]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
Merge branch 'staging-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh...
authorLinus Torvalds <torvalds@linux-foundation.org>
Mon, 23 May 2011 19:49:28 +0000 (12:49 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Mon, 23 May 2011 19:49:28 +0000 (12:49 -0700)
* 'staging-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging-2.6: (970 commits)
  staging: usbip: replace usbip_u{dbg,err,info} and printk with dev_ and pr_
  staging:iio: Trivial kconfig reorganization and uniformity improvements.
  staging:iio:documenation partial update.
  staging:iio: use pollfunc allocation helpers in remaining drivers.
  staging:iio:max1363 misc cleanups and use of for_each_bit_set to simplify event code spitting out.
  staging:iio: implement an iio_info structure to take some of the constant elements out of iio_dev.
  staging:iio:meter:ade7758: Use private data space from iio_allocate_device
  staging:iio:accel:lis3l02dq make write_reg_8 take value not a pointer to value.
  staging:iio: ring core cleanups + check if read_last available in lis3l02dq
  staging:iio:core cleanup: squash tiny wrappers and use dev_set_name to handle creation of event interface name.
  staging:iio: poll func allocation clean up.
  staging:iio:ad7780 trivial unused header cleanup.
  staging:iio:adc: AD7780: Use private data space from iio_allocate_device + trivial fixes
  staging:iio:adc:AD7780: Convert to new channel registration method
  staging:iio:adc: AD7606: Drop dev_data in favour of iio_priv()
  staging:iio:adc: AD7606: Consitently use indio_dev
  staging:iio: Rip out helper for software rings.
  staging:iio:adc:AD7298: Use private data space from iio_allocate_device
  staging:iio: rationalization of different buffer implementation hooks.
  staging:iio:imu:adis16400 avoid allocating rx, tx, and state separately from iio_dev.
  ...

Fix up trivial conflicts in
 - drivers/staging/intel_sst/intelmid.c: patches applied in both branches
 - drivers/staging/rt2860/common/cmm_data_{pci,usb}.c: removed vs spelling
 - drivers/staging/usbip/vhci_sysfs.c: trivial header file inclusion

822 files changed:
drivers/staging/Kconfig
drivers/staging/Makefile
drivers/staging/ath6kl/Kconfig
drivers/staging/ath6kl/Makefile
drivers/staging/ath6kl/bmi/include/bmi_internal.h
drivers/staging/ath6kl/bmi/src/bmi.c
drivers/staging/ath6kl/hif/sdio/linux_sdio/include/hif_internal.h
drivers/staging/ath6kl/hif/sdio/linux_sdio/src/hif.c
drivers/staging/ath6kl/hif/sdio/linux_sdio/src/hif_scatter.c
drivers/staging/ath6kl/htc2/AR6000/ar6k.c
drivers/staging/ath6kl/htc2/AR6000/ar6k.h
drivers/staging/ath6kl/htc2/AR6000/ar6k_events.c
drivers/staging/ath6kl/htc2/AR6000/ar6k_gmbox.c
drivers/staging/ath6kl/htc2/AR6000/ar6k_gmbox_hciuart.c
drivers/staging/ath6kl/htc2/htc.c
drivers/staging/ath6kl/htc2/htc_internal.h
drivers/staging/ath6kl/htc2/htc_recv.c
drivers/staging/ath6kl/htc2/htc_send.c
drivers/staging/ath6kl/include/a_config.h
drivers/staging/ath6kl/include/a_debug.h
drivers/staging/ath6kl/include/a_drv.h
drivers/staging/ath6kl/include/a_drv_api.h
drivers/staging/ath6kl/include/a_osapi.h
drivers/staging/ath6kl/include/a_types.h [deleted file]
drivers/staging/ath6kl/include/ar6000_api.h
drivers/staging/ath6kl/include/athendpack.h [deleted file]
drivers/staging/ath6kl/include/athstartpack.h [deleted file]
drivers/staging/ath6kl/include/bmi.h
drivers/staging/ath6kl/include/common/AR6002/AR6002_regdump.h [deleted file]
drivers/staging/ath6kl/include/common/AR6002/hw2.0/hw/analog_intf_reg.h [deleted file]
drivers/staging/ath6kl/include/common/AR6002/hw2.0/hw/analog_reg.h [deleted file]
drivers/staging/ath6kl/include/common/AR6002/hw2.0/hw/apb_map.h [deleted file]
drivers/staging/ath6kl/include/common/AR6002/hw2.0/hw/gpio_reg.h [deleted file]
drivers/staging/ath6kl/include/common/AR6002/hw2.0/hw/mbox_host_reg.h [deleted file]
drivers/staging/ath6kl/include/common/AR6002/hw2.0/hw/mbox_reg.h [deleted file]
drivers/staging/ath6kl/include/common/AR6002/hw2.0/hw/rtc_reg.h [deleted file]
drivers/staging/ath6kl/include/common/AR6002/hw2.0/hw/si_reg.h [deleted file]
drivers/staging/ath6kl/include/common/AR6002/hw2.0/hw/uart_reg.h [deleted file]
drivers/staging/ath6kl/include/common/AR6002/hw2.0/hw/vmc_reg.h [deleted file]
drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/analog_intf_ares_reg.h [deleted file]
drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/analog_intf_athr_wlan_reg.h [deleted file]
drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/analog_intf_reg.h [deleted file]
drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/apb_map.h
drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/bb_lc_reg.h [deleted file]
drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/efuse_reg.h [deleted file]
drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/gpio_athr_wlan_reg.h [deleted file]
drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/gpio_reg.h [deleted file]
drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/mac_dma_reg.h [deleted file]
drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/mac_pcu_reg.h [deleted file]
drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/mbox_host_reg.h
drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/mbox_reg.h
drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/mbox_wlan_host_reg.h
drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/mbox_wlan_reg.h
drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/rdma_reg.h [deleted file]
drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/rtc_reg.h
drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/rtc_wlan_reg.h
drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/si_reg.h [deleted file]
drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/uart_reg.h
drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/umbox_reg.h [deleted file]
drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/umbox_wlan_reg.h [deleted file]
drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/vmc_reg.h [deleted file]
drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/vmc_wlan_reg.h [deleted file]
drivers/staging/ath6kl/include/common/a_hci.h [deleted file]
drivers/staging/ath6kl/include/common/bmi_msg.h
drivers/staging/ath6kl/include/common/btcoexGpio.h [deleted file]
drivers/staging/ath6kl/include/common/dbglog.h
drivers/staging/ath6kl/include/common/dset_internal.h [deleted file]
drivers/staging/ath6kl/include/common/dsetid.h [deleted file]
drivers/staging/ath6kl/include/common/epping_test.h
drivers/staging/ath6kl/include/common/gmboxif.h
drivers/staging/ath6kl/include/common/gpio.h [deleted file]
drivers/staging/ath6kl/include/common/gpio_reg.h [new file with mode: 0644]
drivers/staging/ath6kl/include/common/htc.h
drivers/staging/ath6kl/include/common/ini_dset.h [deleted file]
drivers/staging/ath6kl/include/common/regDb.h [deleted file]
drivers/staging/ath6kl/include/common/regdump.h [deleted file]
drivers/staging/ath6kl/include/common/regulatory/reg_dbschema.h [deleted file]
drivers/staging/ath6kl/include/common/regulatory/reg_dbvalues.h [deleted file]
drivers/staging/ath6kl/include/common/targaddrs.h
drivers/staging/ath6kl/include/common/wlan_dset.h [deleted file]
drivers/staging/ath6kl/include/common/wmi.h
drivers/staging/ath6kl/include/common/wmi_thin.h [deleted file]
drivers/staging/ath6kl/include/common/wmix.h
drivers/staging/ath6kl/include/common_drv.h
drivers/staging/ath6kl/include/gpio_api.h [deleted file]
drivers/staging/ath6kl/include/hif.h
drivers/staging/ath6kl/include/target_reg_table.h [deleted file]
drivers/staging/ath6kl/miscdrv/ar3kconfig.c
drivers/staging/ath6kl/miscdrv/ar3kps/ar3kpsconfig.c
drivers/staging/ath6kl/miscdrv/ar3kps/ar3kpsparser.c
drivers/staging/ath6kl/miscdrv/ar3kps/ar3kpsparser.h
drivers/staging/ath6kl/miscdrv/common_drv.c
drivers/staging/ath6kl/miscdrv/credit_dist.c
drivers/staging/ath6kl/os/linux/ar6000_android.c [deleted file]
drivers/staging/ath6kl/os/linux/ar6000_drv.c
drivers/staging/ath6kl/os/linux/ar6000_pm.c
drivers/staging/ath6kl/os/linux/ar6k_pal.c [deleted file]
drivers/staging/ath6kl/os/linux/cfg80211.c
drivers/staging/ath6kl/os/linux/eeprom.c [deleted file]
drivers/staging/ath6kl/os/linux/export_hci_transport.c
drivers/staging/ath6kl/os/linux/hci_bridge.c
drivers/staging/ath6kl/os/linux/include/ar6000_drv.h
drivers/staging/ath6kl/os/linux/include/ar6xapi_linux.h
drivers/staging/ath6kl/os/linux/include/athdrv_linux.h
drivers/staging/ath6kl/os/linux/include/athtypes_linux.h [deleted file]
drivers/staging/ath6kl/os/linux/include/config_linux.h
drivers/staging/ath6kl/os/linux/include/osapi_linux.h
drivers/staging/ath6kl/os/linux/include/wlan_config.h
drivers/staging/ath6kl/os/linux/include/wmi_filter_linux.h
drivers/staging/ath6kl/os/linux/ioctl.c [deleted file]
drivers/staging/ath6kl/os/linux/netbuf.c
drivers/staging/ath6kl/os/linux/wireless_ext.c [deleted file]
drivers/staging/ath6kl/reorder/rcv_aggr.c
drivers/staging/ath6kl/wlan/include/ieee80211.h
drivers/staging/ath6kl/wlan/src/wlan_node.c
drivers/staging/ath6kl/wlan/src/wlan_recv_beacon.c
drivers/staging/ath6kl/wlan/src/wlan_utils.c
drivers/staging/ath6kl/wmi/wmi.c
drivers/staging/brcm80211/Kconfig
drivers/staging/brcm80211/Makefile
drivers/staging/brcm80211/README
drivers/staging/brcm80211/TODO
drivers/staging/brcm80211/brcmfmac/Makefile
drivers/staging/brcm80211/brcmfmac/README
drivers/staging/brcm80211/brcmfmac/bcmchip.h [moved from drivers/staging/brcm80211/util/siutils_priv.h with 52% similarity]
drivers/staging/brcm80211/brcmfmac/bcmsdh.c
drivers/staging/brcm80211/brcmfmac/bcmsdh_linux.c
drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c
drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc_linux.c
drivers/staging/brcm80211/brcmfmac/bcmutils.c [deleted file]
drivers/staging/brcm80211/brcmfmac/bcmwifi.c [deleted file]
drivers/staging/brcm80211/brcmfmac/dhd.h
drivers/staging/brcm80211/brcmfmac/dhd_cdc.c
drivers/staging/brcm80211/brcmfmac/dhd_common.c
drivers/staging/brcm80211/brcmfmac/dhd_linux.c
drivers/staging/brcm80211/brcmfmac/dhd_sdio.c
drivers/staging/brcm80211/brcmfmac/hndpmu.c [deleted file]
drivers/staging/brcm80211/brcmfmac/sbutils.c [deleted file]
drivers/staging/brcm80211/brcmfmac/siutils.c [deleted file]
drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c
drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h
drivers/staging/brcm80211/brcmfmac/wl_iw.c
drivers/staging/brcm80211/brcmsmac/Makefile
drivers/staging/brcm80211/brcmsmac/aiutils.c [moved from drivers/staging/brcm80211/util/siutils.c with 55% similarity]
drivers/staging/brcm80211/brcmsmac/aiutils.h [new file with mode: 0644]
drivers/staging/brcm80211/brcmsmac/bcmotp.c [moved from drivers/staging/brcm80211/util/bcmotp.c with 90% similarity]
drivers/staging/brcm80211/brcmsmac/bcmsrom.c [new file with mode: 0644]
drivers/staging/brcm80211/brcmsmac/bcmsrom_tbl.h [moved from drivers/staging/brcm80211/util/bcmsrom_tbl.h with 89% similarity]
drivers/staging/brcm80211/brcmsmac/d11.h
drivers/staging/brcm80211/brcmsmac/hnddma.c [moved from drivers/staging/brcm80211/util/hnddma.c with 94% similarity]
drivers/staging/brcm80211/brcmsmac/nicpci.c [moved from drivers/staging/brcm80211/util/nicpci.c with 92% similarity]
drivers/staging/brcm80211/brcmsmac/nvram.c [moved from drivers/staging/brcm80211/util/nvram/nvram_ro.c with 76% similarity]
drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_cmn.c
drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_hal.h
drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_int.h
drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_lcn.c
drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_n.c
drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_qmath.c [new file with mode: 0644]
drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_qmath.h [moved from drivers/staging/brcm80211/include/qmath.h with 63% similarity]
drivers/staging/brcm80211/brcmsmac/wl_dbg.h
drivers/staging/brcm80211/brcmsmac/wl_export.h
drivers/staging/brcm80211/brcmsmac/wl_mac80211.c
drivers/staging/brcm80211/brcmsmac/wl_mac80211.h
drivers/staging/brcm80211/brcmsmac/wlc_alloc.c
drivers/staging/brcm80211/brcmsmac/wlc_alloc.h
drivers/staging/brcm80211/brcmsmac/wlc_ampdu.c
drivers/staging/brcm80211/brcmsmac/wlc_ampdu.h
drivers/staging/brcm80211/brcmsmac/wlc_antsel.c
drivers/staging/brcm80211/brcmsmac/wlc_bmac.c
drivers/staging/brcm80211/brcmsmac/wlc_bmac.h
drivers/staging/brcm80211/brcmsmac/wlc_bsscfg.h
drivers/staging/brcm80211/brcmsmac/wlc_channel.c
drivers/staging/brcm80211/brcmsmac/wlc_key.h
drivers/staging/brcm80211/brcmsmac/wlc_main.c
drivers/staging/brcm80211/brcmsmac/wlc_main.h
drivers/staging/brcm80211/brcmsmac/wlc_phy_shim.c
drivers/staging/brcm80211/brcmsmac/wlc_pmu.c [moved from drivers/staging/brcm80211/util/hndpmu.c with 67% similarity]
drivers/staging/brcm80211/brcmsmac/wlc_pmu.h [moved from drivers/staging/brcm80211/include/hndpmu.h with 77% similarity]
drivers/staging/brcm80211/brcmsmac/wlc_pub.h
drivers/staging/brcm80211/brcmsmac/wlc_rate.c
drivers/staging/brcm80211/brcmsmac/wlc_rate.h
drivers/staging/brcm80211/brcmsmac/wlc_scb.h
drivers/staging/brcm80211/brcmsmac/wlc_stf.c
drivers/staging/brcm80211/include/aidmp.h
drivers/staging/brcm80211/include/bcmdefs.h
drivers/staging/brcm80211/include/bcmdevs.h
drivers/staging/brcm80211/include/bcmnvram.h
drivers/staging/brcm80211/include/bcmsdpcm.h
drivers/staging/brcm80211/include/bcmsrom_fmt.h
drivers/staging/brcm80211/include/bcmutils.h
drivers/staging/brcm80211/include/bcmwifi.h
drivers/staging/brcm80211/include/hnddma.h
drivers/staging/brcm80211/include/pci_core.h [moved from drivers/staging/brcm80211/util/pci_core.h with 100% similarity]
drivers/staging/brcm80211/include/pcicfg.h
drivers/staging/brcm80211/include/sbchipc.h
drivers/staging/brcm80211/include/siutils.h [deleted file]
drivers/staging/brcm80211/include/wlioctl.h
drivers/staging/brcm80211/util/Makefile [new file with mode: 0644]
drivers/staging/brcm80211/util/aiutils.c [deleted file]
drivers/staging/brcm80211/util/bcmsrom.c [deleted file]
drivers/staging/brcm80211/util/bcmutils.c
drivers/staging/brcm80211/util/bcmwifi.c
drivers/staging/brcm80211/util/qmath.c [deleted file]
drivers/staging/brcm80211/util/sbpcmcia.h [deleted file]
drivers/staging/brcm80211/util/sbsocram.h [deleted file]
drivers/staging/brcm80211/util/sbutils.c [deleted file]
drivers/staging/comedi/drivers/addi-data/APCI1710_Ssi.c
drivers/staging/comedi/drivers/addi-data/addi_common.c
drivers/staging/comedi/drivers/addi-data/addi_common.h
drivers/staging/comedi/drivers/addi-data/addi_eeprom.c
drivers/staging/comedi/drivers/addi-data/hwdrv_apci16xx.c
drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
drivers/staging/comedi/drivers/addi-data/hwdrv_apci3xxx.c
drivers/staging/comedi/drivers/adl_pci9118.c
drivers/staging/comedi/drivers/adv_pci_dio.c
drivers/staging/comedi/drivers/cb_pcidda.c
drivers/staging/comedi/drivers/cb_pcimdas.c
drivers/staging/comedi/drivers/jr3_pci.c
drivers/staging/comedi/drivers/ni_660x.c
drivers/staging/comedi/drivers/ni_mio_common.c
drivers/staging/comedi/drivers/ni_tio.c
drivers/staging/comedi/drivers/pcl724.c
drivers/staging/comedi/drivers/pcl818.c
drivers/staging/comedi/drivers/pcm3724.c
drivers/staging/comedi/drivers/usbdux.c
drivers/staging/comedi/drivers/vmk80xx.c
drivers/staging/cptm1217/clearpad_tm1217.c
drivers/staging/crystalhd/bc_dts_types.h
drivers/staging/crystalhd/crystalhd_misc.c
drivers/staging/cx25821/cx25821-video.c
drivers/staging/easycap/easycap_main.c
drivers/staging/echo/echo.c
drivers/staging/ft1000/ft1000-usb/ft1000_hw.c
drivers/staging/ft1000/ft1000-usb/ft1000_usb.h
drivers/staging/gma500/Makefile
drivers/staging/gma500/mrst.h [new file with mode: 0644]
drivers/staging/gma500/mrst_crtc.c [new file with mode: 0644]
drivers/staging/gma500/mrst_lvds.c [new file with mode: 0644]
drivers/staging/gma500/psb_2d.c
drivers/staging/gma500/psb_bl.c
drivers/staging/gma500/psb_buffer.c [deleted file]
drivers/staging/gma500/psb_drm.h
drivers/staging/gma500/psb_drv.c
drivers/staging/gma500/psb_drv.h
drivers/staging/gma500/psb_fb.c
drivers/staging/gma500/psb_fb.h
drivers/staging/gma500/psb_fence.c [deleted file]
drivers/staging/gma500/psb_gem.c [new file with mode: 0644]
drivers/staging/gma500/psb_gtt.c
drivers/staging/gma500/psb_gtt.h
drivers/staging/gma500/psb_intel_display.c
drivers/staging/gma500/psb_intel_drv.h
drivers/staging/gma500/psb_intel_lvds.c
drivers/staging/gma500/psb_intel_sdvo.c
drivers/staging/gma500/psb_irq.c
drivers/staging/gma500/psb_lid.c [moved from drivers/staging/gma500/psb_reset.c with 100% similarity]
drivers/staging/gma500/psb_mmu.c
drivers/staging/gma500/psb_powermgmt.c
drivers/staging/gma500/psb_powermgmt.h
drivers/staging/gma500/psb_pvr_glue.c [deleted file]
drivers/staging/gma500/psb_pvr_glue.h [deleted file]
drivers/staging/gma500/psb_sgx.c [deleted file]
drivers/staging/gma500/psb_sgx.h [deleted file]
drivers/staging/gma500/psb_ttm_fence.c [deleted file]
drivers/staging/gma500/psb_ttm_fence_api.h [deleted file]
drivers/staging/gma500/psb_ttm_fence_driver.h [deleted file]
drivers/staging/gma500/psb_ttm_fence_user.c [deleted file]
drivers/staging/gma500/psb_ttm_fence_user.h [deleted file]
drivers/staging/gma500/psb_ttm_glue.c [deleted file]
drivers/staging/gma500/psb_ttm_placement_user.c [deleted file]
drivers/staging/gma500/psb_ttm_placement_user.h [deleted file]
drivers/staging/gma500/psb_ttm_userobj_api.h [deleted file]
drivers/staging/hv/Kconfig
drivers/staging/hv/Makefile
drivers/staging/hv/blkvsc.c [deleted file]
drivers/staging/hv/blkvsc_drv.c
drivers/staging/hv/channel.c
drivers/staging/hv/channel.h [deleted file]
drivers/staging/hv/channel_mgmt.c
drivers/staging/hv/channel_mgmt.h [deleted file]
drivers/staging/hv/connection.c
drivers/staging/hv/hv.c
drivers/staging/hv/hv.h [deleted file]
drivers/staging/hv/hv_api.h [deleted file]
drivers/staging/hv/hv_kvp.c
drivers/staging/hv/hv_mouse.c
drivers/staging/hv/hv_timesource.c
drivers/staging/hv/hv_util.c
drivers/staging/hv/hyperv.h [new file with mode: 0644]
drivers/staging/hv/hyperv_net.h [moved from drivers/staging/hv/rndis.h with 65% similarity]
drivers/staging/hv/hyperv_storage.h [moved from drivers/staging/hv/vstorage.h with 63% similarity]
drivers/staging/hv/hyperv_vmbus.h [new file with mode: 0644]
drivers/staging/hv/logging.h [deleted file]
drivers/staging/hv/netvsc.c
drivers/staging/hv/netvsc.h [deleted file]
drivers/staging/hv/netvsc_api.h [deleted file]
drivers/staging/hv/netvsc_drv.c
drivers/staging/hv/ring_buffer.c
drivers/staging/hv/ring_buffer.h [deleted file]
drivers/staging/hv/rndis_filter.c
drivers/staging/hv/rndis_filter.h [deleted file]
drivers/staging/hv/storvsc.c
drivers/staging/hv/storvsc_api.h [deleted file]
drivers/staging/hv/storvsc_drv.c
drivers/staging/hv/utils.h [deleted file]
drivers/staging/hv/version_info.h [deleted file]
drivers/staging/hv/vmbus.h [deleted file]
drivers/staging/hv/vmbus_api.h [deleted file]
drivers/staging/hv/vmbus_channel_interface.h [deleted file]
drivers/staging/hv/vmbus_drv.c
drivers/staging/hv/vmbus_packet_format.h [deleted file]
drivers/staging/hv/vmbus_private.h [deleted file]
drivers/staging/iio/Documentation/device.txt
drivers/staging/iio/Documentation/generic_buffer.c
drivers/staging/iio/Documentation/iio_utils.h
drivers/staging/iio/Documentation/overview.txt
drivers/staging/iio/Documentation/ring.txt
drivers/staging/iio/Documentation/sysfs-bus-iio
drivers/staging/iio/Documentation/sysfs-bus-iio-light
drivers/staging/iio/Documentation/sysfs-bus-iio-light-tsl2583 [new file with mode: 0644]
drivers/staging/iio/Documentation/trigger.txt
drivers/staging/iio/Documentation/userspace.txt [deleted file]
drivers/staging/iio/Kconfig
drivers/staging/iio/accel/adis16201.h
drivers/staging/iio/accel/adis16201_core.c
drivers/staging/iio/accel/adis16201_ring.c
drivers/staging/iio/accel/adis16201_trigger.c
drivers/staging/iio/accel/adis16203.h
drivers/staging/iio/accel/adis16203_core.c
drivers/staging/iio/accel/adis16203_ring.c
drivers/staging/iio/accel/adis16203_trigger.c
drivers/staging/iio/accel/adis16204.h
drivers/staging/iio/accel/adis16204_core.c
drivers/staging/iio/accel/adis16204_ring.c
drivers/staging/iio/accel/adis16204_trigger.c
drivers/staging/iio/accel/adis16209.h
drivers/staging/iio/accel/adis16209_core.c
drivers/staging/iio/accel/adis16209_ring.c
drivers/staging/iio/accel/adis16209_trigger.c
drivers/staging/iio/accel/adis16220_core.c
drivers/staging/iio/accel/adis16240.h
drivers/staging/iio/accel/adis16240_core.c
drivers/staging/iio/accel/adis16240_ring.c
drivers/staging/iio/accel/adis16240_trigger.c
drivers/staging/iio/accel/kxsd9.c
drivers/staging/iio/accel/lis3l02dq.h
drivers/staging/iio/accel/lis3l02dq_core.c
drivers/staging/iio/accel/lis3l02dq_ring.c
drivers/staging/iio/accel/sca3000.h
drivers/staging/iio/accel/sca3000_core.c
drivers/staging/iio/accel/sca3000_ring.c
drivers/staging/iio/adc/Kconfig
drivers/staging/iio/adc/Makefile
drivers/staging/iio/adc/ad7150.c
drivers/staging/iio/adc/ad7152.c
drivers/staging/iio/adc/ad7291.c
drivers/staging/iio/adc/ad7298.h
drivers/staging/iio/adc/ad7298_core.c
drivers/staging/iio/adc/ad7298_ring.c
drivers/staging/iio/adc/ad7314.c
drivers/staging/iio/adc/ad7476.h
drivers/staging/iio/adc/ad7476_core.c
drivers/staging/iio/adc/ad7476_ring.c
drivers/staging/iio/adc/ad7606.h
drivers/staging/iio/adc/ad7606_core.c
drivers/staging/iio/adc/ad7606_par.c
drivers/staging/iio/adc/ad7606_ring.c
drivers/staging/iio/adc/ad7606_spi.c
drivers/staging/iio/adc/ad7745.c
drivers/staging/iio/adc/ad7780.c [new file with mode: 0644]
drivers/staging/iio/adc/ad7780.h [new file with mode: 0644]
drivers/staging/iio/adc/ad7816.c
drivers/staging/iio/adc/ad7887.h
drivers/staging/iio/adc/ad7887_core.c
drivers/staging/iio/adc/ad7887_ring.c
drivers/staging/iio/adc/ad799x.h
drivers/staging/iio/adc/ad799x_core.c
drivers/staging/iio/adc/ad799x_ring.c
drivers/staging/iio/adc/adt7310.c
drivers/staging/iio/adc/adt7410.c
drivers/staging/iio/adc/adt75.c
drivers/staging/iio/adc/max1363.h
drivers/staging/iio/adc/max1363_core.c
drivers/staging/iio/adc/max1363_ring.c
drivers/staging/iio/addac/adt7316.c
drivers/staging/iio/chrdev.h
drivers/staging/iio/dac/Kconfig
drivers/staging/iio/dac/Makefile
drivers/staging/iio/dac/ad5446.c
drivers/staging/iio/dac/ad5446.h
drivers/staging/iio/dac/ad5504.c [new file with mode: 0644]
drivers/staging/iio/dac/ad5504.h [new file with mode: 0644]
drivers/staging/iio/dac/ad5624r_spi.c
drivers/staging/iio/dac/ad5791.c [new file with mode: 0644]
drivers/staging/iio/dac/ad5791.h [new file with mode: 0644]
drivers/staging/iio/dac/max517.c
drivers/staging/iio/dds/Kconfig
drivers/staging/iio/dds/ad5930.c
drivers/staging/iio/dds/ad9832.c
drivers/staging/iio/dds/ad9834.c
drivers/staging/iio/dds/ad9834.h
drivers/staging/iio/dds/ad9850.c
drivers/staging/iio/dds/ad9852.c
drivers/staging/iio/dds/ad9910.c
drivers/staging/iio/dds/ad9951.c
drivers/staging/iio/gyro/Kconfig
drivers/staging/iio/gyro/Makefile
drivers/staging/iio/gyro/adis16060_core.c
drivers/staging/iio/gyro/adis16080_core.c
drivers/staging/iio/gyro/adis16130_core.c
drivers/staging/iio/gyro/adis16260.h
drivers/staging/iio/gyro/adis16260_core.c
drivers/staging/iio/gyro/adis16260_ring.c
drivers/staging/iio/gyro/adis16260_trigger.c
drivers/staging/iio/gyro/adxrs450.h [new file with mode: 0644]
drivers/staging/iio/gyro/adxrs450_core.c [new file with mode: 0644]
drivers/staging/iio/gyro/gyro.h
drivers/staging/iio/iio.h
drivers/staging/iio/imu/Kconfig
drivers/staging/iio/imu/Makefile
drivers/staging/iio/imu/adis16300.h [deleted file]
drivers/staging/iio/imu/adis16300_core.c [deleted file]
drivers/staging/iio/imu/adis16300_ring.c [deleted file]
drivers/staging/iio/imu/adis16300_trigger.c [deleted file]
drivers/staging/iio/imu/adis16350.h [deleted file]
drivers/staging/iio/imu/adis16350_core.c [deleted file]
drivers/staging/iio/imu/adis16350_ring.c [deleted file]
drivers/staging/iio/imu/adis16350_trigger.c [deleted file]
drivers/staging/iio/imu/adis16400.h
drivers/staging/iio/imu/adis16400_core.c
drivers/staging/iio/imu/adis16400_ring.c
drivers/staging/iio/imu/adis16400_trigger.c
drivers/staging/iio/industrialio-core.c
drivers/staging/iio/industrialio-ring.c
drivers/staging/iio/industrialio-trigger.c
drivers/staging/iio/kfifo_buf.c
drivers/staging/iio/kfifo_buf.h
drivers/staging/iio/light/Kconfig
drivers/staging/iio/light/Makefile
drivers/staging/iio/light/isl29018.c
drivers/staging/iio/light/tsl2563.c
drivers/staging/iio/light/tsl2583.c [new file with mode: 0644]
drivers/staging/iio/magnetometer/ak8975.c
drivers/staging/iio/magnetometer/hmc5843.c
drivers/staging/iio/meter/ade7753.c
drivers/staging/iio/meter/ade7754.c
drivers/staging/iio/meter/ade7758.h
drivers/staging/iio/meter/ade7758_core.c
drivers/staging/iio/meter/ade7758_ring.c
drivers/staging/iio/meter/ade7758_trigger.c
drivers/staging/iio/meter/ade7759.c
drivers/staging/iio/meter/ade7854.c
drivers/staging/iio/resolver/ad2s120x.c
drivers/staging/iio/resolver/ad2s1210.c
drivers/staging/iio/resolver/ad2s90.c
drivers/staging/iio/ring_generic.h
drivers/staging/iio/ring_sw.c
drivers/staging/iio/ring_sw.h
drivers/staging/iio/sysfs.h
drivers/staging/iio/trigger.h
drivers/staging/iio/trigger/Kconfig
drivers/staging/iio/trigger/iio-trig-bfin-timer.c
drivers/staging/iio/trigger/iio-trig-gpio.c
drivers/staging/iio/trigger/iio-trig-periodic-rtc.c
drivers/staging/iio/trigger/iio-trig-sysfs.c
drivers/staging/intel_sst/intel_sst.c
drivers/staging/intel_sst/intel_sst.h
drivers/staging/intel_sst/intel_sst_app_interface.c
drivers/staging/intel_sst/intel_sst_common.h
drivers/staging/intel_sst/intel_sst_drv_interface.c
drivers/staging/intel_sst/intel_sst_dsp.c
drivers/staging/intel_sst/intel_sst_fw_ipc.h
drivers/staging/intel_sst/intel_sst_ioctl.h
drivers/staging/intel_sst/intel_sst_ipc.c
drivers/staging/intel_sst/intel_sst_pvt.c
drivers/staging/intel_sst/intel_sst_stream.c
drivers/staging/intel_sst/intel_sst_stream_encoded.c
drivers/staging/intel_sst/intelmid.c
drivers/staging/intel_sst/intelmid.h
drivers/staging/intel_sst/intelmid_adc_control.h [new file with mode: 0644]
drivers/staging/intel_sst/intelmid_ctrl.c
drivers/staging/intel_sst/intelmid_msic_control.c
drivers/staging/intel_sst/intelmid_pvt.c
drivers/staging/intel_sst/intelmid_snd_control.h
drivers/staging/intel_sst/intelmid_v0_control.c
drivers/staging/intel_sst/intelmid_v1_control.c
drivers/staging/intel_sst/intelmid_v2_control.c
drivers/staging/intel_sst/jack.h [deleted file]
drivers/staging/keucr/common.h
drivers/staging/keucr/init.c
drivers/staging/keucr/init.h
drivers/staging/keucr/ms.c
drivers/staging/keucr/ms.h
drivers/staging/keucr/msscsi.c
drivers/staging/keucr/scsiglue.c
drivers/staging/keucr/smcommon.h
drivers/staging/keucr/smil.h
drivers/staging/keucr/smilecc.c
drivers/staging/keucr/smilmain.c
drivers/staging/keucr/smilsub.c
drivers/staging/keucr/smscsi.c
drivers/staging/keucr/transport.c
drivers/staging/keucr/transport.h
drivers/staging/keucr/usb.c
drivers/staging/line6/driver.c
drivers/staging/lirc/lirc_parallel.c
drivers/staging/lirc/lirc_serial.c
drivers/staging/lirc/lirc_sir.c
drivers/staging/mei/Kconfig [new file with mode: 0644]
drivers/staging/mei/Makefile [new file with mode: 0644]
drivers/staging/mei/TODO [new file with mode: 0644]
drivers/staging/mei/hw.h [new file with mode: 0644]
drivers/staging/mei/init.c [new file with mode: 0644]
drivers/staging/mei/interface.c [new file with mode: 0644]
drivers/staging/mei/interface.h [new file with mode: 0644]
drivers/staging/mei/interrupt.c [new file with mode: 0644]
drivers/staging/mei/iorw.c [new file with mode: 0644]
drivers/staging/mei/main.c [new file with mode: 0644]
drivers/staging/mei/mei.h [new file with mode: 0644]
drivers/staging/mei/mei.txt [new file with mode: 0644]
drivers/staging/mei/mei_dev.h [new file with mode: 0644]
drivers/staging/mei/mei_version.h [new file with mode: 0644]
drivers/staging/mei/wd.c [new file with mode: 0644]
drivers/staging/nvec/Kconfig [new file with mode: 0644]
drivers/staging/nvec/Makefile [new file with mode: 0644]
drivers/staging/nvec/README [new file with mode: 0644]
drivers/staging/nvec/TODO [new file with mode: 0644]
drivers/staging/nvec/nvec-keytable.h [new file with mode: 0644]
drivers/staging/nvec/nvec.c [new file with mode: 0644]
drivers/staging/nvec/nvec.h [new file with mode: 0644]
drivers/staging/nvec/nvec_kbd.c [new file with mode: 0644]
drivers/staging/nvec/nvec_power.c [new file with mode: 0644]
drivers/staging/nvec/nvec_ps2.c [new file with mode: 0644]
drivers/staging/octeon/ethernet-mdio.c
drivers/staging/olpc_dcon/olpc_dcon_xo_1.c
drivers/staging/olpc_dcon/olpc_dcon_xo_1_5.c
drivers/staging/rt2860/Kconfig [deleted file]
drivers/staging/rt2860/Makefile [deleted file]
drivers/staging/rt2860/TODO [deleted file]
drivers/staging/rt2860/ap.h [deleted file]
drivers/staging/rt2860/chip/mac_pci.h [deleted file]
drivers/staging/rt2860/chip/mac_usb.h [deleted file]
drivers/staging/rt2860/chip/rt2860.h [deleted file]
drivers/staging/rt2860/chip/rt2870.h [deleted file]
drivers/staging/rt2860/chip/rt3070.h [deleted file]
drivers/staging/rt2860/chip/rt3090.h [deleted file]
drivers/staging/rt2860/chip/rt30xx.h [deleted file]
drivers/staging/rt2860/chip/rtmp_mac.h [deleted file]
drivers/staging/rt2860/chip/rtmp_phy.h [deleted file]
drivers/staging/rt2860/chips/rt3070.c [deleted file]
drivers/staging/rt2860/chips/rt3090.c [deleted file]
drivers/staging/rt2860/chips/rt30xx.c [deleted file]
drivers/staging/rt2860/chlist.h [deleted file]
drivers/staging/rt2860/common/action.c [deleted file]
drivers/staging/rt2860/common/action.h [deleted file]
drivers/staging/rt2860/common/ba_action.c [deleted file]
drivers/staging/rt2860/common/cmm_aes.c [deleted file]
drivers/staging/rt2860/common/cmm_asic.c [deleted file]
drivers/staging/rt2860/common/cmm_cfg.c [deleted file]
drivers/staging/rt2860/common/cmm_data.c [deleted file]
drivers/staging/rt2860/common/cmm_data_pci.c [deleted file]
drivers/staging/rt2860/common/cmm_data_usb.c [deleted file]
drivers/staging/rt2860/common/cmm_info.c [deleted file]
drivers/staging/rt2860/common/cmm_mac_pci.c [deleted file]
drivers/staging/rt2860/common/cmm_mac_usb.c [deleted file]
drivers/staging/rt2860/common/cmm_sanity.c [deleted file]
drivers/staging/rt2860/common/cmm_sync.c [deleted file]
drivers/staging/rt2860/common/cmm_tkip.c [deleted file]
drivers/staging/rt2860/common/cmm_wep.c [deleted file]
drivers/staging/rt2860/common/cmm_wpa.c [deleted file]
drivers/staging/rt2860/common/crypt_hmac.c [deleted file]
drivers/staging/rt2860/common/crypt_md5.c [deleted file]
drivers/staging/rt2860/common/crypt_sha2.c [deleted file]
drivers/staging/rt2860/common/dfs.c [deleted file]
drivers/staging/rt2860/common/ee_efuse.c [deleted file]
drivers/staging/rt2860/common/ee_prom.c [deleted file]
drivers/staging/rt2860/common/eeprom.c [deleted file]
drivers/staging/rt2860/common/mlme.c [deleted file]
drivers/staging/rt2860/common/rt_channel.c [deleted file]
drivers/staging/rt2860/common/rt_rf.c [deleted file]
drivers/staging/rt2860/common/rtmp_init.c [deleted file]
drivers/staging/rt2860/common/rtmp_mcu.c [deleted file]
drivers/staging/rt2860/common/rtmp_timer.c [deleted file]
drivers/staging/rt2860/common/spectrum.c [deleted file]
drivers/staging/rt2860/crypt_hmac.h [deleted file]
drivers/staging/rt2860/crypt_md5.h [deleted file]
drivers/staging/rt2860/crypt_sha2.h [deleted file]
drivers/staging/rt2860/dfs.h [deleted file]
drivers/staging/rt2860/eeprom.h [deleted file]
drivers/staging/rt2860/iface/rtmp_pci.h [deleted file]
drivers/staging/rt2860/iface/rtmp_usb.h [deleted file]
drivers/staging/rt2860/mlme.h [deleted file]
drivers/staging/rt2860/oid.h [deleted file]
drivers/staging/rt2860/pci_main_dev.c [deleted file]
drivers/staging/rt2860/rt_config.h [deleted file]
drivers/staging/rt2860/rt_linux.c [deleted file]
drivers/staging/rt2860/rt_linux.h [deleted file]
drivers/staging/rt2860/rt_main_dev.c [deleted file]
drivers/staging/rt2860/rt_pci_rbus.c [deleted file]
drivers/staging/rt2860/rt_usb.c [deleted file]
drivers/staging/rt2860/rtmp.h [deleted file]
drivers/staging/rt2860/rtmp_chip.h [deleted file]
drivers/staging/rt2860/rtmp_ckipmic.h [deleted file]
drivers/staging/rt2860/rtmp_def.h [deleted file]
drivers/staging/rt2860/rtmp_dot11.h [deleted file]
drivers/staging/rt2860/rtmp_iface.h [deleted file]
drivers/staging/rt2860/rtmp_mcu.h [deleted file]
drivers/staging/rt2860/rtmp_os.h [deleted file]
drivers/staging/rt2860/rtmp_timer.h [deleted file]
drivers/staging/rt2860/rtmp_type.h [deleted file]
drivers/staging/rt2860/rtusb_io.h [deleted file]
drivers/staging/rt2860/spectrum.h [deleted file]
drivers/staging/rt2860/spectrum_def.h [deleted file]
drivers/staging/rt2860/sta/assoc.c [deleted file]
drivers/staging/rt2860/sta/auth.c [deleted file]
drivers/staging/rt2860/sta/auth_rsp.c [deleted file]
drivers/staging/rt2860/sta/connect.c [deleted file]
drivers/staging/rt2860/sta/rtmp_data.c [deleted file]
drivers/staging/rt2860/sta/sanity.c [deleted file]
drivers/staging/rt2860/sta/sync.c [deleted file]
drivers/staging/rt2860/sta/wpa.c [deleted file]
drivers/staging/rt2860/sta_ioctl.c [deleted file]
drivers/staging/rt2860/usb_main_dev.c [deleted file]
drivers/staging/rt2860/wpa.h [deleted file]
drivers/staging/rt2870/Kconfig [deleted file]
drivers/staging/rt2870/Makefile [deleted file]
drivers/staging/rt2870/TODO [deleted file]
drivers/staging/rt2870/aironet.h [deleted file]
drivers/staging/rt2870/ap.h [deleted file]
drivers/staging/rt2870/chips/rt3070.c [deleted file]
drivers/staging/rt2870/chips/rt30xx.c [deleted file]
drivers/staging/rt2870/chlist.h [deleted file]
drivers/staging/rt2870/common/acction.c [deleted file]
drivers/staging/rt2870/common/action.c [deleted file]
drivers/staging/rt2870/common/action.h [deleted file]
drivers/staging/rt2870/common/ba_action.c [deleted file]
drivers/staging/rt2870/common/cmm_aes.c [deleted file]
drivers/staging/rt2870/common/cmm_asic.c [deleted file]
drivers/staging/rt2870/common/cmm_cfg.c [deleted file]
drivers/staging/rt2870/common/cmm_data.c [deleted file]
drivers/staging/rt2870/common/cmm_data_usb.c [deleted file]
drivers/staging/rt2870/common/cmm_info.c [deleted file]
drivers/staging/rt2870/common/cmm_mac_usb.c [deleted file]
drivers/staging/rt2870/common/cmm_profile.c [deleted file]
drivers/staging/rt2870/common/cmm_sanity.c [deleted file]
drivers/staging/rt2870/common/cmm_sync.c [deleted file]
drivers/staging/rt2870/common/cmm_tkip.c [deleted file]
drivers/staging/rt2870/common/cmm_wep.c [deleted file]
drivers/staging/rt2870/common/cmm_wpa.c [deleted file]
drivers/staging/rt2870/common/crypt_hmac.c [deleted file]
drivers/staging/rt2870/common/crypt_md5.c [deleted file]
drivers/staging/rt2870/common/crypt_sha2.c [deleted file]
drivers/staging/rt2870/common/dfs.c [deleted file]
drivers/staging/rt2870/common/ee_efuse.c [deleted file]
drivers/staging/rt2870/common/eeprom.c [deleted file]
drivers/staging/rt2870/common/md5.c [deleted file]
drivers/staging/rt2870/common/mlme.c [deleted file]
drivers/staging/rt2870/common/rt_channel.c [deleted file]
drivers/staging/rt2870/common/rt_rf.c [deleted file]
drivers/staging/rt2870/common/rtmp_init.c [deleted file]
drivers/staging/rt2870/common/rtmp_mcu.c [deleted file]
drivers/staging/rt2870/common/rtmp_timer.c [deleted file]
drivers/staging/rt2870/common/rtmp_tkip.c [deleted file]
drivers/staging/rt2870/common/rtmp_wep.c [deleted file]
drivers/staging/rt2870/common/rtusb_bulk.c [deleted file]
drivers/staging/rt2870/common/rtusb_data.c [deleted file]
drivers/staging/rt2870/common/rtusb_io.c [deleted file]
drivers/staging/rt2870/common/spectrum.c [deleted file]
drivers/staging/rt2870/dfs.h [deleted file]
drivers/staging/rt2870/md5.h [deleted file]
drivers/staging/rt2870/mlme.h [deleted file]
drivers/staging/rt2870/oid.h [deleted file]
drivers/staging/rt2870/rt28xx.h [deleted file]
drivers/staging/rt2870/rt_config.h [deleted file]
drivers/staging/rt2870/rt_linux.c [deleted file]
drivers/staging/rt2870/rt_linux.h [deleted file]
drivers/staging/rt2870/rt_main_dev.c [deleted file]
drivers/staging/rt2870/rt_profile.c [deleted file]
drivers/staging/rt2870/rt_usb.c [deleted file]
drivers/staging/rt2870/rtmp.h [deleted file]
drivers/staging/rt2870/rtmp_ckipmic.h [deleted file]
drivers/staging/rt2870/rtmp_def.h [deleted file]
drivers/staging/rt2870/rtmp_type.h [deleted file]
drivers/staging/rt2870/spectrum.h [deleted file]
drivers/staging/rt2870/spectrum_def.h [deleted file]
drivers/staging/rt2870/sta/aironet.c [deleted file]
drivers/staging/rt2870/sta/assoc.c [deleted file]
drivers/staging/rt2870/sta/auth.c [deleted file]
drivers/staging/rt2870/sta/auth_rsp.c [deleted file]
drivers/staging/rt2870/sta/connect.c [deleted file]
drivers/staging/rt2870/sta/rtmp_data.c [deleted file]
drivers/staging/rt2870/sta/sanity.c [deleted file]
drivers/staging/rt2870/sta/sync.c [deleted file]
drivers/staging/rt2870/sta/wpa.c [deleted file]
drivers/staging/rt2870/sta_ioctl.c [deleted file]
drivers/staging/rt2870/usb_main_dev.c [deleted file]
drivers/staging/rt2870/wpa.h [deleted file]
drivers/staging/rtl8712/ieee80211.h
drivers/staging/rtl8712/if_ether.h
drivers/staging/rtl8712/ip.h
drivers/staging/rtl8712/mlme_osdep.h
drivers/staging/rtl8712/osdep_service.h
drivers/staging/rtl8712/recv_osdep.h
drivers/staging/rtl8712/rtl8712_event.h
drivers/staging/rtl8712/rtl8712_hal.h
drivers/staging/rtl8712/rtl8712_led.c
drivers/staging/rtl8712/rtl8712_recv.c
drivers/staging/rtl8712/rtl8712_recv.h
drivers/staging/rtl8712/rtl8712_xmit.h
drivers/staging/rtl8712/rtl871x_cmd.c
drivers/staging/rtl8712/rtl871x_cmd.h
drivers/staging/rtl8712/rtl871x_event.h
drivers/staging/rtl8712/rtl871x_io.c
drivers/staging/rtl8712/rtl871x_ioctl_linux.c
drivers/staging/rtl8712/rtl871x_ioctl_rtl.c
drivers/staging/rtl8712/rtl871x_ioctl_set.c
drivers/staging/rtl8712/rtl871x_ioctl_set.h
drivers/staging/rtl8712/rtl871x_mp.c
drivers/staging/rtl8712/rtl871x_mp_ioctl.h
drivers/staging/rtl8712/rtl871x_recv.c
drivers/staging/rtl8712/rtl871x_recv.h
drivers/staging/rtl8712/rtl871x_rf.h
drivers/staging/rtl8712/rtl871x_security.h
drivers/staging/rtl8712/rtl871x_xmit.c
drivers/staging/rtl8712/rtl871x_xmit.h
drivers/staging/rtl8712/wifi.h
drivers/staging/rtl8712/wlan_bssdef.h
drivers/staging/rts_pstor/ms.c
drivers/staging/rts_pstor/rtsx.c
drivers/staging/rts_pstor/rtsx.h
drivers/staging/rts_pstor/sd.c
drivers/staging/rts_pstor/spi.c
drivers/staging/rts_pstor/xd.c
drivers/staging/sbe-2t3e3/dc.c
drivers/staging/sep/sep_driver.c
drivers/staging/sm7xx/TODO
drivers/staging/sm7xx/smtcfb.c
drivers/staging/sm7xx/smtcfb.h
drivers/staging/tty/istallion.c
drivers/staging/usbip/Kconfig
drivers/staging/usbip/Makefile
drivers/staging/usbip/stub.h
drivers/staging/usbip/stub_dev.c
drivers/staging/usbip/stub_main.c
drivers/staging/usbip/stub_rx.c
drivers/staging/usbip/stub_tx.c
drivers/staging/usbip/usbip_common.c
drivers/staging/usbip/usbip_common.h
drivers/staging/usbip/usbip_event.c
drivers/staging/usbip/userspace/AUTHORS [new file with mode: 0644]
drivers/staging/usbip/userspace/COPYING [new file with mode: 0644]
drivers/staging/usbip/userspace/INSTALL [new file with mode: 0644]
drivers/staging/usbip/userspace/Makefile.am [new file with mode: 0644]
drivers/staging/usbip/userspace/README [new file with mode: 0644]
drivers/staging/usbip/userspace/autogen.sh [new file with mode: 0755]
drivers/staging/usbip/userspace/cleanup.sh [new file with mode: 0755]
drivers/staging/usbip/userspace/configure.ac [new file with mode: 0644]
drivers/staging/usbip/userspace/doc/usbip.8 [new file with mode: 0644]
drivers/staging/usbip/userspace/doc/usbip_bind_driver.8 [new file with mode: 0644]
drivers/staging/usbip/userspace/doc/usbipd.8 [new file with mode: 0644]
drivers/staging/usbip/userspace/libsrc/Makefile.am [new file with mode: 0644]
drivers/staging/usbip/userspace/libsrc/names.c [new file with mode: 0644]
drivers/staging/usbip/userspace/libsrc/names.h [new file with mode: 0644]
drivers/staging/usbip/userspace/libsrc/stub_driver.c [new file with mode: 0644]
drivers/staging/usbip/userspace/libsrc/stub_driver.h [new file with mode: 0644]
drivers/staging/usbip/userspace/libsrc/usbip.h [new file with mode: 0644]
drivers/staging/usbip/userspace/libsrc/usbip_common.c [new file with mode: 0644]
drivers/staging/usbip/userspace/libsrc/usbip_common.h [new file with mode: 0644]
drivers/staging/usbip/userspace/libsrc/vhci_driver.c [new file with mode: 0644]
drivers/staging/usbip/userspace/libsrc/vhci_driver.h [new file with mode: 0644]
drivers/staging/usbip/userspace/src/Makefile.am [new file with mode: 0644]
drivers/staging/usbip/userspace/src/bind-driver.c [new file with mode: 0644]
drivers/staging/usbip/userspace/src/usbip.c [new file with mode: 0644]
drivers/staging/usbip/userspace/src/usbip_network.c [new file with mode: 0644]
drivers/staging/usbip/userspace/src/usbip_network.h [new file with mode: 0644]
drivers/staging/usbip/userspace/src/usbipd.c [new file with mode: 0644]
drivers/staging/usbip/userspace/src/utils.c [new file with mode: 0644]
drivers/staging/usbip/userspace/src/utils.h [new file with mode: 0644]
drivers/staging/usbip/userspace/usb.ids [new file with mode: 0644]
drivers/staging/usbip/vhci.h
drivers/staging/usbip/vhci_hcd.c
drivers/staging/usbip/vhci_rx.c
drivers/staging/usbip/vhci_sysfs.c
drivers/staging/usbip/vhci_tx.c
drivers/staging/vt6655/bssdb.c
drivers/staging/vt6655/device.h
drivers/staging/vt6655/device_main.c
drivers/staging/vt6655/dpc.c
drivers/staging/vt6655/ioctl.c
drivers/staging/vt6655/power.c
drivers/staging/vt6655/rxtx.c
drivers/staging/vt6655/wcmd.c
drivers/staging/vt6655/wmgr.c
drivers/staging/vt6655/wpactl.c
drivers/staging/vt6656/bssdb.c
drivers/staging/vt6656/dpc.c
drivers/staging/vt6656/ioctl.c
drivers/staging/vt6656/main_usb.c
drivers/staging/vt6656/rxtx.c
drivers/staging/vt6656/wcmd.c
drivers/staging/vt6656/wmgr.c
drivers/staging/vt6656/wpactl.c
drivers/staging/westbridge/astoria/arch/arm/mach-omap2/cyashalomap_kernel.c
drivers/staging/westbridge/astoria/block/cyasblkdev_block.c
drivers/staging/winbond/mto.c
drivers/staging/winbond/phy_calibration.c
drivers/staging/winbond/wb35tx.c
drivers/staging/xgifb/XGI_main.h
drivers/staging/xgifb/XGI_main_26.c
drivers/staging/xgifb/XGIfb.h
drivers/staging/xgifb/vb_def.h
drivers/staging/xgifb/vb_ext.c
drivers/staging/xgifb/vb_ext.h
drivers/staging/xgifb/vb_init.c
drivers/staging/xgifb/vb_init.h
drivers/staging/xgifb/vb_setmode.c
drivers/staging/xgifb/vb_setmode.h
drivers/staging/xgifb/vb_struct.h
drivers/staging/xgifb/vb_table.h
drivers/staging/xgifb/vb_util.c
drivers/staging/xgifb/vgatypes.h
kernel/module.c

index e3786f161bc34676294d89a1bfa2182bf64e44c9..dfc16f955eb882765aef90c63003d01ce95927f9 100644 (file)
@@ -67,10 +67,6 @@ source "drivers/staging/echo/Kconfig"
 
 source "drivers/staging/brcm80211/Kconfig"
 
-source "drivers/staging/rt2860/Kconfig"
-
-source "drivers/staging/rt2870/Kconfig"
-
 source "drivers/staging/comedi/Kconfig"
 
 source "drivers/staging/olpc_dcon/Kconfig"
@@ -177,5 +173,9 @@ source "drivers/staging/gma500/Kconfig"
 
 source "drivers/staging/altera-stapl/Kconfig"
 
+source "drivers/staging/mei/Kconfig"
+
+source "drivers/staging/nvec/Kconfig"
+
 endif # !STAGING_EXCLUDE_BUILD
 endif # STAGING
index f0d5c53156123e15b73d91368f85e56d75237284..fa41b9c23783a90f9d0f7d72a414b6cf18dd406a 100644 (file)
@@ -12,13 +12,12 @@ obj-$(CONFIG_VIDEO_CX25821) += cx25821/
 obj-$(CONFIG_VIDEO_TM6000)     += tm6000/
 obj-$(CONFIG_DVB_CXD2099)      += cxd2099/
 obj-$(CONFIG_LIRC_STAGING)     += lirc/
-obj-$(CONFIG_USB_IP_COMMON)    += usbip/
+obj-$(CONFIG_USBIP_CORE)       += usbip/
 obj-$(CONFIG_W35UND)           += winbond/
 obj-$(CONFIG_PRISM2_USB)       += wlan-ng/
 obj-$(CONFIG_ECHO)             += echo/
-obj-$(CONFIG_BRCM80211)                += brcm80211/
-obj-$(CONFIG_RT2860)           += rt2860/
-obj-$(CONFIG_RT2870)           += rt2870/
+obj-$(CONFIG_BRCMSMAC)         += brcm80211/
+obj-$(CONFIG_BRCMFMAC)         += brcm80211/
 obj-$(CONFIG_COMEDI)           += comedi/
 obj-$(CONFIG_FB_OLPC_DCON)     += olpc_dcon/
 obj-$(CONFIG_ASUS_OLED)                += asus_oled/
@@ -70,3 +69,5 @@ obj-$(CONFIG_ALTERA_STAPL)    +=altera-stapl/
 obj-$(CONFIG_TOUCHSCREEN_CLEARPAD_TM1217)      += cptm1217/
 obj-$(CONFIG_TOUCHSCREEN_SYNAPTICS_I2C_RMI4)   += ste_rmi4/
 obj-$(CONFIG_DRM_PSB)          += gma500/
+obj-$(CONFIG_INTEL_MEI)                += mei/
+obj-$(CONFIG_MFD_NVEC)         += nvec/
index 8a5caa30b85f30afb0502c379064bcd2b8d44b89..1f15e1fb1ab224b6ed0c925463d9e9fed30c0da2 100644 (file)
@@ -100,12 +100,6 @@ config AR600x_BT_RESET_PIN
        help
        WLAN GPIO to be used for resetting BT
 
-config ATH6KL_CFG80211
-       bool "CFG80211 support"
-       depends on ATH6K_LEGACY && CFG80211
-       help
-       Enables support for CFG80211 APIs. The default option is to use WEXT. Even with this option enabled, WEXT is not explicitly disabled and the onus of not exercising WEXT lies on the application(s) running in the user space.
-
 config ATH6KL_HTC_RAW_INTERFACE
        bool "RAW HTC support"
        depends on ATH6K_LEGACY
index ab68078699f29012db533cfbce8ce38780dfe9b7..1d3f2390a17261df56c1f7cd04d13dcc20649f71 100644 (file)
@@ -29,26 +29,6 @@ ccflags-y += -I$(obj)/os
 ccflags-y += -I$(obj)/bmi/include
 ccflags-y += -I$(obj)/include/common/AR6002/hw4.0
 
-ifeq ($(CONFIG_AR600x_SD31_XXX),y)
-ccflags-y += -DAR600x_SD31_XXX
-endif
-
-ifeq ($(CONFIG_AR600x_WB31_XXX),y)
-ccflags-y += -DAR600x_WB31_XXX
-endif
-
-ifeq ($(CONFIG_AR600x_SD32_XXX),y)
-ccflags-y += -DAR600x_SD32_XXX
-endif
-
-ifeq ($(CONFIG_AR600x_CUSTOM_XXX),y)
-ccflags-y += -DAR600x_CUSTOM_XXX
-endif
-
-ifeq ($(CONFIG_ATH6KL_ENABLE_COEXISTENCE),y)
-ccflags-y += -DENABLE_COEXISTENCE
-endif
-
 ifeq ($(CONFIG_AR600x_DUAL_ANTENNA),y)
 ccflags-y += -DAR600x_DUAL_ANTENNA
 endif
@@ -85,11 +65,6 @@ ifeq ($(CONFIG_ATH6KL_CONFIG_GPIO_BT_RESET),y)
 ccflags-y += -DATH6KL_CONFIG_GPIO_BT_RESET
 endif
 
-ifeq ($(CONFIG_ATH6KL_CFG80211),y)
-ccflags-y += -DATH6K_CONFIG_CFG80211
-ath6kl-y += os/linux/cfg80211.o
-endif
-
 ifeq ($(CONFIG_ATH6KL_HTC_RAW_INTERFACE),y)
 ccflags-y += -DHTC_RAW_INTERFACE
 endif
@@ -115,18 +90,8 @@ ifeq ($(CONFIG_ATH6KL_SKIP_ABI_VERSION_CHECK),y)
 ccflags-y += -DATH6KL_SKIP_ABI_VERSION_CHECK
 endif
 
-ccflags-y += -DLINUX -DKERNEL_2_6
-ccflags-y += -DTCMD
-ccflags-y += -DSEND_EVENT_TO_APP
-ccflags-y += -DUSER_KEYS
-ccflags-y += -DNO_SYNC_FLUSH
-ccflags-y += -DHTC_EP_STAT_PROFILING
-ccflags-y += -DATH_AR6K_11N_SUPPORT
 ccflags-y += -DWAPI_ENABLE
 ccflags-y += -DCHECKSUM_OFFLOAD
-ccflags-y += -DWLAN_HEADERS
-ccflags-y += -DINIT_MODE_DRV_ENABLED
-ccflags-y += -DBMIENABLE_SET
 
 obj-$(CONFIG_ATH6K_LEGACY) := ath6kl.o
 ath6kl-y += htc2/AR6000/ar6k.o
@@ -136,14 +101,12 @@ ath6kl-y += htc2/htc_recv.o
 ath6kl-y += htc2/htc_services.o
 ath6kl-y += htc2/htc.o
 ath6kl-y += bmi/src/bmi.o
+ath6kl-y += os/linux/cfg80211.o
 ath6kl-y += os/linux/ar6000_drv.o
 ath6kl-y += os/linux/ar6000_raw_if.o
 ath6kl-y += os/linux/ar6000_pm.o
 ath6kl-y += os/linux/netbuf.o
-ath6kl-y += os/linux/wireless_ext.o
-ath6kl-y += os/linux/ioctl.o
 ath6kl-y += os/linux/hci_bridge.o
-ath6kl-y += os/linux/ar6k_pal.o
 ath6kl-y += miscdrv/common_drv.o
 ath6kl-y += miscdrv/credit_dist.o
 ath6kl-y += wmi/wmi.o
index 6ae2ea7233d8ac9c73616c6b6ee5c829c160e117..8e2577074d659a641ef2467706ee58033e0ddb2d 100644 (file)
 
 #include "a_config.h"
 #include "athdefs.h"
-#include "a_types.h"
 #include "a_osapi.h"
 #define ATH_MODULE_NAME bmi
 #include "a_debug.h"
-#include "AR6002/hw2.0/hw/mbox_host_reg.h"
+#include "hw/mbox_host_reg.h"
 #include "bmi_msg.h"
 
 #define ATH_DEBUG_BMI  ATH_DEBUG_MAKE_MODULE_MASK(0)
index 9268bf3eabd9deb823b855725f1fddc23a1778e0..f1f085eba9c87e1987df12edae6dc8ae7fc00b5c 100644 (file)
@@ -95,12 +95,12 @@ void
 BMICleanup(void)
 {
     if (pBMICmdCredits) {
-        A_FREE(pBMICmdCredits);
+        kfree(pBMICmdCredits);
         pBMICmdCredits = NULL;
     }
 
     if (pBMICmdBuf) {
-        A_FREE(pBMICmdBuf);
+        kfree(pBMICmdBuf);
         pBMICmdBuf = NULL;
     }
 }
@@ -127,12 +127,12 @@ BMIDone(struct hif_device *device)
     }
 
     if (pBMICmdCredits) {
-        A_FREE(pBMICmdCredits);
+        kfree(pBMICmdCredits);
         pBMICmdCredits = NULL;
     }
 
     if (pBMICmdBuf) {
-        A_FREE(pBMICmdBuf);
+        kfree(pBMICmdBuf);
         pBMICmdBuf = NULL;
     }
 
index 6341560b2108262a4e8e3d45cc500b40c484fb56..ed7ad4786f5a517d1440a57fb0376cc2ea7936f7 100644 (file)
@@ -27,7 +27,6 @@
 
 #include "a_config.h"
 #include "athdefs.h"
-#include "a_types.h"
 #include "a_osapi.h"
 #include "hif.h"
 #include "../../../common/hif_sdio_common.h"
index e6d9cd802dee1209d9668c45d76266c16fe845e1..5f5d67720fa4fbe6482657bada71aefc3002dcc2 100644 (file)
@@ -37,7 +37,7 @@
 #include "hif_internal.h"
 #define ATH_MODULE_NAME hif
 #include "a_debug.h"
-#include "AR6002/hw2.0/hw/mbox_host_reg.h"
+#include "hw/mbox_host_reg.h"
 
 #if HIF_USE_DMA_BOUNCE_BUFFER
 /* macro to check if DMA buffer is WORD-aligned and DMA-able.  Most host controllers assume the
 #if defined(CONFIG_PM)
 #define dev_to_sdio_func(d)    container_of(d, struct sdio_func, dev)
 #define to_sdio_driver(d)      container_of(d, struct sdio_driver, drv)
-static int hifDeviceSuspend(struct device *dev);
-static int hifDeviceResume(struct device *dev);
 #endif /* CONFIG_PM */
-static int hifDeviceInserted(struct sdio_func *func, const struct sdio_device_id *id);
-static void hifDeviceRemoved(struct sdio_func *func);
-static struct hif_device *addHifDevice(struct sdio_func *func);
-static struct hif_device *getHifDevice(struct sdio_func *func);
 static void delHifDevice(struct hif_device * device);
 static int Func0_CMD52WriteByte(struct mmc_card *card, unsigned int address, unsigned char byte);
 static int Func0_CMD52ReadByte(struct mmc_card *card, unsigned int address, unsigned char *byte);
 
+static int hifEnableFunc(struct hif_device *device, struct sdio_func *func);
+static int hifDisableFunc(struct hif_device *device, struct sdio_func *func);
+OSDRV_CALLBACKS osdrvCallbacks;
+
 int reset_sdio_on_unload = 0;
 module_param(reset_sdio_on_unload, int, 0644);
 
 extern u32 nohifscattersupport;
 
+static struct hif_device *ath6kl_alloc_hifdev(struct sdio_func *func)
+{
+       struct hif_device *hifdevice;
 
-/* ------ Static Variables ------ */
-static const struct sdio_device_id ar6k_id_table[] = {
-    {  SDIO_DEVICE(MANUFACTURER_CODE, (MANUFACTURER_ID_AR6002_BASE | 0x0))  },
-    {  SDIO_DEVICE(MANUFACTURER_CODE, (MANUFACTURER_ID_AR6002_BASE | 0x1))  },
-    {  SDIO_DEVICE(MANUFACTURER_CODE, (MANUFACTURER_ID_AR6003_BASE | 0x0))  },
-    {  SDIO_DEVICE(MANUFACTURER_CODE, (MANUFACTURER_ID_AR6003_BASE | 0x1))  },
-    { /* null */                                         },
-};
-MODULE_DEVICE_TABLE(sdio, ar6k_id_table);
+       hifdevice = kzalloc(sizeof(struct hif_device), GFP_KERNEL);
 
-static struct sdio_driver ar6k_driver = {
-       .name = "ar6k_wlan",
-       .id_table = ar6k_id_table,
-       .probe = hifDeviceInserted,
-       .remove = hifDeviceRemoved,
+#if HIF_USE_DMA_BOUNCE_BUFFER
+       hifdevice->dma_buffer = kmalloc(HIF_DMA_BUFFER_SIZE, GFP_KERNEL);
+#endif
+       hifdevice->func = func;
+       hifdevice->powerConfig = HIF_DEVICE_POWER_UP;
+       sdio_set_drvdata(func, hifdevice);
+
+       return hifdevice;
+}
+
+static struct hif_device *ath6kl_get_hifdev(struct sdio_func *func)
+{
+       return (struct hif_device *) sdio_get_drvdata(func);
+}
+
+static const struct sdio_device_id ath6kl_hifdev_ids[] = {
+       { SDIO_DEVICE(MANUFACTURER_CODE, (MANUFACTURER_ID_AR6002_BASE | 0x0)) },
+       { SDIO_DEVICE(MANUFACTURER_CODE, (MANUFACTURER_ID_AR6002_BASE | 0x1)) },
+       { SDIO_DEVICE(MANUFACTURER_CODE, (MANUFACTURER_ID_AR6003_BASE | 0x0)) },
+       { SDIO_DEVICE(MANUFACTURER_CODE, (MANUFACTURER_ID_AR6003_BASE | 0x1)) },
+       { /* null */                                         },
 };
 
+MODULE_DEVICE_TABLE(sdio, ath6kl_hifdev_ids);
+
+static int ath6kl_hifdev_probe(struct sdio_func *func,
+                              const struct sdio_device_id *id)
+{
+       int ret;
+       struct hif_device *device;
+       int count;
+
+       AR_DEBUG_PRINTF(ATH_DEBUG_TRACE,
+                       ("ath6kl: Function: 0x%X, Vendor ID: 0x%X, "
+                        "Device ID: 0x%X, block size: 0x%X/0x%X\n",
+                       func->num, func->vendor, func->device,
+                       func->max_blksize, func->cur_blksize));
+
+       ath6kl_alloc_hifdev(func);
+       device = ath6kl_get_hifdev(func);
+
+       device->id = id;
+       device->is_disabled = true;
+
+       spin_lock_init(&device->lock);
+       spin_lock_init(&device->asynclock);
+
+       DL_LIST_INIT(&device->ScatterReqHead);
+
+       /* Try to allow scatter unless globally overridden */
+       if (!nohifscattersupport)
+               device->scatter_enabled = true;
+
+       A_MEMZERO(device->busRequest, sizeof(device->busRequest));
+
+       for (count = 0; count < BUS_REQUEST_MAX_NUM; count++) {
+               sema_init(&device->busRequest[count].sem_req, 0);
+               hifFreeBusRequest(device, &device->busRequest[count]);
+       }
+
+       sema_init(&device->sem_async, 0);
+
+       ret = hifEnableFunc(device, func);
+
+       return ret;
+}
+
+static void ath6kl_hifdev_remove(struct sdio_func *func)
+{
+       int status = 0;
+       struct hif_device *device;
+
+       device = ath6kl_get_hifdev(func);
+       if (device->claimedContext != NULL)
+               status = osdrvCallbacks.
+                       deviceRemovedHandler(device->claimedContext, device);
+
+       if (device->is_disabled)
+               device->is_disabled = false;
+       else
+               status = hifDisableFunc(device, func);
+
+       CleanupHIFScatterResources(device);
+
+       delHifDevice(device);
+}
+
 #if defined(CONFIG_PM)
-/* New suspend/resume based on linux-2.6.32
- * Need to patch linux-2.6.32 with mmc2.6.32_suspend.patch
- * Need to patch with msmsdcc2.6.29_suspend.patch for msm_sdcc host
-     */
-static struct dev_pm_ops ar6k_device_pm_ops = {
-       .suspend = hifDeviceSuspend,
-       .resume = hifDeviceResume,
+static int ath6kl_hifdev_suspend(struct device *dev)
+{
+       struct sdio_func *func = dev_to_sdio_func(dev);
+       int status = 0;
+       struct hif_device *device;
+
+       device = ath6kl_get_hifdev(func);
+
+       if (device && device->claimedContext &&
+           osdrvCallbacks.deviceSuspendHandler) {
+               /* set true first for PowerStateChangeNotify(..) */
+               device->is_suspend = true;
+               status = osdrvCallbacks.
+                       deviceSuspendHandler(device->claimedContext);
+               if (status)
+                       device->is_suspend = false;
+       }
+
+       CleanupHIFScatterResources(device);
+
+       switch (status) {
+       case 0:
+               return 0;
+       case A_EBUSY:
+               /* Hack for kernel in order to support deep sleep and wow */
+               return -EBUSY;
+       default:
+               return -1;
+       }
+}
+
+static int ath6kl_hifdev_resume(struct device *dev)
+{
+       struct sdio_func *func = dev_to_sdio_func(dev);
+       int status = 0;
+       struct hif_device *device;
+
+       device = ath6kl_get_hifdev(func);
+       if (device && device->claimedContext &&
+           osdrvCallbacks.deviceSuspendHandler) {
+               status = osdrvCallbacks.
+                       deviceResumeHandler(device->claimedContext);
+               if (status == 0)
+                       device->is_suspend = false;
+       }
+
+       return status;
+}
+
+static const struct dev_pm_ops ath6kl_hifdev_pmops = {
+       .suspend = ath6kl_hifdev_suspend,
+       .resume = ath6kl_hifdev_resume,
 };
 #endif /* CONFIG_PM */
 
+static struct sdio_driver ath6kl_hifdev_driver = {
+       .name = "ath6kl_hifdev",
+       .id_table = ath6kl_hifdev_ids,
+       .probe = ath6kl_hifdev_probe,
+       .remove = ath6kl_hifdev_remove,
+#if defined(CONFIG_PM)
+       .drv = {
+               .pm = &ath6kl_hifdev_pmops,
+       },
+#endif
+};
+
 /* make sure we only unregister when registered. */
 static int registered = 0;
 
-OSDRV_CALLBACKS osdrvCallbacks;
 extern u32 onebitmode;
 extern u32 busspeedlow;
 extern u32 debughif;
 
 static void ResetAllCards(void);
-static int hifDisableFunc(struct hif_device *device, struct sdio_func *func);
-static int hifEnableFunc(struct hif_device *device, struct sdio_func *func);
 
 #ifdef DEBUG
 
@@ -125,31 +252,22 @@ ATH_DEBUG_INSTANTIATE_MODULE_VAR(hif,
 /* ------ Functions ------ */
 int HIFInit(OSDRV_CALLBACKS *callbacks)
 {
-    int status;
-    AR_DEBUG_ASSERT(callbacks != NULL);
-
-    A_REGISTER_MODULE_DEBUG_INFO(hif);
+       int r;
+       AR_DEBUG_ASSERT(callbacks != NULL);
 
-    /* store the callback handlers */
-    osdrvCallbacks = *callbacks;
+       A_REGISTER_MODULE_DEBUG_INFO(hif);
 
-    /* Register with bus driver core */
-    AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: HIFInit registering\n"));
-    registered = 1;
-#if defined(CONFIG_PM)
-    if (callbacks->deviceSuspendHandler && callbacks->deviceResumeHandler) {
-        ar6k_driver.drv.pm = &ar6k_device_pm_ops;
-    }
-#endif /* CONFIG_PM */
-    status = sdio_register_driver(&ar6k_driver);
-    AR_DEBUG_ASSERT(status==0);
+       /* store the callback handlers */
+       osdrvCallbacks = *callbacks;
 
-    if (status != 0) {
-        return A_ERROR;
-    }
+       /* Register with bus driver core */
+       registered = 1;
 
-    return 0;
+       r = sdio_register_driver(&ath6kl_hifdev_driver);
+       if (r < 0)
+               return r;
 
+       return 0;
 }
 
 static int
@@ -763,7 +881,7 @@ HIFShutDownDevice(struct hif_device *device)
             registered = 0;
             AR_DEBUG_PRINTF(ATH_DEBUG_TRACE,
                             ("AR6000: Unregistering with the bus driver\n"));
-            sdio_unregister_driver(&ar6k_driver);
+            sdio_unregister_driver(&ath6kl_hifdev_driver);
             AR_DEBUG_PRINTF(ATH_DEBUG_TRACE,
                             ("AR6000: Unregistered\n"));
         }
@@ -778,7 +896,7 @@ hifIRQHandler(struct sdio_func *func)
     struct hif_device *device;
     AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: +hifIRQHandler\n"));
 
-    device = getHifDevice(func);
+    device = ath6kl_get_hifdev(func);
     atomic_set(&device->irqHandling, 1);
     /* release the host during ints so we can pick it back up when we process cmds */
     sdio_release_host(device->func);
@@ -823,48 +941,6 @@ static int enable_task(void *param)
 }
 #endif
 
-static int hifDeviceInserted(struct sdio_func *func, const struct sdio_device_id *id)
-{
-    int ret;
-    struct hif_device * device;
-    int count;
-
-    AR_DEBUG_PRINTF(ATH_DEBUG_TRACE,
-                   ("AR6000: hifDeviceInserted, Function: 0x%X, Vendor ID: 0x%X, Device ID: 0x%X, block size: 0x%X/0x%X\n",
-                    func->num, func->vendor, func->device, func->max_blksize, func->cur_blksize));
-
-    addHifDevice(func);
-    device = getHifDevice(func);
-
-    device->id = id;
-    device->is_disabled = true;
-
-    spin_lock_init(&device->lock);
-
-    spin_lock_init(&device->asynclock);
-    
-    DL_LIST_INIT(&device->ScatterReqHead);
-    
-    if (!nohifscattersupport) {
-            /* try to allow scatter operation on all instances,
-             * unless globally overridden */
-        device->scatter_enabled = true;
-    }
-
-    /* Initialize the bus requests to be used later */
-    A_MEMZERO(device->busRequest, sizeof(device->busRequest));
-    for (count = 0; count < BUS_REQUEST_MAX_NUM; count ++) {
-        sema_init(&device->busRequest[count].sem_req, 0);
-        hifFreeBusRequest(device, &device->busRequest[count]);
-    }
-    sema_init(&device->sem_async, 0);
-    
-    ret  = hifEnableFunc(device, func);
-
-    return ret;
-}
-
-
 void
 HIFAckInterrupt(struct hif_device *device)
 {
@@ -955,7 +1031,7 @@ static int hifDisableFunc(struct hif_device *device, struct sdio_func *func)
     int status = 0;
 
     AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: +hifDisableFunc\n"));
-    device = getHifDevice(func);
+    device = ath6kl_get_hifdev(func);
     if (!IS_ERR(device->async_task)) {
         init_completion(&device->async_completion);
         device->async_shutdown = 1;
@@ -1004,7 +1080,7 @@ static int hifEnableFunc(struct hif_device *device, struct sdio_func *func)
     int ret = 0;
     
     AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: +hifEnableFunc\n"));
-    device = getHifDevice(func);
+    device = ath6kl_get_hifdev(func);
 
     if (device->is_disabled) {
        /* enable the SDIO function */
@@ -1016,7 +1092,7 @@ static int hifEnableFunc(struct hif_device *device, struct sdio_func *func)
             if (ret) {
                 AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("AR6000: failed to enable 4-bit ASYNC IRQ mode %d \n",ret));
                 sdio_release_host(func);
-                return A_ERROR;
+                return ret;
             }
             AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: 4-bit ASYNC IRQ mode enabled\n"));
         }
@@ -1027,14 +1103,14 @@ static int hifEnableFunc(struct hif_device *device, struct sdio_func *func)
             AR_DEBUG_PRINTF(ATH_DEBUG_ERROR, ("AR6000: %s(), Unable to enable AR6K: 0x%X\n",
                                          __FUNCTION__, ret));
             sdio_release_host(func);
-            return A_ERROR;
+            return ret;
         }
         ret = sdio_set_block_size(func, HIF_MBOX_BLOCK_SIZE);
         sdio_release_host(func);
         if (ret) {
             AR_DEBUG_PRINTF(ATH_DEBUG_ERROR, ("AR6000: %s(), Unable to set block size 0x%x  AR6K: 0x%X\n",
                                          __FUNCTION__, HIF_MBOX_BLOCK_SIZE, ret));
-            return A_ERROR;
+            return ret;
         }
         device->is_disabled = false;
         /* create async I/O thread */
@@ -1045,7 +1121,7 @@ static int hifEnableFunc(struct hif_device *device, struct sdio_func *func)
                                            "AR6K Async");
            if (IS_ERR(device->async_task)) {
                AR_DEBUG_PRINTF(ATH_DEBUG_ERROR, ("AR6000: %s(), to create async task\n", __FUNCTION__));
-                return A_ERROR;
+                return -ENOMEM;
            }
            AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: start async task\n"));
            wake_up_process(device->async_task );    
@@ -1060,14 +1136,14 @@ static int hifEnableFunc(struct hif_device *device, struct sdio_func *func)
     } else {
         taskFunc = enable_task;
         taskName = "AR6K enable";
-        ret = A_PENDING;
+        ret = -ENOMEM;
 #endif /* CONFIG_PM */
     }
     /* create resume thread */
     pTask = kthread_create(taskFunc, (void *)device, taskName);
     if (IS_ERR(pTask)) {
         AR_DEBUG_PRINTF(ATH_DEBUG_ERROR, ("AR6000: %s(), to create enabel task\n", __FUNCTION__));
-        return A_ERROR;
+        return -ENOMEM;
     }
     wake_up_process(pTask);
     AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: -hifEnableFunc\n"));
@@ -1076,79 +1152,6 @@ static int hifEnableFunc(struct hif_device *device, struct sdio_func *func)
     return ret;
 }
 
-#if defined(CONFIG_PM)
-static int hifDeviceSuspend(struct device *dev)
-{
-    struct sdio_func *func=dev_to_sdio_func(dev);
-    int status = 0;
-    struct hif_device *device;   
-
-    device = getHifDevice(func);
-    AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: +hifDeviceSuspend\n"));
-    if (device && device->claimedContext && osdrvCallbacks.deviceSuspendHandler) {
-        device->is_suspend = true; /* set true first for PowerStateChangeNotify(..) */
-        status = osdrvCallbacks.deviceSuspendHandler(device->claimedContext);
-        if (status) {
-            device->is_suspend = false;
-        }
-    }
-    CleanupHIFScatterResources(device);
-    AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: -hifDeviceSuspend\n"));
-
-    switch (status) {
-    case 0:
-        return 0;
-    case A_EBUSY:
-        return -EBUSY; /* Hack for kernel in order to support deep sleep and wow */
-    default:
-        return -1;
-    }
-}
-
-static int hifDeviceResume(struct device *dev)
-{
-    struct sdio_func *func=dev_to_sdio_func(dev);
-    int status = 0;
-    struct hif_device *device;   
-
-    device = getHifDevice(func);
-    AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: +hifDeviceResume\n"));
-    if (device && device->claimedContext && osdrvCallbacks.deviceSuspendHandler) {
-        status = osdrvCallbacks.deviceResumeHandler(device->claimedContext);
-        if (status == 0) {
-            device->is_suspend = false;
-        }
-    }
-    AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: -hifDeviceResume\n"));
-
-    return status;
-}
-#endif /* CONFIG_PM */
-
-static void hifDeviceRemoved(struct sdio_func *func)
-{
-    int status = 0;
-    struct hif_device *device;
-    AR_DEBUG_ASSERT(func != NULL);
-
-    AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: +hifDeviceRemoved\n"));
-    device = getHifDevice(func);
-    if (device->claimedContext != NULL) {
-        status = osdrvCallbacks.deviceRemovedHandler(device->claimedContext, device);
-    }
-
-    if (device->is_disabled) {
-        device->is_disabled = false;
-    } else {
-        status = hifDisableFunc(device, func);
-    }
-    CleanupHIFScatterResources(device);
-     
-    delHifDevice(device);
-    AR_DEBUG_ASSERT(status == 0);
-    AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: -hifDeviceRemoved\n"));
-}
-
 /*
  * This should be moved to AR6K HTC layer.
  */
@@ -1182,33 +1185,6 @@ int hifWaitForPendingRecv(struct hif_device *device)
     return 0;
 }
     
-
-static struct hif_device *
-addHifDevice(struct sdio_func *func)
-{
-    struct hif_device *hifdevice;
-    AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: addHifDevice\n"));
-    AR_DEBUG_ASSERT(func != NULL);
-    hifdevice = kzalloc(sizeof(struct hif_device), GFP_KERNEL);
-    AR_DEBUG_ASSERT(hifdevice != NULL);
-#if HIF_USE_DMA_BOUNCE_BUFFER
-    hifdevice->dma_buffer = kmalloc(HIF_DMA_BUFFER_SIZE, GFP_KERNEL);
-    AR_DEBUG_ASSERT(hifdevice->dma_buffer != NULL);
-#endif
-    hifdevice->func = func;
-    hifdevice->powerConfig = HIF_DEVICE_POWER_UP;
-    sdio_set_drvdata(func, hifdevice);
-    AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: addHifDevice; 0x%p\n", hifdevice));
-    return hifdevice;
-}
-
-static struct hif_device *
-getHifDevice(struct sdio_func *func)
-{
-    AR_DEBUG_ASSERT(func != NULL);
-    return (struct hif_device *)sdio_get_drvdata(func);
-}
-
 static void
 delHifDevice(struct hif_device * device)
 {
index a1fdcc189f7e75d1db02ccaf266550c0e0604ffe..7516d913dab383e24877d73538429ffa9314a9ca 100644 (file)
@@ -309,7 +309,7 @@ int SetupHIFScatterSupport(struct hif_device *device, struct hif_device_scatter_
                                          (MAX_SCATTER_ENTRIES_PER_REQ - 1) * (sizeof(struct hif_scatter_item))); 
            
             if (NULL == pReqPriv->pHifScatterReq) {
-                A_FREE(pReqPriv);
+                kfree(pReqPriv);
                 break;      
             }           
                 /* just zero the main part of the scatter request */
@@ -319,8 +319,8 @@ int SetupHIFScatterSupport(struct hif_device *device, struct hif_device_scatter_
                 /* allocate a bus request for this scatter request */
             busrequest = hifAllocateBusRequest(device);
             if (NULL == busrequest) {
-                A_FREE(pReqPriv->pHifScatterReq);
-                A_FREE(pReqPriv);
+                kfree(pReqPriv->pHifScatterReq);
+                kfree(pReqPriv);
                 break;    
             }
                 /* assign the scatter request to this bus request */
@@ -382,11 +382,11 @@ void CleanupHIFScatterResources(struct hif_device *device)
         }
         
         if (pReqPriv->pHifScatterReq != NULL) {
-            A_FREE(pReqPriv->pHifScatterReq);   
+            kfree(pReqPriv->pHifScatterReq);   
             pReqPriv->pHifScatterReq = NULL; 
         }
                 
-        A_FREE(pReqPriv);       
+        kfree(pReqPriv);       
     }
 }
 
index eeddf6021f6d896aa8b88a415ba62cd01e2dc929..f8607bc08929112805afffb9665fbe82cce68207 100644 (file)
@@ -25,8 +25,7 @@
 
 #include "a_config.h"
 #include "athdefs.h"
-#include "a_types.h"
-#include "AR6002/hw2.0/hw/mbox_host_reg.h"
+#include "hw/mbox_host_reg.h"
 #include "a_osapi.h"
 #include "../htc_debug.h"
 #include "hif.h"
@@ -743,7 +742,7 @@ static void DevCleanupVirtualScatterSupport(struct ar6k_device *pDev)
         if (NULL == pReq) {
             break;
         }
-        A_FREE(pReq);
+        kfree(pReq);
     }
 
 }
index 1ff221838c0f4278b9efe66acdfb5cf3914fbba9..e551dbe674dc6f761db34b8bd3d7e6578a825674 100644 (file)
@@ -42,7 +42,6 @@
 
 //#define MBOXHW_UNIT_TEST 1
 
-#include "athstartpack.h"
 PREPACK struct ar6k_irq_proc_registers {
     u8 host_int_status;
     u8 cpu_int_status;
@@ -69,8 +68,6 @@ PREPACK struct ar6k_gmbox_ctrl_registers {
     u8 int_status_enable;
 } POSTPACK;
 
-#include "athendpack.h"
-
 #define AR6K_IRQ_ENABLE_REGS_SIZE sizeof(struct ar6k_irq_enable_registers)
 
 #define AR6K_REG_IO_BUFFER_SIZE     32
index 5e6d1e062922e841bbfde4203fa965f750bcdf15..d7af68f70560e712d845e9a4502993202e58bdc2 100644 (file)
@@ -25,8 +25,7 @@
 
 #include "a_config.h"
 #include "athdefs.h"
-#include "a_types.h"
-#include "AR6002/hw2.0/hw/mbox_host_reg.h"
+#include "hw/mbox_host_reg.h"
 #include "a_osapi.h"
 #include "../htc_debug.h"
 #include "hif.h"
index 374001155feb08067723b35eb84d4b73c3a4b3fe..725540f9adde9d3ae7c8c762ca05eec0913bf5ab 100644 (file)
@@ -24,7 +24,6 @@
 //==============================================================================
 #include "a_config.h"
 #include "athdefs.h"
-#include "a_types.h"
 #include "a_osapi.h"
 #include "../htc_debug.h"
 #include "hif.h"
index 41223f953589a117f8b89923e7838e71ec9d5c20..56a0d7143804b1449411dc54459544ab5d34feb1 100644 (file)
@@ -24,7 +24,6 @@
 //==============================================================================
 #include "a_config.h"
 #include "athdefs.h"
-#include "a_types.h"
 #include "a_osapi.h"
 #include "../htc_debug.h"
 #include "hif.h"
@@ -108,7 +107,7 @@ static void HCIUartCleanup(struct gmbox_proto_hci_uart *pProtocol)
     A_MUTEX_DELETE(&pProtocol->HCIRxLock);
     A_MUTEX_DELETE(&pProtocol->HCITxLock);
         
-    A_FREE(pProtocol);    
+    kfree(pProtocol);    
 }
 
 static int InitTxCreditState(struct gmbox_proto_hci_uart *pProt)
index d40bb14a2dac0ae76eade0efb020f838fcf56e2c..ae54e64b624326d81ef2bd207585c578fc9e8d0a 100644 (file)
@@ -70,7 +70,7 @@ static void HTCCleanup(struct htc_target *target)
     
     for (i = 0;i < NUM_CONTROL_BUFFERS;i++) {
         if (target->HTCControlBuffers[i].Buffer) {
-            A_FREE(target->HTCControlBuffers[i].Buffer);
+            kfree(target->HTCControlBuffers[i].Buffer);
         }
     }
     
@@ -86,7 +86,7 @@ static void HTCCleanup(struct htc_target *target)
         A_MUTEX_DELETE(&target->HTCTxLock);
     }
         /* free our instance */
-    A_FREE(target);
+    kfree(target);
 }
 
 /* registered target arrival callback from the HIF layer */
@@ -448,9 +448,7 @@ static void ResetEndpointStates(struct htc_target *target)
         pEndpoint->ServiceID = 0;
         pEndpoint->MaxMsgLength = 0;
         pEndpoint->MaxTxQueueDepth = 0;
-#ifdef HTC_EP_STAT_PROFILING
         A_MEMZERO(&pEndpoint->EndPointStats,sizeof(pEndpoint->EndPointStats));
-#endif
         INIT_HTC_PACKET_QUEUE(&pEndpoint->RxBuffers);
         INIT_HTC_PACKET_QUEUE(&pEndpoint->TxQueue);
         INIT_HTC_PACKET_QUEUE(&pEndpoint->RecvIndicationQueue);
@@ -527,7 +525,6 @@ bool HTCGetEndpointStatistics(HTC_HANDLE               HTCHandle,
                                 struct htc_endpoint_stats       *pStats)
 {
 
-#ifdef HTC_EP_STAT_PROFILING
     struct htc_target *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle);
     bool     clearStats = false;
     bool     sample = false;
@@ -568,9 +565,6 @@ bool HTCGetEndpointStatistics(HTC_HANDLE               HTCHandle,
     UNLOCK_HTC_TX(target);
 
     return true;
-#else
-    return false;
-#endif
 }
 
 struct ar6k_device  *HTCGetAR6KDevice(void *HTCHandle)
index 9425ed983671300e68341b6bcd2337bea1c7aa47..cac97351769aea439f80321187705c45154499d0 100644 (file)
@@ -27,7 +27,6 @@
  * processing errors, the last frame header is dump for comparison */
 //#define HTC_CAPTURE_LAST_FRAME
 
-//#define HTC_EP_STAT_PROFILING
 
 #ifdef __cplusplus
 extern "C" {
@@ -37,7 +36,6 @@ extern "C" {
 
 #include "a_config.h"
 #include "athdefs.h"
-#include "a_types.h"
 #include "a_osapi.h"
 #include "htc_debug.h"
 #include "htc.h"
@@ -82,17 +80,10 @@ struct htc_endpoint {
     struct htc_target           *target;                /* back pointer to target */
     u8 SeqNo;                  /* TX seq no (helpful) for debugging */
     u32 LocalConnectionFlags;   /* local connection flags */
-#ifdef HTC_EP_STAT_PROFILING
     struct htc_endpoint_stats          EndPointStats;          /* endpoint statistics */
-#endif
 };
 
-#ifdef HTC_EP_STAT_PROFILING
 #define INC_HTC_EP_STAT(p,stat,count) (p)->EndPointStats.stat += (count);
-#else
-#define INC_HTC_EP_STAT(p,stat,count)
-#endif
-
 #define HTC_SERVICE_TX_PACKET_TAG  HTC_TX_PACKET_TAG_INTERNAL
 
 #define NUM_CONTROL_BUFFERS     8
index c2088018c51d820b4db0011272d2fee258c3d092..974cc8cd6936226c0fd369eba2a2ab492ae9e490 100644 (file)
@@ -36,7 +36,6 @@
                         (pP)->PktInfo.AsRx.ExpectedHdr,        \
                         (pP)->Endpoint))                         
                         
-#ifdef HTC_EP_STAT_PROFILING
 #define HTC_RX_STAT_PROFILE(t,ep,numLookAheads)        \
 {                                                      \
     INC_HTC_EP_STAT((ep), RxReceived, 1);              \
@@ -46,9 +45,6 @@
         INC_HTC_EP_STAT((ep), RxBundleLookAheads, 1);  \
     }                                                  \
 }
-#else
-#define HTC_RX_STAT_PROFILE(t,ep,lookAhead)
-#endif
 
 static void DoRecvCompletion(struct htc_endpoint     *pEndpoint,
                              struct htc_packet_queue *pQueueToIndicate)
@@ -931,12 +927,10 @@ static void HTCAsyncRecvScatterCompletion(struct hif_scatter_req *pScatterReq)
         }
         
         if (!status) {
-#ifdef HTC_EP_STAT_PROFILING
             LOCK_HTC_RX(target);              
             HTC_RX_STAT_PROFILE(target,pEndpoint,numLookAheads);
             INC_HTC_EP_STAT(pEndpoint, RxPacketsBundled, 1);
             UNLOCK_HTC_RX(target);
-#endif      
             if (i == (pScatterReq->ValidScatterEntries - 1)) {
                     /* last packet's more packets flag is set based on the lookahead */
                 SET_MORE_RX_PACKET_INDICATION_FLAG(lookAheads,numLookAheads,pEndpoint,pPacket);
index 6f4050a98c85d22c4269a475989c305108394d7e..9310d4d5c99250710450fe7abb5842cdd603175b 100644 (file)
@@ -776,9 +776,6 @@ void HTCProcessCreditRpt(struct htc_target *target, HTC_CREDIT_REPORT *pRpt, int
         AR_DEBUG_PRINTF(ATH_DEBUG_SEND, ("  Endpoint %d got %d credits \n",
                 pRpt->EndpointID, pRpt->Credits));
 
-
-#ifdef HTC_EP_STAT_PROFILING
-
         INC_HTC_EP_STAT(pEndpoint, TxCreditRpts, 1);
         INC_HTC_EP_STAT(pEndpoint, TxCreditsReturned, pRpt->Credits);
 
@@ -797,8 +794,6 @@ void HTCProcessCreditRpt(struct htc_target *target, HTC_CREDIT_REPORT *pRpt, int
             INC_HTC_EP_STAT(pEndpoint, TxCreditRptsFromOther, 1);
         }
 
-#endif
-
         if (ENDPOINT_0 == pRpt->EndpointID) {
                 /* always give endpoint 0 credits back */
             pEndpoint->CreditDist.TxCredits += pRpt->Credits;
index 4a0083c65113ed5c18f7ea5e98c9681679410710..f7c09319433fcbfb2b2c2da02b5c864666582066 100644 (file)
 #ifndef _A_CONFIG_H_
 #define _A_CONFIG_H_
 
-#ifdef UNDER_NWIFI
-#include "../os/windows/include/config.h"
-#endif
-
-#ifdef ATHR_CE_LEGACY
-#include "../os/windows/include/config.h"
-#endif
-
-#if defined(__linux__) && !defined(LINUX_EMULATION)
 #include "../os/linux/include/config_linux.h"
-#endif
-
-#ifdef REXOS
-#include "../os/rexos/include/common/config_rexos.h"
-#endif
-
-#ifdef WIN_NWF
-#include "../os/windows/include/win/config_win.h"
-#endif
-
-#ifdef THREADX
-#include "../os/threadx/include/common/config_threadx.h"
-#endif
 
 #endif
index d433942e2b98ebde9cea708f4db097dd23ab1d9e..5154fcb1ca64880237c421c9d60a186c688cb026 100644 (file)
@@ -27,7 +27,6 @@
 extern "C" {
 #endif /* __cplusplus */
 
-#include <a_types.h>
 #include <a_osapi.h>
 
     /* standard debug print masks bits 0..7 */
@@ -187,35 +186,7 @@ void a_dump_module_debug_info_by_name(char *module_name);
 void a_module_debug_support_init(void);
 void a_module_debug_support_cleanup(void);
 
-#ifdef UNDER_NWIFI
-#include "../os/windows/include/debug.h"
-#endif
-
-#ifdef ATHR_CE_LEGACY
-#include "../os/windows/include/debug.h"
-#endif
-
-#if defined(__linux__) && !defined(LINUX_EMULATION)
 #include "../os/linux/include/debug_linux.h"
-#endif
-
-#ifdef REXOS
-#include "../os/rexos/include/common/debug_rexos.h"
-#endif
-
-#if defined ART_WIN
-#include "../os/win_art/include/debug_win.h"
-#endif
-
-#ifdef WIN_NWF
-#include <debug_win.h>
-#endif
-
-#ifdef THREADX
-#define ATH_DEBUG_MAKE_MODULE_MASK(index)  (1 << (ATH_DEBUG_MODULE_MASK_SHIFT + (index)))
-#include "../os/threadx/include/common/debug_threadx.h"
-#endif  
-
 
 #ifdef __cplusplus
 }
index 6db10f0f2d100393b5511313a3280cc126cbd76c..1548604e84653e267097dc5f97627dc759aa541a 100644 (file)
 #ifndef _A_DRV_H_
 #define _A_DRV_H_
 
-#if defined(__linux__) && !defined(LINUX_EMULATION)
 #include "../os/linux/include/athdrv_linux.h"
-#endif
-
-#ifdef UNDER_NWIFI
-#include "../os/windows/include/athdrv.h"
-#endif
-
-#ifdef ATHR_CE_LEGACY
-#include "../os/windows/include/athdrv.h"
-#endif
-
-#ifdef REXOS
-#include "../os/rexos/include/common/athdrv_rexos.h"
-#endif
-
-#ifdef WIN_NWF
-#include "../os/windows/include/athdrv.h"
-#endif
-
-#ifdef THREADX
-#include "../os/threadx/include/common/athdrv_threadx.h"
-#endif
 
 #endif /* _ADRV_H_ */
index 5e098cb30f56e6de1618b03955bff7671be054e2..a40d97a84ffcf6171ea67234bdd6b4ce600b2b23 100644 (file)
@@ -130,34 +130,6 @@ extern "C" {
 #define A_WMI_PEER_EVENT(devt, eventCode, bssid)    \
     ar6000_peer_event ((devt), (eventCode), (bssid))
 
-#ifdef CONFIG_HOST_GPIO_SUPPORT
-
-#define A_WMI_GPIO_INTR_RX(intr_mask, input_values) \
-    ar6000_gpio_intr_rx((intr_mask), (input_values))
-
-#define A_WMI_GPIO_DATA_RX(reg_id, value) \
-    ar6000_gpio_data_rx((reg_id), (value))
-
-#define A_WMI_GPIO_ACK_RX() \
-    ar6000_gpio_ack_rx()
-
-#endif
-
-#ifdef SEND_EVENT_TO_APP
-
-#define A_WMI_SEND_EVENT_TO_APP(ar, eventId, datap, len) \
-    ar6000_send_event_to_app((ar), (eventId), (datap), (len))
-
-#define A_WMI_SEND_GENERIC_EVENT_TO_APP(ar, eventId, datap, len) \
-    ar6000_send_generic_event_to_app((ar), (eventId), (datap), (len))
-
-#else
-
-#define A_WMI_SEND_EVENT_TO_APP(ar, eventId, datap, len)
-#define A_WMI_SEND_GENERIC_EVENT_TO_APP(ar, eventId, datap, len)
-
-#endif
-
 #ifdef CONFIG_HOST_TCMD_SUPPORT
 #define A_WMI_TCMD_RX_REPORT_EVENT(devt, results, len) \
     ar6000_tcmd_rx_report_event((devt), (results), (len))
index 7bdeeea215038776a0926f0759865539c3a0efa1..fd7ae0d612c603fe72f172711582bbe2b630d78e 100644 (file)
 #ifndef _A_OSAPI_H_
 #define _A_OSAPI_H_
 
-#if defined(__linux__) && !defined(LINUX_EMULATION)
 #include "../os/linux/include/osapi_linux.h"
-#endif
-
-#ifdef UNDER_NWIFI
-#include "../os/windows/include/osapi.h"
-#include "../os/windows/include/netbuf.h"
-#endif
-
-#ifdef ATHR_CE_LEGACY
-#include "../os/windows/include/osapi.h"
-#include "../os/windows/include/netbuf.h"
-#endif
-
-#ifdef REXOS
-#include "../os/rexos/include/common/osapi_rexos.h"
-#endif
-
-#if defined ART_WIN
-#include "../os/win_art/include/osapi_win.h"
-#include "../os/win_art/include/netbuf.h"
-#endif
-
-#ifdef WIN_NWF
-#include <osapi_win.h>
-#endif 
-
-#if defined(THREADX)
-#include "../os/threadx/include/common/osapi_threadx.h"
-#endif 
 
 #endif /* _OSAPI_H_ */
diff --git a/drivers/staging/ath6kl/include/a_types.h b/drivers/staging/ath6kl/include/a_types.h
deleted file mode 100644 (file)
index 18f4cfe..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-//------------------------------------------------------------------------------
-// <copyright file="a_types.h" company="Atheros">
-//    Copyright (c) 2004-2010 Atheros Corporation.  All rights reserved.
-// 
-//
-// Permission to use, copy, modify, and/or distribute this software for any
-// purpose with or without fee is hereby granted, provided that the above
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-//
-//
-//------------------------------------------------------------------------------
-//==============================================================================
-// This file contains the definitions of the basic atheros data types.
-// It is used to map the data types in atheros files to a platform specific
-// type.
-//
-// Author(s): ="Atheros"
-//==============================================================================
-#ifndef _A_TYPES_H_
-#define _A_TYPES_H_
-
-#if defined(__linux__) && !defined(LINUX_EMULATION)
-#include "../os/linux/include/athtypes_linux.h"
-#endif
-
-#ifdef UNDER_NWIFI
-#include "../os/windows/include/athtypes.h"
-#endif
-
-#ifdef ATHR_CE_LEGACY
-#include "../os/windows/include/athtypes.h"
-#endif
-
-#ifdef REXOS
-#include "../os/rexos/include/common/athtypes_rexos.h"
-#endif
-
-#if defined ART_WIN
-#include "../os/win_art/include/athtypes_win.h"
-#endif
-
-#ifdef WIN_NWF
-#include <athtypes_win.h>
-#endif
-
-#ifdef THREADX
-#include "../os/threadx/include/common/athtypes_threadx.h"
-#endif
-
-#endif /* _ATHTYPES_H_ */
index 1e1d92a507e23fd1137a3ec7d7dc782c06650733..e9460800272cce1ac4881976e80b25c37b1fadeb 100644 (file)
 #ifndef _AR6000_API_H_
 #define _AR6000_API_H_
 
-#if defined(__linux__) && !defined(LINUX_EMULATION)
 #include "../os/linux/include/ar6xapi_linux.h"
-#endif
-
-#ifdef UNDER_NWIFI
-#include "../os/windows/include/ar6xapi.h"
-#endif
-
-#ifdef ATHR_CE_LEGACY
-#include "../os/windows/include/ar6xapi.h"
-#endif
-
-#ifdef REXOS
-#include "../os/rexos/include/common/ar6xapi_rexos.h"
-#endif
-
-#if defined ART_WIN
-#include "../os/win_art/include/ar6xapi_win.h"
-#endif
-
-#ifdef WIN_NWF
-#include "../os/windows/include/ar6xapi.h"
-#endif
 
 #endif /* _AR6000_API_H */
 
diff --git a/drivers/staging/ath6kl/include/athendpack.h b/drivers/staging/ath6kl/include/athendpack.h
deleted file mode 100644 (file)
index 1b94050..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-//------------------------------------------------------------------------------
-// <copyright file="athendpack.h" company="Atheros">
-//    Copyright (c) 2004-2010 Atheros Corporation.  All rights reserved.
-// 
-//
-// Permission to use, copy, modify, and/or distribute this software for any
-// purpose with or without fee is hereby granted, provided that the above
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-//
-//
-//------------------------------------------------------------------------------
-//==============================================================================
-// end compiler-specific structure packing
-//
-// Author(s): ="Atheros"
-//==============================================================================
-#ifdef VXWORKS
-#endif /* VXWORKS */
-
-#if defined(LINUX) || defined(__linux__)
-#endif /* LINUX */
-
-#ifdef QNX
-#endif /* QNX */
-
-#ifdef INTEGRITY
-#include "integrity/athendpack_integrity.h"
-#endif /* INTEGRITY */
-
-#ifdef NUCLEUS
-#endif /* NUCLEUS */
-
-
-#ifdef UNDER_NWIFI
-#include "../os/windows/include/athendpack.h"
-#endif
-
-#ifdef ATHR_CE_LEGACY
-#include "../os/windows/include/athendpack.h"
-#endif /* WINCE */
-
-#ifdef WIN_NWF
-#include <athendpack_win.h>
-#endif 
diff --git a/drivers/staging/ath6kl/include/athstartpack.h b/drivers/staging/ath6kl/include/athstartpack.h
deleted file mode 100644 (file)
index 1c45f66..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-//------------------------------------------------------------------------------
-// <copyright file="athstartpack.h" company="Atheros">
-//    Copyright (c) 2004-2010 Atheros Corporation.  All rights reserved.
-// 
-//
-// Permission to use, copy, modify, and/or distribute this software for any
-// purpose with or without fee is hereby granted, provided that the above
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-//
-//
-//------------------------------------------------------------------------------
-//==============================================================================
-// start compiler-specific structure packing
-//
-// Author(s): ="Atheros"
-//==============================================================================
-#ifdef VXWORKS
-#endif /* VXWORKS */
-
-#if defined(LINUX) || defined(__linux__)
-#endif /* LINUX */
-
-#ifdef QNX
-#endif /* QNX */
-
-#ifdef INTEGRITY
-#include "integrity/athstartpack_integrity.h"
-#endif /* INTEGRITY */
-
-#ifdef NUCLEUS
-#endif /* NUCLEUS */
-
-#ifdef UNDER_NWIFI
-#include "../os/windows/include/athstartpack.h"
-#endif
-
-#ifdef ATHR_CE_LEGACY
-#include "../os/windows/include/athstartpack.h"
-#endif /* WINCE */
-
-#ifdef WIN_NWF
-#include <athstartpack_win.h>
-#endif
-
-#ifdef THREADX
-#include "../os/threadx/include/common/osapi_threadx.h"
-#endif 
index eb1e75607247dcfdf757d83fb4ad7180cb21a3db..d3227f77fa5d5677b7da16a1138a4aa1a47d6061 100644 (file)
@@ -32,7 +32,6 @@ extern "C" {
 /* Header files */
 #include "a_config.h"
 #include "athdefs.h"
-#include "a_types.h"
 #include "hif.h"
 #include "a_osapi.h"
 #include "bmi_msg.h"
diff --git a/drivers/staging/ath6kl/include/common/AR6002/AR6002_regdump.h b/drivers/staging/ath6kl/include/common/AR6002/AR6002_regdump.h
deleted file mode 100644 (file)
index 4a9b275..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-//------------------------------------------------------------------------------
-// Copyright (c) 2006-2010 Atheros Corporation.  All rights reserved.
-// 
-//
-// Permission to use, copy, modify, and/or distribute this software for any
-// purpose with or without fee is hereby granted, provided that the above
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-//
-//
-//------------------------------------------------------------------------------
-//==============================================================================
-// Author(s): ="Atheros"
-//==============================================================================
-
-#ifndef __AR6002_REGDUMP_H__
-#define __AR6002_REGDUMP_H__
-
-#if !defined(__ASSEMBLER__)
-/*
- * XTensa CPU state
- * This must match the state saved by the target exception handler.
- */
-struct XTensa_exception_frame_s {
-    u32 xt_pc;
-    u32 xt_ps;
-    u32 xt_sar;
-    u32 xt_vpri;
-    u32 xt_a2;
-    u32 xt_a3;
-    u32 xt_a4;
-    u32 xt_a5;
-    u32 xt_exccause;
-    u32 xt_lcount;
-    u32 xt_lbeg;
-    u32 xt_lend;
-
-    u32 epc1, epc2, epc3, epc4;
-
-    /* Extra info to simplify post-mortem stack walkback */
-#define AR6002_REGDUMP_FRAMES 10
-    struct {
-        u32 a0;  /* pc */
-        u32 a1;  /* sp */
-        u32 a2;
-        u32 a3;
-    } wb[AR6002_REGDUMP_FRAMES];
-};
-typedef struct XTensa_exception_frame_s CPU_exception_frame_t; 
-#define RD_SIZE sizeof(CPU_exception_frame_t)
-
-#endif
-#endif /* __AR6002_REGDUMP_H__ */
diff --git a/drivers/staging/ath6kl/include/common/AR6002/hw2.0/hw/analog_intf_reg.h b/drivers/staging/ath6kl/include/common/AR6002/hw2.0/hw/analog_intf_reg.h
deleted file mode 100644 (file)
index 9c82767..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-#ifndef _ANALOG_INTF_REG_REG_H_
-#define _ANALOG_INTF_REG_REG_H_
-
-#define SW_OVERRIDE_ADDRESS                      0x00000080
-#define SW_OVERRIDE_OFFSET                       0x00000080
-#define SW_OVERRIDE_SUPDATE_DELAY_MSB            1
-#define SW_OVERRIDE_SUPDATE_DELAY_LSB            1
-#define SW_OVERRIDE_SUPDATE_DELAY_MASK           0x00000002
-#define SW_OVERRIDE_SUPDATE_DELAY_GET(x)         (((x) & SW_OVERRIDE_SUPDATE_DELAY_MASK) >> SW_OVERRIDE_SUPDATE_DELAY_LSB)
-#define SW_OVERRIDE_SUPDATE_DELAY_SET(x)         (((x) << SW_OVERRIDE_SUPDATE_DELAY_LSB) & SW_OVERRIDE_SUPDATE_DELAY_MASK)
-#define SW_OVERRIDE_ENABLE_MSB                   0
-#define SW_OVERRIDE_ENABLE_LSB                   0
-#define SW_OVERRIDE_ENABLE_MASK                  0x00000001
-#define SW_OVERRIDE_ENABLE_GET(x)                (((x) & SW_OVERRIDE_ENABLE_MASK) >> SW_OVERRIDE_ENABLE_LSB)
-#define SW_OVERRIDE_ENABLE_SET(x)                (((x) << SW_OVERRIDE_ENABLE_LSB) & SW_OVERRIDE_ENABLE_MASK)
-
-#define SIN_VAL_ADDRESS                          0x00000084
-#define SIN_VAL_OFFSET                           0x00000084
-#define SIN_VAL_SIN_MSB                          0
-#define SIN_VAL_SIN_LSB                          0
-#define SIN_VAL_SIN_MASK                         0x00000001
-#define SIN_VAL_SIN_GET(x)                       (((x) & SIN_VAL_SIN_MASK) >> SIN_VAL_SIN_LSB)
-#define SIN_VAL_SIN_SET(x)                       (((x) << SIN_VAL_SIN_LSB) & SIN_VAL_SIN_MASK)
-
-#define SW_SCLK_ADDRESS                          0x00000088
-#define SW_SCLK_OFFSET                           0x00000088
-#define SW_SCLK_SW_SCLK_MSB                      0
-#define SW_SCLK_SW_SCLK_LSB                      0
-#define SW_SCLK_SW_SCLK_MASK                     0x00000001
-#define SW_SCLK_SW_SCLK_GET(x)                   (((x) & SW_SCLK_SW_SCLK_MASK) >> SW_SCLK_SW_SCLK_LSB)
-#define SW_SCLK_SW_SCLK_SET(x)                   (((x) << SW_SCLK_SW_SCLK_LSB) & SW_SCLK_SW_SCLK_MASK)
-
-#define SW_CNTL_ADDRESS                          0x0000008c
-#define SW_CNTL_OFFSET                           0x0000008c
-#define SW_CNTL_SW_SCAPTURE_MSB                  2
-#define SW_CNTL_SW_SCAPTURE_LSB                  2
-#define SW_CNTL_SW_SCAPTURE_MASK                 0x00000004
-#define SW_CNTL_SW_SCAPTURE_GET(x)               (((x) & SW_CNTL_SW_SCAPTURE_MASK) >> SW_CNTL_SW_SCAPTURE_LSB)
-#define SW_CNTL_SW_SCAPTURE_SET(x)               (((x) << SW_CNTL_SW_SCAPTURE_LSB) & SW_CNTL_SW_SCAPTURE_MASK)
-#define SW_CNTL_SW_SUPDATE_MSB                   1
-#define SW_CNTL_SW_SUPDATE_LSB                   1
-#define SW_CNTL_SW_SUPDATE_MASK                  0x00000002
-#define SW_CNTL_SW_SUPDATE_GET(x)                (((x) & SW_CNTL_SW_SUPDATE_MASK) >> SW_CNTL_SW_SUPDATE_LSB)
-#define SW_CNTL_SW_SUPDATE_SET(x)                (((x) << SW_CNTL_SW_SUPDATE_LSB) & SW_CNTL_SW_SUPDATE_MASK)
-#define SW_CNTL_SW_SOUT_MSB                      0
-#define SW_CNTL_SW_SOUT_LSB                      0
-#define SW_CNTL_SW_SOUT_MASK                     0x00000001
-#define SW_CNTL_SW_SOUT_GET(x)                   (((x) & SW_CNTL_SW_SOUT_MASK) >> SW_CNTL_SW_SOUT_LSB)
-#define SW_CNTL_SW_SOUT_SET(x)                   (((x) << SW_CNTL_SW_SOUT_LSB) & SW_CNTL_SW_SOUT_MASK)
-
-
-#ifndef __ASSEMBLER__
-
-typedef struct analog_intf_reg_reg_s {
-  unsigned char pad0[128]; /* pad to 0x80 */
-  volatile unsigned int sw_override;
-  volatile unsigned int sin_val;
-  volatile unsigned int sw_sclk;
-  volatile unsigned int sw_cntl;
-} analog_intf_reg_reg_t;
-
-#endif /* __ASSEMBLER__ */
-
-#endif /* _ANALOG_INTF_REG_H_ */
diff --git a/drivers/staging/ath6kl/include/common/AR6002/hw2.0/hw/analog_reg.h b/drivers/staging/ath6kl/include/common/AR6002/hw2.0/hw/analog_reg.h
deleted file mode 100644 (file)
index cf562b8..0000000
+++ /dev/null
@@ -1,1932 +0,0 @@
-#ifndef _ANALOG_REG_REG_H_
-#define _ANALOG_REG_REG_H_
-
-#define SYNTH_SYNTH1_ADDRESS                     0x00000000
-#define SYNTH_SYNTH1_OFFSET                      0x00000000
-#define SYNTH_SYNTH1_PWD_BIAS_MSB                31
-#define SYNTH_SYNTH1_PWD_BIAS_LSB                31
-#define SYNTH_SYNTH1_PWD_BIAS_MASK               0x80000000
-#define SYNTH_SYNTH1_PWD_BIAS_GET(x)             (((x) & SYNTH_SYNTH1_PWD_BIAS_MASK) >> SYNTH_SYNTH1_PWD_BIAS_LSB)
-#define SYNTH_SYNTH1_PWD_BIAS_SET(x)             (((x) << SYNTH_SYNTH1_PWD_BIAS_LSB) & SYNTH_SYNTH1_PWD_BIAS_MASK)
-#define SYNTH_SYNTH1_PWD_CP_MSB                  30
-#define SYNTH_SYNTH1_PWD_CP_LSB                  30
-#define SYNTH_SYNTH1_PWD_CP_MASK                 0x40000000
-#define SYNTH_SYNTH1_PWD_CP_GET(x)               (((x) & SYNTH_SYNTH1_PWD_CP_MASK) >> SYNTH_SYNTH1_PWD_CP_LSB)
-#define SYNTH_SYNTH1_PWD_CP_SET(x)               (((x) << SYNTH_SYNTH1_PWD_CP_LSB) & SYNTH_SYNTH1_PWD_CP_MASK)
-#define SYNTH_SYNTH1_PWD_VCMON_MSB               29
-#define SYNTH_SYNTH1_PWD_VCMON_LSB               29
-#define SYNTH_SYNTH1_PWD_VCMON_MASK              0x20000000
-#define SYNTH_SYNTH1_PWD_VCMON_GET(x)            (((x) & SYNTH_SYNTH1_PWD_VCMON_MASK) >> SYNTH_SYNTH1_PWD_VCMON_LSB)
-#define SYNTH_SYNTH1_PWD_VCMON_SET(x)            (((x) << SYNTH_SYNTH1_PWD_VCMON_LSB) & SYNTH_SYNTH1_PWD_VCMON_MASK)
-#define SYNTH_SYNTH1_PWD_VCO_MSB                 28
-#define SYNTH_SYNTH1_PWD_VCO_LSB                 28
-#define SYNTH_SYNTH1_PWD_VCO_MASK                0x10000000
-#define SYNTH_SYNTH1_PWD_VCO_GET(x)              (((x) & SYNTH_SYNTH1_PWD_VCO_MASK) >> SYNTH_SYNTH1_PWD_VCO_LSB)
-#define SYNTH_SYNTH1_PWD_VCO_SET(x)              (((x) << SYNTH_SYNTH1_PWD_VCO_LSB) & SYNTH_SYNTH1_PWD_VCO_MASK)
-#define SYNTH_SYNTH1_PWD_PRESC_MSB               27
-#define SYNTH_SYNTH1_PWD_PRESC_LSB               27
-#define SYNTH_SYNTH1_PWD_PRESC_MASK              0x08000000
-#define SYNTH_SYNTH1_PWD_PRESC_GET(x)            (((x) & SYNTH_SYNTH1_PWD_PRESC_MASK) >> SYNTH_SYNTH1_PWD_PRESC_LSB)
-#define SYNTH_SYNTH1_PWD_PRESC_SET(x)            (((x) << SYNTH_SYNTH1_PWD_PRESC_LSB) & SYNTH_SYNTH1_PWD_PRESC_MASK)
-#define SYNTH_SYNTH1_PWD_LODIV_MSB               26
-#define SYNTH_SYNTH1_PWD_LODIV_LSB               26
-#define SYNTH_SYNTH1_PWD_LODIV_MASK              0x04000000
-#define SYNTH_SYNTH1_PWD_LODIV_GET(x)            (((x) & SYNTH_SYNTH1_PWD_LODIV_MASK) >> SYNTH_SYNTH1_PWD_LODIV_LSB)
-#define SYNTH_SYNTH1_PWD_LODIV_SET(x)            (((x) << SYNTH_SYNTH1_PWD_LODIV_LSB) & SYNTH_SYNTH1_PWD_LODIV_MASK)
-#define SYNTH_SYNTH1_PWD_LOMIX_MSB               25
-#define SYNTH_SYNTH1_PWD_LOMIX_LSB               25
-#define SYNTH_SYNTH1_PWD_LOMIX_MASK              0x02000000
-#define SYNTH_SYNTH1_PWD_LOMIX_GET(x)            (((x) & SYNTH_SYNTH1_PWD_LOMIX_MASK) >> SYNTH_SYNTH1_PWD_LOMIX_LSB)
-#define SYNTH_SYNTH1_PWD_LOMIX_SET(x)            (((x) << SYNTH_SYNTH1_PWD_LOMIX_LSB) & SYNTH_SYNTH1_PWD_LOMIX_MASK)
-#define SYNTH_SYNTH1_FORCE_LO_ON_MSB             24
-#define SYNTH_SYNTH1_FORCE_LO_ON_LSB             24
-#define SYNTH_SYNTH1_FORCE_LO_ON_MASK            0x01000000
-#define SYNTH_SYNTH1_FORCE_LO_ON_GET(x)          (((x) & SYNTH_SYNTH1_FORCE_LO_ON_MASK) >> SYNTH_SYNTH1_FORCE_LO_ON_LSB)
-#define SYNTH_SYNTH1_FORCE_LO_ON_SET(x)          (((x) << SYNTH_SYNTH1_FORCE_LO_ON_LSB) & SYNTH_SYNTH1_FORCE_LO_ON_MASK)
-#define SYNTH_SYNTH1_PWD_LOBUF5G_MSB             23
-#define SYNTH_SYNTH1_PWD_LOBUF5G_LSB             23
-#define SYNTH_SYNTH1_PWD_LOBUF5G_MASK            0x00800000
-#define SYNTH_SYNTH1_PWD_LOBUF5G_GET(x)          (((x) & SYNTH_SYNTH1_PWD_LOBUF5G_MASK) >> SYNTH_SYNTH1_PWD_LOBUF5G_LSB)
-#define SYNTH_SYNTH1_PWD_LOBUF5G_SET(x)          (((x) << SYNTH_SYNTH1_PWD_LOBUF5G_LSB) & SYNTH_SYNTH1_PWD_LOBUF5G_MASK)
-#define SYNTH_SYNTH1_VCOREGBYPASS_MSB            22
-#define SYNTH_SYNTH1_VCOREGBYPASS_LSB            22
-#define SYNTH_SYNTH1_VCOREGBYPASS_MASK           0x00400000
-#define SYNTH_SYNTH1_VCOREGBYPASS_GET(x)         (((x) & SYNTH_SYNTH1_VCOREGBYPASS_MASK) >> SYNTH_SYNTH1_VCOREGBYPASS_LSB)
-#define SYNTH_SYNTH1_VCOREGBYPASS_SET(x)         (((x) << SYNTH_SYNTH1_VCOREGBYPASS_LSB) & SYNTH_SYNTH1_VCOREGBYPASS_MASK)
-#define SYNTH_SYNTH1_VCOREGLEVEL_MSB             21
-#define SYNTH_SYNTH1_VCOREGLEVEL_LSB             20
-#define SYNTH_SYNTH1_VCOREGLEVEL_MASK            0x00300000
-#define SYNTH_SYNTH1_VCOREGLEVEL_GET(x)          (((x) & SYNTH_SYNTH1_VCOREGLEVEL_MASK) >> SYNTH_SYNTH1_VCOREGLEVEL_LSB)
-#define SYNTH_SYNTH1_VCOREGLEVEL_SET(x)          (((x) << SYNTH_SYNTH1_VCOREGLEVEL_LSB) & SYNTH_SYNTH1_VCOREGLEVEL_MASK)
-#define SYNTH_SYNTH1_VCOREGBIAS_MSB              19
-#define SYNTH_SYNTH1_VCOREGBIAS_LSB              18
-#define SYNTH_SYNTH1_VCOREGBIAS_MASK             0x000c0000
-#define SYNTH_SYNTH1_VCOREGBIAS_GET(x)           (((x) & SYNTH_SYNTH1_VCOREGBIAS_MASK) >> SYNTH_SYNTH1_VCOREGBIAS_LSB)
-#define SYNTH_SYNTH1_VCOREGBIAS_SET(x)           (((x) << SYNTH_SYNTH1_VCOREGBIAS_LSB) & SYNTH_SYNTH1_VCOREGBIAS_MASK)
-#define SYNTH_SYNTH1_SLIDINGIF_MSB               17
-#define SYNTH_SYNTH1_SLIDINGIF_LSB               17
-#define SYNTH_SYNTH1_SLIDINGIF_MASK              0x00020000
-#define SYNTH_SYNTH1_SLIDINGIF_GET(x)            (((x) & SYNTH_SYNTH1_SLIDINGIF_MASK) >> SYNTH_SYNTH1_SLIDINGIF_LSB)
-#define SYNTH_SYNTH1_SLIDINGIF_SET(x)            (((x) << SYNTH_SYNTH1_SLIDINGIF_LSB) & SYNTH_SYNTH1_SLIDINGIF_MASK)
-#define SYNTH_SYNTH1_SPARE_PWD_MSB               16
-#define SYNTH_SYNTH1_SPARE_PWD_LSB               16
-#define SYNTH_SYNTH1_SPARE_PWD_MASK              0x00010000
-#define SYNTH_SYNTH1_SPARE_PWD_GET(x)            (((x) & SYNTH_SYNTH1_SPARE_PWD_MASK) >> SYNTH_SYNTH1_SPARE_PWD_LSB)
-#define SYNTH_SYNTH1_SPARE_PWD_SET(x)            (((x) << SYNTH_SYNTH1_SPARE_PWD_LSB) & SYNTH_SYNTH1_SPARE_PWD_MASK)
-#define SYNTH_SYNTH1_CON_VDDVCOREG_MSB           15
-#define SYNTH_SYNTH1_CON_VDDVCOREG_LSB           15
-#define SYNTH_SYNTH1_CON_VDDVCOREG_MASK          0x00008000
-#define SYNTH_SYNTH1_CON_VDDVCOREG_GET(x)        (((x) & SYNTH_SYNTH1_CON_VDDVCOREG_MASK) >> SYNTH_SYNTH1_CON_VDDVCOREG_LSB)
-#define SYNTH_SYNTH1_CON_VDDVCOREG_SET(x)        (((x) << SYNTH_SYNTH1_CON_VDDVCOREG_LSB) & SYNTH_SYNTH1_CON_VDDVCOREG_MASK)
-#define SYNTH_SYNTH1_CON_IVCOREG_MSB             14
-#define SYNTH_SYNTH1_CON_IVCOREG_LSB             14
-#define SYNTH_SYNTH1_CON_IVCOREG_MASK            0x00004000
-#define SYNTH_SYNTH1_CON_IVCOREG_GET(x)          (((x) & SYNTH_SYNTH1_CON_IVCOREG_MASK) >> SYNTH_SYNTH1_CON_IVCOREG_LSB)
-#define SYNTH_SYNTH1_CON_IVCOREG_SET(x)          (((x) << SYNTH_SYNTH1_CON_IVCOREG_LSB) & SYNTH_SYNTH1_CON_IVCOREG_MASK)
-#define SYNTH_SYNTH1_CON_IVCOBUF_MSB             13
-#define SYNTH_SYNTH1_CON_IVCOBUF_LSB             13
-#define SYNTH_SYNTH1_CON_IVCOBUF_MASK            0x00002000
-#define SYNTH_SYNTH1_CON_IVCOBUF_GET(x)          (((x) & SYNTH_SYNTH1_CON_IVCOBUF_MASK) >> SYNTH_SYNTH1_CON_IVCOBUF_LSB)
-#define SYNTH_SYNTH1_CON_IVCOBUF_SET(x)          (((x) << SYNTH_SYNTH1_CON_IVCOBUF_LSB) & SYNTH_SYNTH1_CON_IVCOBUF_MASK)
-#define SYNTH_SYNTH1_SEL_VCMONABUS_MSB           12
-#define SYNTH_SYNTH1_SEL_VCMONABUS_LSB           10
-#define SYNTH_SYNTH1_SEL_VCMONABUS_MASK          0x00001c00
-#define SYNTH_SYNTH1_SEL_VCMONABUS_GET(x)        (((x) & SYNTH_SYNTH1_SEL_VCMONABUS_MASK) >> SYNTH_SYNTH1_SEL_VCMONABUS_LSB)
-#define SYNTH_SYNTH1_SEL_VCMONABUS_SET(x)        (((x) << SYNTH_SYNTH1_SEL_VCMONABUS_LSB) & SYNTH_SYNTH1_SEL_VCMONABUS_MASK)
-#define SYNTH_SYNTH1_PWUP_VCOBUF_PD_MSB          9
-#define SYNTH_SYNTH1_PWUP_VCOBUF_PD_LSB          9
-#define SYNTH_SYNTH1_PWUP_VCOBUF_PD_MASK         0x00000200
-#define SYNTH_SYNTH1_PWUP_VCOBUF_PD_GET(x)       (((x) & SYNTH_SYNTH1_PWUP_VCOBUF_PD_MASK) >> SYNTH_SYNTH1_PWUP_VCOBUF_PD_LSB)
-#define SYNTH_SYNTH1_PWUP_VCOBUF_PD_SET(x)       (((x) << SYNTH_SYNTH1_PWUP_VCOBUF_PD_LSB) & SYNTH_SYNTH1_PWUP_VCOBUF_PD_MASK)
-#define SYNTH_SYNTH1_PWUP_LODIV_PD_MSB           8
-#define SYNTH_SYNTH1_PWUP_LODIV_PD_LSB           8
-#define SYNTH_SYNTH1_PWUP_LODIV_PD_MASK          0x00000100
-#define SYNTH_SYNTH1_PWUP_LODIV_PD_GET(x)        (((x) & SYNTH_SYNTH1_PWUP_LODIV_PD_MASK) >> SYNTH_SYNTH1_PWUP_LODIV_PD_LSB)
-#define SYNTH_SYNTH1_PWUP_LODIV_PD_SET(x)        (((x) << SYNTH_SYNTH1_PWUP_LODIV_PD_LSB) & SYNTH_SYNTH1_PWUP_LODIV_PD_MASK)
-#define SYNTH_SYNTH1_PWUP_LOMIX_PD_MSB           7
-#define SYNTH_SYNTH1_PWUP_LOMIX_PD_LSB           7
-#define SYNTH_SYNTH1_PWUP_LOMIX_PD_MASK          0x00000080
-#define SYNTH_SYNTH1_PWUP_LOMIX_PD_GET(x)        (((x) & SYNTH_SYNTH1_PWUP_LOMIX_PD_MASK) >> SYNTH_SYNTH1_PWUP_LOMIX_PD_LSB)
-#define SYNTH_SYNTH1_PWUP_LOMIX_PD_SET(x)        (((x) << SYNTH_SYNTH1_PWUP_LOMIX_PD_LSB) & SYNTH_SYNTH1_PWUP_LOMIX_PD_MASK)
-#define SYNTH_SYNTH1_PWUP_LOBUF5G_PD_MSB         6
-#define SYNTH_SYNTH1_PWUP_LOBUF5G_PD_LSB         6
-#define SYNTH_SYNTH1_PWUP_LOBUF5G_PD_MASK        0x00000040
-#define SYNTH_SYNTH1_PWUP_LOBUF5G_PD_GET(x)      (((x) & SYNTH_SYNTH1_PWUP_LOBUF5G_PD_MASK) >> SYNTH_SYNTH1_PWUP_LOBUF5G_PD_LSB)
-#define SYNTH_SYNTH1_PWUP_LOBUF5G_PD_SET(x)      (((x) << SYNTH_SYNTH1_PWUP_LOBUF5G_PD_LSB) & SYNTH_SYNTH1_PWUP_LOBUF5G_PD_MASK)
-#define SYNTH_SYNTH1_MONITOR_FB_MSB              5
-#define SYNTH_SYNTH1_MONITOR_FB_LSB              5
-#define SYNTH_SYNTH1_MONITOR_FB_MASK             0x00000020
-#define SYNTH_SYNTH1_MONITOR_FB_GET(x)           (((x) & SYNTH_SYNTH1_MONITOR_FB_MASK) >> SYNTH_SYNTH1_MONITOR_FB_LSB)
-#define SYNTH_SYNTH1_MONITOR_FB_SET(x)           (((x) << SYNTH_SYNTH1_MONITOR_FB_LSB) & SYNTH_SYNTH1_MONITOR_FB_MASK)
-#define SYNTH_SYNTH1_MONITOR_REF_MSB             4
-#define SYNTH_SYNTH1_MONITOR_REF_LSB             4
-#define SYNTH_SYNTH1_MONITOR_REF_MASK            0x00000010
-#define SYNTH_SYNTH1_MONITOR_REF_GET(x)          (((x) & SYNTH_SYNTH1_MONITOR_REF_MASK) >> SYNTH_SYNTH1_MONITOR_REF_LSB)
-#define SYNTH_SYNTH1_MONITOR_REF_SET(x)          (((x) << SYNTH_SYNTH1_MONITOR_REF_LSB) & SYNTH_SYNTH1_MONITOR_REF_MASK)
-#define SYNTH_SYNTH1_MONITOR_FB_DIV2_MSB         3
-#define SYNTH_SYNTH1_MONITOR_FB_DIV2_LSB         3
-#define SYNTH_SYNTH1_MONITOR_FB_DIV2_MASK        0x00000008
-#define SYNTH_SYNTH1_MONITOR_FB_DIV2_GET(x)      (((x) & SYNTH_SYNTH1_MONITOR_FB_DIV2_MASK) >> SYNTH_SYNTH1_MONITOR_FB_DIV2_LSB)
-#define SYNTH_SYNTH1_MONITOR_FB_DIV2_SET(x)      (((x) << SYNTH_SYNTH1_MONITOR_FB_DIV2_LSB) & SYNTH_SYNTH1_MONITOR_FB_DIV2_MASK)
-#define SYNTH_SYNTH1_MONITOR_VC2HIGH_MSB         2
-#define SYNTH_SYNTH1_MONITOR_VC2HIGH_LSB         2
-#define SYNTH_SYNTH1_MONITOR_VC2HIGH_MASK        0x00000004
-#define SYNTH_SYNTH1_MONITOR_VC2HIGH_GET(x)      (((x) & SYNTH_SYNTH1_MONITOR_VC2HIGH_MASK) >> SYNTH_SYNTH1_MONITOR_VC2HIGH_LSB)
-#define SYNTH_SYNTH1_MONITOR_VC2HIGH_SET(x)      (((x) << SYNTH_SYNTH1_MONITOR_VC2HIGH_LSB) & SYNTH_SYNTH1_MONITOR_VC2HIGH_MASK)
-#define SYNTH_SYNTH1_MONITOR_VC2LOW_MSB          1
-#define SYNTH_SYNTH1_MONITOR_VC2LOW_LSB          1
-#define SYNTH_SYNTH1_MONITOR_VC2LOW_MASK         0x00000002
-#define SYNTH_SYNTH1_MONITOR_VC2LOW_GET(x)       (((x) & SYNTH_SYNTH1_MONITOR_VC2LOW_MASK) >> SYNTH_SYNTH1_MONITOR_VC2LOW_LSB)
-#define SYNTH_SYNTH1_MONITOR_VC2LOW_SET(x)       (((x) << SYNTH_SYNTH1_MONITOR_VC2LOW_LSB) & SYNTH_SYNTH1_MONITOR_VC2LOW_MASK)
-#define SYNTH_SYNTH1_MONITOR_SYNTHLOCKVCOK_MSB   0
-#define SYNTH_SYNTH1_MONITOR_SYNTHLOCKVCOK_LSB   0
-#define SYNTH_SYNTH1_MONITOR_SYNTHLOCKVCOK_MASK  0x00000001
-#define SYNTH_SYNTH1_MONITOR_SYNTHLOCKVCOK_GET(x) (((x) & SYNTH_SYNTH1_MONITOR_SYNTHLOCKVCOK_MASK) >> SYNTH_SYNTH1_MONITOR_SYNTHLOCKVCOK_LSB)
-#define SYNTH_SYNTH1_MONITOR_SYNTHLOCKVCOK_SET(x) (((x) << SYNTH_SYNTH1_MONITOR_SYNTHLOCKVCOK_LSB) & SYNTH_SYNTH1_MONITOR_SYNTHLOCKVCOK_MASK)
-
-#define SYNTH_SYNTH2_ADDRESS                     0x00000004
-#define SYNTH_SYNTH2_OFFSET                      0x00000004
-#define SYNTH_SYNTH2_VC_CAL_REF_MSB              31
-#define SYNTH_SYNTH2_VC_CAL_REF_LSB              29
-#define SYNTH_SYNTH2_VC_CAL_REF_MASK             0xe0000000
-#define SYNTH_SYNTH2_VC_CAL_REF_GET(x)           (((x) & SYNTH_SYNTH2_VC_CAL_REF_MASK) >> SYNTH_SYNTH2_VC_CAL_REF_LSB)
-#define SYNTH_SYNTH2_VC_CAL_REF_SET(x)           (((x) << SYNTH_SYNTH2_VC_CAL_REF_LSB) & SYNTH_SYNTH2_VC_CAL_REF_MASK)
-#define SYNTH_SYNTH2_VC_HI_REF_MSB               28
-#define SYNTH_SYNTH2_VC_HI_REF_LSB               26
-#define SYNTH_SYNTH2_VC_HI_REF_MASK              0x1c000000
-#define SYNTH_SYNTH2_VC_HI_REF_GET(x)            (((x) & SYNTH_SYNTH2_VC_HI_REF_MASK) >> SYNTH_SYNTH2_VC_HI_REF_LSB)
-#define SYNTH_SYNTH2_VC_HI_REF_SET(x)            (((x) << SYNTH_SYNTH2_VC_HI_REF_LSB) & SYNTH_SYNTH2_VC_HI_REF_MASK)
-#define SYNTH_SYNTH2_VC_MID_REF_MSB              25
-#define SYNTH_SYNTH2_VC_MID_REF_LSB              23
-#define SYNTH_SYNTH2_VC_MID_REF_MASK             0x03800000
-#define SYNTH_SYNTH2_VC_MID_REF_GET(x)           (((x) & SYNTH_SYNTH2_VC_MID_REF_MASK) >> SYNTH_SYNTH2_VC_MID_REF_LSB)
-#define SYNTH_SYNTH2_VC_MID_REF_SET(x)           (((x) << SYNTH_SYNTH2_VC_MID_REF_LSB) & SYNTH_SYNTH2_VC_MID_REF_MASK)
-#define SYNTH_SYNTH2_VC_LOW_REF_MSB              22
-#define SYNTH_SYNTH2_VC_LOW_REF_LSB              20
-#define SYNTH_SYNTH2_VC_LOW_REF_MASK             0x00700000
-#define SYNTH_SYNTH2_VC_LOW_REF_GET(x)           (((x) & SYNTH_SYNTH2_VC_LOW_REF_MASK) >> SYNTH_SYNTH2_VC_LOW_REF_LSB)
-#define SYNTH_SYNTH2_VC_LOW_REF_SET(x)           (((x) << SYNTH_SYNTH2_VC_LOW_REF_LSB) & SYNTH_SYNTH2_VC_LOW_REF_MASK)
-#define SYNTH_SYNTH2_LOOP_3RD_ORDER_R_MSB        19
-#define SYNTH_SYNTH2_LOOP_3RD_ORDER_R_LSB        15
-#define SYNTH_SYNTH2_LOOP_3RD_ORDER_R_MASK       0x000f8000
-#define SYNTH_SYNTH2_LOOP_3RD_ORDER_R_GET(x)     (((x) & SYNTH_SYNTH2_LOOP_3RD_ORDER_R_MASK) >> SYNTH_SYNTH2_LOOP_3RD_ORDER_R_LSB)
-#define SYNTH_SYNTH2_LOOP_3RD_ORDER_R_SET(x)     (((x) << SYNTH_SYNTH2_LOOP_3RD_ORDER_R_LSB) & SYNTH_SYNTH2_LOOP_3RD_ORDER_R_MASK)
-#define SYNTH_SYNTH2_LOOP_CP_MSB                 14
-#define SYNTH_SYNTH2_LOOP_CP_LSB                 10
-#define SYNTH_SYNTH2_LOOP_CP_MASK                0x00007c00
-#define SYNTH_SYNTH2_LOOP_CP_GET(x)              (((x) & SYNTH_SYNTH2_LOOP_CP_MASK) >> SYNTH_SYNTH2_LOOP_CP_LSB)
-#define SYNTH_SYNTH2_LOOP_CP_SET(x)              (((x) << SYNTH_SYNTH2_LOOP_CP_LSB) & SYNTH_SYNTH2_LOOP_CP_MASK)
-#define SYNTH_SYNTH2_LOOP_RS_MSB                 9
-#define SYNTH_SYNTH2_LOOP_RS_LSB                 5
-#define SYNTH_SYNTH2_LOOP_RS_MASK                0x000003e0
-#define SYNTH_SYNTH2_LOOP_RS_GET(x)              (((x) & SYNTH_SYNTH2_LOOP_RS_MASK) >> SYNTH_SYNTH2_LOOP_RS_LSB)
-#define SYNTH_SYNTH2_LOOP_RS_SET(x)              (((x) << SYNTH_SYNTH2_LOOP_RS_LSB) & SYNTH_SYNTH2_LOOP_RS_MASK)
-#define SYNTH_SYNTH2_LOOP_CS_MSB                 4
-#define SYNTH_SYNTH2_LOOP_CS_LSB                 3
-#define SYNTH_SYNTH2_LOOP_CS_MASK                0x00000018
-#define SYNTH_SYNTH2_LOOP_CS_GET(x)              (((x) & SYNTH_SYNTH2_LOOP_CS_MASK) >> SYNTH_SYNTH2_LOOP_CS_LSB)
-#define SYNTH_SYNTH2_LOOP_CS_SET(x)              (((x) << SYNTH_SYNTH2_LOOP_CS_LSB) & SYNTH_SYNTH2_LOOP_CS_MASK)
-#define SYNTH_SYNTH2_SPARE_BITS_MSB              2
-#define SYNTH_SYNTH2_SPARE_BITS_LSB              0
-#define SYNTH_SYNTH2_SPARE_BITS_MASK             0x00000007
-#define SYNTH_SYNTH2_SPARE_BITS_GET(x)           (((x) & SYNTH_SYNTH2_SPARE_BITS_MASK) >> SYNTH_SYNTH2_SPARE_BITS_LSB)
-#define SYNTH_SYNTH2_SPARE_BITS_SET(x)           (((x) << SYNTH_SYNTH2_SPARE_BITS_LSB) & SYNTH_SYNTH2_SPARE_BITS_MASK)
-
-#define SYNTH_SYNTH3_ADDRESS                     0x00000008
-#define SYNTH_SYNTH3_OFFSET                      0x00000008
-#define SYNTH_SYNTH3_DIS_CLK_XTAL_MSB            31
-#define SYNTH_SYNTH3_DIS_CLK_XTAL_LSB            31
-#define SYNTH_SYNTH3_DIS_CLK_XTAL_MASK           0x80000000
-#define SYNTH_SYNTH3_DIS_CLK_XTAL_GET(x)         (((x) & SYNTH_SYNTH3_DIS_CLK_XTAL_MASK) >> SYNTH_SYNTH3_DIS_CLK_XTAL_LSB)
-#define SYNTH_SYNTH3_DIS_CLK_XTAL_SET(x)         (((x) << SYNTH_SYNTH3_DIS_CLK_XTAL_LSB) & SYNTH_SYNTH3_DIS_CLK_XTAL_MASK)
-#define SYNTH_SYNTH3_SEL_CLK_DIV2_MSB            30
-#define SYNTH_SYNTH3_SEL_CLK_DIV2_LSB            30
-#define SYNTH_SYNTH3_SEL_CLK_DIV2_MASK           0x40000000
-#define SYNTH_SYNTH3_SEL_CLK_DIV2_GET(x)         (((x) & SYNTH_SYNTH3_SEL_CLK_DIV2_MASK) >> SYNTH_SYNTH3_SEL_CLK_DIV2_LSB)
-#define SYNTH_SYNTH3_SEL_CLK_DIV2_SET(x)         (((x) << SYNTH_SYNTH3_SEL_CLK_DIV2_LSB) & SYNTH_SYNTH3_SEL_CLK_DIV2_MASK)
-#define SYNTH_SYNTH3_WAIT_SHORTR_PWRUP_MSB       29
-#define SYNTH_SYNTH3_WAIT_SHORTR_PWRUP_LSB       24
-#define SYNTH_SYNTH3_WAIT_SHORTR_PWRUP_MASK      0x3f000000
-#define SYNTH_SYNTH3_WAIT_SHORTR_PWRUP_GET(x)    (((x) & SYNTH_SYNTH3_WAIT_SHORTR_PWRUP_MASK) >> SYNTH_SYNTH3_WAIT_SHORTR_PWRUP_LSB)
-#define SYNTH_SYNTH3_WAIT_SHORTR_PWRUP_SET(x)    (((x) << SYNTH_SYNTH3_WAIT_SHORTR_PWRUP_LSB) & SYNTH_SYNTH3_WAIT_SHORTR_PWRUP_MASK)
-#define SYNTH_SYNTH3_WAIT_PWRUP_MSB              23
-#define SYNTH_SYNTH3_WAIT_PWRUP_LSB              18
-#define SYNTH_SYNTH3_WAIT_PWRUP_MASK             0x00fc0000
-#define SYNTH_SYNTH3_WAIT_PWRUP_GET(x)           (((x) & SYNTH_SYNTH3_WAIT_PWRUP_MASK) >> SYNTH_SYNTH3_WAIT_PWRUP_LSB)
-#define SYNTH_SYNTH3_WAIT_PWRUP_SET(x)           (((x) << SYNTH_SYNTH3_WAIT_PWRUP_LSB) & SYNTH_SYNTH3_WAIT_PWRUP_MASK)
-#define SYNTH_SYNTH3_WAIT_CAL_BIN_MSB            17
-#define SYNTH_SYNTH3_WAIT_CAL_BIN_LSB            12
-#define SYNTH_SYNTH3_WAIT_CAL_BIN_MASK           0x0003f000
-#define SYNTH_SYNTH3_WAIT_CAL_BIN_GET(x)         (((x) & SYNTH_SYNTH3_WAIT_CAL_BIN_MASK) >> SYNTH_SYNTH3_WAIT_CAL_BIN_LSB)
-#define SYNTH_SYNTH3_WAIT_CAL_BIN_SET(x)         (((x) << SYNTH_SYNTH3_WAIT_CAL_BIN_LSB) & SYNTH_SYNTH3_WAIT_CAL_BIN_MASK)
-#define SYNTH_SYNTH3_WAIT_CAL_LIN_MSB            11
-#define SYNTH_SYNTH3_WAIT_CAL_LIN_LSB            6
-#define SYNTH_SYNTH3_WAIT_CAL_LIN_MASK           0x00000fc0
-#define SYNTH_SYNTH3_WAIT_CAL_LIN_GET(x)         (((x) & SYNTH_SYNTH3_WAIT_CAL_LIN_MASK) >> SYNTH_SYNTH3_WAIT_CAL_LIN_LSB)
-#define SYNTH_SYNTH3_WAIT_CAL_LIN_SET(x)         (((x) << SYNTH_SYNTH3_WAIT_CAL_LIN_LSB) & SYNTH_SYNTH3_WAIT_CAL_LIN_MASK)
-#define SYNTH_SYNTH3_WAIT_VC_CHECK_MSB           5
-#define SYNTH_SYNTH3_WAIT_VC_CHECK_LSB           0
-#define SYNTH_SYNTH3_WAIT_VC_CHECK_MASK          0x0000003f
-#define SYNTH_SYNTH3_WAIT_VC_CHECK_GET(x)        (((x) & SYNTH_SYNTH3_WAIT_VC_CHECK_MASK) >> SYNTH_SYNTH3_WAIT_VC_CHECK_LSB)
-#define SYNTH_SYNTH3_WAIT_VC_CHECK_SET(x)        (((x) << SYNTH_SYNTH3_WAIT_VC_CHECK_LSB) & SYNTH_SYNTH3_WAIT_VC_CHECK_MASK)
-
-#define SYNTH_SYNTH4_ADDRESS                     0x0000000c
-#define SYNTH_SYNTH4_OFFSET                      0x0000000c
-#define SYNTH_SYNTH4_DIS_LIN_CAPSEARCH_MSB       31
-#define SYNTH_SYNTH4_DIS_LIN_CAPSEARCH_LSB       31
-#define SYNTH_SYNTH4_DIS_LIN_CAPSEARCH_MASK      0x80000000
-#define SYNTH_SYNTH4_DIS_LIN_CAPSEARCH_GET(x)    (((x) & SYNTH_SYNTH4_DIS_LIN_CAPSEARCH_MASK) >> SYNTH_SYNTH4_DIS_LIN_CAPSEARCH_LSB)
-#define SYNTH_SYNTH4_DIS_LIN_CAPSEARCH_SET(x)    (((x) << SYNTH_SYNTH4_DIS_LIN_CAPSEARCH_LSB) & SYNTH_SYNTH4_DIS_LIN_CAPSEARCH_MASK)
-#define SYNTH_SYNTH4_DIS_LOSTVC_MSB              30
-#define SYNTH_SYNTH4_DIS_LOSTVC_LSB              30
-#define SYNTH_SYNTH4_DIS_LOSTVC_MASK             0x40000000
-#define SYNTH_SYNTH4_DIS_LOSTVC_GET(x)           (((x) & SYNTH_SYNTH4_DIS_LOSTVC_MASK) >> SYNTH_SYNTH4_DIS_LOSTVC_LSB)
-#define SYNTH_SYNTH4_DIS_LOSTVC_SET(x)           (((x) << SYNTH_SYNTH4_DIS_LOSTVC_LSB) & SYNTH_SYNTH4_DIS_LOSTVC_MASK)
-#define SYNTH_SYNTH4_ALWAYS_SHORTR_MSB           29
-#define SYNTH_SYNTH4_ALWAYS_SHORTR_LSB           29
-#define SYNTH_SYNTH4_ALWAYS_SHORTR_MASK          0x20000000
-#define SYNTH_SYNTH4_ALWAYS_SHORTR_GET(x)        (((x) & SYNTH_SYNTH4_ALWAYS_SHORTR_MASK) >> SYNTH_SYNTH4_ALWAYS_SHORTR_LSB)
-#define SYNTH_SYNTH4_ALWAYS_SHORTR_SET(x)        (((x) << SYNTH_SYNTH4_ALWAYS_SHORTR_LSB) & SYNTH_SYNTH4_ALWAYS_SHORTR_MASK)
-#define SYNTH_SYNTH4_SHORTR_UNTIL_LOCKED_MSB     28
-#define SYNTH_SYNTH4_SHORTR_UNTIL_LOCKED_LSB     28
-#define SYNTH_SYNTH4_SHORTR_UNTIL_LOCKED_MASK    0x10000000
-#define SYNTH_SYNTH4_SHORTR_UNTIL_LOCKED_GET(x)  (((x) & SYNTH_SYNTH4_SHORTR_UNTIL_LOCKED_MASK) >> SYNTH_SYNTH4_SHORTR_UNTIL_LOCKED_LSB)
-#define SYNTH_SYNTH4_SHORTR_UNTIL_LOCKED_SET(x)  (((x) << SYNTH_SYNTH4_SHORTR_UNTIL_LOCKED_LSB) & SYNTH_SYNTH4_SHORTR_UNTIL_LOCKED_MASK)
-#define SYNTH_SYNTH4_FORCE_PINVC_MSB             27
-#define SYNTH_SYNTH4_FORCE_PINVC_LSB             27
-#define SYNTH_SYNTH4_FORCE_PINVC_MASK            0x08000000
-#define SYNTH_SYNTH4_FORCE_PINVC_GET(x)          (((x) & SYNTH_SYNTH4_FORCE_PINVC_MASK) >> SYNTH_SYNTH4_FORCE_PINVC_LSB)
-#define SYNTH_SYNTH4_FORCE_PINVC_SET(x)          (((x) << SYNTH_SYNTH4_FORCE_PINVC_LSB) & SYNTH_SYNTH4_FORCE_PINVC_MASK)
-#define SYNTH_SYNTH4_FORCE_VCOCAP_MSB            26
-#define SYNTH_SYNTH4_FORCE_VCOCAP_LSB            26
-#define SYNTH_SYNTH4_FORCE_VCOCAP_MASK           0x04000000
-#define SYNTH_SYNTH4_FORCE_VCOCAP_GET(x)         (((x) & SYNTH_SYNTH4_FORCE_VCOCAP_MASK) >> SYNTH_SYNTH4_FORCE_VCOCAP_LSB)
-#define SYNTH_SYNTH4_FORCE_VCOCAP_SET(x)         (((x) << SYNTH_SYNTH4_FORCE_VCOCAP_LSB) & SYNTH_SYNTH4_FORCE_VCOCAP_MASK)
-#define SYNTH_SYNTH4_VCOCAP_OVR_MSB              25
-#define SYNTH_SYNTH4_VCOCAP_OVR_LSB              18
-#define SYNTH_SYNTH4_VCOCAP_OVR_MASK             0x03fc0000
-#define SYNTH_SYNTH4_VCOCAP_OVR_GET(x)           (((x) & SYNTH_SYNTH4_VCOCAP_OVR_MASK) >> SYNTH_SYNTH4_VCOCAP_OVR_LSB)
-#define SYNTH_SYNTH4_VCOCAP_OVR_SET(x)           (((x) << SYNTH_SYNTH4_VCOCAP_OVR_LSB) & SYNTH_SYNTH4_VCOCAP_OVR_MASK)
-#define SYNTH_SYNTH4_VCOCAPPULLUP_MSB            17
-#define SYNTH_SYNTH4_VCOCAPPULLUP_LSB            17
-#define SYNTH_SYNTH4_VCOCAPPULLUP_MASK           0x00020000
-#define SYNTH_SYNTH4_VCOCAPPULLUP_GET(x)         (((x) & SYNTH_SYNTH4_VCOCAPPULLUP_MASK) >> SYNTH_SYNTH4_VCOCAPPULLUP_LSB)
-#define SYNTH_SYNTH4_VCOCAPPULLUP_SET(x)         (((x) << SYNTH_SYNTH4_VCOCAPPULLUP_LSB) & SYNTH_SYNTH4_VCOCAPPULLUP_MASK)
-#define SYNTH_SYNTH4_REFDIVSEL_MSB               16
-#define SYNTH_SYNTH4_REFDIVSEL_LSB               15
-#define SYNTH_SYNTH4_REFDIVSEL_MASK              0x00018000
-#define SYNTH_SYNTH4_REFDIVSEL_GET(x)            (((x) & SYNTH_SYNTH4_REFDIVSEL_MASK) >> SYNTH_SYNTH4_REFDIVSEL_LSB)
-#define SYNTH_SYNTH4_REFDIVSEL_SET(x)            (((x) << SYNTH_SYNTH4_REFDIVSEL_LSB) & SYNTH_SYNTH4_REFDIVSEL_MASK)
-#define SYNTH_SYNTH4_PFDDELAY_MSB                14
-#define SYNTH_SYNTH4_PFDDELAY_LSB                14
-#define SYNTH_SYNTH4_PFDDELAY_MASK               0x00004000
-#define SYNTH_SYNTH4_PFDDELAY_GET(x)             (((x) & SYNTH_SYNTH4_PFDDELAY_MASK) >> SYNTH_SYNTH4_PFDDELAY_LSB)
-#define SYNTH_SYNTH4_PFDDELAY_SET(x)             (((x) << SYNTH_SYNTH4_PFDDELAY_LSB) & SYNTH_SYNTH4_PFDDELAY_MASK)
-#define SYNTH_SYNTH4_PFD_DISABLE_MSB             13
-#define SYNTH_SYNTH4_PFD_DISABLE_LSB             13
-#define SYNTH_SYNTH4_PFD_DISABLE_MASK            0x00002000
-#define SYNTH_SYNTH4_PFD_DISABLE_GET(x)          (((x) & SYNTH_SYNTH4_PFD_DISABLE_MASK) >> SYNTH_SYNTH4_PFD_DISABLE_LSB)
-#define SYNTH_SYNTH4_PFD_DISABLE_SET(x)          (((x) << SYNTH_SYNTH4_PFD_DISABLE_LSB) & SYNTH_SYNTH4_PFD_DISABLE_MASK)
-#define SYNTH_SYNTH4_PRESCSEL_MSB                12
-#define SYNTH_SYNTH4_PRESCSEL_LSB                11
-#define SYNTH_SYNTH4_PRESCSEL_MASK               0x00001800
-#define SYNTH_SYNTH4_PRESCSEL_GET(x)             (((x) & SYNTH_SYNTH4_PRESCSEL_MASK) >> SYNTH_SYNTH4_PRESCSEL_LSB)
-#define SYNTH_SYNTH4_PRESCSEL_SET(x)             (((x) << SYNTH_SYNTH4_PRESCSEL_LSB) & SYNTH_SYNTH4_PRESCSEL_MASK)
-#define SYNTH_SYNTH4_RESET_PRESC_MSB             10
-#define SYNTH_SYNTH4_RESET_PRESC_LSB             10
-#define SYNTH_SYNTH4_RESET_PRESC_MASK            0x00000400
-#define SYNTH_SYNTH4_RESET_PRESC_GET(x)          (((x) & SYNTH_SYNTH4_RESET_PRESC_MASK) >> SYNTH_SYNTH4_RESET_PRESC_LSB)
-#define SYNTH_SYNTH4_RESET_PRESC_SET(x)          (((x) << SYNTH_SYNTH4_RESET_PRESC_LSB) & SYNTH_SYNTH4_RESET_PRESC_MASK)
-#define SYNTH_SYNTH4_SDM_DISABLE_MSB             9
-#define SYNTH_SYNTH4_SDM_DISABLE_LSB             9
-#define SYNTH_SYNTH4_SDM_DISABLE_MASK            0x00000200
-#define SYNTH_SYNTH4_SDM_DISABLE_GET(x)          (((x) & SYNTH_SYNTH4_SDM_DISABLE_MASK) >> SYNTH_SYNTH4_SDM_DISABLE_LSB)
-#define SYNTH_SYNTH4_SDM_DISABLE_SET(x)          (((x) << SYNTH_SYNTH4_SDM_DISABLE_LSB) & SYNTH_SYNTH4_SDM_DISABLE_MASK)
-#define SYNTH_SYNTH4_SDM_MODE_MSB                8
-#define SYNTH_SYNTH4_SDM_MODE_LSB                8
-#define SYNTH_SYNTH4_SDM_MODE_MASK               0x00000100
-#define SYNTH_SYNTH4_SDM_MODE_GET(x)             (((x) & SYNTH_SYNTH4_SDM_MODE_MASK) >> SYNTH_SYNTH4_SDM_MODE_LSB)
-#define SYNTH_SYNTH4_SDM_MODE_SET(x)             (((x) << SYNTH_SYNTH4_SDM_MODE_LSB) & SYNTH_SYNTH4_SDM_MODE_MASK)
-#define SYNTH_SYNTH4_SDM_DITHER_MSB              7
-#define SYNTH_SYNTH4_SDM_DITHER_LSB              6
-#define SYNTH_SYNTH4_SDM_DITHER_MASK             0x000000c0
-#define SYNTH_SYNTH4_SDM_DITHER_GET(x)           (((x) & SYNTH_SYNTH4_SDM_DITHER_MASK) >> SYNTH_SYNTH4_SDM_DITHER_LSB)
-#define SYNTH_SYNTH4_SDM_DITHER_SET(x)           (((x) << SYNTH_SYNTH4_SDM_DITHER_LSB) & SYNTH_SYNTH4_SDM_DITHER_MASK)
-#define SYNTH_SYNTH4_PSCOUNT_FBSEL_MSB           5
-#define SYNTH_SYNTH4_PSCOUNT_FBSEL_LSB           5
-#define SYNTH_SYNTH4_PSCOUNT_FBSEL_MASK          0x00000020
-#define SYNTH_SYNTH4_PSCOUNT_FBSEL_GET(x)        (((x) & SYNTH_SYNTH4_PSCOUNT_FBSEL_MASK) >> SYNTH_SYNTH4_PSCOUNT_FBSEL_LSB)
-#define SYNTH_SYNTH4_PSCOUNT_FBSEL_SET(x)        (((x) << SYNTH_SYNTH4_PSCOUNT_FBSEL_LSB) & SYNTH_SYNTH4_PSCOUNT_FBSEL_MASK)
-#define SYNTH_SYNTH4_SEL_CLKXTAL_EDGE_MSB        4
-#define SYNTH_SYNTH4_SEL_CLKXTAL_EDGE_LSB        4
-#define SYNTH_SYNTH4_SEL_CLKXTAL_EDGE_MASK       0x00000010
-#define SYNTH_SYNTH4_SEL_CLKXTAL_EDGE_GET(x)     (((x) & SYNTH_SYNTH4_SEL_CLKXTAL_EDGE_MASK) >> SYNTH_SYNTH4_SEL_CLKXTAL_EDGE_LSB)
-#define SYNTH_SYNTH4_SEL_CLKXTAL_EDGE_SET(x)     (((x) << SYNTH_SYNTH4_SEL_CLKXTAL_EDGE_LSB) & SYNTH_SYNTH4_SEL_CLKXTAL_EDGE_MASK)
-#define SYNTH_SYNTH4_SPARE_MISC_MSB              3
-#define SYNTH_SYNTH4_SPARE_MISC_LSB              2
-#define SYNTH_SYNTH4_SPARE_MISC_MASK             0x0000000c
-#define SYNTH_SYNTH4_SPARE_MISC_GET(x)           (((x) & SYNTH_SYNTH4_SPARE_MISC_MASK) >> SYNTH_SYNTH4_SPARE_MISC_LSB)
-#define SYNTH_SYNTH4_SPARE_MISC_SET(x)           (((x) << SYNTH_SYNTH4_SPARE_MISC_LSB) & SYNTH_SYNTH4_SPARE_MISC_MASK)
-#define SYNTH_SYNTH4_LONGSHIFTSEL_MSB            1
-#define SYNTH_SYNTH4_LONGSHIFTSEL_LSB            1
-#define SYNTH_SYNTH4_LONGSHIFTSEL_MASK           0x00000002
-#define SYNTH_SYNTH4_LONGSHIFTSEL_GET(x)         (((x) & SYNTH_SYNTH4_LONGSHIFTSEL_MASK) >> SYNTH_SYNTH4_LONGSHIFTSEL_LSB)
-#define SYNTH_SYNTH4_LONGSHIFTSEL_SET(x)         (((x) << SYNTH_SYNTH4_LONGSHIFTSEL_LSB) & SYNTH_SYNTH4_LONGSHIFTSEL_MASK)
-#define SYNTH_SYNTH4_FORCE_SHIFTREG_MSB          0
-#define SYNTH_SYNTH4_FORCE_SHIFTREG_LSB          0
-#define SYNTH_SYNTH4_FORCE_SHIFTREG_MASK         0x00000001
-#define SYNTH_SYNTH4_FORCE_SHIFTREG_GET(x)       (((x) & SYNTH_SYNTH4_FORCE_SHIFTREG_MASK) >> SYNTH_SYNTH4_FORCE_SHIFTREG_LSB)
-#define SYNTH_SYNTH4_FORCE_SHIFTREG_SET(x)       (((x) << SYNTH_SYNTH4_FORCE_SHIFTREG_LSB) & SYNTH_SYNTH4_FORCE_SHIFTREG_MASK)
-
-#define SYNTH_SYNTH5_ADDRESS                     0x00000010
-#define SYNTH_SYNTH5_OFFSET                      0x00000010
-#define SYNTH_SYNTH5_LOOP_IP0_MSB                31
-#define SYNTH_SYNTH5_LOOP_IP0_LSB                28
-#define SYNTH_SYNTH5_LOOP_IP0_MASK               0xf0000000
-#define SYNTH_SYNTH5_LOOP_IP0_GET(x)             (((x) & SYNTH_SYNTH5_LOOP_IP0_MASK) >> SYNTH_SYNTH5_LOOP_IP0_LSB)
-#define SYNTH_SYNTH5_LOOP_IP0_SET(x)             (((x) << SYNTH_SYNTH5_LOOP_IP0_LSB) & SYNTH_SYNTH5_LOOP_IP0_MASK)
-#define SYNTH_SYNTH5_SLOPE_IP_MSB                27
-#define SYNTH_SYNTH5_SLOPE_IP_LSB                25
-#define SYNTH_SYNTH5_SLOPE_IP_MASK               0x0e000000
-#define SYNTH_SYNTH5_SLOPE_IP_GET(x)             (((x) & SYNTH_SYNTH5_SLOPE_IP_MASK) >> SYNTH_SYNTH5_SLOPE_IP_LSB)
-#define SYNTH_SYNTH5_SLOPE_IP_SET(x)             (((x) << SYNTH_SYNTH5_SLOPE_IP_LSB) & SYNTH_SYNTH5_SLOPE_IP_MASK)
-#define SYNTH_SYNTH5_CPBIAS_MSB                  24
-#define SYNTH_SYNTH5_CPBIAS_LSB                  23
-#define SYNTH_SYNTH5_CPBIAS_MASK                 0x01800000
-#define SYNTH_SYNTH5_CPBIAS_GET(x)               (((x) & SYNTH_SYNTH5_CPBIAS_MASK) >> SYNTH_SYNTH5_CPBIAS_LSB)
-#define SYNTH_SYNTH5_CPBIAS_SET(x)               (((x) << SYNTH_SYNTH5_CPBIAS_LSB) & SYNTH_SYNTH5_CPBIAS_MASK)
-#define SYNTH_SYNTH5_CPSTEERING_EN_MSB           22
-#define SYNTH_SYNTH5_CPSTEERING_EN_LSB           22
-#define SYNTH_SYNTH5_CPSTEERING_EN_MASK          0x00400000
-#define SYNTH_SYNTH5_CPSTEERING_EN_GET(x)        (((x) & SYNTH_SYNTH5_CPSTEERING_EN_MASK) >> SYNTH_SYNTH5_CPSTEERING_EN_LSB)
-#define SYNTH_SYNTH5_CPSTEERING_EN_SET(x)        (((x) << SYNTH_SYNTH5_CPSTEERING_EN_LSB) & SYNTH_SYNTH5_CPSTEERING_EN_MASK)
-#define SYNTH_SYNTH5_CPLOWLK_MSB                 21
-#define SYNTH_SYNTH5_CPLOWLK_LSB                 21
-#define SYNTH_SYNTH5_CPLOWLK_MASK                0x00200000
-#define SYNTH_SYNTH5_CPLOWLK_GET(x)              (((x) & SYNTH_SYNTH5_CPLOWLK_MASK) >> SYNTH_SYNTH5_CPLOWLK_LSB)
-#define SYNTH_SYNTH5_CPLOWLK_SET(x)              (((x) << SYNTH_SYNTH5_CPLOWLK_LSB) & SYNTH_SYNTH5_CPLOWLK_MASK)
-#define SYNTH_SYNTH5_LOOPLEAKCUR_MSB             20
-#define SYNTH_SYNTH5_LOOPLEAKCUR_LSB             17
-#define SYNTH_SYNTH5_LOOPLEAKCUR_MASK            0x001e0000
-#define SYNTH_SYNTH5_LOOPLEAKCUR_GET(x)          (((x) & SYNTH_SYNTH5_LOOPLEAKCUR_MASK) >> SYNTH_SYNTH5_LOOPLEAKCUR_LSB)
-#define SYNTH_SYNTH5_LOOPLEAKCUR_SET(x)          (((x) << SYNTH_SYNTH5_LOOPLEAKCUR_LSB) & SYNTH_SYNTH5_LOOPLEAKCUR_MASK)
-#define SYNTH_SYNTH5_CAPRANGE1_MSB               16
-#define SYNTH_SYNTH5_CAPRANGE1_LSB               13
-#define SYNTH_SYNTH5_CAPRANGE1_MASK              0x0001e000
-#define SYNTH_SYNTH5_CAPRANGE1_GET(x)            (((x) & SYNTH_SYNTH5_CAPRANGE1_MASK) >> SYNTH_SYNTH5_CAPRANGE1_LSB)
-#define SYNTH_SYNTH5_CAPRANGE1_SET(x)            (((x) << SYNTH_SYNTH5_CAPRANGE1_LSB) & SYNTH_SYNTH5_CAPRANGE1_MASK)
-#define SYNTH_SYNTH5_CAPRANGE2_MSB               12
-#define SYNTH_SYNTH5_CAPRANGE2_LSB               9
-#define SYNTH_SYNTH5_CAPRANGE2_MASK              0x00001e00
-#define SYNTH_SYNTH5_CAPRANGE2_GET(x)            (((x) & SYNTH_SYNTH5_CAPRANGE2_MASK) >> SYNTH_SYNTH5_CAPRANGE2_LSB)
-#define SYNTH_SYNTH5_CAPRANGE2_SET(x)            (((x) << SYNTH_SYNTH5_CAPRANGE2_LSB) & SYNTH_SYNTH5_CAPRANGE2_MASK)
-#define SYNTH_SYNTH5_CAPRANGE3_MSB               8
-#define SYNTH_SYNTH5_CAPRANGE3_LSB               5
-#define SYNTH_SYNTH5_CAPRANGE3_MASK              0x000001e0
-#define SYNTH_SYNTH5_CAPRANGE3_GET(x)            (((x) & SYNTH_SYNTH5_CAPRANGE3_MASK) >> SYNTH_SYNTH5_CAPRANGE3_LSB)
-#define SYNTH_SYNTH5_CAPRANGE3_SET(x)            (((x) << SYNTH_SYNTH5_CAPRANGE3_LSB) & SYNTH_SYNTH5_CAPRANGE3_MASK)
-#define SYNTH_SYNTH5_FORCE_LOBUF5GTUNE_MSB       4
-#define SYNTH_SYNTH5_FORCE_LOBUF5GTUNE_LSB       4
-#define SYNTH_SYNTH5_FORCE_LOBUF5GTUNE_MASK      0x00000010
-#define SYNTH_SYNTH5_FORCE_LOBUF5GTUNE_GET(x)    (((x) & SYNTH_SYNTH5_FORCE_LOBUF5GTUNE_MASK) >> SYNTH_SYNTH5_FORCE_LOBUF5GTUNE_LSB)
-#define SYNTH_SYNTH5_FORCE_LOBUF5GTUNE_SET(x)    (((x) << SYNTH_SYNTH5_FORCE_LOBUF5GTUNE_LSB) & SYNTH_SYNTH5_FORCE_LOBUF5GTUNE_MASK)
-#define SYNTH_SYNTH5_LOBUF5GTUNE_OVR_MSB         3
-#define SYNTH_SYNTH5_LOBUF5GTUNE_OVR_LSB         2
-#define SYNTH_SYNTH5_LOBUF5GTUNE_OVR_MASK        0x0000000c
-#define SYNTH_SYNTH5_LOBUF5GTUNE_OVR_GET(x)      (((x) & SYNTH_SYNTH5_LOBUF5GTUNE_OVR_MASK) >> SYNTH_SYNTH5_LOBUF5GTUNE_OVR_LSB)
-#define SYNTH_SYNTH5_LOBUF5GTUNE_OVR_SET(x)      (((x) << SYNTH_SYNTH5_LOBUF5GTUNE_OVR_LSB) & SYNTH_SYNTH5_LOBUF5GTUNE_OVR_MASK)
-#define SYNTH_SYNTH5_SPARE_MSB                   1
-#define SYNTH_SYNTH5_SPARE_LSB                   0
-#define SYNTH_SYNTH5_SPARE_MASK                  0x00000003
-#define SYNTH_SYNTH5_SPARE_GET(x)                (((x) & SYNTH_SYNTH5_SPARE_MASK) >> SYNTH_SYNTH5_SPARE_LSB)
-#define SYNTH_SYNTH5_SPARE_SET(x)                (((x) << SYNTH_SYNTH5_SPARE_LSB) & SYNTH_SYNTH5_SPARE_MASK)
-
-#define SYNTH_SYNTH6_ADDRESS                     0x00000014
-#define SYNTH_SYNTH6_OFFSET                      0x00000014
-#define SYNTH_SYNTH6_IRCP_MSB                    31
-#define SYNTH_SYNTH6_IRCP_LSB                    29
-#define SYNTH_SYNTH6_IRCP_MASK                   0xe0000000
-#define SYNTH_SYNTH6_IRCP_GET(x)                 (((x) & SYNTH_SYNTH6_IRCP_MASK) >> SYNTH_SYNTH6_IRCP_LSB)
-#define SYNTH_SYNTH6_IRCP_SET(x)                 (((x) << SYNTH_SYNTH6_IRCP_LSB) & SYNTH_SYNTH6_IRCP_MASK)
-#define SYNTH_SYNTH6_IRVCMON_MSB                 28
-#define SYNTH_SYNTH6_IRVCMON_LSB                 26
-#define SYNTH_SYNTH6_IRVCMON_MASK                0x1c000000
-#define SYNTH_SYNTH6_IRVCMON_GET(x)              (((x) & SYNTH_SYNTH6_IRVCMON_MASK) >> SYNTH_SYNTH6_IRVCMON_LSB)
-#define SYNTH_SYNTH6_IRVCMON_SET(x)              (((x) << SYNTH_SYNTH6_IRVCMON_LSB) & SYNTH_SYNTH6_IRVCMON_MASK)
-#define SYNTH_SYNTH6_IRSPARE_MSB                 25
-#define SYNTH_SYNTH6_IRSPARE_LSB                 23
-#define SYNTH_SYNTH6_IRSPARE_MASK                0x03800000
-#define SYNTH_SYNTH6_IRSPARE_GET(x)              (((x) & SYNTH_SYNTH6_IRSPARE_MASK) >> SYNTH_SYNTH6_IRSPARE_LSB)
-#define SYNTH_SYNTH6_IRSPARE_SET(x)              (((x) << SYNTH_SYNTH6_IRSPARE_LSB) & SYNTH_SYNTH6_IRSPARE_MASK)
-#define SYNTH_SYNTH6_ICPRESC_MSB                 22
-#define SYNTH_SYNTH6_ICPRESC_LSB                 20
-#define SYNTH_SYNTH6_ICPRESC_MASK                0x00700000
-#define SYNTH_SYNTH6_ICPRESC_GET(x)              (((x) & SYNTH_SYNTH6_ICPRESC_MASK) >> SYNTH_SYNTH6_ICPRESC_LSB)
-#define SYNTH_SYNTH6_ICPRESC_SET(x)              (((x) << SYNTH_SYNTH6_ICPRESC_LSB) & SYNTH_SYNTH6_ICPRESC_MASK)
-#define SYNTH_SYNTH6_ICLODIV_MSB                 19
-#define SYNTH_SYNTH6_ICLODIV_LSB                 17
-#define SYNTH_SYNTH6_ICLODIV_MASK                0x000e0000
-#define SYNTH_SYNTH6_ICLODIV_GET(x)              (((x) & SYNTH_SYNTH6_ICLODIV_MASK) >> SYNTH_SYNTH6_ICLODIV_LSB)
-#define SYNTH_SYNTH6_ICLODIV_SET(x)              (((x) << SYNTH_SYNTH6_ICLODIV_LSB) & SYNTH_SYNTH6_ICLODIV_MASK)
-#define SYNTH_SYNTH6_ICLOMIX_MSB                 16
-#define SYNTH_SYNTH6_ICLOMIX_LSB                 14
-#define SYNTH_SYNTH6_ICLOMIX_MASK                0x0001c000
-#define SYNTH_SYNTH6_ICLOMIX_GET(x)              (((x) & SYNTH_SYNTH6_ICLOMIX_MASK) >> SYNTH_SYNTH6_ICLOMIX_LSB)
-#define SYNTH_SYNTH6_ICLOMIX_SET(x)              (((x) << SYNTH_SYNTH6_ICLOMIX_LSB) & SYNTH_SYNTH6_ICLOMIX_MASK)
-#define SYNTH_SYNTH6_ICSPAREA_MSB                13
-#define SYNTH_SYNTH6_ICSPAREA_LSB                11
-#define SYNTH_SYNTH6_ICSPAREA_MASK               0x00003800
-#define SYNTH_SYNTH6_ICSPAREA_GET(x)             (((x) & SYNTH_SYNTH6_ICSPAREA_MASK) >> SYNTH_SYNTH6_ICSPAREA_LSB)
-#define SYNTH_SYNTH6_ICSPAREA_SET(x)             (((x) << SYNTH_SYNTH6_ICSPAREA_LSB) & SYNTH_SYNTH6_ICSPAREA_MASK)
-#define SYNTH_SYNTH6_ICSPAREB_MSB                10
-#define SYNTH_SYNTH6_ICSPAREB_LSB                8
-#define SYNTH_SYNTH6_ICSPAREB_MASK               0x00000700
-#define SYNTH_SYNTH6_ICSPAREB_GET(x)             (((x) & SYNTH_SYNTH6_ICSPAREB_MASK) >> SYNTH_SYNTH6_ICSPAREB_LSB)
-#define SYNTH_SYNTH6_ICSPAREB_SET(x)             (((x) << SYNTH_SYNTH6_ICSPAREB_LSB) & SYNTH_SYNTH6_ICSPAREB_MASK)
-#define SYNTH_SYNTH6_ICVCO_MSB                   7
-#define SYNTH_SYNTH6_ICVCO_LSB                   5
-#define SYNTH_SYNTH6_ICVCO_MASK                  0x000000e0
-#define SYNTH_SYNTH6_ICVCO_GET(x)                (((x) & SYNTH_SYNTH6_ICVCO_MASK) >> SYNTH_SYNTH6_ICVCO_LSB)
-#define SYNTH_SYNTH6_ICVCO_SET(x)                (((x) << SYNTH_SYNTH6_ICVCO_LSB) & SYNTH_SYNTH6_ICVCO_MASK)
-#define SYNTH_SYNTH6_VCOBUFBIAS_MSB              4
-#define SYNTH_SYNTH6_VCOBUFBIAS_LSB              3
-#define SYNTH_SYNTH6_VCOBUFBIAS_MASK             0x00000018
-#define SYNTH_SYNTH6_VCOBUFBIAS_GET(x)           (((x) & SYNTH_SYNTH6_VCOBUFBIAS_MASK) >> SYNTH_SYNTH6_VCOBUFBIAS_LSB)
-#define SYNTH_SYNTH6_VCOBUFBIAS_SET(x)           (((x) << SYNTH_SYNTH6_VCOBUFBIAS_LSB) & SYNTH_SYNTH6_VCOBUFBIAS_MASK)
-#define SYNTH_SYNTH6_SPARE_BIAS_MSB              2
-#define SYNTH_SYNTH6_SPARE_BIAS_LSB              0
-#define SYNTH_SYNTH6_SPARE_BIAS_MASK             0x00000007
-#define SYNTH_SYNTH6_SPARE_BIAS_GET(x)           (((x) & SYNTH_SYNTH6_SPARE_BIAS_MASK) >> SYNTH_SYNTH6_SPARE_BIAS_LSB)
-#define SYNTH_SYNTH6_SPARE_BIAS_SET(x)           (((x) << SYNTH_SYNTH6_SPARE_BIAS_LSB) & SYNTH_SYNTH6_SPARE_BIAS_MASK)
-
-#define SYNTH_SYNTH7_ADDRESS                     0x00000018
-#define SYNTH_SYNTH7_OFFSET                      0x00000018
-#define SYNTH_SYNTH7_SYNTH_ON_MSB                31
-#define SYNTH_SYNTH7_SYNTH_ON_LSB                31
-#define SYNTH_SYNTH7_SYNTH_ON_MASK               0x80000000
-#define SYNTH_SYNTH7_SYNTH_ON_GET(x)             (((x) & SYNTH_SYNTH7_SYNTH_ON_MASK) >> SYNTH_SYNTH7_SYNTH_ON_LSB)
-#define SYNTH_SYNTH7_SYNTH_ON_SET(x)             (((x) << SYNTH_SYNTH7_SYNTH_ON_LSB) & SYNTH_SYNTH7_SYNTH_ON_MASK)
-#define SYNTH_SYNTH7_SYNTH_SM_STATE_MSB          30
-#define SYNTH_SYNTH7_SYNTH_SM_STATE_LSB          27
-#define SYNTH_SYNTH7_SYNTH_SM_STATE_MASK         0x78000000
-#define SYNTH_SYNTH7_SYNTH_SM_STATE_GET(x)       (((x) & SYNTH_SYNTH7_SYNTH_SM_STATE_MASK) >> SYNTH_SYNTH7_SYNTH_SM_STATE_LSB)
-#define SYNTH_SYNTH7_SYNTH_SM_STATE_SET(x)       (((x) << SYNTH_SYNTH7_SYNTH_SM_STATE_LSB) & SYNTH_SYNTH7_SYNTH_SM_STATE_MASK)
-#define SYNTH_SYNTH7_CAP_SEARCH_MSB              26
-#define SYNTH_SYNTH7_CAP_SEARCH_LSB              26
-#define SYNTH_SYNTH7_CAP_SEARCH_MASK             0x04000000
-#define SYNTH_SYNTH7_CAP_SEARCH_GET(x)           (((x) & SYNTH_SYNTH7_CAP_SEARCH_MASK) >> SYNTH_SYNTH7_CAP_SEARCH_LSB)
-#define SYNTH_SYNTH7_CAP_SEARCH_SET(x)           (((x) << SYNTH_SYNTH7_CAP_SEARCH_LSB) & SYNTH_SYNTH7_CAP_SEARCH_MASK)
-#define SYNTH_SYNTH7_SYNTH_LOCK_VC_OK_MSB        25
-#define SYNTH_SYNTH7_SYNTH_LOCK_VC_OK_LSB        25
-#define SYNTH_SYNTH7_SYNTH_LOCK_VC_OK_MASK       0x02000000
-#define SYNTH_SYNTH7_SYNTH_LOCK_VC_OK_GET(x)     (((x) & SYNTH_SYNTH7_SYNTH_LOCK_VC_OK_MASK) >> SYNTH_SYNTH7_SYNTH_LOCK_VC_OK_LSB)
-#define SYNTH_SYNTH7_SYNTH_LOCK_VC_OK_SET(x)     (((x) << SYNTH_SYNTH7_SYNTH_LOCK_VC_OK_LSB) & SYNTH_SYNTH7_SYNTH_LOCK_VC_OK_MASK)
-#define SYNTH_SYNTH7_PIN_VC_MSB                  24
-#define SYNTH_SYNTH7_PIN_VC_LSB                  24
-#define SYNTH_SYNTH7_PIN_VC_MASK                 0x01000000
-#define SYNTH_SYNTH7_PIN_VC_GET(x)               (((x) & SYNTH_SYNTH7_PIN_VC_MASK) >> SYNTH_SYNTH7_PIN_VC_LSB)
-#define SYNTH_SYNTH7_PIN_VC_SET(x)               (((x) << SYNTH_SYNTH7_PIN_VC_LSB) & SYNTH_SYNTH7_PIN_VC_MASK)
-#define SYNTH_SYNTH7_VCO_CAP_ST_MSB              23
-#define SYNTH_SYNTH7_VCO_CAP_ST_LSB              16
-#define SYNTH_SYNTH7_VCO_CAP_ST_MASK             0x00ff0000
-#define SYNTH_SYNTH7_VCO_CAP_ST_GET(x)           (((x) & SYNTH_SYNTH7_VCO_CAP_ST_MASK) >> SYNTH_SYNTH7_VCO_CAP_ST_LSB)
-#define SYNTH_SYNTH7_VCO_CAP_ST_SET(x)           (((x) << SYNTH_SYNTH7_VCO_CAP_ST_LSB) & SYNTH_SYNTH7_VCO_CAP_ST_MASK)
-#define SYNTH_SYNTH7_SHORT_R_MSB                 15
-#define SYNTH_SYNTH7_SHORT_R_LSB                 15
-#define SYNTH_SYNTH7_SHORT_R_MASK                0x00008000
-#define SYNTH_SYNTH7_SHORT_R_GET(x)              (((x) & SYNTH_SYNTH7_SHORT_R_MASK) >> SYNTH_SYNTH7_SHORT_R_LSB)
-#define SYNTH_SYNTH7_SHORT_R_SET(x)              (((x) << SYNTH_SYNTH7_SHORT_R_LSB) & SYNTH_SYNTH7_SHORT_R_MASK)
-#define SYNTH_SYNTH7_RESET_RFD_MSB               14
-#define SYNTH_SYNTH7_RESET_RFD_LSB               14
-#define SYNTH_SYNTH7_RESET_RFD_MASK              0x00004000
-#define SYNTH_SYNTH7_RESET_RFD_GET(x)            (((x) & SYNTH_SYNTH7_RESET_RFD_MASK) >> SYNTH_SYNTH7_RESET_RFD_LSB)
-#define SYNTH_SYNTH7_RESET_RFD_SET(x)            (((x) << SYNTH_SYNTH7_RESET_RFD_LSB) & SYNTH_SYNTH7_RESET_RFD_MASK)
-#define SYNTH_SYNTH7_RESET_PFD_MSB               13
-#define SYNTH_SYNTH7_RESET_PFD_LSB               13
-#define SYNTH_SYNTH7_RESET_PFD_MASK              0x00002000
-#define SYNTH_SYNTH7_RESET_PFD_GET(x)            (((x) & SYNTH_SYNTH7_RESET_PFD_MASK) >> SYNTH_SYNTH7_RESET_PFD_LSB)
-#define SYNTH_SYNTH7_RESET_PFD_SET(x)            (((x) << SYNTH_SYNTH7_RESET_PFD_LSB) & SYNTH_SYNTH7_RESET_PFD_MASK)
-#define SYNTH_SYNTH7_RESET_PSCOUNTERS_MSB        12
-#define SYNTH_SYNTH7_RESET_PSCOUNTERS_LSB        12
-#define SYNTH_SYNTH7_RESET_PSCOUNTERS_MASK       0x00001000
-#define SYNTH_SYNTH7_RESET_PSCOUNTERS_GET(x)     (((x) & SYNTH_SYNTH7_RESET_PSCOUNTERS_MASK) >> SYNTH_SYNTH7_RESET_PSCOUNTERS_LSB)
-#define SYNTH_SYNTH7_RESET_PSCOUNTERS_SET(x)     (((x) << SYNTH_SYNTH7_RESET_PSCOUNTERS_LSB) & SYNTH_SYNTH7_RESET_PSCOUNTERS_MASK)
-#define SYNTH_SYNTH7_RESET_SDM_B_MSB             11
-#define SYNTH_SYNTH7_RESET_SDM_B_LSB             11
-#define SYNTH_SYNTH7_RESET_SDM_B_MASK            0x00000800
-#define SYNTH_SYNTH7_RESET_SDM_B_GET(x)          (((x) & SYNTH_SYNTH7_RESET_SDM_B_MASK) >> SYNTH_SYNTH7_RESET_SDM_B_LSB)
-#define SYNTH_SYNTH7_RESET_SDM_B_SET(x)          (((x) << SYNTH_SYNTH7_RESET_SDM_B_LSB) & SYNTH_SYNTH7_RESET_SDM_B_MASK)
-#define SYNTH_SYNTH7_VC2HIGH_MSB                 10
-#define SYNTH_SYNTH7_VC2HIGH_LSB                 10
-#define SYNTH_SYNTH7_VC2HIGH_MASK                0x00000400
-#define SYNTH_SYNTH7_VC2HIGH_GET(x)              (((x) & SYNTH_SYNTH7_VC2HIGH_MASK) >> SYNTH_SYNTH7_VC2HIGH_LSB)
-#define SYNTH_SYNTH7_VC2HIGH_SET(x)              (((x) << SYNTH_SYNTH7_VC2HIGH_LSB) & SYNTH_SYNTH7_VC2HIGH_MASK)
-#define SYNTH_SYNTH7_VC2LOW_MSB                  9
-#define SYNTH_SYNTH7_VC2LOW_LSB                  9
-#define SYNTH_SYNTH7_VC2LOW_MASK                 0x00000200
-#define SYNTH_SYNTH7_VC2LOW_GET(x)               (((x) & SYNTH_SYNTH7_VC2LOW_MASK) >> SYNTH_SYNTH7_VC2LOW_LSB)
-#define SYNTH_SYNTH7_VC2LOW_SET(x)               (((x) << SYNTH_SYNTH7_VC2LOW_LSB) & SYNTH_SYNTH7_VC2LOW_MASK)
-#define SYNTH_SYNTH7_LOOP_IP_MSB                 8
-#define SYNTH_SYNTH7_LOOP_IP_LSB                 5
-#define SYNTH_SYNTH7_LOOP_IP_MASK                0x000001e0
-#define SYNTH_SYNTH7_LOOP_IP_GET(x)              (((x) & SYNTH_SYNTH7_LOOP_IP_MASK) >> SYNTH_SYNTH7_LOOP_IP_LSB)
-#define SYNTH_SYNTH7_LOOP_IP_SET(x)              (((x) << SYNTH_SYNTH7_LOOP_IP_LSB) & SYNTH_SYNTH7_LOOP_IP_MASK)
-#define SYNTH_SYNTH7_LOBUF5GTUNE_MSB             4
-#define SYNTH_SYNTH7_LOBUF5GTUNE_LSB             3
-#define SYNTH_SYNTH7_LOBUF5GTUNE_MASK            0x00000018
-#define SYNTH_SYNTH7_LOBUF5GTUNE_GET(x)          (((x) & SYNTH_SYNTH7_LOBUF5GTUNE_MASK) >> SYNTH_SYNTH7_LOBUF5GTUNE_LSB)
-#define SYNTH_SYNTH7_LOBUF5GTUNE_SET(x)          (((x) << SYNTH_SYNTH7_LOBUF5GTUNE_LSB) & SYNTH_SYNTH7_LOBUF5GTUNE_MASK)
-#define SYNTH_SYNTH7_SPARE_READ_MSB              2
-#define SYNTH_SYNTH7_SPARE_READ_LSB              0
-#define SYNTH_SYNTH7_SPARE_READ_MASK             0x00000007
-#define SYNTH_SYNTH7_SPARE_READ_GET(x)           (((x) & SYNTH_SYNTH7_SPARE_READ_MASK) >> SYNTH_SYNTH7_SPARE_READ_LSB)
-#define SYNTH_SYNTH7_SPARE_READ_SET(x)           (((x) << SYNTH_SYNTH7_SPARE_READ_LSB) & SYNTH_SYNTH7_SPARE_READ_MASK)
-
-#define SYNTH_SYNTH8_ADDRESS                     0x0000001c
-#define SYNTH_SYNTH8_OFFSET                      0x0000001c
-#define SYNTH_SYNTH8_LOADSYNTHCHANNEL_MSB        31
-#define SYNTH_SYNTH8_LOADSYNTHCHANNEL_LSB        31
-#define SYNTH_SYNTH8_LOADSYNTHCHANNEL_MASK       0x80000000
-#define SYNTH_SYNTH8_LOADSYNTHCHANNEL_GET(x)     (((x) & SYNTH_SYNTH8_LOADSYNTHCHANNEL_MASK) >> SYNTH_SYNTH8_LOADSYNTHCHANNEL_LSB)
-#define SYNTH_SYNTH8_LOADSYNTHCHANNEL_SET(x)     (((x) << SYNTH_SYNTH8_LOADSYNTHCHANNEL_LSB) & SYNTH_SYNTH8_LOADSYNTHCHANNEL_MASK)
-#define SYNTH_SYNTH8_FRACMODE_MSB                30
-#define SYNTH_SYNTH8_FRACMODE_LSB                30
-#define SYNTH_SYNTH8_FRACMODE_MASK               0x40000000
-#define SYNTH_SYNTH8_FRACMODE_GET(x)             (((x) & SYNTH_SYNTH8_FRACMODE_MASK) >> SYNTH_SYNTH8_FRACMODE_LSB)
-#define SYNTH_SYNTH8_FRACMODE_SET(x)             (((x) << SYNTH_SYNTH8_FRACMODE_LSB) & SYNTH_SYNTH8_FRACMODE_MASK)
-#define SYNTH_SYNTH8_AMODEREFSEL_MSB             29
-#define SYNTH_SYNTH8_AMODEREFSEL_LSB             28
-#define SYNTH_SYNTH8_AMODEREFSEL_MASK            0x30000000
-#define SYNTH_SYNTH8_AMODEREFSEL_GET(x)          (((x) & SYNTH_SYNTH8_AMODEREFSEL_MASK) >> SYNTH_SYNTH8_AMODEREFSEL_LSB)
-#define SYNTH_SYNTH8_AMODEREFSEL_SET(x)          (((x) << SYNTH_SYNTH8_AMODEREFSEL_LSB) & SYNTH_SYNTH8_AMODEREFSEL_MASK)
-#define SYNTH_SYNTH8_SPARE_MSB                   27
-#define SYNTH_SYNTH8_SPARE_LSB                   27
-#define SYNTH_SYNTH8_SPARE_MASK                  0x08000000
-#define SYNTH_SYNTH8_SPARE_GET(x)                (((x) & SYNTH_SYNTH8_SPARE_MASK) >> SYNTH_SYNTH8_SPARE_LSB)
-#define SYNTH_SYNTH8_SPARE_SET(x)                (((x) << SYNTH_SYNTH8_SPARE_LSB) & SYNTH_SYNTH8_SPARE_MASK)
-#define SYNTH_SYNTH8_CHANSEL_MSB                 26
-#define SYNTH_SYNTH8_CHANSEL_LSB                 18
-#define SYNTH_SYNTH8_CHANSEL_MASK                0x07fc0000
-#define SYNTH_SYNTH8_CHANSEL_GET(x)              (((x) & SYNTH_SYNTH8_CHANSEL_MASK) >> SYNTH_SYNTH8_CHANSEL_LSB)
-#define SYNTH_SYNTH8_CHANSEL_SET(x)              (((x) << SYNTH_SYNTH8_CHANSEL_LSB) & SYNTH_SYNTH8_CHANSEL_MASK)
-#define SYNTH_SYNTH8_CHANFRAC_MSB                17
-#define SYNTH_SYNTH8_CHANFRAC_LSB                1
-#define SYNTH_SYNTH8_CHANFRAC_MASK               0x0003fffe
-#define SYNTH_SYNTH8_CHANFRAC_GET(x)             (((x) & SYNTH_SYNTH8_CHANFRAC_MASK) >> SYNTH_SYNTH8_CHANFRAC_LSB)
-#define SYNTH_SYNTH8_CHANFRAC_SET(x)             (((x) << SYNTH_SYNTH8_CHANFRAC_LSB) & SYNTH_SYNTH8_CHANFRAC_MASK)
-#define SYNTH_SYNTH8_FORCE_FRACLSB_MSB           0
-#define SYNTH_SYNTH8_FORCE_FRACLSB_LSB           0
-#define SYNTH_SYNTH8_FORCE_FRACLSB_MASK          0x00000001
-#define SYNTH_SYNTH8_FORCE_FRACLSB_GET(x)        (((x) & SYNTH_SYNTH8_FORCE_FRACLSB_MASK) >> SYNTH_SYNTH8_FORCE_FRACLSB_LSB)
-#define SYNTH_SYNTH8_FORCE_FRACLSB_SET(x)        (((x) << SYNTH_SYNTH8_FORCE_FRACLSB_LSB) & SYNTH_SYNTH8_FORCE_FRACLSB_MASK)
-
-#define RF5G_RF5G1_ADDRESS                       0x00000020
-#define RF5G_RF5G1_OFFSET                        0x00000020
-#define RF5G_RF5G1_PDTXLO5_MSB                   31
-#define RF5G_RF5G1_PDTXLO5_LSB                   31
-#define RF5G_RF5G1_PDTXLO5_MASK                  0x80000000
-#define RF5G_RF5G1_PDTXLO5_GET(x)                (((x) & RF5G_RF5G1_PDTXLO5_MASK) >> RF5G_RF5G1_PDTXLO5_LSB)
-#define RF5G_RF5G1_PDTXLO5_SET(x)                (((x) << RF5G_RF5G1_PDTXLO5_LSB) & RF5G_RF5G1_PDTXLO5_MASK)
-#define RF5G_RF5G1_PDTXMIX5_MSB                  30
-#define RF5G_RF5G1_PDTXMIX5_LSB                  30
-#define RF5G_RF5G1_PDTXMIX5_MASK                 0x40000000
-#define RF5G_RF5G1_PDTXMIX5_GET(x)               (((x) & RF5G_RF5G1_PDTXMIX5_MASK) >> RF5G_RF5G1_PDTXMIX5_LSB)
-#define RF5G_RF5G1_PDTXMIX5_SET(x)               (((x) << RF5G_RF5G1_PDTXMIX5_LSB) & RF5G_RF5G1_PDTXMIX5_MASK)
-#define RF5G_RF5G1_PDTXBUF5_MSB                  29
-#define RF5G_RF5G1_PDTXBUF5_LSB                  29
-#define RF5G_RF5G1_PDTXBUF5_MASK                 0x20000000
-#define RF5G_RF5G1_PDTXBUF5_GET(x)               (((x) & RF5G_RF5G1_PDTXBUF5_MASK) >> RF5G_RF5G1_PDTXBUF5_LSB)
-#define RF5G_RF5G1_PDTXBUF5_SET(x)               (((x) << RF5G_RF5G1_PDTXBUF5_LSB) & RF5G_RF5G1_PDTXBUF5_MASK)
-#define RF5G_RF5G1_PDPADRV5_MSB                  28
-#define RF5G_RF5G1_PDPADRV5_LSB                  28
-#define RF5G_RF5G1_PDPADRV5_MASK                 0x10000000
-#define RF5G_RF5G1_PDPADRV5_GET(x)               (((x) & RF5G_RF5G1_PDPADRV5_MASK) >> RF5G_RF5G1_PDPADRV5_LSB)
-#define RF5G_RF5G1_PDPADRV5_SET(x)               (((x) << RF5G_RF5G1_PDPADRV5_LSB) & RF5G_RF5G1_PDPADRV5_MASK)
-#define RF5G_RF5G1_PDPAOUT5_MSB                  27
-#define RF5G_RF5G1_PDPAOUT5_LSB                  27
-#define RF5G_RF5G1_PDPAOUT5_MASK                 0x08000000
-#define RF5G_RF5G1_PDPAOUT5_GET(x)               (((x) & RF5G_RF5G1_PDPAOUT5_MASK) >> RF5G_RF5G1_PDPAOUT5_LSB)
-#define RF5G_RF5G1_PDPAOUT5_SET(x)               (((x) << RF5G_RF5G1_PDPAOUT5_LSB) & RF5G_RF5G1_PDPAOUT5_MASK)
-#define RF5G_RF5G1_TUNE_PADRV5_MSB               26
-#define RF5G_RF5G1_TUNE_PADRV5_LSB               24
-#define RF5G_RF5G1_TUNE_PADRV5_MASK              0x07000000
-#define RF5G_RF5G1_TUNE_PADRV5_GET(x)            (((x) & RF5G_RF5G1_TUNE_PADRV5_MASK) >> RF5G_RF5G1_TUNE_PADRV5_LSB)
-#define RF5G_RF5G1_TUNE_PADRV5_SET(x)            (((x) << RF5G_RF5G1_TUNE_PADRV5_LSB) & RF5G_RF5G1_TUNE_PADRV5_MASK)
-#define RF5G_RF5G1_PWDTXPKD_MSB                  23
-#define RF5G_RF5G1_PWDTXPKD_LSB                  21
-#define RF5G_RF5G1_PWDTXPKD_MASK                 0x00e00000
-#define RF5G_RF5G1_PWDTXPKD_GET(x)               (((x) & RF5G_RF5G1_PWDTXPKD_MASK) >> RF5G_RF5G1_PWDTXPKD_LSB)
-#define RF5G_RF5G1_PWDTXPKD_SET(x)               (((x) << RF5G_RF5G1_PWDTXPKD_LSB) & RF5G_RF5G1_PWDTXPKD_MASK)
-#define RF5G_RF5G1_DB5_MSB                       20
-#define RF5G_RF5G1_DB5_LSB                       18
-#define RF5G_RF5G1_DB5_MASK                      0x001c0000
-#define RF5G_RF5G1_DB5_GET(x)                    (((x) & RF5G_RF5G1_DB5_MASK) >> RF5G_RF5G1_DB5_LSB)
-#define RF5G_RF5G1_DB5_SET(x)                    (((x) << RF5G_RF5G1_DB5_LSB) & RF5G_RF5G1_DB5_MASK)
-#define RF5G_RF5G1_OB5_MSB                       17
-#define RF5G_RF5G1_OB5_LSB                       15
-#define RF5G_RF5G1_OB5_MASK                      0x00038000
-#define RF5G_RF5G1_OB5_GET(x)                    (((x) & RF5G_RF5G1_OB5_MASK) >> RF5G_RF5G1_OB5_LSB)
-#define RF5G_RF5G1_OB5_SET(x)                    (((x) << RF5G_RF5G1_OB5_LSB) & RF5G_RF5G1_OB5_MASK)
-#define RF5G_RF5G1_TX5_ATB_SEL_MSB               14
-#define RF5G_RF5G1_TX5_ATB_SEL_LSB               12
-#define RF5G_RF5G1_TX5_ATB_SEL_MASK              0x00007000
-#define RF5G_RF5G1_TX5_ATB_SEL_GET(x)            (((x) & RF5G_RF5G1_TX5_ATB_SEL_MASK) >> RF5G_RF5G1_TX5_ATB_SEL_LSB)
-#define RF5G_RF5G1_TX5_ATB_SEL_SET(x)            (((x) << RF5G_RF5G1_TX5_ATB_SEL_LSB) & RF5G_RF5G1_TX5_ATB_SEL_MASK)
-#define RF5G_RF5G1_PDLO5DIV_MSB                  11
-#define RF5G_RF5G1_PDLO5DIV_LSB                  11
-#define RF5G_RF5G1_PDLO5DIV_MASK                 0x00000800
-#define RF5G_RF5G1_PDLO5DIV_GET(x)               (((x) & RF5G_RF5G1_PDLO5DIV_MASK) >> RF5G_RF5G1_PDLO5DIV_LSB)
-#define RF5G_RF5G1_PDLO5DIV_SET(x)               (((x) << RF5G_RF5G1_PDLO5DIV_LSB) & RF5G_RF5G1_PDLO5DIV_MASK)
-#define RF5G_RF5G1_PDLO5MIX_MSB                  10
-#define RF5G_RF5G1_PDLO5MIX_LSB                  10
-#define RF5G_RF5G1_PDLO5MIX_MASK                 0x00000400
-#define RF5G_RF5G1_PDLO5MIX_GET(x)               (((x) & RF5G_RF5G1_PDLO5MIX_MASK) >> RF5G_RF5G1_PDLO5MIX_LSB)
-#define RF5G_RF5G1_PDLO5MIX_SET(x)               (((x) << RF5G_RF5G1_PDLO5MIX_LSB) & RF5G_RF5G1_PDLO5MIX_MASK)
-#define RF5G_RF5G1_PDQBUF5_MSB                   9
-#define RF5G_RF5G1_PDQBUF5_LSB                   9
-#define RF5G_RF5G1_PDQBUF5_MASK                  0x00000200
-#define RF5G_RF5G1_PDQBUF5_GET(x)                (((x) & RF5G_RF5G1_PDQBUF5_MASK) >> RF5G_RF5G1_PDQBUF5_LSB)
-#define RF5G_RF5G1_PDQBUF5_SET(x)                (((x) << RF5G_RF5G1_PDQBUF5_LSB) & RF5G_RF5G1_PDQBUF5_MASK)
-#define RF5G_RF5G1_PDLO5AGC_MSB                  8
-#define RF5G_RF5G1_PDLO5AGC_LSB                  8
-#define RF5G_RF5G1_PDLO5AGC_MASK                 0x00000100
-#define RF5G_RF5G1_PDLO5AGC_GET(x)               (((x) & RF5G_RF5G1_PDLO5AGC_MASK) >> RF5G_RF5G1_PDLO5AGC_LSB)
-#define RF5G_RF5G1_PDLO5AGC_SET(x)               (((x) << RF5G_RF5G1_PDLO5AGC_LSB) & RF5G_RF5G1_PDLO5AGC_MASK)
-#define RF5G_RF5G1_PDREGLO5_MSB                  7
-#define RF5G_RF5G1_PDREGLO5_LSB                  7
-#define RF5G_RF5G1_PDREGLO5_MASK                 0x00000080
-#define RF5G_RF5G1_PDREGLO5_GET(x)               (((x) & RF5G_RF5G1_PDREGLO5_MASK) >> RF5G_RF5G1_PDREGLO5_LSB)
-#define RF5G_RF5G1_PDREGLO5_SET(x)               (((x) << RF5G_RF5G1_PDREGLO5_LSB) & RF5G_RF5G1_PDREGLO5_MASK)
-#define RF5G_RF5G1_LO5_ATB_SEL_MSB               6
-#define RF5G_RF5G1_LO5_ATB_SEL_LSB               4
-#define RF5G_RF5G1_LO5_ATB_SEL_MASK              0x00000070
-#define RF5G_RF5G1_LO5_ATB_SEL_GET(x)            (((x) & RF5G_RF5G1_LO5_ATB_SEL_MASK) >> RF5G_RF5G1_LO5_ATB_SEL_LSB)
-#define RF5G_RF5G1_LO5_ATB_SEL_SET(x)            (((x) << RF5G_RF5G1_LO5_ATB_SEL_LSB) & RF5G_RF5G1_LO5_ATB_SEL_MASK)
-#define RF5G_RF5G1_LO5CONTROL_MSB                3
-#define RF5G_RF5G1_LO5CONTROL_LSB                3
-#define RF5G_RF5G1_LO5CONTROL_MASK               0x00000008
-#define RF5G_RF5G1_LO5CONTROL_GET(x)             (((x) & RF5G_RF5G1_LO5CONTROL_MASK) >> RF5G_RF5G1_LO5CONTROL_LSB)
-#define RF5G_RF5G1_LO5CONTROL_SET(x)             (((x) << RF5G_RF5G1_LO5CONTROL_LSB) & RF5G_RF5G1_LO5CONTROL_MASK)
-#define RF5G_RF5G1_REGLO_BYPASS5_MSB             2
-#define RF5G_RF5G1_REGLO_BYPASS5_LSB             2
-#define RF5G_RF5G1_REGLO_BYPASS5_MASK            0x00000004
-#define RF5G_RF5G1_REGLO_BYPASS5_GET(x)          (((x) & RF5G_RF5G1_REGLO_BYPASS5_MASK) >> RF5G_RF5G1_REGLO_BYPASS5_LSB)
-#define RF5G_RF5G1_REGLO_BYPASS5_SET(x)          (((x) << RF5G_RF5G1_REGLO_BYPASS5_LSB) & RF5G_RF5G1_REGLO_BYPASS5_MASK)
-#define RF5G_RF5G1_SPARE_MSB                     1
-#define RF5G_RF5G1_SPARE_LSB                     0
-#define RF5G_RF5G1_SPARE_MASK                    0x00000003
-#define RF5G_RF5G1_SPARE_GET(x)                  (((x) & RF5G_RF5G1_SPARE_MASK) >> RF5G_RF5G1_SPARE_LSB)
-#define RF5G_RF5G1_SPARE_SET(x)                  (((x) << RF5G_RF5G1_SPARE_LSB) & RF5G_RF5G1_SPARE_MASK)
-
-#define RF5G_RF5G2_ADDRESS                       0x00000024
-#define RF5G_RF5G2_OFFSET                        0x00000024
-#define RF5G_RF5G2_AGCLO_B_MSB                   31
-#define RF5G_RF5G2_AGCLO_B_LSB                   29
-#define RF5G_RF5G2_AGCLO_B_MASK                  0xe0000000
-#define RF5G_RF5G2_AGCLO_B_GET(x)                (((x) & RF5G_RF5G2_AGCLO_B_MASK) >> RF5G_RF5G2_AGCLO_B_LSB)
-#define RF5G_RF5G2_AGCLO_B_SET(x)                (((x) << RF5G_RF5G2_AGCLO_B_LSB) & RF5G_RF5G2_AGCLO_B_MASK)
-#define RF5G_RF5G2_RX5_ATB_SEL_MSB               28
-#define RF5G_RF5G2_RX5_ATB_SEL_LSB               26
-#define RF5G_RF5G2_RX5_ATB_SEL_MASK              0x1c000000
-#define RF5G_RF5G2_RX5_ATB_SEL_GET(x)            (((x) & RF5G_RF5G2_RX5_ATB_SEL_MASK) >> RF5G_RF5G2_RX5_ATB_SEL_LSB)
-#define RF5G_RF5G2_RX5_ATB_SEL_SET(x)            (((x) << RF5G_RF5G2_RX5_ATB_SEL_LSB) & RF5G_RF5G2_RX5_ATB_SEL_MASK)
-#define RF5G_RF5G2_PDCMOSLO5_MSB                 25
-#define RF5G_RF5G2_PDCMOSLO5_LSB                 25
-#define RF5G_RF5G2_PDCMOSLO5_MASK                0x02000000
-#define RF5G_RF5G2_PDCMOSLO5_GET(x)              (((x) & RF5G_RF5G2_PDCMOSLO5_MASK) >> RF5G_RF5G2_PDCMOSLO5_LSB)
-#define RF5G_RF5G2_PDCMOSLO5_SET(x)              (((x) << RF5G_RF5G2_PDCMOSLO5_LSB) & RF5G_RF5G2_PDCMOSLO5_MASK)
-#define RF5G_RF5G2_PDVGM5_MSB                    24
-#define RF5G_RF5G2_PDVGM5_LSB                    24
-#define RF5G_RF5G2_PDVGM5_MASK                   0x01000000
-#define RF5G_RF5G2_PDVGM5_GET(x)                 (((x) & RF5G_RF5G2_PDVGM5_MASK) >> RF5G_RF5G2_PDVGM5_LSB)
-#define RF5G_RF5G2_PDVGM5_SET(x)                 (((x) << RF5G_RF5G2_PDVGM5_LSB) & RF5G_RF5G2_PDVGM5_MASK)
-#define RF5G_RF5G2_PDCSLNA5_MSB                  23
-#define RF5G_RF5G2_PDCSLNA5_LSB                  23
-#define RF5G_RF5G2_PDCSLNA5_MASK                 0x00800000
-#define RF5G_RF5G2_PDCSLNA5_GET(x)               (((x) & RF5G_RF5G2_PDCSLNA5_MASK) >> RF5G_RF5G2_PDCSLNA5_LSB)
-#define RF5G_RF5G2_PDCSLNA5_SET(x)               (((x) << RF5G_RF5G2_PDCSLNA5_LSB) & RF5G_RF5G2_PDCSLNA5_MASK)
-#define RF5G_RF5G2_PDRFVGA5_MSB                  22
-#define RF5G_RF5G2_PDRFVGA5_LSB                  22
-#define RF5G_RF5G2_PDRFVGA5_MASK                 0x00400000
-#define RF5G_RF5G2_PDRFVGA5_GET(x)               (((x) & RF5G_RF5G2_PDRFVGA5_MASK) >> RF5G_RF5G2_PDRFVGA5_LSB)
-#define RF5G_RF5G2_PDRFVGA5_SET(x)               (((x) << RF5G_RF5G2_PDRFVGA5_LSB) & RF5G_RF5G2_PDRFVGA5_MASK)
-#define RF5G_RF5G2_PDREGFE5_MSB                  21
-#define RF5G_RF5G2_PDREGFE5_LSB                  21
-#define RF5G_RF5G2_PDREGFE5_MASK                 0x00200000
-#define RF5G_RF5G2_PDREGFE5_GET(x)               (((x) & RF5G_RF5G2_PDREGFE5_MASK) >> RF5G_RF5G2_PDREGFE5_LSB)
-#define RF5G_RF5G2_PDREGFE5_SET(x)               (((x) << RF5G_RF5G2_PDREGFE5_LSB) & RF5G_RF5G2_PDREGFE5_MASK)
-#define RF5G_RF5G2_TUNE_RFVGA5_MSB               20
-#define RF5G_RF5G2_TUNE_RFVGA5_LSB               18
-#define RF5G_RF5G2_TUNE_RFVGA5_MASK              0x001c0000
-#define RF5G_RF5G2_TUNE_RFVGA5_GET(x)            (((x) & RF5G_RF5G2_TUNE_RFVGA5_MASK) >> RF5G_RF5G2_TUNE_RFVGA5_LSB)
-#define RF5G_RF5G2_TUNE_RFVGA5_SET(x)            (((x) << RF5G_RF5G2_TUNE_RFVGA5_LSB) & RF5G_RF5G2_TUNE_RFVGA5_MASK)
-#define RF5G_RF5G2_BRFVGA5_MSB                   17
-#define RF5G_RF5G2_BRFVGA5_LSB                   15
-#define RF5G_RF5G2_BRFVGA5_MASK                  0x00038000
-#define RF5G_RF5G2_BRFVGA5_GET(x)                (((x) & RF5G_RF5G2_BRFVGA5_MASK) >> RF5G_RF5G2_BRFVGA5_LSB)
-#define RF5G_RF5G2_BRFVGA5_SET(x)                (((x) << RF5G_RF5G2_BRFVGA5_LSB) & RF5G_RF5G2_BRFVGA5_MASK)
-#define RF5G_RF5G2_BCSLNA5_MSB                   14
-#define RF5G_RF5G2_BCSLNA5_LSB                   12
-#define RF5G_RF5G2_BCSLNA5_MASK                  0x00007000
-#define RF5G_RF5G2_BCSLNA5_GET(x)                (((x) & RF5G_RF5G2_BCSLNA5_MASK) >> RF5G_RF5G2_BCSLNA5_LSB)
-#define RF5G_RF5G2_BCSLNA5_SET(x)                (((x) << RF5G_RF5G2_BCSLNA5_LSB) & RF5G_RF5G2_BCSLNA5_MASK)
-#define RF5G_RF5G2_BVGM5_MSB                     11
-#define RF5G_RF5G2_BVGM5_LSB                     9
-#define RF5G_RF5G2_BVGM5_MASK                    0x00000e00
-#define RF5G_RF5G2_BVGM5_GET(x)                  (((x) & RF5G_RF5G2_BVGM5_MASK) >> RF5G_RF5G2_BVGM5_LSB)
-#define RF5G_RF5G2_BVGM5_SET(x)                  (((x) << RF5G_RF5G2_BVGM5_LSB) & RF5G_RF5G2_BVGM5_MASK)
-#define RF5G_RF5G2_REGFE_BYPASS5_MSB             8
-#define RF5G_RF5G2_REGFE_BYPASS5_LSB             8
-#define RF5G_RF5G2_REGFE_BYPASS5_MASK            0x00000100
-#define RF5G_RF5G2_REGFE_BYPASS5_GET(x)          (((x) & RF5G_RF5G2_REGFE_BYPASS5_MASK) >> RF5G_RF5G2_REGFE_BYPASS5_LSB)
-#define RF5G_RF5G2_REGFE_BYPASS5_SET(x)          (((x) << RF5G_RF5G2_REGFE_BYPASS5_LSB) & RF5G_RF5G2_REGFE_BYPASS5_MASK)
-#define RF5G_RF5G2_LNA5_ATTENMODE_MSB            7
-#define RF5G_RF5G2_LNA5_ATTENMODE_LSB            6
-#define RF5G_RF5G2_LNA5_ATTENMODE_MASK           0x000000c0
-#define RF5G_RF5G2_LNA5_ATTENMODE_GET(x)         (((x) & RF5G_RF5G2_LNA5_ATTENMODE_MASK) >> RF5G_RF5G2_LNA5_ATTENMODE_LSB)
-#define RF5G_RF5G2_LNA5_ATTENMODE_SET(x)         (((x) << RF5G_RF5G2_LNA5_ATTENMODE_LSB) & RF5G_RF5G2_LNA5_ATTENMODE_MASK)
-#define RF5G_RF5G2_ENABLE_PCA_MSB                5
-#define RF5G_RF5G2_ENABLE_PCA_LSB                5
-#define RF5G_RF5G2_ENABLE_PCA_MASK               0x00000020
-#define RF5G_RF5G2_ENABLE_PCA_GET(x)             (((x) & RF5G_RF5G2_ENABLE_PCA_MASK) >> RF5G_RF5G2_ENABLE_PCA_LSB)
-#define RF5G_RF5G2_ENABLE_PCA_SET(x)             (((x) << RF5G_RF5G2_ENABLE_PCA_LSB) & RF5G_RF5G2_ENABLE_PCA_MASK)
-#define RF5G_RF5G2_TUNE_LO_MSB                   4
-#define RF5G_RF5G2_TUNE_LO_LSB                   2
-#define RF5G_RF5G2_TUNE_LO_MASK                  0x0000001c
-#define RF5G_RF5G2_TUNE_LO_GET(x)                (((x) & RF5G_RF5G2_TUNE_LO_MASK) >> RF5G_RF5G2_TUNE_LO_LSB)
-#define RF5G_RF5G2_TUNE_LO_SET(x)                (((x) << RF5G_RF5G2_TUNE_LO_LSB) & RF5G_RF5G2_TUNE_LO_MASK)
-#define RF5G_RF5G2_SPARE_MSB                     1
-#define RF5G_RF5G2_SPARE_LSB                     0
-#define RF5G_RF5G2_SPARE_MASK                    0x00000003
-#define RF5G_RF5G2_SPARE_GET(x)                  (((x) & RF5G_RF5G2_SPARE_MASK) >> RF5G_RF5G2_SPARE_LSB)
-#define RF5G_RF5G2_SPARE_SET(x)                  (((x) << RF5G_RF5G2_SPARE_LSB) & RF5G_RF5G2_SPARE_MASK)
-
-#define RF2G_RF2G1_ADDRESS                       0x00000028
-#define RF2G_RF2G1_OFFSET                        0x00000028
-#define RF2G_RF2G1_BLNA1_MSB                     31
-#define RF2G_RF2G1_BLNA1_LSB                     29
-#define RF2G_RF2G1_BLNA1_MASK                    0xe0000000
-#define RF2G_RF2G1_BLNA1_GET(x)                  (((x) & RF2G_RF2G1_BLNA1_MASK) >> RF2G_RF2G1_BLNA1_LSB)
-#define RF2G_RF2G1_BLNA1_SET(x)                  (((x) << RF2G_RF2G1_BLNA1_LSB) & RF2G_RF2G1_BLNA1_MASK)
-#define RF2G_RF2G1_BLNA1F_MSB                    28
-#define RF2G_RF2G1_BLNA1F_LSB                    26
-#define RF2G_RF2G1_BLNA1F_MASK                   0x1c000000
-#define RF2G_RF2G1_BLNA1F_GET(x)                 (((x) & RF2G_RF2G1_BLNA1F_MASK) >> RF2G_RF2G1_BLNA1F_LSB)
-#define RF2G_RF2G1_BLNA1F_SET(x)                 (((x) << RF2G_RF2G1_BLNA1F_LSB) & RF2G_RF2G1_BLNA1F_MASK)
-#define RF2G_RF2G1_BLNA1BUF_MSB                  25
-#define RF2G_RF2G1_BLNA1BUF_LSB                  23
-#define RF2G_RF2G1_BLNA1BUF_MASK                 0x03800000
-#define RF2G_RF2G1_BLNA1BUF_GET(x)               (((x) & RF2G_RF2G1_BLNA1BUF_MASK) >> RF2G_RF2G1_BLNA1BUF_LSB)
-#define RF2G_RF2G1_BLNA1BUF_SET(x)               (((x) << RF2G_RF2G1_BLNA1BUF_LSB) & RF2G_RF2G1_BLNA1BUF_MASK)
-#define RF2G_RF2G1_BLNA2_MSB                     22
-#define RF2G_RF2G1_BLNA2_LSB                     20
-#define RF2G_RF2G1_BLNA2_MASK                    0x00700000
-#define RF2G_RF2G1_BLNA2_GET(x)                  (((x) & RF2G_RF2G1_BLNA2_MASK) >> RF2G_RF2G1_BLNA2_LSB)
-#define RF2G_RF2G1_BLNA2_SET(x)                  (((x) << RF2G_RF2G1_BLNA2_LSB) & RF2G_RF2G1_BLNA2_MASK)
-#define RF2G_RF2G1_DB_MSB                        19
-#define RF2G_RF2G1_DB_LSB                        17
-#define RF2G_RF2G1_DB_MASK                       0x000e0000
-#define RF2G_RF2G1_DB_GET(x)                     (((x) & RF2G_RF2G1_DB_MASK) >> RF2G_RF2G1_DB_LSB)
-#define RF2G_RF2G1_DB_SET(x)                     (((x) << RF2G_RF2G1_DB_LSB) & RF2G_RF2G1_DB_MASK)
-#define RF2G_RF2G1_OB_MSB                        16
-#define RF2G_RF2G1_OB_LSB                        14
-#define RF2G_RF2G1_OB_MASK                       0x0001c000
-#define RF2G_RF2G1_OB_GET(x)                     (((x) & RF2G_RF2G1_OB_MASK) >> RF2G_RF2G1_OB_LSB)
-#define RF2G_RF2G1_OB_SET(x)                     (((x) << RF2G_RF2G1_OB_LSB) & RF2G_RF2G1_OB_MASK)
-#define RF2G_RF2G1_FE_ATB_SEL_MSB                13
-#define RF2G_RF2G1_FE_ATB_SEL_LSB                11
-#define RF2G_RF2G1_FE_ATB_SEL_MASK               0x00003800
-#define RF2G_RF2G1_FE_ATB_SEL_GET(x)             (((x) & RF2G_RF2G1_FE_ATB_SEL_MASK) >> RF2G_RF2G1_FE_ATB_SEL_LSB)
-#define RF2G_RF2G1_FE_ATB_SEL_SET(x)             (((x) << RF2G_RF2G1_FE_ATB_SEL_LSB) & RF2G_RF2G1_FE_ATB_SEL_MASK)
-#define RF2G_RF2G1_RF_ATB_SEL_MSB                10
-#define RF2G_RF2G1_RF_ATB_SEL_LSB                8
-#define RF2G_RF2G1_RF_ATB_SEL_MASK               0x00000700
-#define RF2G_RF2G1_RF_ATB_SEL_GET(x)             (((x) & RF2G_RF2G1_RF_ATB_SEL_MASK) >> RF2G_RF2G1_RF_ATB_SEL_LSB)
-#define RF2G_RF2G1_RF_ATB_SEL_SET(x)             (((x) << RF2G_RF2G1_RF_ATB_SEL_LSB) & RF2G_RF2G1_RF_ATB_SEL_MASK)
-#define RF2G_RF2G1_SELLNA_MSB                    7
-#define RF2G_RF2G1_SELLNA_LSB                    7
-#define RF2G_RF2G1_SELLNA_MASK                   0x00000080
-#define RF2G_RF2G1_SELLNA_GET(x)                 (((x) & RF2G_RF2G1_SELLNA_MASK) >> RF2G_RF2G1_SELLNA_LSB)
-#define RF2G_RF2G1_SELLNA_SET(x)                 (((x) << RF2G_RF2G1_SELLNA_LSB) & RF2G_RF2G1_SELLNA_MASK)
-#define RF2G_RF2G1_LOCONTROL_MSB                 6
-#define RF2G_RF2G1_LOCONTROL_LSB                 6
-#define RF2G_RF2G1_LOCONTROL_MASK                0x00000040
-#define RF2G_RF2G1_LOCONTROL_GET(x)              (((x) & RF2G_RF2G1_LOCONTROL_MASK) >> RF2G_RF2G1_LOCONTROL_LSB)
-#define RF2G_RF2G1_LOCONTROL_SET(x)              (((x) << RF2G_RF2G1_LOCONTROL_LSB) & RF2G_RF2G1_LOCONTROL_MASK)
-#define RF2G_RF2G1_SHORTLNA2_MSB                 5
-#define RF2G_RF2G1_SHORTLNA2_LSB                 5
-#define RF2G_RF2G1_SHORTLNA2_MASK                0x00000020
-#define RF2G_RF2G1_SHORTLNA2_GET(x)              (((x) & RF2G_RF2G1_SHORTLNA2_MASK) >> RF2G_RF2G1_SHORTLNA2_LSB)
-#define RF2G_RF2G1_SHORTLNA2_SET(x)              (((x) << RF2G_RF2G1_SHORTLNA2_LSB) & RF2G_RF2G1_SHORTLNA2_MASK)
-#define RF2G_RF2G1_SPARE_MSB                     4
-#define RF2G_RF2G1_SPARE_LSB                     0
-#define RF2G_RF2G1_SPARE_MASK                    0x0000001f
-#define RF2G_RF2G1_SPARE_GET(x)                  (((x) & RF2G_RF2G1_SPARE_MASK) >> RF2G_RF2G1_SPARE_LSB)
-#define RF2G_RF2G1_SPARE_SET(x)                  (((x) << RF2G_RF2G1_SPARE_LSB) & RF2G_RF2G1_SPARE_MASK)
-
-#define RF2G_RF2G2_ADDRESS                       0x0000002c
-#define RF2G_RF2G2_OFFSET                        0x0000002c
-#define RF2G_RF2G2_PDCGLNA_MSB                   31
-#define RF2G_RF2G2_PDCGLNA_LSB                   31
-#define RF2G_RF2G2_PDCGLNA_MASK                  0x80000000
-#define RF2G_RF2G2_PDCGLNA_GET(x)                (((x) & RF2G_RF2G2_PDCGLNA_MASK) >> RF2G_RF2G2_PDCGLNA_LSB)
-#define RF2G_RF2G2_PDCGLNA_SET(x)                (((x) << RF2G_RF2G2_PDCGLNA_LSB) & RF2G_RF2G2_PDCGLNA_MASK)
-#define RF2G_RF2G2_PDCGLNABUF_MSB                30
-#define RF2G_RF2G2_PDCGLNABUF_LSB                30
-#define RF2G_RF2G2_PDCGLNABUF_MASK               0x40000000
-#define RF2G_RF2G2_PDCGLNABUF_GET(x)             (((x) & RF2G_RF2G2_PDCGLNABUF_MASK) >> RF2G_RF2G2_PDCGLNABUF_LSB)
-#define RF2G_RF2G2_PDCGLNABUF_SET(x)             (((x) << RF2G_RF2G2_PDCGLNABUF_LSB) & RF2G_RF2G2_PDCGLNABUF_MASK)
-#define RF2G_RF2G2_PDCSLNA_MSB                   29
-#define RF2G_RF2G2_PDCSLNA_LSB                   29
-#define RF2G_RF2G2_PDCSLNA_MASK                  0x20000000
-#define RF2G_RF2G2_PDCSLNA_GET(x)                (((x) & RF2G_RF2G2_PDCSLNA_MASK) >> RF2G_RF2G2_PDCSLNA_LSB)
-#define RF2G_RF2G2_PDCSLNA_SET(x)                (((x) << RF2G_RF2G2_PDCSLNA_LSB) & RF2G_RF2G2_PDCSLNA_MASK)
-#define RF2G_RF2G2_PDDIV_MSB                     28
-#define RF2G_RF2G2_PDDIV_LSB                     28
-#define RF2G_RF2G2_PDDIV_MASK                    0x10000000
-#define RF2G_RF2G2_PDDIV_GET(x)                  (((x) & RF2G_RF2G2_PDDIV_MASK) >> RF2G_RF2G2_PDDIV_LSB)
-#define RF2G_RF2G2_PDDIV_SET(x)                  (((x) << RF2G_RF2G2_PDDIV_LSB) & RF2G_RF2G2_PDDIV_MASK)
-#define RF2G_RF2G2_PDPADRV_MSB                   27
-#define RF2G_RF2G2_PDPADRV_LSB                   27
-#define RF2G_RF2G2_PDPADRV_MASK                  0x08000000
-#define RF2G_RF2G2_PDPADRV_GET(x)                (((x) & RF2G_RF2G2_PDPADRV_MASK) >> RF2G_RF2G2_PDPADRV_LSB)
-#define RF2G_RF2G2_PDPADRV_SET(x)                (((x) << RF2G_RF2G2_PDPADRV_LSB) & RF2G_RF2G2_PDPADRV_MASK)
-#define RF2G_RF2G2_PDPAOUT_MSB                   26
-#define RF2G_RF2G2_PDPAOUT_LSB                   26
-#define RF2G_RF2G2_PDPAOUT_MASK                  0x04000000
-#define RF2G_RF2G2_PDPAOUT_GET(x)                (((x) & RF2G_RF2G2_PDPAOUT_MASK) >> RF2G_RF2G2_PDPAOUT_LSB)
-#define RF2G_RF2G2_PDPAOUT_SET(x)                (((x) << RF2G_RF2G2_PDPAOUT_LSB) & RF2G_RF2G2_PDPAOUT_MASK)
-#define RF2G_RF2G2_PDREGLNA_MSB                  25
-#define RF2G_RF2G2_PDREGLNA_LSB                  25
-#define RF2G_RF2G2_PDREGLNA_MASK                 0x02000000
-#define RF2G_RF2G2_PDREGLNA_GET(x)               (((x) & RF2G_RF2G2_PDREGLNA_MASK) >> RF2G_RF2G2_PDREGLNA_LSB)
-#define RF2G_RF2G2_PDREGLNA_SET(x)               (((x) << RF2G_RF2G2_PDREGLNA_LSB) & RF2G_RF2G2_PDREGLNA_MASK)
-#define RF2G_RF2G2_PDREGLO_MSB                   24
-#define RF2G_RF2G2_PDREGLO_LSB                   24
-#define RF2G_RF2G2_PDREGLO_MASK                  0x01000000
-#define RF2G_RF2G2_PDREGLO_GET(x)                (((x) & RF2G_RF2G2_PDREGLO_MASK) >> RF2G_RF2G2_PDREGLO_LSB)
-#define RF2G_RF2G2_PDREGLO_SET(x)                (((x) << RF2G_RF2G2_PDREGLO_LSB) & RF2G_RF2G2_PDREGLO_MASK)
-#define RF2G_RF2G2_PDRFGM_MSB                    23
-#define RF2G_RF2G2_PDRFGM_LSB                    23
-#define RF2G_RF2G2_PDRFGM_MASK                   0x00800000
-#define RF2G_RF2G2_PDRFGM_GET(x)                 (((x) & RF2G_RF2G2_PDRFGM_MASK) >> RF2G_RF2G2_PDRFGM_LSB)
-#define RF2G_RF2G2_PDRFGM_SET(x)                 (((x) << RF2G_RF2G2_PDRFGM_LSB) & RF2G_RF2G2_PDRFGM_MASK)
-#define RF2G_RF2G2_PDRXLO_MSB                    22
-#define RF2G_RF2G2_PDRXLO_LSB                    22
-#define RF2G_RF2G2_PDRXLO_MASK                   0x00400000
-#define RF2G_RF2G2_PDRXLO_GET(x)                 (((x) & RF2G_RF2G2_PDRXLO_MASK) >> RF2G_RF2G2_PDRXLO_LSB)
-#define RF2G_RF2G2_PDRXLO_SET(x)                 (((x) << RF2G_RF2G2_PDRXLO_LSB) & RF2G_RF2G2_PDRXLO_MASK)
-#define RF2G_RF2G2_PDTXLO_MSB                    21
-#define RF2G_RF2G2_PDTXLO_LSB                    21
-#define RF2G_RF2G2_PDTXLO_MASK                   0x00200000
-#define RF2G_RF2G2_PDTXLO_GET(x)                 (((x) & RF2G_RF2G2_PDTXLO_MASK) >> RF2G_RF2G2_PDTXLO_LSB)
-#define RF2G_RF2G2_PDTXLO_SET(x)                 (((x) << RF2G_RF2G2_PDTXLO_LSB) & RF2G_RF2G2_PDTXLO_MASK)
-#define RF2G_RF2G2_PDTXMIX_MSB                   20
-#define RF2G_RF2G2_PDTXMIX_LSB                   20
-#define RF2G_RF2G2_PDTXMIX_MASK                  0x00100000
-#define RF2G_RF2G2_PDTXMIX_GET(x)                (((x) & RF2G_RF2G2_PDTXMIX_MASK) >> RF2G_RF2G2_PDTXMIX_LSB)
-#define RF2G_RF2G2_PDTXMIX_SET(x)                (((x) << RF2G_RF2G2_PDTXMIX_LSB) & RF2G_RF2G2_PDTXMIX_MASK)
-#define RF2G_RF2G2_REGLNA_BYPASS_MSB             19
-#define RF2G_RF2G2_REGLNA_BYPASS_LSB             19
-#define RF2G_RF2G2_REGLNA_BYPASS_MASK            0x00080000
-#define RF2G_RF2G2_REGLNA_BYPASS_GET(x)          (((x) & RF2G_RF2G2_REGLNA_BYPASS_MASK) >> RF2G_RF2G2_REGLNA_BYPASS_LSB)
-#define RF2G_RF2G2_REGLNA_BYPASS_SET(x)          (((x) << RF2G_RF2G2_REGLNA_BYPASS_LSB) & RF2G_RF2G2_REGLNA_BYPASS_MASK)
-#define RF2G_RF2G2_REGLO_BYPASS_MSB              18
-#define RF2G_RF2G2_REGLO_BYPASS_LSB              18
-#define RF2G_RF2G2_REGLO_BYPASS_MASK             0x00040000
-#define RF2G_RF2G2_REGLO_BYPASS_GET(x)           (((x) & RF2G_RF2G2_REGLO_BYPASS_MASK) >> RF2G_RF2G2_REGLO_BYPASS_LSB)
-#define RF2G_RF2G2_REGLO_BYPASS_SET(x)           (((x) << RF2G_RF2G2_REGLO_BYPASS_LSB) & RF2G_RF2G2_REGLO_BYPASS_MASK)
-#define RF2G_RF2G2_ENABLE_PCB_MSB                17
-#define RF2G_RF2G2_ENABLE_PCB_LSB                17
-#define RF2G_RF2G2_ENABLE_PCB_MASK               0x00020000
-#define RF2G_RF2G2_ENABLE_PCB_GET(x)             (((x) & RF2G_RF2G2_ENABLE_PCB_MASK) >> RF2G_RF2G2_ENABLE_PCB_LSB)
-#define RF2G_RF2G2_ENABLE_PCB_SET(x)             (((x) << RF2G_RF2G2_ENABLE_PCB_LSB) & RF2G_RF2G2_ENABLE_PCB_MASK)
-#define RF2G_RF2G2_SPARE_MSB                     16
-#define RF2G_RF2G2_SPARE_LSB                     0
-#define RF2G_RF2G2_SPARE_MASK                    0x0001ffff
-#define RF2G_RF2G2_SPARE_GET(x)                  (((x) & RF2G_RF2G2_SPARE_MASK) >> RF2G_RF2G2_SPARE_LSB)
-#define RF2G_RF2G2_SPARE_SET(x)                  (((x) << RF2G_RF2G2_SPARE_LSB) & RF2G_RF2G2_SPARE_MASK)
-
-#define TOP_GAIN_ADDRESS                         0x00000030
-#define TOP_GAIN_OFFSET                          0x00000030
-#define TOP_GAIN_TX6DBLOQGAIN_MSB                31
-#define TOP_GAIN_TX6DBLOQGAIN_LSB                30
-#define TOP_GAIN_TX6DBLOQGAIN_MASK               0xc0000000
-#define TOP_GAIN_TX6DBLOQGAIN_GET(x)             (((x) & TOP_GAIN_TX6DBLOQGAIN_MASK) >> TOP_GAIN_TX6DBLOQGAIN_LSB)
-#define TOP_GAIN_TX6DBLOQGAIN_SET(x)             (((x) << TOP_GAIN_TX6DBLOQGAIN_LSB) & TOP_GAIN_TX6DBLOQGAIN_MASK)
-#define TOP_GAIN_TX1DBLOQGAIN_MSB                29
-#define TOP_GAIN_TX1DBLOQGAIN_LSB                27
-#define TOP_GAIN_TX1DBLOQGAIN_MASK               0x38000000
-#define TOP_GAIN_TX1DBLOQGAIN_GET(x)             (((x) & TOP_GAIN_TX1DBLOQGAIN_MASK) >> TOP_GAIN_TX1DBLOQGAIN_LSB)
-#define TOP_GAIN_TX1DBLOQGAIN_SET(x)             (((x) << TOP_GAIN_TX1DBLOQGAIN_LSB) & TOP_GAIN_TX1DBLOQGAIN_MASK)
-#define TOP_GAIN_TXV2IGAIN_MSB                   26
-#define TOP_GAIN_TXV2IGAIN_LSB                   25
-#define TOP_GAIN_TXV2IGAIN_MASK                  0x06000000
-#define TOP_GAIN_TXV2IGAIN_GET(x)                (((x) & TOP_GAIN_TXV2IGAIN_MASK) >> TOP_GAIN_TXV2IGAIN_LSB)
-#define TOP_GAIN_TXV2IGAIN_SET(x)                (((x) << TOP_GAIN_TXV2IGAIN_LSB) & TOP_GAIN_TXV2IGAIN_MASK)
-#define TOP_GAIN_PABUF5GN_MSB                    24
-#define TOP_GAIN_PABUF5GN_LSB                    24
-#define TOP_GAIN_PABUF5GN_MASK                   0x01000000
-#define TOP_GAIN_PABUF5GN_GET(x)                 (((x) & TOP_GAIN_PABUF5GN_MASK) >> TOP_GAIN_PABUF5GN_LSB)
-#define TOP_GAIN_PABUF5GN_SET(x)                 (((x) << TOP_GAIN_PABUF5GN_LSB) & TOP_GAIN_PABUF5GN_MASK)
-#define TOP_GAIN_PADRVGN_MSB                     23
-#define TOP_GAIN_PADRVGN_LSB                     21
-#define TOP_GAIN_PADRVGN_MASK                    0x00e00000
-#define TOP_GAIN_PADRVGN_GET(x)                  (((x) & TOP_GAIN_PADRVGN_MASK) >> TOP_GAIN_PADRVGN_LSB)
-#define TOP_GAIN_PADRVGN_SET(x)                  (((x) << TOP_GAIN_PADRVGN_LSB) & TOP_GAIN_PADRVGN_MASK)
-#define TOP_GAIN_PAOUT2GN_MSB                    20
-#define TOP_GAIN_PAOUT2GN_LSB                    18
-#define TOP_GAIN_PAOUT2GN_MASK                   0x001c0000
-#define TOP_GAIN_PAOUT2GN_GET(x)                 (((x) & TOP_GAIN_PAOUT2GN_MASK) >> TOP_GAIN_PAOUT2GN_LSB)
-#define TOP_GAIN_PAOUT2GN_SET(x)                 (((x) << TOP_GAIN_PAOUT2GN_LSB) & TOP_GAIN_PAOUT2GN_MASK)
-#define TOP_GAIN_LNAON_MSB                       17
-#define TOP_GAIN_LNAON_LSB                       17
-#define TOP_GAIN_LNAON_MASK                      0x00020000
-#define TOP_GAIN_LNAON_GET(x)                    (((x) & TOP_GAIN_LNAON_MASK) >> TOP_GAIN_LNAON_LSB)
-#define TOP_GAIN_LNAON_SET(x)                    (((x) << TOP_GAIN_LNAON_LSB) & TOP_GAIN_LNAON_MASK)
-#define TOP_GAIN_LNAGAIN_MSB                     16
-#define TOP_GAIN_LNAGAIN_LSB                     13
-#define TOP_GAIN_LNAGAIN_MASK                    0x0001e000
-#define TOP_GAIN_LNAGAIN_GET(x)                  (((x) & TOP_GAIN_LNAGAIN_MASK) >> TOP_GAIN_LNAGAIN_LSB)
-#define TOP_GAIN_LNAGAIN_SET(x)                  (((x) << TOP_GAIN_LNAGAIN_LSB) & TOP_GAIN_LNAGAIN_MASK)
-#define TOP_GAIN_RFVGA5GAIN_MSB                  12
-#define TOP_GAIN_RFVGA5GAIN_LSB                  11
-#define TOP_GAIN_RFVGA5GAIN_MASK                 0x00001800
-#define TOP_GAIN_RFVGA5GAIN_GET(x)               (((x) & TOP_GAIN_RFVGA5GAIN_MASK) >> TOP_GAIN_RFVGA5GAIN_LSB)
-#define TOP_GAIN_RFVGA5GAIN_SET(x)               (((x) << TOP_GAIN_RFVGA5GAIN_LSB) & TOP_GAIN_RFVGA5GAIN_MASK)
-#define TOP_GAIN_RFGMGN_MSB                      10
-#define TOP_GAIN_RFGMGN_LSB                      8
-#define TOP_GAIN_RFGMGN_MASK                     0x00000700
-#define TOP_GAIN_RFGMGN_GET(x)                   (((x) & TOP_GAIN_RFGMGN_MASK) >> TOP_GAIN_RFGMGN_LSB)
-#define TOP_GAIN_RFGMGN_SET(x)                   (((x) << TOP_GAIN_RFGMGN_LSB) & TOP_GAIN_RFGMGN_MASK)
-#define TOP_GAIN_RX6DBLOQGAIN_MSB                7
-#define TOP_GAIN_RX6DBLOQGAIN_LSB                6
-#define TOP_GAIN_RX6DBLOQGAIN_MASK               0x000000c0
-#define TOP_GAIN_RX6DBLOQGAIN_GET(x)             (((x) & TOP_GAIN_RX6DBLOQGAIN_MASK) >> TOP_GAIN_RX6DBLOQGAIN_LSB)
-#define TOP_GAIN_RX6DBLOQGAIN_SET(x)             (((x) << TOP_GAIN_RX6DBLOQGAIN_LSB) & TOP_GAIN_RX6DBLOQGAIN_MASK)
-#define TOP_GAIN_RX1DBLOQGAIN_MSB                5
-#define TOP_GAIN_RX1DBLOQGAIN_LSB                3
-#define TOP_GAIN_RX1DBLOQGAIN_MASK               0x00000038
-#define TOP_GAIN_RX1DBLOQGAIN_GET(x)             (((x) & TOP_GAIN_RX1DBLOQGAIN_MASK) >> TOP_GAIN_RX1DBLOQGAIN_LSB)
-#define TOP_GAIN_RX1DBLOQGAIN_SET(x)             (((x) << TOP_GAIN_RX1DBLOQGAIN_LSB) & TOP_GAIN_RX1DBLOQGAIN_MASK)
-#define TOP_GAIN_RX6DBHIQGAIN_MSB                2
-#define TOP_GAIN_RX6DBHIQGAIN_LSB                1
-#define TOP_GAIN_RX6DBHIQGAIN_MASK               0x00000006
-#define TOP_GAIN_RX6DBHIQGAIN_GET(x)             (((x) & TOP_GAIN_RX6DBHIQGAIN_MASK) >> TOP_GAIN_RX6DBHIQGAIN_LSB)
-#define TOP_GAIN_RX6DBHIQGAIN_SET(x)             (((x) << TOP_GAIN_RX6DBHIQGAIN_LSB) & TOP_GAIN_RX6DBHIQGAIN_MASK)
-#define TOP_GAIN_SPARE_MSB                       0
-#define TOP_GAIN_SPARE_LSB                       0
-#define TOP_GAIN_SPARE_MASK                      0x00000001
-#define TOP_GAIN_SPARE_GET(x)                    (((x) & TOP_GAIN_SPARE_MASK) >> TOP_GAIN_SPARE_LSB)
-#define TOP_GAIN_SPARE_SET(x)                    (((x) << TOP_GAIN_SPARE_LSB) & TOP_GAIN_SPARE_MASK)
-
-#define TOP_TOP_ADDRESS                          0x00000034
-#define TOP_TOP_OFFSET                           0x00000034
-#define TOP_TOP_LOCALTXGAIN_MSB                  31
-#define TOP_TOP_LOCALTXGAIN_LSB                  31
-#define TOP_TOP_LOCALTXGAIN_MASK                 0x80000000
-#define TOP_TOP_LOCALTXGAIN_GET(x)               (((x) & TOP_TOP_LOCALTXGAIN_MASK) >> TOP_TOP_LOCALTXGAIN_LSB)
-#define TOP_TOP_LOCALTXGAIN_SET(x)               (((x) << TOP_TOP_LOCALTXGAIN_LSB) & TOP_TOP_LOCALTXGAIN_MASK)
-#define TOP_TOP_LOCALRXGAIN_MSB                  30
-#define TOP_TOP_LOCALRXGAIN_LSB                  30
-#define TOP_TOP_LOCALRXGAIN_MASK                 0x40000000
-#define TOP_TOP_LOCALRXGAIN_GET(x)               (((x) & TOP_TOP_LOCALRXGAIN_MASK) >> TOP_TOP_LOCALRXGAIN_LSB)
-#define TOP_TOP_LOCALRXGAIN_SET(x)               (((x) << TOP_TOP_LOCALRXGAIN_LSB) & TOP_TOP_LOCALRXGAIN_MASK)
-#define TOP_TOP_LOCALMODE_MSB                    29
-#define TOP_TOP_LOCALMODE_LSB                    29
-#define TOP_TOP_LOCALMODE_MASK                   0x20000000
-#define TOP_TOP_LOCALMODE_GET(x)                 (((x) & TOP_TOP_LOCALMODE_MASK) >> TOP_TOP_LOCALMODE_LSB)
-#define TOP_TOP_LOCALMODE_SET(x)                 (((x) << TOP_TOP_LOCALMODE_LSB) & TOP_TOP_LOCALMODE_MASK)
-#define TOP_TOP_CALFC_MSB                        28
-#define TOP_TOP_CALFC_LSB                        28
-#define TOP_TOP_CALFC_MASK                       0x10000000
-#define TOP_TOP_CALFC_GET(x)                     (((x) & TOP_TOP_CALFC_MASK) >> TOP_TOP_CALFC_LSB)
-#define TOP_TOP_CALFC_SET(x)                     (((x) << TOP_TOP_CALFC_LSB) & TOP_TOP_CALFC_MASK)
-#define TOP_TOP_CALDC_MSB                        27
-#define TOP_TOP_CALDC_LSB                        27
-#define TOP_TOP_CALDC_MASK                       0x08000000
-#define TOP_TOP_CALDC_GET(x)                     (((x) & TOP_TOP_CALDC_MASK) >> TOP_TOP_CALDC_LSB)
-#define TOP_TOP_CALDC_SET(x)                     (((x) << TOP_TOP_CALDC_LSB) & TOP_TOP_CALDC_MASK)
-#define TOP_TOP_CAL_RESIDUE_MSB                  26
-#define TOP_TOP_CAL_RESIDUE_LSB                  26
-#define TOP_TOP_CAL_RESIDUE_MASK                 0x04000000
-#define TOP_TOP_CAL_RESIDUE_GET(x)               (((x) & TOP_TOP_CAL_RESIDUE_MASK) >> TOP_TOP_CAL_RESIDUE_LSB)
-#define TOP_TOP_CAL_RESIDUE_SET(x)               (((x) << TOP_TOP_CAL_RESIDUE_LSB) & TOP_TOP_CAL_RESIDUE_MASK)
-#define TOP_TOP_BMODE_MSB                        25
-#define TOP_TOP_BMODE_LSB                        25
-#define TOP_TOP_BMODE_MASK                       0x02000000
-#define TOP_TOP_BMODE_GET(x)                     (((x) & TOP_TOP_BMODE_MASK) >> TOP_TOP_BMODE_LSB)
-#define TOP_TOP_BMODE_SET(x)                     (((x) << TOP_TOP_BMODE_LSB) & TOP_TOP_BMODE_MASK)
-#define TOP_TOP_SYNTHON_MSB                      24
-#define TOP_TOP_SYNTHON_LSB                      24
-#define TOP_TOP_SYNTHON_MASK                     0x01000000
-#define TOP_TOP_SYNTHON_GET(x)                   (((x) & TOP_TOP_SYNTHON_MASK) >> TOP_TOP_SYNTHON_LSB)
-#define TOP_TOP_SYNTHON_SET(x)                   (((x) << TOP_TOP_SYNTHON_LSB) & TOP_TOP_SYNTHON_MASK)
-#define TOP_TOP_RXON_MSB                         23
-#define TOP_TOP_RXON_LSB                         23
-#define TOP_TOP_RXON_MASK                        0x00800000
-#define TOP_TOP_RXON_GET(x)                      (((x) & TOP_TOP_RXON_MASK) >> TOP_TOP_RXON_LSB)
-#define TOP_TOP_RXON_SET(x)                      (((x) << TOP_TOP_RXON_LSB) & TOP_TOP_RXON_MASK)
-#define TOP_TOP_TXON_MSB                         22
-#define TOP_TOP_TXON_LSB                         22
-#define TOP_TOP_TXON_MASK                        0x00400000
-#define TOP_TOP_TXON_GET(x)                      (((x) & TOP_TOP_TXON_MASK) >> TOP_TOP_TXON_LSB)
-#define TOP_TOP_TXON_SET(x)                      (((x) << TOP_TOP_TXON_LSB) & TOP_TOP_TXON_MASK)
-#define TOP_TOP_PAON_MSB                         21
-#define TOP_TOP_PAON_LSB                         21
-#define TOP_TOP_PAON_MASK                        0x00200000
-#define TOP_TOP_PAON_GET(x)                      (((x) & TOP_TOP_PAON_MASK) >> TOP_TOP_PAON_LSB)
-#define TOP_TOP_PAON_SET(x)                      (((x) << TOP_TOP_PAON_LSB) & TOP_TOP_PAON_MASK)
-#define TOP_TOP_CALTX_MSB                        20
-#define TOP_TOP_CALTX_LSB                        20
-#define TOP_TOP_CALTX_MASK                       0x00100000
-#define TOP_TOP_CALTX_GET(x)                     (((x) & TOP_TOP_CALTX_MASK) >> TOP_TOP_CALTX_LSB)
-#define TOP_TOP_CALTX_SET(x)                     (((x) << TOP_TOP_CALTX_LSB) & TOP_TOP_CALTX_MASK)
-#define TOP_TOP_LOCALADDAC_MSB                   19
-#define TOP_TOP_LOCALADDAC_LSB                   19
-#define TOP_TOP_LOCALADDAC_MASK                  0x00080000
-#define TOP_TOP_LOCALADDAC_GET(x)                (((x) & TOP_TOP_LOCALADDAC_MASK) >> TOP_TOP_LOCALADDAC_LSB)
-#define TOP_TOP_LOCALADDAC_SET(x)                (((x) << TOP_TOP_LOCALADDAC_LSB) & TOP_TOP_LOCALADDAC_MASK)
-#define TOP_TOP_PWDPLL_MSB                       18
-#define TOP_TOP_PWDPLL_LSB                       18
-#define TOP_TOP_PWDPLL_MASK                      0x00040000
-#define TOP_TOP_PWDPLL_GET(x)                    (((x) & TOP_TOP_PWDPLL_MASK) >> TOP_TOP_PWDPLL_LSB)
-#define TOP_TOP_PWDPLL_SET(x)                    (((x) << TOP_TOP_PWDPLL_LSB) & TOP_TOP_PWDPLL_MASK)
-#define TOP_TOP_PWDADC_MSB                       17
-#define TOP_TOP_PWDADC_LSB                       17
-#define TOP_TOP_PWDADC_MASK                      0x00020000
-#define TOP_TOP_PWDADC_GET(x)                    (((x) & TOP_TOP_PWDADC_MASK) >> TOP_TOP_PWDADC_LSB)
-#define TOP_TOP_PWDADC_SET(x)                    (((x) << TOP_TOP_PWDADC_LSB) & TOP_TOP_PWDADC_MASK)
-#define TOP_TOP_PWDDAC_MSB                       16
-#define TOP_TOP_PWDDAC_LSB                       16
-#define TOP_TOP_PWDDAC_MASK                      0x00010000
-#define TOP_TOP_PWDDAC_GET(x)                    (((x) & TOP_TOP_PWDDAC_MASK) >> TOP_TOP_PWDDAC_LSB)
-#define TOP_TOP_PWDDAC_SET(x)                    (((x) << TOP_TOP_PWDDAC_LSB) & TOP_TOP_PWDDAC_MASK)
-#define TOP_TOP_LOCALXTAL_MSB                    15
-#define TOP_TOP_LOCALXTAL_LSB                    15
-#define TOP_TOP_LOCALXTAL_MASK                   0x00008000
-#define TOP_TOP_LOCALXTAL_GET(x)                 (((x) & TOP_TOP_LOCALXTAL_MASK) >> TOP_TOP_LOCALXTAL_LSB)
-#define TOP_TOP_LOCALXTAL_SET(x)                 (((x) << TOP_TOP_LOCALXTAL_LSB) & TOP_TOP_LOCALXTAL_MASK)
-#define TOP_TOP_PWDCLKIN_MSB                     14
-#define TOP_TOP_PWDCLKIN_LSB                     14
-#define TOP_TOP_PWDCLKIN_MASK                    0x00004000
-#define TOP_TOP_PWDCLKIN_GET(x)                  (((x) & TOP_TOP_PWDCLKIN_MASK) >> TOP_TOP_PWDCLKIN_LSB)
-#define TOP_TOP_PWDCLKIN_SET(x)                  (((x) << TOP_TOP_PWDCLKIN_LSB) & TOP_TOP_PWDCLKIN_MASK)
-#define TOP_TOP_OSCON_MSB                        13
-#define TOP_TOP_OSCON_LSB                        13
-#define TOP_TOP_OSCON_MASK                       0x00002000
-#define TOP_TOP_OSCON_GET(x)                     (((x) & TOP_TOP_OSCON_MASK) >> TOP_TOP_OSCON_LSB)
-#define TOP_TOP_OSCON_SET(x)                     (((x) << TOP_TOP_OSCON_LSB) & TOP_TOP_OSCON_MASK)
-#define TOP_TOP_SCLKEN_FORCE_MSB                 12
-#define TOP_TOP_SCLKEN_FORCE_LSB                 12
-#define TOP_TOP_SCLKEN_FORCE_MASK                0x00001000
-#define TOP_TOP_SCLKEN_FORCE_GET(x)              (((x) & TOP_TOP_SCLKEN_FORCE_MASK) >> TOP_TOP_SCLKEN_FORCE_LSB)
-#define TOP_TOP_SCLKEN_FORCE_SET(x)              (((x) << TOP_TOP_SCLKEN_FORCE_LSB) & TOP_TOP_SCLKEN_FORCE_MASK)
-#define TOP_TOP_SYNTHON_FORCE_MSB                11
-#define TOP_TOP_SYNTHON_FORCE_LSB                11
-#define TOP_TOP_SYNTHON_FORCE_MASK               0x00000800
-#define TOP_TOP_SYNTHON_FORCE_GET(x)             (((x) & TOP_TOP_SYNTHON_FORCE_MASK) >> TOP_TOP_SYNTHON_FORCE_LSB)
-#define TOP_TOP_SYNTHON_FORCE_SET(x)             (((x) << TOP_TOP_SYNTHON_FORCE_LSB) & TOP_TOP_SYNTHON_FORCE_MASK)
-#define TOP_TOP_PDBIAS_MSB                       10
-#define TOP_TOP_PDBIAS_LSB                       10
-#define TOP_TOP_PDBIAS_MASK                      0x00000400
-#define TOP_TOP_PDBIAS_GET(x)                    (((x) & TOP_TOP_PDBIAS_MASK) >> TOP_TOP_PDBIAS_LSB)
-#define TOP_TOP_PDBIAS_SET(x)                    (((x) << TOP_TOP_PDBIAS_LSB) & TOP_TOP_PDBIAS_MASK)
-#define TOP_TOP_DATAOUTSEL_MSB                   9
-#define TOP_TOP_DATAOUTSEL_LSB                   8
-#define TOP_TOP_DATAOUTSEL_MASK                  0x00000300
-#define TOP_TOP_DATAOUTSEL_GET(x)                (((x) & TOP_TOP_DATAOUTSEL_MASK) >> TOP_TOP_DATAOUTSEL_LSB)
-#define TOP_TOP_DATAOUTSEL_SET(x)                (((x) << TOP_TOP_DATAOUTSEL_LSB) & TOP_TOP_DATAOUTSEL_MASK)
-#define TOP_TOP_REVID_MSB                        7
-#define TOP_TOP_REVID_LSB                        5
-#define TOP_TOP_REVID_MASK                       0x000000e0
-#define TOP_TOP_REVID_GET(x)                     (((x) & TOP_TOP_REVID_MASK) >> TOP_TOP_REVID_LSB)
-#define TOP_TOP_REVID_SET(x)                     (((x) << TOP_TOP_REVID_LSB) & TOP_TOP_REVID_MASK)
-#define TOP_TOP_INT2PAD_MSB                      4
-#define TOP_TOP_INT2PAD_LSB                      4
-#define TOP_TOP_INT2PAD_MASK                     0x00000010
-#define TOP_TOP_INT2PAD_GET(x)                   (((x) & TOP_TOP_INT2PAD_MASK) >> TOP_TOP_INT2PAD_LSB)
-#define TOP_TOP_INT2PAD_SET(x)                   (((x) << TOP_TOP_INT2PAD_LSB) & TOP_TOP_INT2PAD_MASK)
-#define TOP_TOP_INTH2PAD_MSB                     3
-#define TOP_TOP_INTH2PAD_LSB                     3
-#define TOP_TOP_INTH2PAD_MASK                    0x00000008
-#define TOP_TOP_INTH2PAD_GET(x)                  (((x) & TOP_TOP_INTH2PAD_MASK) >> TOP_TOP_INTH2PAD_LSB)
-#define TOP_TOP_INTH2PAD_SET(x)                  (((x) << TOP_TOP_INTH2PAD_LSB) & TOP_TOP_INTH2PAD_MASK)
-#define TOP_TOP_PAD2GND_MSB                      2
-#define TOP_TOP_PAD2GND_LSB                      2
-#define TOP_TOP_PAD2GND_MASK                     0x00000004
-#define TOP_TOP_PAD2GND_GET(x)                   (((x) & TOP_TOP_PAD2GND_MASK) >> TOP_TOP_PAD2GND_LSB)
-#define TOP_TOP_PAD2GND_SET(x)                   (((x) << TOP_TOP_PAD2GND_LSB) & TOP_TOP_PAD2GND_MASK)
-#define TOP_TOP_INT2GND_MSB                      1
-#define TOP_TOP_INT2GND_LSB                      1
-#define TOP_TOP_INT2GND_MASK                     0x00000002
-#define TOP_TOP_INT2GND_GET(x)                   (((x) & TOP_TOP_INT2GND_MASK) >> TOP_TOP_INT2GND_LSB)
-#define TOP_TOP_INT2GND_SET(x)                   (((x) << TOP_TOP_INT2GND_LSB) & TOP_TOP_INT2GND_MASK)
-#define TOP_TOP_FORCE_XPAON_MSB                  0
-#define TOP_TOP_FORCE_XPAON_LSB                  0
-#define TOP_TOP_FORCE_XPAON_MASK                 0x00000001
-#define TOP_TOP_FORCE_XPAON_GET(x)               (((x) & TOP_TOP_FORCE_XPAON_MASK) >> TOP_TOP_FORCE_XPAON_LSB)
-#define TOP_TOP_FORCE_XPAON_SET(x)               (((x) << TOP_TOP_FORCE_XPAON_LSB) & TOP_TOP_FORCE_XPAON_MASK)
-
-#define BIAS_BIAS_SEL_ADDRESS                    0x00000038
-#define BIAS_BIAS_SEL_OFFSET                     0x00000038
-#define BIAS_BIAS_SEL_PADON_MSB                  31
-#define BIAS_BIAS_SEL_PADON_LSB                  31
-#define BIAS_BIAS_SEL_PADON_MASK                 0x80000000
-#define BIAS_BIAS_SEL_PADON_GET(x)               (((x) & BIAS_BIAS_SEL_PADON_MASK) >> BIAS_BIAS_SEL_PADON_LSB)
-#define BIAS_BIAS_SEL_PADON_SET(x)               (((x) << BIAS_BIAS_SEL_PADON_LSB) & BIAS_BIAS_SEL_PADON_MASK)
-#define BIAS_BIAS_SEL_SEL_BIAS_MSB               30
-#define BIAS_BIAS_SEL_SEL_BIAS_LSB               25
-#define BIAS_BIAS_SEL_SEL_BIAS_MASK              0x7e000000
-#define BIAS_BIAS_SEL_SEL_BIAS_GET(x)            (((x) & BIAS_BIAS_SEL_SEL_BIAS_MASK) >> BIAS_BIAS_SEL_SEL_BIAS_LSB)
-#define BIAS_BIAS_SEL_SEL_BIAS_SET(x)            (((x) << BIAS_BIAS_SEL_SEL_BIAS_LSB) & BIAS_BIAS_SEL_SEL_BIAS_MASK)
-#define BIAS_BIAS_SEL_SEL_SPARE_MSB              24
-#define BIAS_BIAS_SEL_SEL_SPARE_LSB              21
-#define BIAS_BIAS_SEL_SEL_SPARE_MASK             0x01e00000
-#define BIAS_BIAS_SEL_SEL_SPARE_GET(x)           (((x) & BIAS_BIAS_SEL_SEL_SPARE_MASK) >> BIAS_BIAS_SEL_SEL_SPARE_LSB)
-#define BIAS_BIAS_SEL_SEL_SPARE_SET(x)           (((x) << BIAS_BIAS_SEL_SEL_SPARE_LSB) & BIAS_BIAS_SEL_SEL_SPARE_MASK)
-#define BIAS_BIAS_SEL_SPARE_MSB                  20
-#define BIAS_BIAS_SEL_SPARE_LSB                  20
-#define BIAS_BIAS_SEL_SPARE_MASK                 0x00100000
-#define BIAS_BIAS_SEL_SPARE_GET(x)               (((x) & BIAS_BIAS_SEL_SPARE_MASK) >> BIAS_BIAS_SEL_SPARE_LSB)
-#define BIAS_BIAS_SEL_SPARE_SET(x)               (((x) << BIAS_BIAS_SEL_SPARE_LSB) & BIAS_BIAS_SEL_SPARE_MASK)
-#define BIAS_BIAS_SEL_PWD_ICREFBUFBIAS12P5_MSB   19
-#define BIAS_BIAS_SEL_PWD_ICREFBUFBIAS12P5_LSB   17
-#define BIAS_BIAS_SEL_PWD_ICREFBUFBIAS12P5_MASK  0x000e0000
-#define BIAS_BIAS_SEL_PWD_ICREFBUFBIAS12P5_GET(x) (((x) & BIAS_BIAS_SEL_PWD_ICREFBUFBIAS12P5_MASK) >> BIAS_BIAS_SEL_PWD_ICREFBUFBIAS12P5_LSB)
-#define BIAS_BIAS_SEL_PWD_ICREFBUFBIAS12P5_SET(x) (((x) << BIAS_BIAS_SEL_PWD_ICREFBUFBIAS12P5_LSB) & BIAS_BIAS_SEL_PWD_ICREFBUFBIAS12P5_MASK)
-#define BIAS_BIAS_SEL_PWD_IRDACREGREF12P5_MSB    16
-#define BIAS_BIAS_SEL_PWD_IRDACREGREF12P5_LSB    16
-#define BIAS_BIAS_SEL_PWD_IRDACREGREF12P5_MASK   0x00010000
-#define BIAS_BIAS_SEL_PWD_IRDACREGREF12P5_GET(x) (((x) & BIAS_BIAS_SEL_PWD_IRDACREGREF12P5_MASK) >> BIAS_BIAS_SEL_PWD_IRDACREGREF12P5_LSB)
-#define BIAS_BIAS_SEL_PWD_IRDACREGREF12P5_SET(x) (((x) << BIAS_BIAS_SEL_PWD_IRDACREGREF12P5_LSB) & BIAS_BIAS_SEL_PWD_IRDACREGREF12P5_MASK)
-#define BIAS_BIAS_SEL_PWD_IRREFMASTERBIAS12P5_MSB 15
-#define BIAS_BIAS_SEL_PWD_IRREFMASTERBIAS12P5_LSB 15
-#define BIAS_BIAS_SEL_PWD_IRREFMASTERBIAS12P5_MASK 0x00008000
-#define BIAS_BIAS_SEL_PWD_IRREFMASTERBIAS12P5_GET(x) (((x) & BIAS_BIAS_SEL_PWD_IRREFMASTERBIAS12P5_MASK) >> BIAS_BIAS_SEL_PWD_IRREFMASTERBIAS12P5_LSB)
-#define BIAS_BIAS_SEL_PWD_IRREFMASTERBIAS12P5_SET(x) (((x) << BIAS_BIAS_SEL_PWD_IRREFMASTERBIAS12P5_LSB) & BIAS_BIAS_SEL_PWD_IRREFMASTERBIAS12P5_MASK)
-#define BIAS_BIAS_SEL_PWD_ICREFOPAMPBIAS25_MSB   14
-#define BIAS_BIAS_SEL_PWD_ICREFOPAMPBIAS25_LSB   14
-#define BIAS_BIAS_SEL_PWD_ICREFOPAMPBIAS25_MASK  0x00004000
-#define BIAS_BIAS_SEL_PWD_ICREFOPAMPBIAS25_GET(x) (((x) & BIAS_BIAS_SEL_PWD_ICREFOPAMPBIAS25_MASK) >> BIAS_BIAS_SEL_PWD_ICREFOPAMPBIAS25_LSB)
-#define BIAS_BIAS_SEL_PWD_ICREFOPAMPBIAS25_SET(x) (((x) << BIAS_BIAS_SEL_PWD_ICREFOPAMPBIAS25_LSB) & BIAS_BIAS_SEL_PWD_ICREFOPAMPBIAS25_MASK)
-#define BIAS_BIAS_SEL_PWD_ICCPLL25_MSB           13
-#define BIAS_BIAS_SEL_PWD_ICCPLL25_LSB           13
-#define BIAS_BIAS_SEL_PWD_ICCPLL25_MASK          0x00002000
-#define BIAS_BIAS_SEL_PWD_ICCPLL25_GET(x)        (((x) & BIAS_BIAS_SEL_PWD_ICCPLL25_MASK) >> BIAS_BIAS_SEL_PWD_ICCPLL25_LSB)
-#define BIAS_BIAS_SEL_PWD_ICCPLL25_SET(x)        (((x) << BIAS_BIAS_SEL_PWD_ICCPLL25_LSB) & BIAS_BIAS_SEL_PWD_ICCPLL25_MASK)
-#define BIAS_BIAS_SEL_PWD_ICCOMPBIAS25_MSB       12
-#define BIAS_BIAS_SEL_PWD_ICCOMPBIAS25_LSB       10
-#define BIAS_BIAS_SEL_PWD_ICCOMPBIAS25_MASK      0x00001c00
-#define BIAS_BIAS_SEL_PWD_ICCOMPBIAS25_GET(x)    (((x) & BIAS_BIAS_SEL_PWD_ICCOMPBIAS25_MASK) >> BIAS_BIAS_SEL_PWD_ICCOMPBIAS25_LSB)
-#define BIAS_BIAS_SEL_PWD_ICCOMPBIAS25_SET(x)    (((x) << BIAS_BIAS_SEL_PWD_ICCOMPBIAS25_LSB) & BIAS_BIAS_SEL_PWD_ICCOMPBIAS25_MASK)
-#define BIAS_BIAS_SEL_PWD_ICXTAL25_MSB           9
-#define BIAS_BIAS_SEL_PWD_ICXTAL25_LSB           7
-#define BIAS_BIAS_SEL_PWD_ICXTAL25_MASK          0x00000380
-#define BIAS_BIAS_SEL_PWD_ICXTAL25_GET(x)        (((x) & BIAS_BIAS_SEL_PWD_ICXTAL25_MASK) >> BIAS_BIAS_SEL_PWD_ICXTAL25_LSB)
-#define BIAS_BIAS_SEL_PWD_ICXTAL25_SET(x)        (((x) << BIAS_BIAS_SEL_PWD_ICXTAL25_LSB) & BIAS_BIAS_SEL_PWD_ICXTAL25_MASK)
-#define BIAS_BIAS_SEL_PWD_ICTSENS25_MSB          6
-#define BIAS_BIAS_SEL_PWD_ICTSENS25_LSB          4
-#define BIAS_BIAS_SEL_PWD_ICTSENS25_MASK         0x00000070
-#define BIAS_BIAS_SEL_PWD_ICTSENS25_GET(x)       (((x) & BIAS_BIAS_SEL_PWD_ICTSENS25_MASK) >> BIAS_BIAS_SEL_PWD_ICTSENS25_LSB)
-#define BIAS_BIAS_SEL_PWD_ICTSENS25_SET(x)       (((x) << BIAS_BIAS_SEL_PWD_ICTSENS25_LSB) & BIAS_BIAS_SEL_PWD_ICTSENS25_MASK)
-#define BIAS_BIAS_SEL_PWD_ICTXPC25_MSB           3
-#define BIAS_BIAS_SEL_PWD_ICTXPC25_LSB           1
-#define BIAS_BIAS_SEL_PWD_ICTXPC25_MASK          0x0000000e
-#define BIAS_BIAS_SEL_PWD_ICTXPC25_GET(x)        (((x) & BIAS_BIAS_SEL_PWD_ICTXPC25_MASK) >> BIAS_BIAS_SEL_PWD_ICTXPC25_LSB)
-#define BIAS_BIAS_SEL_PWD_ICTXPC25_SET(x)        (((x) << BIAS_BIAS_SEL_PWD_ICTXPC25_LSB) & BIAS_BIAS_SEL_PWD_ICTXPC25_MASK)
-#define BIAS_BIAS_SEL_PWD_ICLDO25_MSB            0
-#define BIAS_BIAS_SEL_PWD_ICLDO25_LSB            0
-#define BIAS_BIAS_SEL_PWD_ICLDO25_MASK           0x00000001
-#define BIAS_BIAS_SEL_PWD_ICLDO25_GET(x)         (((x) & BIAS_BIAS_SEL_PWD_ICLDO25_MASK) >> BIAS_BIAS_SEL_PWD_ICLDO25_LSB)
-#define BIAS_BIAS_SEL_PWD_ICLDO25_SET(x)         (((x) << BIAS_BIAS_SEL_PWD_ICLDO25_LSB) & BIAS_BIAS_SEL_PWD_ICLDO25_MASK)
-
-#define BIAS_BIAS1_ADDRESS                       0x0000003c
-#define BIAS_BIAS1_OFFSET                        0x0000003c
-#define BIAS_BIAS1_PWD_ICDAC2BB25_MSB            31
-#define BIAS_BIAS1_PWD_ICDAC2BB25_LSB            29
-#define BIAS_BIAS1_PWD_ICDAC2BB25_MASK           0xe0000000
-#define BIAS_BIAS1_PWD_ICDAC2BB25_GET(x)         (((x) & BIAS_BIAS1_PWD_ICDAC2BB25_MASK) >> BIAS_BIAS1_PWD_ICDAC2BB25_LSB)
-#define BIAS_BIAS1_PWD_ICDAC2BB25_SET(x)         (((x) << BIAS_BIAS1_PWD_ICDAC2BB25_LSB) & BIAS_BIAS1_PWD_ICDAC2BB25_MASK)
-#define BIAS_BIAS1_PWD_IC2GVGM25_MSB             28
-#define BIAS_BIAS1_PWD_IC2GVGM25_LSB             26
-#define BIAS_BIAS1_PWD_IC2GVGM25_MASK            0x1c000000
-#define BIAS_BIAS1_PWD_IC2GVGM25_GET(x)          (((x) & BIAS_BIAS1_PWD_IC2GVGM25_MASK) >> BIAS_BIAS1_PWD_IC2GVGM25_LSB)
-#define BIAS_BIAS1_PWD_IC2GVGM25_SET(x)          (((x) << BIAS_BIAS1_PWD_IC2GVGM25_LSB) & BIAS_BIAS1_PWD_IC2GVGM25_MASK)
-#define BIAS_BIAS1_PWD_IC2GRFFE25_MSB            25
-#define BIAS_BIAS1_PWD_IC2GRFFE25_LSB            23
-#define BIAS_BIAS1_PWD_IC2GRFFE25_MASK           0x03800000
-#define BIAS_BIAS1_PWD_IC2GRFFE25_GET(x)         (((x) & BIAS_BIAS1_PWD_IC2GRFFE25_MASK) >> BIAS_BIAS1_PWD_IC2GRFFE25_LSB)
-#define BIAS_BIAS1_PWD_IC2GRFFE25_SET(x)         (((x) << BIAS_BIAS1_PWD_IC2GRFFE25_LSB) & BIAS_BIAS1_PWD_IC2GRFFE25_MASK)
-#define BIAS_BIAS1_PWD_IC2GLOREG25_MSB           22
-#define BIAS_BIAS1_PWD_IC2GLOREG25_LSB           20
-#define BIAS_BIAS1_PWD_IC2GLOREG25_MASK          0x00700000
-#define BIAS_BIAS1_PWD_IC2GLOREG25_GET(x)        (((x) & BIAS_BIAS1_PWD_IC2GLOREG25_MASK) >> BIAS_BIAS1_PWD_IC2GLOREG25_LSB)
-#define BIAS_BIAS1_PWD_IC2GLOREG25_SET(x)        (((x) << BIAS_BIAS1_PWD_IC2GLOREG25_LSB) & BIAS_BIAS1_PWD_IC2GLOREG25_MASK)
-#define BIAS_BIAS1_PWD_IC2GLNAREG25_MSB          19
-#define BIAS_BIAS1_PWD_IC2GLNAREG25_LSB          17
-#define BIAS_BIAS1_PWD_IC2GLNAREG25_MASK         0x000e0000
-#define BIAS_BIAS1_PWD_IC2GLNAREG25_GET(x)       (((x) & BIAS_BIAS1_PWD_IC2GLNAREG25_MASK) >> BIAS_BIAS1_PWD_IC2GLNAREG25_LSB)
-#define BIAS_BIAS1_PWD_IC2GLNAREG25_SET(x)       (((x) << BIAS_BIAS1_PWD_IC2GLNAREG25_LSB) & BIAS_BIAS1_PWD_IC2GLNAREG25_MASK)
-#define BIAS_BIAS1_PWD_ICDETECTORB25_MSB         16
-#define BIAS_BIAS1_PWD_ICDETECTORB25_LSB         16
-#define BIAS_BIAS1_PWD_ICDETECTORB25_MASK        0x00010000
-#define BIAS_BIAS1_PWD_ICDETECTORB25_GET(x)      (((x) & BIAS_BIAS1_PWD_ICDETECTORB25_MASK) >> BIAS_BIAS1_PWD_ICDETECTORB25_LSB)
-#define BIAS_BIAS1_PWD_ICDETECTORB25_SET(x)      (((x) << BIAS_BIAS1_PWD_ICDETECTORB25_LSB) & BIAS_BIAS1_PWD_ICDETECTORB25_MASK)
-#define BIAS_BIAS1_PWD_ICDETECTORA25_MSB         15
-#define BIAS_BIAS1_PWD_ICDETECTORA25_LSB         15
-#define BIAS_BIAS1_PWD_ICDETECTORA25_MASK        0x00008000
-#define BIAS_BIAS1_PWD_ICDETECTORA25_GET(x)      (((x) & BIAS_BIAS1_PWD_ICDETECTORA25_MASK) >> BIAS_BIAS1_PWD_ICDETECTORA25_LSB)
-#define BIAS_BIAS1_PWD_ICDETECTORA25_SET(x)      (((x) << BIAS_BIAS1_PWD_ICDETECTORA25_LSB) & BIAS_BIAS1_PWD_ICDETECTORA25_MASK)
-#define BIAS_BIAS1_PWD_IC5GRXRF25_MSB            14
-#define BIAS_BIAS1_PWD_IC5GRXRF25_LSB            14
-#define BIAS_BIAS1_PWD_IC5GRXRF25_MASK           0x00004000
-#define BIAS_BIAS1_PWD_IC5GRXRF25_GET(x)         (((x) & BIAS_BIAS1_PWD_IC5GRXRF25_MASK) >> BIAS_BIAS1_PWD_IC5GRXRF25_LSB)
-#define BIAS_BIAS1_PWD_IC5GRXRF25_SET(x)         (((x) << BIAS_BIAS1_PWD_IC5GRXRF25_LSB) & BIAS_BIAS1_PWD_IC5GRXRF25_MASK)
-#define BIAS_BIAS1_PWD_IC5GTXPA25_MSB            13
-#define BIAS_BIAS1_PWD_IC5GTXPA25_LSB            11
-#define BIAS_BIAS1_PWD_IC5GTXPA25_MASK           0x00003800
-#define BIAS_BIAS1_PWD_IC5GTXPA25_GET(x)         (((x) & BIAS_BIAS1_PWD_IC5GTXPA25_MASK) >> BIAS_BIAS1_PWD_IC5GTXPA25_LSB)
-#define BIAS_BIAS1_PWD_IC5GTXPA25_SET(x)         (((x) << BIAS_BIAS1_PWD_IC5GTXPA25_LSB) & BIAS_BIAS1_PWD_IC5GTXPA25_MASK)
-#define BIAS_BIAS1_PWD_IC5GTXBUF25_MSB           10
-#define BIAS_BIAS1_PWD_IC5GTXBUF25_LSB           8
-#define BIAS_BIAS1_PWD_IC5GTXBUF25_MASK          0x00000700
-#define BIAS_BIAS1_PWD_IC5GTXBUF25_GET(x)        (((x) & BIAS_BIAS1_PWD_IC5GTXBUF25_MASK) >> BIAS_BIAS1_PWD_IC5GTXBUF25_LSB)
-#define BIAS_BIAS1_PWD_IC5GTXBUF25_SET(x)        (((x) << BIAS_BIAS1_PWD_IC5GTXBUF25_LSB) & BIAS_BIAS1_PWD_IC5GTXBUF25_MASK)
-#define BIAS_BIAS1_PWD_IC5GQB25_MSB              7
-#define BIAS_BIAS1_PWD_IC5GQB25_LSB              5
-#define BIAS_BIAS1_PWD_IC5GQB25_MASK             0x000000e0
-#define BIAS_BIAS1_PWD_IC5GQB25_GET(x)           (((x) & BIAS_BIAS1_PWD_IC5GQB25_MASK) >> BIAS_BIAS1_PWD_IC5GQB25_LSB)
-#define BIAS_BIAS1_PWD_IC5GQB25_SET(x)           (((x) << BIAS_BIAS1_PWD_IC5GQB25_LSB) & BIAS_BIAS1_PWD_IC5GQB25_MASK)
-#define BIAS_BIAS1_PWD_IC5GMIXQ25_MSB            4
-#define BIAS_BIAS1_PWD_IC5GMIXQ25_LSB            2
-#define BIAS_BIAS1_PWD_IC5GMIXQ25_MASK           0x0000001c
-#define BIAS_BIAS1_PWD_IC5GMIXQ25_GET(x)         (((x) & BIAS_BIAS1_PWD_IC5GMIXQ25_MASK) >> BIAS_BIAS1_PWD_IC5GMIXQ25_LSB)
-#define BIAS_BIAS1_PWD_IC5GMIXQ25_SET(x)         (((x) << BIAS_BIAS1_PWD_IC5GMIXQ25_LSB) & BIAS_BIAS1_PWD_IC5GMIXQ25_MASK)
-#define BIAS_BIAS1_SPARE_MSB                     1
-#define BIAS_BIAS1_SPARE_LSB                     0
-#define BIAS_BIAS1_SPARE_MASK                    0x00000003
-#define BIAS_BIAS1_SPARE_GET(x)                  (((x) & BIAS_BIAS1_SPARE_MASK) >> BIAS_BIAS1_SPARE_LSB)
-#define BIAS_BIAS1_SPARE_SET(x)                  (((x) << BIAS_BIAS1_SPARE_LSB) & BIAS_BIAS1_SPARE_MASK)
-
-#define BIAS_BIAS2_ADDRESS                       0x00000040
-#define BIAS_BIAS2_OFFSET                        0x00000040
-#define BIAS_BIAS2_PWD_IC5GMIXI25_MSB            31
-#define BIAS_BIAS2_PWD_IC5GMIXI25_LSB            29
-#define BIAS_BIAS2_PWD_IC5GMIXI25_MASK           0xe0000000
-#define BIAS_BIAS2_PWD_IC5GMIXI25_GET(x)         (((x) & BIAS_BIAS2_PWD_IC5GMIXI25_MASK) >> BIAS_BIAS2_PWD_IC5GMIXI25_LSB)
-#define BIAS_BIAS2_PWD_IC5GMIXI25_SET(x)         (((x) << BIAS_BIAS2_PWD_IC5GMIXI25_LSB) & BIAS_BIAS2_PWD_IC5GMIXI25_MASK)
-#define BIAS_BIAS2_PWD_IC5GDIV25_MSB             28
-#define BIAS_BIAS2_PWD_IC5GDIV25_LSB             26
-#define BIAS_BIAS2_PWD_IC5GDIV25_MASK            0x1c000000
-#define BIAS_BIAS2_PWD_IC5GDIV25_GET(x)          (((x) & BIAS_BIAS2_PWD_IC5GDIV25_MASK) >> BIAS_BIAS2_PWD_IC5GDIV25_LSB)
-#define BIAS_BIAS2_PWD_IC5GDIV25_SET(x)          (((x) << BIAS_BIAS2_PWD_IC5GDIV25_LSB) & BIAS_BIAS2_PWD_IC5GDIV25_MASK)
-#define BIAS_BIAS2_PWD_IC5GLOREG25_MSB           25
-#define BIAS_BIAS2_PWD_IC5GLOREG25_LSB           23
-#define BIAS_BIAS2_PWD_IC5GLOREG25_MASK          0x03800000
-#define BIAS_BIAS2_PWD_IC5GLOREG25_GET(x)        (((x) & BIAS_BIAS2_PWD_IC5GLOREG25_MASK) >> BIAS_BIAS2_PWD_IC5GLOREG25_LSB)
-#define BIAS_BIAS2_PWD_IC5GLOREG25_SET(x)        (((x) << BIAS_BIAS2_PWD_IC5GLOREG25_LSB) & BIAS_BIAS2_PWD_IC5GLOREG25_MASK)
-#define BIAS_BIAS2_PWD_IRPLL25_MSB               22
-#define BIAS_BIAS2_PWD_IRPLL25_LSB               22
-#define BIAS_BIAS2_PWD_IRPLL25_MASK              0x00400000
-#define BIAS_BIAS2_PWD_IRPLL25_GET(x)            (((x) & BIAS_BIAS2_PWD_IRPLL25_MASK) >> BIAS_BIAS2_PWD_IRPLL25_LSB)
-#define BIAS_BIAS2_PWD_IRPLL25_SET(x)            (((x) << BIAS_BIAS2_PWD_IRPLL25_LSB) & BIAS_BIAS2_PWD_IRPLL25_MASK)
-#define BIAS_BIAS2_PWD_IRXTAL25_MSB              21
-#define BIAS_BIAS2_PWD_IRXTAL25_LSB              19
-#define BIAS_BIAS2_PWD_IRXTAL25_MASK             0x00380000
-#define BIAS_BIAS2_PWD_IRXTAL25_GET(x)           (((x) & BIAS_BIAS2_PWD_IRXTAL25_MASK) >> BIAS_BIAS2_PWD_IRXTAL25_LSB)
-#define BIAS_BIAS2_PWD_IRXTAL25_SET(x)           (((x) << BIAS_BIAS2_PWD_IRXTAL25_LSB) & BIAS_BIAS2_PWD_IRXTAL25_MASK)
-#define BIAS_BIAS2_PWD_IRTSENS25_MSB             18
-#define BIAS_BIAS2_PWD_IRTSENS25_LSB             16
-#define BIAS_BIAS2_PWD_IRTSENS25_MASK            0x00070000
-#define BIAS_BIAS2_PWD_IRTSENS25_GET(x)          (((x) & BIAS_BIAS2_PWD_IRTSENS25_MASK) >> BIAS_BIAS2_PWD_IRTSENS25_LSB)
-#define BIAS_BIAS2_PWD_IRTSENS25_SET(x)          (((x) << BIAS_BIAS2_PWD_IRTSENS25_LSB) & BIAS_BIAS2_PWD_IRTSENS25_MASK)
-#define BIAS_BIAS2_PWD_IRTXPC25_MSB              15
-#define BIAS_BIAS2_PWD_IRTXPC25_LSB              13
-#define BIAS_BIAS2_PWD_IRTXPC25_MASK             0x0000e000
-#define BIAS_BIAS2_PWD_IRTXPC25_GET(x)           (((x) & BIAS_BIAS2_PWD_IRTXPC25_MASK) >> BIAS_BIAS2_PWD_IRTXPC25_LSB)
-#define BIAS_BIAS2_PWD_IRTXPC25_SET(x)           (((x) << BIAS_BIAS2_PWD_IRTXPC25_LSB) & BIAS_BIAS2_PWD_IRTXPC25_MASK)
-#define BIAS_BIAS2_PWD_IRLDO25_MSB               12
-#define BIAS_BIAS2_PWD_IRLDO25_LSB               12
-#define BIAS_BIAS2_PWD_IRLDO25_MASK              0x00001000
-#define BIAS_BIAS2_PWD_IRLDO25_GET(x)            (((x) & BIAS_BIAS2_PWD_IRLDO25_MASK) >> BIAS_BIAS2_PWD_IRLDO25_LSB)
-#define BIAS_BIAS2_PWD_IRLDO25_SET(x)            (((x) << BIAS_BIAS2_PWD_IRLDO25_LSB) & BIAS_BIAS2_PWD_IRLDO25_MASK)
-#define BIAS_BIAS2_PWD_IR2GTXMIX25_MSB           11
-#define BIAS_BIAS2_PWD_IR2GTXMIX25_LSB           9
-#define BIAS_BIAS2_PWD_IR2GTXMIX25_MASK          0x00000e00
-#define BIAS_BIAS2_PWD_IR2GTXMIX25_GET(x)        (((x) & BIAS_BIAS2_PWD_IR2GTXMIX25_MASK) >> BIAS_BIAS2_PWD_IR2GTXMIX25_LSB)
-#define BIAS_BIAS2_PWD_IR2GTXMIX25_SET(x)        (((x) << BIAS_BIAS2_PWD_IR2GTXMIX25_LSB) & BIAS_BIAS2_PWD_IR2GTXMIX25_MASK)
-#define BIAS_BIAS2_PWD_IR2GLOREG25_MSB           8
-#define BIAS_BIAS2_PWD_IR2GLOREG25_LSB           6
-#define BIAS_BIAS2_PWD_IR2GLOREG25_MASK          0x000001c0
-#define BIAS_BIAS2_PWD_IR2GLOREG25_GET(x)        (((x) & BIAS_BIAS2_PWD_IR2GLOREG25_MASK) >> BIAS_BIAS2_PWD_IR2GLOREG25_LSB)
-#define BIAS_BIAS2_PWD_IR2GLOREG25_SET(x)        (((x) << BIAS_BIAS2_PWD_IR2GLOREG25_LSB) & BIAS_BIAS2_PWD_IR2GLOREG25_MASK)
-#define BIAS_BIAS2_PWD_IR2GLNAREG25_MSB          5
-#define BIAS_BIAS2_PWD_IR2GLNAREG25_LSB          3
-#define BIAS_BIAS2_PWD_IR2GLNAREG25_MASK         0x00000038
-#define BIAS_BIAS2_PWD_IR2GLNAREG25_GET(x)       (((x) & BIAS_BIAS2_PWD_IR2GLNAREG25_MASK) >> BIAS_BIAS2_PWD_IR2GLNAREG25_LSB)
-#define BIAS_BIAS2_PWD_IR2GLNAREG25_SET(x)       (((x) << BIAS_BIAS2_PWD_IR2GLNAREG25_LSB) & BIAS_BIAS2_PWD_IR2GLNAREG25_MASK)
-#define BIAS_BIAS2_PWD_IR5GRFVREF2525_MSB        2
-#define BIAS_BIAS2_PWD_IR5GRFVREF2525_LSB        0
-#define BIAS_BIAS2_PWD_IR5GRFVREF2525_MASK       0x00000007
-#define BIAS_BIAS2_PWD_IR5GRFVREF2525_GET(x)     (((x) & BIAS_BIAS2_PWD_IR5GRFVREF2525_MASK) >> BIAS_BIAS2_PWD_IR5GRFVREF2525_LSB)
-#define BIAS_BIAS2_PWD_IR5GRFVREF2525_SET(x)     (((x) << BIAS_BIAS2_PWD_IR5GRFVREF2525_LSB) & BIAS_BIAS2_PWD_IR5GRFVREF2525_MASK)
-
-#define BIAS_BIAS3_ADDRESS                       0x00000044
-#define BIAS_BIAS3_OFFSET                        0x00000044
-#define BIAS_BIAS3_PWD_IR5GTXMIX25_MSB           31
-#define BIAS_BIAS3_PWD_IR5GTXMIX25_LSB           29
-#define BIAS_BIAS3_PWD_IR5GTXMIX25_MASK          0xe0000000
-#define BIAS_BIAS3_PWD_IR5GTXMIX25_GET(x)        (((x) & BIAS_BIAS3_PWD_IR5GTXMIX25_MASK) >> BIAS_BIAS3_PWD_IR5GTXMIX25_LSB)
-#define BIAS_BIAS3_PWD_IR5GTXMIX25_SET(x)        (((x) << BIAS_BIAS3_PWD_IR5GTXMIX25_LSB) & BIAS_BIAS3_PWD_IR5GTXMIX25_MASK)
-#define BIAS_BIAS3_PWD_IR5GAGC25_MSB             28
-#define BIAS_BIAS3_PWD_IR5GAGC25_LSB             26
-#define BIAS_BIAS3_PWD_IR5GAGC25_MASK            0x1c000000
-#define BIAS_BIAS3_PWD_IR5GAGC25_GET(x)          (((x) & BIAS_BIAS3_PWD_IR5GAGC25_MASK) >> BIAS_BIAS3_PWD_IR5GAGC25_LSB)
-#define BIAS_BIAS3_PWD_IR5GAGC25_SET(x)          (((x) << BIAS_BIAS3_PWD_IR5GAGC25_LSB) & BIAS_BIAS3_PWD_IR5GAGC25_MASK)
-#define BIAS_BIAS3_PWD_ICDAC50_MSB               25
-#define BIAS_BIAS3_PWD_ICDAC50_LSB               23
-#define BIAS_BIAS3_PWD_ICDAC50_MASK              0x03800000
-#define BIAS_BIAS3_PWD_ICDAC50_GET(x)            (((x) & BIAS_BIAS3_PWD_ICDAC50_MASK) >> BIAS_BIAS3_PWD_ICDAC50_LSB)
-#define BIAS_BIAS3_PWD_ICDAC50_SET(x)            (((x) << BIAS_BIAS3_PWD_ICDAC50_LSB) & BIAS_BIAS3_PWD_ICDAC50_MASK)
-#define BIAS_BIAS3_PWD_ICSYNTH50_MSB             22
-#define BIAS_BIAS3_PWD_ICSYNTH50_LSB             22
-#define BIAS_BIAS3_PWD_ICSYNTH50_MASK            0x00400000
-#define BIAS_BIAS3_PWD_ICSYNTH50_GET(x)          (((x) & BIAS_BIAS3_PWD_ICSYNTH50_MASK) >> BIAS_BIAS3_PWD_ICSYNTH50_LSB)
-#define BIAS_BIAS3_PWD_ICSYNTH50_SET(x)          (((x) << BIAS_BIAS3_PWD_ICSYNTH50_LSB) & BIAS_BIAS3_PWD_ICSYNTH50_MASK)
-#define BIAS_BIAS3_PWD_ICBB50_MSB                21
-#define BIAS_BIAS3_PWD_ICBB50_LSB                21
-#define BIAS_BIAS3_PWD_ICBB50_MASK               0x00200000
-#define BIAS_BIAS3_PWD_ICBB50_GET(x)             (((x) & BIAS_BIAS3_PWD_ICBB50_MASK) >> BIAS_BIAS3_PWD_ICBB50_LSB)
-#define BIAS_BIAS3_PWD_ICBB50_SET(x)             (((x) << BIAS_BIAS3_PWD_ICBB50_LSB) & BIAS_BIAS3_PWD_ICBB50_MASK)
-#define BIAS_BIAS3_PWD_IC2GDIV50_MSB             20
-#define BIAS_BIAS3_PWD_IC2GDIV50_LSB             18
-#define BIAS_BIAS3_PWD_IC2GDIV50_MASK            0x001c0000
-#define BIAS_BIAS3_PWD_IC2GDIV50_GET(x)          (((x) & BIAS_BIAS3_PWD_IC2GDIV50_MASK) >> BIAS_BIAS3_PWD_IC2GDIV50_LSB)
-#define BIAS_BIAS3_PWD_IC2GDIV50_SET(x)          (((x) << BIAS_BIAS3_PWD_IC2GDIV50_LSB) & BIAS_BIAS3_PWD_IC2GDIV50_MASK)
-#define BIAS_BIAS3_PWD_IRSYNTH50_MSB             17
-#define BIAS_BIAS3_PWD_IRSYNTH50_LSB             17
-#define BIAS_BIAS3_PWD_IRSYNTH50_MASK            0x00020000
-#define BIAS_BIAS3_PWD_IRSYNTH50_GET(x)          (((x) & BIAS_BIAS3_PWD_IRSYNTH50_MASK) >> BIAS_BIAS3_PWD_IRSYNTH50_LSB)
-#define BIAS_BIAS3_PWD_IRSYNTH50_SET(x)          (((x) << BIAS_BIAS3_PWD_IRSYNTH50_LSB) & BIAS_BIAS3_PWD_IRSYNTH50_MASK)
-#define BIAS_BIAS3_PWD_IRBB50_MSB                16
-#define BIAS_BIAS3_PWD_IRBB50_LSB                16
-#define BIAS_BIAS3_PWD_IRBB50_MASK               0x00010000
-#define BIAS_BIAS3_PWD_IRBB50_GET(x)             (((x) & BIAS_BIAS3_PWD_IRBB50_MASK) >> BIAS_BIAS3_PWD_IRBB50_LSB)
-#define BIAS_BIAS3_PWD_IRBB50_SET(x)             (((x) << BIAS_BIAS3_PWD_IRBB50_LSB) & BIAS_BIAS3_PWD_IRBB50_MASK)
-#define BIAS_BIAS3_PWD_IC25SPARE1_MSB            15
-#define BIAS_BIAS3_PWD_IC25SPARE1_LSB            13
-#define BIAS_BIAS3_PWD_IC25SPARE1_MASK           0x0000e000
-#define BIAS_BIAS3_PWD_IC25SPARE1_GET(x)         (((x) & BIAS_BIAS3_PWD_IC25SPARE1_MASK) >> BIAS_BIAS3_PWD_IC25SPARE1_LSB)
-#define BIAS_BIAS3_PWD_IC25SPARE1_SET(x)         (((x) << BIAS_BIAS3_PWD_IC25SPARE1_LSB) & BIAS_BIAS3_PWD_IC25SPARE1_MASK)
-#define BIAS_BIAS3_PWD_IC25SPARE2_MSB            12
-#define BIAS_BIAS3_PWD_IC25SPARE2_LSB            10
-#define BIAS_BIAS3_PWD_IC25SPARE2_MASK           0x00001c00
-#define BIAS_BIAS3_PWD_IC25SPARE2_GET(x)         (((x) & BIAS_BIAS3_PWD_IC25SPARE2_MASK) >> BIAS_BIAS3_PWD_IC25SPARE2_LSB)
-#define BIAS_BIAS3_PWD_IC25SPARE2_SET(x)         (((x) << BIAS_BIAS3_PWD_IC25SPARE2_LSB) & BIAS_BIAS3_PWD_IC25SPARE2_MASK)
-#define BIAS_BIAS3_PWD_IR25SPARE1_MSB            9
-#define BIAS_BIAS3_PWD_IR25SPARE1_LSB            7
-#define BIAS_BIAS3_PWD_IR25SPARE1_MASK           0x00000380
-#define BIAS_BIAS3_PWD_IR25SPARE1_GET(x)         (((x) & BIAS_BIAS3_PWD_IR25SPARE1_MASK) >> BIAS_BIAS3_PWD_IR25SPARE1_LSB)
-#define BIAS_BIAS3_PWD_IR25SPARE1_SET(x)         (((x) << BIAS_BIAS3_PWD_IR25SPARE1_LSB) & BIAS_BIAS3_PWD_IR25SPARE1_MASK)
-#define BIAS_BIAS3_PWD_IR25SPARE2_MSB            6
-#define BIAS_BIAS3_PWD_IR25SPARE2_LSB            4
-#define BIAS_BIAS3_PWD_IR25SPARE2_MASK           0x00000070
-#define BIAS_BIAS3_PWD_IR25SPARE2_GET(x)         (((x) & BIAS_BIAS3_PWD_IR25SPARE2_MASK) >> BIAS_BIAS3_PWD_IR25SPARE2_LSB)
-#define BIAS_BIAS3_PWD_IR25SPARE2_SET(x)         (((x) << BIAS_BIAS3_PWD_IR25SPARE2_LSB) & BIAS_BIAS3_PWD_IR25SPARE2_MASK)
-#define BIAS_BIAS3_PWD_ICDACREG12P5_MSB          3
-#define BIAS_BIAS3_PWD_ICDACREG12P5_LSB          1
-#define BIAS_BIAS3_PWD_ICDACREG12P5_MASK         0x0000000e
-#define BIAS_BIAS3_PWD_ICDACREG12P5_GET(x)       (((x) & BIAS_BIAS3_PWD_ICDACREG12P5_MASK) >> BIAS_BIAS3_PWD_ICDACREG12P5_LSB)
-#define BIAS_BIAS3_PWD_ICDACREG12P5_SET(x)       (((x) << BIAS_BIAS3_PWD_ICDACREG12P5_LSB) & BIAS_BIAS3_PWD_ICDACREG12P5_MASK)
-#define BIAS_BIAS3_SPARE_MSB                     0
-#define BIAS_BIAS3_SPARE_LSB                     0
-#define BIAS_BIAS3_SPARE_MASK                    0x00000001
-#define BIAS_BIAS3_SPARE_GET(x)                  (((x) & BIAS_BIAS3_SPARE_MASK) >> BIAS_BIAS3_SPARE_LSB)
-#define BIAS_BIAS3_SPARE_SET(x)                  (((x) << BIAS_BIAS3_SPARE_LSB) & BIAS_BIAS3_SPARE_MASK)
-
-#define TXPC_TXPC_ADDRESS                        0x00000048
-#define TXPC_TXPC_OFFSET                         0x00000048
-#define TXPC_TXPC_SELINTPD_MSB                   31
-#define TXPC_TXPC_SELINTPD_LSB                   31
-#define TXPC_TXPC_SELINTPD_MASK                  0x80000000
-#define TXPC_TXPC_SELINTPD_GET(x)                (((x) & TXPC_TXPC_SELINTPD_MASK) >> TXPC_TXPC_SELINTPD_LSB)
-#define TXPC_TXPC_SELINTPD_SET(x)                (((x) << TXPC_TXPC_SELINTPD_LSB) & TXPC_TXPC_SELINTPD_MASK)
-#define TXPC_TXPC_TEST_MSB                       30
-#define TXPC_TXPC_TEST_LSB                       30
-#define TXPC_TXPC_TEST_MASK                      0x40000000
-#define TXPC_TXPC_TEST_GET(x)                    (((x) & TXPC_TXPC_TEST_MASK) >> TXPC_TXPC_TEST_LSB)
-#define TXPC_TXPC_TEST_SET(x)                    (((x) << TXPC_TXPC_TEST_LSB) & TXPC_TXPC_TEST_MASK)
-#define TXPC_TXPC_TESTGAIN_MSB                   29
-#define TXPC_TXPC_TESTGAIN_LSB                   28
-#define TXPC_TXPC_TESTGAIN_MASK                  0x30000000
-#define TXPC_TXPC_TESTGAIN_GET(x)                (((x) & TXPC_TXPC_TESTGAIN_MASK) >> TXPC_TXPC_TESTGAIN_LSB)
-#define TXPC_TXPC_TESTGAIN_SET(x)                (((x) << TXPC_TXPC_TESTGAIN_LSB) & TXPC_TXPC_TESTGAIN_MASK)
-#define TXPC_TXPC_TESTDAC_MSB                    27
-#define TXPC_TXPC_TESTDAC_LSB                    22
-#define TXPC_TXPC_TESTDAC_MASK                   0x0fc00000
-#define TXPC_TXPC_TESTDAC_GET(x)                 (((x) & TXPC_TXPC_TESTDAC_MASK) >> TXPC_TXPC_TESTDAC_LSB)
-#define TXPC_TXPC_TESTDAC_SET(x)                 (((x) << TXPC_TXPC_TESTDAC_LSB) & TXPC_TXPC_TESTDAC_MASK)
-#define TXPC_TXPC_TESTPWDPC_MSB                  21
-#define TXPC_TXPC_TESTPWDPC_LSB                  21
-#define TXPC_TXPC_TESTPWDPC_MASK                 0x00200000
-#define TXPC_TXPC_TESTPWDPC_GET(x)               (((x) & TXPC_TXPC_TESTPWDPC_MASK) >> TXPC_TXPC_TESTPWDPC_LSB)
-#define TXPC_TXPC_TESTPWDPC_SET(x)               (((x) << TXPC_TXPC_TESTPWDPC_LSB) & TXPC_TXPC_TESTPWDPC_MASK)
-#define TXPC_TXPC_CURHALF_MSB                    20
-#define TXPC_TXPC_CURHALF_LSB                    20
-#define TXPC_TXPC_CURHALF_MASK                   0x00100000
-#define TXPC_TXPC_CURHALF_GET(x)                 (((x) & TXPC_TXPC_CURHALF_MASK) >> TXPC_TXPC_CURHALF_LSB)
-#define TXPC_TXPC_CURHALF_SET(x)                 (((x) << TXPC_TXPC_CURHALF_LSB) & TXPC_TXPC_CURHALF_MASK)
-#define TXPC_TXPC_NEGOUT_MSB                     19
-#define TXPC_TXPC_NEGOUT_LSB                     19
-#define TXPC_TXPC_NEGOUT_MASK                    0x00080000
-#define TXPC_TXPC_NEGOUT_GET(x)                  (((x) & TXPC_TXPC_NEGOUT_MASK) >> TXPC_TXPC_NEGOUT_LSB)
-#define TXPC_TXPC_NEGOUT_SET(x)                  (((x) << TXPC_TXPC_NEGOUT_LSB) & TXPC_TXPC_NEGOUT_MASK)
-#define TXPC_TXPC_CLKDELAY_MSB                   18
-#define TXPC_TXPC_CLKDELAY_LSB                   18
-#define TXPC_TXPC_CLKDELAY_MASK                  0x00040000
-#define TXPC_TXPC_CLKDELAY_GET(x)                (((x) & TXPC_TXPC_CLKDELAY_MASK) >> TXPC_TXPC_CLKDELAY_LSB)
-#define TXPC_TXPC_CLKDELAY_SET(x)                (((x) << TXPC_TXPC_CLKDELAY_LSB) & TXPC_TXPC_CLKDELAY_MASK)
-#define TXPC_TXPC_SELMODREF_MSB                  17
-#define TXPC_TXPC_SELMODREF_LSB                  17
-#define TXPC_TXPC_SELMODREF_MASK                 0x00020000
-#define TXPC_TXPC_SELMODREF_GET(x)               (((x) & TXPC_TXPC_SELMODREF_MASK) >> TXPC_TXPC_SELMODREF_LSB)
-#define TXPC_TXPC_SELMODREF_SET(x)               (((x) << TXPC_TXPC_SELMODREF_LSB) & TXPC_TXPC_SELMODREF_MASK)
-#define TXPC_TXPC_SELCMOUT_MSB                   16
-#define TXPC_TXPC_SELCMOUT_LSB                   16
-#define TXPC_TXPC_SELCMOUT_MASK                  0x00010000
-#define TXPC_TXPC_SELCMOUT_GET(x)                (((x) & TXPC_TXPC_SELCMOUT_MASK) >> TXPC_TXPC_SELCMOUT_LSB)
-#define TXPC_TXPC_SELCMOUT_SET(x)                (((x) << TXPC_TXPC_SELCMOUT_LSB) & TXPC_TXPC_SELCMOUT_MASK)
-#define TXPC_TXPC_TSMODE_MSB                     15
-#define TXPC_TXPC_TSMODE_LSB                     14
-#define TXPC_TXPC_TSMODE_MASK                    0x0000c000
-#define TXPC_TXPC_TSMODE_GET(x)                  (((x) & TXPC_TXPC_TSMODE_MASK) >> TXPC_TXPC_TSMODE_LSB)
-#define TXPC_TXPC_TSMODE_SET(x)                  (((x) << TXPC_TXPC_TSMODE_LSB) & TXPC_TXPC_TSMODE_MASK)
-#define TXPC_TXPC_N_MSB                          13
-#define TXPC_TXPC_N_LSB                          6
-#define TXPC_TXPC_N_MASK                         0x00003fc0
-#define TXPC_TXPC_N_GET(x)                       (((x) & TXPC_TXPC_N_MASK) >> TXPC_TXPC_N_LSB)
-#define TXPC_TXPC_N_SET(x)                       (((x) << TXPC_TXPC_N_LSB) & TXPC_TXPC_N_MASK)
-#define TXPC_TXPC_ON1STSYNTHON_MSB               5
-#define TXPC_TXPC_ON1STSYNTHON_LSB               5
-#define TXPC_TXPC_ON1STSYNTHON_MASK              0x00000020
-#define TXPC_TXPC_ON1STSYNTHON_GET(x)            (((x) & TXPC_TXPC_ON1STSYNTHON_MASK) >> TXPC_TXPC_ON1STSYNTHON_LSB)
-#define TXPC_TXPC_ON1STSYNTHON_SET(x)            (((x) << TXPC_TXPC_ON1STSYNTHON_LSB) & TXPC_TXPC_ON1STSYNTHON_MASK)
-#define TXPC_TXPC_SELINIT_MSB                    4
-#define TXPC_TXPC_SELINIT_LSB                    3
-#define TXPC_TXPC_SELINIT_MASK                   0x00000018
-#define TXPC_TXPC_SELINIT_GET(x)                 (((x) & TXPC_TXPC_SELINIT_MASK) >> TXPC_TXPC_SELINIT_LSB)
-#define TXPC_TXPC_SELINIT_SET(x)                 (((x) << TXPC_TXPC_SELINIT_LSB) & TXPC_TXPC_SELINIT_MASK)
-#define TXPC_TXPC_SELCOUNT_MSB                   2
-#define TXPC_TXPC_SELCOUNT_LSB                   2
-#define TXPC_TXPC_SELCOUNT_MASK                  0x00000004
-#define TXPC_TXPC_SELCOUNT_GET(x)                (((x) & TXPC_TXPC_SELCOUNT_MASK) >> TXPC_TXPC_SELCOUNT_LSB)
-#define TXPC_TXPC_SELCOUNT_SET(x)                (((x) << TXPC_TXPC_SELCOUNT_LSB) & TXPC_TXPC_SELCOUNT_MASK)
-#define TXPC_TXPC_ATBSEL_MSB                     1
-#define TXPC_TXPC_ATBSEL_LSB                     0
-#define TXPC_TXPC_ATBSEL_MASK                    0x00000003
-#define TXPC_TXPC_ATBSEL_GET(x)                  (((x) & TXPC_TXPC_ATBSEL_MASK) >> TXPC_TXPC_ATBSEL_LSB)
-#define TXPC_TXPC_ATBSEL_SET(x)                  (((x) << TXPC_TXPC_ATBSEL_LSB) & TXPC_TXPC_ATBSEL_MASK)
-
-#define TXPC_MISC_ADDRESS                        0x0000004c
-#define TXPC_MISC_OFFSET                         0x0000004c
-#define TXPC_MISC_FLIPBMODE_MSB                  31
-#define TXPC_MISC_FLIPBMODE_LSB                  31
-#define TXPC_MISC_FLIPBMODE_MASK                 0x80000000
-#define TXPC_MISC_FLIPBMODE_GET(x)               (((x) & TXPC_MISC_FLIPBMODE_MASK) >> TXPC_MISC_FLIPBMODE_LSB)
-#define TXPC_MISC_FLIPBMODE_SET(x)               (((x) << TXPC_MISC_FLIPBMODE_LSB) & TXPC_MISC_FLIPBMODE_MASK)
-#define TXPC_MISC_LEVEL_MSB                      30
-#define TXPC_MISC_LEVEL_LSB                      29
-#define TXPC_MISC_LEVEL_MASK                     0x60000000
-#define TXPC_MISC_LEVEL_GET(x)                   (((x) & TXPC_MISC_LEVEL_MASK) >> TXPC_MISC_LEVEL_LSB)
-#define TXPC_MISC_LEVEL_SET(x)                   (((x) << TXPC_MISC_LEVEL_LSB) & TXPC_MISC_LEVEL_MASK)
-#define TXPC_MISC_LDO_TEST_MODE_MSB              28
-#define TXPC_MISC_LDO_TEST_MODE_LSB              28
-#define TXPC_MISC_LDO_TEST_MODE_MASK             0x10000000
-#define TXPC_MISC_LDO_TEST_MODE_GET(x)           (((x) & TXPC_MISC_LDO_TEST_MODE_MASK) >> TXPC_MISC_LDO_TEST_MODE_LSB)
-#define TXPC_MISC_LDO_TEST_MODE_SET(x)           (((x) << TXPC_MISC_LDO_TEST_MODE_LSB) & TXPC_MISC_LDO_TEST_MODE_MASK)
-#define TXPC_MISC_NOTCXODET_MSB                  27
-#define TXPC_MISC_NOTCXODET_LSB                  27
-#define TXPC_MISC_NOTCXODET_MASK                 0x08000000
-#define TXPC_MISC_NOTCXODET_GET(x)               (((x) & TXPC_MISC_NOTCXODET_MASK) >> TXPC_MISC_NOTCXODET_LSB)
-#define TXPC_MISC_NOTCXODET_SET(x)               (((x) << TXPC_MISC_NOTCXODET_LSB) & TXPC_MISC_NOTCXODET_MASK)
-#define TXPC_MISC_PWDCLKIND_MSB                  26
-#define TXPC_MISC_PWDCLKIND_LSB                  26
-#define TXPC_MISC_PWDCLKIND_MASK                 0x04000000
-#define TXPC_MISC_PWDCLKIND_GET(x)               (((x) & TXPC_MISC_PWDCLKIND_MASK) >> TXPC_MISC_PWDCLKIND_LSB)
-#define TXPC_MISC_PWDCLKIND_SET(x)               (((x) << TXPC_MISC_PWDCLKIND_LSB) & TXPC_MISC_PWDCLKIND_MASK)
-#define TXPC_MISC_PWDXINPAD_MSB                  25
-#define TXPC_MISC_PWDXINPAD_LSB                  25
-#define TXPC_MISC_PWDXINPAD_MASK                 0x02000000
-#define TXPC_MISC_PWDXINPAD_GET(x)               (((x) & TXPC_MISC_PWDXINPAD_MASK) >> TXPC_MISC_PWDXINPAD_LSB)
-#define TXPC_MISC_PWDXINPAD_SET(x)               (((x) << TXPC_MISC_PWDXINPAD_LSB) & TXPC_MISC_PWDXINPAD_MASK)
-#define TXPC_MISC_LOCALBIAS_MSB                  24
-#define TXPC_MISC_LOCALBIAS_LSB                  24
-#define TXPC_MISC_LOCALBIAS_MASK                 0x01000000
-#define TXPC_MISC_LOCALBIAS_GET(x)               (((x) & TXPC_MISC_LOCALBIAS_MASK) >> TXPC_MISC_LOCALBIAS_LSB)
-#define TXPC_MISC_LOCALBIAS_SET(x)               (((x) << TXPC_MISC_LOCALBIAS_LSB) & TXPC_MISC_LOCALBIAS_MASK)
-#define TXPC_MISC_LOCALBIAS2X_MSB                23
-#define TXPC_MISC_LOCALBIAS2X_LSB                23
-#define TXPC_MISC_LOCALBIAS2X_MASK               0x00800000
-#define TXPC_MISC_LOCALBIAS2X_GET(x)             (((x) & TXPC_MISC_LOCALBIAS2X_MASK) >> TXPC_MISC_LOCALBIAS2X_LSB)
-#define TXPC_MISC_LOCALBIAS2X_SET(x)             (((x) << TXPC_MISC_LOCALBIAS2X_LSB) & TXPC_MISC_LOCALBIAS2X_MASK)
-#define TXPC_MISC_SELTSP_MSB                     22
-#define TXPC_MISC_SELTSP_LSB                     22
-#define TXPC_MISC_SELTSP_MASK                    0x00400000
-#define TXPC_MISC_SELTSP_GET(x)                  (((x) & TXPC_MISC_SELTSP_MASK) >> TXPC_MISC_SELTSP_LSB)
-#define TXPC_MISC_SELTSP_SET(x)                  (((x) << TXPC_MISC_SELTSP_LSB) & TXPC_MISC_SELTSP_MASK)
-#define TXPC_MISC_SELTSN_MSB                     21
-#define TXPC_MISC_SELTSN_LSB                     21
-#define TXPC_MISC_SELTSN_MASK                    0x00200000
-#define TXPC_MISC_SELTSN_GET(x)                  (((x) & TXPC_MISC_SELTSN_MASK) >> TXPC_MISC_SELTSN_LSB)
-#define TXPC_MISC_SELTSN_SET(x)                  (((x) << TXPC_MISC_SELTSN_LSB) & TXPC_MISC_SELTSN_MASK)
-#define TXPC_MISC_SPARE_A_MSB                    20
-#define TXPC_MISC_SPARE_A_LSB                    18
-#define TXPC_MISC_SPARE_A_MASK                   0x001c0000
-#define TXPC_MISC_SPARE_A_GET(x)                 (((x) & TXPC_MISC_SPARE_A_MASK) >> TXPC_MISC_SPARE_A_LSB)
-#define TXPC_MISC_SPARE_A_SET(x)                 (((x) << TXPC_MISC_SPARE_A_LSB) & TXPC_MISC_SPARE_A_MASK)
-#define TXPC_MISC_DECOUT_MSB                     17
-#define TXPC_MISC_DECOUT_LSB                     8
-#define TXPC_MISC_DECOUT_MASK                    0x0003ff00
-#define TXPC_MISC_DECOUT_GET(x)                  (((x) & TXPC_MISC_DECOUT_MASK) >> TXPC_MISC_DECOUT_LSB)
-#define TXPC_MISC_DECOUT_SET(x)                  (((x) << TXPC_MISC_DECOUT_LSB) & TXPC_MISC_DECOUT_MASK)
-#define TXPC_MISC_XTALDIV_MSB                    7
-#define TXPC_MISC_XTALDIV_LSB                    6
-#define TXPC_MISC_XTALDIV_MASK                   0x000000c0
-#define TXPC_MISC_XTALDIV_GET(x)                 (((x) & TXPC_MISC_XTALDIV_MASK) >> TXPC_MISC_XTALDIV_LSB)
-#define TXPC_MISC_XTALDIV_SET(x)                 (((x) << TXPC_MISC_XTALDIV_LSB) & TXPC_MISC_XTALDIV_MASK)
-#define TXPC_MISC_SPARE_MSB                      5
-#define TXPC_MISC_SPARE_LSB                      0
-#define TXPC_MISC_SPARE_MASK                     0x0000003f
-#define TXPC_MISC_SPARE_GET(x)                   (((x) & TXPC_MISC_SPARE_MASK) >> TXPC_MISC_SPARE_LSB)
-#define TXPC_MISC_SPARE_SET(x)                   (((x) << TXPC_MISC_SPARE_LSB) & TXPC_MISC_SPARE_MASK)
-
-#define RXTXBB_RXTXBB1_ADDRESS                   0x00000050
-#define RXTXBB_RXTXBB1_OFFSET                    0x00000050
-#define RXTXBB_RXTXBB1_SPARE_MSB                 31
-#define RXTXBB_RXTXBB1_SPARE_LSB                 19
-#define RXTXBB_RXTXBB1_SPARE_MASK                0xfff80000
-#define RXTXBB_RXTXBB1_SPARE_GET(x)              (((x) & RXTXBB_RXTXBB1_SPARE_MASK) >> RXTXBB_RXTXBB1_SPARE_LSB)
-#define RXTXBB_RXTXBB1_SPARE_SET(x)              (((x) << RXTXBB_RXTXBB1_SPARE_LSB) & RXTXBB_RXTXBB1_SPARE_MASK)
-#define RXTXBB_RXTXBB1_FNOTCH_MSB                18
-#define RXTXBB_RXTXBB1_FNOTCH_LSB                17
-#define RXTXBB_RXTXBB1_FNOTCH_MASK               0x00060000
-#define RXTXBB_RXTXBB1_FNOTCH_GET(x)             (((x) & RXTXBB_RXTXBB1_FNOTCH_MASK) >> RXTXBB_RXTXBB1_FNOTCH_LSB)
-#define RXTXBB_RXTXBB1_FNOTCH_SET(x)             (((x) << RXTXBB_RXTXBB1_FNOTCH_LSB) & RXTXBB_RXTXBB1_FNOTCH_MASK)
-#define RXTXBB_RXTXBB1_SEL_ATB_MSB               16
-#define RXTXBB_RXTXBB1_SEL_ATB_LSB               9
-#define RXTXBB_RXTXBB1_SEL_ATB_MASK              0x0001fe00
-#define RXTXBB_RXTXBB1_SEL_ATB_GET(x)            (((x) & RXTXBB_RXTXBB1_SEL_ATB_MASK) >> RXTXBB_RXTXBB1_SEL_ATB_LSB)
-#define RXTXBB_RXTXBB1_SEL_ATB_SET(x)            (((x) << RXTXBB_RXTXBB1_SEL_ATB_LSB) & RXTXBB_RXTXBB1_SEL_ATB_MASK)
-#define RXTXBB_RXTXBB1_PDDACINTERFACE_MSB        8
-#define RXTXBB_RXTXBB1_PDDACINTERFACE_LSB        8
-#define RXTXBB_RXTXBB1_PDDACINTERFACE_MASK       0x00000100
-#define RXTXBB_RXTXBB1_PDDACINTERFACE_GET(x)     (((x) & RXTXBB_RXTXBB1_PDDACINTERFACE_MASK) >> RXTXBB_RXTXBB1_PDDACINTERFACE_LSB)
-#define RXTXBB_RXTXBB1_PDDACINTERFACE_SET(x)     (((x) << RXTXBB_RXTXBB1_PDDACINTERFACE_LSB) & RXTXBB_RXTXBB1_PDDACINTERFACE_MASK)
-#define RXTXBB_RXTXBB1_PDV2I_MSB                 7
-#define RXTXBB_RXTXBB1_PDV2I_LSB                 7
-#define RXTXBB_RXTXBB1_PDV2I_MASK                0x00000080
-#define RXTXBB_RXTXBB1_PDV2I_GET(x)              (((x) & RXTXBB_RXTXBB1_PDV2I_MASK) >> RXTXBB_RXTXBB1_PDV2I_LSB)
-#define RXTXBB_RXTXBB1_PDV2I_SET(x)              (((x) << RXTXBB_RXTXBB1_PDV2I_LSB) & RXTXBB_RXTXBB1_PDV2I_MASK)
-#define RXTXBB_RXTXBB1_PDI2V_MSB                 6
-#define RXTXBB_RXTXBB1_PDI2V_LSB                 6
-#define RXTXBB_RXTXBB1_PDI2V_MASK                0x00000040
-#define RXTXBB_RXTXBB1_PDI2V_GET(x)              (((x) & RXTXBB_RXTXBB1_PDI2V_MASK) >> RXTXBB_RXTXBB1_PDI2V_LSB)
-#define RXTXBB_RXTXBB1_PDI2V_SET(x)              (((x) << RXTXBB_RXTXBB1_PDI2V_LSB) & RXTXBB_RXTXBB1_PDI2V_MASK)
-#define RXTXBB_RXTXBB1_PDRXTXBB_MSB              5
-#define RXTXBB_RXTXBB1_PDRXTXBB_LSB              5
-#define RXTXBB_RXTXBB1_PDRXTXBB_MASK             0x00000020
-#define RXTXBB_RXTXBB1_PDRXTXBB_GET(x)           (((x) & RXTXBB_RXTXBB1_PDRXTXBB_MASK) >> RXTXBB_RXTXBB1_PDRXTXBB_LSB)
-#define RXTXBB_RXTXBB1_PDRXTXBB_SET(x)           (((x) << RXTXBB_RXTXBB1_PDRXTXBB_LSB) & RXTXBB_RXTXBB1_PDRXTXBB_MASK)
-#define RXTXBB_RXTXBB1_PDOFFSETLOQ_MSB           4
-#define RXTXBB_RXTXBB1_PDOFFSETLOQ_LSB           4
-#define RXTXBB_RXTXBB1_PDOFFSETLOQ_MASK          0x00000010
-#define RXTXBB_RXTXBB1_PDOFFSETLOQ_GET(x)        (((x) & RXTXBB_RXTXBB1_PDOFFSETLOQ_MASK) >> RXTXBB_RXTXBB1_PDOFFSETLOQ_LSB)
-#define RXTXBB_RXTXBB1_PDOFFSETLOQ_SET(x)        (((x) << RXTXBB_RXTXBB1_PDOFFSETLOQ_LSB) & RXTXBB_RXTXBB1_PDOFFSETLOQ_MASK)
-#define RXTXBB_RXTXBB1_PDOFFSETHIQ_MSB           3
-#define RXTXBB_RXTXBB1_PDOFFSETHIQ_LSB           3
-#define RXTXBB_RXTXBB1_PDOFFSETHIQ_MASK          0x00000008
-#define RXTXBB_RXTXBB1_PDOFFSETHIQ_GET(x)        (((x) & RXTXBB_RXTXBB1_PDOFFSETHIQ_MASK) >> RXTXBB_RXTXBB1_PDOFFSETHIQ_LSB)
-#define RXTXBB_RXTXBB1_PDOFFSETHIQ_SET(x)        (((x) << RXTXBB_RXTXBB1_PDOFFSETHIQ_LSB) & RXTXBB_RXTXBB1_PDOFFSETHIQ_MASK)
-#define RXTXBB_RXTXBB1_PDOFFSETI2V_MSB           2
-#define RXTXBB_RXTXBB1_PDOFFSETI2V_LSB           2
-#define RXTXBB_RXTXBB1_PDOFFSETI2V_MASK          0x00000004
-#define RXTXBB_RXTXBB1_PDOFFSETI2V_GET(x)        (((x) & RXTXBB_RXTXBB1_PDOFFSETI2V_MASK) >> RXTXBB_RXTXBB1_PDOFFSETI2V_LSB)
-#define RXTXBB_RXTXBB1_PDOFFSETI2V_SET(x)        (((x) << RXTXBB_RXTXBB1_PDOFFSETI2V_LSB) & RXTXBB_RXTXBB1_PDOFFSETI2V_MASK)
-#define RXTXBB_RXTXBB1_PDLOQ_MSB                 1
-#define RXTXBB_RXTXBB1_PDLOQ_LSB                 1
-#define RXTXBB_RXTXBB1_PDLOQ_MASK                0x00000002
-#define RXTXBB_RXTXBB1_PDLOQ_GET(x)              (((x) & RXTXBB_RXTXBB1_PDLOQ_MASK) >> RXTXBB_RXTXBB1_PDLOQ_LSB)
-#define RXTXBB_RXTXBB1_PDLOQ_SET(x)              (((x) << RXTXBB_RXTXBB1_PDLOQ_LSB) & RXTXBB_RXTXBB1_PDLOQ_MASK)
-#define RXTXBB_RXTXBB1_PDHIQ_MSB                 0
-#define RXTXBB_RXTXBB1_PDHIQ_LSB                 0
-#define RXTXBB_RXTXBB1_PDHIQ_MASK                0x00000001
-#define RXTXBB_RXTXBB1_PDHIQ_GET(x)              (((x) & RXTXBB_RXTXBB1_PDHIQ_MASK) >> RXTXBB_RXTXBB1_PDHIQ_LSB)
-#define RXTXBB_RXTXBB1_PDHIQ_SET(x)              (((x) << RXTXBB_RXTXBB1_PDHIQ_LSB) & RXTXBB_RXTXBB1_PDHIQ_MASK)
-
-#define RXTXBB_RXTXBB2_ADDRESS                   0x00000054
-#define RXTXBB_RXTXBB2_OFFSET                    0x00000054
-#define RXTXBB_RXTXBB2_IBN_37P5_OSHI_CTRL_MSB    31
-#define RXTXBB_RXTXBB2_IBN_37P5_OSHI_CTRL_LSB    29
-#define RXTXBB_RXTXBB2_IBN_37P5_OSHI_CTRL_MASK   0xe0000000
-#define RXTXBB_RXTXBB2_IBN_37P5_OSHI_CTRL_GET(x) (((x) & RXTXBB_RXTXBB2_IBN_37P5_OSHI_CTRL_MASK) >> RXTXBB_RXTXBB2_IBN_37P5_OSHI_CTRL_LSB)
-#define RXTXBB_RXTXBB2_IBN_37P5_OSHI_CTRL_SET(x) (((x) << RXTXBB_RXTXBB2_IBN_37P5_OSHI_CTRL_LSB) & RXTXBB_RXTXBB2_IBN_37P5_OSHI_CTRL_MASK)
-#define RXTXBB_RXTXBB2_IBN_37P5_OSLO_CTRL_MSB    28
-#define RXTXBB_RXTXBB2_IBN_37P5_OSLO_CTRL_LSB    26
-#define RXTXBB_RXTXBB2_IBN_37P5_OSLO_CTRL_MASK   0x1c000000
-#define RXTXBB_RXTXBB2_IBN_37P5_OSLO_CTRL_GET(x) (((x) & RXTXBB_RXTXBB2_IBN_37P5_OSLO_CTRL_MASK) >> RXTXBB_RXTXBB2_IBN_37P5_OSLO_CTRL_LSB)
-#define RXTXBB_RXTXBB2_IBN_37P5_OSLO_CTRL_SET(x) (((x) << RXTXBB_RXTXBB2_IBN_37P5_OSLO_CTRL_LSB) & RXTXBB_RXTXBB2_IBN_37P5_OSLO_CTRL_MASK)
-#define RXTXBB_RXTXBB2_IBN_37P5_OSI2V_CTRL_MSB   25
-#define RXTXBB_RXTXBB2_IBN_37P5_OSI2V_CTRL_LSB   23
-#define RXTXBB_RXTXBB2_IBN_37P5_OSI2V_CTRL_MASK  0x03800000
-#define RXTXBB_RXTXBB2_IBN_37P5_OSI2V_CTRL_GET(x) (((x) & RXTXBB_RXTXBB2_IBN_37P5_OSI2V_CTRL_MASK) >> RXTXBB_RXTXBB2_IBN_37P5_OSI2V_CTRL_LSB)
-#define RXTXBB_RXTXBB2_IBN_37P5_OSI2V_CTRL_SET(x) (((x) << RXTXBB_RXTXBB2_IBN_37P5_OSI2V_CTRL_LSB) & RXTXBB_RXTXBB2_IBN_37P5_OSI2V_CTRL_MASK)
-#define RXTXBB_RXTXBB2_SPARE_MSB                 22
-#define RXTXBB_RXTXBB2_SPARE_LSB                 21
-#define RXTXBB_RXTXBB2_SPARE_MASK                0x00600000
-#define RXTXBB_RXTXBB2_SPARE_GET(x)              (((x) & RXTXBB_RXTXBB2_SPARE_MASK) >> RXTXBB_RXTXBB2_SPARE_LSB)
-#define RXTXBB_RXTXBB2_SPARE_SET(x)              (((x) << RXTXBB_RXTXBB2_SPARE_LSB) & RXTXBB_RXTXBB2_SPARE_MASK)
-#define RXTXBB_RXTXBB2_SHORTBUFFER_MSB           20
-#define RXTXBB_RXTXBB2_SHORTBUFFER_LSB           20
-#define RXTXBB_RXTXBB2_SHORTBUFFER_MASK          0x00100000
-#define RXTXBB_RXTXBB2_SHORTBUFFER_GET(x)        (((x) & RXTXBB_RXTXBB2_SHORTBUFFER_MASK) >> RXTXBB_RXTXBB2_SHORTBUFFER_LSB)
-#define RXTXBB_RXTXBB2_SHORTBUFFER_SET(x)        (((x) << RXTXBB_RXTXBB2_SHORTBUFFER_LSB) & RXTXBB_RXTXBB2_SHORTBUFFER_MASK)
-#define RXTXBB_RXTXBB2_SELBUFFER_MSB             19
-#define RXTXBB_RXTXBB2_SELBUFFER_LSB             19
-#define RXTXBB_RXTXBB2_SELBUFFER_MASK            0x00080000
-#define RXTXBB_RXTXBB2_SELBUFFER_GET(x)          (((x) & RXTXBB_RXTXBB2_SELBUFFER_MASK) >> RXTXBB_RXTXBB2_SELBUFFER_LSB)
-#define RXTXBB_RXTXBB2_SELBUFFER_SET(x)          (((x) << RXTXBB_RXTXBB2_SELBUFFER_LSB) & RXTXBB_RXTXBB2_SELBUFFER_MASK)
-#define RXTXBB_RXTXBB2_SEL_DAC_TEST_MSB          18
-#define RXTXBB_RXTXBB2_SEL_DAC_TEST_LSB          18
-#define RXTXBB_RXTXBB2_SEL_DAC_TEST_MASK         0x00040000
-#define RXTXBB_RXTXBB2_SEL_DAC_TEST_GET(x)       (((x) & RXTXBB_RXTXBB2_SEL_DAC_TEST_MASK) >> RXTXBB_RXTXBB2_SEL_DAC_TEST_LSB)
-#define RXTXBB_RXTXBB2_SEL_DAC_TEST_SET(x)       (((x) << RXTXBB_RXTXBB2_SEL_DAC_TEST_LSB) & RXTXBB_RXTXBB2_SEL_DAC_TEST_MASK)
-#define RXTXBB_RXTXBB2_SEL_LOQ_TEST_MSB          17
-#define RXTXBB_RXTXBB2_SEL_LOQ_TEST_LSB          17
-#define RXTXBB_RXTXBB2_SEL_LOQ_TEST_MASK         0x00020000
-#define RXTXBB_RXTXBB2_SEL_LOQ_TEST_GET(x)       (((x) & RXTXBB_RXTXBB2_SEL_LOQ_TEST_MASK) >> RXTXBB_RXTXBB2_SEL_LOQ_TEST_LSB)
-#define RXTXBB_RXTXBB2_SEL_LOQ_TEST_SET(x)       (((x) << RXTXBB_RXTXBB2_SEL_LOQ_TEST_LSB) & RXTXBB_RXTXBB2_SEL_LOQ_TEST_MASK)
-#define RXTXBB_RXTXBB2_SEL_HIQ_TEST_MSB          16
-#define RXTXBB_RXTXBB2_SEL_HIQ_TEST_LSB          16
-#define RXTXBB_RXTXBB2_SEL_HIQ_TEST_MASK         0x00010000
-#define RXTXBB_RXTXBB2_SEL_HIQ_TEST_GET(x)       (((x) & RXTXBB_RXTXBB2_SEL_HIQ_TEST_MASK) >> RXTXBB_RXTXBB2_SEL_HIQ_TEST_LSB)
-#define RXTXBB_RXTXBB2_SEL_HIQ_TEST_SET(x)       (((x) << RXTXBB_RXTXBB2_SEL_HIQ_TEST_LSB) & RXTXBB_RXTXBB2_SEL_HIQ_TEST_MASK)
-#define RXTXBB_RXTXBB2_SEL_I2V_TEST_MSB          15
-#define RXTXBB_RXTXBB2_SEL_I2V_TEST_LSB          15
-#define RXTXBB_RXTXBB2_SEL_I2V_TEST_MASK         0x00008000
-#define RXTXBB_RXTXBB2_SEL_I2V_TEST_GET(x)       (((x) & RXTXBB_RXTXBB2_SEL_I2V_TEST_MASK) >> RXTXBB_RXTXBB2_SEL_I2V_TEST_LSB)
-#define RXTXBB_RXTXBB2_SEL_I2V_TEST_SET(x)       (((x) << RXTXBB_RXTXBB2_SEL_I2V_TEST_LSB) & RXTXBB_RXTXBB2_SEL_I2V_TEST_MASK)
-#define RXTXBB_RXTXBB2_CMSEL_MSB                 14
-#define RXTXBB_RXTXBB2_CMSEL_LSB                 13
-#define RXTXBB_RXTXBB2_CMSEL_MASK                0x00006000
-#define RXTXBB_RXTXBB2_CMSEL_GET(x)              (((x) & RXTXBB_RXTXBB2_CMSEL_MASK) >> RXTXBB_RXTXBB2_CMSEL_LSB)
-#define RXTXBB_RXTXBB2_CMSEL_SET(x)              (((x) << RXTXBB_RXTXBB2_CMSEL_LSB) & RXTXBB_RXTXBB2_CMSEL_MASK)
-#define RXTXBB_RXTXBB2_FILTERFC_MSB              12
-#define RXTXBB_RXTXBB2_FILTERFC_LSB              8
-#define RXTXBB_RXTXBB2_FILTERFC_MASK             0x00001f00
-#define RXTXBB_RXTXBB2_FILTERFC_GET(x)           (((x) & RXTXBB_RXTXBB2_FILTERFC_MASK) >> RXTXBB_RXTXBB2_FILTERFC_LSB)
-#define RXTXBB_RXTXBB2_FILTERFC_SET(x)           (((x) << RXTXBB_RXTXBB2_FILTERFC_LSB) & RXTXBB_RXTXBB2_FILTERFC_MASK)
-#define RXTXBB_RXTXBB2_LOCALFILTERTUNING_MSB     7
-#define RXTXBB_RXTXBB2_LOCALFILTERTUNING_LSB     7
-#define RXTXBB_RXTXBB2_LOCALFILTERTUNING_MASK    0x00000080
-#define RXTXBB_RXTXBB2_LOCALFILTERTUNING_GET(x)  (((x) & RXTXBB_RXTXBB2_LOCALFILTERTUNING_MASK) >> RXTXBB_RXTXBB2_LOCALFILTERTUNING_LSB)
-#define RXTXBB_RXTXBB2_LOCALFILTERTUNING_SET(x)  (((x) << RXTXBB_RXTXBB2_LOCALFILTERTUNING_LSB) & RXTXBB_RXTXBB2_LOCALFILTERTUNING_MASK)
-#define RXTXBB_RXTXBB2_FILTERDOUBLEBW_MSB        6
-#define RXTXBB_RXTXBB2_FILTERDOUBLEBW_LSB        6
-#define RXTXBB_RXTXBB2_FILTERDOUBLEBW_MASK       0x00000040
-#define RXTXBB_RXTXBB2_FILTERDOUBLEBW_GET(x)     (((x) & RXTXBB_RXTXBB2_FILTERDOUBLEBW_MASK) >> RXTXBB_RXTXBB2_FILTERDOUBLEBW_LSB)
-#define RXTXBB_RXTXBB2_FILTERDOUBLEBW_SET(x)     (((x) << RXTXBB_RXTXBB2_FILTERDOUBLEBW_LSB) & RXTXBB_RXTXBB2_FILTERDOUBLEBW_MASK)
-#define RXTXBB_RXTXBB2_PATH2HIQ_EN_MSB           5
-#define RXTXBB_RXTXBB2_PATH2HIQ_EN_LSB           5
-#define RXTXBB_RXTXBB2_PATH2HIQ_EN_MASK          0x00000020
-#define RXTXBB_RXTXBB2_PATH2HIQ_EN_GET(x)        (((x) & RXTXBB_RXTXBB2_PATH2HIQ_EN_MASK) >> RXTXBB_RXTXBB2_PATH2HIQ_EN_LSB)
-#define RXTXBB_RXTXBB2_PATH2HIQ_EN_SET(x)        (((x) << RXTXBB_RXTXBB2_PATH2HIQ_EN_LSB) & RXTXBB_RXTXBB2_PATH2HIQ_EN_MASK)
-#define RXTXBB_RXTXBB2_PATH1HIQ_EN_MSB           4
-#define RXTXBB_RXTXBB2_PATH1HIQ_EN_LSB           4
-#define RXTXBB_RXTXBB2_PATH1HIQ_EN_MASK          0x00000010
-#define RXTXBB_RXTXBB2_PATH1HIQ_EN_GET(x)        (((x) & RXTXBB_RXTXBB2_PATH1HIQ_EN_MASK) >> RXTXBB_RXTXBB2_PATH1HIQ_EN_LSB)
-#define RXTXBB_RXTXBB2_PATH1HIQ_EN_SET(x)        (((x) << RXTXBB_RXTXBB2_PATH1HIQ_EN_LSB) & RXTXBB_RXTXBB2_PATH1HIQ_EN_MASK)
-#define RXTXBB_RXTXBB2_PATH3LOQ_EN_MSB           3
-#define RXTXBB_RXTXBB2_PATH3LOQ_EN_LSB           3
-#define RXTXBB_RXTXBB2_PATH3LOQ_EN_MASK          0x00000008
-#define RXTXBB_RXTXBB2_PATH3LOQ_EN_GET(x)        (((x) & RXTXBB_RXTXBB2_PATH3LOQ_EN_MASK) >> RXTXBB_RXTXBB2_PATH3LOQ_EN_LSB)
-#define RXTXBB_RXTXBB2_PATH3LOQ_EN_SET(x)        (((x) << RXTXBB_RXTXBB2_PATH3LOQ_EN_LSB) & RXTXBB_RXTXBB2_PATH3LOQ_EN_MASK)
-#define RXTXBB_RXTXBB2_PATH2LOQ_EN_MSB           2
-#define RXTXBB_RXTXBB2_PATH2LOQ_EN_LSB           2
-#define RXTXBB_RXTXBB2_PATH2LOQ_EN_MASK          0x00000004
-#define RXTXBB_RXTXBB2_PATH2LOQ_EN_GET(x)        (((x) & RXTXBB_RXTXBB2_PATH2LOQ_EN_MASK) >> RXTXBB_RXTXBB2_PATH2LOQ_EN_LSB)
-#define RXTXBB_RXTXBB2_PATH2LOQ_EN_SET(x)        (((x) << RXTXBB_RXTXBB2_PATH2LOQ_EN_LSB) & RXTXBB_RXTXBB2_PATH2LOQ_EN_MASK)
-#define RXTXBB_RXTXBB2_PATH1LOQ_EN_MSB           1
-#define RXTXBB_RXTXBB2_PATH1LOQ_EN_LSB           1
-#define RXTXBB_RXTXBB2_PATH1LOQ_EN_MASK          0x00000002
-#define RXTXBB_RXTXBB2_PATH1LOQ_EN_GET(x)        (((x) & RXTXBB_RXTXBB2_PATH1LOQ_EN_MASK) >> RXTXBB_RXTXBB2_PATH1LOQ_EN_LSB)
-#define RXTXBB_RXTXBB2_PATH1LOQ_EN_SET(x)        (((x) << RXTXBB_RXTXBB2_PATH1LOQ_EN_LSB) & RXTXBB_RXTXBB2_PATH1LOQ_EN_MASK)
-#define RXTXBB_RXTXBB2_PATH_OVERRIDE_MSB         0
-#define RXTXBB_RXTXBB2_PATH_OVERRIDE_LSB         0
-#define RXTXBB_RXTXBB2_PATH_OVERRIDE_MASK        0x00000001
-#define RXTXBB_RXTXBB2_PATH_OVERRIDE_GET(x)      (((x) & RXTXBB_RXTXBB2_PATH_OVERRIDE_MASK) >> RXTXBB_RXTXBB2_PATH_OVERRIDE_LSB)
-#define RXTXBB_RXTXBB2_PATH_OVERRIDE_SET(x)      (((x) << RXTXBB_RXTXBB2_PATH_OVERRIDE_LSB) & RXTXBB_RXTXBB2_PATH_OVERRIDE_MASK)
-
-#define RXTXBB_RXTXBB3_ADDRESS                   0x00000058
-#define RXTXBB_RXTXBB3_OFFSET                    0x00000058
-#define RXTXBB_RXTXBB3_SPARE_MSB                 31
-#define RXTXBB_RXTXBB3_SPARE_LSB                 27
-#define RXTXBB_RXTXBB3_SPARE_MASK                0xf8000000
-#define RXTXBB_RXTXBB3_SPARE_GET(x)              (((x) & RXTXBB_RXTXBB3_SPARE_MASK) >> RXTXBB_RXTXBB3_SPARE_LSB)
-#define RXTXBB_RXTXBB3_SPARE_SET(x)              (((x) << RXTXBB_RXTXBB3_SPARE_LSB) & RXTXBB_RXTXBB3_SPARE_MASK)
-#define RXTXBB_RXTXBB3_IBN_25U_CM_BUFAMP_CTRL_MSB 26
-#define RXTXBB_RXTXBB3_IBN_25U_CM_BUFAMP_CTRL_LSB 24
-#define RXTXBB_RXTXBB3_IBN_25U_CM_BUFAMP_CTRL_MASK 0x07000000
-#define RXTXBB_RXTXBB3_IBN_25U_CM_BUFAMP_CTRL_GET(x) (((x) & RXTXBB_RXTXBB3_IBN_25U_CM_BUFAMP_CTRL_MASK) >> RXTXBB_RXTXBB3_IBN_25U_CM_BUFAMP_CTRL_LSB)
-#define RXTXBB_RXTXBB3_IBN_25U_CM_BUFAMP_CTRL_SET(x) (((x) << RXTXBB_RXTXBB3_IBN_25U_CM_BUFAMP_CTRL_LSB) & RXTXBB_RXTXBB3_IBN_25U_CM_BUFAMP_CTRL_MASK)
-#define RXTXBB_RXTXBB3_IBN_25U_BKV2I_CTRL_MSB    23
-#define RXTXBB_RXTXBB3_IBN_25U_BKV2I_CTRL_LSB    21
-#define RXTXBB_RXTXBB3_IBN_25U_BKV2I_CTRL_MASK   0x00e00000
-#define RXTXBB_RXTXBB3_IBN_25U_BKV2I_CTRL_GET(x) (((x) & RXTXBB_RXTXBB3_IBN_25U_BKV2I_CTRL_MASK) >> RXTXBB_RXTXBB3_IBN_25U_BKV2I_CTRL_LSB)
-#define RXTXBB_RXTXBB3_IBN_25U_BKV2I_CTRL_SET(x) (((x) << RXTXBB_RXTXBB3_IBN_25U_BKV2I_CTRL_LSB) & RXTXBB_RXTXBB3_IBN_25U_BKV2I_CTRL_MASK)
-#define RXTXBB_RXTXBB3_IBN_25U_I2V_CTRL_MSB      20
-#define RXTXBB_RXTXBB3_IBN_25U_I2V_CTRL_LSB      18
-#define RXTXBB_RXTXBB3_IBN_25U_I2V_CTRL_MASK     0x001c0000
-#define RXTXBB_RXTXBB3_IBN_25U_I2V_CTRL_GET(x)   (((x) & RXTXBB_RXTXBB3_IBN_25U_I2V_CTRL_MASK) >> RXTXBB_RXTXBB3_IBN_25U_I2V_CTRL_LSB)
-#define RXTXBB_RXTXBB3_IBN_25U_I2V_CTRL_SET(x)   (((x) << RXTXBB_RXTXBB3_IBN_25U_I2V_CTRL_LSB) & RXTXBB_RXTXBB3_IBN_25U_I2V_CTRL_MASK)
-#define RXTXBB_RXTXBB3_IBN_25U_HI1_CTRL_MSB      17
-#define RXTXBB_RXTXBB3_IBN_25U_HI1_CTRL_LSB      15
-#define RXTXBB_RXTXBB3_IBN_25U_HI1_CTRL_MASK     0x00038000
-#define RXTXBB_RXTXBB3_IBN_25U_HI1_CTRL_GET(x)   (((x) & RXTXBB_RXTXBB3_IBN_25U_HI1_CTRL_MASK) >> RXTXBB_RXTXBB3_IBN_25U_HI1_CTRL_LSB)
-#define RXTXBB_RXTXBB3_IBN_25U_HI1_CTRL_SET(x)   (((x) << RXTXBB_RXTXBB3_IBN_25U_HI1_CTRL_LSB) & RXTXBB_RXTXBB3_IBN_25U_HI1_CTRL_MASK)
-#define RXTXBB_RXTXBB3_IBN_25U_HI2_CTRL_MSB      14
-#define RXTXBB_RXTXBB3_IBN_25U_HI2_CTRL_LSB      12
-#define RXTXBB_RXTXBB3_IBN_25U_HI2_CTRL_MASK     0x00007000
-#define RXTXBB_RXTXBB3_IBN_25U_HI2_CTRL_GET(x)   (((x) & RXTXBB_RXTXBB3_IBN_25U_HI2_CTRL_MASK) >> RXTXBB_RXTXBB3_IBN_25U_HI2_CTRL_LSB)
-#define RXTXBB_RXTXBB3_IBN_25U_HI2_CTRL_SET(x)   (((x) << RXTXBB_RXTXBB3_IBN_25U_HI2_CTRL_LSB) & RXTXBB_RXTXBB3_IBN_25U_HI2_CTRL_MASK)
-#define RXTXBB_RXTXBB3_IBN_25U_LO1_CTRL_MSB      11
-#define RXTXBB_RXTXBB3_IBN_25U_LO1_CTRL_LSB      9
-#define RXTXBB_RXTXBB3_IBN_25U_LO1_CTRL_MASK     0x00000e00
-#define RXTXBB_RXTXBB3_IBN_25U_LO1_CTRL_GET(x)   (((x) & RXTXBB_RXTXBB3_IBN_25U_LO1_CTRL_MASK) >> RXTXBB_RXTXBB3_IBN_25U_LO1_CTRL_LSB)
-#define RXTXBB_RXTXBB3_IBN_25U_LO1_CTRL_SET(x)   (((x) << RXTXBB_RXTXBB3_IBN_25U_LO1_CTRL_LSB) & RXTXBB_RXTXBB3_IBN_25U_LO1_CTRL_MASK)
-#define RXTXBB_RXTXBB3_IBN_25U_LO2_CTRL_MSB      8
-#define RXTXBB_RXTXBB3_IBN_25U_LO2_CTRL_LSB      6
-#define RXTXBB_RXTXBB3_IBN_25U_LO2_CTRL_MASK     0x000001c0
-#define RXTXBB_RXTXBB3_IBN_25U_LO2_CTRL_GET(x)   (((x) & RXTXBB_RXTXBB3_IBN_25U_LO2_CTRL_MASK) >> RXTXBB_RXTXBB3_IBN_25U_LO2_CTRL_LSB)
-#define RXTXBB_RXTXBB3_IBN_25U_LO2_CTRL_SET(x)   (((x) << RXTXBB_RXTXBB3_IBN_25U_LO2_CTRL_LSB) & RXTXBB_RXTXBB3_IBN_25U_LO2_CTRL_MASK)
-#define RXTXBB_RXTXBB3_IBRN_12P5_CM_CTRL_MSB     5
-#define RXTXBB_RXTXBB3_IBRN_12P5_CM_CTRL_LSB     3
-#define RXTXBB_RXTXBB3_IBRN_12P5_CM_CTRL_MASK    0x00000038
-#define RXTXBB_RXTXBB3_IBRN_12P5_CM_CTRL_GET(x)  (((x) & RXTXBB_RXTXBB3_IBRN_12P5_CM_CTRL_MASK) >> RXTXBB_RXTXBB3_IBRN_12P5_CM_CTRL_LSB)
-#define RXTXBB_RXTXBB3_IBRN_12P5_CM_CTRL_SET(x)  (((x) << RXTXBB_RXTXBB3_IBRN_12P5_CM_CTRL_LSB) & RXTXBB_RXTXBB3_IBRN_12P5_CM_CTRL_MASK)
-#define RXTXBB_RXTXBB3_IBN_100U_TEST_CTRL_MSB    2
-#define RXTXBB_RXTXBB3_IBN_100U_TEST_CTRL_LSB    0
-#define RXTXBB_RXTXBB3_IBN_100U_TEST_CTRL_MASK   0x00000007
-#define RXTXBB_RXTXBB3_IBN_100U_TEST_CTRL_GET(x) (((x) & RXTXBB_RXTXBB3_IBN_100U_TEST_CTRL_MASK) >> RXTXBB_RXTXBB3_IBN_100U_TEST_CTRL_LSB)
-#define RXTXBB_RXTXBB3_IBN_100U_TEST_CTRL_SET(x) (((x) << RXTXBB_RXTXBB3_IBN_100U_TEST_CTRL_LSB) & RXTXBB_RXTXBB3_IBN_100U_TEST_CTRL_MASK)
-
-#define RXTXBB_RXTXBB4_ADDRESS                   0x0000005c
-#define RXTXBB_RXTXBB4_OFFSET                    0x0000005c
-#define RXTXBB_RXTXBB4_SPARE_MSB                 31
-#define RXTXBB_RXTXBB4_SPARE_LSB                 31
-#define RXTXBB_RXTXBB4_SPARE_MASK                0x80000000
-#define RXTXBB_RXTXBB4_SPARE_GET(x)              (((x) & RXTXBB_RXTXBB4_SPARE_MASK) >> RXTXBB_RXTXBB4_SPARE_LSB)
-#define RXTXBB_RXTXBB4_SPARE_SET(x)              (((x) << RXTXBB_RXTXBB4_SPARE_LSB) & RXTXBB_RXTXBB4_SPARE_MASK)
-#define RXTXBB_RXTXBB4_LOCALOFFSET_MSB           30
-#define RXTXBB_RXTXBB4_LOCALOFFSET_LSB           30
-#define RXTXBB_RXTXBB4_LOCALOFFSET_MASK          0x40000000
-#define RXTXBB_RXTXBB4_LOCALOFFSET_GET(x)        (((x) & RXTXBB_RXTXBB4_LOCALOFFSET_MASK) >> RXTXBB_RXTXBB4_LOCALOFFSET_LSB)
-#define RXTXBB_RXTXBB4_LOCALOFFSET_SET(x)        (((x) << RXTXBB_RXTXBB4_LOCALOFFSET_LSB) & RXTXBB_RXTXBB4_LOCALOFFSET_MASK)
-#define RXTXBB_RXTXBB4_OFSTCORRHII_MSB           29
-#define RXTXBB_RXTXBB4_OFSTCORRHII_LSB           25
-#define RXTXBB_RXTXBB4_OFSTCORRHII_MASK          0x3e000000
-#define RXTXBB_RXTXBB4_OFSTCORRHII_GET(x)        (((x) & RXTXBB_RXTXBB4_OFSTCORRHII_MASK) >> RXTXBB_RXTXBB4_OFSTCORRHII_LSB)
-#define RXTXBB_RXTXBB4_OFSTCORRHII_SET(x)        (((x) << RXTXBB_RXTXBB4_OFSTCORRHII_LSB) & RXTXBB_RXTXBB4_OFSTCORRHII_MASK)
-#define RXTXBB_RXTXBB4_OFSTCORRHIQ_MSB           24
-#define RXTXBB_RXTXBB4_OFSTCORRHIQ_LSB           20
-#define RXTXBB_RXTXBB4_OFSTCORRHIQ_MASK          0x01f00000
-#define RXTXBB_RXTXBB4_OFSTCORRHIQ_GET(x)        (((x) & RXTXBB_RXTXBB4_OFSTCORRHIQ_MASK) >> RXTXBB_RXTXBB4_OFSTCORRHIQ_LSB)
-#define RXTXBB_RXTXBB4_OFSTCORRHIQ_SET(x)        (((x) << RXTXBB_RXTXBB4_OFSTCORRHIQ_LSB) & RXTXBB_RXTXBB4_OFSTCORRHIQ_MASK)
-#define RXTXBB_RXTXBB4_OFSTCORRLOI_MSB           19
-#define RXTXBB_RXTXBB4_OFSTCORRLOI_LSB           15
-#define RXTXBB_RXTXBB4_OFSTCORRLOI_MASK          0x000f8000
-#define RXTXBB_RXTXBB4_OFSTCORRLOI_GET(x)        (((x) & RXTXBB_RXTXBB4_OFSTCORRLOI_MASK) >> RXTXBB_RXTXBB4_OFSTCORRLOI_LSB)
-#define RXTXBB_RXTXBB4_OFSTCORRLOI_SET(x)        (((x) << RXTXBB_RXTXBB4_OFSTCORRLOI_LSB) & RXTXBB_RXTXBB4_OFSTCORRLOI_MASK)
-#define RXTXBB_RXTXBB4_OFSTCORRLOQ_MSB           14
-#define RXTXBB_RXTXBB4_OFSTCORRLOQ_LSB           10
-#define RXTXBB_RXTXBB4_OFSTCORRLOQ_MASK          0x00007c00
-#define RXTXBB_RXTXBB4_OFSTCORRLOQ_GET(x)        (((x) & RXTXBB_RXTXBB4_OFSTCORRLOQ_MASK) >> RXTXBB_RXTXBB4_OFSTCORRLOQ_LSB)
-#define RXTXBB_RXTXBB4_OFSTCORRLOQ_SET(x)        (((x) << RXTXBB_RXTXBB4_OFSTCORRLOQ_LSB) & RXTXBB_RXTXBB4_OFSTCORRLOQ_MASK)
-#define RXTXBB_RXTXBB4_OFSTCORRI2VI_MSB          9
-#define RXTXBB_RXTXBB4_OFSTCORRI2VI_LSB          5
-#define RXTXBB_RXTXBB4_OFSTCORRI2VI_MASK         0x000003e0
-#define RXTXBB_RXTXBB4_OFSTCORRI2VI_GET(x)       (((x) & RXTXBB_RXTXBB4_OFSTCORRI2VI_MASK) >> RXTXBB_RXTXBB4_OFSTCORRI2VI_LSB)
-#define RXTXBB_RXTXBB4_OFSTCORRI2VI_SET(x)       (((x) << RXTXBB_RXTXBB4_OFSTCORRI2VI_LSB) & RXTXBB_RXTXBB4_OFSTCORRI2VI_MASK)
-#define RXTXBB_RXTXBB4_OFSTCORRI2VQ_MSB          4
-#define RXTXBB_RXTXBB4_OFSTCORRI2VQ_LSB          0
-#define RXTXBB_RXTXBB4_OFSTCORRI2VQ_MASK         0x0000001f
-#define RXTXBB_RXTXBB4_OFSTCORRI2VQ_GET(x)       (((x) & RXTXBB_RXTXBB4_OFSTCORRI2VQ_MASK) >> RXTXBB_RXTXBB4_OFSTCORRI2VQ_LSB)
-#define RXTXBB_RXTXBB4_OFSTCORRI2VQ_SET(x)       (((x) << RXTXBB_RXTXBB4_OFSTCORRI2VQ_LSB) & RXTXBB_RXTXBB4_OFSTCORRI2VQ_MASK)
-
-#define ADDAC_ADDAC1_ADDRESS                     0x00000060
-#define ADDAC_ADDAC1_OFFSET                      0x00000060
-#define ADDAC_ADDAC1_PLL_SVREG_MSB               31
-#define ADDAC_ADDAC1_PLL_SVREG_LSB               31
-#define ADDAC_ADDAC1_PLL_SVREG_MASK              0x80000000
-#define ADDAC_ADDAC1_PLL_SVREG_GET(x)            (((x) & ADDAC_ADDAC1_PLL_SVREG_MASK) >> ADDAC_ADDAC1_PLL_SVREG_LSB)
-#define ADDAC_ADDAC1_PLL_SVREG_SET(x)            (((x) << ADDAC_ADDAC1_PLL_SVREG_LSB) & ADDAC_ADDAC1_PLL_SVREG_MASK)
-#define ADDAC_ADDAC1_PLL_SCLAMP_MSB              30
-#define ADDAC_ADDAC1_PLL_SCLAMP_LSB              28
-#define ADDAC_ADDAC1_PLL_SCLAMP_MASK             0x70000000
-#define ADDAC_ADDAC1_PLL_SCLAMP_GET(x)           (((x) & ADDAC_ADDAC1_PLL_SCLAMP_MASK) >> ADDAC_ADDAC1_PLL_SCLAMP_LSB)
-#define ADDAC_ADDAC1_PLL_SCLAMP_SET(x)           (((x) << ADDAC_ADDAC1_PLL_SCLAMP_LSB) & ADDAC_ADDAC1_PLL_SCLAMP_MASK)
-#define ADDAC_ADDAC1_PLL_ATB_MSB                 27
-#define ADDAC_ADDAC1_PLL_ATB_LSB                 26
-#define ADDAC_ADDAC1_PLL_ATB_MASK                0x0c000000
-#define ADDAC_ADDAC1_PLL_ATB_GET(x)              (((x) & ADDAC_ADDAC1_PLL_ATB_MASK) >> ADDAC_ADDAC1_PLL_ATB_LSB)
-#define ADDAC_ADDAC1_PLL_ATB_SET(x)              (((x) << ADDAC_ADDAC1_PLL_ATB_LSB) & ADDAC_ADDAC1_PLL_ATB_MASK)
-#define ADDAC_ADDAC1_PLL_ICP_MSB                 25
-#define ADDAC_ADDAC1_PLL_ICP_LSB                 23
-#define ADDAC_ADDAC1_PLL_ICP_MASK                0x03800000
-#define ADDAC_ADDAC1_PLL_ICP_GET(x)              (((x) & ADDAC_ADDAC1_PLL_ICP_MASK) >> ADDAC_ADDAC1_PLL_ICP_LSB)
-#define ADDAC_ADDAC1_PLL_ICP_SET(x)              (((x) << ADDAC_ADDAC1_PLL_ICP_LSB) & ADDAC_ADDAC1_PLL_ICP_MASK)
-#define ADDAC_ADDAC1_PLL_FILTER_MSB              22
-#define ADDAC_ADDAC1_PLL_FILTER_LSB              15
-#define ADDAC_ADDAC1_PLL_FILTER_MASK             0x007f8000
-#define ADDAC_ADDAC1_PLL_FILTER_GET(x)           (((x) & ADDAC_ADDAC1_PLL_FILTER_MASK) >> ADDAC_ADDAC1_PLL_FILTER_LSB)
-#define ADDAC_ADDAC1_PLL_FILTER_SET(x)           (((x) << ADDAC_ADDAC1_PLL_FILTER_LSB) & ADDAC_ADDAC1_PLL_FILTER_MASK)
-#define ADDAC_ADDAC1_PWDPLL_MSB                  14
-#define ADDAC_ADDAC1_PWDPLL_LSB                  14
-#define ADDAC_ADDAC1_PWDPLL_MASK                 0x00004000
-#define ADDAC_ADDAC1_PWDPLL_GET(x)               (((x) & ADDAC_ADDAC1_PWDPLL_MASK) >> ADDAC_ADDAC1_PWDPLL_LSB)
-#define ADDAC_ADDAC1_PWDPLL_SET(x)               (((x) << ADDAC_ADDAC1_PWDPLL_LSB) & ADDAC_ADDAC1_PWDPLL_MASK)
-#define ADDAC_ADDAC1_PWDADC_MSB                  13
-#define ADDAC_ADDAC1_PWDADC_LSB                  13
-#define ADDAC_ADDAC1_PWDADC_MASK                 0x00002000
-#define ADDAC_ADDAC1_PWDADC_GET(x)               (((x) & ADDAC_ADDAC1_PWDADC_MASK) >> ADDAC_ADDAC1_PWDADC_LSB)
-#define ADDAC_ADDAC1_PWDADC_SET(x)               (((x) << ADDAC_ADDAC1_PWDADC_LSB) & ADDAC_ADDAC1_PWDADC_MASK)
-#define ADDAC_ADDAC1_PWDDAC_MSB                  12
-#define ADDAC_ADDAC1_PWDDAC_LSB                  12
-#define ADDAC_ADDAC1_PWDDAC_MASK                 0x00001000
-#define ADDAC_ADDAC1_PWDDAC_GET(x)               (((x) & ADDAC_ADDAC1_PWDDAC_MASK) >> ADDAC_ADDAC1_PWDDAC_LSB)
-#define ADDAC_ADDAC1_PWDDAC_SET(x)               (((x) << ADDAC_ADDAC1_PWDDAC_LSB) & ADDAC_ADDAC1_PWDDAC_MASK)
-#define ADDAC_ADDAC1_FORCEMSBLOW_MSB             11
-#define ADDAC_ADDAC1_FORCEMSBLOW_LSB             11
-#define ADDAC_ADDAC1_FORCEMSBLOW_MASK            0x00000800
-#define ADDAC_ADDAC1_FORCEMSBLOW_GET(x)          (((x) & ADDAC_ADDAC1_FORCEMSBLOW_MASK) >> ADDAC_ADDAC1_FORCEMSBLOW_LSB)
-#define ADDAC_ADDAC1_FORCEMSBLOW_SET(x)          (((x) << ADDAC_ADDAC1_FORCEMSBLOW_LSB) & ADDAC_ADDAC1_FORCEMSBLOW_MASK)
-#define ADDAC_ADDAC1_SELMANPWDS_MSB              10
-#define ADDAC_ADDAC1_SELMANPWDS_LSB              10
-#define ADDAC_ADDAC1_SELMANPWDS_MASK             0x00000400
-#define ADDAC_ADDAC1_SELMANPWDS_GET(x)           (((x) & ADDAC_ADDAC1_SELMANPWDS_MASK) >> ADDAC_ADDAC1_SELMANPWDS_LSB)
-#define ADDAC_ADDAC1_SELMANPWDS_SET(x)           (((x) << ADDAC_ADDAC1_SELMANPWDS_LSB) & ADDAC_ADDAC1_SELMANPWDS_MASK)
-#define ADDAC_ADDAC1_INV_CLK160_ADC_MSB          9
-#define ADDAC_ADDAC1_INV_CLK160_ADC_LSB          9
-#define ADDAC_ADDAC1_INV_CLK160_ADC_MASK         0x00000200
-#define ADDAC_ADDAC1_INV_CLK160_ADC_GET(x)       (((x) & ADDAC_ADDAC1_INV_CLK160_ADC_MASK) >> ADDAC_ADDAC1_INV_CLK160_ADC_LSB)
-#define ADDAC_ADDAC1_INV_CLK160_ADC_SET(x)       (((x) << ADDAC_ADDAC1_INV_CLK160_ADC_LSB) & ADDAC_ADDAC1_INV_CLK160_ADC_MASK)
-#define ADDAC_ADDAC1_CM_SEL_MSB                  8
-#define ADDAC_ADDAC1_CM_SEL_LSB                  7
-#define ADDAC_ADDAC1_CM_SEL_MASK                 0x00000180
-#define ADDAC_ADDAC1_CM_SEL_GET(x)               (((x) & ADDAC_ADDAC1_CM_SEL_MASK) >> ADDAC_ADDAC1_CM_SEL_LSB)
-#define ADDAC_ADDAC1_CM_SEL_SET(x)               (((x) << ADDAC_ADDAC1_CM_SEL_LSB) & ADDAC_ADDAC1_CM_SEL_MASK)
-#define ADDAC_ADDAC1_DISABLE_DAC_REG_MSB         6
-#define ADDAC_ADDAC1_DISABLE_DAC_REG_LSB         6
-#define ADDAC_ADDAC1_DISABLE_DAC_REG_MASK        0x00000040
-#define ADDAC_ADDAC1_DISABLE_DAC_REG_GET(x)      (((x) & ADDAC_ADDAC1_DISABLE_DAC_REG_MASK) >> ADDAC_ADDAC1_DISABLE_DAC_REG_LSB)
-#define ADDAC_ADDAC1_DISABLE_DAC_REG_SET(x)      (((x) << ADDAC_ADDAC1_DISABLE_DAC_REG_LSB) & ADDAC_ADDAC1_DISABLE_DAC_REG_MASK)
-#define ADDAC_ADDAC1_SPARE_MSB                   5
-#define ADDAC_ADDAC1_SPARE_LSB                   0
-#define ADDAC_ADDAC1_SPARE_MASK                  0x0000003f
-#define ADDAC_ADDAC1_SPARE_GET(x)                (((x) & ADDAC_ADDAC1_SPARE_MASK) >> ADDAC_ADDAC1_SPARE_LSB)
-#define ADDAC_ADDAC1_SPARE_SET(x)                (((x) << ADDAC_ADDAC1_SPARE_LSB) & ADDAC_ADDAC1_SPARE_MASK)
-
-
-#ifndef __ASSEMBLER__
-
-typedef struct analog_reg_reg_s {
-  volatile unsigned int synth_synth1;
-  volatile unsigned int synth_synth2;
-  volatile unsigned int synth_synth3;
-  volatile unsigned int synth_synth4;
-  volatile unsigned int synth_synth5;
-  volatile unsigned int synth_synth6;
-  volatile unsigned int synth_synth7;
-  volatile unsigned int synth_synth8;
-  volatile unsigned int rf5g_rf5g1;
-  volatile unsigned int rf5g_rf5g2;
-  volatile unsigned int rf2g_rf2g1;
-  volatile unsigned int rf2g_rf2g2;
-  volatile unsigned int top_gain;
-  volatile unsigned int top_top;
-  volatile unsigned int bias_bias_sel;
-  volatile unsigned int bias_bias1;
-  volatile unsigned int bias_bias2;
-  volatile unsigned int bias_bias3;
-  volatile unsigned int txpc_txpc;
-  volatile unsigned int txpc_misc;
-  volatile unsigned int rxtxbb_rxtxbb1;
-  volatile unsigned int rxtxbb_rxtxbb2;
-  volatile unsigned int rxtxbb_rxtxbb3;
-  volatile unsigned int rxtxbb_rxtxbb4;
-  volatile unsigned int addac_addac1;
-} analog_reg_reg_t;
-
-#endif /* __ASSEMBLER__ */
-
-#endif /* _ANALOG_REG_H_ */
diff --git a/drivers/staging/ath6kl/include/common/AR6002/hw2.0/hw/apb_map.h b/drivers/staging/ath6kl/include/common/AR6002/hw2.0/hw/apb_map.h
deleted file mode 100644 (file)
index f3bf6d6..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-#ifndef _APB_MAP_H_
-#define _APB_MAP_H_
-
-#define RTC_BASE_ADDRESS                         0x00004000
-#define VMC_BASE_ADDRESS                         0x00008000
-#define UART_BASE_ADDRESS                        0x0000c000
-#define SI_BASE_ADDRESS                          0x00010000
-#define GPIO_BASE_ADDRESS                        0x00014000
-#define MBOX_BASE_ADDRESS                        0x00018000
-#define ANALOG_INTF_BASE_ADDRESS                 0x0001c000
-#define MAC_BASE_ADDRESS                         0x00020000
-
-#endif /* _APB_MAP_REG_H_ */
diff --git a/drivers/staging/ath6kl/include/common/AR6002/hw2.0/hw/gpio_reg.h b/drivers/staging/ath6kl/include/common/AR6002/hw2.0/hw/gpio_reg.h
deleted file mode 100644 (file)
index 4f2b964..0000000
+++ /dev/null
@@ -1,977 +0,0 @@
-#ifndef _GPIO_REG_REG_H_
-#define _GPIO_REG_REG_H_
-
-#define GPIO_OUT_ADDRESS                         0x00000000
-#define GPIO_OUT_OFFSET                          0x00000000
-#define GPIO_OUT_DATA_MSB                        17
-#define GPIO_OUT_DATA_LSB                        0
-#define GPIO_OUT_DATA_MASK                       0x0003ffff
-#define GPIO_OUT_DATA_GET(x)                     (((x) & GPIO_OUT_DATA_MASK) >> GPIO_OUT_DATA_LSB)
-#define GPIO_OUT_DATA_SET(x)                     (((x) << GPIO_OUT_DATA_LSB) & GPIO_OUT_DATA_MASK)
-
-#define GPIO_OUT_W1TS_ADDRESS                    0x00000004
-#define GPIO_OUT_W1TS_OFFSET                     0x00000004
-#define GPIO_OUT_W1TS_DATA_MSB                   17
-#define GPIO_OUT_W1TS_DATA_LSB                   0
-#define GPIO_OUT_W1TS_DATA_MASK                  0x0003ffff
-#define GPIO_OUT_W1TS_DATA_GET(x)                (((x) & GPIO_OUT_W1TS_DATA_MASK) >> GPIO_OUT_W1TS_DATA_LSB)
-#define GPIO_OUT_W1TS_DATA_SET(x)                (((x) << GPIO_OUT_W1TS_DATA_LSB) & GPIO_OUT_W1TS_DATA_MASK)
-
-#define GPIO_OUT_W1TC_ADDRESS                    0x00000008
-#define GPIO_OUT_W1TC_OFFSET                     0x00000008
-#define GPIO_OUT_W1TC_DATA_MSB                   17
-#define GPIO_OUT_W1TC_DATA_LSB                   0
-#define GPIO_OUT_W1TC_DATA_MASK                  0x0003ffff
-#define GPIO_OUT_W1TC_DATA_GET(x)                (((x) & GPIO_OUT_W1TC_DATA_MASK) >> GPIO_OUT_W1TC_DATA_LSB)
-#define GPIO_OUT_W1TC_DATA_SET(x)                (((x) << GPIO_OUT_W1TC_DATA_LSB) & GPIO_OUT_W1TC_DATA_MASK)
-
-#define GPIO_ENABLE_ADDRESS                      0x0000000c
-#define GPIO_ENABLE_OFFSET                       0x0000000c
-#define GPIO_ENABLE_DATA_MSB                     17
-#define GPIO_ENABLE_DATA_LSB                     0
-#define GPIO_ENABLE_DATA_MASK                    0x0003ffff
-#define GPIO_ENABLE_DATA_GET(x)                  (((x) & GPIO_ENABLE_DATA_MASK) >> GPIO_ENABLE_DATA_LSB)
-#define GPIO_ENABLE_DATA_SET(x)                  (((x) << GPIO_ENABLE_DATA_LSB) & GPIO_ENABLE_DATA_MASK)
-
-#define GPIO_ENABLE_W1TS_ADDRESS                 0x00000010
-#define GPIO_ENABLE_W1TS_OFFSET                  0x00000010
-#define GPIO_ENABLE_W1TS_DATA_MSB                17
-#define GPIO_ENABLE_W1TS_DATA_LSB                0
-#define GPIO_ENABLE_W1TS_DATA_MASK               0x0003ffff
-#define GPIO_ENABLE_W1TS_DATA_GET(x)             (((x) & GPIO_ENABLE_W1TS_DATA_MASK) >> GPIO_ENABLE_W1TS_DATA_LSB)
-#define GPIO_ENABLE_W1TS_DATA_SET(x)             (((x) << GPIO_ENABLE_W1TS_DATA_LSB) & GPIO_ENABLE_W1TS_DATA_MASK)
-
-#define GPIO_ENABLE_W1TC_ADDRESS                 0x00000014
-#define GPIO_ENABLE_W1TC_OFFSET                  0x00000014
-#define GPIO_ENABLE_W1TC_DATA_MSB                17
-#define GPIO_ENABLE_W1TC_DATA_LSB                0
-#define GPIO_ENABLE_W1TC_DATA_MASK               0x0003ffff
-#define GPIO_ENABLE_W1TC_DATA_GET(x)             (((x) & GPIO_ENABLE_W1TC_DATA_MASK) >> GPIO_ENABLE_W1TC_DATA_LSB)
-#define GPIO_ENABLE_W1TC_DATA_SET(x)             (((x) << GPIO_ENABLE_W1TC_DATA_LSB) & GPIO_ENABLE_W1TC_DATA_MASK)
-
-#define GPIO_IN_ADDRESS                          0x00000018
-#define GPIO_IN_OFFSET                           0x00000018
-#define GPIO_IN_DATA_MSB                         17
-#define GPIO_IN_DATA_LSB                         0
-#define GPIO_IN_DATA_MASK                        0x0003ffff
-#define GPIO_IN_DATA_GET(x)                      (((x) & GPIO_IN_DATA_MASK) >> GPIO_IN_DATA_LSB)
-#define GPIO_IN_DATA_SET(x)                      (((x) << GPIO_IN_DATA_LSB) & GPIO_IN_DATA_MASK)
-
-#define GPIO_STATUS_ADDRESS                      0x0000001c
-#define GPIO_STATUS_OFFSET                       0x0000001c
-#define GPIO_STATUS_INTERRUPT_MSB                17
-#define GPIO_STATUS_INTERRUPT_LSB                0
-#define GPIO_STATUS_INTERRUPT_MASK               0x0003ffff
-#define GPIO_STATUS_INTERRUPT_GET(x)             (((x) & GPIO_STATUS_INTERRUPT_MASK) >> GPIO_STATUS_INTERRUPT_LSB)
-#define GPIO_STATUS_INTERRUPT_SET(x)             (((x) << GPIO_STATUS_INTERRUPT_LSB) & GPIO_STATUS_INTERRUPT_MASK)
-
-#define GPIO_STATUS_W1TS_ADDRESS                 0x00000020
-#define GPIO_STATUS_W1TS_OFFSET                  0x00000020
-#define GPIO_STATUS_W1TS_INTERRUPT_MSB           17
-#define GPIO_STATUS_W1TS_INTERRUPT_LSB           0
-#define GPIO_STATUS_W1TS_INTERRUPT_MASK          0x0003ffff
-#define GPIO_STATUS_W1TS_INTERRUPT_GET(x)        (((x) & GPIO_STATUS_W1TS_INTERRUPT_MASK) >> GPIO_STATUS_W1TS_INTERRUPT_LSB)
-#define GPIO_STATUS_W1TS_INTERRUPT_SET(x)        (((x) << GPIO_STATUS_W1TS_INTERRUPT_LSB) & GPIO_STATUS_W1TS_INTERRUPT_MASK)
-
-#define GPIO_STATUS_W1TC_ADDRESS                 0x00000024
-#define GPIO_STATUS_W1TC_OFFSET                  0x00000024
-#define GPIO_STATUS_W1TC_INTERRUPT_MSB           17
-#define GPIO_STATUS_W1TC_INTERRUPT_LSB           0
-#define GPIO_STATUS_W1TC_INTERRUPT_MASK          0x0003ffff
-#define GPIO_STATUS_W1TC_INTERRUPT_GET(x)        (((x) & GPIO_STATUS_W1TC_INTERRUPT_MASK) >> GPIO_STATUS_W1TC_INTERRUPT_LSB)
-#define GPIO_STATUS_W1TC_INTERRUPT_SET(x)        (((x) << GPIO_STATUS_W1TC_INTERRUPT_LSB) & GPIO_STATUS_W1TC_INTERRUPT_MASK)
-
-#define GPIO_PIN0_ADDRESS                        0x00000028
-#define GPIO_PIN0_OFFSET                         0x00000028
-#define GPIO_PIN0_CONFIG_MSB                     12
-#define GPIO_PIN0_CONFIG_LSB                     11
-#define GPIO_PIN0_CONFIG_MASK                    0x00001800
-#define GPIO_PIN0_CONFIG_GET(x)                  (((x) & GPIO_PIN0_CONFIG_MASK) >> GPIO_PIN0_CONFIG_LSB)
-#define GPIO_PIN0_CONFIG_SET(x)                  (((x) << GPIO_PIN0_CONFIG_LSB) & GPIO_PIN0_CONFIG_MASK)
-#define GPIO_PIN0_WAKEUP_ENABLE_MSB              10
-#define GPIO_PIN0_WAKEUP_ENABLE_LSB              10
-#define GPIO_PIN0_WAKEUP_ENABLE_MASK             0x00000400
-#define GPIO_PIN0_WAKEUP_ENABLE_GET(x)           (((x) & GPIO_PIN0_WAKEUP_ENABLE_MASK) >> GPIO_PIN0_WAKEUP_ENABLE_LSB)
-#define GPIO_PIN0_WAKEUP_ENABLE_SET(x)           (((x) << GPIO_PIN0_WAKEUP_ENABLE_LSB) & GPIO_PIN0_WAKEUP_ENABLE_MASK)
-#define GPIO_PIN0_INT_TYPE_MSB                   9
-#define GPIO_PIN0_INT_TYPE_LSB                   7
-#define GPIO_PIN0_INT_TYPE_MASK                  0x00000380
-#define GPIO_PIN0_INT_TYPE_GET(x)                (((x) & GPIO_PIN0_INT_TYPE_MASK) >> GPIO_PIN0_INT_TYPE_LSB)
-#define GPIO_PIN0_INT_TYPE_SET(x)                (((x) << GPIO_PIN0_INT_TYPE_LSB) & GPIO_PIN0_INT_TYPE_MASK)
-#define GPIO_PIN0_PAD_DRIVER_MSB                 2
-#define GPIO_PIN0_PAD_DRIVER_LSB                 2
-#define GPIO_PIN0_PAD_DRIVER_MASK                0x00000004
-#define GPIO_PIN0_PAD_DRIVER_GET(x)              (((x) & GPIO_PIN0_PAD_DRIVER_MASK) >> GPIO_PIN0_PAD_DRIVER_LSB)
-#define GPIO_PIN0_PAD_DRIVER_SET(x)              (((x) << GPIO_PIN0_PAD_DRIVER_LSB) & GPIO_PIN0_PAD_DRIVER_MASK)
-#define GPIO_PIN0_SOURCE_MSB                     0
-#define GPIO_PIN0_SOURCE_LSB                     0
-#define GPIO_PIN0_SOURCE_MASK                    0x00000001
-#define GPIO_PIN0_SOURCE_GET(x)                  (((x) & GPIO_PIN0_SOURCE_MASK) >> GPIO_PIN0_SOURCE_LSB)
-#define GPIO_PIN0_SOURCE_SET(x)                  (((x) << GPIO_PIN0_SOURCE_LSB) & GPIO_PIN0_SOURCE_MASK)
-
-#define GPIO_PIN1_ADDRESS                        0x0000002c
-#define GPIO_PIN1_OFFSET                         0x0000002c
-#define GPIO_PIN1_CONFIG_MSB                     12
-#define GPIO_PIN1_CONFIG_LSB                     11
-#define GPIO_PIN1_CONFIG_MASK                    0x00001800
-#define GPIO_PIN1_CONFIG_GET(x)                  (((x) & GPIO_PIN1_CONFIG_MASK) >> GPIO_PIN1_CONFIG_LSB)
-#define GPIO_PIN1_CONFIG_SET(x)                  (((x) << GPIO_PIN1_CONFIG_LSB) & GPIO_PIN1_CONFIG_MASK)
-#define GPIO_PIN1_WAKEUP_ENABLE_MSB              10
-#define GPIO_PIN1_WAKEUP_ENABLE_LSB              10
-#define GPIO_PIN1_WAKEUP_ENABLE_MASK             0x00000400
-#define GPIO_PIN1_WAKEUP_ENABLE_GET(x)           (((x) & GPIO_PIN1_WAKEUP_ENABLE_MASK) >> GPIO_PIN1_WAKEUP_ENABLE_LSB)
-#define GPIO_PIN1_WAKEUP_ENABLE_SET(x)           (((x) << GPIO_PIN1_WAKEUP_ENABLE_LSB) & GPIO_PIN1_WAKEUP_ENABLE_MASK)
-#define GPIO_PIN1_INT_TYPE_MSB                   9
-#define GPIO_PIN1_INT_TYPE_LSB                   7
-#define GPIO_PIN1_INT_TYPE_MASK                  0x00000380
-#define GPIO_PIN1_INT_TYPE_GET(x)                (((x) & GPIO_PIN1_INT_TYPE_MASK) >> GPIO_PIN1_INT_TYPE_LSB)
-#define GPIO_PIN1_INT_TYPE_SET(x)                (((x) << GPIO_PIN1_INT_TYPE_LSB) & GPIO_PIN1_INT_TYPE_MASK)
-#define GPIO_PIN1_PAD_DRIVER_MSB                 2
-#define GPIO_PIN1_PAD_DRIVER_LSB                 2
-#define GPIO_PIN1_PAD_DRIVER_MASK                0x00000004
-#define GPIO_PIN1_PAD_DRIVER_GET(x)              (((x) & GPIO_PIN1_PAD_DRIVER_MASK) >> GPIO_PIN1_PAD_DRIVER_LSB)
-#define GPIO_PIN1_PAD_DRIVER_SET(x)              (((x) << GPIO_PIN1_PAD_DRIVER_LSB) & GPIO_PIN1_PAD_DRIVER_MASK)
-#define GPIO_PIN1_SOURCE_MSB                     0
-#define GPIO_PIN1_SOURCE_LSB                     0
-#define GPIO_PIN1_SOURCE_MASK                    0x00000001
-#define GPIO_PIN1_SOURCE_GET(x)                  (((x) & GPIO_PIN1_SOURCE_MASK) >> GPIO_PIN1_SOURCE_LSB)
-#define GPIO_PIN1_SOURCE_SET(x)                  (((x) << GPIO_PIN1_SOURCE_LSB) & GPIO_PIN1_SOURCE_MASK)
-
-#define GPIO_PIN2_ADDRESS                        0x00000030
-#define GPIO_PIN2_OFFSET                         0x00000030
-#define GPIO_PIN2_CONFIG_MSB                     12
-#define GPIO_PIN2_CONFIG_LSB                     11
-#define GPIO_PIN2_CONFIG_MASK                    0x00001800
-#define GPIO_PIN2_CONFIG_GET(x)                  (((x) & GPIO_PIN2_CONFIG_MASK) >> GPIO_PIN2_CONFIG_LSB)
-#define GPIO_PIN2_CONFIG_SET(x)                  (((x) << GPIO_PIN2_CONFIG_LSB) & GPIO_PIN2_CONFIG_MASK)
-#define GPIO_PIN2_WAKEUP_ENABLE_MSB              10
-#define GPIO_PIN2_WAKEUP_ENABLE_LSB              10
-#define GPIO_PIN2_WAKEUP_ENABLE_MASK             0x00000400
-#define GPIO_PIN2_WAKEUP_ENABLE_GET(x)           (((x) & GPIO_PIN2_WAKEUP_ENABLE_MASK) >> GPIO_PIN2_WAKEUP_ENABLE_LSB)
-#define GPIO_PIN2_WAKEUP_ENABLE_SET(x)           (((x) << GPIO_PIN2_WAKEUP_ENABLE_LSB) & GPIO_PIN2_WAKEUP_ENABLE_MASK)
-#define GPIO_PIN2_INT_TYPE_MSB                   9
-#define GPIO_PIN2_INT_TYPE_LSB                   7
-#define GPIO_PIN2_INT_TYPE_MASK                  0x00000380
-#define GPIO_PIN2_INT_TYPE_GET(x)                (((x) & GPIO_PIN2_INT_TYPE_MASK) >> GPIO_PIN2_INT_TYPE_LSB)
-#define GPIO_PIN2_INT_TYPE_SET(x)                (((x) << GPIO_PIN2_INT_TYPE_LSB) & GPIO_PIN2_INT_TYPE_MASK)
-#define GPIO_PIN2_PAD_DRIVER_MSB                 2
-#define GPIO_PIN2_PAD_DRIVER_LSB                 2
-#define GPIO_PIN2_PAD_DRIVER_MASK                0x00000004
-#define GPIO_PIN2_PAD_DRIVER_GET(x)              (((x) & GPIO_PIN2_PAD_DRIVER_MASK) >> GPIO_PIN2_PAD_DRIVER_LSB)
-#define GPIO_PIN2_PAD_DRIVER_SET(x)              (((x) << GPIO_PIN2_PAD_DRIVER_LSB) & GPIO_PIN2_PAD_DRIVER_MASK)
-#define GPIO_PIN2_SOURCE_MSB                     0
-#define GPIO_PIN2_SOURCE_LSB                     0
-#define GPIO_PIN2_SOURCE_MASK                    0x00000001
-#define GPIO_PIN2_SOURCE_GET(x)                  (((x) & GPIO_PIN2_SOURCE_MASK) >> GPIO_PIN2_SOURCE_LSB)
-#define GPIO_PIN2_SOURCE_SET(x)                  (((x) << GPIO_PIN2_SOURCE_LSB) & GPIO_PIN2_SOURCE_MASK)
-
-#define GPIO_PIN3_ADDRESS                        0x00000034
-#define GPIO_PIN3_OFFSET                         0x00000034
-#define GPIO_PIN3_CONFIG_MSB                     12
-#define GPIO_PIN3_CONFIG_LSB                     11
-#define GPIO_PIN3_CONFIG_MASK                    0x00001800
-#define GPIO_PIN3_CONFIG_GET(x)                  (((x) & GPIO_PIN3_CONFIG_MASK) >> GPIO_PIN3_CONFIG_LSB)
-#define GPIO_PIN3_CONFIG_SET(x)                  (((x) << GPIO_PIN3_CONFIG_LSB) & GPIO_PIN3_CONFIG_MASK)
-#define GPIO_PIN3_WAKEUP_ENABLE_MSB              10
-#define GPIO_PIN3_WAKEUP_ENABLE_LSB              10
-#define GPIO_PIN3_WAKEUP_ENABLE_MASK             0x00000400
-#define GPIO_PIN3_WAKEUP_ENABLE_GET(x)           (((x) & GPIO_PIN3_WAKEUP_ENABLE_MASK) >> GPIO_PIN3_WAKEUP_ENABLE_LSB)
-#define GPIO_PIN3_WAKEUP_ENABLE_SET(x)           (((x) << GPIO_PIN3_WAKEUP_ENABLE_LSB) & GPIO_PIN3_WAKEUP_ENABLE_MASK)
-#define GPIO_PIN3_INT_TYPE_MSB                   9
-#define GPIO_PIN3_INT_TYPE_LSB                   7
-#define GPIO_PIN3_INT_TYPE_MASK                  0x00000380
-#define GPIO_PIN3_INT_TYPE_GET(x)                (((x) & GPIO_PIN3_INT_TYPE_MASK) >> GPIO_PIN3_INT_TYPE_LSB)
-#define GPIO_PIN3_INT_TYPE_SET(x)                (((x) << GPIO_PIN3_INT_TYPE_LSB) & GPIO_PIN3_INT_TYPE_MASK)
-#define GPIO_PIN3_PAD_DRIVER_MSB                 2
-#define GPIO_PIN3_PAD_DRIVER_LSB                 2
-#define GPIO_PIN3_PAD_DRIVER_MASK                0x00000004
-#define GPIO_PIN3_PAD_DRIVER_GET(x)              (((x) & GPIO_PIN3_PAD_DRIVER_MASK) >> GPIO_PIN3_PAD_DRIVER_LSB)
-#define GPIO_PIN3_PAD_DRIVER_SET(x)              (((x) << GPIO_PIN3_PAD_DRIVER_LSB) & GPIO_PIN3_PAD_DRIVER_MASK)
-#define GPIO_PIN3_SOURCE_MSB                     0
-#define GPIO_PIN3_SOURCE_LSB                     0
-#define GPIO_PIN3_SOURCE_MASK                    0x00000001
-#define GPIO_PIN3_SOURCE_GET(x)                  (((x) & GPIO_PIN3_SOURCE_MASK) >> GPIO_PIN3_SOURCE_LSB)
-#define GPIO_PIN3_SOURCE_SET(x)                  (((x) << GPIO_PIN3_SOURCE_LSB) & GPIO_PIN3_SOURCE_MASK)
-
-#define GPIO_PIN4_ADDRESS                        0x00000038
-#define GPIO_PIN4_OFFSET                         0x00000038
-#define GPIO_PIN4_CONFIG_MSB                     12
-#define GPIO_PIN4_CONFIG_LSB                     11
-#define GPIO_PIN4_CONFIG_MASK                    0x00001800
-#define GPIO_PIN4_CONFIG_GET(x)                  (((x) & GPIO_PIN4_CONFIG_MASK) >> GPIO_PIN4_CONFIG_LSB)
-#define GPIO_PIN4_CONFIG_SET(x)                  (((x) << GPIO_PIN4_CONFIG_LSB) & GPIO_PIN4_CONFIG_MASK)
-#define GPIO_PIN4_WAKEUP_ENABLE_MSB              10
-#define GPIO_PIN4_WAKEUP_ENABLE_LSB              10
-#define GPIO_PIN4_WAKEUP_ENABLE_MASK             0x00000400
-#define GPIO_PIN4_WAKEUP_ENABLE_GET(x)           (((x) & GPIO_PIN4_WAKEUP_ENABLE_MASK) >> GPIO_PIN4_WAKEUP_ENABLE_LSB)
-#define GPIO_PIN4_WAKEUP_ENABLE_SET(x)           (((x) << GPIO_PIN4_WAKEUP_ENABLE_LSB) & GPIO_PIN4_WAKEUP_ENABLE_MASK)
-#define GPIO_PIN4_INT_TYPE_MSB                   9
-#define GPIO_PIN4_INT_TYPE_LSB                   7
-#define GPIO_PIN4_INT_TYPE_MASK                  0x00000380
-#define GPIO_PIN4_INT_TYPE_GET(x)                (((x) & GPIO_PIN4_INT_TYPE_MASK) >> GPIO_PIN4_INT_TYPE_LSB)
-#define GPIO_PIN4_INT_TYPE_SET(x)                (((x) << GPIO_PIN4_INT_TYPE_LSB) & GPIO_PIN4_INT_TYPE_MASK)
-#define GPIO_PIN4_PAD_DRIVER_MSB                 2
-#define GPIO_PIN4_PAD_DRIVER_LSB                 2
-#define GPIO_PIN4_PAD_DRIVER_MASK                0x00000004
-#define GPIO_PIN4_PAD_DRIVER_GET(x)              (((x) & GPIO_PIN4_PAD_DRIVER_MASK) >> GPIO_PIN4_PAD_DRIVER_LSB)
-#define GPIO_PIN4_PAD_DRIVER_SET(x)              (((x) << GPIO_PIN4_PAD_DRIVER_LSB) & GPIO_PIN4_PAD_DRIVER_MASK)
-#define GPIO_PIN4_SOURCE_MSB                     0
-#define GPIO_PIN4_SOURCE_LSB                     0
-#define GPIO_PIN4_SOURCE_MASK                    0x00000001
-#define GPIO_PIN4_SOURCE_GET(x)                  (((x) & GPIO_PIN4_SOURCE_MASK) >> GPIO_PIN4_SOURCE_LSB)
-#define GPIO_PIN4_SOURCE_SET(x)                  (((x) << GPIO_PIN4_SOURCE_LSB) & GPIO_PIN4_SOURCE_MASK)
-
-#define GPIO_PIN5_ADDRESS                        0x0000003c
-#define GPIO_PIN5_OFFSET                         0x0000003c
-#define GPIO_PIN5_CONFIG_MSB                     12
-#define GPIO_PIN5_CONFIG_LSB                     11
-#define GPIO_PIN5_CONFIG_MASK                    0x00001800
-#define GPIO_PIN5_CONFIG_GET(x)                  (((x) & GPIO_PIN5_CONFIG_MASK) >> GPIO_PIN5_CONFIG_LSB)
-#define GPIO_PIN5_CONFIG_SET(x)                  (((x) << GPIO_PIN5_CONFIG_LSB) & GPIO_PIN5_CONFIG_MASK)
-#define GPIO_PIN5_WAKEUP_ENABLE_MSB              10
-#define GPIO_PIN5_WAKEUP_ENABLE_LSB              10
-#define GPIO_PIN5_WAKEUP_ENABLE_MASK             0x00000400
-#define GPIO_PIN5_WAKEUP_ENABLE_GET(x)           (((x) & GPIO_PIN5_WAKEUP_ENABLE_MASK) >> GPIO_PIN5_WAKEUP_ENABLE_LSB)
-#define GPIO_PIN5_WAKEUP_ENABLE_SET(x)           (((x) << GPIO_PIN5_WAKEUP_ENABLE_LSB) & GPIO_PIN5_WAKEUP_ENABLE_MASK)
-#define GPIO_PIN5_INT_TYPE_MSB                   9
-#define GPIO_PIN5_INT_TYPE_LSB                   7
-#define GPIO_PIN5_INT_TYPE_MASK                  0x00000380
-#define GPIO_PIN5_INT_TYPE_GET(x)                (((x) & GPIO_PIN5_INT_TYPE_MASK) >> GPIO_PIN5_INT_TYPE_LSB)
-#define GPIO_PIN5_INT_TYPE_SET(x)                (((x) << GPIO_PIN5_INT_TYPE_LSB) & GPIO_PIN5_INT_TYPE_MASK)
-#define GPIO_PIN5_PAD_DRIVER_MSB                 2
-#define GPIO_PIN5_PAD_DRIVER_LSB                 2
-#define GPIO_PIN5_PAD_DRIVER_MASK                0x00000004
-#define GPIO_PIN5_PAD_DRIVER_GET(x)              (((x) & GPIO_PIN5_PAD_DRIVER_MASK) >> GPIO_PIN5_PAD_DRIVER_LSB)
-#define GPIO_PIN5_PAD_DRIVER_SET(x)              (((x) << GPIO_PIN5_PAD_DRIVER_LSB) & GPIO_PIN5_PAD_DRIVER_MASK)
-#define GPIO_PIN5_SOURCE_MSB                     0
-#define GPIO_PIN5_SOURCE_LSB                     0
-#define GPIO_PIN5_SOURCE_MASK                    0x00000001
-#define GPIO_PIN5_SOURCE_GET(x)                  (((x) & GPIO_PIN5_SOURCE_MASK) >> GPIO_PIN5_SOURCE_LSB)
-#define GPIO_PIN5_SOURCE_SET(x)                  (((x) << GPIO_PIN5_SOURCE_LSB) & GPIO_PIN5_SOURCE_MASK)
-
-#define GPIO_PIN6_ADDRESS                        0x00000040
-#define GPIO_PIN6_OFFSET                         0x00000040
-#define GPIO_PIN6_CONFIG_MSB                     12
-#define GPIO_PIN6_CONFIG_LSB                     11
-#define GPIO_PIN6_CONFIG_MASK                    0x00001800
-#define GPIO_PIN6_CONFIG_GET(x)                  (((x) & GPIO_PIN6_CONFIG_MASK) >> GPIO_PIN6_CONFIG_LSB)
-#define GPIO_PIN6_CONFIG_SET(x)                  (((x) << GPIO_PIN6_CONFIG_LSB) & GPIO_PIN6_CONFIG_MASK)
-#define GPIO_PIN6_WAKEUP_ENABLE_MSB              10
-#define GPIO_PIN6_WAKEUP_ENABLE_LSB              10
-#define GPIO_PIN6_WAKEUP_ENABLE_MASK             0x00000400
-#define GPIO_PIN6_WAKEUP_ENABLE_GET(x)           (((x) & GPIO_PIN6_WAKEUP_ENABLE_MASK) >> GPIO_PIN6_WAKEUP_ENABLE_LSB)
-#define GPIO_PIN6_WAKEUP_ENABLE_SET(x)           (((x) << GPIO_PIN6_WAKEUP_ENABLE_LSB) & GPIO_PIN6_WAKEUP_ENABLE_MASK)
-#define GPIO_PIN6_INT_TYPE_MSB                   9
-#define GPIO_PIN6_INT_TYPE_LSB                   7
-#define GPIO_PIN6_INT_TYPE_MASK                  0x00000380
-#define GPIO_PIN6_INT_TYPE_GET(x)                (((x) & GPIO_PIN6_INT_TYPE_MASK) >> GPIO_PIN6_INT_TYPE_LSB)
-#define GPIO_PIN6_INT_TYPE_SET(x)                (((x) << GPIO_PIN6_INT_TYPE_LSB) & GPIO_PIN6_INT_TYPE_MASK)
-#define GPIO_PIN6_PAD_DRIVER_MSB                 2
-#define GPIO_PIN6_PAD_DRIVER_LSB                 2
-#define GPIO_PIN6_PAD_DRIVER_MASK                0x00000004
-#define GPIO_PIN6_PAD_DRIVER_GET(x)              (((x) & GPIO_PIN6_PAD_DRIVER_MASK) >> GPIO_PIN6_PAD_DRIVER_LSB)
-#define GPIO_PIN6_PAD_DRIVER_SET(x)              (((x) << GPIO_PIN6_PAD_DRIVER_LSB) & GPIO_PIN6_PAD_DRIVER_MASK)
-#define GPIO_PIN6_SOURCE_MSB                     0
-#define GPIO_PIN6_SOURCE_LSB                     0
-#define GPIO_PIN6_SOURCE_MASK                    0x00000001
-#define GPIO_PIN6_SOURCE_GET(x)                  (((x) & GPIO_PIN6_SOURCE_MASK) >> GPIO_PIN6_SOURCE_LSB)
-#define GPIO_PIN6_SOURCE_SET(x)                  (((x) << GPIO_PIN6_SOURCE_LSB) & GPIO_PIN6_SOURCE_MASK)
-
-#define GPIO_PIN7_ADDRESS                        0x00000044
-#define GPIO_PIN7_OFFSET                         0x00000044
-#define GPIO_PIN7_CONFIG_MSB                     12
-#define GPIO_PIN7_CONFIG_LSB                     11
-#define GPIO_PIN7_CONFIG_MASK                    0x00001800
-#define GPIO_PIN7_CONFIG_GET(x)                  (((x) & GPIO_PIN7_CONFIG_MASK) >> GPIO_PIN7_CONFIG_LSB)
-#define GPIO_PIN7_CONFIG_SET(x)                  (((x) << GPIO_PIN7_CONFIG_LSB) & GPIO_PIN7_CONFIG_MASK)
-#define GPIO_PIN7_WAKEUP_ENABLE_MSB              10
-#define GPIO_PIN7_WAKEUP_ENABLE_LSB              10
-#define GPIO_PIN7_WAKEUP_ENABLE_MASK             0x00000400
-#define GPIO_PIN7_WAKEUP_ENABLE_GET(x)           (((x) & GPIO_PIN7_WAKEUP_ENABLE_MASK) >> GPIO_PIN7_WAKEUP_ENABLE_LSB)
-#define GPIO_PIN7_WAKEUP_ENABLE_SET(x)           (((x) << GPIO_PIN7_WAKEUP_ENABLE_LSB) & GPIO_PIN7_WAKEUP_ENABLE_MASK)
-#define GPIO_PIN7_INT_TYPE_MSB                   9
-#define GPIO_PIN7_INT_TYPE_LSB                   7
-#define GPIO_PIN7_INT_TYPE_MASK                  0x00000380
-#define GPIO_PIN7_INT_TYPE_GET(x)                (((x) & GPIO_PIN7_INT_TYPE_MASK) >> GPIO_PIN7_INT_TYPE_LSB)
-#define GPIO_PIN7_INT_TYPE_SET(x)                (((x) << GPIO_PIN7_INT_TYPE_LSB) & GPIO_PIN7_INT_TYPE_MASK)
-#define GPIO_PIN7_PAD_DRIVER_MSB                 2
-#define GPIO_PIN7_PAD_DRIVER_LSB                 2
-#define GPIO_PIN7_PAD_DRIVER_MASK                0x00000004
-#define GPIO_PIN7_PAD_DRIVER_GET(x)              (((x) & GPIO_PIN7_PAD_DRIVER_MASK) >> GPIO_PIN7_PAD_DRIVER_LSB)
-#define GPIO_PIN7_PAD_DRIVER_SET(x)              (((x) << GPIO_PIN7_PAD_DRIVER_LSB) & GPIO_PIN7_PAD_DRIVER_MASK)
-#define GPIO_PIN7_SOURCE_MSB                     0
-#define GPIO_PIN7_SOURCE_LSB                     0
-#define GPIO_PIN7_SOURCE_MASK                    0x00000001
-#define GPIO_PIN7_SOURCE_GET(x)                  (((x) & GPIO_PIN7_SOURCE_MASK) >> GPIO_PIN7_SOURCE_LSB)
-#define GPIO_PIN7_SOURCE_SET(x)                  (((x) << GPIO_PIN7_SOURCE_LSB) & GPIO_PIN7_SOURCE_MASK)
-
-#define GPIO_PIN8_ADDRESS                        0x00000048
-#define GPIO_PIN8_OFFSET                         0x00000048
-#define GPIO_PIN8_CONFIG_MSB                     12
-#define GPIO_PIN8_CONFIG_LSB                     11
-#define GPIO_PIN8_CONFIG_MASK                    0x00001800
-#define GPIO_PIN8_CONFIG_GET(x)                  (((x) & GPIO_PIN8_CONFIG_MASK) >> GPIO_PIN8_CONFIG_LSB)
-#define GPIO_PIN8_CONFIG_SET(x)                  (((x) << GPIO_PIN8_CONFIG_LSB) & GPIO_PIN8_CONFIG_MASK)
-#define GPIO_PIN8_WAKEUP_ENABLE_MSB              10
-#define GPIO_PIN8_WAKEUP_ENABLE_LSB              10
-#define GPIO_PIN8_WAKEUP_ENABLE_MASK             0x00000400
-#define GPIO_PIN8_WAKEUP_ENABLE_GET(x)           (((x) & GPIO_PIN8_WAKEUP_ENABLE_MASK) >> GPIO_PIN8_WAKEUP_ENABLE_LSB)
-#define GPIO_PIN8_WAKEUP_ENABLE_SET(x)           (((x) << GPIO_PIN8_WAKEUP_ENABLE_LSB) & GPIO_PIN8_WAKEUP_ENABLE_MASK)
-#define GPIO_PIN8_INT_TYPE_MSB                   9
-#define GPIO_PIN8_INT_TYPE_LSB                   7
-#define GPIO_PIN8_INT_TYPE_MASK                  0x00000380
-#define GPIO_PIN8_INT_TYPE_GET(x)                (((x) & GPIO_PIN8_INT_TYPE_MASK) >> GPIO_PIN8_INT_TYPE_LSB)
-#define GPIO_PIN8_INT_TYPE_SET(x)                (((x) << GPIO_PIN8_INT_TYPE_LSB) & GPIO_PIN8_INT_TYPE_MASK)
-#define GPIO_PIN8_PAD_DRIVER_MSB                 2
-#define GPIO_PIN8_PAD_DRIVER_LSB                 2
-#define GPIO_PIN8_PAD_DRIVER_MASK                0x00000004
-#define GPIO_PIN8_PAD_DRIVER_GET(x)              (((x) & GPIO_PIN8_PAD_DRIVER_MASK) >> GPIO_PIN8_PAD_DRIVER_LSB)
-#define GPIO_PIN8_PAD_DRIVER_SET(x)              (((x) << GPIO_PIN8_PAD_DRIVER_LSB) & GPIO_PIN8_PAD_DRIVER_MASK)
-#define GPIO_PIN8_SOURCE_MSB                     0
-#define GPIO_PIN8_SOURCE_LSB                     0
-#define GPIO_PIN8_SOURCE_MASK                    0x00000001
-#define GPIO_PIN8_SOURCE_GET(x)                  (((x) & GPIO_PIN8_SOURCE_MASK) >> GPIO_PIN8_SOURCE_LSB)
-#define GPIO_PIN8_SOURCE_SET(x)                  (((x) << GPIO_PIN8_SOURCE_LSB) & GPIO_PIN8_SOURCE_MASK)
-
-#define GPIO_PIN9_ADDRESS                        0x0000004c
-#define GPIO_PIN9_OFFSET                         0x0000004c
-#define GPIO_PIN9_CONFIG_MSB                     12
-#define GPIO_PIN9_CONFIG_LSB                     11
-#define GPIO_PIN9_CONFIG_MASK                    0x00001800
-#define GPIO_PIN9_CONFIG_GET(x)                  (((x) & GPIO_PIN9_CONFIG_MASK) >> GPIO_PIN9_CONFIG_LSB)
-#define GPIO_PIN9_CONFIG_SET(x)                  (((x) << GPIO_PIN9_CONFIG_LSB) & GPIO_PIN9_CONFIG_MASK)
-#define GPIO_PIN9_WAKEUP_ENABLE_MSB              10
-#define GPIO_PIN9_WAKEUP_ENABLE_LSB              10
-#define GPIO_PIN9_WAKEUP_ENABLE_MASK             0x00000400
-#define GPIO_PIN9_WAKEUP_ENABLE_GET(x)           (((x) & GPIO_PIN9_WAKEUP_ENABLE_MASK) >> GPIO_PIN9_WAKEUP_ENABLE_LSB)
-#define GPIO_PIN9_WAKEUP_ENABLE_SET(x)           (((x) << GPIO_PIN9_WAKEUP_ENABLE_LSB) & GPIO_PIN9_WAKEUP_ENABLE_MASK)
-#define GPIO_PIN9_INT_TYPE_MSB                   9
-#define GPIO_PIN9_INT_TYPE_LSB                   7
-#define GPIO_PIN9_INT_TYPE_MASK                  0x00000380
-#define GPIO_PIN9_INT_TYPE_GET(x)                (((x) & GPIO_PIN9_INT_TYPE_MASK) >> GPIO_PIN9_INT_TYPE_LSB)
-#define GPIO_PIN9_INT_TYPE_SET(x)                (((x) << GPIO_PIN9_INT_TYPE_LSB) & GPIO_PIN9_INT_TYPE_MASK)
-#define GPIO_PIN9_PAD_DRIVER_MSB                 2
-#define GPIO_PIN9_PAD_DRIVER_LSB                 2
-#define GPIO_PIN9_PAD_DRIVER_MASK                0x00000004
-#define GPIO_PIN9_PAD_DRIVER_GET(x)              (((x) & GPIO_PIN9_PAD_DRIVER_MASK) >> GPIO_PIN9_PAD_DRIVER_LSB)
-#define GPIO_PIN9_PAD_DRIVER_SET(x)              (((x) << GPIO_PIN9_PAD_DRIVER_LSB) & GPIO_PIN9_PAD_DRIVER_MASK)
-#define GPIO_PIN9_SOURCE_MSB                     0
-#define GPIO_PIN9_SOURCE_LSB                     0
-#define GPIO_PIN9_SOURCE_MASK                    0x00000001
-#define GPIO_PIN9_SOURCE_GET(x)                  (((x) & GPIO_PIN9_SOURCE_MASK) >> GPIO_PIN9_SOURCE_LSB)
-#define GPIO_PIN9_SOURCE_SET(x)                  (((x) << GPIO_PIN9_SOURCE_LSB) & GPIO_PIN9_SOURCE_MASK)
-
-#define GPIO_PIN10_ADDRESS                       0x00000050
-#define GPIO_PIN10_OFFSET                        0x00000050
-#define GPIO_PIN10_CONFIG_MSB                    12
-#define GPIO_PIN10_CONFIG_LSB                    11
-#define GPIO_PIN10_CONFIG_MASK                   0x00001800
-#define GPIO_PIN10_CONFIG_GET(x)                 (((x) & GPIO_PIN10_CONFIG_MASK) >> GPIO_PIN10_CONFIG_LSB)
-#define GPIO_PIN10_CONFIG_SET(x)                 (((x) << GPIO_PIN10_CONFIG_LSB) & GPIO_PIN10_CONFIG_MASK)
-#define GPIO_PIN10_WAKEUP_ENABLE_MSB             10
-#define GPIO_PIN10_WAKEUP_ENABLE_LSB             10
-#define GPIO_PIN10_WAKEUP_ENABLE_MASK            0x00000400
-#define GPIO_PIN10_WAKEUP_ENABLE_GET(x)          (((x) & GPIO_PIN10_WAKEUP_ENABLE_MASK) >> GPIO_PIN10_WAKEUP_ENABLE_LSB)
-#define GPIO_PIN10_WAKEUP_ENABLE_SET(x)          (((x) << GPIO_PIN10_WAKEUP_ENABLE_LSB) & GPIO_PIN10_WAKEUP_ENABLE_MASK)
-#define GPIO_PIN10_INT_TYPE_MSB                  9
-#define GPIO_PIN10_INT_TYPE_LSB                  7
-#define GPIO_PIN10_INT_TYPE_MASK                 0x00000380
-#define GPIO_PIN10_INT_TYPE_GET(x)               (((x) & GPIO_PIN10_INT_TYPE_MASK) >> GPIO_PIN10_INT_TYPE_LSB)
-#define GPIO_PIN10_INT_TYPE_SET(x)               (((x) << GPIO_PIN10_INT_TYPE_LSB) & GPIO_PIN10_INT_TYPE_MASK)
-#define GPIO_PIN10_PAD_DRIVER_MSB                2
-#define GPIO_PIN10_PAD_DRIVER_LSB                2
-#define GPIO_PIN10_PAD_DRIVER_MASK               0x00000004
-#define GPIO_PIN10_PAD_DRIVER_GET(x)             (((x) & GPIO_PIN10_PAD_DRIVER_MASK) >> GPIO_PIN10_PAD_DRIVER_LSB)
-#define GPIO_PIN10_PAD_DRIVER_SET(x)             (((x) << GPIO_PIN10_PAD_DRIVER_LSB) & GPIO_PIN10_PAD_DRIVER_MASK)
-#define GPIO_PIN10_SOURCE_MSB                    0
-#define GPIO_PIN10_SOURCE_LSB                    0
-#define GPIO_PIN10_SOURCE_MASK                   0x00000001
-#define GPIO_PIN10_SOURCE_GET(x)                 (((x) & GPIO_PIN10_SOURCE_MASK) >> GPIO_PIN10_SOURCE_LSB)
-#define GPIO_PIN10_SOURCE_SET(x)                 (((x) << GPIO_PIN10_SOURCE_LSB) & GPIO_PIN10_SOURCE_MASK)
-
-#define GPIO_PIN11_ADDRESS                       0x00000054
-#define GPIO_PIN11_OFFSET                        0x00000054
-#define GPIO_PIN11_CONFIG_MSB                    12
-#define GPIO_PIN11_CONFIG_LSB                    11
-#define GPIO_PIN11_CONFIG_MASK                   0x00001800
-#define GPIO_PIN11_CONFIG_GET(x)                 (((x) & GPIO_PIN11_CONFIG_MASK) >> GPIO_PIN11_CONFIG_LSB)
-#define GPIO_PIN11_CONFIG_SET(x)                 (((x) << GPIO_PIN11_CONFIG_LSB) & GPIO_PIN11_CONFIG_MASK)
-#define GPIO_PIN11_WAKEUP_ENABLE_MSB             10
-#define GPIO_PIN11_WAKEUP_ENABLE_LSB             10
-#define GPIO_PIN11_WAKEUP_ENABLE_MASK            0x00000400
-#define GPIO_PIN11_WAKEUP_ENABLE_GET(x)          (((x) & GPIO_PIN11_WAKEUP_ENABLE_MASK) >> GPIO_PIN11_WAKEUP_ENABLE_LSB)
-#define GPIO_PIN11_WAKEUP_ENABLE_SET(x)          (((x) << GPIO_PIN11_WAKEUP_ENABLE_LSB) & GPIO_PIN11_WAKEUP_ENABLE_MASK)
-#define GPIO_PIN11_INT_TYPE_MSB                  9
-#define GPIO_PIN11_INT_TYPE_LSB                  7
-#define GPIO_PIN11_INT_TYPE_MASK                 0x00000380
-#define GPIO_PIN11_INT_TYPE_GET(x)               (((x) & GPIO_PIN11_INT_TYPE_MASK) >> GPIO_PIN11_INT_TYPE_LSB)
-#define GPIO_PIN11_INT_TYPE_SET(x)               (((x) << GPIO_PIN11_INT_TYPE_LSB) & GPIO_PIN11_INT_TYPE_MASK)
-#define GPIO_PIN11_PAD_DRIVER_MSB                2
-#define GPIO_PIN11_PAD_DRIVER_LSB                2
-#define GPIO_PIN11_PAD_DRIVER_MASK               0x00000004
-#define GPIO_PIN11_PAD_DRIVER_GET(x)             (((x) & GPIO_PIN11_PAD_DRIVER_MASK) >> GPIO_PIN11_PAD_DRIVER_LSB)
-#define GPIO_PIN11_PAD_DRIVER_SET(x)             (((x) << GPIO_PIN11_PAD_DRIVER_LSB) & GPIO_PIN11_PAD_DRIVER_MASK)
-#define GPIO_PIN11_SOURCE_MSB                    0
-#define GPIO_PIN11_SOURCE_LSB                    0
-#define GPIO_PIN11_SOURCE_MASK                   0x00000001
-#define GPIO_PIN11_SOURCE_GET(x)                 (((x) & GPIO_PIN11_SOURCE_MASK) >> GPIO_PIN11_SOURCE_LSB)
-#define GPIO_PIN11_SOURCE_SET(x)                 (((x) << GPIO_PIN11_SOURCE_LSB) & GPIO_PIN11_SOURCE_MASK)
-
-#define GPIO_PIN12_ADDRESS                       0x00000058
-#define GPIO_PIN12_OFFSET                        0x00000058
-#define GPIO_PIN12_CONFIG_MSB                    12
-#define GPIO_PIN12_CONFIG_LSB                    11
-#define GPIO_PIN12_CONFIG_MASK                   0x00001800
-#define GPIO_PIN12_CONFIG_GET(x)                 (((x) & GPIO_PIN12_CONFIG_MASK) >> GPIO_PIN12_CONFIG_LSB)
-#define GPIO_PIN12_CONFIG_SET(x)                 (((x) << GPIO_PIN12_CONFIG_LSB) & GPIO_PIN12_CONFIG_MASK)
-#define GPIO_PIN12_WAKEUP_ENABLE_MSB             10
-#define GPIO_PIN12_WAKEUP_ENABLE_LSB             10
-#define GPIO_PIN12_WAKEUP_ENABLE_MASK            0x00000400
-#define GPIO_PIN12_WAKEUP_ENABLE_GET(x)          (((x) & GPIO_PIN12_WAKEUP_ENABLE_MASK) >> GPIO_PIN12_WAKEUP_ENABLE_LSB)
-#define GPIO_PIN12_WAKEUP_ENABLE_SET(x)          (((x) << GPIO_PIN12_WAKEUP_ENABLE_LSB) & GPIO_PIN12_WAKEUP_ENABLE_MASK)
-#define GPIO_PIN12_INT_TYPE_MSB                  9
-#define GPIO_PIN12_INT_TYPE_LSB                  7
-#define GPIO_PIN12_INT_TYPE_MASK                 0x00000380
-#define GPIO_PIN12_INT_TYPE_GET(x)               (((x) & GPIO_PIN12_INT_TYPE_MASK) >> GPIO_PIN12_INT_TYPE_LSB)
-#define GPIO_PIN12_INT_TYPE_SET(x)               (((x) << GPIO_PIN12_INT_TYPE_LSB) & GPIO_PIN12_INT_TYPE_MASK)
-#define GPIO_PIN12_PAD_DRIVER_MSB                2
-#define GPIO_PIN12_PAD_DRIVER_LSB                2
-#define GPIO_PIN12_PAD_DRIVER_MASK               0x00000004
-#define GPIO_PIN12_PAD_DRIVER_GET(x)             (((x) & GPIO_PIN12_PAD_DRIVER_MASK) >> GPIO_PIN12_PAD_DRIVER_LSB)
-#define GPIO_PIN12_PAD_DRIVER_SET(x)             (((x) << GPIO_PIN12_PAD_DRIVER_LSB) & GPIO_PIN12_PAD_DRIVER_MASK)
-#define GPIO_PIN12_SOURCE_MSB                    0
-#define GPIO_PIN12_SOURCE_LSB                    0
-#define GPIO_PIN12_SOURCE_MASK                   0x00000001
-#define GPIO_PIN12_SOURCE_GET(x)                 (((x) & GPIO_PIN12_SOURCE_MASK) >> GPIO_PIN12_SOURCE_LSB)
-#define GPIO_PIN12_SOURCE_SET(x)                 (((x) << GPIO_PIN12_SOURCE_LSB) & GPIO_PIN12_SOURCE_MASK)
-
-#define GPIO_PIN13_ADDRESS                       0x0000005c
-#define GPIO_PIN13_OFFSET                        0x0000005c
-#define GPIO_PIN13_CONFIG_MSB                    12
-#define GPIO_PIN13_CONFIG_LSB                    11
-#define GPIO_PIN13_CONFIG_MASK                   0x00001800
-#define GPIO_PIN13_CONFIG_GET(x)                 (((x) & GPIO_PIN13_CONFIG_MASK) >> GPIO_PIN13_CONFIG_LSB)
-#define GPIO_PIN13_CONFIG_SET(x)                 (((x) << GPIO_PIN13_CONFIG_LSB) & GPIO_PIN13_CONFIG_MASK)
-#define GPIO_PIN13_WAKEUP_ENABLE_MSB             10
-#define GPIO_PIN13_WAKEUP_ENABLE_LSB             10
-#define GPIO_PIN13_WAKEUP_ENABLE_MASK            0x00000400
-#define GPIO_PIN13_WAKEUP_ENABLE_GET(x)          (((x) & GPIO_PIN13_WAKEUP_ENABLE_MASK) >> GPIO_PIN13_WAKEUP_ENABLE_LSB)
-#define GPIO_PIN13_WAKEUP_ENABLE_SET(x)          (((x) << GPIO_PIN13_WAKEUP_ENABLE_LSB) & GPIO_PIN13_WAKEUP_ENABLE_MASK)
-#define GPIO_PIN13_INT_TYPE_MSB                  9
-#define GPIO_PIN13_INT_TYPE_LSB                  7
-#define GPIO_PIN13_INT_TYPE_MASK                 0x00000380
-#define GPIO_PIN13_INT_TYPE_GET(x)               (((x) & GPIO_PIN13_INT_TYPE_MASK) >> GPIO_PIN13_INT_TYPE_LSB)
-#define GPIO_PIN13_INT_TYPE_SET(x)               (((x) << GPIO_PIN13_INT_TYPE_LSB) & GPIO_PIN13_INT_TYPE_MASK)
-#define GPIO_PIN13_PAD_DRIVER_MSB                2
-#define GPIO_PIN13_PAD_DRIVER_LSB                2
-#define GPIO_PIN13_PAD_DRIVER_MASK               0x00000004
-#define GPIO_PIN13_PAD_DRIVER_GET(x)             (((x) & GPIO_PIN13_PAD_DRIVER_MASK) >> GPIO_PIN13_PAD_DRIVER_LSB)
-#define GPIO_PIN13_PAD_DRIVER_SET(x)             (((x) << GPIO_PIN13_PAD_DRIVER_LSB) & GPIO_PIN13_PAD_DRIVER_MASK)
-#define GPIO_PIN13_SOURCE_MSB                    0
-#define GPIO_PIN13_SOURCE_LSB                    0
-#define GPIO_PIN13_SOURCE_MASK                   0x00000001
-#define GPIO_PIN13_SOURCE_GET(x)                 (((x) & GPIO_PIN13_SOURCE_MASK) >> GPIO_PIN13_SOURCE_LSB)
-#define GPIO_PIN13_SOURCE_SET(x)                 (((x) << GPIO_PIN13_SOURCE_LSB) & GPIO_PIN13_SOURCE_MASK)
-
-#define GPIO_PIN14_ADDRESS                       0x00000060
-#define GPIO_PIN14_OFFSET                        0x00000060
-#define GPIO_PIN14_CONFIG_MSB                    12
-#define GPIO_PIN14_CONFIG_LSB                    11
-#define GPIO_PIN14_CONFIG_MASK                   0x00001800
-#define GPIO_PIN14_CONFIG_GET(x)                 (((x) & GPIO_PIN14_CONFIG_MASK) >> GPIO_PIN14_CONFIG_LSB)
-#define GPIO_PIN14_CONFIG_SET(x)                 (((x) << GPIO_PIN14_CONFIG_LSB) & GPIO_PIN14_CONFIG_MASK)
-#define GPIO_PIN14_WAKEUP_ENABLE_MSB             10
-#define GPIO_PIN14_WAKEUP_ENABLE_LSB             10
-#define GPIO_PIN14_WAKEUP_ENABLE_MASK            0x00000400
-#define GPIO_PIN14_WAKEUP_ENABLE_GET(x)          (((x) & GPIO_PIN14_WAKEUP_ENABLE_MASK) >> GPIO_PIN14_WAKEUP_ENABLE_LSB)
-#define GPIO_PIN14_WAKEUP_ENABLE_SET(x)          (((x) << GPIO_PIN14_WAKEUP_ENABLE_LSB) & GPIO_PIN14_WAKEUP_ENABLE_MASK)
-#define GPIO_PIN14_INT_TYPE_MSB                  9
-#define GPIO_PIN14_INT_TYPE_LSB                  7
-#define GPIO_PIN14_INT_TYPE_MASK                 0x00000380
-#define GPIO_PIN14_INT_TYPE_GET(x)               (((x) & GPIO_PIN14_INT_TYPE_MASK) >> GPIO_PIN14_INT_TYPE_LSB)
-#define GPIO_PIN14_INT_TYPE_SET(x)               (((x) << GPIO_PIN14_INT_TYPE_LSB) & GPIO_PIN14_INT_TYPE_MASK)
-#define GPIO_PIN14_PAD_DRIVER_MSB                2
-#define GPIO_PIN14_PAD_DRIVER_LSB                2
-#define GPIO_PIN14_PAD_DRIVER_MASK               0x00000004
-#define GPIO_PIN14_PAD_DRIVER_GET(x)             (((x) & GPIO_PIN14_PAD_DRIVER_MASK) >> GPIO_PIN14_PAD_DRIVER_LSB)
-#define GPIO_PIN14_PAD_DRIVER_SET(x)             (((x) << GPIO_PIN14_PAD_DRIVER_LSB) & GPIO_PIN14_PAD_DRIVER_MASK)
-#define GPIO_PIN14_SOURCE_MSB                    0
-#define GPIO_PIN14_SOURCE_LSB                    0
-#define GPIO_PIN14_SOURCE_MASK                   0x00000001
-#define GPIO_PIN14_SOURCE_GET(x)                 (((x) & GPIO_PIN14_SOURCE_MASK) >> GPIO_PIN14_SOURCE_LSB)
-#define GPIO_PIN14_SOURCE_SET(x)                 (((x) << GPIO_PIN14_SOURCE_LSB) & GPIO_PIN14_SOURCE_MASK)
-
-#define GPIO_PIN15_ADDRESS                       0x00000064
-#define GPIO_PIN15_OFFSET                        0x00000064
-#define GPIO_PIN15_CONFIG_MSB                    12
-#define GPIO_PIN15_CONFIG_LSB                    11
-#define GPIO_PIN15_CONFIG_MASK                   0x00001800
-#define GPIO_PIN15_CONFIG_GET(x)                 (((x) & GPIO_PIN15_CONFIG_MASK) >> GPIO_PIN15_CONFIG_LSB)
-#define GPIO_PIN15_CONFIG_SET(x)                 (((x) << GPIO_PIN15_CONFIG_LSB) & GPIO_PIN15_CONFIG_MASK)
-#define GPIO_PIN15_WAKEUP_ENABLE_MSB             10
-#define GPIO_PIN15_WAKEUP_ENABLE_LSB             10
-#define GPIO_PIN15_WAKEUP_ENABLE_MASK            0x00000400
-#define GPIO_PIN15_WAKEUP_ENABLE_GET(x)          (((x) & GPIO_PIN15_WAKEUP_ENABLE_MASK) >> GPIO_PIN15_WAKEUP_ENABLE_LSB)
-#define GPIO_PIN15_WAKEUP_ENABLE_SET(x)          (((x) << GPIO_PIN15_WAKEUP_ENABLE_LSB) & GPIO_PIN15_WAKEUP_ENABLE_MASK)
-#define GPIO_PIN15_INT_TYPE_MSB                  9
-#define GPIO_PIN15_INT_TYPE_LSB                  7
-#define GPIO_PIN15_INT_TYPE_MASK                 0x00000380
-#define GPIO_PIN15_INT_TYPE_GET(x)               (((x) & GPIO_PIN15_INT_TYPE_MASK) >> GPIO_PIN15_INT_TYPE_LSB)
-#define GPIO_PIN15_INT_TYPE_SET(x)               (((x) << GPIO_PIN15_INT_TYPE_LSB) & GPIO_PIN15_INT_TYPE_MASK)
-#define GPIO_PIN15_PAD_DRIVER_MSB                2
-#define GPIO_PIN15_PAD_DRIVER_LSB                2
-#define GPIO_PIN15_PAD_DRIVER_MASK               0x00000004
-#define GPIO_PIN15_PAD_DRIVER_GET(x)             (((x) & GPIO_PIN15_PAD_DRIVER_MASK) >> GPIO_PIN15_PAD_DRIVER_LSB)
-#define GPIO_PIN15_PAD_DRIVER_SET(x)             (((x) << GPIO_PIN15_PAD_DRIVER_LSB) & GPIO_PIN15_PAD_DRIVER_MASK)
-#define GPIO_PIN15_SOURCE_MSB                    0
-#define GPIO_PIN15_SOURCE_LSB                    0
-#define GPIO_PIN15_SOURCE_MASK                   0x00000001
-#define GPIO_PIN15_SOURCE_GET(x)                 (((x) & GPIO_PIN15_SOURCE_MASK) >> GPIO_PIN15_SOURCE_LSB)
-#define GPIO_PIN15_SOURCE_SET(x)                 (((x) << GPIO_PIN15_SOURCE_LSB) & GPIO_PIN15_SOURCE_MASK)
-
-#define GPIO_PIN16_ADDRESS                       0x00000068
-#define GPIO_PIN16_OFFSET                        0x00000068
-#define GPIO_PIN16_CONFIG_MSB                    12
-#define GPIO_PIN16_CONFIG_LSB                    11
-#define GPIO_PIN16_CONFIG_MASK                   0x00001800
-#define GPIO_PIN16_CONFIG_GET(x)                 (((x) & GPIO_PIN16_CONFIG_MASK) >> GPIO_PIN16_CONFIG_LSB)
-#define GPIO_PIN16_CONFIG_SET(x)                 (((x) << GPIO_PIN16_CONFIG_LSB) & GPIO_PIN16_CONFIG_MASK)
-#define GPIO_PIN16_WAKEUP_ENABLE_MSB             10
-#define GPIO_PIN16_WAKEUP_ENABLE_LSB             10
-#define GPIO_PIN16_WAKEUP_ENABLE_MASK            0x00000400
-#define GPIO_PIN16_WAKEUP_ENABLE_GET(x)          (((x) & GPIO_PIN16_WAKEUP_ENABLE_MASK) >> GPIO_PIN16_WAKEUP_ENABLE_LSB)
-#define GPIO_PIN16_WAKEUP_ENABLE_SET(x)          (((x) << GPIO_PIN16_WAKEUP_ENABLE_LSB) & GPIO_PIN16_WAKEUP_ENABLE_MASK)
-#define GPIO_PIN16_INT_TYPE_MSB                  9
-#define GPIO_PIN16_INT_TYPE_LSB                  7
-#define GPIO_PIN16_INT_TYPE_MASK                 0x00000380
-#define GPIO_PIN16_INT_TYPE_GET(x)               (((x) & GPIO_PIN16_INT_TYPE_MASK) >> GPIO_PIN16_INT_TYPE_LSB)
-#define GPIO_PIN16_INT_TYPE_SET(x)               (((x) << GPIO_PIN16_INT_TYPE_LSB) & GPIO_PIN16_INT_TYPE_MASK)
-#define GPIO_PIN16_PAD_DRIVER_MSB                2
-#define GPIO_PIN16_PAD_DRIVER_LSB                2
-#define GPIO_PIN16_PAD_DRIVER_MASK               0x00000004
-#define GPIO_PIN16_PAD_DRIVER_GET(x)             (((x) & GPIO_PIN16_PAD_DRIVER_MASK) >> GPIO_PIN16_PAD_DRIVER_LSB)
-#define GPIO_PIN16_PAD_DRIVER_SET(x)             (((x) << GPIO_PIN16_PAD_DRIVER_LSB) & GPIO_PIN16_PAD_DRIVER_MASK)
-#define GPIO_PIN16_SOURCE_MSB                    0
-#define GPIO_PIN16_SOURCE_LSB                    0
-#define GPIO_PIN16_SOURCE_MASK                   0x00000001
-#define GPIO_PIN16_SOURCE_GET(x)                 (((x) & GPIO_PIN16_SOURCE_MASK) >> GPIO_PIN16_SOURCE_LSB)
-#define GPIO_PIN16_SOURCE_SET(x)                 (((x) << GPIO_PIN16_SOURCE_LSB) & GPIO_PIN16_SOURCE_MASK)
-
-#define GPIO_PIN17_ADDRESS                       0x0000006c
-#define GPIO_PIN17_OFFSET                        0x0000006c
-#define GPIO_PIN17_CONFIG_MSB                    12
-#define GPIO_PIN17_CONFIG_LSB                    11
-#define GPIO_PIN17_CONFIG_MASK                   0x00001800
-#define GPIO_PIN17_CONFIG_GET(x)                 (((x) & GPIO_PIN17_CONFIG_MASK) >> GPIO_PIN17_CONFIG_LSB)
-#define GPIO_PIN17_CONFIG_SET(x)                 (((x) << GPIO_PIN17_CONFIG_LSB) & GPIO_PIN17_CONFIG_MASK)
-#define GPIO_PIN17_WAKEUP_ENABLE_MSB             10
-#define GPIO_PIN17_WAKEUP_ENABLE_LSB             10
-#define GPIO_PIN17_WAKEUP_ENABLE_MASK            0x00000400
-#define GPIO_PIN17_WAKEUP_ENABLE_GET(x)          (((x) & GPIO_PIN17_WAKEUP_ENABLE_MASK) >> GPIO_PIN17_WAKEUP_ENABLE_LSB)
-#define GPIO_PIN17_WAKEUP_ENABLE_SET(x)          (((x) << GPIO_PIN17_WAKEUP_ENABLE_LSB) & GPIO_PIN17_WAKEUP_ENABLE_MASK)
-#define GPIO_PIN17_INT_TYPE_MSB                  9
-#define GPIO_PIN17_INT_TYPE_LSB                  7
-#define GPIO_PIN17_INT_TYPE_MASK                 0x00000380
-#define GPIO_PIN17_INT_TYPE_GET(x)               (((x) & GPIO_PIN17_INT_TYPE_MASK) >> GPIO_PIN17_INT_TYPE_LSB)
-#define GPIO_PIN17_INT_TYPE_SET(x)               (((x) << GPIO_PIN17_INT_TYPE_LSB) & GPIO_PIN17_INT_TYPE_MASK)
-#define GPIO_PIN17_PAD_DRIVER_MSB                2
-#define GPIO_PIN17_PAD_DRIVER_LSB                2
-#define GPIO_PIN17_PAD_DRIVER_MASK               0x00000004
-#define GPIO_PIN17_PAD_DRIVER_GET(x)             (((x) & GPIO_PIN17_PAD_DRIVER_MASK) >> GPIO_PIN17_PAD_DRIVER_LSB)
-#define GPIO_PIN17_PAD_DRIVER_SET(x)             (((x) << GPIO_PIN17_PAD_DRIVER_LSB) & GPIO_PIN17_PAD_DRIVER_MASK)
-#define GPIO_PIN17_SOURCE_MSB                    0
-#define GPIO_PIN17_SOURCE_LSB                    0
-#define GPIO_PIN17_SOURCE_MASK                   0x00000001
-#define GPIO_PIN17_SOURCE_GET(x)                 (((x) & GPIO_PIN17_SOURCE_MASK) >> GPIO_PIN17_SOURCE_LSB)
-#define GPIO_PIN17_SOURCE_SET(x)                 (((x) << GPIO_PIN17_SOURCE_LSB) & GPIO_PIN17_SOURCE_MASK)
-
-#define SDIO_PIN_ADDRESS                         0x00000070
-#define SDIO_PIN_OFFSET                          0x00000070
-#define SDIO_PIN_PAD_PULL_MSB                    3
-#define SDIO_PIN_PAD_PULL_LSB                    2
-#define SDIO_PIN_PAD_PULL_MASK                   0x0000000c
-#define SDIO_PIN_PAD_PULL_GET(x)                 (((x) & SDIO_PIN_PAD_PULL_MASK) >> SDIO_PIN_PAD_PULL_LSB)
-#define SDIO_PIN_PAD_PULL_SET(x)                 (((x) << SDIO_PIN_PAD_PULL_LSB) & SDIO_PIN_PAD_PULL_MASK)
-#define SDIO_PIN_PAD_STRENGTH_MSB                1
-#define SDIO_PIN_PAD_STRENGTH_LSB                0
-#define SDIO_PIN_PAD_STRENGTH_MASK               0x00000003
-#define SDIO_PIN_PAD_STRENGTH_GET(x)             (((x) & SDIO_PIN_PAD_STRENGTH_MASK) >> SDIO_PIN_PAD_STRENGTH_LSB)
-#define SDIO_PIN_PAD_STRENGTH_SET(x)             (((x) << SDIO_PIN_PAD_STRENGTH_LSB) & SDIO_PIN_PAD_STRENGTH_MASK)
-
-#define CLK_REQ_PIN_ADDRESS                      0x00000074
-#define CLK_REQ_PIN_OFFSET                       0x00000074
-#define CLK_REQ_PIN_ATE_OE_L_MSB                 4
-#define CLK_REQ_PIN_ATE_OE_L_LSB                 4
-#define CLK_REQ_PIN_ATE_OE_L_MASK                0x00000010
-#define CLK_REQ_PIN_ATE_OE_L_GET(x)              (((x) & CLK_REQ_PIN_ATE_OE_L_MASK) >> CLK_REQ_PIN_ATE_OE_L_LSB)
-#define CLK_REQ_PIN_ATE_OE_L_SET(x)              (((x) << CLK_REQ_PIN_ATE_OE_L_LSB) & CLK_REQ_PIN_ATE_OE_L_MASK)
-#define CLK_REQ_PIN_PAD_PULL_MSB                 3
-#define CLK_REQ_PIN_PAD_PULL_LSB                 2
-#define CLK_REQ_PIN_PAD_PULL_MASK                0x0000000c
-#define CLK_REQ_PIN_PAD_PULL_GET(x)              (((x) & CLK_REQ_PIN_PAD_PULL_MASK) >> CLK_REQ_PIN_PAD_PULL_LSB)
-#define CLK_REQ_PIN_PAD_PULL_SET(x)              (((x) << CLK_REQ_PIN_PAD_PULL_LSB) & CLK_REQ_PIN_PAD_PULL_MASK)
-#define CLK_REQ_PIN_PAD_STRENGTH_MSB             1
-#define CLK_REQ_PIN_PAD_STRENGTH_LSB             0
-#define CLK_REQ_PIN_PAD_STRENGTH_MASK            0x00000003
-#define CLK_REQ_PIN_PAD_STRENGTH_GET(x)          (((x) & CLK_REQ_PIN_PAD_STRENGTH_MASK) >> CLK_REQ_PIN_PAD_STRENGTH_LSB)
-#define CLK_REQ_PIN_PAD_STRENGTH_SET(x)          (((x) << CLK_REQ_PIN_PAD_STRENGTH_LSB) & CLK_REQ_PIN_PAD_STRENGTH_MASK)
-
-#define SIGMA_DELTA_ADDRESS                      0x00000078
-#define SIGMA_DELTA_OFFSET                       0x00000078
-#define SIGMA_DELTA_ENABLE_MSB                   16
-#define SIGMA_DELTA_ENABLE_LSB                   16
-#define SIGMA_DELTA_ENABLE_MASK                  0x00010000
-#define SIGMA_DELTA_ENABLE_GET(x)                (((x) & SIGMA_DELTA_ENABLE_MASK) >> SIGMA_DELTA_ENABLE_LSB)
-#define SIGMA_DELTA_ENABLE_SET(x)                (((x) << SIGMA_DELTA_ENABLE_LSB) & SIGMA_DELTA_ENABLE_MASK)
-#define SIGMA_DELTA_PRESCALAR_MSB                15
-#define SIGMA_DELTA_PRESCALAR_LSB                8
-#define SIGMA_DELTA_PRESCALAR_MASK               0x0000ff00
-#define SIGMA_DELTA_PRESCALAR_GET(x)             (((x) & SIGMA_DELTA_PRESCALAR_MASK) >> SIGMA_DELTA_PRESCALAR_LSB)
-#define SIGMA_DELTA_PRESCALAR_SET(x)             (((x) << SIGMA_DELTA_PRESCALAR_LSB) & SIGMA_DELTA_PRESCALAR_MASK)
-#define SIGMA_DELTA_TARGET_MSB                   7
-#define SIGMA_DELTA_TARGET_LSB                   0
-#define SIGMA_DELTA_TARGET_MASK                  0x000000ff
-#define SIGMA_DELTA_TARGET_GET(x)                (((x) & SIGMA_DELTA_TARGET_MASK) >> SIGMA_DELTA_TARGET_LSB)
-#define SIGMA_DELTA_TARGET_SET(x)                (((x) << SIGMA_DELTA_TARGET_LSB) & SIGMA_DELTA_TARGET_MASK)
-
-#define DEBUG_CONTROL_ADDRESS                    0x0000007c
-#define DEBUG_CONTROL_OFFSET                     0x0000007c
-#define DEBUG_CONTROL_OBS_OE_L_MSB               1
-#define DEBUG_CONTROL_OBS_OE_L_LSB               1
-#define DEBUG_CONTROL_OBS_OE_L_MASK              0x00000002
-#define DEBUG_CONTROL_OBS_OE_L_GET(x)            (((x) & DEBUG_CONTROL_OBS_OE_L_MASK) >> DEBUG_CONTROL_OBS_OE_L_LSB)
-#define DEBUG_CONTROL_OBS_OE_L_SET(x)            (((x) << DEBUG_CONTROL_OBS_OE_L_LSB) & DEBUG_CONTROL_OBS_OE_L_MASK)
-#define DEBUG_CONTROL_ENABLE_MSB                 0
-#define DEBUG_CONTROL_ENABLE_LSB                 0
-#define DEBUG_CONTROL_ENABLE_MASK                0x00000001
-#define DEBUG_CONTROL_ENABLE_GET(x)              (((x) & DEBUG_CONTROL_ENABLE_MASK) >> DEBUG_CONTROL_ENABLE_LSB)
-#define DEBUG_CONTROL_ENABLE_SET(x)              (((x) << DEBUG_CONTROL_ENABLE_LSB) & DEBUG_CONTROL_ENABLE_MASK)
-
-#define DEBUG_INPUT_SEL_ADDRESS                  0x00000080
-#define DEBUG_INPUT_SEL_OFFSET                   0x00000080
-#define DEBUG_INPUT_SEL_SRC_MSB                  3
-#define DEBUG_INPUT_SEL_SRC_LSB                  0
-#define DEBUG_INPUT_SEL_SRC_MASK                 0x0000000f
-#define DEBUG_INPUT_SEL_SRC_GET(x)               (((x) & DEBUG_INPUT_SEL_SRC_MASK) >> DEBUG_INPUT_SEL_SRC_LSB)
-#define DEBUG_INPUT_SEL_SRC_SET(x)               (((x) << DEBUG_INPUT_SEL_SRC_LSB) & DEBUG_INPUT_SEL_SRC_MASK)
-
-#define DEBUG_OUT_ADDRESS                        0x00000084
-#define DEBUG_OUT_OFFSET                         0x00000084
-#define DEBUG_OUT_DATA_MSB                       17
-#define DEBUG_OUT_DATA_LSB                       0
-#define DEBUG_OUT_DATA_MASK                      0x0003ffff
-#define DEBUG_OUT_DATA_GET(x)                    (((x) & DEBUG_OUT_DATA_MASK) >> DEBUG_OUT_DATA_LSB)
-#define DEBUG_OUT_DATA_SET(x)                    (((x) << DEBUG_OUT_DATA_LSB) & DEBUG_OUT_DATA_MASK)
-
-#define LA_CONTROL_ADDRESS                       0x00000088
-#define LA_CONTROL_OFFSET                        0x00000088
-#define LA_CONTROL_RUN_MSB                       1
-#define LA_CONTROL_RUN_LSB                       1
-#define LA_CONTROL_RUN_MASK                      0x00000002
-#define LA_CONTROL_RUN_GET(x)                    (((x) & LA_CONTROL_RUN_MASK) >> LA_CONTROL_RUN_LSB)
-#define LA_CONTROL_RUN_SET(x)                    (((x) << LA_CONTROL_RUN_LSB) & LA_CONTROL_RUN_MASK)
-#define LA_CONTROL_TRIGGERED_MSB                 0
-#define LA_CONTROL_TRIGGERED_LSB                 0
-#define LA_CONTROL_TRIGGERED_MASK                0x00000001
-#define LA_CONTROL_TRIGGERED_GET(x)              (((x) & LA_CONTROL_TRIGGERED_MASK) >> LA_CONTROL_TRIGGERED_LSB)
-#define LA_CONTROL_TRIGGERED_SET(x)              (((x) << LA_CONTROL_TRIGGERED_LSB) & LA_CONTROL_TRIGGERED_MASK)
-
-#define LA_CLOCK_ADDRESS                         0x0000008c
-#define LA_CLOCK_OFFSET                          0x0000008c
-#define LA_CLOCK_DIV_MSB                         7
-#define LA_CLOCK_DIV_LSB                         0
-#define LA_CLOCK_DIV_MASK                        0x000000ff
-#define LA_CLOCK_DIV_GET(x)                      (((x) & LA_CLOCK_DIV_MASK) >> LA_CLOCK_DIV_LSB)
-#define LA_CLOCK_DIV_SET(x)                      (((x) << LA_CLOCK_DIV_LSB) & LA_CLOCK_DIV_MASK)
-
-#define LA_STATUS_ADDRESS                        0x00000090
-#define LA_STATUS_OFFSET                         0x00000090
-#define LA_STATUS_INTERRUPT_MSB                  0
-#define LA_STATUS_INTERRUPT_LSB                  0
-#define LA_STATUS_INTERRUPT_MASK                 0x00000001
-#define LA_STATUS_INTERRUPT_GET(x)               (((x) & LA_STATUS_INTERRUPT_MASK) >> LA_STATUS_INTERRUPT_LSB)
-#define LA_STATUS_INTERRUPT_SET(x)               (((x) << LA_STATUS_INTERRUPT_LSB) & LA_STATUS_INTERRUPT_MASK)
-
-#define LA_TRIGGER_SAMPLE_ADDRESS                0x00000094
-#define LA_TRIGGER_SAMPLE_OFFSET                 0x00000094
-#define LA_TRIGGER_SAMPLE_COUNT_MSB              15
-#define LA_TRIGGER_SAMPLE_COUNT_LSB              0
-#define LA_TRIGGER_SAMPLE_COUNT_MASK             0x0000ffff
-#define LA_TRIGGER_SAMPLE_COUNT_GET(x)           (((x) & LA_TRIGGER_SAMPLE_COUNT_MASK) >> LA_TRIGGER_SAMPLE_COUNT_LSB)
-#define LA_TRIGGER_SAMPLE_COUNT_SET(x)           (((x) << LA_TRIGGER_SAMPLE_COUNT_LSB) & LA_TRIGGER_SAMPLE_COUNT_MASK)
-
-#define LA_TRIGGER_POSITION_ADDRESS              0x00000098
-#define LA_TRIGGER_POSITION_OFFSET               0x00000098
-#define LA_TRIGGER_POSITION_VALUE_MSB            15
-#define LA_TRIGGER_POSITION_VALUE_LSB            0
-#define LA_TRIGGER_POSITION_VALUE_MASK           0x0000ffff
-#define LA_TRIGGER_POSITION_VALUE_GET(x)         (((x) & LA_TRIGGER_POSITION_VALUE_MASK) >> LA_TRIGGER_POSITION_VALUE_LSB)
-#define LA_TRIGGER_POSITION_VALUE_SET(x)         (((x) << LA_TRIGGER_POSITION_VALUE_LSB) & LA_TRIGGER_POSITION_VALUE_MASK)
-
-#define LA_PRE_TRIGGER_ADDRESS                   0x0000009c
-#define LA_PRE_TRIGGER_OFFSET                    0x0000009c
-#define LA_PRE_TRIGGER_COUNT_MSB                 15
-#define LA_PRE_TRIGGER_COUNT_LSB                 0
-#define LA_PRE_TRIGGER_COUNT_MASK                0x0000ffff
-#define LA_PRE_TRIGGER_COUNT_GET(x)              (((x) & LA_PRE_TRIGGER_COUNT_MASK) >> LA_PRE_TRIGGER_COUNT_LSB)
-#define LA_PRE_TRIGGER_COUNT_SET(x)              (((x) << LA_PRE_TRIGGER_COUNT_LSB) & LA_PRE_TRIGGER_COUNT_MASK)
-
-#define LA_POST_TRIGGER_ADDRESS                  0x000000a0
-#define LA_POST_TRIGGER_OFFSET                   0x000000a0
-#define LA_POST_TRIGGER_COUNT_MSB                15
-#define LA_POST_TRIGGER_COUNT_LSB                0
-#define LA_POST_TRIGGER_COUNT_MASK               0x0000ffff
-#define LA_POST_TRIGGER_COUNT_GET(x)             (((x) & LA_POST_TRIGGER_COUNT_MASK) >> LA_POST_TRIGGER_COUNT_LSB)
-#define LA_POST_TRIGGER_COUNT_SET(x)             (((x) << LA_POST_TRIGGER_COUNT_LSB) & LA_POST_TRIGGER_COUNT_MASK)
-
-#define LA_FILTER_CONTROL_ADDRESS                0x000000a4
-#define LA_FILTER_CONTROL_OFFSET                 0x000000a4
-#define LA_FILTER_CONTROL_DELTA_MSB              0
-#define LA_FILTER_CONTROL_DELTA_LSB              0
-#define LA_FILTER_CONTROL_DELTA_MASK             0x00000001
-#define LA_FILTER_CONTROL_DELTA_GET(x)           (((x) & LA_FILTER_CONTROL_DELTA_MASK) >> LA_FILTER_CONTROL_DELTA_LSB)
-#define LA_FILTER_CONTROL_DELTA_SET(x)           (((x) << LA_FILTER_CONTROL_DELTA_LSB) & LA_FILTER_CONTROL_DELTA_MASK)
-
-#define LA_FILTER_DATA_ADDRESS                   0x000000a8
-#define LA_FILTER_DATA_OFFSET                    0x000000a8
-#define LA_FILTER_DATA_MATCH_MSB                 17
-#define LA_FILTER_DATA_MATCH_LSB                 0
-#define LA_FILTER_DATA_MATCH_MASK                0x0003ffff
-#define LA_FILTER_DATA_MATCH_GET(x)              (((x) & LA_FILTER_DATA_MATCH_MASK) >> LA_FILTER_DATA_MATCH_LSB)
-#define LA_FILTER_DATA_MATCH_SET(x)              (((x) << LA_FILTER_DATA_MATCH_LSB) & LA_FILTER_DATA_MATCH_MASK)
-
-#define LA_FILTER_WILDCARD_ADDRESS               0x000000ac
-#define LA_FILTER_WILDCARD_OFFSET                0x000000ac
-#define LA_FILTER_WILDCARD_MATCH_MSB             17
-#define LA_FILTER_WILDCARD_MATCH_LSB             0
-#define LA_FILTER_WILDCARD_MATCH_MASK            0x0003ffff
-#define LA_FILTER_WILDCARD_MATCH_GET(x)          (((x) & LA_FILTER_WILDCARD_MATCH_MASK) >> LA_FILTER_WILDCARD_MATCH_LSB)
-#define LA_FILTER_WILDCARD_MATCH_SET(x)          (((x) << LA_FILTER_WILDCARD_MATCH_LSB) & LA_FILTER_WILDCARD_MATCH_MASK)
-
-#define LA_TRIGGERA_DATA_ADDRESS                 0x000000b0
-#define LA_TRIGGERA_DATA_OFFSET                  0x000000b0
-#define LA_TRIGGERA_DATA_MATCH_MSB               17
-#define LA_TRIGGERA_DATA_MATCH_LSB               0
-#define LA_TRIGGERA_DATA_MATCH_MASK              0x0003ffff
-#define LA_TRIGGERA_DATA_MATCH_GET(x)            (((x) & LA_TRIGGERA_DATA_MATCH_MASK) >> LA_TRIGGERA_DATA_MATCH_LSB)
-#define LA_TRIGGERA_DATA_MATCH_SET(x)            (((x) << LA_TRIGGERA_DATA_MATCH_LSB) & LA_TRIGGERA_DATA_MATCH_MASK)
-
-#define LA_TRIGGERA_WILDCARD_ADDRESS             0x000000b4
-#define LA_TRIGGERA_WILDCARD_OFFSET              0x000000b4
-#define LA_TRIGGERA_WILDCARD_MATCH_MSB           17
-#define LA_TRIGGERA_WILDCARD_MATCH_LSB           0
-#define LA_TRIGGERA_WILDCARD_MATCH_MASK          0x0003ffff
-#define LA_TRIGGERA_WILDCARD_MATCH_GET(x)        (((x) & LA_TRIGGERA_WILDCARD_MATCH_MASK) >> LA_TRIGGERA_WILDCARD_MATCH_LSB)
-#define LA_TRIGGERA_WILDCARD_MATCH_SET(x)        (((x) << LA_TRIGGERA_WILDCARD_MATCH_LSB) & LA_TRIGGERA_WILDCARD_MATCH_MASK)
-
-#define LA_TRIGGERB_DATA_ADDRESS                 0x000000b8
-#define LA_TRIGGERB_DATA_OFFSET                  0x000000b8
-#define LA_TRIGGERB_DATA_MATCH_MSB               17
-#define LA_TRIGGERB_DATA_MATCH_LSB               0
-#define LA_TRIGGERB_DATA_MATCH_MASK              0x0003ffff
-#define LA_TRIGGERB_DATA_MATCH_GET(x)            (((x) & LA_TRIGGERB_DATA_MATCH_MASK) >> LA_TRIGGERB_DATA_MATCH_LSB)
-#define LA_TRIGGERB_DATA_MATCH_SET(x)            (((x) << LA_TRIGGERB_DATA_MATCH_LSB) & LA_TRIGGERB_DATA_MATCH_MASK)
-
-#define LA_TRIGGERB_WILDCARD_ADDRESS             0x000000bc
-#define LA_TRIGGERB_WILDCARD_OFFSET              0x000000bc
-#define LA_TRIGGERB_WILDCARD_MATCH_MSB           17
-#define LA_TRIGGERB_WILDCARD_MATCH_LSB           0
-#define LA_TRIGGERB_WILDCARD_MATCH_MASK          0x0003ffff
-#define LA_TRIGGERB_WILDCARD_MATCH_GET(x)        (((x) & LA_TRIGGERB_WILDCARD_MATCH_MASK) >> LA_TRIGGERB_WILDCARD_MATCH_LSB)
-#define LA_TRIGGERB_WILDCARD_MATCH_SET(x)        (((x) << LA_TRIGGERB_WILDCARD_MATCH_LSB) & LA_TRIGGERB_WILDCARD_MATCH_MASK)
-
-#define LA_TRIGGER_ADDRESS                       0x000000c0
-#define LA_TRIGGER_OFFSET                        0x000000c0
-#define LA_TRIGGER_EVENT_MSB                     2
-#define LA_TRIGGER_EVENT_LSB                     0
-#define LA_TRIGGER_EVENT_MASK                    0x00000007
-#define LA_TRIGGER_EVENT_GET(x)                  (((x) & LA_TRIGGER_EVENT_MASK) >> LA_TRIGGER_EVENT_LSB)
-#define LA_TRIGGER_EVENT_SET(x)                  (((x) << LA_TRIGGER_EVENT_LSB) & LA_TRIGGER_EVENT_MASK)
-
-#define LA_FIFO_ADDRESS                          0x000000c4
-#define LA_FIFO_OFFSET                           0x000000c4
-#define LA_FIFO_FULL_MSB                         1
-#define LA_FIFO_FULL_LSB                         1
-#define LA_FIFO_FULL_MASK                        0x00000002
-#define LA_FIFO_FULL_GET(x)                      (((x) & LA_FIFO_FULL_MASK) >> LA_FIFO_FULL_LSB)
-#define LA_FIFO_FULL_SET(x)                      (((x) << LA_FIFO_FULL_LSB) & LA_FIFO_FULL_MASK)
-#define LA_FIFO_EMPTY_MSB                        0
-#define LA_FIFO_EMPTY_LSB                        0
-#define LA_FIFO_EMPTY_MASK                       0x00000001
-#define LA_FIFO_EMPTY_GET(x)                     (((x) & LA_FIFO_EMPTY_MASK) >> LA_FIFO_EMPTY_LSB)
-#define LA_FIFO_EMPTY_SET(x)                     (((x) << LA_FIFO_EMPTY_LSB) & LA_FIFO_EMPTY_MASK)
-
-#define LA_ADDRESS                               0x000000c8
-#define LA_OFFSET                                0x000000c8
-#define LA_DATA_MSB                              17
-#define LA_DATA_LSB                              0
-#define LA_DATA_MASK                             0x0003ffff
-#define LA_DATA_GET(x)                           (((x) & LA_DATA_MASK) >> LA_DATA_LSB)
-#define LA_DATA_SET(x)                           (((x) << LA_DATA_LSB) & LA_DATA_MASK)
-
-#define ANT_PIN_ADDRESS                          0x000000d0
-#define ANT_PIN_OFFSET                           0x000000d0
-#define ANT_PIN_PAD_PULL_MSB                     3
-#define ANT_PIN_PAD_PULL_LSB                     2
-#define ANT_PIN_PAD_PULL_MASK                    0x0000000c
-#define ANT_PIN_PAD_PULL_GET(x)                  (((x) & ANT_PIN_PAD_PULL_MASK) >> ANT_PIN_PAD_PULL_LSB)
-#define ANT_PIN_PAD_PULL_SET(x)                  (((x) << ANT_PIN_PAD_PULL_LSB) & ANT_PIN_PAD_PULL_MASK)
-#define ANT_PIN_PAD_STRENGTH_MSB                 1
-#define ANT_PIN_PAD_STRENGTH_LSB                 0
-#define ANT_PIN_PAD_STRENGTH_MASK                0x00000003
-#define ANT_PIN_PAD_STRENGTH_GET(x)              (((x) & ANT_PIN_PAD_STRENGTH_MASK) >> ANT_PIN_PAD_STRENGTH_LSB)
-#define ANT_PIN_PAD_STRENGTH_SET(x)              (((x) << ANT_PIN_PAD_STRENGTH_LSB) & ANT_PIN_PAD_STRENGTH_MASK)
-
-#define ANTD_PIN_ADDRESS                         0x000000d4
-#define ANTD_PIN_OFFSET                          0x000000d4
-#define ANTD_PIN_PAD_PULL_MSB                    1
-#define ANTD_PIN_PAD_PULL_LSB                    0
-#define ANTD_PIN_PAD_PULL_MASK                   0x00000003
-#define ANTD_PIN_PAD_PULL_GET(x)                 (((x) & ANTD_PIN_PAD_PULL_MASK) >> ANTD_PIN_PAD_PULL_LSB)
-#define ANTD_PIN_PAD_PULL_SET(x)                 (((x) << ANTD_PIN_PAD_PULL_LSB) & ANTD_PIN_PAD_PULL_MASK)
-
-#define GPIO_PIN_ADDRESS                         0x000000d8
-#define GPIO_PIN_OFFSET                          0x000000d8
-#define GPIO_PIN_PAD_PULL_MSB                    3
-#define GPIO_PIN_PAD_PULL_LSB                    2
-#define GPIO_PIN_PAD_PULL_MASK                   0x0000000c
-#define GPIO_PIN_PAD_PULL_GET(x)                 (((x) & GPIO_PIN_PAD_PULL_MASK) >> GPIO_PIN_PAD_PULL_LSB)
-#define GPIO_PIN_PAD_PULL_SET(x)                 (((x) << GPIO_PIN_PAD_PULL_LSB) & GPIO_PIN_PAD_PULL_MASK)
-#define GPIO_PIN_PAD_STRENGTH_MSB                1
-#define GPIO_PIN_PAD_STRENGTH_LSB                0
-#define GPIO_PIN_PAD_STRENGTH_MASK               0x00000003
-#define GPIO_PIN_PAD_STRENGTH_GET(x)             (((x) & GPIO_PIN_PAD_STRENGTH_MASK) >> GPIO_PIN_PAD_STRENGTH_LSB)
-#define GPIO_PIN_PAD_STRENGTH_SET(x)             (((x) << GPIO_PIN_PAD_STRENGTH_LSB) & GPIO_PIN_PAD_STRENGTH_MASK)
-
-#define GPIO_H_PIN_ADDRESS                       0x000000dc
-#define GPIO_H_PIN_OFFSET                        0x000000dc
-#define GPIO_H_PIN_PAD_PULL_MSB                  1
-#define GPIO_H_PIN_PAD_PULL_LSB                  0
-#define GPIO_H_PIN_PAD_PULL_MASK                 0x00000003
-#define GPIO_H_PIN_PAD_PULL_GET(x)               (((x) & GPIO_H_PIN_PAD_PULL_MASK) >> GPIO_H_PIN_PAD_PULL_LSB)
-#define GPIO_H_PIN_PAD_PULL_SET(x)               (((x) << GPIO_H_PIN_PAD_PULL_LSB) & GPIO_H_PIN_PAD_PULL_MASK)
-
-#define BT_PIN_ADDRESS                           0x000000e0
-#define BT_PIN_OFFSET                            0x000000e0
-#define BT_PIN_PAD_PULL_MSB                      3
-#define BT_PIN_PAD_PULL_LSB                      2
-#define BT_PIN_PAD_PULL_MASK                     0x0000000c
-#define BT_PIN_PAD_PULL_GET(x)                   (((x) & BT_PIN_PAD_PULL_MASK) >> BT_PIN_PAD_PULL_LSB)
-#define BT_PIN_PAD_PULL_SET(x)                   (((x) << BT_PIN_PAD_PULL_LSB) & BT_PIN_PAD_PULL_MASK)
-#define BT_PIN_PAD_STRENGTH_MSB                  1
-#define BT_PIN_PAD_STRENGTH_LSB                  0
-#define BT_PIN_PAD_STRENGTH_MASK                 0x00000003
-#define BT_PIN_PAD_STRENGTH_GET(x)               (((x) & BT_PIN_PAD_STRENGTH_MASK) >> BT_PIN_PAD_STRENGTH_LSB)
-#define BT_PIN_PAD_STRENGTH_SET(x)               (((x) << BT_PIN_PAD_STRENGTH_LSB) & BT_PIN_PAD_STRENGTH_MASK)
-
-#define BT_WLAN_PIN_ADDRESS                      0x000000e4
-#define BT_WLAN_PIN_OFFSET                       0x000000e4
-#define BT_WLAN_PIN_PAD_PULL_MSB                 1
-#define BT_WLAN_PIN_PAD_PULL_LSB                 0
-#define BT_WLAN_PIN_PAD_PULL_MASK                0x00000003
-#define BT_WLAN_PIN_PAD_PULL_GET(x)              (((x) & BT_WLAN_PIN_PAD_PULL_MASK) >> BT_WLAN_PIN_PAD_PULL_LSB)
-#define BT_WLAN_PIN_PAD_PULL_SET(x)              (((x) << BT_WLAN_PIN_PAD_PULL_LSB) & BT_WLAN_PIN_PAD_PULL_MASK)
-
-#define SI_UART_PIN_ADDRESS                      0x000000e8
-#define SI_UART_PIN_OFFSET                       0x000000e8
-#define SI_UART_PIN_PAD_PULL_MSB                 3
-#define SI_UART_PIN_PAD_PULL_LSB                 2
-#define SI_UART_PIN_PAD_PULL_MASK                0x0000000c
-#define SI_UART_PIN_PAD_PULL_GET(x)              (((x) & SI_UART_PIN_PAD_PULL_MASK) >> SI_UART_PIN_PAD_PULL_LSB)
-#define SI_UART_PIN_PAD_PULL_SET(x)              (((x) << SI_UART_PIN_PAD_PULL_LSB) & SI_UART_PIN_PAD_PULL_MASK)
-#define SI_UART_PIN_PAD_STRENGTH_MSB             1
-#define SI_UART_PIN_PAD_STRENGTH_LSB             0
-#define SI_UART_PIN_PAD_STRENGTH_MASK            0x00000003
-#define SI_UART_PIN_PAD_STRENGTH_GET(x)          (((x) & SI_UART_PIN_PAD_STRENGTH_MASK) >> SI_UART_PIN_PAD_STRENGTH_LSB)
-#define SI_UART_PIN_PAD_STRENGTH_SET(x)          (((x) << SI_UART_PIN_PAD_STRENGTH_LSB) & SI_UART_PIN_PAD_STRENGTH_MASK)
-
-#define CLK32K_PIN_ADDRESS                       0x000000ec
-#define CLK32K_PIN_OFFSET                        0x000000ec
-#define CLK32K_PIN_PAD_PULL_MSB                  1
-#define CLK32K_PIN_PAD_PULL_LSB                  0
-#define CLK32K_PIN_PAD_PULL_MASK                 0x00000003
-#define CLK32K_PIN_PAD_PULL_GET(x)               (((x) & CLK32K_PIN_PAD_PULL_MASK) >> CLK32K_PIN_PAD_PULL_LSB)
-#define CLK32K_PIN_PAD_PULL_SET(x)               (((x) << CLK32K_PIN_PAD_PULL_LSB) & CLK32K_PIN_PAD_PULL_MASK)
-
-#define RESET_TUPLE_STATUS_ADDRESS               0x000000f0
-#define RESET_TUPLE_STATUS_OFFSET                0x000000f0
-#define RESET_TUPLE_STATUS_TEST_RESET_TUPLE_MSB  11
-#define RESET_TUPLE_STATUS_TEST_RESET_TUPLE_LSB  8
-#define RESET_TUPLE_STATUS_TEST_RESET_TUPLE_MASK 0x00000f00
-#define RESET_TUPLE_STATUS_TEST_RESET_TUPLE_GET(x) (((x) & RESET_TUPLE_STATUS_TEST_RESET_TUPLE_MASK) >> RESET_TUPLE_STATUS_TEST_RESET_TUPLE_LSB)
-#define RESET_TUPLE_STATUS_TEST_RESET_TUPLE_SET(x) (((x) << RESET_TUPLE_STATUS_TEST_RESET_TUPLE_LSB) & RESET_TUPLE_STATUS_TEST_RESET_TUPLE_MASK)
-#define RESET_TUPLE_STATUS_PIN_RESET_TUPLE_MSB   7
-#define RESET_TUPLE_STATUS_PIN_RESET_TUPLE_LSB   0
-#define RESET_TUPLE_STATUS_PIN_RESET_TUPLE_MASK  0x000000ff
-#define RESET_TUPLE_STATUS_PIN_RESET_TUPLE_GET(x) (((x) & RESET_TUPLE_STATUS_PIN_RESET_TUPLE_MASK) >> RESET_TUPLE_STATUS_PIN_RESET_TUPLE_LSB)
-#define RESET_TUPLE_STATUS_PIN_RESET_TUPLE_SET(x) (((x) << RESET_TUPLE_STATUS_PIN_RESET_TUPLE_LSB) & RESET_TUPLE_STATUS_PIN_RESET_TUPLE_MASK)
-
-
-#ifndef __ASSEMBLER__
-
-typedef struct gpio_reg_reg_s {
-  volatile unsigned int gpio_out;
-  volatile unsigned int gpio_out_w1ts;
-  volatile unsigned int gpio_out_w1tc;
-  volatile unsigned int gpio_enable;
-  volatile unsigned int gpio_enable_w1ts;
-  volatile unsigned int gpio_enable_w1tc;
-  volatile unsigned int gpio_in;
-  volatile unsigned int gpio_status;
-  volatile unsigned int gpio_status_w1ts;
-  volatile unsigned int gpio_status_w1tc;
-  volatile unsigned int gpio_pin0;
-  volatile unsigned int gpio_pin1;
-  volatile unsigned int gpio_pin2;
-  volatile unsigned int gpio_pin3;
-  volatile unsigned int gpio_pin4;
-  volatile unsigned int gpio_pin5;
-  volatile unsigned int gpio_pin6;
-  volatile unsigned int gpio_pin7;
-  volatile unsigned int gpio_pin8;
-  volatile unsigned int gpio_pin9;
-  volatile unsigned int gpio_pin10;
-  volatile unsigned int gpio_pin11;
-  volatile unsigned int gpio_pin12;
-  volatile unsigned int gpio_pin13;
-  volatile unsigned int gpio_pin14;
-  volatile unsigned int gpio_pin15;
-  volatile unsigned int gpio_pin16;
-  volatile unsigned int gpio_pin17;
-  volatile unsigned int sdio_pin;
-  volatile unsigned int clk_req_pin;
-  volatile unsigned int sigma_delta;
-  volatile unsigned int debug_control;
-  volatile unsigned int debug_input_sel;
-  volatile unsigned int debug_out;
-  volatile unsigned int la_control;
-  volatile unsigned int la_clock;
-  volatile unsigned int la_status;
-  volatile unsigned int la_trigger_sample;
-  volatile unsigned int la_trigger_position;
-  volatile unsigned int la_pre_trigger;
-  volatile unsigned int la_post_trigger;
-  volatile unsigned int la_filter_control;
-  volatile unsigned int la_filter_data;
-  volatile unsigned int la_filter_wildcard;
-  volatile unsigned int la_triggera_data;
-  volatile unsigned int la_triggera_wildcard;
-  volatile unsigned int la_triggerb_data;
-  volatile unsigned int la_triggerb_wildcard;
-  volatile unsigned int la_trigger;
-  volatile unsigned int la_fifo;
-  volatile unsigned int la[2];
-  volatile unsigned int ant_pin;
-  volatile unsigned int antd_pin;
-  volatile unsigned int gpio_pin;
-  volatile unsigned int gpio_h_pin;
-  volatile unsigned int bt_pin;
-  volatile unsigned int bt_wlan_pin;
-  volatile unsigned int si_uart_pin;
-  volatile unsigned int clk32k_pin;
-  volatile unsigned int reset_tuple_status;
-} gpio_reg_reg_t;
-
-#endif /* __ASSEMBLER__ */
-
-#endif /* _GPIO_REG_H_ */
diff --git a/drivers/staging/ath6kl/include/common/AR6002/hw2.0/hw/mbox_host_reg.h b/drivers/staging/ath6kl/include/common/AR6002/hw2.0/hw/mbox_host_reg.h
deleted file mode 100644 (file)
index f836ae4..0000000
+++ /dev/null
@@ -1,386 +0,0 @@
-#ifndef _MBOX_HOST_REG_REG_H_
-#define _MBOX_HOST_REG_REG_H_
-
-#define HOST_INT_STATUS_ADDRESS                  0x00000400
-#define HOST_INT_STATUS_OFFSET                   0x00000400
-#define HOST_INT_STATUS_ERROR_MSB                7
-#define HOST_INT_STATUS_ERROR_LSB                7
-#define HOST_INT_STATUS_ERROR_MASK               0x00000080
-#define HOST_INT_STATUS_ERROR_GET(x)             (((x) & HOST_INT_STATUS_ERROR_MASK) >> HOST_INT_STATUS_ERROR_LSB)
-#define HOST_INT_STATUS_ERROR_SET(x)             (((x) << HOST_INT_STATUS_ERROR_LSB) & HOST_INT_STATUS_ERROR_MASK)
-#define HOST_INT_STATUS_CPU_MSB                  6
-#define HOST_INT_STATUS_CPU_LSB                  6
-#define HOST_INT_STATUS_CPU_MASK                 0x00000040
-#define HOST_INT_STATUS_CPU_GET(x)               (((x) & HOST_INT_STATUS_CPU_MASK) >> HOST_INT_STATUS_CPU_LSB)
-#define HOST_INT_STATUS_CPU_SET(x)               (((x) << HOST_INT_STATUS_CPU_LSB) & HOST_INT_STATUS_CPU_MASK)
-#define HOST_INT_STATUS_DRAGON_INT_MSB           5
-#define HOST_INT_STATUS_DRAGON_INT_LSB           5
-#define HOST_INT_STATUS_DRAGON_INT_MASK          0x00000020
-#define HOST_INT_STATUS_DRAGON_INT_GET(x)        (((x) & HOST_INT_STATUS_DRAGON_INT_MASK) >> HOST_INT_STATUS_DRAGON_INT_LSB)
-#define HOST_INT_STATUS_DRAGON_INT_SET(x)        (((x) << HOST_INT_STATUS_DRAGON_INT_LSB) & HOST_INT_STATUS_DRAGON_INT_MASK)
-#define HOST_INT_STATUS_COUNTER_MSB              4
-#define HOST_INT_STATUS_COUNTER_LSB              4
-#define HOST_INT_STATUS_COUNTER_MASK             0x00000010
-#define HOST_INT_STATUS_COUNTER_GET(x)           (((x) & HOST_INT_STATUS_COUNTER_MASK) >> HOST_INT_STATUS_COUNTER_LSB)
-#define HOST_INT_STATUS_COUNTER_SET(x)           (((x) << HOST_INT_STATUS_COUNTER_LSB) & HOST_INT_STATUS_COUNTER_MASK)
-#define HOST_INT_STATUS_MBOX_DATA_MSB            3
-#define HOST_INT_STATUS_MBOX_DATA_LSB            0
-#define HOST_INT_STATUS_MBOX_DATA_MASK           0x0000000f
-#define HOST_INT_STATUS_MBOX_DATA_GET(x)         (((x) & HOST_INT_STATUS_MBOX_DATA_MASK) >> HOST_INT_STATUS_MBOX_DATA_LSB)
-#define HOST_INT_STATUS_MBOX_DATA_SET(x)         (((x) << HOST_INT_STATUS_MBOX_DATA_LSB) & HOST_INT_STATUS_MBOX_DATA_MASK)
-
-#define CPU_INT_STATUS_ADDRESS                   0x00000401
-#define CPU_INT_STATUS_OFFSET                    0x00000401
-#define CPU_INT_STATUS_BIT_MSB                   7
-#define CPU_INT_STATUS_BIT_LSB                   0
-#define CPU_INT_STATUS_BIT_MASK                  0x000000ff
-#define CPU_INT_STATUS_BIT_GET(x)                (((x) & CPU_INT_STATUS_BIT_MASK) >> CPU_INT_STATUS_BIT_LSB)
-#define CPU_INT_STATUS_BIT_SET(x)                (((x) << CPU_INT_STATUS_BIT_LSB) & CPU_INT_STATUS_BIT_MASK)
-
-#define ERROR_INT_STATUS_ADDRESS                 0x00000402
-#define ERROR_INT_STATUS_OFFSET                  0x00000402
-#define ERROR_INT_STATUS_SPI_MSB                 3
-#define ERROR_INT_STATUS_SPI_LSB                 3
-#define ERROR_INT_STATUS_SPI_MASK                0x00000008
-#define ERROR_INT_STATUS_SPI_GET(x)              (((x) & ERROR_INT_STATUS_SPI_MASK) >> ERROR_INT_STATUS_SPI_LSB)
-#define ERROR_INT_STATUS_SPI_SET(x)              (((x) << ERROR_INT_STATUS_SPI_LSB) & ERROR_INT_STATUS_SPI_MASK)
-#define ERROR_INT_STATUS_WAKEUP_MSB              2
-#define ERROR_INT_STATUS_WAKEUP_LSB              2
-#define ERROR_INT_STATUS_WAKEUP_MASK             0x00000004
-#define ERROR_INT_STATUS_WAKEUP_GET(x)           (((x) & ERROR_INT_STATUS_WAKEUP_MASK) >> ERROR_INT_STATUS_WAKEUP_LSB)
-#define ERROR_INT_STATUS_WAKEUP_SET(x)           (((x) << ERROR_INT_STATUS_WAKEUP_LSB) & ERROR_INT_STATUS_WAKEUP_MASK)
-#define ERROR_INT_STATUS_RX_UNDERFLOW_MSB        1
-#define ERROR_INT_STATUS_RX_UNDERFLOW_LSB        1
-#define ERROR_INT_STATUS_RX_UNDERFLOW_MASK       0x00000002
-#define ERROR_INT_STATUS_RX_UNDERFLOW_GET(x)     (((x) & ERROR_INT_STATUS_RX_UNDERFLOW_MASK) >> ERROR_INT_STATUS_RX_UNDERFLOW_LSB)
-#define ERROR_INT_STATUS_RX_UNDERFLOW_SET(x)     (((x) << ERROR_INT_STATUS_RX_UNDERFLOW_LSB) & ERROR_INT_STATUS_RX_UNDERFLOW_MASK)
-#define ERROR_INT_STATUS_TX_OVERFLOW_MSB         0
-#define ERROR_INT_STATUS_TX_OVERFLOW_LSB         0
-#define ERROR_INT_STATUS_TX_OVERFLOW_MASK        0x00000001
-#define ERROR_INT_STATUS_TX_OVERFLOW_GET(x)      (((x) & ERROR_INT_STATUS_TX_OVERFLOW_MASK) >> ERROR_INT_STATUS_TX_OVERFLOW_LSB)
-#define ERROR_INT_STATUS_TX_OVERFLOW_SET(x)      (((x) << ERROR_INT_STATUS_TX_OVERFLOW_LSB) & ERROR_INT_STATUS_TX_OVERFLOW_MASK)
-
-#define COUNTER_INT_STATUS_ADDRESS               0x00000403
-#define COUNTER_INT_STATUS_OFFSET                0x00000403
-#define COUNTER_INT_STATUS_COUNTER_MSB           7
-#define COUNTER_INT_STATUS_COUNTER_LSB           0
-#define COUNTER_INT_STATUS_COUNTER_MASK          0x000000ff
-#define COUNTER_INT_STATUS_COUNTER_GET(x)        (((x) & COUNTER_INT_STATUS_COUNTER_MASK) >> COUNTER_INT_STATUS_COUNTER_LSB)
-#define COUNTER_INT_STATUS_COUNTER_SET(x)        (((x) << COUNTER_INT_STATUS_COUNTER_LSB) & COUNTER_INT_STATUS_COUNTER_MASK)
-
-#define MBOX_FRAME_ADDRESS                       0x00000404
-#define MBOX_FRAME_OFFSET                        0x00000404
-#define MBOX_FRAME_RX_EOM_MSB                    7
-#define MBOX_FRAME_RX_EOM_LSB                    4
-#define MBOX_FRAME_RX_EOM_MASK                   0x000000f0
-#define MBOX_FRAME_RX_EOM_GET(x)                 (((x) & MBOX_FRAME_RX_EOM_MASK) >> MBOX_FRAME_RX_EOM_LSB)
-#define MBOX_FRAME_RX_EOM_SET(x)                 (((x) << MBOX_FRAME_RX_EOM_LSB) & MBOX_FRAME_RX_EOM_MASK)
-#define MBOX_FRAME_RX_SOM_MSB                    3
-#define MBOX_FRAME_RX_SOM_LSB                    0
-#define MBOX_FRAME_RX_SOM_MASK                   0x0000000f
-#define MBOX_FRAME_RX_SOM_GET(x)                 (((x) & MBOX_FRAME_RX_SOM_MASK) >> MBOX_FRAME_RX_SOM_LSB)
-#define MBOX_FRAME_RX_SOM_SET(x)                 (((x) << MBOX_FRAME_RX_SOM_LSB) & MBOX_FRAME_RX_SOM_MASK)
-
-#define RX_LOOKAHEAD_VALID_ADDRESS               0x00000405
-#define RX_LOOKAHEAD_VALID_OFFSET                0x00000405
-#define RX_LOOKAHEAD_VALID_MBOX_MSB              3
-#define RX_LOOKAHEAD_VALID_MBOX_LSB              0
-#define RX_LOOKAHEAD_VALID_MBOX_MASK             0x0000000f
-#define RX_LOOKAHEAD_VALID_MBOX_GET(x)           (((x) & RX_LOOKAHEAD_VALID_MBOX_MASK) >> RX_LOOKAHEAD_VALID_MBOX_LSB)
-#define RX_LOOKAHEAD_VALID_MBOX_SET(x)           (((x) << RX_LOOKAHEAD_VALID_MBOX_LSB) & RX_LOOKAHEAD_VALID_MBOX_MASK)
-
-#define RX_LOOKAHEAD0_ADDRESS                    0x00000408
-#define RX_LOOKAHEAD0_OFFSET                     0x00000408
-#define RX_LOOKAHEAD0_DATA_MSB                   7
-#define RX_LOOKAHEAD0_DATA_LSB                   0
-#define RX_LOOKAHEAD0_DATA_MASK                  0x000000ff
-#define RX_LOOKAHEAD0_DATA_GET(x)                (((x) & RX_LOOKAHEAD0_DATA_MASK) >> RX_LOOKAHEAD0_DATA_LSB)
-#define RX_LOOKAHEAD0_DATA_SET(x)                (((x) << RX_LOOKAHEAD0_DATA_LSB) & RX_LOOKAHEAD0_DATA_MASK)
-
-#define RX_LOOKAHEAD1_ADDRESS                    0x0000040c
-#define RX_LOOKAHEAD1_OFFSET                     0x0000040c
-#define RX_LOOKAHEAD1_DATA_MSB                   7
-#define RX_LOOKAHEAD1_DATA_LSB                   0
-#define RX_LOOKAHEAD1_DATA_MASK                  0x000000ff
-#define RX_LOOKAHEAD1_DATA_GET(x)                (((x) & RX_LOOKAHEAD1_DATA_MASK) >> RX_LOOKAHEAD1_DATA_LSB)
-#define RX_LOOKAHEAD1_DATA_SET(x)                (((x) << RX_LOOKAHEAD1_DATA_LSB) & RX_LOOKAHEAD1_DATA_MASK)
-
-#define RX_LOOKAHEAD2_ADDRESS                    0x00000410
-#define RX_LOOKAHEAD2_OFFSET                     0x00000410
-#define RX_LOOKAHEAD2_DATA_MSB                   7
-#define RX_LOOKAHEAD2_DATA_LSB                   0
-#define RX_LOOKAHEAD2_DATA_MASK                  0x000000ff
-#define RX_LOOKAHEAD2_DATA_GET(x)                (((x) & RX_LOOKAHEAD2_DATA_MASK) >> RX_LOOKAHEAD2_DATA_LSB)
-#define RX_LOOKAHEAD2_DATA_SET(x)                (((x) << RX_LOOKAHEAD2_DATA_LSB) & RX_LOOKAHEAD2_DATA_MASK)
-
-#define RX_LOOKAHEAD3_ADDRESS                    0x00000414
-#define RX_LOOKAHEAD3_OFFSET                     0x00000414
-#define RX_LOOKAHEAD3_DATA_MSB                   7
-#define RX_LOOKAHEAD3_DATA_LSB                   0
-#define RX_LOOKAHEAD3_DATA_MASK                  0x000000ff
-#define RX_LOOKAHEAD3_DATA_GET(x)                (((x) & RX_LOOKAHEAD3_DATA_MASK) >> RX_LOOKAHEAD3_DATA_LSB)
-#define RX_LOOKAHEAD3_DATA_SET(x)                (((x) << RX_LOOKAHEAD3_DATA_LSB) & RX_LOOKAHEAD3_DATA_MASK)
-
-#define INT_STATUS_ENABLE_ADDRESS                0x00000418
-#define INT_STATUS_ENABLE_OFFSET                 0x00000418
-#define INT_STATUS_ENABLE_ERROR_MSB              7
-#define INT_STATUS_ENABLE_ERROR_LSB              7
-#define INT_STATUS_ENABLE_ERROR_MASK             0x00000080
-#define INT_STATUS_ENABLE_ERROR_GET(x)           (((x) & INT_STATUS_ENABLE_ERROR_MASK) >> INT_STATUS_ENABLE_ERROR_LSB)
-#define INT_STATUS_ENABLE_ERROR_SET(x)           (((x) << INT_STATUS_ENABLE_ERROR_LSB) & INT_STATUS_ENABLE_ERROR_MASK)
-#define INT_STATUS_ENABLE_CPU_MSB                6
-#define INT_STATUS_ENABLE_CPU_LSB                6
-#define INT_STATUS_ENABLE_CPU_MASK               0x00000040
-#define INT_STATUS_ENABLE_CPU_GET(x)             (((x) & INT_STATUS_ENABLE_CPU_MASK) >> INT_STATUS_ENABLE_CPU_LSB)
-#define INT_STATUS_ENABLE_CPU_SET(x)             (((x) << INT_STATUS_ENABLE_CPU_LSB) & INT_STATUS_ENABLE_CPU_MASK)
-#define INT_STATUS_ENABLE_DRAGON_INT_MSB         5
-#define INT_STATUS_ENABLE_DRAGON_INT_LSB         5
-#define INT_STATUS_ENABLE_DRAGON_INT_MASK        0x00000020
-#define INT_STATUS_ENABLE_DRAGON_INT_GET(x)      (((x) & INT_STATUS_ENABLE_DRAGON_INT_MASK) >> INT_STATUS_ENABLE_DRAGON_INT_LSB)
-#define INT_STATUS_ENABLE_DRAGON_INT_SET(x)      (((x) << INT_STATUS_ENABLE_DRAGON_INT_LSB) & INT_STATUS_ENABLE_DRAGON_INT_MASK)
-#define INT_STATUS_ENABLE_COUNTER_MSB            4
-#define INT_STATUS_ENABLE_COUNTER_LSB            4
-#define INT_STATUS_ENABLE_COUNTER_MASK           0x00000010
-#define INT_STATUS_ENABLE_COUNTER_GET(x)         (((x) & INT_STATUS_ENABLE_COUNTER_MASK) >> INT_STATUS_ENABLE_COUNTER_LSB)
-#define INT_STATUS_ENABLE_COUNTER_SET(x)         (((x) << INT_STATUS_ENABLE_COUNTER_LSB) & INT_STATUS_ENABLE_COUNTER_MASK)
-#define INT_STATUS_ENABLE_MBOX_DATA_MSB          3
-#define INT_STATUS_ENABLE_MBOX_DATA_LSB          0
-#define INT_STATUS_ENABLE_MBOX_DATA_MASK         0x0000000f
-#define INT_STATUS_ENABLE_MBOX_DATA_GET(x)       (((x) & INT_STATUS_ENABLE_MBOX_DATA_MASK) >> INT_STATUS_ENABLE_MBOX_DATA_LSB)
-#define INT_STATUS_ENABLE_MBOX_DATA_SET(x)       (((x) << INT_STATUS_ENABLE_MBOX_DATA_LSB) & INT_STATUS_ENABLE_MBOX_DATA_MASK)
-
-#define CPU_INT_STATUS_ENABLE_ADDRESS            0x00000419
-#define CPU_INT_STATUS_ENABLE_OFFSET             0x00000419
-#define CPU_INT_STATUS_ENABLE_BIT_MSB            7
-#define CPU_INT_STATUS_ENABLE_BIT_LSB            0
-#define CPU_INT_STATUS_ENABLE_BIT_MASK           0x000000ff
-#define CPU_INT_STATUS_ENABLE_BIT_GET(x)         (((x) & CPU_INT_STATUS_ENABLE_BIT_MASK) >> CPU_INT_STATUS_ENABLE_BIT_LSB)
-#define CPU_INT_STATUS_ENABLE_BIT_SET(x)         (((x) << CPU_INT_STATUS_ENABLE_BIT_LSB) & CPU_INT_STATUS_ENABLE_BIT_MASK)
-
-#define ERROR_STATUS_ENABLE_ADDRESS              0x0000041a
-#define ERROR_STATUS_ENABLE_OFFSET               0x0000041a
-#define ERROR_STATUS_ENABLE_WAKEUP_MSB           2
-#define ERROR_STATUS_ENABLE_WAKEUP_LSB           2
-#define ERROR_STATUS_ENABLE_WAKEUP_MASK          0x00000004
-#define ERROR_STATUS_ENABLE_WAKEUP_GET(x)        (((x) & ERROR_STATUS_ENABLE_WAKEUP_MASK) >> ERROR_STATUS_ENABLE_WAKEUP_LSB)
-#define ERROR_STATUS_ENABLE_WAKEUP_SET(x)        (((x) << ERROR_STATUS_ENABLE_WAKEUP_LSB) & ERROR_STATUS_ENABLE_WAKEUP_MASK)
-#define ERROR_STATUS_ENABLE_RX_UNDERFLOW_MSB     1
-#define ERROR_STATUS_ENABLE_RX_UNDERFLOW_LSB     1
-#define ERROR_STATUS_ENABLE_RX_UNDERFLOW_MASK    0x00000002
-#define ERROR_STATUS_ENABLE_RX_UNDERFLOW_GET(x)  (((x) & ERROR_STATUS_ENABLE_RX_UNDERFLOW_MASK) >> ERROR_STATUS_ENABLE_RX_UNDERFLOW_LSB)
-#define ERROR_STATUS_ENABLE_RX_UNDERFLOW_SET(x)  (((x) << ERROR_STATUS_ENABLE_RX_UNDERFLOW_LSB) & ERROR_STATUS_ENABLE_RX_UNDERFLOW_MASK)
-#define ERROR_STATUS_ENABLE_TX_OVERFLOW_MSB      0
-#define ERROR_STATUS_ENABLE_TX_OVERFLOW_LSB      0
-#define ERROR_STATUS_ENABLE_TX_OVERFLOW_MASK     0x00000001
-#define ERROR_STATUS_ENABLE_TX_OVERFLOW_GET(x)   (((x) & ERROR_STATUS_ENABLE_TX_OVERFLOW_MASK) >> ERROR_STATUS_ENABLE_TX_OVERFLOW_LSB)
-#define ERROR_STATUS_ENABLE_TX_OVERFLOW_SET(x)   (((x) << ERROR_STATUS_ENABLE_TX_OVERFLOW_LSB) & ERROR_STATUS_ENABLE_TX_OVERFLOW_MASK)
-
-#define COUNTER_INT_STATUS_ENABLE_ADDRESS        0x0000041b
-#define COUNTER_INT_STATUS_ENABLE_OFFSET         0x0000041b
-#define COUNTER_INT_STATUS_ENABLE_BIT_MSB        7
-#define COUNTER_INT_STATUS_ENABLE_BIT_LSB        0
-#define COUNTER_INT_STATUS_ENABLE_BIT_MASK       0x000000ff
-#define COUNTER_INT_STATUS_ENABLE_BIT_GET(x)     (((x) & COUNTER_INT_STATUS_ENABLE_BIT_MASK) >> COUNTER_INT_STATUS_ENABLE_BIT_LSB)
-#define COUNTER_INT_STATUS_ENABLE_BIT_SET(x)     (((x) << COUNTER_INT_STATUS_ENABLE_BIT_LSB) & COUNTER_INT_STATUS_ENABLE_BIT_MASK)
-
-#define COUNT_ADDRESS                            0x00000420
-#define COUNT_OFFSET                             0x00000420
-#define COUNT_VALUE_MSB                          7
-#define COUNT_VALUE_LSB                          0
-#define COUNT_VALUE_MASK                         0x000000ff
-#define COUNT_VALUE_GET(x)                       (((x) & COUNT_VALUE_MASK) >> COUNT_VALUE_LSB)
-#define COUNT_VALUE_SET(x)                       (((x) << COUNT_VALUE_LSB) & COUNT_VALUE_MASK)
-
-#define COUNT_DEC_ADDRESS                        0x00000440
-#define COUNT_DEC_OFFSET                         0x00000440
-#define COUNT_DEC_VALUE_MSB                      7
-#define COUNT_DEC_VALUE_LSB                      0
-#define COUNT_DEC_VALUE_MASK                     0x000000ff
-#define COUNT_DEC_VALUE_GET(x)                   (((x) & COUNT_DEC_VALUE_MASK) >> COUNT_DEC_VALUE_LSB)
-#define COUNT_DEC_VALUE_SET(x)                   (((x) << COUNT_DEC_VALUE_LSB) & COUNT_DEC_VALUE_MASK)
-
-#define SCRATCH_ADDRESS                          0x00000460
-#define SCRATCH_OFFSET                           0x00000460
-#define SCRATCH_VALUE_MSB                        7
-#define SCRATCH_VALUE_LSB                        0
-#define SCRATCH_VALUE_MASK                       0x000000ff
-#define SCRATCH_VALUE_GET(x)                     (((x) & SCRATCH_VALUE_MASK) >> SCRATCH_VALUE_LSB)
-#define SCRATCH_VALUE_SET(x)                     (((x) << SCRATCH_VALUE_LSB) & SCRATCH_VALUE_MASK)
-
-#define FIFO_TIMEOUT_ADDRESS                     0x00000468
-#define FIFO_TIMEOUT_OFFSET                      0x00000468
-#define FIFO_TIMEOUT_VALUE_MSB                   7
-#define FIFO_TIMEOUT_VALUE_LSB                   0
-#define FIFO_TIMEOUT_VALUE_MASK                  0x000000ff
-#define FIFO_TIMEOUT_VALUE_GET(x)                (((x) & FIFO_TIMEOUT_VALUE_MASK) >> FIFO_TIMEOUT_VALUE_LSB)
-#define FIFO_TIMEOUT_VALUE_SET(x)                (((x) << FIFO_TIMEOUT_VALUE_LSB) & FIFO_TIMEOUT_VALUE_MASK)
-
-#define FIFO_TIMEOUT_ENABLE_ADDRESS              0x00000469
-#define FIFO_TIMEOUT_ENABLE_OFFSET               0x00000469
-#define FIFO_TIMEOUT_ENABLE_SET_MSB              0
-#define FIFO_TIMEOUT_ENABLE_SET_LSB              0
-#define FIFO_TIMEOUT_ENABLE_SET_MASK             0x00000001
-#define FIFO_TIMEOUT_ENABLE_SET_GET(x)           (((x) & FIFO_TIMEOUT_ENABLE_SET_MASK) >> FIFO_TIMEOUT_ENABLE_SET_LSB)
-#define FIFO_TIMEOUT_ENABLE_SET_SET(x)           (((x) << FIFO_TIMEOUT_ENABLE_SET_LSB) & FIFO_TIMEOUT_ENABLE_SET_MASK)
-
-#define DISABLE_SLEEP_ADDRESS                    0x0000046a
-#define DISABLE_SLEEP_OFFSET                     0x0000046a
-#define DISABLE_SLEEP_FOR_INT_MSB                1
-#define DISABLE_SLEEP_FOR_INT_LSB                1
-#define DISABLE_SLEEP_FOR_INT_MASK               0x00000002
-#define DISABLE_SLEEP_FOR_INT_GET(x)             (((x) & DISABLE_SLEEP_FOR_INT_MASK) >> DISABLE_SLEEP_FOR_INT_LSB)
-#define DISABLE_SLEEP_FOR_INT_SET(x)             (((x) << DISABLE_SLEEP_FOR_INT_LSB) & DISABLE_SLEEP_FOR_INT_MASK)
-#define DISABLE_SLEEP_ON_MSB                     0
-#define DISABLE_SLEEP_ON_LSB                     0
-#define DISABLE_SLEEP_ON_MASK                    0x00000001
-#define DISABLE_SLEEP_ON_GET(x)                  (((x) & DISABLE_SLEEP_ON_MASK) >> DISABLE_SLEEP_ON_LSB)
-#define DISABLE_SLEEP_ON_SET(x)                  (((x) << DISABLE_SLEEP_ON_LSB) & DISABLE_SLEEP_ON_MASK)
-
-#define LOCAL_BUS_ADDRESS                        0x00000470
-#define LOCAL_BUS_OFFSET                         0x00000470
-#define LOCAL_BUS_STATE_MSB                      1
-#define LOCAL_BUS_STATE_LSB                      0
-#define LOCAL_BUS_STATE_MASK                     0x00000003
-#define LOCAL_BUS_STATE_GET(x)                   (((x) & LOCAL_BUS_STATE_MASK) >> LOCAL_BUS_STATE_LSB)
-#define LOCAL_BUS_STATE_SET(x)                   (((x) << LOCAL_BUS_STATE_LSB) & LOCAL_BUS_STATE_MASK)
-
-#define INT_WLAN_ADDRESS                         0x00000472
-#define INT_WLAN_OFFSET                          0x00000472
-#define INT_WLAN_VECTOR_MSB                      7
-#define INT_WLAN_VECTOR_LSB                      0
-#define INT_WLAN_VECTOR_MASK                     0x000000ff
-#define INT_WLAN_VECTOR_GET(x)                   (((x) & INT_WLAN_VECTOR_MASK) >> INT_WLAN_VECTOR_LSB)
-#define INT_WLAN_VECTOR_SET(x)                   (((x) << INT_WLAN_VECTOR_LSB) & INT_WLAN_VECTOR_MASK)
-
-#define WINDOW_DATA_ADDRESS                      0x00000474
-#define WINDOW_DATA_OFFSET                       0x00000474
-#define WINDOW_DATA_DATA_MSB                     7
-#define WINDOW_DATA_DATA_LSB                     0
-#define WINDOW_DATA_DATA_MASK                    0x000000ff
-#define WINDOW_DATA_DATA_GET(x)                  (((x) & WINDOW_DATA_DATA_MASK) >> WINDOW_DATA_DATA_LSB)
-#define WINDOW_DATA_DATA_SET(x)                  (((x) << WINDOW_DATA_DATA_LSB) & WINDOW_DATA_DATA_MASK)
-
-#define WINDOW_WRITE_ADDR_ADDRESS                0x00000478
-#define WINDOW_WRITE_ADDR_OFFSET                 0x00000478
-#define WINDOW_WRITE_ADDR_ADDR_MSB               7
-#define WINDOW_WRITE_ADDR_ADDR_LSB               0
-#define WINDOW_WRITE_ADDR_ADDR_MASK              0x000000ff
-#define WINDOW_WRITE_ADDR_ADDR_GET(x)            (((x) & WINDOW_WRITE_ADDR_ADDR_MASK) >> WINDOW_WRITE_ADDR_ADDR_LSB)
-#define WINDOW_WRITE_ADDR_ADDR_SET(x)            (((x) << WINDOW_WRITE_ADDR_ADDR_LSB) & WINDOW_WRITE_ADDR_ADDR_MASK)
-
-#define WINDOW_READ_ADDR_ADDRESS                 0x0000047c
-#define WINDOW_READ_ADDR_OFFSET                  0x0000047c
-#define WINDOW_READ_ADDR_ADDR_MSB                7
-#define WINDOW_READ_ADDR_ADDR_LSB                0
-#define WINDOW_READ_ADDR_ADDR_MASK               0x000000ff
-#define WINDOW_READ_ADDR_ADDR_GET(x)             (((x) & WINDOW_READ_ADDR_ADDR_MASK) >> WINDOW_READ_ADDR_ADDR_LSB)
-#define WINDOW_READ_ADDR_ADDR_SET(x)             (((x) << WINDOW_READ_ADDR_ADDR_LSB) & WINDOW_READ_ADDR_ADDR_MASK)
-
-#define SPI_CONFIG_ADDRESS                       0x00000480
-#define SPI_CONFIG_OFFSET                        0x00000480
-#define SPI_CONFIG_SPI_RESET_MSB                 4
-#define SPI_CONFIG_SPI_RESET_LSB                 4
-#define SPI_CONFIG_SPI_RESET_MASK                0x00000010
-#define SPI_CONFIG_SPI_RESET_GET(x)              (((x) & SPI_CONFIG_SPI_RESET_MASK) >> SPI_CONFIG_SPI_RESET_LSB)
-#define SPI_CONFIG_SPI_RESET_SET(x)              (((x) << SPI_CONFIG_SPI_RESET_LSB) & SPI_CONFIG_SPI_RESET_MASK)
-#define SPI_CONFIG_INTERRUPT_ENABLE_MSB          3
-#define SPI_CONFIG_INTERRUPT_ENABLE_LSB          3
-#define SPI_CONFIG_INTERRUPT_ENABLE_MASK         0x00000008
-#define SPI_CONFIG_INTERRUPT_ENABLE_GET(x)       (((x) & SPI_CONFIG_INTERRUPT_ENABLE_MASK) >> SPI_CONFIG_INTERRUPT_ENABLE_LSB)
-#define SPI_CONFIG_INTERRUPT_ENABLE_SET(x)       (((x) << SPI_CONFIG_INTERRUPT_ENABLE_LSB) & SPI_CONFIG_INTERRUPT_ENABLE_MASK)
-#define SPI_CONFIG_TEST_MODE_MSB                 2
-#define SPI_CONFIG_TEST_MODE_LSB                 2
-#define SPI_CONFIG_TEST_MODE_MASK                0x00000004
-#define SPI_CONFIG_TEST_MODE_GET(x)              (((x) & SPI_CONFIG_TEST_MODE_MASK) >> SPI_CONFIG_TEST_MODE_LSB)
-#define SPI_CONFIG_TEST_MODE_SET(x)              (((x) << SPI_CONFIG_TEST_MODE_LSB) & SPI_CONFIG_TEST_MODE_MASK)
-#define SPI_CONFIG_DATA_SIZE_MSB                 1
-#define SPI_CONFIG_DATA_SIZE_LSB                 0
-#define SPI_CONFIG_DATA_SIZE_MASK                0x00000003
-#define SPI_CONFIG_DATA_SIZE_GET(x)              (((x) & SPI_CONFIG_DATA_SIZE_MASK) >> SPI_CONFIG_DATA_SIZE_LSB)
-#define SPI_CONFIG_DATA_SIZE_SET(x)              (((x) << SPI_CONFIG_DATA_SIZE_LSB) & SPI_CONFIG_DATA_SIZE_MASK)
-
-#define SPI_STATUS_ADDRESS                       0x00000481
-#define SPI_STATUS_OFFSET                        0x00000481
-#define SPI_STATUS_ADDR_ERR_MSB                  3
-#define SPI_STATUS_ADDR_ERR_LSB                  3
-#define SPI_STATUS_ADDR_ERR_MASK                 0x00000008
-#define SPI_STATUS_ADDR_ERR_GET(x)               (((x) & SPI_STATUS_ADDR_ERR_MASK) >> SPI_STATUS_ADDR_ERR_LSB)
-#define SPI_STATUS_ADDR_ERR_SET(x)               (((x) << SPI_STATUS_ADDR_ERR_LSB) & SPI_STATUS_ADDR_ERR_MASK)
-#define SPI_STATUS_RD_ERR_MSB                    2
-#define SPI_STATUS_RD_ERR_LSB                    2
-#define SPI_STATUS_RD_ERR_MASK                   0x00000004
-#define SPI_STATUS_RD_ERR_GET(x)                 (((x) & SPI_STATUS_RD_ERR_MASK) >> SPI_STATUS_RD_ERR_LSB)
-#define SPI_STATUS_RD_ERR_SET(x)                 (((x) << SPI_STATUS_RD_ERR_LSB) & SPI_STATUS_RD_ERR_MASK)
-#define SPI_STATUS_WR_ERR_MSB                    1
-#define SPI_STATUS_WR_ERR_LSB                    1
-#define SPI_STATUS_WR_ERR_MASK                   0x00000002
-#define SPI_STATUS_WR_ERR_GET(x)                 (((x) & SPI_STATUS_WR_ERR_MASK) >> SPI_STATUS_WR_ERR_LSB)
-#define SPI_STATUS_WR_ERR_SET(x)                 (((x) << SPI_STATUS_WR_ERR_LSB) & SPI_STATUS_WR_ERR_MASK)
-#define SPI_STATUS_READY_MSB                     0
-#define SPI_STATUS_READY_LSB                     0
-#define SPI_STATUS_READY_MASK                    0x00000001
-#define SPI_STATUS_READY_GET(x)                  (((x) & SPI_STATUS_READY_MASK) >> SPI_STATUS_READY_LSB)
-#define SPI_STATUS_READY_SET(x)                  (((x) << SPI_STATUS_READY_LSB) & SPI_STATUS_READY_MASK)
-
-#define NON_ASSOC_SLEEP_EN_ADDRESS               0x00000482
-#define NON_ASSOC_SLEEP_EN_OFFSET                0x00000482
-#define NON_ASSOC_SLEEP_EN_BIT_MSB               0
-#define NON_ASSOC_SLEEP_EN_BIT_LSB               0
-#define NON_ASSOC_SLEEP_EN_BIT_MASK              0x00000001
-#define NON_ASSOC_SLEEP_EN_BIT_GET(x)            (((x) & NON_ASSOC_SLEEP_EN_BIT_MASK) >> NON_ASSOC_SLEEP_EN_BIT_LSB)
-#define NON_ASSOC_SLEEP_EN_BIT_SET(x)            (((x) << NON_ASSOC_SLEEP_EN_BIT_LSB) & NON_ASSOC_SLEEP_EN_BIT_MASK)
-
-#define CIS_WINDOW_ADDRESS                       0x00000600
-#define CIS_WINDOW_OFFSET                        0x00000600
-#define CIS_WINDOW_DATA_MSB                      7
-#define CIS_WINDOW_DATA_LSB                      0
-#define CIS_WINDOW_DATA_MASK                     0x000000ff
-#define CIS_WINDOW_DATA_GET(x)                   (((x) & CIS_WINDOW_DATA_MASK) >> CIS_WINDOW_DATA_LSB)
-#define CIS_WINDOW_DATA_SET(x)                   (((x) << CIS_WINDOW_DATA_LSB) & CIS_WINDOW_DATA_MASK)
-
-
-#ifndef __ASSEMBLER__
-
-typedef struct mbox_host_reg_reg_s {
-  unsigned char pad0[1024]; /* pad to 0x400 */
-  volatile unsigned char host_int_status;
-  volatile unsigned char cpu_int_status;
-  volatile unsigned char error_int_status;
-  volatile unsigned char counter_int_status;
-  volatile unsigned char mbox_frame;
-  volatile unsigned char rx_lookahead_valid;
-  unsigned char pad1[2]; /* pad to 0x408 */
-  volatile unsigned char rx_lookahead0[4];
-  volatile unsigned char rx_lookahead1[4];
-  volatile unsigned char rx_lookahead2[4];
-  volatile unsigned char rx_lookahead3[4];
-  volatile unsigned char int_status_enable;
-  volatile unsigned char cpu_int_status_enable;
-  volatile unsigned char error_status_enable;
-  volatile unsigned char counter_int_status_enable;
-  unsigned char pad2[4]; /* pad to 0x420 */
-  volatile unsigned char count[8];
-  unsigned char pad3[24]; /* pad to 0x440 */
-  volatile unsigned char count_dec[32];
-  volatile unsigned char scratch[8];
-  volatile unsigned char fifo_timeout;
-  volatile unsigned char fifo_timeout_enable;
-  volatile unsigned char disable_sleep;
-  unsigned char pad4[5]; /* pad to 0x470 */
-  volatile unsigned char local_bus;
-  unsigned char pad5[1]; /* pad to 0x472 */
-  volatile unsigned char int_wlan;
-  unsigned char pad6[1]; /* pad to 0x474 */
-  volatile unsigned char window_data[4];
-  volatile unsigned char window_write_addr[4];
-  volatile unsigned char window_read_addr[4];
-  volatile unsigned char spi_config;
-  volatile unsigned char spi_status;
-  volatile unsigned char non_assoc_sleep_en;
-  unsigned char pad7[381]; /* pad to 0x600 */
-  volatile unsigned char cis_window[512];
-} mbox_host_reg_reg_t;
-
-#endif /* __ASSEMBLER__ */
-
-#endif /* _MBOX_HOST_REG_H_ */
diff --git a/drivers/staging/ath6kl/include/common/AR6002/hw2.0/hw/mbox_reg.h b/drivers/staging/ath6kl/include/common/AR6002/hw2.0/hw/mbox_reg.h
deleted file mode 100644 (file)
index 4e07d22..0000000
+++ /dev/null
@@ -1,481 +0,0 @@
-#ifndef _MBOX_REG_REG_H_
-#define _MBOX_REG_REG_H_
-
-#define MBOX_FIFO_ADDRESS                        0x00000000
-#define MBOX_FIFO_OFFSET                         0x00000000
-#define MBOX_FIFO_DATA_MSB                       19
-#define MBOX_FIFO_DATA_LSB                       0
-#define MBOX_FIFO_DATA_MASK                      0x000fffff
-#define MBOX_FIFO_DATA_GET(x)                    (((x) & MBOX_FIFO_DATA_MASK) >> MBOX_FIFO_DATA_LSB)
-#define MBOX_FIFO_DATA_SET(x)                    (((x) << MBOX_FIFO_DATA_LSB) & MBOX_FIFO_DATA_MASK)
-
-#define MBOX_FIFO_STATUS_ADDRESS                 0x00000010
-#define MBOX_FIFO_STATUS_OFFSET                  0x00000010
-#define MBOX_FIFO_STATUS_EMPTY_MSB               19
-#define MBOX_FIFO_STATUS_EMPTY_LSB               16
-#define MBOX_FIFO_STATUS_EMPTY_MASK              0x000f0000
-#define MBOX_FIFO_STATUS_EMPTY_GET(x)            (((x) & MBOX_FIFO_STATUS_EMPTY_MASK) >> MBOX_FIFO_STATUS_EMPTY_LSB)
-#define MBOX_FIFO_STATUS_EMPTY_SET(x)            (((x) << MBOX_FIFO_STATUS_EMPTY_LSB) & MBOX_FIFO_STATUS_EMPTY_MASK)
-#define MBOX_FIFO_STATUS_FULL_MSB                15
-#define MBOX_FIFO_STATUS_FULL_LSB                12
-#define MBOX_FIFO_STATUS_FULL_MASK               0x0000f000
-#define MBOX_FIFO_STATUS_FULL_GET(x)             (((x) & MBOX_FIFO_STATUS_FULL_MASK) >> MBOX_FIFO_STATUS_FULL_LSB)
-#define MBOX_FIFO_STATUS_FULL_SET(x)             (((x) << MBOX_FIFO_STATUS_FULL_LSB) & MBOX_FIFO_STATUS_FULL_MASK)
-
-#define MBOX_DMA_POLICY_ADDRESS                  0x00000014
-#define MBOX_DMA_POLICY_OFFSET                   0x00000014
-#define MBOX_DMA_POLICY_TX_QUANTUM_MSB           3
-#define MBOX_DMA_POLICY_TX_QUANTUM_LSB           3
-#define MBOX_DMA_POLICY_TX_QUANTUM_MASK          0x00000008
-#define MBOX_DMA_POLICY_TX_QUANTUM_GET(x)        (((x) & MBOX_DMA_POLICY_TX_QUANTUM_MASK) >> MBOX_DMA_POLICY_TX_QUANTUM_LSB)
-#define MBOX_DMA_POLICY_TX_QUANTUM_SET(x)        (((x) << MBOX_DMA_POLICY_TX_QUANTUM_LSB) & MBOX_DMA_POLICY_TX_QUANTUM_MASK)
-#define MBOX_DMA_POLICY_TX_ORDER_MSB             2
-#define MBOX_DMA_POLICY_TX_ORDER_LSB             2
-#define MBOX_DMA_POLICY_TX_ORDER_MASK            0x00000004
-#define MBOX_DMA_POLICY_TX_ORDER_GET(x)          (((x) & MBOX_DMA_POLICY_TX_ORDER_MASK) >> MBOX_DMA_POLICY_TX_ORDER_LSB)
-#define MBOX_DMA_POLICY_TX_ORDER_SET(x)          (((x) << MBOX_DMA_POLICY_TX_ORDER_LSB) & MBOX_DMA_POLICY_TX_ORDER_MASK)
-#define MBOX_DMA_POLICY_RX_QUANTUM_MSB           1
-#define MBOX_DMA_POLICY_RX_QUANTUM_LSB           1
-#define MBOX_DMA_POLICY_RX_QUANTUM_MASK          0x00000002
-#define MBOX_DMA_POLICY_RX_QUANTUM_GET(x)        (((x) & MBOX_DMA_POLICY_RX_QUANTUM_MASK) >> MBOX_DMA_POLICY_RX_QUANTUM_LSB)
-#define MBOX_DMA_POLICY_RX_QUANTUM_SET(x)        (((x) << MBOX_DMA_POLICY_RX_QUANTUM_LSB) & MBOX_DMA_POLICY_RX_QUANTUM_MASK)
-#define MBOX_DMA_POLICY_RX_ORDER_MSB             0
-#define MBOX_DMA_POLICY_RX_ORDER_LSB             0
-#define MBOX_DMA_POLICY_RX_ORDER_MASK            0x00000001
-#define MBOX_DMA_POLICY_RX_ORDER_GET(x)          (((x) & MBOX_DMA_POLICY_RX_ORDER_MASK) >> MBOX_DMA_POLICY_RX_ORDER_LSB)
-#define MBOX_DMA_POLICY_RX_ORDER_SET(x)          (((x) << MBOX_DMA_POLICY_RX_ORDER_LSB) & MBOX_DMA_POLICY_RX_ORDER_MASK)
-
-#define MBOX0_DMA_RX_DESCRIPTOR_BASE_ADDRESS     0x00000018
-#define MBOX0_DMA_RX_DESCRIPTOR_BASE_OFFSET      0x00000018
-#define MBOX0_DMA_RX_DESCRIPTOR_BASE_ADDRESS_MSB 27
-#define MBOX0_DMA_RX_DESCRIPTOR_BASE_ADDRESS_LSB 2
-#define MBOX0_DMA_RX_DESCRIPTOR_BASE_ADDRESS_MASK 0x0ffffffc
-#define MBOX0_DMA_RX_DESCRIPTOR_BASE_ADDRESS_GET(x) (((x) & MBOX0_DMA_RX_DESCRIPTOR_BASE_ADDRESS_MASK) >> MBOX0_DMA_RX_DESCRIPTOR_BASE_ADDRESS_LSB)
-#define MBOX0_DMA_RX_DESCRIPTOR_BASE_ADDRESS_SET(x) (((x) << MBOX0_DMA_RX_DESCRIPTOR_BASE_ADDRESS_LSB) & MBOX0_DMA_RX_DESCRIPTOR_BASE_ADDRESS_MASK)
-
-#define MBOX0_DMA_RX_CONTROL_ADDRESS             0x0000001c
-#define MBOX0_DMA_RX_CONTROL_OFFSET              0x0000001c
-#define MBOX0_DMA_RX_CONTROL_RESUME_MSB          2
-#define MBOX0_DMA_RX_CONTROL_RESUME_LSB          2
-#define MBOX0_DMA_RX_CONTROL_RESUME_MASK         0x00000004
-#define MBOX0_DMA_RX_CONTROL_RESUME_GET(x)       (((x) & MBOX0_DMA_RX_CONTROL_RESUME_MASK) >> MBOX0_DMA_RX_CONTROL_RESUME_LSB)
-#define MBOX0_DMA_RX_CONTROL_RESUME_SET(x)       (((x) << MBOX0_DMA_RX_CONTROL_RESUME_LSB) & MBOX0_DMA_RX_CONTROL_RESUME_MASK)
-#define MBOX0_DMA_RX_CONTROL_START_MSB           1
-#define MBOX0_DMA_RX_CONTROL_START_LSB           1
-#define MBOX0_DMA_RX_CONTROL_START_MASK          0x00000002
-#define MBOX0_DMA_RX_CONTROL_START_GET(x)        (((x) & MBOX0_DMA_RX_CONTROL_START_MASK) >> MBOX0_DMA_RX_CONTROL_START_LSB)
-#define MBOX0_DMA_RX_CONTROL_START_SET(x)        (((x) << MBOX0_DMA_RX_CONTROL_START_LSB) & MBOX0_DMA_RX_CONTROL_START_MASK)
-#define MBOX0_DMA_RX_CONTROL_STOP_MSB            0
-#define MBOX0_DMA_RX_CONTROL_STOP_LSB            0
-#define MBOX0_DMA_RX_CONTROL_STOP_MASK           0x00000001
-#define MBOX0_DMA_RX_CONTROL_STOP_GET(x)         (((x) & MBOX0_DMA_RX_CONTROL_STOP_MASK) >> MBOX0_DMA_RX_CONTROL_STOP_LSB)
-#define MBOX0_DMA_RX_CONTROL_STOP_SET(x)         (((x) << MBOX0_DMA_RX_CONTROL_STOP_LSB) & MBOX0_DMA_RX_CONTROL_STOP_MASK)
-
-#define MBOX0_DMA_TX_DESCRIPTOR_BASE_ADDRESS     0x00000020
-#define MBOX0_DMA_TX_DESCRIPTOR_BASE_OFFSET      0x00000020
-#define MBOX0_DMA_TX_DESCRIPTOR_BASE_ADDRESS_MSB 27
-#define MBOX0_DMA_TX_DESCRIPTOR_BASE_ADDRESS_LSB 2
-#define MBOX0_DMA_TX_DESCRIPTOR_BASE_ADDRESS_MASK 0x0ffffffc
-#define MBOX0_DMA_TX_DESCRIPTOR_BASE_ADDRESS_GET(x) (((x) & MBOX0_DMA_TX_DESCRIPTOR_BASE_ADDRESS_MASK) >> MBOX0_DMA_TX_DESCRIPTOR_BASE_ADDRESS_LSB)
-#define MBOX0_DMA_TX_DESCRIPTOR_BASE_ADDRESS_SET(x) (((x) << MBOX0_DMA_TX_DESCRIPTOR_BASE_ADDRESS_LSB) & MBOX0_DMA_TX_DESCRIPTOR_BASE_ADDRESS_MASK)
-
-#define MBOX0_DMA_TX_CONTROL_ADDRESS             0x00000024
-#define MBOX0_DMA_TX_CONTROL_OFFSET              0x00000024
-#define MBOX0_DMA_TX_CONTROL_RESUME_MSB          2
-#define MBOX0_DMA_TX_CONTROL_RESUME_LSB          2
-#define MBOX0_DMA_TX_CONTROL_RESUME_MASK         0x00000004
-#define MBOX0_DMA_TX_CONTROL_RESUME_GET(x)       (((x) & MBOX0_DMA_TX_CONTROL_RESUME_MASK) >> MBOX0_DMA_TX_CONTROL_RESUME_LSB)
-#define MBOX0_DMA_TX_CONTROL_RESUME_SET(x)       (((x) << MBOX0_DMA_TX_CONTROL_RESUME_LSB) & MBOX0_DMA_TX_CONTROL_RESUME_MASK)
-#define MBOX0_DMA_TX_CONTROL_START_MSB           1
-#define MBOX0_DMA_TX_CONTROL_START_LSB           1
-#define MBOX0_DMA_TX_CONTROL_START_MASK          0x00000002
-#define MBOX0_DMA_TX_CONTROL_START_GET(x)        (((x) & MBOX0_DMA_TX_CONTROL_START_MASK) >> MBOX0_DMA_TX_CONTROL_START_LSB)
-#define MBOX0_DMA_TX_CONTROL_START_SET(x)        (((x) << MBOX0_DMA_TX_CONTROL_START_LSB) & MBOX0_DMA_TX_CONTROL_START_MASK)
-#define MBOX0_DMA_TX_CONTROL_STOP_MSB            0
-#define MBOX0_DMA_TX_CONTROL_STOP_LSB            0
-#define MBOX0_DMA_TX_CONTROL_STOP_MASK           0x00000001
-#define MBOX0_DMA_TX_CONTROL_STOP_GET(x)         (((x) & MBOX0_DMA_TX_CONTROL_STOP_MASK) >> MBOX0_DMA_TX_CONTROL_STOP_LSB)
-#define MBOX0_DMA_TX_CONTROL_STOP_SET(x)         (((x) << MBOX0_DMA_TX_CONTROL_STOP_LSB) & MBOX0_DMA_TX_CONTROL_STOP_MASK)
-
-#define MBOX1_DMA_RX_DESCRIPTOR_BASE_ADDRESS     0x00000028
-#define MBOX1_DMA_RX_DESCRIPTOR_BASE_OFFSET      0x00000028
-#define MBOX1_DMA_RX_DESCRIPTOR_BASE_ADDRESS_MSB 27
-#define MBOX1_DMA_RX_DESCRIPTOR_BASE_ADDRESS_LSB 2
-#define MBOX1_DMA_RX_DESCRIPTOR_BASE_ADDRESS_MASK 0x0ffffffc
-#define MBOX1_DMA_RX_DESCRIPTOR_BASE_ADDRESS_GET(x) (((x) & MBOX1_DMA_RX_DESCRIPTOR_BASE_ADDRESS_MASK) >> MBOX1_DMA_RX_DESCRIPTOR_BASE_ADDRESS_LSB)
-#define MBOX1_DMA_RX_DESCRIPTOR_BASE_ADDRESS_SET(x) (((x) << MBOX1_DMA_RX_DESCRIPTOR_BASE_ADDRESS_LSB) & MBOX1_DMA_RX_DESCRIPTOR_BASE_ADDRESS_MASK)
-
-#define MBOX1_DMA_RX_CONTROL_ADDRESS             0x0000002c
-#define MBOX1_DMA_RX_CONTROL_OFFSET              0x0000002c
-#define MBOX1_DMA_RX_CONTROL_RESUME_MSB          2
-#define MBOX1_DMA_RX_CONTROL_RESUME_LSB          2
-#define MBOX1_DMA_RX_CONTROL_RESUME_MASK         0x00000004
-#define MBOX1_DMA_RX_CONTROL_RESUME_GET(x)       (((x) & MBOX1_DMA_RX_CONTROL_RESUME_MASK) >> MBOX1_DMA_RX_CONTROL_RESUME_LSB)
-#define MBOX1_DMA_RX_CONTROL_RESUME_SET(x)       (((x) << MBOX1_DMA_RX_CONTROL_RESUME_LSB) & MBOX1_DMA_RX_CONTROL_RESUME_MASK)
-#define MBOX1_DMA_RX_CONTROL_START_MSB           1
-#define MBOX1_DMA_RX_CONTROL_START_LSB           1
-#define MBOX1_DMA_RX_CONTROL_START_MASK          0x00000002
-#define MBOX1_DMA_RX_CONTROL_START_GET(x)        (((x) & MBOX1_DMA_RX_CONTROL_START_MASK) >> MBOX1_DMA_RX_CONTROL_START_LSB)
-#define MBOX1_DMA_RX_CONTROL_START_SET(x)        (((x) << MBOX1_DMA_RX_CONTROL_START_LSB) & MBOX1_DMA_RX_CONTROL_START_MASK)
-#define MBOX1_DMA_RX_CONTROL_STOP_MSB            0
-#define MBOX1_DMA_RX_CONTROL_STOP_LSB            0
-#define MBOX1_DMA_RX_CONTROL_STOP_MASK           0x00000001
-#define MBOX1_DMA_RX_CONTROL_STOP_GET(x)         (((x) & MBOX1_DMA_RX_CONTROL_STOP_MASK) >> MBOX1_DMA_RX_CONTROL_STOP_LSB)
-#define MBOX1_DMA_RX_CONTROL_STOP_SET(x)         (((x) << MBOX1_DMA_RX_CONTROL_STOP_LSB) & MBOX1_DMA_RX_CONTROL_STOP_MASK)
-
-#define MBOX1_DMA_TX_DESCRIPTOR_BASE_ADDRESS     0x00000030
-#define MBOX1_DMA_TX_DESCRIPTOR_BASE_OFFSET      0x00000030
-#define MBOX1_DMA_TX_DESCRIPTOR_BASE_ADDRESS_MSB 27
-#define MBOX1_DMA_TX_DESCRIPTOR_BASE_ADDRESS_LSB 2
-#define MBOX1_DMA_TX_DESCRIPTOR_BASE_ADDRESS_MASK 0x0ffffffc
-#define MBOX1_DMA_TX_DESCRIPTOR_BASE_ADDRESS_GET(x) (((x) & MBOX1_DMA_TX_DESCRIPTOR_BASE_ADDRESS_MASK) >> MBOX1_DMA_TX_DESCRIPTOR_BASE_ADDRESS_LSB)
-#define MBOX1_DMA_TX_DESCRIPTOR_BASE_ADDRESS_SET(x) (((x) << MBOX1_DMA_TX_DESCRIPTOR_BASE_ADDRESS_LSB) & MBOX1_DMA_TX_DESCRIPTOR_BASE_ADDRESS_MASK)
-
-#define MBOX1_DMA_TX_CONTROL_ADDRESS             0x00000034
-#define MBOX1_DMA_TX_CONTROL_OFFSET              0x00000034
-#define MBOX1_DMA_TX_CONTROL_RESUME_MSB          2
-#define MBOX1_DMA_TX_CONTROL_RESUME_LSB          2
-#define MBOX1_DMA_TX_CONTROL_RESUME_MASK         0x00000004
-#define MBOX1_DMA_TX_CONTROL_RESUME_GET(x)       (((x) & MBOX1_DMA_TX_CONTROL_RESUME_MASK) >> MBOX1_DMA_TX_CONTROL_RESUME_LSB)
-#define MBOX1_DMA_TX_CONTROL_RESUME_SET(x)       (((x) << MBOX1_DMA_TX_CONTROL_RESUME_LSB) & MBOX1_DMA_TX_CONTROL_RESUME_MASK)
-#define MBOX1_DMA_TX_CONTROL_START_MSB           1
-#define MBOX1_DMA_TX_CONTROL_START_LSB           1
-#define MBOX1_DMA_TX_CONTROL_START_MASK          0x00000002
-#define MBOX1_DMA_TX_CONTROL_START_GET(x)        (((x) & MBOX1_DMA_TX_CONTROL_START_MASK) >> MBOX1_DMA_TX_CONTROL_START_LSB)
-#define MBOX1_DMA_TX_CONTROL_START_SET(x)        (((x) << MBOX1_DMA_TX_CONTROL_START_LSB) & MBOX1_DMA_TX_CONTROL_START_MASK)
-#define MBOX1_DMA_TX_CONTROL_STOP_MSB            0
-#define MBOX1_DMA_TX_CONTROL_STOP_LSB            0
-#define MBOX1_DMA_TX_CONTROL_STOP_MASK           0x00000001
-#define MBOX1_DMA_TX_CONTROL_STOP_GET(x)         (((x) & MBOX1_DMA_TX_CONTROL_STOP_MASK) >> MBOX1_DMA_TX_CONTROL_STOP_LSB)
-#define MBOX1_DMA_TX_CONTROL_STOP_SET(x)         (((x) << MBOX1_DMA_TX_CONTROL_STOP_LSB) & MBOX1_DMA_TX_CONTROL_STOP_MASK)
-
-#define MBOX2_DMA_RX_DESCRIPTOR_BASE_ADDRESS     0x00000038
-#define MBOX2_DMA_RX_DESCRIPTOR_BASE_OFFSET      0x00000038
-#define MBOX2_DMA_RX_DESCRIPTOR_BASE_ADDRESS_MSB 27
-#define MBOX2_DMA_RX_DESCRIPTOR_BASE_ADDRESS_LSB 2
-#define MBOX2_DMA_RX_DESCRIPTOR_BASE_ADDRESS_MASK 0x0ffffffc
-#define MBOX2_DMA_RX_DESCRIPTOR_BASE_ADDRESS_GET(x) (((x) & MBOX2_DMA_RX_DESCRIPTOR_BASE_ADDRESS_MASK) >> MBOX2_DMA_RX_DESCRIPTOR_BASE_ADDRESS_LSB)
-#define MBOX2_DMA_RX_DESCRIPTOR_BASE_ADDRESS_SET(x) (((x) << MBOX2_DMA_RX_DESCRIPTOR_BASE_ADDRESS_LSB) & MBOX2_DMA_RX_DESCRIPTOR_BASE_ADDRESS_MASK)
-
-#define MBOX2_DMA_RX_CONTROL_ADDRESS             0x0000003c
-#define MBOX2_DMA_RX_CONTROL_OFFSET              0x0000003c
-#define MBOX2_DMA_RX_CONTROL_RESUME_MSB          2
-#define MBOX2_DMA_RX_CONTROL_RESUME_LSB          2
-#define MBOX2_DMA_RX_CONTROL_RESUME_MASK         0x00000004
-#define MBOX2_DMA_RX_CONTROL_RESUME_GET(x)       (((x) & MBOX2_DMA_RX_CONTROL_RESUME_MASK) >> MBOX2_DMA_RX_CONTROL_RESUME_LSB)
-#define MBOX2_DMA_RX_CONTROL_RESUME_SET(x)       (((x) << MBOX2_DMA_RX_CONTROL_RESUME_LSB) & MBOX2_DMA_RX_CONTROL_RESUME_MASK)
-#define MBOX2_DMA_RX_CONTROL_START_MSB           1
-#define MBOX2_DMA_RX_CONTROL_START_LSB           1
-#define MBOX2_DMA_RX_CONTROL_START_MASK          0x00000002
-#define MBOX2_DMA_RX_CONTROL_START_GET(x)        (((x) & MBOX2_DMA_RX_CONTROL_START_MASK) >> MBOX2_DMA_RX_CONTROL_START_LSB)
-#define MBOX2_DMA_RX_CONTROL_START_SET(x)        (((x) << MBOX2_DMA_RX_CONTROL_START_LSB) & MBOX2_DMA_RX_CONTROL_START_MASK)
-#define MBOX2_DMA_RX_CONTROL_STOP_MSB            0
-#define MBOX2_DMA_RX_CONTROL_STOP_LSB            0
-#define MBOX2_DMA_RX_CONTROL_STOP_MASK           0x00000001
-#define MBOX2_DMA_RX_CONTROL_STOP_GET(x)         (((x) & MBOX2_DMA_RX_CONTROL_STOP_MASK) >> MBOX2_DMA_RX_CONTROL_STOP_LSB)
-#define MBOX2_DMA_RX_CONTROL_STOP_SET(x)         (((x) << MBOX2_DMA_RX_CONTROL_STOP_LSB) & MBOX2_DMA_RX_CONTROL_STOP_MASK)
-
-#define MBOX2_DMA_TX_DESCRIPTOR_BASE_ADDRESS     0x00000040
-#define MBOX2_DMA_TX_DESCRIPTOR_BASE_OFFSET      0x00000040
-#define MBOX2_DMA_TX_DESCRIPTOR_BASE_ADDRESS_MSB 27
-#define MBOX2_DMA_TX_DESCRIPTOR_BASE_ADDRESS_LSB 2
-#define MBOX2_DMA_TX_DESCRIPTOR_BASE_ADDRESS_MASK 0x0ffffffc
-#define MBOX2_DMA_TX_DESCRIPTOR_BASE_ADDRESS_GET(x) (((x) & MBOX2_DMA_TX_DESCRIPTOR_BASE_ADDRESS_MASK) >> MBOX2_DMA_TX_DESCRIPTOR_BASE_ADDRESS_LSB)
-#define MBOX2_DMA_TX_DESCRIPTOR_BASE_ADDRESS_SET(x) (((x) << MBOX2_DMA_TX_DESCRIPTOR_BASE_ADDRESS_LSB) & MBOX2_DMA_TX_DESCRIPTOR_BASE_ADDRESS_MASK)
-
-#define MBOX2_DMA_TX_CONTROL_ADDRESS             0x00000044
-#define MBOX2_DMA_TX_CONTROL_OFFSET              0x00000044
-#define MBOX2_DMA_TX_CONTROL_RESUME_MSB          2
-#define MBOX2_DMA_TX_CONTROL_RESUME_LSB          2
-#define MBOX2_DMA_TX_CONTROL_RESUME_MASK         0x00000004
-#define MBOX2_DMA_TX_CONTROL_RESUME_GET(x)       (((x) & MBOX2_DMA_TX_CONTROL_RESUME_MASK) >> MBOX2_DMA_TX_CONTROL_RESUME_LSB)
-#define MBOX2_DMA_TX_CONTROL_RESUME_SET(x)       (((x) << MBOX2_DMA_TX_CONTROL_RESUME_LSB) & MBOX2_DMA_TX_CONTROL_RESUME_MASK)
-#define MBOX2_DMA_TX_CONTROL_START_MSB           1
-#define MBOX2_DMA_TX_CONTROL_START_LSB           1
-#define MBOX2_DMA_TX_CONTROL_START_MASK          0x00000002
-#define MBOX2_DMA_TX_CONTROL_START_GET(x)        (((x) & MBOX2_DMA_TX_CONTROL_START_MASK) >> MBOX2_DMA_TX_CONTROL_START_LSB)
-#define MBOX2_DMA_TX_CONTROL_START_SET(x)        (((x) << MBOX2_DMA_TX_CONTROL_START_LSB) & MBOX2_DMA_TX_CONTROL_START_MASK)
-#define MBOX2_DMA_TX_CONTROL_STOP_MSB            0
-#define MBOX2_DMA_TX_CONTROL_STOP_LSB            0
-#define MBOX2_DMA_TX_CONTROL_STOP_MASK           0x00000001
-#define MBOX2_DMA_TX_CONTROL_STOP_GET(x)         (((x) & MBOX2_DMA_TX_CONTROL_STOP_MASK) >> MBOX2_DMA_TX_CONTROL_STOP_LSB)
-#define MBOX2_DMA_TX_CONTROL_STOP_SET(x)         (((x) << MBOX2_DMA_TX_CONTROL_STOP_LSB) & MBOX2_DMA_TX_CONTROL_STOP_MASK)
-
-#define MBOX3_DMA_RX_DESCRIPTOR_BASE_ADDRESS     0x00000048
-#define MBOX3_DMA_RX_DESCRIPTOR_BASE_OFFSET      0x00000048
-#define MBOX3_DMA_RX_DESCRIPTOR_BASE_ADDRESS_MSB 27
-#define MBOX3_DMA_RX_DESCRIPTOR_BASE_ADDRESS_LSB 2
-#define MBOX3_DMA_RX_DESCRIPTOR_BASE_ADDRESS_MASK 0x0ffffffc
-#define MBOX3_DMA_RX_DESCRIPTOR_BASE_ADDRESS_GET(x) (((x) & MBOX3_DMA_RX_DESCRIPTOR_BASE_ADDRESS_MASK) >> MBOX3_DMA_RX_DESCRIPTOR_BASE_ADDRESS_LSB)
-#define MBOX3_DMA_RX_DESCRIPTOR_BASE_ADDRESS_SET(x) (((x) << MBOX3_DMA_RX_DESCRIPTOR_BASE_ADDRESS_LSB) & MBOX3_DMA_RX_DESCRIPTOR_BASE_ADDRESS_MASK)
-
-#define MBOX3_DMA_RX_CONTROL_ADDRESS             0x0000004c
-#define MBOX3_DMA_RX_CONTROL_OFFSET              0x0000004c
-#define MBOX3_DMA_RX_CONTROL_RESUME_MSB          2
-#define MBOX3_DMA_RX_CONTROL_RESUME_LSB          2
-#define MBOX3_DMA_RX_CONTROL_RESUME_MASK         0x00000004
-#define MBOX3_DMA_RX_CONTROL_RESUME_GET(x)       (((x) & MBOX3_DMA_RX_CONTROL_RESUME_MASK) >> MBOX3_DMA_RX_CONTROL_RESUME_LSB)
-#define MBOX3_DMA_RX_CONTROL_RESUME_SET(x)       (((x) << MBOX3_DMA_RX_CONTROL_RESUME_LSB) & MBOX3_DMA_RX_CONTROL_RESUME_MASK)
-#define MBOX3_DMA_RX_CONTROL_START_MSB           1
-#define MBOX3_DMA_RX_CONTROL_START_LSB           1
-#define MBOX3_DMA_RX_CONTROL_START_MASK          0x00000002
-#define MBOX3_DMA_RX_CONTROL_START_GET(x)        (((x) & MBOX3_DMA_RX_CONTROL_START_MASK) >> MBOX3_DMA_RX_CONTROL_START_LSB)
-#define MBOX3_DMA_RX_CONTROL_START_SET(x)        (((x) << MBOX3_DMA_RX_CONTROL_START_LSB) & MBOX3_DMA_RX_CONTROL_START_MASK)
-#define MBOX3_DMA_RX_CONTROL_STOP_MSB            0
-#define MBOX3_DMA_RX_CONTROL_STOP_LSB            0
-#define MBOX3_DMA_RX_CONTROL_STOP_MASK           0x00000001
-#define MBOX3_DMA_RX_CONTROL_STOP_GET(x)         (((x) & MBOX3_DMA_RX_CONTROL_STOP_MASK) >> MBOX3_DMA_RX_CONTROL_STOP_LSB)
-#define MBOX3_DMA_RX_CONTROL_STOP_SET(x)         (((x) << MBOX3_DMA_RX_CONTROL_STOP_LSB) & MBOX3_DMA_RX_CONTROL_STOP_MASK)
-
-#define MBOX3_DMA_TX_DESCRIPTOR_BASE_ADDRESS     0x00000050
-#define MBOX3_DMA_TX_DESCRIPTOR_BASE_OFFSET      0x00000050
-#define MBOX3_DMA_TX_DESCRIPTOR_BASE_ADDRESS_MSB 27
-#define MBOX3_DMA_TX_DESCRIPTOR_BASE_ADDRESS_LSB 2
-#define MBOX3_DMA_TX_DESCRIPTOR_BASE_ADDRESS_MASK 0x0ffffffc
-#define MBOX3_DMA_TX_DESCRIPTOR_BASE_ADDRESS_GET(x) (((x) & MBOX3_DMA_TX_DESCRIPTOR_BASE_ADDRESS_MASK) >> MBOX3_DMA_TX_DESCRIPTOR_BASE_ADDRESS_LSB)
-#define MBOX3_DMA_TX_DESCRIPTOR_BASE_ADDRESS_SET(x) (((x) << MBOX3_DMA_TX_DESCRIPTOR_BASE_ADDRESS_LSB) & MBOX3_DMA_TX_DESCRIPTOR_BASE_ADDRESS_MASK)
-
-#define MBOX3_DMA_TX_CONTROL_ADDRESS             0x00000054
-#define MBOX3_DMA_TX_CONTROL_OFFSET              0x00000054
-#define MBOX3_DMA_TX_CONTROL_RESUME_MSB          2
-#define MBOX3_DMA_TX_CONTROL_RESUME_LSB          2
-#define MBOX3_DMA_TX_CONTROL_RESUME_MASK         0x00000004
-#define MBOX3_DMA_TX_CONTROL_RESUME_GET(x)       (((x) & MBOX3_DMA_TX_CONTROL_RESUME_MASK) >> MBOX3_DMA_TX_CONTROL_RESUME_LSB)
-#define MBOX3_DMA_TX_CONTROL_RESUME_SET(x)       (((x) << MBOX3_DMA_TX_CONTROL_RESUME_LSB) & MBOX3_DMA_TX_CONTROL_RESUME_MASK)
-#define MBOX3_DMA_TX_CONTROL_START_MSB           1
-#define MBOX3_DMA_TX_CONTROL_START_LSB           1
-#define MBOX3_DMA_TX_CONTROL_START_MASK          0x00000002
-#define MBOX3_DMA_TX_CONTROL_START_GET(x)        (((x) & MBOX3_DMA_TX_CONTROL_START_MASK) >> MBOX3_DMA_TX_CONTROL_START_LSB)
-#define MBOX3_DMA_TX_CONTROL_START_SET(x)        (((x) << MBOX3_DMA_TX_CONTROL_START_LSB) & MBOX3_DMA_TX_CONTROL_START_MASK)
-#define MBOX3_DMA_TX_CONTROL_STOP_MSB            0
-#define MBOX3_DMA_TX_CONTROL_STOP_LSB            0
-#define MBOX3_DMA_TX_CONTROL_STOP_MASK           0x00000001
-#define MBOX3_DMA_TX_CONTROL_STOP_GET(x)         (((x) & MBOX3_DMA_TX_CONTROL_STOP_MASK) >> MBOX3_DMA_TX_CONTROL_STOP_LSB)
-#define MBOX3_DMA_TX_CONTROL_STOP_SET(x)         (((x) << MBOX3_DMA_TX_CONTROL_STOP_LSB) & MBOX3_DMA_TX_CONTROL_STOP_MASK)
-
-#define MBOX_INT_STATUS_ADDRESS                  0x00000058
-#define MBOX_INT_STATUS_OFFSET                   0x00000058
-#define MBOX_INT_STATUS_RX_DMA_COMPLETE_MSB      31
-#define MBOX_INT_STATUS_RX_DMA_COMPLETE_LSB      28
-#define MBOX_INT_STATUS_RX_DMA_COMPLETE_MASK     0xf0000000
-#define MBOX_INT_STATUS_RX_DMA_COMPLETE_GET(x)   (((x) & MBOX_INT_STATUS_RX_DMA_COMPLETE_MASK) >> MBOX_INT_STATUS_RX_DMA_COMPLETE_LSB)
-#define MBOX_INT_STATUS_RX_DMA_COMPLETE_SET(x)   (((x) << MBOX_INT_STATUS_RX_DMA_COMPLETE_LSB) & MBOX_INT_STATUS_RX_DMA_COMPLETE_MASK)
-#define MBOX_INT_STATUS_TX_DMA_EOM_COMPLETE_MSB  27
-#define MBOX_INT_STATUS_TX_DMA_EOM_COMPLETE_LSB  24
-#define MBOX_INT_STATUS_TX_DMA_EOM_COMPLETE_MASK 0x0f000000
-#define MBOX_INT_STATUS_TX_DMA_EOM_COMPLETE_GET(x) (((x) & MBOX_INT_STATUS_TX_DMA_EOM_COMPLETE_MASK) >> MBOX_INT_STATUS_TX_DMA_EOM_COMPLETE_LSB)
-#define MBOX_INT_STATUS_TX_DMA_EOM_COMPLETE_SET(x) (((x) << MBOX_INT_STATUS_TX_DMA_EOM_COMPLETE_LSB) & MBOX_INT_STATUS_TX_DMA_EOM_COMPLETE_MASK)
-#define MBOX_INT_STATUS_TX_DMA_COMPLETE_MSB      23
-#define MBOX_INT_STATUS_TX_DMA_COMPLETE_LSB      20
-#define MBOX_INT_STATUS_TX_DMA_COMPLETE_MASK     0x00f00000
-#define MBOX_INT_STATUS_TX_DMA_COMPLETE_GET(x)   (((x) & MBOX_INT_STATUS_TX_DMA_COMPLETE_MASK) >> MBOX_INT_STATUS_TX_DMA_COMPLETE_LSB)
-#define MBOX_INT_STATUS_TX_DMA_COMPLETE_SET(x)   (((x) << MBOX_INT_STATUS_TX_DMA_COMPLETE_LSB) & MBOX_INT_STATUS_TX_DMA_COMPLETE_MASK)
-#define MBOX_INT_STATUS_TX_OVERFLOW_MSB          17
-#define MBOX_INT_STATUS_TX_OVERFLOW_LSB          17
-#define MBOX_INT_STATUS_TX_OVERFLOW_MASK         0x00020000
-#define MBOX_INT_STATUS_TX_OVERFLOW_GET(x)       (((x) & MBOX_INT_STATUS_TX_OVERFLOW_MASK) >> MBOX_INT_STATUS_TX_OVERFLOW_LSB)
-#define MBOX_INT_STATUS_TX_OVERFLOW_SET(x)       (((x) << MBOX_INT_STATUS_TX_OVERFLOW_LSB) & MBOX_INT_STATUS_TX_OVERFLOW_MASK)
-#define MBOX_INT_STATUS_RX_UNDERFLOW_MSB         16
-#define MBOX_INT_STATUS_RX_UNDERFLOW_LSB         16
-#define MBOX_INT_STATUS_RX_UNDERFLOW_MASK        0x00010000
-#define MBOX_INT_STATUS_RX_UNDERFLOW_GET(x)      (((x) & MBOX_INT_STATUS_RX_UNDERFLOW_MASK) >> MBOX_INT_STATUS_RX_UNDERFLOW_LSB)
-#define MBOX_INT_STATUS_RX_UNDERFLOW_SET(x)      (((x) << MBOX_INT_STATUS_RX_UNDERFLOW_LSB) & MBOX_INT_STATUS_RX_UNDERFLOW_MASK)
-#define MBOX_INT_STATUS_TX_NOT_EMPTY_MSB         15
-#define MBOX_INT_STATUS_TX_NOT_EMPTY_LSB         12
-#define MBOX_INT_STATUS_TX_NOT_EMPTY_MASK        0x0000f000
-#define MBOX_INT_STATUS_TX_NOT_EMPTY_GET(x)      (((x) & MBOX_INT_STATUS_TX_NOT_EMPTY_MASK) >> MBOX_INT_STATUS_TX_NOT_EMPTY_LSB)
-#define MBOX_INT_STATUS_TX_NOT_EMPTY_SET(x)      (((x) << MBOX_INT_STATUS_TX_NOT_EMPTY_LSB) & MBOX_INT_STATUS_TX_NOT_EMPTY_MASK)
-#define MBOX_INT_STATUS_RX_NOT_FULL_MSB          11
-#define MBOX_INT_STATUS_RX_NOT_FULL_LSB          8
-#define MBOX_INT_STATUS_RX_NOT_FULL_MASK         0x00000f00
-#define MBOX_INT_STATUS_RX_NOT_FULL_GET(x)       (((x) & MBOX_INT_STATUS_RX_NOT_FULL_MASK) >> MBOX_INT_STATUS_RX_NOT_FULL_LSB)
-#define MBOX_INT_STATUS_RX_NOT_FULL_SET(x)       (((x) << MBOX_INT_STATUS_RX_NOT_FULL_LSB) & MBOX_INT_STATUS_RX_NOT_FULL_MASK)
-#define MBOX_INT_STATUS_HOST_MSB                 7
-#define MBOX_INT_STATUS_HOST_LSB                 0
-#define MBOX_INT_STATUS_HOST_MASK                0x000000ff
-#define MBOX_INT_STATUS_HOST_GET(x)              (((x) & MBOX_INT_STATUS_HOST_MASK) >> MBOX_INT_STATUS_HOST_LSB)
-#define MBOX_INT_STATUS_HOST_SET(x)              (((x) << MBOX_INT_STATUS_HOST_LSB) & MBOX_INT_STATUS_HOST_MASK)
-
-#define MBOX_INT_ENABLE_ADDRESS                  0x0000005c
-#define MBOX_INT_ENABLE_OFFSET                   0x0000005c
-#define MBOX_INT_ENABLE_RX_DMA_COMPLETE_MSB      31
-#define MBOX_INT_ENABLE_RX_DMA_COMPLETE_LSB      28
-#define MBOX_INT_ENABLE_RX_DMA_COMPLETE_MASK     0xf0000000
-#define MBOX_INT_ENABLE_RX_DMA_COMPLETE_GET(x)   (((x) & MBOX_INT_ENABLE_RX_DMA_COMPLETE_MASK) >> MBOX_INT_ENABLE_RX_DMA_COMPLETE_LSB)
-#define MBOX_INT_ENABLE_RX_DMA_COMPLETE_SET(x)   (((x) << MBOX_INT_ENABLE_RX_DMA_COMPLETE_LSB) & MBOX_INT_ENABLE_RX_DMA_COMPLETE_MASK)
-#define MBOX_INT_ENABLE_TX_DMA_EOM_COMPLETE_MSB  27
-#define MBOX_INT_ENABLE_TX_DMA_EOM_COMPLETE_LSB  24
-#define MBOX_INT_ENABLE_TX_DMA_EOM_COMPLETE_MASK 0x0f000000
-#define MBOX_INT_ENABLE_TX_DMA_EOM_COMPLETE_GET(x) (((x) & MBOX_INT_ENABLE_TX_DMA_EOM_COMPLETE_MASK) >> MBOX_INT_ENABLE_TX_DMA_EOM_COMPLETE_LSB)
-#define MBOX_INT_ENABLE_TX_DMA_EOM_COMPLETE_SET(x) (((x) << MBOX_INT_ENABLE_TX_DMA_EOM_COMPLETE_LSB) & MBOX_INT_ENABLE_TX_DMA_EOM_COMPLETE_MASK)
-#define MBOX_INT_ENABLE_TX_DMA_COMPLETE_MSB      23
-#define MBOX_INT_ENABLE_TX_DMA_COMPLETE_LSB      20
-#define MBOX_INT_ENABLE_TX_DMA_COMPLETE_MASK     0x00f00000
-#define MBOX_INT_ENABLE_TX_DMA_COMPLETE_GET(x)   (((x) & MBOX_INT_ENABLE_TX_DMA_COMPLETE_MASK) >> MBOX_INT_ENABLE_TX_DMA_COMPLETE_LSB)
-#define MBOX_INT_ENABLE_TX_DMA_COMPLETE_SET(x)   (((x) << MBOX_INT_ENABLE_TX_DMA_COMPLETE_LSB) & MBOX_INT_ENABLE_TX_DMA_COMPLETE_MASK)
-#define MBOX_INT_ENABLE_TX_OVERFLOW_MSB          17
-#define MBOX_INT_ENABLE_TX_OVERFLOW_LSB          17
-#define MBOX_INT_ENABLE_TX_OVERFLOW_MASK         0x00020000
-#define MBOX_INT_ENABLE_TX_OVERFLOW_GET(x)       (((x) & MBOX_INT_ENABLE_TX_OVERFLOW_MASK) >> MBOX_INT_ENABLE_TX_OVERFLOW_LSB)
-#define MBOX_INT_ENABLE_TX_OVERFLOW_SET(x)       (((x) << MBOX_INT_ENABLE_TX_OVERFLOW_LSB) & MBOX_INT_ENABLE_TX_OVERFLOW_MASK)
-#define MBOX_INT_ENABLE_RX_UNDERFLOW_MSB         16
-#define MBOX_INT_ENABLE_RX_UNDERFLOW_LSB         16
-#define MBOX_INT_ENABLE_RX_UNDERFLOW_MASK        0x00010000
-#define MBOX_INT_ENABLE_RX_UNDERFLOW_GET(x)      (((x) & MBOX_INT_ENABLE_RX_UNDERFLOW_MASK) >> MBOX_INT_ENABLE_RX_UNDERFLOW_LSB)
-#define MBOX_INT_ENABLE_RX_UNDERFLOW_SET(x)      (((x) << MBOX_INT_ENABLE_RX_UNDERFLOW_LSB) & MBOX_INT_ENABLE_RX_UNDERFLOW_MASK)
-#define MBOX_INT_ENABLE_TX_NOT_EMPTY_MSB         15
-#define MBOX_INT_ENABLE_TX_NOT_EMPTY_LSB         12
-#define MBOX_INT_ENABLE_TX_NOT_EMPTY_MASK        0x0000f000
-#define MBOX_INT_ENABLE_TX_NOT_EMPTY_GET(x)      (((x) & MBOX_INT_ENABLE_TX_NOT_EMPTY_MASK) >> MBOX_INT_ENABLE_TX_NOT_EMPTY_LSB)
-#define MBOX_INT_ENABLE_TX_NOT_EMPTY_SET(x)      (((x) << MBOX_INT_ENABLE_TX_NOT_EMPTY_LSB) & MBOX_INT_ENABLE_TX_NOT_EMPTY_MASK)
-#define MBOX_INT_ENABLE_RX_NOT_FULL_MSB          11
-#define MBOX_INT_ENABLE_RX_NOT_FULL_LSB          8
-#define MBOX_INT_ENABLE_RX_NOT_FULL_MASK         0x00000f00
-#define MBOX_INT_ENABLE_RX_NOT_FULL_GET(x)       (((x) & MBOX_INT_ENABLE_RX_NOT_FULL_MASK) >> MBOX_INT_ENABLE_RX_NOT_FULL_LSB)
-#define MBOX_INT_ENABLE_RX_NOT_FULL_SET(x)       (((x) << MBOX_INT_ENABLE_RX_NOT_FULL_LSB) & MBOX_INT_ENABLE_RX_NOT_FULL_MASK)
-#define MBOX_INT_ENABLE_HOST_MSB                 7
-#define MBOX_INT_ENABLE_HOST_LSB                 0
-#define MBOX_INT_ENABLE_HOST_MASK                0x000000ff
-#define MBOX_INT_ENABLE_HOST_GET(x)              (((x) & MBOX_INT_ENABLE_HOST_MASK) >> MBOX_INT_ENABLE_HOST_LSB)
-#define MBOX_INT_ENABLE_HOST_SET(x)              (((x) << MBOX_INT_ENABLE_HOST_LSB) & MBOX_INT_ENABLE_HOST_MASK)
-
-#define INT_HOST_ADDRESS                         0x00000060
-#define INT_HOST_OFFSET                          0x00000060
-#define INT_HOST_VECTOR_MSB                      7
-#define INT_HOST_VECTOR_LSB                      0
-#define INT_HOST_VECTOR_MASK                     0x000000ff
-#define INT_HOST_VECTOR_GET(x)                   (((x) & INT_HOST_VECTOR_MASK) >> INT_HOST_VECTOR_LSB)
-#define INT_HOST_VECTOR_SET(x)                   (((x) << INT_HOST_VECTOR_LSB) & INT_HOST_VECTOR_MASK)
-
-#define LOCAL_COUNT_ADDRESS                      0x00000080
-#define LOCAL_COUNT_OFFSET                       0x00000080
-#define LOCAL_COUNT_VALUE_MSB                    7
-#define LOCAL_COUNT_VALUE_LSB                    0
-#define LOCAL_COUNT_VALUE_MASK                   0x000000ff
-#define LOCAL_COUNT_VALUE_GET(x)                 (((x) & LOCAL_COUNT_VALUE_MASK) >> LOCAL_COUNT_VALUE_LSB)
-#define LOCAL_COUNT_VALUE_SET(x)                 (((x) << LOCAL_COUNT_VALUE_LSB) & LOCAL_COUNT_VALUE_MASK)
-
-#define COUNT_INC_ADDRESS                        0x000000a0
-#define COUNT_INC_OFFSET                         0x000000a0
-#define COUNT_INC_VALUE_MSB                      7
-#define COUNT_INC_VALUE_LSB                      0
-#define COUNT_INC_VALUE_MASK                     0x000000ff
-#define COUNT_INC_VALUE_GET(x)                   (((x) & COUNT_INC_VALUE_MASK) >> COUNT_INC_VALUE_LSB)
-#define COUNT_INC_VALUE_SET(x)                   (((x) << COUNT_INC_VALUE_LSB) & COUNT_INC_VALUE_MASK)
-
-#define LOCAL_SCRATCH_ADDRESS                    0x000000c0
-#define LOCAL_SCRATCH_OFFSET                     0x000000c0
-#define LOCAL_SCRATCH_VALUE_MSB                  7
-#define LOCAL_SCRATCH_VALUE_LSB                  0
-#define LOCAL_SCRATCH_VALUE_MASK                 0x000000ff
-#define LOCAL_SCRATCH_VALUE_GET(x)               (((x) & LOCAL_SCRATCH_VALUE_MASK) >> LOCAL_SCRATCH_VALUE_LSB)
-#define LOCAL_SCRATCH_VALUE_SET(x)               (((x) << LOCAL_SCRATCH_VALUE_LSB) & LOCAL_SCRATCH_VALUE_MASK)
-
-#define USE_LOCAL_BUS_ADDRESS                    0x000000e0
-#define USE_LOCAL_BUS_OFFSET                     0x000000e0
-#define USE_LOCAL_BUS_PIN_INIT_MSB               0
-#define USE_LOCAL_BUS_PIN_INIT_LSB               0
-#define USE_LOCAL_BUS_PIN_INIT_MASK              0x00000001
-#define USE_LOCAL_BUS_PIN_INIT_GET(x)            (((x) & USE_LOCAL_BUS_PIN_INIT_MASK) >> USE_LOCAL_BUS_PIN_INIT_LSB)
-#define USE_LOCAL_BUS_PIN_INIT_SET(x)            (((x) << USE_LOCAL_BUS_PIN_INIT_LSB) & USE_LOCAL_BUS_PIN_INIT_MASK)
-
-#define SDIO_CONFIG_ADDRESS                      0x000000e4
-#define SDIO_CONFIG_OFFSET                       0x000000e4
-#define SDIO_CONFIG_CCCR_IOR1_MSB                0
-#define SDIO_CONFIG_CCCR_IOR1_LSB                0
-#define SDIO_CONFIG_CCCR_IOR1_MASK               0x00000001
-#define SDIO_CONFIG_CCCR_IOR1_GET(x)             (((x) & SDIO_CONFIG_CCCR_IOR1_MASK) >> SDIO_CONFIG_CCCR_IOR1_LSB)
-#define SDIO_CONFIG_CCCR_IOR1_SET(x)             (((x) << SDIO_CONFIG_CCCR_IOR1_LSB) & SDIO_CONFIG_CCCR_IOR1_MASK)
-
-#define MBOX_DEBUG_ADDRESS                       0x000000e8
-#define MBOX_DEBUG_OFFSET                        0x000000e8
-#define MBOX_DEBUG_SEL_MSB                       2
-#define MBOX_DEBUG_SEL_LSB                       0
-#define MBOX_DEBUG_SEL_MASK                      0x00000007
-#define MBOX_DEBUG_SEL_GET(x)                    (((x) & MBOX_DEBUG_SEL_MASK) >> MBOX_DEBUG_SEL_LSB)
-#define MBOX_DEBUG_SEL_SET(x)                    (((x) << MBOX_DEBUG_SEL_LSB) & MBOX_DEBUG_SEL_MASK)
-
-#define MBOX_FIFO_RESET_ADDRESS                  0x000000ec
-#define MBOX_FIFO_RESET_OFFSET                   0x000000ec
-#define MBOX_FIFO_RESET_INIT_MSB                 0
-#define MBOX_FIFO_RESET_INIT_LSB                 0
-#define MBOX_FIFO_RESET_INIT_MASK                0x00000001
-#define MBOX_FIFO_RESET_INIT_GET(x)              (((x) & MBOX_FIFO_RESET_INIT_MASK) >> MBOX_FIFO_RESET_INIT_LSB)
-#define MBOX_FIFO_RESET_INIT_SET(x)              (((x) << MBOX_FIFO_RESET_INIT_LSB) & MBOX_FIFO_RESET_INIT_MASK)
-
-#define MBOX_TXFIFO_POP_ADDRESS                  0x000000f0
-#define MBOX_TXFIFO_POP_OFFSET                   0x000000f0
-#define MBOX_TXFIFO_POP_DATA_MSB                 0
-#define MBOX_TXFIFO_POP_DATA_LSB                 0
-#define MBOX_TXFIFO_POP_DATA_MASK                0x00000001
-#define MBOX_TXFIFO_POP_DATA_GET(x)              (((x) & MBOX_TXFIFO_POP_DATA_MASK) >> MBOX_TXFIFO_POP_DATA_LSB)
-#define MBOX_TXFIFO_POP_DATA_SET(x)              (((x) << MBOX_TXFIFO_POP_DATA_LSB) & MBOX_TXFIFO_POP_DATA_MASK)
-
-#define MBOX_RXFIFO_POP_ADDRESS                  0x00000100
-#define MBOX_RXFIFO_POP_OFFSET                   0x00000100
-#define MBOX_RXFIFO_POP_DATA_MSB                 0
-#define MBOX_RXFIFO_POP_DATA_LSB                 0
-#define MBOX_RXFIFO_POP_DATA_MASK                0x00000001
-#define MBOX_RXFIFO_POP_DATA_GET(x)              (((x) & MBOX_RXFIFO_POP_DATA_MASK) >> MBOX_RXFIFO_POP_DATA_LSB)
-#define MBOX_RXFIFO_POP_DATA_SET(x)              (((x) << MBOX_RXFIFO_POP_DATA_LSB) & MBOX_RXFIFO_POP_DATA_MASK)
-
-#define SDIO_DEBUG_ADDRESS                       0x00000110
-#define SDIO_DEBUG_OFFSET                        0x00000110
-#define SDIO_DEBUG_SEL_MSB                       3
-#define SDIO_DEBUG_SEL_LSB                       0
-#define SDIO_DEBUG_SEL_MASK                      0x0000000f
-#define SDIO_DEBUG_SEL_GET(x)                    (((x) & SDIO_DEBUG_SEL_MASK) >> SDIO_DEBUG_SEL_LSB)
-#define SDIO_DEBUG_SEL_SET(x)                    (((x) << SDIO_DEBUG_SEL_LSB) & SDIO_DEBUG_SEL_MASK)
-
-#define HOST_IF_WINDOW_ADDRESS                   0x00002000
-#define HOST_IF_WINDOW_OFFSET                    0x00002000
-#define HOST_IF_WINDOW_DATA_MSB                  7
-#define HOST_IF_WINDOW_DATA_LSB                  0
-#define HOST_IF_WINDOW_DATA_MASK                 0x000000ff
-#define HOST_IF_WINDOW_DATA_GET(x)               (((x) & HOST_IF_WINDOW_DATA_MASK) >> HOST_IF_WINDOW_DATA_LSB)
-#define HOST_IF_WINDOW_DATA_SET(x)               (((x) << HOST_IF_WINDOW_DATA_LSB) & HOST_IF_WINDOW_DATA_MASK)
-
-
-#ifndef __ASSEMBLER__
-
-typedef struct mbox_reg_reg_s {
-  volatile unsigned int mbox_fifo[4];
-  volatile unsigned int mbox_fifo_status;
-  volatile unsigned int mbox_dma_policy;
-  volatile unsigned int mbox0_dma_rx_descriptor_base;
-  volatile unsigned int mbox0_dma_rx_control;
-  volatile unsigned int mbox0_dma_tx_descriptor_base;
-  volatile unsigned int mbox0_dma_tx_control;
-  volatile unsigned int mbox1_dma_rx_descriptor_base;
-  volatile unsigned int mbox1_dma_rx_control;
-  volatile unsigned int mbox1_dma_tx_descriptor_base;
-  volatile unsigned int mbox1_dma_tx_control;
-  volatile unsigned int mbox2_dma_rx_descriptor_base;
-  volatile unsigned int mbox2_dma_rx_control;
-  volatile unsigned int mbox2_dma_tx_descriptor_base;
-  volatile unsigned int mbox2_dma_tx_control;
-  volatile unsigned int mbox3_dma_rx_descriptor_base;
-  volatile unsigned int mbox3_dma_rx_control;
-  volatile unsigned int mbox3_dma_tx_descriptor_base;
-  volatile unsigned int mbox3_dma_tx_control;
-  volatile unsigned int mbox_int_status;
-  volatile unsigned int mbox_int_enable;
-  volatile unsigned int int_host;
-  unsigned char pad0[28]; /* pad to 0x80 */
-  volatile unsigned int local_count[8];
-  volatile unsigned int count_inc[8];
-  volatile unsigned int local_scratch[8];
-  volatile unsigned int use_local_bus;
-  volatile unsigned int sdio_config;
-  volatile unsigned int mbox_debug;
-  volatile unsigned int mbox_fifo_reset;
-  volatile unsigned int mbox_txfifo_pop[4];
-  volatile unsigned int mbox_rxfifo_pop[4];
-  volatile unsigned int sdio_debug;
-  unsigned char pad1[7916]; /* pad to 0x2000 */
-  volatile unsigned int host_if_window[2048];
-} mbox_reg_reg_t;
-
-#endif /* __ASSEMBLER__ */
-
-#endif /* _MBOX_REG_H_ */
diff --git a/drivers/staging/ath6kl/include/common/AR6002/hw2.0/hw/rtc_reg.h b/drivers/staging/ath6kl/include/common/AR6002/hw2.0/hw/rtc_reg.h
deleted file mode 100644 (file)
index 8b3980a..0000000
+++ /dev/null
@@ -1,1163 +0,0 @@
-#ifndef _RTC_REG_REG_H_
-#define _RTC_REG_REG_H_
-
-#define RESET_CONTROL_ADDRESS                    0x00000000
-#define RESET_CONTROL_OFFSET                     0x00000000
-#define RESET_CONTROL_CPU_INIT_RESET_MSB         11
-#define RESET_CONTROL_CPU_INIT_RESET_LSB         11
-#define RESET_CONTROL_CPU_INIT_RESET_MASK        0x00000800
-#define RESET_CONTROL_CPU_INIT_RESET_GET(x)      (((x) & RESET_CONTROL_CPU_INIT_RESET_MASK) >> RESET_CONTROL_CPU_INIT_RESET_LSB)
-#define RESET_CONTROL_CPU_INIT_RESET_SET(x)      (((x) << RESET_CONTROL_CPU_INIT_RESET_LSB) & RESET_CONTROL_CPU_INIT_RESET_MASK)
-#define RESET_CONTROL_VMC_REMAP_RESET_MSB        10
-#define RESET_CONTROL_VMC_REMAP_RESET_LSB        10
-#define RESET_CONTROL_VMC_REMAP_RESET_MASK       0x00000400
-#define RESET_CONTROL_VMC_REMAP_RESET_GET(x)     (((x) & RESET_CONTROL_VMC_REMAP_RESET_MASK) >> RESET_CONTROL_VMC_REMAP_RESET_LSB)
-#define RESET_CONTROL_VMC_REMAP_RESET_SET(x)     (((x) << RESET_CONTROL_VMC_REMAP_RESET_LSB) & RESET_CONTROL_VMC_REMAP_RESET_MASK)
-#define RESET_CONTROL_RST_OUT_MSB                9
-#define RESET_CONTROL_RST_OUT_LSB                9
-#define RESET_CONTROL_RST_OUT_MASK               0x00000200
-#define RESET_CONTROL_RST_OUT_GET(x)             (((x) & RESET_CONTROL_RST_OUT_MASK) >> RESET_CONTROL_RST_OUT_LSB)
-#define RESET_CONTROL_RST_OUT_SET(x)             (((x) << RESET_CONTROL_RST_OUT_LSB) & RESET_CONTROL_RST_OUT_MASK)
-#define RESET_CONTROL_COLD_RST_MSB               8
-#define RESET_CONTROL_COLD_RST_LSB               8
-#define RESET_CONTROL_COLD_RST_MASK              0x00000100
-#define RESET_CONTROL_COLD_RST_GET(x)            (((x) & RESET_CONTROL_COLD_RST_MASK) >> RESET_CONTROL_COLD_RST_LSB)
-#define RESET_CONTROL_COLD_RST_SET(x)            (((x) << RESET_CONTROL_COLD_RST_LSB) & RESET_CONTROL_COLD_RST_MASK)
-#define RESET_CONTROL_WARM_RST_MSB               7
-#define RESET_CONTROL_WARM_RST_LSB               7
-#define RESET_CONTROL_WARM_RST_MASK              0x00000080
-#define RESET_CONTROL_WARM_RST_GET(x)            (((x) & RESET_CONTROL_WARM_RST_MASK) >> RESET_CONTROL_WARM_RST_LSB)
-#define RESET_CONTROL_WARM_RST_SET(x)            (((x) << RESET_CONTROL_WARM_RST_LSB) & RESET_CONTROL_WARM_RST_MASK)
-#define RESET_CONTROL_CPU_WARM_RST_MSB           6
-#define RESET_CONTROL_CPU_WARM_RST_LSB           6
-#define RESET_CONTROL_CPU_WARM_RST_MASK          0x00000040
-#define RESET_CONTROL_CPU_WARM_RST_GET(x)        (((x) & RESET_CONTROL_CPU_WARM_RST_MASK) >> RESET_CONTROL_CPU_WARM_RST_LSB)
-#define RESET_CONTROL_CPU_WARM_RST_SET(x)        (((x) << RESET_CONTROL_CPU_WARM_RST_LSB) & RESET_CONTROL_CPU_WARM_RST_MASK)
-#define RESET_CONTROL_MAC_COLD_RST_MSB           5
-#define RESET_CONTROL_MAC_COLD_RST_LSB           5
-#define RESET_CONTROL_MAC_COLD_RST_MASK          0x00000020
-#define RESET_CONTROL_MAC_COLD_RST_GET(x)        (((x) & RESET_CONTROL_MAC_COLD_RST_MASK) >> RESET_CONTROL_MAC_COLD_RST_LSB)
-#define RESET_CONTROL_MAC_COLD_RST_SET(x)        (((x) << RESET_CONTROL_MAC_COLD_RST_LSB) & RESET_CONTROL_MAC_COLD_RST_MASK)
-#define RESET_CONTROL_MAC_WARM_RST_MSB           4
-#define RESET_CONTROL_MAC_WARM_RST_LSB           4
-#define RESET_CONTROL_MAC_WARM_RST_MASK          0x00000010
-#define RESET_CONTROL_MAC_WARM_RST_GET(x)        (((x) & RESET_CONTROL_MAC_WARM_RST_MASK) >> RESET_CONTROL_MAC_WARM_RST_LSB)
-#define RESET_CONTROL_MAC_WARM_RST_SET(x)        (((x) << RESET_CONTROL_MAC_WARM_RST_LSB) & RESET_CONTROL_MAC_WARM_RST_MASK)
-#define RESET_CONTROL_MBOX_RST_MSB               2
-#define RESET_CONTROL_MBOX_RST_LSB               2
-#define RESET_CONTROL_MBOX_RST_MASK              0x00000004
-#define RESET_CONTROL_MBOX_RST_GET(x)            (((x) & RESET_CONTROL_MBOX_RST_MASK) >> RESET_CONTROL_MBOX_RST_LSB)
-#define RESET_CONTROL_MBOX_RST_SET(x)            (((x) << RESET_CONTROL_MBOX_RST_LSB) & RESET_CONTROL_MBOX_RST_MASK)
-#define RESET_CONTROL_UART_RST_MSB               1
-#define RESET_CONTROL_UART_RST_LSB               1
-#define RESET_CONTROL_UART_RST_MASK              0x00000002
-#define RESET_CONTROL_UART_RST_GET(x)            (((x) & RESET_CONTROL_UART_RST_MASK) >> RESET_CONTROL_UART_RST_LSB)
-#define RESET_CONTROL_UART_RST_SET(x)            (((x) << RESET_CONTROL_UART_RST_LSB) & RESET_CONTROL_UART_RST_MASK)
-#define RESET_CONTROL_SI0_RST_MSB                0
-#define RESET_CONTROL_SI0_RST_LSB                0
-#define RESET_CONTROL_SI0_RST_MASK               0x00000001
-#define RESET_CONTROL_SI0_RST_GET(x)             (((x) & RESET_CONTROL_SI0_RST_MASK) >> RESET_CONTROL_SI0_RST_LSB)
-#define RESET_CONTROL_SI0_RST_SET(x)             (((x) << RESET_CONTROL_SI0_RST_LSB) & RESET_CONTROL_SI0_RST_MASK)
-
-#define XTAL_CONTROL_ADDRESS                     0x00000004
-#define XTAL_CONTROL_OFFSET                      0x00000004
-#define XTAL_CONTROL_TCXO_MSB                    0
-#define XTAL_CONTROL_TCXO_LSB                    0
-#define XTAL_CONTROL_TCXO_MASK                   0x00000001
-#define XTAL_CONTROL_TCXO_GET(x)                 (((x) & XTAL_CONTROL_TCXO_MASK) >> XTAL_CONTROL_TCXO_LSB)
-#define XTAL_CONTROL_TCXO_SET(x)                 (((x) << XTAL_CONTROL_TCXO_LSB) & XTAL_CONTROL_TCXO_MASK)
-
-#define TCXO_DETECT_ADDRESS                      0x00000008
-#define TCXO_DETECT_OFFSET                       0x00000008
-#define TCXO_DETECT_PRESENT_MSB                  0
-#define TCXO_DETECT_PRESENT_LSB                  0
-#define TCXO_DETECT_PRESENT_MASK                 0x00000001
-#define TCXO_DETECT_PRESENT_GET(x)               (((x) & TCXO_DETECT_PRESENT_MASK) >> TCXO_DETECT_PRESENT_LSB)
-#define TCXO_DETECT_PRESENT_SET(x)               (((x) << TCXO_DETECT_PRESENT_LSB) & TCXO_DETECT_PRESENT_MASK)
-
-#define XTAL_TEST_ADDRESS                        0x0000000c
-#define XTAL_TEST_OFFSET                         0x0000000c
-#define XTAL_TEST_NOTCXODET_MSB                  0
-#define XTAL_TEST_NOTCXODET_LSB                  0
-#define XTAL_TEST_NOTCXODET_MASK                 0x00000001
-#define XTAL_TEST_NOTCXODET_GET(x)               (((x) & XTAL_TEST_NOTCXODET_MASK) >> XTAL_TEST_NOTCXODET_LSB)
-#define XTAL_TEST_NOTCXODET_SET(x)               (((x) << XTAL_TEST_NOTCXODET_LSB) & XTAL_TEST_NOTCXODET_MASK)
-
-#define QUADRATURE_ADDRESS                       0x00000010
-#define QUADRATURE_OFFSET                        0x00000010
-#define QUADRATURE_ADC_MSB                       5
-#define QUADRATURE_ADC_LSB                       4
-#define QUADRATURE_ADC_MASK                      0x00000030
-#define QUADRATURE_ADC_GET(x)                    (((x) & QUADRATURE_ADC_MASK) >> QUADRATURE_ADC_LSB)
-#define QUADRATURE_ADC_SET(x)                    (((x) << QUADRATURE_ADC_LSB) & QUADRATURE_ADC_MASK)
-#define QUADRATURE_SEL_MSB                       2
-#define QUADRATURE_SEL_LSB                       2
-#define QUADRATURE_SEL_MASK                      0x00000004
-#define QUADRATURE_SEL_GET(x)                    (((x) & QUADRATURE_SEL_MASK) >> QUADRATURE_SEL_LSB)
-#define QUADRATURE_SEL_SET(x)                    (((x) << QUADRATURE_SEL_LSB) & QUADRATURE_SEL_MASK)
-#define QUADRATURE_DAC_MSB                       1
-#define QUADRATURE_DAC_LSB                       0
-#define QUADRATURE_DAC_MASK                      0x00000003
-#define QUADRATURE_DAC_GET(x)                    (((x) & QUADRATURE_DAC_MASK) >> QUADRATURE_DAC_LSB)
-#define QUADRATURE_DAC_SET(x)                    (((x) << QUADRATURE_DAC_LSB) & QUADRATURE_DAC_MASK)
-
-#define PLL_CONTROL_ADDRESS                      0x00000014
-#define PLL_CONTROL_OFFSET                       0x00000014
-#define PLL_CONTROL_DIG_TEST_CLK_MSB             20
-#define PLL_CONTROL_DIG_TEST_CLK_LSB             20
-#define PLL_CONTROL_DIG_TEST_CLK_MASK            0x00100000
-#define PLL_CONTROL_DIG_TEST_CLK_GET(x)          (((x) & PLL_CONTROL_DIG_TEST_CLK_MASK) >> PLL_CONTROL_DIG_TEST_CLK_LSB)
-#define PLL_CONTROL_DIG_TEST_CLK_SET(x)          (((x) << PLL_CONTROL_DIG_TEST_CLK_LSB) & PLL_CONTROL_DIG_TEST_CLK_MASK)
-#define PLL_CONTROL_MAC_OVERRIDE_MSB             19
-#define PLL_CONTROL_MAC_OVERRIDE_LSB             19
-#define PLL_CONTROL_MAC_OVERRIDE_MASK            0x00080000
-#define PLL_CONTROL_MAC_OVERRIDE_GET(x)          (((x) & PLL_CONTROL_MAC_OVERRIDE_MASK) >> PLL_CONTROL_MAC_OVERRIDE_LSB)
-#define PLL_CONTROL_MAC_OVERRIDE_SET(x)          (((x) << PLL_CONTROL_MAC_OVERRIDE_LSB) & PLL_CONTROL_MAC_OVERRIDE_MASK)
-#define PLL_CONTROL_NOPWD_MSB                    18
-#define PLL_CONTROL_NOPWD_LSB                    18
-#define PLL_CONTROL_NOPWD_MASK                   0x00040000
-#define PLL_CONTROL_NOPWD_GET(x)                 (((x) & PLL_CONTROL_NOPWD_MASK) >> PLL_CONTROL_NOPWD_LSB)
-#define PLL_CONTROL_NOPWD_SET(x)                 (((x) << PLL_CONTROL_NOPWD_LSB) & PLL_CONTROL_NOPWD_MASK)
-#define PLL_CONTROL_UPDATING_MSB                 17
-#define PLL_CONTROL_UPDATING_LSB                 17
-#define PLL_CONTROL_UPDATING_MASK                0x00020000
-#define PLL_CONTROL_UPDATING_GET(x)              (((x) & PLL_CONTROL_UPDATING_MASK) >> PLL_CONTROL_UPDATING_LSB)
-#define PLL_CONTROL_UPDATING_SET(x)              (((x) << PLL_CONTROL_UPDATING_LSB) & PLL_CONTROL_UPDATING_MASK)
-#define PLL_CONTROL_BYPASS_MSB                   16
-#define PLL_CONTROL_BYPASS_LSB                   16
-#define PLL_CONTROL_BYPASS_MASK                  0x00010000
-#define PLL_CONTROL_BYPASS_GET(x)                (((x) & PLL_CONTROL_BYPASS_MASK) >> PLL_CONTROL_BYPASS_LSB)
-#define PLL_CONTROL_BYPASS_SET(x)                (((x) << PLL_CONTROL_BYPASS_LSB) & PLL_CONTROL_BYPASS_MASK)
-#define PLL_CONTROL_REFDIV_MSB                   15
-#define PLL_CONTROL_REFDIV_LSB                   12
-#define PLL_CONTROL_REFDIV_MASK                  0x0000f000
-#define PLL_CONTROL_REFDIV_GET(x)                (((x) & PLL_CONTROL_REFDIV_MASK) >> PLL_CONTROL_REFDIV_LSB)
-#define PLL_CONTROL_REFDIV_SET(x)                (((x) << PLL_CONTROL_REFDIV_LSB) & PLL_CONTROL_REFDIV_MASK)
-#define PLL_CONTROL_DIV_MSB                      9
-#define PLL_CONTROL_DIV_LSB                      0
-#define PLL_CONTROL_DIV_MASK                     0x000003ff
-#define PLL_CONTROL_DIV_GET(x)                   (((x) & PLL_CONTROL_DIV_MASK) >> PLL_CONTROL_DIV_LSB)
-#define PLL_CONTROL_DIV_SET(x)                   (((x) << PLL_CONTROL_DIV_LSB) & PLL_CONTROL_DIV_MASK)
-
-#define PLL_SETTLE_ADDRESS                       0x00000018
-#define PLL_SETTLE_OFFSET                        0x00000018
-#define PLL_SETTLE_TIME_MSB                      11
-#define PLL_SETTLE_TIME_LSB                      0
-#define PLL_SETTLE_TIME_MASK                     0x00000fff
-#define PLL_SETTLE_TIME_GET(x)                   (((x) & PLL_SETTLE_TIME_MASK) >> PLL_SETTLE_TIME_LSB)
-#define PLL_SETTLE_TIME_SET(x)                   (((x) << PLL_SETTLE_TIME_LSB) & PLL_SETTLE_TIME_MASK)
-
-#define XTAL_SETTLE_ADDRESS                      0x0000001c
-#define XTAL_SETTLE_OFFSET                       0x0000001c
-#define XTAL_SETTLE_TIME_MSB                     7
-#define XTAL_SETTLE_TIME_LSB                     0
-#define XTAL_SETTLE_TIME_MASK                    0x000000ff
-#define XTAL_SETTLE_TIME_GET(x)                  (((x) & XTAL_SETTLE_TIME_MASK) >> XTAL_SETTLE_TIME_LSB)
-#define XTAL_SETTLE_TIME_SET(x)                  (((x) << XTAL_SETTLE_TIME_LSB) & XTAL_SETTLE_TIME_MASK)
-
-#define CPU_CLOCK_ADDRESS                        0x00000020
-#define CPU_CLOCK_OFFSET                         0x00000020
-#define CPU_CLOCK_STANDARD_MSB                   1
-#define CPU_CLOCK_STANDARD_LSB                   0
-#define CPU_CLOCK_STANDARD_MASK                  0x00000003
-#define CPU_CLOCK_STANDARD_GET(x)                (((x) & CPU_CLOCK_STANDARD_MASK) >> CPU_CLOCK_STANDARD_LSB)
-#define CPU_CLOCK_STANDARD_SET(x)                (((x) << CPU_CLOCK_STANDARD_LSB) & CPU_CLOCK_STANDARD_MASK)
-
-#define CLOCK_OUT_ADDRESS                        0x00000024
-#define CLOCK_OUT_OFFSET                         0x00000024
-#define CLOCK_OUT_SELECT_MSB                     3
-#define CLOCK_OUT_SELECT_LSB                     0
-#define CLOCK_OUT_SELECT_MASK                    0x0000000f
-#define CLOCK_OUT_SELECT_GET(x)                  (((x) & CLOCK_OUT_SELECT_MASK) >> CLOCK_OUT_SELECT_LSB)
-#define CLOCK_OUT_SELECT_SET(x)                  (((x) << CLOCK_OUT_SELECT_LSB) & CLOCK_OUT_SELECT_MASK)
-
-#define CLOCK_CONTROL_ADDRESS                    0x00000028
-#define CLOCK_CONTROL_OFFSET                     0x00000028
-#define CLOCK_CONTROL_LF_CLK32_MSB               2
-#define CLOCK_CONTROL_LF_CLK32_LSB               2
-#define CLOCK_CONTROL_LF_CLK32_MASK              0x00000004
-#define CLOCK_CONTROL_LF_CLK32_GET(x)            (((x) & CLOCK_CONTROL_LF_CLK32_MASK) >> CLOCK_CONTROL_LF_CLK32_LSB)
-#define CLOCK_CONTROL_LF_CLK32_SET(x)            (((x) << CLOCK_CONTROL_LF_CLK32_LSB) & CLOCK_CONTROL_LF_CLK32_MASK)
-#define CLOCK_CONTROL_UART_CLK_MSB               1
-#define CLOCK_CONTROL_UART_CLK_LSB               1
-#define CLOCK_CONTROL_UART_CLK_MASK              0x00000002
-#define CLOCK_CONTROL_UART_CLK_GET(x)            (((x) & CLOCK_CONTROL_UART_CLK_MASK) >> CLOCK_CONTROL_UART_CLK_LSB)
-#define CLOCK_CONTROL_UART_CLK_SET(x)            (((x) << CLOCK_CONTROL_UART_CLK_LSB) & CLOCK_CONTROL_UART_CLK_MASK)
-#define CLOCK_CONTROL_SI0_CLK_MSB                0
-#define CLOCK_CONTROL_SI0_CLK_LSB                0
-#define CLOCK_CONTROL_SI0_CLK_MASK               0x00000001
-#define CLOCK_CONTROL_SI0_CLK_GET(x)             (((x) & CLOCK_CONTROL_SI0_CLK_MASK) >> CLOCK_CONTROL_SI0_CLK_LSB)
-#define CLOCK_CONTROL_SI0_CLK_SET(x)             (((x) << CLOCK_CONTROL_SI0_CLK_LSB) & CLOCK_CONTROL_SI0_CLK_MASK)
-
-#define BIAS_OVERRIDE_ADDRESS                    0x0000002c
-#define BIAS_OVERRIDE_OFFSET                     0x0000002c
-#define BIAS_OVERRIDE_ON_MSB                     0
-#define BIAS_OVERRIDE_ON_LSB                     0
-#define BIAS_OVERRIDE_ON_MASK                    0x00000001
-#define BIAS_OVERRIDE_ON_GET(x)                  (((x) & BIAS_OVERRIDE_ON_MASK) >> BIAS_OVERRIDE_ON_LSB)
-#define BIAS_OVERRIDE_ON_SET(x)                  (((x) << BIAS_OVERRIDE_ON_LSB) & BIAS_OVERRIDE_ON_MASK)
-
-#define WDT_CONTROL_ADDRESS                      0x00000030
-#define WDT_CONTROL_OFFSET                       0x00000030
-#define WDT_CONTROL_ACTION_MSB                   2
-#define WDT_CONTROL_ACTION_LSB                   0
-#define WDT_CONTROL_ACTION_MASK                  0x00000007
-#define WDT_CONTROL_ACTION_GET(x)                (((x) & WDT_CONTROL_ACTION_MASK) >> WDT_CONTROL_ACTION_LSB)
-#define WDT_CONTROL_ACTION_SET(x)                (((x) << WDT_CONTROL_ACTION_LSB) & WDT_CONTROL_ACTION_MASK)
-
-#define WDT_STATUS_ADDRESS                       0x00000034
-#define WDT_STATUS_OFFSET                        0x00000034
-#define WDT_STATUS_INTERRUPT_MSB                 0
-#define WDT_STATUS_INTERRUPT_LSB                 0
-#define WDT_STATUS_INTERRUPT_MASK                0x00000001
-#define WDT_STATUS_INTERRUPT_GET(x)              (((x) & WDT_STATUS_INTERRUPT_MASK) >> WDT_STATUS_INTERRUPT_LSB)
-#define WDT_STATUS_INTERRUPT_SET(x)              (((x) << WDT_STATUS_INTERRUPT_LSB) & WDT_STATUS_INTERRUPT_MASK)
-
-#define WDT_ADDRESS                              0x00000038
-#define WDT_OFFSET                               0x00000038
-#define WDT_TARGET_MSB                           21
-#define WDT_TARGET_LSB                           0
-#define WDT_TARGET_MASK                          0x003fffff
-#define WDT_TARGET_GET(x)                        (((x) & WDT_TARGET_MASK) >> WDT_TARGET_LSB)
-#define WDT_TARGET_SET(x)                        (((x) << WDT_TARGET_LSB) & WDT_TARGET_MASK)
-
-#define WDT_COUNT_ADDRESS                        0x0000003c
-#define WDT_COUNT_OFFSET                         0x0000003c
-#define WDT_COUNT_VALUE_MSB                      21
-#define WDT_COUNT_VALUE_LSB                      0
-#define WDT_COUNT_VALUE_MASK                     0x003fffff
-#define WDT_COUNT_VALUE_GET(x)                   (((x) & WDT_COUNT_VALUE_MASK) >> WDT_COUNT_VALUE_LSB)
-#define WDT_COUNT_VALUE_SET(x)                   (((x) << WDT_COUNT_VALUE_LSB) & WDT_COUNT_VALUE_MASK)
-
-#define WDT_RESET_ADDRESS                        0x00000040
-#define WDT_RESET_OFFSET                         0x00000040
-#define WDT_RESET_VALUE_MSB                      0
-#define WDT_RESET_VALUE_LSB                      0
-#define WDT_RESET_VALUE_MASK                     0x00000001
-#define WDT_RESET_VALUE_GET(x)                   (((x) & WDT_RESET_VALUE_MASK) >> WDT_RESET_VALUE_LSB)
-#define WDT_RESET_VALUE_SET(x)                   (((x) << WDT_RESET_VALUE_LSB) & WDT_RESET_VALUE_MASK)
-
-#define INT_STATUS_ADDRESS                       0x00000044
-#define INT_STATUS_OFFSET                        0x00000044
-#define INT_STATUS_RTC_POWER_MSB                 14
-#define INT_STATUS_RTC_POWER_LSB                 14
-#define INT_STATUS_RTC_POWER_MASK                0x00004000
-#define INT_STATUS_RTC_POWER_GET(x)              (((x) & INT_STATUS_RTC_POWER_MASK) >> INT_STATUS_RTC_POWER_LSB)
-#define INT_STATUS_RTC_POWER_SET(x)              (((x) << INT_STATUS_RTC_POWER_LSB) & INT_STATUS_RTC_POWER_MASK)
-#define INT_STATUS_MAC_MSB                       13
-#define INT_STATUS_MAC_LSB                       13
-#define INT_STATUS_MAC_MASK                      0x00002000
-#define INT_STATUS_MAC_GET(x)                    (((x) & INT_STATUS_MAC_MASK) >> INT_STATUS_MAC_LSB)
-#define INT_STATUS_MAC_SET(x)                    (((x) << INT_STATUS_MAC_LSB) & INT_STATUS_MAC_MASK)
-#define INT_STATUS_MAILBOX_MSB                   12
-#define INT_STATUS_MAILBOX_LSB                   12
-#define INT_STATUS_MAILBOX_MASK                  0x00001000
-#define INT_STATUS_MAILBOX_GET(x)                (((x) & INT_STATUS_MAILBOX_MASK) >> INT_STATUS_MAILBOX_LSB)
-#define INT_STATUS_MAILBOX_SET(x)                (((x) << INT_STATUS_MAILBOX_LSB) & INT_STATUS_MAILBOX_MASK)
-#define INT_STATUS_RTC_ALARM_MSB                 11
-#define INT_STATUS_RTC_ALARM_LSB                 11
-#define INT_STATUS_RTC_ALARM_MASK                0x00000800
-#define INT_STATUS_RTC_ALARM_GET(x)              (((x) & INT_STATUS_RTC_ALARM_MASK) >> INT_STATUS_RTC_ALARM_LSB)
-#define INT_STATUS_RTC_ALARM_SET(x)              (((x) << INT_STATUS_RTC_ALARM_LSB) & INT_STATUS_RTC_ALARM_MASK)
-#define INT_STATUS_HF_TIMER_MSB                  10
-#define INT_STATUS_HF_TIMER_LSB                  10
-#define INT_STATUS_HF_TIMER_MASK                 0x00000400
-#define INT_STATUS_HF_TIMER_GET(x)               (((x) & INT_STATUS_HF_TIMER_MASK) >> INT_STATUS_HF_TIMER_LSB)
-#define INT_STATUS_HF_TIMER_SET(x)               (((x) << INT_STATUS_HF_TIMER_LSB) & INT_STATUS_HF_TIMER_MASK)
-#define INT_STATUS_LF_TIMER3_MSB                 9
-#define INT_STATUS_LF_TIMER3_LSB                 9
-#define INT_STATUS_LF_TIMER3_MASK                0x00000200
-#define INT_STATUS_LF_TIMER3_GET(x)              (((x) & INT_STATUS_LF_TIMER3_MASK) >> INT_STATUS_LF_TIMER3_LSB)
-#define INT_STATUS_LF_TIMER3_SET(x)              (((x) << INT_STATUS_LF_TIMER3_LSB) & INT_STATUS_LF_TIMER3_MASK)
-#define INT_STATUS_LF_TIMER2_MSB                 8
-#define INT_STATUS_LF_TIMER2_LSB                 8
-#define INT_STATUS_LF_TIMER2_MASK                0x00000100
-#define INT_STATUS_LF_TIMER2_GET(x)              (((x) & INT_STATUS_LF_TIMER2_MASK) >> INT_STATUS_LF_TIMER2_LSB)
-#define INT_STATUS_LF_TIMER2_SET(x)              (((x) << INT_STATUS_LF_TIMER2_LSB) & INT_STATUS_LF_TIMER2_MASK)
-#define INT_STATUS_LF_TIMER1_MSB                 7
-#define INT_STATUS_LF_TIMER1_LSB                 7
-#define INT_STATUS_LF_TIMER1_MASK                0x00000080
-#define INT_STATUS_LF_TIMER1_GET(x)              (((x) & INT_STATUS_LF_TIMER1_MASK) >> INT_STATUS_LF_TIMER1_LSB)
-#define INT_STATUS_LF_TIMER1_SET(x)              (((x) << INT_STATUS_LF_TIMER1_LSB) & INT_STATUS_LF_TIMER1_MASK)
-#define INT_STATUS_LF_TIMER0_MSB                 6
-#define INT_STATUS_LF_TIMER0_LSB                 6
-#define INT_STATUS_LF_TIMER0_MASK                0x00000040
-#define INT_STATUS_LF_TIMER0_GET(x)              (((x) & INT_STATUS_LF_TIMER0_MASK) >> INT_STATUS_LF_TIMER0_LSB)
-#define INT_STATUS_LF_TIMER0_SET(x)              (((x) << INT_STATUS_LF_TIMER0_LSB) & INT_STATUS_LF_TIMER0_MASK)
-#define INT_STATUS_KEYPAD_MSB                    5
-#define INT_STATUS_KEYPAD_LSB                    5
-#define INT_STATUS_KEYPAD_MASK                   0x00000020
-#define INT_STATUS_KEYPAD_GET(x)                 (((x) & INT_STATUS_KEYPAD_MASK) >> INT_STATUS_KEYPAD_LSB)
-#define INT_STATUS_KEYPAD_SET(x)                 (((x) << INT_STATUS_KEYPAD_LSB) & INT_STATUS_KEYPAD_MASK)
-#define INT_STATUS_SI_MSB                        4
-#define INT_STATUS_SI_LSB                        4
-#define INT_STATUS_SI_MASK                       0x00000010
-#define INT_STATUS_SI_GET(x)                     (((x) & INT_STATUS_SI_MASK) >> INT_STATUS_SI_LSB)
-#define INT_STATUS_SI_SET(x)                     (((x) << INT_STATUS_SI_LSB) & INT_STATUS_SI_MASK)
-#define INT_STATUS_GPIO_MSB                      3
-#define INT_STATUS_GPIO_LSB                      3
-#define INT_STATUS_GPIO_MASK                     0x00000008
-#define INT_STATUS_GPIO_GET(x)                   (((x) & INT_STATUS_GPIO_MASK) >> INT_STATUS_GPIO_LSB)
-#define INT_STATUS_GPIO_SET(x)                   (((x) << INT_STATUS_GPIO_LSB) & INT_STATUS_GPIO_MASK)
-#define INT_STATUS_UART_MSB                      2
-#define INT_STATUS_UART_LSB                      2
-#define INT_STATUS_UART_MASK                     0x00000004
-#define INT_STATUS_UART_GET(x)                   (((x) & INT_STATUS_UART_MASK) >> INT_STATUS_UART_LSB)
-#define INT_STATUS_UART_SET(x)                   (((x) << INT_STATUS_UART_LSB) & INT_STATUS_UART_MASK)
-#define INT_STATUS_ERROR_MSB                     1
-#define INT_STATUS_ERROR_LSB                     1
-#define INT_STATUS_ERROR_MASK                    0x00000002
-#define INT_STATUS_ERROR_GET(x)                  (((x) & INT_STATUS_ERROR_MASK) >> INT_STATUS_ERROR_LSB)
-#define INT_STATUS_ERROR_SET(x)                  (((x) << INT_STATUS_ERROR_LSB) & INT_STATUS_ERROR_MASK)
-#define INT_STATUS_WDT_INT_MSB                   0
-#define INT_STATUS_WDT_INT_LSB                   0
-#define INT_STATUS_WDT_INT_MASK                  0x00000001
-#define INT_STATUS_WDT_INT_GET(x)                (((x) & INT_STATUS_WDT_INT_MASK) >> INT_STATUS_WDT_INT_LSB)
-#define INT_STATUS_WDT_INT_SET(x)                (((x) << INT_STATUS_WDT_INT_LSB) & INT_STATUS_WDT_INT_MASK)
-
-#define LF_TIMER0_ADDRESS                        0x00000048
-#define LF_TIMER0_OFFSET                         0x00000048
-#define LF_TIMER0_TARGET_MSB                     31
-#define LF_TIMER0_TARGET_LSB                     0
-#define LF_TIMER0_TARGET_MASK                    0xffffffff
-#define LF_TIMER0_TARGET_GET(x)                  (((x) & LF_TIMER0_TARGET_MASK) >> LF_TIMER0_TARGET_LSB)
-#define LF_TIMER0_TARGET_SET(x)                  (((x) << LF_TIMER0_TARGET_LSB) & LF_TIMER0_TARGET_MASK)
-
-#define LF_TIMER_COUNT0_ADDRESS                  0x0000004c
-#define LF_TIMER_COUNT0_OFFSET                   0x0000004c
-#define LF_TIMER_COUNT0_VALUE_MSB                31
-#define LF_TIMER_COUNT0_VALUE_LSB                0
-#define LF_TIMER_COUNT0_VALUE_MASK               0xffffffff
-#define LF_TIMER_COUNT0_VALUE_GET(x)             (((x) & LF_TIMER_COUNT0_VALUE_MASK) >> LF_TIMER_COUNT0_VALUE_LSB)
-#define LF_TIMER_COUNT0_VALUE_SET(x)             (((x) << LF_TIMER_COUNT0_VALUE_LSB) & LF_TIMER_COUNT0_VALUE_MASK)
-
-#define LF_TIMER_CONTROL0_ADDRESS                0x00000050
-#define LF_TIMER_CONTROL0_OFFSET                 0x00000050
-#define LF_TIMER_CONTROL0_ENABLE_MSB             2
-#define LF_TIMER_CONTROL0_ENABLE_LSB             2
-#define LF_TIMER_CONTROL0_ENABLE_MASK            0x00000004
-#define LF_TIMER_CONTROL0_ENABLE_GET(x)          (((x) & LF_TIMER_CONTROL0_ENABLE_MASK) >> LF_TIMER_CONTROL0_ENABLE_LSB)
-#define LF_TIMER_CONTROL0_ENABLE_SET(x)          (((x) << LF_TIMER_CONTROL0_ENABLE_LSB) & LF_TIMER_CONTROL0_ENABLE_MASK)
-#define LF_TIMER_CONTROL0_AUTO_RESTART_MSB       1
-#define LF_TIMER_CONTROL0_AUTO_RESTART_LSB       1
-#define LF_TIMER_CONTROL0_AUTO_RESTART_MASK      0x00000002
-#define LF_TIMER_CONTROL0_AUTO_RESTART_GET(x)    (((x) & LF_TIMER_CONTROL0_AUTO_RESTART_MASK) >> LF_TIMER_CONTROL0_AUTO_RESTART_LSB)
-#define LF_TIMER_CONTROL0_AUTO_RESTART_SET(x)    (((x) << LF_TIMER_CONTROL0_AUTO_RESTART_LSB) & LF_TIMER_CONTROL0_AUTO_RESTART_MASK)
-#define LF_TIMER_CONTROL0_RESET_MSB              0
-#define LF_TIMER_CONTROL0_RESET_LSB              0
-#define LF_TIMER_CONTROL0_RESET_MASK             0x00000001
-#define LF_TIMER_CONTROL0_RESET_GET(x)           (((x) & LF_TIMER_CONTROL0_RESET_MASK) >> LF_TIMER_CONTROL0_RESET_LSB)
-#define LF_TIMER_CONTROL0_RESET_SET(x)           (((x) << LF_TIMER_CONTROL0_RESET_LSB) & LF_TIMER_CONTROL0_RESET_MASK)
-
-#define LF_TIMER_STATUS0_ADDRESS                 0x00000054
-#define LF_TIMER_STATUS0_OFFSET                  0x00000054
-#define LF_TIMER_STATUS0_INTERRUPT_MSB           0
-#define LF_TIMER_STATUS0_INTERRUPT_LSB           0
-#define LF_TIMER_STATUS0_INTERRUPT_MASK          0x00000001
-#define LF_TIMER_STATUS0_INTERRUPT_GET(x)        (((x) & LF_TIMER_STATUS0_INTERRUPT_MASK) >> LF_TIMER_STATUS0_INTERRUPT_LSB)
-#define LF_TIMER_STATUS0_INTERRUPT_SET(x)        (((x) << LF_TIMER_STATUS0_INTERRUPT_LSB) & LF_TIMER_STATUS0_INTERRUPT_MASK)
-
-#define LF_TIMER1_ADDRESS                        0x00000058
-#define LF_TIMER1_OFFSET                         0x00000058
-#define LF_TIMER1_TARGET_MSB                     31
-#define LF_TIMER1_TARGET_LSB                     0
-#define LF_TIMER1_TARGET_MASK                    0xffffffff
-#define LF_TIMER1_TARGET_GET(x)                  (((x) & LF_TIMER1_TARGET_MASK) >> LF_TIMER1_TARGET_LSB)
-#define LF_TIMER1_TARGET_SET(x)                  (((x) << LF_TIMER1_TARGET_LSB) & LF_TIMER1_TARGET_MASK)
-
-#define LF_TIMER_COUNT1_ADDRESS                  0x0000005c
-#define LF_TIMER_COUNT1_OFFSET                   0x0000005c
-#define LF_TIMER_COUNT1_VALUE_MSB                31
-#define LF_TIMER_COUNT1_VALUE_LSB                0
-#define LF_TIMER_COUNT1_VALUE_MASK               0xffffffff
-#define LF_TIMER_COUNT1_VALUE_GET(x)             (((x) & LF_TIMER_COUNT1_VALUE_MASK) >> LF_TIMER_COUNT1_VALUE_LSB)
-#define LF_TIMER_COUNT1_VALUE_SET(x)             (((x) << LF_TIMER_COUNT1_VALUE_LSB) & LF_TIMER_COUNT1_VALUE_MASK)
-
-#define LF_TIMER_CONTROL1_ADDRESS                0x00000060
-#define LF_TIMER_CONTROL1_OFFSET                 0x00000060
-#define LF_TIMER_CONTROL1_ENABLE_MSB             2
-#define LF_TIMER_CONTROL1_ENABLE_LSB             2
-#define LF_TIMER_CONTROL1_ENABLE_MASK            0x00000004
-#define LF_TIMER_CONTROL1_ENABLE_GET(x)          (((x) & LF_TIMER_CONTROL1_ENABLE_MASK) >> LF_TIMER_CONTROL1_ENABLE_LSB)
-#define LF_TIMER_CONTROL1_ENABLE_SET(x)          (((x) << LF_TIMER_CONTROL1_ENABLE_LSB) & LF_TIMER_CONTROL1_ENABLE_MASK)
-#define LF_TIMER_CONTROL1_AUTO_RESTART_MSB       1
-#define LF_TIMER_CONTROL1_AUTO_RESTART_LSB       1
-#define LF_TIMER_CONTROL1_AUTO_RESTART_MASK      0x00000002
-#define LF_TIMER_CONTROL1_AUTO_RESTART_GET(x)    (((x) & LF_TIMER_CONTROL1_AUTO_RESTART_MASK) >> LF_TIMER_CONTROL1_AUTO_RESTART_LSB)
-#define LF_TIMER_CONTROL1_AUTO_RESTART_SET(x)    (((x) << LF_TIMER_CONTROL1_AUTO_RESTART_LSB) & LF_TIMER_CONTROL1_AUTO_RESTART_MASK)
-#define LF_TIMER_CONTROL1_RESET_MSB              0
-#define LF_TIMER_CONTROL1_RESET_LSB              0
-#define LF_TIMER_CONTROL1_RESET_MASK             0x00000001
-#define LF_TIMER_CONTROL1_RESET_GET(x)           (((x) & LF_TIMER_CONTROL1_RESET_MASK) >> LF_TIMER_CONTROL1_RESET_LSB)
-#define LF_TIMER_CONTROL1_RESET_SET(x)           (((x) << LF_TIMER_CONTROL1_RESET_LSB) & LF_TIMER_CONTROL1_RESET_MASK)
-
-#define LF_TIMER_STATUS1_ADDRESS                 0x00000064
-#define LF_TIMER_STATUS1_OFFSET                  0x00000064
-#define LF_TIMER_STATUS1_INTERRUPT_MSB           0
-#define LF_TIMER_STATUS1_INTERRUPT_LSB           0
-#define LF_TIMER_STATUS1_INTERRUPT_MASK          0x00000001
-#define LF_TIMER_STATUS1_INTERRUPT_GET(x)        (((x) & LF_TIMER_STATUS1_INTERRUPT_MASK) >> LF_TIMER_STATUS1_INTERRUPT_LSB)
-#define LF_TIMER_STATUS1_INTERRUPT_SET(x)        (((x) << LF_TIMER_STATUS1_INTERRUPT_LSB) & LF_TIMER_STATUS1_INTERRUPT_MASK)
-
-#define LF_TIMER2_ADDRESS                        0x00000068
-#define LF_TIMER2_OFFSET                         0x00000068
-#define LF_TIMER2_TARGET_MSB                     31
-#define LF_TIMER2_TARGET_LSB                     0
-#define LF_TIMER2_TARGET_MASK                    0xffffffff
-#define LF_TIMER2_TARGET_GET(x)                  (((x) & LF_TIMER2_TARGET_MASK) >> LF_TIMER2_TARGET_LSB)
-#define LF_TIMER2_TARGET_SET(x)                  (((x) << LF_TIMER2_TARGET_LSB) & LF_TIMER2_TARGET_MASK)
-
-#define LF_TIMER_COUNT2_ADDRESS                  0x0000006c
-#define LF_TIMER_COUNT2_OFFSET                   0x0000006c
-#define LF_TIMER_COUNT2_VALUE_MSB                31
-#define LF_TIMER_COUNT2_VALUE_LSB                0
-#define LF_TIMER_COUNT2_VALUE_MASK               0xffffffff
-#define LF_TIMER_COUNT2_VALUE_GET(x)             (((x) & LF_TIMER_COUNT2_VALUE_MASK) >> LF_TIMER_COUNT2_VALUE_LSB)
-#define LF_TIMER_COUNT2_VALUE_SET(x)             (((x) << LF_TIMER_COUNT2_VALUE_LSB) & LF_TIMER_COUNT2_VALUE_MASK)
-
-#define LF_TIMER_CONTROL2_ADDRESS                0x00000070
-#define LF_TIMER_CONTROL2_OFFSET                 0x00000070
-#define LF_TIMER_CONTROL2_ENABLE_MSB             2
-#define LF_TIMER_CONTROL2_ENABLE_LSB             2
-#define LF_TIMER_CONTROL2_ENABLE_MASK            0x00000004
-#define LF_TIMER_CONTROL2_ENABLE_GET(x)          (((x) & LF_TIMER_CONTROL2_ENABLE_MASK) >> LF_TIMER_CONTROL2_ENABLE_LSB)
-#define LF_TIMER_CONTROL2_ENABLE_SET(x)          (((x) << LF_TIMER_CONTROL2_ENABLE_LSB) & LF_TIMER_CONTROL2_ENABLE_MASK)
-#define LF_TIMER_CONTROL2_AUTO_RESTART_MSB       1
-#define LF_TIMER_CONTROL2_AUTO_RESTART_LSB       1
-#define LF_TIMER_CONTROL2_AUTO_RESTART_MASK      0x00000002
-#define LF_TIMER_CONTROL2_AUTO_RESTART_GET(x)    (((x) & LF_TIMER_CONTROL2_AUTO_RESTART_MASK) >> LF_TIMER_CONTROL2_AUTO_RESTART_LSB)
-#define LF_TIMER_CONTROL2_AUTO_RESTART_SET(x)    (((x) << LF_TIMER_CONTROL2_AUTO_RESTART_LSB) & LF_TIMER_CONTROL2_AUTO_RESTART_MASK)
-#define LF_TIMER_CONTROL2_RESET_MSB              0
-#define LF_TIMER_CONTROL2_RESET_LSB              0
-#define LF_TIMER_CONTROL2_RESET_MASK             0x00000001
-#define LF_TIMER_CONTROL2_RESET_GET(x)           (((x) & LF_TIMER_CONTROL2_RESET_MASK) >> LF_TIMER_CONTROL2_RESET_LSB)
-#define LF_TIMER_CONTROL2_RESET_SET(x)           (((x) << LF_TIMER_CONTROL2_RESET_LSB) & LF_TIMER_CONTROL2_RESET_MASK)
-
-#define LF_TIMER_STATUS2_ADDRESS                 0x00000074
-#define LF_TIMER_STATUS2_OFFSET                  0x00000074
-#define LF_TIMER_STATUS2_INTERRUPT_MSB           0
-#define LF_TIMER_STATUS2_INTERRUPT_LSB           0
-#define LF_TIMER_STATUS2_INTERRUPT_MASK          0x00000001
-#define LF_TIMER_STATUS2_INTERRUPT_GET(x)        (((x) & LF_TIMER_STATUS2_INTERRUPT_MASK) >> LF_TIMER_STATUS2_INTERRUPT_LSB)
-#define LF_TIMER_STATUS2_INTERRUPT_SET(x)        (((x) << LF_TIMER_STATUS2_INTERRUPT_LSB) & LF_TIMER_STATUS2_INTERRUPT_MASK)
-
-#define LF_TIMER3_ADDRESS                        0x00000078
-#define LF_TIMER3_OFFSET                         0x00000078
-#define LF_TIMER3_TARGET_MSB                     31
-#define LF_TIMER3_TARGET_LSB                     0
-#define LF_TIMER3_TARGET_MASK                    0xffffffff
-#define LF_TIMER3_TARGET_GET(x)                  (((x) & LF_TIMER3_TARGET_MASK) >> LF_TIMER3_TARGET_LSB)
-#define LF_TIMER3_TARGET_SET(x)                  (((x) << LF_TIMER3_TARGET_LSB) & LF_TIMER3_TARGET_MASK)
-
-#define LF_TIMER_COUNT3_ADDRESS                  0x0000007c
-#define LF_TIMER_COUNT3_OFFSET                   0x0000007c
-#define LF_TIMER_COUNT3_VALUE_MSB                31
-#define LF_TIMER_COUNT3_VALUE_LSB                0
-#define LF_TIMER_COUNT3_VALUE_MASK               0xffffffff
-#define LF_TIMER_COUNT3_VALUE_GET(x)             (((x) & LF_TIMER_COUNT3_VALUE_MASK) >> LF_TIMER_COUNT3_VALUE_LSB)
-#define LF_TIMER_COUNT3_VALUE_SET(x)             (((x) << LF_TIMER_COUNT3_VALUE_LSB) & LF_TIMER_COUNT3_VALUE_MASK)
-
-#define LF_TIMER_CONTROL3_ADDRESS                0x00000080
-#define LF_TIMER_CONTROL3_OFFSET                 0x00000080
-#define LF_TIMER_CONTROL3_ENABLE_MSB             2
-#define LF_TIMER_CONTROL3_ENABLE_LSB             2
-#define LF_TIMER_CONTROL3_ENABLE_MASK            0x00000004
-#define LF_TIMER_CONTROL3_ENABLE_GET(x)          (((x) & LF_TIMER_CONTROL3_ENABLE_MASK) >> LF_TIMER_CONTROL3_ENABLE_LSB)
-#define LF_TIMER_CONTROL3_ENABLE_SET(x)          (((x) << LF_TIMER_CONTROL3_ENABLE_LSB) & LF_TIMER_CONTROL3_ENABLE_MASK)
-#define LF_TIMER_CONTROL3_AUTO_RESTART_MSB       1
-#define LF_TIMER_CONTROL3_AUTO_RESTART_LSB       1
-#define LF_TIMER_CONTROL3_AUTO_RESTART_MASK      0x00000002
-#define LF_TIMER_CONTROL3_AUTO_RESTART_GET(x)    (((x) & LF_TIMER_CONTROL3_AUTO_RESTART_MASK) >> LF_TIMER_CONTROL3_AUTO_RESTART_LSB)
-#define LF_TIMER_CONTROL3_AUTO_RESTART_SET(x)    (((x) << LF_TIMER_CONTROL3_AUTO_RESTART_LSB) & LF_TIMER_CONTROL3_AUTO_RESTART_MASK)
-#define LF_TIMER_CONTROL3_RESET_MSB              0
-#define LF_TIMER_CONTROL3_RESET_LSB              0
-#define LF_TIMER_CONTROL3_RESET_MASK             0x00000001
-#define LF_TIMER_CONTROL3_RESET_GET(x)           (((x) & LF_TIMER_CONTROL3_RESET_MASK) >> LF_TIMER_CONTROL3_RESET_LSB)
-#define LF_TIMER_CONTROL3_RESET_SET(x)           (((x) << LF_TIMER_CONTROL3_RESET_LSB) & LF_TIMER_CONTROL3_RESET_MASK)
-
-#define LF_TIMER_STATUS3_ADDRESS                 0x00000084
-#define LF_TIMER_STATUS3_OFFSET                  0x00000084
-#define LF_TIMER_STATUS3_INTERRUPT_MSB           0
-#define LF_TIMER_STATUS3_INTERRUPT_LSB           0
-#define LF_TIMER_STATUS3_INTERRUPT_MASK          0x00000001
-#define LF_TIMER_STATUS3_INTERRUPT_GET(x)        (((x) & LF_TIMER_STATUS3_INTERRUPT_MASK) >> LF_TIMER_STATUS3_INTERRUPT_LSB)
-#define LF_TIMER_STATUS3_INTERRUPT_SET(x)        (((x) << LF_TIMER_STATUS3_INTERRUPT_LSB) & LF_TIMER_STATUS3_INTERRUPT_MASK)
-
-#define HF_TIMER_ADDRESS                         0x00000088
-#define HF_TIMER_OFFSET                          0x00000088
-#define HF_TIMER_TARGET_MSB                      31
-#define HF_TIMER_TARGET_LSB                      12
-#define HF_TIMER_TARGET_MASK                     0xfffff000
-#define HF_TIMER_TARGET_GET(x)                   (((x) & HF_TIMER_TARGET_MASK) >> HF_TIMER_TARGET_LSB)
-#define HF_TIMER_TARGET_SET(x)                   (((x) << HF_TIMER_TARGET_LSB) & HF_TIMER_TARGET_MASK)
-
-#define HF_TIMER_COUNT_ADDRESS                   0x0000008c
-#define HF_TIMER_COUNT_OFFSET                    0x0000008c
-#define HF_TIMER_COUNT_VALUE_MSB                 31
-#define HF_TIMER_COUNT_VALUE_LSB                 12
-#define HF_TIMER_COUNT_VALUE_MASK                0xfffff000
-#define HF_TIMER_COUNT_VALUE_GET(x)              (((x) & HF_TIMER_COUNT_VALUE_MASK) >> HF_TIMER_COUNT_VALUE_LSB)
-#define HF_TIMER_COUNT_VALUE_SET(x)              (((x) << HF_TIMER_COUNT_VALUE_LSB) & HF_TIMER_COUNT_VALUE_MASK)
-
-#define HF_LF_COUNT_ADDRESS                      0x00000090
-#define HF_LF_COUNT_OFFSET                       0x00000090
-#define HF_LF_COUNT_VALUE_MSB                    31
-#define HF_LF_COUNT_VALUE_LSB                    0
-#define HF_LF_COUNT_VALUE_MASK                   0xffffffff
-#define HF_LF_COUNT_VALUE_GET(x)                 (((x) & HF_LF_COUNT_VALUE_MASK) >> HF_LF_COUNT_VALUE_LSB)
-#define HF_LF_COUNT_VALUE_SET(x)                 (((x) << HF_LF_COUNT_VALUE_LSB) & HF_LF_COUNT_VALUE_MASK)
-
-#define HF_TIMER_CONTROL_ADDRESS                 0x00000094
-#define HF_TIMER_CONTROL_OFFSET                  0x00000094
-#define HF_TIMER_CONTROL_ENABLE_MSB              3
-#define HF_TIMER_CONTROL_ENABLE_LSB              3
-#define HF_TIMER_CONTROL_ENABLE_MASK             0x00000008
-#define HF_TIMER_CONTROL_ENABLE_GET(x)           (((x) & HF_TIMER_CONTROL_ENABLE_MASK) >> HF_TIMER_CONTROL_ENABLE_LSB)
-#define HF_TIMER_CONTROL_ENABLE_SET(x)           (((x) << HF_TIMER_CONTROL_ENABLE_LSB) & HF_TIMER_CONTROL_ENABLE_MASK)
-#define HF_TIMER_CONTROL_ON_MSB                  2
-#define HF_TIMER_CONTROL_ON_LSB                  2
-#define HF_TIMER_CONTROL_ON_MASK                 0x00000004
-#define HF_TIMER_CONTROL_ON_GET(x)               (((x) & HF_TIMER_CONTROL_ON_MASK) >> HF_TIMER_CONTROL_ON_LSB)
-#define HF_TIMER_CONTROL_ON_SET(x)               (((x) << HF_TIMER_CONTROL_ON_LSB) & HF_TIMER_CONTROL_ON_MASK)
-#define HF_TIMER_CONTROL_AUTO_RESTART_MSB        1
-#define HF_TIMER_CONTROL_AUTO_RESTART_LSB        1
-#define HF_TIMER_CONTROL_AUTO_RESTART_MASK       0x00000002
-#define HF_TIMER_CONTROL_AUTO_RESTART_GET(x)     (((x) & HF_TIMER_CONTROL_AUTO_RESTART_MASK) >> HF_TIMER_CONTROL_AUTO_RESTART_LSB)
-#define HF_TIMER_CONTROL_AUTO_RESTART_SET(x)     (((x) << HF_TIMER_CONTROL_AUTO_RESTART_LSB) & HF_TIMER_CONTROL_AUTO_RESTART_MASK)
-#define HF_TIMER_CONTROL_RESET_MSB               0
-#define HF_TIMER_CONTROL_RESET_LSB               0
-#define HF_TIMER_CONTROL_RESET_MASK              0x00000001
-#define HF_TIMER_CONTROL_RESET_GET(x)            (((x) & HF_TIMER_CONTROL_RESET_MASK) >> HF_TIMER_CONTROL_RESET_LSB)
-#define HF_TIMER_CONTROL_RESET_SET(x)            (((x) << HF_TIMER_CONTROL_RESET_LSB) & HF_TIMER_CONTROL_RESET_MASK)
-
-#define HF_TIMER_STATUS_ADDRESS                  0x00000098
-#define HF_TIMER_STATUS_OFFSET                   0x00000098
-#define HF_TIMER_STATUS_INTERRUPT_MSB            0
-#define HF_TIMER_STATUS_INTERRUPT_LSB            0
-#define HF_TIMER_STATUS_INTERRUPT_MASK           0x00000001
-#define HF_TIMER_STATUS_INTERRUPT_GET(x)         (((x) & HF_TIMER_STATUS_INTERRUPT_MASK) >> HF_TIMER_STATUS_INTERRUPT_LSB)
-#define HF_TIMER_STATUS_INTERRUPT_SET(x)         (((x) << HF_TIMER_STATUS_INTERRUPT_LSB) & HF_TIMER_STATUS_INTERRUPT_MASK)
-
-#define RTC_CONTROL_ADDRESS                      0x0000009c
-#define RTC_CONTROL_OFFSET                       0x0000009c
-#define RTC_CONTROL_ENABLE_MSB                   2
-#define RTC_CONTROL_ENABLE_LSB                   2
-#define RTC_CONTROL_ENABLE_MASK                  0x00000004
-#define RTC_CONTROL_ENABLE_GET(x)                (((x) & RTC_CONTROL_ENABLE_MASK) >> RTC_CONTROL_ENABLE_LSB)
-#define RTC_CONTROL_ENABLE_SET(x)                (((x) << RTC_CONTROL_ENABLE_LSB) & RTC_CONTROL_ENABLE_MASK)
-#define RTC_CONTROL_LOAD_RTC_MSB                 1
-#define RTC_CONTROL_LOAD_RTC_LSB                 1
-#define RTC_CONTROL_LOAD_RTC_MASK                0x00000002
-#define RTC_CONTROL_LOAD_RTC_GET(x)              (((x) & RTC_CONTROL_LOAD_RTC_MASK) >> RTC_CONTROL_LOAD_RTC_LSB)
-#define RTC_CONTROL_LOAD_RTC_SET(x)              (((x) << RTC_CONTROL_LOAD_RTC_LSB) & RTC_CONTROL_LOAD_RTC_MASK)
-#define RTC_CONTROL_LOAD_ALARM_MSB               0
-#define RTC_CONTROL_LOAD_ALARM_LSB               0
-#define RTC_CONTROL_LOAD_ALARM_MASK              0x00000001
-#define RTC_CONTROL_LOAD_ALARM_GET(x)            (((x) & RTC_CONTROL_LOAD_ALARM_MASK) >> RTC_CONTROL_LOAD_ALARM_LSB)
-#define RTC_CONTROL_LOAD_ALARM_SET(x)            (((x) << RTC_CONTROL_LOAD_ALARM_LSB) & RTC_CONTROL_LOAD_ALARM_MASK)
-
-#define RTC_TIME_ADDRESS                         0x000000a0
-#define RTC_TIME_OFFSET                          0x000000a0
-#define RTC_TIME_WEEK_DAY_MSB                    26
-#define RTC_TIME_WEEK_DAY_LSB                    24
-#define RTC_TIME_WEEK_DAY_MASK                   0x07000000
-#define RTC_TIME_WEEK_DAY_GET(x)                 (((x) & RTC_TIME_WEEK_DAY_MASK) >> RTC_TIME_WEEK_DAY_LSB)
-#define RTC_TIME_WEEK_DAY_SET(x)                 (((x) << RTC_TIME_WEEK_DAY_LSB) & RTC_TIME_WEEK_DAY_MASK)
-#define RTC_TIME_HOUR_MSB                        21
-#define RTC_TIME_HOUR_LSB                        16
-#define RTC_TIME_HOUR_MASK                       0x003f0000
-#define RTC_TIME_HOUR_GET(x)                     (((x) & RTC_TIME_HOUR_MASK) >> RTC_TIME_HOUR_LSB)
-#define RTC_TIME_HOUR_SET(x)                     (((x) << RTC_TIME_HOUR_LSB) & RTC_TIME_HOUR_MASK)
-#define RTC_TIME_MINUTE_MSB                      14
-#define RTC_TIME_MINUTE_LSB                      8
-#define RTC_TIME_MINUTE_MASK                     0x00007f00
-#define RTC_TIME_MINUTE_GET(x)                   (((x) & RTC_TIME_MINUTE_MASK) >> RTC_TIME_MINUTE_LSB)
-#define RTC_TIME_MINUTE_SET(x)                   (((x) << RTC_TIME_MINUTE_LSB) & RTC_TIME_MINUTE_MASK)
-#define RTC_TIME_SECOND_MSB                      6
-#define RTC_TIME_SECOND_LSB                      0
-#define RTC_TIME_SECOND_MASK                     0x0000007f
-#define RTC_TIME_SECOND_GET(x)                   (((x) & RTC_TIME_SECOND_MASK) >> RTC_TIME_SECOND_LSB)
-#define RTC_TIME_SECOND_SET(x)                   (((x) << RTC_TIME_SECOND_LSB) & RTC_TIME_SECOND_MASK)
-
-#define RTC_DATE_ADDRESS                         0x000000a4
-#define RTC_DATE_OFFSET                          0x000000a4
-#define RTC_DATE_YEAR_MSB                        23
-#define RTC_DATE_YEAR_LSB                        16
-#define RTC_DATE_YEAR_MASK                       0x00ff0000
-#define RTC_DATE_YEAR_GET(x)                     (((x) & RTC_DATE_YEAR_MASK) >> RTC_DATE_YEAR_LSB)
-#define RTC_DATE_YEAR_SET(x)                     (((x) << RTC_DATE_YEAR_LSB) & RTC_DATE_YEAR_MASK)
-#define RTC_DATE_MONTH_MSB                       12
-#define RTC_DATE_MONTH_LSB                       8
-#define RTC_DATE_MONTH_MASK                      0x00001f00
-#define RTC_DATE_MONTH_GET(x)                    (((x) & RTC_DATE_MONTH_MASK) >> RTC_DATE_MONTH_LSB)
-#define RTC_DATE_MONTH_SET(x)                    (((x) << RTC_DATE_MONTH_LSB) & RTC_DATE_MONTH_MASK)
-#define RTC_DATE_MONTH_DAY_MSB                   5
-#define RTC_DATE_MONTH_DAY_LSB                   0
-#define RTC_DATE_MONTH_DAY_MASK                  0x0000003f
-#define RTC_DATE_MONTH_DAY_GET(x)                (((x) & RTC_DATE_MONTH_DAY_MASK) >> RTC_DATE_MONTH_DAY_LSB)
-#define RTC_DATE_MONTH_DAY_SET(x)                (((x) << RTC_DATE_MONTH_DAY_LSB) & RTC_DATE_MONTH_DAY_MASK)
-
-#define RTC_SET_TIME_ADDRESS                     0x000000a8
-#define RTC_SET_TIME_OFFSET                      0x000000a8
-#define RTC_SET_TIME_WEEK_DAY_MSB                26
-#define RTC_SET_TIME_WEEK_DAY_LSB                24
-#define RTC_SET_TIME_WEEK_DAY_MASK               0x07000000
-#define RTC_SET_TIME_WEEK_DAY_GET(x)             (((x) & RTC_SET_TIME_WEEK_DAY_MASK) >> RTC_SET_TIME_WEEK_DAY_LSB)
-#define RTC_SET_TIME_WEEK_DAY_SET(x)             (((x) << RTC_SET_TIME_WEEK_DAY_LSB) & RTC_SET_TIME_WEEK_DAY_MASK)
-#define RTC_SET_TIME_HOUR_MSB                    21
-#define RTC_SET_TIME_HOUR_LSB                    16
-#define RTC_SET_TIME_HOUR_MASK                   0x003f0000
-#define RTC_SET_TIME_HOUR_GET(x)                 (((x) & RTC_SET_TIME_HOUR_MASK) >> RTC_SET_TIME_HOUR_LSB)
-#define RTC_SET_TIME_HOUR_SET(x)                 (((x) << RTC_SET_TIME_HOUR_LSB) & RTC_SET_TIME_HOUR_MASK)
-#define RTC_SET_TIME_MINUTE_MSB                  14
-#define RTC_SET_TIME_MINUTE_LSB                  8
-#define RTC_SET_TIME_MINUTE_MASK                 0x00007f00
-#define RTC_SET_TIME_MINUTE_GET(x)               (((x) & RTC_SET_TIME_MINUTE_MASK) >> RTC_SET_TIME_MINUTE_LSB)
-#define RTC_SET_TIME_MINUTE_SET(x)               (((x) << RTC_SET_TIME_MINUTE_LSB) & RTC_SET_TIME_MINUTE_MASK)
-#define RTC_SET_TIME_SECOND_MSB                  6
-#define RTC_SET_TIME_SECOND_LSB                  0
-#define RTC_SET_TIME_SECOND_MASK                 0x0000007f
-#define RTC_SET_TIME_SECOND_GET(x)               (((x) & RTC_SET_TIME_SECOND_MASK) >> RTC_SET_TIME_SECOND_LSB)
-#define RTC_SET_TIME_SECOND_SET(x)               (((x) << RTC_SET_TIME_SECOND_LSB) & RTC_SET_TIME_SECOND_MASK)
-
-#define RTC_SET_DATE_ADDRESS                     0x000000ac
-#define RTC_SET_DATE_OFFSET                      0x000000ac
-#define RTC_SET_DATE_YEAR_MSB                    23
-#define RTC_SET_DATE_YEAR_LSB                    16
-#define RTC_SET_DATE_YEAR_MASK                   0x00ff0000
-#define RTC_SET_DATE_YEAR_GET(x)                 (((x) & RTC_SET_DATE_YEAR_MASK) >> RTC_SET_DATE_YEAR_LSB)
-#define RTC_SET_DATE_YEAR_SET(x)                 (((x) << RTC_SET_DATE_YEAR_LSB) & RTC_SET_DATE_YEAR_MASK)
-#define RTC_SET_DATE_MONTH_MSB                   12
-#define RTC_SET_DATE_MONTH_LSB                   8
-#define RTC_SET_DATE_MONTH_MASK                  0x00001f00
-#define RTC_SET_DATE_MONTH_GET(x)                (((x) & RTC_SET_DATE_MONTH_MASK) >> RTC_SET_DATE_MONTH_LSB)
-#define RTC_SET_DATE_MONTH_SET(x)                (((x) << RTC_SET_DATE_MONTH_LSB) & RTC_SET_DATE_MONTH_MASK)
-#define RTC_SET_DATE_MONTH_DAY_MSB               5
-#define RTC_SET_DATE_MONTH_DAY_LSB               0
-#define RTC_SET_DATE_MONTH_DAY_MASK              0x0000003f
-#define RTC_SET_DATE_MONTH_DAY_GET(x)            (((x) & RTC_SET_DATE_MONTH_DAY_MASK) >> RTC_SET_DATE_MONTH_DAY_LSB)
-#define RTC_SET_DATE_MONTH_DAY_SET(x)            (((x) << RTC_SET_DATE_MONTH_DAY_LSB) & RTC_SET_DATE_MONTH_DAY_MASK)
-
-#define RTC_SET_ALARM_ADDRESS                    0x000000b0
-#define RTC_SET_ALARM_OFFSET                     0x000000b0
-#define RTC_SET_ALARM_HOUR_MSB                   21
-#define RTC_SET_ALARM_HOUR_LSB                   16
-#define RTC_SET_ALARM_HOUR_MASK                  0x003f0000
-#define RTC_SET_ALARM_HOUR_GET(x)                (((x) & RTC_SET_ALARM_HOUR_MASK) >> RTC_SET_ALARM_HOUR_LSB)
-#define RTC_SET_ALARM_HOUR_SET(x)                (((x) << RTC_SET_ALARM_HOUR_LSB) & RTC_SET_ALARM_HOUR_MASK)
-#define RTC_SET_ALARM_MINUTE_MSB                 14
-#define RTC_SET_ALARM_MINUTE_LSB                 8
-#define RTC_SET_ALARM_MINUTE_MASK                0x00007f00
-#define RTC_SET_ALARM_MINUTE_GET(x)              (((x) & RTC_SET_ALARM_MINUTE_MASK) >> RTC_SET_ALARM_MINUTE_LSB)
-#define RTC_SET_ALARM_MINUTE_SET(x)              (((x) << RTC_SET_ALARM_MINUTE_LSB) & RTC_SET_ALARM_MINUTE_MASK)
-#define RTC_SET_ALARM_SECOND_MSB                 6
-#define RTC_SET_ALARM_SECOND_LSB                 0
-#define RTC_SET_ALARM_SECOND_MASK                0x0000007f
-#define RTC_SET_ALARM_SECOND_GET(x)              (((x) & RTC_SET_ALARM_SECOND_MASK) >> RTC_SET_ALARM_SECOND_LSB)
-#define RTC_SET_ALARM_SECOND_SET(x)              (((x) << RTC_SET_ALARM_SECOND_LSB) & RTC_SET_ALARM_SECOND_MASK)
-
-#define RTC_CONFIG_ADDRESS                       0x000000b4
-#define RTC_CONFIG_OFFSET                        0x000000b4
-#define RTC_CONFIG_BCD_MSB                       2
-#define RTC_CONFIG_BCD_LSB                       2
-#define RTC_CONFIG_BCD_MASK                      0x00000004
-#define RTC_CONFIG_BCD_GET(x)                    (((x) & RTC_CONFIG_BCD_MASK) >> RTC_CONFIG_BCD_LSB)
-#define RTC_CONFIG_BCD_SET(x)                    (((x) << RTC_CONFIG_BCD_LSB) & RTC_CONFIG_BCD_MASK)
-#define RTC_CONFIG_TWELVE_HOUR_MSB               1
-#define RTC_CONFIG_TWELVE_HOUR_LSB               1
-#define RTC_CONFIG_TWELVE_HOUR_MASK              0x00000002
-#define RTC_CONFIG_TWELVE_HOUR_GET(x)            (((x) & RTC_CONFIG_TWELVE_HOUR_MASK) >> RTC_CONFIG_TWELVE_HOUR_LSB)
-#define RTC_CONFIG_TWELVE_HOUR_SET(x)            (((x) << RTC_CONFIG_TWELVE_HOUR_LSB) & RTC_CONFIG_TWELVE_HOUR_MASK)
-#define RTC_CONFIG_DSE_MSB                       0
-#define RTC_CONFIG_DSE_LSB                       0
-#define RTC_CONFIG_DSE_MASK                      0x00000001
-#define RTC_CONFIG_DSE_GET(x)                    (((x) & RTC_CONFIG_DSE_MASK) >> RTC_CONFIG_DSE_LSB)
-#define RTC_CONFIG_DSE_SET(x)                    (((x) << RTC_CONFIG_DSE_LSB) & RTC_CONFIG_DSE_MASK)
-
-#define RTC_ALARM_STATUS_ADDRESS                 0x000000b8
-#define RTC_ALARM_STATUS_OFFSET                  0x000000b8
-#define RTC_ALARM_STATUS_ENABLE_MSB              1
-#define RTC_ALARM_STATUS_ENABLE_LSB              1
-#define RTC_ALARM_STATUS_ENABLE_MASK             0x00000002
-#define RTC_ALARM_STATUS_ENABLE_GET(x)           (((x) & RTC_ALARM_STATUS_ENABLE_MASK) >> RTC_ALARM_STATUS_ENABLE_LSB)
-#define RTC_ALARM_STATUS_ENABLE_SET(x)           (((x) << RTC_ALARM_STATUS_ENABLE_LSB) & RTC_ALARM_STATUS_ENABLE_MASK)
-#define RTC_ALARM_STATUS_INTERRUPT_MSB           0
-#define RTC_ALARM_STATUS_INTERRUPT_LSB           0
-#define RTC_ALARM_STATUS_INTERRUPT_MASK          0x00000001
-#define RTC_ALARM_STATUS_INTERRUPT_GET(x)        (((x) & RTC_ALARM_STATUS_INTERRUPT_MASK) >> RTC_ALARM_STATUS_INTERRUPT_LSB)
-#define RTC_ALARM_STATUS_INTERRUPT_SET(x)        (((x) << RTC_ALARM_STATUS_INTERRUPT_LSB) & RTC_ALARM_STATUS_INTERRUPT_MASK)
-
-#define UART_WAKEUP_ADDRESS                      0x000000bc
-#define UART_WAKEUP_OFFSET                       0x000000bc
-#define UART_WAKEUP_ENABLE_MSB                   0
-#define UART_WAKEUP_ENABLE_LSB                   0
-#define UART_WAKEUP_ENABLE_MASK                  0x00000001
-#define UART_WAKEUP_ENABLE_GET(x)                (((x) & UART_WAKEUP_ENABLE_MASK) >> UART_WAKEUP_ENABLE_LSB)
-#define UART_WAKEUP_ENABLE_SET(x)                (((x) << UART_WAKEUP_ENABLE_LSB) & UART_WAKEUP_ENABLE_MASK)
-
-#define RESET_CAUSE_ADDRESS                      0x000000c0
-#define RESET_CAUSE_OFFSET                       0x000000c0
-#define RESET_CAUSE_LAST_MSB                     2
-#define RESET_CAUSE_LAST_LSB                     0
-#define RESET_CAUSE_LAST_MASK                    0x00000007
-#define RESET_CAUSE_LAST_GET(x)                  (((x) & RESET_CAUSE_LAST_MASK) >> RESET_CAUSE_LAST_LSB)
-#define RESET_CAUSE_LAST_SET(x)                  (((x) << RESET_CAUSE_LAST_LSB) & RESET_CAUSE_LAST_MASK)
-
-#define SYSTEM_SLEEP_ADDRESS                     0x000000c4
-#define SYSTEM_SLEEP_OFFSET                      0x000000c4
-#define SYSTEM_SLEEP_HOST_IF_MSB                 4
-#define SYSTEM_SLEEP_HOST_IF_LSB                 4
-#define SYSTEM_SLEEP_HOST_IF_MASK                0x00000010
-#define SYSTEM_SLEEP_HOST_IF_GET(x)              (((x) & SYSTEM_SLEEP_HOST_IF_MASK) >> SYSTEM_SLEEP_HOST_IF_LSB)
-#define SYSTEM_SLEEP_HOST_IF_SET(x)              (((x) << SYSTEM_SLEEP_HOST_IF_LSB) & SYSTEM_SLEEP_HOST_IF_MASK)
-#define SYSTEM_SLEEP_MBOX_MSB                    3
-#define SYSTEM_SLEEP_MBOX_LSB                    3
-#define SYSTEM_SLEEP_MBOX_MASK                   0x00000008
-#define SYSTEM_SLEEP_MBOX_GET(x)                 (((x) & SYSTEM_SLEEP_MBOX_MASK) >> SYSTEM_SLEEP_MBOX_LSB)
-#define SYSTEM_SLEEP_MBOX_SET(x)                 (((x) << SYSTEM_SLEEP_MBOX_LSB) & SYSTEM_SLEEP_MBOX_MASK)
-#define SYSTEM_SLEEP_MAC_IF_MSB                  2
-#define SYSTEM_SLEEP_MAC_IF_LSB                  2
-#define SYSTEM_SLEEP_MAC_IF_MASK                 0x00000004
-#define SYSTEM_SLEEP_MAC_IF_GET(x)               (((x) & SYSTEM_SLEEP_MAC_IF_MASK) >> SYSTEM_SLEEP_MAC_IF_LSB)
-#define SYSTEM_SLEEP_MAC_IF_SET(x)               (((x) << SYSTEM_SLEEP_MAC_IF_LSB) & SYSTEM_SLEEP_MAC_IF_MASK)
-#define SYSTEM_SLEEP_LIGHT_MSB                   1
-#define SYSTEM_SLEEP_LIGHT_LSB                   1
-#define SYSTEM_SLEEP_LIGHT_MASK                  0x00000002
-#define SYSTEM_SLEEP_LIGHT_GET(x)                (((x) & SYSTEM_SLEEP_LIGHT_MASK) >> SYSTEM_SLEEP_LIGHT_LSB)
-#define SYSTEM_SLEEP_LIGHT_SET(x)                (((x) << SYSTEM_SLEEP_LIGHT_LSB) & SYSTEM_SLEEP_LIGHT_MASK)
-#define SYSTEM_SLEEP_DISABLE_MSB                 0
-#define SYSTEM_SLEEP_DISABLE_LSB                 0
-#define SYSTEM_SLEEP_DISABLE_MASK                0x00000001
-#define SYSTEM_SLEEP_DISABLE_GET(x)              (((x) & SYSTEM_SLEEP_DISABLE_MASK) >> SYSTEM_SLEEP_DISABLE_LSB)
-#define SYSTEM_SLEEP_DISABLE_SET(x)              (((x) << SYSTEM_SLEEP_DISABLE_LSB) & SYSTEM_SLEEP_DISABLE_MASK)
-
-#define SDIO_WRAPPER_ADDRESS                     0x000000c8
-#define SDIO_WRAPPER_OFFSET                      0x000000c8
-#define SDIO_WRAPPER_SLEEP_MSB                   3
-#define SDIO_WRAPPER_SLEEP_LSB                   3
-#define SDIO_WRAPPER_SLEEP_MASK                  0x00000008
-#define SDIO_WRAPPER_SLEEP_GET(x)                (((x) & SDIO_WRAPPER_SLEEP_MASK) >> SDIO_WRAPPER_SLEEP_LSB)
-#define SDIO_WRAPPER_SLEEP_SET(x)                (((x) << SDIO_WRAPPER_SLEEP_LSB) & SDIO_WRAPPER_SLEEP_MASK)
-#define SDIO_WRAPPER_WAKEUP_MSB                  2
-#define SDIO_WRAPPER_WAKEUP_LSB                  2
-#define SDIO_WRAPPER_WAKEUP_MASK                 0x00000004
-#define SDIO_WRAPPER_WAKEUP_GET(x)               (((x) & SDIO_WRAPPER_WAKEUP_MASK) >> SDIO_WRAPPER_WAKEUP_LSB)
-#define SDIO_WRAPPER_WAKEUP_SET(x)               (((x) << SDIO_WRAPPER_WAKEUP_LSB) & SDIO_WRAPPER_WAKEUP_MASK)
-#define SDIO_WRAPPER_SOC_ON_MSB                  1
-#define SDIO_WRAPPER_SOC_ON_LSB                  1
-#define SDIO_WRAPPER_SOC_ON_MASK                 0x00000002
-#define SDIO_WRAPPER_SOC_ON_GET(x)               (((x) & SDIO_WRAPPER_SOC_ON_MASK) >> SDIO_WRAPPER_SOC_ON_LSB)
-#define SDIO_WRAPPER_SOC_ON_SET(x)               (((x) << SDIO_WRAPPER_SOC_ON_LSB) & SDIO_WRAPPER_SOC_ON_MASK)
-#define SDIO_WRAPPER_ON_MSB                      0
-#define SDIO_WRAPPER_ON_LSB                      0
-#define SDIO_WRAPPER_ON_MASK                     0x00000001
-#define SDIO_WRAPPER_ON_GET(x)                   (((x) & SDIO_WRAPPER_ON_MASK) >> SDIO_WRAPPER_ON_LSB)
-#define SDIO_WRAPPER_ON_SET(x)                   (((x) << SDIO_WRAPPER_ON_LSB) & SDIO_WRAPPER_ON_MASK)
-
-#define MAC_SLEEP_CONTROL_ADDRESS                0x000000cc
-#define MAC_SLEEP_CONTROL_OFFSET                 0x000000cc
-#define MAC_SLEEP_CONTROL_ENABLE_MSB             1
-#define MAC_SLEEP_CONTROL_ENABLE_LSB             0
-#define MAC_SLEEP_CONTROL_ENABLE_MASK            0x00000003
-#define MAC_SLEEP_CONTROL_ENABLE_GET(x)          (((x) & MAC_SLEEP_CONTROL_ENABLE_MASK) >> MAC_SLEEP_CONTROL_ENABLE_LSB)
-#define MAC_SLEEP_CONTROL_ENABLE_SET(x)          (((x) << MAC_SLEEP_CONTROL_ENABLE_LSB) & MAC_SLEEP_CONTROL_ENABLE_MASK)
-
-#define KEEP_AWAKE_ADDRESS                       0x000000d0
-#define KEEP_AWAKE_OFFSET                        0x000000d0
-#define KEEP_AWAKE_COUNT_MSB                     7
-#define KEEP_AWAKE_COUNT_LSB                     0
-#define KEEP_AWAKE_COUNT_MASK                    0x000000ff
-#define KEEP_AWAKE_COUNT_GET(x)                  (((x) & KEEP_AWAKE_COUNT_MASK) >> KEEP_AWAKE_COUNT_LSB)
-#define KEEP_AWAKE_COUNT_SET(x)                  (((x) << KEEP_AWAKE_COUNT_LSB) & KEEP_AWAKE_COUNT_MASK)
-
-#define LPO_CAL_TIME_ADDRESS                     0x000000d4
-#define LPO_CAL_TIME_OFFSET                      0x000000d4
-#define LPO_CAL_TIME_LENGTH_MSB                  13
-#define LPO_CAL_TIME_LENGTH_LSB                  0
-#define LPO_CAL_TIME_LENGTH_MASK                 0x00003fff
-#define LPO_CAL_TIME_LENGTH_GET(x)               (((x) & LPO_CAL_TIME_LENGTH_MASK) >> LPO_CAL_TIME_LENGTH_LSB)
-#define LPO_CAL_TIME_LENGTH_SET(x)               (((x) << LPO_CAL_TIME_LENGTH_LSB) & LPO_CAL_TIME_LENGTH_MASK)
-
-#define LPO_INIT_DIVIDEND_INT_ADDRESS            0x000000d8
-#define LPO_INIT_DIVIDEND_INT_OFFSET             0x000000d8
-#define LPO_INIT_DIVIDEND_INT_VALUE_MSB          23
-#define LPO_INIT_DIVIDEND_INT_VALUE_LSB          0
-#define LPO_INIT_DIVIDEND_INT_VALUE_MASK         0x00ffffff
-#define LPO_INIT_DIVIDEND_INT_VALUE_GET(x)       (((x) & LPO_INIT_DIVIDEND_INT_VALUE_MASK) >> LPO_INIT_DIVIDEND_INT_VALUE_LSB)
-#define LPO_INIT_DIVIDEND_INT_VALUE_SET(x)       (((x) << LPO_INIT_DIVIDEND_INT_VALUE_LSB) & LPO_INIT_DIVIDEND_INT_VALUE_MASK)
-
-#define LPO_INIT_DIVIDEND_FRACTION_ADDRESS       0x000000dc
-#define LPO_INIT_DIVIDEND_FRACTION_OFFSET        0x000000dc
-#define LPO_INIT_DIVIDEND_FRACTION_VALUE_MSB     10
-#define LPO_INIT_DIVIDEND_FRACTION_VALUE_LSB     0
-#define LPO_INIT_DIVIDEND_FRACTION_VALUE_MASK    0x000007ff
-#define LPO_INIT_DIVIDEND_FRACTION_VALUE_GET(x)  (((x) & LPO_INIT_DIVIDEND_FRACTION_VALUE_MASK) >> LPO_INIT_DIVIDEND_FRACTION_VALUE_LSB)
-#define LPO_INIT_DIVIDEND_FRACTION_VALUE_SET(x)  (((x) << LPO_INIT_DIVIDEND_FRACTION_VALUE_LSB) & LPO_INIT_DIVIDEND_FRACTION_VALUE_MASK)
-
-#define LPO_CAL_ADDRESS                          0x000000e0
-#define LPO_CAL_OFFSET                           0x000000e0
-#define LPO_CAL_ENABLE_MSB                       20
-#define LPO_CAL_ENABLE_LSB                       20
-#define LPO_CAL_ENABLE_MASK                      0x00100000
-#define LPO_CAL_ENABLE_GET(x)                    (((x) & LPO_CAL_ENABLE_MASK) >> LPO_CAL_ENABLE_LSB)
-#define LPO_CAL_ENABLE_SET(x)                    (((x) << LPO_CAL_ENABLE_LSB) & LPO_CAL_ENABLE_MASK)
-#define LPO_CAL_COUNT_MSB                        19
-#define LPO_CAL_COUNT_LSB                        0
-#define LPO_CAL_COUNT_MASK                       0x000fffff
-#define LPO_CAL_COUNT_GET(x)                     (((x) & LPO_CAL_COUNT_MASK) >> LPO_CAL_COUNT_LSB)
-#define LPO_CAL_COUNT_SET(x)                     (((x) << LPO_CAL_COUNT_LSB) & LPO_CAL_COUNT_MASK)
-
-#define LPO_CAL_TEST_CONTROL_ADDRESS             0x000000e4
-#define LPO_CAL_TEST_CONTROL_OFFSET              0x000000e4
-#define LPO_CAL_TEST_CONTROL_ENABLE_MSB          5
-#define LPO_CAL_TEST_CONTROL_ENABLE_LSB          5
-#define LPO_CAL_TEST_CONTROL_ENABLE_MASK         0x00000020
-#define LPO_CAL_TEST_CONTROL_ENABLE_GET(x)       (((x) & LPO_CAL_TEST_CONTROL_ENABLE_MASK) >> LPO_CAL_TEST_CONTROL_ENABLE_LSB)
-#define LPO_CAL_TEST_CONTROL_ENABLE_SET(x)       (((x) << LPO_CAL_TEST_CONTROL_ENABLE_LSB) & LPO_CAL_TEST_CONTROL_ENABLE_MASK)
-#define LPO_CAL_TEST_CONTROL_RTC_CYCLES_MSB      4
-#define LPO_CAL_TEST_CONTROL_RTC_CYCLES_LSB      0
-#define LPO_CAL_TEST_CONTROL_RTC_CYCLES_MASK     0x0000001f
-#define LPO_CAL_TEST_CONTROL_RTC_CYCLES_GET(x)   (((x) & LPO_CAL_TEST_CONTROL_RTC_CYCLES_MASK) >> LPO_CAL_TEST_CONTROL_RTC_CYCLES_LSB)
-#define LPO_CAL_TEST_CONTROL_RTC_CYCLES_SET(x)   (((x) << LPO_CAL_TEST_CONTROL_RTC_CYCLES_LSB) & LPO_CAL_TEST_CONTROL_RTC_CYCLES_MASK)
-
-#define LPO_CAL_TEST_STATUS_ADDRESS              0x000000e8
-#define LPO_CAL_TEST_STATUS_OFFSET               0x000000e8
-#define LPO_CAL_TEST_STATUS_READY_MSB            16
-#define LPO_CAL_TEST_STATUS_READY_LSB            16
-#define LPO_CAL_TEST_STATUS_READY_MASK           0x00010000
-#define LPO_CAL_TEST_STATUS_READY_GET(x)         (((x) & LPO_CAL_TEST_STATUS_READY_MASK) >> LPO_CAL_TEST_STATUS_READY_LSB)
-#define LPO_CAL_TEST_STATUS_READY_SET(x)         (((x) << LPO_CAL_TEST_STATUS_READY_LSB) & LPO_CAL_TEST_STATUS_READY_MASK)
-#define LPO_CAL_TEST_STATUS_COUNT_MSB            15
-#define LPO_CAL_TEST_STATUS_COUNT_LSB            0
-#define LPO_CAL_TEST_STATUS_COUNT_MASK           0x0000ffff
-#define LPO_CAL_TEST_STATUS_COUNT_GET(x)         (((x) & LPO_CAL_TEST_STATUS_COUNT_MASK) >> LPO_CAL_TEST_STATUS_COUNT_LSB)
-#define LPO_CAL_TEST_STATUS_COUNT_SET(x)         (((x) << LPO_CAL_TEST_STATUS_COUNT_LSB) & LPO_CAL_TEST_STATUS_COUNT_MASK)
-
-#define CHIP_ID_ADDRESS                          0x000000ec
-#define CHIP_ID_OFFSET                           0x000000ec
-#define CHIP_ID_DEVICE_ID_MSB                    31
-#define CHIP_ID_DEVICE_ID_LSB                    16
-#define CHIP_ID_DEVICE_ID_MASK                   0xffff0000
-#define CHIP_ID_DEVICE_ID_GET(x)                 (((x) & CHIP_ID_DEVICE_ID_MASK) >> CHIP_ID_DEVICE_ID_LSB)
-#define CHIP_ID_DEVICE_ID_SET(x)                 (((x) << CHIP_ID_DEVICE_ID_LSB) & CHIP_ID_DEVICE_ID_MASK)
-#define CHIP_ID_CONFIG_ID_MSB                    15
-#define CHIP_ID_CONFIG_ID_LSB                    4
-#define CHIP_ID_CONFIG_ID_MASK                   0x0000fff0
-#define CHIP_ID_CONFIG_ID_GET(x)                 (((x) & CHIP_ID_CONFIG_ID_MASK) >> CHIP_ID_CONFIG_ID_LSB)
-#define CHIP_ID_CONFIG_ID_SET(x)                 (((x) << CHIP_ID_CONFIG_ID_LSB) & CHIP_ID_CONFIG_ID_MASK)
-#define CHIP_ID_VERSION_ID_MSB                   3
-#define CHIP_ID_VERSION_ID_LSB                   0
-#define CHIP_ID_VERSION_ID_MASK                  0x0000000f
-#define CHIP_ID_VERSION_ID_GET(x)                (((x) & CHIP_ID_VERSION_ID_MASK) >> CHIP_ID_VERSION_ID_LSB)
-#define CHIP_ID_VERSION_ID_SET(x)                (((x) << CHIP_ID_VERSION_ID_LSB) & CHIP_ID_VERSION_ID_MASK)
-
-#define DERIVED_RTC_CLK_ADDRESS                  0x000000f0
-#define DERIVED_RTC_CLK_OFFSET                   0x000000f0
-#define DERIVED_RTC_CLK_EXTERNAL_DETECT_EN_MSB   20
-#define DERIVED_RTC_CLK_EXTERNAL_DETECT_EN_LSB   20
-#define DERIVED_RTC_CLK_EXTERNAL_DETECT_EN_MASK  0x00100000
-#define DERIVED_RTC_CLK_EXTERNAL_DETECT_EN_GET(x) (((x) & DERIVED_RTC_CLK_EXTERNAL_DETECT_EN_MASK) >> DERIVED_RTC_CLK_EXTERNAL_DETECT_EN_LSB)
-#define DERIVED_RTC_CLK_EXTERNAL_DETECT_EN_SET(x) (((x) << DERIVED_RTC_CLK_EXTERNAL_DETECT_EN_LSB) & DERIVED_RTC_CLK_EXTERNAL_DETECT_EN_MASK)
-#define DERIVED_RTC_CLK_EXTERNAL_DETECT_MSB      18
-#define DERIVED_RTC_CLK_EXTERNAL_DETECT_LSB      18
-#define DERIVED_RTC_CLK_EXTERNAL_DETECT_MASK     0x00040000
-#define DERIVED_RTC_CLK_EXTERNAL_DETECT_GET(x)   (((x) & DERIVED_RTC_CLK_EXTERNAL_DETECT_MASK) >> DERIVED_RTC_CLK_EXTERNAL_DETECT_LSB)
-#define DERIVED_RTC_CLK_EXTERNAL_DETECT_SET(x)   (((x) << DERIVED_RTC_CLK_EXTERNAL_DETECT_LSB) & DERIVED_RTC_CLK_EXTERNAL_DETECT_MASK)
-#define DERIVED_RTC_CLK_FORCE_MSB                17
-#define DERIVED_RTC_CLK_FORCE_LSB                16
-#define DERIVED_RTC_CLK_FORCE_MASK               0x00030000
-#define DERIVED_RTC_CLK_FORCE_GET(x)             (((x) & DERIVED_RTC_CLK_FORCE_MASK) >> DERIVED_RTC_CLK_FORCE_LSB)
-#define DERIVED_RTC_CLK_FORCE_SET(x)             (((x) << DERIVED_RTC_CLK_FORCE_LSB) & DERIVED_RTC_CLK_FORCE_MASK)
-#define DERIVED_RTC_CLK_PERIOD_MSB               15
-#define DERIVED_RTC_CLK_PERIOD_LSB               1
-#define DERIVED_RTC_CLK_PERIOD_MASK              0x0000fffe
-#define DERIVED_RTC_CLK_PERIOD_GET(x)            (((x) & DERIVED_RTC_CLK_PERIOD_MASK) >> DERIVED_RTC_CLK_PERIOD_LSB)
-#define DERIVED_RTC_CLK_PERIOD_SET(x)            (((x) << DERIVED_RTC_CLK_PERIOD_LSB) & DERIVED_RTC_CLK_PERIOD_MASK)
-
-#define MAC_PCU_SLP32_MODE_ADDRESS               0x000000f4
-#define MAC_PCU_SLP32_MODE_OFFSET                0x000000f4
-#define MAC_PCU_SLP32_MODE_TSF_WRITE_PENDING_MSB 21
-#define MAC_PCU_SLP32_MODE_TSF_WRITE_PENDING_LSB 21
-#define MAC_PCU_SLP32_MODE_TSF_WRITE_PENDING_MASK 0x00200000
-#define MAC_PCU_SLP32_MODE_TSF_WRITE_PENDING_GET(x) (((x) & MAC_PCU_SLP32_MODE_TSF_WRITE_PENDING_MASK) >> MAC_PCU_SLP32_MODE_TSF_WRITE_PENDING_LSB)
-#define MAC_PCU_SLP32_MODE_TSF_WRITE_PENDING_SET(x) (((x) << MAC_PCU_SLP32_MODE_TSF_WRITE_PENDING_LSB) & MAC_PCU_SLP32_MODE_TSF_WRITE_PENDING_MASK)
-#define MAC_PCU_SLP32_MODE_HALF_CLK_LATENCY_MSB  19
-#define MAC_PCU_SLP32_MODE_HALF_CLK_LATENCY_LSB  0
-#define MAC_PCU_SLP32_MODE_HALF_CLK_LATENCY_MASK 0x000fffff
-#define MAC_PCU_SLP32_MODE_HALF_CLK_LATENCY_GET(x) (((x) & MAC_PCU_SLP32_MODE_HALF_CLK_LATENCY_MASK) >> MAC_PCU_SLP32_MODE_HALF_CLK_LATENCY_LSB)
-#define MAC_PCU_SLP32_MODE_HALF_CLK_LATENCY_SET(x) (((x) << MAC_PCU_SLP32_MODE_HALF_CLK_LATENCY_LSB) & MAC_PCU_SLP32_MODE_HALF_CLK_LATENCY_MASK)
-
-#define MAC_PCU_SLP32_WAKE_ADDRESS               0x000000f8
-#define MAC_PCU_SLP32_WAKE_OFFSET                0x000000f8
-#define MAC_PCU_SLP32_WAKE_XTL_TIME_MSB          15
-#define MAC_PCU_SLP32_WAKE_XTL_TIME_LSB          0
-#define MAC_PCU_SLP32_WAKE_XTL_TIME_MASK         0x0000ffff
-#define MAC_PCU_SLP32_WAKE_XTL_TIME_GET(x)       (((x) & MAC_PCU_SLP32_WAKE_XTL_TIME_MASK) >> MAC_PCU_SLP32_WAKE_XTL_TIME_LSB)
-#define MAC_PCU_SLP32_WAKE_XTL_TIME_SET(x)       (((x) << MAC_PCU_SLP32_WAKE_XTL_TIME_LSB) & MAC_PCU_SLP32_WAKE_XTL_TIME_MASK)
-
-#define MAC_PCU_SLP32_INC_ADDRESS                0x000000fc
-#define MAC_PCU_SLP32_INC_OFFSET                 0x000000fc
-#define MAC_PCU_SLP32_INC_TSF_INC_MSB            19
-#define MAC_PCU_SLP32_INC_TSF_INC_LSB            0
-#define MAC_PCU_SLP32_INC_TSF_INC_MASK           0x000fffff
-#define MAC_PCU_SLP32_INC_TSF_INC_GET(x)         (((x) & MAC_PCU_SLP32_INC_TSF_INC_MASK) >> MAC_PCU_SLP32_INC_TSF_INC_LSB)
-#define MAC_PCU_SLP32_INC_TSF_INC_SET(x)         (((x) << MAC_PCU_SLP32_INC_TSF_INC_LSB) & MAC_PCU_SLP32_INC_TSF_INC_MASK)
-
-#define MAC_PCU_SLP_MIB1_ADDRESS                 0x00000100
-#define MAC_PCU_SLP_MIB1_OFFSET                  0x00000100
-#define MAC_PCU_SLP_MIB1_SLEEP_CNT_MSB           31
-#define MAC_PCU_SLP_MIB1_SLEEP_CNT_LSB           0
-#define MAC_PCU_SLP_MIB1_SLEEP_CNT_MASK          0xffffffff
-#define MAC_PCU_SLP_MIB1_SLEEP_CNT_GET(x)        (((x) & MAC_PCU_SLP_MIB1_SLEEP_CNT_MASK) >> MAC_PCU_SLP_MIB1_SLEEP_CNT_LSB)
-#define MAC_PCU_SLP_MIB1_SLEEP_CNT_SET(x)        (((x) << MAC_PCU_SLP_MIB1_SLEEP_CNT_LSB) & MAC_PCU_SLP_MIB1_SLEEP_CNT_MASK)
-
-#define MAC_PCU_SLP_MIB2_ADDRESS                 0x00000104
-#define MAC_PCU_SLP_MIB2_OFFSET                  0x00000104
-#define MAC_PCU_SLP_MIB2_CYCLE_CNT_MSB           31
-#define MAC_PCU_SLP_MIB2_CYCLE_CNT_LSB           0
-#define MAC_PCU_SLP_MIB2_CYCLE_CNT_MASK          0xffffffff
-#define MAC_PCU_SLP_MIB2_CYCLE_CNT_GET(x)        (((x) & MAC_PCU_SLP_MIB2_CYCLE_CNT_MASK) >> MAC_PCU_SLP_MIB2_CYCLE_CNT_LSB)
-#define MAC_PCU_SLP_MIB2_CYCLE_CNT_SET(x)        (((x) << MAC_PCU_SLP_MIB2_CYCLE_CNT_LSB) & MAC_PCU_SLP_MIB2_CYCLE_CNT_MASK)
-
-#define MAC_PCU_SLP_MIB3_ADDRESS                 0x00000108
-#define MAC_PCU_SLP_MIB3_OFFSET                  0x00000108
-#define MAC_PCU_SLP_MIB3_PENDING_MSB             1
-#define MAC_PCU_SLP_MIB3_PENDING_LSB             1
-#define MAC_PCU_SLP_MIB3_PENDING_MASK            0x00000002
-#define MAC_PCU_SLP_MIB3_PENDING_GET(x)          (((x) & MAC_PCU_SLP_MIB3_PENDING_MASK) >> MAC_PCU_SLP_MIB3_PENDING_LSB)
-#define MAC_PCU_SLP_MIB3_PENDING_SET(x)          (((x) << MAC_PCU_SLP_MIB3_PENDING_LSB) & MAC_PCU_SLP_MIB3_PENDING_MASK)
-#define MAC_PCU_SLP_MIB3_CLR_CNT_MSB             0
-#define MAC_PCU_SLP_MIB3_CLR_CNT_LSB             0
-#define MAC_PCU_SLP_MIB3_CLR_CNT_MASK            0x00000001
-#define MAC_PCU_SLP_MIB3_CLR_CNT_GET(x)          (((x) & MAC_PCU_SLP_MIB3_CLR_CNT_MASK) >> MAC_PCU_SLP_MIB3_CLR_CNT_LSB)
-#define MAC_PCU_SLP_MIB3_CLR_CNT_SET(x)          (((x) << MAC_PCU_SLP_MIB3_CLR_CNT_LSB) & MAC_PCU_SLP_MIB3_CLR_CNT_MASK)
-
-#define MAC_PCU_SLP_BEACON_ADDRESS               0x0000010c
-#define MAC_PCU_SLP_BEACON_OFFSET                0x0000010c
-#define MAC_PCU_SLP_BEACON_BMISS_TIMEOUT_ENABLE_MSB 24
-#define MAC_PCU_SLP_BEACON_BMISS_TIMEOUT_ENABLE_LSB 24
-#define MAC_PCU_SLP_BEACON_BMISS_TIMEOUT_ENABLE_MASK 0x01000000
-#define MAC_PCU_SLP_BEACON_BMISS_TIMEOUT_ENABLE_GET(x) (((x) & MAC_PCU_SLP_BEACON_BMISS_TIMEOUT_ENABLE_MASK) >> MAC_PCU_SLP_BEACON_BMISS_TIMEOUT_ENABLE_LSB)
-#define MAC_PCU_SLP_BEACON_BMISS_TIMEOUT_ENABLE_SET(x) (((x) << MAC_PCU_SLP_BEACON_BMISS_TIMEOUT_ENABLE_LSB) & MAC_PCU_SLP_BEACON_BMISS_TIMEOUT_ENABLE_MASK)
-#define MAC_PCU_SLP_BEACON_BMISS_TIMEOUT_MSB     23
-#define MAC_PCU_SLP_BEACON_BMISS_TIMEOUT_LSB     0
-#define MAC_PCU_SLP_BEACON_BMISS_TIMEOUT_MASK    0x00ffffff
-#define MAC_PCU_SLP_BEACON_BMISS_TIMEOUT_GET(x)  (((x) & MAC_PCU_SLP_BEACON_BMISS_TIMEOUT_MASK) >> MAC_PCU_SLP_BEACON_BMISS_TIMEOUT_LSB)
-#define MAC_PCU_SLP_BEACON_BMISS_TIMEOUT_SET(x)  (((x) << MAC_PCU_SLP_BEACON_BMISS_TIMEOUT_LSB) & MAC_PCU_SLP_BEACON_BMISS_TIMEOUT_MASK)
-
-#define POWER_REG_ADDRESS                        0x00000110
-#define POWER_REG_OFFSET                         0x00000110
-#define POWER_REG_VLVL_MSB                       11
-#define POWER_REG_VLVL_LSB                       8
-#define POWER_REG_VLVL_MASK                      0x00000f00
-#define POWER_REG_VLVL_GET(x)                    (((x) & POWER_REG_VLVL_MASK) >> POWER_REG_VLVL_LSB)
-#define POWER_REG_VLVL_SET(x)                    (((x) << POWER_REG_VLVL_LSB) & POWER_REG_VLVL_MASK)
-#define POWER_REG_CPU_INT_ENABLE_MSB             7
-#define POWER_REG_CPU_INT_ENABLE_LSB             7
-#define POWER_REG_CPU_INT_ENABLE_MASK            0x00000080
-#define POWER_REG_CPU_INT_ENABLE_GET(x)          (((x) & POWER_REG_CPU_INT_ENABLE_MASK) >> POWER_REG_CPU_INT_ENABLE_LSB)
-#define POWER_REG_CPU_INT_ENABLE_SET(x)          (((x) << POWER_REG_CPU_INT_ENABLE_LSB) & POWER_REG_CPU_INT_ENABLE_MASK)
-#define POWER_REG_WLAN_ISO_DIS_MSB               6
-#define POWER_REG_WLAN_ISO_DIS_LSB               6
-#define POWER_REG_WLAN_ISO_DIS_MASK              0x00000040
-#define POWER_REG_WLAN_ISO_DIS_GET(x)            (((x) & POWER_REG_WLAN_ISO_DIS_MASK) >> POWER_REG_WLAN_ISO_DIS_LSB)
-#define POWER_REG_WLAN_ISO_DIS_SET(x)            (((x) << POWER_REG_WLAN_ISO_DIS_LSB) & POWER_REG_WLAN_ISO_DIS_MASK)
-#define POWER_REG_WLAN_ISO_CNTL_MSB              5
-#define POWER_REG_WLAN_ISO_CNTL_LSB              5
-#define POWER_REG_WLAN_ISO_CNTL_MASK             0x00000020
-#define POWER_REG_WLAN_ISO_CNTL_GET(x)           (((x) & POWER_REG_WLAN_ISO_CNTL_MASK) >> POWER_REG_WLAN_ISO_CNTL_LSB)
-#define POWER_REG_WLAN_ISO_CNTL_SET(x)           (((x) << POWER_REG_WLAN_ISO_CNTL_LSB) & POWER_REG_WLAN_ISO_CNTL_MASK)
-#define POWER_REG_RADIO_PWD_EN_MSB               4
-#define POWER_REG_RADIO_PWD_EN_LSB               4
-#define POWER_REG_RADIO_PWD_EN_MASK              0x00000010
-#define POWER_REG_RADIO_PWD_EN_GET(x)            (((x) & POWER_REG_RADIO_PWD_EN_MASK) >> POWER_REG_RADIO_PWD_EN_LSB)
-#define POWER_REG_RADIO_PWD_EN_SET(x)            (((x) << POWER_REG_RADIO_PWD_EN_LSB) & POWER_REG_RADIO_PWD_EN_MASK)
-#define POWER_REG_SOC_SCALE_EN_MSB               3
-#define POWER_REG_SOC_SCALE_EN_LSB               3
-#define POWER_REG_SOC_SCALE_EN_MASK              0x00000008
-#define POWER_REG_SOC_SCALE_EN_GET(x)            (((x) & POWER_REG_SOC_SCALE_EN_MASK) >> POWER_REG_SOC_SCALE_EN_LSB)
-#define POWER_REG_SOC_SCALE_EN_SET(x)            (((x) << POWER_REG_SOC_SCALE_EN_LSB) & POWER_REG_SOC_SCALE_EN_MASK)
-#define POWER_REG_WLAN_SCALE_EN_MSB              2
-#define POWER_REG_WLAN_SCALE_EN_LSB              2
-#define POWER_REG_WLAN_SCALE_EN_MASK             0x00000004
-#define POWER_REG_WLAN_SCALE_EN_GET(x)           (((x) & POWER_REG_WLAN_SCALE_EN_MASK) >> POWER_REG_WLAN_SCALE_EN_LSB)
-#define POWER_REG_WLAN_SCALE_EN_SET(x)           (((x) << POWER_REG_WLAN_SCALE_EN_LSB) & POWER_REG_WLAN_SCALE_EN_MASK)
-#define POWER_REG_WLAN_PWD_EN_MSB                1
-#define POWER_REG_WLAN_PWD_EN_LSB                1
-#define POWER_REG_WLAN_PWD_EN_MASK               0x00000002
-#define POWER_REG_WLAN_PWD_EN_GET(x)             (((x) & POWER_REG_WLAN_PWD_EN_MASK) >> POWER_REG_WLAN_PWD_EN_LSB)
-#define POWER_REG_WLAN_PWD_EN_SET(x)             (((x) << POWER_REG_WLAN_PWD_EN_LSB) & POWER_REG_WLAN_PWD_EN_MASK)
-#define POWER_REG_POWER_EN_MSB                   0
-#define POWER_REG_POWER_EN_LSB                   0
-#define POWER_REG_POWER_EN_MASK                  0x00000001
-#define POWER_REG_POWER_EN_GET(x)                (((x) & POWER_REG_POWER_EN_MASK) >> POWER_REG_POWER_EN_LSB)
-#define POWER_REG_POWER_EN_SET(x)                (((x) << POWER_REG_POWER_EN_LSB) & POWER_REG_POWER_EN_MASK)
-
-#define CORE_CLK_CTRL_ADDRESS                    0x00000114
-#define CORE_CLK_CTRL_OFFSET                     0x00000114
-#define CORE_CLK_CTRL_DIV_MSB                    2
-#define CORE_CLK_CTRL_DIV_LSB                    0
-#define CORE_CLK_CTRL_DIV_MASK                   0x00000007
-#define CORE_CLK_CTRL_DIV_GET(x)                 (((x) & CORE_CLK_CTRL_DIV_MASK) >> CORE_CLK_CTRL_DIV_LSB)
-#define CORE_CLK_CTRL_DIV_SET(x)                 (((x) << CORE_CLK_CTRL_DIV_LSB) & CORE_CLK_CTRL_DIV_MASK)
-
-#define SDIO_SETUP_CIRCUIT_ADDRESS               0x00000120
-#define SDIO_SETUP_CIRCUIT_OFFSET                0x00000120
-#define SDIO_SETUP_CIRCUIT_VECTOR_MSB            7
-#define SDIO_SETUP_CIRCUIT_VECTOR_LSB            0
-#define SDIO_SETUP_CIRCUIT_VECTOR_MASK           0x000000ff
-#define SDIO_SETUP_CIRCUIT_VECTOR_GET(x)         (((x) & SDIO_SETUP_CIRCUIT_VECTOR_MASK) >> SDIO_SETUP_CIRCUIT_VECTOR_LSB)
-#define SDIO_SETUP_CIRCUIT_VECTOR_SET(x)         (((x) << SDIO_SETUP_CIRCUIT_VECTOR_LSB) & SDIO_SETUP_CIRCUIT_VECTOR_MASK)
-
-#define SDIO_SETUP_CONFIG_ADDRESS                0x00000140
-#define SDIO_SETUP_CONFIG_OFFSET                 0x00000140
-#define SDIO_SETUP_CONFIG_ENABLE_MSB             1
-#define SDIO_SETUP_CONFIG_ENABLE_LSB             1
-#define SDIO_SETUP_CONFIG_ENABLE_MASK            0x00000002
-#define SDIO_SETUP_CONFIG_ENABLE_GET(x)          (((x) & SDIO_SETUP_CONFIG_ENABLE_MASK) >> SDIO_SETUP_CONFIG_ENABLE_LSB)
-#define SDIO_SETUP_CONFIG_ENABLE_SET(x)          (((x) << SDIO_SETUP_CONFIG_ENABLE_LSB) & SDIO_SETUP_CONFIG_ENABLE_MASK)
-#define SDIO_SETUP_CONFIG_CLEAR_MSB              0
-#define SDIO_SETUP_CONFIG_CLEAR_LSB              0
-#define SDIO_SETUP_CONFIG_CLEAR_MASK             0x00000001
-#define SDIO_SETUP_CONFIG_CLEAR_GET(x)           (((x) & SDIO_SETUP_CONFIG_CLEAR_MASK) >> SDIO_SETUP_CONFIG_CLEAR_LSB)
-#define SDIO_SETUP_CONFIG_CLEAR_SET(x)           (((x) << SDIO_SETUP_CONFIG_CLEAR_LSB) & SDIO_SETUP_CONFIG_CLEAR_MASK)
-
-#define CPU_SETUP_CONFIG_ADDRESS                 0x00000144
-#define CPU_SETUP_CONFIG_OFFSET                  0x00000144
-#define CPU_SETUP_CONFIG_ENABLE_MSB              1
-#define CPU_SETUP_CONFIG_ENABLE_LSB              1
-#define CPU_SETUP_CONFIG_ENABLE_MASK             0x00000002
-#define CPU_SETUP_CONFIG_ENABLE_GET(x)           (((x) & CPU_SETUP_CONFIG_ENABLE_MASK) >> CPU_SETUP_CONFIG_ENABLE_LSB)
-#define CPU_SETUP_CONFIG_ENABLE_SET(x)           (((x) << CPU_SETUP_CONFIG_ENABLE_LSB) & CPU_SETUP_CONFIG_ENABLE_MASK)
-#define CPU_SETUP_CONFIG_CLEAR_MSB               0
-#define CPU_SETUP_CONFIG_CLEAR_LSB               0
-#define CPU_SETUP_CONFIG_CLEAR_MASK              0x00000001
-#define CPU_SETUP_CONFIG_CLEAR_GET(x)            (((x) & CPU_SETUP_CONFIG_CLEAR_MASK) >> CPU_SETUP_CONFIG_CLEAR_LSB)
-#define CPU_SETUP_CONFIG_CLEAR_SET(x)            (((x) << CPU_SETUP_CONFIG_CLEAR_LSB) & CPU_SETUP_CONFIG_CLEAR_MASK)
-
-#define CPU_SETUP_CIRCUIT_ADDRESS                0x00000160
-#define CPU_SETUP_CIRCUIT_OFFSET                 0x00000160
-#define CPU_SETUP_CIRCUIT_VECTOR_MSB             7
-#define CPU_SETUP_CIRCUIT_VECTOR_LSB             0
-#define CPU_SETUP_CIRCUIT_VECTOR_MASK            0x000000ff
-#define CPU_SETUP_CIRCUIT_VECTOR_GET(x)          (((x) & CPU_SETUP_CIRCUIT_VECTOR_MASK) >> CPU_SETUP_CIRCUIT_VECTOR_LSB)
-#define CPU_SETUP_CIRCUIT_VECTOR_SET(x)          (((x) << CPU_SETUP_CIRCUIT_VECTOR_LSB) & CPU_SETUP_CIRCUIT_VECTOR_MASK)
-
-#define BB_SETUP_CONFIG_ADDRESS                  0x00000180
-#define BB_SETUP_CONFIG_OFFSET                   0x00000180
-#define BB_SETUP_CONFIG_ENABLE_MSB               1
-#define BB_SETUP_CONFIG_ENABLE_LSB               1
-#define BB_SETUP_CONFIG_ENABLE_MASK              0x00000002
-#define BB_SETUP_CONFIG_ENABLE_GET(x)            (((x) & BB_SETUP_CONFIG_ENABLE_MASK) >> BB_SETUP_CONFIG_ENABLE_LSB)
-#define BB_SETUP_CONFIG_ENABLE_SET(x)            (((x) << BB_SETUP_CONFIG_ENABLE_LSB) & BB_SETUP_CONFIG_ENABLE_MASK)
-#define BB_SETUP_CONFIG_CLEAR_MSB                0
-#define BB_SETUP_CONFIG_CLEAR_LSB                0
-#define BB_SETUP_CONFIG_CLEAR_MASK               0x00000001
-#define BB_SETUP_CONFIG_CLEAR_GET(x)             (((x) & BB_SETUP_CONFIG_CLEAR_MASK) >> BB_SETUP_CONFIG_CLEAR_LSB)
-#define BB_SETUP_CONFIG_CLEAR_SET(x)             (((x) << BB_SETUP_CONFIG_CLEAR_LSB) & BB_SETUP_CONFIG_CLEAR_MASK)
-
-#define BB_SETUP_CIRCUIT_ADDRESS                 0x000001a0
-#define BB_SETUP_CIRCUIT_OFFSET                  0x000001a0
-#define BB_SETUP_CIRCUIT_VECTOR_MSB              7
-#define BB_SETUP_CIRCUIT_VECTOR_LSB              0
-#define BB_SETUP_CIRCUIT_VECTOR_MASK             0x000000ff
-#define BB_SETUP_CIRCUIT_VECTOR_GET(x)           (((x) & BB_SETUP_CIRCUIT_VECTOR_MASK) >> BB_SETUP_CIRCUIT_VECTOR_LSB)
-#define BB_SETUP_CIRCUIT_VECTOR_SET(x)           (((x) << BB_SETUP_CIRCUIT_VECTOR_LSB) & BB_SETUP_CIRCUIT_VECTOR_MASK)
-
-#define GPIO_WAKEUP_CONTROL_ADDRESS              0x000001c0
-#define GPIO_WAKEUP_CONTROL_OFFSET               0x000001c0
-#define GPIO_WAKEUP_CONTROL_ENABLE_MSB           0
-#define GPIO_WAKEUP_CONTROL_ENABLE_LSB           0
-#define GPIO_WAKEUP_CONTROL_ENABLE_MASK          0x00000001
-#define GPIO_WAKEUP_CONTROL_ENABLE_GET(x)        (((x) & GPIO_WAKEUP_CONTROL_ENABLE_MASK) >> GPIO_WAKEUP_CONTROL_ENABLE_LSB)
-#define GPIO_WAKEUP_CONTROL_ENABLE_SET(x)        (((x) << GPIO_WAKEUP_CONTROL_ENABLE_LSB) & GPIO_WAKEUP_CONTROL_ENABLE_MASK)
-
-
-#ifndef __ASSEMBLER__
-
-typedef struct rtc_reg_reg_s {
-  volatile unsigned int reset_control;
-  volatile unsigned int xtal_control;
-  volatile unsigned int tcxo_detect;
-  volatile unsigned int xtal_test;
-  volatile unsigned int quadrature;
-  volatile unsigned int pll_control;
-  volatile unsigned int pll_settle;
-  volatile unsigned int xtal_settle;
-  volatile unsigned int cpu_clock;
-  volatile unsigned int clock_out;
-  volatile unsigned int clock_control;
-  volatile unsigned int bias_override;
-  volatile unsigned int wdt_control;
-  volatile unsigned int wdt_status;
-  volatile unsigned int wdt;
-  volatile unsigned int wdt_count;
-  volatile unsigned int wdt_reset;
-  volatile unsigned int int_status;
-  volatile unsigned int lf_timer0;
-  volatile unsigned int lf_timer_count0;
-  volatile unsigned int lf_timer_control0;
-  volatile unsigned int lf_timer_status0;
-  volatile unsigned int lf_timer1;
-  volatile unsigned int lf_timer_count1;
-  volatile unsigned int lf_timer_control1;
-  volatile unsigned int lf_timer_status1;
-  volatile unsigned int lf_timer2;
-  volatile unsigned int lf_timer_count2;
-  volatile unsigned int lf_timer_control2;
-  volatile unsigned int lf_timer_status2;
-  volatile unsigned int lf_timer3;
-  volatile unsigned int lf_timer_count3;
-  volatile unsigned int lf_timer_control3;
-  volatile unsigned int lf_timer_status3;
-  volatile unsigned int hf_timer;
-  volatile unsigned int hf_timer_count;
-  volatile unsigned int hf_lf_count;
-  volatile unsigned int hf_timer_control;
-  volatile unsigned int hf_timer_status;
-  volatile unsigned int rtc_control;
-  volatile unsigned int rtc_time;
-  volatile unsigned int rtc_date;
-  volatile unsigned int rtc_set_time;
-  volatile unsigned int rtc_set_date;
-  volatile unsigned int rtc_set_alarm;
-  volatile unsigned int rtc_config;
-  volatile unsigned int rtc_alarm_status;
-  volatile unsigned int uart_wakeup;
-  volatile unsigned int reset_cause;
-  volatile unsigned int system_sleep;
-  volatile unsigned int sdio_wrapper;
-  volatile unsigned int mac_sleep_control;
-  volatile unsigned int keep_awake;
-  volatile unsigned int lpo_cal_time;
-  volatile unsigned int lpo_init_dividend_int;
-  volatile unsigned int lpo_init_dividend_fraction;
-  volatile unsigned int lpo_cal;
-  volatile unsigned int lpo_cal_test_control;
-  volatile unsigned int lpo_cal_test_status;
-  volatile unsigned int chip_id;
-  volatile unsigned int derived_rtc_clk;
-  volatile unsigned int mac_pcu_slp32_mode;
-  volatile unsigned int mac_pcu_slp32_wake;
-  volatile unsigned int mac_pcu_slp32_inc;
-  volatile unsigned int mac_pcu_slp_mib1;
-  volatile unsigned int mac_pcu_slp_mib2;
-  volatile unsigned int mac_pcu_slp_mib3;
-  volatile unsigned int mac_pcu_slp_beacon;
-  volatile unsigned int power_reg;
-  volatile unsigned int core_clk_ctrl;
-  unsigned char pad0[8]; /* pad to 0x120 */
-  volatile unsigned int sdio_setup_circuit[8];
-  volatile unsigned int sdio_setup_config;
-  volatile unsigned int cpu_setup_config;
-  unsigned char pad1[24]; /* pad to 0x160 */
-  volatile unsigned int cpu_setup_circuit[8];
-  volatile unsigned int bb_setup_config;
-  unsigned char pad2[28]; /* pad to 0x1a0 */
-  volatile unsigned int bb_setup_circuit[8];
-  volatile unsigned int gpio_wakeup_control;
-} rtc_reg_reg_t;
-
-#endif /* __ASSEMBLER__ */
-
-#endif /* _RTC_REG_H_ */
diff --git a/drivers/staging/ath6kl/include/common/AR6002/hw2.0/hw/si_reg.h b/drivers/staging/ath6kl/include/common/AR6002/hw2.0/hw/si_reg.h
deleted file mode 100644 (file)
index 16fb99c..0000000
+++ /dev/null
@@ -1,186 +0,0 @@
-#ifndef _SI_REG_REG_H_
-#define _SI_REG_REG_H_
-
-#define SI_CONFIG_ADDRESS                        0x00000000
-#define SI_CONFIG_OFFSET                         0x00000000
-#define SI_CONFIG_ERR_INT_MSB                    19
-#define SI_CONFIG_ERR_INT_LSB                    19
-#define SI_CONFIG_ERR_INT_MASK                   0x00080000
-#define SI_CONFIG_ERR_INT_GET(x)                 (((x) & SI_CONFIG_ERR_INT_MASK) >> SI_CONFIG_ERR_INT_LSB)
-#define SI_CONFIG_ERR_INT_SET(x)                 (((x) << SI_CONFIG_ERR_INT_LSB) & SI_CONFIG_ERR_INT_MASK)
-#define SI_CONFIG_BIDIR_OD_DATA_MSB              18
-#define SI_CONFIG_BIDIR_OD_DATA_LSB              18
-#define SI_CONFIG_BIDIR_OD_DATA_MASK             0x00040000
-#define SI_CONFIG_BIDIR_OD_DATA_GET(x)           (((x) & SI_CONFIG_BIDIR_OD_DATA_MASK) >> SI_CONFIG_BIDIR_OD_DATA_LSB)
-#define SI_CONFIG_BIDIR_OD_DATA_SET(x)           (((x) << SI_CONFIG_BIDIR_OD_DATA_LSB) & SI_CONFIG_BIDIR_OD_DATA_MASK)
-#define SI_CONFIG_I2C_MSB                        16
-#define SI_CONFIG_I2C_LSB                        16
-#define SI_CONFIG_I2C_MASK                       0x00010000
-#define SI_CONFIG_I2C_GET(x)                     (((x) & SI_CONFIG_I2C_MASK) >> SI_CONFIG_I2C_LSB)
-#define SI_CONFIG_I2C_SET(x)                     (((x) << SI_CONFIG_I2C_LSB) & SI_CONFIG_I2C_MASK)
-#define SI_CONFIG_POS_SAMPLE_MSB                 7
-#define SI_CONFIG_POS_SAMPLE_LSB                 7
-#define SI_CONFIG_POS_SAMPLE_MASK                0x00000080
-#define SI_CONFIG_POS_SAMPLE_GET(x)              (((x) & SI_CONFIG_POS_SAMPLE_MASK) >> SI_CONFIG_POS_SAMPLE_LSB)
-#define SI_CONFIG_POS_SAMPLE_SET(x)              (((x) << SI_CONFIG_POS_SAMPLE_LSB) & SI_CONFIG_POS_SAMPLE_MASK)
-#define SI_CONFIG_POS_DRIVE_MSB                  6
-#define SI_CONFIG_POS_DRIVE_LSB                  6
-#define SI_CONFIG_POS_DRIVE_MASK                 0x00000040
-#define SI_CONFIG_POS_DRIVE_GET(x)               (((x) & SI_CONFIG_POS_DRIVE_MASK) >> SI_CONFIG_POS_DRIVE_LSB)
-#define SI_CONFIG_POS_DRIVE_SET(x)               (((x) << SI_CONFIG_POS_DRIVE_LSB) & SI_CONFIG_POS_DRIVE_MASK)
-#define SI_CONFIG_INACTIVE_DATA_MSB              5
-#define SI_CONFIG_INACTIVE_DATA_LSB              5
-#define SI_CONFIG_INACTIVE_DATA_MASK             0x00000020
-#define SI_CONFIG_INACTIVE_DATA_GET(x)           (((x) & SI_CONFIG_INACTIVE_DATA_MASK) >> SI_CONFIG_INACTIVE_DATA_LSB)
-#define SI_CONFIG_INACTIVE_DATA_SET(x)           (((x) << SI_CONFIG_INACTIVE_DATA_LSB) & SI_CONFIG_INACTIVE_DATA_MASK)
-#define SI_CONFIG_INACTIVE_CLK_MSB               4
-#define SI_CONFIG_INACTIVE_CLK_LSB               4
-#define SI_CONFIG_INACTIVE_CLK_MASK              0x00000010
-#define SI_CONFIG_INACTIVE_CLK_GET(x)            (((x) & SI_CONFIG_INACTIVE_CLK_MASK) >> SI_CONFIG_INACTIVE_CLK_LSB)
-#define SI_CONFIG_INACTIVE_CLK_SET(x)            (((x) << SI_CONFIG_INACTIVE_CLK_LSB) & SI_CONFIG_INACTIVE_CLK_MASK)
-#define SI_CONFIG_DIVIDER_MSB                    3
-#define SI_CONFIG_DIVIDER_LSB                    0
-#define SI_CONFIG_DIVIDER_MASK                   0x0000000f
-#define SI_CONFIG_DIVIDER_GET(x)                 (((x) & SI_CONFIG_DIVIDER_MASK) >> SI_CONFIG_DIVIDER_LSB)
-#define SI_CONFIG_DIVIDER_SET(x)                 (((x) << SI_CONFIG_DIVIDER_LSB) & SI_CONFIG_DIVIDER_MASK)
-
-#define SI_CS_ADDRESS                            0x00000004
-#define SI_CS_OFFSET                             0x00000004
-#define SI_CS_BIT_CNT_IN_LAST_BYTE_MSB           13
-#define SI_CS_BIT_CNT_IN_LAST_BYTE_LSB           11
-#define SI_CS_BIT_CNT_IN_LAST_BYTE_MASK          0x00003800
-#define SI_CS_BIT_CNT_IN_LAST_BYTE_GET(x)        (((x) & SI_CS_BIT_CNT_IN_LAST_BYTE_MASK) >> SI_CS_BIT_CNT_IN_LAST_BYTE_LSB)
-#define SI_CS_BIT_CNT_IN_LAST_BYTE_SET(x)        (((x) << SI_CS_BIT_CNT_IN_LAST_BYTE_LSB) & SI_CS_BIT_CNT_IN_LAST_BYTE_MASK)
-#define SI_CS_DONE_ERR_MSB                       10
-#define SI_CS_DONE_ERR_LSB                       10
-#define SI_CS_DONE_ERR_MASK                      0x00000400
-#define SI_CS_DONE_ERR_GET(x)                    (((x) & SI_CS_DONE_ERR_MASK) >> SI_CS_DONE_ERR_LSB)
-#define SI_CS_DONE_ERR_SET(x)                    (((x) << SI_CS_DONE_ERR_LSB) & SI_CS_DONE_ERR_MASK)
-#define SI_CS_DONE_INT_MSB                       9
-#define SI_CS_DONE_INT_LSB                       9
-#define SI_CS_DONE_INT_MASK                      0x00000200
-#define SI_CS_DONE_INT_GET(x)                    (((x) & SI_CS_DONE_INT_MASK) >> SI_CS_DONE_INT_LSB)
-#define SI_CS_DONE_INT_SET(x)                    (((x) << SI_CS_DONE_INT_LSB) & SI_CS_DONE_INT_MASK)
-#define SI_CS_START_MSB                          8
-#define SI_CS_START_LSB                          8
-#define SI_CS_START_MASK                         0x00000100
-#define SI_CS_START_GET(x)                       (((x) & SI_CS_START_MASK) >> SI_CS_START_LSB)
-#define SI_CS_START_SET(x)                       (((x) << SI_CS_START_LSB) & SI_CS_START_MASK)
-#define SI_CS_RX_CNT_MSB                         7
-#define SI_CS_RX_CNT_LSB                         4
-#define SI_CS_RX_CNT_MASK                        0x000000f0
-#define SI_CS_RX_CNT_GET(x)                      (((x) & SI_CS_RX_CNT_MASK) >> SI_CS_RX_CNT_LSB)
-#define SI_CS_RX_CNT_SET(x)                      (((x) << SI_CS_RX_CNT_LSB) & SI_CS_RX_CNT_MASK)
-#define SI_CS_TX_CNT_MSB                         3
-#define SI_CS_TX_CNT_LSB                         0
-#define SI_CS_TX_CNT_MASK                        0x0000000f
-#define SI_CS_TX_CNT_GET(x)                      (((x) & SI_CS_TX_CNT_MASK) >> SI_CS_TX_CNT_LSB)
-#define SI_CS_TX_CNT_SET(x)                      (((x) << SI_CS_TX_CNT_LSB) & SI_CS_TX_CNT_MASK)
-
-#define SI_TX_DATA0_ADDRESS                      0x00000008
-#define SI_TX_DATA0_OFFSET                       0x00000008
-#define SI_TX_DATA0_DATA3_MSB                    31
-#define SI_TX_DATA0_DATA3_LSB                    24
-#define SI_TX_DATA0_DATA3_MASK                   0xff000000
-#define SI_TX_DATA0_DATA3_GET(x)                 (((x) & SI_TX_DATA0_DATA3_MASK) >> SI_TX_DATA0_DATA3_LSB)
-#define SI_TX_DATA0_DATA3_SET(x)                 (((x) << SI_TX_DATA0_DATA3_LSB) & SI_TX_DATA0_DATA3_MASK)
-#define SI_TX_DATA0_DATA2_MSB                    23
-#define SI_TX_DATA0_DATA2_LSB                    16
-#define SI_TX_DATA0_DATA2_MASK                   0x00ff0000
-#define SI_TX_DATA0_DATA2_GET(x)                 (((x) & SI_TX_DATA0_DATA2_MASK) >> SI_TX_DATA0_DATA2_LSB)
-#define SI_TX_DATA0_DATA2_SET(x)                 (((x) << SI_TX_DATA0_DATA2_LSB) & SI_TX_DATA0_DATA2_MASK)
-#define SI_TX_DATA0_DATA1_MSB                    15
-#define SI_TX_DATA0_DATA1_LSB                    8
-#define SI_TX_DATA0_DATA1_MASK                   0x0000ff00
-#define SI_TX_DATA0_DATA1_GET(x)                 (((x) & SI_TX_DATA0_DATA1_MASK) >> SI_TX_DATA0_DATA1_LSB)
-#define SI_TX_DATA0_DATA1_SET(x)                 (((x) << SI_TX_DATA0_DATA1_LSB) & SI_TX_DATA0_DATA1_MASK)
-#define SI_TX_DATA0_DATA0_MSB                    7
-#define SI_TX_DATA0_DATA0_LSB                    0
-#define SI_TX_DATA0_DATA0_MASK                   0x000000ff
-#define SI_TX_DATA0_DATA0_GET(x)                 (((x) & SI_TX_DATA0_DATA0_MASK) >> SI_TX_DATA0_DATA0_LSB)
-#define SI_TX_DATA0_DATA0_SET(x)                 (((x) << SI_TX_DATA0_DATA0_LSB) & SI_TX_DATA0_DATA0_MASK)
-
-#define SI_TX_DATA1_ADDRESS                      0x0000000c
-#define SI_TX_DATA1_OFFSET                       0x0000000c
-#define SI_TX_DATA1_DATA7_MSB                    31
-#define SI_TX_DATA1_DATA7_LSB                    24
-#define SI_TX_DATA1_DATA7_MASK                   0xff000000
-#define SI_TX_DATA1_DATA7_GET(x)                 (((x) & SI_TX_DATA1_DATA7_MASK) >> SI_TX_DATA1_DATA7_LSB)
-#define SI_TX_DATA1_DATA7_SET(x)                 (((x) << SI_TX_DATA1_DATA7_LSB) & SI_TX_DATA1_DATA7_MASK)
-#define SI_TX_DATA1_DATA6_MSB                    23
-#define SI_TX_DATA1_DATA6_LSB                    16
-#define SI_TX_DATA1_DATA6_MASK                   0x00ff0000
-#define SI_TX_DATA1_DATA6_GET(x)                 (((x) & SI_TX_DATA1_DATA6_MASK) >> SI_TX_DATA1_DATA6_LSB)
-#define SI_TX_DATA1_DATA6_SET(x)                 (((x) << SI_TX_DATA1_DATA6_LSB) & SI_TX_DATA1_DATA6_MASK)
-#define SI_TX_DATA1_DATA5_MSB                    15
-#define SI_TX_DATA1_DATA5_LSB                    8
-#define SI_TX_DATA1_DATA5_MASK                   0x0000ff00
-#define SI_TX_DATA1_DATA5_GET(x)                 (((x) & SI_TX_DATA1_DATA5_MASK) >> SI_TX_DATA1_DATA5_LSB)
-#define SI_TX_DATA1_DATA5_SET(x)                 (((x) << SI_TX_DATA1_DATA5_LSB) & SI_TX_DATA1_DATA5_MASK)
-#define SI_TX_DATA1_DATA4_MSB                    7
-#define SI_TX_DATA1_DATA4_LSB                    0
-#define SI_TX_DATA1_DATA4_MASK                   0x000000ff
-#define SI_TX_DATA1_DATA4_GET(x)                 (((x) & SI_TX_DATA1_DATA4_MASK) >> SI_TX_DATA1_DATA4_LSB)
-#define SI_TX_DATA1_DATA4_SET(x)                 (((x) << SI_TX_DATA1_DATA4_LSB) & SI_TX_DATA1_DATA4_MASK)
-
-#define SI_RX_DATA0_ADDRESS                      0x00000010
-#define SI_RX_DATA0_OFFSET                       0x00000010
-#define SI_RX_DATA0_DATA3_MSB                    31
-#define SI_RX_DATA0_DATA3_LSB                    24
-#define SI_RX_DATA0_DATA3_MASK                   0xff000000
-#define SI_RX_DATA0_DATA3_GET(x)                 (((x) & SI_RX_DATA0_DATA3_MASK) >> SI_RX_DATA0_DATA3_LSB)
-#define SI_RX_DATA0_DATA3_SET(x)                 (((x) << SI_RX_DATA0_DATA3_LSB) & SI_RX_DATA0_DATA3_MASK)
-#define SI_RX_DATA0_DATA2_MSB                    23
-#define SI_RX_DATA0_DATA2_LSB                    16
-#define SI_RX_DATA0_DATA2_MASK                   0x00ff0000
-#define SI_RX_DATA0_DATA2_GET(x)                 (((x) & SI_RX_DATA0_DATA2_MASK) >> SI_RX_DATA0_DATA2_LSB)
-#define SI_RX_DATA0_DATA2_SET(x)                 (((x) << SI_RX_DATA0_DATA2_LSB) & SI_RX_DATA0_DATA2_MASK)
-#define SI_RX_DATA0_DATA1_MSB                    15
-#define SI_RX_DATA0_DATA1_LSB                    8
-#define SI_RX_DATA0_DATA1_MASK                   0x0000ff00
-#define SI_RX_DATA0_DATA1_GET(x)                 (((x) & SI_RX_DATA0_DATA1_MASK) >> SI_RX_DATA0_DATA1_LSB)
-#define SI_RX_DATA0_DATA1_SET(x)                 (((x) << SI_RX_DATA0_DATA1_LSB) & SI_RX_DATA0_DATA1_MASK)
-#define SI_RX_DATA0_DATA0_MSB                    7
-#define SI_RX_DATA0_DATA0_LSB                    0
-#define SI_RX_DATA0_DATA0_MASK                   0x000000ff
-#define SI_RX_DATA0_DATA0_GET(x)                 (((x) & SI_RX_DATA0_DATA0_MASK) >> SI_RX_DATA0_DATA0_LSB)
-#define SI_RX_DATA0_DATA0_SET(x)                 (((x) << SI_RX_DATA0_DATA0_LSB) & SI_RX_DATA0_DATA0_MASK)
-
-#define SI_RX_DATA1_ADDRESS                      0x00000014
-#define SI_RX_DATA1_OFFSET                       0x00000014
-#define SI_RX_DATA1_DATA7_MSB                    31
-#define SI_RX_DATA1_DATA7_LSB                    24
-#define SI_RX_DATA1_DATA7_MASK                   0xff000000
-#define SI_RX_DATA1_DATA7_GET(x)                 (((x) & SI_RX_DATA1_DATA7_MASK) >> SI_RX_DATA1_DATA7_LSB)
-#define SI_RX_DATA1_DATA7_SET(x)                 (((x) << SI_RX_DATA1_DATA7_LSB) & SI_RX_DATA1_DATA7_MASK)
-#define SI_RX_DATA1_DATA6_MSB                    23
-#define SI_RX_DATA1_DATA6_LSB                    16
-#define SI_RX_DATA1_DATA6_MASK                   0x00ff0000
-#define SI_RX_DATA1_DATA6_GET(x)                 (((x) & SI_RX_DATA1_DATA6_MASK) >> SI_RX_DATA1_DATA6_LSB)
-#define SI_RX_DATA1_DATA6_SET(x)                 (((x) << SI_RX_DATA1_DATA6_LSB) & SI_RX_DATA1_DATA6_MASK)
-#define SI_RX_DATA1_DATA5_MSB                    15
-#define SI_RX_DATA1_DATA5_LSB                    8
-#define SI_RX_DATA1_DATA5_MASK                   0x0000ff00
-#define SI_RX_DATA1_DATA5_GET(x)                 (((x) & SI_RX_DATA1_DATA5_MASK) >> SI_RX_DATA1_DATA5_LSB)
-#define SI_RX_DATA1_DATA5_SET(x)                 (((x) << SI_RX_DATA1_DATA5_LSB) & SI_RX_DATA1_DATA5_MASK)
-#define SI_RX_DATA1_DATA4_MSB                    7
-#define SI_RX_DATA1_DATA4_LSB                    0
-#define SI_RX_DATA1_DATA4_MASK                   0x000000ff
-#define SI_RX_DATA1_DATA4_GET(x)                 (((x) & SI_RX_DATA1_DATA4_MASK) >> SI_RX_DATA1_DATA4_LSB)
-#define SI_RX_DATA1_DATA4_SET(x)                 (((x) << SI_RX_DATA1_DATA4_LSB) & SI_RX_DATA1_DATA4_MASK)
-
-
-#ifndef __ASSEMBLER__
-
-typedef struct si_reg_reg_s {
-  volatile unsigned int si_config;
-  volatile unsigned int si_cs;
-  volatile unsigned int si_tx_data0;
-  volatile unsigned int si_tx_data1;
-  volatile unsigned int si_rx_data0;
-  volatile unsigned int si_rx_data1;
-} si_reg_reg_t;
-
-#endif /* __ASSEMBLER__ */
-
-#endif /* _SI_REG_H_ */
diff --git a/drivers/staging/ath6kl/include/common/AR6002/hw2.0/hw/uart_reg.h b/drivers/staging/ath6kl/include/common/AR6002/hw2.0/hw/uart_reg.h
deleted file mode 100644 (file)
index 5db321b..0000000
+++ /dev/null
@@ -1,327 +0,0 @@
-#ifndef _UART_REG_REG_H_
-#define _UART_REG_REG_H_
-
-#define RBR_ADDRESS                              0x00000000
-#define RBR_OFFSET                               0x00000000
-#define RBR_RBR_MSB                              7
-#define RBR_RBR_LSB                              0
-#define RBR_RBR_MASK                             0x000000ff
-#define RBR_RBR_GET(x)                           (((x) & RBR_RBR_MASK) >> RBR_RBR_LSB)
-#define RBR_RBR_SET(x)                           (((x) << RBR_RBR_LSB) & RBR_RBR_MASK)
-
-#define THR_ADDRESS                              0x00000000
-#define THR_OFFSET                               0x00000000
-#define THR_THR_MSB                              7
-#define THR_THR_LSB                              0
-#define THR_THR_MASK                             0x000000ff
-#define THR_THR_GET(x)                           (((x) & THR_THR_MASK) >> THR_THR_LSB)
-#define THR_THR_SET(x)                           (((x) << THR_THR_LSB) & THR_THR_MASK)
-
-#define DLL_ADDRESS                              0x00000000
-#define DLL_OFFSET                               0x00000000
-#define DLL_DLL_MSB                              7
-#define DLL_DLL_LSB                              0
-#define DLL_DLL_MASK                             0x000000ff
-#define DLL_DLL_GET(x)                           (((x) & DLL_DLL_MASK) >> DLL_DLL_LSB)
-#define DLL_DLL_SET(x)                           (((x) << DLL_DLL_LSB) & DLL_DLL_MASK)
-
-#define DLH_ADDRESS                              0x00000004
-#define DLH_OFFSET                               0x00000004
-#define DLH_DLH_MSB                              7
-#define DLH_DLH_LSB                              0
-#define DLH_DLH_MASK                             0x000000ff
-#define DLH_DLH_GET(x)                           (((x) & DLH_DLH_MASK) >> DLH_DLH_LSB)
-#define DLH_DLH_SET(x)                           (((x) << DLH_DLH_LSB) & DLH_DLH_MASK)
-
-#define IER_ADDRESS                              0x00000004
-#define IER_OFFSET                               0x00000004
-#define IER_EDDSI_MSB                            3
-#define IER_EDDSI_LSB                            3
-#define IER_EDDSI_MASK                           0x00000008
-#define IER_EDDSI_GET(x)                         (((x) & IER_EDDSI_MASK) >> IER_EDDSI_LSB)
-#define IER_EDDSI_SET(x)                         (((x) << IER_EDDSI_LSB) & IER_EDDSI_MASK)
-#define IER_ELSI_MSB                             2
-#define IER_ELSI_LSB                             2
-#define IER_ELSI_MASK                            0x00000004
-#define IER_ELSI_GET(x)                          (((x) & IER_ELSI_MASK) >> IER_ELSI_LSB)
-#define IER_ELSI_SET(x)                          (((x) << IER_ELSI_LSB) & IER_ELSI_MASK)
-#define IER_ETBEI_MSB                            1
-#define IER_ETBEI_LSB                            1
-#define IER_ETBEI_MASK                           0x00000002
-#define IER_ETBEI_GET(x)                         (((x) & IER_ETBEI_MASK) >> IER_ETBEI_LSB)
-#define IER_ETBEI_SET(x)                         (((x) << IER_ETBEI_LSB) & IER_ETBEI_MASK)
-#define IER_ERBFI_MSB                            0
-#define IER_ERBFI_LSB                            0
-#define IER_ERBFI_MASK                           0x00000001
-#define IER_ERBFI_GET(x)                         (((x) & IER_ERBFI_MASK) >> IER_ERBFI_LSB)
-#define IER_ERBFI_SET(x)                         (((x) << IER_ERBFI_LSB) & IER_ERBFI_MASK)
-
-#define IIR_ADDRESS                              0x00000008
-#define IIR_OFFSET                               0x00000008
-#define IIR_FIFO_STATUS_MSB                      7
-#define IIR_FIFO_STATUS_LSB                      6
-#define IIR_FIFO_STATUS_MASK                     0x000000c0
-#define IIR_FIFO_STATUS_GET(x)                   (((x) & IIR_FIFO_STATUS_MASK) >> IIR_FIFO_STATUS_LSB)
-#define IIR_FIFO_STATUS_SET(x)                   (((x) << IIR_FIFO_STATUS_LSB) & IIR_FIFO_STATUS_MASK)
-#define IIR_IID_MSB                              3
-#define IIR_IID_LSB                              0
-#define IIR_IID_MASK                             0x0000000f
-#define IIR_IID_GET(x)                           (((x) & IIR_IID_MASK) >> IIR_IID_LSB)
-#define IIR_IID_SET(x)                           (((x) << IIR_IID_LSB) & IIR_IID_MASK)
-
-#define FCR_ADDRESS                              0x00000008
-#define FCR_OFFSET                               0x00000008
-#define FCR_RCVR_TRIG_MSB                        7
-#define FCR_RCVR_TRIG_LSB                        6
-#define FCR_RCVR_TRIG_MASK                       0x000000c0
-#define FCR_RCVR_TRIG_GET(x)                     (((x) & FCR_RCVR_TRIG_MASK) >> FCR_RCVR_TRIG_LSB)
-#define FCR_RCVR_TRIG_SET(x)                     (((x) << FCR_RCVR_TRIG_LSB) & FCR_RCVR_TRIG_MASK)
-#define FCR_DMA_MODE_MSB                         3
-#define FCR_DMA_MODE_LSB                         3
-#define FCR_DMA_MODE_MASK                        0x00000008
-#define FCR_DMA_MODE_GET(x)                      (((x) & FCR_DMA_MODE_MASK) >> FCR_DMA_MODE_LSB)
-#define FCR_DMA_MODE_SET(x)                      (((x) << FCR_DMA_MODE_LSB) & FCR_DMA_MODE_MASK)
-#define FCR_XMIT_FIFO_RST_MSB                    2
-#define FCR_XMIT_FIFO_RST_LSB                    2
-#define FCR_XMIT_FIFO_RST_MASK                   0x00000004
-#define FCR_XMIT_FIFO_RST_GET(x)                 (((x) & FCR_XMIT_FIFO_RST_MASK) >> FCR_XMIT_FIFO_RST_LSB)
-#define FCR_XMIT_FIFO_RST_SET(x)                 (((x) << FCR_XMIT_FIFO_RST_LSB) & FCR_XMIT_FIFO_RST_MASK)
-#define FCR_RCVR_FIFO_RST_MSB                    1
-#define FCR_RCVR_FIFO_RST_LSB                    1
-#define FCR_RCVR_FIFO_RST_MASK                   0x00000002
-#define FCR_RCVR_FIFO_RST_GET(x)                 (((x) & FCR_RCVR_FIFO_RST_MASK) >> FCR_RCVR_FIFO_RST_LSB)
-#define FCR_RCVR_FIFO_RST_SET(x)                 (((x) << FCR_RCVR_FIFO_RST_LSB) & FCR_RCVR_FIFO_RST_MASK)
-#define FCR_FIFO_EN_MSB                          0
-#define FCR_FIFO_EN_LSB                          0
-#define FCR_FIFO_EN_MASK                         0x00000001
-#define FCR_FIFO_EN_GET(x)                       (((x) & FCR_FIFO_EN_MASK) >> FCR_FIFO_EN_LSB)
-#define FCR_FIFO_EN_SET(x)                       (((x) << FCR_FIFO_EN_LSB) & FCR_FIFO_EN_MASK)
-
-#define LCR_ADDRESS                              0x0000000c
-#define LCR_OFFSET                               0x0000000c
-#define LCR_DLAB_MSB                             7
-#define LCR_DLAB_LSB                             7
-#define LCR_DLAB_MASK                            0x00000080
-#define LCR_DLAB_GET(x)                          (((x) & LCR_DLAB_MASK) >> LCR_DLAB_LSB)
-#define LCR_DLAB_SET(x)                          (((x) << LCR_DLAB_LSB) & LCR_DLAB_MASK)
-#define LCR_BREAK_MSB                            6
-#define LCR_BREAK_LSB                            6
-#define LCR_BREAK_MASK                           0x00000040
-#define LCR_BREAK_GET(x)                         (((x) & LCR_BREAK_MASK) >> LCR_BREAK_LSB)
-#define LCR_BREAK_SET(x)                         (((x) << LCR_BREAK_LSB) & LCR_BREAK_MASK)
-#define LCR_EPS_MSB                              4
-#define LCR_EPS_LSB                              4
-#define LCR_EPS_MASK                             0x00000010
-#define LCR_EPS_GET(x)                           (((x) & LCR_EPS_MASK) >> LCR_EPS_LSB)
-#define LCR_EPS_SET(x)                           (((x) << LCR_EPS_LSB) & LCR_EPS_MASK)
-#define LCR_PEN_MSB                              3
-#define LCR_PEN_LSB                              3
-#define LCR_PEN_MASK                             0x00000008
-#define LCR_PEN_GET(x)                           (((x) & LCR_PEN_MASK) >> LCR_PEN_LSB)
-#define LCR_PEN_SET(x)                           (((x) << LCR_PEN_LSB) & LCR_PEN_MASK)
-#define LCR_STOP_MSB                             2
-#define LCR_STOP_LSB                             2
-#define LCR_STOP_MASK                            0x00000004
-#define LCR_STOP_GET(x)                          (((x) & LCR_STOP_MASK) >> LCR_STOP_LSB)
-#define LCR_STOP_SET(x)                          (((x) << LCR_STOP_LSB) & LCR_STOP_MASK)
-#define LCR_CLS_MSB                              1
-#define LCR_CLS_LSB                              0
-#define LCR_CLS_MASK                             0x00000003
-#define LCR_CLS_GET(x)                           (((x) & LCR_CLS_MASK) >> LCR_CLS_LSB)
-#define LCR_CLS_SET(x)                           (((x) << LCR_CLS_LSB) & LCR_CLS_MASK)
-
-#define MCR_ADDRESS                              0x00000010
-#define MCR_OFFSET                               0x00000010
-#define MCR_LOOPBACK_MSB                         5
-#define MCR_LOOPBACK_LSB                         5
-#define MCR_LOOPBACK_MASK                        0x00000020
-#define MCR_LOOPBACK_GET(x)                      (((x) & MCR_LOOPBACK_MASK) >> MCR_LOOPBACK_LSB)
-#define MCR_LOOPBACK_SET(x)                      (((x) << MCR_LOOPBACK_LSB) & MCR_LOOPBACK_MASK)
-#define MCR_OUT2_MSB                             3
-#define MCR_OUT2_LSB                             3
-#define MCR_OUT2_MASK                            0x00000008
-#define MCR_OUT2_GET(x)                          (((x) & MCR_OUT2_MASK) >> MCR_OUT2_LSB)
-#define MCR_OUT2_SET(x)                          (((x) << MCR_OUT2_LSB) & MCR_OUT2_MASK)
-#define MCR_OUT1_MSB                             2
-#define MCR_OUT1_LSB                             2
-#define MCR_OUT1_MASK                            0x00000004
-#define MCR_OUT1_GET(x)                          (((x) & MCR_OUT1_MASK) >> MCR_OUT1_LSB)
-#define MCR_OUT1_SET(x)                          (((x) << MCR_OUT1_LSB) & MCR_OUT1_MASK)
-#define MCR_RTS_MSB                              1
-#define MCR_RTS_LSB                              1
-#define MCR_RTS_MASK                             0x00000002
-#define MCR_RTS_GET(x)                           (((x) & MCR_RTS_MASK) >> MCR_RTS_LSB)
-#define MCR_RTS_SET(x)                           (((x) << MCR_RTS_LSB) & MCR_RTS_MASK)
-#define MCR_DTR_MSB                              0
-#define MCR_DTR_LSB                              0
-#define MCR_DTR_MASK                             0x00000001
-#define MCR_DTR_GET(x)                           (((x) & MCR_DTR_MASK) >> MCR_DTR_LSB)
-#define MCR_DTR_SET(x)                           (((x) << MCR_DTR_LSB) & MCR_DTR_MASK)
-
-#define LSR_ADDRESS                              0x00000014
-#define LSR_OFFSET                               0x00000014
-#define LSR_FERR_MSB                             7
-#define LSR_FERR_LSB                             7
-#define LSR_FERR_MASK                            0x00000080
-#define LSR_FERR_GET(x)                          (((x) & LSR_FERR_MASK) >> LSR_FERR_LSB)
-#define LSR_FERR_SET(x)                          (((x) << LSR_FERR_LSB) & LSR_FERR_MASK)
-#define LSR_TEMT_MSB                             6
-#define LSR_TEMT_LSB                             6
-#define LSR_TEMT_MASK                            0x00000040
-#define LSR_TEMT_GET(x)                          (((x) & LSR_TEMT_MASK) >> LSR_TEMT_LSB)
-#define LSR_TEMT_SET(x)                          (((x) << LSR_TEMT_LSB) & LSR_TEMT_MASK)
-#define LSR_THRE_MSB                             5
-#define LSR_THRE_LSB                             5
-#define LSR_THRE_MASK                            0x00000020
-#define LSR_THRE_GET(x)                          (((x) & LSR_THRE_MASK) >> LSR_THRE_LSB)
-#define LSR_THRE_SET(x)                          (((x) << LSR_THRE_LSB) & LSR_THRE_MASK)
-#define LSR_BI_MSB                               4
-#define LSR_BI_LSB                               4
-#define LSR_BI_MASK                              0x00000010
-#define LSR_BI_GET(x)                            (((x) & LSR_BI_MASK) >> LSR_BI_LSB)
-#define LSR_BI_SET(x)                            (((x) << LSR_BI_LSB) & LSR_BI_MASK)
-#define LSR_FE_MSB                               3
-#define LSR_FE_LSB                               3
-#define LSR_FE_MASK                              0x00000008
-#define LSR_FE_GET(x)                            (((x) & LSR_FE_MASK) >> LSR_FE_LSB)
-#define LSR_FE_SET(x)                            (((x) << LSR_FE_LSB) & LSR_FE_MASK)
-#define LSR_PE_MSB                               2
-#define LSR_PE_LSB                               2
-#define LSR_PE_MASK                              0x00000004
-#define LSR_PE_GET(x)                            (((x) & LSR_PE_MASK) >> LSR_PE_LSB)
-#define LSR_PE_SET(x)                            (((x) << LSR_PE_LSB) & LSR_PE_MASK)
-#define LSR_OE_MSB                               1
-#define LSR_OE_LSB                               1
-#define LSR_OE_MASK                              0x00000002
-#define LSR_OE_GET(x)                            (((x) & LSR_OE_MASK) >> LSR_OE_LSB)
-#define LSR_OE_SET(x)                            (((x) << LSR_OE_LSB) & LSR_OE_MASK)
-#define LSR_DR_MSB                               0
-#define LSR_DR_LSB                               0
-#define LSR_DR_MASK                              0x00000001
-#define LSR_DR_GET(x)                            (((x) & LSR_DR_MASK) >> LSR_DR_LSB)
-#define LSR_DR_SET(x)                            (((x) << LSR_DR_LSB) & LSR_DR_MASK)
-
-#define MSR_ADDRESS                              0x00000018
-#define MSR_OFFSET                               0x00000018
-#define MSR_DCD_MSB                              7
-#define MSR_DCD_LSB                              7
-#define MSR_DCD_MASK                             0x00000080
-#define MSR_DCD_GET(x)                           (((x) & MSR_DCD_MASK) >> MSR_DCD_LSB)
-#define MSR_DCD_SET(x)                           (((x) << MSR_DCD_LSB) & MSR_DCD_MASK)
-#define MSR_RI_MSB                               6
-#define MSR_RI_LSB                               6
-#define MSR_RI_MASK                              0x00000040
-#define MSR_RI_GET(x)                            (((x) & MSR_RI_MASK) >> MSR_RI_LSB)
-#define MSR_RI_SET(x)                            (((x) << MSR_RI_LSB) & MSR_RI_MASK)
-#define MSR_DSR_MSB                              5
-#define MSR_DSR_LSB                              5
-#define MSR_DSR_MASK                             0x00000020
-#define MSR_DSR_GET(x)                           (((x) & MSR_DSR_MASK) >> MSR_DSR_LSB)
-#define MSR_DSR_SET(x)                           (((x) << MSR_DSR_LSB) & MSR_DSR_MASK)
-#define MSR_CTS_MSB                              4
-#define MSR_CTS_LSB                              4
-#define MSR_CTS_MASK                             0x00000010
-#define MSR_CTS_GET(x)                           (((x) & MSR_CTS_MASK) >> MSR_CTS_LSB)
-#define MSR_CTS_SET(x)                           (((x) << MSR_CTS_LSB) & MSR_CTS_MASK)
-#define MSR_DDCD_MSB                             3
-#define MSR_DDCD_LSB                             3
-#define MSR_DDCD_MASK                            0x00000008
-#define MSR_DDCD_GET(x)                          (((x) & MSR_DDCD_MASK) >> MSR_DDCD_LSB)
-#define MSR_DDCD_SET(x)                          (((x) << MSR_DDCD_LSB) & MSR_DDCD_MASK)
-#define MSR_TERI_MSB                             2
-#define MSR_TERI_LSB                             2
-#define MSR_TERI_MASK                            0x00000004
-#define MSR_TERI_GET(x)                          (((x) & MSR_TERI_MASK) >> MSR_TERI_LSB)
-#define MSR_TERI_SET(x)                          (((x) << MSR_TERI_LSB) & MSR_TERI_MASK)
-#define MSR_DDSR_MSB                             1
-#define MSR_DDSR_LSB                             1
-#define MSR_DDSR_MASK                            0x00000002
-#define MSR_DDSR_GET(x)                          (((x) & MSR_DDSR_MASK) >> MSR_DDSR_LSB)
-#define MSR_DDSR_SET(x)                          (((x) << MSR_DDSR_LSB) & MSR_DDSR_MASK)
-#define MSR_DCTS_MSB                             0
-#define MSR_DCTS_LSB                             0
-#define MSR_DCTS_MASK                            0x00000001
-#define MSR_DCTS_GET(x)                          (((x) & MSR_DCTS_MASK) >> MSR_DCTS_LSB)
-#define MSR_DCTS_SET(x)                          (((x) << MSR_DCTS_LSB) & MSR_DCTS_MASK)
-
-#define SCR_ADDRESS                              0x0000001c
-#define SCR_OFFSET                               0x0000001c
-#define SCR_SCR_MSB                              7
-#define SCR_SCR_LSB                              0
-#define SCR_SCR_MASK                             0x000000ff
-#define SCR_SCR_GET(x)                           (((x) & SCR_SCR_MASK) >> SCR_SCR_LSB)
-#define SCR_SCR_SET(x)                           (((x) << SCR_SCR_LSB) & SCR_SCR_MASK)
-
-#define SRBR_ADDRESS                             0x00000020
-#define SRBR_OFFSET                              0x00000020
-#define SRBR_SRBR_MSB                            7
-#define SRBR_SRBR_LSB                            0
-#define SRBR_SRBR_MASK                           0x000000ff
-#define SRBR_SRBR_GET(x)                         (((x) & SRBR_SRBR_MASK) >> SRBR_SRBR_LSB)
-#define SRBR_SRBR_SET(x)                         (((x) << SRBR_SRBR_LSB) & SRBR_SRBR_MASK)
-
-#define SIIR_ADDRESS                             0x00000028
-#define SIIR_OFFSET                              0x00000028
-#define SIIR_SIIR_MSB                            7
-#define SIIR_SIIR_LSB                            0
-#define SIIR_SIIR_MASK                           0x000000ff
-#define SIIR_SIIR_GET(x)                         (((x) & SIIR_SIIR_MASK) >> SIIR_SIIR_LSB)
-#define SIIR_SIIR_SET(x)                         (((x) << SIIR_SIIR_LSB) & SIIR_SIIR_MASK)
-
-#define MWR_ADDRESS                              0x0000002c
-#define MWR_OFFSET                               0x0000002c
-#define MWR_MWR_MSB                              31
-#define MWR_MWR_LSB                              0
-#define MWR_MWR_MASK                             0xffffffff
-#define MWR_MWR_GET(x)                           (((x) & MWR_MWR_MASK) >> MWR_MWR_LSB)
-#define MWR_MWR_SET(x)                           (((x) << MWR_MWR_LSB) & MWR_MWR_MASK)
-
-#define SLSR_ADDRESS                             0x00000034
-#define SLSR_OFFSET                              0x00000034
-#define SLSR_SLSR_MSB                            7
-#define SLSR_SLSR_LSB                            0
-#define SLSR_SLSR_MASK                           0x000000ff
-#define SLSR_SLSR_GET(x)                         (((x) & SLSR_SLSR_MASK) >> SLSR_SLSR_LSB)
-#define SLSR_SLSR_SET(x)                         (((x) << SLSR_SLSR_LSB) & SLSR_SLSR_MASK)
-
-#define SMSR_ADDRESS                             0x00000038
-#define SMSR_OFFSET                              0x00000038
-#define SMSR_SMSR_MSB                            7
-#define SMSR_SMSR_LSB                            0
-#define SMSR_SMSR_MASK                           0x000000ff
-#define SMSR_SMSR_GET(x)                         (((x) & SMSR_SMSR_MASK) >> SMSR_SMSR_LSB)
-#define SMSR_SMSR_SET(x)                         (((x) << SMSR_SMSR_LSB) & SMSR_SMSR_MASK)
-
-#define MRR_ADDRESS                              0x0000003c
-#define MRR_OFFSET                               0x0000003c
-#define MRR_MRR_MSB                              31
-#define MRR_MRR_LSB                              0
-#define MRR_MRR_MASK                             0xffffffff
-#define MRR_MRR_GET(x)                           (((x) & MRR_MRR_MASK) >> MRR_MRR_LSB)
-#define MRR_MRR_SET(x)                           (((x) << MRR_MRR_LSB) & MRR_MRR_MASK)
-
-
-#ifndef __ASSEMBLER__
-
-typedef struct uart_reg_reg_s {
-  volatile unsigned int rbr;
-  volatile unsigned int dlh;
-  volatile unsigned int iir;
-  volatile unsigned int lcr;
-  volatile unsigned int mcr;
-  volatile unsigned int lsr;
-  volatile unsigned int msr;
-  volatile unsigned int scr;
-  volatile unsigned int srbr;
-  unsigned char pad0[4]; /* pad to 0x28 */
-  volatile unsigned int siir;
-  volatile unsigned int mwr;
-  unsigned char pad1[4]; /* pad to 0x34 */
-  volatile unsigned int slsr;
-  volatile unsigned int smsr;
-  volatile unsigned int mrr;
-} uart_reg_reg_t;
-
-#endif /* __ASSEMBLER__ */
-
-#endif /* _UART_REG_H_ */
diff --git a/drivers/staging/ath6kl/include/common/AR6002/hw2.0/hw/vmc_reg.h b/drivers/staging/ath6kl/include/common/AR6002/hw2.0/hw/vmc_reg.h
deleted file mode 100644 (file)
index 932ec51..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-#ifndef _VMC_REG_REG_H_
-#define _VMC_REG_REG_H_
-
-#define MC_TCAM_VALID_ADDRESS                    0x00000000
-#define MC_TCAM_VALID_OFFSET                     0x00000000
-#define MC_TCAM_VALID_BIT_MSB                    0
-#define MC_TCAM_VALID_BIT_LSB                    0
-#define MC_TCAM_VALID_BIT_MASK                   0x00000001
-#define MC_TCAM_VALID_BIT_GET(x)                 (((x) & MC_TCAM_VALID_BIT_MASK) >> MC_TCAM_VALID_BIT_LSB)
-#define MC_TCAM_VALID_BIT_SET(x)                 (((x) << MC_TCAM_VALID_BIT_LSB) & MC_TCAM_VALID_BIT_MASK)
-
-#define MC_TCAM_MASK_ADDRESS                     0x00000080
-#define MC_TCAM_MASK_OFFSET                      0x00000080
-#define MC_TCAM_MASK_SIZE_MSB                    2
-#define MC_TCAM_MASK_SIZE_LSB                    0
-#define MC_TCAM_MASK_SIZE_MASK                   0x00000007
-#define MC_TCAM_MASK_SIZE_GET(x)                 (((x) & MC_TCAM_MASK_SIZE_MASK) >> MC_TCAM_MASK_SIZE_LSB)
-#define MC_TCAM_MASK_SIZE_SET(x)                 (((x) << MC_TCAM_MASK_SIZE_LSB) & MC_TCAM_MASK_SIZE_MASK)
-
-#define MC_TCAM_COMPARE_ADDRESS                  0x00000100
-#define MC_TCAM_COMPARE_OFFSET                   0x00000100
-#define MC_TCAM_COMPARE_KEY_MSB                  21
-#define MC_TCAM_COMPARE_KEY_LSB                  5
-#define MC_TCAM_COMPARE_KEY_MASK                 0x003fffe0
-#define MC_TCAM_COMPARE_KEY_GET(x)               (((x) & MC_TCAM_COMPARE_KEY_MASK) >> MC_TCAM_COMPARE_KEY_LSB)
-#define MC_TCAM_COMPARE_KEY_SET(x)               (((x) << MC_TCAM_COMPARE_KEY_LSB) & MC_TCAM_COMPARE_KEY_MASK)
-
-#define MC_TCAM_TARGET_ADDRESS                   0x00000180
-#define MC_TCAM_TARGET_OFFSET                    0x00000180
-#define MC_TCAM_TARGET_ADDR_MSB                  21
-#define MC_TCAM_TARGET_ADDR_LSB                  5
-#define MC_TCAM_TARGET_ADDR_MASK                 0x003fffe0
-#define MC_TCAM_TARGET_ADDR_GET(x)               (((x) & MC_TCAM_TARGET_ADDR_MASK) >> MC_TCAM_TARGET_ADDR_LSB)
-#define MC_TCAM_TARGET_ADDR_SET(x)               (((x) << MC_TCAM_TARGET_ADDR_LSB) & MC_TCAM_TARGET_ADDR_MASK)
-
-#define ADDR_ERROR_CONTROL_ADDRESS               0x00000200
-#define ADDR_ERROR_CONTROL_OFFSET                0x00000200
-#define ADDR_ERROR_CONTROL_QUAL_ENABLE_MSB       1
-#define ADDR_ERROR_CONTROL_QUAL_ENABLE_LSB       1
-#define ADDR_ERROR_CONTROL_QUAL_ENABLE_MASK      0x00000002
-#define ADDR_ERROR_CONTROL_QUAL_ENABLE_GET(x)    (((x) & ADDR_ERROR_CONTROL_QUAL_ENABLE_MASK) >> ADDR_ERROR_CONTROL_QUAL_ENABLE_LSB)
-#define ADDR_ERROR_CONTROL_QUAL_ENABLE_SET(x)    (((x) << ADDR_ERROR_CONTROL_QUAL_ENABLE_LSB) & ADDR_ERROR_CONTROL_QUAL_ENABLE_MASK)
-#define ADDR_ERROR_CONTROL_ENABLE_MSB            0
-#define ADDR_ERROR_CONTROL_ENABLE_LSB            0
-#define ADDR_ERROR_CONTROL_ENABLE_MASK           0x00000001
-#define ADDR_ERROR_CONTROL_ENABLE_GET(x)         (((x) & ADDR_ERROR_CONTROL_ENABLE_MASK) >> ADDR_ERROR_CONTROL_ENABLE_LSB)
-#define ADDR_ERROR_CONTROL_ENABLE_SET(x)         (((x) << ADDR_ERROR_CONTROL_ENABLE_LSB) & ADDR_ERROR_CONTROL_ENABLE_MASK)
-
-#define ADDR_ERROR_STATUS_ADDRESS                0x00000204
-#define ADDR_ERROR_STATUS_OFFSET                 0x00000204
-#define ADDR_ERROR_STATUS_WRITE_MSB              25
-#define ADDR_ERROR_STATUS_WRITE_LSB              25
-#define ADDR_ERROR_STATUS_WRITE_MASK             0x02000000
-#define ADDR_ERROR_STATUS_WRITE_GET(x)           (((x) & ADDR_ERROR_STATUS_WRITE_MASK) >> ADDR_ERROR_STATUS_WRITE_LSB)
-#define ADDR_ERROR_STATUS_WRITE_SET(x)           (((x) << ADDR_ERROR_STATUS_WRITE_LSB) & ADDR_ERROR_STATUS_WRITE_MASK)
-#define ADDR_ERROR_STATUS_ADDRESS_MSB            24
-#define ADDR_ERROR_STATUS_ADDRESS_LSB            0
-#define ADDR_ERROR_STATUS_ADDRESS_MASK           0x01ffffff
-#define ADDR_ERROR_STATUS_ADDRESS_GET(x)         (((x) & ADDR_ERROR_STATUS_ADDRESS_MASK) >> ADDR_ERROR_STATUS_ADDRESS_LSB)
-#define ADDR_ERROR_STATUS_ADDRESS_SET(x)         (((x) << ADDR_ERROR_STATUS_ADDRESS_LSB) & ADDR_ERROR_STATUS_ADDRESS_MASK)
-
-
-#ifndef __ASSEMBLER__
-
-typedef struct vmc_reg_reg_s {
-  volatile unsigned int mc_tcam_valid[32];
-  volatile unsigned int mc_tcam_mask[32];
-  volatile unsigned int mc_tcam_compare[32];
-  volatile unsigned int mc_tcam_target[32];
-  volatile unsigned int addr_error_control;
-  volatile unsigned int addr_error_status;
-} vmc_reg_reg_t;
-
-#endif /* __ASSEMBLER__ */
-
-#endif /* _VMC_REG_H_ */
diff --git a/drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/analog_intf_ares_reg.h b/drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/analog_intf_ares_reg.h
deleted file mode 100644 (file)
index 5970fa9..0000000
+++ /dev/null
@@ -1,3291 +0,0 @@
-// ------------------------------------------------------------------
-// Copyright (c) 2004-2010 Atheros Corporation.  All rights reserved.
-// 
-//
-// Permission to use, copy, modify, and/or distribute this software for any
-// purpose with or without fee is hereby granted, provided that the above
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-//
-//
-// ------------------------------------------------------------------
-//===================================================================
-// Author(s): ="Atheros"
-//===================================================================
-
-/* Copyright (C) 2009 Denali Software Inc.  All rights reserved              */
-/* THIS FILE IS AUTOMATICALLY GENERATED BY DENALI BLUEPRINT, DO NOT EDIT     */
-
-
-#ifndef _ANALOG_INTF_ARES_REG_REG_H_
-#define _ANALOG_INTF_ARES_REG_REG_H_
-
-
-/* macros for RXRF_BIAS1 */
-#define PHY_ANALOG_RXRF_BIAS1_ADDRESS                                                                0x00000000
-#define PHY_ANALOG_RXRF_BIAS1_OFFSET                                                                 0x00000000
-#define PHY_ANALOG_RXRF_BIAS1_SPARE_MSB                                                                       0
-#define PHY_ANALOG_RXRF_BIAS1_SPARE_LSB                                                                       0
-#define PHY_ANALOG_RXRF_BIAS1_SPARE_MASK                                                             0x00000001
-#define PHY_ANALOG_RXRF_BIAS1_SPARE_GET(x)                                            (((x) & 0x00000001) >> 0)
-#define PHY_ANALOG_RXRF_BIAS1_SPARE_SET(x)                                            (((x) << 0) & 0x00000001)
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IR25SPARE_MSB                                                               3
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IR25SPARE_LSB                                                               1
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IR25SPARE_MASK                                                     0x0000000e
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IR25SPARE_GET(x)                                    (((x) & 0x0000000e) >> 1)
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IR25SPARE_SET(x)                                    (((x) << 1) & 0x0000000e)
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IR25LO18_MSB                                                                6
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IR25LO18_LSB                                                                4
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IR25LO18_MASK                                                      0x00000070
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IR25LO18_GET(x)                                     (((x) & 0x00000070) >> 4)
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IR25LO18_SET(x)                                     (((x) << 4) & 0x00000070)
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC25LO36_MSB                                                                9
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC25LO36_LSB                                                                7
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC25LO36_MASK                                                      0x00000380
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC25LO36_GET(x)                                     (((x) & 0x00000380) >> 7)
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC25LO36_SET(x)                                     (((x) << 7) & 0x00000380)
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC25MXR2_5GH_MSB                                                           12
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC25MXR2_5GH_LSB                                                           10
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC25MXR2_5GH_MASK                                                  0x00001c00
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC25MXR2_5GH_GET(x)                                (((x) & 0x00001c00) >> 10)
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC25MXR2_5GH_SET(x)                                (((x) << 10) & 0x00001c00)
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC25MXR5GH_MSB                                                             15
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC25MXR5GH_LSB                                                             13
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC25MXR5GH_MASK                                                    0x0000e000
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC25MXR5GH_GET(x)                                  (((x) & 0x0000e000) >> 13)
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC25MXR5GH_SET(x)                                  (((x) << 13) & 0x0000e000)
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC25VGA5G_MSB                                                              18
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC25VGA5G_LSB                                                              16
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC25VGA5G_MASK                                                     0x00070000
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC25VGA5G_GET(x)                                   (((x) & 0x00070000) >> 16)
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC25VGA5G_SET(x)                                   (((x) << 16) & 0x00070000)
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC75LNA5G_MSB                                                              21
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC75LNA5G_LSB                                                              19
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC75LNA5G_MASK                                                     0x00380000
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC75LNA5G_GET(x)                                   (((x) & 0x00380000) >> 19)
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC75LNA5G_SET(x)                                   (((x) << 19) & 0x00380000)
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IR25LO24_MSB                                                               24
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IR25LO24_LSB                                                               22
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IR25LO24_MASK                                                      0x01c00000
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IR25LO24_GET(x)                                    (((x) & 0x01c00000) >> 22)
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IR25LO24_SET(x)                                    (((x) << 22) & 0x01c00000)
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC25MXR2GH_MSB                                                             27
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC25MXR2GH_LSB                                                             25
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC25MXR2GH_MASK                                                    0x0e000000
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC25MXR2GH_GET(x)                                  (((x) & 0x0e000000) >> 25)
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC25MXR2GH_SET(x)                                  (((x) << 25) & 0x0e000000)
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC75LNA2G_MSB                                                              30
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC75LNA2G_LSB                                                              28
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC75LNA2G_MASK                                                     0x70000000
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC75LNA2G_GET(x)                                   (((x) & 0x70000000) >> 28)
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC75LNA2G_SET(x)                                   (((x) << 28) & 0x70000000)
-#define PHY_ANALOG_RXRF_BIAS1_PWD_BIAS_MSB                                                                   31
-#define PHY_ANALOG_RXRF_BIAS1_PWD_BIAS_LSB                                                                   31
-#define PHY_ANALOG_RXRF_BIAS1_PWD_BIAS_MASK                                                          0x80000000
-#define PHY_ANALOG_RXRF_BIAS1_PWD_BIAS_GET(x)                                        (((x) & 0x80000000) >> 31)
-#define PHY_ANALOG_RXRF_BIAS1_PWD_BIAS_SET(x)                                        (((x) << 31) & 0x80000000)
-
-/* macros for RXRF_BIAS2 */
-#define PHY_ANALOG_RXRF_BIAS2_ADDRESS                                                                0x00000004
-#define PHY_ANALOG_RXRF_BIAS2_OFFSET                                                                 0x00000004
-#define PHY_ANALOG_RXRF_BIAS2_SPARE_MSB                                                                       0
-#define PHY_ANALOG_RXRF_BIAS2_SPARE_LSB                                                                       0
-#define PHY_ANALOG_RXRF_BIAS2_SPARE_MASK                                                             0x00000001
-#define PHY_ANALOG_RXRF_BIAS2_SPARE_GET(x)                                            (((x) & 0x00000001) >> 0)
-#define PHY_ANALOG_RXRF_BIAS2_SPARE_SET(x)                                            (((x) << 0) & 0x00000001)
-#define PHY_ANALOG_RXRF_BIAS2_PKEN_MSB                                                                        3
-#define PHY_ANALOG_RXRF_BIAS2_PKEN_LSB                                                                        1
-#define PHY_ANALOG_RXRF_BIAS2_PKEN_MASK                                                              0x0000000e
-#define PHY_ANALOG_RXRF_BIAS2_PKEN_GET(x)                                             (((x) & 0x0000000e) >> 1)
-#define PHY_ANALOG_RXRF_BIAS2_PKEN_SET(x)                                             (((x) << 1) & 0x0000000e)
-#define PHY_ANALOG_RXRF_BIAS2_VCMVALUE_MSB                                                                    6
-#define PHY_ANALOG_RXRF_BIAS2_VCMVALUE_LSB                                                                    4
-#define PHY_ANALOG_RXRF_BIAS2_VCMVALUE_MASK                                                          0x00000070
-#define PHY_ANALOG_RXRF_BIAS2_VCMVALUE_GET(x)                                         (((x) & 0x00000070) >> 4)
-#define PHY_ANALOG_RXRF_BIAS2_VCMVALUE_SET(x)                                         (((x) << 4) & 0x00000070)
-#define PHY_ANALOG_RXRF_BIAS2_PWD_VCMBUF_MSB                                                                  7
-#define PHY_ANALOG_RXRF_BIAS2_PWD_VCMBUF_LSB                                                                  7
-#define PHY_ANALOG_RXRF_BIAS2_PWD_VCMBUF_MASK                                                        0x00000080
-#define PHY_ANALOG_RXRF_BIAS2_PWD_VCMBUF_GET(x)                                       (((x) & 0x00000080) >> 7)
-#define PHY_ANALOG_RXRF_BIAS2_PWD_VCMBUF_SET(x)                                       (((x) << 7) & 0x00000080)
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IR25AGC5GH_MSB                                                             10
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IR25AGC5GH_LSB                                                              8
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IR25AGC5GH_MASK                                                    0x00000700
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IR25AGC5GH_GET(x)                                   (((x) & 0x00000700) >> 8)
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IR25AGC5GH_SET(x)                                   (((x) << 8) & 0x00000700)
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IR25AGC5G_MSB                                                              13
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IR25AGC5G_LSB                                                              11
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IR25AGC5G_MASK                                                     0x00003800
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IR25AGC5G_GET(x)                                   (((x) & 0x00003800) >> 11)
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IR25AGC5G_SET(x)                                   (((x) << 11) & 0x00003800)
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IC25AGC5G_MSB                                                              16
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IC25AGC5G_LSB                                                              14
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IC25AGC5G_MASK                                                     0x0001c000
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IC25AGC5G_GET(x)                                   (((x) & 0x0001c000) >> 14)
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IC25AGC5G_SET(x)                                   (((x) << 14) & 0x0001c000)
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IR25AGC2GH_MSB                                                             19
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IR25AGC2GH_LSB                                                             17
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IR25AGC2GH_MASK                                                    0x000e0000
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IR25AGC2GH_GET(x)                                  (((x) & 0x000e0000) >> 17)
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IR25AGC2GH_SET(x)                                  (((x) << 17) & 0x000e0000)
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IR25AGC2G_MSB                                                              22
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IR25AGC2G_LSB                                                              20
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IR25AGC2G_MASK                                                     0x00700000
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IR25AGC2G_GET(x)                                   (((x) & 0x00700000) >> 20)
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IR25AGC2G_SET(x)                                   (((x) << 20) & 0x00700000)
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IC25AGC2G_MSB                                                              25
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IC25AGC2G_LSB                                                              23
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IC25AGC2G_MASK                                                     0x03800000
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IC25AGC2G_GET(x)                                   (((x) & 0x03800000) >> 23)
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IC25AGC2G_SET(x)                                   (((x) << 23) & 0x03800000)
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IC25VCMBUF_MSB                                                             28
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IC25VCMBUF_LSB                                                             26
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IC25VCMBUF_MASK                                                    0x1c000000
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IC25VCMBUF_GET(x)                                  (((x) & 0x1c000000) >> 26)
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IC25VCMBUF_SET(x)                                  (((x) << 26) & 0x1c000000)
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IR25VCM_MSB                                                                31
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IR25VCM_LSB                                                                29
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IR25VCM_MASK                                                       0xe0000000
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IR25VCM_GET(x)                                     (((x) & 0xe0000000) >> 29)
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IR25VCM_SET(x)                                     (((x) << 29) & 0xe0000000)
-
-/* macros for RXRF_GAINSTAGES */
-#define PHY_ANALOG_RXRF_GAINSTAGES_ADDRESS                                                           0x00000008
-#define PHY_ANALOG_RXRF_GAINSTAGES_OFFSET                                                            0x00000008
-#define PHY_ANALOG_RXRF_GAINSTAGES_SPARE_MSB                                                                  0
-#define PHY_ANALOG_RXRF_GAINSTAGES_SPARE_LSB                                                                  0
-#define PHY_ANALOG_RXRF_GAINSTAGES_SPARE_MASK                                                        0x00000001
-#define PHY_ANALOG_RXRF_GAINSTAGES_SPARE_GET(x)                                       (((x) & 0x00000001) >> 0)
-#define PHY_ANALOG_RXRF_GAINSTAGES_SPARE_SET(x)                                       (((x) << 0) & 0x00000001)
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNAON_CALDC_MSB                                                            1
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNAON_CALDC_LSB                                                            1
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNAON_CALDC_MASK                                                  0x00000002
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNAON_CALDC_GET(x)                                 (((x) & 0x00000002) >> 1)
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNAON_CALDC_SET(x)                                 (((x) << 1) & 0x00000002)
-#define PHY_ANALOG_RXRF_GAINSTAGES_VGA5G_CAP_MSB                                                              3
-#define PHY_ANALOG_RXRF_GAINSTAGES_VGA5G_CAP_LSB                                                              2
-#define PHY_ANALOG_RXRF_GAINSTAGES_VGA5G_CAP_MASK                                                    0x0000000c
-#define PHY_ANALOG_RXRF_GAINSTAGES_VGA5G_CAP_GET(x)                                   (((x) & 0x0000000c) >> 2)
-#define PHY_ANALOG_RXRF_GAINSTAGES_VGA5G_CAP_SET(x)                                   (((x) << 2) & 0x0000000c)
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA5G_CAP_MSB                                                              5
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA5G_CAP_LSB                                                              4
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA5G_CAP_MASK                                                    0x00000030
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA5G_CAP_GET(x)                                   (((x) & 0x00000030) >> 4)
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA5G_CAP_SET(x)                                   (((x) << 4) & 0x00000030)
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA5G_SHORTINP_MSB                                                         6
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA5G_SHORTINP_LSB                                                         6
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA5G_SHORTINP_MASK                                               0x00000040
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA5G_SHORTINP_GET(x)                              (((x) & 0x00000040) >> 6)
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA5G_SHORTINP_SET(x)                              (((x) << 6) & 0x00000040)
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_LO5G_MSB                                                               7
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_LO5G_LSB                                                               7
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_LO5G_MASK                                                     0x00000080
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_LO5G_GET(x)                                    (((x) & 0x00000080) >> 7)
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_LO5G_SET(x)                                    (((x) << 7) & 0x00000080)
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_VGA5G_MSB                                                              8
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_VGA5G_LSB                                                              8
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_VGA5G_MASK                                                    0x00000100
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_VGA5G_GET(x)                                   (((x) & 0x00000100) >> 8)
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_VGA5G_SET(x)                                   (((x) << 8) & 0x00000100)
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_MXR5G_MSB                                                              9
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_MXR5G_LSB                                                              9
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_MXR5G_MASK                                                    0x00000200
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_MXR5G_GET(x)                                   (((x) & 0x00000200) >> 9)
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_MXR5G_SET(x)                                   (((x) << 9) & 0x00000200)
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_LNA5G_MSB                                                             10
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_LNA5G_LSB                                                             10
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_LNA5G_MASK                                                    0x00000400
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_LNA5G_GET(x)                                  (((x) & 0x00000400) >> 10)
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_LNA5G_SET(x)                                  (((x) << 10) & 0x00000400)
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA2G_CAP_MSB                                                             12
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA2G_CAP_LSB                                                             11
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA2G_CAP_MASK                                                    0x00001800
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA2G_CAP_GET(x)                                  (((x) & 0x00001800) >> 11)
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA2G_CAP_SET(x)                                  (((x) << 11) & 0x00001800)
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA2G_SHORTINP_MSB                                                        13
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA2G_SHORTINP_LSB                                                        13
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA2G_SHORTINP_MASK                                               0x00002000
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA2G_SHORTINP_GET(x)                             (((x) & 0x00002000) >> 13)
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA2G_SHORTINP_SET(x)                             (((x) << 13) & 0x00002000)
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA2G_LP_MSB                                                              14
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA2G_LP_LSB                                                              14
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA2G_LP_MASK                                                     0x00004000
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA2G_LP_GET(x)                                   (((x) & 0x00004000) >> 14)
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA2G_LP_SET(x)                                   (((x) << 14) & 0x00004000)
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_LO2G_MSB                                                              15
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_LO2G_LSB                                                              15
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_LO2G_MASK                                                     0x00008000
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_LO2G_GET(x)                                   (((x) & 0x00008000) >> 15)
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_LO2G_SET(x)                                   (((x) << 15) & 0x00008000)
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_MXR2G_MSB                                                             16
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_MXR2G_LSB                                                             16
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_MXR2G_MASK                                                    0x00010000
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_MXR2G_GET(x)                                  (((x) & 0x00010000) >> 16)
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_MXR2G_SET(x)                                  (((x) << 16) & 0x00010000)
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_LNA2G_MSB                                                             17
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_LNA2G_LSB                                                             17
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_LNA2G_MASK                                                    0x00020000
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_LNA2G_GET(x)                                  (((x) & 0x00020000) >> 17)
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_LNA2G_SET(x)                                  (((x) << 17) & 0x00020000)
-#define PHY_ANALOG_RXRF_GAINSTAGES_MXR5G_GAIN_OVR_MSB                                                        19
-#define PHY_ANALOG_RXRF_GAINSTAGES_MXR5G_GAIN_OVR_LSB                                                        18
-#define PHY_ANALOG_RXRF_GAINSTAGES_MXR5G_GAIN_OVR_MASK                                               0x000c0000
-#define PHY_ANALOG_RXRF_GAINSTAGES_MXR5G_GAIN_OVR_GET(x)                             (((x) & 0x000c0000) >> 18)
-#define PHY_ANALOG_RXRF_GAINSTAGES_MXR5G_GAIN_OVR_SET(x)                             (((x) << 18) & 0x000c0000)
-#define PHY_ANALOG_RXRF_GAINSTAGES_VGA5G_GAIN_OVR_MSB                                                        22
-#define PHY_ANALOG_RXRF_GAINSTAGES_VGA5G_GAIN_OVR_LSB                                                        20
-#define PHY_ANALOG_RXRF_GAINSTAGES_VGA5G_GAIN_OVR_MASK                                               0x00700000
-#define PHY_ANALOG_RXRF_GAINSTAGES_VGA5G_GAIN_OVR_GET(x)                             (((x) & 0x00700000) >> 20)
-#define PHY_ANALOG_RXRF_GAINSTAGES_VGA5G_GAIN_OVR_SET(x)                             (((x) << 20) & 0x00700000)
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA5G_GAIN_OVR_MSB                                                        25
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA5G_GAIN_OVR_LSB                                                        23
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA5G_GAIN_OVR_MASK                                               0x03800000
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA5G_GAIN_OVR_GET(x)                             (((x) & 0x03800000) >> 23)
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA5G_GAIN_OVR_SET(x)                             (((x) << 23) & 0x03800000)
-#define PHY_ANALOG_RXRF_GAINSTAGES_MXR2G_GAIN_OVR_MSB                                                        27
-#define PHY_ANALOG_RXRF_GAINSTAGES_MXR2G_GAIN_OVR_LSB                                                        26
-#define PHY_ANALOG_RXRF_GAINSTAGES_MXR2G_GAIN_OVR_MASK                                               0x0c000000
-#define PHY_ANALOG_RXRF_GAINSTAGES_MXR2G_GAIN_OVR_GET(x)                             (((x) & 0x0c000000) >> 26)
-#define PHY_ANALOG_RXRF_GAINSTAGES_MXR2G_GAIN_OVR_SET(x)                             (((x) << 26) & 0x0c000000)
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA2G_GAIN_OVR_MSB                                                        30
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA2G_GAIN_OVR_LSB                                                        28
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA2G_GAIN_OVR_MASK                                               0x70000000
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA2G_GAIN_OVR_GET(x)                             (((x) & 0x70000000) >> 28)
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA2G_GAIN_OVR_SET(x)                             (((x) << 28) & 0x70000000)
-#define PHY_ANALOG_RXRF_GAINSTAGES_RX_OVERRIDE_MSB                                                           31
-#define PHY_ANALOG_RXRF_GAINSTAGES_RX_OVERRIDE_LSB                                                           31
-#define PHY_ANALOG_RXRF_GAINSTAGES_RX_OVERRIDE_MASK                                                  0x80000000
-#define PHY_ANALOG_RXRF_GAINSTAGES_RX_OVERRIDE_GET(x)                                (((x) & 0x80000000) >> 31)
-#define PHY_ANALOG_RXRF_GAINSTAGES_RX_OVERRIDE_SET(x)                                (((x) << 31) & 0x80000000)
-
-/* macros for RXRF_AGC */
-#define PHY_ANALOG_RXRF_AGC_ADDRESS                                                                  0x0000000c
-#define PHY_ANALOG_RXRF_AGC_OFFSET                                                                   0x0000000c
-#define PHY_ANALOG_RXRF_AGC_SPARE_MSB                                                                         5
-#define PHY_ANALOG_RXRF_AGC_SPARE_LSB                                                                         0
-#define PHY_ANALOG_RXRF_AGC_SPARE_MASK                                                               0x0000003f
-#define PHY_ANALOG_RXRF_AGC_SPARE_GET(x)                                              (((x) & 0x0000003f) >> 0)
-#define PHY_ANALOG_RXRF_AGC_SPARE_SET(x)                                              (((x) << 0) & 0x0000003f)
-#define PHY_ANALOG_RXRF_AGC_AGC_FALL_CTRL_MSB                                                                 8
-#define PHY_ANALOG_RXRF_AGC_AGC_FALL_CTRL_LSB                                                                 6
-#define PHY_ANALOG_RXRF_AGC_AGC_FALL_CTRL_MASK                                                       0x000001c0
-#define PHY_ANALOG_RXRF_AGC_AGC_FALL_CTRL_GET(x)                                      (((x) & 0x000001c0) >> 6)
-#define PHY_ANALOG_RXRF_AGC_AGC_FALL_CTRL_SET(x)                                      (((x) << 6) & 0x000001c0)
-#define PHY_ANALOG_RXRF_AGC_AGC5G_CALDAC_OVR_MSB                                                             14
-#define PHY_ANALOG_RXRF_AGC_AGC5G_CALDAC_OVR_LSB                                                              9
-#define PHY_ANALOG_RXRF_AGC_AGC5G_CALDAC_OVR_MASK                                                    0x00007e00
-#define PHY_ANALOG_RXRF_AGC_AGC5G_CALDAC_OVR_GET(x)                                   (((x) & 0x00007e00) >> 9)
-#define PHY_ANALOG_RXRF_AGC_AGC5G_CALDAC_OVR_SET(x)                                   (((x) << 9) & 0x00007e00)
-#define PHY_ANALOG_RXRF_AGC_AGC5G_DBDAC_OVR_MSB                                                              18
-#define PHY_ANALOG_RXRF_AGC_AGC5G_DBDAC_OVR_LSB                                                              15
-#define PHY_ANALOG_RXRF_AGC_AGC5G_DBDAC_OVR_MASK                                                     0x00078000
-#define PHY_ANALOG_RXRF_AGC_AGC5G_DBDAC_OVR_GET(x)                                   (((x) & 0x00078000) >> 15)
-#define PHY_ANALOG_RXRF_AGC_AGC5G_DBDAC_OVR_SET(x)                                   (((x) << 15) & 0x00078000)
-#define PHY_ANALOG_RXRF_AGC_AGC2G_CALDAC_OVR_MSB                                                             24
-#define PHY_ANALOG_RXRF_AGC_AGC2G_CALDAC_OVR_LSB                                                             19
-#define PHY_ANALOG_RXRF_AGC_AGC2G_CALDAC_OVR_MASK                                                    0x01f80000
-#define PHY_ANALOG_RXRF_AGC_AGC2G_CALDAC_OVR_GET(x)                                  (((x) & 0x01f80000) >> 19)
-#define PHY_ANALOG_RXRF_AGC_AGC2G_CALDAC_OVR_SET(x)                                  (((x) << 19) & 0x01f80000)
-#define PHY_ANALOG_RXRF_AGC_AGC2G_DBDAC_OVR_MSB                                                              28
-#define PHY_ANALOG_RXRF_AGC_AGC2G_DBDAC_OVR_LSB                                                              25
-#define PHY_ANALOG_RXRF_AGC_AGC2G_DBDAC_OVR_MASK                                                     0x1e000000
-#define PHY_ANALOG_RXRF_AGC_AGC2G_DBDAC_OVR_GET(x)                                   (((x) & 0x1e000000) >> 25)
-#define PHY_ANALOG_RXRF_AGC_AGC2G_DBDAC_OVR_SET(x)                                   (((x) << 25) & 0x1e000000)
-#define PHY_ANALOG_RXRF_AGC_AGC_CAL_OVR_MSB                                                                  29
-#define PHY_ANALOG_RXRF_AGC_AGC_CAL_OVR_LSB                                                                  29
-#define PHY_ANALOG_RXRF_AGC_AGC_CAL_OVR_MASK                                                         0x20000000
-#define PHY_ANALOG_RXRF_AGC_AGC_CAL_OVR_GET(x)                                       (((x) & 0x20000000) >> 29)
-#define PHY_ANALOG_RXRF_AGC_AGC_CAL_OVR_SET(x)                                       (((x) << 29) & 0x20000000)
-#define PHY_ANALOG_RXRF_AGC_AGC_ON_OVR_MSB                                                                   30
-#define PHY_ANALOG_RXRF_AGC_AGC_ON_OVR_LSB                                                                   30
-#define PHY_ANALOG_RXRF_AGC_AGC_ON_OVR_MASK                                                          0x40000000
-#define PHY_ANALOG_RXRF_AGC_AGC_ON_OVR_GET(x)                                        (((x) & 0x40000000) >> 30)
-#define PHY_ANALOG_RXRF_AGC_AGC_ON_OVR_SET(x)                                        (((x) << 30) & 0x40000000)
-#define PHY_ANALOG_RXRF_AGC_AGC_OVERRIDE_MSB                                                                 31
-#define PHY_ANALOG_RXRF_AGC_AGC_OVERRIDE_LSB                                                                 31
-#define PHY_ANALOG_RXRF_AGC_AGC_OVERRIDE_MASK                                                        0x80000000
-#define PHY_ANALOG_RXRF_AGC_AGC_OVERRIDE_GET(x)                                      (((x) & 0x80000000) >> 31)
-#define PHY_ANALOG_RXRF_AGC_AGC_OVERRIDE_SET(x)                                      (((x) << 31) & 0x80000000)
-
-/* macros for TXRF1 */
-#define PHY_ANALOG_TXRF1_ADDRESS                                                                     0x00000040
-#define PHY_ANALOG_TXRF1_OFFSET                                                                      0x00000040
-#define PHY_ANALOG_TXRF1_DCAS2G_MSB                                                                           2
-#define PHY_ANALOG_TXRF1_DCAS2G_LSB                                                                           0
-#define PHY_ANALOG_TXRF1_DCAS2G_MASK                                                                 0x00000007
-#define PHY_ANALOG_TXRF1_DCAS2G_GET(x)                                                (((x) & 0x00000007) >> 0)
-#define PHY_ANALOG_TXRF1_DCAS2G_SET(x)                                                (((x) << 0) & 0x00000007)
-#define PHY_ANALOG_TXRF1_OB2G_PALOFF_MSB                                                                      5
-#define PHY_ANALOG_TXRF1_OB2G_PALOFF_LSB                                                                      3
-#define PHY_ANALOG_TXRF1_OB2G_PALOFF_MASK                                                            0x00000038
-#define PHY_ANALOG_TXRF1_OB2G_PALOFF_GET(x)                                           (((x) & 0x00000038) >> 3)
-#define PHY_ANALOG_TXRF1_OB2G_PALOFF_SET(x)                                           (((x) << 3) & 0x00000038)
-#define PHY_ANALOG_TXRF1_OB2G_QAM_MSB                                                                         8
-#define PHY_ANALOG_TXRF1_OB2G_QAM_LSB                                                                         6
-#define PHY_ANALOG_TXRF1_OB2G_QAM_MASK                                                               0x000001c0
-#define PHY_ANALOG_TXRF1_OB2G_QAM_GET(x)                                              (((x) & 0x000001c0) >> 6)
-#define PHY_ANALOG_TXRF1_OB2G_QAM_SET(x)                                              (((x) << 6) & 0x000001c0)
-#define PHY_ANALOG_TXRF1_OB2G_PSK_MSB                                                                        11
-#define PHY_ANALOG_TXRF1_OB2G_PSK_LSB                                                                         9
-#define PHY_ANALOG_TXRF1_OB2G_PSK_MASK                                                               0x00000e00
-#define PHY_ANALOG_TXRF1_OB2G_PSK_GET(x)                                              (((x) & 0x00000e00) >> 9)
-#define PHY_ANALOG_TXRF1_OB2G_PSK_SET(x)                                              (((x) << 9) & 0x00000e00)
-#define PHY_ANALOG_TXRF1_OB2G_CCK_MSB                                                                        14
-#define PHY_ANALOG_TXRF1_OB2G_CCK_LSB                                                                        12
-#define PHY_ANALOG_TXRF1_OB2G_CCK_MASK                                                               0x00007000
-#define PHY_ANALOG_TXRF1_OB2G_CCK_GET(x)                                             (((x) & 0x00007000) >> 12)
-#define PHY_ANALOG_TXRF1_OB2G_CCK_SET(x)                                             (((x) << 12) & 0x00007000)
-#define PHY_ANALOG_TXRF1_DB2G_MSB                                                                            17
-#define PHY_ANALOG_TXRF1_DB2G_LSB                                                                            15
-#define PHY_ANALOG_TXRF1_DB2G_MASK                                                                   0x00038000
-#define PHY_ANALOG_TXRF1_DB2G_GET(x)                                                 (((x) & 0x00038000) >> 15)
-#define PHY_ANALOG_TXRF1_DB2G_SET(x)                                                 (((x) << 15) & 0x00038000)
-#define PHY_ANALOG_TXRF1_PDOUT2G_MSB                                                                         18
-#define PHY_ANALOG_TXRF1_PDOUT2G_LSB                                                                         18
-#define PHY_ANALOG_TXRF1_PDOUT2G_MASK                                                                0x00040000
-#define PHY_ANALOG_TXRF1_PDOUT2G_GET(x)                                              (((x) & 0x00040000) >> 18)
-#define PHY_ANALOG_TXRF1_PDOUT2G_SET(x)                                              (((x) << 18) & 0x00040000)
-#define PHY_ANALOG_TXRF1_PDDR2G_MSB                                                                          19
-#define PHY_ANALOG_TXRF1_PDDR2G_LSB                                                                          19
-#define PHY_ANALOG_TXRF1_PDDR2G_MASK                                                                 0x00080000
-#define PHY_ANALOG_TXRF1_PDDR2G_GET(x)                                               (((x) & 0x00080000) >> 19)
-#define PHY_ANALOG_TXRF1_PDDR2G_SET(x)                                               (((x) << 19) & 0x00080000)
-#define PHY_ANALOG_TXRF1_PDMXR2G_MSB                                                                         20
-#define PHY_ANALOG_TXRF1_PDMXR2G_LSB                                                                         20
-#define PHY_ANALOG_TXRF1_PDMXR2G_MASK                                                                0x00100000
-#define PHY_ANALOG_TXRF1_PDMXR2G_GET(x)                                              (((x) & 0x00100000) >> 20)
-#define PHY_ANALOG_TXRF1_PDMXR2G_SET(x)                                              (((x) << 20) & 0x00100000)
-#define PHY_ANALOG_TXRF1_PDLO2G_MSB                                                                          21
-#define PHY_ANALOG_TXRF1_PDLO2G_LSB                                                                          21
-#define PHY_ANALOG_TXRF1_PDLO2G_MASK                                                                 0x00200000
-#define PHY_ANALOG_TXRF1_PDLO2G_GET(x)                                               (((x) & 0x00200000) >> 21)
-#define PHY_ANALOG_TXRF1_PDLO2G_SET(x)                                               (((x) << 21) & 0x00200000)
-#define PHY_ANALOG_TXRF1_LOBUF2GFORCED_MSB                                                                   22
-#define PHY_ANALOG_TXRF1_LOBUF2GFORCED_LSB                                                                   22
-#define PHY_ANALOG_TXRF1_LOBUF2GFORCED_MASK                                                          0x00400000
-#define PHY_ANALOG_TXRF1_LOBUF2GFORCED_GET(x)                                        (((x) & 0x00400000) >> 22)
-#define PHY_ANALOG_TXRF1_LOBUF2GFORCED_SET(x)                                        (((x) << 22) & 0x00400000)
-#define PHY_ANALOG_TXRF1_LODIV2GFORCED_MSB                                                                   23
-#define PHY_ANALOG_TXRF1_LODIV2GFORCED_LSB                                                                   23
-#define PHY_ANALOG_TXRF1_LODIV2GFORCED_MASK                                                          0x00800000
-#define PHY_ANALOG_TXRF1_LODIV2GFORCED_GET(x)                                        (((x) & 0x00800000) >> 23)
-#define PHY_ANALOG_TXRF1_LODIV2GFORCED_SET(x)                                        (((x) << 23) & 0x00800000)
-#define PHY_ANALOG_TXRF1_PADRVGN2G_MSB                                                                       30
-#define PHY_ANALOG_TXRF1_PADRVGN2G_LSB                                                                       24
-#define PHY_ANALOG_TXRF1_PADRVGN2G_MASK                                                              0x7f000000
-#define PHY_ANALOG_TXRF1_PADRVGN2G_GET(x)                                            (((x) & 0x7f000000) >> 24)
-#define PHY_ANALOG_TXRF1_PADRVGN2G_SET(x)                                            (((x) << 24) & 0x7f000000)
-#define PHY_ANALOG_TXRF1_LOCALTXGAIN2G_MSB                                                                   31
-#define PHY_ANALOG_TXRF1_LOCALTXGAIN2G_LSB                                                                   31
-#define PHY_ANALOG_TXRF1_LOCALTXGAIN2G_MASK                                                          0x80000000
-#define PHY_ANALOG_TXRF1_LOCALTXGAIN2G_GET(x)                                        (((x) & 0x80000000) >> 31)
-#define PHY_ANALOG_TXRF1_LOCALTXGAIN2G_SET(x)                                        (((x) << 31) & 0x80000000)
-
-/* macros for TXRF2 */
-#define PHY_ANALOG_TXRF2_ADDRESS                                                                     0x00000044
-#define PHY_ANALOG_TXRF2_OFFSET                                                                      0x00000044
-#define PHY_ANALOG_TXRF2_SPARE2_MSB                                                                           0
-#define PHY_ANALOG_TXRF2_SPARE2_LSB                                                                           0
-#define PHY_ANALOG_TXRF2_SPARE2_MASK                                                                 0x00000001
-#define PHY_ANALOG_TXRF2_SPARE2_GET(x)                                                (((x) & 0x00000001) >> 0)
-#define PHY_ANALOG_TXRF2_SPARE2_SET(x)                                                (((x) << 0) & 0x00000001)
-#define PHY_ANALOG_TXRF2_D3B5G_MSB                                                                            3
-#define PHY_ANALOG_TXRF2_D3B5G_LSB                                                                            1
-#define PHY_ANALOG_TXRF2_D3B5G_MASK                                                                  0x0000000e
-#define PHY_ANALOG_TXRF2_D3B5G_GET(x)                                                 (((x) & 0x0000000e) >> 1)
-#define PHY_ANALOG_TXRF2_D3B5G_SET(x)                                                 (((x) << 1) & 0x0000000e)
-#define PHY_ANALOG_TXRF2_D4B5G_MSB                                                                            6
-#define PHY_ANALOG_TXRF2_D4B5G_LSB                                                                            4
-#define PHY_ANALOG_TXRF2_D4B5G_MASK                                                                  0x00000070
-#define PHY_ANALOG_TXRF2_D4B5G_GET(x)                                                 (((x) & 0x00000070) >> 4)
-#define PHY_ANALOG_TXRF2_D4B5G_SET(x)                                                 (((x) << 4) & 0x00000070)
-#define PHY_ANALOG_TXRF2_PDOUT5G_MSB                                                                         10
-#define PHY_ANALOG_TXRF2_PDOUT5G_LSB                                                                          7
-#define PHY_ANALOG_TXRF2_PDOUT5G_MASK                                                                0x00000780
-#define PHY_ANALOG_TXRF2_PDOUT5G_GET(x)                                               (((x) & 0x00000780) >> 7)
-#define PHY_ANALOG_TXRF2_PDOUT5G_SET(x)                                               (((x) << 7) & 0x00000780)
-#define PHY_ANALOG_TXRF2_PDMXR5G_MSB                                                                         11
-#define PHY_ANALOG_TXRF2_PDMXR5G_LSB                                                                         11
-#define PHY_ANALOG_TXRF2_PDMXR5G_MASK                                                                0x00000800
-#define PHY_ANALOG_TXRF2_PDMXR5G_GET(x)                                              (((x) & 0x00000800) >> 11)
-#define PHY_ANALOG_TXRF2_PDMXR5G_SET(x)                                              (((x) << 11) & 0x00000800)
-#define PHY_ANALOG_TXRF2_PDLOBUF5G_MSB                                                                       12
-#define PHY_ANALOG_TXRF2_PDLOBUF5G_LSB                                                                       12
-#define PHY_ANALOG_TXRF2_PDLOBUF5G_MASK                                                              0x00001000
-#define PHY_ANALOG_TXRF2_PDLOBUF5G_GET(x)                                            (((x) & 0x00001000) >> 12)
-#define PHY_ANALOG_TXRF2_PDLOBUF5G_SET(x)                                            (((x) << 12) & 0x00001000)
-#define PHY_ANALOG_TXRF2_PDLODIV5G_MSB                                                                       13
-#define PHY_ANALOG_TXRF2_PDLODIV5G_LSB                                                                       13
-#define PHY_ANALOG_TXRF2_PDLODIV5G_MASK                                                              0x00002000
-#define PHY_ANALOG_TXRF2_PDLODIV5G_GET(x)                                            (((x) & 0x00002000) >> 13)
-#define PHY_ANALOG_TXRF2_PDLODIV5G_SET(x)                                            (((x) << 13) & 0x00002000)
-#define PHY_ANALOG_TXRF2_LOBUF5GFORCED_MSB                                                                   14
-#define PHY_ANALOG_TXRF2_LOBUF5GFORCED_LSB                                                                   14
-#define PHY_ANALOG_TXRF2_LOBUF5GFORCED_MASK                                                          0x00004000
-#define PHY_ANALOG_TXRF2_LOBUF5GFORCED_GET(x)                                        (((x) & 0x00004000) >> 14)
-#define PHY_ANALOG_TXRF2_LOBUF5GFORCED_SET(x)                                        (((x) << 14) & 0x00004000)
-#define PHY_ANALOG_TXRF2_LODIV5GFORCED_MSB                                                                   15
-#define PHY_ANALOG_TXRF2_LODIV5GFORCED_LSB                                                                   15
-#define PHY_ANALOG_TXRF2_LODIV5GFORCED_MASK                                                          0x00008000
-#define PHY_ANALOG_TXRF2_LODIV5GFORCED_GET(x)                                        (((x) & 0x00008000) >> 15)
-#define PHY_ANALOG_TXRF2_LODIV5GFORCED_SET(x)                                        (((x) << 15) & 0x00008000)
-#define PHY_ANALOG_TXRF2_PADRV2GN5G_MSB                                                                      19
-#define PHY_ANALOG_TXRF2_PADRV2GN5G_LSB                                                                      16
-#define PHY_ANALOG_TXRF2_PADRV2GN5G_MASK                                                             0x000f0000
-#define PHY_ANALOG_TXRF2_PADRV2GN5G_GET(x)                                           (((x) & 0x000f0000) >> 16)
-#define PHY_ANALOG_TXRF2_PADRV2GN5G_SET(x)                                           (((x) << 16) & 0x000f0000)
-#define PHY_ANALOG_TXRF2_PADRV3GN5G_MSB                                                                      23
-#define PHY_ANALOG_TXRF2_PADRV3GN5G_LSB                                                                      20
-#define PHY_ANALOG_TXRF2_PADRV3GN5G_MASK                                                             0x00f00000
-#define PHY_ANALOG_TXRF2_PADRV3GN5G_GET(x)                                           (((x) & 0x00f00000) >> 20)
-#define PHY_ANALOG_TXRF2_PADRV3GN5G_SET(x)                                           (((x) << 20) & 0x00f00000)
-#define PHY_ANALOG_TXRF2_PADRV4GN5G_MSB                                                                      27
-#define PHY_ANALOG_TXRF2_PADRV4GN5G_LSB                                                                      24
-#define PHY_ANALOG_TXRF2_PADRV4GN5G_MASK                                                             0x0f000000
-#define PHY_ANALOG_TXRF2_PADRV4GN5G_GET(x)                                           (((x) & 0x0f000000) >> 24)
-#define PHY_ANALOG_TXRF2_PADRV4GN5G_SET(x)                                           (((x) << 24) & 0x0f000000)
-#define PHY_ANALOG_TXRF2_LOCALTXGAIN5G_MSB                                                                   28
-#define PHY_ANALOG_TXRF2_LOCALTXGAIN5G_LSB                                                                   28
-#define PHY_ANALOG_TXRF2_LOCALTXGAIN5G_MASK                                                          0x10000000
-#define PHY_ANALOG_TXRF2_LOCALTXGAIN5G_GET(x)                                        (((x) & 0x10000000) >> 28)
-#define PHY_ANALOG_TXRF2_LOCALTXGAIN5G_SET(x)                                        (((x) << 28) & 0x10000000)
-#define PHY_ANALOG_TXRF2_OCAS2G_MSB                                                                          31
-#define PHY_ANALOG_TXRF2_OCAS2G_LSB                                                                          29
-#define PHY_ANALOG_TXRF2_OCAS2G_MASK                                                                 0xe0000000
-#define PHY_ANALOG_TXRF2_OCAS2G_GET(x)                                               (((x) & 0xe0000000) >> 29)
-#define PHY_ANALOG_TXRF2_OCAS2G_SET(x)                                               (((x) << 29) & 0xe0000000)
-
-/* macros for TXRF3 */
-#define PHY_ANALOG_TXRF3_ADDRESS                                                                     0x00000048
-#define PHY_ANALOG_TXRF3_OFFSET                                                                      0x00000048
-#define PHY_ANALOG_TXRF3_SPARE3_MSB                                                                          22
-#define PHY_ANALOG_TXRF3_SPARE3_LSB                                                                           0
-#define PHY_ANALOG_TXRF3_SPARE3_MASK                                                                 0x007fffff
-#define PHY_ANALOG_TXRF3_SPARE3_GET(x)                                                (((x) & 0x007fffff) >> 0)
-#define PHY_ANALOG_TXRF3_SPARE3_SET(x)                                                (((x) << 0) & 0x007fffff)
-#define PHY_ANALOG_TXRF3_CAS5G_MSB                                                                           25
-#define PHY_ANALOG_TXRF3_CAS5G_LSB                                                                           23
-#define PHY_ANALOG_TXRF3_CAS5G_MASK                                                                  0x03800000
-#define PHY_ANALOG_TXRF3_CAS5G_GET(x)                                                (((x) & 0x03800000) >> 23)
-#define PHY_ANALOG_TXRF3_CAS5G_SET(x)                                                (((x) << 23) & 0x03800000)
-#define PHY_ANALOG_TXRF3_OB5G_MSB                                                                            28
-#define PHY_ANALOG_TXRF3_OB5G_LSB                                                                            26
-#define PHY_ANALOG_TXRF3_OB5G_MASK                                                                   0x1c000000
-#define PHY_ANALOG_TXRF3_OB5G_GET(x)                                                 (((x) & 0x1c000000) >> 26)
-#define PHY_ANALOG_TXRF3_OB5G_SET(x)                                                 (((x) << 26) & 0x1c000000)
-#define PHY_ANALOG_TXRF3_D2B5G_MSB                                                                           31
-#define PHY_ANALOG_TXRF3_D2B5G_LSB                                                                           29
-#define PHY_ANALOG_TXRF3_D2B5G_MASK                                                                  0xe0000000
-#define PHY_ANALOG_TXRF3_D2B5G_GET(x)                                                (((x) & 0xe0000000) >> 29)
-#define PHY_ANALOG_TXRF3_D2B5G_SET(x)                                                (((x) << 29) & 0xe0000000)
-
-/* macros for TXRF4 */
-#define PHY_ANALOG_TXRF4_ADDRESS                                                                     0x0000004c
-#define PHY_ANALOG_TXRF4_OFFSET                                                                      0x0000004c
-#define PHY_ANALOG_TXRF4_COMP2G_PSK_MSB                                                                       2
-#define PHY_ANALOG_TXRF4_COMP2G_PSK_LSB                                                                       0
-#define PHY_ANALOG_TXRF4_COMP2G_PSK_MASK                                                             0x00000007
-#define PHY_ANALOG_TXRF4_COMP2G_PSK_GET(x)                                            (((x) & 0x00000007) >> 0)
-#define PHY_ANALOG_TXRF4_COMP2G_PSK_SET(x)                                            (((x) << 0) & 0x00000007)
-#define PHY_ANALOG_TXRF4_COMP2G_CCK_MSB                                                                       5
-#define PHY_ANALOG_TXRF4_COMP2G_CCK_LSB                                                                       3
-#define PHY_ANALOG_TXRF4_COMP2G_CCK_MASK                                                             0x00000038
-#define PHY_ANALOG_TXRF4_COMP2G_CCK_GET(x)                                            (((x) & 0x00000038) >> 3)
-#define PHY_ANALOG_TXRF4_COMP2G_CCK_SET(x)                                            (((x) << 3) & 0x00000038)
-#define PHY_ANALOG_TXRF4_AMP2B2G_QAM_MSB                                                                      8
-#define PHY_ANALOG_TXRF4_AMP2B2G_QAM_LSB                                                                      6
-#define PHY_ANALOG_TXRF4_AMP2B2G_QAM_MASK                                                            0x000001c0
-#define PHY_ANALOG_TXRF4_AMP2B2G_QAM_GET(x)                                           (((x) & 0x000001c0) >> 6)
-#define PHY_ANALOG_TXRF4_AMP2B2G_QAM_SET(x)                                           (((x) << 6) & 0x000001c0)
-#define PHY_ANALOG_TXRF4_AMP2B2G_PSK_MSB                                                                     11
-#define PHY_ANALOG_TXRF4_AMP2B2G_PSK_LSB                                                                      9
-#define PHY_ANALOG_TXRF4_AMP2B2G_PSK_MASK                                                            0x00000e00
-#define PHY_ANALOG_TXRF4_AMP2B2G_PSK_GET(x)                                           (((x) & 0x00000e00) >> 9)
-#define PHY_ANALOG_TXRF4_AMP2B2G_PSK_SET(x)                                           (((x) << 9) & 0x00000e00)
-#define PHY_ANALOG_TXRF4_AMP2B2G_CCK_MSB                                                                     14
-#define PHY_ANALOG_TXRF4_AMP2B2G_CCK_LSB                                                                     12
-#define PHY_ANALOG_TXRF4_AMP2B2G_CCK_MASK                                                            0x00007000
-#define PHY_ANALOG_TXRF4_AMP2B2G_CCK_GET(x)                                          (((x) & 0x00007000) >> 12)
-#define PHY_ANALOG_TXRF4_AMP2B2G_CCK_SET(x)                                          (((x) << 12) & 0x00007000)
-#define PHY_ANALOG_TXRF4_AMP2CAS2G_MSB                                                                       17
-#define PHY_ANALOG_TXRF4_AMP2CAS2G_LSB                                                                       15
-#define PHY_ANALOG_TXRF4_AMP2CAS2G_MASK                                                              0x00038000
-#define PHY_ANALOG_TXRF4_AMP2CAS2G_GET(x)                                            (((x) & 0x00038000) >> 15)
-#define PHY_ANALOG_TXRF4_AMP2CAS2G_SET(x)                                            (((x) << 15) & 0x00038000)
-#define PHY_ANALOG_TXRF4_FILTR2G_MSB                                                                         19
-#define PHY_ANALOG_TXRF4_FILTR2G_LSB                                                                         18
-#define PHY_ANALOG_TXRF4_FILTR2G_MASK                                                                0x000c0000
-#define PHY_ANALOG_TXRF4_FILTR2G_GET(x)                                              (((x) & 0x000c0000) >> 18)
-#define PHY_ANALOG_TXRF4_FILTR2G_SET(x)                                              (((x) << 18) & 0x000c0000)
-#define PHY_ANALOG_TXRF4_PWDFB2_2G_MSB                                                                       20
-#define PHY_ANALOG_TXRF4_PWDFB2_2G_LSB                                                                       20
-#define PHY_ANALOG_TXRF4_PWDFB2_2G_MASK                                                              0x00100000
-#define PHY_ANALOG_TXRF4_PWDFB2_2G_GET(x)                                            (((x) & 0x00100000) >> 20)
-#define PHY_ANALOG_TXRF4_PWDFB2_2G_SET(x)                                            (((x) << 20) & 0x00100000)
-#define PHY_ANALOG_TXRF4_PWDFB1_2G_MSB                                                                       21
-#define PHY_ANALOG_TXRF4_PWDFB1_2G_LSB                                                                       21
-#define PHY_ANALOG_TXRF4_PWDFB1_2G_MASK                                                              0x00200000
-#define PHY_ANALOG_TXRF4_PWDFB1_2G_GET(x)                                            (((x) & 0x00200000) >> 21)
-#define PHY_ANALOG_TXRF4_PWDFB1_2G_SET(x)                                            (((x) << 21) & 0x00200000)
-#define PHY_ANALOG_TXRF4_PDFB2G_MSB                                                                          22
-#define PHY_ANALOG_TXRF4_PDFB2G_LSB                                                                          22
-#define PHY_ANALOG_TXRF4_PDFB2G_MASK                                                                 0x00400000
-#define PHY_ANALOG_TXRF4_PDFB2G_GET(x)                                               (((x) & 0x00400000) >> 22)
-#define PHY_ANALOG_TXRF4_PDFB2G_SET(x)                                               (((x) << 22) & 0x00400000)
-#define PHY_ANALOG_TXRF4_RDIV5G_MSB                                                                          24
-#define PHY_ANALOG_TXRF4_RDIV5G_LSB                                                                          23
-#define PHY_ANALOG_TXRF4_RDIV5G_MASK                                                                 0x01800000
-#define PHY_ANALOG_TXRF4_RDIV5G_GET(x)                                               (((x) & 0x01800000) >> 23)
-#define PHY_ANALOG_TXRF4_RDIV5G_SET(x)                                               (((x) << 23) & 0x01800000)
-#define PHY_ANALOG_TXRF4_CAPDIV5G_MSB                                                                        27
-#define PHY_ANALOG_TXRF4_CAPDIV5G_LSB                                                                        25
-#define PHY_ANALOG_TXRF4_CAPDIV5G_MASK                                                               0x0e000000
-#define PHY_ANALOG_TXRF4_CAPDIV5G_GET(x)                                             (((x) & 0x0e000000) >> 25)
-#define PHY_ANALOG_TXRF4_CAPDIV5G_SET(x)                                             (((x) << 25) & 0x0e000000)
-#define PHY_ANALOG_TXRF4_PDPREDIST5G_MSB                                                                     28
-#define PHY_ANALOG_TXRF4_PDPREDIST5G_LSB                                                                     28
-#define PHY_ANALOG_TXRF4_PDPREDIST5G_MASK                                                            0x10000000
-#define PHY_ANALOG_TXRF4_PDPREDIST5G_GET(x)                                          (((x) & 0x10000000) >> 28)
-#define PHY_ANALOG_TXRF4_PDPREDIST5G_SET(x)                                          (((x) << 28) & 0x10000000)
-#define PHY_ANALOG_TXRF4_RDIV2G_MSB                                                                          30
-#define PHY_ANALOG_TXRF4_RDIV2G_LSB                                                                          29
-#define PHY_ANALOG_TXRF4_RDIV2G_MASK                                                                 0x60000000
-#define PHY_ANALOG_TXRF4_RDIV2G_GET(x)                                               (((x) & 0x60000000) >> 29)
-#define PHY_ANALOG_TXRF4_RDIV2G_SET(x)                                               (((x) << 29) & 0x60000000)
-#define PHY_ANALOG_TXRF4_PDPREDIST2G_MSB                                                                     31
-#define PHY_ANALOG_TXRF4_PDPREDIST2G_LSB                                                                     31
-#define PHY_ANALOG_TXRF4_PDPREDIST2G_MASK                                                            0x80000000
-#define PHY_ANALOG_TXRF4_PDPREDIST2G_GET(x)                                          (((x) & 0x80000000) >> 31)
-#define PHY_ANALOG_TXRF4_PDPREDIST2G_SET(x)                                          (((x) << 31) & 0x80000000)
-
-/* macros for TXRF5 */
-#define PHY_ANALOG_TXRF5_ADDRESS                                                                     0x00000050
-#define PHY_ANALOG_TXRF5_OFFSET                                                                      0x00000050
-#define PHY_ANALOG_TXRF5_FBHI2G_MSB                                                                           0
-#define PHY_ANALOG_TXRF5_FBHI2G_LSB                                                                           0
-#define PHY_ANALOG_TXRF5_FBHI2G_MASK                                                                 0x00000001
-#define PHY_ANALOG_TXRF5_FBHI2G_GET(x)                                                (((x) & 0x00000001) >> 0)
-#define PHY_ANALOG_TXRF5_FBLO2G_MSB                                                                           1
-#define PHY_ANALOG_TXRF5_FBLO2G_LSB                                                                           1
-#define PHY_ANALOG_TXRF5_FBLO2G_MASK                                                                 0x00000002
-#define PHY_ANALOG_TXRF5_FBLO2G_GET(x)                                                (((x) & 0x00000002) >> 1)
-#define PHY_ANALOG_TXRF5_REFHI2G_MSB                                                                          4
-#define PHY_ANALOG_TXRF5_REFHI2G_LSB                                                                          2
-#define PHY_ANALOG_TXRF5_REFHI2G_MASK                                                                0x0000001c
-#define PHY_ANALOG_TXRF5_REFHI2G_GET(x)                                               (((x) & 0x0000001c) >> 2)
-#define PHY_ANALOG_TXRF5_REFHI2G_SET(x)                                               (((x) << 2) & 0x0000001c)
-#define PHY_ANALOG_TXRF5_REFLO2G_MSB                                                                          7
-#define PHY_ANALOG_TXRF5_REFLO2G_LSB                                                                          5
-#define PHY_ANALOG_TXRF5_REFLO2G_MASK                                                                0x000000e0
-#define PHY_ANALOG_TXRF5_REFLO2G_GET(x)                                               (((x) & 0x000000e0) >> 5)
-#define PHY_ANALOG_TXRF5_REFLO2G_SET(x)                                               (((x) << 5) & 0x000000e0)
-#define PHY_ANALOG_TXRF5_PK2B2G_QAM_MSB                                                                       9
-#define PHY_ANALOG_TXRF5_PK2B2G_QAM_LSB                                                                       8
-#define PHY_ANALOG_TXRF5_PK2B2G_QAM_MASK                                                             0x00000300
-#define PHY_ANALOG_TXRF5_PK2B2G_QAM_GET(x)                                            (((x) & 0x00000300) >> 8)
-#define PHY_ANALOG_TXRF5_PK2B2G_QAM_SET(x)                                            (((x) << 8) & 0x00000300)
-#define PHY_ANALOG_TXRF5_PK2B2G_PSK_MSB                                                                      11
-#define PHY_ANALOG_TXRF5_PK2B2G_PSK_LSB                                                                      10
-#define PHY_ANALOG_TXRF5_PK2B2G_PSK_MASK                                                             0x00000c00
-#define PHY_ANALOG_TXRF5_PK2B2G_PSK_GET(x)                                           (((x) & 0x00000c00) >> 10)
-#define PHY_ANALOG_TXRF5_PK2B2G_PSK_SET(x)                                           (((x) << 10) & 0x00000c00)
-#define PHY_ANALOG_TXRF5_PK2B2G_CCK_MSB                                                                      13
-#define PHY_ANALOG_TXRF5_PK2B2G_CCK_LSB                                                                      12
-#define PHY_ANALOG_TXRF5_PK2B2G_CCK_MASK                                                             0x00003000
-#define PHY_ANALOG_TXRF5_PK2B2G_CCK_GET(x)                                           (((x) & 0x00003000) >> 12)
-#define PHY_ANALOG_TXRF5_PK2B2G_CCK_SET(x)                                           (((x) << 12) & 0x00003000)
-#define PHY_ANALOG_TXRF5_PK1B2G_QAM_MSB                                                                      15
-#define PHY_ANALOG_TXRF5_PK1B2G_QAM_LSB                                                                      14
-#define PHY_ANALOG_TXRF5_PK1B2G_QAM_MASK                                                             0x0000c000
-#define PHY_ANALOG_TXRF5_PK1B2G_QAM_GET(x)                                           (((x) & 0x0000c000) >> 14)
-#define PHY_ANALOG_TXRF5_PK1B2G_QAM_SET(x)                                           (((x) << 14) & 0x0000c000)
-#define PHY_ANALOG_TXRF5_PK1B2G_PSK_MSB                                                                      17
-#define PHY_ANALOG_TXRF5_PK1B2G_PSK_LSB                                                                      16
-#define PHY_ANALOG_TXRF5_PK1B2G_PSK_MASK                                                             0x00030000
-#define PHY_ANALOG_TXRF5_PK1B2G_PSK_GET(x)                                           (((x) & 0x00030000) >> 16)
-#define PHY_ANALOG_TXRF5_PK1B2G_PSK_SET(x)                                           (((x) << 16) & 0x00030000)
-#define PHY_ANALOG_TXRF5_PK1B2G_CCK_MSB                                                                      19
-#define PHY_ANALOG_TXRF5_PK1B2G_CCK_LSB                                                                      18
-#define PHY_ANALOG_TXRF5_PK1B2G_CCK_MASK                                                             0x000c0000
-#define PHY_ANALOG_TXRF5_PK1B2G_CCK_GET(x)                                           (((x) & 0x000c0000) >> 18)
-#define PHY_ANALOG_TXRF5_PK1B2G_CCK_SET(x)                                           (((x) << 18) & 0x000c0000)
-#define PHY_ANALOG_TXRF5_MIOB2G_QAM_MSB                                                                      22
-#define PHY_ANALOG_TXRF5_MIOB2G_QAM_LSB                                                                      20
-#define PHY_ANALOG_TXRF5_MIOB2G_QAM_MASK                                                             0x00700000
-#define PHY_ANALOG_TXRF5_MIOB2G_QAM_GET(x)                                           (((x) & 0x00700000) >> 20)
-#define PHY_ANALOG_TXRF5_MIOB2G_QAM_SET(x)                                           (((x) << 20) & 0x00700000)
-#define PHY_ANALOG_TXRF5_MIOB2G_PSK_MSB                                                                      25
-#define PHY_ANALOG_TXRF5_MIOB2G_PSK_LSB                                                                      23
-#define PHY_ANALOG_TXRF5_MIOB2G_PSK_MASK                                                             0x03800000
-#define PHY_ANALOG_TXRF5_MIOB2G_PSK_GET(x)                                           (((x) & 0x03800000) >> 23)
-#define PHY_ANALOG_TXRF5_MIOB2G_PSK_SET(x)                                           (((x) << 23) & 0x03800000)
-#define PHY_ANALOG_TXRF5_MIOB2G_CCK_MSB                                                                      28
-#define PHY_ANALOG_TXRF5_MIOB2G_CCK_LSB                                                                      26
-#define PHY_ANALOG_TXRF5_MIOB2G_CCK_MASK                                                             0x1c000000
-#define PHY_ANALOG_TXRF5_MIOB2G_CCK_GET(x)                                           (((x) & 0x1c000000) >> 26)
-#define PHY_ANALOG_TXRF5_MIOB2G_CCK_SET(x)                                           (((x) << 26) & 0x1c000000)
-#define PHY_ANALOG_TXRF5_COMP2G_QAM_MSB                                                                      31
-#define PHY_ANALOG_TXRF5_COMP2G_QAM_LSB                                                                      29
-#define PHY_ANALOG_TXRF5_COMP2G_QAM_MASK                                                             0xe0000000
-#define PHY_ANALOG_TXRF5_COMP2G_QAM_GET(x)                                           (((x) & 0xe0000000) >> 29)
-#define PHY_ANALOG_TXRF5_COMP2G_QAM_SET(x)                                           (((x) << 29) & 0xe0000000)
-
-/* macros for TXRF6 */
-#define PHY_ANALOG_TXRF6_ADDRESS                                                                     0x00000054
-#define PHY_ANALOG_TXRF6_OFFSET                                                                      0x00000054
-#define PHY_ANALOG_TXRF6_SPARE6_MSB                                                                           0
-#define PHY_ANALOG_TXRF6_SPARE6_LSB                                                                           0
-#define PHY_ANALOG_TXRF6_SPARE6_MASK                                                                 0x00000001
-#define PHY_ANALOG_TXRF6_SPARE6_GET(x)                                                (((x) & 0x00000001) >> 0)
-#define PHY_ANALOG_TXRF6_SPARE6_SET(x)                                                (((x) << 0) & 0x00000001)
-#define PHY_ANALOG_TXRF6_PAL_LOCKED_MSB                                                                       1
-#define PHY_ANALOG_TXRF6_PAL_LOCKED_LSB                                                                       1
-#define PHY_ANALOG_TXRF6_PAL_LOCKED_MASK                                                             0x00000002
-#define PHY_ANALOG_TXRF6_PAL_LOCKED_GET(x)                                            (((x) & 0x00000002) >> 1)
-#define PHY_ANALOG_TXRF6_PADRVGN2G_SMOUT_MSB                                                                  7
-#define PHY_ANALOG_TXRF6_PADRVGN2G_SMOUT_LSB                                                                  2
-#define PHY_ANALOG_TXRF6_PADRVGN2G_SMOUT_MASK                                                        0x000000fc
-#define PHY_ANALOG_TXRF6_PADRVGN2G_SMOUT_GET(x)                                       (((x) & 0x000000fc) >> 2)
-#define PHY_ANALOG_TXRF6_GAINSTEP2G_MSB                                                                      10
-#define PHY_ANALOG_TXRF6_GAINSTEP2G_LSB                                                                       8
-#define PHY_ANALOG_TXRF6_GAINSTEP2G_MASK                                                             0x00000700
-#define PHY_ANALOG_TXRF6_GAINSTEP2G_GET(x)                                            (((x) & 0x00000700) >> 8)
-#define PHY_ANALOG_TXRF6_GAINSTEP2G_SET(x)                                            (((x) << 8) & 0x00000700)
-#define PHY_ANALOG_TXRF6_USE_GAIN_DELTA2G_MSB                                                                11
-#define PHY_ANALOG_TXRF6_USE_GAIN_DELTA2G_LSB                                                                11
-#define PHY_ANALOG_TXRF6_USE_GAIN_DELTA2G_MASK                                                       0x00000800
-#define PHY_ANALOG_TXRF6_USE_GAIN_DELTA2G_GET(x)                                     (((x) & 0x00000800) >> 11)
-#define PHY_ANALOG_TXRF6_USE_GAIN_DELTA2G_SET(x)                                     (((x) << 11) & 0x00000800)
-#define PHY_ANALOG_TXRF6_PADRVGN_INDEX_I2G_MSB                                                               15
-#define PHY_ANALOG_TXRF6_PADRVGN_INDEX_I2G_LSB                                                               12
-#define PHY_ANALOG_TXRF6_PADRVGN_INDEX_I2G_MASK                                                      0x0000f000
-#define PHY_ANALOG_TXRF6_PADRVGN_INDEX_I2G_GET(x)                                    (((x) & 0x0000f000) >> 12)
-#define PHY_ANALOG_TXRF6_PADRVGN_INDEX_I2G_SET(x)                                    (((x) << 12) & 0x0000f000)
-#define PHY_ANALOG_TXRF6_VCMONDELAY2G_MSB                                                                    18
-#define PHY_ANALOG_TXRF6_VCMONDELAY2G_LSB                                                                    16
-#define PHY_ANALOG_TXRF6_VCMONDELAY2G_MASK                                                           0x00070000
-#define PHY_ANALOG_TXRF6_VCMONDELAY2G_GET(x)                                         (((x) & 0x00070000) >> 16)
-#define PHY_ANALOG_TXRF6_VCMONDELAY2G_SET(x)                                         (((x) << 16) & 0x00070000)
-#define PHY_ANALOG_TXRF6_CAPDIV2G_MSB                                                                        21
-#define PHY_ANALOG_TXRF6_CAPDIV2G_LSB                                                                        19
-#define PHY_ANALOG_TXRF6_CAPDIV2G_MASK                                                               0x00380000
-#define PHY_ANALOG_TXRF6_CAPDIV2G_GET(x)                                             (((x) & 0x00380000) >> 19)
-#define PHY_ANALOG_TXRF6_CAPDIV2G_SET(x)                                             (((x) << 19) & 0x00380000)
-#define PHY_ANALOG_TXRF6_CAPDIV2GOVR_MSB                                                                     22
-#define PHY_ANALOG_TXRF6_CAPDIV2GOVR_LSB                                                                     22
-#define PHY_ANALOG_TXRF6_CAPDIV2GOVR_MASK                                                            0x00400000
-#define PHY_ANALOG_TXRF6_CAPDIV2GOVR_GET(x)                                          (((x) & 0x00400000) >> 22)
-#define PHY_ANALOG_TXRF6_CAPDIV2GOVR_SET(x)                                          (((x) << 22) & 0x00400000)
-#define PHY_ANALOG_TXRF6_ENPACAL2G_MSB                                                                       23
-#define PHY_ANALOG_TXRF6_ENPACAL2G_LSB                                                                       23
-#define PHY_ANALOG_TXRF6_ENPACAL2G_MASK                                                              0x00800000
-#define PHY_ANALOG_TXRF6_ENPACAL2G_GET(x)                                            (((x) & 0x00800000) >> 23)
-#define PHY_ANALOG_TXRF6_ENPACAL2G_SET(x)                                            (((x) << 23) & 0x00800000)
-#define PHY_ANALOG_TXRF6_OFFSET2G_MSB                                                                        30
-#define PHY_ANALOG_TXRF6_OFFSET2G_LSB                                                                        24
-#define PHY_ANALOG_TXRF6_OFFSET2G_MASK                                                               0x7f000000
-#define PHY_ANALOG_TXRF6_OFFSET2G_GET(x)                                             (((x) & 0x7f000000) >> 24)
-#define PHY_ANALOG_TXRF6_OFFSET2G_SET(x)                                             (((x) << 24) & 0x7f000000)
-#define PHY_ANALOG_TXRF6_ENOFFSETCAL2G_MSB                                                                   31
-#define PHY_ANALOG_TXRF6_ENOFFSETCAL2G_LSB                                                                   31
-#define PHY_ANALOG_TXRF6_ENOFFSETCAL2G_MASK                                                          0x80000000
-#define PHY_ANALOG_TXRF6_ENOFFSETCAL2G_GET(x)                                        (((x) & 0x80000000) >> 31)
-#define PHY_ANALOG_TXRF6_ENOFFSETCAL2G_SET(x)                                        (((x) << 31) & 0x80000000)
-
-/* macros for TXRF7 */
-#define PHY_ANALOG_TXRF7_ADDRESS                                                                     0x00000058
-#define PHY_ANALOG_TXRF7_OFFSET                                                                      0x00000058
-#define PHY_ANALOG_TXRF7_SPARE7_MSB                                                                           1
-#define PHY_ANALOG_TXRF7_SPARE7_LSB                                                                           0
-#define PHY_ANALOG_TXRF7_SPARE7_MASK                                                                 0x00000003
-#define PHY_ANALOG_TXRF7_SPARE7_GET(x)                                                (((x) & 0x00000003) >> 0)
-#define PHY_ANALOG_TXRF7_SPARE7_SET(x)                                                (((x) << 0) & 0x00000003)
-#define PHY_ANALOG_TXRF7_PADRVGNTAB_4_MSB                                                                     7
-#define PHY_ANALOG_TXRF7_PADRVGNTAB_4_LSB                                                                     2
-#define PHY_ANALOG_TXRF7_PADRVGNTAB_4_MASK                                                           0x000000fc
-#define PHY_ANALOG_TXRF7_PADRVGNTAB_4_GET(x)                                          (((x) & 0x000000fc) >> 2)
-#define PHY_ANALOG_TXRF7_PADRVGNTAB_4_SET(x)                                          (((x) << 2) & 0x000000fc)
-#define PHY_ANALOG_TXRF7_PADRVGNTAB_3_MSB                                                                    13
-#define PHY_ANALOG_TXRF7_PADRVGNTAB_3_LSB                                                                     8
-#define PHY_ANALOG_TXRF7_PADRVGNTAB_3_MASK                                                           0x00003f00
-#define PHY_ANALOG_TXRF7_PADRVGNTAB_3_GET(x)                                          (((x) & 0x00003f00) >> 8)
-#define PHY_ANALOG_TXRF7_PADRVGNTAB_3_SET(x)                                          (((x) << 8) & 0x00003f00)
-#define PHY_ANALOG_TXRF7_PADRVGNTAB_2_MSB                                                                    19
-#define PHY_ANALOG_TXRF7_PADRVGNTAB_2_LSB                                                                    14
-#define PHY_ANALOG_TXRF7_PADRVGNTAB_2_MASK                                                           0x000fc000
-#define PHY_ANALOG_TXRF7_PADRVGNTAB_2_GET(x)                                         (((x) & 0x000fc000) >> 14)
-#define PHY_ANALOG_TXRF7_PADRVGNTAB_2_SET(x)                                         (((x) << 14) & 0x000fc000)
-#define PHY_ANALOG_TXRF7_PADRVGNTAB_1_MSB                                                                    25
-#define PHY_ANALOG_TXRF7_PADRVGNTAB_1_LSB                                                                    20
-#define PHY_ANALOG_TXRF7_PADRVGNTAB_1_MASK                                                           0x03f00000
-#define PHY_ANALOG_TXRF7_PADRVGNTAB_1_GET(x)                                         (((x) & 0x03f00000) >> 20)
-#define PHY_ANALOG_TXRF7_PADRVGNTAB_1_SET(x)                                         (((x) << 20) & 0x03f00000)
-#define PHY_ANALOG_TXRF7_PADRVGNTAB_0_MSB                                                                    31
-#define PHY_ANALOG_TXRF7_PADRVGNTAB_0_LSB                                                                    26
-#define PHY_ANALOG_TXRF7_PADRVGNTAB_0_MASK                                                           0xfc000000
-#define PHY_ANALOG_TXRF7_PADRVGNTAB_0_GET(x)                                         (((x) & 0xfc000000) >> 26)
-#define PHY_ANALOG_TXRF7_PADRVGNTAB_0_SET(x)                                         (((x) << 26) & 0xfc000000)
-
-/* macros for TXRF8 */
-#define PHY_ANALOG_TXRF8_ADDRESS                                                                     0x0000005c
-#define PHY_ANALOG_TXRF8_OFFSET                                                                      0x0000005c
-#define PHY_ANALOG_TXRF8_SPARE8_MSB                                                                           1
-#define PHY_ANALOG_TXRF8_SPARE8_LSB                                                                           0
-#define PHY_ANALOG_TXRF8_SPARE8_MASK                                                                 0x00000003
-#define PHY_ANALOG_TXRF8_SPARE8_GET(x)                                                (((x) & 0x00000003) >> 0)
-#define PHY_ANALOG_TXRF8_SPARE8_SET(x)                                                (((x) << 0) & 0x00000003)
-#define PHY_ANALOG_TXRF8_PADRVGNTAB_9_MSB                                                                     7
-#define PHY_ANALOG_TXRF8_PADRVGNTAB_9_LSB                                                                     2
-#define PHY_ANALOG_TXRF8_PADRVGNTAB_9_MASK                                                           0x000000fc
-#define PHY_ANALOG_TXRF8_PADRVGNTAB_9_GET(x)                                          (((x) & 0x000000fc) >> 2)
-#define PHY_ANALOG_TXRF8_PADRVGNTAB_9_SET(x)                                          (((x) << 2) & 0x000000fc)
-#define PHY_ANALOG_TXRF8_PADRVGNTAB_8_MSB                                                                    13
-#define PHY_ANALOG_TXRF8_PADRVGNTAB_8_LSB                                                                     8
-#define PHY_ANALOG_TXRF8_PADRVGNTAB_8_MASK                                                           0x00003f00
-#define PHY_ANALOG_TXRF8_PADRVGNTAB_8_GET(x)                                          (((x) & 0x00003f00) >> 8)
-#define PHY_ANALOG_TXRF8_PADRVGNTAB_8_SET(x)                                          (((x) << 8) & 0x00003f00)
-#define PHY_ANALOG_TXRF8_PADRVGNTAB_7_MSB                                                                    19
-#define PHY_ANALOG_TXRF8_PADRVGNTAB_7_LSB                                                                    14
-#define PHY_ANALOG_TXRF8_PADRVGNTAB_7_MASK                                                           0x000fc000
-#define PHY_ANALOG_TXRF8_PADRVGNTAB_7_GET(x)                                         (((x) & 0x000fc000) >> 14)
-#define PHY_ANALOG_TXRF8_PADRVGNTAB_7_SET(x)                                         (((x) << 14) & 0x000fc000)
-#define PHY_ANALOG_TXRF8_PADRVGNTAB_6_MSB                                                                    25
-#define PHY_ANALOG_TXRF8_PADRVGNTAB_6_LSB                                                                    20
-#define PHY_ANALOG_TXRF8_PADRVGNTAB_6_MASK                                                           0x03f00000
-#define PHY_ANALOG_TXRF8_PADRVGNTAB_6_GET(x)                                         (((x) & 0x03f00000) >> 20)
-#define PHY_ANALOG_TXRF8_PADRVGNTAB_6_SET(x)                                         (((x) << 20) & 0x03f00000)
-#define PHY_ANALOG_TXRF8_PADRVGNTAB_5_MSB                                                                    31
-#define PHY_ANALOG_TXRF8_PADRVGNTAB_5_LSB                                                                    26
-#define PHY_ANALOG_TXRF8_PADRVGNTAB_5_MASK                                                           0xfc000000
-#define PHY_ANALOG_TXRF8_PADRVGNTAB_5_GET(x)                                         (((x) & 0xfc000000) >> 26)
-#define PHY_ANALOG_TXRF8_PADRVGNTAB_5_SET(x)                                         (((x) << 26) & 0xfc000000)
-
-/* macros for TXRF9 */
-#define PHY_ANALOG_TXRF9_ADDRESS                                                                     0x00000060
-#define PHY_ANALOG_TXRF9_OFFSET                                                                      0x00000060
-#define PHY_ANALOG_TXRF9_SPARE9_MSB                                                                           1
-#define PHY_ANALOG_TXRF9_SPARE9_LSB                                                                           0
-#define PHY_ANALOG_TXRF9_SPARE9_MASK                                                                 0x00000003
-#define PHY_ANALOG_TXRF9_SPARE9_GET(x)                                                (((x) & 0x00000003) >> 0)
-#define PHY_ANALOG_TXRF9_SPARE9_SET(x)                                                (((x) << 0) & 0x00000003)
-#define PHY_ANALOG_TXRF9_PADRVGNTAB_14_MSB                                                                    7
-#define PHY_ANALOG_TXRF9_PADRVGNTAB_14_LSB                                                                    2
-#define PHY_ANALOG_TXRF9_PADRVGNTAB_14_MASK                                                          0x000000fc
-#define PHY_ANALOG_TXRF9_PADRVGNTAB_14_GET(x)                                         (((x) & 0x000000fc) >> 2)
-#define PHY_ANALOG_TXRF9_PADRVGNTAB_14_SET(x)                                         (((x) << 2) & 0x000000fc)
-#define PHY_ANALOG_TXRF9_PADRVGNTAB_13_MSB                                                                   13
-#define PHY_ANALOG_TXRF9_PADRVGNTAB_13_LSB                                                                    8
-#define PHY_ANALOG_TXRF9_PADRVGNTAB_13_MASK                                                          0x00003f00
-#define PHY_ANALOG_TXRF9_PADRVGNTAB_13_GET(x)                                         (((x) & 0x00003f00) >> 8)
-#define PHY_ANALOG_TXRF9_PADRVGNTAB_13_SET(x)                                         (((x) << 8) & 0x00003f00)
-#define PHY_ANALOG_TXRF9_PADRVGNTAB_12_MSB                                                                   19
-#define PHY_ANALOG_TXRF9_PADRVGNTAB_12_LSB                                                                   14
-#define PHY_ANALOG_TXRF9_PADRVGNTAB_12_MASK                                                          0x000fc000
-#define PHY_ANALOG_TXRF9_PADRVGNTAB_12_GET(x)                                        (((x) & 0x000fc000) >> 14)
-#define PHY_ANALOG_TXRF9_PADRVGNTAB_12_SET(x)                                        (((x) << 14) & 0x000fc000)
-#define PHY_ANALOG_TXRF9_PADRVGNTAB_11_MSB                                                                   25
-#define PHY_ANALOG_TXRF9_PADRVGNTAB_11_LSB                                                                   20
-#define PHY_ANALOG_TXRF9_PADRVGNTAB_11_MASK                                                          0x03f00000
-#define PHY_ANALOG_TXRF9_PADRVGNTAB_11_GET(x)                                        (((x) & 0x03f00000) >> 20)
-#define PHY_ANALOG_TXRF9_PADRVGNTAB_11_SET(x)                                        (((x) << 20) & 0x03f00000)
-#define PHY_ANALOG_TXRF9_PADRVGNTAB_10_MSB                                                                   31
-#define PHY_ANALOG_TXRF9_PADRVGNTAB_10_LSB                                                                   26
-#define PHY_ANALOG_TXRF9_PADRVGNTAB_10_MASK                                                          0xfc000000
-#define PHY_ANALOG_TXRF9_PADRVGNTAB_10_GET(x)                                        (((x) & 0xfc000000) >> 26)
-#define PHY_ANALOG_TXRF9_PADRVGNTAB_10_SET(x)                                        (((x) << 26) & 0xfc000000)
-
-/* macros for TXRF10 */
-#define PHY_ANALOG_TXRF10_ADDRESS                                                                    0x00000064
-#define PHY_ANALOG_TXRF10_OFFSET                                                                     0x00000064
-#define PHY_ANALOG_TXRF10_SPARE10_MSB                                                                        12
-#define PHY_ANALOG_TXRF10_SPARE10_LSB                                                                         0
-#define PHY_ANALOG_TXRF10_SPARE10_MASK                                                               0x00001fff
-#define PHY_ANALOG_TXRF10_SPARE10_GET(x)                                              (((x) & 0x00001fff) >> 0)
-#define PHY_ANALOG_TXRF10_SPARE10_SET(x)                                              (((x) << 0) & 0x00001fff)
-#define PHY_ANALOG_TXRF10_PDOUT5G_3CALTX_MSB                                                                 13
-#define PHY_ANALOG_TXRF10_PDOUT5G_3CALTX_LSB                                                                 13
-#define PHY_ANALOG_TXRF10_PDOUT5G_3CALTX_MASK                                                        0x00002000
-#define PHY_ANALOG_TXRF10_PDOUT5G_3CALTX_GET(x)                                      (((x) & 0x00002000) >> 13)
-#define PHY_ANALOG_TXRF10_PDOUT5G_3CALTX_SET(x)                                      (((x) << 13) & 0x00002000)
-#define PHY_ANALOG_TXRF10_D3B5GCALTX_MSB                                                                     16
-#define PHY_ANALOG_TXRF10_D3B5GCALTX_LSB                                                                     14
-#define PHY_ANALOG_TXRF10_D3B5GCALTX_MASK                                                            0x0001c000
-#define PHY_ANALOG_TXRF10_D3B5GCALTX_GET(x)                                          (((x) & 0x0001c000) >> 14)
-#define PHY_ANALOG_TXRF10_D3B5GCALTX_SET(x)                                          (((x) << 14) & 0x0001c000)
-#define PHY_ANALOG_TXRF10_D4B5GCALTX_MSB                                                                     19
-#define PHY_ANALOG_TXRF10_D4B5GCALTX_LSB                                                                     17
-#define PHY_ANALOG_TXRF10_D4B5GCALTX_MASK                                                            0x000e0000
-#define PHY_ANALOG_TXRF10_D4B5GCALTX_GET(x)                                          (((x) & 0x000e0000) >> 17)
-#define PHY_ANALOG_TXRF10_D4B5GCALTX_SET(x)                                          (((x) << 17) & 0x000e0000)
-#define PHY_ANALOG_TXRF10_PADRVGN2GCALTX_MSB                                                                 26
-#define PHY_ANALOG_TXRF10_PADRVGN2GCALTX_LSB                                                                 20
-#define PHY_ANALOG_TXRF10_PADRVGN2GCALTX_MASK                                                        0x07f00000
-#define PHY_ANALOG_TXRF10_PADRVGN2GCALTX_GET(x)                                      (((x) & 0x07f00000) >> 20)
-#define PHY_ANALOG_TXRF10_PADRVGN2GCALTX_SET(x)                                      (((x) << 20) & 0x07f00000)
-#define PHY_ANALOG_TXRF10_DB2GCALTX_MSB                                                                      29
-#define PHY_ANALOG_TXRF10_DB2GCALTX_LSB                                                                      27
-#define PHY_ANALOG_TXRF10_DB2GCALTX_MASK                                                             0x38000000
-#define PHY_ANALOG_TXRF10_DB2GCALTX_GET(x)                                           (((x) & 0x38000000) >> 27)
-#define PHY_ANALOG_TXRF10_DB2GCALTX_SET(x)                                           (((x) << 27) & 0x38000000)
-#define PHY_ANALOG_TXRF10_CALTXSHIFT_MSB                                                                     30
-#define PHY_ANALOG_TXRF10_CALTXSHIFT_LSB                                                                     30
-#define PHY_ANALOG_TXRF10_CALTXSHIFT_MASK                                                            0x40000000
-#define PHY_ANALOG_TXRF10_CALTXSHIFT_GET(x)                                          (((x) & 0x40000000) >> 30)
-#define PHY_ANALOG_TXRF10_CALTXSHIFT_SET(x)                                          (((x) << 30) & 0x40000000)
-#define PHY_ANALOG_TXRF10_CALTXSHIFTOVR_MSB                                                                  31
-#define PHY_ANALOG_TXRF10_CALTXSHIFTOVR_LSB                                                                  31
-#define PHY_ANALOG_TXRF10_CALTXSHIFTOVR_MASK                                                         0x80000000
-#define PHY_ANALOG_TXRF10_CALTXSHIFTOVR_GET(x)                                       (((x) & 0x80000000) >> 31)
-#define PHY_ANALOG_TXRF10_CALTXSHIFTOVR_SET(x)                                       (((x) << 31) & 0x80000000)
-
-/* macros for TXRF11 */
-#define PHY_ANALOG_TXRF11_ADDRESS                                                                    0x00000068
-#define PHY_ANALOG_TXRF11_OFFSET                                                                     0x00000068
-#define PHY_ANALOG_TXRF11_SPARE11_MSB                                                                         1
-#define PHY_ANALOG_TXRF11_SPARE11_LSB                                                                         0
-#define PHY_ANALOG_TXRF11_SPARE11_MASK                                                               0x00000003
-#define PHY_ANALOG_TXRF11_SPARE11_GET(x)                                              (((x) & 0x00000003) >> 0)
-#define PHY_ANALOG_TXRF11_SPARE11_SET(x)                                              (((x) << 0) & 0x00000003)
-#define PHY_ANALOG_TXRF11_PWD_IR25MIXBIAS5G_MSB                                                               4
-#define PHY_ANALOG_TXRF11_PWD_IR25MIXBIAS5G_LSB                                                               2
-#define PHY_ANALOG_TXRF11_PWD_IR25MIXBIAS5G_MASK                                                     0x0000001c
-#define PHY_ANALOG_TXRF11_PWD_IR25MIXBIAS5G_GET(x)                                    (((x) & 0x0000001c) >> 2)
-#define PHY_ANALOG_TXRF11_PWD_IR25MIXBIAS5G_SET(x)                                    (((x) << 2) & 0x0000001c)
-#define PHY_ANALOG_TXRF11_PWD_IR25MIXDIV5G_MSB                                                                7
-#define PHY_ANALOG_TXRF11_PWD_IR25MIXDIV5G_LSB                                                                5
-#define PHY_ANALOG_TXRF11_PWD_IR25MIXDIV5G_MASK                                                      0x000000e0
-#define PHY_ANALOG_TXRF11_PWD_IR25MIXDIV5G_GET(x)                                     (((x) & 0x000000e0) >> 5)
-#define PHY_ANALOG_TXRF11_PWD_IR25MIXDIV5G_SET(x)                                     (((x) << 5) & 0x000000e0)
-#define PHY_ANALOG_TXRF11_PWD_IR25PA2G_MSB                                                                   10
-#define PHY_ANALOG_TXRF11_PWD_IR25PA2G_LSB                                                                    8
-#define PHY_ANALOG_TXRF11_PWD_IR25PA2G_MASK                                                          0x00000700
-#define PHY_ANALOG_TXRF11_PWD_IR25PA2G_GET(x)                                         (((x) & 0x00000700) >> 8)
-#define PHY_ANALOG_TXRF11_PWD_IR25PA2G_SET(x)                                         (((x) << 8) & 0x00000700)
-#define PHY_ANALOG_TXRF11_PWD_IR25MIXBIAS2G_MSB                                                              13
-#define PHY_ANALOG_TXRF11_PWD_IR25MIXBIAS2G_LSB                                                              11
-#define PHY_ANALOG_TXRF11_PWD_IR25MIXBIAS2G_MASK                                                     0x00003800
-#define PHY_ANALOG_TXRF11_PWD_IR25MIXBIAS2G_GET(x)                                   (((x) & 0x00003800) >> 11)
-#define PHY_ANALOG_TXRF11_PWD_IR25MIXBIAS2G_SET(x)                                   (((x) << 11) & 0x00003800)
-#define PHY_ANALOG_TXRF11_PWD_IR25MIXDIV2G_MSB                                                               16
-#define PHY_ANALOG_TXRF11_PWD_IR25MIXDIV2G_LSB                                                               14
-#define PHY_ANALOG_TXRF11_PWD_IR25MIXDIV2G_MASK                                                      0x0001c000
-#define PHY_ANALOG_TXRF11_PWD_IR25MIXDIV2G_GET(x)                                    (((x) & 0x0001c000) >> 14)
-#define PHY_ANALOG_TXRF11_PWD_IR25MIXDIV2G_SET(x)                                    (((x) << 14) & 0x0001c000)
-#define PHY_ANALOG_TXRF11_PWD_ICSPARE_MSB                                                                    19
-#define PHY_ANALOG_TXRF11_PWD_ICSPARE_LSB                                                                    17
-#define PHY_ANALOG_TXRF11_PWD_ICSPARE_MASK                                                           0x000e0000
-#define PHY_ANALOG_TXRF11_PWD_ICSPARE_GET(x)                                         (((x) & 0x000e0000) >> 17)
-#define PHY_ANALOG_TXRF11_PWD_ICSPARE_SET(x)                                         (((x) << 17) & 0x000e0000)
-#define PHY_ANALOG_TXRF11_PWD_IC25PA5G2_MSB                                                                  22
-#define PHY_ANALOG_TXRF11_PWD_IC25PA5G2_LSB                                                                  20
-#define PHY_ANALOG_TXRF11_PWD_IC25PA5G2_MASK                                                         0x00700000
-#define PHY_ANALOG_TXRF11_PWD_IC25PA5G2_GET(x)                                       (((x) & 0x00700000) >> 20)
-#define PHY_ANALOG_TXRF11_PWD_IC25PA5G2_SET(x)                                       (((x) << 20) & 0x00700000)
-#define PHY_ANALOG_TXRF11_PWD_IC25PA5G1_MSB                                                                  25
-#define PHY_ANALOG_TXRF11_PWD_IC25PA5G1_LSB                                                                  23
-#define PHY_ANALOG_TXRF11_PWD_IC25PA5G1_MASK                                                         0x03800000
-#define PHY_ANALOG_TXRF11_PWD_IC25PA5G1_GET(x)                                       (((x) & 0x03800000) >> 23)
-#define PHY_ANALOG_TXRF11_PWD_IC25PA5G1_SET(x)                                       (((x) << 23) & 0x03800000)
-#define PHY_ANALOG_TXRF11_PWD_IC25MIXBUF5G_MSB                                                               28
-#define PHY_ANALOG_TXRF11_PWD_IC25MIXBUF5G_LSB                                                               26
-#define PHY_ANALOG_TXRF11_PWD_IC25MIXBUF5G_MASK                                                      0x1c000000
-#define PHY_ANALOG_TXRF11_PWD_IC25MIXBUF5G_GET(x)                                    (((x) & 0x1c000000) >> 26)
-#define PHY_ANALOG_TXRF11_PWD_IC25MIXBUF5G_SET(x)                                    (((x) << 26) & 0x1c000000)
-#define PHY_ANALOG_TXRF11_PWD_IC25PA2G_MSB                                                                   31
-#define PHY_ANALOG_TXRF11_PWD_IC25PA2G_LSB                                                                   29
-#define PHY_ANALOG_TXRF11_PWD_IC25PA2G_MASK                                                          0xe0000000
-#define PHY_ANALOG_TXRF11_PWD_IC25PA2G_GET(x)                                        (((x) & 0xe0000000) >> 29)
-#define PHY_ANALOG_TXRF11_PWD_IC25PA2G_SET(x)                                        (((x) << 29) & 0xe0000000)
-
-/* macros for TXRF12 */
-#define PHY_ANALOG_TXRF12_ADDRESS                                                                    0x0000006c
-#define PHY_ANALOG_TXRF12_OFFSET                                                                     0x0000006c
-#define PHY_ANALOG_TXRF12_SPARE12_2_MSB                                                                       7
-#define PHY_ANALOG_TXRF12_SPARE12_2_LSB                                                                       0
-#define PHY_ANALOG_TXRF12_SPARE12_2_MASK                                                             0x000000ff
-#define PHY_ANALOG_TXRF12_SPARE12_2_GET(x)                                            (((x) & 0x000000ff) >> 0)
-#define PHY_ANALOG_TXRF12_SPARE12_1_MSB                                                                      15
-#define PHY_ANALOG_TXRF12_SPARE12_1_LSB                                                                       8
-#define PHY_ANALOG_TXRF12_SPARE12_1_MASK                                                             0x0000ff00
-#define PHY_ANALOG_TXRF12_SPARE12_1_GET(x)                                            (((x) & 0x0000ff00) >> 8)
-#define PHY_ANALOG_TXRF12_SPARE12_1_SET(x)                                            (((x) << 8) & 0x0000ff00)
-#define PHY_ANALOG_TXRF12_ATBSEL5G_MSB                                                                       19
-#define PHY_ANALOG_TXRF12_ATBSEL5G_LSB                                                                       16
-#define PHY_ANALOG_TXRF12_ATBSEL5G_MASK                                                              0x000f0000
-#define PHY_ANALOG_TXRF12_ATBSEL5G_GET(x)                                            (((x) & 0x000f0000) >> 16)
-#define PHY_ANALOG_TXRF12_ATBSEL5G_SET(x)                                            (((x) << 16) & 0x000f0000)
-#define PHY_ANALOG_TXRF12_ATBSEL2G_MSB                                                                       22
-#define PHY_ANALOG_TXRF12_ATBSEL2G_LSB                                                                       20
-#define PHY_ANALOG_TXRF12_ATBSEL2G_MASK                                                              0x00700000
-#define PHY_ANALOG_TXRF12_ATBSEL2G_GET(x)                                            (((x) & 0x00700000) >> 20)
-#define PHY_ANALOG_TXRF12_ATBSEL2G_SET(x)                                            (((x) << 20) & 0x00700000)
-#define PHY_ANALOG_TXRF12_PWD_IRSPARE_MSB                                                                    25
-#define PHY_ANALOG_TXRF12_PWD_IRSPARE_LSB                                                                    23
-#define PHY_ANALOG_TXRF12_PWD_IRSPARE_MASK                                                           0x03800000
-#define PHY_ANALOG_TXRF12_PWD_IRSPARE_GET(x)                                         (((x) & 0x03800000) >> 23)
-#define PHY_ANALOG_TXRF12_PWD_IRSPARE_SET(x)                                         (((x) << 23) & 0x03800000)
-#define PHY_ANALOG_TXRF12_PWD_IR25PA5G2_MSB                                                                  28
-#define PHY_ANALOG_TXRF12_PWD_IR25PA5G2_LSB                                                                  26
-#define PHY_ANALOG_TXRF12_PWD_IR25PA5G2_MASK                                                         0x1c000000
-#define PHY_ANALOG_TXRF12_PWD_IR25PA5G2_GET(x)                                       (((x) & 0x1c000000) >> 26)
-#define PHY_ANALOG_TXRF12_PWD_IR25PA5G2_SET(x)                                       (((x) << 26) & 0x1c000000)
-#define PHY_ANALOG_TXRF12_PWD_IR25PA5G1_MSB                                                                  31
-#define PHY_ANALOG_TXRF12_PWD_IR25PA5G1_LSB                                                                  29
-#define PHY_ANALOG_TXRF12_PWD_IR25PA5G1_MASK                                                         0xe0000000
-#define PHY_ANALOG_TXRF12_PWD_IR25PA5G1_GET(x)                                       (((x) & 0xe0000000) >> 29)
-#define PHY_ANALOG_TXRF12_PWD_IR25PA5G1_SET(x)                                       (((x) << 29) & 0xe0000000)
-
-/* macros for SYNTH1 */
-#define PHY_ANALOG_SYNTH1_ADDRESS                                                                    0x00000080
-#define PHY_ANALOG_SYNTH1_OFFSET                                                                     0x00000080
-#define PHY_ANALOG_SYNTH1_SEL_VCMONABUS_MSB                                                                   2
-#define PHY_ANALOG_SYNTH1_SEL_VCMONABUS_LSB                                                                   0
-#define PHY_ANALOG_SYNTH1_SEL_VCMONABUS_MASK                                                         0x00000007
-#define PHY_ANALOG_SYNTH1_SEL_VCMONABUS_GET(x)                                        (((x) & 0x00000007) >> 0)
-#define PHY_ANALOG_SYNTH1_SEL_VCMONABUS_SET(x)                                        (((x) << 0) & 0x00000007)
-#define PHY_ANALOG_SYNTH1_SEL_VCOABUS_MSB                                                                     5
-#define PHY_ANALOG_SYNTH1_SEL_VCOABUS_LSB                                                                     3
-#define PHY_ANALOG_SYNTH1_SEL_VCOABUS_MASK                                                           0x00000038
-#define PHY_ANALOG_SYNTH1_SEL_VCOABUS_GET(x)                                          (((x) & 0x00000038) >> 3)
-#define PHY_ANALOG_SYNTH1_SEL_VCOABUS_SET(x)                                          (((x) << 3) & 0x00000038)
-#define PHY_ANALOG_SYNTH1_MONITOR_SYNTHLOCKVCOK_MSB                                                           6
-#define PHY_ANALOG_SYNTH1_MONITOR_SYNTHLOCKVCOK_LSB                                                           6
-#define PHY_ANALOG_SYNTH1_MONITOR_SYNTHLOCKVCOK_MASK                                                 0x00000040
-#define PHY_ANALOG_SYNTH1_MONITOR_SYNTHLOCKVCOK_GET(x)                                (((x) & 0x00000040) >> 6)
-#define PHY_ANALOG_SYNTH1_MONITOR_SYNTHLOCKVCOK_SET(x)                                (((x) << 6) & 0x00000040)
-#define PHY_ANALOG_SYNTH1_MONITOR_VC2LOW_MSB                                                                  7
-#define PHY_ANALOG_SYNTH1_MONITOR_VC2LOW_LSB                                                                  7
-#define PHY_ANALOG_SYNTH1_MONITOR_VC2LOW_MASK                                                        0x00000080
-#define PHY_ANALOG_SYNTH1_MONITOR_VC2LOW_GET(x)                                       (((x) & 0x00000080) >> 7)
-#define PHY_ANALOG_SYNTH1_MONITOR_VC2LOW_SET(x)                                       (((x) << 7) & 0x00000080)
-#define PHY_ANALOG_SYNTH1_MONITOR_VC2HIGH_MSB                                                                 8
-#define PHY_ANALOG_SYNTH1_MONITOR_VC2HIGH_LSB                                                                 8
-#define PHY_ANALOG_SYNTH1_MONITOR_VC2HIGH_MASK                                                       0x00000100
-#define PHY_ANALOG_SYNTH1_MONITOR_VC2HIGH_GET(x)                                      (((x) & 0x00000100) >> 8)
-#define PHY_ANALOG_SYNTH1_MONITOR_VC2HIGH_SET(x)                                      (((x) << 8) & 0x00000100)
-#define PHY_ANALOG_SYNTH1_MONITOR_FB_DIV2_MSB                                                                 9
-#define PHY_ANALOG_SYNTH1_MONITOR_FB_DIV2_LSB                                                                 9
-#define PHY_ANALOG_SYNTH1_MONITOR_FB_DIV2_MASK                                                       0x00000200
-#define PHY_ANALOG_SYNTH1_MONITOR_FB_DIV2_GET(x)                                      (((x) & 0x00000200) >> 9)
-#define PHY_ANALOG_SYNTH1_MONITOR_FB_DIV2_SET(x)                                      (((x) << 9) & 0x00000200)
-#define PHY_ANALOG_SYNTH1_MONITOR_REF_MSB                                                                    10
-#define PHY_ANALOG_SYNTH1_MONITOR_REF_LSB                                                                    10
-#define PHY_ANALOG_SYNTH1_MONITOR_REF_MASK                                                           0x00000400
-#define PHY_ANALOG_SYNTH1_MONITOR_REF_GET(x)                                         (((x) & 0x00000400) >> 10)
-#define PHY_ANALOG_SYNTH1_MONITOR_REF_SET(x)                                         (((x) << 10) & 0x00000400)
-#define PHY_ANALOG_SYNTH1_MONITOR_FB_MSB                                                                     11
-#define PHY_ANALOG_SYNTH1_MONITOR_FB_LSB                                                                     11
-#define PHY_ANALOG_SYNTH1_MONITOR_FB_MASK                                                            0x00000800
-#define PHY_ANALOG_SYNTH1_MONITOR_FB_GET(x)                                          (((x) & 0x00000800) >> 11)
-#define PHY_ANALOG_SYNTH1_MONITOR_FB_SET(x)                                          (((x) << 11) & 0x00000800)
-#define PHY_ANALOG_SYNTH1_SEVENBITVCOCAP_MSB                                                                 12
-#define PHY_ANALOG_SYNTH1_SEVENBITVCOCAP_LSB                                                                 12
-#define PHY_ANALOG_SYNTH1_SEVENBITVCOCAP_MASK                                                        0x00001000
-#define PHY_ANALOG_SYNTH1_SEVENBITVCOCAP_GET(x)                                      (((x) & 0x00001000) >> 12)
-#define PHY_ANALOG_SYNTH1_SEVENBITVCOCAP_SET(x)                                      (((x) << 12) & 0x00001000)
-#define PHY_ANALOG_SYNTH1_PWUP_PD_MSB                                                                        15
-#define PHY_ANALOG_SYNTH1_PWUP_PD_LSB                                                                        13
-#define PHY_ANALOG_SYNTH1_PWUP_PD_MASK                                                               0x0000e000
-#define PHY_ANALOG_SYNTH1_PWUP_PD_GET(x)                                             (((x) & 0x0000e000) >> 13)
-#define PHY_ANALOG_SYNTH1_PWUP_PD_SET(x)                                             (((x) << 13) & 0x0000e000)
-#define PHY_ANALOG_SYNTH1_PWD_VCOBUF_MSB                                                                     16
-#define PHY_ANALOG_SYNTH1_PWD_VCOBUF_LSB                                                                     16
-#define PHY_ANALOG_SYNTH1_PWD_VCOBUF_MASK                                                            0x00010000
-#define PHY_ANALOG_SYNTH1_PWD_VCOBUF_GET(x)                                          (((x) & 0x00010000) >> 16)
-#define PHY_ANALOG_SYNTH1_PWD_VCOBUF_SET(x)                                          (((x) << 16) & 0x00010000)
-#define PHY_ANALOG_SYNTH1_VCOBUFGAIN_MSB                                                                     18
-#define PHY_ANALOG_SYNTH1_VCOBUFGAIN_LSB                                                                     17
-#define PHY_ANALOG_SYNTH1_VCOBUFGAIN_MASK                                                            0x00060000
-#define PHY_ANALOG_SYNTH1_VCOBUFGAIN_GET(x)                                          (((x) & 0x00060000) >> 17)
-#define PHY_ANALOG_SYNTH1_VCOBUFGAIN_SET(x)                                          (((x) << 17) & 0x00060000)
-#define PHY_ANALOG_SYNTH1_VCOREGLEVEL_MSB                                                                    20
-#define PHY_ANALOG_SYNTH1_VCOREGLEVEL_LSB                                                                    19
-#define PHY_ANALOG_SYNTH1_VCOREGLEVEL_MASK                                                           0x00180000
-#define PHY_ANALOG_SYNTH1_VCOREGLEVEL_GET(x)                                         (((x) & 0x00180000) >> 19)
-#define PHY_ANALOG_SYNTH1_VCOREGLEVEL_SET(x)                                         (((x) << 19) & 0x00180000)
-#define PHY_ANALOG_SYNTH1_VCOREGBYPASS_MSB                                                                   21
-#define PHY_ANALOG_SYNTH1_VCOREGBYPASS_LSB                                                                   21
-#define PHY_ANALOG_SYNTH1_VCOREGBYPASS_MASK                                                          0x00200000
-#define PHY_ANALOG_SYNTH1_VCOREGBYPASS_GET(x)                                        (((x) & 0x00200000) >> 21)
-#define PHY_ANALOG_SYNTH1_VCOREGBYPASS_SET(x)                                        (((x) << 21) & 0x00200000)
-#define PHY_ANALOG_SYNTH1_PWUP_LOREF_MSB                                                                     22
-#define PHY_ANALOG_SYNTH1_PWUP_LOREF_LSB                                                                     22
-#define PHY_ANALOG_SYNTH1_PWUP_LOREF_MASK                                                            0x00400000
-#define PHY_ANALOG_SYNTH1_PWUP_LOREF_GET(x)                                          (((x) & 0x00400000) >> 22)
-#define PHY_ANALOG_SYNTH1_PWUP_LOREF_SET(x)                                          (((x) << 22) & 0x00400000)
-#define PHY_ANALOG_SYNTH1_PWD_LOMIX_MSB                                                                      23
-#define PHY_ANALOG_SYNTH1_PWD_LOMIX_LSB                                                                      23
-#define PHY_ANALOG_SYNTH1_PWD_LOMIX_MASK                                                             0x00800000
-#define PHY_ANALOG_SYNTH1_PWD_LOMIX_GET(x)                                           (((x) & 0x00800000) >> 23)
-#define PHY_ANALOG_SYNTH1_PWD_LOMIX_SET(x)                                           (((x) << 23) & 0x00800000)
-#define PHY_ANALOG_SYNTH1_PWD_LODIV_MSB                                                                      24
-#define PHY_ANALOG_SYNTH1_PWD_LODIV_LSB                                                                      24
-#define PHY_ANALOG_SYNTH1_PWD_LODIV_MASK                                                             0x01000000
-#define PHY_ANALOG_SYNTH1_PWD_LODIV_GET(x)                                           (((x) & 0x01000000) >> 24)
-#define PHY_ANALOG_SYNTH1_PWD_LODIV_SET(x)                                           (((x) << 24) & 0x01000000)
-#define PHY_ANALOG_SYNTH1_PWD_LOBUF5G_MSB                                                                    25
-#define PHY_ANALOG_SYNTH1_PWD_LOBUF5G_LSB                                                                    25
-#define PHY_ANALOG_SYNTH1_PWD_LOBUF5G_MASK                                                           0x02000000
-#define PHY_ANALOG_SYNTH1_PWD_LOBUF5G_GET(x)                                         (((x) & 0x02000000) >> 25)
-#define PHY_ANALOG_SYNTH1_PWD_LOBUF5G_SET(x)                                         (((x) << 25) & 0x02000000)
-#define PHY_ANALOG_SYNTH1_PWD_LOBUF2G_MSB                                                                    26
-#define PHY_ANALOG_SYNTH1_PWD_LOBUF2G_LSB                                                                    26
-#define PHY_ANALOG_SYNTH1_PWD_LOBUF2G_MASK                                                           0x04000000
-#define PHY_ANALOG_SYNTH1_PWD_LOBUF2G_GET(x)                                         (((x) & 0x04000000) >> 26)
-#define PHY_ANALOG_SYNTH1_PWD_LOBUF2G_SET(x)                                         (((x) << 26) & 0x04000000)
-#define PHY_ANALOG_SYNTH1_PWD_PRESC_MSB                                                                      27
-#define PHY_ANALOG_SYNTH1_PWD_PRESC_LSB                                                                      27
-#define PHY_ANALOG_SYNTH1_PWD_PRESC_MASK                                                             0x08000000
-#define PHY_ANALOG_SYNTH1_PWD_PRESC_GET(x)                                           (((x) & 0x08000000) >> 27)
-#define PHY_ANALOG_SYNTH1_PWD_PRESC_SET(x)                                           (((x) << 27) & 0x08000000)
-#define PHY_ANALOG_SYNTH1_PWD_VCO_MSB                                                                        28
-#define PHY_ANALOG_SYNTH1_PWD_VCO_LSB                                                                        28
-#define PHY_ANALOG_SYNTH1_PWD_VCO_MASK                                                               0x10000000
-#define PHY_ANALOG_SYNTH1_PWD_VCO_GET(x)                                             (((x) & 0x10000000) >> 28)
-#define PHY_ANALOG_SYNTH1_PWD_VCO_SET(x)                                             (((x) << 28) & 0x10000000)
-#define PHY_ANALOG_SYNTH1_PWD_VCMON_MSB                                                                      29
-#define PHY_ANALOG_SYNTH1_PWD_VCMON_LSB                                                                      29
-#define PHY_ANALOG_SYNTH1_PWD_VCMON_MASK                                                             0x20000000
-#define PHY_ANALOG_SYNTH1_PWD_VCMON_GET(x)                                           (((x) & 0x20000000) >> 29)
-#define PHY_ANALOG_SYNTH1_PWD_VCMON_SET(x)                                           (((x) << 29) & 0x20000000)
-#define PHY_ANALOG_SYNTH1_PWD_CP_MSB                                                                         30
-#define PHY_ANALOG_SYNTH1_PWD_CP_LSB                                                                         30
-#define PHY_ANALOG_SYNTH1_PWD_CP_MASK                                                                0x40000000
-#define PHY_ANALOG_SYNTH1_PWD_CP_GET(x)                                              (((x) & 0x40000000) >> 30)
-#define PHY_ANALOG_SYNTH1_PWD_CP_SET(x)                                              (((x) << 30) & 0x40000000)
-#define PHY_ANALOG_SYNTH1_PWD_BIAS_MSB                                                                       31
-#define PHY_ANALOG_SYNTH1_PWD_BIAS_LSB                                                                       31
-#define PHY_ANALOG_SYNTH1_PWD_BIAS_MASK                                                              0x80000000
-#define PHY_ANALOG_SYNTH1_PWD_BIAS_GET(x)                                            (((x) & 0x80000000) >> 31)
-#define PHY_ANALOG_SYNTH1_PWD_BIAS_SET(x)                                            (((x) << 31) & 0x80000000)
-
-/* macros for SYNTH2 */
-#define PHY_ANALOG_SYNTH2_ADDRESS                                                                    0x00000084
-#define PHY_ANALOG_SYNTH2_OFFSET                                                                     0x00000084
-#define PHY_ANALOG_SYNTH2_CAPRANGE3_MSB                                                                       3
-#define PHY_ANALOG_SYNTH2_CAPRANGE3_LSB                                                                       0
-#define PHY_ANALOG_SYNTH2_CAPRANGE3_MASK                                                             0x0000000f
-#define PHY_ANALOG_SYNTH2_CAPRANGE3_GET(x)                                            (((x) & 0x0000000f) >> 0)
-#define PHY_ANALOG_SYNTH2_CAPRANGE3_SET(x)                                            (((x) << 0) & 0x0000000f)
-#define PHY_ANALOG_SYNTH2_CAPRANGE2_MSB                                                                       7
-#define PHY_ANALOG_SYNTH2_CAPRANGE2_LSB                                                                       4
-#define PHY_ANALOG_SYNTH2_CAPRANGE2_MASK                                                             0x000000f0
-#define PHY_ANALOG_SYNTH2_CAPRANGE2_GET(x)                                            (((x) & 0x000000f0) >> 4)
-#define PHY_ANALOG_SYNTH2_CAPRANGE2_SET(x)                                            (((x) << 4) & 0x000000f0)
-#define PHY_ANALOG_SYNTH2_CAPRANGE1_MSB                                                                      11
-#define PHY_ANALOG_SYNTH2_CAPRANGE1_LSB                                                                       8
-#define PHY_ANALOG_SYNTH2_CAPRANGE1_MASK                                                             0x00000f00
-#define PHY_ANALOG_SYNTH2_CAPRANGE1_GET(x)                                            (((x) & 0x00000f00) >> 8)
-#define PHY_ANALOG_SYNTH2_CAPRANGE1_SET(x)                                            (((x) << 8) & 0x00000f00)
-#define PHY_ANALOG_SYNTH2_LOOPLEAKCUR_MSB                                                                    15
-#define PHY_ANALOG_SYNTH2_LOOPLEAKCUR_LSB                                                                    12
-#define PHY_ANALOG_SYNTH2_LOOPLEAKCUR_MASK                                                           0x0000f000
-#define PHY_ANALOG_SYNTH2_LOOPLEAKCUR_GET(x)                                         (((x) & 0x0000f000) >> 12)
-#define PHY_ANALOG_SYNTH2_LOOPLEAKCUR_SET(x)                                         (((x) << 12) & 0x0000f000)
-#define PHY_ANALOG_SYNTH2_CPLOWLK_MSB                                                                        16
-#define PHY_ANALOG_SYNTH2_CPLOWLK_LSB                                                                        16
-#define PHY_ANALOG_SYNTH2_CPLOWLK_MASK                                                               0x00010000
-#define PHY_ANALOG_SYNTH2_CPLOWLK_GET(x)                                             (((x) & 0x00010000) >> 16)
-#define PHY_ANALOG_SYNTH2_CPLOWLK_SET(x)                                             (((x) << 16) & 0x00010000)
-#define PHY_ANALOG_SYNTH2_CPSTEERING_EN_INTN_MSB                                                             17
-#define PHY_ANALOG_SYNTH2_CPSTEERING_EN_INTN_LSB                                                             17
-#define PHY_ANALOG_SYNTH2_CPSTEERING_EN_INTN_MASK                                                    0x00020000
-#define PHY_ANALOG_SYNTH2_CPSTEERING_EN_INTN_GET(x)                                  (((x) & 0x00020000) >> 17)
-#define PHY_ANALOG_SYNTH2_CPSTEERING_EN_INTN_SET(x)                                  (((x) << 17) & 0x00020000)
-#define PHY_ANALOG_SYNTH2_CPBIAS_MSB                                                                         19
-#define PHY_ANALOG_SYNTH2_CPBIAS_LSB                                                                         18
-#define PHY_ANALOG_SYNTH2_CPBIAS_MASK                                                                0x000c0000
-#define PHY_ANALOG_SYNTH2_CPBIAS_GET(x)                                              (((x) & 0x000c0000) >> 18)
-#define PHY_ANALOG_SYNTH2_CPBIAS_SET(x)                                              (((x) << 18) & 0x000c0000)
-#define PHY_ANALOG_SYNTH2_VC_LOW_REF_MSB                                                                     22
-#define PHY_ANALOG_SYNTH2_VC_LOW_REF_LSB                                                                     20
-#define PHY_ANALOG_SYNTH2_VC_LOW_REF_MASK                                                            0x00700000
-#define PHY_ANALOG_SYNTH2_VC_LOW_REF_GET(x)                                          (((x) & 0x00700000) >> 20)
-#define PHY_ANALOG_SYNTH2_VC_LOW_REF_SET(x)                                          (((x) << 20) & 0x00700000)
-#define PHY_ANALOG_SYNTH2_VC_MID_REF_MSB                                                                     25
-#define PHY_ANALOG_SYNTH2_VC_MID_REF_LSB                                                                     23
-#define PHY_ANALOG_SYNTH2_VC_MID_REF_MASK                                                            0x03800000
-#define PHY_ANALOG_SYNTH2_VC_MID_REF_GET(x)                                          (((x) & 0x03800000) >> 23)
-#define PHY_ANALOG_SYNTH2_VC_MID_REF_SET(x)                                          (((x) << 23) & 0x03800000)
-#define PHY_ANALOG_SYNTH2_VC_HI_REF_MSB                                                                      28
-#define PHY_ANALOG_SYNTH2_VC_HI_REF_LSB                                                                      26
-#define PHY_ANALOG_SYNTH2_VC_HI_REF_MASK                                                             0x1c000000
-#define PHY_ANALOG_SYNTH2_VC_HI_REF_GET(x)                                           (((x) & 0x1c000000) >> 26)
-#define PHY_ANALOG_SYNTH2_VC_HI_REF_SET(x)                                           (((x) << 26) & 0x1c000000)
-#define PHY_ANALOG_SYNTH2_VC_CAL_REF_MSB                                                                     31
-#define PHY_ANALOG_SYNTH2_VC_CAL_REF_LSB                                                                     29
-#define PHY_ANALOG_SYNTH2_VC_CAL_REF_MASK                                                            0xe0000000
-#define PHY_ANALOG_SYNTH2_VC_CAL_REF_GET(x)                                          (((x) & 0xe0000000) >> 29)
-#define PHY_ANALOG_SYNTH2_VC_CAL_REF_SET(x)                                          (((x) << 29) & 0xe0000000)
-
-/* macros for SYNTH3 */
-#define PHY_ANALOG_SYNTH3_ADDRESS                                                                    0x00000088
-#define PHY_ANALOG_SYNTH3_OFFSET                                                                     0x00000088
-#define PHY_ANALOG_SYNTH3_WAIT_VC_CHECK_MSB                                                                   5
-#define PHY_ANALOG_SYNTH3_WAIT_VC_CHECK_LSB                                                                   0
-#define PHY_ANALOG_SYNTH3_WAIT_VC_CHECK_MASK                                                         0x0000003f
-#define PHY_ANALOG_SYNTH3_WAIT_VC_CHECK_GET(x)                                        (((x) & 0x0000003f) >> 0)
-#define PHY_ANALOG_SYNTH3_WAIT_VC_CHECK_SET(x)                                        (((x) << 0) & 0x0000003f)
-#define PHY_ANALOG_SYNTH3_WAIT_CAL_LIN_MSB                                                                   11
-#define PHY_ANALOG_SYNTH3_WAIT_CAL_LIN_LSB                                                                    6
-#define PHY_ANALOG_SYNTH3_WAIT_CAL_LIN_MASK                                                          0x00000fc0
-#define PHY_ANALOG_SYNTH3_WAIT_CAL_LIN_GET(x)                                         (((x) & 0x00000fc0) >> 6)
-#define PHY_ANALOG_SYNTH3_WAIT_CAL_LIN_SET(x)                                         (((x) << 6) & 0x00000fc0)
-#define PHY_ANALOG_SYNTH3_WAIT_CAL_BIN_MSB                                                                   17
-#define PHY_ANALOG_SYNTH3_WAIT_CAL_BIN_LSB                                                                   12
-#define PHY_ANALOG_SYNTH3_WAIT_CAL_BIN_MASK                                                          0x0003f000
-#define PHY_ANALOG_SYNTH3_WAIT_CAL_BIN_GET(x)                                        (((x) & 0x0003f000) >> 12)
-#define PHY_ANALOG_SYNTH3_WAIT_CAL_BIN_SET(x)                                        (((x) << 12) & 0x0003f000)
-#define PHY_ANALOG_SYNTH3_WAIT_PWRUP_MSB                                                                     23
-#define PHY_ANALOG_SYNTH3_WAIT_PWRUP_LSB                                                                     18
-#define PHY_ANALOG_SYNTH3_WAIT_PWRUP_MASK                                                            0x00fc0000
-#define PHY_ANALOG_SYNTH3_WAIT_PWRUP_GET(x)                                          (((x) & 0x00fc0000) >> 18)
-#define PHY_ANALOG_SYNTH3_WAIT_PWRUP_SET(x)                                          (((x) << 18) & 0x00fc0000)
-#define PHY_ANALOG_SYNTH3_WAIT_SHORTR_PWRUP_MSB                                                              29
-#define PHY_ANALOG_SYNTH3_WAIT_SHORTR_PWRUP_LSB                                                              24
-#define PHY_ANALOG_SYNTH3_WAIT_SHORTR_PWRUP_MASK                                                     0x3f000000
-#define PHY_ANALOG_SYNTH3_WAIT_SHORTR_PWRUP_GET(x)                                   (((x) & 0x3f000000) >> 24)
-#define PHY_ANALOG_SYNTH3_WAIT_SHORTR_PWRUP_SET(x)                                   (((x) << 24) & 0x3f000000)
-#define PHY_ANALOG_SYNTH3_SEL_CLK_DIV2_MSB                                                                   30
-#define PHY_ANALOG_SYNTH3_SEL_CLK_DIV2_LSB                                                                   30
-#define PHY_ANALOG_SYNTH3_SEL_CLK_DIV2_MASK                                                          0x40000000
-#define PHY_ANALOG_SYNTH3_SEL_CLK_DIV2_GET(x)                                        (((x) & 0x40000000) >> 30)
-#define PHY_ANALOG_SYNTH3_SEL_CLK_DIV2_SET(x)                                        (((x) << 30) & 0x40000000)
-#define PHY_ANALOG_SYNTH3_DIS_CLK_XTAL_MSB                                                                   31
-#define PHY_ANALOG_SYNTH3_DIS_CLK_XTAL_LSB                                                                   31
-#define PHY_ANALOG_SYNTH3_DIS_CLK_XTAL_MASK                                                          0x80000000
-#define PHY_ANALOG_SYNTH3_DIS_CLK_XTAL_GET(x)                                        (((x) & 0x80000000) >> 31)
-#define PHY_ANALOG_SYNTH3_DIS_CLK_XTAL_SET(x)                                        (((x) << 31) & 0x80000000)
-
-/* macros for SYNTH4 */
-#define PHY_ANALOG_SYNTH4_ADDRESS                                                                    0x0000008c
-#define PHY_ANALOG_SYNTH4_OFFSET                                                                     0x0000008c
-#define PHY_ANALOG_SYNTH4_PS_SINGLE_PULSE_MSB                                                                 0
-#define PHY_ANALOG_SYNTH4_PS_SINGLE_PULSE_LSB                                                                 0
-#define PHY_ANALOG_SYNTH4_PS_SINGLE_PULSE_MASK                                                       0x00000001
-#define PHY_ANALOG_SYNTH4_PS_SINGLE_PULSE_GET(x)                                      (((x) & 0x00000001) >> 0)
-#define PHY_ANALOG_SYNTH4_PS_SINGLE_PULSE_SET(x)                                      (((x) << 0) & 0x00000001)
-#define PHY_ANALOG_SYNTH4_LONGSHIFTSEL_MSB                                                                    1
-#define PHY_ANALOG_SYNTH4_LONGSHIFTSEL_LSB                                                                    1
-#define PHY_ANALOG_SYNTH4_LONGSHIFTSEL_MASK                                                          0x00000002
-#define PHY_ANALOG_SYNTH4_LONGSHIFTSEL_GET(x)                                         (((x) & 0x00000002) >> 1)
-#define PHY_ANALOG_SYNTH4_LONGSHIFTSEL_SET(x)                                         (((x) << 1) & 0x00000002)
-#define PHY_ANALOG_SYNTH4_LOBUF5GTUNE_OVR_MSB                                                                 3
-#define PHY_ANALOG_SYNTH4_LOBUF5GTUNE_OVR_LSB                                                                 2
-#define PHY_ANALOG_SYNTH4_LOBUF5GTUNE_OVR_MASK                                                       0x0000000c
-#define PHY_ANALOG_SYNTH4_LOBUF5GTUNE_OVR_GET(x)                                      (((x) & 0x0000000c) >> 2)
-#define PHY_ANALOG_SYNTH4_LOBUF5GTUNE_OVR_SET(x)                                      (((x) << 2) & 0x0000000c)
-#define PHY_ANALOG_SYNTH4_FORCE_LOBUF5GTUNE_MSB                                                               4
-#define PHY_ANALOG_SYNTH4_FORCE_LOBUF5GTUNE_LSB                                                               4
-#define PHY_ANALOG_SYNTH4_FORCE_LOBUF5GTUNE_MASK                                                     0x00000010
-#define PHY_ANALOG_SYNTH4_FORCE_LOBUF5GTUNE_GET(x)                                    (((x) & 0x00000010) >> 4)
-#define PHY_ANALOG_SYNTH4_FORCE_LOBUF5GTUNE_SET(x)                                    (((x) << 4) & 0x00000010)
-#define PHY_ANALOG_SYNTH4_PSCOUNT_FBSEL_MSB                                                                   5
-#define PHY_ANALOG_SYNTH4_PSCOUNT_FBSEL_LSB                                                                   5
-#define PHY_ANALOG_SYNTH4_PSCOUNT_FBSEL_MASK                                                         0x00000020
-#define PHY_ANALOG_SYNTH4_PSCOUNT_FBSEL_GET(x)                                        (((x) & 0x00000020) >> 5)
-#define PHY_ANALOG_SYNTH4_PSCOUNT_FBSEL_SET(x)                                        (((x) << 5) & 0x00000020)
-#define PHY_ANALOG_SYNTH4_SDM_DITHER_MSB                                                                      7
-#define PHY_ANALOG_SYNTH4_SDM_DITHER_LSB                                                                      6
-#define PHY_ANALOG_SYNTH4_SDM_DITHER_MASK                                                            0x000000c0
-#define PHY_ANALOG_SYNTH4_SDM_DITHER_GET(x)                                           (((x) & 0x000000c0) >> 6)
-#define PHY_ANALOG_SYNTH4_SDM_DITHER_SET(x)                                           (((x) << 6) & 0x000000c0)
-#define PHY_ANALOG_SYNTH4_SDM_MODE_MSB                                                                        8
-#define PHY_ANALOG_SYNTH4_SDM_MODE_LSB                                                                        8
-#define PHY_ANALOG_SYNTH4_SDM_MODE_MASK                                                              0x00000100
-#define PHY_ANALOG_SYNTH4_SDM_MODE_GET(x)                                             (((x) & 0x00000100) >> 8)
-#define PHY_ANALOG_SYNTH4_SDM_MODE_SET(x)                                             (((x) << 8) & 0x00000100)
-#define PHY_ANALOG_SYNTH4_SDM_DISABLE_MSB                                                                     9
-#define PHY_ANALOG_SYNTH4_SDM_DISABLE_LSB                                                                     9
-#define PHY_ANALOG_SYNTH4_SDM_DISABLE_MASK                                                           0x00000200
-#define PHY_ANALOG_SYNTH4_SDM_DISABLE_GET(x)                                          (((x) & 0x00000200) >> 9)
-#define PHY_ANALOG_SYNTH4_SDM_DISABLE_SET(x)                                          (((x) << 9) & 0x00000200)
-#define PHY_ANALOG_SYNTH4_RESET_PRESC_MSB                                                                    10
-#define PHY_ANALOG_SYNTH4_RESET_PRESC_LSB                                                                    10
-#define PHY_ANALOG_SYNTH4_RESET_PRESC_MASK                                                           0x00000400
-#define PHY_ANALOG_SYNTH4_RESET_PRESC_GET(x)                                         (((x) & 0x00000400) >> 10)
-#define PHY_ANALOG_SYNTH4_RESET_PRESC_SET(x)                                         (((x) << 10) & 0x00000400)
-#define PHY_ANALOG_SYNTH4_PRESCSEL_MSB                                                                       12
-#define PHY_ANALOG_SYNTH4_PRESCSEL_LSB                                                                       11
-#define PHY_ANALOG_SYNTH4_PRESCSEL_MASK                                                              0x00001800
-#define PHY_ANALOG_SYNTH4_PRESCSEL_GET(x)                                            (((x) & 0x00001800) >> 11)
-#define PHY_ANALOG_SYNTH4_PRESCSEL_SET(x)                                            (((x) << 11) & 0x00001800)
-#define PHY_ANALOG_SYNTH4_PFD_DISABLE_MSB                                                                    13
-#define PHY_ANALOG_SYNTH4_PFD_DISABLE_LSB                                                                    13
-#define PHY_ANALOG_SYNTH4_PFD_DISABLE_MASK                                                           0x00002000
-#define PHY_ANALOG_SYNTH4_PFD_DISABLE_GET(x)                                         (((x) & 0x00002000) >> 13)
-#define PHY_ANALOG_SYNTH4_PFD_DISABLE_SET(x)                                         (((x) << 13) & 0x00002000)
-#define PHY_ANALOG_SYNTH4_PFDDELAY_FRACN_MSB                                                                 14
-#define PHY_ANALOG_SYNTH4_PFDDELAY_FRACN_LSB                                                                 14
-#define PHY_ANALOG_SYNTH4_PFDDELAY_FRACN_MASK                                                        0x00004000
-#define PHY_ANALOG_SYNTH4_PFDDELAY_FRACN_GET(x)                                      (((x) & 0x00004000) >> 14)
-#define PHY_ANALOG_SYNTH4_PFDDELAY_FRACN_SET(x)                                      (((x) << 14) & 0x00004000)
-#define PHY_ANALOG_SYNTH4_FORCE_LO_ON_MSB                                                                    15
-#define PHY_ANALOG_SYNTH4_FORCE_LO_ON_LSB                                                                    15
-#define PHY_ANALOG_SYNTH4_FORCE_LO_ON_MASK                                                           0x00008000
-#define PHY_ANALOG_SYNTH4_FORCE_LO_ON_GET(x)                                         (((x) & 0x00008000) >> 15)
-#define PHY_ANALOG_SYNTH4_FORCE_LO_ON_SET(x)                                         (((x) << 15) & 0x00008000)
-#define PHY_ANALOG_SYNTH4_CLKXTAL_EDGE_SEL_MSB                                                               16
-#define PHY_ANALOG_SYNTH4_CLKXTAL_EDGE_SEL_LSB                                                               16
-#define PHY_ANALOG_SYNTH4_CLKXTAL_EDGE_SEL_MASK                                                      0x00010000
-#define PHY_ANALOG_SYNTH4_CLKXTAL_EDGE_SEL_GET(x)                                    (((x) & 0x00010000) >> 16)
-#define PHY_ANALOG_SYNTH4_CLKXTAL_EDGE_SEL_SET(x)                                    (((x) << 16) & 0x00010000)
-#define PHY_ANALOG_SYNTH4_VCOCAPPULLUP_MSB                                                                   17
-#define PHY_ANALOG_SYNTH4_VCOCAPPULLUP_LSB                                                                   17
-#define PHY_ANALOG_SYNTH4_VCOCAPPULLUP_MASK                                                          0x00020000
-#define PHY_ANALOG_SYNTH4_VCOCAPPULLUP_GET(x)                                        (((x) & 0x00020000) >> 17)
-#define PHY_ANALOG_SYNTH4_VCOCAPPULLUP_SET(x)                                        (((x) << 17) & 0x00020000)
-#define PHY_ANALOG_SYNTH4_VCOCAP_OVR_MSB                                                                     25
-#define PHY_ANALOG_SYNTH4_VCOCAP_OVR_LSB                                                                     18
-#define PHY_ANALOG_SYNTH4_VCOCAP_OVR_MASK                                                            0x03fc0000
-#define PHY_ANALOG_SYNTH4_VCOCAP_OVR_GET(x)                                          (((x) & 0x03fc0000) >> 18)
-#define PHY_ANALOG_SYNTH4_VCOCAP_OVR_SET(x)                                          (((x) << 18) & 0x03fc0000)
-#define PHY_ANALOG_SYNTH4_FORCE_VCOCAP_MSB                                                                   26
-#define PHY_ANALOG_SYNTH4_FORCE_VCOCAP_LSB                                                                   26
-#define PHY_ANALOG_SYNTH4_FORCE_VCOCAP_MASK                                                          0x04000000
-#define PHY_ANALOG_SYNTH4_FORCE_VCOCAP_GET(x)                                        (((x) & 0x04000000) >> 26)
-#define PHY_ANALOG_SYNTH4_FORCE_VCOCAP_SET(x)                                        (((x) << 26) & 0x04000000)
-#define PHY_ANALOG_SYNTH4_FORCE_PINVC_MSB                                                                    27
-#define PHY_ANALOG_SYNTH4_FORCE_PINVC_LSB                                                                    27
-#define PHY_ANALOG_SYNTH4_FORCE_PINVC_MASK                                                           0x08000000
-#define PHY_ANALOG_SYNTH4_FORCE_PINVC_GET(x)                                         (((x) & 0x08000000) >> 27)
-#define PHY_ANALOG_SYNTH4_FORCE_PINVC_SET(x)                                         (((x) << 27) & 0x08000000)
-#define PHY_ANALOG_SYNTH4_SHORTR_UNTIL_LOCKED_MSB                                                            28
-#define PHY_ANALOG_SYNTH4_SHORTR_UNTIL_LOCKED_LSB                                                            28
-#define PHY_ANALOG_SYNTH4_SHORTR_UNTIL_LOCKED_MASK                                                   0x10000000
-#define PHY_ANALOG_SYNTH4_SHORTR_UNTIL_LOCKED_GET(x)                                 (((x) & 0x10000000) >> 28)
-#define PHY_ANALOG_SYNTH4_SHORTR_UNTIL_LOCKED_SET(x)                                 (((x) << 28) & 0x10000000)
-#define PHY_ANALOG_SYNTH4_ALWAYS_SHORTR_MSB                                                                  29
-#define PHY_ANALOG_SYNTH4_ALWAYS_SHORTR_LSB                                                                  29
-#define PHY_ANALOG_SYNTH4_ALWAYS_SHORTR_MASK                                                         0x20000000
-#define PHY_ANALOG_SYNTH4_ALWAYS_SHORTR_GET(x)                                       (((x) & 0x20000000) >> 29)
-#define PHY_ANALOG_SYNTH4_ALWAYS_SHORTR_SET(x)                                       (((x) << 29) & 0x20000000)
-#define PHY_ANALOG_SYNTH4_DIS_LOSTVC_MSB                                                                     30
-#define PHY_ANALOG_SYNTH4_DIS_LOSTVC_LSB                                                                     30
-#define PHY_ANALOG_SYNTH4_DIS_LOSTVC_MASK                                                            0x40000000
-#define PHY_ANALOG_SYNTH4_DIS_LOSTVC_GET(x)                                          (((x) & 0x40000000) >> 30)
-#define PHY_ANALOG_SYNTH4_DIS_LOSTVC_SET(x)                                          (((x) << 30) & 0x40000000)
-#define PHY_ANALOG_SYNTH4_DIS_LIN_CAPSEARCH_MSB                                                              31
-#define PHY_ANALOG_SYNTH4_DIS_LIN_CAPSEARCH_LSB                                                              31
-#define PHY_ANALOG_SYNTH4_DIS_LIN_CAPSEARCH_MASK                                                     0x80000000
-#define PHY_ANALOG_SYNTH4_DIS_LIN_CAPSEARCH_GET(x)                                   (((x) & 0x80000000) >> 31)
-#define PHY_ANALOG_SYNTH4_DIS_LIN_CAPSEARCH_SET(x)                                   (((x) << 31) & 0x80000000)
-
-/* macros for SYNTH5 */
-#define PHY_ANALOG_SYNTH5_ADDRESS                                                                    0x00000090
-#define PHY_ANALOG_SYNTH5_OFFSET                                                                     0x00000090
-#define PHY_ANALOG_SYNTH5_VCOBIAS_MSB                                                                         1
-#define PHY_ANALOG_SYNTH5_VCOBIAS_LSB                                                                         0
-#define PHY_ANALOG_SYNTH5_VCOBIAS_MASK                                                               0x00000003
-#define PHY_ANALOG_SYNTH5_VCOBIAS_GET(x)                                              (((x) & 0x00000003) >> 0)
-#define PHY_ANALOG_SYNTH5_VCOBIAS_SET(x)                                              (((x) << 0) & 0x00000003)
-#define PHY_ANALOG_SYNTH5_PWDB_ICLOBUF5G50_MSB                                                                4
-#define PHY_ANALOG_SYNTH5_PWDB_ICLOBUF5G50_LSB                                                                2
-#define PHY_ANALOG_SYNTH5_PWDB_ICLOBUF5G50_MASK                                                      0x0000001c
-#define PHY_ANALOG_SYNTH5_PWDB_ICLOBUF5G50_GET(x)                                     (((x) & 0x0000001c) >> 2)
-#define PHY_ANALOG_SYNTH5_PWDB_ICLOBUF5G50_SET(x)                                     (((x) << 2) & 0x0000001c)
-#define PHY_ANALOG_SYNTH5_PWDB_ICLOBUF2G50_MSB                                                                7
-#define PHY_ANALOG_SYNTH5_PWDB_ICLOBUF2G50_LSB                                                                5
-#define PHY_ANALOG_SYNTH5_PWDB_ICLOBUF2G50_MASK                                                      0x000000e0
-#define PHY_ANALOG_SYNTH5_PWDB_ICLOBUF2G50_GET(x)                                     (((x) & 0x000000e0) >> 5)
-#define PHY_ANALOG_SYNTH5_PWDB_ICLOBUF2G50_SET(x)                                     (((x) << 5) & 0x000000e0)
-#define PHY_ANALOG_SYNTH5_PWDB_ICVCO25_MSB                                                                   10
-#define PHY_ANALOG_SYNTH5_PWDB_ICVCO25_LSB                                                                    8
-#define PHY_ANALOG_SYNTH5_PWDB_ICVCO25_MASK                                                          0x00000700
-#define PHY_ANALOG_SYNTH5_PWDB_ICVCO25_GET(x)                                         (((x) & 0x00000700) >> 8)
-#define PHY_ANALOG_SYNTH5_PWDB_ICVCO25_SET(x)                                         (((x) << 8) & 0x00000700)
-#define PHY_ANALOG_SYNTH5_PWDB_ICVCOREG25_MSB                                                                13
-#define PHY_ANALOG_SYNTH5_PWDB_ICVCOREG25_LSB                                                                11
-#define PHY_ANALOG_SYNTH5_PWDB_ICVCOREG25_MASK                                                       0x00003800
-#define PHY_ANALOG_SYNTH5_PWDB_ICVCOREG25_GET(x)                                     (((x) & 0x00003800) >> 11)
-#define PHY_ANALOG_SYNTH5_PWDB_ICVCOREG25_SET(x)                                     (((x) << 11) & 0x00003800)
-#define PHY_ANALOG_SYNTH5_PWDB_IRVCOREG50_MSB                                                                14
-#define PHY_ANALOG_SYNTH5_PWDB_IRVCOREG50_LSB                                                                14
-#define PHY_ANALOG_SYNTH5_PWDB_IRVCOREG50_MASK                                                       0x00004000
-#define PHY_ANALOG_SYNTH5_PWDB_IRVCOREG50_GET(x)                                     (((x) & 0x00004000) >> 14)
-#define PHY_ANALOG_SYNTH5_PWDB_IRVCOREG50_SET(x)                                     (((x) << 14) & 0x00004000)
-#define PHY_ANALOG_SYNTH5_PWDB_ICLOMIX_MSB                                                                   17
-#define PHY_ANALOG_SYNTH5_PWDB_ICLOMIX_LSB                                                                   15
-#define PHY_ANALOG_SYNTH5_PWDB_ICLOMIX_MASK                                                          0x00038000
-#define PHY_ANALOG_SYNTH5_PWDB_ICLOMIX_GET(x)                                        (((x) & 0x00038000) >> 15)
-#define PHY_ANALOG_SYNTH5_PWDB_ICLOMIX_SET(x)                                        (((x) << 15) & 0x00038000)
-#define PHY_ANALOG_SYNTH5_PWDB_ICLODIV50_MSB                                                                 20
-#define PHY_ANALOG_SYNTH5_PWDB_ICLODIV50_LSB                                                                 18
-#define PHY_ANALOG_SYNTH5_PWDB_ICLODIV50_MASK                                                        0x001c0000
-#define PHY_ANALOG_SYNTH5_PWDB_ICLODIV50_GET(x)                                      (((x) & 0x001c0000) >> 18)
-#define PHY_ANALOG_SYNTH5_PWDB_ICLODIV50_SET(x)                                      (((x) << 18) & 0x001c0000)
-#define PHY_ANALOG_SYNTH5_PWDB_ICPRESC50_MSB                                                                 23
-#define PHY_ANALOG_SYNTH5_PWDB_ICPRESC50_LSB                                                                 21
-#define PHY_ANALOG_SYNTH5_PWDB_ICPRESC50_MASK                                                        0x00e00000
-#define PHY_ANALOG_SYNTH5_PWDB_ICPRESC50_GET(x)                                      (((x) & 0x00e00000) >> 21)
-#define PHY_ANALOG_SYNTH5_PWDB_ICPRESC50_SET(x)                                      (((x) << 21) & 0x00e00000)
-#define PHY_ANALOG_SYNTH5_PWDB_IRVCMON25_MSB                                                                 26
-#define PHY_ANALOG_SYNTH5_PWDB_IRVCMON25_LSB                                                                 24
-#define PHY_ANALOG_SYNTH5_PWDB_IRVCMON25_MASK                                                        0x07000000
-#define PHY_ANALOG_SYNTH5_PWDB_IRVCMON25_GET(x)                                      (((x) & 0x07000000) >> 24)
-#define PHY_ANALOG_SYNTH5_PWDB_IRVCMON25_SET(x)                                      (((x) << 24) & 0x07000000)
-#define PHY_ANALOG_SYNTH5_PWDB_IRPFDCP_MSB                                                                   29
-#define PHY_ANALOG_SYNTH5_PWDB_IRPFDCP_LSB                                                                   27
-#define PHY_ANALOG_SYNTH5_PWDB_IRPFDCP_MASK                                                          0x38000000
-#define PHY_ANALOG_SYNTH5_PWDB_IRPFDCP_GET(x)                                        (((x) & 0x38000000) >> 27)
-#define PHY_ANALOG_SYNTH5_PWDB_IRPFDCP_SET(x)                                        (((x) << 27) & 0x38000000)
-#define PHY_ANALOG_SYNTH5_SPARE5A_MSB                                                                        31
-#define PHY_ANALOG_SYNTH5_SPARE5A_LSB                                                                        30
-#define PHY_ANALOG_SYNTH5_SPARE5A_MASK                                                               0xc0000000
-#define PHY_ANALOG_SYNTH5_SPARE5A_GET(x)                                             (((x) & 0xc0000000) >> 30)
-#define PHY_ANALOG_SYNTH5_SPARE5A_SET(x)                                             (((x) << 30) & 0xc0000000)
-
-/* macros for SYNTH6 */
-#define PHY_ANALOG_SYNTH6_ADDRESS                                                                    0x00000094
-#define PHY_ANALOG_SYNTH6_OFFSET                                                                     0x00000094
-#define PHY_ANALOG_SYNTH6_LOBUF5GTUNE_MSB                                                                     1
-#define PHY_ANALOG_SYNTH6_LOBUF5GTUNE_LSB                                                                     0
-#define PHY_ANALOG_SYNTH6_LOBUF5GTUNE_MASK                                                           0x00000003
-#define PHY_ANALOG_SYNTH6_LOBUF5GTUNE_GET(x)                                          (((x) & 0x00000003) >> 0)
-#define PHY_ANALOG_SYNTH6_LOOP_IP_MSB                                                                         8
-#define PHY_ANALOG_SYNTH6_LOOP_IP_LSB                                                                         2
-#define PHY_ANALOG_SYNTH6_LOOP_IP_MASK                                                               0x000001fc
-#define PHY_ANALOG_SYNTH6_LOOP_IP_GET(x)                                              (((x) & 0x000001fc) >> 2)
-#define PHY_ANALOG_SYNTH6_VC2LOW_MSB                                                                          9
-#define PHY_ANALOG_SYNTH6_VC2LOW_LSB                                                                          9
-#define PHY_ANALOG_SYNTH6_VC2LOW_MASK                                                                0x00000200
-#define PHY_ANALOG_SYNTH6_VC2LOW_GET(x)                                               (((x) & 0x00000200) >> 9)
-#define PHY_ANALOG_SYNTH6_VC2HIGH_MSB                                                                        10
-#define PHY_ANALOG_SYNTH6_VC2HIGH_LSB                                                                        10
-#define PHY_ANALOG_SYNTH6_VC2HIGH_MASK                                                               0x00000400
-#define PHY_ANALOG_SYNTH6_VC2HIGH_GET(x)                                             (((x) & 0x00000400) >> 10)
-#define PHY_ANALOG_SYNTH6_RESET_SDM_B_MSB                                                                    11
-#define PHY_ANALOG_SYNTH6_RESET_SDM_B_LSB                                                                    11
-#define PHY_ANALOG_SYNTH6_RESET_SDM_B_MASK                                                           0x00000800
-#define PHY_ANALOG_SYNTH6_RESET_SDM_B_GET(x)                                         (((x) & 0x00000800) >> 11)
-#define PHY_ANALOG_SYNTH6_RESET_PSCOUNTERS_MSB                                                               12
-#define PHY_ANALOG_SYNTH6_RESET_PSCOUNTERS_LSB                                                               12
-#define PHY_ANALOG_SYNTH6_RESET_PSCOUNTERS_MASK                                                      0x00001000
-#define PHY_ANALOG_SYNTH6_RESET_PSCOUNTERS_GET(x)                                    (((x) & 0x00001000) >> 12)
-#define PHY_ANALOG_SYNTH6_RESET_PFD_MSB                                                                      13
-#define PHY_ANALOG_SYNTH6_RESET_PFD_LSB                                                                      13
-#define PHY_ANALOG_SYNTH6_RESET_PFD_MASK                                                             0x00002000
-#define PHY_ANALOG_SYNTH6_RESET_PFD_GET(x)                                           (((x) & 0x00002000) >> 13)
-#define PHY_ANALOG_SYNTH6_RESET_RFD_MSB                                                                      14
-#define PHY_ANALOG_SYNTH6_RESET_RFD_LSB                                                                      14
-#define PHY_ANALOG_SYNTH6_RESET_RFD_MASK                                                             0x00004000
-#define PHY_ANALOG_SYNTH6_RESET_RFD_GET(x)                                           (((x) & 0x00004000) >> 14)
-#define PHY_ANALOG_SYNTH6_SHORT_R_MSB                                                                        15
-#define PHY_ANALOG_SYNTH6_SHORT_R_LSB                                                                        15
-#define PHY_ANALOG_SYNTH6_SHORT_R_MASK                                                               0x00008000
-#define PHY_ANALOG_SYNTH6_SHORT_R_GET(x)                                             (((x) & 0x00008000) >> 15)
-#define PHY_ANALOG_SYNTH6_VCO_CAP_ST_MSB                                                                     23
-#define PHY_ANALOG_SYNTH6_VCO_CAP_ST_LSB                                                                     16
-#define PHY_ANALOG_SYNTH6_VCO_CAP_ST_MASK                                                            0x00ff0000
-#define PHY_ANALOG_SYNTH6_VCO_CAP_ST_GET(x)                                          (((x) & 0x00ff0000) >> 16)
-#define PHY_ANALOG_SYNTH6_PIN_VC_MSB                                                                         24
-#define PHY_ANALOG_SYNTH6_PIN_VC_LSB                                                                         24
-#define PHY_ANALOG_SYNTH6_PIN_VC_MASK                                                                0x01000000
-#define PHY_ANALOG_SYNTH6_PIN_VC_GET(x)                                              (((x) & 0x01000000) >> 24)
-#define PHY_ANALOG_SYNTH6_SYNTH_LOCK_VC_OK_MSB                                                               25
-#define PHY_ANALOG_SYNTH6_SYNTH_LOCK_VC_OK_LSB                                                               25
-#define PHY_ANALOG_SYNTH6_SYNTH_LOCK_VC_OK_MASK                                                      0x02000000
-#define PHY_ANALOG_SYNTH6_SYNTH_LOCK_VC_OK_GET(x)                                    (((x) & 0x02000000) >> 25)
-#define PHY_ANALOG_SYNTH6_CAP_SEARCH_MSB                                                                     26
-#define PHY_ANALOG_SYNTH6_CAP_SEARCH_LSB                                                                     26
-#define PHY_ANALOG_SYNTH6_CAP_SEARCH_MASK                                                            0x04000000
-#define PHY_ANALOG_SYNTH6_CAP_SEARCH_GET(x)                                          (((x) & 0x04000000) >> 26)
-#define PHY_ANALOG_SYNTH6_SYNTH_SM_STATE_MSB                                                                 30
-#define PHY_ANALOG_SYNTH6_SYNTH_SM_STATE_LSB                                                                 27
-#define PHY_ANALOG_SYNTH6_SYNTH_SM_STATE_MASK                                                        0x78000000
-#define PHY_ANALOG_SYNTH6_SYNTH_SM_STATE_GET(x)                                      (((x) & 0x78000000) >> 27)
-#define PHY_ANALOG_SYNTH6_SYNTH_ON_MSB                                                                       31
-#define PHY_ANALOG_SYNTH6_SYNTH_ON_LSB                                                                       31
-#define PHY_ANALOG_SYNTH6_SYNTH_ON_MASK                                                              0x80000000
-#define PHY_ANALOG_SYNTH6_SYNTH_ON_GET(x)                                            (((x) & 0x80000000) >> 31)
-
-/* macros for SYNTH7 */
-#define PHY_ANALOG_SYNTH7_ADDRESS                                                                    0x00000098
-#define PHY_ANALOG_SYNTH7_OFFSET                                                                     0x00000098
-#define PHY_ANALOG_SYNTH7_OVRCHANDECODER_MSB                                                                  0
-#define PHY_ANALOG_SYNTH7_OVRCHANDECODER_LSB                                                                  0
-#define PHY_ANALOG_SYNTH7_OVRCHANDECODER_MASK                                                        0x00000001
-#define PHY_ANALOG_SYNTH7_OVRCHANDECODER_GET(x)                                       (((x) & 0x00000001) >> 0)
-#define PHY_ANALOG_SYNTH7_OVRCHANDECODER_SET(x)                                       (((x) << 0) & 0x00000001)
-#define PHY_ANALOG_SYNTH7_FORCE_FRACLSB_MSB                                                                   1
-#define PHY_ANALOG_SYNTH7_FORCE_FRACLSB_LSB                                                                   1
-#define PHY_ANALOG_SYNTH7_FORCE_FRACLSB_MASK                                                         0x00000002
-#define PHY_ANALOG_SYNTH7_FORCE_FRACLSB_GET(x)                                        (((x) & 0x00000002) >> 1)
-#define PHY_ANALOG_SYNTH7_FORCE_FRACLSB_SET(x)                                        (((x) << 1) & 0x00000002)
-#define PHY_ANALOG_SYNTH7_CHANFRAC_MSB                                                                       18
-#define PHY_ANALOG_SYNTH7_CHANFRAC_LSB                                                                        2
-#define PHY_ANALOG_SYNTH7_CHANFRAC_MASK                                                              0x0007fffc
-#define PHY_ANALOG_SYNTH7_CHANFRAC_GET(x)                                             (((x) & 0x0007fffc) >> 2)
-#define PHY_ANALOG_SYNTH7_CHANFRAC_SET(x)                                             (((x) << 2) & 0x0007fffc)
-#define PHY_ANALOG_SYNTH7_CHANSEL_MSB                                                                        27
-#define PHY_ANALOG_SYNTH7_CHANSEL_LSB                                                                        19
-#define PHY_ANALOG_SYNTH7_CHANSEL_MASK                                                               0x0ff80000
-#define PHY_ANALOG_SYNTH7_CHANSEL_GET(x)                                             (((x) & 0x0ff80000) >> 19)
-#define PHY_ANALOG_SYNTH7_CHANSEL_SET(x)                                             (((x) << 19) & 0x0ff80000)
-#define PHY_ANALOG_SYNTH7_AMODEREFSEL_MSB                                                                    29
-#define PHY_ANALOG_SYNTH7_AMODEREFSEL_LSB                                                                    28
-#define PHY_ANALOG_SYNTH7_AMODEREFSEL_MASK                                                           0x30000000
-#define PHY_ANALOG_SYNTH7_AMODEREFSEL_GET(x)                                         (((x) & 0x30000000) >> 28)
-#define PHY_ANALOG_SYNTH7_AMODEREFSEL_SET(x)                                         (((x) << 28) & 0x30000000)
-#define PHY_ANALOG_SYNTH7_FRACMODE_MSB                                                                       30
-#define PHY_ANALOG_SYNTH7_FRACMODE_LSB                                                                       30
-#define PHY_ANALOG_SYNTH7_FRACMODE_MASK                                                              0x40000000
-#define PHY_ANALOG_SYNTH7_FRACMODE_GET(x)                                            (((x) & 0x40000000) >> 30)
-#define PHY_ANALOG_SYNTH7_FRACMODE_SET(x)                                            (((x) << 30) & 0x40000000)
-#define PHY_ANALOG_SYNTH7_LOADSYNTHCHANNEL_MSB                                                               31
-#define PHY_ANALOG_SYNTH7_LOADSYNTHCHANNEL_LSB                                                               31
-#define PHY_ANALOG_SYNTH7_LOADSYNTHCHANNEL_MASK                                                      0x80000000
-#define PHY_ANALOG_SYNTH7_LOADSYNTHCHANNEL_GET(x)                                    (((x) & 0x80000000) >> 31)
-#define PHY_ANALOG_SYNTH7_LOADSYNTHCHANNEL_SET(x)                                    (((x) << 31) & 0x80000000)
-
-/* macros for SYNTH8 */
-#define PHY_ANALOG_SYNTH8_ADDRESS                                                                    0x0000009c
-#define PHY_ANALOG_SYNTH8_OFFSET                                                                     0x0000009c
-#define PHY_ANALOG_SYNTH8_CPSTEERING_EN_FRACN_MSB                                                             0
-#define PHY_ANALOG_SYNTH8_CPSTEERING_EN_FRACN_LSB                                                             0
-#define PHY_ANALOG_SYNTH8_CPSTEERING_EN_FRACN_MASK                                                   0x00000001
-#define PHY_ANALOG_SYNTH8_CPSTEERING_EN_FRACN_GET(x)                                  (((x) & 0x00000001) >> 0)
-#define PHY_ANALOG_SYNTH8_CPSTEERING_EN_FRACN_SET(x)                                  (((x) << 0) & 0x00000001)
-#define PHY_ANALOG_SYNTH8_LOOP_ICPB_MSB                                                                       7
-#define PHY_ANALOG_SYNTH8_LOOP_ICPB_LSB                                                                       1
-#define PHY_ANALOG_SYNTH8_LOOP_ICPB_MASK                                                             0x000000fe
-#define PHY_ANALOG_SYNTH8_LOOP_ICPB_GET(x)                                            (((x) & 0x000000fe) >> 1)
-#define PHY_ANALOG_SYNTH8_LOOP_ICPB_SET(x)                                            (((x) << 1) & 0x000000fe)
-#define PHY_ANALOG_SYNTH8_LOOP_CSB_MSB                                                                       11
-#define PHY_ANALOG_SYNTH8_LOOP_CSB_LSB                                                                        8
-#define PHY_ANALOG_SYNTH8_LOOP_CSB_MASK                                                              0x00000f00
-#define PHY_ANALOG_SYNTH8_LOOP_CSB_GET(x)                                             (((x) & 0x00000f00) >> 8)
-#define PHY_ANALOG_SYNTH8_LOOP_CSB_SET(x)                                             (((x) << 8) & 0x00000f00)
-#define PHY_ANALOG_SYNTH8_LOOP_RSB_MSB                                                                       16
-#define PHY_ANALOG_SYNTH8_LOOP_RSB_LSB                                                                       12
-#define PHY_ANALOG_SYNTH8_LOOP_RSB_MASK                                                              0x0001f000
-#define PHY_ANALOG_SYNTH8_LOOP_RSB_GET(x)                                            (((x) & 0x0001f000) >> 12)
-#define PHY_ANALOG_SYNTH8_LOOP_RSB_SET(x)                                            (((x) << 12) & 0x0001f000)
-#define PHY_ANALOG_SYNTH8_LOOP_CPB_MSB                                                                       21
-#define PHY_ANALOG_SYNTH8_LOOP_CPB_LSB                                                                       17
-#define PHY_ANALOG_SYNTH8_LOOP_CPB_MASK                                                              0x003e0000
-#define PHY_ANALOG_SYNTH8_LOOP_CPB_GET(x)                                            (((x) & 0x003e0000) >> 17)
-#define PHY_ANALOG_SYNTH8_LOOP_CPB_SET(x)                                            (((x) << 17) & 0x003e0000)
-#define PHY_ANALOG_SYNTH8_LOOP_3RD_ORDER_RB_MSB                                                              26
-#define PHY_ANALOG_SYNTH8_LOOP_3RD_ORDER_RB_LSB                                                              22
-#define PHY_ANALOG_SYNTH8_LOOP_3RD_ORDER_RB_MASK                                                     0x07c00000
-#define PHY_ANALOG_SYNTH8_LOOP_3RD_ORDER_RB_GET(x)                                   (((x) & 0x07c00000) >> 22)
-#define PHY_ANALOG_SYNTH8_LOOP_3RD_ORDER_RB_SET(x)                                   (((x) << 22) & 0x07c00000)
-#define PHY_ANALOG_SYNTH8_REFDIVB_MSB                                                                        31
-#define PHY_ANALOG_SYNTH8_REFDIVB_LSB                                                                        27
-#define PHY_ANALOG_SYNTH8_REFDIVB_MASK                                                               0xf8000000
-#define PHY_ANALOG_SYNTH8_REFDIVB_GET(x)                                             (((x) & 0xf8000000) >> 27)
-#define PHY_ANALOG_SYNTH8_REFDIVB_SET(x)                                             (((x) << 27) & 0xf8000000)
-
-/* macros for SYNTH9 */
-#define PHY_ANALOG_SYNTH9_ADDRESS                                                                    0x000000a0
-#define PHY_ANALOG_SYNTH9_OFFSET                                                                     0x000000a0
-#define PHY_ANALOG_SYNTH9_PFDDELAY_INTN_MSB                                                                   0
-#define PHY_ANALOG_SYNTH9_PFDDELAY_INTN_LSB                                                                   0
-#define PHY_ANALOG_SYNTH9_PFDDELAY_INTN_MASK                                                         0x00000001
-#define PHY_ANALOG_SYNTH9_PFDDELAY_INTN_GET(x)                                        (((x) & 0x00000001) >> 0)
-#define PHY_ANALOG_SYNTH9_PFDDELAY_INTN_SET(x)                                        (((x) << 0) & 0x00000001)
-#define PHY_ANALOG_SYNTH9_SLOPE_ICPA0_MSB                                                                     3
-#define PHY_ANALOG_SYNTH9_SLOPE_ICPA0_LSB                                                                     1
-#define PHY_ANALOG_SYNTH9_SLOPE_ICPA0_MASK                                                           0x0000000e
-#define PHY_ANALOG_SYNTH9_SLOPE_ICPA0_GET(x)                                          (((x) & 0x0000000e) >> 1)
-#define PHY_ANALOG_SYNTH9_SLOPE_ICPA0_SET(x)                                          (((x) << 1) & 0x0000000e)
-#define PHY_ANALOG_SYNTH9_LOOP_ICPA0_MSB                                                                      7
-#define PHY_ANALOG_SYNTH9_LOOP_ICPA0_LSB                                                                      4
-#define PHY_ANALOG_SYNTH9_LOOP_ICPA0_MASK                                                            0x000000f0
-#define PHY_ANALOG_SYNTH9_LOOP_ICPA0_GET(x)                                           (((x) & 0x000000f0) >> 4)
-#define PHY_ANALOG_SYNTH9_LOOP_ICPA0_SET(x)                                           (((x) << 4) & 0x000000f0)
-#define PHY_ANALOG_SYNTH9_LOOP_CSA0_MSB                                                                      11
-#define PHY_ANALOG_SYNTH9_LOOP_CSA0_LSB                                                                       8
-#define PHY_ANALOG_SYNTH9_LOOP_CSA0_MASK                                                             0x00000f00
-#define PHY_ANALOG_SYNTH9_LOOP_CSA0_GET(x)                                            (((x) & 0x00000f00) >> 8)
-#define PHY_ANALOG_SYNTH9_LOOP_CSA0_SET(x)                                            (((x) << 8) & 0x00000f00)
-#define PHY_ANALOG_SYNTH9_LOOP_RSA0_MSB                                                                      16
-#define PHY_ANALOG_SYNTH9_LOOP_RSA0_LSB                                                                      12
-#define PHY_ANALOG_SYNTH9_LOOP_RSA0_MASK                                                             0x0001f000
-#define PHY_ANALOG_SYNTH9_LOOP_RSA0_GET(x)                                           (((x) & 0x0001f000) >> 12)
-#define PHY_ANALOG_SYNTH9_LOOP_RSA0_SET(x)                                           (((x) << 12) & 0x0001f000)
-#define PHY_ANALOG_SYNTH9_LOOP_CPA0_MSB                                                                      21
-#define PHY_ANALOG_SYNTH9_LOOP_CPA0_LSB                                                                      17
-#define PHY_ANALOG_SYNTH9_LOOP_CPA0_MASK                                                             0x003e0000
-#define PHY_ANALOG_SYNTH9_LOOP_CPA0_GET(x)                                           (((x) & 0x003e0000) >> 17)
-#define PHY_ANALOG_SYNTH9_LOOP_CPA0_SET(x)                                           (((x) << 17) & 0x003e0000)
-#define PHY_ANALOG_SYNTH9_LOOP_3RD_ORDER_RA_MSB                                                              26
-#define PHY_ANALOG_SYNTH9_LOOP_3RD_ORDER_RA_LSB                                                              22
-#define PHY_ANALOG_SYNTH9_LOOP_3RD_ORDER_RA_MASK                                                     0x07c00000
-#define PHY_ANALOG_SYNTH9_LOOP_3RD_ORDER_RA_GET(x)                                   (((x) & 0x07c00000) >> 22)
-#define PHY_ANALOG_SYNTH9_LOOP_3RD_ORDER_RA_SET(x)                                   (((x) << 22) & 0x07c00000)
-#define PHY_ANALOG_SYNTH9_REFDIVA_MSB                                                                        31
-#define PHY_ANALOG_SYNTH9_REFDIVA_LSB                                                                        27
-#define PHY_ANALOG_SYNTH9_REFDIVA_MASK                                                               0xf8000000
-#define PHY_ANALOG_SYNTH9_REFDIVA_GET(x)                                             (((x) & 0xf8000000) >> 27)
-#define PHY_ANALOG_SYNTH9_REFDIVA_SET(x)                                             (((x) << 27) & 0xf8000000)
-
-/* macros for SYNTH10 */
-#define PHY_ANALOG_SYNTH10_ADDRESS                                                                   0x000000a4
-#define PHY_ANALOG_SYNTH10_OFFSET                                                                    0x000000a4
-#define PHY_ANALOG_SYNTH10_SPARE10A_MSB                                                                       0
-#define PHY_ANALOG_SYNTH10_SPARE10A_LSB                                                                       0
-#define PHY_ANALOG_SYNTH10_SPARE10A_MASK                                                             0x00000001
-#define PHY_ANALOG_SYNTH10_SPARE10A_GET(x)                                            (((x) & 0x00000001) >> 0)
-#define PHY_ANALOG_SYNTH10_SPARE10A_SET(x)                                            (((x) << 0) & 0x00000001)
-#define PHY_ANALOG_SYNTH10_PWDB_ICLOBIAS50_MSB                                                                3
-#define PHY_ANALOG_SYNTH10_PWDB_ICLOBIAS50_LSB                                                                1
-#define PHY_ANALOG_SYNTH10_PWDB_ICLOBIAS50_MASK                                                      0x0000000e
-#define PHY_ANALOG_SYNTH10_PWDB_ICLOBIAS50_GET(x)                                     (((x) & 0x0000000e) >> 1)
-#define PHY_ANALOG_SYNTH10_PWDB_ICLOBIAS50_SET(x)                                     (((x) << 1) & 0x0000000e)
-#define PHY_ANALOG_SYNTH10_EN_2X_LOOPFILT_MSB                                                                 4
-#define PHY_ANALOG_SYNTH10_EN_2X_LOOPFILT_LSB                                                                 4
-#define PHY_ANALOG_SYNTH10_EN_2X_LOOPFILT_MASK                                                       0x00000010
-#define PHY_ANALOG_SYNTH10_EN_2X_LOOPFILT_GET(x)                                      (((x) & 0x00000010) >> 4)
-#define PHY_ANALOG_SYNTH10_EN_2X_LOOPFILT_SET(x)                                      (((x) << 4) & 0x00000010)
-#define PHY_ANALOG_SYNTH10_PWDB_IRSPARE25_MSB                                                                 7
-#define PHY_ANALOG_SYNTH10_PWDB_IRSPARE25_LSB                                                                 5
-#define PHY_ANALOG_SYNTH10_PWDB_IRSPARE25_MASK                                                       0x000000e0
-#define PHY_ANALOG_SYNTH10_PWDB_IRSPARE25_GET(x)                                      (((x) & 0x000000e0) >> 5)
-#define PHY_ANALOG_SYNTH10_PWDB_IRSPARE25_SET(x)                                      (((x) << 5) & 0x000000e0)
-#define PHY_ANALOG_SYNTH10_PWDB_ICSPARE25_MSB                                                                10
-#define PHY_ANALOG_SYNTH10_PWDB_ICSPARE25_LSB                                                                 8
-#define PHY_ANALOG_SYNTH10_PWDB_ICSPARE25_MASK                                                       0x00000700
-#define PHY_ANALOG_SYNTH10_PWDB_ICSPARE25_GET(x)                                      (((x) & 0x00000700) >> 8)
-#define PHY_ANALOG_SYNTH10_PWDB_ICSPARE25_SET(x)                                      (((x) << 8) & 0x00000700)
-#define PHY_ANALOG_SYNTH10_SLOPE_ICPA1_MSB                                                                   13
-#define PHY_ANALOG_SYNTH10_SLOPE_ICPA1_LSB                                                                   11
-#define PHY_ANALOG_SYNTH10_SLOPE_ICPA1_MASK                                                          0x00003800
-#define PHY_ANALOG_SYNTH10_SLOPE_ICPA1_GET(x)                                        (((x) & 0x00003800) >> 11)
-#define PHY_ANALOG_SYNTH10_SLOPE_ICPA1_SET(x)                                        (((x) << 11) & 0x00003800)
-#define PHY_ANALOG_SYNTH10_LOOP_ICPA1_MSB                                                                    17
-#define PHY_ANALOG_SYNTH10_LOOP_ICPA1_LSB                                                                    14
-#define PHY_ANALOG_SYNTH10_LOOP_ICPA1_MASK                                                           0x0003c000
-#define PHY_ANALOG_SYNTH10_LOOP_ICPA1_GET(x)                                         (((x) & 0x0003c000) >> 14)
-#define PHY_ANALOG_SYNTH10_LOOP_ICPA1_SET(x)                                         (((x) << 14) & 0x0003c000)
-#define PHY_ANALOG_SYNTH10_LOOP_CSA1_MSB                                                                     21
-#define PHY_ANALOG_SYNTH10_LOOP_CSA1_LSB                                                                     18
-#define PHY_ANALOG_SYNTH10_LOOP_CSA1_MASK                                                            0x003c0000
-#define PHY_ANALOG_SYNTH10_LOOP_CSA1_GET(x)                                          (((x) & 0x003c0000) >> 18)
-#define PHY_ANALOG_SYNTH10_LOOP_CSA1_SET(x)                                          (((x) << 18) & 0x003c0000)
-#define PHY_ANALOG_SYNTH10_LOOP_RSA1_MSB                                                                     26
-#define PHY_ANALOG_SYNTH10_LOOP_RSA1_LSB                                                                     22
-#define PHY_ANALOG_SYNTH10_LOOP_RSA1_MASK                                                            0x07c00000
-#define PHY_ANALOG_SYNTH10_LOOP_RSA1_GET(x)                                          (((x) & 0x07c00000) >> 22)
-#define PHY_ANALOG_SYNTH10_LOOP_RSA1_SET(x)                                          (((x) << 22) & 0x07c00000)
-#define PHY_ANALOG_SYNTH10_LOOP_CPA1_MSB                                                                     31
-#define PHY_ANALOG_SYNTH10_LOOP_CPA1_LSB                                                                     27
-#define PHY_ANALOG_SYNTH10_LOOP_CPA1_MASK                                                            0xf8000000
-#define PHY_ANALOG_SYNTH10_LOOP_CPA1_GET(x)                                          (((x) & 0xf8000000) >> 27)
-#define PHY_ANALOG_SYNTH10_LOOP_CPA1_SET(x)                                          (((x) << 27) & 0xf8000000)
-
-/* macros for SYNTH11 */
-#define PHY_ANALOG_SYNTH11_ADDRESS                                                                   0x000000a8
-#define PHY_ANALOG_SYNTH11_OFFSET                                                                    0x000000a8
-#define PHY_ANALOG_SYNTH11_SPARE11A_MSB                                                                       4
-#define PHY_ANALOG_SYNTH11_SPARE11A_LSB                                                                       0
-#define PHY_ANALOG_SYNTH11_SPARE11A_MASK                                                             0x0000001f
-#define PHY_ANALOG_SYNTH11_SPARE11A_GET(x)                                            (((x) & 0x0000001f) >> 0)
-#define PHY_ANALOG_SYNTH11_SPARE11A_SET(x)                                            (((x) << 0) & 0x0000001f)
-#define PHY_ANALOG_SYNTH11_FORCE_LOBUF5G_ON_MSB                                                               5
-#define PHY_ANALOG_SYNTH11_FORCE_LOBUF5G_ON_LSB                                                               5
-#define PHY_ANALOG_SYNTH11_FORCE_LOBUF5G_ON_MASK                                                     0x00000020
-#define PHY_ANALOG_SYNTH11_FORCE_LOBUF5G_ON_GET(x)                                    (((x) & 0x00000020) >> 5)
-#define PHY_ANALOG_SYNTH11_FORCE_LOBUF5G_ON_SET(x)                                    (((x) << 5) & 0x00000020)
-#define PHY_ANALOG_SYNTH11_LOREFSEL_MSB                                                                       7
-#define PHY_ANALOG_SYNTH11_LOREFSEL_LSB                                                                       6
-#define PHY_ANALOG_SYNTH11_LOREFSEL_MASK                                                             0x000000c0
-#define PHY_ANALOG_SYNTH11_LOREFSEL_GET(x)                                            (((x) & 0x000000c0) >> 6)
-#define PHY_ANALOG_SYNTH11_LOREFSEL_SET(x)                                            (((x) << 6) & 0x000000c0)
-#define PHY_ANALOG_SYNTH11_LOBUF2GTUNE_MSB                                                                    9
-#define PHY_ANALOG_SYNTH11_LOBUF2GTUNE_LSB                                                                    8
-#define PHY_ANALOG_SYNTH11_LOBUF2GTUNE_MASK                                                          0x00000300
-#define PHY_ANALOG_SYNTH11_LOBUF2GTUNE_GET(x)                                         (((x) & 0x00000300) >> 8)
-#define PHY_ANALOG_SYNTH11_LOBUF2GTUNE_SET(x)                                         (((x) << 8) & 0x00000300)
-#define PHY_ANALOG_SYNTH11_CPSTEERING_MODE_MSB                                                               10
-#define PHY_ANALOG_SYNTH11_CPSTEERING_MODE_LSB                                                               10
-#define PHY_ANALOG_SYNTH11_CPSTEERING_MODE_MASK                                                      0x00000400
-#define PHY_ANALOG_SYNTH11_CPSTEERING_MODE_GET(x)                                    (((x) & 0x00000400) >> 10)
-#define PHY_ANALOG_SYNTH11_CPSTEERING_MODE_SET(x)                                    (((x) << 10) & 0x00000400)
-#define PHY_ANALOG_SYNTH11_SLOPE_ICPA2_MSB                                                                   13
-#define PHY_ANALOG_SYNTH11_SLOPE_ICPA2_LSB                                                                   11
-#define PHY_ANALOG_SYNTH11_SLOPE_ICPA2_MASK                                                          0x00003800
-#define PHY_ANALOG_SYNTH11_SLOPE_ICPA2_GET(x)                                        (((x) & 0x00003800) >> 11)
-#define PHY_ANALOG_SYNTH11_SLOPE_ICPA2_SET(x)                                        (((x) << 11) & 0x00003800)
-#define PHY_ANALOG_SYNTH11_LOOP_ICPA2_MSB                                                                    17
-#define PHY_ANALOG_SYNTH11_LOOP_ICPA2_LSB                                                                    14
-#define PHY_ANALOG_SYNTH11_LOOP_ICPA2_MASK                                                           0x0003c000
-#define PHY_ANALOG_SYNTH11_LOOP_ICPA2_GET(x)                                         (((x) & 0x0003c000) >> 14)
-#define PHY_ANALOG_SYNTH11_LOOP_ICPA2_SET(x)                                         (((x) << 14) & 0x0003c000)
-#define PHY_ANALOG_SYNTH11_LOOP_CSA2_MSB                                                                     21
-#define PHY_ANALOG_SYNTH11_LOOP_CSA2_LSB                                                                     18
-#define PHY_ANALOG_SYNTH11_LOOP_CSA2_MASK                                                            0x003c0000
-#define PHY_ANALOG_SYNTH11_LOOP_CSA2_GET(x)                                          (((x) & 0x003c0000) >> 18)
-#define PHY_ANALOG_SYNTH11_LOOP_CSA2_SET(x)                                          (((x) << 18) & 0x003c0000)
-#define PHY_ANALOG_SYNTH11_LOOP_RSA2_MSB                                                                     26
-#define PHY_ANALOG_SYNTH11_LOOP_RSA2_LSB                                                                     22
-#define PHY_ANALOG_SYNTH11_LOOP_RSA2_MASK                                                            0x07c00000
-#define PHY_ANALOG_SYNTH11_LOOP_RSA2_GET(x)                                          (((x) & 0x07c00000) >> 22)
-#define PHY_ANALOG_SYNTH11_LOOP_RSA2_SET(x)                                          (((x) << 22) & 0x07c00000)
-#define PHY_ANALOG_SYNTH11_LOOP_CPA2_MSB                                                                     31
-#define PHY_ANALOG_SYNTH11_LOOP_CPA2_LSB                                                                     27
-#define PHY_ANALOG_SYNTH11_LOOP_CPA2_MASK                                                            0xf8000000
-#define PHY_ANALOG_SYNTH11_LOOP_CPA2_GET(x)                                          (((x) & 0xf8000000) >> 27)
-#define PHY_ANALOG_SYNTH11_LOOP_CPA2_SET(x)                                          (((x) << 27) & 0xf8000000)
-
-/* macros for SYNTH12 */
-#define PHY_ANALOG_SYNTH12_ADDRESS                                                                   0x000000ac
-#define PHY_ANALOG_SYNTH12_OFFSET                                                                    0x000000ac
-#define PHY_ANALOG_SYNTH12_SPARE12A_MSB                                                                      17
-#define PHY_ANALOG_SYNTH12_SPARE12A_LSB                                                                       0
-#define PHY_ANALOG_SYNTH12_SPARE12A_MASK                                                             0x0003ffff
-#define PHY_ANALOG_SYNTH12_SPARE12A_GET(x)                                            (((x) & 0x0003ffff) >> 0)
-#define PHY_ANALOG_SYNTH12_SPARE12A_SET(x)                                            (((x) << 0) & 0x0003ffff)
-#define PHY_ANALOG_SYNTH12_STRCONT_MSB                                                                       18
-#define PHY_ANALOG_SYNTH12_STRCONT_LSB                                                                       18
-#define PHY_ANALOG_SYNTH12_STRCONT_MASK                                                              0x00040000
-#define PHY_ANALOG_SYNTH12_STRCONT_GET(x)                                            (((x) & 0x00040000) >> 18)
-#define PHY_ANALOG_SYNTH12_STRCONT_SET(x)                                            (((x) << 18) & 0x00040000)
-#define PHY_ANALOG_SYNTH12_VREFMUL3_MSB                                                                      22
-#define PHY_ANALOG_SYNTH12_VREFMUL3_LSB                                                                      19
-#define PHY_ANALOG_SYNTH12_VREFMUL3_MASK                                                             0x00780000
-#define PHY_ANALOG_SYNTH12_VREFMUL3_GET(x)                                           (((x) & 0x00780000) >> 19)
-#define PHY_ANALOG_SYNTH12_VREFMUL3_SET(x)                                           (((x) << 19) & 0x00780000)
-#define PHY_ANALOG_SYNTH12_VREFMUL2_MSB                                                                      26
-#define PHY_ANALOG_SYNTH12_VREFMUL2_LSB                                                                      23
-#define PHY_ANALOG_SYNTH12_VREFMUL2_MASK                                                             0x07800000
-#define PHY_ANALOG_SYNTH12_VREFMUL2_GET(x)                                           (((x) & 0x07800000) >> 23)
-#define PHY_ANALOG_SYNTH12_VREFMUL2_SET(x)                                           (((x) << 23) & 0x07800000)
-#define PHY_ANALOG_SYNTH12_VREFMUL1_MSB                                                                      30
-#define PHY_ANALOG_SYNTH12_VREFMUL1_LSB                                                                      27
-#define PHY_ANALOG_SYNTH12_VREFMUL1_MASK                                                             0x78000000
-#define PHY_ANALOG_SYNTH12_VREFMUL1_GET(x)                                           (((x) & 0x78000000) >> 27)
-#define PHY_ANALOG_SYNTH12_VREFMUL1_SET(x)                                           (((x) << 27) & 0x78000000)
-#define PHY_ANALOG_SYNTH12_CLK_DOUBLER_EN_MSB                                                                31
-#define PHY_ANALOG_SYNTH12_CLK_DOUBLER_EN_LSB                                                                31
-#define PHY_ANALOG_SYNTH12_CLK_DOUBLER_EN_MASK                                                       0x80000000
-#define PHY_ANALOG_SYNTH12_CLK_DOUBLER_EN_GET(x)                                     (((x) & 0x80000000) >> 31)
-#define PHY_ANALOG_SYNTH12_CLK_DOUBLER_EN_SET(x)                                     (((x) << 31) & 0x80000000)
-
-/* macros for BIAS1 */
-#define PHY_ANALOG_BIAS1_ADDRESS                                                                     0x000000c0
-#define PHY_ANALOG_BIAS1_OFFSET                                                                      0x000000c0
-#define PHY_ANALOG_BIAS1_SPARE1_MSB                                                                           6
-#define PHY_ANALOG_BIAS1_SPARE1_LSB                                                                           0
-#define PHY_ANALOG_BIAS1_SPARE1_MASK                                                                 0x0000007f
-#define PHY_ANALOG_BIAS1_SPARE1_GET(x)                                                (((x) & 0x0000007f) >> 0)
-#define PHY_ANALOG_BIAS1_SPARE1_SET(x)                                                (((x) << 0) & 0x0000007f)
-#define PHY_ANALOG_BIAS1_PWD_IC25V2IQ_MSB                                                                     9
-#define PHY_ANALOG_BIAS1_PWD_IC25V2IQ_LSB                                                                     7
-#define PHY_ANALOG_BIAS1_PWD_IC25V2IQ_MASK                                                           0x00000380
-#define PHY_ANALOG_BIAS1_PWD_IC25V2IQ_GET(x)                                          (((x) & 0x00000380) >> 7)
-#define PHY_ANALOG_BIAS1_PWD_IC25V2IQ_SET(x)                                          (((x) << 7) & 0x00000380)
-#define PHY_ANALOG_BIAS1_PWD_IC25V2II_MSB                                                                    12
-#define PHY_ANALOG_BIAS1_PWD_IC25V2II_LSB                                                                    10
-#define PHY_ANALOG_BIAS1_PWD_IC25V2II_MASK                                                           0x00001c00
-#define PHY_ANALOG_BIAS1_PWD_IC25V2II_GET(x)                                         (((x) & 0x00001c00) >> 10)
-#define PHY_ANALOG_BIAS1_PWD_IC25V2II_SET(x)                                         (((x) << 10) & 0x00001c00)
-#define PHY_ANALOG_BIAS1_PWD_IC25BB_MSB                                                                      15
-#define PHY_ANALOG_BIAS1_PWD_IC25BB_LSB                                                                      13
-#define PHY_ANALOG_BIAS1_PWD_IC25BB_MASK                                                             0x0000e000
-#define PHY_ANALOG_BIAS1_PWD_IC25BB_GET(x)                                           (((x) & 0x0000e000) >> 13)
-#define PHY_ANALOG_BIAS1_PWD_IC25BB_SET(x)                                           (((x) << 13) & 0x0000e000)
-#define PHY_ANALOG_BIAS1_PWD_IC25DAC_MSB                                                                     18
-#define PHY_ANALOG_BIAS1_PWD_IC25DAC_LSB                                                                     16
-#define PHY_ANALOG_BIAS1_PWD_IC25DAC_MASK                                                            0x00070000
-#define PHY_ANALOG_BIAS1_PWD_IC25DAC_GET(x)                                          (((x) & 0x00070000) >> 16)
-#define PHY_ANALOG_BIAS1_PWD_IC25DAC_SET(x)                                          (((x) << 16) & 0x00070000)
-#define PHY_ANALOG_BIAS1_PWD_IC25FIR_MSB                                                                     21
-#define PHY_ANALOG_BIAS1_PWD_IC25FIR_LSB                                                                     19
-#define PHY_ANALOG_BIAS1_PWD_IC25FIR_MASK                                                            0x00380000
-#define PHY_ANALOG_BIAS1_PWD_IC25FIR_GET(x)                                          (((x) & 0x00380000) >> 19)
-#define PHY_ANALOG_BIAS1_PWD_IC25FIR_SET(x)                                          (((x) << 19) & 0x00380000)
-#define PHY_ANALOG_BIAS1_PWD_IC25ADC_MSB                                                                     24
-#define PHY_ANALOG_BIAS1_PWD_IC25ADC_LSB                                                                     22
-#define PHY_ANALOG_BIAS1_PWD_IC25ADC_MASK                                                            0x01c00000
-#define PHY_ANALOG_BIAS1_PWD_IC25ADC_GET(x)                                          (((x) & 0x01c00000) >> 22)
-#define PHY_ANALOG_BIAS1_PWD_IC25ADC_SET(x)                                          (((x) << 22) & 0x01c00000)
-#define PHY_ANALOG_BIAS1_BIAS_SEL_MSB                                                                        31
-#define PHY_ANALOG_BIAS1_BIAS_SEL_LSB                                                                        25
-#define PHY_ANALOG_BIAS1_BIAS_SEL_MASK                                                               0xfe000000
-#define PHY_ANALOG_BIAS1_BIAS_SEL_GET(x)                                             (((x) & 0xfe000000) >> 25)
-#define PHY_ANALOG_BIAS1_BIAS_SEL_SET(x)                                             (((x) << 25) & 0xfe000000)
-
-/* macros for BIAS2 */
-#define PHY_ANALOG_BIAS2_ADDRESS                                                                     0x000000c4
-#define PHY_ANALOG_BIAS2_OFFSET                                                                      0x000000c4
-#define PHY_ANALOG_BIAS2_SPARE2_MSB                                                                           4
-#define PHY_ANALOG_BIAS2_SPARE2_LSB                                                                           0
-#define PHY_ANALOG_BIAS2_SPARE2_MASK                                                                 0x0000001f
-#define PHY_ANALOG_BIAS2_SPARE2_GET(x)                                                (((x) & 0x0000001f) >> 0)
-#define PHY_ANALOG_BIAS2_SPARE2_SET(x)                                                (((x) << 0) & 0x0000001f)
-#define PHY_ANALOG_BIAS2_PWD_IC25XTALREG_MSB                                                                  7
-#define PHY_ANALOG_BIAS2_PWD_IC25XTALREG_LSB                                                                  5
-#define PHY_ANALOG_BIAS2_PWD_IC25XTALREG_MASK                                                        0x000000e0
-#define PHY_ANALOG_BIAS2_PWD_IC25XTALREG_GET(x)                                       (((x) & 0x000000e0) >> 5)
-#define PHY_ANALOG_BIAS2_PWD_IC25XTALREG_SET(x)                                       (((x) << 5) & 0x000000e0)
-#define PHY_ANALOG_BIAS2_PWD_IC25XTAL_MSB                                                                    10
-#define PHY_ANALOG_BIAS2_PWD_IC25XTAL_LSB                                                                     8
-#define PHY_ANALOG_BIAS2_PWD_IC25XTAL_MASK                                                           0x00000700
-#define PHY_ANALOG_BIAS2_PWD_IC25XTAL_GET(x)                                          (((x) & 0x00000700) >> 8)
-#define PHY_ANALOG_BIAS2_PWD_IC25XTAL_SET(x)                                          (((x) << 8) & 0x00000700)
-#define PHY_ANALOG_BIAS2_PWD_IC25TXRF_MSB                                                                    13
-#define PHY_ANALOG_BIAS2_PWD_IC25TXRF_LSB                                                                    11
-#define PHY_ANALOG_BIAS2_PWD_IC25TXRF_MASK                                                           0x00003800
-#define PHY_ANALOG_BIAS2_PWD_IC25TXRF_GET(x)                                         (((x) & 0x00003800) >> 11)
-#define PHY_ANALOG_BIAS2_PWD_IC25TXRF_SET(x)                                         (((x) << 11) & 0x00003800)
-#define PHY_ANALOG_BIAS2_PWD_IC25RXRF_MSB                                                                    16
-#define PHY_ANALOG_BIAS2_PWD_IC25RXRF_LSB                                                                    14
-#define PHY_ANALOG_BIAS2_PWD_IC25RXRF_MASK                                                           0x0001c000
-#define PHY_ANALOG_BIAS2_PWD_IC25RXRF_GET(x)                                         (((x) & 0x0001c000) >> 14)
-#define PHY_ANALOG_BIAS2_PWD_IC25RXRF_SET(x)                                         (((x) << 14) & 0x0001c000)
-#define PHY_ANALOG_BIAS2_PWD_IC50SYNTH_MSB                                                                   19
-#define PHY_ANALOG_BIAS2_PWD_IC50SYNTH_LSB                                                                   17
-#define PHY_ANALOG_BIAS2_PWD_IC50SYNTH_MASK                                                          0x000e0000
-#define PHY_ANALOG_BIAS2_PWD_IC50SYNTH_GET(x)                                        (((x) & 0x000e0000) >> 17)
-#define PHY_ANALOG_BIAS2_PWD_IC50SYNTH_SET(x)                                        (((x) << 17) & 0x000e0000)
-#define PHY_ANALOG_BIAS2_PWD_IC25PLLREG_MSB                                                                  22
-#define PHY_ANALOG_BIAS2_PWD_IC25PLLREG_LSB                                                                  20
-#define PHY_ANALOG_BIAS2_PWD_IC25PLLREG_MASK                                                         0x00700000
-#define PHY_ANALOG_BIAS2_PWD_IC25PLLREG_GET(x)                                       (((x) & 0x00700000) >> 20)
-#define PHY_ANALOG_BIAS2_PWD_IC25PLLREG_SET(x)                                       (((x) << 20) & 0x00700000)
-#define PHY_ANALOG_BIAS2_PWD_IC25PLLCP2_MSB                                                                  25
-#define PHY_ANALOG_BIAS2_PWD_IC25PLLCP2_LSB                                                                  23
-#define PHY_ANALOG_BIAS2_PWD_IC25PLLCP2_MASK                                                         0x03800000
-#define PHY_ANALOG_BIAS2_PWD_IC25PLLCP2_GET(x)                                       (((x) & 0x03800000) >> 23)
-#define PHY_ANALOG_BIAS2_PWD_IC25PLLCP2_SET(x)                                       (((x) << 23) & 0x03800000)
-#define PHY_ANALOG_BIAS2_PWD_IC25PLLCP_MSB                                                                   28
-#define PHY_ANALOG_BIAS2_PWD_IC25PLLCP_LSB                                                                   26
-#define PHY_ANALOG_BIAS2_PWD_IC25PLLCP_MASK                                                          0x1c000000
-#define PHY_ANALOG_BIAS2_PWD_IC25PLLCP_GET(x)                                        (((x) & 0x1c000000) >> 26)
-#define PHY_ANALOG_BIAS2_PWD_IC25PLLCP_SET(x)                                        (((x) << 26) & 0x1c000000)
-#define PHY_ANALOG_BIAS2_PWD_IC25PLLGM_MSB                                                                   31
-#define PHY_ANALOG_BIAS2_PWD_IC25PLLGM_LSB                                                                   29
-#define PHY_ANALOG_BIAS2_PWD_IC25PLLGM_MASK                                                          0xe0000000
-#define PHY_ANALOG_BIAS2_PWD_IC25PLLGM_GET(x)                                        (((x) & 0xe0000000) >> 29)
-#define PHY_ANALOG_BIAS2_PWD_IC25PLLGM_SET(x)                                        (((x) << 29) & 0xe0000000)
-
-/* macros for BIAS3 */
-#define PHY_ANALOG_BIAS3_ADDRESS                                                                     0x000000c8
-#define PHY_ANALOG_BIAS3_OFFSET                                                                      0x000000c8
-#define PHY_ANALOG_BIAS3_SPARE3_MSB                                                                           1
-#define PHY_ANALOG_BIAS3_SPARE3_LSB                                                                           0
-#define PHY_ANALOG_BIAS3_SPARE3_MASK                                                                 0x00000003
-#define PHY_ANALOG_BIAS3_SPARE3_GET(x)                                                (((x) & 0x00000003) >> 0)
-#define PHY_ANALOG_BIAS3_SPARE3_SET(x)                                                (((x) << 0) & 0x00000003)
-#define PHY_ANALOG_BIAS3_PWD_IR25XTALREG_MSB                                                                  4
-#define PHY_ANALOG_BIAS3_PWD_IR25XTALREG_LSB                                                                  2
-#define PHY_ANALOG_BIAS3_PWD_IR25XTALREG_MASK                                                        0x0000001c
-#define PHY_ANALOG_BIAS3_PWD_IR25XTALREG_GET(x)                                       (((x) & 0x0000001c) >> 2)
-#define PHY_ANALOG_BIAS3_PWD_IR25XTALREG_SET(x)                                       (((x) << 2) & 0x0000001c)
-#define PHY_ANALOG_BIAS3_PWD_IR25TXRF_MSB                                                                     7
-#define PHY_ANALOG_BIAS3_PWD_IR25TXRF_LSB                                                                     5
-#define PHY_ANALOG_BIAS3_PWD_IR25TXRF_MASK                                                           0x000000e0
-#define PHY_ANALOG_BIAS3_PWD_IR25TXRF_GET(x)                                          (((x) & 0x000000e0) >> 5)
-#define PHY_ANALOG_BIAS3_PWD_IR25TXRF_SET(x)                                          (((x) << 5) & 0x000000e0)
-#define PHY_ANALOG_BIAS3_PWD_IR25RXRF_MSB                                                                    10
-#define PHY_ANALOG_BIAS3_PWD_IR25RXRF_LSB                                                                     8
-#define PHY_ANALOG_BIAS3_PWD_IR25RXRF_MASK                                                           0x00000700
-#define PHY_ANALOG_BIAS3_PWD_IR25RXRF_GET(x)                                          (((x) & 0x00000700) >> 8)
-#define PHY_ANALOG_BIAS3_PWD_IR25RXRF_SET(x)                                          (((x) << 8) & 0x00000700)
-#define PHY_ANALOG_BIAS3_PWD_IR50SYNTH_MSB                                                                   13
-#define PHY_ANALOG_BIAS3_PWD_IR50SYNTH_LSB                                                                   11
-#define PHY_ANALOG_BIAS3_PWD_IR50SYNTH_MASK                                                          0x00003800
-#define PHY_ANALOG_BIAS3_PWD_IR50SYNTH_GET(x)                                        (((x) & 0x00003800) >> 11)
-#define PHY_ANALOG_BIAS3_PWD_IR50SYNTH_SET(x)                                        (((x) << 11) & 0x00003800)
-#define PHY_ANALOG_BIAS3_PWD_IR25PLLREG_MSB                                                                  16
-#define PHY_ANALOG_BIAS3_PWD_IR25PLLREG_LSB                                                                  14
-#define PHY_ANALOG_BIAS3_PWD_IR25PLLREG_MASK                                                         0x0001c000
-#define PHY_ANALOG_BIAS3_PWD_IR25PLLREG_GET(x)                                       (((x) & 0x0001c000) >> 14)
-#define PHY_ANALOG_BIAS3_PWD_IR25PLLREG_SET(x)                                       (((x) << 14) & 0x0001c000)
-#define PHY_ANALOG_BIAS3_PWD_IR25BB_MSB                                                                      19
-#define PHY_ANALOG_BIAS3_PWD_IR25BB_LSB                                                                      17
-#define PHY_ANALOG_BIAS3_PWD_IR25BB_MASK                                                             0x000e0000
-#define PHY_ANALOG_BIAS3_PWD_IR25BB_GET(x)                                           (((x) & 0x000e0000) >> 17)
-#define PHY_ANALOG_BIAS3_PWD_IR25BB_SET(x)                                           (((x) << 17) & 0x000e0000)
-#define PHY_ANALOG_BIAS3_PWD_IR50DAC_MSB                                                                     22
-#define PHY_ANALOG_BIAS3_PWD_IR50DAC_LSB                                                                     20
-#define PHY_ANALOG_BIAS3_PWD_IR50DAC_MASK                                                            0x00700000
-#define PHY_ANALOG_BIAS3_PWD_IR50DAC_GET(x)                                          (((x) & 0x00700000) >> 20)
-#define PHY_ANALOG_BIAS3_PWD_IR50DAC_SET(x)                                          (((x) << 20) & 0x00700000)
-#define PHY_ANALOG_BIAS3_PWD_IR25DAC_MSB                                                                     25
-#define PHY_ANALOG_BIAS3_PWD_IR25DAC_LSB                                                                     23
-#define PHY_ANALOG_BIAS3_PWD_IR25DAC_MASK                                                            0x03800000
-#define PHY_ANALOG_BIAS3_PWD_IR25DAC_GET(x)                                          (((x) & 0x03800000) >> 23)
-#define PHY_ANALOG_BIAS3_PWD_IR25DAC_SET(x)                                          (((x) << 23) & 0x03800000)
-#define PHY_ANALOG_BIAS3_PWD_IR25FIR_MSB                                                                     28
-#define PHY_ANALOG_BIAS3_PWD_IR25FIR_LSB                                                                     26
-#define PHY_ANALOG_BIAS3_PWD_IR25FIR_MASK                                                            0x1c000000
-#define PHY_ANALOG_BIAS3_PWD_IR25FIR_GET(x)                                          (((x) & 0x1c000000) >> 26)
-#define PHY_ANALOG_BIAS3_PWD_IR25FIR_SET(x)                                          (((x) << 26) & 0x1c000000)
-#define PHY_ANALOG_BIAS3_PWD_IR50ADC_MSB                                                                     31
-#define PHY_ANALOG_BIAS3_PWD_IR50ADC_LSB                                                                     29
-#define PHY_ANALOG_BIAS3_PWD_IR50ADC_MASK                                                            0xe0000000
-#define PHY_ANALOG_BIAS3_PWD_IR50ADC_GET(x)                                          (((x) & 0xe0000000) >> 29)
-#define PHY_ANALOG_BIAS3_PWD_IR50ADC_SET(x)                                          (((x) << 29) & 0xe0000000)
-
-/* macros for BIAS4 */
-#define PHY_ANALOG_BIAS4_ADDRESS                                                                     0x000000cc
-#define PHY_ANALOG_BIAS4_OFFSET                                                                      0x000000cc
-#define PHY_ANALOG_BIAS4_SPARE4_MSB                                                                          13
-#define PHY_ANALOG_BIAS4_SPARE4_LSB                                                                           0
-#define PHY_ANALOG_BIAS4_SPARE4_MASK                                                                 0x00003fff
-#define PHY_ANALOG_BIAS4_SPARE4_GET(x)                                                (((x) & 0x00003fff) >> 0)
-#define PHY_ANALOG_BIAS4_SPARE4_SET(x)                                                (((x) << 0) & 0x00003fff)
-#define PHY_ANALOG_BIAS4_PWD_IR25SPAREC_MSB                                                                  16
-#define PHY_ANALOG_BIAS4_PWD_IR25SPAREC_LSB                                                                  14
-#define PHY_ANALOG_BIAS4_PWD_IR25SPAREC_MASK                                                         0x0001c000
-#define PHY_ANALOG_BIAS4_PWD_IR25SPAREC_GET(x)                                       (((x) & 0x0001c000) >> 14)
-#define PHY_ANALOG_BIAS4_PWD_IR25SPAREC_SET(x)                                       (((x) << 14) & 0x0001c000)
-#define PHY_ANALOG_BIAS4_PWD_IR25SPAREB_MSB                                                                  19
-#define PHY_ANALOG_BIAS4_PWD_IR25SPAREB_LSB                                                                  17
-#define PHY_ANALOG_BIAS4_PWD_IR25SPAREB_MASK                                                         0x000e0000
-#define PHY_ANALOG_BIAS4_PWD_IR25SPAREB_GET(x)                                       (((x) & 0x000e0000) >> 17)
-#define PHY_ANALOG_BIAS4_PWD_IR25SPAREB_SET(x)                                       (((x) << 17) & 0x000e0000)
-#define PHY_ANALOG_BIAS4_PWD_IR25SPAREA_MSB                                                                  22
-#define PHY_ANALOG_BIAS4_PWD_IR25SPAREA_LSB                                                                  20
-#define PHY_ANALOG_BIAS4_PWD_IR25SPAREA_MASK                                                         0x00700000
-#define PHY_ANALOG_BIAS4_PWD_IR25SPAREA_GET(x)                                       (((x) & 0x00700000) >> 20)
-#define PHY_ANALOG_BIAS4_PWD_IR25SPAREA_SET(x)                                       (((x) << 20) & 0x00700000)
-#define PHY_ANALOG_BIAS4_PWD_IC25SPAREC_MSB                                                                  25
-#define PHY_ANALOG_BIAS4_PWD_IC25SPAREC_LSB                                                                  23
-#define PHY_ANALOG_BIAS4_PWD_IC25SPAREC_MASK                                                         0x03800000
-#define PHY_ANALOG_BIAS4_PWD_IC25SPAREC_GET(x)                                       (((x) & 0x03800000) >> 23)
-#define PHY_ANALOG_BIAS4_PWD_IC25SPAREC_SET(x)                                       (((x) << 23) & 0x03800000)
-#define PHY_ANALOG_BIAS4_PWD_IC25SPAREB_MSB                                                                  28
-#define PHY_ANALOG_BIAS4_PWD_IC25SPAREB_LSB                                                                  26
-#define PHY_ANALOG_BIAS4_PWD_IC25SPAREB_MASK                                                         0x1c000000
-#define PHY_ANALOG_BIAS4_PWD_IC25SPAREB_GET(x)                                       (((x) & 0x1c000000) >> 26)
-#define PHY_ANALOG_BIAS4_PWD_IC25SPAREB_SET(x)                                       (((x) << 26) & 0x1c000000)
-#define PHY_ANALOG_BIAS4_PWD_IC25SPAREA_MSB                                                                  31
-#define PHY_ANALOG_BIAS4_PWD_IC25SPAREA_LSB                                                                  29
-#define PHY_ANALOG_BIAS4_PWD_IC25SPAREA_MASK                                                         0xe0000000
-#define PHY_ANALOG_BIAS4_PWD_IC25SPAREA_GET(x)                                       (((x) & 0xe0000000) >> 29)
-#define PHY_ANALOG_BIAS4_PWD_IC25SPAREA_SET(x)                                       (((x) << 29) & 0xe0000000)
-
-/* macros for RXTX1 */
-#define PHY_ANALOG_RXTX1_ADDRESS                                                                     0x00000100
-#define PHY_ANALOG_RXTX1_OFFSET                                                                      0x00000100
-#define PHY_ANALOG_RXTX1_SCFIR_GAIN_MSB                                                                       0
-#define PHY_ANALOG_RXTX1_SCFIR_GAIN_LSB                                                                       0
-#define PHY_ANALOG_RXTX1_SCFIR_GAIN_MASK                                                             0x00000001
-#define PHY_ANALOG_RXTX1_SCFIR_GAIN_GET(x)                                            (((x) & 0x00000001) >> 0)
-#define PHY_ANALOG_RXTX1_SCFIR_GAIN_SET(x)                                            (((x) << 0) & 0x00000001)
-#define PHY_ANALOG_RXTX1_MANRXGAIN_MSB                                                                        1
-#define PHY_ANALOG_RXTX1_MANRXGAIN_LSB                                                                        1
-#define PHY_ANALOG_RXTX1_MANRXGAIN_MASK                                                              0x00000002
-#define PHY_ANALOG_RXTX1_MANRXGAIN_GET(x)                                             (((x) & 0x00000002) >> 1)
-#define PHY_ANALOG_RXTX1_MANRXGAIN_SET(x)                                             (((x) << 1) & 0x00000002)
-#define PHY_ANALOG_RXTX1_AGC_DBDAC_MSB                                                                        5
-#define PHY_ANALOG_RXTX1_AGC_DBDAC_LSB                                                                        2
-#define PHY_ANALOG_RXTX1_AGC_DBDAC_MASK                                                              0x0000003c
-#define PHY_ANALOG_RXTX1_AGC_DBDAC_GET(x)                                             (((x) & 0x0000003c) >> 2)
-#define PHY_ANALOG_RXTX1_AGC_DBDAC_SET(x)                                             (((x) << 2) & 0x0000003c)
-#define PHY_ANALOG_RXTX1_OVR_AGC_DBDAC_MSB                                                                    6
-#define PHY_ANALOG_RXTX1_OVR_AGC_DBDAC_LSB                                                                    6
-#define PHY_ANALOG_RXTX1_OVR_AGC_DBDAC_MASK                                                          0x00000040
-#define PHY_ANALOG_RXTX1_OVR_AGC_DBDAC_GET(x)                                         (((x) & 0x00000040) >> 6)
-#define PHY_ANALOG_RXTX1_OVR_AGC_DBDAC_SET(x)                                         (((x) << 6) & 0x00000040)
-#define PHY_ANALOG_RXTX1_ENABLE_PAL_MSB                                                                       7
-#define PHY_ANALOG_RXTX1_ENABLE_PAL_LSB                                                                       7
-#define PHY_ANALOG_RXTX1_ENABLE_PAL_MASK                                                             0x00000080
-#define PHY_ANALOG_RXTX1_ENABLE_PAL_GET(x)                                            (((x) & 0x00000080) >> 7)
-#define PHY_ANALOG_RXTX1_ENABLE_PAL_SET(x)                                            (((x) << 7) & 0x00000080)
-#define PHY_ANALOG_RXTX1_ENABLE_PAL_OVR_MSB                                                                   8
-#define PHY_ANALOG_RXTX1_ENABLE_PAL_OVR_LSB                                                                   8
-#define PHY_ANALOG_RXTX1_ENABLE_PAL_OVR_MASK                                                         0x00000100
-#define PHY_ANALOG_RXTX1_ENABLE_PAL_OVR_GET(x)                                        (((x) & 0x00000100) >> 8)
-#define PHY_ANALOG_RXTX1_ENABLE_PAL_OVR_SET(x)                                        (((x) << 8) & 0x00000100)
-#define PHY_ANALOG_RXTX1_TX1DB_BIQUAD_MSB                                                                    11
-#define PHY_ANALOG_RXTX1_TX1DB_BIQUAD_LSB                                                                     9
-#define PHY_ANALOG_RXTX1_TX1DB_BIQUAD_MASK                                                           0x00000e00
-#define PHY_ANALOG_RXTX1_TX1DB_BIQUAD_GET(x)                                          (((x) & 0x00000e00) >> 9)
-#define PHY_ANALOG_RXTX1_TX1DB_BIQUAD_SET(x)                                          (((x) << 9) & 0x00000e00)
-#define PHY_ANALOG_RXTX1_TX6DB_BIQUAD_MSB                                                                    13
-#define PHY_ANALOG_RXTX1_TX6DB_BIQUAD_LSB                                                                    12
-#define PHY_ANALOG_RXTX1_TX6DB_BIQUAD_MASK                                                           0x00003000
-#define PHY_ANALOG_RXTX1_TX6DB_BIQUAD_GET(x)                                         (((x) & 0x00003000) >> 12)
-#define PHY_ANALOG_RXTX1_TX6DB_BIQUAD_SET(x)                                         (((x) << 12) & 0x00003000)
-#define PHY_ANALOG_RXTX1_PADRVHALFGN2G_MSB                                                                   14
-#define PHY_ANALOG_RXTX1_PADRVHALFGN2G_LSB                                                                   14
-#define PHY_ANALOG_RXTX1_PADRVHALFGN2G_MASK                                                          0x00004000
-#define PHY_ANALOG_RXTX1_PADRVHALFGN2G_GET(x)                                        (((x) & 0x00004000) >> 14)
-#define PHY_ANALOG_RXTX1_PADRVHALFGN2G_SET(x)                                        (((x) << 14) & 0x00004000)
-#define PHY_ANALOG_RXTX1_PADRV2GN_MSB                                                                        18
-#define PHY_ANALOG_RXTX1_PADRV2GN_LSB                                                                        15
-#define PHY_ANALOG_RXTX1_PADRV2GN_MASK                                                               0x00078000
-#define PHY_ANALOG_RXTX1_PADRV2GN_GET(x)                                             (((x) & 0x00078000) >> 15)
-#define PHY_ANALOG_RXTX1_PADRV2GN_SET(x)                                             (((x) << 15) & 0x00078000)
-#define PHY_ANALOG_RXTX1_PADRV3GN5G_MSB                                                                      22
-#define PHY_ANALOG_RXTX1_PADRV3GN5G_LSB                                                                      19
-#define PHY_ANALOG_RXTX1_PADRV3GN5G_MASK                                                             0x00780000
-#define PHY_ANALOG_RXTX1_PADRV3GN5G_GET(x)                                           (((x) & 0x00780000) >> 19)
-#define PHY_ANALOG_RXTX1_PADRV3GN5G_SET(x)                                           (((x) << 19) & 0x00780000)
-#define PHY_ANALOG_RXTX1_PADRV4GN5G_MSB                                                                      26
-#define PHY_ANALOG_RXTX1_PADRV4GN5G_LSB                                                                      23
-#define PHY_ANALOG_RXTX1_PADRV4GN5G_MASK                                                             0x07800000
-#define PHY_ANALOG_RXTX1_PADRV4GN5G_GET(x)                                           (((x) & 0x07800000) >> 23)
-#define PHY_ANALOG_RXTX1_PADRV4GN5G_SET(x)                                           (((x) << 23) & 0x07800000)
-#define PHY_ANALOG_RXTX1_TXBB_GC_MSB                                                                         30
-#define PHY_ANALOG_RXTX1_TXBB_GC_LSB                                                                         27
-#define PHY_ANALOG_RXTX1_TXBB_GC_MASK                                                                0x78000000
-#define PHY_ANALOG_RXTX1_TXBB_GC_GET(x)                                              (((x) & 0x78000000) >> 27)
-#define PHY_ANALOG_RXTX1_TXBB_GC_SET(x)                                              (((x) << 27) & 0x78000000)
-#define PHY_ANALOG_RXTX1_MANTXGAIN_MSB                                                                       31
-#define PHY_ANALOG_RXTX1_MANTXGAIN_LSB                                                                       31
-#define PHY_ANALOG_RXTX1_MANTXGAIN_MASK                                                              0x80000000
-#define PHY_ANALOG_RXTX1_MANTXGAIN_GET(x)                                            (((x) & 0x80000000) >> 31)
-#define PHY_ANALOG_RXTX1_MANTXGAIN_SET(x)                                            (((x) << 31) & 0x80000000)
-
-/* macros for RXTX2 */
-#define PHY_ANALOG_RXTX2_ADDRESS                                                                     0x00000104
-#define PHY_ANALOG_RXTX2_OFFSET                                                                      0x00000104
-#define PHY_ANALOG_RXTX2_BMODE_MSB                                                                            0
-#define PHY_ANALOG_RXTX2_BMODE_LSB                                                                            0
-#define PHY_ANALOG_RXTX2_BMODE_MASK                                                                  0x00000001
-#define PHY_ANALOG_RXTX2_BMODE_GET(x)                                                 (((x) & 0x00000001) >> 0)
-#define PHY_ANALOG_RXTX2_BMODE_SET(x)                                                 (((x) << 0) & 0x00000001)
-#define PHY_ANALOG_RXTX2_BMODE_OVR_MSB                                                                        1
-#define PHY_ANALOG_RXTX2_BMODE_OVR_LSB                                                                        1
-#define PHY_ANALOG_RXTX2_BMODE_OVR_MASK                                                              0x00000002
-#define PHY_ANALOG_RXTX2_BMODE_OVR_GET(x)                                             (((x) & 0x00000002) >> 1)
-#define PHY_ANALOG_RXTX2_BMODE_OVR_SET(x)                                             (((x) << 1) & 0x00000002)
-#define PHY_ANALOG_RXTX2_SYNTHON_MSB                                                                          2
-#define PHY_ANALOG_RXTX2_SYNTHON_LSB                                                                          2
-#define PHY_ANALOG_RXTX2_SYNTHON_MASK                                                                0x00000004
-#define PHY_ANALOG_RXTX2_SYNTHON_GET(x)                                               (((x) & 0x00000004) >> 2)
-#define PHY_ANALOG_RXTX2_SYNTHON_SET(x)                                               (((x) << 2) & 0x00000004)
-#define PHY_ANALOG_RXTX2_SYNTHON_OVR_MSB                                                                      3
-#define PHY_ANALOG_RXTX2_SYNTHON_OVR_LSB                                                                      3
-#define PHY_ANALOG_RXTX2_SYNTHON_OVR_MASK                                                            0x00000008
-#define PHY_ANALOG_RXTX2_SYNTHON_OVR_GET(x)                                           (((x) & 0x00000008) >> 3)
-#define PHY_ANALOG_RXTX2_SYNTHON_OVR_SET(x)                                           (((x) << 3) & 0x00000008)
-#define PHY_ANALOG_RXTX2_BW_ST_MSB                                                                            5
-#define PHY_ANALOG_RXTX2_BW_ST_LSB                                                                            4
-#define PHY_ANALOG_RXTX2_BW_ST_MASK                                                                  0x00000030
-#define PHY_ANALOG_RXTX2_BW_ST_GET(x)                                                 (((x) & 0x00000030) >> 4)
-#define PHY_ANALOG_RXTX2_BW_ST_SET(x)                                                 (((x) << 4) & 0x00000030)
-#define PHY_ANALOG_RXTX2_BW_ST_OVR_MSB                                                                        6
-#define PHY_ANALOG_RXTX2_BW_ST_OVR_LSB                                                                        6
-#define PHY_ANALOG_RXTX2_BW_ST_OVR_MASK                                                              0x00000040
-#define PHY_ANALOG_RXTX2_BW_ST_OVR_GET(x)                                             (((x) & 0x00000040) >> 6)
-#define PHY_ANALOG_RXTX2_BW_ST_OVR_SET(x)                                             (((x) << 6) & 0x00000040)
-#define PHY_ANALOG_RXTX2_TXON_MSB                                                                             7
-#define PHY_ANALOG_RXTX2_TXON_LSB                                                                             7
-#define PHY_ANALOG_RXTX2_TXON_MASK                                                                   0x00000080
-#define PHY_ANALOG_RXTX2_TXON_GET(x)                                                  (((x) & 0x00000080) >> 7)
-#define PHY_ANALOG_RXTX2_TXON_SET(x)                                                  (((x) << 7) & 0x00000080)
-#define PHY_ANALOG_RXTX2_TXON_OVR_MSB                                                                         8
-#define PHY_ANALOG_RXTX2_TXON_OVR_LSB                                                                         8
-#define PHY_ANALOG_RXTX2_TXON_OVR_MASK                                                               0x00000100
-#define PHY_ANALOG_RXTX2_TXON_OVR_GET(x)                                              (((x) & 0x00000100) >> 8)
-#define PHY_ANALOG_RXTX2_TXON_OVR_SET(x)                                              (((x) << 8) & 0x00000100)
-#define PHY_ANALOG_RXTX2_PAON_MSB                                                                             9
-#define PHY_ANALOG_RXTX2_PAON_LSB                                                                             9
-#define PHY_ANALOG_RXTX2_PAON_MASK                                                                   0x00000200
-#define PHY_ANALOG_RXTX2_PAON_GET(x)                                                  (((x) & 0x00000200) >> 9)
-#define PHY_ANALOG_RXTX2_PAON_SET(x)                                                  (((x) << 9) & 0x00000200)
-#define PHY_ANALOG_RXTX2_PAON_OVR_MSB                                                                        10
-#define PHY_ANALOG_RXTX2_PAON_OVR_LSB                                                                        10
-#define PHY_ANALOG_RXTX2_PAON_OVR_MASK                                                               0x00000400
-#define PHY_ANALOG_RXTX2_PAON_OVR_GET(x)                                             (((x) & 0x00000400) >> 10)
-#define PHY_ANALOG_RXTX2_PAON_OVR_SET(x)                                             (((x) << 10) & 0x00000400)
-#define PHY_ANALOG_RXTX2_RXON_MSB                                                                            11
-#define PHY_ANALOG_RXTX2_RXON_LSB                                                                            11
-#define PHY_ANALOG_RXTX2_RXON_MASK                                                                   0x00000800
-#define PHY_ANALOG_RXTX2_RXON_GET(x)                                                 (((x) & 0x00000800) >> 11)
-#define PHY_ANALOG_RXTX2_RXON_SET(x)                                                 (((x) << 11) & 0x00000800)
-#define PHY_ANALOG_RXTX2_RXON_OVR_MSB                                                                        12
-#define PHY_ANALOG_RXTX2_RXON_OVR_LSB                                                                        12
-#define PHY_ANALOG_RXTX2_RXON_OVR_MASK                                                               0x00001000
-#define PHY_ANALOG_RXTX2_RXON_OVR_GET(x)                                             (((x) & 0x00001000) >> 12)
-#define PHY_ANALOG_RXTX2_RXON_OVR_SET(x)                                             (((x) << 12) & 0x00001000)
-#define PHY_ANALOG_RXTX2_AGCON_MSB                                                                           13
-#define PHY_ANALOG_RXTX2_AGCON_LSB                                                                           13
-#define PHY_ANALOG_RXTX2_AGCON_MASK                                                                  0x00002000
-#define PHY_ANALOG_RXTX2_AGCON_GET(x)                                                (((x) & 0x00002000) >> 13)
-#define PHY_ANALOG_RXTX2_AGCON_SET(x)                                                (((x) << 13) & 0x00002000)
-#define PHY_ANALOG_RXTX2_AGCON_OVR_MSB                                                                       14
-#define PHY_ANALOG_RXTX2_AGCON_OVR_LSB                                                                       14
-#define PHY_ANALOG_RXTX2_AGCON_OVR_MASK                                                              0x00004000
-#define PHY_ANALOG_RXTX2_AGCON_OVR_GET(x)                                            (((x) & 0x00004000) >> 14)
-#define PHY_ANALOG_RXTX2_AGCON_OVR_SET(x)                                            (((x) << 14) & 0x00004000)
-#define PHY_ANALOG_RXTX2_TXMOD_MSB                                                                           17
-#define PHY_ANALOG_RXTX2_TXMOD_LSB                                                                           15
-#define PHY_ANALOG_RXTX2_TXMOD_MASK                                                                  0x00038000
-#define PHY_ANALOG_RXTX2_TXMOD_GET(x)                                                (((x) & 0x00038000) >> 15)
-#define PHY_ANALOG_RXTX2_TXMOD_SET(x)                                                (((x) << 15) & 0x00038000)
-#define PHY_ANALOG_RXTX2_TXMOD_OVR_MSB                                                                       18
-#define PHY_ANALOG_RXTX2_TXMOD_OVR_LSB                                                                       18
-#define PHY_ANALOG_RXTX2_TXMOD_OVR_MASK                                                              0x00040000
-#define PHY_ANALOG_RXTX2_TXMOD_OVR_GET(x)                                            (((x) & 0x00040000) >> 18)
-#define PHY_ANALOG_RXTX2_TXMOD_OVR_SET(x)                                            (((x) << 18) & 0x00040000)
-#define PHY_ANALOG_RXTX2_RX1DB_BIQUAD_MSB                                                                    21
-#define PHY_ANALOG_RXTX2_RX1DB_BIQUAD_LSB                                                                    19
-#define PHY_ANALOG_RXTX2_RX1DB_BIQUAD_MASK                                                           0x00380000
-#define PHY_ANALOG_RXTX2_RX1DB_BIQUAD_GET(x)                                         (((x) & 0x00380000) >> 19)
-#define PHY_ANALOG_RXTX2_RX1DB_BIQUAD_SET(x)                                         (((x) << 19) & 0x00380000)
-#define PHY_ANALOG_RXTX2_RX6DB_BIQUAD_MSB                                                                    23
-#define PHY_ANALOG_RXTX2_RX6DB_BIQUAD_LSB                                                                    22
-#define PHY_ANALOG_RXTX2_RX6DB_BIQUAD_MASK                                                           0x00c00000
-#define PHY_ANALOG_RXTX2_RX6DB_BIQUAD_GET(x)                                         (((x) & 0x00c00000) >> 22)
-#define PHY_ANALOG_RXTX2_RX6DB_BIQUAD_SET(x)                                         (((x) << 22) & 0x00c00000)
-#define PHY_ANALOG_RXTX2_MXRGAIN_MSB                                                                         25
-#define PHY_ANALOG_RXTX2_MXRGAIN_LSB                                                                         24
-#define PHY_ANALOG_RXTX2_MXRGAIN_MASK                                                                0x03000000
-#define PHY_ANALOG_RXTX2_MXRGAIN_GET(x)                                              (((x) & 0x03000000) >> 24)
-#define PHY_ANALOG_RXTX2_MXRGAIN_SET(x)                                              (((x) << 24) & 0x03000000)
-#define PHY_ANALOG_RXTX2_VGAGAIN_MSB                                                                         28
-#define PHY_ANALOG_RXTX2_VGAGAIN_LSB                                                                         26
-#define PHY_ANALOG_RXTX2_VGAGAIN_MASK                                                                0x1c000000
-#define PHY_ANALOG_RXTX2_VGAGAIN_GET(x)                                              (((x) & 0x1c000000) >> 26)
-#define PHY_ANALOG_RXTX2_VGAGAIN_SET(x)                                              (((x) << 26) & 0x1c000000)
-#define PHY_ANALOG_RXTX2_LNAGAIN_MSB                                                                         31
-#define PHY_ANALOG_RXTX2_LNAGAIN_LSB                                                                         29
-#define PHY_ANALOG_RXTX2_LNAGAIN_MASK                                                                0xe0000000
-#define PHY_ANALOG_RXTX2_LNAGAIN_GET(x)                                              (((x) & 0xe0000000) >> 29)
-#define PHY_ANALOG_RXTX2_LNAGAIN_SET(x)                                              (((x) << 29) & 0xe0000000)
-
-/* macros for RXTX3 */
-#define PHY_ANALOG_RXTX3_ADDRESS                                                                     0x00000108
-#define PHY_ANALOG_RXTX3_OFFSET                                                                      0x00000108
-#define PHY_ANALOG_RXTX3_SPARE3_MSB                                                                           2
-#define PHY_ANALOG_RXTX3_SPARE3_LSB                                                                           0
-#define PHY_ANALOG_RXTX3_SPARE3_MASK                                                                 0x00000007
-#define PHY_ANALOG_RXTX3_SPARE3_GET(x)                                                (((x) & 0x00000007) >> 0)
-#define PHY_ANALOG_RXTX3_SPARE3_SET(x)                                                (((x) << 0) & 0x00000007)
-#define PHY_ANALOG_RXTX3_DACFULLSCALE_MSB                                                                     3
-#define PHY_ANALOG_RXTX3_DACFULLSCALE_LSB                                                                     3
-#define PHY_ANALOG_RXTX3_DACFULLSCALE_MASK                                                           0x00000008
-#define PHY_ANALOG_RXTX3_DACFULLSCALE_GET(x)                                          (((x) & 0x00000008) >> 3)
-#define PHY_ANALOG_RXTX3_DACFULLSCALE_SET(x)                                          (((x) << 3) & 0x00000008)
-#define PHY_ANALOG_RXTX3_DACRSTB_MSB                                                                          4
-#define PHY_ANALOG_RXTX3_DACRSTB_LSB                                                                          4
-#define PHY_ANALOG_RXTX3_DACRSTB_MASK                                                                0x00000010
-#define PHY_ANALOG_RXTX3_DACRSTB_GET(x)                                               (((x) & 0x00000010) >> 4)
-#define PHY_ANALOG_RXTX3_DACRSTB_SET(x)                                               (((x) << 4) & 0x00000010)
-#define PHY_ANALOG_RXTX3_ADDACLOOPBACK_MSB                                                                    5
-#define PHY_ANALOG_RXTX3_ADDACLOOPBACK_LSB                                                                    5
-#define PHY_ANALOG_RXTX3_ADDACLOOPBACK_MASK                                                          0x00000020
-#define PHY_ANALOG_RXTX3_ADDACLOOPBACK_GET(x)                                         (((x) & 0x00000020) >> 5)
-#define PHY_ANALOG_RXTX3_ADDACLOOPBACK_SET(x)                                         (((x) << 5) & 0x00000020)
-#define PHY_ANALOG_RXTX3_ADCSHORT_MSB                                                                         6
-#define PHY_ANALOG_RXTX3_ADCSHORT_LSB                                                                         6
-#define PHY_ANALOG_RXTX3_ADCSHORT_MASK                                                               0x00000040
-#define PHY_ANALOG_RXTX3_ADCSHORT_GET(x)                                              (((x) & 0x00000040) >> 6)
-#define PHY_ANALOG_RXTX3_ADCSHORT_SET(x)                                              (((x) << 6) & 0x00000040)
-#define PHY_ANALOG_RXTX3_DACPWD_MSB                                                                           7
-#define PHY_ANALOG_RXTX3_DACPWD_LSB                                                                           7
-#define PHY_ANALOG_RXTX3_DACPWD_MASK                                                                 0x00000080
-#define PHY_ANALOG_RXTX3_DACPWD_GET(x)                                                (((x) & 0x00000080) >> 7)
-#define PHY_ANALOG_RXTX3_DACPWD_SET(x)                                                (((x) << 7) & 0x00000080)
-#define PHY_ANALOG_RXTX3_DACPWD_OVR_MSB                                                                       8
-#define PHY_ANALOG_RXTX3_DACPWD_OVR_LSB                                                                       8
-#define PHY_ANALOG_RXTX3_DACPWD_OVR_MASK                                                             0x00000100
-#define PHY_ANALOG_RXTX3_DACPWD_OVR_GET(x)                                            (((x) & 0x00000100) >> 8)
-#define PHY_ANALOG_RXTX3_DACPWD_OVR_SET(x)                                            (((x) << 8) & 0x00000100)
-#define PHY_ANALOG_RXTX3_ADCPWD_MSB                                                                           9
-#define PHY_ANALOG_RXTX3_ADCPWD_LSB                                                                           9
-#define PHY_ANALOG_RXTX3_ADCPWD_MASK                                                                 0x00000200
-#define PHY_ANALOG_RXTX3_ADCPWD_GET(x)                                                (((x) & 0x00000200) >> 9)
-#define PHY_ANALOG_RXTX3_ADCPWD_SET(x)                                                (((x) << 9) & 0x00000200)
-#define PHY_ANALOG_RXTX3_ADCPWD_OVR_MSB                                                                      10
-#define PHY_ANALOG_RXTX3_ADCPWD_OVR_LSB                                                                      10
-#define PHY_ANALOG_RXTX3_ADCPWD_OVR_MASK                                                             0x00000400
-#define PHY_ANALOG_RXTX3_ADCPWD_OVR_GET(x)                                           (((x) & 0x00000400) >> 10)
-#define PHY_ANALOG_RXTX3_ADCPWD_OVR_SET(x)                                           (((x) << 10) & 0x00000400)
-#define PHY_ANALOG_RXTX3_AGC_CALDAC_MSB                                                                      16
-#define PHY_ANALOG_RXTX3_AGC_CALDAC_LSB                                                                      11
-#define PHY_ANALOG_RXTX3_AGC_CALDAC_MASK                                                             0x0001f800
-#define PHY_ANALOG_RXTX3_AGC_CALDAC_GET(x)                                           (((x) & 0x0001f800) >> 11)
-#define PHY_ANALOG_RXTX3_AGC_CALDAC_SET(x)                                           (((x) << 11) & 0x0001f800)
-#define PHY_ANALOG_RXTX3_AGC_CAL_MSB                                                                         17
-#define PHY_ANALOG_RXTX3_AGC_CAL_LSB                                                                         17
-#define PHY_ANALOG_RXTX3_AGC_CAL_MASK                                                                0x00020000
-#define PHY_ANALOG_RXTX3_AGC_CAL_GET(x)                                              (((x) & 0x00020000) >> 17)
-#define PHY_ANALOG_RXTX3_AGC_CAL_SET(x)                                              (((x) << 17) & 0x00020000)
-#define PHY_ANALOG_RXTX3_AGC_CAL_OVR_MSB                                                                     18
-#define PHY_ANALOG_RXTX3_AGC_CAL_OVR_LSB                                                                     18
-#define PHY_ANALOG_RXTX3_AGC_CAL_OVR_MASK                                                            0x00040000
-#define PHY_ANALOG_RXTX3_AGC_CAL_OVR_GET(x)                                          (((x) & 0x00040000) >> 18)
-#define PHY_ANALOG_RXTX3_AGC_CAL_OVR_SET(x)                                          (((x) << 18) & 0x00040000)
-#define PHY_ANALOG_RXTX3_LOFORCEDON_MSB                                                                      19
-#define PHY_ANALOG_RXTX3_LOFORCEDON_LSB                                                                      19
-#define PHY_ANALOG_RXTX3_LOFORCEDON_MASK                                                             0x00080000
-#define PHY_ANALOG_RXTX3_LOFORCEDON_GET(x)                                           (((x) & 0x00080000) >> 19)
-#define PHY_ANALOG_RXTX3_LOFORCEDON_SET(x)                                           (((x) << 19) & 0x00080000)
-#define PHY_ANALOG_RXTX3_CALRESIDUE_MSB                                                                      20
-#define PHY_ANALOG_RXTX3_CALRESIDUE_LSB                                                                      20
-#define PHY_ANALOG_RXTX3_CALRESIDUE_MASK                                                             0x00100000
-#define PHY_ANALOG_RXTX3_CALRESIDUE_GET(x)                                           (((x) & 0x00100000) >> 20)
-#define PHY_ANALOG_RXTX3_CALRESIDUE_SET(x)                                           (((x) << 20) & 0x00100000)
-#define PHY_ANALOG_RXTX3_CALRESIDUE_OVR_MSB                                                                  21
-#define PHY_ANALOG_RXTX3_CALRESIDUE_OVR_LSB                                                                  21
-#define PHY_ANALOG_RXTX3_CALRESIDUE_OVR_MASK                                                         0x00200000
-#define PHY_ANALOG_RXTX3_CALRESIDUE_OVR_GET(x)                                       (((x) & 0x00200000) >> 21)
-#define PHY_ANALOG_RXTX3_CALRESIDUE_OVR_SET(x)                                       (((x) << 21) & 0x00200000)
-#define PHY_ANALOG_RXTX3_CALFC_MSB                                                                           22
-#define PHY_ANALOG_RXTX3_CALFC_LSB                                                                           22
-#define PHY_ANALOG_RXTX3_CALFC_MASK                                                                  0x00400000
-#define PHY_ANALOG_RXTX3_CALFC_GET(x)                                                (((x) & 0x00400000) >> 22)
-#define PHY_ANALOG_RXTX3_CALFC_SET(x)                                                (((x) << 22) & 0x00400000)
-#define PHY_ANALOG_RXTX3_CALFC_OVR_MSB                                                                       23
-#define PHY_ANALOG_RXTX3_CALFC_OVR_LSB                                                                       23
-#define PHY_ANALOG_RXTX3_CALFC_OVR_MASK                                                              0x00800000
-#define PHY_ANALOG_RXTX3_CALFC_OVR_GET(x)                                            (((x) & 0x00800000) >> 23)
-#define PHY_ANALOG_RXTX3_CALFC_OVR_SET(x)                                            (((x) << 23) & 0x00800000)
-#define PHY_ANALOG_RXTX3_CALTX_MSB                                                                           24
-#define PHY_ANALOG_RXTX3_CALTX_LSB                                                                           24
-#define PHY_ANALOG_RXTX3_CALTX_MASK                                                                  0x01000000
-#define PHY_ANALOG_RXTX3_CALTX_GET(x)                                                (((x) & 0x01000000) >> 24)
-#define PHY_ANALOG_RXTX3_CALTX_SET(x)                                                (((x) << 24) & 0x01000000)
-#define PHY_ANALOG_RXTX3_CALTX_OVR_MSB                                                                       25
-#define PHY_ANALOG_RXTX3_CALTX_OVR_LSB                                                                       25
-#define PHY_ANALOG_RXTX3_CALTX_OVR_MASK                                                              0x02000000
-#define PHY_ANALOG_RXTX3_CALTX_OVR_GET(x)                                            (((x) & 0x02000000) >> 25)
-#define PHY_ANALOG_RXTX3_CALTX_OVR_SET(x)                                            (((x) << 25) & 0x02000000)
-#define PHY_ANALOG_RXTX3_CALTXSHIFT_MSB                                                                      26
-#define PHY_ANALOG_RXTX3_CALTXSHIFT_LSB                                                                      26
-#define PHY_ANALOG_RXTX3_CALTXSHIFT_MASK                                                             0x04000000
-#define PHY_ANALOG_RXTX3_CALTXSHIFT_GET(x)                                           (((x) & 0x04000000) >> 26)
-#define PHY_ANALOG_RXTX3_CALTXSHIFT_SET(x)                                           (((x) << 26) & 0x04000000)
-#define PHY_ANALOG_RXTX3_CALTXSHIFT_OVR_MSB                                                                  27
-#define PHY_ANALOG_RXTX3_CALTXSHIFT_OVR_LSB                                                                  27
-#define PHY_ANALOG_RXTX3_CALTXSHIFT_OVR_MASK                                                         0x08000000
-#define PHY_ANALOG_RXTX3_CALTXSHIFT_OVR_GET(x)                                       (((x) & 0x08000000) >> 27)
-#define PHY_ANALOG_RXTX3_CALTXSHIFT_OVR_SET(x)                                       (((x) << 27) & 0x08000000)
-#define PHY_ANALOG_RXTX3_CALPA_MSB                                                                           28
-#define PHY_ANALOG_RXTX3_CALPA_LSB                                                                           28
-#define PHY_ANALOG_RXTX3_CALPA_MASK                                                                  0x10000000
-#define PHY_ANALOG_RXTX3_CALPA_GET(x)                                                (((x) & 0x10000000) >> 28)
-#define PHY_ANALOG_RXTX3_CALPA_SET(x)                                                (((x) << 28) & 0x10000000)
-#define PHY_ANALOG_RXTX3_CALPA_OVR_MSB                                                                       29
-#define PHY_ANALOG_RXTX3_CALPA_OVR_LSB                                                                       29
-#define PHY_ANALOG_RXTX3_CALPA_OVR_MASK                                                              0x20000000
-#define PHY_ANALOG_RXTX3_CALPA_OVR_GET(x)                                            (((x) & 0x20000000) >> 29)
-#define PHY_ANALOG_RXTX3_CALPA_OVR_SET(x)                                            (((x) << 29) & 0x20000000)
-#define PHY_ANALOG_RXTX3_SPURON_MSB                                                                          30
-#define PHY_ANALOG_RXTX3_SPURON_LSB                                                                          30
-#define PHY_ANALOG_RXTX3_SPURON_MASK                                                                 0x40000000
-#define PHY_ANALOG_RXTX3_SPURON_GET(x)                                               (((x) & 0x40000000) >> 30)
-#define PHY_ANALOG_RXTX3_SPURON_SET(x)                                               (((x) << 30) & 0x40000000)
-#define PHY_ANALOG_RXTX3_SPURON_OVR_MSB                                                                      31
-#define PHY_ANALOG_RXTX3_SPURON_OVR_LSB                                                                      31
-#define PHY_ANALOG_RXTX3_SPURON_OVR_MASK                                                             0x80000000
-#define PHY_ANALOG_RXTX3_SPURON_OVR_GET(x)                                           (((x) & 0x80000000) >> 31)
-#define PHY_ANALOG_RXTX3_SPURON_OVR_SET(x)                                           (((x) << 31) & 0x80000000)
-
-/* macros for BB1 */
-#define PHY_ANALOG_BB1_ADDRESS                                                                       0x00000140
-#define PHY_ANALOG_BB1_OFFSET                                                                        0x00000140
-#define PHY_ANALOG_BB1_I2V_CURR2X_MSB                                                                         0
-#define PHY_ANALOG_BB1_I2V_CURR2X_LSB                                                                         0
-#define PHY_ANALOG_BB1_I2V_CURR2X_MASK                                                               0x00000001
-#define PHY_ANALOG_BB1_I2V_CURR2X_GET(x)                                              (((x) & 0x00000001) >> 0)
-#define PHY_ANALOG_BB1_I2V_CURR2X_SET(x)                                              (((x) << 0) & 0x00000001)
-#define PHY_ANALOG_BB1_ENABLE_LOQ_MSB                                                                         1
-#define PHY_ANALOG_BB1_ENABLE_LOQ_LSB                                                                         1
-#define PHY_ANALOG_BB1_ENABLE_LOQ_MASK                                                               0x00000002
-#define PHY_ANALOG_BB1_ENABLE_LOQ_GET(x)                                              (((x) & 0x00000002) >> 1)
-#define PHY_ANALOG_BB1_ENABLE_LOQ_SET(x)                                              (((x) << 1) & 0x00000002)
-#define PHY_ANALOG_BB1_FORCE_LOQ_MSB                                                                          2
-#define PHY_ANALOG_BB1_FORCE_LOQ_LSB                                                                          2
-#define PHY_ANALOG_BB1_FORCE_LOQ_MASK                                                                0x00000004
-#define PHY_ANALOG_BB1_FORCE_LOQ_GET(x)                                               (((x) & 0x00000004) >> 2)
-#define PHY_ANALOG_BB1_FORCE_LOQ_SET(x)                                               (((x) << 2) & 0x00000004)
-#define PHY_ANALOG_BB1_ENABLE_NOTCH_MSB                                                                       3
-#define PHY_ANALOG_BB1_ENABLE_NOTCH_LSB                                                                       3
-#define PHY_ANALOG_BB1_ENABLE_NOTCH_MASK                                                             0x00000008
-#define PHY_ANALOG_BB1_ENABLE_NOTCH_GET(x)                                            (((x) & 0x00000008) >> 3)
-#define PHY_ANALOG_BB1_ENABLE_NOTCH_SET(x)                                            (((x) << 3) & 0x00000008)
-#define PHY_ANALOG_BB1_FORCE_NOTCH_MSB                                                                        4
-#define PHY_ANALOG_BB1_FORCE_NOTCH_LSB                                                                        4
-#define PHY_ANALOG_BB1_FORCE_NOTCH_MASK                                                              0x00000010
-#define PHY_ANALOG_BB1_FORCE_NOTCH_GET(x)                                             (((x) & 0x00000010) >> 4)
-#define PHY_ANALOG_BB1_FORCE_NOTCH_SET(x)                                             (((x) << 4) & 0x00000010)
-#define PHY_ANALOG_BB1_ENABLE_BIQUAD_MSB                                                                      5
-#define PHY_ANALOG_BB1_ENABLE_BIQUAD_LSB                                                                      5
-#define PHY_ANALOG_BB1_ENABLE_BIQUAD_MASK                                                            0x00000020
-#define PHY_ANALOG_BB1_ENABLE_BIQUAD_GET(x)                                           (((x) & 0x00000020) >> 5)
-#define PHY_ANALOG_BB1_ENABLE_BIQUAD_SET(x)                                           (((x) << 5) & 0x00000020)
-#define PHY_ANALOG_BB1_FORCE_BIQUAD_MSB                                                                       6
-#define PHY_ANALOG_BB1_FORCE_BIQUAD_LSB                                                                       6
-#define PHY_ANALOG_BB1_FORCE_BIQUAD_MASK                                                             0x00000040
-#define PHY_ANALOG_BB1_FORCE_BIQUAD_GET(x)                                            (((x) & 0x00000040) >> 6)
-#define PHY_ANALOG_BB1_FORCE_BIQUAD_SET(x)                                            (((x) << 6) & 0x00000040)
-#define PHY_ANALOG_BB1_ENABLE_OSDAC_MSB                                                                       7
-#define PHY_ANALOG_BB1_ENABLE_OSDAC_LSB                                                                       7
-#define PHY_ANALOG_BB1_ENABLE_OSDAC_MASK                                                             0x00000080
-#define PHY_ANALOG_BB1_ENABLE_OSDAC_GET(x)                                            (((x) & 0x00000080) >> 7)
-#define PHY_ANALOG_BB1_ENABLE_OSDAC_SET(x)                                            (((x) << 7) & 0x00000080)
-#define PHY_ANALOG_BB1_FORCE_OSDAC_MSB                                                                        8
-#define PHY_ANALOG_BB1_FORCE_OSDAC_LSB                                                                        8
-#define PHY_ANALOG_BB1_FORCE_OSDAC_MASK                                                              0x00000100
-#define PHY_ANALOG_BB1_FORCE_OSDAC_GET(x)                                             (((x) & 0x00000100) >> 8)
-#define PHY_ANALOG_BB1_FORCE_OSDAC_SET(x)                                             (((x) << 8) & 0x00000100)
-#define PHY_ANALOG_BB1_ENABLE_V2I_MSB                                                                         9
-#define PHY_ANALOG_BB1_ENABLE_V2I_LSB                                                                         9
-#define PHY_ANALOG_BB1_ENABLE_V2I_MASK                                                               0x00000200
-#define PHY_ANALOG_BB1_ENABLE_V2I_GET(x)                                              (((x) & 0x00000200) >> 9)
-#define PHY_ANALOG_BB1_ENABLE_V2I_SET(x)                                              (((x) << 9) & 0x00000200)
-#define PHY_ANALOG_BB1_FORCE_V2I_MSB                                                                         10
-#define PHY_ANALOG_BB1_FORCE_V2I_LSB                                                                         10
-#define PHY_ANALOG_BB1_FORCE_V2I_MASK                                                                0x00000400
-#define PHY_ANALOG_BB1_FORCE_V2I_GET(x)                                              (((x) & 0x00000400) >> 10)
-#define PHY_ANALOG_BB1_FORCE_V2I_SET(x)                                              (((x) << 10) & 0x00000400)
-#define PHY_ANALOG_BB1_ENABLE_I2V_MSB                                                                        11
-#define PHY_ANALOG_BB1_ENABLE_I2V_LSB                                                                        11
-#define PHY_ANALOG_BB1_ENABLE_I2V_MASK                                                               0x00000800
-#define PHY_ANALOG_BB1_ENABLE_I2V_GET(x)                                             (((x) & 0x00000800) >> 11)
-#define PHY_ANALOG_BB1_ENABLE_I2V_SET(x)                                             (((x) << 11) & 0x00000800)
-#define PHY_ANALOG_BB1_FORCE_I2V_MSB                                                                         12
-#define PHY_ANALOG_BB1_FORCE_I2V_LSB                                                                         12
-#define PHY_ANALOG_BB1_FORCE_I2V_MASK                                                                0x00001000
-#define PHY_ANALOG_BB1_FORCE_I2V_GET(x)                                              (((x) & 0x00001000) >> 12)
-#define PHY_ANALOG_BB1_FORCE_I2V_SET(x)                                              (((x) << 12) & 0x00001000)
-#define PHY_ANALOG_BB1_CMSEL_MSB                                                                             15
-#define PHY_ANALOG_BB1_CMSEL_LSB                                                                             13
-#define PHY_ANALOG_BB1_CMSEL_MASK                                                                    0x0000e000
-#define PHY_ANALOG_BB1_CMSEL_GET(x)                                                  (((x) & 0x0000e000) >> 13)
-#define PHY_ANALOG_BB1_CMSEL_SET(x)                                                  (((x) << 13) & 0x0000e000)
-#define PHY_ANALOG_BB1_ATBSEL_MSB                                                                            17
-#define PHY_ANALOG_BB1_ATBSEL_LSB                                                                            16
-#define PHY_ANALOG_BB1_ATBSEL_MASK                                                                   0x00030000
-#define PHY_ANALOG_BB1_ATBSEL_GET(x)                                                 (((x) & 0x00030000) >> 16)
-#define PHY_ANALOG_BB1_ATBSEL_SET(x)                                                 (((x) << 16) & 0x00030000)
-#define PHY_ANALOG_BB1_PD_OSDAC_CALTX_CALPA_MSB                                                              18
-#define PHY_ANALOG_BB1_PD_OSDAC_CALTX_CALPA_LSB                                                              18
-#define PHY_ANALOG_BB1_PD_OSDAC_CALTX_CALPA_MASK                                                     0x00040000
-#define PHY_ANALOG_BB1_PD_OSDAC_CALTX_CALPA_GET(x)                                   (((x) & 0x00040000) >> 18)
-#define PHY_ANALOG_BB1_PD_OSDAC_CALTX_CALPA_SET(x)                                   (((x) << 18) & 0x00040000)
-#define PHY_ANALOG_BB1_OFSTCORRI2VQ_MSB                                                                      23
-#define PHY_ANALOG_BB1_OFSTCORRI2VQ_LSB                                                                      19
-#define PHY_ANALOG_BB1_OFSTCORRI2VQ_MASK                                                             0x00f80000
-#define PHY_ANALOG_BB1_OFSTCORRI2VQ_GET(x)                                           (((x) & 0x00f80000) >> 19)
-#define PHY_ANALOG_BB1_OFSTCORRI2VQ_SET(x)                                           (((x) << 19) & 0x00f80000)
-#define PHY_ANALOG_BB1_OFSTCORRI2VI_MSB                                                                      28
-#define PHY_ANALOG_BB1_OFSTCORRI2VI_LSB                                                                      24
-#define PHY_ANALOG_BB1_OFSTCORRI2VI_MASK                                                             0x1f000000
-#define PHY_ANALOG_BB1_OFSTCORRI2VI_GET(x)                                           (((x) & 0x1f000000) >> 24)
-#define PHY_ANALOG_BB1_OFSTCORRI2VI_SET(x)                                           (((x) << 24) & 0x1f000000)
-#define PHY_ANALOG_BB1_LOCALOFFSET_MSB                                                                       29
-#define PHY_ANALOG_BB1_LOCALOFFSET_LSB                                                                       29
-#define PHY_ANALOG_BB1_LOCALOFFSET_MASK                                                              0x20000000
-#define PHY_ANALOG_BB1_LOCALOFFSET_GET(x)                                            (((x) & 0x20000000) >> 29)
-#define PHY_ANALOG_BB1_LOCALOFFSET_SET(x)                                            (((x) << 29) & 0x20000000)
-#define PHY_ANALOG_BB1_RANGE_OSDAC_MSB                                                                       31
-#define PHY_ANALOG_BB1_RANGE_OSDAC_LSB                                                                       30
-#define PHY_ANALOG_BB1_RANGE_OSDAC_MASK                                                              0xc0000000
-#define PHY_ANALOG_BB1_RANGE_OSDAC_GET(x)                                            (((x) & 0xc0000000) >> 30)
-#define PHY_ANALOG_BB1_RANGE_OSDAC_SET(x)                                            (((x) << 30) & 0xc0000000)
-
-/* macros for BB2 */
-#define PHY_ANALOG_BB2_ADDRESS                                                                       0x00000144
-#define PHY_ANALOG_BB2_OFFSET                                                                        0x00000144
-#define PHY_ANALOG_BB2_SPARE_MSB                                                                              6
-#define PHY_ANALOG_BB2_SPARE_LSB                                                                              0
-#define PHY_ANALOG_BB2_SPARE_MASK                                                                    0x0000007f
-#define PHY_ANALOG_BB2_SPARE_GET(x)                                                   (((x) & 0x0000007f) >> 0)
-#define PHY_ANALOG_BB2_SPARE_SET(x)                                                   (((x) << 0) & 0x0000007f)
-#define PHY_ANALOG_BB2_SEL_TEST_MSB                                                                           9
-#define PHY_ANALOG_BB2_SEL_TEST_LSB                                                                           7
-#define PHY_ANALOG_BB2_SEL_TEST_MASK                                                                 0x00000380
-#define PHY_ANALOG_BB2_SEL_TEST_GET(x)                                                (((x) & 0x00000380) >> 7)
-#define PHY_ANALOG_BB2_SEL_TEST_SET(x)                                                (((x) << 7) & 0x00000380)
-#define PHY_ANALOG_BB2_SCFIR_CAP_MSB                                                                         14
-#define PHY_ANALOG_BB2_SCFIR_CAP_LSB                                                                         10
-#define PHY_ANALOG_BB2_SCFIR_CAP_MASK                                                                0x00007c00
-#define PHY_ANALOG_BB2_SCFIR_CAP_GET(x)                                              (((x) & 0x00007c00) >> 10)
-#define PHY_ANALOG_BB2_SCFIR_CAP_SET(x)                                              (((x) << 10) & 0x00007c00)
-#define PHY_ANALOG_BB2_OVERRIDE_SCFIR_CAP_MSB                                                                15
-#define PHY_ANALOG_BB2_OVERRIDE_SCFIR_CAP_LSB                                                                15
-#define PHY_ANALOG_BB2_OVERRIDE_SCFIR_CAP_MASK                                                       0x00008000
-#define PHY_ANALOG_BB2_OVERRIDE_SCFIR_CAP_GET(x)                                     (((x) & 0x00008000) >> 15)
-#define PHY_ANALOG_BB2_OVERRIDE_SCFIR_CAP_SET(x)                                     (((x) << 15) & 0x00008000)
-#define PHY_ANALOG_BB2_FNOTCH_MSB                                                                            19
-#define PHY_ANALOG_BB2_FNOTCH_LSB                                                                            16
-#define PHY_ANALOG_BB2_FNOTCH_MASK                                                                   0x000f0000
-#define PHY_ANALOG_BB2_FNOTCH_GET(x)                                                 (((x) & 0x000f0000) >> 16)
-#define PHY_ANALOG_BB2_FNOTCH_SET(x)                                                 (((x) << 16) & 0x000f0000)
-#define PHY_ANALOG_BB2_OVERRIDE_FNOTCH_MSB                                                                   20
-#define PHY_ANALOG_BB2_OVERRIDE_FNOTCH_LSB                                                                   20
-#define PHY_ANALOG_BB2_OVERRIDE_FNOTCH_MASK                                                          0x00100000
-#define PHY_ANALOG_BB2_OVERRIDE_FNOTCH_GET(x)                                        (((x) & 0x00100000) >> 20)
-#define PHY_ANALOG_BB2_OVERRIDE_FNOTCH_SET(x)                                        (((x) << 20) & 0x00100000)
-#define PHY_ANALOG_BB2_FILTERFC_MSB                                                                          25
-#define PHY_ANALOG_BB2_FILTERFC_LSB                                                                          21
-#define PHY_ANALOG_BB2_FILTERFC_MASK                                                                 0x03e00000
-#define PHY_ANALOG_BB2_FILTERFC_GET(x)                                               (((x) & 0x03e00000) >> 21)
-#define PHY_ANALOG_BB2_FILTERFC_SET(x)                                               (((x) << 21) & 0x03e00000)
-#define PHY_ANALOG_BB2_OVERRIDE_FILTERFC_MSB                                                                 26
-#define PHY_ANALOG_BB2_OVERRIDE_FILTERFC_LSB                                                                 26
-#define PHY_ANALOG_BB2_OVERRIDE_FILTERFC_MASK                                                        0x04000000
-#define PHY_ANALOG_BB2_OVERRIDE_FILTERFC_GET(x)                                      (((x) & 0x04000000) >> 26)
-#define PHY_ANALOG_BB2_OVERRIDE_FILTERFC_SET(x)                                      (((x) << 26) & 0x04000000)
-#define PHY_ANALOG_BB2_I2V2RXOUT_EN_MSB                                                                      27
-#define PHY_ANALOG_BB2_I2V2RXOUT_EN_LSB                                                                      27
-#define PHY_ANALOG_BB2_I2V2RXOUT_EN_MASK                                                             0x08000000
-#define PHY_ANALOG_BB2_I2V2RXOUT_EN_GET(x)                                           (((x) & 0x08000000) >> 27)
-#define PHY_ANALOG_BB2_I2V2RXOUT_EN_SET(x)                                           (((x) << 27) & 0x08000000)
-#define PHY_ANALOG_BB2_BQ2RXOUT_EN_MSB                                                                       28
-#define PHY_ANALOG_BB2_BQ2RXOUT_EN_LSB                                                                       28
-#define PHY_ANALOG_BB2_BQ2RXOUT_EN_MASK                                                              0x10000000
-#define PHY_ANALOG_BB2_BQ2RXOUT_EN_GET(x)                                            (((x) & 0x10000000) >> 28)
-#define PHY_ANALOG_BB2_BQ2RXOUT_EN_SET(x)                                            (((x) << 28) & 0x10000000)
-#define PHY_ANALOG_BB2_RXIN2I2V_EN_MSB                                                                       29
-#define PHY_ANALOG_BB2_RXIN2I2V_EN_LSB                                                                       29
-#define PHY_ANALOG_BB2_RXIN2I2V_EN_MASK                                                              0x20000000
-#define PHY_ANALOG_BB2_RXIN2I2V_EN_GET(x)                                            (((x) & 0x20000000) >> 29)
-#define PHY_ANALOG_BB2_RXIN2I2V_EN_SET(x)                                            (((x) << 29) & 0x20000000)
-#define PHY_ANALOG_BB2_RXIN2BQ_EN_MSB                                                                        30
-#define PHY_ANALOG_BB2_RXIN2BQ_EN_LSB                                                                        30
-#define PHY_ANALOG_BB2_RXIN2BQ_EN_MASK                                                               0x40000000
-#define PHY_ANALOG_BB2_RXIN2BQ_EN_GET(x)                                             (((x) & 0x40000000) >> 30)
-#define PHY_ANALOG_BB2_RXIN2BQ_EN_SET(x)                                             (((x) << 30) & 0x40000000)
-#define PHY_ANALOG_BB2_SWITCH_OVERRIDE_MSB                                                                   31
-#define PHY_ANALOG_BB2_SWITCH_OVERRIDE_LSB                                                                   31
-#define PHY_ANALOG_BB2_SWITCH_OVERRIDE_MASK                                                          0x80000000
-#define PHY_ANALOG_BB2_SWITCH_OVERRIDE_GET(x)                                        (((x) & 0x80000000) >> 31)
-#define PHY_ANALOG_BB2_SWITCH_OVERRIDE_SET(x)                                        (((x) << 31) & 0x80000000)
-
-/* macros for TOP1 */
-#define PHY_ANALOG_TOP1_ADDRESS                                                                      0x00000280
-#define PHY_ANALOG_TOP1_OFFSET                                                                       0x00000280
-#define PHY_ANALOG_TOP1_SEL_KVCO_MSB                                                                          1
-#define PHY_ANALOG_TOP1_SEL_KVCO_LSB                                                                          0
-#define PHY_ANALOG_TOP1_SEL_KVCO_MASK                                                                0x00000003
-#define PHY_ANALOG_TOP1_SEL_KVCO_GET(x)                                               (((x) & 0x00000003) >> 0)
-#define PHY_ANALOG_TOP1_SEL_KVCO_SET(x)                                               (((x) << 0) & 0x00000003)
-#define PHY_ANALOG_TOP1_PLLATB_MSB                                                                            3
-#define PHY_ANALOG_TOP1_PLLATB_LSB                                                                            2
-#define PHY_ANALOG_TOP1_PLLATB_MASK                                                                  0x0000000c
-#define PHY_ANALOG_TOP1_PLLATB_GET(x)                                                 (((x) & 0x0000000c) >> 2)
-#define PHY_ANALOG_TOP1_PLLATB_SET(x)                                                 (((x) << 2) & 0x0000000c)
-#define PHY_ANALOG_TOP1_PLL_SVREG_MSB                                                                         4
-#define PHY_ANALOG_TOP1_PLL_SVREG_LSB                                                                         4
-#define PHY_ANALOG_TOP1_PLL_SVREG_MASK                                                               0x00000010
-#define PHY_ANALOG_TOP1_PLL_SVREG_GET(x)                                              (((x) & 0x00000010) >> 4)
-#define PHY_ANALOG_TOP1_PLL_SVREG_SET(x)                                              (((x) << 4) & 0x00000010)
-#define PHY_ANALOG_TOP1_HI_FREQ_EN_MSB                                                                        5
-#define PHY_ANALOG_TOP1_HI_FREQ_EN_LSB                                                                        5
-#define PHY_ANALOG_TOP1_HI_FREQ_EN_MASK                                                              0x00000020
-#define PHY_ANALOG_TOP1_HI_FREQ_EN_GET(x)                                             (((x) & 0x00000020) >> 5)
-#define PHY_ANALOG_TOP1_HI_FREQ_EN_SET(x)                                             (((x) << 5) & 0x00000020)
-#define PHY_ANALOG_TOP1_PWDPLL_MSB                                                                            6
-#define PHY_ANALOG_TOP1_PWDPLL_LSB                                                                            6
-#define PHY_ANALOG_TOP1_PWDPLL_MASK                                                                  0x00000040
-#define PHY_ANALOG_TOP1_PWDPLL_GET(x)                                                 (((x) & 0x00000040) >> 6)
-#define PHY_ANALOG_TOP1_PWDPLL_SET(x)                                                 (((x) << 6) & 0x00000040)
-#define PHY_ANALOG_TOP1_PWDEXTCLKBUF_MSB                                                                      7
-#define PHY_ANALOG_TOP1_PWDEXTCLKBUF_LSB                                                                      7
-#define PHY_ANALOG_TOP1_PWDEXTCLKBUF_MASK                                                            0x00000080
-#define PHY_ANALOG_TOP1_PWDEXTCLKBUF_GET(x)                                           (((x) & 0x00000080) >> 7)
-#define PHY_ANALOG_TOP1_PWDEXTCLKBUF_SET(x)                                           (((x) << 7) & 0x00000080)
-#define PHY_ANALOG_TOP1_ADCPWD_PHASE_MSB                                                                      9
-#define PHY_ANALOG_TOP1_ADCPWD_PHASE_LSB                                                                      8
-#define PHY_ANALOG_TOP1_ADCPWD_PHASE_MASK                                                            0x00000300
-#define PHY_ANALOG_TOP1_ADCPWD_PHASE_GET(x)                                           (((x) & 0x00000300) >> 8)
-#define PHY_ANALOG_TOP1_ADCPWD_PHASE_SET(x)                                           (((x) << 8) & 0x00000300)
-#define PHY_ANALOG_TOP1_ADCCLK_PHASE_MSB                                                                     11
-#define PHY_ANALOG_TOP1_ADCCLK_PHASE_LSB                                                                     10
-#define PHY_ANALOG_TOP1_ADCCLK_PHASE_MASK                                                            0x00000c00
-#define PHY_ANALOG_TOP1_ADCCLK_PHASE_GET(x)                                          (((x) & 0x00000c00) >> 10)
-#define PHY_ANALOG_TOP1_ADCCLK_PHASE_SET(x)                                          (((x) << 10) & 0x00000c00)
-#define PHY_ANALOG_TOP1_DAC_CLK_SEL_MSB                                                                      13
-#define PHY_ANALOG_TOP1_DAC_CLK_SEL_LSB                                                                      12
-#define PHY_ANALOG_TOP1_DAC_CLK_SEL_MASK                                                             0x00003000
-#define PHY_ANALOG_TOP1_DAC_CLK_SEL_GET(x)                                           (((x) & 0x00003000) >> 12)
-#define PHY_ANALOG_TOP1_DAC_CLK_SEL_SET(x)                                           (((x) << 12) & 0x00003000)
-#define PHY_ANALOG_TOP1_ADC_CLK_SEL_MSB                                                                      15
-#define PHY_ANALOG_TOP1_ADC_CLK_SEL_LSB                                                                      14
-#define PHY_ANALOG_TOP1_ADC_CLK_SEL_MASK                                                             0x0000c000
-#define PHY_ANALOG_TOP1_ADC_CLK_SEL_GET(x)                                           (((x) & 0x0000c000) >> 14)
-#define PHY_ANALOG_TOP1_ADC_CLK_SEL_SET(x)                                           (((x) << 14) & 0x0000c000)
-#define PHY_ANALOG_TOP1_REFDIV_MSB                                                                           19
-#define PHY_ANALOG_TOP1_REFDIV_LSB                                                                           16
-#define PHY_ANALOG_TOP1_REFDIV_MASK                                                                  0x000f0000
-#define PHY_ANALOG_TOP1_REFDIV_GET(x)                                                (((x) & 0x000f0000) >> 16)
-#define PHY_ANALOG_TOP1_REFDIV_SET(x)                                                (((x) << 16) & 0x000f0000)
-#define PHY_ANALOG_TOP1_DIV_MSB                                                                              29
-#define PHY_ANALOG_TOP1_DIV_LSB                                                                              20
-#define PHY_ANALOG_TOP1_DIV_MASK                                                                     0x3ff00000
-#define PHY_ANALOG_TOP1_DIV_GET(x)                                                   (((x) & 0x3ff00000) >> 20)
-#define PHY_ANALOG_TOP1_DIV_SET(x)                                                   (((x) << 20) & 0x3ff00000)
-#define PHY_ANALOG_TOP1_PLLBYPASS_MSB                                                                        30
-#define PHY_ANALOG_TOP1_PLLBYPASS_LSB                                                                        30
-#define PHY_ANALOG_TOP1_PLLBYPASS_MASK                                                               0x40000000
-#define PHY_ANALOG_TOP1_PLLBYPASS_GET(x)                                             (((x) & 0x40000000) >> 30)
-#define PHY_ANALOG_TOP1_PLLBYPASS_SET(x)                                             (((x) << 30) & 0x40000000)
-#define PHY_ANALOG_TOP1_CLKMOD_RSTB_MSB                                                                      31
-#define PHY_ANALOG_TOP1_CLKMOD_RSTB_LSB                                                                      31
-#define PHY_ANALOG_TOP1_CLKMOD_RSTB_MASK                                                             0x80000000
-#define PHY_ANALOG_TOP1_CLKMOD_RSTB_GET(x)                                           (((x) & 0x80000000) >> 31)
-#define PHY_ANALOG_TOP1_CLKMOD_RSTB_SET(x)                                           (((x) << 31) & 0x80000000)
-
-/* macros for TOP2 */
-#define PHY_ANALOG_TOP2_ADDRESS                                                                      0x00000284
-#define PHY_ANALOG_TOP2_OFFSET                                                                       0x00000284
-#define PHY_ANALOG_TOP2_PLL_LOWLEAK_MSB                                                                       0
-#define PHY_ANALOG_TOP2_PLL_LOWLEAK_LSB                                                                       0
-#define PHY_ANALOG_TOP2_PLL_LOWLEAK_MASK                                                             0x00000001
-#define PHY_ANALOG_TOP2_PLL_LOWLEAK_GET(x)                                            (((x) & 0x00000001) >> 0)
-#define PHY_ANALOG_TOP2_PLL_LOWLEAK_SET(x)                                            (((x) << 0) & 0x00000001)
-#define PHY_ANALOG_TOP2_PLL_LEAK_MSB                                                                          4
-#define PHY_ANALOG_TOP2_PLL_LEAK_LSB                                                                          1
-#define PHY_ANALOG_TOP2_PLL_LEAK_MASK                                                                0x0000001e
-#define PHY_ANALOG_TOP2_PLL_LEAK_GET(x)                                               (((x) & 0x0000001e) >> 1)
-#define PHY_ANALOG_TOP2_PLL_LEAK_SET(x)                                               (((x) << 1) & 0x0000001e)
-#define PHY_ANALOG_TOP2_PLLFRAC_MSB                                                                          19
-#define PHY_ANALOG_TOP2_PLLFRAC_LSB                                                                           5
-#define PHY_ANALOG_TOP2_PLLFRAC_MASK                                                                 0x000fffe0
-#define PHY_ANALOG_TOP2_PLLFRAC_GET(x)                                                (((x) & 0x000fffe0) >> 5)
-#define PHY_ANALOG_TOP2_PLLFRAC_SET(x)                                                (((x) << 5) & 0x000fffe0)
-#define PHY_ANALOG_TOP2_PWD_PLLSDM_MSB                                                                       20
-#define PHY_ANALOG_TOP2_PWD_PLLSDM_LSB                                                                       20
-#define PHY_ANALOG_TOP2_PWD_PLLSDM_MASK                                                              0x00100000
-#define PHY_ANALOG_TOP2_PWD_PLLSDM_GET(x)                                            (((x) & 0x00100000) >> 20)
-#define PHY_ANALOG_TOP2_PWD_PLLSDM_SET(x)                                            (((x) << 20) & 0x00100000)
-#define PHY_ANALOG_TOP2_PLLICP_MSB                                                                           23
-#define PHY_ANALOG_TOP2_PLLICP_LSB                                                                           21
-#define PHY_ANALOG_TOP2_PLLICP_MASK                                                                  0x00e00000
-#define PHY_ANALOG_TOP2_PLLICP_GET(x)                                                (((x) & 0x00e00000) >> 21)
-#define PHY_ANALOG_TOP2_PLLICP_SET(x)                                                (((x) << 21) & 0x00e00000)
-#define PHY_ANALOG_TOP2_PLLFILTER_MSB                                                                        31
-#define PHY_ANALOG_TOP2_PLLFILTER_LSB                                                                        24
-#define PHY_ANALOG_TOP2_PLLFILTER_MASK                                                               0xff000000
-#define PHY_ANALOG_TOP2_PLLFILTER_GET(x)                                             (((x) & 0xff000000) >> 24)
-#define PHY_ANALOG_TOP2_PLLFILTER_SET(x)                                             (((x) << 24) & 0xff000000)
-
-/* macros for TOP3 */
-#define PHY_ANALOG_TOP3_ADDRESS                                                                      0x00000288
-#define PHY_ANALOG_TOP3_OFFSET                                                                       0x00000288
-#define PHY_ANALOG_TOP3_INT2GND_MSB                                                                           0
-#define PHY_ANALOG_TOP3_INT2GND_LSB                                                                           0
-#define PHY_ANALOG_TOP3_INT2GND_MASK                                                                 0x00000001
-#define PHY_ANALOG_TOP3_INT2GND_GET(x)                                                (((x) & 0x00000001) >> 0)
-#define PHY_ANALOG_TOP3_INT2GND_SET(x)                                                (((x) << 0) & 0x00000001)
-#define PHY_ANALOG_TOP3_PWDPALCLK_MSB                                                                         1
-#define PHY_ANALOG_TOP3_PWDPALCLK_LSB                                                                         1
-#define PHY_ANALOG_TOP3_PWDPALCLK_MASK                                                               0x00000002
-#define PHY_ANALOG_TOP3_PWDPALCLK_GET(x)                                              (((x) & 0x00000002) >> 1)
-#define PHY_ANALOG_TOP3_PWDPALCLK_SET(x)                                              (((x) << 1) & 0x00000002)
-#define PHY_ANALOG_TOP3_PWDAGCCLK_MSB                                                                         2
-#define PHY_ANALOG_TOP3_PWDAGCCLK_LSB                                                                         2
-#define PHY_ANALOG_TOP3_PWDAGCCLK_MASK                                                               0x00000004
-#define PHY_ANALOG_TOP3_PWDAGCCLK_GET(x)                                              (((x) & 0x00000004) >> 2)
-#define PHY_ANALOG_TOP3_PWDAGCCLK_SET(x)                                              (((x) << 2) & 0x00000004)
-#define PHY_ANALOG_TOP3_PWDV2I_MSB                                                                            3
-#define PHY_ANALOG_TOP3_PWDV2I_LSB                                                                            3
-#define PHY_ANALOG_TOP3_PWDV2I_MASK                                                                  0x00000008
-#define PHY_ANALOG_TOP3_PWDV2I_GET(x)                                                 (((x) & 0x00000008) >> 3)
-#define PHY_ANALOG_TOP3_PWDV2I_SET(x)                                                 (((x) << 3) & 0x00000008)
-#define PHY_ANALOG_TOP3_PWDBIAS_MSB                                                                           4
-#define PHY_ANALOG_TOP3_PWDBIAS_LSB                                                                           4
-#define PHY_ANALOG_TOP3_PWDBIAS_MASK                                                                 0x00000010
-#define PHY_ANALOG_TOP3_PWDBIAS_GET(x)                                                (((x) & 0x00000010) >> 4)
-#define PHY_ANALOG_TOP3_PWDBIAS_SET(x)                                                (((x) << 4) & 0x00000010)
-#define PHY_ANALOG_TOP3_PWDBG_MSB                                                                             5
-#define PHY_ANALOG_TOP3_PWDBG_LSB                                                                             5
-#define PHY_ANALOG_TOP3_PWDBG_MASK                                                                   0x00000020
-#define PHY_ANALOG_TOP3_PWDBG_GET(x)                                                  (((x) & 0x00000020) >> 5)
-#define PHY_ANALOG_TOP3_PWDBG_SET(x)                                                  (((x) << 5) & 0x00000020)
-#define PHY_ANALOG_TOP3_XTAL_SELVREG_MSB                                                                      6
-#define PHY_ANALOG_TOP3_XTAL_SELVREG_LSB                                                                      6
-#define PHY_ANALOG_TOP3_XTAL_SELVREG_MASK                                                            0x00000040
-#define PHY_ANALOG_TOP3_XTAL_SELVREG_GET(x)                                           (((x) & 0x00000040) >> 6)
-#define PHY_ANALOG_TOP3_XTAL_SELVREG_SET(x)                                           (((x) << 6) & 0x00000040)
-#define PHY_ANALOG_TOP3_XTAL_PWDREG_MSB                                                                       7
-#define PHY_ANALOG_TOP3_XTAL_PWDREG_LSB                                                                       7
-#define PHY_ANALOG_TOP3_XTAL_PWDREG_MASK                                                             0x00000080
-#define PHY_ANALOG_TOP3_XTAL_PWDREG_GET(x)                                            (((x) & 0x00000080) >> 7)
-#define PHY_ANALOG_TOP3_XTAL_PWDREG_SET(x)                                            (((x) << 7) & 0x00000080)
-#define PHY_ANALOG_TOP3_XTAL_PWDCLKIN_MSB                                                                     8
-#define PHY_ANALOG_TOP3_XTAL_PWDCLKIN_LSB                                                                     8
-#define PHY_ANALOG_TOP3_XTAL_PWDCLKIN_MASK                                                           0x00000100
-#define PHY_ANALOG_TOP3_XTAL_PWDCLKIN_GET(x)                                          (((x) & 0x00000100) >> 8)
-#define PHY_ANALOG_TOP3_XTAL_PWDCLKIN_SET(x)                                          (((x) << 8) & 0x00000100)
-#define PHY_ANALOG_TOP3_XTAL_PWDCLKD_MSB                                                                      9
-#define PHY_ANALOG_TOP3_XTAL_PWDCLKD_LSB                                                                      9
-#define PHY_ANALOG_TOP3_XTAL_PWDCLKD_MASK                                                            0x00000200
-#define PHY_ANALOG_TOP3_XTAL_PWDCLKD_GET(x)                                           (((x) & 0x00000200) >> 9)
-#define PHY_ANALOG_TOP3_XTAL_PWDCLKD_SET(x)                                           (((x) << 9) & 0x00000200)
-#define PHY_ANALOG_TOP3_XTAL_OSCON_MSB                                                                       10
-#define PHY_ANALOG_TOP3_XTAL_OSCON_LSB                                                                       10
-#define PHY_ANALOG_TOP3_XTAL_OSCON_MASK                                                              0x00000400
-#define PHY_ANALOG_TOP3_XTAL_OSCON_GET(x)                                            (((x) & 0x00000400) >> 10)
-#define PHY_ANALOG_TOP3_XTAL_OSCON_SET(x)                                            (((x) << 10) & 0x00000400)
-#define PHY_ANALOG_TOP3_XTAL_NOTCXODET_MSB                                                                   11
-#define PHY_ANALOG_TOP3_XTAL_NOTCXODET_LSB                                                                   11
-#define PHY_ANALOG_TOP3_XTAL_NOTCXODET_MASK                                                          0x00000800
-#define PHY_ANALOG_TOP3_XTAL_NOTCXODET_GET(x)                                        (((x) & 0x00000800) >> 11)
-#define PHY_ANALOG_TOP3_XTAL_NOTCXODET_SET(x)                                        (((x) << 11) & 0x00000800)
-#define PHY_ANALOG_TOP3_XTAL_LOCALBIAS_MSB                                                                   12
-#define PHY_ANALOG_TOP3_XTAL_LOCALBIAS_LSB                                                                   12
-#define PHY_ANALOG_TOP3_XTAL_LOCALBIAS_MASK                                                          0x00001000
-#define PHY_ANALOG_TOP3_XTAL_LOCALBIAS_GET(x)                                        (((x) & 0x00001000) >> 12)
-#define PHY_ANALOG_TOP3_XTAL_LOCALBIAS_SET(x)                                        (((x) << 12) & 0x00001000)
-#define PHY_ANALOG_TOP3_XTAL_HIGHZ_MSB                                                                       13
-#define PHY_ANALOG_TOP3_XTAL_HIGHZ_LSB                                                                       13
-#define PHY_ANALOG_TOP3_XTAL_HIGHZ_MASK                                                              0x00002000
-#define PHY_ANALOG_TOP3_XTAL_HIGHZ_GET(x)                                            (((x) & 0x00002000) >> 13)
-#define PHY_ANALOG_TOP3_XTAL_HIGHZ_SET(x)                                            (((x) << 13) & 0x00002000)
-#define PHY_ANALOG_TOP3_XTAL_DRVPNR_MSB                                                                      15
-#define PHY_ANALOG_TOP3_XTAL_DRVPNR_LSB                                                                      14
-#define PHY_ANALOG_TOP3_XTAL_DRVPNR_MASK                                                             0x0000c000
-#define PHY_ANALOG_TOP3_XTAL_DRVPNR_GET(x)                                           (((x) & 0x0000c000) >> 14)
-#define PHY_ANALOG_TOP3_XTAL_DRVPNR_SET(x)                                           (((x) << 14) & 0x0000c000)
-#define PHY_ANALOG_TOP3_XTALCAPOUTDAC_MSB                                                                    22
-#define PHY_ANALOG_TOP3_XTALCAPOUTDAC_LSB                                                                    16
-#define PHY_ANALOG_TOP3_XTALCAPOUTDAC_MASK                                                           0x007f0000
-#define PHY_ANALOG_TOP3_XTALCAPOUTDAC_GET(x)                                         (((x) & 0x007f0000) >> 16)
-#define PHY_ANALOG_TOP3_XTALCAPOUTDAC_SET(x)                                         (((x) << 16) & 0x007f0000)
-#define PHY_ANALOG_TOP3_XTAL_CAPINDAC_MSB                                                                    29
-#define PHY_ANALOG_TOP3_XTAL_CAPINDAC_LSB                                                                    23
-#define PHY_ANALOG_TOP3_XTAL_CAPINDAC_MASK                                                           0x3f800000
-#define PHY_ANALOG_TOP3_XTAL_CAPINDAC_GET(x)                                         (((x) & 0x3f800000) >> 23)
-#define PHY_ANALOG_TOP3_XTAL_CAPINDAC_SET(x)                                         (((x) << 23) & 0x3f800000)
-#define PHY_ANALOG_TOP3_XTAL_BIAS2X_MSB                                                                      30
-#define PHY_ANALOG_TOP3_XTAL_BIAS2X_LSB                                                                      30
-#define PHY_ANALOG_TOP3_XTAL_BIAS2X_MASK                                                             0x40000000
-#define PHY_ANALOG_TOP3_XTAL_BIAS2X_GET(x)                                           (((x) & 0x40000000) >> 30)
-#define PHY_ANALOG_TOP3_XTAL_BIAS2X_SET(x)                                           (((x) << 30) & 0x40000000)
-#define PHY_ANALOG_TOP3_TCXODET_MSB                                                                          31
-#define PHY_ANALOG_TOP3_TCXODET_LSB                                                                          31
-#define PHY_ANALOG_TOP3_TCXODET_MASK                                                                 0x80000000
-#define PHY_ANALOG_TOP3_TCXODET_GET(x)                                               (((x) & 0x80000000) >> 31)
-
-/* macros for TOP4 */
-#define PHY_ANALOG_TOP4_ADDRESS                                                                      0x0000028c
-#define PHY_ANALOG_TOP4_OFFSET                                                                       0x0000028c
-#define PHY_ANALOG_TOP4_SPARE4_MSB                                                                           19
-#define PHY_ANALOG_TOP4_SPARE4_LSB                                                                            0
-#define PHY_ANALOG_TOP4_SPARE4_MASK                                                                  0x000fffff
-#define PHY_ANALOG_TOP4_SPARE4_GET(x)                                                 (((x) & 0x000fffff) >> 0)
-#define PHY_ANALOG_TOP4_SPARE4_SET(x)                                                 (((x) << 0) & 0x000fffff)
-#define PHY_ANALOG_TOP4_SEL_TEMPSENSOR_MSB                                                                   20
-#define PHY_ANALOG_TOP4_SEL_TEMPSENSOR_LSB                                                                   20
-#define PHY_ANALOG_TOP4_SEL_TEMPSENSOR_MASK                                                          0x00100000
-#define PHY_ANALOG_TOP4_SEL_TEMPSENSOR_GET(x)                                        (((x) & 0x00100000) >> 20)
-#define PHY_ANALOG_TOP4_SEL_TEMPSENSOR_SET(x)                                        (((x) << 20) & 0x00100000)
-#define PHY_ANALOG_TOP4_ADCPWD_OVR_MSB                                                                       21
-#define PHY_ANALOG_TOP4_ADCPWD_OVR_LSB                                                                       21
-#define PHY_ANALOG_TOP4_ADCPWD_OVR_MASK                                                              0x00200000
-#define PHY_ANALOG_TOP4_ADCPWD_OVR_GET(x)                                            (((x) & 0x00200000) >> 21)
-#define PHY_ANALOG_TOP4_ADCPWD_OVR_SET(x)                                            (((x) << 21) & 0x00200000)
-#define PHY_ANALOG_TOP4_ADCPWD_INT_MSB                                                                       22
-#define PHY_ANALOG_TOP4_ADCPWD_INT_LSB                                                                       22
-#define PHY_ANALOG_TOP4_ADCPWD_INT_MASK                                                              0x00400000
-#define PHY_ANALOG_TOP4_ADCPWD_INT_GET(x)                                            (((x) & 0x00400000) >> 22)
-#define PHY_ANALOG_TOP4_ADCPWD_INT_SET(x)                                            (((x) << 22) & 0x00400000)
-#define PHY_ANALOG_TOP4_TESTIQ_OFF_MSB                                                                       23
-#define PHY_ANALOG_TOP4_TESTIQ_OFF_LSB                                                                       23
-#define PHY_ANALOG_TOP4_TESTIQ_OFF_MASK                                                              0x00800000
-#define PHY_ANALOG_TOP4_TESTIQ_OFF_GET(x)                                            (((x) & 0x00800000) >> 23)
-#define PHY_ANALOG_TOP4_TESTIQ_OFF_SET(x)                                            (((x) << 23) & 0x00800000)
-#define PHY_ANALOG_TOP4_TESTIQ_BUFEN_MSB                                                                     24
-#define PHY_ANALOG_TOP4_TESTIQ_BUFEN_LSB                                                                     24
-#define PHY_ANALOG_TOP4_TESTIQ_BUFEN_MASK                                                            0x01000000
-#define PHY_ANALOG_TOP4_TESTIQ_BUFEN_GET(x)                                          (((x) & 0x01000000) >> 24)
-#define PHY_ANALOG_TOP4_TESTIQ_BUFEN_SET(x)                                          (((x) << 24) & 0x01000000)
-#define PHY_ANALOG_TOP4_PAL_LOCKEDEN_MSB                                                                     25
-#define PHY_ANALOG_TOP4_PAL_LOCKEDEN_LSB                                                                     25
-#define PHY_ANALOG_TOP4_PAL_LOCKEDEN_MASK                                                            0x02000000
-#define PHY_ANALOG_TOP4_PAL_LOCKEDEN_GET(x)                                          (((x) & 0x02000000) >> 25)
-#define PHY_ANALOG_TOP4_PAL_LOCKEDEN_SET(x)                                          (((x) << 25) & 0x02000000)
-#define PHY_ANALOG_TOP4_SYNTHDIGOUTEN_MSB                                                                    26
-#define PHY_ANALOG_TOP4_SYNTHDIGOUTEN_LSB                                                                    26
-#define PHY_ANALOG_TOP4_SYNTHDIGOUTEN_MASK                                                           0x04000000
-#define PHY_ANALOG_TOP4_SYNTHDIGOUTEN_GET(x)                                         (((x) & 0x04000000) >> 26)
-#define PHY_ANALOG_TOP4_SYNTHDIGOUTEN_SET(x)                                         (((x) << 26) & 0x04000000)
-#define PHY_ANALOG_TOP4_ENBTCLK_MSB                                                                          27
-#define PHY_ANALOG_TOP4_ENBTCLK_LSB                                                                          27
-#define PHY_ANALOG_TOP4_ENBTCLK_MASK                                                                 0x08000000
-#define PHY_ANALOG_TOP4_ENBTCLK_GET(x)                                               (((x) & 0x08000000) >> 27)
-#define PHY_ANALOG_TOP4_ENBTCLK_SET(x)                                               (((x) << 27) & 0x08000000)
-#define PHY_ANALOG_TOP4_PAD2GND_MSB                                                                          28
-#define PHY_ANALOG_TOP4_PAD2GND_LSB                                                                          28
-#define PHY_ANALOG_TOP4_PAD2GND_MASK                                                                 0x10000000
-#define PHY_ANALOG_TOP4_PAD2GND_GET(x)                                               (((x) & 0x10000000) >> 28)
-#define PHY_ANALOG_TOP4_PAD2GND_SET(x)                                               (((x) << 28) & 0x10000000)
-#define PHY_ANALOG_TOP4_INTH2PAD_MSB                                                                         29
-#define PHY_ANALOG_TOP4_INTH2PAD_LSB                                                                         29
-#define PHY_ANALOG_TOP4_INTH2PAD_MASK                                                                0x20000000
-#define PHY_ANALOG_TOP4_INTH2PAD_GET(x)                                              (((x) & 0x20000000) >> 29)
-#define PHY_ANALOG_TOP4_INTH2PAD_SET(x)                                              (((x) << 29) & 0x20000000)
-#define PHY_ANALOG_TOP4_INTH2GND_MSB                                                                         30
-#define PHY_ANALOG_TOP4_INTH2GND_LSB                                                                         30
-#define PHY_ANALOG_TOP4_INTH2GND_MASK                                                                0x40000000
-#define PHY_ANALOG_TOP4_INTH2GND_GET(x)                                              (((x) & 0x40000000) >> 30)
-#define PHY_ANALOG_TOP4_INTH2GND_SET(x)                                              (((x) << 30) & 0x40000000)
-#define PHY_ANALOG_TOP4_INT2PAD_MSB                                                                          31
-#define PHY_ANALOG_TOP4_INT2PAD_LSB                                                                          31
-#define PHY_ANALOG_TOP4_INT2PAD_MASK                                                                 0x80000000
-#define PHY_ANALOG_TOP4_INT2PAD_GET(x)                                               (((x) & 0x80000000) >> 31)
-#define PHY_ANALOG_TOP4_INT2PAD_SET(x)                                               (((x) << 31) & 0x80000000)
-
-/* macros for rbist_cntrl */
-#define PHY_ANALOG_RBIST_CNTRL_ADDRESS                                                               0x00000380
-#define PHY_ANALOG_RBIST_CNTRL_OFFSET                                                                0x00000380
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_DC_ENABLE_MSB                                                      0
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_DC_ENABLE_LSB                                                      0
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_DC_ENABLE_MASK                                            0x00000001
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_DC_ENABLE_GET(x)                           (((x) & 0x00000001) >> 0)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_DC_ENABLE_SET(x)                           (((x) << 0) & 0x00000001)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_TONE0_ENABLE_MSB                                                   1
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_TONE0_ENABLE_LSB                                                   1
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_TONE0_ENABLE_MASK                                         0x00000002
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_TONE0_ENABLE_GET(x)                        (((x) & 0x00000002) >> 1)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_TONE0_ENABLE_SET(x)                        (((x) << 1) & 0x00000002)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_TONE1_ENABLE_MSB                                                   2
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_TONE1_ENABLE_LSB                                                   2
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_TONE1_ENABLE_MASK                                         0x00000004
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_TONE1_ENABLE_GET(x)                        (((x) & 0x00000004) >> 2)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_TONE1_ENABLE_SET(x)                        (((x) << 2) & 0x00000004)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_LFTONE0_ENABLE_MSB                                                 3
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_LFTONE0_ENABLE_LSB                                                 3
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_LFTONE0_ENABLE_MASK                                       0x00000008
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_LFTONE0_ENABLE_GET(x)                      (((x) & 0x00000008) >> 3)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_LFTONE0_ENABLE_SET(x)                      (((x) << 3) & 0x00000008)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_LINRAMP_ENABLE_I_MSB                                               4
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_LINRAMP_ENABLE_I_LSB                                               4
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_LINRAMP_ENABLE_I_MASK                                     0x00000010
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_LINRAMP_ENABLE_I_GET(x)                    (((x) & 0x00000010) >> 4)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_LINRAMP_ENABLE_I_SET(x)                    (((x) << 4) & 0x00000010)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_LINRAMP_ENABLE_Q_MSB                                               5
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_LINRAMP_ENABLE_Q_LSB                                               5
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_LINRAMP_ENABLE_Q_MASK                                     0x00000020
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_LINRAMP_ENABLE_Q_GET(x)                    (((x) & 0x00000020) >> 5)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_LINRAMP_ENABLE_Q_SET(x)                    (((x) << 5) & 0x00000020)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_PRBS_ENABLE_I_MSB                                                  6
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_PRBS_ENABLE_I_LSB                                                  6
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_PRBS_ENABLE_I_MASK                                        0x00000040
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_PRBS_ENABLE_I_GET(x)                       (((x) & 0x00000040) >> 6)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_PRBS_ENABLE_I_SET(x)                       (((x) << 6) & 0x00000040)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_PRBS_ENABLE_Q_MSB                                                  7
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_PRBS_ENABLE_Q_LSB                                                  7
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_PRBS_ENABLE_Q_MASK                                        0x00000080
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_PRBS_ENABLE_Q_GET(x)                       (((x) & 0x00000080) >> 7)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_PRBS_ENABLE_Q_SET(x)                       (((x) << 7) & 0x00000080)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_DC_WRITE_TO_CANCEL_MSB                                                8
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_DC_WRITE_TO_CANCEL_LSB                                                8
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_DC_WRITE_TO_CANCEL_MASK                                      0x00000100
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_DC_WRITE_TO_CANCEL_GET(x)                     (((x) & 0x00000100) >> 8)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_DC_WRITE_TO_CANCEL_SET(x)                     (((x) << 8) & 0x00000100)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_DC_ENABLE_MSB                                                         9
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_DC_ENABLE_LSB                                                         9
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_DC_ENABLE_MASK                                               0x00000200
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_DC_ENABLE_GET(x)                              (((x) & 0x00000200) >> 9)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_DC_ENABLE_SET(x)                              (((x) << 9) & 0x00000200)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_CORR_ENABLE_MSB                                                      10
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_CORR_ENABLE_LSB                                                      10
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_CORR_ENABLE_MASK                                             0x00000400
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_CORR_ENABLE_GET(x)                           (((x) & 0x00000400) >> 10)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_CORR_ENABLE_SET(x)                           (((x) << 10) & 0x00000400)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_POWER_ENABLE_MSB                                                     11
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_POWER_ENABLE_LSB                                                     11
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_POWER_ENABLE_MASK                                            0x00000800
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_POWER_ENABLE_GET(x)                          (((x) & 0x00000800) >> 11)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_POWER_ENABLE_SET(x)                          (((x) << 11) & 0x00000800)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_IQ_ENABLE_MSB                                                        12
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_IQ_ENABLE_LSB                                                        12
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_IQ_ENABLE_MASK                                               0x00001000
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_IQ_ENABLE_GET(x)                             (((x) & 0x00001000) >> 12)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_IQ_ENABLE_SET(x)                             (((x) << 12) & 0x00001000)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_I2Q2_ENABLE_MSB                                                      13
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_I2Q2_ENABLE_LSB                                                      13
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_I2Q2_ENABLE_MASK                                             0x00002000
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_I2Q2_ENABLE_GET(x)                           (((x) & 0x00002000) >> 13)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_I2Q2_ENABLE_SET(x)                           (((x) << 13) & 0x00002000)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_POWER_HPF_ENABLE_MSB                                                 14
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_POWER_HPF_ENABLE_LSB                                                 14
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_POWER_HPF_ENABLE_MASK                                        0x00004000
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_POWER_HPF_ENABLE_GET(x)                      (((x) & 0x00004000) >> 14)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_POWER_HPF_ENABLE_SET(x)                      (((x) << 14) & 0x00004000)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_RXDAC_CALIBRATE_MSB                                                       15
-#define PHY_ANALOG_RBIST_CNTRL_ATE_RXDAC_CALIBRATE_LSB                                                       15
-#define PHY_ANALOG_RBIST_CNTRL_ATE_RXDAC_CALIBRATE_MASK                                              0x00008000
-#define PHY_ANALOG_RBIST_CNTRL_ATE_RXDAC_CALIBRATE_GET(x)                            (((x) & 0x00008000) >> 15)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_RXDAC_CALIBRATE_SET(x)                            (((x) << 15) & 0x00008000)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_RBIST_ENABLE_MSB                                                          16
-#define PHY_ANALOG_RBIST_CNTRL_ATE_RBIST_ENABLE_LSB                                                          16
-#define PHY_ANALOG_RBIST_CNTRL_ATE_RBIST_ENABLE_MASK                                                 0x00010000
-#define PHY_ANALOG_RBIST_CNTRL_ATE_RBIST_ENABLE_GET(x)                               (((x) & 0x00010000) >> 16)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_RBIST_ENABLE_SET(x)                               (((x) << 16) & 0x00010000)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_ADC_CLK_INVERT_MSB                                                        17
-#define PHY_ANALOG_RBIST_CNTRL_ATE_ADC_CLK_INVERT_LSB                                                        17
-#define PHY_ANALOG_RBIST_CNTRL_ATE_ADC_CLK_INVERT_MASK                                               0x00020000
-#define PHY_ANALOG_RBIST_CNTRL_ATE_ADC_CLK_INVERT_GET(x)                             (((x) & 0x00020000) >> 17)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_ADC_CLK_INVERT_SET(x)                             (((x) << 17) & 0x00020000)
-
-/* macros for tx_dc_offset */
-#define PHY_ANALOG_TX_DC_OFFSET_ADDRESS                                                              0x00000384
-#define PHY_ANALOG_TX_DC_OFFSET_OFFSET                                                               0x00000384
-#define PHY_ANALOG_TX_DC_OFFSET_ATE_TONEGEN_DC_I_MSB                                                         10
-#define PHY_ANALOG_TX_DC_OFFSET_ATE_TONEGEN_DC_I_LSB                                                          0
-#define PHY_ANALOG_TX_DC_OFFSET_ATE_TONEGEN_DC_I_MASK                                                0x000007ff
-#define PHY_ANALOG_TX_DC_OFFSET_ATE_TONEGEN_DC_I_GET(x)                               (((x) & 0x000007ff) >> 0)
-#define PHY_ANALOG_TX_DC_OFFSET_ATE_TONEGEN_DC_I_SET(x)                               (((x) << 0) & 0x000007ff)
-#define PHY_ANALOG_TX_DC_OFFSET_ATE_TONEGEN_DC_Q_MSB                                                         26
-#define PHY_ANALOG_TX_DC_OFFSET_ATE_TONEGEN_DC_Q_LSB                                                         16
-#define PHY_ANALOG_TX_DC_OFFSET_ATE_TONEGEN_DC_Q_MASK                                                0x07ff0000
-#define PHY_ANALOG_TX_DC_OFFSET_ATE_TONEGEN_DC_Q_GET(x)                              (((x) & 0x07ff0000) >> 16)
-#define PHY_ANALOG_TX_DC_OFFSET_ATE_TONEGEN_DC_Q_SET(x)                              (((x) << 16) & 0x07ff0000)
-
-/* macros for tx_tonegen0 */
-#define PHY_ANALOG_TX_TONEGEN0_ADDRESS                                                               0x00000388
-#define PHY_ANALOG_TX_TONEGEN0_OFFSET                                                                0x00000388
-#define PHY_ANALOG_TX_TONEGEN0_ATE_TONEGEN_TONE_FREQ_MSB                                                      6
-#define PHY_ANALOG_TX_TONEGEN0_ATE_TONEGEN_TONE_FREQ_LSB                                                      0
-#define PHY_ANALOG_TX_TONEGEN0_ATE_TONEGEN_TONE_FREQ_MASK                                            0x0000007f
-#define PHY_ANALOG_TX_TONEGEN0_ATE_TONEGEN_TONE_FREQ_GET(x)                           (((x) & 0x0000007f) >> 0)
-#define PHY_ANALOG_TX_TONEGEN0_ATE_TONEGEN_TONE_FREQ_SET(x)                           (((x) << 0) & 0x0000007f)
-#define PHY_ANALOG_TX_TONEGEN0_ATE_TONEGEN_TONE_A_EXP_MSB                                                    11
-#define PHY_ANALOG_TX_TONEGEN0_ATE_TONEGEN_TONE_A_EXP_LSB                                                     8
-#define PHY_ANALOG_TX_TONEGEN0_ATE_TONEGEN_TONE_A_EXP_MASK                                           0x00000f00
-#define PHY_ANALOG_TX_TONEGEN0_ATE_TONEGEN_TONE_A_EXP_GET(x)                          (((x) & 0x00000f00) >> 8)
-#define PHY_ANALOG_TX_TONEGEN0_ATE_TONEGEN_TONE_A_EXP_SET(x)                          (((x) << 8) & 0x00000f00)
-#define PHY_ANALOG_TX_TONEGEN0_ATE_TONEGEN_TONE_A_MAN_MSB                                                    23
-#define PHY_ANALOG_TX_TONEGEN0_ATE_TONEGEN_TONE_A_MAN_LSB                                                    16
-#define PHY_ANALOG_TX_TONEGEN0_ATE_TONEGEN_TONE_A_MAN_MASK                                           0x00ff0000
-#define PHY_ANALOG_TX_TONEGEN0_ATE_TONEGEN_TONE_A_MAN_GET(x)                         (((x) & 0x00ff0000) >> 16)
-#define PHY_ANALOG_TX_TONEGEN0_ATE_TONEGEN_TONE_A_MAN_SET(x)                         (((x) << 16) & 0x00ff0000)
-#define PHY_ANALOG_TX_TONEGEN0_ATE_TONEGEN_TONE_TAU_K_MSB                                                    30
-#define PHY_ANALOG_TX_TONEGEN0_ATE_TONEGEN_TONE_TAU_K_LSB                                                    24
-#define PHY_ANALOG_TX_TONEGEN0_ATE_TONEGEN_TONE_TAU_K_MASK                                           0x7f000000
-#define PHY_ANALOG_TX_TONEGEN0_ATE_TONEGEN_TONE_TAU_K_GET(x)                         (((x) & 0x7f000000) >> 24)
-#define PHY_ANALOG_TX_TONEGEN0_ATE_TONEGEN_TONE_TAU_K_SET(x)                         (((x) << 24) & 0x7f000000)
-
-/* macros for tx_tonegen1 */
-#define PHY_ANALOG_TX_TONEGEN1_ADDRESS                                                               0x0000038c
-#define PHY_ANALOG_TX_TONEGEN1_OFFSET                                                                0x0000038c
-#define PHY_ANALOG_TX_TONEGEN1_ATE_TONEGEN_TONE_FREQ_MSB                                                      6
-#define PHY_ANALOG_TX_TONEGEN1_ATE_TONEGEN_TONE_FREQ_LSB                                                      0
-#define PHY_ANALOG_TX_TONEGEN1_ATE_TONEGEN_TONE_FREQ_MASK                                            0x0000007f
-#define PHY_ANALOG_TX_TONEGEN1_ATE_TONEGEN_TONE_FREQ_GET(x)                           (((x) & 0x0000007f) >> 0)
-#define PHY_ANALOG_TX_TONEGEN1_ATE_TONEGEN_TONE_FREQ_SET(x)                           (((x) << 0) & 0x0000007f)
-#define PHY_ANALOG_TX_TONEGEN1_ATE_TONEGEN_TONE_A_EXP_MSB                                                    11
-#define PHY_ANALOG_TX_TONEGEN1_ATE_TONEGEN_TONE_A_EXP_LSB                                                     8
-#define PHY_ANALOG_TX_TONEGEN1_ATE_TONEGEN_TONE_A_EXP_MASK                                           0x00000f00
-#define PHY_ANALOG_TX_TONEGEN1_ATE_TONEGEN_TONE_A_EXP_GET(x)                          (((x) & 0x00000f00) >> 8)
-#define PHY_ANALOG_TX_TONEGEN1_ATE_TONEGEN_TONE_A_EXP_SET(x)                          (((x) << 8) & 0x00000f00)
-#define PHY_ANALOG_TX_TONEGEN1_ATE_TONEGEN_TONE_A_MAN_MSB                                                    23
-#define PHY_ANALOG_TX_TONEGEN1_ATE_TONEGEN_TONE_A_MAN_LSB                                                    16
-#define PHY_ANALOG_TX_TONEGEN1_ATE_TONEGEN_TONE_A_MAN_MASK                                           0x00ff0000
-#define PHY_ANALOG_TX_TONEGEN1_ATE_TONEGEN_TONE_A_MAN_GET(x)                         (((x) & 0x00ff0000) >> 16)
-#define PHY_ANALOG_TX_TONEGEN1_ATE_TONEGEN_TONE_A_MAN_SET(x)                         (((x) << 16) & 0x00ff0000)
-#define PHY_ANALOG_TX_TONEGEN1_ATE_TONEGEN_TONE_TAU_K_MSB                                                    30
-#define PHY_ANALOG_TX_TONEGEN1_ATE_TONEGEN_TONE_TAU_K_LSB                                                    24
-#define PHY_ANALOG_TX_TONEGEN1_ATE_TONEGEN_TONE_TAU_K_MASK                                           0x7f000000
-#define PHY_ANALOG_TX_TONEGEN1_ATE_TONEGEN_TONE_TAU_K_GET(x)                         (((x) & 0x7f000000) >> 24)
-#define PHY_ANALOG_TX_TONEGEN1_ATE_TONEGEN_TONE_TAU_K_SET(x)                         (((x) << 24) & 0x7f000000)
-
-/* macros for tx_lftonegen0 */
-#define PHY_ANALOG_TX_LFTONEGEN0_ADDRESS                                                             0x00000390
-#define PHY_ANALOG_TX_LFTONEGEN0_OFFSET                                                              0x00000390
-#define PHY_ANALOG_TX_LFTONEGEN0_ATE_TONEGEN_TONE_FREQ_MSB                                                    6
-#define PHY_ANALOG_TX_LFTONEGEN0_ATE_TONEGEN_TONE_FREQ_LSB                                                    0
-#define PHY_ANALOG_TX_LFTONEGEN0_ATE_TONEGEN_TONE_FREQ_MASK                                          0x0000007f
-#define PHY_ANALOG_TX_LFTONEGEN0_ATE_TONEGEN_TONE_FREQ_GET(x)                         (((x) & 0x0000007f) >> 0)
-#define PHY_ANALOG_TX_LFTONEGEN0_ATE_TONEGEN_TONE_FREQ_SET(x)                         (((x) << 0) & 0x0000007f)
-#define PHY_ANALOG_TX_LFTONEGEN0_ATE_TONEGEN_TONE_A_EXP_MSB                                                  11
-#define PHY_ANALOG_TX_LFTONEGEN0_ATE_TONEGEN_TONE_A_EXP_LSB                                                   8
-#define PHY_ANALOG_TX_LFTONEGEN0_ATE_TONEGEN_TONE_A_EXP_MASK                                         0x00000f00
-#define PHY_ANALOG_TX_LFTONEGEN0_ATE_TONEGEN_TONE_A_EXP_GET(x)                        (((x) & 0x00000f00) >> 8)
-#define PHY_ANALOG_TX_LFTONEGEN0_ATE_TONEGEN_TONE_A_EXP_SET(x)                        (((x) << 8) & 0x00000f00)
-#define PHY_ANALOG_TX_LFTONEGEN0_ATE_TONEGEN_TONE_A_MAN_MSB                                                  23
-#define PHY_ANALOG_TX_LFTONEGEN0_ATE_TONEGEN_TONE_A_MAN_LSB                                                  16
-#define PHY_ANALOG_TX_LFTONEGEN0_ATE_TONEGEN_TONE_A_MAN_MASK                                         0x00ff0000
-#define PHY_ANALOG_TX_LFTONEGEN0_ATE_TONEGEN_TONE_A_MAN_GET(x)                       (((x) & 0x00ff0000) >> 16)
-#define PHY_ANALOG_TX_LFTONEGEN0_ATE_TONEGEN_TONE_A_MAN_SET(x)                       (((x) << 16) & 0x00ff0000)
-#define PHY_ANALOG_TX_LFTONEGEN0_ATE_TONEGEN_TONE_TAU_K_MSB                                                  30
-#define PHY_ANALOG_TX_LFTONEGEN0_ATE_TONEGEN_TONE_TAU_K_LSB                                                  24
-#define PHY_ANALOG_TX_LFTONEGEN0_ATE_TONEGEN_TONE_TAU_K_MASK                                         0x7f000000
-#define PHY_ANALOG_TX_LFTONEGEN0_ATE_TONEGEN_TONE_TAU_K_GET(x)                       (((x) & 0x7f000000) >> 24)
-#define PHY_ANALOG_TX_LFTONEGEN0_ATE_TONEGEN_TONE_TAU_K_SET(x)                       (((x) << 24) & 0x7f000000)
-
-/* macros for tx_linear_ramp_i */
-#define PHY_ANALOG_TX_LINEAR_RAMP_I_ADDRESS                                                          0x00000394
-#define PHY_ANALOG_TX_LINEAR_RAMP_I_OFFSET                                                           0x00000394
-#define PHY_ANALOG_TX_LINEAR_RAMP_I_ATE_TONEGEN_LINRAMP_INIT_MSB                                             10
-#define PHY_ANALOG_TX_LINEAR_RAMP_I_ATE_TONEGEN_LINRAMP_INIT_LSB                                              0
-#define PHY_ANALOG_TX_LINEAR_RAMP_I_ATE_TONEGEN_LINRAMP_INIT_MASK                                    0x000007ff
-#define PHY_ANALOG_TX_LINEAR_RAMP_I_ATE_TONEGEN_LINRAMP_INIT_GET(x)                   (((x) & 0x000007ff) >> 0)
-#define PHY_ANALOG_TX_LINEAR_RAMP_I_ATE_TONEGEN_LINRAMP_INIT_SET(x)                   (((x) << 0) & 0x000007ff)
-#define PHY_ANALOG_TX_LINEAR_RAMP_I_ATE_TONEGEN_LINRAMP_DWELL_MSB                                            21
-#define PHY_ANALOG_TX_LINEAR_RAMP_I_ATE_TONEGEN_LINRAMP_DWELL_LSB                                            12
-#define PHY_ANALOG_TX_LINEAR_RAMP_I_ATE_TONEGEN_LINRAMP_DWELL_MASK                                   0x003ff000
-#define PHY_ANALOG_TX_LINEAR_RAMP_I_ATE_TONEGEN_LINRAMP_DWELL_GET(x)                 (((x) & 0x003ff000) >> 12)
-#define PHY_ANALOG_TX_LINEAR_RAMP_I_ATE_TONEGEN_LINRAMP_DWELL_SET(x)                 (((x) << 12) & 0x003ff000)
-#define PHY_ANALOG_TX_LINEAR_RAMP_I_ATE_TONEGEN_LINRAMP_STEP_MSB                                             29
-#define PHY_ANALOG_TX_LINEAR_RAMP_I_ATE_TONEGEN_LINRAMP_STEP_LSB                                             24
-#define PHY_ANALOG_TX_LINEAR_RAMP_I_ATE_TONEGEN_LINRAMP_STEP_MASK                                    0x3f000000
-#define PHY_ANALOG_TX_LINEAR_RAMP_I_ATE_TONEGEN_LINRAMP_STEP_GET(x)                  (((x) & 0x3f000000) >> 24)
-#define PHY_ANALOG_TX_LINEAR_RAMP_I_ATE_TONEGEN_LINRAMP_STEP_SET(x)                  (((x) << 24) & 0x3f000000)
-
-/* macros for tx_linear_ramp_q */
-#define PHY_ANALOG_TX_LINEAR_RAMP_Q_ADDRESS                                                          0x00000398
-#define PHY_ANALOG_TX_LINEAR_RAMP_Q_OFFSET                                                           0x00000398
-#define PHY_ANALOG_TX_LINEAR_RAMP_Q_ATE_TONEGEN_LINRAMP_INIT_MSB                                             10
-#define PHY_ANALOG_TX_LINEAR_RAMP_Q_ATE_TONEGEN_LINRAMP_INIT_LSB                                              0
-#define PHY_ANALOG_TX_LINEAR_RAMP_Q_ATE_TONEGEN_LINRAMP_INIT_MASK                                    0x000007ff
-#define PHY_ANALOG_TX_LINEAR_RAMP_Q_ATE_TONEGEN_LINRAMP_INIT_GET(x)                   (((x) & 0x000007ff) >> 0)
-#define PHY_ANALOG_TX_LINEAR_RAMP_Q_ATE_TONEGEN_LINRAMP_INIT_SET(x)                   (((x) << 0) & 0x000007ff)
-#define PHY_ANALOG_TX_LINEAR_RAMP_Q_ATE_TONEGEN_LINRAMP_DWELL_MSB                                            21
-#define PHY_ANALOG_TX_LINEAR_RAMP_Q_ATE_TONEGEN_LINRAMP_DWELL_LSB                                            12
-#define PHY_ANALOG_TX_LINEAR_RAMP_Q_ATE_TONEGEN_LINRAMP_DWELL_MASK                                   0x003ff000
-#define PHY_ANALOG_TX_LINEAR_RAMP_Q_ATE_TONEGEN_LINRAMP_DWELL_GET(x)                 (((x) & 0x003ff000) >> 12)
-#define PHY_ANALOG_TX_LINEAR_RAMP_Q_ATE_TONEGEN_LINRAMP_DWELL_SET(x)                 (((x) << 12) & 0x003ff000)
-#define PHY_ANALOG_TX_LINEAR_RAMP_Q_ATE_TONEGEN_LINRAMP_STEP_MSB                                             29
-#define PHY_ANALOG_TX_LINEAR_RAMP_Q_ATE_TONEGEN_LINRAMP_STEP_LSB                                             24
-#define PHY_ANALOG_TX_LINEAR_RAMP_Q_ATE_TONEGEN_LINRAMP_STEP_MASK                                    0x3f000000
-#define PHY_ANALOG_TX_LINEAR_RAMP_Q_ATE_TONEGEN_LINRAMP_STEP_GET(x)                  (((x) & 0x3f000000) >> 24)
-#define PHY_ANALOG_TX_LINEAR_RAMP_Q_ATE_TONEGEN_LINRAMP_STEP_SET(x)                  (((x) << 24) & 0x3f000000)
-
-/* macros for tx_prbs_mag */
-#define PHY_ANALOG_TX_PRBS_MAG_ADDRESS                                                               0x0000039c
-#define PHY_ANALOG_TX_PRBS_MAG_OFFSET                                                                0x0000039c
-#define PHY_ANALOG_TX_PRBS_MAG_ATE_TONEGEN_PRBS_MAGNITUDE_I_MSB                                               9
-#define PHY_ANALOG_TX_PRBS_MAG_ATE_TONEGEN_PRBS_MAGNITUDE_I_LSB                                               0
-#define PHY_ANALOG_TX_PRBS_MAG_ATE_TONEGEN_PRBS_MAGNITUDE_I_MASK                                     0x000003ff
-#define PHY_ANALOG_TX_PRBS_MAG_ATE_TONEGEN_PRBS_MAGNITUDE_I_GET(x)                    (((x) & 0x000003ff) >> 0)
-#define PHY_ANALOG_TX_PRBS_MAG_ATE_TONEGEN_PRBS_MAGNITUDE_I_SET(x)                    (((x) << 0) & 0x000003ff)
-#define PHY_ANALOG_TX_PRBS_MAG_ATE_TONEGEN_PRBS_MAGNITUDE_Q_MSB                                              25
-#define PHY_ANALOG_TX_PRBS_MAG_ATE_TONEGEN_PRBS_MAGNITUDE_Q_LSB                                              16
-#define PHY_ANALOG_TX_PRBS_MAG_ATE_TONEGEN_PRBS_MAGNITUDE_Q_MASK                                     0x03ff0000
-#define PHY_ANALOG_TX_PRBS_MAG_ATE_TONEGEN_PRBS_MAGNITUDE_Q_GET(x)                   (((x) & 0x03ff0000) >> 16)
-#define PHY_ANALOG_TX_PRBS_MAG_ATE_TONEGEN_PRBS_MAGNITUDE_Q_SET(x)                   (((x) << 16) & 0x03ff0000)
-
-/* macros for tx_prbs_seed_i */
-#define PHY_ANALOG_TX_PRBS_SEED_I_ADDRESS                                                            0x000003a0
-#define PHY_ANALOG_TX_PRBS_SEED_I_OFFSET                                                             0x000003a0
-#define PHY_ANALOG_TX_PRBS_SEED_I_ATE_TONEGEN_PRBS_SEED_MSB                                                  30
-#define PHY_ANALOG_TX_PRBS_SEED_I_ATE_TONEGEN_PRBS_SEED_LSB                                                   0
-#define PHY_ANALOG_TX_PRBS_SEED_I_ATE_TONEGEN_PRBS_SEED_MASK                                         0x7fffffff
-#define PHY_ANALOG_TX_PRBS_SEED_I_ATE_TONEGEN_PRBS_SEED_GET(x)                        (((x) & 0x7fffffff) >> 0)
-#define PHY_ANALOG_TX_PRBS_SEED_I_ATE_TONEGEN_PRBS_SEED_SET(x)                        (((x) << 0) & 0x7fffffff)
-
-/* macros for tx_prbs_seed_q */
-#define PHY_ANALOG_TX_PRBS_SEED_Q_ADDRESS                                                            0x000003a4
-#define PHY_ANALOG_TX_PRBS_SEED_Q_OFFSET                                                             0x000003a4
-#define PHY_ANALOG_TX_PRBS_SEED_Q_ATE_TONEGEN_PRBS_SEED_MSB                                                  30
-#define PHY_ANALOG_TX_PRBS_SEED_Q_ATE_TONEGEN_PRBS_SEED_LSB                                                   0
-#define PHY_ANALOG_TX_PRBS_SEED_Q_ATE_TONEGEN_PRBS_SEED_MASK                                         0x7fffffff
-#define PHY_ANALOG_TX_PRBS_SEED_Q_ATE_TONEGEN_PRBS_SEED_GET(x)                        (((x) & 0x7fffffff) >> 0)
-#define PHY_ANALOG_TX_PRBS_SEED_Q_ATE_TONEGEN_PRBS_SEED_SET(x)                        (((x) << 0) & 0x7fffffff)
-
-/* macros for cmac_dc_cancel */
-#define PHY_ANALOG_CMAC_DC_CANCEL_ADDRESS                                                            0x000003a8
-#define PHY_ANALOG_CMAC_DC_CANCEL_OFFSET                                                             0x000003a8
-#define PHY_ANALOG_CMAC_DC_CANCEL_ATE_CMAC_DC_CANCEL_I_MSB                                                    9
-#define PHY_ANALOG_CMAC_DC_CANCEL_ATE_CMAC_DC_CANCEL_I_LSB                                                    0
-#define PHY_ANALOG_CMAC_DC_CANCEL_ATE_CMAC_DC_CANCEL_I_MASK                                          0x000003ff
-#define PHY_ANALOG_CMAC_DC_CANCEL_ATE_CMAC_DC_CANCEL_I_GET(x)                         (((x) & 0x000003ff) >> 0)
-#define PHY_ANALOG_CMAC_DC_CANCEL_ATE_CMAC_DC_CANCEL_I_SET(x)                         (((x) << 0) & 0x000003ff)
-#define PHY_ANALOG_CMAC_DC_CANCEL_ATE_CMAC_DC_CANCEL_Q_MSB                                                   25
-#define PHY_ANALOG_CMAC_DC_CANCEL_ATE_CMAC_DC_CANCEL_Q_LSB                                                   16
-#define PHY_ANALOG_CMAC_DC_CANCEL_ATE_CMAC_DC_CANCEL_Q_MASK                                          0x03ff0000
-#define PHY_ANALOG_CMAC_DC_CANCEL_ATE_CMAC_DC_CANCEL_Q_GET(x)                        (((x) & 0x03ff0000) >> 16)
-#define PHY_ANALOG_CMAC_DC_CANCEL_ATE_CMAC_DC_CANCEL_Q_SET(x)                        (((x) << 16) & 0x03ff0000)
-
-/* macros for cmac_dc_offset */
-#define PHY_ANALOG_CMAC_DC_OFFSET_ADDRESS                                                            0x000003ac
-#define PHY_ANALOG_CMAC_DC_OFFSET_OFFSET                                                             0x000003ac
-#define PHY_ANALOG_CMAC_DC_OFFSET_ATE_CMAC_DC_CYCLES_MSB                                                      3
-#define PHY_ANALOG_CMAC_DC_OFFSET_ATE_CMAC_DC_CYCLES_LSB                                                      0
-#define PHY_ANALOG_CMAC_DC_OFFSET_ATE_CMAC_DC_CYCLES_MASK                                            0x0000000f
-#define PHY_ANALOG_CMAC_DC_OFFSET_ATE_CMAC_DC_CYCLES_GET(x)                           (((x) & 0x0000000f) >> 0)
-#define PHY_ANALOG_CMAC_DC_OFFSET_ATE_CMAC_DC_CYCLES_SET(x)                           (((x) << 0) & 0x0000000f)
-
-/* macros for cmac_corr */
-#define PHY_ANALOG_CMAC_CORR_ADDRESS                                                                 0x000003b0
-#define PHY_ANALOG_CMAC_CORR_OFFSET                                                                  0x000003b0
-#define PHY_ANALOG_CMAC_CORR_ATE_CMAC_CORR_CYCLES_MSB                                                         4
-#define PHY_ANALOG_CMAC_CORR_ATE_CMAC_CORR_CYCLES_LSB                                                         0
-#define PHY_ANALOG_CMAC_CORR_ATE_CMAC_CORR_CYCLES_MASK                                               0x0000001f
-#define PHY_ANALOG_CMAC_CORR_ATE_CMAC_CORR_CYCLES_GET(x)                              (((x) & 0x0000001f) >> 0)
-#define PHY_ANALOG_CMAC_CORR_ATE_CMAC_CORR_CYCLES_SET(x)                              (((x) << 0) & 0x0000001f)
-#define PHY_ANALOG_CMAC_CORR_ATE_CMAC_CORR_FREQ_MSB                                                          13
-#define PHY_ANALOG_CMAC_CORR_ATE_CMAC_CORR_FREQ_LSB                                                           8
-#define PHY_ANALOG_CMAC_CORR_ATE_CMAC_CORR_FREQ_MASK                                                 0x00003f00
-#define PHY_ANALOG_CMAC_CORR_ATE_CMAC_CORR_FREQ_GET(x)                                (((x) & 0x00003f00) >> 8)
-#define PHY_ANALOG_CMAC_CORR_ATE_CMAC_CORR_FREQ_SET(x)                                (((x) << 8) & 0x00003f00)
-
-/* macros for cmac_power */
-#define PHY_ANALOG_CMAC_POWER_ADDRESS                                                                0x000003b4
-#define PHY_ANALOG_CMAC_POWER_OFFSET                                                                 0x000003b4
-#define PHY_ANALOG_CMAC_POWER_ATE_CMAC_POWER_CYCLES_MSB                                                       3
-#define PHY_ANALOG_CMAC_POWER_ATE_CMAC_POWER_CYCLES_LSB                                                       0
-#define PHY_ANALOG_CMAC_POWER_ATE_CMAC_POWER_CYCLES_MASK                                             0x0000000f
-#define PHY_ANALOG_CMAC_POWER_ATE_CMAC_POWER_CYCLES_GET(x)                            (((x) & 0x0000000f) >> 0)
-#define PHY_ANALOG_CMAC_POWER_ATE_CMAC_POWER_CYCLES_SET(x)                            (((x) << 0) & 0x0000000f)
-
-/* macros for cmac_cross_corr */
-#define PHY_ANALOG_CMAC_CROSS_CORR_ADDRESS                                                           0x000003b8
-#define PHY_ANALOG_CMAC_CROSS_CORR_OFFSET                                                            0x000003b8
-#define PHY_ANALOG_CMAC_CROSS_CORR_ATE_CMAC_IQ_CYCLES_MSB                                                     3
-#define PHY_ANALOG_CMAC_CROSS_CORR_ATE_CMAC_IQ_CYCLES_LSB                                                     0
-#define PHY_ANALOG_CMAC_CROSS_CORR_ATE_CMAC_IQ_CYCLES_MASK                                           0x0000000f
-#define PHY_ANALOG_CMAC_CROSS_CORR_ATE_CMAC_IQ_CYCLES_GET(x)                          (((x) & 0x0000000f) >> 0)
-#define PHY_ANALOG_CMAC_CROSS_CORR_ATE_CMAC_IQ_CYCLES_SET(x)                          (((x) << 0) & 0x0000000f)
-
-/* macros for cmac_i2q2 */
-#define PHY_ANALOG_CMAC_I2Q2_ADDRESS                                                                 0x000003bc
-#define PHY_ANALOG_CMAC_I2Q2_OFFSET                                                                  0x000003bc
-#define PHY_ANALOG_CMAC_I2Q2_ATE_CMAC_I2Q2_CYCLES_MSB                                                         3
-#define PHY_ANALOG_CMAC_I2Q2_ATE_CMAC_I2Q2_CYCLES_LSB                                                         0
-#define PHY_ANALOG_CMAC_I2Q2_ATE_CMAC_I2Q2_CYCLES_MASK                                               0x0000000f
-#define PHY_ANALOG_CMAC_I2Q2_ATE_CMAC_I2Q2_CYCLES_GET(x)                              (((x) & 0x0000000f) >> 0)
-#define PHY_ANALOG_CMAC_I2Q2_ATE_CMAC_I2Q2_CYCLES_SET(x)                              (((x) << 0) & 0x0000000f)
-
-/* macros for cmac_power_hpf */
-#define PHY_ANALOG_CMAC_POWER_HPF_ADDRESS                                                            0x000003c0
-#define PHY_ANALOG_CMAC_POWER_HPF_OFFSET                                                             0x000003c0
-#define PHY_ANALOG_CMAC_POWER_HPF_ATE_CMAC_POWER_HPF_CYCLES_MSB                                               3
-#define PHY_ANALOG_CMAC_POWER_HPF_ATE_CMAC_POWER_HPF_CYCLES_LSB                                               0
-#define PHY_ANALOG_CMAC_POWER_HPF_ATE_CMAC_POWER_HPF_CYCLES_MASK                                     0x0000000f
-#define PHY_ANALOG_CMAC_POWER_HPF_ATE_CMAC_POWER_HPF_CYCLES_GET(x)                    (((x) & 0x0000000f) >> 0)
-#define PHY_ANALOG_CMAC_POWER_HPF_ATE_CMAC_POWER_HPF_CYCLES_SET(x)                    (((x) << 0) & 0x0000000f)
-#define PHY_ANALOG_CMAC_POWER_HPF_ATE_CMAC_POWER_HPF_WAIT_MSB                                                 7
-#define PHY_ANALOG_CMAC_POWER_HPF_ATE_CMAC_POWER_HPF_WAIT_LSB                                                 4
-#define PHY_ANALOG_CMAC_POWER_HPF_ATE_CMAC_POWER_HPF_WAIT_MASK                                       0x000000f0
-#define PHY_ANALOG_CMAC_POWER_HPF_ATE_CMAC_POWER_HPF_WAIT_GET(x)                      (((x) & 0x000000f0) >> 4)
-#define PHY_ANALOG_CMAC_POWER_HPF_ATE_CMAC_POWER_HPF_WAIT_SET(x)                      (((x) << 4) & 0x000000f0)
-
-/* macros for rxdac_set1 */
-#define PHY_ANALOG_RXDAC_SET1_ADDRESS                                                                0x000003c4
-#define PHY_ANALOG_RXDAC_SET1_OFFSET                                                                 0x000003c4
-#define PHY_ANALOG_RXDAC_SET1_ATE_RXDAC_MUX_MSB                                                               1
-#define PHY_ANALOG_RXDAC_SET1_ATE_RXDAC_MUX_LSB                                                               0
-#define PHY_ANALOG_RXDAC_SET1_ATE_RXDAC_MUX_MASK                                                     0x00000003
-#define PHY_ANALOG_RXDAC_SET1_ATE_RXDAC_MUX_GET(x)                                    (((x) & 0x00000003) >> 0)
-#define PHY_ANALOG_RXDAC_SET1_ATE_RXDAC_MUX_SET(x)                                    (((x) << 0) & 0x00000003)
-#define PHY_ANALOG_RXDAC_SET1_ATE_RXDAC_HI_GAIN_MSB                                                           4
-#define PHY_ANALOG_RXDAC_SET1_ATE_RXDAC_HI_GAIN_LSB                                                           4
-#define PHY_ANALOG_RXDAC_SET1_ATE_RXDAC_HI_GAIN_MASK                                                 0x00000010
-#define PHY_ANALOG_RXDAC_SET1_ATE_RXDAC_HI_GAIN_GET(x)                                (((x) & 0x00000010) >> 4)
-#define PHY_ANALOG_RXDAC_SET1_ATE_RXDAC_HI_GAIN_SET(x)                                (((x) << 4) & 0x00000010)
-#define PHY_ANALOG_RXDAC_SET1_ATE_RXDAC_CAL_WAIT_MSB                                                         13
-#define PHY_ANALOG_RXDAC_SET1_ATE_RXDAC_CAL_WAIT_LSB                                                          8
-#define PHY_ANALOG_RXDAC_SET1_ATE_RXDAC_CAL_WAIT_MASK                                                0x00003f00
-#define PHY_ANALOG_RXDAC_SET1_ATE_RXDAC_CAL_WAIT_GET(x)                               (((x) & 0x00003f00) >> 8)
-#define PHY_ANALOG_RXDAC_SET1_ATE_RXDAC_CAL_WAIT_SET(x)                               (((x) << 8) & 0x00003f00)
-#define PHY_ANALOG_RXDAC_SET1_ATE_RXDAC_CAL_MEASURE_TIME_MSB                                                 19
-#define PHY_ANALOG_RXDAC_SET1_ATE_RXDAC_CAL_MEASURE_TIME_LSB                                                 16
-#define PHY_ANALOG_RXDAC_SET1_ATE_RXDAC_CAL_MEASURE_TIME_MASK                                        0x000f0000
-#define PHY_ANALOG_RXDAC_SET1_ATE_RXDAC_CAL_MEASURE_TIME_GET(x)                      (((x) & 0x000f0000) >> 16)
-#define PHY_ANALOG_RXDAC_SET1_ATE_RXDAC_CAL_MEASURE_TIME_SET(x)                      (((x) << 16) & 0x000f0000)
-
-/* macros for rxdac_set2 */
-#define PHY_ANALOG_RXDAC_SET2_ADDRESS                                                                0x000003c8
-#define PHY_ANALOG_RXDAC_SET2_OFFSET                                                                 0x000003c8
-#define PHY_ANALOG_RXDAC_SET2_ATE_RXDAC_I_HI_MSB                                                              4
-#define PHY_ANALOG_RXDAC_SET2_ATE_RXDAC_I_HI_LSB                                                              0
-#define PHY_ANALOG_RXDAC_SET2_ATE_RXDAC_I_HI_MASK                                                    0x0000001f
-#define PHY_ANALOG_RXDAC_SET2_ATE_RXDAC_I_HI_GET(x)                                   (((x) & 0x0000001f) >> 0)
-#define PHY_ANALOG_RXDAC_SET2_ATE_RXDAC_I_HI_SET(x)                                   (((x) << 0) & 0x0000001f)
-#define PHY_ANALOG_RXDAC_SET2_ATE_RXDAC_Q_HI_MSB                                                             12
-#define PHY_ANALOG_RXDAC_SET2_ATE_RXDAC_Q_HI_LSB                                                              8
-#define PHY_ANALOG_RXDAC_SET2_ATE_RXDAC_Q_HI_MASK                                                    0x00001f00
-#define PHY_ANALOG_RXDAC_SET2_ATE_RXDAC_Q_HI_GET(x)                                   (((x) & 0x00001f00) >> 8)
-#define PHY_ANALOG_RXDAC_SET2_ATE_RXDAC_Q_HI_SET(x)                                   (((x) << 8) & 0x00001f00)
-#define PHY_ANALOG_RXDAC_SET2_ATE_RXDAC_I_LOW_MSB                                                            20
-#define PHY_ANALOG_RXDAC_SET2_ATE_RXDAC_I_LOW_LSB                                                            16
-#define PHY_ANALOG_RXDAC_SET2_ATE_RXDAC_I_LOW_MASK                                                   0x001f0000
-#define PHY_ANALOG_RXDAC_SET2_ATE_RXDAC_I_LOW_GET(x)                                 (((x) & 0x001f0000) >> 16)
-#define PHY_ANALOG_RXDAC_SET2_ATE_RXDAC_I_LOW_SET(x)                                 (((x) << 16) & 0x001f0000)
-#define PHY_ANALOG_RXDAC_SET2_ATE_RXDAC_Q_LOW_MSB                                                            28
-#define PHY_ANALOG_RXDAC_SET2_ATE_RXDAC_Q_LOW_LSB                                                            24
-#define PHY_ANALOG_RXDAC_SET2_ATE_RXDAC_Q_LOW_MASK                                                   0x1f000000
-#define PHY_ANALOG_RXDAC_SET2_ATE_RXDAC_Q_LOW_GET(x)                                 (((x) & 0x1f000000) >> 24)
-#define PHY_ANALOG_RXDAC_SET2_ATE_RXDAC_Q_LOW_SET(x)                                 (((x) << 24) & 0x1f000000)
-
-/* macros for rxdac_long_shift */
-#define PHY_ANALOG_RXDAC_LONG_SHIFT_ADDRESS                                                          0x000003cc
-#define PHY_ANALOG_RXDAC_LONG_SHIFT_OFFSET                                                           0x000003cc
-#define PHY_ANALOG_RXDAC_LONG_SHIFT_ATE_RXDAC_I_STATIC_MSB                                                    4
-#define PHY_ANALOG_RXDAC_LONG_SHIFT_ATE_RXDAC_I_STATIC_LSB                                                    0
-#define PHY_ANALOG_RXDAC_LONG_SHIFT_ATE_RXDAC_I_STATIC_MASK                                          0x0000001f
-#define PHY_ANALOG_RXDAC_LONG_SHIFT_ATE_RXDAC_I_STATIC_GET(x)                         (((x) & 0x0000001f) >> 0)
-#define PHY_ANALOG_RXDAC_LONG_SHIFT_ATE_RXDAC_I_STATIC_SET(x)                         (((x) << 0) & 0x0000001f)
-#define PHY_ANALOG_RXDAC_LONG_SHIFT_ATE_RXDAC_Q_STATIC_MSB                                                   12
-#define PHY_ANALOG_RXDAC_LONG_SHIFT_ATE_RXDAC_Q_STATIC_LSB                                                    8
-#define PHY_ANALOG_RXDAC_LONG_SHIFT_ATE_RXDAC_Q_STATIC_MASK                                          0x00001f00
-#define PHY_ANALOG_RXDAC_LONG_SHIFT_ATE_RXDAC_Q_STATIC_GET(x)                         (((x) & 0x00001f00) >> 8)
-#define PHY_ANALOG_RXDAC_LONG_SHIFT_ATE_RXDAC_Q_STATIC_SET(x)                         (((x) << 8) & 0x00001f00)
-
-/* macros for cmac_results_i */
-#define PHY_ANALOG_CMAC_RESULTS_I_ADDRESS                                                            0x000003d0
-#define PHY_ANALOG_CMAC_RESULTS_I_OFFSET                                                             0x000003d0
-#define PHY_ANALOG_CMAC_RESULTS_I_ATE_CMAC_RESULTS_MSB                                                       31
-#define PHY_ANALOG_CMAC_RESULTS_I_ATE_CMAC_RESULTS_LSB                                                        0
-#define PHY_ANALOG_CMAC_RESULTS_I_ATE_CMAC_RESULTS_MASK                                              0xffffffff
-#define PHY_ANALOG_CMAC_RESULTS_I_ATE_CMAC_RESULTS_GET(x)                             (((x) & 0xffffffff) >> 0)
-#define PHY_ANALOG_CMAC_RESULTS_I_ATE_CMAC_RESULTS_SET(x)                             (((x) << 0) & 0xffffffff)
-
-/* macros for cmac_results_q */
-#define PHY_ANALOG_CMAC_RESULTS_Q_ADDRESS                                                            0x000003d4
-#define PHY_ANALOG_CMAC_RESULTS_Q_OFFSET                                                             0x000003d4
-#define PHY_ANALOG_CMAC_RESULTS_Q_ATE_CMAC_RESULTS_MSB                                                       31
-#define PHY_ANALOG_CMAC_RESULTS_Q_ATE_CMAC_RESULTS_LSB                                                        0
-#define PHY_ANALOG_CMAC_RESULTS_Q_ATE_CMAC_RESULTS_MASK                                              0xffffffff
-#define PHY_ANALOG_CMAC_RESULTS_Q_ATE_CMAC_RESULTS_GET(x)                             (((x) & 0xffffffff) >> 0)
-#define PHY_ANALOG_CMAC_RESULTS_Q_ATE_CMAC_RESULTS_SET(x)                             (((x) << 0) & 0xffffffff)
-
-/* macros for PMU1 */
-#define PHY_ANALOG_PMU1_ADDRESS                                                                      0x00000740
-#define PHY_ANALOG_PMU1_OFFSET                                                                       0x00000740
-#define PHY_ANALOG_PMU1_SPARE_MSB                                                                            10
-#define PHY_ANALOG_PMU1_SPARE_LSB                                                                             0
-#define PHY_ANALOG_PMU1_SPARE_MASK                                                                   0x000007ff
-#define PHY_ANALOG_PMU1_SPARE_GET(x)                                                  (((x) & 0x000007ff) >> 0)
-#define PHY_ANALOG_PMU1_SPARE_SET(x)                                                  (((x) << 0) & 0x000007ff)
-#define PHY_ANALOG_PMU1_OTP_V25_PWD_MSB                                                                      11
-#define PHY_ANALOG_PMU1_OTP_V25_PWD_LSB                                                                      11
-#define PHY_ANALOG_PMU1_OTP_V25_PWD_MASK                                                             0x00000800
-#define PHY_ANALOG_PMU1_OTP_V25_PWD_GET(x)                                           (((x) & 0x00000800) >> 11)
-#define PHY_ANALOG_PMU1_OTP_V25_PWD_SET(x)                                           (((x) << 11) & 0x00000800)
-#define PHY_ANALOG_PMU1_PAREGON_MAN_MSB                                                                      12
-#define PHY_ANALOG_PMU1_PAREGON_MAN_LSB                                                                      12
-#define PHY_ANALOG_PMU1_PAREGON_MAN_MASK                                                             0x00001000
-#define PHY_ANALOG_PMU1_PAREGON_MAN_GET(x)                                           (((x) & 0x00001000) >> 12)
-#define PHY_ANALOG_PMU1_PAREGON_MAN_SET(x)                                           (((x) << 12) & 0x00001000)
-#define PHY_ANALOG_PMU1_OTPREGON_MAN_MSB                                                                     13
-#define PHY_ANALOG_PMU1_OTPREGON_MAN_LSB                                                                     13
-#define PHY_ANALOG_PMU1_OTPREGON_MAN_MASK                                                            0x00002000
-#define PHY_ANALOG_PMU1_OTPREGON_MAN_GET(x)                                          (((x) & 0x00002000) >> 13)
-#define PHY_ANALOG_PMU1_OTPREGON_MAN_SET(x)                                          (((x) << 13) & 0x00002000)
-#define PHY_ANALOG_PMU1_DREGON_MAN_MSB                                                                       14
-#define PHY_ANALOG_PMU1_DREGON_MAN_LSB                                                                       14
-#define PHY_ANALOG_PMU1_DREGON_MAN_MASK                                                              0x00004000
-#define PHY_ANALOG_PMU1_DREGON_MAN_GET(x)                                            (((x) & 0x00004000) >> 14)
-#define PHY_ANALOG_PMU1_DREGON_MAN_SET(x)                                            (((x) << 14) & 0x00004000)
-#define PHY_ANALOG_PMU1_DISCONTMODEEN_MSB                                                                    15
-#define PHY_ANALOG_PMU1_DISCONTMODEEN_LSB                                                                    15
-#define PHY_ANALOG_PMU1_DISCONTMODEEN_MASK                                                           0x00008000
-#define PHY_ANALOG_PMU1_DISCONTMODEEN_GET(x)                                         (((x) & 0x00008000) >> 15)
-#define PHY_ANALOG_PMU1_DISCONTMODEEN_SET(x)                                         (((x) << 15) & 0x00008000)
-#define PHY_ANALOG_PMU1_SWREGON_MAN_MSB                                                                      16
-#define PHY_ANALOG_PMU1_SWREGON_MAN_LSB                                                                      16
-#define PHY_ANALOG_PMU1_SWREGON_MAN_MASK                                                             0x00010000
-#define PHY_ANALOG_PMU1_SWREGON_MAN_GET(x)                                           (((x) & 0x00010000) >> 16)
-#define PHY_ANALOG_PMU1_SWREGON_MAN_SET(x)                                           (((x) << 16) & 0x00010000)
-#define PHY_ANALOG_PMU1_SWREG_FREQCUR_MSB                                                                    18
-#define PHY_ANALOG_PMU1_SWREG_FREQCUR_LSB                                                                    17
-#define PHY_ANALOG_PMU1_SWREG_FREQCUR_MASK                                                           0x00060000
-#define PHY_ANALOG_PMU1_SWREG_FREQCUR_GET(x)                                         (((x) & 0x00060000) >> 17)
-#define PHY_ANALOG_PMU1_SWREG_FREQCUR_SET(x)                                         (((x) << 17) & 0x00060000)
-#define PHY_ANALOG_PMU1_SWREG_FREQCAP_MSB                                                                    21
-#define PHY_ANALOG_PMU1_SWREG_FREQCAP_LSB                                                                    19
-#define PHY_ANALOG_PMU1_SWREG_FREQCAP_MASK                                                           0x00380000
-#define PHY_ANALOG_PMU1_SWREG_FREQCAP_GET(x)                                         (((x) & 0x00380000) >> 19)
-#define PHY_ANALOG_PMU1_SWREG_FREQCAP_SET(x)                                         (((x) << 19) & 0x00380000)
-#define PHY_ANALOG_PMU1_SWREG_LVLCTR_MSB                                                                     23
-#define PHY_ANALOG_PMU1_SWREG_LVLCTR_LSB                                                                     22
-#define PHY_ANALOG_PMU1_SWREG_LVLCTR_MASK                                                            0x00c00000
-#define PHY_ANALOG_PMU1_SWREG_LVLCTR_GET(x)                                          (((x) & 0x00c00000) >> 22)
-#define PHY_ANALOG_PMU1_SWREG_LVLCTR_SET(x)                                          (((x) << 22) & 0x00c00000)
-#define PHY_ANALOG_PMU1_SREG_LVLCTR_MSB                                                                      25
-#define PHY_ANALOG_PMU1_SREG_LVLCTR_LSB                                                                      24
-#define PHY_ANALOG_PMU1_SREG_LVLCTR_MASK                                                             0x03000000
-#define PHY_ANALOG_PMU1_SREG_LVLCTR_GET(x)                                           (((x) & 0x03000000) >> 24)
-#define PHY_ANALOG_PMU1_SREG_LVLCTR_SET(x)                                           (((x) << 24) & 0x03000000)
-#define PHY_ANALOG_PMU1_DREG_LVLCTR_MSB                                                                      27
-#define PHY_ANALOG_PMU1_DREG_LVLCTR_LSB                                                                      26
-#define PHY_ANALOG_PMU1_DREG_LVLCTR_MASK                                                             0x0c000000
-#define PHY_ANALOG_PMU1_DREG_LVLCTR_GET(x)                                           (((x) & 0x0c000000) >> 26)
-#define PHY_ANALOG_PMU1_DREG_LVLCTR_SET(x)                                           (((x) << 26) & 0x0c000000)
-#define PHY_ANALOG_PMU1_PAREG_XPNP_MSB                                                                       28
-#define PHY_ANALOG_PMU1_PAREG_XPNP_LSB                                                                       28
-#define PHY_ANALOG_PMU1_PAREG_XPNP_MASK                                                              0x10000000
-#define PHY_ANALOG_PMU1_PAREG_XPNP_GET(x)                                            (((x) & 0x10000000) >> 28)
-#define PHY_ANALOG_PMU1_PAREG_XPNP_SET(x)                                            (((x) << 28) & 0x10000000)
-#define PHY_ANALOG_PMU1_PAREG_LVLCTR_MSB                                                                     31
-#define PHY_ANALOG_PMU1_PAREG_LVLCTR_LSB                                                                     29
-#define PHY_ANALOG_PMU1_PAREG_LVLCTR_MASK                                                            0xe0000000
-#define PHY_ANALOG_PMU1_PAREG_LVLCTR_GET(x)                                          (((x) & 0xe0000000) >> 29)
-#define PHY_ANALOG_PMU1_PAREG_LVLCTR_SET(x)                                          (((x) << 29) & 0xe0000000)
-
-/* macros for PMU2 */
-#define PHY_ANALOG_PMU2_ADDRESS                                                                      0x00000744
-#define PHY_ANALOG_PMU2_OFFSET                                                                       0x00000744
-#define PHY_ANALOG_PMU2_SPARE_MSB                                                                             7
-#define PHY_ANALOG_PMU2_SPARE_LSB                                                                             0
-#define PHY_ANALOG_PMU2_SPARE_MASK                                                                   0x000000ff
-#define PHY_ANALOG_PMU2_SPARE_GET(x)                                                  (((x) & 0x000000ff) >> 0)
-#define PHY_ANALOG_PMU2_SPARE_SET(x)                                                  (((x) << 0) & 0x000000ff)
-#define PHY_ANALOG_PMU2_VBATT_1_3TOATB_MSB                                                                    8
-#define PHY_ANALOG_PMU2_VBATT_1_3TOATB_LSB                                                                    8
-#define PHY_ANALOG_PMU2_VBATT_1_3TOATB_MASK                                                          0x00000100
-#define PHY_ANALOG_PMU2_VBATT_1_3TOATB_GET(x)                                         (((x) & 0x00000100) >> 8)
-#define PHY_ANALOG_PMU2_VBATT_1_3TOATB_SET(x)                                         (((x) << 8) & 0x00000100)
-#define PHY_ANALOG_PMU2_VBATT_1_2TOATB_MSB                                                                    9
-#define PHY_ANALOG_PMU2_VBATT_1_2TOATB_LSB                                                                    9
-#define PHY_ANALOG_PMU2_VBATT_1_2TOATB_MASK                                                          0x00000200
-#define PHY_ANALOG_PMU2_VBATT_1_2TOATB_GET(x)                                         (((x) & 0x00000200) >> 9)
-#define PHY_ANALOG_PMU2_VBATT_1_2TOATB_SET(x)                                         (((x) << 9) & 0x00000200)
-#define PHY_ANALOG_PMU2_VBATT_2_3TOATB_MSB                                                                   10
-#define PHY_ANALOG_PMU2_VBATT_2_3TOATB_LSB                                                                   10
-#define PHY_ANALOG_PMU2_VBATT_2_3TOATB_MASK                                                          0x00000400
-#define PHY_ANALOG_PMU2_VBATT_2_3TOATB_GET(x)                                        (((x) & 0x00000400) >> 10)
-#define PHY_ANALOG_PMU2_VBATT_2_3TOATB_SET(x)                                        (((x) << 10) & 0x00000400)
-#define PHY_ANALOG_PMU2_PWD_BANDGAP_MAN_MSB                                                                  11
-#define PHY_ANALOG_PMU2_PWD_BANDGAP_MAN_LSB                                                                  11
-#define PHY_ANALOG_PMU2_PWD_BANDGAP_MAN_MASK                                                         0x00000800
-#define PHY_ANALOG_PMU2_PWD_BANDGAP_MAN_GET(x)                                       (((x) & 0x00000800) >> 11)
-#define PHY_ANALOG_PMU2_PWD_BANDGAP_MAN_SET(x)                                       (((x) << 11) & 0x00000800)
-#define PHY_ANALOG_PMU2_PWD_LFO_MAN_MSB                                                                      12
-#define PHY_ANALOG_PMU2_PWD_LFO_MAN_LSB                                                                      12
-#define PHY_ANALOG_PMU2_PWD_LFO_MAN_MASK                                                             0x00001000
-#define PHY_ANALOG_PMU2_PWD_LFO_MAN_GET(x)                                           (((x) & 0x00001000) >> 12)
-#define PHY_ANALOG_PMU2_PWD_LFO_MAN_SET(x)                                           (((x) << 12) & 0x00001000)
-#define PHY_ANALOG_PMU2_VBATT_LT_3P2_MSB                                                                     13
-#define PHY_ANALOG_PMU2_VBATT_LT_3P2_LSB                                                                     13
-#define PHY_ANALOG_PMU2_VBATT_LT_3P2_MASK                                                            0x00002000
-#define PHY_ANALOG_PMU2_VBATT_LT_3P2_GET(x)                                          (((x) & 0x00002000) >> 13)
-#define PHY_ANALOG_PMU2_VBATT_LT_3P2_SET(x)                                          (((x) << 13) & 0x00002000)
-#define PHY_ANALOG_PMU2_VBATT_LT_2P8_MSB                                                                     14
-#define PHY_ANALOG_PMU2_VBATT_LT_2P8_LSB                                                                     14
-#define PHY_ANALOG_PMU2_VBATT_LT_2P8_MASK                                                            0x00004000
-#define PHY_ANALOG_PMU2_VBATT_LT_2P8_GET(x)                                          (((x) & 0x00004000) >> 14)
-#define PHY_ANALOG_PMU2_VBATT_LT_2P8_SET(x)                                          (((x) << 14) & 0x00004000)
-#define PHY_ANALOG_PMU2_VBATT_GT_4P2_MSB                                                                     15
-#define PHY_ANALOG_PMU2_VBATT_GT_4P2_LSB                                                                     15
-#define PHY_ANALOG_PMU2_VBATT_GT_4P2_MASK                                                            0x00008000
-#define PHY_ANALOG_PMU2_VBATT_GT_4P2_GET(x)                                          (((x) & 0x00008000) >> 15)
-#define PHY_ANALOG_PMU2_VBATT_GT_4P2_SET(x)                                          (((x) << 15) & 0x00008000)
-#define PHY_ANALOG_PMU2_PMU_MAN_OVERRIDE_EN_MSB                                                              16
-#define PHY_ANALOG_PMU2_PMU_MAN_OVERRIDE_EN_LSB                                                              16
-#define PHY_ANALOG_PMU2_PMU_MAN_OVERRIDE_EN_MASK                                                     0x00010000
-#define PHY_ANALOG_PMU2_PMU_MAN_OVERRIDE_EN_GET(x)                                   (((x) & 0x00010000) >> 16)
-#define PHY_ANALOG_PMU2_PMU_MAN_OVERRIDE_EN_SET(x)                                   (((x) << 16) & 0x00010000)
-#define PHY_ANALOG_PMU2_VBATT_GT_LVLCTR_MSB                                                                  18
-#define PHY_ANALOG_PMU2_VBATT_GT_LVLCTR_LSB                                                                  17
-#define PHY_ANALOG_PMU2_VBATT_GT_LVLCTR_MASK                                                         0x00060000
-#define PHY_ANALOG_PMU2_VBATT_GT_LVLCTR_GET(x)                                       (((x) & 0x00060000) >> 17)
-#define PHY_ANALOG_PMU2_VBATT_GT_LVLCTR_SET(x)                                       (((x) << 17) & 0x00060000)
-#define PHY_ANALOG_PMU2_SWREGVSSL2ATB_MSB                                                                    19
-#define PHY_ANALOG_PMU2_SWREGVSSL2ATB_LSB                                                                    19
-#define PHY_ANALOG_PMU2_SWREGVSSL2ATB_MASK                                                           0x00080000
-#define PHY_ANALOG_PMU2_SWREGVSSL2ATB_GET(x)                                         (((x) & 0x00080000) >> 19)
-#define PHY_ANALOG_PMU2_SWREGVSSL2ATB_SET(x)                                         (((x) << 19) & 0x00080000)
-#define PHY_ANALOG_PMU2_SWREGVSSL_LVLCTR_MSB                                                                 21
-#define PHY_ANALOG_PMU2_SWREGVSSL_LVLCTR_LSB                                                                 20
-#define PHY_ANALOG_PMU2_SWREGVSSL_LVLCTR_MASK                                                        0x00300000
-#define PHY_ANALOG_PMU2_SWREGVSSL_LVLCTR_GET(x)                                      (((x) & 0x00300000) >> 20)
-#define PHY_ANALOG_PMU2_SWREGVSSL_LVLCTR_SET(x)                                      (((x) << 20) & 0x00300000)
-#define PHY_ANALOG_PMU2_SWREGVDDH2ATB_MSB                                                                    22
-#define PHY_ANALOG_PMU2_SWREGVDDH2ATB_LSB                                                                    22
-#define PHY_ANALOG_PMU2_SWREGVDDH2ATB_MASK                                                           0x00400000
-#define PHY_ANALOG_PMU2_SWREGVDDH2ATB_GET(x)                                         (((x) & 0x00400000) >> 22)
-#define PHY_ANALOG_PMU2_SWREGVDDH2ATB_SET(x)                                         (((x) << 22) & 0x00400000)
-#define PHY_ANALOG_PMU2_SWREGVDDH_LVLCTR_MSB                                                                 24
-#define PHY_ANALOG_PMU2_SWREGVDDH_LVLCTR_LSB                                                                 23
-#define PHY_ANALOG_PMU2_SWREGVDDH_LVLCTR_MASK                                                        0x01800000
-#define PHY_ANALOG_PMU2_SWREGVDDH_LVLCTR_GET(x)                                      (((x) & 0x01800000) >> 23)
-#define PHY_ANALOG_PMU2_SWREGVDDH_LVLCTR_SET(x)                                      (((x) << 23) & 0x01800000)
-#define PHY_ANALOG_PMU2_SWREG2ATB_MSB                                                                        27
-#define PHY_ANALOG_PMU2_SWREG2ATB_LSB                                                                        25
-#define PHY_ANALOG_PMU2_SWREG2ATB_MASK                                                               0x0e000000
-#define PHY_ANALOG_PMU2_SWREG2ATB_GET(x)                                             (((x) & 0x0e000000) >> 25)
-#define PHY_ANALOG_PMU2_SWREG2ATB_SET(x)                                             (((x) << 25) & 0x0e000000)
-#define PHY_ANALOG_PMU2_OTPREG2ATB_MSB                                                                       28
-#define PHY_ANALOG_PMU2_OTPREG2ATB_LSB                                                                       28
-#define PHY_ANALOG_PMU2_OTPREG2ATB_MASK                                                              0x10000000
-#define PHY_ANALOG_PMU2_OTPREG2ATB_GET(x)                                            (((x) & 0x10000000) >> 28)
-#define PHY_ANALOG_PMU2_OTPREG2ATB_SET(x)                                            (((x) << 28) & 0x10000000)
-#define PHY_ANALOG_PMU2_OTPREG_LVLCTR_MSB                                                                    30
-#define PHY_ANALOG_PMU2_OTPREG_LVLCTR_LSB                                                                    29
-#define PHY_ANALOG_PMU2_OTPREG_LVLCTR_MASK                                                           0x60000000
-#define PHY_ANALOG_PMU2_OTPREG_LVLCTR_GET(x)                                         (((x) & 0x60000000) >> 29)
-#define PHY_ANALOG_PMU2_OTPREG_LVLCTR_SET(x)                                         (((x) << 29) & 0x60000000)
-#define PHY_ANALOG_PMU2_DREG_LVLCTR_MANOVR_EN_MSB                                                            31
-#define PHY_ANALOG_PMU2_DREG_LVLCTR_MANOVR_EN_LSB                                                            31
-#define PHY_ANALOG_PMU2_DREG_LVLCTR_MANOVR_EN_MASK                                                   0x80000000
-#define PHY_ANALOG_PMU2_DREG_LVLCTR_MANOVR_EN_GET(x)                                 (((x) & 0x80000000) >> 31)
-#define PHY_ANALOG_PMU2_DREG_LVLCTR_MANOVR_EN_SET(x)                                 (((x) << 31) & 0x80000000)
-
-
-#ifndef __ASSEMBLER__
-
-typedef struct analog_intf_ares_reg_reg_s {
-  volatile unsigned int RXRF_BIAS1;                                    /*        0x0 - 0x4        */
-  volatile unsigned int RXRF_BIAS2;                                    /*        0x4 - 0x8        */
-  volatile unsigned int RXRF_GAINSTAGES;                               /*        0x8 - 0xc        */
-  volatile unsigned int RXRF_AGC;                                      /*        0xc - 0x10       */
-  volatile char pad__0[0x30];                                          /*       0x10 - 0x40       */
-  volatile unsigned int TXRF1;                                         /*       0x40 - 0x44       */
-  volatile unsigned int TXRF2;                                         /*       0x44 - 0x48       */
-  volatile unsigned int TXRF3;                                         /*       0x48 - 0x4c       */
-  volatile unsigned int TXRF4;                                         /*       0x4c - 0x50       */
-  volatile unsigned int TXRF5;                                         /*       0x50 - 0x54       */
-  volatile unsigned int TXRF6;                                         /*       0x54 - 0x58       */
-  volatile unsigned int TXRF7;                                         /*       0x58 - 0x5c       */
-  volatile unsigned int TXRF8;                                         /*       0x5c - 0x60       */
-  volatile unsigned int TXRF9;                                         /*       0x60 - 0x64       */
-  volatile unsigned int TXRF10;                                        /*       0x64 - 0x68       */
-  volatile unsigned int TXRF11;                                        /*       0x68 - 0x6c       */
-  volatile unsigned int TXRF12;                                        /*       0x6c - 0x70       */
-  volatile char pad__1[0x10];                                          /*       0x70 - 0x80       */
-  volatile unsigned int SYNTH1;                                        /*       0x80 - 0x84       */
-  volatile unsigned int SYNTH2;                                        /*       0x84 - 0x88       */
-  volatile unsigned int SYNTH3;                                        /*       0x88 - 0x8c       */
-  volatile unsigned int SYNTH4;                                        /*       0x8c - 0x90       */
-  volatile unsigned int SYNTH5;                                        /*       0x90 - 0x94       */
-  volatile unsigned int SYNTH6;                                        /*       0x94 - 0x98       */
-  volatile unsigned int SYNTH7;                                        /*       0x98 - 0x9c       */
-  volatile unsigned int SYNTH8;                                        /*       0x9c - 0xa0       */
-  volatile unsigned int SYNTH9;                                        /*       0xa0 - 0xa4       */
-  volatile unsigned int SYNTH10;                                       /*       0xa4 - 0xa8       */
-  volatile unsigned int SYNTH11;                                       /*       0xa8 - 0xac       */
-  volatile unsigned int SYNTH12;                                       /*       0xac - 0xb0       */
-  volatile char pad__2[0x10];                                          /*       0xb0 - 0xc0       */
-  volatile unsigned int BIAS1;                                         /*       0xc0 - 0xc4       */
-  volatile unsigned int BIAS2;                                         /*       0xc4 - 0xc8       */
-  volatile unsigned int BIAS3;                                         /*       0xc8 - 0xcc       */
-  volatile unsigned int BIAS4;                                         /*       0xcc - 0xd0       */
-  volatile char pad__3[0x30];                                          /*       0xd0 - 0x100      */
-  volatile unsigned int RXTX1;                                         /*      0x100 - 0x104      */
-  volatile unsigned int RXTX2;                                         /*      0x104 - 0x108      */
-  volatile unsigned int RXTX3;                                         /*      0x108 - 0x10c      */
-  volatile char pad__4[0x34];                                          /*      0x10c - 0x140      */
-  volatile unsigned int BB1;                                           /*      0x140 - 0x144      */
-  volatile unsigned int BB2;                                           /*      0x144 - 0x148      */
-  volatile char pad__5[0x138];                                         /*      0x148 - 0x280      */
-  volatile unsigned int TOP1;                                          /*      0x280 - 0x284      */
-  volatile unsigned int TOP2;                                          /*      0x284 - 0x288      */
-  volatile unsigned int TOP3;                                          /*      0x288 - 0x28c      */
-  volatile unsigned int TOP4;                                          /*      0x28c - 0x290      */
-  volatile char pad__6[0xf0];                                          /*      0x290 - 0x380      */
-  volatile unsigned int rbist_cntrl;                                   /*      0x380 - 0x384      */
-  volatile unsigned int tx_dc_offset;                                  /*      0x384 - 0x388      */
-  volatile unsigned int tx_tonegen0;                                   /*      0x388 - 0x38c      */
-  volatile unsigned int tx_tonegen1;                                   /*      0x38c - 0x390      */
-  volatile unsigned int tx_lftonegen0;                                 /*      0x390 - 0x394      */
-  volatile unsigned int tx_linear_ramp_i;                              /*      0x394 - 0x398      */
-  volatile unsigned int tx_linear_ramp_q;                              /*      0x398 - 0x39c      */
-  volatile unsigned int tx_prbs_mag;                                   /*      0x39c - 0x3a0      */
-  volatile unsigned int tx_prbs_seed_i;                                /*      0x3a0 - 0x3a4      */
-  volatile unsigned int tx_prbs_seed_q;                                /*      0x3a4 - 0x3a8      */
-  volatile unsigned int cmac_dc_cancel;                                /*      0x3a8 - 0x3ac      */
-  volatile unsigned int cmac_dc_offset;                                /*      0x3ac - 0x3b0      */
-  volatile unsigned int cmac_corr;                                     /*      0x3b0 - 0x3b4      */
-  volatile unsigned int cmac_power;                                    /*      0x3b4 - 0x3b8      */
-  volatile unsigned int cmac_cross_corr;                               /*      0x3b8 - 0x3bc      */
-  volatile unsigned int cmac_i2q2;                                     /*      0x3bc - 0x3c0      */
-  volatile unsigned int cmac_power_hpf;                                /*      0x3c0 - 0x3c4      */
-  volatile unsigned int rxdac_set1;                                    /*      0x3c4 - 0x3c8      */
-  volatile unsigned int rxdac_set2;                                    /*      0x3c8 - 0x3cc      */
-  volatile unsigned int rxdac_long_shift;                              /*      0x3cc - 0x3d0      */
-  volatile unsigned int cmac_results_i;                                /*      0x3d0 - 0x3d4      */
-  volatile unsigned int cmac_results_q;                                /*      0x3d4 - 0x3d8      */
-  volatile char pad__7[0x368];                                         /*      0x3d8 - 0x740      */
-  volatile unsigned int PMU1;                                          /*      0x740 - 0x744      */
-  volatile unsigned int PMU2;                                          /*      0x744 - 0x748      */
-} analog_intf_ares_reg_reg_t;
-
-#endif /* __ASSEMBLER__ */
-
-#endif /* _ANALOG_INTF_ARES_REG_REG_H_ */
diff --git a/drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/analog_intf_athr_wlan_reg.h b/drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/analog_intf_athr_wlan_reg.h
deleted file mode 100644 (file)
index 1c243fb..0000000
+++ /dev/null
@@ -1,3674 +0,0 @@
-// ------------------------------------------------------------------
-// Copyright (c) 2004-2010 Atheros Corporation.  All rights reserved.
-// 
-//
-// Permission to use, copy, modify, and/or distribute this software for any
-// purpose with or without fee is hereby granted, provided that the above
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-//
-//
-// ------------------------------------------------------------------
-//===================================================================
-// Author(s): ="Atheros"
-//===================================================================
-
-/* Copyright (C) 2009 Denali Software Inc.  All rights reserved              */
-/* THIS FILE IS AUTOMATICALLY GENERATED BY DENALI BLUEPRINT, DO NOT EDIT     */
-
-
-#ifndef _ANALOG_INTF_ATHR_WLAN_REG_REG_H_
-#define _ANALOG_INTF_ATHR_WLAN_REG_REG_H_
-
-
-/* macros for RXRF_BIAS1 */
-#define PHY_ANALOG_RXRF_BIAS1_ADDRESS                                                                0x00000000
-#define PHY_ANALOG_RXRF_BIAS1_OFFSET                                                                 0x00000000
-#define PHY_ANALOG_RXRF_BIAS1_SPARE_MSB                                                                       0
-#define PHY_ANALOG_RXRF_BIAS1_SPARE_LSB                                                                       0
-#define PHY_ANALOG_RXRF_BIAS1_SPARE_MASK                                                             0x00000001
-#define PHY_ANALOG_RXRF_BIAS1_SPARE_GET(x)                                            (((x) & 0x00000001) >> 0)
-#define PHY_ANALOG_RXRF_BIAS1_SPARE_SET(x)                                            (((x) << 0) & 0x00000001)
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IR25SPARE_MSB                                                               3
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IR25SPARE_LSB                                                               1
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IR25SPARE_MASK                                                     0x0000000e
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IR25SPARE_GET(x)                                    (((x) & 0x0000000e) >> 1)
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IR25SPARE_SET(x)                                    (((x) << 1) & 0x0000000e)
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IR25LO18_MSB                                                                6
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IR25LO18_LSB                                                                4
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IR25LO18_MASK                                                      0x00000070
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IR25LO18_GET(x)                                     (((x) & 0x00000070) >> 4)
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IR25LO18_SET(x)                                     (((x) << 4) & 0x00000070)
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC25LO36_MSB                                                                9
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC25LO36_LSB                                                                7
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC25LO36_MASK                                                      0x00000380
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC25LO36_GET(x)                                     (((x) & 0x00000380) >> 7)
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC25LO36_SET(x)                                     (((x) << 7) & 0x00000380)
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC25MXR2_5GH_MSB                                                           12
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC25MXR2_5GH_LSB                                                           10
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC25MXR2_5GH_MASK                                                  0x00001c00
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC25MXR2_5GH_GET(x)                                (((x) & 0x00001c00) >> 10)
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC25MXR2_5GH_SET(x)                                (((x) << 10) & 0x00001c00)
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC25MXR5GH_MSB                                                             15
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC25MXR5GH_LSB                                                             13
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC25MXR5GH_MASK                                                    0x0000e000
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC25MXR5GH_GET(x)                                  (((x) & 0x0000e000) >> 13)
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC25MXR5GH_SET(x)                                  (((x) << 13) & 0x0000e000)
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC25VGA5G_MSB                                                              18
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC25VGA5G_LSB                                                              16
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC25VGA5G_MASK                                                     0x00070000
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC25VGA5G_GET(x)                                   (((x) & 0x00070000) >> 16)
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC25VGA5G_SET(x)                                   (((x) << 16) & 0x00070000)
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC75LNA5G_MSB                                                              21
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC75LNA5G_LSB                                                              19
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC75LNA5G_MASK                                                     0x00380000
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC75LNA5G_GET(x)                                   (((x) & 0x00380000) >> 19)
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC75LNA5G_SET(x)                                   (((x) << 19) & 0x00380000)
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IR25LO24_MSB                                                               24
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IR25LO24_LSB                                                               22
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IR25LO24_MASK                                                      0x01c00000
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IR25LO24_GET(x)                                    (((x) & 0x01c00000) >> 22)
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IR25LO24_SET(x)                                    (((x) << 22) & 0x01c00000)
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC25MXR2GH_MSB                                                             27
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC25MXR2GH_LSB                                                             25
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC25MXR2GH_MASK                                                    0x0e000000
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC25MXR2GH_GET(x)                                  (((x) & 0x0e000000) >> 25)
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC25MXR2GH_SET(x)                                  (((x) << 25) & 0x0e000000)
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC75LNA2G_MSB                                                              30
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC75LNA2G_LSB                                                              28
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC75LNA2G_MASK                                                     0x70000000
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC75LNA2G_GET(x)                                   (((x) & 0x70000000) >> 28)
-#define PHY_ANALOG_RXRF_BIAS1_PWD_IC75LNA2G_SET(x)                                   (((x) << 28) & 0x70000000)
-#define PHY_ANALOG_RXRF_BIAS1_PWD_BIAS_MSB                                                                   31
-#define PHY_ANALOG_RXRF_BIAS1_PWD_BIAS_LSB                                                                   31
-#define PHY_ANALOG_RXRF_BIAS1_PWD_BIAS_MASK                                                          0x80000000
-#define PHY_ANALOG_RXRF_BIAS1_PWD_BIAS_GET(x)                                        (((x) & 0x80000000) >> 31)
-#define PHY_ANALOG_RXRF_BIAS1_PWD_BIAS_SET(x)                                        (((x) << 31) & 0x80000000)
-
-/* macros for RXRF_BIAS2 */
-#define PHY_ANALOG_RXRF_BIAS2_ADDRESS                                                                0x00000004
-#define PHY_ANALOG_RXRF_BIAS2_OFFSET                                                                 0x00000004
-#define PHY_ANALOG_RXRF_BIAS2_SPARE_MSB                                                                       0
-#define PHY_ANALOG_RXRF_BIAS2_SPARE_LSB                                                                       0
-#define PHY_ANALOG_RXRF_BIAS2_SPARE_MASK                                                             0x00000001
-#define PHY_ANALOG_RXRF_BIAS2_SPARE_GET(x)                                            (((x) & 0x00000001) >> 0)
-#define PHY_ANALOG_RXRF_BIAS2_SPARE_SET(x)                                            (((x) << 0) & 0x00000001)
-#define PHY_ANALOG_RXRF_BIAS2_PKEN_MSB                                                                        3
-#define PHY_ANALOG_RXRF_BIAS2_PKEN_LSB                                                                        1
-#define PHY_ANALOG_RXRF_BIAS2_PKEN_MASK                                                              0x0000000e
-#define PHY_ANALOG_RXRF_BIAS2_PKEN_GET(x)                                             (((x) & 0x0000000e) >> 1)
-#define PHY_ANALOG_RXRF_BIAS2_PKEN_SET(x)                                             (((x) << 1) & 0x0000000e)
-#define PHY_ANALOG_RXRF_BIAS2_VCMVALUE_MSB                                                                    6
-#define PHY_ANALOG_RXRF_BIAS2_VCMVALUE_LSB                                                                    4
-#define PHY_ANALOG_RXRF_BIAS2_VCMVALUE_MASK                                                          0x00000070
-#define PHY_ANALOG_RXRF_BIAS2_VCMVALUE_GET(x)                                         (((x) & 0x00000070) >> 4)
-#define PHY_ANALOG_RXRF_BIAS2_VCMVALUE_SET(x)                                         (((x) << 4) & 0x00000070)
-#define PHY_ANALOG_RXRF_BIAS2_PWD_VCMBUF_MSB                                                                  7
-#define PHY_ANALOG_RXRF_BIAS2_PWD_VCMBUF_LSB                                                                  7
-#define PHY_ANALOG_RXRF_BIAS2_PWD_VCMBUF_MASK                                                        0x00000080
-#define PHY_ANALOG_RXRF_BIAS2_PWD_VCMBUF_GET(x)                                       (((x) & 0x00000080) >> 7)
-#define PHY_ANALOG_RXRF_BIAS2_PWD_VCMBUF_SET(x)                                       (((x) << 7) & 0x00000080)
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IR25SPAREH_MSB                                                             10
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IR25SPAREH_LSB                                                              8
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IR25SPAREH_MASK                                                    0x00000700
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IR25SPAREH_GET(x)                                   (((x) & 0x00000700) >> 8)
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IR25SPAREH_SET(x)                                   (((x) << 8) & 0x00000700)
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IR25SPARE_MSB                                                              13
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IR25SPARE_LSB                                                              11
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IR25SPARE_MASK                                                     0x00003800
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IR25SPARE_GET(x)                                   (((x) & 0x00003800) >> 11)
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IR25SPARE_SET(x)                                   (((x) << 11) & 0x00003800)
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IC25LNABUF_MSB                                                             16
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IC25LNABUF_LSB                                                             14
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IC25LNABUF_MASK                                                    0x0001c000
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IC25LNABUF_GET(x)                                  (((x) & 0x0001c000) >> 14)
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IC25LNABUF_SET(x)                                  (((x) << 14) & 0x0001c000)
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IR25AGCH_MSB                                                               19
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IR25AGCH_LSB                                                               17
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IR25AGCH_MASK                                                      0x000e0000
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IR25AGCH_GET(x)                                    (((x) & 0x000e0000) >> 17)
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IR25AGCH_SET(x)                                    (((x) << 17) & 0x000e0000)
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IR25AGC_MSB                                                                22
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IR25AGC_LSB                                                                20
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IR25AGC_MASK                                                       0x00700000
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IR25AGC_GET(x)                                     (((x) & 0x00700000) >> 20)
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IR25AGC_SET(x)                                     (((x) << 20) & 0x00700000)
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IC25AGC_MSB                                                                25
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IC25AGC_LSB                                                                23
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IC25AGC_MASK                                                       0x03800000
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IC25AGC_GET(x)                                     (((x) & 0x03800000) >> 23)
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IC25AGC_SET(x)                                     (((x) << 23) & 0x03800000)
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IC25VCMBUF_MSB                                                             28
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IC25VCMBUF_LSB                                                             26
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IC25VCMBUF_MASK                                                    0x1c000000
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IC25VCMBUF_GET(x)                                  (((x) & 0x1c000000) >> 26)
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IC25VCMBUF_SET(x)                                  (((x) << 26) & 0x1c000000)
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IR25VCM_MSB                                                                31
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IR25VCM_LSB                                                                29
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IR25VCM_MASK                                                       0xe0000000
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IR25VCM_GET(x)                                     (((x) & 0xe0000000) >> 29)
-#define PHY_ANALOG_RXRF_BIAS2_PWD_IR25VCM_SET(x)                                     (((x) << 29) & 0xe0000000)
-
-/* macros for RXRF_GAINSTAGES */
-#define PHY_ANALOG_RXRF_GAINSTAGES_ADDRESS                                                           0x00000008
-#define PHY_ANALOG_RXRF_GAINSTAGES_OFFSET                                                            0x00000008
-#define PHY_ANALOG_RXRF_GAINSTAGES_SPARE_MSB                                                                  0
-#define PHY_ANALOG_RXRF_GAINSTAGES_SPARE_LSB                                                                  0
-#define PHY_ANALOG_RXRF_GAINSTAGES_SPARE_MASK                                                        0x00000001
-#define PHY_ANALOG_RXRF_GAINSTAGES_SPARE_GET(x)                                       (((x) & 0x00000001) >> 0)
-#define PHY_ANALOG_RXRF_GAINSTAGES_SPARE_SET(x)                                       (((x) << 0) & 0x00000001)
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNAON_CALDC_MSB                                                            1
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNAON_CALDC_LSB                                                            1
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNAON_CALDC_MASK                                                  0x00000002
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNAON_CALDC_GET(x)                                 (((x) & 0x00000002) >> 1)
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNAON_CALDC_SET(x)                                 (((x) << 1) & 0x00000002)
-#define PHY_ANALOG_RXRF_GAINSTAGES_VGA5G_CAP_MSB                                                              3
-#define PHY_ANALOG_RXRF_GAINSTAGES_VGA5G_CAP_LSB                                                              2
-#define PHY_ANALOG_RXRF_GAINSTAGES_VGA5G_CAP_MASK                                                    0x0000000c
-#define PHY_ANALOG_RXRF_GAINSTAGES_VGA5G_CAP_GET(x)                                   (((x) & 0x0000000c) >> 2)
-#define PHY_ANALOG_RXRF_GAINSTAGES_VGA5G_CAP_SET(x)                                   (((x) << 2) & 0x0000000c)
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA5G_CAP_MSB                                                              5
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA5G_CAP_LSB                                                              4
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA5G_CAP_MASK                                                    0x00000030
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA5G_CAP_GET(x)                                   (((x) & 0x00000030) >> 4)
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA5G_CAP_SET(x)                                   (((x) << 4) & 0x00000030)
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA5G_SHORTINP_MSB                                                         6
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA5G_SHORTINP_LSB                                                         6
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA5G_SHORTINP_MASK                                               0x00000040
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA5G_SHORTINP_GET(x)                              (((x) & 0x00000040) >> 6)
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA5G_SHORTINP_SET(x)                              (((x) << 6) & 0x00000040)
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_LO5G_MSB                                                               7
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_LO5G_LSB                                                               7
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_LO5G_MASK                                                     0x00000080
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_LO5G_GET(x)                                    (((x) & 0x00000080) >> 7)
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_LO5G_SET(x)                                    (((x) << 7) & 0x00000080)
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_VGA5G_MSB                                                              8
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_VGA5G_LSB                                                              8
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_VGA5G_MASK                                                    0x00000100
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_VGA5G_GET(x)                                   (((x) & 0x00000100) >> 8)
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_VGA5G_SET(x)                                   (((x) << 8) & 0x00000100)
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_MXR5G_MSB                                                              9
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_MXR5G_LSB                                                              9
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_MXR5G_MASK                                                    0x00000200
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_MXR5G_GET(x)                                   (((x) & 0x00000200) >> 9)
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_MXR5G_SET(x)                                   (((x) << 9) & 0x00000200)
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_LNA5G_MSB                                                             10
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_LNA5G_LSB                                                             10
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_LNA5G_MASK                                                    0x00000400
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_LNA5G_GET(x)                                  (((x) & 0x00000400) >> 10)
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_LNA5G_SET(x)                                  (((x) << 10) & 0x00000400)
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA2G_CAP_MSB                                                             12
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA2G_CAP_LSB                                                             11
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA2G_CAP_MASK                                                    0x00001800
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA2G_CAP_GET(x)                                  (((x) & 0x00001800) >> 11)
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA2G_CAP_SET(x)                                  (((x) << 11) & 0x00001800)
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA2G_SHORTINP_MSB                                                        13
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA2G_SHORTINP_LSB                                                        13
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA2G_SHORTINP_MASK                                               0x00002000
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA2G_SHORTINP_GET(x)                             (((x) & 0x00002000) >> 13)
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA2G_SHORTINP_SET(x)                             (((x) << 13) & 0x00002000)
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA2G_LP_MSB                                                              14
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA2G_LP_LSB                                                              14
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA2G_LP_MASK                                                     0x00004000
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA2G_LP_GET(x)                                   (((x) & 0x00004000) >> 14)
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA2G_LP_SET(x)                                   (((x) << 14) & 0x00004000)
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_LO2G_MSB                                                              15
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_LO2G_LSB                                                              15
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_LO2G_MASK                                                     0x00008000
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_LO2G_GET(x)                                   (((x) & 0x00008000) >> 15)
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_LO2G_SET(x)                                   (((x) << 15) & 0x00008000)
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_MXR2G_MSB                                                             16
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_MXR2G_LSB                                                             16
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_MXR2G_MASK                                                    0x00010000
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_MXR2G_GET(x)                                  (((x) & 0x00010000) >> 16)
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_MXR2G_SET(x)                                  (((x) << 16) & 0x00010000)
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_LNA2G_MSB                                                             17
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_LNA2G_LSB                                                             17
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_LNA2G_MASK                                                    0x00020000
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_LNA2G_GET(x)                                  (((x) & 0x00020000) >> 17)
-#define PHY_ANALOG_RXRF_GAINSTAGES_PWD_LNA2G_SET(x)                                  (((x) << 17) & 0x00020000)
-#define PHY_ANALOG_RXRF_GAINSTAGES_MXR5G_GAIN_OVR_MSB                                                        19
-#define PHY_ANALOG_RXRF_GAINSTAGES_MXR5G_GAIN_OVR_LSB                                                        18
-#define PHY_ANALOG_RXRF_GAINSTAGES_MXR5G_GAIN_OVR_MASK                                               0x000c0000
-#define PHY_ANALOG_RXRF_GAINSTAGES_MXR5G_GAIN_OVR_GET(x)                             (((x) & 0x000c0000) >> 18)
-#define PHY_ANALOG_RXRF_GAINSTAGES_MXR5G_GAIN_OVR_SET(x)                             (((x) << 18) & 0x000c0000)
-#define PHY_ANALOG_RXRF_GAINSTAGES_VGA5G_GAIN_OVR_MSB                                                        22
-#define PHY_ANALOG_RXRF_GAINSTAGES_VGA5G_GAIN_OVR_LSB                                                        20
-#define PHY_ANALOG_RXRF_GAINSTAGES_VGA5G_GAIN_OVR_MASK                                               0x00700000
-#define PHY_ANALOG_RXRF_GAINSTAGES_VGA5G_GAIN_OVR_GET(x)                             (((x) & 0x00700000) >> 20)
-#define PHY_ANALOG_RXRF_GAINSTAGES_VGA5G_GAIN_OVR_SET(x)                             (((x) << 20) & 0x00700000)
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA5G_GAIN_OVR_MSB                                                        25
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA5G_GAIN_OVR_LSB                                                        23
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA5G_GAIN_OVR_MASK                                               0x03800000
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA5G_GAIN_OVR_GET(x)                             (((x) & 0x03800000) >> 23)
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA5G_GAIN_OVR_SET(x)                             (((x) << 23) & 0x03800000)
-#define PHY_ANALOG_RXRF_GAINSTAGES_MXR2G_GAIN_OVR_MSB                                                        27
-#define PHY_ANALOG_RXRF_GAINSTAGES_MXR2G_GAIN_OVR_LSB                                                        26
-#define PHY_ANALOG_RXRF_GAINSTAGES_MXR2G_GAIN_OVR_MASK                                               0x0c000000
-#define PHY_ANALOG_RXRF_GAINSTAGES_MXR2G_GAIN_OVR_GET(x)                             (((x) & 0x0c000000) >> 26)
-#define PHY_ANALOG_RXRF_GAINSTAGES_MXR2G_GAIN_OVR_SET(x)                             (((x) << 26) & 0x0c000000)
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA2G_GAIN_OVR_MSB                                                        30
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA2G_GAIN_OVR_LSB                                                        28
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA2G_GAIN_OVR_MASK                                               0x70000000
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA2G_GAIN_OVR_GET(x)                             (((x) & 0x70000000) >> 28)
-#define PHY_ANALOG_RXRF_GAINSTAGES_LNA2G_GAIN_OVR_SET(x)                             (((x) << 28) & 0x70000000)
-#define PHY_ANALOG_RXRF_GAINSTAGES_RX_OVERRIDE_MSB                                                           31
-#define PHY_ANALOG_RXRF_GAINSTAGES_RX_OVERRIDE_LSB                                                           31
-#define PHY_ANALOG_RXRF_GAINSTAGES_RX_OVERRIDE_MASK                                                  0x80000000
-#define PHY_ANALOG_RXRF_GAINSTAGES_RX_OVERRIDE_GET(x)                                (((x) & 0x80000000) >> 31)
-#define PHY_ANALOG_RXRF_GAINSTAGES_RX_OVERRIDE_SET(x)                                (((x) << 31) & 0x80000000)
-
-/* macros for RXRF_AGC */
-#define PHY_ANALOG_RXRF_AGC_ADDRESS                                                                  0x0000000c
-#define PHY_ANALOG_RXRF_AGC_OFFSET                                                                   0x0000000c
-#define PHY_ANALOG_RXRF_AGC_RF5G_ON_DURING_CALPA_MSB                                                          0
-#define PHY_ANALOG_RXRF_AGC_RF5G_ON_DURING_CALPA_LSB                                                          0
-#define PHY_ANALOG_RXRF_AGC_RF5G_ON_DURING_CALPA_MASK                                                0x00000001
-#define PHY_ANALOG_RXRF_AGC_RF5G_ON_DURING_CALPA_GET(x)                               (((x) & 0x00000001) >> 0)
-#define PHY_ANALOG_RXRF_AGC_RF5G_ON_DURING_CALPA_SET(x)                               (((x) << 0) & 0x00000001)
-#define PHY_ANALOG_RXRF_AGC_RF2G_ON_DURING_CALPA_MSB                                                          1
-#define PHY_ANALOG_RXRF_AGC_RF2G_ON_DURING_CALPA_LSB                                                          1
-#define PHY_ANALOG_RXRF_AGC_RF2G_ON_DURING_CALPA_MASK                                                0x00000002
-#define PHY_ANALOG_RXRF_AGC_RF2G_ON_DURING_CALPA_GET(x)                               (((x) & 0x00000002) >> 1)
-#define PHY_ANALOG_RXRF_AGC_RF2G_ON_DURING_CALPA_SET(x)                               (((x) << 1) & 0x00000002)
-#define PHY_ANALOG_RXRF_AGC_AGC_OUT_MSB                                                                       2
-#define PHY_ANALOG_RXRF_AGC_AGC_OUT_LSB                                                                       2
-#define PHY_ANALOG_RXRF_AGC_AGC_OUT_MASK                                                             0x00000004
-#define PHY_ANALOG_RXRF_AGC_AGC_OUT_GET(x)                                            (((x) & 0x00000004) >> 2)
-#define PHY_ANALOG_RXRF_AGC_LNABUFGAIN2X_MSB                                                                  3
-#define PHY_ANALOG_RXRF_AGC_LNABUFGAIN2X_LSB                                                                  3
-#define PHY_ANALOG_RXRF_AGC_LNABUFGAIN2X_MASK                                                        0x00000008
-#define PHY_ANALOG_RXRF_AGC_LNABUFGAIN2X_GET(x)                                       (((x) & 0x00000008) >> 3)
-#define PHY_ANALOG_RXRF_AGC_LNABUFGAIN2X_SET(x)                                       (((x) << 3) & 0x00000008)
-#define PHY_ANALOG_RXRF_AGC_LNABUF_PWD_OVR_MSB                                                                4
-#define PHY_ANALOG_RXRF_AGC_LNABUF_PWD_OVR_LSB                                                                4
-#define PHY_ANALOG_RXRF_AGC_LNABUF_PWD_OVR_MASK                                                      0x00000010
-#define PHY_ANALOG_RXRF_AGC_LNABUF_PWD_OVR_GET(x)                                     (((x) & 0x00000010) >> 4)
-#define PHY_ANALOG_RXRF_AGC_LNABUF_PWD_OVR_SET(x)                                     (((x) << 4) & 0x00000010)
-#define PHY_ANALOG_RXRF_AGC_PWD_LNABUF_MSB                                                                    5
-#define PHY_ANALOG_RXRF_AGC_PWD_LNABUF_LSB                                                                    5
-#define PHY_ANALOG_RXRF_AGC_PWD_LNABUF_MASK                                                          0x00000020
-#define PHY_ANALOG_RXRF_AGC_PWD_LNABUF_GET(x)                                         (((x) & 0x00000020) >> 5)
-#define PHY_ANALOG_RXRF_AGC_PWD_LNABUF_SET(x)                                         (((x) << 5) & 0x00000020)
-#define PHY_ANALOG_RXRF_AGC_AGC_FALL_CTRL_MSB                                                                 8
-#define PHY_ANALOG_RXRF_AGC_AGC_FALL_CTRL_LSB                                                                 6
-#define PHY_ANALOG_RXRF_AGC_AGC_FALL_CTRL_MASK                                                       0x000001c0
-#define PHY_ANALOG_RXRF_AGC_AGC_FALL_CTRL_GET(x)                                      (((x) & 0x000001c0) >> 6)
-#define PHY_ANALOG_RXRF_AGC_AGC_FALL_CTRL_SET(x)                                      (((x) << 6) & 0x000001c0)
-#define PHY_ANALOG_RXRF_AGC_AGC5G_CALDAC_OVR_MSB                                                             14
-#define PHY_ANALOG_RXRF_AGC_AGC5G_CALDAC_OVR_LSB                                                              9
-#define PHY_ANALOG_RXRF_AGC_AGC5G_CALDAC_OVR_MASK                                                    0x00007e00
-#define PHY_ANALOG_RXRF_AGC_AGC5G_CALDAC_OVR_GET(x)                                   (((x) & 0x00007e00) >> 9)
-#define PHY_ANALOG_RXRF_AGC_AGC5G_CALDAC_OVR_SET(x)                                   (((x) << 9) & 0x00007e00)
-#define PHY_ANALOG_RXRF_AGC_AGC5G_DBDAC_OVR_MSB                                                              18
-#define PHY_ANALOG_RXRF_AGC_AGC5G_DBDAC_OVR_LSB                                                              15
-#define PHY_ANALOG_RXRF_AGC_AGC5G_DBDAC_OVR_MASK                                                     0x00078000
-#define PHY_ANALOG_RXRF_AGC_AGC5G_DBDAC_OVR_GET(x)                                   (((x) & 0x00078000) >> 15)
-#define PHY_ANALOG_RXRF_AGC_AGC5G_DBDAC_OVR_SET(x)                                   (((x) << 15) & 0x00078000)
-#define PHY_ANALOG_RXRF_AGC_AGC2G_CALDAC_OVR_MSB                                                             24
-#define PHY_ANALOG_RXRF_AGC_AGC2G_CALDAC_OVR_LSB                                                             19
-#define PHY_ANALOG_RXRF_AGC_AGC2G_CALDAC_OVR_MASK                                                    0x01f80000
-#define PHY_ANALOG_RXRF_AGC_AGC2G_CALDAC_OVR_GET(x)                                  (((x) & 0x01f80000) >> 19)
-#define PHY_ANALOG_RXRF_AGC_AGC2G_CALDAC_OVR_SET(x)                                  (((x) << 19) & 0x01f80000)
-#define PHY_ANALOG_RXRF_AGC_AGC2G_DBDAC_OVR_MSB                                                              28
-#define PHY_ANALOG_RXRF_AGC_AGC2G_DBDAC_OVR_LSB                                                              25
-#define PHY_ANALOG_RXRF_AGC_AGC2G_DBDAC_OVR_MASK                                                     0x1e000000
-#define PHY_ANALOG_RXRF_AGC_AGC2G_DBDAC_OVR_GET(x)                                   (((x) & 0x1e000000) >> 25)
-#define PHY_ANALOG_RXRF_AGC_AGC2G_DBDAC_OVR_SET(x)                                   (((x) << 25) & 0x1e000000)
-#define PHY_ANALOG_RXRF_AGC_AGC_CAL_OVR_MSB                                                                  29
-#define PHY_ANALOG_RXRF_AGC_AGC_CAL_OVR_LSB                                                                  29
-#define PHY_ANALOG_RXRF_AGC_AGC_CAL_OVR_MASK                                                         0x20000000
-#define PHY_ANALOG_RXRF_AGC_AGC_CAL_OVR_GET(x)                                       (((x) & 0x20000000) >> 29)
-#define PHY_ANALOG_RXRF_AGC_AGC_CAL_OVR_SET(x)                                       (((x) << 29) & 0x20000000)
-#define PHY_ANALOG_RXRF_AGC_AGC_ON_OVR_MSB                                                                   30
-#define PHY_ANALOG_RXRF_AGC_AGC_ON_OVR_LSB                                                                   30
-#define PHY_ANALOG_RXRF_AGC_AGC_ON_OVR_MASK                                                          0x40000000
-#define PHY_ANALOG_RXRF_AGC_AGC_ON_OVR_GET(x)                                        (((x) & 0x40000000) >> 30)
-#define PHY_ANALOG_RXRF_AGC_AGC_ON_OVR_SET(x)                                        (((x) << 30) & 0x40000000)
-#define PHY_ANALOG_RXRF_AGC_AGC_OVERRIDE_MSB                                                                 31
-#define PHY_ANALOG_RXRF_AGC_AGC_OVERRIDE_LSB                                                                 31
-#define PHY_ANALOG_RXRF_AGC_AGC_OVERRIDE_MASK                                                        0x80000000
-#define PHY_ANALOG_RXRF_AGC_AGC_OVERRIDE_GET(x)                                      (((x) & 0x80000000) >> 31)
-#define PHY_ANALOG_RXRF_AGC_AGC_OVERRIDE_SET(x)                                      (((x) << 31) & 0x80000000)
-
-/* macros for TXRF1 */
-#define PHY_ANALOG_TXRF1_ADDRESS                                                                     0x00000040
-#define PHY_ANALOG_TXRF1_OFFSET                                                                      0x00000040
-#define PHY_ANALOG_TXRF1_PDLOBUF5G_MSB                                                                        0
-#define PHY_ANALOG_TXRF1_PDLOBUF5G_LSB                                                                        0
-#define PHY_ANALOG_TXRF1_PDLOBUF5G_MASK                                                              0x00000001
-#define PHY_ANALOG_TXRF1_PDLOBUF5G_GET(x)                                             (((x) & 0x00000001) >> 0)
-#define PHY_ANALOG_TXRF1_PDLOBUF5G_SET(x)                                             (((x) << 0) & 0x00000001)
-#define PHY_ANALOG_TXRF1_PDLODIV5G_MSB                                                                        1
-#define PHY_ANALOG_TXRF1_PDLODIV5G_LSB                                                                        1
-#define PHY_ANALOG_TXRF1_PDLODIV5G_MASK                                                              0x00000002
-#define PHY_ANALOG_TXRF1_PDLODIV5G_GET(x)                                             (((x) & 0x00000002) >> 1)
-#define PHY_ANALOG_TXRF1_PDLODIV5G_SET(x)                                             (((x) << 1) & 0x00000002)
-#define PHY_ANALOG_TXRF1_LOBUF5GFORCED_MSB                                                                    2
-#define PHY_ANALOG_TXRF1_LOBUF5GFORCED_LSB                                                                    2
-#define PHY_ANALOG_TXRF1_LOBUF5GFORCED_MASK                                                          0x00000004
-#define PHY_ANALOG_TXRF1_LOBUF5GFORCED_GET(x)                                         (((x) & 0x00000004) >> 2)
-#define PHY_ANALOG_TXRF1_LOBUF5GFORCED_SET(x)                                         (((x) << 2) & 0x00000004)
-#define PHY_ANALOG_TXRF1_LODIV5GFORCED_MSB                                                                    3
-#define PHY_ANALOG_TXRF1_LODIV5GFORCED_LSB                                                                    3
-#define PHY_ANALOG_TXRF1_LODIV5GFORCED_MASK                                                          0x00000008
-#define PHY_ANALOG_TXRF1_LODIV5GFORCED_GET(x)                                         (((x) & 0x00000008) >> 3)
-#define PHY_ANALOG_TXRF1_LODIV5GFORCED_SET(x)                                         (((x) << 3) & 0x00000008)
-#define PHY_ANALOG_TXRF1_PADRV2GN5G_MSB                                                                       7
-#define PHY_ANALOG_TXRF1_PADRV2GN5G_LSB                                                                       4
-#define PHY_ANALOG_TXRF1_PADRV2GN5G_MASK                                                             0x000000f0
-#define PHY_ANALOG_TXRF1_PADRV2GN5G_GET(x)                                            (((x) & 0x000000f0) >> 4)
-#define PHY_ANALOG_TXRF1_PADRV2GN5G_SET(x)                                            (((x) << 4) & 0x000000f0)
-#define PHY_ANALOG_TXRF1_PADRV3GN5G_MSB                                                                      11
-#define PHY_ANALOG_TXRF1_PADRV3GN5G_LSB                                                                       8
-#define PHY_ANALOG_TXRF1_PADRV3GN5G_MASK                                                             0x00000f00
-#define PHY_ANALOG_TXRF1_PADRV3GN5G_GET(x)                                            (((x) & 0x00000f00) >> 8)
-#define PHY_ANALOG_TXRF1_PADRV3GN5G_SET(x)                                            (((x) << 8) & 0x00000f00)
-#define PHY_ANALOG_TXRF1_PADRV4GN5G_MSB                                                                      15
-#define PHY_ANALOG_TXRF1_PADRV4GN5G_LSB                                                                      12
-#define PHY_ANALOG_TXRF1_PADRV4GN5G_MASK                                                             0x0000f000
-#define PHY_ANALOG_TXRF1_PADRV4GN5G_GET(x)                                           (((x) & 0x0000f000) >> 12)
-#define PHY_ANALOG_TXRF1_PADRV4GN5G_SET(x)                                           (((x) << 12) & 0x0000f000)
-#define PHY_ANALOG_TXRF1_LOCALTXGAIN5G_MSB                                                                   16
-#define PHY_ANALOG_TXRF1_LOCALTXGAIN5G_LSB                                                                   16
-#define PHY_ANALOG_TXRF1_LOCALTXGAIN5G_MASK                                                          0x00010000
-#define PHY_ANALOG_TXRF1_LOCALTXGAIN5G_GET(x)                                        (((x) & 0x00010000) >> 16)
-#define PHY_ANALOG_TXRF1_LOCALTXGAIN5G_SET(x)                                        (((x) << 16) & 0x00010000)
-#define PHY_ANALOG_TXRF1_PDOUT2G_MSB                                                                         17
-#define PHY_ANALOG_TXRF1_PDOUT2G_LSB                                                                         17
-#define PHY_ANALOG_TXRF1_PDOUT2G_MASK                                                                0x00020000
-#define PHY_ANALOG_TXRF1_PDOUT2G_GET(x)                                              (((x) & 0x00020000) >> 17)
-#define PHY_ANALOG_TXRF1_PDOUT2G_SET(x)                                              (((x) << 17) & 0x00020000)
-#define PHY_ANALOG_TXRF1_PDDR2G_MSB                                                                          18
-#define PHY_ANALOG_TXRF1_PDDR2G_LSB                                                                          18
-#define PHY_ANALOG_TXRF1_PDDR2G_MASK                                                                 0x00040000
-#define PHY_ANALOG_TXRF1_PDDR2G_GET(x)                                               (((x) & 0x00040000) >> 18)
-#define PHY_ANALOG_TXRF1_PDDR2G_SET(x)                                               (((x) << 18) & 0x00040000)
-#define PHY_ANALOG_TXRF1_PDMXR2G_MSB                                                                         19
-#define PHY_ANALOG_TXRF1_PDMXR2G_LSB                                                                         19
-#define PHY_ANALOG_TXRF1_PDMXR2G_MASK                                                                0x00080000
-#define PHY_ANALOG_TXRF1_PDMXR2G_GET(x)                                              (((x) & 0x00080000) >> 19)
-#define PHY_ANALOG_TXRF1_PDMXR2G_SET(x)                                              (((x) << 19) & 0x00080000)
-#define PHY_ANALOG_TXRF1_PDLOBUF2G_MSB                                                                       20
-#define PHY_ANALOG_TXRF1_PDLOBUF2G_LSB                                                                       20
-#define PHY_ANALOG_TXRF1_PDLOBUF2G_MASK                                                              0x00100000
-#define PHY_ANALOG_TXRF1_PDLOBUF2G_GET(x)                                            (((x) & 0x00100000) >> 20)
-#define PHY_ANALOG_TXRF1_PDLOBUF2G_SET(x)                                            (((x) << 20) & 0x00100000)
-#define PHY_ANALOG_TXRF1_PDLODIV2G_MSB                                                                       21
-#define PHY_ANALOG_TXRF1_PDLODIV2G_LSB                                                                       21
-#define PHY_ANALOG_TXRF1_PDLODIV2G_MASK                                                              0x00200000
-#define PHY_ANALOG_TXRF1_PDLODIV2G_GET(x)                                            (((x) & 0x00200000) >> 21)
-#define PHY_ANALOG_TXRF1_PDLODIV2G_SET(x)                                            (((x) << 21) & 0x00200000)
-#define PHY_ANALOG_TXRF1_LOBUF2GFORCED_MSB                                                                   22
-#define PHY_ANALOG_TXRF1_LOBUF2GFORCED_LSB                                                                   22
-#define PHY_ANALOG_TXRF1_LOBUF2GFORCED_MASK                                                          0x00400000
-#define PHY_ANALOG_TXRF1_LOBUF2GFORCED_GET(x)                                        (((x) & 0x00400000) >> 22)
-#define PHY_ANALOG_TXRF1_LOBUF2GFORCED_SET(x)                                        (((x) << 22) & 0x00400000)
-#define PHY_ANALOG_TXRF1_LODIV2GFORCED_MSB                                                                   23
-#define PHY_ANALOG_TXRF1_LODIV2GFORCED_LSB                                                                   23
-#define PHY_ANALOG_TXRF1_LODIV2GFORCED_MASK                                                          0x00800000
-#define PHY_ANALOG_TXRF1_LODIV2GFORCED_GET(x)                                        (((x) & 0x00800000) >> 23)
-#define PHY_ANALOG_TXRF1_LODIV2GFORCED_SET(x)                                        (((x) << 23) & 0x00800000)
-#define PHY_ANALOG_TXRF1_PADRVGN2G_MSB                                                                       30
-#define PHY_ANALOG_TXRF1_PADRVGN2G_LSB                                                                       24
-#define PHY_ANALOG_TXRF1_PADRVGN2G_MASK                                                              0x7f000000
-#define PHY_ANALOG_TXRF1_PADRVGN2G_GET(x)                                            (((x) & 0x7f000000) >> 24)
-#define PHY_ANALOG_TXRF1_PADRVGN2G_SET(x)                                            (((x) << 24) & 0x7f000000)
-#define PHY_ANALOG_TXRF1_LOCALTXGAIN2G_MSB                                                                   31
-#define PHY_ANALOG_TXRF1_LOCALTXGAIN2G_LSB                                                                   31
-#define PHY_ANALOG_TXRF1_LOCALTXGAIN2G_MASK                                                          0x80000000
-#define PHY_ANALOG_TXRF1_LOCALTXGAIN2G_GET(x)                                        (((x) & 0x80000000) >> 31)
-#define PHY_ANALOG_TXRF1_LOCALTXGAIN2G_SET(x)                                        (((x) << 31) & 0x80000000)
-
-/* macros for TXRF2 */
-#define PHY_ANALOG_TXRF2_ADDRESS                                                                     0x00000044
-#define PHY_ANALOG_TXRF2_OFFSET                                                                      0x00000044
-#define PHY_ANALOG_TXRF2_D3B5G_MSB                                                                            2
-#define PHY_ANALOG_TXRF2_D3B5G_LSB                                                                            0
-#define PHY_ANALOG_TXRF2_D3B5G_MASK                                                                  0x00000007
-#define PHY_ANALOG_TXRF2_D3B5G_GET(x)                                                 (((x) & 0x00000007) >> 0)
-#define PHY_ANALOG_TXRF2_D3B5G_SET(x)                                                 (((x) << 0) & 0x00000007)
-#define PHY_ANALOG_TXRF2_D4B5G_MSB                                                                            5
-#define PHY_ANALOG_TXRF2_D4B5G_LSB                                                                            3
-#define PHY_ANALOG_TXRF2_D4B5G_MASK                                                                  0x00000038
-#define PHY_ANALOG_TXRF2_D4B5G_GET(x)                                                 (((x) & 0x00000038) >> 3)
-#define PHY_ANALOG_TXRF2_D4B5G_SET(x)                                                 (((x) << 3) & 0x00000038)
-#define PHY_ANALOG_TXRF2_OCAS2G_MSB                                                                           8
-#define PHY_ANALOG_TXRF2_OCAS2G_LSB                                                                           6
-#define PHY_ANALOG_TXRF2_OCAS2G_MASK                                                                 0x000001c0
-#define PHY_ANALOG_TXRF2_OCAS2G_GET(x)                                                (((x) & 0x000001c0) >> 6)
-#define PHY_ANALOG_TXRF2_OCAS2G_SET(x)                                                (((x) << 6) & 0x000001c0)
-#define PHY_ANALOG_TXRF2_DCAS2G_MSB                                                                          11
-#define PHY_ANALOG_TXRF2_DCAS2G_LSB                                                                           9
-#define PHY_ANALOG_TXRF2_DCAS2G_MASK                                                                 0x00000e00
-#define PHY_ANALOG_TXRF2_DCAS2G_GET(x)                                                (((x) & 0x00000e00) >> 9)
-#define PHY_ANALOG_TXRF2_DCAS2G_SET(x)                                                (((x) << 9) & 0x00000e00)
-#define PHY_ANALOG_TXRF2_OB2G_PALOFF_MSB                                                                     14
-#define PHY_ANALOG_TXRF2_OB2G_PALOFF_LSB                                                                     12
-#define PHY_ANALOG_TXRF2_OB2G_PALOFF_MASK                                                            0x00007000
-#define PHY_ANALOG_TXRF2_OB2G_PALOFF_GET(x)                                          (((x) & 0x00007000) >> 12)
-#define PHY_ANALOG_TXRF2_OB2G_PALOFF_SET(x)                                          (((x) << 12) & 0x00007000)
-#define PHY_ANALOG_TXRF2_OB2G_QAM_MSB                                                                        17
-#define PHY_ANALOG_TXRF2_OB2G_QAM_LSB                                                                        15
-#define PHY_ANALOG_TXRF2_OB2G_QAM_MASK                                                               0x00038000
-#define PHY_ANALOG_TXRF2_OB2G_QAM_GET(x)                                             (((x) & 0x00038000) >> 15)
-#define PHY_ANALOG_TXRF2_OB2G_QAM_SET(x)                                             (((x) << 15) & 0x00038000)
-#define PHY_ANALOG_TXRF2_OB2G_PSK_MSB                                                                        20
-#define PHY_ANALOG_TXRF2_OB2G_PSK_LSB                                                                        18
-#define PHY_ANALOG_TXRF2_OB2G_PSK_MASK                                                               0x001c0000
-#define PHY_ANALOG_TXRF2_OB2G_PSK_GET(x)                                             (((x) & 0x001c0000) >> 18)
-#define PHY_ANALOG_TXRF2_OB2G_PSK_SET(x)                                             (((x) << 18) & 0x001c0000)
-#define PHY_ANALOG_TXRF2_OB2G_CCK_MSB                                                                        23
-#define PHY_ANALOG_TXRF2_OB2G_CCK_LSB                                                                        21
-#define PHY_ANALOG_TXRF2_OB2G_CCK_MASK                                                               0x00e00000
-#define PHY_ANALOG_TXRF2_OB2G_CCK_GET(x)                                             (((x) & 0x00e00000) >> 21)
-#define PHY_ANALOG_TXRF2_OB2G_CCK_SET(x)                                             (((x) << 21) & 0x00e00000)
-#define PHY_ANALOG_TXRF2_DB2G_MSB                                                                            26
-#define PHY_ANALOG_TXRF2_DB2G_LSB                                                                            24
-#define PHY_ANALOG_TXRF2_DB2G_MASK                                                                   0x07000000
-#define PHY_ANALOG_TXRF2_DB2G_GET(x)                                                 (((x) & 0x07000000) >> 24)
-#define PHY_ANALOG_TXRF2_DB2G_SET(x)                                                 (((x) << 24) & 0x07000000)
-#define PHY_ANALOG_TXRF2_PDOUT5G_MSB                                                                         30
-#define PHY_ANALOG_TXRF2_PDOUT5G_LSB                                                                         27
-#define PHY_ANALOG_TXRF2_PDOUT5G_MASK                                                                0x78000000
-#define PHY_ANALOG_TXRF2_PDOUT5G_GET(x)                                              (((x) & 0x78000000) >> 27)
-#define PHY_ANALOG_TXRF2_PDOUT5G_SET(x)                                              (((x) << 27) & 0x78000000)
-#define PHY_ANALOG_TXRF2_PDMXR5G_MSB                                                                         31
-#define PHY_ANALOG_TXRF2_PDMXR5G_LSB                                                                         31
-#define PHY_ANALOG_TXRF2_PDMXR5G_MASK                                                                0x80000000
-#define PHY_ANALOG_TXRF2_PDMXR5G_GET(x)                                              (((x) & 0x80000000) >> 31)
-#define PHY_ANALOG_TXRF2_PDMXR5G_SET(x)                                              (((x) << 31) & 0x80000000)
-
-/* macros for TXRF3 */
-#define PHY_ANALOG_TXRF3_ADDRESS                                                                     0x00000048
-#define PHY_ANALOG_TXRF3_OFFSET                                                                      0x00000048
-#define PHY_ANALOG_TXRF3_FILTR2G_MSB                                                                          1
-#define PHY_ANALOG_TXRF3_FILTR2G_LSB                                                                          0
-#define PHY_ANALOG_TXRF3_FILTR2G_MASK                                                                0x00000003
-#define PHY_ANALOG_TXRF3_FILTR2G_GET(x)                                               (((x) & 0x00000003) >> 0)
-#define PHY_ANALOG_TXRF3_FILTR2G_SET(x)                                               (((x) << 0) & 0x00000003)
-#define PHY_ANALOG_TXRF3_PWDFB2_2G_MSB                                                                        2
-#define PHY_ANALOG_TXRF3_PWDFB2_2G_LSB                                                                        2
-#define PHY_ANALOG_TXRF3_PWDFB2_2G_MASK                                                              0x00000004
-#define PHY_ANALOG_TXRF3_PWDFB2_2G_GET(x)                                             (((x) & 0x00000004) >> 2)
-#define PHY_ANALOG_TXRF3_PWDFB2_2G_SET(x)                                             (((x) << 2) & 0x00000004)
-#define PHY_ANALOG_TXRF3_PWDFB1_2G_MSB                                                                        3
-#define PHY_ANALOG_TXRF3_PWDFB1_2G_LSB                                                                        3
-#define PHY_ANALOG_TXRF3_PWDFB1_2G_MASK                                                              0x00000008
-#define PHY_ANALOG_TXRF3_PWDFB1_2G_GET(x)                                             (((x) & 0x00000008) >> 3)
-#define PHY_ANALOG_TXRF3_PWDFB1_2G_SET(x)                                             (((x) << 3) & 0x00000008)
-#define PHY_ANALOG_TXRF3_PDFB2G_MSB                                                                           4
-#define PHY_ANALOG_TXRF3_PDFB2G_LSB                                                                           4
-#define PHY_ANALOG_TXRF3_PDFB2G_MASK                                                                 0x00000010
-#define PHY_ANALOG_TXRF3_PDFB2G_GET(x)                                                (((x) & 0x00000010) >> 4)
-#define PHY_ANALOG_TXRF3_PDFB2G_SET(x)                                                (((x) << 4) & 0x00000010)
-#define PHY_ANALOG_TXRF3_RDIV5G_MSB                                                                           6
-#define PHY_ANALOG_TXRF3_RDIV5G_LSB                                                                           5
-#define PHY_ANALOG_TXRF3_RDIV5G_MASK                                                                 0x00000060
-#define PHY_ANALOG_TXRF3_RDIV5G_GET(x)                                                (((x) & 0x00000060) >> 5)
-#define PHY_ANALOG_TXRF3_RDIV5G_SET(x)                                                (((x) << 5) & 0x00000060)
-#define PHY_ANALOG_TXRF3_CAPDIV5G_MSB                                                                         9
-#define PHY_ANALOG_TXRF3_CAPDIV5G_LSB                                                                         7
-#define PHY_ANALOG_TXRF3_CAPDIV5G_MASK                                                               0x00000380
-#define PHY_ANALOG_TXRF3_CAPDIV5G_GET(x)                                              (((x) & 0x00000380) >> 7)
-#define PHY_ANALOG_TXRF3_CAPDIV5G_SET(x)                                              (((x) << 7) & 0x00000380)
-#define PHY_ANALOG_TXRF3_PDPREDIST5G_MSB                                                                     10
-#define PHY_ANALOG_TXRF3_PDPREDIST5G_LSB                                                                     10
-#define PHY_ANALOG_TXRF3_PDPREDIST5G_MASK                                                            0x00000400
-#define PHY_ANALOG_TXRF3_PDPREDIST5G_GET(x)                                          (((x) & 0x00000400) >> 10)
-#define PHY_ANALOG_TXRF3_PDPREDIST5G_SET(x)                                          (((x) << 10) & 0x00000400)
-#define PHY_ANALOG_TXRF3_RDIV2G_MSB                                                                          12
-#define PHY_ANALOG_TXRF3_RDIV2G_LSB                                                                          11
-#define PHY_ANALOG_TXRF3_RDIV2G_MASK                                                                 0x00001800
-#define PHY_ANALOG_TXRF3_RDIV2G_GET(x)                                               (((x) & 0x00001800) >> 11)
-#define PHY_ANALOG_TXRF3_RDIV2G_SET(x)                                               (((x) << 11) & 0x00001800)
-#define PHY_ANALOG_TXRF3_PDPREDIST2G_MSB                                                                     13
-#define PHY_ANALOG_TXRF3_PDPREDIST2G_LSB                                                                     13
-#define PHY_ANALOG_TXRF3_PDPREDIST2G_MASK                                                            0x00002000
-#define PHY_ANALOG_TXRF3_PDPREDIST2G_GET(x)                                          (((x) & 0x00002000) >> 13)
-#define PHY_ANALOG_TXRF3_PDPREDIST2G_SET(x)                                          (((x) << 13) & 0x00002000)
-#define PHY_ANALOG_TXRF3_OCAS5G_MSB                                                                          16
-#define PHY_ANALOG_TXRF3_OCAS5G_LSB                                                                          14
-#define PHY_ANALOG_TXRF3_OCAS5G_MASK                                                                 0x0001c000
-#define PHY_ANALOG_TXRF3_OCAS5G_GET(x)                                               (((x) & 0x0001c000) >> 14)
-#define PHY_ANALOG_TXRF3_OCAS5G_SET(x)                                               (((x) << 14) & 0x0001c000)
-#define PHY_ANALOG_TXRF3_D2CAS5G_MSB                                                                         19
-#define PHY_ANALOG_TXRF3_D2CAS5G_LSB                                                                         17
-#define PHY_ANALOG_TXRF3_D2CAS5G_MASK                                                                0x000e0000
-#define PHY_ANALOG_TXRF3_D2CAS5G_GET(x)                                              (((x) & 0x000e0000) >> 17)
-#define PHY_ANALOG_TXRF3_D2CAS5G_SET(x)                                              (((x) << 17) & 0x000e0000)
-#define PHY_ANALOG_TXRF3_D3CAS5G_MSB                                                                         22
-#define PHY_ANALOG_TXRF3_D3CAS5G_LSB                                                                         20
-#define PHY_ANALOG_TXRF3_D3CAS5G_MASK                                                                0x00700000
-#define PHY_ANALOG_TXRF3_D3CAS5G_GET(x)                                              (((x) & 0x00700000) >> 20)
-#define PHY_ANALOG_TXRF3_D3CAS5G_SET(x)                                              (((x) << 20) & 0x00700000)
-#define PHY_ANALOG_TXRF3_D4CAS5G_MSB                                                                         25
-#define PHY_ANALOG_TXRF3_D4CAS5G_LSB                                                                         23
-#define PHY_ANALOG_TXRF3_D4CAS5G_MASK                                                                0x03800000
-#define PHY_ANALOG_TXRF3_D4CAS5G_GET(x)                                              (((x) & 0x03800000) >> 23)
-#define PHY_ANALOG_TXRF3_D4CAS5G_SET(x)                                              (((x) << 23) & 0x03800000)
-#define PHY_ANALOG_TXRF3_OB5G_MSB                                                                            28
-#define PHY_ANALOG_TXRF3_OB5G_LSB                                                                            26
-#define PHY_ANALOG_TXRF3_OB5G_MASK                                                                   0x1c000000
-#define PHY_ANALOG_TXRF3_OB5G_GET(x)                                                 (((x) & 0x1c000000) >> 26)
-#define PHY_ANALOG_TXRF3_OB5G_SET(x)                                                 (((x) << 26) & 0x1c000000)
-#define PHY_ANALOG_TXRF3_D2B5G_MSB                                                                           31
-#define PHY_ANALOG_TXRF3_D2B5G_LSB                                                                           29
-#define PHY_ANALOG_TXRF3_D2B5G_MASK                                                                  0xe0000000
-#define PHY_ANALOG_TXRF3_D2B5G_GET(x)                                                (((x) & 0xe0000000) >> 29)
-#define PHY_ANALOG_TXRF3_D2B5G_SET(x)                                                (((x) << 29) & 0xe0000000)
-
-/* macros for TXRF4 */
-#define PHY_ANALOG_TXRF4_ADDRESS                                                                     0x0000004c
-#define PHY_ANALOG_TXRF4_OFFSET                                                                      0x0000004c
-#define PHY_ANALOG_TXRF4_PK1B2G_CCK_MSB                                                                       1
-#define PHY_ANALOG_TXRF4_PK1B2G_CCK_LSB                                                                       0
-#define PHY_ANALOG_TXRF4_PK1B2G_CCK_MASK                                                             0x00000003
-#define PHY_ANALOG_TXRF4_PK1B2G_CCK_GET(x)                                            (((x) & 0x00000003) >> 0)
-#define PHY_ANALOG_TXRF4_PK1B2G_CCK_SET(x)                                            (((x) << 0) & 0x00000003)
-#define PHY_ANALOG_TXRF4_MIOB2G_QAM_MSB                                                                       4
-#define PHY_ANALOG_TXRF4_MIOB2G_QAM_LSB                                                                       2
-#define PHY_ANALOG_TXRF4_MIOB2G_QAM_MASK                                                             0x0000001c
-#define PHY_ANALOG_TXRF4_MIOB2G_QAM_GET(x)                                            (((x) & 0x0000001c) >> 2)
-#define PHY_ANALOG_TXRF4_MIOB2G_QAM_SET(x)                                            (((x) << 2) & 0x0000001c)
-#define PHY_ANALOG_TXRF4_MIOB2G_PSK_MSB                                                                       7
-#define PHY_ANALOG_TXRF4_MIOB2G_PSK_LSB                                                                       5
-#define PHY_ANALOG_TXRF4_MIOB2G_PSK_MASK                                                             0x000000e0
-#define PHY_ANALOG_TXRF4_MIOB2G_PSK_GET(x)                                            (((x) & 0x000000e0) >> 5)
-#define PHY_ANALOG_TXRF4_MIOB2G_PSK_SET(x)                                            (((x) << 5) & 0x000000e0)
-#define PHY_ANALOG_TXRF4_MIOB2G_CCK_MSB                                                                      10
-#define PHY_ANALOG_TXRF4_MIOB2G_CCK_LSB                                                                       8
-#define PHY_ANALOG_TXRF4_MIOB2G_CCK_MASK                                                             0x00000700
-#define PHY_ANALOG_TXRF4_MIOB2G_CCK_GET(x)                                            (((x) & 0x00000700) >> 8)
-#define PHY_ANALOG_TXRF4_MIOB2G_CCK_SET(x)                                            (((x) << 8) & 0x00000700)
-#define PHY_ANALOG_TXRF4_COMP2G_QAM_MSB                                                                      13
-#define PHY_ANALOG_TXRF4_COMP2G_QAM_LSB                                                                      11
-#define PHY_ANALOG_TXRF4_COMP2G_QAM_MASK                                                             0x00003800
-#define PHY_ANALOG_TXRF4_COMP2G_QAM_GET(x)                                           (((x) & 0x00003800) >> 11)
-#define PHY_ANALOG_TXRF4_COMP2G_QAM_SET(x)                                           (((x) << 11) & 0x00003800)
-#define PHY_ANALOG_TXRF4_COMP2G_PSK_MSB                                                                      16
-#define PHY_ANALOG_TXRF4_COMP2G_PSK_LSB                                                                      14
-#define PHY_ANALOG_TXRF4_COMP2G_PSK_MASK                                                             0x0001c000
-#define PHY_ANALOG_TXRF4_COMP2G_PSK_GET(x)                                           (((x) & 0x0001c000) >> 14)
-#define PHY_ANALOG_TXRF4_COMP2G_PSK_SET(x)                                           (((x) << 14) & 0x0001c000)
-#define PHY_ANALOG_TXRF4_COMP2G_CCK_MSB                                                                      19
-#define PHY_ANALOG_TXRF4_COMP2G_CCK_LSB                                                                      17
-#define PHY_ANALOG_TXRF4_COMP2G_CCK_MASK                                                             0x000e0000
-#define PHY_ANALOG_TXRF4_COMP2G_CCK_GET(x)                                           (((x) & 0x000e0000) >> 17)
-#define PHY_ANALOG_TXRF4_COMP2G_CCK_SET(x)                                           (((x) << 17) & 0x000e0000)
-#define PHY_ANALOG_TXRF4_AMP2B2G_QAM_MSB                                                                     22
-#define PHY_ANALOG_TXRF4_AMP2B2G_QAM_LSB                                                                     20
-#define PHY_ANALOG_TXRF4_AMP2B2G_QAM_MASK                                                            0x00700000
-#define PHY_ANALOG_TXRF4_AMP2B2G_QAM_GET(x)                                          (((x) & 0x00700000) >> 20)
-#define PHY_ANALOG_TXRF4_AMP2B2G_QAM_SET(x)                                          (((x) << 20) & 0x00700000)
-#define PHY_ANALOG_TXRF4_AMP2B2G_PSK_MSB                                                                     25
-#define PHY_ANALOG_TXRF4_AMP2B2G_PSK_LSB                                                                     23
-#define PHY_ANALOG_TXRF4_AMP2B2G_PSK_MASK                                                            0x03800000
-#define PHY_ANALOG_TXRF4_AMP2B2G_PSK_GET(x)                                          (((x) & 0x03800000) >> 23)
-#define PHY_ANALOG_TXRF4_AMP2B2G_PSK_SET(x)                                          (((x) << 23) & 0x03800000)
-#define PHY_ANALOG_TXRF4_AMP2B2G_CCK_MSB                                                                     28
-#define PHY_ANALOG_TXRF4_AMP2B2G_CCK_LSB                                                                     26
-#define PHY_ANALOG_TXRF4_AMP2B2G_CCK_MASK                                                            0x1c000000
-#define PHY_ANALOG_TXRF4_AMP2B2G_CCK_GET(x)                                          (((x) & 0x1c000000) >> 26)
-#define PHY_ANALOG_TXRF4_AMP2B2G_CCK_SET(x)                                          (((x) << 26) & 0x1c000000)
-#define PHY_ANALOG_TXRF4_AMP2CAS2G_MSB                                                                       31
-#define PHY_ANALOG_TXRF4_AMP2CAS2G_LSB                                                                       29
-#define PHY_ANALOG_TXRF4_AMP2CAS2G_MASK                                                              0xe0000000
-#define PHY_ANALOG_TXRF4_AMP2CAS2G_GET(x)                                            (((x) & 0xe0000000) >> 29)
-#define PHY_ANALOG_TXRF4_AMP2CAS2G_SET(x)                                            (((x) << 29) & 0xe0000000)
-
-/* macros for TXRF5 */
-#define PHY_ANALOG_TXRF5_ADDRESS                                                                     0x00000050
-#define PHY_ANALOG_TXRF5_OFFSET                                                                      0x00000050
-#define PHY_ANALOG_TXRF5_SPARE5_MSB                                                                           0
-#define PHY_ANALOG_TXRF5_SPARE5_LSB                                                                           0
-#define PHY_ANALOG_TXRF5_SPARE5_MASK                                                                 0x00000001
-#define PHY_ANALOG_TXRF5_SPARE5_GET(x)                                                (((x) & 0x00000001) >> 0)
-#define PHY_ANALOG_TXRF5_SPARE5_SET(x)                                                (((x) << 0) & 0x00000001)
-#define PHY_ANALOG_TXRF5_PAL_LOCKED_MSB                                                                       1
-#define PHY_ANALOG_TXRF5_PAL_LOCKED_LSB                                                                       1
-#define PHY_ANALOG_TXRF5_PAL_LOCKED_MASK                                                             0x00000002
-#define PHY_ANALOG_TXRF5_PAL_LOCKED_GET(x)                                            (((x) & 0x00000002) >> 1)
-#define PHY_ANALOG_TXRF5_FBHI2G_MSB                                                                           2
-#define PHY_ANALOG_TXRF5_FBHI2G_LSB                                                                           2
-#define PHY_ANALOG_TXRF5_FBHI2G_MASK                                                                 0x00000004
-#define PHY_ANALOG_TXRF5_FBHI2G_GET(x)                                                (((x) & 0x00000004) >> 2)
-#define PHY_ANALOG_TXRF5_FBLO2G_MSB                                                                           3
-#define PHY_ANALOG_TXRF5_FBLO2G_LSB                                                                           3
-#define PHY_ANALOG_TXRF5_FBLO2G_MASK                                                                 0x00000008
-#define PHY_ANALOG_TXRF5_FBLO2G_GET(x)                                                (((x) & 0x00000008) >> 3)
-#define PHY_ANALOG_TXRF5_NOPALGAIN2G_MSB                                                                      4
-#define PHY_ANALOG_TXRF5_NOPALGAIN2G_LSB                                                                      4
-#define PHY_ANALOG_TXRF5_NOPALGAIN2G_MASK                                                            0x00000010
-#define PHY_ANALOG_TXRF5_NOPALGAIN2G_GET(x)                                           (((x) & 0x00000010) >> 4)
-#define PHY_ANALOG_TXRF5_NOPALGAIN2G_SET(x)                                           (((x) << 4) & 0x00000010)
-#define PHY_ANALOG_TXRF5_ENPACAL2G_MSB                                                                        5
-#define PHY_ANALOG_TXRF5_ENPACAL2G_LSB                                                                        5
-#define PHY_ANALOG_TXRF5_ENPACAL2G_MASK                                                              0x00000020
-#define PHY_ANALOG_TXRF5_ENPACAL2G_GET(x)                                             (((x) & 0x00000020) >> 5)
-#define PHY_ANALOG_TXRF5_ENPACAL2G_SET(x)                                             (((x) << 5) & 0x00000020)
-#define PHY_ANALOG_TXRF5_OFFSET2G_MSB                                                                        12
-#define PHY_ANALOG_TXRF5_OFFSET2G_LSB                                                                         6
-#define PHY_ANALOG_TXRF5_OFFSET2G_MASK                                                               0x00001fc0
-#define PHY_ANALOG_TXRF5_OFFSET2G_GET(x)                                              (((x) & 0x00001fc0) >> 6)
-#define PHY_ANALOG_TXRF5_OFFSET2G_SET(x)                                              (((x) << 6) & 0x00001fc0)
-#define PHY_ANALOG_TXRF5_ENOFFSETCAL2G_MSB                                                                   13
-#define PHY_ANALOG_TXRF5_ENOFFSETCAL2G_LSB                                                                   13
-#define PHY_ANALOG_TXRF5_ENOFFSETCAL2G_MASK                                                          0x00002000
-#define PHY_ANALOG_TXRF5_ENOFFSETCAL2G_GET(x)                                        (((x) & 0x00002000) >> 13)
-#define PHY_ANALOG_TXRF5_ENOFFSETCAL2G_SET(x)                                        (((x) << 13) & 0x00002000)
-#define PHY_ANALOG_TXRF5_REFHI2G_MSB                                                                         16
-#define PHY_ANALOG_TXRF5_REFHI2G_LSB                                                                         14
-#define PHY_ANALOG_TXRF5_REFHI2G_MASK                                                                0x0001c000
-#define PHY_ANALOG_TXRF5_REFHI2G_GET(x)                                              (((x) & 0x0001c000) >> 14)
-#define PHY_ANALOG_TXRF5_REFHI2G_SET(x)                                              (((x) << 14) & 0x0001c000)
-#define PHY_ANALOG_TXRF5_REFLO2G_MSB                                                                         19
-#define PHY_ANALOG_TXRF5_REFLO2G_LSB                                                                         17
-#define PHY_ANALOG_TXRF5_REFLO2G_MASK                                                                0x000e0000
-#define PHY_ANALOG_TXRF5_REFLO2G_GET(x)                                              (((x) & 0x000e0000) >> 17)
-#define PHY_ANALOG_TXRF5_REFLO2G_SET(x)                                              (((x) << 17) & 0x000e0000)
-#define PHY_ANALOG_TXRF5_PALCLAMP2G_MSB                                                                      21
-#define PHY_ANALOG_TXRF5_PALCLAMP2G_LSB                                                                      20
-#define PHY_ANALOG_TXRF5_PALCLAMP2G_MASK                                                             0x00300000
-#define PHY_ANALOG_TXRF5_PALCLAMP2G_GET(x)                                           (((x) & 0x00300000) >> 20)
-#define PHY_ANALOG_TXRF5_PALCLAMP2G_SET(x)                                           (((x) << 20) & 0x00300000)
-#define PHY_ANALOG_TXRF5_PK2B2G_QAM_MSB                                                                      23
-#define PHY_ANALOG_TXRF5_PK2B2G_QAM_LSB                                                                      22
-#define PHY_ANALOG_TXRF5_PK2B2G_QAM_MASK                                                             0x00c00000
-#define PHY_ANALOG_TXRF5_PK2B2G_QAM_GET(x)                                           (((x) & 0x00c00000) >> 22)
-#define PHY_ANALOG_TXRF5_PK2B2G_QAM_SET(x)                                           (((x) << 22) & 0x00c00000)
-#define PHY_ANALOG_TXRF5_PK2B2G_PSK_MSB                                                                      25
-#define PHY_ANALOG_TXRF5_PK2B2G_PSK_LSB                                                                      24
-#define PHY_ANALOG_TXRF5_PK2B2G_PSK_MASK                                                             0x03000000
-#define PHY_ANALOG_TXRF5_PK2B2G_PSK_GET(x)                                           (((x) & 0x03000000) >> 24)
-#define PHY_ANALOG_TXRF5_PK2B2G_PSK_SET(x)                                           (((x) << 24) & 0x03000000)
-#define PHY_ANALOG_TXRF5_PK2B2G_CCK_MSB                                                                      27
-#define PHY_ANALOG_TXRF5_PK2B2G_CCK_LSB                                                                      26
-#define PHY_ANALOG_TXRF5_PK2B2G_CCK_MASK                                                             0x0c000000
-#define PHY_ANALOG_TXRF5_PK2B2G_CCK_GET(x)                                           (((x) & 0x0c000000) >> 26)
-#define PHY_ANALOG_TXRF5_PK2B2G_CCK_SET(x)                                           (((x) << 26) & 0x0c000000)
-#define PHY_ANALOG_TXRF5_PK1B2G_QAM_MSB                                                                      29
-#define PHY_ANALOG_TXRF5_PK1B2G_QAM_LSB                                                                      28
-#define PHY_ANALOG_TXRF5_PK1B2G_QAM_MASK                                                             0x30000000
-#define PHY_ANALOG_TXRF5_PK1B2G_QAM_GET(x)                                           (((x) & 0x30000000) >> 28)
-#define PHY_ANALOG_TXRF5_PK1B2G_QAM_SET(x)                                           (((x) << 28) & 0x30000000)
-#define PHY_ANALOG_TXRF5_PK1B2G_PSK_MSB                                                                      31
-#define PHY_ANALOG_TXRF5_PK1B2G_PSK_LSB                                                                      30
-#define PHY_ANALOG_TXRF5_PK1B2G_PSK_MASK                                                             0xc0000000
-#define PHY_ANALOG_TXRF5_PK1B2G_PSK_GET(x)                                           (((x) & 0xc0000000) >> 30)
-#define PHY_ANALOG_TXRF5_PK1B2G_PSK_SET(x)                                           (((x) << 30) & 0xc0000000)
-
-/* macros for TXRF6 */
-#define PHY_ANALOG_TXRF6_ADDRESS                                                                     0x00000054
-#define PHY_ANALOG_TXRF6_OFFSET                                                                      0x00000054
-#define PHY_ANALOG_TXRF6_PALCLKGATE2G_MSB                                                                     0
-#define PHY_ANALOG_TXRF6_PALCLKGATE2G_LSB                                                                     0
-#define PHY_ANALOG_TXRF6_PALCLKGATE2G_MASK                                                           0x00000001
-#define PHY_ANALOG_TXRF6_PALCLKGATE2G_GET(x)                                          (((x) & 0x00000001) >> 0)
-#define PHY_ANALOG_TXRF6_PALCLKGATE2G_SET(x)                                          (((x) << 0) & 0x00000001)
-#define PHY_ANALOG_TXRF6_PALFLUCTCOUNT2G_MSB                                                                  8
-#define PHY_ANALOG_TXRF6_PALFLUCTCOUNT2G_LSB                                                                  1
-#define PHY_ANALOG_TXRF6_PALFLUCTCOUNT2G_MASK                                                        0x000001fe
-#define PHY_ANALOG_TXRF6_PALFLUCTCOUNT2G_GET(x)                                       (((x) & 0x000001fe) >> 1)
-#define PHY_ANALOG_TXRF6_PALFLUCTCOUNT2G_SET(x)                                       (((x) << 1) & 0x000001fe)
-#define PHY_ANALOG_TXRF6_PALFLUCTGAIN2G_MSB                                                                  10
-#define PHY_ANALOG_TXRF6_PALFLUCTGAIN2G_LSB                                                                   9
-#define PHY_ANALOG_TXRF6_PALFLUCTGAIN2G_MASK                                                         0x00000600
-#define PHY_ANALOG_TXRF6_PALFLUCTGAIN2G_GET(x)                                        (((x) & 0x00000600) >> 9)
-#define PHY_ANALOG_TXRF6_PALFLUCTGAIN2G_SET(x)                                        (((x) << 9) & 0x00000600)
-#define PHY_ANALOG_TXRF6_PALNOFLUCT2G_MSB                                                                    11
-#define PHY_ANALOG_TXRF6_PALNOFLUCT2G_LSB                                                                    11
-#define PHY_ANALOG_TXRF6_PALNOFLUCT2G_MASK                                                           0x00000800
-#define PHY_ANALOG_TXRF6_PALNOFLUCT2G_GET(x)                                         (((x) & 0x00000800) >> 11)
-#define PHY_ANALOG_TXRF6_PALNOFLUCT2G_SET(x)                                         (((x) << 11) & 0x00000800)
-#define PHY_ANALOG_TXRF6_GAINSTEP2G_MSB                                                                      14
-#define PHY_ANALOG_TXRF6_GAINSTEP2G_LSB                                                                      12
-#define PHY_ANALOG_TXRF6_GAINSTEP2G_MASK                                                             0x00007000
-#define PHY_ANALOG_TXRF6_GAINSTEP2G_GET(x)                                           (((x) & 0x00007000) >> 12)
-#define PHY_ANALOG_TXRF6_GAINSTEP2G_SET(x)                                           (((x) << 12) & 0x00007000)
-#define PHY_ANALOG_TXRF6_USE_GAIN_DELTA2G_MSB                                                                15
-#define PHY_ANALOG_TXRF6_USE_GAIN_DELTA2G_LSB                                                                15
-#define PHY_ANALOG_TXRF6_USE_GAIN_DELTA2G_MASK                                                       0x00008000
-#define PHY_ANALOG_TXRF6_USE_GAIN_DELTA2G_GET(x)                                     (((x) & 0x00008000) >> 15)
-#define PHY_ANALOG_TXRF6_USE_GAIN_DELTA2G_SET(x)                                     (((x) << 15) & 0x00008000)
-#define PHY_ANALOG_TXRF6_CAPDIV_I2G_MSB                                                                      19
-#define PHY_ANALOG_TXRF6_CAPDIV_I2G_LSB                                                                      16
-#define PHY_ANALOG_TXRF6_CAPDIV_I2G_MASK                                                             0x000f0000
-#define PHY_ANALOG_TXRF6_CAPDIV_I2G_GET(x)                                           (((x) & 0x000f0000) >> 16)
-#define PHY_ANALOG_TXRF6_CAPDIV_I2G_SET(x)                                           (((x) << 16) & 0x000f0000)
-#define PHY_ANALOG_TXRF6_PADRVGN_INDEX_I2G_MSB                                                               23
-#define PHY_ANALOG_TXRF6_PADRVGN_INDEX_I2G_LSB                                                               20
-#define PHY_ANALOG_TXRF6_PADRVGN_INDEX_I2G_MASK                                                      0x00f00000
-#define PHY_ANALOG_TXRF6_PADRVGN_INDEX_I2G_GET(x)                                    (((x) & 0x00f00000) >> 20)
-#define PHY_ANALOG_TXRF6_PADRVGN_INDEX_I2G_SET(x)                                    (((x) << 20) & 0x00f00000)
-#define PHY_ANALOG_TXRF6_VCMONDELAY2G_MSB                                                                    26
-#define PHY_ANALOG_TXRF6_VCMONDELAY2G_LSB                                                                    24
-#define PHY_ANALOG_TXRF6_VCMONDELAY2G_MASK                                                           0x07000000
-#define PHY_ANALOG_TXRF6_VCMONDELAY2G_GET(x)                                         (((x) & 0x07000000) >> 24)
-#define PHY_ANALOG_TXRF6_VCMONDELAY2G_SET(x)                                         (((x) << 24) & 0x07000000)
-#define PHY_ANALOG_TXRF6_CAPDIV2G_MSB                                                                        30
-#define PHY_ANALOG_TXRF6_CAPDIV2G_LSB                                                                        27
-#define PHY_ANALOG_TXRF6_CAPDIV2G_MASK                                                               0x78000000
-#define PHY_ANALOG_TXRF6_CAPDIV2G_GET(x)                                             (((x) & 0x78000000) >> 27)
-#define PHY_ANALOG_TXRF6_CAPDIV2G_SET(x)                                             (((x) << 27) & 0x78000000)
-#define PHY_ANALOG_TXRF6_CAPDIV2GOVR_MSB                                                                     31
-#define PHY_ANALOG_TXRF6_CAPDIV2GOVR_LSB                                                                     31
-#define PHY_ANALOG_TXRF6_CAPDIV2GOVR_MASK                                                            0x80000000
-#define PHY_ANALOG_TXRF6_CAPDIV2GOVR_GET(x)                                          (((x) & 0x80000000) >> 31)
-#define PHY_ANALOG_TXRF6_CAPDIV2GOVR_SET(x)                                          (((x) << 31) & 0x80000000)
-
-/* macros for TXRF7 */
-#define PHY_ANALOG_TXRF7_ADDRESS                                                                     0x00000058
-#define PHY_ANALOG_TXRF7_OFFSET                                                                      0x00000058
-#define PHY_ANALOG_TXRF7_SPARE7_MSB                                                                           1
-#define PHY_ANALOG_TXRF7_SPARE7_LSB                                                                           0
-#define PHY_ANALOG_TXRF7_SPARE7_MASK                                                                 0x00000003
-#define PHY_ANALOG_TXRF7_SPARE7_GET(x)                                                (((x) & 0x00000003) >> 0)
-#define PHY_ANALOG_TXRF7_SPARE7_SET(x)                                                (((x) << 0) & 0x00000003)
-#define PHY_ANALOG_TXRF7_PADRVGNTAB_4_MSB                                                                     7
-#define PHY_ANALOG_TXRF7_PADRVGNTAB_4_LSB                                                                     2
-#define PHY_ANALOG_TXRF7_PADRVGNTAB_4_MASK                                                           0x000000fc
-#define PHY_ANALOG_TXRF7_PADRVGNTAB_4_GET(x)                                          (((x) & 0x000000fc) >> 2)
-#define PHY_ANALOG_TXRF7_PADRVGNTAB_4_SET(x)                                          (((x) << 2) & 0x000000fc)
-#define PHY_ANALOG_TXRF7_PADRVGNTAB_3_MSB                                                                    13
-#define PHY_ANALOG_TXRF7_PADRVGNTAB_3_LSB                                                                     8
-#define PHY_ANALOG_TXRF7_PADRVGNTAB_3_MASK                                                           0x00003f00
-#define PHY_ANALOG_TXRF7_PADRVGNTAB_3_GET(x)                                          (((x) & 0x00003f00) >> 8)
-#define PHY_ANALOG_TXRF7_PADRVGNTAB_3_SET(x)                                          (((x) << 8) & 0x00003f00)
-#define PHY_ANALOG_TXRF7_PADRVGNTAB_2_MSB                                                                    19
-#define PHY_ANALOG_TXRF7_PADRVGNTAB_2_LSB                                                                    14
-#define PHY_ANALOG_TXRF7_PADRVGNTAB_2_MASK                                                           0x000fc000
-#define PHY_ANALOG_TXRF7_PADRVGNTAB_2_GET(x)                                         (((x) & 0x000fc000) >> 14)
-#define PHY_ANALOG_TXRF7_PADRVGNTAB_2_SET(x)                                         (((x) << 14) & 0x000fc000)
-#define PHY_ANALOG_TXRF7_PADRVGNTAB_1_MSB                                                                    25
-#define PHY_ANALOG_TXRF7_PADRVGNTAB_1_LSB                                                                    20
-#define PHY_ANALOG_TXRF7_PADRVGNTAB_1_MASK                                                           0x03f00000
-#define PHY_ANALOG_TXRF7_PADRVGNTAB_1_GET(x)                                         (((x) & 0x03f00000) >> 20)
-#define PHY_ANALOG_TXRF7_PADRVGNTAB_1_SET(x)                                         (((x) << 20) & 0x03f00000)
-#define PHY_ANALOG_TXRF7_PADRVGNTAB_0_MSB                                                                    31
-#define PHY_ANALOG_TXRF7_PADRVGNTAB_0_LSB                                                                    26
-#define PHY_ANALOG_TXRF7_PADRVGNTAB_0_MASK                                                           0xfc000000
-#define PHY_ANALOG_TXRF7_PADRVGNTAB_0_GET(x)                                         (((x) & 0xfc000000) >> 26)
-#define PHY_ANALOG_TXRF7_PADRVGNTAB_0_SET(x)                                         (((x) << 26) & 0xfc000000)
-
-/* macros for TXRF8 */
-#define PHY_ANALOG_TXRF8_ADDRESS                                                                     0x0000005c
-#define PHY_ANALOG_TXRF8_OFFSET                                                                      0x0000005c
-#define PHY_ANALOG_TXRF8_SPARE8_MSB                                                                           1
-#define PHY_ANALOG_TXRF8_SPARE8_LSB                                                                           0
-#define PHY_ANALOG_TXRF8_SPARE8_MASK                                                                 0x00000003
-#define PHY_ANALOG_TXRF8_SPARE8_GET(x)                                                (((x) & 0x00000003) >> 0)
-#define PHY_ANALOG_TXRF8_SPARE8_SET(x)                                                (((x) << 0) & 0x00000003)
-#define PHY_ANALOG_TXRF8_PADRVGNTAB_9_MSB                                                                     7
-#define PHY_ANALOG_TXRF8_PADRVGNTAB_9_LSB                                                                     2
-#define PHY_ANALOG_TXRF8_PADRVGNTAB_9_MASK                                                           0x000000fc
-#define PHY_ANALOG_TXRF8_PADRVGNTAB_9_GET(x)                                          (((x) & 0x000000fc) >> 2)
-#define PHY_ANALOG_TXRF8_PADRVGNTAB_9_SET(x)                                          (((x) << 2) & 0x000000fc)
-#define PHY_ANALOG_TXRF8_PADRVGNTAB_8_MSB                                                                    13
-#define PHY_ANALOG_TXRF8_PADRVGNTAB_8_LSB                                                                     8
-#define PHY_ANALOG_TXRF8_PADRVGNTAB_8_MASK                                                           0x00003f00
-#define PHY_ANALOG_TXRF8_PADRVGNTAB_8_GET(x)                                          (((x) & 0x00003f00) >> 8)
-#define PHY_ANALOG_TXRF8_PADRVGNTAB_8_SET(x)                                          (((x) << 8) & 0x00003f00)
-#define PHY_ANALOG_TXRF8_PADRVGNTAB_7_MSB                                                                    19
-#define PHY_ANALOG_TXRF8_PADRVGNTAB_7_LSB                                                                    14
-#define PHY_ANALOG_TXRF8_PADRVGNTAB_7_MASK                                                           0x000fc000
-#define PHY_ANALOG_TXRF8_PADRVGNTAB_7_GET(x)                                         (((x) & 0x000fc000) >> 14)
-#define PHY_ANALOG_TXRF8_PADRVGNTAB_7_SET(x)                                         (((x) << 14) & 0x000fc000)
-#define PHY_ANALOG_TXRF8_PADRVGNTAB_6_MSB                                                                    25
-#define PHY_ANALOG_TXRF8_PADRVGNTAB_6_LSB                                                                    20
-#define PHY_ANALOG_TXRF8_PADRVGNTAB_6_MASK                                                           0x03f00000
-#define PHY_ANALOG_TXRF8_PADRVGNTAB_6_GET(x)                                         (((x) & 0x03f00000) >> 20)
-#define PHY_ANALOG_TXRF8_PADRVGNTAB_6_SET(x)                                         (((x) << 20) & 0x03f00000)
-#define PHY_ANALOG_TXRF8_PADRVGNTAB_5_MSB                                                                    31
-#define PHY_ANALOG_TXRF8_PADRVGNTAB_5_LSB                                                                    26
-#define PHY_ANALOG_TXRF8_PADRVGNTAB_5_MASK                                                           0xfc000000
-#define PHY_ANALOG_TXRF8_PADRVGNTAB_5_GET(x)                                         (((x) & 0xfc000000) >> 26)
-#define PHY_ANALOG_TXRF8_PADRVGNTAB_5_SET(x)                                         (((x) << 26) & 0xfc000000)
-
-/* macros for TXRF9 */
-#define PHY_ANALOG_TXRF9_ADDRESS                                                                     0x00000060
-#define PHY_ANALOG_TXRF9_OFFSET                                                                      0x00000060
-#define PHY_ANALOG_TXRF9_SPARE9_MSB                                                                           1
-#define PHY_ANALOG_TXRF9_SPARE9_LSB                                                                           0
-#define PHY_ANALOG_TXRF9_SPARE9_MASK                                                                 0x00000003
-#define PHY_ANALOG_TXRF9_SPARE9_GET(x)                                                (((x) & 0x00000003) >> 0)
-#define PHY_ANALOG_TXRF9_SPARE9_SET(x)                                                (((x) << 0) & 0x00000003)
-#define PHY_ANALOG_TXRF9_PADRVGNTAB_14_MSB                                                                    7
-#define PHY_ANALOG_TXRF9_PADRVGNTAB_14_LSB                                                                    2
-#define PHY_ANALOG_TXRF9_PADRVGNTAB_14_MASK                                                          0x000000fc
-#define PHY_ANALOG_TXRF9_PADRVGNTAB_14_GET(x)                                         (((x) & 0x000000fc) >> 2)
-#define PHY_ANALOG_TXRF9_PADRVGNTAB_14_SET(x)                                         (((x) << 2) & 0x000000fc)
-#define PHY_ANALOG_TXRF9_PADRVGNTAB_13_MSB                                                                   13
-#define PHY_ANALOG_TXRF9_PADRVGNTAB_13_LSB                                                                    8
-#define PHY_ANALOG_TXRF9_PADRVGNTAB_13_MASK                                                          0x00003f00
-#define PHY_ANALOG_TXRF9_PADRVGNTAB_13_GET(x)                                         (((x) & 0x00003f00) >> 8)
-#define PHY_ANALOG_TXRF9_PADRVGNTAB_13_SET(x)                                         (((x) << 8) & 0x00003f00)
-#define PHY_ANALOG_TXRF9_PADRVGNTAB_12_MSB                                                                   19
-#define PHY_ANALOG_TXRF9_PADRVGNTAB_12_LSB                                                                   14
-#define PHY_ANALOG_TXRF9_PADRVGNTAB_12_MASK                                                          0x000fc000
-#define PHY_ANALOG_TXRF9_PADRVGNTAB_12_GET(x)                                        (((x) & 0x000fc000) >> 14)
-#define PHY_ANALOG_TXRF9_PADRVGNTAB_12_SET(x)                                        (((x) << 14) & 0x000fc000)
-#define PHY_ANALOG_TXRF9_PADRVGNTAB_11_MSB                                                                   25
-#define PHY_ANALOG_TXRF9_PADRVGNTAB_11_LSB                                                                   20
-#define PHY_ANALOG_TXRF9_PADRVGNTAB_11_MASK                                                          0x03f00000
-#define PHY_ANALOG_TXRF9_PADRVGNTAB_11_GET(x)                                        (((x) & 0x03f00000) >> 20)
-#define PHY_ANALOG_TXRF9_PADRVGNTAB_11_SET(x)                                        (((x) << 20) & 0x03f00000)
-#define PHY_ANALOG_TXRF9_PADRVGNTAB_10_MSB                                                                   31
-#define PHY_ANALOG_TXRF9_PADRVGNTAB_10_LSB                                                                   26
-#define PHY_ANALOG_TXRF9_PADRVGNTAB_10_MASK                                                          0xfc000000
-#define PHY_ANALOG_TXRF9_PADRVGNTAB_10_GET(x)                                        (((x) & 0xfc000000) >> 26)
-#define PHY_ANALOG_TXRF9_PADRVGNTAB_10_SET(x)                                        (((x) << 26) & 0xfc000000)
-
-/* macros for TXRF10 */
-#define PHY_ANALOG_TXRF10_ADDRESS                                                                    0x00000064
-#define PHY_ANALOG_TXRF10_OFFSET                                                                     0x00000064
-#define PHY_ANALOG_TXRF10_SPARE10_MSB                                                                         2
-#define PHY_ANALOG_TXRF10_SPARE10_LSB                                                                         0
-#define PHY_ANALOG_TXRF10_SPARE10_MASK                                                               0x00000007
-#define PHY_ANALOG_TXRF10_SPARE10_GET(x)                                              (((x) & 0x00000007) >> 0)
-#define PHY_ANALOG_TXRF10_SPARE10_SET(x)                                              (((x) << 0) & 0x00000007)
-#define PHY_ANALOG_TXRF10_PDOUT5G_3CALTX_MSB                                                                  3
-#define PHY_ANALOG_TXRF10_PDOUT5G_3CALTX_LSB                                                                  3
-#define PHY_ANALOG_TXRF10_PDOUT5G_3CALTX_MASK                                                        0x00000008
-#define PHY_ANALOG_TXRF10_PDOUT5G_3CALTX_GET(x)                                       (((x) & 0x00000008) >> 3)
-#define PHY_ANALOG_TXRF10_PDOUT5G_3CALTX_SET(x)                                       (((x) << 3) & 0x00000008)
-#define PHY_ANALOG_TXRF10_D3B5GCALTX_MSB                                                                      6
-#define PHY_ANALOG_TXRF10_D3B5GCALTX_LSB                                                                      4
-#define PHY_ANALOG_TXRF10_D3B5GCALTX_MASK                                                            0x00000070
-#define PHY_ANALOG_TXRF10_D3B5GCALTX_GET(x)                                           (((x) & 0x00000070) >> 4)
-#define PHY_ANALOG_TXRF10_D3B5GCALTX_SET(x)                                           (((x) << 4) & 0x00000070)
-#define PHY_ANALOG_TXRF10_D4B5GCALTX_MSB                                                                      9
-#define PHY_ANALOG_TXRF10_D4B5GCALTX_LSB                                                                      7
-#define PHY_ANALOG_TXRF10_D4B5GCALTX_MASK                                                            0x00000380
-#define PHY_ANALOG_TXRF10_D4B5GCALTX_GET(x)                                           (((x) & 0x00000380) >> 7)
-#define PHY_ANALOG_TXRF10_D4B5GCALTX_SET(x)                                           (((x) << 7) & 0x00000380)
-#define PHY_ANALOG_TXRF10_PADRVGN2GCALTX_MSB                                                                 16
-#define PHY_ANALOG_TXRF10_PADRVGN2GCALTX_LSB                                                                 10
-#define PHY_ANALOG_TXRF10_PADRVGN2GCALTX_MASK                                                        0x0001fc00
-#define PHY_ANALOG_TXRF10_PADRVGN2GCALTX_GET(x)                                      (((x) & 0x0001fc00) >> 10)
-#define PHY_ANALOG_TXRF10_PADRVGN2GCALTX_SET(x)                                      (((x) << 10) & 0x0001fc00)
-#define PHY_ANALOG_TXRF10_DB2GCALTX_MSB                                                                      19
-#define PHY_ANALOG_TXRF10_DB2GCALTX_LSB                                                                      17
-#define PHY_ANALOG_TXRF10_DB2GCALTX_MASK                                                             0x000e0000
-#define PHY_ANALOG_TXRF10_DB2GCALTX_GET(x)                                           (((x) & 0x000e0000) >> 17)
-#define PHY_ANALOG_TXRF10_DB2GCALTX_SET(x)                                           (((x) << 17) & 0x000e0000)
-#define PHY_ANALOG_TXRF10_CALTXSHIFT_MSB                                                                     20
-#define PHY_ANALOG_TXRF10_CALTXSHIFT_LSB                                                                     20
-#define PHY_ANALOG_TXRF10_CALTXSHIFT_MASK                                                            0x00100000
-#define PHY_ANALOG_TXRF10_CALTXSHIFT_GET(x)                                          (((x) & 0x00100000) >> 20)
-#define PHY_ANALOG_TXRF10_CALTXSHIFT_SET(x)                                          (((x) << 20) & 0x00100000)
-#define PHY_ANALOG_TXRF10_CALTXSHIFTOVR_MSB                                                                  21
-#define PHY_ANALOG_TXRF10_CALTXSHIFTOVR_LSB                                                                  21
-#define PHY_ANALOG_TXRF10_CALTXSHIFTOVR_MASK                                                         0x00200000
-#define PHY_ANALOG_TXRF10_CALTXSHIFTOVR_GET(x)                                       (((x) & 0x00200000) >> 21)
-#define PHY_ANALOG_TXRF10_CALTXSHIFTOVR_SET(x)                                       (((x) << 21) & 0x00200000)
-#define PHY_ANALOG_TXRF10_PADRVGN2G_SMOUT_MSB                                                                27
-#define PHY_ANALOG_TXRF10_PADRVGN2G_SMOUT_LSB                                                                22
-#define PHY_ANALOG_TXRF10_PADRVGN2G_SMOUT_MASK                                                       0x0fc00000
-#define PHY_ANALOG_TXRF10_PADRVGN2G_SMOUT_GET(x)                                     (((x) & 0x0fc00000) >> 22)
-#define PHY_ANALOG_TXRF10_PADRVGN_INDEX2G_SMOUT_MSB                                                          31
-#define PHY_ANALOG_TXRF10_PADRVGN_INDEX2G_SMOUT_LSB                                                          28
-#define PHY_ANALOG_TXRF10_PADRVGN_INDEX2G_SMOUT_MASK                                                 0xf0000000
-#define PHY_ANALOG_TXRF10_PADRVGN_INDEX2G_SMOUT_GET(x)                               (((x) & 0xf0000000) >> 28)
-
-/* macros for TXRF11 */
-#define PHY_ANALOG_TXRF11_ADDRESS                                                                    0x00000068
-#define PHY_ANALOG_TXRF11_OFFSET                                                                     0x00000068
-#define PHY_ANALOG_TXRF11_SPARE11_MSB                                                                         1
-#define PHY_ANALOG_TXRF11_SPARE11_LSB                                                                         0
-#define PHY_ANALOG_TXRF11_SPARE11_MASK                                                               0x00000003
-#define PHY_ANALOG_TXRF11_SPARE11_GET(x)                                              (((x) & 0x00000003) >> 0)
-#define PHY_ANALOG_TXRF11_SPARE11_SET(x)                                              (((x) << 0) & 0x00000003)
-#define PHY_ANALOG_TXRF11_PWD_IR25MIXDIV5G_MSB                                                                4
-#define PHY_ANALOG_TXRF11_PWD_IR25MIXDIV5G_LSB                                                                2
-#define PHY_ANALOG_TXRF11_PWD_IR25MIXDIV5G_MASK                                                      0x0000001c
-#define PHY_ANALOG_TXRF11_PWD_IR25MIXDIV5G_GET(x)                                     (((x) & 0x0000001c) >> 2)
-#define PHY_ANALOG_TXRF11_PWD_IR25MIXDIV5G_SET(x)                                     (((x) << 2) & 0x0000001c)
-#define PHY_ANALOG_TXRF11_PWD_IR25PA2G_MSB                                                                    7
-#define PHY_ANALOG_TXRF11_PWD_IR25PA2G_LSB                                                                    5
-#define PHY_ANALOG_TXRF11_PWD_IR25PA2G_MASK                                                          0x000000e0
-#define PHY_ANALOG_TXRF11_PWD_IR25PA2G_GET(x)                                         (((x) & 0x000000e0) >> 5)
-#define PHY_ANALOG_TXRF11_PWD_IR25PA2G_SET(x)                                         (((x) << 5) & 0x000000e0)
-#define PHY_ANALOG_TXRF11_PWD_IR25MIXBIAS2G_MSB                                                              10
-#define PHY_ANALOG_TXRF11_PWD_IR25MIXBIAS2G_LSB                                                               8
-#define PHY_ANALOG_TXRF11_PWD_IR25MIXBIAS2G_MASK                                                     0x00000700
-#define PHY_ANALOG_TXRF11_PWD_IR25MIXBIAS2G_GET(x)                                    (((x) & 0x00000700) >> 8)
-#define PHY_ANALOG_TXRF11_PWD_IR25MIXBIAS2G_SET(x)                                    (((x) << 8) & 0x00000700)
-#define PHY_ANALOG_TXRF11_PWD_IR25MIXDIV2G_MSB                                                               13
-#define PHY_ANALOG_TXRF11_PWD_IR25MIXDIV2G_LSB                                                               11
-#define PHY_ANALOG_TXRF11_PWD_IR25MIXDIV2G_MASK                                                      0x00003800
-#define PHY_ANALOG_TXRF11_PWD_IR25MIXDIV2G_GET(x)                                    (((x) & 0x00003800) >> 11)
-#define PHY_ANALOG_TXRF11_PWD_IR25MIXDIV2G_SET(x)                                    (((x) << 11) & 0x00003800)
-#define PHY_ANALOG_TXRF11_PWD_ICSPARE_MSB                                                                    16
-#define PHY_ANALOG_TXRF11_PWD_ICSPARE_LSB                                                                    14
-#define PHY_ANALOG_TXRF11_PWD_ICSPARE_MASK                                                           0x0001c000
-#define PHY_ANALOG_TXRF11_PWD_ICSPARE_GET(x)                                         (((x) & 0x0001c000) >> 14)
-#define PHY_ANALOG_TXRF11_PWD_ICSPARE_SET(x)                                         (((x) << 14) & 0x0001c000)
-#define PHY_ANALOG_TXRF11_PWD_IC25TEMPSEN_MSB                                                                19
-#define PHY_ANALOG_TXRF11_PWD_IC25TEMPSEN_LSB                                                                17
-#define PHY_ANALOG_TXRF11_PWD_IC25TEMPSEN_MASK                                                       0x000e0000
-#define PHY_ANALOG_TXRF11_PWD_IC25TEMPSEN_GET(x)                                     (((x) & 0x000e0000) >> 17)
-#define PHY_ANALOG_TXRF11_PWD_IC25TEMPSEN_SET(x)                                     (((x) << 17) & 0x000e0000)
-#define PHY_ANALOG_TXRF11_PWD_IC25PA5G2_MSB                                                                  22
-#define PHY_ANALOG_TXRF11_PWD_IC25PA5G2_LSB                                                                  20
-#define PHY_ANALOG_TXRF11_PWD_IC25PA5G2_MASK                                                         0x00700000
-#define PHY_ANALOG_TXRF11_PWD_IC25PA5G2_GET(x)                                       (((x) & 0x00700000) >> 20)
-#define PHY_ANALOG_TXRF11_PWD_IC25PA5G2_SET(x)                                       (((x) << 20) & 0x00700000)
-#define PHY_ANALOG_TXRF11_PWD_IC25PA5G1_MSB                                                                  25
-#define PHY_ANALOG_TXRF11_PWD_IC25PA5G1_LSB                                                                  23
-#define PHY_ANALOG_TXRF11_PWD_IC25PA5G1_MASK                                                         0x03800000
-#define PHY_ANALOG_TXRF11_PWD_IC25PA5G1_GET(x)                                       (((x) & 0x03800000) >> 23)
-#define PHY_ANALOG_TXRF11_PWD_IC25PA5G1_SET(x)                                       (((x) << 23) & 0x03800000)
-#define PHY_ANALOG_TXRF11_PWD_IC25MIXBUF5G_MSB                                                               28
-#define PHY_ANALOG_TXRF11_PWD_IC25MIXBUF5G_LSB                                                               26
-#define PHY_ANALOG_TXRF11_PWD_IC25MIXBUF5G_MASK                                                      0x1c000000
-#define PHY_ANALOG_TXRF11_PWD_IC25MIXBUF5G_GET(x)                                    (((x) & 0x1c000000) >> 26)
-#define PHY_ANALOG_TXRF11_PWD_IC25MIXBUF5G_SET(x)                                    (((x) << 26) & 0x1c000000)
-#define PHY_ANALOG_TXRF11_PWD_IC25PA2G_MSB                                                                   31
-#define PHY_ANALOG_TXRF11_PWD_IC25PA2G_LSB                                                                   29
-#define PHY_ANALOG_TXRF11_PWD_IC25PA2G_MASK                                                          0xe0000000
-#define PHY_ANALOG_TXRF11_PWD_IC25PA2G_GET(x)                                        (((x) & 0xe0000000) >> 29)
-#define PHY_ANALOG_TXRF11_PWD_IC25PA2G_SET(x)                                        (((x) << 29) & 0xe0000000)
-
-/* macros for TXRF12 */
-#define PHY_ANALOG_TXRF12_ADDRESS                                                                    0x0000006c
-#define PHY_ANALOG_TXRF12_OFFSET                                                                     0x0000006c
-#define PHY_ANALOG_TXRF12_SPARE12_2_MSB                                                                       7
-#define PHY_ANALOG_TXRF12_SPARE12_2_LSB                                                                       0
-#define PHY_ANALOG_TXRF12_SPARE12_2_MASK                                                             0x000000ff
-#define PHY_ANALOG_TXRF12_SPARE12_2_GET(x)                                            (((x) & 0x000000ff) >> 0)
-#define PHY_ANALOG_TXRF12_SPARE12_1_MSB                                                                       9
-#define PHY_ANALOG_TXRF12_SPARE12_1_LSB                                                                       8
-#define PHY_ANALOG_TXRF12_SPARE12_1_MASK                                                             0x00000300
-#define PHY_ANALOG_TXRF12_SPARE12_1_GET(x)                                            (((x) & 0x00000300) >> 8)
-#define PHY_ANALOG_TXRF12_SPARE12_1_SET(x)                                            (((x) << 8) & 0x00000300)
-#define PHY_ANALOG_TXRF12_ATBSEL5G_MSB                                                                       13
-#define PHY_ANALOG_TXRF12_ATBSEL5G_LSB                                                                       10
-#define PHY_ANALOG_TXRF12_ATBSEL5G_MASK                                                              0x00003c00
-#define PHY_ANALOG_TXRF12_ATBSEL5G_GET(x)                                            (((x) & 0x00003c00) >> 10)
-#define PHY_ANALOG_TXRF12_ATBSEL5G_SET(x)                                            (((x) << 10) & 0x00003c00)
-#define PHY_ANALOG_TXRF12_ATBSEL2G_MSB                                                                       16
-#define PHY_ANALOG_TXRF12_ATBSEL2G_LSB                                                                       14
-#define PHY_ANALOG_TXRF12_ATBSEL2G_MASK                                                              0x0001c000
-#define PHY_ANALOG_TXRF12_ATBSEL2G_GET(x)                                            (((x) & 0x0001c000) >> 14)
-#define PHY_ANALOG_TXRF12_ATBSEL2G_SET(x)                                            (((x) << 14) & 0x0001c000)
-#define PHY_ANALOG_TXRF12_PWD_IRSPARE_MSB                                                                    19
-#define PHY_ANALOG_TXRF12_PWD_IRSPARE_LSB                                                                    17
-#define PHY_ANALOG_TXRF12_PWD_IRSPARE_MASK                                                           0x000e0000
-#define PHY_ANALOG_TXRF12_PWD_IRSPARE_GET(x)                                         (((x) & 0x000e0000) >> 17)
-#define PHY_ANALOG_TXRF12_PWD_IRSPARE_SET(x)                                         (((x) << 17) & 0x000e0000)
-#define PHY_ANALOG_TXRF12_PWD_IR25TEMPSEN_MSB                                                                22
-#define PHY_ANALOG_TXRF12_PWD_IR25TEMPSEN_LSB                                                                20
-#define PHY_ANALOG_TXRF12_PWD_IR25TEMPSEN_MASK                                                       0x00700000
-#define PHY_ANALOG_TXRF12_PWD_IR25TEMPSEN_GET(x)                                     (((x) & 0x00700000) >> 20)
-#define PHY_ANALOG_TXRF12_PWD_IR25TEMPSEN_SET(x)                                     (((x) << 20) & 0x00700000)
-#define PHY_ANALOG_TXRF12_PWD_IR25PA5G2_MSB                                                                  25
-#define PHY_ANALOG_TXRF12_PWD_IR25PA5G2_LSB                                                                  23
-#define PHY_ANALOG_TXRF12_PWD_IR25PA5G2_MASK                                                         0x03800000
-#define PHY_ANALOG_TXRF12_PWD_IR25PA5G2_GET(x)                                       (((x) & 0x03800000) >> 23)
-#define PHY_ANALOG_TXRF12_PWD_IR25PA5G2_SET(x)                                       (((x) << 23) & 0x03800000)
-#define PHY_ANALOG_TXRF12_PWD_IR25PA5G1_MSB                                                                  28
-#define PHY_ANALOG_TXRF12_PWD_IR25PA5G1_LSB                                                                  26
-#define PHY_ANALOG_TXRF12_PWD_IR25PA5G1_MASK                                                         0x1c000000
-#define PHY_ANALOG_TXRF12_PWD_IR25PA5G1_GET(x)                                       (((x) & 0x1c000000) >> 26)
-#define PHY_ANALOG_TXRF12_PWD_IR25PA5G1_SET(x)                                       (((x) << 26) & 0x1c000000)
-#define PHY_ANALOG_TXRF12_PWD_IR25MIXBIAS5G_MSB                                                              31
-#define PHY_ANALOG_TXRF12_PWD_IR25MIXBIAS5G_LSB                                                              29
-#define PHY_ANALOG_TXRF12_PWD_IR25MIXBIAS5G_MASK                                                     0xe0000000
-#define PHY_ANALOG_TXRF12_PWD_IR25MIXBIAS5G_GET(x)                                   (((x) & 0xe0000000) >> 29)
-#define PHY_ANALOG_TXRF12_PWD_IR25MIXBIAS5G_SET(x)                                   (((x) << 29) & 0xe0000000)
-
-/* macros for SYNTH1 */
-#define PHY_ANALOG_SYNTH1_ADDRESS                                                                    0x00000080
-#define PHY_ANALOG_SYNTH1_OFFSET                                                                     0x00000080
-#define PHY_ANALOG_SYNTH1_SEL_VCMONABUS_MSB                                                                   2
-#define PHY_ANALOG_SYNTH1_SEL_VCMONABUS_LSB                                                                   0
-#define PHY_ANALOG_SYNTH1_SEL_VCMONABUS_MASK                                                         0x00000007
-#define PHY_ANALOG_SYNTH1_SEL_VCMONABUS_GET(x)                                        (((x) & 0x00000007) >> 0)
-#define PHY_ANALOG_SYNTH1_SEL_VCMONABUS_SET(x)                                        (((x) << 0) & 0x00000007)
-#define PHY_ANALOG_SYNTH1_SEL_VCOABUS_MSB                                                                     5
-#define PHY_ANALOG_SYNTH1_SEL_VCOABUS_LSB                                                                     3
-#define PHY_ANALOG_SYNTH1_SEL_VCOABUS_MASK                                                           0x00000038
-#define PHY_ANALOG_SYNTH1_SEL_VCOABUS_GET(x)                                          (((x) & 0x00000038) >> 3)
-#define PHY_ANALOG_SYNTH1_SEL_VCOABUS_SET(x)                                          (((x) << 3) & 0x00000038)
-#define PHY_ANALOG_SYNTH1_MONITOR_SYNTHLOCKVCOK_MSB                                                           6
-#define PHY_ANALOG_SYNTH1_MONITOR_SYNTHLOCKVCOK_LSB                                                           6
-#define PHY_ANALOG_SYNTH1_MONITOR_SYNTHLOCKVCOK_MASK                                                 0x00000040
-#define PHY_ANALOG_SYNTH1_MONITOR_SYNTHLOCKVCOK_GET(x)                                (((x) & 0x00000040) >> 6)
-#define PHY_ANALOG_SYNTH1_MONITOR_SYNTHLOCKVCOK_SET(x)                                (((x) << 6) & 0x00000040)
-#define PHY_ANALOG_SYNTH1_MONITOR_VC2LOW_MSB                                                                  7
-#define PHY_ANALOG_SYNTH1_MONITOR_VC2LOW_LSB                                                                  7
-#define PHY_ANALOG_SYNTH1_MONITOR_VC2LOW_MASK                                                        0x00000080
-#define PHY_ANALOG_SYNTH1_MONITOR_VC2LOW_GET(x)                                       (((x) & 0x00000080) >> 7)
-#define PHY_ANALOG_SYNTH1_MONITOR_VC2LOW_SET(x)                                       (((x) << 7) & 0x00000080)
-#define PHY_ANALOG_SYNTH1_MONITOR_VC2HIGH_MSB                                                                 8
-#define PHY_ANALOG_SYNTH1_MONITOR_VC2HIGH_LSB                                                                 8
-#define PHY_ANALOG_SYNTH1_MONITOR_VC2HIGH_MASK                                                       0x00000100
-#define PHY_ANALOG_SYNTH1_MONITOR_VC2HIGH_GET(x)                                      (((x) & 0x00000100) >> 8)
-#define PHY_ANALOG_SYNTH1_MONITOR_VC2HIGH_SET(x)                                      (((x) << 8) & 0x00000100)
-#define PHY_ANALOG_SYNTH1_MONITOR_FB_DIV2_MSB                                                                 9
-#define PHY_ANALOG_SYNTH1_MONITOR_FB_DIV2_LSB                                                                 9
-#define PHY_ANALOG_SYNTH1_MONITOR_FB_DIV2_MASK                                                       0x00000200
-#define PHY_ANALOG_SYNTH1_MONITOR_FB_DIV2_GET(x)                                      (((x) & 0x00000200) >> 9)
-#define PHY_ANALOG_SYNTH1_MONITOR_FB_DIV2_SET(x)                                      (((x) << 9) & 0x00000200)
-#define PHY_ANALOG_SYNTH1_MONITOR_REF_MSB                                                                    10
-#define PHY_ANALOG_SYNTH1_MONITOR_REF_LSB                                                                    10
-#define PHY_ANALOG_SYNTH1_MONITOR_REF_MASK                                                           0x00000400
-#define PHY_ANALOG_SYNTH1_MONITOR_REF_GET(x)                                         (((x) & 0x00000400) >> 10)
-#define PHY_ANALOG_SYNTH1_MONITOR_REF_SET(x)                                         (((x) << 10) & 0x00000400)
-#define PHY_ANALOG_SYNTH1_MONITOR_FB_MSB                                                                     11
-#define PHY_ANALOG_SYNTH1_MONITOR_FB_LSB                                                                     11
-#define PHY_ANALOG_SYNTH1_MONITOR_FB_MASK                                                            0x00000800
-#define PHY_ANALOG_SYNTH1_MONITOR_FB_GET(x)                                          (((x) & 0x00000800) >> 11)
-#define PHY_ANALOG_SYNTH1_MONITOR_FB_SET(x)                                          (((x) << 11) & 0x00000800)
-#define PHY_ANALOG_SYNTH1_SEVENBITVCOCAP_MSB                                                                 12
-#define PHY_ANALOG_SYNTH1_SEVENBITVCOCAP_LSB                                                                 12
-#define PHY_ANALOG_SYNTH1_SEVENBITVCOCAP_MASK                                                        0x00001000
-#define PHY_ANALOG_SYNTH1_SEVENBITVCOCAP_GET(x)                                      (((x) & 0x00001000) >> 12)
-#define PHY_ANALOG_SYNTH1_SEVENBITVCOCAP_SET(x)                                      (((x) << 12) & 0x00001000)
-#define PHY_ANALOG_SYNTH1_PWUP_PD_MSB                                                                        15
-#define PHY_ANALOG_SYNTH1_PWUP_PD_LSB                                                                        13
-#define PHY_ANALOG_SYNTH1_PWUP_PD_MASK                                                               0x0000e000
-#define PHY_ANALOG_SYNTH1_PWUP_PD_GET(x)                                             (((x) & 0x0000e000) >> 13)
-#define PHY_ANALOG_SYNTH1_PWUP_PD_SET(x)                                             (((x) << 13) & 0x0000e000)
-#define PHY_ANALOG_SYNTH1_PWD_VCOBUF_MSB                                                                     16
-#define PHY_ANALOG_SYNTH1_PWD_VCOBUF_LSB                                                                     16
-#define PHY_ANALOG_SYNTH1_PWD_VCOBUF_MASK                                                            0x00010000
-#define PHY_ANALOG_SYNTH1_PWD_VCOBUF_GET(x)                                          (((x) & 0x00010000) >> 16)
-#define PHY_ANALOG_SYNTH1_PWD_VCOBUF_SET(x)                                          (((x) << 16) & 0x00010000)
-#define PHY_ANALOG_SYNTH1_VCOBUFGAIN_MSB                                                                     18
-#define PHY_ANALOG_SYNTH1_VCOBUFGAIN_LSB                                                                     17
-#define PHY_ANALOG_SYNTH1_VCOBUFGAIN_MASK                                                            0x00060000
-#define PHY_ANALOG_SYNTH1_VCOBUFGAIN_GET(x)                                          (((x) & 0x00060000) >> 17)
-#define PHY_ANALOG_SYNTH1_VCOBUFGAIN_SET(x)                                          (((x) << 17) & 0x00060000)
-#define PHY_ANALOG_SYNTH1_VCOREGLEVEL_MSB                                                                    20
-#define PHY_ANALOG_SYNTH1_VCOREGLEVEL_LSB                                                                    19
-#define PHY_ANALOG_SYNTH1_VCOREGLEVEL_MASK                                                           0x00180000
-#define PHY_ANALOG_SYNTH1_VCOREGLEVEL_GET(x)                                         (((x) & 0x00180000) >> 19)
-#define PHY_ANALOG_SYNTH1_VCOREGLEVEL_SET(x)                                         (((x) << 19) & 0x00180000)
-#define PHY_ANALOG_SYNTH1_VCOREGBYPASS_MSB                                                                   21
-#define PHY_ANALOG_SYNTH1_VCOREGBYPASS_LSB                                                                   21
-#define PHY_ANALOG_SYNTH1_VCOREGBYPASS_MASK                                                          0x00200000
-#define PHY_ANALOG_SYNTH1_VCOREGBYPASS_GET(x)                                        (((x) & 0x00200000) >> 21)
-#define PHY_ANALOG_SYNTH1_VCOREGBYPASS_SET(x)                                        (((x) << 21) & 0x00200000)
-#define PHY_ANALOG_SYNTH1_PWUP_LOREF_MSB                                                                     22
-#define PHY_ANALOG_SYNTH1_PWUP_LOREF_LSB                                                                     22
-#define PHY_ANALOG_SYNTH1_PWUP_LOREF_MASK                                                            0x00400000
-#define PHY_ANALOG_SYNTH1_PWUP_LOREF_GET(x)                                          (((x) & 0x00400000) >> 22)
-#define PHY_ANALOG_SYNTH1_PWUP_LOREF_SET(x)                                          (((x) << 22) & 0x00400000)
-#define PHY_ANALOG_SYNTH1_PWD_LOMIX_MSB                                                                      23
-#define PHY_ANALOG_SYNTH1_PWD_LOMIX_LSB                                                                      23
-#define PHY_ANALOG_SYNTH1_PWD_LOMIX_MASK                                                             0x00800000
-#define PHY_ANALOG_SYNTH1_PWD_LOMIX_GET(x)                                           (((x) & 0x00800000) >> 23)
-#define PHY_ANALOG_SYNTH1_PWD_LOMIX_SET(x)                                           (((x) << 23) & 0x00800000)
-#define PHY_ANALOG_SYNTH1_PWD_LODIV_MSB                                                                      24
-#define PHY_ANALOG_SYNTH1_PWD_LODIV_LSB                                                                      24
-#define PHY_ANALOG_SYNTH1_PWD_LODIV_MASK                                                             0x01000000
-#define PHY_ANALOG_SYNTH1_PWD_LODIV_GET(x)                                           (((x) & 0x01000000) >> 24)
-#define PHY_ANALOG_SYNTH1_PWD_LODIV_SET(x)                                           (((x) << 24) & 0x01000000)
-#define PHY_ANALOG_SYNTH1_PWD_LOBUF5G_MSB                                                                    25
-#define PHY_ANALOG_SYNTH1_PWD_LOBUF5G_LSB                                                                    25
-#define PHY_ANALOG_SYNTH1_PWD_LOBUF5G_MASK                                                           0x02000000
-#define PHY_ANALOG_SYNTH1_PWD_LOBUF5G_GET(x)                                         (((x) & 0x02000000) >> 25)
-#define PHY_ANALOG_SYNTH1_PWD_LOBUF5G_SET(x)                                         (((x) << 25) & 0x02000000)
-#define PHY_ANALOG_SYNTH1_PWD_LOBUF2G_MSB                                                                    26
-#define PHY_ANALOG_SYNTH1_PWD_LOBUF2G_LSB                                                                    26
-#define PHY_ANALOG_SYNTH1_PWD_LOBUF2G_MASK                                                           0x04000000
-#define PHY_ANALOG_SYNTH1_PWD_LOBUF2G_GET(x)                                         (((x) & 0x04000000) >> 26)
-#define PHY_ANALOG_SYNTH1_PWD_LOBUF2G_SET(x)                                         (((x) << 26) & 0x04000000)
-#define PHY_ANALOG_SYNTH1_PWD_PRESC_MSB                                                                      27
-#define PHY_ANALOG_SYNTH1_PWD_PRESC_LSB                                                                      27
-#define PHY_ANALOG_SYNTH1_PWD_PRESC_MASK                                                             0x08000000
-#define PHY_ANALOG_SYNTH1_PWD_PRESC_GET(x)                                           (((x) & 0x08000000) >> 27)
-#define PHY_ANALOG_SYNTH1_PWD_PRESC_SET(x)                                           (((x) << 27) & 0x08000000)
-#define PHY_ANALOG_SYNTH1_PWD_VCO_MSB                                                                        28
-#define PHY_ANALOG_SYNTH1_PWD_VCO_LSB                                                                        28
-#define PHY_ANALOG_SYNTH1_PWD_VCO_MASK                                                               0x10000000
-#define PHY_ANALOG_SYNTH1_PWD_VCO_GET(x)                                             (((x) & 0x10000000) >> 28)
-#define PHY_ANALOG_SYNTH1_PWD_VCO_SET(x)                                             (((x) << 28) & 0x10000000)
-#define PHY_ANALOG_SYNTH1_PWD_VCMON_MSB                                                                      29
-#define PHY_ANALOG_SYNTH1_PWD_VCMON_LSB                                                                      29
-#define PHY_ANALOG_SYNTH1_PWD_VCMON_MASK                                                             0x20000000
-#define PHY_ANALOG_SYNTH1_PWD_VCMON_GET(x)                                           (((x) & 0x20000000) >> 29)
-#define PHY_ANALOG_SYNTH1_PWD_VCMON_SET(x)                                           (((x) << 29) & 0x20000000)
-#define PHY_ANALOG_SYNTH1_PWD_CP_MSB                                                                         30
-#define PHY_ANALOG_SYNTH1_PWD_CP_LSB                                                                         30
-#define PHY_ANALOG_SYNTH1_PWD_CP_MASK                                                                0x40000000
-#define PHY_ANALOG_SYNTH1_PWD_CP_GET(x)                                              (((x) & 0x40000000) >> 30)
-#define PHY_ANALOG_SYNTH1_PWD_CP_SET(x)                                              (((x) << 30) & 0x40000000)
-#define PHY_ANALOG_SYNTH1_PWD_BIAS_MSB                                                                       31
-#define PHY_ANALOG_SYNTH1_PWD_BIAS_LSB                                                                       31
-#define PHY_ANALOG_SYNTH1_PWD_BIAS_MASK                                                              0x80000000
-#define PHY_ANALOG_SYNTH1_PWD_BIAS_GET(x)                                            (((x) & 0x80000000) >> 31)
-#define PHY_ANALOG_SYNTH1_PWD_BIAS_SET(x)                                            (((x) << 31) & 0x80000000)
-
-/* macros for SYNTH2 */
-#define PHY_ANALOG_SYNTH2_ADDRESS                                                                    0x00000084
-#define PHY_ANALOG_SYNTH2_OFFSET                                                                     0x00000084
-#define PHY_ANALOG_SYNTH2_CAPRANGE3_MSB                                                                       3
-#define PHY_ANALOG_SYNTH2_CAPRANGE3_LSB                                                                       0
-#define PHY_ANALOG_SYNTH2_CAPRANGE3_MASK                                                             0x0000000f
-#define PHY_ANALOG_SYNTH2_CAPRANGE3_GET(x)                                            (((x) & 0x0000000f) >> 0)
-#define PHY_ANALOG_SYNTH2_CAPRANGE3_SET(x)                                            (((x) << 0) & 0x0000000f)
-#define PHY_ANALOG_SYNTH2_CAPRANGE2_MSB                                                                       7
-#define PHY_ANALOG_SYNTH2_CAPRANGE2_LSB                                                                       4
-#define PHY_ANALOG_SYNTH2_CAPRANGE2_MASK                                                             0x000000f0
-#define PHY_ANALOG_SYNTH2_CAPRANGE2_GET(x)                                            (((x) & 0x000000f0) >> 4)
-#define PHY_ANALOG_SYNTH2_CAPRANGE2_SET(x)                                            (((x) << 4) & 0x000000f0)
-#define PHY_ANALOG_SYNTH2_CAPRANGE1_MSB                                                                      11
-#define PHY_ANALOG_SYNTH2_CAPRANGE1_LSB                                                                       8
-#define PHY_ANALOG_SYNTH2_CAPRANGE1_MASK                                                             0x00000f00
-#define PHY_ANALOG_SYNTH2_CAPRANGE1_GET(x)                                            (((x) & 0x00000f00) >> 8)
-#define PHY_ANALOG_SYNTH2_CAPRANGE1_SET(x)                                            (((x) << 8) & 0x00000f00)
-#define PHY_ANALOG_SYNTH2_LOOPLEAKCUR_INTN_MSB                                                               15
-#define PHY_ANALOG_SYNTH2_LOOPLEAKCUR_INTN_LSB                                                               12
-#define PHY_ANALOG_SYNTH2_LOOPLEAKCUR_INTN_MASK                                                      0x0000f000
-#define PHY_ANALOG_SYNTH2_LOOPLEAKCUR_INTN_GET(x)                                    (((x) & 0x0000f000) >> 12)
-#define PHY_ANALOG_SYNTH2_LOOPLEAKCUR_INTN_SET(x)                                    (((x) << 12) & 0x0000f000)
-#define PHY_ANALOG_SYNTH2_CPLOWLK_INTN_MSB                                                                   16
-#define PHY_ANALOG_SYNTH2_CPLOWLK_INTN_LSB                                                                   16
-#define PHY_ANALOG_SYNTH2_CPLOWLK_INTN_MASK                                                          0x00010000
-#define PHY_ANALOG_SYNTH2_CPLOWLK_INTN_GET(x)                                        (((x) & 0x00010000) >> 16)
-#define PHY_ANALOG_SYNTH2_CPLOWLK_INTN_SET(x)                                        (((x) << 16) & 0x00010000)
-#define PHY_ANALOG_SYNTH2_CPSTEERING_EN_INTN_MSB                                                             17
-#define PHY_ANALOG_SYNTH2_CPSTEERING_EN_INTN_LSB                                                             17
-#define PHY_ANALOG_SYNTH2_CPSTEERING_EN_INTN_MASK                                                    0x00020000
-#define PHY_ANALOG_SYNTH2_CPSTEERING_EN_INTN_GET(x)                                  (((x) & 0x00020000) >> 17)
-#define PHY_ANALOG_SYNTH2_CPSTEERING_EN_INTN_SET(x)                                  (((x) << 17) & 0x00020000)
-#define PHY_ANALOG_SYNTH2_CPBIAS_INTN_MSB                                                                    19
-#define PHY_ANALOG_SYNTH2_CPBIAS_INTN_LSB                                                                    18
-#define PHY_ANALOG_SYNTH2_CPBIAS_INTN_MASK                                                           0x000c0000
-#define PHY_ANALOG_SYNTH2_CPBIAS_INTN_GET(x)                                         (((x) & 0x000c0000) >> 18)
-#define PHY_ANALOG_SYNTH2_CPBIAS_INTN_SET(x)                                         (((x) << 18) & 0x000c0000)
-#define PHY_ANALOG_SYNTH2_VC_LOW_REF_MSB                                                                     22
-#define PHY_ANALOG_SYNTH2_VC_LOW_REF_LSB                                                                     20
-#define PHY_ANALOG_SYNTH2_VC_LOW_REF_MASK                                                            0x00700000
-#define PHY_ANALOG_SYNTH2_VC_LOW_REF_GET(x)                                          (((x) & 0x00700000) >> 20)
-#define PHY_ANALOG_SYNTH2_VC_LOW_REF_SET(x)                                          (((x) << 20) & 0x00700000)
-#define PHY_ANALOG_SYNTH2_VC_MID_REF_MSB                                                                     25
-#define PHY_ANALOG_SYNTH2_VC_MID_REF_LSB                                                                     23
-#define PHY_ANALOG_SYNTH2_VC_MID_REF_MASK                                                            0x03800000
-#define PHY_ANALOG_SYNTH2_VC_MID_REF_GET(x)                                          (((x) & 0x03800000) >> 23)
-#define PHY_ANALOG_SYNTH2_VC_MID_REF_SET(x)                                          (((x) << 23) & 0x03800000)
-#define PHY_ANALOG_SYNTH2_VC_HI_REF_MSB                                                                      28
-#define PHY_ANALOG_SYNTH2_VC_HI_REF_LSB                                                                      26
-#define PHY_ANALOG_SYNTH2_VC_HI_REF_MASK                                                             0x1c000000
-#define PHY_ANALOG_SYNTH2_VC_HI_REF_GET(x)                                           (((x) & 0x1c000000) >> 26)
-#define PHY_ANALOG_SYNTH2_VC_HI_REF_SET(x)                                           (((x) << 26) & 0x1c000000)
-#define PHY_ANALOG_SYNTH2_VC_CAL_REF_MSB                                                                     31
-#define PHY_ANALOG_SYNTH2_VC_CAL_REF_LSB                                                                     29
-#define PHY_ANALOG_SYNTH2_VC_CAL_REF_MASK                                                            0xe0000000
-#define PHY_ANALOG_SYNTH2_VC_CAL_REF_GET(x)                                          (((x) & 0xe0000000) >> 29)
-#define PHY_ANALOG_SYNTH2_VC_CAL_REF_SET(x)                                          (((x) << 29) & 0xe0000000)
-
-/* macros for SYNTH3 */
-#define PHY_ANALOG_SYNTH3_ADDRESS                                                                    0x00000088
-#define PHY_ANALOG_SYNTH3_OFFSET                                                                     0x00000088
-#define PHY_ANALOG_SYNTH3_WAIT_VC_CHECK_MSB                                                                   5
-#define PHY_ANALOG_SYNTH3_WAIT_VC_CHECK_LSB                                                                   0
-#define PHY_ANALOG_SYNTH3_WAIT_VC_CHECK_MASK                                                         0x0000003f
-#define PHY_ANALOG_SYNTH3_WAIT_VC_CHECK_GET(x)                                        (((x) & 0x0000003f) >> 0)
-#define PHY_ANALOG_SYNTH3_WAIT_VC_CHECK_SET(x)                                        (((x) << 0) & 0x0000003f)
-#define PHY_ANALOG_SYNTH3_WAIT_CAL_LIN_MSB                                                                   11
-#define PHY_ANALOG_SYNTH3_WAIT_CAL_LIN_LSB                                                                    6
-#define PHY_ANALOG_SYNTH3_WAIT_CAL_LIN_MASK                                                          0x00000fc0
-#define PHY_ANALOG_SYNTH3_WAIT_CAL_LIN_GET(x)                                         (((x) & 0x00000fc0) >> 6)
-#define PHY_ANALOG_SYNTH3_WAIT_CAL_LIN_SET(x)                                         (((x) << 6) & 0x00000fc0)
-#define PHY_ANALOG_SYNTH3_WAIT_CAL_BIN_MSB                                                                   17
-#define PHY_ANALOG_SYNTH3_WAIT_CAL_BIN_LSB                                                                   12
-#define PHY_ANALOG_SYNTH3_WAIT_CAL_BIN_MASK                                                          0x0003f000
-#define PHY_ANALOG_SYNTH3_WAIT_CAL_BIN_GET(x)                                        (((x) & 0x0003f000) >> 12)
-#define PHY_ANALOG_SYNTH3_WAIT_CAL_BIN_SET(x)                                        (((x) << 12) & 0x0003f000)
-#define PHY_ANALOG_SYNTH3_WAIT_PWRUP_MSB                                                                     23
-#define PHY_ANALOG_SYNTH3_WAIT_PWRUP_LSB                                                                     18
-#define PHY_ANALOG_SYNTH3_WAIT_PWRUP_MASK                                                            0x00fc0000
-#define PHY_ANALOG_SYNTH3_WAIT_PWRUP_GET(x)                                          (((x) & 0x00fc0000) >> 18)
-#define PHY_ANALOG_SYNTH3_WAIT_PWRUP_SET(x)                                          (((x) << 18) & 0x00fc0000)
-#define PHY_ANALOG_SYNTH3_WAIT_SHORTR_PWRUP_MSB                                                              29
-#define PHY_ANALOG_SYNTH3_WAIT_SHORTR_PWRUP_LSB                                                              24
-#define PHY_ANALOG_SYNTH3_WAIT_SHORTR_PWRUP_MASK                                                     0x3f000000
-#define PHY_ANALOG_SYNTH3_WAIT_SHORTR_PWRUP_GET(x)                                   (((x) & 0x3f000000) >> 24)
-#define PHY_ANALOG_SYNTH3_WAIT_SHORTR_PWRUP_SET(x)                                   (((x) << 24) & 0x3f000000)
-#define PHY_ANALOG_SYNTH3_SEL_CLK_DIV2_MSB                                                                   30
-#define PHY_ANALOG_SYNTH3_SEL_CLK_DIV2_LSB                                                                   30
-#define PHY_ANALOG_SYNTH3_SEL_CLK_DIV2_MASK                                                          0x40000000
-#define PHY_ANALOG_SYNTH3_SEL_CLK_DIV2_GET(x)                                        (((x) & 0x40000000) >> 30)
-#define PHY_ANALOG_SYNTH3_SEL_CLK_DIV2_SET(x)                                        (((x) << 30) & 0x40000000)
-#define PHY_ANALOG_SYNTH3_DIS_CLK_XTAL_MSB                                                                   31
-#define PHY_ANALOG_SYNTH3_DIS_CLK_XTAL_LSB                                                                   31
-#define PHY_ANALOG_SYNTH3_DIS_CLK_XTAL_MASK                                                          0x80000000
-#define PHY_ANALOG_SYNTH3_DIS_CLK_XTAL_GET(x)                                        (((x) & 0x80000000) >> 31)
-#define PHY_ANALOG_SYNTH3_DIS_CLK_XTAL_SET(x)                                        (((x) << 31) & 0x80000000)
-
-/* macros for SYNTH4 */
-#define PHY_ANALOG_SYNTH4_ADDRESS                                                                    0x0000008c
-#define PHY_ANALOG_SYNTH4_OFFSET                                                                     0x0000008c
-#define PHY_ANALOG_SYNTH4_PS_SINGLE_PULSE_MSB                                                                 0
-#define PHY_ANALOG_SYNTH4_PS_SINGLE_PULSE_LSB                                                                 0
-#define PHY_ANALOG_SYNTH4_PS_SINGLE_PULSE_MASK                                                       0x00000001
-#define PHY_ANALOG_SYNTH4_PS_SINGLE_PULSE_GET(x)                                      (((x) & 0x00000001) >> 0)
-#define PHY_ANALOG_SYNTH4_PS_SINGLE_PULSE_SET(x)                                      (((x) << 0) & 0x00000001)
-#define PHY_ANALOG_SYNTH4_LONGSHIFTSEL_MSB                                                                    1
-#define PHY_ANALOG_SYNTH4_LONGSHIFTSEL_LSB                                                                    1
-#define PHY_ANALOG_SYNTH4_LONGSHIFTSEL_MASK                                                          0x00000002
-#define PHY_ANALOG_SYNTH4_LONGSHIFTSEL_GET(x)                                         (((x) & 0x00000002) >> 1)
-#define PHY_ANALOG_SYNTH4_LONGSHIFTSEL_SET(x)                                         (((x) << 1) & 0x00000002)
-#define PHY_ANALOG_SYNTH4_LOBUF5GTUNE_OVR_MSB                                                                 3
-#define PHY_ANALOG_SYNTH4_LOBUF5GTUNE_OVR_LSB                                                                 2
-#define PHY_ANALOG_SYNTH4_LOBUF5GTUNE_OVR_MASK                                                       0x0000000c
-#define PHY_ANALOG_SYNTH4_LOBUF5GTUNE_OVR_GET(x)                                      (((x) & 0x0000000c) >> 2)
-#define PHY_ANALOG_SYNTH4_LOBUF5GTUNE_OVR_SET(x)                                      (((x) << 2) & 0x0000000c)
-#define PHY_ANALOG_SYNTH4_FORCE_LOBUF5GTUNE_MSB                                                               4
-#define PHY_ANALOG_SYNTH4_FORCE_LOBUF5GTUNE_LSB                                                               4
-#define PHY_ANALOG_SYNTH4_FORCE_LOBUF5GTUNE_MASK                                                     0x00000010
-#define PHY_ANALOG_SYNTH4_FORCE_LOBUF5GTUNE_GET(x)                                    (((x) & 0x00000010) >> 4)
-#define PHY_ANALOG_SYNTH4_FORCE_LOBUF5GTUNE_SET(x)                                    (((x) << 4) & 0x00000010)
-#define PHY_ANALOG_SYNTH4_PSCOUNT_FBSEL_MSB                                                                   5
-#define PHY_ANALOG_SYNTH4_PSCOUNT_FBSEL_LSB                                                                   5
-#define PHY_ANALOG_SYNTH4_PSCOUNT_FBSEL_MASK                                                         0x00000020
-#define PHY_ANALOG_SYNTH4_PSCOUNT_FBSEL_GET(x)                                        (((x) & 0x00000020) >> 5)
-#define PHY_ANALOG_SYNTH4_PSCOUNT_FBSEL_SET(x)                                        (((x) << 5) & 0x00000020)
-#define PHY_ANALOG_SYNTH4_SDM_DITHER1_MSB                                                                     7
-#define PHY_ANALOG_SYNTH4_SDM_DITHER1_LSB                                                                     6
-#define PHY_ANALOG_SYNTH4_SDM_DITHER1_MASK                                                           0x000000c0
-#define PHY_ANALOG_SYNTH4_SDM_DITHER1_GET(x)                                          (((x) & 0x000000c0) >> 6)
-#define PHY_ANALOG_SYNTH4_SDM_DITHER1_SET(x)                                          (((x) << 6) & 0x000000c0)
-#define PHY_ANALOG_SYNTH4_SDM_MODE_MSB                                                                        8
-#define PHY_ANALOG_SYNTH4_SDM_MODE_LSB                                                                        8
-#define PHY_ANALOG_SYNTH4_SDM_MODE_MASK                                                              0x00000100
-#define PHY_ANALOG_SYNTH4_SDM_MODE_GET(x)                                             (((x) & 0x00000100) >> 8)
-#define PHY_ANALOG_SYNTH4_SDM_MODE_SET(x)                                             (((x) << 8) & 0x00000100)
-#define PHY_ANALOG_SYNTH4_SDM_DISABLE_MSB                                                                     9
-#define PHY_ANALOG_SYNTH4_SDM_DISABLE_LSB                                                                     9
-#define PHY_ANALOG_SYNTH4_SDM_DISABLE_MASK                                                           0x00000200
-#define PHY_ANALOG_SYNTH4_SDM_DISABLE_GET(x)                                          (((x) & 0x00000200) >> 9)
-#define PHY_ANALOG_SYNTH4_SDM_DISABLE_SET(x)                                          (((x) << 9) & 0x00000200)
-#define PHY_ANALOG_SYNTH4_RESET_PRESC_MSB                                                                    10
-#define PHY_ANALOG_SYNTH4_RESET_PRESC_LSB                                                                    10
-#define PHY_ANALOG_SYNTH4_RESET_PRESC_MASK                                                           0x00000400
-#define PHY_ANALOG_SYNTH4_RESET_PRESC_GET(x)                                         (((x) & 0x00000400) >> 10)
-#define PHY_ANALOG_SYNTH4_RESET_PRESC_SET(x)                                         (((x) << 10) & 0x00000400)
-#define PHY_ANALOG_SYNTH4_PRESCSEL_MSB                                                                       12
-#define PHY_ANALOG_SYNTH4_PRESCSEL_LSB                                                                       11
-#define PHY_ANALOG_SYNTH4_PRESCSEL_MASK                                                              0x00001800
-#define PHY_ANALOG_SYNTH4_PRESCSEL_GET(x)                                            (((x) & 0x00001800) >> 11)
-#define PHY_ANALOG_SYNTH4_PRESCSEL_SET(x)                                            (((x) << 11) & 0x00001800)
-#define PHY_ANALOG_SYNTH4_PFD_DISABLE_MSB                                                                    13
-#define PHY_ANALOG_SYNTH4_PFD_DISABLE_LSB                                                                    13
-#define PHY_ANALOG_SYNTH4_PFD_DISABLE_MASK                                                           0x00002000
-#define PHY_ANALOG_SYNTH4_PFD_DISABLE_GET(x)                                         (((x) & 0x00002000) >> 13)
-#define PHY_ANALOG_SYNTH4_PFD_DISABLE_SET(x)                                         (((x) << 13) & 0x00002000)
-#define PHY_ANALOG_SYNTH4_PFDDELAY_FRACN_MSB                                                                 14
-#define PHY_ANALOG_SYNTH4_PFDDELAY_FRACN_LSB                                                                 14
-#define PHY_ANALOG_SYNTH4_PFDDELAY_FRACN_MASK                                                        0x00004000
-#define PHY_ANALOG_SYNTH4_PFDDELAY_FRACN_GET(x)                                      (((x) & 0x00004000) >> 14)
-#define PHY_ANALOG_SYNTH4_PFDDELAY_FRACN_SET(x)                                      (((x) << 14) & 0x00004000)
-#define PHY_ANALOG_SYNTH4_FORCE_LO_ON_MSB                                                                    15
-#define PHY_ANALOG_SYNTH4_FORCE_LO_ON_LSB                                                                    15
-#define PHY_ANALOG_SYNTH4_FORCE_LO_ON_MASK                                                           0x00008000
-#define PHY_ANALOG_SYNTH4_FORCE_LO_ON_GET(x)                                         (((x) & 0x00008000) >> 15)
-#define PHY_ANALOG_SYNTH4_FORCE_LO_ON_SET(x)                                         (((x) << 15) & 0x00008000)
-#define PHY_ANALOG_SYNTH4_CLKXTAL_EDGE_SEL_MSB                                                               16
-#define PHY_ANALOG_SYNTH4_CLKXTAL_EDGE_SEL_LSB                                                               16
-#define PHY_ANALOG_SYNTH4_CLKXTAL_EDGE_SEL_MASK                                                      0x00010000
-#define PHY_ANALOG_SYNTH4_CLKXTAL_EDGE_SEL_GET(x)                                    (((x) & 0x00010000) >> 16)
-#define PHY_ANALOG_SYNTH4_CLKXTAL_EDGE_SEL_SET(x)                                    (((x) << 16) & 0x00010000)
-#define PHY_ANALOG_SYNTH4_VCOCAPPULLUP_MSB                                                                   17
-#define PHY_ANALOG_SYNTH4_VCOCAPPULLUP_LSB                                                                   17
-#define PHY_ANALOG_SYNTH4_VCOCAPPULLUP_MASK                                                          0x00020000
-#define PHY_ANALOG_SYNTH4_VCOCAPPULLUP_GET(x)                                        (((x) & 0x00020000) >> 17)
-#define PHY_ANALOG_SYNTH4_VCOCAPPULLUP_SET(x)                                        (((x) << 17) & 0x00020000)
-#define PHY_ANALOG_SYNTH4_VCOCAP_OVR_MSB                                                                     25
-#define PHY_ANALOG_SYNTH4_VCOCAP_OVR_LSB                                                                     18
-#define PHY_ANALOG_SYNTH4_VCOCAP_OVR_MASK                                                            0x03fc0000
-#define PHY_ANALOG_SYNTH4_VCOCAP_OVR_GET(x)                                          (((x) & 0x03fc0000) >> 18)
-#define PHY_ANALOG_SYNTH4_VCOCAP_OVR_SET(x)                                          (((x) << 18) & 0x03fc0000)
-#define PHY_ANALOG_SYNTH4_FORCE_VCOCAP_MSB                                                                   26
-#define PHY_ANALOG_SYNTH4_FORCE_VCOCAP_LSB                                                                   26
-#define PHY_ANALOG_SYNTH4_FORCE_VCOCAP_MASK                                                          0x04000000
-#define PHY_ANALOG_SYNTH4_FORCE_VCOCAP_GET(x)                                        (((x) & 0x04000000) >> 26)
-#define PHY_ANALOG_SYNTH4_FORCE_VCOCAP_SET(x)                                        (((x) << 26) & 0x04000000)
-#define PHY_ANALOG_SYNTH4_FORCE_PINVC_MSB                                                                    27
-#define PHY_ANALOG_SYNTH4_FORCE_PINVC_LSB                                                                    27
-#define PHY_ANALOG_SYNTH4_FORCE_PINVC_MASK                                                           0x08000000
-#define PHY_ANALOG_SYNTH4_FORCE_PINVC_GET(x)                                         (((x) & 0x08000000) >> 27)
-#define PHY_ANALOG_SYNTH4_FORCE_PINVC_SET(x)                                         (((x) << 27) & 0x08000000)
-#define PHY_ANALOG_SYNTH4_SHORTR_UNTIL_LOCKED_MSB                                                            28
-#define PHY_ANALOG_SYNTH4_SHORTR_UNTIL_LOCKED_LSB                                                            28
-#define PHY_ANALOG_SYNTH4_SHORTR_UNTIL_LOCKED_MASK                                                   0x10000000
-#define PHY_ANALOG_SYNTH4_SHORTR_UNTIL_LOCKED_GET(x)                                 (((x) & 0x10000000) >> 28)
-#define PHY_ANALOG_SYNTH4_SHORTR_UNTIL_LOCKED_SET(x)                                 (((x) << 28) & 0x10000000)
-#define PHY_ANALOG_SYNTH4_ALWAYS_SHORTR_MSB                                                                  29
-#define PHY_ANALOG_SYNTH4_ALWAYS_SHORTR_LSB                                                                  29
-#define PHY_ANALOG_SYNTH4_ALWAYS_SHORTR_MASK                                                         0x20000000
-#define PHY_ANALOG_SYNTH4_ALWAYS_SHORTR_GET(x)                                       (((x) & 0x20000000) >> 29)
-#define PHY_ANALOG_SYNTH4_ALWAYS_SHORTR_SET(x)                                       (((x) << 29) & 0x20000000)
-#define PHY_ANALOG_SYNTH4_DIS_LOSTVC_MSB                                                                     30
-#define PHY_ANALOG_SYNTH4_DIS_LOSTVC_LSB                                                                     30
-#define PHY_ANALOG_SYNTH4_DIS_LOSTVC_MASK                                                            0x40000000
-#define PHY_ANALOG_SYNTH4_DIS_LOSTVC_GET(x)                                          (((x) & 0x40000000) >> 30)
-#define PHY_ANALOG_SYNTH4_DIS_LOSTVC_SET(x)                                          (((x) << 30) & 0x40000000)
-#define PHY_ANALOG_SYNTH4_DIS_LIN_CAPSEARCH_MSB                                                              31
-#define PHY_ANALOG_SYNTH4_DIS_LIN_CAPSEARCH_LSB                                                              31
-#define PHY_ANALOG_SYNTH4_DIS_LIN_CAPSEARCH_MASK                                                     0x80000000
-#define PHY_ANALOG_SYNTH4_DIS_LIN_CAPSEARCH_GET(x)                                   (((x) & 0x80000000) >> 31)
-#define PHY_ANALOG_SYNTH4_DIS_LIN_CAPSEARCH_SET(x)                                   (((x) << 31) & 0x80000000)
-
-/* macros for SYNTH5 */
-#define PHY_ANALOG_SYNTH5_ADDRESS                                                                    0x00000090
-#define PHY_ANALOG_SYNTH5_OFFSET                                                                     0x00000090
-#define PHY_ANALOG_SYNTH5_VCOBIAS_MSB                                                                         1
-#define PHY_ANALOG_SYNTH5_VCOBIAS_LSB                                                                         0
-#define PHY_ANALOG_SYNTH5_VCOBIAS_MASK                                                               0x00000003
-#define PHY_ANALOG_SYNTH5_VCOBIAS_GET(x)                                              (((x) & 0x00000003) >> 0)
-#define PHY_ANALOG_SYNTH5_VCOBIAS_SET(x)                                              (((x) << 0) & 0x00000003)
-#define PHY_ANALOG_SYNTH5_PWDB_ICLOBUF5G50_MSB                                                                4
-#define PHY_ANALOG_SYNTH5_PWDB_ICLOBUF5G50_LSB                                                                2
-#define PHY_ANALOG_SYNTH5_PWDB_ICLOBUF5G50_MASK                                                      0x0000001c
-#define PHY_ANALOG_SYNTH5_PWDB_ICLOBUF5G50_GET(x)                                     (((x) & 0x0000001c) >> 2)
-#define PHY_ANALOG_SYNTH5_PWDB_ICLOBUF5G50_SET(x)                                     (((x) << 2) & 0x0000001c)
-#define PHY_ANALOG_SYNTH5_PWDB_ICLOBUF2G50_MSB                                                                7
-#define PHY_ANALOG_SYNTH5_PWDB_ICLOBUF2G50_LSB                                                                5
-#define PHY_ANALOG_SYNTH5_PWDB_ICLOBUF2G50_MASK                                                      0x000000e0
-#define PHY_ANALOG_SYNTH5_PWDB_ICLOBUF2G50_GET(x)                                     (((x) & 0x000000e0) >> 5)
-#define PHY_ANALOG_SYNTH5_PWDB_ICLOBUF2G50_SET(x)                                     (((x) << 5) & 0x000000e0)
-#define PHY_ANALOG_SYNTH5_PWDB_ICVCO25_MSB                                                                   10
-#define PHY_ANALOG_SYNTH5_PWDB_ICVCO25_LSB                                                                    8
-#define PHY_ANALOG_SYNTH5_PWDB_ICVCO25_MASK                                                          0x00000700
-#define PHY_ANALOG_SYNTH5_PWDB_ICVCO25_GET(x)                                         (((x) & 0x00000700) >> 8)
-#define PHY_ANALOG_SYNTH5_PWDB_ICVCO25_SET(x)                                         (((x) << 8) & 0x00000700)
-#define PHY_ANALOG_SYNTH5_PWDB_ICVCOREG25_MSB                                                                13
-#define PHY_ANALOG_SYNTH5_PWDB_ICVCOREG25_LSB                                                                11
-#define PHY_ANALOG_SYNTH5_PWDB_ICVCOREG25_MASK                                                       0x00003800
-#define PHY_ANALOG_SYNTH5_PWDB_ICVCOREG25_GET(x)                                     (((x) & 0x00003800) >> 11)
-#define PHY_ANALOG_SYNTH5_PWDB_ICVCOREG25_SET(x)                                     (((x) << 11) & 0x00003800)
-#define PHY_ANALOG_SYNTH5_PWDB_IRVCOREG50_MSB                                                                14
-#define PHY_ANALOG_SYNTH5_PWDB_IRVCOREG50_LSB                                                                14
-#define PHY_ANALOG_SYNTH5_PWDB_IRVCOREG50_MASK                                                       0x00004000
-#define PHY_ANALOG_SYNTH5_PWDB_IRVCOREG50_GET(x)                                     (((x) & 0x00004000) >> 14)
-#define PHY_ANALOG_SYNTH5_PWDB_IRVCOREG50_SET(x)                                     (((x) << 14) & 0x00004000)
-#define PHY_ANALOG_SYNTH5_PWDB_ICLOMIX_MSB                                                                   17
-#define PHY_ANALOG_SYNTH5_PWDB_ICLOMIX_LSB                                                                   15
-#define PHY_ANALOG_SYNTH5_PWDB_ICLOMIX_MASK                                                          0x00038000
-#define PHY_ANALOG_SYNTH5_PWDB_ICLOMIX_GET(x)                                        (((x) & 0x00038000) >> 15)
-#define PHY_ANALOG_SYNTH5_PWDB_ICLOMIX_SET(x)                                        (((x) << 15) & 0x00038000)
-#define PHY_ANALOG_SYNTH5_PWDB_ICLODIV50_MSB                                                                 20
-#define PHY_ANALOG_SYNTH5_PWDB_ICLODIV50_LSB                                                                 18
-#define PHY_ANALOG_SYNTH5_PWDB_ICLODIV50_MASK                                                        0x001c0000
-#define PHY_ANALOG_SYNTH5_PWDB_ICLODIV50_GET(x)                                      (((x) & 0x001c0000) >> 18)
-#define PHY_ANALOG_SYNTH5_PWDB_ICLODIV50_SET(x)                                      (((x) << 18) & 0x001c0000)
-#define PHY_ANALOG_SYNTH5_PWDB_ICPRESC50_MSB                                                                 23
-#define PHY_ANALOG_SYNTH5_PWDB_ICPRESC50_LSB                                                                 21
-#define PHY_ANALOG_SYNTH5_PWDB_ICPRESC50_MASK                                                        0x00e00000
-#define PHY_ANALOG_SYNTH5_PWDB_ICPRESC50_GET(x)                                      (((x) & 0x00e00000) >> 21)
-#define PHY_ANALOG_SYNTH5_PWDB_ICPRESC50_SET(x)                                      (((x) << 21) & 0x00e00000)
-#define PHY_ANALOG_SYNTH5_PWDB_IRVCMON25_MSB                                                                 26
-#define PHY_ANALOG_SYNTH5_PWDB_IRVCMON25_LSB                                                                 24
-#define PHY_ANALOG_SYNTH5_PWDB_IRVCMON25_MASK                                                        0x07000000
-#define PHY_ANALOG_SYNTH5_PWDB_IRVCMON25_GET(x)                                      (((x) & 0x07000000) >> 24)
-#define PHY_ANALOG_SYNTH5_PWDB_IRVCMON25_SET(x)                                      (((x) << 24) & 0x07000000)
-#define PHY_ANALOG_SYNTH5_PWDB_IRPFDCP_MSB                                                                   29
-#define PHY_ANALOG_SYNTH5_PWDB_IRPFDCP_LSB                                                                   27
-#define PHY_ANALOG_SYNTH5_PWDB_IRPFDCP_MASK                                                          0x38000000
-#define PHY_ANALOG_SYNTH5_PWDB_IRPFDCP_GET(x)                                        (((x) & 0x38000000) >> 27)
-#define PHY_ANALOG_SYNTH5_PWDB_IRPFDCP_SET(x)                                        (((x) << 27) & 0x38000000)
-#define PHY_ANALOG_SYNTH5_SDM_DITHER2_MSB                                                                    31
-#define PHY_ANALOG_SYNTH5_SDM_DITHER2_LSB                                                                    30
-#define PHY_ANALOG_SYNTH5_SDM_DITHER2_MASK                                                           0xc0000000
-#define PHY_ANALOG_SYNTH5_SDM_DITHER2_GET(x)                                         (((x) & 0xc0000000) >> 30)
-#define PHY_ANALOG_SYNTH5_SDM_DITHER2_SET(x)                                         (((x) << 30) & 0xc0000000)
-
-/* macros for SYNTH6 */
-#define PHY_ANALOG_SYNTH6_ADDRESS                                                                    0x00000094
-#define PHY_ANALOG_SYNTH6_OFFSET                                                                     0x00000094
-#define PHY_ANALOG_SYNTH6_LOBUF5GTUNE_MSB                                                                     1
-#define PHY_ANALOG_SYNTH6_LOBUF5GTUNE_LSB                                                                     0
-#define PHY_ANALOG_SYNTH6_LOBUF5GTUNE_MASK                                                           0x00000003
-#define PHY_ANALOG_SYNTH6_LOBUF5GTUNE_GET(x)                                          (((x) & 0x00000003) >> 0)
-#define PHY_ANALOG_SYNTH6_LOOP_IP_MSB                                                                         8
-#define PHY_ANALOG_SYNTH6_LOOP_IP_LSB                                                                         2
-#define PHY_ANALOG_SYNTH6_LOOP_IP_MASK                                                               0x000001fc
-#define PHY_ANALOG_SYNTH6_LOOP_IP_GET(x)                                              (((x) & 0x000001fc) >> 2)
-#define PHY_ANALOG_SYNTH6_VC2LOW_MSB                                                                          9
-#define PHY_ANALOG_SYNTH6_VC2LOW_LSB                                                                          9
-#define PHY_ANALOG_SYNTH6_VC2LOW_MASK                                                                0x00000200
-#define PHY_ANALOG_SYNTH6_VC2LOW_GET(x)                                               (((x) & 0x00000200) >> 9)
-#define PHY_ANALOG_SYNTH6_VC2HIGH_MSB                                                                        10
-#define PHY_ANALOG_SYNTH6_VC2HIGH_LSB                                                                        10
-#define PHY_ANALOG_SYNTH6_VC2HIGH_MASK                                                               0x00000400
-#define PHY_ANALOG_SYNTH6_VC2HIGH_GET(x)                                             (((x) & 0x00000400) >> 10)
-#define PHY_ANALOG_SYNTH6_RESET_SDM_B_MSB                                                                    11
-#define PHY_ANALOG_SYNTH6_RESET_SDM_B_LSB                                                                    11
-#define PHY_ANALOG_SYNTH6_RESET_SDM_B_MASK                                                           0x00000800
-#define PHY_ANALOG_SYNTH6_RESET_SDM_B_GET(x)                                         (((x) & 0x00000800) >> 11)
-#define PHY_ANALOG_SYNTH6_RESET_PSCOUNTERS_MSB                                                               12
-#define PHY_ANALOG_SYNTH6_RESET_PSCOUNTERS_LSB                                                               12
-#define PHY_ANALOG_SYNTH6_RESET_PSCOUNTERS_MASK                                                      0x00001000
-#define PHY_ANALOG_SYNTH6_RESET_PSCOUNTERS_GET(x)                                    (((x) & 0x00001000) >> 12)
-#define PHY_ANALOG_SYNTH6_RESET_PFD_MSB                                                                      13
-#define PHY_ANALOG_SYNTH6_RESET_PFD_LSB                                                                      13
-#define PHY_ANALOG_SYNTH6_RESET_PFD_MASK                                                             0x00002000
-#define PHY_ANALOG_SYNTH6_RESET_PFD_GET(x)                                           (((x) & 0x00002000) >> 13)
-#define PHY_ANALOG_SYNTH6_RESET_RFD_MSB                                                                      14
-#define PHY_ANALOG_SYNTH6_RESET_RFD_LSB                                                                      14
-#define PHY_ANALOG_SYNTH6_RESET_RFD_MASK                                                             0x00004000
-#define PHY_ANALOG_SYNTH6_RESET_RFD_GET(x)                                           (((x) & 0x00004000) >> 14)
-#define PHY_ANALOG_SYNTH6_SHORT_R_MSB                                                                        15
-#define PHY_ANALOG_SYNTH6_SHORT_R_LSB                                                                        15
-#define PHY_ANALOG_SYNTH6_SHORT_R_MASK                                                               0x00008000
-#define PHY_ANALOG_SYNTH6_SHORT_R_GET(x)                                             (((x) & 0x00008000) >> 15)
-#define PHY_ANALOG_SYNTH6_VCO_CAP_ST_MSB                                                                     23
-#define PHY_ANALOG_SYNTH6_VCO_CAP_ST_LSB                                                                     16
-#define PHY_ANALOG_SYNTH6_VCO_CAP_ST_MASK                                                            0x00ff0000
-#define PHY_ANALOG_SYNTH6_VCO_CAP_ST_GET(x)                                          (((x) & 0x00ff0000) >> 16)
-#define PHY_ANALOG_SYNTH6_PIN_VC_MSB                                                                         24
-#define PHY_ANALOG_SYNTH6_PIN_VC_LSB                                                                         24
-#define PHY_ANALOG_SYNTH6_PIN_VC_MASK                                                                0x01000000
-#define PHY_ANALOG_SYNTH6_PIN_VC_GET(x)                                              (((x) & 0x01000000) >> 24)
-#define PHY_ANALOG_SYNTH6_SYNTH_LOCK_VC_OK_MSB                                                               25
-#define PHY_ANALOG_SYNTH6_SYNTH_LOCK_VC_OK_LSB                                                               25
-#define PHY_ANALOG_SYNTH6_SYNTH_LOCK_VC_OK_MASK                                                      0x02000000
-#define PHY_ANALOG_SYNTH6_SYNTH_LOCK_VC_OK_GET(x)                                    (((x) & 0x02000000) >> 25)
-#define PHY_ANALOG_SYNTH6_CAP_SEARCH_MSB                                                                     26
-#define PHY_ANALOG_SYNTH6_CAP_SEARCH_LSB                                                                     26
-#define PHY_ANALOG_SYNTH6_CAP_SEARCH_MASK                                                            0x04000000
-#define PHY_ANALOG_SYNTH6_CAP_SEARCH_GET(x)                                          (((x) & 0x04000000) >> 26)
-#define PHY_ANALOG_SYNTH6_SYNTH_SM_STATE_MSB                                                                 30
-#define PHY_ANALOG_SYNTH6_SYNTH_SM_STATE_LSB                                                                 27
-#define PHY_ANALOG_SYNTH6_SYNTH_SM_STATE_MASK                                                        0x78000000
-#define PHY_ANALOG_SYNTH6_SYNTH_SM_STATE_GET(x)                                      (((x) & 0x78000000) >> 27)
-#define PHY_ANALOG_SYNTH6_SYNTH_ON_MSB                                                                       31
-#define PHY_ANALOG_SYNTH6_SYNTH_ON_LSB                                                                       31
-#define PHY_ANALOG_SYNTH6_SYNTH_ON_MASK                                                              0x80000000
-#define PHY_ANALOG_SYNTH6_SYNTH_ON_GET(x)                                            (((x) & 0x80000000) >> 31)
-
-/* macros for SYNTH7 */
-#define PHY_ANALOG_SYNTH7_ADDRESS                                                                    0x00000098
-#define PHY_ANALOG_SYNTH7_OFFSET                                                                     0x00000098
-#define PHY_ANALOG_SYNTH7_OVRCHANDECODER_MSB                                                                  0
-#define PHY_ANALOG_SYNTH7_OVRCHANDECODER_LSB                                                                  0
-#define PHY_ANALOG_SYNTH7_OVRCHANDECODER_MASK                                                        0x00000001
-#define PHY_ANALOG_SYNTH7_OVRCHANDECODER_GET(x)                                       (((x) & 0x00000001) >> 0)
-#define PHY_ANALOG_SYNTH7_OVRCHANDECODER_SET(x)                                       (((x) << 0) & 0x00000001)
-#define PHY_ANALOG_SYNTH7_FORCE_FRACLSB_MSB                                                                   1
-#define PHY_ANALOG_SYNTH7_FORCE_FRACLSB_LSB                                                                   1
-#define PHY_ANALOG_SYNTH7_FORCE_FRACLSB_MASK                                                         0x00000002
-#define PHY_ANALOG_SYNTH7_FORCE_FRACLSB_GET(x)                                        (((x) & 0x00000002) >> 1)
-#define PHY_ANALOG_SYNTH7_FORCE_FRACLSB_SET(x)                                        (((x) << 1) & 0x00000002)
-#define PHY_ANALOG_SYNTH7_CHANFRAC_MSB                                                                       18
-#define PHY_ANALOG_SYNTH7_CHANFRAC_LSB                                                                        2
-#define PHY_ANALOG_SYNTH7_CHANFRAC_MASK                                                              0x0007fffc
-#define PHY_ANALOG_SYNTH7_CHANFRAC_GET(x)                                             (((x) & 0x0007fffc) >> 2)
-#define PHY_ANALOG_SYNTH7_CHANFRAC_SET(x)                                             (((x) << 2) & 0x0007fffc)
-#define PHY_ANALOG_SYNTH7_CHANSEL_MSB                                                                        27
-#define PHY_ANALOG_SYNTH7_CHANSEL_LSB                                                                        19
-#define PHY_ANALOG_SYNTH7_CHANSEL_MASK                                                               0x0ff80000
-#define PHY_ANALOG_SYNTH7_CHANSEL_GET(x)                                             (((x) & 0x0ff80000) >> 19)
-#define PHY_ANALOG_SYNTH7_CHANSEL_SET(x)                                             (((x) << 19) & 0x0ff80000)
-#define PHY_ANALOG_SYNTH7_AMODEREFSEL_MSB                                                                    29
-#define PHY_ANALOG_SYNTH7_AMODEREFSEL_LSB                                                                    28
-#define PHY_ANALOG_SYNTH7_AMODEREFSEL_MASK                                                           0x30000000
-#define PHY_ANALOG_SYNTH7_AMODEREFSEL_GET(x)                                         (((x) & 0x30000000) >> 28)
-#define PHY_ANALOG_SYNTH7_AMODEREFSEL_SET(x)                                         (((x) << 28) & 0x30000000)
-#define PHY_ANALOG_SYNTH7_FRACMODE_MSB                                                                       30
-#define PHY_ANALOG_SYNTH7_FRACMODE_LSB                                                                       30
-#define PHY_ANALOG_SYNTH7_FRACMODE_MASK                                                              0x40000000
-#define PHY_ANALOG_SYNTH7_FRACMODE_GET(x)                                            (((x) & 0x40000000) >> 30)
-#define PHY_ANALOG_SYNTH7_FRACMODE_SET(x)                                            (((x) << 30) & 0x40000000)
-#define PHY_ANALOG_SYNTH7_LOADSYNTHCHANNEL_MSB                                                               31
-#define PHY_ANALOG_SYNTH7_LOADSYNTHCHANNEL_LSB                                                               31
-#define PHY_ANALOG_SYNTH7_LOADSYNTHCHANNEL_MASK                                                      0x80000000
-#define PHY_ANALOG_SYNTH7_LOADSYNTHCHANNEL_GET(x)                                    (((x) & 0x80000000) >> 31)
-#define PHY_ANALOG_SYNTH7_LOADSYNTHCHANNEL_SET(x)                                    (((x) << 31) & 0x80000000)
-
-/* macros for SYNTH8 */
-#define PHY_ANALOG_SYNTH8_ADDRESS                                                                    0x0000009c
-#define PHY_ANALOG_SYNTH8_OFFSET                                                                     0x0000009c
-#define PHY_ANALOG_SYNTH8_CPSTEERING_EN_FRACN_MSB                                                             0
-#define PHY_ANALOG_SYNTH8_CPSTEERING_EN_FRACN_LSB                                                             0
-#define PHY_ANALOG_SYNTH8_CPSTEERING_EN_FRACN_MASK                                                   0x00000001
-#define PHY_ANALOG_SYNTH8_CPSTEERING_EN_FRACN_GET(x)                                  (((x) & 0x00000001) >> 0)
-#define PHY_ANALOG_SYNTH8_CPSTEERING_EN_FRACN_SET(x)                                  (((x) << 0) & 0x00000001)
-#define PHY_ANALOG_SYNTH8_LOOP_ICPB_MSB                                                                       7
-#define PHY_ANALOG_SYNTH8_LOOP_ICPB_LSB                                                                       1
-#define PHY_ANALOG_SYNTH8_LOOP_ICPB_MASK                                                             0x000000fe
-#define PHY_ANALOG_SYNTH8_LOOP_ICPB_GET(x)                                            (((x) & 0x000000fe) >> 1)
-#define PHY_ANALOG_SYNTH8_LOOP_ICPB_SET(x)                                            (((x) << 1) & 0x000000fe)
-#define PHY_ANALOG_SYNTH8_LOOP_CSB_MSB                                                                       11
-#define PHY_ANALOG_SYNTH8_LOOP_CSB_LSB                                                                        8
-#define PHY_ANALOG_SYNTH8_LOOP_CSB_MASK                                                              0x00000f00
-#define PHY_ANALOG_SYNTH8_LOOP_CSB_GET(x)                                             (((x) & 0x00000f00) >> 8)
-#define PHY_ANALOG_SYNTH8_LOOP_CSB_SET(x)                                             (((x) << 8) & 0x00000f00)
-#define PHY_ANALOG_SYNTH8_LOOP_RSB_MSB                                                                       16
-#define PHY_ANALOG_SYNTH8_LOOP_RSB_LSB                                                                       12
-#define PHY_ANALOG_SYNTH8_LOOP_RSB_MASK                                                              0x0001f000
-#define PHY_ANALOG_SYNTH8_LOOP_RSB_GET(x)                                            (((x) & 0x0001f000) >> 12)
-#define PHY_ANALOG_SYNTH8_LOOP_RSB_SET(x)                                            (((x) << 12) & 0x0001f000)
-#define PHY_ANALOG_SYNTH8_LOOP_CPB_MSB                                                                       21
-#define PHY_ANALOG_SYNTH8_LOOP_CPB_LSB                                                                       17
-#define PHY_ANALOG_SYNTH8_LOOP_CPB_MASK                                                              0x003e0000
-#define PHY_ANALOG_SYNTH8_LOOP_CPB_GET(x)                                            (((x) & 0x003e0000) >> 17)
-#define PHY_ANALOG_SYNTH8_LOOP_CPB_SET(x)                                            (((x) << 17) & 0x003e0000)
-#define PHY_ANALOG_SYNTH8_LOOP_3RD_ORDER_RB_MSB                                                              26
-#define PHY_ANALOG_SYNTH8_LOOP_3RD_ORDER_RB_LSB                                                              22
-#define PHY_ANALOG_SYNTH8_LOOP_3RD_ORDER_RB_MASK                                                     0x07c00000
-#define PHY_ANALOG_SYNTH8_LOOP_3RD_ORDER_RB_GET(x)                                   (((x) & 0x07c00000) >> 22)
-#define PHY_ANALOG_SYNTH8_LOOP_3RD_ORDER_RB_SET(x)                                   (((x) << 22) & 0x07c00000)
-#define PHY_ANALOG_SYNTH8_REFDIVB_MSB                                                                        31
-#define PHY_ANALOG_SYNTH8_REFDIVB_LSB                                                                        27
-#define PHY_ANALOG_SYNTH8_REFDIVB_MASK                                                               0xf8000000
-#define PHY_ANALOG_SYNTH8_REFDIVB_GET(x)                                             (((x) & 0xf8000000) >> 27)
-#define PHY_ANALOG_SYNTH8_REFDIVB_SET(x)                                             (((x) << 27) & 0xf8000000)
-
-/* macros for SYNTH9 */
-#define PHY_ANALOG_SYNTH9_ADDRESS                                                                    0x000000a0
-#define PHY_ANALOG_SYNTH9_OFFSET                                                                     0x000000a0
-#define PHY_ANALOG_SYNTH9_PFDDELAY_INTN_MSB                                                                   0
-#define PHY_ANALOG_SYNTH9_PFDDELAY_INTN_LSB                                                                   0
-#define PHY_ANALOG_SYNTH9_PFDDELAY_INTN_MASK                                                         0x00000001
-#define PHY_ANALOG_SYNTH9_PFDDELAY_INTN_GET(x)                                        (((x) & 0x00000001) >> 0)
-#define PHY_ANALOG_SYNTH9_PFDDELAY_INTN_SET(x)                                        (((x) << 0) & 0x00000001)
-#define PHY_ANALOG_SYNTH9_SLOPE_ICPA0_MSB                                                                     3
-#define PHY_ANALOG_SYNTH9_SLOPE_ICPA0_LSB                                                                     1
-#define PHY_ANALOG_SYNTH9_SLOPE_ICPA0_MASK                                                           0x0000000e
-#define PHY_ANALOG_SYNTH9_SLOPE_ICPA0_GET(x)                                          (((x) & 0x0000000e) >> 1)
-#define PHY_ANALOG_SYNTH9_SLOPE_ICPA0_SET(x)                                          (((x) << 1) & 0x0000000e)
-#define PHY_ANALOG_SYNTH9_LOOP_ICPA0_MSB                                                                      7
-#define PHY_ANALOG_SYNTH9_LOOP_ICPA0_LSB                                                                      4
-#define PHY_ANALOG_SYNTH9_LOOP_ICPA0_MASK                                                            0x000000f0
-#define PHY_ANALOG_SYNTH9_LOOP_ICPA0_GET(x)                                           (((x) & 0x000000f0) >> 4)
-#define PHY_ANALOG_SYNTH9_LOOP_ICPA0_SET(x)                                           (((x) << 4) & 0x000000f0)
-#define PHY_ANALOG_SYNTH9_LOOP_CSA0_MSB                                                                      11
-#define PHY_ANALOG_SYNTH9_LOOP_CSA0_LSB                                                                       8
-#define PHY_ANALOG_SYNTH9_LOOP_CSA0_MASK                                                             0x00000f00
-#define PHY_ANALOG_SYNTH9_LOOP_CSA0_GET(x)                                            (((x) & 0x00000f00) >> 8)
-#define PHY_ANALOG_SYNTH9_LOOP_CSA0_SET(x)                                            (((x) << 8) & 0x00000f00)
-#define PHY_ANALOG_SYNTH9_LOOP_RSA0_MSB                                                                      16
-#define PHY_ANALOG_SYNTH9_LOOP_RSA0_LSB                                                                      12
-#define PHY_ANALOG_SYNTH9_LOOP_RSA0_MASK                                                             0x0001f000
-#define PHY_ANALOG_SYNTH9_LOOP_RSA0_GET(x)                                           (((x) & 0x0001f000) >> 12)
-#define PHY_ANALOG_SYNTH9_LOOP_RSA0_SET(x)                                           (((x) << 12) & 0x0001f000)
-#define PHY_ANALOG_SYNTH9_LOOP_CPA0_MSB                                                                      21
-#define PHY_ANALOG_SYNTH9_LOOP_CPA0_LSB                                                                      17
-#define PHY_ANALOG_SYNTH9_LOOP_CPA0_MASK                                                             0x003e0000
-#define PHY_ANALOG_SYNTH9_LOOP_CPA0_GET(x)                                           (((x) & 0x003e0000) >> 17)
-#define PHY_ANALOG_SYNTH9_LOOP_CPA0_SET(x)                                           (((x) << 17) & 0x003e0000)
-#define PHY_ANALOG_SYNTH9_LOOP_3RD_ORDER_RA_MSB                                                              26
-#define PHY_ANALOG_SYNTH9_LOOP_3RD_ORDER_RA_LSB                                                              22
-#define PHY_ANALOG_SYNTH9_LOOP_3RD_ORDER_RA_MASK                                                     0x07c00000
-#define PHY_ANALOG_SYNTH9_LOOP_3RD_ORDER_RA_GET(x)                                   (((x) & 0x07c00000) >> 22)
-#define PHY_ANALOG_SYNTH9_LOOP_3RD_ORDER_RA_SET(x)                                   (((x) << 22) & 0x07c00000)
-#define PHY_ANALOG_SYNTH9_REFDIVA_MSB                                                                        31
-#define PHY_ANALOG_SYNTH9_REFDIVA_LSB                                                                        27
-#define PHY_ANALOG_SYNTH9_REFDIVA_MASK                                                               0xf8000000
-#define PHY_ANALOG_SYNTH9_REFDIVA_GET(x)                                             (((x) & 0xf8000000) >> 27)
-#define PHY_ANALOG_SYNTH9_REFDIVA_SET(x)                                             (((x) << 27) & 0xf8000000)
-
-/* macros for SYNTH10 */
-#define PHY_ANALOG_SYNTH10_ADDRESS                                                                   0x000000a4
-#define PHY_ANALOG_SYNTH10_OFFSET                                                                    0x000000a4
-#define PHY_ANALOG_SYNTH10_SPARE10A_MSB                                                                       1
-#define PHY_ANALOG_SYNTH10_SPARE10A_LSB                                                                       0
-#define PHY_ANALOG_SYNTH10_SPARE10A_MASK                                                             0x00000003
-#define PHY_ANALOG_SYNTH10_SPARE10A_GET(x)                                            (((x) & 0x00000003) >> 0)
-#define PHY_ANALOG_SYNTH10_SPARE10A_SET(x)                                            (((x) << 0) & 0x00000003)
-#define PHY_ANALOG_SYNTH10_PWDB_ICLOBIAS50_MSB                                                                4
-#define PHY_ANALOG_SYNTH10_PWDB_ICLOBIAS50_LSB                                                                2
-#define PHY_ANALOG_SYNTH10_PWDB_ICLOBIAS50_MASK                                                      0x0000001c
-#define PHY_ANALOG_SYNTH10_PWDB_ICLOBIAS50_GET(x)                                     (((x) & 0x0000001c) >> 2)
-#define PHY_ANALOG_SYNTH10_PWDB_ICLOBIAS50_SET(x)                                     (((x) << 2) & 0x0000001c)
-#define PHY_ANALOG_SYNTH10_PWDB_IRSPARE25_MSB                                                                 7
-#define PHY_ANALOG_SYNTH10_PWDB_IRSPARE25_LSB                                                                 5
-#define PHY_ANALOG_SYNTH10_PWDB_IRSPARE25_MASK                                                       0x000000e0
-#define PHY_ANALOG_SYNTH10_PWDB_IRSPARE25_GET(x)                                      (((x) & 0x000000e0) >> 5)
-#define PHY_ANALOG_SYNTH10_PWDB_IRSPARE25_SET(x)                                      (((x) << 5) & 0x000000e0)
-#define PHY_ANALOG_SYNTH10_PWDB_ICSPARE25_MSB                                                                10
-#define PHY_ANALOG_SYNTH10_PWDB_ICSPARE25_LSB                                                                 8
-#define PHY_ANALOG_SYNTH10_PWDB_ICSPARE25_MASK                                                       0x00000700
-#define PHY_ANALOG_SYNTH10_PWDB_ICSPARE25_GET(x)                                      (((x) & 0x00000700) >> 8)
-#define PHY_ANALOG_SYNTH10_PWDB_ICSPARE25_SET(x)                                      (((x) << 8) & 0x00000700)
-#define PHY_ANALOG_SYNTH10_SLOPE_ICPA1_MSB                                                                   13
-#define PHY_ANALOG_SYNTH10_SLOPE_ICPA1_LSB                                                                   11
-#define PHY_ANALOG_SYNTH10_SLOPE_ICPA1_MASK                                                          0x00003800
-#define PHY_ANALOG_SYNTH10_SLOPE_ICPA1_GET(x)                                        (((x) & 0x00003800) >> 11)
-#define PHY_ANALOG_SYNTH10_SLOPE_ICPA1_SET(x)                                        (((x) << 11) & 0x00003800)
-#define PHY_ANALOG_SYNTH10_LOOP_ICPA1_MSB                                                                    17
-#define PHY_ANALOG_SYNTH10_LOOP_ICPA1_LSB                                                                    14
-#define PHY_ANALOG_SYNTH10_LOOP_ICPA1_MASK                                                           0x0003c000
-#define PHY_ANALOG_SYNTH10_LOOP_ICPA1_GET(x)                                         (((x) & 0x0003c000) >> 14)
-#define PHY_ANALOG_SYNTH10_LOOP_ICPA1_SET(x)                                         (((x) << 14) & 0x0003c000)
-#define PHY_ANALOG_SYNTH10_LOOP_CSA1_MSB                                                                     21
-#define PHY_ANALOG_SYNTH10_LOOP_CSA1_LSB                                                                     18
-#define PHY_ANALOG_SYNTH10_LOOP_CSA1_MASK                                                            0x003c0000
-#define PHY_ANALOG_SYNTH10_LOOP_CSA1_GET(x)                                          (((x) & 0x003c0000) >> 18)
-#define PHY_ANALOG_SYNTH10_LOOP_CSA1_SET(x)                                          (((x) << 18) & 0x003c0000)
-#define PHY_ANALOG_SYNTH10_LOOP_RSA1_MSB                                                                     26
-#define PHY_ANALOG_SYNTH10_LOOP_RSA1_LSB                                                                     22
-#define PHY_ANALOG_SYNTH10_LOOP_RSA1_MASK                                                            0x07c00000
-#define PHY_ANALOG_SYNTH10_LOOP_RSA1_GET(x)                                          (((x) & 0x07c00000) >> 22)
-#define PHY_ANALOG_SYNTH10_LOOP_RSA1_SET(x)                                          (((x) << 22) & 0x07c00000)
-#define PHY_ANALOG_SYNTH10_LOOP_CPA1_MSB                                                                     31
-#define PHY_ANALOG_SYNTH10_LOOP_CPA1_LSB                                                                     27
-#define PHY_ANALOG_SYNTH10_LOOP_CPA1_MASK                                                            0xf8000000
-#define PHY_ANALOG_SYNTH10_LOOP_CPA1_GET(x)                                          (((x) & 0xf8000000) >> 27)
-#define PHY_ANALOG_SYNTH10_LOOP_CPA1_SET(x)                                          (((x) << 27) & 0xf8000000)
-
-/* macros for SYNTH11 */
-#define PHY_ANALOG_SYNTH11_ADDRESS                                                                   0x000000a8
-#define PHY_ANALOG_SYNTH11_OFFSET                                                                    0x000000a8
-#define PHY_ANALOG_SYNTH11_SPARE11A_MSB                                                                       4
-#define PHY_ANALOG_SYNTH11_SPARE11A_LSB                                                                       0
-#define PHY_ANALOG_SYNTH11_SPARE11A_MASK                                                             0x0000001f
-#define PHY_ANALOG_SYNTH11_SPARE11A_GET(x)                                            (((x) & 0x0000001f) >> 0)
-#define PHY_ANALOG_SYNTH11_SPARE11A_SET(x)                                            (((x) << 0) & 0x0000001f)
-#define PHY_ANALOG_SYNTH11_FORCE_LOBUF5G_ON_MSB                                                               5
-#define PHY_ANALOG_SYNTH11_FORCE_LOBUF5G_ON_LSB                                                               5
-#define PHY_ANALOG_SYNTH11_FORCE_LOBUF5G_ON_MASK                                                     0x00000020
-#define PHY_ANALOG_SYNTH11_FORCE_LOBUF5G_ON_GET(x)                                    (((x) & 0x00000020) >> 5)
-#define PHY_ANALOG_SYNTH11_FORCE_LOBUF5G_ON_SET(x)                                    (((x) << 5) & 0x00000020)
-#define PHY_ANALOG_SYNTH11_LOREFSEL_MSB                                                                       7
-#define PHY_ANALOG_SYNTH11_LOREFSEL_LSB                                                                       6
-#define PHY_ANALOG_SYNTH11_LOREFSEL_MASK                                                             0x000000c0
-#define PHY_ANALOG_SYNTH11_LOREFSEL_GET(x)                                            (((x) & 0x000000c0) >> 6)
-#define PHY_ANALOG_SYNTH11_LOREFSEL_SET(x)                                            (((x) << 6) & 0x000000c0)
-#define PHY_ANALOG_SYNTH11_LOBUF2GTUNE_MSB                                                                    9
-#define PHY_ANALOG_SYNTH11_LOBUF2GTUNE_LSB                                                                    8
-#define PHY_ANALOG_SYNTH11_LOBUF2GTUNE_MASK                                                          0x00000300
-#define PHY_ANALOG_SYNTH11_LOBUF2GTUNE_GET(x)                                         (((x) & 0x00000300) >> 8)
-#define PHY_ANALOG_SYNTH11_LOBUF2GTUNE_SET(x)                                         (((x) << 8) & 0x00000300)
-#define PHY_ANALOG_SYNTH11_CPSTEERING_MODE_MSB                                                               10
-#define PHY_ANALOG_SYNTH11_CPSTEERING_MODE_LSB                                                               10
-#define PHY_ANALOG_SYNTH11_CPSTEERING_MODE_MASK                                                      0x00000400
-#define PHY_ANALOG_SYNTH11_CPSTEERING_MODE_GET(x)                                    (((x) & 0x00000400) >> 10)
-#define PHY_ANALOG_SYNTH11_CPSTEERING_MODE_SET(x)                                    (((x) << 10) & 0x00000400)
-#define PHY_ANALOG_SYNTH11_SLOPE_ICPA2_MSB                                                                   13
-#define PHY_ANALOG_SYNTH11_SLOPE_ICPA2_LSB                                                                   11
-#define PHY_ANALOG_SYNTH11_SLOPE_ICPA2_MASK                                                          0x00003800
-#define PHY_ANALOG_SYNTH11_SLOPE_ICPA2_GET(x)                                        (((x) & 0x00003800) >> 11)
-#define PHY_ANALOG_SYNTH11_SLOPE_ICPA2_SET(x)                                        (((x) << 11) & 0x00003800)
-#define PHY_ANALOG_SYNTH11_LOOP_ICPA2_MSB                                                                    17
-#define PHY_ANALOG_SYNTH11_LOOP_ICPA2_LSB                                                                    14
-#define PHY_ANALOG_SYNTH11_LOOP_ICPA2_MASK                                                           0x0003c000
-#define PHY_ANALOG_SYNTH11_LOOP_ICPA2_GET(x)                                         (((x) & 0x0003c000) >> 14)
-#define PHY_ANALOG_SYNTH11_LOOP_ICPA2_SET(x)                                         (((x) << 14) & 0x0003c000)
-#define PHY_ANALOG_SYNTH11_LOOP_CSA2_MSB                                                                     21
-#define PHY_ANALOG_SYNTH11_LOOP_CSA2_LSB                                                                     18
-#define PHY_ANALOG_SYNTH11_LOOP_CSA2_MASK                                                            0x003c0000
-#define PHY_ANALOG_SYNTH11_LOOP_CSA2_GET(x)                                          (((x) & 0x003c0000) >> 18)
-#define PHY_ANALOG_SYNTH11_LOOP_CSA2_SET(x)                                          (((x) << 18) & 0x003c0000)
-#define PHY_ANALOG_SYNTH11_LOOP_RSA2_MSB                                                                     26
-#define PHY_ANALOG_SYNTH11_LOOP_RSA2_LSB                                                                     22
-#define PHY_ANALOG_SYNTH11_LOOP_RSA2_MASK                                                            0x07c00000
-#define PHY_ANALOG_SYNTH11_LOOP_RSA2_GET(x)                                          (((x) & 0x07c00000) >> 22)
-#define PHY_ANALOG_SYNTH11_LOOP_RSA2_SET(x)                                          (((x) << 22) & 0x07c00000)
-#define PHY_ANALOG_SYNTH11_LOOP_CPA2_MSB                                                                     31
-#define PHY_ANALOG_SYNTH11_LOOP_CPA2_LSB                                                                     27
-#define PHY_ANALOG_SYNTH11_LOOP_CPA2_MASK                                                            0xf8000000
-#define PHY_ANALOG_SYNTH11_LOOP_CPA2_GET(x)                                          (((x) & 0xf8000000) >> 27)
-#define PHY_ANALOG_SYNTH11_LOOP_CPA2_SET(x)                                          (((x) << 27) & 0xf8000000)
-
-/* macros for SYNTH12 */
-#define PHY_ANALOG_SYNTH12_ADDRESS                                                                   0x000000ac
-#define PHY_ANALOG_SYNTH12_OFFSET                                                                    0x000000ac
-#define PHY_ANALOG_SYNTH12_SPARE12A_MSB                                                                       9
-#define PHY_ANALOG_SYNTH12_SPARE12A_LSB                                                                       0
-#define PHY_ANALOG_SYNTH12_SPARE12A_MASK                                                             0x000003ff
-#define PHY_ANALOG_SYNTH12_SPARE12A_GET(x)                                            (((x) & 0x000003ff) >> 0)
-#define PHY_ANALOG_SYNTH12_SPARE12A_SET(x)                                            (((x) << 0) & 0x000003ff)
-#define PHY_ANALOG_SYNTH12_LOOPLEAKCUR_FRACN_MSB                                                             13
-#define PHY_ANALOG_SYNTH12_LOOPLEAKCUR_FRACN_LSB                                                             10
-#define PHY_ANALOG_SYNTH12_LOOPLEAKCUR_FRACN_MASK                                                    0x00003c00
-#define PHY_ANALOG_SYNTH12_LOOPLEAKCUR_FRACN_GET(x)                                  (((x) & 0x00003c00) >> 10)
-#define PHY_ANALOG_SYNTH12_LOOPLEAKCUR_FRACN_SET(x)                                  (((x) << 10) & 0x00003c00)
-#define PHY_ANALOG_SYNTH12_CPLOWLK_FRACN_MSB                                                                 14
-#define PHY_ANALOG_SYNTH12_CPLOWLK_FRACN_LSB                                                                 14
-#define PHY_ANALOG_SYNTH12_CPLOWLK_FRACN_MASK                                                        0x00004000
-#define PHY_ANALOG_SYNTH12_CPLOWLK_FRACN_GET(x)                                      (((x) & 0x00004000) >> 14)
-#define PHY_ANALOG_SYNTH12_CPLOWLK_FRACN_SET(x)                                      (((x) << 14) & 0x00004000)
-#define PHY_ANALOG_SYNTH12_CPBIAS_FRACN_MSB                                                                  16
-#define PHY_ANALOG_SYNTH12_CPBIAS_FRACN_LSB                                                                  15
-#define PHY_ANALOG_SYNTH12_CPBIAS_FRACN_MASK                                                         0x00018000
-#define PHY_ANALOG_SYNTH12_CPBIAS_FRACN_GET(x)                                       (((x) & 0x00018000) >> 15)
-#define PHY_ANALOG_SYNTH12_CPBIAS_FRACN_SET(x)                                       (((x) << 15) & 0x00018000)
-#define PHY_ANALOG_SYNTH12_SYNTHDIGOUTEN_MSB                                                                 17
-#define PHY_ANALOG_SYNTH12_SYNTHDIGOUTEN_LSB                                                                 17
-#define PHY_ANALOG_SYNTH12_SYNTHDIGOUTEN_MASK                                                        0x00020000
-#define PHY_ANALOG_SYNTH12_SYNTHDIGOUTEN_GET(x)                                      (((x) & 0x00020000) >> 17)
-#define PHY_ANALOG_SYNTH12_SYNTHDIGOUTEN_SET(x)                                      (((x) << 17) & 0x00020000)
-#define PHY_ANALOG_SYNTH12_STRCONT_MSB                                                                       18
-#define PHY_ANALOG_SYNTH12_STRCONT_LSB                                                                       18
-#define PHY_ANALOG_SYNTH12_STRCONT_MASK                                                              0x00040000
-#define PHY_ANALOG_SYNTH12_STRCONT_GET(x)                                            (((x) & 0x00040000) >> 18)
-#define PHY_ANALOG_SYNTH12_STRCONT_SET(x)                                            (((x) << 18) & 0x00040000)
-#define PHY_ANALOG_SYNTH12_VREFMUL3_MSB                                                                      22
-#define PHY_ANALOG_SYNTH12_VREFMUL3_LSB                                                                      19
-#define PHY_ANALOG_SYNTH12_VREFMUL3_MASK                                                             0x00780000
-#define PHY_ANALOG_SYNTH12_VREFMUL3_GET(x)                                           (((x) & 0x00780000) >> 19)
-#define PHY_ANALOG_SYNTH12_VREFMUL3_SET(x)                                           (((x) << 19) & 0x00780000)
-#define PHY_ANALOG_SYNTH12_VREFMUL2_MSB                                                                      26
-#define PHY_ANALOG_SYNTH12_VREFMUL2_LSB                                                                      23
-#define PHY_ANALOG_SYNTH12_VREFMUL2_MASK                                                             0x07800000
-#define PHY_ANALOG_SYNTH12_VREFMUL2_GET(x)                                           (((x) & 0x07800000) >> 23)
-#define PHY_ANALOG_SYNTH12_VREFMUL2_SET(x)                                           (((x) << 23) & 0x07800000)
-#define PHY_ANALOG_SYNTH12_VREFMUL1_MSB                                                                      30
-#define PHY_ANALOG_SYNTH12_VREFMUL1_LSB                                                                      27
-#define PHY_ANALOG_SYNTH12_VREFMUL1_MASK                                                             0x78000000
-#define PHY_ANALOG_SYNTH12_VREFMUL1_GET(x)                                           (((x) & 0x78000000) >> 27)
-#define PHY_ANALOG_SYNTH12_VREFMUL1_SET(x)                                           (((x) << 27) & 0x78000000)
-#define PHY_ANALOG_SYNTH12_CLK_DOUBLER_EN_MSB                                                                31
-#define PHY_ANALOG_SYNTH12_CLK_DOUBLER_EN_LSB                                                                31
-#define PHY_ANALOG_SYNTH12_CLK_DOUBLER_EN_MASK                                                       0x80000000
-#define PHY_ANALOG_SYNTH12_CLK_DOUBLER_EN_GET(x)                                     (((x) & 0x80000000) >> 31)
-#define PHY_ANALOG_SYNTH12_CLK_DOUBLER_EN_SET(x)                                     (((x) << 31) & 0x80000000)
-
-/* macros for SYNTH13 */
-#define PHY_ANALOG_SYNTH13_ADDRESS                                                                   0x000000b0
-#define PHY_ANALOG_SYNTH13_OFFSET                                                                    0x000000b0
-#define PHY_ANALOG_SYNTH13_SPARE13A_MSB                                                                       0
-#define PHY_ANALOG_SYNTH13_SPARE13A_LSB                                                                       0
-#define PHY_ANALOG_SYNTH13_SPARE13A_MASK                                                             0x00000001
-#define PHY_ANALOG_SYNTH13_SPARE13A_GET(x)                                            (((x) & 0x00000001) >> 0)
-#define PHY_ANALOG_SYNTH13_SPARE13A_SET(x)                                            (((x) << 0) & 0x00000001)
-#define PHY_ANALOG_SYNTH13_SLOPE_ICPA_FRACN_MSB                                                               3
-#define PHY_ANALOG_SYNTH13_SLOPE_ICPA_FRACN_LSB                                                               1
-#define PHY_ANALOG_SYNTH13_SLOPE_ICPA_FRACN_MASK                                                     0x0000000e
-#define PHY_ANALOG_SYNTH13_SLOPE_ICPA_FRACN_GET(x)                                    (((x) & 0x0000000e) >> 1)
-#define PHY_ANALOG_SYNTH13_SLOPE_ICPA_FRACN_SET(x)                                    (((x) << 1) & 0x0000000e)
-#define PHY_ANALOG_SYNTH13_LOOP_ICPA_FRACN_MSB                                                                7
-#define PHY_ANALOG_SYNTH13_LOOP_ICPA_FRACN_LSB                                                                4
-#define PHY_ANALOG_SYNTH13_LOOP_ICPA_FRACN_MASK                                                      0x000000f0
-#define PHY_ANALOG_SYNTH13_LOOP_ICPA_FRACN_GET(x)                                     (((x) & 0x000000f0) >> 4)
-#define PHY_ANALOG_SYNTH13_LOOP_ICPA_FRACN_SET(x)                                     (((x) << 4) & 0x000000f0)
-#define PHY_ANALOG_SYNTH13_LOOP_CSA_FRACN_MSB                                                                11
-#define PHY_ANALOG_SYNTH13_LOOP_CSA_FRACN_LSB                                                                 8
-#define PHY_ANALOG_SYNTH13_LOOP_CSA_FRACN_MASK                                                       0x00000f00
-#define PHY_ANALOG_SYNTH13_LOOP_CSA_FRACN_GET(x)                                      (((x) & 0x00000f00) >> 8)
-#define PHY_ANALOG_SYNTH13_LOOP_CSA_FRACN_SET(x)                                      (((x) << 8) & 0x00000f00)
-#define PHY_ANALOG_SYNTH13_LOOP_RSA_FRACN_MSB                                                                16
-#define PHY_ANALOG_SYNTH13_LOOP_RSA_FRACN_LSB                                                                12
-#define PHY_ANALOG_SYNTH13_LOOP_RSA_FRACN_MASK                                                       0x0001f000
-#define PHY_ANALOG_SYNTH13_LOOP_RSA_FRACN_GET(x)                                     (((x) & 0x0001f000) >> 12)
-#define PHY_ANALOG_SYNTH13_LOOP_RSA_FRACN_SET(x)                                     (((x) << 12) & 0x0001f000)
-#define PHY_ANALOG_SYNTH13_LOOP_CPA_FRACN_MSB                                                                21
-#define PHY_ANALOG_SYNTH13_LOOP_CPA_FRACN_LSB                                                                17
-#define PHY_ANALOG_SYNTH13_LOOP_CPA_FRACN_MASK                                                       0x003e0000
-#define PHY_ANALOG_SYNTH13_LOOP_CPA_FRACN_GET(x)                                     (((x) & 0x003e0000) >> 17)
-#define PHY_ANALOG_SYNTH13_LOOP_CPA_FRACN_SET(x)                                     (((x) << 17) & 0x003e0000)
-#define PHY_ANALOG_SYNTH13_LOOP_3RD_ORDER_RA_FRACN_MSB                                                       26
-#define PHY_ANALOG_SYNTH13_LOOP_3RD_ORDER_RA_FRACN_LSB                                                       22
-#define PHY_ANALOG_SYNTH13_LOOP_3RD_ORDER_RA_FRACN_MASK                                              0x07c00000
-#define PHY_ANALOG_SYNTH13_LOOP_3RD_ORDER_RA_FRACN_GET(x)                            (((x) & 0x07c00000) >> 22)
-#define PHY_ANALOG_SYNTH13_LOOP_3RD_ORDER_RA_FRACN_SET(x)                            (((x) << 22) & 0x07c00000)
-#define PHY_ANALOG_SYNTH13_REFDIVA_FRACN_MSB                                                                 31
-#define PHY_ANALOG_SYNTH13_REFDIVA_FRACN_LSB                                                                 27
-#define PHY_ANALOG_SYNTH13_REFDIVA_FRACN_MASK                                                        0xf8000000
-#define PHY_ANALOG_SYNTH13_REFDIVA_FRACN_GET(x)                                      (((x) & 0xf8000000) >> 27)
-#define PHY_ANALOG_SYNTH13_REFDIVA_FRACN_SET(x)                                      (((x) << 27) & 0xf8000000)
-
-/* macros for SYNTH14 */
-#define PHY_ANALOG_SYNTH14_ADDRESS                                                                   0x000000b4
-#define PHY_ANALOG_SYNTH14_OFFSET                                                                    0x000000b4
-#define PHY_ANALOG_SYNTH14_SPARE14A_MSB                                                                       1
-#define PHY_ANALOG_SYNTH14_SPARE14A_LSB                                                                       0
-#define PHY_ANALOG_SYNTH14_SPARE14A_MASK                                                             0x00000003
-#define PHY_ANALOG_SYNTH14_SPARE14A_GET(x)                                            (((x) & 0x00000003) >> 0)
-#define PHY_ANALOG_SYNTH14_SPARE14A_SET(x)                                            (((x) << 0) & 0x00000003)
-#define PHY_ANALOG_SYNTH14_LOBUF5GTUNE_3_MSB                                                                  3
-#define PHY_ANALOG_SYNTH14_LOBUF5GTUNE_3_LSB                                                                  2
-#define PHY_ANALOG_SYNTH14_LOBUF5GTUNE_3_MASK                                                        0x0000000c
-#define PHY_ANALOG_SYNTH14_LOBUF5GTUNE_3_GET(x)                                       (((x) & 0x0000000c) >> 2)
-#define PHY_ANALOG_SYNTH14_LOBUF5GTUNE_3_SET(x)                                       (((x) << 2) & 0x0000000c)
-#define PHY_ANALOG_SYNTH14_LOBUF2GTUNE_3_MSB                                                                  5
-#define PHY_ANALOG_SYNTH14_LOBUF2GTUNE_3_LSB                                                                  4
-#define PHY_ANALOG_SYNTH14_LOBUF2GTUNE_3_MASK                                                        0x00000030
-#define PHY_ANALOG_SYNTH14_LOBUF2GTUNE_3_GET(x)                                       (((x) & 0x00000030) >> 4)
-#define PHY_ANALOG_SYNTH14_LOBUF2GTUNE_3_SET(x)                                       (((x) << 4) & 0x00000030)
-#define PHY_ANALOG_SYNTH14_LOBUF5GTUNE_2_MSB                                                                  7
-#define PHY_ANALOG_SYNTH14_LOBUF5GTUNE_2_LSB                                                                  6
-#define PHY_ANALOG_SYNTH14_LOBUF5GTUNE_2_MASK                                                        0x000000c0
-#define PHY_ANALOG_SYNTH14_LOBUF5GTUNE_2_GET(x)                                       (((x) & 0x000000c0) >> 6)
-#define PHY_ANALOG_SYNTH14_LOBUF5GTUNE_2_SET(x)                                       (((x) << 6) & 0x000000c0)
-#define PHY_ANALOG_SYNTH14_LOBUF2GTUNE_2_MSB                                                                  9
-#define PHY_ANALOG_SYNTH14_LOBUF2GTUNE_2_LSB                                                                  8
-#define PHY_ANALOG_SYNTH14_LOBUF2GTUNE_2_MASK                                                        0x00000300
-#define PHY_ANALOG_SYNTH14_LOBUF2GTUNE_2_GET(x)                                       (((x) & 0x00000300) >> 8)
-#define PHY_ANALOG_SYNTH14_LOBUF2GTUNE_2_SET(x)                                       (((x) << 8) & 0x00000300)
-#define PHY_ANALOG_SYNTH14_PWD_LOBUF5G_3_MSB                                                                 10
-#define PHY_ANALOG_SYNTH14_PWD_LOBUF5G_3_LSB                                                                 10
-#define PHY_ANALOG_SYNTH14_PWD_LOBUF5G_3_MASK                                                        0x00000400
-#define PHY_ANALOG_SYNTH14_PWD_LOBUF5G_3_GET(x)                                      (((x) & 0x00000400) >> 10)
-#define PHY_ANALOG_SYNTH14_PWD_LOBUF5G_3_SET(x)                                      (((x) << 10) & 0x00000400)
-#define PHY_ANALOG_SYNTH14_PWD_LOBUF2G_3_MSB                                                                 11
-#define PHY_ANALOG_SYNTH14_PWD_LOBUF2G_3_LSB                                                                 11
-#define PHY_ANALOG_SYNTH14_PWD_LOBUF2G_3_MASK                                                        0x00000800
-#define PHY_ANALOG_SYNTH14_PWD_LOBUF2G_3_GET(x)                                      (((x) & 0x00000800) >> 11)
-#define PHY_ANALOG_SYNTH14_PWD_LOBUF2G_3_SET(x)                                      (((x) << 11) & 0x00000800)
-#define PHY_ANALOG_SYNTH14_PWD_LOBUF5G_2_MSB                                                                 12
-#define PHY_ANALOG_SYNTH14_PWD_LOBUF5G_2_LSB                                                                 12
-#define PHY_ANALOG_SYNTH14_PWD_LOBUF5G_2_MASK                                                        0x00001000
-#define PHY_ANALOG_SYNTH14_PWD_LOBUF5G_2_GET(x)                                      (((x) & 0x00001000) >> 12)
-#define PHY_ANALOG_SYNTH14_PWD_LOBUF5G_2_SET(x)                                      (((x) << 12) & 0x00001000)
-#define PHY_ANALOG_SYNTH14_PWD_LOBUF2G_2_MSB                                                                 13
-#define PHY_ANALOG_SYNTH14_PWD_LOBUF2G_2_LSB                                                                 13
-#define PHY_ANALOG_SYNTH14_PWD_LOBUF2G_2_MASK                                                        0x00002000
-#define PHY_ANALOG_SYNTH14_PWD_LOBUF2G_2_GET(x)                                      (((x) & 0x00002000) >> 13)
-#define PHY_ANALOG_SYNTH14_PWD_LOBUF2G_2_SET(x)                                      (((x) << 13) & 0x00002000)
-#define PHY_ANALOG_SYNTH14_PWUPLO23_PD_MSB                                                                   16
-#define PHY_ANALOG_SYNTH14_PWUPLO23_PD_LSB                                                                   14
-#define PHY_ANALOG_SYNTH14_PWUPLO23_PD_MASK                                                          0x0001c000
-#define PHY_ANALOG_SYNTH14_PWUPLO23_PD_GET(x)                                        (((x) & 0x0001c000) >> 14)
-#define PHY_ANALOG_SYNTH14_PWUPLO23_PD_SET(x)                                        (((x) << 14) & 0x0001c000)
-#define PHY_ANALOG_SYNTH14_PWDB_ICLOBUF5G50_3_MSB                                                            19
-#define PHY_ANALOG_SYNTH14_PWDB_ICLOBUF5G50_3_LSB                                                            17
-#define PHY_ANALOG_SYNTH14_PWDB_ICLOBUF5G50_3_MASK                                                   0x000e0000
-#define PHY_ANALOG_SYNTH14_PWDB_ICLOBUF5G50_3_GET(x)                                 (((x) & 0x000e0000) >> 17)
-#define PHY_ANALOG_SYNTH14_PWDB_ICLOBUF5G50_3_SET(x)                                 (((x) << 17) & 0x000e0000)
-#define PHY_ANALOG_SYNTH14_PWDB_ICLOBUF2G50_3_MSB                                                            22
-#define PHY_ANALOG_SYNTH14_PWDB_ICLOBUF2G50_3_LSB                                                            20
-#define PHY_ANALOG_SYNTH14_PWDB_ICLOBUF2G50_3_MASK                                                   0x00700000
-#define PHY_ANALOG_SYNTH14_PWDB_ICLOBUF2G50_3_GET(x)                                 (((x) & 0x00700000) >> 20)
-#define PHY_ANALOG_SYNTH14_PWDB_ICLOBUF2G50_3_SET(x)                                 (((x) << 20) & 0x00700000)
-#define PHY_ANALOG_SYNTH14_PWDB_ICLOBUF5G50_2_MSB                                                            25
-#define PHY_ANALOG_SYNTH14_PWDB_ICLOBUF5G50_2_LSB                                                            23
-#define PHY_ANALOG_SYNTH14_PWDB_ICLOBUF5G50_2_MASK                                                   0x03800000
-#define PHY_ANALOG_SYNTH14_PWDB_ICLOBUF5G50_2_GET(x)                                 (((x) & 0x03800000) >> 23)
-#define PHY_ANALOG_SYNTH14_PWDB_ICLOBUF5G50_2_SET(x)                                 (((x) << 23) & 0x03800000)
-#define PHY_ANALOG_SYNTH14_PWDB_ICLOBUF2G50_2_MSB                                                            28
-#define PHY_ANALOG_SYNTH14_PWDB_ICLOBUF2G50_2_LSB                                                            26
-#define PHY_ANALOG_SYNTH14_PWDB_ICLOBUF2G50_2_MASK                                                   0x1c000000
-#define PHY_ANALOG_SYNTH14_PWDB_ICLOBUF2G50_2_GET(x)                                 (((x) & 0x1c000000) >> 26)
-#define PHY_ANALOG_SYNTH14_PWDB_ICLOBUF2G50_2_SET(x)                                 (((x) << 26) & 0x1c000000)
-#define PHY_ANALOG_SYNTH14_PWDB_ICLVLSHFT_MSB                                                                31
-#define PHY_ANALOG_SYNTH14_PWDB_ICLVLSHFT_LSB                                                                29
-#define PHY_ANALOG_SYNTH14_PWDB_ICLVLSHFT_MASK                                                       0xe0000000
-#define PHY_ANALOG_SYNTH14_PWDB_ICLVLSHFT_GET(x)                                     (((x) & 0xe0000000) >> 29)
-#define PHY_ANALOG_SYNTH14_PWDB_ICLVLSHFT_SET(x)                                     (((x) << 29) & 0xe0000000)
-
-/* macros for BIAS1 */
-#define PHY_ANALOG_BIAS1_ADDRESS                                                                     0x000000c0
-#define PHY_ANALOG_BIAS1_OFFSET                                                                      0x000000c0
-#define PHY_ANALOG_BIAS1_SPARE1_MSB                                                                           6
-#define PHY_ANALOG_BIAS1_SPARE1_LSB                                                                           0
-#define PHY_ANALOG_BIAS1_SPARE1_MASK                                                                 0x0000007f
-#define PHY_ANALOG_BIAS1_SPARE1_GET(x)                                                (((x) & 0x0000007f) >> 0)
-#define PHY_ANALOG_BIAS1_SPARE1_SET(x)                                                (((x) << 0) & 0x0000007f)
-#define PHY_ANALOG_BIAS1_PWD_IC25V2IQ_MSB                                                                     9
-#define PHY_ANALOG_BIAS1_PWD_IC25V2IQ_LSB                                                                     7
-#define PHY_ANALOG_BIAS1_PWD_IC25V2IQ_MASK                                                           0x00000380
-#define PHY_ANALOG_BIAS1_PWD_IC25V2IQ_GET(x)                                          (((x) & 0x00000380) >> 7)
-#define PHY_ANALOG_BIAS1_PWD_IC25V2IQ_SET(x)                                          (((x) << 7) & 0x00000380)
-#define PHY_ANALOG_BIAS1_PWD_IC25V2II_MSB                                                                    12
-#define PHY_ANALOG_BIAS1_PWD_IC25V2II_LSB                                                                    10
-#define PHY_ANALOG_BIAS1_PWD_IC25V2II_MASK                                                           0x00001c00
-#define PHY_ANALOG_BIAS1_PWD_IC25V2II_GET(x)                                         (((x) & 0x00001c00) >> 10)
-#define PHY_ANALOG_BIAS1_PWD_IC25V2II_SET(x)                                         (((x) << 10) & 0x00001c00)
-#define PHY_ANALOG_BIAS1_PWD_IC25BB_MSB                                                                      15
-#define PHY_ANALOG_BIAS1_PWD_IC25BB_LSB                                                                      13
-#define PHY_ANALOG_BIAS1_PWD_IC25BB_MASK                                                             0x0000e000
-#define PHY_ANALOG_BIAS1_PWD_IC25BB_GET(x)                                           (((x) & 0x0000e000) >> 13)
-#define PHY_ANALOG_BIAS1_PWD_IC25BB_SET(x)                                           (((x) << 13) & 0x0000e000)
-#define PHY_ANALOG_BIAS1_PWD_IC25DAC_MSB                                                                     18
-#define PHY_ANALOG_BIAS1_PWD_IC25DAC_LSB                                                                     16
-#define PHY_ANALOG_BIAS1_PWD_IC25DAC_MASK                                                            0x00070000
-#define PHY_ANALOG_BIAS1_PWD_IC25DAC_GET(x)                                          (((x) & 0x00070000) >> 16)
-#define PHY_ANALOG_BIAS1_PWD_IC25DAC_SET(x)                                          (((x) << 16) & 0x00070000)
-#define PHY_ANALOG_BIAS1_PWD_IC25FIR_MSB                                                                     21
-#define PHY_ANALOG_BIAS1_PWD_IC25FIR_LSB                                                                     19
-#define PHY_ANALOG_BIAS1_PWD_IC25FIR_MASK                                                            0x00380000
-#define PHY_ANALOG_BIAS1_PWD_IC25FIR_GET(x)                                          (((x) & 0x00380000) >> 19)
-#define PHY_ANALOG_BIAS1_PWD_IC25FIR_SET(x)                                          (((x) << 19) & 0x00380000)
-#define PHY_ANALOG_BIAS1_PWD_IC25ADC_MSB                                                                     24
-#define PHY_ANALOG_BIAS1_PWD_IC25ADC_LSB                                                                     22
-#define PHY_ANALOG_BIAS1_PWD_IC25ADC_MASK                                                            0x01c00000
-#define PHY_ANALOG_BIAS1_PWD_IC25ADC_GET(x)                                          (((x) & 0x01c00000) >> 22)
-#define PHY_ANALOG_BIAS1_PWD_IC25ADC_SET(x)                                          (((x) << 22) & 0x01c00000)
-#define PHY_ANALOG_BIAS1_BIAS_SEL_MSB                                                                        31
-#define PHY_ANALOG_BIAS1_BIAS_SEL_LSB                                                                        25
-#define PHY_ANALOG_BIAS1_BIAS_SEL_MASK                                                               0xfe000000
-#define PHY_ANALOG_BIAS1_BIAS_SEL_GET(x)                                             (((x) & 0xfe000000) >> 25)
-#define PHY_ANALOG_BIAS1_BIAS_SEL_SET(x)                                             (((x) << 25) & 0xfe000000)
-
-/* macros for BIAS2 */
-#define PHY_ANALOG_BIAS2_ADDRESS                                                                     0x000000c4
-#define PHY_ANALOG_BIAS2_OFFSET                                                                      0x000000c4
-#define PHY_ANALOG_BIAS2_SPARE2_MSB                                                                           4
-#define PHY_ANALOG_BIAS2_SPARE2_LSB                                                                           0
-#define PHY_ANALOG_BIAS2_SPARE2_MASK                                                                 0x0000001f
-#define PHY_ANALOG_BIAS2_SPARE2_GET(x)                                                (((x) & 0x0000001f) >> 0)
-#define PHY_ANALOG_BIAS2_SPARE2_SET(x)                                                (((x) << 0) & 0x0000001f)
-#define PHY_ANALOG_BIAS2_PWD_IC25XPA_MSB                                                                      7
-#define PHY_ANALOG_BIAS2_PWD_IC25XPA_LSB                                                                      5
-#define PHY_ANALOG_BIAS2_PWD_IC25XPA_MASK                                                            0x000000e0
-#define PHY_ANALOG_BIAS2_PWD_IC25XPA_GET(x)                                           (((x) & 0x000000e0) >> 5)
-#define PHY_ANALOG_BIAS2_PWD_IC25XPA_SET(x)                                           (((x) << 5) & 0x000000e0)
-#define PHY_ANALOG_BIAS2_PWD_IC25XTAL_MSB                                                                    10
-#define PHY_ANALOG_BIAS2_PWD_IC25XTAL_LSB                                                                     8
-#define PHY_ANALOG_BIAS2_PWD_IC25XTAL_MASK                                                           0x00000700
-#define PHY_ANALOG_BIAS2_PWD_IC25XTAL_GET(x)                                          (((x) & 0x00000700) >> 8)
-#define PHY_ANALOG_BIAS2_PWD_IC25XTAL_SET(x)                                          (((x) << 8) & 0x00000700)
-#define PHY_ANALOG_BIAS2_PWD_IC25TXRF_MSB                                                                    13
-#define PHY_ANALOG_BIAS2_PWD_IC25TXRF_LSB                                                                    11
-#define PHY_ANALOG_BIAS2_PWD_IC25TXRF_MASK                                                           0x00003800
-#define PHY_ANALOG_BIAS2_PWD_IC25TXRF_GET(x)                                         (((x) & 0x00003800) >> 11)
-#define PHY_ANALOG_BIAS2_PWD_IC25TXRF_SET(x)                                         (((x) << 11) & 0x00003800)
-#define PHY_ANALOG_BIAS2_PWD_IC25RXRF_MSB                                                                    16
-#define PHY_ANALOG_BIAS2_PWD_IC25RXRF_LSB                                                                    14
-#define PHY_ANALOG_BIAS2_PWD_IC25RXRF_MASK                                                           0x0001c000
-#define PHY_ANALOG_BIAS2_PWD_IC25RXRF_GET(x)                                         (((x) & 0x0001c000) >> 14)
-#define PHY_ANALOG_BIAS2_PWD_IC25RXRF_SET(x)                                         (((x) << 14) & 0x0001c000)
-#define PHY_ANALOG_BIAS2_PWD_IC25SYNTH_MSB                                                                   19
-#define PHY_ANALOG_BIAS2_PWD_IC25SYNTH_LSB                                                                   17
-#define PHY_ANALOG_BIAS2_PWD_IC25SYNTH_MASK                                                          0x000e0000
-#define PHY_ANALOG_BIAS2_PWD_IC25SYNTH_GET(x)                                        (((x) & 0x000e0000) >> 17)
-#define PHY_ANALOG_BIAS2_PWD_IC25SYNTH_SET(x)                                        (((x) << 17) & 0x000e0000)
-#define PHY_ANALOG_BIAS2_PWD_IC25PLLREG_MSB                                                                  22
-#define PHY_ANALOG_BIAS2_PWD_IC25PLLREG_LSB                                                                  20
-#define PHY_ANALOG_BIAS2_PWD_IC25PLLREG_MASK                                                         0x00700000
-#define PHY_ANALOG_BIAS2_PWD_IC25PLLREG_GET(x)                                       (((x) & 0x00700000) >> 20)
-#define PHY_ANALOG_BIAS2_PWD_IC25PLLREG_SET(x)                                       (((x) << 20) & 0x00700000)
-#define PHY_ANALOG_BIAS2_PWD_IC25PLLCP2_MSB                                                                  25
-#define PHY_ANALOG_BIAS2_PWD_IC25PLLCP2_LSB                                                                  23
-#define PHY_ANALOG_BIAS2_PWD_IC25PLLCP2_MASK                                                         0x03800000
-#define PHY_ANALOG_BIAS2_PWD_IC25PLLCP2_GET(x)                                       (((x) & 0x03800000) >> 23)
-#define PHY_ANALOG_BIAS2_PWD_IC25PLLCP2_SET(x)                                       (((x) << 23) & 0x03800000)
-#define PHY_ANALOG_BIAS2_PWD_IC25PLLCP_MSB                                                                   28
-#define PHY_ANALOG_BIAS2_PWD_IC25PLLCP_LSB                                                                   26
-#define PHY_ANALOG_BIAS2_PWD_IC25PLLCP_MASK                                                          0x1c000000
-#define PHY_ANALOG_BIAS2_PWD_IC25PLLCP_GET(x)                                        (((x) & 0x1c000000) >> 26)
-#define PHY_ANALOG_BIAS2_PWD_IC25PLLCP_SET(x)                                        (((x) << 26) & 0x1c000000)
-#define PHY_ANALOG_BIAS2_PWD_IC25PLLGM_MSB                                                                   31
-#define PHY_ANALOG_BIAS2_PWD_IC25PLLGM_LSB                                                                   29
-#define PHY_ANALOG_BIAS2_PWD_IC25PLLGM_MASK                                                          0xe0000000
-#define PHY_ANALOG_BIAS2_PWD_IC25PLLGM_GET(x)                                        (((x) & 0xe0000000) >> 29)
-#define PHY_ANALOG_BIAS2_PWD_IC25PLLGM_SET(x)                                        (((x) << 29) & 0xe0000000)
-
-/* macros for BIAS3 */
-#define PHY_ANALOG_BIAS3_ADDRESS                                                                     0x000000c8
-#define PHY_ANALOG_BIAS3_OFFSET                                                                      0x000000c8
-#define PHY_ANALOG_BIAS3_SPARE3_MSB                                                                           1
-#define PHY_ANALOG_BIAS3_SPARE3_LSB                                                                           0
-#define PHY_ANALOG_BIAS3_SPARE3_MASK                                                                 0x00000003
-#define PHY_ANALOG_BIAS3_SPARE3_GET(x)                                                (((x) & 0x00000003) >> 0)
-#define PHY_ANALOG_BIAS3_SPARE3_SET(x)                                                (((x) << 0) & 0x00000003)
-#define PHY_ANALOG_BIAS3_PWD_IR25SAR_MSB                                                                      4
-#define PHY_ANALOG_BIAS3_PWD_IR25SAR_LSB                                                                      2
-#define PHY_ANALOG_BIAS3_PWD_IR25SAR_MASK                                                            0x0000001c
-#define PHY_ANALOG_BIAS3_PWD_IR25SAR_GET(x)                                           (((x) & 0x0000001c) >> 2)
-#define PHY_ANALOG_BIAS3_PWD_IR25SAR_SET(x)                                           (((x) << 2) & 0x0000001c)
-#define PHY_ANALOG_BIAS3_PWD_IR25TXRF_MSB                                                                     7
-#define PHY_ANALOG_BIAS3_PWD_IR25TXRF_LSB                                                                     5
-#define PHY_ANALOG_BIAS3_PWD_IR25TXRF_MASK                                                           0x000000e0
-#define PHY_ANALOG_BIAS3_PWD_IR25TXRF_GET(x)                                          (((x) & 0x000000e0) >> 5)
-#define PHY_ANALOG_BIAS3_PWD_IR25TXRF_SET(x)                                          (((x) << 5) & 0x000000e0)
-#define PHY_ANALOG_BIAS3_PWD_IR25RXRF_MSB                                                                    10
-#define PHY_ANALOG_BIAS3_PWD_IR25RXRF_LSB                                                                     8
-#define PHY_ANALOG_BIAS3_PWD_IR25RXRF_MASK                                                           0x00000700
-#define PHY_ANALOG_BIAS3_PWD_IR25RXRF_GET(x)                                          (((x) & 0x00000700) >> 8)
-#define PHY_ANALOG_BIAS3_PWD_IR25RXRF_SET(x)                                          (((x) << 8) & 0x00000700)
-#define PHY_ANALOG_BIAS3_PWD_IR25SYNTH_MSB                                                                   13
-#define PHY_ANALOG_BIAS3_PWD_IR25SYNTH_LSB                                                                   11
-#define PHY_ANALOG_BIAS3_PWD_IR25SYNTH_MASK                                                          0x00003800
-#define PHY_ANALOG_BIAS3_PWD_IR25SYNTH_GET(x)                                        (((x) & 0x00003800) >> 11)
-#define PHY_ANALOG_BIAS3_PWD_IR25SYNTH_SET(x)                                        (((x) << 11) & 0x00003800)
-#define PHY_ANALOG_BIAS3_PWD_IR25PLLREG_MSB                                                                  16
-#define PHY_ANALOG_BIAS3_PWD_IR25PLLREG_LSB                                                                  14
-#define PHY_ANALOG_BIAS3_PWD_IR25PLLREG_MASK                                                         0x0001c000
-#define PHY_ANALOG_BIAS3_PWD_IR25PLLREG_GET(x)                                       (((x) & 0x0001c000) >> 14)
-#define PHY_ANALOG_BIAS3_PWD_IR25PLLREG_SET(x)                                       (((x) << 14) & 0x0001c000)
-#define PHY_ANALOG_BIAS3_PWD_IR25BB_MSB                                                                      19
-#define PHY_ANALOG_BIAS3_PWD_IR25BB_LSB                                                                      17
-#define PHY_ANALOG_BIAS3_PWD_IR25BB_MASK                                                             0x000e0000
-#define PHY_ANALOG_BIAS3_PWD_IR25BB_GET(x)                                           (((x) & 0x000e0000) >> 17)
-#define PHY_ANALOG_BIAS3_PWD_IR25BB_SET(x)                                           (((x) << 17) & 0x000e0000)
-#define PHY_ANALOG_BIAS3_PWD_IR50DAC_MSB                                                                     22
-#define PHY_ANALOG_BIAS3_PWD_IR50DAC_LSB                                                                     20
-#define PHY_ANALOG_BIAS3_PWD_IR50DAC_MASK                                                            0x00700000
-#define PHY_ANALOG_BIAS3_PWD_IR50DAC_GET(x)                                          (((x) & 0x00700000) >> 20)
-#define PHY_ANALOG_BIAS3_PWD_IR50DAC_SET(x)                                          (((x) << 20) & 0x00700000)
-#define PHY_ANALOG_BIAS3_PWD_IR25DAC_MSB                                                                     25
-#define PHY_ANALOG_BIAS3_PWD_IR25DAC_LSB                                                                     23
-#define PHY_ANALOG_BIAS3_PWD_IR25DAC_MASK                                                            0x03800000
-#define PHY_ANALOG_BIAS3_PWD_IR25DAC_GET(x)                                          (((x) & 0x03800000) >> 23)
-#define PHY_ANALOG_BIAS3_PWD_IR25DAC_SET(x)                                          (((x) << 23) & 0x03800000)
-#define PHY_ANALOG_BIAS3_PWD_IR25FIR_MSB                                                                     28
-#define PHY_ANALOG_BIAS3_PWD_IR25FIR_LSB                                                                     26
-#define PHY_ANALOG_BIAS3_PWD_IR25FIR_MASK                                                            0x1c000000
-#define PHY_ANALOG_BIAS3_PWD_IR25FIR_GET(x)                                          (((x) & 0x1c000000) >> 26)
-#define PHY_ANALOG_BIAS3_PWD_IR25FIR_SET(x)                                          (((x) << 26) & 0x1c000000)
-#define PHY_ANALOG_BIAS3_PWD_IR50ADC_MSB                                                                     31
-#define PHY_ANALOG_BIAS3_PWD_IR50ADC_LSB                                                                     29
-#define PHY_ANALOG_BIAS3_PWD_IR50ADC_MASK                                                            0xe0000000
-#define PHY_ANALOG_BIAS3_PWD_IR50ADC_GET(x)                                          (((x) & 0xe0000000) >> 29)
-#define PHY_ANALOG_BIAS3_PWD_IR50ADC_SET(x)                                          (((x) << 29) & 0xe0000000)
-
-/* macros for BIAS4 */
-#define PHY_ANALOG_BIAS4_ADDRESS                                                                     0x000000cc
-#define PHY_ANALOG_BIAS4_OFFSET                                                                      0x000000cc
-#define PHY_ANALOG_BIAS4_SPARE4_MSB                                                                          10
-#define PHY_ANALOG_BIAS4_SPARE4_LSB                                                                           0
-#define PHY_ANALOG_BIAS4_SPARE4_MASK                                                                 0x000007ff
-#define PHY_ANALOG_BIAS4_SPARE4_GET(x)                                                (((x) & 0x000007ff) >> 0)
-#define PHY_ANALOG_BIAS4_SPARE4_SET(x)                                                (((x) << 0) & 0x000007ff)
-#define PHY_ANALOG_BIAS4_PWD_IR25SPARED_MSB                                                                  13
-#define PHY_ANALOG_BIAS4_PWD_IR25SPARED_LSB                                                                  11
-#define PHY_ANALOG_BIAS4_PWD_IR25SPARED_MASK                                                         0x00003800
-#define PHY_ANALOG_BIAS4_PWD_IR25SPARED_GET(x)                                       (((x) & 0x00003800) >> 11)
-#define PHY_ANALOG_BIAS4_PWD_IR25SPARED_SET(x)                                       (((x) << 11) & 0x00003800)
-#define PHY_ANALOG_BIAS4_PWD_IR25SPAREC_MSB                                                                  16
-#define PHY_ANALOG_BIAS4_PWD_IR25SPAREC_LSB                                                                  14
-#define PHY_ANALOG_BIAS4_PWD_IR25SPAREC_MASK                                                         0x0001c000
-#define PHY_ANALOG_BIAS4_PWD_IR25SPAREC_GET(x)                                       (((x) & 0x0001c000) >> 14)
-#define PHY_ANALOG_BIAS4_PWD_IR25SPAREC_SET(x)                                       (((x) << 14) & 0x0001c000)
-#define PHY_ANALOG_BIAS4_PWD_IR25SPAREB_MSB                                                                  19
-#define PHY_ANALOG_BIAS4_PWD_IR25SPAREB_LSB                                                                  17
-#define PHY_ANALOG_BIAS4_PWD_IR25SPAREB_MASK                                                         0x000e0000
-#define PHY_ANALOG_BIAS4_PWD_IR25SPAREB_GET(x)                                       (((x) & 0x000e0000) >> 17)
-#define PHY_ANALOG_BIAS4_PWD_IR25SPAREB_SET(x)                                       (((x) << 17) & 0x000e0000)
-#define PHY_ANALOG_BIAS4_PWD_IR25XPA_MSB                                                                     22
-#define PHY_ANALOG_BIAS4_PWD_IR25XPA_LSB                                                                     20
-#define PHY_ANALOG_BIAS4_PWD_IR25XPA_MASK                                                            0x00700000
-#define PHY_ANALOG_BIAS4_PWD_IR25XPA_GET(x)                                          (((x) & 0x00700000) >> 20)
-#define PHY_ANALOG_BIAS4_PWD_IR25XPA_SET(x)                                          (((x) << 20) & 0x00700000)
-#define PHY_ANALOG_BIAS4_PWD_IC25SPAREC_MSB                                                                  25
-#define PHY_ANALOG_BIAS4_PWD_IC25SPAREC_LSB                                                                  23
-#define PHY_ANALOG_BIAS4_PWD_IC25SPAREC_MASK                                                         0x03800000
-#define PHY_ANALOG_BIAS4_PWD_IC25SPAREC_GET(x)                                       (((x) & 0x03800000) >> 23)
-#define PHY_ANALOG_BIAS4_PWD_IC25SPAREC_SET(x)                                       (((x) << 23) & 0x03800000)
-#define PHY_ANALOG_BIAS4_PWD_IC25SPAREB_MSB                                                                  28
-#define PHY_ANALOG_BIAS4_PWD_IC25SPAREB_LSB                                                                  26
-#define PHY_ANALOG_BIAS4_PWD_IC25SPAREB_MASK                                                         0x1c000000
-#define PHY_ANALOG_BIAS4_PWD_IC25SPAREB_GET(x)                                       (((x) & 0x1c000000) >> 26)
-#define PHY_ANALOG_BIAS4_PWD_IC25SPAREB_SET(x)                                       (((x) << 26) & 0x1c000000)
-#define PHY_ANALOG_BIAS4_PWD_IC25SPAREA_MSB                                                                  31
-#define PHY_ANALOG_BIAS4_PWD_IC25SPAREA_LSB                                                                  29
-#define PHY_ANALOG_BIAS4_PWD_IC25SPAREA_MASK                                                         0xe0000000
-#define PHY_ANALOG_BIAS4_PWD_IC25SPAREA_GET(x)                                       (((x) & 0xe0000000) >> 29)
-#define PHY_ANALOG_BIAS4_PWD_IC25SPAREA_SET(x)                                       (((x) << 29) & 0xe0000000)
-
-/* macros for RXTX1 */
-#define PHY_ANALOG_RXTX1_ADDRESS                                                                     0x00000100
-#define PHY_ANALOG_RXTX1_OFFSET                                                                      0x00000100
-#define PHY_ANALOG_RXTX1_SCFIR_GAIN_MSB                                                                       0
-#define PHY_ANALOG_RXTX1_SCFIR_GAIN_LSB                                                                       0
-#define PHY_ANALOG_RXTX1_SCFIR_GAIN_MASK                                                             0x00000001
-#define PHY_ANALOG_RXTX1_SCFIR_GAIN_GET(x)                                            (((x) & 0x00000001) >> 0)
-#define PHY_ANALOG_RXTX1_SCFIR_GAIN_SET(x)                                            (((x) << 0) & 0x00000001)
-#define PHY_ANALOG_RXTX1_MANRXGAIN_MSB                                                                        1
-#define PHY_ANALOG_RXTX1_MANRXGAIN_LSB                                                                        1
-#define PHY_ANALOG_RXTX1_MANRXGAIN_MASK                                                              0x00000002
-#define PHY_ANALOG_RXTX1_MANRXGAIN_GET(x)                                             (((x) & 0x00000002) >> 1)
-#define PHY_ANALOG_RXTX1_MANRXGAIN_SET(x)                                             (((x) << 1) & 0x00000002)
-#define PHY_ANALOG_RXTX1_AGC_DBDAC_MSB                                                                        5
-#define PHY_ANALOG_RXTX1_AGC_DBDAC_LSB                                                                        2
-#define PHY_ANALOG_RXTX1_AGC_DBDAC_MASK                                                              0x0000003c
-#define PHY_ANALOG_RXTX1_AGC_DBDAC_GET(x)                                             (((x) & 0x0000003c) >> 2)
-#define PHY_ANALOG_RXTX1_AGC_DBDAC_SET(x)                                             (((x) << 2) & 0x0000003c)
-#define PHY_ANALOG_RXTX1_OVR_AGC_DBDAC_MSB                                                                    6
-#define PHY_ANALOG_RXTX1_OVR_AGC_DBDAC_LSB                                                                    6
-#define PHY_ANALOG_RXTX1_OVR_AGC_DBDAC_MASK                                                          0x00000040
-#define PHY_ANALOG_RXTX1_OVR_AGC_DBDAC_GET(x)                                         (((x) & 0x00000040) >> 6)
-#define PHY_ANALOG_RXTX1_OVR_AGC_DBDAC_SET(x)                                         (((x) << 6) & 0x00000040)
-#define PHY_ANALOG_RXTX1_ENABLE_PAL_MSB                                                                       7
-#define PHY_ANALOG_RXTX1_ENABLE_PAL_LSB                                                                       7
-#define PHY_ANALOG_RXTX1_ENABLE_PAL_MASK                                                             0x00000080
-#define PHY_ANALOG_RXTX1_ENABLE_PAL_GET(x)                                            (((x) & 0x00000080) >> 7)
-#define PHY_ANALOG_RXTX1_ENABLE_PAL_SET(x)                                            (((x) << 7) & 0x00000080)
-#define PHY_ANALOG_RXTX1_ENABLE_PAL_OVR_MSB                                                                   8
-#define PHY_ANALOG_RXTX1_ENABLE_PAL_OVR_LSB                                                                   8
-#define PHY_ANALOG_RXTX1_ENABLE_PAL_OVR_MASK                                                         0x00000100
-#define PHY_ANALOG_RXTX1_ENABLE_PAL_OVR_GET(x)                                        (((x) & 0x00000100) >> 8)
-#define PHY_ANALOG_RXTX1_ENABLE_PAL_OVR_SET(x)                                        (((x) << 8) & 0x00000100)
-#define PHY_ANALOG_RXTX1_TX1DB_BIQUAD_MSB                                                                    11
-#define PHY_ANALOG_RXTX1_TX1DB_BIQUAD_LSB                                                                     9
-#define PHY_ANALOG_RXTX1_TX1DB_BIQUAD_MASK                                                           0x00000e00
-#define PHY_ANALOG_RXTX1_TX1DB_BIQUAD_GET(x)                                          (((x) & 0x00000e00) >> 9)
-#define PHY_ANALOG_RXTX1_TX1DB_BIQUAD_SET(x)                                          (((x) << 9) & 0x00000e00)
-#define PHY_ANALOG_RXTX1_TX6DB_BIQUAD_MSB                                                                    13
-#define PHY_ANALOG_RXTX1_TX6DB_BIQUAD_LSB                                                                    12
-#define PHY_ANALOG_RXTX1_TX6DB_BIQUAD_MASK                                                           0x00003000
-#define PHY_ANALOG_RXTX1_TX6DB_BIQUAD_GET(x)                                         (((x) & 0x00003000) >> 12)
-#define PHY_ANALOG_RXTX1_TX6DB_BIQUAD_SET(x)                                         (((x) << 12) & 0x00003000)
-#define PHY_ANALOG_RXTX1_PADRVHALFGN2G_MSB                                                                   14
-#define PHY_ANALOG_RXTX1_PADRVHALFGN2G_LSB                                                                   14
-#define PHY_ANALOG_RXTX1_PADRVHALFGN2G_MASK                                                          0x00004000
-#define PHY_ANALOG_RXTX1_PADRVHALFGN2G_GET(x)                                        (((x) & 0x00004000) >> 14)
-#define PHY_ANALOG_RXTX1_PADRVHALFGN2G_SET(x)                                        (((x) << 14) & 0x00004000)
-#define PHY_ANALOG_RXTX1_PADRV2GN_MSB                                                                        18
-#define PHY_ANALOG_RXTX1_PADRV2GN_LSB                                                                        15
-#define PHY_ANALOG_RXTX1_PADRV2GN_MASK                                                               0x00078000
-#define PHY_ANALOG_RXTX1_PADRV2GN_GET(x)                                             (((x) & 0x00078000) >> 15)
-#define PHY_ANALOG_RXTX1_PADRV2GN_SET(x)                                             (((x) << 15) & 0x00078000)
-#define PHY_ANALOG_RXTX1_PADRV3GN5G_MSB                                                                      22
-#define PHY_ANALOG_RXTX1_PADRV3GN5G_LSB                                                                      19
-#define PHY_ANALOG_RXTX1_PADRV3GN5G_MASK                                                             0x00780000
-#define PHY_ANALOG_RXTX1_PADRV3GN5G_GET(x)                                           (((x) & 0x00780000) >> 19)
-#define PHY_ANALOG_RXTX1_PADRV3GN5G_SET(x)                                           (((x) << 19) & 0x00780000)
-#define PHY_ANALOG_RXTX1_PADRV4GN5G_MSB                                                                      26
-#define PHY_ANALOG_RXTX1_PADRV4GN5G_LSB                                                                      23
-#define PHY_ANALOG_RXTX1_PADRV4GN5G_MASK                                                             0x07800000
-#define PHY_ANALOG_RXTX1_PADRV4GN5G_GET(x)                                           (((x) & 0x07800000) >> 23)
-#define PHY_ANALOG_RXTX1_PADRV4GN5G_SET(x)                                           (((x) << 23) & 0x07800000)
-#define PHY_ANALOG_RXTX1_TXBB_GC_MSB                                                                         30
-#define PHY_ANALOG_RXTX1_TXBB_GC_LSB                                                                         27
-#define PHY_ANALOG_RXTX1_TXBB_GC_MASK                                                                0x78000000
-#define PHY_ANALOG_RXTX1_TXBB_GC_GET(x)                                              (((x) & 0x78000000) >> 27)
-#define PHY_ANALOG_RXTX1_TXBB_GC_SET(x)                                              (((x) << 27) & 0x78000000)
-#define PHY_ANALOG_RXTX1_MANTXGAIN_MSB                                                                       31
-#define PHY_ANALOG_RXTX1_MANTXGAIN_LSB                                                                       31
-#define PHY_ANALOG_RXTX1_MANTXGAIN_MASK                                                              0x80000000
-#define PHY_ANALOG_RXTX1_MANTXGAIN_GET(x)                                            (((x) & 0x80000000) >> 31)
-#define PHY_ANALOG_RXTX1_MANTXGAIN_SET(x)                                            (((x) << 31) & 0x80000000)
-
-/* macros for RXTX2 */
-#define PHY_ANALOG_RXTX2_ADDRESS                                                                     0x00000104
-#define PHY_ANALOG_RXTX2_OFFSET                                                                      0x00000104
-#define PHY_ANALOG_RXTX2_BMODE_MSB                                                                            0
-#define PHY_ANALOG_RXTX2_BMODE_LSB                                                                            0
-#define PHY_ANALOG_RXTX2_BMODE_MASK                                                                  0x00000001
-#define PHY_ANALOG_RXTX2_BMODE_GET(x)                                                 (((x) & 0x00000001) >> 0)
-#define PHY_ANALOG_RXTX2_BMODE_SET(x)                                                 (((x) << 0) & 0x00000001)
-#define PHY_ANALOG_RXTX2_BMODE_OVR_MSB                                                                        1
-#define PHY_ANALOG_RXTX2_BMODE_OVR_LSB                                                                        1
-#define PHY_ANALOG_RXTX2_BMODE_OVR_MASK                                                              0x00000002
-#define PHY_ANALOG_RXTX2_BMODE_OVR_GET(x)                                             (((x) & 0x00000002) >> 1)
-#define PHY_ANALOG_RXTX2_BMODE_OVR_SET(x)                                             (((x) << 1) & 0x00000002)
-#define PHY_ANALOG_RXTX2_SYNTHON_MSB                                                                          2
-#define PHY_ANALOG_RXTX2_SYNTHON_LSB                                                                          2
-#define PHY_ANALOG_RXTX2_SYNTHON_MASK                                                                0x00000004
-#define PHY_ANALOG_RXTX2_SYNTHON_GET(x)                                               (((x) & 0x00000004) >> 2)
-#define PHY_ANALOG_RXTX2_SYNTHON_SET(x)                                               (((x) << 2) & 0x00000004)
-#define PHY_ANALOG_RXTX2_SYNTHON_OVR_MSB                                                                      3
-#define PHY_ANALOG_RXTX2_SYNTHON_OVR_LSB                                                                      3
-#define PHY_ANALOG_RXTX2_SYNTHON_OVR_MASK                                                            0x00000008
-#define PHY_ANALOG_RXTX2_SYNTHON_OVR_GET(x)                                           (((x) & 0x00000008) >> 3)
-#define PHY_ANALOG_RXTX2_SYNTHON_OVR_SET(x)                                           (((x) << 3) & 0x00000008)
-#define PHY_ANALOG_RXTX2_BW_ST_MSB                                                                            5
-#define PHY_ANALOG_RXTX2_BW_ST_LSB                                                                            4
-#define PHY_ANALOG_RXTX2_BW_ST_MASK                                                                  0x00000030
-#define PHY_ANALOG_RXTX2_BW_ST_GET(x)                                                 (((x) & 0x00000030) >> 4)
-#define PHY_ANALOG_RXTX2_BW_ST_SET(x)                                                 (((x) << 4) & 0x00000030)
-#define PHY_ANALOG_RXTX2_BW_ST_OVR_MSB                                                                        6
-#define PHY_ANALOG_RXTX2_BW_ST_OVR_LSB                                                                        6
-#define PHY_ANALOG_RXTX2_BW_ST_OVR_MASK                                                              0x00000040
-#define PHY_ANALOG_RXTX2_BW_ST_OVR_GET(x)                                             (((x) & 0x00000040) >> 6)
-#define PHY_ANALOG_RXTX2_BW_ST_OVR_SET(x)                                             (((x) << 6) & 0x00000040)
-#define PHY_ANALOG_RXTX2_TXON_MSB                                                                             7
-#define PHY_ANALOG_RXTX2_TXON_LSB                                                                             7
-#define PHY_ANALOG_RXTX2_TXON_MASK                                                                   0x00000080
-#define PHY_ANALOG_RXTX2_TXON_GET(x)                                                  (((x) & 0x00000080) >> 7)
-#define PHY_ANALOG_RXTX2_TXON_SET(x)                                                  (((x) << 7) & 0x00000080)
-#define PHY_ANALOG_RXTX2_TXON_OVR_MSB                                                                         8
-#define PHY_ANALOG_RXTX2_TXON_OVR_LSB                                                                         8
-#define PHY_ANALOG_RXTX2_TXON_OVR_MASK                                                               0x00000100
-#define PHY_ANALOG_RXTX2_TXON_OVR_GET(x)                                              (((x) & 0x00000100) >> 8)
-#define PHY_ANALOG_RXTX2_TXON_OVR_SET(x)                                              (((x) << 8) & 0x00000100)
-#define PHY_ANALOG_RXTX2_PAON_MSB                                                                             9
-#define PHY_ANALOG_RXTX2_PAON_LSB                                                                             9
-#define PHY_ANALOG_RXTX2_PAON_MASK                                                                   0x00000200
-#define PHY_ANALOG_RXTX2_PAON_GET(x)                                                  (((x) & 0x00000200) >> 9)
-#define PHY_ANALOG_RXTX2_PAON_SET(x)                                                  (((x) << 9) & 0x00000200)
-#define PHY_ANALOG_RXTX2_PAON_OVR_MSB                                                                        10
-#define PHY_ANALOG_RXTX2_PAON_OVR_LSB                                                                        10
-#define PHY_ANALOG_RXTX2_PAON_OVR_MASK                                                               0x00000400
-#define PHY_ANALOG_RXTX2_PAON_OVR_GET(x)                                             (((x) & 0x00000400) >> 10)
-#define PHY_ANALOG_RXTX2_PAON_OVR_SET(x)                                             (((x) << 10) & 0x00000400)
-#define PHY_ANALOG_RXTX2_RXON_MSB                                                                            11
-#define PHY_ANALOG_RXTX2_RXON_LSB                                                                            11
-#define PHY_ANALOG_RXTX2_RXON_MASK                                                                   0x00000800
-#define PHY_ANALOG_RXTX2_RXON_GET(x)                                                 (((x) & 0x00000800) >> 11)
-#define PHY_ANALOG_RXTX2_RXON_SET(x)                                                 (((x) << 11) & 0x00000800)
-#define PHY_ANALOG_RXTX2_RXON_OVR_MSB                                                                        12
-#define PHY_ANALOG_RXTX2_RXON_OVR_LSB                                                                        12
-#define PHY_ANALOG_RXTX2_RXON_OVR_MASK                                                               0x00001000
-#define PHY_ANALOG_RXTX2_RXON_OVR_GET(x)                                             (((x) & 0x00001000) >> 12)
-#define PHY_ANALOG_RXTX2_RXON_OVR_SET(x)                                             (((x) << 12) & 0x00001000)
-#define PHY_ANALOG_RXTX2_AGCON_MSB                                                                           13
-#define PHY_ANALOG_RXTX2_AGCON_LSB                                                                           13
-#define PHY_ANALOG_RXTX2_AGCON_MASK                                                                  0x00002000
-#define PHY_ANALOG_RXTX2_AGCON_GET(x)                                                (((x) & 0x00002000) >> 13)
-#define PHY_ANALOG_RXTX2_AGCON_SET(x)                                                (((x) << 13) & 0x00002000)
-#define PHY_ANALOG_RXTX2_AGCON_OVR_MSB                                                                       14
-#define PHY_ANALOG_RXTX2_AGCON_OVR_LSB                                                                       14
-#define PHY_ANALOG_RXTX2_AGCON_OVR_MASK                                                              0x00004000
-#define PHY_ANALOG_RXTX2_AGCON_OVR_GET(x)                                            (((x) & 0x00004000) >> 14)
-#define PHY_ANALOG_RXTX2_AGCON_OVR_SET(x)                                            (((x) << 14) & 0x00004000)
-#define PHY_ANALOG_RXTX2_TXMOD_MSB                                                                           17
-#define PHY_ANALOG_RXTX2_TXMOD_LSB                                                                           15
-#define PHY_ANALOG_RXTX2_TXMOD_MASK                                                                  0x00038000
-#define PHY_ANALOG_RXTX2_TXMOD_GET(x)                                                (((x) & 0x00038000) >> 15)
-#define PHY_ANALOG_RXTX2_TXMOD_SET(x)                                                (((x) << 15) & 0x00038000)
-#define PHY_ANALOG_RXTX2_TXMOD_OVR_MSB                                                                       18
-#define PHY_ANALOG_RXTX2_TXMOD_OVR_LSB                                                                       18
-#define PHY_ANALOG_RXTX2_TXMOD_OVR_MASK                                                              0x00040000
-#define PHY_ANALOG_RXTX2_TXMOD_OVR_GET(x)                                            (((x) & 0x00040000) >> 18)
-#define PHY_ANALOG_RXTX2_TXMOD_OVR_SET(x)                                            (((x) << 18) & 0x00040000)
-#define PHY_ANALOG_RXTX2_RX1DB_BIQUAD_MSB                                                                    21
-#define PHY_ANALOG_RXTX2_RX1DB_BIQUAD_LSB                                                                    19
-#define PHY_ANALOG_RXTX2_RX1DB_BIQUAD_MASK                                                           0x00380000
-#define PHY_ANALOG_RXTX2_RX1DB_BIQUAD_GET(x)                                         (((x) & 0x00380000) >> 19)
-#define PHY_ANALOG_RXTX2_RX1DB_BIQUAD_SET(x)                                         (((x) << 19) & 0x00380000)
-#define PHY_ANALOG_RXTX2_RX6DB_BIQUAD_MSB                                                                    23
-#define PHY_ANALOG_RXTX2_RX6DB_BIQUAD_LSB                                                                    22
-#define PHY_ANALOG_RXTX2_RX6DB_BIQUAD_MASK                                                           0x00c00000
-#define PHY_ANALOG_RXTX2_RX6DB_BIQUAD_GET(x)                                         (((x) & 0x00c00000) >> 22)
-#define PHY_ANALOG_RXTX2_RX6DB_BIQUAD_SET(x)                                         (((x) << 22) & 0x00c00000)
-#define PHY_ANALOG_RXTX2_MXRGAIN_MSB                                                                         25
-#define PHY_ANALOG_RXTX2_MXRGAIN_LSB                                                                         24
-#define PHY_ANALOG_RXTX2_MXRGAIN_MASK                                                                0x03000000
-#define PHY_ANALOG_RXTX2_MXRGAIN_GET(x)                                              (((x) & 0x03000000) >> 24)
-#define PHY_ANALOG_RXTX2_MXRGAIN_SET(x)                                              (((x) << 24) & 0x03000000)
-#define PHY_ANALOG_RXTX2_VGAGAIN_MSB                                                                         28
-#define PHY_ANALOG_RXTX2_VGAGAIN_LSB                                                                         26
-#define PHY_ANALOG_RXTX2_VGAGAIN_MASK                                                                0x1c000000
-#define PHY_ANALOG_RXTX2_VGAGAIN_GET(x)                                              (((x) & 0x1c000000) >> 26)
-#define PHY_ANALOG_RXTX2_VGAGAIN_SET(x)                                              (((x) << 26) & 0x1c000000)
-#define PHY_ANALOG_RXTX2_LNAGAIN_MSB                                                                         31
-#define PHY_ANALOG_RXTX2_LNAGAIN_LSB                                                                         29
-#define PHY_ANALOG_RXTX2_LNAGAIN_MASK                                                                0xe0000000
-#define PHY_ANALOG_RXTX2_LNAGAIN_GET(x)                                              (((x) & 0xe0000000) >> 29)
-#define PHY_ANALOG_RXTX2_LNAGAIN_SET(x)                                              (((x) << 29) & 0xe0000000)
-
-/* macros for RXTX3 */
-#define PHY_ANALOG_RXTX3_ADDRESS                                                                     0x00000108
-#define PHY_ANALOG_RXTX3_OFFSET                                                                      0x00000108
-#define PHY_ANALOG_RXTX3_SPARE3_MSB                                                                           2
-#define PHY_ANALOG_RXTX3_SPARE3_LSB                                                                           0
-#define PHY_ANALOG_RXTX3_SPARE3_MASK                                                                 0x00000007
-#define PHY_ANALOG_RXTX3_SPARE3_GET(x)                                                (((x) & 0x00000007) >> 0)
-#define PHY_ANALOG_RXTX3_SPARE3_SET(x)                                                (((x) << 0) & 0x00000007)
-#define PHY_ANALOG_RXTX3_SPURON_MSB                                                                           3
-#define PHY_ANALOG_RXTX3_SPURON_LSB                                                                           3
-#define PHY_ANALOG_RXTX3_SPURON_MASK                                                                 0x00000008
-#define PHY_ANALOG_RXTX3_SPURON_GET(x)                                                (((x) & 0x00000008) >> 3)
-#define PHY_ANALOG_RXTX3_SPURON_SET(x)                                                (((x) << 3) & 0x00000008)
-#define PHY_ANALOG_RXTX3_PAL_LOCKEDEN_MSB                                                                     4
-#define PHY_ANALOG_RXTX3_PAL_LOCKEDEN_LSB                                                                     4
-#define PHY_ANALOG_RXTX3_PAL_LOCKEDEN_MASK                                                           0x00000010
-#define PHY_ANALOG_RXTX3_PAL_LOCKEDEN_GET(x)                                          (((x) & 0x00000010) >> 4)
-#define PHY_ANALOG_RXTX3_PAL_LOCKEDEN_SET(x)                                          (((x) << 4) & 0x00000010)
-#define PHY_ANALOG_RXTX3_DACFULLSCALE_MSB                                                                     5
-#define PHY_ANALOG_RXTX3_DACFULLSCALE_LSB                                                                     5
-#define PHY_ANALOG_RXTX3_DACFULLSCALE_MASK                                                           0x00000020
-#define PHY_ANALOG_RXTX3_DACFULLSCALE_GET(x)                                          (((x) & 0x00000020) >> 5)
-#define PHY_ANALOG_RXTX3_DACFULLSCALE_SET(x)                                          (((x) << 5) & 0x00000020)
-#define PHY_ANALOG_RXTX3_ADCSHORT_MSB                                                                         6
-#define PHY_ANALOG_RXTX3_ADCSHORT_LSB                                                                         6
-#define PHY_ANALOG_RXTX3_ADCSHORT_MASK                                                               0x00000040
-#define PHY_ANALOG_RXTX3_ADCSHORT_GET(x)                                              (((x) & 0x00000040) >> 6)
-#define PHY_ANALOG_RXTX3_ADCSHORT_SET(x)                                              (((x) << 6) & 0x00000040)
-#define PHY_ANALOG_RXTX3_DACPWD_MSB                                                                           7
-#define PHY_ANALOG_RXTX3_DACPWD_LSB                                                                           7
-#define PHY_ANALOG_RXTX3_DACPWD_MASK                                                                 0x00000080
-#define PHY_ANALOG_RXTX3_DACPWD_GET(x)                                                (((x) & 0x00000080) >> 7)
-#define PHY_ANALOG_RXTX3_DACPWD_SET(x)                                                (((x) << 7) & 0x00000080)
-#define PHY_ANALOG_RXTX3_DACPWD_OVR_MSB                                                                       8
-#define PHY_ANALOG_RXTX3_DACPWD_OVR_LSB                                                                       8
-#define PHY_ANALOG_RXTX3_DACPWD_OVR_MASK                                                             0x00000100
-#define PHY_ANALOG_RXTX3_DACPWD_OVR_GET(x)                                            (((x) & 0x00000100) >> 8)
-#define PHY_ANALOG_RXTX3_DACPWD_OVR_SET(x)                                            (((x) << 8) & 0x00000100)
-#define PHY_ANALOG_RXTX3_ADCPWD_MSB                                                                           9
-#define PHY_ANALOG_RXTX3_ADCPWD_LSB                                                                           9
-#define PHY_ANALOG_RXTX3_ADCPWD_MASK                                                                 0x00000200
-#define PHY_ANALOG_RXTX3_ADCPWD_GET(x)                                                (((x) & 0x00000200) >> 9)
-#define PHY_ANALOG_RXTX3_ADCPWD_SET(x)                                                (((x) << 9) & 0x00000200)
-#define PHY_ANALOG_RXTX3_ADCPWD_OVR_MSB                                                                      10
-#define PHY_ANALOG_RXTX3_ADCPWD_OVR_LSB                                                                      10
-#define PHY_ANALOG_RXTX3_ADCPWD_OVR_MASK                                                             0x00000400
-#define PHY_ANALOG_RXTX3_ADCPWD_OVR_GET(x)                                           (((x) & 0x00000400) >> 10)
-#define PHY_ANALOG_RXTX3_ADCPWD_OVR_SET(x)                                           (((x) << 10) & 0x00000400)
-#define PHY_ANALOG_RXTX3_AGC_CALDAC_MSB                                                                      16
-#define PHY_ANALOG_RXTX3_AGC_CALDAC_LSB                                                                      11
-#define PHY_ANALOG_RXTX3_AGC_CALDAC_MASK                                                             0x0001f800
-#define PHY_ANALOG_RXTX3_AGC_CALDAC_GET(x)                                           (((x) & 0x0001f800) >> 11)
-#define PHY_ANALOG_RXTX3_AGC_CALDAC_SET(x)                                           (((x) << 11) & 0x0001f800)
-#define PHY_ANALOG_RXTX3_AGC_CAL_MSB                                                                         17
-#define PHY_ANALOG_RXTX3_AGC_CAL_LSB                                                                         17
-#define PHY_ANALOG_RXTX3_AGC_CAL_MASK                                                                0x00020000
-#define PHY_ANALOG_RXTX3_AGC_CAL_GET(x)                                              (((x) & 0x00020000) >> 17)
-#define PHY_ANALOG_RXTX3_AGC_CAL_SET(x)                                              (((x) << 17) & 0x00020000)
-#define PHY_ANALOG_RXTX3_AGC_CAL_OVR_MSB                                                                     18
-#define PHY_ANALOG_RXTX3_AGC_CAL_OVR_LSB                                                                     18
-#define PHY_ANALOG_RXTX3_AGC_CAL_OVR_MASK                                                            0x00040000
-#define PHY_ANALOG_RXTX3_AGC_CAL_OVR_GET(x)                                          (((x) & 0x00040000) >> 18)
-#define PHY_ANALOG_RXTX3_AGC_CAL_OVR_SET(x)                                          (((x) << 18) & 0x00040000)
-#define PHY_ANALOG_RXTX3_LOFORCEDON_MSB                                                                      19
-#define PHY_ANALOG_RXTX3_LOFORCEDON_LSB                                                                      19
-#define PHY_ANALOG_RXTX3_LOFORCEDON_MASK                                                             0x00080000
-#define PHY_ANALOG_RXTX3_LOFORCEDON_GET(x)                                           (((x) & 0x00080000) >> 19)
-#define PHY_ANALOG_RXTX3_LOFORCEDON_SET(x)                                           (((x) << 19) & 0x00080000)
-#define PHY_ANALOG_RXTX3_CALRESIDUE_MSB                                                                      20
-#define PHY_ANALOG_RXTX3_CALRESIDUE_LSB                                                                      20
-#define PHY_ANALOG_RXTX3_CALRESIDUE_MASK                                                             0x00100000
-#define PHY_ANALOG_RXTX3_CALRESIDUE_GET(x)                                           (((x) & 0x00100000) >> 20)
-#define PHY_ANALOG_RXTX3_CALRESIDUE_SET(x)                                           (((x) << 20) & 0x00100000)
-#define PHY_ANALOG_RXTX3_CALRESIDUE_OVR_MSB                                                                  21
-#define PHY_ANALOG_RXTX3_CALRESIDUE_OVR_LSB                                                                  21
-#define PHY_ANALOG_RXTX3_CALRESIDUE_OVR_MASK                                                         0x00200000
-#define PHY_ANALOG_RXTX3_CALRESIDUE_OVR_GET(x)                                       (((x) & 0x00200000) >> 21)
-#define PHY_ANALOG_RXTX3_CALRESIDUE_OVR_SET(x)                                       (((x) << 21) & 0x00200000)
-#define PHY_ANALOG_RXTX3_CALFC_MSB                                                                           22
-#define PHY_ANALOG_RXTX3_CALFC_LSB                                                                           22
-#define PHY_ANALOG_RXTX3_CALFC_MASK                                                                  0x00400000
-#define PHY_ANALOG_RXTX3_CALFC_GET(x)                                                (((x) & 0x00400000) >> 22)
-#define PHY_ANALOG_RXTX3_CALFC_SET(x)                                                (((x) << 22) & 0x00400000)
-#define PHY_ANALOG_RXTX3_CALFC_OVR_MSB                                                                       23
-#define PHY_ANALOG_RXTX3_CALFC_OVR_LSB                                                                       23
-#define PHY_ANALOG_RXTX3_CALFC_OVR_MASK                                                              0x00800000
-#define PHY_ANALOG_RXTX3_CALFC_OVR_GET(x)                                            (((x) & 0x00800000) >> 23)
-#define PHY_ANALOG_RXTX3_CALFC_OVR_SET(x)                                            (((x) << 23) & 0x00800000)
-#define PHY_ANALOG_RXTX3_CALTX_MSB                                                                           24
-#define PHY_ANALOG_RXTX3_CALTX_LSB                                                                           24
-#define PHY_ANALOG_RXTX3_CALTX_MASK                                                                  0x01000000
-#define PHY_ANALOG_RXTX3_CALTX_GET(x)                                                (((x) & 0x01000000) >> 24)
-#define PHY_ANALOG_RXTX3_CALTX_SET(x)                                                (((x) << 24) & 0x01000000)
-#define PHY_ANALOG_RXTX3_CALTX_OVR_MSB                                                                       25
-#define PHY_ANALOG_RXTX3_CALTX_OVR_LSB                                                                       25
-#define PHY_ANALOG_RXTX3_CALTX_OVR_MASK                                                              0x02000000
-#define PHY_ANALOG_RXTX3_CALTX_OVR_GET(x)                                            (((x) & 0x02000000) >> 25)
-#define PHY_ANALOG_RXTX3_CALTX_OVR_SET(x)                                            (((x) << 25) & 0x02000000)
-#define PHY_ANALOG_RXTX3_CALTXSHIFT_MSB                                                                      26
-#define PHY_ANALOG_RXTX3_CALTXSHIFT_LSB                                                                      26
-#define PHY_ANALOG_RXTX3_CALTXSHIFT_MASK                                                             0x04000000
-#define PHY_ANALOG_RXTX3_CALTXSHIFT_GET(x)                                           (((x) & 0x04000000) >> 26)
-#define PHY_ANALOG_RXTX3_CALTXSHIFT_SET(x)                                           (((x) << 26) & 0x04000000)
-#define PHY_ANALOG_RXTX3_CALTXSHIFT_OVR_MSB                                                                  27
-#define PHY_ANALOG_RXTX3_CALTXSHIFT_OVR_LSB                                                                  27
-#define PHY_ANALOG_RXTX3_CALTXSHIFT_OVR_MASK                                                         0x08000000
-#define PHY_ANALOG_RXTX3_CALTXSHIFT_OVR_GET(x)                                       (((x) & 0x08000000) >> 27)
-#define PHY_ANALOG_RXTX3_CALTXSHIFT_OVR_SET(x)                                       (((x) << 27) & 0x08000000)
-#define PHY_ANALOG_RXTX3_CALPA_MSB                                                                           28
-#define PHY_ANALOG_RXTX3_CALPA_LSB                                                                           28
-#define PHY_ANALOG_RXTX3_CALPA_MASK                                                                  0x10000000
-#define PHY_ANALOG_RXTX3_CALPA_GET(x)                                                (((x) & 0x10000000) >> 28)
-#define PHY_ANALOG_RXTX3_CALPA_SET(x)                                                (((x) << 28) & 0x10000000)
-#define PHY_ANALOG_RXTX3_CALPA_OVR_MSB                                                                       29
-#define PHY_ANALOG_RXTX3_CALPA_OVR_LSB                                                                       29
-#define PHY_ANALOG_RXTX3_CALPA_OVR_MASK                                                              0x20000000
-#define PHY_ANALOG_RXTX3_CALPA_OVR_GET(x)                                            (((x) & 0x20000000) >> 29)
-#define PHY_ANALOG_RXTX3_CALPA_OVR_SET(x)                                            (((x) << 29) & 0x20000000)
-#define PHY_ANALOG_RXTX3_TURBOADC_MSB                                                                        30
-#define PHY_ANALOG_RXTX3_TURBOADC_LSB                                                                        30
-#define PHY_ANALOG_RXTX3_TURBOADC_MASK                                                               0x40000000
-#define PHY_ANALOG_RXTX3_TURBOADC_GET(x)                                             (((x) & 0x40000000) >> 30)
-#define PHY_ANALOG_RXTX3_TURBOADC_SET(x)                                             (((x) << 30) & 0x40000000)
-#define PHY_ANALOG_RXTX3_TURBOADC_OVR_MSB                                                                    31
-#define PHY_ANALOG_RXTX3_TURBOADC_OVR_LSB                                                                    31
-#define PHY_ANALOG_RXTX3_TURBOADC_OVR_MASK                                                           0x80000000
-#define PHY_ANALOG_RXTX3_TURBOADC_OVR_GET(x)                                         (((x) & 0x80000000) >> 31)
-#define PHY_ANALOG_RXTX3_TURBOADC_OVR_SET(x)                                         (((x) << 31) & 0x80000000)
-
-/* macros for BB1 */
-#define PHY_ANALOG_BB1_ADDRESS                                                                       0x00000140
-#define PHY_ANALOG_BB1_OFFSET                                                                        0x00000140
-#define PHY_ANALOG_BB1_I2V_CURR2X_MSB                                                                         0
-#define PHY_ANALOG_BB1_I2V_CURR2X_LSB                                                                         0
-#define PHY_ANALOG_BB1_I2V_CURR2X_MASK                                                               0x00000001
-#define PHY_ANALOG_BB1_I2V_CURR2X_GET(x)                                              (((x) & 0x00000001) >> 0)
-#define PHY_ANALOG_BB1_I2V_CURR2X_SET(x)                                              (((x) << 0) & 0x00000001)
-#define PHY_ANALOG_BB1_ENABLE_LOQ_MSB                                                                         1
-#define PHY_ANALOG_BB1_ENABLE_LOQ_LSB                                                                         1
-#define PHY_ANALOG_BB1_ENABLE_LOQ_MASK                                                               0x00000002
-#define PHY_ANALOG_BB1_ENABLE_LOQ_GET(x)                                              (((x) & 0x00000002) >> 1)
-#define PHY_ANALOG_BB1_ENABLE_LOQ_SET(x)                                              (((x) << 1) & 0x00000002)
-#define PHY_ANALOG_BB1_FORCE_LOQ_MSB                                                                          2
-#define PHY_ANALOG_BB1_FORCE_LOQ_LSB                                                                          2
-#define PHY_ANALOG_BB1_FORCE_LOQ_MASK                                                                0x00000004
-#define PHY_ANALOG_BB1_FORCE_LOQ_GET(x)                                               (((x) & 0x00000004) >> 2)
-#define PHY_ANALOG_BB1_FORCE_LOQ_SET(x)                                               (((x) << 2) & 0x00000004)
-#define PHY_ANALOG_BB1_ENABLE_NOTCH_MSB                                                                       3
-#define PHY_ANALOG_BB1_ENABLE_NOTCH_LSB                                                                       3
-#define PHY_ANALOG_BB1_ENABLE_NOTCH_MASK                                                             0x00000008
-#define PHY_ANALOG_BB1_ENABLE_NOTCH_GET(x)                                            (((x) & 0x00000008) >> 3)
-#define PHY_ANALOG_BB1_ENABLE_NOTCH_SET(x)                                            (((x) << 3) & 0x00000008)
-#define PHY_ANALOG_BB1_FORCE_NOTCH_MSB                                                                        4
-#define PHY_ANALOG_BB1_FORCE_NOTCH_LSB                                                                        4
-#define PHY_ANALOG_BB1_FORCE_NOTCH_MASK                                                              0x00000010
-#define PHY_ANALOG_BB1_FORCE_NOTCH_GET(x)                                             (((x) & 0x00000010) >> 4)
-#define PHY_ANALOG_BB1_FORCE_NOTCH_SET(x)                                             (((x) << 4) & 0x00000010)
-#define PHY_ANALOG_BB1_ENABLE_BIQUAD_MSB                                                                      5
-#define PHY_ANALOG_BB1_ENABLE_BIQUAD_LSB                                                                      5
-#define PHY_ANALOG_BB1_ENABLE_BIQUAD_MASK                                                            0x00000020
-#define PHY_ANALOG_BB1_ENABLE_BIQUAD_GET(x)                                           (((x) & 0x00000020) >> 5)
-#define PHY_ANALOG_BB1_ENABLE_BIQUAD_SET(x)                                           (((x) << 5) & 0x00000020)
-#define PHY_ANALOG_BB1_FORCE_BIQUAD_MSB                                                                       6
-#define PHY_ANALOG_BB1_FORCE_BIQUAD_LSB                                                                       6
-#define PHY_ANALOG_BB1_FORCE_BIQUAD_MASK                                                             0x00000040
-#define PHY_ANALOG_BB1_FORCE_BIQUAD_GET(x)                                            (((x) & 0x00000040) >> 6)
-#define PHY_ANALOG_BB1_FORCE_BIQUAD_SET(x)                                            (((x) << 6) & 0x00000040)
-#define PHY_ANALOG_BB1_ENABLE_OSDAC_MSB                                                                       7
-#define PHY_ANALOG_BB1_ENABLE_OSDAC_LSB                                                                       7
-#define PHY_ANALOG_BB1_ENABLE_OSDAC_MASK                                                             0x00000080
-#define PHY_ANALOG_BB1_ENABLE_OSDAC_GET(x)                                            (((x) & 0x00000080) >> 7)
-#define PHY_ANALOG_BB1_ENABLE_OSDAC_SET(x)                                            (((x) << 7) & 0x00000080)
-#define PHY_ANALOG_BB1_FORCE_OSDAC_MSB                                                                        8
-#define PHY_ANALOG_BB1_FORCE_OSDAC_LSB                                                                        8
-#define PHY_ANALOG_BB1_FORCE_OSDAC_MASK                                                              0x00000100
-#define PHY_ANALOG_BB1_FORCE_OSDAC_GET(x)                                             (((x) & 0x00000100) >> 8)
-#define PHY_ANALOG_BB1_FORCE_OSDAC_SET(x)                                             (((x) << 8) & 0x00000100)
-#define PHY_ANALOG_BB1_ENABLE_V2I_MSB                                                                         9
-#define PHY_ANALOG_BB1_ENABLE_V2I_LSB                                                                         9
-#define PHY_ANALOG_BB1_ENABLE_V2I_MASK                                                               0x00000200
-#define PHY_ANALOG_BB1_ENABLE_V2I_GET(x)                                              (((x) & 0x00000200) >> 9)
-#define PHY_ANALOG_BB1_ENABLE_V2I_SET(x)                                              (((x) << 9) & 0x00000200)
-#define PHY_ANALOG_BB1_FORCE_V2I_MSB                                                                         10
-#define PHY_ANALOG_BB1_FORCE_V2I_LSB                                                                         10
-#define PHY_ANALOG_BB1_FORCE_V2I_MASK                                                                0x00000400
-#define PHY_ANALOG_BB1_FORCE_V2I_GET(x)                                              (((x) & 0x00000400) >> 10)
-#define PHY_ANALOG_BB1_FORCE_V2I_SET(x)                                              (((x) << 10) & 0x00000400)
-#define PHY_ANALOG_BB1_ENABLE_I2V_MSB                                                                        11
-#define PHY_ANALOG_BB1_ENABLE_I2V_LSB                                                                        11
-#define PHY_ANALOG_BB1_ENABLE_I2V_MASK                                                               0x00000800
-#define PHY_ANALOG_BB1_ENABLE_I2V_GET(x)                                             (((x) & 0x00000800) >> 11)
-#define PHY_ANALOG_BB1_ENABLE_I2V_SET(x)                                             (((x) << 11) & 0x00000800)
-#define PHY_ANALOG_BB1_FORCE_I2V_MSB                                                                         12
-#define PHY_ANALOG_BB1_FORCE_I2V_LSB                                                                         12
-#define PHY_ANALOG_BB1_FORCE_I2V_MASK                                                                0x00001000
-#define PHY_ANALOG_BB1_FORCE_I2V_GET(x)                                              (((x) & 0x00001000) >> 12)
-#define PHY_ANALOG_BB1_FORCE_I2V_SET(x)                                              (((x) << 12) & 0x00001000)
-#define PHY_ANALOG_BB1_CMSEL_MSB                                                                             15
-#define PHY_ANALOG_BB1_CMSEL_LSB                                                                             13
-#define PHY_ANALOG_BB1_CMSEL_MASK                                                                    0x0000e000
-#define PHY_ANALOG_BB1_CMSEL_GET(x)                                                  (((x) & 0x0000e000) >> 13)
-#define PHY_ANALOG_BB1_CMSEL_SET(x)                                                  (((x) << 13) & 0x0000e000)
-#define PHY_ANALOG_BB1_ATBSEL_MSB                                                                            17
-#define PHY_ANALOG_BB1_ATBSEL_LSB                                                                            16
-#define PHY_ANALOG_BB1_ATBSEL_MASK                                                                   0x00030000
-#define PHY_ANALOG_BB1_ATBSEL_GET(x)                                                 (((x) & 0x00030000) >> 16)
-#define PHY_ANALOG_BB1_ATBSEL_SET(x)                                                 (((x) << 16) & 0x00030000)
-#define PHY_ANALOG_BB1_PD_OSDAC_CALTX_CALPA_MSB                                                              18
-#define PHY_ANALOG_BB1_PD_OSDAC_CALTX_CALPA_LSB                                                              18
-#define PHY_ANALOG_BB1_PD_OSDAC_CALTX_CALPA_MASK                                                     0x00040000
-#define PHY_ANALOG_BB1_PD_OSDAC_CALTX_CALPA_GET(x)                                   (((x) & 0x00040000) >> 18)
-#define PHY_ANALOG_BB1_PD_OSDAC_CALTX_CALPA_SET(x)                                   (((x) << 18) & 0x00040000)
-#define PHY_ANALOG_BB1_OFSTCORRI2VQ_MSB                                                                      23
-#define PHY_ANALOG_BB1_OFSTCORRI2VQ_LSB                                                                      19
-#define PHY_ANALOG_BB1_OFSTCORRI2VQ_MASK                                                             0x00f80000
-#define PHY_ANALOG_BB1_OFSTCORRI2VQ_GET(x)                                           (((x) & 0x00f80000) >> 19)
-#define PHY_ANALOG_BB1_OFSTCORRI2VQ_SET(x)                                           (((x) << 19) & 0x00f80000)
-#define PHY_ANALOG_BB1_OFSTCORRI2VI_MSB                                                                      28
-#define PHY_ANALOG_BB1_OFSTCORRI2VI_LSB                                                                      24
-#define PHY_ANALOG_BB1_OFSTCORRI2VI_MASK                                                             0x1f000000
-#define PHY_ANALOG_BB1_OFSTCORRI2VI_GET(x)                                           (((x) & 0x1f000000) >> 24)
-#define PHY_ANALOG_BB1_OFSTCORRI2VI_SET(x)                                           (((x) << 24) & 0x1f000000)
-#define PHY_ANALOG_BB1_LOCALOFFSET_MSB                                                                       29
-#define PHY_ANALOG_BB1_LOCALOFFSET_LSB                                                                       29
-#define PHY_ANALOG_BB1_LOCALOFFSET_MASK                                                              0x20000000
-#define PHY_ANALOG_BB1_LOCALOFFSET_GET(x)                                            (((x) & 0x20000000) >> 29)
-#define PHY_ANALOG_BB1_LOCALOFFSET_SET(x)                                            (((x) << 29) & 0x20000000)
-#define PHY_ANALOG_BB1_RANGE_OSDAC_MSB                                                                       31
-#define PHY_ANALOG_BB1_RANGE_OSDAC_LSB                                                                       30
-#define PHY_ANALOG_BB1_RANGE_OSDAC_MASK                                                              0xc0000000
-#define PHY_ANALOG_BB1_RANGE_OSDAC_GET(x)                                            (((x) & 0xc0000000) >> 30)
-#define PHY_ANALOG_BB1_RANGE_OSDAC_SET(x)                                            (((x) << 30) & 0xc0000000)
-
-/* macros for BB2 */
-#define PHY_ANALOG_BB2_ADDRESS                                                                       0x00000144
-#define PHY_ANALOG_BB2_OFFSET                                                                        0x00000144
-#define PHY_ANALOG_BB2_SPARE_MSB                                                                              3
-#define PHY_ANALOG_BB2_SPARE_LSB                                                                              0
-#define PHY_ANALOG_BB2_SPARE_MASK                                                                    0x0000000f
-#define PHY_ANALOG_BB2_SPARE_GET(x)                                                   (((x) & 0x0000000f) >> 0)
-#define PHY_ANALOG_BB2_SPARE_SET(x)                                                   (((x) << 0) & 0x0000000f)
-#define PHY_ANALOG_BB2_MXR_HIGHGAINMASK_MSB                                                                   7
-#define PHY_ANALOG_BB2_MXR_HIGHGAINMASK_LSB                                                                   4
-#define PHY_ANALOG_BB2_MXR_HIGHGAINMASK_MASK                                                         0x000000f0
-#define PHY_ANALOG_BB2_MXR_HIGHGAINMASK_GET(x)                                        (((x) & 0x000000f0) >> 4)
-#define PHY_ANALOG_BB2_MXR_HIGHGAINMASK_SET(x)                                        (((x) << 4) & 0x000000f0)
-#define PHY_ANALOG_BB2_SEL_TEST_MSB                                                                           9
-#define PHY_ANALOG_BB2_SEL_TEST_LSB                                                                           8
-#define PHY_ANALOG_BB2_SEL_TEST_MASK                                                                 0x00000300
-#define PHY_ANALOG_BB2_SEL_TEST_GET(x)                                                (((x) & 0x00000300) >> 8)
-#define PHY_ANALOG_BB2_SEL_TEST_SET(x)                                                (((x) << 8) & 0x00000300)
-#define PHY_ANALOG_BB2_RCFILTER_CAP_MSB                                                                      14
-#define PHY_ANALOG_BB2_RCFILTER_CAP_LSB                                                                      10
-#define PHY_ANALOG_BB2_RCFILTER_CAP_MASK                                                             0x00007c00
-#define PHY_ANALOG_BB2_RCFILTER_CAP_GET(x)                                           (((x) & 0x00007c00) >> 10)
-#define PHY_ANALOG_BB2_RCFILTER_CAP_SET(x)                                           (((x) << 10) & 0x00007c00)
-#define PHY_ANALOG_BB2_OVERRIDE_RCFILTER_CAP_MSB                                                             15
-#define PHY_ANALOG_BB2_OVERRIDE_RCFILTER_CAP_LSB                                                             15
-#define PHY_ANALOG_BB2_OVERRIDE_RCFILTER_CAP_MASK                                                    0x00008000
-#define PHY_ANALOG_BB2_OVERRIDE_RCFILTER_CAP_GET(x)                                  (((x) & 0x00008000) >> 15)
-#define PHY_ANALOG_BB2_OVERRIDE_RCFILTER_CAP_SET(x)                                  (((x) << 15) & 0x00008000)
-#define PHY_ANALOG_BB2_FNOTCH_MSB                                                                            19
-#define PHY_ANALOG_BB2_FNOTCH_LSB                                                                            16
-#define PHY_ANALOG_BB2_FNOTCH_MASK                                                                   0x000f0000
-#define PHY_ANALOG_BB2_FNOTCH_GET(x)                                                 (((x) & 0x000f0000) >> 16)
-#define PHY_ANALOG_BB2_FNOTCH_SET(x)                                                 (((x) << 16) & 0x000f0000)
-#define PHY_ANALOG_BB2_OVERRIDE_FNOTCH_MSB                                                                   20
-#define PHY_ANALOG_BB2_OVERRIDE_FNOTCH_LSB                                                                   20
-#define PHY_ANALOG_BB2_OVERRIDE_FNOTCH_MASK                                                          0x00100000
-#define PHY_ANALOG_BB2_OVERRIDE_FNOTCH_GET(x)                                        (((x) & 0x00100000) >> 20)
-#define PHY_ANALOG_BB2_OVERRIDE_FNOTCH_SET(x)                                        (((x) << 20) & 0x00100000)
-#define PHY_ANALOG_BB2_FILTERFC_MSB                                                                          25
-#define PHY_ANALOG_BB2_FILTERFC_LSB                                                                          21
-#define PHY_ANALOG_BB2_FILTERFC_MASK                                                                 0x03e00000
-#define PHY_ANALOG_BB2_FILTERFC_GET(x)                                               (((x) & 0x03e00000) >> 21)
-#define PHY_ANALOG_BB2_FILTERFC_SET(x)                                               (((x) << 21) & 0x03e00000)
-#define PHY_ANALOG_BB2_OVERRIDE_FILTERFC_MSB                                                                 26
-#define PHY_ANALOG_BB2_OVERRIDE_FILTERFC_LSB                                                                 26
-#define PHY_ANALOG_BB2_OVERRIDE_FILTERFC_MASK                                                        0x04000000
-#define PHY_ANALOG_BB2_OVERRIDE_FILTERFC_GET(x)                                      (((x) & 0x04000000) >> 26)
-#define PHY_ANALOG_BB2_OVERRIDE_FILTERFC_SET(x)                                      (((x) << 26) & 0x04000000)
-#define PHY_ANALOG_BB2_I2V2RXOUT_EN_MSB                                                                      27
-#define PHY_ANALOG_BB2_I2V2RXOUT_EN_LSB                                                                      27
-#define PHY_ANALOG_BB2_I2V2RXOUT_EN_MASK                                                             0x08000000
-#define PHY_ANALOG_BB2_I2V2RXOUT_EN_GET(x)                                           (((x) & 0x08000000) >> 27)
-#define PHY_ANALOG_BB2_I2V2RXOUT_EN_SET(x)                                           (((x) << 27) & 0x08000000)
-#define PHY_ANALOG_BB2_BQ2RXOUT_EN_MSB                                                                       28
-#define PHY_ANALOG_BB2_BQ2RXOUT_EN_LSB                                                                       28
-#define PHY_ANALOG_BB2_BQ2RXOUT_EN_MASK                                                              0x10000000
-#define PHY_ANALOG_BB2_BQ2RXOUT_EN_GET(x)                                            (((x) & 0x10000000) >> 28)
-#define PHY_ANALOG_BB2_BQ2RXOUT_EN_SET(x)                                            (((x) << 28) & 0x10000000)
-#define PHY_ANALOG_BB2_RXIN2I2V_EN_MSB                                                                       29
-#define PHY_ANALOG_BB2_RXIN2I2V_EN_LSB                                                                       29
-#define PHY_ANALOG_BB2_RXIN2I2V_EN_MASK                                                              0x20000000
-#define PHY_ANALOG_BB2_RXIN2I2V_EN_GET(x)                                            (((x) & 0x20000000) >> 29)
-#define PHY_ANALOG_BB2_RXIN2I2V_EN_SET(x)                                            (((x) << 29) & 0x20000000)
-#define PHY_ANALOG_BB2_RXIN2BQ_EN_MSB                                                                        30
-#define PHY_ANALOG_BB2_RXIN2BQ_EN_LSB                                                                        30
-#define PHY_ANALOG_BB2_RXIN2BQ_EN_MASK                                                               0x40000000
-#define PHY_ANALOG_BB2_RXIN2BQ_EN_GET(x)                                             (((x) & 0x40000000) >> 30)
-#define PHY_ANALOG_BB2_RXIN2BQ_EN_SET(x)                                             (((x) << 30) & 0x40000000)
-#define PHY_ANALOG_BB2_SWITCH_OVERRIDE_MSB                                                                   31
-#define PHY_ANALOG_BB2_SWITCH_OVERRIDE_LSB                                                                   31
-#define PHY_ANALOG_BB2_SWITCH_OVERRIDE_MASK                                                          0x80000000
-#define PHY_ANALOG_BB2_SWITCH_OVERRIDE_GET(x)                                        (((x) & 0x80000000) >> 31)
-#define PHY_ANALOG_BB2_SWITCH_OVERRIDE_SET(x)                                        (((x) << 31) & 0x80000000)
-
-/* macros for BB3 */
-#define PHY_ANALOG_BB3_ADDRESS                                                                       0x00000148
-#define PHY_ANALOG_BB3_OFFSET                                                                        0x00000148
-#define PHY_ANALOG_BB3_SPARE_MSB                                                                             15
-#define PHY_ANALOG_BB3_SPARE_LSB                                                                              0
-#define PHY_ANALOG_BB3_SPARE_MASK                                                                    0x0000ffff
-#define PHY_ANALOG_BB3_SPARE_GET(x)                                                   (((x) & 0x0000ffff) >> 0)
-#define PHY_ANALOG_BB3_SPARE_SET(x)                                                   (((x) << 0) & 0x0000ffff)
-#define PHY_ANALOG_BB3_FILTERFC_MSB                                                                          20
-#define PHY_ANALOG_BB3_FILTERFC_LSB                                                                          16
-#define PHY_ANALOG_BB3_FILTERFC_MASK                                                                 0x001f0000
-#define PHY_ANALOG_BB3_FILTERFC_GET(x)                                               (((x) & 0x001f0000) >> 16)
-#define PHY_ANALOG_BB3_OFSTCORRI2VQ_MSB                                                                      25
-#define PHY_ANALOG_BB3_OFSTCORRI2VQ_LSB                                                                      21
-#define PHY_ANALOG_BB3_OFSTCORRI2VQ_MASK                                                             0x03e00000
-#define PHY_ANALOG_BB3_OFSTCORRI2VQ_GET(x)                                           (((x) & 0x03e00000) >> 21)
-#define PHY_ANALOG_BB3_OFSTCORRI2VI_MSB                                                                      30
-#define PHY_ANALOG_BB3_OFSTCORRI2VI_LSB                                                                      26
-#define PHY_ANALOG_BB3_OFSTCORRI2VI_MASK                                                             0x7c000000
-#define PHY_ANALOG_BB3_OFSTCORRI2VI_GET(x)                                           (((x) & 0x7c000000) >> 26)
-#define PHY_ANALOG_BB3_EN_TXBBCONSTCUR_MSB                                                                   31
-#define PHY_ANALOG_BB3_EN_TXBBCONSTCUR_LSB                                                                   31
-#define PHY_ANALOG_BB3_EN_TXBBCONSTCUR_MASK                                                          0x80000000
-#define PHY_ANALOG_BB3_EN_TXBBCONSTCUR_GET(x)                                        (((x) & 0x80000000) >> 31)
-#define PHY_ANALOG_BB3_EN_TXBBCONSTCUR_SET(x)                                        (((x) << 31) & 0x80000000)
-
-/* macros for PLLCLKMODA */
-#define PHY_ANALOG_PLLCLKMODA_ADDRESS                                                                0x00000280
-#define PHY_ANALOG_PLLCLKMODA_OFFSET                                                                 0x00000280
-#define PHY_ANALOG_PLLCLKMODA_PWD_PLLSDM_MSB                                                                  0
-#define PHY_ANALOG_PLLCLKMODA_PWD_PLLSDM_LSB                                                                  0
-#define PHY_ANALOG_PLLCLKMODA_PWD_PLLSDM_MASK                                                        0x00000001
-#define PHY_ANALOG_PLLCLKMODA_PWD_PLLSDM_GET(x)                                       (((x) & 0x00000001) >> 0)
-#define PHY_ANALOG_PLLCLKMODA_PWD_PLLSDM_SET(x)                                       (((x) << 0) & 0x00000001)
-#define PHY_ANALOG_PLLCLKMODA_PWDPLL_MSB                                                                      1
-#define PHY_ANALOG_PLLCLKMODA_PWDPLL_LSB                                                                      1
-#define PHY_ANALOG_PLLCLKMODA_PWDPLL_MASK                                                            0x00000002
-#define PHY_ANALOG_PLLCLKMODA_PWDPLL_GET(x)                                           (((x) & 0x00000002) >> 1)
-#define PHY_ANALOG_PLLCLKMODA_PWDPLL_SET(x)                                           (((x) << 1) & 0x00000002)
-#define PHY_ANALOG_PLLCLKMODA_PLLFRAC_MSB                                                                    16
-#define PHY_ANALOG_PLLCLKMODA_PLLFRAC_LSB                                                                     2
-#define PHY_ANALOG_PLLCLKMODA_PLLFRAC_MASK                                                           0x0001fffc
-#define PHY_ANALOG_PLLCLKMODA_PLLFRAC_GET(x)                                          (((x) & 0x0001fffc) >> 2)
-#define PHY_ANALOG_PLLCLKMODA_PLLFRAC_SET(x)                                          (((x) << 2) & 0x0001fffc)
-#define PHY_ANALOG_PLLCLKMODA_REFDIV_MSB                                                                     20
-#define PHY_ANALOG_PLLCLKMODA_REFDIV_LSB                                                                     17
-#define PHY_ANALOG_PLLCLKMODA_REFDIV_MASK                                                            0x001e0000
-#define PHY_ANALOG_PLLCLKMODA_REFDIV_GET(x)                                          (((x) & 0x001e0000) >> 17)
-#define PHY_ANALOG_PLLCLKMODA_REFDIV_SET(x)                                          (((x) << 17) & 0x001e0000)
-#define PHY_ANALOG_PLLCLKMODA_DIV_MSB                                                                        30
-#define PHY_ANALOG_PLLCLKMODA_DIV_LSB                                                                        21
-#define PHY_ANALOG_PLLCLKMODA_DIV_MASK                                                               0x7fe00000
-#define PHY_ANALOG_PLLCLKMODA_DIV_GET(x)                                             (((x) & 0x7fe00000) >> 21)
-#define PHY_ANALOG_PLLCLKMODA_DIV_SET(x)                                             (((x) << 21) & 0x7fe00000)
-#define PHY_ANALOG_PLLCLKMODA_LOCAL_PLL_MSB                                                                  31
-#define PHY_ANALOG_PLLCLKMODA_LOCAL_PLL_LSB                                                                  31
-#define PHY_ANALOG_PLLCLKMODA_LOCAL_PLL_MASK                                                         0x80000000
-#define PHY_ANALOG_PLLCLKMODA_LOCAL_PLL_GET(x)                                       (((x) & 0x80000000) >> 31)
-#define PHY_ANALOG_PLLCLKMODA_LOCAL_PLL_SET(x)                                       (((x) << 31) & 0x80000000)
-
-/* macros for PLLCLKMODA2 */
-#define PHY_ANALOG_PLLCLKMODA2_ADDRESS                                                               0x00000284
-#define PHY_ANALOG_PLLCLKMODA2_OFFSET                                                                0x00000284
-#define PHY_ANALOG_PLLCLKMODA2_SPARE_MSB                                                                      3
-#define PHY_ANALOG_PLLCLKMODA2_SPARE_LSB                                                                      0
-#define PHY_ANALOG_PLLCLKMODA2_SPARE_MASK                                                            0x0000000f
-#define PHY_ANALOG_PLLCLKMODA2_SPARE_GET(x)                                           (((x) & 0x0000000f) >> 0)
-#define PHY_ANALOG_PLLCLKMODA2_SPARE_SET(x)                                           (((x) << 0) & 0x0000000f)
-#define PHY_ANALOG_PLLCLKMODA2_DACPWD_MSB                                                                     4
-#define PHY_ANALOG_PLLCLKMODA2_DACPWD_LSB                                                                     4
-#define PHY_ANALOG_PLLCLKMODA2_DACPWD_MASK                                                           0x00000010
-#define PHY_ANALOG_PLLCLKMODA2_DACPWD_GET(x)                                          (((x) & 0x00000010) >> 4)
-#define PHY_ANALOG_PLLCLKMODA2_DACPWD_SET(x)                                          (((x) << 4) & 0x00000010)
-#define PHY_ANALOG_PLLCLKMODA2_ADCPWD_MSB                                                                     5
-#define PHY_ANALOG_PLLCLKMODA2_ADCPWD_LSB                                                                     5
-#define PHY_ANALOG_PLLCLKMODA2_ADCPWD_MASK                                                           0x00000020
-#define PHY_ANALOG_PLLCLKMODA2_ADCPWD_GET(x)                                          (((x) & 0x00000020) >> 5)
-#define PHY_ANALOG_PLLCLKMODA2_ADCPWD_SET(x)                                          (((x) << 5) & 0x00000020)
-#define PHY_ANALOG_PLLCLKMODA2_LOCAL_ADDAC_MSB                                                                6
-#define PHY_ANALOG_PLLCLKMODA2_LOCAL_ADDAC_LSB                                                                6
-#define PHY_ANALOG_PLLCLKMODA2_LOCAL_ADDAC_MASK                                                      0x00000040
-#define PHY_ANALOG_PLLCLKMODA2_LOCAL_ADDAC_GET(x)                                     (((x) & 0x00000040) >> 6)
-#define PHY_ANALOG_PLLCLKMODA2_LOCAL_ADDAC_SET(x)                                     (((x) << 6) & 0x00000040)
-#define PHY_ANALOG_PLLCLKMODA2_DAC_CLK_SEL_MSB                                                                8
-#define PHY_ANALOG_PLLCLKMODA2_DAC_CLK_SEL_LSB                                                                7
-#define PHY_ANALOG_PLLCLKMODA2_DAC_CLK_SEL_MASK                                                      0x00000180
-#define PHY_ANALOG_PLLCLKMODA2_DAC_CLK_SEL_GET(x)                                     (((x) & 0x00000180) >> 7)
-#define PHY_ANALOG_PLLCLKMODA2_DAC_CLK_SEL_SET(x)                                     (((x) << 7) & 0x00000180)
-#define PHY_ANALOG_PLLCLKMODA2_ADC_CLK_SEL_MSB                                                               12
-#define PHY_ANALOG_PLLCLKMODA2_ADC_CLK_SEL_LSB                                                                9
-#define PHY_ANALOG_PLLCLKMODA2_ADC_CLK_SEL_MASK                                                      0x00001e00
-#define PHY_ANALOG_PLLCLKMODA2_ADC_CLK_SEL_GET(x)                                     (((x) & 0x00001e00) >> 9)
-#define PHY_ANALOG_PLLCLKMODA2_ADC_CLK_SEL_SET(x)                                     (((x) << 9) & 0x00001e00)
-#define PHY_ANALOG_PLLCLKMODA2_LOCAL_CLKMODA_MSB                                                             13
-#define PHY_ANALOG_PLLCLKMODA2_LOCAL_CLKMODA_LSB                                                             13
-#define PHY_ANALOG_PLLCLKMODA2_LOCAL_CLKMODA_MASK                                                    0x00002000
-#define PHY_ANALOG_PLLCLKMODA2_LOCAL_CLKMODA_GET(x)                                  (((x) & 0x00002000) >> 13)
-#define PHY_ANALOG_PLLCLKMODA2_LOCAL_CLKMODA_SET(x)                                  (((x) << 13) & 0x00002000)
-#define PHY_ANALOG_PLLCLKMODA2_PLLBYPASS_MSB                                                                 14
-#define PHY_ANALOG_PLLCLKMODA2_PLLBYPASS_LSB                                                                 14
-#define PHY_ANALOG_PLLCLKMODA2_PLLBYPASS_MASK                                                        0x00004000
-#define PHY_ANALOG_PLLCLKMODA2_PLLBYPASS_GET(x)                                      (((x) & 0x00004000) >> 14)
-#define PHY_ANALOG_PLLCLKMODA2_PLLBYPASS_SET(x)                                      (((x) << 14) & 0x00004000)
-#define PHY_ANALOG_PLLCLKMODA2_LOCAL_PLLBYPASS_MSB                                                           15
-#define PHY_ANALOG_PLLCLKMODA2_LOCAL_PLLBYPASS_LSB                                                           15
-#define PHY_ANALOG_PLLCLKMODA2_LOCAL_PLLBYPASS_MASK                                                  0x00008000
-#define PHY_ANALOG_PLLCLKMODA2_LOCAL_PLLBYPASS_GET(x)                                (((x) & 0x00008000) >> 15)
-#define PHY_ANALOG_PLLCLKMODA2_LOCAL_PLLBYPASS_SET(x)                                (((x) << 15) & 0x00008000)
-#define PHY_ANALOG_PLLCLKMODA2_PLLATB_MSB                                                                    17
-#define PHY_ANALOG_PLLCLKMODA2_PLLATB_LSB                                                                    16
-#define PHY_ANALOG_PLLCLKMODA2_PLLATB_MASK                                                           0x00030000
-#define PHY_ANALOG_PLLCLKMODA2_PLLATB_GET(x)                                         (((x) & 0x00030000) >> 16)
-#define PHY_ANALOG_PLLCLKMODA2_PLLATB_SET(x)                                         (((x) << 16) & 0x00030000)
-#define PHY_ANALOG_PLLCLKMODA2_PLL_SVREG_MSB                                                                 18
-#define PHY_ANALOG_PLLCLKMODA2_PLL_SVREG_LSB                                                                 18
-#define PHY_ANALOG_PLLCLKMODA2_PLL_SVREG_MASK                                                        0x00040000
-#define PHY_ANALOG_PLLCLKMODA2_PLL_SVREG_GET(x)                                      (((x) & 0x00040000) >> 18)
-#define PHY_ANALOG_PLLCLKMODA2_PLL_SVREG_SET(x)                                      (((x) << 18) & 0x00040000)
-#define PHY_ANALOG_PLLCLKMODA2_HI_FREQ_EN_MSB                                                                19
-#define PHY_ANALOG_PLLCLKMODA2_HI_FREQ_EN_LSB                                                                19
-#define PHY_ANALOG_PLLCLKMODA2_HI_FREQ_EN_MASK                                                       0x00080000
-#define PHY_ANALOG_PLLCLKMODA2_HI_FREQ_EN_GET(x)                                     (((x) & 0x00080000) >> 19)
-#define PHY_ANALOG_PLLCLKMODA2_HI_FREQ_EN_SET(x)                                     (((x) << 19) & 0x00080000)
-#define PHY_ANALOG_PLLCLKMODA2_RST_WARM_INT_L_MSB                                                            20
-#define PHY_ANALOG_PLLCLKMODA2_RST_WARM_INT_L_LSB                                                            20
-#define PHY_ANALOG_PLLCLKMODA2_RST_WARM_INT_L_MASK                                                   0x00100000
-#define PHY_ANALOG_PLLCLKMODA2_RST_WARM_INT_L_GET(x)                                 (((x) & 0x00100000) >> 20)
-#define PHY_ANALOG_PLLCLKMODA2_RST_WARM_INT_L_SET(x)                                 (((x) << 20) & 0x00100000)
-#define PHY_ANALOG_PLLCLKMODA2_RST_WARM_OVR_MSB                                                              21
-#define PHY_ANALOG_PLLCLKMODA2_RST_WARM_OVR_LSB                                                              21
-#define PHY_ANALOG_PLLCLKMODA2_RST_WARM_OVR_MASK                                                     0x00200000
-#define PHY_ANALOG_PLLCLKMODA2_RST_WARM_OVR_GET(x)                                   (((x) & 0x00200000) >> 21)
-#define PHY_ANALOG_PLLCLKMODA2_RST_WARM_OVR_SET(x)                                   (((x) << 21) & 0x00200000)
-#define PHY_ANALOG_PLLCLKMODA2_PLL_KVCO_MSB                                                                  23
-#define PHY_ANALOG_PLLCLKMODA2_PLL_KVCO_LSB                                                                  22
-#define PHY_ANALOG_PLLCLKMODA2_PLL_KVCO_MASK                                                         0x00c00000
-#define PHY_ANALOG_PLLCLKMODA2_PLL_KVCO_GET(x)                                       (((x) & 0x00c00000) >> 22)
-#define PHY_ANALOG_PLLCLKMODA2_PLL_KVCO_SET(x)                                       (((x) << 22) & 0x00c00000)
-#define PHY_ANALOG_PLLCLKMODA2_PLLICP_MSB                                                                    26
-#define PHY_ANALOG_PLLCLKMODA2_PLLICP_LSB                                                                    24
-#define PHY_ANALOG_PLLCLKMODA2_PLLICP_MASK                                                           0x07000000
-#define PHY_ANALOG_PLLCLKMODA2_PLLICP_GET(x)                                         (((x) & 0x07000000) >> 24)
-#define PHY_ANALOG_PLLCLKMODA2_PLLICP_SET(x)                                         (((x) << 24) & 0x07000000)
-#define PHY_ANALOG_PLLCLKMODA2_PLLFILTER_MSB                                                                 31
-#define PHY_ANALOG_PLLCLKMODA2_PLLFILTER_LSB                                                                 27
-#define PHY_ANALOG_PLLCLKMODA2_PLLFILTER_MASK                                                        0xf8000000
-#define PHY_ANALOG_PLLCLKMODA2_PLLFILTER_GET(x)                                      (((x) & 0xf8000000) >> 27)
-#define PHY_ANALOG_PLLCLKMODA2_PLLFILTER_SET(x)                                      (((x) << 27) & 0xf8000000)
-
-/* macros for TOP */
-#define PHY_ANALOG_TOP_ADDRESS                                                                       0x00000288
-#define PHY_ANALOG_TOP_OFFSET                                                                        0x00000288
-#define PHY_ANALOG_TOP_SPARE_MSB                                                                              2
-#define PHY_ANALOG_TOP_SPARE_LSB                                                                              0
-#define PHY_ANALOG_TOP_SPARE_MASK                                                                    0x00000007
-#define PHY_ANALOG_TOP_SPARE_GET(x)                                                   (((x) & 0x00000007) >> 0)
-#define PHY_ANALOG_TOP_SPARE_SET(x)                                                   (((x) << 0) & 0x00000007)
-#define PHY_ANALOG_TOP_PWDBIAS_MSB                                                                            3
-#define PHY_ANALOG_TOP_PWDBIAS_LSB                                                                            3
-#define PHY_ANALOG_TOP_PWDBIAS_MASK                                                                  0x00000008
-#define PHY_ANALOG_TOP_PWDBIAS_GET(x)                                                 (((x) & 0x00000008) >> 3)
-#define PHY_ANALOG_TOP_PWDBIAS_SET(x)                                                 (((x) << 3) & 0x00000008)
-#define PHY_ANALOG_TOP_FLIP_XPABIAS_MSB                                                                       4
-#define PHY_ANALOG_TOP_FLIP_XPABIAS_LSB                                                                       4
-#define PHY_ANALOG_TOP_FLIP_XPABIAS_MASK                                                             0x00000010
-#define PHY_ANALOG_TOP_FLIP_XPABIAS_GET(x)                                            (((x) & 0x00000010) >> 4)
-#define PHY_ANALOG_TOP_FLIP_XPABIAS_SET(x)                                            (((x) << 4) & 0x00000010)
-#define PHY_ANALOG_TOP_XPAON2_MSB                                                                             5
-#define PHY_ANALOG_TOP_XPAON2_LSB                                                                             5
-#define PHY_ANALOG_TOP_XPAON2_MASK                                                                   0x00000020
-#define PHY_ANALOG_TOP_XPAON2_GET(x)                                                  (((x) & 0x00000020) >> 5)
-#define PHY_ANALOG_TOP_XPAON2_SET(x)                                                  (((x) << 5) & 0x00000020)
-#define PHY_ANALOG_TOP_XPAON5_MSB                                                                             6
-#define PHY_ANALOG_TOP_XPAON5_LSB                                                                             6
-#define PHY_ANALOG_TOP_XPAON5_MASK                                                                   0x00000040
-#define PHY_ANALOG_TOP_XPAON5_GET(x)                                                  (((x) & 0x00000040) >> 6)
-#define PHY_ANALOG_TOP_XPAON5_SET(x)                                                  (((x) << 6) & 0x00000040)
-#define PHY_ANALOG_TOP_XPASHORT2GND_MSB                                                                       7
-#define PHY_ANALOG_TOP_XPASHORT2GND_LSB                                                                       7
-#define PHY_ANALOG_TOP_XPASHORT2GND_MASK                                                             0x00000080
-#define PHY_ANALOG_TOP_XPASHORT2GND_GET(x)                                            (((x) & 0x00000080) >> 7)
-#define PHY_ANALOG_TOP_XPASHORT2GND_SET(x)                                            (((x) << 7) & 0x00000080)
-#define PHY_ANALOG_TOP_XPABIASLVL_MSB                                                                        11
-#define PHY_ANALOG_TOP_XPABIASLVL_LSB                                                                         8
-#define PHY_ANALOG_TOP_XPABIASLVL_MASK                                                               0x00000f00
-#define PHY_ANALOG_TOP_XPABIASLVL_GET(x)                                              (((x) & 0x00000f00) >> 8)
-#define PHY_ANALOG_TOP_XPABIASLVL_SET(x)                                              (((x) << 8) & 0x00000f00)
-#define PHY_ANALOG_TOP_XPABIAS_EN_MSB                                                                        12
-#define PHY_ANALOG_TOP_XPABIAS_EN_LSB                                                                        12
-#define PHY_ANALOG_TOP_XPABIAS_EN_MASK                                                               0x00001000
-#define PHY_ANALOG_TOP_XPABIAS_EN_GET(x)                                             (((x) & 0x00001000) >> 12)
-#define PHY_ANALOG_TOP_XPABIAS_EN_SET(x)                                             (((x) << 12) & 0x00001000)
-#define PHY_ANALOG_TOP_ATBSELECT_MSB                                                                         13
-#define PHY_ANALOG_TOP_ATBSELECT_LSB                                                                         13
-#define PHY_ANALOG_TOP_ATBSELECT_MASK                                                                0x00002000
-#define PHY_ANALOG_TOP_ATBSELECT_GET(x)                                              (((x) & 0x00002000) >> 13)
-#define PHY_ANALOG_TOP_ATBSELECT_SET(x)                                              (((x) << 13) & 0x00002000)
-#define PHY_ANALOG_TOP_LOCAL_XPA_MSB                                                                         14
-#define PHY_ANALOG_TOP_LOCAL_XPA_LSB                                                                         14
-#define PHY_ANALOG_TOP_LOCAL_XPA_MASK                                                                0x00004000
-#define PHY_ANALOG_TOP_LOCAL_XPA_GET(x)                                              (((x) & 0x00004000) >> 14)
-#define PHY_ANALOG_TOP_LOCAL_XPA_SET(x)                                              (((x) << 14) & 0x00004000)
-#define PHY_ANALOG_TOP_XPABIAS_BYPASS_MSB                                                                    15
-#define PHY_ANALOG_TOP_XPABIAS_BYPASS_LSB                                                                    15
-#define PHY_ANALOG_TOP_XPABIAS_BYPASS_MASK                                                           0x00008000
-#define PHY_ANALOG_TOP_XPABIAS_BYPASS_GET(x)                                         (((x) & 0x00008000) >> 15)
-#define PHY_ANALOG_TOP_XPABIAS_BYPASS_SET(x)                                         (((x) << 15) & 0x00008000)
-#define PHY_ANALOG_TOP_TEST_PADQ_EN_MSB                                                                      16
-#define PHY_ANALOG_TOP_TEST_PADQ_EN_LSB                                                                      16
-#define PHY_ANALOG_TOP_TEST_PADQ_EN_MASK                                                             0x00010000
-#define PHY_ANALOG_TOP_TEST_PADQ_EN_GET(x)                                           (((x) & 0x00010000) >> 16)
-#define PHY_ANALOG_TOP_TEST_PADQ_EN_SET(x)                                           (((x) << 16) & 0x00010000)
-#define PHY_ANALOG_TOP_TEST_PADI_EN_MSB                                                                      17
-#define PHY_ANALOG_TOP_TEST_PADI_EN_LSB                                                                      17
-#define PHY_ANALOG_TOP_TEST_PADI_EN_MASK                                                             0x00020000
-#define PHY_ANALOG_TOP_TEST_PADI_EN_GET(x)                                           (((x) & 0x00020000) >> 17)
-#define PHY_ANALOG_TOP_TEST_PADI_EN_SET(x)                                           (((x) << 17) & 0x00020000)
-#define PHY_ANALOG_TOP_TESTIQ_RSEL_MSB                                                                       18
-#define PHY_ANALOG_TOP_TESTIQ_RSEL_LSB                                                                       18
-#define PHY_ANALOG_TOP_TESTIQ_RSEL_MASK                                                              0x00040000
-#define PHY_ANALOG_TOP_TESTIQ_RSEL_GET(x)                                            (((x) & 0x00040000) >> 18)
-#define PHY_ANALOG_TOP_TESTIQ_RSEL_SET(x)                                            (((x) << 18) & 0x00040000)
-#define PHY_ANALOG_TOP_TESTIQ_BUFEN_MSB                                                                      19
-#define PHY_ANALOG_TOP_TESTIQ_BUFEN_LSB                                                                      19
-#define PHY_ANALOG_TOP_TESTIQ_BUFEN_MASK                                                             0x00080000
-#define PHY_ANALOG_TOP_TESTIQ_BUFEN_GET(x)                                           (((x) & 0x00080000) >> 19)
-#define PHY_ANALOG_TOP_TESTIQ_BUFEN_SET(x)                                           (((x) << 19) & 0x00080000)
-#define PHY_ANALOG_TOP_PAD2GND_MSB                                                                           20
-#define PHY_ANALOG_TOP_PAD2GND_LSB                                                                           20
-#define PHY_ANALOG_TOP_PAD2GND_MASK                                                                  0x00100000
-#define PHY_ANALOG_TOP_PAD2GND_GET(x)                                                (((x) & 0x00100000) >> 20)
-#define PHY_ANALOG_TOP_PAD2GND_SET(x)                                                (((x) << 20) & 0x00100000)
-#define PHY_ANALOG_TOP_INTH2PAD_MSB                                                                          21
-#define PHY_ANALOG_TOP_INTH2PAD_LSB                                                                          21
-#define PHY_ANALOG_TOP_INTH2PAD_MASK                                                                 0x00200000
-#define PHY_ANALOG_TOP_INTH2PAD_GET(x)                                               (((x) & 0x00200000) >> 21)
-#define PHY_ANALOG_TOP_INTH2PAD_SET(x)                                               (((x) << 21) & 0x00200000)
-#define PHY_ANALOG_TOP_INTH2GND_MSB                                                                          22
-#define PHY_ANALOG_TOP_INTH2GND_LSB                                                                          22
-#define PHY_ANALOG_TOP_INTH2GND_MASK                                                                 0x00400000
-#define PHY_ANALOG_TOP_INTH2GND_GET(x)                                               (((x) & 0x00400000) >> 22)
-#define PHY_ANALOG_TOP_INTH2GND_SET(x)                                               (((x) << 22) & 0x00400000)
-#define PHY_ANALOG_TOP_INT2PAD_MSB                                                                           23
-#define PHY_ANALOG_TOP_INT2PAD_LSB                                                                           23
-#define PHY_ANALOG_TOP_INT2PAD_MASK                                                                  0x00800000
-#define PHY_ANALOG_TOP_INT2PAD_GET(x)                                                (((x) & 0x00800000) >> 23)
-#define PHY_ANALOG_TOP_INT2PAD_SET(x)                                                (((x) << 23) & 0x00800000)
-#define PHY_ANALOG_TOP_INT2GND_MSB                                                                           24
-#define PHY_ANALOG_TOP_INT2GND_LSB                                                                           24
-#define PHY_ANALOG_TOP_INT2GND_MASK                                                                  0x01000000
-#define PHY_ANALOG_TOP_INT2GND_GET(x)                                                (((x) & 0x01000000) >> 24)
-#define PHY_ANALOG_TOP_INT2GND_SET(x)                                                (((x) << 24) & 0x01000000)
-#define PHY_ANALOG_TOP_PWDPALCLK_MSB                                                                         25
-#define PHY_ANALOG_TOP_PWDPALCLK_LSB                                                                         25
-#define PHY_ANALOG_TOP_PWDPALCLK_MASK                                                                0x02000000
-#define PHY_ANALOG_TOP_PWDPALCLK_GET(x)                                              (((x) & 0x02000000) >> 25)
-#define PHY_ANALOG_TOP_PWDPALCLK_SET(x)                                              (((x) << 25) & 0x02000000)
-#define PHY_ANALOG_TOP_INV_CLK320_ADC_MSB                                                                    26
-#define PHY_ANALOG_TOP_INV_CLK320_ADC_LSB                                                                    26
-#define PHY_ANALOG_TOP_INV_CLK320_ADC_MASK                                                           0x04000000
-#define PHY_ANALOG_TOP_INV_CLK320_ADC_GET(x)                                         (((x) & 0x04000000) >> 26)
-#define PHY_ANALOG_TOP_INV_CLK320_ADC_SET(x)                                         (((x) << 26) & 0x04000000)
-#define PHY_ANALOG_TOP_FLIP_REFCLK40_MSB                                                                     27
-#define PHY_ANALOG_TOP_FLIP_REFCLK40_LSB                                                                     27
-#define PHY_ANALOG_TOP_FLIP_REFCLK40_MASK                                                            0x08000000
-#define PHY_ANALOG_TOP_FLIP_REFCLK40_GET(x)                                          (((x) & 0x08000000) >> 27)
-#define PHY_ANALOG_TOP_FLIP_REFCLK40_SET(x)                                          (((x) << 27) & 0x08000000)
-#define PHY_ANALOG_TOP_FLIP_PLLCLK320_MSB                                                                    28
-#define PHY_ANALOG_TOP_FLIP_PLLCLK320_LSB                                                                    28
-#define PHY_ANALOG_TOP_FLIP_PLLCLK320_MASK                                                           0x10000000
-#define PHY_ANALOG_TOP_FLIP_PLLCLK320_GET(x)                                         (((x) & 0x10000000) >> 28)
-#define PHY_ANALOG_TOP_FLIP_PLLCLK320_SET(x)                                         (((x) << 28) & 0x10000000)
-#define PHY_ANALOG_TOP_FLIP_PLLCLK160_MSB                                                                    29
-#define PHY_ANALOG_TOP_FLIP_PLLCLK160_LSB                                                                    29
-#define PHY_ANALOG_TOP_FLIP_PLLCLK160_MASK                                                           0x20000000
-#define PHY_ANALOG_TOP_FLIP_PLLCLK160_GET(x)                                         (((x) & 0x20000000) >> 29)
-#define PHY_ANALOG_TOP_FLIP_PLLCLK160_SET(x)                                         (((x) << 29) & 0x20000000)
-#define PHY_ANALOG_TOP_CLK_SEL_MSB                                                                           31
-#define PHY_ANALOG_TOP_CLK_SEL_LSB                                                                           30
-#define PHY_ANALOG_TOP_CLK_SEL_MASK                                                                  0xc0000000
-#define PHY_ANALOG_TOP_CLK_SEL_GET(x)                                                (((x) & 0xc0000000) >> 30)
-#define PHY_ANALOG_TOP_CLK_SEL_SET(x)                                                (((x) << 30) & 0xc0000000)
-
-/* macros for THERM */
-#define PHY_ANALOG_THERM_ADDRESS                                                                     0x0000028c
-#define PHY_ANALOG_THERM_OFFSET                                                                      0x0000028c
-#define PHY_ANALOG_THERM_LOREG_LVL_MSB                                                                        2
-#define PHY_ANALOG_THERM_LOREG_LVL_LSB                                                                        0
-#define PHY_ANALOG_THERM_LOREG_LVL_MASK                                                              0x00000007
-#define PHY_ANALOG_THERM_LOREG_LVL_GET(x)                                             (((x) & 0x00000007) >> 0)
-#define PHY_ANALOG_THERM_LOREG_LVL_SET(x)                                             (((x) << 0) & 0x00000007)
-#define PHY_ANALOG_THERM_RFREG_LVL_MSB                                                                        5
-#define PHY_ANALOG_THERM_RFREG_LVL_LSB                                                                        3
-#define PHY_ANALOG_THERM_RFREG_LVL_MASK                                                              0x00000038
-#define PHY_ANALOG_THERM_RFREG_LVL_GET(x)                                             (((x) & 0x00000038) >> 3)
-#define PHY_ANALOG_THERM_RFREG_LVL_SET(x)                                             (((x) << 3) & 0x00000038)
-#define PHY_ANALOG_THERM_SAR_ADC_DONE_MSB                                                                     6
-#define PHY_ANALOG_THERM_SAR_ADC_DONE_LSB                                                                     6
-#define PHY_ANALOG_THERM_SAR_ADC_DONE_MASK                                                           0x00000040
-#define PHY_ANALOG_THERM_SAR_ADC_DONE_GET(x)                                          (((x) & 0x00000040) >> 6)
-#define PHY_ANALOG_THERM_SAR_ADC_OUT_MSB                                                                     14
-#define PHY_ANALOG_THERM_SAR_ADC_OUT_LSB                                                                      7
-#define PHY_ANALOG_THERM_SAR_ADC_OUT_MASK                                                            0x00007f80
-#define PHY_ANALOG_THERM_SAR_ADC_OUT_GET(x)                                           (((x) & 0x00007f80) >> 7)
-#define PHY_ANALOG_THERM_SAR_DACTEST_CODE_MSB                                                                22
-#define PHY_ANALOG_THERM_SAR_DACTEST_CODE_LSB                                                                15
-#define PHY_ANALOG_THERM_SAR_DACTEST_CODE_MASK                                                       0x007f8000
-#define PHY_ANALOG_THERM_SAR_DACTEST_CODE_GET(x)                                     (((x) & 0x007f8000) >> 15)
-#define PHY_ANALOG_THERM_SAR_DACTEST_CODE_SET(x)                                     (((x) << 15) & 0x007f8000)
-#define PHY_ANALOG_THERM_SAR_DACTEST_EN_MSB                                                                  23
-#define PHY_ANALOG_THERM_SAR_DACTEST_EN_LSB                                                                  23
-#define PHY_ANALOG_THERM_SAR_DACTEST_EN_MASK                                                         0x00800000
-#define PHY_ANALOG_THERM_SAR_DACTEST_EN_GET(x)                                       (((x) & 0x00800000) >> 23)
-#define PHY_ANALOG_THERM_SAR_DACTEST_EN_SET(x)                                       (((x) << 23) & 0x00800000)
-#define PHY_ANALOG_THERM_SAR_ADCCAL_EN_MSB                                                                   24
-#define PHY_ANALOG_THERM_SAR_ADCCAL_EN_LSB                                                                   24
-#define PHY_ANALOG_THERM_SAR_ADCCAL_EN_MASK                                                          0x01000000
-#define PHY_ANALOG_THERM_SAR_ADCCAL_EN_GET(x)                                        (((x) & 0x01000000) >> 24)
-#define PHY_ANALOG_THERM_SAR_ADCCAL_EN_SET(x)                                        (((x) << 24) & 0x01000000)
-#define PHY_ANALOG_THERM_THERMSEL_MSB                                                                        26
-#define PHY_ANALOG_THERM_THERMSEL_LSB                                                                        25
-#define PHY_ANALOG_THERM_THERMSEL_MASK                                                               0x06000000
-#define PHY_ANALOG_THERM_THERMSEL_GET(x)                                             (((x) & 0x06000000) >> 25)
-#define PHY_ANALOG_THERM_THERMSEL_SET(x)                                             (((x) << 25) & 0x06000000)
-#define PHY_ANALOG_THERM_SAR_SLOW_EN_MSB                                                                     27
-#define PHY_ANALOG_THERM_SAR_SLOW_EN_LSB                                                                     27
-#define PHY_ANALOG_THERM_SAR_SLOW_EN_MASK                                                            0x08000000
-#define PHY_ANALOG_THERM_SAR_SLOW_EN_GET(x)                                          (((x) & 0x08000000) >> 27)
-#define PHY_ANALOG_THERM_SAR_SLOW_EN_SET(x)                                          (((x) << 27) & 0x08000000)
-#define PHY_ANALOG_THERM_THERMSTART_MSB                                                                      28
-#define PHY_ANALOG_THERM_THERMSTART_LSB                                                                      28
-#define PHY_ANALOG_THERM_THERMSTART_MASK                                                             0x10000000
-#define PHY_ANALOG_THERM_THERMSTART_GET(x)                                           (((x) & 0x10000000) >> 28)
-#define PHY_ANALOG_THERM_THERMSTART_SET(x)                                           (((x) << 28) & 0x10000000)
-#define PHY_ANALOG_THERM_SAR_AUTOPWD_EN_MSB                                                                  29
-#define PHY_ANALOG_THERM_SAR_AUTOPWD_EN_LSB                                                                  29
-#define PHY_ANALOG_THERM_SAR_AUTOPWD_EN_MASK                                                         0x20000000
-#define PHY_ANALOG_THERM_SAR_AUTOPWD_EN_GET(x)                                       (((x) & 0x20000000) >> 29)
-#define PHY_ANALOG_THERM_SAR_AUTOPWD_EN_SET(x)                                       (((x) << 29) & 0x20000000)
-#define PHY_ANALOG_THERM_THERMON_MSB                                                                         30
-#define PHY_ANALOG_THERM_THERMON_LSB                                                                         30
-#define PHY_ANALOG_THERM_THERMON_MASK                                                                0x40000000
-#define PHY_ANALOG_THERM_THERMON_GET(x)                                              (((x) & 0x40000000) >> 30)
-#define PHY_ANALOG_THERM_THERMON_SET(x)                                              (((x) << 30) & 0x40000000)
-#define PHY_ANALOG_THERM_LOCAL_THERM_MSB                                                                     31
-#define PHY_ANALOG_THERM_LOCAL_THERM_LSB                                                                     31
-#define PHY_ANALOG_THERM_LOCAL_THERM_MASK                                                            0x80000000
-#define PHY_ANALOG_THERM_LOCAL_THERM_GET(x)                                          (((x) & 0x80000000) >> 31)
-#define PHY_ANALOG_THERM_LOCAL_THERM_SET(x)                                          (((x) << 31) & 0x80000000)
-
-/* macros for XTAL */
-#define PHY_ANALOG_XTAL_ADDRESS                                                                      0x00000290
-#define PHY_ANALOG_XTAL_OFFSET                                                                       0x00000290
-#define PHY_ANALOG_XTAL_SPARE_MSB                                                                             5
-#define PHY_ANALOG_XTAL_SPARE_LSB                                                                             0
-#define PHY_ANALOG_XTAL_SPARE_MASK                                                                   0x0000003f
-#define PHY_ANALOG_XTAL_SPARE_GET(x)                                                  (((x) & 0x0000003f) >> 0)
-#define PHY_ANALOG_XTAL_SPARE_SET(x)                                                  (((x) << 0) & 0x0000003f)
-#define PHY_ANALOG_XTAL_XTAL_NOTCXODET_MSB                                                                    6
-#define PHY_ANALOG_XTAL_XTAL_NOTCXODET_LSB                                                                    6
-#define PHY_ANALOG_XTAL_XTAL_NOTCXODET_MASK                                                          0x00000040
-#define PHY_ANALOG_XTAL_XTAL_NOTCXODET_GET(x)                                         (((x) & 0x00000040) >> 6)
-#define PHY_ANALOG_XTAL_XTAL_NOTCXODET_SET(x)                                         (((x) << 6) & 0x00000040)
-#define PHY_ANALOG_XTAL_LOCALBIAS2X_MSB                                                                       7
-#define PHY_ANALOG_XTAL_LOCALBIAS2X_LSB                                                                       7
-#define PHY_ANALOG_XTAL_LOCALBIAS2X_MASK                                                             0x00000080
-#define PHY_ANALOG_XTAL_LOCALBIAS2X_GET(x)                                            (((x) & 0x00000080) >> 7)
-#define PHY_ANALOG_XTAL_LOCALBIAS2X_SET(x)                                            (((x) << 7) & 0x00000080)
-#define PHY_ANALOG_XTAL_LOCAL_XTAL_MSB                                                                        8
-#define PHY_ANALOG_XTAL_LOCAL_XTAL_LSB                                                                        8
-#define PHY_ANALOG_XTAL_LOCAL_XTAL_MASK                                                              0x00000100
-#define PHY_ANALOG_XTAL_LOCAL_XTAL_GET(x)                                             (((x) & 0x00000100) >> 8)
-#define PHY_ANALOG_XTAL_LOCAL_XTAL_SET(x)                                             (((x) << 8) & 0x00000100)
-#define PHY_ANALOG_XTAL_XTAL_PWDCLKIN_MSB                                                                     9
-#define PHY_ANALOG_XTAL_XTAL_PWDCLKIN_LSB                                                                     9
-#define PHY_ANALOG_XTAL_XTAL_PWDCLKIN_MASK                                                           0x00000200
-#define PHY_ANALOG_XTAL_XTAL_PWDCLKIN_GET(x)                                          (((x) & 0x00000200) >> 9)
-#define PHY_ANALOG_XTAL_XTAL_PWDCLKIN_SET(x)                                          (((x) << 9) & 0x00000200)
-#define PHY_ANALOG_XTAL_XTAL_OSCON_MSB                                                                       10
-#define PHY_ANALOG_XTAL_XTAL_OSCON_LSB                                                                       10
-#define PHY_ANALOG_XTAL_XTAL_OSCON_MASK                                                              0x00000400
-#define PHY_ANALOG_XTAL_XTAL_OSCON_GET(x)                                            (((x) & 0x00000400) >> 10)
-#define PHY_ANALOG_XTAL_XTAL_OSCON_SET(x)                                            (((x) << 10) & 0x00000400)
-#define PHY_ANALOG_XTAL_XTAL_PWDCLKD_MSB                                                                     11
-#define PHY_ANALOG_XTAL_XTAL_PWDCLKD_LSB                                                                     11
-#define PHY_ANALOG_XTAL_XTAL_PWDCLKD_MASK                                                            0x00000800
-#define PHY_ANALOG_XTAL_XTAL_PWDCLKD_GET(x)                                          (((x) & 0x00000800) >> 11)
-#define PHY_ANALOG_XTAL_XTAL_PWDCLKD_SET(x)                                          (((x) << 11) & 0x00000800)
-#define PHY_ANALOG_XTAL_XTAL_LOCALBIAS_MSB                                                                   12
-#define PHY_ANALOG_XTAL_XTAL_LOCALBIAS_LSB                                                                   12
-#define PHY_ANALOG_XTAL_XTAL_LOCALBIAS_MASK                                                          0x00001000
-#define PHY_ANALOG_XTAL_XTAL_LOCALBIAS_GET(x)                                        (((x) & 0x00001000) >> 12)
-#define PHY_ANALOG_XTAL_XTAL_LOCALBIAS_SET(x)                                        (((x) << 12) & 0x00001000)
-#define PHY_ANALOG_XTAL_XTAL_SHRTXIN_MSB                                                                     13
-#define PHY_ANALOG_XTAL_XTAL_SHRTXIN_LSB                                                                     13
-#define PHY_ANALOG_XTAL_XTAL_SHRTXIN_MASK                                                            0x00002000
-#define PHY_ANALOG_XTAL_XTAL_SHRTXIN_GET(x)                                          (((x) & 0x00002000) >> 13)
-#define PHY_ANALOG_XTAL_XTAL_SHRTXIN_SET(x)                                          (((x) << 13) & 0x00002000)
-#define PHY_ANALOG_XTAL_XTAL_DRVSTR_MSB                                                                      15
-#define PHY_ANALOG_XTAL_XTAL_DRVSTR_LSB                                                                      14
-#define PHY_ANALOG_XTAL_XTAL_DRVSTR_MASK                                                             0x0000c000
-#define PHY_ANALOG_XTAL_XTAL_DRVSTR_GET(x)                                           (((x) & 0x0000c000) >> 14)
-#define PHY_ANALOG_XTAL_XTAL_DRVSTR_SET(x)                                           (((x) << 14) & 0x0000c000)
-#define PHY_ANALOG_XTAL_XTAL_CAPOUTDAC_MSB                                                                   22
-#define PHY_ANALOG_XTAL_XTAL_CAPOUTDAC_LSB                                                                   16
-#define PHY_ANALOG_XTAL_XTAL_CAPOUTDAC_MASK                                                          0x007f0000
-#define PHY_ANALOG_XTAL_XTAL_CAPOUTDAC_GET(x)                                        (((x) & 0x007f0000) >> 16)
-#define PHY_ANALOG_XTAL_XTAL_CAPOUTDAC_SET(x)                                        (((x) << 16) & 0x007f0000)
-#define PHY_ANALOG_XTAL_XTAL_CAPINDAC_MSB                                                                    29
-#define PHY_ANALOG_XTAL_XTAL_CAPINDAC_LSB                                                                    23
-#define PHY_ANALOG_XTAL_XTAL_CAPINDAC_MASK                                                           0x3f800000
-#define PHY_ANALOG_XTAL_XTAL_CAPINDAC_GET(x)                                         (((x) & 0x3f800000) >> 23)
-#define PHY_ANALOG_XTAL_XTAL_CAPINDAC_SET(x)                                         (((x) << 23) & 0x3f800000)
-#define PHY_ANALOG_XTAL_XTAL_BIAS2X_MSB                                                                      30
-#define PHY_ANALOG_XTAL_XTAL_BIAS2X_LSB                                                                      30
-#define PHY_ANALOG_XTAL_XTAL_BIAS2X_MASK                                                             0x40000000
-#define PHY_ANALOG_XTAL_XTAL_BIAS2X_GET(x)                                           (((x) & 0x40000000) >> 30)
-#define PHY_ANALOG_XTAL_XTAL_BIAS2X_SET(x)                                           (((x) << 30) & 0x40000000)
-#define PHY_ANALOG_XTAL_TCXODET_MSB                                                                          31
-#define PHY_ANALOG_XTAL_TCXODET_LSB                                                                          31
-#define PHY_ANALOG_XTAL_TCXODET_MASK                                                                 0x80000000
-#define PHY_ANALOG_XTAL_TCXODET_GET(x)                                               (((x) & 0x80000000) >> 31)
-
-/* macros for rbist_cntrl */
-#define PHY_ANALOG_RBIST_CNTRL_ADDRESS                                                               0x00000380
-#define PHY_ANALOG_RBIST_CNTRL_OFFSET                                                                0x00000380
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_DC_ENABLE_MSB                                                      0
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_DC_ENABLE_LSB                                                      0
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_DC_ENABLE_MASK                                            0x00000001
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_DC_ENABLE_GET(x)                           (((x) & 0x00000001) >> 0)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_DC_ENABLE_SET(x)                           (((x) << 0) & 0x00000001)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_TONE0_ENABLE_MSB                                                   1
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_TONE0_ENABLE_LSB                                                   1
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_TONE0_ENABLE_MASK                                         0x00000002
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_TONE0_ENABLE_GET(x)                        (((x) & 0x00000002) >> 1)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_TONE0_ENABLE_SET(x)                        (((x) << 1) & 0x00000002)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_TONE1_ENABLE_MSB                                                   2
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_TONE1_ENABLE_LSB                                                   2
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_TONE1_ENABLE_MASK                                         0x00000004
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_TONE1_ENABLE_GET(x)                        (((x) & 0x00000004) >> 2)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_TONE1_ENABLE_SET(x)                        (((x) << 2) & 0x00000004)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_LFTONE0_ENABLE_MSB                                                 3
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_LFTONE0_ENABLE_LSB                                                 3
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_LFTONE0_ENABLE_MASK                                       0x00000008
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_LFTONE0_ENABLE_GET(x)                      (((x) & 0x00000008) >> 3)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_LFTONE0_ENABLE_SET(x)                      (((x) << 3) & 0x00000008)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_LINRAMP_ENABLE_I_MSB                                               4
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_LINRAMP_ENABLE_I_LSB                                               4
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_LINRAMP_ENABLE_I_MASK                                     0x00000010
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_LINRAMP_ENABLE_I_GET(x)                    (((x) & 0x00000010) >> 4)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_LINRAMP_ENABLE_I_SET(x)                    (((x) << 4) & 0x00000010)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_LINRAMP_ENABLE_Q_MSB                                               5
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_LINRAMP_ENABLE_Q_LSB                                               5
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_LINRAMP_ENABLE_Q_MASK                                     0x00000020
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_LINRAMP_ENABLE_Q_GET(x)                    (((x) & 0x00000020) >> 5)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_LINRAMP_ENABLE_Q_SET(x)                    (((x) << 5) & 0x00000020)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_PRBS_ENABLE_I_MSB                                                  6
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_PRBS_ENABLE_I_LSB                                                  6
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_PRBS_ENABLE_I_MASK                                        0x00000040
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_PRBS_ENABLE_I_GET(x)                       (((x) & 0x00000040) >> 6)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_PRBS_ENABLE_I_SET(x)                       (((x) << 6) & 0x00000040)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_PRBS_ENABLE_Q_MSB                                                  7
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_PRBS_ENABLE_Q_LSB                                                  7
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_PRBS_ENABLE_Q_MASK                                        0x00000080
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_PRBS_ENABLE_Q_GET(x)                       (((x) & 0x00000080) >> 7)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_TONEGEN_PRBS_ENABLE_Q_SET(x)                       (((x) << 7) & 0x00000080)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_DC_WRITE_TO_CANCEL_MSB                                                8
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_DC_WRITE_TO_CANCEL_LSB                                                8
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_DC_WRITE_TO_CANCEL_MASK                                      0x00000100
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_DC_WRITE_TO_CANCEL_GET(x)                     (((x) & 0x00000100) >> 8)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_DC_WRITE_TO_CANCEL_SET(x)                     (((x) << 8) & 0x00000100)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_DC_ENABLE_MSB                                                         9
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_DC_ENABLE_LSB                                                         9
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_DC_ENABLE_MASK                                               0x00000200
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_DC_ENABLE_GET(x)                              (((x) & 0x00000200) >> 9)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_DC_ENABLE_SET(x)                              (((x) << 9) & 0x00000200)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_CORR_ENABLE_MSB                                                      10
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_CORR_ENABLE_LSB                                                      10
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_CORR_ENABLE_MASK                                             0x00000400
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_CORR_ENABLE_GET(x)                           (((x) & 0x00000400) >> 10)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_CORR_ENABLE_SET(x)                           (((x) << 10) & 0x00000400)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_POWER_ENABLE_MSB                                                     11
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_POWER_ENABLE_LSB                                                     11
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_POWER_ENABLE_MASK                                            0x00000800
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_POWER_ENABLE_GET(x)                          (((x) & 0x00000800) >> 11)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_POWER_ENABLE_SET(x)                          (((x) << 11) & 0x00000800)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_IQ_ENABLE_MSB                                                        12
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_IQ_ENABLE_LSB                                                        12
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_IQ_ENABLE_MASK                                               0x00001000
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_IQ_ENABLE_GET(x)                             (((x) & 0x00001000) >> 12)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_IQ_ENABLE_SET(x)                             (((x) << 12) & 0x00001000)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_I2Q2_ENABLE_MSB                                                      13
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_I2Q2_ENABLE_LSB                                                      13
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_I2Q2_ENABLE_MASK                                             0x00002000
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_I2Q2_ENABLE_GET(x)                           (((x) & 0x00002000) >> 13)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_I2Q2_ENABLE_SET(x)                           (((x) << 13) & 0x00002000)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_POWER_HPF_ENABLE_MSB                                                 14
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_POWER_HPF_ENABLE_LSB                                                 14
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_POWER_HPF_ENABLE_MASK                                        0x00004000
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_POWER_HPF_ENABLE_GET(x)                      (((x) & 0x00004000) >> 14)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_CMAC_POWER_HPF_ENABLE_SET(x)                      (((x) << 14) & 0x00004000)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_RXDAC_CALIBRATE_MSB                                                       15
-#define PHY_ANALOG_RBIST_CNTRL_ATE_RXDAC_CALIBRATE_LSB                                                       15
-#define PHY_ANALOG_RBIST_CNTRL_ATE_RXDAC_CALIBRATE_MASK                                              0x00008000
-#define PHY_ANALOG_RBIST_CNTRL_ATE_RXDAC_CALIBRATE_GET(x)                            (((x) & 0x00008000) >> 15)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_RXDAC_CALIBRATE_SET(x)                            (((x) << 15) & 0x00008000)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_RBIST_ENABLE_MSB                                                          16
-#define PHY_ANALOG_RBIST_CNTRL_ATE_RBIST_ENABLE_LSB                                                          16
-#define PHY_ANALOG_RBIST_CNTRL_ATE_RBIST_ENABLE_MASK                                                 0x00010000
-#define PHY_ANALOG_RBIST_CNTRL_ATE_RBIST_ENABLE_GET(x)                               (((x) & 0x00010000) >> 16)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_RBIST_ENABLE_SET(x)                               (((x) << 16) & 0x00010000)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_ADC_CLK_INVERT_MSB                                                        17
-#define PHY_ANALOG_RBIST_CNTRL_ATE_ADC_CLK_INVERT_LSB                                                        17
-#define PHY_ANALOG_RBIST_CNTRL_ATE_ADC_CLK_INVERT_MASK                                               0x00020000
-#define PHY_ANALOG_RBIST_CNTRL_ATE_ADC_CLK_INVERT_GET(x)                             (((x) & 0x00020000) >> 17)
-#define PHY_ANALOG_RBIST_CNTRL_ATE_ADC_CLK_INVERT_SET(x)                             (((x) << 17) & 0x00020000)
-
-/* macros for tx_dc_offset */
-#define PHY_ANALOG_TX_DC_OFFSET_ADDRESS                                                              0x00000384
-#define PHY_ANALOG_TX_DC_OFFSET_OFFSET                                                               0x00000384
-#define PHY_ANALOG_TX_DC_OFFSET_ATE_TONEGEN_DC_I_MSB                                                         10
-#define PHY_ANALOG_TX_DC_OFFSET_ATE_TONEGEN_DC_I_LSB                                                          0
-#define PHY_ANALOG_TX_DC_OFFSET_ATE_TONEGEN_DC_I_MASK                                                0x000007ff
-#define PHY_ANALOG_TX_DC_OFFSET_ATE_TONEGEN_DC_I_GET(x)                               (((x) & 0x000007ff) >> 0)
-#define PHY_ANALOG_TX_DC_OFFSET_ATE_TONEGEN_DC_I_SET(x)                               (((x) << 0) & 0x000007ff)
-#define PHY_ANALOG_TX_DC_OFFSET_ATE_TONEGEN_DC_Q_MSB                                                         26
-#define PHY_ANALOG_TX_DC_OFFSET_ATE_TONEGEN_DC_Q_LSB                                                         16
-#define PHY_ANALOG_TX_DC_OFFSET_ATE_TONEGEN_DC_Q_MASK                                                0x07ff0000
-#define PHY_ANALOG_TX_DC_OFFSET_ATE_TONEGEN_DC_Q_GET(x)                              (((x) & 0x07ff0000) >> 16)
-#define PHY_ANALOG_TX_DC_OFFSET_ATE_TONEGEN_DC_Q_SET(x)                              (((x) << 16) & 0x07ff0000)
-
-/* macros for tx_tonegen0 */
-#define PHY_ANALOG_TX_TONEGEN0_ADDRESS                                                               0x00000388
-#define PHY_ANALOG_TX_TONEGEN0_OFFSET                                                                0x00000388
-#define PHY_ANALOG_TX_TONEGEN0_ATE_TONEGEN_TONE_FREQ_MSB                                                      6
-#define PHY_ANALOG_TX_TONEGEN0_ATE_TONEGEN_TONE_FREQ_LSB                                                      0
-#define PHY_ANALOG_TX_TONEGEN0_ATE_TONEGEN_TONE_FREQ_MASK                                            0x0000007f
-#define PHY_ANALOG_TX_TONEGEN0_ATE_TONEGEN_TONE_FREQ_GET(x)                           (((x) & 0x0000007f) >> 0)
-#define PHY_ANALOG_TX_TONEGEN0_ATE_TONEGEN_TONE_FREQ_SET(x)                           (((x) << 0) & 0x0000007f)
-#define PHY_ANALOG_TX_TONEGEN0_ATE_TONEGEN_TONE_A_EXP_MSB                                                    11
-#define PHY_ANALOG_TX_TONEGEN0_ATE_TONEGEN_TONE_A_EXP_LSB                                                     8
-#define PHY_ANALOG_TX_TONEGEN0_ATE_TONEGEN_TONE_A_EXP_MASK                                           0x00000f00
-#define PHY_ANALOG_TX_TONEGEN0_ATE_TONEGEN_TONE_A_EXP_GET(x)                          (((x) & 0x00000f00) >> 8)
-#define PHY_ANALOG_TX_TONEGEN0_ATE_TONEGEN_TONE_A_EXP_SET(x)                          (((x) << 8) & 0x00000f00)
-#define PHY_ANALOG_TX_TONEGEN0_ATE_TONEGEN_TONE_A_MAN_MSB                                                    23
-#define PHY_ANALOG_TX_TONEGEN0_ATE_TONEGEN_TONE_A_MAN_LSB                                                    16
-#define PHY_ANALOG_TX_TONEGEN0_ATE_TONEGEN_TONE_A_MAN_MASK                                           0x00ff0000
-#define PHY_ANALOG_TX_TONEGEN0_ATE_TONEGEN_TONE_A_MAN_GET(x)                         (((x) & 0x00ff0000) >> 16)
-#define PHY_ANALOG_TX_TONEGEN0_ATE_TONEGEN_TONE_A_MAN_SET(x)                         (((x) << 16) & 0x00ff0000)
-#define PHY_ANALOG_TX_TONEGEN0_ATE_TONEGEN_TONE_TAU_K_MSB                                                    30
-#define PHY_ANALOG_TX_TONEGEN0_ATE_TONEGEN_TONE_TAU_K_LSB                                                    24
-#define PHY_ANALOG_TX_TONEGEN0_ATE_TONEGEN_TONE_TAU_K_MASK                                           0x7f000000
-#define PHY_ANALOG_TX_TONEGEN0_ATE_TONEGEN_TONE_TAU_K_GET(x)                         (((x) & 0x7f000000) >> 24)
-#define PHY_ANALOG_TX_TONEGEN0_ATE_TONEGEN_TONE_TAU_K_SET(x)                         (((x) << 24) & 0x7f000000)
-
-/* macros for tx_tonegen1 */
-#define PHY_ANALOG_TX_TONEGEN1_ADDRESS                                                               0x0000038c
-#define PHY_ANALOG_TX_TONEGEN1_OFFSET                                                                0x0000038c
-#define PHY_ANALOG_TX_TONEGEN1_ATE_TONEGEN_TONE_FREQ_MSB                                                      6
-#define PHY_ANALOG_TX_TONEGEN1_ATE_TONEGEN_TONE_FREQ_LSB                                                      0
-#define PHY_ANALOG_TX_TONEGEN1_ATE_TONEGEN_TONE_FREQ_MASK                                            0x0000007f
-#define PHY_ANALOG_TX_TONEGEN1_ATE_TONEGEN_TONE_FREQ_GET(x)                           (((x) & 0x0000007f) >> 0)
-#define PHY_ANALOG_TX_TONEGEN1_ATE_TONEGEN_TONE_FREQ_SET(x)                           (((x) << 0) & 0x0000007f)
-#define PHY_ANALOG_TX_TONEGEN1_ATE_TONEGEN_TONE_A_EXP_MSB                                                    11
-#define PHY_ANALOG_TX_TONEGEN1_ATE_TONEGEN_TONE_A_EXP_LSB                                                     8
-#define PHY_ANALOG_TX_TONEGEN1_ATE_TONEGEN_TONE_A_EXP_MASK                                           0x00000f00
-#define PHY_ANALOG_TX_TONEGEN1_ATE_TONEGEN_TONE_A_EXP_GET(x)                          (((x) & 0x00000f00) >> 8)
-#define PHY_ANALOG_TX_TONEGEN1_ATE_TONEGEN_TONE_A_EXP_SET(x)                          (((x) << 8) & 0x00000f00)
-#define PHY_ANALOG_TX_TONEGEN1_ATE_TONEGEN_TONE_A_MAN_MSB                                                    23
-#define PHY_ANALOG_TX_TONEGEN1_ATE_TONEGEN_TONE_A_MAN_LSB                                                    16
-#define PHY_ANALOG_TX_TONEGEN1_ATE_TONEGEN_TONE_A_MAN_MASK                                           0x00ff0000
-#define PHY_ANALOG_TX_TONEGEN1_ATE_TONEGEN_TONE_A_MAN_GET(x)                         (((x) & 0x00ff0000) >> 16)
-#define PHY_ANALOG_TX_TONEGEN1_ATE_TONEGEN_TONE_A_MAN_SET(x)                         (((x) << 16) & 0x00ff0000)
-#define PHY_ANALOG_TX_TONEGEN1_ATE_TONEGEN_TONE_TAU_K_MSB                                                    30
-#define PHY_ANALOG_TX_TONEGEN1_ATE_TONEGEN_TONE_TAU_K_LSB                                                    24
-#define PHY_ANALOG_TX_TONEGEN1_ATE_TONEGEN_TONE_TAU_K_MASK                                           0x7f000000
-#define PHY_ANALOG_TX_TONEGEN1_ATE_TONEGEN_TONE_TAU_K_GET(x)                         (((x) & 0x7f000000) >> 24)
-#define PHY_ANALOG_TX_TONEGEN1_ATE_TONEGEN_TONE_TAU_K_SET(x)                         (((x) << 24) & 0x7f000000)
-
-/* macros for tx_lftonegen0 */
-#define PHY_ANALOG_TX_LFTONEGEN0_ADDRESS                                                             0x00000390
-#define PHY_ANALOG_TX_LFTONEGEN0_OFFSET                                                              0x00000390
-#define PHY_ANALOG_TX_LFTONEGEN0_ATE_TONEGEN_TONE_FREQ_MSB                                                    6
-#define PHY_ANALOG_TX_LFTONEGEN0_ATE_TONEGEN_TONE_FREQ_LSB                                                    0
-#define PHY_ANALOG_TX_LFTONEGEN0_ATE_TONEGEN_TONE_FREQ_MASK                                          0x0000007f
-#define PHY_ANALOG_TX_LFTONEGEN0_ATE_TONEGEN_TONE_FREQ_GET(x)                         (((x) & 0x0000007f) >> 0)
-#define PHY_ANALOG_TX_LFTONEGEN0_ATE_TONEGEN_TONE_FREQ_SET(x)                         (((x) << 0) & 0x0000007f)
-#define PHY_ANALOG_TX_LFTONEGEN0_ATE_TONEGEN_TONE_A_EXP_MSB                                                  11
-#define PHY_ANALOG_TX_LFTONEGEN0_ATE_TONEGEN_TONE_A_EXP_LSB                                                   8
-#define PHY_ANALOG_TX_LFTONEGEN0_ATE_TONEGEN_TONE_A_EXP_MASK                                         0x00000f00
-#define PHY_ANALOG_TX_LFTONEGEN0_ATE_TONEGEN_TONE_A_EXP_GET(x)                        (((x) & 0x00000f00) >> 8)
-#define PHY_ANALOG_TX_LFTONEGEN0_ATE_TONEGEN_TONE_A_EXP_SET(x)                        (((x) << 8) & 0x00000f00)
-#define PHY_ANALOG_TX_LFTONEGEN0_ATE_TONEGEN_TONE_A_MAN_MSB                                                  23
-#define PHY_ANALOG_TX_LFTONEGEN0_ATE_TONEGEN_TONE_A_MAN_LSB                                                  16
-#define PHY_ANALOG_TX_LFTONEGEN0_ATE_TONEGEN_TONE_A_MAN_MASK                                         0x00ff0000
-#define PHY_ANALOG_TX_LFTONEGEN0_ATE_TONEGEN_TONE_A_MAN_GET(x)                       (((x) & 0x00ff0000) >> 16)
-#define PHY_ANALOG_TX_LFTONEGEN0_ATE_TONEGEN_TONE_A_MAN_SET(x)                       (((x) << 16) & 0x00ff0000)
-#define PHY_ANALOG_TX_LFTONEGEN0_ATE_TONEGEN_TONE_TAU_K_MSB                                                  30
-#define PHY_ANALOG_TX_LFTONEGEN0_ATE_TONEGEN_TONE_TAU_K_LSB                                                  24
-#define PHY_ANALOG_TX_LFTONEGEN0_ATE_TONEGEN_TONE_TAU_K_MASK                                         0x7f000000
-#define PHY_ANALOG_TX_LFTONEGEN0_ATE_TONEGEN_TONE_TAU_K_GET(x)                       (((x) & 0x7f000000) >> 24)
-#define PHY_ANALOG_TX_LFTONEGEN0_ATE_TONEGEN_TONE_TAU_K_SET(x)                       (((x) << 24) & 0x7f000000)
-
-/* macros for tx_linear_ramp_i */
-#define PHY_ANALOG_TX_LINEAR_RAMP_I_ADDRESS                                                          0x00000394
-#define PHY_ANALOG_TX_LINEAR_RAMP_I_OFFSET                                                           0x00000394
-#define PHY_ANALOG_TX_LINEAR_RAMP_I_ATE_TONEGEN_LINRAMP_INIT_MSB                                             10
-#define PHY_ANALOG_TX_LINEAR_RAMP_I_ATE_TONEGEN_LINRAMP_INIT_LSB                                              0
-#define PHY_ANALOG_TX_LINEAR_RAMP_I_ATE_TONEGEN_LINRAMP_INIT_MASK                                    0x000007ff
-#define PHY_ANALOG_TX_LINEAR_RAMP_I_ATE_TONEGEN_LINRAMP_INIT_GET(x)                   (((x) & 0x000007ff) >> 0)
-#define PHY_ANALOG_TX_LINEAR_RAMP_I_ATE_TONEGEN_LINRAMP_INIT_SET(x)                   (((x) << 0) & 0x000007ff)
-#define PHY_ANALOG_TX_LINEAR_RAMP_I_ATE_TONEGEN_LINRAMP_DWELL_MSB                                            21
-#define PHY_ANALOG_TX_LINEAR_RAMP_I_ATE_TONEGEN_LINRAMP_DWELL_LSB                                            12
-#define PHY_ANALOG_TX_LINEAR_RAMP_I_ATE_TONEGEN_LINRAMP_DWELL_MASK                                   0x003ff000
-#define PHY_ANALOG_TX_LINEAR_RAMP_I_ATE_TONEGEN_LINRAMP_DWELL_GET(x)                 (((x) & 0x003ff000) >> 12)
-#define PHY_ANALOG_TX_LINEAR_RAMP_I_ATE_TONEGEN_LINRAMP_DWELL_SET(x)                 (((x) << 12) & 0x003ff000)
-#define PHY_ANALOG_TX_LINEAR_RAMP_I_ATE_TONEGEN_LINRAMP_STEP_MSB                                             29
-#define PHY_ANALOG_TX_LINEAR_RAMP_I_ATE_TONEGEN_LINRAMP_STEP_LSB                                             24
-#define PHY_ANALOG_TX_LINEAR_RAMP_I_ATE_TONEGEN_LINRAMP_STEP_MASK                                    0x3f000000
-#define PHY_ANALOG_TX_LINEAR_RAMP_I_ATE_TONEGEN_LINRAMP_STEP_GET(x)                  (((x) & 0x3f000000) >> 24)
-#define PHY_ANALOG_TX_LINEAR_RAMP_I_ATE_TONEGEN_LINRAMP_STEP_SET(x)                  (((x) << 24) & 0x3f000000)
-
-/* macros for tx_linear_ramp_q */
-#define PHY_ANALOG_TX_LINEAR_RAMP_Q_ADDRESS                                                          0x00000398
-#define PHY_ANALOG_TX_LINEAR_RAMP_Q_OFFSET                                                           0x00000398
-#define PHY_ANALOG_TX_LINEAR_RAMP_Q_ATE_TONEGEN_LINRAMP_INIT_MSB                                             10
-#define PHY_ANALOG_TX_LINEAR_RAMP_Q_ATE_TONEGEN_LINRAMP_INIT_LSB                                              0
-#define PHY_ANALOG_TX_LINEAR_RAMP_Q_ATE_TONEGEN_LINRAMP_INIT_MASK                                    0x000007ff
-#define PHY_ANALOG_TX_LINEAR_RAMP_Q_ATE_TONEGEN_LINRAMP_INIT_GET(x)                   (((x) & 0x000007ff) >> 0)
-#define PHY_ANALOG_TX_LINEAR_RAMP_Q_ATE_TONEGEN_LINRAMP_INIT_SET(x)                   (((x) << 0) & 0x000007ff)
-#define PHY_ANALOG_TX_LINEAR_RAMP_Q_ATE_TONEGEN_LINRAMP_DWELL_MSB                                            21
-#define PHY_ANALOG_TX_LINEAR_RAMP_Q_ATE_TONEGEN_LINRAMP_DWELL_LSB                                            12
-#define PHY_ANALOG_TX_LINEAR_RAMP_Q_ATE_TONEGEN_LINRAMP_DWELL_MASK                                   0x003ff000
-#define PHY_ANALOG_TX_LINEAR_RAMP_Q_ATE_TONEGEN_LINRAMP_DWELL_GET(x)                 (((x) & 0x003ff000) >> 12)
-#define PHY_ANALOG_TX_LINEAR_RAMP_Q_ATE_TONEGEN_LINRAMP_DWELL_SET(x)                 (((x) << 12) & 0x003ff000)
-#define PHY_ANALOG_TX_LINEAR_RAMP_Q_ATE_TONEGEN_LINRAMP_STEP_MSB                                             29
-#define PHY_ANALOG_TX_LINEAR_RAMP_Q_ATE_TONEGEN_LINRAMP_STEP_LSB                                             24
-#define PHY_ANALOG_TX_LINEAR_RAMP_Q_ATE_TONEGEN_LINRAMP_STEP_MASK                                    0x3f000000
-#define PHY_ANALOG_TX_LINEAR_RAMP_Q_ATE_TONEGEN_LINRAMP_STEP_GET(x)                  (((x) & 0x3f000000) >> 24)
-#define PHY_ANALOG_TX_LINEAR_RAMP_Q_ATE_TONEGEN_LINRAMP_STEP_SET(x)                  (((x) << 24) & 0x3f000000)
-
-/* macros for tx_prbs_mag */
-#define PHY_ANALOG_TX_PRBS_MAG_ADDRESS                                                               0x0000039c
-#define PHY_ANALOG_TX_PRBS_MAG_OFFSET                                                                0x0000039c
-#define PHY_ANALOG_TX_PRBS_MAG_ATE_TONEGEN_PRBS_MAGNITUDE_I_MSB                                               9
-#define PHY_ANALOG_TX_PRBS_MAG_ATE_TONEGEN_PRBS_MAGNITUDE_I_LSB                                               0
-#define PHY_ANALOG_TX_PRBS_MAG_ATE_TONEGEN_PRBS_MAGNITUDE_I_MASK                                     0x000003ff
-#define PHY_ANALOG_TX_PRBS_MAG_ATE_TONEGEN_PRBS_MAGNITUDE_I_GET(x)                    (((x) & 0x000003ff) >> 0)
-#define PHY_ANALOG_TX_PRBS_MAG_ATE_TONEGEN_PRBS_MAGNITUDE_I_SET(x)                    (((x) << 0) & 0x000003ff)
-#define PHY_ANALOG_TX_PRBS_MAG_ATE_TONEGEN_PRBS_MAGNITUDE_Q_MSB                                              25
-#define PHY_ANALOG_TX_PRBS_MAG_ATE_TONEGEN_PRBS_MAGNITUDE_Q_LSB                                              16
-#define PHY_ANALOG_TX_PRBS_MAG_ATE_TONEGEN_PRBS_MAGNITUDE_Q_MASK                                     0x03ff0000
-#define PHY_ANALOG_TX_PRBS_MAG_ATE_TONEGEN_PRBS_MAGNITUDE_Q_GET(x)                   (((x) & 0x03ff0000) >> 16)
-#define PHY_ANALOG_TX_PRBS_MAG_ATE_TONEGEN_PRBS_MAGNITUDE_Q_SET(x)                   (((x) << 16) & 0x03ff0000)
-
-/* macros for tx_prbs_seed_i */
-#define PHY_ANALOG_TX_PRBS_SEED_I_ADDRESS                                                            0x000003a0
-#define PHY_ANALOG_TX_PRBS_SEED_I_OFFSET                                                             0x000003a0
-#define PHY_ANALOG_TX_PRBS_SEED_I_ATE_TONEGEN_PRBS_SEED_MSB                                                  30
-#define PHY_ANALOG_TX_PRBS_SEED_I_ATE_TONEGEN_PRBS_SEED_LSB                                                   0
-#define PHY_ANALOG_TX_PRBS_SEED_I_ATE_TONEGEN_PRBS_SEED_MASK                                         0x7fffffff
-#define PHY_ANALOG_TX_PRBS_SEED_I_ATE_TONEGEN_PRBS_SEED_GET(x)                        (((x) & 0x7fffffff) >> 0)
-#define PHY_ANALOG_TX_PRBS_SEED_I_ATE_TONEGEN_PRBS_SEED_SET(x)                        (((x) << 0) & 0x7fffffff)
-
-/* macros for tx_prbs_seed_q */
-#define PHY_ANALOG_TX_PRBS_SEED_Q_ADDRESS                                                            0x000003a4
-#define PHY_ANALOG_TX_PRBS_SEED_Q_OFFSET                                                             0x000003a4
-#define PHY_ANALOG_TX_PRBS_SEED_Q_ATE_TONEGEN_PRBS_SEED_MSB                                                  30
-#define PHY_ANALOG_TX_PRBS_SEED_Q_ATE_TONEGEN_PRBS_SEED_LSB                                                   0
-#define PHY_ANALOG_TX_PRBS_SEED_Q_ATE_TONEGEN_PRBS_SEED_MASK                                         0x7fffffff
-#define PHY_ANALOG_TX_PRBS_SEED_Q_ATE_TONEGEN_PRBS_SEED_GET(x)                        (((x) & 0x7fffffff) >> 0)
-#define PHY_ANALOG_TX_PRBS_SEED_Q_ATE_TONEGEN_PRBS_SEED_SET(x)                        (((x) << 0) & 0x7fffffff)
-
-/* macros for cmac_dc_cancel */
-#define PHY_ANALOG_CMAC_DC_CANCEL_ADDRESS                                                            0x000003a8
-#define PHY_ANALOG_CMAC_DC_CANCEL_OFFSET                                                             0x000003a8
-#define PHY_ANALOG_CMAC_DC_CANCEL_ATE_CMAC_DC_CANCEL_I_MSB                                                    9
-#define PHY_ANALOG_CMAC_DC_CANCEL_ATE_CMAC_DC_CANCEL_I_LSB                                                    0
-#define PHY_ANALOG_CMAC_DC_CANCEL_ATE_CMAC_DC_CANCEL_I_MASK                                          0x000003ff
-#define PHY_ANALOG_CMAC_DC_CANCEL_ATE_CMAC_DC_CANCEL_I_GET(x)                         (((x) & 0x000003ff) >> 0)
-#define PHY_ANALOG_CMAC_DC_CANCEL_ATE_CMAC_DC_CANCEL_I_SET(x)                         (((x) << 0) & 0x000003ff)
-#define PHY_ANALOG_CMAC_DC_CANCEL_ATE_CMAC_DC_CANCEL_Q_MSB                                                   25
-#define PHY_ANALOG_CMAC_DC_CANCEL_ATE_CMAC_DC_CANCEL_Q_LSB                                                   16
-#define PHY_ANALOG_CMAC_DC_CANCEL_ATE_CMAC_DC_CANCEL_Q_MASK                                          0x03ff0000
-#define PHY_ANALOG_CMAC_DC_CANCEL_ATE_CMAC_DC_CANCEL_Q_GET(x)                        (((x) & 0x03ff0000) >> 16)
-#define PHY_ANALOG_CMAC_DC_CANCEL_ATE_CMAC_DC_CANCEL_Q_SET(x)                        (((x) << 16) & 0x03ff0000)
-
-/* macros for cmac_dc_offset */
-#define PHY_ANALOG_CMAC_DC_OFFSET_ADDRESS                                                            0x000003ac
-#define PHY_ANALOG_CMAC_DC_OFFSET_OFFSET                                                             0x000003ac
-#define PHY_ANALOG_CMAC_DC_OFFSET_ATE_CMAC_DC_CYCLES_MSB                                                      3
-#define PHY_ANALOG_CMAC_DC_OFFSET_ATE_CMAC_DC_CYCLES_LSB                                                      0
-#define PHY_ANALOG_CMAC_DC_OFFSET_ATE_CMAC_DC_CYCLES_MASK                                            0x0000000f
-#define PHY_ANALOG_CMAC_DC_OFFSET_ATE_CMAC_DC_CYCLES_GET(x)                           (((x) & 0x0000000f) >> 0)
-#define PHY_ANALOG_CMAC_DC_OFFSET_ATE_CMAC_DC_CYCLES_SET(x)                           (((x) << 0) & 0x0000000f)
-
-/* macros for cmac_corr */
-#define PHY_ANALOG_CMAC_CORR_ADDRESS                                                                 0x000003b0
-#define PHY_ANALOG_CMAC_CORR_OFFSET                                                                  0x000003b0
-#define PHY_ANALOG_CMAC_CORR_ATE_CMAC_CORR_CYCLES_MSB                                                         4
-#define PHY_ANALOG_CMAC_CORR_ATE_CMAC_CORR_CYCLES_LSB                                                         0
-#define PHY_ANALOG_CMAC_CORR_ATE_CMAC_CORR_CYCLES_MASK                                               0x0000001f
-#define PHY_ANALOG_CMAC_CORR_ATE_CMAC_CORR_CYCLES_GET(x)                              (((x) & 0x0000001f) >> 0)
-#define PHY_ANALOG_CMAC_CORR_ATE_CMAC_CORR_CYCLES_SET(x)                              (((x) << 0) & 0x0000001f)
-#define PHY_ANALOG_CMAC_CORR_ATE_CMAC_CORR_FREQ_MSB                                                          13
-#define PHY_ANALOG_CMAC_CORR_ATE_CMAC_CORR_FREQ_LSB                                                           8
-#define PHY_ANALOG_CMAC_CORR_ATE_CMAC_CORR_FREQ_MASK                                                 0x00003f00
-#define PHY_ANALOG_CMAC_CORR_ATE_CMAC_CORR_FREQ_GET(x)                                (((x) & 0x00003f00) >> 8)
-#define PHY_ANALOG_CMAC_CORR_ATE_CMAC_CORR_FREQ_SET(x)                                (((x) << 8) & 0x00003f00)
-
-/* macros for cmac_power */
-#define PHY_ANALOG_CMAC_POWER_ADDRESS                                                                0x000003b4
-#define PHY_ANALOG_CMAC_POWER_OFFSET                                                                 0x000003b4
-#define PHY_ANALOG_CMAC_POWER_ATE_CMAC_POWER_CYCLES_MSB                                                       3
-#define PHY_ANALOG_CMAC_POWER_ATE_CMAC_POWER_CYCLES_LSB                                                       0
-#define PHY_ANALOG_CMAC_POWER_ATE_CMAC_POWER_CYCLES_MASK                                             0x0000000f
-#define PHY_ANALOG_CMAC_POWER_ATE_CMAC_POWER_CYCLES_GET(x)                            (((x) & 0x0000000f) >> 0)
-#define PHY_ANALOG_CMAC_POWER_ATE_CMAC_POWER_CYCLES_SET(x)                            (((x) << 0) & 0x0000000f)
-
-/* macros for cmac_cross_corr */
-#define PHY_ANALOG_CMAC_CROSS_CORR_ADDRESS                                                           0x000003b8
-#define PHY_ANALOG_CMAC_CROSS_CORR_OFFSET                                                            0x000003b8
-#define PHY_ANALOG_CMAC_CROSS_CORR_ATE_CMAC_IQ_CYCLES_MSB                                                     3
-#define PHY_ANALOG_CMAC_CROSS_CORR_ATE_CMAC_IQ_CYCLES_LSB                                                     0
-#define PHY_ANALOG_CMAC_CROSS_CORR_ATE_CMAC_IQ_CYCLES_MASK                                           0x0000000f
-#define PHY_ANALOG_CMAC_CROSS_CORR_ATE_CMAC_IQ_CYCLES_GET(x)                          (((x) & 0x0000000f) >> 0)
-#define PHY_ANALOG_CMAC_CROSS_CORR_ATE_CMAC_IQ_CYCLES_SET(x)                          (((x) << 0) & 0x0000000f)
-
-/* macros for cmac_i2q2 */
-#define PHY_ANALOG_CMAC_I2Q2_ADDRESS                                                                 0x000003bc
-#define PHY_ANALOG_CMAC_I2Q2_OFFSET                                                                  0x000003bc
-#define PHY_ANALOG_CMAC_I2Q2_ATE_CMAC_I2Q2_CYCLES_MSB                                                         3
-#define PHY_ANALOG_CMAC_I2Q2_ATE_CMAC_I2Q2_CYCLES_LSB                                                         0
-#define PHY_ANALOG_CMAC_I2Q2_ATE_CMAC_I2Q2_CYCLES_MASK                                               0x0000000f
-#define PHY_ANALOG_CMAC_I2Q2_ATE_CMAC_I2Q2_CYCLES_GET(x)                              (((x) & 0x0000000f) >> 0)
-#define PHY_ANALOG_CMAC_I2Q2_ATE_CMAC_I2Q2_CYCLES_SET(x)                              (((x) << 0) & 0x0000000f)
-
-/* macros for cmac_power_hpf */
-#define PHY_ANALOG_CMAC_POWER_HPF_ADDRESS                                                            0x000003c0
-#define PHY_ANALOG_CMAC_POWER_HPF_OFFSET                                                             0x000003c0
-#define PHY_ANALOG_CMAC_POWER_HPF_ATE_CMAC_POWER_HPF_CYCLES_MSB                                               3
-#define PHY_ANALOG_CMAC_POWER_HPF_ATE_CMAC_POWER_HPF_CYCLES_LSB                                               0
-#define PHY_ANALOG_CMAC_POWER_HPF_ATE_CMAC_POWER_HPF_CYCLES_MASK                                     0x0000000f
-#define PHY_ANALOG_CMAC_POWER_HPF_ATE_CMAC_POWER_HPF_CYCLES_GET(x)                    (((x) & 0x0000000f) >> 0)
-#define PHY_ANALOG_CMAC_POWER_HPF_ATE_CMAC_POWER_HPF_CYCLES_SET(x)                    (((x) << 0) & 0x0000000f)
-#define PHY_ANALOG_CMAC_POWER_HPF_ATE_CMAC_POWER_HPF_WAIT_MSB                                                 7
-#define PHY_ANALOG_CMAC_POWER_HPF_ATE_CMAC_POWER_HPF_WAIT_LSB                                                 4
-#define PHY_ANALOG_CMAC_POWER_HPF_ATE_CMAC_POWER_HPF_WAIT_MASK                                       0x000000f0
-#define PHY_ANALOG_CMAC_POWER_HPF_ATE_CMAC_POWER_HPF_WAIT_GET(x)                      (((x) & 0x000000f0) >> 4)
-#define PHY_ANALOG_CMAC_POWER_HPF_ATE_CMAC_POWER_HPF_WAIT_SET(x)                      (((x) << 4) & 0x000000f0)
-
-/* macros for rxdac_set1 */
-#define PHY_ANALOG_RXDAC_SET1_ADDRESS                                                                0x000003c4
-#define PHY_ANALOG_RXDAC_SET1_OFFSET                                                                 0x000003c4
-#define PHY_ANALOG_RXDAC_SET1_ATE_RXDAC_MUX_MSB                                                               1
-#define PHY_ANALOG_RXDAC_SET1_ATE_RXDAC_MUX_LSB                                                               0
-#define PHY_ANALOG_RXDAC_SET1_ATE_RXDAC_MUX_MASK                                                     0x00000003
-#define PHY_ANALOG_RXDAC_SET1_ATE_RXDAC_MUX_GET(x)                                    (((x) & 0x00000003) >> 0)
-#define PHY_ANALOG_RXDAC_SET1_ATE_RXDAC_MUX_SET(x)                                    (((x) << 0) & 0x00000003)
-#define PHY_ANALOG_RXDAC_SET1_ATE_RXDAC_HI_GAIN_MSB                                                           4
-#define PHY_ANALOG_RXDAC_SET1_ATE_RXDAC_HI_GAIN_LSB                                                           4
-#define PHY_ANALOG_RXDAC_SET1_ATE_RXDAC_HI_GAIN_MASK                                                 0x00000010
-#define PHY_ANALOG_RXDAC_SET1_ATE_RXDAC_HI_GAIN_GET(x)                                (((x) & 0x00000010) >> 4)
-#define PHY_ANALOG_RXDAC_SET1_ATE_RXDAC_HI_GAIN_SET(x)                                (((x) << 4) & 0x00000010)
-#define PHY_ANALOG_RXDAC_SET1_ATE_RXDAC_CAL_WAIT_MSB                                                         13
-#define PHY_ANALOG_RXDAC_SET1_ATE_RXDAC_CAL_WAIT_LSB                                                          8
-#define PHY_ANALOG_RXDAC_SET1_ATE_RXDAC_CAL_WAIT_MASK                                                0x00003f00
-#define PHY_ANALOG_RXDAC_SET1_ATE_RXDAC_CAL_WAIT_GET(x)                               (((x) & 0x00003f00) >> 8)
-#define PHY_ANALOG_RXDAC_SET1_ATE_RXDAC_CAL_WAIT_SET(x)                               (((x) << 8) & 0x00003f00)
-#define PHY_ANALOG_RXDAC_SET1_ATE_RXDAC_CAL_MEASURE_TIME_MSB                                                 19
-#define PHY_ANALOG_RXDAC_SET1_ATE_RXDAC_CAL_MEASURE_TIME_LSB                                                 16
-#define PHY_ANALOG_RXDAC_SET1_ATE_RXDAC_CAL_MEASURE_TIME_MASK                                        0x000f0000
-#define PHY_ANALOG_RXDAC_SET1_ATE_RXDAC_CAL_MEASURE_TIME_GET(x)                      (((x) & 0x000f0000) >> 16)
-#define PHY_ANALOG_RXDAC_SET1_ATE_RXDAC_CAL_MEASURE_TIME_SET(x)                      (((x) << 16) & 0x000f0000)
-
-/* macros for rxdac_set2 */
-#define PHY_ANALOG_RXDAC_SET2_ADDRESS                                                                0x000003c8
-#define PHY_ANALOG_RXDAC_SET2_OFFSET                                                                 0x000003c8
-#define PHY_ANALOG_RXDAC_SET2_ATE_RXDAC_I_HI_MSB                                                              4
-#define PHY_ANALOG_RXDAC_SET2_ATE_RXDAC_I_HI_LSB                                                              0
-#define PHY_ANALOG_RXDAC_SET2_ATE_RXDAC_I_HI_MASK                                                    0x0000001f
-#define PHY_ANALOG_RXDAC_SET2_ATE_RXDAC_I_HI_GET(x)                                   (((x) & 0x0000001f) >> 0)
-#define PHY_ANALOG_RXDAC_SET2_ATE_RXDAC_I_HI_SET(x)                                   (((x) << 0) & 0x0000001f)
-#define PHY_ANALOG_RXDAC_SET2_ATE_RXDAC_Q_HI_MSB                                                             12
-#define PHY_ANALOG_RXDAC_SET2_ATE_RXDAC_Q_HI_LSB                                                              8
-#define PHY_ANALOG_RXDAC_SET2_ATE_RXDAC_Q_HI_MASK                                                    0x00001f00
-#define PHY_ANALOG_RXDAC_SET2_ATE_RXDAC_Q_HI_GET(x)                                   (((x) & 0x00001f00) >> 8)
-#define PHY_ANALOG_RXDAC_SET2_ATE_RXDAC_Q_HI_SET(x)                                   (((x) << 8) & 0x00001f00)
-#define PHY_ANALOG_RXDAC_SET2_ATE_RXDAC_I_LOW_MSB                                                            20
-#define PHY_ANALOG_RXDAC_SET2_ATE_RXDAC_I_LOW_LSB                                                            16
-#define PHY_ANALOG_RXDAC_SET2_ATE_RXDAC_I_LOW_MASK                                                   0x001f0000
-#define PHY_ANALOG_RXDAC_SET2_ATE_RXDAC_I_LOW_GET(x)                                 (((x) & 0x001f0000) >> 16)
-#define PHY_ANALOG_RXDAC_SET2_ATE_RXDAC_I_LOW_SET(x)                                 (((x) << 16) & 0x001f0000)
-#define PHY_ANALOG_RXDAC_SET2_ATE_RXDAC_Q_LOW_MSB                                                            28
-#define PHY_ANALOG_RXDAC_SET2_ATE_RXDAC_Q_LOW_LSB                                                            24
-#define PHY_ANALOG_RXDAC_SET2_ATE_RXDAC_Q_LOW_MASK                                                   0x1f000000
-#define PHY_ANALOG_RXDAC_SET2_ATE_RXDAC_Q_LOW_GET(x)                                 (((x) & 0x1f000000) >> 24)
-#define PHY_ANALOG_RXDAC_SET2_ATE_RXDAC_Q_LOW_SET(x)                                 (((x) << 24) & 0x1f000000)
-
-/* macros for rxdac_long_shift */
-#define PHY_ANALOG_RXDAC_LONG_SHIFT_ADDRESS                                                          0x000003cc
-#define PHY_ANALOG_RXDAC_LONG_SHIFT_OFFSET                                                           0x000003cc
-#define PHY_ANALOG_RXDAC_LONG_SHIFT_ATE_RXDAC_I_STATIC_MSB                                                    4
-#define PHY_ANALOG_RXDAC_LONG_SHIFT_ATE_RXDAC_I_STATIC_LSB                                                    0
-#define PHY_ANALOG_RXDAC_LONG_SHIFT_ATE_RXDAC_I_STATIC_MASK                                          0x0000001f
-#define PHY_ANALOG_RXDAC_LONG_SHIFT_ATE_RXDAC_I_STATIC_GET(x)                         (((x) & 0x0000001f) >> 0)
-#define PHY_ANALOG_RXDAC_LONG_SHIFT_ATE_RXDAC_I_STATIC_SET(x)                         (((x) << 0) & 0x0000001f)
-#define PHY_ANALOG_RXDAC_LONG_SHIFT_ATE_RXDAC_Q_STATIC_MSB                                                   12
-#define PHY_ANALOG_RXDAC_LONG_SHIFT_ATE_RXDAC_Q_STATIC_LSB                                                    8
-#define PHY_ANALOG_RXDAC_LONG_SHIFT_ATE_RXDAC_Q_STATIC_MASK                                          0x00001f00
-#define PHY_ANALOG_RXDAC_LONG_SHIFT_ATE_RXDAC_Q_STATIC_GET(x)                         (((x) & 0x00001f00) >> 8)
-#define PHY_ANALOG_RXDAC_LONG_SHIFT_ATE_RXDAC_Q_STATIC_SET(x)                         (((x) << 8) & 0x00001f00)
-
-/* macros for cmac_results_i */
-#define PHY_ANALOG_CMAC_RESULTS_I_ADDRESS                                                            0x000003d0
-#define PHY_ANALOG_CMAC_RESULTS_I_OFFSET                                                             0x000003d0
-#define PHY_ANALOG_CMAC_RESULTS_I_ATE_CMAC_RESULTS_MSB                                                       31
-#define PHY_ANALOG_CMAC_RESULTS_I_ATE_CMAC_RESULTS_LSB                                                        0
-#define PHY_ANALOG_CMAC_RESULTS_I_ATE_CMAC_RESULTS_MASK                                              0xffffffff
-#define PHY_ANALOG_CMAC_RESULTS_I_ATE_CMAC_RESULTS_GET(x)                             (((x) & 0xffffffff) >> 0)
-#define PHY_ANALOG_CMAC_RESULTS_I_ATE_CMAC_RESULTS_SET(x)                             (((x) << 0) & 0xffffffff)
-
-/* macros for cmac_results_q */
-#define PHY_ANALOG_CMAC_RESULTS_Q_ADDRESS                                                            0x000003d4
-#define PHY_ANALOG_CMAC_RESULTS_Q_OFFSET                                                             0x000003d4
-#define PHY_ANALOG_CMAC_RESULTS_Q_ATE_CMAC_RESULTS_MSB                                                       31
-#define PHY_ANALOG_CMAC_RESULTS_Q_ATE_CMAC_RESULTS_LSB                                                        0
-#define PHY_ANALOG_CMAC_RESULTS_Q_ATE_CMAC_RESULTS_MASK                                              0xffffffff
-#define PHY_ANALOG_CMAC_RESULTS_Q_ATE_CMAC_RESULTS_GET(x)                             (((x) & 0xffffffff) >> 0)
-#define PHY_ANALOG_CMAC_RESULTS_Q_ATE_CMAC_RESULTS_SET(x)                             (((x) << 0) & 0xffffffff)
-
-/* macros for PMU1 */
-#define PHY_ANALOG_PMU1_ADDRESS                                                                      0x00000740
-#define PHY_ANALOG_PMU1_OFFSET                                                                       0x00000740
-#define PHY_ANALOG_PMU1_SPARE_MSB                                                                            10
-#define PHY_ANALOG_PMU1_SPARE_LSB                                                                             0
-#define PHY_ANALOG_PMU1_SPARE_MASK                                                                   0x000007ff
-#define PHY_ANALOG_PMU1_SPARE_GET(x)                                                  (((x) & 0x000007ff) >> 0)
-#define PHY_ANALOG_PMU1_SPARE_SET(x)                                                  (((x) << 0) & 0x000007ff)
-#define PHY_ANALOG_PMU1_OTP_V25_PWD_MSB                                                                      11
-#define PHY_ANALOG_PMU1_OTP_V25_PWD_LSB                                                                      11
-#define PHY_ANALOG_PMU1_OTP_V25_PWD_MASK                                                             0x00000800
-#define PHY_ANALOG_PMU1_OTP_V25_PWD_GET(x)                                           (((x) & 0x00000800) >> 11)
-#define PHY_ANALOG_PMU1_OTP_V25_PWD_SET(x)                                           (((x) << 11) & 0x00000800)
-#define PHY_ANALOG_PMU1_PAREGON_MAN_MSB                                                                      12
-#define PHY_ANALOG_PMU1_PAREGON_MAN_LSB                                                                      12
-#define PHY_ANALOG_PMU1_PAREGON_MAN_MASK                                                             0x00001000
-#define PHY_ANALOG_PMU1_PAREGON_MAN_GET(x)                                           (((x) & 0x00001000) >> 12)
-#define PHY_ANALOG_PMU1_PAREGON_MAN_SET(x)                                           (((x) << 12) & 0x00001000)
-#define PHY_ANALOG_PMU1_OTPREGON_MAN_MSB                                                                     13
-#define PHY_ANALOG_PMU1_OTPREGON_MAN_LSB                                                                     13
-#define PHY_ANALOG_PMU1_OTPREGON_MAN_MASK                                                            0x00002000
-#define PHY_ANALOG_PMU1_OTPREGON_MAN_GET(x)                                          (((x) & 0x00002000) >> 13)
-#define PHY_ANALOG_PMU1_OTPREGON_MAN_SET(x)                                          (((x) << 13) & 0x00002000)
-#define PHY_ANALOG_PMU1_DREGON_MAN_MSB                                                                       14
-#define PHY_ANALOG_PMU1_DREGON_MAN_LSB                                                                       14
-#define PHY_ANALOG_PMU1_DREGON_MAN_MASK                                                              0x00004000
-#define PHY_ANALOG_PMU1_DREGON_MAN_GET(x)                                            (((x) & 0x00004000) >> 14)
-#define PHY_ANALOG_PMU1_DREGON_MAN_SET(x)                                            (((x) << 14) & 0x00004000)
-#define PHY_ANALOG_PMU1_DISCONTMODEEN_MSB                                                                    15
-#define PHY_ANALOG_PMU1_DISCONTMODEEN_LSB                                                                    15
-#define PHY_ANALOG_PMU1_DISCONTMODEEN_MASK                                                           0x00008000
-#define PHY_ANALOG_PMU1_DISCONTMODEEN_GET(x)                                         (((x) & 0x00008000) >> 15)
-#define PHY_ANALOG_PMU1_DISCONTMODEEN_SET(x)                                         (((x) << 15) & 0x00008000)
-#define PHY_ANALOG_PMU1_SWREGON_MAN_MSB                                                                      16
-#define PHY_ANALOG_PMU1_SWREGON_MAN_LSB                                                                      16
-#define PHY_ANALOG_PMU1_SWREGON_MAN_MASK                                                             0x00010000
-#define PHY_ANALOG_PMU1_SWREGON_MAN_GET(x)                                           (((x) & 0x00010000) >> 16)
-#define PHY_ANALOG_PMU1_SWREGON_MAN_SET(x)                                           (((x) << 16) & 0x00010000)
-#define PHY_ANALOG_PMU1_SWREG_FREQCUR_MSB                                                                    18
-#define PHY_ANALOG_PMU1_SWREG_FREQCUR_LSB                                                                    17
-#define PHY_ANALOG_PMU1_SWREG_FREQCUR_MASK                                                           0x00060000
-#define PHY_ANALOG_PMU1_SWREG_FREQCUR_GET(x)                                         (((x) & 0x00060000) >> 17)
-#define PHY_ANALOG_PMU1_SWREG_FREQCUR_SET(x)                                         (((x) << 17) & 0x00060000)
-#define PHY_ANALOG_PMU1_SWREG_FREQCAP_MSB                                                                    21
-#define PHY_ANALOG_PMU1_SWREG_FREQCAP_LSB                                                                    19
-#define PHY_ANALOG_PMU1_SWREG_FREQCAP_MASK                                                           0x00380000
-#define PHY_ANALOG_PMU1_SWREG_FREQCAP_GET(x)                                         (((x) & 0x00380000) >> 19)
-#define PHY_ANALOG_PMU1_SWREG_FREQCAP_SET(x)                                         (((x) << 19) & 0x00380000)
-#define PHY_ANALOG_PMU1_SWREG_LVLCTR_MSB                                                                     23
-#define PHY_ANALOG_PMU1_SWREG_LVLCTR_LSB                                                                     22
-#define PHY_ANALOG_PMU1_SWREG_LVLCTR_MASK                                                            0x00c00000
-#define PHY_ANALOG_PMU1_SWREG_LVLCTR_GET(x)                                          (((x) & 0x00c00000) >> 22)
-#define PHY_ANALOG_PMU1_SWREG_LVLCTR_SET(x)                                          (((x) << 22) & 0x00c00000)
-#define PHY_ANALOG_PMU1_SREG_LVLCTR_MSB                                                                      25
-#define PHY_ANALOG_PMU1_SREG_LVLCTR_LSB                                                                      24
-#define PHY_ANALOG_PMU1_SREG_LVLCTR_MASK                                                             0x03000000
-#define PHY_ANALOG_PMU1_SREG_LVLCTR_GET(x)                                           (((x) & 0x03000000) >> 24)
-#define PHY_ANALOG_PMU1_SREG_LVLCTR_SET(x)                                           (((x) << 24) & 0x03000000)
-#define PHY_ANALOG_PMU1_DREG_LVLCTR_MSB                                                                      27
-#define PHY_ANALOG_PMU1_DREG_LVLCTR_LSB                                                                      26
-#define PHY_ANALOG_PMU1_DREG_LVLCTR_MASK                                                             0x0c000000
-#define PHY_ANALOG_PMU1_DREG_LVLCTR_GET(x)                                           (((x) & 0x0c000000) >> 26)
-#define PHY_ANALOG_PMU1_DREG_LVLCTR_SET(x)                                           (((x) << 26) & 0x0c000000)
-#define PHY_ANALOG_PMU1_PAREG_XPNP_MSB                                                                       28
-#define PHY_ANALOG_PMU1_PAREG_XPNP_LSB                                                                       28
-#define PHY_ANALOG_PMU1_PAREG_XPNP_MASK                                                              0x10000000
-#define PHY_ANALOG_PMU1_PAREG_XPNP_GET(x)                                            (((x) & 0x10000000) >> 28)
-#define PHY_ANALOG_PMU1_PAREG_XPNP_SET(x)                                            (((x) << 28) & 0x10000000)
-#define PHY_ANALOG_PMU1_PAREG_LVLCTR_MSB                                                                     31
-#define PHY_ANALOG_PMU1_PAREG_LVLCTR_LSB                                                                     29
-#define PHY_ANALOG_PMU1_PAREG_LVLCTR_MASK                                                            0xe0000000
-#define PHY_ANALOG_PMU1_PAREG_LVLCTR_GET(x)                                          (((x) & 0xe0000000) >> 29)
-#define PHY_ANALOG_PMU1_PAREG_LVLCTR_SET(x)                                          (((x) << 29) & 0xe0000000)
-
-/* macros for PMU2 */
-#define PHY_ANALOG_PMU2_ADDRESS                                                                      0x00000744
-#define PHY_ANALOG_PMU2_OFFSET                                                                       0x00000744
-#define PHY_ANALOG_PMU2_SPARE_MSB                                                                             7
-#define PHY_ANALOG_PMU2_SPARE_LSB                                                                             0
-#define PHY_ANALOG_PMU2_SPARE_MASK                                                                   0x000000ff
-#define PHY_ANALOG_PMU2_SPARE_GET(x)                                                  (((x) & 0x000000ff) >> 0)
-#define PHY_ANALOG_PMU2_SPARE_SET(x)                                                  (((x) << 0) & 0x000000ff)
-#define PHY_ANALOG_PMU2_VBATT_1_3TOATB_MSB                                                                    8
-#define PHY_ANALOG_PMU2_VBATT_1_3TOATB_LSB                                                                    8
-#define PHY_ANALOG_PMU2_VBATT_1_3TOATB_MASK                                                          0x00000100
-#define PHY_ANALOG_PMU2_VBATT_1_3TOATB_GET(x)                                         (((x) & 0x00000100) >> 8)
-#define PHY_ANALOG_PMU2_VBATT_1_3TOATB_SET(x)                                         (((x) << 8) & 0x00000100)
-#define PHY_ANALOG_PMU2_VBATT_1_2TOATB_MSB                                                                    9
-#define PHY_ANALOG_PMU2_VBATT_1_2TOATB_LSB                                                                    9
-#define PHY_ANALOG_PMU2_VBATT_1_2TOATB_MASK                                                          0x00000200
-#define PHY_ANALOG_PMU2_VBATT_1_2TOATB_GET(x)                                         (((x) & 0x00000200) >> 9)
-#define PHY_ANALOG_PMU2_VBATT_1_2TOATB_SET(x)                                         (((x) << 9) & 0x00000200)
-#define PHY_ANALOG_PMU2_VBATT_2_3TOATB_MSB                                                                   10
-#define PHY_ANALOG_PMU2_VBATT_2_3TOATB_LSB                                                                   10
-#define PHY_ANALOG_PMU2_VBATT_2_3TOATB_MASK                                                          0x00000400
-#define PHY_ANALOG_PMU2_VBATT_2_3TOATB_GET(x)                                        (((x) & 0x00000400) >> 10)
-#define PHY_ANALOG_PMU2_VBATT_2_3TOATB_SET(x)                                        (((x) << 10) & 0x00000400)
-#define PHY_ANALOG_PMU2_PWD_BANDGAP_MAN_MSB                                                                  11
-#define PHY_ANALOG_PMU2_PWD_BANDGAP_MAN_LSB                                                                  11
-#define PHY_ANALOG_PMU2_PWD_BANDGAP_MAN_MASK                                                         0x00000800
-#define PHY_ANALOG_PMU2_PWD_BANDGAP_MAN_GET(x)                                       (((x) & 0x00000800) >> 11)
-#define PHY_ANALOG_PMU2_PWD_BANDGAP_MAN_SET(x)                                       (((x) << 11) & 0x00000800)
-#define PHY_ANALOG_PMU2_PWD_LFO_MAN_MSB                                                                      12
-#define PHY_ANALOG_PMU2_PWD_LFO_MAN_LSB                                                                      12
-#define PHY_ANALOG_PMU2_PWD_LFO_MAN_MASK                                                             0x00001000
-#define PHY_ANALOG_PMU2_PWD_LFO_MAN_GET(x)                                           (((x) & 0x00001000) >> 12)
-#define PHY_ANALOG_PMU2_PWD_LFO_MAN_SET(x)                                           (((x) << 12) & 0x00001000)
-#define PHY_ANALOG_PMU2_VBATT_LT_3P2_MSB                                                                     13
-#define PHY_ANALOG_PMU2_VBATT_LT_3P2_LSB                                                                     13
-#define PHY_ANALOG_PMU2_VBATT_LT_3P2_MASK                                                            0x00002000
-#define PHY_ANALOG_PMU2_VBATT_LT_3P2_GET(x)                                          (((x) & 0x00002000) >> 13)
-#define PHY_ANALOG_PMU2_VBATT_LT_3P2_SET(x)                                          (((x) << 13) & 0x00002000)
-#define PHY_ANALOG_PMU2_VBATT_LT_2P8_MSB                                                                     14
-#define PHY_ANALOG_PMU2_VBATT_LT_2P8_LSB                                                                     14
-#define PHY_ANALOG_PMU2_VBATT_LT_2P8_MASK                                                            0x00004000
-#define PHY_ANALOG_PMU2_VBATT_LT_2P8_GET(x)                                          (((x) & 0x00004000) >> 14)
-#define PHY_ANALOG_PMU2_VBATT_LT_2P8_SET(x)                                          (((x) << 14) & 0x00004000)
-#define PHY_ANALOG_PMU2_VBATT_GT_4P2_MSB                                                                     15
-#define PHY_ANALOG_PMU2_VBATT_GT_4P2_LSB                                                                     15
-#define PHY_ANALOG_PMU2_VBATT_GT_4P2_MASK                                                            0x00008000
-#define PHY_ANALOG_PMU2_VBATT_GT_4P2_GET(x)                                          (((x) & 0x00008000) >> 15)
-#define PHY_ANALOG_PMU2_VBATT_GT_4P2_SET(x)                                          (((x) << 15) & 0x00008000)
-#define PHY_ANALOG_PMU2_PMU_MAN_OVERRIDE_EN_MSB                                                              16
-#define PHY_ANALOG_PMU2_PMU_MAN_OVERRIDE_EN_LSB                                                              16
-#define PHY_ANALOG_PMU2_PMU_MAN_OVERRIDE_EN_MASK                                                     0x00010000
-#define PHY_ANALOG_PMU2_PMU_MAN_OVERRIDE_EN_GET(x)                                   (((x) & 0x00010000) >> 16)
-#define PHY_ANALOG_PMU2_PMU_MAN_OVERRIDE_EN_SET(x)                                   (((x) << 16) & 0x00010000)
-#define PHY_ANALOG_PMU2_VBATT_GT_LVLCTR_MSB                                                                  18
-#define PHY_ANALOG_PMU2_VBATT_GT_LVLCTR_LSB                                                                  17
-#define PHY_ANALOG_PMU2_VBATT_GT_LVLCTR_MASK                                                         0x00060000
-#define PHY_ANALOG_PMU2_VBATT_GT_LVLCTR_GET(x)                                       (((x) & 0x00060000) >> 17)
-#define PHY_ANALOG_PMU2_VBATT_GT_LVLCTR_SET(x)                                       (((x) << 17) & 0x00060000)
-#define PHY_ANALOG_PMU2_SWREGVSSL2ATB_MSB                                                                    19
-#define PHY_ANALOG_PMU2_SWREGVSSL2ATB_LSB                                                                    19
-#define PHY_ANALOG_PMU2_SWREGVSSL2ATB_MASK                                                           0x00080000
-#define PHY_ANALOG_PMU2_SWREGVSSL2ATB_GET(x)                                         (((x) & 0x00080000) >> 19)
-#define PHY_ANALOG_PMU2_SWREGVSSL2ATB_SET(x)                                         (((x) << 19) & 0x00080000)
-#define PHY_ANALOG_PMU2_SWREGVSSL_LVLCTR_MSB                                                                 21
-#define PHY_ANALOG_PMU2_SWREGVSSL_LVLCTR_LSB                                                                 20
-#define PHY_ANALOG_PMU2_SWREGVSSL_LVLCTR_MASK                                                        0x00300000
-#define PHY_ANALOG_PMU2_SWREGVSSL_LVLCTR_GET(x)                                      (((x) & 0x00300000) >> 20)
-#define PHY_ANALOG_PMU2_SWREGVSSL_LVLCTR_SET(x)                                      (((x) << 20) & 0x00300000)
-#define PHY_ANALOG_PMU2_SWREGVDDH2ATB_MSB                                                                    22
-#define PHY_ANALOG_PMU2_SWREGVDDH2ATB_LSB                                                                    22
-#define PHY_ANALOG_PMU2_SWREGVDDH2ATB_MASK                                                           0x00400000
-#define PHY_ANALOG_PMU2_SWREGVDDH2ATB_GET(x)                                         (((x) & 0x00400000) >> 22)
-#define PHY_ANALOG_PMU2_SWREGVDDH2ATB_SET(x)                                         (((x) << 22) & 0x00400000)
-#define PHY_ANALOG_PMU2_SWREGVDDH_LVLCTR_MSB                                                                 24
-#define PHY_ANALOG_PMU2_SWREGVDDH_LVLCTR_LSB                                                                 23
-#define PHY_ANALOG_PMU2_SWREGVDDH_LVLCTR_MASK                                                        0x01800000
-#define PHY_ANALOG_PMU2_SWREGVDDH_LVLCTR_GET(x)                                      (((x) & 0x01800000) >> 23)
-#define PHY_ANALOG_PMU2_SWREGVDDH_LVLCTR_SET(x)                                      (((x) << 23) & 0x01800000)
-#define PHY_ANALOG_PMU2_SWREG2ATB_MSB                                                                        27
-#define PHY_ANALOG_PMU2_SWREG2ATB_LSB                                                                        25
-#define PHY_ANALOG_PMU2_SWREG2ATB_MASK                                                               0x0e000000
-#define PHY_ANALOG_PMU2_SWREG2ATB_GET(x)                                             (((x) & 0x0e000000) >> 25)
-#define PHY_ANALOG_PMU2_SWREG2ATB_SET(x)                                             (((x) << 25) & 0x0e000000)
-#define PHY_ANALOG_PMU2_OTPREG2ATB_MSB                                                                       28
-#define PHY_ANALOG_PMU2_OTPREG2ATB_LSB                                                                       28
-#define PHY_ANALOG_PMU2_OTPREG2ATB_MASK                                                              0x10000000
-#define PHY_ANALOG_PMU2_OTPREG2ATB_GET(x)                                            (((x) & 0x10000000) >> 28)
-#define PHY_ANALOG_PMU2_OTPREG2ATB_SET(x)                                            (((x) << 28) & 0x10000000)
-#define PHY_ANALOG_PMU2_OTPREG_LVLCTR_MSB                                                                    30
-#define PHY_ANALOG_PMU2_OTPREG_LVLCTR_LSB                                                                    29
-#define PHY_ANALOG_PMU2_OTPREG_LVLCTR_MASK                                                           0x60000000
-#define PHY_ANALOG_PMU2_OTPREG_LVLCTR_GET(x)                                         (((x) & 0x60000000) >> 29)
-#define PHY_ANALOG_PMU2_OTPREG_LVLCTR_SET(x)                                         (((x) << 29) & 0x60000000)
-#define PHY_ANALOG_PMU2_DREG_LVLCTR_MANOVR_EN_MSB                                                            31
-#define PHY_ANALOG_PMU2_DREG_LVLCTR_MANOVR_EN_LSB                                                            31
-#define PHY_ANALOG_PMU2_DREG_LVLCTR_MANOVR_EN_MASK                                                   0x80000000
-#define PHY_ANALOG_PMU2_DREG_LVLCTR_MANOVR_EN_GET(x)                                 (((x) & 0x80000000) >> 31)
-#define PHY_ANALOG_PMU2_DREG_LVLCTR_MANOVR_EN_SET(x)                                 (((x) << 31) & 0x80000000)
-
-
-#ifndef __ASSEMBLER__
-
-typedef struct analog_intf_athr_wlan_reg_reg_s {
-  volatile unsigned int RXRF_BIAS1;                                    /*        0x0 - 0x4        */
-  volatile unsigned int RXRF_BIAS2;                                    /*        0x4 - 0x8        */
-  volatile unsigned int RXRF_GAINSTAGES;                               /*        0x8 - 0xc        */
-  volatile unsigned int RXRF_AGC;                                      /*        0xc - 0x10       */
-  volatile char pad__0[0x30];                                          /*       0x10 - 0x40       */
-  volatile unsigned int TXRF1;                                         /*       0x40 - 0x44       */
-  volatile unsigned int TXRF2;                                         /*       0x44 - 0x48       */
-  volatile unsigned int TXRF3;                                         /*       0x48 - 0x4c       */
-  volatile unsigned int TXRF4;                                         /*       0x4c - 0x50       */
-  volatile unsigned int TXRF5;                                         /*       0x50 - 0x54       */
-  volatile unsigned int TXRF6;                                         /*       0x54 - 0x58       */
-  volatile unsigned int TXRF7;                                         /*       0x58 - 0x5c       */
-  volatile unsigned int TXRF8;                                         /*       0x5c - 0x60       */
-  volatile unsigned int TXRF9;                                         /*       0x60 - 0x64       */
-  volatile unsigned int TXRF10;                                        /*       0x64 - 0x68       */
-  volatile unsigned int TXRF11;                                        /*       0x68 - 0x6c       */
-  volatile unsigned int TXRF12;                                        /*       0x6c - 0x70       */
-  volatile char pad__1[0x10];                                          /*       0x70 - 0x80       */
-  volatile unsigned int SYNTH1;                                        /*       0x80 - 0x84       */
-  volatile unsigned int SYNTH2;                                        /*       0x84 - 0x88       */
-  volatile unsigned int SYNTH3;                                        /*       0x88 - 0x8c       */
-  volatile unsigned int SYNTH4;                                        /*       0x8c - 0x90       */
-  volatile unsigned int SYNTH5;                                        /*       0x90 - 0x94       */
-  volatile unsigned int SYNTH6;                                        /*       0x94 - 0x98       */
-  volatile unsigned int SYNTH7;                                        /*       0x98 - 0x9c       */
-  volatile unsigned int SYNTH8;                                        /*       0x9c - 0xa0       */
-  volatile unsigned int SYNTH9;                                        /*       0xa0 - 0xa4       */
-  volatile unsigned int SYNTH10;                                       /*       0xa4 - 0xa8       */
-  volatile unsigned int SYNTH11;                                       /*       0xa8 - 0xac       */
-  volatile unsigned int SYNTH12;                                       /*       0xac - 0xb0       */
-  volatile unsigned int SYNTH13;                                       /*       0xb0 - 0xb4       */
-  volatile unsigned int SYNTH14;                                       /*       0xb4 - 0xb8       */
-  volatile char pad__2[0x8];                                           /*       0xb8 - 0xc0       */
-  volatile unsigned int BIAS1;                                         /*       0xc0 - 0xc4       */
-  volatile unsigned int BIAS2;                                         /*       0xc4 - 0xc8       */
-  volatile unsigned int BIAS3;                                         /*       0xc8 - 0xcc       */
-  volatile unsigned int BIAS4;                                         /*       0xcc - 0xd0       */
-  volatile char pad__3[0x30];                                          /*       0xd0 - 0x100      */
-  volatile unsigned int RXTX1;                                         /*      0x100 - 0x104      */
-  volatile unsigned int RXTX2;                                         /*      0x104 - 0x108      */
-  volatile unsigned int RXTX3;                                         /*      0x108 - 0x10c      */
-  volatile char pad__4[0x34];                                          /*      0x10c - 0x140      */
-  volatile unsigned int BB1;                                           /*      0x140 - 0x144      */
-  volatile unsigned int BB2;                                           /*      0x144 - 0x148      */
-  volatile unsigned int BB3;                                           /*      0x148 - 0x14c      */
-  volatile char pad__5[0x134];                                         /*      0x14c - 0x280      */
-  volatile unsigned int PLLCLKMODA;                                    /*      0x280 - 0x284      */
-  volatile unsigned int PLLCLKMODA2;                                   /*      0x284 - 0x288      */
-  volatile unsigned int TOP;                                           /*      0x288 - 0x28c      */
-  volatile unsigned int THERM;                                         /*      0x28c - 0x290      */
-  volatile unsigned int XTAL;                                          /*      0x290 - 0x294      */
-  volatile char pad__6[0xec];                                          /*      0x294 - 0x380      */
-  volatile unsigned int rbist_cntrl;                                   /*      0x380 - 0x384      */
-  volatile unsigned int tx_dc_offset;                                  /*      0x384 - 0x388      */
-  volatile unsigned int tx_tonegen0;                                   /*      0x388 - 0x38c      */
-  volatile unsigned int tx_tonegen1;                                   /*      0x38c - 0x390      */
-  volatile unsigned int tx_lftonegen0;                                 /*      0x390 - 0x394      */
-  volatile unsigned int tx_linear_ramp_i;                              /*      0x394 - 0x398      */
-  volatile unsigned int tx_linear_ramp_q;                              /*      0x398 - 0x39c      */
-  volatile unsigned int tx_prbs_mag;                                   /*      0x39c - 0x3a0      */
-  volatile unsigned int tx_prbs_seed_i;                                /*      0x3a0 - 0x3a4      */
-  volatile unsigned int tx_prbs_seed_q;                                /*      0x3a4 - 0x3a8      */
-  volatile unsigned int cmac_dc_cancel;                                /*      0x3a8 - 0x3ac      */
-  volatile unsigned int cmac_dc_offset;                                /*      0x3ac - 0x3b0      */
-  volatile unsigned int cmac_corr;                                     /*      0x3b0 - 0x3b4      */
-  volatile unsigned int cmac_power;                                    /*      0x3b4 - 0x3b8      */
-  volatile unsigned int cmac_cross_corr;                               /*      0x3b8 - 0x3bc      */
-  volatile unsigned int cmac_i2q2;                                     /*      0x3bc - 0x3c0      */
-  volatile unsigned int cmac_power_hpf;                                /*      0x3c0 - 0x3c4      */
-  volatile unsigned int rxdac_set1;                                    /*      0x3c4 - 0x3c8      */
-  volatile unsigned int rxdac_set2;                                    /*      0x3c8 - 0x3cc      */
-  volatile unsigned int rxdac_long_shift;                              /*      0x3cc - 0x3d0      */
-  volatile unsigned int cmac_results_i;                                /*      0x3d0 - 0x3d4      */
-  volatile unsigned int cmac_results_q;                                /*      0x3d4 - 0x3d8      */
-  volatile char pad__7[0x368];                                         /*      0x3d8 - 0x740      */
-  volatile unsigned int PMU1;                                          /*      0x740 - 0x744      */
-  volatile unsigned int PMU2;                                          /*      0x744 - 0x748      */
-} analog_intf_athr_wlan_reg_reg_t;
-
-#endif /* __ASSEMBLER__ */
-
-#endif /* _ANALOG_INTF_ATHR_WLAN_REG_REG_H_ */
diff --git a/drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/analog_intf_reg.h b/drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/analog_intf_reg.h
deleted file mode 100644 (file)
index 01b9eb5..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-// ------------------------------------------------------------------
-// Copyright (c) 2004-2010 Atheros Corporation.  All rights reserved.
-// 
-//
-// Permission to use, copy, modify, and/or distribute this software for any
-// purpose with or without fee is hereby granted, provided that the above
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-//
-//
-// ------------------------------------------------------------------
-//===================================================================
-// Author(s): ="Atheros"
-//===================================================================
-
-
-#ifdef WLAN_HEADERS
-
-#include "analog_intf_athr_wlan_reg.h"
-
-
-#ifndef BT_HEADERS
-
-
-
-#endif
-#endif
-
-
-
index e4d2d62f0bb48ec63acb2ef49357ad4f045fd6c3..0068ca31b0516e0bf397c460f1c89904deaefe4c 100644 (file)
 //===================================================================
 
 
-#ifdef WLAN_HEADERS
-
 #include "apb_athr_wlan_map.h"
 
-
 #ifndef BT_HEADERS
 
 #define RTC_BASE_ADDRESS WLAN_RTC_BASE_ADDRESS
@@ -40,9 +37,4 @@
 #define MAC_BASE_ADDRESS WLAN_MAC_BASE_ADDRESS
 #define RDMA_BASE_ADDRESS WLAN_RDMA_BASE_ADDRESS
 
-
-#endif
 #endif
-
-
-
diff --git a/drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/bb_lc_reg.h b/drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/bb_lc_reg.h
deleted file mode 100644 (file)
index 2711929..0000000
+++ /dev/null
@@ -1,7076 +0,0 @@
-// ------------------------------------------------------------------
-// Copyright (c) 2004-2010 Atheros Corporation.  All rights reserved.
-// 
-//
-// Permission to use, copy, modify, and/or distribute this software for any
-// purpose with or without fee is hereby granted, provided that the above
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-//
-//
-// ------------------------------------------------------------------
-//===================================================================
-// Author(s): ="Atheros"
-//===================================================================
-
-/* Copyright (C) 2009 Denali Software Inc.  All rights reserved              */
-/* THIS FILE IS AUTOMATICALLY GENERATED BY DENALI BLUEPRINT, DO NOT EDIT     */
-
-
-#ifndef _BB_LC_REG_REG_H_
-#define _BB_LC_REG_REG_H_
-
-
-/* macros for BB_test_controls */
-#define PHY_BB_TEST_CONTROLS_ADDRESS                                                          0x00009800
-#define PHY_BB_TEST_CONTROLS_OFFSET                                                           0x00009800
-#define PHY_BB_TEST_CONTROLS_CF_TSTTRIG_SEL_MSB                                                        3
-#define PHY_BB_TEST_CONTROLS_CF_TSTTRIG_SEL_LSB                                                        0
-#define PHY_BB_TEST_CONTROLS_CF_TSTTRIG_SEL_MASK                                              0x0000000f
-#define PHY_BB_TEST_CONTROLS_CF_TSTTRIG_SEL_GET(x)                             (((x) & 0x0000000f) >> 0)
-#define PHY_BB_TEST_CONTROLS_CF_TSTTRIG_SEL_SET(x)                             (((x) << 0) & 0x0000000f)
-#define PHY_BB_TEST_CONTROLS_CF_TSTTRIG_MSB                                                            4
-#define PHY_BB_TEST_CONTROLS_CF_TSTTRIG_LSB                                                            4
-#define PHY_BB_TEST_CONTROLS_CF_TSTTRIG_MASK                                                  0x00000010
-#define PHY_BB_TEST_CONTROLS_CF_TSTTRIG_GET(x)                                 (((x) & 0x00000010) >> 4)
-#define PHY_BB_TEST_CONTROLS_CF_TSTTRIG_SET(x)                                 (((x) << 4) & 0x00000010)
-#define PHY_BB_TEST_CONTROLS_CF_RFSHIFT_SEL_MSB                                                        6
-#define PHY_BB_TEST_CONTROLS_CF_RFSHIFT_SEL_LSB                                                        5
-#define PHY_BB_TEST_CONTROLS_CF_RFSHIFT_SEL_MASK                                              0x00000060
-#define PHY_BB_TEST_CONTROLS_CF_RFSHIFT_SEL_GET(x)                             (((x) & 0x00000060) >> 5)
-#define PHY_BB_TEST_CONTROLS_CF_RFSHIFT_SEL_SET(x)                             (((x) << 5) & 0x00000060)
-#define PHY_BB_TEST_CONTROLS_CARDBUS_MODE_MSB                                                          9
-#define PHY_BB_TEST_CONTROLS_CARDBUS_MODE_LSB                                                          8
-#define PHY_BB_TEST_CONTROLS_CARDBUS_MODE_MASK                                                0x00000300
-#define PHY_BB_TEST_CONTROLS_CARDBUS_MODE_GET(x)                               (((x) & 0x00000300) >> 8)
-#define PHY_BB_TEST_CONTROLS_CARDBUS_MODE_SET(x)                               (((x) << 8) & 0x00000300)
-#define PHY_BB_TEST_CONTROLS_CLKOUT_IS_CLK32_MSB                                                      10
-#define PHY_BB_TEST_CONTROLS_CLKOUT_IS_CLK32_LSB                                                      10
-#define PHY_BB_TEST_CONTROLS_CLKOUT_IS_CLK32_MASK                                             0x00000400
-#define PHY_BB_TEST_CONTROLS_CLKOUT_IS_CLK32_GET(x)                           (((x) & 0x00000400) >> 10)
-#define PHY_BB_TEST_CONTROLS_CLKOUT_IS_CLK32_SET(x)                           (((x) << 10) & 0x00000400)
-#define PHY_BB_TEST_CONTROLS_ENABLE_RFSILENT_BB_MSB                                                   13
-#define PHY_BB_TEST_CONTROLS_ENABLE_RFSILENT_BB_LSB                                                   13
-#define PHY_BB_TEST_CONTROLS_ENABLE_RFSILENT_BB_MASK                                          0x00002000
-#define PHY_BB_TEST_CONTROLS_ENABLE_RFSILENT_BB_GET(x)                        (((x) & 0x00002000) >> 13)
-#define PHY_BB_TEST_CONTROLS_ENABLE_RFSILENT_BB_SET(x)                        (((x) << 13) & 0x00002000)
-#define PHY_BB_TEST_CONTROLS_ENABLE_MINI_OBS_MSB                                                      15
-#define PHY_BB_TEST_CONTROLS_ENABLE_MINI_OBS_LSB                                                      15
-#define PHY_BB_TEST_CONTROLS_ENABLE_MINI_OBS_MASK                                             0x00008000
-#define PHY_BB_TEST_CONTROLS_ENABLE_MINI_OBS_GET(x)                           (((x) & 0x00008000) >> 15)
-#define PHY_BB_TEST_CONTROLS_ENABLE_MINI_OBS_SET(x)                           (((x) << 15) & 0x00008000)
-#define PHY_BB_TEST_CONTROLS_SLOW_CLK160_MSB                                                          17
-#define PHY_BB_TEST_CONTROLS_SLOW_CLK160_LSB                                                          17
-#define PHY_BB_TEST_CONTROLS_SLOW_CLK160_MASK                                                 0x00020000
-#define PHY_BB_TEST_CONTROLS_SLOW_CLK160_GET(x)                               (((x) & 0x00020000) >> 17)
-#define PHY_BB_TEST_CONTROLS_SLOW_CLK160_SET(x)                               (((x) << 17) & 0x00020000)
-#define PHY_BB_TEST_CONTROLS_AGC_OBS_SEL_3_MSB                                                        18
-#define PHY_BB_TEST_CONTROLS_AGC_OBS_SEL_3_LSB                                                        18
-#define PHY_BB_TEST_CONTROLS_AGC_OBS_SEL_3_MASK                                               0x00040000
-#define PHY_BB_TEST_CONTROLS_AGC_OBS_SEL_3_GET(x)                             (((x) & 0x00040000) >> 18)
-#define PHY_BB_TEST_CONTROLS_AGC_OBS_SEL_3_SET(x)                             (((x) << 18) & 0x00040000)
-#define PHY_BB_TEST_CONTROLS_CF_BBB_OBS_SEL_MSB                                                       22
-#define PHY_BB_TEST_CONTROLS_CF_BBB_OBS_SEL_LSB                                                       19
-#define PHY_BB_TEST_CONTROLS_CF_BBB_OBS_SEL_MASK                                              0x00780000
-#define PHY_BB_TEST_CONTROLS_CF_BBB_OBS_SEL_GET(x)                            (((x) & 0x00780000) >> 19)
-#define PHY_BB_TEST_CONTROLS_CF_BBB_OBS_SEL_SET(x)                            (((x) << 19) & 0x00780000)
-#define PHY_BB_TEST_CONTROLS_RX_OBS_SEL_5TH_BIT_MSB                                                   23
-#define PHY_BB_TEST_CONTROLS_RX_OBS_SEL_5TH_BIT_LSB                                                   23
-#define PHY_BB_TEST_CONTROLS_RX_OBS_SEL_5TH_BIT_MASK                                          0x00800000
-#define PHY_BB_TEST_CONTROLS_RX_OBS_SEL_5TH_BIT_GET(x)                        (((x) & 0x00800000) >> 23)
-#define PHY_BB_TEST_CONTROLS_RX_OBS_SEL_5TH_BIT_SET(x)                        (((x) << 23) & 0x00800000)
-#define PHY_BB_TEST_CONTROLS_AGC_OBS_SEL_4_MSB                                                        24
-#define PHY_BB_TEST_CONTROLS_AGC_OBS_SEL_4_LSB                                                        24
-#define PHY_BB_TEST_CONTROLS_AGC_OBS_SEL_4_MASK                                               0x01000000
-#define PHY_BB_TEST_CONTROLS_AGC_OBS_SEL_4_GET(x)                             (((x) & 0x01000000) >> 24)
-#define PHY_BB_TEST_CONTROLS_AGC_OBS_SEL_4_SET(x)                             (((x) << 24) & 0x01000000)
-#define PHY_BB_TEST_CONTROLS_FORCE_AGC_CLEAR_MSB                                                      28
-#define PHY_BB_TEST_CONTROLS_FORCE_AGC_CLEAR_LSB                                                      28
-#define PHY_BB_TEST_CONTROLS_FORCE_AGC_CLEAR_MASK                                             0x10000000
-#define PHY_BB_TEST_CONTROLS_FORCE_AGC_CLEAR_GET(x)                           (((x) & 0x10000000) >> 28)
-#define PHY_BB_TEST_CONTROLS_FORCE_AGC_CLEAR_SET(x)                           (((x) << 28) & 0x10000000)
-#define PHY_BB_TEST_CONTROLS_TSTDAC_OUT_SEL_MSB                                                       31
-#define PHY_BB_TEST_CONTROLS_TSTDAC_OUT_SEL_LSB                                                       30
-#define PHY_BB_TEST_CONTROLS_TSTDAC_OUT_SEL_MASK                                              0xc0000000
-#define PHY_BB_TEST_CONTROLS_TSTDAC_OUT_SEL_GET(x)                            (((x) & 0xc0000000) >> 30)
-#define PHY_BB_TEST_CONTROLS_TSTDAC_OUT_SEL_SET(x)                            (((x) << 30) & 0xc0000000)
-
-/* macros for BB_gen_controls */
-#define PHY_BB_GEN_CONTROLS_ADDRESS                                                           0x00009804
-#define PHY_BB_GEN_CONTROLS_OFFSET                                                            0x00009804
-#define PHY_BB_GEN_CONTROLS_TURBO_MSB                                                                  0
-#define PHY_BB_GEN_CONTROLS_TURBO_LSB                                                                  0
-#define PHY_BB_GEN_CONTROLS_TURBO_MASK                                                        0x00000001
-#define PHY_BB_GEN_CONTROLS_TURBO_GET(x)                                       (((x) & 0x00000001) >> 0)
-#define PHY_BB_GEN_CONTROLS_TURBO_SET(x)                                       (((x) << 0) & 0x00000001)
-#define PHY_BB_GEN_CONTROLS_CF_SHORT20_MSB                                                             1
-#define PHY_BB_GEN_CONTROLS_CF_SHORT20_LSB                                                             1
-#define PHY_BB_GEN_CONTROLS_CF_SHORT20_MASK                                                   0x00000002
-#define PHY_BB_GEN_CONTROLS_CF_SHORT20_GET(x)                                  (((x) & 0x00000002) >> 1)
-#define PHY_BB_GEN_CONTROLS_CF_SHORT20_SET(x)                                  (((x) << 1) & 0x00000002)
-#define PHY_BB_GEN_CONTROLS_DYN_20_40_MSB                                                              2
-#define PHY_BB_GEN_CONTROLS_DYN_20_40_LSB                                                              2
-#define PHY_BB_GEN_CONTROLS_DYN_20_40_MASK                                                    0x00000004
-#define PHY_BB_GEN_CONTROLS_DYN_20_40_GET(x)                                   (((x) & 0x00000004) >> 2)
-#define PHY_BB_GEN_CONTROLS_DYN_20_40_SET(x)                                   (((x) << 2) & 0x00000004)
-#define PHY_BB_GEN_CONTROLS_DYN_20_40_PRI_ONLY_MSB                                                     3
-#define PHY_BB_GEN_CONTROLS_DYN_20_40_PRI_ONLY_LSB                                                     3
-#define PHY_BB_GEN_CONTROLS_DYN_20_40_PRI_ONLY_MASK                                           0x00000008
-#define PHY_BB_GEN_CONTROLS_DYN_20_40_PRI_ONLY_GET(x)                          (((x) & 0x00000008) >> 3)
-#define PHY_BB_GEN_CONTROLS_DYN_20_40_PRI_ONLY_SET(x)                          (((x) << 3) & 0x00000008)
-#define PHY_BB_GEN_CONTROLS_DYN_20_40_PRI_CHN_MSB                                                      4
-#define PHY_BB_GEN_CONTROLS_DYN_20_40_PRI_CHN_LSB                                                      4
-#define PHY_BB_GEN_CONTROLS_DYN_20_40_PRI_CHN_MASK                                            0x00000010
-#define PHY_BB_GEN_CONTROLS_DYN_20_40_PRI_CHN_GET(x)                           (((x) & 0x00000010) >> 4)
-#define PHY_BB_GEN_CONTROLS_DYN_20_40_PRI_CHN_SET(x)                           (((x) << 4) & 0x00000010)
-#define PHY_BB_GEN_CONTROLS_DYN_20_40_EXT_CHN_MSB                                                      5
-#define PHY_BB_GEN_CONTROLS_DYN_20_40_EXT_CHN_LSB                                                      5
-#define PHY_BB_GEN_CONTROLS_DYN_20_40_EXT_CHN_MASK                                            0x00000020
-#define PHY_BB_GEN_CONTROLS_DYN_20_40_EXT_CHN_GET(x)                           (((x) & 0x00000020) >> 5)
-#define PHY_BB_GEN_CONTROLS_DYN_20_40_EXT_CHN_SET(x)                           (((x) << 5) & 0x00000020)
-#define PHY_BB_GEN_CONTROLS_HT_ENABLE_MSB                                                              6
-#define PHY_BB_GEN_CONTROLS_HT_ENABLE_LSB                                                              6
-#define PHY_BB_GEN_CONTROLS_HT_ENABLE_MASK                                                    0x00000040
-#define PHY_BB_GEN_CONTROLS_HT_ENABLE_GET(x)                                   (((x) & 0x00000040) >> 6)
-#define PHY_BB_GEN_CONTROLS_HT_ENABLE_SET(x)                                   (((x) << 6) & 0x00000040)
-#define PHY_BB_GEN_CONTROLS_ALLOW_SHORT_GI_MSB                                                         7
-#define PHY_BB_GEN_CONTROLS_ALLOW_SHORT_GI_LSB                                                         7
-#define PHY_BB_GEN_CONTROLS_ALLOW_SHORT_GI_MASK                                               0x00000080
-#define PHY_BB_GEN_CONTROLS_ALLOW_SHORT_GI_GET(x)                              (((x) & 0x00000080) >> 7)
-#define PHY_BB_GEN_CONTROLS_ALLOW_SHORT_GI_SET(x)                              (((x) << 7) & 0x00000080)
-#define PHY_BB_GEN_CONTROLS_CF_2_CHAINS_USE_WALSH_MSB                                                  8
-#define PHY_BB_GEN_CONTROLS_CF_2_CHAINS_USE_WALSH_LSB                                                  8
-#define PHY_BB_GEN_CONTROLS_CF_2_CHAINS_USE_WALSH_MASK                                        0x00000100
-#define PHY_BB_GEN_CONTROLS_CF_2_CHAINS_USE_WALSH_GET(x)                       (((x) & 0x00000100) >> 8)
-#define PHY_BB_GEN_CONTROLS_CF_2_CHAINS_USE_WALSH_SET(x)                       (((x) << 8) & 0x00000100)
-#define PHY_BB_GEN_CONTROLS_CF_SINGLE_HT_LTF1_MSB                                                      9
-#define PHY_BB_GEN_CONTROLS_CF_SINGLE_HT_LTF1_LSB                                                      9
-#define PHY_BB_GEN_CONTROLS_CF_SINGLE_HT_LTF1_MASK                                            0x00000200
-#define PHY_BB_GEN_CONTROLS_CF_SINGLE_HT_LTF1_GET(x)                           (((x) & 0x00000200) >> 9)
-#define PHY_BB_GEN_CONTROLS_CF_SINGLE_HT_LTF1_SET(x)                           (((x) << 9) & 0x00000200)
-#define PHY_BB_GEN_CONTROLS_GF_ENABLE_MSB                                                             10
-#define PHY_BB_GEN_CONTROLS_GF_ENABLE_LSB                                                             10
-#define PHY_BB_GEN_CONTROLS_GF_ENABLE_MASK                                                    0x00000400
-#define PHY_BB_GEN_CONTROLS_GF_ENABLE_GET(x)                                  (((x) & 0x00000400) >> 10)
-#define PHY_BB_GEN_CONTROLS_GF_ENABLE_SET(x)                                  (((x) << 10) & 0x00000400)
-#define PHY_BB_GEN_CONTROLS_BYPASS_DAC_FIFO_N_MSB                                                     11
-#define PHY_BB_GEN_CONTROLS_BYPASS_DAC_FIFO_N_LSB                                                     11
-#define PHY_BB_GEN_CONTROLS_BYPASS_DAC_FIFO_N_MASK                                            0x00000800
-#define PHY_BB_GEN_CONTROLS_BYPASS_DAC_FIFO_N_GET(x)                          (((x) & 0x00000800) >> 11)
-#define PHY_BB_GEN_CONTROLS_BYPASS_DAC_FIFO_N_SET(x)                          (((x) << 11) & 0x00000800)
-
-/* macros for BB_test_controls_status */
-#define PHY_BB_TEST_CONTROLS_STATUS_ADDRESS                                                   0x00009808
-#define PHY_BB_TEST_CONTROLS_STATUS_OFFSET                                                    0x00009808
-#define PHY_BB_TEST_CONTROLS_STATUS_CF_TSTDAC_EN_MSB                                                   0
-#define PHY_BB_TEST_CONTROLS_STATUS_CF_TSTDAC_EN_LSB                                                   0
-#define PHY_BB_TEST_CONTROLS_STATUS_CF_TSTDAC_EN_MASK                                         0x00000001
-#define PHY_BB_TEST_CONTROLS_STATUS_CF_TSTDAC_EN_GET(x)                        (((x) & 0x00000001) >> 0)
-#define PHY_BB_TEST_CONTROLS_STATUS_CF_TSTDAC_EN_SET(x)                        (((x) << 0) & 0x00000001)
-#define PHY_BB_TEST_CONTROLS_STATUS_CF_TX_SRC_IS_TSTDAC_MSB                                            1
-#define PHY_BB_TEST_CONTROLS_STATUS_CF_TX_SRC_IS_TSTDAC_LSB                                            1
-#define PHY_BB_TEST_CONTROLS_STATUS_CF_TX_SRC_IS_TSTDAC_MASK                                  0x00000002
-#define PHY_BB_TEST_CONTROLS_STATUS_CF_TX_SRC_IS_TSTDAC_GET(x)                 (((x) & 0x00000002) >> 1)
-#define PHY_BB_TEST_CONTROLS_STATUS_CF_TX_SRC_IS_TSTDAC_SET(x)                 (((x) << 1) & 0x00000002)
-#define PHY_BB_TEST_CONTROLS_STATUS_CF_TX_OBS_SEL_MSB                                                  4
-#define PHY_BB_TEST_CONTROLS_STATUS_CF_TX_OBS_SEL_LSB                                                  2
-#define PHY_BB_TEST_CONTROLS_STATUS_CF_TX_OBS_SEL_MASK                                        0x0000001c
-#define PHY_BB_TEST_CONTROLS_STATUS_CF_TX_OBS_SEL_GET(x)                       (((x) & 0x0000001c) >> 2)
-#define PHY_BB_TEST_CONTROLS_STATUS_CF_TX_OBS_SEL_SET(x)                       (((x) << 2) & 0x0000001c)
-#define PHY_BB_TEST_CONTROLS_STATUS_CF_TX_OBS_MUX_SEL_MSB                                              6
-#define PHY_BB_TEST_CONTROLS_STATUS_CF_TX_OBS_MUX_SEL_LSB                                              5
-#define PHY_BB_TEST_CONTROLS_STATUS_CF_TX_OBS_MUX_SEL_MASK                                    0x00000060
-#define PHY_BB_TEST_CONTROLS_STATUS_CF_TX_OBS_MUX_SEL_GET(x)                   (((x) & 0x00000060) >> 5)
-#define PHY_BB_TEST_CONTROLS_STATUS_CF_TX_OBS_MUX_SEL_SET(x)                   (((x) << 5) & 0x00000060)
-#define PHY_BB_TEST_CONTROLS_STATUS_CF_TX_SRC_ALTERNATE_MSB                                            7
-#define PHY_BB_TEST_CONTROLS_STATUS_CF_TX_SRC_ALTERNATE_LSB                                            7
-#define PHY_BB_TEST_CONTROLS_STATUS_CF_TX_SRC_ALTERNATE_MASK                                  0x00000080
-#define PHY_BB_TEST_CONTROLS_STATUS_CF_TX_SRC_ALTERNATE_GET(x)                 (((x) & 0x00000080) >> 7)
-#define PHY_BB_TEST_CONTROLS_STATUS_CF_TX_SRC_ALTERNATE_SET(x)                 (((x) << 7) & 0x00000080)
-#define PHY_BB_TEST_CONTROLS_STATUS_CF_TSTADC_EN_MSB                                                   8
-#define PHY_BB_TEST_CONTROLS_STATUS_CF_TSTADC_EN_LSB                                                   8
-#define PHY_BB_TEST_CONTROLS_STATUS_CF_TSTADC_EN_MASK                                         0x00000100
-#define PHY_BB_TEST_CONTROLS_STATUS_CF_TSTADC_EN_GET(x)                        (((x) & 0x00000100) >> 8)
-#define PHY_BB_TEST_CONTROLS_STATUS_CF_TSTADC_EN_SET(x)                        (((x) << 8) & 0x00000100)
-#define PHY_BB_TEST_CONTROLS_STATUS_CF_RX_SRC_IS_TSTADC_MSB                                            9
-#define PHY_BB_TEST_CONTROLS_STATUS_CF_RX_SRC_IS_TSTADC_LSB                                            9
-#define PHY_BB_TEST_CONTROLS_STATUS_CF_RX_SRC_IS_TSTADC_MASK                                  0x00000200
-#define PHY_BB_TEST_CONTROLS_STATUS_CF_RX_SRC_IS_TSTADC_GET(x)                 (((x) & 0x00000200) >> 9)
-#define PHY_BB_TEST_CONTROLS_STATUS_CF_RX_SRC_IS_TSTADC_SET(x)                 (((x) << 9) & 0x00000200)
-#define PHY_BB_TEST_CONTROLS_STATUS_RX_OBS_SEL_MSB                                                    13
-#define PHY_BB_TEST_CONTROLS_STATUS_RX_OBS_SEL_LSB                                                    10
-#define PHY_BB_TEST_CONTROLS_STATUS_RX_OBS_SEL_MASK                                           0x00003c00
-#define PHY_BB_TEST_CONTROLS_STATUS_RX_OBS_SEL_GET(x)                         (((x) & 0x00003c00) >> 10)
-#define PHY_BB_TEST_CONTROLS_STATUS_RX_OBS_SEL_SET(x)                         (((x) << 10) & 0x00003c00)
-#define PHY_BB_TEST_CONTROLS_STATUS_DISABLE_A2_WARM_RESET_MSB                                         14
-#define PHY_BB_TEST_CONTROLS_STATUS_DISABLE_A2_WARM_RESET_LSB                                         14
-#define PHY_BB_TEST_CONTROLS_STATUS_DISABLE_A2_WARM_RESET_MASK                                0x00004000
-#define PHY_BB_TEST_CONTROLS_STATUS_DISABLE_A2_WARM_RESET_GET(x)              (((x) & 0x00004000) >> 14)
-#define PHY_BB_TEST_CONTROLS_STATUS_DISABLE_A2_WARM_RESET_SET(x)              (((x) << 14) & 0x00004000)
-#define PHY_BB_TEST_CONTROLS_STATUS_RESET_A2_MSB                                                      15
-#define PHY_BB_TEST_CONTROLS_STATUS_RESET_A2_LSB                                                      15
-#define PHY_BB_TEST_CONTROLS_STATUS_RESET_A2_MASK                                             0x00008000
-#define PHY_BB_TEST_CONTROLS_STATUS_RESET_A2_GET(x)                           (((x) & 0x00008000) >> 15)
-#define PHY_BB_TEST_CONTROLS_STATUS_RESET_A2_SET(x)                           (((x) << 15) & 0x00008000)
-#define PHY_BB_TEST_CONTROLS_STATUS_AGC_OBS_SEL_MSB                                                   18
-#define PHY_BB_TEST_CONTROLS_STATUS_AGC_OBS_SEL_LSB                                                   16
-#define PHY_BB_TEST_CONTROLS_STATUS_AGC_OBS_SEL_MASK                                          0x00070000
-#define PHY_BB_TEST_CONTROLS_STATUS_AGC_OBS_SEL_GET(x)                        (((x) & 0x00070000) >> 16)
-#define PHY_BB_TEST_CONTROLS_STATUS_AGC_OBS_SEL_SET(x)                        (((x) << 16) & 0x00070000)
-#define PHY_BB_TEST_CONTROLS_STATUS_CF_ENABLE_FFT_DUMP_MSB                                            19
-#define PHY_BB_TEST_CONTROLS_STATUS_CF_ENABLE_FFT_DUMP_LSB                                            19
-#define PHY_BB_TEST_CONTROLS_STATUS_CF_ENABLE_FFT_DUMP_MASK                                   0x00080000
-#define PHY_BB_TEST_CONTROLS_STATUS_CF_ENABLE_FFT_DUMP_GET(x)                 (((x) & 0x00080000) >> 19)
-#define PHY_BB_TEST_CONTROLS_STATUS_CF_ENABLE_FFT_DUMP_SET(x)                 (((x) << 19) & 0x00080000)
-#define PHY_BB_TEST_CONTROLS_STATUS_CF_DEBUGPORT_IN_MSB                                               23
-#define PHY_BB_TEST_CONTROLS_STATUS_CF_DEBUGPORT_IN_LSB                                               23
-#define PHY_BB_TEST_CONTROLS_STATUS_CF_DEBUGPORT_IN_MASK                                      0x00800000
-#define PHY_BB_TEST_CONTROLS_STATUS_CF_DEBUGPORT_IN_GET(x)                    (((x) & 0x00800000) >> 23)
-#define PHY_BB_TEST_CONTROLS_STATUS_CF_DEBUGPORT_IN_SET(x)                    (((x) << 23) & 0x00800000)
-#define PHY_BB_TEST_CONTROLS_STATUS_DISABLE_AGC_TO_A2_MSB                                             27
-#define PHY_BB_TEST_CONTROLS_STATUS_DISABLE_AGC_TO_A2_LSB                                             27
-#define PHY_BB_TEST_CONTROLS_STATUS_DISABLE_AGC_TO_A2_MASK                                    0x08000000
-#define PHY_BB_TEST_CONTROLS_STATUS_DISABLE_AGC_TO_A2_GET(x)                  (((x) & 0x08000000) >> 27)
-#define PHY_BB_TEST_CONTROLS_STATUS_DISABLE_AGC_TO_A2_SET(x)                  (((x) << 27) & 0x08000000)
-#define PHY_BB_TEST_CONTROLS_STATUS_CF_DEBUGPORT_EN_MSB                                               28
-#define PHY_BB_TEST_CONTROLS_STATUS_CF_DEBUGPORT_EN_LSB                                               28
-#define PHY_BB_TEST_CONTROLS_STATUS_CF_DEBUGPORT_EN_MASK                                      0x10000000
-#define PHY_BB_TEST_CONTROLS_STATUS_CF_DEBUGPORT_EN_GET(x)                    (((x) & 0x10000000) >> 28)
-#define PHY_BB_TEST_CONTROLS_STATUS_CF_DEBUGPORT_EN_SET(x)                    (((x) << 28) & 0x10000000)
-#define PHY_BB_TEST_CONTROLS_STATUS_CF_DEBUGPORT_SEL_MSB                                              30
-#define PHY_BB_TEST_CONTROLS_STATUS_CF_DEBUGPORT_SEL_LSB                                              29
-#define PHY_BB_TEST_CONTROLS_STATUS_CF_DEBUGPORT_SEL_MASK                                     0x60000000
-#define PHY_BB_TEST_CONTROLS_STATUS_CF_DEBUGPORT_SEL_GET(x)                   (((x) & 0x60000000) >> 29)
-#define PHY_BB_TEST_CONTROLS_STATUS_CF_DEBUGPORT_SEL_SET(x)                   (((x) << 29) & 0x60000000)
-
-/* macros for BB_timing_controls_1 */
-#define PHY_BB_TIMING_CONTROLS_1_ADDRESS                                                      0x0000980c
-#define PHY_BB_TIMING_CONTROLS_1_OFFSET                                                       0x0000980c
-#define PHY_BB_TIMING_CONTROLS_1_STE_THR_MSB                                                           6
-#define PHY_BB_TIMING_CONTROLS_1_STE_THR_LSB                                                           0
-#define PHY_BB_TIMING_CONTROLS_1_STE_THR_MASK                                                 0x0000007f
-#define PHY_BB_TIMING_CONTROLS_1_STE_THR_GET(x)                                (((x) & 0x0000007f) >> 0)
-#define PHY_BB_TIMING_CONTROLS_1_STE_THR_SET(x)                                (((x) << 0) & 0x0000007f)
-#define PHY_BB_TIMING_CONTROLS_1_STE_TO_LONG1_MSB                                                     12
-#define PHY_BB_TIMING_CONTROLS_1_STE_TO_LONG1_LSB                                                      7
-#define PHY_BB_TIMING_CONTROLS_1_STE_TO_LONG1_MASK                                            0x00001f80
-#define PHY_BB_TIMING_CONTROLS_1_STE_TO_LONG1_GET(x)                           (((x) & 0x00001f80) >> 7)
-#define PHY_BB_TIMING_CONTROLS_1_STE_TO_LONG1_SET(x)                           (((x) << 7) & 0x00001f80)
-#define PHY_BB_TIMING_CONTROLS_1_TIMING_BACKOFF_MSB                                                   16
-#define PHY_BB_TIMING_CONTROLS_1_TIMING_BACKOFF_LSB                                                   13
-#define PHY_BB_TIMING_CONTROLS_1_TIMING_BACKOFF_MASK                                          0x0001e000
-#define PHY_BB_TIMING_CONTROLS_1_TIMING_BACKOFF_GET(x)                        (((x) & 0x0001e000) >> 13)
-#define PHY_BB_TIMING_CONTROLS_1_TIMING_BACKOFF_SET(x)                        (((x) << 13) & 0x0001e000)
-#define PHY_BB_TIMING_CONTROLS_1_ENABLE_HT_FINE_PPM_MSB                                               17
-#define PHY_BB_TIMING_CONTROLS_1_ENABLE_HT_FINE_PPM_LSB                                               17
-#define PHY_BB_TIMING_CONTROLS_1_ENABLE_HT_FINE_PPM_MASK                                      0x00020000
-#define PHY_BB_TIMING_CONTROLS_1_ENABLE_HT_FINE_PPM_GET(x)                    (((x) & 0x00020000) >> 17)
-#define PHY_BB_TIMING_CONTROLS_1_ENABLE_HT_FINE_PPM_SET(x)                    (((x) << 17) & 0x00020000)
-#define PHY_BB_TIMING_CONTROLS_1_HT_FINE_PPM_STREAM_MSB                                               19
-#define PHY_BB_TIMING_CONTROLS_1_HT_FINE_PPM_STREAM_LSB                                               18
-#define PHY_BB_TIMING_CONTROLS_1_HT_FINE_PPM_STREAM_MASK                                      0x000c0000
-#define PHY_BB_TIMING_CONTROLS_1_HT_FINE_PPM_STREAM_GET(x)                    (((x) & 0x000c0000) >> 18)
-#define PHY_BB_TIMING_CONTROLS_1_HT_FINE_PPM_STREAM_SET(x)                    (((x) << 18) & 0x000c0000)
-#define PHY_BB_TIMING_CONTROLS_1_HT_FINE_PPM_QAM_MSB                                                  21
-#define PHY_BB_TIMING_CONTROLS_1_HT_FINE_PPM_QAM_LSB                                                  20
-#define PHY_BB_TIMING_CONTROLS_1_HT_FINE_PPM_QAM_MASK                                         0x00300000
-#define PHY_BB_TIMING_CONTROLS_1_HT_FINE_PPM_QAM_GET(x)                       (((x) & 0x00300000) >> 20)
-#define PHY_BB_TIMING_CONTROLS_1_HT_FINE_PPM_QAM_SET(x)                       (((x) << 20) & 0x00300000)
-#define PHY_BB_TIMING_CONTROLS_1_ENABLE_LONG_CHANFIL_MSB                                              22
-#define PHY_BB_TIMING_CONTROLS_1_ENABLE_LONG_CHANFIL_LSB                                              22
-#define PHY_BB_TIMING_CONTROLS_1_ENABLE_LONG_CHANFIL_MASK                                     0x00400000
-#define PHY_BB_TIMING_CONTROLS_1_ENABLE_LONG_CHANFIL_GET(x)                   (((x) & 0x00400000) >> 22)
-#define PHY_BB_TIMING_CONTROLS_1_ENABLE_LONG_CHANFIL_SET(x)                   (((x) << 22) & 0x00400000)
-#define PHY_BB_TIMING_CONTROLS_1_ENABLE_RX_STBC_MSB                                                   23
-#define PHY_BB_TIMING_CONTROLS_1_ENABLE_RX_STBC_LSB                                                   23
-#define PHY_BB_TIMING_CONTROLS_1_ENABLE_RX_STBC_MASK                                          0x00800000
-#define PHY_BB_TIMING_CONTROLS_1_ENABLE_RX_STBC_GET(x)                        (((x) & 0x00800000) >> 23)
-#define PHY_BB_TIMING_CONTROLS_1_ENABLE_RX_STBC_SET(x)                        (((x) << 23) & 0x00800000)
-#define PHY_BB_TIMING_CONTROLS_1_ENABLE_CHANNEL_FILTER_MSB                                            24
-#define PHY_BB_TIMING_CONTROLS_1_ENABLE_CHANNEL_FILTER_LSB                                            24
-#define PHY_BB_TIMING_CONTROLS_1_ENABLE_CHANNEL_FILTER_MASK                                   0x01000000
-#define PHY_BB_TIMING_CONTROLS_1_ENABLE_CHANNEL_FILTER_GET(x)                 (((x) & 0x01000000) >> 24)
-#define PHY_BB_TIMING_CONTROLS_1_ENABLE_CHANNEL_FILTER_SET(x)                 (((x) << 24) & 0x01000000)
-#define PHY_BB_TIMING_CONTROLS_1_FALSE_ALARM_MSB                                                      26
-#define PHY_BB_TIMING_CONTROLS_1_FALSE_ALARM_LSB                                                      25
-#define PHY_BB_TIMING_CONTROLS_1_FALSE_ALARM_MASK                                             0x06000000
-#define PHY_BB_TIMING_CONTROLS_1_FALSE_ALARM_GET(x)                           (((x) & 0x06000000) >> 25)
-#define PHY_BB_TIMING_CONTROLS_1_FALSE_ALARM_SET(x)                           (((x) << 25) & 0x06000000)
-#define PHY_BB_TIMING_CONTROLS_1_ENABLE_LONG_RESCALE_MSB                                              27
-#define PHY_BB_TIMING_CONTROLS_1_ENABLE_LONG_RESCALE_LSB                                              27
-#define PHY_BB_TIMING_CONTROLS_1_ENABLE_LONG_RESCALE_MASK                                     0x08000000
-#define PHY_BB_TIMING_CONTROLS_1_ENABLE_LONG_RESCALE_GET(x)                   (((x) & 0x08000000) >> 27)
-#define PHY_BB_TIMING_CONTROLS_1_ENABLE_LONG_RESCALE_SET(x)                   (((x) << 27) & 0x08000000)
-#define PHY_BB_TIMING_CONTROLS_1_TIMING_LEAK_ENABLE_MSB                                               28
-#define PHY_BB_TIMING_CONTROLS_1_TIMING_LEAK_ENABLE_LSB                                               28
-#define PHY_BB_TIMING_CONTROLS_1_TIMING_LEAK_ENABLE_MASK                                      0x10000000
-#define PHY_BB_TIMING_CONTROLS_1_TIMING_LEAK_ENABLE_GET(x)                    (((x) & 0x10000000) >> 28)
-#define PHY_BB_TIMING_CONTROLS_1_TIMING_LEAK_ENABLE_SET(x)                    (((x) << 28) & 0x10000000)
-#define PHY_BB_TIMING_CONTROLS_1_COARSE_PPM_SELECT_MSB                                                30
-#define PHY_BB_TIMING_CONTROLS_1_COARSE_PPM_SELECT_LSB                                                29
-#define PHY_BB_TIMING_CONTROLS_1_COARSE_PPM_SELECT_MASK                                       0x60000000
-#define PHY_BB_TIMING_CONTROLS_1_COARSE_PPM_SELECT_GET(x)                     (((x) & 0x60000000) >> 29)
-#define PHY_BB_TIMING_CONTROLS_1_COARSE_PPM_SELECT_SET(x)                     (((x) << 29) & 0x60000000)
-#define PHY_BB_TIMING_CONTROLS_1_FFT_SCALING_MSB                                                      31
-#define PHY_BB_TIMING_CONTROLS_1_FFT_SCALING_LSB                                                      31
-#define PHY_BB_TIMING_CONTROLS_1_FFT_SCALING_MASK                                             0x80000000
-#define PHY_BB_TIMING_CONTROLS_1_FFT_SCALING_GET(x)                           (((x) & 0x80000000) >> 31)
-#define PHY_BB_TIMING_CONTROLS_1_FFT_SCALING_SET(x)                           (((x) << 31) & 0x80000000)
-
-/* macros for BB_timing_controls_2 */
-#define PHY_BB_TIMING_CONTROLS_2_ADDRESS                                                      0x00009810
-#define PHY_BB_TIMING_CONTROLS_2_OFFSET                                                       0x00009810
-#define PHY_BB_TIMING_CONTROLS_2_FORCED_DELTA_PHI_SYMBOL_MSB                                          11
-#define PHY_BB_TIMING_CONTROLS_2_FORCED_DELTA_PHI_SYMBOL_LSB                                           0
-#define PHY_BB_TIMING_CONTROLS_2_FORCED_DELTA_PHI_SYMBOL_MASK                                 0x00000fff
-#define PHY_BB_TIMING_CONTROLS_2_FORCED_DELTA_PHI_SYMBOL_GET(x)                (((x) & 0x00000fff) >> 0)
-#define PHY_BB_TIMING_CONTROLS_2_FORCED_DELTA_PHI_SYMBOL_SET(x)                (((x) << 0) & 0x00000fff)
-#define PHY_BB_TIMING_CONTROLS_2_FORCE_DELTA_PHI_SYMBOL_MSB                                           12
-#define PHY_BB_TIMING_CONTROLS_2_FORCE_DELTA_PHI_SYMBOL_LSB                                           12
-#define PHY_BB_TIMING_CONTROLS_2_FORCE_DELTA_PHI_SYMBOL_MASK                                  0x00001000
-#define PHY_BB_TIMING_CONTROLS_2_FORCE_DELTA_PHI_SYMBOL_GET(x)                (((x) & 0x00001000) >> 12)
-#define PHY_BB_TIMING_CONTROLS_2_FORCE_DELTA_PHI_SYMBOL_SET(x)                (((x) << 12) & 0x00001000)
-#define PHY_BB_TIMING_CONTROLS_2_ENABLE_MAGNITUDE_TRACK_MSB                                           13
-#define PHY_BB_TIMING_CONTROLS_2_ENABLE_MAGNITUDE_TRACK_LSB                                           13
-#define PHY_BB_TIMING_CONTROLS_2_ENABLE_MAGNITUDE_TRACK_MASK                                  0x00002000
-#define PHY_BB_TIMING_CONTROLS_2_ENABLE_MAGNITUDE_TRACK_GET(x)                (((x) & 0x00002000) >> 13)
-#define PHY_BB_TIMING_CONTROLS_2_ENABLE_MAGNITUDE_TRACK_SET(x)                (((x) << 13) & 0x00002000)
-#define PHY_BB_TIMING_CONTROLS_2_ENABLE_SLOPE_FILTER_MSB                                              14
-#define PHY_BB_TIMING_CONTROLS_2_ENABLE_SLOPE_FILTER_LSB                                              14
-#define PHY_BB_TIMING_CONTROLS_2_ENABLE_SLOPE_FILTER_MASK                                     0x00004000
-#define PHY_BB_TIMING_CONTROLS_2_ENABLE_SLOPE_FILTER_GET(x)                   (((x) & 0x00004000) >> 14)
-#define PHY_BB_TIMING_CONTROLS_2_ENABLE_SLOPE_FILTER_SET(x)                   (((x) << 14) & 0x00004000)
-#define PHY_BB_TIMING_CONTROLS_2_ENABLE_OFFSET_FILTER_MSB                                             15
-#define PHY_BB_TIMING_CONTROLS_2_ENABLE_OFFSET_FILTER_LSB                                             15
-#define PHY_BB_TIMING_CONTROLS_2_ENABLE_OFFSET_FILTER_MASK                                    0x00008000
-#define PHY_BB_TIMING_CONTROLS_2_ENABLE_OFFSET_FILTER_GET(x)                  (((x) & 0x00008000) >> 15)
-#define PHY_BB_TIMING_CONTROLS_2_ENABLE_OFFSET_FILTER_SET(x)                  (((x) << 15) & 0x00008000)
-#define PHY_BB_TIMING_CONTROLS_2_DC_OFF_DELTAF_THRES_MSB                                              22
-#define PHY_BB_TIMING_CONTROLS_2_DC_OFF_DELTAF_THRES_LSB                                              16
-#define PHY_BB_TIMING_CONTROLS_2_DC_OFF_DELTAF_THRES_MASK                                     0x007f0000
-#define PHY_BB_TIMING_CONTROLS_2_DC_OFF_DELTAF_THRES_GET(x)                   (((x) & 0x007f0000) >> 16)
-#define PHY_BB_TIMING_CONTROLS_2_DC_OFF_DELTAF_THRES_SET(x)                   (((x) << 16) & 0x007f0000)
-#define PHY_BB_TIMING_CONTROLS_2_DC_OFF_TIM_CONST_MSB                                                 26
-#define PHY_BB_TIMING_CONTROLS_2_DC_OFF_TIM_CONST_LSB                                                 24
-#define PHY_BB_TIMING_CONTROLS_2_DC_OFF_TIM_CONST_MASK                                        0x07000000
-#define PHY_BB_TIMING_CONTROLS_2_DC_OFF_TIM_CONST_GET(x)                      (((x) & 0x07000000) >> 24)
-#define PHY_BB_TIMING_CONTROLS_2_DC_OFF_TIM_CONST_SET(x)                      (((x) << 24) & 0x07000000)
-#define PHY_BB_TIMING_CONTROLS_2_ENABLE_DC_OFFSET_MSB                                                 27
-#define PHY_BB_TIMING_CONTROLS_2_ENABLE_DC_OFFSET_LSB                                                 27
-#define PHY_BB_TIMING_CONTROLS_2_ENABLE_DC_OFFSET_MASK                                        0x08000000
-#define PHY_BB_TIMING_CONTROLS_2_ENABLE_DC_OFFSET_GET(x)                      (((x) & 0x08000000) >> 27)
-#define PHY_BB_TIMING_CONTROLS_2_ENABLE_DC_OFFSET_SET(x)                      (((x) << 27) & 0x08000000)
-#define PHY_BB_TIMING_CONTROLS_2_ENABLE_DC_OFFSET_TRACK_MSB                                           28
-#define PHY_BB_TIMING_CONTROLS_2_ENABLE_DC_OFFSET_TRACK_LSB                                           28
-#define PHY_BB_TIMING_CONTROLS_2_ENABLE_DC_OFFSET_TRACK_MASK                                  0x10000000
-#define PHY_BB_TIMING_CONTROLS_2_ENABLE_DC_OFFSET_TRACK_GET(x)                (((x) & 0x10000000) >> 28)
-#define PHY_BB_TIMING_CONTROLS_2_ENABLE_DC_OFFSET_TRACK_SET(x)                (((x) << 28) & 0x10000000)
-#define PHY_BB_TIMING_CONTROLS_2_ENABLE_WEIGHTING_MSB                                                 29
-#define PHY_BB_TIMING_CONTROLS_2_ENABLE_WEIGHTING_LSB                                                 29
-#define PHY_BB_TIMING_CONTROLS_2_ENABLE_WEIGHTING_MASK                                        0x20000000
-#define PHY_BB_TIMING_CONTROLS_2_ENABLE_WEIGHTING_GET(x)                      (((x) & 0x20000000) >> 29)
-#define PHY_BB_TIMING_CONTROLS_2_ENABLE_WEIGHTING_SET(x)                      (((x) << 29) & 0x20000000)
-#define PHY_BB_TIMING_CONTROLS_2_TRACEBACK128_MSB                                                     30
-#define PHY_BB_TIMING_CONTROLS_2_TRACEBACK128_LSB                                                     30
-#define PHY_BB_TIMING_CONTROLS_2_TRACEBACK128_MASK                                            0x40000000
-#define PHY_BB_TIMING_CONTROLS_2_TRACEBACK128_GET(x)                          (((x) & 0x40000000) >> 30)
-#define PHY_BB_TIMING_CONTROLS_2_TRACEBACK128_SET(x)                          (((x) << 30) & 0x40000000)
-#define PHY_BB_TIMING_CONTROLS_2_ENABLE_HT_FINE_TIMING_MSB                                            31
-#define PHY_BB_TIMING_CONTROLS_2_ENABLE_HT_FINE_TIMING_LSB                                            31
-#define PHY_BB_TIMING_CONTROLS_2_ENABLE_HT_FINE_TIMING_MASK                                   0x80000000
-#define PHY_BB_TIMING_CONTROLS_2_ENABLE_HT_FINE_TIMING_GET(x)                 (((x) & 0x80000000) >> 31)
-#define PHY_BB_TIMING_CONTROLS_2_ENABLE_HT_FINE_TIMING_SET(x)                 (((x) << 31) & 0x80000000)
-
-/* macros for BB_timing_controls_3 */
-#define PHY_BB_TIMING_CONTROLS_3_ADDRESS                                                      0x00009814
-#define PHY_BB_TIMING_CONTROLS_3_OFFSET                                                       0x00009814
-#define PHY_BB_TIMING_CONTROLS_3_PPM_RESCUE_INTERVAL_MSB                                               7
-#define PHY_BB_TIMING_CONTROLS_3_PPM_RESCUE_INTERVAL_LSB                                               0
-#define PHY_BB_TIMING_CONTROLS_3_PPM_RESCUE_INTERVAL_MASK                                     0x000000ff
-#define PHY_BB_TIMING_CONTROLS_3_PPM_RESCUE_INTERVAL_GET(x)                    (((x) & 0x000000ff) >> 0)
-#define PHY_BB_TIMING_CONTROLS_3_PPM_RESCUE_INTERVAL_SET(x)                    (((x) << 0) & 0x000000ff)
-#define PHY_BB_TIMING_CONTROLS_3_ENABLE_PPM_RESCUE_MSB                                                 8
-#define PHY_BB_TIMING_CONTROLS_3_ENABLE_PPM_RESCUE_LSB                                                 8
-#define PHY_BB_TIMING_CONTROLS_3_ENABLE_PPM_RESCUE_MASK                                       0x00000100
-#define PHY_BB_TIMING_CONTROLS_3_ENABLE_PPM_RESCUE_GET(x)                      (((x) & 0x00000100) >> 8)
-#define PHY_BB_TIMING_CONTROLS_3_ENABLE_PPM_RESCUE_SET(x)                      (((x) << 8) & 0x00000100)
-#define PHY_BB_TIMING_CONTROLS_3_ENABLE_FINE_PPM_MSB                                                   9
-#define PHY_BB_TIMING_CONTROLS_3_ENABLE_FINE_PPM_LSB                                                   9
-#define PHY_BB_TIMING_CONTROLS_3_ENABLE_FINE_PPM_MASK                                         0x00000200
-#define PHY_BB_TIMING_CONTROLS_3_ENABLE_FINE_PPM_GET(x)                        (((x) & 0x00000200) >> 9)
-#define PHY_BB_TIMING_CONTROLS_3_ENABLE_FINE_PPM_SET(x)                        (((x) << 9) & 0x00000200)
-#define PHY_BB_TIMING_CONTROLS_3_ENABLE_FINE_INTERP_MSB                                               10
-#define PHY_BB_TIMING_CONTROLS_3_ENABLE_FINE_INTERP_LSB                                               10
-#define PHY_BB_TIMING_CONTROLS_3_ENABLE_FINE_INTERP_MASK                                      0x00000400
-#define PHY_BB_TIMING_CONTROLS_3_ENABLE_FINE_INTERP_GET(x)                    (((x) & 0x00000400) >> 10)
-#define PHY_BB_TIMING_CONTROLS_3_ENABLE_FINE_INTERP_SET(x)                    (((x) << 10) & 0x00000400)
-#define PHY_BB_TIMING_CONTROLS_3_CONTINUOUS_PPM_RESCUE_MSB                                            11
-#define PHY_BB_TIMING_CONTROLS_3_CONTINUOUS_PPM_RESCUE_LSB                                            11
-#define PHY_BB_TIMING_CONTROLS_3_CONTINUOUS_PPM_RESCUE_MASK                                   0x00000800
-#define PHY_BB_TIMING_CONTROLS_3_CONTINUOUS_PPM_RESCUE_GET(x)                 (((x) & 0x00000800) >> 11)
-#define PHY_BB_TIMING_CONTROLS_3_CONTINUOUS_PPM_RESCUE_SET(x)                 (((x) << 11) & 0x00000800)
-#define PHY_BB_TIMING_CONTROLS_3_ENABLE_DF_CHANEST_MSB                                                12
-#define PHY_BB_TIMING_CONTROLS_3_ENABLE_DF_CHANEST_LSB                                                12
-#define PHY_BB_TIMING_CONTROLS_3_ENABLE_DF_CHANEST_MASK                                       0x00001000
-#define PHY_BB_TIMING_CONTROLS_3_ENABLE_DF_CHANEST_GET(x)                     (((x) & 0x00001000) >> 12)
-#define PHY_BB_TIMING_CONTROLS_3_ENABLE_DF_CHANEST_SET(x)                     (((x) << 12) & 0x00001000)
-#define PHY_BB_TIMING_CONTROLS_3_DELTA_SLOPE_COEF_EXP_MSB                                             16
-#define PHY_BB_TIMING_CONTROLS_3_DELTA_SLOPE_COEF_EXP_LSB                                             13
-#define PHY_BB_TIMING_CONTROLS_3_DELTA_SLOPE_COEF_EXP_MASK                                    0x0001e000
-#define PHY_BB_TIMING_CONTROLS_3_DELTA_SLOPE_COEF_EXP_GET(x)                  (((x) & 0x0001e000) >> 13)
-#define PHY_BB_TIMING_CONTROLS_3_DELTA_SLOPE_COEF_EXP_SET(x)                  (((x) << 13) & 0x0001e000)
-#define PHY_BB_TIMING_CONTROLS_3_DELTA_SLOPE_COEF_MAN_MSB                                             31
-#define PHY_BB_TIMING_CONTROLS_3_DELTA_SLOPE_COEF_MAN_LSB                                             17
-#define PHY_BB_TIMING_CONTROLS_3_DELTA_SLOPE_COEF_MAN_MASK                                    0xfffe0000
-#define PHY_BB_TIMING_CONTROLS_3_DELTA_SLOPE_COEF_MAN_GET(x)                  (((x) & 0xfffe0000) >> 17)
-#define PHY_BB_TIMING_CONTROLS_3_DELTA_SLOPE_COEF_MAN_SET(x)                  (((x) << 17) & 0xfffe0000)
-
-/* macros for BB_D2_chip_id */
-#define PHY_BB_D2_CHIP_ID_ADDRESS                                                             0x00009818
-#define PHY_BB_D2_CHIP_ID_OFFSET                                                              0x00009818
-#define PHY_BB_D2_CHIP_ID_OLD_ID_MSB                                                                   7
-#define PHY_BB_D2_CHIP_ID_OLD_ID_LSB                                                                   0
-#define PHY_BB_D2_CHIP_ID_OLD_ID_MASK                                                         0x000000ff
-#define PHY_BB_D2_CHIP_ID_OLD_ID_GET(x)                                        (((x) & 0x000000ff) >> 0)
-#define PHY_BB_D2_CHIP_ID_ID_MSB                                                                      31
-#define PHY_BB_D2_CHIP_ID_ID_LSB                                                                       8
-#define PHY_BB_D2_CHIP_ID_ID_MASK                                                             0xffffff00
-#define PHY_BB_D2_CHIP_ID_ID_GET(x)                                            (((x) & 0xffffff00) >> 8)
-
-/* macros for BB_active */
-#define PHY_BB_ACTIVE_ADDRESS                                                                 0x0000981c
-#define PHY_BB_ACTIVE_OFFSET                                                                  0x0000981c
-#define PHY_BB_ACTIVE_CF_ACTIVE_MSB                                                                    0
-#define PHY_BB_ACTIVE_CF_ACTIVE_LSB                                                                    0
-#define PHY_BB_ACTIVE_CF_ACTIVE_MASK                                                          0x00000001
-#define PHY_BB_ACTIVE_CF_ACTIVE_GET(x)                                         (((x) & 0x00000001) >> 0)
-#define PHY_BB_ACTIVE_CF_ACTIVE_SET(x)                                         (((x) << 0) & 0x00000001)
-
-/* macros for BB_tx_timing_1 */
-#define PHY_BB_TX_TIMING_1_ADDRESS                                                            0x00009820
-#define PHY_BB_TX_TIMING_1_OFFSET                                                             0x00009820
-#define PHY_BB_TX_TIMING_1_TX_FRAME_TO_ADC_OFF_MSB                                                     7
-#define PHY_BB_TX_TIMING_1_TX_FRAME_TO_ADC_OFF_LSB                                                     0
-#define PHY_BB_TX_TIMING_1_TX_FRAME_TO_ADC_OFF_MASK                                           0x000000ff
-#define PHY_BB_TX_TIMING_1_TX_FRAME_TO_ADC_OFF_GET(x)                          (((x) & 0x000000ff) >> 0)
-#define PHY_BB_TX_TIMING_1_TX_FRAME_TO_ADC_OFF_SET(x)                          (((x) << 0) & 0x000000ff)
-#define PHY_BB_TX_TIMING_1_TX_FRAME_TO_A2_RX_OFF_MSB                                                  15
-#define PHY_BB_TX_TIMING_1_TX_FRAME_TO_A2_RX_OFF_LSB                                                   8
-#define PHY_BB_TX_TIMING_1_TX_FRAME_TO_A2_RX_OFF_MASK                                         0x0000ff00
-#define PHY_BB_TX_TIMING_1_TX_FRAME_TO_A2_RX_OFF_GET(x)                        (((x) & 0x0000ff00) >> 8)
-#define PHY_BB_TX_TIMING_1_TX_FRAME_TO_A2_RX_OFF_SET(x)                        (((x) << 8) & 0x0000ff00)
-#define PHY_BB_TX_TIMING_1_TX_FRAME_TO_DAC_ON_MSB                                                     23
-#define PHY_BB_TX_TIMING_1_TX_FRAME_TO_DAC_ON_LSB                                                     16
-#define PHY_BB_TX_TIMING_1_TX_FRAME_TO_DAC_ON_MASK                                            0x00ff0000
-#define PHY_BB_TX_TIMING_1_TX_FRAME_TO_DAC_ON_GET(x)                          (((x) & 0x00ff0000) >> 16)
-#define PHY_BB_TX_TIMING_1_TX_FRAME_TO_DAC_ON_SET(x)                          (((x) << 16) & 0x00ff0000)
-#define PHY_BB_TX_TIMING_1_TX_FRAME_TO_A2_TX_ON_MSB                                                   31
-#define PHY_BB_TX_TIMING_1_TX_FRAME_TO_A2_TX_ON_LSB                                                   24
-#define PHY_BB_TX_TIMING_1_TX_FRAME_TO_A2_TX_ON_MASK                                          0xff000000
-#define PHY_BB_TX_TIMING_1_TX_FRAME_TO_A2_TX_ON_GET(x)                        (((x) & 0xff000000) >> 24)
-#define PHY_BB_TX_TIMING_1_TX_FRAME_TO_A2_TX_ON_SET(x)                        (((x) << 24) & 0xff000000)
-
-/* macros for BB_tx_timing_2 */
-#define PHY_BB_TX_TIMING_2_ADDRESS                                                            0x00009824
-#define PHY_BB_TX_TIMING_2_OFFSET                                                             0x00009824
-#define PHY_BB_TX_TIMING_2_TX_FRAME_TO_TX_D_START_MSB                                                  7
-#define PHY_BB_TX_TIMING_2_TX_FRAME_TO_TX_D_START_LSB                                                  0
-#define PHY_BB_TX_TIMING_2_TX_FRAME_TO_TX_D_START_MASK                                        0x000000ff
-#define PHY_BB_TX_TIMING_2_TX_FRAME_TO_TX_D_START_GET(x)                       (((x) & 0x000000ff) >> 0)
-#define PHY_BB_TX_TIMING_2_TX_FRAME_TO_TX_D_START_SET(x)                       (((x) << 0) & 0x000000ff)
-#define PHY_BB_TX_TIMING_2_TX_FRAME_TO_PA_ON_MSB                                                      15
-#define PHY_BB_TX_TIMING_2_TX_FRAME_TO_PA_ON_LSB                                                       8
-#define PHY_BB_TX_TIMING_2_TX_FRAME_TO_PA_ON_MASK                                             0x0000ff00
-#define PHY_BB_TX_TIMING_2_TX_FRAME_TO_PA_ON_GET(x)                            (((x) & 0x0000ff00) >> 8)
-#define PHY_BB_TX_TIMING_2_TX_FRAME_TO_PA_ON_SET(x)                            (((x) << 8) & 0x0000ff00)
-#define PHY_BB_TX_TIMING_2_TX_END_TO_PA_OFF_MSB                                                       23
-#define PHY_BB_TX_TIMING_2_TX_END_TO_PA_OFF_LSB                                                       16
-#define PHY_BB_TX_TIMING_2_TX_END_TO_PA_OFF_MASK                                              0x00ff0000
-#define PHY_BB_TX_TIMING_2_TX_END_TO_PA_OFF_GET(x)                            (((x) & 0x00ff0000) >> 16)
-#define PHY_BB_TX_TIMING_2_TX_END_TO_PA_OFF_SET(x)                            (((x) << 16) & 0x00ff0000)
-#define PHY_BB_TX_TIMING_2_TX_END_TO_A2_TX_OFF_MSB                                                    31
-#define PHY_BB_TX_TIMING_2_TX_END_TO_A2_TX_OFF_LSB                                                    24
-#define PHY_BB_TX_TIMING_2_TX_END_TO_A2_TX_OFF_MASK                                           0xff000000
-#define PHY_BB_TX_TIMING_2_TX_END_TO_A2_TX_OFF_GET(x)                         (((x) & 0xff000000) >> 24)
-#define PHY_BB_TX_TIMING_2_TX_END_TO_A2_TX_OFF_SET(x)                         (((x) << 24) & 0xff000000)
-
-/* macros for BB_tx_timing_3 */
-#define PHY_BB_TX_TIMING_3_ADDRESS                                                            0x00009828
-#define PHY_BB_TX_TIMING_3_OFFSET                                                             0x00009828
-#define PHY_BB_TX_TIMING_3_TX_END_TO_DAC_OFF_MSB                                                       7
-#define PHY_BB_TX_TIMING_3_TX_END_TO_DAC_OFF_LSB                                                       0
-#define PHY_BB_TX_TIMING_3_TX_END_TO_DAC_OFF_MASK                                             0x000000ff
-#define PHY_BB_TX_TIMING_3_TX_END_TO_DAC_OFF_GET(x)                            (((x) & 0x000000ff) >> 0)
-#define PHY_BB_TX_TIMING_3_TX_END_TO_DAC_OFF_SET(x)                            (((x) << 0) & 0x000000ff)
-#define PHY_BB_TX_TIMING_3_TX_FRAME_TO_THERM_CHAIN_ON_MSB                                             15
-#define PHY_BB_TX_TIMING_3_TX_FRAME_TO_THERM_CHAIN_ON_LSB                                              8
-#define PHY_BB_TX_TIMING_3_TX_FRAME_TO_THERM_CHAIN_ON_MASK                                    0x0000ff00
-#define PHY_BB_TX_TIMING_3_TX_FRAME_TO_THERM_CHAIN_ON_GET(x)                   (((x) & 0x0000ff00) >> 8)
-#define PHY_BB_TX_TIMING_3_TX_FRAME_TO_THERM_CHAIN_ON_SET(x)                   (((x) << 8) & 0x0000ff00)
-#define PHY_BB_TX_TIMING_3_TX_END_TO_A2_RX_ON_MSB                                                     23
-#define PHY_BB_TX_TIMING_3_TX_END_TO_A2_RX_ON_LSB                                                     16
-#define PHY_BB_TX_TIMING_3_TX_END_TO_A2_RX_ON_MASK                                            0x00ff0000
-#define PHY_BB_TX_TIMING_3_TX_END_TO_A2_RX_ON_GET(x)                          (((x) & 0x00ff0000) >> 16)
-#define PHY_BB_TX_TIMING_3_TX_END_TO_A2_RX_ON_SET(x)                          (((x) << 16) & 0x00ff0000)
-#define PHY_BB_TX_TIMING_3_TX_END_TO_ADC_ON_MSB                                                       31
-#define PHY_BB_TX_TIMING_3_TX_END_TO_ADC_ON_LSB                                                       24
-#define PHY_BB_TX_TIMING_3_TX_END_TO_ADC_ON_MASK                                              0xff000000
-#define PHY_BB_TX_TIMING_3_TX_END_TO_ADC_ON_GET(x)                            (((x) & 0xff000000) >> 24)
-#define PHY_BB_TX_TIMING_3_TX_END_TO_ADC_ON_SET(x)                            (((x) << 24) & 0xff000000)
-
-/* macros for BB_addac_parallel_control */
-#define PHY_BB_ADDAC_PARALLEL_CONTROL_ADDRESS                                                 0x0000982c
-#define PHY_BB_ADDAC_PARALLEL_CONTROL_OFFSET                                                  0x0000982c
-#define PHY_BB_ADDAC_PARALLEL_CONTROL_OFF_DACLPMODE_MSB                                               12
-#define PHY_BB_ADDAC_PARALLEL_CONTROL_OFF_DACLPMODE_LSB                                               12
-#define PHY_BB_ADDAC_PARALLEL_CONTROL_OFF_DACLPMODE_MASK                                      0x00001000
-#define PHY_BB_ADDAC_PARALLEL_CONTROL_OFF_DACLPMODE_GET(x)                    (((x) & 0x00001000) >> 12)
-#define PHY_BB_ADDAC_PARALLEL_CONTROL_OFF_DACLPMODE_SET(x)                    (((x) << 12) & 0x00001000)
-#define PHY_BB_ADDAC_PARALLEL_CONTROL_OFF_PWDDAC_MSB                                                  13
-#define PHY_BB_ADDAC_PARALLEL_CONTROL_OFF_PWDDAC_LSB                                                  13
-#define PHY_BB_ADDAC_PARALLEL_CONTROL_OFF_PWDDAC_MASK                                         0x00002000
-#define PHY_BB_ADDAC_PARALLEL_CONTROL_OFF_PWDDAC_GET(x)                       (((x) & 0x00002000) >> 13)
-#define PHY_BB_ADDAC_PARALLEL_CONTROL_OFF_PWDDAC_SET(x)                       (((x) << 13) & 0x00002000)
-#define PHY_BB_ADDAC_PARALLEL_CONTROL_OFF_PWDADC_MSB                                                  15
-#define PHY_BB_ADDAC_PARALLEL_CONTROL_OFF_PWDADC_LSB                                                  15
-#define PHY_BB_ADDAC_PARALLEL_CONTROL_OFF_PWDADC_MASK                                         0x00008000
-#define PHY_BB_ADDAC_PARALLEL_CONTROL_OFF_PWDADC_GET(x)                       (((x) & 0x00008000) >> 15)
-#define PHY_BB_ADDAC_PARALLEL_CONTROL_OFF_PWDADC_SET(x)                       (((x) << 15) & 0x00008000)
-#define PHY_BB_ADDAC_PARALLEL_CONTROL_ON_DACLPMODE_MSB                                                28
-#define PHY_BB_ADDAC_PARALLEL_CONTROL_ON_DACLPMODE_LSB                                                28
-#define PHY_BB_ADDAC_PARALLEL_CONTROL_ON_DACLPMODE_MASK                                       0x10000000
-#define PHY_BB_ADDAC_PARALLEL_CONTROL_ON_DACLPMODE_GET(x)                     (((x) & 0x10000000) >> 28)
-#define PHY_BB_ADDAC_PARALLEL_CONTROL_ON_DACLPMODE_SET(x)                     (((x) << 28) & 0x10000000)
-#define PHY_BB_ADDAC_PARALLEL_CONTROL_ON_PWDDAC_MSB                                                   29
-#define PHY_BB_ADDAC_PARALLEL_CONTROL_ON_PWDDAC_LSB                                                   29
-#define PHY_BB_ADDAC_PARALLEL_CONTROL_ON_PWDDAC_MASK                                          0x20000000
-#define PHY_BB_ADDAC_PARALLEL_CONTROL_ON_PWDDAC_GET(x)                        (((x) & 0x20000000) >> 29)
-#define PHY_BB_ADDAC_PARALLEL_CONTROL_ON_PWDDAC_SET(x)                        (((x) << 29) & 0x20000000)
-#define PHY_BB_ADDAC_PARALLEL_CONTROL_ON_PWDADC_MSB                                                   31
-#define PHY_BB_ADDAC_PARALLEL_CONTROL_ON_PWDADC_LSB                                                   31
-#define PHY_BB_ADDAC_PARALLEL_CONTROL_ON_PWDADC_MASK                                          0x80000000
-#define PHY_BB_ADDAC_PARALLEL_CONTROL_ON_PWDADC_GET(x)                        (((x) & 0x80000000) >> 31)
-#define PHY_BB_ADDAC_PARALLEL_CONTROL_ON_PWDADC_SET(x)                        (((x) << 31) & 0x80000000)
-
-/* macros for BB_xpa_timing_control */
-#define PHY_BB_XPA_TIMING_CONTROL_ADDRESS                                                     0x00009834
-#define PHY_BB_XPA_TIMING_CONTROL_OFFSET                                                      0x00009834
-#define PHY_BB_XPA_TIMING_CONTROL_TX_FRAME_TO_XPAA_ON_MSB                                              7
-#define PHY_BB_XPA_TIMING_CONTROL_TX_FRAME_TO_XPAA_ON_LSB                                              0
-#define PHY_BB_XPA_TIMING_CONTROL_TX_FRAME_TO_XPAA_ON_MASK                                    0x000000ff
-#define PHY_BB_XPA_TIMING_CONTROL_TX_FRAME_TO_XPAA_ON_GET(x)                   (((x) & 0x000000ff) >> 0)
-#define PHY_BB_XPA_TIMING_CONTROL_TX_FRAME_TO_XPAA_ON_SET(x)                   (((x) << 0) & 0x000000ff)
-#define PHY_BB_XPA_TIMING_CONTROL_TX_FRAME_TO_XPAB_ON_MSB                                             15
-#define PHY_BB_XPA_TIMING_CONTROL_TX_FRAME_TO_XPAB_ON_LSB                                              8
-#define PHY_BB_XPA_TIMING_CONTROL_TX_FRAME_TO_XPAB_ON_MASK                                    0x0000ff00
-#define PHY_BB_XPA_TIMING_CONTROL_TX_FRAME_TO_XPAB_ON_GET(x)                   (((x) & 0x0000ff00) >> 8)
-#define PHY_BB_XPA_TIMING_CONTROL_TX_FRAME_TO_XPAB_ON_SET(x)                   (((x) << 8) & 0x0000ff00)
-#define PHY_BB_XPA_TIMING_CONTROL_TX_END_TO_XPAA_OFF_MSB                                              23
-#define PHY_BB_XPA_TIMING_CONTROL_TX_END_TO_XPAA_OFF_LSB                                              16
-#define PHY_BB_XPA_TIMING_CONTROL_TX_END_TO_XPAA_OFF_MASK                                     0x00ff0000
-#define PHY_BB_XPA_TIMING_CONTROL_TX_END_TO_XPAA_OFF_GET(x)                   (((x) & 0x00ff0000) >> 16)
-#define PHY_BB_XPA_TIMING_CONTROL_TX_END_TO_XPAA_OFF_SET(x)                   (((x) << 16) & 0x00ff0000)
-#define PHY_BB_XPA_TIMING_CONTROL_TX_END_TO_XPAB_OFF_MSB                                              31
-#define PHY_BB_XPA_TIMING_CONTROL_TX_END_TO_XPAB_OFF_LSB                                              24
-#define PHY_BB_XPA_TIMING_CONTROL_TX_END_TO_XPAB_OFF_MASK                                     0xff000000
-#define PHY_BB_XPA_TIMING_CONTROL_TX_END_TO_XPAB_OFF_GET(x)                   (((x) & 0xff000000) >> 24)
-#define PHY_BB_XPA_TIMING_CONTROL_TX_END_TO_XPAB_OFF_SET(x)                   (((x) << 24) & 0xff000000)
-
-/* macros for BB_misc_pa_control */
-#define PHY_BB_MISC_PA_CONTROL_ADDRESS                                                        0x00009838
-#define PHY_BB_MISC_PA_CONTROL_OFFSET                                                         0x00009838
-#define PHY_BB_MISC_PA_CONTROL_XPAA_ACTIVE_HIGH_MSB                                                    0
-#define PHY_BB_MISC_PA_CONTROL_XPAA_ACTIVE_HIGH_LSB                                                    0
-#define PHY_BB_MISC_PA_CONTROL_XPAA_ACTIVE_HIGH_MASK                                          0x00000001
-#define PHY_BB_MISC_PA_CONTROL_XPAA_ACTIVE_HIGH_GET(x)                         (((x) & 0x00000001) >> 0)
-#define PHY_BB_MISC_PA_CONTROL_XPAA_ACTIVE_HIGH_SET(x)                         (((x) << 0) & 0x00000001)
-#define PHY_BB_MISC_PA_CONTROL_XPAB_ACTIVE_HIGH_MSB                                                    1
-#define PHY_BB_MISC_PA_CONTROL_XPAB_ACTIVE_HIGH_LSB                                                    1
-#define PHY_BB_MISC_PA_CONTROL_XPAB_ACTIVE_HIGH_MASK                                          0x00000002
-#define PHY_BB_MISC_PA_CONTROL_XPAB_ACTIVE_HIGH_GET(x)                         (((x) & 0x00000002) >> 1)
-#define PHY_BB_MISC_PA_CONTROL_XPAB_ACTIVE_HIGH_SET(x)                         (((x) << 1) & 0x00000002)
-#define PHY_BB_MISC_PA_CONTROL_ENABLE_XPAA_MSB                                                         2
-#define PHY_BB_MISC_PA_CONTROL_ENABLE_XPAA_LSB                                                         2
-#define PHY_BB_MISC_PA_CONTROL_ENABLE_XPAA_MASK                                               0x00000004
-#define PHY_BB_MISC_PA_CONTROL_ENABLE_XPAA_GET(x)                              (((x) & 0x00000004) >> 2)
-#define PHY_BB_MISC_PA_CONTROL_ENABLE_XPAA_SET(x)                              (((x) << 2) & 0x00000004)
-#define PHY_BB_MISC_PA_CONTROL_ENABLE_XPAB_MSB                                                         3
-#define PHY_BB_MISC_PA_CONTROL_ENABLE_XPAB_LSB                                                         3
-#define PHY_BB_MISC_PA_CONTROL_ENABLE_XPAB_MASK                                               0x00000008
-#define PHY_BB_MISC_PA_CONTROL_ENABLE_XPAB_GET(x)                              (((x) & 0x00000008) >> 3)
-#define PHY_BB_MISC_PA_CONTROL_ENABLE_XPAB_SET(x)                              (((x) << 3) & 0x00000008)
-
-/* macros for BB_tstdac_constant */
-#define PHY_BB_TSTDAC_CONSTANT_ADDRESS                                                        0x0000983c
-#define PHY_BB_TSTDAC_CONSTANT_OFFSET                                                         0x0000983c
-#define PHY_BB_TSTDAC_CONSTANT_CF_TSTDAC_CONSTANT_I_MSB                                               10
-#define PHY_BB_TSTDAC_CONSTANT_CF_TSTDAC_CONSTANT_I_LSB                                                0
-#define PHY_BB_TSTDAC_CONSTANT_CF_TSTDAC_CONSTANT_I_MASK                                      0x000007ff
-#define PHY_BB_TSTDAC_CONSTANT_CF_TSTDAC_CONSTANT_I_GET(x)                     (((x) & 0x000007ff) >> 0)
-#define PHY_BB_TSTDAC_CONSTANT_CF_TSTDAC_CONSTANT_I_SET(x)                     (((x) << 0) & 0x000007ff)
-#define PHY_BB_TSTDAC_CONSTANT_CF_TSTDAC_CONSTANT_Q_MSB                                               21
-#define PHY_BB_TSTDAC_CONSTANT_CF_TSTDAC_CONSTANT_Q_LSB                                               11
-#define PHY_BB_TSTDAC_CONSTANT_CF_TSTDAC_CONSTANT_Q_MASK                                      0x003ff800
-#define PHY_BB_TSTDAC_CONSTANT_CF_TSTDAC_CONSTANT_Q_GET(x)                    (((x) & 0x003ff800) >> 11)
-#define PHY_BB_TSTDAC_CONSTANT_CF_TSTDAC_CONSTANT_Q_SET(x)                    (((x) << 11) & 0x003ff800)
-
-/* macros for BB_find_signal_low */
-#define PHY_BB_FIND_SIGNAL_LOW_ADDRESS                                                        0x00009840
-#define PHY_BB_FIND_SIGNAL_LOW_OFFSET                                                         0x00009840
-#define PHY_BB_FIND_SIGNAL_LOW_RELSTEP_LOW_MSB                                                         5
-#define PHY_BB_FIND_SIGNAL_LOW_RELSTEP_LOW_LSB                                                         0
-#define PHY_BB_FIND_SIGNAL_LOW_RELSTEP_LOW_MASK                                               0x0000003f
-#define PHY_BB_FIND_SIGNAL_LOW_RELSTEP_LOW_GET(x)                              (((x) & 0x0000003f) >> 0)
-#define PHY_BB_FIND_SIGNAL_LOW_RELSTEP_LOW_SET(x)                              (((x) << 0) & 0x0000003f)
-#define PHY_BB_FIND_SIGNAL_LOW_FIRSTEP_LOW_MSB                                                        11
-#define PHY_BB_FIND_SIGNAL_LOW_FIRSTEP_LOW_LSB                                                         6
-#define PHY_BB_FIND_SIGNAL_LOW_FIRSTEP_LOW_MASK                                               0x00000fc0
-#define PHY_BB_FIND_SIGNAL_LOW_FIRSTEP_LOW_GET(x)                              (((x) & 0x00000fc0) >> 6)
-#define PHY_BB_FIND_SIGNAL_LOW_FIRSTEP_LOW_SET(x)                              (((x) << 6) & 0x00000fc0)
-#define PHY_BB_FIND_SIGNAL_LOW_FIRPWR_LOW_MSB                                                         19
-#define PHY_BB_FIND_SIGNAL_LOW_FIRPWR_LOW_LSB                                                         12
-#define PHY_BB_FIND_SIGNAL_LOW_FIRPWR_LOW_MASK                                                0x000ff000
-#define PHY_BB_FIND_SIGNAL_LOW_FIRPWR_LOW_GET(x)                              (((x) & 0x000ff000) >> 12)
-#define PHY_BB_FIND_SIGNAL_LOW_FIRPWR_LOW_SET(x)                              (((x) << 12) & 0x000ff000)
-#define PHY_BB_FIND_SIGNAL_LOW_YCOK_MAX_LOW_MSB                                                       23
-#define PHY_BB_FIND_SIGNAL_LOW_YCOK_MAX_LOW_LSB                                                       20
-#define PHY_BB_FIND_SIGNAL_LOW_YCOK_MAX_LOW_MASK                                              0x00f00000
-#define PHY_BB_FIND_SIGNAL_LOW_YCOK_MAX_LOW_GET(x)                            (((x) & 0x00f00000) >> 20)
-#define PHY_BB_FIND_SIGNAL_LOW_YCOK_MAX_LOW_SET(x)                            (((x) << 20) & 0x00f00000)
-#define PHY_BB_FIND_SIGNAL_LOW_LONG_SC_THRESH_MSB                                                     30
-#define PHY_BB_FIND_SIGNAL_LOW_LONG_SC_THRESH_LSB                                                     24
-#define PHY_BB_FIND_SIGNAL_LOW_LONG_SC_THRESH_MASK                                            0x7f000000
-#define PHY_BB_FIND_SIGNAL_LOW_LONG_SC_THRESH_GET(x)                          (((x) & 0x7f000000) >> 24)
-#define PHY_BB_FIND_SIGNAL_LOW_LONG_SC_THRESH_SET(x)                          (((x) << 24) & 0x7f000000)
-
-/* macros for BB_settling_time */
-#define PHY_BB_SETTLING_TIME_ADDRESS                                                          0x00009844
-#define PHY_BB_SETTLING_TIME_OFFSET                                                           0x00009844
-#define PHY_BB_SETTLING_TIME_AGC_SETTLING_MSB                                                          6
-#define PHY_BB_SETTLING_TIME_AGC_SETTLING_LSB                                                          0
-#define PHY_BB_SETTLING_TIME_AGC_SETTLING_MASK                                                0x0000007f
-#define PHY_BB_SETTLING_TIME_AGC_SETTLING_GET(x)                               (((x) & 0x0000007f) >> 0)
-#define PHY_BB_SETTLING_TIME_AGC_SETTLING_SET(x)                               (((x) << 0) & 0x0000007f)
-#define PHY_BB_SETTLING_TIME_SWITCH_SETTLING_MSB                                                      13
-#define PHY_BB_SETTLING_TIME_SWITCH_SETTLING_LSB                                                       7
-#define PHY_BB_SETTLING_TIME_SWITCH_SETTLING_MASK                                             0x00003f80
-#define PHY_BB_SETTLING_TIME_SWITCH_SETTLING_GET(x)                            (((x) & 0x00003f80) >> 7)
-#define PHY_BB_SETTLING_TIME_SWITCH_SETTLING_SET(x)                            (((x) << 7) & 0x00003f80)
-#define PHY_BB_SETTLING_TIME_ADCSAT_THRL_MSB                                                          19
-#define PHY_BB_SETTLING_TIME_ADCSAT_THRL_LSB                                                          14
-#define PHY_BB_SETTLING_TIME_ADCSAT_THRL_MASK                                                 0x000fc000
-#define PHY_BB_SETTLING_TIME_ADCSAT_THRL_GET(x)                               (((x) & 0x000fc000) >> 14)
-#define PHY_BB_SETTLING_TIME_ADCSAT_THRL_SET(x)                               (((x) << 14) & 0x000fc000)
-#define PHY_BB_SETTLING_TIME_ADCSAT_THRH_MSB                                                          25
-#define PHY_BB_SETTLING_TIME_ADCSAT_THRH_LSB                                                          20
-#define PHY_BB_SETTLING_TIME_ADCSAT_THRH_MASK                                                 0x03f00000
-#define PHY_BB_SETTLING_TIME_ADCSAT_THRH_GET(x)                               (((x) & 0x03f00000) >> 20)
-#define PHY_BB_SETTLING_TIME_ADCSAT_THRH_SET(x)                               (((x) << 20) & 0x03f00000)
-#define PHY_BB_SETTLING_TIME_LBRESET_ADVANCE_MSB                                                      29
-#define PHY_BB_SETTLING_TIME_LBRESET_ADVANCE_LSB                                                      26
-#define PHY_BB_SETTLING_TIME_LBRESET_ADVANCE_MASK                                             0x3c000000
-#define PHY_BB_SETTLING_TIME_LBRESET_ADVANCE_GET(x)                           (((x) & 0x3c000000) >> 26)
-#define PHY_BB_SETTLING_TIME_LBRESET_ADVANCE_SET(x)                           (((x) << 26) & 0x3c000000)
-
-/* macros for BB_gain_force_max_gains_b0 */
-#define PHY_BB_GAIN_FORCE_MAX_GAINS_B0_ADDRESS                                                0x00009848
-#define PHY_BB_GAIN_FORCE_MAX_GAINS_B0_OFFSET                                                 0x00009848
-#define PHY_BB_GAIN_FORCE_MAX_GAINS_B0_XATTEN1_HYST_MARGIN_0_MSB                                      13
-#define PHY_BB_GAIN_FORCE_MAX_GAINS_B0_XATTEN1_HYST_MARGIN_0_LSB                                       7
-#define PHY_BB_GAIN_FORCE_MAX_GAINS_B0_XATTEN1_HYST_MARGIN_0_MASK                             0x00003f80
-#define PHY_BB_GAIN_FORCE_MAX_GAINS_B0_XATTEN1_HYST_MARGIN_0_GET(x)            (((x) & 0x00003f80) >> 7)
-#define PHY_BB_GAIN_FORCE_MAX_GAINS_B0_XATTEN1_HYST_MARGIN_0_SET(x)            (((x) << 7) & 0x00003f80)
-#define PHY_BB_GAIN_FORCE_MAX_GAINS_B0_XATTEN2_HYST_MARGIN_0_MSB                                      20
-#define PHY_BB_GAIN_FORCE_MAX_GAINS_B0_XATTEN2_HYST_MARGIN_0_LSB                                      14
-#define PHY_BB_GAIN_FORCE_MAX_GAINS_B0_XATTEN2_HYST_MARGIN_0_MASK                             0x001fc000
-#define PHY_BB_GAIN_FORCE_MAX_GAINS_B0_XATTEN2_HYST_MARGIN_0_GET(x)           (((x) & 0x001fc000) >> 14)
-#define PHY_BB_GAIN_FORCE_MAX_GAINS_B0_XATTEN2_HYST_MARGIN_0_SET(x)           (((x) << 14) & 0x001fc000)
-#define PHY_BB_GAIN_FORCE_MAX_GAINS_B0_GAIN_FORCE_MSB                                                 21
-#define PHY_BB_GAIN_FORCE_MAX_GAINS_B0_GAIN_FORCE_LSB                                                 21
-#define PHY_BB_GAIN_FORCE_MAX_GAINS_B0_GAIN_FORCE_MASK                                        0x00200000
-#define PHY_BB_GAIN_FORCE_MAX_GAINS_B0_GAIN_FORCE_GET(x)                      (((x) & 0x00200000) >> 21)
-#define PHY_BB_GAIN_FORCE_MAX_GAINS_B0_GAIN_FORCE_SET(x)                      (((x) << 21) & 0x00200000)
-#define PHY_BB_GAIN_FORCE_MAX_GAINS_B0_ENABLE_SHARED_RX_MSB                                           31
-#define PHY_BB_GAIN_FORCE_MAX_GAINS_B0_ENABLE_SHARED_RX_LSB                                           31
-#define PHY_BB_GAIN_FORCE_MAX_GAINS_B0_ENABLE_SHARED_RX_MASK                                  0x80000000
-#define PHY_BB_GAIN_FORCE_MAX_GAINS_B0_ENABLE_SHARED_RX_GET(x)                (((x) & 0x80000000) >> 31)
-#define PHY_BB_GAIN_FORCE_MAX_GAINS_B0_ENABLE_SHARED_RX_SET(x)                (((x) << 31) & 0x80000000)
-
-/* macros for BB_gains_min_offsets_b0 */
-#define PHY_BB_GAINS_MIN_OFFSETS_B0_ADDRESS                                                   0x0000984c
-#define PHY_BB_GAINS_MIN_OFFSETS_B0_OFFSET                                                    0x0000984c
-#define PHY_BB_GAINS_MIN_OFFSETS_B0_OFFSETC1_MSB                                                       6
-#define PHY_BB_GAINS_MIN_OFFSETS_B0_OFFSETC1_LSB                                                       0
-#define PHY_BB_GAINS_MIN_OFFSETS_B0_OFFSETC1_MASK                                             0x0000007f
-#define PHY_BB_GAINS_MIN_OFFSETS_B0_OFFSETC1_GET(x)                            (((x) & 0x0000007f) >> 0)
-#define PHY_BB_GAINS_MIN_OFFSETS_B0_OFFSETC1_SET(x)                            (((x) << 0) & 0x0000007f)
-#define PHY_BB_GAINS_MIN_OFFSETS_B0_OFFSETC2_MSB                                                      11
-#define PHY_BB_GAINS_MIN_OFFSETS_B0_OFFSETC2_LSB                                                       7
-#define PHY_BB_GAINS_MIN_OFFSETS_B0_OFFSETC2_MASK                                             0x00000f80
-#define PHY_BB_GAINS_MIN_OFFSETS_B0_OFFSETC2_GET(x)                            (((x) & 0x00000f80) >> 7)
-#define PHY_BB_GAINS_MIN_OFFSETS_B0_OFFSETC2_SET(x)                            (((x) << 7) & 0x00000f80)
-#define PHY_BB_GAINS_MIN_OFFSETS_B0_OFFSETC3_MSB                                                      16
-#define PHY_BB_GAINS_MIN_OFFSETS_B0_OFFSETC3_LSB                                                      12
-#define PHY_BB_GAINS_MIN_OFFSETS_B0_OFFSETC3_MASK                                             0x0001f000
-#define PHY_BB_GAINS_MIN_OFFSETS_B0_OFFSETC3_GET(x)                           (((x) & 0x0001f000) >> 12)
-#define PHY_BB_GAINS_MIN_OFFSETS_B0_OFFSETC3_SET(x)                           (((x) << 12) & 0x0001f000)
-#define PHY_BB_GAINS_MIN_OFFSETS_B0_RF_GAIN_F_0_MSB                                                   24
-#define PHY_BB_GAINS_MIN_OFFSETS_B0_RF_GAIN_F_0_LSB                                                   17
-#define PHY_BB_GAINS_MIN_OFFSETS_B0_RF_GAIN_F_0_MASK                                          0x01fe0000
-#define PHY_BB_GAINS_MIN_OFFSETS_B0_RF_GAIN_F_0_GET(x)                        (((x) & 0x01fe0000) >> 17)
-#define PHY_BB_GAINS_MIN_OFFSETS_B0_RF_GAIN_F_0_SET(x)                        (((x) << 17) & 0x01fe0000)
-#define PHY_BB_GAINS_MIN_OFFSETS_B0_XATTEN1_SW_F_0_MSB                                                25
-#define PHY_BB_GAINS_MIN_OFFSETS_B0_XATTEN1_SW_F_0_LSB                                                25
-#define PHY_BB_GAINS_MIN_OFFSETS_B0_XATTEN1_SW_F_0_MASK                                       0x02000000
-#define PHY_BB_GAINS_MIN_OFFSETS_B0_XATTEN1_SW_F_0_GET(x)                     (((x) & 0x02000000) >> 25)
-#define PHY_BB_GAINS_MIN_OFFSETS_B0_XATTEN1_SW_F_0_SET(x)                     (((x) << 25) & 0x02000000)
-#define PHY_BB_GAINS_MIN_OFFSETS_B0_XATTEN2_SW_F_0_MSB                                                26
-#define PHY_BB_GAINS_MIN_OFFSETS_B0_XATTEN2_SW_F_0_LSB                                                26
-#define PHY_BB_GAINS_MIN_OFFSETS_B0_XATTEN2_SW_F_0_MASK                                       0x04000000
-#define PHY_BB_GAINS_MIN_OFFSETS_B0_XATTEN2_SW_F_0_GET(x)                     (((x) & 0x04000000) >> 26)
-#define PHY_BB_GAINS_MIN_OFFSETS_B0_XATTEN2_SW_F_0_SET(x)                     (((x) << 26) & 0x04000000)
-
-/* macros for BB_desired_sigsize */
-#define PHY_BB_DESIRED_SIGSIZE_ADDRESS                                                        0x00009850
-#define PHY_BB_DESIRED_SIGSIZE_OFFSET                                                         0x00009850
-#define PHY_BB_DESIRED_SIGSIZE_ADC_DESIRED_SIZE_MSB                                                    7
-#define PHY_BB_DESIRED_SIGSIZE_ADC_DESIRED_SIZE_LSB                                                    0
-#define PHY_BB_DESIRED_SIGSIZE_ADC_DESIRED_SIZE_MASK                                          0x000000ff
-#define PHY_BB_DESIRED_SIGSIZE_ADC_DESIRED_SIZE_GET(x)                         (((x) & 0x000000ff) >> 0)
-#define PHY_BB_DESIRED_SIGSIZE_ADC_DESIRED_SIZE_SET(x)                         (((x) << 0) & 0x000000ff)
-#define PHY_BB_DESIRED_SIGSIZE_TOTAL_DESIRED_MSB                                                      27
-#define PHY_BB_DESIRED_SIGSIZE_TOTAL_DESIRED_LSB                                                      20
-#define PHY_BB_DESIRED_SIGSIZE_TOTAL_DESIRED_MASK                                             0x0ff00000
-#define PHY_BB_DESIRED_SIGSIZE_TOTAL_DESIRED_GET(x)                           (((x) & 0x0ff00000) >> 20)
-#define PHY_BB_DESIRED_SIGSIZE_TOTAL_DESIRED_SET(x)                           (((x) << 20) & 0x0ff00000)
-#define PHY_BB_DESIRED_SIGSIZE_INIT_GC_COUNT_MAX_MSB                                                  29
-#define PHY_BB_DESIRED_SIGSIZE_INIT_GC_COUNT_MAX_LSB                                                  28
-#define PHY_BB_DESIRED_SIGSIZE_INIT_GC_COUNT_MAX_MASK                                         0x30000000
-#define PHY_BB_DESIRED_SIGSIZE_INIT_GC_COUNT_MAX_GET(x)                       (((x) & 0x30000000) >> 28)
-#define PHY_BB_DESIRED_SIGSIZE_INIT_GC_COUNT_MAX_SET(x)                       (((x) << 28) & 0x30000000)
-#define PHY_BB_DESIRED_SIGSIZE_REDUCE_INIT_GC_COUNT_MSB                                               30
-#define PHY_BB_DESIRED_SIGSIZE_REDUCE_INIT_GC_COUNT_LSB                                               30
-#define PHY_BB_DESIRED_SIGSIZE_REDUCE_INIT_GC_COUNT_MASK                                      0x40000000
-#define PHY_BB_DESIRED_SIGSIZE_REDUCE_INIT_GC_COUNT_GET(x)                    (((x) & 0x40000000) >> 30)
-#define PHY_BB_DESIRED_SIGSIZE_REDUCE_INIT_GC_COUNT_SET(x)                    (((x) << 30) & 0x40000000)
-#define PHY_BB_DESIRED_SIGSIZE_ENA_INIT_GAIN_MSB                                                      31
-#define PHY_BB_DESIRED_SIGSIZE_ENA_INIT_GAIN_LSB                                                      31
-#define PHY_BB_DESIRED_SIGSIZE_ENA_INIT_GAIN_MASK                                             0x80000000
-#define PHY_BB_DESIRED_SIGSIZE_ENA_INIT_GAIN_GET(x)                           (((x) & 0x80000000) >> 31)
-#define PHY_BB_DESIRED_SIGSIZE_ENA_INIT_GAIN_SET(x)                           (((x) << 31) & 0x80000000)
-
-/* macros for BB_timing_control_3a */
-#define PHY_BB_TIMING_CONTROL_3A_ADDRESS                                                      0x00009854
-#define PHY_BB_TIMING_CONTROL_3A_OFFSET                                                       0x00009854
-#define PHY_BB_TIMING_CONTROL_3A_STE_THR_HI_RSSI_MSB                                                   6
-#define PHY_BB_TIMING_CONTROL_3A_STE_THR_HI_RSSI_LSB                                                   0
-#define PHY_BB_TIMING_CONTROL_3A_STE_THR_HI_RSSI_MASK                                         0x0000007f
-#define PHY_BB_TIMING_CONTROL_3A_STE_THR_HI_RSSI_GET(x)                        (((x) & 0x0000007f) >> 0)
-#define PHY_BB_TIMING_CONTROL_3A_STE_THR_HI_RSSI_SET(x)                        (((x) << 0) & 0x0000007f)
-
-/* macros for BB_find_signal */
-#define PHY_BB_FIND_SIGNAL_ADDRESS                                                            0x00009858
-#define PHY_BB_FIND_SIGNAL_OFFSET                                                             0x00009858
-#define PHY_BB_FIND_SIGNAL_RELSTEP_MSB                                                                 5
-#define PHY_BB_FIND_SIGNAL_RELSTEP_LSB                                                                 0
-#define PHY_BB_FIND_SIGNAL_RELSTEP_MASK                                                       0x0000003f
-#define PHY_BB_FIND_SIGNAL_RELSTEP_GET(x)                                      (((x) & 0x0000003f) >> 0)
-#define PHY_BB_FIND_SIGNAL_RELSTEP_SET(x)                                      (((x) << 0) & 0x0000003f)
-#define PHY_BB_FIND_SIGNAL_RELPWR_MSB                                                                 11
-#define PHY_BB_FIND_SIGNAL_RELPWR_LSB                                                                  6
-#define PHY_BB_FIND_SIGNAL_RELPWR_MASK                                                        0x00000fc0
-#define PHY_BB_FIND_SIGNAL_RELPWR_GET(x)                                       (((x) & 0x00000fc0) >> 6)
-#define PHY_BB_FIND_SIGNAL_RELPWR_SET(x)                                       (((x) << 6) & 0x00000fc0)
-#define PHY_BB_FIND_SIGNAL_FIRSTEP_MSB                                                                17
-#define PHY_BB_FIND_SIGNAL_FIRSTEP_LSB                                                                12
-#define PHY_BB_FIND_SIGNAL_FIRSTEP_MASK                                                       0x0003f000
-#define PHY_BB_FIND_SIGNAL_FIRSTEP_GET(x)                                     (((x) & 0x0003f000) >> 12)
-#define PHY_BB_FIND_SIGNAL_FIRSTEP_SET(x)                                     (((x) << 12) & 0x0003f000)
-#define PHY_BB_FIND_SIGNAL_FIRPWR_MSB                                                                 25
-#define PHY_BB_FIND_SIGNAL_FIRPWR_LSB                                                                 18
-#define PHY_BB_FIND_SIGNAL_FIRPWR_MASK                                                        0x03fc0000
-#define PHY_BB_FIND_SIGNAL_FIRPWR_GET(x)                                      (((x) & 0x03fc0000) >> 18)
-#define PHY_BB_FIND_SIGNAL_FIRPWR_SET(x)                                      (((x) << 18) & 0x03fc0000)
-#define PHY_BB_FIND_SIGNAL_M1COUNT_MAX_MSB                                                            31
-#define PHY_BB_FIND_SIGNAL_M1COUNT_MAX_LSB                                                            26
-#define PHY_BB_FIND_SIGNAL_M1COUNT_MAX_MASK                                                   0xfc000000
-#define PHY_BB_FIND_SIGNAL_M1COUNT_MAX_GET(x)                                 (((x) & 0xfc000000) >> 26)
-#define PHY_BB_FIND_SIGNAL_M1COUNT_MAX_SET(x)                                 (((x) << 26) & 0xfc000000)
-
-/* macros for BB_agc */
-#define PHY_BB_AGC_ADDRESS                                                                    0x0000985c
-#define PHY_BB_AGC_OFFSET                                                                     0x0000985c
-#define PHY_BB_AGC_COARSEPWR_CONST_MSB                                                                 6
-#define PHY_BB_AGC_COARSEPWR_CONST_LSB                                                                 0
-#define PHY_BB_AGC_COARSEPWR_CONST_MASK                                                       0x0000007f
-#define PHY_BB_AGC_COARSEPWR_CONST_GET(x)                                      (((x) & 0x0000007f) >> 0)
-#define PHY_BB_AGC_COARSEPWR_CONST_SET(x)                                      (((x) << 0) & 0x0000007f)
-#define PHY_BB_AGC_COARSE_LOW_MSB                                                                     14
-#define PHY_BB_AGC_COARSE_LOW_LSB                                                                      7
-#define PHY_BB_AGC_COARSE_LOW_MASK                                                            0x00007f80
-#define PHY_BB_AGC_COARSE_LOW_GET(x)                                           (((x) & 0x00007f80) >> 7)
-#define PHY_BB_AGC_COARSE_LOW_SET(x)                                           (((x) << 7) & 0x00007f80)
-#define PHY_BB_AGC_COARSE_HIGH_MSB                                                                    21
-#define PHY_BB_AGC_COARSE_HIGH_LSB                                                                    15
-#define PHY_BB_AGC_COARSE_HIGH_MASK                                                           0x003f8000
-#define PHY_BB_AGC_COARSE_HIGH_GET(x)                                         (((x) & 0x003f8000) >> 15)
-#define PHY_BB_AGC_COARSE_HIGH_SET(x)                                         (((x) << 15) & 0x003f8000)
-#define PHY_BB_AGC_QUICK_DROP_MSB                                                                     29
-#define PHY_BB_AGC_QUICK_DROP_LSB                                                                     22
-#define PHY_BB_AGC_QUICK_DROP_MASK                                                            0x3fc00000
-#define PHY_BB_AGC_QUICK_DROP_GET(x)                                          (((x) & 0x3fc00000) >> 22)
-#define PHY_BB_AGC_QUICK_DROP_SET(x)                                          (((x) << 22) & 0x3fc00000)
-#define PHY_BB_AGC_RSSI_OUT_SELECT_MSB                                                                31
-#define PHY_BB_AGC_RSSI_OUT_SELECT_LSB                                                                30
-#define PHY_BB_AGC_RSSI_OUT_SELECT_MASK                                                       0xc0000000
-#define PHY_BB_AGC_RSSI_OUT_SELECT_GET(x)                                     (((x) & 0xc0000000) >> 30)
-#define PHY_BB_AGC_RSSI_OUT_SELECT_SET(x)                                     (((x) << 30) & 0xc0000000)
-
-/* macros for BB_agc_control */
-#define PHY_BB_AGC_CONTROL_ADDRESS                                                            0x00009860
-#define PHY_BB_AGC_CONTROL_OFFSET                                                             0x00009860
-#define PHY_BB_AGC_CONTROL_DO_CALIBRATE_MSB                                                            0
-#define PHY_BB_AGC_CONTROL_DO_CALIBRATE_LSB                                                            0
-#define PHY_BB_AGC_CONTROL_DO_CALIBRATE_MASK                                                  0x00000001
-#define PHY_BB_AGC_CONTROL_DO_CALIBRATE_GET(x)                                 (((x) & 0x00000001) >> 0)
-#define PHY_BB_AGC_CONTROL_DO_CALIBRATE_SET(x)                                 (((x) << 0) & 0x00000001)
-#define PHY_BB_AGC_CONTROL_DO_NOISEFLOOR_MSB                                                           1
-#define PHY_BB_AGC_CONTROL_DO_NOISEFLOOR_LSB                                                           1
-#define PHY_BB_AGC_CONTROL_DO_NOISEFLOOR_MASK                                                 0x00000002
-#define PHY_BB_AGC_CONTROL_DO_NOISEFLOOR_GET(x)                                (((x) & 0x00000002) >> 1)
-#define PHY_BB_AGC_CONTROL_DO_NOISEFLOOR_SET(x)                                (((x) << 1) & 0x00000002)
-#define PHY_BB_AGC_CONTROL_MIN_NUM_GAIN_CHANGE_MSB                                                     5
-#define PHY_BB_AGC_CONTROL_MIN_NUM_GAIN_CHANGE_LSB                                                     3
-#define PHY_BB_AGC_CONTROL_MIN_NUM_GAIN_CHANGE_MASK                                           0x00000038
-#define PHY_BB_AGC_CONTROL_MIN_NUM_GAIN_CHANGE_GET(x)                          (((x) & 0x00000038) >> 3)
-#define PHY_BB_AGC_CONTROL_MIN_NUM_GAIN_CHANGE_SET(x)                          (((x) << 3) & 0x00000038)
-#define PHY_BB_AGC_CONTROL_YCOK_MAX_MSB                                                                9
-#define PHY_BB_AGC_CONTROL_YCOK_MAX_LSB                                                                6
-#define PHY_BB_AGC_CONTROL_YCOK_MAX_MASK                                                      0x000003c0
-#define PHY_BB_AGC_CONTROL_YCOK_MAX_GET(x)                                     (((x) & 0x000003c0) >> 6)
-#define PHY_BB_AGC_CONTROL_YCOK_MAX_SET(x)                                     (((x) << 6) & 0x000003c0)
-#define PHY_BB_AGC_CONTROL_LEAKY_BUCKET_ENABLE_MSB                                                    10
-#define PHY_BB_AGC_CONTROL_LEAKY_BUCKET_ENABLE_LSB                                                    10
-#define PHY_BB_AGC_CONTROL_LEAKY_BUCKET_ENABLE_MASK                                           0x00000400
-#define PHY_BB_AGC_CONTROL_LEAKY_BUCKET_ENABLE_GET(x)                         (((x) & 0x00000400) >> 10)
-#define PHY_BB_AGC_CONTROL_LEAKY_BUCKET_ENABLE_SET(x)                         (((x) << 10) & 0x00000400)
-#define PHY_BB_AGC_CONTROL_CAL_ENABLE_MSB                                                             11
-#define PHY_BB_AGC_CONTROL_CAL_ENABLE_LSB                                                             11
-#define PHY_BB_AGC_CONTROL_CAL_ENABLE_MASK                                                    0x00000800
-#define PHY_BB_AGC_CONTROL_CAL_ENABLE_GET(x)                                  (((x) & 0x00000800) >> 11)
-#define PHY_BB_AGC_CONTROL_CAL_ENABLE_SET(x)                                  (((x) << 11) & 0x00000800)
-#define PHY_BB_AGC_CONTROL_USE_TABLE_SEED_MSB                                                         12
-#define PHY_BB_AGC_CONTROL_USE_TABLE_SEED_LSB                                                         12
-#define PHY_BB_AGC_CONTROL_USE_TABLE_SEED_MASK                                                0x00001000
-#define PHY_BB_AGC_CONTROL_USE_TABLE_SEED_GET(x)                              (((x) & 0x00001000) >> 12)
-#define PHY_BB_AGC_CONTROL_USE_TABLE_SEED_SET(x)                              (((x) << 12) & 0x00001000)
-#define PHY_BB_AGC_CONTROL_AGC_UPDATE_TABLE_SEED_MSB                                                  13
-#define PHY_BB_AGC_CONTROL_AGC_UPDATE_TABLE_SEED_LSB                                                  13
-#define PHY_BB_AGC_CONTROL_AGC_UPDATE_TABLE_SEED_MASK                                         0x00002000
-#define PHY_BB_AGC_CONTROL_AGC_UPDATE_TABLE_SEED_GET(x)                       (((x) & 0x00002000) >> 13)
-#define PHY_BB_AGC_CONTROL_AGC_UPDATE_TABLE_SEED_SET(x)                       (((x) << 13) & 0x00002000)
-#define PHY_BB_AGC_CONTROL_ENABLE_NOISEFLOOR_MSB                                                      15
-#define PHY_BB_AGC_CONTROL_ENABLE_NOISEFLOOR_LSB                                                      15
-#define PHY_BB_AGC_CONTROL_ENABLE_NOISEFLOOR_MASK                                             0x00008000
-#define PHY_BB_AGC_CONTROL_ENABLE_NOISEFLOOR_GET(x)                           (((x) & 0x00008000) >> 15)
-#define PHY_BB_AGC_CONTROL_ENABLE_NOISEFLOOR_SET(x)                           (((x) << 15) & 0x00008000)
-#define PHY_BB_AGC_CONTROL_ENABLE_FLTR_CAL_MSB                                                        16
-#define PHY_BB_AGC_CONTROL_ENABLE_FLTR_CAL_LSB                                                        16
-#define PHY_BB_AGC_CONTROL_ENABLE_FLTR_CAL_MASK                                               0x00010000
-#define PHY_BB_AGC_CONTROL_ENABLE_FLTR_CAL_GET(x)                             (((x) & 0x00010000) >> 16)
-#define PHY_BB_AGC_CONTROL_ENABLE_FLTR_CAL_SET(x)                             (((x) << 16) & 0x00010000)
-#define PHY_BB_AGC_CONTROL_NO_UPDATE_NOISEFLOOR_MSB                                                   17
-#define PHY_BB_AGC_CONTROL_NO_UPDATE_NOISEFLOOR_LSB                                                   17
-#define PHY_BB_AGC_CONTROL_NO_UPDATE_NOISEFLOOR_MASK                                          0x00020000
-#define PHY_BB_AGC_CONTROL_NO_UPDATE_NOISEFLOOR_GET(x)                        (((x) & 0x00020000) >> 17)
-#define PHY_BB_AGC_CONTROL_NO_UPDATE_NOISEFLOOR_SET(x)                        (((x) << 17) & 0x00020000)
-#define PHY_BB_AGC_CONTROL_EXTEND_NF_PWR_MEAS_MSB                                                     18
-#define PHY_BB_AGC_CONTROL_EXTEND_NF_PWR_MEAS_LSB                                                     18
-#define PHY_BB_AGC_CONTROL_EXTEND_NF_PWR_MEAS_MASK                                            0x00040000
-#define PHY_BB_AGC_CONTROL_EXTEND_NF_PWR_MEAS_GET(x)                          (((x) & 0x00040000) >> 18)
-#define PHY_BB_AGC_CONTROL_EXTEND_NF_PWR_MEAS_SET(x)                          (((x) << 18) & 0x00040000)
-#define PHY_BB_AGC_CONTROL_CLC_SUCCESS_MSB                                                            19
-#define PHY_BB_AGC_CONTROL_CLC_SUCCESS_LSB                                                            19
-#define PHY_BB_AGC_CONTROL_CLC_SUCCESS_MASK                                                   0x00080000
-#define PHY_BB_AGC_CONTROL_CLC_SUCCESS_GET(x)                                 (((x) & 0x00080000) >> 19)
-#define PHY_BB_AGC_CONTROL_ENABLE_PKDET_CAL_MSB                                                       20
-#define PHY_BB_AGC_CONTROL_ENABLE_PKDET_CAL_LSB                                                       20
-#define PHY_BB_AGC_CONTROL_ENABLE_PKDET_CAL_MASK                                              0x00100000
-#define PHY_BB_AGC_CONTROL_ENABLE_PKDET_CAL_GET(x)                            (((x) & 0x00100000) >> 20)
-#define PHY_BB_AGC_CONTROL_ENABLE_PKDET_CAL_SET(x)                            (((x) << 20) & 0x00100000)
-
-/* macros for BB_cca_b0 */
-#define PHY_BB_CCA_B0_ADDRESS                                                                 0x00009864
-#define PHY_BB_CCA_B0_OFFSET                                                                  0x00009864
-#define PHY_BB_CCA_B0_CF_MAXCCAPWR_0_MSB                                                               8
-#define PHY_BB_CCA_B0_CF_MAXCCAPWR_0_LSB                                                               0
-#define PHY_BB_CCA_B0_CF_MAXCCAPWR_0_MASK                                                     0x000001ff
-#define PHY_BB_CCA_B0_CF_MAXCCAPWR_0_GET(x)                                    (((x) & 0x000001ff) >> 0)
-#define PHY_BB_CCA_B0_CF_MAXCCAPWR_0_SET(x)                                    (((x) << 0) & 0x000001ff)
-#define PHY_BB_CCA_B0_CF_CCA_COUNT_MAXC_MSB                                                           11
-#define PHY_BB_CCA_B0_CF_CCA_COUNT_MAXC_LSB                                                            9
-#define PHY_BB_CCA_B0_CF_CCA_COUNT_MAXC_MASK                                                  0x00000e00
-#define PHY_BB_CCA_B0_CF_CCA_COUNT_MAXC_GET(x)                                 (((x) & 0x00000e00) >> 9)
-#define PHY_BB_CCA_B0_CF_CCA_COUNT_MAXC_SET(x)                                 (((x) << 9) & 0x00000e00)
-#define PHY_BB_CCA_B0_CF_THRESH62_MSB                                                                 19
-#define PHY_BB_CCA_B0_CF_THRESH62_LSB                                                                 12
-#define PHY_BB_CCA_B0_CF_THRESH62_MASK                                                        0x000ff000
-#define PHY_BB_CCA_B0_CF_THRESH62_GET(x)                                      (((x) & 0x000ff000) >> 12)
-#define PHY_BB_CCA_B0_CF_THRESH62_SET(x)                                      (((x) << 12) & 0x000ff000)
-#define PHY_BB_CCA_B0_MINCCAPWR_0_MSB                                                                 28
-#define PHY_BB_CCA_B0_MINCCAPWR_0_LSB                                                                 20
-#define PHY_BB_CCA_B0_MINCCAPWR_0_MASK                                                        0x1ff00000
-#define PHY_BB_CCA_B0_MINCCAPWR_0_GET(x)                                      (((x) & 0x1ff00000) >> 20)
-
-/* macros for BB_sfcorr */
-#define PHY_BB_SFCORR_ADDRESS                                                                 0x00009868
-#define PHY_BB_SFCORR_OFFSET                                                                  0x00009868
-#define PHY_BB_SFCORR_M2COUNT_THR_MSB                                                                  4
-#define PHY_BB_SFCORR_M2COUNT_THR_LSB                                                                  0
-#define PHY_BB_SFCORR_M2COUNT_THR_MASK                                                        0x0000001f
-#define PHY_BB_SFCORR_M2COUNT_THR_GET(x)                                       (((x) & 0x0000001f) >> 0)
-#define PHY_BB_SFCORR_M2COUNT_THR_SET(x)                                       (((x) << 0) & 0x0000001f)
-#define PHY_BB_SFCORR_ADCSAT_THRESH_MSB                                                               10
-#define PHY_BB_SFCORR_ADCSAT_THRESH_LSB                                                                5
-#define PHY_BB_SFCORR_ADCSAT_THRESH_MASK                                                      0x000007e0
-#define PHY_BB_SFCORR_ADCSAT_THRESH_GET(x)                                     (((x) & 0x000007e0) >> 5)
-#define PHY_BB_SFCORR_ADCSAT_THRESH_SET(x)                                     (((x) << 5) & 0x000007e0)
-#define PHY_BB_SFCORR_ADCSAT_ICOUNT_MSB                                                               16
-#define PHY_BB_SFCORR_ADCSAT_ICOUNT_LSB                                                               11
-#define PHY_BB_SFCORR_ADCSAT_ICOUNT_MASK                                                      0x0001f800
-#define PHY_BB_SFCORR_ADCSAT_ICOUNT_GET(x)                                    (((x) & 0x0001f800) >> 11)
-#define PHY_BB_SFCORR_ADCSAT_ICOUNT_SET(x)                                    (((x) << 11) & 0x0001f800)
-#define PHY_BB_SFCORR_M1_THRES_MSB                                                                    23
-#define PHY_BB_SFCORR_M1_THRES_LSB                                                                    17
-#define PHY_BB_SFCORR_M1_THRES_MASK                                                           0x00fe0000
-#define PHY_BB_SFCORR_M1_THRES_GET(x)                                         (((x) & 0x00fe0000) >> 17)
-#define PHY_BB_SFCORR_M1_THRES_SET(x)                                         (((x) << 17) & 0x00fe0000)
-#define PHY_BB_SFCORR_M2_THRES_MSB                                                                    30
-#define PHY_BB_SFCORR_M2_THRES_LSB                                                                    24
-#define PHY_BB_SFCORR_M2_THRES_MASK                                                           0x7f000000
-#define PHY_BB_SFCORR_M2_THRES_GET(x)                                         (((x) & 0x7f000000) >> 24)
-#define PHY_BB_SFCORR_M2_THRES_SET(x)                                         (((x) << 24) & 0x7f000000)
-
-/* macros for BB_self_corr_low */
-#define PHY_BB_SELF_CORR_LOW_ADDRESS                                                          0x0000986c
-#define PHY_BB_SELF_CORR_LOW_OFFSET                                                           0x0000986c
-#define PHY_BB_SELF_CORR_LOW_USE_SELF_CORR_LOW_MSB                                                     0
-#define PHY_BB_SELF_CORR_LOW_USE_SELF_CORR_LOW_LSB                                                     0
-#define PHY_BB_SELF_CORR_LOW_USE_SELF_CORR_LOW_MASK                                           0x00000001
-#define PHY_BB_SELF_CORR_LOW_USE_SELF_CORR_LOW_GET(x)                          (((x) & 0x00000001) >> 0)
-#define PHY_BB_SELF_CORR_LOW_USE_SELF_CORR_LOW_SET(x)                          (((x) << 0) & 0x00000001)
-#define PHY_BB_SELF_CORR_LOW_M1COUNT_MAX_LOW_MSB                                                       7
-#define PHY_BB_SELF_CORR_LOW_M1COUNT_MAX_LOW_LSB                                                       1
-#define PHY_BB_SELF_CORR_LOW_M1COUNT_MAX_LOW_MASK                                             0x000000fe
-#define PHY_BB_SELF_CORR_LOW_M1COUNT_MAX_LOW_GET(x)                            (((x) & 0x000000fe) >> 1)
-#define PHY_BB_SELF_CORR_LOW_M1COUNT_MAX_LOW_SET(x)                            (((x) << 1) & 0x000000fe)
-#define PHY_BB_SELF_CORR_LOW_M2COUNT_THR_LOW_MSB                                                      13
-#define PHY_BB_SELF_CORR_LOW_M2COUNT_THR_LOW_LSB                                                       8
-#define PHY_BB_SELF_CORR_LOW_M2COUNT_THR_LOW_MASK                                             0x00003f00
-#define PHY_BB_SELF_CORR_LOW_M2COUNT_THR_LOW_GET(x)                            (((x) & 0x00003f00) >> 8)
-#define PHY_BB_SELF_CORR_LOW_M2COUNT_THR_LOW_SET(x)                            (((x) << 8) & 0x00003f00)
-#define PHY_BB_SELF_CORR_LOW_M1_THRESH_LOW_MSB                                                        20
-#define PHY_BB_SELF_CORR_LOW_M1_THRESH_LOW_LSB                                                        14
-#define PHY_BB_SELF_CORR_LOW_M1_THRESH_LOW_MASK                                               0x001fc000
-#define PHY_BB_SELF_CORR_LOW_M1_THRESH_LOW_GET(x)                             (((x) & 0x001fc000) >> 14)
-#define PHY_BB_SELF_CORR_LOW_M1_THRESH_LOW_SET(x)                             (((x) << 14) & 0x001fc000)
-#define PHY_BB_SELF_CORR_LOW_M2_THRESH_LOW_MSB                                                        27
-#define PHY_BB_SELF_CORR_LOW_M2_THRESH_LOW_LSB                                                        21
-#define PHY_BB_SELF_CORR_LOW_M2_THRESH_LOW_MASK                                               0x0fe00000
-#define PHY_BB_SELF_CORR_LOW_M2_THRESH_LOW_GET(x)                             (((x) & 0x0fe00000) >> 21)
-#define PHY_BB_SELF_CORR_LOW_M2_THRESH_LOW_SET(x)                             (((x) << 21) & 0x0fe00000)
-
-/* macros for BB_synth_control */
-#define PHY_BB_SYNTH_CONTROL_ADDRESS                                                          0x00009874
-#define PHY_BB_SYNTH_CONTROL_OFFSET                                                           0x00009874
-#define PHY_BB_SYNTH_CONTROL_RFCHANFRAC_MSB                                                           16
-#define PHY_BB_SYNTH_CONTROL_RFCHANFRAC_LSB                                                            0
-#define PHY_BB_SYNTH_CONTROL_RFCHANFRAC_MASK                                                  0x0001ffff
-#define PHY_BB_SYNTH_CONTROL_RFCHANFRAC_GET(x)                                 (((x) & 0x0001ffff) >> 0)
-#define PHY_BB_SYNTH_CONTROL_RFCHANFRAC_SET(x)                                 (((x) << 0) & 0x0001ffff)
-#define PHY_BB_SYNTH_CONTROL_RFCHANNEL_MSB                                                            25
-#define PHY_BB_SYNTH_CONTROL_RFCHANNEL_LSB                                                            17
-#define PHY_BB_SYNTH_CONTROL_RFCHANNEL_MASK                                                   0x03fe0000
-#define PHY_BB_SYNTH_CONTROL_RFCHANNEL_GET(x)                                 (((x) & 0x03fe0000) >> 17)
-#define PHY_BB_SYNTH_CONTROL_RFCHANNEL_SET(x)                                 (((x) << 17) & 0x03fe0000)
-#define PHY_BB_SYNTH_CONTROL_RFAMODEREFSEL_MSB                                                        27
-#define PHY_BB_SYNTH_CONTROL_RFAMODEREFSEL_LSB                                                        26
-#define PHY_BB_SYNTH_CONTROL_RFAMODEREFSEL_MASK                                               0x0c000000
-#define PHY_BB_SYNTH_CONTROL_RFAMODEREFSEL_GET(x)                             (((x) & 0x0c000000) >> 26)
-#define PHY_BB_SYNTH_CONTROL_RFAMODEREFSEL_SET(x)                             (((x) << 26) & 0x0c000000)
-#define PHY_BB_SYNTH_CONTROL_RFFRACMODE_MSB                                                           28
-#define PHY_BB_SYNTH_CONTROL_RFFRACMODE_LSB                                                           28
-#define PHY_BB_SYNTH_CONTROL_RFFRACMODE_MASK                                                  0x10000000
-#define PHY_BB_SYNTH_CONTROL_RFFRACMODE_GET(x)                                (((x) & 0x10000000) >> 28)
-#define PHY_BB_SYNTH_CONTROL_RFFRACMODE_SET(x)                                (((x) << 28) & 0x10000000)
-#define PHY_BB_SYNTH_CONTROL_RFBMODE_MSB                                                              29
-#define PHY_BB_SYNTH_CONTROL_RFBMODE_LSB                                                              29
-#define PHY_BB_SYNTH_CONTROL_RFBMODE_MASK                                                     0x20000000
-#define PHY_BB_SYNTH_CONTROL_RFBMODE_GET(x)                                   (((x) & 0x20000000) >> 29)
-#define PHY_BB_SYNTH_CONTROL_RFBMODE_SET(x)                                   (((x) << 29) & 0x20000000)
-#define PHY_BB_SYNTH_CONTROL_RFSYNTH_CTRL_SSHIFT_MSB                                                  30
-#define PHY_BB_SYNTH_CONTROL_RFSYNTH_CTRL_SSHIFT_LSB                                                  30
-#define PHY_BB_SYNTH_CONTROL_RFSYNTH_CTRL_SSHIFT_MASK                                         0x40000000
-#define PHY_BB_SYNTH_CONTROL_RFSYNTH_CTRL_SSHIFT_GET(x)                       (((x) & 0x40000000) >> 30)
-#define PHY_BB_SYNTH_CONTROL_RFSYNTH_CTRL_SSHIFT_SET(x)                       (((x) << 30) & 0x40000000)
-
-/* macros for BB_addac_clk_select */
-#define PHY_BB_ADDAC_CLK_SELECT_ADDRESS                                                       0x00009878
-#define PHY_BB_ADDAC_CLK_SELECT_OFFSET                                                        0x00009878
-#define PHY_BB_ADDAC_CLK_SELECT_BB_DAC_CLK_SELECT_MSB                                                  3
-#define PHY_BB_ADDAC_CLK_SELECT_BB_DAC_CLK_SELECT_LSB                                                  2
-#define PHY_BB_ADDAC_CLK_SELECT_BB_DAC_CLK_SELECT_MASK                                        0x0000000c
-#define PHY_BB_ADDAC_CLK_SELECT_BB_DAC_CLK_SELECT_GET(x)                       (((x) & 0x0000000c) >> 2)
-#define PHY_BB_ADDAC_CLK_SELECT_BB_DAC_CLK_SELECT_SET(x)                       (((x) << 2) & 0x0000000c)
-#define PHY_BB_ADDAC_CLK_SELECT_BB_ADC_CLK_SELECT_MSB                                                  5
-#define PHY_BB_ADDAC_CLK_SELECT_BB_ADC_CLK_SELECT_LSB                                                  4
-#define PHY_BB_ADDAC_CLK_SELECT_BB_ADC_CLK_SELECT_MASK                                        0x00000030
-#define PHY_BB_ADDAC_CLK_SELECT_BB_ADC_CLK_SELECT_GET(x)                       (((x) & 0x00000030) >> 4)
-#define PHY_BB_ADDAC_CLK_SELECT_BB_ADC_CLK_SELECT_SET(x)                       (((x) << 4) & 0x00000030)
-
-/* macros for BB_pll_cntl */
-#define PHY_BB_PLL_CNTL_ADDRESS                                                               0x0000987c
-#define PHY_BB_PLL_CNTL_OFFSET                                                                0x0000987c
-#define PHY_BB_PLL_CNTL_BB_PLL_DIV_MSB                                                                 9
-#define PHY_BB_PLL_CNTL_BB_PLL_DIV_LSB                                                                 0
-#define PHY_BB_PLL_CNTL_BB_PLL_DIV_MASK                                                       0x000003ff
-#define PHY_BB_PLL_CNTL_BB_PLL_DIV_GET(x)                                      (((x) & 0x000003ff) >> 0)
-#define PHY_BB_PLL_CNTL_BB_PLL_DIV_SET(x)                                      (((x) << 0) & 0x000003ff)
-#define PHY_BB_PLL_CNTL_BB_PLL_REFDIV_MSB                                                             13
-#define PHY_BB_PLL_CNTL_BB_PLL_REFDIV_LSB                                                             10
-#define PHY_BB_PLL_CNTL_BB_PLL_REFDIV_MASK                                                    0x00003c00
-#define PHY_BB_PLL_CNTL_BB_PLL_REFDIV_GET(x)                                  (((x) & 0x00003c00) >> 10)
-#define PHY_BB_PLL_CNTL_BB_PLL_REFDIV_SET(x)                                  (((x) << 10) & 0x00003c00)
-#define PHY_BB_PLL_CNTL_BB_PLL_CLK_SEL_MSB                                                            15
-#define PHY_BB_PLL_CNTL_BB_PLL_CLK_SEL_LSB                                                            14
-#define PHY_BB_PLL_CNTL_BB_PLL_CLK_SEL_MASK                                                   0x0000c000
-#define PHY_BB_PLL_CNTL_BB_PLL_CLK_SEL_GET(x)                                 (((x) & 0x0000c000) >> 14)
-#define PHY_BB_PLL_CNTL_BB_PLL_CLK_SEL_SET(x)                                 (((x) << 14) & 0x0000c000)
-#define PHY_BB_PLL_CNTL_BB_PLLBYPASS_MSB                                                              16
-#define PHY_BB_PLL_CNTL_BB_PLLBYPASS_LSB                                                              16
-#define PHY_BB_PLL_CNTL_BB_PLLBYPASS_MASK                                                     0x00010000
-#define PHY_BB_PLL_CNTL_BB_PLLBYPASS_GET(x)                                   (((x) & 0x00010000) >> 16)
-#define PHY_BB_PLL_CNTL_BB_PLLBYPASS_SET(x)                                   (((x) << 16) & 0x00010000)
-#define PHY_BB_PLL_CNTL_BB_PLL_SETTLE_TIME_MSB                                                        27
-#define PHY_BB_PLL_CNTL_BB_PLL_SETTLE_TIME_LSB                                                        17
-#define PHY_BB_PLL_CNTL_BB_PLL_SETTLE_TIME_MASK                                               0x0ffe0000
-#define PHY_BB_PLL_CNTL_BB_PLL_SETTLE_TIME_GET(x)                             (((x) & 0x0ffe0000) >> 17)
-#define PHY_BB_PLL_CNTL_BB_PLL_SETTLE_TIME_SET(x)                             (((x) << 17) & 0x0ffe0000)
-
-/* macros for BB_vit_spur_mask_A */
-#define PHY_BB_VIT_SPUR_MASK_A_ADDRESS                                                        0x00009900
-#define PHY_BB_VIT_SPUR_MASK_A_OFFSET                                                         0x00009900
-#define PHY_BB_VIT_SPUR_MASK_A_CF_PUNC_MASK_A_MSB                                                      9
-#define PHY_BB_VIT_SPUR_MASK_A_CF_PUNC_MASK_A_LSB                                                      0
-#define PHY_BB_VIT_SPUR_MASK_A_CF_PUNC_MASK_A_MASK                                            0x000003ff
-#define PHY_BB_VIT_SPUR_MASK_A_CF_PUNC_MASK_A_GET(x)                           (((x) & 0x000003ff) >> 0)
-#define PHY_BB_VIT_SPUR_MASK_A_CF_PUNC_MASK_A_SET(x)                           (((x) << 0) & 0x000003ff)
-#define PHY_BB_VIT_SPUR_MASK_A_CF_PUNC_MASK_IDX_A_MSB                                                 16
-#define PHY_BB_VIT_SPUR_MASK_A_CF_PUNC_MASK_IDX_A_LSB                                                 10
-#define PHY_BB_VIT_SPUR_MASK_A_CF_PUNC_MASK_IDX_A_MASK                                        0x0001fc00
-#define PHY_BB_VIT_SPUR_MASK_A_CF_PUNC_MASK_IDX_A_GET(x)                      (((x) & 0x0001fc00) >> 10)
-#define PHY_BB_VIT_SPUR_MASK_A_CF_PUNC_MASK_IDX_A_SET(x)                      (((x) << 10) & 0x0001fc00)
-
-/* macros for BB_vit_spur_mask_B */
-#define PHY_BB_VIT_SPUR_MASK_B_ADDRESS                                                        0x00009904
-#define PHY_BB_VIT_SPUR_MASK_B_OFFSET                                                         0x00009904
-#define PHY_BB_VIT_SPUR_MASK_B_CF_PUNC_MASK_B_MSB                                                      9
-#define PHY_BB_VIT_SPUR_MASK_B_CF_PUNC_MASK_B_LSB                                                      0
-#define PHY_BB_VIT_SPUR_MASK_B_CF_PUNC_MASK_B_MASK                                            0x000003ff
-#define PHY_BB_VIT_SPUR_MASK_B_CF_PUNC_MASK_B_GET(x)                           (((x) & 0x000003ff) >> 0)
-#define PHY_BB_VIT_SPUR_MASK_B_CF_PUNC_MASK_B_SET(x)                           (((x) << 0) & 0x000003ff)
-#define PHY_BB_VIT_SPUR_MASK_B_CF_PUNC_MASK_IDX_B_MSB                                                 16
-#define PHY_BB_VIT_SPUR_MASK_B_CF_PUNC_MASK_IDX_B_LSB                                                 10
-#define PHY_BB_VIT_SPUR_MASK_B_CF_PUNC_MASK_IDX_B_MASK                                        0x0001fc00
-#define PHY_BB_VIT_SPUR_MASK_B_CF_PUNC_MASK_IDX_B_GET(x)                      (((x) & 0x0001fc00) >> 10)
-#define PHY_BB_VIT_SPUR_MASK_B_CF_PUNC_MASK_IDX_B_SET(x)                      (((x) << 10) & 0x0001fc00)
-
-/* macros for BB_pilot_spur_mask */
-#define PHY_BB_PILOT_SPUR_MASK_ADDRESS                                                        0x00009908
-#define PHY_BB_PILOT_SPUR_MASK_OFFSET                                                         0x00009908
-#define PHY_BB_PILOT_SPUR_MASK_CF_PILOT_MASK_A_MSB                                                     4
-#define PHY_BB_PILOT_SPUR_MASK_CF_PILOT_MASK_A_LSB                                                     0
-#define PHY_BB_PILOT_SPUR_MASK_CF_PILOT_MASK_A_MASK                                           0x0000001f
-#define PHY_BB_PILOT_SPUR_MASK_CF_PILOT_MASK_A_GET(x)                          (((x) & 0x0000001f) >> 0)
-#define PHY_BB_PILOT_SPUR_MASK_CF_PILOT_MASK_A_SET(x)                          (((x) << 0) & 0x0000001f)
-#define PHY_BB_PILOT_SPUR_MASK_CF_PILOT_MASK_IDX_A_MSB                                                11
-#define PHY_BB_PILOT_SPUR_MASK_CF_PILOT_MASK_IDX_A_LSB                                                 5
-#define PHY_BB_PILOT_SPUR_MASK_CF_PILOT_MASK_IDX_A_MASK                                       0x00000fe0
-#define PHY_BB_PILOT_SPUR_MASK_CF_PILOT_MASK_IDX_A_GET(x)                      (((x) & 0x00000fe0) >> 5)
-#define PHY_BB_PILOT_SPUR_MASK_CF_PILOT_MASK_IDX_A_SET(x)                      (((x) << 5) & 0x00000fe0)
-#define PHY_BB_PILOT_SPUR_MASK_CF_PILOT_MASK_B_MSB                                                    16
-#define PHY_BB_PILOT_SPUR_MASK_CF_PILOT_MASK_B_LSB                                                    12
-#define PHY_BB_PILOT_SPUR_MASK_CF_PILOT_MASK_B_MASK                                           0x0001f000
-#define PHY_BB_PILOT_SPUR_MASK_CF_PILOT_MASK_B_GET(x)                         (((x) & 0x0001f000) >> 12)
-#define PHY_BB_PILOT_SPUR_MASK_CF_PILOT_MASK_B_SET(x)                         (((x) << 12) & 0x0001f000)
-#define PHY_BB_PILOT_SPUR_MASK_CF_PILOT_MASK_IDX_B_MSB                                                23
-#define PHY_BB_PILOT_SPUR_MASK_CF_PILOT_MASK_IDX_B_LSB                                                17
-#define PHY_BB_PILOT_SPUR_MASK_CF_PILOT_MASK_IDX_B_MASK                                       0x00fe0000
-#define PHY_BB_PILOT_SPUR_MASK_CF_PILOT_MASK_IDX_B_GET(x)                     (((x) & 0x00fe0000) >> 17)
-#define PHY_BB_PILOT_SPUR_MASK_CF_PILOT_MASK_IDX_B_SET(x)                     (((x) << 17) & 0x00fe0000)
-
-/* macros for BB_chan_spur_mask */
-#define PHY_BB_CHAN_SPUR_MASK_ADDRESS                                                         0x0000990c
-#define PHY_BB_CHAN_SPUR_MASK_OFFSET                                                          0x0000990c
-#define PHY_BB_CHAN_SPUR_MASK_CF_CHAN_MASK_A_MSB                                                       4
-#define PHY_BB_CHAN_SPUR_MASK_CF_CHAN_MASK_A_LSB                                                       0
-#define PHY_BB_CHAN_SPUR_MASK_CF_CHAN_MASK_A_MASK                                             0x0000001f
-#define PHY_BB_CHAN_SPUR_MASK_CF_CHAN_MASK_A_GET(x)                            (((x) & 0x0000001f) >> 0)
-#define PHY_BB_CHAN_SPUR_MASK_CF_CHAN_MASK_A_SET(x)                            (((x) << 0) & 0x0000001f)
-#define PHY_BB_CHAN_SPUR_MASK_CF_CHAN_MASK_IDX_A_MSB                                                  11
-#define PHY_BB_CHAN_SPUR_MASK_CF_CHAN_MASK_IDX_A_LSB                                                   5
-#define PHY_BB_CHAN_SPUR_MASK_CF_CHAN_MASK_IDX_A_MASK                                         0x00000fe0
-#define PHY_BB_CHAN_SPUR_MASK_CF_CHAN_MASK_IDX_A_GET(x)                        (((x) & 0x00000fe0) >> 5)
-#define PHY_BB_CHAN_SPUR_MASK_CF_CHAN_MASK_IDX_A_SET(x)                        (((x) << 5) & 0x00000fe0)
-#define PHY_BB_CHAN_SPUR_MASK_CF_CHAN_MASK_B_MSB                                                      16
-#define PHY_BB_CHAN_SPUR_MASK_CF_CHAN_MASK_B_LSB                                                      12
-#define PHY_BB_CHAN_SPUR_MASK_CF_CHAN_MASK_B_MASK                                             0x0001f000
-#define PHY_BB_CHAN_SPUR_MASK_CF_CHAN_MASK_B_GET(x)                           (((x) & 0x0001f000) >> 12)
-#define PHY_BB_CHAN_SPUR_MASK_CF_CHAN_MASK_B_SET(x)                           (((x) << 12) & 0x0001f000)
-#define PHY_BB_CHAN_SPUR_MASK_CF_CHAN_MASK_IDX_B_MSB                                                  23
-#define PHY_BB_CHAN_SPUR_MASK_CF_CHAN_MASK_IDX_B_LSB                                                  17
-#define PHY_BB_CHAN_SPUR_MASK_CF_CHAN_MASK_IDX_B_MASK                                         0x00fe0000
-#define PHY_BB_CHAN_SPUR_MASK_CF_CHAN_MASK_IDX_B_GET(x)                       (((x) & 0x00fe0000) >> 17)
-#define PHY_BB_CHAN_SPUR_MASK_CF_CHAN_MASK_IDX_B_SET(x)                       (((x) << 17) & 0x00fe0000)
-
-/* macros for BB_spectral_scan */
-#define PHY_BB_SPECTRAL_SCAN_ADDRESS                                                          0x00009910
-#define PHY_BB_SPECTRAL_SCAN_OFFSET                                                           0x00009910
-#define PHY_BB_SPECTRAL_SCAN_SPECTRAL_SCAN_ENA_MSB                                                     0
-#define PHY_BB_SPECTRAL_SCAN_SPECTRAL_SCAN_ENA_LSB                                                     0
-#define PHY_BB_SPECTRAL_SCAN_SPECTRAL_SCAN_ENA_MASK                                           0x00000001
-#define PHY_BB_SPECTRAL_SCAN_SPECTRAL_SCAN_ENA_GET(x)                          (((x) & 0x00000001) >> 0)
-#define PHY_BB_SPECTRAL_SCAN_SPECTRAL_SCAN_ENA_SET(x)                          (((x) << 0) & 0x00000001)
-#define PHY_BB_SPECTRAL_SCAN_SPECTRAL_SCAN_ACTIVE_MSB                                                  1
-#define PHY_BB_SPECTRAL_SCAN_SPECTRAL_SCAN_ACTIVE_LSB                                                  1
-#define PHY_BB_SPECTRAL_SCAN_SPECTRAL_SCAN_ACTIVE_MASK                                        0x00000002
-#define PHY_BB_SPECTRAL_SCAN_SPECTRAL_SCAN_ACTIVE_GET(x)                       (((x) & 0x00000002) >> 1)
-#define PHY_BB_SPECTRAL_SCAN_SPECTRAL_SCAN_ACTIVE_SET(x)                       (((x) << 1) & 0x00000002)
-#define PHY_BB_SPECTRAL_SCAN_DISABLE_RADAR_TCTL_RST_MSB                                                2
-#define PHY_BB_SPECTRAL_SCAN_DISABLE_RADAR_TCTL_RST_LSB                                                2
-#define PHY_BB_SPECTRAL_SCAN_DISABLE_RADAR_TCTL_RST_MASK                                      0x00000004
-#define PHY_BB_SPECTRAL_SCAN_DISABLE_RADAR_TCTL_RST_GET(x)                     (((x) & 0x00000004) >> 2)
-#define PHY_BB_SPECTRAL_SCAN_DISABLE_RADAR_TCTL_RST_SET(x)                     (((x) << 2) & 0x00000004)
-#define PHY_BB_SPECTRAL_SCAN_DISABLE_PULSE_COARSE_LOW_MSB                                              3
-#define PHY_BB_SPECTRAL_SCAN_DISABLE_PULSE_COARSE_LOW_LSB                                              3
-#define PHY_BB_SPECTRAL_SCAN_DISABLE_PULSE_COARSE_LOW_MASK                                    0x00000008
-#define PHY_BB_SPECTRAL_SCAN_DISABLE_PULSE_COARSE_LOW_GET(x)                   (((x) & 0x00000008) >> 3)
-#define PHY_BB_SPECTRAL_SCAN_DISABLE_PULSE_COARSE_LOW_SET(x)                   (((x) << 3) & 0x00000008)
-#define PHY_BB_SPECTRAL_SCAN_SPECTRAL_SCAN_FFT_PERIOD_MSB                                              7
-#define PHY_BB_SPECTRAL_SCAN_SPECTRAL_SCAN_FFT_PERIOD_LSB                                              4
-#define PHY_BB_SPECTRAL_SCAN_SPECTRAL_SCAN_FFT_PERIOD_MASK                                    0x000000f0
-#define PHY_BB_SPECTRAL_SCAN_SPECTRAL_SCAN_FFT_PERIOD_GET(x)                   (((x) & 0x000000f0) >> 4)
-#define PHY_BB_SPECTRAL_SCAN_SPECTRAL_SCAN_FFT_PERIOD_SET(x)                   (((x) << 4) & 0x000000f0)
-#define PHY_BB_SPECTRAL_SCAN_SPECTRAL_SCAN_PERIOD_MSB                                                 15
-#define PHY_BB_SPECTRAL_SCAN_SPECTRAL_SCAN_PERIOD_LSB                                                  8
-#define PHY_BB_SPECTRAL_SCAN_SPECTRAL_SCAN_PERIOD_MASK                                        0x0000ff00
-#define PHY_BB_SPECTRAL_SCAN_SPECTRAL_SCAN_PERIOD_GET(x)                       (((x) & 0x0000ff00) >> 8)
-#define PHY_BB_SPECTRAL_SCAN_SPECTRAL_SCAN_PERIOD_SET(x)                       (((x) << 8) & 0x0000ff00)
-#define PHY_BB_SPECTRAL_SCAN_SPECTRAL_SCAN_COUNT_MSB                                                  27
-#define PHY_BB_SPECTRAL_SCAN_SPECTRAL_SCAN_COUNT_LSB                                                  16
-#define PHY_BB_SPECTRAL_SCAN_SPECTRAL_SCAN_COUNT_MASK                                         0x0fff0000
-#define PHY_BB_SPECTRAL_SCAN_SPECTRAL_SCAN_COUNT_GET(x)                       (((x) & 0x0fff0000) >> 16)
-#define PHY_BB_SPECTRAL_SCAN_SPECTRAL_SCAN_COUNT_SET(x)                       (((x) << 16) & 0x0fff0000)
-#define PHY_BB_SPECTRAL_SCAN_SPECTRAL_SCAN_SHORT_RPT_MSB                                              28
-#define PHY_BB_SPECTRAL_SCAN_SPECTRAL_SCAN_SHORT_RPT_LSB                                              28
-#define PHY_BB_SPECTRAL_SCAN_SPECTRAL_SCAN_SHORT_RPT_MASK                                     0x10000000
-#define PHY_BB_SPECTRAL_SCAN_SPECTRAL_SCAN_SHORT_RPT_GET(x)                   (((x) & 0x10000000) >> 28)
-#define PHY_BB_SPECTRAL_SCAN_SPECTRAL_SCAN_SHORT_RPT_SET(x)                   (((x) << 28) & 0x10000000)
-#define PHY_BB_SPECTRAL_SCAN_SPECTRAL_SCAN_PRIORITY_MSB                                               29
-#define PHY_BB_SPECTRAL_SCAN_SPECTRAL_SCAN_PRIORITY_LSB                                               29
-#define PHY_BB_SPECTRAL_SCAN_SPECTRAL_SCAN_PRIORITY_MASK                                      0x20000000
-#define PHY_BB_SPECTRAL_SCAN_SPECTRAL_SCAN_PRIORITY_GET(x)                    (((x) & 0x20000000) >> 29)
-#define PHY_BB_SPECTRAL_SCAN_SPECTRAL_SCAN_PRIORITY_SET(x)                    (((x) << 29) & 0x20000000)
-#define PHY_BB_SPECTRAL_SCAN_SPECTRAL_SCAN_USE_ERR5_MSB                                               30
-#define PHY_BB_SPECTRAL_SCAN_SPECTRAL_SCAN_USE_ERR5_LSB                                               30
-#define PHY_BB_SPECTRAL_SCAN_SPECTRAL_SCAN_USE_ERR5_MASK                                      0x40000000
-#define PHY_BB_SPECTRAL_SCAN_SPECTRAL_SCAN_USE_ERR5_GET(x)                    (((x) & 0x40000000) >> 30)
-#define PHY_BB_SPECTRAL_SCAN_SPECTRAL_SCAN_USE_ERR5_SET(x)                    (((x) << 30) & 0x40000000)
-
-/* macros for BB_analog_power_on_time */
-#define PHY_BB_ANALOG_POWER_ON_TIME_ADDRESS                                                   0x00009914
-#define PHY_BB_ANALOG_POWER_ON_TIME_OFFSET                                                    0x00009914
-#define PHY_BB_ANALOG_POWER_ON_TIME_ACTIVE_TO_RECEIVE_MSB                                             13
-#define PHY_BB_ANALOG_POWER_ON_TIME_ACTIVE_TO_RECEIVE_LSB                                              0
-#define PHY_BB_ANALOG_POWER_ON_TIME_ACTIVE_TO_RECEIVE_MASK                                    0x00003fff
-#define PHY_BB_ANALOG_POWER_ON_TIME_ACTIVE_TO_RECEIVE_GET(x)                   (((x) & 0x00003fff) >> 0)
-#define PHY_BB_ANALOG_POWER_ON_TIME_ACTIVE_TO_RECEIVE_SET(x)                   (((x) << 0) & 0x00003fff)
-
-/* macros for BB_search_start_delay */
-#define PHY_BB_SEARCH_START_DELAY_ADDRESS                                                     0x00009918
-#define PHY_BB_SEARCH_START_DELAY_OFFSET                                                      0x00009918
-#define PHY_BB_SEARCH_START_DELAY_SEARCH_START_DELAY_MSB                                              11
-#define PHY_BB_SEARCH_START_DELAY_SEARCH_START_DELAY_LSB                                               0
-#define PHY_BB_SEARCH_START_DELAY_SEARCH_START_DELAY_MASK                                     0x00000fff
-#define PHY_BB_SEARCH_START_DELAY_SEARCH_START_DELAY_GET(x)                    (((x) & 0x00000fff) >> 0)
-#define PHY_BB_SEARCH_START_DELAY_SEARCH_START_DELAY_SET(x)                    (((x) << 0) & 0x00000fff)
-#define PHY_BB_SEARCH_START_DELAY_ENABLE_FLT_SVD_MSB                                                  12
-#define PHY_BB_SEARCH_START_DELAY_ENABLE_FLT_SVD_LSB                                                  12
-#define PHY_BB_SEARCH_START_DELAY_ENABLE_FLT_SVD_MASK                                         0x00001000
-#define PHY_BB_SEARCH_START_DELAY_ENABLE_FLT_SVD_GET(x)                       (((x) & 0x00001000) >> 12)
-#define PHY_BB_SEARCH_START_DELAY_ENABLE_FLT_SVD_SET(x)                       (((x) << 12) & 0x00001000)
-#define PHY_BB_SEARCH_START_DELAY_ENABLE_SEND_CHAN_MSB                                                13
-#define PHY_BB_SEARCH_START_DELAY_ENABLE_SEND_CHAN_LSB                                                13
-#define PHY_BB_SEARCH_START_DELAY_ENABLE_SEND_CHAN_MASK                                       0x00002000
-#define PHY_BB_SEARCH_START_DELAY_ENABLE_SEND_CHAN_GET(x)                     (((x) & 0x00002000) >> 13)
-#define PHY_BB_SEARCH_START_DELAY_ENABLE_SEND_CHAN_SET(x)                     (((x) << 13) & 0x00002000)
-
-/* macros for BB_max_rx_length */
-#define PHY_BB_MAX_RX_LENGTH_ADDRESS                                                          0x0000991c
-#define PHY_BB_MAX_RX_LENGTH_OFFSET                                                           0x0000991c
-#define PHY_BB_MAX_RX_LENGTH_MAX_RX_LENGTH_MSB                                                        11
-#define PHY_BB_MAX_RX_LENGTH_MAX_RX_LENGTH_LSB                                                         0
-#define PHY_BB_MAX_RX_LENGTH_MAX_RX_LENGTH_MASK                                               0x00000fff
-#define PHY_BB_MAX_RX_LENGTH_MAX_RX_LENGTH_GET(x)                              (((x) & 0x00000fff) >> 0)
-#define PHY_BB_MAX_RX_LENGTH_MAX_RX_LENGTH_SET(x)                              (((x) << 0) & 0x00000fff)
-#define PHY_BB_MAX_RX_LENGTH_MAX_HT_LENGTH_MSB                                                        29
-#define PHY_BB_MAX_RX_LENGTH_MAX_HT_LENGTH_LSB                                                        12
-#define PHY_BB_MAX_RX_LENGTH_MAX_HT_LENGTH_MASK                                               0x3ffff000
-#define PHY_BB_MAX_RX_LENGTH_MAX_HT_LENGTH_GET(x)                             (((x) & 0x3ffff000) >> 12)
-#define PHY_BB_MAX_RX_LENGTH_MAX_HT_LENGTH_SET(x)                             (((x) << 12) & 0x3ffff000)
-
-/* macros for BB_timing_control_4 */
-#define PHY_BB_TIMING_CONTROL_4_ADDRESS                                                       0x00009920
-#define PHY_BB_TIMING_CONTROL_4_OFFSET                                                        0x00009920
-#define PHY_BB_TIMING_CONTROL_4_CAL_LG_COUNT_MAX_MSB                                                  15
-#define PHY_BB_TIMING_CONTROL_4_CAL_LG_COUNT_MAX_LSB                                                  12
-#define PHY_BB_TIMING_CONTROL_4_CAL_LG_COUNT_MAX_MASK                                         0x0000f000
-#define PHY_BB_TIMING_CONTROL_4_CAL_LG_COUNT_MAX_GET(x)                       (((x) & 0x0000f000) >> 12)
-#define PHY_BB_TIMING_CONTROL_4_CAL_LG_COUNT_MAX_SET(x)                       (((x) << 12) & 0x0000f000)
-#define PHY_BB_TIMING_CONTROL_4_DO_GAIN_DC_IQ_CAL_MSB                                                 16
-#define PHY_BB_TIMING_CONTROL_4_DO_GAIN_DC_IQ_CAL_LSB                                                 16
-#define PHY_BB_TIMING_CONTROL_4_DO_GAIN_DC_IQ_CAL_MASK                                        0x00010000
-#define PHY_BB_TIMING_CONTROL_4_DO_GAIN_DC_IQ_CAL_GET(x)                      (((x) & 0x00010000) >> 16)
-#define PHY_BB_TIMING_CONTROL_4_DO_GAIN_DC_IQ_CAL_SET(x)                      (((x) << 16) & 0x00010000)
-#define PHY_BB_TIMING_CONTROL_4_USE_PILOT_TRACK_DF_MSB                                                20
-#define PHY_BB_TIMING_CONTROL_4_USE_PILOT_TRACK_DF_LSB                                                17
-#define PHY_BB_TIMING_CONTROL_4_USE_PILOT_TRACK_DF_MASK                                       0x001e0000
-#define PHY_BB_TIMING_CONTROL_4_USE_PILOT_TRACK_DF_GET(x)                     (((x) & 0x001e0000) >> 17)
-#define PHY_BB_TIMING_CONTROL_4_USE_PILOT_TRACK_DF_SET(x)                     (((x) << 17) & 0x001e0000)
-#define PHY_BB_TIMING_CONTROL_4_EARLY_TRIGGER_THR_MSB                                                 27
-#define PHY_BB_TIMING_CONTROL_4_EARLY_TRIGGER_THR_LSB                                                 21
-#define PHY_BB_TIMING_CONTROL_4_EARLY_TRIGGER_THR_MASK                                        0x0fe00000
-#define PHY_BB_TIMING_CONTROL_4_EARLY_TRIGGER_THR_GET(x)                      (((x) & 0x0fe00000) >> 21)
-#define PHY_BB_TIMING_CONTROL_4_EARLY_TRIGGER_THR_SET(x)                      (((x) << 21) & 0x0fe00000)
-#define PHY_BB_TIMING_CONTROL_4_ENABLE_PILOT_MASK_MSB                                                 28
-#define PHY_BB_TIMING_CONTROL_4_ENABLE_PILOT_MASK_LSB                                                 28
-#define PHY_BB_TIMING_CONTROL_4_ENABLE_PILOT_MASK_MASK                                        0x10000000
-#define PHY_BB_TIMING_CONTROL_4_ENABLE_PILOT_MASK_GET(x)                      (((x) & 0x10000000) >> 28)
-#define PHY_BB_TIMING_CONTROL_4_ENABLE_PILOT_MASK_SET(x)                      (((x) << 28) & 0x10000000)
-#define PHY_BB_TIMING_CONTROL_4_ENABLE_CHAN_MASK_MSB                                                  29
-#define PHY_BB_TIMING_CONTROL_4_ENABLE_CHAN_MASK_LSB                                                  29
-#define PHY_BB_TIMING_CONTROL_4_ENABLE_CHAN_MASK_MASK                                         0x20000000
-#define PHY_BB_TIMING_CONTROL_4_ENABLE_CHAN_MASK_GET(x)                       (((x) & 0x20000000) >> 29)
-#define PHY_BB_TIMING_CONTROL_4_ENABLE_CHAN_MASK_SET(x)                       (((x) << 29) & 0x20000000)
-#define PHY_BB_TIMING_CONTROL_4_ENABLE_SPUR_FILTER_MSB                                                30
-#define PHY_BB_TIMING_CONTROL_4_ENABLE_SPUR_FILTER_LSB                                                30
-#define PHY_BB_TIMING_CONTROL_4_ENABLE_SPUR_FILTER_MASK                                       0x40000000
-#define PHY_BB_TIMING_CONTROL_4_ENABLE_SPUR_FILTER_GET(x)                     (((x) & 0x40000000) >> 30)
-#define PHY_BB_TIMING_CONTROL_4_ENABLE_SPUR_FILTER_SET(x)                     (((x) << 30) & 0x40000000)
-#define PHY_BB_TIMING_CONTROL_4_ENABLE_SPUR_RSSI_MSB                                                  31
-#define PHY_BB_TIMING_CONTROL_4_ENABLE_SPUR_RSSI_LSB                                                  31
-#define PHY_BB_TIMING_CONTROL_4_ENABLE_SPUR_RSSI_MASK                                         0x80000000
-#define PHY_BB_TIMING_CONTROL_4_ENABLE_SPUR_RSSI_GET(x)                       (((x) & 0x80000000) >> 31)
-#define PHY_BB_TIMING_CONTROL_4_ENABLE_SPUR_RSSI_SET(x)                       (((x) << 31) & 0x80000000)
-
-/* macros for BB_timing_control_5 */
-#define PHY_BB_TIMING_CONTROL_5_ADDRESS                                                       0x00009924
-#define PHY_BB_TIMING_CONTROL_5_OFFSET                                                        0x00009924
-#define PHY_BB_TIMING_CONTROL_5_ENABLE_CYCPWR_THR1_MSB                                                 0
-#define PHY_BB_TIMING_CONTROL_5_ENABLE_CYCPWR_THR1_LSB                                                 0
-#define PHY_BB_TIMING_CONTROL_5_ENABLE_CYCPWR_THR1_MASK                                       0x00000001
-#define PHY_BB_TIMING_CONTROL_5_ENABLE_CYCPWR_THR1_GET(x)                      (((x) & 0x00000001) >> 0)
-#define PHY_BB_TIMING_CONTROL_5_ENABLE_CYCPWR_THR1_SET(x)                      (((x) << 0) & 0x00000001)
-#define PHY_BB_TIMING_CONTROL_5_CYCPWR_THR1_MSB                                                        7
-#define PHY_BB_TIMING_CONTROL_5_CYCPWR_THR1_LSB                                                        1
-#define PHY_BB_TIMING_CONTROL_5_CYCPWR_THR1_MASK                                              0x000000fe
-#define PHY_BB_TIMING_CONTROL_5_CYCPWR_THR1_GET(x)                             (((x) & 0x000000fe) >> 1)
-#define PHY_BB_TIMING_CONTROL_5_CYCPWR_THR1_SET(x)                             (((x) << 1) & 0x000000fe)
-#define PHY_BB_TIMING_CONTROL_5_ENABLE_RSSI_THR1A_MSB                                                 15
-#define PHY_BB_TIMING_CONTROL_5_ENABLE_RSSI_THR1A_LSB                                                 15
-#define PHY_BB_TIMING_CONTROL_5_ENABLE_RSSI_THR1A_MASK                                        0x00008000
-#define PHY_BB_TIMING_CONTROL_5_ENABLE_RSSI_THR1A_GET(x)                      (((x) & 0x00008000) >> 15)
-#define PHY_BB_TIMING_CONTROL_5_ENABLE_RSSI_THR1A_SET(x)                      (((x) << 15) & 0x00008000)
-#define PHY_BB_TIMING_CONTROL_5_RSSI_THR1A_MSB                                                        22
-#define PHY_BB_TIMING_CONTROL_5_RSSI_THR1A_LSB                                                        16
-#define PHY_BB_TIMING_CONTROL_5_RSSI_THR1A_MASK                                               0x007f0000
-#define PHY_BB_TIMING_CONTROL_5_RSSI_THR1A_GET(x)                             (((x) & 0x007f0000) >> 16)
-#define PHY_BB_TIMING_CONTROL_5_RSSI_THR1A_SET(x)                             (((x) << 16) & 0x007f0000)
-#define PHY_BB_TIMING_CONTROL_5_LONG_SC_THRESH_HI_RSSI_MSB                                            29
-#define PHY_BB_TIMING_CONTROL_5_LONG_SC_THRESH_HI_RSSI_LSB                                            23
-#define PHY_BB_TIMING_CONTROL_5_LONG_SC_THRESH_HI_RSSI_MASK                                   0x3f800000
-#define PHY_BB_TIMING_CONTROL_5_LONG_SC_THRESH_HI_RSSI_GET(x)                 (((x) & 0x3f800000) >> 23)
-#define PHY_BB_TIMING_CONTROL_5_LONG_SC_THRESH_HI_RSSI_SET(x)                 (((x) << 23) & 0x3f800000)
-#define PHY_BB_TIMING_CONTROL_5_FORCED_AGC_STR_PRI_MSB                                                30
-#define PHY_BB_TIMING_CONTROL_5_FORCED_AGC_STR_PRI_LSB                                                30
-#define PHY_BB_TIMING_CONTROL_5_FORCED_AGC_STR_PRI_MASK                                       0x40000000
-#define PHY_BB_TIMING_CONTROL_5_FORCED_AGC_STR_PRI_GET(x)                     (((x) & 0x40000000) >> 30)
-#define PHY_BB_TIMING_CONTROL_5_FORCED_AGC_STR_PRI_SET(x)                     (((x) << 30) & 0x40000000)
-#define PHY_BB_TIMING_CONTROL_5_FORCED_AGC_STR_PRI_EN_MSB                                             31
-#define PHY_BB_TIMING_CONTROL_5_FORCED_AGC_STR_PRI_EN_LSB                                             31
-#define PHY_BB_TIMING_CONTROL_5_FORCED_AGC_STR_PRI_EN_MASK                                    0x80000000
-#define PHY_BB_TIMING_CONTROL_5_FORCED_AGC_STR_PRI_EN_GET(x)                  (((x) & 0x80000000) >> 31)
-#define PHY_BB_TIMING_CONTROL_5_FORCED_AGC_STR_PRI_EN_SET(x)                  (((x) << 31) & 0x80000000)
-
-/* macros for BB_phyonly_warm_reset */
-#define PHY_BB_PHYONLY_WARM_RESET_ADDRESS                                                     0x00009928
-#define PHY_BB_PHYONLY_WARM_RESET_OFFSET                                                      0x00009928
-#define PHY_BB_PHYONLY_WARM_RESET_PHYONLY_RST_WARM_L_MSB                                               0
-#define PHY_BB_PHYONLY_WARM_RESET_PHYONLY_RST_WARM_L_LSB                                               0
-#define PHY_BB_PHYONLY_WARM_RESET_PHYONLY_RST_WARM_L_MASK                                     0x00000001
-#define PHY_BB_PHYONLY_WARM_RESET_PHYONLY_RST_WARM_L_GET(x)                    (((x) & 0x00000001) >> 0)
-#define PHY_BB_PHYONLY_WARM_RESET_PHYONLY_RST_WARM_L_SET(x)                    (((x) << 0) & 0x00000001)
-
-/* macros for BB_phyonly_control */
-#define PHY_BB_PHYONLY_CONTROL_ADDRESS                                                        0x0000992c
-#define PHY_BB_PHYONLY_CONTROL_OFFSET                                                         0x0000992c
-#define PHY_BB_PHYONLY_CONTROL_RX_DRAIN_RATE_MSB                                                       0
-#define PHY_BB_PHYONLY_CONTROL_RX_DRAIN_RATE_LSB                                                       0
-#define PHY_BB_PHYONLY_CONTROL_RX_DRAIN_RATE_MASK                                             0x00000001
-#define PHY_BB_PHYONLY_CONTROL_RX_DRAIN_RATE_GET(x)                            (((x) & 0x00000001) >> 0)
-#define PHY_BB_PHYONLY_CONTROL_RX_DRAIN_RATE_SET(x)                            (((x) << 0) & 0x00000001)
-#define PHY_BB_PHYONLY_CONTROL_LATE_TX_SIGNAL_SYMBOL_MSB                                               1
-#define PHY_BB_PHYONLY_CONTROL_LATE_TX_SIGNAL_SYMBOL_LSB                                               1
-#define PHY_BB_PHYONLY_CONTROL_LATE_TX_SIGNAL_SYMBOL_MASK                                     0x00000002
-#define PHY_BB_PHYONLY_CONTROL_LATE_TX_SIGNAL_SYMBOL_GET(x)                    (((x) & 0x00000002) >> 1)
-#define PHY_BB_PHYONLY_CONTROL_LATE_TX_SIGNAL_SYMBOL_SET(x)                    (((x) << 1) & 0x00000002)
-#define PHY_BB_PHYONLY_CONTROL_GENERATE_SCRAMBLER_MSB                                                  2
-#define PHY_BB_PHYONLY_CONTROL_GENERATE_SCRAMBLER_LSB                                                  2
-#define PHY_BB_PHYONLY_CONTROL_GENERATE_SCRAMBLER_MASK                                        0x00000004
-#define PHY_BB_PHYONLY_CONTROL_GENERATE_SCRAMBLER_GET(x)                       (((x) & 0x00000004) >> 2)
-#define PHY_BB_PHYONLY_CONTROL_GENERATE_SCRAMBLER_SET(x)                       (((x) << 2) & 0x00000004)
-#define PHY_BB_PHYONLY_CONTROL_TX_ANTENNA_SELECT_MSB                                                   3
-#define PHY_BB_PHYONLY_CONTROL_TX_ANTENNA_SELECT_LSB                                                   3
-#define PHY_BB_PHYONLY_CONTROL_TX_ANTENNA_SELECT_MASK                                         0x00000008
-#define PHY_BB_PHYONLY_CONTROL_TX_ANTENNA_SELECT_GET(x)                        (((x) & 0x00000008) >> 3)
-#define PHY_BB_PHYONLY_CONTROL_TX_ANTENNA_SELECT_SET(x)                        (((x) << 3) & 0x00000008)
-#define PHY_BB_PHYONLY_CONTROL_STATIC_TX_ANTENNA_MSB                                                   4
-#define PHY_BB_PHYONLY_CONTROL_STATIC_TX_ANTENNA_LSB                                                   4
-#define PHY_BB_PHYONLY_CONTROL_STATIC_TX_ANTENNA_MASK                                         0x00000010
-#define PHY_BB_PHYONLY_CONTROL_STATIC_TX_ANTENNA_GET(x)                        (((x) & 0x00000010) >> 4)
-#define PHY_BB_PHYONLY_CONTROL_STATIC_TX_ANTENNA_SET(x)                        (((x) << 4) & 0x00000010)
-#define PHY_BB_PHYONLY_CONTROL_RX_ANTENNA_SELECT_MSB                                                   5
-#define PHY_BB_PHYONLY_CONTROL_RX_ANTENNA_SELECT_LSB                                                   5
-#define PHY_BB_PHYONLY_CONTROL_RX_ANTENNA_SELECT_MASK                                         0x00000020
-#define PHY_BB_PHYONLY_CONTROL_RX_ANTENNA_SELECT_GET(x)                        (((x) & 0x00000020) >> 5)
-#define PHY_BB_PHYONLY_CONTROL_RX_ANTENNA_SELECT_SET(x)                        (((x) << 5) & 0x00000020)
-#define PHY_BB_PHYONLY_CONTROL_STATIC_RX_ANTENNA_MSB                                                   6
-#define PHY_BB_PHYONLY_CONTROL_STATIC_RX_ANTENNA_LSB                                                   6
-#define PHY_BB_PHYONLY_CONTROL_STATIC_RX_ANTENNA_MASK                                         0x00000040
-#define PHY_BB_PHYONLY_CONTROL_STATIC_RX_ANTENNA_GET(x)                        (((x) & 0x00000040) >> 6)
-#define PHY_BB_PHYONLY_CONTROL_STATIC_RX_ANTENNA_SET(x)                        (((x) << 6) & 0x00000040)
-#define PHY_BB_PHYONLY_CONTROL_EN_LOW_FREQ_SLEEP_MSB                                                   7
-#define PHY_BB_PHYONLY_CONTROL_EN_LOW_FREQ_SLEEP_LSB                                                   7
-#define PHY_BB_PHYONLY_CONTROL_EN_LOW_FREQ_SLEEP_MASK                                         0x00000080
-#define PHY_BB_PHYONLY_CONTROL_EN_LOW_FREQ_SLEEP_GET(x)                        (((x) & 0x00000080) >> 7)
-#define PHY_BB_PHYONLY_CONTROL_EN_LOW_FREQ_SLEEP_SET(x)                        (((x) << 7) & 0x00000080)
-
-/* macros for BB_powertx_rate1 */
-#define PHY_BB_POWERTX_RATE1_ADDRESS                                                          0x00009934
-#define PHY_BB_POWERTX_RATE1_OFFSET                                                           0x00009934
-#define PHY_BB_POWERTX_RATE1_POWERTX_0_MSB                                                             5
-#define PHY_BB_POWERTX_RATE1_POWERTX_0_LSB                                                             0
-#define PHY_BB_POWERTX_RATE1_POWERTX_0_MASK                                                   0x0000003f
-#define PHY_BB_POWERTX_RATE1_POWERTX_0_GET(x)                                  (((x) & 0x0000003f) >> 0)
-#define PHY_BB_POWERTX_RATE1_POWERTX_0_SET(x)                                  (((x) << 0) & 0x0000003f)
-#define PHY_BB_POWERTX_RATE1_POWERTX_1_MSB                                                            13
-#define PHY_BB_POWERTX_RATE1_POWERTX_1_LSB                                                             8
-#define PHY_BB_POWERTX_RATE1_POWERTX_1_MASK                                                   0x00003f00
-#define PHY_BB_POWERTX_RATE1_POWERTX_1_GET(x)                                  (((x) & 0x00003f00) >> 8)
-#define PHY_BB_POWERTX_RATE1_POWERTX_1_SET(x)                                  (((x) << 8) & 0x00003f00)
-#define PHY_BB_POWERTX_RATE1_POWERTX_2_MSB                                                            21
-#define PHY_BB_POWERTX_RATE1_POWERTX_2_LSB                                                            16
-#define PHY_BB_POWERTX_RATE1_POWERTX_2_MASK                                                   0x003f0000
-#define PHY_BB_POWERTX_RATE1_POWERTX_2_GET(x)                                 (((x) & 0x003f0000) >> 16)
-#define PHY_BB_POWERTX_RATE1_POWERTX_2_SET(x)                                 (((x) << 16) & 0x003f0000)
-#define PHY_BB_POWERTX_RATE1_POWERTX_3_MSB                                                            29
-#define PHY_BB_POWERTX_RATE1_POWERTX_3_LSB                                                            24
-#define PHY_BB_POWERTX_RATE1_POWERTX_3_MASK                                                   0x3f000000
-#define PHY_BB_POWERTX_RATE1_POWERTX_3_GET(x)                                 (((x) & 0x3f000000) >> 24)
-#define PHY_BB_POWERTX_RATE1_POWERTX_3_SET(x)                                 (((x) << 24) & 0x3f000000)
-
-/* macros for BB_powertx_rate2 */
-#define PHY_BB_POWERTX_RATE2_ADDRESS                                                          0x00009938
-#define PHY_BB_POWERTX_RATE2_OFFSET                                                           0x00009938
-#define PHY_BB_POWERTX_RATE2_POWERTX_4_MSB                                                             5
-#define PHY_BB_POWERTX_RATE2_POWERTX_4_LSB                                                             0
-#define PHY_BB_POWERTX_RATE2_POWERTX_4_MASK                                                   0x0000003f
-#define PHY_BB_POWERTX_RATE2_POWERTX_4_GET(x)                                  (((x) & 0x0000003f) >> 0)
-#define PHY_BB_POWERTX_RATE2_POWERTX_4_SET(x)                                  (((x) << 0) & 0x0000003f)
-#define PHY_BB_POWERTX_RATE2_POWERTX_5_MSB                                                            13
-#define PHY_BB_POWERTX_RATE2_POWERTX_5_LSB                                                             8
-#define PHY_BB_POWERTX_RATE2_POWERTX_5_MASK                                                   0x00003f00
-#define PHY_BB_POWERTX_RATE2_POWERTX_5_GET(x)                                  (((x) & 0x00003f00) >> 8)
-#define PHY_BB_POWERTX_RATE2_POWERTX_5_SET(x)                                  (((x) << 8) & 0x00003f00)
-#define PHY_BB_POWERTX_RATE2_POWERTX_6_MSB                                                            21
-#define PHY_BB_POWERTX_RATE2_POWERTX_6_LSB                                                            16
-#define PHY_BB_POWERTX_RATE2_POWERTX_6_MASK                                                   0x003f0000
-#define PHY_BB_POWERTX_RATE2_POWERTX_6_GET(x)                                 (((x) & 0x003f0000) >> 16)
-#define PHY_BB_POWERTX_RATE2_POWERTX_6_SET(x)                                 (((x) << 16) & 0x003f0000)
-#define PHY_BB_POWERTX_RATE2_POWERTX_7_MSB                                                            29
-#define PHY_BB_POWERTX_RATE2_POWERTX_7_LSB                                                            24
-#define PHY_BB_POWERTX_RATE2_POWERTX_7_MASK                                                   0x3f000000
-#define PHY_BB_POWERTX_RATE2_POWERTX_7_GET(x)                                 (((x) & 0x3f000000) >> 24)
-#define PHY_BB_POWERTX_RATE2_POWERTX_7_SET(x)                                 (((x) << 24) & 0x3f000000)
-
-/* macros for BB_powertx_max */
-#define PHY_BB_POWERTX_MAX_ADDRESS                                                            0x0000993c
-#define PHY_BB_POWERTX_MAX_OFFSET                                                             0x0000993c
-#define PHY_BB_POWERTX_MAX_USE_PER_PACKET_POWERTX_MAX_MSB                                              6
-#define PHY_BB_POWERTX_MAX_USE_PER_PACKET_POWERTX_MAX_LSB                                              6
-#define PHY_BB_POWERTX_MAX_USE_PER_PACKET_POWERTX_MAX_MASK                                    0x00000040
-#define PHY_BB_POWERTX_MAX_USE_PER_PACKET_POWERTX_MAX_GET(x)                   (((x) & 0x00000040) >> 6)
-#define PHY_BB_POWERTX_MAX_USE_PER_PACKET_POWERTX_MAX_SET(x)                   (((x) << 6) & 0x00000040)
-
-/* macros for BB_extension_radar */
-#define PHY_BB_EXTENSION_RADAR_ADDRESS                                                        0x00009940
-#define PHY_BB_EXTENSION_RADAR_OFFSET                                                         0x00009940
-#define PHY_BB_EXTENSION_RADAR_BLOCKER40_MAX_RADAR_MSB                                                13
-#define PHY_BB_EXTENSION_RADAR_BLOCKER40_MAX_RADAR_LSB                                                 8
-#define PHY_BB_EXTENSION_RADAR_BLOCKER40_MAX_RADAR_MASK                                       0x00003f00
-#define PHY_BB_EXTENSION_RADAR_BLOCKER40_MAX_RADAR_GET(x)                      (((x) & 0x00003f00) >> 8)
-#define PHY_BB_EXTENSION_RADAR_BLOCKER40_MAX_RADAR_SET(x)                      (((x) << 8) & 0x00003f00)
-#define PHY_BB_EXTENSION_RADAR_ENABLE_EXT_RADAR_MSB                                                   14
-#define PHY_BB_EXTENSION_RADAR_ENABLE_EXT_RADAR_LSB                                                   14
-#define PHY_BB_EXTENSION_RADAR_ENABLE_EXT_RADAR_MASK                                          0x00004000
-#define PHY_BB_EXTENSION_RADAR_ENABLE_EXT_RADAR_GET(x)                        (((x) & 0x00004000) >> 14)
-#define PHY_BB_EXTENSION_RADAR_ENABLE_EXT_RADAR_SET(x)                        (((x) << 14) & 0x00004000)
-#define PHY_BB_EXTENSION_RADAR_RADAR_DC_PWR_THRESH_MSB                                                22
-#define PHY_BB_EXTENSION_RADAR_RADAR_DC_PWR_THRESH_LSB                                                15
-#define PHY_BB_EXTENSION_RADAR_RADAR_DC_PWR_THRESH_MASK                                       0x007f8000
-#define PHY_BB_EXTENSION_RADAR_RADAR_DC_PWR_THRESH_GET(x)                     (((x) & 0x007f8000) >> 15)
-#define PHY_BB_EXTENSION_RADAR_RADAR_DC_PWR_THRESH_SET(x)                     (((x) << 15) & 0x007f8000)
-#define PHY_BB_EXTENSION_RADAR_RADAR_LB_DC_CAP_MSB                                                    30
-#define PHY_BB_EXTENSION_RADAR_RADAR_LB_DC_CAP_LSB                                                    23
-#define PHY_BB_EXTENSION_RADAR_RADAR_LB_DC_CAP_MASK                                           0x7f800000
-#define PHY_BB_EXTENSION_RADAR_RADAR_LB_DC_CAP_GET(x)                         (((x) & 0x7f800000) >> 23)
-#define PHY_BB_EXTENSION_RADAR_RADAR_LB_DC_CAP_SET(x)                         (((x) << 23) & 0x7f800000)
-#define PHY_BB_EXTENSION_RADAR_DISABLE_ADCSAT_HOLD_MSB                                                31
-#define PHY_BB_EXTENSION_RADAR_DISABLE_ADCSAT_HOLD_LSB                                                31
-#define PHY_BB_EXTENSION_RADAR_DISABLE_ADCSAT_HOLD_MASK                                       0x80000000
-#define PHY_BB_EXTENSION_RADAR_DISABLE_ADCSAT_HOLD_GET(x)                     (((x) & 0x80000000) >> 31)
-#define PHY_BB_EXTENSION_RADAR_DISABLE_ADCSAT_HOLD_SET(x)                     (((x) << 31) & 0x80000000)
-
-/* macros for BB_frame_control */
-#define PHY_BB_FRAME_CONTROL_ADDRESS                                                          0x00009944
-#define PHY_BB_FRAME_CONTROL_OFFSET                                                           0x00009944
-#define PHY_BB_FRAME_CONTROL_CF_OVERLAP_WINDOW_MSB                                                     1
-#define PHY_BB_FRAME_CONTROL_CF_OVERLAP_WINDOW_LSB                                                     0
-#define PHY_BB_FRAME_CONTROL_CF_OVERLAP_WINDOW_MASK                                           0x00000003
-#define PHY_BB_FRAME_CONTROL_CF_OVERLAP_WINDOW_GET(x)                          (((x) & 0x00000003) >> 0)
-#define PHY_BB_FRAME_CONTROL_CF_OVERLAP_WINDOW_SET(x)                          (((x) << 0) & 0x00000003)
-#define PHY_BB_FRAME_CONTROL_CF_SCALE_SHORT_MSB                                                        2
-#define PHY_BB_FRAME_CONTROL_CF_SCALE_SHORT_LSB                                                        2
-#define PHY_BB_FRAME_CONTROL_CF_SCALE_SHORT_MASK                                              0x00000004
-#define PHY_BB_FRAME_CONTROL_CF_SCALE_SHORT_GET(x)                             (((x) & 0x00000004) >> 2)
-#define PHY_BB_FRAME_CONTROL_CF_SCALE_SHORT_SET(x)                             (((x) << 2) & 0x00000004)
-#define PHY_BB_FRAME_CONTROL_CF_TX_CLIP_MSB                                                            5
-#define PHY_BB_FRAME_CONTROL_CF_TX_CLIP_LSB                                                            3
-#define PHY_BB_FRAME_CONTROL_CF_TX_CLIP_MASK                                                  0x00000038
-#define PHY_BB_FRAME_CONTROL_CF_TX_CLIP_GET(x)                                 (((x) & 0x00000038) >> 3)
-#define PHY_BB_FRAME_CONTROL_CF_TX_CLIP_SET(x)                                 (((x) << 3) & 0x00000038)
-#define PHY_BB_FRAME_CONTROL_CF_TX_DOUBLESAMP_DAC_MSB                                                  7
-#define PHY_BB_FRAME_CONTROL_CF_TX_DOUBLESAMP_DAC_LSB                                                  6
-#define PHY_BB_FRAME_CONTROL_CF_TX_DOUBLESAMP_DAC_MASK                                        0x000000c0
-#define PHY_BB_FRAME_CONTROL_CF_TX_DOUBLESAMP_DAC_GET(x)                       (((x) & 0x000000c0) >> 6)
-#define PHY_BB_FRAME_CONTROL_CF_TX_DOUBLESAMP_DAC_SET(x)                       (((x) << 6) & 0x000000c0)
-#define PHY_BB_FRAME_CONTROL_TX_END_ADJUST_MSB                                                        15
-#define PHY_BB_FRAME_CONTROL_TX_END_ADJUST_LSB                                                         8
-#define PHY_BB_FRAME_CONTROL_TX_END_ADJUST_MASK                                               0x0000ff00
-#define PHY_BB_FRAME_CONTROL_TX_END_ADJUST_GET(x)                              (((x) & 0x0000ff00) >> 8)
-#define PHY_BB_FRAME_CONTROL_TX_END_ADJUST_SET(x)                              (((x) << 8) & 0x0000ff00)
-#define PHY_BB_FRAME_CONTROL_PREPEND_CHAN_INFO_MSB                                                    16
-#define PHY_BB_FRAME_CONTROL_PREPEND_CHAN_INFO_LSB                                                    16
-#define PHY_BB_FRAME_CONTROL_PREPEND_CHAN_INFO_MASK                                           0x00010000
-#define PHY_BB_FRAME_CONTROL_PREPEND_CHAN_INFO_GET(x)                         (((x) & 0x00010000) >> 16)
-#define PHY_BB_FRAME_CONTROL_PREPEND_CHAN_INFO_SET(x)                         (((x) << 16) & 0x00010000)
-#define PHY_BB_FRAME_CONTROL_SHORT_HIGH_PAR_NORM_MSB                                                  17
-#define PHY_BB_FRAME_CONTROL_SHORT_HIGH_PAR_NORM_LSB                                                  17
-#define PHY_BB_FRAME_CONTROL_SHORT_HIGH_PAR_NORM_MASK                                         0x00020000
-#define PHY_BB_FRAME_CONTROL_SHORT_HIGH_PAR_NORM_GET(x)                       (((x) & 0x00020000) >> 17)
-#define PHY_BB_FRAME_CONTROL_SHORT_HIGH_PAR_NORM_SET(x)                       (((x) << 17) & 0x00020000)
-#define PHY_BB_FRAME_CONTROL_EN_ERR_GREEN_FIELD_MSB                                                   18
-#define PHY_BB_FRAME_CONTROL_EN_ERR_GREEN_FIELD_LSB                                                   18
-#define PHY_BB_FRAME_CONTROL_EN_ERR_GREEN_FIELD_MASK                                          0x00040000
-#define PHY_BB_FRAME_CONTROL_EN_ERR_GREEN_FIELD_GET(x)                        (((x) & 0x00040000) >> 18)
-#define PHY_BB_FRAME_CONTROL_EN_ERR_GREEN_FIELD_SET(x)                        (((x) << 18) & 0x00040000)
-#define PHY_BB_FRAME_CONTROL_EN_ERR_XR_POWER_RATIO_MSB                                                19
-#define PHY_BB_FRAME_CONTROL_EN_ERR_XR_POWER_RATIO_LSB                                                19
-#define PHY_BB_FRAME_CONTROL_EN_ERR_XR_POWER_RATIO_MASK                                       0x00080000
-#define PHY_BB_FRAME_CONTROL_EN_ERR_XR_POWER_RATIO_GET(x)                     (((x) & 0x00080000) >> 19)
-#define PHY_BB_FRAME_CONTROL_EN_ERR_XR_POWER_RATIO_SET(x)                     (((x) << 19) & 0x00080000)
-#define PHY_BB_FRAME_CONTROL_EN_ERR_OFDM_XCORR_MSB                                                    20
-#define PHY_BB_FRAME_CONTROL_EN_ERR_OFDM_XCORR_LSB                                                    20
-#define PHY_BB_FRAME_CONTROL_EN_ERR_OFDM_XCORR_MASK                                           0x00100000
-#define PHY_BB_FRAME_CONTROL_EN_ERR_OFDM_XCORR_GET(x)                         (((x) & 0x00100000) >> 20)
-#define PHY_BB_FRAME_CONTROL_EN_ERR_OFDM_XCORR_SET(x)                         (((x) << 20) & 0x00100000)
-#define PHY_BB_FRAME_CONTROL_EN_ERR_LONG_SC_THR_MSB                                                   21
-#define PHY_BB_FRAME_CONTROL_EN_ERR_LONG_SC_THR_LSB                                                   21
-#define PHY_BB_FRAME_CONTROL_EN_ERR_LONG_SC_THR_MASK                                          0x00200000
-#define PHY_BB_FRAME_CONTROL_EN_ERR_LONG_SC_THR_GET(x)                        (((x) & 0x00200000) >> 21)
-#define PHY_BB_FRAME_CONTROL_EN_ERR_LONG_SC_THR_SET(x)                        (((x) << 21) & 0x00200000)
-#define PHY_BB_FRAME_CONTROL_EN_ERR_TIM_LONG1_MSB                                                     22
-#define PHY_BB_FRAME_CONTROL_EN_ERR_TIM_LONG1_LSB                                                     22
-#define PHY_BB_FRAME_CONTROL_EN_ERR_TIM_LONG1_MASK                                            0x00400000
-#define PHY_BB_FRAME_CONTROL_EN_ERR_TIM_LONG1_GET(x)                          (((x) & 0x00400000) >> 22)
-#define PHY_BB_FRAME_CONTROL_EN_ERR_TIM_LONG1_SET(x)                          (((x) << 22) & 0x00400000)
-#define PHY_BB_FRAME_CONTROL_EN_ERR_TIM_EARLY_TRIG_MSB                                                23
-#define PHY_BB_FRAME_CONTROL_EN_ERR_TIM_EARLY_TRIG_LSB                                                23
-#define PHY_BB_FRAME_CONTROL_EN_ERR_TIM_EARLY_TRIG_MASK                                       0x00800000
-#define PHY_BB_FRAME_CONTROL_EN_ERR_TIM_EARLY_TRIG_GET(x)                     (((x) & 0x00800000) >> 23)
-#define PHY_BB_FRAME_CONTROL_EN_ERR_TIM_EARLY_TRIG_SET(x)                     (((x) << 23) & 0x00800000)
-#define PHY_BB_FRAME_CONTROL_EN_ERR_TIM_TIMEOUT_MSB                                                   24
-#define PHY_BB_FRAME_CONTROL_EN_ERR_TIM_TIMEOUT_LSB                                                   24
-#define PHY_BB_FRAME_CONTROL_EN_ERR_TIM_TIMEOUT_MASK                                          0x01000000
-#define PHY_BB_FRAME_CONTROL_EN_ERR_TIM_TIMEOUT_GET(x)                        (((x) & 0x01000000) >> 24)
-#define PHY_BB_FRAME_CONTROL_EN_ERR_TIM_TIMEOUT_SET(x)                        (((x) << 24) & 0x01000000)
-#define PHY_BB_FRAME_CONTROL_EN_ERR_SIGNAL_PARITY_MSB                                                 25
-#define PHY_BB_FRAME_CONTROL_EN_ERR_SIGNAL_PARITY_LSB                                                 25
-#define PHY_BB_FRAME_CONTROL_EN_ERR_SIGNAL_PARITY_MASK                                        0x02000000
-#define PHY_BB_FRAME_CONTROL_EN_ERR_SIGNAL_PARITY_GET(x)                      (((x) & 0x02000000) >> 25)
-#define PHY_BB_FRAME_CONTROL_EN_ERR_SIGNAL_PARITY_SET(x)                      (((x) << 25) & 0x02000000)
-#define PHY_BB_FRAME_CONTROL_EN_ERR_RATE_ILLEGAL_MSB                                                  26
-#define PHY_BB_FRAME_CONTROL_EN_ERR_RATE_ILLEGAL_LSB                                                  26
-#define PHY_BB_FRAME_CONTROL_EN_ERR_RATE_ILLEGAL_MASK                                         0x04000000
-#define PHY_BB_FRAME_CONTROL_EN_ERR_RATE_ILLEGAL_GET(x)                       (((x) & 0x04000000) >> 26)
-#define PHY_BB_FRAME_CONTROL_EN_ERR_RATE_ILLEGAL_SET(x)                       (((x) << 26) & 0x04000000)
-#define PHY_BB_FRAME_CONTROL_EN_ERR_LENGTH_ILLEGAL_MSB                                                27
-#define PHY_BB_FRAME_CONTROL_EN_ERR_LENGTH_ILLEGAL_LSB                                                27
-#define PHY_BB_FRAME_CONTROL_EN_ERR_LENGTH_ILLEGAL_MASK                                       0x08000000
-#define PHY_BB_FRAME_CONTROL_EN_ERR_LENGTH_ILLEGAL_GET(x)                     (((x) & 0x08000000) >> 27)
-#define PHY_BB_FRAME_CONTROL_EN_ERR_LENGTH_ILLEGAL_SET(x)                     (((x) << 27) & 0x08000000)
-#define PHY_BB_FRAME_CONTROL_EN_ERR_HT_SERVICE_MSB                                                    28
-#define PHY_BB_FRAME_CONTROL_EN_ERR_HT_SERVICE_LSB                                                    28
-#define PHY_BB_FRAME_CONTROL_EN_ERR_HT_SERVICE_MASK                                           0x10000000
-#define PHY_BB_FRAME_CONTROL_EN_ERR_HT_SERVICE_GET(x)                         (((x) & 0x10000000) >> 28)
-#define PHY_BB_FRAME_CONTROL_EN_ERR_HT_SERVICE_SET(x)                         (((x) << 28) & 0x10000000)
-#define PHY_BB_FRAME_CONTROL_EN_ERR_SERVICE_MSB                                                       29
-#define PHY_BB_FRAME_CONTROL_EN_ERR_SERVICE_LSB                                                       29
-#define PHY_BB_FRAME_CONTROL_EN_ERR_SERVICE_MASK                                              0x20000000
-#define PHY_BB_FRAME_CONTROL_EN_ERR_SERVICE_GET(x)                            (((x) & 0x20000000) >> 29)
-#define PHY_BB_FRAME_CONTROL_EN_ERR_SERVICE_SET(x)                            (((x) << 29) & 0x20000000)
-#define PHY_BB_FRAME_CONTROL_EN_ERR_TX_UNDERRUN_MSB                                                   30
-#define PHY_BB_FRAME_CONTROL_EN_ERR_TX_UNDERRUN_LSB                                                   30
-#define PHY_BB_FRAME_CONTROL_EN_ERR_TX_UNDERRUN_MASK                                          0x40000000
-#define PHY_BB_FRAME_CONTROL_EN_ERR_TX_UNDERRUN_GET(x)                        (((x) & 0x40000000) >> 30)
-#define PHY_BB_FRAME_CONTROL_EN_ERR_TX_UNDERRUN_SET(x)                        (((x) << 30) & 0x40000000)
-#define PHY_BB_FRAME_CONTROL_EN_ERR_RX_ABORT_MSB                                                      31
-#define PHY_BB_FRAME_CONTROL_EN_ERR_RX_ABORT_LSB                                                      31
-#define PHY_BB_FRAME_CONTROL_EN_ERR_RX_ABORT_MASK                                             0x80000000
-#define PHY_BB_FRAME_CONTROL_EN_ERR_RX_ABORT_GET(x)                           (((x) & 0x80000000) >> 31)
-#define PHY_BB_FRAME_CONTROL_EN_ERR_RX_ABORT_SET(x)                           (((x) << 31) & 0x80000000)
-
-/* macros for BB_timing_control_6 */
-#define PHY_BB_TIMING_CONTROL_6_ADDRESS                                                       0x00009948
-#define PHY_BB_TIMING_CONTROL_6_OFFSET                                                        0x00009948
-#define PHY_BB_TIMING_CONTROL_6_HI_RSSI_THRESH_MSB                                                     7
-#define PHY_BB_TIMING_CONTROL_6_HI_RSSI_THRESH_LSB                                                     0
-#define PHY_BB_TIMING_CONTROL_6_HI_RSSI_THRESH_MASK                                           0x000000ff
-#define PHY_BB_TIMING_CONTROL_6_HI_RSSI_THRESH_GET(x)                          (((x) & 0x000000ff) >> 0)
-#define PHY_BB_TIMING_CONTROL_6_HI_RSSI_THRESH_SET(x)                          (((x) << 0) & 0x000000ff)
-#define PHY_BB_TIMING_CONTROL_6_EARLY_TRIGGER_THR_HI_RSSI_MSB                                         14
-#define PHY_BB_TIMING_CONTROL_6_EARLY_TRIGGER_THR_HI_RSSI_LSB                                          8
-#define PHY_BB_TIMING_CONTROL_6_EARLY_TRIGGER_THR_HI_RSSI_MASK                                0x00007f00
-#define PHY_BB_TIMING_CONTROL_6_EARLY_TRIGGER_THR_HI_RSSI_GET(x)               (((x) & 0x00007f00) >> 8)
-#define PHY_BB_TIMING_CONTROL_6_EARLY_TRIGGER_THR_HI_RSSI_SET(x)               (((x) << 8) & 0x00007f00)
-#define PHY_BB_TIMING_CONTROL_6_OFDM_XCORR_THRESH_MSB                                                 20
-#define PHY_BB_TIMING_CONTROL_6_OFDM_XCORR_THRESH_LSB                                                 15
-#define PHY_BB_TIMING_CONTROL_6_OFDM_XCORR_THRESH_MASK                                        0x001f8000
-#define PHY_BB_TIMING_CONTROL_6_OFDM_XCORR_THRESH_GET(x)                      (((x) & 0x001f8000) >> 15)
-#define PHY_BB_TIMING_CONTROL_6_OFDM_XCORR_THRESH_SET(x)                      (((x) << 15) & 0x001f8000)
-#define PHY_BB_TIMING_CONTROL_6_OFDM_XCORR_THRESH_HI_RSSI_MSB                                         27
-#define PHY_BB_TIMING_CONTROL_6_OFDM_XCORR_THRESH_HI_RSSI_LSB                                         21
-#define PHY_BB_TIMING_CONTROL_6_OFDM_XCORR_THRESH_HI_RSSI_MASK                                0x0fe00000
-#define PHY_BB_TIMING_CONTROL_6_OFDM_XCORR_THRESH_HI_RSSI_GET(x)              (((x) & 0x0fe00000) >> 21)
-#define PHY_BB_TIMING_CONTROL_6_OFDM_XCORR_THRESH_HI_RSSI_SET(x)              (((x) << 21) & 0x0fe00000)
-#define PHY_BB_TIMING_CONTROL_6_LONG_MEDIUM_RATIO_THR_MSB                                             31
-#define PHY_BB_TIMING_CONTROL_6_LONG_MEDIUM_RATIO_THR_LSB                                             28
-#define PHY_BB_TIMING_CONTROL_6_LONG_MEDIUM_RATIO_THR_MASK                                    0xf0000000
-#define PHY_BB_TIMING_CONTROL_6_LONG_MEDIUM_RATIO_THR_GET(x)                  (((x) & 0xf0000000) >> 28)
-#define PHY_BB_TIMING_CONTROL_6_LONG_MEDIUM_RATIO_THR_SET(x)                  (((x) << 28) & 0xf0000000)
-
-/* macros for BB_spur_mask_controls */
-#define PHY_BB_SPUR_MASK_CONTROLS_ADDRESS                                                     0x0000994c
-#define PHY_BB_SPUR_MASK_CONTROLS_OFFSET                                                      0x0000994c
-#define PHY_BB_SPUR_MASK_CONTROLS_SPUR_RSSI_THRESH_MSB                                                 7
-#define PHY_BB_SPUR_MASK_CONTROLS_SPUR_RSSI_THRESH_LSB                                                 0
-#define PHY_BB_SPUR_MASK_CONTROLS_SPUR_RSSI_THRESH_MASK                                       0x000000ff
-#define PHY_BB_SPUR_MASK_CONTROLS_SPUR_RSSI_THRESH_GET(x)                      (((x) & 0x000000ff) >> 0)
-#define PHY_BB_SPUR_MASK_CONTROLS_SPUR_RSSI_THRESH_SET(x)                      (((x) << 0) & 0x000000ff)
-#define PHY_BB_SPUR_MASK_CONTROLS_EN_VIT_SPUR_RSSI_MSB                                                 8
-#define PHY_BB_SPUR_MASK_CONTROLS_EN_VIT_SPUR_RSSI_LSB                                                 8
-#define PHY_BB_SPUR_MASK_CONTROLS_EN_VIT_SPUR_RSSI_MASK                                       0x00000100
-#define PHY_BB_SPUR_MASK_CONTROLS_EN_VIT_SPUR_RSSI_GET(x)                      (((x) & 0x00000100) >> 8)
-#define PHY_BB_SPUR_MASK_CONTROLS_EN_VIT_SPUR_RSSI_SET(x)                      (((x) << 8) & 0x00000100)
-#define PHY_BB_SPUR_MASK_CONTROLS_ENABLE_MASK_PPM_MSB                                                 17
-#define PHY_BB_SPUR_MASK_CONTROLS_ENABLE_MASK_PPM_LSB                                                 17
-#define PHY_BB_SPUR_MASK_CONTROLS_ENABLE_MASK_PPM_MASK                                        0x00020000
-#define PHY_BB_SPUR_MASK_CONTROLS_ENABLE_MASK_PPM_GET(x)                      (((x) & 0x00020000) >> 17)
-#define PHY_BB_SPUR_MASK_CONTROLS_ENABLE_MASK_PPM_SET(x)                      (((x) << 17) & 0x00020000)
-#define PHY_BB_SPUR_MASK_CONTROLS_MASK_RATE_CNTL_MSB                                                  25
-#define PHY_BB_SPUR_MASK_CONTROLS_MASK_RATE_CNTL_LSB                                                  18
-#define PHY_BB_SPUR_MASK_CONTROLS_MASK_RATE_CNTL_MASK                                         0x03fc0000
-#define PHY_BB_SPUR_MASK_CONTROLS_MASK_RATE_CNTL_GET(x)                       (((x) & 0x03fc0000) >> 18)
-#define PHY_BB_SPUR_MASK_CONTROLS_MASK_RATE_CNTL_SET(x)                       (((x) << 18) & 0x03fc0000)
-
-/* macros for BB_rx_iq_corr_b0 */
-#define PHY_BB_RX_IQ_CORR_B0_ADDRESS                                                          0x00009950
-#define PHY_BB_RX_IQ_CORR_B0_OFFSET                                                           0x00009950
-#define PHY_BB_RX_IQ_CORR_B0_RX_IQCORR_Q_Q_COFF_0_MSB                                                  6
-#define PHY_BB_RX_IQ_CORR_B0_RX_IQCORR_Q_Q_COFF_0_LSB                                                  0
-#define PHY_BB_RX_IQ_CORR_B0_RX_IQCORR_Q_Q_COFF_0_MASK                                        0x0000007f
-#define PHY_BB_RX_IQ_CORR_B0_RX_IQCORR_Q_Q_COFF_0_GET(x)                       (((x) & 0x0000007f) >> 0)
-#define PHY_BB_RX_IQ_CORR_B0_RX_IQCORR_Q_Q_COFF_0_SET(x)                       (((x) << 0) & 0x0000007f)
-#define PHY_BB_RX_IQ_CORR_B0_RX_IQCORR_Q_I_COFF_0_MSB                                                 13
-#define PHY_BB_RX_IQ_CORR_B0_RX_IQCORR_Q_I_COFF_0_LSB                                                  7
-#define PHY_BB_RX_IQ_CORR_B0_RX_IQCORR_Q_I_COFF_0_MASK                                        0x00003f80
-#define PHY_BB_RX_IQ_CORR_B0_RX_IQCORR_Q_I_COFF_0_GET(x)                       (((x) & 0x00003f80) >> 7)
-#define PHY_BB_RX_IQ_CORR_B0_RX_IQCORR_Q_I_COFF_0_SET(x)                       (((x) << 7) & 0x00003f80)
-#define PHY_BB_RX_IQ_CORR_B0_RX_IQCORR_ENABLE_MSB                                                     14
-#define PHY_BB_RX_IQ_CORR_B0_RX_IQCORR_ENABLE_LSB                                                     14
-#define PHY_BB_RX_IQ_CORR_B0_RX_IQCORR_ENABLE_MASK                                            0x00004000
-#define PHY_BB_RX_IQ_CORR_B0_RX_IQCORR_ENABLE_GET(x)                          (((x) & 0x00004000) >> 14)
-#define PHY_BB_RX_IQ_CORR_B0_RX_IQCORR_ENABLE_SET(x)                          (((x) << 14) & 0x00004000)
-#define PHY_BB_RX_IQ_CORR_B0_LOOPBACK_IQCORR_Q_Q_COFF_0_MSB                                           21
-#define PHY_BB_RX_IQ_CORR_B0_LOOPBACK_IQCORR_Q_Q_COFF_0_LSB                                           15
-#define PHY_BB_RX_IQ_CORR_B0_LOOPBACK_IQCORR_Q_Q_COFF_0_MASK                                  0x003f8000
-#define PHY_BB_RX_IQ_CORR_B0_LOOPBACK_IQCORR_Q_Q_COFF_0_GET(x)                (((x) & 0x003f8000) >> 15)
-#define PHY_BB_RX_IQ_CORR_B0_LOOPBACK_IQCORR_Q_Q_COFF_0_SET(x)                (((x) << 15) & 0x003f8000)
-#define PHY_BB_RX_IQ_CORR_B0_LOOPBACK_IQCORR_Q_I_COFF_0_MSB                                           28
-#define PHY_BB_RX_IQ_CORR_B0_LOOPBACK_IQCORR_Q_I_COFF_0_LSB                                           22
-#define PHY_BB_RX_IQ_CORR_B0_LOOPBACK_IQCORR_Q_I_COFF_0_MASK                                  0x1fc00000
-#define PHY_BB_RX_IQ_CORR_B0_LOOPBACK_IQCORR_Q_I_COFF_0_GET(x)                (((x) & 0x1fc00000) >> 22)
-#define PHY_BB_RX_IQ_CORR_B0_LOOPBACK_IQCORR_Q_I_COFF_0_SET(x)                (((x) << 22) & 0x1fc00000)
-#define PHY_BB_RX_IQ_CORR_B0_LOOPBACK_IQCORR_ENABLE_MSB                                               29
-#define PHY_BB_RX_IQ_CORR_B0_LOOPBACK_IQCORR_ENABLE_LSB                                               29
-#define PHY_BB_RX_IQ_CORR_B0_LOOPBACK_IQCORR_ENABLE_MASK                                      0x20000000
-#define PHY_BB_RX_IQ_CORR_B0_LOOPBACK_IQCORR_ENABLE_GET(x)                    (((x) & 0x20000000) >> 29)
-#define PHY_BB_RX_IQ_CORR_B0_LOOPBACK_IQCORR_ENABLE_SET(x)                    (((x) << 29) & 0x20000000)
-
-/* macros for BB_radar_detection */
-#define PHY_BB_RADAR_DETECTION_ADDRESS                                                        0x00009954
-#define PHY_BB_RADAR_DETECTION_OFFSET                                                         0x00009954
-#define PHY_BB_RADAR_DETECTION_PULSE_DETECT_ENABLE_MSB                                                 0
-#define PHY_BB_RADAR_DETECTION_PULSE_DETECT_ENABLE_LSB                                                 0
-#define PHY_BB_RADAR_DETECTION_PULSE_DETECT_ENABLE_MASK                                       0x00000001
-#define PHY_BB_RADAR_DETECTION_PULSE_DETECT_ENABLE_GET(x)                      (((x) & 0x00000001) >> 0)
-#define PHY_BB_RADAR_DETECTION_PULSE_DETECT_ENABLE_SET(x)                      (((x) << 0) & 0x00000001)
-#define PHY_BB_RADAR_DETECTION_PULSE_IN_BAND_THRESH_MSB                                                5
-#define PHY_BB_RADAR_DETECTION_PULSE_IN_BAND_THRESH_LSB                                                1
-#define PHY_BB_RADAR_DETECTION_PULSE_IN_BAND_THRESH_MASK                                      0x0000003e
-#define PHY_BB_RADAR_DETECTION_PULSE_IN_BAND_THRESH_GET(x)                     (((x) & 0x0000003e) >> 1)
-#define PHY_BB_RADAR_DETECTION_PULSE_IN_BAND_THRESH_SET(x)                     (((x) << 1) & 0x0000003e)
-#define PHY_BB_RADAR_DETECTION_PULSE_RSSI_THRESH_MSB                                                  11
-#define PHY_BB_RADAR_DETECTION_PULSE_RSSI_THRESH_LSB                                                   6
-#define PHY_BB_RADAR_DETECTION_PULSE_RSSI_THRESH_MASK                                         0x00000fc0
-#define PHY_BB_RADAR_DETECTION_PULSE_RSSI_THRESH_GET(x)                        (((x) & 0x00000fc0) >> 6)
-#define PHY_BB_RADAR_DETECTION_PULSE_RSSI_THRESH_SET(x)                        (((x) << 6) & 0x00000fc0)
-#define PHY_BB_RADAR_DETECTION_PULSE_HEIGHT_THRESH_MSB                                                17
-#define PHY_BB_RADAR_DETECTION_PULSE_HEIGHT_THRESH_LSB                                                12
-#define PHY_BB_RADAR_DETECTION_PULSE_HEIGHT_THRESH_MASK                                       0x0003f000
-#define PHY_BB_RADAR_DETECTION_PULSE_HEIGHT_THRESH_GET(x)                     (((x) & 0x0003f000) >> 12)
-#define PHY_BB_RADAR_DETECTION_PULSE_HEIGHT_THRESH_SET(x)                     (((x) << 12) & 0x0003f000)
-#define PHY_BB_RADAR_DETECTION_RADAR_RSSI_THRESH_MSB                                                  23
-#define PHY_BB_RADAR_DETECTION_RADAR_RSSI_THRESH_LSB                                                  18
-#define PHY_BB_RADAR_DETECTION_RADAR_RSSI_THRESH_MASK                                         0x00fc0000
-#define PHY_BB_RADAR_DETECTION_RADAR_RSSI_THRESH_GET(x)                       (((x) & 0x00fc0000) >> 18)
-#define PHY_BB_RADAR_DETECTION_RADAR_RSSI_THRESH_SET(x)                       (((x) << 18) & 0x00fc0000)
-#define PHY_BB_RADAR_DETECTION_RADAR_FIRPWR_THRESH_MSB                                                30
-#define PHY_BB_RADAR_DETECTION_RADAR_FIRPWR_THRESH_LSB                                                24
-#define PHY_BB_RADAR_DETECTION_RADAR_FIRPWR_THRESH_MASK                                       0x7f000000
-#define PHY_BB_RADAR_DETECTION_RADAR_FIRPWR_THRESH_GET(x)                     (((x) & 0x7f000000) >> 24)
-#define PHY_BB_RADAR_DETECTION_RADAR_FIRPWR_THRESH_SET(x)                     (((x) << 24) & 0x7f000000)
-#define PHY_BB_RADAR_DETECTION_ENABLE_RADAR_FFT_MSB                                                   31
-#define PHY_BB_RADAR_DETECTION_ENABLE_RADAR_FFT_LSB                                                   31
-#define PHY_BB_RADAR_DETECTION_ENABLE_RADAR_FFT_MASK                                          0x80000000
-#define PHY_BB_RADAR_DETECTION_ENABLE_RADAR_FFT_GET(x)                        (((x) & 0x80000000) >> 31)
-#define PHY_BB_RADAR_DETECTION_ENABLE_RADAR_FFT_SET(x)                        (((x) << 31) & 0x80000000)
-
-/* macros for BB_radar_detection_2 */
-#define PHY_BB_RADAR_DETECTION_2_ADDRESS                                                      0x00009958
-#define PHY_BB_RADAR_DETECTION_2_OFFSET                                                       0x00009958
-#define PHY_BB_RADAR_DETECTION_2_RADAR_LENGTH_MAX_MSB                                                  7
-#define PHY_BB_RADAR_DETECTION_2_RADAR_LENGTH_MAX_LSB                                                  0
-#define PHY_BB_RADAR_DETECTION_2_RADAR_LENGTH_MAX_MASK                                        0x000000ff
-#define PHY_BB_RADAR_DETECTION_2_RADAR_LENGTH_MAX_GET(x)                       (((x) & 0x000000ff) >> 0)
-#define PHY_BB_RADAR_DETECTION_2_RADAR_LENGTH_MAX_SET(x)                       (((x) << 0) & 0x000000ff)
-#define PHY_BB_RADAR_DETECTION_2_PULSE_RELSTEP_THRESH_MSB                                             12
-#define PHY_BB_RADAR_DETECTION_2_PULSE_RELSTEP_THRESH_LSB                                              8
-#define PHY_BB_RADAR_DETECTION_2_PULSE_RELSTEP_THRESH_MASK                                    0x00001f00
-#define PHY_BB_RADAR_DETECTION_2_PULSE_RELSTEP_THRESH_GET(x)                   (((x) & 0x00001f00) >> 8)
-#define PHY_BB_RADAR_DETECTION_2_PULSE_RELSTEP_THRESH_SET(x)                   (((x) << 8) & 0x00001f00)
-#define PHY_BB_RADAR_DETECTION_2_ENABLE_PULSE_RELSTEP_CHECK_MSB                                       13
-#define PHY_BB_RADAR_DETECTION_2_ENABLE_PULSE_RELSTEP_CHECK_LSB                                       13
-#define PHY_BB_RADAR_DETECTION_2_ENABLE_PULSE_RELSTEP_CHECK_MASK                              0x00002000
-#define PHY_BB_RADAR_DETECTION_2_ENABLE_PULSE_RELSTEP_CHECK_GET(x)            (((x) & 0x00002000) >> 13)
-#define PHY_BB_RADAR_DETECTION_2_ENABLE_PULSE_RELSTEP_CHECK_SET(x)            (((x) << 13) & 0x00002000)
-#define PHY_BB_RADAR_DETECTION_2_ENABLE_MAX_RADAR_RSSI_MSB                                            14
-#define PHY_BB_RADAR_DETECTION_2_ENABLE_MAX_RADAR_RSSI_LSB                                            14
-#define PHY_BB_RADAR_DETECTION_2_ENABLE_MAX_RADAR_RSSI_MASK                                   0x00004000
-#define PHY_BB_RADAR_DETECTION_2_ENABLE_MAX_RADAR_RSSI_GET(x)                 (((x) & 0x00004000) >> 14)
-#define PHY_BB_RADAR_DETECTION_2_ENABLE_MAX_RADAR_RSSI_SET(x)                 (((x) << 14) & 0x00004000)
-#define PHY_BB_RADAR_DETECTION_2_ENABLE_BLOCK_RADAR_CHECK_MSB                                         15
-#define PHY_BB_RADAR_DETECTION_2_ENABLE_BLOCK_RADAR_CHECK_LSB                                         15
-#define PHY_BB_RADAR_DETECTION_2_ENABLE_BLOCK_RADAR_CHECK_MASK                                0x00008000
-#define PHY_BB_RADAR_DETECTION_2_ENABLE_BLOCK_RADAR_CHECK_GET(x)              (((x) & 0x00008000) >> 15)
-#define PHY_BB_RADAR_DETECTION_2_ENABLE_BLOCK_RADAR_CHECK_SET(x)              (((x) << 15) & 0x00008000)
-#define PHY_BB_RADAR_DETECTION_2_RADAR_RELPWR_THRESH_MSB                                              21
-#define PHY_BB_RADAR_DETECTION_2_RADAR_RELPWR_THRESH_LSB                                              16
-#define PHY_BB_RADAR_DETECTION_2_RADAR_RELPWR_THRESH_MASK                                     0x003f0000
-#define PHY_BB_RADAR_DETECTION_2_RADAR_RELPWR_THRESH_GET(x)                   (((x) & 0x003f0000) >> 16)
-#define PHY_BB_RADAR_DETECTION_2_RADAR_RELPWR_THRESH_SET(x)                   (((x) << 16) & 0x003f0000)
-#define PHY_BB_RADAR_DETECTION_2_RADAR_USE_FIRPWR_128_MSB                                             22
-#define PHY_BB_RADAR_DETECTION_2_RADAR_USE_FIRPWR_128_LSB                                             22
-#define PHY_BB_RADAR_DETECTION_2_RADAR_USE_FIRPWR_128_MASK                                    0x00400000
-#define PHY_BB_RADAR_DETECTION_2_RADAR_USE_FIRPWR_128_GET(x)                  (((x) & 0x00400000) >> 22)
-#define PHY_BB_RADAR_DETECTION_2_RADAR_USE_FIRPWR_128_SET(x)                  (((x) << 22) & 0x00400000)
-#define PHY_BB_RADAR_DETECTION_2_ENABLE_RADAR_RELPWR_CHECK_MSB                                        23
-#define PHY_BB_RADAR_DETECTION_2_ENABLE_RADAR_RELPWR_CHECK_LSB                                        23
-#define PHY_BB_RADAR_DETECTION_2_ENABLE_RADAR_RELPWR_CHECK_MASK                               0x00800000
-#define PHY_BB_RADAR_DETECTION_2_ENABLE_RADAR_RELPWR_CHECK_GET(x)             (((x) & 0x00800000) >> 23)
-#define PHY_BB_RADAR_DETECTION_2_ENABLE_RADAR_RELPWR_CHECK_SET(x)             (((x) << 23) & 0x00800000)
-#define PHY_BB_RADAR_DETECTION_2_CF_RADAR_BIN_THRESH_SEL_MSB                                          26
-#define PHY_BB_RADAR_DETECTION_2_CF_RADAR_BIN_THRESH_SEL_LSB                                          24
-#define PHY_BB_RADAR_DETECTION_2_CF_RADAR_BIN_THRESH_SEL_MASK                                 0x07000000
-#define PHY_BB_RADAR_DETECTION_2_CF_RADAR_BIN_THRESH_SEL_GET(x)               (((x) & 0x07000000) >> 24)
-#define PHY_BB_RADAR_DETECTION_2_CF_RADAR_BIN_THRESH_SEL_SET(x)               (((x) << 24) & 0x07000000)
-#define PHY_BB_RADAR_DETECTION_2_ENABLE_PULSE_GC_COUNT_CHECK_MSB                                      27
-#define PHY_BB_RADAR_DETECTION_2_ENABLE_PULSE_GC_COUNT_CHECK_LSB                                      27
-#define PHY_BB_RADAR_DETECTION_2_ENABLE_PULSE_GC_COUNT_CHECK_MASK                             0x08000000
-#define PHY_BB_RADAR_DETECTION_2_ENABLE_PULSE_GC_COUNT_CHECK_GET(x)           (((x) & 0x08000000) >> 27)
-#define PHY_BB_RADAR_DETECTION_2_ENABLE_PULSE_GC_COUNT_CHECK_SET(x)           (((x) << 27) & 0x08000000)
-
-/* macros for BB_tx_phase_ramp_b0 */
-#define PHY_BB_TX_PHASE_RAMP_B0_ADDRESS                                                       0x0000995c
-#define PHY_BB_TX_PHASE_RAMP_B0_OFFSET                                                        0x0000995c
-#define PHY_BB_TX_PHASE_RAMP_B0_CF_PHASE_RAMP_ENABLE_0_MSB                                             0
-#define PHY_BB_TX_PHASE_RAMP_B0_CF_PHASE_RAMP_ENABLE_0_LSB                                             0
-#define PHY_BB_TX_PHASE_RAMP_B0_CF_PHASE_RAMP_ENABLE_0_MASK                                   0x00000001
-#define PHY_BB_TX_PHASE_RAMP_B0_CF_PHASE_RAMP_ENABLE_0_GET(x)                  (((x) & 0x00000001) >> 0)
-#define PHY_BB_TX_PHASE_RAMP_B0_CF_PHASE_RAMP_ENABLE_0_SET(x)                  (((x) << 0) & 0x00000001)
-#define PHY_BB_TX_PHASE_RAMP_B0_CF_PHASE_RAMP_BIAS_0_MSB                                               6
-#define PHY_BB_TX_PHASE_RAMP_B0_CF_PHASE_RAMP_BIAS_0_LSB                                               1
-#define PHY_BB_TX_PHASE_RAMP_B0_CF_PHASE_RAMP_BIAS_0_MASK                                     0x0000007e
-#define PHY_BB_TX_PHASE_RAMP_B0_CF_PHASE_RAMP_BIAS_0_GET(x)                    (((x) & 0x0000007e) >> 1)
-#define PHY_BB_TX_PHASE_RAMP_B0_CF_PHASE_RAMP_BIAS_0_SET(x)                    (((x) << 1) & 0x0000007e)
-#define PHY_BB_TX_PHASE_RAMP_B0_CF_PHASE_RAMP_INIT_0_MSB                                              16
-#define PHY_BB_TX_PHASE_RAMP_B0_CF_PHASE_RAMP_INIT_0_LSB                                               7
-#define PHY_BB_TX_PHASE_RAMP_B0_CF_PHASE_RAMP_INIT_0_MASK                                     0x0001ff80
-#define PHY_BB_TX_PHASE_RAMP_B0_CF_PHASE_RAMP_INIT_0_GET(x)                    (((x) & 0x0001ff80) >> 7)
-#define PHY_BB_TX_PHASE_RAMP_B0_CF_PHASE_RAMP_INIT_0_SET(x)                    (((x) << 7) & 0x0001ff80)
-#define PHY_BB_TX_PHASE_RAMP_B0_CF_PHASE_RAMP_ALPHA_0_MSB                                             24
-#define PHY_BB_TX_PHASE_RAMP_B0_CF_PHASE_RAMP_ALPHA_0_LSB                                             17
-#define PHY_BB_TX_PHASE_RAMP_B0_CF_PHASE_RAMP_ALPHA_0_MASK                                    0x01fe0000
-#define PHY_BB_TX_PHASE_RAMP_B0_CF_PHASE_RAMP_ALPHA_0_GET(x)                  (((x) & 0x01fe0000) >> 17)
-#define PHY_BB_TX_PHASE_RAMP_B0_CF_PHASE_RAMP_ALPHA_0_SET(x)                  (((x) << 17) & 0x01fe0000)
-
-/* macros for BB_switch_table_chn_b0 */
-#define PHY_BB_SWITCH_TABLE_CHN_B0_ADDRESS                                                    0x00009960
-#define PHY_BB_SWITCH_TABLE_CHN_B0_OFFSET                                                     0x00009960
-#define PHY_BB_SWITCH_TABLE_CHN_B0_SWITCH_TABLE_IDLE_0_MSB                                             1
-#define PHY_BB_SWITCH_TABLE_CHN_B0_SWITCH_TABLE_IDLE_0_LSB                                             0
-#define PHY_BB_SWITCH_TABLE_CHN_B0_SWITCH_TABLE_IDLE_0_MASK                                   0x00000003
-#define PHY_BB_SWITCH_TABLE_CHN_B0_SWITCH_TABLE_IDLE_0_GET(x)                  (((x) & 0x00000003) >> 0)
-#define PHY_BB_SWITCH_TABLE_CHN_B0_SWITCH_TABLE_IDLE_0_SET(x)                  (((x) << 0) & 0x00000003)
-#define PHY_BB_SWITCH_TABLE_CHN_B0_SWITCH_TABLE_T_0_MSB                                                3
-#define PHY_BB_SWITCH_TABLE_CHN_B0_SWITCH_TABLE_T_0_LSB                                                2
-#define PHY_BB_SWITCH_TABLE_CHN_B0_SWITCH_TABLE_T_0_MASK                                      0x0000000c
-#define PHY_BB_SWITCH_TABLE_CHN_B0_SWITCH_TABLE_T_0_GET(x)                     (((x) & 0x0000000c) >> 2)
-#define PHY_BB_SWITCH_TABLE_CHN_B0_SWITCH_TABLE_T_0_SET(x)                     (((x) << 2) & 0x0000000c)
-#define PHY_BB_SWITCH_TABLE_CHN_B0_SWITCH_TABLE_R_0_MSB                                                5
-#define PHY_BB_SWITCH_TABLE_CHN_B0_SWITCH_TABLE_R_0_LSB                                                4
-#define PHY_BB_SWITCH_TABLE_CHN_B0_SWITCH_TABLE_R_0_MASK                                      0x00000030
-#define PHY_BB_SWITCH_TABLE_CHN_B0_SWITCH_TABLE_R_0_GET(x)                     (((x) & 0x00000030) >> 4)
-#define PHY_BB_SWITCH_TABLE_CHN_B0_SWITCH_TABLE_R_0_SET(x)                     (((x) << 4) & 0x00000030)
-#define PHY_BB_SWITCH_TABLE_CHN_B0_SWITCH_TABLE_RX1_0_MSB                                              7
-#define PHY_BB_SWITCH_TABLE_CHN_B0_SWITCH_TABLE_RX1_0_LSB                                              6
-#define PHY_BB_SWITCH_TABLE_CHN_B0_SWITCH_TABLE_RX1_0_MASK                                    0x000000c0
-#define PHY_BB_SWITCH_TABLE_CHN_B0_SWITCH_TABLE_RX1_0_GET(x)                   (((x) & 0x000000c0) >> 6)
-#define PHY_BB_SWITCH_TABLE_CHN_B0_SWITCH_TABLE_RX1_0_SET(x)                   (((x) << 6) & 0x000000c0)
-#define PHY_BB_SWITCH_TABLE_CHN_B0_SWITCH_TABLE_RX12_0_MSB                                             9
-#define PHY_BB_SWITCH_TABLE_CHN_B0_SWITCH_TABLE_RX12_0_LSB                                             8
-#define PHY_BB_SWITCH_TABLE_CHN_B0_SWITCH_TABLE_RX12_0_MASK                                   0x00000300
-#define PHY_BB_SWITCH_TABLE_CHN_B0_SWITCH_TABLE_RX12_0_GET(x)                  (((x) & 0x00000300) >> 8)
-#define PHY_BB_SWITCH_TABLE_CHN_B0_SWITCH_TABLE_RX12_0_SET(x)                  (((x) << 8) & 0x00000300)
-#define PHY_BB_SWITCH_TABLE_CHN_B0_SWITCH_TABLE_B_0_MSB                                               11
-#define PHY_BB_SWITCH_TABLE_CHN_B0_SWITCH_TABLE_B_0_LSB                                               10
-#define PHY_BB_SWITCH_TABLE_CHN_B0_SWITCH_TABLE_B_0_MASK                                      0x00000c00
-#define PHY_BB_SWITCH_TABLE_CHN_B0_SWITCH_TABLE_B_0_GET(x)                    (((x) & 0x00000c00) >> 10)
-#define PHY_BB_SWITCH_TABLE_CHN_B0_SWITCH_TABLE_B_0_SET(x)                    (((x) << 10) & 0x00000c00)
-
-/* macros for BB_switch_table_com1 */
-#define PHY_BB_SWITCH_TABLE_COM1_ADDRESS                                                      0x00009964
-#define PHY_BB_SWITCH_TABLE_COM1_OFFSET                                                       0x00009964
-#define PHY_BB_SWITCH_TABLE_COM1_SWITCH_TABLE_COM_IDLE_MSB                                             3
-#define PHY_BB_SWITCH_TABLE_COM1_SWITCH_TABLE_COM_IDLE_LSB                                             0
-#define PHY_BB_SWITCH_TABLE_COM1_SWITCH_TABLE_COM_IDLE_MASK                                   0x0000000f
-#define PHY_BB_SWITCH_TABLE_COM1_SWITCH_TABLE_COM_IDLE_GET(x)                  (((x) & 0x0000000f) >> 0)
-#define PHY_BB_SWITCH_TABLE_COM1_SWITCH_TABLE_COM_IDLE_SET(x)                  (((x) << 0) & 0x0000000f)
-#define PHY_BB_SWITCH_TABLE_COM1_SWITCH_TABLE_COM_T1_MSB                                               7
-#define PHY_BB_SWITCH_TABLE_COM1_SWITCH_TABLE_COM_T1_LSB                                               4
-#define PHY_BB_SWITCH_TABLE_COM1_SWITCH_TABLE_COM_T1_MASK                                     0x000000f0
-#define PHY_BB_SWITCH_TABLE_COM1_SWITCH_TABLE_COM_T1_GET(x)                    (((x) & 0x000000f0) >> 4)
-#define PHY_BB_SWITCH_TABLE_COM1_SWITCH_TABLE_COM_T1_SET(x)                    (((x) << 4) & 0x000000f0)
-#define PHY_BB_SWITCH_TABLE_COM1_SWITCH_TABLE_COM_T2_MSB                                              11
-#define PHY_BB_SWITCH_TABLE_COM1_SWITCH_TABLE_COM_T2_LSB                                               8
-#define PHY_BB_SWITCH_TABLE_COM1_SWITCH_TABLE_COM_T2_MASK                                     0x00000f00
-#define PHY_BB_SWITCH_TABLE_COM1_SWITCH_TABLE_COM_T2_GET(x)                    (((x) & 0x00000f00) >> 8)
-#define PHY_BB_SWITCH_TABLE_COM1_SWITCH_TABLE_COM_T2_SET(x)                    (((x) << 8) & 0x00000f00)
-#define PHY_BB_SWITCH_TABLE_COM1_SWITCH_TABLE_COM_B_MSB                                               15
-#define PHY_BB_SWITCH_TABLE_COM1_SWITCH_TABLE_COM_B_LSB                                               12
-#define PHY_BB_SWITCH_TABLE_COM1_SWITCH_TABLE_COM_B_MASK                                      0x0000f000
-#define PHY_BB_SWITCH_TABLE_COM1_SWITCH_TABLE_COM_B_GET(x)                    (((x) & 0x0000f000) >> 12)
-#define PHY_BB_SWITCH_TABLE_COM1_SWITCH_TABLE_COM_B_SET(x)                    (((x) << 12) & 0x0000f000)
-
-/* macros for BB_cca_ctrl_2_b0 */
-#define PHY_BB_CCA_CTRL_2_B0_ADDRESS                                                          0x00009968
-#define PHY_BB_CCA_CTRL_2_B0_OFFSET                                                           0x00009968
-#define PHY_BB_CCA_CTRL_2_B0_MINCCAPWR_THR_0_MSB                                                       8
-#define PHY_BB_CCA_CTRL_2_B0_MINCCAPWR_THR_0_LSB                                                       0
-#define PHY_BB_CCA_CTRL_2_B0_MINCCAPWR_THR_0_MASK                                             0x000001ff
-#define PHY_BB_CCA_CTRL_2_B0_MINCCAPWR_THR_0_GET(x)                            (((x) & 0x000001ff) >> 0)
-#define PHY_BB_CCA_CTRL_2_B0_MINCCAPWR_THR_0_SET(x)                            (((x) << 0) & 0x000001ff)
-#define PHY_BB_CCA_CTRL_2_B0_ENABLE_MINCCAPWR_THR_MSB                                                  9
-#define PHY_BB_CCA_CTRL_2_B0_ENABLE_MINCCAPWR_THR_LSB                                                  9
-#define PHY_BB_CCA_CTRL_2_B0_ENABLE_MINCCAPWR_THR_MASK                                        0x00000200
-#define PHY_BB_CCA_CTRL_2_B0_ENABLE_MINCCAPWR_THR_GET(x)                       (((x) & 0x00000200) >> 9)
-#define PHY_BB_CCA_CTRL_2_B0_ENABLE_MINCCAPWR_THR_SET(x)                       (((x) << 9) & 0x00000200)
-#define PHY_BB_CCA_CTRL_2_B0_NF_GAIN_COMP_0_MSB                                                       17
-#define PHY_BB_CCA_CTRL_2_B0_NF_GAIN_COMP_0_LSB                                                       10
-#define PHY_BB_CCA_CTRL_2_B0_NF_GAIN_COMP_0_MASK                                              0x0003fc00
-#define PHY_BB_CCA_CTRL_2_B0_NF_GAIN_COMP_0_GET(x)                            (((x) & 0x0003fc00) >> 10)
-#define PHY_BB_CCA_CTRL_2_B0_NF_GAIN_COMP_0_SET(x)                            (((x) << 10) & 0x0003fc00)
-#define PHY_BB_CCA_CTRL_2_B0_THRESH62_MODE_MSB                                                        18
-#define PHY_BB_CCA_CTRL_2_B0_THRESH62_MODE_LSB                                                        18
-#define PHY_BB_CCA_CTRL_2_B0_THRESH62_MODE_MASK                                               0x00040000
-#define PHY_BB_CCA_CTRL_2_B0_THRESH62_MODE_GET(x)                             (((x) & 0x00040000) >> 18)
-#define PHY_BB_CCA_CTRL_2_B0_THRESH62_MODE_SET(x)                             (((x) << 18) & 0x00040000)
-
-/* macros for BB_switch_table_com2 */
-#define PHY_BB_SWITCH_TABLE_COM2_ADDRESS                                                      0x0000996c
-#define PHY_BB_SWITCH_TABLE_COM2_OFFSET                                                       0x0000996c
-#define PHY_BB_SWITCH_TABLE_COM2_SWITCH_TABLE_COM_RA1NXAL1_MSB                                         3
-#define PHY_BB_SWITCH_TABLE_COM2_SWITCH_TABLE_COM_RA1NXAL1_LSB                                         0
-#define PHY_BB_SWITCH_TABLE_COM2_SWITCH_TABLE_COM_RA1NXAL1_MASK                               0x0000000f
-#define PHY_BB_SWITCH_TABLE_COM2_SWITCH_TABLE_COM_RA1NXAL1_GET(x)              (((x) & 0x0000000f) >> 0)
-#define PHY_BB_SWITCH_TABLE_COM2_SWITCH_TABLE_COM_RA1NXAL1_SET(x)              (((x) << 0) & 0x0000000f)
-#define PHY_BB_SWITCH_TABLE_COM2_SWITCH_TABLE_COM_RA2NXAL1_MSB                                         7
-#define PHY_BB_SWITCH_TABLE_COM2_SWITCH_TABLE_COM_RA2NXAL1_LSB                                         4
-#define PHY_BB_SWITCH_TABLE_COM2_SWITCH_TABLE_COM_RA2NXAL1_MASK                               0x000000f0
-#define PHY_BB_SWITCH_TABLE_COM2_SWITCH_TABLE_COM_RA2NXAL1_GET(x)              (((x) & 0x000000f0) >> 4)
-#define PHY_BB_SWITCH_TABLE_COM2_SWITCH_TABLE_COM_RA2NXAL1_SET(x)              (((x) << 4) & 0x000000f0)
-#define PHY_BB_SWITCH_TABLE_COM2_SWITCH_TABLE_COM_RA1XAL1_MSB                                         11
-#define PHY_BB_SWITCH_TABLE_COM2_SWITCH_TABLE_COM_RA1XAL1_LSB                                          8
-#define PHY_BB_SWITCH_TABLE_COM2_SWITCH_TABLE_COM_RA1XAL1_MASK                                0x00000f00
-#define PHY_BB_SWITCH_TABLE_COM2_SWITCH_TABLE_COM_RA1XAL1_GET(x)               (((x) & 0x00000f00) >> 8)
-#define PHY_BB_SWITCH_TABLE_COM2_SWITCH_TABLE_COM_RA1XAL1_SET(x)               (((x) << 8) & 0x00000f00)
-#define PHY_BB_SWITCH_TABLE_COM2_SWITCH_TABLE_COM_RA2XAL1_MSB                                         15
-#define PHY_BB_SWITCH_TABLE_COM2_SWITCH_TABLE_COM_RA2XAL1_LSB                                         12
-#define PHY_BB_SWITCH_TABLE_COM2_SWITCH_TABLE_COM_RA2XAL1_MASK                                0x0000f000
-#define PHY_BB_SWITCH_TABLE_COM2_SWITCH_TABLE_COM_RA2XAL1_GET(x)              (((x) & 0x0000f000) >> 12)
-#define PHY_BB_SWITCH_TABLE_COM2_SWITCH_TABLE_COM_RA2XAL1_SET(x)              (((x) << 12) & 0x0000f000)
-#define PHY_BB_SWITCH_TABLE_COM2_SWITCH_TABLE_COM_RA1NXAL2_MSB                                        19
-#define PHY_BB_SWITCH_TABLE_COM2_SWITCH_TABLE_COM_RA1NXAL2_LSB                                        16
-#define PHY_BB_SWITCH_TABLE_COM2_SWITCH_TABLE_COM_RA1NXAL2_MASK                               0x000f0000
-#define PHY_BB_SWITCH_TABLE_COM2_SWITCH_TABLE_COM_RA1NXAL2_GET(x)             (((x) & 0x000f0000) >> 16)
-#define PHY_BB_SWITCH_TABLE_COM2_SWITCH_TABLE_COM_RA1NXAL2_SET(x)             (((x) << 16) & 0x000f0000)
-#define PHY_BB_SWITCH_TABLE_COM2_SWITCH_TABLE_COM_RA2NXAL2_MSB                                        23
-#define PHY_BB_SWITCH_TABLE_COM2_SWITCH_TABLE_COM_RA2NXAL2_LSB                                        20
-#define PHY_BB_SWITCH_TABLE_COM2_SWITCH_TABLE_COM_RA2NXAL2_MASK                               0x00f00000
-#define PHY_BB_SWITCH_TABLE_COM2_SWITCH_TABLE_COM_RA2NXAL2_GET(x)             (((x) & 0x00f00000) >> 20)
-#define PHY_BB_SWITCH_TABLE_COM2_SWITCH_TABLE_COM_RA2NXAL2_SET(x)             (((x) << 20) & 0x00f00000)
-#define PHY_BB_SWITCH_TABLE_COM2_SWITCH_TABLE_COM_RA1XAL2_MSB                                         27
-#define PHY_BB_SWITCH_TABLE_COM2_SWITCH_TABLE_COM_RA1XAL2_LSB                                         24
-#define PHY_BB_SWITCH_TABLE_COM2_SWITCH_TABLE_COM_RA1XAL2_MASK                                0x0f000000
-#define PHY_BB_SWITCH_TABLE_COM2_SWITCH_TABLE_COM_RA1XAL2_GET(x)              (((x) & 0x0f000000) >> 24)
-#define PHY_BB_SWITCH_TABLE_COM2_SWITCH_TABLE_COM_RA1XAL2_SET(x)              (((x) << 24) & 0x0f000000)
-#define PHY_BB_SWITCH_TABLE_COM2_SWITCH_TABLE_COM_RA2XAL2_MSB                                         31
-#define PHY_BB_SWITCH_TABLE_COM2_SWITCH_TABLE_COM_RA2XAL2_LSB                                         28
-#define PHY_BB_SWITCH_TABLE_COM2_SWITCH_TABLE_COM_RA2XAL2_MASK                                0xf0000000
-#define PHY_BB_SWITCH_TABLE_COM2_SWITCH_TABLE_COM_RA2XAL2_GET(x)              (((x) & 0xf0000000) >> 28)
-#define PHY_BB_SWITCH_TABLE_COM2_SWITCH_TABLE_COM_RA2XAL2_SET(x)              (((x) << 28) & 0xf0000000)
-
-/* macros for BB_restart */
-#define PHY_BB_RESTART_ADDRESS                                                                0x00009970
-#define PHY_BB_RESTART_OFFSET                                                                 0x00009970
-#define PHY_BB_RESTART_ENABLE_RESTART_MSB                                                              0
-#define PHY_BB_RESTART_ENABLE_RESTART_LSB                                                              0
-#define PHY_BB_RESTART_ENABLE_RESTART_MASK                                                    0x00000001
-#define PHY_BB_RESTART_ENABLE_RESTART_GET(x)                                   (((x) & 0x00000001) >> 0)
-#define PHY_BB_RESTART_ENABLE_RESTART_SET(x)                                   (((x) << 0) & 0x00000001)
-#define PHY_BB_RESTART_RESTART_LGFIRPWR_DELTA_MSB                                                      5
-#define PHY_BB_RESTART_RESTART_LGFIRPWR_DELTA_LSB                                                      1
-#define PHY_BB_RESTART_RESTART_LGFIRPWR_DELTA_MASK                                            0x0000003e
-#define PHY_BB_RESTART_RESTART_LGFIRPWR_DELTA_GET(x)                           (((x) & 0x0000003e) >> 1)
-#define PHY_BB_RESTART_RESTART_LGFIRPWR_DELTA_SET(x)                           (((x) << 1) & 0x0000003e)
-#define PHY_BB_RESTART_ENABLE_PWR_DROP_ERR_MSB                                                         6
-#define PHY_BB_RESTART_ENABLE_PWR_DROP_ERR_LSB                                                         6
-#define PHY_BB_RESTART_ENABLE_PWR_DROP_ERR_MASK                                               0x00000040
-#define PHY_BB_RESTART_ENABLE_PWR_DROP_ERR_GET(x)                              (((x) & 0x00000040) >> 6)
-#define PHY_BB_RESTART_ENABLE_PWR_DROP_ERR_SET(x)                              (((x) << 6) & 0x00000040)
-#define PHY_BB_RESTART_PWRDROP_LGFIRPWR_DELTA_MSB                                                     11
-#define PHY_BB_RESTART_PWRDROP_LGFIRPWR_DELTA_LSB                                                      7
-#define PHY_BB_RESTART_PWRDROP_LGFIRPWR_DELTA_MASK                                            0x00000f80
-#define PHY_BB_RESTART_PWRDROP_LGFIRPWR_DELTA_GET(x)                           (((x) & 0x00000f80) >> 7)
-#define PHY_BB_RESTART_PWRDROP_LGFIRPWR_DELTA_SET(x)                           (((x) << 7) & 0x00000f80)
-#define PHY_BB_RESTART_OFDM_CCK_RSSI_BIAS_MSB                                                         17
-#define PHY_BB_RESTART_OFDM_CCK_RSSI_BIAS_LSB                                                         12
-#define PHY_BB_RESTART_OFDM_CCK_RSSI_BIAS_MASK                                                0x0003f000
-#define PHY_BB_RESTART_OFDM_CCK_RSSI_BIAS_GET(x)                              (((x) & 0x0003f000) >> 12)
-#define PHY_BB_RESTART_OFDM_CCK_RSSI_BIAS_SET(x)                              (((x) << 12) & 0x0003f000)
-#define PHY_BB_RESTART_ANT_FAST_DIV_GC_LIMIT_MSB                                                      20
-#define PHY_BB_RESTART_ANT_FAST_DIV_GC_LIMIT_LSB                                                      18
-#define PHY_BB_RESTART_ANT_FAST_DIV_GC_LIMIT_MASK                                             0x001c0000
-#define PHY_BB_RESTART_ANT_FAST_DIV_GC_LIMIT_GET(x)                           (((x) & 0x001c0000) >> 18)
-#define PHY_BB_RESTART_ANT_FAST_DIV_GC_LIMIT_SET(x)                           (((x) << 18) & 0x001c0000)
-#define PHY_BB_RESTART_ENABLE_ANT_FAST_DIV_M2FLAG_MSB                                                 21
-#define PHY_BB_RESTART_ENABLE_ANT_FAST_DIV_M2FLAG_LSB                                                 21
-#define PHY_BB_RESTART_ENABLE_ANT_FAST_DIV_M2FLAG_MASK                                        0x00200000
-#define PHY_BB_RESTART_ENABLE_ANT_FAST_DIV_M2FLAG_GET(x)                      (((x) & 0x00200000) >> 21)
-#define PHY_BB_RESTART_ENABLE_ANT_FAST_DIV_M2FLAG_SET(x)                      (((x) << 21) & 0x00200000)
-#define PHY_BB_RESTART_WEAK_RSSI_VOTE_THR_MSB                                                         28
-#define PHY_BB_RESTART_WEAK_RSSI_VOTE_THR_LSB                                                         22
-#define PHY_BB_RESTART_WEAK_RSSI_VOTE_THR_MASK                                                0x1fc00000
-#define PHY_BB_RESTART_WEAK_RSSI_VOTE_THR_GET(x)                              (((x) & 0x1fc00000) >> 22)
-#define PHY_BB_RESTART_WEAK_RSSI_VOTE_THR_SET(x)                              (((x) << 22) & 0x1fc00000)
-#define PHY_BB_RESTART_ENABLE_PWR_DROP_ERR_CCK_MSB                                                    29
-#define PHY_BB_RESTART_ENABLE_PWR_DROP_ERR_CCK_LSB                                                    29
-#define PHY_BB_RESTART_ENABLE_PWR_DROP_ERR_CCK_MASK                                           0x20000000
-#define PHY_BB_RESTART_ENABLE_PWR_DROP_ERR_CCK_GET(x)                         (((x) & 0x20000000) >> 29)
-#define PHY_BB_RESTART_ENABLE_PWR_DROP_ERR_CCK_SET(x)                         (((x) << 29) & 0x20000000)
-#define PHY_BB_RESTART_DISABLE_DC_RESTART_MSB                                                         30
-#define PHY_BB_RESTART_DISABLE_DC_RESTART_LSB                                                         30
-#define PHY_BB_RESTART_DISABLE_DC_RESTART_MASK                                                0x40000000
-#define PHY_BB_RESTART_DISABLE_DC_RESTART_GET(x)                              (((x) & 0x40000000) >> 30)
-#define PHY_BB_RESTART_DISABLE_DC_RESTART_SET(x)                              (((x) << 30) & 0x40000000)
-#define PHY_BB_RESTART_RESTART_MODE_BW40_MSB                                                          31
-#define PHY_BB_RESTART_RESTART_MODE_BW40_LSB                                                          31
-#define PHY_BB_RESTART_RESTART_MODE_BW40_MASK                                                 0x80000000
-#define PHY_BB_RESTART_RESTART_MODE_BW40_GET(x)                               (((x) & 0x80000000) >> 31)
-#define PHY_BB_RESTART_RESTART_MODE_BW40_SET(x)                               (((x) << 31) & 0x80000000)
-
-/* macros for BB_scrambler_seed */
-#define PHY_BB_SCRAMBLER_SEED_ADDRESS                                                         0x00009978
-#define PHY_BB_SCRAMBLER_SEED_OFFSET                                                          0x00009978
-#define PHY_BB_SCRAMBLER_SEED_FIXED_SCRAMBLER_SEED_MSB                                                 6
-#define PHY_BB_SCRAMBLER_SEED_FIXED_SCRAMBLER_SEED_LSB                                                 0
-#define PHY_BB_SCRAMBLER_SEED_FIXED_SCRAMBLER_SEED_MASK                                       0x0000007f
-#define PHY_BB_SCRAMBLER_SEED_FIXED_SCRAMBLER_SEED_GET(x)                      (((x) & 0x0000007f) >> 0)
-#define PHY_BB_SCRAMBLER_SEED_FIXED_SCRAMBLER_SEED_SET(x)                      (((x) << 0) & 0x0000007f)
-
-/* macros for BB_rfbus_request */
-#define PHY_BB_RFBUS_REQUEST_ADDRESS                                                          0x0000997c
-#define PHY_BB_RFBUS_REQUEST_OFFSET                                                           0x0000997c
-#define PHY_BB_RFBUS_REQUEST_RFBUS_REQUEST_MSB                                                         0
-#define PHY_BB_RFBUS_REQUEST_RFBUS_REQUEST_LSB                                                         0
-#define PHY_BB_RFBUS_REQUEST_RFBUS_REQUEST_MASK                                               0x00000001
-#define PHY_BB_RFBUS_REQUEST_RFBUS_REQUEST_GET(x)                              (((x) & 0x00000001) >> 0)
-#define PHY_BB_RFBUS_REQUEST_RFBUS_REQUEST_SET(x)                              (((x) << 0) & 0x00000001)
-
-/* macros for BB_timing_control_11 */
-#define PHY_BB_TIMING_CONTROL_11_ADDRESS                                                      0x000099a0
-#define PHY_BB_TIMING_CONTROL_11_OFFSET                                                       0x000099a0
-#define PHY_BB_TIMING_CONTROL_11_SPUR_DELTA_PHASE_MSB                                                 19
-#define PHY_BB_TIMING_CONTROL_11_SPUR_DELTA_PHASE_LSB                                                  0
-#define PHY_BB_TIMING_CONTROL_11_SPUR_DELTA_PHASE_MASK                                        0x000fffff
-#define PHY_BB_TIMING_CONTROL_11_SPUR_DELTA_PHASE_GET(x)                       (((x) & 0x000fffff) >> 0)
-#define PHY_BB_TIMING_CONTROL_11_SPUR_DELTA_PHASE_SET(x)                       (((x) << 0) & 0x000fffff)
-#define PHY_BB_TIMING_CONTROL_11_SPUR_FREQ_SD_MSB                                                     29
-#define PHY_BB_TIMING_CONTROL_11_SPUR_FREQ_SD_LSB                                                     20
-#define PHY_BB_TIMING_CONTROL_11_SPUR_FREQ_SD_MASK                                            0x3ff00000
-#define PHY_BB_TIMING_CONTROL_11_SPUR_FREQ_SD_GET(x)                          (((x) & 0x3ff00000) >> 20)
-#define PHY_BB_TIMING_CONTROL_11_SPUR_FREQ_SD_SET(x)                          (((x) << 20) & 0x3ff00000)
-#define PHY_BB_TIMING_CONTROL_11_USE_SPUR_FILTER_IN_AGC_MSB                                           30
-#define PHY_BB_TIMING_CONTROL_11_USE_SPUR_FILTER_IN_AGC_LSB                                           30
-#define PHY_BB_TIMING_CONTROL_11_USE_SPUR_FILTER_IN_AGC_MASK                                  0x40000000
-#define PHY_BB_TIMING_CONTROL_11_USE_SPUR_FILTER_IN_AGC_GET(x)                (((x) & 0x40000000) >> 30)
-#define PHY_BB_TIMING_CONTROL_11_USE_SPUR_FILTER_IN_AGC_SET(x)                (((x) << 30) & 0x40000000)
-#define PHY_BB_TIMING_CONTROL_11_USE_SPUR_FILTER_IN_SELFCOR_MSB                                       31
-#define PHY_BB_TIMING_CONTROL_11_USE_SPUR_FILTER_IN_SELFCOR_LSB                                       31
-#define PHY_BB_TIMING_CONTROL_11_USE_SPUR_FILTER_IN_SELFCOR_MASK                              0x80000000
-#define PHY_BB_TIMING_CONTROL_11_USE_SPUR_FILTER_IN_SELFCOR_GET(x)            (((x) & 0x80000000) >> 31)
-#define PHY_BB_TIMING_CONTROL_11_USE_SPUR_FILTER_IN_SELFCOR_SET(x)            (((x) << 31) & 0x80000000)
-
-/* macros for BB_multichain_enable */
-#define PHY_BB_MULTICHAIN_ENABLE_ADDRESS                                                      0x000099a4
-#define PHY_BB_MULTICHAIN_ENABLE_OFFSET                                                       0x000099a4
-#define PHY_BB_MULTICHAIN_ENABLE_RX_CHAIN_MASK_MSB                                                     2
-#define PHY_BB_MULTICHAIN_ENABLE_RX_CHAIN_MASK_LSB                                                     0
-#define PHY_BB_MULTICHAIN_ENABLE_RX_CHAIN_MASK_MASK                                           0x00000007
-#define PHY_BB_MULTICHAIN_ENABLE_RX_CHAIN_MASK_GET(x)                          (((x) & 0x00000007) >> 0)
-#define PHY_BB_MULTICHAIN_ENABLE_RX_CHAIN_MASK_SET(x)                          (((x) << 0) & 0x00000007)
-
-/* macros for BB_multichain_control */
-#define PHY_BB_MULTICHAIN_CONTROL_ADDRESS                                                     0x000099a8
-#define PHY_BB_MULTICHAIN_CONTROL_OFFSET                                                      0x000099a8
-#define PHY_BB_MULTICHAIN_CONTROL_FORCE_ANALOG_GAIN_DIFF_MSB                                           0
-#define PHY_BB_MULTICHAIN_CONTROL_FORCE_ANALOG_GAIN_DIFF_LSB                                           0
-#define PHY_BB_MULTICHAIN_CONTROL_FORCE_ANALOG_GAIN_DIFF_MASK                                 0x00000001
-#define PHY_BB_MULTICHAIN_CONTROL_FORCE_ANALOG_GAIN_DIFF_GET(x)                (((x) & 0x00000001) >> 0)
-#define PHY_BB_MULTICHAIN_CONTROL_FORCE_ANALOG_GAIN_DIFF_SET(x)                (((x) << 0) & 0x00000001)
-#define PHY_BB_MULTICHAIN_CONTROL_FORCED_GAIN_DIFF_01_MSB                                              7
-#define PHY_BB_MULTICHAIN_CONTROL_FORCED_GAIN_DIFF_01_LSB                                              1
-#define PHY_BB_MULTICHAIN_CONTROL_FORCED_GAIN_DIFF_01_MASK                                    0x000000fe
-#define PHY_BB_MULTICHAIN_CONTROL_FORCED_GAIN_DIFF_01_GET(x)                   (((x) & 0x000000fe) >> 1)
-#define PHY_BB_MULTICHAIN_CONTROL_FORCED_GAIN_DIFF_01_SET(x)                   (((x) << 1) & 0x000000fe)
-#define PHY_BB_MULTICHAIN_CONTROL_SYNC_SYNTHON_MSB                                                     8
-#define PHY_BB_MULTICHAIN_CONTROL_SYNC_SYNTHON_LSB                                                     8
-#define PHY_BB_MULTICHAIN_CONTROL_SYNC_SYNTHON_MASK                                           0x00000100
-#define PHY_BB_MULTICHAIN_CONTROL_SYNC_SYNTHON_GET(x)                          (((x) & 0x00000100) >> 8)
-#define PHY_BB_MULTICHAIN_CONTROL_SYNC_SYNTHON_SET(x)                          (((x) << 8) & 0x00000100)
-#define PHY_BB_MULTICHAIN_CONTROL_USE_POSEDGE_REFCLK_MSB                                               9
-#define PHY_BB_MULTICHAIN_CONTROL_USE_POSEDGE_REFCLK_LSB                                               9
-#define PHY_BB_MULTICHAIN_CONTROL_USE_POSEDGE_REFCLK_MASK                                     0x00000200
-#define PHY_BB_MULTICHAIN_CONTROL_USE_POSEDGE_REFCLK_GET(x)                    (((x) & 0x00000200) >> 9)
-#define PHY_BB_MULTICHAIN_CONTROL_USE_POSEDGE_REFCLK_SET(x)                    (((x) << 9) & 0x00000200)
-#define PHY_BB_MULTICHAIN_CONTROL_CF_SHORT_SAT_MSB                                                    20
-#define PHY_BB_MULTICHAIN_CONTROL_CF_SHORT_SAT_LSB                                                    10
-#define PHY_BB_MULTICHAIN_CONTROL_CF_SHORT_SAT_MASK                                           0x001ffc00
-#define PHY_BB_MULTICHAIN_CONTROL_CF_SHORT_SAT_GET(x)                         (((x) & 0x001ffc00) >> 10)
-#define PHY_BB_MULTICHAIN_CONTROL_CF_SHORT_SAT_SET(x)                         (((x) << 10) & 0x001ffc00)
-#define PHY_BB_MULTICHAIN_CONTROL_FORCED_GAIN_DIFF_02_MSB                                             28
-#define PHY_BB_MULTICHAIN_CONTROL_FORCED_GAIN_DIFF_02_LSB                                             22
-#define PHY_BB_MULTICHAIN_CONTROL_FORCED_GAIN_DIFF_02_MASK                                    0x1fc00000
-#define PHY_BB_MULTICHAIN_CONTROL_FORCED_GAIN_DIFF_02_GET(x)                  (((x) & 0x1fc00000) >> 22)
-#define PHY_BB_MULTICHAIN_CONTROL_FORCED_GAIN_DIFF_02_SET(x)                  (((x) << 22) & 0x1fc00000)
-#define PHY_BB_MULTICHAIN_CONTROL_FORCE_SIGMA_ZERO_MSB                                                29
-#define PHY_BB_MULTICHAIN_CONTROL_FORCE_SIGMA_ZERO_LSB                                                29
-#define PHY_BB_MULTICHAIN_CONTROL_FORCE_SIGMA_ZERO_MASK                                       0x20000000
-#define PHY_BB_MULTICHAIN_CONTROL_FORCE_SIGMA_ZERO_GET(x)                     (((x) & 0x20000000) >> 29)
-#define PHY_BB_MULTICHAIN_CONTROL_FORCE_SIGMA_ZERO_SET(x)                     (((x) << 29) & 0x20000000)
-
-/* macros for BB_multichain_gain_ctrl */
-#define PHY_BB_MULTICHAIN_GAIN_CTRL_ADDRESS                                                   0x000099ac
-#define PHY_BB_MULTICHAIN_GAIN_CTRL_OFFSET                                                    0x000099ac
-#define PHY_BB_MULTICHAIN_GAIN_CTRL_QUICKDROP_LOW_MSB                                                  7
-#define PHY_BB_MULTICHAIN_GAIN_CTRL_QUICKDROP_LOW_LSB                                                  0
-#define PHY_BB_MULTICHAIN_GAIN_CTRL_QUICKDROP_LOW_MASK                                        0x000000ff
-#define PHY_BB_MULTICHAIN_GAIN_CTRL_QUICKDROP_LOW_GET(x)                       (((x) & 0x000000ff) >> 0)
-#define PHY_BB_MULTICHAIN_GAIN_CTRL_QUICKDROP_LOW_SET(x)                       (((x) << 0) & 0x000000ff)
-#define PHY_BB_MULTICHAIN_GAIN_CTRL_ENABLE_CHECK_STRONG_ANT_MSB                                        8
-#define PHY_BB_MULTICHAIN_GAIN_CTRL_ENABLE_CHECK_STRONG_ANT_LSB                                        8
-#define PHY_BB_MULTICHAIN_GAIN_CTRL_ENABLE_CHECK_STRONG_ANT_MASK                              0x00000100
-#define PHY_BB_MULTICHAIN_GAIN_CTRL_ENABLE_CHECK_STRONG_ANT_GET(x)             (((x) & 0x00000100) >> 8)
-#define PHY_BB_MULTICHAIN_GAIN_CTRL_ENABLE_CHECK_STRONG_ANT_SET(x)             (((x) << 8) & 0x00000100)
-#define PHY_BB_MULTICHAIN_GAIN_CTRL_ANT_FAST_DIV_BIAS_MSB                                             14
-#define PHY_BB_MULTICHAIN_GAIN_CTRL_ANT_FAST_DIV_BIAS_LSB                                              9
-#define PHY_BB_MULTICHAIN_GAIN_CTRL_ANT_FAST_DIV_BIAS_MASK                                    0x00007e00
-#define PHY_BB_MULTICHAIN_GAIN_CTRL_ANT_FAST_DIV_BIAS_GET(x)                   (((x) & 0x00007e00) >> 9)
-#define PHY_BB_MULTICHAIN_GAIN_CTRL_ANT_FAST_DIV_BIAS_SET(x)                   (((x) << 9) & 0x00007e00)
-#define PHY_BB_MULTICHAIN_GAIN_CTRL_CAP_GAIN_RATIO_SNR_MSB                                            20
-#define PHY_BB_MULTICHAIN_GAIN_CTRL_CAP_GAIN_RATIO_SNR_LSB                                            15
-#define PHY_BB_MULTICHAIN_GAIN_CTRL_CAP_GAIN_RATIO_SNR_MASK                                   0x001f8000
-#define PHY_BB_MULTICHAIN_GAIN_CTRL_CAP_GAIN_RATIO_SNR_GET(x)                 (((x) & 0x001f8000) >> 15)
-#define PHY_BB_MULTICHAIN_GAIN_CTRL_CAP_GAIN_RATIO_SNR_SET(x)                 (((x) << 15) & 0x001f8000)
-#define PHY_BB_MULTICHAIN_GAIN_CTRL_CAP_GAIN_RATIO_ENA_MSB                                            21
-#define PHY_BB_MULTICHAIN_GAIN_CTRL_CAP_GAIN_RATIO_ENA_LSB                                            21
-#define PHY_BB_MULTICHAIN_GAIN_CTRL_CAP_GAIN_RATIO_ENA_MASK                                   0x00200000
-#define PHY_BB_MULTICHAIN_GAIN_CTRL_CAP_GAIN_RATIO_ENA_GET(x)                 (((x) & 0x00200000) >> 21)
-#define PHY_BB_MULTICHAIN_GAIN_CTRL_CAP_GAIN_RATIO_ENA_SET(x)                 (((x) << 21) & 0x00200000)
-#define PHY_BB_MULTICHAIN_GAIN_CTRL_CAP_GAIN_RATIO_MODE_MSB                                           22
-#define PHY_BB_MULTICHAIN_GAIN_CTRL_CAP_GAIN_RATIO_MODE_LSB                                           22
-#define PHY_BB_MULTICHAIN_GAIN_CTRL_CAP_GAIN_RATIO_MODE_MASK                                  0x00400000
-#define PHY_BB_MULTICHAIN_GAIN_CTRL_CAP_GAIN_RATIO_MODE_GET(x)                (((x) & 0x00400000) >> 22)
-#define PHY_BB_MULTICHAIN_GAIN_CTRL_CAP_GAIN_RATIO_MODE_SET(x)                (((x) << 22) & 0x00400000)
-#define PHY_BB_MULTICHAIN_GAIN_CTRL_ENABLE_ANT_SW_RX_PROT_MSB                                         23
-#define PHY_BB_MULTICHAIN_GAIN_CTRL_ENABLE_ANT_SW_RX_PROT_LSB                                         23
-#define PHY_BB_MULTICHAIN_GAIN_CTRL_ENABLE_ANT_SW_RX_PROT_MASK                                0x00800000
-#define PHY_BB_MULTICHAIN_GAIN_CTRL_ENABLE_ANT_SW_RX_PROT_GET(x)              (((x) & 0x00800000) >> 23)
-#define PHY_BB_MULTICHAIN_GAIN_CTRL_ENABLE_ANT_SW_RX_PROT_SET(x)              (((x) << 23) & 0x00800000)
-#define PHY_BB_MULTICHAIN_GAIN_CTRL_ENABLE_ANT_DIV_LNADIV_MSB                                         24
-#define PHY_BB_MULTICHAIN_GAIN_CTRL_ENABLE_ANT_DIV_LNADIV_LSB                                         24
-#define PHY_BB_MULTICHAIN_GAIN_CTRL_ENABLE_ANT_DIV_LNADIV_MASK                                0x01000000
-#define PHY_BB_MULTICHAIN_GAIN_CTRL_ENABLE_ANT_DIV_LNADIV_GET(x)              (((x) & 0x01000000) >> 24)
-#define PHY_BB_MULTICHAIN_GAIN_CTRL_ENABLE_ANT_DIV_LNADIV_SET(x)              (((x) << 24) & 0x01000000)
-#define PHY_BB_MULTICHAIN_GAIN_CTRL_ANT_DIV_ALT_LNACONF_MSB                                           26
-#define PHY_BB_MULTICHAIN_GAIN_CTRL_ANT_DIV_ALT_LNACONF_LSB                                           25
-#define PHY_BB_MULTICHAIN_GAIN_CTRL_ANT_DIV_ALT_LNACONF_MASK                                  0x06000000
-#define PHY_BB_MULTICHAIN_GAIN_CTRL_ANT_DIV_ALT_LNACONF_GET(x)                (((x) & 0x06000000) >> 25)
-#define PHY_BB_MULTICHAIN_GAIN_CTRL_ANT_DIV_ALT_LNACONF_SET(x)                (((x) << 25) & 0x06000000)
-#define PHY_BB_MULTICHAIN_GAIN_CTRL_ANT_DIV_MAIN_LNACONF_MSB                                          28
-#define PHY_BB_MULTICHAIN_GAIN_CTRL_ANT_DIV_MAIN_LNACONF_LSB                                          27
-#define PHY_BB_MULTICHAIN_GAIN_CTRL_ANT_DIV_MAIN_LNACONF_MASK                                 0x18000000
-#define PHY_BB_MULTICHAIN_GAIN_CTRL_ANT_DIV_MAIN_LNACONF_GET(x)               (((x) & 0x18000000) >> 27)
-#define PHY_BB_MULTICHAIN_GAIN_CTRL_ANT_DIV_MAIN_LNACONF_SET(x)               (((x) << 27) & 0x18000000)
-#define PHY_BB_MULTICHAIN_GAIN_CTRL_ANT_DIV_ALT_GAINTB_MSB                                            29
-#define PHY_BB_MULTICHAIN_GAIN_CTRL_ANT_DIV_ALT_GAINTB_LSB                                            29
-#define PHY_BB_MULTICHAIN_GAIN_CTRL_ANT_DIV_ALT_GAINTB_MASK                                   0x20000000
-#define PHY_BB_MULTICHAIN_GAIN_CTRL_ANT_DIV_ALT_GAINTB_GET(x)                 (((x) & 0x20000000) >> 29)
-#define PHY_BB_MULTICHAIN_GAIN_CTRL_ANT_DIV_ALT_GAINTB_SET(x)                 (((x) << 29) & 0x20000000)
-#define PHY_BB_MULTICHAIN_GAIN_CTRL_ANT_DIV_MAIN_GAINTB_MSB                                           30
-#define PHY_BB_MULTICHAIN_GAIN_CTRL_ANT_DIV_MAIN_GAINTB_LSB                                           30
-#define PHY_BB_MULTICHAIN_GAIN_CTRL_ANT_DIV_MAIN_GAINTB_MASK                                  0x40000000
-#define PHY_BB_MULTICHAIN_GAIN_CTRL_ANT_DIV_MAIN_GAINTB_GET(x)                (((x) & 0x40000000) >> 30)
-#define PHY_BB_MULTICHAIN_GAIN_CTRL_ANT_DIV_MAIN_GAINTB_SET(x)                (((x) << 30) & 0x40000000)
-
-/* macros for BB_adc_gain_dc_corr_b0 */
-#define PHY_BB_ADC_GAIN_DC_CORR_B0_ADDRESS                                                    0x000099b4
-#define PHY_BB_ADC_GAIN_DC_CORR_B0_OFFSET                                                     0x000099b4
-#define PHY_BB_ADC_GAIN_DC_CORR_B0_ADC_GAIN_CORR_Q_COEFF_0_MSB                                         5
-#define PHY_BB_ADC_GAIN_DC_CORR_B0_ADC_GAIN_CORR_Q_COEFF_0_LSB                                         0
-#define PHY_BB_ADC_GAIN_DC_CORR_B0_ADC_GAIN_CORR_Q_COEFF_0_MASK                               0x0000003f
-#define PHY_BB_ADC_GAIN_DC_CORR_B0_ADC_GAIN_CORR_Q_COEFF_0_GET(x)              (((x) & 0x0000003f) >> 0)
-#define PHY_BB_ADC_GAIN_DC_CORR_B0_ADC_GAIN_CORR_Q_COEFF_0_SET(x)              (((x) << 0) & 0x0000003f)
-#define PHY_BB_ADC_GAIN_DC_CORR_B0_ADC_GAIN_CORR_I_COEFF_0_MSB                                        11
-#define PHY_BB_ADC_GAIN_DC_CORR_B0_ADC_GAIN_CORR_I_COEFF_0_LSB                                         6
-#define PHY_BB_ADC_GAIN_DC_CORR_B0_ADC_GAIN_CORR_I_COEFF_0_MASK                               0x00000fc0
-#define PHY_BB_ADC_GAIN_DC_CORR_B0_ADC_GAIN_CORR_I_COEFF_0_GET(x)              (((x) & 0x00000fc0) >> 6)
-#define PHY_BB_ADC_GAIN_DC_CORR_B0_ADC_GAIN_CORR_I_COEFF_0_SET(x)              (((x) << 6) & 0x00000fc0)
-#define PHY_BB_ADC_GAIN_DC_CORR_B0_ADC_DC_CORR_Q_COEFF_0_MSB                                          20
-#define PHY_BB_ADC_GAIN_DC_CORR_B0_ADC_DC_CORR_Q_COEFF_0_LSB                                          12
-#define PHY_BB_ADC_GAIN_DC_CORR_B0_ADC_DC_CORR_Q_COEFF_0_MASK                                 0x001ff000
-#define PHY_BB_ADC_GAIN_DC_CORR_B0_ADC_DC_CORR_Q_COEFF_0_GET(x)               (((x) & 0x001ff000) >> 12)
-#define PHY_BB_ADC_GAIN_DC_CORR_B0_ADC_DC_CORR_Q_COEFF_0_SET(x)               (((x) << 12) & 0x001ff000)
-#define PHY_BB_ADC_GAIN_DC_CORR_B0_ADC_DC_CORR_I_COEFF_0_MSB                                          29
-#define PHY_BB_ADC_GAIN_DC_CORR_B0_ADC_DC_CORR_I_COEFF_0_LSB                                          21
-#define PHY_BB_ADC_GAIN_DC_CORR_B0_ADC_DC_CORR_I_COEFF_0_MASK                                 0x3fe00000
-#define PHY_BB_ADC_GAIN_DC_CORR_B0_ADC_DC_CORR_I_COEFF_0_GET(x)               (((x) & 0x3fe00000) >> 21)
-#define PHY_BB_ADC_GAIN_DC_CORR_B0_ADC_DC_CORR_I_COEFF_0_SET(x)               (((x) << 21) & 0x3fe00000)
-#define PHY_BB_ADC_GAIN_DC_CORR_B0_ADC_GAIN_CORR_ENABLE_MSB                                           30
-#define PHY_BB_ADC_GAIN_DC_CORR_B0_ADC_GAIN_CORR_ENABLE_LSB                                           30
-#define PHY_BB_ADC_GAIN_DC_CORR_B0_ADC_GAIN_CORR_ENABLE_MASK                                  0x40000000
-#define PHY_BB_ADC_GAIN_DC_CORR_B0_ADC_GAIN_CORR_ENABLE_GET(x)                (((x) & 0x40000000) >> 30)
-#define PHY_BB_ADC_GAIN_DC_CORR_B0_ADC_GAIN_CORR_ENABLE_SET(x)                (((x) << 30) & 0x40000000)
-#define PHY_BB_ADC_GAIN_DC_CORR_B0_ADC_DC_CORR_ENABLE_MSB                                             31
-#define PHY_BB_ADC_GAIN_DC_CORR_B0_ADC_DC_CORR_ENABLE_LSB                                             31
-#define PHY_BB_ADC_GAIN_DC_CORR_B0_ADC_DC_CORR_ENABLE_MASK                                    0x80000000
-#define PHY_BB_ADC_GAIN_DC_CORR_B0_ADC_DC_CORR_ENABLE_GET(x)                  (((x) & 0x80000000) >> 31)
-#define PHY_BB_ADC_GAIN_DC_CORR_B0_ADC_DC_CORR_ENABLE_SET(x)                  (((x) << 31) & 0x80000000)
-
-/* macros for BB_ext_chan_pwr_thr_1 */
-#define PHY_BB_EXT_CHAN_PWR_THR_1_ADDRESS                                                     0x000099b8
-#define PHY_BB_EXT_CHAN_PWR_THR_1_OFFSET                                                      0x000099b8
-#define PHY_BB_EXT_CHAN_PWR_THR_1_THRESH62_EXT_MSB                                                     7
-#define PHY_BB_EXT_CHAN_PWR_THR_1_THRESH62_EXT_LSB                                                     0
-#define PHY_BB_EXT_CHAN_PWR_THR_1_THRESH62_EXT_MASK                                           0x000000ff
-#define PHY_BB_EXT_CHAN_PWR_THR_1_THRESH62_EXT_GET(x)                          (((x) & 0x000000ff) >> 0)
-#define PHY_BB_EXT_CHAN_PWR_THR_1_THRESH62_EXT_SET(x)                          (((x) << 0) & 0x000000ff)
-#define PHY_BB_EXT_CHAN_PWR_THR_1_ANT_DIV_ALT_ANT_MINGAINIDX_MSB                                      15
-#define PHY_BB_EXT_CHAN_PWR_THR_1_ANT_DIV_ALT_ANT_MINGAINIDX_LSB                                       8
-#define PHY_BB_EXT_CHAN_PWR_THR_1_ANT_DIV_ALT_ANT_MINGAINIDX_MASK                             0x0000ff00
-#define PHY_BB_EXT_CHAN_PWR_THR_1_ANT_DIV_ALT_ANT_MINGAINIDX_GET(x)            (((x) & 0x0000ff00) >> 8)
-#define PHY_BB_EXT_CHAN_PWR_THR_1_ANT_DIV_ALT_ANT_MINGAINIDX_SET(x)            (((x) << 8) & 0x0000ff00)
-#define PHY_BB_EXT_CHAN_PWR_THR_1_ANT_DIV_ALT_ANT_DELTAGAINIDX_MSB                                    20
-#define PHY_BB_EXT_CHAN_PWR_THR_1_ANT_DIV_ALT_ANT_DELTAGAINIDX_LSB                                    16
-#define PHY_BB_EXT_CHAN_PWR_THR_1_ANT_DIV_ALT_ANT_DELTAGAINIDX_MASK                           0x001f0000
-#define PHY_BB_EXT_CHAN_PWR_THR_1_ANT_DIV_ALT_ANT_DELTAGAINIDX_GET(x)         (((x) & 0x001f0000) >> 16)
-#define PHY_BB_EXT_CHAN_PWR_THR_1_ANT_DIV_ALT_ANT_DELTAGAINIDX_SET(x)         (((x) << 16) & 0x001f0000)
-#define PHY_BB_EXT_CHAN_PWR_THR_1_ANT_DIV_ALT_ANT_DELTANF_MSB                                         26
-#define PHY_BB_EXT_CHAN_PWR_THR_1_ANT_DIV_ALT_ANT_DELTANF_LSB                                         21
-#define PHY_BB_EXT_CHAN_PWR_THR_1_ANT_DIV_ALT_ANT_DELTANF_MASK                                0x07e00000
-#define PHY_BB_EXT_CHAN_PWR_THR_1_ANT_DIV_ALT_ANT_DELTANF_GET(x)              (((x) & 0x07e00000) >> 21)
-#define PHY_BB_EXT_CHAN_PWR_THR_1_ANT_DIV_ALT_ANT_DELTANF_SET(x)              (((x) << 21) & 0x07e00000)
-
-/* macros for BB_ext_chan_pwr_thr_2_b0 */
-#define PHY_BB_EXT_CHAN_PWR_THR_2_B0_ADDRESS                                                  0x000099bc
-#define PHY_BB_EXT_CHAN_PWR_THR_2_B0_OFFSET                                                   0x000099bc
-#define PHY_BB_EXT_CHAN_PWR_THR_2_B0_CF_MAXCCAPWR_EXT_0_MSB                                            8
-#define PHY_BB_EXT_CHAN_PWR_THR_2_B0_CF_MAXCCAPWR_EXT_0_LSB                                            0
-#define PHY_BB_EXT_CHAN_PWR_THR_2_B0_CF_MAXCCAPWR_EXT_0_MASK                                  0x000001ff
-#define PHY_BB_EXT_CHAN_PWR_THR_2_B0_CF_MAXCCAPWR_EXT_0_GET(x)                 (((x) & 0x000001ff) >> 0)
-#define PHY_BB_EXT_CHAN_PWR_THR_2_B0_CF_MAXCCAPWR_EXT_0_SET(x)                 (((x) << 0) & 0x000001ff)
-#define PHY_BB_EXT_CHAN_PWR_THR_2_B0_CYCPWR_THR1_EXT_MSB                                              15
-#define PHY_BB_EXT_CHAN_PWR_THR_2_B0_CYCPWR_THR1_EXT_LSB                                               9
-#define PHY_BB_EXT_CHAN_PWR_THR_2_B0_CYCPWR_THR1_EXT_MASK                                     0x0000fe00
-#define PHY_BB_EXT_CHAN_PWR_THR_2_B0_CYCPWR_THR1_EXT_GET(x)                    (((x) & 0x0000fe00) >> 9)
-#define PHY_BB_EXT_CHAN_PWR_THR_2_B0_CYCPWR_THR1_EXT_SET(x)                    (((x) << 9) & 0x0000fe00)
-#define PHY_BB_EXT_CHAN_PWR_THR_2_B0_MINCCAPWR_EXT_0_MSB                                              24
-#define PHY_BB_EXT_CHAN_PWR_THR_2_B0_MINCCAPWR_EXT_0_LSB                                              16
-#define PHY_BB_EXT_CHAN_PWR_THR_2_B0_MINCCAPWR_EXT_0_MASK                                     0x01ff0000
-#define PHY_BB_EXT_CHAN_PWR_THR_2_B0_MINCCAPWR_EXT_0_GET(x)                   (((x) & 0x01ff0000) >> 16)
-
-/* macros for BB_ext_chan_scorr_thr */
-#define PHY_BB_EXT_CHAN_SCORR_THR_ADDRESS                                                     0x000099c0
-#define PHY_BB_EXT_CHAN_SCORR_THR_OFFSET                                                      0x000099c0
-#define PHY_BB_EXT_CHAN_SCORR_THR_M1_THRES_EXT_MSB                                                     6
-#define PHY_BB_EXT_CHAN_SCORR_THR_M1_THRES_EXT_LSB                                                     0
-#define PHY_BB_EXT_CHAN_SCORR_THR_M1_THRES_EXT_MASK                                           0x0000007f
-#define PHY_BB_EXT_CHAN_SCORR_THR_M1_THRES_EXT_GET(x)                          (((x) & 0x0000007f) >> 0)
-#define PHY_BB_EXT_CHAN_SCORR_THR_M1_THRES_EXT_SET(x)                          (((x) << 0) & 0x0000007f)
-#define PHY_BB_EXT_CHAN_SCORR_THR_M2_THRES_EXT_MSB                                                    13
-#define PHY_BB_EXT_CHAN_SCORR_THR_M2_THRES_EXT_LSB                                                     7
-#define PHY_BB_EXT_CHAN_SCORR_THR_M2_THRES_EXT_MASK                                           0x00003f80
-#define PHY_BB_EXT_CHAN_SCORR_THR_M2_THRES_EXT_GET(x)                          (((x) & 0x00003f80) >> 7)
-#define PHY_BB_EXT_CHAN_SCORR_THR_M2_THRES_EXT_SET(x)                          (((x) << 7) & 0x00003f80)
-#define PHY_BB_EXT_CHAN_SCORR_THR_M1_THRES_LOW_EXT_MSB                                                20
-#define PHY_BB_EXT_CHAN_SCORR_THR_M1_THRES_LOW_EXT_LSB                                                14
-#define PHY_BB_EXT_CHAN_SCORR_THR_M1_THRES_LOW_EXT_MASK                                       0x001fc000
-#define PHY_BB_EXT_CHAN_SCORR_THR_M1_THRES_LOW_EXT_GET(x)                     (((x) & 0x001fc000) >> 14)
-#define PHY_BB_EXT_CHAN_SCORR_THR_M1_THRES_LOW_EXT_SET(x)                     (((x) << 14) & 0x001fc000)
-#define PHY_BB_EXT_CHAN_SCORR_THR_M2_THRES_LOW_EXT_MSB                                                27
-#define PHY_BB_EXT_CHAN_SCORR_THR_M2_THRES_LOW_EXT_LSB                                                21
-#define PHY_BB_EXT_CHAN_SCORR_THR_M2_THRES_LOW_EXT_MASK                                       0x0fe00000
-#define PHY_BB_EXT_CHAN_SCORR_THR_M2_THRES_LOW_EXT_GET(x)                     (((x) & 0x0fe00000) >> 21)
-#define PHY_BB_EXT_CHAN_SCORR_THR_M2_THRES_LOW_EXT_SET(x)                     (((x) << 21) & 0x0fe00000)
-#define PHY_BB_EXT_CHAN_SCORR_THR_SPUR_SUBCHANNEL_SD_MSB                                              28
-#define PHY_BB_EXT_CHAN_SCORR_THR_SPUR_SUBCHANNEL_SD_LSB                                              28
-#define PHY_BB_EXT_CHAN_SCORR_THR_SPUR_SUBCHANNEL_SD_MASK                                     0x10000000
-#define PHY_BB_EXT_CHAN_SCORR_THR_SPUR_SUBCHANNEL_SD_GET(x)                   (((x) & 0x10000000) >> 28)
-#define PHY_BB_EXT_CHAN_SCORR_THR_SPUR_SUBCHANNEL_SD_SET(x)                   (((x) << 28) & 0x10000000)
-
-/* macros for BB_ext_chan_detect_win */
-#define PHY_BB_EXT_CHAN_DETECT_WIN_ADDRESS                                                    0x000099c4
-#define PHY_BB_EXT_CHAN_DETECT_WIN_OFFSET                                                     0x000099c4
-#define PHY_BB_EXT_CHAN_DETECT_WIN_DET_DIFF_WIN_WEAK_MSB                                               3
-#define PHY_BB_EXT_CHAN_DETECT_WIN_DET_DIFF_WIN_WEAK_LSB                                               0
-#define PHY_BB_EXT_CHAN_DETECT_WIN_DET_DIFF_WIN_WEAK_MASK                                     0x0000000f
-#define PHY_BB_EXT_CHAN_DETECT_WIN_DET_DIFF_WIN_WEAK_GET(x)                    (((x) & 0x0000000f) >> 0)
-#define PHY_BB_EXT_CHAN_DETECT_WIN_DET_DIFF_WIN_WEAK_SET(x)                    (((x) << 0) & 0x0000000f)
-#define PHY_BB_EXT_CHAN_DETECT_WIN_DET_DIFF_WIN_WEAK_LOW_MSB                                           7
-#define PHY_BB_EXT_CHAN_DETECT_WIN_DET_DIFF_WIN_WEAK_LOW_LSB                                           4
-#define PHY_BB_EXT_CHAN_DETECT_WIN_DET_DIFF_WIN_WEAK_LOW_MASK                                 0x000000f0
-#define PHY_BB_EXT_CHAN_DETECT_WIN_DET_DIFF_WIN_WEAK_LOW_GET(x)                (((x) & 0x000000f0) >> 4)
-#define PHY_BB_EXT_CHAN_DETECT_WIN_DET_DIFF_WIN_WEAK_LOW_SET(x)                (((x) << 4) & 0x000000f0)
-#define PHY_BB_EXT_CHAN_DETECT_WIN_DET_DIFF_WIN_WEAK_CCK_MSB                                          12
-#define PHY_BB_EXT_CHAN_DETECT_WIN_DET_DIFF_WIN_WEAK_CCK_LSB                                           8
-#define PHY_BB_EXT_CHAN_DETECT_WIN_DET_DIFF_WIN_WEAK_CCK_MASK                                 0x00001f00
-#define PHY_BB_EXT_CHAN_DETECT_WIN_DET_DIFF_WIN_WEAK_CCK_GET(x)                (((x) & 0x00001f00) >> 8)
-#define PHY_BB_EXT_CHAN_DETECT_WIN_DET_DIFF_WIN_WEAK_CCK_SET(x)                (((x) << 8) & 0x00001f00)
-#define PHY_BB_EXT_CHAN_DETECT_WIN_DET_20H_COUNT_MSB                                                  15
-#define PHY_BB_EXT_CHAN_DETECT_WIN_DET_20H_COUNT_LSB                                                  13
-#define PHY_BB_EXT_CHAN_DETECT_WIN_DET_20H_COUNT_MASK                                         0x0000e000
-#define PHY_BB_EXT_CHAN_DETECT_WIN_DET_20H_COUNT_GET(x)                       (((x) & 0x0000e000) >> 13)
-#define PHY_BB_EXT_CHAN_DETECT_WIN_DET_20H_COUNT_SET(x)                       (((x) << 13) & 0x0000e000)
-#define PHY_BB_EXT_CHAN_DETECT_WIN_DET_EXT_BLK_COUNT_MSB                                              18
-#define PHY_BB_EXT_CHAN_DETECT_WIN_DET_EXT_BLK_COUNT_LSB                                              16
-#define PHY_BB_EXT_CHAN_DETECT_WIN_DET_EXT_BLK_COUNT_MASK                                     0x00070000
-#define PHY_BB_EXT_CHAN_DETECT_WIN_DET_EXT_BLK_COUNT_GET(x)                   (((x) & 0x00070000) >> 16)
-#define PHY_BB_EXT_CHAN_DETECT_WIN_DET_EXT_BLK_COUNT_SET(x)                   (((x) << 16) & 0x00070000)
-#define PHY_BB_EXT_CHAN_DETECT_WIN_WEAK_SIG_THR_CCK_EXT_MSB                                           24
-#define PHY_BB_EXT_CHAN_DETECT_WIN_WEAK_SIG_THR_CCK_EXT_LSB                                           19
-#define PHY_BB_EXT_CHAN_DETECT_WIN_WEAK_SIG_THR_CCK_EXT_MASK                                  0x01f80000
-#define PHY_BB_EXT_CHAN_DETECT_WIN_WEAK_SIG_THR_CCK_EXT_GET(x)                (((x) & 0x01f80000) >> 19)
-#define PHY_BB_EXT_CHAN_DETECT_WIN_WEAK_SIG_THR_CCK_EXT_SET(x)                (((x) << 19) & 0x01f80000)
-#define PHY_BB_EXT_CHAN_DETECT_WIN_DET_DIFF_WIN_THRESH_MSB                                            28
-#define PHY_BB_EXT_CHAN_DETECT_WIN_DET_DIFF_WIN_THRESH_LSB                                            25
-#define PHY_BB_EXT_CHAN_DETECT_WIN_DET_DIFF_WIN_THRESH_MASK                                   0x1e000000
-#define PHY_BB_EXT_CHAN_DETECT_WIN_DET_DIFF_WIN_THRESH_GET(x)                 (((x) & 0x1e000000) >> 25)
-#define PHY_BB_EXT_CHAN_DETECT_WIN_DET_DIFF_WIN_THRESH_SET(x)                 (((x) << 25) & 0x1e000000)
-
-/* macros for BB_pwr_thr_20_40_det */
-#define PHY_BB_PWR_THR_20_40_DET_ADDRESS                                                      0x000099c8
-#define PHY_BB_PWR_THR_20_40_DET_OFFSET                                                       0x000099c8
-#define PHY_BB_PWR_THR_20_40_DET_PWRDIFF40_THRSTR_MSB                                                  4
-#define PHY_BB_PWR_THR_20_40_DET_PWRDIFF40_THRSTR_LSB                                                  0
-#define PHY_BB_PWR_THR_20_40_DET_PWRDIFF40_THRSTR_MASK                                        0x0000001f
-#define PHY_BB_PWR_THR_20_40_DET_PWRDIFF40_THRSTR_GET(x)                       (((x) & 0x0000001f) >> 0)
-#define PHY_BB_PWR_THR_20_40_DET_PWRDIFF40_THRSTR_SET(x)                       (((x) << 0) & 0x0000001f)
-#define PHY_BB_PWR_THR_20_40_DET_BLOCKER40_MAX_MSB                                                    10
-#define PHY_BB_PWR_THR_20_40_DET_BLOCKER40_MAX_LSB                                                     5
-#define PHY_BB_PWR_THR_20_40_DET_BLOCKER40_MAX_MASK                                           0x000007e0
-#define PHY_BB_PWR_THR_20_40_DET_BLOCKER40_MAX_GET(x)                          (((x) & 0x000007e0) >> 5)
-#define PHY_BB_PWR_THR_20_40_DET_BLOCKER40_MAX_SET(x)                          (((x) << 5) & 0x000007e0)
-#define PHY_BB_PWR_THR_20_40_DET_DET40_PWRSTEP_MAX_MSB                                                15
-#define PHY_BB_PWR_THR_20_40_DET_DET40_PWRSTEP_MAX_LSB                                                11
-#define PHY_BB_PWR_THR_20_40_DET_DET40_PWRSTEP_MAX_MASK                                       0x0000f800
-#define PHY_BB_PWR_THR_20_40_DET_DET40_PWRSTEP_MAX_GET(x)                     (((x) & 0x0000f800) >> 11)
-#define PHY_BB_PWR_THR_20_40_DET_DET40_PWRSTEP_MAX_SET(x)                     (((x) << 11) & 0x0000f800)
-#define PHY_BB_PWR_THR_20_40_DET_DET40_THR_SNR_MSB                                                    23
-#define PHY_BB_PWR_THR_20_40_DET_DET40_THR_SNR_LSB                                                    16
-#define PHY_BB_PWR_THR_20_40_DET_DET40_THR_SNR_MASK                                           0x00ff0000
-#define PHY_BB_PWR_THR_20_40_DET_DET40_THR_SNR_GET(x)                         (((x) & 0x00ff0000) >> 16)
-#define PHY_BB_PWR_THR_20_40_DET_DET40_THR_SNR_SET(x)                         (((x) << 16) & 0x00ff0000)
-#define PHY_BB_PWR_THR_20_40_DET_DET40_PRI_BIAS_MSB                                                   28
-#define PHY_BB_PWR_THR_20_40_DET_DET40_PRI_BIAS_LSB                                                   24
-#define PHY_BB_PWR_THR_20_40_DET_DET40_PRI_BIAS_MASK                                          0x1f000000
-#define PHY_BB_PWR_THR_20_40_DET_DET40_PRI_BIAS_GET(x)                        (((x) & 0x1f000000) >> 24)
-#define PHY_BB_PWR_THR_20_40_DET_DET40_PRI_BIAS_SET(x)                        (((x) << 24) & 0x1f000000)
-#define PHY_BB_PWR_THR_20_40_DET_PWRSTEP40_ENA_MSB                                                    29
-#define PHY_BB_PWR_THR_20_40_DET_PWRSTEP40_ENA_LSB                                                    29
-#define PHY_BB_PWR_THR_20_40_DET_PWRSTEP40_ENA_MASK                                           0x20000000
-#define PHY_BB_PWR_THR_20_40_DET_PWRSTEP40_ENA_GET(x)                         (((x) & 0x20000000) >> 29)
-#define PHY_BB_PWR_THR_20_40_DET_PWRSTEP40_ENA_SET(x)                         (((x) << 29) & 0x20000000)
-#define PHY_BB_PWR_THR_20_40_DET_LOWSNR40_ENA_MSB                                                     30
-#define PHY_BB_PWR_THR_20_40_DET_LOWSNR40_ENA_LSB                                                     30
-#define PHY_BB_PWR_THR_20_40_DET_LOWSNR40_ENA_MASK                                            0x40000000
-#define PHY_BB_PWR_THR_20_40_DET_LOWSNR40_ENA_GET(x)                          (((x) & 0x40000000) >> 30)
-#define PHY_BB_PWR_THR_20_40_DET_LOWSNR40_ENA_SET(x)                          (((x) << 30) & 0x40000000)
-
-/* macros for BB_short_gi_delta_slope */
-#define PHY_BB_SHORT_GI_DELTA_SLOPE_ADDRESS                                                   0x000099d0
-#define PHY_BB_SHORT_GI_DELTA_SLOPE_OFFSET                                                    0x000099d0
-#define PHY_BB_SHORT_GI_DELTA_SLOPE_DELTA_SLOPE_COEF_EXP_SHORT_GI_MSB                                  3
-#define PHY_BB_SHORT_GI_DELTA_SLOPE_DELTA_SLOPE_COEF_EXP_SHORT_GI_LSB                                  0
-#define PHY_BB_SHORT_GI_DELTA_SLOPE_DELTA_SLOPE_COEF_EXP_SHORT_GI_MASK                        0x0000000f
-#define PHY_BB_SHORT_GI_DELTA_SLOPE_DELTA_SLOPE_COEF_EXP_SHORT_GI_GET(x)       (((x) & 0x0000000f) >> 0)
-#define PHY_BB_SHORT_GI_DELTA_SLOPE_DELTA_SLOPE_COEF_EXP_SHORT_GI_SET(x)       (((x) << 0) & 0x0000000f)
-#define PHY_BB_SHORT_GI_DELTA_SLOPE_DELTA_SLOPE_COEF_MAN_SHORT_GI_MSB                                 18
-#define PHY_BB_SHORT_GI_DELTA_SLOPE_DELTA_SLOPE_COEF_MAN_SHORT_GI_LSB                                  4
-#define PHY_BB_SHORT_GI_DELTA_SLOPE_DELTA_SLOPE_COEF_MAN_SHORT_GI_MASK                        0x0007fff0
-#define PHY_BB_SHORT_GI_DELTA_SLOPE_DELTA_SLOPE_COEF_MAN_SHORT_GI_GET(x)       (((x) & 0x0007fff0) >> 4)
-#define PHY_BB_SHORT_GI_DELTA_SLOPE_DELTA_SLOPE_COEF_MAN_SHORT_GI_SET(x)       (((x) << 4) & 0x0007fff0)
-
-/* macros for BB_chaninfo_ctrl */
-#define PHY_BB_CHANINFO_CTRL_ADDRESS                                                          0x000099dc
-#define PHY_BB_CHANINFO_CTRL_OFFSET                                                           0x000099dc
-#define PHY_BB_CHANINFO_CTRL_CAPTURE_CHAN_INFO_MSB                                                     0
-#define PHY_BB_CHANINFO_CTRL_CAPTURE_CHAN_INFO_LSB                                                     0
-#define PHY_BB_CHANINFO_CTRL_CAPTURE_CHAN_INFO_MASK                                           0x00000001
-#define PHY_BB_CHANINFO_CTRL_CAPTURE_CHAN_INFO_GET(x)                          (((x) & 0x00000001) >> 0)
-#define PHY_BB_CHANINFO_CTRL_CAPTURE_CHAN_INFO_SET(x)                          (((x) << 0) & 0x00000001)
-#define PHY_BB_CHANINFO_CTRL_DISABLE_CHANINFOMEM_MSB                                                   1
-#define PHY_BB_CHANINFO_CTRL_DISABLE_CHANINFOMEM_LSB                                                   1
-#define PHY_BB_CHANINFO_CTRL_DISABLE_CHANINFOMEM_MASK                                         0x00000002
-#define PHY_BB_CHANINFO_CTRL_DISABLE_CHANINFOMEM_GET(x)                        (((x) & 0x00000002) >> 1)
-#define PHY_BB_CHANINFO_CTRL_DISABLE_CHANINFOMEM_SET(x)                        (((x) << 1) & 0x00000002)
-
-/* macros for BB_heavy_clip_ctrl */
-#define PHY_BB_HEAVY_CLIP_CTRL_ADDRESS                                                        0x000099e0
-#define PHY_BB_HEAVY_CLIP_CTRL_OFFSET                                                         0x000099e0
-#define PHY_BB_HEAVY_CLIP_CTRL_CF_HEAVY_CLIP_ENABLE_MSB                                                8
-#define PHY_BB_HEAVY_CLIP_CTRL_CF_HEAVY_CLIP_ENABLE_LSB                                                0
-#define PHY_BB_HEAVY_CLIP_CTRL_CF_HEAVY_CLIP_ENABLE_MASK                                      0x000001ff
-#define PHY_BB_HEAVY_CLIP_CTRL_CF_HEAVY_CLIP_ENABLE_GET(x)                     (((x) & 0x000001ff) >> 0)
-#define PHY_BB_HEAVY_CLIP_CTRL_CF_HEAVY_CLIP_ENABLE_SET(x)                     (((x) << 0) & 0x000001ff)
-#define PHY_BB_HEAVY_CLIP_CTRL_PRE_EMP_HT40_ENABLE_MSB                                                 9
-#define PHY_BB_HEAVY_CLIP_CTRL_PRE_EMP_HT40_ENABLE_LSB                                                 9
-#define PHY_BB_HEAVY_CLIP_CTRL_PRE_EMP_HT40_ENABLE_MASK                                       0x00000200
-#define PHY_BB_HEAVY_CLIP_CTRL_PRE_EMP_HT40_ENABLE_GET(x)                      (((x) & 0x00000200) >> 9)
-#define PHY_BB_HEAVY_CLIP_CTRL_PRE_EMP_HT40_ENABLE_SET(x)                      (((x) << 9) & 0x00000200)
-
-/* macros for BB_heavy_clip_20 */
-#define PHY_BB_HEAVY_CLIP_20_ADDRESS                                                          0x000099e4
-#define PHY_BB_HEAVY_CLIP_20_OFFSET                                                           0x000099e4
-#define PHY_BB_HEAVY_CLIP_20_HEAVY_CLIP_FACTOR_0_MSB                                                   7
-#define PHY_BB_HEAVY_CLIP_20_HEAVY_CLIP_FACTOR_0_LSB                                                   0
-#define PHY_BB_HEAVY_CLIP_20_HEAVY_CLIP_FACTOR_0_MASK                                         0x000000ff
-#define PHY_BB_HEAVY_CLIP_20_HEAVY_CLIP_FACTOR_0_GET(x)                        (((x) & 0x000000ff) >> 0)
-#define PHY_BB_HEAVY_CLIP_20_HEAVY_CLIP_FACTOR_0_SET(x)                        (((x) << 0) & 0x000000ff)
-#define PHY_BB_HEAVY_CLIP_20_HEAVY_CLIP_FACTOR_1_MSB                                                  15
-#define PHY_BB_HEAVY_CLIP_20_HEAVY_CLIP_FACTOR_1_LSB                                                   8
-#define PHY_BB_HEAVY_CLIP_20_HEAVY_CLIP_FACTOR_1_MASK                                         0x0000ff00
-#define PHY_BB_HEAVY_CLIP_20_HEAVY_CLIP_FACTOR_1_GET(x)                        (((x) & 0x0000ff00) >> 8)
-#define PHY_BB_HEAVY_CLIP_20_HEAVY_CLIP_FACTOR_1_SET(x)                        (((x) << 8) & 0x0000ff00)
-#define PHY_BB_HEAVY_CLIP_20_HEAVY_CLIP_FACTOR_2_MSB                                                  23
-#define PHY_BB_HEAVY_CLIP_20_HEAVY_CLIP_FACTOR_2_LSB                                                  16
-#define PHY_BB_HEAVY_CLIP_20_HEAVY_CLIP_FACTOR_2_MASK                                         0x00ff0000
-#define PHY_BB_HEAVY_CLIP_20_HEAVY_CLIP_FACTOR_2_GET(x)                       (((x) & 0x00ff0000) >> 16)
-#define PHY_BB_HEAVY_CLIP_20_HEAVY_CLIP_FACTOR_2_SET(x)                       (((x) << 16) & 0x00ff0000)
-#define PHY_BB_HEAVY_CLIP_20_HEAVY_CLIP_FACTOR_3_MSB                                                  31
-#define PHY_BB_HEAVY_CLIP_20_HEAVY_CLIP_FACTOR_3_LSB                                                  24
-#define PHY_BB_HEAVY_CLIP_20_HEAVY_CLIP_FACTOR_3_MASK                                         0xff000000
-#define PHY_BB_HEAVY_CLIP_20_HEAVY_CLIP_FACTOR_3_GET(x)                       (((x) & 0xff000000) >> 24)
-#define PHY_BB_HEAVY_CLIP_20_HEAVY_CLIP_FACTOR_3_SET(x)                       (((x) << 24) & 0xff000000)
-
-/* macros for BB_heavy_clip_40 */
-#define PHY_BB_HEAVY_CLIP_40_ADDRESS                                                          0x000099e8
-#define PHY_BB_HEAVY_CLIP_40_OFFSET                                                           0x000099e8
-#define PHY_BB_HEAVY_CLIP_40_HEAVY_CLIP_FACTOR_4_MSB                                                   7
-#define PHY_BB_HEAVY_CLIP_40_HEAVY_CLIP_FACTOR_4_LSB                                                   0
-#define PHY_BB_HEAVY_CLIP_40_HEAVY_CLIP_FACTOR_4_MASK                                         0x000000ff
-#define PHY_BB_HEAVY_CLIP_40_HEAVY_CLIP_FACTOR_4_GET(x)                        (((x) & 0x000000ff) >> 0)
-#define PHY_BB_HEAVY_CLIP_40_HEAVY_CLIP_FACTOR_4_SET(x)                        (((x) << 0) & 0x000000ff)
-#define PHY_BB_HEAVY_CLIP_40_HEAVY_CLIP_FACTOR_5_MSB                                                  15
-#define PHY_BB_HEAVY_CLIP_40_HEAVY_CLIP_FACTOR_5_LSB                                                   8
-#define PHY_BB_HEAVY_CLIP_40_HEAVY_CLIP_FACTOR_5_MASK                                         0x0000ff00
-#define PHY_BB_HEAVY_CLIP_40_HEAVY_CLIP_FACTOR_5_GET(x)                        (((x) & 0x0000ff00) >> 8)
-#define PHY_BB_HEAVY_CLIP_40_HEAVY_CLIP_FACTOR_5_SET(x)                        (((x) << 8) & 0x0000ff00)
-#define PHY_BB_HEAVY_CLIP_40_HEAVY_CLIP_FACTOR_6_MSB                                                  23
-#define PHY_BB_HEAVY_CLIP_40_HEAVY_CLIP_FACTOR_6_LSB                                                  16
-#define PHY_BB_HEAVY_CLIP_40_HEAVY_CLIP_FACTOR_6_MASK                                         0x00ff0000
-#define PHY_BB_HEAVY_CLIP_40_HEAVY_CLIP_FACTOR_6_GET(x)                       (((x) & 0x00ff0000) >> 16)
-#define PHY_BB_HEAVY_CLIP_40_HEAVY_CLIP_FACTOR_6_SET(x)                       (((x) << 16) & 0x00ff0000)
-#define PHY_BB_HEAVY_CLIP_40_HEAVY_CLIP_FACTOR_7_MSB                                                  31
-#define PHY_BB_HEAVY_CLIP_40_HEAVY_CLIP_FACTOR_7_LSB                                                  24
-#define PHY_BB_HEAVY_CLIP_40_HEAVY_CLIP_FACTOR_7_MASK                                         0xff000000
-#define PHY_BB_HEAVY_CLIP_40_HEAVY_CLIP_FACTOR_7_GET(x)                       (((x) & 0xff000000) >> 24)
-#define PHY_BB_HEAVY_CLIP_40_HEAVY_CLIP_FACTOR_7_SET(x)                       (((x) << 24) & 0xff000000)
-
-/* macros for BB_rifs_srch */
-#define PHY_BB_RIFS_SRCH_ADDRESS                                                              0x000099ec
-#define PHY_BB_RIFS_SRCH_OFFSET                                                               0x000099ec
-#define PHY_BB_RIFS_SRCH_HEAVY_CLIP_FACTOR_XR_MSB                                                      7
-#define PHY_BB_RIFS_SRCH_HEAVY_CLIP_FACTOR_XR_LSB                                                      0
-#define PHY_BB_RIFS_SRCH_HEAVY_CLIP_FACTOR_XR_MASK                                            0x000000ff
-#define PHY_BB_RIFS_SRCH_HEAVY_CLIP_FACTOR_XR_GET(x)                           (((x) & 0x000000ff) >> 0)
-#define PHY_BB_RIFS_SRCH_HEAVY_CLIP_FACTOR_XR_SET(x)                           (((x) << 0) & 0x000000ff)
-#define PHY_BB_RIFS_SRCH_INIT_GAIN_DB_OFFSET_MSB                                                      15
-#define PHY_BB_RIFS_SRCH_INIT_GAIN_DB_OFFSET_LSB                                                       8
-#define PHY_BB_RIFS_SRCH_INIT_GAIN_DB_OFFSET_MASK                                             0x0000ff00
-#define PHY_BB_RIFS_SRCH_INIT_GAIN_DB_OFFSET_GET(x)                            (((x) & 0x0000ff00) >> 8)
-#define PHY_BB_RIFS_SRCH_INIT_GAIN_DB_OFFSET_SET(x)                            (((x) << 8) & 0x0000ff00)
-#define PHY_BB_RIFS_SRCH_RIFS_INIT_DELAY_MSB                                                          25
-#define PHY_BB_RIFS_SRCH_RIFS_INIT_DELAY_LSB                                                          16
-#define PHY_BB_RIFS_SRCH_RIFS_INIT_DELAY_MASK                                                 0x03ff0000
-#define PHY_BB_RIFS_SRCH_RIFS_INIT_DELAY_GET(x)                               (((x) & 0x03ff0000) >> 16)
-#define PHY_BB_RIFS_SRCH_RIFS_INIT_DELAY_SET(x)                               (((x) << 16) & 0x03ff0000)
-#define PHY_BB_RIFS_SRCH_RIFS_DISABLE_PWRLOW_GC_MSB                                                   26
-#define PHY_BB_RIFS_SRCH_RIFS_DISABLE_PWRLOW_GC_LSB                                                   26
-#define PHY_BB_RIFS_SRCH_RIFS_DISABLE_PWRLOW_GC_MASK                                          0x04000000
-#define PHY_BB_RIFS_SRCH_RIFS_DISABLE_PWRLOW_GC_GET(x)                        (((x) & 0x04000000) >> 26)
-#define PHY_BB_RIFS_SRCH_RIFS_DISABLE_PWRLOW_GC_SET(x)                        (((x) << 26) & 0x04000000)
-#define PHY_BB_RIFS_SRCH_RIFS_DISABLE_CCK_DET_MSB                                                     27
-#define PHY_BB_RIFS_SRCH_RIFS_DISABLE_CCK_DET_LSB                                                     27
-#define PHY_BB_RIFS_SRCH_RIFS_DISABLE_CCK_DET_MASK                                            0x08000000
-#define PHY_BB_RIFS_SRCH_RIFS_DISABLE_CCK_DET_GET(x)                          (((x) & 0x08000000) >> 27)
-#define PHY_BB_RIFS_SRCH_RIFS_DISABLE_CCK_DET_SET(x)                          (((x) << 27) & 0x08000000)
-
-/* macros for BB_iq_adc_cal_mode */
-#define PHY_BB_IQ_ADC_CAL_MODE_ADDRESS                                                        0x000099f0
-#define PHY_BB_IQ_ADC_CAL_MODE_OFFSET                                                         0x000099f0
-#define PHY_BB_IQ_ADC_CAL_MODE_GAIN_DC_IQ_CAL_MODE_MSB                                                 1
-#define PHY_BB_IQ_ADC_CAL_MODE_GAIN_DC_IQ_CAL_MODE_LSB                                                 0
-#define PHY_BB_IQ_ADC_CAL_MODE_GAIN_DC_IQ_CAL_MODE_MASK                                       0x00000003
-#define PHY_BB_IQ_ADC_CAL_MODE_GAIN_DC_IQ_CAL_MODE_GET(x)                      (((x) & 0x00000003) >> 0)
-#define PHY_BB_IQ_ADC_CAL_MODE_GAIN_DC_IQ_CAL_MODE_SET(x)                      (((x) << 0) & 0x00000003)
-#define PHY_BB_IQ_ADC_CAL_MODE_TEST_CALADCOFF_MSB                                                      2
-#define PHY_BB_IQ_ADC_CAL_MODE_TEST_CALADCOFF_LSB                                                      2
-#define PHY_BB_IQ_ADC_CAL_MODE_TEST_CALADCOFF_MASK                                            0x00000004
-#define PHY_BB_IQ_ADC_CAL_MODE_TEST_CALADCOFF_GET(x)                           (((x) & 0x00000004) >> 2)
-#define PHY_BB_IQ_ADC_CAL_MODE_TEST_CALADCOFF_SET(x)                           (((x) << 2) & 0x00000004)
-
-/* macros for BB_per_chain_csd */
-#define PHY_BB_PER_CHAIN_CSD_ADDRESS                                                          0x000099fc
-#define PHY_BB_PER_CHAIN_CSD_OFFSET                                                           0x000099fc
-#define PHY_BB_PER_CHAIN_CSD_CSD_CHN1_2CHAINS_MSB                                                      4
-#define PHY_BB_PER_CHAIN_CSD_CSD_CHN1_2CHAINS_LSB                                                      0
-#define PHY_BB_PER_CHAIN_CSD_CSD_CHN1_2CHAINS_MASK                                            0x0000001f
-#define PHY_BB_PER_CHAIN_CSD_CSD_CHN1_2CHAINS_GET(x)                           (((x) & 0x0000001f) >> 0)
-#define PHY_BB_PER_CHAIN_CSD_CSD_CHN1_2CHAINS_SET(x)                           (((x) << 0) & 0x0000001f)
-#define PHY_BB_PER_CHAIN_CSD_CSD_CHN1_3CHAINS_MSB                                                      9
-#define PHY_BB_PER_CHAIN_CSD_CSD_CHN1_3CHAINS_LSB                                                      5
-#define PHY_BB_PER_CHAIN_CSD_CSD_CHN1_3CHAINS_MASK                                            0x000003e0
-#define PHY_BB_PER_CHAIN_CSD_CSD_CHN1_3CHAINS_GET(x)                           (((x) & 0x000003e0) >> 5)
-#define PHY_BB_PER_CHAIN_CSD_CSD_CHN1_3CHAINS_SET(x)                           (((x) << 5) & 0x000003e0)
-#define PHY_BB_PER_CHAIN_CSD_CSD_CHN2_3CHAINS_MSB                                                     14
-#define PHY_BB_PER_CHAIN_CSD_CSD_CHN2_3CHAINS_LSB                                                     10
-#define PHY_BB_PER_CHAIN_CSD_CSD_CHN2_3CHAINS_MASK                                            0x00007c00
-#define PHY_BB_PER_CHAIN_CSD_CSD_CHN2_3CHAINS_GET(x)                          (((x) & 0x00007c00) >> 10)
-#define PHY_BB_PER_CHAIN_CSD_CSD_CHN2_3CHAINS_SET(x)                          (((x) << 10) & 0x00007c00)
-
-/* macros for BB_rx_ocgain */
-#define PHY_BB_RX_OCGAIN_ADDRESS                                                              0x00009a00
-#define PHY_BB_RX_OCGAIN_OFFSET                                                               0x00009a00
-#define PHY_BB_RX_OCGAIN_GAIN_ENTRY_MSB                                                               31
-#define PHY_BB_RX_OCGAIN_GAIN_ENTRY_LSB                                                                0
-#define PHY_BB_RX_OCGAIN_GAIN_ENTRY_MASK                                                      0xffffffff
-#define PHY_BB_RX_OCGAIN_GAIN_ENTRY_SET(x)                                     (((x) << 0) & 0xffffffff)
-
-/* macros for BB_tx_crc */
-#define PHY_BB_TX_CRC_ADDRESS                                                                 0x00009c00
-#define PHY_BB_TX_CRC_OFFSET                                                                  0x00009c00
-#define PHY_BB_TX_CRC_TX_CRC_MSB                                                                      15
-#define PHY_BB_TX_CRC_TX_CRC_LSB                                                                       0
-#define PHY_BB_TX_CRC_TX_CRC_MASK                                                             0x0000ffff
-#define PHY_BB_TX_CRC_TX_CRC_GET(x)                                            (((x) & 0x0000ffff) >> 0)
-
-/* macros for BB_iq_adc_meas_0_b0 */
-#define PHY_BB_IQ_ADC_MEAS_0_B0_ADDRESS                                                       0x00009c10
-#define PHY_BB_IQ_ADC_MEAS_0_B0_OFFSET                                                        0x00009c10
-#define PHY_BB_IQ_ADC_MEAS_0_B0_GAIN_DC_IQ_CAL_MEAS_0_0_MSB                                           31
-#define PHY_BB_IQ_ADC_MEAS_0_B0_GAIN_DC_IQ_CAL_MEAS_0_0_LSB                                            0
-#define PHY_BB_IQ_ADC_MEAS_0_B0_GAIN_DC_IQ_CAL_MEAS_0_0_MASK                                  0xffffffff
-#define PHY_BB_IQ_ADC_MEAS_0_B0_GAIN_DC_IQ_CAL_MEAS_0_0_GET(x)                 (((x) & 0xffffffff) >> 0)
-
-/* macros for BB_iq_adc_meas_1_b0 */
-#define PHY_BB_IQ_ADC_MEAS_1_B0_ADDRESS                                                       0x00009c14
-#define PHY_BB_IQ_ADC_MEAS_1_B0_OFFSET                                                        0x00009c14
-#define PHY_BB_IQ_ADC_MEAS_1_B0_GAIN_DC_IQ_CAL_MEAS_1_0_MSB                                           31
-#define PHY_BB_IQ_ADC_MEAS_1_B0_GAIN_DC_IQ_CAL_MEAS_1_0_LSB                                            0
-#define PHY_BB_IQ_ADC_MEAS_1_B0_GAIN_DC_IQ_CAL_MEAS_1_0_MASK                                  0xffffffff
-#define PHY_BB_IQ_ADC_MEAS_1_B0_GAIN_DC_IQ_CAL_MEAS_1_0_GET(x)                 (((x) & 0xffffffff) >> 0)
-
-/* macros for BB_iq_adc_meas_2_b0 */
-#define PHY_BB_IQ_ADC_MEAS_2_B0_ADDRESS                                                       0x00009c18
-#define PHY_BB_IQ_ADC_MEAS_2_B0_OFFSET                                                        0x00009c18
-#define PHY_BB_IQ_ADC_MEAS_2_B0_GAIN_DC_IQ_CAL_MEAS_2_0_MSB                                           31
-#define PHY_BB_IQ_ADC_MEAS_2_B0_GAIN_DC_IQ_CAL_MEAS_2_0_LSB                                            0
-#define PHY_BB_IQ_ADC_MEAS_2_B0_GAIN_DC_IQ_CAL_MEAS_2_0_MASK                                  0xffffffff
-#define PHY_BB_IQ_ADC_MEAS_2_B0_GAIN_DC_IQ_CAL_MEAS_2_0_GET(x)                 (((x) & 0xffffffff) >> 0)
-
-/* macros for BB_iq_adc_meas_3_b0 */
-#define PHY_BB_IQ_ADC_MEAS_3_B0_ADDRESS                                                       0x00009c1c
-#define PHY_BB_IQ_ADC_MEAS_3_B0_OFFSET                                                        0x00009c1c
-#define PHY_BB_IQ_ADC_MEAS_3_B0_GAIN_DC_IQ_CAL_MEAS_3_0_MSB                                           31
-#define PHY_BB_IQ_ADC_MEAS_3_B0_GAIN_DC_IQ_CAL_MEAS_3_0_LSB                                            0
-#define PHY_BB_IQ_ADC_MEAS_3_B0_GAIN_DC_IQ_CAL_MEAS_3_0_MASK                                  0xffffffff
-#define PHY_BB_IQ_ADC_MEAS_3_B0_GAIN_DC_IQ_CAL_MEAS_3_0_GET(x)                 (((x) & 0xffffffff) >> 0)
-
-/* macros for BB_rfbus_grant */
-#define PHY_BB_RFBUS_GRANT_ADDRESS                                                            0x00009c20
-#define PHY_BB_RFBUS_GRANT_OFFSET                                                             0x00009c20
-#define PHY_BB_RFBUS_GRANT_RFBUS_GRANT_MSB                                                             0
-#define PHY_BB_RFBUS_GRANT_RFBUS_GRANT_LSB                                                             0
-#define PHY_BB_RFBUS_GRANT_RFBUS_GRANT_MASK                                                   0x00000001
-#define PHY_BB_RFBUS_GRANT_RFBUS_GRANT_GET(x)                                  (((x) & 0x00000001) >> 0)
-#define PHY_BB_RFBUS_GRANT_BT_ANT_MSB                                                                  1
-#define PHY_BB_RFBUS_GRANT_BT_ANT_LSB                                                                  1
-#define PHY_BB_RFBUS_GRANT_BT_ANT_MASK                                                        0x00000002
-#define PHY_BB_RFBUS_GRANT_BT_ANT_GET(x)                                       (((x) & 0x00000002) >> 1)
-
-/* macros for BB_tstadc */
-#define PHY_BB_TSTADC_ADDRESS                                                                 0x00009c24
-#define PHY_BB_TSTADC_OFFSET                                                                  0x00009c24
-#define PHY_BB_TSTADC_TSTADC_OUT_Q_MSB                                                                 9
-#define PHY_BB_TSTADC_TSTADC_OUT_Q_LSB                                                                 0
-#define PHY_BB_TSTADC_TSTADC_OUT_Q_MASK                                                       0x000003ff
-#define PHY_BB_TSTADC_TSTADC_OUT_Q_GET(x)                                      (((x) & 0x000003ff) >> 0)
-#define PHY_BB_TSTADC_TSTADC_OUT_I_MSB                                                                19
-#define PHY_BB_TSTADC_TSTADC_OUT_I_LSB                                                                10
-#define PHY_BB_TSTADC_TSTADC_OUT_I_MASK                                                       0x000ffc00
-#define PHY_BB_TSTADC_TSTADC_OUT_I_GET(x)                                     (((x) & 0x000ffc00) >> 10)
-
-/* macros for BB_tstdac */
-#define PHY_BB_TSTDAC_ADDRESS                                                                 0x00009c28
-#define PHY_BB_TSTDAC_OFFSET                                                                  0x00009c28
-#define PHY_BB_TSTDAC_TSTDAC_OUT_Q_MSB                                                                 9
-#define PHY_BB_TSTDAC_TSTDAC_OUT_Q_LSB                                                                 0
-#define PHY_BB_TSTDAC_TSTDAC_OUT_Q_MASK                                                       0x000003ff
-#define PHY_BB_TSTDAC_TSTDAC_OUT_Q_GET(x)                                      (((x) & 0x000003ff) >> 0)
-#define PHY_BB_TSTDAC_TSTDAC_OUT_I_MSB                                                                19
-#define PHY_BB_TSTDAC_TSTDAC_OUT_I_LSB                                                                10
-#define PHY_BB_TSTDAC_TSTDAC_OUT_I_MASK                                                       0x000ffc00
-#define PHY_BB_TSTDAC_TSTDAC_OUT_I_GET(x)                                     (((x) & 0x000ffc00) >> 10)
-
-/* macros for BB_illegal_tx_rate */
-#define PHY_BB_ILLEGAL_TX_RATE_ADDRESS                                                        0x00009c30
-#define PHY_BB_ILLEGAL_TX_RATE_OFFSET                                                         0x00009c30
-#define PHY_BB_ILLEGAL_TX_RATE_ILLEGAL_TX_RATE_MSB                                                     0
-#define PHY_BB_ILLEGAL_TX_RATE_ILLEGAL_TX_RATE_LSB                                                     0
-#define PHY_BB_ILLEGAL_TX_RATE_ILLEGAL_TX_RATE_MASK                                           0x00000001
-#define PHY_BB_ILLEGAL_TX_RATE_ILLEGAL_TX_RATE_GET(x)                          (((x) & 0x00000001) >> 0)
-
-/* macros for BB_spur_report_b0 */
-#define PHY_BB_SPUR_REPORT_B0_ADDRESS                                                         0x00009c34
-#define PHY_BB_SPUR_REPORT_B0_OFFSET                                                          0x00009c34
-#define PHY_BB_SPUR_REPORT_B0_SPUR_EST_I_0_MSB                                                         7
-#define PHY_BB_SPUR_REPORT_B0_SPUR_EST_I_0_LSB                                                         0
-#define PHY_BB_SPUR_REPORT_B0_SPUR_EST_I_0_MASK                                               0x000000ff
-#define PHY_BB_SPUR_REPORT_B0_SPUR_EST_I_0_GET(x)                              (((x) & 0x000000ff) >> 0)
-#define PHY_BB_SPUR_REPORT_B0_SPUR_EST_Q_0_MSB                                                        15
-#define PHY_BB_SPUR_REPORT_B0_SPUR_EST_Q_0_LSB                                                         8
-#define PHY_BB_SPUR_REPORT_B0_SPUR_EST_Q_0_MASK                                               0x0000ff00
-#define PHY_BB_SPUR_REPORT_B0_SPUR_EST_Q_0_GET(x)                              (((x) & 0x0000ff00) >> 8)
-#define PHY_BB_SPUR_REPORT_B0_POWER_WITH_SPUR_REMOVED_0_MSB                                           31
-#define PHY_BB_SPUR_REPORT_B0_POWER_WITH_SPUR_REMOVED_0_LSB                                           16
-#define PHY_BB_SPUR_REPORT_B0_POWER_WITH_SPUR_REMOVED_0_MASK                                  0xffff0000
-#define PHY_BB_SPUR_REPORT_B0_POWER_WITH_SPUR_REMOVED_0_GET(x)                (((x) & 0xffff0000) >> 16)
-
-/* macros for BB_channel_status */
-#define PHY_BB_CHANNEL_STATUS_ADDRESS                                                         0x00009c38
-#define PHY_BB_CHANNEL_STATUS_OFFSET                                                          0x00009c38
-#define PHY_BB_CHANNEL_STATUS_BT_ACTIVE_MSB                                                            0
-#define PHY_BB_CHANNEL_STATUS_BT_ACTIVE_LSB                                                            0
-#define PHY_BB_CHANNEL_STATUS_BT_ACTIVE_MASK                                                  0x00000001
-#define PHY_BB_CHANNEL_STATUS_BT_ACTIVE_GET(x)                                 (((x) & 0x00000001) >> 0)
-#define PHY_BB_CHANNEL_STATUS_RX_CLEAR_RAW_MSB                                                         1
-#define PHY_BB_CHANNEL_STATUS_RX_CLEAR_RAW_LSB                                                         1
-#define PHY_BB_CHANNEL_STATUS_RX_CLEAR_RAW_MASK                                               0x00000002
-#define PHY_BB_CHANNEL_STATUS_RX_CLEAR_RAW_GET(x)                              (((x) & 0x00000002) >> 1)
-#define PHY_BB_CHANNEL_STATUS_RX_CLEAR_MAC_MSB                                                         2
-#define PHY_BB_CHANNEL_STATUS_RX_CLEAR_MAC_LSB                                                         2
-#define PHY_BB_CHANNEL_STATUS_RX_CLEAR_MAC_MASK                                               0x00000004
-#define PHY_BB_CHANNEL_STATUS_RX_CLEAR_MAC_GET(x)                              (((x) & 0x00000004) >> 2)
-#define PHY_BB_CHANNEL_STATUS_RX_CLEAR_PAD_MSB                                                         3
-#define PHY_BB_CHANNEL_STATUS_RX_CLEAR_PAD_LSB                                                         3
-#define PHY_BB_CHANNEL_STATUS_RX_CLEAR_PAD_MASK                                               0x00000008
-#define PHY_BB_CHANNEL_STATUS_RX_CLEAR_PAD_GET(x)                              (((x) & 0x00000008) >> 3)
-#define PHY_BB_CHANNEL_STATUS_BB_SW_OUT_0_MSB                                                          5
-#define PHY_BB_CHANNEL_STATUS_BB_SW_OUT_0_LSB                                                          4
-#define PHY_BB_CHANNEL_STATUS_BB_SW_OUT_0_MASK                                                0x00000030
-#define PHY_BB_CHANNEL_STATUS_BB_SW_OUT_0_GET(x)                               (((x) & 0x00000030) >> 4)
-#define PHY_BB_CHANNEL_STATUS_BB_SW_OUT_1_MSB                                                          7
-#define PHY_BB_CHANNEL_STATUS_BB_SW_OUT_1_LSB                                                          6
-#define PHY_BB_CHANNEL_STATUS_BB_SW_OUT_1_MASK                                                0x000000c0
-#define PHY_BB_CHANNEL_STATUS_BB_SW_OUT_1_GET(x)                               (((x) & 0x000000c0) >> 6)
-#define PHY_BB_CHANNEL_STATUS_BB_SW_OUT_2_MSB                                                          9
-#define PHY_BB_CHANNEL_STATUS_BB_SW_OUT_2_LSB                                                          8
-#define PHY_BB_CHANNEL_STATUS_BB_SW_OUT_2_MASK                                                0x00000300
-#define PHY_BB_CHANNEL_STATUS_BB_SW_OUT_2_GET(x)                               (((x) & 0x00000300) >> 8)
-#define PHY_BB_CHANNEL_STATUS_BB_SW_COM_OUT_MSB                                                       13
-#define PHY_BB_CHANNEL_STATUS_BB_SW_COM_OUT_LSB                                                       10
-#define PHY_BB_CHANNEL_STATUS_BB_SW_COM_OUT_MASK                                              0x00003c00
-#define PHY_BB_CHANNEL_STATUS_BB_SW_COM_OUT_GET(x)                            (((x) & 0x00003c00) >> 10)
-#define PHY_BB_CHANNEL_STATUS_ANT_DIV_CFG_USED_MSB                                                    16
-#define PHY_BB_CHANNEL_STATUS_ANT_DIV_CFG_USED_LSB                                                    14
-#define PHY_BB_CHANNEL_STATUS_ANT_DIV_CFG_USED_MASK                                           0x0001c000
-#define PHY_BB_CHANNEL_STATUS_ANT_DIV_CFG_USED_GET(x)                         (((x) & 0x0001c000) >> 14)
-
-/* macros for BB_rssi_b0 */
-#define PHY_BB_RSSI_B0_ADDRESS                                                                0x00009c3c
-#define PHY_BB_RSSI_B0_OFFSET                                                                 0x00009c3c
-#define PHY_BB_RSSI_B0_RSSI_0_MSB                                                                      7
-#define PHY_BB_RSSI_B0_RSSI_0_LSB                                                                      0
-#define PHY_BB_RSSI_B0_RSSI_0_MASK                                                            0x000000ff
-#define PHY_BB_RSSI_B0_RSSI_0_GET(x)                                           (((x) & 0x000000ff) >> 0)
-#define PHY_BB_RSSI_B0_RSSI_EXT_0_MSB                                                                 15
-#define PHY_BB_RSSI_B0_RSSI_EXT_0_LSB                                                                  8
-#define PHY_BB_RSSI_B0_RSSI_EXT_0_MASK                                                        0x0000ff00
-#define PHY_BB_RSSI_B0_RSSI_EXT_0_GET(x)                                       (((x) & 0x0000ff00) >> 8)
-
-/* macros for BB_spur_est_cck_report_b0 */
-#define PHY_BB_SPUR_EST_CCK_REPORT_B0_ADDRESS                                                 0x00009c40
-#define PHY_BB_SPUR_EST_CCK_REPORT_B0_OFFSET                                                  0x00009c40
-#define PHY_BB_SPUR_EST_CCK_REPORT_B0_SPUR_EST_SD_I_0_CCK_MSB                                          7
-#define PHY_BB_SPUR_EST_CCK_REPORT_B0_SPUR_EST_SD_I_0_CCK_LSB                                          0
-#define PHY_BB_SPUR_EST_CCK_REPORT_B0_SPUR_EST_SD_I_0_CCK_MASK                                0x000000ff
-#define PHY_BB_SPUR_EST_CCK_REPORT_B0_SPUR_EST_SD_I_0_CCK_GET(x)               (((x) & 0x000000ff) >> 0)
-#define PHY_BB_SPUR_EST_CCK_REPORT_B0_SPUR_EST_SD_Q_0_CCK_MSB                                         15
-#define PHY_BB_SPUR_EST_CCK_REPORT_B0_SPUR_EST_SD_Q_0_CCK_LSB                                          8
-#define PHY_BB_SPUR_EST_CCK_REPORT_B0_SPUR_EST_SD_Q_0_CCK_MASK                                0x0000ff00
-#define PHY_BB_SPUR_EST_CCK_REPORT_B0_SPUR_EST_SD_Q_0_CCK_GET(x)               (((x) & 0x0000ff00) >> 8)
-#define PHY_BB_SPUR_EST_CCK_REPORT_B0_SPUR_EST_I_0_CCK_MSB                                            23
-#define PHY_BB_SPUR_EST_CCK_REPORT_B0_SPUR_EST_I_0_CCK_LSB                                            16
-#define PHY_BB_SPUR_EST_CCK_REPORT_B0_SPUR_EST_I_0_CCK_MASK                                   0x00ff0000
-#define PHY_BB_SPUR_EST_CCK_REPORT_B0_SPUR_EST_I_0_CCK_GET(x)                 (((x) & 0x00ff0000) >> 16)
-#define PHY_BB_SPUR_EST_CCK_REPORT_B0_SPUR_EST_Q_0_CCK_MSB                                            31
-#define PHY_BB_SPUR_EST_CCK_REPORT_B0_SPUR_EST_Q_0_CCK_LSB                                            24
-#define PHY_BB_SPUR_EST_CCK_REPORT_B0_SPUR_EST_Q_0_CCK_MASK                                   0xff000000
-#define PHY_BB_SPUR_EST_CCK_REPORT_B0_SPUR_EST_Q_0_CCK_GET(x)                 (((x) & 0xff000000) >> 24)
-
-/* macros for BB_chan_info_noise_pwr */
-#define PHY_BB_CHAN_INFO_NOISE_PWR_ADDRESS                                                    0x00009cac
-#define PHY_BB_CHAN_INFO_NOISE_PWR_OFFSET                                                     0x00009cac
-#define PHY_BB_CHAN_INFO_NOISE_PWR_NOISE_POWER_MSB                                                    11
-#define PHY_BB_CHAN_INFO_NOISE_PWR_NOISE_POWER_LSB                                                     0
-#define PHY_BB_CHAN_INFO_NOISE_PWR_NOISE_POWER_MASK                                           0x00000fff
-#define PHY_BB_CHAN_INFO_NOISE_PWR_NOISE_POWER_GET(x)                          (((x) & 0x00000fff) >> 0)
-
-/* macros for BB_chan_info_gain_diff */
-#define PHY_BB_CHAN_INFO_GAIN_DIFF_ADDRESS                                                    0x00009cb0
-#define PHY_BB_CHAN_INFO_GAIN_DIFF_OFFSET                                                     0x00009cb0
-#define PHY_BB_CHAN_INFO_GAIN_DIFF_FINE_PPM_MSB                                                       11
-#define PHY_BB_CHAN_INFO_GAIN_DIFF_FINE_PPM_LSB                                                        0
-#define PHY_BB_CHAN_INFO_GAIN_DIFF_FINE_PPM_MASK                                              0x00000fff
-#define PHY_BB_CHAN_INFO_GAIN_DIFF_FINE_PPM_GET(x)                             (((x) & 0x00000fff) >> 0)
-
-/* macros for BB_chan_info_fine_timing */
-#define PHY_BB_CHAN_INFO_FINE_TIMING_ADDRESS                                                  0x00009cb4
-#define PHY_BB_CHAN_INFO_FINE_TIMING_OFFSET                                                   0x00009cb4
-#define PHY_BB_CHAN_INFO_FINE_TIMING_COARSE_PPM_MSB                                                   11
-#define PHY_BB_CHAN_INFO_FINE_TIMING_COARSE_PPM_LSB                                                    0
-#define PHY_BB_CHAN_INFO_FINE_TIMING_COARSE_PPM_MASK                                          0x00000fff
-#define PHY_BB_CHAN_INFO_FINE_TIMING_COARSE_PPM_GET(x)                         (((x) & 0x00000fff) >> 0)
-#define PHY_BB_CHAN_INFO_FINE_TIMING_FINE_TIMING_MSB                                                  21
-#define PHY_BB_CHAN_INFO_FINE_TIMING_FINE_TIMING_LSB                                                  12
-#define PHY_BB_CHAN_INFO_FINE_TIMING_FINE_TIMING_MASK                                         0x003ff000
-#define PHY_BB_CHAN_INFO_FINE_TIMING_FINE_TIMING_GET(x)                       (((x) & 0x003ff000) >> 12)
-
-/* macros for BB_chan_info_gain_b0 */
-#define PHY_BB_CHAN_INFO_GAIN_B0_ADDRESS                                                      0x00009cb8
-#define PHY_BB_CHAN_INFO_GAIN_B0_OFFSET                                                       0x00009cb8
-#define PHY_BB_CHAN_INFO_GAIN_B0_CHAN_INFO_RSSI_0_MSB                                                  7
-#define PHY_BB_CHAN_INFO_GAIN_B0_CHAN_INFO_RSSI_0_LSB                                                  0
-#define PHY_BB_CHAN_INFO_GAIN_B0_CHAN_INFO_RSSI_0_MASK                                        0x000000ff
-#define PHY_BB_CHAN_INFO_GAIN_B0_CHAN_INFO_RSSI_0_GET(x)                       (((x) & 0x000000ff) >> 0)
-#define PHY_BB_CHAN_INFO_GAIN_B0_CHAN_INFO_RF_GAIN_0_MSB                                              15
-#define PHY_BB_CHAN_INFO_GAIN_B0_CHAN_INFO_RF_GAIN_0_LSB                                               8
-#define PHY_BB_CHAN_INFO_GAIN_B0_CHAN_INFO_RF_GAIN_0_MASK                                     0x0000ff00
-#define PHY_BB_CHAN_INFO_GAIN_B0_CHAN_INFO_RF_GAIN_0_GET(x)                    (((x) & 0x0000ff00) >> 8)
-#define PHY_BB_CHAN_INFO_GAIN_B0_CHAN_INFO_XATTEN1_SW_0_MSB                                           16
-#define PHY_BB_CHAN_INFO_GAIN_B0_CHAN_INFO_XATTEN1_SW_0_LSB                                           16
-#define PHY_BB_CHAN_INFO_GAIN_B0_CHAN_INFO_XATTEN1_SW_0_MASK                                  0x00010000
-#define PHY_BB_CHAN_INFO_GAIN_B0_CHAN_INFO_XATTEN1_SW_0_GET(x)                (((x) & 0x00010000) >> 16)
-#define PHY_BB_CHAN_INFO_GAIN_B0_CHAN_INFO_XATTEN2_SW_0_MSB                                           17
-#define PHY_BB_CHAN_INFO_GAIN_B0_CHAN_INFO_XATTEN2_SW_0_LSB                                           17
-#define PHY_BB_CHAN_INFO_GAIN_B0_CHAN_INFO_XATTEN2_SW_0_MASK                                  0x00020000
-#define PHY_BB_CHAN_INFO_GAIN_B0_CHAN_INFO_XATTEN2_SW_0_GET(x)                (((x) & 0x00020000) >> 17)
-
-/* macros for BB_chan_info_chan_tab_b0 */
-#define PHY_BB_CHAN_INFO_CHAN_TAB_B0_ADDRESS                                                  0x00009cbc
-#define PHY_BB_CHAN_INFO_CHAN_TAB_B0_OFFSET                                                   0x00009cbc
-#define PHY_BB_CHAN_INFO_CHAN_TAB_B0_MAN_Q_0_MSB                                                       5
-#define PHY_BB_CHAN_INFO_CHAN_TAB_B0_MAN_Q_0_LSB                                                       0
-#define PHY_BB_CHAN_INFO_CHAN_TAB_B0_MAN_Q_0_MASK                                             0x0000003f
-#define PHY_BB_CHAN_INFO_CHAN_TAB_B0_MAN_Q_0_GET(x)                            (((x) & 0x0000003f) >> 0)
-#define PHY_BB_CHAN_INFO_CHAN_TAB_B0_MAN_I_0_MSB                                                      11
-#define PHY_BB_CHAN_INFO_CHAN_TAB_B0_MAN_I_0_LSB                                                       6
-#define PHY_BB_CHAN_INFO_CHAN_TAB_B0_MAN_I_0_MASK                                             0x00000fc0
-#define PHY_BB_CHAN_INFO_CHAN_TAB_B0_MAN_I_0_GET(x)                            (((x) & 0x00000fc0) >> 6)
-#define PHY_BB_CHAN_INFO_CHAN_TAB_B0_EXP_0_MSB                                                        15
-#define PHY_BB_CHAN_INFO_CHAN_TAB_B0_EXP_0_LSB                                                        12
-#define PHY_BB_CHAN_INFO_CHAN_TAB_B0_EXP_0_MASK                                               0x0000f000
-#define PHY_BB_CHAN_INFO_CHAN_TAB_B0_EXP_0_GET(x)                             (((x) & 0x0000f000) >> 12)
-#define PHY_BB_CHAN_INFO_CHAN_TAB_B0_MAN_Q_1_MSB                                                      21
-#define PHY_BB_CHAN_INFO_CHAN_TAB_B0_MAN_Q_1_LSB                                                      16
-#define PHY_BB_CHAN_INFO_CHAN_TAB_B0_MAN_Q_1_MASK                                             0x003f0000
-#define PHY_BB_CHAN_INFO_CHAN_TAB_B0_MAN_Q_1_GET(x)                           (((x) & 0x003f0000) >> 16)
-#define PHY_BB_CHAN_INFO_CHAN_TAB_B0_MAN_I_1_MSB                                                      27
-#define PHY_BB_CHAN_INFO_CHAN_TAB_B0_MAN_I_1_LSB                                                      22
-#define PHY_BB_CHAN_INFO_CHAN_TAB_B0_MAN_I_1_MASK                                             0x0fc00000
-#define PHY_BB_CHAN_INFO_CHAN_TAB_B0_MAN_I_1_GET(x)                           (((x) & 0x0fc00000) >> 22)
-#define PHY_BB_CHAN_INFO_CHAN_TAB_B0_EXP_1_MSB                                                        31
-#define PHY_BB_CHAN_INFO_CHAN_TAB_B0_EXP_1_LSB                                                        28
-#define PHY_BB_CHAN_INFO_CHAN_TAB_B0_EXP_1_MASK                                               0xf0000000
-#define PHY_BB_CHAN_INFO_CHAN_TAB_B0_EXP_1_GET(x)                             (((x) & 0xf0000000) >> 28)
-
-/* macros for BB_paprd_am2am_mask */
-#define PHY_BB_PAPRD_AM2AM_MASK_ADDRESS                                                       0x00009de4
-#define PHY_BB_PAPRD_AM2AM_MASK_OFFSET                                                        0x00009de4
-#define PHY_BB_PAPRD_AM2AM_MASK_PAPRD_AM2AM_MASK_MSB                                                  24
-#define PHY_BB_PAPRD_AM2AM_MASK_PAPRD_AM2AM_MASK_LSB                                                   0
-#define PHY_BB_PAPRD_AM2AM_MASK_PAPRD_AM2AM_MASK_MASK                                         0x01ffffff
-#define PHY_BB_PAPRD_AM2AM_MASK_PAPRD_AM2AM_MASK_GET(x)                        (((x) & 0x01ffffff) >> 0)
-#define PHY_BB_PAPRD_AM2AM_MASK_PAPRD_AM2AM_MASK_SET(x)                        (((x) << 0) & 0x01ffffff)
-
-/* macros for BB_paprd_am2pm_mask */
-#define PHY_BB_PAPRD_AM2PM_MASK_ADDRESS                                                       0x00009de8
-#define PHY_BB_PAPRD_AM2PM_MASK_OFFSET                                                        0x00009de8
-#define PHY_BB_PAPRD_AM2PM_MASK_PAPRD_AM2PM_MASK_MSB                                                  24
-#define PHY_BB_PAPRD_AM2PM_MASK_PAPRD_AM2PM_MASK_LSB                                                   0
-#define PHY_BB_PAPRD_AM2PM_MASK_PAPRD_AM2PM_MASK_MASK                                         0x01ffffff
-#define PHY_BB_PAPRD_AM2PM_MASK_PAPRD_AM2PM_MASK_GET(x)                        (((x) & 0x01ffffff) >> 0)
-#define PHY_BB_PAPRD_AM2PM_MASK_PAPRD_AM2PM_MASK_SET(x)                        (((x) << 0) & 0x01ffffff)
-
-/* macros for BB_paprd_ht40_mask */
-#define PHY_BB_PAPRD_HT40_MASK_ADDRESS                                                        0x00009dec
-#define PHY_BB_PAPRD_HT40_MASK_OFFSET                                                         0x00009dec
-#define PHY_BB_PAPRD_HT40_MASK_PAPRD_HT40_MASK_MSB                                                    24
-#define PHY_BB_PAPRD_HT40_MASK_PAPRD_HT40_MASK_LSB                                                     0
-#define PHY_BB_PAPRD_HT40_MASK_PAPRD_HT40_MASK_MASK                                           0x01ffffff
-#define PHY_BB_PAPRD_HT40_MASK_PAPRD_HT40_MASK_GET(x)                          (((x) & 0x01ffffff) >> 0)
-#define PHY_BB_PAPRD_HT40_MASK_PAPRD_HT40_MASK_SET(x)                          (((x) << 0) & 0x01ffffff)
-
-/* macros for BB_paprd_ctrl0 */
-#define PHY_BB_PAPRD_CTRL0_ADDRESS                                                            0x00009df0
-#define PHY_BB_PAPRD_CTRL0_OFFSET                                                             0x00009df0
-#define PHY_BB_PAPRD_CTRL0_PAPRD_ENABLE_MSB                                                            0
-#define PHY_BB_PAPRD_CTRL0_PAPRD_ENABLE_LSB                                                            0
-#define PHY_BB_PAPRD_CTRL0_PAPRD_ENABLE_MASK                                                  0x00000001
-#define PHY_BB_PAPRD_CTRL0_PAPRD_ENABLE_GET(x)                                 (((x) & 0x00000001) >> 0)
-#define PHY_BB_PAPRD_CTRL0_PAPRD_ENABLE_SET(x)                                 (((x) << 0) & 0x00000001)
-#define PHY_BB_PAPRD_CTRL0_PAPRD_ADAPTIVE_USE_SINGLE_TABLE_MSB                                         1
-#define PHY_BB_PAPRD_CTRL0_PAPRD_ADAPTIVE_USE_SINGLE_TABLE_LSB                                         1
-#define PHY_BB_PAPRD_CTRL0_PAPRD_ADAPTIVE_USE_SINGLE_TABLE_MASK                               0x00000002
-#define PHY_BB_PAPRD_CTRL0_PAPRD_ADAPTIVE_USE_SINGLE_TABLE_GET(x)              (((x) & 0x00000002) >> 1)
-#define PHY_BB_PAPRD_CTRL0_PAPRD_ADAPTIVE_USE_SINGLE_TABLE_SET(x)              (((x) << 1) & 0x00000002)
-#define PHY_BB_PAPRD_CTRL0_PAPRD_VALID_GAIN_MSB                                                       26
-#define PHY_BB_PAPRD_CTRL0_PAPRD_VALID_GAIN_LSB                                                        2
-#define PHY_BB_PAPRD_CTRL0_PAPRD_VALID_GAIN_MASK                                              0x07fffffc
-#define PHY_BB_PAPRD_CTRL0_PAPRD_VALID_GAIN_GET(x)                             (((x) & 0x07fffffc) >> 2)
-#define PHY_BB_PAPRD_CTRL0_PAPRD_VALID_GAIN_SET(x)                             (((x) << 2) & 0x07fffffc)
-#define PHY_BB_PAPRD_CTRL0_PAPRD_MAG_THRSH_MSB                                                        31
-#define PHY_BB_PAPRD_CTRL0_PAPRD_MAG_THRSH_LSB                                                        27
-#define PHY_BB_PAPRD_CTRL0_PAPRD_MAG_THRSH_MASK                                               0xf8000000
-#define PHY_BB_PAPRD_CTRL0_PAPRD_MAG_THRSH_GET(x)                             (((x) & 0xf8000000) >> 27)
-#define PHY_BB_PAPRD_CTRL0_PAPRD_MAG_THRSH_SET(x)                             (((x) << 27) & 0xf8000000)
-
-/* macros for BB_paprd_ctrl1 */
-#define PHY_BB_PAPRD_CTRL1_ADDRESS                                                            0x00009df4
-#define PHY_BB_PAPRD_CTRL1_OFFSET                                                             0x00009df4
-#define PHY_BB_PAPRD_CTRL1_PAPRD_ADAPTIVE_SCALING_ENABLE_MSB                                           0
-#define PHY_BB_PAPRD_CTRL1_PAPRD_ADAPTIVE_SCALING_ENABLE_LSB                                           0
-#define PHY_BB_PAPRD_CTRL1_PAPRD_ADAPTIVE_SCALING_ENABLE_MASK                                 0x00000001
-#define PHY_BB_PAPRD_CTRL1_PAPRD_ADAPTIVE_SCALING_ENABLE_GET(x)                (((x) & 0x00000001) >> 0)
-#define PHY_BB_PAPRD_CTRL1_PAPRD_ADAPTIVE_SCALING_ENABLE_SET(x)                (((x) << 0) & 0x00000001)
-#define PHY_BB_PAPRD_CTRL1_PAPRD_ADAPTIVE_AM2AM_ENABLE_MSB                                             1
-#define PHY_BB_PAPRD_CTRL1_PAPRD_ADAPTIVE_AM2AM_ENABLE_LSB                                             1
-#define PHY_BB_PAPRD_CTRL1_PAPRD_ADAPTIVE_AM2AM_ENABLE_MASK                                   0x00000002
-#define PHY_BB_PAPRD_CTRL1_PAPRD_ADAPTIVE_AM2AM_ENABLE_GET(x)                  (((x) & 0x00000002) >> 1)
-#define PHY_BB_PAPRD_CTRL1_PAPRD_ADAPTIVE_AM2AM_ENABLE_SET(x)                  (((x) << 1) & 0x00000002)
-#define PHY_BB_PAPRD_CTRL1_PAPRD_ADAPTIVE_AM2PM_ENABLE_MSB                                             2
-#define PHY_BB_PAPRD_CTRL1_PAPRD_ADAPTIVE_AM2PM_ENABLE_LSB                                             2
-#define PHY_BB_PAPRD_CTRL1_PAPRD_ADAPTIVE_AM2PM_ENABLE_MASK                                   0x00000004
-#define PHY_BB_PAPRD_CTRL1_PAPRD_ADAPTIVE_AM2PM_ENABLE_GET(x)                  (((x) & 0x00000004) >> 2)
-#define PHY_BB_PAPRD_CTRL1_PAPRD_ADAPTIVE_AM2PM_ENABLE_SET(x)                  (((x) << 2) & 0x00000004)
-#define PHY_BB_PAPRD_CTRL1_PAPRD_POWER_AT_AM2AM_CAL_MSB                                                8
-#define PHY_BB_PAPRD_CTRL1_PAPRD_POWER_AT_AM2AM_CAL_LSB                                                3
-#define PHY_BB_PAPRD_CTRL1_PAPRD_POWER_AT_AM2AM_CAL_MASK                                      0x000001f8
-#define PHY_BB_PAPRD_CTRL1_PAPRD_POWER_AT_AM2AM_CAL_GET(x)                     (((x) & 0x000001f8) >> 3)
-#define PHY_BB_PAPRD_CTRL1_PAPRD_POWER_AT_AM2AM_CAL_SET(x)                     (((x) << 3) & 0x000001f8)
-#define PHY_BB_PAPRD_CTRL1_PA_GAIN_SCALE_FACTOR_MSB                                                   16
-#define PHY_BB_PAPRD_CTRL1_PA_GAIN_SCALE_FACTOR_LSB                                                    9
-#define PHY_BB_PAPRD_CTRL1_PA_GAIN_SCALE_FACTOR_MASK                                          0x0001fe00
-#define PHY_BB_PAPRD_CTRL1_PA_GAIN_SCALE_FACTOR_GET(x)                         (((x) & 0x0001fe00) >> 9)
-#define PHY_BB_PAPRD_CTRL1_PA_GAIN_SCALE_FACTOR_SET(x)                         (((x) << 9) & 0x0001fe00)
-#define PHY_BB_PAPRD_CTRL1_PAPRD_MAG_SCALE_FACTOR_MSB                                                 26
-#define PHY_BB_PAPRD_CTRL1_PAPRD_MAG_SCALE_FACTOR_LSB                                                 17
-#define PHY_BB_PAPRD_CTRL1_PAPRD_MAG_SCALE_FACTOR_MASK                                        0x07fe0000
-#define PHY_BB_PAPRD_CTRL1_PAPRD_MAG_SCALE_FACTOR_GET(x)                      (((x) & 0x07fe0000) >> 17)
-#define PHY_BB_PAPRD_CTRL1_PAPRD_MAG_SCALE_FACTOR_SET(x)                      (((x) << 17) & 0x07fe0000)
-#define PHY_BB_PAPRD_CTRL1_PAPRD_TRAINER_IANDQ_SEL_MSB                                                27
-#define PHY_BB_PAPRD_CTRL1_PAPRD_TRAINER_IANDQ_SEL_LSB                                                27
-#define PHY_BB_PAPRD_CTRL1_PAPRD_TRAINER_IANDQ_SEL_MASK                                       0x08000000
-#define PHY_BB_PAPRD_CTRL1_PAPRD_TRAINER_IANDQ_SEL_GET(x)                     (((x) & 0x08000000) >> 27)
-#define PHY_BB_PAPRD_CTRL1_PAPRD_TRAINER_IANDQ_SEL_SET(x)                     (((x) << 27) & 0x08000000)
-
-/* macros for BB_pa_gain123 */
-#define PHY_BB_PA_GAIN123_ADDRESS                                                             0x00009df8
-#define PHY_BB_PA_GAIN123_OFFSET                                                              0x00009df8
-#define PHY_BB_PA_GAIN123_PA_GAIN1_MSB                                                                 9
-#define PHY_BB_PA_GAIN123_PA_GAIN1_LSB                                                                 0
-#define PHY_BB_PA_GAIN123_PA_GAIN1_MASK                                                       0x000003ff
-#define PHY_BB_PA_GAIN123_PA_GAIN1_GET(x)                                      (((x) & 0x000003ff) >> 0)
-#define PHY_BB_PA_GAIN123_PA_GAIN1_SET(x)                                      (((x) << 0) & 0x000003ff)
-#define PHY_BB_PA_GAIN123_PA_GAIN2_MSB                                                                19
-#define PHY_BB_PA_GAIN123_PA_GAIN2_LSB                                                                10
-#define PHY_BB_PA_GAIN123_PA_GAIN2_MASK                                                       0x000ffc00
-#define PHY_BB_PA_GAIN123_PA_GAIN2_GET(x)                                     (((x) & 0x000ffc00) >> 10)
-#define PHY_BB_PA_GAIN123_PA_GAIN2_SET(x)                                     (((x) << 10) & 0x000ffc00)
-#define PHY_BB_PA_GAIN123_PA_GAIN3_MSB                                                                29
-#define PHY_BB_PA_GAIN123_PA_GAIN3_LSB                                                                20
-#define PHY_BB_PA_GAIN123_PA_GAIN3_MASK                                                       0x3ff00000
-#define PHY_BB_PA_GAIN123_PA_GAIN3_GET(x)                                     (((x) & 0x3ff00000) >> 20)
-#define PHY_BB_PA_GAIN123_PA_GAIN3_SET(x)                                     (((x) << 20) & 0x3ff00000)
-
-/* macros for BB_pa_gain45 */
-#define PHY_BB_PA_GAIN45_ADDRESS                                                              0x00009dfc
-#define PHY_BB_PA_GAIN45_OFFSET                                                               0x00009dfc
-#define PHY_BB_PA_GAIN45_PA_GAIN4_MSB                                                                  9
-#define PHY_BB_PA_GAIN45_PA_GAIN4_LSB                                                                  0
-#define PHY_BB_PA_GAIN45_PA_GAIN4_MASK                                                        0x000003ff
-#define PHY_BB_PA_GAIN45_PA_GAIN4_GET(x)                                       (((x) & 0x000003ff) >> 0)
-#define PHY_BB_PA_GAIN45_PA_GAIN4_SET(x)                                       (((x) << 0) & 0x000003ff)
-#define PHY_BB_PA_GAIN45_PA_GAIN5_MSB                                                                 19
-#define PHY_BB_PA_GAIN45_PA_GAIN5_LSB                                                                 10
-#define PHY_BB_PA_GAIN45_PA_GAIN5_MASK                                                        0x000ffc00
-#define PHY_BB_PA_GAIN45_PA_GAIN5_GET(x)                                      (((x) & 0x000ffc00) >> 10)
-#define PHY_BB_PA_GAIN45_PA_GAIN5_SET(x)                                      (((x) << 10) & 0x000ffc00)
-#define PHY_BB_PA_GAIN45_PAPRD_ADAPTIVE_TABLE_VALID_MSB                                               24
-#define PHY_BB_PA_GAIN45_PAPRD_ADAPTIVE_TABLE_VALID_LSB                                               20
-#define PHY_BB_PA_GAIN45_PAPRD_ADAPTIVE_TABLE_VALID_MASK                                      0x01f00000
-#define PHY_BB_PA_GAIN45_PAPRD_ADAPTIVE_TABLE_VALID_GET(x)                    (((x) & 0x01f00000) >> 20)
-#define PHY_BB_PA_GAIN45_PAPRD_ADAPTIVE_TABLE_VALID_SET(x)                    (((x) << 20) & 0x01f00000)
-
-/* macros for BB_paprd_pre_post_scale_0 */
-#define PHY_BB_PAPRD_PRE_POST_SCALE_0_ADDRESS                                                 0x00009e00
-#define PHY_BB_PAPRD_PRE_POST_SCALE_0_OFFSET                                                  0x00009e00
-#define PHY_BB_PAPRD_PRE_POST_SCALE_0_PAPRD_PRE_POST_SCALING_0_MSB                                    17
-#define PHY_BB_PAPRD_PRE_POST_SCALE_0_PAPRD_PRE_POST_SCALING_0_LSB                                     0
-#define PHY_BB_PAPRD_PRE_POST_SCALE_0_PAPRD_PRE_POST_SCALING_0_MASK                           0x0003ffff
-#define PHY_BB_PAPRD_PRE_POST_SCALE_0_PAPRD_PRE_POST_SCALING_0_GET(x)          (((x) & 0x0003ffff) >> 0)
-#define PHY_BB_PAPRD_PRE_POST_SCALE_0_PAPRD_PRE_POST_SCALING_0_SET(x)          (((x) << 0) & 0x0003ffff)
-
-/* macros for BB_paprd_pre_post_scale_1 */
-#define PHY_BB_PAPRD_PRE_POST_SCALE_1_ADDRESS                                                 0x00009e04
-#define PHY_BB_PAPRD_PRE_POST_SCALE_1_OFFSET                                                  0x00009e04
-#define PHY_BB_PAPRD_PRE_POST_SCALE_1_PAPRD_PRE_POST_SCALING_1_MSB                                    17
-#define PHY_BB_PAPRD_PRE_POST_SCALE_1_PAPRD_PRE_POST_SCALING_1_LSB                                     0
-#define PHY_BB_PAPRD_PRE_POST_SCALE_1_PAPRD_PRE_POST_SCALING_1_MASK                           0x0003ffff
-#define PHY_BB_PAPRD_PRE_POST_SCALE_1_PAPRD_PRE_POST_SCALING_1_GET(x)          (((x) & 0x0003ffff) >> 0)
-#define PHY_BB_PAPRD_PRE_POST_SCALE_1_PAPRD_PRE_POST_SCALING_1_SET(x)          (((x) << 0) & 0x0003ffff)
-
-/* macros for BB_paprd_pre_post_scale_2 */
-#define PHY_BB_PAPRD_PRE_POST_SCALE_2_ADDRESS                                                 0x00009e08
-#define PHY_BB_PAPRD_PRE_POST_SCALE_2_OFFSET                                                  0x00009e08
-#define PHY_BB_PAPRD_PRE_POST_SCALE_2_PAPRD_PRE_POST_SCALING_2_MSB                                    17
-#define PHY_BB_PAPRD_PRE_POST_SCALE_2_PAPRD_PRE_POST_SCALING_2_LSB                                     0
-#define PHY_BB_PAPRD_PRE_POST_SCALE_2_PAPRD_PRE_POST_SCALING_2_MASK                           0x0003ffff
-#define PHY_BB_PAPRD_PRE_POST_SCALE_2_PAPRD_PRE_POST_SCALING_2_GET(x)          (((x) & 0x0003ffff) >> 0)
-#define PHY_BB_PAPRD_PRE_POST_SCALE_2_PAPRD_PRE_POST_SCALING_2_SET(x)          (((x) << 0) & 0x0003ffff)
-
-/* macros for BB_paprd_pre_post_scale_3 */
-#define PHY_BB_PAPRD_PRE_POST_SCALE_3_ADDRESS                                                 0x00009e0c
-#define PHY_BB_PAPRD_PRE_POST_SCALE_3_OFFSET                                                  0x00009e0c
-#define PHY_BB_PAPRD_PRE_POST_SCALE_3_PAPRD_PRE_POST_SCALING_3_MSB                                    17
-#define PHY_BB_PAPRD_PRE_POST_SCALE_3_PAPRD_PRE_POST_SCALING_3_LSB                                     0
-#define PHY_BB_PAPRD_PRE_POST_SCALE_3_PAPRD_PRE_POST_SCALING_3_MASK                           0x0003ffff
-#define PHY_BB_PAPRD_PRE_POST_SCALE_3_PAPRD_PRE_POST_SCALING_3_GET(x)          (((x) & 0x0003ffff) >> 0)
-#define PHY_BB_PAPRD_PRE_POST_SCALE_3_PAPRD_PRE_POST_SCALING_3_SET(x)          (((x) << 0) & 0x0003ffff)
-
-/* macros for BB_paprd_pre_post_scale_4 */
-#define PHY_BB_PAPRD_PRE_POST_SCALE_4_ADDRESS                                                 0x00009e10
-#define PHY_BB_PAPRD_PRE_POST_SCALE_4_OFFSET                                                  0x00009e10
-#define PHY_BB_PAPRD_PRE_POST_SCALE_4_PAPRD_PRE_POST_SCALING_4_MSB                                    17
-#define PHY_BB_PAPRD_PRE_POST_SCALE_4_PAPRD_PRE_POST_SCALING_4_LSB                                     0
-#define PHY_BB_PAPRD_PRE_POST_SCALE_4_PAPRD_PRE_POST_SCALING_4_MASK                           0x0003ffff
-#define PHY_BB_PAPRD_PRE_POST_SCALE_4_PAPRD_PRE_POST_SCALING_4_GET(x)          (((x) & 0x0003ffff) >> 0)
-#define PHY_BB_PAPRD_PRE_POST_SCALE_4_PAPRD_PRE_POST_SCALING_4_SET(x)          (((x) << 0) & 0x0003ffff)
-
-/* macros for BB_paprd_pre_post_scale_5 */
-#define PHY_BB_PAPRD_PRE_POST_SCALE_5_ADDRESS                                                 0x00009e14
-#define PHY_BB_PAPRD_PRE_POST_SCALE_5_OFFSET                                                  0x00009e14
-#define PHY_BB_PAPRD_PRE_POST_SCALE_5_PAPRD_PRE_POST_SCALING_5_MSB                                    17
-#define PHY_BB_PAPRD_PRE_POST_SCALE_5_PAPRD_PRE_POST_SCALING_5_LSB                                     0
-#define PHY_BB_PAPRD_PRE_POST_SCALE_5_PAPRD_PRE_POST_SCALING_5_MASK                           0x0003ffff
-#define PHY_BB_PAPRD_PRE_POST_SCALE_5_PAPRD_PRE_POST_SCALING_5_GET(x)          (((x) & 0x0003ffff) >> 0)
-#define PHY_BB_PAPRD_PRE_POST_SCALE_5_PAPRD_PRE_POST_SCALING_5_SET(x)          (((x) << 0) & 0x0003ffff)
-
-/* macros for BB_paprd_pre_post_scale_6 */
-#define PHY_BB_PAPRD_PRE_POST_SCALE_6_ADDRESS                                                 0x00009e18
-#define PHY_BB_PAPRD_PRE_POST_SCALE_6_OFFSET                                                  0x00009e18
-#define PHY_BB_PAPRD_PRE_POST_SCALE_6_PAPRD_PRE_POST_SCALING_6_MSB                                    17
-#define PHY_BB_PAPRD_PRE_POST_SCALE_6_PAPRD_PRE_POST_SCALING_6_LSB                                     0
-#define PHY_BB_PAPRD_PRE_POST_SCALE_6_PAPRD_PRE_POST_SCALING_6_MASK                           0x0003ffff
-#define PHY_BB_PAPRD_PRE_POST_SCALE_6_PAPRD_PRE_POST_SCALING_6_GET(x)          (((x) & 0x0003ffff) >> 0)
-#define PHY_BB_PAPRD_PRE_POST_SCALE_6_PAPRD_PRE_POST_SCALING_6_SET(x)          (((x) << 0) & 0x0003ffff)
-
-/* macros for BB_paprd_pre_post_scale_7 */
-#define PHY_BB_PAPRD_PRE_POST_SCALE_7_ADDRESS                                                 0x00009e1c
-#define PHY_BB_PAPRD_PRE_POST_SCALE_7_OFFSET                                                  0x00009e1c
-#define PHY_BB_PAPRD_PRE_POST_SCALE_7_PAPRD_PRE_POST_SCALING_7_MSB                                    17
-#define PHY_BB_PAPRD_PRE_POST_SCALE_7_PAPRD_PRE_POST_SCALING_7_LSB                                     0
-#define PHY_BB_PAPRD_PRE_POST_SCALE_7_PAPRD_PRE_POST_SCALING_7_MASK                           0x0003ffff
-#define PHY_BB_PAPRD_PRE_POST_SCALE_7_PAPRD_PRE_POST_SCALING_7_GET(x)          (((x) & 0x0003ffff) >> 0)
-#define PHY_BB_PAPRD_PRE_POST_SCALE_7_PAPRD_PRE_POST_SCALING_7_SET(x)          (((x) << 0) & 0x0003ffff)
-
-/* macros for BB_paprd_mem_tab */
-#define PHY_BB_PAPRD_MEM_TAB_ADDRESS                                                          0x00009e20
-#define PHY_BB_PAPRD_MEM_TAB_OFFSET                                                           0x00009e20
-#define PHY_BB_PAPRD_MEM_TAB_PAPRD_MEM_MSB                                                            21
-#define PHY_BB_PAPRD_MEM_TAB_PAPRD_MEM_LSB                                                             0
-#define PHY_BB_PAPRD_MEM_TAB_PAPRD_MEM_MASK                                                   0x003fffff
-#define PHY_BB_PAPRD_MEM_TAB_PAPRD_MEM_GET(x)                                  (((x) & 0x003fffff) >> 0)
-#define PHY_BB_PAPRD_MEM_TAB_PAPRD_MEM_SET(x)                                  (((x) << 0) & 0x003fffff)
-
-/* macros for BB_peak_det_ctrl_1 */
-#define PHY_BB_PEAK_DET_CTRL_1_ADDRESS                                                        0x0000a000
-#define PHY_BB_PEAK_DET_CTRL_1_OFFSET                                                         0x0000a000
-#define PHY_BB_PEAK_DET_CTRL_1_USE_OC_GAIN_TABLE_MSB                                                   0
-#define PHY_BB_PEAK_DET_CTRL_1_USE_OC_GAIN_TABLE_LSB                                                   0
-#define PHY_BB_PEAK_DET_CTRL_1_USE_OC_GAIN_TABLE_MASK                                         0x00000001
-#define PHY_BB_PEAK_DET_CTRL_1_USE_OC_GAIN_TABLE_GET(x)                        (((x) & 0x00000001) >> 0)
-#define PHY_BB_PEAK_DET_CTRL_1_USE_OC_GAIN_TABLE_SET(x)                        (((x) << 0) & 0x00000001)
-#define PHY_BB_PEAK_DET_CTRL_1_USE_PEAK_DET_MSB                                                        1
-#define PHY_BB_PEAK_DET_CTRL_1_USE_PEAK_DET_LSB                                                        1
-#define PHY_BB_PEAK_DET_CTRL_1_USE_PEAK_DET_MASK                                              0x00000002
-#define PHY_BB_PEAK_DET_CTRL_1_USE_PEAK_DET_GET(x)                             (((x) & 0x00000002) >> 1)
-#define PHY_BB_PEAK_DET_CTRL_1_USE_PEAK_DET_SET(x)                             (((x) << 1) & 0x00000002)
-#define PHY_BB_PEAK_DET_CTRL_1_PEAK_DET_WIN_LEN_MSB                                                    7
-#define PHY_BB_PEAK_DET_CTRL_1_PEAK_DET_WIN_LEN_LSB                                                    2
-#define PHY_BB_PEAK_DET_CTRL_1_PEAK_DET_WIN_LEN_MASK                                          0x000000fc
-#define PHY_BB_PEAK_DET_CTRL_1_PEAK_DET_WIN_LEN_GET(x)                         (((x) & 0x000000fc) >> 2)
-#define PHY_BB_PEAK_DET_CTRL_1_PEAK_DET_WIN_LEN_SET(x)                         (((x) << 2) & 0x000000fc)
-#define PHY_BB_PEAK_DET_CTRL_1_PEAK_DET_TALLY_THR_LOW_MSB                                             12
-#define PHY_BB_PEAK_DET_CTRL_1_PEAK_DET_TALLY_THR_LOW_LSB                                              8
-#define PHY_BB_PEAK_DET_CTRL_1_PEAK_DET_TALLY_THR_LOW_MASK                                    0x00001f00
-#define PHY_BB_PEAK_DET_CTRL_1_PEAK_DET_TALLY_THR_LOW_GET(x)                   (((x) & 0x00001f00) >> 8)
-#define PHY_BB_PEAK_DET_CTRL_1_PEAK_DET_TALLY_THR_LOW_SET(x)                   (((x) << 8) & 0x00001f00)
-#define PHY_BB_PEAK_DET_CTRL_1_PEAK_DET_TALLY_THR_MED_MSB                                             17
-#define PHY_BB_PEAK_DET_CTRL_1_PEAK_DET_TALLY_THR_MED_LSB                                             13
-#define PHY_BB_PEAK_DET_CTRL_1_PEAK_DET_TALLY_THR_MED_MASK                                    0x0003e000
-#define PHY_BB_PEAK_DET_CTRL_1_PEAK_DET_TALLY_THR_MED_GET(x)                  (((x) & 0x0003e000) >> 13)
-#define PHY_BB_PEAK_DET_CTRL_1_PEAK_DET_TALLY_THR_MED_SET(x)                  (((x) << 13) & 0x0003e000)
-#define PHY_BB_PEAK_DET_CTRL_1_PEAK_DET_TALLY_THR_HIGH_MSB                                            22
-#define PHY_BB_PEAK_DET_CTRL_1_PEAK_DET_TALLY_THR_HIGH_LSB                                            18
-#define PHY_BB_PEAK_DET_CTRL_1_PEAK_DET_TALLY_THR_HIGH_MASK                                   0x007c0000
-#define PHY_BB_PEAK_DET_CTRL_1_PEAK_DET_TALLY_THR_HIGH_GET(x)                 (((x) & 0x007c0000) >> 18)
-#define PHY_BB_PEAK_DET_CTRL_1_PEAK_DET_TALLY_THR_HIGH_SET(x)                 (((x) << 18) & 0x007c0000)
-#define PHY_BB_PEAK_DET_CTRL_1_PEAK_DET_SETTLING_MSB                                                  29
-#define PHY_BB_PEAK_DET_CTRL_1_PEAK_DET_SETTLING_LSB                                                  23
-#define PHY_BB_PEAK_DET_CTRL_1_PEAK_DET_SETTLING_MASK                                         0x3f800000
-#define PHY_BB_PEAK_DET_CTRL_1_PEAK_DET_SETTLING_GET(x)                       (((x) & 0x3f800000) >> 23)
-#define PHY_BB_PEAK_DET_CTRL_1_PEAK_DET_SETTLING_SET(x)                       (((x) << 23) & 0x3f800000)
-#define PHY_BB_PEAK_DET_CTRL_1_PWD_PKDET_DURING_CAL_MSB                                               30
-#define PHY_BB_PEAK_DET_CTRL_1_PWD_PKDET_DURING_CAL_LSB                                               30
-#define PHY_BB_PEAK_DET_CTRL_1_PWD_PKDET_DURING_CAL_MASK                                      0x40000000
-#define PHY_BB_PEAK_DET_CTRL_1_PWD_PKDET_DURING_CAL_GET(x)                    (((x) & 0x40000000) >> 30)
-#define PHY_BB_PEAK_DET_CTRL_1_PWD_PKDET_DURING_CAL_SET(x)                    (((x) << 30) & 0x40000000)
-#define PHY_BB_PEAK_DET_CTRL_1_PWD_PKDET_DURING_RX_MSB                                                31
-#define PHY_BB_PEAK_DET_CTRL_1_PWD_PKDET_DURING_RX_LSB                                                31
-#define PHY_BB_PEAK_DET_CTRL_1_PWD_PKDET_DURING_RX_MASK                                       0x80000000
-#define PHY_BB_PEAK_DET_CTRL_1_PWD_PKDET_DURING_RX_GET(x)                     (((x) & 0x80000000) >> 31)
-#define PHY_BB_PEAK_DET_CTRL_1_PWD_PKDET_DURING_RX_SET(x)                     (((x) << 31) & 0x80000000)
-
-/* macros for BB_peak_det_ctrl_2 */
-#define PHY_BB_PEAK_DET_CTRL_2_ADDRESS                                                        0x0000a004
-#define PHY_BB_PEAK_DET_CTRL_2_OFFSET                                                         0x0000a004
-#define PHY_BB_PEAK_DET_CTRL_2_RFSAT_2_ADD_RFGAIN_DEL_MSB                                              9
-#define PHY_BB_PEAK_DET_CTRL_2_RFSAT_2_ADD_RFGAIN_DEL_LSB                                              0
-#define PHY_BB_PEAK_DET_CTRL_2_RFSAT_2_ADD_RFGAIN_DEL_MASK                                    0x000003ff
-#define PHY_BB_PEAK_DET_CTRL_2_RFSAT_2_ADD_RFGAIN_DEL_GET(x)                   (((x) & 0x000003ff) >> 0)
-#define PHY_BB_PEAK_DET_CTRL_2_RFSAT_2_ADD_RFGAIN_DEL_SET(x)                   (((x) << 0) & 0x000003ff)
-#define PHY_BB_PEAK_DET_CTRL_2_RF_GAIN_DROP_DB_LOW_MSB                                                14
-#define PHY_BB_PEAK_DET_CTRL_2_RF_GAIN_DROP_DB_LOW_LSB                                                10
-#define PHY_BB_PEAK_DET_CTRL_2_RF_GAIN_DROP_DB_LOW_MASK                                       0x00007c00
-#define PHY_BB_PEAK_DET_CTRL_2_RF_GAIN_DROP_DB_LOW_GET(x)                     (((x) & 0x00007c00) >> 10)
-#define PHY_BB_PEAK_DET_CTRL_2_RF_GAIN_DROP_DB_LOW_SET(x)                     (((x) << 10) & 0x00007c00)
-#define PHY_BB_PEAK_DET_CTRL_2_RF_GAIN_DROP_DB_MED_MSB                                                19
-#define PHY_BB_PEAK_DET_CTRL_2_RF_GAIN_DROP_DB_MED_LSB                                                15
-#define PHY_BB_PEAK_DET_CTRL_2_RF_GAIN_DROP_DB_MED_MASK                                       0x000f8000
-#define PHY_BB_PEAK_DET_CTRL_2_RF_GAIN_DROP_DB_MED_GET(x)                     (((x) & 0x000f8000) >> 15)
-#define PHY_BB_PEAK_DET_CTRL_2_RF_GAIN_DROP_DB_MED_SET(x)                     (((x) << 15) & 0x000f8000)
-#define PHY_BB_PEAK_DET_CTRL_2_RF_GAIN_DROP_DB_HIGH_MSB                                               24
-#define PHY_BB_PEAK_DET_CTRL_2_RF_GAIN_DROP_DB_HIGH_LSB                                               20
-#define PHY_BB_PEAK_DET_CTRL_2_RF_GAIN_DROP_DB_HIGH_MASK                                      0x01f00000
-#define PHY_BB_PEAK_DET_CTRL_2_RF_GAIN_DROP_DB_HIGH_GET(x)                    (((x) & 0x01f00000) >> 20)
-#define PHY_BB_PEAK_DET_CTRL_2_RF_GAIN_DROP_DB_HIGH_SET(x)                    (((x) << 20) & 0x01f00000)
-#define PHY_BB_PEAK_DET_CTRL_2_RF_GAIN_DROP_DB_NON_MSB                                                29
-#define PHY_BB_PEAK_DET_CTRL_2_RF_GAIN_DROP_DB_NON_LSB                                                25
-#define PHY_BB_PEAK_DET_CTRL_2_RF_GAIN_DROP_DB_NON_MASK                                       0x3e000000
-#define PHY_BB_PEAK_DET_CTRL_2_RF_GAIN_DROP_DB_NON_GET(x)                     (((x) & 0x3e000000) >> 25)
-#define PHY_BB_PEAK_DET_CTRL_2_RF_GAIN_DROP_DB_NON_SET(x)                     (((x) << 25) & 0x3e000000)
-
-/* macros for BB_rx_gain_bounds_1 */
-#define PHY_BB_RX_GAIN_BOUNDS_1_ADDRESS                                                       0x0000a008
-#define PHY_BB_RX_GAIN_BOUNDS_1_OFFSET                                                        0x0000a008
-#define PHY_BB_RX_GAIN_BOUNDS_1_RX_MAX_MB_GAIN_MSB                                                     7
-#define PHY_BB_RX_GAIN_BOUNDS_1_RX_MAX_MB_GAIN_LSB                                                     0
-#define PHY_BB_RX_GAIN_BOUNDS_1_RX_MAX_MB_GAIN_MASK                                           0x000000ff
-#define PHY_BB_RX_GAIN_BOUNDS_1_RX_MAX_MB_GAIN_GET(x)                          (((x) & 0x000000ff) >> 0)
-#define PHY_BB_RX_GAIN_BOUNDS_1_RX_MAX_MB_GAIN_SET(x)                          (((x) << 0) & 0x000000ff)
-#define PHY_BB_RX_GAIN_BOUNDS_1_RX_MAX_RF_GAIN_REF_MSB                                                15
-#define PHY_BB_RX_GAIN_BOUNDS_1_RX_MAX_RF_GAIN_REF_LSB                                                 8
-#define PHY_BB_RX_GAIN_BOUNDS_1_RX_MAX_RF_GAIN_REF_MASK                                       0x0000ff00
-#define PHY_BB_RX_GAIN_BOUNDS_1_RX_MAX_RF_GAIN_REF_GET(x)                      (((x) & 0x0000ff00) >> 8)
-#define PHY_BB_RX_GAIN_BOUNDS_1_RX_MAX_RF_GAIN_REF_SET(x)                      (((x) << 8) & 0x0000ff00)
-#define PHY_BB_RX_GAIN_BOUNDS_1_RX_MAX_RF_GAIN_MSB                                                    23
-#define PHY_BB_RX_GAIN_BOUNDS_1_RX_MAX_RF_GAIN_LSB                                                    16
-#define PHY_BB_RX_GAIN_BOUNDS_1_RX_MAX_RF_GAIN_MASK                                           0x00ff0000
-#define PHY_BB_RX_GAIN_BOUNDS_1_RX_MAX_RF_GAIN_GET(x)                         (((x) & 0x00ff0000) >> 16)
-#define PHY_BB_RX_GAIN_BOUNDS_1_RX_MAX_RF_GAIN_SET(x)                         (((x) << 16) & 0x00ff0000)
-#define PHY_BB_RX_GAIN_BOUNDS_1_RX_OCGAIN_SEL_2G_MSB                                                  24
-#define PHY_BB_RX_GAIN_BOUNDS_1_RX_OCGAIN_SEL_2G_LSB                                                  24
-#define PHY_BB_RX_GAIN_BOUNDS_1_RX_OCGAIN_SEL_2G_MASK                                         0x01000000
-#define PHY_BB_RX_GAIN_BOUNDS_1_RX_OCGAIN_SEL_2G_GET(x)                       (((x) & 0x01000000) >> 24)
-#define PHY_BB_RX_GAIN_BOUNDS_1_RX_OCGAIN_SEL_2G_SET(x)                       (((x) << 24) & 0x01000000)
-#define PHY_BB_RX_GAIN_BOUNDS_1_RX_OCGAIN_SEL_5G_MSB                                                  25
-#define PHY_BB_RX_GAIN_BOUNDS_1_RX_OCGAIN_SEL_5G_LSB                                                  25
-#define PHY_BB_RX_GAIN_BOUNDS_1_RX_OCGAIN_SEL_5G_MASK                                         0x02000000
-#define PHY_BB_RX_GAIN_BOUNDS_1_RX_OCGAIN_SEL_5G_GET(x)                       (((x) & 0x02000000) >> 25)
-#define PHY_BB_RX_GAIN_BOUNDS_1_RX_OCGAIN_SEL_5G_SET(x)                       (((x) << 25) & 0x02000000)
-
-/* macros for BB_rx_gain_bounds_2 */
-#define PHY_BB_RX_GAIN_BOUNDS_2_ADDRESS                                                       0x0000a00c
-#define PHY_BB_RX_GAIN_BOUNDS_2_OFFSET                                                        0x0000a00c
-#define PHY_BB_RX_GAIN_BOUNDS_2_GC_RSSI_LOW_DB_MSB                                                     7
-#define PHY_BB_RX_GAIN_BOUNDS_2_GC_RSSI_LOW_DB_LSB                                                     0
-#define PHY_BB_RX_GAIN_BOUNDS_2_GC_RSSI_LOW_DB_MASK                                           0x000000ff
-#define PHY_BB_RX_GAIN_BOUNDS_2_GC_RSSI_LOW_DB_GET(x)                          (((x) & 0x000000ff) >> 0)
-#define PHY_BB_RX_GAIN_BOUNDS_2_GC_RSSI_LOW_DB_SET(x)                          (((x) << 0) & 0x000000ff)
-#define PHY_BB_RX_GAIN_BOUNDS_2_RF_GAIN_REF_BASE_ADDR_MSB                                             15
-#define PHY_BB_RX_GAIN_BOUNDS_2_RF_GAIN_REF_BASE_ADDR_LSB                                              8
-#define PHY_BB_RX_GAIN_BOUNDS_2_RF_GAIN_REF_BASE_ADDR_MASK                                    0x0000ff00
-#define PHY_BB_RX_GAIN_BOUNDS_2_RF_GAIN_REF_BASE_ADDR_GET(x)                   (((x) & 0x0000ff00) >> 8)
-#define PHY_BB_RX_GAIN_BOUNDS_2_RF_GAIN_REF_BASE_ADDR_SET(x)                   (((x) << 8) & 0x0000ff00)
-#define PHY_BB_RX_GAIN_BOUNDS_2_RF_GAIN_BASE_ADDR_MSB                                                 23
-#define PHY_BB_RX_GAIN_BOUNDS_2_RF_GAIN_BASE_ADDR_LSB                                                 16
-#define PHY_BB_RX_GAIN_BOUNDS_2_RF_GAIN_BASE_ADDR_MASK                                        0x00ff0000
-#define PHY_BB_RX_GAIN_BOUNDS_2_RF_GAIN_BASE_ADDR_GET(x)                      (((x) & 0x00ff0000) >> 16)
-#define PHY_BB_RX_GAIN_BOUNDS_2_RF_GAIN_BASE_ADDR_SET(x)                      (((x) << 16) & 0x00ff0000)
-#define PHY_BB_RX_GAIN_BOUNDS_2_RF_GAIN_DIV_BASE_ADDR_MSB                                             31
-#define PHY_BB_RX_GAIN_BOUNDS_2_RF_GAIN_DIV_BASE_ADDR_LSB                                             24
-#define PHY_BB_RX_GAIN_BOUNDS_2_RF_GAIN_DIV_BASE_ADDR_MASK                                    0xff000000
-#define PHY_BB_RX_GAIN_BOUNDS_2_RF_GAIN_DIV_BASE_ADDR_GET(x)                  (((x) & 0xff000000) >> 24)
-#define PHY_BB_RX_GAIN_BOUNDS_2_RF_GAIN_DIV_BASE_ADDR_SET(x)                  (((x) << 24) & 0xff000000)
-
-/* macros for BB_peak_det_cal_ctrl */
-#define PHY_BB_PEAK_DET_CAL_CTRL_ADDRESS                                                      0x0000a010
-#define PHY_BB_PEAK_DET_CAL_CTRL_OFFSET                                                       0x0000a010
-#define PHY_BB_PEAK_DET_CAL_CTRL_PKDET_CAL_WIN_THR_MSB                                                 5
-#define PHY_BB_PEAK_DET_CAL_CTRL_PKDET_CAL_WIN_THR_LSB                                                 0
-#define PHY_BB_PEAK_DET_CAL_CTRL_PKDET_CAL_WIN_THR_MASK                                       0x0000003f
-#define PHY_BB_PEAK_DET_CAL_CTRL_PKDET_CAL_WIN_THR_GET(x)                      (((x) & 0x0000003f) >> 0)
-#define PHY_BB_PEAK_DET_CAL_CTRL_PKDET_CAL_WIN_THR_SET(x)                      (((x) << 0) & 0x0000003f)
-#define PHY_BB_PEAK_DET_CAL_CTRL_PKDET_CAL_BIAS_MSB                                                   11
-#define PHY_BB_PEAK_DET_CAL_CTRL_PKDET_CAL_BIAS_LSB                                                    6
-#define PHY_BB_PEAK_DET_CAL_CTRL_PKDET_CAL_BIAS_MASK                                          0x00000fc0
-#define PHY_BB_PEAK_DET_CAL_CTRL_PKDET_CAL_BIAS_GET(x)                         (((x) & 0x00000fc0) >> 6)
-#define PHY_BB_PEAK_DET_CAL_CTRL_PKDET_CAL_BIAS_SET(x)                         (((x) << 6) & 0x00000fc0)
-#define PHY_BB_PEAK_DET_CAL_CTRL_PKDET_CAL_MEAS_TIME_SEL_MSB                                          13
-#define PHY_BB_PEAK_DET_CAL_CTRL_PKDET_CAL_MEAS_TIME_SEL_LSB                                          12
-#define PHY_BB_PEAK_DET_CAL_CTRL_PKDET_CAL_MEAS_TIME_SEL_MASK                                 0x00003000
-#define PHY_BB_PEAK_DET_CAL_CTRL_PKDET_CAL_MEAS_TIME_SEL_GET(x)               (((x) & 0x00003000) >> 12)
-#define PHY_BB_PEAK_DET_CAL_CTRL_PKDET_CAL_MEAS_TIME_SEL_SET(x)               (((x) << 12) & 0x00003000)
-
-/* macros for BB_agc_dig_dc_ctrl */
-#define PHY_BB_AGC_DIG_DC_CTRL_ADDRESS                                                        0x0000a014
-#define PHY_BB_AGC_DIG_DC_CTRL_OFFSET                                                         0x0000a014
-#define PHY_BB_AGC_DIG_DC_CTRL_USE_DIG_DC_MSB                                                          0
-#define PHY_BB_AGC_DIG_DC_CTRL_USE_DIG_DC_LSB                                                          0
-#define PHY_BB_AGC_DIG_DC_CTRL_USE_DIG_DC_MASK                                                0x00000001
-#define PHY_BB_AGC_DIG_DC_CTRL_USE_DIG_DC_GET(x)                               (((x) & 0x00000001) >> 0)
-#define PHY_BB_AGC_DIG_DC_CTRL_USE_DIG_DC_SET(x)                               (((x) << 0) & 0x00000001)
-#define PHY_BB_AGC_DIG_DC_CTRL_DIG_DC_SCALE_BIAS_MSB                                                   3
-#define PHY_BB_AGC_DIG_DC_CTRL_DIG_DC_SCALE_BIAS_LSB                                                   1
-#define PHY_BB_AGC_DIG_DC_CTRL_DIG_DC_SCALE_BIAS_MASK                                         0x0000000e
-#define PHY_BB_AGC_DIG_DC_CTRL_DIG_DC_SCALE_BIAS_GET(x)                        (((x) & 0x0000000e) >> 1)
-#define PHY_BB_AGC_DIG_DC_CTRL_DIG_DC_SCALE_BIAS_SET(x)                        (((x) << 1) & 0x0000000e)
-#define PHY_BB_AGC_DIG_DC_CTRL_DIG_DC_CORRECT_CAP_MSB                                                  9
-#define PHY_BB_AGC_DIG_DC_CTRL_DIG_DC_CORRECT_CAP_LSB                                                  4
-#define PHY_BB_AGC_DIG_DC_CTRL_DIG_DC_CORRECT_CAP_MASK                                        0x000003f0
-#define PHY_BB_AGC_DIG_DC_CTRL_DIG_DC_CORRECT_CAP_GET(x)                       (((x) & 0x000003f0) >> 4)
-#define PHY_BB_AGC_DIG_DC_CTRL_DIG_DC_CORRECT_CAP_SET(x)                       (((x) << 4) & 0x000003f0)
-#define PHY_BB_AGC_DIG_DC_CTRL_DIG_DC_MIXER_SEL_MASK_MSB                                              31
-#define PHY_BB_AGC_DIG_DC_CTRL_DIG_DC_MIXER_SEL_MASK_LSB                                              16
-#define PHY_BB_AGC_DIG_DC_CTRL_DIG_DC_MIXER_SEL_MASK_MASK                                     0xffff0000
-#define PHY_BB_AGC_DIG_DC_CTRL_DIG_DC_MIXER_SEL_MASK_GET(x)                   (((x) & 0xffff0000) >> 16)
-#define PHY_BB_AGC_DIG_DC_CTRL_DIG_DC_MIXER_SEL_MASK_SET(x)                   (((x) << 16) & 0xffff0000)
-
-/* macros for BB_agc_dig_dc_status_i_b0 */
-#define PHY_BB_AGC_DIG_DC_STATUS_I_B0_ADDRESS                                                 0x0000a018
-#define PHY_BB_AGC_DIG_DC_STATUS_I_B0_OFFSET                                                  0x0000a018
-#define PHY_BB_AGC_DIG_DC_STATUS_I_B0_DIG_DC_C1_RES_I_0_MSB                                            8
-#define PHY_BB_AGC_DIG_DC_STATUS_I_B0_DIG_DC_C1_RES_I_0_LSB                                            0
-#define PHY_BB_AGC_DIG_DC_STATUS_I_B0_DIG_DC_C1_RES_I_0_MASK                                  0x000001ff
-#define PHY_BB_AGC_DIG_DC_STATUS_I_B0_DIG_DC_C1_RES_I_0_GET(x)                 (((x) & 0x000001ff) >> 0)
-#define PHY_BB_AGC_DIG_DC_STATUS_I_B0_DIG_DC_C2_RES_I_0_MSB                                           17
-#define PHY_BB_AGC_DIG_DC_STATUS_I_B0_DIG_DC_C2_RES_I_0_LSB                                            9
-#define PHY_BB_AGC_DIG_DC_STATUS_I_B0_DIG_DC_C2_RES_I_0_MASK                                  0x0003fe00
-#define PHY_BB_AGC_DIG_DC_STATUS_I_B0_DIG_DC_C2_RES_I_0_GET(x)                 (((x) & 0x0003fe00) >> 9)
-#define PHY_BB_AGC_DIG_DC_STATUS_I_B0_DIG_DC_C3_RES_I_0_MSB                                           26
-#define PHY_BB_AGC_DIG_DC_STATUS_I_B0_DIG_DC_C3_RES_I_0_LSB                                           18
-#define PHY_BB_AGC_DIG_DC_STATUS_I_B0_DIG_DC_C3_RES_I_0_MASK                                  0x07fc0000
-#define PHY_BB_AGC_DIG_DC_STATUS_I_B0_DIG_DC_C3_RES_I_0_GET(x)                (((x) & 0x07fc0000) >> 18)
-
-/* macros for BB_agc_dig_dc_status_q_b0 */
-#define PHY_BB_AGC_DIG_DC_STATUS_Q_B0_ADDRESS                                                 0x0000a01c
-#define PHY_BB_AGC_DIG_DC_STATUS_Q_B0_OFFSET                                                  0x0000a01c
-#define PHY_BB_AGC_DIG_DC_STATUS_Q_B0_DIG_DC_C1_RES_Q_0_MSB                                            8
-#define PHY_BB_AGC_DIG_DC_STATUS_Q_B0_DIG_DC_C1_RES_Q_0_LSB                                            0
-#define PHY_BB_AGC_DIG_DC_STATUS_Q_B0_DIG_DC_C1_RES_Q_0_MASK                                  0x000001ff
-#define PHY_BB_AGC_DIG_DC_STATUS_Q_B0_DIG_DC_C1_RES_Q_0_GET(x)                 (((x) & 0x000001ff) >> 0)
-#define PHY_BB_AGC_DIG_DC_STATUS_Q_B0_DIG_DC_C2_RES_Q_0_MSB                                           17
-#define PHY_BB_AGC_DIG_DC_STATUS_Q_B0_DIG_DC_C2_RES_Q_0_LSB                                            9
-#define PHY_BB_AGC_DIG_DC_STATUS_Q_B0_DIG_DC_C2_RES_Q_0_MASK                                  0x0003fe00
-#define PHY_BB_AGC_DIG_DC_STATUS_Q_B0_DIG_DC_C2_RES_Q_0_GET(x)                 (((x) & 0x0003fe00) >> 9)
-#define PHY_BB_AGC_DIG_DC_STATUS_Q_B0_DIG_DC_C3_RES_Q_0_MSB                                           26
-#define PHY_BB_AGC_DIG_DC_STATUS_Q_B0_DIG_DC_C3_RES_Q_0_LSB                                           18
-#define PHY_BB_AGC_DIG_DC_STATUS_Q_B0_DIG_DC_C3_RES_Q_0_MASK                                  0x07fc0000
-#define PHY_BB_AGC_DIG_DC_STATUS_Q_B0_DIG_DC_C3_RES_Q_0_GET(x)                (((x) & 0x07fc0000) >> 18)
-
-/* macros for BB_bbb_txfir_0 */
-#define PHY_BB_BBB_TXFIR_0_ADDRESS                                                            0x0000a1f4
-#define PHY_BB_BBB_TXFIR_0_OFFSET                                                             0x0000a1f4
-#define PHY_BB_BBB_TXFIR_0_TXFIR_COEFF_H0_MSB                                                          3
-#define PHY_BB_BBB_TXFIR_0_TXFIR_COEFF_H0_LSB                                                          0
-#define PHY_BB_BBB_TXFIR_0_TXFIR_COEFF_H0_MASK                                                0x0000000f
-#define PHY_BB_BBB_TXFIR_0_TXFIR_COEFF_H0_GET(x)                               (((x) & 0x0000000f) >> 0)
-#define PHY_BB_BBB_TXFIR_0_TXFIR_COEFF_H0_SET(x)                               (((x) << 0) & 0x0000000f)
-#define PHY_BB_BBB_TXFIR_0_TXFIR_COEFF_H1_MSB                                                         11
-#define PHY_BB_BBB_TXFIR_0_TXFIR_COEFF_H1_LSB                                                          8
-#define PHY_BB_BBB_TXFIR_0_TXFIR_COEFF_H1_MASK                                                0x00000f00
-#define PHY_BB_BBB_TXFIR_0_TXFIR_COEFF_H1_GET(x)                               (((x) & 0x00000f00) >> 8)
-#define PHY_BB_BBB_TXFIR_0_TXFIR_COEFF_H1_SET(x)                               (((x) << 8) & 0x00000f00)
-#define PHY_BB_BBB_TXFIR_0_TXFIR_COEFF_H2_MSB                                                         20
-#define PHY_BB_BBB_TXFIR_0_TXFIR_COEFF_H2_LSB                                                         16
-#define PHY_BB_BBB_TXFIR_0_TXFIR_COEFF_H2_MASK                                                0x001f0000
-#define PHY_BB_BBB_TXFIR_0_TXFIR_COEFF_H2_GET(x)                              (((x) & 0x001f0000) >> 16)
-#define PHY_BB_BBB_TXFIR_0_TXFIR_COEFF_H2_SET(x)                              (((x) << 16) & 0x001f0000)
-#define PHY_BB_BBB_TXFIR_0_TXFIR_COEFF_H3_MSB                                                         28
-#define PHY_BB_BBB_TXFIR_0_TXFIR_COEFF_H3_LSB                                                         24
-#define PHY_BB_BBB_TXFIR_0_TXFIR_COEFF_H3_MASK                                                0x1f000000
-#define PHY_BB_BBB_TXFIR_0_TXFIR_COEFF_H3_GET(x)                              (((x) & 0x1f000000) >> 24)
-#define PHY_BB_BBB_TXFIR_0_TXFIR_COEFF_H3_SET(x)                              (((x) << 24) & 0x1f000000)
-
-/* macros for BB_bbb_txfir_1 */
-#define PHY_BB_BBB_TXFIR_1_ADDRESS                                                            0x0000a1f8
-#define PHY_BB_BBB_TXFIR_1_OFFSET                                                             0x0000a1f8
-#define PHY_BB_BBB_TXFIR_1_TXFIR_COEFF_H4_MSB                                                          5
-#define PHY_BB_BBB_TXFIR_1_TXFIR_COEFF_H4_LSB                                                          0
-#define PHY_BB_BBB_TXFIR_1_TXFIR_COEFF_H4_MASK                                                0x0000003f
-#define PHY_BB_BBB_TXFIR_1_TXFIR_COEFF_H4_GET(x)                               (((x) & 0x0000003f) >> 0)
-#define PHY_BB_BBB_TXFIR_1_TXFIR_COEFF_H4_SET(x)                               (((x) << 0) & 0x0000003f)
-#define PHY_BB_BBB_TXFIR_1_TXFIR_COEFF_H5_MSB                                                         13
-#define PHY_BB_BBB_TXFIR_1_TXFIR_COEFF_H5_LSB                                                          8
-#define PHY_BB_BBB_TXFIR_1_TXFIR_COEFF_H5_MASK                                                0x00003f00
-#define PHY_BB_BBB_TXFIR_1_TXFIR_COEFF_H5_GET(x)                               (((x) & 0x00003f00) >> 8)
-#define PHY_BB_BBB_TXFIR_1_TXFIR_COEFF_H5_SET(x)                               (((x) << 8) & 0x00003f00)
-#define PHY_BB_BBB_TXFIR_1_TXFIR_COEFF_H6_MSB                                                         22
-#define PHY_BB_BBB_TXFIR_1_TXFIR_COEFF_H6_LSB                                                         16
-#define PHY_BB_BBB_TXFIR_1_TXFIR_COEFF_H6_MASK                                                0x007f0000
-#define PHY_BB_BBB_TXFIR_1_TXFIR_COEFF_H6_GET(x)                              (((x) & 0x007f0000) >> 16)
-#define PHY_BB_BBB_TXFIR_1_TXFIR_COEFF_H6_SET(x)                              (((x) << 16) & 0x007f0000)
-#define PHY_BB_BBB_TXFIR_1_TXFIR_COEFF_H7_MSB                                                         30
-#define PHY_BB_BBB_TXFIR_1_TXFIR_COEFF_H7_LSB                                                         24
-#define PHY_BB_BBB_TXFIR_1_TXFIR_COEFF_H7_MASK                                                0x7f000000
-#define PHY_BB_BBB_TXFIR_1_TXFIR_COEFF_H7_GET(x)                              (((x) & 0x7f000000) >> 24)
-#define PHY_BB_BBB_TXFIR_1_TXFIR_COEFF_H7_SET(x)                              (((x) << 24) & 0x7f000000)
-
-/* macros for BB_bbb_txfir_2 */
-#define PHY_BB_BBB_TXFIR_2_ADDRESS                                                            0x0000a1fc
-#define PHY_BB_BBB_TXFIR_2_OFFSET                                                             0x0000a1fc
-#define PHY_BB_BBB_TXFIR_2_TXFIR_COEFF_H8_MSB                                                          7
-#define PHY_BB_BBB_TXFIR_2_TXFIR_COEFF_H8_LSB                                                          0
-#define PHY_BB_BBB_TXFIR_2_TXFIR_COEFF_H8_MASK                                                0x000000ff
-#define PHY_BB_BBB_TXFIR_2_TXFIR_COEFF_H8_GET(x)                               (((x) & 0x000000ff) >> 0)
-#define PHY_BB_BBB_TXFIR_2_TXFIR_COEFF_H8_SET(x)                               (((x) << 0) & 0x000000ff)
-#define PHY_BB_BBB_TXFIR_2_TXFIR_COEFF_H9_MSB                                                         15
-#define PHY_BB_BBB_TXFIR_2_TXFIR_COEFF_H9_LSB                                                          8
-#define PHY_BB_BBB_TXFIR_2_TXFIR_COEFF_H9_MASK                                                0x0000ff00
-#define PHY_BB_BBB_TXFIR_2_TXFIR_COEFF_H9_GET(x)                               (((x) & 0x0000ff00) >> 8)
-#define PHY_BB_BBB_TXFIR_2_TXFIR_COEFF_H9_SET(x)                               (((x) << 8) & 0x0000ff00)
-#define PHY_BB_BBB_TXFIR_2_TXFIR_COEFF_H10_MSB                                                        23
-#define PHY_BB_BBB_TXFIR_2_TXFIR_COEFF_H10_LSB                                                        16
-#define PHY_BB_BBB_TXFIR_2_TXFIR_COEFF_H10_MASK                                               0x00ff0000
-#define PHY_BB_BBB_TXFIR_2_TXFIR_COEFF_H10_GET(x)                             (((x) & 0x00ff0000) >> 16)
-#define PHY_BB_BBB_TXFIR_2_TXFIR_COEFF_H10_SET(x)                             (((x) << 16) & 0x00ff0000)
-#define PHY_BB_BBB_TXFIR_2_TXFIR_COEFF_H11_MSB                                                        31
-#define PHY_BB_BBB_TXFIR_2_TXFIR_COEFF_H11_LSB                                                        24
-#define PHY_BB_BBB_TXFIR_2_TXFIR_COEFF_H11_MASK                                               0xff000000
-#define PHY_BB_BBB_TXFIR_2_TXFIR_COEFF_H11_GET(x)                             (((x) & 0xff000000) >> 24)
-#define PHY_BB_BBB_TXFIR_2_TXFIR_COEFF_H11_SET(x)                             (((x) << 24) & 0xff000000)
-
-/* macros for BB_modes_select */
-#define PHY_BB_MODES_SELECT_ADDRESS                                                           0x0000a200
-#define PHY_BB_MODES_SELECT_OFFSET                                                            0x0000a200
-#define PHY_BB_MODES_SELECT_CCK_MODE_MSB                                                               0
-#define PHY_BB_MODES_SELECT_CCK_MODE_LSB                                                               0
-#define PHY_BB_MODES_SELECT_CCK_MODE_MASK                                                     0x00000001
-#define PHY_BB_MODES_SELECT_CCK_MODE_GET(x)                                    (((x) & 0x00000001) >> 0)
-#define PHY_BB_MODES_SELECT_CCK_MODE_SET(x)                                    (((x) << 0) & 0x00000001)
-#define PHY_BB_MODES_SELECT_DYN_OFDM_CCK_MODE_MSB                                                      2
-#define PHY_BB_MODES_SELECT_DYN_OFDM_CCK_MODE_LSB                                                      2
-#define PHY_BB_MODES_SELECT_DYN_OFDM_CCK_MODE_MASK                                            0x00000004
-#define PHY_BB_MODES_SELECT_DYN_OFDM_CCK_MODE_GET(x)                           (((x) & 0x00000004) >> 2)
-#define PHY_BB_MODES_SELECT_DYN_OFDM_CCK_MODE_SET(x)                           (((x) << 2) & 0x00000004)
-#define PHY_BB_MODES_SELECT_HALF_RATE_MODE_MSB                                                         5
-#define PHY_BB_MODES_SELECT_HALF_RATE_MODE_LSB                                                         5
-#define PHY_BB_MODES_SELECT_HALF_RATE_MODE_MASK                                               0x00000020
-#define PHY_BB_MODES_SELECT_HALF_RATE_MODE_GET(x)                              (((x) & 0x00000020) >> 5)
-#define PHY_BB_MODES_SELECT_HALF_RATE_MODE_SET(x)                              (((x) << 5) & 0x00000020)
-#define PHY_BB_MODES_SELECT_QUARTER_RATE_MODE_MSB                                                      6
-#define PHY_BB_MODES_SELECT_QUARTER_RATE_MODE_LSB                                                      6
-#define PHY_BB_MODES_SELECT_QUARTER_RATE_MODE_MASK                                            0x00000040
-#define PHY_BB_MODES_SELECT_QUARTER_RATE_MODE_GET(x)                           (((x) & 0x00000040) >> 6)
-#define PHY_BB_MODES_SELECT_QUARTER_RATE_MODE_SET(x)                           (((x) << 6) & 0x00000040)
-#define PHY_BB_MODES_SELECT_MAC_CLK_MODE_MSB                                                           7
-#define PHY_BB_MODES_SELECT_MAC_CLK_MODE_LSB                                                           7
-#define PHY_BB_MODES_SELECT_MAC_CLK_MODE_MASK                                                 0x00000080
-#define PHY_BB_MODES_SELECT_MAC_CLK_MODE_GET(x)                                (((x) & 0x00000080) >> 7)
-#define PHY_BB_MODES_SELECT_MAC_CLK_MODE_SET(x)                                (((x) << 7) & 0x00000080)
-#define PHY_BB_MODES_SELECT_DISABLE_DYN_CCK_DET_MSB                                                    8
-#define PHY_BB_MODES_SELECT_DISABLE_DYN_CCK_DET_LSB                                                    8
-#define PHY_BB_MODES_SELECT_DISABLE_DYN_CCK_DET_MASK                                          0x00000100
-#define PHY_BB_MODES_SELECT_DISABLE_DYN_CCK_DET_GET(x)                         (((x) & 0x00000100) >> 8)
-#define PHY_BB_MODES_SELECT_DISABLE_DYN_CCK_DET_SET(x)                         (((x) << 8) & 0x00000100)
-
-/* macros for BB_bbb_tx_ctrl */
-#define PHY_BB_BBB_TX_CTRL_ADDRESS                                                            0x0000a204
-#define PHY_BB_BBB_TX_CTRL_OFFSET                                                             0x0000a204
-#define PHY_BB_BBB_TX_CTRL_DISABLE_SCRAMBLER_MSB                                                       0
-#define PHY_BB_BBB_TX_CTRL_DISABLE_SCRAMBLER_LSB                                                       0
-#define PHY_BB_BBB_TX_CTRL_DISABLE_SCRAMBLER_MASK                                             0x00000001
-#define PHY_BB_BBB_TX_CTRL_DISABLE_SCRAMBLER_GET(x)                            (((x) & 0x00000001) >> 0)
-#define PHY_BB_BBB_TX_CTRL_DISABLE_SCRAMBLER_SET(x)                            (((x) << 0) & 0x00000001)
-#define PHY_BB_BBB_TX_CTRL_USE_SCRAMBLER_SEED_MSB                                                      1
-#define PHY_BB_BBB_TX_CTRL_USE_SCRAMBLER_SEED_LSB                                                      1
-#define PHY_BB_BBB_TX_CTRL_USE_SCRAMBLER_SEED_MASK                                            0x00000002
-#define PHY_BB_BBB_TX_CTRL_USE_SCRAMBLER_SEED_GET(x)                           (((x) & 0x00000002) >> 1)
-#define PHY_BB_BBB_TX_CTRL_USE_SCRAMBLER_SEED_SET(x)                           (((x) << 1) & 0x00000002)
-#define PHY_BB_BBB_TX_CTRL_TX_DAC_SCALE_CCK_MSB                                                        3
-#define PHY_BB_BBB_TX_CTRL_TX_DAC_SCALE_CCK_LSB                                                        2
-#define PHY_BB_BBB_TX_CTRL_TX_DAC_SCALE_CCK_MASK                                              0x0000000c
-#define PHY_BB_BBB_TX_CTRL_TX_DAC_SCALE_CCK_GET(x)                             (((x) & 0x0000000c) >> 2)
-#define PHY_BB_BBB_TX_CTRL_TX_DAC_SCALE_CCK_SET(x)                             (((x) << 2) & 0x0000000c)
-#define PHY_BB_BBB_TX_CTRL_TXFIR_JAPAN_CCK_MSB                                                         4
-#define PHY_BB_BBB_TX_CTRL_TXFIR_JAPAN_CCK_LSB                                                         4
-#define PHY_BB_BBB_TX_CTRL_TXFIR_JAPAN_CCK_MASK                                               0x00000010
-#define PHY_BB_BBB_TX_CTRL_TXFIR_JAPAN_CCK_GET(x)                              (((x) & 0x00000010) >> 4)
-#define PHY_BB_BBB_TX_CTRL_TXFIR_JAPAN_CCK_SET(x)                              (((x) << 4) & 0x00000010)
-#define PHY_BB_BBB_TX_CTRL_ALLOW_1MBPS_SHORT_MSB                                                       5
-#define PHY_BB_BBB_TX_CTRL_ALLOW_1MBPS_SHORT_LSB                                                       5
-#define PHY_BB_BBB_TX_CTRL_ALLOW_1MBPS_SHORT_MASK                                             0x00000020
-#define PHY_BB_BBB_TX_CTRL_ALLOW_1MBPS_SHORT_GET(x)                            (((x) & 0x00000020) >> 5)
-#define PHY_BB_BBB_TX_CTRL_ALLOW_1MBPS_SHORT_SET(x)                            (((x) << 5) & 0x00000020)
-#define PHY_BB_BBB_TX_CTRL_TX_CCK_DELAY_1_MSB                                                          8
-#define PHY_BB_BBB_TX_CTRL_TX_CCK_DELAY_1_LSB                                                          6
-#define PHY_BB_BBB_TX_CTRL_TX_CCK_DELAY_1_MASK                                                0x000001c0
-#define PHY_BB_BBB_TX_CTRL_TX_CCK_DELAY_1_GET(x)                               (((x) & 0x000001c0) >> 6)
-#define PHY_BB_BBB_TX_CTRL_TX_CCK_DELAY_1_SET(x)                               (((x) << 6) & 0x000001c0)
-#define PHY_BB_BBB_TX_CTRL_TX_CCK_DELAY_2_MSB                                                         11
-#define PHY_BB_BBB_TX_CTRL_TX_CCK_DELAY_2_LSB                                                          9
-#define PHY_BB_BBB_TX_CTRL_TX_CCK_DELAY_2_MASK                                                0x00000e00
-#define PHY_BB_BBB_TX_CTRL_TX_CCK_DELAY_2_GET(x)                               (((x) & 0x00000e00) >> 9)
-#define PHY_BB_BBB_TX_CTRL_TX_CCK_DELAY_2_SET(x)                               (((x) << 9) & 0x00000e00)
-
-/* macros for BB_bbb_sig_detect */
-#define PHY_BB_BBB_SIG_DETECT_ADDRESS                                                         0x0000a208
-#define PHY_BB_BBB_SIG_DETECT_OFFSET                                                          0x0000a208
-#define PHY_BB_BBB_SIG_DETECT_WEAK_SIG_THR_CCK_MSB                                                     5
-#define PHY_BB_BBB_SIG_DETECT_WEAK_SIG_THR_CCK_LSB                                                     0
-#define PHY_BB_BBB_SIG_DETECT_WEAK_SIG_THR_CCK_MASK                                           0x0000003f
-#define PHY_BB_BBB_SIG_DETECT_WEAK_SIG_THR_CCK_GET(x)                          (((x) & 0x0000003f) >> 0)
-#define PHY_BB_BBB_SIG_DETECT_WEAK_SIG_THR_CCK_SET(x)                          (((x) << 0) & 0x0000003f)
-#define PHY_BB_BBB_SIG_DETECT_ANT_SWITCH_TIME_MSB                                                     12
-#define PHY_BB_BBB_SIG_DETECT_ANT_SWITCH_TIME_LSB                                                      6
-#define PHY_BB_BBB_SIG_DETECT_ANT_SWITCH_TIME_MASK                                            0x00001fc0
-#define PHY_BB_BBB_SIG_DETECT_ANT_SWITCH_TIME_GET(x)                           (((x) & 0x00001fc0) >> 6)
-#define PHY_BB_BBB_SIG_DETECT_ANT_SWITCH_TIME_SET(x)                           (((x) << 6) & 0x00001fc0)
-#define PHY_BB_BBB_SIG_DETECT_ENABLE_ANT_FAST_DIV_MSB                                                 13
-#define PHY_BB_BBB_SIG_DETECT_ENABLE_ANT_FAST_DIV_LSB                                                 13
-#define PHY_BB_BBB_SIG_DETECT_ENABLE_ANT_FAST_DIV_MASK                                        0x00002000
-#define PHY_BB_BBB_SIG_DETECT_ENABLE_ANT_FAST_DIV_GET(x)                      (((x) & 0x00002000) >> 13)
-#define PHY_BB_BBB_SIG_DETECT_ENABLE_ANT_FAST_DIV_SET(x)                      (((x) << 13) & 0x00002000)
-#define PHY_BB_BBB_SIG_DETECT_LB_ALPHA_128_CCK_MSB                                                    14
-#define PHY_BB_BBB_SIG_DETECT_LB_ALPHA_128_CCK_LSB                                                    14
-#define PHY_BB_BBB_SIG_DETECT_LB_ALPHA_128_CCK_MASK                                           0x00004000
-#define PHY_BB_BBB_SIG_DETECT_LB_ALPHA_128_CCK_GET(x)                         (((x) & 0x00004000) >> 14)
-#define PHY_BB_BBB_SIG_DETECT_LB_ALPHA_128_CCK_SET(x)                         (((x) << 14) & 0x00004000)
-#define PHY_BB_BBB_SIG_DETECT_LB_RX_ENABLE_CCK_MSB                                                    15
-#define PHY_BB_BBB_SIG_DETECT_LB_RX_ENABLE_CCK_LSB                                                    15
-#define PHY_BB_BBB_SIG_DETECT_LB_RX_ENABLE_CCK_MASK                                           0x00008000
-#define PHY_BB_BBB_SIG_DETECT_LB_RX_ENABLE_CCK_GET(x)                         (((x) & 0x00008000) >> 15)
-#define PHY_BB_BBB_SIG_DETECT_LB_RX_ENABLE_CCK_SET(x)                         (((x) << 15) & 0x00008000)
-#define PHY_BB_BBB_SIG_DETECT_CYC32_COARSE_DC_EST_CCK_MSB                                             16
-#define PHY_BB_BBB_SIG_DETECT_CYC32_COARSE_DC_EST_CCK_LSB                                             16
-#define PHY_BB_BBB_SIG_DETECT_CYC32_COARSE_DC_EST_CCK_MASK                                    0x00010000
-#define PHY_BB_BBB_SIG_DETECT_CYC32_COARSE_DC_EST_CCK_GET(x)                  (((x) & 0x00010000) >> 16)
-#define PHY_BB_BBB_SIG_DETECT_CYC32_COARSE_DC_EST_CCK_SET(x)                  (((x) << 16) & 0x00010000)
-#define PHY_BB_BBB_SIG_DETECT_CYC64_COARSE_DC_EST_CCK_MSB                                             17
-#define PHY_BB_BBB_SIG_DETECT_CYC64_COARSE_DC_EST_CCK_LSB                                             17
-#define PHY_BB_BBB_SIG_DETECT_CYC64_COARSE_DC_EST_CCK_MASK                                    0x00020000
-#define PHY_BB_BBB_SIG_DETECT_CYC64_COARSE_DC_EST_CCK_GET(x)                  (((x) & 0x00020000) >> 17)
-#define PHY_BB_BBB_SIG_DETECT_CYC64_COARSE_DC_EST_CCK_SET(x)                  (((x) << 17) & 0x00020000)
-#define PHY_BB_BBB_SIG_DETECT_ENABLE_COARSE_DC_CCK_MSB                                                18
-#define PHY_BB_BBB_SIG_DETECT_ENABLE_COARSE_DC_CCK_LSB                                                18
-#define PHY_BB_BBB_SIG_DETECT_ENABLE_COARSE_DC_CCK_MASK                                       0x00040000
-#define PHY_BB_BBB_SIG_DETECT_ENABLE_COARSE_DC_CCK_GET(x)                     (((x) & 0x00040000) >> 18)
-#define PHY_BB_BBB_SIG_DETECT_ENABLE_COARSE_DC_CCK_SET(x)                     (((x) << 18) & 0x00040000)
-#define PHY_BB_BBB_SIG_DETECT_CYC256_FINE_DC_EST_CCK_MSB                                              19
-#define PHY_BB_BBB_SIG_DETECT_CYC256_FINE_DC_EST_CCK_LSB                                              19
-#define PHY_BB_BBB_SIG_DETECT_CYC256_FINE_DC_EST_CCK_MASK                                     0x00080000
-#define PHY_BB_BBB_SIG_DETECT_CYC256_FINE_DC_EST_CCK_GET(x)                   (((x) & 0x00080000) >> 19)
-#define PHY_BB_BBB_SIG_DETECT_CYC256_FINE_DC_EST_CCK_SET(x)                   (((x) << 19) & 0x00080000)
-#define PHY_BB_BBB_SIG_DETECT_ENABLE_FINE_DC_CCK_MSB                                                  20
-#define PHY_BB_BBB_SIG_DETECT_ENABLE_FINE_DC_CCK_LSB                                                  20
-#define PHY_BB_BBB_SIG_DETECT_ENABLE_FINE_DC_CCK_MASK                                         0x00100000
-#define PHY_BB_BBB_SIG_DETECT_ENABLE_FINE_DC_CCK_GET(x)                       (((x) & 0x00100000) >> 20)
-#define PHY_BB_BBB_SIG_DETECT_ENABLE_FINE_DC_CCK_SET(x)                       (((x) << 20) & 0x00100000)
-#define PHY_BB_BBB_SIG_DETECT_DELAY_START_SYNC_CCK_MSB                                                21
-#define PHY_BB_BBB_SIG_DETECT_DELAY_START_SYNC_CCK_LSB                                                21
-#define PHY_BB_BBB_SIG_DETECT_DELAY_START_SYNC_CCK_MASK                                       0x00200000
-#define PHY_BB_BBB_SIG_DETECT_DELAY_START_SYNC_CCK_GET(x)                     (((x) & 0x00200000) >> 21)
-#define PHY_BB_BBB_SIG_DETECT_DELAY_START_SYNC_CCK_SET(x)                     (((x) << 21) & 0x00200000)
-#define PHY_BB_BBB_SIG_DETECT_USE_DC_EST_DURING_SRCH_MSB                                              22
-#define PHY_BB_BBB_SIG_DETECT_USE_DC_EST_DURING_SRCH_LSB                                              22
-#define PHY_BB_BBB_SIG_DETECT_USE_DC_EST_DURING_SRCH_MASK                                     0x00400000
-#define PHY_BB_BBB_SIG_DETECT_USE_DC_EST_DURING_SRCH_GET(x)                   (((x) & 0x00400000) >> 22)
-#define PHY_BB_BBB_SIG_DETECT_USE_DC_EST_DURING_SRCH_SET(x)                   (((x) << 22) & 0x00400000)
-#define PHY_BB_BBB_SIG_DETECT_ENABLE_BARKER_TWO_PHASE_MSB                                             31
-#define PHY_BB_BBB_SIG_DETECT_ENABLE_BARKER_TWO_PHASE_LSB                                             31
-#define PHY_BB_BBB_SIG_DETECT_ENABLE_BARKER_TWO_PHASE_MASK                                    0x80000000
-#define PHY_BB_BBB_SIG_DETECT_ENABLE_BARKER_TWO_PHASE_GET(x)                  (((x) & 0x80000000) >> 31)
-#define PHY_BB_BBB_SIG_DETECT_ENABLE_BARKER_TWO_PHASE_SET(x)                  (((x) << 31) & 0x80000000)
-
-/* macros for BB_ext_atten_switch_ctl_b0 */
-#define PHY_BB_EXT_ATTEN_SWITCH_CTL_B0_ADDRESS                                                0x0000a20c
-#define PHY_BB_EXT_ATTEN_SWITCH_CTL_B0_OFFSET                                                 0x0000a20c
-#define PHY_BB_EXT_ATTEN_SWITCH_CTL_B0_XATTEN1_DB_0_MSB                                                5
-#define PHY_BB_EXT_ATTEN_SWITCH_CTL_B0_XATTEN1_DB_0_LSB                                                0
-#define PHY_BB_EXT_ATTEN_SWITCH_CTL_B0_XATTEN1_DB_0_MASK                                      0x0000003f
-#define PHY_BB_EXT_ATTEN_SWITCH_CTL_B0_XATTEN1_DB_0_GET(x)                     (((x) & 0x0000003f) >> 0)
-#define PHY_BB_EXT_ATTEN_SWITCH_CTL_B0_XATTEN1_DB_0_SET(x)                     (((x) << 0) & 0x0000003f)
-#define PHY_BB_EXT_ATTEN_SWITCH_CTL_B0_XATTEN2_DB_0_MSB                                               11
-#define PHY_BB_EXT_ATTEN_SWITCH_CTL_B0_XATTEN2_DB_0_LSB                                                6
-#define PHY_BB_EXT_ATTEN_SWITCH_CTL_B0_XATTEN2_DB_0_MASK                                      0x00000fc0
-#define PHY_BB_EXT_ATTEN_SWITCH_CTL_B0_XATTEN2_DB_0_GET(x)                     (((x) & 0x00000fc0) >> 6)
-#define PHY_BB_EXT_ATTEN_SWITCH_CTL_B0_XATTEN2_DB_0_SET(x)                     (((x) << 6) & 0x00000fc0)
-#define PHY_BB_EXT_ATTEN_SWITCH_CTL_B0_XATTEN1_MARGIN_0_MSB                                           16
-#define PHY_BB_EXT_ATTEN_SWITCH_CTL_B0_XATTEN1_MARGIN_0_LSB                                           12
-#define PHY_BB_EXT_ATTEN_SWITCH_CTL_B0_XATTEN1_MARGIN_0_MASK                                  0x0001f000
-#define PHY_BB_EXT_ATTEN_SWITCH_CTL_B0_XATTEN1_MARGIN_0_GET(x)                (((x) & 0x0001f000) >> 12)
-#define PHY_BB_EXT_ATTEN_SWITCH_CTL_B0_XATTEN1_MARGIN_0_SET(x)                (((x) << 12) & 0x0001f000)
-#define PHY_BB_EXT_ATTEN_SWITCH_CTL_B0_XATTEN2_MARGIN_0_MSB                                           21
-#define PHY_BB_EXT_ATTEN_SWITCH_CTL_B0_XATTEN2_MARGIN_0_LSB                                           17
-#define PHY_BB_EXT_ATTEN_SWITCH_CTL_B0_XATTEN2_MARGIN_0_MASK                                  0x003e0000
-#define PHY_BB_EXT_ATTEN_SWITCH_CTL_B0_XATTEN2_MARGIN_0_GET(x)                (((x) & 0x003e0000) >> 17)
-#define PHY_BB_EXT_ATTEN_SWITCH_CTL_B0_XATTEN2_MARGIN_0_SET(x)                (((x) << 17) & 0x003e0000)
-
-/* macros for BB_bbb_rx_ctrl_1 */
-#define PHY_BB_BBB_RX_CTRL_1_ADDRESS                                                          0x0000a210
-#define PHY_BB_BBB_RX_CTRL_1_OFFSET                                                           0x0000a210
-#define PHY_BB_BBB_RX_CTRL_1_COARSE_TIM_THRESHOLD_2_MSB                                                2
-#define PHY_BB_BBB_RX_CTRL_1_COARSE_TIM_THRESHOLD_2_LSB                                                0
-#define PHY_BB_BBB_RX_CTRL_1_COARSE_TIM_THRESHOLD_2_MASK                                      0x00000007
-#define PHY_BB_BBB_RX_CTRL_1_COARSE_TIM_THRESHOLD_2_GET(x)                     (((x) & 0x00000007) >> 0)
-#define PHY_BB_BBB_RX_CTRL_1_COARSE_TIM_THRESHOLD_2_SET(x)                     (((x) << 0) & 0x00000007)
-#define PHY_BB_BBB_RX_CTRL_1_COARSE_TIM_THRESHOLD_MSB                                                  7
-#define PHY_BB_BBB_RX_CTRL_1_COARSE_TIM_THRESHOLD_LSB                                                  3
-#define PHY_BB_BBB_RX_CTRL_1_COARSE_TIM_THRESHOLD_MASK                                        0x000000f8
-#define PHY_BB_BBB_RX_CTRL_1_COARSE_TIM_THRESHOLD_GET(x)                       (((x) & 0x000000f8) >> 3)
-#define PHY_BB_BBB_RX_CTRL_1_COARSE_TIM_THRESHOLD_SET(x)                       (((x) << 3) & 0x000000f8)
-#define PHY_BB_BBB_RX_CTRL_1_COARSE_TIM_N_SYNC_MSB                                                    10
-#define PHY_BB_BBB_RX_CTRL_1_COARSE_TIM_N_SYNC_LSB                                                     8
-#define PHY_BB_BBB_RX_CTRL_1_COARSE_TIM_N_SYNC_MASK                                           0x00000700
-#define PHY_BB_BBB_RX_CTRL_1_COARSE_TIM_N_SYNC_GET(x)                          (((x) & 0x00000700) >> 8)
-#define PHY_BB_BBB_RX_CTRL_1_COARSE_TIM_N_SYNC_SET(x)                          (((x) << 8) & 0x00000700)
-#define PHY_BB_BBB_RX_CTRL_1_MAX_BAL_LONG_MSB                                                         15
-#define PHY_BB_BBB_RX_CTRL_1_MAX_BAL_LONG_LSB                                                         11
-#define PHY_BB_BBB_RX_CTRL_1_MAX_BAL_LONG_MASK                                                0x0000f800
-#define PHY_BB_BBB_RX_CTRL_1_MAX_BAL_LONG_GET(x)                              (((x) & 0x0000f800) >> 11)
-#define PHY_BB_BBB_RX_CTRL_1_MAX_BAL_LONG_SET(x)                              (((x) << 11) & 0x0000f800)
-#define PHY_BB_BBB_RX_CTRL_1_MAX_BAL_SHORT_MSB                                                        20
-#define PHY_BB_BBB_RX_CTRL_1_MAX_BAL_SHORT_LSB                                                        16
-#define PHY_BB_BBB_RX_CTRL_1_MAX_BAL_SHORT_MASK                                               0x001f0000
-#define PHY_BB_BBB_RX_CTRL_1_MAX_BAL_SHORT_GET(x)                             (((x) & 0x001f0000) >> 16)
-#define PHY_BB_BBB_RX_CTRL_1_MAX_BAL_SHORT_SET(x)                             (((x) << 16) & 0x001f0000)
-#define PHY_BB_BBB_RX_CTRL_1_RECON_LMS_STEP_MSB                                                       23
-#define PHY_BB_BBB_RX_CTRL_1_RECON_LMS_STEP_LSB                                                       21
-#define PHY_BB_BBB_RX_CTRL_1_RECON_LMS_STEP_MASK                                              0x00e00000
-#define PHY_BB_BBB_RX_CTRL_1_RECON_LMS_STEP_GET(x)                            (((x) & 0x00e00000) >> 21)
-#define PHY_BB_BBB_RX_CTRL_1_RECON_LMS_STEP_SET(x)                            (((x) << 21) & 0x00e00000)
-#define PHY_BB_BBB_RX_CTRL_1_SB_CHECK_WIN_MSB                                                         30
-#define PHY_BB_BBB_RX_CTRL_1_SB_CHECK_WIN_LSB                                                         24
-#define PHY_BB_BBB_RX_CTRL_1_SB_CHECK_WIN_MASK                                                0x7f000000
-#define PHY_BB_BBB_RX_CTRL_1_SB_CHECK_WIN_GET(x)                              (((x) & 0x7f000000) >> 24)
-#define PHY_BB_BBB_RX_CTRL_1_SB_CHECK_WIN_SET(x)                              (((x) << 24) & 0x7f000000)
-#define PHY_BB_BBB_RX_CTRL_1_EN_RX_ABORT_CCK_MSB                                                      31
-#define PHY_BB_BBB_RX_CTRL_1_EN_RX_ABORT_CCK_LSB                                                      31
-#define PHY_BB_BBB_RX_CTRL_1_EN_RX_ABORT_CCK_MASK                                             0x80000000
-#define PHY_BB_BBB_RX_CTRL_1_EN_RX_ABORT_CCK_GET(x)                           (((x) & 0x80000000) >> 31)
-#define PHY_BB_BBB_RX_CTRL_1_EN_RX_ABORT_CCK_SET(x)                           (((x) << 31) & 0x80000000)
-
-/* macros for BB_bbb_rx_ctrl_2 */
-#define PHY_BB_BBB_RX_CTRL_2_ADDRESS                                                          0x0000a214
-#define PHY_BB_BBB_RX_CTRL_2_OFFSET                                                           0x0000a214
-#define PHY_BB_BBB_RX_CTRL_2_FREQ_EST_N_AVG_LONG_MSB                                                   5
-#define PHY_BB_BBB_RX_CTRL_2_FREQ_EST_N_AVG_LONG_LSB                                                   0
-#define PHY_BB_BBB_RX_CTRL_2_FREQ_EST_N_AVG_LONG_MASK                                         0x0000003f
-#define PHY_BB_BBB_RX_CTRL_2_FREQ_EST_N_AVG_LONG_GET(x)                        (((x) & 0x0000003f) >> 0)
-#define PHY_BB_BBB_RX_CTRL_2_FREQ_EST_N_AVG_LONG_SET(x)                        (((x) << 0) & 0x0000003f)
-#define PHY_BB_BBB_RX_CTRL_2_CHAN_AVG_LONG_MSB                                                        11
-#define PHY_BB_BBB_RX_CTRL_2_CHAN_AVG_LONG_LSB                                                         6
-#define PHY_BB_BBB_RX_CTRL_2_CHAN_AVG_LONG_MASK                                               0x00000fc0
-#define PHY_BB_BBB_RX_CTRL_2_CHAN_AVG_LONG_GET(x)                              (((x) & 0x00000fc0) >> 6)
-#define PHY_BB_BBB_RX_CTRL_2_CHAN_AVG_LONG_SET(x)                              (((x) << 6) & 0x00000fc0)
-#define PHY_BB_BBB_RX_CTRL_2_COARSE_TIM_THRESHOLD_3_MSB                                               16
-#define PHY_BB_BBB_RX_CTRL_2_COARSE_TIM_THRESHOLD_3_LSB                                               12
-#define PHY_BB_BBB_RX_CTRL_2_COARSE_TIM_THRESHOLD_3_MASK                                      0x0001f000
-#define PHY_BB_BBB_RX_CTRL_2_COARSE_TIM_THRESHOLD_3_GET(x)                    (((x) & 0x0001f000) >> 12)
-#define PHY_BB_BBB_RX_CTRL_2_COARSE_TIM_THRESHOLD_3_SET(x)                    (((x) << 12) & 0x0001f000)
-#define PHY_BB_BBB_RX_CTRL_2_FREQ_TRACK_UPDATE_PERIOD_MSB                                             21
-#define PHY_BB_BBB_RX_CTRL_2_FREQ_TRACK_UPDATE_PERIOD_LSB                                             17
-#define PHY_BB_BBB_RX_CTRL_2_FREQ_TRACK_UPDATE_PERIOD_MASK                                    0x003e0000
-#define PHY_BB_BBB_RX_CTRL_2_FREQ_TRACK_UPDATE_PERIOD_GET(x)                  (((x) & 0x003e0000) >> 17)
-#define PHY_BB_BBB_RX_CTRL_2_FREQ_TRACK_UPDATE_PERIOD_SET(x)                  (((x) << 17) & 0x003e0000)
-#define PHY_BB_BBB_RX_CTRL_2_FREQ_EST_SCALING_PERIOD_MSB                                              25
-#define PHY_BB_BBB_RX_CTRL_2_FREQ_EST_SCALING_PERIOD_LSB                                              22
-#define PHY_BB_BBB_RX_CTRL_2_FREQ_EST_SCALING_PERIOD_MASK                                     0x03c00000
-#define PHY_BB_BBB_RX_CTRL_2_FREQ_EST_SCALING_PERIOD_GET(x)                   (((x) & 0x03c00000) >> 22)
-#define PHY_BB_BBB_RX_CTRL_2_FREQ_EST_SCALING_PERIOD_SET(x)                   (((x) << 22) & 0x03c00000)
-#define PHY_BB_BBB_RX_CTRL_2_LOOP_COEF_DPSK_C2_DATA_MSB                                               31
-#define PHY_BB_BBB_RX_CTRL_2_LOOP_COEF_DPSK_C2_DATA_LSB                                               26
-#define PHY_BB_BBB_RX_CTRL_2_LOOP_COEF_DPSK_C2_DATA_MASK                                      0xfc000000
-#define PHY_BB_BBB_RX_CTRL_2_LOOP_COEF_DPSK_C2_DATA_GET(x)                    (((x) & 0xfc000000) >> 26)
-#define PHY_BB_BBB_RX_CTRL_2_LOOP_COEF_DPSK_C2_DATA_SET(x)                    (((x) << 26) & 0xfc000000)
-
-/* macros for BB_bbb_rx_ctrl_3 */
-#define PHY_BB_BBB_RX_CTRL_3_ADDRESS                                                          0x0000a218
-#define PHY_BB_BBB_RX_CTRL_3_OFFSET                                                           0x0000a218
-#define PHY_BB_BBB_RX_CTRL_3_TIM_ADJUST_FREQ_DPSK_MSB                                                  7
-#define PHY_BB_BBB_RX_CTRL_3_TIM_ADJUST_FREQ_DPSK_LSB                                                  0
-#define PHY_BB_BBB_RX_CTRL_3_TIM_ADJUST_FREQ_DPSK_MASK                                        0x000000ff
-#define PHY_BB_BBB_RX_CTRL_3_TIM_ADJUST_FREQ_DPSK_GET(x)                       (((x) & 0x000000ff) >> 0)
-#define PHY_BB_BBB_RX_CTRL_3_TIM_ADJUST_FREQ_DPSK_SET(x)                       (((x) << 0) & 0x000000ff)
-#define PHY_BB_BBB_RX_CTRL_3_TIM_ADJUST_FREQ_CCK_MSB                                                  15
-#define PHY_BB_BBB_RX_CTRL_3_TIM_ADJUST_FREQ_CCK_LSB                                                   8
-#define PHY_BB_BBB_RX_CTRL_3_TIM_ADJUST_FREQ_CCK_MASK                                         0x0000ff00
-#define PHY_BB_BBB_RX_CTRL_3_TIM_ADJUST_FREQ_CCK_GET(x)                        (((x) & 0x0000ff00) >> 8)
-#define PHY_BB_BBB_RX_CTRL_3_TIM_ADJUST_FREQ_CCK_SET(x)                        (((x) << 8) & 0x0000ff00)
-#define PHY_BB_BBB_RX_CTRL_3_TIMER_N_SFD_MSB                                                          23
-#define PHY_BB_BBB_RX_CTRL_3_TIMER_N_SFD_LSB                                                          16
-#define PHY_BB_BBB_RX_CTRL_3_TIMER_N_SFD_MASK                                                 0x00ff0000
-#define PHY_BB_BBB_RX_CTRL_3_TIMER_N_SFD_GET(x)                               (((x) & 0x00ff0000) >> 16)
-#define PHY_BB_BBB_RX_CTRL_3_TIMER_N_SFD_SET(x)                               (((x) << 16) & 0x00ff0000)
-
-/* macros for BB_bbb_rx_ctrl_4 */
-#define PHY_BB_BBB_RX_CTRL_4_ADDRESS                                                          0x0000a21c
-#define PHY_BB_BBB_RX_CTRL_4_OFFSET                                                           0x0000a21c
-#define PHY_BB_BBB_RX_CTRL_4_TIMER_N_SYNC_MSB                                                          3
-#define PHY_BB_BBB_RX_CTRL_4_TIMER_N_SYNC_LSB                                                          0
-#define PHY_BB_BBB_RX_CTRL_4_TIMER_N_SYNC_MASK                                                0x0000000f
-#define PHY_BB_BBB_RX_CTRL_4_TIMER_N_SYNC_GET(x)                               (((x) & 0x0000000f) >> 0)
-#define PHY_BB_BBB_RX_CTRL_4_TIMER_N_SYNC_SET(x)                               (((x) << 0) & 0x0000000f)
-#define PHY_BB_BBB_RX_CTRL_4_TIM_ADJUST_TIMER_EXP_MSB                                                 15
-#define PHY_BB_BBB_RX_CTRL_4_TIM_ADJUST_TIMER_EXP_LSB                                                  4
-#define PHY_BB_BBB_RX_CTRL_4_TIM_ADJUST_TIMER_EXP_MASK                                        0x0000fff0
-#define PHY_BB_BBB_RX_CTRL_4_TIM_ADJUST_TIMER_EXP_GET(x)                       (((x) & 0x0000fff0) >> 4)
-#define PHY_BB_BBB_RX_CTRL_4_TIM_ADJUST_TIMER_EXP_SET(x)                       (((x) << 4) & 0x0000fff0)
-#define PHY_BB_BBB_RX_CTRL_4_FORCE_UNLOCKED_CLOCKS_MSB                                                16
-#define PHY_BB_BBB_RX_CTRL_4_FORCE_UNLOCKED_CLOCKS_LSB                                                16
-#define PHY_BB_BBB_RX_CTRL_4_FORCE_UNLOCKED_CLOCKS_MASK                                       0x00010000
-#define PHY_BB_BBB_RX_CTRL_4_FORCE_UNLOCKED_CLOCKS_GET(x)                     (((x) & 0x00010000) >> 16)
-#define PHY_BB_BBB_RX_CTRL_4_FORCE_UNLOCKED_CLOCKS_SET(x)                     (((x) << 16) & 0x00010000)
-#define PHY_BB_BBB_RX_CTRL_4_DYNAMIC_PREAM_SEL_MSB                                                    17
-#define PHY_BB_BBB_RX_CTRL_4_DYNAMIC_PREAM_SEL_LSB                                                    17
-#define PHY_BB_BBB_RX_CTRL_4_DYNAMIC_PREAM_SEL_MASK                                           0x00020000
-#define PHY_BB_BBB_RX_CTRL_4_DYNAMIC_PREAM_SEL_GET(x)                         (((x) & 0x00020000) >> 17)
-#define PHY_BB_BBB_RX_CTRL_4_DYNAMIC_PREAM_SEL_SET(x)                         (((x) << 17) & 0x00020000)
-#define PHY_BB_BBB_RX_CTRL_4_SHORT_PREAMBLE_MSB                                                       18
-#define PHY_BB_BBB_RX_CTRL_4_SHORT_PREAMBLE_LSB                                                       18
-#define PHY_BB_BBB_RX_CTRL_4_SHORT_PREAMBLE_MASK                                              0x00040000
-#define PHY_BB_BBB_RX_CTRL_4_SHORT_PREAMBLE_GET(x)                            (((x) & 0x00040000) >> 18)
-#define PHY_BB_BBB_RX_CTRL_4_SHORT_PREAMBLE_SET(x)                            (((x) << 18) & 0x00040000)
-#define PHY_BB_BBB_RX_CTRL_4_FREQ_EST_N_AVG_SHORT_MSB                                                 24
-#define PHY_BB_BBB_RX_CTRL_4_FREQ_EST_N_AVG_SHORT_LSB                                                 19
-#define PHY_BB_BBB_RX_CTRL_4_FREQ_EST_N_AVG_SHORT_MASK                                        0x01f80000
-#define PHY_BB_BBB_RX_CTRL_4_FREQ_EST_N_AVG_SHORT_GET(x)                      (((x) & 0x01f80000) >> 19)
-#define PHY_BB_BBB_RX_CTRL_4_FREQ_EST_N_AVG_SHORT_SET(x)                      (((x) << 19) & 0x01f80000)
-#define PHY_BB_BBB_RX_CTRL_4_CHAN_AVG_SHORT_MSB                                                       30
-#define PHY_BB_BBB_RX_CTRL_4_CHAN_AVG_SHORT_LSB                                                       25
-#define PHY_BB_BBB_RX_CTRL_4_CHAN_AVG_SHORT_MASK                                              0x7e000000
-#define PHY_BB_BBB_RX_CTRL_4_CHAN_AVG_SHORT_GET(x)                            (((x) & 0x7e000000) >> 25)
-#define PHY_BB_BBB_RX_CTRL_4_CHAN_AVG_SHORT_SET(x)                            (((x) << 25) & 0x7e000000)
-
-/* macros for BB_bbb_rx_ctrl_5 */
-#define PHY_BB_BBB_RX_CTRL_5_ADDRESS                                                          0x0000a220
-#define PHY_BB_BBB_RX_CTRL_5_OFFSET                                                           0x0000a220
-#define PHY_BB_BBB_RX_CTRL_5_LOOP_COEF_DPSK_C1_DATA_MSB                                                4
-#define PHY_BB_BBB_RX_CTRL_5_LOOP_COEF_DPSK_C1_DATA_LSB                                                0
-#define PHY_BB_BBB_RX_CTRL_5_LOOP_COEF_DPSK_C1_DATA_MASK                                      0x0000001f
-#define PHY_BB_BBB_RX_CTRL_5_LOOP_COEF_DPSK_C1_DATA_GET(x)                     (((x) & 0x0000001f) >> 0)
-#define PHY_BB_BBB_RX_CTRL_5_LOOP_COEF_DPSK_C1_DATA_SET(x)                     (((x) << 0) & 0x0000001f)
-#define PHY_BB_BBB_RX_CTRL_5_LOOP_COEF_DPSK_C1_HEAD_MSB                                                9
-#define PHY_BB_BBB_RX_CTRL_5_LOOP_COEF_DPSK_C1_HEAD_LSB                                                5
-#define PHY_BB_BBB_RX_CTRL_5_LOOP_COEF_DPSK_C1_HEAD_MASK                                      0x000003e0
-#define PHY_BB_BBB_RX_CTRL_5_LOOP_COEF_DPSK_C1_HEAD_GET(x)                     (((x) & 0x000003e0) >> 5)
-#define PHY_BB_BBB_RX_CTRL_5_LOOP_COEF_DPSK_C1_HEAD_SET(x)                     (((x) << 5) & 0x000003e0)
-#define PHY_BB_BBB_RX_CTRL_5_LOOP_COEF_DPSK_C2_HEAD_MSB                                               15
-#define PHY_BB_BBB_RX_CTRL_5_LOOP_COEF_DPSK_C2_HEAD_LSB                                               10
-#define PHY_BB_BBB_RX_CTRL_5_LOOP_COEF_DPSK_C2_HEAD_MASK                                      0x0000fc00
-#define PHY_BB_BBB_RX_CTRL_5_LOOP_COEF_DPSK_C2_HEAD_GET(x)                    (((x) & 0x0000fc00) >> 10)
-#define PHY_BB_BBB_RX_CTRL_5_LOOP_COEF_DPSK_C2_HEAD_SET(x)                    (((x) << 10) & 0x0000fc00)
-#define PHY_BB_BBB_RX_CTRL_5_LOOP_COEF_CCK_C1_MSB                                                     20
-#define PHY_BB_BBB_RX_CTRL_5_LOOP_COEF_CCK_C1_LSB                                                     16
-#define PHY_BB_BBB_RX_CTRL_5_LOOP_COEF_CCK_C1_MASK                                            0x001f0000
-#define PHY_BB_BBB_RX_CTRL_5_LOOP_COEF_CCK_C1_GET(x)                          (((x) & 0x001f0000) >> 16)
-#define PHY_BB_BBB_RX_CTRL_5_LOOP_COEF_CCK_C1_SET(x)                          (((x) << 16) & 0x001f0000)
-#define PHY_BB_BBB_RX_CTRL_5_LOOP_COEF_CCK_C2_MSB                                                     26
-#define PHY_BB_BBB_RX_CTRL_5_LOOP_COEF_CCK_C2_LSB                                                     21
-#define PHY_BB_BBB_RX_CTRL_5_LOOP_COEF_CCK_C2_MASK                                            0x07e00000
-#define PHY_BB_BBB_RX_CTRL_5_LOOP_COEF_CCK_C2_GET(x)                          (((x) & 0x07e00000) >> 21)
-#define PHY_BB_BBB_RX_CTRL_5_LOOP_COEF_CCK_C2_SET(x)                          (((x) << 21) & 0x07e00000)
-
-/* macros for BB_bbb_rx_ctrl_6 */
-#define PHY_BB_BBB_RX_CTRL_6_ADDRESS                                                          0x0000a224
-#define PHY_BB_BBB_RX_CTRL_6_OFFSET                                                           0x0000a224
-#define PHY_BB_BBB_RX_CTRL_6_SYNC_START_DELAY_MSB                                                      9
-#define PHY_BB_BBB_RX_CTRL_6_SYNC_START_DELAY_LSB                                                      0
-#define PHY_BB_BBB_RX_CTRL_6_SYNC_START_DELAY_MASK                                            0x000003ff
-#define PHY_BB_BBB_RX_CTRL_6_SYNC_START_DELAY_GET(x)                           (((x) & 0x000003ff) >> 0)
-#define PHY_BB_BBB_RX_CTRL_6_SYNC_START_DELAY_SET(x)                           (((x) << 0) & 0x000003ff)
-#define PHY_BB_BBB_RX_CTRL_6_MAP_1S_TO_2S_MSB                                                         10
-#define PHY_BB_BBB_RX_CTRL_6_MAP_1S_TO_2S_LSB                                                         10
-#define PHY_BB_BBB_RX_CTRL_6_MAP_1S_TO_2S_MASK                                                0x00000400
-#define PHY_BB_BBB_RX_CTRL_6_MAP_1S_TO_2S_GET(x)                              (((x) & 0x00000400) >> 10)
-#define PHY_BB_BBB_RX_CTRL_6_MAP_1S_TO_2S_SET(x)                              (((x) << 10) & 0x00000400)
-#define PHY_BB_BBB_RX_CTRL_6_START_IIR_DELAY_MSB                                                      20
-#define PHY_BB_BBB_RX_CTRL_6_START_IIR_DELAY_LSB                                                      11
-#define PHY_BB_BBB_RX_CTRL_6_START_IIR_DELAY_MASK                                             0x001ff800
-#define PHY_BB_BBB_RX_CTRL_6_START_IIR_DELAY_GET(x)                           (((x) & 0x001ff800) >> 11)
-#define PHY_BB_BBB_RX_CTRL_6_START_IIR_DELAY_SET(x)                           (((x) << 11) & 0x001ff800)
-
-/* macros for BB_bbb_dagc_ctrl */
-#define PHY_BB_BBB_DAGC_CTRL_ADDRESS                                                          0x0000a228
-#define PHY_BB_BBB_DAGC_CTRL_OFFSET                                                           0x0000a228
-#define PHY_BB_BBB_DAGC_CTRL_ENABLE_DAGC_CCK_MSB                                                       0
-#define PHY_BB_BBB_DAGC_CTRL_ENABLE_DAGC_CCK_LSB                                                       0
-#define PHY_BB_BBB_DAGC_CTRL_ENABLE_DAGC_CCK_MASK                                             0x00000001
-#define PHY_BB_BBB_DAGC_CTRL_ENABLE_DAGC_CCK_GET(x)                            (((x) & 0x00000001) >> 0)
-#define PHY_BB_BBB_DAGC_CTRL_ENABLE_DAGC_CCK_SET(x)                            (((x) << 0) & 0x00000001)
-#define PHY_BB_BBB_DAGC_CTRL_DAGC_TARGET_PWR_CCK_MSB                                                   8
-#define PHY_BB_BBB_DAGC_CTRL_DAGC_TARGET_PWR_CCK_LSB                                                   1
-#define PHY_BB_BBB_DAGC_CTRL_DAGC_TARGET_PWR_CCK_MASK                                         0x000001fe
-#define PHY_BB_BBB_DAGC_CTRL_DAGC_TARGET_PWR_CCK_GET(x)                        (((x) & 0x000001fe) >> 1)
-#define PHY_BB_BBB_DAGC_CTRL_DAGC_TARGET_PWR_CCK_SET(x)                        (((x) << 1) & 0x000001fe)
-#define PHY_BB_BBB_DAGC_CTRL_ENABLE_BARKER_RSSI_THR_MSB                                                9
-#define PHY_BB_BBB_DAGC_CTRL_ENABLE_BARKER_RSSI_THR_LSB                                                9
-#define PHY_BB_BBB_DAGC_CTRL_ENABLE_BARKER_RSSI_THR_MASK                                      0x00000200
-#define PHY_BB_BBB_DAGC_CTRL_ENABLE_BARKER_RSSI_THR_GET(x)                     (((x) & 0x00000200) >> 9)
-#define PHY_BB_BBB_DAGC_CTRL_ENABLE_BARKER_RSSI_THR_SET(x)                     (((x) << 9) & 0x00000200)
-#define PHY_BB_BBB_DAGC_CTRL_BARKER_RSSI_THR_MSB                                                      16
-#define PHY_BB_BBB_DAGC_CTRL_BARKER_RSSI_THR_LSB                                                      10
-#define PHY_BB_BBB_DAGC_CTRL_BARKER_RSSI_THR_MASK                                             0x0001fc00
-#define PHY_BB_BBB_DAGC_CTRL_BARKER_RSSI_THR_GET(x)                           (((x) & 0x0001fc00) >> 10)
-#define PHY_BB_BBB_DAGC_CTRL_BARKER_RSSI_THR_SET(x)                           (((x) << 10) & 0x0001fc00)
-#define PHY_BB_BBB_DAGC_CTRL_ENABLE_FIRSTEP_SEL_MSB                                                   17
-#define PHY_BB_BBB_DAGC_CTRL_ENABLE_FIRSTEP_SEL_LSB                                                   17
-#define PHY_BB_BBB_DAGC_CTRL_ENABLE_FIRSTEP_SEL_MASK                                          0x00020000
-#define PHY_BB_BBB_DAGC_CTRL_ENABLE_FIRSTEP_SEL_GET(x)                        (((x) & 0x00020000) >> 17)
-#define PHY_BB_BBB_DAGC_CTRL_ENABLE_FIRSTEP_SEL_SET(x)                        (((x) << 17) & 0x00020000)
-#define PHY_BB_BBB_DAGC_CTRL_FIRSTEP_2_MSB                                                            23
-#define PHY_BB_BBB_DAGC_CTRL_FIRSTEP_2_LSB                                                            18
-#define PHY_BB_BBB_DAGC_CTRL_FIRSTEP_2_MASK                                                   0x00fc0000
-#define PHY_BB_BBB_DAGC_CTRL_FIRSTEP_2_GET(x)                                 (((x) & 0x00fc0000) >> 18)
-#define PHY_BB_BBB_DAGC_CTRL_FIRSTEP_2_SET(x)                                 (((x) << 18) & 0x00fc0000)
-#define PHY_BB_BBB_DAGC_CTRL_FIRSTEP_COUNT_LGMAX_MSB                                                  27
-#define PHY_BB_BBB_DAGC_CTRL_FIRSTEP_COUNT_LGMAX_LSB                                                  24
-#define PHY_BB_BBB_DAGC_CTRL_FIRSTEP_COUNT_LGMAX_MASK                                         0x0f000000
-#define PHY_BB_BBB_DAGC_CTRL_FIRSTEP_COUNT_LGMAX_GET(x)                       (((x) & 0x0f000000) >> 24)
-#define PHY_BB_BBB_DAGC_CTRL_FIRSTEP_COUNT_LGMAX_SET(x)                       (((x) << 24) & 0x0f000000)
-
-/* macros for BB_force_clken_cck */
-#define PHY_BB_FORCE_CLKEN_CCK_ADDRESS                                                        0x0000a22c
-#define PHY_BB_FORCE_CLKEN_CCK_OFFSET                                                         0x0000a22c
-#define PHY_BB_FORCE_CLKEN_CCK_FORCE_RX_ENABLE0_MSB                                                    0
-#define PHY_BB_FORCE_CLKEN_CCK_FORCE_RX_ENABLE0_LSB                                                    0
-#define PHY_BB_FORCE_CLKEN_CCK_FORCE_RX_ENABLE0_MASK                                          0x00000001
-#define PHY_BB_FORCE_CLKEN_CCK_FORCE_RX_ENABLE0_GET(x)                         (((x) & 0x00000001) >> 0)
-#define PHY_BB_FORCE_CLKEN_CCK_FORCE_RX_ENABLE0_SET(x)                         (((x) << 0) & 0x00000001)
-#define PHY_BB_FORCE_CLKEN_CCK_FORCE_RX_ENABLE1_MSB                                                    1
-#define PHY_BB_FORCE_CLKEN_CCK_FORCE_RX_ENABLE1_LSB                                                    1
-#define PHY_BB_FORCE_CLKEN_CCK_FORCE_RX_ENABLE1_MASK                                          0x00000002
-#define PHY_BB_FORCE_CLKEN_CCK_FORCE_RX_ENABLE1_GET(x)                         (((x) & 0x00000002) >> 1)
-#define PHY_BB_FORCE_CLKEN_CCK_FORCE_RX_ENABLE1_SET(x)                         (((x) << 1) & 0x00000002)
-#define PHY_BB_FORCE_CLKEN_CCK_FORCE_RX_ENABLE2_MSB                                                    2
-#define PHY_BB_FORCE_CLKEN_CCK_FORCE_RX_ENABLE2_LSB                                                    2
-#define PHY_BB_FORCE_CLKEN_CCK_FORCE_RX_ENABLE2_MASK                                          0x00000004
-#define PHY_BB_FORCE_CLKEN_CCK_FORCE_RX_ENABLE2_GET(x)                         (((x) & 0x00000004) >> 2)
-#define PHY_BB_FORCE_CLKEN_CCK_FORCE_RX_ENABLE2_SET(x)                         (((x) << 2) & 0x00000004)
-#define PHY_BB_FORCE_CLKEN_CCK_FORCE_RX_ENABLE3_MSB                                                    3
-#define PHY_BB_FORCE_CLKEN_CCK_FORCE_RX_ENABLE3_LSB                                                    3
-#define PHY_BB_FORCE_CLKEN_CCK_FORCE_RX_ENABLE3_MASK                                          0x00000008
-#define PHY_BB_FORCE_CLKEN_CCK_FORCE_RX_ENABLE3_GET(x)                         (((x) & 0x00000008) >> 3)
-#define PHY_BB_FORCE_CLKEN_CCK_FORCE_RX_ENABLE3_SET(x)                         (((x) << 3) & 0x00000008)
-#define PHY_BB_FORCE_CLKEN_CCK_FORCE_RX_ALWAYS_MSB                                                     4
-#define PHY_BB_FORCE_CLKEN_CCK_FORCE_RX_ALWAYS_LSB                                                     4
-#define PHY_BB_FORCE_CLKEN_CCK_FORCE_RX_ALWAYS_MASK                                           0x00000010
-#define PHY_BB_FORCE_CLKEN_CCK_FORCE_RX_ALWAYS_GET(x)                          (((x) & 0x00000010) >> 4)
-#define PHY_BB_FORCE_CLKEN_CCK_FORCE_RX_ALWAYS_SET(x)                          (((x) << 4) & 0x00000010)
-#define PHY_BB_FORCE_CLKEN_CCK_FORCE_TXSM_CLKEN_MSB                                                    5
-#define PHY_BB_FORCE_CLKEN_CCK_FORCE_TXSM_CLKEN_LSB                                                    5
-#define PHY_BB_FORCE_CLKEN_CCK_FORCE_TXSM_CLKEN_MASK                                          0x00000020
-#define PHY_BB_FORCE_CLKEN_CCK_FORCE_TXSM_CLKEN_GET(x)                         (((x) & 0x00000020) >> 5)
-#define PHY_BB_FORCE_CLKEN_CCK_FORCE_TXSM_CLKEN_SET(x)                         (((x) << 5) & 0x00000020)
-
-/* macros for BB_rx_clear_delay */
-#define PHY_BB_RX_CLEAR_DELAY_ADDRESS                                                         0x0000a230
-#define PHY_BB_RX_CLEAR_DELAY_OFFSET                                                          0x0000a230
-#define PHY_BB_RX_CLEAR_DELAY_OFDM_XR_RX_CLEAR_DELAY_MSB                                               9
-#define PHY_BB_RX_CLEAR_DELAY_OFDM_XR_RX_CLEAR_DELAY_LSB                                               0
-#define PHY_BB_RX_CLEAR_DELAY_OFDM_XR_RX_CLEAR_DELAY_MASK                                     0x000003ff
-#define PHY_BB_RX_CLEAR_DELAY_OFDM_XR_RX_CLEAR_DELAY_GET(x)                    (((x) & 0x000003ff) >> 0)
-#define PHY_BB_RX_CLEAR_DELAY_OFDM_XR_RX_CLEAR_DELAY_SET(x)                    (((x) << 0) & 0x000003ff)
-
-/* macros for BB_powertx_rate3 */
-#define PHY_BB_POWERTX_RATE3_ADDRESS                                                          0x0000a234
-#define PHY_BB_POWERTX_RATE3_OFFSET                                                           0x0000a234
-#define PHY_BB_POWERTX_RATE3_POWERTX_1L_MSB                                                            5
-#define PHY_BB_POWERTX_RATE3_POWERTX_1L_LSB                                                            0
-#define PHY_BB_POWERTX_RATE3_POWERTX_1L_MASK                                                  0x0000003f
-#define PHY_BB_POWERTX_RATE3_POWERTX_1L_GET(x)                                 (((x) & 0x0000003f) >> 0)
-#define PHY_BB_POWERTX_RATE3_POWERTX_1L_SET(x)                                 (((x) << 0) & 0x0000003f)
-#define PHY_BB_POWERTX_RATE3_POWERTX_2L_MSB                                                           21
-#define PHY_BB_POWERTX_RATE3_POWERTX_2L_LSB                                                           16
-#define PHY_BB_POWERTX_RATE3_POWERTX_2L_MASK                                                  0x003f0000
-#define PHY_BB_POWERTX_RATE3_POWERTX_2L_GET(x)                                (((x) & 0x003f0000) >> 16)
-#define PHY_BB_POWERTX_RATE3_POWERTX_2L_SET(x)                                (((x) << 16) & 0x003f0000)
-#define PHY_BB_POWERTX_RATE3_POWERTX_2S_MSB                                                           29
-#define PHY_BB_POWERTX_RATE3_POWERTX_2S_LSB                                                           24
-#define PHY_BB_POWERTX_RATE3_POWERTX_2S_MASK                                                  0x3f000000
-#define PHY_BB_POWERTX_RATE3_POWERTX_2S_GET(x)                                (((x) & 0x3f000000) >> 24)
-#define PHY_BB_POWERTX_RATE3_POWERTX_2S_SET(x)                                (((x) << 24) & 0x3f000000)
-
-/* macros for BB_powertx_rate4 */
-#define PHY_BB_POWERTX_RATE4_ADDRESS                                                          0x0000a238
-#define PHY_BB_POWERTX_RATE4_OFFSET                                                           0x0000a238
-#define PHY_BB_POWERTX_RATE4_POWERTX_55L_MSB                                                           5
-#define PHY_BB_POWERTX_RATE4_POWERTX_55L_LSB                                                           0
-#define PHY_BB_POWERTX_RATE4_POWERTX_55L_MASK                                                 0x0000003f
-#define PHY_BB_POWERTX_RATE4_POWERTX_55L_GET(x)                                (((x) & 0x0000003f) >> 0)
-#define PHY_BB_POWERTX_RATE4_POWERTX_55L_SET(x)                                (((x) << 0) & 0x0000003f)
-#define PHY_BB_POWERTX_RATE4_POWERTX_55S_MSB                                                          13
-#define PHY_BB_POWERTX_RATE4_POWERTX_55S_LSB                                                           8
-#define PHY_BB_POWERTX_RATE4_POWERTX_55S_MASK                                                 0x00003f00
-#define PHY_BB_POWERTX_RATE4_POWERTX_55S_GET(x)                                (((x) & 0x00003f00) >> 8)
-#define PHY_BB_POWERTX_RATE4_POWERTX_55S_SET(x)                                (((x) << 8) & 0x00003f00)
-#define PHY_BB_POWERTX_RATE4_POWERTX_11L_MSB                                                          21
-#define PHY_BB_POWERTX_RATE4_POWERTX_11L_LSB                                                          16
-#define PHY_BB_POWERTX_RATE4_POWERTX_11L_MASK                                                 0x003f0000
-#define PHY_BB_POWERTX_RATE4_POWERTX_11L_GET(x)                               (((x) & 0x003f0000) >> 16)
-#define PHY_BB_POWERTX_RATE4_POWERTX_11L_SET(x)                               (((x) << 16) & 0x003f0000)
-#define PHY_BB_POWERTX_RATE4_POWERTX_11S_MSB                                                          29
-#define PHY_BB_POWERTX_RATE4_POWERTX_11S_LSB                                                          24
-#define PHY_BB_POWERTX_RATE4_POWERTX_11S_MASK                                                 0x3f000000
-#define PHY_BB_POWERTX_RATE4_POWERTX_11S_GET(x)                               (((x) & 0x3f000000) >> 24)
-#define PHY_BB_POWERTX_RATE4_POWERTX_11S_SET(x)                               (((x) << 24) & 0x3f000000)
-
-/* macros for BB_cck_spur_mit */
-#define PHY_BB_CCK_SPUR_MIT_ADDRESS                                                           0x0000a240
-#define PHY_BB_CCK_SPUR_MIT_OFFSET                                                            0x0000a240
-#define PHY_BB_CCK_SPUR_MIT_USE_CCK_SPUR_MIT_MSB                                                       0
-#define PHY_BB_CCK_SPUR_MIT_USE_CCK_SPUR_MIT_LSB                                                       0
-#define PHY_BB_CCK_SPUR_MIT_USE_CCK_SPUR_MIT_MASK                                             0x00000001
-#define PHY_BB_CCK_SPUR_MIT_USE_CCK_SPUR_MIT_GET(x)                            (((x) & 0x00000001) >> 0)
-#define PHY_BB_CCK_SPUR_MIT_USE_CCK_SPUR_MIT_SET(x)                            (((x) << 0) & 0x00000001)
-#define PHY_BB_CCK_SPUR_MIT_SPUR_RSSI_THR_MSB                                                          8
-#define PHY_BB_CCK_SPUR_MIT_SPUR_RSSI_THR_LSB                                                          1
-#define PHY_BB_CCK_SPUR_MIT_SPUR_RSSI_THR_MASK                                                0x000001fe
-#define PHY_BB_CCK_SPUR_MIT_SPUR_RSSI_THR_GET(x)                               (((x) & 0x000001fe) >> 1)
-#define PHY_BB_CCK_SPUR_MIT_SPUR_RSSI_THR_SET(x)                               (((x) << 1) & 0x000001fe)
-#define PHY_BB_CCK_SPUR_MIT_CCK_SPUR_FREQ_MSB                                                         28
-#define PHY_BB_CCK_SPUR_MIT_CCK_SPUR_FREQ_LSB                                                          9
-#define PHY_BB_CCK_SPUR_MIT_CCK_SPUR_FREQ_MASK                                                0x1ffffe00
-#define PHY_BB_CCK_SPUR_MIT_CCK_SPUR_FREQ_GET(x)                               (((x) & 0x1ffffe00) >> 9)
-#define PHY_BB_CCK_SPUR_MIT_CCK_SPUR_FREQ_SET(x)                               (((x) << 9) & 0x1ffffe00)
-#define PHY_BB_CCK_SPUR_MIT_SPUR_FILTER_TYPE_MSB                                                      30
-#define PHY_BB_CCK_SPUR_MIT_SPUR_FILTER_TYPE_LSB                                                      29
-#define PHY_BB_CCK_SPUR_MIT_SPUR_FILTER_TYPE_MASK                                             0x60000000
-#define PHY_BB_CCK_SPUR_MIT_SPUR_FILTER_TYPE_GET(x)                           (((x) & 0x60000000) >> 29)
-#define PHY_BB_CCK_SPUR_MIT_SPUR_FILTER_TYPE_SET(x)                           (((x) << 29) & 0x60000000)
-
-/* macros for BB_panic_watchdog_status */
-#define PHY_BB_PANIC_WATCHDOG_STATUS_ADDRESS                                                  0x0000a244
-#define PHY_BB_PANIC_WATCHDOG_STATUS_OFFSET                                                   0x0000a244
-#define PHY_BB_PANIC_WATCHDOG_STATUS_PANIC_WATCHDOG_STATUS_1_MSB                                       2
-#define PHY_BB_PANIC_WATCHDOG_STATUS_PANIC_WATCHDOG_STATUS_1_LSB                                       0
-#define PHY_BB_PANIC_WATCHDOG_STATUS_PANIC_WATCHDOG_STATUS_1_MASK                             0x00000007
-#define PHY_BB_PANIC_WATCHDOG_STATUS_PANIC_WATCHDOG_STATUS_1_GET(x)            (((x) & 0x00000007) >> 0)
-#define PHY_BB_PANIC_WATCHDOG_STATUS_PANIC_WATCHDOG_STATUS_1_SET(x)            (((x) << 0) & 0x00000007)
-#define PHY_BB_PANIC_WATCHDOG_STATUS_PANIC_WATCHDOG_DET_HANG_MSB                                       3
-#define PHY_BB_PANIC_WATCHDOG_STATUS_PANIC_WATCHDOG_DET_HANG_LSB                                       3
-#define PHY_BB_PANIC_WATCHDOG_STATUS_PANIC_WATCHDOG_DET_HANG_MASK                             0x00000008
-#define PHY_BB_PANIC_WATCHDOG_STATUS_PANIC_WATCHDOG_DET_HANG_GET(x)            (((x) & 0x00000008) >> 3)
-#define PHY_BB_PANIC_WATCHDOG_STATUS_PANIC_WATCHDOG_DET_HANG_SET(x)            (((x) << 3) & 0x00000008)
-#define PHY_BB_PANIC_WATCHDOG_STATUS_PANIC_WATCHDOG_STATUS_2_MSB                                       7
-#define PHY_BB_PANIC_WATCHDOG_STATUS_PANIC_WATCHDOG_STATUS_2_LSB                                       4
-#define PHY_BB_PANIC_WATCHDOG_STATUS_PANIC_WATCHDOG_STATUS_2_MASK                             0x000000f0
-#define PHY_BB_PANIC_WATCHDOG_STATUS_PANIC_WATCHDOG_STATUS_2_GET(x)            (((x) & 0x000000f0) >> 4)
-#define PHY_BB_PANIC_WATCHDOG_STATUS_PANIC_WATCHDOG_STATUS_2_SET(x)            (((x) << 4) & 0x000000f0)
-#define PHY_BB_PANIC_WATCHDOG_STATUS_PANIC_WATCHDOG_STATUS_3_MSB                                      11
-#define PHY_BB_PANIC_WATCHDOG_STATUS_PANIC_WATCHDOG_STATUS_3_LSB                                       8
-#define PHY_BB_PANIC_WATCHDOG_STATUS_PANIC_WATCHDOG_STATUS_3_MASK                             0x00000f00
-#define PHY_BB_PANIC_WATCHDOG_STATUS_PANIC_WATCHDOG_STATUS_3_GET(x)            (((x) & 0x00000f00) >> 8)
-#define PHY_BB_PANIC_WATCHDOG_STATUS_PANIC_WATCHDOG_STATUS_3_SET(x)            (((x) << 8) & 0x00000f00)
-#define PHY_BB_PANIC_WATCHDOG_STATUS_PANIC_WATCHDOG_STATUS_4_MSB                                      15
-#define PHY_BB_PANIC_WATCHDOG_STATUS_PANIC_WATCHDOG_STATUS_4_LSB                                      12
-#define PHY_BB_PANIC_WATCHDOG_STATUS_PANIC_WATCHDOG_STATUS_4_MASK                             0x0000f000
-#define PHY_BB_PANIC_WATCHDOG_STATUS_PANIC_WATCHDOG_STATUS_4_GET(x)           (((x) & 0x0000f000) >> 12)
-#define PHY_BB_PANIC_WATCHDOG_STATUS_PANIC_WATCHDOG_STATUS_4_SET(x)           (((x) << 12) & 0x0000f000)
-#define PHY_BB_PANIC_WATCHDOG_STATUS_PANIC_WATCHDOG_STATUS_5_MSB                                      19
-#define PHY_BB_PANIC_WATCHDOG_STATUS_PANIC_WATCHDOG_STATUS_5_LSB                                      16
-#define PHY_BB_PANIC_WATCHDOG_STATUS_PANIC_WATCHDOG_STATUS_5_MASK                             0x000f0000
-#define PHY_BB_PANIC_WATCHDOG_STATUS_PANIC_WATCHDOG_STATUS_5_GET(x)           (((x) & 0x000f0000) >> 16)
-#define PHY_BB_PANIC_WATCHDOG_STATUS_PANIC_WATCHDOG_STATUS_5_SET(x)           (((x) << 16) & 0x000f0000)
-#define PHY_BB_PANIC_WATCHDOG_STATUS_PANIC_WATCHDOG_STATUS_6_MSB                                      23
-#define PHY_BB_PANIC_WATCHDOG_STATUS_PANIC_WATCHDOG_STATUS_6_LSB                                      20
-#define PHY_BB_PANIC_WATCHDOG_STATUS_PANIC_WATCHDOG_STATUS_6_MASK                             0x00f00000
-#define PHY_BB_PANIC_WATCHDOG_STATUS_PANIC_WATCHDOG_STATUS_6_GET(x)           (((x) & 0x00f00000) >> 20)
-#define PHY_BB_PANIC_WATCHDOG_STATUS_PANIC_WATCHDOG_STATUS_6_SET(x)           (((x) << 20) & 0x00f00000)
-#define PHY_BB_PANIC_WATCHDOG_STATUS_PANIC_WATCHDOG_STATUS_7_MSB                                      27
-#define PHY_BB_PANIC_WATCHDOG_STATUS_PANIC_WATCHDOG_STATUS_7_LSB                                      24
-#define PHY_BB_PANIC_WATCHDOG_STATUS_PANIC_WATCHDOG_STATUS_7_MASK                             0x0f000000
-#define PHY_BB_PANIC_WATCHDOG_STATUS_PANIC_WATCHDOG_STATUS_7_GET(x)           (((x) & 0x0f000000) >> 24)
-#define PHY_BB_PANIC_WATCHDOG_STATUS_PANIC_WATCHDOG_STATUS_7_SET(x)           (((x) << 24) & 0x0f000000)
-#define PHY_BB_PANIC_WATCHDOG_STATUS_PANIC_WATCHDOG_STATUS_8_MSB                                      31
-#define PHY_BB_PANIC_WATCHDOG_STATUS_PANIC_WATCHDOG_STATUS_8_LSB                                      28
-#define PHY_BB_PANIC_WATCHDOG_STATUS_PANIC_WATCHDOG_STATUS_8_MASK                             0xf0000000
-#define PHY_BB_PANIC_WATCHDOG_STATUS_PANIC_WATCHDOG_STATUS_8_GET(x)           (((x) & 0xf0000000) >> 28)
-#define PHY_BB_PANIC_WATCHDOG_STATUS_PANIC_WATCHDOG_STATUS_8_SET(x)           (((x) << 28) & 0xf0000000)
-
-/* macros for BB_panic_watchdog_ctrl_1 */
-#define PHY_BB_PANIC_WATCHDOG_CTRL_1_ADDRESS                                                  0x0000a248
-#define PHY_BB_PANIC_WATCHDOG_CTRL_1_OFFSET                                                   0x0000a248
-#define PHY_BB_PANIC_WATCHDOG_CTRL_1_ENABLE_PANIC_WATCHDOG_NON_IDLE_MSB                                0
-#define PHY_BB_PANIC_WATCHDOG_CTRL_1_ENABLE_PANIC_WATCHDOG_NON_IDLE_LSB                                0
-#define PHY_BB_PANIC_WATCHDOG_CTRL_1_ENABLE_PANIC_WATCHDOG_NON_IDLE_MASK                      0x00000001
-#define PHY_BB_PANIC_WATCHDOG_CTRL_1_ENABLE_PANIC_WATCHDOG_NON_IDLE_GET(x)     (((x) & 0x00000001) >> 0)
-#define PHY_BB_PANIC_WATCHDOG_CTRL_1_ENABLE_PANIC_WATCHDOG_NON_IDLE_SET(x)     (((x) << 0) & 0x00000001)
-#define PHY_BB_PANIC_WATCHDOG_CTRL_1_ENABLE_PANIC_WATCHDOG_IDLE_MSB                                    1
-#define PHY_BB_PANIC_WATCHDOG_CTRL_1_ENABLE_PANIC_WATCHDOG_IDLE_LSB                                    1
-#define PHY_BB_PANIC_WATCHDOG_CTRL_1_ENABLE_PANIC_WATCHDOG_IDLE_MASK                          0x00000002
-#define PHY_BB_PANIC_WATCHDOG_CTRL_1_ENABLE_PANIC_WATCHDOG_IDLE_GET(x)         (((x) & 0x00000002) >> 1)
-#define PHY_BB_PANIC_WATCHDOG_CTRL_1_ENABLE_PANIC_WATCHDOG_IDLE_SET(x)         (((x) << 1) & 0x00000002)
-#define PHY_BB_PANIC_WATCHDOG_CTRL_1_PANIC_WATCHDOG_NON_IDLE_LIMIT_MSB                                15
-#define PHY_BB_PANIC_WATCHDOG_CTRL_1_PANIC_WATCHDOG_NON_IDLE_LIMIT_LSB                                 2
-#define PHY_BB_PANIC_WATCHDOG_CTRL_1_PANIC_WATCHDOG_NON_IDLE_LIMIT_MASK                       0x0000fffc
-#define PHY_BB_PANIC_WATCHDOG_CTRL_1_PANIC_WATCHDOG_NON_IDLE_LIMIT_GET(x)      (((x) & 0x0000fffc) >> 2)
-#define PHY_BB_PANIC_WATCHDOG_CTRL_1_PANIC_WATCHDOG_NON_IDLE_LIMIT_SET(x)      (((x) << 2) & 0x0000fffc)
-#define PHY_BB_PANIC_WATCHDOG_CTRL_1_PANIC_WATCHDOG_IDLE_LIMIT_MSB                                    31
-#define PHY_BB_PANIC_WATCHDOG_CTRL_1_PANIC_WATCHDOG_IDLE_LIMIT_LSB                                    16
-#define PHY_BB_PANIC_WATCHDOG_CTRL_1_PANIC_WATCHDOG_IDLE_LIMIT_MASK                           0xffff0000
-#define PHY_BB_PANIC_WATCHDOG_CTRL_1_PANIC_WATCHDOG_IDLE_LIMIT_GET(x)         (((x) & 0xffff0000) >> 16)
-#define PHY_BB_PANIC_WATCHDOG_CTRL_1_PANIC_WATCHDOG_IDLE_LIMIT_SET(x)         (((x) << 16) & 0xffff0000)
-
-/* macros for BB_panic_watchdog_ctrl_2 */
-#define PHY_BB_PANIC_WATCHDOG_CTRL_2_ADDRESS                                                  0x0000a24c
-#define PHY_BB_PANIC_WATCHDOG_CTRL_2_OFFSET                                                   0x0000a24c
-#define PHY_BB_PANIC_WATCHDOG_CTRL_2_FORCE_FAST_ADC_CLK_MSB                                            0
-#define PHY_BB_PANIC_WATCHDOG_CTRL_2_FORCE_FAST_ADC_CLK_LSB                                            0
-#define PHY_BB_PANIC_WATCHDOG_CTRL_2_FORCE_FAST_ADC_CLK_MASK                                  0x00000001
-#define PHY_BB_PANIC_WATCHDOG_CTRL_2_FORCE_FAST_ADC_CLK_GET(x)                 (((x) & 0x00000001) >> 0)
-#define PHY_BB_PANIC_WATCHDOG_CTRL_2_FORCE_FAST_ADC_CLK_SET(x)                 (((x) << 0) & 0x00000001)
-#define PHY_BB_PANIC_WATCHDOG_CTRL_2_PANIC_WATCHDOG_RESET_ENA_MSB                                      1
-#define PHY_BB_PANIC_WATCHDOG_CTRL_2_PANIC_WATCHDOG_RESET_ENA_LSB                                      1
-#define PHY_BB_PANIC_WATCHDOG_CTRL_2_PANIC_WATCHDOG_RESET_ENA_MASK                            0x00000002
-#define PHY_BB_PANIC_WATCHDOG_CTRL_2_PANIC_WATCHDOG_RESET_ENA_GET(x)           (((x) & 0x00000002) >> 1)
-#define PHY_BB_PANIC_WATCHDOG_CTRL_2_PANIC_WATCHDOG_RESET_ENA_SET(x)           (((x) << 1) & 0x00000002)
-#define PHY_BB_PANIC_WATCHDOG_CTRL_2_PANIC_WATCHDOG_IRQ_ENA_MSB                                        2
-#define PHY_BB_PANIC_WATCHDOG_CTRL_2_PANIC_WATCHDOG_IRQ_ENA_LSB                                        2
-#define PHY_BB_PANIC_WATCHDOG_CTRL_2_PANIC_WATCHDOG_IRQ_ENA_MASK                              0x00000004
-#define PHY_BB_PANIC_WATCHDOG_CTRL_2_PANIC_WATCHDOG_IRQ_ENA_GET(x)             (((x) & 0x00000004) >> 2)
-#define PHY_BB_PANIC_WATCHDOG_CTRL_2_PANIC_WATCHDOG_IRQ_ENA_SET(x)             (((x) << 2) & 0x00000004)
-
-/* macros for BB_iqcorr_ctrl_cck */
-#define PHY_BB_IQCORR_CTRL_CCK_ADDRESS                                                        0x0000a250
-#define PHY_BB_IQCORR_CTRL_CCK_OFFSET                                                         0x0000a250
-#define PHY_BB_IQCORR_CTRL_CCK_IQCORR_Q_Q_COFF_CCK_MSB                                                 4
-#define PHY_BB_IQCORR_CTRL_CCK_IQCORR_Q_Q_COFF_CCK_LSB                                                 0
-#define PHY_BB_IQCORR_CTRL_CCK_IQCORR_Q_Q_COFF_CCK_MASK                                       0x0000001f
-#define PHY_BB_IQCORR_CTRL_CCK_IQCORR_Q_Q_COFF_CCK_GET(x)                      (((x) & 0x0000001f) >> 0)
-#define PHY_BB_IQCORR_CTRL_CCK_IQCORR_Q_Q_COFF_CCK_SET(x)                      (((x) << 0) & 0x0000001f)
-#define PHY_BB_IQCORR_CTRL_CCK_IQCORR_Q_I_COFF_CCK_MSB                                                10
-#define PHY_BB_IQCORR_CTRL_CCK_IQCORR_Q_I_COFF_CCK_LSB                                                 5
-#define PHY_BB_IQCORR_CTRL_CCK_IQCORR_Q_I_COFF_CCK_MASK                                       0x000007e0
-#define PHY_BB_IQCORR_CTRL_CCK_IQCORR_Q_I_COFF_CCK_GET(x)                      (((x) & 0x000007e0) >> 5)
-#define PHY_BB_IQCORR_CTRL_CCK_IQCORR_Q_I_COFF_CCK_SET(x)                      (((x) << 5) & 0x000007e0)
-#define PHY_BB_IQCORR_CTRL_CCK_ENABLE_IQCORR_CCK_MSB                                                  11
-#define PHY_BB_IQCORR_CTRL_CCK_ENABLE_IQCORR_CCK_LSB                                                  11
-#define PHY_BB_IQCORR_CTRL_CCK_ENABLE_IQCORR_CCK_MASK                                         0x00000800
-#define PHY_BB_IQCORR_CTRL_CCK_ENABLE_IQCORR_CCK_GET(x)                       (((x) & 0x00000800) >> 11)
-#define PHY_BB_IQCORR_CTRL_CCK_ENABLE_IQCORR_CCK_SET(x)                       (((x) << 11) & 0x00000800)
-#define PHY_BB_IQCORR_CTRL_CCK_RXCAL_MEAS_TIME_SEL_MSB                                                13
-#define PHY_BB_IQCORR_CTRL_CCK_RXCAL_MEAS_TIME_SEL_LSB                                                12
-#define PHY_BB_IQCORR_CTRL_CCK_RXCAL_MEAS_TIME_SEL_MASK                                       0x00003000
-#define PHY_BB_IQCORR_CTRL_CCK_RXCAL_MEAS_TIME_SEL_GET(x)                     (((x) & 0x00003000) >> 12)
-#define PHY_BB_IQCORR_CTRL_CCK_RXCAL_MEAS_TIME_SEL_SET(x)                     (((x) << 12) & 0x00003000)
-#define PHY_BB_IQCORR_CTRL_CCK_CLCAL_MEAS_TIME_SEL_MSB                                                15
-#define PHY_BB_IQCORR_CTRL_CCK_CLCAL_MEAS_TIME_SEL_LSB                                                14
-#define PHY_BB_IQCORR_CTRL_CCK_CLCAL_MEAS_TIME_SEL_MASK                                       0x0000c000
-#define PHY_BB_IQCORR_CTRL_CCK_CLCAL_MEAS_TIME_SEL_GET(x)                     (((x) & 0x0000c000) >> 14)
-#define PHY_BB_IQCORR_CTRL_CCK_CLCAL_MEAS_TIME_SEL_SET(x)                     (((x) << 14) & 0x0000c000)
-#define PHY_BB_IQCORR_CTRL_CCK_CF_CLC_INIT_RFGAIN_MSB                                                 20
-#define PHY_BB_IQCORR_CTRL_CCK_CF_CLC_INIT_RFGAIN_LSB                                                 16
-#define PHY_BB_IQCORR_CTRL_CCK_CF_CLC_INIT_RFGAIN_MASK                                        0x001f0000
-#define PHY_BB_IQCORR_CTRL_CCK_CF_CLC_INIT_RFGAIN_GET(x)                      (((x) & 0x001f0000) >> 16)
-#define PHY_BB_IQCORR_CTRL_CCK_CF_CLC_INIT_RFGAIN_SET(x)                      (((x) << 16) & 0x001f0000)
-#define PHY_BB_IQCORR_CTRL_CCK_CF_CLC_PAL_MODE_MSB                                                    21
-#define PHY_BB_IQCORR_CTRL_CCK_CF_CLC_PAL_MODE_LSB                                                    21
-#define PHY_BB_IQCORR_CTRL_CCK_CF_CLC_PAL_MODE_MASK                                           0x00200000
-#define PHY_BB_IQCORR_CTRL_CCK_CF_CLC_PAL_MODE_GET(x)                         (((x) & 0x00200000) >> 21)
-#define PHY_BB_IQCORR_CTRL_CCK_CF_CLC_PAL_MODE_SET(x)                         (((x) << 21) & 0x00200000)
-
-/* macros for BB_bluetooth_cntl */
-#define PHY_BB_BLUETOOTH_CNTL_ADDRESS                                                         0x0000a254
-#define PHY_BB_BLUETOOTH_CNTL_OFFSET                                                          0x0000a254
-#define PHY_BB_BLUETOOTH_CNTL_BT_BREAK_CCK_EN_MSB                                                      0
-#define PHY_BB_BLUETOOTH_CNTL_BT_BREAK_CCK_EN_LSB                                                      0
-#define PHY_BB_BLUETOOTH_CNTL_BT_BREAK_CCK_EN_MASK                                            0x00000001
-#define PHY_BB_BLUETOOTH_CNTL_BT_BREAK_CCK_EN_GET(x)                           (((x) & 0x00000001) >> 0)
-#define PHY_BB_BLUETOOTH_CNTL_BT_BREAK_CCK_EN_SET(x)                           (((x) << 0) & 0x00000001)
-#define PHY_BB_BLUETOOTH_CNTL_BT_ANT_HALT_WLAN_MSB                                                     1
-#define PHY_BB_BLUETOOTH_CNTL_BT_ANT_HALT_WLAN_LSB                                                     1
-#define PHY_BB_BLUETOOTH_CNTL_BT_ANT_HALT_WLAN_MASK                                           0x00000002
-#define PHY_BB_BLUETOOTH_CNTL_BT_ANT_HALT_WLAN_GET(x)                          (((x) & 0x00000002) >> 1)
-#define PHY_BB_BLUETOOTH_CNTL_BT_ANT_HALT_WLAN_SET(x)                          (((x) << 1) & 0x00000002)
-
-/* macros for BB_tpc_1 */
-#define PHY_BB_TPC_1_ADDRESS                                                                  0x0000a258
-#define PHY_BB_TPC_1_OFFSET                                                                   0x0000a258
-#define PHY_BB_TPC_1_FORCE_DAC_GAIN_MSB                                                                0
-#define PHY_BB_TPC_1_FORCE_DAC_GAIN_LSB                                                                0
-#define PHY_BB_TPC_1_FORCE_DAC_GAIN_MASK                                                      0x00000001
-#define PHY_BB_TPC_1_FORCE_DAC_GAIN_GET(x)                                     (((x) & 0x00000001) >> 0)
-#define PHY_BB_TPC_1_FORCE_DAC_GAIN_SET(x)                                     (((x) << 0) & 0x00000001)
-#define PHY_BB_TPC_1_FORCED_DAC_GAIN_MSB                                                               5
-#define PHY_BB_TPC_1_FORCED_DAC_GAIN_LSB                                                               1
-#define PHY_BB_TPC_1_FORCED_DAC_GAIN_MASK                                                     0x0000003e
-#define PHY_BB_TPC_1_FORCED_DAC_GAIN_GET(x)                                    (((x) & 0x0000003e) >> 1)
-#define PHY_BB_TPC_1_FORCED_DAC_GAIN_SET(x)                                    (((x) << 1) & 0x0000003e)
-#define PHY_BB_TPC_1_PD_DC_OFFSET_TARGET_MSB                                                          13
-#define PHY_BB_TPC_1_PD_DC_OFFSET_TARGET_LSB                                                           6
-#define PHY_BB_TPC_1_PD_DC_OFFSET_TARGET_MASK                                                 0x00003fc0
-#define PHY_BB_TPC_1_PD_DC_OFFSET_TARGET_GET(x)                                (((x) & 0x00003fc0) >> 6)
-#define PHY_BB_TPC_1_PD_DC_OFFSET_TARGET_SET(x)                                (((x) << 6) & 0x00003fc0)
-#define PHY_BB_TPC_1_NUM_PD_GAIN_MSB                                                                  15
-#define PHY_BB_TPC_1_NUM_PD_GAIN_LSB                                                                  14
-#define PHY_BB_TPC_1_NUM_PD_GAIN_MASK                                                         0x0000c000
-#define PHY_BB_TPC_1_NUM_PD_GAIN_GET(x)                                       (((x) & 0x0000c000) >> 14)
-#define PHY_BB_TPC_1_NUM_PD_GAIN_SET(x)                                       (((x) << 14) & 0x0000c000)
-#define PHY_BB_TPC_1_PD_GAIN_SETTING1_MSB                                                             17
-#define PHY_BB_TPC_1_PD_GAIN_SETTING1_LSB                                                             16
-#define PHY_BB_TPC_1_PD_GAIN_SETTING1_MASK                                                    0x00030000
-#define PHY_BB_TPC_1_PD_GAIN_SETTING1_GET(x)                                  (((x) & 0x00030000) >> 16)
-#define PHY_BB_TPC_1_PD_GAIN_SETTING1_SET(x)                                  (((x) << 16) & 0x00030000)
-#define PHY_BB_TPC_1_PD_GAIN_SETTING2_MSB                                                             19
-#define PHY_BB_TPC_1_PD_GAIN_SETTING2_LSB                                                             18
-#define PHY_BB_TPC_1_PD_GAIN_SETTING2_MASK                                                    0x000c0000
-#define PHY_BB_TPC_1_PD_GAIN_SETTING2_GET(x)                                  (((x) & 0x000c0000) >> 18)
-#define PHY_BB_TPC_1_PD_GAIN_SETTING2_SET(x)                                  (((x) << 18) & 0x000c0000)
-#define PHY_BB_TPC_1_PD_GAIN_SETTING3_MSB                                                             21
-#define PHY_BB_TPC_1_PD_GAIN_SETTING3_LSB                                                             20
-#define PHY_BB_TPC_1_PD_GAIN_SETTING3_MASK                                                    0x00300000
-#define PHY_BB_TPC_1_PD_GAIN_SETTING3_GET(x)                                  (((x) & 0x00300000) >> 20)
-#define PHY_BB_TPC_1_PD_GAIN_SETTING3_SET(x)                                  (((x) << 20) & 0x00300000)
-#define PHY_BB_TPC_1_ENABLE_PD_CALIBRATE_MSB                                                          22
-#define PHY_BB_TPC_1_ENABLE_PD_CALIBRATE_LSB                                                          22
-#define PHY_BB_TPC_1_ENABLE_PD_CALIBRATE_MASK                                                 0x00400000
-#define PHY_BB_TPC_1_ENABLE_PD_CALIBRATE_GET(x)                               (((x) & 0x00400000) >> 22)
-#define PHY_BB_TPC_1_ENABLE_PD_CALIBRATE_SET(x)                               (((x) << 22) & 0x00400000)
-#define PHY_BB_TPC_1_PD_CALIBRATE_WAIT_MSB                                                            28
-#define PHY_BB_TPC_1_PD_CALIBRATE_WAIT_LSB                                                            23
-#define PHY_BB_TPC_1_PD_CALIBRATE_WAIT_MASK                                                   0x1f800000
-#define PHY_BB_TPC_1_PD_CALIBRATE_WAIT_GET(x)                                 (((x) & 0x1f800000) >> 23)
-#define PHY_BB_TPC_1_PD_CALIBRATE_WAIT_SET(x)                                 (((x) << 23) & 0x1f800000)
-#define PHY_BB_TPC_1_FORCE_PDADC_GAIN_MSB                                                             29
-#define PHY_BB_TPC_1_FORCE_PDADC_GAIN_LSB                                                             29
-#define PHY_BB_TPC_1_FORCE_PDADC_GAIN_MASK                                                    0x20000000
-#define PHY_BB_TPC_1_FORCE_PDADC_GAIN_GET(x)                                  (((x) & 0x20000000) >> 29)
-#define PHY_BB_TPC_1_FORCE_PDADC_GAIN_SET(x)                                  (((x) << 29) & 0x20000000)
-#define PHY_BB_TPC_1_FORCED_PDADC_GAIN_MSB                                                            31
-#define PHY_BB_TPC_1_FORCED_PDADC_GAIN_LSB                                                            30
-#define PHY_BB_TPC_1_FORCED_PDADC_GAIN_MASK                                                   0xc0000000
-#define PHY_BB_TPC_1_FORCED_PDADC_GAIN_GET(x)                                 (((x) & 0xc0000000) >> 30)
-#define PHY_BB_TPC_1_FORCED_PDADC_GAIN_SET(x)                                 (((x) << 30) & 0xc0000000)
-
-/* macros for BB_tpc_2 */
-#define PHY_BB_TPC_2_ADDRESS                                                                  0x0000a25c
-#define PHY_BB_TPC_2_OFFSET                                                                   0x0000a25c
-#define PHY_BB_TPC_2_TX_FRAME_TO_PDADC_ON_MSB                                                          7
-#define PHY_BB_TPC_2_TX_FRAME_TO_PDADC_ON_LSB                                                          0
-#define PHY_BB_TPC_2_TX_FRAME_TO_PDADC_ON_MASK                                                0x000000ff
-#define PHY_BB_TPC_2_TX_FRAME_TO_PDADC_ON_GET(x)                               (((x) & 0x000000ff) >> 0)
-#define PHY_BB_TPC_2_TX_FRAME_TO_PDADC_ON_SET(x)                               (((x) << 0) & 0x000000ff)
-#define PHY_BB_TPC_2_TX_FRAME_TO_PD_ACC_OFDM_MSB                                                      15
-#define PHY_BB_TPC_2_TX_FRAME_TO_PD_ACC_OFDM_LSB                                                       8
-#define PHY_BB_TPC_2_TX_FRAME_TO_PD_ACC_OFDM_MASK                                             0x0000ff00
-#define PHY_BB_TPC_2_TX_FRAME_TO_PD_ACC_OFDM_GET(x)                            (((x) & 0x0000ff00) >> 8)
-#define PHY_BB_TPC_2_TX_FRAME_TO_PD_ACC_OFDM_SET(x)                            (((x) << 8) & 0x0000ff00)
-#define PHY_BB_TPC_2_TX_FRAME_TO_PD_ACC_CCK_MSB                                                       23
-#define PHY_BB_TPC_2_TX_FRAME_TO_PD_ACC_CCK_LSB                                                       16
-#define PHY_BB_TPC_2_TX_FRAME_TO_PD_ACC_CCK_MASK                                              0x00ff0000
-#define PHY_BB_TPC_2_TX_FRAME_TO_PD_ACC_CCK_GET(x)                            (((x) & 0x00ff0000) >> 16)
-#define PHY_BB_TPC_2_TX_FRAME_TO_PD_ACC_CCK_SET(x)                            (((x) << 16) & 0x00ff0000)
-
-/* macros for BB_tpc_3 */
-#define PHY_BB_TPC_3_ADDRESS                                                                  0x0000a260
-#define PHY_BB_TPC_3_OFFSET                                                                   0x0000a260
-#define PHY_BB_TPC_3_TX_END_TO_PDADC_ON_MSB                                                            7
-#define PHY_BB_TPC_3_TX_END_TO_PDADC_ON_LSB                                                            0
-#define PHY_BB_TPC_3_TX_END_TO_PDADC_ON_MASK                                                  0x000000ff
-#define PHY_BB_TPC_3_TX_END_TO_PDADC_ON_GET(x)                                 (((x) & 0x000000ff) >> 0)
-#define PHY_BB_TPC_3_TX_END_TO_PDADC_ON_SET(x)                                 (((x) << 0) & 0x000000ff)
-#define PHY_BB_TPC_3_TX_END_TO_PD_ACC_ON_MSB                                                          15
-#define PHY_BB_TPC_3_TX_END_TO_PD_ACC_ON_LSB                                                           8
-#define PHY_BB_TPC_3_TX_END_TO_PD_ACC_ON_MASK                                                 0x0000ff00
-#define PHY_BB_TPC_3_TX_END_TO_PD_ACC_ON_GET(x)                                (((x) & 0x0000ff00) >> 8)
-#define PHY_BB_TPC_3_TX_END_TO_PD_ACC_ON_SET(x)                                (((x) << 8) & 0x0000ff00)
-#define PHY_BB_TPC_3_PD_ACC_WINDOW_DC_OFF_MSB                                                         18
-#define PHY_BB_TPC_3_PD_ACC_WINDOW_DC_OFF_LSB                                                         16
-#define PHY_BB_TPC_3_PD_ACC_WINDOW_DC_OFF_MASK                                                0x00070000
-#define PHY_BB_TPC_3_PD_ACC_WINDOW_DC_OFF_GET(x)                              (((x) & 0x00070000) >> 16)
-#define PHY_BB_TPC_3_PD_ACC_WINDOW_DC_OFF_SET(x)                              (((x) << 16) & 0x00070000)
-#define PHY_BB_TPC_3_PD_ACC_WINDOW_CAL_MSB                                                            21
-#define PHY_BB_TPC_3_PD_ACC_WINDOW_CAL_LSB                                                            19
-#define PHY_BB_TPC_3_PD_ACC_WINDOW_CAL_MASK                                                   0x00380000
-#define PHY_BB_TPC_3_PD_ACC_WINDOW_CAL_GET(x)                                 (((x) & 0x00380000) >> 19)
-#define PHY_BB_TPC_3_PD_ACC_WINDOW_CAL_SET(x)                                 (((x) << 19) & 0x00380000)
-#define PHY_BB_TPC_3_PD_ACC_WINDOW_OFDM_MSB                                                           24
-#define PHY_BB_TPC_3_PD_ACC_WINDOW_OFDM_LSB                                                           22
-#define PHY_BB_TPC_3_PD_ACC_WINDOW_OFDM_MASK                                                  0x01c00000
-#define PHY_BB_TPC_3_PD_ACC_WINDOW_OFDM_GET(x)                                (((x) & 0x01c00000) >> 22)
-#define PHY_BB_TPC_3_PD_ACC_WINDOW_OFDM_SET(x)                                (((x) << 22) & 0x01c00000)
-#define PHY_BB_TPC_3_PD_ACC_WINDOW_CCK_MSB                                                            27
-#define PHY_BB_TPC_3_PD_ACC_WINDOW_CCK_LSB                                                            25
-#define PHY_BB_TPC_3_PD_ACC_WINDOW_CCK_MASK                                                   0x0e000000
-#define PHY_BB_TPC_3_PD_ACC_WINDOW_CCK_GET(x)                                 (((x) & 0x0e000000) >> 25)
-#define PHY_BB_TPC_3_PD_ACC_WINDOW_CCK_SET(x)                                 (((x) << 25) & 0x0e000000)
-#define PHY_BB_TPC_3_TPC_CLK_GATE_ENABLE_MSB                                                          31
-#define PHY_BB_TPC_3_TPC_CLK_GATE_ENABLE_LSB                                                          31
-#define PHY_BB_TPC_3_TPC_CLK_GATE_ENABLE_MASK                                                 0x80000000
-#define PHY_BB_TPC_3_TPC_CLK_GATE_ENABLE_GET(x)                               (((x) & 0x80000000) >> 31)
-#define PHY_BB_TPC_3_TPC_CLK_GATE_ENABLE_SET(x)                               (((x) << 31) & 0x80000000)
-
-/* macros for BB_tpc_4_b0 */
-#define PHY_BB_TPC_4_B0_ADDRESS                                                               0x0000a264
-#define PHY_BB_TPC_4_B0_OFFSET                                                                0x0000a264
-#define PHY_BB_TPC_4_B0_PD_AVG_VALID_0_MSB                                                             0
-#define PHY_BB_TPC_4_B0_PD_AVG_VALID_0_LSB                                                             0
-#define PHY_BB_TPC_4_B0_PD_AVG_VALID_0_MASK                                                   0x00000001
-#define PHY_BB_TPC_4_B0_PD_AVG_VALID_0_GET(x)                                  (((x) & 0x00000001) >> 0)
-#define PHY_BB_TPC_4_B0_PD_AVG_OUT_0_MSB                                                               8
-#define PHY_BB_TPC_4_B0_PD_AVG_OUT_0_LSB                                                               1
-#define PHY_BB_TPC_4_B0_PD_AVG_OUT_0_MASK                                                     0x000001fe
-#define PHY_BB_TPC_4_B0_PD_AVG_OUT_0_GET(x)                                    (((x) & 0x000001fe) >> 1)
-#define PHY_BB_TPC_4_B0_DAC_GAIN_0_MSB                                                                13
-#define PHY_BB_TPC_4_B0_DAC_GAIN_0_LSB                                                                 9
-#define PHY_BB_TPC_4_B0_DAC_GAIN_0_MASK                                                       0x00003e00
-#define PHY_BB_TPC_4_B0_DAC_GAIN_0_GET(x)                                      (((x) & 0x00003e00) >> 9)
-#define PHY_BB_TPC_4_B0_TX_GAIN_SETTING_0_MSB                                                         19
-#define PHY_BB_TPC_4_B0_TX_GAIN_SETTING_0_LSB                                                         14
-#define PHY_BB_TPC_4_B0_TX_GAIN_SETTING_0_MASK                                                0x000fc000
-#define PHY_BB_TPC_4_B0_TX_GAIN_SETTING_0_GET(x)                              (((x) & 0x000fc000) >> 14)
-#define PHY_BB_TPC_4_B0_RATE_SENT_0_MSB                                                               24
-#define PHY_BB_TPC_4_B0_RATE_SENT_0_LSB                                                               20
-#define PHY_BB_TPC_4_B0_RATE_SENT_0_MASK                                                      0x01f00000
-#define PHY_BB_TPC_4_B0_RATE_SENT_0_GET(x)                                    (((x) & 0x01f00000) >> 20)
-#define PHY_BB_TPC_4_B0_ERROR_EST_UPDATE_POWER_THRESH_MSB                                             30
-#define PHY_BB_TPC_4_B0_ERROR_EST_UPDATE_POWER_THRESH_LSB                                             25
-#define PHY_BB_TPC_4_B0_ERROR_EST_UPDATE_POWER_THRESH_MASK                                    0x7e000000
-#define PHY_BB_TPC_4_B0_ERROR_EST_UPDATE_POWER_THRESH_GET(x)                  (((x) & 0x7e000000) >> 25)
-#define PHY_BB_TPC_4_B0_ERROR_EST_UPDATE_POWER_THRESH_SET(x)                  (((x) << 25) & 0x7e000000)
-
-/* macros for BB_analog_swap */
-#define PHY_BB_ANALOG_SWAP_ADDRESS                                                            0x0000a268
-#define PHY_BB_ANALOG_SWAP_OFFSET                                                             0x0000a268
-#define PHY_BB_ANALOG_SWAP_ANALOG_RX_SWAP_CNTL_MSB                                                     2
-#define PHY_BB_ANALOG_SWAP_ANALOG_RX_SWAP_CNTL_LSB                                                     0
-#define PHY_BB_ANALOG_SWAP_ANALOG_RX_SWAP_CNTL_MASK                                           0x00000007
-#define PHY_BB_ANALOG_SWAP_ANALOG_RX_SWAP_CNTL_GET(x)                          (((x) & 0x00000007) >> 0)
-#define PHY_BB_ANALOG_SWAP_ANALOG_RX_SWAP_CNTL_SET(x)                          (((x) << 0) & 0x00000007)
-#define PHY_BB_ANALOG_SWAP_ANALOG_TX_SWAP_CNTL_MSB                                                     5
-#define PHY_BB_ANALOG_SWAP_ANALOG_TX_SWAP_CNTL_LSB                                                     3
-#define PHY_BB_ANALOG_SWAP_ANALOG_TX_SWAP_CNTL_MASK                                           0x00000038
-#define PHY_BB_ANALOG_SWAP_ANALOG_TX_SWAP_CNTL_GET(x)                          (((x) & 0x00000038) >> 3)
-#define PHY_BB_ANALOG_SWAP_ANALOG_TX_SWAP_CNTL_SET(x)                          (((x) << 3) & 0x00000038)
-#define PHY_BB_ANALOG_SWAP_SWAP_ALT_CHN_MSB                                                            6
-#define PHY_BB_ANALOG_SWAP_SWAP_ALT_CHN_LSB                                                            6
-#define PHY_BB_ANALOG_SWAP_SWAP_ALT_CHN_MASK                                                  0x00000040
-#define PHY_BB_ANALOG_SWAP_SWAP_ALT_CHN_GET(x)                                 (((x) & 0x00000040) >> 6)
-#define PHY_BB_ANALOG_SWAP_SWAP_ALT_CHN_SET(x)                                 (((x) << 6) & 0x00000040)
-#define PHY_BB_ANALOG_SWAP_ANALOG_DC_DAC_POLARITY_MSB                                                  7
-#define PHY_BB_ANALOG_SWAP_ANALOG_DC_DAC_POLARITY_LSB                                                  7
-#define PHY_BB_ANALOG_SWAP_ANALOG_DC_DAC_POLARITY_MASK                                        0x00000080
-#define PHY_BB_ANALOG_SWAP_ANALOG_DC_DAC_POLARITY_GET(x)                       (((x) & 0x00000080) >> 7)
-#define PHY_BB_ANALOG_SWAP_ANALOG_DC_DAC_POLARITY_SET(x)                       (((x) << 7) & 0x00000080)
-#define PHY_BB_ANALOG_SWAP_ANALOG_PKDET_DAC_POLARITY_MSB                                               8
-#define PHY_BB_ANALOG_SWAP_ANALOG_PKDET_DAC_POLARITY_LSB                                               8
-#define PHY_BB_ANALOG_SWAP_ANALOG_PKDET_DAC_POLARITY_MASK                                     0x00000100
-#define PHY_BB_ANALOG_SWAP_ANALOG_PKDET_DAC_POLARITY_GET(x)                    (((x) & 0x00000100) >> 8)
-#define PHY_BB_ANALOG_SWAP_ANALOG_PKDET_DAC_POLARITY_SET(x)                    (((x) << 8) & 0x00000100)
-
-/* macros for BB_tpc_5_b0 */
-#define PHY_BB_TPC_5_B0_ADDRESS                                                               0x0000a26c
-#define PHY_BB_TPC_5_B0_OFFSET                                                                0x0000a26c
-#define PHY_BB_TPC_5_B0_PD_GAIN_OVERLAP_MSB                                                            3
-#define PHY_BB_TPC_5_B0_PD_GAIN_OVERLAP_LSB                                                            0
-#define PHY_BB_TPC_5_B0_PD_GAIN_OVERLAP_MASK                                                  0x0000000f
-#define PHY_BB_TPC_5_B0_PD_GAIN_OVERLAP_GET(x)                                 (((x) & 0x0000000f) >> 0)
-#define PHY_BB_TPC_5_B0_PD_GAIN_OVERLAP_SET(x)                                 (((x) << 0) & 0x0000000f)
-#define PHY_BB_TPC_5_B0_PD_GAIN_BOUNDARY_1_0_MSB                                                       9
-#define PHY_BB_TPC_5_B0_PD_GAIN_BOUNDARY_1_0_LSB                                                       4
-#define PHY_BB_TPC_5_B0_PD_GAIN_BOUNDARY_1_0_MASK                                             0x000003f0
-#define PHY_BB_TPC_5_B0_PD_GAIN_BOUNDARY_1_0_GET(x)                            (((x) & 0x000003f0) >> 4)
-#define PHY_BB_TPC_5_B0_PD_GAIN_BOUNDARY_1_0_SET(x)                            (((x) << 4) & 0x000003f0)
-#define PHY_BB_TPC_5_B0_PD_GAIN_BOUNDARY_2_0_MSB                                                      15
-#define PHY_BB_TPC_5_B0_PD_GAIN_BOUNDARY_2_0_LSB                                                      10
-#define PHY_BB_TPC_5_B0_PD_GAIN_BOUNDARY_2_0_MASK                                             0x0000fc00
-#define PHY_BB_TPC_5_B0_PD_GAIN_BOUNDARY_2_0_GET(x)                           (((x) & 0x0000fc00) >> 10)
-#define PHY_BB_TPC_5_B0_PD_GAIN_BOUNDARY_2_0_SET(x)                           (((x) << 10) & 0x0000fc00)
-#define PHY_BB_TPC_5_B0_PD_GAIN_BOUNDARY_3_0_MSB                                                      21
-#define PHY_BB_TPC_5_B0_PD_GAIN_BOUNDARY_3_0_LSB                                                      16
-#define PHY_BB_TPC_5_B0_PD_GAIN_BOUNDARY_3_0_MASK                                             0x003f0000
-#define PHY_BB_TPC_5_B0_PD_GAIN_BOUNDARY_3_0_GET(x)                           (((x) & 0x003f0000) >> 16)
-#define PHY_BB_TPC_5_B0_PD_GAIN_BOUNDARY_3_0_SET(x)                           (((x) << 16) & 0x003f0000)
-#define PHY_BB_TPC_5_B0_PD_GAIN_BOUNDARY_4_0_MSB                                                      27
-#define PHY_BB_TPC_5_B0_PD_GAIN_BOUNDARY_4_0_LSB                                                      22
-#define PHY_BB_TPC_5_B0_PD_GAIN_BOUNDARY_4_0_MASK                                             0x0fc00000
-#define PHY_BB_TPC_5_B0_PD_GAIN_BOUNDARY_4_0_GET(x)                           (((x) & 0x0fc00000) >> 22)
-#define PHY_BB_TPC_5_B0_PD_GAIN_BOUNDARY_4_0_SET(x)                           (((x) << 22) & 0x0fc00000)
-
-/* macros for BB_tpc_6_b0 */
-#define PHY_BB_TPC_6_B0_ADDRESS                                                               0x0000a270
-#define PHY_BB_TPC_6_B0_OFFSET                                                                0x0000a270
-#define PHY_BB_TPC_6_B0_PD_DAC_SETTING_1_0_MSB                                                         5
-#define PHY_BB_TPC_6_B0_PD_DAC_SETTING_1_0_LSB                                                         0
-#define PHY_BB_TPC_6_B0_PD_DAC_SETTING_1_0_MASK                                               0x0000003f
-#define PHY_BB_TPC_6_B0_PD_DAC_SETTING_1_0_GET(x)                              (((x) & 0x0000003f) >> 0)
-#define PHY_BB_TPC_6_B0_PD_DAC_SETTING_1_0_SET(x)                              (((x) << 0) & 0x0000003f)
-#define PHY_BB_TPC_6_B0_PD_DAC_SETTING_2_0_MSB                                                        11
-#define PHY_BB_TPC_6_B0_PD_DAC_SETTING_2_0_LSB                                                         6
-#define PHY_BB_TPC_6_B0_PD_DAC_SETTING_2_0_MASK                                               0x00000fc0
-#define PHY_BB_TPC_6_B0_PD_DAC_SETTING_2_0_GET(x)                              (((x) & 0x00000fc0) >> 6)
-#define PHY_BB_TPC_6_B0_PD_DAC_SETTING_2_0_SET(x)                              (((x) << 6) & 0x00000fc0)
-#define PHY_BB_TPC_6_B0_PD_DAC_SETTING_3_0_MSB                                                        17
-#define PHY_BB_TPC_6_B0_PD_DAC_SETTING_3_0_LSB                                                        12
-#define PHY_BB_TPC_6_B0_PD_DAC_SETTING_3_0_MASK                                               0x0003f000
-#define PHY_BB_TPC_6_B0_PD_DAC_SETTING_3_0_GET(x)                             (((x) & 0x0003f000) >> 12)
-#define PHY_BB_TPC_6_B0_PD_DAC_SETTING_3_0_SET(x)                             (((x) << 12) & 0x0003f000)
-#define PHY_BB_TPC_6_B0_PD_DAC_SETTING_4_0_MSB                                                        23
-#define PHY_BB_TPC_6_B0_PD_DAC_SETTING_4_0_LSB                                                        18
-#define PHY_BB_TPC_6_B0_PD_DAC_SETTING_4_0_MASK                                               0x00fc0000
-#define PHY_BB_TPC_6_B0_PD_DAC_SETTING_4_0_GET(x)                             (((x) & 0x00fc0000) >> 18)
-#define PHY_BB_TPC_6_B0_PD_DAC_SETTING_4_0_SET(x)                             (((x) << 18) & 0x00fc0000)
-#define PHY_BB_TPC_6_B0_ERROR_EST_MODE_MSB                                                            25
-#define PHY_BB_TPC_6_B0_ERROR_EST_MODE_LSB                                                            24
-#define PHY_BB_TPC_6_B0_ERROR_EST_MODE_MASK                                                   0x03000000
-#define PHY_BB_TPC_6_B0_ERROR_EST_MODE_GET(x)                                 (((x) & 0x03000000) >> 24)
-#define PHY_BB_TPC_6_B0_ERROR_EST_MODE_SET(x)                                 (((x) << 24) & 0x03000000)
-#define PHY_BB_TPC_6_B0_ERROR_EST_FILTER_COEFF_MSB                                                    28
-#define PHY_BB_TPC_6_B0_ERROR_EST_FILTER_COEFF_LSB                                                    26
-#define PHY_BB_TPC_6_B0_ERROR_EST_FILTER_COEFF_MASK                                           0x1c000000
-#define PHY_BB_TPC_6_B0_ERROR_EST_FILTER_COEFF_GET(x)                         (((x) & 0x1c000000) >> 26)
-#define PHY_BB_TPC_6_B0_ERROR_EST_FILTER_COEFF_SET(x)                         (((x) << 26) & 0x1c000000)
-
-/* macros for BB_tpc_7 */
-#define PHY_BB_TPC_7_ADDRESS                                                                  0x0000a274
-#define PHY_BB_TPC_7_OFFSET                                                                   0x0000a274
-#define PHY_BB_TPC_7_TX_GAIN_TABLE_MAX_MSB                                                             5
-#define PHY_BB_TPC_7_TX_GAIN_TABLE_MAX_LSB                                                             0
-#define PHY_BB_TPC_7_TX_GAIN_TABLE_MAX_MASK                                                   0x0000003f
-#define PHY_BB_TPC_7_TX_GAIN_TABLE_MAX_GET(x)                                  (((x) & 0x0000003f) >> 0)
-#define PHY_BB_TPC_7_TX_GAIN_TABLE_MAX_SET(x)                                  (((x) << 0) & 0x0000003f)
-#define PHY_BB_TPC_7_INIT_TX_GAIN_SETTING_MSB                                                         11
-#define PHY_BB_TPC_7_INIT_TX_GAIN_SETTING_LSB                                                          6
-#define PHY_BB_TPC_7_INIT_TX_GAIN_SETTING_MASK                                                0x00000fc0
-#define PHY_BB_TPC_7_INIT_TX_GAIN_SETTING_GET(x)                               (((x) & 0x00000fc0) >> 6)
-#define PHY_BB_TPC_7_INIT_TX_GAIN_SETTING_SET(x)                               (((x) << 6) & 0x00000fc0)
-#define PHY_BB_TPC_7_EN_CL_GAIN_MOD_MSB                                                               12
-#define PHY_BB_TPC_7_EN_CL_GAIN_MOD_LSB                                                               12
-#define PHY_BB_TPC_7_EN_CL_GAIN_MOD_MASK                                                      0x00001000
-#define PHY_BB_TPC_7_EN_CL_GAIN_MOD_GET(x)                                    (((x) & 0x00001000) >> 12)
-#define PHY_BB_TPC_7_EN_CL_GAIN_MOD_SET(x)                                    (((x) << 12) & 0x00001000)
-#define PHY_BB_TPC_7_USE_TX_PD_IN_XPA_MSB                                                             13
-#define PHY_BB_TPC_7_USE_TX_PD_IN_XPA_LSB                                                             13
-#define PHY_BB_TPC_7_USE_TX_PD_IN_XPA_MASK                                                    0x00002000
-#define PHY_BB_TPC_7_USE_TX_PD_IN_XPA_GET(x)                                  (((x) & 0x00002000) >> 13)
-#define PHY_BB_TPC_7_USE_TX_PD_IN_XPA_SET(x)                                  (((x) << 13) & 0x00002000)
-#define PHY_BB_TPC_7_EXTEND_TX_FRAME_FOR_TPC_MSB                                                      14
-#define PHY_BB_TPC_7_EXTEND_TX_FRAME_FOR_TPC_LSB                                                      14
-#define PHY_BB_TPC_7_EXTEND_TX_FRAME_FOR_TPC_MASK                                             0x00004000
-#define PHY_BB_TPC_7_EXTEND_TX_FRAME_FOR_TPC_GET(x)                           (((x) & 0x00004000) >> 14)
-#define PHY_BB_TPC_7_EXTEND_TX_FRAME_FOR_TPC_SET(x)                           (((x) << 14) & 0x00004000)
-#define PHY_BB_TPC_7_USE_INIT_TX_GAIN_SETTING_AFTER_WARM_RESET_MSB                                    15
-#define PHY_BB_TPC_7_USE_INIT_TX_GAIN_SETTING_AFTER_WARM_RESET_LSB                                    15
-#define PHY_BB_TPC_7_USE_INIT_TX_GAIN_SETTING_AFTER_WARM_RESET_MASK                           0x00008000
-#define PHY_BB_TPC_7_USE_INIT_TX_GAIN_SETTING_AFTER_WARM_RESET_GET(x)         (((x) & 0x00008000) >> 15)
-#define PHY_BB_TPC_7_USE_INIT_TX_GAIN_SETTING_AFTER_WARM_RESET_SET(x)         (((x) << 15) & 0x00008000)
-
-/* macros for BB_tpc_8 */
-#define PHY_BB_TPC_8_ADDRESS                                                                  0x0000a278
-#define PHY_BB_TPC_8_OFFSET                                                                   0x0000a278
-#define PHY_BB_TPC_8_DESIRED_SCALE_0_MSB                                                               4
-#define PHY_BB_TPC_8_DESIRED_SCALE_0_LSB                                                               0
-#define PHY_BB_TPC_8_DESIRED_SCALE_0_MASK                                                     0x0000001f
-#define PHY_BB_TPC_8_DESIRED_SCALE_0_GET(x)                                    (((x) & 0x0000001f) >> 0)
-#define PHY_BB_TPC_8_DESIRED_SCALE_0_SET(x)                                    (((x) << 0) & 0x0000001f)
-#define PHY_BB_TPC_8_DESIRED_SCALE_1_MSB                                                               9
-#define PHY_BB_TPC_8_DESIRED_SCALE_1_LSB                                                               5
-#define PHY_BB_TPC_8_DESIRED_SCALE_1_MASK                                                     0x000003e0
-#define PHY_BB_TPC_8_DESIRED_SCALE_1_GET(x)                                    (((x) & 0x000003e0) >> 5)
-#define PHY_BB_TPC_8_DESIRED_SCALE_1_SET(x)                                    (((x) << 5) & 0x000003e0)
-#define PHY_BB_TPC_8_DESIRED_SCALE_2_MSB                                                              14
-#define PHY_BB_TPC_8_DESIRED_SCALE_2_LSB                                                              10
-#define PHY_BB_TPC_8_DESIRED_SCALE_2_MASK                                                     0x00007c00
-#define PHY_BB_TPC_8_DESIRED_SCALE_2_GET(x)                                   (((x) & 0x00007c00) >> 10)
-#define PHY_BB_TPC_8_DESIRED_SCALE_2_SET(x)                                   (((x) << 10) & 0x00007c00)
-#define PHY_BB_TPC_8_DESIRED_SCALE_3_MSB                                                              19
-#define PHY_BB_TPC_8_DESIRED_SCALE_3_LSB                                                              15
-#define PHY_BB_TPC_8_DESIRED_SCALE_3_MASK                                                     0x000f8000
-#define PHY_BB_TPC_8_DESIRED_SCALE_3_GET(x)                                   (((x) & 0x000f8000) >> 15)
-#define PHY_BB_TPC_8_DESIRED_SCALE_3_SET(x)                                   (((x) << 15) & 0x000f8000)
-#define PHY_BB_TPC_8_DESIRED_SCALE_4_MSB                                                              24
-#define PHY_BB_TPC_8_DESIRED_SCALE_4_LSB                                                              20
-#define PHY_BB_TPC_8_DESIRED_SCALE_4_MASK                                                     0x01f00000
-#define PHY_BB_TPC_8_DESIRED_SCALE_4_GET(x)                                   (((x) & 0x01f00000) >> 20)
-#define PHY_BB_TPC_8_DESIRED_SCALE_4_SET(x)                                   (((x) << 20) & 0x01f00000)
-#define PHY_BB_TPC_8_DESIRED_SCALE_5_MSB                                                              29
-#define PHY_BB_TPC_8_DESIRED_SCALE_5_LSB                                                              25
-#define PHY_BB_TPC_8_DESIRED_SCALE_5_MASK                                                     0x3e000000
-#define PHY_BB_TPC_8_DESIRED_SCALE_5_GET(x)                                   (((x) & 0x3e000000) >> 25)
-#define PHY_BB_TPC_8_DESIRED_SCALE_5_SET(x)                                   (((x) << 25) & 0x3e000000)
-
-/* macros for BB_tpc_9 */
-#define PHY_BB_TPC_9_ADDRESS                                                                  0x0000a27c
-#define PHY_BB_TPC_9_OFFSET                                                                   0x0000a27c
-#define PHY_BB_TPC_9_DESIRED_SCALE_6_MSB                                                               4
-#define PHY_BB_TPC_9_DESIRED_SCALE_6_LSB                                                               0
-#define PHY_BB_TPC_9_DESIRED_SCALE_6_MASK                                                     0x0000001f
-#define PHY_BB_TPC_9_DESIRED_SCALE_6_GET(x)                                    (((x) & 0x0000001f) >> 0)
-#define PHY_BB_TPC_9_DESIRED_SCALE_6_SET(x)                                    (((x) << 0) & 0x0000001f)
-#define PHY_BB_TPC_9_DESIRED_SCALE_7_MSB                                                               9
-#define PHY_BB_TPC_9_DESIRED_SCALE_7_LSB                                                               5
-#define PHY_BB_TPC_9_DESIRED_SCALE_7_MASK                                                     0x000003e0
-#define PHY_BB_TPC_9_DESIRED_SCALE_7_GET(x)                                    (((x) & 0x000003e0) >> 5)
-#define PHY_BB_TPC_9_DESIRED_SCALE_7_SET(x)                                    (((x) << 5) & 0x000003e0)
-#define PHY_BB_TPC_9_DESIRED_SCALE_CCK_MSB                                                            14
-#define PHY_BB_TPC_9_DESIRED_SCALE_CCK_LSB                                                            10
-#define PHY_BB_TPC_9_DESIRED_SCALE_CCK_MASK                                                   0x00007c00
-#define PHY_BB_TPC_9_DESIRED_SCALE_CCK_GET(x)                                 (((x) & 0x00007c00) >> 10)
-#define PHY_BB_TPC_9_DESIRED_SCALE_CCK_SET(x)                                 (((x) << 10) & 0x00007c00)
-#define PHY_BB_TPC_9_EN_PD_DC_OFFSET_THR_MSB                                                          20
-#define PHY_BB_TPC_9_EN_PD_DC_OFFSET_THR_LSB                                                          20
-#define PHY_BB_TPC_9_EN_PD_DC_OFFSET_THR_MASK                                                 0x00100000
-#define PHY_BB_TPC_9_EN_PD_DC_OFFSET_THR_GET(x)                               (((x) & 0x00100000) >> 20)
-#define PHY_BB_TPC_9_EN_PD_DC_OFFSET_THR_SET(x)                               (((x) << 20) & 0x00100000)
-#define PHY_BB_TPC_9_PD_DC_OFFSET_THR_MSB                                                             26
-#define PHY_BB_TPC_9_PD_DC_OFFSET_THR_LSB                                                             21
-#define PHY_BB_TPC_9_PD_DC_OFFSET_THR_MASK                                                    0x07e00000
-#define PHY_BB_TPC_9_PD_DC_OFFSET_THR_GET(x)                                  (((x) & 0x07e00000) >> 21)
-#define PHY_BB_TPC_9_PD_DC_OFFSET_THR_SET(x)                                  (((x) << 21) & 0x07e00000)
-#define PHY_BB_TPC_9_WAIT_CALTX_SETTLE_MSB                                                            30
-#define PHY_BB_TPC_9_WAIT_CALTX_SETTLE_LSB                                                            27
-#define PHY_BB_TPC_9_WAIT_CALTX_SETTLE_MASK                                                   0x78000000
-#define PHY_BB_TPC_9_WAIT_CALTX_SETTLE_GET(x)                                 (((x) & 0x78000000) >> 27)
-#define PHY_BB_TPC_9_WAIT_CALTX_SETTLE_SET(x)                                 (((x) << 27) & 0x78000000)
-#define PHY_BB_TPC_9_DISABLE_PDADC_RESIDUAL_DC_REMOVAL_MSB                                            31
-#define PHY_BB_TPC_9_DISABLE_PDADC_RESIDUAL_DC_REMOVAL_LSB                                            31
-#define PHY_BB_TPC_9_DISABLE_PDADC_RESIDUAL_DC_REMOVAL_MASK                                   0x80000000
-#define PHY_BB_TPC_9_DISABLE_PDADC_RESIDUAL_DC_REMOVAL_GET(x)                 (((x) & 0x80000000) >> 31)
-#define PHY_BB_TPC_9_DISABLE_PDADC_RESIDUAL_DC_REMOVAL_SET(x)                 (((x) << 31) & 0x80000000)
-
-/* macros for BB_pdadc_tab_b0 */
-#define PHY_BB_PDADC_TAB_B0_ADDRESS                                                           0x0000a280
-#define PHY_BB_PDADC_TAB_B0_OFFSET                                                            0x0000a280
-#define PHY_BB_PDADC_TAB_B0_TAB_ENTRY_MSB                                                             31
-#define PHY_BB_PDADC_TAB_B0_TAB_ENTRY_LSB                                                              0
-#define PHY_BB_PDADC_TAB_B0_TAB_ENTRY_MASK                                                    0xffffffff
-#define PHY_BB_PDADC_TAB_B0_TAB_ENTRY_SET(x)                                   (((x) << 0) & 0xffffffff)
-
-/* macros for BB_cl_tab_b0 */
-#define PHY_BB_CL_TAB_B0_ADDRESS                                                              0x0000a300
-#define PHY_BB_CL_TAB_B0_OFFSET                                                               0x0000a300
-#define PHY_BB_CL_TAB_B0_CL_GAIN_MOD_MSB                                                               4
-#define PHY_BB_CL_TAB_B0_CL_GAIN_MOD_LSB                                                               0
-#define PHY_BB_CL_TAB_B0_CL_GAIN_MOD_MASK                                                     0x0000001f
-#define PHY_BB_CL_TAB_B0_CL_GAIN_MOD_GET(x)                                    (((x) & 0x0000001f) >> 0)
-#define PHY_BB_CL_TAB_B0_CL_GAIN_MOD_SET(x)                                    (((x) << 0) & 0x0000001f)
-#define PHY_BB_CL_TAB_B0_CARR_LK_DC_ADD_Q_MSB                                                         15
-#define PHY_BB_CL_TAB_B0_CARR_LK_DC_ADD_Q_LSB                                                          5
-#define PHY_BB_CL_TAB_B0_CARR_LK_DC_ADD_Q_MASK                                                0x0000ffe0
-#define PHY_BB_CL_TAB_B0_CARR_LK_DC_ADD_Q_GET(x)                               (((x) & 0x0000ffe0) >> 5)
-#define PHY_BB_CL_TAB_B0_CARR_LK_DC_ADD_Q_SET(x)                               (((x) << 5) & 0x0000ffe0)
-#define PHY_BB_CL_TAB_B0_CARR_LK_DC_ADD_I_MSB                                                         26
-#define PHY_BB_CL_TAB_B0_CARR_LK_DC_ADD_I_LSB                                                         16
-#define PHY_BB_CL_TAB_B0_CARR_LK_DC_ADD_I_MASK                                                0x07ff0000
-#define PHY_BB_CL_TAB_B0_CARR_LK_DC_ADD_I_GET(x)                              (((x) & 0x07ff0000) >> 16)
-#define PHY_BB_CL_TAB_B0_CARR_LK_DC_ADD_I_SET(x)                              (((x) << 16) & 0x07ff0000)
-#define PHY_BB_CL_TAB_B0_BB_GAIN_MSB                                                                  30
-#define PHY_BB_CL_TAB_B0_BB_GAIN_LSB                                                                  27
-#define PHY_BB_CL_TAB_B0_BB_GAIN_MASK                                                         0x78000000
-#define PHY_BB_CL_TAB_B0_BB_GAIN_GET(x)                                       (((x) & 0x78000000) >> 27)
-#define PHY_BB_CL_TAB_B0_BB_GAIN_SET(x)                                       (((x) << 27) & 0x78000000)
-
-/* macros for BB_cl_map_0_b0 */
-#define PHY_BB_CL_MAP_0_B0_ADDRESS                                                            0x0000a340
-#define PHY_BB_CL_MAP_0_B0_OFFSET                                                             0x0000a340
-#define PHY_BB_CL_MAP_0_B0_CL_MAP_0_MSB                                                               31
-#define PHY_BB_CL_MAP_0_B0_CL_MAP_0_LSB                                                                0
-#define PHY_BB_CL_MAP_0_B0_CL_MAP_0_MASK                                                      0xffffffff
-#define PHY_BB_CL_MAP_0_B0_CL_MAP_0_GET(x)                                     (((x) & 0xffffffff) >> 0)
-#define PHY_BB_CL_MAP_0_B0_CL_MAP_0_SET(x)                                     (((x) << 0) & 0xffffffff)
-
-/* macros for BB_cl_map_1_b0 */
-#define PHY_BB_CL_MAP_1_B0_ADDRESS                                                            0x0000a344
-#define PHY_BB_CL_MAP_1_B0_OFFSET                                                             0x0000a344
-#define PHY_BB_CL_MAP_1_B0_CL_MAP_1_MSB                                                               31
-#define PHY_BB_CL_MAP_1_B0_CL_MAP_1_LSB                                                                0
-#define PHY_BB_CL_MAP_1_B0_CL_MAP_1_MASK                                                      0xffffffff
-#define PHY_BB_CL_MAP_1_B0_CL_MAP_1_GET(x)                                     (((x) & 0xffffffff) >> 0)
-#define PHY_BB_CL_MAP_1_B0_CL_MAP_1_SET(x)                                     (((x) << 0) & 0xffffffff)
-
-/* macros for BB_cl_map_2_b0 */
-#define PHY_BB_CL_MAP_2_B0_ADDRESS                                                            0x0000a348
-#define PHY_BB_CL_MAP_2_B0_OFFSET                                                             0x0000a348
-#define PHY_BB_CL_MAP_2_B0_CL_MAP_2_MSB                                                               31
-#define PHY_BB_CL_MAP_2_B0_CL_MAP_2_LSB                                                                0
-#define PHY_BB_CL_MAP_2_B0_CL_MAP_2_MASK                                                      0xffffffff
-#define PHY_BB_CL_MAP_2_B0_CL_MAP_2_GET(x)                                     (((x) & 0xffffffff) >> 0)
-#define PHY_BB_CL_MAP_2_B0_CL_MAP_2_SET(x)                                     (((x) << 0) & 0xffffffff)
-
-/* macros for BB_cl_map_3_b0 */
-#define PHY_BB_CL_MAP_3_B0_ADDRESS                                                            0x0000a34c
-#define PHY_BB_CL_MAP_3_B0_OFFSET                                                             0x0000a34c
-#define PHY_BB_CL_MAP_3_B0_CL_MAP_3_MSB                                                               31
-#define PHY_BB_CL_MAP_3_B0_CL_MAP_3_LSB                                                                0
-#define PHY_BB_CL_MAP_3_B0_CL_MAP_3_MASK                                                      0xffffffff
-#define PHY_BB_CL_MAP_3_B0_CL_MAP_3_GET(x)                                     (((x) & 0xffffffff) >> 0)
-#define PHY_BB_CL_MAP_3_B0_CL_MAP_3_SET(x)                                     (((x) << 0) & 0xffffffff)
-
-/* macros for BB_cl_cal_ctrl */
-#define PHY_BB_CL_CAL_CTRL_ADDRESS                                                            0x0000a358
-#define PHY_BB_CL_CAL_CTRL_OFFSET                                                             0x0000a358
-#define PHY_BB_CL_CAL_CTRL_ENABLE_PARALLEL_CAL_MSB                                                     0
-#define PHY_BB_CL_CAL_CTRL_ENABLE_PARALLEL_CAL_LSB                                                     0
-#define PHY_BB_CL_CAL_CTRL_ENABLE_PARALLEL_CAL_MASK                                           0x00000001
-#define PHY_BB_CL_CAL_CTRL_ENABLE_PARALLEL_CAL_GET(x)                          (((x) & 0x00000001) >> 0)
-#define PHY_BB_CL_CAL_CTRL_ENABLE_PARALLEL_CAL_SET(x)                          (((x) << 0) & 0x00000001)
-#define PHY_BB_CL_CAL_CTRL_ENABLE_CL_CALIBRATE_MSB                                                     1
-#define PHY_BB_CL_CAL_CTRL_ENABLE_CL_CALIBRATE_LSB                                                     1
-#define PHY_BB_CL_CAL_CTRL_ENABLE_CL_CALIBRATE_MASK                                           0x00000002
-#define PHY_BB_CL_CAL_CTRL_ENABLE_CL_CALIBRATE_GET(x)                          (((x) & 0x00000002) >> 1)
-#define PHY_BB_CL_CAL_CTRL_ENABLE_CL_CALIBRATE_SET(x)                          (((x) << 1) & 0x00000002)
-#define PHY_BB_CL_CAL_CTRL_CF_CLC_TEST_POINT_MSB                                                       3
-#define PHY_BB_CL_CAL_CTRL_CF_CLC_TEST_POINT_LSB                                                       2
-#define PHY_BB_CL_CAL_CTRL_CF_CLC_TEST_POINT_MASK                                             0x0000000c
-#define PHY_BB_CL_CAL_CTRL_CF_CLC_TEST_POINT_GET(x)                            (((x) & 0x0000000c) >> 2)
-#define PHY_BB_CL_CAL_CTRL_CF_CLC_TEST_POINT_SET(x)                            (((x) << 2) & 0x0000000c)
-#define PHY_BB_CL_CAL_CTRL_CF_CLC_FORCED_PAGAIN_MSB                                                    7
-#define PHY_BB_CL_CAL_CTRL_CF_CLC_FORCED_PAGAIN_LSB                                                    4
-#define PHY_BB_CL_CAL_CTRL_CF_CLC_FORCED_PAGAIN_MASK                                          0x000000f0
-#define PHY_BB_CL_CAL_CTRL_CF_CLC_FORCED_PAGAIN_GET(x)                         (((x) & 0x000000f0) >> 4)
-#define PHY_BB_CL_CAL_CTRL_CF_CLC_FORCED_PAGAIN_SET(x)                         (((x) << 4) & 0x000000f0)
-#define PHY_BB_CL_CAL_CTRL_CARR_LEAK_MAX_OFFSET_MSB                                                   15
-#define PHY_BB_CL_CAL_CTRL_CARR_LEAK_MAX_OFFSET_LSB                                                    8
-#define PHY_BB_CL_CAL_CTRL_CARR_LEAK_MAX_OFFSET_MASK                                          0x0000ff00
-#define PHY_BB_CL_CAL_CTRL_CARR_LEAK_MAX_OFFSET_GET(x)                         (((x) & 0x0000ff00) >> 8)
-#define PHY_BB_CL_CAL_CTRL_CARR_LEAK_MAX_OFFSET_SET(x)                         (((x) << 8) & 0x0000ff00)
-#define PHY_BB_CL_CAL_CTRL_CF_CLC_INIT_BBGAIN_MSB                                                     21
-#define PHY_BB_CL_CAL_CTRL_CF_CLC_INIT_BBGAIN_LSB                                                     16
-#define PHY_BB_CL_CAL_CTRL_CF_CLC_INIT_BBGAIN_MASK                                            0x003f0000
-#define PHY_BB_CL_CAL_CTRL_CF_CLC_INIT_BBGAIN_GET(x)                          (((x) & 0x003f0000) >> 16)
-#define PHY_BB_CL_CAL_CTRL_CF_CLC_INIT_BBGAIN_SET(x)                          (((x) << 16) & 0x003f0000)
-#define PHY_BB_CL_CAL_CTRL_CF_ADC_BOUND_MSB                                                           29
-#define PHY_BB_CL_CAL_CTRL_CF_ADC_BOUND_LSB                                                           22
-#define PHY_BB_CL_CAL_CTRL_CF_ADC_BOUND_MASK                                                  0x3fc00000
-#define PHY_BB_CL_CAL_CTRL_CF_ADC_BOUND_GET(x)                                (((x) & 0x3fc00000) >> 22)
-#define PHY_BB_CL_CAL_CTRL_CF_ADC_BOUND_SET(x)                                (((x) << 22) & 0x3fc00000)
-#define PHY_BB_CL_CAL_CTRL_USE_DAC_CL_CORRECTION_MSB                                                  30
-#define PHY_BB_CL_CAL_CTRL_USE_DAC_CL_CORRECTION_LSB                                                  30
-#define PHY_BB_CL_CAL_CTRL_USE_DAC_CL_CORRECTION_MASK                                         0x40000000
-#define PHY_BB_CL_CAL_CTRL_USE_DAC_CL_CORRECTION_GET(x)                       (((x) & 0x40000000) >> 30)
-#define PHY_BB_CL_CAL_CTRL_USE_DAC_CL_CORRECTION_SET(x)                       (((x) << 30) & 0x40000000)
-#define PHY_BB_CL_CAL_CTRL_CL_MAP_HW_GEN_MSB                                                          31
-#define PHY_BB_CL_CAL_CTRL_CL_MAP_HW_GEN_LSB                                                          31
-#define PHY_BB_CL_CAL_CTRL_CL_MAP_HW_GEN_MASK                                                 0x80000000
-#define PHY_BB_CL_CAL_CTRL_CL_MAP_HW_GEN_GET(x)                               (((x) & 0x80000000) >> 31)
-#define PHY_BB_CL_CAL_CTRL_CL_MAP_HW_GEN_SET(x)                               (((x) << 31) & 0x80000000)
-
-/* macros for BB_cl_map_pal_0_b0 */
-#define PHY_BB_CL_MAP_PAL_0_B0_ADDRESS                                                        0x0000a35c
-#define PHY_BB_CL_MAP_PAL_0_B0_OFFSET                                                         0x0000a35c
-#define PHY_BB_CL_MAP_PAL_0_B0_CL_MAP_0_MSB                                                           31
-#define PHY_BB_CL_MAP_PAL_0_B0_CL_MAP_0_LSB                                                            0
-#define PHY_BB_CL_MAP_PAL_0_B0_CL_MAP_0_MASK                                                  0xffffffff
-#define PHY_BB_CL_MAP_PAL_0_B0_CL_MAP_0_GET(x)                                 (((x) & 0xffffffff) >> 0)
-#define PHY_BB_CL_MAP_PAL_0_B0_CL_MAP_0_SET(x)                                 (((x) << 0) & 0xffffffff)
-
-/* macros for BB_cl_map_pal_1_b0 */
-#define PHY_BB_CL_MAP_PAL_1_B0_ADDRESS                                                        0x0000a360
-#define PHY_BB_CL_MAP_PAL_1_B0_OFFSET                                                         0x0000a360
-#define PHY_BB_CL_MAP_PAL_1_B0_CL_MAP_1_MSB                                                           31
-#define PHY_BB_CL_MAP_PAL_1_B0_CL_MAP_1_LSB                                                            0
-#define PHY_BB_CL_MAP_PAL_1_B0_CL_MAP_1_MASK                                                  0xffffffff
-#define PHY_BB_CL_MAP_PAL_1_B0_CL_MAP_1_GET(x)                                 (((x) & 0xffffffff) >> 0)
-#define PHY_BB_CL_MAP_PAL_1_B0_CL_MAP_1_SET(x)                                 (((x) << 0) & 0xffffffff)
-
-/* macros for BB_cl_map_pal_2_b0 */
-#define PHY_BB_CL_MAP_PAL_2_B0_ADDRESS                                                        0x0000a364
-#define PHY_BB_CL_MAP_PAL_2_B0_OFFSET                                                         0x0000a364
-#define PHY_BB_CL_MAP_PAL_2_B0_CL_MAP_2_MSB                                                           31
-#define PHY_BB_CL_MAP_PAL_2_B0_CL_MAP_2_LSB                                                            0
-#define PHY_BB_CL_MAP_PAL_2_B0_CL_MAP_2_MASK                                                  0xffffffff
-#define PHY_BB_CL_MAP_PAL_2_B0_CL_MAP_2_GET(x)                                 (((x) & 0xffffffff) >> 0)
-#define PHY_BB_CL_MAP_PAL_2_B0_CL_MAP_2_SET(x)                                 (((x) << 0) & 0xffffffff)
-
-/* macros for BB_cl_map_pal_3_b0 */
-#define PHY_BB_CL_MAP_PAL_3_B0_ADDRESS                                                        0x0000a368
-#define PHY_BB_CL_MAP_PAL_3_B0_OFFSET                                                         0x0000a368
-#define PHY_BB_CL_MAP_PAL_3_B0_CL_MAP_3_MSB                                                           31
-#define PHY_BB_CL_MAP_PAL_3_B0_CL_MAP_3_LSB                                                            0
-#define PHY_BB_CL_MAP_PAL_3_B0_CL_MAP_3_MASK                                                  0xffffffff
-#define PHY_BB_CL_MAP_PAL_3_B0_CL_MAP_3_GET(x)                                 (((x) & 0xffffffff) >> 0)
-#define PHY_BB_CL_MAP_PAL_3_B0_CL_MAP_3_SET(x)                                 (((x) << 0) & 0xffffffff)
-
-/* macros for BB_rifs */
-#define PHY_BB_RIFS_ADDRESS                                                                   0x0000a388
-#define PHY_BB_RIFS_OFFSET                                                                    0x0000a388
-#define PHY_BB_RIFS_DISABLE_FCC_FIX_MSB                                                               25
-#define PHY_BB_RIFS_DISABLE_FCC_FIX_LSB                                                               25
-#define PHY_BB_RIFS_DISABLE_FCC_FIX_MASK                                                      0x02000000
-#define PHY_BB_RIFS_DISABLE_FCC_FIX_GET(x)                                    (((x) & 0x02000000) >> 25)
-#define PHY_BB_RIFS_DISABLE_FCC_FIX_SET(x)                                    (((x) << 25) & 0x02000000)
-#define PHY_BB_RIFS_ENABLE_RESET_TDOMAIN_MSB                                                          26
-#define PHY_BB_RIFS_ENABLE_RESET_TDOMAIN_LSB                                                          26
-#define PHY_BB_RIFS_ENABLE_RESET_TDOMAIN_MASK                                                 0x04000000
-#define PHY_BB_RIFS_ENABLE_RESET_TDOMAIN_GET(x)                               (((x) & 0x04000000) >> 26)
-#define PHY_BB_RIFS_ENABLE_RESET_TDOMAIN_SET(x)                               (((x) << 26) & 0x04000000)
-#define PHY_BB_RIFS_DISABLE_FCC_FIX2_MSB                                                              27
-#define PHY_BB_RIFS_DISABLE_FCC_FIX2_LSB                                                              27
-#define PHY_BB_RIFS_DISABLE_FCC_FIX2_MASK                                                     0x08000000
-#define PHY_BB_RIFS_DISABLE_FCC_FIX2_GET(x)                                   (((x) & 0x08000000) >> 27)
-#define PHY_BB_RIFS_DISABLE_FCC_FIX2_SET(x)                                   (((x) << 27) & 0x08000000)
-#define PHY_BB_RIFS_DISABLE_RIFS_CCK_FIX_MSB                                                          28
-#define PHY_BB_RIFS_DISABLE_RIFS_CCK_FIX_LSB                                                          28
-#define PHY_BB_RIFS_DISABLE_RIFS_CCK_FIX_MASK                                                 0x10000000
-#define PHY_BB_RIFS_DISABLE_RIFS_CCK_FIX_GET(x)                               (((x) & 0x10000000) >> 28)
-#define PHY_BB_RIFS_DISABLE_RIFS_CCK_FIX_SET(x)                               (((x) << 28) & 0x10000000)
-#define PHY_BB_RIFS_DISABLE_ERROR_RESET_FIX_MSB                                                       29
-#define PHY_BB_RIFS_DISABLE_ERROR_RESET_FIX_LSB                                                       29
-#define PHY_BB_RIFS_DISABLE_ERROR_RESET_FIX_MASK                                              0x20000000
-#define PHY_BB_RIFS_DISABLE_ERROR_RESET_FIX_GET(x)                            (((x) & 0x20000000) >> 29)
-#define PHY_BB_RIFS_DISABLE_ERROR_RESET_FIX_SET(x)                            (((x) << 29) & 0x20000000)
-#define PHY_BB_RIFS_RADAR_USE_FDOMAIN_RESET_MSB                                                       30
-#define PHY_BB_RIFS_RADAR_USE_FDOMAIN_RESET_LSB                                                       30
-#define PHY_BB_RIFS_RADAR_USE_FDOMAIN_RESET_MASK                                              0x40000000
-#define PHY_BB_RIFS_RADAR_USE_FDOMAIN_RESET_GET(x)                            (((x) & 0x40000000) >> 30)
-#define PHY_BB_RIFS_RADAR_USE_FDOMAIN_RESET_SET(x)                            (((x) << 30) & 0x40000000)
-
-/* macros for BB_powertx_rate5 */
-#define PHY_BB_POWERTX_RATE5_ADDRESS                                                          0x0000a38c
-#define PHY_BB_POWERTX_RATE5_OFFSET                                                           0x0000a38c
-#define PHY_BB_POWERTX_RATE5_POWERTXHT20_0_MSB                                                         5
-#define PHY_BB_POWERTX_RATE5_POWERTXHT20_0_LSB                                                         0
-#define PHY_BB_POWERTX_RATE5_POWERTXHT20_0_MASK                                               0x0000003f
-#define PHY_BB_POWERTX_RATE5_POWERTXHT20_0_GET(x)                              (((x) & 0x0000003f) >> 0)
-#define PHY_BB_POWERTX_RATE5_POWERTXHT20_0_SET(x)                              (((x) << 0) & 0x0000003f)
-#define PHY_BB_POWERTX_RATE5_POWERTXHT20_1_MSB                                                        13
-#define PHY_BB_POWERTX_RATE5_POWERTXHT20_1_LSB                                                         8
-#define PHY_BB_POWERTX_RATE5_POWERTXHT20_1_MASK                                               0x00003f00
-#define PHY_BB_POWERTX_RATE5_POWERTXHT20_1_GET(x)                              (((x) & 0x00003f00) >> 8)
-#define PHY_BB_POWERTX_RATE5_POWERTXHT20_1_SET(x)                              (((x) << 8) & 0x00003f00)
-#define PHY_BB_POWERTX_RATE5_POWERTXHT20_2_MSB                                                        21
-#define PHY_BB_POWERTX_RATE5_POWERTXHT20_2_LSB                                                        16
-#define PHY_BB_POWERTX_RATE5_POWERTXHT20_2_MASK                                               0x003f0000
-#define PHY_BB_POWERTX_RATE5_POWERTXHT20_2_GET(x)                             (((x) & 0x003f0000) >> 16)
-#define PHY_BB_POWERTX_RATE5_POWERTXHT20_2_SET(x)                             (((x) << 16) & 0x003f0000)
-#define PHY_BB_POWERTX_RATE5_POWERTXHT20_3_MSB                                                        29
-#define PHY_BB_POWERTX_RATE5_POWERTXHT20_3_LSB                                                        24
-#define PHY_BB_POWERTX_RATE5_POWERTXHT20_3_MASK                                               0x3f000000
-#define PHY_BB_POWERTX_RATE5_POWERTXHT20_3_GET(x)                             (((x) & 0x3f000000) >> 24)
-#define PHY_BB_POWERTX_RATE5_POWERTXHT20_3_SET(x)                             (((x) << 24) & 0x3f000000)
-
-/* macros for BB_powertx_rate6 */
-#define PHY_BB_POWERTX_RATE6_ADDRESS                                                          0x0000a390
-#define PHY_BB_POWERTX_RATE6_OFFSET                                                           0x0000a390
-#define PHY_BB_POWERTX_RATE6_POWERTXHT20_4_MSB                                                         5
-#define PHY_BB_POWERTX_RATE6_POWERTXHT20_4_LSB                                                         0
-#define PHY_BB_POWERTX_RATE6_POWERTXHT20_4_MASK                                               0x0000003f
-#define PHY_BB_POWERTX_RATE6_POWERTXHT20_4_GET(x)                              (((x) & 0x0000003f) >> 0)
-#define PHY_BB_POWERTX_RATE6_POWERTXHT20_4_SET(x)                              (((x) << 0) & 0x0000003f)
-#define PHY_BB_POWERTX_RATE6_POWERTXHT20_5_MSB                                                        13
-#define PHY_BB_POWERTX_RATE6_POWERTXHT20_5_LSB                                                         8
-#define PHY_BB_POWERTX_RATE6_POWERTXHT20_5_MASK                                               0x00003f00
-#define PHY_BB_POWERTX_RATE6_POWERTXHT20_5_GET(x)                              (((x) & 0x00003f00) >> 8)
-#define PHY_BB_POWERTX_RATE6_POWERTXHT20_5_SET(x)                              (((x) << 8) & 0x00003f00)
-#define PHY_BB_POWERTX_RATE6_POWERTXHT20_6_MSB                                                        21
-#define PHY_BB_POWERTX_RATE6_POWERTXHT20_6_LSB                                                        16
-#define PHY_BB_POWERTX_RATE6_POWERTXHT20_6_MASK                                               0x003f0000
-#define PHY_BB_POWERTX_RATE6_POWERTXHT20_6_GET(x)                             (((x) & 0x003f0000) >> 16)
-#define PHY_BB_POWERTX_RATE6_POWERTXHT20_6_SET(x)                             (((x) << 16) & 0x003f0000)
-#define PHY_BB_POWERTX_RATE6_POWERTXHT20_7_MSB                                                        29
-#define PHY_BB_POWERTX_RATE6_POWERTXHT20_7_LSB                                                        24
-#define PHY_BB_POWERTX_RATE6_POWERTXHT20_7_MASK                                               0x3f000000
-#define PHY_BB_POWERTX_RATE6_POWERTXHT20_7_GET(x)                             (((x) & 0x3f000000) >> 24)
-#define PHY_BB_POWERTX_RATE6_POWERTXHT20_7_SET(x)                             (((x) << 24) & 0x3f000000)
-
-/* macros for BB_tpc_10 */
-#define PHY_BB_TPC_10_ADDRESS                                                                 0x0000a394
-#define PHY_BB_TPC_10_OFFSET                                                                  0x0000a394
-#define PHY_BB_TPC_10_DESIRED_SCALE_HT20_0_MSB                                                         4
-#define PHY_BB_TPC_10_DESIRED_SCALE_HT20_0_LSB                                                         0
-#define PHY_BB_TPC_10_DESIRED_SCALE_HT20_0_MASK                                               0x0000001f
-#define PHY_BB_TPC_10_DESIRED_SCALE_HT20_0_GET(x)                              (((x) & 0x0000001f) >> 0)
-#define PHY_BB_TPC_10_DESIRED_SCALE_HT20_0_SET(x)                              (((x) << 0) & 0x0000001f)
-#define PHY_BB_TPC_10_DESIRED_SCALE_HT20_1_MSB                                                         9
-#define PHY_BB_TPC_10_DESIRED_SCALE_HT20_1_LSB                                                         5
-#define PHY_BB_TPC_10_DESIRED_SCALE_HT20_1_MASK                                               0x000003e0
-#define PHY_BB_TPC_10_DESIRED_SCALE_HT20_1_GET(x)                              (((x) & 0x000003e0) >> 5)
-#define PHY_BB_TPC_10_DESIRED_SCALE_HT20_1_SET(x)                              (((x) << 5) & 0x000003e0)
-#define PHY_BB_TPC_10_DESIRED_SCALE_HT20_2_MSB                                                        14
-#define PHY_BB_TPC_10_DESIRED_SCALE_HT20_2_LSB                                                        10
-#define PHY_BB_TPC_10_DESIRED_SCALE_HT20_2_MASK                                               0x00007c00
-#define PHY_BB_TPC_10_DESIRED_SCALE_HT20_2_GET(x)                             (((x) & 0x00007c00) >> 10)
-#define PHY_BB_TPC_10_DESIRED_SCALE_HT20_2_SET(x)                             (((x) << 10) & 0x00007c00)
-#define PHY_BB_TPC_10_DESIRED_SCALE_HT20_3_MSB                                                        19
-#define PHY_BB_TPC_10_DESIRED_SCALE_HT20_3_LSB                                                        15
-#define PHY_BB_TPC_10_DESIRED_SCALE_HT20_3_MASK                                               0x000f8000
-#define PHY_BB_TPC_10_DESIRED_SCALE_HT20_3_GET(x)                             (((x) & 0x000f8000) >> 15)
-#define PHY_BB_TPC_10_DESIRED_SCALE_HT20_3_SET(x)                             (((x) << 15) & 0x000f8000)
-#define PHY_BB_TPC_10_DESIRED_SCALE_HT20_4_MSB                                                        24
-#define PHY_BB_TPC_10_DESIRED_SCALE_HT20_4_LSB                                                        20
-#define PHY_BB_TPC_10_DESIRED_SCALE_HT20_4_MASK                                               0x01f00000
-#define PHY_BB_TPC_10_DESIRED_SCALE_HT20_4_GET(x)                             (((x) & 0x01f00000) >> 20)
-#define PHY_BB_TPC_10_DESIRED_SCALE_HT20_4_SET(x)                             (((x) << 20) & 0x01f00000)
-#define PHY_BB_TPC_10_DESIRED_SCALE_HT20_5_MSB                                                        29
-#define PHY_BB_TPC_10_DESIRED_SCALE_HT20_5_LSB                                                        25
-#define PHY_BB_TPC_10_DESIRED_SCALE_HT20_5_MASK                                               0x3e000000
-#define PHY_BB_TPC_10_DESIRED_SCALE_HT20_5_GET(x)                             (((x) & 0x3e000000) >> 25)
-#define PHY_BB_TPC_10_DESIRED_SCALE_HT20_5_SET(x)                             (((x) << 25) & 0x3e000000)
-
-/* macros for BB_tpc_11_b0 */
-#define PHY_BB_TPC_11_B0_ADDRESS                                                              0x0000a398
-#define PHY_BB_TPC_11_B0_OFFSET                                                               0x0000a398
-#define PHY_BB_TPC_11_B0_DESIRED_SCALE_HT20_6_MSB                                                      4
-#define PHY_BB_TPC_11_B0_DESIRED_SCALE_HT20_6_LSB                                                      0
-#define PHY_BB_TPC_11_B0_DESIRED_SCALE_HT20_6_MASK                                            0x0000001f
-#define PHY_BB_TPC_11_B0_DESIRED_SCALE_HT20_6_GET(x)                           (((x) & 0x0000001f) >> 0)
-#define PHY_BB_TPC_11_B0_DESIRED_SCALE_HT20_6_SET(x)                           (((x) << 0) & 0x0000001f)
-#define PHY_BB_TPC_11_B0_DESIRED_SCALE_HT20_7_MSB                                                      9
-#define PHY_BB_TPC_11_B0_DESIRED_SCALE_HT20_7_LSB                                                      5
-#define PHY_BB_TPC_11_B0_DESIRED_SCALE_HT20_7_MASK                                            0x000003e0
-#define PHY_BB_TPC_11_B0_DESIRED_SCALE_HT20_7_GET(x)                           (((x) & 0x000003e0) >> 5)
-#define PHY_BB_TPC_11_B0_DESIRED_SCALE_HT20_7_SET(x)                           (((x) << 5) & 0x000003e0)
-#define PHY_BB_TPC_11_B0_OLPC_GAIN_DELTA_0_MSB                                                        23
-#define PHY_BB_TPC_11_B0_OLPC_GAIN_DELTA_0_LSB                                                        16
-#define PHY_BB_TPC_11_B0_OLPC_GAIN_DELTA_0_MASK                                               0x00ff0000
-#define PHY_BB_TPC_11_B0_OLPC_GAIN_DELTA_0_GET(x)                             (((x) & 0x00ff0000) >> 16)
-#define PHY_BB_TPC_11_B0_OLPC_GAIN_DELTA_0_SET(x)                             (((x) << 16) & 0x00ff0000)
-#define PHY_BB_TPC_11_B0_OLPC_GAIN_DELTA_0_PAL_ON_MSB                                                 31
-#define PHY_BB_TPC_11_B0_OLPC_GAIN_DELTA_0_PAL_ON_LSB                                                 24
-#define PHY_BB_TPC_11_B0_OLPC_GAIN_DELTA_0_PAL_ON_MASK                                        0xff000000
-#define PHY_BB_TPC_11_B0_OLPC_GAIN_DELTA_0_PAL_ON_GET(x)                      (((x) & 0xff000000) >> 24)
-#define PHY_BB_TPC_11_B0_OLPC_GAIN_DELTA_0_PAL_ON_SET(x)                      (((x) << 24) & 0xff000000)
-
-/* macros for BB_cal_chain_mask */
-#define PHY_BB_CAL_CHAIN_MASK_ADDRESS                                                         0x0000a39c
-#define PHY_BB_CAL_CHAIN_MASK_OFFSET                                                          0x0000a39c
-#define PHY_BB_CAL_CHAIN_MASK_CAL_CHAIN_MASK_MSB                                                       2
-#define PHY_BB_CAL_CHAIN_MASK_CAL_CHAIN_MASK_LSB                                                       0
-#define PHY_BB_CAL_CHAIN_MASK_CAL_CHAIN_MASK_MASK                                             0x00000007
-#define PHY_BB_CAL_CHAIN_MASK_CAL_CHAIN_MASK_GET(x)                            (((x) & 0x00000007) >> 0)
-#define PHY_BB_CAL_CHAIN_MASK_CAL_CHAIN_MASK_SET(x)                            (((x) << 0) & 0x00000007)
-
-/* macros for BB_powertx_sub */
-#define PHY_BB_POWERTX_SUB_ADDRESS                                                            0x0000a3bc
-#define PHY_BB_POWERTX_SUB_OFFSET                                                             0x0000a3bc
-#define PHY_BB_POWERTX_SUB_POWERTX_SUB_FOR_2CHAIN_MSB                                                  5
-#define PHY_BB_POWERTX_SUB_POWERTX_SUB_FOR_2CHAIN_LSB                                                  0
-#define PHY_BB_POWERTX_SUB_POWERTX_SUB_FOR_2CHAIN_MASK                                        0x0000003f
-#define PHY_BB_POWERTX_SUB_POWERTX_SUB_FOR_2CHAIN_GET(x)                       (((x) & 0x0000003f) >> 0)
-#define PHY_BB_POWERTX_SUB_POWERTX_SUB_FOR_2CHAIN_SET(x)                       (((x) << 0) & 0x0000003f)
-
-/* macros for BB_powertx_rate7 */
-#define PHY_BB_POWERTX_RATE7_ADDRESS                                                          0x0000a3c0
-#define PHY_BB_POWERTX_RATE7_OFFSET                                                           0x0000a3c0
-#define PHY_BB_POWERTX_RATE7_POWERTXHT40_0_MSB                                                         5
-#define PHY_BB_POWERTX_RATE7_POWERTXHT40_0_LSB                                                         0
-#define PHY_BB_POWERTX_RATE7_POWERTXHT40_0_MASK                                               0x0000003f
-#define PHY_BB_POWERTX_RATE7_POWERTXHT40_0_GET(x)                              (((x) & 0x0000003f) >> 0)
-#define PHY_BB_POWERTX_RATE7_POWERTXHT40_0_SET(x)                              (((x) << 0) & 0x0000003f)
-#define PHY_BB_POWERTX_RATE7_POWERTXHT40_1_MSB                                                        13
-#define PHY_BB_POWERTX_RATE7_POWERTXHT40_1_LSB                                                         8
-#define PHY_BB_POWERTX_RATE7_POWERTXHT40_1_MASK                                               0x00003f00
-#define PHY_BB_POWERTX_RATE7_POWERTXHT40_1_GET(x)                              (((x) & 0x00003f00) >> 8)
-#define PHY_BB_POWERTX_RATE7_POWERTXHT40_1_SET(x)                              (((x) << 8) & 0x00003f00)
-#define PHY_BB_POWERTX_RATE7_POWERTXHT40_2_MSB                                                        21
-#define PHY_BB_POWERTX_RATE7_POWERTXHT40_2_LSB                                                        16
-#define PHY_BB_POWERTX_RATE7_POWERTXHT40_2_MASK                                               0x003f0000
-#define PHY_BB_POWERTX_RATE7_POWERTXHT40_2_GET(x)                             (((x) & 0x003f0000) >> 16)
-#define PHY_BB_POWERTX_RATE7_POWERTXHT40_2_SET(x)                             (((x) << 16) & 0x003f0000)
-#define PHY_BB_POWERTX_RATE7_POWERTXHT40_3_MSB                                                        29
-#define PHY_BB_POWERTX_RATE7_POWERTXHT40_3_LSB                                                        24
-#define PHY_BB_POWERTX_RATE7_POWERTXHT40_3_MASK                                               0x3f000000
-#define PHY_BB_POWERTX_RATE7_POWERTXHT40_3_GET(x)                             (((x) & 0x3f000000) >> 24)
-#define PHY_BB_POWERTX_RATE7_POWERTXHT40_3_SET(x)                             (((x) << 24) & 0x3f000000)
-
-/* macros for BB_powertx_rate8 */
-#define PHY_BB_POWERTX_RATE8_ADDRESS                                                          0x0000a3c4
-#define PHY_BB_POWERTX_RATE8_OFFSET                                                           0x0000a3c4
-#define PHY_BB_POWERTX_RATE8_POWERTXHT40_4_MSB                                                         5
-#define PHY_BB_POWERTX_RATE8_POWERTXHT40_4_LSB                                                         0
-#define PHY_BB_POWERTX_RATE8_POWERTXHT40_4_MASK                                               0x0000003f
-#define PHY_BB_POWERTX_RATE8_POWERTXHT40_4_GET(x)                              (((x) & 0x0000003f) >> 0)
-#define PHY_BB_POWERTX_RATE8_POWERTXHT40_4_SET(x)                              (((x) << 0) & 0x0000003f)
-#define PHY_BB_POWERTX_RATE8_POWERTXHT40_5_MSB                                                        13
-#define PHY_BB_POWERTX_RATE8_POWERTXHT40_5_LSB                                                         8
-#define PHY_BB_POWERTX_RATE8_POWERTXHT40_5_MASK                                               0x00003f00
-#define PHY_BB_POWERTX_RATE8_POWERTXHT40_5_GET(x)                              (((x) & 0x00003f00) >> 8)
-#define PHY_BB_POWERTX_RATE8_POWERTXHT40_5_SET(x)                              (((x) << 8) & 0x00003f00)
-#define PHY_BB_POWERTX_RATE8_POWERTXHT40_6_MSB                                                        21
-#define PHY_BB_POWERTX_RATE8_POWERTXHT40_6_LSB                                                        16
-#define PHY_BB_POWERTX_RATE8_POWERTXHT40_6_MASK                                               0x003f0000
-#define PHY_BB_POWERTX_RATE8_POWERTXHT40_6_GET(x)                             (((x) & 0x003f0000) >> 16)
-#define PHY_BB_POWERTX_RATE8_POWERTXHT40_6_SET(x)                             (((x) << 16) & 0x003f0000)
-#define PHY_BB_POWERTX_RATE8_POWERTXHT40_7_MSB                                                        29
-#define PHY_BB_POWERTX_RATE8_POWERTXHT40_7_LSB                                                        24
-#define PHY_BB_POWERTX_RATE8_POWERTXHT40_7_MASK                                               0x3f000000
-#define PHY_BB_POWERTX_RATE8_POWERTXHT40_7_GET(x)                             (((x) & 0x3f000000) >> 24)
-#define PHY_BB_POWERTX_RATE8_POWERTXHT40_7_SET(x)                             (((x) << 24) & 0x3f000000)
-
-/* macros for BB_powertx_rate9 */
-#define PHY_BB_POWERTX_RATE9_ADDRESS                                                          0x0000a3c8
-#define PHY_BB_POWERTX_RATE9_OFFSET                                                           0x0000a3c8
-#define PHY_BB_POWERTX_RATE9_POWERTX_DUP40_CCK_MSB                                                     5
-#define PHY_BB_POWERTX_RATE9_POWERTX_DUP40_CCK_LSB                                                     0
-#define PHY_BB_POWERTX_RATE9_POWERTX_DUP40_CCK_MASK                                           0x0000003f
-#define PHY_BB_POWERTX_RATE9_POWERTX_DUP40_CCK_GET(x)                          (((x) & 0x0000003f) >> 0)
-#define PHY_BB_POWERTX_RATE9_POWERTX_DUP40_CCK_SET(x)                          (((x) << 0) & 0x0000003f)
-#define PHY_BB_POWERTX_RATE9_POWERTX_DUP40_OFDM_MSB                                                   13
-#define PHY_BB_POWERTX_RATE9_POWERTX_DUP40_OFDM_LSB                                                    8
-#define PHY_BB_POWERTX_RATE9_POWERTX_DUP40_OFDM_MASK                                          0x00003f00
-#define PHY_BB_POWERTX_RATE9_POWERTX_DUP40_OFDM_GET(x)                         (((x) & 0x00003f00) >> 8)
-#define PHY_BB_POWERTX_RATE9_POWERTX_DUP40_OFDM_SET(x)                         (((x) << 8) & 0x00003f00)
-#define PHY_BB_POWERTX_RATE9_POWERTX_EXT20_CCK_MSB                                                    21
-#define PHY_BB_POWERTX_RATE9_POWERTX_EXT20_CCK_LSB                                                    16
-#define PHY_BB_POWERTX_RATE9_POWERTX_EXT20_CCK_MASK                                           0x003f0000
-#define PHY_BB_POWERTX_RATE9_POWERTX_EXT20_CCK_GET(x)                         (((x) & 0x003f0000) >> 16)
-#define PHY_BB_POWERTX_RATE9_POWERTX_EXT20_CCK_SET(x)                         (((x) << 16) & 0x003f0000)
-#define PHY_BB_POWERTX_RATE9_POWERTX_EXT20_OFDM_MSB                                                   29
-#define PHY_BB_POWERTX_RATE9_POWERTX_EXT20_OFDM_LSB                                                   24
-#define PHY_BB_POWERTX_RATE9_POWERTX_EXT20_OFDM_MASK                                          0x3f000000
-#define PHY_BB_POWERTX_RATE9_POWERTX_EXT20_OFDM_GET(x)                        (((x) & 0x3f000000) >> 24)
-#define PHY_BB_POWERTX_RATE9_POWERTX_EXT20_OFDM_SET(x)                        (((x) << 24) & 0x3f000000)
-
-/* macros for BB_powertx_rate10 */
-#define PHY_BB_POWERTX_RATE10_ADDRESS                                                         0x0000a3cc
-#define PHY_BB_POWERTX_RATE10_OFFSET                                                          0x0000a3cc
-#define PHY_BB_POWERTX_RATE10_POWERTXHT20_8_MSB                                                        5
-#define PHY_BB_POWERTX_RATE10_POWERTXHT20_8_LSB                                                        0
-#define PHY_BB_POWERTX_RATE10_POWERTXHT20_8_MASK                                              0x0000003f
-#define PHY_BB_POWERTX_RATE10_POWERTXHT20_8_GET(x)                             (((x) & 0x0000003f) >> 0)
-#define PHY_BB_POWERTX_RATE10_POWERTXHT20_8_SET(x)                             (((x) << 0) & 0x0000003f)
-#define PHY_BB_POWERTX_RATE10_POWERTXHT20_9_MSB                                                       13
-#define PHY_BB_POWERTX_RATE10_POWERTXHT20_9_LSB                                                        8
-#define PHY_BB_POWERTX_RATE10_POWERTXHT20_9_MASK                                              0x00003f00
-#define PHY_BB_POWERTX_RATE10_POWERTXHT20_9_GET(x)                             (((x) & 0x00003f00) >> 8)
-#define PHY_BB_POWERTX_RATE10_POWERTXHT20_9_SET(x)                             (((x) << 8) & 0x00003f00)
-#define PHY_BB_POWERTX_RATE10_POWERTXHT20_10_MSB                                                      21
-#define PHY_BB_POWERTX_RATE10_POWERTXHT20_10_LSB                                                      16
-#define PHY_BB_POWERTX_RATE10_POWERTXHT20_10_MASK                                             0x003f0000
-#define PHY_BB_POWERTX_RATE10_POWERTXHT20_10_GET(x)                           (((x) & 0x003f0000) >> 16)
-#define PHY_BB_POWERTX_RATE10_POWERTXHT20_10_SET(x)                           (((x) << 16) & 0x003f0000)
-#define PHY_BB_POWERTX_RATE10_POWERTXHT20_11_MSB                                                      29
-#define PHY_BB_POWERTX_RATE10_POWERTXHT20_11_LSB                                                      24
-#define PHY_BB_POWERTX_RATE10_POWERTXHT20_11_MASK                                             0x3f000000
-#define PHY_BB_POWERTX_RATE10_POWERTXHT20_11_GET(x)                           (((x) & 0x3f000000) >> 24)
-#define PHY_BB_POWERTX_RATE10_POWERTXHT20_11_SET(x)                           (((x) << 24) & 0x3f000000)
-
-/* macros for BB_powertx_rate11 */
-#define PHY_BB_POWERTX_RATE11_ADDRESS                                                         0x0000a3d0
-#define PHY_BB_POWERTX_RATE11_OFFSET                                                          0x0000a3d0
-#define PHY_BB_POWERTX_RATE11_POWERTXHT20_12_MSB                                                       5
-#define PHY_BB_POWERTX_RATE11_POWERTXHT20_12_LSB                                                       0
-#define PHY_BB_POWERTX_RATE11_POWERTXHT20_12_MASK                                             0x0000003f
-#define PHY_BB_POWERTX_RATE11_POWERTXHT20_12_GET(x)                            (((x) & 0x0000003f) >> 0)
-#define PHY_BB_POWERTX_RATE11_POWERTXHT20_12_SET(x)                            (((x) << 0) & 0x0000003f)
-#define PHY_BB_POWERTX_RATE11_POWERTXHT20_13_MSB                                                      13
-#define PHY_BB_POWERTX_RATE11_POWERTXHT20_13_LSB                                                       8
-#define PHY_BB_POWERTX_RATE11_POWERTXHT20_13_MASK                                             0x00003f00
-#define PHY_BB_POWERTX_RATE11_POWERTXHT20_13_GET(x)                            (((x) & 0x00003f00) >> 8)
-#define PHY_BB_POWERTX_RATE11_POWERTXHT20_13_SET(x)                            (((x) << 8) & 0x00003f00)
-#define PHY_BB_POWERTX_RATE11_POWERTXHT40_12_MSB                                                      21
-#define PHY_BB_POWERTX_RATE11_POWERTXHT40_12_LSB                                                      16
-#define PHY_BB_POWERTX_RATE11_POWERTXHT40_12_MASK                                             0x003f0000
-#define PHY_BB_POWERTX_RATE11_POWERTXHT40_12_GET(x)                           (((x) & 0x003f0000) >> 16)
-#define PHY_BB_POWERTX_RATE11_POWERTXHT40_12_SET(x)                           (((x) << 16) & 0x003f0000)
-#define PHY_BB_POWERTX_RATE11_POWERTXHT40_13_MSB                                                      29
-#define PHY_BB_POWERTX_RATE11_POWERTXHT40_13_LSB                                                      24
-#define PHY_BB_POWERTX_RATE11_POWERTXHT40_13_MASK                                             0x3f000000
-#define PHY_BB_POWERTX_RATE11_POWERTXHT40_13_GET(x)                           (((x) & 0x3f000000) >> 24)
-#define PHY_BB_POWERTX_RATE11_POWERTXHT40_13_SET(x)                           (((x) << 24) & 0x3f000000)
-
-/* macros for BB_powertx_rate12 */
-#define PHY_BB_POWERTX_RATE12_ADDRESS                                                         0x0000a3d4
-#define PHY_BB_POWERTX_RATE12_OFFSET                                                          0x0000a3d4
-#define PHY_BB_POWERTX_RATE12_POWERTXHT40_8_MSB                                                        5
-#define PHY_BB_POWERTX_RATE12_POWERTXHT40_8_LSB                                                        0
-#define PHY_BB_POWERTX_RATE12_POWERTXHT40_8_MASK                                              0x0000003f
-#define PHY_BB_POWERTX_RATE12_POWERTXHT40_8_GET(x)                             (((x) & 0x0000003f) >> 0)
-#define PHY_BB_POWERTX_RATE12_POWERTXHT40_8_SET(x)                             (((x) << 0) & 0x0000003f)
-#define PHY_BB_POWERTX_RATE12_POWERTXHT40_9_MSB                                                       13
-#define PHY_BB_POWERTX_RATE12_POWERTXHT40_9_LSB                                                        8
-#define PHY_BB_POWERTX_RATE12_POWERTXHT40_9_MASK                                              0x00003f00
-#define PHY_BB_POWERTX_RATE12_POWERTXHT40_9_GET(x)                             (((x) & 0x00003f00) >> 8)
-#define PHY_BB_POWERTX_RATE12_POWERTXHT40_9_SET(x)                             (((x) << 8) & 0x00003f00)
-#define PHY_BB_POWERTX_RATE12_POWERTXHT40_10_MSB                                                      21
-#define PHY_BB_POWERTX_RATE12_POWERTXHT40_10_LSB                                                      16
-#define PHY_BB_POWERTX_RATE12_POWERTXHT40_10_MASK                                             0x003f0000
-#define PHY_BB_POWERTX_RATE12_POWERTXHT40_10_GET(x)                           (((x) & 0x003f0000) >> 16)
-#define PHY_BB_POWERTX_RATE12_POWERTXHT40_10_SET(x)                           (((x) << 16) & 0x003f0000)
-#define PHY_BB_POWERTX_RATE12_POWERTXHT40_11_MSB                                                      29
-#define PHY_BB_POWERTX_RATE12_POWERTXHT40_11_LSB                                                      24
-#define PHY_BB_POWERTX_RATE12_POWERTXHT40_11_MASK                                             0x3f000000
-#define PHY_BB_POWERTX_RATE12_POWERTXHT40_11_GET(x)                           (((x) & 0x3f000000) >> 24)
-#define PHY_BB_POWERTX_RATE12_POWERTXHT40_11_SET(x)                           (((x) << 24) & 0x3f000000)
-
-/* macros for BB_force_analog */
-#define PHY_BB_FORCE_ANALOG_ADDRESS                                                           0x0000a3d8
-#define PHY_BB_FORCE_ANALOG_OFFSET                                                            0x0000a3d8
-#define PHY_BB_FORCE_ANALOG_FORCE_XPAON_MSB                                                            0
-#define PHY_BB_FORCE_ANALOG_FORCE_XPAON_LSB                                                            0
-#define PHY_BB_FORCE_ANALOG_FORCE_XPAON_MASK                                                  0x00000001
-#define PHY_BB_FORCE_ANALOG_FORCE_XPAON_GET(x)                                 (((x) & 0x00000001) >> 0)
-#define PHY_BB_FORCE_ANALOG_FORCE_XPAON_SET(x)                                 (((x) << 0) & 0x00000001)
-#define PHY_BB_FORCE_ANALOG_FORCED_XPAON_MSB                                                           3
-#define PHY_BB_FORCE_ANALOG_FORCED_XPAON_LSB                                                           1
-#define PHY_BB_FORCE_ANALOG_FORCED_XPAON_MASK                                                 0x0000000e
-#define PHY_BB_FORCE_ANALOG_FORCED_XPAON_GET(x)                                (((x) & 0x0000000e) >> 1)
-#define PHY_BB_FORCE_ANALOG_FORCED_XPAON_SET(x)                                (((x) << 1) & 0x0000000e)
-#define PHY_BB_FORCE_ANALOG_FORCE_PDADC_PWD_MSB                                                        4
-#define PHY_BB_FORCE_ANALOG_FORCE_PDADC_PWD_LSB                                                        4
-#define PHY_BB_FORCE_ANALOG_FORCE_PDADC_PWD_MASK                                              0x00000010
-#define PHY_BB_FORCE_ANALOG_FORCE_PDADC_PWD_GET(x)                             (((x) & 0x00000010) >> 4)
-#define PHY_BB_FORCE_ANALOG_FORCE_PDADC_PWD_SET(x)                             (((x) << 4) & 0x00000010)
-#define PHY_BB_FORCE_ANALOG_FORCED_PDADC_PWD_MSB                                                       7
-#define PHY_BB_FORCE_ANALOG_FORCED_PDADC_PWD_LSB                                                       5
-#define PHY_BB_FORCE_ANALOG_FORCED_PDADC_PWD_MASK                                             0x000000e0
-#define PHY_BB_FORCE_ANALOG_FORCED_PDADC_PWD_GET(x)                            (((x) & 0x000000e0) >> 5)
-#define PHY_BB_FORCE_ANALOG_FORCED_PDADC_PWD_SET(x)                            (((x) << 5) & 0x000000e0)
-
-/* macros for BB_tpc_12 */
-#define PHY_BB_TPC_12_ADDRESS                                                                 0x0000a3dc
-#define PHY_BB_TPC_12_OFFSET                                                                  0x0000a3dc
-#define PHY_BB_TPC_12_DESIRED_SCALE_HT40_0_MSB                                                         4
-#define PHY_BB_TPC_12_DESIRED_SCALE_HT40_0_LSB                                                         0
-#define PHY_BB_TPC_12_DESIRED_SCALE_HT40_0_MASK                                               0x0000001f
-#define PHY_BB_TPC_12_DESIRED_SCALE_HT40_0_GET(x)                              (((x) & 0x0000001f) >> 0)
-#define PHY_BB_TPC_12_DESIRED_SCALE_HT40_0_SET(x)                              (((x) << 0) & 0x0000001f)
-#define PHY_BB_TPC_12_DESIRED_SCALE_HT40_1_MSB                                                         9
-#define PHY_BB_TPC_12_DESIRED_SCALE_HT40_1_LSB                                                         5
-#define PHY_BB_TPC_12_DESIRED_SCALE_HT40_1_MASK                                               0x000003e0
-#define PHY_BB_TPC_12_DESIRED_SCALE_HT40_1_GET(x)                              (((x) & 0x000003e0) >> 5)
-#define PHY_BB_TPC_12_DESIRED_SCALE_HT40_1_SET(x)                              (((x) << 5) & 0x000003e0)
-#define PHY_BB_TPC_12_DESIRED_SCALE_HT40_2_MSB                                                        14
-#define PHY_BB_TPC_12_DESIRED_SCALE_HT40_2_LSB                                                        10
-#define PHY_BB_TPC_12_DESIRED_SCALE_HT40_2_MASK                                               0x00007c00
-#define PHY_BB_TPC_12_DESIRED_SCALE_HT40_2_GET(x)                             (((x) & 0x00007c00) >> 10)
-#define PHY_BB_TPC_12_DESIRED_SCALE_HT40_2_SET(x)                             (((x) << 10) & 0x00007c00)
-#define PHY_BB_TPC_12_DESIRED_SCALE_HT40_3_MSB                                                        19
-#define PHY_BB_TPC_12_DESIRED_SCALE_HT40_3_LSB                                                        15
-#define PHY_BB_TPC_12_DESIRED_SCALE_HT40_3_MASK                                               0x000f8000
-#define PHY_BB_TPC_12_DESIRED_SCALE_HT40_3_GET(x)                             (((x) & 0x000f8000) >> 15)
-#define PHY_BB_TPC_12_DESIRED_SCALE_HT40_3_SET(x)                             (((x) << 15) & 0x000f8000)
-#define PHY_BB_TPC_12_DESIRED_SCALE_HT40_4_MSB                                                        24
-#define PHY_BB_TPC_12_DESIRED_SCALE_HT40_4_LSB                                                        20
-#define PHY_BB_TPC_12_DESIRED_SCALE_HT40_4_MASK                                               0x01f00000
-#define PHY_BB_TPC_12_DESIRED_SCALE_HT40_4_GET(x)                             (((x) & 0x01f00000) >> 20)
-#define PHY_BB_TPC_12_DESIRED_SCALE_HT40_4_SET(x)                             (((x) << 20) & 0x01f00000)
-#define PHY_BB_TPC_12_DESIRED_SCALE_HT40_5_MSB                                                        29
-#define PHY_BB_TPC_12_DESIRED_SCALE_HT40_5_LSB                                                        25
-#define PHY_BB_TPC_12_DESIRED_SCALE_HT40_5_MASK                                               0x3e000000
-#define PHY_BB_TPC_12_DESIRED_SCALE_HT40_5_GET(x)                             (((x) & 0x3e000000) >> 25)
-#define PHY_BB_TPC_12_DESIRED_SCALE_HT40_5_SET(x)                             (((x) << 25) & 0x3e000000)
-
-/* macros for BB_tpc_13 */
-#define PHY_BB_TPC_13_ADDRESS                                                                 0x0000a3e0
-#define PHY_BB_TPC_13_OFFSET                                                                  0x0000a3e0
-#define PHY_BB_TPC_13_DESIRED_SCALE_HT40_6_MSB                                                         4
-#define PHY_BB_TPC_13_DESIRED_SCALE_HT40_6_LSB                                                         0
-#define PHY_BB_TPC_13_DESIRED_SCALE_HT40_6_MASK                                               0x0000001f
-#define PHY_BB_TPC_13_DESIRED_SCALE_HT40_6_GET(x)                              (((x) & 0x0000001f) >> 0)
-#define PHY_BB_TPC_13_DESIRED_SCALE_HT40_6_SET(x)                              (((x) << 0) & 0x0000001f)
-#define PHY_BB_TPC_13_DESIRED_SCALE_HT40_7_MSB                                                         9
-#define PHY_BB_TPC_13_DESIRED_SCALE_HT40_7_LSB                                                         5
-#define PHY_BB_TPC_13_DESIRED_SCALE_HT40_7_MASK                                               0x000003e0
-#define PHY_BB_TPC_13_DESIRED_SCALE_HT40_7_GET(x)                              (((x) & 0x000003e0) >> 5)
-#define PHY_BB_TPC_13_DESIRED_SCALE_HT40_7_SET(x)                              (((x) << 5) & 0x000003e0)
-
-/* macros for BB_tpc_14 */
-#define PHY_BB_TPC_14_ADDRESS                                                                 0x0000a3e4
-#define PHY_BB_TPC_14_OFFSET                                                                  0x0000a3e4
-#define PHY_BB_TPC_14_DESIRED_SCALE_HT20_8_MSB                                                         4
-#define PHY_BB_TPC_14_DESIRED_SCALE_HT20_8_LSB                                                         0
-#define PHY_BB_TPC_14_DESIRED_SCALE_HT20_8_MASK                                               0x0000001f
-#define PHY_BB_TPC_14_DESIRED_SCALE_HT20_8_GET(x)                              (((x) & 0x0000001f) >> 0)
-#define PHY_BB_TPC_14_DESIRED_SCALE_HT20_8_SET(x)                              (((x) << 0) & 0x0000001f)
-#define PHY_BB_TPC_14_DESIRED_SCALE_HT20_9_MSB                                                         9
-#define PHY_BB_TPC_14_DESIRED_SCALE_HT20_9_LSB                                                         5
-#define PHY_BB_TPC_14_DESIRED_SCALE_HT20_9_MASK                                               0x000003e0
-#define PHY_BB_TPC_14_DESIRED_SCALE_HT20_9_GET(x)                              (((x) & 0x000003e0) >> 5)
-#define PHY_BB_TPC_14_DESIRED_SCALE_HT20_9_SET(x)                              (((x) << 5) & 0x000003e0)
-#define PHY_BB_TPC_14_DESIRED_SCALE_HT20_10_MSB                                                       14
-#define PHY_BB_TPC_14_DESIRED_SCALE_HT20_10_LSB                                                       10
-#define PHY_BB_TPC_14_DESIRED_SCALE_HT20_10_MASK                                              0x00007c00
-#define PHY_BB_TPC_14_DESIRED_SCALE_HT20_10_GET(x)                            (((x) & 0x00007c00) >> 10)
-#define PHY_BB_TPC_14_DESIRED_SCALE_HT20_10_SET(x)                            (((x) << 10) & 0x00007c00)
-#define PHY_BB_TPC_14_DESIRED_SCALE_HT20_11_MSB                                                       19
-#define PHY_BB_TPC_14_DESIRED_SCALE_HT20_11_LSB                                                       15
-#define PHY_BB_TPC_14_DESIRED_SCALE_HT20_11_MASK                                              0x000f8000
-#define PHY_BB_TPC_14_DESIRED_SCALE_HT20_11_GET(x)                            (((x) & 0x000f8000) >> 15)
-#define PHY_BB_TPC_14_DESIRED_SCALE_HT20_11_SET(x)                            (((x) << 15) & 0x000f8000)
-#define PHY_BB_TPC_14_DESIRED_SCALE_HT20_12_MSB                                                       24
-#define PHY_BB_TPC_14_DESIRED_SCALE_HT20_12_LSB                                                       20
-#define PHY_BB_TPC_14_DESIRED_SCALE_HT20_12_MASK                                              0x01f00000
-#define PHY_BB_TPC_14_DESIRED_SCALE_HT20_12_GET(x)                            (((x) & 0x01f00000) >> 20)
-#define PHY_BB_TPC_14_DESIRED_SCALE_HT20_12_SET(x)                            (((x) << 20) & 0x01f00000)
-#define PHY_BB_TPC_14_DESIRED_SCALE_HT20_13_MSB                                                       29
-#define PHY_BB_TPC_14_DESIRED_SCALE_HT20_13_LSB                                                       25
-#define PHY_BB_TPC_14_DESIRED_SCALE_HT20_13_MASK                                              0x3e000000
-#define PHY_BB_TPC_14_DESIRED_SCALE_HT20_13_GET(x)                            (((x) & 0x3e000000) >> 25)
-#define PHY_BB_TPC_14_DESIRED_SCALE_HT20_13_SET(x)                            (((x) << 25) & 0x3e000000)
-
-/* macros for BB_tpc_15 */
-#define PHY_BB_TPC_15_ADDRESS                                                                 0x0000a3e8
-#define PHY_BB_TPC_15_OFFSET                                                                  0x0000a3e8
-#define PHY_BB_TPC_15_DESIRED_SCALE_HT40_8_MSB                                                         4
-#define PHY_BB_TPC_15_DESIRED_SCALE_HT40_8_LSB                                                         0
-#define PHY_BB_TPC_15_DESIRED_SCALE_HT40_8_MASK                                               0x0000001f
-#define PHY_BB_TPC_15_DESIRED_SCALE_HT40_8_GET(x)                              (((x) & 0x0000001f) >> 0)
-#define PHY_BB_TPC_15_DESIRED_SCALE_HT40_8_SET(x)                              (((x) << 0) & 0x0000001f)
-#define PHY_BB_TPC_15_DESIRED_SCALE_HT40_9_MSB                                                         9
-#define PHY_BB_TPC_15_DESIRED_SCALE_HT40_9_LSB                                                         5
-#define PHY_BB_TPC_15_DESIRED_SCALE_HT40_9_MASK                                               0x000003e0
-#define PHY_BB_TPC_15_DESIRED_SCALE_HT40_9_GET(x)                              (((x) & 0x000003e0) >> 5)
-#define PHY_BB_TPC_15_DESIRED_SCALE_HT40_9_SET(x)                              (((x) << 5) & 0x000003e0)
-#define PHY_BB_TPC_15_DESIRED_SCALE_HT40_10_MSB                                                       14
-#define PHY_BB_TPC_15_DESIRED_SCALE_HT40_10_LSB                                                       10
-#define PHY_BB_TPC_15_DESIRED_SCALE_HT40_10_MASK                                              0x00007c00
-#define PHY_BB_TPC_15_DESIRED_SCALE_HT40_10_GET(x)                            (((x) & 0x00007c00) >> 10)
-#define PHY_BB_TPC_15_DESIRED_SCALE_HT40_10_SET(x)                            (((x) << 10) & 0x00007c00)
-#define PHY_BB_TPC_15_DESIRED_SCALE_HT40_11_MSB                                                       19
-#define PHY_BB_TPC_15_DESIRED_SCALE_HT40_11_LSB                                                       15
-#define PHY_BB_TPC_15_DESIRED_SCALE_HT40_11_MASK                                              0x000f8000
-#define PHY_BB_TPC_15_DESIRED_SCALE_HT40_11_GET(x)                            (((x) & 0x000f8000) >> 15)
-#define PHY_BB_TPC_15_DESIRED_SCALE_HT40_11_SET(x)                            (((x) << 15) & 0x000f8000)
-#define PHY_BB_TPC_15_DESIRED_SCALE_HT40_12_MSB                                                       24
-#define PHY_BB_TPC_15_DESIRED_SCALE_HT40_12_LSB                                                       20
-#define PHY_BB_TPC_15_DESIRED_SCALE_HT40_12_MASK                                              0x01f00000
-#define PHY_BB_TPC_15_DESIRED_SCALE_HT40_12_GET(x)                            (((x) & 0x01f00000) >> 20)
-#define PHY_BB_TPC_15_DESIRED_SCALE_HT40_12_SET(x)                            (((x) << 20) & 0x01f00000)
-#define PHY_BB_TPC_15_DESIRED_SCALE_HT40_13_MSB                                                       29
-#define PHY_BB_TPC_15_DESIRED_SCALE_HT40_13_LSB                                                       25
-#define PHY_BB_TPC_15_DESIRED_SCALE_HT40_13_MASK                                              0x3e000000
-#define PHY_BB_TPC_15_DESIRED_SCALE_HT40_13_GET(x)                            (((x) & 0x3e000000) >> 25)
-#define PHY_BB_TPC_15_DESIRED_SCALE_HT40_13_SET(x)                            (((x) << 25) & 0x3e000000)
-
-/* macros for BB_tpc_16 */
-#define PHY_BB_TPC_16_ADDRESS                                                                 0x0000a3ec
-#define PHY_BB_TPC_16_OFFSET                                                                  0x0000a3ec
-#define PHY_BB_TPC_16_PDADC_PAR_CORR_CCK_MSB                                                          13
-#define PHY_BB_TPC_16_PDADC_PAR_CORR_CCK_LSB                                                           8
-#define PHY_BB_TPC_16_PDADC_PAR_CORR_CCK_MASK                                                 0x00003f00
-#define PHY_BB_TPC_16_PDADC_PAR_CORR_CCK_GET(x)                                (((x) & 0x00003f00) >> 8)
-#define PHY_BB_TPC_16_PDADC_PAR_CORR_CCK_SET(x)                                (((x) << 8) & 0x00003f00)
-#define PHY_BB_TPC_16_PDADC_PAR_CORR_OFDM_MSB                                                         21
-#define PHY_BB_TPC_16_PDADC_PAR_CORR_OFDM_LSB                                                         16
-#define PHY_BB_TPC_16_PDADC_PAR_CORR_OFDM_MASK                                                0x003f0000
-#define PHY_BB_TPC_16_PDADC_PAR_CORR_OFDM_GET(x)                              (((x) & 0x003f0000) >> 16)
-#define PHY_BB_TPC_16_PDADC_PAR_CORR_OFDM_SET(x)                              (((x) << 16) & 0x003f0000)
-#define PHY_BB_TPC_16_PDADC_PAR_CORR_HT40_MSB                                                         29
-#define PHY_BB_TPC_16_PDADC_PAR_CORR_HT40_LSB                                                         24
-#define PHY_BB_TPC_16_PDADC_PAR_CORR_HT40_MASK                                                0x3f000000
-#define PHY_BB_TPC_16_PDADC_PAR_CORR_HT40_GET(x)                              (((x) & 0x3f000000) >> 24)
-#define PHY_BB_TPC_16_PDADC_PAR_CORR_HT40_SET(x)                              (((x) << 24) & 0x3f000000)
-
-/* macros for BB_tpc_17 */
-#define PHY_BB_TPC_17_ADDRESS                                                                 0x0000a3f0
-#define PHY_BB_TPC_17_OFFSET                                                                  0x0000a3f0
-#define PHY_BB_TPC_17_ENABLE_PAL_MSB                                                                   0
-#define PHY_BB_TPC_17_ENABLE_PAL_LSB                                                                   0
-#define PHY_BB_TPC_17_ENABLE_PAL_MASK                                                         0x00000001
-#define PHY_BB_TPC_17_ENABLE_PAL_GET(x)                                        (((x) & 0x00000001) >> 0)
-#define PHY_BB_TPC_17_ENABLE_PAL_SET(x)                                        (((x) << 0) & 0x00000001)
-#define PHY_BB_TPC_17_ENABLE_PAL_CCK_MSB                                                               1
-#define PHY_BB_TPC_17_ENABLE_PAL_CCK_LSB                                                               1
-#define PHY_BB_TPC_17_ENABLE_PAL_CCK_MASK                                                     0x00000002
-#define PHY_BB_TPC_17_ENABLE_PAL_CCK_GET(x)                                    (((x) & 0x00000002) >> 1)
-#define PHY_BB_TPC_17_ENABLE_PAL_CCK_SET(x)                                    (((x) << 1) & 0x00000002)
-#define PHY_BB_TPC_17_ENABLE_PAL_OFDM_20_MSB                                                           2
-#define PHY_BB_TPC_17_ENABLE_PAL_OFDM_20_LSB                                                           2
-#define PHY_BB_TPC_17_ENABLE_PAL_OFDM_20_MASK                                                 0x00000004
-#define PHY_BB_TPC_17_ENABLE_PAL_OFDM_20_GET(x)                                (((x) & 0x00000004) >> 2)
-#define PHY_BB_TPC_17_ENABLE_PAL_OFDM_20_SET(x)                                (((x) << 2) & 0x00000004)
-#define PHY_BB_TPC_17_ENABLE_PAL_OFDM_40_MSB                                                           3
-#define PHY_BB_TPC_17_ENABLE_PAL_OFDM_40_LSB                                                           3
-#define PHY_BB_TPC_17_ENABLE_PAL_OFDM_40_MASK                                                 0x00000008
-#define PHY_BB_TPC_17_ENABLE_PAL_OFDM_40_GET(x)                                (((x) & 0x00000008) >> 3)
-#define PHY_BB_TPC_17_ENABLE_PAL_OFDM_40_SET(x)                                (((x) << 3) & 0x00000008)
-#define PHY_BB_TPC_17_PAL_POWER_THRESHOLD_MSB                                                          9
-#define PHY_BB_TPC_17_PAL_POWER_THRESHOLD_LSB                                                          4
-#define PHY_BB_TPC_17_PAL_POWER_THRESHOLD_MASK                                                0x000003f0
-#define PHY_BB_TPC_17_PAL_POWER_THRESHOLD_GET(x)                               (((x) & 0x000003f0) >> 4)
-#define PHY_BB_TPC_17_PAL_POWER_THRESHOLD_SET(x)                               (((x) << 4) & 0x000003f0)
-#define PHY_BB_TPC_17_FORCE_PAL_LOCKED_MSB                                                            10
-#define PHY_BB_TPC_17_FORCE_PAL_LOCKED_LSB                                                            10
-#define PHY_BB_TPC_17_FORCE_PAL_LOCKED_MASK                                                   0x00000400
-#define PHY_BB_TPC_17_FORCE_PAL_LOCKED_GET(x)                                 (((x) & 0x00000400) >> 10)
-#define PHY_BB_TPC_17_FORCE_PAL_LOCKED_SET(x)                                 (((x) << 10) & 0x00000400)
-#define PHY_BB_TPC_17_INIT_TX_GAIN_SETTING_PAL_ON_MSB                                                 16
-#define PHY_BB_TPC_17_INIT_TX_GAIN_SETTING_PAL_ON_LSB                                                 11
-#define PHY_BB_TPC_17_INIT_TX_GAIN_SETTING_PAL_ON_MASK                                        0x0001f800
-#define PHY_BB_TPC_17_INIT_TX_GAIN_SETTING_PAL_ON_GET(x)                      (((x) & 0x0001f800) >> 11)
-#define PHY_BB_TPC_17_INIT_TX_GAIN_SETTING_PAL_ON_SET(x)                      (((x) << 11) & 0x0001f800)
-
-/* macros for BB_tpc_18 */
-#define PHY_BB_TPC_18_ADDRESS                                                                 0x0000a3f4
-#define PHY_BB_TPC_18_OFFSET                                                                  0x0000a3f4
-#define PHY_BB_TPC_18_THERM_CAL_VALUE_MSB                                                              7
-#define PHY_BB_TPC_18_THERM_CAL_VALUE_LSB                                                              0
-#define PHY_BB_TPC_18_THERM_CAL_VALUE_MASK                                                    0x000000ff
-#define PHY_BB_TPC_18_THERM_CAL_VALUE_GET(x)                                   (((x) & 0x000000ff) >> 0)
-#define PHY_BB_TPC_18_THERM_CAL_VALUE_SET(x)                                   (((x) << 0) & 0x000000ff)
-#define PHY_BB_TPC_18_VOLT_CAL_VALUE_MSB                                                              15
-#define PHY_BB_TPC_18_VOLT_CAL_VALUE_LSB                                                               8
-#define PHY_BB_TPC_18_VOLT_CAL_VALUE_MASK                                                     0x0000ff00
-#define PHY_BB_TPC_18_VOLT_CAL_VALUE_GET(x)                                    (((x) & 0x0000ff00) >> 8)
-#define PHY_BB_TPC_18_VOLT_CAL_VALUE_SET(x)                                    (((x) << 8) & 0x0000ff00)
-#define PHY_BB_TPC_18_USE_LEGACY_TPC_MSB                                                              16
-#define PHY_BB_TPC_18_USE_LEGACY_TPC_LSB                                                              16
-#define PHY_BB_TPC_18_USE_LEGACY_TPC_MASK                                                     0x00010000
-#define PHY_BB_TPC_18_USE_LEGACY_TPC_GET(x)                                   (((x) & 0x00010000) >> 16)
-#define PHY_BB_TPC_18_USE_LEGACY_TPC_SET(x)                                   (((x) << 16) & 0x00010000)
-
-/* macros for BB_tpc_19 */
-#define PHY_BB_TPC_19_ADDRESS                                                                 0x0000a3f8
-#define PHY_BB_TPC_19_OFFSET                                                                  0x0000a3f8
-#define PHY_BB_TPC_19_ALPHA_THERM_MSB                                                                  7
-#define PHY_BB_TPC_19_ALPHA_THERM_LSB                                                                  0
-#define PHY_BB_TPC_19_ALPHA_THERM_MASK                                                        0x000000ff
-#define PHY_BB_TPC_19_ALPHA_THERM_GET(x)                                       (((x) & 0x000000ff) >> 0)
-#define PHY_BB_TPC_19_ALPHA_THERM_SET(x)                                       (((x) << 0) & 0x000000ff)
-#define PHY_BB_TPC_19_ALPHA_THERM_PAL_ON_MSB                                                          15
-#define PHY_BB_TPC_19_ALPHA_THERM_PAL_ON_LSB                                                           8
-#define PHY_BB_TPC_19_ALPHA_THERM_PAL_ON_MASK                                                 0x0000ff00
-#define PHY_BB_TPC_19_ALPHA_THERM_PAL_ON_GET(x)                                (((x) & 0x0000ff00) >> 8)
-#define PHY_BB_TPC_19_ALPHA_THERM_PAL_ON_SET(x)                                (((x) << 8) & 0x0000ff00)
-#define PHY_BB_TPC_19_ALPHA_VOLT_MSB                                                                  20
-#define PHY_BB_TPC_19_ALPHA_VOLT_LSB                                                                  16
-#define PHY_BB_TPC_19_ALPHA_VOLT_MASK                                                         0x001f0000
-#define PHY_BB_TPC_19_ALPHA_VOLT_GET(x)                                       (((x) & 0x001f0000) >> 16)
-#define PHY_BB_TPC_19_ALPHA_VOLT_SET(x)                                       (((x) << 16) & 0x001f0000)
-#define PHY_BB_TPC_19_ALPHA_VOLT_PAL_ON_MSB                                                           25
-#define PHY_BB_TPC_19_ALPHA_VOLT_PAL_ON_LSB                                                           21
-#define PHY_BB_TPC_19_ALPHA_VOLT_PAL_ON_MASK                                                  0x03e00000
-#define PHY_BB_TPC_19_ALPHA_VOLT_PAL_ON_GET(x)                                (((x) & 0x03e00000) >> 21)
-#define PHY_BB_TPC_19_ALPHA_VOLT_PAL_ON_SET(x)                                (((x) << 21) & 0x03e00000)
-
-/* macros for BB_tpc_20 */
-#define PHY_BB_TPC_20_ADDRESS                                                                 0x0000a3fc
-#define PHY_BB_TPC_20_OFFSET                                                                  0x0000a3fc
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_0_MSB                                                             0
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_0_LSB                                                             0
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_0_MASK                                                   0x00000001
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_0_GET(x)                                  (((x) & 0x00000001) >> 0)
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_0_SET(x)                                  (((x) << 0) & 0x00000001)
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_1_MSB                                                             1
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_1_LSB                                                             1
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_1_MASK                                                   0x00000002
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_1_GET(x)                                  (((x) & 0x00000002) >> 1)
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_1_SET(x)                                  (((x) << 1) & 0x00000002)
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_2_MSB                                                             2
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_2_LSB                                                             2
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_2_MASK                                                   0x00000004
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_2_GET(x)                                  (((x) & 0x00000004) >> 2)
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_2_SET(x)                                  (((x) << 2) & 0x00000004)
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_3_MSB                                                             3
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_3_LSB                                                             3
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_3_MASK                                                   0x00000008
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_3_GET(x)                                  (((x) & 0x00000008) >> 3)
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_3_SET(x)                                  (((x) << 3) & 0x00000008)
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_4_MSB                                                             4
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_4_LSB                                                             4
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_4_MASK                                                   0x00000010
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_4_GET(x)                                  (((x) & 0x00000010) >> 4)
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_4_SET(x)                                  (((x) << 4) & 0x00000010)
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_5_MSB                                                             5
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_5_LSB                                                             5
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_5_MASK                                                   0x00000020
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_5_GET(x)                                  (((x) & 0x00000020) >> 5)
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_5_SET(x)                                  (((x) << 5) & 0x00000020)
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_6_MSB                                                             6
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_6_LSB                                                             6
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_6_MASK                                                   0x00000040
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_6_GET(x)                                  (((x) & 0x00000040) >> 6)
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_6_SET(x)                                  (((x) << 6) & 0x00000040)
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_7_MSB                                                             7
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_7_LSB                                                             7
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_7_MASK                                                   0x00000080
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_7_GET(x)                                  (((x) & 0x00000080) >> 7)
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_7_SET(x)                                  (((x) << 7) & 0x00000080)
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_8_MSB                                                             8
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_8_LSB                                                             8
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_8_MASK                                                   0x00000100
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_8_GET(x)                                  (((x) & 0x00000100) >> 8)
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_8_SET(x)                                  (((x) << 8) & 0x00000100)
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_9_MSB                                                             9
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_9_LSB                                                             9
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_9_MASK                                                   0x00000200
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_9_GET(x)                                  (((x) & 0x00000200) >> 9)
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_9_SET(x)                                  (((x) << 9) & 0x00000200)
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_10_MSB                                                           10
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_10_LSB                                                           10
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_10_MASK                                                  0x00000400
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_10_GET(x)                                (((x) & 0x00000400) >> 10)
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_10_SET(x)                                (((x) << 10) & 0x00000400)
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_11_MSB                                                           11
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_11_LSB                                                           11
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_11_MASK                                                  0x00000800
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_11_GET(x)                                (((x) & 0x00000800) >> 11)
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_11_SET(x)                                (((x) << 11) & 0x00000800)
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_12_MSB                                                           12
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_12_LSB                                                           12
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_12_MASK                                                  0x00001000
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_12_GET(x)                                (((x) & 0x00001000) >> 12)
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_12_SET(x)                                (((x) << 12) & 0x00001000)
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_13_MSB                                                           13
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_13_LSB                                                           13
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_13_MASK                                                  0x00002000
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_13_GET(x)                                (((x) & 0x00002000) >> 13)
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_13_SET(x)                                (((x) << 13) & 0x00002000)
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_14_MSB                                                           14
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_14_LSB                                                           14
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_14_MASK                                                  0x00004000
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_14_GET(x)                                (((x) & 0x00004000) >> 14)
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_14_SET(x)                                (((x) << 14) & 0x00004000)
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_15_MSB                                                           15
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_15_LSB                                                           15
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_15_MASK                                                  0x00008000
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_15_GET(x)                                (((x) & 0x00008000) >> 15)
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_15_SET(x)                                (((x) << 15) & 0x00008000)
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_16_MSB                                                           16
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_16_LSB                                                           16
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_16_MASK                                                  0x00010000
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_16_GET(x)                                (((x) & 0x00010000) >> 16)
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_16_SET(x)                                (((x) << 16) & 0x00010000)
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_17_MSB                                                           17
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_17_LSB                                                           17
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_17_MASK                                                  0x00020000
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_17_GET(x)                                (((x) & 0x00020000) >> 17)
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_17_SET(x)                                (((x) << 17) & 0x00020000)
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_18_MSB                                                           18
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_18_LSB                                                           18
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_18_MASK                                                  0x00040000
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_18_GET(x)                                (((x) & 0x00040000) >> 18)
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_18_SET(x)                                (((x) << 18) & 0x00040000)
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_19_MSB                                                           19
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_19_LSB                                                           19
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_19_MASK                                                  0x00080000
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_19_GET(x)                                (((x) & 0x00080000) >> 19)
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_19_SET(x)                                (((x) << 19) & 0x00080000)
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_20_MSB                                                           20
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_20_LSB                                                           20
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_20_MASK                                                  0x00100000
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_20_GET(x)                                (((x) & 0x00100000) >> 20)
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_20_SET(x)                                (((x) << 20) & 0x00100000)
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_21_MSB                                                           21
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_21_LSB                                                           21
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_21_MASK                                                  0x00200000
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_21_GET(x)                                (((x) & 0x00200000) >> 21)
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_21_SET(x)                                (((x) << 21) & 0x00200000)
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_22_MSB                                                           22
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_22_LSB                                                           22
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_22_MASK                                                  0x00400000
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_22_GET(x)                                (((x) & 0x00400000) >> 22)
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_22_SET(x)                                (((x) << 22) & 0x00400000)
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_23_MSB                                                           23
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_23_LSB                                                           23
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_23_MASK                                                  0x00800000
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_23_GET(x)                                (((x) & 0x00800000) >> 23)
-#define PHY_BB_TPC_20_ENABLE_PAL_MCS_23_SET(x)                                (((x) << 23) & 0x00800000)
-
-/* macros for BB_tx_gain_tab_1 */
-#define PHY_BB_TX_GAIN_TAB_1_ADDRESS                                                          0x0000a400
-#define PHY_BB_TX_GAIN_TAB_1_OFFSET                                                           0x0000a400
-#define PHY_BB_TX_GAIN_TAB_1_TG_TABLE1_MSB                                                            31
-#define PHY_BB_TX_GAIN_TAB_1_TG_TABLE1_LSB                                                             0
-#define PHY_BB_TX_GAIN_TAB_1_TG_TABLE1_MASK                                                   0xffffffff
-#define PHY_BB_TX_GAIN_TAB_1_TG_TABLE1_GET(x)                                  (((x) & 0xffffffff) >> 0)
-#define PHY_BB_TX_GAIN_TAB_1_TG_TABLE1_SET(x)                                  (((x) << 0) & 0xffffffff)
-
-/* macros for BB_tx_gain_tab_2 */
-#define PHY_BB_TX_GAIN_TAB_2_ADDRESS                                                          0x0000a404
-#define PHY_BB_TX_GAIN_TAB_2_OFFSET                                                           0x0000a404
-#define PHY_BB_TX_GAIN_TAB_2_TG_TABLE2_MSB                                                            31
-#define PHY_BB_TX_GAIN_TAB_2_TG_TABLE2_LSB                                                             0
-#define PHY_BB_TX_GAIN_TAB_2_TG_TABLE2_MASK                                                   0xffffffff
-#define PHY_BB_TX_GAIN_TAB_2_TG_TABLE2_GET(x)                                  (((x) & 0xffffffff) >> 0)
-#define PHY_BB_TX_GAIN_TAB_2_TG_TABLE2_SET(x)                                  (((x) << 0) & 0xffffffff)
-
-/* macros for BB_tx_gain_tab_3 */
-#define PHY_BB_TX_GAIN_TAB_3_ADDRESS                                                          0x0000a408
-#define PHY_BB_TX_GAIN_TAB_3_OFFSET                                                           0x0000a408
-#define PHY_BB_TX_GAIN_TAB_3_TG_TABLE3_MSB                                                            31
-#define PHY_BB_TX_GAIN_TAB_3_TG_TABLE3_LSB                                                             0
-#define PHY_BB_TX_GAIN_TAB_3_TG_TABLE3_MASK                                                   0xffffffff
-#define PHY_BB_TX_GAIN_TAB_3_TG_TABLE3_GET(x)                                  (((x) & 0xffffffff) >> 0)
-#define PHY_BB_TX_GAIN_TAB_3_TG_TABLE3_SET(x)                                  (((x) << 0) & 0xffffffff)
-
-/* macros for BB_tx_gain_tab_4 */
-#define PHY_BB_TX_GAIN_TAB_4_ADDRESS                                                          0x0000a40c
-#define PHY_BB_TX_GAIN_TAB_4_OFFSET                                                           0x0000a40c
-#define PHY_BB_TX_GAIN_TAB_4_TG_TABLE4_MSB                                                            31
-#define PHY_BB_TX_GAIN_TAB_4_TG_TABLE4_LSB                                                             0
-#define PHY_BB_TX_GAIN_TAB_4_TG_TABLE4_MASK                                                   0xffffffff
-#define PHY_BB_TX_GAIN_TAB_4_TG_TABLE4_GET(x)                                  (((x) & 0xffffffff) >> 0)
-#define PHY_BB_TX_GAIN_TAB_4_TG_TABLE4_SET(x)                                  (((x) << 0) & 0xffffffff)
-
-/* macros for BB_tx_gain_tab_5 */
-#define PHY_BB_TX_GAIN_TAB_5_ADDRESS                                                          0x0000a410
-#define PHY_BB_TX_GAIN_TAB_5_OFFSET                                                           0x0000a410
-#define PHY_BB_TX_GAIN_TAB_5_TG_TABLE5_MSB                                                            31
-#define PHY_BB_TX_GAIN_TAB_5_TG_TABLE5_LSB                                                             0
-#define PHY_BB_TX_GAIN_TAB_5_TG_TABLE5_MASK                                                   0xffffffff
-#define PHY_BB_TX_GAIN_TAB_5_TG_TABLE5_GET(x)                                  (((x) & 0xffffffff) >> 0)
-#define PHY_BB_TX_GAIN_TAB_5_TG_TABLE5_SET(x)                                  (((x) << 0) & 0xffffffff)
-
-/* macros for BB_tx_gain_tab_6 */
-#define PHY_BB_TX_GAIN_TAB_6_ADDRESS                                                          0x0000a414
-#define PHY_BB_TX_GAIN_TAB_6_OFFSET                                                           0x0000a414
-#define PHY_BB_TX_GAIN_TAB_6_TG_TABLE6_MSB                                                            31
-#define PHY_BB_TX_GAIN_TAB_6_TG_TABLE6_LSB                                                             0
-#define PHY_BB_TX_GAIN_TAB_6_TG_TABLE6_MASK                                                   0xffffffff
-#define PHY_BB_TX_GAIN_TAB_6_TG_TABLE6_GET(x)                                  (((x) & 0xffffffff) >> 0)
-#define PHY_BB_TX_GAIN_TAB_6_TG_TABLE6_SET(x)                                  (((x) << 0) & 0xffffffff)
-
-/* macros for BB_tx_gain_tab_7 */
-#define PHY_BB_TX_GAIN_TAB_7_ADDRESS                                                          0x0000a418
-#define PHY_BB_TX_GAIN_TAB_7_OFFSET                                                           0x0000a418
-#define PHY_BB_TX_GAIN_TAB_7_TG_TABLE7_MSB                                                            31
-#define PHY_BB_TX_GAIN_TAB_7_TG_TABLE7_LSB                                                             0
-#define PHY_BB_TX_GAIN_TAB_7_TG_TABLE7_MASK                                                   0xffffffff
-#define PHY_BB_TX_GAIN_TAB_7_TG_TABLE7_GET(x)                                  (((x) & 0xffffffff) >> 0)
-#define PHY_BB_TX_GAIN_TAB_7_TG_TABLE7_SET(x)                                  (((x) << 0) & 0xffffffff)
-
-/* macros for BB_tx_gain_tab_8 */
-#define PHY_BB_TX_GAIN_TAB_8_ADDRESS                                                          0x0000a41c
-#define PHY_BB_TX_GAIN_TAB_8_OFFSET                                                           0x0000a41c
-#define PHY_BB_TX_GAIN_TAB_8_TG_TABLE8_MSB                                                            31
-#define PHY_BB_TX_GAIN_TAB_8_TG_TABLE8_LSB                                                             0
-#define PHY_BB_TX_GAIN_TAB_8_TG_TABLE8_MASK                                                   0xffffffff
-#define PHY_BB_TX_GAIN_TAB_8_TG_TABLE8_GET(x)                                  (((x) & 0xffffffff) >> 0)
-#define PHY_BB_TX_GAIN_TAB_8_TG_TABLE8_SET(x)                                  (((x) << 0) & 0xffffffff)
-
-/* macros for BB_tx_gain_tab_9 */
-#define PHY_BB_TX_GAIN_TAB_9_ADDRESS                                                          0x0000a420
-#define PHY_BB_TX_GAIN_TAB_9_OFFSET                                                           0x0000a420
-#define PHY_BB_TX_GAIN_TAB_9_TG_TABLE9_MSB                                                            31
-#define PHY_BB_TX_GAIN_TAB_9_TG_TABLE9_LSB                                                             0
-#define PHY_BB_TX_GAIN_TAB_9_TG_TABLE9_MASK                                                   0xffffffff
-#define PHY_BB_TX_GAIN_TAB_9_TG_TABLE9_GET(x)                                  (((x) & 0xffffffff) >> 0)
-#define PHY_BB_TX_GAIN_TAB_9_TG_TABLE9_SET(x)                                  (((x) << 0) & 0xffffffff)
-
-/* macros for BB_tx_gain_tab_10 */
-#define PHY_BB_TX_GAIN_TAB_10_ADDRESS                                                         0x0000a424
-#define PHY_BB_TX_GAIN_TAB_10_OFFSET                                                          0x0000a424
-#define PHY_BB_TX_GAIN_TAB_10_TG_TABLE10_MSB                                                          31
-#define PHY_BB_TX_GAIN_TAB_10_TG_TABLE10_LSB                                                           0
-#define PHY_BB_TX_GAIN_TAB_10_TG_TABLE10_MASK                                                 0xffffffff
-#define PHY_BB_TX_GAIN_TAB_10_TG_TABLE10_GET(x)                                (((x) & 0xffffffff) >> 0)
-#define PHY_BB_TX_GAIN_TAB_10_TG_TABLE10_SET(x)                                (((x) << 0) & 0xffffffff)
-
-/* macros for BB_tx_gain_tab_11 */
-#define PHY_BB_TX_GAIN_TAB_11_ADDRESS                                                         0x0000a428
-#define PHY_BB_TX_GAIN_TAB_11_OFFSET                                                          0x0000a428
-#define PHY_BB_TX_GAIN_TAB_11_TG_TABLE11_MSB                                                          31
-#define PHY_BB_TX_GAIN_TAB_11_TG_TABLE11_LSB                                                           0
-#define PHY_BB_TX_GAIN_TAB_11_TG_TABLE11_MASK                                                 0xffffffff
-#define PHY_BB_TX_GAIN_TAB_11_TG_TABLE11_GET(x)                                (((x) & 0xffffffff) >> 0)
-#define PHY_BB_TX_GAIN_TAB_11_TG_TABLE11_SET(x)                                (((x) << 0) & 0xffffffff)
-
-/* macros for BB_tx_gain_tab_12 */
-#define PHY_BB_TX_GAIN_TAB_12_ADDRESS                                                         0x0000a42c
-#define PHY_BB_TX_GAIN_TAB_12_OFFSET                                                          0x0000a42c
-#define PHY_BB_TX_GAIN_TAB_12_TG_TABLE12_MSB                                                          31
-#define PHY_BB_TX_GAIN_TAB_12_TG_TABLE12_LSB                                                           0
-#define PHY_BB_TX_GAIN_TAB_12_TG_TABLE12_MASK                                                 0xffffffff
-#define PHY_BB_TX_GAIN_TAB_12_TG_TABLE12_GET(x)                                (((x) & 0xffffffff) >> 0)
-#define PHY_BB_TX_GAIN_TAB_12_TG_TABLE12_SET(x)                                (((x) << 0) & 0xffffffff)
-
-/* macros for BB_tx_gain_tab_13 */
-#define PHY_BB_TX_GAIN_TAB_13_ADDRESS                                                         0x0000a430
-#define PHY_BB_TX_GAIN_TAB_13_OFFSET                                                          0x0000a430
-#define PHY_BB_TX_GAIN_TAB_13_TG_TABLE13_MSB                                                          31
-#define PHY_BB_TX_GAIN_TAB_13_TG_TABLE13_LSB                                                           0
-#define PHY_BB_TX_GAIN_TAB_13_TG_TABLE13_MASK                                                 0xffffffff
-#define PHY_BB_TX_GAIN_TAB_13_TG_TABLE13_GET(x)                                (((x) & 0xffffffff) >> 0)
-#define PHY_BB_TX_GAIN_TAB_13_TG_TABLE13_SET(x)                                (((x) << 0) & 0xffffffff)
-
-/* macros for BB_tx_gain_tab_14 */
-#define PHY_BB_TX_GAIN_TAB_14_ADDRESS                                                         0x0000a434
-#define PHY_BB_TX_GAIN_TAB_14_OFFSET                                                          0x0000a434
-#define PHY_BB_TX_GAIN_TAB_14_TG_TABLE14_MSB                                                          31
-#define PHY_BB_TX_GAIN_TAB_14_TG_TABLE14_LSB                                                           0
-#define PHY_BB_TX_GAIN_TAB_14_TG_TABLE14_MASK                                                 0xffffffff
-#define PHY_BB_TX_GAIN_TAB_14_TG_TABLE14_GET(x)                                (((x) & 0xffffffff) >> 0)
-#define PHY_BB_TX_GAIN_TAB_14_TG_TABLE14_SET(x)                                (((x) << 0) & 0xffffffff)
-
-/* macros for BB_tx_gain_tab_15 */
-#define PHY_BB_TX_GAIN_TAB_15_ADDRESS                                                         0x0000a438
-#define PHY_BB_TX_GAIN_TAB_15_OFFSET                                                          0x0000a438
-#define PHY_BB_TX_GAIN_TAB_15_TG_TABLE15_MSB                                                          31
-#define PHY_BB_TX_GAIN_TAB_15_TG_TABLE15_LSB                                                           0
-#define PHY_BB_TX_GAIN_TAB_15_TG_TABLE15_MASK                                                 0xffffffff
-#define PHY_BB_TX_GAIN_TAB_15_TG_TABLE15_GET(x)                                (((x) & 0xffffffff) >> 0)
-#define PHY_BB_TX_GAIN_TAB_15_TG_TABLE15_SET(x)                                (((x) << 0) & 0xffffffff)
-
-/* macros for BB_tx_gain_tab_16 */
-#define PHY_BB_TX_GAIN_TAB_16_ADDRESS                                                         0x0000a43c
-#define PHY_BB_TX_GAIN_TAB_16_OFFSET                                                          0x0000a43c
-#define PHY_BB_TX_GAIN_TAB_16_TG_TABLE16_MSB                                                          31
-#define PHY_BB_TX_GAIN_TAB_16_TG_TABLE16_LSB                                                           0
-#define PHY_BB_TX_GAIN_TAB_16_TG_TABLE16_MASK                                                 0xffffffff
-#define PHY_BB_TX_GAIN_TAB_16_TG_TABLE16_GET(x)                                (((x) & 0xffffffff) >> 0)
-#define PHY_BB_TX_GAIN_TAB_16_TG_TABLE16_SET(x)                                (((x) << 0) & 0xffffffff)
-
-/* macros for BB_tx_gain_tab_17 */
-#define PHY_BB_TX_GAIN_TAB_17_ADDRESS                                                         0x0000a440
-#define PHY_BB_TX_GAIN_TAB_17_OFFSET                                                          0x0000a440
-#define PHY_BB_TX_GAIN_TAB_17_TG_TABLE17_MSB                                                          31
-#define PHY_BB_TX_GAIN_TAB_17_TG_TABLE17_LSB                                                           0
-#define PHY_BB_TX_GAIN_TAB_17_TG_TABLE17_MASK                                                 0xffffffff
-#define PHY_BB_TX_GAIN_TAB_17_TG_TABLE17_GET(x)                                (((x) & 0xffffffff) >> 0)
-#define PHY_BB_TX_GAIN_TAB_17_TG_TABLE17_SET(x)                                (((x) << 0) & 0xffffffff)
-
-/* macros for BB_tx_gain_tab_18 */
-#define PHY_BB_TX_GAIN_TAB_18_ADDRESS                                                         0x0000a444
-#define PHY_BB_TX_GAIN_TAB_18_OFFSET                                                          0x0000a444
-#define PHY_BB_TX_GAIN_TAB_18_TG_TABLE18_MSB                                                          31
-#define PHY_BB_TX_GAIN_TAB_18_TG_TABLE18_LSB                                                           0
-#define PHY_BB_TX_GAIN_TAB_18_TG_TABLE18_MASK                                                 0xffffffff
-#define PHY_BB_TX_GAIN_TAB_18_TG_TABLE18_GET(x)                                (((x) & 0xffffffff) >> 0)
-#define PHY_BB_TX_GAIN_TAB_18_TG_TABLE18_SET(x)                                (((x) << 0) & 0xffffffff)
-
-/* macros for BB_tx_gain_tab_19 */
-#define PHY_BB_TX_GAIN_TAB_19_ADDRESS                                                         0x0000a448
-#define PHY_BB_TX_GAIN_TAB_19_OFFSET                                                          0x0000a448
-#define PHY_BB_TX_GAIN_TAB_19_TG_TABLE19_MSB                                                          31
-#define PHY_BB_TX_GAIN_TAB_19_TG_TABLE19_LSB                                                           0
-#define PHY_BB_TX_GAIN_TAB_19_TG_TABLE19_MASK                                                 0xffffffff
-#define PHY_BB_TX_GAIN_TAB_19_TG_TABLE19_GET(x)                                (((x) & 0xffffffff) >> 0)
-#define PHY_BB_TX_GAIN_TAB_19_TG_TABLE19_SET(x)                                (((x) << 0) & 0xffffffff)
-
-/* macros for BB_tx_gain_tab_20 */
-#define PHY_BB_TX_GAIN_TAB_20_ADDRESS                                                         0x0000a44c
-#define PHY_BB_TX_GAIN_TAB_20_OFFSET                                                          0x0000a44c
-#define PHY_BB_TX_GAIN_TAB_20_TG_TABLE20_MSB                                                          31
-#define PHY_BB_TX_GAIN_TAB_20_TG_TABLE20_LSB                                                           0
-#define PHY_BB_TX_GAIN_TAB_20_TG_TABLE20_MASK                                                 0xffffffff
-#define PHY_BB_TX_GAIN_TAB_20_TG_TABLE20_GET(x)                                (((x) & 0xffffffff) >> 0)
-#define PHY_BB_TX_GAIN_TAB_20_TG_TABLE20_SET(x)                                (((x) << 0) & 0xffffffff)
-
-/* macros for BB_tx_gain_tab_21 */
-#define PHY_BB_TX_GAIN_TAB_21_ADDRESS                                                         0x0000a450
-#define PHY_BB_TX_GAIN_TAB_21_OFFSET                                                          0x0000a450
-#define PHY_BB_TX_GAIN_TAB_21_TG_TABLE21_MSB                                                          31
-#define PHY_BB_TX_GAIN_TAB_21_TG_TABLE21_LSB                                                           0
-#define PHY_BB_TX_GAIN_TAB_21_TG_TABLE21_MASK                                                 0xffffffff
-#define PHY_BB_TX_GAIN_TAB_21_TG_TABLE21_GET(x)                                (((x) & 0xffffffff) >> 0)
-#define PHY_BB_TX_GAIN_TAB_21_TG_TABLE21_SET(x)                                (((x) << 0) & 0xffffffff)
-
-/* macros for BB_tx_gain_tab_22 */
-#define PHY_BB_TX_GAIN_TAB_22_ADDRESS                                                         0x0000a454
-#define PHY_BB_TX_GAIN_TAB_22_OFFSET                                                          0x0000a454
-#define PHY_BB_TX_GAIN_TAB_22_TG_TABLE22_MSB                                                          31
-#define PHY_BB_TX_GAIN_TAB_22_TG_TABLE22_LSB                                                           0
-#define PHY_BB_TX_GAIN_TAB_22_TG_TABLE22_MASK                                                 0xffffffff
-#define PHY_BB_TX_GAIN_TAB_22_TG_TABLE22_GET(x)                                (((x) & 0xffffffff) >> 0)
-#define PHY_BB_TX_GAIN_TAB_22_TG_TABLE22_SET(x)                                (((x) << 0) & 0xffffffff)
-
-/* macros for BB_tx_gain_tab_23 */
-#define PHY_BB_TX_GAIN_TAB_23_ADDRESS                                                         0x0000a458
-#define PHY_BB_TX_GAIN_TAB_23_OFFSET                                                          0x0000a458
-#define PHY_BB_TX_GAIN_TAB_23_TG_TABLE23_MSB                                                          31
-#define PHY_BB_TX_GAIN_TAB_23_TG_TABLE23_LSB                                                           0
-#define PHY_BB_TX_GAIN_TAB_23_TG_TABLE23_MASK                                                 0xffffffff
-#define PHY_BB_TX_GAIN_TAB_23_TG_TABLE23_GET(x)                                (((x) & 0xffffffff) >> 0)
-#define PHY_BB_TX_GAIN_TAB_23_TG_TABLE23_SET(x)                                (((x) << 0) & 0xffffffff)
-
-/* macros for BB_tx_gain_tab_24 */
-#define PHY_BB_TX_GAIN_TAB_24_ADDRESS                                                         0x0000a45c
-#define PHY_BB_TX_GAIN_TAB_24_OFFSET                                                          0x0000a45c
-#define PHY_BB_TX_GAIN_TAB_24_TG_TABLE24_MSB                                                          31
-#define PHY_BB_TX_GAIN_TAB_24_TG_TABLE24_LSB                                                           0
-#define PHY_BB_TX_GAIN_TAB_24_TG_TABLE24_MASK                                                 0xffffffff
-#define PHY_BB_TX_GAIN_TAB_24_TG_TABLE24_GET(x)                                (((x) & 0xffffffff) >> 0)
-#define PHY_BB_TX_GAIN_TAB_24_TG_TABLE24_SET(x)                                (((x) << 0) & 0xffffffff)
-
-/* macros for BB_tx_gain_tab_25 */
-#define PHY_BB_TX_GAIN_TAB_25_ADDRESS                                                         0x0000a460
-#define PHY_BB_TX_GAIN_TAB_25_OFFSET                                                          0x0000a460
-#define PHY_BB_TX_GAIN_TAB_25_TG_TABLE25_MSB                                                          31
-#define PHY_BB_TX_GAIN_TAB_25_TG_TABLE25_LSB                                                           0
-#define PHY_BB_TX_GAIN_TAB_25_TG_TABLE25_MASK                                                 0xffffffff
-#define PHY_BB_TX_GAIN_TAB_25_TG_TABLE25_GET(x)                                (((x) & 0xffffffff) >> 0)
-#define PHY_BB_TX_GAIN_TAB_25_TG_TABLE25_SET(x)                                (((x) << 0) & 0xffffffff)
-
-/* macros for BB_tx_gain_tab_26 */
-#define PHY_BB_TX_GAIN_TAB_26_ADDRESS                                                         0x0000a464
-#define PHY_BB_TX_GAIN_TAB_26_OFFSET                                                          0x0000a464
-#define PHY_BB_TX_GAIN_TAB_26_TG_TABLE26_MSB                                                          31
-#define PHY_BB_TX_GAIN_TAB_26_TG_TABLE26_LSB                                                           0
-#define PHY_BB_TX_GAIN_TAB_26_TG_TABLE26_MASK                                                 0xffffffff
-#define PHY_BB_TX_GAIN_TAB_26_TG_TABLE26_GET(x)                                (((x) & 0xffffffff) >> 0)
-#define PHY_BB_TX_GAIN_TAB_26_TG_TABLE26_SET(x)                                (((x) << 0) & 0xffffffff)
-
-/* macros for BB_tx_gain_tab_27 */
-#define PHY_BB_TX_GAIN_TAB_27_ADDRESS                                                         0x0000a468
-#define PHY_BB_TX_GAIN_TAB_27_OFFSET                                                          0x0000a468
-#define PHY_BB_TX_GAIN_TAB_27_TG_TABLE27_MSB                                                          31
-#define PHY_BB_TX_GAIN_TAB_27_TG_TABLE27_LSB                                                           0
-#define PHY_BB_TX_GAIN_TAB_27_TG_TABLE27_MASK                                                 0xffffffff
-#define PHY_BB_TX_GAIN_TAB_27_TG_TABLE27_GET(x)                                (((x) & 0xffffffff) >> 0)
-#define PHY_BB_TX_GAIN_TAB_27_TG_TABLE27_SET(x)                                (((x) << 0) & 0xffffffff)
-
-/* macros for BB_tx_gain_tab_28 */
-#define PHY_BB_TX_GAIN_TAB_28_ADDRESS                                                         0x0000a46c
-#define PHY_BB_TX_GAIN_TAB_28_OFFSET                                                          0x0000a46c
-#define PHY_BB_TX_GAIN_TAB_28_TG_TABLE28_MSB                                                          31
-#define PHY_BB_TX_GAIN_TAB_28_TG_TABLE28_LSB                                                           0
-#define PHY_BB_TX_GAIN_TAB_28_TG_TABLE28_MASK                                                 0xffffffff
-#define PHY_BB_TX_GAIN_TAB_28_TG_TABLE28_GET(x)                                (((x) & 0xffffffff) >> 0)
-#define PHY_BB_TX_GAIN_TAB_28_TG_TABLE28_SET(x)                                (((x) << 0) & 0xffffffff)
-
-/* macros for BB_tx_gain_tab_29 */
-#define PHY_BB_TX_GAIN_TAB_29_ADDRESS                                                         0x0000a470
-#define PHY_BB_TX_GAIN_TAB_29_OFFSET                                                          0x0000a470
-#define PHY_BB_TX_GAIN_TAB_29_TG_TABLE29_MSB                                                          31
-#define PHY_BB_TX_GAIN_TAB_29_TG_TABLE29_LSB                                                           0
-#define PHY_BB_TX_GAIN_TAB_29_TG_TABLE29_MASK                                                 0xffffffff
-#define PHY_BB_TX_GAIN_TAB_29_TG_TABLE29_GET(x)                                (((x) & 0xffffffff) >> 0)
-#define PHY_BB_TX_GAIN_TAB_29_TG_TABLE29_SET(x)                                (((x) << 0) & 0xffffffff)
-
-/* macros for BB_tx_gain_tab_30 */
-#define PHY_BB_TX_GAIN_TAB_30_ADDRESS                                                         0x0000a474
-#define PHY_BB_TX_GAIN_TAB_30_OFFSET                                                          0x0000a474
-#define PHY_BB_TX_GAIN_TAB_30_TG_TABLE30_MSB                                                          31
-#define PHY_BB_TX_GAIN_TAB_30_TG_TABLE30_LSB                                                           0
-#define PHY_BB_TX_GAIN_TAB_30_TG_TABLE30_MASK                                                 0xffffffff
-#define PHY_BB_TX_GAIN_TAB_30_TG_TABLE30_GET(x)                                (((x) & 0xffffffff) >> 0)
-#define PHY_BB_TX_GAIN_TAB_30_TG_TABLE30_SET(x)                                (((x) << 0) & 0xffffffff)
-
-/* macros for BB_tx_gain_tab_31 */
-#define PHY_BB_TX_GAIN_TAB_31_ADDRESS                                                         0x0000a478
-#define PHY_BB_TX_GAIN_TAB_31_OFFSET                                                          0x0000a478
-#define PHY_BB_TX_GAIN_TAB_31_TG_TABLE31_MSB                                                          31
-#define PHY_BB_TX_GAIN_TAB_31_TG_TABLE31_LSB                                                           0
-#define PHY_BB_TX_GAIN_TAB_31_TG_TABLE31_MASK                                                 0xffffffff
-#define PHY_BB_TX_GAIN_TAB_31_TG_TABLE31_GET(x)                                (((x) & 0xffffffff) >> 0)
-#define PHY_BB_TX_GAIN_TAB_31_TG_TABLE31_SET(x)                                (((x) << 0) & 0xffffffff)
-
-/* macros for BB_tx_gain_tab_32 */
-#define PHY_BB_TX_GAIN_TAB_32_ADDRESS                                                         0x0000a47c
-#define PHY_BB_TX_GAIN_TAB_32_OFFSET                                                          0x0000a47c
-#define PHY_BB_TX_GAIN_TAB_32_TG_TABLE32_MSB                                                          31
-#define PHY_BB_TX_GAIN_TAB_32_TG_TABLE32_LSB                                                           0
-#define PHY_BB_TX_GAIN_TAB_32_TG_TABLE32_MASK                                                 0xffffffff
-#define PHY_BB_TX_GAIN_TAB_32_TG_TABLE32_GET(x)                                (((x) & 0xffffffff) >> 0)
-#define PHY_BB_TX_GAIN_TAB_32_TG_TABLE32_SET(x)                                (((x) << 0) & 0xffffffff)
-
-/* macros for BB_tx_gain_tab_pal_1 */
-#define PHY_BB_TX_GAIN_TAB_PAL_1_ADDRESS                                                      0x0000a480
-#define PHY_BB_TX_GAIN_TAB_PAL_1_OFFSET                                                       0x0000a480
-#define PHY_BB_TX_GAIN_TAB_PAL_1_TG_TABLE1_PAL_ON_MSB                                                 31
-#define PHY_BB_TX_GAIN_TAB_PAL_1_TG_TABLE1_PAL_ON_LSB                                                  0
-#define PHY_BB_TX_GAIN_TAB_PAL_1_TG_TABLE1_PAL_ON_MASK                                        0xffffffff
-#define PHY_BB_TX_GAIN_TAB_PAL_1_TG_TABLE1_PAL_ON_GET(x)                       (((x) & 0xffffffff) >> 0)
-#define PHY_BB_TX_GAIN_TAB_PAL_1_TG_TABLE1_PAL_ON_SET(x)                       (((x) << 0) & 0xffffffff)
-
-/* macros for BB_tx_gain_tab_pal_2 */
-#define PHY_BB_TX_GAIN_TAB_PAL_2_ADDRESS                                                      0x0000a484
-#define PHY_BB_TX_GAIN_TAB_PAL_2_OFFSET                                                       0x0000a484
-#define PHY_BB_TX_GAIN_TAB_PAL_2_TG_TABLE2_PAL_ON_MSB                                                 31
-#define PHY_BB_TX_GAIN_TAB_PAL_2_TG_TABLE2_PAL_ON_LSB                                                  0
-#define PHY_BB_TX_GAIN_TAB_PAL_2_TG_TABLE2_PAL_ON_MASK                                        0xffffffff
-#define PHY_BB_TX_GAIN_TAB_PAL_2_TG_TABLE2_PAL_ON_GET(x)                       (((x) & 0xffffffff) >> 0)
-#define PHY_BB_TX_GAIN_TAB_PAL_2_TG_TABLE2_PAL_ON_SET(x)                       (((x) << 0) & 0xffffffff)
-
-/* macros for BB_tx_gain_tab_pal_3 */
-#define PHY_BB_TX_GAIN_TAB_PAL_3_ADDRESS                                                      0x0000a488
-#define PHY_BB_TX_GAIN_TAB_PAL_3_OFFSET                                                       0x0000a488
-#define PHY_BB_TX_GAIN_TAB_PAL_3_TG_TABLE3_PAL_ON_MSB                                                 31
-#define PHY_BB_TX_GAIN_TAB_PAL_3_TG_TABLE3_PAL_ON_LSB                                                  0
-#define PHY_BB_TX_GAIN_TAB_PAL_3_TG_TABLE3_PAL_ON_MASK                                        0xffffffff
-#define PHY_BB_TX_GAIN_TAB_PAL_3_TG_TABLE3_PAL_ON_GET(x)                       (((x) & 0xffffffff) >> 0)
-#define PHY_BB_TX_GAIN_TAB_PAL_3_TG_TABLE3_PAL_ON_SET(x)                       (((x) << 0) & 0xffffffff)
-
-/* macros for BB_tx_gain_tab_pal_4 */
-#define PHY_BB_TX_GAIN_TAB_PAL_4_ADDRESS                                                      0x0000a48c
-#define PHY_BB_TX_GAIN_TAB_PAL_4_OFFSET                                                       0x0000a48c
-#define PHY_BB_TX_GAIN_TAB_PAL_4_TG_TABLE4_PAL_ON_MSB                                                 31
-#define PHY_BB_TX_GAIN_TAB_PAL_4_TG_TABLE4_PAL_ON_LSB                                                  0
-#define PHY_BB_TX_GAIN_TAB_PAL_4_TG_TABLE4_PAL_ON_MASK                                        0xffffffff
-#define PHY_BB_TX_GAIN_TAB_PAL_4_TG_TABLE4_PAL_ON_GET(x)                       (((x) & 0xffffffff) >> 0)
-#define PHY_BB_TX_GAIN_TAB_PAL_4_TG_TABLE4_PAL_ON_SET(x)                       (((x) << 0) & 0xffffffff)
-
-/* macros for BB_tx_gain_tab_pal_5 */
-#define PHY_BB_TX_GAIN_TAB_PAL_5_ADDRESS                                                      0x0000a490
-#define PHY_BB_TX_GAIN_TAB_PAL_5_OFFSET                                                       0x0000a490
-#define PHY_BB_TX_GAIN_TAB_PAL_5_TG_TABLE5_PAL_ON_MSB                                                 31
-#define PHY_BB_TX_GAIN_TAB_PAL_5_TG_TABLE5_PAL_ON_LSB                                                  0
-#define PHY_BB_TX_GAIN_TAB_PAL_5_TG_TABLE5_PAL_ON_MASK                                        0xffffffff
-#define PHY_BB_TX_GAIN_TAB_PAL_5_TG_TABLE5_PAL_ON_GET(x)                       (((x) & 0xffffffff) >> 0)
-#define PHY_BB_TX_GAIN_TAB_PAL_5_TG_TABLE5_PAL_ON_SET(x)                       (((x) << 0) & 0xffffffff)
-
-/* macros for BB_tx_gain_tab_pal_6 */
-#define PHY_BB_TX_GAIN_TAB_PAL_6_ADDRESS                                                      0x0000a494
-#define PHY_BB_TX_GAIN_TAB_PAL_6_OFFSET                                                       0x0000a494
-#define PHY_BB_TX_GAIN_TAB_PAL_6_TG_TABLE6_PAL_ON_MSB                                                 31
-#define PHY_BB_TX_GAIN_TAB_PAL_6_TG_TABLE6_PAL_ON_LSB                                                  0
-#define PHY_BB_TX_GAIN_TAB_PAL_6_TG_TABLE6_PAL_ON_MASK                                        0xffffffff
-#define PHY_BB_TX_GAIN_TAB_PAL_6_TG_TABLE6_PAL_ON_GET(x)                       (((x) & 0xffffffff) >> 0)
-#define PHY_BB_TX_GAIN_TAB_PAL_6_TG_TABLE6_PAL_ON_SET(x)                       (((x) << 0) & 0xffffffff)
-
-/* macros for BB_tx_gain_tab_pal_7 */
-#define PHY_BB_TX_GAIN_TAB_PAL_7_ADDRESS                                                      0x0000a498
-#define PHY_BB_TX_GAIN_TAB_PAL_7_OFFSET                                                       0x0000a498
-#define PHY_BB_TX_GAIN_TAB_PAL_7_TG_TABLE7_PAL_ON_MSB                                                 31
-#define PHY_BB_TX_GAIN_TAB_PAL_7_TG_TABLE7_PAL_ON_LSB                                                  0
-#define PHY_BB_TX_GAIN_TAB_PAL_7_TG_TABLE7_PAL_ON_MASK                                        0xffffffff
-#define PHY_BB_TX_GAIN_TAB_PAL_7_TG_TABLE7_PAL_ON_GET(x)                       (((x) & 0xffffffff) >> 0)
-#define PHY_BB_TX_GAIN_TAB_PAL_7_TG_TABLE7_PAL_ON_SET(x)                       (((x) << 0) & 0xffffffff)
-
-/* macros for BB_tx_gain_tab_pal_8 */
-#define PHY_BB_TX_GAIN_TAB_PAL_8_ADDRESS                                                      0x0000a49c
-#define PHY_BB_TX_GAIN_TAB_PAL_8_OFFSET                                                       0x0000a49c
-#define PHY_BB_TX_GAIN_TAB_PAL_8_TG_TABLE8_PAL_ON_MSB                                                 31
-#define PHY_BB_TX_GAIN_TAB_PAL_8_TG_TABLE8_PAL_ON_LSB                                                  0
-#define PHY_BB_TX_GAIN_TAB_PAL_8_TG_TABLE8_PAL_ON_MASK                                        0xffffffff
-#define PHY_BB_TX_GAIN_TAB_PAL_8_TG_TABLE8_PAL_ON_GET(x)                       (((x) & 0xffffffff) >> 0)
-#define PHY_BB_TX_GAIN_TAB_PAL_8_TG_TABLE8_PAL_ON_SET(x)                       (((x) << 0) & 0xffffffff)
-
-/* macros for BB_tx_gain_tab_pal_9 */
-#define PHY_BB_TX_GAIN_TAB_PAL_9_ADDRESS                                                      0x0000a4a0
-#define PHY_BB_TX_GAIN_TAB_PAL_9_OFFSET                                                       0x0000a4a0
-#define PHY_BB_TX_GAIN_TAB_PAL_9_TG_TABLE9_PAL_ON_MSB                                                 31
-#define PHY_BB_TX_GAIN_TAB_PAL_9_TG_TABLE9_PAL_ON_LSB                                                  0
-#define PHY_BB_TX_GAIN_TAB_PAL_9_TG_TABLE9_PAL_ON_MASK                                        0xffffffff
-#define PHY_BB_TX_GAIN_TAB_PAL_9_TG_TABLE9_PAL_ON_GET(x)                       (((x) & 0xffffffff) >> 0)
-#define PHY_BB_TX_GAIN_TAB_PAL_9_TG_TABLE9_PAL_ON_SET(x)                       (((x) << 0) & 0xffffffff)
-
-/* macros for BB_tx_gain_tab_pal_10 */
-#define PHY_BB_TX_GAIN_TAB_PAL_10_ADDRESS                                                     0x0000a4a4
-#define PHY_BB_TX_GAIN_TAB_PAL_10_OFFSET                                                      0x0000a4a4
-#define PHY_BB_TX_GAIN_TAB_PAL_10_TG_TABLE10_PAL_ON_MSB                                               31
-#define PHY_BB_TX_GAIN_TAB_PAL_10_TG_TABLE10_PAL_ON_LSB                                                0
-#define PHY_BB_TX_GAIN_TAB_PAL_10_TG_TABLE10_PAL_ON_MASK                                      0xffffffff
-#define PHY_BB_TX_GAIN_TAB_PAL_10_TG_TABLE10_PAL_ON_GET(x)                     (((x) & 0xffffffff) >> 0)
-#define PHY_BB_TX_GAIN_TAB_PAL_10_TG_TABLE10_PAL_ON_SET(x)                     (((x) << 0) & 0xffffffff)
-
-/* macros for BB_tx_gain_tab_pal_11 */
-#define PHY_BB_TX_GAIN_TAB_PAL_11_ADDRESS                                                     0x0000a4a8
-#define PHY_BB_TX_GAIN_TAB_PAL_11_OFFSET                                                      0x0000a4a8
-#define PHY_BB_TX_GAIN_TAB_PAL_11_TG_TABLE11_PAL_ON_MSB                                               31
-#define PHY_BB_TX_GAIN_TAB_PAL_11_TG_TABLE11_PAL_ON_LSB                                                0
-#define PHY_BB_TX_GAIN_TAB_PAL_11_TG_TABLE11_PAL_ON_MASK                                      0xffffffff
-#define PHY_BB_TX_GAIN_TAB_PAL_11_TG_TABLE11_PAL_ON_GET(x)                     (((x) & 0xffffffff) >> 0)
-#define PHY_BB_TX_GAIN_TAB_PAL_11_TG_TABLE11_PAL_ON_SET(x)                     (((x) << 0) & 0xffffffff)
-
-/* macros for BB_tx_gain_tab_pal_12 */
-#define PHY_BB_TX_GAIN_TAB_PAL_12_ADDRESS                                                     0x0000a4ac
-#define PHY_BB_TX_GAIN_TAB_PAL_12_OFFSET                                                      0x0000a4ac
-#define PHY_BB_TX_GAIN_TAB_PAL_12_TG_TABLE12_PAL_ON_MSB                                               31
-#define PHY_BB_TX_GAIN_TAB_PAL_12_TG_TABLE12_PAL_ON_LSB                                                0
-#define PHY_BB_TX_GAIN_TAB_PAL_12_TG_TABLE12_PAL_ON_MASK                                      0xffffffff
-#define PHY_BB_TX_GAIN_TAB_PAL_12_TG_TABLE12_PAL_ON_GET(x)                     (((x) & 0xffffffff) >> 0)
-#define PHY_BB_TX_GAIN_TAB_PAL_12_TG_TABLE12_PAL_ON_SET(x)                     (((x) << 0) & 0xffffffff)
-
-/* macros for BB_tx_gain_tab_pal_13 */
-#define PHY_BB_TX_GAIN_TAB_PAL_13_ADDRESS                                                     0x0000a4b0
-#define PHY_BB_TX_GAIN_TAB_PAL_13_OFFSET                                                      0x0000a4b0
-#define PHY_BB_TX_GAIN_TAB_PAL_13_TG_TABLE13_PAL_ON_MSB                                               31
-#define PHY_BB_TX_GAIN_TAB_PAL_13_TG_TABLE13_PAL_ON_LSB                                                0
-#define PHY_BB_TX_GAIN_TAB_PAL_13_TG_TABLE13_PAL_ON_MASK                                      0xffffffff
-#define PHY_BB_TX_GAIN_TAB_PAL_13_TG_TABLE13_PAL_ON_GET(x)                     (((x) & 0xffffffff) >> 0)
-#define PHY_BB_TX_GAIN_TAB_PAL_13_TG_TABLE13_PAL_ON_SET(x)                     (((x) << 0) & 0xffffffff)
-
-/* macros for BB_tx_gain_tab_pal_14 */
-#define PHY_BB_TX_GAIN_TAB_PAL_14_ADDRESS                                                     0x0000a4b4
-#define PHY_BB_TX_GAIN_TAB_PAL_14_OFFSET                                                      0x0000a4b4
-#define PHY_BB_TX_GAIN_TAB_PAL_14_TG_TABLE14_PAL_ON_MSB                                               31
-#define PHY_BB_TX_GAIN_TAB_PAL_14_TG_TABLE14_PAL_ON_LSB                                                0
-#define PHY_BB_TX_GAIN_TAB_PAL_14_TG_TABLE14_PAL_ON_MASK                                      0xffffffff
-#define PHY_BB_TX_GAIN_TAB_PAL_14_TG_TABLE14_PAL_ON_GET(x)                     (((x) & 0xffffffff) >> 0)
-#define PHY_BB_TX_GAIN_TAB_PAL_14_TG_TABLE14_PAL_ON_SET(x)                     (((x) << 0) & 0xffffffff)
-
-/* macros for BB_tx_gain_tab_pal_15 */
-#define PHY_BB_TX_GAIN_TAB_PAL_15_ADDRESS                                                     0x0000a4b8
-#define PHY_BB_TX_GAIN_TAB_PAL_15_OFFSET                                                      0x0000a4b8
-#define PHY_BB_TX_GAIN_TAB_PAL_15_TG_TABLE15_PAL_ON_MSB                                               31
-#define PHY_BB_TX_GAIN_TAB_PAL_15_TG_TABLE15_PAL_ON_LSB                                                0
-#define PHY_BB_TX_GAIN_TAB_PAL_15_TG_TABLE15_PAL_ON_MASK                                      0xffffffff
-#define PHY_BB_TX_GAIN_TAB_PAL_15_TG_TABLE15_PAL_ON_GET(x)                     (((x) & 0xffffffff) >> 0)
-#define PHY_BB_TX_GAIN_TAB_PAL_15_TG_TABLE15_PAL_ON_SET(x)                     (((x) << 0) & 0xffffffff)
-
-/* macros for BB_tx_gain_tab_pal_16 */
-#define PHY_BB_TX_GAIN_TAB_PAL_16_ADDRESS                                                     0x0000a4bc
-#define PHY_BB_TX_GAIN_TAB_PAL_16_OFFSET                                                      0x0000a4bc
-#define PHY_BB_TX_GAIN_TAB_PAL_16_TG_TABLE16_PAL_ON_MSB                                               31
-#define PHY_BB_TX_GAIN_TAB_PAL_16_TG_TABLE16_PAL_ON_LSB                                                0
-#define PHY_BB_TX_GAIN_TAB_PAL_16_TG_TABLE16_PAL_ON_MASK                                      0xffffffff
-#define PHY_BB_TX_GAIN_TAB_PAL_16_TG_TABLE16_PAL_ON_GET(x)                     (((x) & 0xffffffff) >> 0)
-#define PHY_BB_TX_GAIN_TAB_PAL_16_TG_TABLE16_PAL_ON_SET(x)                     (((x) << 0) & 0xffffffff)
-
-/* macros for BB_tx_gain_tab_pal_17 */
-#define PHY_BB_TX_GAIN_TAB_PAL_17_ADDRESS                                                     0x0000a4c0
-#define PHY_BB_TX_GAIN_TAB_PAL_17_OFFSET                                                      0x0000a4c0
-#define PHY_BB_TX_GAIN_TAB_PAL_17_TG_TABLE17_PAL_ON_MSB                                               31
-#define PHY_BB_TX_GAIN_TAB_PAL_17_TG_TABLE17_PAL_ON_LSB                                                0
-#define PHY_BB_TX_GAIN_TAB_PAL_17_TG_TABLE17_PAL_ON_MASK                                      0xffffffff
-#define PHY_BB_TX_GAIN_TAB_PAL_17_TG_TABLE17_PAL_ON_GET(x)                     (((x) & 0xffffffff) >> 0)
-#define PHY_BB_TX_GAIN_TAB_PAL_17_TG_TABLE17_PAL_ON_SET(x)                     (((x) << 0) & 0xffffffff)
-
-/* macros for BB_tx_gain_tab_pal_18 */
-#define PHY_BB_TX_GAIN_TAB_PAL_18_ADDRESS                                                     0x0000a4c4
-#define PHY_BB_TX_GAIN_TAB_PAL_18_OFFSET                                                      0x0000a4c4
-#define PHY_BB_TX_GAIN_TAB_PAL_18_TG_TABLE18_PAL_ON_MSB                                               31
-#define PHY_BB_TX_GAIN_TAB_PAL_18_TG_TABLE18_PAL_ON_LSB                                                0
-#define PHY_BB_TX_GAIN_TAB_PAL_18_TG_TABLE18_PAL_ON_MASK                                      0xffffffff
-#define PHY_BB_TX_GAIN_TAB_PAL_18_TG_TABLE18_PAL_ON_GET(x)                     (((x) & 0xffffffff) >> 0)
-#define PHY_BB_TX_GAIN_TAB_PAL_18_TG_TABLE18_PAL_ON_SET(x)                     (((x) << 0) & 0xffffffff)
-
-/* macros for BB_tx_gain_tab_pal_19 */
-#define PHY_BB_TX_GAIN_TAB_PAL_19_ADDRESS                                                     0x0000a4c8
-#define PHY_BB_TX_GAIN_TAB_PAL_19_OFFSET                                                      0x0000a4c8
-#define PHY_BB_TX_GAIN_TAB_PAL_19_TG_TABLE19_PAL_ON_MSB                                               31
-#define PHY_BB_TX_GAIN_TAB_PAL_19_TG_TABLE19_PAL_ON_LSB                                                0
-#define PHY_BB_TX_GAIN_TAB_PAL_19_TG_TABLE19_PAL_ON_MASK                                      0xffffffff
-#define PHY_BB_TX_GAIN_TAB_PAL_19_TG_TABLE19_PAL_ON_GET(x)                     (((x) & 0xffffffff) >> 0)
-#define PHY_BB_TX_GAIN_TAB_PAL_19_TG_TABLE19_PAL_ON_SET(x)                     (((x) << 0) & 0xffffffff)
-
-/* macros for BB_tx_gain_tab_pal_20 */
-#define PHY_BB_TX_GAIN_TAB_PAL_20_ADDRESS                                                     0x0000a4cc
-#define PHY_BB_TX_GAIN_TAB_PAL_20_OFFSET                                                      0x0000a4cc
-#define PHY_BB_TX_GAIN_TAB_PAL_20_TG_TABLE20_PAL_ON_MSB                                               31
-#define PHY_BB_TX_GAIN_TAB_PAL_20_TG_TABLE20_PAL_ON_LSB                                                0
-#define PHY_BB_TX_GAIN_TAB_PAL_20_TG_TABLE20_PAL_ON_MASK                                      0xffffffff
-#define PHY_BB_TX_GAIN_TAB_PAL_20_TG_TABLE20_PAL_ON_GET(x)                     (((x) & 0xffffffff) >> 0)
-#define PHY_BB_TX_GAIN_TAB_PAL_20_TG_TABLE20_PAL_ON_SET(x)                     (((x) << 0) & 0xffffffff)
-
-/* macros for BB_tx_gain_tab_pal_21 */
-#define PHY_BB_TX_GAIN_TAB_PAL_21_ADDRESS                                                     0x0000a4d0
-#define PHY_BB_TX_GAIN_TAB_PAL_21_OFFSET                                                      0x0000a4d0
-#define PHY_BB_TX_GAIN_TAB_PAL_21_TG_TABLE21_PAL_ON_MSB                                               31
-#define PHY_BB_TX_GAIN_TAB_PAL_21_TG_TABLE21_PAL_ON_LSB                                                0
-#define PHY_BB_TX_GAIN_TAB_PAL_21_TG_TABLE21_PAL_ON_MASK                                      0xffffffff
-#define PHY_BB_TX_GAIN_TAB_PAL_21_TG_TABLE21_PAL_ON_GET(x)                     (((x) & 0xffffffff) >> 0)
-#define PHY_BB_TX_GAIN_TAB_PAL_21_TG_TABLE21_PAL_ON_SET(x)                     (((x) << 0) & 0xffffffff)
-
-/* macros for BB_tx_gain_tab_pal_22 */
-#define PHY_BB_TX_GAIN_TAB_PAL_22_ADDRESS                                                     0x0000a4d4
-#define PHY_BB_TX_GAIN_TAB_PAL_22_OFFSET                                                      0x0000a4d4
-#define PHY_BB_TX_GAIN_TAB_PAL_22_TG_TABLE22_PAL_ON_MSB                                               31
-#define PHY_BB_TX_GAIN_TAB_PAL_22_TG_TABLE22_PAL_ON_LSB                                                0
-#define PHY_BB_TX_GAIN_TAB_PAL_22_TG_TABLE22_PAL_ON_MASK                                      0xffffffff
-#define PHY_BB_TX_GAIN_TAB_PAL_22_TG_TABLE22_PAL_ON_GET(x)                     (((x) & 0xffffffff) >> 0)
-#define PHY_BB_TX_GAIN_TAB_PAL_22_TG_TABLE22_PAL_ON_SET(x)                     (((x) << 0) & 0xffffffff)
-
-/* macros for BB_tx_gain_tab_pal_23 */
-#define PHY_BB_TX_GAIN_TAB_PAL_23_ADDRESS                                                     0x0000a4d8
-#define PHY_BB_TX_GAIN_TAB_PAL_23_OFFSET                                                      0x0000a4d8
-#define PHY_BB_TX_GAIN_TAB_PAL_23_TG_TABLE23_PAL_ON_MSB                                               31
-#define PHY_BB_TX_GAIN_TAB_PAL_23_TG_TABLE23_PAL_ON_LSB                                                0
-#define PHY_BB_TX_GAIN_TAB_PAL_23_TG_TABLE23_PAL_ON_MASK                                      0xffffffff
-#define PHY_BB_TX_GAIN_TAB_PAL_23_TG_TABLE23_PAL_ON_GET(x)                     (((x) & 0xffffffff) >> 0)
-#define PHY_BB_TX_GAIN_TAB_PAL_23_TG_TABLE23_PAL_ON_SET(x)                     (((x) << 0) & 0xffffffff)
-
-/* macros for BB_tx_gain_tab_pal_24 */
-#define PHY_BB_TX_GAIN_TAB_PAL_24_ADDRESS                                                     0x0000a4dc
-#define PHY_BB_TX_GAIN_TAB_PAL_24_OFFSET                                                      0x0000a4dc
-#define PHY_BB_TX_GAIN_TAB_PAL_24_TG_TABLE24_PAL_ON_MSB                                               31
-#define PHY_BB_TX_GAIN_TAB_PAL_24_TG_TABLE24_PAL_ON_LSB                                                0
-#define PHY_BB_TX_GAIN_TAB_PAL_24_TG_TABLE24_PAL_ON_MASK                                      0xffffffff
-#define PHY_BB_TX_GAIN_TAB_PAL_24_TG_TABLE24_PAL_ON_GET(x)                     (((x) & 0xffffffff) >> 0)
-#define PHY_BB_TX_GAIN_TAB_PAL_24_TG_TABLE24_PAL_ON_SET(x)                     (((x) << 0) & 0xffffffff)
-
-/* macros for BB_tx_gain_tab_pal_25 */
-#define PHY_BB_TX_GAIN_TAB_PAL_25_ADDRESS                                                     0x0000a4e0
-#define PHY_BB_TX_GAIN_TAB_PAL_25_OFFSET                                                      0x0000a4e0
-#define PHY_BB_TX_GAIN_TAB_PAL_25_TG_TABLE25_PAL_ON_MSB                                               31
-#define PHY_BB_TX_GAIN_TAB_PAL_25_TG_TABLE25_PAL_ON_LSB                                                0
-#define PHY_BB_TX_GAIN_TAB_PAL_25_TG_TABLE25_PAL_ON_MASK                                      0xffffffff
-#define PHY_BB_TX_GAIN_TAB_PAL_25_TG_TABLE25_PAL_ON_GET(x)                     (((x) & 0xffffffff) >> 0)
-#define PHY_BB_TX_GAIN_TAB_PAL_25_TG_TABLE25_PAL_ON_SET(x)                     (((x) << 0) & 0xffffffff)
-
-/* macros for BB_tx_gain_tab_pal_26 */
-#define PHY_BB_TX_GAIN_TAB_PAL_26_ADDRESS                                                     0x0000a4e4
-#define PHY_BB_TX_GAIN_TAB_PAL_26_OFFSET                                                      0x0000a4e4
-#define PHY_BB_TX_GAIN_TAB_PAL_26_TG_TABLE26_PAL_ON_MSB                                               31
-#define PHY_BB_TX_GAIN_TAB_PAL_26_TG_TABLE26_PAL_ON_LSB                                                0
-#define PHY_BB_TX_GAIN_TAB_PAL_26_TG_TABLE26_PAL_ON_MASK                                      0xffffffff
-#define PHY_BB_TX_GAIN_TAB_PAL_26_TG_TABLE26_PAL_ON_GET(x)                     (((x) & 0xffffffff) >> 0)
-#define PHY_BB_TX_GAIN_TAB_PAL_26_TG_TABLE26_PAL_ON_SET(x)                     (((x) << 0) & 0xffffffff)
-
-/* macros for BB_tx_gain_tab_pal_27 */
-#define PHY_BB_TX_GAIN_TAB_PAL_27_ADDRESS                                                     0x0000a4e8
-#define PHY_BB_TX_GAIN_TAB_PAL_27_OFFSET                                                      0x0000a4e8
-#define PHY_BB_TX_GAIN_TAB_PAL_27_TG_TABLE27_PAL_ON_MSB                                               31
-#define PHY_BB_TX_GAIN_TAB_PAL_27_TG_TABLE27_PAL_ON_LSB                                                0
-#define PHY_BB_TX_GAIN_TAB_PAL_27_TG_TABLE27_PAL_ON_MASK                                      0xffffffff
-#define PHY_BB_TX_GAIN_TAB_PAL_27_TG_TABLE27_PAL_ON_GET(x)                     (((x) & 0xffffffff) >> 0)
-#define PHY_BB_TX_GAIN_TAB_PAL_27_TG_TABLE27_PAL_ON_SET(x)                     (((x) << 0) & 0xffffffff)
-
-/* macros for BB_tx_gain_tab_pal_28 */
-#define PHY_BB_TX_GAIN_TAB_PAL_28_ADDRESS                                                     0x0000a4ec
-#define PHY_BB_TX_GAIN_TAB_PAL_28_OFFSET                                                      0x0000a4ec
-#define PHY_BB_TX_GAIN_TAB_PAL_28_TG_TABLE28_PAL_ON_MSB                                               31
-#define PHY_BB_TX_GAIN_TAB_PAL_28_TG_TABLE28_PAL_ON_LSB                                                0
-#define PHY_BB_TX_GAIN_TAB_PAL_28_TG_TABLE28_PAL_ON_MASK                                      0xffffffff
-#define PHY_BB_TX_GAIN_TAB_PAL_28_TG_TABLE28_PAL_ON_GET(x)                     (((x) & 0xffffffff) >> 0)
-#define PHY_BB_TX_GAIN_TAB_PAL_28_TG_TABLE28_PAL_ON_SET(x)                     (((x) << 0) & 0xffffffff)
-
-/* macros for BB_tx_gain_tab_pal_29 */
-#define PHY_BB_TX_GAIN_TAB_PAL_29_ADDRESS                                                     0x0000a4f0
-#define PHY_BB_TX_GAIN_TAB_PAL_29_OFFSET                                                      0x0000a4f0
-#define PHY_BB_TX_GAIN_TAB_PAL_29_TG_TABLE29_PAL_ON_MSB                                               31
-#define PHY_BB_TX_GAIN_TAB_PAL_29_TG_TABLE29_PAL_ON_LSB                                                0
-#define PHY_BB_TX_GAIN_TAB_PAL_29_TG_TABLE29_PAL_ON_MASK                                      0xffffffff
-#define PHY_BB_TX_GAIN_TAB_PAL_29_TG_TABLE29_PAL_ON_GET(x)                     (((x) & 0xffffffff) >> 0)
-#define PHY_BB_TX_GAIN_TAB_PAL_29_TG_TABLE29_PAL_ON_SET(x)                     (((x) << 0) & 0xffffffff)
-
-/* macros for BB_tx_gain_tab_pal_30 */
-#define PHY_BB_TX_GAIN_TAB_PAL_30_ADDRESS                                                     0x0000a4f4
-#define PHY_BB_TX_GAIN_TAB_PAL_30_OFFSET                                                      0x0000a4f4
-#define PHY_BB_TX_GAIN_TAB_PAL_30_TG_TABLE30_PAL_ON_MSB                                               31
-#define PHY_BB_TX_GAIN_TAB_PAL_30_TG_TABLE30_PAL_ON_LSB                                                0
-#define PHY_BB_TX_GAIN_TAB_PAL_30_TG_TABLE30_PAL_ON_MASK                                      0xffffffff
-#define PHY_BB_TX_GAIN_TAB_PAL_30_TG_TABLE30_PAL_ON_GET(x)                     (((x) & 0xffffffff) >> 0)
-#define PHY_BB_TX_GAIN_TAB_PAL_30_TG_TABLE30_PAL_ON_SET(x)                     (((x) << 0) & 0xffffffff)
-
-/* macros for BB_tx_gain_tab_pal_31 */
-#define PHY_BB_TX_GAIN_TAB_PAL_31_ADDRESS                                                     0x0000a4f8
-#define PHY_BB_TX_GAIN_TAB_PAL_31_OFFSET                                                      0x0000a4f8
-#define PHY_BB_TX_GAIN_TAB_PAL_31_TG_TABLE31_PAL_ON_MSB                                               31
-#define PHY_BB_TX_GAIN_TAB_PAL_31_TG_TABLE31_PAL_ON_LSB                                                0
-#define PHY_BB_TX_GAIN_TAB_PAL_31_TG_TABLE31_PAL_ON_MASK                                      0xffffffff
-#define PHY_BB_TX_GAIN_TAB_PAL_31_TG_TABLE31_PAL_ON_GET(x)                     (((x) & 0xffffffff) >> 0)
-#define PHY_BB_TX_GAIN_TAB_PAL_31_TG_TABLE31_PAL_ON_SET(x)                     (((x) << 0) & 0xffffffff)
-
-/* macros for BB_tx_gain_tab_pal_32 */
-#define PHY_BB_TX_GAIN_TAB_PAL_32_ADDRESS                                                     0x0000a4fc
-#define PHY_BB_TX_GAIN_TAB_PAL_32_OFFSET                                                      0x0000a4fc
-#define PHY_BB_TX_GAIN_TAB_PAL_32_TG_TABLE32_PAL_ON_MSB                                               31
-#define PHY_BB_TX_GAIN_TAB_PAL_32_TG_TABLE32_PAL_ON_LSB                                                0
-#define PHY_BB_TX_GAIN_TAB_PAL_32_TG_TABLE32_PAL_ON_MASK                                      0xffffffff
-#define PHY_BB_TX_GAIN_TAB_PAL_32_TG_TABLE32_PAL_ON_GET(x)                     (((x) & 0xffffffff) >> 0)
-#define PHY_BB_TX_GAIN_TAB_PAL_32_TG_TABLE32_PAL_ON_SET(x)                     (((x) << 0) & 0xffffffff)
-
-/* macros for BB_caltx_gain_set_0 */
-#define PHY_BB_CALTX_GAIN_SET_0_ADDRESS                                                       0x0000a518
-#define PHY_BB_CALTX_GAIN_SET_0_OFFSET                                                        0x0000a518
-#define PHY_BB_CALTX_GAIN_SET_0_CALTX_GAIN_SET_0_MSB                                                  13
-#define PHY_BB_CALTX_GAIN_SET_0_CALTX_GAIN_SET_0_LSB                                                   0
-#define PHY_BB_CALTX_GAIN_SET_0_CALTX_GAIN_SET_0_MASK                                         0x00003fff
-#define PHY_BB_CALTX_GAIN_SET_0_CALTX_GAIN_SET_0_GET(x)                        (((x) & 0x00003fff) >> 0)
-#define PHY_BB_CALTX_GAIN_SET_0_CALTX_GAIN_SET_0_SET(x)                        (((x) << 0) & 0x00003fff)
-#define PHY_BB_CALTX_GAIN_SET_0_CALTX_GAIN_SET_1_MSB                                                  27
-#define PHY_BB_CALTX_GAIN_SET_0_CALTX_GAIN_SET_1_LSB                                                  14
-#define PHY_BB_CALTX_GAIN_SET_0_CALTX_GAIN_SET_1_MASK                                         0x0fffc000
-#define PHY_BB_CALTX_GAIN_SET_0_CALTX_GAIN_SET_1_GET(x)                       (((x) & 0x0fffc000) >> 14)
-#define PHY_BB_CALTX_GAIN_SET_0_CALTX_GAIN_SET_1_SET(x)                       (((x) << 14) & 0x0fffc000)
-
-/* macros for BB_caltx_gain_set_2 */
-#define PHY_BB_CALTX_GAIN_SET_2_ADDRESS                                                       0x0000a51c
-#define PHY_BB_CALTX_GAIN_SET_2_OFFSET                                                        0x0000a51c
-#define PHY_BB_CALTX_GAIN_SET_2_CALTX_GAIN_SET_2_MSB                                                  13
-#define PHY_BB_CALTX_GAIN_SET_2_CALTX_GAIN_SET_2_LSB                                                   0
-#define PHY_BB_CALTX_GAIN_SET_2_CALTX_GAIN_SET_2_MASK                                         0x00003fff
-#define PHY_BB_CALTX_GAIN_SET_2_CALTX_GAIN_SET_2_GET(x)                        (((x) & 0x00003fff) >> 0)
-#define PHY_BB_CALTX_GAIN_SET_2_CALTX_GAIN_SET_2_SET(x)                        (((x) << 0) & 0x00003fff)
-#define PHY_BB_CALTX_GAIN_SET_2_CALTX_GAIN_SET_3_MSB                                                  27
-#define PHY_BB_CALTX_GAIN_SET_2_CALTX_GAIN_SET_3_LSB                                                  14
-#define PHY_BB_CALTX_GAIN_SET_2_CALTX_GAIN_SET_3_MASK                                         0x0fffc000
-#define PHY_BB_CALTX_GAIN_SET_2_CALTX_GAIN_SET_3_GET(x)                       (((x) & 0x0fffc000) >> 14)
-#define PHY_BB_CALTX_GAIN_SET_2_CALTX_GAIN_SET_3_SET(x)                       (((x) << 14) & 0x0fffc000)
-
-/* macros for BB_caltx_gain_set_4 */
-#define PHY_BB_CALTX_GAIN_SET_4_ADDRESS                                                       0x0000a520
-#define PHY_BB_CALTX_GAIN_SET_4_OFFSET                                                        0x0000a520
-#define PHY_BB_CALTX_GAIN_SET_4_CALTX_GAIN_SET_4_MSB                                                  13
-#define PHY_BB_CALTX_GAIN_SET_4_CALTX_GAIN_SET_4_LSB                                                   0
-#define PHY_BB_CALTX_GAIN_SET_4_CALTX_GAIN_SET_4_MASK                                         0x00003fff
-#define PHY_BB_CALTX_GAIN_SET_4_CALTX_GAIN_SET_4_GET(x)                        (((x) & 0x00003fff) >> 0)
-#define PHY_BB_CALTX_GAIN_SET_4_CALTX_GAIN_SET_4_SET(x)                        (((x) << 0) & 0x00003fff)
-#define PHY_BB_CALTX_GAIN_SET_4_CALTX_GAIN_SET_5_MSB                                                  27
-#define PHY_BB_CALTX_GAIN_SET_4_CALTX_GAIN_SET_5_LSB                                                  14
-#define PHY_BB_CALTX_GAIN_SET_4_CALTX_GAIN_SET_5_MASK                                         0x0fffc000
-#define PHY_BB_CALTX_GAIN_SET_4_CALTX_GAIN_SET_5_GET(x)                       (((x) & 0x0fffc000) >> 14)
-#define PHY_BB_CALTX_GAIN_SET_4_CALTX_GAIN_SET_5_SET(x)                       (((x) << 14) & 0x0fffc000)
-
-/* macros for BB_caltx_gain_set_6 */
-#define PHY_BB_CALTX_GAIN_SET_6_ADDRESS                                                       0x0000a524
-#define PHY_BB_CALTX_GAIN_SET_6_OFFSET                                                        0x0000a524
-#define PHY_BB_CALTX_GAIN_SET_6_CALTX_GAIN_SET_6_MSB                                                  13
-#define PHY_BB_CALTX_GAIN_SET_6_CALTX_GAIN_SET_6_LSB                                                   0
-#define PHY_BB_CALTX_GAIN_SET_6_CALTX_GAIN_SET_6_MASK                                         0x00003fff
-#define PHY_BB_CALTX_GAIN_SET_6_CALTX_GAIN_SET_6_GET(x)                        (((x) & 0x00003fff) >> 0)
-#define PHY_BB_CALTX_GAIN_SET_6_CALTX_GAIN_SET_6_SET(x)                        (((x) << 0) & 0x00003fff)
-#define PHY_BB_CALTX_GAIN_SET_6_CALTX_GAIN_SET_7_MSB                                                  27
-#define PHY_BB_CALTX_GAIN_SET_6_CALTX_GAIN_SET_7_LSB                                                  14
-#define PHY_BB_CALTX_GAIN_SET_6_CALTX_GAIN_SET_7_MASK                                         0x0fffc000
-#define PHY_BB_CALTX_GAIN_SET_6_CALTX_GAIN_SET_7_GET(x)                       (((x) & 0x0fffc000) >> 14)
-#define PHY_BB_CALTX_GAIN_SET_6_CALTX_GAIN_SET_7_SET(x)                       (((x) << 14) & 0x0fffc000)
-
-/* macros for BB_caltx_gain_set_8 */
-#define PHY_BB_CALTX_GAIN_SET_8_ADDRESS                                                       0x0000a528
-#define PHY_BB_CALTX_GAIN_SET_8_OFFSET                                                        0x0000a528
-#define PHY_BB_CALTX_GAIN_SET_8_CALTX_GAIN_SET_8_MSB                                                  13
-#define PHY_BB_CALTX_GAIN_SET_8_CALTX_GAIN_SET_8_LSB                                                   0
-#define PHY_BB_CALTX_GAIN_SET_8_CALTX_GAIN_SET_8_MASK                                         0x00003fff
-#define PHY_BB_CALTX_GAIN_SET_8_CALTX_GAIN_SET_8_GET(x)                        (((x) & 0x00003fff) >> 0)
-#define PHY_BB_CALTX_GAIN_SET_8_CALTX_GAIN_SET_8_SET(x)                        (((x) << 0) & 0x00003fff)
-#define PHY_BB_CALTX_GAIN_SET_8_CALTX_GAIN_SET_9_MSB                                                  27
-#define PHY_BB_CALTX_GAIN_SET_8_CALTX_GAIN_SET_9_LSB                                                  14
-#define PHY_BB_CALTX_GAIN_SET_8_CALTX_GAIN_SET_9_MASK                                         0x0fffc000
-#define PHY_BB_CALTX_GAIN_SET_8_CALTX_GAIN_SET_9_GET(x)                       (((x) & 0x0fffc000) >> 14)
-#define PHY_BB_CALTX_GAIN_SET_8_CALTX_GAIN_SET_9_SET(x)                       (((x) << 14) & 0x0fffc000)
-
-/* macros for BB_caltx_gain_set_10 */
-#define PHY_BB_CALTX_GAIN_SET_10_ADDRESS                                                      0x0000a52c
-#define PHY_BB_CALTX_GAIN_SET_10_OFFSET                                                       0x0000a52c
-#define PHY_BB_CALTX_GAIN_SET_10_CALTX_GAIN_SET_10_MSB                                                13
-#define PHY_BB_CALTX_GAIN_SET_10_CALTX_GAIN_SET_10_LSB                                                 0
-#define PHY_BB_CALTX_GAIN_SET_10_CALTX_GAIN_SET_10_MASK                                       0x00003fff
-#define PHY_BB_CALTX_GAIN_SET_10_CALTX_GAIN_SET_10_GET(x)                      (((x) & 0x00003fff) >> 0)
-#define PHY_BB_CALTX_GAIN_SET_10_CALTX_GAIN_SET_10_SET(x)                      (((x) << 0) & 0x00003fff)
-#define PHY_BB_CALTX_GAIN_SET_10_CALTX_GAIN_SET_11_MSB                                                27
-#define PHY_BB_CALTX_GAIN_SET_10_CALTX_GAIN_SET_11_LSB                                                14
-#define PHY_BB_CALTX_GAIN_SET_10_CALTX_GAIN_SET_11_MASK                                       0x0fffc000
-#define PHY_BB_CALTX_GAIN_SET_10_CALTX_GAIN_SET_11_GET(x)                     (((x) & 0x0fffc000) >> 14)
-#define PHY_BB_CALTX_GAIN_SET_10_CALTX_GAIN_SET_11_SET(x)                     (((x) << 14) & 0x0fffc000)
-
-/* macros for BB_caltx_gain_set_12 */
-#define PHY_BB_CALTX_GAIN_SET_12_ADDRESS                                                      0x0000a530
-#define PHY_BB_CALTX_GAIN_SET_12_OFFSET                                                       0x0000a530
-#define PHY_BB_CALTX_GAIN_SET_12_CALTX_GAIN_SET_12_MSB                                                13
-#define PHY_BB_CALTX_GAIN_SET_12_CALTX_GAIN_SET_12_LSB                                                 0
-#define PHY_BB_CALTX_GAIN_SET_12_CALTX_GAIN_SET_12_MASK                                       0x00003fff
-#define PHY_BB_CALTX_GAIN_SET_12_CALTX_GAIN_SET_12_GET(x)                      (((x) & 0x00003fff) >> 0)
-#define PHY_BB_CALTX_GAIN_SET_12_CALTX_GAIN_SET_12_SET(x)                      (((x) << 0) & 0x00003fff)
-#define PHY_BB_CALTX_GAIN_SET_12_CALTX_GAIN_SET_13_MSB                                                27
-#define PHY_BB_CALTX_GAIN_SET_12_CALTX_GAIN_SET_13_LSB                                                14
-#define PHY_BB_CALTX_GAIN_SET_12_CALTX_GAIN_SET_13_MASK                                       0x0fffc000
-#define PHY_BB_CALTX_GAIN_SET_12_CALTX_GAIN_SET_13_GET(x)                     (((x) & 0x0fffc000) >> 14)
-#define PHY_BB_CALTX_GAIN_SET_12_CALTX_GAIN_SET_13_SET(x)                     (((x) << 14) & 0x0fffc000)
-
-/* macros for BB_caltx_gain_set_14 */
-#define PHY_BB_CALTX_GAIN_SET_14_ADDRESS                                                      0x0000a534
-#define PHY_BB_CALTX_GAIN_SET_14_OFFSET                                                       0x0000a534
-#define PHY_BB_CALTX_GAIN_SET_14_CALTX_GAIN_SET_14_MSB                                                13
-#define PHY_BB_CALTX_GAIN_SET_14_CALTX_GAIN_SET_14_LSB                                                 0
-#define PHY_BB_CALTX_GAIN_SET_14_CALTX_GAIN_SET_14_MASK                                       0x00003fff
-#define PHY_BB_CALTX_GAIN_SET_14_CALTX_GAIN_SET_14_GET(x)                      (((x) & 0x00003fff) >> 0)
-#define PHY_BB_CALTX_GAIN_SET_14_CALTX_GAIN_SET_14_SET(x)                      (((x) << 0) & 0x00003fff)
-#define PHY_BB_CALTX_GAIN_SET_14_CALTX_GAIN_SET_15_MSB                                                27
-#define PHY_BB_CALTX_GAIN_SET_14_CALTX_GAIN_SET_15_LSB                                                14
-#define PHY_BB_CALTX_GAIN_SET_14_CALTX_GAIN_SET_15_MASK                                       0x0fffc000
-#define PHY_BB_CALTX_GAIN_SET_14_CALTX_GAIN_SET_15_GET(x)                     (((x) & 0x0fffc000) >> 14)
-#define PHY_BB_CALTX_GAIN_SET_14_CALTX_GAIN_SET_15_SET(x)                     (((x) << 14) & 0x0fffc000)
-
-/* macros for BB_caltx_gain_set_16 */
-#define PHY_BB_CALTX_GAIN_SET_16_ADDRESS                                                      0x0000a538
-#define PHY_BB_CALTX_GAIN_SET_16_OFFSET                                                       0x0000a538
-#define PHY_BB_CALTX_GAIN_SET_16_CALTX_GAIN_SET_16_MSB                                                13
-#define PHY_BB_CALTX_GAIN_SET_16_CALTX_GAIN_SET_16_LSB                                                 0
-#define PHY_BB_CALTX_GAIN_SET_16_CALTX_GAIN_SET_16_MASK                                       0x00003fff
-#define PHY_BB_CALTX_GAIN_SET_16_CALTX_GAIN_SET_16_GET(x)                      (((x) & 0x00003fff) >> 0)
-#define PHY_BB_CALTX_GAIN_SET_16_CALTX_GAIN_SET_16_SET(x)                      (((x) << 0) & 0x00003fff)
-#define PHY_BB_CALTX_GAIN_SET_16_CALTX_GAIN_SET_17_MSB                                                27
-#define PHY_BB_CALTX_GAIN_SET_16_CALTX_GAIN_SET_17_LSB                                                14
-#define PHY_BB_CALTX_GAIN_SET_16_CALTX_GAIN_SET_17_MASK                                       0x0fffc000
-#define PHY_BB_CALTX_GAIN_SET_16_CALTX_GAIN_SET_17_GET(x)                     (((x) & 0x0fffc000) >> 14)
-#define PHY_BB_CALTX_GAIN_SET_16_CALTX_GAIN_SET_17_SET(x)                     (((x) << 14) & 0x0fffc000)
-
-/* macros for BB_caltx_gain_set_18 */
-#define PHY_BB_CALTX_GAIN_SET_18_ADDRESS                                                      0x0000a53c
-#define PHY_BB_CALTX_GAIN_SET_18_OFFSET                                                       0x0000a53c
-#define PHY_BB_CALTX_GAIN_SET_18_CALTX_GAIN_SET_18_MSB                                                13
-#define PHY_BB_CALTX_GAIN_SET_18_CALTX_GAIN_SET_18_LSB                                                 0
-#define PHY_BB_CALTX_GAIN_SET_18_CALTX_GAIN_SET_18_MASK                                       0x00003fff
-#define PHY_BB_CALTX_GAIN_SET_18_CALTX_GAIN_SET_18_GET(x)                      (((x) & 0x00003fff) >> 0)
-#define PHY_BB_CALTX_GAIN_SET_18_CALTX_GAIN_SET_18_SET(x)                      (((x) << 0) & 0x00003fff)
-#define PHY_BB_CALTX_GAIN_SET_18_CALTX_GAIN_SET_19_MSB                                                27
-#define PHY_BB_CALTX_GAIN_SET_18_CALTX_GAIN_SET_19_LSB                                                14
-#define PHY_BB_CALTX_GAIN_SET_18_CALTX_GAIN_SET_19_MASK                                       0x0fffc000
-#define PHY_BB_CALTX_GAIN_SET_18_CALTX_GAIN_SET_19_GET(x)                     (((x) & 0x0fffc000) >> 14)
-#define PHY_BB_CALTX_GAIN_SET_18_CALTX_GAIN_SET_19_SET(x)                     (((x) << 14) & 0x0fffc000)
-
-/* macros for BB_caltx_gain_set_20 */
-#define PHY_BB_CALTX_GAIN_SET_20_ADDRESS                                                      0x0000a540
-#define PHY_BB_CALTX_GAIN_SET_20_OFFSET                                                       0x0000a540
-#define PHY_BB_CALTX_GAIN_SET_20_CALTX_GAIN_SET_20_MSB                                                13
-#define PHY_BB_CALTX_GAIN_SET_20_CALTX_GAIN_SET_20_LSB                                                 0
-#define PHY_BB_CALTX_GAIN_SET_20_CALTX_GAIN_SET_20_MASK                                       0x00003fff
-#define PHY_BB_CALTX_GAIN_SET_20_CALTX_GAIN_SET_20_GET(x)                      (((x) & 0x00003fff) >> 0)
-#define PHY_BB_CALTX_GAIN_SET_20_CALTX_GAIN_SET_20_SET(x)                      (((x) << 0) & 0x00003fff)
-#define PHY_BB_CALTX_GAIN_SET_20_CALTX_GAIN_SET_21_MSB                                                27
-#define PHY_BB_CALTX_GAIN_SET_20_CALTX_GAIN_SET_21_LSB                                                14
-#define PHY_BB_CALTX_GAIN_SET_20_CALTX_GAIN_SET_21_MASK                                       0x0fffc000
-#define PHY_BB_CALTX_GAIN_SET_20_CALTX_GAIN_SET_21_GET(x)                     (((x) & 0x0fffc000) >> 14)
-#define PHY_BB_CALTX_GAIN_SET_20_CALTX_GAIN_SET_21_SET(x)                     (((x) << 14) & 0x0fffc000)
-
-/* macros for BB_caltx_gain_set_22 */
-#define PHY_BB_CALTX_GAIN_SET_22_ADDRESS                                                      0x0000a544
-#define PHY_BB_CALTX_GAIN_SET_22_OFFSET                                                       0x0000a544
-#define PHY_BB_CALTX_GAIN_SET_22_CALTX_GAIN_SET_22_MSB                                                13
-#define PHY_BB_CALTX_GAIN_SET_22_CALTX_GAIN_SET_22_LSB                                                 0
-#define PHY_BB_CALTX_GAIN_SET_22_CALTX_GAIN_SET_22_MASK                                       0x00003fff
-#define PHY_BB_CALTX_GAIN_SET_22_CALTX_GAIN_SET_22_GET(x)                      (((x) & 0x00003fff) >> 0)
-#define PHY_BB_CALTX_GAIN_SET_22_CALTX_GAIN_SET_22_SET(x)                      (((x) << 0) & 0x00003fff)
-#define PHY_BB_CALTX_GAIN_SET_22_CALTX_GAIN_SET_23_MSB                                                27
-#define PHY_BB_CALTX_GAIN_SET_22_CALTX_GAIN_SET_23_LSB                                                14
-#define PHY_BB_CALTX_GAIN_SET_22_CALTX_GAIN_SET_23_MASK                                       0x0fffc000
-#define PHY_BB_CALTX_GAIN_SET_22_CALTX_GAIN_SET_23_GET(x)                     (((x) & 0x0fffc000) >> 14)
-#define PHY_BB_CALTX_GAIN_SET_22_CALTX_GAIN_SET_23_SET(x)                     (((x) << 14) & 0x0fffc000)
-
-/* macros for BB_caltx_gain_set_24 */
-#define PHY_BB_CALTX_GAIN_SET_24_ADDRESS                                                      0x0000a548
-#define PHY_BB_CALTX_GAIN_SET_24_OFFSET                                                       0x0000a548
-#define PHY_BB_CALTX_GAIN_SET_24_CALTX_GAIN_SET_24_MSB                                                13
-#define PHY_BB_CALTX_GAIN_SET_24_CALTX_GAIN_SET_24_LSB                                                 0
-#define PHY_BB_CALTX_GAIN_SET_24_CALTX_GAIN_SET_24_MASK                                       0x00003fff
-#define PHY_BB_CALTX_GAIN_SET_24_CALTX_GAIN_SET_24_GET(x)                      (((x) & 0x00003fff) >> 0)
-#define PHY_BB_CALTX_GAIN_SET_24_CALTX_GAIN_SET_24_SET(x)                      (((x) << 0) & 0x00003fff)
-#define PHY_BB_CALTX_GAIN_SET_24_CALTX_GAIN_SET_25_MSB                                                27
-#define PHY_BB_CALTX_GAIN_SET_24_CALTX_GAIN_SET_25_LSB                                                14
-#define PHY_BB_CALTX_GAIN_SET_24_CALTX_GAIN_SET_25_MASK                                       0x0fffc000
-#define PHY_BB_CALTX_GAIN_SET_24_CALTX_GAIN_SET_25_GET(x)                     (((x) & 0x0fffc000) >> 14)
-#define PHY_BB_CALTX_GAIN_SET_24_CALTX_GAIN_SET_25_SET(x)                     (((x) << 14) & 0x0fffc000)
-
-/* macros for BB_caltx_gain_set_26 */
-#define PHY_BB_CALTX_GAIN_SET_26_ADDRESS                                                      0x0000a54c
-#define PHY_BB_CALTX_GAIN_SET_26_OFFSET                                                       0x0000a54c
-#define PHY_BB_CALTX_GAIN_SET_26_CALTX_GAIN_SET_26_MSB                                                13
-#define PHY_BB_CALTX_GAIN_SET_26_CALTX_GAIN_SET_26_LSB                                                 0
-#define PHY_BB_CALTX_GAIN_SET_26_CALTX_GAIN_SET_26_MASK                                       0x00003fff
-#define PHY_BB_CALTX_GAIN_SET_26_CALTX_GAIN_SET_26_GET(x)                      (((x) & 0x00003fff) >> 0)
-#define PHY_BB_CALTX_GAIN_SET_26_CALTX_GAIN_SET_26_SET(x)                      (((x) << 0) & 0x00003fff)
-#define PHY_BB_CALTX_GAIN_SET_26_CALTX_GAIN_SET_27_MSB                                                27
-#define PHY_BB_CALTX_GAIN_SET_26_CALTX_GAIN_SET_27_LSB                                                14
-#define PHY_BB_CALTX_GAIN_SET_26_CALTX_GAIN_SET_27_MASK                                       0x0fffc000
-#define PHY_BB_CALTX_GAIN_SET_26_CALTX_GAIN_SET_27_GET(x)                     (((x) & 0x0fffc000) >> 14)
-#define PHY_BB_CALTX_GAIN_SET_26_CALTX_GAIN_SET_27_SET(x)                     (((x) << 14) & 0x0fffc000)
-
-/* macros for BB_caltx_gain_set_28 */
-#define PHY_BB_CALTX_GAIN_SET_28_ADDRESS                                                      0x0000a550
-#define PHY_BB_CALTX_GAIN_SET_28_OFFSET                                                       0x0000a550
-#define PHY_BB_CALTX_GAIN_SET_28_CALTX_GAIN_SET_28_MSB                                                13
-#define PHY_BB_CALTX_GAIN_SET_28_CALTX_GAIN_SET_28_LSB                                                 0
-#define PHY_BB_CALTX_GAIN_SET_28_CALTX_GAIN_SET_28_MASK                                       0x00003fff
-#define PHY_BB_CALTX_GAIN_SET_28_CALTX_GAIN_SET_28_GET(x)                      (((x) & 0x00003fff) >> 0)
-#define PHY_BB_CALTX_GAIN_SET_28_CALTX_GAIN_SET_28_SET(x)                      (((x) << 0) & 0x00003fff)
-#define PHY_BB_CALTX_GAIN_SET_28_CALTX_GAIN_SET_29_MSB                                                27
-#define PHY_BB_CALTX_GAIN_SET_28_CALTX_GAIN_SET_29_LSB                                                14
-#define PHY_BB_CALTX_GAIN_SET_28_CALTX_GAIN_SET_29_MASK                                       0x0fffc000
-#define PHY_BB_CALTX_GAIN_SET_28_CALTX_GAIN_SET_29_GET(x)                     (((x) & 0x0fffc000) >> 14)
-#define PHY_BB_CALTX_GAIN_SET_28_CALTX_GAIN_SET_29_SET(x)                     (((x) << 14) & 0x0fffc000)
-
-/* macros for BB_caltx_gain_set_30 */
-#define PHY_BB_CALTX_GAIN_SET_30_ADDRESS                                                      0x0000a554
-#define PHY_BB_CALTX_GAIN_SET_30_OFFSET                                                       0x0000a554
-#define PHY_BB_CALTX_GAIN_SET_30_CALTX_GAIN_SET_30_MSB                                                13
-#define PHY_BB_CALTX_GAIN_SET_30_CALTX_GAIN_SET_30_LSB                                                 0
-#define PHY_BB_CALTX_GAIN_SET_30_CALTX_GAIN_SET_30_MASK                                       0x00003fff
-#define PHY_BB_CALTX_GAIN_SET_30_CALTX_GAIN_SET_30_GET(x)                      (((x) & 0x00003fff) >> 0)
-#define PHY_BB_CALTX_GAIN_SET_30_CALTX_GAIN_SET_30_SET(x)                      (((x) << 0) & 0x00003fff)
-#define PHY_BB_CALTX_GAIN_SET_30_CALTX_GAIN_SET_31_MSB                                                27
-#define PHY_BB_CALTX_GAIN_SET_30_CALTX_GAIN_SET_31_LSB                                                14
-#define PHY_BB_CALTX_GAIN_SET_30_CALTX_GAIN_SET_31_MASK                                       0x0fffc000
-#define PHY_BB_CALTX_GAIN_SET_30_CALTX_GAIN_SET_31_GET(x)                     (((x) & 0x0fffc000) >> 14)
-#define PHY_BB_CALTX_GAIN_SET_30_CALTX_GAIN_SET_31_SET(x)                     (((x) << 14) & 0x0fffc000)
-
-/* macros for BB_txiqcal_meas_b0 */
-#define PHY_BB_TXIQCAL_MEAS_B0_ADDRESS                                                        0x0000a558
-#define PHY_BB_TXIQCAL_MEAS_B0_OFFSET                                                         0x0000a558
-#define PHY_BB_TXIQCAL_MEAS_B0_TXIQC_MEAS_DATA0_0_MSB                                                 11
-#define PHY_BB_TXIQCAL_MEAS_B0_TXIQC_MEAS_DATA0_0_LSB                                                  0
-#define PHY_BB_TXIQCAL_MEAS_B0_TXIQC_MEAS_DATA0_0_MASK                                        0x00000fff
-#define PHY_BB_TXIQCAL_MEAS_B0_TXIQC_MEAS_DATA0_0_GET(x)                       (((x) & 0x00000fff) >> 0)
-#define PHY_BB_TXIQCAL_MEAS_B0_TXIQC_MEAS_DATA1_0_MSB                                                 23
-#define PHY_BB_TXIQCAL_MEAS_B0_TXIQC_MEAS_DATA1_0_LSB                                                 12
-#define PHY_BB_TXIQCAL_MEAS_B0_TXIQC_MEAS_DATA1_0_MASK                                        0x00fff000
-#define PHY_BB_TXIQCAL_MEAS_B0_TXIQC_MEAS_DATA1_0_GET(x)                      (((x) & 0x00fff000) >> 12)
-
-/* macros for BB_txiqcal_start */
-#define PHY_BB_TXIQCAL_START_ADDRESS                                                          0x0000a6d8
-#define PHY_BB_TXIQCAL_START_OFFSET                                                           0x0000a6d8
-#define PHY_BB_TXIQCAL_START_DO_TX_IQCAL_MSB                                                           0
-#define PHY_BB_TXIQCAL_START_DO_TX_IQCAL_LSB                                                           0
-#define PHY_BB_TXIQCAL_START_DO_TX_IQCAL_MASK                                                 0x00000001
-#define PHY_BB_TXIQCAL_START_DO_TX_IQCAL_GET(x)                                (((x) & 0x00000001) >> 0)
-#define PHY_BB_TXIQCAL_START_DO_TX_IQCAL_SET(x)                                (((x) << 0) & 0x00000001)
-
-/* macros for BB_txiqcal_control_0 */
-#define PHY_BB_TXIQCAL_CONTROL_0_ADDRESS                                                      0x0000a6dc
-#define PHY_BB_TXIQCAL_CONTROL_0_OFFSET                                                       0x0000a6dc
-#define PHY_BB_TXIQCAL_CONTROL_0_IQC_TX_TABLE_SEL_MSB                                                  0
-#define PHY_BB_TXIQCAL_CONTROL_0_IQC_TX_TABLE_SEL_LSB                                                  0
-#define PHY_BB_TXIQCAL_CONTROL_0_IQC_TX_TABLE_SEL_MASK                                        0x00000001
-#define PHY_BB_TXIQCAL_CONTROL_0_IQC_TX_TABLE_SEL_GET(x)                       (((x) & 0x00000001) >> 0)
-#define PHY_BB_TXIQCAL_CONTROL_0_IQC_TX_TABLE_SEL_SET(x)                       (((x) << 0) & 0x00000001)
-#define PHY_BB_TXIQCAL_CONTROL_0_BASE_TX_TONE_DB_MSB                                                   6
-#define PHY_BB_TXIQCAL_CONTROL_0_BASE_TX_TONE_DB_LSB                                                   1
-#define PHY_BB_TXIQCAL_CONTROL_0_BASE_TX_TONE_DB_MASK                                         0x0000007e
-#define PHY_BB_TXIQCAL_CONTROL_0_BASE_TX_TONE_DB_GET(x)                        (((x) & 0x0000007e) >> 1)
-#define PHY_BB_TXIQCAL_CONTROL_0_BASE_TX_TONE_DB_SET(x)                        (((x) << 1) & 0x0000007e)
-#define PHY_BB_TXIQCAL_CONTROL_0_MAX_TX_TONE_GAIN_MSB                                                 12
-#define PHY_BB_TXIQCAL_CONTROL_0_MAX_TX_TONE_GAIN_LSB                                                  7
-#define PHY_BB_TXIQCAL_CONTROL_0_MAX_TX_TONE_GAIN_MASK                                        0x00001f80
-#define PHY_BB_TXIQCAL_CONTROL_0_MAX_TX_TONE_GAIN_GET(x)                       (((x) & 0x00001f80) >> 7)
-#define PHY_BB_TXIQCAL_CONTROL_0_MAX_TX_TONE_GAIN_SET(x)                       (((x) << 7) & 0x00001f80)
-#define PHY_BB_TXIQCAL_CONTROL_0_MIN_TX_TONE_GAIN_MSB                                                 18
-#define PHY_BB_TXIQCAL_CONTROL_0_MIN_TX_TONE_GAIN_LSB                                                 13
-#define PHY_BB_TXIQCAL_CONTROL_0_MIN_TX_TONE_GAIN_MASK                                        0x0007e000
-#define PHY_BB_TXIQCAL_CONTROL_0_MIN_TX_TONE_GAIN_GET(x)                      (((x) & 0x0007e000) >> 13)
-#define PHY_BB_TXIQCAL_CONTROL_0_MIN_TX_TONE_GAIN_SET(x)                      (((x) << 13) & 0x0007e000)
-#define PHY_BB_TXIQCAL_CONTROL_0_CALTXSHIFT_DELAY_MSB                                                 22
-#define PHY_BB_TXIQCAL_CONTROL_0_CALTXSHIFT_DELAY_LSB                                                 19
-#define PHY_BB_TXIQCAL_CONTROL_0_CALTXSHIFT_DELAY_MASK                                        0x00780000
-#define PHY_BB_TXIQCAL_CONTROL_0_CALTXSHIFT_DELAY_GET(x)                      (((x) & 0x00780000) >> 19)
-#define PHY_BB_TXIQCAL_CONTROL_0_CALTXSHIFT_DELAY_SET(x)                      (((x) << 19) & 0x00780000)
-#define PHY_BB_TXIQCAL_CONTROL_0_LOOPBACK_DELAY_MSB                                                   29
-#define PHY_BB_TXIQCAL_CONTROL_0_LOOPBACK_DELAY_LSB                                                   23
-#define PHY_BB_TXIQCAL_CONTROL_0_LOOPBACK_DELAY_MASK                                          0x3f800000
-#define PHY_BB_TXIQCAL_CONTROL_0_LOOPBACK_DELAY_GET(x)                        (((x) & 0x3f800000) >> 23)
-#define PHY_BB_TXIQCAL_CONTROL_0_LOOPBACK_DELAY_SET(x)                        (((x) << 23) & 0x3f800000)
-
-/* macros for BB_txiqcal_control_1 */
-#define PHY_BB_TXIQCAL_CONTROL_1_ADDRESS                                                      0x0000a6e0
-#define PHY_BB_TXIQCAL_CONTROL_1_OFFSET                                                       0x0000a6e0
-#define PHY_BB_TXIQCAL_CONTROL_1_RX_INIT_GAIN_DB_MSB                                                   5
-#define PHY_BB_TXIQCAL_CONTROL_1_RX_INIT_GAIN_DB_LSB                                                   0
-#define PHY_BB_TXIQCAL_CONTROL_1_RX_INIT_GAIN_DB_MASK                                         0x0000003f
-#define PHY_BB_TXIQCAL_CONTROL_1_RX_INIT_GAIN_DB_GET(x)                        (((x) & 0x0000003f) >> 0)
-#define PHY_BB_TXIQCAL_CONTROL_1_RX_INIT_GAIN_DB_SET(x)                        (((x) << 0) & 0x0000003f)
-#define PHY_BB_TXIQCAL_CONTROL_1_MAX_RX_GAIN_DB_MSB                                                   11
-#define PHY_BB_TXIQCAL_CONTROL_1_MAX_RX_GAIN_DB_LSB                                                    6
-#define PHY_BB_TXIQCAL_CONTROL_1_MAX_RX_GAIN_DB_MASK                                          0x00000fc0
-#define PHY_BB_TXIQCAL_CONTROL_1_MAX_RX_GAIN_DB_GET(x)                         (((x) & 0x00000fc0) >> 6)
-#define PHY_BB_TXIQCAL_CONTROL_1_MAX_RX_GAIN_DB_SET(x)                         (((x) << 6) & 0x00000fc0)
-#define PHY_BB_TXIQCAL_CONTROL_1_MIN_RX_GAIN_DB_MSB                                                   17
-#define PHY_BB_TXIQCAL_CONTROL_1_MIN_RX_GAIN_DB_LSB                                                   12
-#define PHY_BB_TXIQCAL_CONTROL_1_MIN_RX_GAIN_DB_MASK                                          0x0003f000
-#define PHY_BB_TXIQCAL_CONTROL_1_MIN_RX_GAIN_DB_GET(x)                        (((x) & 0x0003f000) >> 12)
-#define PHY_BB_TXIQCAL_CONTROL_1_MIN_RX_GAIN_DB_SET(x)                        (((x) << 12) & 0x0003f000)
-#define PHY_BB_TXIQCAL_CONTROL_1_IQCORR_I_Q_COFF_DELPT_MSB                                            24
-#define PHY_BB_TXIQCAL_CONTROL_1_IQCORR_I_Q_COFF_DELPT_LSB                                            18
-#define PHY_BB_TXIQCAL_CONTROL_1_IQCORR_I_Q_COFF_DELPT_MASK                                   0x01fc0000
-#define PHY_BB_TXIQCAL_CONTROL_1_IQCORR_I_Q_COFF_DELPT_GET(x)                 (((x) & 0x01fc0000) >> 18)
-#define PHY_BB_TXIQCAL_CONTROL_1_IQCORR_I_Q_COFF_DELPT_SET(x)                 (((x) << 18) & 0x01fc0000)
-
-/* macros for BB_txiqcal_control_2 */
-#define PHY_BB_TXIQCAL_CONTROL_2_ADDRESS                                                      0x0000a6e4
-#define PHY_BB_TXIQCAL_CONTROL_2_OFFSET                                                       0x0000a6e4
-#define PHY_BB_TXIQCAL_CONTROL_2_IQC_FORCED_PAGAIN_MSB                                                 3
-#define PHY_BB_TXIQCAL_CONTROL_2_IQC_FORCED_PAGAIN_LSB                                                 0
-#define PHY_BB_TXIQCAL_CONTROL_2_IQC_FORCED_PAGAIN_MASK                                       0x0000000f
-#define PHY_BB_TXIQCAL_CONTROL_2_IQC_FORCED_PAGAIN_GET(x)                      (((x) & 0x0000000f) >> 0)
-#define PHY_BB_TXIQCAL_CONTROL_2_IQC_FORCED_PAGAIN_SET(x)                      (((x) << 0) & 0x0000000f)
-#define PHY_BB_TXIQCAL_CONTROL_2_IQCAL_MIN_TX_GAIN_MSB                                                 8
-#define PHY_BB_TXIQCAL_CONTROL_2_IQCAL_MIN_TX_GAIN_LSB                                                 4
-#define PHY_BB_TXIQCAL_CONTROL_2_IQCAL_MIN_TX_GAIN_MASK                                       0x000001f0
-#define PHY_BB_TXIQCAL_CONTROL_2_IQCAL_MIN_TX_GAIN_GET(x)                      (((x) & 0x000001f0) >> 4)
-#define PHY_BB_TXIQCAL_CONTROL_2_IQCAL_MIN_TX_GAIN_SET(x)                      (((x) << 4) & 0x000001f0)
-#define PHY_BB_TXIQCAL_CONTROL_2_IQCAL_MAX_TX_GAIN_MSB                                                13
-#define PHY_BB_TXIQCAL_CONTROL_2_IQCAL_MAX_TX_GAIN_LSB                                                 9
-#define PHY_BB_TXIQCAL_CONTROL_2_IQCAL_MAX_TX_GAIN_MASK                                       0x00003e00
-#define PHY_BB_TXIQCAL_CONTROL_2_IQCAL_MAX_TX_GAIN_GET(x)                      (((x) & 0x00003e00) >> 9)
-#define PHY_BB_TXIQCAL_CONTROL_2_IQCAL_MAX_TX_GAIN_SET(x)                      (((x) << 9) & 0x00003e00)
-
-/* macros for BB_txiqcal_control_3 */
-#define PHY_BB_TXIQCAL_CONTROL_3_ADDRESS                                                      0x0000a6e8
-#define PHY_BB_TXIQCAL_CONTROL_3_OFFSET                                                       0x0000a6e8
-#define PHY_BB_TXIQCAL_CONTROL_3_PWR_HIGH_DB_MSB                                                       5
-#define PHY_BB_TXIQCAL_CONTROL_3_PWR_HIGH_DB_LSB                                                       0
-#define PHY_BB_TXIQCAL_CONTROL_3_PWR_HIGH_DB_MASK                                             0x0000003f
-#define PHY_BB_TXIQCAL_CONTROL_3_PWR_HIGH_DB_GET(x)                            (((x) & 0x0000003f) >> 0)
-#define PHY_BB_TXIQCAL_CONTROL_3_PWR_HIGH_DB_SET(x)                            (((x) << 0) & 0x0000003f)
-#define PHY_BB_TXIQCAL_CONTROL_3_PWR_LOW_DB_MSB                                                       11
-#define PHY_BB_TXIQCAL_CONTROL_3_PWR_LOW_DB_LSB                                                        6
-#define PHY_BB_TXIQCAL_CONTROL_3_PWR_LOW_DB_MASK                                              0x00000fc0
-#define PHY_BB_TXIQCAL_CONTROL_3_PWR_LOW_DB_GET(x)                             (((x) & 0x00000fc0) >> 6)
-#define PHY_BB_TXIQCAL_CONTROL_3_PWR_LOW_DB_SET(x)                             (((x) << 6) & 0x00000fc0)
-#define PHY_BB_TXIQCAL_CONTROL_3_IQCAL_TONE_PHS_STEP_MSB                                              21
-#define PHY_BB_TXIQCAL_CONTROL_3_IQCAL_TONE_PHS_STEP_LSB                                              12
-#define PHY_BB_TXIQCAL_CONTROL_3_IQCAL_TONE_PHS_STEP_MASK                                     0x003ff000
-#define PHY_BB_TXIQCAL_CONTROL_3_IQCAL_TONE_PHS_STEP_GET(x)                   (((x) & 0x003ff000) >> 12)
-#define PHY_BB_TXIQCAL_CONTROL_3_IQCAL_TONE_PHS_STEP_SET(x)                   (((x) << 12) & 0x003ff000)
-#define PHY_BB_TXIQCAL_CONTROL_3_DC_EST_LEN_MSB                                                       23
-#define PHY_BB_TXIQCAL_CONTROL_3_DC_EST_LEN_LSB                                                       22
-#define PHY_BB_TXIQCAL_CONTROL_3_DC_EST_LEN_MASK                                              0x00c00000
-#define PHY_BB_TXIQCAL_CONTROL_3_DC_EST_LEN_GET(x)                            (((x) & 0x00c00000) >> 22)
-#define PHY_BB_TXIQCAL_CONTROL_3_DC_EST_LEN_SET(x)                            (((x) << 22) & 0x00c00000)
-#define PHY_BB_TXIQCAL_CONTROL_3_ADC_SAT_LEN_MSB                                                      24
-#define PHY_BB_TXIQCAL_CONTROL_3_ADC_SAT_LEN_LSB                                                      24
-#define PHY_BB_TXIQCAL_CONTROL_3_ADC_SAT_LEN_MASK                                             0x01000000
-#define PHY_BB_TXIQCAL_CONTROL_3_ADC_SAT_LEN_GET(x)                           (((x) & 0x01000000) >> 24)
-#define PHY_BB_TXIQCAL_CONTROL_3_ADC_SAT_LEN_SET(x)                           (((x) << 24) & 0x01000000)
-#define PHY_BB_TXIQCAL_CONTROL_3_ADC_SAT_SEL_MSB                                                      26
-#define PHY_BB_TXIQCAL_CONTROL_3_ADC_SAT_SEL_LSB                                                      25
-#define PHY_BB_TXIQCAL_CONTROL_3_ADC_SAT_SEL_MASK                                             0x06000000
-#define PHY_BB_TXIQCAL_CONTROL_3_ADC_SAT_SEL_GET(x)                           (((x) & 0x06000000) >> 25)
-#define PHY_BB_TXIQCAL_CONTROL_3_ADC_SAT_SEL_SET(x)                           (((x) << 25) & 0x06000000)
-#define PHY_BB_TXIQCAL_CONTROL_3_IQCAL_MEAS_LEN_MSB                                                   28
-#define PHY_BB_TXIQCAL_CONTROL_3_IQCAL_MEAS_LEN_LSB                                                   27
-#define PHY_BB_TXIQCAL_CONTROL_3_IQCAL_MEAS_LEN_MASK                                          0x18000000
-#define PHY_BB_TXIQCAL_CONTROL_3_IQCAL_MEAS_LEN_GET(x)                        (((x) & 0x18000000) >> 27)
-#define PHY_BB_TXIQCAL_CONTROL_3_IQCAL_MEAS_LEN_SET(x)                        (((x) << 27) & 0x18000000)
-#define PHY_BB_TXIQCAL_CONTROL_3_DESIRED_SIZE_DB_MSB                                                  30
-#define PHY_BB_TXIQCAL_CONTROL_3_DESIRED_SIZE_DB_LSB                                                  29
-#define PHY_BB_TXIQCAL_CONTROL_3_DESIRED_SIZE_DB_MASK                                         0x60000000
-#define PHY_BB_TXIQCAL_CONTROL_3_DESIRED_SIZE_DB_GET(x)                       (((x) & 0x60000000) >> 29)
-#define PHY_BB_TXIQCAL_CONTROL_3_DESIRED_SIZE_DB_SET(x)                       (((x) << 29) & 0x60000000)
-#define PHY_BB_TXIQCAL_CONTROL_3_TX_IQCORR_EN_MSB                                                     31
-#define PHY_BB_TXIQCAL_CONTROL_3_TX_IQCORR_EN_LSB                                                     31
-#define PHY_BB_TXIQCAL_CONTROL_3_TX_IQCORR_EN_MASK                                            0x80000000
-#define PHY_BB_TXIQCAL_CONTROL_3_TX_IQCORR_EN_GET(x)                          (((x) & 0x80000000) >> 31)
-#define PHY_BB_TXIQCAL_CONTROL_3_TX_IQCORR_EN_SET(x)                          (((x) << 31) & 0x80000000)
-
-/* macros for BB_txiq_corr_coeff_01_b0 */
-#define PHY_BB_TXIQ_CORR_COEFF_01_B0_ADDRESS                                                  0x0000a6ec
-#define PHY_BB_TXIQ_CORR_COEFF_01_B0_OFFSET                                                   0x0000a6ec
-#define PHY_BB_TXIQ_CORR_COEFF_01_B0_IQC_COEFF_TABLE_0_0_MSB                                          13
-#define PHY_BB_TXIQ_CORR_COEFF_01_B0_IQC_COEFF_TABLE_0_0_LSB                                           0
-#define PHY_BB_TXIQ_CORR_COEFF_01_B0_IQC_COEFF_TABLE_0_0_MASK                                 0x00003fff
-#define PHY_BB_TXIQ_CORR_COEFF_01_B0_IQC_COEFF_TABLE_0_0_GET(x)                (((x) & 0x00003fff) >> 0)
-#define PHY_BB_TXIQ_CORR_COEFF_01_B0_IQC_COEFF_TABLE_0_0_SET(x)                (((x) << 0) & 0x00003fff)
-#define PHY_BB_TXIQ_CORR_COEFF_01_B0_IQC_COEFF_TABLE_1_0_MSB                                          27
-#define PHY_BB_TXIQ_CORR_COEFF_01_B0_IQC_COEFF_TABLE_1_0_LSB                                          14
-#define PHY_BB_TXIQ_CORR_COEFF_01_B0_IQC_COEFF_TABLE_1_0_MASK                                 0x0fffc000
-#define PHY_BB_TXIQ_CORR_COEFF_01_B0_IQC_COEFF_TABLE_1_0_GET(x)               (((x) & 0x0fffc000) >> 14)
-#define PHY_BB_TXIQ_CORR_COEFF_01_B0_IQC_COEFF_TABLE_1_0_SET(x)               (((x) << 14) & 0x0fffc000)
-
-/* macros for BB_txiq_corr_coeff_23_b0 */
-#define PHY_BB_TXIQ_CORR_COEFF_23_B0_ADDRESS                                                  0x0000a6f0
-#define PHY_BB_TXIQ_CORR_COEFF_23_B0_OFFSET                                                   0x0000a6f0
-#define PHY_BB_TXIQ_CORR_COEFF_23_B0_IQC_COEFF_TABLE_2_0_MSB                                          13
-#define PHY_BB_TXIQ_CORR_COEFF_23_B0_IQC_COEFF_TABLE_2_0_LSB                                           0
-#define PHY_BB_TXIQ_CORR_COEFF_23_B0_IQC_COEFF_TABLE_2_0_MASK                                 0x00003fff
-#define PHY_BB_TXIQ_CORR_COEFF_23_B0_IQC_COEFF_TABLE_2_0_GET(x)                (((x) & 0x00003fff) >> 0)
-#define PHY_BB_TXIQ_CORR_COEFF_23_B0_IQC_COEFF_TABLE_2_0_SET(x)                (((x) << 0) & 0x00003fff)
-#define PHY_BB_TXIQ_CORR_COEFF_23_B0_IQC_COEFF_TABLE_3_0_MSB                                          27
-#define PHY_BB_TXIQ_CORR_COEFF_23_B0_IQC_COEFF_TABLE_3_0_LSB                                          14
-#define PHY_BB_TXIQ_CORR_COEFF_23_B0_IQC_COEFF_TABLE_3_0_MASK                                 0x0fffc000
-#define PHY_BB_TXIQ_CORR_COEFF_23_B0_IQC_COEFF_TABLE_3_0_GET(x)               (((x) & 0x0fffc000) >> 14)
-#define PHY_BB_TXIQ_CORR_COEFF_23_B0_IQC_COEFF_TABLE_3_0_SET(x)               (((x) << 14) & 0x0fffc000)
-
-/* macros for BB_txiq_corr_coeff_45_b0 */
-#define PHY_BB_TXIQ_CORR_COEFF_45_B0_ADDRESS                                                  0x0000a6f4
-#define PHY_BB_TXIQ_CORR_COEFF_45_B0_OFFSET                                                   0x0000a6f4
-#define PHY_BB_TXIQ_CORR_COEFF_45_B0_IQC_COEFF_TABLE_4_0_MSB                                          13
-#define PHY_BB_TXIQ_CORR_COEFF_45_B0_IQC_COEFF_TABLE_4_0_LSB                                           0
-#define PHY_BB_TXIQ_CORR_COEFF_45_B0_IQC_COEFF_TABLE_4_0_MASK                                 0x00003fff
-#define PHY_BB_TXIQ_CORR_COEFF_45_B0_IQC_COEFF_TABLE_4_0_GET(x)                (((x) & 0x00003fff) >> 0)
-#define PHY_BB_TXIQ_CORR_COEFF_45_B0_IQC_COEFF_TABLE_4_0_SET(x)                (((x) << 0) & 0x00003fff)
-#define PHY_BB_TXIQ_CORR_COEFF_45_B0_IQC_COEFF_TABLE_5_0_MSB                                          27
-#define PHY_BB_TXIQ_CORR_COEFF_45_B0_IQC_COEFF_TABLE_5_0_LSB                                          14
-#define PHY_BB_TXIQ_CORR_COEFF_45_B0_IQC_COEFF_TABLE_5_0_MASK                                 0x0fffc000
-#define PHY_BB_TXIQ_CORR_COEFF_45_B0_IQC_COEFF_TABLE_5_0_GET(x)               (((x) & 0x0fffc000) >> 14)
-#define PHY_BB_TXIQ_CORR_COEFF_45_B0_IQC_COEFF_TABLE_5_0_SET(x)               (((x) << 14) & 0x0fffc000)
-
-/* macros for BB_txiq_corr_coeff_67_b0 */
-#define PHY_BB_TXIQ_CORR_COEFF_67_B0_ADDRESS                                                  0x0000a6f8
-#define PHY_BB_TXIQ_CORR_COEFF_67_B0_OFFSET                                                   0x0000a6f8
-#define PHY_BB_TXIQ_CORR_COEFF_67_B0_IQC_COEFF_TABLE_6_0_MSB                                          13
-#define PHY_BB_TXIQ_CORR_COEFF_67_B0_IQC_COEFF_TABLE_6_0_LSB                                           0
-#define PHY_BB_TXIQ_CORR_COEFF_67_B0_IQC_COEFF_TABLE_6_0_MASK                                 0x00003fff
-#define PHY_BB_TXIQ_CORR_COEFF_67_B0_IQC_COEFF_TABLE_6_0_GET(x)                (((x) & 0x00003fff) >> 0)
-#define PHY_BB_TXIQ_CORR_COEFF_67_B0_IQC_COEFF_TABLE_6_0_SET(x)                (((x) << 0) & 0x00003fff)
-#define PHY_BB_TXIQ_CORR_COEFF_67_B0_IQC_COEFF_TABLE_7_0_MSB                                          27
-#define PHY_BB_TXIQ_CORR_COEFF_67_B0_IQC_COEFF_TABLE_7_0_LSB                                          14
-#define PHY_BB_TXIQ_CORR_COEFF_67_B0_IQC_COEFF_TABLE_7_0_MASK                                 0x0fffc000
-#define PHY_BB_TXIQ_CORR_COEFF_67_B0_IQC_COEFF_TABLE_7_0_GET(x)               (((x) & 0x0fffc000) >> 14)
-#define PHY_BB_TXIQ_CORR_COEFF_67_B0_IQC_COEFF_TABLE_7_0_SET(x)               (((x) << 14) & 0x0fffc000)
-
-/* macros for BB_txiq_corr_coeff_89_b0 */
-#define PHY_BB_TXIQ_CORR_COEFF_89_B0_ADDRESS                                                  0x0000a6fc
-#define PHY_BB_TXIQ_CORR_COEFF_89_B0_OFFSET                                                   0x0000a6fc
-#define PHY_BB_TXIQ_CORR_COEFF_89_B0_IQC_COEFF_TABLE_8_0_MSB                                          13
-#define PHY_BB_TXIQ_CORR_COEFF_89_B0_IQC_COEFF_TABLE_8_0_LSB                                           0
-#define PHY_BB_TXIQ_CORR_COEFF_89_B0_IQC_COEFF_TABLE_8_0_MASK                                 0x00003fff
-#define PHY_BB_TXIQ_CORR_COEFF_89_B0_IQC_COEFF_TABLE_8_0_GET(x)                (((x) & 0x00003fff) >> 0)
-#define PHY_BB_TXIQ_CORR_COEFF_89_B0_IQC_COEFF_TABLE_8_0_SET(x)                (((x) << 0) & 0x00003fff)
-#define PHY_BB_TXIQ_CORR_COEFF_89_B0_IQC_COEFF_TABLE_9_0_MSB                                          27
-#define PHY_BB_TXIQ_CORR_COEFF_89_B0_IQC_COEFF_TABLE_9_0_LSB                                          14
-#define PHY_BB_TXIQ_CORR_COEFF_89_B0_IQC_COEFF_TABLE_9_0_MASK                                 0x0fffc000
-#define PHY_BB_TXIQ_CORR_COEFF_89_B0_IQC_COEFF_TABLE_9_0_GET(x)               (((x) & 0x0fffc000) >> 14)
-#define PHY_BB_TXIQ_CORR_COEFF_89_B0_IQC_COEFF_TABLE_9_0_SET(x)               (((x) << 14) & 0x0fffc000)
-
-/* macros for BB_txiq_corr_coeff_ab_b0 */
-#define PHY_BB_TXIQ_CORR_COEFF_AB_B0_ADDRESS                                                  0x0000a700
-#define PHY_BB_TXIQ_CORR_COEFF_AB_B0_OFFSET                                                   0x0000a700
-#define PHY_BB_TXIQ_CORR_COEFF_AB_B0_IQC_COEFF_TABLE_A_0_MSB                                          13
-#define PHY_BB_TXIQ_CORR_COEFF_AB_B0_IQC_COEFF_TABLE_A_0_LSB                                           0
-#define PHY_BB_TXIQ_CORR_COEFF_AB_B0_IQC_COEFF_TABLE_A_0_MASK                                 0x00003fff
-#define PHY_BB_TXIQ_CORR_COEFF_AB_B0_IQC_COEFF_TABLE_A_0_GET(x)                (((x) & 0x00003fff) >> 0)
-#define PHY_BB_TXIQ_CORR_COEFF_AB_B0_IQC_COEFF_TABLE_A_0_SET(x)                (((x) << 0) & 0x00003fff)
-#define PHY_BB_TXIQ_CORR_COEFF_AB_B0_IQC_COEFF_TABLE_B_0_MSB                                          27
-#define PHY_BB_TXIQ_CORR_COEFF_AB_B0_IQC_COEFF_TABLE_B_0_LSB                                          14
-#define PHY_BB_TXIQ_CORR_COEFF_AB_B0_IQC_COEFF_TABLE_B_0_MASK                                 0x0fffc000
-#define PHY_BB_TXIQ_CORR_COEFF_AB_B0_IQC_COEFF_TABLE_B_0_GET(x)               (((x) & 0x0fffc000) >> 14)
-#define PHY_BB_TXIQ_CORR_COEFF_AB_B0_IQC_COEFF_TABLE_B_0_SET(x)               (((x) << 14) & 0x0fffc000)
-
-/* macros for BB_txiq_corr_coeff_cd_b0 */
-#define PHY_BB_TXIQ_CORR_COEFF_CD_B0_ADDRESS                                                  0x0000a704
-#define PHY_BB_TXIQ_CORR_COEFF_CD_B0_OFFSET                                                   0x0000a704
-#define PHY_BB_TXIQ_CORR_COEFF_CD_B0_IQC_COEFF_TABLE_C_0_MSB                                          13
-#define PHY_BB_TXIQ_CORR_COEFF_CD_B0_IQC_COEFF_TABLE_C_0_LSB                                           0
-#define PHY_BB_TXIQ_CORR_COEFF_CD_B0_IQC_COEFF_TABLE_C_0_MASK                                 0x00003fff
-#define PHY_BB_TXIQ_CORR_COEFF_CD_B0_IQC_COEFF_TABLE_C_0_GET(x)                (((x) & 0x00003fff) >> 0)
-#define PHY_BB_TXIQ_CORR_COEFF_CD_B0_IQC_COEFF_TABLE_C_0_SET(x)                (((x) << 0) & 0x00003fff)
-#define PHY_BB_TXIQ_CORR_COEFF_CD_B0_IQC_COEFF_TABLE_D_0_MSB                                          27
-#define PHY_BB_TXIQ_CORR_COEFF_CD_B0_IQC_COEFF_TABLE_D_0_LSB                                          14
-#define PHY_BB_TXIQ_CORR_COEFF_CD_B0_IQC_COEFF_TABLE_D_0_MASK                                 0x0fffc000
-#define PHY_BB_TXIQ_CORR_COEFF_CD_B0_IQC_COEFF_TABLE_D_0_GET(x)               (((x) & 0x0fffc000) >> 14)
-#define PHY_BB_TXIQ_CORR_COEFF_CD_B0_IQC_COEFF_TABLE_D_0_SET(x)               (((x) << 14) & 0x0fffc000)
-
-/* macros for BB_txiq_corr_coeff_ef_b0 */
-#define PHY_BB_TXIQ_CORR_COEFF_EF_B0_ADDRESS                                                  0x0000a708
-#define PHY_BB_TXIQ_CORR_COEFF_EF_B0_OFFSET                                                   0x0000a708
-#define PHY_BB_TXIQ_CORR_COEFF_EF_B0_IQC_COEFF_TABLE_E_0_MSB                                          13
-#define PHY_BB_TXIQ_CORR_COEFF_EF_B0_IQC_COEFF_TABLE_E_0_LSB                                           0
-#define PHY_BB_TXIQ_CORR_COEFF_EF_B0_IQC_COEFF_TABLE_E_0_MASK                                 0x00003fff
-#define PHY_BB_TXIQ_CORR_COEFF_EF_B0_IQC_COEFF_TABLE_E_0_GET(x)                (((x) & 0x00003fff) >> 0)
-#define PHY_BB_TXIQ_CORR_COEFF_EF_B0_IQC_COEFF_TABLE_E_0_SET(x)                (((x) << 0) & 0x00003fff)
-#define PHY_BB_TXIQ_CORR_COEFF_EF_B0_IQC_COEFF_TABLE_F_0_MSB                                          27
-#define PHY_BB_TXIQ_CORR_COEFF_EF_B0_IQC_COEFF_TABLE_F_0_LSB                                          14
-#define PHY_BB_TXIQ_CORR_COEFF_EF_B0_IQC_COEFF_TABLE_F_0_MASK                                 0x0fffc000
-#define PHY_BB_TXIQ_CORR_COEFF_EF_B0_IQC_COEFF_TABLE_F_0_GET(x)               (((x) & 0x0fffc000) >> 14)
-#define PHY_BB_TXIQ_CORR_COEFF_EF_B0_IQC_COEFF_TABLE_F_0_SET(x)               (((x) << 14) & 0x0fffc000)
-
-/* macros for BB_cal_rxbb_gain_tbl_0 */
-#define PHY_BB_CAL_RXBB_GAIN_TBL_0_ADDRESS                                                    0x0000a70c
-#define PHY_BB_CAL_RXBB_GAIN_TBL_0_OFFSET                                                     0x0000a70c
-#define PHY_BB_CAL_RXBB_GAIN_TBL_0_TXCAL_RX_BB_GAIN_TABLE_0_MSB                                        5
-#define PHY_BB_CAL_RXBB_GAIN_TBL_0_TXCAL_RX_BB_GAIN_TABLE_0_LSB                                        0
-#define PHY_BB_CAL_RXBB_GAIN_TBL_0_TXCAL_RX_BB_GAIN_TABLE_0_MASK                              0x0000003f
-#define PHY_BB_CAL_RXBB_GAIN_TBL_0_TXCAL_RX_BB_GAIN_TABLE_0_GET(x)             (((x) & 0x0000003f) >> 0)
-#define PHY_BB_CAL_RXBB_GAIN_TBL_0_TXCAL_RX_BB_GAIN_TABLE_0_SET(x)             (((x) << 0) & 0x0000003f)
-#define PHY_BB_CAL_RXBB_GAIN_TBL_0_TXCAL_RX_BB_GAIN_TABLE_1_MSB                                       11
-#define PHY_BB_CAL_RXBB_GAIN_TBL_0_TXCAL_RX_BB_GAIN_TABLE_1_LSB                                        6
-#define PHY_BB_CAL_RXBB_GAIN_TBL_0_TXCAL_RX_BB_GAIN_TABLE_1_MASK                              0x00000fc0
-#define PHY_BB_CAL_RXBB_GAIN_TBL_0_TXCAL_RX_BB_GAIN_TABLE_1_GET(x)             (((x) & 0x00000fc0) >> 6)
-#define PHY_BB_CAL_RXBB_GAIN_TBL_0_TXCAL_RX_BB_GAIN_TABLE_1_SET(x)             (((x) << 6) & 0x00000fc0)
-#define PHY_BB_CAL_RXBB_GAIN_TBL_0_TXCAL_RX_BB_GAIN_TABLE_2_MSB                                       17
-#define PHY_BB_CAL_RXBB_GAIN_TBL_0_TXCAL_RX_BB_GAIN_TABLE_2_LSB                                       12
-#define PHY_BB_CAL_RXBB_GAIN_TBL_0_TXCAL_RX_BB_GAIN_TABLE_2_MASK                              0x0003f000
-#define PHY_BB_CAL_RXBB_GAIN_TBL_0_TXCAL_RX_BB_GAIN_TABLE_2_GET(x)            (((x) & 0x0003f000) >> 12)
-#define PHY_BB_CAL_RXBB_GAIN_TBL_0_TXCAL_RX_BB_GAIN_TABLE_2_SET(x)            (((x) << 12) & 0x0003f000)
-#define PHY_BB_CAL_RXBB_GAIN_TBL_0_TXCAL_RX_BB_GAIN_TABLE_3_MSB                                       23
-#define PHY_BB_CAL_RXBB_GAIN_TBL_0_TXCAL_RX_BB_GAIN_TABLE_3_LSB                                       18
-#define PHY_BB_CAL_RXBB_GAIN_TBL_0_TXCAL_RX_BB_GAIN_TABLE_3_MASK                              0x00fc0000
-#define PHY_BB_CAL_RXBB_GAIN_TBL_0_TXCAL_RX_BB_GAIN_TABLE_3_GET(x)            (((x) & 0x00fc0000) >> 18)
-#define PHY_BB_CAL_RXBB_GAIN_TBL_0_TXCAL_RX_BB_GAIN_TABLE_3_SET(x)            (((x) << 18) & 0x00fc0000)
-
-/* macros for BB_cal_rxbb_gain_tbl_4 */
-#define PHY_BB_CAL_RXBB_GAIN_TBL_4_ADDRESS                                                    0x0000a710
-#define PHY_BB_CAL_RXBB_GAIN_TBL_4_OFFSET                                                     0x0000a710
-#define PHY_BB_CAL_RXBB_GAIN_TBL_4_TXCAL_RX_BB_GAIN_TABLE_4_MSB                                        5
-#define PHY_BB_CAL_RXBB_GAIN_TBL_4_TXCAL_RX_BB_GAIN_TABLE_4_LSB                                        0
-#define PHY_BB_CAL_RXBB_GAIN_TBL_4_TXCAL_RX_BB_GAIN_TABLE_4_MASK                              0x0000003f
-#define PHY_BB_CAL_RXBB_GAIN_TBL_4_TXCAL_RX_BB_GAIN_TABLE_4_GET(x)             (((x) & 0x0000003f) >> 0)
-#define PHY_BB_CAL_RXBB_GAIN_TBL_4_TXCAL_RX_BB_GAIN_TABLE_4_SET(x)             (((x) << 0) & 0x0000003f)
-#define PHY_BB_CAL_RXBB_GAIN_TBL_4_TXCAL_RX_BB_GAIN_TABLE_5_MSB                                       11
-#define PHY_BB_CAL_RXBB_GAIN_TBL_4_TXCAL_RX_BB_GAIN_TABLE_5_LSB                                        6
-#define PHY_BB_CAL_RXBB_GAIN_TBL_4_TXCAL_RX_BB_GAIN_TABLE_5_MASK                              0x00000fc0
-#define PHY_BB_CAL_RXBB_GAIN_TBL_4_TXCAL_RX_BB_GAIN_TABLE_5_GET(x)             (((x) & 0x00000fc0) >> 6)
-#define PHY_BB_CAL_RXBB_GAIN_TBL_4_TXCAL_RX_BB_GAIN_TABLE_5_SET(x)             (((x) << 6) & 0x00000fc0)
-#define PHY_BB_CAL_RXBB_GAIN_TBL_4_TXCAL_RX_BB_GAIN_TABLE_6_MSB                                       17
-#define PHY_BB_CAL_RXBB_GAIN_TBL_4_TXCAL_RX_BB_GAIN_TABLE_6_LSB                                       12
-#define PHY_BB_CAL_RXBB_GAIN_TBL_4_TXCAL_RX_BB_GAIN_TABLE_6_MASK                              0x0003f000
-#define PHY_BB_CAL_RXBB_GAIN_TBL_4_TXCAL_RX_BB_GAIN_TABLE_6_GET(x)            (((x) & 0x0003f000) >> 12)
-#define PHY_BB_CAL_RXBB_GAIN_TBL_4_TXCAL_RX_BB_GAIN_TABLE_6_SET(x)            (((x) << 12) & 0x0003f000)
-#define PHY_BB_CAL_RXBB_GAIN_TBL_4_TXCAL_RX_BB_GAIN_TABLE_7_MSB                                       23
-#define PHY_BB_CAL_RXBB_GAIN_TBL_4_TXCAL_RX_BB_GAIN_TABLE_7_LSB                                       18
-#define PHY_BB_CAL_RXBB_GAIN_TBL_4_TXCAL_RX_BB_GAIN_TABLE_7_MASK                              0x00fc0000
-#define PHY_BB_CAL_RXBB_GAIN_TBL_4_TXCAL_RX_BB_GAIN_TABLE_7_GET(x)            (((x) & 0x00fc0000) >> 18)
-#define PHY_BB_CAL_RXBB_GAIN_TBL_4_TXCAL_RX_BB_GAIN_TABLE_7_SET(x)            (((x) << 18) & 0x00fc0000)
-
-/* macros for BB_cal_rxbb_gain_tbl_8 */
-#define PHY_BB_CAL_RXBB_GAIN_TBL_8_ADDRESS                                                    0x0000a714
-#define PHY_BB_CAL_RXBB_GAIN_TBL_8_OFFSET                                                     0x0000a714
-#define PHY_BB_CAL_RXBB_GAIN_TBL_8_TXCAL_RX_BB_GAIN_TABLE_8_MSB                                        5
-#define PHY_BB_CAL_RXBB_GAIN_TBL_8_TXCAL_RX_BB_GAIN_TABLE_8_LSB                                        0
-#define PHY_BB_CAL_RXBB_GAIN_TBL_8_TXCAL_RX_BB_GAIN_TABLE_8_MASK                              0x0000003f
-#define PHY_BB_CAL_RXBB_GAIN_TBL_8_TXCAL_RX_BB_GAIN_TABLE_8_GET(x)             (((x) & 0x0000003f) >> 0)
-#define PHY_BB_CAL_RXBB_GAIN_TBL_8_TXCAL_RX_BB_GAIN_TABLE_8_SET(x)             (((x) << 0) & 0x0000003f)
-#define PHY_BB_CAL_RXBB_GAIN_TBL_8_TXCAL_RX_BB_GAIN_TABLE_9_MSB                                       11
-#define PHY_BB_CAL_RXBB_GAIN_TBL_8_TXCAL_RX_BB_GAIN_TABLE_9_LSB                                        6
-#define PHY_BB_CAL_RXBB_GAIN_TBL_8_TXCAL_RX_BB_GAIN_TABLE_9_MASK                              0x00000fc0
-#define PHY_BB_CAL_RXBB_GAIN_TBL_8_TXCAL_RX_BB_GAIN_TABLE_9_GET(x)             (((x) & 0x00000fc0) >> 6)
-#define PHY_BB_CAL_RXBB_GAIN_TBL_8_TXCAL_RX_BB_GAIN_TABLE_9_SET(x)             (((x) << 6) & 0x00000fc0)
-#define PHY_BB_CAL_RXBB_GAIN_TBL_8_TXCAL_RX_BB_GAIN_TABLE_10_MSB                                      17
-#define PHY_BB_CAL_RXBB_GAIN_TBL_8_TXCAL_RX_BB_GAIN_TABLE_10_LSB                                      12
-#define PHY_BB_CAL_RXBB_GAIN_TBL_8_TXCAL_RX_BB_GAIN_TABLE_10_MASK                             0x0003f000
-#define PHY_BB_CAL_RXBB_GAIN_TBL_8_TXCAL_RX_BB_GAIN_TABLE_10_GET(x)           (((x) & 0x0003f000) >> 12)
-#define PHY_BB_CAL_RXBB_GAIN_TBL_8_TXCAL_RX_BB_GAIN_TABLE_10_SET(x)           (((x) << 12) & 0x0003f000)
-#define PHY_BB_CAL_RXBB_GAIN_TBL_8_TXCAL_RX_BB_GAIN_TABLE_11_MSB                                      23
-#define PHY_BB_CAL_RXBB_GAIN_TBL_8_TXCAL_RX_BB_GAIN_TABLE_11_LSB                                      18
-#define PHY_BB_CAL_RXBB_GAIN_TBL_8_TXCAL_RX_BB_GAIN_TABLE_11_MASK                             0x00fc0000
-#define PHY_BB_CAL_RXBB_GAIN_TBL_8_TXCAL_RX_BB_GAIN_TABLE_11_GET(x)           (((x) & 0x00fc0000) >> 18)
-#define PHY_BB_CAL_RXBB_GAIN_TBL_8_TXCAL_RX_BB_GAIN_TABLE_11_SET(x)           (((x) << 18) & 0x00fc0000)
-
-/* macros for BB_cal_rxbb_gain_tbl_12 */
-#define PHY_BB_CAL_RXBB_GAIN_TBL_12_ADDRESS                                                   0x0000a718
-#define PHY_BB_CAL_RXBB_GAIN_TBL_12_OFFSET                                                    0x0000a718
-#define PHY_BB_CAL_RXBB_GAIN_TBL_12_TXCAL_RX_BB_GAIN_TABLE_12_MSB                                      5
-#define PHY_BB_CAL_RXBB_GAIN_TBL_12_TXCAL_RX_BB_GAIN_TABLE_12_LSB                                      0
-#define PHY_BB_CAL_RXBB_GAIN_TBL_12_TXCAL_RX_BB_GAIN_TABLE_12_MASK                            0x0000003f
-#define PHY_BB_CAL_RXBB_GAIN_TBL_12_TXCAL_RX_BB_GAIN_TABLE_12_GET(x)           (((x) & 0x0000003f) >> 0)
-#define PHY_BB_CAL_RXBB_GAIN_TBL_12_TXCAL_RX_BB_GAIN_TABLE_12_SET(x)           (((x) << 0) & 0x0000003f)
-#define PHY_BB_CAL_RXBB_GAIN_TBL_12_TXCAL_RX_BB_GAIN_TABLE_13_MSB                                     11
-#define PHY_BB_CAL_RXBB_GAIN_TBL_12_TXCAL_RX_BB_GAIN_TABLE_13_LSB                                      6
-#define PHY_BB_CAL_RXBB_GAIN_TBL_12_TXCAL_RX_BB_GAIN_TABLE_13_MASK                            0x00000fc0
-#define PHY_BB_CAL_RXBB_GAIN_TBL_12_TXCAL_RX_BB_GAIN_TABLE_13_GET(x)           (((x) & 0x00000fc0) >> 6)
-#define PHY_BB_CAL_RXBB_GAIN_TBL_12_TXCAL_RX_BB_GAIN_TABLE_13_SET(x)           (((x) << 6) & 0x00000fc0)
-#define PHY_BB_CAL_RXBB_GAIN_TBL_12_TXCAL_RX_BB_GAIN_TABLE_14_MSB                                     17
-#define PHY_BB_CAL_RXBB_GAIN_TBL_12_TXCAL_RX_BB_GAIN_TABLE_14_LSB                                     12
-#define PHY_BB_CAL_RXBB_GAIN_TBL_12_TXCAL_RX_BB_GAIN_TABLE_14_MASK                            0x0003f000
-#define PHY_BB_CAL_RXBB_GAIN_TBL_12_TXCAL_RX_BB_GAIN_TABLE_14_GET(x)          (((x) & 0x0003f000) >> 12)
-#define PHY_BB_CAL_RXBB_GAIN_TBL_12_TXCAL_RX_BB_GAIN_TABLE_14_SET(x)          (((x) << 12) & 0x0003f000)
-#define PHY_BB_CAL_RXBB_GAIN_TBL_12_TXCAL_RX_BB_GAIN_TABLE_15_MSB                                     23
-#define PHY_BB_CAL_RXBB_GAIN_TBL_12_TXCAL_RX_BB_GAIN_TABLE_15_LSB                                     18
-#define PHY_BB_CAL_RXBB_GAIN_TBL_12_TXCAL_RX_BB_GAIN_TABLE_15_MASK                            0x00fc0000
-#define PHY_BB_CAL_RXBB_GAIN_TBL_12_TXCAL_RX_BB_GAIN_TABLE_15_GET(x)          (((x) & 0x00fc0000) >> 18)
-#define PHY_BB_CAL_RXBB_GAIN_TBL_12_TXCAL_RX_BB_GAIN_TABLE_15_SET(x)          (((x) << 18) & 0x00fc0000)
-
-/* macros for BB_cal_rxbb_gain_tbl_16 */
-#define PHY_BB_CAL_RXBB_GAIN_TBL_16_ADDRESS                                                   0x0000a71c
-#define PHY_BB_CAL_RXBB_GAIN_TBL_16_OFFSET                                                    0x0000a71c
-#define PHY_BB_CAL_RXBB_GAIN_TBL_16_TXCAL_RX_BB_GAIN_TABLE_16_MSB                                      5
-#define PHY_BB_CAL_RXBB_GAIN_TBL_16_TXCAL_RX_BB_GAIN_TABLE_16_LSB                                      0
-#define PHY_BB_CAL_RXBB_GAIN_TBL_16_TXCAL_RX_BB_GAIN_TABLE_16_MASK                            0x0000003f
-#define PHY_BB_CAL_RXBB_GAIN_TBL_16_TXCAL_RX_BB_GAIN_TABLE_16_GET(x)           (((x) & 0x0000003f) >> 0)
-#define PHY_BB_CAL_RXBB_GAIN_TBL_16_TXCAL_RX_BB_GAIN_TABLE_16_SET(x)           (((x) << 0) & 0x0000003f)
-#define PHY_BB_CAL_RXBB_GAIN_TBL_16_TXCAL_RX_BB_GAIN_TABLE_17_MSB                                     11
-#define PHY_BB_CAL_RXBB_GAIN_TBL_16_TXCAL_RX_BB_GAIN_TABLE_17_LSB                                      6
-#define PHY_BB_CAL_RXBB_GAIN_TBL_16_TXCAL_RX_BB_GAIN_TABLE_17_MASK                            0x00000fc0
-#define PHY_BB_CAL_RXBB_GAIN_TBL_16_TXCAL_RX_BB_GAIN_TABLE_17_GET(x)           (((x) & 0x00000fc0) >> 6)
-#define PHY_BB_CAL_RXBB_GAIN_TBL_16_TXCAL_RX_BB_GAIN_TABLE_17_SET(x)           (((x) << 6) & 0x00000fc0)
-#define PHY_BB_CAL_RXBB_GAIN_TBL_16_TXCAL_RX_BB_GAIN_TABLE_18_MSB                                     17
-#define PHY_BB_CAL_RXBB_GAIN_TBL_16_TXCAL_RX_BB_GAIN_TABLE_18_LSB                                     12
-#define PHY_BB_CAL_RXBB_GAIN_TBL_16_TXCAL_RX_BB_GAIN_TABLE_18_MASK                            0x0003f000
-#define PHY_BB_CAL_RXBB_GAIN_TBL_16_TXCAL_RX_BB_GAIN_TABLE_18_GET(x)          (((x) & 0x0003f000) >> 12)
-#define PHY_BB_CAL_RXBB_GAIN_TBL_16_TXCAL_RX_BB_GAIN_TABLE_18_SET(x)          (((x) << 12) & 0x0003f000)
-#define PHY_BB_CAL_RXBB_GAIN_TBL_16_TXCAL_RX_BB_GAIN_TABLE_19_MSB                                     23
-#define PHY_BB_CAL_RXBB_GAIN_TBL_16_TXCAL_RX_BB_GAIN_TABLE_19_LSB                                     18
-#define PHY_BB_CAL_RXBB_GAIN_TBL_16_TXCAL_RX_BB_GAIN_TABLE_19_MASK                            0x00fc0000
-#define PHY_BB_CAL_RXBB_GAIN_TBL_16_TXCAL_RX_BB_GAIN_TABLE_19_GET(x)          (((x) & 0x00fc0000) >> 18)
-#define PHY_BB_CAL_RXBB_GAIN_TBL_16_TXCAL_RX_BB_GAIN_TABLE_19_SET(x)          (((x) << 18) & 0x00fc0000)
-
-/* macros for BB_cal_rxbb_gain_tbl_20 */
-#define PHY_BB_CAL_RXBB_GAIN_TBL_20_ADDRESS                                                   0x0000a720
-#define PHY_BB_CAL_RXBB_GAIN_TBL_20_OFFSET                                                    0x0000a720
-#define PHY_BB_CAL_RXBB_GAIN_TBL_20_TXCAL_RX_BB_GAIN_TABLE_20_MSB                                      5
-#define PHY_BB_CAL_RXBB_GAIN_TBL_20_TXCAL_RX_BB_GAIN_TABLE_20_LSB                                      0
-#define PHY_BB_CAL_RXBB_GAIN_TBL_20_TXCAL_RX_BB_GAIN_TABLE_20_MASK                            0x0000003f
-#define PHY_BB_CAL_RXBB_GAIN_TBL_20_TXCAL_RX_BB_GAIN_TABLE_20_GET(x)           (((x) & 0x0000003f) >> 0)
-#define PHY_BB_CAL_RXBB_GAIN_TBL_20_TXCAL_RX_BB_GAIN_TABLE_20_SET(x)           (((x) << 0) & 0x0000003f)
-#define PHY_BB_CAL_RXBB_GAIN_TBL_20_TXCAL_RX_BB_GAIN_TABLE_21_MSB                                     11
-#define PHY_BB_CAL_RXBB_GAIN_TBL_20_TXCAL_RX_BB_GAIN_TABLE_21_LSB                                      6
-#define PHY_BB_CAL_RXBB_GAIN_TBL_20_TXCAL_RX_BB_GAIN_TABLE_21_MASK                            0x00000fc0
-#define PHY_BB_CAL_RXBB_GAIN_TBL_20_TXCAL_RX_BB_GAIN_TABLE_21_GET(x)           (((x) & 0x00000fc0) >> 6)
-#define PHY_BB_CAL_RXBB_GAIN_TBL_20_TXCAL_RX_BB_GAIN_TABLE_21_SET(x)           (((x) << 6) & 0x00000fc0)
-#define PHY_BB_CAL_RXBB_GAIN_TBL_20_TXCAL_RX_BB_GAIN_TABLE_22_MSB                                     17
-#define PHY_BB_CAL_RXBB_GAIN_TBL_20_TXCAL_RX_BB_GAIN_TABLE_22_LSB                                     12
-#define PHY_BB_CAL_RXBB_GAIN_TBL_20_TXCAL_RX_BB_GAIN_TABLE_22_MASK                            0x0003f000
-#define PHY_BB_CAL_RXBB_GAIN_TBL_20_TXCAL_RX_BB_GAIN_TABLE_22_GET(x)          (((x) & 0x0003f000) >> 12)
-#define PHY_BB_CAL_RXBB_GAIN_TBL_20_TXCAL_RX_BB_GAIN_TABLE_22_SET(x)          (((x) << 12) & 0x0003f000)
-#define PHY_BB_CAL_RXBB_GAIN_TBL_20_TXCAL_RX_BB_GAIN_TABLE_23_MSB                                     23
-#define PHY_BB_CAL_RXBB_GAIN_TBL_20_TXCAL_RX_BB_GAIN_TABLE_23_LSB                                     18
-#define PHY_BB_CAL_RXBB_GAIN_TBL_20_TXCAL_RX_BB_GAIN_TABLE_23_MASK                            0x00fc0000
-#define PHY_BB_CAL_RXBB_GAIN_TBL_20_TXCAL_RX_BB_GAIN_TABLE_23_GET(x)          (((x) & 0x00fc0000) >> 18)
-#define PHY_BB_CAL_RXBB_GAIN_TBL_20_TXCAL_RX_BB_GAIN_TABLE_23_SET(x)          (((x) << 18) & 0x00fc0000)
-
-/* macros for BB_cal_rxbb_gain_tbl_24 */
-#define PHY_BB_CAL_RXBB_GAIN_TBL_24_ADDRESS                                                   0x0000a724
-#define PHY_BB_CAL_RXBB_GAIN_TBL_24_OFFSET                                                    0x0000a724
-#define PHY_BB_CAL_RXBB_GAIN_TBL_24_TXCAL_RX_BB_GAIN_TABLE_24_MSB                                      5
-#define PHY_BB_CAL_RXBB_GAIN_TBL_24_TXCAL_RX_BB_GAIN_TABLE_24_LSB                                      0
-#define PHY_BB_CAL_RXBB_GAIN_TBL_24_TXCAL_RX_BB_GAIN_TABLE_24_MASK                            0x0000003f
-#define PHY_BB_CAL_RXBB_GAIN_TBL_24_TXCAL_RX_BB_GAIN_TABLE_24_GET(x)           (((x) & 0x0000003f) >> 0)
-#define PHY_BB_CAL_RXBB_GAIN_TBL_24_TXCAL_RX_BB_GAIN_TABLE_24_SET(x)           (((x) << 0) & 0x0000003f)
-
-/* macros for BB_txiqcal_status_b0 */
-#define PHY_BB_TXIQCAL_STATUS_B0_ADDRESS                                                      0x0000a728
-#define PHY_BB_TXIQCAL_STATUS_B0_OFFSET                                                       0x0000a728
-#define PHY_BB_TXIQCAL_STATUS_B0_TXIQCAL_FAILED_0_MSB                                                  0
-#define PHY_BB_TXIQCAL_STATUS_B0_TXIQCAL_FAILED_0_LSB                                                  0
-#define PHY_BB_TXIQCAL_STATUS_B0_TXIQCAL_FAILED_0_MASK                                        0x00000001
-#define PHY_BB_TXIQCAL_STATUS_B0_TXIQCAL_FAILED_0_GET(x)                       (((x) & 0x00000001) >> 0)
-#define PHY_BB_TXIQCAL_STATUS_B0_CALIBRATED_GAINS_0_MSB                                                5
-#define PHY_BB_TXIQCAL_STATUS_B0_CALIBRATED_GAINS_0_LSB                                                1
-#define PHY_BB_TXIQCAL_STATUS_B0_CALIBRATED_GAINS_0_MASK                                      0x0000003e
-#define PHY_BB_TXIQCAL_STATUS_B0_CALIBRATED_GAINS_0_GET(x)                     (((x) & 0x0000003e) >> 1)
-#define PHY_BB_TXIQCAL_STATUS_B0_TONE_GAIN_USED_0_MSB                                                 11
-#define PHY_BB_TXIQCAL_STATUS_B0_TONE_GAIN_USED_0_LSB                                                  6
-#define PHY_BB_TXIQCAL_STATUS_B0_TONE_GAIN_USED_0_MASK                                        0x00000fc0
-#define PHY_BB_TXIQCAL_STATUS_B0_TONE_GAIN_USED_0_GET(x)                       (((x) & 0x00000fc0) >> 6)
-#define PHY_BB_TXIQCAL_STATUS_B0_RX_GAIN_USED_0_MSB                                                   17
-#define PHY_BB_TXIQCAL_STATUS_B0_RX_GAIN_USED_0_LSB                                                   12
-#define PHY_BB_TXIQCAL_STATUS_B0_RX_GAIN_USED_0_MASK                                          0x0003f000
-#define PHY_BB_TXIQCAL_STATUS_B0_RX_GAIN_USED_0_GET(x)                        (((x) & 0x0003f000) >> 12)
-#define PHY_BB_TXIQCAL_STATUS_B0_LAST_MEAS_ADDR_0_MSB                                                 24
-#define PHY_BB_TXIQCAL_STATUS_B0_LAST_MEAS_ADDR_0_LSB                                                 18
-#define PHY_BB_TXIQCAL_STATUS_B0_LAST_MEAS_ADDR_0_MASK                                        0x01fc0000
-#define PHY_BB_TXIQCAL_STATUS_B0_LAST_MEAS_ADDR_0_GET(x)                      (((x) & 0x01fc0000) >> 18)
-
-/* macros for BB_paprd_trainer_cntl1 */
-#define PHY_BB_PAPRD_TRAINER_CNTL1_ADDRESS                                                    0x0000a72c
-#define PHY_BB_PAPRD_TRAINER_CNTL1_OFFSET                                                     0x0000a72c
-#define PHY_BB_PAPRD_TRAINER_CNTL1_CF_PAPRD_TRAIN_ENABLE_MSB                                           0
-#define PHY_BB_PAPRD_TRAINER_CNTL1_CF_PAPRD_TRAIN_ENABLE_LSB                                           0
-#define PHY_BB_PAPRD_TRAINER_CNTL1_CF_PAPRD_TRAIN_ENABLE_MASK                                 0x00000001
-#define PHY_BB_PAPRD_TRAINER_CNTL1_CF_PAPRD_TRAIN_ENABLE_GET(x)                (((x) & 0x00000001) >> 0)
-#define PHY_BB_PAPRD_TRAINER_CNTL1_CF_PAPRD_TRAIN_ENABLE_SET(x)                (((x) << 0) & 0x00000001)
-#define PHY_BB_PAPRD_TRAINER_CNTL1_CF_PAPRD_AGC2_SETTLING_MSB                                          7
-#define PHY_BB_PAPRD_TRAINER_CNTL1_CF_PAPRD_AGC2_SETTLING_LSB                                          1
-#define PHY_BB_PAPRD_TRAINER_CNTL1_CF_PAPRD_AGC2_SETTLING_MASK                                0x000000fe
-#define PHY_BB_PAPRD_TRAINER_CNTL1_CF_PAPRD_AGC2_SETTLING_GET(x)               (((x) & 0x000000fe) >> 1)
-#define PHY_BB_PAPRD_TRAINER_CNTL1_CF_PAPRD_AGC2_SETTLING_SET(x)               (((x) << 1) & 0x000000fe)
-#define PHY_BB_PAPRD_TRAINER_CNTL1_CF_PAPRD_IQCORR_ENABLE_MSB                                          8
-#define PHY_BB_PAPRD_TRAINER_CNTL1_CF_PAPRD_IQCORR_ENABLE_LSB                                          8
-#define PHY_BB_PAPRD_TRAINER_CNTL1_CF_PAPRD_IQCORR_ENABLE_MASK                                0x00000100
-#define PHY_BB_PAPRD_TRAINER_CNTL1_CF_PAPRD_IQCORR_ENABLE_GET(x)               (((x) & 0x00000100) >> 8)
-#define PHY_BB_PAPRD_TRAINER_CNTL1_CF_PAPRD_IQCORR_ENABLE_SET(x)               (((x) << 8) & 0x00000100)
-#define PHY_BB_PAPRD_TRAINER_CNTL1_CF_PAPRD_RX_BB_GAIN_FORCE_MSB                                       9
-#define PHY_BB_PAPRD_TRAINER_CNTL1_CF_PAPRD_RX_BB_GAIN_FORCE_LSB                                       9
-#define PHY_BB_PAPRD_TRAINER_CNTL1_CF_PAPRD_RX_BB_GAIN_FORCE_MASK                             0x00000200
-#define PHY_BB_PAPRD_TRAINER_CNTL1_CF_PAPRD_RX_BB_GAIN_FORCE_GET(x)            (((x) & 0x00000200) >> 9)
-#define PHY_BB_PAPRD_TRAINER_CNTL1_CF_PAPRD_RX_BB_GAIN_FORCE_SET(x)            (((x) << 9) & 0x00000200)
-#define PHY_BB_PAPRD_TRAINER_CNTL1_CF_PAPRD_TX_GAIN_FORCE_MSB                                         10
-#define PHY_BB_PAPRD_TRAINER_CNTL1_CF_PAPRD_TX_GAIN_FORCE_LSB                                         10
-#define PHY_BB_PAPRD_TRAINER_CNTL1_CF_PAPRD_TX_GAIN_FORCE_MASK                                0x00000400
-#define PHY_BB_PAPRD_TRAINER_CNTL1_CF_PAPRD_TX_GAIN_FORCE_GET(x)              (((x) & 0x00000400) >> 10)
-#define PHY_BB_PAPRD_TRAINER_CNTL1_CF_PAPRD_TX_GAIN_FORCE_SET(x)              (((x) << 10) & 0x00000400)
-#define PHY_BB_PAPRD_TRAINER_CNTL1_CF_PAPRD_LB_ENABLE_MSB                                             11
-#define PHY_BB_PAPRD_TRAINER_CNTL1_CF_PAPRD_LB_ENABLE_LSB                                             11
-#define PHY_BB_PAPRD_TRAINER_CNTL1_CF_PAPRD_LB_ENABLE_MASK                                    0x00000800
-#define PHY_BB_PAPRD_TRAINER_CNTL1_CF_PAPRD_LB_ENABLE_GET(x)                  (((x) & 0x00000800) >> 11)
-#define PHY_BB_PAPRD_TRAINER_CNTL1_CF_PAPRD_LB_ENABLE_SET(x)                  (((x) << 11) & 0x00000800)
-#define PHY_BB_PAPRD_TRAINER_CNTL1_CF_PAPRD_LB_SKIP_MSB                                               18
-#define PHY_BB_PAPRD_TRAINER_CNTL1_CF_PAPRD_LB_SKIP_LSB                                               12
-#define PHY_BB_PAPRD_TRAINER_CNTL1_CF_PAPRD_LB_SKIP_MASK                                      0x0007f000
-#define PHY_BB_PAPRD_TRAINER_CNTL1_CF_PAPRD_LB_SKIP_GET(x)                    (((x) & 0x0007f000) >> 12)
-#define PHY_BB_PAPRD_TRAINER_CNTL1_CF_PAPRD_LB_SKIP_SET(x)                    (((x) << 12) & 0x0007f000)
-
-/* macros for BB_paprd_trainer_cntl2 */
-#define PHY_BB_PAPRD_TRAINER_CNTL2_ADDRESS                                                    0x0000a730
-#define PHY_BB_PAPRD_TRAINER_CNTL2_OFFSET                                                     0x0000a730
-#define PHY_BB_PAPRD_TRAINER_CNTL2_CF_PAPRD_INIT_RX_BB_GAIN_MSB                                       31
-#define PHY_BB_PAPRD_TRAINER_CNTL2_CF_PAPRD_INIT_RX_BB_GAIN_LSB                                        0
-#define PHY_BB_PAPRD_TRAINER_CNTL2_CF_PAPRD_INIT_RX_BB_GAIN_MASK                              0xffffffff
-#define PHY_BB_PAPRD_TRAINER_CNTL2_CF_PAPRD_INIT_RX_BB_GAIN_GET(x)             (((x) & 0xffffffff) >> 0)
-#define PHY_BB_PAPRD_TRAINER_CNTL2_CF_PAPRD_INIT_RX_BB_GAIN_SET(x)             (((x) << 0) & 0xffffffff)
-
-/* macros for BB_paprd_trainer_cntl3 */
-#define PHY_BB_PAPRD_TRAINER_CNTL3_ADDRESS                                                    0x0000a734
-#define PHY_BB_PAPRD_TRAINER_CNTL3_OFFSET                                                     0x0000a734
-#define PHY_BB_PAPRD_TRAINER_CNTL3_CF_PAPRD_ADC_DESIRED_SIZE_MSB                                       5
-#define PHY_BB_PAPRD_TRAINER_CNTL3_CF_PAPRD_ADC_DESIRED_SIZE_LSB                                       0
-#define PHY_BB_PAPRD_TRAINER_CNTL3_CF_PAPRD_ADC_DESIRED_SIZE_MASK                             0x0000003f
-#define PHY_BB_PAPRD_TRAINER_CNTL3_CF_PAPRD_ADC_DESIRED_SIZE_GET(x)            (((x) & 0x0000003f) >> 0)
-#define PHY_BB_PAPRD_TRAINER_CNTL3_CF_PAPRD_ADC_DESIRED_SIZE_SET(x)            (((x) << 0) & 0x0000003f)
-#define PHY_BB_PAPRD_TRAINER_CNTL3_CF_PAPRD_QUICK_DROP_MSB                                            11
-#define PHY_BB_PAPRD_TRAINER_CNTL3_CF_PAPRD_QUICK_DROP_LSB                                             6
-#define PHY_BB_PAPRD_TRAINER_CNTL3_CF_PAPRD_QUICK_DROP_MASK                                   0x00000fc0
-#define PHY_BB_PAPRD_TRAINER_CNTL3_CF_PAPRD_QUICK_DROP_GET(x)                  (((x) & 0x00000fc0) >> 6)
-#define PHY_BB_PAPRD_TRAINER_CNTL3_CF_PAPRD_QUICK_DROP_SET(x)                  (((x) << 6) & 0x00000fc0)
-#define PHY_BB_PAPRD_TRAINER_CNTL3_CF_PAPRD_MIN_LOOPBACK_DEL_MSB                                      16
-#define PHY_BB_PAPRD_TRAINER_CNTL3_CF_PAPRD_MIN_LOOPBACK_DEL_LSB                                      12
-#define PHY_BB_PAPRD_TRAINER_CNTL3_CF_PAPRD_MIN_LOOPBACK_DEL_MASK                             0x0001f000
-#define PHY_BB_PAPRD_TRAINER_CNTL3_CF_PAPRD_MIN_LOOPBACK_DEL_GET(x)           (((x) & 0x0001f000) >> 12)
-#define PHY_BB_PAPRD_TRAINER_CNTL3_CF_PAPRD_MIN_LOOPBACK_DEL_SET(x)           (((x) << 12) & 0x0001f000)
-#define PHY_BB_PAPRD_TRAINER_CNTL3_CF_PAPRD_NUM_CORR_STAGES_MSB                                       19
-#define PHY_BB_PAPRD_TRAINER_CNTL3_CF_PAPRD_NUM_CORR_STAGES_LSB                                       17
-#define PHY_BB_PAPRD_TRAINER_CNTL3_CF_PAPRD_NUM_CORR_STAGES_MASK                              0x000e0000
-#define PHY_BB_PAPRD_TRAINER_CNTL3_CF_PAPRD_NUM_CORR_STAGES_GET(x)            (((x) & 0x000e0000) >> 17)
-#define PHY_BB_PAPRD_TRAINER_CNTL3_CF_PAPRD_NUM_CORR_STAGES_SET(x)            (((x) << 17) & 0x000e0000)
-#define PHY_BB_PAPRD_TRAINER_CNTL3_CF_PAPRD_COARSE_CORR_LEN_MSB                                       23
-#define PHY_BB_PAPRD_TRAINER_CNTL3_CF_PAPRD_COARSE_CORR_LEN_LSB                                       20
-#define PHY_BB_PAPRD_TRAINER_CNTL3_CF_PAPRD_COARSE_CORR_LEN_MASK                              0x00f00000
-#define PHY_BB_PAPRD_TRAINER_CNTL3_CF_PAPRD_COARSE_CORR_LEN_GET(x)            (((x) & 0x00f00000) >> 20)
-#define PHY_BB_PAPRD_TRAINER_CNTL3_CF_PAPRD_COARSE_CORR_LEN_SET(x)            (((x) << 20) & 0x00f00000)
-#define PHY_BB_PAPRD_TRAINER_CNTL3_CF_PAPRD_FINE_CORR_LEN_MSB                                         27
-#define PHY_BB_PAPRD_TRAINER_CNTL3_CF_PAPRD_FINE_CORR_LEN_LSB                                         24
-#define PHY_BB_PAPRD_TRAINER_CNTL3_CF_PAPRD_FINE_CORR_LEN_MASK                                0x0f000000
-#define PHY_BB_PAPRD_TRAINER_CNTL3_CF_PAPRD_FINE_CORR_LEN_GET(x)              (((x) & 0x0f000000) >> 24)
-#define PHY_BB_PAPRD_TRAINER_CNTL3_CF_PAPRD_FINE_CORR_LEN_SET(x)              (((x) << 24) & 0x0f000000)
-#define PHY_BB_PAPRD_TRAINER_CNTL3_CF_PAPRD_BBTXMIX_DISABLE_MSB                                       28
-#define PHY_BB_PAPRD_TRAINER_CNTL3_CF_PAPRD_BBTXMIX_DISABLE_LSB                                       28
-#define PHY_BB_PAPRD_TRAINER_CNTL3_CF_PAPRD_BBTXMIX_DISABLE_MASK                              0x10000000
-#define PHY_BB_PAPRD_TRAINER_CNTL3_CF_PAPRD_BBTXMIX_DISABLE_GET(x)            (((x) & 0x10000000) >> 28)
-#define PHY_BB_PAPRD_TRAINER_CNTL3_CF_PAPRD_BBTXMIX_DISABLE_SET(x)            (((x) << 28) & 0x10000000)
-
-/* macros for BB_paprd_trainer_cntl4 */
-#define PHY_BB_PAPRD_TRAINER_CNTL4_ADDRESS                                                    0x0000a738
-#define PHY_BB_PAPRD_TRAINER_CNTL4_OFFSET                                                     0x0000a738
-#define PHY_BB_PAPRD_TRAINER_CNTL4_CF_PAPRD_MIN_CORR_MSB                                              11
-#define PHY_BB_PAPRD_TRAINER_CNTL4_CF_PAPRD_MIN_CORR_LSB                                               0
-#define PHY_BB_PAPRD_TRAINER_CNTL4_CF_PAPRD_MIN_CORR_MASK                                     0x00000fff
-#define PHY_BB_PAPRD_TRAINER_CNTL4_CF_PAPRD_MIN_CORR_GET(x)                    (((x) & 0x00000fff) >> 0)
-#define PHY_BB_PAPRD_TRAINER_CNTL4_CF_PAPRD_MIN_CORR_SET(x)                    (((x) << 0) & 0x00000fff)
-#define PHY_BB_PAPRD_TRAINER_CNTL4_CF_PAPRD_SAFETY_DELTA_MSB                                          15
-#define PHY_BB_PAPRD_TRAINER_CNTL4_CF_PAPRD_SAFETY_DELTA_LSB                                          12
-#define PHY_BB_PAPRD_TRAINER_CNTL4_CF_PAPRD_SAFETY_DELTA_MASK                                 0x0000f000
-#define PHY_BB_PAPRD_TRAINER_CNTL4_CF_PAPRD_SAFETY_DELTA_GET(x)               (((x) & 0x0000f000) >> 12)
-#define PHY_BB_PAPRD_TRAINER_CNTL4_CF_PAPRD_SAFETY_DELTA_SET(x)               (((x) << 12) & 0x0000f000)
-#define PHY_BB_PAPRD_TRAINER_CNTL4_CF_PAPRD_NUM_TRAIN_SAMPLES_MSB                                     25
-#define PHY_BB_PAPRD_TRAINER_CNTL4_CF_PAPRD_NUM_TRAIN_SAMPLES_LSB                                     16
-#define PHY_BB_PAPRD_TRAINER_CNTL4_CF_PAPRD_NUM_TRAIN_SAMPLES_MASK                            0x03ff0000
-#define PHY_BB_PAPRD_TRAINER_CNTL4_CF_PAPRD_NUM_TRAIN_SAMPLES_GET(x)          (((x) & 0x03ff0000) >> 16)
-#define PHY_BB_PAPRD_TRAINER_CNTL4_CF_PAPRD_NUM_TRAIN_SAMPLES_SET(x)          (((x) << 16) & 0x03ff0000)
-
-/* macros for BB_paprd_trainer_stat1 */
-#define PHY_BB_PAPRD_TRAINER_STAT1_ADDRESS                                                    0x0000a73c
-#define PHY_BB_PAPRD_TRAINER_STAT1_OFFSET                                                     0x0000a73c
-#define PHY_BB_PAPRD_TRAINER_STAT1_PAPRD_TRAIN_DONE_MSB                                                0
-#define PHY_BB_PAPRD_TRAINER_STAT1_PAPRD_TRAIN_DONE_LSB                                                0
-#define PHY_BB_PAPRD_TRAINER_STAT1_PAPRD_TRAIN_DONE_MASK                                      0x00000001
-#define PHY_BB_PAPRD_TRAINER_STAT1_PAPRD_TRAIN_DONE_GET(x)                     (((x) & 0x00000001) >> 0)
-#define PHY_BB_PAPRD_TRAINER_STAT1_PAPRD_TRAIN_DONE_SET(x)                     (((x) << 0) & 0x00000001)
-#define PHY_BB_PAPRD_TRAINER_STAT1_PAPRD_TRAIN_INCOMPLETE_MSB                                          1
-#define PHY_BB_PAPRD_TRAINER_STAT1_PAPRD_TRAIN_INCOMPLETE_LSB                                          1
-#define PHY_BB_PAPRD_TRAINER_STAT1_PAPRD_TRAIN_INCOMPLETE_MASK                                0x00000002
-#define PHY_BB_PAPRD_TRAINER_STAT1_PAPRD_TRAIN_INCOMPLETE_GET(x)               (((x) & 0x00000002) >> 1)
-#define PHY_BB_PAPRD_TRAINER_STAT1_PAPRD_CORR_ERR_MSB                                                  2
-#define PHY_BB_PAPRD_TRAINER_STAT1_PAPRD_CORR_ERR_LSB                                                  2
-#define PHY_BB_PAPRD_TRAINER_STAT1_PAPRD_CORR_ERR_MASK                                        0x00000004
-#define PHY_BB_PAPRD_TRAINER_STAT1_PAPRD_CORR_ERR_GET(x)                       (((x) & 0x00000004) >> 2)
-#define PHY_BB_PAPRD_TRAINER_STAT1_PAPRD_TRAIN_ACTIVE_MSB                                              3
-#define PHY_BB_PAPRD_TRAINER_STAT1_PAPRD_TRAIN_ACTIVE_LSB                                              3
-#define PHY_BB_PAPRD_TRAINER_STAT1_PAPRD_TRAIN_ACTIVE_MASK                                    0x00000008
-#define PHY_BB_PAPRD_TRAINER_STAT1_PAPRD_TRAIN_ACTIVE_GET(x)                   (((x) & 0x00000008) >> 3)
-#define PHY_BB_PAPRD_TRAINER_STAT1_PAPRD_RX_GAIN_IDX_MSB                                               8
-#define PHY_BB_PAPRD_TRAINER_STAT1_PAPRD_RX_GAIN_IDX_LSB                                               4
-#define PHY_BB_PAPRD_TRAINER_STAT1_PAPRD_RX_GAIN_IDX_MASK                                     0x000001f0
-#define PHY_BB_PAPRD_TRAINER_STAT1_PAPRD_RX_GAIN_IDX_GET(x)                    (((x) & 0x000001f0) >> 4)
-#define PHY_BB_PAPRD_TRAINER_STAT1_PAPRD_AGC2_PWR_MSB                                                 16
-#define PHY_BB_PAPRD_TRAINER_STAT1_PAPRD_AGC2_PWR_LSB                                                  9
-#define PHY_BB_PAPRD_TRAINER_STAT1_PAPRD_AGC2_PWR_MASK                                        0x0001fe00
-#define PHY_BB_PAPRD_TRAINER_STAT1_PAPRD_AGC2_PWR_GET(x)                       (((x) & 0x0001fe00) >> 9)
-
-/* macros for BB_paprd_trainer_stat2 */
-#define PHY_BB_PAPRD_TRAINER_STAT2_ADDRESS                                                    0x0000a740
-#define PHY_BB_PAPRD_TRAINER_STAT2_OFFSET                                                     0x0000a740
-#define PHY_BB_PAPRD_TRAINER_STAT2_PAPRD_FINE_VAL_MSB                                                 15
-#define PHY_BB_PAPRD_TRAINER_STAT2_PAPRD_FINE_VAL_LSB                                                  0
-#define PHY_BB_PAPRD_TRAINER_STAT2_PAPRD_FINE_VAL_MASK                                        0x0000ffff
-#define PHY_BB_PAPRD_TRAINER_STAT2_PAPRD_FINE_VAL_GET(x)                       (((x) & 0x0000ffff) >> 0)
-#define PHY_BB_PAPRD_TRAINER_STAT2_PAPRD_COARSE_IDX_MSB                                               20
-#define PHY_BB_PAPRD_TRAINER_STAT2_PAPRD_COARSE_IDX_LSB                                               16
-#define PHY_BB_PAPRD_TRAINER_STAT2_PAPRD_COARSE_IDX_MASK                                      0x001f0000
-#define PHY_BB_PAPRD_TRAINER_STAT2_PAPRD_COARSE_IDX_GET(x)                    (((x) & 0x001f0000) >> 16)
-#define PHY_BB_PAPRD_TRAINER_STAT2_PAPRD_FINE_IDX_MSB                                                 22
-#define PHY_BB_PAPRD_TRAINER_STAT2_PAPRD_FINE_IDX_LSB                                                 21
-#define PHY_BB_PAPRD_TRAINER_STAT2_PAPRD_FINE_IDX_MASK                                        0x00600000
-#define PHY_BB_PAPRD_TRAINER_STAT2_PAPRD_FINE_IDX_GET(x)                      (((x) & 0x00600000) >> 21)
-
-/* macros for BB_paprd_trainer_stat3 */
-#define PHY_BB_PAPRD_TRAINER_STAT3_ADDRESS                                                    0x0000a744
-#define PHY_BB_PAPRD_TRAINER_STAT3_OFFSET                                                     0x0000a744
-#define PHY_BB_PAPRD_TRAINER_STAT3_PAPRD_TRAIN_SAMPLES_CNT_MSB                                        19
-#define PHY_BB_PAPRD_TRAINER_STAT3_PAPRD_TRAIN_SAMPLES_CNT_LSB                                         0
-#define PHY_BB_PAPRD_TRAINER_STAT3_PAPRD_TRAIN_SAMPLES_CNT_MASK                               0x000fffff
-#define PHY_BB_PAPRD_TRAINER_STAT3_PAPRD_TRAIN_SAMPLES_CNT_GET(x)              (((x) & 0x000fffff) >> 0)
-
-/* macros for BB_fcal_1 */
-#define PHY_BB_FCAL_1_ADDRESS                                                                 0x0000a7d8
-#define PHY_BB_FCAL_1_OFFSET                                                                  0x0000a7d8
-#define PHY_BB_FCAL_1_FLC_PB_FSTEP_MSB                                                                 9
-#define PHY_BB_FCAL_1_FLC_PB_FSTEP_LSB                                                                 0
-#define PHY_BB_FCAL_1_FLC_PB_FSTEP_MASK                                                       0x000003ff
-#define PHY_BB_FCAL_1_FLC_PB_FSTEP_GET(x)                                      (((x) & 0x000003ff) >> 0)
-#define PHY_BB_FCAL_1_FLC_PB_FSTEP_SET(x)                                      (((x) << 0) & 0x000003ff)
-#define PHY_BB_FCAL_1_FLC_SB_FSTEP_MSB                                                                19
-#define PHY_BB_FCAL_1_FLC_SB_FSTEP_LSB                                                                10
-#define PHY_BB_FCAL_1_FLC_SB_FSTEP_MASK                                                       0x000ffc00
-#define PHY_BB_FCAL_1_FLC_SB_FSTEP_GET(x)                                     (((x) & 0x000ffc00) >> 10)
-#define PHY_BB_FCAL_1_FLC_SB_FSTEP_SET(x)                                     (((x) << 10) & 0x000ffc00)
-#define PHY_BB_FCAL_1_FLC_PB_ATTEN_MSB                                                                24
-#define PHY_BB_FCAL_1_FLC_PB_ATTEN_LSB                                                                20
-#define PHY_BB_FCAL_1_FLC_PB_ATTEN_MASK                                                       0x01f00000
-#define PHY_BB_FCAL_1_FLC_PB_ATTEN_GET(x)                                     (((x) & 0x01f00000) >> 20)
-#define PHY_BB_FCAL_1_FLC_PB_ATTEN_SET(x)                                     (((x) << 20) & 0x01f00000)
-#define PHY_BB_FCAL_1_FLC_SB_ATTEN_MSB                                                                29
-#define PHY_BB_FCAL_1_FLC_SB_ATTEN_LSB                                                                25
-#define PHY_BB_FCAL_1_FLC_SB_ATTEN_MASK                                                       0x3e000000
-#define PHY_BB_FCAL_1_FLC_SB_ATTEN_GET(x)                                     (((x) & 0x3e000000) >> 25)
-#define PHY_BB_FCAL_1_FLC_SB_ATTEN_SET(x)                                     (((x) << 25) & 0x3e000000)
-
-/* macros for BB_fcal_2_b0 */
-#define PHY_BB_FCAL_2_B0_ADDRESS                                                              0x0000a7dc
-#define PHY_BB_FCAL_2_B0_OFFSET                                                               0x0000a7dc
-#define PHY_BB_FCAL_2_B0_FLC_PWR_THRESH_MSB                                                            2
-#define PHY_BB_FCAL_2_B0_FLC_PWR_THRESH_LSB                                                            0
-#define PHY_BB_FCAL_2_B0_FLC_PWR_THRESH_MASK                                                  0x00000007
-#define PHY_BB_FCAL_2_B0_FLC_PWR_THRESH_GET(x)                                 (((x) & 0x00000007) >> 0)
-#define PHY_BB_FCAL_2_B0_FLC_PWR_THRESH_SET(x)                                 (((x) << 0) & 0x00000007)
-#define PHY_BB_FCAL_2_B0_FLC_SW_CAP_VAL_0_MSB                                                          7
-#define PHY_BB_FCAL_2_B0_FLC_SW_CAP_VAL_0_LSB                                                          3
-#define PHY_BB_FCAL_2_B0_FLC_SW_CAP_VAL_0_MASK                                                0x000000f8
-#define PHY_BB_FCAL_2_B0_FLC_SW_CAP_VAL_0_GET(x)                               (((x) & 0x000000f8) >> 3)
-#define PHY_BB_FCAL_2_B0_FLC_SW_CAP_VAL_0_SET(x)                               (((x) << 3) & 0x000000f8)
-#define PHY_BB_FCAL_2_B0_FLC_BBMISCGAIN_MSB                                                            9
-#define PHY_BB_FCAL_2_B0_FLC_BBMISCGAIN_LSB                                                            8
-#define PHY_BB_FCAL_2_B0_FLC_BBMISCGAIN_MASK                                                  0x00000300
-#define PHY_BB_FCAL_2_B0_FLC_BBMISCGAIN_GET(x)                                 (((x) & 0x00000300) >> 8)
-#define PHY_BB_FCAL_2_B0_FLC_BBMISCGAIN_SET(x)                                 (((x) << 8) & 0x00000300)
-#define PHY_BB_FCAL_2_B0_FLC_BB1DBGAIN_MSB                                                            12
-#define PHY_BB_FCAL_2_B0_FLC_BB1DBGAIN_LSB                                                            10
-#define PHY_BB_FCAL_2_B0_FLC_BB1DBGAIN_MASK                                                   0x00001c00
-#define PHY_BB_FCAL_2_B0_FLC_BB1DBGAIN_GET(x)                                 (((x) & 0x00001c00) >> 10)
-#define PHY_BB_FCAL_2_B0_FLC_BB1DBGAIN_SET(x)                                 (((x) << 10) & 0x00001c00)
-#define PHY_BB_FCAL_2_B0_FLC_BB6DBGAIN_MSB                                                            14
-#define PHY_BB_FCAL_2_B0_FLC_BB6DBGAIN_LSB                                                            13
-#define PHY_BB_FCAL_2_B0_FLC_BB6DBGAIN_MASK                                                   0x00006000
-#define PHY_BB_FCAL_2_B0_FLC_BB6DBGAIN_GET(x)                                 (((x) & 0x00006000) >> 13)
-#define PHY_BB_FCAL_2_B0_FLC_BB6DBGAIN_SET(x)                                 (((x) << 13) & 0x00006000)
-#define PHY_BB_FCAL_2_B0_FLC_SW_CAP_SET_MSB                                                           15
-#define PHY_BB_FCAL_2_B0_FLC_SW_CAP_SET_LSB                                                           15
-#define PHY_BB_FCAL_2_B0_FLC_SW_CAP_SET_MASK                                                  0x00008000
-#define PHY_BB_FCAL_2_B0_FLC_SW_CAP_SET_GET(x)                                (((x) & 0x00008000) >> 15)
-#define PHY_BB_FCAL_2_B0_FLC_SW_CAP_SET_SET(x)                                (((x) << 15) & 0x00008000)
-#define PHY_BB_FCAL_2_B0_FLC_MEAS_WIN_MSB                                                             18
-#define PHY_BB_FCAL_2_B0_FLC_MEAS_WIN_LSB                                                             16
-#define PHY_BB_FCAL_2_B0_FLC_MEAS_WIN_MASK                                                    0x00070000
-#define PHY_BB_FCAL_2_B0_FLC_MEAS_WIN_GET(x)                                  (((x) & 0x00070000) >> 16)
-#define PHY_BB_FCAL_2_B0_FLC_MEAS_WIN_SET(x)                                  (((x) << 16) & 0x00070000)
-#define PHY_BB_FCAL_2_B0_FLC_CAP_VAL_STATUS_0_MSB                                                     24
-#define PHY_BB_FCAL_2_B0_FLC_CAP_VAL_STATUS_0_LSB                                                     20
-#define PHY_BB_FCAL_2_B0_FLC_CAP_VAL_STATUS_0_MASK                                            0x01f00000
-#define PHY_BB_FCAL_2_B0_FLC_CAP_VAL_STATUS_0_GET(x)                          (((x) & 0x01f00000) >> 20)
-
-/* macros for BB_radar_bw_filter */
-#define PHY_BB_RADAR_BW_FILTER_ADDRESS                                                        0x0000a7e0
-#define PHY_BB_RADAR_BW_FILTER_OFFSET                                                         0x0000a7e0
-#define PHY_BB_RADAR_BW_FILTER_RADAR_AVG_BW_CHECK_MSB                                                  0
-#define PHY_BB_RADAR_BW_FILTER_RADAR_AVG_BW_CHECK_LSB                                                  0
-#define PHY_BB_RADAR_BW_FILTER_RADAR_AVG_BW_CHECK_MASK                                        0x00000001
-#define PHY_BB_RADAR_BW_FILTER_RADAR_AVG_BW_CHECK_GET(x)                       (((x) & 0x00000001) >> 0)
-#define PHY_BB_RADAR_BW_FILTER_RADAR_AVG_BW_CHECK_SET(x)                       (((x) << 0) & 0x00000001)
-#define PHY_BB_RADAR_BW_FILTER_RADAR_DC_SRC_SEL_MSB                                                    1
-#define PHY_BB_RADAR_BW_FILTER_RADAR_DC_SRC_SEL_LSB                                                    1
-#define PHY_BB_RADAR_BW_FILTER_RADAR_DC_SRC_SEL_MASK                                          0x00000002
-#define PHY_BB_RADAR_BW_FILTER_RADAR_DC_SRC_SEL_GET(x)                         (((x) & 0x00000002) >> 1)
-#define PHY_BB_RADAR_BW_FILTER_RADAR_DC_SRC_SEL_SET(x)                         (((x) << 1) & 0x00000002)
-#define PHY_BB_RADAR_BW_FILTER_RADAR_FIRPWR_SEL_MSB                                                    3
-#define PHY_BB_RADAR_BW_FILTER_RADAR_FIRPWR_SEL_LSB                                                    2
-#define PHY_BB_RADAR_BW_FILTER_RADAR_FIRPWR_SEL_MASK                                          0x0000000c
-#define PHY_BB_RADAR_BW_FILTER_RADAR_FIRPWR_SEL_GET(x)                         (((x) & 0x0000000c) >> 2)
-#define PHY_BB_RADAR_BW_FILTER_RADAR_FIRPWR_SEL_SET(x)                         (((x) << 2) & 0x0000000c)
-#define PHY_BB_RADAR_BW_FILTER_RADAR_PULSE_WIDTH_SEL_MSB                                               5
-#define PHY_BB_RADAR_BW_FILTER_RADAR_PULSE_WIDTH_SEL_LSB                                               4
-#define PHY_BB_RADAR_BW_FILTER_RADAR_PULSE_WIDTH_SEL_MASK                                     0x00000030
-#define PHY_BB_RADAR_BW_FILTER_RADAR_PULSE_WIDTH_SEL_GET(x)                    (((x) & 0x00000030) >> 4)
-#define PHY_BB_RADAR_BW_FILTER_RADAR_PULSE_WIDTH_SEL_SET(x)                    (((x) << 4) & 0x00000030)
-#define PHY_BB_RADAR_BW_FILTER_RADAR_DC_FIRPWR_THRESH_MSB                                             14
-#define PHY_BB_RADAR_BW_FILTER_RADAR_DC_FIRPWR_THRESH_LSB                                              8
-#define PHY_BB_RADAR_BW_FILTER_RADAR_DC_FIRPWR_THRESH_MASK                                    0x00007f00
-#define PHY_BB_RADAR_BW_FILTER_RADAR_DC_FIRPWR_THRESH_GET(x)                   (((x) & 0x00007f00) >> 8)
-#define PHY_BB_RADAR_BW_FILTER_RADAR_DC_FIRPWR_THRESH_SET(x)                   (((x) << 8) & 0x00007f00)
-#define PHY_BB_RADAR_BW_FILTER_RADAR_DC_PWR_BIAS_MSB                                                  20
-#define PHY_BB_RADAR_BW_FILTER_RADAR_DC_PWR_BIAS_LSB                                                  15
-#define PHY_BB_RADAR_BW_FILTER_RADAR_DC_PWR_BIAS_MASK                                         0x001f8000
-#define PHY_BB_RADAR_BW_FILTER_RADAR_DC_PWR_BIAS_GET(x)                       (((x) & 0x001f8000) >> 15)
-#define PHY_BB_RADAR_BW_FILTER_RADAR_DC_PWR_BIAS_SET(x)                       (((x) << 15) & 0x001f8000)
-#define PHY_BB_RADAR_BW_FILTER_RADAR_BIN_MAX_BW_MSB                                                   26
-#define PHY_BB_RADAR_BW_FILTER_RADAR_BIN_MAX_BW_LSB                                                   21
-#define PHY_BB_RADAR_BW_FILTER_RADAR_BIN_MAX_BW_MASK                                          0x07e00000
-#define PHY_BB_RADAR_BW_FILTER_RADAR_BIN_MAX_BW_GET(x)                        (((x) & 0x07e00000) >> 21)
-#define PHY_BB_RADAR_BW_FILTER_RADAR_BIN_MAX_BW_SET(x)                        (((x) << 21) & 0x07e00000)
-
-/* macros for BB_dft_tone_ctrl_b0 */
-#define PHY_BB_DFT_TONE_CTRL_B0_ADDRESS                                                       0x0000a7e4
-#define PHY_BB_DFT_TONE_CTRL_B0_OFFSET                                                        0x0000a7e4
-#define PHY_BB_DFT_TONE_CTRL_B0_DFT_TONE_EN_0_MSB                                                      0
-#define PHY_BB_DFT_TONE_CTRL_B0_DFT_TONE_EN_0_LSB                                                      0
-#define PHY_BB_DFT_TONE_CTRL_B0_DFT_TONE_EN_0_MASK                                            0x00000001
-#define PHY_BB_DFT_TONE_CTRL_B0_DFT_TONE_EN_0_GET(x)                           (((x) & 0x00000001) >> 0)
-#define PHY_BB_DFT_TONE_CTRL_B0_DFT_TONE_EN_0_SET(x)                           (((x) << 0) & 0x00000001)
-#define PHY_BB_DFT_TONE_CTRL_B0_DFT_TONE_AMP_SEL_0_MSB                                                 3
-#define PHY_BB_DFT_TONE_CTRL_B0_DFT_TONE_AMP_SEL_0_LSB                                                 2
-#define PHY_BB_DFT_TONE_CTRL_B0_DFT_TONE_AMP_SEL_0_MASK                                       0x0000000c
-#define PHY_BB_DFT_TONE_CTRL_B0_DFT_TONE_AMP_SEL_0_GET(x)                      (((x) & 0x0000000c) >> 2)
-#define PHY_BB_DFT_TONE_CTRL_B0_DFT_TONE_AMP_SEL_0_SET(x)                      (((x) << 2) & 0x0000000c)
-#define PHY_BB_DFT_TONE_CTRL_B0_DFT_TONE_FREQ_ANG_0_MSB                                               12
-#define PHY_BB_DFT_TONE_CTRL_B0_DFT_TONE_FREQ_ANG_0_LSB                                                4
-#define PHY_BB_DFT_TONE_CTRL_B0_DFT_TONE_FREQ_ANG_0_MASK                                      0x00001ff0
-#define PHY_BB_DFT_TONE_CTRL_B0_DFT_TONE_FREQ_ANG_0_GET(x)                     (((x) & 0x00001ff0) >> 4)
-#define PHY_BB_DFT_TONE_CTRL_B0_DFT_TONE_FREQ_ANG_0_SET(x)                     (((x) << 4) & 0x00001ff0)
-
-/* macros for BB_therm_adc_1 */
-#define PHY_BB_THERM_ADC_1_ADDRESS                                                            0x0000a7e8
-#define PHY_BB_THERM_ADC_1_OFFSET                                                             0x0000a7e8
-#define PHY_BB_THERM_ADC_1_INIT_THERM_SETTING_MSB                                                      7
-#define PHY_BB_THERM_ADC_1_INIT_THERM_SETTING_LSB                                                      0
-#define PHY_BB_THERM_ADC_1_INIT_THERM_SETTING_MASK                                            0x000000ff
-#define PHY_BB_THERM_ADC_1_INIT_THERM_SETTING_GET(x)                           (((x) & 0x000000ff) >> 0)
-#define PHY_BB_THERM_ADC_1_INIT_THERM_SETTING_SET(x)                           (((x) << 0) & 0x000000ff)
-#define PHY_BB_THERM_ADC_1_INIT_VOLT_SETTING_MSB                                                      15
-#define PHY_BB_THERM_ADC_1_INIT_VOLT_SETTING_LSB                                                       8
-#define PHY_BB_THERM_ADC_1_INIT_VOLT_SETTING_MASK                                             0x0000ff00
-#define PHY_BB_THERM_ADC_1_INIT_VOLT_SETTING_GET(x)                            (((x) & 0x0000ff00) >> 8)
-#define PHY_BB_THERM_ADC_1_INIT_VOLT_SETTING_SET(x)                            (((x) << 8) & 0x0000ff00)
-#define PHY_BB_THERM_ADC_1_INIT_ATB_SETTING_MSB                                                       23
-#define PHY_BB_THERM_ADC_1_INIT_ATB_SETTING_LSB                                                       16
-#define PHY_BB_THERM_ADC_1_INIT_ATB_SETTING_MASK                                              0x00ff0000
-#define PHY_BB_THERM_ADC_1_INIT_ATB_SETTING_GET(x)                            (((x) & 0x00ff0000) >> 16)
-#define PHY_BB_THERM_ADC_1_INIT_ATB_SETTING_SET(x)                            (((x) << 16) & 0x00ff0000)
-#define PHY_BB_THERM_ADC_1_SAMPLES_CNT_CODING_MSB                                                     25
-#define PHY_BB_THERM_ADC_1_SAMPLES_CNT_CODING_LSB                                                     24
-#define PHY_BB_THERM_ADC_1_SAMPLES_CNT_CODING_MASK                                            0x03000000
-#define PHY_BB_THERM_ADC_1_SAMPLES_CNT_CODING_GET(x)                          (((x) & 0x03000000) >> 24)
-#define PHY_BB_THERM_ADC_1_SAMPLES_CNT_CODING_SET(x)                          (((x) << 24) & 0x03000000)
-#define PHY_BB_THERM_ADC_1_USE_INIT_THERM_VOLT_ATB_AFTER_WARM_RESET_MSB                               26
-#define PHY_BB_THERM_ADC_1_USE_INIT_THERM_VOLT_ATB_AFTER_WARM_RESET_LSB                               26
-#define PHY_BB_THERM_ADC_1_USE_INIT_THERM_VOLT_ATB_AFTER_WARM_RESET_MASK                      0x04000000
-#define PHY_BB_THERM_ADC_1_USE_INIT_THERM_VOLT_ATB_AFTER_WARM_RESET_GET(x)    (((x) & 0x04000000) >> 26)
-#define PHY_BB_THERM_ADC_1_USE_INIT_THERM_VOLT_ATB_AFTER_WARM_RESET_SET(x)    (((x) << 26) & 0x04000000)
-#define PHY_BB_THERM_ADC_1_FORCE_THERM_VOLT_ATB_TO_INIT_SETTINGS_MSB                                  27
-#define PHY_BB_THERM_ADC_1_FORCE_THERM_VOLT_ATB_TO_INIT_SETTINGS_LSB                                  27
-#define PHY_BB_THERM_ADC_1_FORCE_THERM_VOLT_ATB_TO_INIT_SETTINGS_MASK                         0x08000000
-#define PHY_BB_THERM_ADC_1_FORCE_THERM_VOLT_ATB_TO_INIT_SETTINGS_GET(x)       (((x) & 0x08000000) >> 27)
-#define PHY_BB_THERM_ADC_1_FORCE_THERM_VOLT_ATB_TO_INIT_SETTINGS_SET(x)       (((x) << 27) & 0x08000000)
-
-/* macros for BB_therm_adc_2 */
-#define PHY_BB_THERM_ADC_2_ADDRESS                                                            0x0000a7ec
-#define PHY_BB_THERM_ADC_2_OFFSET                                                             0x0000a7ec
-#define PHY_BB_THERM_ADC_2_MEASURE_THERM_FREQ_MSB                                                     11
-#define PHY_BB_THERM_ADC_2_MEASURE_THERM_FREQ_LSB                                                      0
-#define PHY_BB_THERM_ADC_2_MEASURE_THERM_FREQ_MASK                                            0x00000fff
-#define PHY_BB_THERM_ADC_2_MEASURE_THERM_FREQ_GET(x)                           (((x) & 0x00000fff) >> 0)
-#define PHY_BB_THERM_ADC_2_MEASURE_THERM_FREQ_SET(x)                           (((x) << 0) & 0x00000fff)
-#define PHY_BB_THERM_ADC_2_MEASURE_VOLT_FREQ_MSB                                                      21
-#define PHY_BB_THERM_ADC_2_MEASURE_VOLT_FREQ_LSB                                                      12
-#define PHY_BB_THERM_ADC_2_MEASURE_VOLT_FREQ_MASK                                             0x003ff000
-#define PHY_BB_THERM_ADC_2_MEASURE_VOLT_FREQ_GET(x)                           (((x) & 0x003ff000) >> 12)
-#define PHY_BB_THERM_ADC_2_MEASURE_VOLT_FREQ_SET(x)                           (((x) << 12) & 0x003ff000)
-#define PHY_BB_THERM_ADC_2_MEASURE_ATB_FREQ_MSB                                                       31
-#define PHY_BB_THERM_ADC_2_MEASURE_ATB_FREQ_LSB                                                       22
-#define PHY_BB_THERM_ADC_2_MEASURE_ATB_FREQ_MASK                                              0xffc00000
-#define PHY_BB_THERM_ADC_2_MEASURE_ATB_FREQ_GET(x)                            (((x) & 0xffc00000) >> 22)
-#define PHY_BB_THERM_ADC_2_MEASURE_ATB_FREQ_SET(x)                            (((x) << 22) & 0xffc00000)
-
-/* macros for BB_therm_adc_3 */
-#define PHY_BB_THERM_ADC_3_ADDRESS                                                            0x0000a7f0
-#define PHY_BB_THERM_ADC_3_OFFSET                                                             0x0000a7f0
-#define PHY_BB_THERM_ADC_3_THERM_ADC_OFFSET_MSB                                                        7
-#define PHY_BB_THERM_ADC_3_THERM_ADC_OFFSET_LSB                                                        0
-#define PHY_BB_THERM_ADC_3_THERM_ADC_OFFSET_MASK                                              0x000000ff
-#define PHY_BB_THERM_ADC_3_THERM_ADC_OFFSET_GET(x)                             (((x) & 0x000000ff) >> 0)
-#define PHY_BB_THERM_ADC_3_THERM_ADC_OFFSET_SET(x)                             (((x) << 0) & 0x000000ff)
-#define PHY_BB_THERM_ADC_3_THERM_ADC_SCALED_GAIN_MSB                                                  16
-#define PHY_BB_THERM_ADC_3_THERM_ADC_SCALED_GAIN_LSB                                                   8
-#define PHY_BB_THERM_ADC_3_THERM_ADC_SCALED_GAIN_MASK                                         0x0001ff00
-#define PHY_BB_THERM_ADC_3_THERM_ADC_SCALED_GAIN_GET(x)                        (((x) & 0x0001ff00) >> 8)
-#define PHY_BB_THERM_ADC_3_THERM_ADC_SCALED_GAIN_SET(x)                        (((x) << 8) & 0x0001ff00)
-#define PHY_BB_THERM_ADC_3_ADC_INTERVAL_MSB                                                           29
-#define PHY_BB_THERM_ADC_3_ADC_INTERVAL_LSB                                                           17
-#define PHY_BB_THERM_ADC_3_ADC_INTERVAL_MASK                                                  0x3ffe0000
-#define PHY_BB_THERM_ADC_3_ADC_INTERVAL_GET(x)                                (((x) & 0x3ffe0000) >> 17)
-#define PHY_BB_THERM_ADC_3_ADC_INTERVAL_SET(x)                                (((x) << 17) & 0x3ffe0000)
-
-/* macros for BB_therm_adc_4 */
-#define PHY_BB_THERM_ADC_4_ADDRESS                                                            0x0000a7f4
-#define PHY_BB_THERM_ADC_4_OFFSET                                                             0x0000a7f4
-#define PHY_BB_THERM_ADC_4_LATEST_THERM_VALUE_MSB                                                      7
-#define PHY_BB_THERM_ADC_4_LATEST_THERM_VALUE_LSB                                                      0
-#define PHY_BB_THERM_ADC_4_LATEST_THERM_VALUE_MASK                                            0x000000ff
-#define PHY_BB_THERM_ADC_4_LATEST_THERM_VALUE_GET(x)                           (((x) & 0x000000ff) >> 0)
-#define PHY_BB_THERM_ADC_4_LATEST_VOLT_VALUE_MSB                                                      15
-#define PHY_BB_THERM_ADC_4_LATEST_VOLT_VALUE_LSB                                                       8
-#define PHY_BB_THERM_ADC_4_LATEST_VOLT_VALUE_MASK                                             0x0000ff00
-#define PHY_BB_THERM_ADC_4_LATEST_VOLT_VALUE_GET(x)                            (((x) & 0x0000ff00) >> 8)
-#define PHY_BB_THERM_ADC_4_LATEST_ATB_VALUE_MSB                                                       23
-#define PHY_BB_THERM_ADC_4_LATEST_ATB_VALUE_LSB                                                       16
-#define PHY_BB_THERM_ADC_4_LATEST_ATB_VALUE_MASK                                              0x00ff0000
-#define PHY_BB_THERM_ADC_4_LATEST_ATB_VALUE_GET(x)                            (((x) & 0x00ff0000) >> 16)
-
-/* macros for BB_tx_forced_gain */
-#define PHY_BB_TX_FORCED_GAIN_ADDRESS                                                         0x0000a7f8
-#define PHY_BB_TX_FORCED_GAIN_OFFSET                                                          0x0000a7f8
-#define PHY_BB_TX_FORCED_GAIN_FORCE_TX_GAIN_MSB                                                        0
-#define PHY_BB_TX_FORCED_GAIN_FORCE_TX_GAIN_LSB                                                        0
-#define PHY_BB_TX_FORCED_GAIN_FORCE_TX_GAIN_MASK                                              0x00000001
-#define PHY_BB_TX_FORCED_GAIN_FORCE_TX_GAIN_GET(x)                             (((x) & 0x00000001) >> 0)
-#define PHY_BB_TX_FORCED_GAIN_FORCE_TX_GAIN_SET(x)                             (((x) << 0) & 0x00000001)
-#define PHY_BB_TX_FORCED_GAIN_FORCED_TXBB1DBGAIN_MSB                                                   3
-#define PHY_BB_TX_FORCED_GAIN_FORCED_TXBB1DBGAIN_LSB                                                   1
-#define PHY_BB_TX_FORCED_GAIN_FORCED_TXBB1DBGAIN_MASK                                         0x0000000e
-#define PHY_BB_TX_FORCED_GAIN_FORCED_TXBB1DBGAIN_GET(x)                        (((x) & 0x0000000e) >> 1)
-#define PHY_BB_TX_FORCED_GAIN_FORCED_TXBB1DBGAIN_SET(x)                        (((x) << 1) & 0x0000000e)
-#define PHY_BB_TX_FORCED_GAIN_FORCED_TXBB6DBGAIN_MSB                                                   5
-#define PHY_BB_TX_FORCED_GAIN_FORCED_TXBB6DBGAIN_LSB                                                   4
-#define PHY_BB_TX_FORCED_GAIN_FORCED_TXBB6DBGAIN_MASK                                         0x00000030
-#define PHY_BB_TX_FORCED_GAIN_FORCED_TXBB6DBGAIN_GET(x)                        (((x) & 0x00000030) >> 4)
-#define PHY_BB_TX_FORCED_GAIN_FORCED_TXBB6DBGAIN_SET(x)                        (((x) << 4) & 0x00000030)
-#define PHY_BB_TX_FORCED_GAIN_FORCED_TXMXRGAIN_MSB                                                     9
-#define PHY_BB_TX_FORCED_GAIN_FORCED_TXMXRGAIN_LSB                                                     6
-#define PHY_BB_TX_FORCED_GAIN_FORCED_TXMXRGAIN_MASK                                           0x000003c0
-#define PHY_BB_TX_FORCED_GAIN_FORCED_TXMXRGAIN_GET(x)                          (((x) & 0x000003c0) >> 6)
-#define PHY_BB_TX_FORCED_GAIN_FORCED_TXMXRGAIN_SET(x)                          (((x) << 6) & 0x000003c0)
-#define PHY_BB_TX_FORCED_GAIN_FORCED_PADRVGNA_MSB                                                     13
-#define PHY_BB_TX_FORCED_GAIN_FORCED_PADRVGNA_LSB                                                     10
-#define PHY_BB_TX_FORCED_GAIN_FORCED_PADRVGNA_MASK                                            0x00003c00
-#define PHY_BB_TX_FORCED_GAIN_FORCED_PADRVGNA_GET(x)                          (((x) & 0x00003c00) >> 10)
-#define PHY_BB_TX_FORCED_GAIN_FORCED_PADRVGNA_SET(x)                          (((x) << 10) & 0x00003c00)
-#define PHY_BB_TX_FORCED_GAIN_FORCED_PADRVGNB_MSB                                                     17
-#define PHY_BB_TX_FORCED_GAIN_FORCED_PADRVGNB_LSB                                                     14
-#define PHY_BB_TX_FORCED_GAIN_FORCED_PADRVGNB_MASK                                            0x0003c000
-#define PHY_BB_TX_FORCED_GAIN_FORCED_PADRVGNB_GET(x)                          (((x) & 0x0003c000) >> 14)
-#define PHY_BB_TX_FORCED_GAIN_FORCED_PADRVGNB_SET(x)                          (((x) << 14) & 0x0003c000)
-#define PHY_BB_TX_FORCED_GAIN_FORCED_PADRVGNC_MSB                                                     21
-#define PHY_BB_TX_FORCED_GAIN_FORCED_PADRVGNC_LSB                                                     18
-#define PHY_BB_TX_FORCED_GAIN_FORCED_PADRVGNC_MASK                                            0x003c0000
-#define PHY_BB_TX_FORCED_GAIN_FORCED_PADRVGNC_GET(x)                          (((x) & 0x003c0000) >> 18)
-#define PHY_BB_TX_FORCED_GAIN_FORCED_PADRVGNC_SET(x)                          (((x) << 18) & 0x003c0000)
-#define PHY_BB_TX_FORCED_GAIN_FORCED_PADRVGND_MSB                                                     23
-#define PHY_BB_TX_FORCED_GAIN_FORCED_PADRVGND_LSB                                                     22
-#define PHY_BB_TX_FORCED_GAIN_FORCED_PADRVGND_MASK                                            0x00c00000
-#define PHY_BB_TX_FORCED_GAIN_FORCED_PADRVGND_GET(x)                          (((x) & 0x00c00000) >> 22)
-#define PHY_BB_TX_FORCED_GAIN_FORCED_PADRVGND_SET(x)                          (((x) << 22) & 0x00c00000)
-#define PHY_BB_TX_FORCED_GAIN_FORCED_ENABLE_PAL_MSB                                                   24
-#define PHY_BB_TX_FORCED_GAIN_FORCED_ENABLE_PAL_LSB                                                   24
-#define PHY_BB_TX_FORCED_GAIN_FORCED_ENABLE_PAL_MASK                                          0x01000000
-#define PHY_BB_TX_FORCED_GAIN_FORCED_ENABLE_PAL_GET(x)                        (((x) & 0x01000000) >> 24)
-#define PHY_BB_TX_FORCED_GAIN_FORCED_ENABLE_PAL_SET(x)                        (((x) << 24) & 0x01000000)
-
-/* macros for BB_eco_ctrl */
-#define PHY_BB_ECO_CTRL_ADDRESS                                                               0x0000a7fc
-#define PHY_BB_ECO_CTRL_OFFSET                                                                0x0000a7fc
-#define PHY_BB_ECO_CTRL_ECO_CTRL_MSB                                                                   7
-#define PHY_BB_ECO_CTRL_ECO_CTRL_LSB                                                                   0
-#define PHY_BB_ECO_CTRL_ECO_CTRL_MASK                                                         0x000000ff
-#define PHY_BB_ECO_CTRL_ECO_CTRL_GET(x)                                        (((x) & 0x000000ff) >> 0)
-#define PHY_BB_ECO_CTRL_ECO_CTRL_SET(x)                                        (((x) << 0) & 0x000000ff)
-
-/* macros for BB_gain_force_max_gains_b1 */
-#define PHY_BB_GAIN_FORCE_MAX_GAINS_B1_ADDRESS                                                0x0000a848
-#define PHY_BB_GAIN_FORCE_MAX_GAINS_B1_OFFSET                                                 0x0000a848
-#define PHY_BB_GAIN_FORCE_MAX_GAINS_B1_XATTEN1_HYST_MARGIN_1_MSB                                      13
-#define PHY_BB_GAIN_FORCE_MAX_GAINS_B1_XATTEN1_HYST_MARGIN_1_LSB                                       7
-#define PHY_BB_GAIN_FORCE_MAX_GAINS_B1_XATTEN1_HYST_MARGIN_1_MASK                             0x00003f80
-#define PHY_BB_GAIN_FORCE_MAX_GAINS_B1_XATTEN1_HYST_MARGIN_1_GET(x)            (((x) & 0x00003f80) >> 7)
-#define PHY_BB_GAIN_FORCE_MAX_GAINS_B1_XATTEN1_HYST_MARGIN_1_SET(x)            (((x) << 7) & 0x00003f80)
-#define PHY_BB_GAIN_FORCE_MAX_GAINS_B1_XATTEN2_HYST_MARGIN_1_MSB                                      20
-#define PHY_BB_GAIN_FORCE_MAX_GAINS_B1_XATTEN2_HYST_MARGIN_1_LSB                                      14
-#define PHY_BB_GAIN_FORCE_MAX_GAINS_B1_XATTEN2_HYST_MARGIN_1_MASK                             0x001fc000
-#define PHY_BB_GAIN_FORCE_MAX_GAINS_B1_XATTEN2_HYST_MARGIN_1_GET(x)           (((x) & 0x001fc000) >> 14)
-#define PHY_BB_GAIN_FORCE_MAX_GAINS_B1_XATTEN2_HYST_MARGIN_1_SET(x)           (((x) << 14) & 0x001fc000)
-
-/* macros for BB_gains_min_offsets_b1 */
-#define PHY_BB_GAINS_MIN_OFFSETS_B1_ADDRESS                                                   0x0000a84c
-#define PHY_BB_GAINS_MIN_OFFSETS_B1_OFFSET                                                    0x0000a84c
-#define PHY_BB_GAINS_MIN_OFFSETS_B1_RF_GAIN_F_1_MSB                                                   24
-#define PHY_BB_GAINS_MIN_OFFSETS_B1_RF_GAIN_F_1_LSB                                                   17
-#define PHY_BB_GAINS_MIN_OFFSETS_B1_RF_GAIN_F_1_MASK                                          0x01fe0000
-#define PHY_BB_GAINS_MIN_OFFSETS_B1_RF_GAIN_F_1_GET(x)                        (((x) & 0x01fe0000) >> 17)
-#define PHY_BB_GAINS_MIN_OFFSETS_B1_RF_GAIN_F_1_SET(x)                        (((x) << 17) & 0x01fe0000)
-#define PHY_BB_GAINS_MIN_OFFSETS_B1_XATTEN1_SW_F_1_MSB                                                25
-#define PHY_BB_GAINS_MIN_OFFSETS_B1_XATTEN1_SW_F_1_LSB                                                25
-#define PHY_BB_GAINS_MIN_OFFSETS_B1_XATTEN1_SW_F_1_MASK                                       0x02000000
-#define PHY_BB_GAINS_MIN_OFFSETS_B1_XATTEN1_SW_F_1_GET(x)                     (((x) & 0x02000000) >> 25)
-#define PHY_BB_GAINS_MIN_OFFSETS_B1_XATTEN1_SW_F_1_SET(x)                     (((x) << 25) & 0x02000000)
-#define PHY_BB_GAINS_MIN_OFFSETS_B1_XATTEN2_SW_F_1_MSB                                                26
-#define PHY_BB_GAINS_MIN_OFFSETS_B1_XATTEN2_SW_F_1_LSB                                                26
-#define PHY_BB_GAINS_MIN_OFFSETS_B1_XATTEN2_SW_F_1_MASK                                       0x04000000
-#define PHY_BB_GAINS_MIN_OFFSETS_B1_XATTEN2_SW_F_1_GET(x)                     (((x) & 0x04000000) >> 26)
-#define PHY_BB_GAINS_MIN_OFFSETS_B1_XATTEN2_SW_F_1_SET(x)                     (((x) << 26) & 0x04000000)
-
-/* macros for BB_rx_ocgain2 */
-#define PHY_BB_RX_OCGAIN2_ADDRESS                                                             0x0000aa00
-#define PHY_BB_RX_OCGAIN2_OFFSET                                                              0x0000aa00
-#define PHY_BB_RX_OCGAIN2_GAIN_ENTRY2_MSB                                                             31
-#define PHY_BB_RX_OCGAIN2_GAIN_ENTRY2_LSB                                                              0
-#define PHY_BB_RX_OCGAIN2_GAIN_ENTRY2_MASK                                                    0xffffffff
-#define PHY_BB_RX_OCGAIN2_GAIN_ENTRY2_SET(x)                                   (((x) << 0) & 0xffffffff)
-
-/* macros for BB_ext_atten_switch_ctl_b1 */
-#define PHY_BB_EXT_ATTEN_SWITCH_CTL_B1_ADDRESS                                                0x0000b20c
-#define PHY_BB_EXT_ATTEN_SWITCH_CTL_B1_OFFSET                                                 0x0000b20c
-#define PHY_BB_EXT_ATTEN_SWITCH_CTL_B1_XATTEN1_DB_1_MSB                                                5
-#define PHY_BB_EXT_ATTEN_SWITCH_CTL_B1_XATTEN1_DB_1_LSB                                                0
-#define PHY_BB_EXT_ATTEN_SWITCH_CTL_B1_XATTEN1_DB_1_MASK                                      0x0000003f
-#define PHY_BB_EXT_ATTEN_SWITCH_CTL_B1_XATTEN1_DB_1_GET(x)                     (((x) & 0x0000003f) >> 0)
-#define PHY_BB_EXT_ATTEN_SWITCH_CTL_B1_XATTEN1_DB_1_SET(x)                     (((x) << 0) & 0x0000003f)
-#define PHY_BB_EXT_ATTEN_SWITCH_CTL_B1_XATTEN2_DB_1_MSB                                               11
-#define PHY_BB_EXT_ATTEN_SWITCH_CTL_B1_XATTEN2_DB_1_LSB                                                6
-#define PHY_BB_EXT_ATTEN_SWITCH_CTL_B1_XATTEN2_DB_1_MASK                                      0x00000fc0
-#define PHY_BB_EXT_ATTEN_SWITCH_CTL_B1_XATTEN2_DB_1_GET(x)                     (((x) & 0x00000fc0) >> 6)
-#define PHY_BB_EXT_ATTEN_SWITCH_CTL_B1_XATTEN2_DB_1_SET(x)                     (((x) << 6) & 0x00000fc0)
-#define PHY_BB_EXT_ATTEN_SWITCH_CTL_B1_XATTEN1_MARGIN_1_MSB                                           16
-#define PHY_BB_EXT_ATTEN_SWITCH_CTL_B1_XATTEN1_MARGIN_1_LSB                                           12
-#define PHY_BB_EXT_ATTEN_SWITCH_CTL_B1_XATTEN1_MARGIN_1_MASK                                  0x0001f000
-#define PHY_BB_EXT_ATTEN_SWITCH_CTL_B1_XATTEN1_MARGIN_1_GET(x)                (((x) & 0x0001f000) >> 12)
-#define PHY_BB_EXT_ATTEN_SWITCH_CTL_B1_XATTEN1_MARGIN_1_SET(x)                (((x) << 12) & 0x0001f000)
-#define PHY_BB_EXT_ATTEN_SWITCH_CTL_B1_XATTEN2_MARGIN_1_MSB                                           21
-#define PHY_BB_EXT_ATTEN_SWITCH_CTL_B1_XATTEN2_MARGIN_1_LSB                                           17
-#define PHY_BB_EXT_ATTEN_SWITCH_CTL_B1_XATTEN2_MARGIN_1_MASK                                  0x003e0000
-#define PHY_BB_EXT_ATTEN_SWITCH_CTL_B1_XATTEN2_MARGIN_1_GET(x)                (((x) & 0x003e0000) >> 17)
-#define PHY_BB_EXT_ATTEN_SWITCH_CTL_B1_XATTEN2_MARGIN_1_SET(x)                (((x) << 17) & 0x003e0000)
-
-
-#ifndef __ASSEMBLER__
-
-typedef struct bb_lc_reg_reg_s {
-  volatile char pad__0[0x9800];                                        /*        0x0 - 0x9800     */
-  volatile unsigned int BB_test_controls;                              /*     0x9800 - 0x9804     */
-  volatile unsigned int BB_gen_controls;                               /*     0x9804 - 0x9808     */
-  volatile unsigned int BB_test_controls_status;                       /*     0x9808 - 0x980c     */
-  volatile unsigned int BB_timing_controls_1;                          /*     0x980c - 0x9810     */
-  volatile unsigned int BB_timing_controls_2;                          /*     0x9810 - 0x9814     */
-  volatile unsigned int BB_timing_controls_3;                          /*     0x9814 - 0x9818     */
-  volatile unsigned int BB_D2_chip_id;                                 /*     0x9818 - 0x981c     */
-  volatile unsigned int BB_active;                                     /*     0x981c - 0x9820     */
-  volatile unsigned int BB_tx_timing_1;                                /*     0x9820 - 0x9824     */
-  volatile unsigned int BB_tx_timing_2;                                /*     0x9824 - 0x9828     */
-  volatile unsigned int BB_tx_timing_3;                                /*     0x9828 - 0x982c     */
-  volatile unsigned int BB_addac_parallel_control;                     /*     0x982c - 0x9830     */
-  volatile char pad__1[0x4];                                           /*     0x9830 - 0x9834     */
-  volatile unsigned int BB_xpa_timing_control;                         /*     0x9834 - 0x9838     */
-  volatile unsigned int BB_misc_pa_control;                            /*     0x9838 - 0x983c     */
-  volatile unsigned int BB_tstdac_constant;                            /*     0x983c - 0x9840     */
-  volatile unsigned int BB_find_signal_low;                            /*     0x9840 - 0x9844     */
-  volatile unsigned int BB_settling_time;                              /*     0x9844 - 0x9848     */
-  volatile unsigned int BB_gain_force_max_gains_b0;                    /*     0x9848 - 0x984c     */
-  volatile unsigned int BB_gains_min_offsets_b0;                       /*     0x984c - 0x9850     */
-  volatile unsigned int BB_desired_sigsize;                            /*     0x9850 - 0x9854     */
-  volatile unsigned int BB_timing_control_3a;                          /*     0x9854 - 0x9858     */
-  volatile unsigned int BB_find_signal;                                /*     0x9858 - 0x985c     */
-  volatile unsigned int BB_agc;                                        /*     0x985c - 0x9860     */
-  volatile unsigned int BB_agc_control;                                /*     0x9860 - 0x9864     */
-  volatile unsigned int BB_cca_b0;                                     /*     0x9864 - 0x9868     */
-  volatile unsigned int BB_sfcorr;                                     /*     0x9868 - 0x986c     */
-  volatile unsigned int BB_self_corr_low;                              /*     0x986c - 0x9870     */
-  volatile char pad__2[0x4];                                           /*     0x9870 - 0x9874     */
-  volatile unsigned int BB_synth_control;                              /*     0x9874 - 0x9878     */
-  volatile unsigned int BB_addac_clk_select;                           /*     0x9878 - 0x987c     */
-  volatile unsigned int BB_pll_cntl;                                   /*     0x987c - 0x9880     */
-  volatile char pad__3[0x80];                                          /*     0x9880 - 0x9900     */
-  volatile unsigned int BB_vit_spur_mask_A;                            /*     0x9900 - 0x9904     */
-  volatile unsigned int BB_vit_spur_mask_B;                            /*     0x9904 - 0x9908     */
-  volatile unsigned int BB_pilot_spur_mask;                            /*     0x9908 - 0x990c     */
-  volatile unsigned int BB_chan_spur_mask;                             /*     0x990c - 0x9910     */
-  volatile unsigned int BB_spectral_scan;                              /*     0x9910 - 0x9914     */
-  volatile unsigned int BB_analog_power_on_time;                       /*     0x9914 - 0x9918     */
-  volatile unsigned int BB_search_start_delay;                         /*     0x9918 - 0x991c     */
-  volatile unsigned int BB_max_rx_length;                              /*     0x991c - 0x9920     */
-  volatile unsigned int BB_timing_control_4;                           /*     0x9920 - 0x9924     */
-  volatile unsigned int BB_timing_control_5;                           /*     0x9924 - 0x9928     */
-  volatile unsigned int BB_phyonly_warm_reset;                         /*     0x9928 - 0x992c     */
-  volatile unsigned int BB_phyonly_control;                            /*     0x992c - 0x9930     */
-  volatile char pad__4[0x4];                                           /*     0x9930 - 0x9934     */
-  volatile unsigned int BB_powertx_rate1;                              /*     0x9934 - 0x9938     */
-  volatile unsigned int BB_powertx_rate2;                              /*     0x9938 - 0x993c     */
-  volatile unsigned int BB_powertx_max;                                /*     0x993c - 0x9940     */
-  volatile unsigned int BB_extension_radar;                            /*     0x9940 - 0x9944     */
-  volatile unsigned int BB_frame_control;                              /*     0x9944 - 0x9948     */
-  volatile unsigned int BB_timing_control_6;                           /*     0x9948 - 0x994c     */
-  volatile unsigned int BB_spur_mask_controls;                         /*     0x994c - 0x9950     */
-  volatile unsigned int BB_rx_iq_corr_b0;                              /*     0x9950 - 0x9954     */
-  volatile unsigned int BB_radar_detection;                            /*     0x9954 - 0x9958     */
-  volatile unsigned int BB_radar_detection_2;                          /*     0x9958 - 0x995c     */
-  volatile unsigned int BB_tx_phase_ramp_b0;                           /*     0x995c - 0x9960     */
-  volatile unsigned int BB_switch_table_chn_b0;                        /*     0x9960 - 0x9964     */
-  volatile unsigned int BB_switch_table_com1;                          /*     0x9964 - 0x9968     */
-  volatile unsigned int BB_cca_ctrl_2_b0;                              /*     0x9968 - 0x996c     */
-  volatile unsigned int BB_switch_table_com2;                          /*     0x996c - 0x9970     */
-  volatile unsigned int BB_restart;                                    /*     0x9970 - 0x9974     */
-  volatile char pad__5[0x4];                                           /*     0x9974 - 0x9978     */
-  volatile unsigned int BB_scrambler_seed;                             /*     0x9978 - 0x997c     */
-  volatile unsigned int BB_rfbus_request;                              /*     0x997c - 0x9980     */
-  volatile char pad__6[0x20];                                          /*     0x9980 - 0x99a0     */
-  volatile unsigned int BB_timing_control_11;                          /*     0x99a0 - 0x99a4     */
-  volatile unsigned int BB_multichain_enable;                          /*     0x99a4 - 0x99a8     */
-  volatile unsigned int BB_multichain_control;                         /*     0x99a8 - 0x99ac     */
-  volatile unsigned int BB_multichain_gain_ctrl;                       /*     0x99ac - 0x99b0     */
-  volatile char pad__7[0x4];                                           /*     0x99b0 - 0x99b4     */
-  volatile unsigned int BB_adc_gain_dc_corr_b0;                        /*     0x99b4 - 0x99b8     */
-  volatile unsigned int BB_ext_chan_pwr_thr_1;                         /*     0x99b8 - 0x99bc     */
-  volatile unsigned int BB_ext_chan_pwr_thr_2_b0;                      /*     0x99bc - 0x99c0     */
-  volatile unsigned int BB_ext_chan_scorr_thr;                         /*     0x99c0 - 0x99c4     */
-  volatile unsigned int BB_ext_chan_detect_win;                        /*     0x99c4 - 0x99c8     */
-  volatile unsigned int BB_pwr_thr_20_40_det;                          /*     0x99c8 - 0x99cc     */
-  volatile char pad__8[0x4];                                           /*     0x99cc - 0x99d0     */
-  volatile unsigned int BB_short_gi_delta_slope;                       /*     0x99d0 - 0x99d4     */
-  volatile char pad__9[0x8];                                           /*     0x99d4 - 0x99dc     */
-  volatile unsigned int BB_chaninfo_ctrl;                              /*     0x99dc - 0x99e0     */
-  volatile unsigned int BB_heavy_clip_ctrl;                            /*     0x99e0 - 0x99e4     */
-  volatile unsigned int BB_heavy_clip_20;                              /*     0x99e4 - 0x99e8     */
-  volatile unsigned int BB_heavy_clip_40;                              /*     0x99e8 - 0x99ec     */
-  volatile unsigned int BB_rifs_srch;                                  /*     0x99ec - 0x99f0     */
-  volatile unsigned int BB_iq_adc_cal_mode;                            /*     0x99f0 - 0x99f4     */
-  volatile char pad__10[0x8];                                          /*     0x99f4 - 0x99fc     */
-  volatile unsigned int BB_per_chain_csd;                              /*     0x99fc - 0x9a00     */
-  volatile unsigned int BB_rx_ocgain[128];                             /*     0x9a00 - 0x9c00     */
-  volatile unsigned int BB_tx_crc;                                     /*     0x9c00 - 0x9c04     */
-  volatile char pad__11[0xc];                                          /*     0x9c04 - 0x9c10     */
-  volatile unsigned int BB_iq_adc_meas_0_b0;                           /*     0x9c10 - 0x9c14     */
-  volatile unsigned int BB_iq_adc_meas_1_b0;                           /*     0x9c14 - 0x9c18     */
-  volatile unsigned int BB_iq_adc_meas_2_b0;                           /*     0x9c18 - 0x9c1c     */
-  volatile unsigned int BB_iq_adc_meas_3_b0;                           /*     0x9c1c - 0x9c20     */
-  volatile unsigned int BB_rfbus_grant;                                /*     0x9c20 - 0x9c24     */
-  volatile unsigned int BB_tstadc;                                     /*     0x9c24 - 0x9c28     */
-  volatile unsigned int BB_tstdac;                                     /*     0x9c28 - 0x9c2c     */
-  volatile char pad__12[0x4];                                          /*     0x9c2c - 0x9c30     */
-  volatile unsigned int BB_illegal_tx_rate;                            /*     0x9c30 - 0x9c34     */
-  volatile unsigned int BB_spur_report_b0;                             /*     0x9c34 - 0x9c38     */
-  volatile unsigned int BB_channel_status;                             /*     0x9c38 - 0x9c3c     */
-  volatile unsigned int BB_rssi_b0;                                    /*     0x9c3c - 0x9c40     */
-  volatile unsigned int BB_spur_est_cck_report_b0;                     /*     0x9c40 - 0x9c44     */
-  volatile char pad__13[0x68];                                         /*     0x9c44 - 0x9cac     */
-  volatile unsigned int BB_chan_info_noise_pwr;                        /*     0x9cac - 0x9cb0     */
-  volatile unsigned int BB_chan_info_gain_diff;                        /*     0x9cb0 - 0x9cb4     */
-  volatile unsigned int BB_chan_info_fine_timing;                      /*     0x9cb4 - 0x9cb8     */
-  volatile unsigned int BB_chan_info_gain_b0;                          /*     0x9cb8 - 0x9cbc     */
-  volatile unsigned int BB_chan_info_chan_tab_b0[60];                  /*     0x9cbc - 0x9dac     */
-  volatile char pad__14[0x38];                                         /*     0x9dac - 0x9de4     */
-  volatile unsigned int BB_paprd_am2am_mask;                           /*     0x9de4 - 0x9de8     */
-  volatile unsigned int BB_paprd_am2pm_mask;                           /*     0x9de8 - 0x9dec     */
-  volatile unsigned int BB_paprd_ht40_mask;                            /*     0x9dec - 0x9df0     */
-  volatile unsigned int BB_paprd_ctrl0;                                /*     0x9df0 - 0x9df4     */
-  volatile unsigned int BB_paprd_ctrl1;                                /*     0x9df4 - 0x9df8     */
-  volatile unsigned int BB_pa_gain123;                                 /*     0x9df8 - 0x9dfc     */
-  volatile unsigned int BB_pa_gain45;                                  /*     0x9dfc - 0x9e00     */
-  volatile unsigned int BB_paprd_pre_post_scale_0;                     /*     0x9e00 - 0x9e04     */
-  volatile unsigned int BB_paprd_pre_post_scale_1;                     /*     0x9e04 - 0x9e08     */
-  volatile unsigned int BB_paprd_pre_post_scale_2;                     /*     0x9e08 - 0x9e0c     */
-  volatile unsigned int BB_paprd_pre_post_scale_3;                     /*     0x9e0c - 0x9e10     */
-  volatile unsigned int BB_paprd_pre_post_scale_4;                     /*     0x9e10 - 0x9e14     */
-  volatile unsigned int BB_paprd_pre_post_scale_5;                     /*     0x9e14 - 0x9e18     */
-  volatile unsigned int BB_paprd_pre_post_scale_6;                     /*     0x9e18 - 0x9e1c     */
-  volatile unsigned int BB_paprd_pre_post_scale_7;                     /*     0x9e1c - 0x9e20     */
-  volatile unsigned int BB_paprd_mem_tab[120];                         /*     0x9e20 - 0xa000     */
-  volatile unsigned int BB_peak_det_ctrl_1;                            /*     0xa000 - 0xa004     */
-  volatile unsigned int BB_peak_det_ctrl_2;                            /*     0xa004 - 0xa008     */
-  volatile unsigned int BB_rx_gain_bounds_1;                           /*     0xa008 - 0xa00c     */
-  volatile unsigned int BB_rx_gain_bounds_2;                           /*     0xa00c - 0xa010     */
-  volatile unsigned int BB_peak_det_cal_ctrl;                          /*     0xa010 - 0xa014     */
-  volatile unsigned int BB_agc_dig_dc_ctrl;                            /*     0xa014 - 0xa018     */
-  volatile unsigned int BB_agc_dig_dc_status_i_b0;                     /*     0xa018 - 0xa01c     */
-  volatile unsigned int BB_agc_dig_dc_status_q_b0;                     /*     0xa01c - 0xa020     */
-  volatile char pad__15[0x1d4];                                        /*     0xa020 - 0xa1f4     */
-  volatile unsigned int BB_bbb_txfir_0;                                /*     0xa1f4 - 0xa1f8     */
-  volatile unsigned int BB_bbb_txfir_1;                                /*     0xa1f8 - 0xa1fc     */
-  volatile unsigned int BB_bbb_txfir_2;                                /*     0xa1fc - 0xa200     */
-  volatile unsigned int BB_modes_select;                               /*     0xa200 - 0xa204     */
-  volatile unsigned int BB_bbb_tx_ctrl;                                /*     0xa204 - 0xa208     */
-  volatile unsigned int BB_bbb_sig_detect;                             /*     0xa208 - 0xa20c     */
-  volatile unsigned int BB_ext_atten_switch_ctl_b0;                    /*     0xa20c - 0xa210     */
-  volatile unsigned int BB_bbb_rx_ctrl_1;                              /*     0xa210 - 0xa214     */
-  volatile unsigned int BB_bbb_rx_ctrl_2;                              /*     0xa214 - 0xa218     */
-  volatile unsigned int BB_bbb_rx_ctrl_3;                              /*     0xa218 - 0xa21c     */
-  volatile unsigned int BB_bbb_rx_ctrl_4;                              /*     0xa21c - 0xa220     */
-  volatile unsigned int BB_bbb_rx_ctrl_5;                              /*     0xa220 - 0xa224     */
-  volatile unsigned int BB_bbb_rx_ctrl_6;                              /*     0xa224 - 0xa228     */
-  volatile unsigned int BB_bbb_dagc_ctrl;                              /*     0xa228 - 0xa22c     */
-  volatile unsigned int BB_force_clken_cck;                            /*     0xa22c - 0xa230     */
-  volatile unsigned int BB_rx_clear_delay;                             /*     0xa230 - 0xa234     */
-  volatile unsigned int BB_powertx_rate3;                              /*     0xa234 - 0xa238     */
-  volatile unsigned int BB_powertx_rate4;                              /*     0xa238 - 0xa23c     */
-  volatile char pad__16[0x4];                                          /*     0xa23c - 0xa240     */
-  volatile unsigned int BB_cck_spur_mit;                               /*     0xa240 - 0xa244     */
-  volatile unsigned int BB_panic_watchdog_status;                      /*     0xa244 - 0xa248     */
-  volatile unsigned int BB_panic_watchdog_ctrl_1;                      /*     0xa248 - 0xa24c     */
-  volatile unsigned int BB_panic_watchdog_ctrl_2;                      /*     0xa24c - 0xa250     */
-  volatile unsigned int BB_iqcorr_ctrl_cck;                            /*     0xa250 - 0xa254     */
-  volatile unsigned int BB_bluetooth_cntl;                             /*     0xa254 - 0xa258     */
-  volatile unsigned int BB_tpc_1;                                      /*     0xa258 - 0xa25c     */
-  volatile unsigned int BB_tpc_2;                                      /*     0xa25c - 0xa260     */
-  volatile unsigned int BB_tpc_3;                                      /*     0xa260 - 0xa264     */
-  volatile unsigned int BB_tpc_4_b0;                                   /*     0xa264 - 0xa268     */
-  volatile unsigned int BB_analog_swap;                                /*     0xa268 - 0xa26c     */
-  volatile unsigned int BB_tpc_5_b0;                                   /*     0xa26c - 0xa270     */
-  volatile unsigned int BB_tpc_6_b0;                                   /*     0xa270 - 0xa274     */
-  volatile unsigned int BB_tpc_7;                                      /*     0xa274 - 0xa278     */
-  volatile unsigned int BB_tpc_8;                                      /*     0xa278 - 0xa27c     */
-  volatile unsigned int BB_tpc_9;                                      /*     0xa27c - 0xa280     */
-  volatile unsigned int BB_pdadc_tab_b0[32];                           /*     0xa280 - 0xa300     */
-  volatile unsigned int BB_cl_tab_b0[16];                              /*     0xa300 - 0xa340     */
-  volatile unsigned int BB_cl_map_0_b0;                                /*     0xa340 - 0xa344     */
-  volatile unsigned int BB_cl_map_1_b0;                                /*     0xa344 - 0xa348     */
-  volatile unsigned int BB_cl_map_2_b0;                                /*     0xa348 - 0xa34c     */
-  volatile unsigned int BB_cl_map_3_b0;                                /*     0xa34c - 0xa350     */
-  volatile char pad__17[0x8];                                          /*     0xa350 - 0xa358     */
-  volatile unsigned int BB_cl_cal_ctrl;                                /*     0xa358 - 0xa35c     */
-  volatile unsigned int BB_cl_map_pal_0_b0;                            /*     0xa35c - 0xa360     */
-  volatile unsigned int BB_cl_map_pal_1_b0;                            /*     0xa360 - 0xa364     */
-  volatile unsigned int BB_cl_map_pal_2_b0;                            /*     0xa364 - 0xa368     */
-  volatile unsigned int BB_cl_map_pal_3_b0;                            /*     0xa368 - 0xa36c     */
-  volatile char pad__18[0x1c];                                         /*     0xa36c - 0xa388     */
-  volatile unsigned int BB_rifs;                                       /*     0xa388 - 0xa38c     */
-  volatile unsigned int BB_powertx_rate5;                              /*     0xa38c - 0xa390     */
-  volatile unsigned int BB_powertx_rate6;                              /*     0xa390 - 0xa394     */
-  volatile unsigned int BB_tpc_10;                                     /*     0xa394 - 0xa398     */
-  volatile unsigned int BB_tpc_11_b0;                                  /*     0xa398 - 0xa39c     */
-  volatile unsigned int BB_cal_chain_mask;                             /*     0xa39c - 0xa3a0     */
-  volatile char pad__19[0x1c];                                         /*     0xa3a0 - 0xa3bc     */
-  volatile unsigned int BB_powertx_sub;                                /*     0xa3bc - 0xa3c0     */
-  volatile unsigned int BB_powertx_rate7;                              /*     0xa3c0 - 0xa3c4     */
-  volatile unsigned int BB_powertx_rate8;                              /*     0xa3c4 - 0xa3c8     */
-  volatile unsigned int BB_powertx_rate9;                              /*     0xa3c8 - 0xa3cc     */
-  volatile unsigned int BB_powertx_rate10;                             /*     0xa3cc - 0xa3d0     */
-  volatile unsigned int BB_powertx_rate11;                             /*     0xa3d0 - 0xa3d4     */
-  volatile unsigned int BB_powertx_rate12;                             /*     0xa3d4 - 0xa3d8     */
-  volatile unsigned int BB_force_analog;                               /*     0xa3d8 - 0xa3dc     */
-  volatile unsigned int BB_tpc_12;                                     /*     0xa3dc - 0xa3e0     */
-  volatile unsigned int BB_tpc_13;                                     /*     0xa3e0 - 0xa3e4     */
-  volatile unsigned int BB_tpc_14;                                     /*     0xa3e4 - 0xa3e8     */
-  volatile unsigned int BB_tpc_15;                                     /*     0xa3e8 - 0xa3ec     */
-  volatile unsigned int BB_tpc_16;                                     /*     0xa3ec - 0xa3f0     */
-  volatile unsigned int BB_tpc_17;                                     /*     0xa3f0 - 0xa3f4     */
-  volatile unsigned int BB_tpc_18;                                     /*     0xa3f4 - 0xa3f8     */
-  volatile unsigned int BB_tpc_19;                                     /*     0xa3f8 - 0xa3fc     */
-  volatile unsigned int BB_tpc_20;                                     /*     0xa3fc - 0xa400     */
-  volatile unsigned int BB_tx_gain_tab_1;                              /*     0xa400 - 0xa404     */
-  volatile unsigned int BB_tx_gain_tab_2;                              /*     0xa404 - 0xa408     */
-  volatile unsigned int BB_tx_gain_tab_3;                              /*     0xa408 - 0xa40c     */
-  volatile unsigned int BB_tx_gain_tab_4;                              /*     0xa40c - 0xa410     */
-  volatile unsigned int BB_tx_gain_tab_5;                              /*     0xa410 - 0xa414     */
-  volatile unsigned int BB_tx_gain_tab_6;                              /*     0xa414 - 0xa418     */
-  volatile unsigned int BB_tx_gain_tab_7;                              /*     0xa418 - 0xa41c     */
-  volatile unsigned int BB_tx_gain_tab_8;                              /*     0xa41c - 0xa420     */
-  volatile unsigned int BB_tx_gain_tab_9;                              /*     0xa420 - 0xa424     */
-  volatile unsigned int BB_tx_gain_tab_10;                             /*     0xa424 - 0xa428     */
-  volatile unsigned int BB_tx_gain_tab_11;                             /*     0xa428 - 0xa42c     */
-  volatile unsigned int BB_tx_gain_tab_12;                             /*     0xa42c - 0xa430     */
-  volatile unsigned int BB_tx_gain_tab_13;                             /*     0xa430 - 0xa434     */
-  volatile unsigned int BB_tx_gain_tab_14;                             /*     0xa434 - 0xa438     */
-  volatile unsigned int BB_tx_gain_tab_15;                             /*     0xa438 - 0xa43c     */
-  volatile unsigned int BB_tx_gain_tab_16;                             /*     0xa43c - 0xa440     */
-  volatile unsigned int BB_tx_gain_tab_17;                             /*     0xa440 - 0xa444     */
-  volatile unsigned int BB_tx_gain_tab_18;                             /*     0xa444 - 0xa448     */
-  volatile unsigned int BB_tx_gain_tab_19;                             /*     0xa448 - 0xa44c     */
-  volatile unsigned int BB_tx_gain_tab_20;                             /*     0xa44c - 0xa450     */
-  volatile unsigned int BB_tx_gain_tab_21;                             /*     0xa450 - 0xa454     */
-  volatile unsigned int BB_tx_gain_tab_22;                             /*     0xa454 - 0xa458     */
-  volatile unsigned int BB_tx_gain_tab_23;                             /*     0xa458 - 0xa45c     */
-  volatile unsigned int BB_tx_gain_tab_24;                             /*     0xa45c - 0xa460     */
-  volatile unsigned int BB_tx_gain_tab_25;                             /*     0xa460 - 0xa464     */
-  volatile unsigned int BB_tx_gain_tab_26;                             /*     0xa464 - 0xa468     */
-  volatile unsigned int BB_tx_gain_tab_27;                             /*     0xa468 - 0xa46c     */
-  volatile unsigned int BB_tx_gain_tab_28;                             /*     0xa46c - 0xa470     */
-  volatile unsigned int BB_tx_gain_tab_29;                             /*     0xa470 - 0xa474     */
-  volatile unsigned int BB_tx_gain_tab_30;                             /*     0xa474 - 0xa478     */
-  volatile unsigned int BB_tx_gain_tab_31;                             /*     0xa478 - 0xa47c     */
-  volatile unsigned int BB_tx_gain_tab_32;                             /*     0xa47c - 0xa480     */
-  volatile unsigned int BB_tx_gain_tab_pal_1;                          /*     0xa480 - 0xa484     */
-  volatile unsigned int BB_tx_gain_tab_pal_2;                          /*     0xa484 - 0xa488     */
-  volatile unsigned int BB_tx_gain_tab_pal_3;                          /*     0xa488 - 0xa48c     */
-  volatile unsigned int BB_tx_gain_tab_pal_4;                          /*     0xa48c - 0xa490     */
-  volatile unsigned int BB_tx_gain_tab_pal_5;                          /*     0xa490 - 0xa494     */
-  volatile unsigned int BB_tx_gain_tab_pal_6;                          /*     0xa494 - 0xa498     */
-  volatile unsigned int BB_tx_gain_tab_pal_7;                          /*     0xa498 - 0xa49c     */
-  volatile unsigned int BB_tx_gain_tab_pal_8;                          /*     0xa49c - 0xa4a0     */
-  volatile unsigned int BB_tx_gain_tab_pal_9;                          /*     0xa4a0 - 0xa4a4     */
-  volatile unsigned int BB_tx_gain_tab_pal_10;                         /*     0xa4a4 - 0xa4a8     */
-  volatile unsigned int BB_tx_gain_tab_pal_11;                         /*     0xa4a8 - 0xa4ac     */
-  volatile unsigned int BB_tx_gain_tab_pal_12;                         /*     0xa4ac - 0xa4b0     */
-  volatile unsigned int BB_tx_gain_tab_pal_13;                         /*     0xa4b0 - 0xa4b4     */
-  volatile unsigned int BB_tx_gain_tab_pal_14;                         /*     0xa4b4 - 0xa4b8     */
-  volatile unsigned int BB_tx_gain_tab_pal_15;                         /*     0xa4b8 - 0xa4bc     */
-  volatile unsigned int BB_tx_gain_tab_pal_16;                         /*     0xa4bc - 0xa4c0     */
-  volatile unsigned int BB_tx_gain_tab_pal_17;                         /*     0xa4c0 - 0xa4c4     */
-  volatile unsigned int BB_tx_gain_tab_pal_18;                         /*     0xa4c4 - 0xa4c8     */
-  volatile unsigned int BB_tx_gain_tab_pal_19;                         /*     0xa4c8 - 0xa4cc     */
-  volatile unsigned int BB_tx_gain_tab_pal_20;                         /*     0xa4cc - 0xa4d0     */
-  volatile unsigned int BB_tx_gain_tab_pal_21;                         /*     0xa4d0 - 0xa4d4     */
-  volatile unsigned int BB_tx_gain_tab_pal_22;                         /*     0xa4d4 - 0xa4d8     */
-  volatile unsigned int BB_tx_gain_tab_pal_23;                         /*     0xa4d8 - 0xa4dc     */
-  volatile unsigned int BB_tx_gain_tab_pal_24;                         /*     0xa4dc - 0xa4e0     */
-  volatile unsigned int BB_tx_gain_tab_pal_25;                         /*     0xa4e0 - 0xa4e4     */
-  volatile unsigned int BB_tx_gain_tab_pal_26;                         /*     0xa4e4 - 0xa4e8     */
-  volatile unsigned int BB_tx_gain_tab_pal_27;                         /*     0xa4e8 - 0xa4ec     */
-  volatile unsigned int BB_tx_gain_tab_pal_28;                         /*     0xa4ec - 0xa4f0     */
-  volatile unsigned int BB_tx_gain_tab_pal_29;                         /*     0xa4f0 - 0xa4f4     */
-  volatile unsigned int BB_tx_gain_tab_pal_30;                         /*     0xa4f4 - 0xa4f8     */
-  volatile unsigned int BB_tx_gain_tab_pal_31;                         /*     0xa4f8 - 0xa4fc     */
-  volatile unsigned int BB_tx_gain_tab_pal_32;                         /*     0xa4fc - 0xa500     */
-  volatile char pad__20[0x18];                                         /*     0xa500 - 0xa518     */
-  volatile unsigned int BB_caltx_gain_set_0;                           /*     0xa518 - 0xa51c     */
-  volatile unsigned int BB_caltx_gain_set_2;                           /*     0xa51c - 0xa520     */
-  volatile unsigned int BB_caltx_gain_set_4;                           /*     0xa520 - 0xa524     */
-  volatile unsigned int BB_caltx_gain_set_6;                           /*     0xa524 - 0xa528     */
-  volatile unsigned int BB_caltx_gain_set_8;                           /*     0xa528 - 0xa52c     */
-  volatile unsigned int BB_caltx_gain_set_10;                          /*     0xa52c - 0xa530     */
-  volatile unsigned int BB_caltx_gain_set_12;                          /*     0xa530 - 0xa534     */
-  volatile unsigned int BB_caltx_gain_set_14;                          /*     0xa534 - 0xa538     */
-  volatile unsigned int BB_caltx_gain_set_16;                          /*     0xa538 - 0xa53c     */
-  volatile unsigned int BB_caltx_gain_set_18;                          /*     0xa53c - 0xa540     */
-  volatile unsigned int BB_caltx_gain_set_20;                          /*     0xa540 - 0xa544     */
-  volatile unsigned int BB_caltx_gain_set_22;                          /*     0xa544 - 0xa548     */
-  volatile unsigned int BB_caltx_gain_set_24;                          /*     0xa548 - 0xa54c     */
-  volatile unsigned int BB_caltx_gain_set_26;                          /*     0xa54c - 0xa550     */
-  volatile unsigned int BB_caltx_gain_set_28;                          /*     0xa550 - 0xa554     */
-  volatile unsigned int BB_caltx_gain_set_30;                          /*     0xa554 - 0xa558     */
-  volatile unsigned int BB_txiqcal_meas_b0[96];                        /*     0xa558 - 0xa6d8     */
-  volatile unsigned int BB_txiqcal_start;                              /*     0xa6d8 - 0xa6dc     */
-  volatile unsigned int BB_txiqcal_control_0;                          /*     0xa6dc - 0xa6e0     */
-  volatile unsigned int BB_txiqcal_control_1;                          /*     0xa6e0 - 0xa6e4     */
-  volatile unsigned int BB_txiqcal_control_2;                          /*     0xa6e4 - 0xa6e8     */
-  volatile unsigned int BB_txiqcal_control_3;                          /*     0xa6e8 - 0xa6ec     */
-  volatile unsigned int BB_txiq_corr_coeff_01_b0;                      /*     0xa6ec - 0xa6f0     */
-  volatile unsigned int BB_txiq_corr_coeff_23_b0;                      /*     0xa6f0 - 0xa6f4     */
-  volatile unsigned int BB_txiq_corr_coeff_45_b0;                      /*     0xa6f4 - 0xa6f8     */
-  volatile unsigned int BB_txiq_corr_coeff_67_b0;                      /*     0xa6f8 - 0xa6fc     */
-  volatile unsigned int BB_txiq_corr_coeff_89_b0;                      /*     0xa6fc - 0xa700     */
-  volatile unsigned int BB_txiq_corr_coeff_ab_b0;                      /*     0xa700 - 0xa704     */
-  volatile unsigned int BB_txiq_corr_coeff_cd_b0;                      /*     0xa704 - 0xa708     */
-  volatile unsigned int BB_txiq_corr_coeff_ef_b0;                      /*     0xa708 - 0xa70c     */
-  volatile unsigned int BB_cal_rxbb_gain_tbl_0;                        /*     0xa70c - 0xa710     */
-  volatile unsigned int BB_cal_rxbb_gain_tbl_4;                        /*     0xa710 - 0xa714     */
-  volatile unsigned int BB_cal_rxbb_gain_tbl_8;                        /*     0xa714 - 0xa718     */
-  volatile unsigned int BB_cal_rxbb_gain_tbl_12;                       /*     0xa718 - 0xa71c     */
-  volatile unsigned int BB_cal_rxbb_gain_tbl_16;                       /*     0xa71c - 0xa720     */
-  volatile unsigned int BB_cal_rxbb_gain_tbl_20;                       /*     0xa720 - 0xa724     */
-  volatile unsigned int BB_cal_rxbb_gain_tbl_24;                       /*     0xa724 - 0xa728     */
-  volatile unsigned int BB_txiqcal_status_b0;                          /*     0xa728 - 0xa72c     */
-  volatile unsigned int BB_paprd_trainer_cntl1;                        /*     0xa72c - 0xa730     */
-  volatile unsigned int BB_paprd_trainer_cntl2;                        /*     0xa730 - 0xa734     */
-  volatile unsigned int BB_paprd_trainer_cntl3;                        /*     0xa734 - 0xa738     */
-  volatile unsigned int BB_paprd_trainer_cntl4;                        /*     0xa738 - 0xa73c     */
-  volatile unsigned int BB_paprd_trainer_stat1;                        /*     0xa73c - 0xa740     */
-  volatile unsigned int BB_paprd_trainer_stat2;                        /*     0xa740 - 0xa744     */
-  volatile unsigned int BB_paprd_trainer_stat3;                        /*     0xa744 - 0xa748     */
-  volatile char pad__21[0x90];                                         /*     0xa748 - 0xa7d8     */
-  volatile unsigned int BB_fcal_1;                                     /*     0xa7d8 - 0xa7dc     */
-  volatile unsigned int BB_fcal_2_b0;                                  /*     0xa7dc - 0xa7e0     */
-  volatile unsigned int BB_radar_bw_filter;                            /*     0xa7e0 - 0xa7e4     */
-  volatile unsigned int BB_dft_tone_ctrl_b0;                           /*     0xa7e4 - 0xa7e8     */
-  volatile unsigned int BB_therm_adc_1;                                /*     0xa7e8 - 0xa7ec     */
-  volatile unsigned int BB_therm_adc_2;                                /*     0xa7ec - 0xa7f0     */
-  volatile unsigned int BB_therm_adc_3;                                /*     0xa7f0 - 0xa7f4     */
-  volatile unsigned int BB_therm_adc_4;                                /*     0xa7f4 - 0xa7f8     */
-  volatile unsigned int BB_tx_forced_gain;                             /*     0xa7f8 - 0xa7fc     */
-  volatile unsigned int BB_eco_ctrl;                                   /*     0xa7fc - 0xa800     */
-  volatile char pad__22[0x48];                                         /*     0xa800 - 0xa848     */
-  volatile unsigned int BB_gain_force_max_gains_b1;                    /*     0xa848 - 0xa84c     */
-  volatile unsigned int BB_gains_min_offsets_b1;                       /*     0xa84c - 0xa850     */
-  volatile char pad__23[0x1b0];                                        /*     0xa850 - 0xaa00     */
-  volatile unsigned int BB_rx_ocgain2[128];                            /*     0xaa00 - 0xac00     */
-  volatile char pad__24[0x60c];                                        /*     0xac00 - 0xb20c     */
-  volatile unsigned int BB_ext_atten_switch_ctl_b1;                    /*     0xb20c - 0xb210     */
-} bb_lc_reg_reg_t;
-
-#endif /* __ASSEMBLER__ */
-
-#endif /* _BB_LC_REG_REG_H_ */
diff --git a/drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/efuse_reg.h b/drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/efuse_reg.h
deleted file mode 100644 (file)
index 12cadb3..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-// ------------------------------------------------------------------
-// Copyright (c) 2004-2010 Atheros Corporation.  All rights reserved.
-// 
-//
-// Permission to use, copy, modify, and/or distribute this software for any
-// purpose with or without fee is hereby granted, provided that the above
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-//
-//
-// ------------------------------------------------------------------
-//===================================================================
-// Author(s): ="Atheros"
-//===================================================================
-
-
-#ifndef _EFUSE_REG_REG_H_
-#define _EFUSE_REG_REG_H_
-
-#define EFUSE_WR_ENABLE_REG_ADDRESS              0x00000000
-#define EFUSE_WR_ENABLE_REG_OFFSET               0x00000000
-#define EFUSE_WR_ENABLE_REG_V_MSB                0
-#define EFUSE_WR_ENABLE_REG_V_LSB                0
-#define EFUSE_WR_ENABLE_REG_V_MASK               0x00000001
-#define EFUSE_WR_ENABLE_REG_V_GET(x)             (((x) & EFUSE_WR_ENABLE_REG_V_MASK) >> EFUSE_WR_ENABLE_REG_V_LSB)
-#define EFUSE_WR_ENABLE_REG_V_SET(x)             (((x) << EFUSE_WR_ENABLE_REG_V_LSB) & EFUSE_WR_ENABLE_REG_V_MASK)
-
-#define EFUSE_INT_ENABLE_REG_ADDRESS             0x00000004
-#define EFUSE_INT_ENABLE_REG_OFFSET              0x00000004
-#define EFUSE_INT_ENABLE_REG_V_MSB               0
-#define EFUSE_INT_ENABLE_REG_V_LSB               0
-#define EFUSE_INT_ENABLE_REG_V_MASK              0x00000001
-#define EFUSE_INT_ENABLE_REG_V_GET(x)            (((x) & EFUSE_INT_ENABLE_REG_V_MASK) >> EFUSE_INT_ENABLE_REG_V_LSB)
-#define EFUSE_INT_ENABLE_REG_V_SET(x)            (((x) << EFUSE_INT_ENABLE_REG_V_LSB) & EFUSE_INT_ENABLE_REG_V_MASK)
-
-#define EFUSE_INT_STATUS_REG_ADDRESS             0x00000008
-#define EFUSE_INT_STATUS_REG_OFFSET              0x00000008
-#define EFUSE_INT_STATUS_REG_V_MSB               0
-#define EFUSE_INT_STATUS_REG_V_LSB               0
-#define EFUSE_INT_STATUS_REG_V_MASK              0x00000001
-#define EFUSE_INT_STATUS_REG_V_GET(x)            (((x) & EFUSE_INT_STATUS_REG_V_MASK) >> EFUSE_INT_STATUS_REG_V_LSB)
-#define EFUSE_INT_STATUS_REG_V_SET(x)            (((x) << EFUSE_INT_STATUS_REG_V_LSB) & EFUSE_INT_STATUS_REG_V_MASK)
-
-#define BITMASK_WR_REG_ADDRESS                   0x0000000c
-#define BITMASK_WR_REG_OFFSET                    0x0000000c
-#define BITMASK_WR_REG_V_MSB                     31
-#define BITMASK_WR_REG_V_LSB                     0
-#define BITMASK_WR_REG_V_MASK                    0xffffffff
-#define BITMASK_WR_REG_V_GET(x)                  (((x) & BITMASK_WR_REG_V_MASK) >> BITMASK_WR_REG_V_LSB)
-#define BITMASK_WR_REG_V_SET(x)                  (((x) << BITMASK_WR_REG_V_LSB) & BITMASK_WR_REG_V_MASK)
-
-#define VDDQ_SETTLE_TIME_REG_ADDRESS             0x00000010
-#define VDDQ_SETTLE_TIME_REG_OFFSET              0x00000010
-#define VDDQ_SETTLE_TIME_REG_V_MSB               31
-#define VDDQ_SETTLE_TIME_REG_V_LSB               0
-#define VDDQ_SETTLE_TIME_REG_V_MASK              0xffffffff
-#define VDDQ_SETTLE_TIME_REG_V_GET(x)            (((x) & VDDQ_SETTLE_TIME_REG_V_MASK) >> VDDQ_SETTLE_TIME_REG_V_LSB)
-#define VDDQ_SETTLE_TIME_REG_V_SET(x)            (((x) << VDDQ_SETTLE_TIME_REG_V_LSB) & VDDQ_SETTLE_TIME_REG_V_MASK)
-
-#define RD_STROBE_PW_REG_ADDRESS                 0x00000014
-#define RD_STROBE_PW_REG_OFFSET                  0x00000014
-#define RD_STROBE_PW_REG_V_MSB                   31
-#define RD_STROBE_PW_REG_V_LSB                   0
-#define RD_STROBE_PW_REG_V_MASK                  0xffffffff
-#define RD_STROBE_PW_REG_V_GET(x)                (((x) & RD_STROBE_PW_REG_V_MASK) >> RD_STROBE_PW_REG_V_LSB)
-#define RD_STROBE_PW_REG_V_SET(x)                (((x) << RD_STROBE_PW_REG_V_LSB) & RD_STROBE_PW_REG_V_MASK)
-
-#define PG_STROBE_PW_REG_ADDRESS                 0x00000018
-#define PG_STROBE_PW_REG_OFFSET                  0x00000018
-#define PG_STROBE_PW_REG_V_MSB                   31
-#define PG_STROBE_PW_REG_V_LSB                   0
-#define PG_STROBE_PW_REG_V_MASK                  0xffffffff
-#define PG_STROBE_PW_REG_V_GET(x)                (((x) & PG_STROBE_PW_REG_V_MASK) >> PG_STROBE_PW_REG_V_LSB)
-#define PG_STROBE_PW_REG_V_SET(x)                (((x) << PG_STROBE_PW_REG_V_LSB) & PG_STROBE_PW_REG_V_MASK)
-
-#define EFUSE_INTF_ADDRESS                       0x00000800
-#define EFUSE_INTF_OFFSET                        0x00000800
-#define EFUSE_INTF_R_MSB                         31
-#define EFUSE_INTF_R_LSB                         0
-#define EFUSE_INTF_R_MASK                        0xffffffff
-#define EFUSE_INTF_R_GET(x)                      (((x) & EFUSE_INTF_R_MASK) >> EFUSE_INTF_R_LSB)
-#define EFUSE_INTF_R_SET(x)                      (((x) << EFUSE_INTF_R_LSB) & EFUSE_INTF_R_MASK)
-
-
-#ifndef __ASSEMBLER__
-
-typedef struct efuse_reg_reg_s {
-  volatile unsigned int efuse_wr_enable_reg;
-  volatile unsigned int efuse_int_enable_reg;
-  volatile unsigned int efuse_int_status_reg;
-  volatile unsigned int bitmask_wr_reg;
-  volatile unsigned int vddq_settle_time_reg;
-  volatile unsigned int rd_strobe_pw_reg;
-  volatile unsigned int pg_strobe_pw_reg;
-  unsigned char pad0[2020]; /* pad to 0x800 */
-  volatile unsigned int efuse_intf[512];
-} efuse_reg_reg_t;
-
-#endif /* __ASSEMBLER__ */
-
-#endif /* _EFUSE_REG_H_ */
diff --git a/drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/gpio_athr_wlan_reg.h b/drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/gpio_athr_wlan_reg.h
deleted file mode 100644 (file)
index 1adee70..0000000
+++ /dev/null
@@ -1,1253 +0,0 @@
-// ------------------------------------------------------------------
-// Copyright (c) 2004-2010 Atheros Corporation.  All rights reserved.
-// 
-//
-// Permission to use, copy, modify, and/or distribute this software for any
-// purpose with or without fee is hereby granted, provided that the above
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-//
-//
-// ------------------------------------------------------------------
-//===================================================================
-// Author(s): ="Atheros"
-//===================================================================
-
-
-#ifndef _GPIO_ATHR_WLAN_REG_REG_H_
-#define _GPIO_ATHR_WLAN_REG_REG_H_
-
-#define WLAN_GPIO_OUT_ADDRESS                    0x00000000
-#define WLAN_GPIO_OUT_OFFSET                     0x00000000
-#define WLAN_GPIO_OUT_DATA_MSB                   25
-#define WLAN_GPIO_OUT_DATA_LSB                   0
-#define WLAN_GPIO_OUT_DATA_MASK                  0x03ffffff
-#define WLAN_GPIO_OUT_DATA_GET(x)                (((x) & WLAN_GPIO_OUT_DATA_MASK) >> WLAN_GPIO_OUT_DATA_LSB)
-#define WLAN_GPIO_OUT_DATA_SET(x)                (((x) << WLAN_GPIO_OUT_DATA_LSB) & WLAN_GPIO_OUT_DATA_MASK)
-
-#define WLAN_GPIO_OUT_W1TS_ADDRESS               0x00000004
-#define WLAN_GPIO_OUT_W1TS_OFFSET                0x00000004
-#define WLAN_GPIO_OUT_W1TS_DATA_MSB              25
-#define WLAN_GPIO_OUT_W1TS_DATA_LSB              0
-#define WLAN_GPIO_OUT_W1TS_DATA_MASK             0x03ffffff
-#define WLAN_GPIO_OUT_W1TS_DATA_GET(x)           (((x) & WLAN_GPIO_OUT_W1TS_DATA_MASK) >> WLAN_GPIO_OUT_W1TS_DATA_LSB)
-#define WLAN_GPIO_OUT_W1TS_DATA_SET(x)           (((x) << WLAN_GPIO_OUT_W1TS_DATA_LSB) & WLAN_GPIO_OUT_W1TS_DATA_MASK)
-
-#define WLAN_GPIO_OUT_W1TC_ADDRESS               0x00000008
-#define WLAN_GPIO_OUT_W1TC_OFFSET                0x00000008
-#define WLAN_GPIO_OUT_W1TC_DATA_MSB              25
-#define WLAN_GPIO_OUT_W1TC_DATA_LSB              0
-#define WLAN_GPIO_OUT_W1TC_DATA_MASK             0x03ffffff
-#define WLAN_GPIO_OUT_W1TC_DATA_GET(x)           (((x) & WLAN_GPIO_OUT_W1TC_DATA_MASK) >> WLAN_GPIO_OUT_W1TC_DATA_LSB)
-#define WLAN_GPIO_OUT_W1TC_DATA_SET(x)           (((x) << WLAN_GPIO_OUT_W1TC_DATA_LSB) & WLAN_GPIO_OUT_W1TC_DATA_MASK)
-
-#define WLAN_GPIO_ENABLE_ADDRESS                 0x0000000c
-#define WLAN_GPIO_ENABLE_OFFSET                  0x0000000c
-#define WLAN_GPIO_ENABLE_DATA_MSB                25
-#define WLAN_GPIO_ENABLE_DATA_LSB                0
-#define WLAN_GPIO_ENABLE_DATA_MASK               0x03ffffff
-#define WLAN_GPIO_ENABLE_DATA_GET(x)             (((x) & WLAN_GPIO_ENABLE_DATA_MASK) >> WLAN_GPIO_ENABLE_DATA_LSB)
-#define WLAN_GPIO_ENABLE_DATA_SET(x)             (((x) << WLAN_GPIO_ENABLE_DATA_LSB) & WLAN_GPIO_ENABLE_DATA_MASK)
-
-#define WLAN_GPIO_ENABLE_W1TS_ADDRESS            0x00000010
-#define WLAN_GPIO_ENABLE_W1TS_OFFSET             0x00000010
-#define WLAN_GPIO_ENABLE_W1TS_DATA_MSB           25
-#define WLAN_GPIO_ENABLE_W1TS_DATA_LSB           0
-#define WLAN_GPIO_ENABLE_W1TS_DATA_MASK          0x03ffffff
-#define WLAN_GPIO_ENABLE_W1TS_DATA_GET(x)        (((x) & WLAN_GPIO_ENABLE_W1TS_DATA_MASK) >> WLAN_GPIO_ENABLE_W1TS_DATA_LSB)
-#define WLAN_GPIO_ENABLE_W1TS_DATA_SET(x)        (((x) << WLAN_GPIO_ENABLE_W1TS_DATA_LSB) & WLAN_GPIO_ENABLE_W1TS_DATA_MASK)
-
-#define WLAN_GPIO_ENABLE_W1TC_ADDRESS            0x00000014
-#define WLAN_GPIO_ENABLE_W1TC_OFFSET             0x00000014
-#define WLAN_GPIO_ENABLE_W1TC_DATA_MSB           25
-#define WLAN_GPIO_ENABLE_W1TC_DATA_LSB           0
-#define WLAN_GPIO_ENABLE_W1TC_DATA_MASK          0x03ffffff
-#define WLAN_GPIO_ENABLE_W1TC_DATA_GET(x)        (((x) & WLAN_GPIO_ENABLE_W1TC_DATA_MASK) >> WLAN_GPIO_ENABLE_W1TC_DATA_LSB)
-#define WLAN_GPIO_ENABLE_W1TC_DATA_SET(x)        (((x) << WLAN_GPIO_ENABLE_W1TC_DATA_LSB) & WLAN_GPIO_ENABLE_W1TC_DATA_MASK)
-
-#define WLAN_GPIO_IN_ADDRESS                     0x00000018
-#define WLAN_GPIO_IN_OFFSET                      0x00000018
-#define WLAN_GPIO_IN_DATA_MSB                    25
-#define WLAN_GPIO_IN_DATA_LSB                    0
-#define WLAN_GPIO_IN_DATA_MASK                   0x03ffffff
-#define WLAN_GPIO_IN_DATA_GET(x)                 (((x) & WLAN_GPIO_IN_DATA_MASK) >> WLAN_GPIO_IN_DATA_LSB)
-#define WLAN_GPIO_IN_DATA_SET(x)                 (((x) << WLAN_GPIO_IN_DATA_LSB) & WLAN_GPIO_IN_DATA_MASK)
-
-#define WLAN_GPIO_STATUS_ADDRESS                 0x0000001c
-#define WLAN_GPIO_STATUS_OFFSET                  0x0000001c
-#define WLAN_GPIO_STATUS_INTERRUPT_MSB           25
-#define WLAN_GPIO_STATUS_INTERRUPT_LSB           0
-#define WLAN_GPIO_STATUS_INTERRUPT_MASK          0x03ffffff
-#define WLAN_GPIO_STATUS_INTERRUPT_GET(x)        (((x) & WLAN_GPIO_STATUS_INTERRUPT_MASK) >> WLAN_GPIO_STATUS_INTERRUPT_LSB)
-#define WLAN_GPIO_STATUS_INTERRUPT_SET(x)        (((x) << WLAN_GPIO_STATUS_INTERRUPT_LSB) & WLAN_GPIO_STATUS_INTERRUPT_MASK)
-
-#define WLAN_GPIO_STATUS_W1TS_ADDRESS            0x00000020
-#define WLAN_GPIO_STATUS_W1TS_OFFSET             0x00000020
-#define WLAN_GPIO_STATUS_W1TS_INTERRUPT_MSB      25
-#define WLAN_GPIO_STATUS_W1TS_INTERRUPT_LSB      0
-#define WLAN_GPIO_STATUS_W1TS_INTERRUPT_MASK     0x03ffffff
-#define WLAN_GPIO_STATUS_W1TS_INTERRUPT_GET(x)   (((x) & WLAN_GPIO_STATUS_W1TS_INTERRUPT_MASK) >> WLAN_GPIO_STATUS_W1TS_INTERRUPT_LSB)
-#define WLAN_GPIO_STATUS_W1TS_INTERRUPT_SET(x)   (((x) << WLAN_GPIO_STATUS_W1TS_INTERRUPT_LSB) & WLAN_GPIO_STATUS_W1TS_INTERRUPT_MASK)
-
-#define WLAN_GPIO_STATUS_W1TC_ADDRESS            0x00000024
-#define WLAN_GPIO_STATUS_W1TC_OFFSET             0x00000024
-#define WLAN_GPIO_STATUS_W1TC_INTERRUPT_MSB      25
-#define WLAN_GPIO_STATUS_W1TC_INTERRUPT_LSB      0
-#define WLAN_GPIO_STATUS_W1TC_INTERRUPT_MASK     0x03ffffff
-#define WLAN_GPIO_STATUS_W1TC_INTERRUPT_GET(x)   (((x) & WLAN_GPIO_STATUS_W1TC_INTERRUPT_MASK) >> WLAN_GPIO_STATUS_W1TC_INTERRUPT_LSB)
-#define WLAN_GPIO_STATUS_W1TC_INTERRUPT_SET(x)   (((x) << WLAN_GPIO_STATUS_W1TC_INTERRUPT_LSB) & WLAN_GPIO_STATUS_W1TC_INTERRUPT_MASK)
-
-#define WLAN_GPIO_PIN0_ADDRESS                   0x00000028
-#define WLAN_GPIO_PIN0_OFFSET                    0x00000028
-#define WLAN_GPIO_PIN0_CONFIG_MSB                13
-#define WLAN_GPIO_PIN0_CONFIG_LSB                11
-#define WLAN_GPIO_PIN0_CONFIG_MASK               0x00003800
-#define WLAN_GPIO_PIN0_CONFIG_GET(x)             (((x) & WLAN_GPIO_PIN0_CONFIG_MASK) >> WLAN_GPIO_PIN0_CONFIG_LSB)
-#define WLAN_GPIO_PIN0_CONFIG_SET(x)             (((x) << WLAN_GPIO_PIN0_CONFIG_LSB) & WLAN_GPIO_PIN0_CONFIG_MASK)
-#define WLAN_GPIO_PIN0_WAKEUP_ENABLE_MSB         10
-#define WLAN_GPIO_PIN0_WAKEUP_ENABLE_LSB         10
-#define WLAN_GPIO_PIN0_WAKEUP_ENABLE_MASK        0x00000400
-#define WLAN_GPIO_PIN0_WAKEUP_ENABLE_GET(x)      (((x) & WLAN_GPIO_PIN0_WAKEUP_ENABLE_MASK) >> WLAN_GPIO_PIN0_WAKEUP_ENABLE_LSB)
-#define WLAN_GPIO_PIN0_WAKEUP_ENABLE_SET(x)      (((x) << WLAN_GPIO_PIN0_WAKEUP_ENABLE_LSB) & WLAN_GPIO_PIN0_WAKEUP_ENABLE_MASK)
-#define WLAN_GPIO_PIN0_INT_TYPE_MSB              9
-#define WLAN_GPIO_PIN0_INT_TYPE_LSB              7
-#define WLAN_GPIO_PIN0_INT_TYPE_MASK             0x00000380
-#define WLAN_GPIO_PIN0_INT_TYPE_GET(x)           (((x) & WLAN_GPIO_PIN0_INT_TYPE_MASK) >> WLAN_GPIO_PIN0_INT_TYPE_LSB)
-#define WLAN_GPIO_PIN0_INT_TYPE_SET(x)           (((x) << WLAN_GPIO_PIN0_INT_TYPE_LSB) & WLAN_GPIO_PIN0_INT_TYPE_MASK)
-#define WLAN_GPIO_PIN0_PAD_PULL_MSB              6
-#define WLAN_GPIO_PIN0_PAD_PULL_LSB              5
-#define WLAN_GPIO_PIN0_PAD_PULL_MASK             0x00000060
-#define WLAN_GPIO_PIN0_PAD_PULL_GET(x)           (((x) & WLAN_GPIO_PIN0_PAD_PULL_MASK) >> WLAN_GPIO_PIN0_PAD_PULL_LSB)
-#define WLAN_GPIO_PIN0_PAD_PULL_SET(x)           (((x) << WLAN_GPIO_PIN0_PAD_PULL_LSB) & WLAN_GPIO_PIN0_PAD_PULL_MASK)
-#define WLAN_GPIO_PIN0_PAD_STRENGTH_MSB          4
-#define WLAN_GPIO_PIN0_PAD_STRENGTH_LSB          3
-#define WLAN_GPIO_PIN0_PAD_STRENGTH_MASK         0x00000018
-#define WLAN_GPIO_PIN0_PAD_STRENGTH_GET(x)       (((x) & WLAN_GPIO_PIN0_PAD_STRENGTH_MASK) >> WLAN_GPIO_PIN0_PAD_STRENGTH_LSB)
-#define WLAN_GPIO_PIN0_PAD_STRENGTH_SET(x)       (((x) << WLAN_GPIO_PIN0_PAD_STRENGTH_LSB) & WLAN_GPIO_PIN0_PAD_STRENGTH_MASK)
-#define WLAN_GPIO_PIN0_PAD_DRIVER_MSB            2
-#define WLAN_GPIO_PIN0_PAD_DRIVER_LSB            2
-#define WLAN_GPIO_PIN0_PAD_DRIVER_MASK           0x00000004
-#define WLAN_GPIO_PIN0_PAD_DRIVER_GET(x)         (((x) & WLAN_GPIO_PIN0_PAD_DRIVER_MASK) >> WLAN_GPIO_PIN0_PAD_DRIVER_LSB)
-#define WLAN_GPIO_PIN0_PAD_DRIVER_SET(x)         (((x) << WLAN_GPIO_PIN0_PAD_DRIVER_LSB) & WLAN_GPIO_PIN0_PAD_DRIVER_MASK)
-#define WLAN_GPIO_PIN0_SOURCE_MSB                0
-#define WLAN_GPIO_PIN0_SOURCE_LSB                0
-#define WLAN_GPIO_PIN0_SOURCE_MASK               0x00000001
-#define WLAN_GPIO_PIN0_SOURCE_GET(x)             (((x) & WLAN_GPIO_PIN0_SOURCE_MASK) >> WLAN_GPIO_PIN0_SOURCE_LSB)
-#define WLAN_GPIO_PIN0_SOURCE_SET(x)             (((x) << WLAN_GPIO_PIN0_SOURCE_LSB) & WLAN_GPIO_PIN0_SOURCE_MASK)
-
-#define WLAN_GPIO_PIN1_ADDRESS                   0x0000002c
-#define WLAN_GPIO_PIN1_OFFSET                    0x0000002c
-#define WLAN_GPIO_PIN1_CONFIG_MSB                13
-#define WLAN_GPIO_PIN1_CONFIG_LSB                11
-#define WLAN_GPIO_PIN1_CONFIG_MASK               0x00003800
-#define WLAN_GPIO_PIN1_CONFIG_GET(x)             (((x) & WLAN_GPIO_PIN1_CONFIG_MASK) >> WLAN_GPIO_PIN1_CONFIG_LSB)
-#define WLAN_GPIO_PIN1_CONFIG_SET(x)             (((x) << WLAN_GPIO_PIN1_CONFIG_LSB) & WLAN_GPIO_PIN1_CONFIG_MASK)
-#define WLAN_GPIO_PIN1_WAKEUP_ENABLE_MSB         10
-#define WLAN_GPIO_PIN1_WAKEUP_ENABLE_LSB         10
-#define WLAN_GPIO_PIN1_WAKEUP_ENABLE_MASK        0x00000400
-#define WLAN_GPIO_PIN1_WAKEUP_ENABLE_GET(x)      (((x) & WLAN_GPIO_PIN1_WAKEUP_ENABLE_MASK) >> WLAN_GPIO_PIN1_WAKEUP_ENABLE_LSB)
-#define WLAN_GPIO_PIN1_WAKEUP_ENABLE_SET(x)      (((x) << WLAN_GPIO_PIN1_WAKEUP_ENABLE_LSB) & WLAN_GPIO_PIN1_WAKEUP_ENABLE_MASK)
-#define WLAN_GPIO_PIN1_INT_TYPE_MSB              9
-#define WLAN_GPIO_PIN1_INT_TYPE_LSB              7
-#define WLAN_GPIO_PIN1_INT_TYPE_MASK             0x00000380
-#define WLAN_GPIO_PIN1_INT_TYPE_GET(x)           (((x) & WLAN_GPIO_PIN1_INT_TYPE_MASK) >> WLAN_GPIO_PIN1_INT_TYPE_LSB)
-#define WLAN_GPIO_PIN1_INT_TYPE_SET(x)           (((x) << WLAN_GPIO_PIN1_INT_TYPE_LSB) & WLAN_GPIO_PIN1_INT_TYPE_MASK)
-#define WLAN_GPIO_PIN1_PAD_PULL_MSB              6
-#define WLAN_GPIO_PIN1_PAD_PULL_LSB              5
-#define WLAN_GPIO_PIN1_PAD_PULL_MASK             0x00000060
-#define WLAN_GPIO_PIN1_PAD_PULL_GET(x)           (((x) & WLAN_GPIO_PIN1_PAD_PULL_MASK) >> WLAN_GPIO_PIN1_PAD_PULL_LSB)
-#define WLAN_GPIO_PIN1_PAD_PULL_SET(x)           (((x) << WLAN_GPIO_PIN1_PAD_PULL_LSB) & WLAN_GPIO_PIN1_PAD_PULL_MASK)
-#define WLAN_GPIO_PIN1_PAD_STRENGTH_MSB          4
-#define WLAN_GPIO_PIN1_PAD_STRENGTH_LSB          3
-#define WLAN_GPIO_PIN1_PAD_STRENGTH_MASK         0x00000018
-#define WLAN_GPIO_PIN1_PAD_STRENGTH_GET(x)       (((x) & WLAN_GPIO_PIN1_PAD_STRENGTH_MASK) >> WLAN_GPIO_PIN1_PAD_STRENGTH_LSB)
-#define WLAN_GPIO_PIN1_PAD_STRENGTH_SET(x)       (((x) << WLAN_GPIO_PIN1_PAD_STRENGTH_LSB) & WLAN_GPIO_PIN1_PAD_STRENGTH_MASK)
-#define WLAN_GPIO_PIN1_PAD_DRIVER_MSB            2
-#define WLAN_GPIO_PIN1_PAD_DRIVER_LSB            2
-#define WLAN_GPIO_PIN1_PAD_DRIVER_MASK           0x00000004
-#define WLAN_GPIO_PIN1_PAD_DRIVER_GET(x)         (((x) & WLAN_GPIO_PIN1_PAD_DRIVER_MASK) >> WLAN_GPIO_PIN1_PAD_DRIVER_LSB)
-#define WLAN_GPIO_PIN1_PAD_DRIVER_SET(x)         (((x) << WLAN_GPIO_PIN1_PAD_DRIVER_LSB) & WLAN_GPIO_PIN1_PAD_DRIVER_MASK)
-#define WLAN_GPIO_PIN1_SOURCE_MSB                0
-#define WLAN_GPIO_PIN1_SOURCE_LSB                0
-#define WLAN_GPIO_PIN1_SOURCE_MASK               0x00000001
-#define WLAN_GPIO_PIN1_SOURCE_GET(x)             (((x) & WLAN_GPIO_PIN1_SOURCE_MASK) >> WLAN_GPIO_PIN1_SOURCE_LSB)
-#define WLAN_GPIO_PIN1_SOURCE_SET(x)             (((x) << WLAN_GPIO_PIN1_SOURCE_LSB) & WLAN_GPIO_PIN1_SOURCE_MASK)
-
-#define WLAN_GPIO_PIN2_ADDRESS                   0x00000030
-#define WLAN_GPIO_PIN2_OFFSET                    0x00000030
-#define WLAN_GPIO_PIN2_CONFIG_MSB                13
-#define WLAN_GPIO_PIN2_CONFIG_LSB                11
-#define WLAN_GPIO_PIN2_CONFIG_MASK               0x00003800
-#define WLAN_GPIO_PIN2_CONFIG_GET(x)             (((x) & WLAN_GPIO_PIN2_CONFIG_MASK) >> WLAN_GPIO_PIN2_CONFIG_LSB)
-#define WLAN_GPIO_PIN2_CONFIG_SET(x)             (((x) << WLAN_GPIO_PIN2_CONFIG_LSB) & WLAN_GPIO_PIN2_CONFIG_MASK)
-#define WLAN_GPIO_PIN2_WAKEUP_ENABLE_MSB         10
-#define WLAN_GPIO_PIN2_WAKEUP_ENABLE_LSB         10
-#define WLAN_GPIO_PIN2_WAKEUP_ENABLE_MASK        0x00000400
-#define WLAN_GPIO_PIN2_WAKEUP_ENABLE_GET(x)      (((x) & WLAN_GPIO_PIN2_WAKEUP_ENABLE_MASK) >> WLAN_GPIO_PIN2_WAKEUP_ENABLE_LSB)
-#define WLAN_GPIO_PIN2_WAKEUP_ENABLE_SET(x)      (((x) << WLAN_GPIO_PIN2_WAKEUP_ENABLE_LSB) & WLAN_GPIO_PIN2_WAKEUP_ENABLE_MASK)
-#define WLAN_GPIO_PIN2_INT_TYPE_MSB              9
-#define WLAN_GPIO_PIN2_INT_TYPE_LSB              7
-#define WLAN_GPIO_PIN2_INT_TYPE_MASK             0x00000380
-#define WLAN_GPIO_PIN2_INT_TYPE_GET(x)           (((x) & WLAN_GPIO_PIN2_INT_TYPE_MASK) >> WLAN_GPIO_PIN2_INT_TYPE_LSB)
-#define WLAN_GPIO_PIN2_INT_TYPE_SET(x)           (((x) << WLAN_GPIO_PIN2_INT_TYPE_LSB) & WLAN_GPIO_PIN2_INT_TYPE_MASK)
-#define WLAN_GPIO_PIN2_PAD_PULL_MSB              6
-#define WLAN_GPIO_PIN2_PAD_PULL_LSB              5
-#define WLAN_GPIO_PIN2_PAD_PULL_MASK             0x00000060
-#define WLAN_GPIO_PIN2_PAD_PULL_GET(x)           (((x) & WLAN_GPIO_PIN2_PAD_PULL_MASK) >> WLAN_GPIO_PIN2_PAD_PULL_LSB)
-#define WLAN_GPIO_PIN2_PAD_PULL_SET(x)           (((x) << WLAN_GPIO_PIN2_PAD_PULL_LSB) & WLAN_GPIO_PIN2_PAD_PULL_MASK)
-#define WLAN_GPIO_PIN2_PAD_STRENGTH_MSB          4
-#define WLAN_GPIO_PIN2_PAD_STRENGTH_LSB          3
-#define WLAN_GPIO_PIN2_PAD_STRENGTH_MASK         0x00000018
-#define WLAN_GPIO_PIN2_PAD_STRENGTH_GET(x)       (((x) & WLAN_GPIO_PIN2_PAD_STRENGTH_MASK) >> WLAN_GPIO_PIN2_PAD_STRENGTH_LSB)
-#define WLAN_GPIO_PIN2_PAD_STRENGTH_SET(x)       (((x) << WLAN_GPIO_PIN2_PAD_STRENGTH_LSB) & WLAN_GPIO_PIN2_PAD_STRENGTH_MASK)
-#define WLAN_GPIO_PIN2_PAD_DRIVER_MSB            2
-#define WLAN_GPIO_PIN2_PAD_DRIVER_LSB            2
-#define WLAN_GPIO_PIN2_PAD_DRIVER_MASK           0x00000004
-#define WLAN_GPIO_PIN2_PAD_DRIVER_GET(x)         (((x) & WLAN_GPIO_PIN2_PAD_DRIVER_MASK) >> WLAN_GPIO_PIN2_PAD_DRIVER_LSB)
-#define WLAN_GPIO_PIN2_PAD_DRIVER_SET(x)         (((x) << WLAN_GPIO_PIN2_PAD_DRIVER_LSB) & WLAN_GPIO_PIN2_PAD_DRIVER_MASK)
-#define WLAN_GPIO_PIN2_SOURCE_MSB                0
-#define WLAN_GPIO_PIN2_SOURCE_LSB                0
-#define WLAN_GPIO_PIN2_SOURCE_MASK               0x00000001
-#define WLAN_GPIO_PIN2_SOURCE_GET(x)             (((x) & WLAN_GPIO_PIN2_SOURCE_MASK) >> WLAN_GPIO_PIN2_SOURCE_LSB)
-#define WLAN_GPIO_PIN2_SOURCE_SET(x)             (((x) << WLAN_GPIO_PIN2_SOURCE_LSB) & WLAN_GPIO_PIN2_SOURCE_MASK)
-
-#define WLAN_GPIO_PIN3_ADDRESS                   0x00000034
-#define WLAN_GPIO_PIN3_OFFSET                    0x00000034
-#define WLAN_GPIO_PIN3_CONFIG_MSB                13
-#define WLAN_GPIO_PIN3_CONFIG_LSB                11
-#define WLAN_GPIO_PIN3_CONFIG_MASK               0x00003800
-#define WLAN_GPIO_PIN3_CONFIG_GET(x)             (((x) & WLAN_GPIO_PIN3_CONFIG_MASK) >> WLAN_GPIO_PIN3_CONFIG_LSB)
-#define WLAN_GPIO_PIN3_CONFIG_SET(x)             (((x) << WLAN_GPIO_PIN3_CONFIG_LSB) & WLAN_GPIO_PIN3_CONFIG_MASK)
-#define WLAN_GPIO_PIN3_WAKEUP_ENABLE_MSB         10
-#define WLAN_GPIO_PIN3_WAKEUP_ENABLE_LSB         10
-#define WLAN_GPIO_PIN3_WAKEUP_ENABLE_MASK        0x00000400
-#define WLAN_GPIO_PIN3_WAKEUP_ENABLE_GET(x)      (((x) & WLAN_GPIO_PIN3_WAKEUP_ENABLE_MASK) >> WLAN_GPIO_PIN3_WAKEUP_ENABLE_LSB)
-#define WLAN_GPIO_PIN3_WAKEUP_ENABLE_SET(x)      (((x) << WLAN_GPIO_PIN3_WAKEUP_ENABLE_LSB) & WLAN_GPIO_PIN3_WAKEUP_ENABLE_MASK)
-#define WLAN_GPIO_PIN3_INT_TYPE_MSB              9
-#define WLAN_GPIO_PIN3_INT_TYPE_LSB              7
-#define WLAN_GPIO_PIN3_INT_TYPE_MASK             0x00000380
-#define WLAN_GPIO_PIN3_INT_TYPE_GET(x)           (((x) & WLAN_GPIO_PIN3_INT_TYPE_MASK) >> WLAN_GPIO_PIN3_INT_TYPE_LSB)
-#define WLAN_GPIO_PIN3_INT_TYPE_SET(x)           (((x) << WLAN_GPIO_PIN3_INT_TYPE_LSB) & WLAN_GPIO_PIN3_INT_TYPE_MASK)
-#define WLAN_GPIO_PIN3_PAD_PULL_MSB              6
-#define WLAN_GPIO_PIN3_PAD_PULL_LSB              5
-#define WLAN_GPIO_PIN3_PAD_PULL_MASK             0x00000060
-#define WLAN_GPIO_PIN3_PAD_PULL_GET(x)           (((x) & WLAN_GPIO_PIN3_PAD_PULL_MASK) >> WLAN_GPIO_PIN3_PAD_PULL_LSB)
-#define WLAN_GPIO_PIN3_PAD_PULL_SET(x)           (((x) << WLAN_GPIO_PIN3_PAD_PULL_LSB) & WLAN_GPIO_PIN3_PAD_PULL_MASK)
-#define WLAN_GPIO_PIN3_PAD_STRENGTH_MSB          4
-#define WLAN_GPIO_PIN3_PAD_STRENGTH_LSB          3
-#define WLAN_GPIO_PIN3_PAD_STRENGTH_MASK         0x00000018
-#define WLAN_GPIO_PIN3_PAD_STRENGTH_GET(x)       (((x) & WLAN_GPIO_PIN3_PAD_STRENGTH_MASK) >> WLAN_GPIO_PIN3_PAD_STRENGTH_LSB)
-#define WLAN_GPIO_PIN3_PAD_STRENGTH_SET(x)       (((x) << WLAN_GPIO_PIN3_PAD_STRENGTH_LSB) & WLAN_GPIO_PIN3_PAD_STRENGTH_MASK)
-#define WLAN_GPIO_PIN3_PAD_DRIVER_MSB            2
-#define WLAN_GPIO_PIN3_PAD_DRIVER_LSB            2
-#define WLAN_GPIO_PIN3_PAD_DRIVER_MASK           0x00000004
-#define WLAN_GPIO_PIN3_PAD_DRIVER_GET(x)         (((x) & WLAN_GPIO_PIN3_PAD_DRIVER_MASK) >> WLAN_GPIO_PIN3_PAD_DRIVER_LSB)
-#define WLAN_GPIO_PIN3_PAD_DRIVER_SET(x)         (((x) << WLAN_GPIO_PIN3_PAD_DRIVER_LSB) & WLAN_GPIO_PIN3_PAD_DRIVER_MASK)
-#define WLAN_GPIO_PIN3_SOURCE_MSB                0
-#define WLAN_GPIO_PIN3_SOURCE_LSB                0
-#define WLAN_GPIO_PIN3_SOURCE_MASK               0x00000001
-#define WLAN_GPIO_PIN3_SOURCE_GET(x)             (((x) & WLAN_GPIO_PIN3_SOURCE_MASK) >> WLAN_GPIO_PIN3_SOURCE_LSB)
-#define WLAN_GPIO_PIN3_SOURCE_SET(x)             (((x) << WLAN_GPIO_PIN3_SOURCE_LSB) & WLAN_GPIO_PIN3_SOURCE_MASK)
-
-#define WLAN_GPIO_PIN4_ADDRESS                   0x00000038
-#define WLAN_GPIO_PIN4_OFFSET                    0x00000038
-#define WLAN_GPIO_PIN4_CONFIG_MSB                13
-#define WLAN_GPIO_PIN4_CONFIG_LSB                11
-#define WLAN_GPIO_PIN4_CONFIG_MASK               0x00003800
-#define WLAN_GPIO_PIN4_CONFIG_GET(x)             (((x) & WLAN_GPIO_PIN4_CONFIG_MASK) >> WLAN_GPIO_PIN4_CONFIG_LSB)
-#define WLAN_GPIO_PIN4_CONFIG_SET(x)             (((x) << WLAN_GPIO_PIN4_CONFIG_LSB) & WLAN_GPIO_PIN4_CONFIG_MASK)
-#define WLAN_GPIO_PIN4_WAKEUP_ENABLE_MSB         10
-#define WLAN_GPIO_PIN4_WAKEUP_ENABLE_LSB         10
-#define WLAN_GPIO_PIN4_WAKEUP_ENABLE_MASK        0x00000400
-#define WLAN_GPIO_PIN4_WAKEUP_ENABLE_GET(x)      (((x) & WLAN_GPIO_PIN4_WAKEUP_ENABLE_MASK) >> WLAN_GPIO_PIN4_WAKEUP_ENABLE_LSB)
-#define WLAN_GPIO_PIN4_WAKEUP_ENABLE_SET(x)      (((x) << WLAN_GPIO_PIN4_WAKEUP_ENABLE_LSB) & WLAN_GPIO_PIN4_WAKEUP_ENABLE_MASK)
-#define WLAN_GPIO_PIN4_INT_TYPE_MSB              9
-#define WLAN_GPIO_PIN4_INT_TYPE_LSB              7
-#define WLAN_GPIO_PIN4_INT_TYPE_MASK             0x00000380
-#define WLAN_GPIO_PIN4_INT_TYPE_GET(x)           (((x) & WLAN_GPIO_PIN4_INT_TYPE_MASK) >> WLAN_GPIO_PIN4_INT_TYPE_LSB)
-#define WLAN_GPIO_PIN4_INT_TYPE_SET(x)           (((x) << WLAN_GPIO_PIN4_INT_TYPE_LSB) & WLAN_GPIO_PIN4_INT_TYPE_MASK)
-#define WLAN_GPIO_PIN4_PAD_PULL_MSB              6
-#define WLAN_GPIO_PIN4_PAD_PULL_LSB              5
-#define WLAN_GPIO_PIN4_PAD_PULL_MASK             0x00000060
-#define WLAN_GPIO_PIN4_PAD_PULL_GET(x)           (((x) & WLAN_GPIO_PIN4_PAD_PULL_MASK) >> WLAN_GPIO_PIN4_PAD_PULL_LSB)
-#define WLAN_GPIO_PIN4_PAD_PULL_SET(x)           (((x) << WLAN_GPIO_PIN4_PAD_PULL_LSB) & WLAN_GPIO_PIN4_PAD_PULL_MASK)
-#define WLAN_GPIO_PIN4_PAD_STRENGTH_MSB          4
-#define WLAN_GPIO_PIN4_PAD_STRENGTH_LSB          3
-#define WLAN_GPIO_PIN4_PAD_STRENGTH_MASK         0x00000018
-#define WLAN_GPIO_PIN4_PAD_STRENGTH_GET(x)       (((x) & WLAN_GPIO_PIN4_PAD_STRENGTH_MASK) >> WLAN_GPIO_PIN4_PAD_STRENGTH_LSB)
-#define WLAN_GPIO_PIN4_PAD_STRENGTH_SET(x)       (((x) << WLAN_GPIO_PIN4_PAD_STRENGTH_LSB) & WLAN_GPIO_PIN4_PAD_STRENGTH_MASK)
-#define WLAN_GPIO_PIN4_PAD_DRIVER_MSB            2
-#define WLAN_GPIO_PIN4_PAD_DRIVER_LSB            2
-#define WLAN_GPIO_PIN4_PAD_DRIVER_MASK           0x00000004
-#define WLAN_GPIO_PIN4_PAD_DRIVER_GET(x)         (((x) & WLAN_GPIO_PIN4_PAD_DRIVER_MASK) >> WLAN_GPIO_PIN4_PAD_DRIVER_LSB)
-#define WLAN_GPIO_PIN4_PAD_DRIVER_SET(x)         (((x) << WLAN_GPIO_PIN4_PAD_DRIVER_LSB) & WLAN_GPIO_PIN4_PAD_DRIVER_MASK)
-#define WLAN_GPIO_PIN4_SOURCE_MSB                0
-#define WLAN_GPIO_PIN4_SOURCE_LSB                0
-#define WLAN_GPIO_PIN4_SOURCE_MASK               0x00000001
-#define WLAN_GPIO_PIN4_SOURCE_GET(x)             (((x) & WLAN_GPIO_PIN4_SOURCE_MASK) >> WLAN_GPIO_PIN4_SOURCE_LSB)
-#define WLAN_GPIO_PIN4_SOURCE_SET(x)             (((x) << WLAN_GPIO_PIN4_SOURCE_LSB) & WLAN_GPIO_PIN4_SOURCE_MASK)
-
-#define WLAN_GPIO_PIN5_ADDRESS                   0x0000003c
-#define WLAN_GPIO_PIN5_OFFSET                    0x0000003c
-#define WLAN_GPIO_PIN5_CONFIG_MSB                13
-#define WLAN_GPIO_PIN5_CONFIG_LSB                11
-#define WLAN_GPIO_PIN5_CONFIG_MASK               0x00003800
-#define WLAN_GPIO_PIN5_CONFIG_GET(x)             (((x) & WLAN_GPIO_PIN5_CONFIG_MASK) >> WLAN_GPIO_PIN5_CONFIG_LSB)
-#define WLAN_GPIO_PIN5_CONFIG_SET(x)             (((x) << WLAN_GPIO_PIN5_CONFIG_LSB) & WLAN_GPIO_PIN5_CONFIG_MASK)
-#define WLAN_GPIO_PIN5_WAKEUP_ENABLE_MSB         10
-#define WLAN_GPIO_PIN5_WAKEUP_ENABLE_LSB         10
-#define WLAN_GPIO_PIN5_WAKEUP_ENABLE_MASK        0x00000400
-#define WLAN_GPIO_PIN5_WAKEUP_ENABLE_GET(x)      (((x) & WLAN_GPIO_PIN5_WAKEUP_ENABLE_MASK) >> WLAN_GPIO_PIN5_WAKEUP_ENABLE_LSB)
-#define WLAN_GPIO_PIN5_WAKEUP_ENABLE_SET(x)      (((x) << WLAN_GPIO_PIN5_WAKEUP_ENABLE_LSB) & WLAN_GPIO_PIN5_WAKEUP_ENABLE_MASK)
-#define WLAN_GPIO_PIN5_INT_TYPE_MSB              9
-#define WLAN_GPIO_PIN5_INT_TYPE_LSB              7
-#define WLAN_GPIO_PIN5_INT_TYPE_MASK             0x00000380
-#define WLAN_GPIO_PIN5_INT_TYPE_GET(x)           (((x) & WLAN_GPIO_PIN5_INT_TYPE_MASK) >> WLAN_GPIO_PIN5_INT_TYPE_LSB)
-#define WLAN_GPIO_PIN5_INT_TYPE_SET(x)           (((x) << WLAN_GPIO_PIN5_INT_TYPE_LSB) & WLAN_GPIO_PIN5_INT_TYPE_MASK)
-#define WLAN_GPIO_PIN5_PAD_PULL_MSB              6
-#define WLAN_GPIO_PIN5_PAD_PULL_LSB              5
-#define WLAN_GPIO_PIN5_PAD_PULL_MASK             0x00000060
-#define WLAN_GPIO_PIN5_PAD_PULL_GET(x)           (((x) & WLAN_GPIO_PIN5_PAD_PULL_MASK) >> WLAN_GPIO_PIN5_PAD_PULL_LSB)
-#define WLAN_GPIO_PIN5_PAD_PULL_SET(x)           (((x) << WLAN_GPIO_PIN5_PAD_PULL_LSB) & WLAN_GPIO_PIN5_PAD_PULL_MASK)
-#define WLAN_GPIO_PIN5_PAD_STRENGTH_MSB          4
-#define WLAN_GPIO_PIN5_PAD_STRENGTH_LSB          3
-#define WLAN_GPIO_PIN5_PAD_STRENGTH_MASK         0x00000018
-#define WLAN_GPIO_PIN5_PAD_STRENGTH_GET(x)       (((x) & WLAN_GPIO_PIN5_PAD_STRENGTH_MASK) >> WLAN_GPIO_PIN5_PAD_STRENGTH_LSB)
-#define WLAN_GPIO_PIN5_PAD_STRENGTH_SET(x)       (((x) << WLAN_GPIO_PIN5_PAD_STRENGTH_LSB) & WLAN_GPIO_PIN5_PAD_STRENGTH_MASK)
-#define WLAN_GPIO_PIN5_PAD_DRIVER_MSB            2
-#define WLAN_GPIO_PIN5_PAD_DRIVER_LSB            2
-#define WLAN_GPIO_PIN5_PAD_DRIVER_MASK           0x00000004
-#define WLAN_GPIO_PIN5_PAD_DRIVER_GET(x)         (((x) & WLAN_GPIO_PIN5_PAD_DRIVER_MASK) >> WLAN_GPIO_PIN5_PAD_DRIVER_LSB)
-#define WLAN_GPIO_PIN5_PAD_DRIVER_SET(x)         (((x) << WLAN_GPIO_PIN5_PAD_DRIVER_LSB) & WLAN_GPIO_PIN5_PAD_DRIVER_MASK)
-#define WLAN_GPIO_PIN5_SOURCE_MSB                0
-#define WLAN_GPIO_PIN5_SOURCE_LSB                0
-#define WLAN_GPIO_PIN5_SOURCE_MASK               0x00000001
-#define WLAN_GPIO_PIN5_SOURCE_GET(x)             (((x) & WLAN_GPIO_PIN5_SOURCE_MASK) >> WLAN_GPIO_PIN5_SOURCE_LSB)
-#define WLAN_GPIO_PIN5_SOURCE_SET(x)             (((x) << WLAN_GPIO_PIN5_SOURCE_LSB) & WLAN_GPIO_PIN5_SOURCE_MASK)
-
-#define WLAN_GPIO_PIN6_ADDRESS                   0x00000040
-#define WLAN_GPIO_PIN6_OFFSET                    0x00000040
-#define WLAN_GPIO_PIN6_CONFIG_MSB                13
-#define WLAN_GPIO_PIN6_CONFIG_LSB                11
-#define WLAN_GPIO_PIN6_CONFIG_MASK               0x00003800
-#define WLAN_GPIO_PIN6_CONFIG_GET(x)             (((x) & WLAN_GPIO_PIN6_CONFIG_MASK) >> WLAN_GPIO_PIN6_CONFIG_LSB)
-#define WLAN_GPIO_PIN6_CONFIG_SET(x)             (((x) << WLAN_GPIO_PIN6_CONFIG_LSB) & WLAN_GPIO_PIN6_CONFIG_MASK)
-#define WLAN_GPIO_PIN6_WAKEUP_ENABLE_MSB         10
-#define WLAN_GPIO_PIN6_WAKEUP_ENABLE_LSB         10
-#define WLAN_GPIO_PIN6_WAKEUP_ENABLE_MASK        0x00000400
-#define WLAN_GPIO_PIN6_WAKEUP_ENABLE_GET(x)      (((x) & WLAN_GPIO_PIN6_WAKEUP_ENABLE_MASK) >> WLAN_GPIO_PIN6_WAKEUP_ENABLE_LSB)
-#define WLAN_GPIO_PIN6_WAKEUP_ENABLE_SET(x)      (((x) << WLAN_GPIO_PIN6_WAKEUP_ENABLE_LSB) & WLAN_GPIO_PIN6_WAKEUP_ENABLE_MASK)
-#define WLAN_GPIO_PIN6_INT_TYPE_MSB              9
-#define WLAN_GPIO_PIN6_INT_TYPE_LSB              7
-#define WLAN_GPIO_PIN6_INT_TYPE_MASK             0x00000380
-#define WLAN_GPIO_PIN6_INT_TYPE_GET(x)           (((x) & WLAN_GPIO_PIN6_INT_TYPE_MASK) >> WLAN_GPIO_PIN6_INT_TYPE_LSB)
-#define WLAN_GPIO_PIN6_INT_TYPE_SET(x)           (((x) << WLAN_GPIO_PIN6_INT_TYPE_LSB) & WLAN_GPIO_PIN6_INT_TYPE_MASK)
-#define WLAN_GPIO_PIN6_PAD_PULL_MSB              6
-#define WLAN_GPIO_PIN6_PAD_PULL_LSB              5
-#define WLAN_GPIO_PIN6_PAD_PULL_MASK             0x00000060
-#define WLAN_GPIO_PIN6_PAD_PULL_GET(x)           (((x) & WLAN_GPIO_PIN6_PAD_PULL_MASK) >> WLAN_GPIO_PIN6_PAD_PULL_LSB)
-#define WLAN_GPIO_PIN6_PAD_PULL_SET(x)           (((x) << WLAN_GPIO_PIN6_PAD_PULL_LSB) & WLAN_GPIO_PIN6_PAD_PULL_MASK)
-#define WLAN_GPIO_PIN6_PAD_STRENGTH_MSB          4
-#define WLAN_GPIO_PIN6_PAD_STRENGTH_LSB          3
-#define WLAN_GPIO_PIN6_PAD_STRENGTH_MASK         0x00000018
-#define WLAN_GPIO_PIN6_PAD_STRENGTH_GET(x)       (((x) & WLAN_GPIO_PIN6_PAD_STRENGTH_MASK) >> WLAN_GPIO_PIN6_PAD_STRENGTH_LSB)
-#define WLAN_GPIO_PIN6_PAD_STRENGTH_SET(x)       (((x) << WLAN_GPIO_PIN6_PAD_STRENGTH_LSB) & WLAN_GPIO_PIN6_PAD_STRENGTH_MASK)
-#define WLAN_GPIO_PIN6_PAD_DRIVER_MSB            2
-#define WLAN_GPIO_PIN6_PAD_DRIVER_LSB            2
-#define WLAN_GPIO_PIN6_PAD_DRIVER_MASK           0x00000004
-#define WLAN_GPIO_PIN6_PAD_DRIVER_GET(x)         (((x) & WLAN_GPIO_PIN6_PAD_DRIVER_MASK) >> WLAN_GPIO_PIN6_PAD_DRIVER_LSB)
-#define WLAN_GPIO_PIN6_PAD_DRIVER_SET(x)         (((x) << WLAN_GPIO_PIN6_PAD_DRIVER_LSB) & WLAN_GPIO_PIN6_PAD_DRIVER_MASK)
-#define WLAN_GPIO_PIN6_SOURCE_MSB                0
-#define WLAN_GPIO_PIN6_SOURCE_LSB                0
-#define WLAN_GPIO_PIN6_SOURCE_MASK               0x00000001
-#define WLAN_GPIO_PIN6_SOURCE_GET(x)             (((x) & WLAN_GPIO_PIN6_SOURCE_MASK) >> WLAN_GPIO_PIN6_SOURCE_LSB)
-#define WLAN_GPIO_PIN6_SOURCE_SET(x)             (((x) << WLAN_GPIO_PIN6_SOURCE_LSB) & WLAN_GPIO_PIN6_SOURCE_MASK)
-
-#define WLAN_GPIO_PIN7_ADDRESS                   0x00000044
-#define WLAN_GPIO_PIN7_OFFSET                    0x00000044
-#define WLAN_GPIO_PIN7_CONFIG_MSB                13
-#define WLAN_GPIO_PIN7_CONFIG_LSB                11
-#define WLAN_GPIO_PIN7_CONFIG_MASK               0x00003800
-#define WLAN_GPIO_PIN7_CONFIG_GET(x)             (((x) & WLAN_GPIO_PIN7_CONFIG_MASK) >> WLAN_GPIO_PIN7_CONFIG_LSB)
-#define WLAN_GPIO_PIN7_CONFIG_SET(x)             (((x) << WLAN_GPIO_PIN7_CONFIG_LSB) & WLAN_GPIO_PIN7_CONFIG_MASK)
-#define WLAN_GPIO_PIN7_WAKEUP_ENABLE_MSB         10
-#define WLAN_GPIO_PIN7_WAKEUP_ENABLE_LSB         10
-#define WLAN_GPIO_PIN7_WAKEUP_ENABLE_MASK        0x00000400
-#define WLAN_GPIO_PIN7_WAKEUP_ENABLE_GET(x)      (((x) & WLAN_GPIO_PIN7_WAKEUP_ENABLE_MASK) >> WLAN_GPIO_PIN7_WAKEUP_ENABLE_LSB)
-#define WLAN_GPIO_PIN7_WAKEUP_ENABLE_SET(x)      (((x) << WLAN_GPIO_PIN7_WAKEUP_ENABLE_LSB) & WLAN_GPIO_PIN7_WAKEUP_ENABLE_MASK)
-#define WLAN_GPIO_PIN7_INT_TYPE_MSB              9
-#define WLAN_GPIO_PIN7_INT_TYPE_LSB              7
-#define WLAN_GPIO_PIN7_INT_TYPE_MASK             0x00000380
-#define WLAN_GPIO_PIN7_INT_TYPE_GET(x)           (((x) & WLAN_GPIO_PIN7_INT_TYPE_MASK) >> WLAN_GPIO_PIN7_INT_TYPE_LSB)
-#define WLAN_GPIO_PIN7_INT_TYPE_SET(x)           (((x) << WLAN_GPIO_PIN7_INT_TYPE_LSB) & WLAN_GPIO_PIN7_INT_TYPE_MASK)
-#define WLAN_GPIO_PIN7_PAD_PULL_MSB              6
-#define WLAN_GPIO_PIN7_PAD_PULL_LSB              5
-#define WLAN_GPIO_PIN7_PAD_PULL_MASK             0x00000060
-#define WLAN_GPIO_PIN7_PAD_PULL_GET(x)           (((x) & WLAN_GPIO_PIN7_PAD_PULL_MASK) >> WLAN_GPIO_PIN7_PAD_PULL_LSB)
-#define WLAN_GPIO_PIN7_PAD_PULL_SET(x)           (((x) << WLAN_GPIO_PIN7_PAD_PULL_LSB) & WLAN_GPIO_PIN7_PAD_PULL_MASK)
-#define WLAN_GPIO_PIN7_PAD_STRENGTH_MSB          4
-#define WLAN_GPIO_PIN7_PAD_STRENGTH_LSB          3
-#define WLAN_GPIO_PIN7_PAD_STRENGTH_MASK         0x00000018
-#define WLAN_GPIO_PIN7_PAD_STRENGTH_GET(x)       (((x) & WLAN_GPIO_PIN7_PAD_STRENGTH_MASK) >> WLAN_GPIO_PIN7_PAD_STRENGTH_LSB)
-#define WLAN_GPIO_PIN7_PAD_STRENGTH_SET(x)       (((x) << WLAN_GPIO_PIN7_PAD_STRENGTH_LSB) & WLAN_GPIO_PIN7_PAD_STRENGTH_MASK)
-#define WLAN_GPIO_PIN7_PAD_DRIVER_MSB            2
-#define WLAN_GPIO_PIN7_PAD_DRIVER_LSB            2
-#define WLAN_GPIO_PIN7_PAD_DRIVER_MASK           0x00000004
-#define WLAN_GPIO_PIN7_PAD_DRIVER_GET(x)         (((x) & WLAN_GPIO_PIN7_PAD_DRIVER_MASK) >> WLAN_GPIO_PIN7_PAD_DRIVER_LSB)
-#define WLAN_GPIO_PIN7_PAD_DRIVER_SET(x)         (((x) << WLAN_GPIO_PIN7_PAD_DRIVER_LSB) & WLAN_GPIO_PIN7_PAD_DRIVER_MASK)
-#define WLAN_GPIO_PIN7_SOURCE_MSB                0
-#define WLAN_GPIO_PIN7_SOURCE_LSB                0
-#define WLAN_GPIO_PIN7_SOURCE_MASK               0x00000001
-#define WLAN_GPIO_PIN7_SOURCE_GET(x)             (((x) & WLAN_GPIO_PIN7_SOURCE_MASK) >> WLAN_GPIO_PIN7_SOURCE_LSB)
-#define WLAN_GPIO_PIN7_SOURCE_SET(x)             (((x) << WLAN_GPIO_PIN7_SOURCE_LSB) & WLAN_GPIO_PIN7_SOURCE_MASK)
-
-#define WLAN_GPIO_PIN8_ADDRESS                   0x00000048
-#define WLAN_GPIO_PIN8_OFFSET                    0x00000048
-#define WLAN_GPIO_PIN8_CONFIG_MSB                13
-#define WLAN_GPIO_PIN8_CONFIG_LSB                11
-#define WLAN_GPIO_PIN8_CONFIG_MASK               0x00003800
-#define WLAN_GPIO_PIN8_CONFIG_GET(x)             (((x) & WLAN_GPIO_PIN8_CONFIG_MASK) >> WLAN_GPIO_PIN8_CONFIG_LSB)
-#define WLAN_GPIO_PIN8_CONFIG_SET(x)             (((x) << WLAN_GPIO_PIN8_CONFIG_LSB) & WLAN_GPIO_PIN8_CONFIG_MASK)
-#define WLAN_GPIO_PIN8_WAKEUP_ENABLE_MSB         10
-#define WLAN_GPIO_PIN8_WAKEUP_ENABLE_LSB         10
-#define WLAN_GPIO_PIN8_WAKEUP_ENABLE_MASK        0x00000400
-#define WLAN_GPIO_PIN8_WAKEUP_ENABLE_GET(x)      (((x) & WLAN_GPIO_PIN8_WAKEUP_ENABLE_MASK) >> WLAN_GPIO_PIN8_WAKEUP_ENABLE_LSB)
-#define WLAN_GPIO_PIN8_WAKEUP_ENABLE_SET(x)      (((x) << WLAN_GPIO_PIN8_WAKEUP_ENABLE_LSB) & WLAN_GPIO_PIN8_WAKEUP_ENABLE_MASK)
-#define WLAN_GPIO_PIN8_INT_TYPE_MSB              9
-#define WLAN_GPIO_PIN8_INT_TYPE_LSB              7
-#define WLAN_GPIO_PIN8_INT_TYPE_MASK             0x00000380
-#define WLAN_GPIO_PIN8_INT_TYPE_GET(x)           (((x) & WLAN_GPIO_PIN8_INT_TYPE_MASK) >> WLAN_GPIO_PIN8_INT_TYPE_LSB)
-#define WLAN_GPIO_PIN8_INT_TYPE_SET(x)           (((x) << WLAN_GPIO_PIN8_INT_TYPE_LSB) & WLAN_GPIO_PIN8_INT_TYPE_MASK)
-#define WLAN_GPIO_PIN8_PAD_PULL_MSB              6
-#define WLAN_GPIO_PIN8_PAD_PULL_LSB              5
-#define WLAN_GPIO_PIN8_PAD_PULL_MASK             0x00000060
-#define WLAN_GPIO_PIN8_PAD_PULL_GET(x)           (((x) & WLAN_GPIO_PIN8_PAD_PULL_MASK) >> WLAN_GPIO_PIN8_PAD_PULL_LSB)
-#define WLAN_GPIO_PIN8_PAD_PULL_SET(x)           (((x) << WLAN_GPIO_PIN8_PAD_PULL_LSB) & WLAN_GPIO_PIN8_PAD_PULL_MASK)
-#define WLAN_GPIO_PIN8_PAD_STRENGTH_MSB          4
-#define WLAN_GPIO_PIN8_PAD_STRENGTH_LSB          3
-#define WLAN_GPIO_PIN8_PAD_STRENGTH_MASK         0x00000018
-#define WLAN_GPIO_PIN8_PAD_STRENGTH_GET(x)       (((x) & WLAN_GPIO_PIN8_PAD_STRENGTH_MASK) >> WLAN_GPIO_PIN8_PAD_STRENGTH_LSB)
-#define WLAN_GPIO_PIN8_PAD_STRENGTH_SET(x)       (((x) << WLAN_GPIO_PIN8_PAD_STRENGTH_LSB) & WLAN_GPIO_PIN8_PAD_STRENGTH_MASK)
-#define WLAN_GPIO_PIN8_PAD_DRIVER_MSB            2
-#define WLAN_GPIO_PIN8_PAD_DRIVER_LSB            2
-#define WLAN_GPIO_PIN8_PAD_DRIVER_MASK           0x00000004
-#define WLAN_GPIO_PIN8_PAD_DRIVER_GET(x)         (((x) & WLAN_GPIO_PIN8_PAD_DRIVER_MASK) >> WLAN_GPIO_PIN8_PAD_DRIVER_LSB)
-#define WLAN_GPIO_PIN8_PAD_DRIVER_SET(x)         (((x) << WLAN_GPIO_PIN8_PAD_DRIVER_LSB) & WLAN_GPIO_PIN8_PAD_DRIVER_MASK)
-#define WLAN_GPIO_PIN8_SOURCE_MSB                0
-#define WLAN_GPIO_PIN8_SOURCE_LSB                0
-#define WLAN_GPIO_PIN8_SOURCE_MASK               0x00000001
-#define WLAN_GPIO_PIN8_SOURCE_GET(x)             (((x) & WLAN_GPIO_PIN8_SOURCE_MASK) >> WLAN_GPIO_PIN8_SOURCE_LSB)
-#define WLAN_GPIO_PIN8_SOURCE_SET(x)             (((x) << WLAN_GPIO_PIN8_SOURCE_LSB) & WLAN_GPIO_PIN8_SOURCE_MASK)
-
-#define WLAN_GPIO_PIN9_ADDRESS                   0x0000004c
-#define WLAN_GPIO_PIN9_OFFSET                    0x0000004c
-#define WLAN_GPIO_PIN9_CONFIG_MSB                13
-#define WLAN_GPIO_PIN9_CONFIG_LSB                11
-#define WLAN_GPIO_PIN9_CONFIG_MASK               0x00003800
-#define WLAN_GPIO_PIN9_CONFIG_GET(x)             (((x) & WLAN_GPIO_PIN9_CONFIG_MASK) >> WLAN_GPIO_PIN9_CONFIG_LSB)
-#define WLAN_GPIO_PIN9_CONFIG_SET(x)             (((x) << WLAN_GPIO_PIN9_CONFIG_LSB) & WLAN_GPIO_PIN9_CONFIG_MASK)
-#define WLAN_GPIO_PIN9_WAKEUP_ENABLE_MSB         10
-#define WLAN_GPIO_PIN9_WAKEUP_ENABLE_LSB         10
-#define WLAN_GPIO_PIN9_WAKEUP_ENABLE_MASK        0x00000400
-#define WLAN_GPIO_PIN9_WAKEUP_ENABLE_GET(x)      (((x) & WLAN_GPIO_PIN9_WAKEUP_ENABLE_MASK) >> WLAN_GPIO_PIN9_WAKEUP_ENABLE_LSB)
-#define WLAN_GPIO_PIN9_WAKEUP_ENABLE_SET(x)      (((x) << WLAN_GPIO_PIN9_WAKEUP_ENABLE_LSB) & WLAN_GPIO_PIN9_WAKEUP_ENABLE_MASK)
-#define WLAN_GPIO_PIN9_INT_TYPE_MSB              9
-#define WLAN_GPIO_PIN9_INT_TYPE_LSB              7
-#define WLAN_GPIO_PIN9_INT_TYPE_MASK             0x00000380
-#define WLAN_GPIO_PIN9_INT_TYPE_GET(x)           (((x) & WLAN_GPIO_PIN9_INT_TYPE_MASK) >> WLAN_GPIO_PIN9_INT_TYPE_LSB)
-#define WLAN_GPIO_PIN9_INT_TYPE_SET(x)           (((x) << WLAN_GPIO_PIN9_INT_TYPE_LSB) & WLAN_GPIO_PIN9_INT_TYPE_MASK)
-#define WLAN_GPIO_PIN9_PAD_PULL_MSB              6
-#define WLAN_GPIO_PIN9_PAD_PULL_LSB              5
-#define WLAN_GPIO_PIN9_PAD_PULL_MASK             0x00000060
-#define WLAN_GPIO_PIN9_PAD_PULL_GET(x)           (((x) & WLAN_GPIO_PIN9_PAD_PULL_MASK) >> WLAN_GPIO_PIN9_PAD_PULL_LSB)
-#define WLAN_GPIO_PIN9_PAD_PULL_SET(x)           (((x) << WLAN_GPIO_PIN9_PAD_PULL_LSB) & WLAN_GPIO_PIN9_PAD_PULL_MASK)
-#define WLAN_GPIO_PIN9_PAD_STRENGTH_MSB          4
-#define WLAN_GPIO_PIN9_PAD_STRENGTH_LSB          3
-#define WLAN_GPIO_PIN9_PAD_STRENGTH_MASK         0x00000018
-#define WLAN_GPIO_PIN9_PAD_STRENGTH_GET(x)       (((x) & WLAN_GPIO_PIN9_PAD_STRENGTH_MASK) >> WLAN_GPIO_PIN9_PAD_STRENGTH_LSB)
-#define WLAN_GPIO_PIN9_PAD_STRENGTH_SET(x)       (((x) << WLAN_GPIO_PIN9_PAD_STRENGTH_LSB) & WLAN_GPIO_PIN9_PAD_STRENGTH_MASK)
-#define WLAN_GPIO_PIN9_PAD_DRIVER_MSB            2
-#define WLAN_GPIO_PIN9_PAD_DRIVER_LSB            2
-#define WLAN_GPIO_PIN9_PAD_DRIVER_MASK           0x00000004
-#define WLAN_GPIO_PIN9_PAD_DRIVER_GET(x)         (((x) & WLAN_GPIO_PIN9_PAD_DRIVER_MASK) >> WLAN_GPIO_PIN9_PAD_DRIVER_LSB)
-#define WLAN_GPIO_PIN9_PAD_DRIVER_SET(x)         (((x) << WLAN_GPIO_PIN9_PAD_DRIVER_LSB) & WLAN_GPIO_PIN9_PAD_DRIVER_MASK)
-#define WLAN_GPIO_PIN9_SOURCE_MSB                0
-#define WLAN_GPIO_PIN9_SOURCE_LSB                0
-#define WLAN_GPIO_PIN9_SOURCE_MASK               0x00000001
-#define WLAN_GPIO_PIN9_SOURCE_GET(x)             (((x) & WLAN_GPIO_PIN9_SOURCE_MASK) >> WLAN_GPIO_PIN9_SOURCE_LSB)
-#define WLAN_GPIO_PIN9_SOURCE_SET(x)             (((x) << WLAN_GPIO_PIN9_SOURCE_LSB) & WLAN_GPIO_PIN9_SOURCE_MASK)
-
-#define WLAN_GPIO_PIN10_ADDRESS                  0x00000050
-#define WLAN_GPIO_PIN10_OFFSET                   0x00000050
-#define WLAN_GPIO_PIN10_CONFIG_MSB               13
-#define WLAN_GPIO_PIN10_CONFIG_LSB               11
-#define WLAN_GPIO_PIN10_CONFIG_MASK              0x00003800
-#define WLAN_GPIO_PIN10_CONFIG_GET(x)            (((x) & WLAN_GPIO_PIN10_CONFIG_MASK) >> WLAN_GPIO_PIN10_CONFIG_LSB)
-#define WLAN_GPIO_PIN10_CONFIG_SET(x)            (((x) << WLAN_GPIO_PIN10_CONFIG_LSB) & WLAN_GPIO_PIN10_CONFIG_MASK)
-#define WLAN_GPIO_PIN10_WAKEUP_ENABLE_MSB        10
-#define WLAN_GPIO_PIN10_WAKEUP_ENABLE_LSB        10
-#define WLAN_GPIO_PIN10_WAKEUP_ENABLE_MASK       0x00000400
-#define WLAN_GPIO_PIN10_WAKEUP_ENABLE_GET(x)     (((x) & WLAN_GPIO_PIN10_WAKEUP_ENABLE_MASK) >> WLAN_GPIO_PIN10_WAKEUP_ENABLE_LSB)
-#define WLAN_GPIO_PIN10_WAKEUP_ENABLE_SET(x)     (((x) << WLAN_GPIO_PIN10_WAKEUP_ENABLE_LSB) & WLAN_GPIO_PIN10_WAKEUP_ENABLE_MASK)
-#define WLAN_GPIO_PIN10_INT_TYPE_MSB             9
-#define WLAN_GPIO_PIN10_INT_TYPE_LSB             7
-#define WLAN_GPIO_PIN10_INT_TYPE_MASK            0x00000380
-#define WLAN_GPIO_PIN10_INT_TYPE_GET(x)          (((x) & WLAN_GPIO_PIN10_INT_TYPE_MASK) >> WLAN_GPIO_PIN10_INT_TYPE_LSB)
-#define WLAN_GPIO_PIN10_INT_TYPE_SET(x)          (((x) << WLAN_GPIO_PIN10_INT_TYPE_LSB) & WLAN_GPIO_PIN10_INT_TYPE_MASK)
-#define WLAN_GPIO_PIN10_PAD_PULL_MSB             6
-#define WLAN_GPIO_PIN10_PAD_PULL_LSB             5
-#define WLAN_GPIO_PIN10_PAD_PULL_MASK            0x00000060
-#define WLAN_GPIO_PIN10_PAD_PULL_GET(x)          (((x) & WLAN_GPIO_PIN10_PAD_PULL_MASK) >> WLAN_GPIO_PIN10_PAD_PULL_LSB)
-#define WLAN_GPIO_PIN10_PAD_PULL_SET(x)          (((x) << WLAN_GPIO_PIN10_PAD_PULL_LSB) & WLAN_GPIO_PIN10_PAD_PULL_MASK)
-#define WLAN_GPIO_PIN10_PAD_STRENGTH_MSB         4
-#define WLAN_GPIO_PIN10_PAD_STRENGTH_LSB         3
-#define WLAN_GPIO_PIN10_PAD_STRENGTH_MASK        0x00000018
-#define WLAN_GPIO_PIN10_PAD_STRENGTH_GET(x)      (((x) & WLAN_GPIO_PIN10_PAD_STRENGTH_MASK) >> WLAN_GPIO_PIN10_PAD_STRENGTH_LSB)
-#define WLAN_GPIO_PIN10_PAD_STRENGTH_SET(x)      (((x) << WLAN_GPIO_PIN10_PAD_STRENGTH_LSB) & WLAN_GPIO_PIN10_PAD_STRENGTH_MASK)
-#define WLAN_GPIO_PIN10_PAD_DRIVER_MSB           2
-#define WLAN_GPIO_PIN10_PAD_DRIVER_LSB           2
-#define WLAN_GPIO_PIN10_PAD_DRIVER_MASK          0x00000004
-#define WLAN_GPIO_PIN10_PAD_DRIVER_GET(x)        (((x) & WLAN_GPIO_PIN10_PAD_DRIVER_MASK) >> WLAN_GPIO_PIN10_PAD_DRIVER_LSB)
-#define WLAN_GPIO_PIN10_PAD_DRIVER_SET(x)        (((x) << WLAN_GPIO_PIN10_PAD_DRIVER_LSB) & WLAN_GPIO_PIN10_PAD_DRIVER_MASK)
-#define WLAN_GPIO_PIN10_SOURCE_MSB               0
-#define WLAN_GPIO_PIN10_SOURCE_LSB               0
-#define WLAN_GPIO_PIN10_SOURCE_MASK              0x00000001
-#define WLAN_GPIO_PIN10_SOURCE_GET(x)            (((x) & WLAN_GPIO_PIN10_SOURCE_MASK) >> WLAN_GPIO_PIN10_SOURCE_LSB)
-#define WLAN_GPIO_PIN10_SOURCE_SET(x)            (((x) << WLAN_GPIO_PIN10_SOURCE_LSB) & WLAN_GPIO_PIN10_SOURCE_MASK)
-
-#define WLAN_GPIO_PIN11_ADDRESS                  0x00000054
-#define WLAN_GPIO_PIN11_OFFSET                   0x00000054
-#define WLAN_GPIO_PIN11_CONFIG_MSB               13
-#define WLAN_GPIO_PIN11_CONFIG_LSB               11
-#define WLAN_GPIO_PIN11_CONFIG_MASK              0x00003800
-#define WLAN_GPIO_PIN11_CONFIG_GET(x)            (((x) & WLAN_GPIO_PIN11_CONFIG_MASK) >> WLAN_GPIO_PIN11_CONFIG_LSB)
-#define WLAN_GPIO_PIN11_CONFIG_SET(x)            (((x) << WLAN_GPIO_PIN11_CONFIG_LSB) & WLAN_GPIO_PIN11_CONFIG_MASK)
-#define WLAN_GPIO_PIN11_WAKEUP_ENABLE_MSB        10
-#define WLAN_GPIO_PIN11_WAKEUP_ENABLE_LSB        10
-#define WLAN_GPIO_PIN11_WAKEUP_ENABLE_MASK       0x00000400
-#define WLAN_GPIO_PIN11_WAKEUP_ENABLE_GET(x)     (((x) & WLAN_GPIO_PIN11_WAKEUP_ENABLE_MASK) >> WLAN_GPIO_PIN11_WAKEUP_ENABLE_LSB)
-#define WLAN_GPIO_PIN11_WAKEUP_ENABLE_SET(x)     (((x) << WLAN_GPIO_PIN11_WAKEUP_ENABLE_LSB) & WLAN_GPIO_PIN11_WAKEUP_ENABLE_MASK)
-#define WLAN_GPIO_PIN11_INT_TYPE_MSB             9
-#define WLAN_GPIO_PIN11_INT_TYPE_LSB             7
-#define WLAN_GPIO_PIN11_INT_TYPE_MASK            0x00000380
-#define WLAN_GPIO_PIN11_INT_TYPE_GET(x)          (((x) & WLAN_GPIO_PIN11_INT_TYPE_MASK) >> WLAN_GPIO_PIN11_INT_TYPE_LSB)
-#define WLAN_GPIO_PIN11_INT_TYPE_SET(x)          (((x) << WLAN_GPIO_PIN11_INT_TYPE_LSB) & WLAN_GPIO_PIN11_INT_TYPE_MASK)
-#define WLAN_GPIO_PIN11_PAD_PULL_MSB             6
-#define WLAN_GPIO_PIN11_PAD_PULL_LSB             5
-#define WLAN_GPIO_PIN11_PAD_PULL_MASK            0x00000060
-#define WLAN_GPIO_PIN11_PAD_PULL_GET(x)          (((x) & WLAN_GPIO_PIN11_PAD_PULL_MASK) >> WLAN_GPIO_PIN11_PAD_PULL_LSB)
-#define WLAN_GPIO_PIN11_PAD_PULL_SET(x)          (((x) << WLAN_GPIO_PIN11_PAD_PULL_LSB) & WLAN_GPIO_PIN11_PAD_PULL_MASK)
-#define WLAN_GPIO_PIN11_PAD_STRENGTH_MSB         4
-#define WLAN_GPIO_PIN11_PAD_STRENGTH_LSB         3
-#define WLAN_GPIO_PIN11_PAD_STRENGTH_MASK        0x00000018
-#define WLAN_GPIO_PIN11_PAD_STRENGTH_GET(x)      (((x) & WLAN_GPIO_PIN11_PAD_STRENGTH_MASK) >> WLAN_GPIO_PIN11_PAD_STRENGTH_LSB)
-#define WLAN_GPIO_PIN11_PAD_STRENGTH_SET(x)      (((x) << WLAN_GPIO_PIN11_PAD_STRENGTH_LSB) & WLAN_GPIO_PIN11_PAD_STRENGTH_MASK)
-#define WLAN_GPIO_PIN11_PAD_DRIVER_MSB           2
-#define WLAN_GPIO_PIN11_PAD_DRIVER_LSB           2
-#define WLAN_GPIO_PIN11_PAD_DRIVER_MASK          0x00000004
-#define WLAN_GPIO_PIN11_PAD_DRIVER_GET(x)        (((x) & WLAN_GPIO_PIN11_PAD_DRIVER_MASK) >> WLAN_GPIO_PIN11_PAD_DRIVER_LSB)
-#define WLAN_GPIO_PIN11_PAD_DRIVER_SET(x)        (((x) << WLAN_GPIO_PIN11_PAD_DRIVER_LSB) & WLAN_GPIO_PIN11_PAD_DRIVER_MASK)
-#define WLAN_GPIO_PIN11_SOURCE_MSB               0
-#define WLAN_GPIO_PIN11_SOURCE_LSB               0
-#define WLAN_GPIO_PIN11_SOURCE_MASK              0x00000001
-#define WLAN_GPIO_PIN11_SOURCE_GET(x)            (((x) & WLAN_GPIO_PIN11_SOURCE_MASK) >> WLAN_GPIO_PIN11_SOURCE_LSB)
-#define WLAN_GPIO_PIN11_SOURCE_SET(x)            (((x) << WLAN_GPIO_PIN11_SOURCE_LSB) & WLAN_GPIO_PIN11_SOURCE_MASK)
-
-#define WLAN_GPIO_PIN12_ADDRESS                  0x00000058
-#define WLAN_GPIO_PIN12_OFFSET                   0x00000058
-#define WLAN_GPIO_PIN12_CONFIG_MSB               13
-#define WLAN_GPIO_PIN12_CONFIG_LSB               11
-#define WLAN_GPIO_PIN12_CONFIG_MASK              0x00003800
-#define WLAN_GPIO_PIN12_CONFIG_GET(x)            (((x) & WLAN_GPIO_PIN12_CONFIG_MASK) >> WLAN_GPIO_PIN12_CONFIG_LSB)
-#define WLAN_GPIO_PIN12_CONFIG_SET(x)            (((x) << WLAN_GPIO_PIN12_CONFIG_LSB) & WLAN_GPIO_PIN12_CONFIG_MASK)
-#define WLAN_GPIO_PIN12_WAKEUP_ENABLE_MSB        10
-#define WLAN_GPIO_PIN12_WAKEUP_ENABLE_LSB        10
-#define WLAN_GPIO_PIN12_WAKEUP_ENABLE_MASK       0x00000400
-#define WLAN_GPIO_PIN12_WAKEUP_ENABLE_GET(x)     (((x) & WLAN_GPIO_PIN12_WAKEUP_ENABLE_MASK) >> WLAN_GPIO_PIN12_WAKEUP_ENABLE_LSB)
-#define WLAN_GPIO_PIN12_WAKEUP_ENABLE_SET(x)     (((x) << WLAN_GPIO_PIN12_WAKEUP_ENABLE_LSB) & WLAN_GPIO_PIN12_WAKEUP_ENABLE_MASK)
-#define WLAN_GPIO_PIN12_INT_TYPE_MSB             9
-#define WLAN_GPIO_PIN12_INT_TYPE_LSB             7
-#define WLAN_GPIO_PIN12_INT_TYPE_MASK            0x00000380
-#define WLAN_GPIO_PIN12_INT_TYPE_GET(x)          (((x) & WLAN_GPIO_PIN12_INT_TYPE_MASK) >> WLAN_GPIO_PIN12_INT_TYPE_LSB)
-#define WLAN_GPIO_PIN12_INT_TYPE_SET(x)          (((x) << WLAN_GPIO_PIN12_INT_TYPE_LSB) & WLAN_GPIO_PIN12_INT_TYPE_MASK)
-#define WLAN_GPIO_PIN12_PAD_PULL_MSB             6
-#define WLAN_GPIO_PIN12_PAD_PULL_LSB             5
-#define WLAN_GPIO_PIN12_PAD_PULL_MASK            0x00000060
-#define WLAN_GPIO_PIN12_PAD_PULL_GET(x)          (((x) & WLAN_GPIO_PIN12_PAD_PULL_MASK) >> WLAN_GPIO_PIN12_PAD_PULL_LSB)
-#define WLAN_GPIO_PIN12_PAD_PULL_SET(x)          (((x) << WLAN_GPIO_PIN12_PAD_PULL_LSB) & WLAN_GPIO_PIN12_PAD_PULL_MASK)
-#define WLAN_GPIO_PIN12_PAD_STRENGTH_MSB         4
-#define WLAN_GPIO_PIN12_PAD_STRENGTH_LSB         3
-#define WLAN_GPIO_PIN12_PAD_STRENGTH_MASK        0x00000018
-#define WLAN_GPIO_PIN12_PAD_STRENGTH_GET(x)      (((x) & WLAN_GPIO_PIN12_PAD_STRENGTH_MASK) >> WLAN_GPIO_PIN12_PAD_STRENGTH_LSB)
-#define WLAN_GPIO_PIN12_PAD_STRENGTH_SET(x)      (((x) << WLAN_GPIO_PIN12_PAD_STRENGTH_LSB) & WLAN_GPIO_PIN12_PAD_STRENGTH_MASK)
-#define WLAN_GPIO_PIN12_PAD_DRIVER_MSB           2
-#define WLAN_GPIO_PIN12_PAD_DRIVER_LSB           2
-#define WLAN_GPIO_PIN12_PAD_DRIVER_MASK          0x00000004
-#define WLAN_GPIO_PIN12_PAD_DRIVER_GET(x)        (((x) & WLAN_GPIO_PIN12_PAD_DRIVER_MASK) >> WLAN_GPIO_PIN12_PAD_DRIVER_LSB)
-#define WLAN_GPIO_PIN12_PAD_DRIVER_SET(x)        (((x) << WLAN_GPIO_PIN12_PAD_DRIVER_LSB) & WLAN_GPIO_PIN12_PAD_DRIVER_MASK)
-#define WLAN_GPIO_PIN12_SOURCE_MSB               0
-#define WLAN_GPIO_PIN12_SOURCE_LSB               0
-#define WLAN_GPIO_PIN12_SOURCE_MASK              0x00000001
-#define WLAN_GPIO_PIN12_SOURCE_GET(x)            (((x) & WLAN_GPIO_PIN12_SOURCE_MASK) >> WLAN_GPIO_PIN12_SOURCE_LSB)
-#define WLAN_GPIO_PIN12_SOURCE_SET(x)            (((x) << WLAN_GPIO_PIN12_SOURCE_LSB) & WLAN_GPIO_PIN12_SOURCE_MASK)
-
-#define WLAN_GPIO_PIN13_ADDRESS                  0x0000005c
-#define WLAN_GPIO_PIN13_OFFSET                   0x0000005c
-#define WLAN_GPIO_PIN13_CONFIG_MSB               13
-#define WLAN_GPIO_PIN13_CONFIG_LSB               11
-#define WLAN_GPIO_PIN13_CONFIG_MASK              0x00003800
-#define WLAN_GPIO_PIN13_CONFIG_GET(x)            (((x) & WLAN_GPIO_PIN13_CONFIG_MASK) >> WLAN_GPIO_PIN13_CONFIG_LSB)
-#define WLAN_GPIO_PIN13_CONFIG_SET(x)            (((x) << WLAN_GPIO_PIN13_CONFIG_LSB) & WLAN_GPIO_PIN13_CONFIG_MASK)
-#define WLAN_GPIO_PIN13_WAKEUP_ENABLE_MSB        10
-#define WLAN_GPIO_PIN13_WAKEUP_ENABLE_LSB        10
-#define WLAN_GPIO_PIN13_WAKEUP_ENABLE_MASK       0x00000400
-#define WLAN_GPIO_PIN13_WAKEUP_ENABLE_GET(x)     (((x) & WLAN_GPIO_PIN13_WAKEUP_ENABLE_MASK) >> WLAN_GPIO_PIN13_WAKEUP_ENABLE_LSB)
-#define WLAN_GPIO_PIN13_WAKEUP_ENABLE_SET(x)     (((x) << WLAN_GPIO_PIN13_WAKEUP_ENABLE_LSB) & WLAN_GPIO_PIN13_WAKEUP_ENABLE_MASK)
-#define WLAN_GPIO_PIN13_INT_TYPE_MSB             9
-#define WLAN_GPIO_PIN13_INT_TYPE_LSB             7
-#define WLAN_GPIO_PIN13_INT_TYPE_MASK            0x00000380
-#define WLAN_GPIO_PIN13_INT_TYPE_GET(x)          (((x) & WLAN_GPIO_PIN13_INT_TYPE_MASK) >> WLAN_GPIO_PIN13_INT_TYPE_LSB)
-#define WLAN_GPIO_PIN13_INT_TYPE_SET(x)          (((x) << WLAN_GPIO_PIN13_INT_TYPE_LSB) & WLAN_GPIO_PIN13_INT_TYPE_MASK)
-#define WLAN_GPIO_PIN13_PAD_PULL_MSB             6
-#define WLAN_GPIO_PIN13_PAD_PULL_LSB             5
-#define WLAN_GPIO_PIN13_PAD_PULL_MASK            0x00000060
-#define WLAN_GPIO_PIN13_PAD_PULL_GET(x)          (((x) & WLAN_GPIO_PIN13_PAD_PULL_MASK) >> WLAN_GPIO_PIN13_PAD_PULL_LSB)
-#define WLAN_GPIO_PIN13_PAD_PULL_SET(x)          (((x) << WLAN_GPIO_PIN13_PAD_PULL_LSB) & WLAN_GPIO_PIN13_PAD_PULL_MASK)
-#define WLAN_GPIO_PIN13_PAD_STRENGTH_MSB         4
-#define WLAN_GPIO_PIN13_PAD_STRENGTH_LSB         3
-#define WLAN_GPIO_PIN13_PAD_STRENGTH_MASK        0x00000018
-#define WLAN_GPIO_PIN13_PAD_STRENGTH_GET(x)      (((x) & WLAN_GPIO_PIN13_PAD_STRENGTH_MASK) >> WLAN_GPIO_PIN13_PAD_STRENGTH_LSB)
-#define WLAN_GPIO_PIN13_PAD_STRENGTH_SET(x)      (((x) << WLAN_GPIO_PIN13_PAD_STRENGTH_LSB) & WLAN_GPIO_PIN13_PAD_STRENGTH_MASK)
-#define WLAN_GPIO_PIN13_PAD_DRIVER_MSB           2
-#define WLAN_GPIO_PIN13_PAD_DRIVER_LSB           2
-#define WLAN_GPIO_PIN13_PAD_DRIVER_MASK          0x00000004
-#define WLAN_GPIO_PIN13_PAD_DRIVER_GET(x)        (((x) & WLAN_GPIO_PIN13_PAD_DRIVER_MASK) >> WLAN_GPIO_PIN13_PAD_DRIVER_LSB)
-#define WLAN_GPIO_PIN13_PAD_DRIVER_SET(x)        (((x) << WLAN_GPIO_PIN13_PAD_DRIVER_LSB) & WLAN_GPIO_PIN13_PAD_DRIVER_MASK)
-#define WLAN_GPIO_PIN13_SOURCE_MSB               0
-#define WLAN_GPIO_PIN13_SOURCE_LSB               0
-#define WLAN_GPIO_PIN13_SOURCE_MASK              0x00000001
-#define WLAN_GPIO_PIN13_SOURCE_GET(x)            (((x) & WLAN_GPIO_PIN13_SOURCE_MASK) >> WLAN_GPIO_PIN13_SOURCE_LSB)
-#define WLAN_GPIO_PIN13_SOURCE_SET(x)            (((x) << WLAN_GPIO_PIN13_SOURCE_LSB) & WLAN_GPIO_PIN13_SOURCE_MASK)
-
-#define WLAN_GPIO_PIN14_ADDRESS                  0x00000060
-#define WLAN_GPIO_PIN14_OFFSET                   0x00000060
-#define WLAN_GPIO_PIN14_CONFIG_MSB               13
-#define WLAN_GPIO_PIN14_CONFIG_LSB               11
-#define WLAN_GPIO_PIN14_CONFIG_MASK              0x00003800
-#define WLAN_GPIO_PIN14_CONFIG_GET(x)            (((x) & WLAN_GPIO_PIN14_CONFIG_MASK) >> WLAN_GPIO_PIN14_CONFIG_LSB)
-#define WLAN_GPIO_PIN14_CONFIG_SET(x)            (((x) << WLAN_GPIO_PIN14_CONFIG_LSB) & WLAN_GPIO_PIN14_CONFIG_MASK)
-#define WLAN_GPIO_PIN14_WAKEUP_ENABLE_MSB        10
-#define WLAN_GPIO_PIN14_WAKEUP_ENABLE_LSB        10
-#define WLAN_GPIO_PIN14_WAKEUP_ENABLE_MASK       0x00000400
-#define WLAN_GPIO_PIN14_WAKEUP_ENABLE_GET(x)     (((x) & WLAN_GPIO_PIN14_WAKEUP_ENABLE_MASK) >> WLAN_GPIO_PIN14_WAKEUP_ENABLE_LSB)
-#define WLAN_GPIO_PIN14_WAKEUP_ENABLE_SET(x)     (((x) << WLAN_GPIO_PIN14_WAKEUP_ENABLE_LSB) & WLAN_GPIO_PIN14_WAKEUP_ENABLE_MASK)
-#define WLAN_GPIO_PIN14_INT_TYPE_MSB             9
-#define WLAN_GPIO_PIN14_INT_TYPE_LSB             7
-#define WLAN_GPIO_PIN14_INT_TYPE_MASK            0x00000380
-#define WLAN_GPIO_PIN14_INT_TYPE_GET(x)          (((x) & WLAN_GPIO_PIN14_INT_TYPE_MASK) >> WLAN_GPIO_PIN14_INT_TYPE_LSB)
-#define WLAN_GPIO_PIN14_INT_TYPE_SET(x)          (((x) << WLAN_GPIO_PIN14_INT_TYPE_LSB) & WLAN_GPIO_PIN14_INT_TYPE_MASK)
-#define WLAN_GPIO_PIN14_PAD_PULL_MSB             6
-#define WLAN_GPIO_PIN14_PAD_PULL_LSB             5
-#define WLAN_GPIO_PIN14_PAD_PULL_MASK            0x00000060
-#define WLAN_GPIO_PIN14_PAD_PULL_GET(x)          (((x) & WLAN_GPIO_PIN14_PAD_PULL_MASK) >> WLAN_GPIO_PIN14_PAD_PULL_LSB)
-#define WLAN_GPIO_PIN14_PAD_PULL_SET(x)          (((x) << WLAN_GPIO_PIN14_PAD_PULL_LSB) & WLAN_GPIO_PIN14_PAD_PULL_MASK)
-#define WLAN_GPIO_PIN14_PAD_STRENGTH_MSB         4
-#define WLAN_GPIO_PIN14_PAD_STRENGTH_LSB         3
-#define WLAN_GPIO_PIN14_PAD_STRENGTH_MASK        0x00000018
-#define WLAN_GPIO_PIN14_PAD_STRENGTH_GET(x)      (((x) & WLAN_GPIO_PIN14_PAD_STRENGTH_MASK) >> WLAN_GPIO_PIN14_PAD_STRENGTH_LSB)
-#define WLAN_GPIO_PIN14_PAD_STRENGTH_SET(x)      (((x) << WLAN_GPIO_PIN14_PAD_STRENGTH_LSB) & WLAN_GPIO_PIN14_PAD_STRENGTH_MASK)
-#define WLAN_GPIO_PIN14_PAD_DRIVER_MSB           2
-#define WLAN_GPIO_PIN14_PAD_DRIVER_LSB           2
-#define WLAN_GPIO_PIN14_PAD_DRIVER_MASK          0x00000004
-#define WLAN_GPIO_PIN14_PAD_DRIVER_GET(x)        (((x) & WLAN_GPIO_PIN14_PAD_DRIVER_MASK) >> WLAN_GPIO_PIN14_PAD_DRIVER_LSB)
-#define WLAN_GPIO_PIN14_PAD_DRIVER_SET(x)        (((x) << WLAN_GPIO_PIN14_PAD_DRIVER_LSB) & WLAN_GPIO_PIN14_PAD_DRIVER_MASK)
-#define WLAN_GPIO_PIN14_SOURCE_MSB               0
-#define WLAN_GPIO_PIN14_SOURCE_LSB               0
-#define WLAN_GPIO_PIN14_SOURCE_MASK              0x00000001
-#define WLAN_GPIO_PIN14_SOURCE_GET(x)            (((x) & WLAN_GPIO_PIN14_SOURCE_MASK) >> WLAN_GPIO_PIN14_SOURCE_LSB)
-#define WLAN_GPIO_PIN14_SOURCE_SET(x)            (((x) << WLAN_GPIO_PIN14_SOURCE_LSB) & WLAN_GPIO_PIN14_SOURCE_MASK)
-
-#define WLAN_GPIO_PIN15_ADDRESS                  0x00000064
-#define WLAN_GPIO_PIN15_OFFSET                   0x00000064
-#define WLAN_GPIO_PIN15_CONFIG_MSB               13
-#define WLAN_GPIO_PIN15_CONFIG_LSB               11
-#define WLAN_GPIO_PIN15_CONFIG_MASK              0x00003800
-#define WLAN_GPIO_PIN15_CONFIG_GET(x)            (((x) & WLAN_GPIO_PIN15_CONFIG_MASK) >> WLAN_GPIO_PIN15_CONFIG_LSB)
-#define WLAN_GPIO_PIN15_CONFIG_SET(x)            (((x) << WLAN_GPIO_PIN15_CONFIG_LSB) & WLAN_GPIO_PIN15_CONFIG_MASK)
-#define WLAN_GPIO_PIN15_WAKEUP_ENABLE_MSB        10
-#define WLAN_GPIO_PIN15_WAKEUP_ENABLE_LSB        10
-#define WLAN_GPIO_PIN15_WAKEUP_ENABLE_MASK       0x00000400
-#define WLAN_GPIO_PIN15_WAKEUP_ENABLE_GET(x)     (((x) & WLAN_GPIO_PIN15_WAKEUP_ENABLE_MASK) >> WLAN_GPIO_PIN15_WAKEUP_ENABLE_LSB)
-#define WLAN_GPIO_PIN15_WAKEUP_ENABLE_SET(x)     (((x) << WLAN_GPIO_PIN15_WAKEUP_ENABLE_LSB) & WLAN_GPIO_PIN15_WAKEUP_ENABLE_MASK)
-#define WLAN_GPIO_PIN15_INT_TYPE_MSB             9
-#define WLAN_GPIO_PIN15_INT_TYPE_LSB             7
-#define WLAN_GPIO_PIN15_INT_TYPE_MASK            0x00000380
-#define WLAN_GPIO_PIN15_INT_TYPE_GET(x)          (((x) & WLAN_GPIO_PIN15_INT_TYPE_MASK) >> WLAN_GPIO_PIN15_INT_TYPE_LSB)
-#define WLAN_GPIO_PIN15_INT_TYPE_SET(x)          (((x) << WLAN_GPIO_PIN15_INT_TYPE_LSB) & WLAN_GPIO_PIN15_INT_TYPE_MASK)
-#define WLAN_GPIO_PIN15_PAD_PULL_MSB             6
-#define WLAN_GPIO_PIN15_PAD_PULL_LSB             5
-#define WLAN_GPIO_PIN15_PAD_PULL_MASK            0x00000060
-#define WLAN_GPIO_PIN15_PAD_PULL_GET(x)          (((x) & WLAN_GPIO_PIN15_PAD_PULL_MASK) >> WLAN_GPIO_PIN15_PAD_PULL_LSB)
-#define WLAN_GPIO_PIN15_PAD_PULL_SET(x)          (((x) << WLAN_GPIO_PIN15_PAD_PULL_LSB) & WLAN_GPIO_PIN15_PAD_PULL_MASK)
-#define WLAN_GPIO_PIN15_PAD_STRENGTH_MSB         4
-#define WLAN_GPIO_PIN15_PAD_STRENGTH_LSB         3
-#define WLAN_GPIO_PIN15_PAD_STRENGTH_MASK        0x00000018
-#define WLAN_GPIO_PIN15_PAD_STRENGTH_GET(x)      (((x) & WLAN_GPIO_PIN15_PAD_STRENGTH_MASK) >> WLAN_GPIO_PIN15_PAD_STRENGTH_LSB)
-#define WLAN_GPIO_PIN15_PAD_STRENGTH_SET(x)      (((x) << WLAN_GPIO_PIN15_PAD_STRENGTH_LSB) & WLAN_GPIO_PIN15_PAD_STRENGTH_MASK)
-#define WLAN_GPIO_PIN15_PAD_DRIVER_MSB           2
-#define WLAN_GPIO_PIN15_PAD_DRIVER_LSB           2
-#define WLAN_GPIO_PIN15_PAD_DRIVER_MASK          0x00000004
-#define WLAN_GPIO_PIN15_PAD_DRIVER_GET(x)        (((x) & WLAN_GPIO_PIN15_PAD_DRIVER_MASK) >> WLAN_GPIO_PIN15_PAD_DRIVER_LSB)
-#define WLAN_GPIO_PIN15_PAD_DRIVER_SET(x)        (((x) << WLAN_GPIO_PIN15_PAD_DRIVER_LSB) & WLAN_GPIO_PIN15_PAD_DRIVER_MASK)
-#define WLAN_GPIO_PIN15_SOURCE_MSB               0
-#define WLAN_GPIO_PIN15_SOURCE_LSB               0
-#define WLAN_GPIO_PIN15_SOURCE_MASK              0x00000001
-#define WLAN_GPIO_PIN15_SOURCE_GET(x)            (((x) & WLAN_GPIO_PIN15_SOURCE_MASK) >> WLAN_GPIO_PIN15_SOURCE_LSB)
-#define WLAN_GPIO_PIN15_SOURCE_SET(x)            (((x) << WLAN_GPIO_PIN15_SOURCE_LSB) & WLAN_GPIO_PIN15_SOURCE_MASK)
-
-#define WLAN_GPIO_PIN16_ADDRESS                  0x00000068
-#define WLAN_GPIO_PIN16_OFFSET                   0x00000068
-#define WLAN_GPIO_PIN16_CONFIG_MSB               13
-#define WLAN_GPIO_PIN16_CONFIG_LSB               11
-#define WLAN_GPIO_PIN16_CONFIG_MASK              0x00003800
-#define WLAN_GPIO_PIN16_CONFIG_GET(x)            (((x) & WLAN_GPIO_PIN16_CONFIG_MASK) >> WLAN_GPIO_PIN16_CONFIG_LSB)
-#define WLAN_GPIO_PIN16_CONFIG_SET(x)            (((x) << WLAN_GPIO_PIN16_CONFIG_LSB) & WLAN_GPIO_PIN16_CONFIG_MASK)
-#define WLAN_GPIO_PIN16_WAKEUP_ENABLE_MSB        10
-#define WLAN_GPIO_PIN16_WAKEUP_ENABLE_LSB        10
-#define WLAN_GPIO_PIN16_WAKEUP_ENABLE_MASK       0x00000400
-#define WLAN_GPIO_PIN16_WAKEUP_ENABLE_GET(x)     (((x) & WLAN_GPIO_PIN16_WAKEUP_ENABLE_MASK) >> WLAN_GPIO_PIN16_WAKEUP_ENABLE_LSB)
-#define WLAN_GPIO_PIN16_WAKEUP_ENABLE_SET(x)     (((x) << WLAN_GPIO_PIN16_WAKEUP_ENABLE_LSB) & WLAN_GPIO_PIN16_WAKEUP_ENABLE_MASK)
-#define WLAN_GPIO_PIN16_INT_TYPE_MSB             9
-#define WLAN_GPIO_PIN16_INT_TYPE_LSB             7
-#define WLAN_GPIO_PIN16_INT_TYPE_MASK            0x00000380
-#define WLAN_GPIO_PIN16_INT_TYPE_GET(x)          (((x) & WLAN_GPIO_PIN16_INT_TYPE_MASK) >> WLAN_GPIO_PIN16_INT_TYPE_LSB)
-#define WLAN_GPIO_PIN16_INT_TYPE_SET(x)          (((x) << WLAN_GPIO_PIN16_INT_TYPE_LSB) & WLAN_GPIO_PIN16_INT_TYPE_MASK)
-#define WLAN_GPIO_PIN16_PAD_PULL_MSB             6
-#define WLAN_GPIO_PIN16_PAD_PULL_LSB             5
-#define WLAN_GPIO_PIN16_PAD_PULL_MASK            0x00000060
-#define WLAN_GPIO_PIN16_PAD_PULL_GET(x)          (((x) & WLAN_GPIO_PIN16_PAD_PULL_MASK) >> WLAN_GPIO_PIN16_PAD_PULL_LSB)
-#define WLAN_GPIO_PIN16_PAD_PULL_SET(x)          (((x) << WLAN_GPIO_PIN16_PAD_PULL_LSB) & WLAN_GPIO_PIN16_PAD_PULL_MASK)
-#define WLAN_GPIO_PIN16_PAD_STRENGTH_MSB         4
-#define WLAN_GPIO_PIN16_PAD_STRENGTH_LSB         3
-#define WLAN_GPIO_PIN16_PAD_STRENGTH_MASK        0x00000018
-#define WLAN_GPIO_PIN16_PAD_STRENGTH_GET(x)      (((x) & WLAN_GPIO_PIN16_PAD_STRENGTH_MASK) >> WLAN_GPIO_PIN16_PAD_STRENGTH_LSB)
-#define WLAN_GPIO_PIN16_PAD_STRENGTH_SET(x)      (((x) << WLAN_GPIO_PIN16_PAD_STRENGTH_LSB) & WLAN_GPIO_PIN16_PAD_STRENGTH_MASK)
-#define WLAN_GPIO_PIN16_PAD_DRIVER_MSB           2
-#define WLAN_GPIO_PIN16_PAD_DRIVER_LSB           2
-#define WLAN_GPIO_PIN16_PAD_DRIVER_MASK          0x00000004
-#define WLAN_GPIO_PIN16_PAD_DRIVER_GET(x)        (((x) & WLAN_GPIO_PIN16_PAD_DRIVER_MASK) >> WLAN_GPIO_PIN16_PAD_DRIVER_LSB)
-#define WLAN_GPIO_PIN16_PAD_DRIVER_SET(x)        (((x) << WLAN_GPIO_PIN16_PAD_DRIVER_LSB) & WLAN_GPIO_PIN16_PAD_DRIVER_MASK)
-#define WLAN_GPIO_PIN16_SOURCE_MSB               0
-#define WLAN_GPIO_PIN16_SOURCE_LSB               0
-#define WLAN_GPIO_PIN16_SOURCE_MASK              0x00000001
-#define WLAN_GPIO_PIN16_SOURCE_GET(x)            (((x) & WLAN_GPIO_PIN16_SOURCE_MASK) >> WLAN_GPIO_PIN16_SOURCE_LSB)
-#define WLAN_GPIO_PIN16_SOURCE_SET(x)            (((x) << WLAN_GPIO_PIN16_SOURCE_LSB) & WLAN_GPIO_PIN16_SOURCE_MASK)
-
-#define WLAN_GPIO_PIN17_ADDRESS                  0x0000006c
-#define WLAN_GPIO_PIN17_OFFSET                   0x0000006c
-#define WLAN_GPIO_PIN17_CONFIG_MSB               13
-#define WLAN_GPIO_PIN17_CONFIG_LSB               11
-#define WLAN_GPIO_PIN17_CONFIG_MASK              0x00003800
-#define WLAN_GPIO_PIN17_CONFIG_GET(x)            (((x) & WLAN_GPIO_PIN17_CONFIG_MASK) >> WLAN_GPIO_PIN17_CONFIG_LSB)
-#define WLAN_GPIO_PIN17_CONFIG_SET(x)            (((x) << WLAN_GPIO_PIN17_CONFIG_LSB) & WLAN_GPIO_PIN17_CONFIG_MASK)
-#define WLAN_GPIO_PIN17_WAKEUP_ENABLE_MSB        10
-#define WLAN_GPIO_PIN17_WAKEUP_ENABLE_LSB        10
-#define WLAN_GPIO_PIN17_WAKEUP_ENABLE_MASK       0x00000400
-#define WLAN_GPIO_PIN17_WAKEUP_ENABLE_GET(x)     (((x) & WLAN_GPIO_PIN17_WAKEUP_ENABLE_MASK) >> WLAN_GPIO_PIN17_WAKEUP_ENABLE_LSB)
-#define WLAN_GPIO_PIN17_WAKEUP_ENABLE_SET(x)     (((x) << WLAN_GPIO_PIN17_WAKEUP_ENABLE_LSB) & WLAN_GPIO_PIN17_WAKEUP_ENABLE_MASK)
-#define WLAN_GPIO_PIN17_INT_TYPE_MSB             9
-#define WLAN_GPIO_PIN17_INT_TYPE_LSB             7
-#define WLAN_GPIO_PIN17_INT_TYPE_MASK            0x00000380
-#define WLAN_GPIO_PIN17_INT_TYPE_GET(x)          (((x) & WLAN_GPIO_PIN17_INT_TYPE_MASK) >> WLAN_GPIO_PIN17_INT_TYPE_LSB)
-#define WLAN_GPIO_PIN17_INT_TYPE_SET(x)          (((x) << WLAN_GPIO_PIN17_INT_TYPE_LSB) & WLAN_GPIO_PIN17_INT_TYPE_MASK)
-#define WLAN_GPIO_PIN17_PAD_PULL_MSB             6
-#define WLAN_GPIO_PIN17_PAD_PULL_LSB             5
-#define WLAN_GPIO_PIN17_PAD_PULL_MASK            0x00000060
-#define WLAN_GPIO_PIN17_PAD_PULL_GET(x)          (((x) & WLAN_GPIO_PIN17_PAD_PULL_MASK) >> WLAN_GPIO_PIN17_PAD_PULL_LSB)
-#define WLAN_GPIO_PIN17_PAD_PULL_SET(x)          (((x) << WLAN_GPIO_PIN17_PAD_PULL_LSB) & WLAN_GPIO_PIN17_PAD_PULL_MASK)
-#define WLAN_GPIO_PIN17_PAD_STRENGTH_MSB         4
-#define WLAN_GPIO_PIN17_PAD_STRENGTH_LSB         3
-#define WLAN_GPIO_PIN17_PAD_STRENGTH_MASK        0x00000018
-#define WLAN_GPIO_PIN17_PAD_STRENGTH_GET(x)      (((x) & WLAN_GPIO_PIN17_PAD_STRENGTH_MASK) >> WLAN_GPIO_PIN17_PAD_STRENGTH_LSB)
-#define WLAN_GPIO_PIN17_PAD_STRENGTH_SET(x)      (((x) << WLAN_GPIO_PIN17_PAD_STRENGTH_LSB) & WLAN_GPIO_PIN17_PAD_STRENGTH_MASK)
-#define WLAN_GPIO_PIN17_PAD_DRIVER_MSB           2
-#define WLAN_GPIO_PIN17_PAD_DRIVER_LSB           2
-#define WLAN_GPIO_PIN17_PAD_DRIVER_MASK          0x00000004
-#define WLAN_GPIO_PIN17_PAD_DRIVER_GET(x)        (((x) & WLAN_GPIO_PIN17_PAD_DRIVER_MASK) >> WLAN_GPIO_PIN17_PAD_DRIVER_LSB)
-#define WLAN_GPIO_PIN17_PAD_DRIVER_SET(x)        (((x) << WLAN_GPIO_PIN17_PAD_DRIVER_LSB) & WLAN_GPIO_PIN17_PAD_DRIVER_MASK)
-#define WLAN_GPIO_PIN17_SOURCE_MSB               0
-#define WLAN_GPIO_PIN17_SOURCE_LSB               0
-#define WLAN_GPIO_PIN17_SOURCE_MASK              0x00000001
-#define WLAN_GPIO_PIN17_SOURCE_GET(x)            (((x) & WLAN_GPIO_PIN17_SOURCE_MASK) >> WLAN_GPIO_PIN17_SOURCE_LSB)
-#define WLAN_GPIO_PIN17_SOURCE_SET(x)            (((x) << WLAN_GPIO_PIN17_SOURCE_LSB) & WLAN_GPIO_PIN17_SOURCE_MASK)
-
-#define WLAN_GPIO_PIN18_ADDRESS                  0x00000070
-#define WLAN_GPIO_PIN18_OFFSET                   0x00000070
-#define WLAN_GPIO_PIN18_CONFIG_MSB               13
-#define WLAN_GPIO_PIN18_CONFIG_LSB               11
-#define WLAN_GPIO_PIN18_CONFIG_MASK              0x00003800
-#define WLAN_GPIO_PIN18_CONFIG_GET(x)            (((x) & WLAN_GPIO_PIN18_CONFIG_MASK) >> WLAN_GPIO_PIN18_CONFIG_LSB)
-#define WLAN_GPIO_PIN18_CONFIG_SET(x)            (((x) << WLAN_GPIO_PIN18_CONFIG_LSB) & WLAN_GPIO_PIN18_CONFIG_MASK)
-#define WLAN_GPIO_PIN18_WAKEUP_ENABLE_MSB        10
-#define WLAN_GPIO_PIN18_WAKEUP_ENABLE_LSB        10
-#define WLAN_GPIO_PIN18_WAKEUP_ENABLE_MASK       0x00000400
-#define WLAN_GPIO_PIN18_WAKEUP_ENABLE_GET(x)     (((x) & WLAN_GPIO_PIN18_WAKEUP_ENABLE_MASK) >> WLAN_GPIO_PIN18_WAKEUP_ENABLE_LSB)
-#define WLAN_GPIO_PIN18_WAKEUP_ENABLE_SET(x)     (((x) << WLAN_GPIO_PIN18_WAKEUP_ENABLE_LSB) & WLAN_GPIO_PIN18_WAKEUP_ENABLE_MASK)
-#define WLAN_GPIO_PIN18_INT_TYPE_MSB             9
-#define WLAN_GPIO_PIN18_INT_TYPE_LSB             7
-#define WLAN_GPIO_PIN18_INT_TYPE_MASK            0x00000380
-#define WLAN_GPIO_PIN18_INT_TYPE_GET(x)          (((x) & WLAN_GPIO_PIN18_INT_TYPE_MASK) >> WLAN_GPIO_PIN18_INT_TYPE_LSB)
-#define WLAN_GPIO_PIN18_INT_TYPE_SET(x)          (((x) << WLAN_GPIO_PIN18_INT_TYPE_LSB) & WLAN_GPIO_PIN18_INT_TYPE_MASK)
-#define WLAN_GPIO_PIN18_PAD_PULL_MSB             6
-#define WLAN_GPIO_PIN18_PAD_PULL_LSB             5
-#define WLAN_GPIO_PIN18_PAD_PULL_MASK            0x00000060
-#define WLAN_GPIO_PIN18_PAD_PULL_GET(x)          (((x) & WLAN_GPIO_PIN18_PAD_PULL_MASK) >> WLAN_GPIO_PIN18_PAD_PULL_LSB)
-#define WLAN_GPIO_PIN18_PAD_PULL_SET(x)          (((x) << WLAN_GPIO_PIN18_PAD_PULL_LSB) & WLAN_GPIO_PIN18_PAD_PULL_MASK)
-#define WLAN_GPIO_PIN18_PAD_STRENGTH_MSB         4
-#define WLAN_GPIO_PIN18_PAD_STRENGTH_LSB         3
-#define WLAN_GPIO_PIN18_PAD_STRENGTH_MASK        0x00000018
-#define WLAN_GPIO_PIN18_PAD_STRENGTH_GET(x)      (((x) & WLAN_GPIO_PIN18_PAD_STRENGTH_MASK) >> WLAN_GPIO_PIN18_PAD_STRENGTH_LSB)
-#define WLAN_GPIO_PIN18_PAD_STRENGTH_SET(x)      (((x) << WLAN_GPIO_PIN18_PAD_STRENGTH_LSB) & WLAN_GPIO_PIN18_PAD_STRENGTH_MASK)
-#define WLAN_GPIO_PIN18_PAD_DRIVER_MSB           2
-#define WLAN_GPIO_PIN18_PAD_DRIVER_LSB           2
-#define WLAN_GPIO_PIN18_PAD_DRIVER_MASK          0x00000004
-#define WLAN_GPIO_PIN18_PAD_DRIVER_GET(x)        (((x) & WLAN_GPIO_PIN18_PAD_DRIVER_MASK) >> WLAN_GPIO_PIN18_PAD_DRIVER_LSB)
-#define WLAN_GPIO_PIN18_PAD_DRIVER_SET(x)        (((x) << WLAN_GPIO_PIN18_PAD_DRIVER_LSB) & WLAN_GPIO_PIN18_PAD_DRIVER_MASK)
-#define WLAN_GPIO_PIN18_SOURCE_MSB               0
-#define WLAN_GPIO_PIN18_SOURCE_LSB               0
-#define WLAN_GPIO_PIN18_SOURCE_MASK              0x00000001
-#define WLAN_GPIO_PIN18_SOURCE_GET(x)            (((x) & WLAN_GPIO_PIN18_SOURCE_MASK) >> WLAN_GPIO_PIN18_SOURCE_LSB)
-#define WLAN_GPIO_PIN18_SOURCE_SET(x)            (((x) << WLAN_GPIO_PIN18_SOURCE_LSB) & WLAN_GPIO_PIN18_SOURCE_MASK)
-
-#define WLAN_GPIO_PIN19_ADDRESS                  0x00000074
-#define WLAN_GPIO_PIN19_OFFSET                   0x00000074
-#define WLAN_GPIO_PIN19_CONFIG_MSB               13
-#define WLAN_GPIO_PIN19_CONFIG_LSB               11
-#define WLAN_GPIO_PIN19_CONFIG_MASK              0x00003800
-#define WLAN_GPIO_PIN19_CONFIG_GET(x)            (((x) & WLAN_GPIO_PIN19_CONFIG_MASK) >> WLAN_GPIO_PIN19_CONFIG_LSB)
-#define WLAN_GPIO_PIN19_CONFIG_SET(x)            (((x) << WLAN_GPIO_PIN19_CONFIG_LSB) & WLAN_GPIO_PIN19_CONFIG_MASK)
-#define WLAN_GPIO_PIN19_WAKEUP_ENABLE_MSB        10
-#define WLAN_GPIO_PIN19_WAKEUP_ENABLE_LSB        10
-#define WLAN_GPIO_PIN19_WAKEUP_ENABLE_MASK       0x00000400
-#define WLAN_GPIO_PIN19_WAKEUP_ENABLE_GET(x)     (((x) & WLAN_GPIO_PIN19_WAKEUP_ENABLE_MASK) >> WLAN_GPIO_PIN19_WAKEUP_ENABLE_LSB)
-#define WLAN_GPIO_PIN19_WAKEUP_ENABLE_SET(x)     (((x) << WLAN_GPIO_PIN19_WAKEUP_ENABLE_LSB) & WLAN_GPIO_PIN19_WAKEUP_ENABLE_MASK)
-#define WLAN_GPIO_PIN19_INT_TYPE_MSB             9
-#define WLAN_GPIO_PIN19_INT_TYPE_LSB             7
-#define WLAN_GPIO_PIN19_INT_TYPE_MASK            0x00000380
-#define WLAN_GPIO_PIN19_INT_TYPE_GET(x)          (((x) & WLAN_GPIO_PIN19_INT_TYPE_MASK) >> WLAN_GPIO_PIN19_INT_TYPE_LSB)
-#define WLAN_GPIO_PIN19_INT_TYPE_SET(x)          (((x) << WLAN_GPIO_PIN19_INT_TYPE_LSB) & WLAN_GPIO_PIN19_INT_TYPE_MASK)
-#define WLAN_GPIO_PIN19_PAD_PULL_MSB             6
-#define WLAN_GPIO_PIN19_PAD_PULL_LSB             5
-#define WLAN_GPIO_PIN19_PAD_PULL_MASK            0x00000060
-#define WLAN_GPIO_PIN19_PAD_PULL_GET(x)          (((x) & WLAN_GPIO_PIN19_PAD_PULL_MASK) >> WLAN_GPIO_PIN19_PAD_PULL_LSB)
-#define WLAN_GPIO_PIN19_PAD_PULL_SET(x)          (((x) << WLAN_GPIO_PIN19_PAD_PULL_LSB) & WLAN_GPIO_PIN19_PAD_PULL_MASK)
-#define WLAN_GPIO_PIN19_PAD_STRENGTH_MSB         4
-#define WLAN_GPIO_PIN19_PAD_STRENGTH_LSB         3
-#define WLAN_GPIO_PIN19_PAD_STRENGTH_MASK        0x00000018
-#define WLAN_GPIO_PIN19_PAD_STRENGTH_GET(x)      (((x) & WLAN_GPIO_PIN19_PAD_STRENGTH_MASK) >> WLAN_GPIO_PIN19_PAD_STRENGTH_LSB)
-#define WLAN_GPIO_PIN19_PAD_STRENGTH_SET(x)      (((x) << WLAN_GPIO_PIN19_PAD_STRENGTH_LSB) & WLAN_GPIO_PIN19_PAD_STRENGTH_MASK)
-#define WLAN_GPIO_PIN19_PAD_DRIVER_MSB           2
-#define WLAN_GPIO_PIN19_PAD_DRIVER_LSB           2
-#define WLAN_GPIO_PIN19_PAD_DRIVER_MASK          0x00000004
-#define WLAN_GPIO_PIN19_PAD_DRIVER_GET(x)        (((x) & WLAN_GPIO_PIN19_PAD_DRIVER_MASK) >> WLAN_GPIO_PIN19_PAD_DRIVER_LSB)
-#define WLAN_GPIO_PIN19_PAD_DRIVER_SET(x)        (((x) << WLAN_GPIO_PIN19_PAD_DRIVER_LSB) & WLAN_GPIO_PIN19_PAD_DRIVER_MASK)
-#define WLAN_GPIO_PIN19_SOURCE_MSB               0
-#define WLAN_GPIO_PIN19_SOURCE_LSB               0
-#define WLAN_GPIO_PIN19_SOURCE_MASK              0x00000001
-#define WLAN_GPIO_PIN19_SOURCE_GET(x)            (((x) & WLAN_GPIO_PIN19_SOURCE_MASK) >> WLAN_GPIO_PIN19_SOURCE_LSB)
-#define WLAN_GPIO_PIN19_SOURCE_SET(x)            (((x) << WLAN_GPIO_PIN19_SOURCE_LSB) & WLAN_GPIO_PIN19_SOURCE_MASK)
-
-#define WLAN_GPIO_PIN20_ADDRESS                  0x00000078
-#define WLAN_GPIO_PIN20_OFFSET                   0x00000078
-#define WLAN_GPIO_PIN20_CONFIG_MSB               13
-#define WLAN_GPIO_PIN20_CONFIG_LSB               11
-#define WLAN_GPIO_PIN20_CONFIG_MASK              0x00003800
-#define WLAN_GPIO_PIN20_CONFIG_GET(x)            (((x) & WLAN_GPIO_PIN20_CONFIG_MASK) >> WLAN_GPIO_PIN20_CONFIG_LSB)
-#define WLAN_GPIO_PIN20_CONFIG_SET(x)            (((x) << WLAN_GPIO_PIN20_CONFIG_LSB) & WLAN_GPIO_PIN20_CONFIG_MASK)
-#define WLAN_GPIO_PIN20_WAKEUP_ENABLE_MSB        10
-#define WLAN_GPIO_PIN20_WAKEUP_ENABLE_LSB        10
-#define WLAN_GPIO_PIN20_WAKEUP_ENABLE_MASK       0x00000400
-#define WLAN_GPIO_PIN20_WAKEUP_ENABLE_GET(x)     (((x) & WLAN_GPIO_PIN20_WAKEUP_ENABLE_MASK) >> WLAN_GPIO_PIN20_WAKEUP_ENABLE_LSB)
-#define WLAN_GPIO_PIN20_WAKEUP_ENABLE_SET(x)     (((x) << WLAN_GPIO_PIN20_WAKEUP_ENABLE_LSB) & WLAN_GPIO_PIN20_WAKEUP_ENABLE_MASK)
-#define WLAN_GPIO_PIN20_INT_TYPE_MSB             9
-#define WLAN_GPIO_PIN20_INT_TYPE_LSB             7
-#define WLAN_GPIO_PIN20_INT_TYPE_MASK            0x00000380
-#define WLAN_GPIO_PIN20_INT_TYPE_GET(x)          (((x) & WLAN_GPIO_PIN20_INT_TYPE_MASK) >> WLAN_GPIO_PIN20_INT_TYPE_LSB)
-#define WLAN_GPIO_PIN20_INT_TYPE_SET(x)          (((x) << WLAN_GPIO_PIN20_INT_TYPE_LSB) & WLAN_GPIO_PIN20_INT_TYPE_MASK)
-#define WLAN_GPIO_PIN20_PAD_PULL_MSB             6
-#define WLAN_GPIO_PIN20_PAD_PULL_LSB             5
-#define WLAN_GPIO_PIN20_PAD_PULL_MASK            0x00000060
-#define WLAN_GPIO_PIN20_PAD_PULL_GET(x)          (((x) & WLAN_GPIO_PIN20_PAD_PULL_MASK) >> WLAN_GPIO_PIN20_PAD_PULL_LSB)
-#define WLAN_GPIO_PIN20_PAD_PULL_SET(x)          (((x) << WLAN_GPIO_PIN20_PAD_PULL_LSB) & WLAN_GPIO_PIN20_PAD_PULL_MASK)
-#define WLAN_GPIO_PIN20_PAD_STRENGTH_MSB         4
-#define WLAN_GPIO_PIN20_PAD_STRENGTH_LSB         3
-#define WLAN_GPIO_PIN20_PAD_STRENGTH_MASK        0x00000018
-#define WLAN_GPIO_PIN20_PAD_STRENGTH_GET(x)      (((x) & WLAN_GPIO_PIN20_PAD_STRENGTH_MASK) >> WLAN_GPIO_PIN20_PAD_STRENGTH_LSB)
-#define WLAN_GPIO_PIN20_PAD_STRENGTH_SET(x)      (((x) << WLAN_GPIO_PIN20_PAD_STRENGTH_LSB) & WLAN_GPIO_PIN20_PAD_STRENGTH_MASK)
-#define WLAN_GPIO_PIN20_PAD_DRIVER_MSB           2
-#define WLAN_GPIO_PIN20_PAD_DRIVER_LSB           2
-#define WLAN_GPIO_PIN20_PAD_DRIVER_MASK          0x00000004
-#define WLAN_GPIO_PIN20_PAD_DRIVER_GET(x)        (((x) & WLAN_GPIO_PIN20_PAD_DRIVER_MASK) >> WLAN_GPIO_PIN20_PAD_DRIVER_LSB)
-#define WLAN_GPIO_PIN20_PAD_DRIVER_SET(x)        (((x) << WLAN_GPIO_PIN20_PAD_DRIVER_LSB) & WLAN_GPIO_PIN20_PAD_DRIVER_MASK)
-#define WLAN_GPIO_PIN20_SOURCE_MSB               0
-#define WLAN_GPIO_PIN20_SOURCE_LSB               0
-#define WLAN_GPIO_PIN20_SOURCE_MASK              0x00000001
-#define WLAN_GPIO_PIN20_SOURCE_GET(x)            (((x) & WLAN_GPIO_PIN20_SOURCE_MASK) >> WLAN_GPIO_PIN20_SOURCE_LSB)
-#define WLAN_GPIO_PIN20_SOURCE_SET(x)            (((x) << WLAN_GPIO_PIN20_SOURCE_LSB) & WLAN_GPIO_PIN20_SOURCE_MASK)
-
-#define WLAN_GPIO_PIN21_ADDRESS                  0x0000007c
-#define WLAN_GPIO_PIN21_OFFSET                   0x0000007c
-#define WLAN_GPIO_PIN21_CONFIG_MSB               13
-#define WLAN_GPIO_PIN21_CONFIG_LSB               11
-#define WLAN_GPIO_PIN21_CONFIG_MASK              0x00003800
-#define WLAN_GPIO_PIN21_CONFIG_GET(x)            (((x) & WLAN_GPIO_PIN21_CONFIG_MASK) >> WLAN_GPIO_PIN21_CONFIG_LSB)
-#define WLAN_GPIO_PIN21_CONFIG_SET(x)            (((x) << WLAN_GPIO_PIN21_CONFIG_LSB) & WLAN_GPIO_PIN21_CONFIG_MASK)
-#define WLAN_GPIO_PIN21_WAKEUP_ENABLE_MSB        10
-#define WLAN_GPIO_PIN21_WAKEUP_ENABLE_LSB        10
-#define WLAN_GPIO_PIN21_WAKEUP_ENABLE_MASK       0x00000400
-#define WLAN_GPIO_PIN21_WAKEUP_ENABLE_GET(x)     (((x) & WLAN_GPIO_PIN21_WAKEUP_ENABLE_MASK) >> WLAN_GPIO_PIN21_WAKEUP_ENABLE_LSB)
-#define WLAN_GPIO_PIN21_WAKEUP_ENABLE_SET(x)     (((x) << WLAN_GPIO_PIN21_WAKEUP_ENABLE_LSB) & WLAN_GPIO_PIN21_WAKEUP_ENABLE_MASK)
-#define WLAN_GPIO_PIN21_INT_TYPE_MSB             9
-#define WLAN_GPIO_PIN21_INT_TYPE_LSB             7
-#define WLAN_GPIO_PIN21_INT_TYPE_MASK            0x00000380
-#define WLAN_GPIO_PIN21_INT_TYPE_GET(x)          (((x) & WLAN_GPIO_PIN21_INT_TYPE_MASK) >> WLAN_GPIO_PIN21_INT_TYPE_LSB)
-#define WLAN_GPIO_PIN21_INT_TYPE_SET(x)          (((x) << WLAN_GPIO_PIN21_INT_TYPE_LSB) & WLAN_GPIO_PIN21_INT_TYPE_MASK)
-#define WLAN_GPIO_PIN21_PAD_PULL_MSB             6
-#define WLAN_GPIO_PIN21_PAD_PULL_LSB             5
-#define WLAN_GPIO_PIN21_PAD_PULL_MASK            0x00000060
-#define WLAN_GPIO_PIN21_PAD_PULL_GET(x)          (((x) & WLAN_GPIO_PIN21_PAD_PULL_MASK) >> WLAN_GPIO_PIN21_PAD_PULL_LSB)
-#define WLAN_GPIO_PIN21_PAD_PULL_SET(x)          (((x) << WLAN_GPIO_PIN21_PAD_PULL_LSB) & WLAN_GPIO_PIN21_PAD_PULL_MASK)
-#define WLAN_GPIO_PIN21_PAD_STRENGTH_MSB         4
-#define WLAN_GPIO_PIN21_PAD_STRENGTH_LSB         3
-#define WLAN_GPIO_PIN21_PAD_STRENGTH_MASK        0x00000018
-#define WLAN_GPIO_PIN21_PAD_STRENGTH_GET(x)      (((x) & WLAN_GPIO_PIN21_PAD_STRENGTH_MASK) >> WLAN_GPIO_PIN21_PAD_STRENGTH_LSB)
-#define WLAN_GPIO_PIN21_PAD_STRENGTH_SET(x)      (((x) << WLAN_GPIO_PIN21_PAD_STRENGTH_LSB) & WLAN_GPIO_PIN21_PAD_STRENGTH_MASK)
-#define WLAN_GPIO_PIN21_PAD_DRIVER_MSB           2
-#define WLAN_GPIO_PIN21_PAD_DRIVER_LSB           2
-#define WLAN_GPIO_PIN21_PAD_DRIVER_MASK          0x00000004
-#define WLAN_GPIO_PIN21_PAD_DRIVER_GET(x)        (((x) & WLAN_GPIO_PIN21_PAD_DRIVER_MASK) >> WLAN_GPIO_PIN21_PAD_DRIVER_LSB)
-#define WLAN_GPIO_PIN21_PAD_DRIVER_SET(x)        (((x) << WLAN_GPIO_PIN21_PAD_DRIVER_LSB) & WLAN_GPIO_PIN21_PAD_DRIVER_MASK)
-#define WLAN_GPIO_PIN21_SOURCE_MSB               0
-#define WLAN_GPIO_PIN21_SOURCE_LSB               0
-#define WLAN_GPIO_PIN21_SOURCE_MASK              0x00000001
-#define WLAN_GPIO_PIN21_SOURCE_GET(x)            (((x) & WLAN_GPIO_PIN21_SOURCE_MASK) >> WLAN_GPIO_PIN21_SOURCE_LSB)
-#define WLAN_GPIO_PIN21_SOURCE_SET(x)            (((x) << WLAN_GPIO_PIN21_SOURCE_LSB) & WLAN_GPIO_PIN21_SOURCE_MASK)
-
-#define WLAN_GPIO_PIN22_ADDRESS                  0x00000080
-#define WLAN_GPIO_PIN22_OFFSET                   0x00000080
-#define WLAN_GPIO_PIN22_CONFIG_MSB               13
-#define WLAN_GPIO_PIN22_CONFIG_LSB               11
-#define WLAN_GPIO_PIN22_CONFIG_MASK              0x00003800
-#define WLAN_GPIO_PIN22_CONFIG_GET(x)            (((x) & WLAN_GPIO_PIN22_CONFIG_MASK) >> WLAN_GPIO_PIN22_CONFIG_LSB)
-#define WLAN_GPIO_PIN22_CONFIG_SET(x)            (((x) << WLAN_GPIO_PIN22_CONFIG_LSB) & WLAN_GPIO_PIN22_CONFIG_MASK)
-#define WLAN_GPIO_PIN22_WAKEUP_ENABLE_MSB        10
-#define WLAN_GPIO_PIN22_WAKEUP_ENABLE_LSB        10
-#define WLAN_GPIO_PIN22_WAKEUP_ENABLE_MASK       0x00000400
-#define WLAN_GPIO_PIN22_WAKEUP_ENABLE_GET(x)     (((x) & WLAN_GPIO_PIN22_WAKEUP_ENABLE_MASK) >> WLAN_GPIO_PIN22_WAKEUP_ENABLE_LSB)
-#define WLAN_GPIO_PIN22_WAKEUP_ENABLE_SET(x)     (((x) << WLAN_GPIO_PIN22_WAKEUP_ENABLE_LSB) & WLAN_GPIO_PIN22_WAKEUP_ENABLE_MASK)
-#define WLAN_GPIO_PIN22_INT_TYPE_MSB             9
-#define WLAN_GPIO_PIN22_INT_TYPE_LSB             7
-#define WLAN_GPIO_PIN22_INT_TYPE_MASK            0x00000380
-#define WLAN_GPIO_PIN22_INT_TYPE_GET(x)          (((x) & WLAN_GPIO_PIN22_INT_TYPE_MASK) >> WLAN_GPIO_PIN22_INT_TYPE_LSB)
-#define WLAN_GPIO_PIN22_INT_TYPE_SET(x)          (((x) << WLAN_GPIO_PIN22_INT_TYPE_LSB) & WLAN_GPIO_PIN22_INT_TYPE_MASK)
-#define WLAN_GPIO_PIN22_PAD_PULL_MSB             6
-#define WLAN_GPIO_PIN22_PAD_PULL_LSB             5
-#define WLAN_GPIO_PIN22_PAD_PULL_MASK            0x00000060
-#define WLAN_GPIO_PIN22_PAD_PULL_GET(x)          (((x) & WLAN_GPIO_PIN22_PAD_PULL_MASK) >> WLAN_GPIO_PIN22_PAD_PULL_LSB)
-#define WLAN_GPIO_PIN22_PAD_PULL_SET(x)          (((x) << WLAN_GPIO_PIN22_PAD_PULL_LSB) & WLAN_GPIO_PIN22_PAD_PULL_MASK)
-#define WLAN_GPIO_PIN22_PAD_STRENGTH_MSB         4
-#define WLAN_GPIO_PIN22_PAD_STRENGTH_LSB         3
-#define WLAN_GPIO_PIN22_PAD_STRENGTH_MASK        0x00000018
-#define WLAN_GPIO_PIN22_PAD_STRENGTH_GET(x)      (((x) & WLAN_GPIO_PIN22_PAD_STRENGTH_MASK) >> WLAN_GPIO_PIN22_PAD_STRENGTH_LSB)
-#define WLAN_GPIO_PIN22_PAD_STRENGTH_SET(x)      (((x) << WLAN_GPIO_PIN22_PAD_STRENGTH_LSB) & WLAN_GPIO_PIN22_PAD_STRENGTH_MASK)
-#define WLAN_GPIO_PIN22_PAD_DRIVER_MSB           2
-#define WLAN_GPIO_PIN22_PAD_DRIVER_LSB           2
-#define WLAN_GPIO_PIN22_PAD_DRIVER_MASK          0x00000004
-#define WLAN_GPIO_PIN22_PAD_DRIVER_GET(x)        (((x) & WLAN_GPIO_PIN22_PAD_DRIVER_MASK) >> WLAN_GPIO_PIN22_PAD_DRIVER_LSB)
-#define WLAN_GPIO_PIN22_PAD_DRIVER_SET(x)        (((x) << WLAN_GPIO_PIN22_PAD_DRIVER_LSB) & WLAN_GPIO_PIN22_PAD_DRIVER_MASK)
-#define WLAN_GPIO_PIN22_SOURCE_MSB               0
-#define WLAN_GPIO_PIN22_SOURCE_LSB               0
-#define WLAN_GPIO_PIN22_SOURCE_MASK              0x00000001
-#define WLAN_GPIO_PIN22_SOURCE_GET(x)            (((x) & WLAN_GPIO_PIN22_SOURCE_MASK) >> WLAN_GPIO_PIN22_SOURCE_LSB)
-#define WLAN_GPIO_PIN22_SOURCE_SET(x)            (((x) << WLAN_GPIO_PIN22_SOURCE_LSB) & WLAN_GPIO_PIN22_SOURCE_MASK)
-
-#define WLAN_GPIO_PIN23_ADDRESS                  0x00000084
-#define WLAN_GPIO_PIN23_OFFSET                   0x00000084
-#define WLAN_GPIO_PIN23_CONFIG_MSB               13
-#define WLAN_GPIO_PIN23_CONFIG_LSB               11
-#define WLAN_GPIO_PIN23_CONFIG_MASK              0x00003800
-#define WLAN_GPIO_PIN23_CONFIG_GET(x)            (((x) & WLAN_GPIO_PIN23_CONFIG_MASK) >> WLAN_GPIO_PIN23_CONFIG_LSB)
-#define WLAN_GPIO_PIN23_CONFIG_SET(x)            (((x) << WLAN_GPIO_PIN23_CONFIG_LSB) & WLAN_GPIO_PIN23_CONFIG_MASK)
-#define WLAN_GPIO_PIN23_WAKEUP_ENABLE_MSB        10
-#define WLAN_GPIO_PIN23_WAKEUP_ENABLE_LSB        10
-#define WLAN_GPIO_PIN23_WAKEUP_ENABLE_MASK       0x00000400
-#define WLAN_GPIO_PIN23_WAKEUP_ENABLE_GET(x)     (((x) & WLAN_GPIO_PIN23_WAKEUP_ENABLE_MASK) >> WLAN_GPIO_PIN23_WAKEUP_ENABLE_LSB)
-#define WLAN_GPIO_PIN23_WAKEUP_ENABLE_SET(x)     (((x) << WLAN_GPIO_PIN23_WAKEUP_ENABLE_LSB) & WLAN_GPIO_PIN23_WAKEUP_ENABLE_MASK)
-#define WLAN_GPIO_PIN23_INT_TYPE_MSB             9
-#define WLAN_GPIO_PIN23_INT_TYPE_LSB             7
-#define WLAN_GPIO_PIN23_INT_TYPE_MASK            0x00000380
-#define WLAN_GPIO_PIN23_INT_TYPE_GET(x)          (((x) & WLAN_GPIO_PIN23_INT_TYPE_MASK) >> WLAN_GPIO_PIN23_INT_TYPE_LSB)
-#define WLAN_GPIO_PIN23_INT_TYPE_SET(x)          (((x) << WLAN_GPIO_PIN23_INT_TYPE_LSB) & WLAN_GPIO_PIN23_INT_TYPE_MASK)
-#define WLAN_GPIO_PIN23_PAD_DRIVER_MSB           2
-#define WLAN_GPIO_PIN23_PAD_DRIVER_LSB           2
-#define WLAN_GPIO_PIN23_PAD_DRIVER_MASK          0x00000004
-#define WLAN_GPIO_PIN23_PAD_DRIVER_GET(x)        (((x) & WLAN_GPIO_PIN23_PAD_DRIVER_MASK) >> WLAN_GPIO_PIN23_PAD_DRIVER_LSB)
-#define WLAN_GPIO_PIN23_PAD_DRIVER_SET(x)        (((x) << WLAN_GPIO_PIN23_PAD_DRIVER_LSB) & WLAN_GPIO_PIN23_PAD_DRIVER_MASK)
-#define WLAN_GPIO_PIN23_SOURCE_MSB               0
-#define WLAN_GPIO_PIN23_SOURCE_LSB               0
-#define WLAN_GPIO_PIN23_SOURCE_MASK              0x00000001
-#define WLAN_GPIO_PIN23_SOURCE_GET(x)            (((x) & WLAN_GPIO_PIN23_SOURCE_MASK) >> WLAN_GPIO_PIN23_SOURCE_LSB)
-#define WLAN_GPIO_PIN23_SOURCE_SET(x)            (((x) << WLAN_GPIO_PIN23_SOURCE_LSB) & WLAN_GPIO_PIN23_SOURCE_MASK)
-
-#define WLAN_GPIO_PIN24_ADDRESS                  0x00000088
-#define WLAN_GPIO_PIN24_OFFSET                   0x00000088
-#define WLAN_GPIO_PIN24_CONFIG_MSB               13
-#define WLAN_GPIO_PIN24_CONFIG_LSB               11
-#define WLAN_GPIO_PIN24_CONFIG_MASK              0x00003800
-#define WLAN_GPIO_PIN24_CONFIG_GET(x)            (((x) & WLAN_GPIO_PIN24_CONFIG_MASK) >> WLAN_GPIO_PIN24_CONFIG_LSB)
-#define WLAN_GPIO_PIN24_CONFIG_SET(x)            (((x) << WLAN_GPIO_PIN24_CONFIG_LSB) & WLAN_GPIO_PIN24_CONFIG_MASK)
-#define WLAN_GPIO_PIN24_WAKEUP_ENABLE_MSB        10
-#define WLAN_GPIO_PIN24_WAKEUP_ENABLE_LSB        10
-#define WLAN_GPIO_PIN24_WAKEUP_ENABLE_MASK       0x00000400
-#define WLAN_GPIO_PIN24_WAKEUP_ENABLE_GET(x)     (((x) & WLAN_GPIO_PIN24_WAKEUP_ENABLE_MASK) >> WLAN_GPIO_PIN24_WAKEUP_ENABLE_LSB)
-#define WLAN_GPIO_PIN24_WAKEUP_ENABLE_SET(x)     (((x) << WLAN_GPIO_PIN24_WAKEUP_ENABLE_LSB) & WLAN_GPIO_PIN24_WAKEUP_ENABLE_MASK)
-#define WLAN_GPIO_PIN24_INT_TYPE_MSB             9
-#define WLAN_GPIO_PIN24_INT_TYPE_LSB             7
-#define WLAN_GPIO_PIN24_INT_TYPE_MASK            0x00000380
-#define WLAN_GPIO_PIN24_INT_TYPE_GET(x)          (((x) & WLAN_GPIO_PIN24_INT_TYPE_MASK) >> WLAN_GPIO_PIN24_INT_TYPE_LSB)
-#define WLAN_GPIO_PIN24_INT_TYPE_SET(x)          (((x) << WLAN_GPIO_PIN24_INT_TYPE_LSB) & WLAN_GPIO_PIN24_INT_TYPE_MASK)
-#define WLAN_GPIO_PIN24_PAD_DRIVER_MSB           2
-#define WLAN_GPIO_PIN24_PAD_DRIVER_LSB           2
-#define WLAN_GPIO_PIN24_PAD_DRIVER_MASK          0x00000004
-#define WLAN_GPIO_PIN24_PAD_DRIVER_GET(x)        (((x) & WLAN_GPIO_PIN24_PAD_DRIVER_MASK) >> WLAN_GPIO_PIN24_PAD_DRIVER_LSB)
-#define WLAN_GPIO_PIN24_PAD_DRIVER_SET(x)        (((x) << WLAN_GPIO_PIN24_PAD_DRIVER_LSB) & WLAN_GPIO_PIN24_PAD_DRIVER_MASK)
-#define WLAN_GPIO_PIN24_SOURCE_MSB               0
-#define WLAN_GPIO_PIN24_SOURCE_LSB               0
-#define WLAN_GPIO_PIN24_SOURCE_MASK              0x00000001
-#define WLAN_GPIO_PIN24_SOURCE_GET(x)            (((x) & WLAN_GPIO_PIN24_SOURCE_MASK) >> WLAN_GPIO_PIN24_SOURCE_LSB)
-#define WLAN_GPIO_PIN24_SOURCE_SET(x)            (((x) << WLAN_GPIO_PIN24_SOURCE_LSB) & WLAN_GPIO_PIN24_SOURCE_MASK)
-
-#define WLAN_GPIO_PIN25_ADDRESS                  0x0000008c
-#define WLAN_GPIO_PIN25_OFFSET                   0x0000008c
-#define WLAN_GPIO_PIN25_CONFIG_MSB               13
-#define WLAN_GPIO_PIN25_CONFIG_LSB               11
-#define WLAN_GPIO_PIN25_CONFIG_MASK              0x00003800
-#define WLAN_GPIO_PIN25_CONFIG_GET(x)            (((x) & WLAN_GPIO_PIN25_CONFIG_MASK) >> WLAN_GPIO_PIN25_CONFIG_LSB)
-#define WLAN_GPIO_PIN25_CONFIG_SET(x)            (((x) << WLAN_GPIO_PIN25_CONFIG_LSB) & WLAN_GPIO_PIN25_CONFIG_MASK)
-#define WLAN_GPIO_PIN25_WAKEUP_ENABLE_MSB        10
-#define WLAN_GPIO_PIN25_WAKEUP_ENABLE_LSB        10
-#define WLAN_GPIO_PIN25_WAKEUP_ENABLE_MASK       0x00000400
-#define WLAN_GPIO_PIN25_WAKEUP_ENABLE_GET(x)     (((x) & WLAN_GPIO_PIN25_WAKEUP_ENABLE_MASK) >> WLAN_GPIO_PIN25_WAKEUP_ENABLE_LSB)
-#define WLAN_GPIO_PIN25_WAKEUP_ENABLE_SET(x)     (((x) << WLAN_GPIO_PIN25_WAKEUP_ENABLE_LSB) & WLAN_GPIO_PIN25_WAKEUP_ENABLE_MASK)
-#define WLAN_GPIO_PIN25_INT_TYPE_MSB             9
-#define WLAN_GPIO_PIN25_INT_TYPE_LSB             7
-#define WLAN_GPIO_PIN25_INT_TYPE_MASK            0x00000380
-#define WLAN_GPIO_PIN25_INT_TYPE_GET(x)          (((x) & WLAN_GPIO_PIN25_INT_TYPE_MASK) >> WLAN_GPIO_PIN25_INT_TYPE_LSB)
-#define WLAN_GPIO_PIN25_INT_TYPE_SET(x)          (((x) << WLAN_GPIO_PIN25_INT_TYPE_LSB) & WLAN_GPIO_PIN25_INT_TYPE_MASK)
-#define WLAN_GPIO_PIN25_PAD_DRIVER_MSB           2
-#define WLAN_GPIO_PIN25_PAD_DRIVER_LSB           2
-#define WLAN_GPIO_PIN25_PAD_DRIVER_MASK          0x00000004
-#define WLAN_GPIO_PIN25_PAD_DRIVER_GET(x)        (((x) & WLAN_GPIO_PIN25_PAD_DRIVER_MASK) >> WLAN_GPIO_PIN25_PAD_DRIVER_LSB)
-#define WLAN_GPIO_PIN25_PAD_DRIVER_SET(x)        (((x) << WLAN_GPIO_PIN25_PAD_DRIVER_LSB) & WLAN_GPIO_PIN25_PAD_DRIVER_MASK)
-#define WLAN_GPIO_PIN25_SOURCE_MSB               0
-#define WLAN_GPIO_PIN25_SOURCE_LSB               0
-#define WLAN_GPIO_PIN25_SOURCE_MASK              0x00000001
-#define WLAN_GPIO_PIN25_SOURCE_GET(x)            (((x) & WLAN_GPIO_PIN25_SOURCE_MASK) >> WLAN_GPIO_PIN25_SOURCE_LSB)
-#define WLAN_GPIO_PIN25_SOURCE_SET(x)            (((x) << WLAN_GPIO_PIN25_SOURCE_LSB) & WLAN_GPIO_PIN25_SOURCE_MASK)
-
-#define SDIO_ADDRESS                             0x00000090
-#define SDIO_OFFSET                              0x00000090
-#define SDIO_PINS_EN_MSB                         0
-#define SDIO_PINS_EN_LSB                         0
-#define SDIO_PINS_EN_MASK                        0x00000001
-#define SDIO_PINS_EN_GET(x)                      (((x) & SDIO_PINS_EN_MASK) >> SDIO_PINS_EN_LSB)
-#define SDIO_PINS_EN_SET(x)                      (((x) << SDIO_PINS_EN_LSB) & SDIO_PINS_EN_MASK)
-
-#define FUNC_BUS_ADDRESS                         0x00000094
-#define FUNC_BUS_OFFSET                          0x00000094
-#define FUNC_BUS_GPIO_MODE_MSB                   22
-#define FUNC_BUS_GPIO_MODE_LSB                   22
-#define FUNC_BUS_GPIO_MODE_MASK                  0x00400000
-#define FUNC_BUS_GPIO_MODE_GET(x)                (((x) & FUNC_BUS_GPIO_MODE_MASK) >> FUNC_BUS_GPIO_MODE_LSB)
-#define FUNC_BUS_GPIO_MODE_SET(x)                (((x) << FUNC_BUS_GPIO_MODE_LSB) & FUNC_BUS_GPIO_MODE_MASK)
-#define FUNC_BUS_OE_L_MSB                        21
-#define FUNC_BUS_OE_L_LSB                        0
-#define FUNC_BUS_OE_L_MASK                       0x003fffff
-#define FUNC_BUS_OE_L_GET(x)                     (((x) & FUNC_BUS_OE_L_MASK) >> FUNC_BUS_OE_L_LSB)
-#define FUNC_BUS_OE_L_SET(x)                     (((x) << FUNC_BUS_OE_L_LSB) & FUNC_BUS_OE_L_MASK)
-
-#define WL_SOC_APB_ADDRESS                       0x00000098
-#define WL_SOC_APB_OFFSET                        0x00000098
-#define WL_SOC_APB_TOGGLE_MSB                    0
-#define WL_SOC_APB_TOGGLE_LSB                    0
-#define WL_SOC_APB_TOGGLE_MASK                   0x00000001
-#define WL_SOC_APB_TOGGLE_GET(x)                 (((x) & WL_SOC_APB_TOGGLE_MASK) >> WL_SOC_APB_TOGGLE_LSB)
-#define WL_SOC_APB_TOGGLE_SET(x)                 (((x) << WL_SOC_APB_TOGGLE_LSB) & WL_SOC_APB_TOGGLE_MASK)
-
-#define WLAN_SIGMA_DELTA_ADDRESS                 0x0000009c
-#define WLAN_SIGMA_DELTA_OFFSET                  0x0000009c
-#define WLAN_SIGMA_DELTA_ENABLE_MSB              16
-#define WLAN_SIGMA_DELTA_ENABLE_LSB              16
-#define WLAN_SIGMA_DELTA_ENABLE_MASK             0x00010000
-#define WLAN_SIGMA_DELTA_ENABLE_GET(x)           (((x) & WLAN_SIGMA_DELTA_ENABLE_MASK) >> WLAN_SIGMA_DELTA_ENABLE_LSB)
-#define WLAN_SIGMA_DELTA_ENABLE_SET(x)           (((x) << WLAN_SIGMA_DELTA_ENABLE_LSB) & WLAN_SIGMA_DELTA_ENABLE_MASK)
-#define WLAN_SIGMA_DELTA_PRESCALAR_MSB           15
-#define WLAN_SIGMA_DELTA_PRESCALAR_LSB           8
-#define WLAN_SIGMA_DELTA_PRESCALAR_MASK          0x0000ff00
-#define WLAN_SIGMA_DELTA_PRESCALAR_GET(x)        (((x) & WLAN_SIGMA_DELTA_PRESCALAR_MASK) >> WLAN_SIGMA_DELTA_PRESCALAR_LSB)
-#define WLAN_SIGMA_DELTA_PRESCALAR_SET(x)        (((x) << WLAN_SIGMA_DELTA_PRESCALAR_LSB) & WLAN_SIGMA_DELTA_PRESCALAR_MASK)
-#define WLAN_SIGMA_DELTA_TARGET_MSB              7
-#define WLAN_SIGMA_DELTA_TARGET_LSB              0
-#define WLAN_SIGMA_DELTA_TARGET_MASK             0x000000ff
-#define WLAN_SIGMA_DELTA_TARGET_GET(x)           (((x) & WLAN_SIGMA_DELTA_TARGET_MASK) >> WLAN_SIGMA_DELTA_TARGET_LSB)
-#define WLAN_SIGMA_DELTA_TARGET_SET(x)           (((x) << WLAN_SIGMA_DELTA_TARGET_LSB) & WLAN_SIGMA_DELTA_TARGET_MASK)
-
-#define WL_BOOTSTRAP_ADDRESS                     0x000000a0
-#define WL_BOOTSTRAP_OFFSET                      0x000000a0
-#define WL_BOOTSTRAP_STATUS_MSB                  22
-#define WL_BOOTSTRAP_STATUS_LSB                  0
-#define WL_BOOTSTRAP_STATUS_MASK                 0x007fffff
-#define WL_BOOTSTRAP_STATUS_GET(x)               (((x) & WL_BOOTSTRAP_STATUS_MASK) >> WL_BOOTSTRAP_STATUS_LSB)
-#define WL_BOOTSTRAP_STATUS_SET(x)               (((x) << WL_BOOTSTRAP_STATUS_LSB) & WL_BOOTSTRAP_STATUS_MASK)
-
-#define CLOCK_GPIO_ADDRESS                       0x000000a4
-#define CLOCK_GPIO_OFFSET                        0x000000a4
-#define CLOCK_GPIO_CLK_REQ_OUT_EN_MSB            2
-#define CLOCK_GPIO_CLK_REQ_OUT_EN_LSB            2
-#define CLOCK_GPIO_CLK_REQ_OUT_EN_MASK           0x00000004
-#define CLOCK_GPIO_CLK_REQ_OUT_EN_GET(x)         (((x) & CLOCK_GPIO_CLK_REQ_OUT_EN_MASK) >> CLOCK_GPIO_CLK_REQ_OUT_EN_LSB)
-#define CLOCK_GPIO_CLK_REQ_OUT_EN_SET(x)         (((x) << CLOCK_GPIO_CLK_REQ_OUT_EN_LSB) & CLOCK_GPIO_CLK_REQ_OUT_EN_MASK)
-#define CLOCK_GPIO_BT_CLK_REQ_EN_MSB             1
-#define CLOCK_GPIO_BT_CLK_REQ_EN_LSB             1
-#define CLOCK_GPIO_BT_CLK_REQ_EN_MASK            0x00000002
-#define CLOCK_GPIO_BT_CLK_REQ_EN_GET(x)          (((x) & CLOCK_GPIO_BT_CLK_REQ_EN_MASK) >> CLOCK_GPIO_BT_CLK_REQ_EN_LSB)
-#define CLOCK_GPIO_BT_CLK_REQ_EN_SET(x)          (((x) << CLOCK_GPIO_BT_CLK_REQ_EN_LSB) & CLOCK_GPIO_BT_CLK_REQ_EN_MASK)
-#define CLOCK_GPIO_BT_CLK_OUT_EN_MSB             0
-#define CLOCK_GPIO_BT_CLK_OUT_EN_LSB             0
-#define CLOCK_GPIO_BT_CLK_OUT_EN_MASK            0x00000001
-#define CLOCK_GPIO_BT_CLK_OUT_EN_GET(x)          (((x) & CLOCK_GPIO_BT_CLK_OUT_EN_MASK) >> CLOCK_GPIO_BT_CLK_OUT_EN_LSB)
-#define CLOCK_GPIO_BT_CLK_OUT_EN_SET(x)          (((x) << CLOCK_GPIO_BT_CLK_OUT_EN_LSB) & CLOCK_GPIO_BT_CLK_OUT_EN_MASK)
-
-#define WLAN_DEBUG_CONTROL_ADDRESS               0x000000a8
-#define WLAN_DEBUG_CONTROL_OFFSET                0x000000a8
-#define WLAN_DEBUG_CONTROL_ENABLE_MSB            0
-#define WLAN_DEBUG_CONTROL_ENABLE_LSB            0
-#define WLAN_DEBUG_CONTROL_ENABLE_MASK           0x00000001
-#define WLAN_DEBUG_CONTROL_ENABLE_GET(x)         (((x) & WLAN_DEBUG_CONTROL_ENABLE_MASK) >> WLAN_DEBUG_CONTROL_ENABLE_LSB)
-#define WLAN_DEBUG_CONTROL_ENABLE_SET(x)         (((x) << WLAN_DEBUG_CONTROL_ENABLE_LSB) & WLAN_DEBUG_CONTROL_ENABLE_MASK)
-
-#define WLAN_DEBUG_INPUT_SEL_ADDRESS             0x000000ac
-#define WLAN_DEBUG_INPUT_SEL_OFFSET              0x000000ac
-#define WLAN_DEBUG_INPUT_SEL_SHIFT_MSB           5
-#define WLAN_DEBUG_INPUT_SEL_SHIFT_LSB           4
-#define WLAN_DEBUG_INPUT_SEL_SHIFT_MASK          0x00000030
-#define WLAN_DEBUG_INPUT_SEL_SHIFT_GET(x)        (((x) & WLAN_DEBUG_INPUT_SEL_SHIFT_MASK) >> WLAN_DEBUG_INPUT_SEL_SHIFT_LSB)
-#define WLAN_DEBUG_INPUT_SEL_SHIFT_SET(x)        (((x) << WLAN_DEBUG_INPUT_SEL_SHIFT_LSB) & WLAN_DEBUG_INPUT_SEL_SHIFT_MASK)
-#define WLAN_DEBUG_INPUT_SEL_SRC_MSB             3
-#define WLAN_DEBUG_INPUT_SEL_SRC_LSB             0
-#define WLAN_DEBUG_INPUT_SEL_SRC_MASK            0x0000000f
-#define WLAN_DEBUG_INPUT_SEL_SRC_GET(x)          (((x) & WLAN_DEBUG_INPUT_SEL_SRC_MASK) >> WLAN_DEBUG_INPUT_SEL_SRC_LSB)
-#define WLAN_DEBUG_INPUT_SEL_SRC_SET(x)          (((x) << WLAN_DEBUG_INPUT_SEL_SRC_LSB) & WLAN_DEBUG_INPUT_SEL_SRC_MASK)
-
-#define WLAN_DEBUG_OUT_ADDRESS                   0x000000b0
-#define WLAN_DEBUG_OUT_OFFSET                    0x000000b0
-#define WLAN_DEBUG_OUT_DATA_MSB                  17
-#define WLAN_DEBUG_OUT_DATA_LSB                  0
-#define WLAN_DEBUG_OUT_DATA_MASK                 0x0003ffff
-#define WLAN_DEBUG_OUT_DATA_GET(x)               (((x) & WLAN_DEBUG_OUT_DATA_MASK) >> WLAN_DEBUG_OUT_DATA_LSB)
-#define WLAN_DEBUG_OUT_DATA_SET(x)               (((x) << WLAN_DEBUG_OUT_DATA_LSB) & WLAN_DEBUG_OUT_DATA_MASK)
-
-#define WLAN_RESET_TUPLE_STATUS_ADDRESS          0x000000b4
-#define WLAN_RESET_TUPLE_STATUS_OFFSET           0x000000b4
-#define WLAN_RESET_TUPLE_STATUS_TEST_RESET_TUPLE_MSB 11
-#define WLAN_RESET_TUPLE_STATUS_TEST_RESET_TUPLE_LSB 8
-#define WLAN_RESET_TUPLE_STATUS_TEST_RESET_TUPLE_MASK 0x00000f00
-#define WLAN_RESET_TUPLE_STATUS_TEST_RESET_TUPLE_GET(x) (((x) & WLAN_RESET_TUPLE_STATUS_TEST_RESET_TUPLE_MASK) >> WLAN_RESET_TUPLE_STATUS_TEST_RESET_TUPLE_LSB)
-#define WLAN_RESET_TUPLE_STATUS_TEST_RESET_TUPLE_SET(x) (((x) << WLAN_RESET_TUPLE_STATUS_TEST_RESET_TUPLE_LSB) & WLAN_RESET_TUPLE_STATUS_TEST_RESET_TUPLE_MASK)
-#define WLAN_RESET_TUPLE_STATUS_PIN_RESET_TUPLE_MSB 7
-#define WLAN_RESET_TUPLE_STATUS_PIN_RESET_TUPLE_LSB 0
-#define WLAN_RESET_TUPLE_STATUS_PIN_RESET_TUPLE_MASK 0x000000ff
-#define WLAN_RESET_TUPLE_STATUS_PIN_RESET_TUPLE_GET(x) (((x) & WLAN_RESET_TUPLE_STATUS_PIN_RESET_TUPLE_MASK) >> WLAN_RESET_TUPLE_STATUS_PIN_RESET_TUPLE_LSB)
-#define WLAN_RESET_TUPLE_STATUS_PIN_RESET_TUPLE_SET(x) (((x) << WLAN_RESET_TUPLE_STATUS_PIN_RESET_TUPLE_LSB) & WLAN_RESET_TUPLE_STATUS_PIN_RESET_TUPLE_MASK)
-
-#define ANTENNA_SLEEP_CONTROL_ADDRESS            0x000000b8
-#define ANTENNA_SLEEP_CONTROL_OFFSET             0x000000b8
-#define ANTENNA_SLEEP_CONTROL_OVERRIDE_MSB       14
-#define ANTENNA_SLEEP_CONTROL_OVERRIDE_LSB       10
-#define ANTENNA_SLEEP_CONTROL_OVERRIDE_MASK      0x00007c00
-#define ANTENNA_SLEEP_CONTROL_OVERRIDE_GET(x)    (((x) & ANTENNA_SLEEP_CONTROL_OVERRIDE_MASK) >> ANTENNA_SLEEP_CONTROL_OVERRIDE_LSB)
-#define ANTENNA_SLEEP_CONTROL_OVERRIDE_SET(x)    (((x) << ANTENNA_SLEEP_CONTROL_OVERRIDE_LSB) & ANTENNA_SLEEP_CONTROL_OVERRIDE_MASK)
-#define ANTENNA_SLEEP_CONTROL_VALUE_MSB          9
-#define ANTENNA_SLEEP_CONTROL_VALUE_LSB          5
-#define ANTENNA_SLEEP_CONTROL_VALUE_MASK         0x000003e0
-#define ANTENNA_SLEEP_CONTROL_VALUE_GET(x)       (((x) & ANTENNA_SLEEP_CONTROL_VALUE_MASK) >> ANTENNA_SLEEP_CONTROL_VALUE_LSB)
-#define ANTENNA_SLEEP_CONTROL_VALUE_SET(x)       (((x) << ANTENNA_SLEEP_CONTROL_VALUE_LSB) & ANTENNA_SLEEP_CONTROL_VALUE_MASK)
-#define ANTENNA_SLEEP_CONTROL_ENABLE_MSB         4
-#define ANTENNA_SLEEP_CONTROL_ENABLE_LSB         0
-#define ANTENNA_SLEEP_CONTROL_ENABLE_MASK        0x0000001f
-#define ANTENNA_SLEEP_CONTROL_ENABLE_GET(x)      (((x) & ANTENNA_SLEEP_CONTROL_ENABLE_MASK) >> ANTENNA_SLEEP_CONTROL_ENABLE_LSB)
-#define ANTENNA_SLEEP_CONTROL_ENABLE_SET(x)      (((x) << ANTENNA_SLEEP_CONTROL_ENABLE_LSB) & ANTENNA_SLEEP_CONTROL_ENABLE_MASK)
-
-
-#ifndef __ASSEMBLER__
-
-typedef struct gpio_athr_wlan_reg_reg_s {
-  volatile unsigned int wlan_gpio_out;
-  volatile unsigned int wlan_gpio_out_w1ts;
-  volatile unsigned int wlan_gpio_out_w1tc;
-  volatile unsigned int wlan_gpio_enable;
-  volatile unsigned int wlan_gpio_enable_w1ts;
-  volatile unsigned int wlan_gpio_enable_w1tc;
-  volatile unsigned int wlan_gpio_in;
-  volatile unsigned int wlan_gpio_status;
-  volatile unsigned int wlan_gpio_status_w1ts;
-  volatile unsigned int wlan_gpio_status_w1tc;
-  volatile unsigned int wlan_gpio_pin0;
-  volatile unsigned int wlan_gpio_pin1;
-  volatile unsigned int wlan_gpio_pin2;
-  volatile unsigned int wlan_gpio_pin3;
-  volatile unsigned int wlan_gpio_pin4;
-  volatile unsigned int wlan_gpio_pin5;
-  volatile unsigned int wlan_gpio_pin6;
-  volatile unsigned int wlan_gpio_pin7;
-  volatile unsigned int wlan_gpio_pin8;
-  volatile unsigned int wlan_gpio_pin9;
-  volatile unsigned int wlan_gpio_pin10;
-  volatile unsigned int wlan_gpio_pin11;
-  volatile unsigned int wlan_gpio_pin12;
-  volatile unsigned int wlan_gpio_pin13;
-  volatile unsigned int wlan_gpio_pin14;
-  volatile unsigned int wlan_gpio_pin15;
-  volatile unsigned int wlan_gpio_pin16;
-  volatile unsigned int wlan_gpio_pin17;
-  volatile unsigned int wlan_gpio_pin18;
-  volatile unsigned int wlan_gpio_pin19;
-  volatile unsigned int wlan_gpio_pin20;
-  volatile unsigned int wlan_gpio_pin21;
-  volatile unsigned int wlan_gpio_pin22;
-  volatile unsigned int wlan_gpio_pin23;
-  volatile unsigned int wlan_gpio_pin24;
-  volatile unsigned int wlan_gpio_pin25;
-  volatile unsigned int sdio;
-  volatile unsigned int func_bus;
-  volatile unsigned int wl_soc_apb;
-  volatile unsigned int wlan_sigma_delta;
-  volatile unsigned int wl_bootstrap;
-  volatile unsigned int clock_gpio;
-  volatile unsigned int wlan_debug_control;
-  volatile unsigned int wlan_debug_input_sel;
-  volatile unsigned int wlan_debug_out;
-  volatile unsigned int wlan_reset_tuple_status;
-  volatile unsigned int antenna_sleep_control;
-} gpio_athr_wlan_reg_reg_t;
-
-#endif /* __ASSEMBLER__ */
-
-#endif /* _GPIO_ATHR_WLAN_REG_H_ */
diff --git a/drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/gpio_reg.h b/drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/gpio_reg.h
deleted file mode 100644 (file)
index b3e7126..0000000
+++ /dev/null
@@ -1,1094 +0,0 @@
-// ------------------------------------------------------------------
-// Copyright (c) 2004-2010 Atheros Corporation.  All rights reserved.
-// 
-//
-// Permission to use, copy, modify, and/or distribute this software for any
-// purpose with or without fee is hereby granted, provided that the above
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-//
-//
-// ------------------------------------------------------------------
-//===================================================================
-// Author(s): ="Atheros"
-//===================================================================
-
-
-#ifdef WLAN_HEADERS
-
-#include "gpio_athr_wlan_reg.h"
-
-
-#ifndef BT_HEADERS
-
-#define GPIO_OUT_ADDRESS WLAN_GPIO_OUT_ADDRESS
-#define GPIO_OUT_OFFSET WLAN_GPIO_OUT_OFFSET
-#define GPIO_OUT_DATA_MSB WLAN_GPIO_OUT_DATA_MSB
-#define GPIO_OUT_DATA_LSB WLAN_GPIO_OUT_DATA_LSB
-#define GPIO_OUT_DATA_MASK WLAN_GPIO_OUT_DATA_MASK
-#define GPIO_OUT_DATA_GET(x) WLAN_GPIO_OUT_DATA_GET(x)
-#define GPIO_OUT_DATA_SET(x) WLAN_GPIO_OUT_DATA_SET(x)
-#define GPIO_OUT_W1TS_ADDRESS WLAN_GPIO_OUT_W1TS_ADDRESS
-#define GPIO_OUT_W1TS_OFFSET WLAN_GPIO_OUT_W1TS_OFFSET
-#define GPIO_OUT_W1TS_DATA_MSB WLAN_GPIO_OUT_W1TS_DATA_MSB
-#define GPIO_OUT_W1TS_DATA_LSB WLAN_GPIO_OUT_W1TS_DATA_LSB
-#define GPIO_OUT_W1TS_DATA_MASK WLAN_GPIO_OUT_W1TS_DATA_MASK
-#define GPIO_OUT_W1TS_DATA_GET(x) WLAN_GPIO_OUT_W1TS_DATA_GET(x)
-#define GPIO_OUT_W1TS_DATA_SET(x) WLAN_GPIO_OUT_W1TS_DATA_SET(x)
-#define GPIO_OUT_W1TC_ADDRESS WLAN_GPIO_OUT_W1TC_ADDRESS
-#define GPIO_OUT_W1TC_OFFSET WLAN_GPIO_OUT_W1TC_OFFSET
-#define GPIO_OUT_W1TC_DATA_MSB WLAN_GPIO_OUT_W1TC_DATA_MSB
-#define GPIO_OUT_W1TC_DATA_LSB WLAN_GPIO_OUT_W1TC_DATA_LSB
-#define GPIO_OUT_W1TC_DATA_MASK WLAN_GPIO_OUT_W1TC_DATA_MASK
-#define GPIO_OUT_W1TC_DATA_GET(x) WLAN_GPIO_OUT_W1TC_DATA_GET(x)
-#define GPIO_OUT_W1TC_DATA_SET(x) WLAN_GPIO_OUT_W1TC_DATA_SET(x)
-#define GPIO_ENABLE_ADDRESS WLAN_GPIO_ENABLE_ADDRESS
-#define GPIO_ENABLE_OFFSET WLAN_GPIO_ENABLE_OFFSET
-#define GPIO_ENABLE_DATA_MSB WLAN_GPIO_ENABLE_DATA_MSB
-#define GPIO_ENABLE_DATA_LSB WLAN_GPIO_ENABLE_DATA_LSB
-#define GPIO_ENABLE_DATA_MASK WLAN_GPIO_ENABLE_DATA_MASK
-#define GPIO_ENABLE_DATA_GET(x) WLAN_GPIO_ENABLE_DATA_GET(x)
-#define GPIO_ENABLE_DATA_SET(x) WLAN_GPIO_ENABLE_DATA_SET(x)
-#define GPIO_ENABLE_W1TS_ADDRESS WLAN_GPIO_ENABLE_W1TS_ADDRESS
-#define GPIO_ENABLE_W1TS_OFFSET WLAN_GPIO_ENABLE_W1TS_OFFSET
-#define GPIO_ENABLE_W1TS_DATA_MSB WLAN_GPIO_ENABLE_W1TS_DATA_MSB
-#define GPIO_ENABLE_W1TS_DATA_LSB WLAN_GPIO_ENABLE_W1TS_DATA_LSB
-#define GPIO_ENABLE_W1TS_DATA_MASK WLAN_GPIO_ENABLE_W1TS_DATA_MASK
-#define GPIO_ENABLE_W1TS_DATA_GET(x) WLAN_GPIO_ENABLE_W1TS_DATA_GET(x)
-#define GPIO_ENABLE_W1TS_DATA_SET(x) WLAN_GPIO_ENABLE_W1TS_DATA_SET(x)
-#define GPIO_ENABLE_W1TC_ADDRESS WLAN_GPIO_ENABLE_W1TC_ADDRESS
-#define GPIO_ENABLE_W1TC_OFFSET WLAN_GPIO_ENABLE_W1TC_OFFSET
-#define GPIO_ENABLE_W1TC_DATA_MSB WLAN_GPIO_ENABLE_W1TC_DATA_MSB
-#define GPIO_ENABLE_W1TC_DATA_LSB WLAN_GPIO_ENABLE_W1TC_DATA_LSB
-#define GPIO_ENABLE_W1TC_DATA_MASK WLAN_GPIO_ENABLE_W1TC_DATA_MASK
-#define GPIO_ENABLE_W1TC_DATA_GET(x) WLAN_GPIO_ENABLE_W1TC_DATA_GET(x)
-#define GPIO_ENABLE_W1TC_DATA_SET(x) WLAN_GPIO_ENABLE_W1TC_DATA_SET(x)
-#define GPIO_IN_ADDRESS WLAN_GPIO_IN_ADDRESS
-#define GPIO_IN_OFFSET WLAN_GPIO_IN_OFFSET
-#define GPIO_IN_DATA_MSB WLAN_GPIO_IN_DATA_MSB
-#define GPIO_IN_DATA_LSB WLAN_GPIO_IN_DATA_LSB
-#define GPIO_IN_DATA_MASK WLAN_GPIO_IN_DATA_MASK
-#define GPIO_IN_DATA_GET(x) WLAN_GPIO_IN_DATA_GET(x)
-#define GPIO_IN_DATA_SET(x) WLAN_GPIO_IN_DATA_SET(x)
-#define GPIO_STATUS_ADDRESS WLAN_GPIO_STATUS_ADDRESS
-#define GPIO_STATUS_OFFSET WLAN_GPIO_STATUS_OFFSET
-#define GPIO_STATUS_INTERRUPT_MSB WLAN_GPIO_STATUS_INTERRUPT_MSB
-#define GPIO_STATUS_INTERRUPT_LSB WLAN_GPIO_STATUS_INTERRUPT_LSB
-#define GPIO_STATUS_INTERRUPT_MASK WLAN_GPIO_STATUS_INTERRUPT_MASK
-#define GPIO_STATUS_INTERRUPT_GET(x) WLAN_GPIO_STATUS_INTERRUPT_GET(x)
-#define GPIO_STATUS_INTERRUPT_SET(x) WLAN_GPIO_STATUS_INTERRUPT_SET(x)
-#define GPIO_STATUS_W1TS_ADDRESS WLAN_GPIO_STATUS_W1TS_ADDRESS
-#define GPIO_STATUS_W1TS_OFFSET WLAN_GPIO_STATUS_W1TS_OFFSET
-#define GPIO_STATUS_W1TS_INTERRUPT_MSB WLAN_GPIO_STATUS_W1TS_INTERRUPT_MSB
-#define GPIO_STATUS_W1TS_INTERRUPT_LSB WLAN_GPIO_STATUS_W1TS_INTERRUPT_LSB
-#define GPIO_STATUS_W1TS_INTERRUPT_MASK WLAN_GPIO_STATUS_W1TS_INTERRUPT_MASK
-#define GPIO_STATUS_W1TS_INTERRUPT_GET(x) WLAN_GPIO_STATUS_W1TS_INTERRUPT_GET(x)
-#define GPIO_STATUS_W1TS_INTERRUPT_SET(x) WLAN_GPIO_STATUS_W1TS_INTERRUPT_SET(x)
-#define GPIO_STATUS_W1TC_ADDRESS WLAN_GPIO_STATUS_W1TC_ADDRESS
-#define GPIO_STATUS_W1TC_OFFSET WLAN_GPIO_STATUS_W1TC_OFFSET
-#define GPIO_STATUS_W1TC_INTERRUPT_MSB WLAN_GPIO_STATUS_W1TC_INTERRUPT_MSB
-#define GPIO_STATUS_W1TC_INTERRUPT_LSB WLAN_GPIO_STATUS_W1TC_INTERRUPT_LSB
-#define GPIO_STATUS_W1TC_INTERRUPT_MASK WLAN_GPIO_STATUS_W1TC_INTERRUPT_MASK
-#define GPIO_STATUS_W1TC_INTERRUPT_GET(x) WLAN_GPIO_STATUS_W1TC_INTERRUPT_GET(x)
-#define GPIO_STATUS_W1TC_INTERRUPT_SET(x) WLAN_GPIO_STATUS_W1TC_INTERRUPT_SET(x)
-#define GPIO_PIN0_ADDRESS WLAN_GPIO_PIN0_ADDRESS
-#define GPIO_PIN0_OFFSET WLAN_GPIO_PIN0_OFFSET
-#define GPIO_PIN0_CONFIG_MSB WLAN_GPIO_PIN0_CONFIG_MSB
-#define GPIO_PIN0_CONFIG_LSB WLAN_GPIO_PIN0_CONFIG_LSB
-#define GPIO_PIN0_CONFIG_MASK WLAN_GPIO_PIN0_CONFIG_MASK
-#define GPIO_PIN0_CONFIG_GET(x) WLAN_GPIO_PIN0_CONFIG_GET(x)
-#define GPIO_PIN0_CONFIG_SET(x) WLAN_GPIO_PIN0_CONFIG_SET(x)
-#define GPIO_PIN0_WAKEUP_ENABLE_MSB WLAN_GPIO_PIN0_WAKEUP_ENABLE_MSB
-#define GPIO_PIN0_WAKEUP_ENABLE_LSB WLAN_GPIO_PIN0_WAKEUP_ENABLE_LSB
-#define GPIO_PIN0_WAKEUP_ENABLE_MASK WLAN_GPIO_PIN0_WAKEUP_ENABLE_MASK
-#define GPIO_PIN0_WAKEUP_ENABLE_GET(x) WLAN_GPIO_PIN0_WAKEUP_ENABLE_GET(x)
-#define GPIO_PIN0_WAKEUP_ENABLE_SET(x) WLAN_GPIO_PIN0_WAKEUP_ENABLE_SET(x)
-#define GPIO_PIN0_INT_TYPE_MSB WLAN_GPIO_PIN0_INT_TYPE_MSB
-#define GPIO_PIN0_INT_TYPE_LSB WLAN_GPIO_PIN0_INT_TYPE_LSB
-#define GPIO_PIN0_INT_TYPE_MASK WLAN_GPIO_PIN0_INT_TYPE_MASK
-#define GPIO_PIN0_INT_TYPE_GET(x) WLAN_GPIO_PIN0_INT_TYPE_GET(x)
-#define GPIO_PIN0_INT_TYPE_SET(x) WLAN_GPIO_PIN0_INT_TYPE_SET(x)
-#define GPIO_PIN0_PAD_PULL_MSB WLAN_GPIO_PIN0_PAD_PULL_MSB
-#define GPIO_PIN0_PAD_PULL_LSB WLAN_GPIO_PIN0_PAD_PULL_LSB
-#define GPIO_PIN0_PAD_PULL_MASK WLAN_GPIO_PIN0_PAD_PULL_MASK
-#define GPIO_PIN0_PAD_PULL_GET(x) WLAN_GPIO_PIN0_PAD_PULL_GET(x)
-#define GPIO_PIN0_PAD_PULL_SET(x) WLAN_GPIO_PIN0_PAD_PULL_SET(x)
-#define GPIO_PIN0_PAD_STRENGTH_MSB WLAN_GPIO_PIN0_PAD_STRENGTH_MSB
-#define GPIO_PIN0_PAD_STRENGTH_LSB WLAN_GPIO_PIN0_PAD_STRENGTH_LSB
-#define GPIO_PIN0_PAD_STRENGTH_MASK WLAN_GPIO_PIN0_PAD_STRENGTH_MASK
-#define GPIO_PIN0_PAD_STRENGTH_GET(x) WLAN_GPIO_PIN0_PAD_STRENGTH_GET(x)
-#define GPIO_PIN0_PAD_STRENGTH_SET(x) WLAN_GPIO_PIN0_PAD_STRENGTH_SET(x)
-#define GPIO_PIN0_PAD_DRIVER_MSB WLAN_GPIO_PIN0_PAD_DRIVER_MSB
-#define GPIO_PIN0_PAD_DRIVER_LSB WLAN_GPIO_PIN0_PAD_DRIVER_LSB
-#define GPIO_PIN0_PAD_DRIVER_MASK WLAN_GPIO_PIN0_PAD_DRIVER_MASK
-#define GPIO_PIN0_PAD_DRIVER_GET(x) WLAN_GPIO_PIN0_PAD_DRIVER_GET(x)
-#define GPIO_PIN0_PAD_DRIVER_SET(x) WLAN_GPIO_PIN0_PAD_DRIVER_SET(x)
-#define GPIO_PIN0_SOURCE_MSB WLAN_GPIO_PIN0_SOURCE_MSB
-#define GPIO_PIN0_SOURCE_LSB WLAN_GPIO_PIN0_SOURCE_LSB
-#define GPIO_PIN0_SOURCE_MASK WLAN_GPIO_PIN0_SOURCE_MASK
-#define GPIO_PIN0_SOURCE_GET(x) WLAN_GPIO_PIN0_SOURCE_GET(x)
-#define GPIO_PIN0_SOURCE_SET(x) WLAN_GPIO_PIN0_SOURCE_SET(x)
-#define GPIO_PIN1_ADDRESS WLAN_GPIO_PIN1_ADDRESS
-#define GPIO_PIN1_OFFSET WLAN_GPIO_PIN1_OFFSET
-#define GPIO_PIN1_CONFIG_MSB WLAN_GPIO_PIN1_CONFIG_MSB
-#define GPIO_PIN1_CONFIG_LSB WLAN_GPIO_PIN1_CONFIG_LSB
-#define GPIO_PIN1_CONFIG_MASK WLAN_GPIO_PIN1_CONFIG_MASK
-#define GPIO_PIN1_CONFIG_GET(x) WLAN_GPIO_PIN1_CONFIG_GET(x)
-#define GPIO_PIN1_CONFIG_SET(x) WLAN_GPIO_PIN1_CONFIG_SET(x)
-#define GPIO_PIN1_WAKEUP_ENABLE_MSB WLAN_GPIO_PIN1_WAKEUP_ENABLE_MSB
-#define GPIO_PIN1_WAKEUP_ENABLE_LSB WLAN_GPIO_PIN1_WAKEUP_ENABLE_LSB
-#define GPIO_PIN1_WAKEUP_ENABLE_MASK WLAN_GPIO_PIN1_WAKEUP_ENABLE_MASK
-#define GPIO_PIN1_WAKEUP_ENABLE_GET(x) WLAN_GPIO_PIN1_WAKEUP_ENABLE_GET(x)
-#define GPIO_PIN1_WAKEUP_ENABLE_SET(x) WLAN_GPIO_PIN1_WAKEUP_ENABLE_SET(x)
-#define GPIO_PIN1_INT_TYPE_MSB WLAN_GPIO_PIN1_INT_TYPE_MSB
-#define GPIO_PIN1_INT_TYPE_LSB WLAN_GPIO_PIN1_INT_TYPE_LSB
-#define GPIO_PIN1_INT_TYPE_MASK WLAN_GPIO_PIN1_INT_TYPE_MASK
-#define GPIO_PIN1_INT_TYPE_GET(x) WLAN_GPIO_PIN1_INT_TYPE_GET(x)
-#define GPIO_PIN1_INT_TYPE_SET(x) WLAN_GPIO_PIN1_INT_TYPE_SET(x)
-#define GPIO_PIN1_PAD_PULL_MSB WLAN_GPIO_PIN1_PAD_PULL_MSB
-#define GPIO_PIN1_PAD_PULL_LSB WLAN_GPIO_PIN1_PAD_PULL_LSB
-#define GPIO_PIN1_PAD_PULL_MASK WLAN_GPIO_PIN1_PAD_PULL_MASK
-#define GPIO_PIN1_PAD_PULL_GET(x) WLAN_GPIO_PIN1_PAD_PULL_GET(x)
-#define GPIO_PIN1_PAD_PULL_SET(x) WLAN_GPIO_PIN1_PAD_PULL_SET(x)
-#define GPIO_PIN1_PAD_STRENGTH_MSB WLAN_GPIO_PIN1_PAD_STRENGTH_MSB
-#define GPIO_PIN1_PAD_STRENGTH_LSB WLAN_GPIO_PIN1_PAD_STRENGTH_LSB
-#define GPIO_PIN1_PAD_STRENGTH_MASK WLAN_GPIO_PIN1_PAD_STRENGTH_MASK
-#define GPIO_PIN1_PAD_STRENGTH_GET(x) WLAN_GPIO_PIN1_PAD_STRENGTH_GET(x)
-#define GPIO_PIN1_PAD_STRENGTH_SET(x) WLAN_GPIO_PIN1_PAD_STRENGTH_SET(x)
-#define GPIO_PIN1_PAD_DRIVER_MSB WLAN_GPIO_PIN1_PAD_DRIVER_MSB
-#define GPIO_PIN1_PAD_DRIVER_LSB WLAN_GPIO_PIN1_PAD_DRIVER_LSB
-#define GPIO_PIN1_PAD_DRIVER_MASK WLAN_GPIO_PIN1_PAD_DRIVER_MASK
-#define GPIO_PIN1_PAD_DRIVER_GET(x) WLAN_GPIO_PIN1_PAD_DRIVER_GET(x)
-#define GPIO_PIN1_PAD_DRIVER_SET(x) WLAN_GPIO_PIN1_PAD_DRIVER_SET(x)
-#define GPIO_PIN1_SOURCE_MSB WLAN_GPIO_PIN1_SOURCE_MSB
-#define GPIO_PIN1_SOURCE_LSB WLAN_GPIO_PIN1_SOURCE_LSB
-#define GPIO_PIN1_SOURCE_MASK WLAN_GPIO_PIN1_SOURCE_MASK
-#define GPIO_PIN1_SOURCE_GET(x) WLAN_GPIO_PIN1_SOURCE_GET(x)
-#define GPIO_PIN1_SOURCE_SET(x) WLAN_GPIO_PIN1_SOURCE_SET(x)
-#define GPIO_PIN2_ADDRESS WLAN_GPIO_PIN2_ADDRESS
-#define GPIO_PIN2_OFFSET WLAN_GPIO_PIN2_OFFSET
-#define GPIO_PIN2_CONFIG_MSB WLAN_GPIO_PIN2_CONFIG_MSB
-#define GPIO_PIN2_CONFIG_LSB WLAN_GPIO_PIN2_CONFIG_LSB
-#define GPIO_PIN2_CONFIG_MASK WLAN_GPIO_PIN2_CONFIG_MASK
-#define GPIO_PIN2_CONFIG_GET(x) WLAN_GPIO_PIN2_CONFIG_GET(x)
-#define GPIO_PIN2_CONFIG_SET(x) WLAN_GPIO_PIN2_CONFIG_SET(x)
-#define GPIO_PIN2_WAKEUP_ENABLE_MSB WLAN_GPIO_PIN2_WAKEUP_ENABLE_MSB
-#define GPIO_PIN2_WAKEUP_ENABLE_LSB WLAN_GPIO_PIN2_WAKEUP_ENABLE_LSB
-#define GPIO_PIN2_WAKEUP_ENABLE_MASK WLAN_GPIO_PIN2_WAKEUP_ENABLE_MASK
-#define GPIO_PIN2_WAKEUP_ENABLE_GET(x) WLAN_GPIO_PIN2_WAKEUP_ENABLE_GET(x)
-#define GPIO_PIN2_WAKEUP_ENABLE_SET(x) WLAN_GPIO_PIN2_WAKEUP_ENABLE_SET(x)
-#define GPIO_PIN2_INT_TYPE_MSB WLAN_GPIO_PIN2_INT_TYPE_MSB
-#define GPIO_PIN2_INT_TYPE_LSB WLAN_GPIO_PIN2_INT_TYPE_LSB
-#define GPIO_PIN2_INT_TYPE_MASK WLAN_GPIO_PIN2_INT_TYPE_MASK
-#define GPIO_PIN2_INT_TYPE_GET(x) WLAN_GPIO_PIN2_INT_TYPE_GET(x)
-#define GPIO_PIN2_INT_TYPE_SET(x) WLAN_GPIO_PIN2_INT_TYPE_SET(x)
-#define GPIO_PIN2_PAD_PULL_MSB WLAN_GPIO_PIN2_PAD_PULL_MSB
-#define GPIO_PIN2_PAD_PULL_LSB WLAN_GPIO_PIN2_PAD_PULL_LSB
-#define GPIO_PIN2_PAD_PULL_MASK WLAN_GPIO_PIN2_PAD_PULL_MASK
-#define GPIO_PIN2_PAD_PULL_GET(x) WLAN_GPIO_PIN2_PAD_PULL_GET(x)
-#define GPIO_PIN2_PAD_PULL_SET(x) WLAN_GPIO_PIN2_PAD_PULL_SET(x)
-#define GPIO_PIN2_PAD_STRENGTH_MSB WLAN_GPIO_PIN2_PAD_STRENGTH_MSB
-#define GPIO_PIN2_PAD_STRENGTH_LSB WLAN_GPIO_PIN2_PAD_STRENGTH_LSB
-#define GPIO_PIN2_PAD_STRENGTH_MASK WLAN_GPIO_PIN2_PAD_STRENGTH_MASK
-#define GPIO_PIN2_PAD_STRENGTH_GET(x) WLAN_GPIO_PIN2_PAD_STRENGTH_GET(x)
-#define GPIO_PIN2_PAD_STRENGTH_SET(x) WLAN_GPIO_PIN2_PAD_STRENGTH_SET(x)
-#define GPIO_PIN2_PAD_DRIVER_MSB WLAN_GPIO_PIN2_PAD_DRIVER_MSB
-#define GPIO_PIN2_PAD_DRIVER_LSB WLAN_GPIO_PIN2_PAD_DRIVER_LSB
-#define GPIO_PIN2_PAD_DRIVER_MASK WLAN_GPIO_PIN2_PAD_DRIVER_MASK
-#define GPIO_PIN2_PAD_DRIVER_GET(x) WLAN_GPIO_PIN2_PAD_DRIVER_GET(x)
-#define GPIO_PIN2_PAD_DRIVER_SET(x) WLAN_GPIO_PIN2_PAD_DRIVER_SET(x)
-#define GPIO_PIN2_SOURCE_MSB WLAN_GPIO_PIN2_SOURCE_MSB
-#define GPIO_PIN2_SOURCE_LSB WLAN_GPIO_PIN2_SOURCE_LSB
-#define GPIO_PIN2_SOURCE_MASK WLAN_GPIO_PIN2_SOURCE_MASK
-#define GPIO_PIN2_SOURCE_GET(x) WLAN_GPIO_PIN2_SOURCE_GET(x)
-#define GPIO_PIN2_SOURCE_SET(x) WLAN_GPIO_PIN2_SOURCE_SET(x)
-#define GPIO_PIN3_ADDRESS WLAN_GPIO_PIN3_ADDRESS
-#define GPIO_PIN3_OFFSET WLAN_GPIO_PIN3_OFFSET
-#define GPIO_PIN3_CONFIG_MSB WLAN_GPIO_PIN3_CONFIG_MSB
-#define GPIO_PIN3_CONFIG_LSB WLAN_GPIO_PIN3_CONFIG_LSB
-#define GPIO_PIN3_CONFIG_MASK WLAN_GPIO_PIN3_CONFIG_MASK
-#define GPIO_PIN3_CONFIG_GET(x) WLAN_GPIO_PIN3_CONFIG_GET(x)
-#define GPIO_PIN3_CONFIG_SET(x) WLAN_GPIO_PIN3_CONFIG_SET(x)
-#define GPIO_PIN3_WAKEUP_ENABLE_MSB WLAN_GPIO_PIN3_WAKEUP_ENABLE_MSB
-#define GPIO_PIN3_WAKEUP_ENABLE_LSB WLAN_GPIO_PIN3_WAKEUP_ENABLE_LSB
-#define GPIO_PIN3_WAKEUP_ENABLE_MASK WLAN_GPIO_PIN3_WAKEUP_ENABLE_MASK
-#define GPIO_PIN3_WAKEUP_ENABLE_GET(x) WLAN_GPIO_PIN3_WAKEUP_ENABLE_GET(x)
-#define GPIO_PIN3_WAKEUP_ENABLE_SET(x) WLAN_GPIO_PIN3_WAKEUP_ENABLE_SET(x)
-#define GPIO_PIN3_INT_TYPE_MSB WLAN_GPIO_PIN3_INT_TYPE_MSB
-#define GPIO_PIN3_INT_TYPE_LSB WLAN_GPIO_PIN3_INT_TYPE_LSB
-#define GPIO_PIN3_INT_TYPE_MASK WLAN_GPIO_PIN3_INT_TYPE_MASK
-#define GPIO_PIN3_INT_TYPE_GET(x) WLAN_GPIO_PIN3_INT_TYPE_GET(x)
-#define GPIO_PIN3_INT_TYPE_SET(x) WLAN_GPIO_PIN3_INT_TYPE_SET(x)
-#define GPIO_PIN3_PAD_PULL_MSB WLAN_GPIO_PIN3_PAD_PULL_MSB
-#define GPIO_PIN3_PAD_PULL_LSB WLAN_GPIO_PIN3_PAD_PULL_LSB
-#define GPIO_PIN3_PAD_PULL_MASK WLAN_GPIO_PIN3_PAD_PULL_MASK
-#define GPIO_PIN3_PAD_PULL_GET(x) WLAN_GPIO_PIN3_PAD_PULL_GET(x)
-#define GPIO_PIN3_PAD_PULL_SET(x) WLAN_GPIO_PIN3_PAD_PULL_SET(x)
-#define GPIO_PIN3_PAD_STRENGTH_MSB WLAN_GPIO_PIN3_PAD_STRENGTH_MSB
-#define GPIO_PIN3_PAD_STRENGTH_LSB WLAN_GPIO_PIN3_PAD_STRENGTH_LSB
-#define GPIO_PIN3_PAD_STRENGTH_MASK WLAN_GPIO_PIN3_PAD_STRENGTH_MASK
-#define GPIO_PIN3_PAD_STRENGTH_GET(x) WLAN_GPIO_PIN3_PAD_STRENGTH_GET(x)
-#define GPIO_PIN3_PAD_STRENGTH_SET(x) WLAN_GPIO_PIN3_PAD_STRENGTH_SET(x)
-#define GPIO_PIN3_PAD_DRIVER_MSB WLAN_GPIO_PIN3_PAD_DRIVER_MSB
-#define GPIO_PIN3_PAD_DRIVER_LSB WLAN_GPIO_PIN3_PAD_DRIVER_LSB
-#define GPIO_PIN3_PAD_DRIVER_MASK WLAN_GPIO_PIN3_PAD_DRIVER_MASK
-#define GPIO_PIN3_PAD_DRIVER_GET(x) WLAN_GPIO_PIN3_PAD_DRIVER_GET(x)
-#define GPIO_PIN3_PAD_DRIVER_SET(x) WLAN_GPIO_PIN3_PAD_DRIVER_SET(x)
-#define GPIO_PIN3_SOURCE_MSB WLAN_GPIO_PIN3_SOURCE_MSB
-#define GPIO_PIN3_SOURCE_LSB WLAN_GPIO_PIN3_SOURCE_LSB
-#define GPIO_PIN3_SOURCE_MASK WLAN_GPIO_PIN3_SOURCE_MASK
-#define GPIO_PIN3_SOURCE_GET(x) WLAN_GPIO_PIN3_SOURCE_GET(x)
-#define GPIO_PIN3_SOURCE_SET(x) WLAN_GPIO_PIN3_SOURCE_SET(x)
-#define GPIO_PIN4_ADDRESS WLAN_GPIO_PIN4_ADDRESS
-#define GPIO_PIN4_OFFSET WLAN_GPIO_PIN4_OFFSET
-#define GPIO_PIN4_CONFIG_MSB WLAN_GPIO_PIN4_CONFIG_MSB
-#define GPIO_PIN4_CONFIG_LSB WLAN_GPIO_PIN4_CONFIG_LSB
-#define GPIO_PIN4_CONFIG_MASK WLAN_GPIO_PIN4_CONFIG_MASK
-#define GPIO_PIN4_CONFIG_GET(x) WLAN_GPIO_PIN4_CONFIG_GET(x)
-#define GPIO_PIN4_CONFIG_SET(x) WLAN_GPIO_PIN4_CONFIG_SET(x)
-#define GPIO_PIN4_WAKEUP_ENABLE_MSB WLAN_GPIO_PIN4_WAKEUP_ENABLE_MSB
-#define GPIO_PIN4_WAKEUP_ENABLE_LSB WLAN_GPIO_PIN4_WAKEUP_ENABLE_LSB
-#define GPIO_PIN4_WAKEUP_ENABLE_MASK WLAN_GPIO_PIN4_WAKEUP_ENABLE_MASK
-#define GPIO_PIN4_WAKEUP_ENABLE_GET(x) WLAN_GPIO_PIN4_WAKEUP_ENABLE_GET(x)
-#define GPIO_PIN4_WAKEUP_ENABLE_SET(x) WLAN_GPIO_PIN4_WAKEUP_ENABLE_SET(x)
-#define GPIO_PIN4_INT_TYPE_MSB WLAN_GPIO_PIN4_INT_TYPE_MSB
-#define GPIO_PIN4_INT_TYPE_LSB WLAN_GPIO_PIN4_INT_TYPE_LSB
-#define GPIO_PIN4_INT_TYPE_MASK WLAN_GPIO_PIN4_INT_TYPE_MASK
-#define GPIO_PIN4_INT_TYPE_GET(x) WLAN_GPIO_PIN4_INT_TYPE_GET(x)
-#define GPIO_PIN4_INT_TYPE_SET(x) WLAN_GPIO_PIN4_INT_TYPE_SET(x)
-#define GPIO_PIN4_PAD_PULL_MSB WLAN_GPIO_PIN4_PAD_PULL_MSB
-#define GPIO_PIN4_PAD_PULL_LSB WLAN_GPIO_PIN4_PAD_PULL_LSB
-#define GPIO_PIN4_PAD_PULL_MASK WLAN_GPIO_PIN4_PAD_PULL_MASK
-#define GPIO_PIN4_PAD_PULL_GET(x) WLAN_GPIO_PIN4_PAD_PULL_GET(x)
-#define GPIO_PIN4_PAD_PULL_SET(x) WLAN_GPIO_PIN4_PAD_PULL_SET(x)
-#define GPIO_PIN4_PAD_STRENGTH_MSB WLAN_GPIO_PIN4_PAD_STRENGTH_MSB
-#define GPIO_PIN4_PAD_STRENGTH_LSB WLAN_GPIO_PIN4_PAD_STRENGTH_LSB
-#define GPIO_PIN4_PAD_STRENGTH_MASK WLAN_GPIO_PIN4_PAD_STRENGTH_MASK
-#define GPIO_PIN4_PAD_STRENGTH_GET(x) WLAN_GPIO_PIN4_PAD_STRENGTH_GET(x)
-#define GPIO_PIN4_PAD_STRENGTH_SET(x) WLAN_GPIO_PIN4_PAD_STRENGTH_SET(x)
-#define GPIO_PIN4_PAD_DRIVER_MSB WLAN_GPIO_PIN4_PAD_DRIVER_MSB
-#define GPIO_PIN4_PAD_DRIVER_LSB WLAN_GPIO_PIN4_PAD_DRIVER_LSB
-#define GPIO_PIN4_PAD_DRIVER_MASK WLAN_GPIO_PIN4_PAD_DRIVER_MASK
-#define GPIO_PIN4_PAD_DRIVER_GET(x) WLAN_GPIO_PIN4_PAD_DRIVER_GET(x)
-#define GPIO_PIN4_PAD_DRIVER_SET(x) WLAN_GPIO_PIN4_PAD_DRIVER_SET(x)
-#define GPIO_PIN4_SOURCE_MSB WLAN_GPIO_PIN4_SOURCE_MSB
-#define GPIO_PIN4_SOURCE_LSB WLAN_GPIO_PIN4_SOURCE_LSB
-#define GPIO_PIN4_SOURCE_MASK WLAN_GPIO_PIN4_SOURCE_MASK
-#define GPIO_PIN4_SOURCE_GET(x) WLAN_GPIO_PIN4_SOURCE_GET(x)
-#define GPIO_PIN4_SOURCE_SET(x) WLAN_GPIO_PIN4_SOURCE_SET(x)
-#define GPIO_PIN5_ADDRESS WLAN_GPIO_PIN5_ADDRESS
-#define GPIO_PIN5_OFFSET WLAN_GPIO_PIN5_OFFSET
-#define GPIO_PIN5_CONFIG_MSB WLAN_GPIO_PIN5_CONFIG_MSB
-#define GPIO_PIN5_CONFIG_LSB WLAN_GPIO_PIN5_CONFIG_LSB
-#define GPIO_PIN5_CONFIG_MASK WLAN_GPIO_PIN5_CONFIG_MASK
-#define GPIO_PIN5_CONFIG_GET(x) WLAN_GPIO_PIN5_CONFIG_GET(x)
-#define GPIO_PIN5_CONFIG_SET(x) WLAN_GPIO_PIN5_CONFIG_SET(x)
-#define GPIO_PIN5_WAKEUP_ENABLE_MSB WLAN_GPIO_PIN5_WAKEUP_ENABLE_MSB
-#define GPIO_PIN5_WAKEUP_ENABLE_LSB WLAN_GPIO_PIN5_WAKEUP_ENABLE_LSB
-#define GPIO_PIN5_WAKEUP_ENABLE_MASK WLAN_GPIO_PIN5_WAKEUP_ENABLE_MASK
-#define GPIO_PIN5_WAKEUP_ENABLE_GET(x) WLAN_GPIO_PIN5_WAKEUP_ENABLE_GET(x)
-#define GPIO_PIN5_WAKEUP_ENABLE_SET(x) WLAN_GPIO_PIN5_WAKEUP_ENABLE_SET(x)
-#define GPIO_PIN5_INT_TYPE_MSB WLAN_GPIO_PIN5_INT_TYPE_MSB
-#define GPIO_PIN5_INT_TYPE_LSB WLAN_GPIO_PIN5_INT_TYPE_LSB
-#define GPIO_PIN5_INT_TYPE_MASK WLAN_GPIO_PIN5_INT_TYPE_MASK
-#define GPIO_PIN5_INT_TYPE_GET(x) WLAN_GPIO_PIN5_INT_TYPE_GET(x)
-#define GPIO_PIN5_INT_TYPE_SET(x) WLAN_GPIO_PIN5_INT_TYPE_SET(x)
-#define GPIO_PIN5_PAD_PULL_MSB WLAN_GPIO_PIN5_PAD_PULL_MSB
-#define GPIO_PIN5_PAD_PULL_LSB WLAN_GPIO_PIN5_PAD_PULL_LSB
-#define GPIO_PIN5_PAD_PULL_MASK WLAN_GPIO_PIN5_PAD_PULL_MASK
-#define GPIO_PIN5_PAD_PULL_GET(x) WLAN_GPIO_PIN5_PAD_PULL_GET(x)
-#define GPIO_PIN5_PAD_PULL_SET(x) WLAN_GPIO_PIN5_PAD_PULL_SET(x)
-#define GPIO_PIN5_PAD_STRENGTH_MSB WLAN_GPIO_PIN5_PAD_STRENGTH_MSB
-#define GPIO_PIN5_PAD_STRENGTH_LSB WLAN_GPIO_PIN5_PAD_STRENGTH_LSB
-#define GPIO_PIN5_PAD_STRENGTH_MASK WLAN_GPIO_PIN5_PAD_STRENGTH_MASK
-#define GPIO_PIN5_PAD_STRENGTH_GET(x) WLAN_GPIO_PIN5_PAD_STRENGTH_GET(x)
-#define GPIO_PIN5_PAD_STRENGTH_SET(x) WLAN_GPIO_PIN5_PAD_STRENGTH_SET(x)
-#define GPIO_PIN5_PAD_DRIVER_MSB WLAN_GPIO_PIN5_PAD_DRIVER_MSB
-#define GPIO_PIN5_PAD_DRIVER_LSB WLAN_GPIO_PIN5_PAD_DRIVER_LSB
-#define GPIO_PIN5_PAD_DRIVER_MASK WLAN_GPIO_PIN5_PAD_DRIVER_MASK
-#define GPIO_PIN5_PAD_DRIVER_GET(x) WLAN_GPIO_PIN5_PAD_DRIVER_GET(x)
-#define GPIO_PIN5_PAD_DRIVER_SET(x) WLAN_GPIO_PIN5_PAD_DRIVER_SET(x)
-#define GPIO_PIN5_SOURCE_MSB WLAN_GPIO_PIN5_SOURCE_MSB
-#define GPIO_PIN5_SOURCE_LSB WLAN_GPIO_PIN5_SOURCE_LSB
-#define GPIO_PIN5_SOURCE_MASK WLAN_GPIO_PIN5_SOURCE_MASK
-#define GPIO_PIN5_SOURCE_GET(x) WLAN_GPIO_PIN5_SOURCE_GET(x)
-#define GPIO_PIN5_SOURCE_SET(x) WLAN_GPIO_PIN5_SOURCE_SET(x)
-#define GPIO_PIN6_ADDRESS WLAN_GPIO_PIN6_ADDRESS
-#define GPIO_PIN6_OFFSET WLAN_GPIO_PIN6_OFFSET
-#define GPIO_PIN6_CONFIG_MSB WLAN_GPIO_PIN6_CONFIG_MSB
-#define GPIO_PIN6_CONFIG_LSB WLAN_GPIO_PIN6_CONFIG_LSB
-#define GPIO_PIN6_CONFIG_MASK WLAN_GPIO_PIN6_CONFIG_MASK
-#define GPIO_PIN6_CONFIG_GET(x) WLAN_GPIO_PIN6_CONFIG_GET(x)
-#define GPIO_PIN6_CONFIG_SET(x) WLAN_GPIO_PIN6_CONFIG_SET(x)
-#define GPIO_PIN6_WAKEUP_ENABLE_MSB WLAN_GPIO_PIN6_WAKEUP_ENABLE_MSB
-#define GPIO_PIN6_WAKEUP_ENABLE_LSB WLAN_GPIO_PIN6_WAKEUP_ENABLE_LSB
-#define GPIO_PIN6_WAKEUP_ENABLE_MASK WLAN_GPIO_PIN6_WAKEUP_ENABLE_MASK
-#define GPIO_PIN6_WAKEUP_ENABLE_GET(x) WLAN_GPIO_PIN6_WAKEUP_ENABLE_GET(x)
-#define GPIO_PIN6_WAKEUP_ENABLE_SET(x) WLAN_GPIO_PIN6_WAKEUP_ENABLE_SET(x)
-#define GPIO_PIN6_INT_TYPE_MSB WLAN_GPIO_PIN6_INT_TYPE_MSB
-#define GPIO_PIN6_INT_TYPE_LSB WLAN_GPIO_PIN6_INT_TYPE_LSB
-#define GPIO_PIN6_INT_TYPE_MASK WLAN_GPIO_PIN6_INT_TYPE_MASK
-#define GPIO_PIN6_INT_TYPE_GET(x) WLAN_GPIO_PIN6_INT_TYPE_GET(x)
-#define GPIO_PIN6_INT_TYPE_SET(x) WLAN_GPIO_PIN6_INT_TYPE_SET(x)
-#define GPIO_PIN6_PAD_PULL_MSB WLAN_GPIO_PIN6_PAD_PULL_MSB
-#define GPIO_PIN6_PAD_PULL_LSB WLAN_GPIO_PIN6_PAD_PULL_LSB
-#define GPIO_PIN6_PAD_PULL_MASK WLAN_GPIO_PIN6_PAD_PULL_MASK
-#define GPIO_PIN6_PAD_PULL_GET(x) WLAN_GPIO_PIN6_PAD_PULL_GET(x)
-#define GPIO_PIN6_PAD_PULL_SET(x) WLAN_GPIO_PIN6_PAD_PULL_SET(x)
-#define GPIO_PIN6_PAD_STRENGTH_MSB WLAN_GPIO_PIN6_PAD_STRENGTH_MSB
-#define GPIO_PIN6_PAD_STRENGTH_LSB WLAN_GPIO_PIN6_PAD_STRENGTH_LSB
-#define GPIO_PIN6_PAD_STRENGTH_MASK WLAN_GPIO_PIN6_PAD_STRENGTH_MASK
-#define GPIO_PIN6_PAD_STRENGTH_GET(x) WLAN_GPIO_PIN6_PAD_STRENGTH_GET(x)
-#define GPIO_PIN6_PAD_STRENGTH_SET(x) WLAN_GPIO_PIN6_PAD_STRENGTH_SET(x)
-#define GPIO_PIN6_PAD_DRIVER_MSB WLAN_GPIO_PIN6_PAD_DRIVER_MSB
-#define GPIO_PIN6_PAD_DRIVER_LSB WLAN_GPIO_PIN6_PAD_DRIVER_LSB
-#define GPIO_PIN6_PAD_DRIVER_MASK WLAN_GPIO_PIN6_PAD_DRIVER_MASK
-#define GPIO_PIN6_PAD_DRIVER_GET(x) WLAN_GPIO_PIN6_PAD_DRIVER_GET(x)
-#define GPIO_PIN6_PAD_DRIVER_SET(x) WLAN_GPIO_PIN6_PAD_DRIVER_SET(x)
-#define GPIO_PIN6_SOURCE_MSB WLAN_GPIO_PIN6_SOURCE_MSB
-#define GPIO_PIN6_SOURCE_LSB WLAN_GPIO_PIN6_SOURCE_LSB
-#define GPIO_PIN6_SOURCE_MASK WLAN_GPIO_PIN6_SOURCE_MASK
-#define GPIO_PIN6_SOURCE_GET(x) WLAN_GPIO_PIN6_SOURCE_GET(x)
-#define GPIO_PIN6_SOURCE_SET(x) WLAN_GPIO_PIN6_SOURCE_SET(x)
-#define GPIO_PIN7_ADDRESS WLAN_GPIO_PIN7_ADDRESS
-#define GPIO_PIN7_OFFSET WLAN_GPIO_PIN7_OFFSET
-#define GPIO_PIN7_CONFIG_MSB WLAN_GPIO_PIN7_CONFIG_MSB
-#define GPIO_PIN7_CONFIG_LSB WLAN_GPIO_PIN7_CONFIG_LSB
-#define GPIO_PIN7_CONFIG_MASK WLAN_GPIO_PIN7_CONFIG_MASK
-#define GPIO_PIN7_CONFIG_GET(x) WLAN_GPIO_PIN7_CONFIG_GET(x)
-#define GPIO_PIN7_CONFIG_SET(x) WLAN_GPIO_PIN7_CONFIG_SET(x)
-#define GPIO_PIN7_WAKEUP_ENABLE_MSB WLAN_GPIO_PIN7_WAKEUP_ENABLE_MSB
-#define GPIO_PIN7_WAKEUP_ENABLE_LSB WLAN_GPIO_PIN7_WAKEUP_ENABLE_LSB
-#define GPIO_PIN7_WAKEUP_ENABLE_MASK WLAN_GPIO_PIN7_WAKEUP_ENABLE_MASK
-#define GPIO_PIN7_WAKEUP_ENABLE_GET(x) WLAN_GPIO_PIN7_WAKEUP_ENABLE_GET(x)
-#define GPIO_PIN7_WAKEUP_ENABLE_SET(x) WLAN_GPIO_PIN7_WAKEUP_ENABLE_SET(x)
-#define GPIO_PIN7_INT_TYPE_MSB WLAN_GPIO_PIN7_INT_TYPE_MSB
-#define GPIO_PIN7_INT_TYPE_LSB WLAN_GPIO_PIN7_INT_TYPE_LSB
-#define GPIO_PIN7_INT_TYPE_MASK WLAN_GPIO_PIN7_INT_TYPE_MASK
-#define GPIO_PIN7_INT_TYPE_GET(x) WLAN_GPIO_PIN7_INT_TYPE_GET(x)
-#define GPIO_PIN7_INT_TYPE_SET(x) WLAN_GPIO_PIN7_INT_TYPE_SET(x)
-#define GPIO_PIN7_PAD_PULL_MSB WLAN_GPIO_PIN7_PAD_PULL_MSB
-#define GPIO_PIN7_PAD_PULL_LSB WLAN_GPIO_PIN7_PAD_PULL_LSB
-#define GPIO_PIN7_PAD_PULL_MASK WLAN_GPIO_PIN7_PAD_PULL_MASK
-#define GPIO_PIN7_PAD_PULL_GET(x) WLAN_GPIO_PIN7_PAD_PULL_GET(x)
-#define GPIO_PIN7_PAD_PULL_SET(x) WLAN_GPIO_PIN7_PAD_PULL_SET(x)
-#define GPIO_PIN7_PAD_STRENGTH_MSB WLAN_GPIO_PIN7_PAD_STRENGTH_MSB
-#define GPIO_PIN7_PAD_STRENGTH_LSB WLAN_GPIO_PIN7_PAD_STRENGTH_LSB
-#define GPIO_PIN7_PAD_STRENGTH_MASK WLAN_GPIO_PIN7_PAD_STRENGTH_MASK
-#define GPIO_PIN7_PAD_STRENGTH_GET(x) WLAN_GPIO_PIN7_PAD_STRENGTH_GET(x)
-#define GPIO_PIN7_PAD_STRENGTH_SET(x) WLAN_GPIO_PIN7_PAD_STRENGTH_SET(x)
-#define GPIO_PIN7_PAD_DRIVER_MSB WLAN_GPIO_PIN7_PAD_DRIVER_MSB
-#define GPIO_PIN7_PAD_DRIVER_LSB WLAN_GPIO_PIN7_PAD_DRIVER_LSB
-#define GPIO_PIN7_PAD_DRIVER_MASK WLAN_GPIO_PIN7_PAD_DRIVER_MASK
-#define GPIO_PIN7_PAD_DRIVER_GET(x) WLAN_GPIO_PIN7_PAD_DRIVER_GET(x)
-#define GPIO_PIN7_PAD_DRIVER_SET(x) WLAN_GPIO_PIN7_PAD_DRIVER_SET(x)
-#define GPIO_PIN7_SOURCE_MSB WLAN_GPIO_PIN7_SOURCE_MSB
-#define GPIO_PIN7_SOURCE_LSB WLAN_GPIO_PIN7_SOURCE_LSB
-#define GPIO_PIN7_SOURCE_MASK WLAN_GPIO_PIN7_SOURCE_MASK
-#define GPIO_PIN7_SOURCE_GET(x) WLAN_GPIO_PIN7_SOURCE_GET(x)
-#define GPIO_PIN7_SOURCE_SET(x) WLAN_GPIO_PIN7_SOURCE_SET(x)
-#define GPIO_PIN8_ADDRESS WLAN_GPIO_PIN8_ADDRESS
-#define GPIO_PIN8_OFFSET WLAN_GPIO_PIN8_OFFSET
-#define GPIO_PIN8_CONFIG_MSB WLAN_GPIO_PIN8_CONFIG_MSB
-#define GPIO_PIN8_CONFIG_LSB WLAN_GPIO_PIN8_CONFIG_LSB
-#define GPIO_PIN8_CONFIG_MASK WLAN_GPIO_PIN8_CONFIG_MASK
-#define GPIO_PIN8_CONFIG_GET(x) WLAN_GPIO_PIN8_CONFIG_GET(x)
-#define GPIO_PIN8_CONFIG_SET(x) WLAN_GPIO_PIN8_CONFIG_SET(x)
-#define GPIO_PIN8_WAKEUP_ENABLE_MSB WLAN_GPIO_PIN8_WAKEUP_ENABLE_MSB
-#define GPIO_PIN8_WAKEUP_ENABLE_LSB WLAN_GPIO_PIN8_WAKEUP_ENABLE_LSB
-#define GPIO_PIN8_WAKEUP_ENABLE_MASK WLAN_GPIO_PIN8_WAKEUP_ENABLE_MASK
-#define GPIO_PIN8_WAKEUP_ENABLE_GET(x) WLAN_GPIO_PIN8_WAKEUP_ENABLE_GET(x)
-#define GPIO_PIN8_WAKEUP_ENABLE_SET(x) WLAN_GPIO_PIN8_WAKEUP_ENABLE_SET(x)
-#define GPIO_PIN8_INT_TYPE_MSB WLAN_GPIO_PIN8_INT_TYPE_MSB
-#define GPIO_PIN8_INT_TYPE_LSB WLAN_GPIO_PIN8_INT_TYPE_LSB
-#define GPIO_PIN8_INT_TYPE_MASK WLAN_GPIO_PIN8_INT_TYPE_MASK
-#define GPIO_PIN8_INT_TYPE_GET(x) WLAN_GPIO_PIN8_INT_TYPE_GET(x)
-#define GPIO_PIN8_INT_TYPE_SET(x) WLAN_GPIO_PIN8_INT_TYPE_SET(x)
-#define GPIO_PIN8_PAD_PULL_MSB WLAN_GPIO_PIN8_PAD_PULL_MSB
-#define GPIO_PIN8_PAD_PULL_LSB WLAN_GPIO_PIN8_PAD_PULL_LSB
-#define GPIO_PIN8_PAD_PULL_MASK WLAN_GPIO_PIN8_PAD_PULL_MASK
-#define GPIO_PIN8_PAD_PULL_GET(x) WLAN_GPIO_PIN8_PAD_PULL_GET(x)
-#define GPIO_PIN8_PAD_PULL_SET(x) WLAN_GPIO_PIN8_PAD_PULL_SET(x)
-#define GPIO_PIN8_PAD_STRENGTH_MSB WLAN_GPIO_PIN8_PAD_STRENGTH_MSB
-#define GPIO_PIN8_PAD_STRENGTH_LSB WLAN_GPIO_PIN8_PAD_STRENGTH_LSB
-#define GPIO_PIN8_PAD_STRENGTH_MASK WLAN_GPIO_PIN8_PAD_STRENGTH_MASK
-#define GPIO_PIN8_PAD_STRENGTH_GET(x) WLAN_GPIO_PIN8_PAD_STRENGTH_GET(x)
-#define GPIO_PIN8_PAD_STRENGTH_SET(x) WLAN_GPIO_PIN8_PAD_STRENGTH_SET(x)
-#define GPIO_PIN8_PAD_DRIVER_MSB WLAN_GPIO_PIN8_PAD_DRIVER_MSB
-#define GPIO_PIN8_PAD_DRIVER_LSB WLAN_GPIO_PIN8_PAD_DRIVER_LSB
-#define GPIO_PIN8_PAD_DRIVER_MASK WLAN_GPIO_PIN8_PAD_DRIVER_MASK
-#define GPIO_PIN8_PAD_DRIVER_GET(x) WLAN_GPIO_PIN8_PAD_DRIVER_GET(x)
-#define GPIO_PIN8_PAD_DRIVER_SET(x) WLAN_GPIO_PIN8_PAD_DRIVER_SET(x)
-#define GPIO_PIN8_SOURCE_MSB WLAN_GPIO_PIN8_SOURCE_MSB
-#define GPIO_PIN8_SOURCE_LSB WLAN_GPIO_PIN8_SOURCE_LSB
-#define GPIO_PIN8_SOURCE_MASK WLAN_GPIO_PIN8_SOURCE_MASK
-#define GPIO_PIN8_SOURCE_GET(x) WLAN_GPIO_PIN8_SOURCE_GET(x)
-#define GPIO_PIN8_SOURCE_SET(x) WLAN_GPIO_PIN8_SOURCE_SET(x)
-#define GPIO_PIN9_ADDRESS WLAN_GPIO_PIN9_ADDRESS
-#define GPIO_PIN9_OFFSET WLAN_GPIO_PIN9_OFFSET
-#define GPIO_PIN9_CONFIG_MSB WLAN_GPIO_PIN9_CONFIG_MSB
-#define GPIO_PIN9_CONFIG_LSB WLAN_GPIO_PIN9_CONFIG_LSB
-#define GPIO_PIN9_CONFIG_MASK WLAN_GPIO_PIN9_CONFIG_MASK
-#define GPIO_PIN9_CONFIG_GET(x) WLAN_GPIO_PIN9_CONFIG_GET(x)
-#define GPIO_PIN9_CONFIG_SET(x) WLAN_GPIO_PIN9_CONFIG_SET(x)
-#define GPIO_PIN9_WAKEUP_ENABLE_MSB WLAN_GPIO_PIN9_WAKEUP_ENABLE_MSB
-#define GPIO_PIN9_WAKEUP_ENABLE_LSB WLAN_GPIO_PIN9_WAKEUP_ENABLE_LSB
-#define GPIO_PIN9_WAKEUP_ENABLE_MASK WLAN_GPIO_PIN9_WAKEUP_ENABLE_MASK
-#define GPIO_PIN9_WAKEUP_ENABLE_GET(x) WLAN_GPIO_PIN9_WAKEUP_ENABLE_GET(x)
-#define GPIO_PIN9_WAKEUP_ENABLE_SET(x) WLAN_GPIO_PIN9_WAKEUP_ENABLE_SET(x)
-#define GPIO_PIN9_INT_TYPE_MSB WLAN_GPIO_PIN9_INT_TYPE_MSB
-#define GPIO_PIN9_INT_TYPE_LSB WLAN_GPIO_PIN9_INT_TYPE_LSB
-#define GPIO_PIN9_INT_TYPE_MASK WLAN_GPIO_PIN9_INT_TYPE_MASK
-#define GPIO_PIN9_INT_TYPE_GET(x) WLAN_GPIO_PIN9_INT_TYPE_GET(x)
-#define GPIO_PIN9_INT_TYPE_SET(x) WLAN_GPIO_PIN9_INT_TYPE_SET(x)
-#define GPIO_PIN9_PAD_PULL_MSB WLAN_GPIO_PIN9_PAD_PULL_MSB
-#define GPIO_PIN9_PAD_PULL_LSB WLAN_GPIO_PIN9_PAD_PULL_LSB
-#define GPIO_PIN9_PAD_PULL_MASK WLAN_GPIO_PIN9_PAD_PULL_MASK
-#define GPIO_PIN9_PAD_PULL_GET(x) WLAN_GPIO_PIN9_PAD_PULL_GET(x)
-#define GPIO_PIN9_PAD_PULL_SET(x) WLAN_GPIO_PIN9_PAD_PULL_SET(x)
-#define GPIO_PIN9_PAD_STRENGTH_MSB WLAN_GPIO_PIN9_PAD_STRENGTH_MSB
-#define GPIO_PIN9_PAD_STRENGTH_LSB WLAN_GPIO_PIN9_PAD_STRENGTH_LSB
-#define GPIO_PIN9_PAD_STRENGTH_MASK WLAN_GPIO_PIN9_PAD_STRENGTH_MASK
-#define GPIO_PIN9_PAD_STRENGTH_GET(x) WLAN_GPIO_PIN9_PAD_STRENGTH_GET(x)
-#define GPIO_PIN9_PAD_STRENGTH_SET(x) WLAN_GPIO_PIN9_PAD_STRENGTH_SET(x)
-#define GPIO_PIN9_PAD_DRIVER_MSB WLAN_GPIO_PIN9_PAD_DRIVER_MSB
-#define GPIO_PIN9_PAD_DRIVER_LSB WLAN_GPIO_PIN9_PAD_DRIVER_LSB
-#define GPIO_PIN9_PAD_DRIVER_MASK WLAN_GPIO_PIN9_PAD_DRIVER_MASK
-#define GPIO_PIN9_PAD_DRIVER_GET(x) WLAN_GPIO_PIN9_PAD_DRIVER_GET(x)
-#define GPIO_PIN9_PAD_DRIVER_SET(x) WLAN_GPIO_PIN9_PAD_DRIVER_SET(x)
-#define GPIO_PIN9_SOURCE_MSB WLAN_GPIO_PIN9_SOURCE_MSB
-#define GPIO_PIN9_SOURCE_LSB WLAN_GPIO_PIN9_SOURCE_LSB
-#define GPIO_PIN9_SOURCE_MASK WLAN_GPIO_PIN9_SOURCE_MASK
-#define GPIO_PIN9_SOURCE_GET(x) WLAN_GPIO_PIN9_SOURCE_GET(x)
-#define GPIO_PIN9_SOURCE_SET(x) WLAN_GPIO_PIN9_SOURCE_SET(x)
-#define GPIO_PIN10_ADDRESS WLAN_GPIO_PIN10_ADDRESS
-#define GPIO_PIN10_OFFSET WLAN_GPIO_PIN10_OFFSET
-#define GPIO_PIN10_CONFIG_MSB WLAN_GPIO_PIN10_CONFIG_MSB
-#define GPIO_PIN10_CONFIG_LSB WLAN_GPIO_PIN10_CONFIG_LSB
-#define GPIO_PIN10_CONFIG_MASK WLAN_GPIO_PIN10_CONFIG_MASK
-#define GPIO_PIN10_CONFIG_GET(x) WLAN_GPIO_PIN10_CONFIG_GET(x)
-#define GPIO_PIN10_CONFIG_SET(x) WLAN_GPIO_PIN10_CONFIG_SET(x)
-#define GPIO_PIN10_WAKEUP_ENABLE_MSB WLAN_GPIO_PIN10_WAKEUP_ENABLE_MSB
-#define GPIO_PIN10_WAKEUP_ENABLE_LSB WLAN_GPIO_PIN10_WAKEUP_ENABLE_LSB
-#define GPIO_PIN10_WAKEUP_ENABLE_MASK WLAN_GPIO_PIN10_WAKEUP_ENABLE_MASK
-#define GPIO_PIN10_WAKEUP_ENABLE_GET(x) WLAN_GPIO_PIN10_WAKEUP_ENABLE_GET(x)
-#define GPIO_PIN10_WAKEUP_ENABLE_SET(x) WLAN_GPIO_PIN10_WAKEUP_ENABLE_SET(x)
-#define GPIO_PIN10_INT_TYPE_MSB WLAN_GPIO_PIN10_INT_TYPE_MSB
-#define GPIO_PIN10_INT_TYPE_LSB WLAN_GPIO_PIN10_INT_TYPE_LSB
-#define GPIO_PIN10_INT_TYPE_MASK WLAN_GPIO_PIN10_INT_TYPE_MASK
-#define GPIO_PIN10_INT_TYPE_GET(x) WLAN_GPIO_PIN10_INT_TYPE_GET(x)
-#define GPIO_PIN10_INT_TYPE_SET(x) WLAN_GPIO_PIN10_INT_TYPE_SET(x)
-#define GPIO_PIN10_PAD_PULL_MSB WLAN_GPIO_PIN10_PAD_PULL_MSB
-#define GPIO_PIN10_PAD_PULL_LSB WLAN_GPIO_PIN10_PAD_PULL_LSB
-#define GPIO_PIN10_PAD_PULL_MASK WLAN_GPIO_PIN10_PAD_PULL_MASK
-#define GPIO_PIN10_PAD_PULL_GET(x) WLAN_GPIO_PIN10_PAD_PULL_GET(x)
-#define GPIO_PIN10_PAD_PULL_SET(x) WLAN_GPIO_PIN10_PAD_PULL_SET(x)
-#define GPIO_PIN10_PAD_STRENGTH_MSB WLAN_GPIO_PIN10_PAD_STRENGTH_MSB
-#define GPIO_PIN10_PAD_STRENGTH_LSB WLAN_GPIO_PIN10_PAD_STRENGTH_LSB
-#define GPIO_PIN10_PAD_STRENGTH_MASK WLAN_GPIO_PIN10_PAD_STRENGTH_MASK
-#define GPIO_PIN10_PAD_STRENGTH_GET(x) WLAN_GPIO_PIN10_PAD_STRENGTH_GET(x)
-#define GPIO_PIN10_PAD_STRENGTH_SET(x) WLAN_GPIO_PIN10_PAD_STRENGTH_SET(x)
-#define GPIO_PIN10_PAD_DRIVER_MSB WLAN_GPIO_PIN10_PAD_DRIVER_MSB
-#define GPIO_PIN10_PAD_DRIVER_LSB WLAN_GPIO_PIN10_PAD_DRIVER_LSB
-#define GPIO_PIN10_PAD_DRIVER_MASK WLAN_GPIO_PIN10_PAD_DRIVER_MASK
-#define GPIO_PIN10_PAD_DRIVER_GET(x) WLAN_GPIO_PIN10_PAD_DRIVER_GET(x)
-#define GPIO_PIN10_PAD_DRIVER_SET(x) WLAN_GPIO_PIN10_PAD_DRIVER_SET(x)
-#define GPIO_PIN10_SOURCE_MSB WLAN_GPIO_PIN10_SOURCE_MSB
-#define GPIO_PIN10_SOURCE_LSB WLAN_GPIO_PIN10_SOURCE_LSB
-#define GPIO_PIN10_SOURCE_MASK WLAN_GPIO_PIN10_SOURCE_MASK
-#define GPIO_PIN10_SOURCE_GET(x) WLAN_GPIO_PIN10_SOURCE_GET(x)
-#define GPIO_PIN10_SOURCE_SET(x) WLAN_GPIO_PIN10_SOURCE_SET(x)
-#define GPIO_PIN11_ADDRESS WLAN_GPIO_PIN11_ADDRESS
-#define GPIO_PIN11_OFFSET WLAN_GPIO_PIN11_OFFSET
-#define GPIO_PIN11_CONFIG_MSB WLAN_GPIO_PIN11_CONFIG_MSB
-#define GPIO_PIN11_CONFIG_LSB WLAN_GPIO_PIN11_CONFIG_LSB
-#define GPIO_PIN11_CONFIG_MASK WLAN_GPIO_PIN11_CONFIG_MASK
-#define GPIO_PIN11_CONFIG_GET(x) WLAN_GPIO_PIN11_CONFIG_GET(x)
-#define GPIO_PIN11_CONFIG_SET(x) WLAN_GPIO_PIN11_CONFIG_SET(x)
-#define GPIO_PIN11_WAKEUP_ENABLE_MSB WLAN_GPIO_PIN11_WAKEUP_ENABLE_MSB
-#define GPIO_PIN11_WAKEUP_ENABLE_LSB WLAN_GPIO_PIN11_WAKEUP_ENABLE_LSB
-#define GPIO_PIN11_WAKEUP_ENABLE_MASK WLAN_GPIO_PIN11_WAKEUP_ENABLE_MASK
-#define GPIO_PIN11_WAKEUP_ENABLE_GET(x) WLAN_GPIO_PIN11_WAKEUP_ENABLE_GET(x)
-#define GPIO_PIN11_WAKEUP_ENABLE_SET(x) WLAN_GPIO_PIN11_WAKEUP_ENABLE_SET(x)
-#define GPIO_PIN11_INT_TYPE_MSB WLAN_GPIO_PIN11_INT_TYPE_MSB
-#define GPIO_PIN11_INT_TYPE_LSB WLAN_GPIO_PIN11_INT_TYPE_LSB
-#define GPIO_PIN11_INT_TYPE_MASK WLAN_GPIO_PIN11_INT_TYPE_MASK
-#define GPIO_PIN11_INT_TYPE_GET(x) WLAN_GPIO_PIN11_INT_TYPE_GET(x)
-#define GPIO_PIN11_INT_TYPE_SET(x) WLAN_GPIO_PIN11_INT_TYPE_SET(x)
-#define GPIO_PIN11_PAD_PULL_MSB WLAN_GPIO_PIN11_PAD_PULL_MSB
-#define GPIO_PIN11_PAD_PULL_LSB WLAN_GPIO_PIN11_PAD_PULL_LSB
-#define GPIO_PIN11_PAD_PULL_MASK WLAN_GPIO_PIN11_PAD_PULL_MASK
-#define GPIO_PIN11_PAD_PULL_GET(x) WLAN_GPIO_PIN11_PAD_PULL_GET(x)
-#define GPIO_PIN11_PAD_PULL_SET(x) WLAN_GPIO_PIN11_PAD_PULL_SET(x)
-#define GPIO_PIN11_PAD_STRENGTH_MSB WLAN_GPIO_PIN11_PAD_STRENGTH_MSB
-#define GPIO_PIN11_PAD_STRENGTH_LSB WLAN_GPIO_PIN11_PAD_STRENGTH_LSB
-#define GPIO_PIN11_PAD_STRENGTH_MASK WLAN_GPIO_PIN11_PAD_STRENGTH_MASK
-#define GPIO_PIN11_PAD_STRENGTH_GET(x) WLAN_GPIO_PIN11_PAD_STRENGTH_GET(x)
-#define GPIO_PIN11_PAD_STRENGTH_SET(x) WLAN_GPIO_PIN11_PAD_STRENGTH_SET(x)
-#define GPIO_PIN11_PAD_DRIVER_MSB WLAN_GPIO_PIN11_PAD_DRIVER_MSB
-#define GPIO_PIN11_PAD_DRIVER_LSB WLAN_GPIO_PIN11_PAD_DRIVER_LSB
-#define GPIO_PIN11_PAD_DRIVER_MASK WLAN_GPIO_PIN11_PAD_DRIVER_MASK
-#define GPIO_PIN11_PAD_DRIVER_GET(x) WLAN_GPIO_PIN11_PAD_DRIVER_GET(x)
-#define GPIO_PIN11_PAD_DRIVER_SET(x) WLAN_GPIO_PIN11_PAD_DRIVER_SET(x)
-#define GPIO_PIN11_SOURCE_MSB WLAN_GPIO_PIN11_SOURCE_MSB
-#define GPIO_PIN11_SOURCE_LSB WLAN_GPIO_PIN11_SOURCE_LSB
-#define GPIO_PIN11_SOURCE_MASK WLAN_GPIO_PIN11_SOURCE_MASK
-#define GPIO_PIN11_SOURCE_GET(x) WLAN_GPIO_PIN11_SOURCE_GET(x)
-#define GPIO_PIN11_SOURCE_SET(x) WLAN_GPIO_PIN11_SOURCE_SET(x)
-#define GPIO_PIN12_ADDRESS WLAN_GPIO_PIN12_ADDRESS
-#define GPIO_PIN12_OFFSET WLAN_GPIO_PIN12_OFFSET
-#define GPIO_PIN12_CONFIG_MSB WLAN_GPIO_PIN12_CONFIG_MSB
-#define GPIO_PIN12_CONFIG_LSB WLAN_GPIO_PIN12_CONFIG_LSB
-#define GPIO_PIN12_CONFIG_MASK WLAN_GPIO_PIN12_CONFIG_MASK
-#define GPIO_PIN12_CONFIG_GET(x) WLAN_GPIO_PIN12_CONFIG_GET(x)
-#define GPIO_PIN12_CONFIG_SET(x) WLAN_GPIO_PIN12_CONFIG_SET(x)
-#define GPIO_PIN12_WAKEUP_ENABLE_MSB WLAN_GPIO_PIN12_WAKEUP_ENABLE_MSB
-#define GPIO_PIN12_WAKEUP_ENABLE_LSB WLAN_GPIO_PIN12_WAKEUP_ENABLE_LSB
-#define GPIO_PIN12_WAKEUP_ENABLE_MASK WLAN_GPIO_PIN12_WAKEUP_ENABLE_MASK
-#define GPIO_PIN12_WAKEUP_ENABLE_GET(x) WLAN_GPIO_PIN12_WAKEUP_ENABLE_GET(x)
-#define GPIO_PIN12_WAKEUP_ENABLE_SET(x) WLAN_GPIO_PIN12_WAKEUP_ENABLE_SET(x)
-#define GPIO_PIN12_INT_TYPE_MSB WLAN_GPIO_PIN12_INT_TYPE_MSB
-#define GPIO_PIN12_INT_TYPE_LSB WLAN_GPIO_PIN12_INT_TYPE_LSB
-#define GPIO_PIN12_INT_TYPE_MASK WLAN_GPIO_PIN12_INT_TYPE_MASK
-#define GPIO_PIN12_INT_TYPE_GET(x) WLAN_GPIO_PIN12_INT_TYPE_GET(x)
-#define GPIO_PIN12_INT_TYPE_SET(x) WLAN_GPIO_PIN12_INT_TYPE_SET(x)
-#define GPIO_PIN12_PAD_PULL_MSB WLAN_GPIO_PIN12_PAD_PULL_MSB
-#define GPIO_PIN12_PAD_PULL_LSB WLAN_GPIO_PIN12_PAD_PULL_LSB
-#define GPIO_PIN12_PAD_PULL_MASK WLAN_GPIO_PIN12_PAD_PULL_MASK
-#define GPIO_PIN12_PAD_PULL_GET(x) WLAN_GPIO_PIN12_PAD_PULL_GET(x)
-#define GPIO_PIN12_PAD_PULL_SET(x) WLAN_GPIO_PIN12_PAD_PULL_SET(x)
-#define GPIO_PIN12_PAD_STRENGTH_MSB WLAN_GPIO_PIN12_PAD_STRENGTH_MSB
-#define GPIO_PIN12_PAD_STRENGTH_LSB WLAN_GPIO_PIN12_PAD_STRENGTH_LSB
-#define GPIO_PIN12_PAD_STRENGTH_MASK WLAN_GPIO_PIN12_PAD_STRENGTH_MASK
-#define GPIO_PIN12_PAD_STRENGTH_GET(x) WLAN_GPIO_PIN12_PAD_STRENGTH_GET(x)
-#define GPIO_PIN12_PAD_STRENGTH_SET(x) WLAN_GPIO_PIN12_PAD_STRENGTH_SET(x)
-#define GPIO_PIN12_PAD_DRIVER_MSB WLAN_GPIO_PIN12_PAD_DRIVER_MSB
-#define GPIO_PIN12_PAD_DRIVER_LSB WLAN_GPIO_PIN12_PAD_DRIVER_LSB
-#define GPIO_PIN12_PAD_DRIVER_MASK WLAN_GPIO_PIN12_PAD_DRIVER_MASK
-#define GPIO_PIN12_PAD_DRIVER_GET(x) WLAN_GPIO_PIN12_PAD_DRIVER_GET(x)
-#define GPIO_PIN12_PAD_DRIVER_SET(x) WLAN_GPIO_PIN12_PAD_DRIVER_SET(x)
-#define GPIO_PIN12_SOURCE_MSB WLAN_GPIO_PIN12_SOURCE_MSB
-#define GPIO_PIN12_SOURCE_LSB WLAN_GPIO_PIN12_SOURCE_LSB
-#define GPIO_PIN12_SOURCE_MASK WLAN_GPIO_PIN12_SOURCE_MASK
-#define GPIO_PIN12_SOURCE_GET(x) WLAN_GPIO_PIN12_SOURCE_GET(x)
-#define GPIO_PIN12_SOURCE_SET(x) WLAN_GPIO_PIN12_SOURCE_SET(x)
-#define GPIO_PIN13_ADDRESS WLAN_GPIO_PIN13_ADDRESS
-#define GPIO_PIN13_OFFSET WLAN_GPIO_PIN13_OFFSET
-#define GPIO_PIN13_CONFIG_MSB WLAN_GPIO_PIN13_CONFIG_MSB
-#define GPIO_PIN13_CONFIG_LSB WLAN_GPIO_PIN13_CONFIG_LSB
-#define GPIO_PIN13_CONFIG_MASK WLAN_GPIO_PIN13_CONFIG_MASK
-#define GPIO_PIN13_CONFIG_GET(x) WLAN_GPIO_PIN13_CONFIG_GET(x)
-#define GPIO_PIN13_CONFIG_SET(x) WLAN_GPIO_PIN13_CONFIG_SET(x)
-#define GPIO_PIN13_WAKEUP_ENABLE_MSB WLAN_GPIO_PIN13_WAKEUP_ENABLE_MSB
-#define GPIO_PIN13_WAKEUP_ENABLE_LSB WLAN_GPIO_PIN13_WAKEUP_ENABLE_LSB
-#define GPIO_PIN13_WAKEUP_ENABLE_MASK WLAN_GPIO_PIN13_WAKEUP_ENABLE_MASK
-#define GPIO_PIN13_WAKEUP_ENABLE_GET(x) WLAN_GPIO_PIN13_WAKEUP_ENABLE_GET(x)
-#define GPIO_PIN13_WAKEUP_ENABLE_SET(x) WLAN_GPIO_PIN13_WAKEUP_ENABLE_SET(x)
-#define GPIO_PIN13_INT_TYPE_MSB WLAN_GPIO_PIN13_INT_TYPE_MSB
-#define GPIO_PIN13_INT_TYPE_LSB WLAN_GPIO_PIN13_INT_TYPE_LSB
-#define GPIO_PIN13_INT_TYPE_MASK WLAN_GPIO_PIN13_INT_TYPE_MASK
-#define GPIO_PIN13_INT_TYPE_GET(x) WLAN_GPIO_PIN13_INT_TYPE_GET(x)
-#define GPIO_PIN13_INT_TYPE_SET(x) WLAN_GPIO_PIN13_INT_TYPE_SET(x)
-#define GPIO_PIN13_PAD_PULL_MSB WLAN_GPIO_PIN13_PAD_PULL_MSB
-#define GPIO_PIN13_PAD_PULL_LSB WLAN_GPIO_PIN13_PAD_PULL_LSB
-#define GPIO_PIN13_PAD_PULL_MASK WLAN_GPIO_PIN13_PAD_PULL_MASK
-#define GPIO_PIN13_PAD_PULL_GET(x) WLAN_GPIO_PIN13_PAD_PULL_GET(x)
-#define GPIO_PIN13_PAD_PULL_SET(x) WLAN_GPIO_PIN13_PAD_PULL_SET(x)
-#define GPIO_PIN13_PAD_STRENGTH_MSB WLAN_GPIO_PIN13_PAD_STRENGTH_MSB
-#define GPIO_PIN13_PAD_STRENGTH_LSB WLAN_GPIO_PIN13_PAD_STRENGTH_LSB
-#define GPIO_PIN13_PAD_STRENGTH_MASK WLAN_GPIO_PIN13_PAD_STRENGTH_MASK
-#define GPIO_PIN13_PAD_STRENGTH_GET(x) WLAN_GPIO_PIN13_PAD_STRENGTH_GET(x)
-#define GPIO_PIN13_PAD_STRENGTH_SET(x) WLAN_GPIO_PIN13_PAD_STRENGTH_SET(x)
-#define GPIO_PIN13_PAD_DRIVER_MSB WLAN_GPIO_PIN13_PAD_DRIVER_MSB
-#define GPIO_PIN13_PAD_DRIVER_LSB WLAN_GPIO_PIN13_PAD_DRIVER_LSB
-#define GPIO_PIN13_PAD_DRIVER_MASK WLAN_GPIO_PIN13_PAD_DRIVER_MASK
-#define GPIO_PIN13_PAD_DRIVER_GET(x) WLAN_GPIO_PIN13_PAD_DRIVER_GET(x)
-#define GPIO_PIN13_PAD_DRIVER_SET(x) WLAN_GPIO_PIN13_PAD_DRIVER_SET(x)
-#define GPIO_PIN13_SOURCE_MSB WLAN_GPIO_PIN13_SOURCE_MSB
-#define GPIO_PIN13_SOURCE_LSB WLAN_GPIO_PIN13_SOURCE_LSB
-#define GPIO_PIN13_SOURCE_MASK WLAN_GPIO_PIN13_SOURCE_MASK
-#define GPIO_PIN13_SOURCE_GET(x) WLAN_GPIO_PIN13_SOURCE_GET(x)
-#define GPIO_PIN13_SOURCE_SET(x) WLAN_GPIO_PIN13_SOURCE_SET(x)
-#define GPIO_PIN14_ADDRESS WLAN_GPIO_PIN14_ADDRESS
-#define GPIO_PIN14_OFFSET WLAN_GPIO_PIN14_OFFSET
-#define GPIO_PIN14_CONFIG_MSB WLAN_GPIO_PIN14_CONFIG_MSB
-#define GPIO_PIN14_CONFIG_LSB WLAN_GPIO_PIN14_CONFIG_LSB
-#define GPIO_PIN14_CONFIG_MASK WLAN_GPIO_PIN14_CONFIG_MASK
-#define GPIO_PIN14_CONFIG_GET(x) WLAN_GPIO_PIN14_CONFIG_GET(x)
-#define GPIO_PIN14_CONFIG_SET(x) WLAN_GPIO_PIN14_CONFIG_SET(x)
-#define GPIO_PIN14_WAKEUP_ENABLE_MSB WLAN_GPIO_PIN14_WAKEUP_ENABLE_MSB
-#define GPIO_PIN14_WAKEUP_ENABLE_LSB WLAN_GPIO_PIN14_WAKEUP_ENABLE_LSB
-#define GPIO_PIN14_WAKEUP_ENABLE_MASK WLAN_GPIO_PIN14_WAKEUP_ENABLE_MASK
-#define GPIO_PIN14_WAKEUP_ENABLE_GET(x) WLAN_GPIO_PIN14_WAKEUP_ENABLE_GET(x)
-#define GPIO_PIN14_WAKEUP_ENABLE_SET(x) WLAN_GPIO_PIN14_WAKEUP_ENABLE_SET(x)
-#define GPIO_PIN14_INT_TYPE_MSB WLAN_GPIO_PIN14_INT_TYPE_MSB
-#define GPIO_PIN14_INT_TYPE_LSB WLAN_GPIO_PIN14_INT_TYPE_LSB
-#define GPIO_PIN14_INT_TYPE_MASK WLAN_GPIO_PIN14_INT_TYPE_MASK
-#define GPIO_PIN14_INT_TYPE_GET(x) WLAN_GPIO_PIN14_INT_TYPE_GET(x)
-#define GPIO_PIN14_INT_TYPE_SET(x) WLAN_GPIO_PIN14_INT_TYPE_SET(x)
-#define GPIO_PIN14_PAD_PULL_MSB WLAN_GPIO_PIN14_PAD_PULL_MSB
-#define GPIO_PIN14_PAD_PULL_LSB WLAN_GPIO_PIN14_PAD_PULL_LSB
-#define GPIO_PIN14_PAD_PULL_MASK WLAN_GPIO_PIN14_PAD_PULL_MASK
-#define GPIO_PIN14_PAD_PULL_GET(x) WLAN_GPIO_PIN14_PAD_PULL_GET(x)
-#define GPIO_PIN14_PAD_PULL_SET(x) WLAN_GPIO_PIN14_PAD_PULL_SET(x)
-#define GPIO_PIN14_PAD_STRENGTH_MSB WLAN_GPIO_PIN14_PAD_STRENGTH_MSB
-#define GPIO_PIN14_PAD_STRENGTH_LSB WLAN_GPIO_PIN14_PAD_STRENGTH_LSB
-#define GPIO_PIN14_PAD_STRENGTH_MASK WLAN_GPIO_PIN14_PAD_STRENGTH_MASK
-#define GPIO_PIN14_PAD_STRENGTH_GET(x) WLAN_GPIO_PIN14_PAD_STRENGTH_GET(x)
-#define GPIO_PIN14_PAD_STRENGTH_SET(x) WLAN_GPIO_PIN14_PAD_STRENGTH_SET(x)
-#define GPIO_PIN14_PAD_DRIVER_MSB WLAN_GPIO_PIN14_PAD_DRIVER_MSB
-#define GPIO_PIN14_PAD_DRIVER_LSB WLAN_GPIO_PIN14_PAD_DRIVER_LSB
-#define GPIO_PIN14_PAD_DRIVER_MASK WLAN_GPIO_PIN14_PAD_DRIVER_MASK
-#define GPIO_PIN14_PAD_DRIVER_GET(x) WLAN_GPIO_PIN14_PAD_DRIVER_GET(x)
-#define GPIO_PIN14_PAD_DRIVER_SET(x) WLAN_GPIO_PIN14_PAD_DRIVER_SET(x)
-#define GPIO_PIN14_SOURCE_MSB WLAN_GPIO_PIN14_SOURCE_MSB
-#define GPIO_PIN14_SOURCE_LSB WLAN_GPIO_PIN14_SOURCE_LSB
-#define GPIO_PIN14_SOURCE_MASK WLAN_GPIO_PIN14_SOURCE_MASK
-#define GPIO_PIN14_SOURCE_GET(x) WLAN_GPIO_PIN14_SOURCE_GET(x)
-#define GPIO_PIN14_SOURCE_SET(x) WLAN_GPIO_PIN14_SOURCE_SET(x)
-#define GPIO_PIN15_ADDRESS WLAN_GPIO_PIN15_ADDRESS
-#define GPIO_PIN15_OFFSET WLAN_GPIO_PIN15_OFFSET
-#define GPIO_PIN15_CONFIG_MSB WLAN_GPIO_PIN15_CONFIG_MSB
-#define GPIO_PIN15_CONFIG_LSB WLAN_GPIO_PIN15_CONFIG_LSB
-#define GPIO_PIN15_CONFIG_MASK WLAN_GPIO_PIN15_CONFIG_MASK
-#define GPIO_PIN15_CONFIG_GET(x) WLAN_GPIO_PIN15_CONFIG_GET(x)
-#define GPIO_PIN15_CONFIG_SET(x) WLAN_GPIO_PIN15_CONFIG_SET(x)
-#define GPIO_PIN15_WAKEUP_ENABLE_MSB WLAN_GPIO_PIN15_WAKEUP_ENABLE_MSB
-#define GPIO_PIN15_WAKEUP_ENABLE_LSB WLAN_GPIO_PIN15_WAKEUP_ENABLE_LSB
-#define GPIO_PIN15_WAKEUP_ENABLE_MASK WLAN_GPIO_PIN15_WAKEUP_ENABLE_MASK
-#define GPIO_PIN15_WAKEUP_ENABLE_GET(x) WLAN_GPIO_PIN15_WAKEUP_ENABLE_GET(x)
-#define GPIO_PIN15_WAKEUP_ENABLE_SET(x) WLAN_GPIO_PIN15_WAKEUP_ENABLE_SET(x)
-#define GPIO_PIN15_INT_TYPE_MSB WLAN_GPIO_PIN15_INT_TYPE_MSB
-#define GPIO_PIN15_INT_TYPE_LSB WLAN_GPIO_PIN15_INT_TYPE_LSB
-#define GPIO_PIN15_INT_TYPE_MASK WLAN_GPIO_PIN15_INT_TYPE_MASK
-#define GPIO_PIN15_INT_TYPE_GET(x) WLAN_GPIO_PIN15_INT_TYPE_GET(x)
-#define GPIO_PIN15_INT_TYPE_SET(x) WLAN_GPIO_PIN15_INT_TYPE_SET(x)
-#define GPIO_PIN15_PAD_PULL_MSB WLAN_GPIO_PIN15_PAD_PULL_MSB
-#define GPIO_PIN15_PAD_PULL_LSB WLAN_GPIO_PIN15_PAD_PULL_LSB
-#define GPIO_PIN15_PAD_PULL_MASK WLAN_GPIO_PIN15_PAD_PULL_MASK
-#define GPIO_PIN15_PAD_PULL_GET(x) WLAN_GPIO_PIN15_PAD_PULL_GET(x)
-#define GPIO_PIN15_PAD_PULL_SET(x) WLAN_GPIO_PIN15_PAD_PULL_SET(x)
-#define GPIO_PIN15_PAD_STRENGTH_MSB WLAN_GPIO_PIN15_PAD_STRENGTH_MSB
-#define GPIO_PIN15_PAD_STRENGTH_LSB WLAN_GPIO_PIN15_PAD_STRENGTH_LSB
-#define GPIO_PIN15_PAD_STRENGTH_MASK WLAN_GPIO_PIN15_PAD_STRENGTH_MASK
-#define GPIO_PIN15_PAD_STRENGTH_GET(x) WLAN_GPIO_PIN15_PAD_STRENGTH_GET(x)
-#define GPIO_PIN15_PAD_STRENGTH_SET(x) WLAN_GPIO_PIN15_PAD_STRENGTH_SET(x)
-#define GPIO_PIN15_PAD_DRIVER_MSB WLAN_GPIO_PIN15_PAD_DRIVER_MSB
-#define GPIO_PIN15_PAD_DRIVER_LSB WLAN_GPIO_PIN15_PAD_DRIVER_LSB
-#define GPIO_PIN15_PAD_DRIVER_MASK WLAN_GPIO_PIN15_PAD_DRIVER_MASK
-#define GPIO_PIN15_PAD_DRIVER_GET(x) WLAN_GPIO_PIN15_PAD_DRIVER_GET(x)
-#define GPIO_PIN15_PAD_DRIVER_SET(x) WLAN_GPIO_PIN15_PAD_DRIVER_SET(x)
-#define GPIO_PIN15_SOURCE_MSB WLAN_GPIO_PIN15_SOURCE_MSB
-#define GPIO_PIN15_SOURCE_LSB WLAN_GPIO_PIN15_SOURCE_LSB
-#define GPIO_PIN15_SOURCE_MASK WLAN_GPIO_PIN15_SOURCE_MASK
-#define GPIO_PIN15_SOURCE_GET(x) WLAN_GPIO_PIN15_SOURCE_GET(x)
-#define GPIO_PIN15_SOURCE_SET(x) WLAN_GPIO_PIN15_SOURCE_SET(x)
-#define GPIO_PIN16_ADDRESS WLAN_GPIO_PIN16_ADDRESS
-#define GPIO_PIN16_OFFSET WLAN_GPIO_PIN16_OFFSET
-#define GPIO_PIN16_CONFIG_MSB WLAN_GPIO_PIN16_CONFIG_MSB
-#define GPIO_PIN16_CONFIG_LSB WLAN_GPIO_PIN16_CONFIG_LSB
-#define GPIO_PIN16_CONFIG_MASK WLAN_GPIO_PIN16_CONFIG_MASK
-#define GPIO_PIN16_CONFIG_GET(x) WLAN_GPIO_PIN16_CONFIG_GET(x)
-#define GPIO_PIN16_CONFIG_SET(x) WLAN_GPIO_PIN16_CONFIG_SET(x)
-#define GPIO_PIN16_WAKEUP_ENABLE_MSB WLAN_GPIO_PIN16_WAKEUP_ENABLE_MSB
-#define GPIO_PIN16_WAKEUP_ENABLE_LSB WLAN_GPIO_PIN16_WAKEUP_ENABLE_LSB
-#define GPIO_PIN16_WAKEUP_ENABLE_MASK WLAN_GPIO_PIN16_WAKEUP_ENABLE_MASK
-#define GPIO_PIN16_WAKEUP_ENABLE_GET(x) WLAN_GPIO_PIN16_WAKEUP_ENABLE_GET(x)
-#define GPIO_PIN16_WAKEUP_ENABLE_SET(x) WLAN_GPIO_PIN16_WAKEUP_ENABLE_SET(x)
-#define GPIO_PIN16_INT_TYPE_MSB WLAN_GPIO_PIN16_INT_TYPE_MSB
-#define GPIO_PIN16_INT_TYPE_LSB WLAN_GPIO_PIN16_INT_TYPE_LSB
-#define GPIO_PIN16_INT_TYPE_MASK WLAN_GPIO_PIN16_INT_TYPE_MASK
-#define GPIO_PIN16_INT_TYPE_GET(x) WLAN_GPIO_PIN16_INT_TYPE_GET(x)
-#define GPIO_PIN16_INT_TYPE_SET(x) WLAN_GPIO_PIN16_INT_TYPE_SET(x)
-#define GPIO_PIN16_PAD_PULL_MSB WLAN_GPIO_PIN16_PAD_PULL_MSB
-#define GPIO_PIN16_PAD_PULL_LSB WLAN_GPIO_PIN16_PAD_PULL_LSB
-#define GPIO_PIN16_PAD_PULL_MASK WLAN_GPIO_PIN16_PAD_PULL_MASK
-#define GPIO_PIN16_PAD_PULL_GET(x) WLAN_GPIO_PIN16_PAD_PULL_GET(x)
-#define GPIO_PIN16_PAD_PULL_SET(x) WLAN_GPIO_PIN16_PAD_PULL_SET(x)
-#define GPIO_PIN16_PAD_STRENGTH_MSB WLAN_GPIO_PIN16_PAD_STRENGTH_MSB
-#define GPIO_PIN16_PAD_STRENGTH_LSB WLAN_GPIO_PIN16_PAD_STRENGTH_LSB
-#define GPIO_PIN16_PAD_STRENGTH_MASK WLAN_GPIO_PIN16_PAD_STRENGTH_MASK
-#define GPIO_PIN16_PAD_STRENGTH_GET(x) WLAN_GPIO_PIN16_PAD_STRENGTH_GET(x)
-#define GPIO_PIN16_PAD_STRENGTH_SET(x) WLAN_GPIO_PIN16_PAD_STRENGTH_SET(x)
-#define GPIO_PIN16_PAD_DRIVER_MSB WLAN_GPIO_PIN16_PAD_DRIVER_MSB
-#define GPIO_PIN16_PAD_DRIVER_LSB WLAN_GPIO_PIN16_PAD_DRIVER_LSB
-#define GPIO_PIN16_PAD_DRIVER_MASK WLAN_GPIO_PIN16_PAD_DRIVER_MASK
-#define GPIO_PIN16_PAD_DRIVER_GET(x) WLAN_GPIO_PIN16_PAD_DRIVER_GET(x)
-#define GPIO_PIN16_PAD_DRIVER_SET(x) WLAN_GPIO_PIN16_PAD_DRIVER_SET(x)
-#define GPIO_PIN16_SOURCE_MSB WLAN_GPIO_PIN16_SOURCE_MSB
-#define GPIO_PIN16_SOURCE_LSB WLAN_GPIO_PIN16_SOURCE_LSB
-#define GPIO_PIN16_SOURCE_MASK WLAN_GPIO_PIN16_SOURCE_MASK
-#define GPIO_PIN16_SOURCE_GET(x) WLAN_GPIO_PIN16_SOURCE_GET(x)
-#define GPIO_PIN16_SOURCE_SET(x) WLAN_GPIO_PIN16_SOURCE_SET(x)
-#define GPIO_PIN17_ADDRESS WLAN_GPIO_PIN17_ADDRESS
-#define GPIO_PIN17_OFFSET WLAN_GPIO_PIN17_OFFSET
-#define GPIO_PIN17_CONFIG_MSB WLAN_GPIO_PIN17_CONFIG_MSB
-#define GPIO_PIN17_CONFIG_LSB WLAN_GPIO_PIN17_CONFIG_LSB
-#define GPIO_PIN17_CONFIG_MASK WLAN_GPIO_PIN17_CONFIG_MASK
-#define GPIO_PIN17_CONFIG_GET(x) WLAN_GPIO_PIN17_CONFIG_GET(x)
-#define GPIO_PIN17_CONFIG_SET(x) WLAN_GPIO_PIN17_CONFIG_SET(x)
-#define GPIO_PIN17_WAKEUP_ENABLE_MSB WLAN_GPIO_PIN17_WAKEUP_ENABLE_MSB
-#define GPIO_PIN17_WAKEUP_ENABLE_LSB WLAN_GPIO_PIN17_WAKEUP_ENABLE_LSB
-#define GPIO_PIN17_WAKEUP_ENABLE_MASK WLAN_GPIO_PIN17_WAKEUP_ENABLE_MASK
-#define GPIO_PIN17_WAKEUP_ENABLE_GET(x) WLAN_GPIO_PIN17_WAKEUP_ENABLE_GET(x)
-#define GPIO_PIN17_WAKEUP_ENABLE_SET(x) WLAN_GPIO_PIN17_WAKEUP_ENABLE_SET(x)
-#define GPIO_PIN17_INT_TYPE_MSB WLAN_GPIO_PIN17_INT_TYPE_MSB
-#define GPIO_PIN17_INT_TYPE_LSB WLAN_GPIO_PIN17_INT_TYPE_LSB
-#define GPIO_PIN17_INT_TYPE_MASK WLAN_GPIO_PIN17_INT_TYPE_MASK
-#define GPIO_PIN17_INT_TYPE_GET(x) WLAN_GPIO_PIN17_INT_TYPE_GET(x)
-#define GPIO_PIN17_INT_TYPE_SET(x) WLAN_GPIO_PIN17_INT_TYPE_SET(x)
-#define GPIO_PIN17_PAD_PULL_MSB WLAN_GPIO_PIN17_PAD_PULL_MSB
-#define GPIO_PIN17_PAD_PULL_LSB WLAN_GPIO_PIN17_PAD_PULL_LSB
-#define GPIO_PIN17_PAD_PULL_MASK WLAN_GPIO_PIN17_PAD_PULL_MASK
-#define GPIO_PIN17_PAD_PULL_GET(x) WLAN_GPIO_PIN17_PAD_PULL_GET(x)
-#define GPIO_PIN17_PAD_PULL_SET(x) WLAN_GPIO_PIN17_PAD_PULL_SET(x)
-#define GPIO_PIN17_PAD_STRENGTH_MSB WLAN_GPIO_PIN17_PAD_STRENGTH_MSB
-#define GPIO_PIN17_PAD_STRENGTH_LSB WLAN_GPIO_PIN17_PAD_STRENGTH_LSB
-#define GPIO_PIN17_PAD_STRENGTH_MASK WLAN_GPIO_PIN17_PAD_STRENGTH_MASK
-#define GPIO_PIN17_PAD_STRENGTH_GET(x) WLAN_GPIO_PIN17_PAD_STRENGTH_GET(x)
-#define GPIO_PIN17_PAD_STRENGTH_SET(x) WLAN_GPIO_PIN17_PAD_STRENGTH_SET(x)
-#define GPIO_PIN17_PAD_DRIVER_MSB WLAN_GPIO_PIN17_PAD_DRIVER_MSB
-#define GPIO_PIN17_PAD_DRIVER_LSB WLAN_GPIO_PIN17_PAD_DRIVER_LSB
-#define GPIO_PIN17_PAD_DRIVER_MASK WLAN_GPIO_PIN17_PAD_DRIVER_MASK
-#define GPIO_PIN17_PAD_DRIVER_GET(x) WLAN_GPIO_PIN17_PAD_DRIVER_GET(x)
-#define GPIO_PIN17_PAD_DRIVER_SET(x) WLAN_GPIO_PIN17_PAD_DRIVER_SET(x)
-#define GPIO_PIN17_SOURCE_MSB WLAN_GPIO_PIN17_SOURCE_MSB
-#define GPIO_PIN17_SOURCE_LSB WLAN_GPIO_PIN17_SOURCE_LSB
-#define GPIO_PIN17_SOURCE_MASK WLAN_GPIO_PIN17_SOURCE_MASK
-#define GPIO_PIN17_SOURCE_GET(x) WLAN_GPIO_PIN17_SOURCE_GET(x)
-#define GPIO_PIN17_SOURCE_SET(x) WLAN_GPIO_PIN17_SOURCE_SET(x)
-#define GPIO_PIN18_ADDRESS WLAN_GPIO_PIN18_ADDRESS
-#define GPIO_PIN18_OFFSET WLAN_GPIO_PIN18_OFFSET
-#define GPIO_PIN18_CONFIG_MSB WLAN_GPIO_PIN18_CONFIG_MSB
-#define GPIO_PIN18_CONFIG_LSB WLAN_GPIO_PIN18_CONFIG_LSB
-#define GPIO_PIN18_CONFIG_MASK WLAN_GPIO_PIN18_CONFIG_MASK
-#define GPIO_PIN18_CONFIG_GET(x) WLAN_GPIO_PIN18_CONFIG_GET(x)
-#define GPIO_PIN18_CONFIG_SET(x) WLAN_GPIO_PIN18_CONFIG_SET(x)
-#define GPIO_PIN18_WAKEUP_ENABLE_MSB WLAN_GPIO_PIN18_WAKEUP_ENABLE_MSB
-#define GPIO_PIN18_WAKEUP_ENABLE_LSB WLAN_GPIO_PIN18_WAKEUP_ENABLE_LSB
-#define GPIO_PIN18_WAKEUP_ENABLE_MASK WLAN_GPIO_PIN18_WAKEUP_ENABLE_MASK
-#define GPIO_PIN18_WAKEUP_ENABLE_GET(x) WLAN_GPIO_PIN18_WAKEUP_ENABLE_GET(x)
-#define GPIO_PIN18_WAKEUP_ENABLE_SET(x) WLAN_GPIO_PIN18_WAKEUP_ENABLE_SET(x)
-#define GPIO_PIN18_INT_TYPE_MSB WLAN_GPIO_PIN18_INT_TYPE_MSB
-#define GPIO_PIN18_INT_TYPE_LSB WLAN_GPIO_PIN18_INT_TYPE_LSB
-#define GPIO_PIN18_INT_TYPE_MASK WLAN_GPIO_PIN18_INT_TYPE_MASK
-#define GPIO_PIN18_INT_TYPE_GET(x) WLAN_GPIO_PIN18_INT_TYPE_GET(x)
-#define GPIO_PIN18_INT_TYPE_SET(x) WLAN_GPIO_PIN18_INT_TYPE_SET(x)
-#define GPIO_PIN18_PAD_PULL_MSB WLAN_GPIO_PIN18_PAD_PULL_MSB
-#define GPIO_PIN18_PAD_PULL_LSB WLAN_GPIO_PIN18_PAD_PULL_LSB
-#define GPIO_PIN18_PAD_PULL_MASK WLAN_GPIO_PIN18_PAD_PULL_MASK
-#define GPIO_PIN18_PAD_PULL_GET(x) WLAN_GPIO_PIN18_PAD_PULL_GET(x)
-#define GPIO_PIN18_PAD_PULL_SET(x) WLAN_GPIO_PIN18_PAD_PULL_SET(x)
-#define GPIO_PIN18_PAD_STRENGTH_MSB WLAN_GPIO_PIN18_PAD_STRENGTH_MSB
-#define GPIO_PIN18_PAD_STRENGTH_LSB WLAN_GPIO_PIN18_PAD_STRENGTH_LSB
-#define GPIO_PIN18_PAD_STRENGTH_MASK WLAN_GPIO_PIN18_PAD_STRENGTH_MASK
-#define GPIO_PIN18_PAD_STRENGTH_GET(x) WLAN_GPIO_PIN18_PAD_STRENGTH_GET(x)
-#define GPIO_PIN18_PAD_STRENGTH_SET(x) WLAN_GPIO_PIN18_PAD_STRENGTH_SET(x)
-#define GPIO_PIN18_PAD_DRIVER_MSB WLAN_GPIO_PIN18_PAD_DRIVER_MSB
-#define GPIO_PIN18_PAD_DRIVER_LSB WLAN_GPIO_PIN18_PAD_DRIVER_LSB
-#define GPIO_PIN18_PAD_DRIVER_MASK WLAN_GPIO_PIN18_PAD_DRIVER_MASK
-#define GPIO_PIN18_PAD_DRIVER_GET(x) WLAN_GPIO_PIN18_PAD_DRIVER_GET(x)
-#define GPIO_PIN18_PAD_DRIVER_SET(x) WLAN_GPIO_PIN18_PAD_DRIVER_SET(x)
-#define GPIO_PIN18_SOURCE_MSB WLAN_GPIO_PIN18_SOURCE_MSB
-#define GPIO_PIN18_SOURCE_LSB WLAN_GPIO_PIN18_SOURCE_LSB
-#define GPIO_PIN18_SOURCE_MASK WLAN_GPIO_PIN18_SOURCE_MASK
-#define GPIO_PIN18_SOURCE_GET(x) WLAN_GPIO_PIN18_SOURCE_GET(x)
-#define GPIO_PIN18_SOURCE_SET(x) WLAN_GPIO_PIN18_SOURCE_SET(x)
-#define GPIO_PIN19_ADDRESS WLAN_GPIO_PIN19_ADDRESS
-#define GPIO_PIN19_OFFSET WLAN_GPIO_PIN19_OFFSET
-#define GPIO_PIN19_CONFIG_MSB WLAN_GPIO_PIN19_CONFIG_MSB
-#define GPIO_PIN19_CONFIG_LSB WLAN_GPIO_PIN19_CONFIG_LSB
-#define GPIO_PIN19_CONFIG_MASK WLAN_GPIO_PIN19_CONFIG_MASK
-#define GPIO_PIN19_CONFIG_GET(x) WLAN_GPIO_PIN19_CONFIG_GET(x)
-#define GPIO_PIN19_CONFIG_SET(x) WLAN_GPIO_PIN19_CONFIG_SET(x)
-#define GPIO_PIN19_WAKEUP_ENABLE_MSB WLAN_GPIO_PIN19_WAKEUP_ENABLE_MSB
-#define GPIO_PIN19_WAKEUP_ENABLE_LSB WLAN_GPIO_PIN19_WAKEUP_ENABLE_LSB
-#define GPIO_PIN19_WAKEUP_ENABLE_MASK WLAN_GPIO_PIN19_WAKEUP_ENABLE_MASK
-#define GPIO_PIN19_WAKEUP_ENABLE_GET(x) WLAN_GPIO_PIN19_WAKEUP_ENABLE_GET(x)
-#define GPIO_PIN19_WAKEUP_ENABLE_SET(x) WLAN_GPIO_PIN19_WAKEUP_ENABLE_SET(x)
-#define GPIO_PIN19_INT_TYPE_MSB WLAN_GPIO_PIN19_INT_TYPE_MSB
-#define GPIO_PIN19_INT_TYPE_LSB WLAN_GPIO_PIN19_INT_TYPE_LSB
-#define GPIO_PIN19_INT_TYPE_MASK WLAN_GPIO_PIN19_INT_TYPE_MASK
-#define GPIO_PIN19_INT_TYPE_GET(x) WLAN_GPIO_PIN19_INT_TYPE_GET(x)
-#define GPIO_PIN19_INT_TYPE_SET(x) WLAN_GPIO_PIN19_INT_TYPE_SET(x)
-#define GPIO_PIN19_PAD_PULL_MSB WLAN_GPIO_PIN19_PAD_PULL_MSB
-#define GPIO_PIN19_PAD_PULL_LSB WLAN_GPIO_PIN19_PAD_PULL_LSB
-#define GPIO_PIN19_PAD_PULL_MASK WLAN_GPIO_PIN19_PAD_PULL_MASK
-#define GPIO_PIN19_PAD_PULL_GET(x) WLAN_GPIO_PIN19_PAD_PULL_GET(x)
-#define GPIO_PIN19_PAD_PULL_SET(x) WLAN_GPIO_PIN19_PAD_PULL_SET(x)
-#define GPIO_PIN19_PAD_STRENGTH_MSB WLAN_GPIO_PIN19_PAD_STRENGTH_MSB
-#define GPIO_PIN19_PAD_STRENGTH_LSB WLAN_GPIO_PIN19_PAD_STRENGTH_LSB
-#define GPIO_PIN19_PAD_STRENGTH_MASK WLAN_GPIO_PIN19_PAD_STRENGTH_MASK
-#define GPIO_PIN19_PAD_STRENGTH_GET(x) WLAN_GPIO_PIN19_PAD_STRENGTH_GET(x)
-#define GPIO_PIN19_PAD_STRENGTH_SET(x) WLAN_GPIO_PIN19_PAD_STRENGTH_SET(x)
-#define GPIO_PIN19_PAD_DRIVER_MSB WLAN_GPIO_PIN19_PAD_DRIVER_MSB
-#define GPIO_PIN19_PAD_DRIVER_LSB WLAN_GPIO_PIN19_PAD_DRIVER_LSB
-#define GPIO_PIN19_PAD_DRIVER_MASK WLAN_GPIO_PIN19_PAD_DRIVER_MASK
-#define GPIO_PIN19_PAD_DRIVER_GET(x) WLAN_GPIO_PIN19_PAD_DRIVER_GET(x)
-#define GPIO_PIN19_PAD_DRIVER_SET(x) WLAN_GPIO_PIN19_PAD_DRIVER_SET(x)
-#define GPIO_PIN19_SOURCE_MSB WLAN_GPIO_PIN19_SOURCE_MSB
-#define GPIO_PIN19_SOURCE_LSB WLAN_GPIO_PIN19_SOURCE_LSB
-#define GPIO_PIN19_SOURCE_MASK WLAN_GPIO_PIN19_SOURCE_MASK
-#define GPIO_PIN19_SOURCE_GET(x) WLAN_GPIO_PIN19_SOURCE_GET(x)
-#define GPIO_PIN19_SOURCE_SET(x) WLAN_GPIO_PIN19_SOURCE_SET(x)
-#define GPIO_PIN20_ADDRESS WLAN_GPIO_PIN20_ADDRESS
-#define GPIO_PIN20_OFFSET WLAN_GPIO_PIN20_OFFSET
-#define GPIO_PIN20_CONFIG_MSB WLAN_GPIO_PIN20_CONFIG_MSB
-#define GPIO_PIN20_CONFIG_LSB WLAN_GPIO_PIN20_CONFIG_LSB
-#define GPIO_PIN20_CONFIG_MASK WLAN_GPIO_PIN20_CONFIG_MASK
-#define GPIO_PIN20_CONFIG_GET(x) WLAN_GPIO_PIN20_CONFIG_GET(x)
-#define GPIO_PIN20_CONFIG_SET(x) WLAN_GPIO_PIN20_CONFIG_SET(x)
-#define GPIO_PIN20_WAKEUP_ENABLE_MSB WLAN_GPIO_PIN20_WAKEUP_ENABLE_MSB
-#define GPIO_PIN20_WAKEUP_ENABLE_LSB WLAN_GPIO_PIN20_WAKEUP_ENABLE_LSB
-#define GPIO_PIN20_WAKEUP_ENABLE_MASK WLAN_GPIO_PIN20_WAKEUP_ENABLE_MASK
-#define GPIO_PIN20_WAKEUP_ENABLE_GET(x) WLAN_GPIO_PIN20_WAKEUP_ENABLE_GET(x)
-#define GPIO_PIN20_WAKEUP_ENABLE_SET(x) WLAN_GPIO_PIN20_WAKEUP_ENABLE_SET(x)
-#define GPIO_PIN20_INT_TYPE_MSB WLAN_GPIO_PIN20_INT_TYPE_MSB
-#define GPIO_PIN20_INT_TYPE_LSB WLAN_GPIO_PIN20_INT_TYPE_LSB
-#define GPIO_PIN20_INT_TYPE_MASK WLAN_GPIO_PIN20_INT_TYPE_MASK
-#define GPIO_PIN20_INT_TYPE_GET(x) WLAN_GPIO_PIN20_INT_TYPE_GET(x)
-#define GPIO_PIN20_INT_TYPE_SET(x) WLAN_GPIO_PIN20_INT_TYPE_SET(x)
-#define GPIO_PIN20_PAD_PULL_MSB WLAN_GPIO_PIN20_PAD_PULL_MSB
-#define GPIO_PIN20_PAD_PULL_LSB WLAN_GPIO_PIN20_PAD_PULL_LSB
-#define GPIO_PIN20_PAD_PULL_MASK WLAN_GPIO_PIN20_PAD_PULL_MASK
-#define GPIO_PIN20_PAD_PULL_GET(x) WLAN_GPIO_PIN20_PAD_PULL_GET(x)
-#define GPIO_PIN20_PAD_PULL_SET(x) WLAN_GPIO_PIN20_PAD_PULL_SET(x)
-#define GPIO_PIN20_PAD_STRENGTH_MSB WLAN_GPIO_PIN20_PAD_STRENGTH_MSB
-#define GPIO_PIN20_PAD_STRENGTH_LSB WLAN_GPIO_PIN20_PAD_STRENGTH_LSB
-#define GPIO_PIN20_PAD_STRENGTH_MASK WLAN_GPIO_PIN20_PAD_STRENGTH_MASK
-#define GPIO_PIN20_PAD_STRENGTH_GET(x) WLAN_GPIO_PIN20_PAD_STRENGTH_GET(x)
-#define GPIO_PIN20_PAD_STRENGTH_SET(x) WLAN_GPIO_PIN20_PAD_STRENGTH_SET(x)
-#define GPIO_PIN20_PAD_DRIVER_MSB WLAN_GPIO_PIN20_PAD_DRIVER_MSB
-#define GPIO_PIN20_PAD_DRIVER_LSB WLAN_GPIO_PIN20_PAD_DRIVER_LSB
-#define GPIO_PIN20_PAD_DRIVER_MASK WLAN_GPIO_PIN20_PAD_DRIVER_MASK
-#define GPIO_PIN20_PAD_DRIVER_GET(x) WLAN_GPIO_PIN20_PAD_DRIVER_GET(x)
-#define GPIO_PIN20_PAD_DRIVER_SET(x) WLAN_GPIO_PIN20_PAD_DRIVER_SET(x)
-#define GPIO_PIN20_SOURCE_MSB WLAN_GPIO_PIN20_SOURCE_MSB
-#define GPIO_PIN20_SOURCE_LSB WLAN_GPIO_PIN20_SOURCE_LSB
-#define GPIO_PIN20_SOURCE_MASK WLAN_GPIO_PIN20_SOURCE_MASK
-#define GPIO_PIN20_SOURCE_GET(x) WLAN_GPIO_PIN20_SOURCE_GET(x)
-#define GPIO_PIN20_SOURCE_SET(x) WLAN_GPIO_PIN20_SOURCE_SET(x)
-#define GPIO_PIN21_ADDRESS WLAN_GPIO_PIN21_ADDRESS
-#define GPIO_PIN21_OFFSET WLAN_GPIO_PIN21_OFFSET
-#define GPIO_PIN21_CONFIG_MSB WLAN_GPIO_PIN21_CONFIG_MSB
-#define GPIO_PIN21_CONFIG_LSB WLAN_GPIO_PIN21_CONFIG_LSB
-#define GPIO_PIN21_CONFIG_MASK WLAN_GPIO_PIN21_CONFIG_MASK
-#define GPIO_PIN21_CONFIG_GET(x) WLAN_GPIO_PIN21_CONFIG_GET(x)
-#define GPIO_PIN21_CONFIG_SET(x) WLAN_GPIO_PIN21_CONFIG_SET(x)
-#define GPIO_PIN21_WAKEUP_ENABLE_MSB WLAN_GPIO_PIN21_WAKEUP_ENABLE_MSB
-#define GPIO_PIN21_WAKEUP_ENABLE_LSB WLAN_GPIO_PIN21_WAKEUP_ENABLE_LSB
-#define GPIO_PIN21_WAKEUP_ENABLE_MASK WLAN_GPIO_PIN21_WAKEUP_ENABLE_MASK
-#define GPIO_PIN21_WAKEUP_ENABLE_GET(x) WLAN_GPIO_PIN21_WAKEUP_ENABLE_GET(x)
-#define GPIO_PIN21_WAKEUP_ENABLE_SET(x) WLAN_GPIO_PIN21_WAKEUP_ENABLE_SET(x)
-#define GPIO_PIN21_INT_TYPE_MSB WLAN_GPIO_PIN21_INT_TYPE_MSB
-#define GPIO_PIN21_INT_TYPE_LSB WLAN_GPIO_PIN21_INT_TYPE_LSB
-#define GPIO_PIN21_INT_TYPE_MASK WLAN_GPIO_PIN21_INT_TYPE_MASK
-#define GPIO_PIN21_INT_TYPE_GET(x) WLAN_GPIO_PIN21_INT_TYPE_GET(x)
-#define GPIO_PIN21_INT_TYPE_SET(x) WLAN_GPIO_PIN21_INT_TYPE_SET(x)
-#define GPIO_PIN21_PAD_PULL_MSB WLAN_GPIO_PIN21_PAD_PULL_MSB
-#define GPIO_PIN21_PAD_PULL_LSB WLAN_GPIO_PIN21_PAD_PULL_LSB
-#define GPIO_PIN21_PAD_PULL_MASK WLAN_GPIO_PIN21_PAD_PULL_MASK
-#define GPIO_PIN21_PAD_PULL_GET(x) WLAN_GPIO_PIN21_PAD_PULL_GET(x)
-#define GPIO_PIN21_PAD_PULL_SET(x) WLAN_GPIO_PIN21_PAD_PULL_SET(x)
-#define GPIO_PIN21_PAD_STRENGTH_MSB WLAN_GPIO_PIN21_PAD_STRENGTH_MSB
-#define GPIO_PIN21_PAD_STRENGTH_LSB WLAN_GPIO_PIN21_PAD_STRENGTH_LSB
-#define GPIO_PIN21_PAD_STRENGTH_MASK WLAN_GPIO_PIN21_PAD_STRENGTH_MASK
-#define GPIO_PIN21_PAD_STRENGTH_GET(x) WLAN_GPIO_PIN21_PAD_STRENGTH_GET(x)
-#define GPIO_PIN21_PAD_STRENGTH_SET(x) WLAN_GPIO_PIN21_PAD_STRENGTH_SET(x)
-#define GPIO_PIN21_PAD_DRIVER_MSB WLAN_GPIO_PIN21_PAD_DRIVER_MSB
-#define GPIO_PIN21_PAD_DRIVER_LSB WLAN_GPIO_PIN21_PAD_DRIVER_LSB
-#define GPIO_PIN21_PAD_DRIVER_MASK WLAN_GPIO_PIN21_PAD_DRIVER_MASK
-#define GPIO_PIN21_PAD_DRIVER_GET(x) WLAN_GPIO_PIN21_PAD_DRIVER_GET(x)
-#define GPIO_PIN21_PAD_DRIVER_SET(x) WLAN_GPIO_PIN21_PAD_DRIVER_SET(x)
-#define GPIO_PIN21_SOURCE_MSB WLAN_GPIO_PIN21_SOURCE_MSB
-#define GPIO_PIN21_SOURCE_LSB WLAN_GPIO_PIN21_SOURCE_LSB
-#define GPIO_PIN21_SOURCE_MASK WLAN_GPIO_PIN21_SOURCE_MASK
-#define GPIO_PIN21_SOURCE_GET(x) WLAN_GPIO_PIN21_SOURCE_GET(x)
-#define GPIO_PIN21_SOURCE_SET(x) WLAN_GPIO_PIN21_SOURCE_SET(x)
-#define GPIO_PIN22_ADDRESS WLAN_GPIO_PIN22_ADDRESS
-#define GPIO_PIN22_OFFSET WLAN_GPIO_PIN22_OFFSET
-#define GPIO_PIN22_CONFIG_MSB WLAN_GPIO_PIN22_CONFIG_MSB
-#define GPIO_PIN22_CONFIG_LSB WLAN_GPIO_PIN22_CONFIG_LSB
-#define GPIO_PIN22_CONFIG_MASK WLAN_GPIO_PIN22_CONFIG_MASK
-#define GPIO_PIN22_CONFIG_GET(x) WLAN_GPIO_PIN22_CONFIG_GET(x)
-#define GPIO_PIN22_CONFIG_SET(x) WLAN_GPIO_PIN22_CONFIG_SET(x)
-#define GPIO_PIN22_WAKEUP_ENABLE_MSB WLAN_GPIO_PIN22_WAKEUP_ENABLE_MSB
-#define GPIO_PIN22_WAKEUP_ENABLE_LSB WLAN_GPIO_PIN22_WAKEUP_ENABLE_LSB
-#define GPIO_PIN22_WAKEUP_ENABLE_MASK WLAN_GPIO_PIN22_WAKEUP_ENABLE_MASK
-#define GPIO_PIN22_WAKEUP_ENABLE_GET(x) WLAN_GPIO_PIN22_WAKEUP_ENABLE_GET(x)
-#define GPIO_PIN22_WAKEUP_ENABLE_SET(x) WLAN_GPIO_PIN22_WAKEUP_ENABLE_SET(x)
-#define GPIO_PIN22_INT_TYPE_MSB WLAN_GPIO_PIN22_INT_TYPE_MSB
-#define GPIO_PIN22_INT_TYPE_LSB WLAN_GPIO_PIN22_INT_TYPE_LSB
-#define GPIO_PIN22_INT_TYPE_MASK WLAN_GPIO_PIN22_INT_TYPE_MASK
-#define GPIO_PIN22_INT_TYPE_GET(x) WLAN_GPIO_PIN22_INT_TYPE_GET(x)
-#define GPIO_PIN22_INT_TYPE_SET(x) WLAN_GPIO_PIN22_INT_TYPE_SET(x)
-#define GPIO_PIN22_PAD_PULL_MSB WLAN_GPIO_PIN22_PAD_PULL_MSB
-#define GPIO_PIN22_PAD_PULL_LSB WLAN_GPIO_PIN22_PAD_PULL_LSB
-#define GPIO_PIN22_PAD_PULL_MASK WLAN_GPIO_PIN22_PAD_PULL_MASK
-#define GPIO_PIN22_PAD_PULL_GET(x) WLAN_GPIO_PIN22_PAD_PULL_GET(x)
-#define GPIO_PIN22_PAD_PULL_SET(x) WLAN_GPIO_PIN22_PAD_PULL_SET(x)
-#define GPIO_PIN22_PAD_STRENGTH_MSB WLAN_GPIO_PIN22_PAD_STRENGTH_MSB
-#define GPIO_PIN22_PAD_STRENGTH_LSB WLAN_GPIO_PIN22_PAD_STRENGTH_LSB
-#define GPIO_PIN22_PAD_STRENGTH_MASK WLAN_GPIO_PIN22_PAD_STRENGTH_MASK
-#define GPIO_PIN22_PAD_STRENGTH_GET(x) WLAN_GPIO_PIN22_PAD_STRENGTH_GET(x)
-#define GPIO_PIN22_PAD_STRENGTH_SET(x) WLAN_GPIO_PIN22_PAD_STRENGTH_SET(x)
-#define GPIO_PIN22_PAD_DRIVER_MSB WLAN_GPIO_PIN22_PAD_DRIVER_MSB
-#define GPIO_PIN22_PAD_DRIVER_LSB WLAN_GPIO_PIN22_PAD_DRIVER_LSB
-#define GPIO_PIN22_PAD_DRIVER_MASK WLAN_GPIO_PIN22_PAD_DRIVER_MASK
-#define GPIO_PIN22_PAD_DRIVER_GET(x) WLAN_GPIO_PIN22_PAD_DRIVER_GET(x)
-#define GPIO_PIN22_PAD_DRIVER_SET(x) WLAN_GPIO_PIN22_PAD_DRIVER_SET(x)
-#define GPIO_PIN22_SOURCE_MSB WLAN_GPIO_PIN22_SOURCE_MSB
-#define GPIO_PIN22_SOURCE_LSB WLAN_GPIO_PIN22_SOURCE_LSB
-#define GPIO_PIN22_SOURCE_MASK WLAN_GPIO_PIN22_SOURCE_MASK
-#define GPIO_PIN22_SOURCE_GET(x) WLAN_GPIO_PIN22_SOURCE_GET(x)
-#define GPIO_PIN22_SOURCE_SET(x) WLAN_GPIO_PIN22_SOURCE_SET(x)
-#define GPIO_PIN23_ADDRESS WLAN_GPIO_PIN23_ADDRESS
-#define GPIO_PIN23_OFFSET WLAN_GPIO_PIN23_OFFSET
-#define GPIO_PIN23_CONFIG_MSB WLAN_GPIO_PIN23_CONFIG_MSB
-#define GPIO_PIN23_CONFIG_LSB WLAN_GPIO_PIN23_CONFIG_LSB
-#define GPIO_PIN23_CONFIG_MASK WLAN_GPIO_PIN23_CONFIG_MASK
-#define GPIO_PIN23_CONFIG_GET(x) WLAN_GPIO_PIN23_CONFIG_GET(x)
-#define GPIO_PIN23_CONFIG_SET(x) WLAN_GPIO_PIN23_CONFIG_SET(x)
-#define GPIO_PIN23_WAKEUP_ENABLE_MSB WLAN_GPIO_PIN23_WAKEUP_ENABLE_MSB
-#define GPIO_PIN23_WAKEUP_ENABLE_LSB WLAN_GPIO_PIN23_WAKEUP_ENABLE_LSB
-#define GPIO_PIN23_WAKEUP_ENABLE_MASK WLAN_GPIO_PIN23_WAKEUP_ENABLE_MASK
-#define GPIO_PIN23_WAKEUP_ENABLE_GET(x) WLAN_GPIO_PIN23_WAKEUP_ENABLE_GET(x)
-#define GPIO_PIN23_WAKEUP_ENABLE_SET(x) WLAN_GPIO_PIN23_WAKEUP_ENABLE_SET(x)
-#define GPIO_PIN23_INT_TYPE_MSB WLAN_GPIO_PIN23_INT_TYPE_MSB
-#define GPIO_PIN23_INT_TYPE_LSB WLAN_GPIO_PIN23_INT_TYPE_LSB
-#define GPIO_PIN23_INT_TYPE_MASK WLAN_GPIO_PIN23_INT_TYPE_MASK
-#define GPIO_PIN23_INT_TYPE_GET(x) WLAN_GPIO_PIN23_INT_TYPE_GET(x)
-#define GPIO_PIN23_INT_TYPE_SET(x) WLAN_GPIO_PIN23_INT_TYPE_SET(x)
-#define GPIO_PIN23_PAD_DRIVER_MSB WLAN_GPIO_PIN23_PAD_DRIVER_MSB
-#define GPIO_PIN23_PAD_DRIVER_LSB WLAN_GPIO_PIN23_PAD_DRIVER_LSB
-#define GPIO_PIN23_PAD_DRIVER_MASK WLAN_GPIO_PIN23_PAD_DRIVER_MASK
-#define GPIO_PIN23_PAD_DRIVER_GET(x) WLAN_GPIO_PIN23_PAD_DRIVER_GET(x)
-#define GPIO_PIN23_PAD_DRIVER_SET(x) WLAN_GPIO_PIN23_PAD_DRIVER_SET(x)
-#define GPIO_PIN23_SOURCE_MSB WLAN_GPIO_PIN23_SOURCE_MSB
-#define GPIO_PIN23_SOURCE_LSB WLAN_GPIO_PIN23_SOURCE_LSB
-#define GPIO_PIN23_SOURCE_MASK WLAN_GPIO_PIN23_SOURCE_MASK
-#define GPIO_PIN23_SOURCE_GET(x) WLAN_GPIO_PIN23_SOURCE_GET(x)
-#define GPIO_PIN23_SOURCE_SET(x) WLAN_GPIO_PIN23_SOURCE_SET(x)
-#define GPIO_PIN24_ADDRESS WLAN_GPIO_PIN24_ADDRESS
-#define GPIO_PIN24_OFFSET WLAN_GPIO_PIN24_OFFSET
-#define GPIO_PIN24_CONFIG_MSB WLAN_GPIO_PIN24_CONFIG_MSB
-#define GPIO_PIN24_CONFIG_LSB WLAN_GPIO_PIN24_CONFIG_LSB
-#define GPIO_PIN24_CONFIG_MASK WLAN_GPIO_PIN24_CONFIG_MASK
-#define GPIO_PIN24_CONFIG_GET(x) WLAN_GPIO_PIN24_CONFIG_GET(x)
-#define GPIO_PIN24_CONFIG_SET(x) WLAN_GPIO_PIN24_CONFIG_SET(x)
-#define GPIO_PIN24_WAKEUP_ENABLE_MSB WLAN_GPIO_PIN24_WAKEUP_ENABLE_MSB
-#define GPIO_PIN24_WAKEUP_ENABLE_LSB WLAN_GPIO_PIN24_WAKEUP_ENABLE_LSB
-#define GPIO_PIN24_WAKEUP_ENABLE_MASK WLAN_GPIO_PIN24_WAKEUP_ENABLE_MASK
-#define GPIO_PIN24_WAKEUP_ENABLE_GET(x) WLAN_GPIO_PIN24_WAKEUP_ENABLE_GET(x)
-#define GPIO_PIN24_WAKEUP_ENABLE_SET(x) WLAN_GPIO_PIN24_WAKEUP_ENABLE_SET(x)
-#define GPIO_PIN24_INT_TYPE_MSB WLAN_GPIO_PIN24_INT_TYPE_MSB
-#define GPIO_PIN24_INT_TYPE_LSB WLAN_GPIO_PIN24_INT_TYPE_LSB
-#define GPIO_PIN24_INT_TYPE_MASK WLAN_GPIO_PIN24_INT_TYPE_MASK
-#define GPIO_PIN24_INT_TYPE_GET(x) WLAN_GPIO_PIN24_INT_TYPE_GET(x)
-#define GPIO_PIN24_INT_TYPE_SET(x) WLAN_GPIO_PIN24_INT_TYPE_SET(x)
-#define GPIO_PIN24_PAD_DRIVER_MSB WLAN_GPIO_PIN24_PAD_DRIVER_MSB
-#define GPIO_PIN24_PAD_DRIVER_LSB WLAN_GPIO_PIN24_PAD_DRIVER_LSB
-#define GPIO_PIN24_PAD_DRIVER_MASK WLAN_GPIO_PIN24_PAD_DRIVER_MASK
-#define GPIO_PIN24_PAD_DRIVER_GET(x) WLAN_GPIO_PIN24_PAD_DRIVER_GET(x)
-#define GPIO_PIN24_PAD_DRIVER_SET(x) WLAN_GPIO_PIN24_PAD_DRIVER_SET(x)
-#define GPIO_PIN24_SOURCE_MSB WLAN_GPIO_PIN24_SOURCE_MSB
-#define GPIO_PIN24_SOURCE_LSB WLAN_GPIO_PIN24_SOURCE_LSB
-#define GPIO_PIN24_SOURCE_MASK WLAN_GPIO_PIN24_SOURCE_MASK
-#define GPIO_PIN24_SOURCE_GET(x) WLAN_GPIO_PIN24_SOURCE_GET(x)
-#define GPIO_PIN24_SOURCE_SET(x) WLAN_GPIO_PIN24_SOURCE_SET(x)
-#define GPIO_PIN25_ADDRESS WLAN_GPIO_PIN25_ADDRESS
-#define GPIO_PIN25_OFFSET WLAN_GPIO_PIN25_OFFSET
-#define GPIO_PIN25_CONFIG_MSB WLAN_GPIO_PIN25_CONFIG_MSB
-#define GPIO_PIN25_CONFIG_LSB WLAN_GPIO_PIN25_CONFIG_LSB
-#define GPIO_PIN25_CONFIG_MASK WLAN_GPIO_PIN25_CONFIG_MASK
-#define GPIO_PIN25_CONFIG_GET(x) WLAN_GPIO_PIN25_CONFIG_GET(x)
-#define GPIO_PIN25_CONFIG_SET(x) WLAN_GPIO_PIN25_CONFIG_SET(x)
-#define GPIO_PIN25_WAKEUP_ENABLE_MSB WLAN_GPIO_PIN25_WAKEUP_ENABLE_MSB
-#define GPIO_PIN25_WAKEUP_ENABLE_LSB WLAN_GPIO_PIN25_WAKEUP_ENABLE_LSB
-#define GPIO_PIN25_WAKEUP_ENABLE_MASK WLAN_GPIO_PIN25_WAKEUP_ENABLE_MASK
-#define GPIO_PIN25_WAKEUP_ENABLE_GET(x) WLAN_GPIO_PIN25_WAKEUP_ENABLE_GET(x)
-#define GPIO_PIN25_WAKEUP_ENABLE_SET(x) WLAN_GPIO_PIN25_WAKEUP_ENABLE_SET(x)
-#define GPIO_PIN25_INT_TYPE_MSB WLAN_GPIO_PIN25_INT_TYPE_MSB
-#define GPIO_PIN25_INT_TYPE_LSB WLAN_GPIO_PIN25_INT_TYPE_LSB
-#define GPIO_PIN25_INT_TYPE_MASK WLAN_GPIO_PIN25_INT_TYPE_MASK
-#define GPIO_PIN25_INT_TYPE_GET(x) WLAN_GPIO_PIN25_INT_TYPE_GET(x)
-#define GPIO_PIN25_INT_TYPE_SET(x) WLAN_GPIO_PIN25_INT_TYPE_SET(x)
-#define GPIO_PIN25_PAD_DRIVER_MSB WLAN_GPIO_PIN25_PAD_DRIVER_MSB
-#define GPIO_PIN25_PAD_DRIVER_LSB WLAN_GPIO_PIN25_PAD_DRIVER_LSB
-#define GPIO_PIN25_PAD_DRIVER_MASK WLAN_GPIO_PIN25_PAD_DRIVER_MASK
-#define GPIO_PIN25_PAD_DRIVER_GET(x) WLAN_GPIO_PIN25_PAD_DRIVER_GET(x)
-#define GPIO_PIN25_PAD_DRIVER_SET(x) WLAN_GPIO_PIN25_PAD_DRIVER_SET(x)
-#define GPIO_PIN25_SOURCE_MSB WLAN_GPIO_PIN25_SOURCE_MSB
-#define GPIO_PIN25_SOURCE_LSB WLAN_GPIO_PIN25_SOURCE_LSB
-#define GPIO_PIN25_SOURCE_MASK WLAN_GPIO_PIN25_SOURCE_MASK
-#define GPIO_PIN25_SOURCE_GET(x) WLAN_GPIO_PIN25_SOURCE_GET(x)
-#define GPIO_PIN25_SOURCE_SET(x) WLAN_GPIO_PIN25_SOURCE_SET(x)
-#define SIGMA_DELTA_ADDRESS WLAN_SIGMA_DELTA_ADDRESS
-#define SIGMA_DELTA_OFFSET WLAN_SIGMA_DELTA_OFFSET
-#define SIGMA_DELTA_ENABLE_MSB WLAN_SIGMA_DELTA_ENABLE_MSB
-#define SIGMA_DELTA_ENABLE_LSB WLAN_SIGMA_DELTA_ENABLE_LSB
-#define SIGMA_DELTA_ENABLE_MASK WLAN_SIGMA_DELTA_ENABLE_MASK
-#define SIGMA_DELTA_ENABLE_GET(x) WLAN_SIGMA_DELTA_ENABLE_GET(x)
-#define SIGMA_DELTA_ENABLE_SET(x) WLAN_SIGMA_DELTA_ENABLE_SET(x)
-#define SIGMA_DELTA_PRESCALAR_MSB WLAN_SIGMA_DELTA_PRESCALAR_MSB
-#define SIGMA_DELTA_PRESCALAR_LSB WLAN_SIGMA_DELTA_PRESCALAR_LSB
-#define SIGMA_DELTA_PRESCALAR_MASK WLAN_SIGMA_DELTA_PRESCALAR_MASK
-#define SIGMA_DELTA_PRESCALAR_GET(x) WLAN_SIGMA_DELTA_PRESCALAR_GET(x)
-#define SIGMA_DELTA_PRESCALAR_SET(x) WLAN_SIGMA_DELTA_PRESCALAR_SET(x)
-#define SIGMA_DELTA_TARGET_MSB WLAN_SIGMA_DELTA_TARGET_MSB
-#define SIGMA_DELTA_TARGET_LSB WLAN_SIGMA_DELTA_TARGET_LSB
-#define SIGMA_DELTA_TARGET_MASK WLAN_SIGMA_DELTA_TARGET_MASK
-#define SIGMA_DELTA_TARGET_GET(x) WLAN_SIGMA_DELTA_TARGET_GET(x)
-#define SIGMA_DELTA_TARGET_SET(x) WLAN_SIGMA_DELTA_TARGET_SET(x)
-#define DEBUG_CONTROL_ADDRESS WLAN_DEBUG_CONTROL_ADDRESS
-#define DEBUG_CONTROL_OFFSET WLAN_DEBUG_CONTROL_OFFSET
-#define DEBUG_CONTROL_ENABLE_MSB WLAN_DEBUG_CONTROL_ENABLE_MSB
-#define DEBUG_CONTROL_ENABLE_LSB WLAN_DEBUG_CONTROL_ENABLE_LSB
-#define DEBUG_CONTROL_ENABLE_MASK WLAN_DEBUG_CONTROL_ENABLE_MASK
-#define DEBUG_CONTROL_ENABLE_GET(x) WLAN_DEBUG_CONTROL_ENABLE_GET(x)
-#define DEBUG_CONTROL_ENABLE_SET(x) WLAN_DEBUG_CONTROL_ENABLE_SET(x)
-#define DEBUG_INPUT_SEL_ADDRESS WLAN_DEBUG_INPUT_SEL_ADDRESS
-#define DEBUG_INPUT_SEL_OFFSET WLAN_DEBUG_INPUT_SEL_OFFSET
-#define DEBUG_INPUT_SEL_SHIFT_MSB WLAN_DEBUG_INPUT_SEL_SHIFT_MSB
-#define DEBUG_INPUT_SEL_SHIFT_LSB WLAN_DEBUG_INPUT_SEL_SHIFT_LSB
-#define DEBUG_INPUT_SEL_SHIFT_MASK WLAN_DEBUG_INPUT_SEL_SHIFT_MASK
-#define DEBUG_INPUT_SEL_SHIFT_GET(x) WLAN_DEBUG_INPUT_SEL_SHIFT_GET(x)
-#define DEBUG_INPUT_SEL_SHIFT_SET(x) WLAN_DEBUG_INPUT_SEL_SHIFT_SET(x)
-#define DEBUG_INPUT_SEL_SRC_MSB WLAN_DEBUG_INPUT_SEL_SRC_MSB
-#define DEBUG_INPUT_SEL_SRC_LSB WLAN_DEBUG_INPUT_SEL_SRC_LSB
-#define DEBUG_INPUT_SEL_SRC_MASK WLAN_DEBUG_INPUT_SEL_SRC_MASK
-#define DEBUG_INPUT_SEL_SRC_GET(x) WLAN_DEBUG_INPUT_SEL_SRC_GET(x)
-#define DEBUG_INPUT_SEL_SRC_SET(x) WLAN_DEBUG_INPUT_SEL_SRC_SET(x)
-#define DEBUG_OUT_ADDRESS WLAN_DEBUG_OUT_ADDRESS
-#define DEBUG_OUT_OFFSET WLAN_DEBUG_OUT_OFFSET
-#define DEBUG_OUT_DATA_MSB WLAN_DEBUG_OUT_DATA_MSB
-#define DEBUG_OUT_DATA_LSB WLAN_DEBUG_OUT_DATA_LSB
-#define DEBUG_OUT_DATA_MASK WLAN_DEBUG_OUT_DATA_MASK
-#define DEBUG_OUT_DATA_GET(x) WLAN_DEBUG_OUT_DATA_GET(x)
-#define DEBUG_OUT_DATA_SET(x) WLAN_DEBUG_OUT_DATA_SET(x)
-#define RESET_TUPLE_STATUS_ADDRESS WLAN_RESET_TUPLE_STATUS_ADDRESS
-#define RESET_TUPLE_STATUS_OFFSET WLAN_RESET_TUPLE_STATUS_OFFSET
-#define RESET_TUPLE_STATUS_TEST_RESET_TUPLE_MSB WLAN_RESET_TUPLE_STATUS_TEST_RESET_TUPLE_MSB
-#define RESET_TUPLE_STATUS_TEST_RESET_TUPLE_LSB WLAN_RESET_TUPLE_STATUS_TEST_RESET_TUPLE_LSB
-#define RESET_TUPLE_STATUS_TEST_RESET_TUPLE_MASK WLAN_RESET_TUPLE_STATUS_TEST_RESET_TUPLE_MASK
-#define RESET_TUPLE_STATUS_TEST_RESET_TUPLE_GET(x) WLAN_RESET_TUPLE_STATUS_TEST_RESET_TUPLE_GET(x)
-#define RESET_TUPLE_STATUS_TEST_RESET_TUPLE_SET(x) WLAN_RESET_TUPLE_STATUS_TEST_RESET_TUPLE_SET(x)
-#define RESET_TUPLE_STATUS_PIN_RESET_TUPLE_MSB WLAN_RESET_TUPLE_STATUS_PIN_RESET_TUPLE_MSB
-#define RESET_TUPLE_STATUS_PIN_RESET_TUPLE_LSB WLAN_RESET_TUPLE_STATUS_PIN_RESET_TUPLE_LSB
-#define RESET_TUPLE_STATUS_PIN_RESET_TUPLE_MASK WLAN_RESET_TUPLE_STATUS_PIN_RESET_TUPLE_MASK
-#define RESET_TUPLE_STATUS_PIN_RESET_TUPLE_GET(x) WLAN_RESET_TUPLE_STATUS_PIN_RESET_TUPLE_GET(x)
-#define RESET_TUPLE_STATUS_PIN_RESET_TUPLE_SET(x) WLAN_RESET_TUPLE_STATUS_PIN_RESET_TUPLE_SET(x)
-
-
-#endif
-#endif
-
-
-
diff --git a/drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/mac_dma_reg.h b/drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/mac_dma_reg.h
deleted file mode 100644 (file)
index f82f809..0000000
+++ /dev/null
@@ -1,605 +0,0 @@
-// ------------------------------------------------------------------
-// Copyright (c) 2002-2010 Atheros Communications Inc.
-// All rights reserved.
-// 
-//
-// Permission to use, copy, modify, and/or distribute this software for any
-// purpose with or without fee is hereby granted, provided that the above
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-//
-//
-// ------------------------------------------------------------------
-//===================================================================
-// Author(s): ="Atheros"
-//===================================================================
-
-
-/*****************************************************************************/
-/* AR6003 WLAN MAC DMA register definitions                                  */
-/*****************************************************************************/
-
-#ifndef _AR6000_DMAREG_H_
-#define _AR6000_DMAREG_H_
-
-/*
- * Definitions for the Atheros AR6003 chipset.
- */
-
-/* DMA Control and Interrupt Registers */
-#define MAC_DMA_CR_ADDRESS                       0x00000008 /* MAC control register */
-#define MAC_DMA_CR_RXE_MASK                      0x00000004 /* Receive enable */
-#define MAC_DMA_CR_RXD_MASK                      0x00000020 /* Receive disable */
-#define MAC_DMA_CR_SWI_MASK                      0x00000040 /* One-shot software interrupt */
-
-#define MAC_DMA_RXDP_ADDRESS                     0x0000000C /* MAC receive queue descriptor pointer */
-
-#define MAC_DMA_CFG_ADDRESS                      0x00000014 /* MAC configuration and status register */
-#define MAC_DMA_CFG_SWTD_MASK                    0x00000001 /* byteswap tx descriptor words */
-#define MAC_DMA_CFG_SWTB_MASK                    0x00000002 /* byteswap tx data buffer words */
-#define MAC_DMA_CFG_SWRD_MASK                    0x00000004 /* byteswap rx descriptor words */
-#define MAC_DMA_CFG_SWRB_MASK                    0x00000008 /* byteswap rx data buffer words */
-#define MAC_DMA_CFG_SWRG_MASK                    0x00000010 /* byteswap register access data words */
-#define MAC_DMA_CFG_AP_ADHOC_INDICATION_MASK     0x00000020 /* AP/adhoc indication (0-AP, 1-Adhoc) */
-#define MAC_DMA_CFG_PHOK_MASK                    0x00000100 /* PHY OK status */
-#define MAC_DMA_CFG_CLK_GATE_DIS_MASK            0x00000400 /* Clock gating disable  */
-
-#define MAC_DMA_MIRT_ADDRESS                     0x00000020 /* Maximum rate threshold register */
-#define MAC_DMA_MIRT_THRESH_MASK                 0x0000FFFF 
-
-#define MAC_DMA_IER_ADDRESS                      0x00000024  /* MAC Interrupt enable register */
-#define MAC_DMA_IER_ENABLE_MASK                  0x00000001 /* Global interrupt enable */
-#define MAC_DMA_IER_DISABLE_MASK                 0x00000000 /* Global interrupt disable */
-
-#define MAC_DMA_TIMT_ADDRESS                     0x00000028 /* Transmit Interrupt Mitigation Threshold */
-#define MAC_DMA_TIMT_LAST_PACKER_THRESH_MASK     0x0000FFFF /* Last packet threshold mask */
-#define MAC_DMA_TIMT_FIRST_PACKER_THRESH_MASK    0xFFFF0000 /* First packet threshold mask */
-
-#define MAC_DMA_RIMT_ADDRESS                     0x0000002C /* Receive Interrupt Mitigation Threshold */
-#define MAC_DMA_RIMT_LAST_PACKER_THRESH_MASK     0x0000FFFF /* Last packet threshold mask */
-#define MAC_DMA_RIMT_FIRST_PACKER_THRESH_MASK    0xFFFF0000 /* First packet threshold mask */
-
-#define MAC_DMA_TXCFG_ADDRESS                    0x00000030  /* MAC tx DMA size config register */
-#define MAC_DMA_FTRIG_MASK                       0x000003F0 /* Mask for Frame trigger level */
-#define MAC_DMA_FTRIG_LSB                        4          /* Shift for Frame trigger level */
-#define MAC_DMA_FTRIG_IMMED                      0x00000000 /* bytes in PCU TX FIFO before air */
-#define MAC_DMA_FTRIG_64B                        0x00000010 /* default */
-#define MAC_DMA_FTRIG_128B                       0x00000020
-#define MAC_DMA_FTRIG_192B                       0x00000030
-#define MAC_DMA_FTRIG_256B                       0x00000040 /* 5 bits total */
-#define MAC_DMA_TXCFG_ADHOC_BEACON_ATIM_TX_POLICY_MASK 0x00000800
-
-#define MAC_DMA_RXCFG_ADDRESS                     0x00000034  /* MAC rx DMA size config register */
-#define MAC_DMA_RXCFG_ZLFDMA_MASK                 0x00000010 /* Enable DMA of zero-length frame */
-#define MAC_DMA_RXCFG_DMASIZE_4B                  0x00000000 /* DMA size 4 bytes (TXCFG + RXCFG) */
-#define MAC_DMA_RXCFG_DMASIZE_8B                  0x00000001 /* DMA size 8 bytes */
-#define MAC_DMA_RXCFG_DMASIZE_16B                 0x00000002 /* DMA size 16 bytes */
-#define MAC_DMA_RXCFG_DMASIZE_32B                 0x00000003 /* DMA size 32 bytes */
-#define MAC_DMA_RXCFG_DMASIZE_64B                 0x00000004 /* DMA size 64 bytes */
-#define MAC_DMA_RXCFG_DMASIZE_128B                0x00000005 /* DMA size 128 bytes */
-#define MAC_DMA_RXCFG_DMASIZE_256B                0x00000006 /* DMA size 256 bytes */
-#define MAC_DMA_RXCFG_DMASIZE_512B                0x00000007 /* DMA size 512 bytes */
-
-#define MAC_DMA_MIBC_ADDRESS                      0x00000040  /* MAC MIB control register */
-#define MAC_DMA_MIBC_COW_MASK                     0x00000001 /* counter overflow warning */
-#define MAC_DMA_MIBC_FMC_MASK                     0x00000002 /* freeze MIB counters */
-#define MAC_DMA_MIBC_CMC_MASK                     0x00000004 /* clear MIB counters */
-#define MAC_DMA_MIBC_MCS_MASK                     0x00000008 /* MIB counter strobe, increment all */
-
-#define MAC_DMA_TOPS_ADDRESS                      0x00000044  /* MAC timeout prescale count */
-#define MAC_DMA_TOPS_MASK                         0x0000FFFF /* Mask for timeout prescale */
-
-#define MAC_DMA_RXNPTO_ADDRESS                    0x00000048  /* MAC no frame received timeout */
-#define MAC_DMA_RXNPTO_MASK                       0x000003FF /* Mask for no frame received timeout */
-
-#define MAC_DMA_TXNPTO_ADDRESS                    0x0000004C  /* MAC no frame trasmitted timeout */
-#define MAC_DMA_TXNPTO_MASK                       0x000003FF /* Mask for no frame transmitted timeout */
-#define MAC_DMA_TXNPTO_QCU_MASK                   0x000FFC00 /* Mask indicating the set of QCUs */
-                                                       /* for which frame completions will cause */
-                                                       /* a reset of the no frame xmit'd timeout */
-
-#define MAC_DMA_RPGTO_ADDRESS                     0x00000050  /* MAC receive frame gap timeout */
-#define MAC_DMA_RPGTO_MASK                        0x000003FF /* Mask for receive frame gap timeout */
-
-#define MAC_DMA_RPCNT_ADDRESS                     0x00000054  /* MAC receive frame count limit */
-#define MAC_DMA_RPCNT_MASK                        0x0000001F /* Mask for receive frame count limit */
-
-#define MAC_DMA_MACMISC_ADDRESS                   0x00000058  /* MAC miscellaneous control/status register */
-#define MAC_DMA_MACMISC_DMA_OBS_MASK              0x000001E0 /* Mask for DMA observation bus mux select */
-#define MAC_DMA_MACMISC_DMA_OBS_LSB               5          /* Shift for DMA observation bus mux select */
-#define MAC_DMA_MACMISC_MISC_OBS                  0x00000E00 /* Mask for MISC observation bus mux select */
-#define MAC_DMA_MACMISC_MISC_OBS_LSB              9          /* Shift for MISC observation bus mux select */
-#define MAC_DMA_MACMISC_MAC_OBS_BUS_LSB           0x00007000 /* Mask for MAC observation bus mux select (lsb) */
-#define MAC_DMA_MACMISC_MAC_OBS_BUS_LSB_LSB       12         /* Shift for MAC observation bus mux select (lsb) */
-#define MAC_DMA_MACMISC_MAC_OBS_BUS_MSB           0x00038000 /* Mask for MAC observation bus mux select (msb) */
-#define MAC_DMA_MACMISC_MAC_OBS_BUS_MSB_LSB       15         /* Shift for MAC observation bus mux select (msb) */
-
-
-#define MAC_DMA_ISR_ADDRESS                        0x00000080  /* MAC Primary interrupt status register */
-/*
- * Interrupt Status Registers
- *
- * Only the bits in the ISR_P register and the IMR_P registers
- * control whether the MAC's INTA# output is asserted.  The bits in
- * the secondary interrupt status/mask registers control what bits
- * are set in the primary interrupt status register; however the
- * IMR_S* registers DO NOT determine whether INTA# is asserted.
- * That is INTA# is asserted only when the logical AND of ISR_P
- * and IMR_P is non-zero.  The secondary interrupt mask/status
- * registers affect what bits are set in ISR_P but they do not
- * directly affect whether INTA# is asserted.
- */
-#define MAC_DMA_ISR_RXOK_MASK                    0x00000001 /* At least one frame received sans errors */
-#define MAC_DMA_ISR_RXDESC_MASK                  0x00000002 /* Receive interrupt request */
-#define MAC_DMA_ISR_RXERR_MASK                   0x00000004 /* Receive error interrupt */
-#define MAC_DMA_ISR_RXNOPKT_MASK                 0x00000008 /* No frame received within timeout clock */
-#define MAC_DMA_ISR_RXEOL_MASK                   0x00000010 /* Received descriptor empty interrupt */
-#define MAC_DMA_ISR_RXORN_MASK                   0x00000020 /* Receive FIFO overrun interrupt */
-#define MAC_DMA_ISR_TXOK_MASK                    0x00000040 /* Transmit okay interrupt */
-#define MAC_DMA_ISR_TXDESC_MASK                  0x00000080 /* Transmit interrupt request */
-#define MAC_DMA_ISR_TXERR_MASK                   0x00000100 /* Transmit error interrupt */
-#define MAC_DMA_ISR_TXNOPKT_MASK                 0x00000200 /* No frame transmitted interrupt */
-#define MAC_DMA_ISR_TXEOL_MASK                   0x00000400 /* Transmit descriptor empty interrupt */
-#define MAC_DMA_ISR_TXURN_MASK                   0x00000800 /* Transmit FIFO underrun interrupt */
-#define MAC_DMA_ISR_MIB_MASK                     0x00001000 /* MIB interrupt - see MIBC */
-#define MAC_DMA_ISR_SWI_MASK                     0x00002000 /* Software interrupt */
-#define MAC_DMA_ISR_RXPHY_MASK                   0x00004000 /* PHY receive error interrupt */
-#define MAC_DMA_ISR_RXKCM_MASK                   0x00008000 /* Key-cache miss interrupt */
-#define MAC_DMA_ISR_BRSSI_HI_MASK                0x00010000 /* Beacon rssi high threshold interrupt */
-#define MAC_DMA_ISR_BRSSI_LO_MASK                0x00020000 /* Beacon threshold interrupt */
-#define MAC_DMA_ISR_BMISS_MASK                   0x00040000 /* Beacon missed interrupt */
-#define MAC_DMA_ISR_TXMINTR_MASK                 0x00080000 /* Maximum transmit interrupt rate */
-#define MAC_DMA_ISR_BNR_MASK                     0x00100000 /* Beacon not ready interrupt */
-#define MAC_DMA_ISR_HIUERR_MASK                  0x00200000 /* An unexpected bus error has occurred */
-#define MAC_DMA_ISR_BCNMISC_MASK                 0x00800000 /* 'or' of TIM, CABEND, DTIMSYNC, BCNTO */
-#define MAC_DMA_ISR_RXMINTR_MASK                 0x01000000 /* Maximum receive interrupt rate */
-#define MAC_DMA_ISR_QCBROVF_MASK                 0x02000000 /* QCU CBR overflow interrupt */
-#define MAC_DMA_ISR_QCBRURN_MASK                 0x04000000 /* QCU CBR underrun interrupt */
-#define MAC_DMA_ISR_QTRIG_MASK                   0x08000000 /* QCU scheduling trigger interrupt */
-#define MAC_DMA_ISR_TIMER_MASK                   0x10000000 /* GENTMR interrupt */
-#define MAC_DMA_ISR_HCFTO_MASK                   0x20000000 /* HCFTO interrupt   */
-#define MAC_DMA_ISR_TXINTM_MASK                  0x40000000 /* Transmit completion mitigation interrupt */
-#define MAC_DMA_ISR_RXINTM_MASK                  0x80000000 /* Receive completion mitigation interrupt */
-
-#define MAC_DMA_ISR_S0_ADDRESS                   0x00000084  /* MAC Secondary interrupt status register 0 */
-#define MAC_DMA_ISR_S0_QCU_TXOK_MASK             0x000003FF /* Mask for TXOK (QCU 0-9) */
-#define MAC_DMA_ISR_S0_QCU_TXOK_LSB              0
-#define MAC_DMA_ISR_S0_QCU_TXDESC_MASK           0x03FF0000 /* Mask for TXDESC (QCU 0-9) */
-#define MAC_DMA_ISR_S0_QCU_TXDESC_LSB            16
-
-#define MAC_DMA_ISR_S1_ADDRESS                   0x00000088  /* MAC Secondary interrupt status register 1 */
-#define MAC_DMA_ISR_S1_QCU_TXERR_MASK            0x000003FF /* Mask for TXERR (QCU 0-9) */
-#define MAC_DMA_ISR_S1_QCU_TXERR_LSB             0
-#define MAC_DMA_ISR_S1_QCU_TXEOL_MASK            0x03FF0000 /* Mask for TXEOL (QCU 0-9) */
-#define MAC_DMA_ISR_S1_QCU_TXEOL_LSB             16
-
-#define MAC_DMA_ISR_S2_ADDRESS                      0x0000008c  /* MAC Secondary interrupt status register 2 */
-#define MAC_DMA_ISR_S2_QCU_TXURN_MASK               0x000003FF /* Mask for TXURN (QCU 0-9) */
-#define MAC_DMA_ISR_S2_QCU_TXURN_LSB                0 /* Shift for TXURN (QCU 0-9) */
-#define MAC_DMA_ISR_S2_RX_INT_MASK                             0x00000800
-#define MAC_DMA_ISR_S2_WL_STOMPED_MASK                 0x00001000
-#define MAC_DMA_ISR_S2_RX_PTR_BAD_MASK                 0x00002000
-#define MAC_DMA_ISR_S2_BT_LOW_PRIORITY_RISING_MASK  0x00004000
-#define MAC_DMA_ISR_S2_BT_LOW_PRIORITY_FALLING_MASK    0x00008000
-#define MAC_DMA_ISR_S2_BB_PANIC_IRQ_MASK            0x00010000
-#define MAC_DMA_ISR_S2_BT_STOMPED_MASK                 0x00020000
-#define MAC_DMA_ISR_S2_BT_ACTIVE_RISING_MASK       0x00040000
-#define MAC_DMA_ISR_S2_BT_ACTIVE_FALLING_MASK      0x00080000
-#define MAC_DMA_ISR_S2_BT_PRIORITY_RISING_MASK     0x00100000
-#define MAC_DMA_ISR_S2_BT_PRIORITY_FALLING_MASK            0x00200000
-#define MAC_DMA_ISR_S2_CST_MASK                                    0x00400000
-#define MAC_DMA_ISR_S2_GTT_MASK                                    0x00800000
-#define MAC_DMA_ISR_S2_TIM_MASK                     0x01000000 /* TIM */
-#define MAC_DMA_ISR_S2_CABEND_MASK                  0x02000000 /* CABEND */
-#define MAC_DMA_ISR_S2_DTIMSYNC_MASK                0x04000000 /* DTIMSYNC */
-#define MAC_DMA_ISR_S2_BCNTO_MASK                   0x08000000 /* BCNTO */
-#define MAC_DMA_ISR_S2_CABTO_MASK                   0x10000000 /* CABTO */
-#define MAC_DMA_ISR_S2_DTIM_MASK                    0x20000000 /* DTIM */
-#define MAC_DMA_ISR_S2_TSFOOR_MASK                  0x40000000 /* TSFOOR */
-
-#define MAC_DMA_ISR_S3_ADDRESS                   0x00000090  /* MAC Secondary interrupt status register 3 */
-#define MAC_DMA_ISR_S3_QCU_QCBROVF_MASK          0x000003FF /* Mask for QCBROVF (QCU 0-9) */
-#define MAC_DMA_ISR_S3_QCU_QCBRURN_MASK          0x03FF0000 /* Mask for QCBRURN (QCU 0-9) */
-
-#define MAC_DMA_ISR_S4_ADDRESS                   0x00000094  /* MAC Secondary interrupt status register 4 */
-#define MAC_DMA_ISR_S4_QCU_QTRIG_MASK            0x000003FF /* Mask for QTRIG (QCU 0-9) */
-
-#define MAC_DMA_ISR_S5_ADDRESS                   0x00000098  /* MAC Secondary interrupt status register 5 */
-#define MAC_DMA_ISR_S5_TBTT_TIMER_TRIGGER_MASK   0x00000001
-#define MAC_DMA_ISR_S5_DBA_TIMER_TRIGGER_MASK    0x00000002
-#define MAC_DMA_ISR_S5_SBA_TIMER_TRIGGER_MASK    0x00000004
-#define MAC_DMA_ISR_S5_HCF_TIMER_TRIGGER_MASK    0x00000008
-#define MAC_DMA_ISR_S5_TIM_TIMER_TRIGGER_MASK    0x00000010
-#define MAC_DMA_ISR_S5_DTIM_TIMER_TRIGGER_MASK   0x00000020
-#define MAC_DMA_ISR_S5_QUIET_TIMER_TRIGGER_MASK  0x00000040
-#define MAC_DMA_ISR_S5_NDP_TIMER_TRIGGER_MASK    0x00000080
-#define MAC_DMA_ISR_S5_GENERIC_TIMER2_TRIGGER_MASK 0x0000FF00
-#define MAC_DMA_ISR_S5_GENERIC_TIMER2_TRIGGER_LSB 8 
-#define MAC_DMA_ISR_S5_GENERIC_TIMER2_TRIGGER(_i) (0x00000100 << (_i))
-#define MAC_DMA_ISR_S5_TIMER_OVERFLOW_MASK       0x00010000
-#define MAC_DMA_ISR_S5_DBA_TIMER_THRESHOLD_MASK  0x00020000
-#define MAC_DMA_ISR_S5_SBA_TIMER_THRESHOLD_MASK  0x00040000
-#define MAC_DMA_ISR_S5_HCF_TIMER_THRESHOLD_MASK  0x00080000
-#define MAC_DMA_ISR_S5_TIM_TIMER_THRESHOLD_MASK  0x00100000
-#define MAC_DMA_ISR_S5_DTIM_TIMER_THRESHOLD_MASK  0x00200000
-#define MAC_DMA_ISR_S5_QUIET_TIMER_THRESHOLD_MASK 0x00400000
-#define MAC_DMA_ISR_S5_NDP_TIMER_THRESHOLD_MASK   0x00800000
-#define MAC_DMA_IMR_S5_GENERIC_TIMER2_THRESHOLD_MASK 0xFF000000
-#define MAC_DMA_IMR_S5_GENERIC_TIMER2_THRESHOLD_LSB  24 
-#define MAC_DMA_IMR_S5_GENERIC_TIMER2_THRESHOLD(_i) (0x01000000 << (_i))
-
-#define MAC_DMA_IMR_ADDRESS                      0x000000A0  /* MAC Primary interrupt mask register */
-/*
- * Interrupt Mask Registers
- *
- * Only the bits in the IMR control whether the MAC's INTA#
- * output will be asserted.  The bits in the secondary interrupt
- * mask registers control what bits get set in the primary
- * interrupt status register; however the IMR_S* registers
- * DO NOT determine whether INTA# is asserted.
- */
-#define MAC_DMA_IMR_RXOK_MASK                    0x00000001 /* At least one frame received sans errors */
-#define MAC_DMA_IMR_RXDESC_MASK                  0x00000002 /* Receive interrupt request */
-#define MAC_DMA_IMR_RXERR_MASK                   0x00000004 /* Receive error interrupt */
-#define MAC_DMA_IMR_RXNOPKT_MASK                 0x00000008 /* No frame received within timeout clock */
-#define MAC_DMA_IMR_RXEOL_MASK                   0x00000010 /* Received descriptor empty interrupt */
-#define MAC_DMA_IMR_RXORN_MASK                   0x00000020 /* Receive FIFO overrun interrupt */
-#define MAC_DMA_IMR_TXOK_MASK                    0x00000040 /* Transmit okay interrupt */
-#define MAC_DMA_IMR_TXDESC_MASK                  0x00000080 /* Transmit interrupt request */
-#define MAC_DMA_IMR_TXERR_MASK                   0x00000100 /* Transmit error interrupt */
-#define MAC_DMA_IMR_TXNOPKT_MASK                 0x00000200 /* No frame transmitted interrupt */
-#define MAC_DMA_IMR_TXEOL_MASK                   0x00000400 /* Transmit descriptor empty interrupt */
-#define MAC_DMA_IMR_TXURN_MASK                   0x00000800 /* Transmit FIFO underrun interrupt */
-#define MAC_DMA_IMR_MIB_MASK                     0x00001000 /* MIB interrupt - see MIBC */
-#define MAC_DMA_IMR_SWI_MASK                     0x00002000 /* Software interrupt */
-#define MAC_DMA_IMR_RXPHY_MASK                   0x00004000 /* PHY receive error interrupt */
-#define MAC_DMA_IMR_RXKCM_MASK                   0x00008000 /* Key-cache miss interrupt */
-#define MAC_DMA_IMR_BRSSI_HI_MASK                0x00010000 /* Beacon rssi hi threshold interrupt */
-#define MAC_DMA_IMR_BRSSI_LO_MASK                0x00020000 /* Beacon rssi lo threshold interrupt */
-#define MAC_DMA_IMR_BMISS_MASK                   0x00040000 /* Beacon missed interrupt */
-#define MAC_DMA_IMR_TXMINTR_MASK                 0x00080000 /* Maximum transmit interrupt rate */
-#define MAC_DMA_IMR_BNR_MASK                     0x00100000 /* BNR interrupt */
-#define MAC_DMA_IMR_HIUERR_MASK                  0x00200000 /* An unexpected bus error has occurred */
-#define MAC_DMA_IMR_BCNMISC_MASK                 0x00800000 /* Beacon Misc */
-#define MAC_DMA_IMR_RXMINTR_MASK                 0x01000000 /* Maximum receive interrupt rate */
-#define MAC_DMA_IMR_QCBROVF_MASK                 0x02000000 /* QCU CBR overflow interrupt */
-#define MAC_DMA_IMR_QCBRURN_MASK                 0x04000000 /* QCU CBR underrun interrupt */
-#define MAC_DMA_IMR_QTRIG_MASK                   0x08000000 /* QCU scheduling trigger interrupt */
-#define MAC_DMA_IMR_TIMER_MASK                   0x10000000 /* GENTMR interrupt */
-#define MAC_DMA_IMR_HCFTO_MASK                   0x20000000 /* HCFTO interrupt*/
-#define MAC_DMA_IMR_TXINTM_MASK                  0x40000000 /* Transmit completion mitigation interrupt */
-#define MAC_DMA_IMR_RXINTM_MASK                  0x80000000 /* Receive completion mitigation interrupt */
-
-#define MAC_DMA_IMR_S0_ADDRESS                   0x000000A4  /* MAC Secondary interrupt mask register 0 */
-#define MAC_DMA_IMR_S0_QCU_TXOK_MASK             0x000003FF /* TXOK (QCU 0-9) */
-#define MAC_DMA_IMR_S0_QCU_TXOK_LSB              0
-#define MAC_DMA_IMR_S0_QCU_TXDESC_MASK           0x03FF0000 /* TXDESC (QCU 0-9) */
-#define MAC_DMA_IMR_S0_QCU_TXDESC_LSB            16
-
-#define MAC_DMA_IMR_S1_ADDRESS                   0x000000A8  /* MAC Secondary interrupt mask register 1 */
-#define MAC_DMA_IMR_S1_QCU_TXERR_MASK            0x000003FF /* TXERR (QCU 0-9) */
-#define MAC_DMA_IMR_S1_QCU_TXERR_LSB             0
-#define MAC_DMA_IMR_S1_QCU_TXEOL_MASK            0x03FF0000 /* TXEOL (QCU 0-9) */
-#define MAC_DMA_IMR_S1_QCU_TXEOL_LSB             16
-
-#define MAC_DMA_IMR_S2_ADDRESS                      0x000000AC  /* MAC Secondary interrupt mask register 2 */
-#define MAC_DMA_IMR_S2_QCU_TXURN_MASK               0x000003FF /* Mask for TXURN (QCU 0-9) */
-#define MAC_DMA_IMR_S2_QCU_TXURN_LSB                0
-#define MAC_DMA_IMR_S2_RX_INT_MASK                             0x00000800
-#define MAC_DMA_IMR_S2_WL_STOMPED_MASK                 0x00001000
-#define MAC_DMA_IMR_S2_RX_PTR_BAD_MASK                 0x00002000
-#define MAC_DMA_IMR_S2_BT_LOW_PRIORITY_RISING_MASK  0x00004000
-#define MAC_DMA_IMR_S2_BT_LOW_PRIORITY_FALLING_MASK    0x00008000
-#define MAC_DMA_IMR_S2_BB_PANIC_IRQ_MASK            0x00010000
-#define MAC_DMA_IMR_S2_BT_STOMPED_MASK                 0x00020000
-#define MAC_DMA_IMR_S2_BT_ACTIVE_RISING_MASK       0x00040000
-#define MAC_DMA_IMR_S2_BT_ACTIVE_FALLING_MASK      0x00080000
-#define MAC_DMA_IMR_S2_BT_PRIORITY_RISING_MASK     0x00100000
-#define MAC_DMA_IMR_S2_BT_PRIORITY_FALLING_MASK            0x00200000
-#define MAC_DMA_IMR_S2_CST_MASK                                    0x00400000
-#define MAC_DMA_IMR_S2_GTT_MASK                                    0x00800000
-#define MAC_DMA_IMR_S2_TIM_MASK                     0x01000000 /* TIM */
-#define MAC_DMA_IMR_S2_CABEND_MASK                  0x02000000 /* CABEND */
-#define MAC_DMA_IMR_S2_DTIMSYNC_MASK                0x04000000 /* DTIMSYNC */
-#define MAC_DMA_IMR_S2_BCNTO_MASK                   0x08000000 /* BCNTO */
-#define MAC_DMA_IMR_S2_CABTO_MASK                   0x10000000 /* CABTO */
-#define MAC_DMA_IMR_S2_DTIM_MASK                    0x20000000 /* DTIM */
-#define MAC_DMA_IMR_S2_TSFOOR_MASK                  0x40000000 /* TSFOOR */
-
-#define MAC_DMA_IMR_S3_ADDRESS                   0x000000B0  /* MAC Secondary interrupt mask register 3 */
-#define MAC_DMA_IMR_S3_QCU_QCBROVF_MASK          0x000003FF /* Mask for QCBROVF (QCU 0-9) */
-#define MAC_DMA_IMR_S3_QCU_QCBRURN_MASK          0x03FF0000 /* Mask for QCBRURN (QCU 0-9) */
-#define MAC_DMA_IMR_S3_QCU_QCBRURN_LSB           16 
-
-#define MAC_DMA_IMR_S4_ADDRESS                   0x000000B4  /* MAC Secondary interrupt mask register 4 */
-#define MAC_DMA_IMR_S4_QCU_QTRIG_MASK            0x000003FF /* Mask for QTRIG (QCU 0-9) */
-
-#define MAC_DMA_IMR_S5_ADDRESS                   0x000000B8  /* MAC Secondary interrupt mask register 5 */
-#define MAC_DMA_IMR_S5_TBTT_TIMER_TRIGGER_MASK   0x00000001
-#define MAC_DMA_IMR_S5_DBA_TIMER_TRIGGER_MASK    0x00000002
-#define MAC_DMA_IMR_S5_SBA_TIMER_TRIGGER_MASK    0x00000004
-#define MAC_DMA_IMR_S5_HCF_TIMER_TRIGGER_MASK    0x00000008
-#define MAC_DMA_IMR_S5_TIM_TIMER_TRIGGER_MASK    0x00000010
-#define MAC_DMA_IMR_S5_DTIM_TIMER_TRIGGER_MASK   0x00000020
-#define MAC_DMA_IMR_S5_QUIET_TIMER_TRIGGER_MASK  0x00000040
-#define MAC_DMA_IMR_S5_NDP_TIMER_TRIGGER_MASK    0x00000080
-#define MAC_DMA_IMR_S5_GENERIC_TIMER2_TRIGGER_MASK 0x0000FF00
-#define MAC_DMA_IMR_S5_GENERIC_TIMER2_TRIGGER_LSB 8 
-#define MAC_DMA_IMR_S5_GENERIC_TIMER2_TRIGGER(_i)    (0x100 << (_i))
-#define MAC_DMA_IMR_S5_TIMER_OVERFLOW_MASK       0x00010000
-#define MAC_DMA_IMR_S5_DBA_TIMER_THRESHOLD_MASK  0x00020000
-#define MAC_DMA_IMR_S5_SBA_TIMER_THRESHOLD_MASK  0x00040000
-#define MAC_DMA_IMR_S5_HCF_TIMER_THRESHOLD_MASK  0x00080000
-#define MAC_DMA_IMR_S5_TIM_TIMER_THRESHOLD_MASK  0x00100000
-#define MAC_DMA_IMR_S5_DTIM_TIMER_THRESHOLD_MASK 0x00200000
-#define MAC_DMA_IMR_S5_QUIET_TIMER_THRESHOLD_MASK 0000400000
-#define MAC_DMA_IMR_S5_NDP_TIMER_THRESHOLD_MASK  0x00800000
-#define MAC_DMA_IMR_S5_GENERIC_TIMER2_THRESHOLD_MASK 0xFF000000
-#define MAC_DMA_IMR_S5_GENERIC_TIMER2_THRESHOLD_LSB  24 
-#define MAC_DMA_IMR_S5_GENERIC_TIMER2_THRESHOLD(_i) (0x01000000 << (_i))
-
-#define MAC_DMA_ISR_RAC_ADDRESS                  0x000000C0  /* ISR read-and-clear access */
-
-/* Shadow copies with read-and-clear access */
-#define MAC_DMA_ISR_S0_S_ADDRESS                 0x000000C4  /* ISR_S0 shadow copy */
-#define MAC_DMA_ISR_S1_S_ADDRESS                 0x000000C8  /* ISR_S1 shadow copy */
-#define MAC_DMA_ISR_S2_S_ADDRESS                 0x000000Cc  /* ISR_S2 shadow copy */
-#define MAC_DMA_ISR_S3_S_ADDRESS                 0x000000D0  /* ISR_S3 shadow copy */
-#define MAC_DMA_ISR_S4_S_ADDRESS                 0x000000D4  /* ISR_S4 shadow copy */
-#define MAC_DMA_ISR_S5_S_ADDRESS                 0x000000D8  /* ISR_S5 shadow copy */
-
-#define MAC_DMA_Q0_TXDP_ADDRESS                  0x00000800  /* MAC Transmit Queue descriptor pointer */
-#define MAC_DMA_Q1_TXDP_ADDRESS                  0x00000804  /* MAC Transmit Queue descriptor pointer */
-#define MAC_DMA_Q2_TXDP_ADDRESS                  0x00000808  /* MAC Transmit Queue descriptor pointer */
-#define MAC_DMA_Q3_TXDP_ADDRESS                  0x0000080C  /* MAC Transmit Queue descriptor pointer */
-#define MAC_DMA_Q4_TXDP_ADDRESS                  0x00000810  /* MAC Transmit Queue descriptor pointer */
-#define MAC_DMA_Q5_TXDP_ADDRESS                  0x00000814  /* MAC Transmit Queue descriptor pointer */
-#define MAC_DMA_Q6_TXDP_ADDRESS                  0x00000818  /* MAC Transmit Queue descriptor pointer */
-#define MAC_DMA_Q7_TXDP_ADDRESS                  0x0000081C  /* MAC Transmit Queue descriptor pointer */
-#define MAC_DMA_Q8_TXDP_ADDRESS                  0x00000820  /* MAC Transmit Queue descriptor pointer */
-#define MAC_DMA_Q9_TXDP_ADDRESS                  0x00000824  /* MAC Transmit Queue descriptor pointer */
-#define MAC_DMA_QTXDP_ADDRESS(_i)                (MAC_DMA_Q0_TXDP_ADDRESS + ((_i)<<2))
-
-#define MAC_DMA_Q_TXE_ADDRESS                    0x00000840  /* MAC Transmit Queue enable */
-#define MAC_DMA_Q_TXD_ADDRESS                    0x00000880  /* MAC Transmit Queue disable */
-/* QCU registers */
-
-#define MAC_DMA_Q0_CBRCFG_ADDRESS                0x000008C0  /* MAC CBR configuration */
-#define MAC_DMA_Q1_CBRCFG_ADDRESS                0x000008C4  /* MAC CBR configuration */
-#define MAC_DMA_Q2_CBRCFG_ADDRESS                0x000008C8  /* MAC CBR configuration */
-#define MAC_DMA_Q3_CBRCFG_ADDRESS                0x000008CC  /* MAC CBR configuration */
-#define MAC_DMA_Q4_CBRCFG_ADDRESS                0x000008D0  /* MAC CBR configuration */
-#define MAC_DMA_Q5_CBRCFG_ADDRESS                0x000008D4  /* MAC CBR configuration */
-#define MAC_DMA_Q6_CBRCFG_ADDRESS                0x000008D8  /* MAC CBR configuration */
-#define MAC_DMA_Q7_CBRCFG_ADDRESS                0x000008DC  /* MAC CBR configuration */
-#define MAC_DMA_Q8_CBRCFG_ADDRESS                0x000008E0  /* MAC CBR configuration */
-#define MAC_DMA_Q9_CBRCFG_ADDRESS                0x000008E4  /* MAC CBR configuration */
-#define MAC_DMA_QCBRCFG_ADDRESS(_i)             (MAC_DMA_Q0_CBRCFG_ADDRESS + ((_i)<<2))
-
-#define MAC_DMA_Q_CBRCFG_CBR_INTERVAL_MASK        0x00FFFFFF /* Mask for CBR interval (us) */
-#define MAC_DMA_Q_CBRCFG_CBR_INTERVAL_LSB         0   /* Shift for CBR interval */
-#define MAC_DMA_Q_CBRCFG_CBR_OVF_THRESH_MASK      0xFF000000 /* Mask for CBR overflow threshold */
-#define MAC_DMA_Q_CBRCFG_CBR_OVF_THRESH_LSB       24  /* Shift for CBR overflow thresh */
-
-
-#define MAC_DMA_Q0_RDYTIMECFG_ADDRESS             0x00000900  /* MAC ReadyTime configuration */
-#define MAC_DMA_Q1_RDYTIMECFG_ADDRESS             0x00000904  /* MAC ReadyTime configuration */
-#define MAC_DMA_Q2_RDYTIMECFG_ADDRESS             0x00000908  /* MAC ReadyTime configuration */
-#define MAC_DMA_Q3_RDYTIMECFG_ADDRESS             0x0000090C  /* MAC ReadyTime configuration */
-#define MAC_DMA_Q4_RDYTIMECFG_ADDRESS             0x00000910  /* MAC ReadyTime configuration */
-#define MAC_DMA_Q5_RDYTIMECFG_ADDRESS             0x00000914  /* MAC ReadyTime configuration */
-#define MAC_DMA_Q6_RDYTIMECFG_ADDRESS             0x00000918  /* MAC ReadyTime configuration */
-#define MAC_DMA_Q7_RDYTIMECFG_ADDRESS             0x0000091C  /* MAC ReadyTime configuration */
-#define MAC_DMA_Q8_RDYTIMECFG_ADDRESS             0x00000920  /* MAC ReadyTime configuration */
-#define MAC_DMA_Q9_RDYTIMECFG_ADDRESS             0x00000924  /* MAC ReadyTime configuration */
-#define MAC_DMA_QRDYTIMECFG_ADDRESS(_i)           (MAC_DMA_Q0_RDYTIMECFG_ADDRESS + ((_i)<<2))
-
-#define MAC_DMA_Q_RDYTIMECFG_INT_MASK             0x00FFFFFF /* CBR interval (us) */
-#define MAC_DMA_Q_RDYTIMECFG_INT_LSB              0  /* Shift for ReadyTime Interval (us) */
-#define MAC_DMA_Q_RDYTIMECFG_ENA_MASK             0x01000000 /* CBR enable */
-
-#define MAC_DMA_Q_ONESHOTMAC_DMAM_SC_ADDRESS      0x00000940  /* MAC OneShotArm set control */
-#define MAC_DMA_Q_ONESHOTMAC_DMAM_CC_ADDRESS      0x00000980  /* MAC OneShotArm clear control */
-
-#define MAC_DMA_Q0_MISC_ADDRESS                   0x000009C0  /* MAC Miscellaneous QCU settings */
-#define MAC_DMA_Q1_MISC_ADDRESS                   0x000009C4  /* MAC Miscellaneous QCU settings */
-#define MAC_DMA_Q2_MISC_ADDRESS                   0x000009C8  /* MAC Miscellaneous QCU settings */
-#define MAC_DMA_Q3_MISC_ADDRESS                   0x000009CC  /* MAC Miscellaneous QCU settings */
-#define MAC_DMA_Q4_MISC_ADDRESS                   0x000009D0  /* MAC Miscellaneous QCU settings */
-#define MAC_DMA_Q5_MISC_ADDRESS                   0x000009D4  /* MAC Miscellaneous QCU settings */
-#define MAC_DMA_Q6_MISC_ADDRESS                   0x000009D8  /* MAC Miscellaneous QCU settings */
-#define MAC_DMA_Q7_MISC_ADDRESS                   0x000009DC  /* MAC Miscellaneous QCU settings */
-#define MAC_DMA_Q8_MISC_ADDRESS                   0x000009E0  /* MAC Miscellaneous QCU settings */
-#define MAC_DMA_Q9_MISC_ADDRESS                   0x000009E4  /* MAC Miscellaneous QCU settings */
-#define MAC_DMA_QMISC_ADDRESS(_i)                 (MAC_DMA_Q0_MISC_ADDRESS + ((_i)<<2))
-
-#define MAC_DMA_Q_MISC_FSP_MASK                   0x0000000F /* Frame Scheduling Policy mask */
-#define MAC_DMA_Q_MISC_FSP_ASAP                   0   /* ASAP */
-#define MAC_DMA_Q_MISC_FSP_CBR                    1   /* CBR */
-#define MAC_DMA_Q_MISC_FSP_DBA_GATED              2   /* DMA Beacon Alert gated */
-#define MAC_DMA_Q_MISC_FSP_TIM_GATED              3   /* TIM gated */
-#define MAC_DMA_Q_MISC_FSP_BEACON_SENT_GATED      4   /* Beacon-sent-gated */
-#define MAC_DMA_Q_MISC_ONE_SHOT_EN_MASK           0x00000010 /* OneShot enable */
-#define MAC_DMA_Q_MISC_CBR_INCR_DIS1_MASK         0x00000020 /* Disable CBR expired counter incr
-                                                        (empty q) */
-#define MAC_DMA_Q_MISC_CBR_INCR_DIS0_MASK         0x00000040 /* Disable CBR expired counter incr
-                                                        (empty beacon q) */
-#define MAC_DMA_Q_MISC_BEACON_USE_MASK            0x00000080 /* Beacon use indication */
-#define MAC_DMA_Q_MISC_CBR_EXP_CNTR_LIMIT_MASK    0x00000100 /* CBR expired counter limit enable */
-#define MAC_DMA_Q_MISC_RDYTIME_EXP_POLICY_MASK    0x00000200 /* Enable TXE cleared on ReadyTime expired or VEOL */
-#define MAC_DMA_Q_MISC_RESET_CBR_EXP_CTR_MASK     0x00000400 /* Reset CBR expired counter */
-#define MAC_DMA_Q_MISC_DCU_EARLY_TERM_REQ_MASK    0x00000800 /* DCU frame early termination request control */
-
-#define MAC_DMA_Q0_STS_ADDRESS                   0x00000A00  /* MAC Miscellaneous QCU status */
-#define MAC_DMA_Q1_STS_ADDRESS                   0x00000A04  /* MAC Miscellaneous QCU status */
-#define MAC_DMA_Q2_STS_ADDRESS                   0x00000A08  /* MAC Miscellaneous QCU status */
-#define MAC_DMA_Q3_STS_ADDRESS                   0x00000A0C  /* MAC Miscellaneous QCU status */
-#define MAC_DMA_Q4_STS_ADDRESS                   0x00000A10  /* MAC Miscellaneous QCU status */
-#define MAC_DMA_Q5_STS_ADDRESS                   0x00000A14  /* MAC Miscellaneous QCU status */
-#define MAC_DMA_Q6_STS_ADDRESS                   0x00000A18  /* MAC Miscellaneous QCU status */
-#define MAC_DMA_Q7_STS_ADDRESS                   0x00000A1C  /* MAC Miscellaneous QCU status */
-#define MAC_DMA_Q8_STS_ADDRESS                   0x00000A20  /* MAC Miscellaneous QCU status */
-#define MAC_DMA_Q9_STS_ADDRESS                   0x00000A24  /* MAC Miscellaneous QCU status */
-#define MAC_DMA_QSTS_ADDRESS(_i)                 (MAC_DMA_Q0_STS_ADDRESS + ((_i)<<2))
-
-#define MAC_DMA_Q_STS_PEND_FR_CNT_MASK           0x00000003 /* Mask for Pending Frame Count */
-#define MAC_DMA_Q_STS_CBR_EXP_CNT_MASK           0x0000FF00 /* Mask for CBR expired counter */
-
-#define MAC_DMA_Q_RDYTIMESHDN_ADDRESS            0x00000A40  /* MAC ReadyTimeShutdown status */
-
-/* DCU registers */
-
-#define MAC_DMA_D0_QCUMASK_ADDRESS               0x00001000  /* MAC QCU Mask */
-#define MAC_DMA_D1_QCUMASK_ADDRESS               0x00001004  /* MAC QCU Mask */
-#define MAC_DMA_D2_QCUMASK_ADDRESS               0x00001008  /* MAC QCU Mask */
-#define MAC_DMA_D3_QCUMASK_ADDRESS               0x0000100C  /* MAC QCU Mask */
-#define MAC_DMA_D4_QCUMASK_ADDRESS               0x00001010  /* MAC QCU Mask */
-#define MAC_DMA_D5_QCUMASK_ADDRESS               0x00001014  /* MAC QCU Mask */
-#define MAC_DMA_D6_QCUMASK_ADDRESS               0x00001018  /* MAC QCU Mask */
-#define MAC_DMA_D7_QCUMASK_ADDRESS               0x0000101C  /* MAC QCU Mask */
-#define MAC_DMA_D8_QCUMASK_ADDRESS               0x00001020  /* MAC QCU Mask */
-#define MAC_DMA_D9_QCUMASK_ADDRESS               0x00001024  /* MAC QCU Mask */
-#define MAC_DMA_DQCUMASK_ADDRESS(_i)             (MAC_DMA_D0_QCUMASK_ADDRESS + ((_i)<<2))
-
-#define MAC_DMA_D_QCUMASK_MASK                   0x000003FF /* Mask for QCU Mask (QCU 0-9) */
-
-#define MAC_DMA_D_GBL_IFS_SIFS_ADDRESS           0x00001030  /* DCU global SIFS settings */
-
-
-#define MAC_DMA_D0_LCL_IFS_ADDRESS               0x00001040  /* MAC DCU-specific IFS settings */
-#define MAC_DMA_D1_LCL_IFS_ADDRESS               0x00001044  /* MAC DCU-specific IFS settings */
-#define MAC_DMA_D2_LCL_IFS_ADDRESS               0x00001048  /* MAC DCU-specific IFS settings */
-#define MAC_DMA_D3_LCL_IFS_ADDRESS               0x0000104C  /* MAC DCU-specific IFS settings */
-#define MAC_DMA_D4_LCL_IFS_ADDRESS               0x00001050  /* MAC DCU-specific IFS settings */
-#define MAC_DMA_D5_LCL_IFS_ADDRESS               0x00001054  /* MAC DCU-specific IFS settings */
-#define MAC_DMA_D6_LCL_IFS_ADDRESS               0x00001058  /* MAC DCU-specific IFS settings */
-#define MAC_DMA_D7_LCL_IFS_ADDRESS               0x0000105C  /* MAC DCU-specific IFS settings */
-#define MAC_DMA_D8_LCL_IFS_ADDRESS               0x00001060  /* MAC DCU-specific IFS settings */
-#define MAC_DMA_D9_LCL_IFS_ADDRESS               0x00001064  /* MAC DCU-specific IFS settings */
-#define MAC_DMA_DLCL_IFS_ADDRESS(_i)             (MAC_DMA_D0_LCL_IFS_ADDRESS + ((_i)<<2))
-#define MAC_DMA_D_LCL_IFS_CWMIN_MASK             0x000003FF /* Mask for CW_MIN */
-#define MAC_DMA_D_LCL_IFS_CWMIN_LSB              0
-#define MAC_DMA_D_LCL_IFS_CWMAX_MASK             0x000FFC00 /* Mask for CW_MAX */
-#define MAC_DMA_D_LCL_IFS_CWMAX_LSB              10
-#define MAC_DMA_D_LCL_IFS_AIFS_MASK              0x0FF00000 /* Mask for AIFS */
-#define MAC_DMA_D_LCL_IFS_AIFS_LSB               20
-/*
- *  Note:  even though this field is 8 bits wide the
- *  maximum supported AIFS value is 0xFc.  Setting the AIFS value
- *  to 0xFd 0xFe, or 0xFf will not work correctly and will cause
- *  the DCU to hang.
- */
-#define MAC_DMA_D_GBL_IFS_SLOT_ADDRESS           0x00001070  /* DC global slot interval */
-
-#define MAC_DMA_D0_RETRY_LIMIT_ADDRESS           0x00001080  /* MAC Retry limits */
-#define MAC_DMA_D1_RETRY_LIMIT_ADDRESS           0x00001084  /* MAC Retry limits */
-#define MAC_DMA_D2_RETRY_LIMIT_ADDRESS           0x00001088  /* MAC Retry limits */
-#define MAC_DMA_D3_RETRY_LIMIT_ADDRESS           0x0000108C  /* MAC Retry limits */
-#define MAC_DMA_D4_RETRY_LIMIT_ADDRESS           0x00001090  /* MAC Retry limits */
-#define MAC_DMA_D5_RETRY_LIMIT_ADDRESS           0x00001094  /* MAC Retry limits */
-#define MAC_DMA_D6_RETRY_LIMIT_ADDRESS           0x00001098  /* MAC Retry limits */
-#define MAC_DMA_D7_RETRY_LIMIT_ADDRESS           0x0000109C  /* MAC Retry limits */
-#define MAC_DMA_D8_RETRY_LIMIT_ADDRESS           0x000010A0  /* MAC Retry limits */
-#define MAC_DMA_D9_RETRY_LIMIT_ADDRESS           0x000010A4  /* MAC Retry limits */
-#define MAC_DMA_DRETRY_LIMIT_ADDRESS(_i)         (MAC_DMA_D0_RETRY_LIMIT_ADDRESS + ((_i)<<2))
-
-#define MAC_DMA_D_RETRY_LIMIT_FR_RTS_MASK        0x0000000F /* frame RTS failure limit */
-#define MAC_DMA_D_RETRY_LIMIT_FR_RTS_LSB         0
-#define MAC_DMA_D_RETRY_LIMIT_STA_RTS_MASK       0x00003F00 /* station RTS failure limit */
-#define MAC_DMA_D_RETRY_LIMIT_STA_RTS_LSB        8
-#define MAC_DMA_D_RETRY_LIMIT_STA_DATA_MASK      0x000FC000 /* station short retry limit */
-#define MAC_DMA_D_RETRY_LIMIT_STA_DATA_LSB       14
-
-#define MAC_DMA_D_GBL_IFS_EIFS_ADDRESS           0x000010B0  /* DCU global EIFS setting */
-
-#define MAC_DMA_D0_CHNTIME_ADDRESS               0x000010C0  /* MAC ChannelTime settings */
-#define MAC_DMA_D1_CHNTIME_ADDRESS               0x000010C4  /* MAC ChannelTime settings */
-#define MAC_DMA_D2_CHNTIME_ADDRESS               0x000010C8  /* MAC ChannelTime settings */
-#define MAC_DMA_D3_CHNTIME_ADDRESS               0x000010CC  /* MAC ChannelTime settings */
-#define MAC_DMA_D4_CHNTIME_ADDRESS               0x000010D0  /* MAC ChannelTime settings */
-#define MAC_DMA_D5_CHNTIME_ADDRESS               0x000010D4  /* MAC ChannelTime settings */
-#define MAC_DMA_D6_CHNTIME_ADDRESS               0x000010D8  /* MAC ChannelTime settings */
-#define MAC_DMA_D7_CHNTIME_ADDRESS               0x000010DC  /* MAC ChannelTime settings */
-#define MAC_DMA_D8_CHNTIME_ADDRESS               0x000010E0  /* MAC ChannelTime settings */
-#define MAC_DMA_D9_CHNTIME_ADDRESS               0x000010E4  /* MAC ChannelTime settings */
-#define MAC_DMA_DCHNTIME_ADDRESS(_i)             (MAC_DMA_D0_CHNTIME_ADDRESS + ((_i)<<2))
-
-#define MAC_DMA_D_CHNTIME_DUR_MASK               0x000FFFFF /* ChannelTime duration (us) */
-#define MAC_DMA_D_CHNTIME_DUR_LSB                0 /* Shift for ChannelTime duration */
-#define MAC_DMA_D_CHNTIME_EN_MASK                0x00100000 /* ChannelTime enable */
-
-#define MAC_DMA_D_GBL_IFS_MISC_ADDRESS           0x000010f0  /* DCU global misc. IFS settings */
-#define MAC_DMA_D_GBL_IFS_MISC_LFSR_SLICE_SEL_MASK 0x00000007 /* LFSR slice select */
-#define MAC_DMA_D_GBL_IFS_MISC_TURBO_MODE_MASK     0x00000008 /* Turbo mode indication */
-#define MAC_DMA_D_GBL_IFS_MISC_DCU_ARBITER_DLY_MASK 0x00300000 /* DCU arbiter delay */
-#define MAC_DMA_D_GBL_IFS_IGNORE_BACKOFF_MASK      0x10000000
-
-#define MAC_DMA_D0_MISC_ADDRESS                  0x00001100  /* MAC Miscellaneous DCU-specific settings */
-#define MAC_DMA_D1_MISC_ADDRESS                  0x00001104  /* MAC Miscellaneous DCU-specific settings */
-#define MAC_DMA_D2_MISC_ADDRESS                  0x00001108  /* MAC Miscellaneous DCU-specific settings */
-#define MAC_DMA_D3_MISC_ADDRESS                  0x0000110C  /* MAC Miscellaneous DCU-specific settings */
-#define MAC_DMA_D4_MISC_ADDRESS                  0x00001110  /* MAC Miscellaneous DCU-specific settings */
-#define MAC_DMA_D5_MISC_ADDRESS                  0x00001114  /* MAC Miscellaneous DCU-specific settings */
-#define MAC_DMA_D6_MISC_ADDRESS                  0x00001118  /* MAC Miscellaneous DCU-specific settings */
-#define MAC_DMA_D7_MISC_ADDRESS                  0x0000111C  /* MAC Miscellaneous DCU-specific settings */
-#define MAC_DMA_D8_MISC_ADDRESS                  0x00001120  /* MAC Miscellaneous DCU-specific settings */
-#define MAC_DMA_D9_MISC_ADDRESS                  0x00001124  /* MAC Miscellaneous DCU-specific settings */
-#define MAC_DMA_DMISC_ADDRESS(_i)                (MAC_DMA_D0_MISC_ADDRESS + ((_i)<<2))
-
-#define MAC_DMA_D0_EOL_ADDRESS                  0x00001180
-#define MAC_DMA_D1_EOL_ADDRESS                  0x00001184
-#define MAC_DMA_D2_EOL_ADDRESS                  0x00001188
-#define MAC_DMA_D3_EOL_ADDRESS                  0x0000118C
-#define MAC_DMA_D4_EOL_ADDRESS                  0x00001190
-#define MAC_DMA_D5_EOL_ADDRESS                  0x00001194
-#define MAC_DMA_D6_EOL_ADDRESS                  0x00001198
-#define MAC_DMA_D7_EOL_ADDRESS                  0x0000119C
-#define MAC_DMA_D8_EOL_ADDRESS                  0x00001200
-#define MAC_DMA_D9_EOL_ADDRESS                  0x00001204
-#define MAC_DMA_DEOL_ADDRESS(_i)                (MAC_DMA_D0_EOL_ADDRESS + ((_i)<<2))
-
-#define MAC_DMA_D_MISC_BKOFF_THRESH_MASK         0x0000003F /* Backoff threshold */
-#define MAC_DMA_D_MISC_BACK_OFF_THRESH_LSB       0
-#define MAC_DMA_D_MISC_ETS_RTS_MASK              0x00000040 /* End of transmission series
-                                                          station RTS/data failure
-                                                          count reset policy */
-#define MAC_DMA_D_MISC_ETS_CW_MASK               0x00000080 /* End of transmission series
-                                                          CW reset policy */
-#define MAC_DMA_D_MISC_FRAG_WAIT_EN_MASK         0x00000100  /* Fragment Starvation Policy */
-
-#define MAC_DMA_D_MISC_FRAG_BKOFF_EN_MASK        0x00000200 /* Backoff during a frag burst */
-#define MAC_DMA_D_MISC_HCF_POLL_EN_MASK          0x00000800 /* HFC poll enable */
-#define MAC_DMA_D_MISC_BKOFF_PERSISTENCE_MASK    0x00001000 /* Backoff persistence factor
-                                                          setting */
-#define MAC_DMA_D_MISC_VIR_COL_HANDLING_MASK     0x0000C000 /* Mask for Virtual collision
-                                                          handling policy */
-#define MAC_DMA_D_MISC_VIR_COL_HANDLING_LSB      14
-#define MAC_DMA_D_MISC_VIR_COL_HANDLING_DEFAULT  0   /* Normal */
-#define MAC_DMA_D_MISC_VIR_COL_HANDLING_IGNORE   1   /* Ignore */
-#define MAC_DMA_D_MISC_BEACON_USE_MASK           0x00010000 /*  Beacon use indication */
-#define MAC_DMA_D_MISC_ARB_LOCKOUT_CNTRL_MASK 0x00060000 /*  Mask for DCU arbiter lockout control */
-#define MAC_DMA_D_MISC_ARB_LOCKOUT_CNTRL_LSB  17
-#define MAC_DMA_D_MISC_ARB_LOCKOUT_CNTRL_NONE     0        /*  No lockout*/
-#define MAC_DMA_D_MISC_ARB_LOCKOUT_CNTRL_INTRA_FR 1        /*  Intra-frame*/
-#define MAC_DMA_D_MISC_ARB_LOCKOUT_CNTRL_GLOBAL   2        /*  Global */
-#define MAC_DMA_D_MISC_ARB_LOCKOUT_IGNORE_MASK 0x00080000 /*  DCU arbiter lockout ignore control */
-#define MAC_DMA_D_MISC_SEQ_NUM_INCR_DIS_MASK    0x00100000 /* Sequence number increment disable */
-#define MAC_DMA_D_MISC_POST_FR_BKOFF_DIS_MASK   0x00200000 /* Post-frame backoff disable */
-#define MAC_DMA_D_MISC_VIRT_COLL_POLICY_MASK    0x00400000 /* Virtual coll. handling policy */
-#define MAC_DMA_D_MISC_BLOWN_IFS_POLICY_MASK    0x00800000 /* Blown IFS handling policy */
-
-#define MAC_DMA_D_SEQNUM_ADDRESS                0x00001140  /* MAC Frame sequence number */
-
-
-
-#define MAC_DMA_D_FPCTL_ADDRESS                  0x00001230      /* DCU frame prefetch settings */
-#define MAC_DMA_D_TXPSE_ADDRESS                  0x00001270      /* DCU transmit pause control/status */
-
-#endif /* _AR6000_DMMAEG_H_ */
diff --git a/drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/mac_pcu_reg.h b/drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/mac_pcu_reg.h
deleted file mode 100644 (file)
index 6ccb08c..0000000
+++ /dev/null
@@ -1,3065 +0,0 @@
-// ------------------------------------------------------------------
-// Copyright (c) 2004-2010 Atheros Corporation.  All rights reserved.
-// 
-//
-// Permission to use, copy, modify, and/or distribute this software for any
-// purpose with or without fee is hereby granted, provided that the above
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-//
-//
-// ------------------------------------------------------------------
-//===================================================================
-// Author(s): ="Atheros"
-//===================================================================
-
-
-#ifndef _MAC_PCU_REG_H_
-#define _MAC_PCU_REG_H_
-
-#define MAC_PCU_STA_ADDR_L32_ADDRESS             0x00008000
-#define MAC_PCU_STA_ADDR_L32_OFFSET              0x00000000
-#define MAC_PCU_STA_ADDR_L32_ADDR_31_0_MSB       31
-#define MAC_PCU_STA_ADDR_L32_ADDR_31_0_LSB       0
-#define MAC_PCU_STA_ADDR_L32_ADDR_31_0_MASK      0xffffffff
-#define MAC_PCU_STA_ADDR_L32_ADDR_31_0_GET(x)    (((x) & MAC_PCU_STA_ADDR_L32_ADDR_31_0_MASK) >> MAC_PCU_STA_ADDR_L32_ADDR_31_0_LSB)
-#define MAC_PCU_STA_ADDR_L32_ADDR_31_0_SET(x)    (((x) << MAC_PCU_STA_ADDR_L32_ADDR_31_0_LSB) & MAC_PCU_STA_ADDR_L32_ADDR_31_0_MASK)
-
-#define MAC_PCU_STA_ADDR_U16_ADDRESS             0x00008004
-#define MAC_PCU_STA_ADDR_U16_OFFSET              0x00000004
-#define MAC_PCU_STA_ADDR_U16_ADHOC_MCAST_SEARCH_MSB 31
-#define MAC_PCU_STA_ADDR_U16_ADHOC_MCAST_SEARCH_LSB 31
-#define MAC_PCU_STA_ADDR_U16_ADHOC_MCAST_SEARCH_MASK 0x80000000
-#define MAC_PCU_STA_ADDR_U16_ADHOC_MCAST_SEARCH_GET(x) (((x) & MAC_PCU_STA_ADDR_U16_ADHOC_MCAST_SEARCH_MASK) >> MAC_PCU_STA_ADDR_U16_ADHOC_MCAST_SEARCH_LSB)
-#define MAC_PCU_STA_ADDR_U16_ADHOC_MCAST_SEARCH_SET(x) (((x) << MAC_PCU_STA_ADDR_U16_ADHOC_MCAST_SEARCH_LSB) & MAC_PCU_STA_ADDR_U16_ADHOC_MCAST_SEARCH_MASK)
-#define MAC_PCU_STA_ADDR_U16_CBCIV_ENDIAN_MSB    30
-#define MAC_PCU_STA_ADDR_U16_CBCIV_ENDIAN_LSB    30
-#define MAC_PCU_STA_ADDR_U16_CBCIV_ENDIAN_MASK   0x40000000
-#define MAC_PCU_STA_ADDR_U16_CBCIV_ENDIAN_GET(x) (((x) & MAC_PCU_STA_ADDR_U16_CBCIV_ENDIAN_MASK) >> MAC_PCU_STA_ADDR_U16_CBCIV_ENDIAN_LSB)
-#define MAC_PCU_STA_ADDR_U16_CBCIV_ENDIAN_SET(x) (((x) << MAC_PCU_STA_ADDR_U16_CBCIV_ENDIAN_LSB) & MAC_PCU_STA_ADDR_U16_CBCIV_ENDIAN_MASK)
-#define MAC_PCU_STA_ADDR_U16_PRESERVE_SEQNUM_MSB 29
-#define MAC_PCU_STA_ADDR_U16_PRESERVE_SEQNUM_LSB 29
-#define MAC_PCU_STA_ADDR_U16_PRESERVE_SEQNUM_MASK 0x20000000
-#define MAC_PCU_STA_ADDR_U16_PRESERVE_SEQNUM_GET(x) (((x) & MAC_PCU_STA_ADDR_U16_PRESERVE_SEQNUM_MASK) >> MAC_PCU_STA_ADDR_U16_PRESERVE_SEQNUM_LSB)
-#define MAC_PCU_STA_ADDR_U16_PRESERVE_SEQNUM_SET(x) (((x) << MAC_PCU_STA_ADDR_U16_PRESERVE_SEQNUM_LSB) & MAC_PCU_STA_ADDR_U16_PRESERVE_SEQNUM_MASK)
-#define MAC_PCU_STA_ADDR_U16_KSRCH_MODE_MSB      28
-#define MAC_PCU_STA_ADDR_U16_KSRCH_MODE_LSB      28
-#define MAC_PCU_STA_ADDR_U16_KSRCH_MODE_MASK     0x10000000
-#define MAC_PCU_STA_ADDR_U16_KSRCH_MODE_GET(x)   (((x) & MAC_PCU_STA_ADDR_U16_KSRCH_MODE_MASK) >> MAC_PCU_STA_ADDR_U16_KSRCH_MODE_LSB)
-#define MAC_PCU_STA_ADDR_U16_KSRCH_MODE_SET(x)   (((x) << MAC_PCU_STA_ADDR_U16_KSRCH_MODE_LSB) & MAC_PCU_STA_ADDR_U16_KSRCH_MODE_MASK)
-#define MAC_PCU_STA_ADDR_U16_CRPT_MIC_ENABLE_MSB 27
-#define MAC_PCU_STA_ADDR_U16_CRPT_MIC_ENABLE_LSB 27
-#define MAC_PCU_STA_ADDR_U16_CRPT_MIC_ENABLE_MASK 0x08000000
-#define MAC_PCU_STA_ADDR_U16_CRPT_MIC_ENABLE_GET(x) (((x) & MAC_PCU_STA_ADDR_U16_CRPT_MIC_ENABLE_MASK) >> MAC_PCU_STA_ADDR_U16_CRPT_MIC_ENABLE_LSB)
-#define MAC_PCU_STA_ADDR_U16_CRPT_MIC_ENABLE_SET(x) (((x) << MAC_PCU_STA_ADDR_U16_CRPT_MIC_ENABLE_LSB) & MAC_PCU_STA_ADDR_U16_CRPT_MIC_ENABLE_MASK)
-#define MAC_PCU_STA_ADDR_U16_SECTOR_SELF_GEN_MSB 26
-#define MAC_PCU_STA_ADDR_U16_SECTOR_SELF_GEN_LSB 26
-#define MAC_PCU_STA_ADDR_U16_SECTOR_SELF_GEN_MASK 0x04000000
-#define MAC_PCU_STA_ADDR_U16_SECTOR_SELF_GEN_GET(x) (((x) & MAC_PCU_STA_ADDR_U16_SECTOR_SELF_GEN_MASK) >> MAC_PCU_STA_ADDR_U16_SECTOR_SELF_GEN_LSB)
-#define MAC_PCU_STA_ADDR_U16_SECTOR_SELF_GEN_SET(x) (((x) << MAC_PCU_STA_ADDR_U16_SECTOR_SELF_GEN_LSB) & MAC_PCU_STA_ADDR_U16_SECTOR_SELF_GEN_MASK)
-#define MAC_PCU_STA_ADDR_U16_BASE_RATE_11B_MSB   25
-#define MAC_PCU_STA_ADDR_U16_BASE_RATE_11B_LSB   25
-#define MAC_PCU_STA_ADDR_U16_BASE_RATE_11B_MASK  0x02000000
-#define MAC_PCU_STA_ADDR_U16_BASE_RATE_11B_GET(x) (((x) & MAC_PCU_STA_ADDR_U16_BASE_RATE_11B_MASK) >> MAC_PCU_STA_ADDR_U16_BASE_RATE_11B_LSB)
-#define MAC_PCU_STA_ADDR_U16_BASE_RATE_11B_SET(x) (((x) << MAC_PCU_STA_ADDR_U16_BASE_RATE_11B_LSB) & MAC_PCU_STA_ADDR_U16_BASE_RATE_11B_MASK)
-#define MAC_PCU_STA_ADDR_U16_ACKCTS_6MB_MSB      24
-#define MAC_PCU_STA_ADDR_U16_ACKCTS_6MB_LSB      24
-#define MAC_PCU_STA_ADDR_U16_ACKCTS_6MB_MASK     0x01000000
-#define MAC_PCU_STA_ADDR_U16_ACKCTS_6MB_GET(x)   (((x) & MAC_PCU_STA_ADDR_U16_ACKCTS_6MB_MASK) >> MAC_PCU_STA_ADDR_U16_ACKCTS_6MB_LSB)
-#define MAC_PCU_STA_ADDR_U16_ACKCTS_6MB_SET(x)   (((x) << MAC_PCU_STA_ADDR_U16_ACKCTS_6MB_LSB) & MAC_PCU_STA_ADDR_U16_ACKCTS_6MB_MASK)
-#define MAC_PCU_STA_ADDR_U16_RTS_USE_DEF_MSB     23
-#define MAC_PCU_STA_ADDR_U16_RTS_USE_DEF_LSB     23
-#define MAC_PCU_STA_ADDR_U16_RTS_USE_DEF_MASK    0x00800000
-#define MAC_PCU_STA_ADDR_U16_RTS_USE_DEF_GET(x)  (((x) & MAC_PCU_STA_ADDR_U16_RTS_USE_DEF_MASK) >> MAC_PCU_STA_ADDR_U16_RTS_USE_DEF_LSB)
-#define MAC_PCU_STA_ADDR_U16_RTS_USE_DEF_SET(x)  (((x) << MAC_PCU_STA_ADDR_U16_RTS_USE_DEF_LSB) & MAC_PCU_STA_ADDR_U16_RTS_USE_DEF_MASK)
-#define MAC_PCU_STA_ADDR_U16_DEFANT_UPDATE_MSB   22
-#define MAC_PCU_STA_ADDR_U16_DEFANT_UPDATE_LSB   22
-#define MAC_PCU_STA_ADDR_U16_DEFANT_UPDATE_MASK  0x00400000
-#define MAC_PCU_STA_ADDR_U16_DEFANT_UPDATE_GET(x) (((x) & MAC_PCU_STA_ADDR_U16_DEFANT_UPDATE_MASK) >> MAC_PCU_STA_ADDR_U16_DEFANT_UPDATE_LSB)
-#define MAC_PCU_STA_ADDR_U16_DEFANT_UPDATE_SET(x) (((x) << MAC_PCU_STA_ADDR_U16_DEFANT_UPDATE_LSB) & MAC_PCU_STA_ADDR_U16_DEFANT_UPDATE_MASK)
-#define MAC_PCU_STA_ADDR_U16_USE_DEFANT_MSB      21
-#define MAC_PCU_STA_ADDR_U16_USE_DEFANT_LSB      21
-#define MAC_PCU_STA_ADDR_U16_USE_DEFANT_MASK     0x00200000
-#define MAC_PCU_STA_ADDR_U16_USE_DEFANT_GET(x)   (((x) & MAC_PCU_STA_ADDR_U16_USE_DEFANT_MASK) >> MAC_PCU_STA_ADDR_U16_USE_DEFANT_LSB)
-#define MAC_PCU_STA_ADDR_U16_USE_DEFANT_SET(x)   (((x) << MAC_PCU_STA_ADDR_U16_USE_DEFANT_LSB) & MAC_PCU_STA_ADDR_U16_USE_DEFANT_MASK)
-#define MAC_PCU_STA_ADDR_U16_PCF_MSB             20
-#define MAC_PCU_STA_ADDR_U16_PCF_LSB             20
-#define MAC_PCU_STA_ADDR_U16_PCF_MASK            0x00100000
-#define MAC_PCU_STA_ADDR_U16_PCF_GET(x)          (((x) & MAC_PCU_STA_ADDR_U16_PCF_MASK) >> MAC_PCU_STA_ADDR_U16_PCF_LSB)
-#define MAC_PCU_STA_ADDR_U16_PCF_SET(x)          (((x) << MAC_PCU_STA_ADDR_U16_PCF_LSB) & MAC_PCU_STA_ADDR_U16_PCF_MASK)
-#define MAC_PCU_STA_ADDR_U16_KEYSRCH_DIS_MSB     19
-#define MAC_PCU_STA_ADDR_U16_KEYSRCH_DIS_LSB     19
-#define MAC_PCU_STA_ADDR_U16_KEYSRCH_DIS_MASK    0x00080000
-#define MAC_PCU_STA_ADDR_U16_KEYSRCH_DIS_GET(x)  (((x) & MAC_PCU_STA_ADDR_U16_KEYSRCH_DIS_MASK) >> MAC_PCU_STA_ADDR_U16_KEYSRCH_DIS_LSB)
-#define MAC_PCU_STA_ADDR_U16_KEYSRCH_DIS_SET(x)  (((x) << MAC_PCU_STA_ADDR_U16_KEYSRCH_DIS_LSB) & MAC_PCU_STA_ADDR_U16_KEYSRCH_DIS_MASK)
-#define MAC_PCU_STA_ADDR_U16_PW_SAVE_MSB         18
-#define MAC_PCU_STA_ADDR_U16_PW_SAVE_LSB         18
-#define MAC_PCU_STA_ADDR_U16_PW_SAVE_MASK        0x00040000
-#define MAC_PCU_STA_ADDR_U16_PW_SAVE_GET(x)      (((x) & MAC_PCU_STA_ADDR_U16_PW_SAVE_MASK) >> MAC_PCU_STA_ADDR_U16_PW_SAVE_LSB)
-#define MAC_PCU_STA_ADDR_U16_PW_SAVE_SET(x)      (((x) << MAC_PCU_STA_ADDR_U16_PW_SAVE_LSB) & MAC_PCU_STA_ADDR_U16_PW_SAVE_MASK)
-#define MAC_PCU_STA_ADDR_U16_ADHOC_MSB           17
-#define MAC_PCU_STA_ADDR_U16_ADHOC_LSB           17
-#define MAC_PCU_STA_ADDR_U16_ADHOC_MASK          0x00020000
-#define MAC_PCU_STA_ADDR_U16_ADHOC_GET(x)        (((x) & MAC_PCU_STA_ADDR_U16_ADHOC_MASK) >> MAC_PCU_STA_ADDR_U16_ADHOC_LSB)
-#define MAC_PCU_STA_ADDR_U16_ADHOC_SET(x)        (((x) << MAC_PCU_STA_ADDR_U16_ADHOC_LSB) & MAC_PCU_STA_ADDR_U16_ADHOC_MASK)
-#define MAC_PCU_STA_ADDR_U16_STA_AP_MSB          16
-#define MAC_PCU_STA_ADDR_U16_STA_AP_LSB          16
-#define MAC_PCU_STA_ADDR_U16_STA_AP_MASK         0x00010000
-#define MAC_PCU_STA_ADDR_U16_STA_AP_GET(x)       (((x) & MAC_PCU_STA_ADDR_U16_STA_AP_MASK) >> MAC_PCU_STA_ADDR_U16_STA_AP_LSB)
-#define MAC_PCU_STA_ADDR_U16_STA_AP_SET(x)       (((x) << MAC_PCU_STA_ADDR_U16_STA_AP_LSB) & MAC_PCU_STA_ADDR_U16_STA_AP_MASK)
-#define MAC_PCU_STA_ADDR_U16_ADDR_47_32_MSB      15
-#define MAC_PCU_STA_ADDR_U16_ADDR_47_32_LSB      0
-#define MAC_PCU_STA_ADDR_U16_ADDR_47_32_MASK     0x0000ffff
-#define MAC_PCU_STA_ADDR_U16_ADDR_47_32_GET(x)   (((x) & MAC_PCU_STA_ADDR_U16_ADDR_47_32_MASK) >> MAC_PCU_STA_ADDR_U16_ADDR_47_32_LSB)
-#define MAC_PCU_STA_ADDR_U16_ADDR_47_32_SET(x)   (((x) << MAC_PCU_STA_ADDR_U16_ADDR_47_32_LSB) & MAC_PCU_STA_ADDR_U16_ADDR_47_32_MASK)
-
-#define MAC_PCU_BSSID_L32_ADDRESS                0x00008008
-#define MAC_PCU_BSSID_L32_OFFSET                 0x00000008
-#define MAC_PCU_BSSID_L32_ADDR_MSB               31
-#define MAC_PCU_BSSID_L32_ADDR_LSB               0
-#define MAC_PCU_BSSID_L32_ADDR_MASK              0xffffffff
-#define MAC_PCU_BSSID_L32_ADDR_GET(x)            (((x) & MAC_PCU_BSSID_L32_ADDR_MASK) >> MAC_PCU_BSSID_L32_ADDR_LSB)
-#define MAC_PCU_BSSID_L32_ADDR_SET(x)            (((x) << MAC_PCU_BSSID_L32_ADDR_LSB) & MAC_PCU_BSSID_L32_ADDR_MASK)
-
-#define MAC_PCU_BSSID_U16_ADDRESS                0x0000800c
-#define MAC_PCU_BSSID_U16_OFFSET                 0x0000000c
-#define MAC_PCU_BSSID_U16_AID_MSB                26
-#define MAC_PCU_BSSID_U16_AID_LSB                16
-#define MAC_PCU_BSSID_U16_AID_MASK               0x07ff0000
-#define MAC_PCU_BSSID_U16_AID_GET(x)             (((x) & MAC_PCU_BSSID_U16_AID_MASK) >> MAC_PCU_BSSID_U16_AID_LSB)
-#define MAC_PCU_BSSID_U16_AID_SET(x)             (((x) << MAC_PCU_BSSID_U16_AID_LSB) & MAC_PCU_BSSID_U16_AID_MASK)
-#define MAC_PCU_BSSID_U16_ADDR_MSB               15
-#define MAC_PCU_BSSID_U16_ADDR_LSB               0
-#define MAC_PCU_BSSID_U16_ADDR_MASK              0x0000ffff
-#define MAC_PCU_BSSID_U16_ADDR_GET(x)            (((x) & MAC_PCU_BSSID_U16_ADDR_MASK) >> MAC_PCU_BSSID_U16_ADDR_LSB)
-#define MAC_PCU_BSSID_U16_ADDR_SET(x)            (((x) << MAC_PCU_BSSID_U16_ADDR_LSB) & MAC_PCU_BSSID_U16_ADDR_MASK)
-
-#define MAC_PCU_BCN_RSSI_AVE_ADDRESS             0x00008010
-#define MAC_PCU_BCN_RSSI_AVE_OFFSET              0x00000010
-#define MAC_PCU_BCN_RSSI_AVE_VALUE_MSB           11
-#define MAC_PCU_BCN_RSSI_AVE_VALUE_LSB           0
-#define MAC_PCU_BCN_RSSI_AVE_VALUE_MASK          0x00000fff
-#define MAC_PCU_BCN_RSSI_AVE_VALUE_GET(x)        (((x) & MAC_PCU_BCN_RSSI_AVE_VALUE_MASK) >> MAC_PCU_BCN_RSSI_AVE_VALUE_LSB)
-#define MAC_PCU_BCN_RSSI_AVE_VALUE_SET(x)        (((x) << MAC_PCU_BCN_RSSI_AVE_VALUE_LSB) & MAC_PCU_BCN_RSSI_AVE_VALUE_MASK)
-
-#define MAC_PCU_ACK_CTS_TIMEOUT_ADDRESS          0x00008014
-#define MAC_PCU_ACK_CTS_TIMEOUT_OFFSET           0x00000014
-#define MAC_PCU_ACK_CTS_TIMEOUT_CTS_TIMEOUT_MSB  29
-#define MAC_PCU_ACK_CTS_TIMEOUT_CTS_TIMEOUT_LSB  16
-#define MAC_PCU_ACK_CTS_TIMEOUT_CTS_TIMEOUT_MASK 0x3fff0000
-#define MAC_PCU_ACK_CTS_TIMEOUT_CTS_TIMEOUT_GET(x) (((x) & MAC_PCU_ACK_CTS_TIMEOUT_CTS_TIMEOUT_MASK) >> MAC_PCU_ACK_CTS_TIMEOUT_CTS_TIMEOUT_LSB)
-#define MAC_PCU_ACK_CTS_TIMEOUT_CTS_TIMEOUT_SET(x) (((x) << MAC_PCU_ACK_CTS_TIMEOUT_CTS_TIMEOUT_LSB) & MAC_PCU_ACK_CTS_TIMEOUT_CTS_TIMEOUT_MASK)
-#define MAC_PCU_ACK_CTS_TIMEOUT_ACK_TIMEOUT_MSB  13
-#define MAC_PCU_ACK_CTS_TIMEOUT_ACK_TIMEOUT_LSB  0
-#define MAC_PCU_ACK_CTS_TIMEOUT_ACK_TIMEOUT_MASK 0x00003fff
-#define MAC_PCU_ACK_CTS_TIMEOUT_ACK_TIMEOUT_GET(x) (((x) & MAC_PCU_ACK_CTS_TIMEOUT_ACK_TIMEOUT_MASK) >> MAC_PCU_ACK_CTS_TIMEOUT_ACK_TIMEOUT_LSB)
-#define MAC_PCU_ACK_CTS_TIMEOUT_ACK_TIMEOUT_SET(x) (((x) << MAC_PCU_ACK_CTS_TIMEOUT_ACK_TIMEOUT_LSB) & MAC_PCU_ACK_CTS_TIMEOUT_ACK_TIMEOUT_MASK)
-
-#define MAC_PCU_BCN_RSSI_CTL_ADDRESS             0x00008018
-#define MAC_PCU_BCN_RSSI_CTL_OFFSET              0x00000018
-#define MAC_PCU_BCN_RSSI_CTL_RESET_MSB           29
-#define MAC_PCU_BCN_RSSI_CTL_RESET_LSB           29
-#define MAC_PCU_BCN_RSSI_CTL_RESET_MASK          0x20000000
-#define MAC_PCU_BCN_RSSI_CTL_RESET_GET(x)        (((x) & MAC_PCU_BCN_RSSI_CTL_RESET_MASK) >> MAC_PCU_BCN_RSSI_CTL_RESET_LSB)
-#define MAC_PCU_BCN_RSSI_CTL_RESET_SET(x)        (((x) << MAC_PCU_BCN_RSSI_CTL_RESET_LSB) & MAC_PCU_BCN_RSSI_CTL_RESET_MASK)
-#define MAC_PCU_BCN_RSSI_CTL_WEIGHT_MSB          28
-#define MAC_PCU_BCN_RSSI_CTL_WEIGHT_LSB          24
-#define MAC_PCU_BCN_RSSI_CTL_WEIGHT_MASK         0x1f000000
-#define MAC_PCU_BCN_RSSI_CTL_WEIGHT_GET(x)       (((x) & MAC_PCU_BCN_RSSI_CTL_WEIGHT_MASK) >> MAC_PCU_BCN_RSSI_CTL_WEIGHT_LSB)
-#define MAC_PCU_BCN_RSSI_CTL_WEIGHT_SET(x)       (((x) << MAC_PCU_BCN_RSSI_CTL_WEIGHT_LSB) & MAC_PCU_BCN_RSSI_CTL_WEIGHT_MASK)
-#define MAC_PCU_BCN_RSSI_CTL_RSSI_HIGH_THRESH_MSB 23
-#define MAC_PCU_BCN_RSSI_CTL_RSSI_HIGH_THRESH_LSB 16
-#define MAC_PCU_BCN_RSSI_CTL_RSSI_HIGH_THRESH_MASK 0x00ff0000
-#define MAC_PCU_BCN_RSSI_CTL_RSSI_HIGH_THRESH_GET(x) (((x) & MAC_PCU_BCN_RSSI_CTL_RSSI_HIGH_THRESH_MASK) >> MAC_PCU_BCN_RSSI_CTL_RSSI_HIGH_THRESH_LSB)
-#define MAC_PCU_BCN_RSSI_CTL_RSSI_HIGH_THRESH_SET(x) (((x) << MAC_PCU_BCN_RSSI_CTL_RSSI_HIGH_THRESH_LSB) & MAC_PCU_BCN_RSSI_CTL_RSSI_HIGH_THRESH_MASK)
-#define MAC_PCU_BCN_RSSI_CTL_MISS_THRESH_MSB     15
-#define MAC_PCU_BCN_RSSI_CTL_MISS_THRESH_LSB     8
-#define MAC_PCU_BCN_RSSI_CTL_MISS_THRESH_MASK    0x0000ff00
-#define MAC_PCU_BCN_RSSI_CTL_MISS_THRESH_GET(x)  (((x) & MAC_PCU_BCN_RSSI_CTL_MISS_THRESH_MASK) >> MAC_PCU_BCN_RSSI_CTL_MISS_THRESH_LSB)
-#define MAC_PCU_BCN_RSSI_CTL_MISS_THRESH_SET(x)  (((x) << MAC_PCU_BCN_RSSI_CTL_MISS_THRESH_LSB) & MAC_PCU_BCN_RSSI_CTL_MISS_THRESH_MASK)
-#define MAC_PCU_BCN_RSSI_CTL_RSSI_LOW_THRESH_MSB 7
-#define MAC_PCU_BCN_RSSI_CTL_RSSI_LOW_THRESH_LSB 0
-#define MAC_PCU_BCN_RSSI_CTL_RSSI_LOW_THRESH_MASK 0x000000ff
-#define MAC_PCU_BCN_RSSI_CTL_RSSI_LOW_THRESH_GET(x) (((x) & MAC_PCU_BCN_RSSI_CTL_RSSI_LOW_THRESH_MASK) >> MAC_PCU_BCN_RSSI_CTL_RSSI_LOW_THRESH_LSB)
-#define MAC_PCU_BCN_RSSI_CTL_RSSI_LOW_THRESH_SET(x) (((x) << MAC_PCU_BCN_RSSI_CTL_RSSI_LOW_THRESH_LSB) & MAC_PCU_BCN_RSSI_CTL_RSSI_LOW_THRESH_MASK)
-
-#define MAC_PCU_USEC_LATENCY_ADDRESS             0x0000801c
-#define MAC_PCU_USEC_LATENCY_OFFSET              0x0000001c
-#define MAC_PCU_USEC_LATENCY_RX_LATENCY_MSB      28
-#define MAC_PCU_USEC_LATENCY_RX_LATENCY_LSB      23
-#define MAC_PCU_USEC_LATENCY_RX_LATENCY_MASK     0x1f800000
-#define MAC_PCU_USEC_LATENCY_RX_LATENCY_GET(x)   (((x) & MAC_PCU_USEC_LATENCY_RX_LATENCY_MASK) >> MAC_PCU_USEC_LATENCY_RX_LATENCY_LSB)
-#define MAC_PCU_USEC_LATENCY_RX_LATENCY_SET(x)   (((x) << MAC_PCU_USEC_LATENCY_RX_LATENCY_LSB) & MAC_PCU_USEC_LATENCY_RX_LATENCY_MASK)
-#define MAC_PCU_USEC_LATENCY_TX_LATENCY_MSB      22
-#define MAC_PCU_USEC_LATENCY_TX_LATENCY_LSB      14
-#define MAC_PCU_USEC_LATENCY_TX_LATENCY_MASK     0x007fc000
-#define MAC_PCU_USEC_LATENCY_TX_LATENCY_GET(x)   (((x) & MAC_PCU_USEC_LATENCY_TX_LATENCY_MASK) >> MAC_PCU_USEC_LATENCY_TX_LATENCY_LSB)
-#define MAC_PCU_USEC_LATENCY_TX_LATENCY_SET(x)   (((x) << MAC_PCU_USEC_LATENCY_TX_LATENCY_LSB) & MAC_PCU_USEC_LATENCY_TX_LATENCY_MASK)
-#define MAC_PCU_USEC_LATENCY_USEC_MSB            7
-#define MAC_PCU_USEC_LATENCY_USEC_LSB            0
-#define MAC_PCU_USEC_LATENCY_USEC_MASK           0x000000ff
-#define MAC_PCU_USEC_LATENCY_USEC_GET(x)         (((x) & MAC_PCU_USEC_LATENCY_USEC_MASK) >> MAC_PCU_USEC_LATENCY_USEC_LSB)
-#define MAC_PCU_USEC_LATENCY_USEC_SET(x)         (((x) << MAC_PCU_USEC_LATENCY_USEC_LSB) & MAC_PCU_USEC_LATENCY_USEC_MASK)
-
-#define PCU_MAX_CFP_DUR_ADDRESS                  0x00008020
-#define PCU_MAX_CFP_DUR_OFFSET                   0x00000020
-#define PCU_MAX_CFP_DUR_VALUE_MSB                15
-#define PCU_MAX_CFP_DUR_VALUE_LSB                0
-#define PCU_MAX_CFP_DUR_VALUE_MASK               0x0000ffff
-#define PCU_MAX_CFP_DUR_VALUE_GET(x)             (((x) & PCU_MAX_CFP_DUR_VALUE_MASK) >> PCU_MAX_CFP_DUR_VALUE_LSB)
-#define PCU_MAX_CFP_DUR_VALUE_SET(x)             (((x) << PCU_MAX_CFP_DUR_VALUE_LSB) & PCU_MAX_CFP_DUR_VALUE_MASK)
-
-#define MAC_PCU_RX_FILTER_ADDRESS                0x00008024
-#define MAC_PCU_RX_FILTER_OFFSET                 0x00000024
-#define MAC_PCU_RX_FILTER_GENERIC_FILTER_MSB     25
-#define MAC_PCU_RX_FILTER_GENERIC_FILTER_LSB     24
-#define MAC_PCU_RX_FILTER_GENERIC_FILTER_MASK    0x03000000
-#define MAC_PCU_RX_FILTER_GENERIC_FILTER_GET(x)  (((x) & MAC_PCU_RX_FILTER_GENERIC_FILTER_MASK) >> MAC_PCU_RX_FILTER_GENERIC_FILTER_LSB)
-#define MAC_PCU_RX_FILTER_GENERIC_FILTER_SET(x)  (((x) << MAC_PCU_RX_FILTER_GENERIC_FILTER_LSB) & MAC_PCU_RX_FILTER_GENERIC_FILTER_MASK)
-#define MAC_PCU_RX_FILTER_GENERIC_FTYPE_MSB      23
-#define MAC_PCU_RX_FILTER_GENERIC_FTYPE_LSB      18
-#define MAC_PCU_RX_FILTER_GENERIC_FTYPE_MASK     0x00fc0000
-#define MAC_PCU_RX_FILTER_GENERIC_FTYPE_GET(x)   (((x) & MAC_PCU_RX_FILTER_GENERIC_FTYPE_MASK) >> MAC_PCU_RX_FILTER_GENERIC_FTYPE_LSB)
-#define MAC_PCU_RX_FILTER_GENERIC_FTYPE_SET(x)   (((x) << MAC_PCU_RX_FILTER_GENERIC_FTYPE_LSB) & MAC_PCU_RX_FILTER_GENERIC_FTYPE_MASK)
-#define MAC_PCU_RX_FILTER_FROM_TO_DS_MSB         17
-#define MAC_PCU_RX_FILTER_FROM_TO_DS_LSB         17
-#define MAC_PCU_RX_FILTER_FROM_TO_DS_MASK        0x00020000
-#define MAC_PCU_RX_FILTER_FROM_TO_DS_GET(x)      (((x) & MAC_PCU_RX_FILTER_FROM_TO_DS_MASK) >> MAC_PCU_RX_FILTER_FROM_TO_DS_LSB)
-#define MAC_PCU_RX_FILTER_FROM_TO_DS_SET(x)      (((x) << MAC_PCU_RX_FILTER_FROM_TO_DS_LSB) & MAC_PCU_RX_FILTER_FROM_TO_DS_MASK)
-#define MAC_PCU_RX_FILTER_RST_DLMTR_CNT_DISABLE_MSB 16
-#define MAC_PCU_RX_FILTER_RST_DLMTR_CNT_DISABLE_LSB 16
-#define MAC_PCU_RX_FILTER_RST_DLMTR_CNT_DISABLE_MASK 0x00010000
-#define MAC_PCU_RX_FILTER_RST_DLMTR_CNT_DISABLE_GET(x) (((x) & MAC_PCU_RX_FILTER_RST_DLMTR_CNT_DISABLE_MASK) >> MAC_PCU_RX_FILTER_RST_DLMTR_CNT_DISABLE_LSB)
-#define MAC_PCU_RX_FILTER_RST_DLMTR_CNT_DISABLE_SET(x) (((x) << MAC_PCU_RX_FILTER_RST_DLMTR_CNT_DISABLE_LSB) & MAC_PCU_RX_FILTER_RST_DLMTR_CNT_DISABLE_MASK)
-#define MAC_PCU_RX_FILTER_MCAST_BCAST_ALL_MSB    15
-#define MAC_PCU_RX_FILTER_MCAST_BCAST_ALL_LSB    15
-#define MAC_PCU_RX_FILTER_MCAST_BCAST_ALL_MASK   0x00008000
-#define MAC_PCU_RX_FILTER_MCAST_BCAST_ALL_GET(x) (((x) & MAC_PCU_RX_FILTER_MCAST_BCAST_ALL_MASK) >> MAC_PCU_RX_FILTER_MCAST_BCAST_ALL_LSB)
-#define MAC_PCU_RX_FILTER_MCAST_BCAST_ALL_SET(x) (((x) << MAC_PCU_RX_FILTER_MCAST_BCAST_ALL_LSB) & MAC_PCU_RX_FILTER_MCAST_BCAST_ALL_MASK)
-#define MAC_PCU_RX_FILTER_PS_POLL_MSB            14
-#define MAC_PCU_RX_FILTER_PS_POLL_LSB            14
-#define MAC_PCU_RX_FILTER_PS_POLL_MASK           0x00004000
-#define MAC_PCU_RX_FILTER_PS_POLL_GET(x)         (((x) & MAC_PCU_RX_FILTER_PS_POLL_MASK) >> MAC_PCU_RX_FILTER_PS_POLL_LSB)
-#define MAC_PCU_RX_FILTER_PS_POLL_SET(x)         (((x) << MAC_PCU_RX_FILTER_PS_POLL_LSB) & MAC_PCU_RX_FILTER_PS_POLL_MASK)
-#define MAC_PCU_RX_FILTER_ASSUME_RADAR_MSB       13
-#define MAC_PCU_RX_FILTER_ASSUME_RADAR_LSB       13
-#define MAC_PCU_RX_FILTER_ASSUME_RADAR_MASK      0x00002000
-#define MAC_PCU_RX_FILTER_ASSUME_RADAR_GET(x)    (((x) & MAC_PCU_RX_FILTER_ASSUME_RADAR_MASK) >> MAC_PCU_RX_FILTER_ASSUME_RADAR_LSB)
-#define MAC_PCU_RX_FILTER_ASSUME_RADAR_SET(x)    (((x) << MAC_PCU_RX_FILTER_ASSUME_RADAR_LSB) & MAC_PCU_RX_FILTER_ASSUME_RADAR_MASK)
-#define MAC_PCU_RX_FILTER_UNCOMPRESSED_BA_BAR_MSB 12
-#define MAC_PCU_RX_FILTER_UNCOMPRESSED_BA_BAR_LSB 12
-#define MAC_PCU_RX_FILTER_UNCOMPRESSED_BA_BAR_MASK 0x00001000
-#define MAC_PCU_RX_FILTER_UNCOMPRESSED_BA_BAR_GET(x) (((x) & MAC_PCU_RX_FILTER_UNCOMPRESSED_BA_BAR_MASK) >> MAC_PCU_RX_FILTER_UNCOMPRESSED_BA_BAR_LSB)
-#define MAC_PCU_RX_FILTER_UNCOMPRESSED_BA_BAR_SET(x) (((x) << MAC_PCU_RX_FILTER_UNCOMPRESSED_BA_BAR_LSB) & MAC_PCU_RX_FILTER_UNCOMPRESSED_BA_BAR_MASK)
-#define MAC_PCU_RX_FILTER_COMPRESSED_BA_MSB      11
-#define MAC_PCU_RX_FILTER_COMPRESSED_BA_LSB      11
-#define MAC_PCU_RX_FILTER_COMPRESSED_BA_MASK     0x00000800
-#define MAC_PCU_RX_FILTER_COMPRESSED_BA_GET(x)   (((x) & MAC_PCU_RX_FILTER_COMPRESSED_BA_MASK) >> MAC_PCU_RX_FILTER_COMPRESSED_BA_LSB)
-#define MAC_PCU_RX_FILTER_COMPRESSED_BA_SET(x)   (((x) << MAC_PCU_RX_FILTER_COMPRESSED_BA_LSB) & MAC_PCU_RX_FILTER_COMPRESSED_BA_MASK)
-#define MAC_PCU_RX_FILTER_COMPRESSED_BAR_MSB     10
-#define MAC_PCU_RX_FILTER_COMPRESSED_BAR_LSB     10
-#define MAC_PCU_RX_FILTER_COMPRESSED_BAR_MASK    0x00000400
-#define MAC_PCU_RX_FILTER_COMPRESSED_BAR_GET(x)  (((x) & MAC_PCU_RX_FILTER_COMPRESSED_BAR_MASK) >> MAC_PCU_RX_FILTER_COMPRESSED_BAR_LSB)
-#define MAC_PCU_RX_FILTER_COMPRESSED_BAR_SET(x)  (((x) << MAC_PCU_RX_FILTER_COMPRESSED_BAR_LSB) & MAC_PCU_RX_FILTER_COMPRESSED_BAR_MASK)
-#define MAC_PCU_RX_FILTER_MY_BEACON_MSB          9
-#define MAC_PCU_RX_FILTER_MY_BEACON_LSB          9
-#define MAC_PCU_RX_FILTER_MY_BEACON_MASK         0x00000200
-#define MAC_PCU_RX_FILTER_MY_BEACON_GET(x)       (((x) & MAC_PCU_RX_FILTER_MY_BEACON_MASK) >> MAC_PCU_RX_FILTER_MY_BEACON_LSB)
-#define MAC_PCU_RX_FILTER_MY_BEACON_SET(x)       (((x) << MAC_PCU_RX_FILTER_MY_BEACON_LSB) & MAC_PCU_RX_FILTER_MY_BEACON_MASK)
-#define MAC_PCU_RX_FILTER_SYNC_FRAME_MSB         8
-#define MAC_PCU_RX_FILTER_SYNC_FRAME_LSB         8
-#define MAC_PCU_RX_FILTER_SYNC_FRAME_MASK        0x00000100
-#define MAC_PCU_RX_FILTER_SYNC_FRAME_GET(x)      (((x) & MAC_PCU_RX_FILTER_SYNC_FRAME_MASK) >> MAC_PCU_RX_FILTER_SYNC_FRAME_LSB)
-#define MAC_PCU_RX_FILTER_SYNC_FRAME_SET(x)      (((x) << MAC_PCU_RX_FILTER_SYNC_FRAME_LSB) & MAC_PCU_RX_FILTER_SYNC_FRAME_MASK)
-#define MAC_PCU_RX_FILTER_PROBE_REQ_MSB          7
-#define MAC_PCU_RX_FILTER_PROBE_REQ_LSB          7
-#define MAC_PCU_RX_FILTER_PROBE_REQ_MASK         0x00000080
-#define MAC_PCU_RX_FILTER_PROBE_REQ_GET(x)       (((x) & MAC_PCU_RX_FILTER_PROBE_REQ_MASK) >> MAC_PCU_RX_FILTER_PROBE_REQ_LSB)
-#define MAC_PCU_RX_FILTER_PROBE_REQ_SET(x)       (((x) << MAC_PCU_RX_FILTER_PROBE_REQ_LSB) & MAC_PCU_RX_FILTER_PROBE_REQ_MASK)
-#define MAC_PCU_RX_FILTER_XR_POLL_MSB            6
-#define MAC_PCU_RX_FILTER_XR_POLL_LSB            6
-#define MAC_PCU_RX_FILTER_XR_POLL_MASK           0x00000040
-#define MAC_PCU_RX_FILTER_XR_POLL_GET(x)         (((x) & MAC_PCU_RX_FILTER_XR_POLL_MASK) >> MAC_PCU_RX_FILTER_XR_POLL_LSB)
-#define MAC_PCU_RX_FILTER_XR_POLL_SET(x)         (((x) << MAC_PCU_RX_FILTER_XR_POLL_LSB) & MAC_PCU_RX_FILTER_XR_POLL_MASK)
-#define MAC_PCU_RX_FILTER_PROMISCUOUS_MSB        5
-#define MAC_PCU_RX_FILTER_PROMISCUOUS_LSB        5
-#define MAC_PCU_RX_FILTER_PROMISCUOUS_MASK       0x00000020
-#define MAC_PCU_RX_FILTER_PROMISCUOUS_GET(x)     (((x) & MAC_PCU_RX_FILTER_PROMISCUOUS_MASK) >> MAC_PCU_RX_FILTER_PROMISCUOUS_LSB)
-#define MAC_PCU_RX_FILTER_PROMISCUOUS_SET(x)     (((x) << MAC_PCU_RX_FILTER_PROMISCUOUS_LSB) & MAC_PCU_RX_FILTER_PROMISCUOUS_MASK)
-#define MAC_PCU_RX_FILTER_BEACON_MSB             4
-#define MAC_PCU_RX_FILTER_BEACON_LSB             4
-#define MAC_PCU_RX_FILTER_BEACON_MASK            0x00000010
-#define MAC_PCU_RX_FILTER_BEACON_GET(x)          (((x) & MAC_PCU_RX_FILTER_BEACON_MASK) >> MAC_PCU_RX_FILTER_BEACON_LSB)
-#define MAC_PCU_RX_FILTER_BEACON_SET(x)          (((x) << MAC_PCU_RX_FILTER_BEACON_LSB) & MAC_PCU_RX_FILTER_BEACON_MASK)
-#define MAC_PCU_RX_FILTER_CONTROL_MSB            3
-#define MAC_PCU_RX_FILTER_CONTROL_LSB            3
-#define MAC_PCU_RX_FILTER_CONTROL_MASK           0x00000008
-#define MAC_PCU_RX_FILTER_CONTROL_GET(x)         (((x) & MAC_PCU_RX_FILTER_CONTROL_MASK) >> MAC_PCU_RX_FILTER_CONTROL_LSB)
-#define MAC_PCU_RX_FILTER_CONTROL_SET(x)         (((x) << MAC_PCU_RX_FILTER_CONTROL_LSB) & MAC_PCU_RX_FILTER_CONTROL_MASK)
-#define MAC_PCU_RX_FILTER_BROADCAST_MSB          2
-#define MAC_PCU_RX_FILTER_BROADCAST_LSB          2
-#define MAC_PCU_RX_FILTER_BROADCAST_MASK         0x00000004
-#define MAC_PCU_RX_FILTER_BROADCAST_GET(x)       (((x) & MAC_PCU_RX_FILTER_BROADCAST_MASK) >> MAC_PCU_RX_FILTER_BROADCAST_LSB)
-#define MAC_PCU_RX_FILTER_BROADCAST_SET(x)       (((x) << MAC_PCU_RX_FILTER_BROADCAST_LSB) & MAC_PCU_RX_FILTER_BROADCAST_MASK)
-#define MAC_PCU_RX_FILTER_MULTICAST_MSB          1
-#define MAC_PCU_RX_FILTER_MULTICAST_LSB          1
-#define MAC_PCU_RX_FILTER_MULTICAST_MASK         0x00000002
-#define MAC_PCU_RX_FILTER_MULTICAST_GET(x)       (((x) & MAC_PCU_RX_FILTER_MULTICAST_MASK) >> MAC_PCU_RX_FILTER_MULTICAST_LSB)
-#define MAC_PCU_RX_FILTER_MULTICAST_SET(x)       (((x) << MAC_PCU_RX_FILTER_MULTICAST_LSB) & MAC_PCU_RX_FILTER_MULTICAST_MASK)
-#define MAC_PCU_RX_FILTER_UNICAST_MSB            0
-#define MAC_PCU_RX_FILTER_UNICAST_LSB            0
-#define MAC_PCU_RX_FILTER_UNICAST_MASK           0x00000001
-#define MAC_PCU_RX_FILTER_UNICAST_GET(x)         (((x) & MAC_PCU_RX_FILTER_UNICAST_MASK) >> MAC_PCU_RX_FILTER_UNICAST_LSB)
-#define MAC_PCU_RX_FILTER_UNICAST_SET(x)         (((x) << MAC_PCU_RX_FILTER_UNICAST_LSB) & MAC_PCU_RX_FILTER_UNICAST_MASK)
-
-#define MAC_PCU_MCAST_FILTER_L32_ADDRESS         0x00008028
-#define MAC_PCU_MCAST_FILTER_L32_OFFSET          0x00000028
-#define MAC_PCU_MCAST_FILTER_L32_VALUE_MSB       31
-#define MAC_PCU_MCAST_FILTER_L32_VALUE_LSB       0
-#define MAC_PCU_MCAST_FILTER_L32_VALUE_MASK      0xffffffff
-#define MAC_PCU_MCAST_FILTER_L32_VALUE_GET(x)    (((x) & MAC_PCU_MCAST_FILTER_L32_VALUE_MASK) >> MAC_PCU_MCAST_FILTER_L32_VALUE_LSB)
-#define MAC_PCU_MCAST_FILTER_L32_VALUE_SET(x)    (((x) << MAC_PCU_MCAST_FILTER_L32_VALUE_LSB) & MAC_PCU_MCAST_FILTER_L32_VALUE_MASK)
-
-#define MAC_PCU_MCAST_FILTER_U32_ADDRESS         0x0000802c
-#define MAC_PCU_MCAST_FILTER_U32_OFFSET          0x0000002c
-#define MAC_PCU_MCAST_FILTER_U32_VALUE_MSB       31
-#define MAC_PCU_MCAST_FILTER_U32_VALUE_LSB       0
-#define MAC_PCU_MCAST_FILTER_U32_VALUE_MASK      0xffffffff
-#define MAC_PCU_MCAST_FILTER_U32_VALUE_GET(x)    (((x) & MAC_PCU_MCAST_FILTER_U32_VALUE_MASK) >> MAC_PCU_MCAST_FILTER_U32_VALUE_LSB)
-#define MAC_PCU_MCAST_FILTER_U32_VALUE_SET(x)    (((x) << MAC_PCU_MCAST_FILTER_U32_VALUE_LSB) & MAC_PCU_MCAST_FILTER_U32_VALUE_MASK)
-
-#define MAC_PCU_DIAG_SW_ADDRESS                  0x00008030
-#define MAC_PCU_DIAG_SW_OFFSET                   0x00000030
-#define MAC_PCU_DIAG_SW_DEBUG_MODE_MSB           31
-#define MAC_PCU_DIAG_SW_DEBUG_MODE_LSB           30
-#define MAC_PCU_DIAG_SW_DEBUG_MODE_MASK          0xc0000000
-#define MAC_PCU_DIAG_SW_DEBUG_MODE_GET(x)        (((x) & MAC_PCU_DIAG_SW_DEBUG_MODE_MASK) >> MAC_PCU_DIAG_SW_DEBUG_MODE_LSB)
-#define MAC_PCU_DIAG_SW_DEBUG_MODE_SET(x)        (((x) << MAC_PCU_DIAG_SW_DEBUG_MODE_LSB) & MAC_PCU_DIAG_SW_DEBUG_MODE_MASK)
-#define MAC_PCU_DIAG_SW_RX_CLEAR_EXT_LOW_MSB     29
-#define MAC_PCU_DIAG_SW_RX_CLEAR_EXT_LOW_LSB     29
-#define MAC_PCU_DIAG_SW_RX_CLEAR_EXT_LOW_MASK    0x20000000
-#define MAC_PCU_DIAG_SW_RX_CLEAR_EXT_LOW_GET(x)  (((x) & MAC_PCU_DIAG_SW_RX_CLEAR_EXT_LOW_MASK) >> MAC_PCU_DIAG_SW_RX_CLEAR_EXT_LOW_LSB)
-#define MAC_PCU_DIAG_SW_RX_CLEAR_EXT_LOW_SET(x)  (((x) << MAC_PCU_DIAG_SW_RX_CLEAR_EXT_LOW_LSB) & MAC_PCU_DIAG_SW_RX_CLEAR_EXT_LOW_MASK)
-#define MAC_PCU_DIAG_SW_RX_CLEAR_CTL_LOW_MSB     28
-#define MAC_PCU_DIAG_SW_RX_CLEAR_CTL_LOW_LSB     28
-#define MAC_PCU_DIAG_SW_RX_CLEAR_CTL_LOW_MASK    0x10000000
-#define MAC_PCU_DIAG_SW_RX_CLEAR_CTL_LOW_GET(x)  (((x) & MAC_PCU_DIAG_SW_RX_CLEAR_CTL_LOW_MASK) >> MAC_PCU_DIAG_SW_RX_CLEAR_CTL_LOW_LSB)
-#define MAC_PCU_DIAG_SW_RX_CLEAR_CTL_LOW_SET(x)  (((x) << MAC_PCU_DIAG_SW_RX_CLEAR_CTL_LOW_LSB) & MAC_PCU_DIAG_SW_RX_CLEAR_CTL_LOW_MASK)
-#define MAC_PCU_DIAG_SW_OBS_SEL_2_MSB            27
-#define MAC_PCU_DIAG_SW_OBS_SEL_2_LSB            27
-#define MAC_PCU_DIAG_SW_OBS_SEL_2_MASK           0x08000000
-#define MAC_PCU_DIAG_SW_OBS_SEL_2_GET(x)         (((x) & MAC_PCU_DIAG_SW_OBS_SEL_2_MASK) >> MAC_PCU_DIAG_SW_OBS_SEL_2_LSB)
-#define MAC_PCU_DIAG_SW_OBS_SEL_2_SET(x)         (((x) << MAC_PCU_DIAG_SW_OBS_SEL_2_LSB) & MAC_PCU_DIAG_SW_OBS_SEL_2_MASK)
-#define MAC_PCU_DIAG_SW_SATURATE_CYCLE_CNT_MSB   26
-#define MAC_PCU_DIAG_SW_SATURATE_CYCLE_CNT_LSB   26
-#define MAC_PCU_DIAG_SW_SATURATE_CYCLE_CNT_MASK  0x04000000
-#define MAC_PCU_DIAG_SW_SATURATE_CYCLE_CNT_GET(x) (((x) & MAC_PCU_DIAG_SW_SATURATE_CYCLE_CNT_MASK) >> MAC_PCU_DIAG_SW_SATURATE_CYCLE_CNT_LSB)
-#define MAC_PCU_DIAG_SW_SATURATE_CYCLE_CNT_SET(x) (((x) << MAC_PCU_DIAG_SW_SATURATE_CYCLE_CNT_LSB) & MAC_PCU_DIAG_SW_SATURATE_CYCLE_CNT_MASK)
-#define MAC_PCU_DIAG_SW_FORCE_RX_ABORT_MSB       25
-#define MAC_PCU_DIAG_SW_FORCE_RX_ABORT_LSB       25
-#define MAC_PCU_DIAG_SW_FORCE_RX_ABORT_MASK      0x02000000
-#define MAC_PCU_DIAG_SW_FORCE_RX_ABORT_GET(x)    (((x) & MAC_PCU_DIAG_SW_FORCE_RX_ABORT_MASK) >> MAC_PCU_DIAG_SW_FORCE_RX_ABORT_LSB)
-#define MAC_PCU_DIAG_SW_FORCE_RX_ABORT_SET(x)    (((x) << MAC_PCU_DIAG_SW_FORCE_RX_ABORT_LSB) & MAC_PCU_DIAG_SW_FORCE_RX_ABORT_MASK)
-#define MAC_PCU_DIAG_SW_DUAL_CHAIN_CHAN_INFO_MSB 24
-#define MAC_PCU_DIAG_SW_DUAL_CHAIN_CHAN_INFO_LSB 24
-#define MAC_PCU_DIAG_SW_DUAL_CHAIN_CHAN_INFO_MASK 0x01000000
-#define MAC_PCU_DIAG_SW_DUAL_CHAIN_CHAN_INFO_GET(x) (((x) & MAC_PCU_DIAG_SW_DUAL_CHAIN_CHAN_INFO_MASK) >> MAC_PCU_DIAG_SW_DUAL_CHAIN_CHAN_INFO_LSB)
-#define MAC_PCU_DIAG_SW_DUAL_CHAIN_CHAN_INFO_SET(x) (((x) << MAC_PCU_DIAG_SW_DUAL_CHAIN_CHAN_INFO_LSB) & MAC_PCU_DIAG_SW_DUAL_CHAIN_CHAN_INFO_MASK)
-#define MAC_PCU_DIAG_SW_PHYERR_ENABLE_EIFS_CTL_MSB 23
-#define MAC_PCU_DIAG_SW_PHYERR_ENABLE_EIFS_CTL_LSB 23
-#define MAC_PCU_DIAG_SW_PHYERR_ENABLE_EIFS_CTL_MASK 0x00800000
-#define MAC_PCU_DIAG_SW_PHYERR_ENABLE_EIFS_CTL_GET(x) (((x) & MAC_PCU_DIAG_SW_PHYERR_ENABLE_EIFS_CTL_MASK) >> MAC_PCU_DIAG_SW_PHYERR_ENABLE_EIFS_CTL_LSB)
-#define MAC_PCU_DIAG_SW_PHYERR_ENABLE_EIFS_CTL_SET(x) (((x) << MAC_PCU_DIAG_SW_PHYERR_ENABLE_EIFS_CTL_LSB) & MAC_PCU_DIAG_SW_PHYERR_ENABLE_EIFS_CTL_MASK)
-#define MAC_PCU_DIAG_SW_CHAN_IDLE_HIGH_MSB       22
-#define MAC_PCU_DIAG_SW_CHAN_IDLE_HIGH_LSB       22
-#define MAC_PCU_DIAG_SW_CHAN_IDLE_HIGH_MASK      0x00400000
-#define MAC_PCU_DIAG_SW_CHAN_IDLE_HIGH_GET(x)    (((x) & MAC_PCU_DIAG_SW_CHAN_IDLE_HIGH_MASK) >> MAC_PCU_DIAG_SW_CHAN_IDLE_HIGH_LSB)
-#define MAC_PCU_DIAG_SW_CHAN_IDLE_HIGH_SET(x)    (((x) << MAC_PCU_DIAG_SW_CHAN_IDLE_HIGH_LSB) & MAC_PCU_DIAG_SW_CHAN_IDLE_HIGH_MASK)
-#define MAC_PCU_DIAG_SW_IGNORE_NAV_MSB           21
-#define MAC_PCU_DIAG_SW_IGNORE_NAV_LSB           21
-#define MAC_PCU_DIAG_SW_IGNORE_NAV_MASK          0x00200000
-#define MAC_PCU_DIAG_SW_IGNORE_NAV_GET(x)        (((x) & MAC_PCU_DIAG_SW_IGNORE_NAV_MASK) >> MAC_PCU_DIAG_SW_IGNORE_NAV_LSB)
-#define MAC_PCU_DIAG_SW_IGNORE_NAV_SET(x)        (((x) << MAC_PCU_DIAG_SW_IGNORE_NAV_LSB) & MAC_PCU_DIAG_SW_IGNORE_NAV_MASK)
-#define MAC_PCU_DIAG_SW_RX_CLEAR_HIGH_MSB        20
-#define MAC_PCU_DIAG_SW_RX_CLEAR_HIGH_LSB        20
-#define MAC_PCU_DIAG_SW_RX_CLEAR_HIGH_MASK       0x00100000
-#define MAC_PCU_DIAG_SW_RX_CLEAR_HIGH_GET(x)     (((x) & MAC_PCU_DIAG_SW_RX_CLEAR_HIGH_MASK) >> MAC_PCU_DIAG_SW_RX_CLEAR_HIGH_LSB)
-#define MAC_PCU_DIAG_SW_RX_CLEAR_HIGH_SET(x)     (((x) << MAC_PCU_DIAG_SW_RX_CLEAR_HIGH_LSB) & MAC_PCU_DIAG_SW_RX_CLEAR_HIGH_MASK)
-#define MAC_PCU_DIAG_SW_OBS_SEL_1_0_MSB          19
-#define MAC_PCU_DIAG_SW_OBS_SEL_1_0_LSB          18
-#define MAC_PCU_DIAG_SW_OBS_SEL_1_0_MASK         0x000c0000
-#define MAC_PCU_DIAG_SW_OBS_SEL_1_0_GET(x)       (((x) & MAC_PCU_DIAG_SW_OBS_SEL_1_0_MASK) >> MAC_PCU_DIAG_SW_OBS_SEL_1_0_LSB)
-#define MAC_PCU_DIAG_SW_OBS_SEL_1_0_SET(x)       (((x) << MAC_PCU_DIAG_SW_OBS_SEL_1_0_LSB) & MAC_PCU_DIAG_SW_OBS_SEL_1_0_MASK)
-#define MAC_PCU_DIAG_SW_ACCEPT_NON_V0_MSB        17
-#define MAC_PCU_DIAG_SW_ACCEPT_NON_V0_LSB        17
-#define MAC_PCU_DIAG_SW_ACCEPT_NON_V0_MASK       0x00020000
-#define MAC_PCU_DIAG_SW_ACCEPT_NON_V0_GET(x)     (((x) & MAC_PCU_DIAG_SW_ACCEPT_NON_V0_MASK) >> MAC_PCU_DIAG_SW_ACCEPT_NON_V0_LSB)
-#define MAC_PCU_DIAG_SW_ACCEPT_NON_V0_SET(x)     (((x) << MAC_PCU_DIAG_SW_ACCEPT_NON_V0_LSB) & MAC_PCU_DIAG_SW_ACCEPT_NON_V0_MASK)
-#define MAC_PCU_DIAG_SW_DUMP_CHAN_INFO_MSB       8
-#define MAC_PCU_DIAG_SW_DUMP_CHAN_INFO_LSB       8
-#define MAC_PCU_DIAG_SW_DUMP_CHAN_INFO_MASK      0x00000100
-#define MAC_PCU_DIAG_SW_DUMP_CHAN_INFO_GET(x)    (((x) & MAC_PCU_DIAG_SW_DUMP_CHAN_INFO_MASK) >> MAC_PCU_DIAG_SW_DUMP_CHAN_INFO_LSB)
-#define MAC_PCU_DIAG_SW_DUMP_CHAN_INFO_SET(x)    (((x) << MAC_PCU_DIAG_SW_DUMP_CHAN_INFO_LSB) & MAC_PCU_DIAG_SW_DUMP_CHAN_INFO_MASK)
-#define MAC_PCU_DIAG_SW_CORRUPT_FCS_MSB          7
-#define MAC_PCU_DIAG_SW_CORRUPT_FCS_LSB          7
-#define MAC_PCU_DIAG_SW_CORRUPT_FCS_MASK         0x00000080
-#define MAC_PCU_DIAG_SW_CORRUPT_FCS_GET(x)       (((x) & MAC_PCU_DIAG_SW_CORRUPT_FCS_MASK) >> MAC_PCU_DIAG_SW_CORRUPT_FCS_LSB)
-#define MAC_PCU_DIAG_SW_CORRUPT_FCS_SET(x)       (((x) << MAC_PCU_DIAG_SW_CORRUPT_FCS_LSB) & MAC_PCU_DIAG_SW_CORRUPT_FCS_MASK)
-#define MAC_PCU_DIAG_SW_LOOP_BACK_MSB            6
-#define MAC_PCU_DIAG_SW_LOOP_BACK_LSB            6
-#define MAC_PCU_DIAG_SW_LOOP_BACK_MASK           0x00000040
-#define MAC_PCU_DIAG_SW_LOOP_BACK_GET(x)         (((x) & MAC_PCU_DIAG_SW_LOOP_BACK_MASK) >> MAC_PCU_DIAG_SW_LOOP_BACK_LSB)
-#define MAC_PCU_DIAG_SW_LOOP_BACK_SET(x)         (((x) << MAC_PCU_DIAG_SW_LOOP_BACK_LSB) & MAC_PCU_DIAG_SW_LOOP_BACK_MASK)
-#define MAC_PCU_DIAG_SW_HALT_RX_MSB              5
-#define MAC_PCU_DIAG_SW_HALT_RX_LSB              5
-#define MAC_PCU_DIAG_SW_HALT_RX_MASK             0x00000020
-#define MAC_PCU_DIAG_SW_HALT_RX_GET(x)           (((x) & MAC_PCU_DIAG_SW_HALT_RX_MASK) >> MAC_PCU_DIAG_SW_HALT_RX_LSB)
-#define MAC_PCU_DIAG_SW_HALT_RX_SET(x)           (((x) << MAC_PCU_DIAG_SW_HALT_RX_LSB) & MAC_PCU_DIAG_SW_HALT_RX_MASK)
-#define MAC_PCU_DIAG_SW_NO_DECRYPT_MSB           4
-#define MAC_PCU_DIAG_SW_NO_DECRYPT_LSB           4
-#define MAC_PCU_DIAG_SW_NO_DECRYPT_MASK          0x00000010
-#define MAC_PCU_DIAG_SW_NO_DECRYPT_GET(x)        (((x) & MAC_PCU_DIAG_SW_NO_DECRYPT_MASK) >> MAC_PCU_DIAG_SW_NO_DECRYPT_LSB)
-#define MAC_PCU_DIAG_SW_NO_DECRYPT_SET(x)        (((x) << MAC_PCU_DIAG_SW_NO_DECRYPT_LSB) & MAC_PCU_DIAG_SW_NO_DECRYPT_MASK)
-#define MAC_PCU_DIAG_SW_NO_ENCRYPT_MSB           3
-#define MAC_PCU_DIAG_SW_NO_ENCRYPT_LSB           3
-#define MAC_PCU_DIAG_SW_NO_ENCRYPT_MASK          0x00000008
-#define MAC_PCU_DIAG_SW_NO_ENCRYPT_GET(x)        (((x) & MAC_PCU_DIAG_SW_NO_ENCRYPT_MASK) >> MAC_PCU_DIAG_SW_NO_ENCRYPT_LSB)
-#define MAC_PCU_DIAG_SW_NO_ENCRYPT_SET(x)        (((x) << MAC_PCU_DIAG_SW_NO_ENCRYPT_LSB) & MAC_PCU_DIAG_SW_NO_ENCRYPT_MASK)
-#define MAC_PCU_DIAG_SW_NO_CTS_MSB               2
-#define MAC_PCU_DIAG_SW_NO_CTS_LSB               2
-#define MAC_PCU_DIAG_SW_NO_CTS_MASK              0x00000004
-#define MAC_PCU_DIAG_SW_NO_CTS_GET(x)            (((x) & MAC_PCU_DIAG_SW_NO_CTS_MASK) >> MAC_PCU_DIAG_SW_NO_CTS_LSB)
-#define MAC_PCU_DIAG_SW_NO_CTS_SET(x)            (((x) << MAC_PCU_DIAG_SW_NO_CTS_LSB) & MAC_PCU_DIAG_SW_NO_CTS_MASK)
-#define MAC_PCU_DIAG_SW_NO_ACK_MSB               1
-#define MAC_PCU_DIAG_SW_NO_ACK_LSB               1
-#define MAC_PCU_DIAG_SW_NO_ACK_MASK              0x00000002
-#define MAC_PCU_DIAG_SW_NO_ACK_GET(x)            (((x) & MAC_PCU_DIAG_SW_NO_ACK_MASK) >> MAC_PCU_DIAG_SW_NO_ACK_LSB)
-#define MAC_PCU_DIAG_SW_NO_ACK_SET(x)            (((x) << MAC_PCU_DIAG_SW_NO_ACK_LSB) & MAC_PCU_DIAG_SW_NO_ACK_MASK)
-#define MAC_PCU_DIAG_SW_INVALID_KEY_NO_ACK_MSB   0
-#define MAC_PCU_DIAG_SW_INVALID_KEY_NO_ACK_LSB   0
-#define MAC_PCU_DIAG_SW_INVALID_KEY_NO_ACK_MASK  0x00000001
-#define MAC_PCU_DIAG_SW_INVALID_KEY_NO_ACK_GET(x) (((x) & MAC_PCU_DIAG_SW_INVALID_KEY_NO_ACK_MASK) >> MAC_PCU_DIAG_SW_INVALID_KEY_NO_ACK_LSB)
-#define MAC_PCU_DIAG_SW_INVALID_KEY_NO_ACK_SET(x) (((x) << MAC_PCU_DIAG_SW_INVALID_KEY_NO_ACK_LSB) & MAC_PCU_DIAG_SW_INVALID_KEY_NO_ACK_MASK)
-
-#define MAC_PCU_TST_ADDAC_ADDRESS                0x00008034
-#define MAC_PCU_TST_ADDAC_OFFSET                 0x00000034
-#define MAC_PCU_TST_ADDAC_TEST_ARM_MSB           20
-#define MAC_PCU_TST_ADDAC_TEST_ARM_LSB           20
-#define MAC_PCU_TST_ADDAC_TEST_ARM_MASK          0x00100000
-#define MAC_PCU_TST_ADDAC_TEST_ARM_GET(x)        (((x) & MAC_PCU_TST_ADDAC_TEST_ARM_MASK) >> MAC_PCU_TST_ADDAC_TEST_ARM_LSB)
-#define MAC_PCU_TST_ADDAC_TEST_ARM_SET(x)        (((x) << MAC_PCU_TST_ADDAC_TEST_ARM_LSB) & MAC_PCU_TST_ADDAC_TEST_ARM_MASK)
-#define MAC_PCU_TST_ADDAC_TEST_CAPTURE_MSB       19
-#define MAC_PCU_TST_ADDAC_TEST_CAPTURE_LSB       19
-#define MAC_PCU_TST_ADDAC_TEST_CAPTURE_MASK      0x00080000
-#define MAC_PCU_TST_ADDAC_TEST_CAPTURE_GET(x)    (((x) & MAC_PCU_TST_ADDAC_TEST_CAPTURE_MASK) >> MAC_PCU_TST_ADDAC_TEST_CAPTURE_LSB)
-#define MAC_PCU_TST_ADDAC_TEST_CAPTURE_SET(x)    (((x) << MAC_PCU_TST_ADDAC_TEST_CAPTURE_LSB) & MAC_PCU_TST_ADDAC_TEST_CAPTURE_MASK)
-#define MAC_PCU_TST_ADDAC_CONT_TEST_MSB          18
-#define MAC_PCU_TST_ADDAC_CONT_TEST_LSB          18
-#define MAC_PCU_TST_ADDAC_CONT_TEST_MASK         0x00040000
-#define MAC_PCU_TST_ADDAC_CONT_TEST_GET(x)       (((x) & MAC_PCU_TST_ADDAC_CONT_TEST_MASK) >> MAC_PCU_TST_ADDAC_CONT_TEST_LSB)
-#define MAC_PCU_TST_ADDAC_CONT_TEST_SET(x)       (((x) << MAC_PCU_TST_ADDAC_CONT_TEST_LSB) & MAC_PCU_TST_ADDAC_CONT_TEST_MASK)
-#define MAC_PCU_TST_ADDAC_TRIG_POLARITY_MSB      17
-#define MAC_PCU_TST_ADDAC_TRIG_POLARITY_LSB      17
-#define MAC_PCU_TST_ADDAC_TRIG_POLARITY_MASK     0x00020000
-#define MAC_PCU_TST_ADDAC_TRIG_POLARITY_GET(x)   (((x) & MAC_PCU_TST_ADDAC_TRIG_POLARITY_MASK) >> MAC_PCU_TST_ADDAC_TRIG_POLARITY_LSB)
-#define MAC_PCU_TST_ADDAC_TRIG_POLARITY_SET(x)   (((x) << MAC_PCU_TST_ADDAC_TRIG_POLARITY_LSB) & MAC_PCU_TST_ADDAC_TRIG_POLARITY_MASK)
-#define MAC_PCU_TST_ADDAC_TRIG_SEL_MSB           16
-#define MAC_PCU_TST_ADDAC_TRIG_SEL_LSB           16
-#define MAC_PCU_TST_ADDAC_TRIG_SEL_MASK          0x00010000
-#define MAC_PCU_TST_ADDAC_TRIG_SEL_GET(x)        (((x) & MAC_PCU_TST_ADDAC_TRIG_SEL_MASK) >> MAC_PCU_TST_ADDAC_TRIG_SEL_LSB)
-#define MAC_PCU_TST_ADDAC_TRIG_SEL_SET(x)        (((x) << MAC_PCU_TST_ADDAC_TRIG_SEL_LSB) & MAC_PCU_TST_ADDAC_TRIG_SEL_MASK)
-#define MAC_PCU_TST_ADDAC_UPPER_8B_MSB           14
-#define MAC_PCU_TST_ADDAC_UPPER_8B_LSB           14
-#define MAC_PCU_TST_ADDAC_UPPER_8B_MASK          0x00004000
-#define MAC_PCU_TST_ADDAC_UPPER_8B_GET(x)        (((x) & MAC_PCU_TST_ADDAC_UPPER_8B_MASK) >> MAC_PCU_TST_ADDAC_UPPER_8B_LSB)
-#define MAC_PCU_TST_ADDAC_UPPER_8B_SET(x)        (((x) << MAC_PCU_TST_ADDAC_UPPER_8B_LSB) & MAC_PCU_TST_ADDAC_UPPER_8B_MASK)
-#define MAC_PCU_TST_ADDAC_LOOP_LEN_MSB           13
-#define MAC_PCU_TST_ADDAC_LOOP_LEN_LSB           3
-#define MAC_PCU_TST_ADDAC_LOOP_LEN_MASK          0x00003ff8
-#define MAC_PCU_TST_ADDAC_LOOP_LEN_GET(x)        (((x) & MAC_PCU_TST_ADDAC_LOOP_LEN_MASK) >> MAC_PCU_TST_ADDAC_LOOP_LEN_LSB)
-#define MAC_PCU_TST_ADDAC_LOOP_LEN_SET(x)        (((x) << MAC_PCU_TST_ADDAC_LOOP_LEN_LSB) & MAC_PCU_TST_ADDAC_LOOP_LEN_MASK)
-#define MAC_PCU_TST_ADDAC_LOOP_MSB               2
-#define MAC_PCU_TST_ADDAC_LOOP_LSB               2
-#define MAC_PCU_TST_ADDAC_LOOP_MASK              0x00000004
-#define MAC_PCU_TST_ADDAC_LOOP_GET(x)            (((x) & MAC_PCU_TST_ADDAC_LOOP_MASK) >> MAC_PCU_TST_ADDAC_LOOP_LSB)
-#define MAC_PCU_TST_ADDAC_LOOP_SET(x)            (((x) << MAC_PCU_TST_ADDAC_LOOP_LSB) & MAC_PCU_TST_ADDAC_LOOP_MASK)
-#define MAC_PCU_TST_ADDAC_TESTMODE_MSB           1
-#define MAC_PCU_TST_ADDAC_TESTMODE_LSB           1
-#define MAC_PCU_TST_ADDAC_TESTMODE_MASK          0x00000002
-#define MAC_PCU_TST_ADDAC_TESTMODE_GET(x)        (((x) & MAC_PCU_TST_ADDAC_TESTMODE_MASK) >> MAC_PCU_TST_ADDAC_TESTMODE_LSB)
-#define MAC_PCU_TST_ADDAC_TESTMODE_SET(x)        (((x) << MAC_PCU_TST_ADDAC_TESTMODE_LSB) & MAC_PCU_TST_ADDAC_TESTMODE_MASK)
-#define MAC_PCU_TST_ADDAC_CONT_TX_MSB            0
-#define MAC_PCU_TST_ADDAC_CONT_TX_LSB            0
-#define MAC_PCU_TST_ADDAC_CONT_TX_MASK           0x00000001
-#define MAC_PCU_TST_ADDAC_CONT_TX_GET(x)         (((x) & MAC_PCU_TST_ADDAC_CONT_TX_MASK) >> MAC_PCU_TST_ADDAC_CONT_TX_LSB)
-#define MAC_PCU_TST_ADDAC_CONT_TX_SET(x)         (((x) << MAC_PCU_TST_ADDAC_CONT_TX_LSB) & MAC_PCU_TST_ADDAC_CONT_TX_MASK)
-
-#define MAC_PCU_DEF_ANTENNA_ADDRESS              0x00008038
-#define MAC_PCU_DEF_ANTENNA_OFFSET               0x00000038
-#define MAC_PCU_DEF_ANTENNA_RX_LNA_CONFIG_SEL_MSB 28
-#define MAC_PCU_DEF_ANTENNA_RX_LNA_CONFIG_SEL_LSB 28
-#define MAC_PCU_DEF_ANTENNA_RX_LNA_CONFIG_SEL_MASK 0x10000000
-#define MAC_PCU_DEF_ANTENNA_RX_LNA_CONFIG_SEL_GET(x) (((x) & MAC_PCU_DEF_ANTENNA_RX_LNA_CONFIG_SEL_MASK) >> MAC_PCU_DEF_ANTENNA_RX_LNA_CONFIG_SEL_LSB)
-#define MAC_PCU_DEF_ANTENNA_RX_LNA_CONFIG_SEL_SET(x) (((x) << MAC_PCU_DEF_ANTENNA_RX_LNA_CONFIG_SEL_LSB) & MAC_PCU_DEF_ANTENNA_RX_LNA_CONFIG_SEL_MASK)
-#define MAC_PCU_DEF_ANTENNA_TX_DEF_ANT_SEL_MSB   24
-#define MAC_PCU_DEF_ANTENNA_TX_DEF_ANT_SEL_LSB   24
-#define MAC_PCU_DEF_ANTENNA_TX_DEF_ANT_SEL_MASK  0x01000000
-#define MAC_PCU_DEF_ANTENNA_TX_DEF_ANT_SEL_GET(x) (((x) & MAC_PCU_DEF_ANTENNA_TX_DEF_ANT_SEL_MASK) >> MAC_PCU_DEF_ANTENNA_TX_DEF_ANT_SEL_LSB)
-#define MAC_PCU_DEF_ANTENNA_TX_DEF_ANT_SEL_SET(x) (((x) << MAC_PCU_DEF_ANTENNA_TX_DEF_ANT_SEL_LSB) & MAC_PCU_DEF_ANTENNA_TX_DEF_ANT_SEL_MASK)
-#define MAC_PCU_DEF_ANTENNA_VALUE_MSB            23
-#define MAC_PCU_DEF_ANTENNA_VALUE_LSB            0
-#define MAC_PCU_DEF_ANTENNA_VALUE_MASK           0x00ffffff
-#define MAC_PCU_DEF_ANTENNA_VALUE_GET(x)         (((x) & MAC_PCU_DEF_ANTENNA_VALUE_MASK) >> MAC_PCU_DEF_ANTENNA_VALUE_LSB)
-#define MAC_PCU_DEF_ANTENNA_VALUE_SET(x)         (((x) << MAC_PCU_DEF_ANTENNA_VALUE_LSB) & MAC_PCU_DEF_ANTENNA_VALUE_MASK)
-
-#define MAC_PCU_AES_MUTE_MASK_0_ADDRESS          0x0000803c
-#define MAC_PCU_AES_MUTE_MASK_0_OFFSET           0x0000003c
-#define MAC_PCU_AES_MUTE_MASK_0_QOS_MSB          31
-#define MAC_PCU_AES_MUTE_MASK_0_QOS_LSB          16
-#define MAC_PCU_AES_MUTE_MASK_0_QOS_MASK         0xffff0000
-#define MAC_PCU_AES_MUTE_MASK_0_QOS_GET(x)       (((x) & MAC_PCU_AES_MUTE_MASK_0_QOS_MASK) >> MAC_PCU_AES_MUTE_MASK_0_QOS_LSB)
-#define MAC_PCU_AES_MUTE_MASK_0_QOS_SET(x)       (((x) << MAC_PCU_AES_MUTE_MASK_0_QOS_LSB) & MAC_PCU_AES_MUTE_MASK_0_QOS_MASK)
-#define MAC_PCU_AES_MUTE_MASK_0_FC_MSB           15
-#define MAC_PCU_AES_MUTE_MASK_0_FC_LSB           0
-#define MAC_PCU_AES_MUTE_MASK_0_FC_MASK          0x0000ffff
-#define MAC_PCU_AES_MUTE_MASK_0_FC_GET(x)        (((x) & MAC_PCU_AES_MUTE_MASK_0_FC_MASK) >> MAC_PCU_AES_MUTE_MASK_0_FC_LSB)
-#define MAC_PCU_AES_MUTE_MASK_0_FC_SET(x)        (((x) << MAC_PCU_AES_MUTE_MASK_0_FC_LSB) & MAC_PCU_AES_MUTE_MASK_0_FC_MASK)
-
-#define MAC_PCU_AES_MUTE_MASK_1_ADDRESS          0x00008040
-#define MAC_PCU_AES_MUTE_MASK_1_OFFSET           0x00000040
-#define MAC_PCU_AES_MUTE_MASK_1_FC_MGMT_MSB      31
-#define MAC_PCU_AES_MUTE_MASK_1_FC_MGMT_LSB      16
-#define MAC_PCU_AES_MUTE_MASK_1_FC_MGMT_MASK     0xffff0000
-#define MAC_PCU_AES_MUTE_MASK_1_FC_MGMT_GET(x)   (((x) & MAC_PCU_AES_MUTE_MASK_1_FC_MGMT_MASK) >> MAC_PCU_AES_MUTE_MASK_1_FC_MGMT_LSB)
-#define MAC_PCU_AES_MUTE_MASK_1_FC_MGMT_SET(x)   (((x) << MAC_PCU_AES_MUTE_MASK_1_FC_MGMT_LSB) & MAC_PCU_AES_MUTE_MASK_1_FC_MGMT_MASK)
-#define MAC_PCU_AES_MUTE_MASK_1_SEQ_MSB          15
-#define MAC_PCU_AES_MUTE_MASK_1_SEQ_LSB          0
-#define MAC_PCU_AES_MUTE_MASK_1_SEQ_MASK         0x0000ffff
-#define MAC_PCU_AES_MUTE_MASK_1_SEQ_GET(x)       (((x) & MAC_PCU_AES_MUTE_MASK_1_SEQ_MASK) >> MAC_PCU_AES_MUTE_MASK_1_SEQ_LSB)
-#define MAC_PCU_AES_MUTE_MASK_1_SEQ_SET(x)       (((x) << MAC_PCU_AES_MUTE_MASK_1_SEQ_LSB) & MAC_PCU_AES_MUTE_MASK_1_SEQ_MASK)
-
-#define MAC_PCU_GATED_CLKS_ADDRESS               0x00008044
-#define MAC_PCU_GATED_CLKS_OFFSET                0x00000044
-#define MAC_PCU_GATED_CLKS_GATED_REG_MSB         3
-#define MAC_PCU_GATED_CLKS_GATED_REG_LSB         3
-#define MAC_PCU_GATED_CLKS_GATED_REG_MASK        0x00000008
-#define MAC_PCU_GATED_CLKS_GATED_REG_GET(x)      (((x) & MAC_PCU_GATED_CLKS_GATED_REG_MASK) >> MAC_PCU_GATED_CLKS_GATED_REG_LSB)
-#define MAC_PCU_GATED_CLKS_GATED_REG_SET(x)      (((x) << MAC_PCU_GATED_CLKS_GATED_REG_LSB) & MAC_PCU_GATED_CLKS_GATED_REG_MASK)
-#define MAC_PCU_GATED_CLKS_GATED_RX_MSB          2
-#define MAC_PCU_GATED_CLKS_GATED_RX_LSB          2
-#define MAC_PCU_GATED_CLKS_GATED_RX_MASK         0x00000004
-#define MAC_PCU_GATED_CLKS_GATED_RX_GET(x)       (((x) & MAC_PCU_GATED_CLKS_GATED_RX_MASK) >> MAC_PCU_GATED_CLKS_GATED_RX_LSB)
-#define MAC_PCU_GATED_CLKS_GATED_RX_SET(x)       (((x) << MAC_PCU_GATED_CLKS_GATED_RX_LSB) & MAC_PCU_GATED_CLKS_GATED_RX_MASK)
-#define MAC_PCU_GATED_CLKS_GATED_TX_MSB          1
-#define MAC_PCU_GATED_CLKS_GATED_TX_LSB          1
-#define MAC_PCU_GATED_CLKS_GATED_TX_MASK         0x00000002
-#define MAC_PCU_GATED_CLKS_GATED_TX_GET(x)       (((x) & MAC_PCU_GATED_CLKS_GATED_TX_MASK) >> MAC_PCU_GATED_CLKS_GATED_TX_LSB)
-#define MAC_PCU_GATED_CLKS_GATED_TX_SET(x)       (((x) << MAC_PCU_GATED_CLKS_GATED_TX_LSB) & MAC_PCU_GATED_CLKS_GATED_TX_MASK)
-
-#define MAC_PCU_OBS_BUS_2_ADDRESS                0x00008048
-#define MAC_PCU_OBS_BUS_2_OFFSET                 0x00000048
-#define MAC_PCU_OBS_BUS_2_VALUE_MSB              17
-#define MAC_PCU_OBS_BUS_2_VALUE_LSB              0
-#define MAC_PCU_OBS_BUS_2_VALUE_MASK             0x0003ffff
-#define MAC_PCU_OBS_BUS_2_VALUE_GET(x)           (((x) & MAC_PCU_OBS_BUS_2_VALUE_MASK) >> MAC_PCU_OBS_BUS_2_VALUE_LSB)
-#define MAC_PCU_OBS_BUS_2_VALUE_SET(x)           (((x) << MAC_PCU_OBS_BUS_2_VALUE_LSB) & MAC_PCU_OBS_BUS_2_VALUE_MASK)
-
-#define MAC_PCU_OBS_BUS_1_ADDRESS                0x0000804c
-#define MAC_PCU_OBS_BUS_1_OFFSET                 0x0000004c
-#define MAC_PCU_OBS_BUS_1_TX_STATE_MSB           30
-#define MAC_PCU_OBS_BUS_1_TX_STATE_LSB           25
-#define MAC_PCU_OBS_BUS_1_TX_STATE_MASK          0x7e000000
-#define MAC_PCU_OBS_BUS_1_TX_STATE_GET(x)        (((x) & MAC_PCU_OBS_BUS_1_TX_STATE_MASK) >> MAC_PCU_OBS_BUS_1_TX_STATE_LSB)
-#define MAC_PCU_OBS_BUS_1_TX_STATE_SET(x)        (((x) << MAC_PCU_OBS_BUS_1_TX_STATE_LSB) & MAC_PCU_OBS_BUS_1_TX_STATE_MASK)
-#define MAC_PCU_OBS_BUS_1_RX_STATE_MSB           24
-#define MAC_PCU_OBS_BUS_1_RX_STATE_LSB           20
-#define MAC_PCU_OBS_BUS_1_RX_STATE_MASK          0x01f00000
-#define MAC_PCU_OBS_BUS_1_RX_STATE_GET(x)        (((x) & MAC_PCU_OBS_BUS_1_RX_STATE_MASK) >> MAC_PCU_OBS_BUS_1_RX_STATE_LSB)
-#define MAC_PCU_OBS_BUS_1_RX_STATE_SET(x)        (((x) << MAC_PCU_OBS_BUS_1_RX_STATE_LSB) & MAC_PCU_OBS_BUS_1_RX_STATE_MASK)
-#define MAC_PCU_OBS_BUS_1_WEP_STATE_MSB          17
-#define MAC_PCU_OBS_BUS_1_WEP_STATE_LSB          12
-#define MAC_PCU_OBS_BUS_1_WEP_STATE_MASK         0x0003f000
-#define MAC_PCU_OBS_BUS_1_WEP_STATE_GET(x)       (((x) & MAC_PCU_OBS_BUS_1_WEP_STATE_MASK) >> MAC_PCU_OBS_BUS_1_WEP_STATE_LSB)
-#define MAC_PCU_OBS_BUS_1_WEP_STATE_SET(x)       (((x) << MAC_PCU_OBS_BUS_1_WEP_STATE_LSB) & MAC_PCU_OBS_BUS_1_WEP_STATE_MASK)
-#define MAC_PCU_OBS_BUS_1_RX_CLEAR_MSB           11
-#define MAC_PCU_OBS_BUS_1_RX_CLEAR_LSB           11
-#define MAC_PCU_OBS_BUS_1_RX_CLEAR_MASK          0x00000800
-#define MAC_PCU_OBS_BUS_1_RX_CLEAR_GET(x)        (((x) & MAC_PCU_OBS_BUS_1_RX_CLEAR_MASK) >> MAC_PCU_OBS_BUS_1_RX_CLEAR_LSB)
-#define MAC_PCU_OBS_BUS_1_RX_CLEAR_SET(x)        (((x) << MAC_PCU_OBS_BUS_1_RX_CLEAR_LSB) & MAC_PCU_OBS_BUS_1_RX_CLEAR_MASK)
-#define MAC_PCU_OBS_BUS_1_RX_FRAME_MSB           10
-#define MAC_PCU_OBS_BUS_1_RX_FRAME_LSB           10
-#define MAC_PCU_OBS_BUS_1_RX_FRAME_MASK          0x00000400
-#define MAC_PCU_OBS_BUS_1_RX_FRAME_GET(x)        (((x) & MAC_PCU_OBS_BUS_1_RX_FRAME_MASK) >> MAC_PCU_OBS_BUS_1_RX_FRAME_LSB)
-#define MAC_PCU_OBS_BUS_1_RX_FRAME_SET(x)        (((x) << MAC_PCU_OBS_BUS_1_RX_FRAME_LSB) & MAC_PCU_OBS_BUS_1_RX_FRAME_MASK)
-#define MAC_PCU_OBS_BUS_1_TX_FRAME_MSB           9
-#define MAC_PCU_OBS_BUS_1_TX_FRAME_LSB           9
-#define MAC_PCU_OBS_BUS_1_TX_FRAME_MASK          0x00000200
-#define MAC_PCU_OBS_BUS_1_TX_FRAME_GET(x)        (((x) & MAC_PCU_OBS_BUS_1_TX_FRAME_MASK) >> MAC_PCU_OBS_BUS_1_TX_FRAME_LSB)
-#define MAC_PCU_OBS_BUS_1_TX_FRAME_SET(x)        (((x) << MAC_PCU_OBS_BUS_1_TX_FRAME_LSB) & MAC_PCU_OBS_BUS_1_TX_FRAME_MASK)
-#define MAC_PCU_OBS_BUS_1_TX_HOLD_MSB            8
-#define MAC_PCU_OBS_BUS_1_TX_HOLD_LSB            8
-#define MAC_PCU_OBS_BUS_1_TX_HOLD_MASK           0x00000100
-#define MAC_PCU_OBS_BUS_1_TX_HOLD_GET(x)         (((x) & MAC_PCU_OBS_BUS_1_TX_HOLD_MASK) >> MAC_PCU_OBS_BUS_1_TX_HOLD_LSB)
-#define MAC_PCU_OBS_BUS_1_TX_HOLD_SET(x)         (((x) << MAC_PCU_OBS_BUS_1_TX_HOLD_LSB) & MAC_PCU_OBS_BUS_1_TX_HOLD_MASK)
-#define MAC_PCU_OBS_BUS_1_PCU_CHANNEL_IDLE_MSB   7
-#define MAC_PCU_OBS_BUS_1_PCU_CHANNEL_IDLE_LSB   7
-#define MAC_PCU_OBS_BUS_1_PCU_CHANNEL_IDLE_MASK  0x00000080
-#define MAC_PCU_OBS_BUS_1_PCU_CHANNEL_IDLE_GET(x) (((x) & MAC_PCU_OBS_BUS_1_PCU_CHANNEL_IDLE_MASK) >> MAC_PCU_OBS_BUS_1_PCU_CHANNEL_IDLE_LSB)
-#define MAC_PCU_OBS_BUS_1_PCU_CHANNEL_IDLE_SET(x) (((x) << MAC_PCU_OBS_BUS_1_PCU_CHANNEL_IDLE_LSB) & MAC_PCU_OBS_BUS_1_PCU_CHANNEL_IDLE_MASK)
-#define MAC_PCU_OBS_BUS_1_TM_QUIET_TIME_MSB      6
-#define MAC_PCU_OBS_BUS_1_TM_QUIET_TIME_LSB      6
-#define MAC_PCU_OBS_BUS_1_TM_QUIET_TIME_MASK     0x00000040
-#define MAC_PCU_OBS_BUS_1_TM_QUIET_TIME_GET(x)   (((x) & MAC_PCU_OBS_BUS_1_TM_QUIET_TIME_MASK) >> MAC_PCU_OBS_BUS_1_TM_QUIET_TIME_LSB)
-#define MAC_PCU_OBS_BUS_1_TM_QUIET_TIME_SET(x)   (((x) << MAC_PCU_OBS_BUS_1_TM_QUIET_TIME_LSB) & MAC_PCU_OBS_BUS_1_TM_QUIET_TIME_MASK)
-#define MAC_PCU_OBS_BUS_1_TX_HCF_MSB             5
-#define MAC_PCU_OBS_BUS_1_TX_HCF_LSB             5
-#define MAC_PCU_OBS_BUS_1_TX_HCF_MASK            0x00000020
-#define MAC_PCU_OBS_BUS_1_TX_HCF_GET(x)          (((x) & MAC_PCU_OBS_BUS_1_TX_HCF_MASK) >> MAC_PCU_OBS_BUS_1_TX_HCF_LSB)
-#define MAC_PCU_OBS_BUS_1_TX_HCF_SET(x)          (((x) << MAC_PCU_OBS_BUS_1_TX_HCF_LSB) & MAC_PCU_OBS_BUS_1_TX_HCF_MASK)
-#define MAC_PCU_OBS_BUS_1_FILTER_PASS_MSB        4
-#define MAC_PCU_OBS_BUS_1_FILTER_PASS_LSB        4
-#define MAC_PCU_OBS_BUS_1_FILTER_PASS_MASK       0x00000010
-#define MAC_PCU_OBS_BUS_1_FILTER_PASS_GET(x)     (((x) & MAC_PCU_OBS_BUS_1_FILTER_PASS_MASK) >> MAC_PCU_OBS_BUS_1_FILTER_PASS_LSB)
-#define MAC_PCU_OBS_BUS_1_FILTER_PASS_SET(x)     (((x) << MAC_PCU_OBS_BUS_1_FILTER_PASS_LSB) & MAC_PCU_OBS_BUS_1_FILTER_PASS_MASK)
-#define MAC_PCU_OBS_BUS_1_RX_MY_BEACON_MSB       3
-#define MAC_PCU_OBS_BUS_1_RX_MY_BEACON_LSB       3
-#define MAC_PCU_OBS_BUS_1_RX_MY_BEACON_MASK      0x00000008
-#define MAC_PCU_OBS_BUS_1_RX_MY_BEACON_GET(x)    (((x) & MAC_PCU_OBS_BUS_1_RX_MY_BEACON_MASK) >> MAC_PCU_OBS_BUS_1_RX_MY_BEACON_LSB)
-#define MAC_PCU_OBS_BUS_1_RX_MY_BEACON_SET(x)    (((x) << MAC_PCU_OBS_BUS_1_RX_MY_BEACON_LSB) & MAC_PCU_OBS_BUS_1_RX_MY_BEACON_MASK)
-#define MAC_PCU_OBS_BUS_1_RX_WEP_MSB             2
-#define MAC_PCU_OBS_BUS_1_RX_WEP_LSB             2
-#define MAC_PCU_OBS_BUS_1_RX_WEP_MASK            0x00000004
-#define MAC_PCU_OBS_BUS_1_RX_WEP_GET(x)          (((x) & MAC_PCU_OBS_BUS_1_RX_WEP_MASK) >> MAC_PCU_OBS_BUS_1_RX_WEP_LSB)
-#define MAC_PCU_OBS_BUS_1_RX_WEP_SET(x)          (((x) << MAC_PCU_OBS_BUS_1_RX_WEP_LSB) & MAC_PCU_OBS_BUS_1_RX_WEP_MASK)
-#define MAC_PCU_OBS_BUS_1_PCU_RX_END_MSB         1
-#define MAC_PCU_OBS_BUS_1_PCU_RX_END_LSB         1
-#define MAC_PCU_OBS_BUS_1_PCU_RX_END_MASK        0x00000002
-#define MAC_PCU_OBS_BUS_1_PCU_RX_END_GET(x)      (((x) & MAC_PCU_OBS_BUS_1_PCU_RX_END_MASK) >> MAC_PCU_OBS_BUS_1_PCU_RX_END_LSB)
-#define MAC_PCU_OBS_BUS_1_PCU_RX_END_SET(x)      (((x) << MAC_PCU_OBS_BUS_1_PCU_RX_END_LSB) & MAC_PCU_OBS_BUS_1_PCU_RX_END_MASK)
-#define MAC_PCU_OBS_BUS_1_PCU_DIRECTED_MSB       0
-#define MAC_PCU_OBS_BUS_1_PCU_DIRECTED_LSB       0
-#define MAC_PCU_OBS_BUS_1_PCU_DIRECTED_MASK      0x00000001
-#define MAC_PCU_OBS_BUS_1_PCU_DIRECTED_GET(x)    (((x) & MAC_PCU_OBS_BUS_1_PCU_DIRECTED_MASK) >> MAC_PCU_OBS_BUS_1_PCU_DIRECTED_LSB)
-#define MAC_PCU_OBS_BUS_1_PCU_DIRECTED_SET(x)    (((x) << MAC_PCU_OBS_BUS_1_PCU_DIRECTED_LSB) & MAC_PCU_OBS_BUS_1_PCU_DIRECTED_MASK)
-
-#define MAC_PCU_DYM_MIMO_PWR_SAVE_ADDRESS        0x00008050
-#define MAC_PCU_DYM_MIMO_PWR_SAVE_OFFSET         0x00000050
-#define MAC_PCU_DYM_MIMO_PWR_SAVE_HI_PWR_CHAIN_MASK_MSB 10
-#define MAC_PCU_DYM_MIMO_PWR_SAVE_HI_PWR_CHAIN_MASK_LSB 8
-#define MAC_PCU_DYM_MIMO_PWR_SAVE_HI_PWR_CHAIN_MASK_MASK 0x00000700
-#define MAC_PCU_DYM_MIMO_PWR_SAVE_HI_PWR_CHAIN_MASK_GET(x) (((x) & MAC_PCU_DYM_MIMO_PWR_SAVE_HI_PWR_CHAIN_MASK_MASK) >> MAC_PCU_DYM_MIMO_PWR_SAVE_HI_PWR_CHAIN_MASK_LSB)
-#define MAC_PCU_DYM_MIMO_PWR_SAVE_HI_PWR_CHAIN_MASK_SET(x) (((x) << MAC_PCU_DYM_MIMO_PWR_SAVE_HI_PWR_CHAIN_MASK_LSB) & MAC_PCU_DYM_MIMO_PWR_SAVE_HI_PWR_CHAIN_MASK_MASK)
-#define MAC_PCU_DYM_MIMO_PWR_SAVE_LOW_PWR_CHAIN_MASK_MSB 6
-#define MAC_PCU_DYM_MIMO_PWR_SAVE_LOW_PWR_CHAIN_MASK_LSB 4
-#define MAC_PCU_DYM_MIMO_PWR_SAVE_LOW_PWR_CHAIN_MASK_MASK 0x00000070
-#define MAC_PCU_DYM_MIMO_PWR_SAVE_LOW_PWR_CHAIN_MASK_GET(x) (((x) & MAC_PCU_DYM_MIMO_PWR_SAVE_LOW_PWR_CHAIN_MASK_MASK) >> MAC_PCU_DYM_MIMO_PWR_SAVE_LOW_PWR_CHAIN_MASK_LSB)
-#define MAC_PCU_DYM_MIMO_PWR_SAVE_LOW_PWR_CHAIN_MASK_SET(x) (((x) << MAC_PCU_DYM_MIMO_PWR_SAVE_LOW_PWR_CHAIN_MASK_LSB) & MAC_PCU_DYM_MIMO_PWR_SAVE_LOW_PWR_CHAIN_MASK_MASK)
-#define MAC_PCU_DYM_MIMO_PWR_SAVE_SW_CHAIN_MASK_SEL_MSB 2
-#define MAC_PCU_DYM_MIMO_PWR_SAVE_SW_CHAIN_MASK_SEL_LSB 2
-#define MAC_PCU_DYM_MIMO_PWR_SAVE_SW_CHAIN_MASK_SEL_MASK 0x00000004
-#define MAC_PCU_DYM_MIMO_PWR_SAVE_SW_CHAIN_MASK_SEL_GET(x) (((x) & MAC_PCU_DYM_MIMO_PWR_SAVE_SW_CHAIN_MASK_SEL_MASK) >> MAC_PCU_DYM_MIMO_PWR_SAVE_SW_CHAIN_MASK_SEL_LSB)
-#define MAC_PCU_DYM_MIMO_PWR_SAVE_SW_CHAIN_MASK_SEL_SET(x) (((x) << MAC_PCU_DYM_MIMO_PWR_SAVE_SW_CHAIN_MASK_SEL_LSB) & MAC_PCU_DYM_MIMO_PWR_SAVE_SW_CHAIN_MASK_SEL_MASK)
-#define MAC_PCU_DYM_MIMO_PWR_SAVE_HW_CTRL_EN_MSB 1
-#define MAC_PCU_DYM_MIMO_PWR_SAVE_HW_CTRL_EN_LSB 1
-#define MAC_PCU_DYM_MIMO_PWR_SAVE_HW_CTRL_EN_MASK 0x00000002
-#define MAC_PCU_DYM_MIMO_PWR_SAVE_HW_CTRL_EN_GET(x) (((x) & MAC_PCU_DYM_MIMO_PWR_SAVE_HW_CTRL_EN_MASK) >> MAC_PCU_DYM_MIMO_PWR_SAVE_HW_CTRL_EN_LSB)
-#define MAC_PCU_DYM_MIMO_PWR_SAVE_HW_CTRL_EN_SET(x) (((x) << MAC_PCU_DYM_MIMO_PWR_SAVE_HW_CTRL_EN_LSB) & MAC_PCU_DYM_MIMO_PWR_SAVE_HW_CTRL_EN_MASK)
-#define MAC_PCU_DYM_MIMO_PWR_SAVE_USE_MAC_CTRL_MSB 0
-#define MAC_PCU_DYM_MIMO_PWR_SAVE_USE_MAC_CTRL_LSB 0
-#define MAC_PCU_DYM_MIMO_PWR_SAVE_USE_MAC_CTRL_MASK 0x00000001
-#define MAC_PCU_DYM_MIMO_PWR_SAVE_USE_MAC_CTRL_GET(x) (((x) & MAC_PCU_DYM_MIMO_PWR_SAVE_USE_MAC_CTRL_MASK) >> MAC_PCU_DYM_MIMO_PWR_SAVE_USE_MAC_CTRL_LSB)
-#define MAC_PCU_DYM_MIMO_PWR_SAVE_USE_MAC_CTRL_SET(x) (((x) << MAC_PCU_DYM_MIMO_PWR_SAVE_USE_MAC_CTRL_LSB) & MAC_PCU_DYM_MIMO_PWR_SAVE_USE_MAC_CTRL_MASK)
-
-#define MAC_PCU_LAST_BEACON_TSF_ADDRESS          0x00008054
-#define MAC_PCU_LAST_BEACON_TSF_OFFSET           0x00000054
-#define MAC_PCU_LAST_BEACON_TSF_VALUE_MSB        31
-#define MAC_PCU_LAST_BEACON_TSF_VALUE_LSB        0
-#define MAC_PCU_LAST_BEACON_TSF_VALUE_MASK       0xffffffff
-#define MAC_PCU_LAST_BEACON_TSF_VALUE_GET(x)     (((x) & MAC_PCU_LAST_BEACON_TSF_VALUE_MASK) >> MAC_PCU_LAST_BEACON_TSF_VALUE_LSB)
-#define MAC_PCU_LAST_BEACON_TSF_VALUE_SET(x)     (((x) << MAC_PCU_LAST_BEACON_TSF_VALUE_LSB) & MAC_PCU_LAST_BEACON_TSF_VALUE_MASK)
-
-#define MAC_PCU_NAV_ADDRESS                      0x00008058
-#define MAC_PCU_NAV_OFFSET                       0x00000058
-#define MAC_PCU_NAV_VALUE_MSB                    25
-#define MAC_PCU_NAV_VALUE_LSB                    0
-#define MAC_PCU_NAV_VALUE_MASK                   0x03ffffff
-#define MAC_PCU_NAV_VALUE_GET(x)                 (((x) & MAC_PCU_NAV_VALUE_MASK) >> MAC_PCU_NAV_VALUE_LSB)
-#define MAC_PCU_NAV_VALUE_SET(x)                 (((x) << MAC_PCU_NAV_VALUE_LSB) & MAC_PCU_NAV_VALUE_MASK)
-
-#define MAC_PCU_RTS_SUCCESS_CNT_ADDRESS          0x0000805c
-#define MAC_PCU_RTS_SUCCESS_CNT_OFFSET           0x0000005c
-#define MAC_PCU_RTS_SUCCESS_CNT_VALUE_MSB        15
-#define MAC_PCU_RTS_SUCCESS_CNT_VALUE_LSB        0
-#define MAC_PCU_RTS_SUCCESS_CNT_VALUE_MASK       0x0000ffff
-#define MAC_PCU_RTS_SUCCESS_CNT_VALUE_GET(x)     (((x) & MAC_PCU_RTS_SUCCESS_CNT_VALUE_MASK) >> MAC_PCU_RTS_SUCCESS_CNT_VALUE_LSB)
-#define MAC_PCU_RTS_SUCCESS_CNT_VALUE_SET(x)     (((x) << MAC_PCU_RTS_SUCCESS_CNT_VALUE_LSB) & MAC_PCU_RTS_SUCCESS_CNT_VALUE_MASK)
-
-#define MAC_PCU_RTS_FAIL_CNT_ADDRESS             0x00008060
-#define MAC_PCU_RTS_FAIL_CNT_OFFSET              0x00000060
-#define MAC_PCU_RTS_FAIL_CNT_VALUE_MSB           15
-#define MAC_PCU_RTS_FAIL_CNT_VALUE_LSB           0
-#define MAC_PCU_RTS_FAIL_CNT_VALUE_MASK          0x0000ffff
-#define MAC_PCU_RTS_FAIL_CNT_VALUE_GET(x)        (((x) & MAC_PCU_RTS_FAIL_CNT_VALUE_MASK) >> MAC_PCU_RTS_FAIL_CNT_VALUE_LSB)
-#define MAC_PCU_RTS_FAIL_CNT_VALUE_SET(x)        (((x) << MAC_PCU_RTS_FAIL_CNT_VALUE_LSB) & MAC_PCU_RTS_FAIL_CNT_VALUE_MASK)
-
-#define MAC_PCU_ACK_FAIL_CNT_ADDRESS             0x00008064
-#define MAC_PCU_ACK_FAIL_CNT_OFFSET              0x00000064
-#define MAC_PCU_ACK_FAIL_CNT_VALUE_MSB           15
-#define MAC_PCU_ACK_FAIL_CNT_VALUE_LSB           0
-#define MAC_PCU_ACK_FAIL_CNT_VALUE_MASK          0x0000ffff
-#define MAC_PCU_ACK_FAIL_CNT_VALUE_GET(x)        (((x) & MAC_PCU_ACK_FAIL_CNT_VALUE_MASK) >> MAC_PCU_ACK_FAIL_CNT_VALUE_LSB)
-#define MAC_PCU_ACK_FAIL_CNT_VALUE_SET(x)        (((x) << MAC_PCU_ACK_FAIL_CNT_VALUE_LSB) & MAC_PCU_ACK_FAIL_CNT_VALUE_MASK)
-
-#define MAC_PCU_FCS_FAIL_CNT_ADDRESS             0x00008068
-#define MAC_PCU_FCS_FAIL_CNT_OFFSET              0x00000068
-#define MAC_PCU_FCS_FAIL_CNT_VALUE_MSB           15
-#define MAC_PCU_FCS_FAIL_CNT_VALUE_LSB           0
-#define MAC_PCU_FCS_FAIL_CNT_VALUE_MASK          0x0000ffff
-#define MAC_PCU_FCS_FAIL_CNT_VALUE_GET(x)        (((x) & MAC_PCU_FCS_FAIL_CNT_VALUE_MASK) >> MAC_PCU_FCS_FAIL_CNT_VALUE_LSB)
-#define MAC_PCU_FCS_FAIL_CNT_VALUE_SET(x)        (((x) << MAC_PCU_FCS_FAIL_CNT_VALUE_LSB) & MAC_PCU_FCS_FAIL_CNT_VALUE_MASK)
-
-#define MAC_PCU_BEACON_CNT_ADDRESS               0x0000806c
-#define MAC_PCU_BEACON_CNT_OFFSET                0x0000006c
-#define MAC_PCU_BEACON_CNT_VALUE_MSB             15
-#define MAC_PCU_BEACON_CNT_VALUE_LSB             0
-#define MAC_PCU_BEACON_CNT_VALUE_MASK            0x0000ffff
-#define MAC_PCU_BEACON_CNT_VALUE_GET(x)          (((x) & MAC_PCU_BEACON_CNT_VALUE_MASK) >> MAC_PCU_BEACON_CNT_VALUE_LSB)
-#define MAC_PCU_BEACON_CNT_VALUE_SET(x)          (((x) << MAC_PCU_BEACON_CNT_VALUE_LSB) & MAC_PCU_BEACON_CNT_VALUE_MASK)
-
-#define MAC_PCU_XRMODE_ADDRESS                   0x00008070
-#define MAC_PCU_XRMODE_OFFSET                    0x00000070
-#define MAC_PCU_XRMODE_FRAME_HOLD_MSB            31
-#define MAC_PCU_XRMODE_FRAME_HOLD_LSB            20
-#define MAC_PCU_XRMODE_FRAME_HOLD_MASK           0xfff00000
-#define MAC_PCU_XRMODE_FRAME_HOLD_GET(x)         (((x) & MAC_PCU_XRMODE_FRAME_HOLD_MASK) >> MAC_PCU_XRMODE_FRAME_HOLD_LSB)
-#define MAC_PCU_XRMODE_FRAME_HOLD_SET(x)         (((x) << MAC_PCU_XRMODE_FRAME_HOLD_LSB) & MAC_PCU_XRMODE_FRAME_HOLD_MASK)
-#define MAC_PCU_XRMODE_WAIT_FOR_POLL_MSB         7
-#define MAC_PCU_XRMODE_WAIT_FOR_POLL_LSB         7
-#define MAC_PCU_XRMODE_WAIT_FOR_POLL_MASK        0x00000080
-#define MAC_PCU_XRMODE_WAIT_FOR_POLL_GET(x)      (((x) & MAC_PCU_XRMODE_WAIT_FOR_POLL_MASK) >> MAC_PCU_XRMODE_WAIT_FOR_POLL_LSB)
-#define MAC_PCU_XRMODE_WAIT_FOR_POLL_SET(x)      (((x) << MAC_PCU_XRMODE_WAIT_FOR_POLL_LSB) & MAC_PCU_XRMODE_WAIT_FOR_POLL_MASK)
-#define MAC_PCU_XRMODE_POLL_TYPE_MSB             5
-#define MAC_PCU_XRMODE_POLL_TYPE_LSB             0
-#define MAC_PCU_XRMODE_POLL_TYPE_MASK            0x0000003f
-#define MAC_PCU_XRMODE_POLL_TYPE_GET(x)          (((x) & MAC_PCU_XRMODE_POLL_TYPE_MASK) >> MAC_PCU_XRMODE_POLL_TYPE_LSB)
-#define MAC_PCU_XRMODE_POLL_TYPE_SET(x)          (((x) << MAC_PCU_XRMODE_POLL_TYPE_LSB) & MAC_PCU_XRMODE_POLL_TYPE_MASK)
-
-#define MAC_PCU_XRDEL_ADDRESS                    0x00008074
-#define MAC_PCU_XRDEL_OFFSET                     0x00000074
-#define MAC_PCU_XRDEL_CHIRP_DATA_DELAY_MSB       31
-#define MAC_PCU_XRDEL_CHIRP_DATA_DELAY_LSB       16
-#define MAC_PCU_XRDEL_CHIRP_DATA_DELAY_MASK      0xffff0000
-#define MAC_PCU_XRDEL_CHIRP_DATA_DELAY_GET(x)    (((x) & MAC_PCU_XRDEL_CHIRP_DATA_DELAY_MASK) >> MAC_PCU_XRDEL_CHIRP_DATA_DELAY_LSB)
-#define MAC_PCU_XRDEL_CHIRP_DATA_DELAY_SET(x)    (((x) << MAC_PCU_XRDEL_CHIRP_DATA_DELAY_LSB) & MAC_PCU_XRDEL_CHIRP_DATA_DELAY_MASK)
-#define MAC_PCU_XRDEL_SLOT_DELAY_MSB             15
-#define MAC_PCU_XRDEL_SLOT_DELAY_LSB             0
-#define MAC_PCU_XRDEL_SLOT_DELAY_MASK            0x0000ffff
-#define MAC_PCU_XRDEL_SLOT_DELAY_GET(x)          (((x) & MAC_PCU_XRDEL_SLOT_DELAY_MASK) >> MAC_PCU_XRDEL_SLOT_DELAY_LSB)
-#define MAC_PCU_XRDEL_SLOT_DELAY_SET(x)          (((x) << MAC_PCU_XRDEL_SLOT_DELAY_LSB) & MAC_PCU_XRDEL_SLOT_DELAY_MASK)
-
-#define MAC_PCU_XRTO_ADDRESS                     0x00008078
-#define MAC_PCU_XRTO_OFFSET                      0x00000078
-#define MAC_PCU_XRTO_POLL_TIMEOUT_MSB            31
-#define MAC_PCU_XRTO_POLL_TIMEOUT_LSB            16
-#define MAC_PCU_XRTO_POLL_TIMEOUT_MASK           0xffff0000
-#define MAC_PCU_XRTO_POLL_TIMEOUT_GET(x)         (((x) & MAC_PCU_XRTO_POLL_TIMEOUT_MASK) >> MAC_PCU_XRTO_POLL_TIMEOUT_LSB)
-#define MAC_PCU_XRTO_POLL_TIMEOUT_SET(x)         (((x) << MAC_PCU_XRTO_POLL_TIMEOUT_LSB) & MAC_PCU_XRTO_POLL_TIMEOUT_MASK)
-#define MAC_PCU_XRTO_CHIRP_TIMEOUT_MSB           15
-#define MAC_PCU_XRTO_CHIRP_TIMEOUT_LSB           0
-#define MAC_PCU_XRTO_CHIRP_TIMEOUT_MASK          0x0000ffff
-#define MAC_PCU_XRTO_CHIRP_TIMEOUT_GET(x)        (((x) & MAC_PCU_XRTO_CHIRP_TIMEOUT_MASK) >> MAC_PCU_XRTO_CHIRP_TIMEOUT_LSB)
-#define MAC_PCU_XRTO_CHIRP_TIMEOUT_SET(x)        (((x) << MAC_PCU_XRTO_CHIRP_TIMEOUT_LSB) & MAC_PCU_XRTO_CHIRP_TIMEOUT_MASK)
-
-#define MAC_PCU_XRCRP_ADDRESS                    0x0000807c
-#define MAC_PCU_XRCRP_OFFSET                     0x0000007c
-#define MAC_PCU_XRCRP_CHIRP_GAP_MSB              31
-#define MAC_PCU_XRCRP_CHIRP_GAP_LSB              16
-#define MAC_PCU_XRCRP_CHIRP_GAP_MASK             0xffff0000
-#define MAC_PCU_XRCRP_CHIRP_GAP_GET(x)           (((x) & MAC_PCU_XRCRP_CHIRP_GAP_MASK) >> MAC_PCU_XRCRP_CHIRP_GAP_LSB)
-#define MAC_PCU_XRCRP_CHIRP_GAP_SET(x)           (((x) << MAC_PCU_XRCRP_CHIRP_GAP_LSB) & MAC_PCU_XRCRP_CHIRP_GAP_MASK)
-#define MAC_PCU_XRCRP_SEND_CHIRP_MSB             0
-#define MAC_PCU_XRCRP_SEND_CHIRP_LSB             0
-#define MAC_PCU_XRCRP_SEND_CHIRP_MASK            0x00000001
-#define MAC_PCU_XRCRP_SEND_CHIRP_GET(x)          (((x) & MAC_PCU_XRCRP_SEND_CHIRP_MASK) >> MAC_PCU_XRCRP_SEND_CHIRP_LSB)
-#define MAC_PCU_XRCRP_SEND_CHIRP_SET(x)          (((x) << MAC_PCU_XRCRP_SEND_CHIRP_LSB) & MAC_PCU_XRCRP_SEND_CHIRP_MASK)
-
-#define MAC_PCU_XRSTMP_ADDRESS                   0x00008080
-#define MAC_PCU_XRSTMP_OFFSET                    0x00000080
-#define MAC_PCU_XRSTMP_RX_ABORT_RSSI_THRESH_MSB  23
-#define MAC_PCU_XRSTMP_RX_ABORT_RSSI_THRESH_LSB  16
-#define MAC_PCU_XRSTMP_RX_ABORT_RSSI_THRESH_MASK 0x00ff0000
-#define MAC_PCU_XRSTMP_RX_ABORT_RSSI_THRESH_GET(x) (((x) & MAC_PCU_XRSTMP_RX_ABORT_RSSI_THRESH_MASK) >> MAC_PCU_XRSTMP_RX_ABORT_RSSI_THRESH_LSB)
-#define MAC_PCU_XRSTMP_RX_ABORT_RSSI_THRESH_SET(x) (((x) << MAC_PCU_XRSTMP_RX_ABORT_RSSI_THRESH_LSB) & MAC_PCU_XRSTMP_RX_ABORT_RSSI_THRESH_MASK)
-#define MAC_PCU_XRSTMP_TX_STOMP_RSSI_THRESH_MSB  15
-#define MAC_PCU_XRSTMP_TX_STOMP_RSSI_THRESH_LSB  8
-#define MAC_PCU_XRSTMP_TX_STOMP_RSSI_THRESH_MASK 0x0000ff00
-#define MAC_PCU_XRSTMP_TX_STOMP_RSSI_THRESH_GET(x) (((x) & MAC_PCU_XRSTMP_TX_STOMP_RSSI_THRESH_MASK) >> MAC_PCU_XRSTMP_TX_STOMP_RSSI_THRESH_LSB)
-#define MAC_PCU_XRSTMP_TX_STOMP_RSSI_THRESH_SET(x) (((x) << MAC_PCU_XRSTMP_TX_STOMP_RSSI_THRESH_LSB) & MAC_PCU_XRSTMP_TX_STOMP_RSSI_THRESH_MASK)
-#define MAC_PCU_XRSTMP_RX_ABORT_DATA_MSB         5
-#define MAC_PCU_XRSTMP_RX_ABORT_DATA_LSB         5
-#define MAC_PCU_XRSTMP_RX_ABORT_DATA_MASK        0x00000020
-#define MAC_PCU_XRSTMP_RX_ABORT_DATA_GET(x)      (((x) & MAC_PCU_XRSTMP_RX_ABORT_DATA_MASK) >> MAC_PCU_XRSTMP_RX_ABORT_DATA_LSB)
-#define MAC_PCU_XRSTMP_RX_ABORT_DATA_SET(x)      (((x) << MAC_PCU_XRSTMP_RX_ABORT_DATA_LSB) & MAC_PCU_XRSTMP_RX_ABORT_DATA_MASK)
-#define MAC_PCU_XRSTMP_TX_STOMP_DATA_MSB         4
-#define MAC_PCU_XRSTMP_TX_STOMP_DATA_LSB         4
-#define MAC_PCU_XRSTMP_TX_STOMP_DATA_MASK        0x00000010
-#define MAC_PCU_XRSTMP_TX_STOMP_DATA_GET(x)      (((x) & MAC_PCU_XRSTMP_TX_STOMP_DATA_MASK) >> MAC_PCU_XRSTMP_TX_STOMP_DATA_LSB)
-#define MAC_PCU_XRSTMP_TX_STOMP_DATA_SET(x)      (((x) << MAC_PCU_XRSTMP_TX_STOMP_DATA_LSB) & MAC_PCU_XRSTMP_TX_STOMP_DATA_MASK)
-#define MAC_PCU_XRSTMP_TX_STOMP_BSSID_MSB        3
-#define MAC_PCU_XRSTMP_TX_STOMP_BSSID_LSB        3
-#define MAC_PCU_XRSTMP_TX_STOMP_BSSID_MASK       0x00000008
-#define MAC_PCU_XRSTMP_TX_STOMP_BSSID_GET(x)     (((x) & MAC_PCU_XRSTMP_TX_STOMP_BSSID_MASK) >> MAC_PCU_XRSTMP_TX_STOMP_BSSID_LSB)
-#define MAC_PCU_XRSTMP_TX_STOMP_BSSID_SET(x)     (((x) << MAC_PCU_XRSTMP_TX_STOMP_BSSID_LSB) & MAC_PCU_XRSTMP_TX_STOMP_BSSID_MASK)
-#define MAC_PCU_XRSTMP_TX_STOMP_RSSI_MSB         2
-#define MAC_PCU_XRSTMP_TX_STOMP_RSSI_LSB         2
-#define MAC_PCU_XRSTMP_TX_STOMP_RSSI_MASK        0x00000004
-#define MAC_PCU_XRSTMP_TX_STOMP_RSSI_GET(x)      (((x) & MAC_PCU_XRSTMP_TX_STOMP_RSSI_MASK) >> MAC_PCU_XRSTMP_TX_STOMP_RSSI_LSB)
-#define MAC_PCU_XRSTMP_TX_STOMP_RSSI_SET(x)      (((x) << MAC_PCU_XRSTMP_TX_STOMP_RSSI_LSB) & MAC_PCU_XRSTMP_TX_STOMP_RSSI_MASK)
-#define MAC_PCU_XRSTMP_RX_ABORT_BSSID_MSB        1
-#define MAC_PCU_XRSTMP_RX_ABORT_BSSID_LSB        1
-#define MAC_PCU_XRSTMP_RX_ABORT_BSSID_MASK       0x00000002
-#define MAC_PCU_XRSTMP_RX_ABORT_BSSID_GET(x)     (((x) & MAC_PCU_XRSTMP_RX_ABORT_BSSID_MASK) >> MAC_PCU_XRSTMP_RX_ABORT_BSSID_LSB)
-#define MAC_PCU_XRSTMP_RX_ABORT_BSSID_SET(x)     (((x) << MAC_PCU_XRSTMP_RX_ABORT_BSSID_LSB) & MAC_PCU_XRSTMP_RX_ABORT_BSSID_MASK)
-#define MAC_PCU_XRSTMP_RX_ABORT_RSSI_MSB         0
-#define MAC_PCU_XRSTMP_RX_ABORT_RSSI_LSB         0
-#define MAC_PCU_XRSTMP_RX_ABORT_RSSI_MASK        0x00000001
-#define MAC_PCU_XRSTMP_RX_ABORT_RSSI_GET(x)      (((x) & MAC_PCU_XRSTMP_RX_ABORT_RSSI_MASK) >> MAC_PCU_XRSTMP_RX_ABORT_RSSI_LSB)
-#define MAC_PCU_XRSTMP_RX_ABORT_RSSI_SET(x)      (((x) << MAC_PCU_XRSTMP_RX_ABORT_RSSI_LSB) & MAC_PCU_XRSTMP_RX_ABORT_RSSI_MASK)
-
-#define MAC_PCU_ADDR1_MASK_L32_ADDRESS           0x00008084
-#define MAC_PCU_ADDR1_MASK_L32_OFFSET            0x00000084
-#define MAC_PCU_ADDR1_MASK_L32_VALUE_MSB         31
-#define MAC_PCU_ADDR1_MASK_L32_VALUE_LSB         0
-#define MAC_PCU_ADDR1_MASK_L32_VALUE_MASK        0xffffffff
-#define MAC_PCU_ADDR1_MASK_L32_VALUE_GET(x)      (((x) & MAC_PCU_ADDR1_MASK_L32_VALUE_MASK) >> MAC_PCU_ADDR1_MASK_L32_VALUE_LSB)
-#define MAC_PCU_ADDR1_MASK_L32_VALUE_SET(x)      (((x) << MAC_PCU_ADDR1_MASK_L32_VALUE_LSB) & MAC_PCU_ADDR1_MASK_L32_VALUE_MASK)
-
-#define MAC_PCU_ADDR1_MASK_U16_ADDRESS           0x00008088
-#define MAC_PCU_ADDR1_MASK_U16_OFFSET            0x00000088
-#define MAC_PCU_ADDR1_MASK_U16_VALUE_MSB         15
-#define MAC_PCU_ADDR1_MASK_U16_VALUE_LSB         0
-#define MAC_PCU_ADDR1_MASK_U16_VALUE_MASK        0x0000ffff
-#define MAC_PCU_ADDR1_MASK_U16_VALUE_GET(x)      (((x) & MAC_PCU_ADDR1_MASK_U16_VALUE_MASK) >> MAC_PCU_ADDR1_MASK_U16_VALUE_LSB)
-#define MAC_PCU_ADDR1_MASK_U16_VALUE_SET(x)      (((x) << MAC_PCU_ADDR1_MASK_U16_VALUE_LSB) & MAC_PCU_ADDR1_MASK_U16_VALUE_MASK)
-
-#define MAC_PCU_TPC_ADDRESS                      0x0000808c
-#define MAC_PCU_TPC_OFFSET                       0x0000008c
-#define MAC_PCU_TPC_CHIRP_PWR_MSB                21
-#define MAC_PCU_TPC_CHIRP_PWR_LSB                16
-#define MAC_PCU_TPC_CHIRP_PWR_MASK               0x003f0000
-#define MAC_PCU_TPC_CHIRP_PWR_GET(x)             (((x) & MAC_PCU_TPC_CHIRP_PWR_MASK) >> MAC_PCU_TPC_CHIRP_PWR_LSB)
-#define MAC_PCU_TPC_CHIRP_PWR_SET(x)             (((x) << MAC_PCU_TPC_CHIRP_PWR_LSB) & MAC_PCU_TPC_CHIRP_PWR_MASK)
-#define MAC_PCU_TPC_CTS_PWR_MSB                  13
-#define MAC_PCU_TPC_CTS_PWR_LSB                  8
-#define MAC_PCU_TPC_CTS_PWR_MASK                 0x00003f00
-#define MAC_PCU_TPC_CTS_PWR_GET(x)               (((x) & MAC_PCU_TPC_CTS_PWR_MASK) >> MAC_PCU_TPC_CTS_PWR_LSB)
-#define MAC_PCU_TPC_CTS_PWR_SET(x)               (((x) << MAC_PCU_TPC_CTS_PWR_LSB) & MAC_PCU_TPC_CTS_PWR_MASK)
-#define MAC_PCU_TPC_ACK_PWR_MSB                  5
-#define MAC_PCU_TPC_ACK_PWR_LSB                  0
-#define MAC_PCU_TPC_ACK_PWR_MASK                 0x0000003f
-#define MAC_PCU_TPC_ACK_PWR_GET(x)               (((x) & MAC_PCU_TPC_ACK_PWR_MASK) >> MAC_PCU_TPC_ACK_PWR_LSB)
-#define MAC_PCU_TPC_ACK_PWR_SET(x)               (((x) << MAC_PCU_TPC_ACK_PWR_LSB) & MAC_PCU_TPC_ACK_PWR_MASK)
-
-#define MAC_PCU_TX_FRAME_CNT_ADDRESS             0x00008090
-#define MAC_PCU_TX_FRAME_CNT_OFFSET              0x00000090
-#define MAC_PCU_TX_FRAME_CNT_VALUE_MSB           31
-#define MAC_PCU_TX_FRAME_CNT_VALUE_LSB           0
-#define MAC_PCU_TX_FRAME_CNT_VALUE_MASK          0xffffffff
-#define MAC_PCU_TX_FRAME_CNT_VALUE_GET(x)        (((x) & MAC_PCU_TX_FRAME_CNT_VALUE_MASK) >> MAC_PCU_TX_FRAME_CNT_VALUE_LSB)
-#define MAC_PCU_TX_FRAME_CNT_VALUE_SET(x)        (((x) << MAC_PCU_TX_FRAME_CNT_VALUE_LSB) & MAC_PCU_TX_FRAME_CNT_VALUE_MASK)
-
-#define MAC_PCU_RX_FRAME_CNT_ADDRESS             0x00008094
-#define MAC_PCU_RX_FRAME_CNT_OFFSET              0x00000094
-#define MAC_PCU_RX_FRAME_CNT_VALUE_MSB           31
-#define MAC_PCU_RX_FRAME_CNT_VALUE_LSB           0
-#define MAC_PCU_RX_FRAME_CNT_VALUE_MASK          0xffffffff
-#define MAC_PCU_RX_FRAME_CNT_VALUE_GET(x)        (((x) & MAC_PCU_RX_FRAME_CNT_VALUE_MASK) >> MAC_PCU_RX_FRAME_CNT_VALUE_LSB)
-#define MAC_PCU_RX_FRAME_CNT_VALUE_SET(x)        (((x) << MAC_PCU_RX_FRAME_CNT_VALUE_LSB) & MAC_PCU_RX_FRAME_CNT_VALUE_MASK)
-
-#define MAC_PCU_RX_CLEAR_CNT_ADDRESS             0x00008098
-#define MAC_PCU_RX_CLEAR_CNT_OFFSET              0x00000098
-#define MAC_PCU_RX_CLEAR_CNT_VALUE_MSB           31
-#define MAC_PCU_RX_CLEAR_CNT_VALUE_LSB           0
-#define MAC_PCU_RX_CLEAR_CNT_VALUE_MASK          0xffffffff
-#define MAC_PCU_RX_CLEAR_CNT_VALUE_GET(x)        (((x) & MAC_PCU_RX_CLEAR_CNT_VALUE_MASK) >> MAC_PCU_RX_CLEAR_CNT_VALUE_LSB)
-#define MAC_PCU_RX_CLEAR_CNT_VALUE_SET(x)        (((x) << MAC_PCU_RX_CLEAR_CNT_VALUE_LSB) & MAC_PCU_RX_CLEAR_CNT_VALUE_MASK)
-
-#define MAC_PCU_CYCLE_CNT_ADDRESS                0x0000809c
-#define MAC_PCU_CYCLE_CNT_OFFSET                 0x0000009c
-#define MAC_PCU_CYCLE_CNT_VALUE_MSB              31
-#define MAC_PCU_CYCLE_CNT_VALUE_LSB              0
-#define MAC_PCU_CYCLE_CNT_VALUE_MASK             0xffffffff
-#define MAC_PCU_CYCLE_CNT_VALUE_GET(x)           (((x) & MAC_PCU_CYCLE_CNT_VALUE_MASK) >> MAC_PCU_CYCLE_CNT_VALUE_LSB)
-#define MAC_PCU_CYCLE_CNT_VALUE_SET(x)           (((x) << MAC_PCU_CYCLE_CNT_VALUE_LSB) & MAC_PCU_CYCLE_CNT_VALUE_MASK)
-
-#define MAC_PCU_QUIET_TIME_1_ADDRESS             0x000080a0
-#define MAC_PCU_QUIET_TIME_1_OFFSET              0x000000a0
-#define MAC_PCU_QUIET_TIME_1_ACK_CTS_ENABLE_MSB  17
-#define MAC_PCU_QUIET_TIME_1_ACK_CTS_ENABLE_LSB  17
-#define MAC_PCU_QUIET_TIME_1_ACK_CTS_ENABLE_MASK 0x00020000
-#define MAC_PCU_QUIET_TIME_1_ACK_CTS_ENABLE_GET(x) (((x) & MAC_PCU_QUIET_TIME_1_ACK_CTS_ENABLE_MASK) >> MAC_PCU_QUIET_TIME_1_ACK_CTS_ENABLE_LSB)
-#define MAC_PCU_QUIET_TIME_1_ACK_CTS_ENABLE_SET(x) (((x) << MAC_PCU_QUIET_TIME_1_ACK_CTS_ENABLE_LSB) & MAC_PCU_QUIET_TIME_1_ACK_CTS_ENABLE_MASK)
-
-#define MAC_PCU_QUIET_TIME_2_ADDRESS             0x000080a4
-#define MAC_PCU_QUIET_TIME_2_OFFSET              0x000000a4
-#define MAC_PCU_QUIET_TIME_2_DURATION_MSB        31
-#define MAC_PCU_QUIET_TIME_2_DURATION_LSB        16
-#define MAC_PCU_QUIET_TIME_2_DURATION_MASK       0xffff0000
-#define MAC_PCU_QUIET_TIME_2_DURATION_GET(x)     (((x) & MAC_PCU_QUIET_TIME_2_DURATION_MASK) >> MAC_PCU_QUIET_TIME_2_DURATION_LSB)
-#define MAC_PCU_QUIET_TIME_2_DURATION_SET(x)     (((x) << MAC_PCU_QUIET_TIME_2_DURATION_LSB) & MAC_PCU_QUIET_TIME_2_DURATION_MASK)
-
-#define MAC_PCU_QOS_NO_ACK_ADDRESS               0x000080a8
-#define MAC_PCU_QOS_NO_ACK_OFFSET                0x000000a8
-#define MAC_PCU_QOS_NO_ACK_BYTE_OFFSET_MSB       8
-#define MAC_PCU_QOS_NO_ACK_BYTE_OFFSET_LSB       7
-#define MAC_PCU_QOS_NO_ACK_BYTE_OFFSET_MASK      0x00000180
-#define MAC_PCU_QOS_NO_ACK_BYTE_OFFSET_GET(x)    (((x) & MAC_PCU_QOS_NO_ACK_BYTE_OFFSET_MASK) >> MAC_PCU_QOS_NO_ACK_BYTE_OFFSET_LSB)
-#define MAC_PCU_QOS_NO_ACK_BYTE_OFFSET_SET(x)    (((x) << MAC_PCU_QOS_NO_ACK_BYTE_OFFSET_LSB) & MAC_PCU_QOS_NO_ACK_BYTE_OFFSET_MASK)
-#define MAC_PCU_QOS_NO_ACK_BIT_OFFSET_MSB        6
-#define MAC_PCU_QOS_NO_ACK_BIT_OFFSET_LSB        4
-#define MAC_PCU_QOS_NO_ACK_BIT_OFFSET_MASK       0x00000070
-#define MAC_PCU_QOS_NO_ACK_BIT_OFFSET_GET(x)     (((x) & MAC_PCU_QOS_NO_ACK_BIT_OFFSET_MASK) >> MAC_PCU_QOS_NO_ACK_BIT_OFFSET_LSB)
-#define MAC_PCU_QOS_NO_ACK_BIT_OFFSET_SET(x)     (((x) << MAC_PCU_QOS_NO_ACK_BIT_OFFSET_LSB) & MAC_PCU_QOS_NO_ACK_BIT_OFFSET_MASK)
-#define MAC_PCU_QOS_NO_ACK_TWO_BIT_VALUES_MSB    3
-#define MAC_PCU_QOS_NO_ACK_TWO_BIT_VALUES_LSB    0
-#define MAC_PCU_QOS_NO_ACK_TWO_BIT_VALUES_MASK   0x0000000f
-#define MAC_PCU_QOS_NO_ACK_TWO_BIT_VALUES_GET(x) (((x) & MAC_PCU_QOS_NO_ACK_TWO_BIT_VALUES_MASK) >> MAC_PCU_QOS_NO_ACK_TWO_BIT_VALUES_LSB)
-#define MAC_PCU_QOS_NO_ACK_TWO_BIT_VALUES_SET(x) (((x) << MAC_PCU_QOS_NO_ACK_TWO_BIT_VALUES_LSB) & MAC_PCU_QOS_NO_ACK_TWO_BIT_VALUES_MASK)
-
-#define MAC_PCU_PHY_ERROR_MASK_ADDRESS           0x000080ac
-#define MAC_PCU_PHY_ERROR_MASK_OFFSET            0x000000ac
-#define MAC_PCU_PHY_ERROR_MASK_VALUE_MSB         31
-#define MAC_PCU_PHY_ERROR_MASK_VALUE_LSB         0
-#define MAC_PCU_PHY_ERROR_MASK_VALUE_MASK        0xffffffff
-#define MAC_PCU_PHY_ERROR_MASK_VALUE_GET(x)      (((x) & MAC_PCU_PHY_ERROR_MASK_VALUE_MASK) >> MAC_PCU_PHY_ERROR_MASK_VALUE_LSB)
-#define MAC_PCU_PHY_ERROR_MASK_VALUE_SET(x)      (((x) << MAC_PCU_PHY_ERROR_MASK_VALUE_LSB) & MAC_PCU_PHY_ERROR_MASK_VALUE_MASK)
-
-#define MAC_PCU_XRLAT_ADDRESS                    0x000080b0
-#define MAC_PCU_XRLAT_OFFSET                     0x000000b0
-#define MAC_PCU_XRLAT_VALUE_MSB                  11
-#define MAC_PCU_XRLAT_VALUE_LSB                  0
-#define MAC_PCU_XRLAT_VALUE_MASK                 0x00000fff
-#define MAC_PCU_XRLAT_VALUE_GET(x)               (((x) & MAC_PCU_XRLAT_VALUE_MASK) >> MAC_PCU_XRLAT_VALUE_LSB)
-#define MAC_PCU_XRLAT_VALUE_SET(x)               (((x) << MAC_PCU_XRLAT_VALUE_LSB) & MAC_PCU_XRLAT_VALUE_MASK)
-
-#define MAC_PCU_RXBUF_ADDRESS                    0x000080b4
-#define MAC_PCU_RXBUF_OFFSET                     0x000000b4
-#define MAC_PCU_RXBUF_REG_RD_ENABLE_MSB          11
-#define MAC_PCU_RXBUF_REG_RD_ENABLE_LSB          11
-#define MAC_PCU_RXBUF_REG_RD_ENABLE_MASK         0x00000800
-#define MAC_PCU_RXBUF_REG_RD_ENABLE_GET(x)       (((x) & MAC_PCU_RXBUF_REG_RD_ENABLE_MASK) >> MAC_PCU_RXBUF_REG_RD_ENABLE_LSB)
-#define MAC_PCU_RXBUF_REG_RD_ENABLE_SET(x)       (((x) << MAC_PCU_RXBUF_REG_RD_ENABLE_LSB) & MAC_PCU_RXBUF_REG_RD_ENABLE_MASK)
-#define MAC_PCU_RXBUF_HIGH_PRIORITY_THRSHD_MSB   10
-#define MAC_PCU_RXBUF_HIGH_PRIORITY_THRSHD_LSB   0
-#define MAC_PCU_RXBUF_HIGH_PRIORITY_THRSHD_MASK  0x000007ff
-#define MAC_PCU_RXBUF_HIGH_PRIORITY_THRSHD_GET(x) (((x) & MAC_PCU_RXBUF_HIGH_PRIORITY_THRSHD_MASK) >> MAC_PCU_RXBUF_HIGH_PRIORITY_THRSHD_LSB)
-#define MAC_PCU_RXBUF_HIGH_PRIORITY_THRSHD_SET(x) (((x) << MAC_PCU_RXBUF_HIGH_PRIORITY_THRSHD_LSB) & MAC_PCU_RXBUF_HIGH_PRIORITY_THRSHD_MASK)
-
-#define MAC_PCU_MIC_QOS_CONTROL_ADDRESS          0x000080b8
-#define MAC_PCU_MIC_QOS_CONTROL_OFFSET           0x000000b8
-#define MAC_PCU_MIC_QOS_CONTROL_ENABLE_MSB       16
-#define MAC_PCU_MIC_QOS_CONTROL_ENABLE_LSB       16
-#define MAC_PCU_MIC_QOS_CONTROL_ENABLE_MASK      0x00010000
-#define MAC_PCU_MIC_QOS_CONTROL_ENABLE_GET(x)    (((x) & MAC_PCU_MIC_QOS_CONTROL_ENABLE_MASK) >> MAC_PCU_MIC_QOS_CONTROL_ENABLE_LSB)
-#define MAC_PCU_MIC_QOS_CONTROL_ENABLE_SET(x)    (((x) << MAC_PCU_MIC_QOS_CONTROL_ENABLE_LSB) & MAC_PCU_MIC_QOS_CONTROL_ENABLE_MASK)
-#define MAC_PCU_MIC_QOS_CONTROL_VALUE_7_MSB      15
-#define MAC_PCU_MIC_QOS_CONTROL_VALUE_7_LSB      14
-#define MAC_PCU_MIC_QOS_CONTROL_VALUE_7_MASK     0x0000c000
-#define MAC_PCU_MIC_QOS_CONTROL_VALUE_7_GET(x)   (((x) & MAC_PCU_MIC_QOS_CONTROL_VALUE_7_MASK) >> MAC_PCU_MIC_QOS_CONTROL_VALUE_7_LSB)
-#define MAC_PCU_MIC_QOS_CONTROL_VALUE_7_SET(x)   (((x) << MAC_PCU_MIC_QOS_CONTROL_VALUE_7_LSB) & MAC_PCU_MIC_QOS_CONTROL_VALUE_7_MASK)
-#define MAC_PCU_MIC_QOS_CONTROL_VALUE_6_MSB      13
-#define MAC_PCU_MIC_QOS_CONTROL_VALUE_6_LSB      12
-#define MAC_PCU_MIC_QOS_CONTROL_VALUE_6_MASK     0x00003000
-#define MAC_PCU_MIC_QOS_CONTROL_VALUE_6_GET(x)   (((x) & MAC_PCU_MIC_QOS_CONTROL_VALUE_6_MASK) >> MAC_PCU_MIC_QOS_CONTROL_VALUE_6_LSB)
-#define MAC_PCU_MIC_QOS_CONTROL_VALUE_6_SET(x)   (((x) << MAC_PCU_MIC_QOS_CONTROL_VALUE_6_LSB) & MAC_PCU_MIC_QOS_CONTROL_VALUE_6_MASK)
-#define MAC_PCU_MIC_QOS_CONTROL_VALUE_5_MSB      11
-#define MAC_PCU_MIC_QOS_CONTROL_VALUE_5_LSB      10
-#define MAC_PCU_MIC_QOS_CONTROL_VALUE_5_MASK     0x00000c00
-#define MAC_PCU_MIC_QOS_CONTROL_VALUE_5_GET(x)   (((x) & MAC_PCU_MIC_QOS_CONTROL_VALUE_5_MASK) >> MAC_PCU_MIC_QOS_CONTROL_VALUE_5_LSB)
-#define MAC_PCU_MIC_QOS_CONTROL_VALUE_5_SET(x)   (((x) << MAC_PCU_MIC_QOS_CONTROL_VALUE_5_LSB) & MAC_PCU_MIC_QOS_CONTROL_VALUE_5_MASK)
-#define MAC_PCU_MIC_QOS_CONTROL_VALUE_4_MSB      9
-#define MAC_PCU_MIC_QOS_CONTROL_VALUE_4_LSB      8
-#define MAC_PCU_MIC_QOS_CONTROL_VALUE_4_MASK     0x00000300
-#define MAC_PCU_MIC_QOS_CONTROL_VALUE_4_GET(x)   (((x) & MAC_PCU_MIC_QOS_CONTROL_VALUE_4_MASK) >> MAC_PCU_MIC_QOS_CONTROL_VALUE_4_LSB)
-#define MAC_PCU_MIC_QOS_CONTROL_VALUE_4_SET(x)   (((x) << MAC_PCU_MIC_QOS_CONTROL_VALUE_4_LSB) & MAC_PCU_MIC_QOS_CONTROL_VALUE_4_MASK)
-#define MAC_PCU_MIC_QOS_CONTROL_VALUE_3_MSB      7
-#define MAC_PCU_MIC_QOS_CONTROL_VALUE_3_LSB      6
-#define MAC_PCU_MIC_QOS_CONTROL_VALUE_3_MASK     0x000000c0
-#define MAC_PCU_MIC_QOS_CONTROL_VALUE_3_GET(x)   (((x) & MAC_PCU_MIC_QOS_CONTROL_VALUE_3_MASK) >> MAC_PCU_MIC_QOS_CONTROL_VALUE_3_LSB)
-#define MAC_PCU_MIC_QOS_CONTROL_VALUE_3_SET(x)   (((x) << MAC_PCU_MIC_QOS_CONTROL_VALUE_3_LSB) & MAC_PCU_MIC_QOS_CONTROL_VALUE_3_MASK)
-#define MAC_PCU_MIC_QOS_CONTROL_VALUE_2_MSB      5
-#define MAC_PCU_MIC_QOS_CONTROL_VALUE_2_LSB      4
-#define MAC_PCU_MIC_QOS_CONTROL_VALUE_2_MASK     0x00000030
-#define MAC_PCU_MIC_QOS_CONTROL_VALUE_2_GET(x)   (((x) & MAC_PCU_MIC_QOS_CONTROL_VALUE_2_MASK) >> MAC_PCU_MIC_QOS_CONTROL_VALUE_2_LSB)
-#define MAC_PCU_MIC_QOS_CONTROL_VALUE_2_SET(x)   (((x) << MAC_PCU_MIC_QOS_CONTROL_VALUE_2_LSB) & MAC_PCU_MIC_QOS_CONTROL_VALUE_2_MASK)
-#define MAC_PCU_MIC_QOS_CONTROL_VALUE_1_MSB      3
-#define MAC_PCU_MIC_QOS_CONTROL_VALUE_1_LSB      2
-#define MAC_PCU_MIC_QOS_CONTROL_VALUE_1_MASK     0x0000000c
-#define MAC_PCU_MIC_QOS_CONTROL_VALUE_1_GET(x)   (((x) & MAC_PCU_MIC_QOS_CONTROL_VALUE_1_MASK) >> MAC_PCU_MIC_QOS_CONTROL_VALUE_1_LSB)
-#define MAC_PCU_MIC_QOS_CONTROL_VALUE_1_SET(x)   (((x) << MAC_PCU_MIC_QOS_CONTROL_VALUE_1_LSB) & MAC_PCU_MIC_QOS_CONTROL_VALUE_1_MASK)
-#define MAC_PCU_MIC_QOS_CONTROL_VALUE_0_MSB      1
-#define MAC_PCU_MIC_QOS_CONTROL_VALUE_0_LSB      0
-#define MAC_PCU_MIC_QOS_CONTROL_VALUE_0_MASK     0x00000003
-#define MAC_PCU_MIC_QOS_CONTROL_VALUE_0_GET(x)   (((x) & MAC_PCU_MIC_QOS_CONTROL_VALUE_0_MASK) >> MAC_PCU_MIC_QOS_CONTROL_VALUE_0_LSB)
-#define MAC_PCU_MIC_QOS_CONTROL_VALUE_0_SET(x)   (((x) << MAC_PCU_MIC_QOS_CONTROL_VALUE_0_LSB) & MAC_PCU_MIC_QOS_CONTROL_VALUE_0_MASK)
-
-#define MAC_PCU_MIC_QOS_SELECT_ADDRESS           0x000080bc
-#define MAC_PCU_MIC_QOS_SELECT_OFFSET            0x000000bc
-#define MAC_PCU_MIC_QOS_SELECT_VALUE_7_MSB       31
-#define MAC_PCU_MIC_QOS_SELECT_VALUE_7_LSB       28
-#define MAC_PCU_MIC_QOS_SELECT_VALUE_7_MASK      0xf0000000
-#define MAC_PCU_MIC_QOS_SELECT_VALUE_7_GET(x)    (((x) & MAC_PCU_MIC_QOS_SELECT_VALUE_7_MASK) >> MAC_PCU_MIC_QOS_SELECT_VALUE_7_LSB)
-#define MAC_PCU_MIC_QOS_SELECT_VALUE_7_SET(x)    (((x) << MAC_PCU_MIC_QOS_SELECT_VALUE_7_LSB) & MAC_PCU_MIC_QOS_SELECT_VALUE_7_MASK)
-#define MAC_PCU_MIC_QOS_SELECT_VALUE_6_MSB       27
-#define MAC_PCU_MIC_QOS_SELECT_VALUE_6_LSB       24
-#define MAC_PCU_MIC_QOS_SELECT_VALUE_6_MASK      0x0f000000
-#define MAC_PCU_MIC_QOS_SELECT_VALUE_6_GET(x)    (((x) & MAC_PCU_MIC_QOS_SELECT_VALUE_6_MASK) >> MAC_PCU_MIC_QOS_SELECT_VALUE_6_LSB)
-#define MAC_PCU_MIC_QOS_SELECT_VALUE_6_SET(x)    (((x) << MAC_PCU_MIC_QOS_SELECT_VALUE_6_LSB) & MAC_PCU_MIC_QOS_SELECT_VALUE_6_MASK)
-#define MAC_PCU_MIC_QOS_SELECT_VALUE_5_MSB       23
-#define MAC_PCU_MIC_QOS_SELECT_VALUE_5_LSB       20
-#define MAC_PCU_MIC_QOS_SELECT_VALUE_5_MASK      0x00f00000
-#define MAC_PCU_MIC_QOS_SELECT_VALUE_5_GET(x)    (((x) & MAC_PCU_MIC_QOS_SELECT_VALUE_5_MASK) >> MAC_PCU_MIC_QOS_SELECT_VALUE_5_LSB)
-#define MAC_PCU_MIC_QOS_SELECT_VALUE_5_SET(x)    (((x) << MAC_PCU_MIC_QOS_SELECT_VALUE_5_LSB) & MAC_PCU_MIC_QOS_SELECT_VALUE_5_MASK)
-#define MAC_PCU_MIC_QOS_SELECT_VALUE_4_MSB       19
-#define MAC_PCU_MIC_QOS_SELECT_VALUE_4_LSB       16
-#define MAC_PCU_MIC_QOS_SELECT_VALUE_4_MASK      0x000f0000
-#define MAC_PCU_MIC_QOS_SELECT_VALUE_4_GET(x)    (((x) & MAC_PCU_MIC_QOS_SELECT_VALUE_4_MASK) >> MAC_PCU_MIC_QOS_SELECT_VALUE_4_LSB)
-#define MAC_PCU_MIC_QOS_SELECT_VALUE_4_SET(x)    (((x) << MAC_PCU_MIC_QOS_SELECT_VALUE_4_LSB) & MAC_PCU_MIC_QOS_SELECT_VALUE_4_MASK)
-#define MAC_PCU_MIC_QOS_SELECT_VALUE_3_MSB       15
-#define MAC_PCU_MIC_QOS_SELECT_VALUE_3_LSB       12
-#define MAC_PCU_MIC_QOS_SELECT_VALUE_3_MASK      0x0000f000
-#define MAC_PCU_MIC_QOS_SELECT_VALUE_3_GET(x)    (((x) & MAC_PCU_MIC_QOS_SELECT_VALUE_3_MASK) >> MAC_PCU_MIC_QOS_SELECT_VALUE_3_LSB)
-#define MAC_PCU_MIC_QOS_SELECT_VALUE_3_SET(x)    (((x) << MAC_PCU_MIC_QOS_SELECT_VALUE_3_LSB) & MAC_PCU_MIC_QOS_SELECT_VALUE_3_MASK)
-#define MAC_PCU_MIC_QOS_SELECT_VALUE_2_MSB       11
-#define MAC_PCU_MIC_QOS_SELECT_VALUE_2_LSB       8
-#define MAC_PCU_MIC_QOS_SELECT_VALUE_2_MASK      0x00000f00
-#define MAC_PCU_MIC_QOS_SELECT_VALUE_2_GET(x)    (((x) & MAC_PCU_MIC_QOS_SELECT_VALUE_2_MASK) >> MAC_PCU_MIC_QOS_SELECT_VALUE_2_LSB)
-#define MAC_PCU_MIC_QOS_SELECT_VALUE_2_SET(x)    (((x) << MAC_PCU_MIC_QOS_SELECT_VALUE_2_LSB) & MAC_PCU_MIC_QOS_SELECT_VALUE_2_MASK)
-#define MAC_PCU_MIC_QOS_SELECT_VALUE_1_MSB       7
-#define MAC_PCU_MIC_QOS_SELECT_VALUE_1_LSB       4
-#define MAC_PCU_MIC_QOS_SELECT_VALUE_1_MASK      0x000000f0
-#define MAC_PCU_MIC_QOS_SELECT_VALUE_1_GET(x)    (((x) & MAC_PCU_MIC_QOS_SELECT_VALUE_1_MASK) >> MAC_PCU_MIC_QOS_SELECT_VALUE_1_LSB)
-#define MAC_PCU_MIC_QOS_SELECT_VALUE_1_SET(x)    (((x) << MAC_PCU_MIC_QOS_SELECT_VALUE_1_LSB) & MAC_PCU_MIC_QOS_SELECT_VALUE_1_MASK)
-#define MAC_PCU_MIC_QOS_SELECT_VALUE_0_MSB       3
-#define MAC_PCU_MIC_QOS_SELECT_VALUE_0_LSB       0
-#define MAC_PCU_MIC_QOS_SELECT_VALUE_0_MASK      0x0000000f
-#define MAC_PCU_MIC_QOS_SELECT_VALUE_0_GET(x)    (((x) & MAC_PCU_MIC_QOS_SELECT_VALUE_0_MASK) >> MAC_PCU_MIC_QOS_SELECT_VALUE_0_LSB)
-#define MAC_PCU_MIC_QOS_SELECT_VALUE_0_SET(x)    (((x) << MAC_PCU_MIC_QOS_SELECT_VALUE_0_LSB) & MAC_PCU_MIC_QOS_SELECT_VALUE_0_MASK)
-
-#define MAC_PCU_MISC_MODE_ADDRESS                0x000080c0
-#define MAC_PCU_MISC_MODE_OFFSET                 0x000000c0
-#define MAC_PCU_MISC_MODE_DEBUG_MODE_MSB         31
-#define MAC_PCU_MISC_MODE_DEBUG_MODE_LSB         30
-#define MAC_PCU_MISC_MODE_DEBUG_MODE_MASK        0xc0000000
-#define MAC_PCU_MISC_MODE_DEBUG_MODE_GET(x)      (((x) & MAC_PCU_MISC_MODE_DEBUG_MODE_MASK) >> MAC_PCU_MISC_MODE_DEBUG_MODE_LSB)
-#define MAC_PCU_MISC_MODE_DEBUG_MODE_SET(x)      (((x) << MAC_PCU_MISC_MODE_DEBUG_MODE_LSB) & MAC_PCU_MISC_MODE_DEBUG_MODE_MASK)
-#define MAC_PCU_MISC_MODE_USE_EOP_PTR_FOR_DMA_WR_MSB 29
-#define MAC_PCU_MISC_MODE_USE_EOP_PTR_FOR_DMA_WR_LSB 29
-#define MAC_PCU_MISC_MODE_USE_EOP_PTR_FOR_DMA_WR_MASK 0x20000000
-#define MAC_PCU_MISC_MODE_USE_EOP_PTR_FOR_DMA_WR_GET(x) (((x) & MAC_PCU_MISC_MODE_USE_EOP_PTR_FOR_DMA_WR_MASK) >> MAC_PCU_MISC_MODE_USE_EOP_PTR_FOR_DMA_WR_LSB)
-#define MAC_PCU_MISC_MODE_USE_EOP_PTR_FOR_DMA_WR_SET(x) (((x) << MAC_PCU_MISC_MODE_USE_EOP_PTR_FOR_DMA_WR_LSB) & MAC_PCU_MISC_MODE_USE_EOP_PTR_FOR_DMA_WR_MASK)
-#define MAC_PCU_MISC_MODE_ALWAYS_PERFORM_KEY_SEARCH_MSB 28
-#define MAC_PCU_MISC_MODE_ALWAYS_PERFORM_KEY_SEARCH_LSB 28
-#define MAC_PCU_MISC_MODE_ALWAYS_PERFORM_KEY_SEARCH_MASK 0x10000000
-#define MAC_PCU_MISC_MODE_ALWAYS_PERFORM_KEY_SEARCH_GET(x) (((x) & MAC_PCU_MISC_MODE_ALWAYS_PERFORM_KEY_SEARCH_MASK) >> MAC_PCU_MISC_MODE_ALWAYS_PERFORM_KEY_SEARCH_LSB)
-#define MAC_PCU_MISC_MODE_ALWAYS_PERFORM_KEY_SEARCH_SET(x) (((x) << MAC_PCU_MISC_MODE_ALWAYS_PERFORM_KEY_SEARCH_LSB) & MAC_PCU_MISC_MODE_ALWAYS_PERFORM_KEY_SEARCH_MASK)
-#define MAC_PCU_MISC_MODE_SEL_EVM_MSB            27
-#define MAC_PCU_MISC_MODE_SEL_EVM_LSB            27
-#define MAC_PCU_MISC_MODE_SEL_EVM_MASK           0x08000000
-#define MAC_PCU_MISC_MODE_SEL_EVM_GET(x)         (((x) & MAC_PCU_MISC_MODE_SEL_EVM_MASK) >> MAC_PCU_MISC_MODE_SEL_EVM_LSB)
-#define MAC_PCU_MISC_MODE_SEL_EVM_SET(x)         (((x) << MAC_PCU_MISC_MODE_SEL_EVM_LSB) & MAC_PCU_MISC_MODE_SEL_EVM_MASK)
-#define MAC_PCU_MISC_MODE_CLEAR_BA_VALID_MSB     26
-#define MAC_PCU_MISC_MODE_CLEAR_BA_VALID_LSB     26
-#define MAC_PCU_MISC_MODE_CLEAR_BA_VALID_MASK    0x04000000
-#define MAC_PCU_MISC_MODE_CLEAR_BA_VALID_GET(x)  (((x) & MAC_PCU_MISC_MODE_CLEAR_BA_VALID_MASK) >> MAC_PCU_MISC_MODE_CLEAR_BA_VALID_LSB)
-#define MAC_PCU_MISC_MODE_CLEAR_BA_VALID_SET(x)  (((x) << MAC_PCU_MISC_MODE_CLEAR_BA_VALID_LSB) & MAC_PCU_MISC_MODE_CLEAR_BA_VALID_MASK)
-#define MAC_PCU_MISC_MODE_CLEAR_FIRST_HCF_MSB    25
-#define MAC_PCU_MISC_MODE_CLEAR_FIRST_HCF_LSB    25
-#define MAC_PCU_MISC_MODE_CLEAR_FIRST_HCF_MASK   0x02000000
-#define MAC_PCU_MISC_MODE_CLEAR_FIRST_HCF_GET(x) (((x) & MAC_PCU_MISC_MODE_CLEAR_FIRST_HCF_MASK) >> MAC_PCU_MISC_MODE_CLEAR_FIRST_HCF_LSB)
-#define MAC_PCU_MISC_MODE_CLEAR_FIRST_HCF_SET(x) (((x) << MAC_PCU_MISC_MODE_CLEAR_FIRST_HCF_LSB) & MAC_PCU_MISC_MODE_CLEAR_FIRST_HCF_MASK)
-#define MAC_PCU_MISC_MODE_CLEAR_VMF_MSB          24
-#define MAC_PCU_MISC_MODE_CLEAR_VMF_LSB          24
-#define MAC_PCU_MISC_MODE_CLEAR_VMF_MASK         0x01000000
-#define MAC_PCU_MISC_MODE_CLEAR_VMF_GET(x)       (((x) & MAC_PCU_MISC_MODE_CLEAR_VMF_MASK) >> MAC_PCU_MISC_MODE_CLEAR_VMF_LSB)
-#define MAC_PCU_MISC_MODE_CLEAR_VMF_SET(x)       (((x) << MAC_PCU_MISC_MODE_CLEAR_VMF_LSB) & MAC_PCU_MISC_MODE_CLEAR_VMF_MASK)
-#define MAC_PCU_MISC_MODE_RX_HCF_POLL_ENABLE_MSB 23
-#define MAC_PCU_MISC_MODE_RX_HCF_POLL_ENABLE_LSB 23
-#define MAC_PCU_MISC_MODE_RX_HCF_POLL_ENABLE_MASK 0x00800000
-#define MAC_PCU_MISC_MODE_RX_HCF_POLL_ENABLE_GET(x) (((x) & MAC_PCU_MISC_MODE_RX_HCF_POLL_ENABLE_MASK) >> MAC_PCU_MISC_MODE_RX_HCF_POLL_ENABLE_LSB)
-#define MAC_PCU_MISC_MODE_RX_HCF_POLL_ENABLE_SET(x) (((x) << MAC_PCU_MISC_MODE_RX_HCF_POLL_ENABLE_LSB) & MAC_PCU_MISC_MODE_RX_HCF_POLL_ENABLE_MASK)
-#define MAC_PCU_MISC_MODE_HCF_POLL_CANCELS_NAV_MSB 22
-#define MAC_PCU_MISC_MODE_HCF_POLL_CANCELS_NAV_LSB 22
-#define MAC_PCU_MISC_MODE_HCF_POLL_CANCELS_NAV_MASK 0x00400000
-#define MAC_PCU_MISC_MODE_HCF_POLL_CANCELS_NAV_GET(x) (((x) & MAC_PCU_MISC_MODE_HCF_POLL_CANCELS_NAV_MASK) >> MAC_PCU_MISC_MODE_HCF_POLL_CANCELS_NAV_LSB)
-#define MAC_PCU_MISC_MODE_HCF_POLL_CANCELS_NAV_SET(x) (((x) << MAC_PCU_MISC_MODE_HCF_POLL_CANCELS_NAV_LSB) & MAC_PCU_MISC_MODE_HCF_POLL_CANCELS_NAV_MASK)
-#define MAC_PCU_MISC_MODE_TBTT_PROTECT_MSB       21
-#define MAC_PCU_MISC_MODE_TBTT_PROTECT_LSB       21
-#define MAC_PCU_MISC_MODE_TBTT_PROTECT_MASK      0x00200000
-#define MAC_PCU_MISC_MODE_TBTT_PROTECT_GET(x)    (((x) & MAC_PCU_MISC_MODE_TBTT_PROTECT_MASK) >> MAC_PCU_MISC_MODE_TBTT_PROTECT_LSB)
-#define MAC_PCU_MISC_MODE_TBTT_PROTECT_SET(x)    (((x) << MAC_PCU_MISC_MODE_TBTT_PROTECT_LSB) & MAC_PCU_MISC_MODE_TBTT_PROTECT_MASK)
-#define MAC_PCU_MISC_MODE_BT_ANT_PREVENTS_RX_MSB 20
-#define MAC_PCU_MISC_MODE_BT_ANT_PREVENTS_RX_LSB 20
-#define MAC_PCU_MISC_MODE_BT_ANT_PREVENTS_RX_MASK 0x00100000
-#define MAC_PCU_MISC_MODE_BT_ANT_PREVENTS_RX_GET(x) (((x) & MAC_PCU_MISC_MODE_BT_ANT_PREVENTS_RX_MASK) >> MAC_PCU_MISC_MODE_BT_ANT_PREVENTS_RX_LSB)
-#define MAC_PCU_MISC_MODE_BT_ANT_PREVENTS_RX_SET(x) (((x) << MAC_PCU_MISC_MODE_BT_ANT_PREVENTS_RX_LSB) & MAC_PCU_MISC_MODE_BT_ANT_PREVENTS_RX_MASK)
-#define MAC_PCU_MISC_MODE_FORCE_QUIET_COLLISION_MSB 18
-#define MAC_PCU_MISC_MODE_FORCE_QUIET_COLLISION_LSB 18
-#define MAC_PCU_MISC_MODE_FORCE_QUIET_COLLISION_MASK 0x00040000
-#define MAC_PCU_MISC_MODE_FORCE_QUIET_COLLISION_GET(x) (((x) & MAC_PCU_MISC_MODE_FORCE_QUIET_COLLISION_MASK) >> MAC_PCU_MISC_MODE_FORCE_QUIET_COLLISION_LSB)
-#define MAC_PCU_MISC_MODE_FORCE_QUIET_COLLISION_SET(x) (((x) << MAC_PCU_MISC_MODE_FORCE_QUIET_COLLISION_LSB) & MAC_PCU_MISC_MODE_FORCE_QUIET_COLLISION_MASK)
-#define MAC_PCU_MISC_MODE_MISS_BEACON_IN_SLEEP_MSB 14
-#define MAC_PCU_MISC_MODE_MISS_BEACON_IN_SLEEP_LSB 14
-#define MAC_PCU_MISC_MODE_MISS_BEACON_IN_SLEEP_MASK 0x00004000
-#define MAC_PCU_MISC_MODE_MISS_BEACON_IN_SLEEP_GET(x) (((x) & MAC_PCU_MISC_MODE_MISS_BEACON_IN_SLEEP_MASK) >> MAC_PCU_MISC_MODE_MISS_BEACON_IN_SLEEP_LSB)
-#define MAC_PCU_MISC_MODE_MISS_BEACON_IN_SLEEP_SET(x) (((x) << MAC_PCU_MISC_MODE_MISS_BEACON_IN_SLEEP_LSB) & MAC_PCU_MISC_MODE_MISS_BEACON_IN_SLEEP_MASK)
-#define MAC_PCU_MISC_MODE_TXOP_TBTT_LIMIT_ENABLE_MSB 12
-#define MAC_PCU_MISC_MODE_TXOP_TBTT_LIMIT_ENABLE_LSB 12
-#define MAC_PCU_MISC_MODE_TXOP_TBTT_LIMIT_ENABLE_MASK 0x00001000
-#define MAC_PCU_MISC_MODE_TXOP_TBTT_LIMIT_ENABLE_GET(x) (((x) & MAC_PCU_MISC_MODE_TXOP_TBTT_LIMIT_ENABLE_MASK) >> MAC_PCU_MISC_MODE_TXOP_TBTT_LIMIT_ENABLE_LSB)
-#define MAC_PCU_MISC_MODE_TXOP_TBTT_LIMIT_ENABLE_SET(x) (((x) << MAC_PCU_MISC_MODE_TXOP_TBTT_LIMIT_ENABLE_LSB) & MAC_PCU_MISC_MODE_TXOP_TBTT_LIMIT_ENABLE_MASK)
-#define MAC_PCU_MISC_MODE_KC_RX_ANT_UPDATE_MSB   11
-#define MAC_PCU_MISC_MODE_KC_RX_ANT_UPDATE_LSB   11
-#define MAC_PCU_MISC_MODE_KC_RX_ANT_UPDATE_MASK  0x00000800
-#define MAC_PCU_MISC_MODE_KC_RX_ANT_UPDATE_GET(x) (((x) & MAC_PCU_MISC_MODE_KC_RX_ANT_UPDATE_MASK) >> MAC_PCU_MISC_MODE_KC_RX_ANT_UPDATE_LSB)
-#define MAC_PCU_MISC_MODE_KC_RX_ANT_UPDATE_SET(x) (((x) << MAC_PCU_MISC_MODE_KC_RX_ANT_UPDATE_LSB) & MAC_PCU_MISC_MODE_KC_RX_ANT_UPDATE_MASK)
-#define MAC_PCU_MISC_MODE_DEBUG_MODE_SIFS_MSB    10
-#define MAC_PCU_MISC_MODE_DEBUG_MODE_SIFS_LSB    10
-#define MAC_PCU_MISC_MODE_DEBUG_MODE_SIFS_MASK   0x00000400
-#define MAC_PCU_MISC_MODE_DEBUG_MODE_SIFS_GET(x) (((x) & MAC_PCU_MISC_MODE_DEBUG_MODE_SIFS_MASK) >> MAC_PCU_MISC_MODE_DEBUG_MODE_SIFS_LSB)
-#define MAC_PCU_MISC_MODE_DEBUG_MODE_SIFS_SET(x) (((x) << MAC_PCU_MISC_MODE_DEBUG_MODE_SIFS_LSB) & MAC_PCU_MISC_MODE_DEBUG_MODE_SIFS_MASK)
-#define MAC_PCU_MISC_MODE_DEBUG_MODE_BA_BITMAP_MSB 9
-#define MAC_PCU_MISC_MODE_DEBUG_MODE_BA_BITMAP_LSB 9
-#define MAC_PCU_MISC_MODE_DEBUG_MODE_BA_BITMAP_MASK 0x00000200
-#define MAC_PCU_MISC_MODE_DEBUG_MODE_BA_BITMAP_GET(x) (((x) & MAC_PCU_MISC_MODE_DEBUG_MODE_BA_BITMAP_MASK) >> MAC_PCU_MISC_MODE_DEBUG_MODE_BA_BITMAP_LSB)
-#define MAC_PCU_MISC_MODE_DEBUG_MODE_BA_BITMAP_SET(x) (((x) << MAC_PCU_MISC_MODE_DEBUG_MODE_BA_BITMAP_LSB) & MAC_PCU_MISC_MODE_DEBUG_MODE_BA_BITMAP_MASK)
-#define MAC_PCU_MISC_MODE_CCK_SIFS_MODE_MSB      4
-#define MAC_PCU_MISC_MODE_CCK_SIFS_MODE_LSB      4
-#define MAC_PCU_MISC_MODE_CCK_SIFS_MODE_MASK     0x00000010
-#define MAC_PCU_MISC_MODE_CCK_SIFS_MODE_GET(x)   (((x) & MAC_PCU_MISC_MODE_CCK_SIFS_MODE_MASK) >> MAC_PCU_MISC_MODE_CCK_SIFS_MODE_LSB)
-#define MAC_PCU_MISC_MODE_CCK_SIFS_MODE_SET(x)   (((x) << MAC_PCU_MISC_MODE_CCK_SIFS_MODE_LSB) & MAC_PCU_MISC_MODE_CCK_SIFS_MODE_MASK)
-#define MAC_PCU_MISC_MODE_TX_ADD_TSF_MSB         3
-#define MAC_PCU_MISC_MODE_TX_ADD_TSF_LSB         3
-#define MAC_PCU_MISC_MODE_TX_ADD_TSF_MASK        0x00000008
-#define MAC_PCU_MISC_MODE_TX_ADD_TSF_GET(x)      (((x) & MAC_PCU_MISC_MODE_TX_ADD_TSF_MASK) >> MAC_PCU_MISC_MODE_TX_ADD_TSF_LSB)
-#define MAC_PCU_MISC_MODE_TX_ADD_TSF_SET(x)      (((x) << MAC_PCU_MISC_MODE_TX_ADD_TSF_LSB) & MAC_PCU_MISC_MODE_TX_ADD_TSF_MASK)
-#define MAC_PCU_MISC_MODE_MIC_NEW_LOCATION_ENABLE_MSB 2
-#define MAC_PCU_MISC_MODE_MIC_NEW_LOCATION_ENABLE_LSB 2
-#define MAC_PCU_MISC_MODE_MIC_NEW_LOCATION_ENABLE_MASK 0x00000004
-#define MAC_PCU_MISC_MODE_MIC_NEW_LOCATION_ENABLE_GET(x) (((x) & MAC_PCU_MISC_MODE_MIC_NEW_LOCATION_ENABLE_MASK) >> MAC_PCU_MISC_MODE_MIC_NEW_LOCATION_ENABLE_LSB)
-#define MAC_PCU_MISC_MODE_MIC_NEW_LOCATION_ENABLE_SET(x) (((x) << MAC_PCU_MISC_MODE_MIC_NEW_LOCATION_ENABLE_LSB) & MAC_PCU_MISC_MODE_MIC_NEW_LOCATION_ENABLE_MASK)
-#define MAC_PCU_MISC_MODE_DEBUG_MODE_AD_MSB      1
-#define MAC_PCU_MISC_MODE_DEBUG_MODE_AD_LSB      1
-#define MAC_PCU_MISC_MODE_DEBUG_MODE_AD_MASK     0x00000002
-#define MAC_PCU_MISC_MODE_DEBUG_MODE_AD_GET(x)   (((x) & MAC_PCU_MISC_MODE_DEBUG_MODE_AD_MASK) >> MAC_PCU_MISC_MODE_DEBUG_MODE_AD_LSB)
-#define MAC_PCU_MISC_MODE_DEBUG_MODE_AD_SET(x)   (((x) << MAC_PCU_MISC_MODE_DEBUG_MODE_AD_LSB) & MAC_PCU_MISC_MODE_DEBUG_MODE_AD_MASK)
-#define MAC_PCU_MISC_MODE_BSSID_MATCH_FORCE_MSB  0
-#define MAC_PCU_MISC_MODE_BSSID_MATCH_FORCE_LSB  0
-#define MAC_PCU_MISC_MODE_BSSID_MATCH_FORCE_MASK 0x00000001
-#define MAC_PCU_MISC_MODE_BSSID_MATCH_FORCE_GET(x) (((x) & MAC_PCU_MISC_MODE_BSSID_MATCH_FORCE_MASK) >> MAC_PCU_MISC_MODE_BSSID_MATCH_FORCE_LSB)
-#define MAC_PCU_MISC_MODE_BSSID_MATCH_FORCE_SET(x) (((x) << MAC_PCU_MISC_MODE_BSSID_MATCH_FORCE_LSB) & MAC_PCU_MISC_MODE_BSSID_MATCH_FORCE_MASK)
-
-#define MAC_PCU_FILTER_OFDM_CNT_ADDRESS          0x000080c4
-#define MAC_PCU_FILTER_OFDM_CNT_OFFSET           0x000000c4
-#define MAC_PCU_FILTER_OFDM_CNT_VALUE_MSB        23
-#define MAC_PCU_FILTER_OFDM_CNT_VALUE_LSB        0
-#define MAC_PCU_FILTER_OFDM_CNT_VALUE_MASK       0x00ffffff
-#define MAC_PCU_FILTER_OFDM_CNT_VALUE_GET(x)     (((x) & MAC_PCU_FILTER_OFDM_CNT_VALUE_MASK) >> MAC_PCU_FILTER_OFDM_CNT_VALUE_LSB)
-#define MAC_PCU_FILTER_OFDM_CNT_VALUE_SET(x)     (((x) << MAC_PCU_FILTER_OFDM_CNT_VALUE_LSB) & MAC_PCU_FILTER_OFDM_CNT_VALUE_MASK)
-
-#define MAC_PCU_FILTER_CCK_CNT_ADDRESS           0x000080c8
-#define MAC_PCU_FILTER_CCK_CNT_OFFSET            0x000000c8
-#define MAC_PCU_FILTER_CCK_CNT_VALUE_MSB         23
-#define MAC_PCU_FILTER_CCK_CNT_VALUE_LSB         0
-#define MAC_PCU_FILTER_CCK_CNT_VALUE_MASK        0x00ffffff
-#define MAC_PCU_FILTER_CCK_CNT_VALUE_GET(x)      (((x) & MAC_PCU_FILTER_CCK_CNT_VALUE_MASK) >> MAC_PCU_FILTER_CCK_CNT_VALUE_LSB)
-#define MAC_PCU_FILTER_CCK_CNT_VALUE_SET(x)      (((x) << MAC_PCU_FILTER_CCK_CNT_VALUE_LSB) & MAC_PCU_FILTER_CCK_CNT_VALUE_MASK)
-
-#define MAC_PCU_PHY_ERR_CNT_1_ADDRESS            0x000080cc
-#define MAC_PCU_PHY_ERR_CNT_1_OFFSET             0x000000cc
-#define MAC_PCU_PHY_ERR_CNT_1_VALUE_MSB          23
-#define MAC_PCU_PHY_ERR_CNT_1_VALUE_LSB          0
-#define MAC_PCU_PHY_ERR_CNT_1_VALUE_MASK         0x00ffffff
-#define MAC_PCU_PHY_ERR_CNT_1_VALUE_GET(x)       (((x) & MAC_PCU_PHY_ERR_CNT_1_VALUE_MASK) >> MAC_PCU_PHY_ERR_CNT_1_VALUE_LSB)
-#define MAC_PCU_PHY_ERR_CNT_1_VALUE_SET(x)       (((x) << MAC_PCU_PHY_ERR_CNT_1_VALUE_LSB) & MAC_PCU_PHY_ERR_CNT_1_VALUE_MASK)
-
-#define MAC_PCU_PHY_ERR_CNT_1_MASK_ADDRESS       0x000080d0
-#define MAC_PCU_PHY_ERR_CNT_1_MASK_OFFSET        0x000000d0
-#define MAC_PCU_PHY_ERR_CNT_1_MASK_VALUE_MSB     31
-#define MAC_PCU_PHY_ERR_CNT_1_MASK_VALUE_LSB     0
-#define MAC_PCU_PHY_ERR_CNT_1_MASK_VALUE_MASK    0xffffffff
-#define MAC_PCU_PHY_ERR_CNT_1_MASK_VALUE_GET(x)  (((x) & MAC_PCU_PHY_ERR_CNT_1_MASK_VALUE_MASK) >> MAC_PCU_PHY_ERR_CNT_1_MASK_VALUE_LSB)
-#define MAC_PCU_PHY_ERR_CNT_1_MASK_VALUE_SET(x)  (((x) << MAC_PCU_PHY_ERR_CNT_1_MASK_VALUE_LSB) & MAC_PCU_PHY_ERR_CNT_1_MASK_VALUE_MASK)
-
-#define MAC_PCU_PHY_ERR_CNT_2_ADDRESS            0x000080d4
-#define MAC_PCU_PHY_ERR_CNT_2_OFFSET             0x000000d4
-#define MAC_PCU_PHY_ERR_CNT_2_VALUE_MSB          23
-#define MAC_PCU_PHY_ERR_CNT_2_VALUE_LSB          0
-#define MAC_PCU_PHY_ERR_CNT_2_VALUE_MASK         0x00ffffff
-#define MAC_PCU_PHY_ERR_CNT_2_VALUE_GET(x)       (((x) & MAC_PCU_PHY_ERR_CNT_2_VALUE_MASK) >> MAC_PCU_PHY_ERR_CNT_2_VALUE_LSB)
-#define MAC_PCU_PHY_ERR_CNT_2_VALUE_SET(x)       (((x) << MAC_PCU_PHY_ERR_CNT_2_VALUE_LSB) & MAC_PCU_PHY_ERR_CNT_2_VALUE_MASK)
-
-#define MAC_PCU_PHY_ERR_CNT_2_MASK_ADDRESS       0x000080d8
-#define MAC_PCU_PHY_ERR_CNT_2_MASK_OFFSET        0x000000d8
-#define MAC_PCU_PHY_ERR_CNT_2_MASK_VALUE_MSB     31
-#define MAC_PCU_PHY_ERR_CNT_2_MASK_VALUE_LSB     0
-#define MAC_PCU_PHY_ERR_CNT_2_MASK_VALUE_MASK    0xffffffff
-#define MAC_PCU_PHY_ERR_CNT_2_MASK_VALUE_GET(x)  (((x) & MAC_PCU_PHY_ERR_CNT_2_MASK_VALUE_MASK) >> MAC_PCU_PHY_ERR_CNT_2_MASK_VALUE_LSB)
-#define MAC_PCU_PHY_ERR_CNT_2_MASK_VALUE_SET(x)  (((x) << MAC_PCU_PHY_ERR_CNT_2_MASK_VALUE_LSB) & MAC_PCU_PHY_ERR_CNT_2_MASK_VALUE_MASK)
-
-#define MAC_PCU_TSF_THRESHOLD_ADDRESS            0x000080dc
-#define MAC_PCU_TSF_THRESHOLD_OFFSET             0x000000dc
-#define MAC_PCU_TSF_THRESHOLD_VALUE_MSB          15
-#define MAC_PCU_TSF_THRESHOLD_VALUE_LSB          0
-#define MAC_PCU_TSF_THRESHOLD_VALUE_MASK         0x0000ffff
-#define MAC_PCU_TSF_THRESHOLD_VALUE_GET(x)       (((x) & MAC_PCU_TSF_THRESHOLD_VALUE_MASK) >> MAC_PCU_TSF_THRESHOLD_VALUE_LSB)
-#define MAC_PCU_TSF_THRESHOLD_VALUE_SET(x)       (((x) << MAC_PCU_TSF_THRESHOLD_VALUE_LSB) & MAC_PCU_TSF_THRESHOLD_VALUE_MASK)
-
-#define MAC_PCU_PHY_ERROR_EIFS_MASK_ADDRESS      0x000080e0
-#define MAC_PCU_PHY_ERROR_EIFS_MASK_OFFSET       0x000000e0
-#define MAC_PCU_PHY_ERROR_EIFS_MASK_VALUE_MSB    31
-#define MAC_PCU_PHY_ERROR_EIFS_MASK_VALUE_LSB    0
-#define MAC_PCU_PHY_ERROR_EIFS_MASK_VALUE_MASK   0xffffffff
-#define MAC_PCU_PHY_ERROR_EIFS_MASK_VALUE_GET(x) (((x) & MAC_PCU_PHY_ERROR_EIFS_MASK_VALUE_MASK) >> MAC_PCU_PHY_ERROR_EIFS_MASK_VALUE_LSB)
-#define MAC_PCU_PHY_ERROR_EIFS_MASK_VALUE_SET(x) (((x) << MAC_PCU_PHY_ERROR_EIFS_MASK_VALUE_LSB) & MAC_PCU_PHY_ERROR_EIFS_MASK_VALUE_MASK)
-
-#define MAC_PCU_PHY_ERR_CNT_3_ADDRESS            0x000080e4
-#define MAC_PCU_PHY_ERR_CNT_3_OFFSET             0x000000e4
-#define MAC_PCU_PHY_ERR_CNT_3_VALUE_MSB          23
-#define MAC_PCU_PHY_ERR_CNT_3_VALUE_LSB          0
-#define MAC_PCU_PHY_ERR_CNT_3_VALUE_MASK         0x00ffffff
-#define MAC_PCU_PHY_ERR_CNT_3_VALUE_GET(x)       (((x) & MAC_PCU_PHY_ERR_CNT_3_VALUE_MASK) >> MAC_PCU_PHY_ERR_CNT_3_VALUE_LSB)
-#define MAC_PCU_PHY_ERR_CNT_3_VALUE_SET(x)       (((x) << MAC_PCU_PHY_ERR_CNT_3_VALUE_LSB) & MAC_PCU_PHY_ERR_CNT_3_VALUE_MASK)
-
-#define MAC_PCU_PHY_ERR_CNT_3_MASK_ADDRESS       0x000080e8
-#define MAC_PCU_PHY_ERR_CNT_3_MASK_OFFSET        0x000000e8
-#define MAC_PCU_PHY_ERR_CNT_3_MASK_VALUE_MSB     31
-#define MAC_PCU_PHY_ERR_CNT_3_MASK_VALUE_LSB     0
-#define MAC_PCU_PHY_ERR_CNT_3_MASK_VALUE_MASK    0xffffffff
-#define MAC_PCU_PHY_ERR_CNT_3_MASK_VALUE_GET(x)  (((x) & MAC_PCU_PHY_ERR_CNT_3_MASK_VALUE_MASK) >> MAC_PCU_PHY_ERR_CNT_3_MASK_VALUE_LSB)
-#define MAC_PCU_PHY_ERR_CNT_3_MASK_VALUE_SET(x)  (((x) << MAC_PCU_PHY_ERR_CNT_3_MASK_VALUE_LSB) & MAC_PCU_PHY_ERR_CNT_3_MASK_VALUE_MASK)
-
-#define MAC_PCU_BLUETOOTH_MODE_ADDRESS           0x000080ec
-#define MAC_PCU_BLUETOOTH_MODE_OFFSET            0x000000ec
-#define MAC_PCU_BLUETOOTH_MODE_FIRST_SLOT_TIME_MSB 31
-#define MAC_PCU_BLUETOOTH_MODE_FIRST_SLOT_TIME_LSB 24
-#define MAC_PCU_BLUETOOTH_MODE_FIRST_SLOT_TIME_MASK 0xff000000
-#define MAC_PCU_BLUETOOTH_MODE_FIRST_SLOT_TIME_GET(x) (((x) & MAC_PCU_BLUETOOTH_MODE_FIRST_SLOT_TIME_MASK) >> MAC_PCU_BLUETOOTH_MODE_FIRST_SLOT_TIME_LSB)
-#define MAC_PCU_BLUETOOTH_MODE_FIRST_SLOT_TIME_SET(x) (((x) << MAC_PCU_BLUETOOTH_MODE_FIRST_SLOT_TIME_LSB) & MAC_PCU_BLUETOOTH_MODE_FIRST_SLOT_TIME_MASK)
-#define MAC_PCU_BLUETOOTH_MODE_PRIORITY_TIME_MSB 23
-#define MAC_PCU_BLUETOOTH_MODE_PRIORITY_TIME_LSB 18
-#define MAC_PCU_BLUETOOTH_MODE_PRIORITY_TIME_MASK 0x00fc0000
-#define MAC_PCU_BLUETOOTH_MODE_PRIORITY_TIME_GET(x) (((x) & MAC_PCU_BLUETOOTH_MODE_PRIORITY_TIME_MASK) >> MAC_PCU_BLUETOOTH_MODE_PRIORITY_TIME_LSB)
-#define MAC_PCU_BLUETOOTH_MODE_PRIORITY_TIME_SET(x) (((x) << MAC_PCU_BLUETOOTH_MODE_PRIORITY_TIME_LSB) & MAC_PCU_BLUETOOTH_MODE_PRIORITY_TIME_MASK)
-#define MAC_PCU_BLUETOOTH_MODE_RX_CLEAR_POLARITY_MSB 17
-#define MAC_PCU_BLUETOOTH_MODE_RX_CLEAR_POLARITY_LSB 17
-#define MAC_PCU_BLUETOOTH_MODE_RX_CLEAR_POLARITY_MASK 0x00020000
-#define MAC_PCU_BLUETOOTH_MODE_RX_CLEAR_POLARITY_GET(x) (((x) & MAC_PCU_BLUETOOTH_MODE_RX_CLEAR_POLARITY_MASK) >> MAC_PCU_BLUETOOTH_MODE_RX_CLEAR_POLARITY_LSB)
-#define MAC_PCU_BLUETOOTH_MODE_RX_CLEAR_POLARITY_SET(x) (((x) << MAC_PCU_BLUETOOTH_MODE_RX_CLEAR_POLARITY_LSB) & MAC_PCU_BLUETOOTH_MODE_RX_CLEAR_POLARITY_MASK)
-#define MAC_PCU_BLUETOOTH_MODE_QCU_THRESH_MSB    16
-#define MAC_PCU_BLUETOOTH_MODE_QCU_THRESH_LSB    13
-#define MAC_PCU_BLUETOOTH_MODE_QCU_THRESH_MASK   0x0001e000
-#define MAC_PCU_BLUETOOTH_MODE_QCU_THRESH_GET(x) (((x) & MAC_PCU_BLUETOOTH_MODE_QCU_THRESH_MASK) >> MAC_PCU_BLUETOOTH_MODE_QCU_THRESH_LSB)
-#define MAC_PCU_BLUETOOTH_MODE_QCU_THRESH_SET(x) (((x) << MAC_PCU_BLUETOOTH_MODE_QCU_THRESH_LSB) & MAC_PCU_BLUETOOTH_MODE_QCU_THRESH_MASK)
-#define MAC_PCU_BLUETOOTH_MODE_QUIET_MSB         12
-#define MAC_PCU_BLUETOOTH_MODE_QUIET_LSB         12
-#define MAC_PCU_BLUETOOTH_MODE_QUIET_MASK        0x00001000
-#define MAC_PCU_BLUETOOTH_MODE_QUIET_GET(x)      (((x) & MAC_PCU_BLUETOOTH_MODE_QUIET_MASK) >> MAC_PCU_BLUETOOTH_MODE_QUIET_LSB)
-#define MAC_PCU_BLUETOOTH_MODE_QUIET_SET(x)      (((x) << MAC_PCU_BLUETOOTH_MODE_QUIET_LSB) & MAC_PCU_BLUETOOTH_MODE_QUIET_MASK)
-#define MAC_PCU_BLUETOOTH_MODE_MODE_MSB          11
-#define MAC_PCU_BLUETOOTH_MODE_MODE_LSB          10
-#define MAC_PCU_BLUETOOTH_MODE_MODE_MASK         0x00000c00
-#define MAC_PCU_BLUETOOTH_MODE_MODE_GET(x)       (((x) & MAC_PCU_BLUETOOTH_MODE_MODE_MASK) >> MAC_PCU_BLUETOOTH_MODE_MODE_LSB)
-#define MAC_PCU_BLUETOOTH_MODE_MODE_SET(x)       (((x) << MAC_PCU_BLUETOOTH_MODE_MODE_LSB) & MAC_PCU_BLUETOOTH_MODE_MODE_MASK)
-#define MAC_PCU_BLUETOOTH_MODE_TX_FRAME_EXTEND_MSB 9
-#define MAC_PCU_BLUETOOTH_MODE_TX_FRAME_EXTEND_LSB 9
-#define MAC_PCU_BLUETOOTH_MODE_TX_FRAME_EXTEND_MASK 0x00000200
-#define MAC_PCU_BLUETOOTH_MODE_TX_FRAME_EXTEND_GET(x) (((x) & MAC_PCU_BLUETOOTH_MODE_TX_FRAME_EXTEND_MASK) >> MAC_PCU_BLUETOOTH_MODE_TX_FRAME_EXTEND_LSB)
-#define MAC_PCU_BLUETOOTH_MODE_TX_FRAME_EXTEND_SET(x) (((x) << MAC_PCU_BLUETOOTH_MODE_TX_FRAME_EXTEND_LSB) & MAC_PCU_BLUETOOTH_MODE_TX_FRAME_EXTEND_MASK)
-#define MAC_PCU_BLUETOOTH_MODE_TX_STATE_EXTEND_MSB 8
-#define MAC_PCU_BLUETOOTH_MODE_TX_STATE_EXTEND_LSB 8
-#define MAC_PCU_BLUETOOTH_MODE_TX_STATE_EXTEND_MASK 0x00000100
-#define MAC_PCU_BLUETOOTH_MODE_TX_STATE_EXTEND_GET(x) (((x) & MAC_PCU_BLUETOOTH_MODE_TX_STATE_EXTEND_MASK) >> MAC_PCU_BLUETOOTH_MODE_TX_STATE_EXTEND_LSB)
-#define MAC_PCU_BLUETOOTH_MODE_TX_STATE_EXTEND_SET(x) (((x) << MAC_PCU_BLUETOOTH_MODE_TX_STATE_EXTEND_LSB) & MAC_PCU_BLUETOOTH_MODE_TX_STATE_EXTEND_MASK)
-#define MAC_PCU_BLUETOOTH_MODE_TIME_EXTEND_MSB   7
-#define MAC_PCU_BLUETOOTH_MODE_TIME_EXTEND_LSB   0
-#define MAC_PCU_BLUETOOTH_MODE_TIME_EXTEND_MASK  0x000000ff
-#define MAC_PCU_BLUETOOTH_MODE_TIME_EXTEND_GET(x) (((x) & MAC_PCU_BLUETOOTH_MODE_TIME_EXTEND_MASK) >> MAC_PCU_BLUETOOTH_MODE_TIME_EXTEND_LSB)
-#define MAC_PCU_BLUETOOTH_MODE_TIME_EXTEND_SET(x) (((x) << MAC_PCU_BLUETOOTH_MODE_TIME_EXTEND_LSB) & MAC_PCU_BLUETOOTH_MODE_TIME_EXTEND_MASK)
-
-#define MAC_PCU_BLUETOOTH_WEIGHTS_ADDRESS        0x000080f0
-#define MAC_PCU_BLUETOOTH_WEIGHTS_OFFSET         0x000000f0
-#define MAC_PCU_BLUETOOTH_WEIGHTS_WL_WEIGHT_MSB  31
-#define MAC_PCU_BLUETOOTH_WEIGHTS_WL_WEIGHT_LSB  16
-#define MAC_PCU_BLUETOOTH_WEIGHTS_WL_WEIGHT_MASK 0xffff0000
-#define MAC_PCU_BLUETOOTH_WEIGHTS_WL_WEIGHT_GET(x) (((x) & MAC_PCU_BLUETOOTH_WEIGHTS_WL_WEIGHT_MASK) >> MAC_PCU_BLUETOOTH_WEIGHTS_WL_WEIGHT_LSB)
-#define MAC_PCU_BLUETOOTH_WEIGHTS_WL_WEIGHT_SET(x) (((x) << MAC_PCU_BLUETOOTH_WEIGHTS_WL_WEIGHT_LSB) & MAC_PCU_BLUETOOTH_WEIGHTS_WL_WEIGHT_MASK)
-#define MAC_PCU_BLUETOOTH_WEIGHTS_BT_WEIGHT_MSB  15
-#define MAC_PCU_BLUETOOTH_WEIGHTS_BT_WEIGHT_LSB  0
-#define MAC_PCU_BLUETOOTH_WEIGHTS_BT_WEIGHT_MASK 0x0000ffff
-#define MAC_PCU_BLUETOOTH_WEIGHTS_BT_WEIGHT_GET(x) (((x) & MAC_PCU_BLUETOOTH_WEIGHTS_BT_WEIGHT_MASK) >> MAC_PCU_BLUETOOTH_WEIGHTS_BT_WEIGHT_LSB)
-#define MAC_PCU_BLUETOOTH_WEIGHTS_BT_WEIGHT_SET(x) (((x) << MAC_PCU_BLUETOOTH_WEIGHTS_BT_WEIGHT_LSB) & MAC_PCU_BLUETOOTH_WEIGHTS_BT_WEIGHT_MASK)
-
-#define MAC_PCU_BLUETOOTH_MODE2_ADDRESS          0x000080f4
-#define MAC_PCU_BLUETOOTH_MODE2_OFFSET           0x000000f4
-#define MAC_PCU_BLUETOOTH_MODE2_PHY_ERR_BT_COLL_ENABLE_MSB 31
-#define MAC_PCU_BLUETOOTH_MODE2_PHY_ERR_BT_COLL_ENABLE_LSB 31
-#define MAC_PCU_BLUETOOTH_MODE2_PHY_ERR_BT_COLL_ENABLE_MASK 0x80000000
-#define MAC_PCU_BLUETOOTH_MODE2_PHY_ERR_BT_COLL_ENABLE_GET(x) (((x) & MAC_PCU_BLUETOOTH_MODE2_PHY_ERR_BT_COLL_ENABLE_MASK) >> MAC_PCU_BLUETOOTH_MODE2_PHY_ERR_BT_COLL_ENABLE_LSB)
-#define MAC_PCU_BLUETOOTH_MODE2_PHY_ERR_BT_COLL_ENABLE_SET(x) (((x) << MAC_PCU_BLUETOOTH_MODE2_PHY_ERR_BT_COLL_ENABLE_LSB) & MAC_PCU_BLUETOOTH_MODE2_PHY_ERR_BT_COLL_ENABLE_MASK)
-#define MAC_PCU_BLUETOOTH_MODE2_INTERRUPT_ENABLE_MSB 30
-#define MAC_PCU_BLUETOOTH_MODE2_INTERRUPT_ENABLE_LSB 30
-#define MAC_PCU_BLUETOOTH_MODE2_INTERRUPT_ENABLE_MASK 0x40000000
-#define MAC_PCU_BLUETOOTH_MODE2_INTERRUPT_ENABLE_GET(x) (((x) & MAC_PCU_BLUETOOTH_MODE2_INTERRUPT_ENABLE_MASK) >> MAC_PCU_BLUETOOTH_MODE2_INTERRUPT_ENABLE_LSB)
-#define MAC_PCU_BLUETOOTH_MODE2_INTERRUPT_ENABLE_SET(x) (((x) << MAC_PCU_BLUETOOTH_MODE2_INTERRUPT_ENABLE_LSB) & MAC_PCU_BLUETOOTH_MODE2_INTERRUPT_ENABLE_MASK)
-#define MAC_PCU_BLUETOOTH_MODE2_TSF_BT_PRIORITY_CTRL_MSB 29
-#define MAC_PCU_BLUETOOTH_MODE2_TSF_BT_PRIORITY_CTRL_LSB 28
-#define MAC_PCU_BLUETOOTH_MODE2_TSF_BT_PRIORITY_CTRL_MASK 0x30000000
-#define MAC_PCU_BLUETOOTH_MODE2_TSF_BT_PRIORITY_CTRL_GET(x) (((x) & MAC_PCU_BLUETOOTH_MODE2_TSF_BT_PRIORITY_CTRL_MASK) >> MAC_PCU_BLUETOOTH_MODE2_TSF_BT_PRIORITY_CTRL_LSB)
-#define MAC_PCU_BLUETOOTH_MODE2_TSF_BT_PRIORITY_CTRL_SET(x) (((x) << MAC_PCU_BLUETOOTH_MODE2_TSF_BT_PRIORITY_CTRL_LSB) & MAC_PCU_BLUETOOTH_MODE2_TSF_BT_PRIORITY_CTRL_MASK)
-#define MAC_PCU_BLUETOOTH_MODE2_TSF_BT_ACTIVE_CTRL_MSB 27
-#define MAC_PCU_BLUETOOTH_MODE2_TSF_BT_ACTIVE_CTRL_LSB 26
-#define MAC_PCU_BLUETOOTH_MODE2_TSF_BT_ACTIVE_CTRL_MASK 0x0c000000
-#define MAC_PCU_BLUETOOTH_MODE2_TSF_BT_ACTIVE_CTRL_GET(x) (((x) & MAC_PCU_BLUETOOTH_MODE2_TSF_BT_ACTIVE_CTRL_MASK) >> MAC_PCU_BLUETOOTH_MODE2_TSF_BT_ACTIVE_CTRL_LSB)
-#define MAC_PCU_BLUETOOTH_MODE2_TSF_BT_ACTIVE_CTRL_SET(x) (((x) << MAC_PCU_BLUETOOTH_MODE2_TSF_BT_ACTIVE_CTRL_LSB) & MAC_PCU_BLUETOOTH_MODE2_TSF_BT_ACTIVE_CTRL_MASK)
-#define MAC_PCU_BLUETOOTH_MODE2_RS_DISCARD_EXTEND_MSB 25
-#define MAC_PCU_BLUETOOTH_MODE2_RS_DISCARD_EXTEND_LSB 25
-#define MAC_PCU_BLUETOOTH_MODE2_RS_DISCARD_EXTEND_MASK 0x02000000
-#define MAC_PCU_BLUETOOTH_MODE2_RS_DISCARD_EXTEND_GET(x) (((x) & MAC_PCU_BLUETOOTH_MODE2_RS_DISCARD_EXTEND_MASK) >> MAC_PCU_BLUETOOTH_MODE2_RS_DISCARD_EXTEND_LSB)
-#define MAC_PCU_BLUETOOTH_MODE2_RS_DISCARD_EXTEND_SET(x) (((x) << MAC_PCU_BLUETOOTH_MODE2_RS_DISCARD_EXTEND_LSB) & MAC_PCU_BLUETOOTH_MODE2_RS_DISCARD_EXTEND_MASK)
-#define MAC_PCU_BLUETOOTH_MODE2_WL_TXRX_SEPARATE_MSB 24
-#define MAC_PCU_BLUETOOTH_MODE2_WL_TXRX_SEPARATE_LSB 24
-#define MAC_PCU_BLUETOOTH_MODE2_WL_TXRX_SEPARATE_MASK 0x01000000
-#define MAC_PCU_BLUETOOTH_MODE2_WL_TXRX_SEPARATE_GET(x) (((x) & MAC_PCU_BLUETOOTH_MODE2_WL_TXRX_SEPARATE_MASK) >> MAC_PCU_BLUETOOTH_MODE2_WL_TXRX_SEPARATE_LSB)
-#define MAC_PCU_BLUETOOTH_MODE2_WL_TXRX_SEPARATE_SET(x) (((x) << MAC_PCU_BLUETOOTH_MODE2_WL_TXRX_SEPARATE_LSB) & MAC_PCU_BLUETOOTH_MODE2_WL_TXRX_SEPARATE_MASK)
-#define MAC_PCU_BLUETOOTH_MODE2_WL_ACTIVE_MODE_MSB 23
-#define MAC_PCU_BLUETOOTH_MODE2_WL_ACTIVE_MODE_LSB 22
-#define MAC_PCU_BLUETOOTH_MODE2_WL_ACTIVE_MODE_MASK 0x00c00000
-#define MAC_PCU_BLUETOOTH_MODE2_WL_ACTIVE_MODE_GET(x) (((x) & MAC_PCU_BLUETOOTH_MODE2_WL_ACTIVE_MODE_MASK) >> MAC_PCU_BLUETOOTH_MODE2_WL_ACTIVE_MODE_LSB)
-#define MAC_PCU_BLUETOOTH_MODE2_WL_ACTIVE_MODE_SET(x) (((x) << MAC_PCU_BLUETOOTH_MODE2_WL_ACTIVE_MODE_LSB) & MAC_PCU_BLUETOOTH_MODE2_WL_ACTIVE_MODE_MASK)
-#define MAC_PCU_BLUETOOTH_MODE2_QUIET_2_WIRE_MSB 21
-#define MAC_PCU_BLUETOOTH_MODE2_QUIET_2_WIRE_LSB 21
-#define MAC_PCU_BLUETOOTH_MODE2_QUIET_2_WIRE_MASK 0x00200000
-#define MAC_PCU_BLUETOOTH_MODE2_QUIET_2_WIRE_GET(x) (((x) & MAC_PCU_BLUETOOTH_MODE2_QUIET_2_WIRE_MASK) >> MAC_PCU_BLUETOOTH_MODE2_QUIET_2_WIRE_LSB)
-#define MAC_PCU_BLUETOOTH_MODE2_QUIET_2_WIRE_SET(x) (((x) << MAC_PCU_BLUETOOTH_MODE2_QUIET_2_WIRE_LSB) & MAC_PCU_BLUETOOTH_MODE2_QUIET_2_WIRE_MASK)
-#define MAC_PCU_BLUETOOTH_MODE2_DISABLE_BT_ANT_MSB 20
-#define MAC_PCU_BLUETOOTH_MODE2_DISABLE_BT_ANT_LSB 20
-#define MAC_PCU_BLUETOOTH_MODE2_DISABLE_BT_ANT_MASK 0x00100000
-#define MAC_PCU_BLUETOOTH_MODE2_DISABLE_BT_ANT_GET(x) (((x) & MAC_PCU_BLUETOOTH_MODE2_DISABLE_BT_ANT_MASK) >> MAC_PCU_BLUETOOTH_MODE2_DISABLE_BT_ANT_LSB)
-#define MAC_PCU_BLUETOOTH_MODE2_DISABLE_BT_ANT_SET(x) (((x) << MAC_PCU_BLUETOOTH_MODE2_DISABLE_BT_ANT_LSB) & MAC_PCU_BLUETOOTH_MODE2_DISABLE_BT_ANT_MASK)
-#define MAC_PCU_BLUETOOTH_MODE2_PROTECT_BT_AFTER_WAKEUP_MSB 19
-#define MAC_PCU_BLUETOOTH_MODE2_PROTECT_BT_AFTER_WAKEUP_LSB 19
-#define MAC_PCU_BLUETOOTH_MODE2_PROTECT_BT_AFTER_WAKEUP_MASK 0x00080000
-#define MAC_PCU_BLUETOOTH_MODE2_PROTECT_BT_AFTER_WAKEUP_GET(x) (((x) & MAC_PCU_BLUETOOTH_MODE2_PROTECT_BT_AFTER_WAKEUP_MASK) >> MAC_PCU_BLUETOOTH_MODE2_PROTECT_BT_AFTER_WAKEUP_LSB)
-#define MAC_PCU_BLUETOOTH_MODE2_PROTECT_BT_AFTER_WAKEUP_SET(x) (((x) << MAC_PCU_BLUETOOTH_MODE2_PROTECT_BT_AFTER_WAKEUP_LSB) & MAC_PCU_BLUETOOTH_MODE2_PROTECT_BT_AFTER_WAKEUP_MASK)
-#define MAC_PCU_BLUETOOTH_MODE2_SLEEP_ALLOW_BT_ACCESS_MSB 17
-#define MAC_PCU_BLUETOOTH_MODE2_SLEEP_ALLOW_BT_ACCESS_LSB 17
-#define MAC_PCU_BLUETOOTH_MODE2_SLEEP_ALLOW_BT_ACCESS_MASK 0x00020000
-#define MAC_PCU_BLUETOOTH_MODE2_SLEEP_ALLOW_BT_ACCESS_GET(x) (((x) & MAC_PCU_BLUETOOTH_MODE2_SLEEP_ALLOW_BT_ACCESS_MASK) >> MAC_PCU_BLUETOOTH_MODE2_SLEEP_ALLOW_BT_ACCESS_LSB)
-#define MAC_PCU_BLUETOOTH_MODE2_SLEEP_ALLOW_BT_ACCESS_SET(x) (((x) << MAC_PCU_BLUETOOTH_MODE2_SLEEP_ALLOW_BT_ACCESS_LSB) & MAC_PCU_BLUETOOTH_MODE2_SLEEP_ALLOW_BT_ACCESS_MASK)
-#define MAC_PCU_BLUETOOTH_MODE2_HOLD_RX_CLEAR_MSB 16
-#define MAC_PCU_BLUETOOTH_MODE2_HOLD_RX_CLEAR_LSB 16
-#define MAC_PCU_BLUETOOTH_MODE2_HOLD_RX_CLEAR_MASK 0x00010000
-#define MAC_PCU_BLUETOOTH_MODE2_HOLD_RX_CLEAR_GET(x) (((x) & MAC_PCU_BLUETOOTH_MODE2_HOLD_RX_CLEAR_MASK) >> MAC_PCU_BLUETOOTH_MODE2_HOLD_RX_CLEAR_LSB)
-#define MAC_PCU_BLUETOOTH_MODE2_HOLD_RX_CLEAR_SET(x) (((x) << MAC_PCU_BLUETOOTH_MODE2_HOLD_RX_CLEAR_LSB) & MAC_PCU_BLUETOOTH_MODE2_HOLD_RX_CLEAR_MASK)
-#define MAC_PCU_BLUETOOTH_MODE2_BCN_MISS_CNT_MSB 15
-#define MAC_PCU_BLUETOOTH_MODE2_BCN_MISS_CNT_LSB 8
-#define MAC_PCU_BLUETOOTH_MODE2_BCN_MISS_CNT_MASK 0x0000ff00
-#define MAC_PCU_BLUETOOTH_MODE2_BCN_MISS_CNT_GET(x) (((x) & MAC_PCU_BLUETOOTH_MODE2_BCN_MISS_CNT_MASK) >> MAC_PCU_BLUETOOTH_MODE2_BCN_MISS_CNT_LSB)
-#define MAC_PCU_BLUETOOTH_MODE2_BCN_MISS_CNT_SET(x) (((x) << MAC_PCU_BLUETOOTH_MODE2_BCN_MISS_CNT_LSB) & MAC_PCU_BLUETOOTH_MODE2_BCN_MISS_CNT_MASK)
-#define MAC_PCU_BLUETOOTH_MODE2_BCN_MISS_THRESH_MSB 7
-#define MAC_PCU_BLUETOOTH_MODE2_BCN_MISS_THRESH_LSB 0
-#define MAC_PCU_BLUETOOTH_MODE2_BCN_MISS_THRESH_MASK 0x000000ff
-#define MAC_PCU_BLUETOOTH_MODE2_BCN_MISS_THRESH_GET(x) (((x) & MAC_PCU_BLUETOOTH_MODE2_BCN_MISS_THRESH_MASK) >> MAC_PCU_BLUETOOTH_MODE2_BCN_MISS_THRESH_LSB)
-#define MAC_PCU_BLUETOOTH_MODE2_BCN_MISS_THRESH_SET(x) (((x) << MAC_PCU_BLUETOOTH_MODE2_BCN_MISS_THRESH_LSB) & MAC_PCU_BLUETOOTH_MODE2_BCN_MISS_THRESH_MASK)
-
-#define MAC_PCU_TXSIFS_ADDRESS                   0x000080f8
-#define MAC_PCU_TXSIFS_OFFSET                    0x000000f8
-#define MAC_PCU_TXSIFS_ACK_SHIFT_MSB             14
-#define MAC_PCU_TXSIFS_ACK_SHIFT_LSB             12
-#define MAC_PCU_TXSIFS_ACK_SHIFT_MASK            0x00007000
-#define MAC_PCU_TXSIFS_ACK_SHIFT_GET(x)          (((x) & MAC_PCU_TXSIFS_ACK_SHIFT_MASK) >> MAC_PCU_TXSIFS_ACK_SHIFT_LSB)
-#define MAC_PCU_TXSIFS_ACK_SHIFT_SET(x)          (((x) << MAC_PCU_TXSIFS_ACK_SHIFT_LSB) & MAC_PCU_TXSIFS_ACK_SHIFT_MASK)
-#define MAC_PCU_TXSIFS_TX_LATENCY_MSB            11
-#define MAC_PCU_TXSIFS_TX_LATENCY_LSB            8
-#define MAC_PCU_TXSIFS_TX_LATENCY_MASK           0x00000f00
-#define MAC_PCU_TXSIFS_TX_LATENCY_GET(x)         (((x) & MAC_PCU_TXSIFS_TX_LATENCY_MASK) >> MAC_PCU_TXSIFS_TX_LATENCY_LSB)
-#define MAC_PCU_TXSIFS_TX_LATENCY_SET(x)         (((x) << MAC_PCU_TXSIFS_TX_LATENCY_LSB) & MAC_PCU_TXSIFS_TX_LATENCY_MASK)
-#define MAC_PCU_TXSIFS_SIFS_TIME_MSB             7
-#define MAC_PCU_TXSIFS_SIFS_TIME_LSB             0
-#define MAC_PCU_TXSIFS_SIFS_TIME_MASK            0x000000ff
-#define MAC_PCU_TXSIFS_SIFS_TIME_GET(x)          (((x) & MAC_PCU_TXSIFS_SIFS_TIME_MASK) >> MAC_PCU_TXSIFS_SIFS_TIME_LSB)
-#define MAC_PCU_TXSIFS_SIFS_TIME_SET(x)          (((x) << MAC_PCU_TXSIFS_SIFS_TIME_LSB) & MAC_PCU_TXSIFS_SIFS_TIME_MASK)
-
-#define MAC_PCU_TXOP_X_ADDRESS                   0x000080fc
-#define MAC_PCU_TXOP_X_OFFSET                    0x000000fc
-#define MAC_PCU_TXOP_X_VALUE_MSB                 7
-#define MAC_PCU_TXOP_X_VALUE_LSB                 0
-#define MAC_PCU_TXOP_X_VALUE_MASK                0x000000ff
-#define MAC_PCU_TXOP_X_VALUE_GET(x)              (((x) & MAC_PCU_TXOP_X_VALUE_MASK) >> MAC_PCU_TXOP_X_VALUE_LSB)
-#define MAC_PCU_TXOP_X_VALUE_SET(x)              (((x) << MAC_PCU_TXOP_X_VALUE_LSB) & MAC_PCU_TXOP_X_VALUE_MASK)
-
-#define MAC_PCU_TXOP_0_3_ADDRESS                 0x00008100
-#define MAC_PCU_TXOP_0_3_OFFSET                  0x00000100
-#define MAC_PCU_TXOP_0_3_VALUE_3_MSB             31
-#define MAC_PCU_TXOP_0_3_VALUE_3_LSB             24
-#define MAC_PCU_TXOP_0_3_VALUE_3_MASK            0xff000000
-#define MAC_PCU_TXOP_0_3_VALUE_3_GET(x)          (((x) & MAC_PCU_TXOP_0_3_VALUE_3_MASK) >> MAC_PCU_TXOP_0_3_VALUE_3_LSB)
-#define MAC_PCU_TXOP_0_3_VALUE_3_SET(x)          (((x) << MAC_PCU_TXOP_0_3_VALUE_3_LSB) & MAC_PCU_TXOP_0_3_VALUE_3_MASK)
-#define MAC_PCU_TXOP_0_3_VALUE_2_MSB             23
-#define MAC_PCU_TXOP_0_3_VALUE_2_LSB             16
-#define MAC_PCU_TXOP_0_3_VALUE_2_MASK            0x00ff0000
-#define MAC_PCU_TXOP_0_3_VALUE_2_GET(x)          (((x) & MAC_PCU_TXOP_0_3_VALUE_2_MASK) >> MAC_PCU_TXOP_0_3_VALUE_2_LSB)
-#define MAC_PCU_TXOP_0_3_VALUE_2_SET(x)          (((x) << MAC_PCU_TXOP_0_3_VALUE_2_LSB) & MAC_PCU_TXOP_0_3_VALUE_2_MASK)
-#define MAC_PCU_TXOP_0_3_VALUE_1_MSB             15
-#define MAC_PCU_TXOP_0_3_VALUE_1_LSB             8
-#define MAC_PCU_TXOP_0_3_VALUE_1_MASK            0x0000ff00
-#define MAC_PCU_TXOP_0_3_VALUE_1_GET(x)          (((x) & MAC_PCU_TXOP_0_3_VALUE_1_MASK) >> MAC_PCU_TXOP_0_3_VALUE_1_LSB)
-#define MAC_PCU_TXOP_0_3_VALUE_1_SET(x)          (((x) << MAC_PCU_TXOP_0_3_VALUE_1_LSB) & MAC_PCU_TXOP_0_3_VALUE_1_MASK)
-#define MAC_PCU_TXOP_0_3_VALUE_0_MSB             7
-#define MAC_PCU_TXOP_0_3_VALUE_0_LSB             0
-#define MAC_PCU_TXOP_0_3_VALUE_0_MASK            0x000000ff
-#define MAC_PCU_TXOP_0_3_VALUE_0_GET(x)          (((x) & MAC_PCU_TXOP_0_3_VALUE_0_MASK) >> MAC_PCU_TXOP_0_3_VALUE_0_LSB)
-#define MAC_PCU_TXOP_0_3_VALUE_0_SET(x)          (((x) << MAC_PCU_TXOP_0_3_VALUE_0_LSB) & MAC_PCU_TXOP_0_3_VALUE_0_MASK)
-
-#define MAC_PCU_TXOP_4_7_ADDRESS                 0x00008104
-#define MAC_PCU_TXOP_4_7_OFFSET                  0x00000104
-#define MAC_PCU_TXOP_4_7_VALUE_7_MSB             31
-#define MAC_PCU_TXOP_4_7_VALUE_7_LSB             24
-#define MAC_PCU_TXOP_4_7_VALUE_7_MASK            0xff000000
-#define MAC_PCU_TXOP_4_7_VALUE_7_GET(x)          (((x) & MAC_PCU_TXOP_4_7_VALUE_7_MASK) >> MAC_PCU_TXOP_4_7_VALUE_7_LSB)
-#define MAC_PCU_TXOP_4_7_VALUE_7_SET(x)          (((x) << MAC_PCU_TXOP_4_7_VALUE_7_LSB) & MAC_PCU_TXOP_4_7_VALUE_7_MASK)
-#define MAC_PCU_TXOP_4_7_VALUE_6_MSB             23
-#define MAC_PCU_TXOP_4_7_VALUE_6_LSB             16
-#define MAC_PCU_TXOP_4_7_VALUE_6_MASK            0x00ff0000
-#define MAC_PCU_TXOP_4_7_VALUE_6_GET(x)          (((x) & MAC_PCU_TXOP_4_7_VALUE_6_MASK) >> MAC_PCU_TXOP_4_7_VALUE_6_LSB)
-#define MAC_PCU_TXOP_4_7_VALUE_6_SET(x)          (((x) << MAC_PCU_TXOP_4_7_VALUE_6_LSB) & MAC_PCU_TXOP_4_7_VALUE_6_MASK)
-#define MAC_PCU_TXOP_4_7_VALUE_5_MSB             15
-#define MAC_PCU_TXOP_4_7_VALUE_5_LSB             8
-#define MAC_PCU_TXOP_4_7_VALUE_5_MASK            0x0000ff00
-#define MAC_PCU_TXOP_4_7_VALUE_5_GET(x)          (((x) & MAC_PCU_TXOP_4_7_VALUE_5_MASK) >> MAC_PCU_TXOP_4_7_VALUE_5_LSB)
-#define MAC_PCU_TXOP_4_7_VALUE_5_SET(x)          (((x) << MAC_PCU_TXOP_4_7_VALUE_5_LSB) & MAC_PCU_TXOP_4_7_VALUE_5_MASK)
-#define MAC_PCU_TXOP_4_7_VALUE_4_MSB             7
-#define MAC_PCU_TXOP_4_7_VALUE_4_LSB             0
-#define MAC_PCU_TXOP_4_7_VALUE_4_MASK            0x000000ff
-#define MAC_PCU_TXOP_4_7_VALUE_4_GET(x)          (((x) & MAC_PCU_TXOP_4_7_VALUE_4_MASK) >> MAC_PCU_TXOP_4_7_VALUE_4_LSB)
-#define MAC_PCU_TXOP_4_7_VALUE_4_SET(x)          (((x) << MAC_PCU_TXOP_4_7_VALUE_4_LSB) & MAC_PCU_TXOP_4_7_VALUE_4_MASK)
-
-#define MAC_PCU_TXOP_8_11_ADDRESS                0x00008108
-#define MAC_PCU_TXOP_8_11_OFFSET                 0x00000108
-#define MAC_PCU_TXOP_8_11_VALUE_11_MSB           31
-#define MAC_PCU_TXOP_8_11_VALUE_11_LSB           24
-#define MAC_PCU_TXOP_8_11_VALUE_11_MASK          0xff000000
-#define MAC_PCU_TXOP_8_11_VALUE_11_GET(x)        (((x) & MAC_PCU_TXOP_8_11_VALUE_11_MASK) >> MAC_PCU_TXOP_8_11_VALUE_11_LSB)
-#define MAC_PCU_TXOP_8_11_VALUE_11_SET(x)        (((x) << MAC_PCU_TXOP_8_11_VALUE_11_LSB) & MAC_PCU_TXOP_8_11_VALUE_11_MASK)
-#define MAC_PCU_TXOP_8_11_VALUE_10_MSB           23
-#define MAC_PCU_TXOP_8_11_VALUE_10_LSB           16
-#define MAC_PCU_TXOP_8_11_VALUE_10_MASK          0x00ff0000
-#define MAC_PCU_TXOP_8_11_VALUE_10_GET(x)        (((x) & MAC_PCU_TXOP_8_11_VALUE_10_MASK) >> MAC_PCU_TXOP_8_11_VALUE_10_LSB)
-#define MAC_PCU_TXOP_8_11_VALUE_10_SET(x)        (((x) << MAC_PCU_TXOP_8_11_VALUE_10_LSB) & MAC_PCU_TXOP_8_11_VALUE_10_MASK)
-#define MAC_PCU_TXOP_8_11_VALUE_9_MSB            15
-#define MAC_PCU_TXOP_8_11_VALUE_9_LSB            8
-#define MAC_PCU_TXOP_8_11_VALUE_9_MASK           0x0000ff00
-#define MAC_PCU_TXOP_8_11_VALUE_9_GET(x)         (((x) & MAC_PCU_TXOP_8_11_VALUE_9_MASK) >> MAC_PCU_TXOP_8_11_VALUE_9_LSB)
-#define MAC_PCU_TXOP_8_11_VALUE_9_SET(x)         (((x) << MAC_PCU_TXOP_8_11_VALUE_9_LSB) & MAC_PCU_TXOP_8_11_VALUE_9_MASK)
-#define MAC_PCU_TXOP_8_11_VALUE_8_MSB            7
-#define MAC_PCU_TXOP_8_11_VALUE_8_LSB            0
-#define MAC_PCU_TXOP_8_11_VALUE_8_MASK           0x000000ff
-#define MAC_PCU_TXOP_8_11_VALUE_8_GET(x)         (((x) & MAC_PCU_TXOP_8_11_VALUE_8_MASK) >> MAC_PCU_TXOP_8_11_VALUE_8_LSB)
-#define MAC_PCU_TXOP_8_11_VALUE_8_SET(x)         (((x) << MAC_PCU_TXOP_8_11_VALUE_8_LSB) & MAC_PCU_TXOP_8_11_VALUE_8_MASK)
-
-#define MAC_PCU_TXOP_12_15_ADDRESS               0x0000810c
-#define MAC_PCU_TXOP_12_15_OFFSET                0x0000010c
-#define MAC_PCU_TXOP_12_15_VALUE_15_MSB          31
-#define MAC_PCU_TXOP_12_15_VALUE_15_LSB          24
-#define MAC_PCU_TXOP_12_15_VALUE_15_MASK         0xff000000
-#define MAC_PCU_TXOP_12_15_VALUE_15_GET(x)       (((x) & MAC_PCU_TXOP_12_15_VALUE_15_MASK) >> MAC_PCU_TXOP_12_15_VALUE_15_LSB)
-#define MAC_PCU_TXOP_12_15_VALUE_15_SET(x)       (((x) << MAC_PCU_TXOP_12_15_VALUE_15_LSB) & MAC_PCU_TXOP_12_15_VALUE_15_MASK)
-#define MAC_PCU_TXOP_12_15_VALUE_14_MSB          23
-#define MAC_PCU_TXOP_12_15_VALUE_14_LSB          16
-#define MAC_PCU_TXOP_12_15_VALUE_14_MASK         0x00ff0000
-#define MAC_PCU_TXOP_12_15_VALUE_14_GET(x)       (((x) & MAC_PCU_TXOP_12_15_VALUE_14_MASK) >> MAC_PCU_TXOP_12_15_VALUE_14_LSB)
-#define MAC_PCU_TXOP_12_15_VALUE_14_SET(x)       (((x) << MAC_PCU_TXOP_12_15_VALUE_14_LSB) & MAC_PCU_TXOP_12_15_VALUE_14_MASK)
-#define MAC_PCU_TXOP_12_15_VALUE_13_MSB          15
-#define MAC_PCU_TXOP_12_15_VALUE_13_LSB          8
-#define MAC_PCU_TXOP_12_15_VALUE_13_MASK         0x0000ff00
-#define MAC_PCU_TXOP_12_15_VALUE_13_GET(x)       (((x) & MAC_PCU_TXOP_12_15_VALUE_13_MASK) >> MAC_PCU_TXOP_12_15_VALUE_13_LSB)
-#define MAC_PCU_TXOP_12_15_VALUE_13_SET(x)       (((x) << MAC_PCU_TXOP_12_15_VALUE_13_LSB) & MAC_PCU_TXOP_12_15_VALUE_13_MASK)
-#define MAC_PCU_TXOP_12_15_VALUE_12_MSB          7
-#define MAC_PCU_TXOP_12_15_VALUE_12_LSB          0
-#define MAC_PCU_TXOP_12_15_VALUE_12_MASK         0x000000ff
-#define MAC_PCU_TXOP_12_15_VALUE_12_GET(x)       (((x) & MAC_PCU_TXOP_12_15_VALUE_12_MASK) >> MAC_PCU_TXOP_12_15_VALUE_12_LSB)
-#define MAC_PCU_TXOP_12_15_VALUE_12_SET(x)       (((x) << MAC_PCU_TXOP_12_15_VALUE_12_LSB) & MAC_PCU_TXOP_12_15_VALUE_12_MASK)
-
-#define MAC_PCU_LOGIC_ANALYZER_ADDRESS           0x00008110
-#define MAC_PCU_LOGIC_ANALYZER_OFFSET            0x00000110
-#define MAC_PCU_LOGIC_ANALYZER_DIAG_MODE_MSB     31
-#define MAC_PCU_LOGIC_ANALYZER_DIAG_MODE_LSB     18
-#define MAC_PCU_LOGIC_ANALYZER_DIAG_MODE_MASK    0xfffc0000
-#define MAC_PCU_LOGIC_ANALYZER_DIAG_MODE_GET(x)  (((x) & MAC_PCU_LOGIC_ANALYZER_DIAG_MODE_MASK) >> MAC_PCU_LOGIC_ANALYZER_DIAG_MODE_LSB)
-#define MAC_PCU_LOGIC_ANALYZER_DIAG_MODE_SET(x)  (((x) << MAC_PCU_LOGIC_ANALYZER_DIAG_MODE_LSB) & MAC_PCU_LOGIC_ANALYZER_DIAG_MODE_MASK)
-#define MAC_PCU_LOGIC_ANALYZER_INT_ADDR_MSB      17
-#define MAC_PCU_LOGIC_ANALYZER_INT_ADDR_LSB      8
-#define MAC_PCU_LOGIC_ANALYZER_INT_ADDR_MASK     0x0003ff00
-#define MAC_PCU_LOGIC_ANALYZER_INT_ADDR_GET(x)   (((x) & MAC_PCU_LOGIC_ANALYZER_INT_ADDR_MASK) >> MAC_PCU_LOGIC_ANALYZER_INT_ADDR_LSB)
-#define MAC_PCU_LOGIC_ANALYZER_INT_ADDR_SET(x)   (((x) << MAC_PCU_LOGIC_ANALYZER_INT_ADDR_LSB) & MAC_PCU_LOGIC_ANALYZER_INT_ADDR_MASK)
-#define MAC_PCU_LOGIC_ANALYZER_QCU_SEL_MSB       7
-#define MAC_PCU_LOGIC_ANALYZER_QCU_SEL_LSB       4
-#define MAC_PCU_LOGIC_ANALYZER_QCU_SEL_MASK      0x000000f0
-#define MAC_PCU_LOGIC_ANALYZER_QCU_SEL_GET(x)    (((x) & MAC_PCU_LOGIC_ANALYZER_QCU_SEL_MASK) >> MAC_PCU_LOGIC_ANALYZER_QCU_SEL_LSB)
-#define MAC_PCU_LOGIC_ANALYZER_QCU_SEL_SET(x)    (((x) << MAC_PCU_LOGIC_ANALYZER_QCU_SEL_LSB) & MAC_PCU_LOGIC_ANALYZER_QCU_SEL_MASK)
-#define MAC_PCU_LOGIC_ANALYZER_ENABLE_MSB        3
-#define MAC_PCU_LOGIC_ANALYZER_ENABLE_LSB        3
-#define MAC_PCU_LOGIC_ANALYZER_ENABLE_MASK       0x00000008
-#define MAC_PCU_LOGIC_ANALYZER_ENABLE_GET(x)     (((x) & MAC_PCU_LOGIC_ANALYZER_ENABLE_MASK) >> MAC_PCU_LOGIC_ANALYZER_ENABLE_LSB)
-#define MAC_PCU_LOGIC_ANALYZER_ENABLE_SET(x)     (((x) << MAC_PCU_LOGIC_ANALYZER_ENABLE_LSB) & MAC_PCU_LOGIC_ANALYZER_ENABLE_MASK)
-#define MAC_PCU_LOGIC_ANALYZER_STATE_MSB         2
-#define MAC_PCU_LOGIC_ANALYZER_STATE_LSB         2
-#define MAC_PCU_LOGIC_ANALYZER_STATE_MASK        0x00000004
-#define MAC_PCU_LOGIC_ANALYZER_STATE_GET(x)      (((x) & MAC_PCU_LOGIC_ANALYZER_STATE_MASK) >> MAC_PCU_LOGIC_ANALYZER_STATE_LSB)
-#define MAC_PCU_LOGIC_ANALYZER_STATE_SET(x)      (((x) << MAC_PCU_LOGIC_ANALYZER_STATE_LSB) & MAC_PCU_LOGIC_ANALYZER_STATE_MASK)
-#define MAC_PCU_LOGIC_ANALYZER_CLEAR_MSB         1
-#define MAC_PCU_LOGIC_ANALYZER_CLEAR_LSB         1
-#define MAC_PCU_LOGIC_ANALYZER_CLEAR_MASK        0x00000002
-#define MAC_PCU_LOGIC_ANALYZER_CLEAR_GET(x)      (((x) & MAC_PCU_LOGIC_ANALYZER_CLEAR_MASK) >> MAC_PCU_LOGIC_ANALYZER_CLEAR_LSB)
-#define MAC_PCU_LOGIC_ANALYZER_CLEAR_SET(x)      (((x) << MAC_PCU_LOGIC_ANALYZER_CLEAR_LSB) & MAC_PCU_LOGIC_ANALYZER_CLEAR_MASK)
-#define MAC_PCU_LOGIC_ANALYZER_HOLD_MSB          0
-#define MAC_PCU_LOGIC_ANALYZER_HOLD_LSB          0
-#define MAC_PCU_LOGIC_ANALYZER_HOLD_MASK         0x00000001
-#define MAC_PCU_LOGIC_ANALYZER_HOLD_GET(x)       (((x) & MAC_PCU_LOGIC_ANALYZER_HOLD_MASK) >> MAC_PCU_LOGIC_ANALYZER_HOLD_LSB)
-#define MAC_PCU_LOGIC_ANALYZER_HOLD_SET(x)       (((x) << MAC_PCU_LOGIC_ANALYZER_HOLD_LSB) & MAC_PCU_LOGIC_ANALYZER_HOLD_MASK)
-
-#define MAC_PCU_LOGIC_ANALYZER_32L_ADDRESS       0x00008114
-#define MAC_PCU_LOGIC_ANALYZER_32L_OFFSET        0x00000114
-#define MAC_PCU_LOGIC_ANALYZER_32L_MASK_MSB      31
-#define MAC_PCU_LOGIC_ANALYZER_32L_MASK_LSB      0
-#define MAC_PCU_LOGIC_ANALYZER_32L_MASK_MASK     0xffffffff
-#define MAC_PCU_LOGIC_ANALYZER_32L_MASK_GET(x)   (((x) & MAC_PCU_LOGIC_ANALYZER_32L_MASK_MASK) >> MAC_PCU_LOGIC_ANALYZER_32L_MASK_LSB)
-#define MAC_PCU_LOGIC_ANALYZER_32L_MASK_SET(x)   (((x) << MAC_PCU_LOGIC_ANALYZER_32L_MASK_LSB) & MAC_PCU_LOGIC_ANALYZER_32L_MASK_MASK)
-
-#define MAC_PCU_LOGIC_ANALYZER_16U_ADDRESS       0x00008118
-#define MAC_PCU_LOGIC_ANALYZER_16U_OFFSET        0x00000118
-#define MAC_PCU_LOGIC_ANALYZER_16U_MASK_MSB      15
-#define MAC_PCU_LOGIC_ANALYZER_16U_MASK_LSB      0
-#define MAC_PCU_LOGIC_ANALYZER_16U_MASK_MASK     0x0000ffff
-#define MAC_PCU_LOGIC_ANALYZER_16U_MASK_GET(x)   (((x) & MAC_PCU_LOGIC_ANALYZER_16U_MASK_MASK) >> MAC_PCU_LOGIC_ANALYZER_16U_MASK_LSB)
-#define MAC_PCU_LOGIC_ANALYZER_16U_MASK_SET(x)   (((x) << MAC_PCU_LOGIC_ANALYZER_16U_MASK_LSB) & MAC_PCU_LOGIC_ANALYZER_16U_MASK_MASK)
-
-#define MAC_PCU_PHY_ERR_CNT_MASK_CONT_ADDRESS    0x0000811c
-#define MAC_PCU_PHY_ERR_CNT_MASK_CONT_OFFSET     0x0000011c
-#define MAC_PCU_PHY_ERR_CNT_MASK_CONT_MASK3_MSB  23
-#define MAC_PCU_PHY_ERR_CNT_MASK_CONT_MASK3_LSB  16
-#define MAC_PCU_PHY_ERR_CNT_MASK_CONT_MASK3_MASK 0x00ff0000
-#define MAC_PCU_PHY_ERR_CNT_MASK_CONT_MASK3_GET(x) (((x) & MAC_PCU_PHY_ERR_CNT_MASK_CONT_MASK3_MASK) >> MAC_PCU_PHY_ERR_CNT_MASK_CONT_MASK3_LSB)
-#define MAC_PCU_PHY_ERR_CNT_MASK_CONT_MASK3_SET(x) (((x) << MAC_PCU_PHY_ERR_CNT_MASK_CONT_MASK3_LSB) & MAC_PCU_PHY_ERR_CNT_MASK_CONT_MASK3_MASK)
-#define MAC_PCU_PHY_ERR_CNT_MASK_CONT_MASK2_MSB  15
-#define MAC_PCU_PHY_ERR_CNT_MASK_CONT_MASK2_LSB  8
-#define MAC_PCU_PHY_ERR_CNT_MASK_CONT_MASK2_MASK 0x0000ff00
-#define MAC_PCU_PHY_ERR_CNT_MASK_CONT_MASK2_GET(x) (((x) & MAC_PCU_PHY_ERR_CNT_MASK_CONT_MASK2_MASK) >> MAC_PCU_PHY_ERR_CNT_MASK_CONT_MASK2_LSB)
-#define MAC_PCU_PHY_ERR_CNT_MASK_CONT_MASK2_SET(x) (((x) << MAC_PCU_PHY_ERR_CNT_MASK_CONT_MASK2_LSB) & MAC_PCU_PHY_ERR_CNT_MASK_CONT_MASK2_MASK)
-#define MAC_PCU_PHY_ERR_CNT_MASK_CONT_MASK1_MSB  7
-#define MAC_PCU_PHY_ERR_CNT_MASK_CONT_MASK1_LSB  0
-#define MAC_PCU_PHY_ERR_CNT_MASK_CONT_MASK1_MASK 0x000000ff
-#define MAC_PCU_PHY_ERR_CNT_MASK_CONT_MASK1_GET(x) (((x) & MAC_PCU_PHY_ERR_CNT_MASK_CONT_MASK1_MASK) >> MAC_PCU_PHY_ERR_CNT_MASK_CONT_MASK1_LSB)
-#define MAC_PCU_PHY_ERR_CNT_MASK_CONT_MASK1_SET(x) (((x) << MAC_PCU_PHY_ERR_CNT_MASK_CONT_MASK1_LSB) & MAC_PCU_PHY_ERR_CNT_MASK_CONT_MASK1_MASK)
-
-#define MAC_PCU_AZIMUTH_MODE_ADDRESS             0x00008120
-#define MAC_PCU_AZIMUTH_MODE_OFFSET              0x00000120
-#define MAC_PCU_AZIMUTH_MODE_BA_USES_AD1_MSB     7
-#define MAC_PCU_AZIMUTH_MODE_BA_USES_AD1_LSB     7
-#define MAC_PCU_AZIMUTH_MODE_BA_USES_AD1_MASK    0x00000080
-#define MAC_PCU_AZIMUTH_MODE_BA_USES_AD1_GET(x)  (((x) & MAC_PCU_AZIMUTH_MODE_BA_USES_AD1_MASK) >> MAC_PCU_AZIMUTH_MODE_BA_USES_AD1_LSB)
-#define MAC_PCU_AZIMUTH_MODE_BA_USES_AD1_SET(x)  (((x) << MAC_PCU_AZIMUTH_MODE_BA_USES_AD1_LSB) & MAC_PCU_AZIMUTH_MODE_BA_USES_AD1_MASK)
-#define MAC_PCU_AZIMUTH_MODE_ACK_CTS_MATCH_TX_AD2_MSB 6
-#define MAC_PCU_AZIMUTH_MODE_ACK_CTS_MATCH_TX_AD2_LSB 6
-#define MAC_PCU_AZIMUTH_MODE_ACK_CTS_MATCH_TX_AD2_MASK 0x00000040
-#define MAC_PCU_AZIMUTH_MODE_ACK_CTS_MATCH_TX_AD2_GET(x) (((x) & MAC_PCU_AZIMUTH_MODE_ACK_CTS_MATCH_TX_AD2_MASK) >> MAC_PCU_AZIMUTH_MODE_ACK_CTS_MATCH_TX_AD2_LSB)
-#define MAC_PCU_AZIMUTH_MODE_ACK_CTS_MATCH_TX_AD2_SET(x) (((x) << MAC_PCU_AZIMUTH_MODE_ACK_CTS_MATCH_TX_AD2_LSB) & MAC_PCU_AZIMUTH_MODE_ACK_CTS_MATCH_TX_AD2_MASK)
-#define MAC_PCU_AZIMUTH_MODE_TX_DESC_EN_MSB      5
-#define MAC_PCU_AZIMUTH_MODE_TX_DESC_EN_LSB      5
-#define MAC_PCU_AZIMUTH_MODE_TX_DESC_EN_MASK     0x00000020
-#define MAC_PCU_AZIMUTH_MODE_TX_DESC_EN_GET(x)   (((x) & MAC_PCU_AZIMUTH_MODE_TX_DESC_EN_MASK) >> MAC_PCU_AZIMUTH_MODE_TX_DESC_EN_LSB)
-#define MAC_PCU_AZIMUTH_MODE_TX_DESC_EN_SET(x)   (((x) << MAC_PCU_AZIMUTH_MODE_TX_DESC_EN_LSB) & MAC_PCU_AZIMUTH_MODE_TX_DESC_EN_MASK)
-#define MAC_PCU_AZIMUTH_MODE_CLK_EN_MSB          4
-#define MAC_PCU_AZIMUTH_MODE_CLK_EN_LSB          4
-#define MAC_PCU_AZIMUTH_MODE_CLK_EN_MASK         0x00000010
-#define MAC_PCU_AZIMUTH_MODE_CLK_EN_GET(x)       (((x) & MAC_PCU_AZIMUTH_MODE_CLK_EN_MASK) >> MAC_PCU_AZIMUTH_MODE_CLK_EN_LSB)
-#define MAC_PCU_AZIMUTH_MODE_CLK_EN_SET(x)       (((x) << MAC_PCU_AZIMUTH_MODE_CLK_EN_LSB) & MAC_PCU_AZIMUTH_MODE_CLK_EN_MASK)
-#define MAC_PCU_AZIMUTH_MODE_RX_TSF_STATUS_SEL_MSB 3
-#define MAC_PCU_AZIMUTH_MODE_RX_TSF_STATUS_SEL_LSB 3
-#define MAC_PCU_AZIMUTH_MODE_RX_TSF_STATUS_SEL_MASK 0x00000008
-#define MAC_PCU_AZIMUTH_MODE_RX_TSF_STATUS_SEL_GET(x) (((x) & MAC_PCU_AZIMUTH_MODE_RX_TSF_STATUS_SEL_MASK) >> MAC_PCU_AZIMUTH_MODE_RX_TSF_STATUS_SEL_LSB)
-#define MAC_PCU_AZIMUTH_MODE_RX_TSF_STATUS_SEL_SET(x) (((x) << MAC_PCU_AZIMUTH_MODE_RX_TSF_STATUS_SEL_LSB) & MAC_PCU_AZIMUTH_MODE_RX_TSF_STATUS_SEL_MASK)
-#define MAC_PCU_AZIMUTH_MODE_TX_TSF_STATUS_SEL_MSB 2
-#define MAC_PCU_AZIMUTH_MODE_TX_TSF_STATUS_SEL_LSB 2
-#define MAC_PCU_AZIMUTH_MODE_TX_TSF_STATUS_SEL_MASK 0x00000004
-#define MAC_PCU_AZIMUTH_MODE_TX_TSF_STATUS_SEL_GET(x) (((x) & MAC_PCU_AZIMUTH_MODE_TX_TSF_STATUS_SEL_MASK) >> MAC_PCU_AZIMUTH_MODE_TX_TSF_STATUS_SEL_LSB)
-#define MAC_PCU_AZIMUTH_MODE_TX_TSF_STATUS_SEL_SET(x) (((x) << MAC_PCU_AZIMUTH_MODE_TX_TSF_STATUS_SEL_LSB) & MAC_PCU_AZIMUTH_MODE_TX_TSF_STATUS_SEL_MASK)
-#define MAC_PCU_AZIMUTH_MODE_KEY_SEARCH_AD1_MSB  1
-#define MAC_PCU_AZIMUTH_MODE_KEY_SEARCH_AD1_LSB  1
-#define MAC_PCU_AZIMUTH_MODE_KEY_SEARCH_AD1_MASK 0x00000002
-#define MAC_PCU_AZIMUTH_MODE_KEY_SEARCH_AD1_GET(x) (((x) & MAC_PCU_AZIMUTH_MODE_KEY_SEARCH_AD1_MASK) >> MAC_PCU_AZIMUTH_MODE_KEY_SEARCH_AD1_LSB)
-#define MAC_PCU_AZIMUTH_MODE_KEY_SEARCH_AD1_SET(x) (((x) << MAC_PCU_AZIMUTH_MODE_KEY_SEARCH_AD1_LSB) & MAC_PCU_AZIMUTH_MODE_KEY_SEARCH_AD1_MASK)
-#define MAC_PCU_AZIMUTH_MODE_DISABLE_TSF_UPDATE_MSB 0
-#define MAC_PCU_AZIMUTH_MODE_DISABLE_TSF_UPDATE_LSB 0
-#define MAC_PCU_AZIMUTH_MODE_DISABLE_TSF_UPDATE_MASK 0x00000001
-#define MAC_PCU_AZIMUTH_MODE_DISABLE_TSF_UPDATE_GET(x) (((x) & MAC_PCU_AZIMUTH_MODE_DISABLE_TSF_UPDATE_MASK) >> MAC_PCU_AZIMUTH_MODE_DISABLE_TSF_UPDATE_LSB)
-#define MAC_PCU_AZIMUTH_MODE_DISABLE_TSF_UPDATE_SET(x) (((x) << MAC_PCU_AZIMUTH_MODE_DISABLE_TSF_UPDATE_LSB) & MAC_PCU_AZIMUTH_MODE_DISABLE_TSF_UPDATE_MASK)
-
-#define MAC_PCU_20_40_MODE_ADDRESS               0x00008124
-#define MAC_PCU_20_40_MODE_OFFSET                0x00000124
-#define MAC_PCU_20_40_MODE_PIFS_CYCLES_MSB       15
-#define MAC_PCU_20_40_MODE_PIFS_CYCLES_LSB       4
-#define MAC_PCU_20_40_MODE_PIFS_CYCLES_MASK      0x0000fff0
-#define MAC_PCU_20_40_MODE_PIFS_CYCLES_GET(x)    (((x) & MAC_PCU_20_40_MODE_PIFS_CYCLES_MASK) >> MAC_PCU_20_40_MODE_PIFS_CYCLES_LSB)
-#define MAC_PCU_20_40_MODE_PIFS_CYCLES_SET(x)    (((x) << MAC_PCU_20_40_MODE_PIFS_CYCLES_LSB) & MAC_PCU_20_40_MODE_PIFS_CYCLES_MASK)
-#define MAC_PCU_20_40_MODE_SWAMPED_FORCES_RX_CLEAR_CTL_IDLE_MSB 3
-#define MAC_PCU_20_40_MODE_SWAMPED_FORCES_RX_CLEAR_CTL_IDLE_LSB 3
-#define MAC_PCU_20_40_MODE_SWAMPED_FORCES_RX_CLEAR_CTL_IDLE_MASK 0x00000008
-#define MAC_PCU_20_40_MODE_SWAMPED_FORCES_RX_CLEAR_CTL_IDLE_GET(x) (((x) & MAC_PCU_20_40_MODE_SWAMPED_FORCES_RX_CLEAR_CTL_IDLE_MASK) >> MAC_PCU_20_40_MODE_SWAMPED_FORCES_RX_CLEAR_CTL_IDLE_LSB)
-#define MAC_PCU_20_40_MODE_SWAMPED_FORCES_RX_CLEAR_CTL_IDLE_SET(x) (((x) << MAC_PCU_20_40_MODE_SWAMPED_FORCES_RX_CLEAR_CTL_IDLE_LSB) & MAC_PCU_20_40_MODE_SWAMPED_FORCES_RX_CLEAR_CTL_IDLE_MASK)
-#define MAC_PCU_20_40_MODE_TX_HT20_ON_EXT_BUSY_MSB 2
-#define MAC_PCU_20_40_MODE_TX_HT20_ON_EXT_BUSY_LSB 2
-#define MAC_PCU_20_40_MODE_TX_HT20_ON_EXT_BUSY_MASK 0x00000004
-#define MAC_PCU_20_40_MODE_TX_HT20_ON_EXT_BUSY_GET(x) (((x) & MAC_PCU_20_40_MODE_TX_HT20_ON_EXT_BUSY_MASK) >> MAC_PCU_20_40_MODE_TX_HT20_ON_EXT_BUSY_LSB)
-#define MAC_PCU_20_40_MODE_TX_HT20_ON_EXT_BUSY_SET(x) (((x) << MAC_PCU_20_40_MODE_TX_HT20_ON_EXT_BUSY_LSB) & MAC_PCU_20_40_MODE_TX_HT20_ON_EXT_BUSY_MASK)
-#define MAC_PCU_20_40_MODE_EXT_PIFS_ENABLE_MSB   1
-#define MAC_PCU_20_40_MODE_EXT_PIFS_ENABLE_LSB   1
-#define MAC_PCU_20_40_MODE_EXT_PIFS_ENABLE_MASK  0x00000002
-#define MAC_PCU_20_40_MODE_EXT_PIFS_ENABLE_GET(x) (((x) & MAC_PCU_20_40_MODE_EXT_PIFS_ENABLE_MASK) >> MAC_PCU_20_40_MODE_EXT_PIFS_ENABLE_LSB)
-#define MAC_PCU_20_40_MODE_EXT_PIFS_ENABLE_SET(x) (((x) << MAC_PCU_20_40_MODE_EXT_PIFS_ENABLE_LSB) & MAC_PCU_20_40_MODE_EXT_PIFS_ENABLE_MASK)
-#define MAC_PCU_20_40_MODE_JOINED_RX_CLEAR_MSB   0
-#define MAC_PCU_20_40_MODE_JOINED_RX_CLEAR_LSB   0
-#define MAC_PCU_20_40_MODE_JOINED_RX_CLEAR_MASK  0x00000001
-#define MAC_PCU_20_40_MODE_JOINED_RX_CLEAR_GET(x) (((x) & MAC_PCU_20_40_MODE_JOINED_RX_CLEAR_MASK) >> MAC_PCU_20_40_MODE_JOINED_RX_CLEAR_LSB)
-#define MAC_PCU_20_40_MODE_JOINED_RX_CLEAR_SET(x) (((x) << MAC_PCU_20_40_MODE_JOINED_RX_CLEAR_LSB) & MAC_PCU_20_40_MODE_JOINED_RX_CLEAR_MASK)
-
-#define MAC_PCU_RX_CLEAR_DIFF_CNT_ADDRESS        0x00008128
-#define MAC_PCU_RX_CLEAR_DIFF_CNT_OFFSET         0x00000128
-#define MAC_PCU_RX_CLEAR_DIFF_CNT_VALUE_MSB      31
-#define MAC_PCU_RX_CLEAR_DIFF_CNT_VALUE_LSB      0
-#define MAC_PCU_RX_CLEAR_DIFF_CNT_VALUE_MASK     0xffffffff
-#define MAC_PCU_RX_CLEAR_DIFF_CNT_VALUE_GET(x)   (((x) & MAC_PCU_RX_CLEAR_DIFF_CNT_VALUE_MASK) >> MAC_PCU_RX_CLEAR_DIFF_CNT_VALUE_LSB)
-#define MAC_PCU_RX_CLEAR_DIFF_CNT_VALUE_SET(x)   (((x) << MAC_PCU_RX_CLEAR_DIFF_CNT_VALUE_LSB) & MAC_PCU_RX_CLEAR_DIFF_CNT_VALUE_MASK)
-
-#define MAC_PCU_SELF_GEN_ANTENNA_MASK_ADDRESS    0x0000812c
-#define MAC_PCU_SELF_GEN_ANTENNA_MASK_OFFSET     0x0000012c
-#define MAC_PCU_SELF_GEN_ANTENNA_MASK_VALUE_MSB  2
-#define MAC_PCU_SELF_GEN_ANTENNA_MASK_VALUE_LSB  0
-#define MAC_PCU_SELF_GEN_ANTENNA_MASK_VALUE_MASK 0x00000007
-#define MAC_PCU_SELF_GEN_ANTENNA_MASK_VALUE_GET(x) (((x) & MAC_PCU_SELF_GEN_ANTENNA_MASK_VALUE_MASK) >> MAC_PCU_SELF_GEN_ANTENNA_MASK_VALUE_LSB)
-#define MAC_PCU_SELF_GEN_ANTENNA_MASK_VALUE_SET(x) (((x) << MAC_PCU_SELF_GEN_ANTENNA_MASK_VALUE_LSB) & MAC_PCU_SELF_GEN_ANTENNA_MASK_VALUE_MASK)
-
-#define MAC_PCU_BA_BAR_CONTROL_ADDRESS           0x00008130
-#define MAC_PCU_BA_BAR_CONTROL_OFFSET            0x00000130
-#define MAC_PCU_BA_BAR_CONTROL_UPDATE_BA_BITMAP_QOS_NULL_MSB 12
-#define MAC_PCU_BA_BAR_CONTROL_UPDATE_BA_BITMAP_QOS_NULL_LSB 12
-#define MAC_PCU_BA_BAR_CONTROL_UPDATE_BA_BITMAP_QOS_NULL_MASK 0x00001000
-#define MAC_PCU_BA_BAR_CONTROL_UPDATE_BA_BITMAP_QOS_NULL_GET(x) (((x) & MAC_PCU_BA_BAR_CONTROL_UPDATE_BA_BITMAP_QOS_NULL_MASK) >> MAC_PCU_BA_BAR_CONTROL_UPDATE_BA_BITMAP_QOS_NULL_LSB)
-#define MAC_PCU_BA_BAR_CONTROL_UPDATE_BA_BITMAP_QOS_NULL_SET(x) (((x) << MAC_PCU_BA_BAR_CONTROL_UPDATE_BA_BITMAP_QOS_NULL_LSB) & MAC_PCU_BA_BAR_CONTROL_UPDATE_BA_BITMAP_QOS_NULL_MASK)
-#define MAC_PCU_BA_BAR_CONTROL_TX_BA_CLEAR_BA_VALID_MSB 11
-#define MAC_PCU_BA_BAR_CONTROL_TX_BA_CLEAR_BA_VALID_LSB 11
-#define MAC_PCU_BA_BAR_CONTROL_TX_BA_CLEAR_BA_VALID_MASK 0x00000800
-#define MAC_PCU_BA_BAR_CONTROL_TX_BA_CLEAR_BA_VALID_GET(x) (((x) & MAC_PCU_BA_BAR_CONTROL_TX_BA_CLEAR_BA_VALID_MASK) >> MAC_PCU_BA_BAR_CONTROL_TX_BA_CLEAR_BA_VALID_LSB)
-#define MAC_PCU_BA_BAR_CONTROL_TX_BA_CLEAR_BA_VALID_SET(x) (((x) << MAC_PCU_BA_BAR_CONTROL_TX_BA_CLEAR_BA_VALID_LSB) & MAC_PCU_BA_BAR_CONTROL_TX_BA_CLEAR_BA_VALID_MASK)
-#define MAC_PCU_BA_BAR_CONTROL_FORCE_NO_MATCH_MSB 10
-#define MAC_PCU_BA_BAR_CONTROL_FORCE_NO_MATCH_LSB 10
-#define MAC_PCU_BA_BAR_CONTROL_FORCE_NO_MATCH_MASK 0x00000400
-#define MAC_PCU_BA_BAR_CONTROL_FORCE_NO_MATCH_GET(x) (((x) & MAC_PCU_BA_BAR_CONTROL_FORCE_NO_MATCH_MASK) >> MAC_PCU_BA_BAR_CONTROL_FORCE_NO_MATCH_LSB)
-#define MAC_PCU_BA_BAR_CONTROL_FORCE_NO_MATCH_SET(x) (((x) << MAC_PCU_BA_BAR_CONTROL_FORCE_NO_MATCH_LSB) & MAC_PCU_BA_BAR_CONTROL_FORCE_NO_MATCH_MASK)
-#define MAC_PCU_BA_BAR_CONTROL_ACK_POLICY_VALUE_MSB 9
-#define MAC_PCU_BA_BAR_CONTROL_ACK_POLICY_VALUE_LSB 9
-#define MAC_PCU_BA_BAR_CONTROL_ACK_POLICY_VALUE_MASK 0x00000200
-#define MAC_PCU_BA_BAR_CONTROL_ACK_POLICY_VALUE_GET(x) (((x) & MAC_PCU_BA_BAR_CONTROL_ACK_POLICY_VALUE_MASK) >> MAC_PCU_BA_BAR_CONTROL_ACK_POLICY_VALUE_LSB)
-#define MAC_PCU_BA_BAR_CONTROL_ACK_POLICY_VALUE_SET(x) (((x) << MAC_PCU_BA_BAR_CONTROL_ACK_POLICY_VALUE_LSB) & MAC_PCU_BA_BAR_CONTROL_ACK_POLICY_VALUE_MASK)
-#define MAC_PCU_BA_BAR_CONTROL_COMPRESSED_VALUE_MSB 8
-#define MAC_PCU_BA_BAR_CONTROL_COMPRESSED_VALUE_LSB 8
-#define MAC_PCU_BA_BAR_CONTROL_COMPRESSED_VALUE_MASK 0x00000100
-#define MAC_PCU_BA_BAR_CONTROL_COMPRESSED_VALUE_GET(x) (((x) & MAC_PCU_BA_BAR_CONTROL_COMPRESSED_VALUE_MASK) >> MAC_PCU_BA_BAR_CONTROL_COMPRESSED_VALUE_LSB)
-#define MAC_PCU_BA_BAR_CONTROL_COMPRESSED_VALUE_SET(x) (((x) << MAC_PCU_BA_BAR_CONTROL_COMPRESSED_VALUE_LSB) & MAC_PCU_BA_BAR_CONTROL_COMPRESSED_VALUE_MASK)
-#define MAC_PCU_BA_BAR_CONTROL_ACK_POLICY_OFFSET_MSB 7
-#define MAC_PCU_BA_BAR_CONTROL_ACK_POLICY_OFFSET_LSB 4
-#define MAC_PCU_BA_BAR_CONTROL_ACK_POLICY_OFFSET_MASK 0x000000f0
-#define MAC_PCU_BA_BAR_CONTROL_ACK_POLICY_OFFSET_GET(x) (((x) & MAC_PCU_BA_BAR_CONTROL_ACK_POLICY_OFFSET_MASK) >> MAC_PCU_BA_BAR_CONTROL_ACK_POLICY_OFFSET_LSB)
-#define MAC_PCU_BA_BAR_CONTROL_ACK_POLICY_OFFSET_SET(x) (((x) << MAC_PCU_BA_BAR_CONTROL_ACK_POLICY_OFFSET_LSB) & MAC_PCU_BA_BAR_CONTROL_ACK_POLICY_OFFSET_MASK)
-#define MAC_PCU_BA_BAR_CONTROL_COMPRESSED_OFFSET_MSB 3
-#define MAC_PCU_BA_BAR_CONTROL_COMPRESSED_OFFSET_LSB 0
-#define MAC_PCU_BA_BAR_CONTROL_COMPRESSED_OFFSET_MASK 0x0000000f
-#define MAC_PCU_BA_BAR_CONTROL_COMPRESSED_OFFSET_GET(x) (((x) & MAC_PCU_BA_BAR_CONTROL_COMPRESSED_OFFSET_MASK) >> MAC_PCU_BA_BAR_CONTROL_COMPRESSED_OFFSET_LSB)
-#define MAC_PCU_BA_BAR_CONTROL_COMPRESSED_OFFSET_SET(x) (((x) << MAC_PCU_BA_BAR_CONTROL_COMPRESSED_OFFSET_LSB) & MAC_PCU_BA_BAR_CONTROL_COMPRESSED_OFFSET_MASK)
-
-#define MAC_PCU_LEGACY_PLCP_SPOOF_ADDRESS        0x00008134
-#define MAC_PCU_LEGACY_PLCP_SPOOF_OFFSET         0x00000134
-#define MAC_PCU_LEGACY_PLCP_SPOOF_MIN_LENGTH_MSB 12
-#define MAC_PCU_LEGACY_PLCP_SPOOF_MIN_LENGTH_LSB 8
-#define MAC_PCU_LEGACY_PLCP_SPOOF_MIN_LENGTH_MASK 0x00001f00
-#define MAC_PCU_LEGACY_PLCP_SPOOF_MIN_LENGTH_GET(x) (((x) & MAC_PCU_LEGACY_PLCP_SPOOF_MIN_LENGTH_MASK) >> MAC_PCU_LEGACY_PLCP_SPOOF_MIN_LENGTH_LSB)
-#define MAC_PCU_LEGACY_PLCP_SPOOF_MIN_LENGTH_SET(x) (((x) << MAC_PCU_LEGACY_PLCP_SPOOF_MIN_LENGTH_LSB) & MAC_PCU_LEGACY_PLCP_SPOOF_MIN_LENGTH_MASK)
-#define MAC_PCU_LEGACY_PLCP_SPOOF_EIFS_MINUS_DIFS_MSB 7
-#define MAC_PCU_LEGACY_PLCP_SPOOF_EIFS_MINUS_DIFS_LSB 0
-#define MAC_PCU_LEGACY_PLCP_SPOOF_EIFS_MINUS_DIFS_MASK 0x000000ff
-#define MAC_PCU_LEGACY_PLCP_SPOOF_EIFS_MINUS_DIFS_GET(x) (((x) & MAC_PCU_LEGACY_PLCP_SPOOF_EIFS_MINUS_DIFS_MASK) >> MAC_PCU_LEGACY_PLCP_SPOOF_EIFS_MINUS_DIFS_LSB)
-#define MAC_PCU_LEGACY_PLCP_SPOOF_EIFS_MINUS_DIFS_SET(x) (((x) << MAC_PCU_LEGACY_PLCP_SPOOF_EIFS_MINUS_DIFS_LSB) & MAC_PCU_LEGACY_PLCP_SPOOF_EIFS_MINUS_DIFS_MASK)
-
-#define MAC_PCU_PHY_ERROR_MASK_CONT_ADDRESS      0x00008138
-#define MAC_PCU_PHY_ERROR_MASK_CONT_OFFSET       0x00000138
-#define MAC_PCU_PHY_ERROR_MASK_CONT_EIFS_VALUE_MSB 23
-#define MAC_PCU_PHY_ERROR_MASK_CONT_EIFS_VALUE_LSB 16
-#define MAC_PCU_PHY_ERROR_MASK_CONT_EIFS_VALUE_MASK 0x00ff0000
-#define MAC_PCU_PHY_ERROR_MASK_CONT_EIFS_VALUE_GET(x) (((x) & MAC_PCU_PHY_ERROR_MASK_CONT_EIFS_VALUE_MASK) >> MAC_PCU_PHY_ERROR_MASK_CONT_EIFS_VALUE_LSB)
-#define MAC_PCU_PHY_ERROR_MASK_CONT_EIFS_VALUE_SET(x) (((x) << MAC_PCU_PHY_ERROR_MASK_CONT_EIFS_VALUE_LSB) & MAC_PCU_PHY_ERROR_MASK_CONT_EIFS_VALUE_MASK)
-#define MAC_PCU_PHY_ERROR_MASK_CONT_MASK_VALUE_MSB 7
-#define MAC_PCU_PHY_ERROR_MASK_CONT_MASK_VALUE_LSB 0
-#define MAC_PCU_PHY_ERROR_MASK_CONT_MASK_VALUE_MASK 0x000000ff
-#define MAC_PCU_PHY_ERROR_MASK_CONT_MASK_VALUE_GET(x) (((x) & MAC_PCU_PHY_ERROR_MASK_CONT_MASK_VALUE_MASK) >> MAC_PCU_PHY_ERROR_MASK_CONT_MASK_VALUE_LSB)
-#define MAC_PCU_PHY_ERROR_MASK_CONT_MASK_VALUE_SET(x) (((x) << MAC_PCU_PHY_ERROR_MASK_CONT_MASK_VALUE_LSB) & MAC_PCU_PHY_ERROR_MASK_CONT_MASK_VALUE_MASK)
-
-#define MAC_PCU_TX_TIMER_ADDRESS                 0x0000813c
-#define MAC_PCU_TX_TIMER_OFFSET                  0x0000013c
-#define MAC_PCU_TX_TIMER_QUIET_TIMER_ENABLE_MSB  25
-#define MAC_PCU_TX_TIMER_QUIET_TIMER_ENABLE_LSB  25
-#define MAC_PCU_TX_TIMER_QUIET_TIMER_ENABLE_MASK 0x02000000
-#define MAC_PCU_TX_TIMER_QUIET_TIMER_ENABLE_GET(x) (((x) & MAC_PCU_TX_TIMER_QUIET_TIMER_ENABLE_MASK) >> MAC_PCU_TX_TIMER_QUIET_TIMER_ENABLE_LSB)
-#define MAC_PCU_TX_TIMER_QUIET_TIMER_ENABLE_SET(x) (((x) << MAC_PCU_TX_TIMER_QUIET_TIMER_ENABLE_LSB) & MAC_PCU_TX_TIMER_QUIET_TIMER_ENABLE_MASK)
-#define MAC_PCU_TX_TIMER_QUIET_TIMER_MSB         24
-#define MAC_PCU_TX_TIMER_QUIET_TIMER_LSB         20
-#define MAC_PCU_TX_TIMER_QUIET_TIMER_MASK        0x01f00000
-#define MAC_PCU_TX_TIMER_QUIET_TIMER_GET(x)      (((x) & MAC_PCU_TX_TIMER_QUIET_TIMER_MASK) >> MAC_PCU_TX_TIMER_QUIET_TIMER_LSB)
-#define MAC_PCU_TX_TIMER_QUIET_TIMER_SET(x)      (((x) << MAC_PCU_TX_TIMER_QUIET_TIMER_LSB) & MAC_PCU_TX_TIMER_QUIET_TIMER_MASK)
-#define MAC_PCU_TX_TIMER_RIFS_TIMER_MSB          19
-#define MAC_PCU_TX_TIMER_RIFS_TIMER_LSB          16
-#define MAC_PCU_TX_TIMER_RIFS_TIMER_MASK         0x000f0000
-#define MAC_PCU_TX_TIMER_RIFS_TIMER_GET(x)       (((x) & MAC_PCU_TX_TIMER_RIFS_TIMER_MASK) >> MAC_PCU_TX_TIMER_RIFS_TIMER_LSB)
-#define MAC_PCU_TX_TIMER_RIFS_TIMER_SET(x)       (((x) << MAC_PCU_TX_TIMER_RIFS_TIMER_LSB) & MAC_PCU_TX_TIMER_RIFS_TIMER_MASK)
-#define MAC_PCU_TX_TIMER_TX_TIMER_ENABLE_MSB     15
-#define MAC_PCU_TX_TIMER_TX_TIMER_ENABLE_LSB     15
-#define MAC_PCU_TX_TIMER_TX_TIMER_ENABLE_MASK    0x00008000
-#define MAC_PCU_TX_TIMER_TX_TIMER_ENABLE_GET(x)  (((x) & MAC_PCU_TX_TIMER_TX_TIMER_ENABLE_MASK) >> MAC_PCU_TX_TIMER_TX_TIMER_ENABLE_LSB)
-#define MAC_PCU_TX_TIMER_TX_TIMER_ENABLE_SET(x)  (((x) << MAC_PCU_TX_TIMER_TX_TIMER_ENABLE_LSB) & MAC_PCU_TX_TIMER_TX_TIMER_ENABLE_MASK)
-#define MAC_PCU_TX_TIMER_TX_TIMER_MSB            14
-#define MAC_PCU_TX_TIMER_TX_TIMER_LSB            0
-#define MAC_PCU_TX_TIMER_TX_TIMER_MASK           0x00007fff
-#define MAC_PCU_TX_TIMER_TX_TIMER_GET(x)         (((x) & MAC_PCU_TX_TIMER_TX_TIMER_MASK) >> MAC_PCU_TX_TIMER_TX_TIMER_LSB)
-#define MAC_PCU_TX_TIMER_TX_TIMER_SET(x)         (((x) << MAC_PCU_TX_TIMER_TX_TIMER_LSB) & MAC_PCU_TX_TIMER_TX_TIMER_MASK)
-
-#define MAC_PCU_TXBUF_CTRL_ADDRESS               0x00008140
-#define MAC_PCU_TXBUF_CTRL_OFFSET                0x00000140
-#define MAC_PCU_TXBUF_CTRL_TX_FIFO_WRAP_ENABLE_MSB 16
-#define MAC_PCU_TXBUF_CTRL_TX_FIFO_WRAP_ENABLE_LSB 16
-#define MAC_PCU_TXBUF_CTRL_TX_FIFO_WRAP_ENABLE_MASK 0x00010000
-#define MAC_PCU_TXBUF_CTRL_TX_FIFO_WRAP_ENABLE_GET(x) (((x) & MAC_PCU_TXBUF_CTRL_TX_FIFO_WRAP_ENABLE_MASK) >> MAC_PCU_TXBUF_CTRL_TX_FIFO_WRAP_ENABLE_LSB)
-#define MAC_PCU_TXBUF_CTRL_TX_FIFO_WRAP_ENABLE_SET(x) (((x) << MAC_PCU_TXBUF_CTRL_TX_FIFO_WRAP_ENABLE_LSB) & MAC_PCU_TXBUF_CTRL_TX_FIFO_WRAP_ENABLE_MASK)
-#define MAC_PCU_TXBUF_CTRL_USABLE_ENTRIES_MSB    11
-#define MAC_PCU_TXBUF_CTRL_USABLE_ENTRIES_LSB    0
-#define MAC_PCU_TXBUF_CTRL_USABLE_ENTRIES_MASK   0x00000fff
-#define MAC_PCU_TXBUF_CTRL_USABLE_ENTRIES_GET(x) (((x) & MAC_PCU_TXBUF_CTRL_USABLE_ENTRIES_MASK) >> MAC_PCU_TXBUF_CTRL_USABLE_ENTRIES_LSB)
-#define MAC_PCU_TXBUF_CTRL_USABLE_ENTRIES_SET(x) (((x) << MAC_PCU_TXBUF_CTRL_USABLE_ENTRIES_LSB) & MAC_PCU_TXBUF_CTRL_USABLE_ENTRIES_MASK)
-
-#define MAC_PCU_MISC_MODE2_ADDRESS               0x00008144
-#define MAC_PCU_MISC_MODE2_OFFSET                0x00000144
-#define MAC_PCU_MISC_MODE2_RESERVED_1_MSB        31
-#define MAC_PCU_MISC_MODE2_RESERVED_1_LSB        28
-#define MAC_PCU_MISC_MODE2_RESERVED_1_MASK       0xf0000000
-#define MAC_PCU_MISC_MODE2_RESERVED_1_GET(x)     (((x) & MAC_PCU_MISC_MODE2_RESERVED_1_MASK) >> MAC_PCU_MISC_MODE2_RESERVED_1_LSB)
-#define MAC_PCU_MISC_MODE2_RESERVED_1_SET(x)     (((x) << MAC_PCU_MISC_MODE2_RESERVED_1_LSB) & MAC_PCU_MISC_MODE2_RESERVED_1_MASK)
-#define MAC_PCU_MISC_MODE2_RCV_TIMESTAMP_FIX_MSB 27
-#define MAC_PCU_MISC_MODE2_RCV_TIMESTAMP_FIX_LSB 27
-#define MAC_PCU_MISC_MODE2_RCV_TIMESTAMP_FIX_MASK 0x08000000
-#define MAC_PCU_MISC_MODE2_RCV_TIMESTAMP_FIX_GET(x) (((x) & MAC_PCU_MISC_MODE2_RCV_TIMESTAMP_FIX_MASK) >> MAC_PCU_MISC_MODE2_RCV_TIMESTAMP_FIX_LSB)
-#define MAC_PCU_MISC_MODE2_RCV_TIMESTAMP_FIX_SET(x) (((x) << MAC_PCU_MISC_MODE2_RCV_TIMESTAMP_FIX_LSB) & MAC_PCU_MISC_MODE2_RCV_TIMESTAMP_FIX_MASK)
-#define MAC_PCU_MISC_MODE2_BEACON_FROM_TO_DS_MSB 26
-#define MAC_PCU_MISC_MODE2_BEACON_FROM_TO_DS_LSB 26
-#define MAC_PCU_MISC_MODE2_BEACON_FROM_TO_DS_MASK 0x04000000
-#define MAC_PCU_MISC_MODE2_BEACON_FROM_TO_DS_GET(x) (((x) & MAC_PCU_MISC_MODE2_BEACON_FROM_TO_DS_MASK) >> MAC_PCU_MISC_MODE2_BEACON_FROM_TO_DS_LSB)
-#define MAC_PCU_MISC_MODE2_BEACON_FROM_TO_DS_SET(x) (((x) << MAC_PCU_MISC_MODE2_BEACON_FROM_TO_DS_LSB) & MAC_PCU_MISC_MODE2_BEACON_FROM_TO_DS_MASK)
-#define MAC_PCU_MISC_MODE2_PM_FIELD_FOR_MGMT_MSB 25
-#define MAC_PCU_MISC_MODE2_PM_FIELD_FOR_MGMT_LSB 25
-#define MAC_PCU_MISC_MODE2_PM_FIELD_FOR_MGMT_MASK 0x02000000
-#define MAC_PCU_MISC_MODE2_PM_FIELD_FOR_MGMT_GET(x) (((x) & MAC_PCU_MISC_MODE2_PM_FIELD_FOR_MGMT_MASK) >> MAC_PCU_MISC_MODE2_PM_FIELD_FOR_MGMT_LSB)
-#define MAC_PCU_MISC_MODE2_PM_FIELD_FOR_MGMT_SET(x) (((x) << MAC_PCU_MISC_MODE2_PM_FIELD_FOR_MGMT_LSB) & MAC_PCU_MISC_MODE2_PM_FIELD_FOR_MGMT_MASK)
-#define MAC_PCU_MISC_MODE2_PM_FIELD_FOR_DAT_MSB  24
-#define MAC_PCU_MISC_MODE2_PM_FIELD_FOR_DAT_LSB  24
-#define MAC_PCU_MISC_MODE2_PM_FIELD_FOR_DAT_MASK 0x01000000
-#define MAC_PCU_MISC_MODE2_PM_FIELD_FOR_DAT_GET(x) (((x) & MAC_PCU_MISC_MODE2_PM_FIELD_FOR_DAT_MASK) >> MAC_PCU_MISC_MODE2_PM_FIELD_FOR_DAT_LSB)
-#define MAC_PCU_MISC_MODE2_PM_FIELD_FOR_DAT_SET(x) (((x) << MAC_PCU_MISC_MODE2_PM_FIELD_FOR_DAT_LSB) & MAC_PCU_MISC_MODE2_PM_FIELD_FOR_DAT_MASK)
-#define MAC_PCU_MISC_MODE2_IGNORE_TXOP_IF_ZERO_MSB 23
-#define MAC_PCU_MISC_MODE2_IGNORE_TXOP_IF_ZERO_LSB 23
-#define MAC_PCU_MISC_MODE2_IGNORE_TXOP_IF_ZERO_MASK 0x00800000
-#define MAC_PCU_MISC_MODE2_IGNORE_TXOP_IF_ZERO_GET(x) (((x) & MAC_PCU_MISC_MODE2_IGNORE_TXOP_IF_ZERO_MASK) >> MAC_PCU_MISC_MODE2_IGNORE_TXOP_IF_ZERO_LSB)
-#define MAC_PCU_MISC_MODE2_IGNORE_TXOP_IF_ZERO_SET(x) (((x) << MAC_PCU_MISC_MODE2_IGNORE_TXOP_IF_ZERO_LSB) & MAC_PCU_MISC_MODE2_IGNORE_TXOP_IF_ZERO_MASK)
-#define MAC_PCU_MISC_MODE2_IGNORE_TXOP_1ST_PKT_MSB 22
-#define MAC_PCU_MISC_MODE2_IGNORE_TXOP_1ST_PKT_LSB 22
-#define MAC_PCU_MISC_MODE2_IGNORE_TXOP_1ST_PKT_MASK 0x00400000
-#define MAC_PCU_MISC_MODE2_IGNORE_TXOP_1ST_PKT_GET(x) (((x) & MAC_PCU_MISC_MODE2_IGNORE_TXOP_1ST_PKT_MASK) >> MAC_PCU_MISC_MODE2_IGNORE_TXOP_1ST_PKT_LSB)
-#define MAC_PCU_MISC_MODE2_IGNORE_TXOP_1ST_PKT_SET(x) (((x) << MAC_PCU_MISC_MODE2_IGNORE_TXOP_1ST_PKT_LSB) & MAC_PCU_MISC_MODE2_IGNORE_TXOP_1ST_PKT_MASK)
-#define MAC_PCU_MISC_MODE2_CLEAR_MORE_FRAG_MSB   21
-#define MAC_PCU_MISC_MODE2_CLEAR_MORE_FRAG_LSB   21
-#define MAC_PCU_MISC_MODE2_CLEAR_MORE_FRAG_MASK  0x00200000
-#define MAC_PCU_MISC_MODE2_CLEAR_MORE_FRAG_GET(x) (((x) & MAC_PCU_MISC_MODE2_CLEAR_MORE_FRAG_MASK) >> MAC_PCU_MISC_MODE2_CLEAR_MORE_FRAG_LSB)
-#define MAC_PCU_MISC_MODE2_CLEAR_MORE_FRAG_SET(x) (((x) << MAC_PCU_MISC_MODE2_CLEAR_MORE_FRAG_LSB) & MAC_PCU_MISC_MODE2_CLEAR_MORE_FRAG_MASK)
-#define MAC_PCU_MISC_MODE2_BUG_28676_MSB         20
-#define MAC_PCU_MISC_MODE2_BUG_28676_LSB         20
-#define MAC_PCU_MISC_MODE2_BUG_28676_MASK        0x00100000
-#define MAC_PCU_MISC_MODE2_BUG_28676_GET(x)      (((x) & MAC_PCU_MISC_MODE2_BUG_28676_MASK) >> MAC_PCU_MISC_MODE2_BUG_28676_LSB)
-#define MAC_PCU_MISC_MODE2_BUG_28676_SET(x)      (((x) << MAC_PCU_MISC_MODE2_BUG_28676_LSB) & MAC_PCU_MISC_MODE2_BUG_28676_MASK)
-#define MAC_PCU_MISC_MODE2_DUR_ACCOUNT_BY_BA_MSB 19
-#define MAC_PCU_MISC_MODE2_DUR_ACCOUNT_BY_BA_LSB 19
-#define MAC_PCU_MISC_MODE2_DUR_ACCOUNT_BY_BA_MASK 0x00080000
-#define MAC_PCU_MISC_MODE2_DUR_ACCOUNT_BY_BA_GET(x) (((x) & MAC_PCU_MISC_MODE2_DUR_ACCOUNT_BY_BA_MASK) >> MAC_PCU_MISC_MODE2_DUR_ACCOUNT_BY_BA_LSB)
-#define MAC_PCU_MISC_MODE2_DUR_ACCOUNT_BY_BA_SET(x) (((x) << MAC_PCU_MISC_MODE2_DUR_ACCOUNT_BY_BA_LSB) & MAC_PCU_MISC_MODE2_DUR_ACCOUNT_BY_BA_MASK)
-#define MAC_PCU_MISC_MODE2_BC_MC_WAPI_MODE_MSB   18
-#define MAC_PCU_MISC_MODE2_BC_MC_WAPI_MODE_LSB   18
-#define MAC_PCU_MISC_MODE2_BC_MC_WAPI_MODE_MASK  0x00040000
-#define MAC_PCU_MISC_MODE2_BC_MC_WAPI_MODE_GET(x) (((x) & MAC_PCU_MISC_MODE2_BC_MC_WAPI_MODE_MASK) >> MAC_PCU_MISC_MODE2_BC_MC_WAPI_MODE_LSB)
-#define MAC_PCU_MISC_MODE2_BC_MC_WAPI_MODE_SET(x) (((x) << MAC_PCU_MISC_MODE2_BC_MC_WAPI_MODE_LSB) & MAC_PCU_MISC_MODE2_BC_MC_WAPI_MODE_MASK)
-#define MAC_PCU_MISC_MODE2_AGG_WEP_MSB           17
-#define MAC_PCU_MISC_MODE2_AGG_WEP_LSB           17
-#define MAC_PCU_MISC_MODE2_AGG_WEP_MASK          0x00020000
-#define MAC_PCU_MISC_MODE2_AGG_WEP_GET(x)        (((x) & MAC_PCU_MISC_MODE2_AGG_WEP_MASK) >> MAC_PCU_MISC_MODE2_AGG_WEP_LSB)
-#define MAC_PCU_MISC_MODE2_AGG_WEP_SET(x)        (((x) << MAC_PCU_MISC_MODE2_AGG_WEP_LSB) & MAC_PCU_MISC_MODE2_AGG_WEP_MASK)
-#define MAC_PCU_MISC_MODE2_ENABLE_LOAD_NAV_BEACON_DURATION_MSB 16
-#define MAC_PCU_MISC_MODE2_ENABLE_LOAD_NAV_BEACON_DURATION_LSB 16
-#define MAC_PCU_MISC_MODE2_ENABLE_LOAD_NAV_BEACON_DURATION_MASK 0x00010000
-#define MAC_PCU_MISC_MODE2_ENABLE_LOAD_NAV_BEACON_DURATION_GET(x) (((x) & MAC_PCU_MISC_MODE2_ENABLE_LOAD_NAV_BEACON_DURATION_MASK) >> MAC_PCU_MISC_MODE2_ENABLE_LOAD_NAV_BEACON_DURATION_LSB)
-#define MAC_PCU_MISC_MODE2_ENABLE_LOAD_NAV_BEACON_DURATION_SET(x) (((x) << MAC_PCU_MISC_MODE2_ENABLE_LOAD_NAV_BEACON_DURATION_LSB) & MAC_PCU_MISC_MODE2_ENABLE_LOAD_NAV_BEACON_DURATION_MASK)
-#define MAC_PCU_MISC_MODE2_MGMT_QOS_MSB          15
-#define MAC_PCU_MISC_MODE2_MGMT_QOS_LSB          8
-#define MAC_PCU_MISC_MODE2_MGMT_QOS_MASK         0x0000ff00
-#define MAC_PCU_MISC_MODE2_MGMT_QOS_GET(x)       (((x) & MAC_PCU_MISC_MODE2_MGMT_QOS_MASK) >> MAC_PCU_MISC_MODE2_MGMT_QOS_LSB)
-#define MAC_PCU_MISC_MODE2_MGMT_QOS_SET(x)       (((x) << MAC_PCU_MISC_MODE2_MGMT_QOS_LSB) & MAC_PCU_MISC_MODE2_MGMT_QOS_MASK)
-#define MAC_PCU_MISC_MODE2_CFP_IGNORE_MSB        7
-#define MAC_PCU_MISC_MODE2_CFP_IGNORE_LSB        7
-#define MAC_PCU_MISC_MODE2_CFP_IGNORE_MASK       0x00000080
-#define MAC_PCU_MISC_MODE2_CFP_IGNORE_GET(x)     (((x) & MAC_PCU_MISC_MODE2_CFP_IGNORE_MASK) >> MAC_PCU_MISC_MODE2_CFP_IGNORE_LSB)
-#define MAC_PCU_MISC_MODE2_CFP_IGNORE_SET(x)     (((x) << MAC_PCU_MISC_MODE2_CFP_IGNORE_LSB) & MAC_PCU_MISC_MODE2_CFP_IGNORE_MASK)
-#define MAC_PCU_MISC_MODE2_ADHOC_MCAST_KEYID_ENABLE_MSB 6
-#define MAC_PCU_MISC_MODE2_ADHOC_MCAST_KEYID_ENABLE_LSB 6
-#define MAC_PCU_MISC_MODE2_ADHOC_MCAST_KEYID_ENABLE_MASK 0x00000040
-#define MAC_PCU_MISC_MODE2_ADHOC_MCAST_KEYID_ENABLE_GET(x) (((x) & MAC_PCU_MISC_MODE2_ADHOC_MCAST_KEYID_ENABLE_MASK) >> MAC_PCU_MISC_MODE2_ADHOC_MCAST_KEYID_ENABLE_LSB)
-#define MAC_PCU_MISC_MODE2_ADHOC_MCAST_KEYID_ENABLE_SET(x) (((x) << MAC_PCU_MISC_MODE2_ADHOC_MCAST_KEYID_ENABLE_LSB) & MAC_PCU_MISC_MODE2_ADHOC_MCAST_KEYID_ENABLE_MASK)
-#define MAC_PCU_MISC_MODE2_RESERVED_2_MSB        5
-#define MAC_PCU_MISC_MODE2_RESERVED_2_LSB        5
-#define MAC_PCU_MISC_MODE2_RESERVED_2_MASK       0x00000020
-#define MAC_PCU_MISC_MODE2_RESERVED_2_GET(x)     (((x) & MAC_PCU_MISC_MODE2_RESERVED_2_MASK) >> MAC_PCU_MISC_MODE2_RESERVED_2_LSB)
-#define MAC_PCU_MISC_MODE2_RESERVED_2_SET(x)     (((x) << MAC_PCU_MISC_MODE2_RESERVED_2_LSB) & MAC_PCU_MISC_MODE2_RESERVED_2_MASK)
-#define MAC_PCU_MISC_MODE2_BUG_58057_FIX_ENABLE_MSB 4
-#define MAC_PCU_MISC_MODE2_BUG_58057_FIX_ENABLE_LSB 4
-#define MAC_PCU_MISC_MODE2_BUG_58057_FIX_ENABLE_MASK 0x00000010
-#define MAC_PCU_MISC_MODE2_BUG_58057_FIX_ENABLE_GET(x) (((x) & MAC_PCU_MISC_MODE2_BUG_58057_FIX_ENABLE_MASK) >> MAC_PCU_MISC_MODE2_BUG_58057_FIX_ENABLE_LSB)
-#define MAC_PCU_MISC_MODE2_BUG_58057_FIX_ENABLE_SET(x) (((x) << MAC_PCU_MISC_MODE2_BUG_58057_FIX_ENABLE_LSB) & MAC_PCU_MISC_MODE2_BUG_58057_FIX_ENABLE_MASK)
-#define MAC_PCU_MISC_MODE2_RESERVED_0_MSB        3
-#define MAC_PCU_MISC_MODE2_RESERVED_0_LSB        3
-#define MAC_PCU_MISC_MODE2_RESERVED_0_MASK       0x00000008
-#define MAC_PCU_MISC_MODE2_RESERVED_0_GET(x)     (((x) & MAC_PCU_MISC_MODE2_RESERVED_0_MASK) >> MAC_PCU_MISC_MODE2_RESERVED_0_LSB)
-#define MAC_PCU_MISC_MODE2_RESERVED_0_SET(x)     (((x) << MAC_PCU_MISC_MODE2_RESERVED_0_LSB) & MAC_PCU_MISC_MODE2_RESERVED_0_MASK)
-#define MAC_PCU_MISC_MODE2_NO_CRYPTO_FOR_NON_DATA_PKT_MSB 2
-#define MAC_PCU_MISC_MODE2_NO_CRYPTO_FOR_NON_DATA_PKT_LSB 2
-#define MAC_PCU_MISC_MODE2_NO_CRYPTO_FOR_NON_DATA_PKT_MASK 0x00000004
-#define MAC_PCU_MISC_MODE2_NO_CRYPTO_FOR_NON_DATA_PKT_GET(x) (((x) & MAC_PCU_MISC_MODE2_NO_CRYPTO_FOR_NON_DATA_PKT_MASK) >> MAC_PCU_MISC_MODE2_NO_CRYPTO_FOR_NON_DATA_PKT_LSB)
-#define MAC_PCU_MISC_MODE2_NO_CRYPTO_FOR_NON_DATA_PKT_SET(x) (((x) << MAC_PCU_MISC_MODE2_NO_CRYPTO_FOR_NON_DATA_PKT_LSB) & MAC_PCU_MISC_MODE2_NO_CRYPTO_FOR_NON_DATA_PKT_MASK)
-#define MAC_PCU_MISC_MODE2_MGMT_CRYPTO_ENABLE_MSB 1
-#define MAC_PCU_MISC_MODE2_MGMT_CRYPTO_ENABLE_LSB 1
-#define MAC_PCU_MISC_MODE2_MGMT_CRYPTO_ENABLE_MASK 0x00000002
-#define MAC_PCU_MISC_MODE2_MGMT_CRYPTO_ENABLE_GET(x) (((x) & MAC_PCU_MISC_MODE2_MGMT_CRYPTO_ENABLE_MASK) >> MAC_PCU_MISC_MODE2_MGMT_CRYPTO_ENABLE_LSB)
-#define MAC_PCU_MISC_MODE2_MGMT_CRYPTO_ENABLE_SET(x) (((x) << MAC_PCU_MISC_MODE2_MGMT_CRYPTO_ENABLE_LSB) & MAC_PCU_MISC_MODE2_MGMT_CRYPTO_ENABLE_MASK)
-#define MAC_PCU_MISC_MODE2_BUG_21532_FIX_ENABLE_MSB 0
-#define MAC_PCU_MISC_MODE2_BUG_21532_FIX_ENABLE_LSB 0
-#define MAC_PCU_MISC_MODE2_BUG_21532_FIX_ENABLE_MASK 0x00000001
-#define MAC_PCU_MISC_MODE2_BUG_21532_FIX_ENABLE_GET(x) (((x) & MAC_PCU_MISC_MODE2_BUG_21532_FIX_ENABLE_MASK) >> MAC_PCU_MISC_MODE2_BUG_21532_FIX_ENABLE_LSB)
-#define MAC_PCU_MISC_MODE2_BUG_21532_FIX_ENABLE_SET(x) (((x) << MAC_PCU_MISC_MODE2_BUG_21532_FIX_ENABLE_LSB) & MAC_PCU_MISC_MODE2_BUG_21532_FIX_ENABLE_MASK)
-
-#define MAC_PCU_ALT_AES_MUTE_MASK_ADDRESS        0x00008148
-#define MAC_PCU_ALT_AES_MUTE_MASK_OFFSET         0x00000148
-#define MAC_PCU_ALT_AES_MUTE_MASK_QOS_MSB        31
-#define MAC_PCU_ALT_AES_MUTE_MASK_QOS_LSB        16
-#define MAC_PCU_ALT_AES_MUTE_MASK_QOS_MASK       0xffff0000
-#define MAC_PCU_ALT_AES_MUTE_MASK_QOS_GET(x)     (((x) & MAC_PCU_ALT_AES_MUTE_MASK_QOS_MASK) >> MAC_PCU_ALT_AES_MUTE_MASK_QOS_LSB)
-#define MAC_PCU_ALT_AES_MUTE_MASK_QOS_SET(x)     (((x) << MAC_PCU_ALT_AES_MUTE_MASK_QOS_LSB) & MAC_PCU_ALT_AES_MUTE_MASK_QOS_MASK)
-
-#define MAC_PCU_AZIMUTH_TIME_STAMP_ADDRESS       0x0000814c
-#define MAC_PCU_AZIMUTH_TIME_STAMP_OFFSET        0x0000014c
-#define MAC_PCU_AZIMUTH_TIME_STAMP_VALUE_MSB     31
-#define MAC_PCU_AZIMUTH_TIME_STAMP_VALUE_LSB     0
-#define MAC_PCU_AZIMUTH_TIME_STAMP_VALUE_MASK    0xffffffff
-#define MAC_PCU_AZIMUTH_TIME_STAMP_VALUE_GET(x)  (((x) & MAC_PCU_AZIMUTH_TIME_STAMP_VALUE_MASK) >> MAC_PCU_AZIMUTH_TIME_STAMP_VALUE_LSB)
-#define MAC_PCU_AZIMUTH_TIME_STAMP_VALUE_SET(x)  (((x) << MAC_PCU_AZIMUTH_TIME_STAMP_VALUE_LSB) & MAC_PCU_AZIMUTH_TIME_STAMP_VALUE_MASK)
-
-#define MAC_PCU_MAX_CFP_DUR_ADDRESS              0x00008150
-#define MAC_PCU_MAX_CFP_DUR_OFFSET               0x00000150
-#define MAC_PCU_MAX_CFP_DUR_USEC_FRAC_DENOMINATOR_MSB 7
-#define MAC_PCU_MAX_CFP_DUR_USEC_FRAC_DENOMINATOR_LSB 4
-#define MAC_PCU_MAX_CFP_DUR_USEC_FRAC_DENOMINATOR_MASK 0x000000f0
-#define MAC_PCU_MAX_CFP_DUR_USEC_FRAC_DENOMINATOR_GET(x) (((x) & MAC_PCU_MAX_CFP_DUR_USEC_FRAC_DENOMINATOR_MASK) >> MAC_PCU_MAX_CFP_DUR_USEC_FRAC_DENOMINATOR_LSB)
-#define MAC_PCU_MAX_CFP_DUR_USEC_FRAC_DENOMINATOR_SET(x) (((x) << MAC_PCU_MAX_CFP_DUR_USEC_FRAC_DENOMINATOR_LSB) & MAC_PCU_MAX_CFP_DUR_USEC_FRAC_DENOMINATOR_MASK)
-#define MAC_PCU_MAX_CFP_DUR_USEC_FRAC_NUMERATOR_MSB 3
-#define MAC_PCU_MAX_CFP_DUR_USEC_FRAC_NUMERATOR_LSB 0
-#define MAC_PCU_MAX_CFP_DUR_USEC_FRAC_NUMERATOR_MASK 0x0000000f
-#define MAC_PCU_MAX_CFP_DUR_USEC_FRAC_NUMERATOR_GET(x) (((x) & MAC_PCU_MAX_CFP_DUR_USEC_FRAC_NUMERATOR_MASK) >> MAC_PCU_MAX_CFP_DUR_USEC_FRAC_NUMERATOR_LSB)
-#define MAC_PCU_MAX_CFP_DUR_USEC_FRAC_NUMERATOR_SET(x) (((x) << MAC_PCU_MAX_CFP_DUR_USEC_FRAC_NUMERATOR_LSB) & MAC_PCU_MAX_CFP_DUR_USEC_FRAC_NUMERATOR_MASK)
-
-#define MAC_PCU_HCF_TIMEOUT_ADDRESS              0x00008154
-#define MAC_PCU_HCF_TIMEOUT_OFFSET               0x00000154
-#define MAC_PCU_HCF_TIMEOUT_VALUE_MSB            15
-#define MAC_PCU_HCF_TIMEOUT_VALUE_LSB            0
-#define MAC_PCU_HCF_TIMEOUT_VALUE_MASK           0x0000ffff
-#define MAC_PCU_HCF_TIMEOUT_VALUE_GET(x)         (((x) & MAC_PCU_HCF_TIMEOUT_VALUE_MASK) >> MAC_PCU_HCF_TIMEOUT_VALUE_LSB)
-#define MAC_PCU_HCF_TIMEOUT_VALUE_SET(x)         (((x) << MAC_PCU_HCF_TIMEOUT_VALUE_LSB) & MAC_PCU_HCF_TIMEOUT_VALUE_MASK)
-
-#define MAC_PCU_BLUETOOTH_WEIGHTS2_ADDRESS       0x00008158
-#define MAC_PCU_BLUETOOTH_WEIGHTS2_OFFSET        0x00000158
-#define MAC_PCU_BLUETOOTH_WEIGHTS2_WL_WEIGHT_CONTD_MSB 31
-#define MAC_PCU_BLUETOOTH_WEIGHTS2_WL_WEIGHT_CONTD_LSB 16
-#define MAC_PCU_BLUETOOTH_WEIGHTS2_WL_WEIGHT_CONTD_MASK 0xffff0000
-#define MAC_PCU_BLUETOOTH_WEIGHTS2_WL_WEIGHT_CONTD_GET(x) (((x) & MAC_PCU_BLUETOOTH_WEIGHTS2_WL_WEIGHT_CONTD_MASK) >> MAC_PCU_BLUETOOTH_WEIGHTS2_WL_WEIGHT_CONTD_LSB)
-#define MAC_PCU_BLUETOOTH_WEIGHTS2_WL_WEIGHT_CONTD_SET(x) (((x) << MAC_PCU_BLUETOOTH_WEIGHTS2_WL_WEIGHT_CONTD_LSB) & MAC_PCU_BLUETOOTH_WEIGHTS2_WL_WEIGHT_CONTD_MASK)
-
-#define MAC_PCU_BLUETOOTH_TSF_BT_ACTIVE_ADDRESS  0x0000815c
-#define MAC_PCU_BLUETOOTH_TSF_BT_ACTIVE_OFFSET   0x0000015c
-#define MAC_PCU_BLUETOOTH_TSF_BT_ACTIVE_VALUE_MSB 31
-#define MAC_PCU_BLUETOOTH_TSF_BT_ACTIVE_VALUE_LSB 0
-#define MAC_PCU_BLUETOOTH_TSF_BT_ACTIVE_VALUE_MASK 0xffffffff
-#define MAC_PCU_BLUETOOTH_TSF_BT_ACTIVE_VALUE_GET(x) (((x) & MAC_PCU_BLUETOOTH_TSF_BT_ACTIVE_VALUE_MASK) >> MAC_PCU_BLUETOOTH_TSF_BT_ACTIVE_VALUE_LSB)
-#define MAC_PCU_BLUETOOTH_TSF_BT_ACTIVE_VALUE_SET(x) (((x) << MAC_PCU_BLUETOOTH_TSF_BT_ACTIVE_VALUE_LSB) & MAC_PCU_BLUETOOTH_TSF_BT_ACTIVE_VALUE_MASK)
-
-#define MAC_PCU_BLUETOOTH_TSF_BT_PRIORITY_ADDRESS 0x00008160
-#define MAC_PCU_BLUETOOTH_TSF_BT_PRIORITY_OFFSET 0x00000160
-#define MAC_PCU_BLUETOOTH_TSF_BT_PRIORITY_VALUE_MSB 31
-#define MAC_PCU_BLUETOOTH_TSF_BT_PRIORITY_VALUE_LSB 0
-#define MAC_PCU_BLUETOOTH_TSF_BT_PRIORITY_VALUE_MASK 0xffffffff
-#define MAC_PCU_BLUETOOTH_TSF_BT_PRIORITY_VALUE_GET(x) (((x) & MAC_PCU_BLUETOOTH_TSF_BT_PRIORITY_VALUE_MASK) >> MAC_PCU_BLUETOOTH_TSF_BT_PRIORITY_VALUE_LSB)
-#define MAC_PCU_BLUETOOTH_TSF_BT_PRIORITY_VALUE_SET(x) (((x) << MAC_PCU_BLUETOOTH_TSF_BT_PRIORITY_VALUE_LSB) & MAC_PCU_BLUETOOTH_TSF_BT_PRIORITY_VALUE_MASK)
-
-#define MAC_PCU_BLUETOOTH_MODE3_ADDRESS          0x00008164
-#define MAC_PCU_BLUETOOTH_MODE3_OFFSET           0x00000164
-#define MAC_PCU_BLUETOOTH_MODE3_BT_PRIORITY_EXTEND_THRES_MSB 31
-#define MAC_PCU_BLUETOOTH_MODE3_BT_PRIORITY_EXTEND_THRES_LSB 28
-#define MAC_PCU_BLUETOOTH_MODE3_BT_PRIORITY_EXTEND_THRES_MASK 0xf0000000
-#define MAC_PCU_BLUETOOTH_MODE3_BT_PRIORITY_EXTEND_THRES_GET(x) (((x) & MAC_PCU_BLUETOOTH_MODE3_BT_PRIORITY_EXTEND_THRES_MASK) >> MAC_PCU_BLUETOOTH_MODE3_BT_PRIORITY_EXTEND_THRES_LSB)
-#define MAC_PCU_BLUETOOTH_MODE3_BT_PRIORITY_EXTEND_THRES_SET(x) (((x) << MAC_PCU_BLUETOOTH_MODE3_BT_PRIORITY_EXTEND_THRES_LSB) & MAC_PCU_BLUETOOTH_MODE3_BT_PRIORITY_EXTEND_THRES_MASK)
-#define MAC_PCU_BLUETOOTH_MODE3_BT_TX_ON_EN_MSB  27
-#define MAC_PCU_BLUETOOTH_MODE3_BT_TX_ON_EN_LSB  27
-#define MAC_PCU_BLUETOOTH_MODE3_BT_TX_ON_EN_MASK 0x08000000
-#define MAC_PCU_BLUETOOTH_MODE3_BT_TX_ON_EN_GET(x) (((x) & MAC_PCU_BLUETOOTH_MODE3_BT_TX_ON_EN_MASK) >> MAC_PCU_BLUETOOTH_MODE3_BT_TX_ON_EN_LSB)
-#define MAC_PCU_BLUETOOTH_MODE3_BT_TX_ON_EN_SET(x) (((x) << MAC_PCU_BLUETOOTH_MODE3_BT_TX_ON_EN_LSB) & MAC_PCU_BLUETOOTH_MODE3_BT_TX_ON_EN_MASK)
-#define MAC_PCU_BLUETOOTH_MODE3_SLOT_SLOP_MSB    26
-#define MAC_PCU_BLUETOOTH_MODE3_SLOT_SLOP_LSB    25
-#define MAC_PCU_BLUETOOTH_MODE3_SLOT_SLOP_MASK   0x06000000
-#define MAC_PCU_BLUETOOTH_MODE3_SLOT_SLOP_GET(x) (((x) & MAC_PCU_BLUETOOTH_MODE3_SLOT_SLOP_MASK) >> MAC_PCU_BLUETOOTH_MODE3_SLOT_SLOP_LSB)
-#define MAC_PCU_BLUETOOTH_MODE3_SLOT_SLOP_SET(x) (((x) << MAC_PCU_BLUETOOTH_MODE3_SLOT_SLOP_LSB) & MAC_PCU_BLUETOOTH_MODE3_SLOT_SLOP_MASK)
-#define MAC_PCU_BLUETOOTH_MODE3_DYNAMIC_TOGGLE_WLA_EN_MSB 24
-#define MAC_PCU_BLUETOOTH_MODE3_DYNAMIC_TOGGLE_WLA_EN_LSB 24
-#define MAC_PCU_BLUETOOTH_MODE3_DYNAMIC_TOGGLE_WLA_EN_MASK 0x01000000
-#define MAC_PCU_BLUETOOTH_MODE3_DYNAMIC_TOGGLE_WLA_EN_GET(x) (((x) & MAC_PCU_BLUETOOTH_MODE3_DYNAMIC_TOGGLE_WLA_EN_MASK) >> MAC_PCU_BLUETOOTH_MODE3_DYNAMIC_TOGGLE_WLA_EN_LSB)
-#define MAC_PCU_BLUETOOTH_MODE3_DYNAMIC_TOGGLE_WLA_EN_SET(x) (((x) << MAC_PCU_BLUETOOTH_MODE3_DYNAMIC_TOGGLE_WLA_EN_LSB) & MAC_PCU_BLUETOOTH_MODE3_DYNAMIC_TOGGLE_WLA_EN_MASK)
-#define MAC_PCU_BLUETOOTH_MODE3_DYNAMIC_PRI_EN_MSB 23
-#define MAC_PCU_BLUETOOTH_MODE3_DYNAMIC_PRI_EN_LSB 23
-#define MAC_PCU_BLUETOOTH_MODE3_DYNAMIC_PRI_EN_MASK 0x00800000
-#define MAC_PCU_BLUETOOTH_MODE3_DYNAMIC_PRI_EN_GET(x) (((x) & MAC_PCU_BLUETOOTH_MODE3_DYNAMIC_PRI_EN_MASK) >> MAC_PCU_BLUETOOTH_MODE3_DYNAMIC_PRI_EN_LSB)
-#define MAC_PCU_BLUETOOTH_MODE3_DYNAMIC_PRI_EN_SET(x) (((x) << MAC_PCU_BLUETOOTH_MODE3_DYNAMIC_PRI_EN_LSB) & MAC_PCU_BLUETOOTH_MODE3_DYNAMIC_PRI_EN_MASK)
-#define MAC_PCU_BLUETOOTH_MODE3_RFGAIN_LOCK_SRC_MSB 22
-#define MAC_PCU_BLUETOOTH_MODE3_RFGAIN_LOCK_SRC_LSB 22
-#define MAC_PCU_BLUETOOTH_MODE3_RFGAIN_LOCK_SRC_MASK 0x00400000
-#define MAC_PCU_BLUETOOTH_MODE3_RFGAIN_LOCK_SRC_GET(x) (((x) & MAC_PCU_BLUETOOTH_MODE3_RFGAIN_LOCK_SRC_MASK) >> MAC_PCU_BLUETOOTH_MODE3_RFGAIN_LOCK_SRC_LSB)
-#define MAC_PCU_BLUETOOTH_MODE3_RFGAIN_LOCK_SRC_SET(x) (((x) << MAC_PCU_BLUETOOTH_MODE3_RFGAIN_LOCK_SRC_LSB) & MAC_PCU_BLUETOOTH_MODE3_RFGAIN_LOCK_SRC_MASK)
-#define MAC_PCU_BLUETOOTH_MODE3_WL_PRIORITY_OFFSET_EN_MSB 21
-#define MAC_PCU_BLUETOOTH_MODE3_WL_PRIORITY_OFFSET_EN_LSB 21
-#define MAC_PCU_BLUETOOTH_MODE3_WL_PRIORITY_OFFSET_EN_MASK 0x00200000
-#define MAC_PCU_BLUETOOTH_MODE3_WL_PRIORITY_OFFSET_EN_GET(x) (((x) & MAC_PCU_BLUETOOTH_MODE3_WL_PRIORITY_OFFSET_EN_MASK) >> MAC_PCU_BLUETOOTH_MODE3_WL_PRIORITY_OFFSET_EN_LSB)
-#define MAC_PCU_BLUETOOTH_MODE3_WL_PRIORITY_OFFSET_EN_SET(x) (((x) << MAC_PCU_BLUETOOTH_MODE3_WL_PRIORITY_OFFSET_EN_LSB) & MAC_PCU_BLUETOOTH_MODE3_WL_PRIORITY_OFFSET_EN_MASK)
-#define MAC_PCU_BLUETOOTH_MODE3_SHARED_RX_MSB    20
-#define MAC_PCU_BLUETOOTH_MODE3_SHARED_RX_LSB    20
-#define MAC_PCU_BLUETOOTH_MODE3_SHARED_RX_MASK   0x00100000
-#define MAC_PCU_BLUETOOTH_MODE3_SHARED_RX_GET(x) (((x) & MAC_PCU_BLUETOOTH_MODE3_SHARED_RX_MASK) >> MAC_PCU_BLUETOOTH_MODE3_SHARED_RX_LSB)
-#define MAC_PCU_BLUETOOTH_MODE3_SHARED_RX_SET(x) (((x) << MAC_PCU_BLUETOOTH_MODE3_SHARED_RX_LSB) & MAC_PCU_BLUETOOTH_MODE3_SHARED_RX_MASK)
-#define MAC_PCU_BLUETOOTH_MODE3_ALLOW_CONCURRENT_ACCESS_MSB 19
-#define MAC_PCU_BLUETOOTH_MODE3_ALLOW_CONCURRENT_ACCESS_LSB 16
-#define MAC_PCU_BLUETOOTH_MODE3_ALLOW_CONCURRENT_ACCESS_MASK 0x000f0000
-#define MAC_PCU_BLUETOOTH_MODE3_ALLOW_CONCURRENT_ACCESS_GET(x) (((x) & MAC_PCU_BLUETOOTH_MODE3_ALLOW_CONCURRENT_ACCESS_MASK) >> MAC_PCU_BLUETOOTH_MODE3_ALLOW_CONCURRENT_ACCESS_LSB)
-#define MAC_PCU_BLUETOOTH_MODE3_ALLOW_CONCURRENT_ACCESS_SET(x) (((x) << MAC_PCU_BLUETOOTH_MODE3_ALLOW_CONCURRENT_ACCESS_LSB) & MAC_PCU_BLUETOOTH_MODE3_ALLOW_CONCURRENT_ACCESS_MASK)
-#define MAC_PCU_BLUETOOTH_MODE3_WL_QC_TIME_MSB   15
-#define MAC_PCU_BLUETOOTH_MODE3_WL_QC_TIME_LSB   8
-#define MAC_PCU_BLUETOOTH_MODE3_WL_QC_TIME_MASK  0x0000ff00
-#define MAC_PCU_BLUETOOTH_MODE3_WL_QC_TIME_GET(x) (((x) & MAC_PCU_BLUETOOTH_MODE3_WL_QC_TIME_MASK) >> MAC_PCU_BLUETOOTH_MODE3_WL_QC_TIME_LSB)
-#define MAC_PCU_BLUETOOTH_MODE3_WL_QC_TIME_SET(x) (((x) << MAC_PCU_BLUETOOTH_MODE3_WL_QC_TIME_LSB) & MAC_PCU_BLUETOOTH_MODE3_WL_QC_TIME_MASK)
-#define MAC_PCU_BLUETOOTH_MODE3_WL_ACTIVE_TIME_MSB 7
-#define MAC_PCU_BLUETOOTH_MODE3_WL_ACTIVE_TIME_LSB 0
-#define MAC_PCU_BLUETOOTH_MODE3_WL_ACTIVE_TIME_MASK 0x000000ff
-#define MAC_PCU_BLUETOOTH_MODE3_WL_ACTIVE_TIME_GET(x) (((x) & MAC_PCU_BLUETOOTH_MODE3_WL_ACTIVE_TIME_MASK) >> MAC_PCU_BLUETOOTH_MODE3_WL_ACTIVE_TIME_LSB)
-#define MAC_PCU_BLUETOOTH_MODE3_WL_ACTIVE_TIME_SET(x) (((x) << MAC_PCU_BLUETOOTH_MODE3_WL_ACTIVE_TIME_LSB) & MAC_PCU_BLUETOOTH_MODE3_WL_ACTIVE_TIME_MASK)
-
-#define MAC_PCU_BLUETOOTH_MODE4_ADDRESS          0x00008168
-#define MAC_PCU_BLUETOOTH_MODE4_OFFSET           0x00000168
-#define MAC_PCU_BLUETOOTH_MODE4_BT_PRIORITY_EXTEND_MSB 31
-#define MAC_PCU_BLUETOOTH_MODE4_BT_PRIORITY_EXTEND_LSB 16
-#define MAC_PCU_BLUETOOTH_MODE4_BT_PRIORITY_EXTEND_MASK 0xffff0000
-#define MAC_PCU_BLUETOOTH_MODE4_BT_PRIORITY_EXTEND_GET(x) (((x) & MAC_PCU_BLUETOOTH_MODE4_BT_PRIORITY_EXTEND_MASK) >> MAC_PCU_BLUETOOTH_MODE4_BT_PRIORITY_EXTEND_LSB)
-#define MAC_PCU_BLUETOOTH_MODE4_BT_PRIORITY_EXTEND_SET(x) (((x) << MAC_PCU_BLUETOOTH_MODE4_BT_PRIORITY_EXTEND_LSB) & MAC_PCU_BLUETOOTH_MODE4_BT_PRIORITY_EXTEND_MASK)
-#define MAC_PCU_BLUETOOTH_MODE4_BT_ACTIVE_EXTEND_MSB 15
-#define MAC_PCU_BLUETOOTH_MODE4_BT_ACTIVE_EXTEND_LSB 0
-#define MAC_PCU_BLUETOOTH_MODE4_BT_ACTIVE_EXTEND_MASK 0x0000ffff
-#define MAC_PCU_BLUETOOTH_MODE4_BT_ACTIVE_EXTEND_GET(x) (((x) & MAC_PCU_BLUETOOTH_MODE4_BT_ACTIVE_EXTEND_MASK) >> MAC_PCU_BLUETOOTH_MODE4_BT_ACTIVE_EXTEND_LSB)
-#define MAC_PCU_BLUETOOTH_MODE4_BT_ACTIVE_EXTEND_SET(x) (((x) << MAC_PCU_BLUETOOTH_MODE4_BT_ACTIVE_EXTEND_LSB) & MAC_PCU_BLUETOOTH_MODE4_BT_ACTIVE_EXTEND_MASK)
-
-#define MAC_PCU_BT_BT_ADDRESS                    0x00008200
-#define MAC_PCU_BT_BT_OFFSET                     0x00000200
-#define MAC_PCU_BT_BT_WEIGHT_MSB                 31
-#define MAC_PCU_BT_BT_WEIGHT_LSB                 0
-#define MAC_PCU_BT_BT_WEIGHT_MASK                0xffffffff
-#define MAC_PCU_BT_BT_WEIGHT_GET(x)              (((x) & MAC_PCU_BT_BT_WEIGHT_MASK) >> MAC_PCU_BT_BT_WEIGHT_LSB)
-#define MAC_PCU_BT_BT_WEIGHT_SET(x)              (((x) << MAC_PCU_BT_BT_WEIGHT_LSB) & MAC_PCU_BT_BT_WEIGHT_MASK)
-
-#define MAC_PCU_BT_BT_ASYNC_ADDRESS              0x00008300
-#define MAC_PCU_BT_BT_ASYNC_OFFSET               0x00000300
-#define MAC_PCU_BT_BT_ASYNC_RXLP_WEIGHT_MSB      15
-#define MAC_PCU_BT_BT_ASYNC_RXLP_WEIGHT_LSB      12
-#define MAC_PCU_BT_BT_ASYNC_RXLP_WEIGHT_MASK     0x0000f000
-#define MAC_PCU_BT_BT_ASYNC_RXLP_WEIGHT_GET(x)   (((x) & MAC_PCU_BT_BT_ASYNC_RXLP_WEIGHT_MASK) >> MAC_PCU_BT_BT_ASYNC_RXLP_WEIGHT_LSB)
-#define MAC_PCU_BT_BT_ASYNC_RXLP_WEIGHT_SET(x)   (((x) << MAC_PCU_BT_BT_ASYNC_RXLP_WEIGHT_LSB) & MAC_PCU_BT_BT_ASYNC_RXLP_WEIGHT_MASK)
-#define MAC_PCU_BT_BT_ASYNC_RXHP_WEIGHT_MSB      11
-#define MAC_PCU_BT_BT_ASYNC_RXHP_WEIGHT_LSB      8
-#define MAC_PCU_BT_BT_ASYNC_RXHP_WEIGHT_MASK     0x00000f00
-#define MAC_PCU_BT_BT_ASYNC_RXHP_WEIGHT_GET(x)   (((x) & MAC_PCU_BT_BT_ASYNC_RXHP_WEIGHT_MASK) >> MAC_PCU_BT_BT_ASYNC_RXHP_WEIGHT_LSB)
-#define MAC_PCU_BT_BT_ASYNC_RXHP_WEIGHT_SET(x)   (((x) << MAC_PCU_BT_BT_ASYNC_RXHP_WEIGHT_LSB) & MAC_PCU_BT_BT_ASYNC_RXHP_WEIGHT_MASK)
-#define MAC_PCU_BT_BT_ASYNC_TXLP_WEIGHT_MSB      7
-#define MAC_PCU_BT_BT_ASYNC_TXLP_WEIGHT_LSB      4
-#define MAC_PCU_BT_BT_ASYNC_TXLP_WEIGHT_MASK     0x000000f0
-#define MAC_PCU_BT_BT_ASYNC_TXLP_WEIGHT_GET(x)   (((x) & MAC_PCU_BT_BT_ASYNC_TXLP_WEIGHT_MASK) >> MAC_PCU_BT_BT_ASYNC_TXLP_WEIGHT_LSB)
-#define MAC_PCU_BT_BT_ASYNC_TXLP_WEIGHT_SET(x)   (((x) << MAC_PCU_BT_BT_ASYNC_TXLP_WEIGHT_LSB) & MAC_PCU_BT_BT_ASYNC_TXLP_WEIGHT_MASK)
-#define MAC_PCU_BT_BT_ASYNC_TXHP_WEIGHT_MSB      3
-#define MAC_PCU_BT_BT_ASYNC_TXHP_WEIGHT_LSB      0
-#define MAC_PCU_BT_BT_ASYNC_TXHP_WEIGHT_MASK     0x0000000f
-#define MAC_PCU_BT_BT_ASYNC_TXHP_WEIGHT_GET(x)   (((x) & MAC_PCU_BT_BT_ASYNC_TXHP_WEIGHT_MASK) >> MAC_PCU_BT_BT_ASYNC_TXHP_WEIGHT_LSB)
-#define MAC_PCU_BT_BT_ASYNC_TXHP_WEIGHT_SET(x)   (((x) << MAC_PCU_BT_BT_ASYNC_TXHP_WEIGHT_LSB) & MAC_PCU_BT_BT_ASYNC_TXHP_WEIGHT_MASK)
-
-#define MAC_PCU_BT_WL_1_ADDRESS                  0x00008304
-#define MAC_PCU_BT_WL_1_OFFSET                   0x00000304
-#define MAC_PCU_BT_WL_1_WEIGHT_MSB               31
-#define MAC_PCU_BT_WL_1_WEIGHT_LSB               0
-#define MAC_PCU_BT_WL_1_WEIGHT_MASK              0xffffffff
-#define MAC_PCU_BT_WL_1_WEIGHT_GET(x)            (((x) & MAC_PCU_BT_WL_1_WEIGHT_MASK) >> MAC_PCU_BT_WL_1_WEIGHT_LSB)
-#define MAC_PCU_BT_WL_1_WEIGHT_SET(x)            (((x) << MAC_PCU_BT_WL_1_WEIGHT_LSB) & MAC_PCU_BT_WL_1_WEIGHT_MASK)
-
-#define MAC_PCU_BT_WL_2_ADDRESS                  0x00008308
-#define MAC_PCU_BT_WL_2_OFFSET                   0x00000308
-#define MAC_PCU_BT_WL_2_WEIGHT_MSB               31
-#define MAC_PCU_BT_WL_2_WEIGHT_LSB               0
-#define MAC_PCU_BT_WL_2_WEIGHT_MASK              0xffffffff
-#define MAC_PCU_BT_WL_2_WEIGHT_GET(x)            (((x) & MAC_PCU_BT_WL_2_WEIGHT_MASK) >> MAC_PCU_BT_WL_2_WEIGHT_LSB)
-#define MAC_PCU_BT_WL_2_WEIGHT_SET(x)            (((x) << MAC_PCU_BT_WL_2_WEIGHT_LSB) & MAC_PCU_BT_WL_2_WEIGHT_MASK)
-
-#define MAC_PCU_BT_WL_3_ADDRESS                  0x0000830c
-#define MAC_PCU_BT_WL_3_OFFSET                   0x0000030c
-#define MAC_PCU_BT_WL_3_WEIGHT_MSB               31
-#define MAC_PCU_BT_WL_3_WEIGHT_LSB               0
-#define MAC_PCU_BT_WL_3_WEIGHT_MASK              0xffffffff
-#define MAC_PCU_BT_WL_3_WEIGHT_GET(x)            (((x) & MAC_PCU_BT_WL_3_WEIGHT_MASK) >> MAC_PCU_BT_WL_3_WEIGHT_LSB)
-#define MAC_PCU_BT_WL_3_WEIGHT_SET(x)            (((x) << MAC_PCU_BT_WL_3_WEIGHT_LSB) & MAC_PCU_BT_WL_3_WEIGHT_MASK)
-
-#define MAC_PCU_BT_WL_4_ADDRESS                  0x00008310
-#define MAC_PCU_BT_WL_4_OFFSET                   0x00000310
-#define MAC_PCU_BT_WL_4_WEIGHT_MSB               31
-#define MAC_PCU_BT_WL_4_WEIGHT_LSB               0
-#define MAC_PCU_BT_WL_4_WEIGHT_MASK              0xffffffff
-#define MAC_PCU_BT_WL_4_WEIGHT_GET(x)            (((x) & MAC_PCU_BT_WL_4_WEIGHT_MASK) >> MAC_PCU_BT_WL_4_WEIGHT_LSB)
-#define MAC_PCU_BT_WL_4_WEIGHT_SET(x)            (((x) << MAC_PCU_BT_WL_4_WEIGHT_LSB) & MAC_PCU_BT_WL_4_WEIGHT_MASK)
-
-#define MAC_PCU_COEX_EPTA_ADDRESS                0x00008314
-#define MAC_PCU_COEX_EPTA_OFFSET                 0x00000314
-#define MAC_PCU_COEX_EPTA_WT_IDX_MSB             12
-#define MAC_PCU_COEX_EPTA_WT_IDX_LSB             6
-#define MAC_PCU_COEX_EPTA_WT_IDX_MASK            0x00001fc0
-#define MAC_PCU_COEX_EPTA_WT_IDX_GET(x)          (((x) & MAC_PCU_COEX_EPTA_WT_IDX_MASK) >> MAC_PCU_COEX_EPTA_WT_IDX_LSB)
-#define MAC_PCU_COEX_EPTA_WT_IDX_SET(x)          (((x) << MAC_PCU_COEX_EPTA_WT_IDX_LSB) & MAC_PCU_COEX_EPTA_WT_IDX_MASK)
-#define MAC_PCU_COEX_EPTA_LINKID_MSB             5
-#define MAC_PCU_COEX_EPTA_LINKID_LSB             0
-#define MAC_PCU_COEX_EPTA_LINKID_MASK            0x0000003f
-#define MAC_PCU_COEX_EPTA_LINKID_GET(x)          (((x) & MAC_PCU_COEX_EPTA_LINKID_MASK) >> MAC_PCU_COEX_EPTA_LINKID_LSB)
-#define MAC_PCU_COEX_EPTA_LINKID_SET(x)          (((x) << MAC_PCU_COEX_EPTA_LINKID_LSB) & MAC_PCU_COEX_EPTA_LINKID_MASK)
-
-#define MAC_PCU_COEX_LNAMAXGAIN1_ADDRESS         0x00008318
-#define MAC_PCU_COEX_LNAMAXGAIN1_OFFSET          0x00000318
-#define MAC_PCU_COEX_LNAMAXGAIN1_MAXGAIN4_MSB    31
-#define MAC_PCU_COEX_LNAMAXGAIN1_MAXGAIN4_LSB    24
-#define MAC_PCU_COEX_LNAMAXGAIN1_MAXGAIN4_MASK   0xff000000
-#define MAC_PCU_COEX_LNAMAXGAIN1_MAXGAIN4_GET(x) (((x) & MAC_PCU_COEX_LNAMAXGAIN1_MAXGAIN4_MASK) >> MAC_PCU_COEX_LNAMAXGAIN1_MAXGAIN4_LSB)
-#define MAC_PCU_COEX_LNAMAXGAIN1_MAXGAIN4_SET(x) (((x) << MAC_PCU_COEX_LNAMAXGAIN1_MAXGAIN4_LSB) & MAC_PCU_COEX_LNAMAXGAIN1_MAXGAIN4_MASK)
-#define MAC_PCU_COEX_LNAMAXGAIN1_MAXGAIN3_MSB    23
-#define MAC_PCU_COEX_LNAMAXGAIN1_MAXGAIN3_LSB    16
-#define MAC_PCU_COEX_LNAMAXGAIN1_MAXGAIN3_MASK   0x00ff0000
-#define MAC_PCU_COEX_LNAMAXGAIN1_MAXGAIN3_GET(x) (((x) & MAC_PCU_COEX_LNAMAXGAIN1_MAXGAIN3_MASK) >> MAC_PCU_COEX_LNAMAXGAIN1_MAXGAIN3_LSB)
-#define MAC_PCU_COEX_LNAMAXGAIN1_MAXGAIN3_SET(x) (((x) << MAC_PCU_COEX_LNAMAXGAIN1_MAXGAIN3_LSB) & MAC_PCU_COEX_LNAMAXGAIN1_MAXGAIN3_MASK)
-#define MAC_PCU_COEX_LNAMAXGAIN1_MAXGAIN2_MSB    15
-#define MAC_PCU_COEX_LNAMAXGAIN1_MAXGAIN2_LSB    8
-#define MAC_PCU_COEX_LNAMAXGAIN1_MAXGAIN2_MASK   0x0000ff00
-#define MAC_PCU_COEX_LNAMAXGAIN1_MAXGAIN2_GET(x) (((x) & MAC_PCU_COEX_LNAMAXGAIN1_MAXGAIN2_MASK) >> MAC_PCU_COEX_LNAMAXGAIN1_MAXGAIN2_LSB)
-#define MAC_PCU_COEX_LNAMAXGAIN1_MAXGAIN2_SET(x) (((x) << MAC_PCU_COEX_LNAMAXGAIN1_MAXGAIN2_LSB) & MAC_PCU_COEX_LNAMAXGAIN1_MAXGAIN2_MASK)
-#define MAC_PCU_COEX_LNAMAXGAIN1_MAXGAIN1_MSB    7
-#define MAC_PCU_COEX_LNAMAXGAIN1_MAXGAIN1_LSB    0
-#define MAC_PCU_COEX_LNAMAXGAIN1_MAXGAIN1_MASK   0x000000ff
-#define MAC_PCU_COEX_LNAMAXGAIN1_MAXGAIN1_GET(x) (((x) & MAC_PCU_COEX_LNAMAXGAIN1_MAXGAIN1_MASK) >> MAC_PCU_COEX_LNAMAXGAIN1_MAXGAIN1_LSB)
-#define MAC_PCU_COEX_LNAMAXGAIN1_MAXGAIN1_SET(x) (((x) << MAC_PCU_COEX_LNAMAXGAIN1_MAXGAIN1_LSB) & MAC_PCU_COEX_LNAMAXGAIN1_MAXGAIN1_MASK)
-
-#define MAC_PCU_COEX_LNAMAXGAIN2_ADDRESS         0x0000831c
-#define MAC_PCU_COEX_LNAMAXGAIN2_OFFSET          0x0000031c
-#define MAC_PCU_COEX_LNAMAXGAIN2_MAXGAIN4_MSB    31
-#define MAC_PCU_COEX_LNAMAXGAIN2_MAXGAIN4_LSB    24
-#define MAC_PCU_COEX_LNAMAXGAIN2_MAXGAIN4_MASK   0xff000000
-#define MAC_PCU_COEX_LNAMAXGAIN2_MAXGAIN4_GET(x) (((x) & MAC_PCU_COEX_LNAMAXGAIN2_MAXGAIN4_MASK) >> MAC_PCU_COEX_LNAMAXGAIN2_MAXGAIN4_LSB)
-#define MAC_PCU_COEX_LNAMAXGAIN2_MAXGAIN4_SET(x) (((x) << MAC_PCU_COEX_LNAMAXGAIN2_MAXGAIN4_LSB) & MAC_PCU_COEX_LNAMAXGAIN2_MAXGAIN4_MASK)
-#define MAC_PCU_COEX_LNAMAXGAIN2_MAXGAIN3_MSB    23
-#define MAC_PCU_COEX_LNAMAXGAIN2_MAXGAIN3_LSB    16
-#define MAC_PCU_COEX_LNAMAXGAIN2_MAXGAIN3_MASK   0x00ff0000
-#define MAC_PCU_COEX_LNAMAXGAIN2_MAXGAIN3_GET(x) (((x) & MAC_PCU_COEX_LNAMAXGAIN2_MAXGAIN3_MASK) >> MAC_PCU_COEX_LNAMAXGAIN2_MAXGAIN3_LSB)
-#define MAC_PCU_COEX_LNAMAXGAIN2_MAXGAIN3_SET(x) (((x) << MAC_PCU_COEX_LNAMAXGAIN2_MAXGAIN3_LSB) & MAC_PCU_COEX_LNAMAXGAIN2_MAXGAIN3_MASK)
-#define MAC_PCU_COEX_LNAMAXGAIN2_MAXGAIN2_MSB    15
-#define MAC_PCU_COEX_LNAMAXGAIN2_MAXGAIN2_LSB    8
-#define MAC_PCU_COEX_LNAMAXGAIN2_MAXGAIN2_MASK   0x0000ff00
-#define MAC_PCU_COEX_LNAMAXGAIN2_MAXGAIN2_GET(x) (((x) & MAC_PCU_COEX_LNAMAXGAIN2_MAXGAIN2_MASK) >> MAC_PCU_COEX_LNAMAXGAIN2_MAXGAIN2_LSB)
-#define MAC_PCU_COEX_LNAMAXGAIN2_MAXGAIN2_SET(x) (((x) << MAC_PCU_COEX_LNAMAXGAIN2_MAXGAIN2_LSB) & MAC_PCU_COEX_LNAMAXGAIN2_MAXGAIN2_MASK)
-#define MAC_PCU_COEX_LNAMAXGAIN2_MAXGAIN1_MSB    7
-#define MAC_PCU_COEX_LNAMAXGAIN2_MAXGAIN1_LSB    0
-#define MAC_PCU_COEX_LNAMAXGAIN2_MAXGAIN1_MASK   0x000000ff
-#define MAC_PCU_COEX_LNAMAXGAIN2_MAXGAIN1_GET(x) (((x) & MAC_PCU_COEX_LNAMAXGAIN2_MAXGAIN1_MASK) >> MAC_PCU_COEX_LNAMAXGAIN2_MAXGAIN1_LSB)
-#define MAC_PCU_COEX_LNAMAXGAIN2_MAXGAIN1_SET(x) (((x) << MAC_PCU_COEX_LNAMAXGAIN2_MAXGAIN1_LSB) & MAC_PCU_COEX_LNAMAXGAIN2_MAXGAIN1_MASK)
-
-#define MAC_PCU_COEX_LNAMAXGAIN3_ADDRESS         0x00008320
-#define MAC_PCU_COEX_LNAMAXGAIN3_OFFSET          0x00000320
-#define MAC_PCU_COEX_LNAMAXGAIN3_MAXGAIN4_MSB    31
-#define MAC_PCU_COEX_LNAMAXGAIN3_MAXGAIN4_LSB    24
-#define MAC_PCU_COEX_LNAMAXGAIN3_MAXGAIN4_MASK   0xff000000
-#define MAC_PCU_COEX_LNAMAXGAIN3_MAXGAIN4_GET(x) (((x) & MAC_PCU_COEX_LNAMAXGAIN3_MAXGAIN4_MASK) >> MAC_PCU_COEX_LNAMAXGAIN3_MAXGAIN4_LSB)
-#define MAC_PCU_COEX_LNAMAXGAIN3_MAXGAIN4_SET(x) (((x) << MAC_PCU_COEX_LNAMAXGAIN3_MAXGAIN4_LSB) & MAC_PCU_COEX_LNAMAXGAIN3_MAXGAIN4_MASK)
-#define MAC_PCU_COEX_LNAMAXGAIN3_MAXGAIN3_MSB    23
-#define MAC_PCU_COEX_LNAMAXGAIN3_MAXGAIN3_LSB    16
-#define MAC_PCU_COEX_LNAMAXGAIN3_MAXGAIN3_MASK   0x00ff0000
-#define MAC_PCU_COEX_LNAMAXGAIN3_MAXGAIN3_GET(x) (((x) & MAC_PCU_COEX_LNAMAXGAIN3_MAXGAIN3_MASK) >> MAC_PCU_COEX_LNAMAXGAIN3_MAXGAIN3_LSB)
-#define MAC_PCU_COEX_LNAMAXGAIN3_MAXGAIN3_SET(x) (((x) << MAC_PCU_COEX_LNAMAXGAIN3_MAXGAIN3_LSB) & MAC_PCU_COEX_LNAMAXGAIN3_MAXGAIN3_MASK)
-#define MAC_PCU_COEX_LNAMAXGAIN3_MAXGAIN2_MSB    15
-#define MAC_PCU_COEX_LNAMAXGAIN3_MAXGAIN2_LSB    8
-#define MAC_PCU_COEX_LNAMAXGAIN3_MAXGAIN2_MASK   0x0000ff00
-#define MAC_PCU_COEX_LNAMAXGAIN3_MAXGAIN2_GET(x) (((x) & MAC_PCU_COEX_LNAMAXGAIN3_MAXGAIN2_MASK) >> MAC_PCU_COEX_LNAMAXGAIN3_MAXGAIN2_LSB)
-#define MAC_PCU_COEX_LNAMAXGAIN3_MAXGAIN2_SET(x) (((x) << MAC_PCU_COEX_LNAMAXGAIN3_MAXGAIN2_LSB) & MAC_PCU_COEX_LNAMAXGAIN3_MAXGAIN2_MASK)
-#define MAC_PCU_COEX_LNAMAXGAIN3_MAXGAIN1_MSB    7
-#define MAC_PCU_COEX_LNAMAXGAIN3_MAXGAIN1_LSB    0
-#define MAC_PCU_COEX_LNAMAXGAIN3_MAXGAIN1_MASK   0x000000ff
-#define MAC_PCU_COEX_LNAMAXGAIN3_MAXGAIN1_GET(x) (((x) & MAC_PCU_COEX_LNAMAXGAIN3_MAXGAIN1_MASK) >> MAC_PCU_COEX_LNAMAXGAIN3_MAXGAIN1_LSB)
-#define MAC_PCU_COEX_LNAMAXGAIN3_MAXGAIN1_SET(x) (((x) << MAC_PCU_COEX_LNAMAXGAIN3_MAXGAIN1_LSB) & MAC_PCU_COEX_LNAMAXGAIN3_MAXGAIN1_MASK)
-
-#define MAC_PCU_COEX_LNAMAXGAIN4_ADDRESS         0x00008324
-#define MAC_PCU_COEX_LNAMAXGAIN4_OFFSET          0x00000324
-#define MAC_PCU_COEX_LNAMAXGAIN4_MAXGAIN4_MSB    31
-#define MAC_PCU_COEX_LNAMAXGAIN4_MAXGAIN4_LSB    24
-#define MAC_PCU_COEX_LNAMAXGAIN4_MAXGAIN4_MASK   0xff000000
-#define MAC_PCU_COEX_LNAMAXGAIN4_MAXGAIN4_GET(x) (((x) & MAC_PCU_COEX_LNAMAXGAIN4_MAXGAIN4_MASK) >> MAC_PCU_COEX_LNAMAXGAIN4_MAXGAIN4_LSB)
-#define MAC_PCU_COEX_LNAMAXGAIN4_MAXGAIN4_SET(x) (((x) << MAC_PCU_COEX_LNAMAXGAIN4_MAXGAIN4_LSB) & MAC_PCU_COEX_LNAMAXGAIN4_MAXGAIN4_MASK)
-#define MAC_PCU_COEX_LNAMAXGAIN4_MAXGAIN3_MSB    23
-#define MAC_PCU_COEX_LNAMAXGAIN4_MAXGAIN3_LSB    16
-#define MAC_PCU_COEX_LNAMAXGAIN4_MAXGAIN3_MASK   0x00ff0000
-#define MAC_PCU_COEX_LNAMAXGAIN4_MAXGAIN3_GET(x) (((x) & MAC_PCU_COEX_LNAMAXGAIN4_MAXGAIN3_MASK) >> MAC_PCU_COEX_LNAMAXGAIN4_MAXGAIN3_LSB)
-#define MAC_PCU_COEX_LNAMAXGAIN4_MAXGAIN3_SET(x) (((x) << MAC_PCU_COEX_LNAMAXGAIN4_MAXGAIN3_LSB) & MAC_PCU_COEX_LNAMAXGAIN4_MAXGAIN3_MASK)
-#define MAC_PCU_COEX_LNAMAXGAIN4_MAXGAIN2_MSB    15
-#define MAC_PCU_COEX_LNAMAXGAIN4_MAXGAIN2_LSB    8
-#define MAC_PCU_COEX_LNAMAXGAIN4_MAXGAIN2_MASK   0x0000ff00
-#define MAC_PCU_COEX_LNAMAXGAIN4_MAXGAIN2_GET(x) (((x) & MAC_PCU_COEX_LNAMAXGAIN4_MAXGAIN2_MASK) >> MAC_PCU_COEX_LNAMAXGAIN4_MAXGAIN2_LSB)
-#define MAC_PCU_COEX_LNAMAXGAIN4_MAXGAIN2_SET(x) (((x) << MAC_PCU_COEX_LNAMAXGAIN4_MAXGAIN2_LSB) & MAC_PCU_COEX_LNAMAXGAIN4_MAXGAIN2_MASK)
-#define MAC_PCU_COEX_LNAMAXGAIN4_MAXGAIN1_MSB    7
-#define MAC_PCU_COEX_LNAMAXGAIN4_MAXGAIN1_LSB    0
-#define MAC_PCU_COEX_LNAMAXGAIN4_MAXGAIN1_MASK   0x000000ff
-#define MAC_PCU_COEX_LNAMAXGAIN4_MAXGAIN1_GET(x) (((x) & MAC_PCU_COEX_LNAMAXGAIN4_MAXGAIN1_MASK) >> MAC_PCU_COEX_LNAMAXGAIN4_MAXGAIN1_LSB)
-#define MAC_PCU_COEX_LNAMAXGAIN4_MAXGAIN1_SET(x) (((x) << MAC_PCU_COEX_LNAMAXGAIN4_MAXGAIN1_LSB) & MAC_PCU_COEX_LNAMAXGAIN4_MAXGAIN1_MASK)
-
-#define MAC_PCU_BASIC_RATE_SET0_ADDRESS          0x00008328
-#define MAC_PCU_BASIC_RATE_SET0_OFFSET           0x00000328
-#define MAC_PCU_BASIC_RATE_SET0_VALUE_MSB        29
-#define MAC_PCU_BASIC_RATE_SET0_VALUE_LSB        0
-#define MAC_PCU_BASIC_RATE_SET0_VALUE_MASK       0x3fffffff
-#define MAC_PCU_BASIC_RATE_SET0_VALUE_GET(x)     (((x) & MAC_PCU_BASIC_RATE_SET0_VALUE_MASK) >> MAC_PCU_BASIC_RATE_SET0_VALUE_LSB)
-#define MAC_PCU_BASIC_RATE_SET0_VALUE_SET(x)     (((x) << MAC_PCU_BASIC_RATE_SET0_VALUE_LSB) & MAC_PCU_BASIC_RATE_SET0_VALUE_MASK)
-
-#define MAC_PCU_BASIC_RATE_SET1_ADDRESS          0x0000832c
-#define MAC_PCU_BASIC_RATE_SET1_OFFSET           0x0000032c
-#define MAC_PCU_BASIC_RATE_SET1_VALUE_MSB        29
-#define MAC_PCU_BASIC_RATE_SET1_VALUE_LSB        0
-#define MAC_PCU_BASIC_RATE_SET1_VALUE_MASK       0x3fffffff
-#define MAC_PCU_BASIC_RATE_SET1_VALUE_GET(x)     (((x) & MAC_PCU_BASIC_RATE_SET1_VALUE_MASK) >> MAC_PCU_BASIC_RATE_SET1_VALUE_LSB)
-#define MAC_PCU_BASIC_RATE_SET1_VALUE_SET(x)     (((x) << MAC_PCU_BASIC_RATE_SET1_VALUE_LSB) & MAC_PCU_BASIC_RATE_SET1_VALUE_MASK)
-
-#define MAC_PCU_BASIC_RATE_SET2_ADDRESS          0x00008330
-#define MAC_PCU_BASIC_RATE_SET2_OFFSET           0x00000330
-#define MAC_PCU_BASIC_RATE_SET2_VALUE_MSB        29
-#define MAC_PCU_BASIC_RATE_SET2_VALUE_LSB        0
-#define MAC_PCU_BASIC_RATE_SET2_VALUE_MASK       0x3fffffff
-#define MAC_PCU_BASIC_RATE_SET2_VALUE_GET(x)     (((x) & MAC_PCU_BASIC_RATE_SET2_VALUE_MASK) >> MAC_PCU_BASIC_RATE_SET2_VALUE_LSB)
-#define MAC_PCU_BASIC_RATE_SET2_VALUE_SET(x)     (((x) << MAC_PCU_BASIC_RATE_SET2_VALUE_LSB) & MAC_PCU_BASIC_RATE_SET2_VALUE_MASK)
-
-#define MAC_PCU_BASIC_RATE_SET3_ADDRESS          0x00008334
-#define MAC_PCU_BASIC_RATE_SET3_OFFSET           0x00000334
-#define MAC_PCU_BASIC_RATE_SET3_VALUE_MSB        24
-#define MAC_PCU_BASIC_RATE_SET3_VALUE_LSB        0
-#define MAC_PCU_BASIC_RATE_SET3_VALUE_MASK       0x01ffffff
-#define MAC_PCU_BASIC_RATE_SET3_VALUE_GET(x)     (((x) & MAC_PCU_BASIC_RATE_SET3_VALUE_MASK) >> MAC_PCU_BASIC_RATE_SET3_VALUE_LSB)
-#define MAC_PCU_BASIC_RATE_SET3_VALUE_SET(x)     (((x) << MAC_PCU_BASIC_RATE_SET3_VALUE_LSB) & MAC_PCU_BASIC_RATE_SET3_VALUE_MASK)
-
-#define MAC_PCU_RX_INT_STATUS0_ADDRESS           0x00008338
-#define MAC_PCU_RX_INT_STATUS0_OFFSET            0x00000338
-#define MAC_PCU_RX_INT_STATUS0_DURATION_H_MSB    31
-#define MAC_PCU_RX_INT_STATUS0_DURATION_H_LSB    24
-#define MAC_PCU_RX_INT_STATUS0_DURATION_H_MASK   0xff000000
-#define MAC_PCU_RX_INT_STATUS0_DURATION_H_GET(x) (((x) & MAC_PCU_RX_INT_STATUS0_DURATION_H_MASK) >> MAC_PCU_RX_INT_STATUS0_DURATION_H_LSB)
-#define MAC_PCU_RX_INT_STATUS0_DURATION_H_SET(x) (((x) << MAC_PCU_RX_INT_STATUS0_DURATION_H_LSB) & MAC_PCU_RX_INT_STATUS0_DURATION_H_MASK)
-#define MAC_PCU_RX_INT_STATUS0_DURATION_L_MSB    23
-#define MAC_PCU_RX_INT_STATUS0_DURATION_L_LSB    16
-#define MAC_PCU_RX_INT_STATUS0_DURATION_L_MASK   0x00ff0000
-#define MAC_PCU_RX_INT_STATUS0_DURATION_L_GET(x) (((x) & MAC_PCU_RX_INT_STATUS0_DURATION_L_MASK) >> MAC_PCU_RX_INT_STATUS0_DURATION_L_LSB)
-#define MAC_PCU_RX_INT_STATUS0_DURATION_L_SET(x) (((x) << MAC_PCU_RX_INT_STATUS0_DURATION_L_LSB) & MAC_PCU_RX_INT_STATUS0_DURATION_L_MASK)
-#define MAC_PCU_RX_INT_STATUS0_FRAME_CONTROL_H_MSB 15
-#define MAC_PCU_RX_INT_STATUS0_FRAME_CONTROL_H_LSB 8
-#define MAC_PCU_RX_INT_STATUS0_FRAME_CONTROL_H_MASK 0x0000ff00
-#define MAC_PCU_RX_INT_STATUS0_FRAME_CONTROL_H_GET(x) (((x) & MAC_PCU_RX_INT_STATUS0_FRAME_CONTROL_H_MASK) >> MAC_PCU_RX_INT_STATUS0_FRAME_CONTROL_H_LSB)
-#define MAC_PCU_RX_INT_STATUS0_FRAME_CONTROL_H_SET(x) (((x) << MAC_PCU_RX_INT_STATUS0_FRAME_CONTROL_H_LSB) & MAC_PCU_RX_INT_STATUS0_FRAME_CONTROL_H_MASK)
-#define MAC_PCU_RX_INT_STATUS0_FRAME_CONTROL_L_MSB 7
-#define MAC_PCU_RX_INT_STATUS0_FRAME_CONTROL_L_LSB 0
-#define MAC_PCU_RX_INT_STATUS0_FRAME_CONTROL_L_MASK 0x000000ff
-#define MAC_PCU_RX_INT_STATUS0_FRAME_CONTROL_L_GET(x) (((x) & MAC_PCU_RX_INT_STATUS0_FRAME_CONTROL_L_MASK) >> MAC_PCU_RX_INT_STATUS0_FRAME_CONTROL_L_LSB)
-#define MAC_PCU_RX_INT_STATUS0_FRAME_CONTROL_L_SET(x) (((x) << MAC_PCU_RX_INT_STATUS0_FRAME_CONTROL_L_LSB) & MAC_PCU_RX_INT_STATUS0_FRAME_CONTROL_L_MASK)
-
-#define MAC_PCU_RX_INT_STATUS1_ADDRESS           0x0000833c
-#define MAC_PCU_RX_INT_STATUS1_OFFSET            0x0000033c
-#define MAC_PCU_RX_INT_STATUS1_VALUE_MSB         17
-#define MAC_PCU_RX_INT_STATUS1_VALUE_LSB         0
-#define MAC_PCU_RX_INT_STATUS1_VALUE_MASK        0x0003ffff
-#define MAC_PCU_RX_INT_STATUS1_VALUE_GET(x)      (((x) & MAC_PCU_RX_INT_STATUS1_VALUE_MASK) >> MAC_PCU_RX_INT_STATUS1_VALUE_LSB)
-#define MAC_PCU_RX_INT_STATUS1_VALUE_SET(x)      (((x) << MAC_PCU_RX_INT_STATUS1_VALUE_LSB) & MAC_PCU_RX_INT_STATUS1_VALUE_MASK)
-
-#define MAC_PCU_RX_INT_STATUS2_ADDRESS           0x00008340
-#define MAC_PCU_RX_INT_STATUS2_OFFSET            0x00000340
-#define MAC_PCU_RX_INT_STATUS2_VALUE_MSB         26
-#define MAC_PCU_RX_INT_STATUS2_VALUE_LSB         0
-#define MAC_PCU_RX_INT_STATUS2_VALUE_MASK        0x07ffffff
-#define MAC_PCU_RX_INT_STATUS2_VALUE_GET(x)      (((x) & MAC_PCU_RX_INT_STATUS2_VALUE_MASK) >> MAC_PCU_RX_INT_STATUS2_VALUE_LSB)
-#define MAC_PCU_RX_INT_STATUS2_VALUE_SET(x)      (((x) << MAC_PCU_RX_INT_STATUS2_VALUE_LSB) & MAC_PCU_RX_INT_STATUS2_VALUE_MASK)
-
-#define MAC_PCU_RX_INT_STATUS3_ADDRESS           0x00008344
-#define MAC_PCU_RX_INT_STATUS3_OFFSET            0x00000344
-#define MAC_PCU_RX_INT_STATUS3_VALUE_MSB         23
-#define MAC_PCU_RX_INT_STATUS3_VALUE_LSB         0
-#define MAC_PCU_RX_INT_STATUS3_VALUE_MASK        0x00ffffff
-#define MAC_PCU_RX_INT_STATUS3_VALUE_GET(x)      (((x) & MAC_PCU_RX_INT_STATUS3_VALUE_MASK) >> MAC_PCU_RX_INT_STATUS3_VALUE_LSB)
-#define MAC_PCU_RX_INT_STATUS3_VALUE_SET(x)      (((x) << MAC_PCU_RX_INT_STATUS3_VALUE_LSB) & MAC_PCU_RX_INT_STATUS3_VALUE_MASK)
-
-#define HT_HALF_GI_RATE1_ADDRESS                 0x00008348
-#define HT_HALF_GI_RATE1_OFFSET                  0x00000348
-#define HT_HALF_GI_RATE1_MCS3_MSB                31
-#define HT_HALF_GI_RATE1_MCS3_LSB                24
-#define HT_HALF_GI_RATE1_MCS3_MASK               0xff000000
-#define HT_HALF_GI_RATE1_MCS3_GET(x)             (((x) & HT_HALF_GI_RATE1_MCS3_MASK) >> HT_HALF_GI_RATE1_MCS3_LSB)
-#define HT_HALF_GI_RATE1_MCS3_SET(x)             (((x) << HT_HALF_GI_RATE1_MCS3_LSB) & HT_HALF_GI_RATE1_MCS3_MASK)
-#define HT_HALF_GI_RATE1_MCS2_MSB                23
-#define HT_HALF_GI_RATE1_MCS2_LSB                16
-#define HT_HALF_GI_RATE1_MCS2_MASK               0x00ff0000
-#define HT_HALF_GI_RATE1_MCS2_GET(x)             (((x) & HT_HALF_GI_RATE1_MCS2_MASK) >> HT_HALF_GI_RATE1_MCS2_LSB)
-#define HT_HALF_GI_RATE1_MCS2_SET(x)             (((x) << HT_HALF_GI_RATE1_MCS2_LSB) & HT_HALF_GI_RATE1_MCS2_MASK)
-#define HT_HALF_GI_RATE1_MCS1_MSB                15
-#define HT_HALF_GI_RATE1_MCS1_LSB                8
-#define HT_HALF_GI_RATE1_MCS1_MASK               0x0000ff00
-#define HT_HALF_GI_RATE1_MCS1_GET(x)             (((x) & HT_HALF_GI_RATE1_MCS1_MASK) >> HT_HALF_GI_RATE1_MCS1_LSB)
-#define HT_HALF_GI_RATE1_MCS1_SET(x)             (((x) << HT_HALF_GI_RATE1_MCS1_LSB) & HT_HALF_GI_RATE1_MCS1_MASK)
-#define HT_HALF_GI_RATE1_MCS0_MSB                7
-#define HT_HALF_GI_RATE1_MCS0_LSB                0
-#define HT_HALF_GI_RATE1_MCS0_MASK               0x000000ff
-#define HT_HALF_GI_RATE1_MCS0_GET(x)             (((x) & HT_HALF_GI_RATE1_MCS0_MASK) >> HT_HALF_GI_RATE1_MCS0_LSB)
-#define HT_HALF_GI_RATE1_MCS0_SET(x)             (((x) << HT_HALF_GI_RATE1_MCS0_LSB) & HT_HALF_GI_RATE1_MCS0_MASK)
-
-#define HT_HALF_GI_RATE2_ADDRESS                 0x0000834c
-#define HT_HALF_GI_RATE2_OFFSET                  0x0000034c
-#define HT_HALF_GI_RATE2_MCS7_MSB                31
-#define HT_HALF_GI_RATE2_MCS7_LSB                24
-#define HT_HALF_GI_RATE2_MCS7_MASK               0xff000000
-#define HT_HALF_GI_RATE2_MCS7_GET(x)             (((x) & HT_HALF_GI_RATE2_MCS7_MASK) >> HT_HALF_GI_RATE2_MCS7_LSB)
-#define HT_HALF_GI_RATE2_MCS7_SET(x)             (((x) << HT_HALF_GI_RATE2_MCS7_LSB) & HT_HALF_GI_RATE2_MCS7_MASK)
-#define HT_HALF_GI_RATE2_MCS6_MSB                23
-#define HT_HALF_GI_RATE2_MCS6_LSB                16
-#define HT_HALF_GI_RATE2_MCS6_MASK               0x00ff0000
-#define HT_HALF_GI_RATE2_MCS6_GET(x)             (((x) & HT_HALF_GI_RATE2_MCS6_MASK) >> HT_HALF_GI_RATE2_MCS6_LSB)
-#define HT_HALF_GI_RATE2_MCS6_SET(x)             (((x) << HT_HALF_GI_RATE2_MCS6_LSB) & HT_HALF_GI_RATE2_MCS6_MASK)
-#define HT_HALF_GI_RATE2_MCS5_MSB                15
-#define HT_HALF_GI_RATE2_MCS5_LSB                8
-#define HT_HALF_GI_RATE2_MCS5_MASK               0x0000ff00
-#define HT_HALF_GI_RATE2_MCS5_GET(x)             (((x) & HT_HALF_GI_RATE2_MCS5_MASK) >> HT_HALF_GI_RATE2_MCS5_LSB)
-#define HT_HALF_GI_RATE2_MCS5_SET(x)             (((x) << HT_HALF_GI_RATE2_MCS5_LSB) & HT_HALF_GI_RATE2_MCS5_MASK)
-#define HT_HALF_GI_RATE2_MCS4_MSB                7
-#define HT_HALF_GI_RATE2_MCS4_LSB                0
-#define HT_HALF_GI_RATE2_MCS4_MASK               0x000000ff
-#define HT_HALF_GI_RATE2_MCS4_GET(x)             (((x) & HT_HALF_GI_RATE2_MCS4_MASK) >> HT_HALF_GI_RATE2_MCS4_LSB)
-#define HT_HALF_GI_RATE2_MCS4_SET(x)             (((x) << HT_HALF_GI_RATE2_MCS4_LSB) & HT_HALF_GI_RATE2_MCS4_MASK)
-
-#define HT_FULL_GI_RATE1_ADDRESS                 0x00008350
-#define HT_FULL_GI_RATE1_OFFSET                  0x00000350
-#define HT_FULL_GI_RATE1_MCS3_MSB                31
-#define HT_FULL_GI_RATE1_MCS3_LSB                24
-#define HT_FULL_GI_RATE1_MCS3_MASK               0xff000000
-#define HT_FULL_GI_RATE1_MCS3_GET(x)             (((x) & HT_FULL_GI_RATE1_MCS3_MASK) >> HT_FULL_GI_RATE1_MCS3_LSB)
-#define HT_FULL_GI_RATE1_MCS3_SET(x)             (((x) << HT_FULL_GI_RATE1_MCS3_LSB) & HT_FULL_GI_RATE1_MCS3_MASK)
-#define HT_FULL_GI_RATE1_MCS2_MSB                23
-#define HT_FULL_GI_RATE1_MCS2_LSB                16
-#define HT_FULL_GI_RATE1_MCS2_MASK               0x00ff0000
-#define HT_FULL_GI_RATE1_MCS2_GET(x)             (((x) & HT_FULL_GI_RATE1_MCS2_MASK) >> HT_FULL_GI_RATE1_MCS2_LSB)
-#define HT_FULL_GI_RATE1_MCS2_SET(x)             (((x) << HT_FULL_GI_RATE1_MCS2_LSB) & HT_FULL_GI_RATE1_MCS2_MASK)
-#define HT_FULL_GI_RATE1_MCS1_MSB                15
-#define HT_FULL_GI_RATE1_MCS1_LSB                8
-#define HT_FULL_GI_RATE1_MCS1_MASK               0x0000ff00
-#define HT_FULL_GI_RATE1_MCS1_GET(x)             (((x) & HT_FULL_GI_RATE1_MCS1_MASK) >> HT_FULL_GI_RATE1_MCS1_LSB)
-#define HT_FULL_GI_RATE1_MCS1_SET(x)             (((x) << HT_FULL_GI_RATE1_MCS1_LSB) & HT_FULL_GI_RATE1_MCS1_MASK)
-#define HT_FULL_GI_RATE1_MCS0_MSB                7
-#define HT_FULL_GI_RATE1_MCS0_LSB                0
-#define HT_FULL_GI_RATE1_MCS0_MASK               0x000000ff
-#define HT_FULL_GI_RATE1_MCS0_GET(x)             (((x) & HT_FULL_GI_RATE1_MCS0_MASK) >> HT_FULL_GI_RATE1_MCS0_LSB)
-#define HT_FULL_GI_RATE1_MCS0_SET(x)             (((x) << HT_FULL_GI_RATE1_MCS0_LSB) & HT_FULL_GI_RATE1_MCS0_MASK)
-
-#define HT_FULL_GI_RATE2_ADDRESS                 0x00008354
-#define HT_FULL_GI_RATE2_OFFSET                  0x00000354
-#define HT_FULL_GI_RATE2_MCS7_MSB                31
-#define HT_FULL_GI_RATE2_MCS7_LSB                24
-#define HT_FULL_GI_RATE2_MCS7_MASK               0xff000000
-#define HT_FULL_GI_RATE2_MCS7_GET(x)             (((x) & HT_FULL_GI_RATE2_MCS7_MASK) >> HT_FULL_GI_RATE2_MCS7_LSB)
-#define HT_FULL_GI_RATE2_MCS7_SET(x)             (((x) << HT_FULL_GI_RATE2_MCS7_LSB) & HT_FULL_GI_RATE2_MCS7_MASK)
-#define HT_FULL_GI_RATE2_MCS6_MSB                23
-#define HT_FULL_GI_RATE2_MCS6_LSB                16
-#define HT_FULL_GI_RATE2_MCS6_MASK               0x00ff0000
-#define HT_FULL_GI_RATE2_MCS6_GET(x)             (((x) & HT_FULL_GI_RATE2_MCS6_MASK) >> HT_FULL_GI_RATE2_MCS6_LSB)
-#define HT_FULL_GI_RATE2_MCS6_SET(x)             (((x) << HT_FULL_GI_RATE2_MCS6_LSB) & HT_FULL_GI_RATE2_MCS6_MASK)
-#define HT_FULL_GI_RATE2_MCS5_MSB                15
-#define HT_FULL_GI_RATE2_MCS5_LSB                8
-#define HT_FULL_GI_RATE2_MCS5_MASK               0x0000ff00
-#define HT_FULL_GI_RATE2_MCS5_GET(x)             (((x) & HT_FULL_GI_RATE2_MCS5_MASK) >> HT_FULL_GI_RATE2_MCS5_LSB)
-#define HT_FULL_GI_RATE2_MCS5_SET(x)             (((x) << HT_FULL_GI_RATE2_MCS5_LSB) & HT_FULL_GI_RATE2_MCS5_MASK)
-#define HT_FULL_GI_RATE2_MCS4_MSB                7
-#define HT_FULL_GI_RATE2_MCS4_LSB                0
-#define HT_FULL_GI_RATE2_MCS4_MASK               0x000000ff
-#define HT_FULL_GI_RATE2_MCS4_GET(x)             (((x) & HT_FULL_GI_RATE2_MCS4_MASK) >> HT_FULL_GI_RATE2_MCS4_LSB)
-#define HT_FULL_GI_RATE2_MCS4_SET(x)             (((x) << HT_FULL_GI_RATE2_MCS4_LSB) & HT_FULL_GI_RATE2_MCS4_MASK)
-
-#define LEGACY_RATE1_ADDRESS                     0x00008358
-#define LEGACY_RATE1_OFFSET                      0x00000358
-#define LEGACY_RATE1_RATE12_MSB                  29
-#define LEGACY_RATE1_RATE12_LSB                  24
-#define LEGACY_RATE1_RATE12_MASK                 0x3f000000
-#define LEGACY_RATE1_RATE12_GET(x)               (((x) & LEGACY_RATE1_RATE12_MASK) >> LEGACY_RATE1_RATE12_LSB)
-#define LEGACY_RATE1_RATE12_SET(x)               (((x) << LEGACY_RATE1_RATE12_LSB) & LEGACY_RATE1_RATE12_MASK)
-#define LEGACY_RATE1_RATE11_MSB                  23
-#define LEGACY_RATE1_RATE11_LSB                  18
-#define LEGACY_RATE1_RATE11_MASK                 0x00fc0000
-#define LEGACY_RATE1_RATE11_GET(x)               (((x) & LEGACY_RATE1_RATE11_MASK) >> LEGACY_RATE1_RATE11_LSB)
-#define LEGACY_RATE1_RATE11_SET(x)               (((x) << LEGACY_RATE1_RATE11_LSB) & LEGACY_RATE1_RATE11_MASK)
-#define LEGACY_RATE1_RATE10_MSB                  17
-#define LEGACY_RATE1_RATE10_LSB                  12
-#define LEGACY_RATE1_RATE10_MASK                 0x0003f000
-#define LEGACY_RATE1_RATE10_GET(x)               (((x) & LEGACY_RATE1_RATE10_MASK) >> LEGACY_RATE1_RATE10_LSB)
-#define LEGACY_RATE1_RATE10_SET(x)               (((x) << LEGACY_RATE1_RATE10_LSB) & LEGACY_RATE1_RATE10_MASK)
-#define LEGACY_RATE1_RATE9_MSB                   11
-#define LEGACY_RATE1_RATE9_LSB                   6
-#define LEGACY_RATE1_RATE9_MASK                  0x00000fc0
-#define LEGACY_RATE1_RATE9_GET(x)                (((x) & LEGACY_RATE1_RATE9_MASK) >> LEGACY_RATE1_RATE9_LSB)
-#define LEGACY_RATE1_RATE9_SET(x)                (((x) << LEGACY_RATE1_RATE9_LSB) & LEGACY_RATE1_RATE9_MASK)
-#define LEGACY_RATE1_RATE8_MSB                   5
-#define LEGACY_RATE1_RATE8_LSB                   0
-#define LEGACY_RATE1_RATE8_MASK                  0x0000003f
-#define LEGACY_RATE1_RATE8_GET(x)                (((x) & LEGACY_RATE1_RATE8_MASK) >> LEGACY_RATE1_RATE8_LSB)
-#define LEGACY_RATE1_RATE8_SET(x)                (((x) << LEGACY_RATE1_RATE8_LSB) & LEGACY_RATE1_RATE8_MASK)
-
-#define LEGACY_RATE2_ADDRESS                     0x0000835c
-#define LEGACY_RATE2_OFFSET                      0x0000035c
-#define LEGACY_RATE2_RATE25_MSB                  29
-#define LEGACY_RATE2_RATE25_LSB                  24
-#define LEGACY_RATE2_RATE25_MASK                 0x3f000000
-#define LEGACY_RATE2_RATE25_GET(x)               (((x) & LEGACY_RATE2_RATE25_MASK) >> LEGACY_RATE2_RATE25_LSB)
-#define LEGACY_RATE2_RATE25_SET(x)               (((x) << LEGACY_RATE2_RATE25_LSB) & LEGACY_RATE2_RATE25_MASK)
-#define LEGACY_RATE2_RATE24_MSB                  23
-#define LEGACY_RATE2_RATE24_LSB                  18
-#define LEGACY_RATE2_RATE24_MASK                 0x00fc0000
-#define LEGACY_RATE2_RATE24_GET(x)               (((x) & LEGACY_RATE2_RATE24_MASK) >> LEGACY_RATE2_RATE24_LSB)
-#define LEGACY_RATE2_RATE24_SET(x)               (((x) << LEGACY_RATE2_RATE24_LSB) & LEGACY_RATE2_RATE24_MASK)
-#define LEGACY_RATE2_RATE15_MSB                  17
-#define LEGACY_RATE2_RATE15_LSB                  12
-#define LEGACY_RATE2_RATE15_MASK                 0x0003f000
-#define LEGACY_RATE2_RATE15_GET(x)               (((x) & LEGACY_RATE2_RATE15_MASK) >> LEGACY_RATE2_RATE15_LSB)
-#define LEGACY_RATE2_RATE15_SET(x)               (((x) << LEGACY_RATE2_RATE15_LSB) & LEGACY_RATE2_RATE15_MASK)
-#define LEGACY_RATE2_RATE14_MSB                  11
-#define LEGACY_RATE2_RATE14_LSB                  6
-#define LEGACY_RATE2_RATE14_MASK                 0x00000fc0
-#define LEGACY_RATE2_RATE14_GET(x)               (((x) & LEGACY_RATE2_RATE14_MASK) >> LEGACY_RATE2_RATE14_LSB)
-#define LEGACY_RATE2_RATE14_SET(x)               (((x) << LEGACY_RATE2_RATE14_LSB) & LEGACY_RATE2_RATE14_MASK)
-#define LEGACY_RATE2_RATE13_MSB                  5
-#define LEGACY_RATE2_RATE13_LSB                  0
-#define LEGACY_RATE2_RATE13_MASK                 0x0000003f
-#define LEGACY_RATE2_RATE13_GET(x)               (((x) & LEGACY_RATE2_RATE13_MASK) >> LEGACY_RATE2_RATE13_LSB)
-#define LEGACY_RATE2_RATE13_SET(x)               (((x) << LEGACY_RATE2_RATE13_LSB) & LEGACY_RATE2_RATE13_MASK)
-
-#define LEGACY_RATE3_ADDRESS                     0x00008360
-#define LEGACY_RATE3_OFFSET                      0x00000360
-#define LEGACY_RATE3_RATE30_MSB                  29
-#define LEGACY_RATE3_RATE30_LSB                  24
-#define LEGACY_RATE3_RATE30_MASK                 0x3f000000
-#define LEGACY_RATE3_RATE30_GET(x)               (((x) & LEGACY_RATE3_RATE30_MASK) >> LEGACY_RATE3_RATE30_LSB)
-#define LEGACY_RATE3_RATE30_SET(x)               (((x) << LEGACY_RATE3_RATE30_LSB) & LEGACY_RATE3_RATE30_MASK)
-#define LEGACY_RATE3_RATE29_MSB                  23
-#define LEGACY_RATE3_RATE29_LSB                  18
-#define LEGACY_RATE3_RATE29_MASK                 0x00fc0000
-#define LEGACY_RATE3_RATE29_GET(x)               (((x) & LEGACY_RATE3_RATE29_MASK) >> LEGACY_RATE3_RATE29_LSB)
-#define LEGACY_RATE3_RATE29_SET(x)               (((x) << LEGACY_RATE3_RATE29_LSB) & LEGACY_RATE3_RATE29_MASK)
-#define LEGACY_RATE3_RATE28_MSB                  17
-#define LEGACY_RATE3_RATE28_LSB                  12
-#define LEGACY_RATE3_RATE28_MASK                 0x0003f000
-#define LEGACY_RATE3_RATE28_GET(x)               (((x) & LEGACY_RATE3_RATE28_MASK) >> LEGACY_RATE3_RATE28_LSB)
-#define LEGACY_RATE3_RATE28_SET(x)               (((x) << LEGACY_RATE3_RATE28_LSB) & LEGACY_RATE3_RATE28_MASK)
-#define LEGACY_RATE3_RATE27_MSB                  11
-#define LEGACY_RATE3_RATE27_LSB                  6
-#define LEGACY_RATE3_RATE27_MASK                 0x00000fc0
-#define LEGACY_RATE3_RATE27_GET(x)               (((x) & LEGACY_RATE3_RATE27_MASK) >> LEGACY_RATE3_RATE27_LSB)
-#define LEGACY_RATE3_RATE27_SET(x)               (((x) << LEGACY_RATE3_RATE27_LSB) & LEGACY_RATE3_RATE27_MASK)
-#define LEGACY_RATE3_RATE26_MSB                  5
-#define LEGACY_RATE3_RATE26_LSB                  0
-#define LEGACY_RATE3_RATE26_MASK                 0x0000003f
-#define LEGACY_RATE3_RATE26_GET(x)               (((x) & LEGACY_RATE3_RATE26_MASK) >> LEGACY_RATE3_RATE26_LSB)
-#define LEGACY_RATE3_RATE26_SET(x)               (((x) << LEGACY_RATE3_RATE26_LSB) & LEGACY_RATE3_RATE26_MASK)
-
-#define RX_INT_FILTER_ADDRESS                    0x00008364
-#define RX_INT_FILTER_OFFSET                     0x00000364
-#define RX_INT_FILTER_BEACON_MSB                 17
-#define RX_INT_FILTER_BEACON_LSB                 17
-#define RX_INT_FILTER_BEACON_MASK                0x00020000
-#define RX_INT_FILTER_BEACON_GET(x)              (((x) & RX_INT_FILTER_BEACON_MASK) >> RX_INT_FILTER_BEACON_LSB)
-#define RX_INT_FILTER_BEACON_SET(x)              (((x) << RX_INT_FILTER_BEACON_LSB) & RX_INT_FILTER_BEACON_MASK)
-#define RX_INT_FILTER_AMPDU_MSB                  16
-#define RX_INT_FILTER_AMPDU_LSB                  16
-#define RX_INT_FILTER_AMPDU_MASK                 0x00010000
-#define RX_INT_FILTER_AMPDU_GET(x)               (((x) & RX_INT_FILTER_AMPDU_MASK) >> RX_INT_FILTER_AMPDU_LSB)
-#define RX_INT_FILTER_AMPDU_SET(x)               (((x) << RX_INT_FILTER_AMPDU_LSB) & RX_INT_FILTER_AMPDU_MASK)
-#define RX_INT_FILTER_EOSP_MSB                   15
-#define RX_INT_FILTER_EOSP_LSB                   15
-#define RX_INT_FILTER_EOSP_MASK                  0x00008000
-#define RX_INT_FILTER_EOSP_GET(x)                (((x) & RX_INT_FILTER_EOSP_MASK) >> RX_INT_FILTER_EOSP_LSB)
-#define RX_INT_FILTER_EOSP_SET(x)                (((x) << RX_INT_FILTER_EOSP_LSB) & RX_INT_FILTER_EOSP_MASK)
-#define RX_INT_FILTER_LENGTH_LOW_MSB             14
-#define RX_INT_FILTER_LENGTH_LOW_LSB             14
-#define RX_INT_FILTER_LENGTH_LOW_MASK            0x00004000
-#define RX_INT_FILTER_LENGTH_LOW_GET(x)          (((x) & RX_INT_FILTER_LENGTH_LOW_MASK) >> RX_INT_FILTER_LENGTH_LOW_LSB)
-#define RX_INT_FILTER_LENGTH_LOW_SET(x)          (((x) << RX_INT_FILTER_LENGTH_LOW_LSB) & RX_INT_FILTER_LENGTH_LOW_MASK)
-#define RX_INT_FILTER_LENGTH_HIGH_MSB            13
-#define RX_INT_FILTER_LENGTH_HIGH_LSB            13
-#define RX_INT_FILTER_LENGTH_HIGH_MASK           0x00002000
-#define RX_INT_FILTER_LENGTH_HIGH_GET(x)         (((x) & RX_INT_FILTER_LENGTH_HIGH_MASK) >> RX_INT_FILTER_LENGTH_HIGH_LSB)
-#define RX_INT_FILTER_LENGTH_HIGH_SET(x)         (((x) << RX_INT_FILTER_LENGTH_HIGH_LSB) & RX_INT_FILTER_LENGTH_HIGH_MASK)
-#define RX_INT_FILTER_RSSI_MSB                   12
-#define RX_INT_FILTER_RSSI_LSB                   12
-#define RX_INT_FILTER_RSSI_MASK                  0x00001000
-#define RX_INT_FILTER_RSSI_GET(x)                (((x) & RX_INT_FILTER_RSSI_MASK) >> RX_INT_FILTER_RSSI_LSB)
-#define RX_INT_FILTER_RSSI_SET(x)                (((x) << RX_INT_FILTER_RSSI_LSB) & RX_INT_FILTER_RSSI_MASK)
-#define RX_INT_FILTER_RATE_LOW_MSB               11
-#define RX_INT_FILTER_RATE_LOW_LSB               11
-#define RX_INT_FILTER_RATE_LOW_MASK              0x00000800
-#define RX_INT_FILTER_RATE_LOW_GET(x)            (((x) & RX_INT_FILTER_RATE_LOW_MASK) >> RX_INT_FILTER_RATE_LOW_LSB)
-#define RX_INT_FILTER_RATE_LOW_SET(x)            (((x) << RX_INT_FILTER_RATE_LOW_LSB) & RX_INT_FILTER_RATE_LOW_MASK)
-#define RX_INT_FILTER_RATE_HIGH_MSB              10
-#define RX_INT_FILTER_RATE_HIGH_LSB              10
-#define RX_INT_FILTER_RATE_HIGH_MASK             0x00000400
-#define RX_INT_FILTER_RATE_HIGH_GET(x)           (((x) & RX_INT_FILTER_RATE_HIGH_MASK) >> RX_INT_FILTER_RATE_HIGH_LSB)
-#define RX_INT_FILTER_RATE_HIGH_SET(x)           (((x) << RX_INT_FILTER_RATE_HIGH_LSB) & RX_INT_FILTER_RATE_HIGH_MASK)
-#define RX_INT_FILTER_MORE_FRAG_MSB              9
-#define RX_INT_FILTER_MORE_FRAG_LSB              9
-#define RX_INT_FILTER_MORE_FRAG_MASK             0x00000200
-#define RX_INT_FILTER_MORE_FRAG_GET(x)           (((x) & RX_INT_FILTER_MORE_FRAG_MASK) >> RX_INT_FILTER_MORE_FRAG_LSB)
-#define RX_INT_FILTER_MORE_FRAG_SET(x)           (((x) << RX_INT_FILTER_MORE_FRAG_LSB) & RX_INT_FILTER_MORE_FRAG_MASK)
-#define RX_INT_FILTER_MORE_DATA_MSB              8
-#define RX_INT_FILTER_MORE_DATA_LSB              8
-#define RX_INT_FILTER_MORE_DATA_MASK             0x00000100
-#define RX_INT_FILTER_MORE_DATA_GET(x)           (((x) & RX_INT_FILTER_MORE_DATA_MASK) >> RX_INT_FILTER_MORE_DATA_LSB)
-#define RX_INT_FILTER_MORE_DATA_SET(x)           (((x) << RX_INT_FILTER_MORE_DATA_LSB) & RX_INT_FILTER_MORE_DATA_MASK)
-#define RX_INT_FILTER_RETRY_MSB                  7
-#define RX_INT_FILTER_RETRY_LSB                  7
-#define RX_INT_FILTER_RETRY_MASK                 0x00000080
-#define RX_INT_FILTER_RETRY_GET(x)               (((x) & RX_INT_FILTER_RETRY_MASK) >> RX_INT_FILTER_RETRY_LSB)
-#define RX_INT_FILTER_RETRY_SET(x)               (((x) << RX_INT_FILTER_RETRY_LSB) & RX_INT_FILTER_RETRY_MASK)
-#define RX_INT_FILTER_CTS_MSB                    6
-#define RX_INT_FILTER_CTS_LSB                    6
-#define RX_INT_FILTER_CTS_MASK                   0x00000040
-#define RX_INT_FILTER_CTS_GET(x)                 (((x) & RX_INT_FILTER_CTS_MASK) >> RX_INT_FILTER_CTS_LSB)
-#define RX_INT_FILTER_CTS_SET(x)                 (((x) << RX_INT_FILTER_CTS_LSB) & RX_INT_FILTER_CTS_MASK)
-#define RX_INT_FILTER_ACK_MSB                    5
-#define RX_INT_FILTER_ACK_LSB                    5
-#define RX_INT_FILTER_ACK_MASK                   0x00000020
-#define RX_INT_FILTER_ACK_GET(x)                 (((x) & RX_INT_FILTER_ACK_MASK) >> RX_INT_FILTER_ACK_LSB)
-#define RX_INT_FILTER_ACK_SET(x)                 (((x) << RX_INT_FILTER_ACK_LSB) & RX_INT_FILTER_ACK_MASK)
-#define RX_INT_FILTER_RTS_MSB                    4
-#define RX_INT_FILTER_RTS_LSB                    4
-#define RX_INT_FILTER_RTS_MASK                   0x00000010
-#define RX_INT_FILTER_RTS_GET(x)                 (((x) & RX_INT_FILTER_RTS_MASK) >> RX_INT_FILTER_RTS_LSB)
-#define RX_INT_FILTER_RTS_SET(x)                 (((x) << RX_INT_FILTER_RTS_LSB) & RX_INT_FILTER_RTS_MASK)
-#define RX_INT_FILTER_MCAST_MSB                  3
-#define RX_INT_FILTER_MCAST_LSB                  3
-#define RX_INT_FILTER_MCAST_MASK                 0x00000008
-#define RX_INT_FILTER_MCAST_GET(x)               (((x) & RX_INT_FILTER_MCAST_MASK) >> RX_INT_FILTER_MCAST_LSB)
-#define RX_INT_FILTER_MCAST_SET(x)               (((x) << RX_INT_FILTER_MCAST_LSB) & RX_INT_FILTER_MCAST_MASK)
-#define RX_INT_FILTER_BCAST_MSB                  2
-#define RX_INT_FILTER_BCAST_LSB                  2
-#define RX_INT_FILTER_BCAST_MASK                 0x00000004
-#define RX_INT_FILTER_BCAST_GET(x)               (((x) & RX_INT_FILTER_BCAST_MASK) >> RX_INT_FILTER_BCAST_LSB)
-#define RX_INT_FILTER_BCAST_SET(x)               (((x) << RX_INT_FILTER_BCAST_LSB) & RX_INT_FILTER_BCAST_MASK)
-#define RX_INT_FILTER_DIRECTED_MSB               1
-#define RX_INT_FILTER_DIRECTED_LSB               1
-#define RX_INT_FILTER_DIRECTED_MASK              0x00000002
-#define RX_INT_FILTER_DIRECTED_GET(x)            (((x) & RX_INT_FILTER_DIRECTED_MASK) >> RX_INT_FILTER_DIRECTED_LSB)
-#define RX_INT_FILTER_DIRECTED_SET(x)            (((x) << RX_INT_FILTER_DIRECTED_LSB) & RX_INT_FILTER_DIRECTED_MASK)
-#define RX_INT_FILTER_ENABLE_MSB                 0
-#define RX_INT_FILTER_ENABLE_LSB                 0
-#define RX_INT_FILTER_ENABLE_MASK                0x00000001
-#define RX_INT_FILTER_ENABLE_GET(x)              (((x) & RX_INT_FILTER_ENABLE_MASK) >> RX_INT_FILTER_ENABLE_LSB)
-#define RX_INT_FILTER_ENABLE_SET(x)              (((x) << RX_INT_FILTER_ENABLE_LSB) & RX_INT_FILTER_ENABLE_MASK)
-
-#define RX_INT_OVERFLOW_ADDRESS                  0x00008368
-#define RX_INT_OVERFLOW_OFFSET                   0x00000368
-#define RX_INT_OVERFLOW_STATUS_MSB               0
-#define RX_INT_OVERFLOW_STATUS_LSB               0
-#define RX_INT_OVERFLOW_STATUS_MASK              0x00000001
-#define RX_INT_OVERFLOW_STATUS_GET(x)            (((x) & RX_INT_OVERFLOW_STATUS_MASK) >> RX_INT_OVERFLOW_STATUS_LSB)
-#define RX_INT_OVERFLOW_STATUS_SET(x)            (((x) << RX_INT_OVERFLOW_STATUS_LSB) & RX_INT_OVERFLOW_STATUS_MASK)
-
-#define RX_FILTER_THRESH_ADDRESS                 0x0000836c
-#define RX_FILTER_THRESH_OFFSET                  0x0000036c
-#define RX_FILTER_THRESH_RSSI_LOW_MSB            23
-#define RX_FILTER_THRESH_RSSI_LOW_LSB            16
-#define RX_FILTER_THRESH_RSSI_LOW_MASK           0x00ff0000
-#define RX_FILTER_THRESH_RSSI_LOW_GET(x)         (((x) & RX_FILTER_THRESH_RSSI_LOW_MASK) >> RX_FILTER_THRESH_RSSI_LOW_LSB)
-#define RX_FILTER_THRESH_RSSI_LOW_SET(x)         (((x) << RX_FILTER_THRESH_RSSI_LOW_LSB) & RX_FILTER_THRESH_RSSI_LOW_MASK)
-#define RX_FILTER_THRESH_RATE_LOW_MSB            15
-#define RX_FILTER_THRESH_RATE_LOW_LSB            8
-#define RX_FILTER_THRESH_RATE_LOW_MASK           0x0000ff00
-#define RX_FILTER_THRESH_RATE_LOW_GET(x)         (((x) & RX_FILTER_THRESH_RATE_LOW_MASK) >> RX_FILTER_THRESH_RATE_LOW_LSB)
-#define RX_FILTER_THRESH_RATE_LOW_SET(x)         (((x) << RX_FILTER_THRESH_RATE_LOW_LSB) & RX_FILTER_THRESH_RATE_LOW_MASK)
-#define RX_FILTER_THRESH_RATE_HIGH_MSB           7
-#define RX_FILTER_THRESH_RATE_HIGH_LSB           0
-#define RX_FILTER_THRESH_RATE_HIGH_MASK          0x000000ff
-#define RX_FILTER_THRESH_RATE_HIGH_GET(x)        (((x) & RX_FILTER_THRESH_RATE_HIGH_MASK) >> RX_FILTER_THRESH_RATE_HIGH_LSB)
-#define RX_FILTER_THRESH_RATE_HIGH_SET(x)        (((x) << RX_FILTER_THRESH_RATE_HIGH_LSB) & RX_FILTER_THRESH_RATE_HIGH_MASK)
-
-#define RX_FILTER_THRESH1_ADDRESS                0x00008370
-#define RX_FILTER_THRESH1_OFFSET                 0x00000370
-#define RX_FILTER_THRESH1_LENGTH_LOW_MSB         23
-#define RX_FILTER_THRESH1_LENGTH_LOW_LSB         12
-#define RX_FILTER_THRESH1_LENGTH_LOW_MASK        0x00fff000
-#define RX_FILTER_THRESH1_LENGTH_LOW_GET(x)      (((x) & RX_FILTER_THRESH1_LENGTH_LOW_MASK) >> RX_FILTER_THRESH1_LENGTH_LOW_LSB)
-#define RX_FILTER_THRESH1_LENGTH_LOW_SET(x)      (((x) << RX_FILTER_THRESH1_LENGTH_LOW_LSB) & RX_FILTER_THRESH1_LENGTH_LOW_MASK)
-#define RX_FILTER_THRESH1_LENGTH_HIGH_MSB        11
-#define RX_FILTER_THRESH1_LENGTH_HIGH_LSB        0
-#define RX_FILTER_THRESH1_LENGTH_HIGH_MASK       0x00000fff
-#define RX_FILTER_THRESH1_LENGTH_HIGH_GET(x)     (((x) & RX_FILTER_THRESH1_LENGTH_HIGH_MASK) >> RX_FILTER_THRESH1_LENGTH_HIGH_LSB)
-#define RX_FILTER_THRESH1_LENGTH_HIGH_SET(x)     (((x) << RX_FILTER_THRESH1_LENGTH_HIGH_LSB) & RX_FILTER_THRESH1_LENGTH_HIGH_MASK)
-
-#define RX_PRIORITY_THRESH0_ADDRESS              0x00008374
-#define RX_PRIORITY_THRESH0_OFFSET               0x00000374
-#define RX_PRIORITY_THRESH0_RSSI_LOW_MSB         31
-#define RX_PRIORITY_THRESH0_RSSI_LOW_LSB         24
-#define RX_PRIORITY_THRESH0_RSSI_LOW_MASK        0xff000000
-#define RX_PRIORITY_THRESH0_RSSI_LOW_GET(x)      (((x) & RX_PRIORITY_THRESH0_RSSI_LOW_MASK) >> RX_PRIORITY_THRESH0_RSSI_LOW_LSB)
-#define RX_PRIORITY_THRESH0_RSSI_LOW_SET(x)      (((x) << RX_PRIORITY_THRESH0_RSSI_LOW_LSB) & RX_PRIORITY_THRESH0_RSSI_LOW_MASK)
-#define RX_PRIORITY_THRESH0_RSSI_HIGH_MSB        23
-#define RX_PRIORITY_THRESH0_RSSI_HIGH_LSB        16
-#define RX_PRIORITY_THRESH0_RSSI_HIGH_MASK       0x00ff0000
-#define RX_PRIORITY_THRESH0_RSSI_HIGH_GET(x)     (((x) & RX_PRIORITY_THRESH0_RSSI_HIGH_MASK) >> RX_PRIORITY_THRESH0_RSSI_HIGH_LSB)
-#define RX_PRIORITY_THRESH0_RSSI_HIGH_SET(x)     (((x) << RX_PRIORITY_THRESH0_RSSI_HIGH_LSB) & RX_PRIORITY_THRESH0_RSSI_HIGH_MASK)
-#define RX_PRIORITY_THRESH0_RATE_LOW_MSB         15
-#define RX_PRIORITY_THRESH0_RATE_LOW_LSB         8
-#define RX_PRIORITY_THRESH0_RATE_LOW_MASK        0x0000ff00
-#define RX_PRIORITY_THRESH0_RATE_LOW_GET(x)      (((x) & RX_PRIORITY_THRESH0_RATE_LOW_MASK) >> RX_PRIORITY_THRESH0_RATE_LOW_LSB)
-#define RX_PRIORITY_THRESH0_RATE_LOW_SET(x)      (((x) << RX_PRIORITY_THRESH0_RATE_LOW_LSB) & RX_PRIORITY_THRESH0_RATE_LOW_MASK)
-#define RX_PRIORITY_THRESH0_RATE_HIGH_MSB        7
-#define RX_PRIORITY_THRESH0_RATE_HIGH_LSB        0
-#define RX_PRIORITY_THRESH0_RATE_HIGH_MASK       0x000000ff
-#define RX_PRIORITY_THRESH0_RATE_HIGH_GET(x)     (((x) & RX_PRIORITY_THRESH0_RATE_HIGH_MASK) >> RX_PRIORITY_THRESH0_RATE_HIGH_LSB)
-#define RX_PRIORITY_THRESH0_RATE_HIGH_SET(x)     (((x) << RX_PRIORITY_THRESH0_RATE_HIGH_LSB) & RX_PRIORITY_THRESH0_RATE_HIGH_MASK)
-
-#define RX_PRIORITY_THRESH1_ADDRESS              0x00008378
-#define RX_PRIORITY_THRESH1_OFFSET               0x00000378
-#define RX_PRIORITY_THRESH1_XCAST_RSSI_HIGH_MSB  31
-#define RX_PRIORITY_THRESH1_XCAST_RSSI_HIGH_LSB  24
-#define RX_PRIORITY_THRESH1_XCAST_RSSI_HIGH_MASK 0xff000000
-#define RX_PRIORITY_THRESH1_XCAST_RSSI_HIGH_GET(x) (((x) & RX_PRIORITY_THRESH1_XCAST_RSSI_HIGH_MASK) >> RX_PRIORITY_THRESH1_XCAST_RSSI_HIGH_LSB)
-#define RX_PRIORITY_THRESH1_XCAST_RSSI_HIGH_SET(x) (((x) << RX_PRIORITY_THRESH1_XCAST_RSSI_HIGH_LSB) & RX_PRIORITY_THRESH1_XCAST_RSSI_HIGH_MASK)
-#define RX_PRIORITY_THRESH1_LENGTH_LOW_MSB       23
-#define RX_PRIORITY_THRESH1_LENGTH_LOW_LSB       12
-#define RX_PRIORITY_THRESH1_LENGTH_LOW_MASK      0x00fff000
-#define RX_PRIORITY_THRESH1_LENGTH_LOW_GET(x)    (((x) & RX_PRIORITY_THRESH1_LENGTH_LOW_MASK) >> RX_PRIORITY_THRESH1_LENGTH_LOW_LSB)
-#define RX_PRIORITY_THRESH1_LENGTH_LOW_SET(x)    (((x) << RX_PRIORITY_THRESH1_LENGTH_LOW_LSB) & RX_PRIORITY_THRESH1_LENGTH_LOW_MASK)
-#define RX_PRIORITY_THRESH1_LENGTH_HIGH_MSB      11
-#define RX_PRIORITY_THRESH1_LENGTH_HIGH_LSB      0
-#define RX_PRIORITY_THRESH1_LENGTH_HIGH_MASK     0x00000fff
-#define RX_PRIORITY_THRESH1_LENGTH_HIGH_GET(x)   (((x) & RX_PRIORITY_THRESH1_LENGTH_HIGH_MASK) >> RX_PRIORITY_THRESH1_LENGTH_HIGH_LSB)
-#define RX_PRIORITY_THRESH1_LENGTH_HIGH_SET(x)   (((x) << RX_PRIORITY_THRESH1_LENGTH_HIGH_LSB) & RX_PRIORITY_THRESH1_LENGTH_HIGH_MASK)
-
-#define RX_PRIORITY_THRESH2_ADDRESS              0x0000837c
-#define RX_PRIORITY_THRESH2_OFFSET               0x0000037c
-#define RX_PRIORITY_THRESH2_NULL_RSSI_HIGH_MSB   31
-#define RX_PRIORITY_THRESH2_NULL_RSSI_HIGH_LSB   24
-#define RX_PRIORITY_THRESH2_NULL_RSSI_HIGH_MASK  0xff000000
-#define RX_PRIORITY_THRESH2_NULL_RSSI_HIGH_GET(x) (((x) & RX_PRIORITY_THRESH2_NULL_RSSI_HIGH_MASK) >> RX_PRIORITY_THRESH2_NULL_RSSI_HIGH_LSB)
-#define RX_PRIORITY_THRESH2_NULL_RSSI_HIGH_SET(x) (((x) << RX_PRIORITY_THRESH2_NULL_RSSI_HIGH_LSB) & RX_PRIORITY_THRESH2_NULL_RSSI_HIGH_MASK)
-#define RX_PRIORITY_THRESH2_BEACON_RSSI_HIGH_MSB 23
-#define RX_PRIORITY_THRESH2_BEACON_RSSI_HIGH_LSB 16
-#define RX_PRIORITY_THRESH2_BEACON_RSSI_HIGH_MASK 0x00ff0000
-#define RX_PRIORITY_THRESH2_BEACON_RSSI_HIGH_GET(x) (((x) & RX_PRIORITY_THRESH2_BEACON_RSSI_HIGH_MASK) >> RX_PRIORITY_THRESH2_BEACON_RSSI_HIGH_LSB)
-#define RX_PRIORITY_THRESH2_BEACON_RSSI_HIGH_SET(x) (((x) << RX_PRIORITY_THRESH2_BEACON_RSSI_HIGH_LSB) & RX_PRIORITY_THRESH2_BEACON_RSSI_HIGH_MASK)
-#define RX_PRIORITY_THRESH2_MGMT_RSSI_HIGH_MSB   15
-#define RX_PRIORITY_THRESH2_MGMT_RSSI_HIGH_LSB   8
-#define RX_PRIORITY_THRESH2_MGMT_RSSI_HIGH_MASK  0x0000ff00
-#define RX_PRIORITY_THRESH2_MGMT_RSSI_HIGH_GET(x) (((x) & RX_PRIORITY_THRESH2_MGMT_RSSI_HIGH_MASK) >> RX_PRIORITY_THRESH2_MGMT_RSSI_HIGH_LSB)
-#define RX_PRIORITY_THRESH2_MGMT_RSSI_HIGH_SET(x) (((x) << RX_PRIORITY_THRESH2_MGMT_RSSI_HIGH_LSB) & RX_PRIORITY_THRESH2_MGMT_RSSI_HIGH_MASK)
-#define RX_PRIORITY_THRESH2_PRESP_RSSI_HIGH_MSB  7
-#define RX_PRIORITY_THRESH2_PRESP_RSSI_HIGH_LSB  0
-#define RX_PRIORITY_THRESH2_PRESP_RSSI_HIGH_MASK 0x000000ff
-#define RX_PRIORITY_THRESH2_PRESP_RSSI_HIGH_GET(x) (((x) & RX_PRIORITY_THRESH2_PRESP_RSSI_HIGH_MASK) >> RX_PRIORITY_THRESH2_PRESP_RSSI_HIGH_LSB)
-#define RX_PRIORITY_THRESH2_PRESP_RSSI_HIGH_SET(x) (((x) << RX_PRIORITY_THRESH2_PRESP_RSSI_HIGH_LSB) & RX_PRIORITY_THRESH2_PRESP_RSSI_HIGH_MASK)
-
-#define RX_PRIORITY_THRESH3_ADDRESS              0x00008380
-#define RX_PRIORITY_THRESH3_OFFSET               0x00000380
-#define RX_PRIORITY_THRESH3_PS_POLL_RSSI_HIGH_MSB 15
-#define RX_PRIORITY_THRESH3_PS_POLL_RSSI_HIGH_LSB 8
-#define RX_PRIORITY_THRESH3_PS_POLL_RSSI_HIGH_MASK 0x0000ff00
-#define RX_PRIORITY_THRESH3_PS_POLL_RSSI_HIGH_GET(x) (((x) & RX_PRIORITY_THRESH3_PS_POLL_RSSI_HIGH_MASK) >> RX_PRIORITY_THRESH3_PS_POLL_RSSI_HIGH_LSB)
-#define RX_PRIORITY_THRESH3_PS_POLL_RSSI_HIGH_SET(x) (((x) << RX_PRIORITY_THRESH3_PS_POLL_RSSI_HIGH_LSB) & RX_PRIORITY_THRESH3_PS_POLL_RSSI_HIGH_MASK)
-#define RX_PRIORITY_THRESH3_PREQ_RSSI_HIGH_MSB   7
-#define RX_PRIORITY_THRESH3_PREQ_RSSI_HIGH_LSB   0
-#define RX_PRIORITY_THRESH3_PREQ_RSSI_HIGH_MASK  0x000000ff
-#define RX_PRIORITY_THRESH3_PREQ_RSSI_HIGH_GET(x) (((x) & RX_PRIORITY_THRESH3_PREQ_RSSI_HIGH_MASK) >> RX_PRIORITY_THRESH3_PREQ_RSSI_HIGH_LSB)
-#define RX_PRIORITY_THRESH3_PREQ_RSSI_HIGH_SET(x) (((x) << RX_PRIORITY_THRESH3_PREQ_RSSI_HIGH_LSB) & RX_PRIORITY_THRESH3_PREQ_RSSI_HIGH_MASK)
-
-#define RX_PRIORITY_OFFSET0_ADDRESS              0x00008384
-#define RX_PRIORITY_OFFSET0_OFFSET               0x00000384
-#define RX_PRIORITY_OFFSET0_XCAST_RSSI_HIGH_MSB  29
-#define RX_PRIORITY_OFFSET0_XCAST_RSSI_HIGH_LSB  24
-#define RX_PRIORITY_OFFSET0_XCAST_RSSI_HIGH_MASK 0x3f000000
-#define RX_PRIORITY_OFFSET0_XCAST_RSSI_HIGH_GET(x) (((x) & RX_PRIORITY_OFFSET0_XCAST_RSSI_HIGH_MASK) >> RX_PRIORITY_OFFSET0_XCAST_RSSI_HIGH_LSB)
-#define RX_PRIORITY_OFFSET0_XCAST_RSSI_HIGH_SET(x) (((x) << RX_PRIORITY_OFFSET0_XCAST_RSSI_HIGH_LSB) & RX_PRIORITY_OFFSET0_XCAST_RSSI_HIGH_MASK)
-#define RX_PRIORITY_OFFSET0_RSSI_LOW_MSB         23
-#define RX_PRIORITY_OFFSET0_RSSI_LOW_LSB         18
-#define RX_PRIORITY_OFFSET0_RSSI_LOW_MASK        0x00fc0000
-#define RX_PRIORITY_OFFSET0_RSSI_LOW_GET(x)      (((x) & RX_PRIORITY_OFFSET0_RSSI_LOW_MASK) >> RX_PRIORITY_OFFSET0_RSSI_LOW_LSB)
-#define RX_PRIORITY_OFFSET0_RSSI_LOW_SET(x)      (((x) << RX_PRIORITY_OFFSET0_RSSI_LOW_LSB) & RX_PRIORITY_OFFSET0_RSSI_LOW_MASK)
-#define RX_PRIORITY_OFFSET0_RSSI_HIGH_MSB        17
-#define RX_PRIORITY_OFFSET0_RSSI_HIGH_LSB        12
-#define RX_PRIORITY_OFFSET0_RSSI_HIGH_MASK       0x0003f000
-#define RX_PRIORITY_OFFSET0_RSSI_HIGH_GET(x)     (((x) & RX_PRIORITY_OFFSET0_RSSI_HIGH_MASK) >> RX_PRIORITY_OFFSET0_RSSI_HIGH_LSB)
-#define RX_PRIORITY_OFFSET0_RSSI_HIGH_SET(x)     (((x) << RX_PRIORITY_OFFSET0_RSSI_HIGH_LSB) & RX_PRIORITY_OFFSET0_RSSI_HIGH_MASK)
-#define RX_PRIORITY_OFFSET0_PHY_RATE_LOW_MSB     11
-#define RX_PRIORITY_OFFSET0_PHY_RATE_LOW_LSB     6
-#define RX_PRIORITY_OFFSET0_PHY_RATE_LOW_MASK    0x00000fc0
-#define RX_PRIORITY_OFFSET0_PHY_RATE_LOW_GET(x)  (((x) & RX_PRIORITY_OFFSET0_PHY_RATE_LOW_MASK) >> RX_PRIORITY_OFFSET0_PHY_RATE_LOW_LSB)
-#define RX_PRIORITY_OFFSET0_PHY_RATE_LOW_SET(x)  (((x) << RX_PRIORITY_OFFSET0_PHY_RATE_LOW_LSB) & RX_PRIORITY_OFFSET0_PHY_RATE_LOW_MASK)
-#define RX_PRIORITY_OFFSET0_PHY_RATE_HIGH_MSB    5
-#define RX_PRIORITY_OFFSET0_PHY_RATE_HIGH_LSB    0
-#define RX_PRIORITY_OFFSET0_PHY_RATE_HIGH_MASK   0x0000003f
-#define RX_PRIORITY_OFFSET0_PHY_RATE_HIGH_GET(x) (((x) & RX_PRIORITY_OFFSET0_PHY_RATE_HIGH_MASK) >> RX_PRIORITY_OFFSET0_PHY_RATE_HIGH_LSB)
-#define RX_PRIORITY_OFFSET0_PHY_RATE_HIGH_SET(x) (((x) << RX_PRIORITY_OFFSET0_PHY_RATE_HIGH_LSB) & RX_PRIORITY_OFFSET0_PHY_RATE_HIGH_MASK)
-
-#define RX_PRIORITY_OFFSET1_ADDRESS              0x00008388
-#define RX_PRIORITY_OFFSET1_OFFSET               0x00000388
-#define RX_PRIORITY_OFFSET1_RTS_MSB              29
-#define RX_PRIORITY_OFFSET1_RTS_LSB              24
-#define RX_PRIORITY_OFFSET1_RTS_MASK             0x3f000000
-#define RX_PRIORITY_OFFSET1_RTS_GET(x)           (((x) & RX_PRIORITY_OFFSET1_RTS_MASK) >> RX_PRIORITY_OFFSET1_RTS_LSB)
-#define RX_PRIORITY_OFFSET1_RTS_SET(x)           (((x) << RX_PRIORITY_OFFSET1_RTS_LSB) & RX_PRIORITY_OFFSET1_RTS_MASK)
-#define RX_PRIORITY_OFFSET1_RETX_MSB             23
-#define RX_PRIORITY_OFFSET1_RETX_LSB             18
-#define RX_PRIORITY_OFFSET1_RETX_MASK            0x00fc0000
-#define RX_PRIORITY_OFFSET1_RETX_GET(x)          (((x) & RX_PRIORITY_OFFSET1_RETX_MASK) >> RX_PRIORITY_OFFSET1_RETX_LSB)
-#define RX_PRIORITY_OFFSET1_RETX_SET(x)          (((x) << RX_PRIORITY_OFFSET1_RETX_LSB) & RX_PRIORITY_OFFSET1_RETX_MASK)
-#define RX_PRIORITY_OFFSET1_PRESP_RSSI_HIGH_MSB  17
-#define RX_PRIORITY_OFFSET1_PRESP_RSSI_HIGH_LSB  12
-#define RX_PRIORITY_OFFSET1_PRESP_RSSI_HIGH_MASK 0x0003f000
-#define RX_PRIORITY_OFFSET1_PRESP_RSSI_HIGH_GET(x) (((x) & RX_PRIORITY_OFFSET1_PRESP_RSSI_HIGH_MASK) >> RX_PRIORITY_OFFSET1_PRESP_RSSI_HIGH_LSB)
-#define RX_PRIORITY_OFFSET1_PRESP_RSSI_HIGH_SET(x) (((x) << RX_PRIORITY_OFFSET1_PRESP_RSSI_HIGH_LSB) & RX_PRIORITY_OFFSET1_PRESP_RSSI_HIGH_MASK)
-#define RX_PRIORITY_OFFSET1_LENGTH_LOW_MSB       11
-#define RX_PRIORITY_OFFSET1_LENGTH_LOW_LSB       6
-#define RX_PRIORITY_OFFSET1_LENGTH_LOW_MASK      0x00000fc0
-#define RX_PRIORITY_OFFSET1_LENGTH_LOW_GET(x)    (((x) & RX_PRIORITY_OFFSET1_LENGTH_LOW_MASK) >> RX_PRIORITY_OFFSET1_LENGTH_LOW_LSB)
-#define RX_PRIORITY_OFFSET1_LENGTH_LOW_SET(x)    (((x) << RX_PRIORITY_OFFSET1_LENGTH_LOW_LSB) & RX_PRIORITY_OFFSET1_LENGTH_LOW_MASK)
-#define RX_PRIORITY_OFFSET1_LENGTH_HIGH_MSB      5
-#define RX_PRIORITY_OFFSET1_LENGTH_HIGH_LSB      0
-#define RX_PRIORITY_OFFSET1_LENGTH_HIGH_MASK     0x0000003f
-#define RX_PRIORITY_OFFSET1_LENGTH_HIGH_GET(x)   (((x) & RX_PRIORITY_OFFSET1_LENGTH_HIGH_MASK) >> RX_PRIORITY_OFFSET1_LENGTH_HIGH_LSB)
-#define RX_PRIORITY_OFFSET1_LENGTH_HIGH_SET(x)   (((x) << RX_PRIORITY_OFFSET1_LENGTH_HIGH_LSB) & RX_PRIORITY_OFFSET1_LENGTH_HIGH_MASK)
-
-#define RX_PRIORITY_OFFSET2_ADDRESS              0x0000838c
-#define RX_PRIORITY_OFFSET2_OFFSET               0x0000038c
-#define RX_PRIORITY_OFFSET2_BEACON_MSB           29
-#define RX_PRIORITY_OFFSET2_BEACON_LSB           24
-#define RX_PRIORITY_OFFSET2_BEACON_MASK          0x3f000000
-#define RX_PRIORITY_OFFSET2_BEACON_GET(x)        (((x) & RX_PRIORITY_OFFSET2_BEACON_MASK) >> RX_PRIORITY_OFFSET2_BEACON_LSB)
-#define RX_PRIORITY_OFFSET2_BEACON_SET(x)        (((x) << RX_PRIORITY_OFFSET2_BEACON_LSB) & RX_PRIORITY_OFFSET2_BEACON_MASK)
-#define RX_PRIORITY_OFFSET2_MGMT_MSB             23
-#define RX_PRIORITY_OFFSET2_MGMT_LSB             18
-#define RX_PRIORITY_OFFSET2_MGMT_MASK            0x00fc0000
-#define RX_PRIORITY_OFFSET2_MGMT_GET(x)          (((x) & RX_PRIORITY_OFFSET2_MGMT_MASK) >> RX_PRIORITY_OFFSET2_MGMT_LSB)
-#define RX_PRIORITY_OFFSET2_MGMT_SET(x)          (((x) << RX_PRIORITY_OFFSET2_MGMT_LSB) & RX_PRIORITY_OFFSET2_MGMT_MASK)
-#define RX_PRIORITY_OFFSET2_ATIM_MSB             17
-#define RX_PRIORITY_OFFSET2_ATIM_LSB             12
-#define RX_PRIORITY_OFFSET2_ATIM_MASK            0x0003f000
-#define RX_PRIORITY_OFFSET2_ATIM_GET(x)          (((x) & RX_PRIORITY_OFFSET2_ATIM_MASK) >> RX_PRIORITY_OFFSET2_ATIM_LSB)
-#define RX_PRIORITY_OFFSET2_ATIM_SET(x)          (((x) << RX_PRIORITY_OFFSET2_ATIM_LSB) & RX_PRIORITY_OFFSET2_ATIM_MASK)
-#define RX_PRIORITY_OFFSET2_PRESP_MSB            11
-#define RX_PRIORITY_OFFSET2_PRESP_LSB            6
-#define RX_PRIORITY_OFFSET2_PRESP_MASK           0x00000fc0
-#define RX_PRIORITY_OFFSET2_PRESP_GET(x)         (((x) & RX_PRIORITY_OFFSET2_PRESP_MASK) >> RX_PRIORITY_OFFSET2_PRESP_LSB)
-#define RX_PRIORITY_OFFSET2_PRESP_SET(x)         (((x) << RX_PRIORITY_OFFSET2_PRESP_LSB) & RX_PRIORITY_OFFSET2_PRESP_MASK)
-#define RX_PRIORITY_OFFSET2_XCAST_MSB            5
-#define RX_PRIORITY_OFFSET2_XCAST_LSB            0
-#define RX_PRIORITY_OFFSET2_XCAST_MASK           0x0000003f
-#define RX_PRIORITY_OFFSET2_XCAST_GET(x)         (((x) & RX_PRIORITY_OFFSET2_XCAST_MASK) >> RX_PRIORITY_OFFSET2_XCAST_LSB)
-#define RX_PRIORITY_OFFSET2_XCAST_SET(x)         (((x) << RX_PRIORITY_OFFSET2_XCAST_LSB) & RX_PRIORITY_OFFSET2_XCAST_MASK)
-
-#define RX_PRIORITY_OFFSET3_ADDRESS              0x00008390
-#define RX_PRIORITY_OFFSET3_OFFSET               0x00000390
-#define RX_PRIORITY_OFFSET3_PS_POLL_MSB          29
-#define RX_PRIORITY_OFFSET3_PS_POLL_LSB          24
-#define RX_PRIORITY_OFFSET3_PS_POLL_MASK         0x3f000000
-#define RX_PRIORITY_OFFSET3_PS_POLL_GET(x)       (((x) & RX_PRIORITY_OFFSET3_PS_POLL_MASK) >> RX_PRIORITY_OFFSET3_PS_POLL_LSB)
-#define RX_PRIORITY_OFFSET3_PS_POLL_SET(x)       (((x) << RX_PRIORITY_OFFSET3_PS_POLL_LSB) & RX_PRIORITY_OFFSET3_PS_POLL_MASK)
-#define RX_PRIORITY_OFFSET3_AMSDU_MSB            23
-#define RX_PRIORITY_OFFSET3_AMSDU_LSB            18
-#define RX_PRIORITY_OFFSET3_AMSDU_MASK           0x00fc0000
-#define RX_PRIORITY_OFFSET3_AMSDU_GET(x)         (((x) & RX_PRIORITY_OFFSET3_AMSDU_MASK) >> RX_PRIORITY_OFFSET3_AMSDU_LSB)
-#define RX_PRIORITY_OFFSET3_AMSDU_SET(x)         (((x) << RX_PRIORITY_OFFSET3_AMSDU_LSB) & RX_PRIORITY_OFFSET3_AMSDU_MASK)
-#define RX_PRIORITY_OFFSET3_AMPDU_MSB            17
-#define RX_PRIORITY_OFFSET3_AMPDU_LSB            12
-#define RX_PRIORITY_OFFSET3_AMPDU_MASK           0x0003f000
-#define RX_PRIORITY_OFFSET3_AMPDU_GET(x)         (((x) & RX_PRIORITY_OFFSET3_AMPDU_MASK) >> RX_PRIORITY_OFFSET3_AMPDU_LSB)
-#define RX_PRIORITY_OFFSET3_AMPDU_SET(x)         (((x) << RX_PRIORITY_OFFSET3_AMPDU_LSB) & RX_PRIORITY_OFFSET3_AMPDU_MASK)
-#define RX_PRIORITY_OFFSET3_EOSP_MSB             11
-#define RX_PRIORITY_OFFSET3_EOSP_LSB             6
-#define RX_PRIORITY_OFFSET3_EOSP_MASK            0x00000fc0
-#define RX_PRIORITY_OFFSET3_EOSP_GET(x)          (((x) & RX_PRIORITY_OFFSET3_EOSP_MASK) >> RX_PRIORITY_OFFSET3_EOSP_LSB)
-#define RX_PRIORITY_OFFSET3_EOSP_SET(x)          (((x) << RX_PRIORITY_OFFSET3_EOSP_LSB) & RX_PRIORITY_OFFSET3_EOSP_MASK)
-#define RX_PRIORITY_OFFSET3_MORE_MSB             5
-#define RX_PRIORITY_OFFSET3_MORE_LSB             0
-#define RX_PRIORITY_OFFSET3_MORE_MASK            0x0000003f
-#define RX_PRIORITY_OFFSET3_MORE_GET(x)          (((x) & RX_PRIORITY_OFFSET3_MORE_MASK) >> RX_PRIORITY_OFFSET3_MORE_LSB)
-#define RX_PRIORITY_OFFSET3_MORE_SET(x)          (((x) << RX_PRIORITY_OFFSET3_MORE_LSB) & RX_PRIORITY_OFFSET3_MORE_MASK)
-
-#define RX_PRIORITY_OFFSET4_ADDRESS              0x00008394
-#define RX_PRIORITY_OFFSET4_OFFSET               0x00000394
-#define RX_PRIORITY_OFFSET4_BEACON_RSSI_HIGH_MSB 29
-#define RX_PRIORITY_OFFSET4_BEACON_RSSI_HIGH_LSB 24
-#define RX_PRIORITY_OFFSET4_BEACON_RSSI_HIGH_MASK 0x3f000000
-#define RX_PRIORITY_OFFSET4_BEACON_RSSI_HIGH_GET(x) (((x) & RX_PRIORITY_OFFSET4_BEACON_RSSI_HIGH_MASK) >> RX_PRIORITY_OFFSET4_BEACON_RSSI_HIGH_LSB)
-#define RX_PRIORITY_OFFSET4_BEACON_RSSI_HIGH_SET(x) (((x) << RX_PRIORITY_OFFSET4_BEACON_RSSI_HIGH_LSB) & RX_PRIORITY_OFFSET4_BEACON_RSSI_HIGH_MASK)
-#define RX_PRIORITY_OFFSET4_MGMT_RSSI_HIGH_MSB   23
-#define RX_PRIORITY_OFFSET4_MGMT_RSSI_HIGH_LSB   18
-#define RX_PRIORITY_OFFSET4_MGMT_RSSI_HIGH_MASK  0x00fc0000
-#define RX_PRIORITY_OFFSET4_MGMT_RSSI_HIGH_GET(x) (((x) & RX_PRIORITY_OFFSET4_MGMT_RSSI_HIGH_MASK) >> RX_PRIORITY_OFFSET4_MGMT_RSSI_HIGH_LSB)
-#define RX_PRIORITY_OFFSET4_MGMT_RSSI_HIGH_SET(x) (((x) << RX_PRIORITY_OFFSET4_MGMT_RSSI_HIGH_LSB) & RX_PRIORITY_OFFSET4_MGMT_RSSI_HIGH_MASK)
-#define RX_PRIORITY_OFFSET4_BEACON_SSID_MSB      17
-#define RX_PRIORITY_OFFSET4_BEACON_SSID_LSB      12
-#define RX_PRIORITY_OFFSET4_BEACON_SSID_MASK     0x0003f000
-#define RX_PRIORITY_OFFSET4_BEACON_SSID_GET(x)   (((x) & RX_PRIORITY_OFFSET4_BEACON_SSID_MASK) >> RX_PRIORITY_OFFSET4_BEACON_SSID_LSB)
-#define RX_PRIORITY_OFFSET4_BEACON_SSID_SET(x)   (((x) << RX_PRIORITY_OFFSET4_BEACON_SSID_LSB) & RX_PRIORITY_OFFSET4_BEACON_SSID_MASK)
-#define RX_PRIORITY_OFFSET4_NULL_MSB             11
-#define RX_PRIORITY_OFFSET4_NULL_LSB             6
-#define RX_PRIORITY_OFFSET4_NULL_MASK            0x00000fc0
-#define RX_PRIORITY_OFFSET4_NULL_GET(x)          (((x) & RX_PRIORITY_OFFSET4_NULL_MASK) >> RX_PRIORITY_OFFSET4_NULL_LSB)
-#define RX_PRIORITY_OFFSET4_NULL_SET(x)          (((x) << RX_PRIORITY_OFFSET4_NULL_LSB) & RX_PRIORITY_OFFSET4_NULL_MASK)
-#define RX_PRIORITY_OFFSET4_PREQ_MSB             5
-#define RX_PRIORITY_OFFSET4_PREQ_LSB             0
-#define RX_PRIORITY_OFFSET4_PREQ_MASK            0x0000003f
-#define RX_PRIORITY_OFFSET4_PREQ_GET(x)          (((x) & RX_PRIORITY_OFFSET4_PREQ_MASK) >> RX_PRIORITY_OFFSET4_PREQ_LSB)
-#define RX_PRIORITY_OFFSET4_PREQ_SET(x)          (((x) << RX_PRIORITY_OFFSET4_PREQ_LSB) & RX_PRIORITY_OFFSET4_PREQ_MASK)
-
-#define RX_PRIORITY_OFFSET5_ADDRESS              0x00008398
-#define RX_PRIORITY_OFFSET5_OFFSET               0x00000398
-#define RX_PRIORITY_OFFSET5_PS_POLL_RSSI_HIGH_MSB 17
-#define RX_PRIORITY_OFFSET5_PS_POLL_RSSI_HIGH_LSB 12
-#define RX_PRIORITY_OFFSET5_PS_POLL_RSSI_HIGH_MASK 0x0003f000
-#define RX_PRIORITY_OFFSET5_PS_POLL_RSSI_HIGH_GET(x) (((x) & RX_PRIORITY_OFFSET5_PS_POLL_RSSI_HIGH_MASK) >> RX_PRIORITY_OFFSET5_PS_POLL_RSSI_HIGH_LSB)
-#define RX_PRIORITY_OFFSET5_PS_POLL_RSSI_HIGH_SET(x) (((x) << RX_PRIORITY_OFFSET5_PS_POLL_RSSI_HIGH_LSB) & RX_PRIORITY_OFFSET5_PS_POLL_RSSI_HIGH_MASK)
-#define RX_PRIORITY_OFFSET5_PREQ_RSSI_HIGH_MSB   11
-#define RX_PRIORITY_OFFSET5_PREQ_RSSI_HIGH_LSB   6
-#define RX_PRIORITY_OFFSET5_PREQ_RSSI_HIGH_MASK  0x00000fc0
-#define RX_PRIORITY_OFFSET5_PREQ_RSSI_HIGH_GET(x) (((x) & RX_PRIORITY_OFFSET5_PREQ_RSSI_HIGH_MASK) >> RX_PRIORITY_OFFSET5_PREQ_RSSI_HIGH_LSB)
-#define RX_PRIORITY_OFFSET5_PREQ_RSSI_HIGH_SET(x) (((x) << RX_PRIORITY_OFFSET5_PREQ_RSSI_HIGH_LSB) & RX_PRIORITY_OFFSET5_PREQ_RSSI_HIGH_MASK)
-#define RX_PRIORITY_OFFSET5_NULL_RSSI_HIGH_MSB   5
-#define RX_PRIORITY_OFFSET5_NULL_RSSI_HIGH_LSB   0
-#define RX_PRIORITY_OFFSET5_NULL_RSSI_HIGH_MASK  0x0000003f
-#define RX_PRIORITY_OFFSET5_NULL_RSSI_HIGH_GET(x) (((x) & RX_PRIORITY_OFFSET5_NULL_RSSI_HIGH_MASK) >> RX_PRIORITY_OFFSET5_NULL_RSSI_HIGH_LSB)
-#define RX_PRIORITY_OFFSET5_NULL_RSSI_HIGH_SET(x) (((x) << RX_PRIORITY_OFFSET5_NULL_RSSI_HIGH_LSB) & RX_PRIORITY_OFFSET5_NULL_RSSI_HIGH_MASK)
-
-#define MAC_PCU_BSSID2_L32_ADDRESS               0x0000839c
-#define MAC_PCU_BSSID2_L32_OFFSET                0x0000039c
-#define MAC_PCU_BSSID2_L32_ADDR_MSB              31
-#define MAC_PCU_BSSID2_L32_ADDR_LSB              0
-#define MAC_PCU_BSSID2_L32_ADDR_MASK             0xffffffff
-#define MAC_PCU_BSSID2_L32_ADDR_GET(x)           (((x) & MAC_PCU_BSSID2_L32_ADDR_MASK) >> MAC_PCU_BSSID2_L32_ADDR_LSB)
-#define MAC_PCU_BSSID2_L32_ADDR_SET(x)           (((x) << MAC_PCU_BSSID2_L32_ADDR_LSB) & MAC_PCU_BSSID2_L32_ADDR_MASK)
-
-#define MAC_PCU_BSSID2_U16_ADDRESS               0x000083a0
-#define MAC_PCU_BSSID2_U16_OFFSET                0x000003a0
-#define MAC_PCU_BSSID2_U16_ENABLE_MSB            16
-#define MAC_PCU_BSSID2_U16_ENABLE_LSB            16
-#define MAC_PCU_BSSID2_U16_ENABLE_MASK           0x00010000
-#define MAC_PCU_BSSID2_U16_ENABLE_GET(x)         (((x) & MAC_PCU_BSSID2_U16_ENABLE_MASK) >> MAC_PCU_BSSID2_U16_ENABLE_LSB)
-#define MAC_PCU_BSSID2_U16_ENABLE_SET(x)         (((x) << MAC_PCU_BSSID2_U16_ENABLE_LSB) & MAC_PCU_BSSID2_U16_ENABLE_MASK)
-#define MAC_PCU_BSSID2_U16_ADDR_MSB              15
-#define MAC_PCU_BSSID2_U16_ADDR_LSB              0
-#define MAC_PCU_BSSID2_U16_ADDR_MASK             0x0000ffff
-#define MAC_PCU_BSSID2_U16_ADDR_GET(x)           (((x) & MAC_PCU_BSSID2_U16_ADDR_MASK) >> MAC_PCU_BSSID2_U16_ADDR_LSB)
-#define MAC_PCU_BSSID2_U16_ADDR_SET(x)           (((x) << MAC_PCU_BSSID2_U16_ADDR_LSB) & MAC_PCU_BSSID2_U16_ADDR_MASK)
-
-#define MAC_PCU_TSF1_STATUS_L32_ADDRESS          0x000083a4
-#define MAC_PCU_TSF1_STATUS_L32_OFFSET           0x000003a4
-#define MAC_PCU_TSF1_STATUS_L32_VALUE_MSB        31
-#define MAC_PCU_TSF1_STATUS_L32_VALUE_LSB        0
-#define MAC_PCU_TSF1_STATUS_L32_VALUE_MASK       0xffffffff
-#define MAC_PCU_TSF1_STATUS_L32_VALUE_GET(x)     (((x) & MAC_PCU_TSF1_STATUS_L32_VALUE_MASK) >> MAC_PCU_TSF1_STATUS_L32_VALUE_LSB)
-#define MAC_PCU_TSF1_STATUS_L32_VALUE_SET(x)     (((x) << MAC_PCU_TSF1_STATUS_L32_VALUE_LSB) & MAC_PCU_TSF1_STATUS_L32_VALUE_MASK)
-
-#define MAC_PCU_TSF1_STATUS_U32_ADDRESS          0x000083a8
-#define MAC_PCU_TSF1_STATUS_U32_OFFSET           0x000003a8
-#define MAC_PCU_TSF1_STATUS_U32_VALUE_MSB        31
-#define MAC_PCU_TSF1_STATUS_U32_VALUE_LSB        0
-#define MAC_PCU_TSF1_STATUS_U32_VALUE_MASK       0xffffffff
-#define MAC_PCU_TSF1_STATUS_U32_VALUE_GET(x)     (((x) & MAC_PCU_TSF1_STATUS_U32_VALUE_MASK) >> MAC_PCU_TSF1_STATUS_U32_VALUE_LSB)
-#define MAC_PCU_TSF1_STATUS_U32_VALUE_SET(x)     (((x) << MAC_PCU_TSF1_STATUS_U32_VALUE_LSB) & MAC_PCU_TSF1_STATUS_U32_VALUE_MASK)
-
-#define MAC_PCU_TSF2_STATUS_L32_ADDRESS          0x000083ac
-#define MAC_PCU_TSF2_STATUS_L32_OFFSET           0x000003ac
-#define MAC_PCU_TSF2_STATUS_L32_VALUE_MSB        31
-#define MAC_PCU_TSF2_STATUS_L32_VALUE_LSB        0
-#define MAC_PCU_TSF2_STATUS_L32_VALUE_MASK       0xffffffff
-#define MAC_PCU_TSF2_STATUS_L32_VALUE_GET(x)     (((x) & MAC_PCU_TSF2_STATUS_L32_VALUE_MASK) >> MAC_PCU_TSF2_STATUS_L32_VALUE_LSB)
-#define MAC_PCU_TSF2_STATUS_L32_VALUE_SET(x)     (((x) << MAC_PCU_TSF2_STATUS_L32_VALUE_LSB) & MAC_PCU_TSF2_STATUS_L32_VALUE_MASK)
-
-#define MAC_PCU_TSF2_STATUS_U32_ADDRESS          0x000083b0
-#define MAC_PCU_TSF2_STATUS_U32_OFFSET           0x000003b0
-#define MAC_PCU_TSF2_STATUS_U32_VALUE_MSB        31
-#define MAC_PCU_TSF2_STATUS_U32_VALUE_LSB        0
-#define MAC_PCU_TSF2_STATUS_U32_VALUE_MASK       0xffffffff
-#define MAC_PCU_TSF2_STATUS_U32_VALUE_GET(x)     (((x) & MAC_PCU_TSF2_STATUS_U32_VALUE_MASK) >> MAC_PCU_TSF2_STATUS_U32_VALUE_LSB)
-#define MAC_PCU_TSF2_STATUS_U32_VALUE_SET(x)     (((x) << MAC_PCU_TSF2_STATUS_U32_VALUE_LSB) & MAC_PCU_TSF2_STATUS_U32_VALUE_MASK)
-
-#define MAC_PCU_TXBUF_BA_ADDRESS                 0x00008400
-#define MAC_PCU_TXBUF_BA_OFFSET                  0x00000400
-#define MAC_PCU_TXBUF_BA_DATA_MSB                31
-#define MAC_PCU_TXBUF_BA_DATA_LSB                0
-#define MAC_PCU_TXBUF_BA_DATA_MASK               0xffffffff
-#define MAC_PCU_TXBUF_BA_DATA_GET(x)             (((x) & MAC_PCU_TXBUF_BA_DATA_MASK) >> MAC_PCU_TXBUF_BA_DATA_LSB)
-#define MAC_PCU_TXBUF_BA_DATA_SET(x)             (((x) << MAC_PCU_TXBUF_BA_DATA_LSB) & MAC_PCU_TXBUF_BA_DATA_MASK)
-
-#define MAC_PCU_KEY_CACHE_1_ADDRESS              0x00008800
-#define MAC_PCU_KEY_CACHE_1_OFFSET               0x00000800
-#define MAC_PCU_KEY_CACHE_1_DATA_MSB             31
-#define MAC_PCU_KEY_CACHE_1_DATA_LSB             0
-#define MAC_PCU_KEY_CACHE_1_DATA_MASK            0xffffffff
-#define MAC_PCU_KEY_CACHE_1_DATA_GET(x)          (((x) & MAC_PCU_KEY_CACHE_1_DATA_MASK) >> MAC_PCU_KEY_CACHE_1_DATA_LSB)
-#define MAC_PCU_KEY_CACHE_1_DATA_SET(x)          (((x) << MAC_PCU_KEY_CACHE_1_DATA_LSB) & MAC_PCU_KEY_CACHE_1_DATA_MASK)
-
-#define MAC_PCU_BASEBAND_0_ADDRESS               0x00009800
-#define MAC_PCU_BASEBAND_0_OFFSET                0x00001800
-#define MAC_PCU_BASEBAND_0_DATA_MSB              31
-#define MAC_PCU_BASEBAND_0_DATA_LSB              0
-#define MAC_PCU_BASEBAND_0_DATA_MASK             0xffffffff
-#define MAC_PCU_BASEBAND_0_DATA_GET(x)           (((x) & MAC_PCU_BASEBAND_0_DATA_MASK) >> MAC_PCU_BASEBAND_0_DATA_LSB)
-#define MAC_PCU_BASEBAND_0_DATA_SET(x)           (((x) << MAC_PCU_BASEBAND_0_DATA_LSB) & MAC_PCU_BASEBAND_0_DATA_MASK)
-
-#define MAC_PCU_BASEBAND_1_ADDRESS               0x0000a000
-#define MAC_PCU_BASEBAND_1_OFFSET                0x00002000
-#define MAC_PCU_BASEBAND_1_DATA_MSB              31
-#define MAC_PCU_BASEBAND_1_DATA_LSB              0
-#define MAC_PCU_BASEBAND_1_DATA_MASK             0xffffffff
-#define MAC_PCU_BASEBAND_1_DATA_GET(x)           (((x) & MAC_PCU_BASEBAND_1_DATA_MASK) >> MAC_PCU_BASEBAND_1_DATA_LSB)
-#define MAC_PCU_BASEBAND_1_DATA_SET(x)           (((x) << MAC_PCU_BASEBAND_1_DATA_LSB) & MAC_PCU_BASEBAND_1_DATA_MASK)
-
-#define MAC_PCU_BASEBAND_2_ADDRESS               0x0000c000
-#define MAC_PCU_BASEBAND_2_OFFSET                0x00004000
-#define MAC_PCU_BASEBAND_2_DATA_MSB              31
-#define MAC_PCU_BASEBAND_2_DATA_LSB              0
-#define MAC_PCU_BASEBAND_2_DATA_MASK             0xffffffff
-#define MAC_PCU_BASEBAND_2_DATA_GET(x)           (((x) & MAC_PCU_BASEBAND_2_DATA_MASK) >> MAC_PCU_BASEBAND_2_DATA_LSB)
-#define MAC_PCU_BASEBAND_2_DATA_SET(x)           (((x) << MAC_PCU_BASEBAND_2_DATA_LSB) & MAC_PCU_BASEBAND_2_DATA_MASK)
-
-#define MAC_PCU_BASEBAND_3_ADDRESS               0x0000d000
-#define MAC_PCU_BASEBAND_3_OFFSET                0x00005000
-#define MAC_PCU_BASEBAND_3_DATA_MSB              31
-#define MAC_PCU_BASEBAND_3_DATA_LSB              0
-#define MAC_PCU_BASEBAND_3_DATA_MASK             0xffffffff
-#define MAC_PCU_BASEBAND_3_DATA_GET(x)           (((x) & MAC_PCU_BASEBAND_3_DATA_MASK) >> MAC_PCU_BASEBAND_3_DATA_LSB)
-#define MAC_PCU_BASEBAND_3_DATA_SET(x)           (((x) << MAC_PCU_BASEBAND_3_DATA_LSB) & MAC_PCU_BASEBAND_3_DATA_MASK)
-
-#define MAC_PCU_BUF_ADDRESS                      0x0000e000
-#define MAC_PCU_BUF_OFFSET                       0x00006000
-#define MAC_PCU_BUF_DATA_MSB                     31
-#define MAC_PCU_BUF_DATA_LSB                     0
-#define MAC_PCU_BUF_DATA_MASK                    0xffffffff
-#define MAC_PCU_BUF_DATA_GET(x)                  (((x) & MAC_PCU_BUF_DATA_MASK) >> MAC_PCU_BUF_DATA_LSB)
-#define MAC_PCU_BUF_DATA_SET(x)                  (((x) << MAC_PCU_BUF_DATA_LSB) & MAC_PCU_BUF_DATA_MASK)
-
-
-#ifndef __ASSEMBLER__
-
-typedef struct mac_pcu_reg_s {
-  volatile unsigned int mac_pcu_sta_addr_l32;
-  volatile unsigned int mac_pcu_sta_addr_u16;
-  volatile unsigned int mac_pcu_bssid_l32;
-  volatile unsigned int mac_pcu_bssid_u16;
-  volatile unsigned int mac_pcu_bcn_rssi_ave;
-  volatile unsigned int mac_pcu_ack_cts_timeout;
-  volatile unsigned int mac_pcu_bcn_rssi_ctl;
-  volatile unsigned int mac_pcu_usec_latency;
-  volatile unsigned int pcu_max_cfp_dur;
-  volatile unsigned int mac_pcu_rx_filter;
-  volatile unsigned int mac_pcu_mcast_filter_l32;
-  volatile unsigned int mac_pcu_mcast_filter_u32;
-  volatile unsigned int mac_pcu_diag_sw;
-  volatile unsigned int mac_pcu_tst_addac;
-  volatile unsigned int mac_pcu_def_antenna;
-  volatile unsigned int mac_pcu_aes_mute_mask_0;
-  volatile unsigned int mac_pcu_aes_mute_mask_1;
-  volatile unsigned int mac_pcu_gated_clks;
-  volatile unsigned int mac_pcu_obs_bus_2;
-  volatile unsigned int mac_pcu_obs_bus_1;
-  volatile unsigned int mac_pcu_dym_mimo_pwr_save;
-  volatile unsigned int mac_pcu_last_beacon_tsf;
-  volatile unsigned int mac_pcu_nav;
-  volatile unsigned int mac_pcu_rts_success_cnt;
-  volatile unsigned int mac_pcu_rts_fail_cnt;
-  volatile unsigned int mac_pcu_ack_fail_cnt;
-  volatile unsigned int mac_pcu_fcs_fail_cnt;
-  volatile unsigned int mac_pcu_beacon_cnt;
-  volatile unsigned int mac_pcu_xrmode;
-  volatile unsigned int mac_pcu_xrdel;
-  volatile unsigned int mac_pcu_xrto;
-  volatile unsigned int mac_pcu_xrcrp;
-  volatile unsigned int mac_pcu_xrstmp;
-  volatile unsigned int mac_pcu_addr1_mask_l32;
-  volatile unsigned int mac_pcu_addr1_mask_u16;
-  volatile unsigned int mac_pcu_tpc;
-  volatile unsigned int mac_pcu_tx_frame_cnt;
-  volatile unsigned int mac_pcu_rx_frame_cnt;
-  volatile unsigned int mac_pcu_rx_clear_cnt;
-  volatile unsigned int mac_pcu_cycle_cnt;
-  volatile unsigned int mac_pcu_quiet_time_1;
-  volatile unsigned int mac_pcu_quiet_time_2;
-  volatile unsigned int mac_pcu_qos_no_ack;
-  volatile unsigned int mac_pcu_phy_error_mask;
-  volatile unsigned int mac_pcu_xrlat;
-  volatile unsigned int mac_pcu_rxbuf;
-  volatile unsigned int mac_pcu_mic_qos_control;
-  volatile unsigned int mac_pcu_mic_qos_select;
-  volatile unsigned int mac_pcu_misc_mode;
-  volatile unsigned int mac_pcu_filter_ofdm_cnt;
-  volatile unsigned int mac_pcu_filter_cck_cnt;
-  volatile unsigned int mac_pcu_phy_err_cnt_1;
-  volatile unsigned int mac_pcu_phy_err_cnt_1_mask;
-  volatile unsigned int mac_pcu_phy_err_cnt_2;
-  volatile unsigned int mac_pcu_phy_err_cnt_2_mask;
-  volatile unsigned int mac_pcu_tsf_threshold;
-  volatile unsigned int mac_pcu_phy_error_eifs_mask;
-  volatile unsigned int mac_pcu_phy_err_cnt_3;
-  volatile unsigned int mac_pcu_phy_err_cnt_3_mask;
-  volatile unsigned int mac_pcu_bluetooth_mode;
-  volatile unsigned int mac_pcu_bluetooth_weights;
-  volatile unsigned int mac_pcu_bluetooth_mode2;
-  volatile unsigned int mac_pcu_txsifs;
-  volatile unsigned int mac_pcu_txop_x;
-  volatile unsigned int mac_pcu_txop_0_3;
-  volatile unsigned int mac_pcu_txop_4_7;
-  volatile unsigned int mac_pcu_txop_8_11;
-  volatile unsigned int mac_pcu_txop_12_15;
-  volatile unsigned int mac_pcu_logic_analyzer;
-  volatile unsigned int mac_pcu_logic_analyzer_32l;
-  volatile unsigned int mac_pcu_logic_analyzer_16u;
-  volatile unsigned int mac_pcu_phy_err_cnt_mask_cont;
-  volatile unsigned int mac_pcu_azimuth_mode;
-  volatile unsigned int mac_pcu_20_40_mode;
-  volatile unsigned int mac_pcu_rx_clear_diff_cnt;
-  volatile unsigned int mac_pcu_self_gen_antenna_mask;
-  volatile unsigned int mac_pcu_ba_bar_control;
-  volatile unsigned int mac_pcu_legacy_plcp_spoof;
-  volatile unsigned int mac_pcu_phy_error_mask_cont;
-  volatile unsigned int mac_pcu_tx_timer;
-  volatile unsigned int mac_pcu_txbuf_ctrl;
-  volatile unsigned int mac_pcu_misc_mode2;
-  volatile unsigned int mac_pcu_alt_aes_mute_mask;
-  volatile unsigned int mac_pcu_azimuth_time_stamp;
-  volatile unsigned int mac_pcu_max_cfp_dur;
-  volatile unsigned int mac_pcu_hcf_timeout;
-  volatile unsigned int mac_pcu_bluetooth_weights2;
-  volatile unsigned int mac_pcu_bluetooth_tsf_bt_active;
-  volatile unsigned int mac_pcu_bluetooth_tsf_bt_priority;
-  volatile unsigned int mac_pcu_bluetooth_mode3;
-  volatile unsigned int mac_pcu_bluetooth_mode4;
-  unsigned char pad0[148]; /* pad to 0x200 */
-  volatile unsigned int mac_pcu_bt_bt[64];
-  volatile unsigned int mac_pcu_bt_bt_async;
-  volatile unsigned int mac_pcu_bt_wl_1;
-  volatile unsigned int mac_pcu_bt_wl_2;
-  volatile unsigned int mac_pcu_bt_wl_3;
-  volatile unsigned int mac_pcu_bt_wl_4;
-  volatile unsigned int mac_pcu_coex_epta;
-  volatile unsigned int mac_pcu_coex_lnamaxgain1;
-  volatile unsigned int mac_pcu_coex_lnamaxgain2;
-  volatile unsigned int mac_pcu_coex_lnamaxgain3;
-  volatile unsigned int mac_pcu_coex_lnamaxgain4;
-  volatile unsigned int mac_pcu_basic_rate_set0;
-  volatile unsigned int mac_pcu_basic_rate_set1;
-  volatile unsigned int mac_pcu_basic_rate_set2;
-  volatile unsigned int mac_pcu_basic_rate_set3;
-  volatile unsigned int mac_pcu_rx_int_status0;
-  volatile unsigned int mac_pcu_rx_int_status1;
-  volatile unsigned int mac_pcu_rx_int_status2;
-  volatile unsigned int mac_pcu_rx_int_status3;
-  volatile unsigned int ht_half_gi_rate1;
-  volatile unsigned int ht_half_gi_rate2;
-  volatile unsigned int ht_full_gi_rate1;
-  volatile unsigned int ht_full_gi_rate2;
-  volatile unsigned int legacy_rate1;
-  volatile unsigned int legacy_rate2;
-  volatile unsigned int legacy_rate3;
-  volatile unsigned int rx_int_filter;
-  volatile unsigned int rx_int_overflow;
-  volatile unsigned int rx_filter_thresh;
-  volatile unsigned int rx_filter_thresh1;
-  volatile unsigned int rx_priority_thresh0;
-  volatile unsigned int rx_priority_thresh1;
-  volatile unsigned int rx_priority_thresh2;
-  volatile unsigned int rx_priority_thresh3;
-  volatile unsigned int rx_priority_offset0;
-  volatile unsigned int rx_priority_offset1;
-  volatile unsigned int rx_priority_offset2;
-  volatile unsigned int rx_priority_offset3;
-  volatile unsigned int rx_priority_offset4;
-  volatile unsigned int rx_priority_offset5;
-  volatile unsigned int mac_pcu_bssid2_l32;
-  volatile unsigned int mac_pcu_bssid2_u16;
-  volatile unsigned int mac_pcu_tsf1_status_l32;
-  volatile unsigned int mac_pcu_tsf1_status_u32;
-  volatile unsigned int mac_pcu_tsf2_status_l32;
-  volatile unsigned int mac_pcu_tsf2_status_u32;
-  unsigned char pad1[76]; /* pad to 0x400 */
-  volatile unsigned int mac_pcu_txbuf_ba[64];
-  unsigned char pad2[768]; /* pad to 0x800 */
-  volatile unsigned int mac_pcu_key_cache_1[256];
-  unsigned char pad3[3072]; /* pad to 0x1800 */
-  volatile unsigned int mac_pcu_baseband_0[512];
-  volatile unsigned int mac_pcu_baseband_1[2048];
-  volatile unsigned int mac_pcu_baseband_2[1024];
-  volatile unsigned int mac_pcu_baseband_3[1024];
-  volatile unsigned int mac_pcu_buf[512];
-} mac_pcu_reg_t;
-
-#endif /* __ASSEMBLER__ */
-
-#endif /* _MAC_PCU_H_ */
index 3af562156f6e0a1bac114cb2277c1defc1b1a08b..109f24e10a650a7a8021fc0b59da817897f4dc82 100644 (file)
 //===================================================================
 
 
-#ifdef WLAN_HEADERS
-
 #include "mbox_wlan_host_reg.h"
-
-
-#ifndef BT_HEADERS
-
-
-
-#endif
-#endif
-
-
-
index cc67585e2e8bf4979b281af5d6870d8f526c3aa1..72fa483450d611e27d1195d1c386b47abe8cd5a3 100644 (file)
 //===================================================================
 
 
-#ifdef WLAN_HEADERS
-
 #include "mbox_wlan_reg.h"
 
-
 #ifndef BT_HEADERS
 
 #define MBOX_FIFO_ADDRESS WLAN_MBOX_FIFO_ADDRESS
 #define HOST_IF_WINDOW_DATA_GET(x) WLAN_HOST_IF_WINDOW_DATA_GET(x)
 #define HOST_IF_WINDOW_DATA_SET(x) WLAN_HOST_IF_WINDOW_DATA_SET(x)
 
-
-#endif
 #endif
-
-
-
index 60855021c2b06ccbcd9e9bd628e81c273e0a2054..038d0d0192731b3096f38ee6ffa9df098438e00b 100644 (file)
 #define CIS_WINDOW_DATA_SET(x)                   (((x) << CIS_WINDOW_DATA_LSB) & CIS_WINDOW_DATA_MASK)
 
 
-#ifndef __ASSEMBLER__
-
-typedef struct mbox_wlan_host_reg_reg_s {
-  unsigned char pad0[1024]; /* pad to 0x400 */
-  volatile unsigned char host_int_status;
-  volatile unsigned char cpu_int_status;
-  volatile unsigned char error_int_status;
-  volatile unsigned char counter_int_status;
-  volatile unsigned char mbox_frame;
-  volatile unsigned char rx_lookahead_valid;
-  volatile unsigned char host_int_status2;
-  volatile unsigned char gmbox_rx_avail;
-  volatile unsigned char rx_lookahead0[4];
-  volatile unsigned char rx_lookahead1[4];
-  volatile unsigned char rx_lookahead2[4];
-  volatile unsigned char rx_lookahead3[4];
-  volatile unsigned char int_status_enable;
-  volatile unsigned char cpu_int_status_enable;
-  volatile unsigned char error_status_enable;
-  volatile unsigned char counter_int_status_enable;
-  unsigned char pad1[4]; /* pad to 0x420 */
-  volatile unsigned char count[8];
-  unsigned char pad2[24]; /* pad to 0x440 */
-  volatile unsigned char count_dec[32];
-  volatile unsigned char scratch[8];
-  volatile unsigned char fifo_timeout;
-  volatile unsigned char fifo_timeout_enable;
-  volatile unsigned char disable_sleep;
-  unsigned char pad3[5]; /* pad to 0x470 */
-  volatile unsigned char local_bus;
-  unsigned char pad4[1]; /* pad to 0x472 */
-  volatile unsigned char int_wlan;
-  unsigned char pad5[1]; /* pad to 0x474 */
-  volatile unsigned char window_data[4];
-  volatile unsigned char window_write_addr[4];
-  volatile unsigned char window_read_addr[4];
-  volatile unsigned char host_ctrl_spi_config;
-  volatile unsigned char host_ctrl_spi_status;
-  volatile unsigned char non_assoc_sleep_en;
-  volatile unsigned char cpu_dbg_sel;
-  volatile unsigned char cpu_dbg[4];
-  volatile unsigned char int_status2_enable;
-  unsigned char pad6[7]; /* pad to 0x490 */
-  volatile unsigned char gmbox_rx_lookahead[8];
-  volatile unsigned char gmbox_rx_lookahead_mux;
-  unsigned char pad7[359]; /* pad to 0x600 */
-  volatile unsigned char cis_window[512];
-} mbox_wlan_host_reg_reg_t;
-
-#endif /* __ASSEMBLER__ */
-
 #endif /* _MBOX_WLAN_HOST_REG_H_ */
index e00270fc14509cd37dba9d13e39d216ef64dc329..f5167b9ae8d093241e49e790d68b911216f17a09 100644 (file)
 #define WLAN_HOST_IF_WINDOW_DATA_GET(x)          (((x) & WLAN_HOST_IF_WINDOW_DATA_MASK) >> WLAN_HOST_IF_WINDOW_DATA_LSB)
 #define WLAN_HOST_IF_WINDOW_DATA_SET(x)          (((x) << WLAN_HOST_IF_WINDOW_DATA_LSB) & WLAN_HOST_IF_WINDOW_DATA_MASK)
 
-
-#ifndef __ASSEMBLER__
-
-typedef struct mbox_wlan_reg_reg_s {
-  volatile unsigned int wlan_mbox_fifo[4];
-  volatile unsigned int wlan_mbox_fifo_status;
-  volatile unsigned int wlan_mbox_dma_policy;
-  volatile unsigned int wlan_mbox0_dma_rx_descriptor_base;
-  volatile unsigned int wlan_mbox0_dma_rx_control;
-  volatile unsigned int wlan_mbox0_dma_tx_descriptor_base;
-  volatile unsigned int wlan_mbox0_dma_tx_control;
-  volatile unsigned int wlan_mbox1_dma_rx_descriptor_base;
-  volatile unsigned int wlan_mbox1_dma_rx_control;
-  volatile unsigned int wlan_mbox1_dma_tx_descriptor_base;
-  volatile unsigned int wlan_mbox1_dma_tx_control;
-  volatile unsigned int wlan_mbox2_dma_rx_descriptor_base;
-  volatile unsigned int wlan_mbox2_dma_rx_control;
-  volatile unsigned int wlan_mbox2_dma_tx_descriptor_base;
-  volatile unsigned int wlan_mbox2_dma_tx_control;
-  volatile unsigned int wlan_mbox3_dma_rx_descriptor_base;
-  volatile unsigned int wlan_mbox3_dma_rx_control;
-  volatile unsigned int wlan_mbox3_dma_tx_descriptor_base;
-  volatile unsigned int wlan_mbox3_dma_tx_control;
-  volatile unsigned int wlan_mbox_int_status;
-  volatile unsigned int wlan_mbox_int_enable;
-  volatile unsigned int wlan_int_host;
-  unsigned char pad0[28]; /* pad to 0x80 */
-  volatile unsigned int wlan_local_count[8];
-  volatile unsigned int wlan_count_inc[8];
-  volatile unsigned int wlan_local_scratch[8];
-  volatile unsigned int wlan_use_local_bus;
-  volatile unsigned int wlan_sdio_config;
-  volatile unsigned int wlan_mbox_debug;
-  volatile unsigned int wlan_mbox_fifo_reset;
-  volatile unsigned int wlan_mbox_txfifo_pop[4];
-  volatile unsigned int wlan_mbox_rxfifo_pop[4];
-  volatile unsigned int wlan_sdio_debug;
-  volatile unsigned int wlan_gmbox0_dma_rx_descriptor_base;
-  volatile unsigned int wlan_gmbox0_dma_rx_control;
-  volatile unsigned int wlan_gmbox0_dma_tx_descriptor_base;
-  volatile unsigned int wlan_gmbox0_dma_tx_control;
-  volatile unsigned int wlan_gmbox_int_status;
-  volatile unsigned int wlan_gmbox_int_enable;
-  unsigned char pad1[7892]; /* pad to 0x2000 */
-  volatile unsigned int wlan_host_if_window[2048];
-} mbox_wlan_reg_reg_t;
-
-#endif /* __ASSEMBLER__ */
-
 #endif /* _MBOX_WLAN_REG_H_ */
diff --git a/drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/rdma_reg.h b/drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/rdma_reg.h
deleted file mode 100644 (file)
index 56ffda5..0000000
+++ /dev/null
@@ -1,564 +0,0 @@
-// ------------------------------------------------------------------
-// Copyright (c) 2004-2010 Atheros Corporation.  All rights reserved.
-// 
-//
-// Permission to use, copy, modify, and/or distribute this software for any
-// purpose with or without fee is hereby granted, provided that the above
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-//
-//
-// ------------------------------------------------------------------
-//===================================================================
-// Author(s): ="Atheros"
-//===================================================================
-
-
-#ifndef _RDMA_REG_REG_H_
-#define _RDMA_REG_REG_H_
-
-#define DMA_CONFIG_ADDRESS                       0x00000000
-#define DMA_CONFIG_OFFSET                        0x00000000
-#define DMA_CONFIG_WLBB_PWD_EN_MSB               4
-#define DMA_CONFIG_WLBB_PWD_EN_LSB               4
-#define DMA_CONFIG_WLBB_PWD_EN_MASK              0x00000010
-#define DMA_CONFIG_WLBB_PWD_EN_GET(x)            (((x) & DMA_CONFIG_WLBB_PWD_EN_MASK) >> DMA_CONFIG_WLBB_PWD_EN_LSB)
-#define DMA_CONFIG_WLBB_PWD_EN_SET(x)            (((x) << DMA_CONFIG_WLBB_PWD_EN_LSB) & DMA_CONFIG_WLBB_PWD_EN_MASK)
-#define DMA_CONFIG_WLMAC_PWD_EN_MSB              3
-#define DMA_CONFIG_WLMAC_PWD_EN_LSB              3
-#define DMA_CONFIG_WLMAC_PWD_EN_MASK             0x00000008
-#define DMA_CONFIG_WLMAC_PWD_EN_GET(x)           (((x) & DMA_CONFIG_WLMAC_PWD_EN_MASK) >> DMA_CONFIG_WLMAC_PWD_EN_LSB)
-#define DMA_CONFIG_WLMAC_PWD_EN_SET(x)           (((x) << DMA_CONFIG_WLMAC_PWD_EN_LSB) & DMA_CONFIG_WLMAC_PWD_EN_MASK)
-#define DMA_CONFIG_ENABLE_RETENTION_MSB          2
-#define DMA_CONFIG_ENABLE_RETENTION_LSB          2
-#define DMA_CONFIG_ENABLE_RETENTION_MASK         0x00000004
-#define DMA_CONFIG_ENABLE_RETENTION_GET(x)       (((x) & DMA_CONFIG_ENABLE_RETENTION_MASK) >> DMA_CONFIG_ENABLE_RETENTION_LSB)
-#define DMA_CONFIG_ENABLE_RETENTION_SET(x)       (((x) << DMA_CONFIG_ENABLE_RETENTION_LSB) & DMA_CONFIG_ENABLE_RETENTION_MASK)
-#define DMA_CONFIG_RTC_PRIORITY_MSB              1
-#define DMA_CONFIG_RTC_PRIORITY_LSB              1
-#define DMA_CONFIG_RTC_PRIORITY_MASK             0x00000002
-#define DMA_CONFIG_RTC_PRIORITY_GET(x)           (((x) & DMA_CONFIG_RTC_PRIORITY_MASK) >> DMA_CONFIG_RTC_PRIORITY_LSB)
-#define DMA_CONFIG_RTC_PRIORITY_SET(x)           (((x) << DMA_CONFIG_RTC_PRIORITY_LSB) & DMA_CONFIG_RTC_PRIORITY_MASK)
-#define DMA_CONFIG_DMA_TYPE_MSB                  0
-#define DMA_CONFIG_DMA_TYPE_LSB                  0
-#define DMA_CONFIG_DMA_TYPE_MASK                 0x00000001
-#define DMA_CONFIG_DMA_TYPE_GET(x)               (((x) & DMA_CONFIG_DMA_TYPE_MASK) >> DMA_CONFIG_DMA_TYPE_LSB)
-#define DMA_CONFIG_DMA_TYPE_SET(x)               (((x) << DMA_CONFIG_DMA_TYPE_LSB) & DMA_CONFIG_DMA_TYPE_MASK)
-
-#define DMA_CONTROL_ADDRESS                      0x00000004
-#define DMA_CONTROL_OFFSET                       0x00000004
-#define DMA_CONTROL_START_MSB                    1
-#define DMA_CONTROL_START_LSB                    1
-#define DMA_CONTROL_START_MASK                   0x00000002
-#define DMA_CONTROL_START_GET(x)                 (((x) & DMA_CONTROL_START_MASK) >> DMA_CONTROL_START_LSB)
-#define DMA_CONTROL_START_SET(x)                 (((x) << DMA_CONTROL_START_LSB) & DMA_CONTROL_START_MASK)
-#define DMA_CONTROL_STOP_MSB                     0
-#define DMA_CONTROL_STOP_LSB                     0
-#define DMA_CONTROL_STOP_MASK                    0x00000001
-#define DMA_CONTROL_STOP_GET(x)                  (((x) & DMA_CONTROL_STOP_MASK) >> DMA_CONTROL_STOP_LSB)
-#define DMA_CONTROL_STOP_SET(x)                  (((x) << DMA_CONTROL_STOP_LSB) & DMA_CONTROL_STOP_MASK)
-
-#define DMA_SRC_ADDRESS                          0x00000008
-#define DMA_SRC_OFFSET                           0x00000008
-#define DMA_SRC_ADDR_MSB                         31
-#define DMA_SRC_ADDR_LSB                         2
-#define DMA_SRC_ADDR_MASK                        0xfffffffc
-#define DMA_SRC_ADDR_GET(x)                      (((x) & DMA_SRC_ADDR_MASK) >> DMA_SRC_ADDR_LSB)
-#define DMA_SRC_ADDR_SET(x)                      (((x) << DMA_SRC_ADDR_LSB) & DMA_SRC_ADDR_MASK)
-
-#define DMA_DEST_ADDRESS                         0x0000000c
-#define DMA_DEST_OFFSET                          0x0000000c
-#define DMA_DEST_ADDR_MSB                        31
-#define DMA_DEST_ADDR_LSB                        2
-#define DMA_DEST_ADDR_MASK                       0xfffffffc
-#define DMA_DEST_ADDR_GET(x)                     (((x) & DMA_DEST_ADDR_MASK) >> DMA_DEST_ADDR_LSB)
-#define DMA_DEST_ADDR_SET(x)                     (((x) << DMA_DEST_ADDR_LSB) & DMA_DEST_ADDR_MASK)
-
-#define DMA_LENGTH_ADDRESS                       0x00000010
-#define DMA_LENGTH_OFFSET                        0x00000010
-#define DMA_LENGTH_WORDS_MSB                     11
-#define DMA_LENGTH_WORDS_LSB                     0
-#define DMA_LENGTH_WORDS_MASK                    0x00000fff
-#define DMA_LENGTH_WORDS_GET(x)                  (((x) & DMA_LENGTH_WORDS_MASK) >> DMA_LENGTH_WORDS_LSB)
-#define DMA_LENGTH_WORDS_SET(x)                  (((x) << DMA_LENGTH_WORDS_LSB) & DMA_LENGTH_WORDS_MASK)
-
-#define VMC_BASE_ADDRESS                         0x00000014
-#define VMC_BASE_OFFSET                          0x00000014
-#define VMC_BASE_ADDR_MSB                        31
-#define VMC_BASE_ADDR_LSB                        2
-#define VMC_BASE_ADDR_MASK                       0xfffffffc
-#define VMC_BASE_ADDR_GET(x)                     (((x) & VMC_BASE_ADDR_MASK) >> VMC_BASE_ADDR_LSB)
-#define VMC_BASE_ADDR_SET(x)                     (((x) << VMC_BASE_ADDR_LSB) & VMC_BASE_ADDR_MASK)
-
-#define INDIRECT_REG_ADDRESS                     0x00000018
-#define INDIRECT_REG_OFFSET                      0x00000018
-#define INDIRECT_REG_ID_MSB                      31
-#define INDIRECT_REG_ID_LSB                      2
-#define INDIRECT_REG_ID_MASK                     0xfffffffc
-#define INDIRECT_REG_ID_GET(x)                   (((x) & INDIRECT_REG_ID_MASK) >> INDIRECT_REG_ID_LSB)
-#define INDIRECT_REG_ID_SET(x)                   (((x) << INDIRECT_REG_ID_LSB) & INDIRECT_REG_ID_MASK)
-
-#define INDIRECT_RETURN_ADDRESS                  0x0000001c
-#define INDIRECT_RETURN_OFFSET                   0x0000001c
-#define INDIRECT_RETURN_ADDR_MSB                 31
-#define INDIRECT_RETURN_ADDR_LSB                 2
-#define INDIRECT_RETURN_ADDR_MASK                0xfffffffc
-#define INDIRECT_RETURN_ADDR_GET(x)              (((x) & INDIRECT_RETURN_ADDR_MASK) >> INDIRECT_RETURN_ADDR_LSB)
-#define INDIRECT_RETURN_ADDR_SET(x)              (((x) << INDIRECT_RETURN_ADDR_LSB) & INDIRECT_RETURN_ADDR_MASK)
-
-#define RDMA_REGION_0__ADDRESS                   0x00000020
-#define RDMA_REGION_0__OFFSET                    0x00000020
-#define RDMA_REGION_0__ADDR_MSB                  31
-#define RDMA_REGION_0__ADDR_LSB                  13
-#define RDMA_REGION_0__ADDR_MASK                 0xffffe000
-#define RDMA_REGION_0__ADDR_GET(x)               (((x) & RDMA_REGION_0__ADDR_MASK) >> RDMA_REGION_0__ADDR_LSB)
-#define RDMA_REGION_0__ADDR_SET(x)               (((x) << RDMA_REGION_0__ADDR_LSB) & RDMA_REGION_0__ADDR_MASK)
-#define RDMA_REGION_0__LENGTH_MSB                12
-#define RDMA_REGION_0__LENGTH_LSB                2
-#define RDMA_REGION_0__LENGTH_MASK               0x00001ffc
-#define RDMA_REGION_0__LENGTH_GET(x)             (((x) & RDMA_REGION_0__LENGTH_MASK) >> RDMA_REGION_0__LENGTH_LSB)
-#define RDMA_REGION_0__LENGTH_SET(x)             (((x) << RDMA_REGION_0__LENGTH_LSB) & RDMA_REGION_0__LENGTH_MASK)
-#define RDMA_REGION_0__INDI_MSB                  1
-#define RDMA_REGION_0__INDI_LSB                  1
-#define RDMA_REGION_0__INDI_MASK                 0x00000002
-#define RDMA_REGION_0__INDI_GET(x)               (((x) & RDMA_REGION_0__INDI_MASK) >> RDMA_REGION_0__INDI_LSB)
-#define RDMA_REGION_0__INDI_SET(x)               (((x) << RDMA_REGION_0__INDI_LSB) & RDMA_REGION_0__INDI_MASK)
-#define RDMA_REGION_0__NEXT_MSB                  0
-#define RDMA_REGION_0__NEXT_LSB                  0
-#define RDMA_REGION_0__NEXT_MASK                 0x00000001
-#define RDMA_REGION_0__NEXT_GET(x)               (((x) & RDMA_REGION_0__NEXT_MASK) >> RDMA_REGION_0__NEXT_LSB)
-#define RDMA_REGION_0__NEXT_SET(x)               (((x) << RDMA_REGION_0__NEXT_LSB) & RDMA_REGION_0__NEXT_MASK)
-
-#define RDMA_REGION_1__ADDRESS                   0x00000024
-#define RDMA_REGION_1__OFFSET                    0x00000024
-#define RDMA_REGION_1__ADDR_MSB                  31
-#define RDMA_REGION_1__ADDR_LSB                  13
-#define RDMA_REGION_1__ADDR_MASK                 0xffffe000
-#define RDMA_REGION_1__ADDR_GET(x)               (((x) & RDMA_REGION_1__ADDR_MASK) >> RDMA_REGION_1__ADDR_LSB)
-#define RDMA_REGION_1__ADDR_SET(x)               (((x) << RDMA_REGION_1__ADDR_LSB) & RDMA_REGION_1__ADDR_MASK)
-#define RDMA_REGION_1__LENGTH_MSB                12
-#define RDMA_REGION_1__LENGTH_LSB                2
-#define RDMA_REGION_1__LENGTH_MASK               0x00001ffc
-#define RDMA_REGION_1__LENGTH_GET(x)             (((x) & RDMA_REGION_1__LENGTH_MASK) >> RDMA_REGION_1__LENGTH_LSB)
-#define RDMA_REGION_1__LENGTH_SET(x)             (((x) << RDMA_REGION_1__LENGTH_LSB) & RDMA_REGION_1__LENGTH_MASK)
-#define RDMA_REGION_1__INDI_MSB                  1
-#define RDMA_REGION_1__INDI_LSB                  1
-#define RDMA_REGION_1__INDI_MASK                 0x00000002
-#define RDMA_REGION_1__INDI_GET(x)               (((x) & RDMA_REGION_1__INDI_MASK) >> RDMA_REGION_1__INDI_LSB)
-#define RDMA_REGION_1__INDI_SET(x)               (((x) << RDMA_REGION_1__INDI_LSB) & RDMA_REGION_1__INDI_MASK)
-#define RDMA_REGION_1__NEXT_MSB                  0
-#define RDMA_REGION_1__NEXT_LSB                  0
-#define RDMA_REGION_1__NEXT_MASK                 0x00000001
-#define RDMA_REGION_1__NEXT_GET(x)               (((x) & RDMA_REGION_1__NEXT_MASK) >> RDMA_REGION_1__NEXT_LSB)
-#define RDMA_REGION_1__NEXT_SET(x)               (((x) << RDMA_REGION_1__NEXT_LSB) & RDMA_REGION_1__NEXT_MASK)
-
-#define RDMA_REGION_2__ADDRESS                   0x00000028
-#define RDMA_REGION_2__OFFSET                    0x00000028
-#define RDMA_REGION_2__ADDR_MSB                  31
-#define RDMA_REGION_2__ADDR_LSB                  13
-#define RDMA_REGION_2__ADDR_MASK                 0xffffe000
-#define RDMA_REGION_2__ADDR_GET(x)               (((x) & RDMA_REGION_2__ADDR_MASK) >> RDMA_REGION_2__ADDR_LSB)
-#define RDMA_REGION_2__ADDR_SET(x)               (((x) << RDMA_REGION_2__ADDR_LSB) & RDMA_REGION_2__ADDR_MASK)
-#define RDMA_REGION_2__LENGTH_MSB                12
-#define RDMA_REGION_2__LENGTH_LSB                2
-#define RDMA_REGION_2__LENGTH_MASK               0x00001ffc
-#define RDMA_REGION_2__LENGTH_GET(x)             (((x) & RDMA_REGION_2__LENGTH_MASK) >> RDMA_REGION_2__LENGTH_LSB)
-#define RDMA_REGION_2__LENGTH_SET(x)             (((x) << RDMA_REGION_2__LENGTH_LSB) & RDMA_REGION_2__LENGTH_MASK)
-#define RDMA_REGION_2__INDI_MSB                  1
-#define RDMA_REGION_2__INDI_LSB                  1
-#define RDMA_REGION_2__INDI_MASK                 0x00000002
-#define RDMA_REGION_2__INDI_GET(x)               (((x) & RDMA_REGION_2__INDI_MASK) >> RDMA_REGION_2__INDI_LSB)
-#define RDMA_REGION_2__INDI_SET(x)               (((x) << RDMA_REGION_2__INDI_LSB) & RDMA_REGION_2__INDI_MASK)
-#define RDMA_REGION_2__NEXT_MSB                  0
-#define RDMA_REGION_2__NEXT_LSB                  0
-#define RDMA_REGION_2__NEXT_MASK                 0x00000001
-#define RDMA_REGION_2__NEXT_GET(x)               (((x) & RDMA_REGION_2__NEXT_MASK) >> RDMA_REGION_2__NEXT_LSB)
-#define RDMA_REGION_2__NEXT_SET(x)               (((x) << RDMA_REGION_2__NEXT_LSB) & RDMA_REGION_2__NEXT_MASK)
-
-#define RDMA_REGION_3__ADDRESS                   0x0000002c
-#define RDMA_REGION_3__OFFSET                    0x0000002c
-#define RDMA_REGION_3__ADDR_MSB                  31
-#define RDMA_REGION_3__ADDR_LSB                  13
-#define RDMA_REGION_3__ADDR_MASK                 0xffffe000
-#define RDMA_REGION_3__ADDR_GET(x)               (((x) & RDMA_REGION_3__ADDR_MASK) >> RDMA_REGION_3__ADDR_LSB)
-#define RDMA_REGION_3__ADDR_SET(x)               (((x) << RDMA_REGION_3__ADDR_LSB) & RDMA_REGION_3__ADDR_MASK)
-#define RDMA_REGION_3__LENGTH_MSB                12
-#define RDMA_REGION_3__LENGTH_LSB                2
-#define RDMA_REGION_3__LENGTH_MASK               0x00001ffc
-#define RDMA_REGION_3__LENGTH_GET(x)             (((x) & RDMA_REGION_3__LENGTH_MASK) >> RDMA_REGION_3__LENGTH_LSB)
-#define RDMA_REGION_3__LENGTH_SET(x)             (((x) << RDMA_REGION_3__LENGTH_LSB) & RDMA_REGION_3__LENGTH_MASK)
-#define RDMA_REGION_3__INDI_MSB                  1
-#define RDMA_REGION_3__INDI_LSB                  1
-#define RDMA_REGION_3__INDI_MASK                 0x00000002
-#define RDMA_REGION_3__INDI_GET(x)               (((x) & RDMA_REGION_3__INDI_MASK) >> RDMA_REGION_3__INDI_LSB)
-#define RDMA_REGION_3__INDI_SET(x)               (((x) << RDMA_REGION_3__INDI_LSB) & RDMA_REGION_3__INDI_MASK)
-#define RDMA_REGION_3__NEXT_MSB                  0
-#define RDMA_REGION_3__NEXT_LSB                  0
-#define RDMA_REGION_3__NEXT_MASK                 0x00000001
-#define RDMA_REGION_3__NEXT_GET(x)               (((x) & RDMA_REGION_3__NEXT_MASK) >> RDMA_REGION_3__NEXT_LSB)
-#define RDMA_REGION_3__NEXT_SET(x)               (((x) << RDMA_REGION_3__NEXT_LSB) & RDMA_REGION_3__NEXT_MASK)
-
-#define RDMA_REGION_4__ADDRESS                   0x00000030
-#define RDMA_REGION_4__OFFSET                    0x00000030
-#define RDMA_REGION_4__ADDR_MSB                  31
-#define RDMA_REGION_4__ADDR_LSB                  13
-#define RDMA_REGION_4__ADDR_MASK                 0xffffe000
-#define RDMA_REGION_4__ADDR_GET(x)               (((x) & RDMA_REGION_4__ADDR_MASK) >> RDMA_REGION_4__ADDR_LSB)
-#define RDMA_REGION_4__ADDR_SET(x)               (((x) << RDMA_REGION_4__ADDR_LSB) & RDMA_REGION_4__ADDR_MASK)
-#define RDMA_REGION_4__LENGTH_MSB                12
-#define RDMA_REGION_4__LENGTH_LSB                2
-#define RDMA_REGION_4__LENGTH_MASK               0x00001ffc
-#define RDMA_REGION_4__LENGTH_GET(x)             (((x) & RDMA_REGION_4__LENGTH_MASK) >> RDMA_REGION_4__LENGTH_LSB)
-#define RDMA_REGION_4__LENGTH_SET(x)             (((x) << RDMA_REGION_4__LENGTH_LSB) & RDMA_REGION_4__LENGTH_MASK)
-#define RDMA_REGION_4__INDI_MSB                  1
-#define RDMA_REGION_4__INDI_LSB                  1
-#define RDMA_REGION_4__INDI_MASK                 0x00000002
-#define RDMA_REGION_4__INDI_GET(x)               (((x) & RDMA_REGION_4__INDI_MASK) >> RDMA_REGION_4__INDI_LSB)
-#define RDMA_REGION_4__INDI_SET(x)               (((x) << RDMA_REGION_4__INDI_LSB) & RDMA_REGION_4__INDI_MASK)
-#define RDMA_REGION_4__NEXT_MSB                  0
-#define RDMA_REGION_4__NEXT_LSB                  0
-#define RDMA_REGION_4__NEXT_MASK                 0x00000001
-#define RDMA_REGION_4__NEXT_GET(x)               (((x) & RDMA_REGION_4__NEXT_MASK) >> RDMA_REGION_4__NEXT_LSB)
-#define RDMA_REGION_4__NEXT_SET(x)               (((x) << RDMA_REGION_4__NEXT_LSB) & RDMA_REGION_4__NEXT_MASK)
-
-#define RDMA_REGION_5__ADDRESS                   0x00000034
-#define RDMA_REGION_5__OFFSET                    0x00000034
-#define RDMA_REGION_5__ADDR_MSB                  31
-#define RDMA_REGION_5__ADDR_LSB                  13
-#define RDMA_REGION_5__ADDR_MASK                 0xffffe000
-#define RDMA_REGION_5__ADDR_GET(x)               (((x) & RDMA_REGION_5__ADDR_MASK) >> RDMA_REGION_5__ADDR_LSB)
-#define RDMA_REGION_5__ADDR_SET(x)               (((x) << RDMA_REGION_5__ADDR_LSB) & RDMA_REGION_5__ADDR_MASK)
-#define RDMA_REGION_5__LENGTH_MSB                12
-#define RDMA_REGION_5__LENGTH_LSB                2
-#define RDMA_REGION_5__LENGTH_MASK               0x00001ffc
-#define RDMA_REGION_5__LENGTH_GET(x)             (((x) & RDMA_REGION_5__LENGTH_MASK) >> RDMA_REGION_5__LENGTH_LSB)
-#define RDMA_REGION_5__LENGTH_SET(x)             (((x) << RDMA_REGION_5__LENGTH_LSB) & RDMA_REGION_5__LENGTH_MASK)
-#define RDMA_REGION_5__INDI_MSB                  1
-#define RDMA_REGION_5__INDI_LSB                  1
-#define RDMA_REGION_5__INDI_MASK                 0x00000002
-#define RDMA_REGION_5__INDI_GET(x)               (((x) & RDMA_REGION_5__INDI_MASK) >> RDMA_REGION_5__INDI_LSB)
-#define RDMA_REGION_5__INDI_SET(x)               (((x) << RDMA_REGION_5__INDI_LSB) & RDMA_REGION_5__INDI_MASK)
-#define RDMA_REGION_5__NEXT_MSB                  0
-#define RDMA_REGION_5__NEXT_LSB                  0
-#define RDMA_REGION_5__NEXT_MASK                 0x00000001
-#define RDMA_REGION_5__NEXT_GET(x)               (((x) & RDMA_REGION_5__NEXT_MASK) >> RDMA_REGION_5__NEXT_LSB)
-#define RDMA_REGION_5__NEXT_SET(x)               (((x) << RDMA_REGION_5__NEXT_LSB) & RDMA_REGION_5__NEXT_MASK)
-
-#define RDMA_REGION_6__ADDRESS                   0x00000038
-#define RDMA_REGION_6__OFFSET                    0x00000038
-#define RDMA_REGION_6__ADDR_MSB                  31
-#define RDMA_REGION_6__ADDR_LSB                  13
-#define RDMA_REGION_6__ADDR_MASK                 0xffffe000
-#define RDMA_REGION_6__ADDR_GET(x)               (((x) & RDMA_REGION_6__ADDR_MASK) >> RDMA_REGION_6__ADDR_LSB)
-#define RDMA_REGION_6__ADDR_SET(x)               (((x) << RDMA_REGION_6__ADDR_LSB) & RDMA_REGION_6__ADDR_MASK)
-#define RDMA_REGION_6__LENGTH_MSB                12
-#define RDMA_REGION_6__LENGTH_LSB                2
-#define RDMA_REGION_6__LENGTH_MASK               0x00001ffc
-#define RDMA_REGION_6__LENGTH_GET(x)             (((x) & RDMA_REGION_6__LENGTH_MASK) >> RDMA_REGION_6__LENGTH_LSB)
-#define RDMA_REGION_6__LENGTH_SET(x)             (((x) << RDMA_REGION_6__LENGTH_LSB) & RDMA_REGION_6__LENGTH_MASK)
-#define RDMA_REGION_6__INDI_MSB                  1
-#define RDMA_REGION_6__INDI_LSB                  1
-#define RDMA_REGION_6__INDI_MASK                 0x00000002
-#define RDMA_REGION_6__INDI_GET(x)               (((x) & RDMA_REGION_6__INDI_MASK) >> RDMA_REGION_6__INDI_LSB)
-#define RDMA_REGION_6__INDI_SET(x)               (((x) << RDMA_REGION_6__INDI_LSB) & RDMA_REGION_6__INDI_MASK)
-#define RDMA_REGION_6__NEXT_MSB                  0
-#define RDMA_REGION_6__NEXT_LSB                  0
-#define RDMA_REGION_6__NEXT_MASK                 0x00000001
-#define RDMA_REGION_6__NEXT_GET(x)               (((x) & RDMA_REGION_6__NEXT_MASK) >> RDMA_REGION_6__NEXT_LSB)
-#define RDMA_REGION_6__NEXT_SET(x)               (((x) << RDMA_REGION_6__NEXT_LSB) & RDMA_REGION_6__NEXT_MASK)
-
-#define RDMA_REGION_7__ADDRESS                   0x0000003c
-#define RDMA_REGION_7__OFFSET                    0x0000003c
-#define RDMA_REGION_7__ADDR_MSB                  31
-#define RDMA_REGION_7__ADDR_LSB                  13
-#define RDMA_REGION_7__ADDR_MASK                 0xffffe000
-#define RDMA_REGION_7__ADDR_GET(x)               (((x) & RDMA_REGION_7__ADDR_MASK) >> RDMA_REGION_7__ADDR_LSB)
-#define RDMA_REGION_7__ADDR_SET(x)               (((x) << RDMA_REGION_7__ADDR_LSB) & RDMA_REGION_7__ADDR_MASK)
-#define RDMA_REGION_7__LENGTH_MSB                12
-#define RDMA_REGION_7__LENGTH_LSB                2
-#define RDMA_REGION_7__LENGTH_MASK               0x00001ffc
-#define RDMA_REGION_7__LENGTH_GET(x)             (((x) & RDMA_REGION_7__LENGTH_MASK) >> RDMA_REGION_7__LENGTH_LSB)
-#define RDMA_REGION_7__LENGTH_SET(x)             (((x) << RDMA_REGION_7__LENGTH_LSB) & RDMA_REGION_7__LENGTH_MASK)
-#define RDMA_REGION_7__INDI_MSB                  1
-#define RDMA_REGION_7__INDI_LSB                  1
-#define RDMA_REGION_7__INDI_MASK                 0x00000002
-#define RDMA_REGION_7__INDI_GET(x)               (((x) & RDMA_REGION_7__INDI_MASK) >> RDMA_REGION_7__INDI_LSB)
-#define RDMA_REGION_7__INDI_SET(x)               (((x) << RDMA_REGION_7__INDI_LSB) & RDMA_REGION_7__INDI_MASK)
-#define RDMA_REGION_7__NEXT_MSB                  0
-#define RDMA_REGION_7__NEXT_LSB                  0
-#define RDMA_REGION_7__NEXT_MASK                 0x00000001
-#define RDMA_REGION_7__NEXT_GET(x)               (((x) & RDMA_REGION_7__NEXT_MASK) >> RDMA_REGION_7__NEXT_LSB)
-#define RDMA_REGION_7__NEXT_SET(x)               (((x) << RDMA_REGION_7__NEXT_LSB) & RDMA_REGION_7__NEXT_MASK)
-
-#define RDMA_REGION_8__ADDRESS                   0x00000040
-#define RDMA_REGION_8__OFFSET                    0x00000040
-#define RDMA_REGION_8__ADDR_MSB                  31
-#define RDMA_REGION_8__ADDR_LSB                  13
-#define RDMA_REGION_8__ADDR_MASK                 0xffffe000
-#define RDMA_REGION_8__ADDR_GET(x)               (((x) & RDMA_REGION_8__ADDR_MASK) >> RDMA_REGION_8__ADDR_LSB)
-#define RDMA_REGION_8__ADDR_SET(x)               (((x) << RDMA_REGION_8__ADDR_LSB) & RDMA_REGION_8__ADDR_MASK)
-#define RDMA_REGION_8__LENGTH_MSB                12
-#define RDMA_REGION_8__LENGTH_LSB                2
-#define RDMA_REGION_8__LENGTH_MASK               0x00001ffc
-#define RDMA_REGION_8__LENGTH_GET(x)             (((x) & RDMA_REGION_8__LENGTH_MASK) >> RDMA_REGION_8__LENGTH_LSB)
-#define RDMA_REGION_8__LENGTH_SET(x)             (((x) << RDMA_REGION_8__LENGTH_LSB) & RDMA_REGION_8__LENGTH_MASK)
-#define RDMA_REGION_8__INDI_MSB                  1
-#define RDMA_REGION_8__INDI_LSB                  1
-#define RDMA_REGION_8__INDI_MASK                 0x00000002
-#define RDMA_REGION_8__INDI_GET(x)               (((x) & RDMA_REGION_8__INDI_MASK) >> RDMA_REGION_8__INDI_LSB)
-#define RDMA_REGION_8__INDI_SET(x)               (((x) << RDMA_REGION_8__INDI_LSB) & RDMA_REGION_8__INDI_MASK)
-#define RDMA_REGION_8__NEXT_MSB                  0
-#define RDMA_REGION_8__NEXT_LSB                  0
-#define RDMA_REGION_8__NEXT_MASK                 0x00000001
-#define RDMA_REGION_8__NEXT_GET(x)               (((x) & RDMA_REGION_8__NEXT_MASK) >> RDMA_REGION_8__NEXT_LSB)
-#define RDMA_REGION_8__NEXT_SET(x)               (((x) << RDMA_REGION_8__NEXT_LSB) & RDMA_REGION_8__NEXT_MASK)
-
-#define RDMA_REGION_9__ADDRESS                   0x00000044
-#define RDMA_REGION_9__OFFSET                    0x00000044
-#define RDMA_REGION_9__ADDR_MSB                  31
-#define RDMA_REGION_9__ADDR_LSB                  13
-#define RDMA_REGION_9__ADDR_MASK                 0xffffe000
-#define RDMA_REGION_9__ADDR_GET(x)               (((x) & RDMA_REGION_9__ADDR_MASK) >> RDMA_REGION_9__ADDR_LSB)
-#define RDMA_REGION_9__ADDR_SET(x)               (((x) << RDMA_REGION_9__ADDR_LSB) & RDMA_REGION_9__ADDR_MASK)
-#define RDMA_REGION_9__LENGTH_MSB                12
-#define RDMA_REGION_9__LENGTH_LSB                2
-#define RDMA_REGION_9__LENGTH_MASK               0x00001ffc
-#define RDMA_REGION_9__LENGTH_GET(x)             (((x) & RDMA_REGION_9__LENGTH_MASK) >> RDMA_REGION_9__LENGTH_LSB)
-#define RDMA_REGION_9__LENGTH_SET(x)             (((x) << RDMA_REGION_9__LENGTH_LSB) & RDMA_REGION_9__LENGTH_MASK)
-#define RDMA_REGION_9__INDI_MSB                  1
-#define RDMA_REGION_9__INDI_LSB                  1
-#define RDMA_REGION_9__INDI_MASK                 0x00000002
-#define RDMA_REGION_9__INDI_GET(x)               (((x) & RDMA_REGION_9__INDI_MASK) >> RDMA_REGION_9__INDI_LSB)
-#define RDMA_REGION_9__INDI_SET(x)               (((x) << RDMA_REGION_9__INDI_LSB) & RDMA_REGION_9__INDI_MASK)
-#define RDMA_REGION_9__NEXT_MSB                  0
-#define RDMA_REGION_9__NEXT_LSB                  0
-#define RDMA_REGION_9__NEXT_MASK                 0x00000001
-#define RDMA_REGION_9__NEXT_GET(x)               (((x) & RDMA_REGION_9__NEXT_MASK) >> RDMA_REGION_9__NEXT_LSB)
-#define RDMA_REGION_9__NEXT_SET(x)               (((x) << RDMA_REGION_9__NEXT_LSB) & RDMA_REGION_9__NEXT_MASK)
-
-#define RDMA_REGION_10__ADDRESS                  0x00000048
-#define RDMA_REGION_10__OFFSET                   0x00000048
-#define RDMA_REGION_10__ADDR_MSB                 31
-#define RDMA_REGION_10__ADDR_LSB                 13
-#define RDMA_REGION_10__ADDR_MASK                0xffffe000
-#define RDMA_REGION_10__ADDR_GET(x)              (((x) & RDMA_REGION_10__ADDR_MASK) >> RDMA_REGION_10__ADDR_LSB)
-#define RDMA_REGION_10__ADDR_SET(x)              (((x) << RDMA_REGION_10__ADDR_LSB) & RDMA_REGION_10__ADDR_MASK)
-#define RDMA_REGION_10__LENGTH_MSB               12
-#define RDMA_REGION_10__LENGTH_LSB               2
-#define RDMA_REGION_10__LENGTH_MASK              0x00001ffc
-#define RDMA_REGION_10__LENGTH_GET(x)            (((x) & RDMA_REGION_10__LENGTH_MASK) >> RDMA_REGION_10__LENGTH_LSB)
-#define RDMA_REGION_10__LENGTH_SET(x)            (((x) << RDMA_REGION_10__LENGTH_LSB) & RDMA_REGION_10__LENGTH_MASK)
-#define RDMA_REGION_10__INDI_MSB                 1
-#define RDMA_REGION_10__INDI_LSB                 1
-#define RDMA_REGION_10__INDI_MASK                0x00000002
-#define RDMA_REGION_10__INDI_GET(x)              (((x) & RDMA_REGION_10__INDI_MASK) >> RDMA_REGION_10__INDI_LSB)
-#define RDMA_REGION_10__INDI_SET(x)              (((x) << RDMA_REGION_10__INDI_LSB) & RDMA_REGION_10__INDI_MASK)
-#define RDMA_REGION_10__NEXT_MSB                 0
-#define RDMA_REGION_10__NEXT_LSB                 0
-#define RDMA_REGION_10__NEXT_MASK                0x00000001
-#define RDMA_REGION_10__NEXT_GET(x)              (((x) & RDMA_REGION_10__NEXT_MASK) >> RDMA_REGION_10__NEXT_LSB)
-#define RDMA_REGION_10__NEXT_SET(x)              (((x) << RDMA_REGION_10__NEXT_LSB) & RDMA_REGION_10__NEXT_MASK)
-
-#define RDMA_REGION_11__ADDRESS                  0x0000004c
-#define RDMA_REGION_11__OFFSET                   0x0000004c
-#define RDMA_REGION_11__ADDR_MSB                 31
-#define RDMA_REGION_11__ADDR_LSB                 13
-#define RDMA_REGION_11__ADDR_MASK                0xffffe000
-#define RDMA_REGION_11__ADDR_GET(x)              (((x) & RDMA_REGION_11__ADDR_MASK) >> RDMA_REGION_11__ADDR_LSB)
-#define RDMA_REGION_11__ADDR_SET(x)              (((x) << RDMA_REGION_11__ADDR_LSB) & RDMA_REGION_11__ADDR_MASK)
-#define RDMA_REGION_11__LENGTH_MSB               12
-#define RDMA_REGION_11__LENGTH_LSB               2
-#define RDMA_REGION_11__LENGTH_MASK              0x00001ffc
-#define RDMA_REGION_11__LENGTH_GET(x)            (((x) & RDMA_REGION_11__LENGTH_MASK) >> RDMA_REGION_11__LENGTH_LSB)
-#define RDMA_REGION_11__LENGTH_SET(x)            (((x) << RDMA_REGION_11__LENGTH_LSB) & RDMA_REGION_11__LENGTH_MASK)
-#define RDMA_REGION_11__INDI_MSB                 1
-#define RDMA_REGION_11__INDI_LSB                 1
-#define RDMA_REGION_11__INDI_MASK                0x00000002
-#define RDMA_REGION_11__INDI_GET(x)              (((x) & RDMA_REGION_11__INDI_MASK) >> RDMA_REGION_11__INDI_LSB)
-#define RDMA_REGION_11__INDI_SET(x)              (((x) << RDMA_REGION_11__INDI_LSB) & RDMA_REGION_11__INDI_MASK)
-#define RDMA_REGION_11__NEXT_MSB                 0
-#define RDMA_REGION_11__NEXT_LSB                 0
-#define RDMA_REGION_11__NEXT_MASK                0x00000001
-#define RDMA_REGION_11__NEXT_GET(x)              (((x) & RDMA_REGION_11__NEXT_MASK) >> RDMA_REGION_11__NEXT_LSB)
-#define RDMA_REGION_11__NEXT_SET(x)              (((x) << RDMA_REGION_11__NEXT_LSB) & RDMA_REGION_11__NEXT_MASK)
-
-#define RDMA_REGION_12__ADDRESS                  0x00000050
-#define RDMA_REGION_12__OFFSET                   0x00000050
-#define RDMA_REGION_12__ADDR_MSB                 31
-#define RDMA_REGION_12__ADDR_LSB                 13
-#define RDMA_REGION_12__ADDR_MASK                0xffffe000
-#define RDMA_REGION_12__ADDR_GET(x)              (((x) & RDMA_REGION_12__ADDR_MASK) >> RDMA_REGION_12__ADDR_LSB)
-#define RDMA_REGION_12__ADDR_SET(x)              (((x) << RDMA_REGION_12__ADDR_LSB) & RDMA_REGION_12__ADDR_MASK)
-#define RDMA_REGION_12__LENGTH_MSB               12
-#define RDMA_REGION_12__LENGTH_LSB               2
-#define RDMA_REGION_12__LENGTH_MASK              0x00001ffc
-#define RDMA_REGION_12__LENGTH_GET(x)            (((x) & RDMA_REGION_12__LENGTH_MASK) >> RDMA_REGION_12__LENGTH_LSB)
-#define RDMA_REGION_12__LENGTH_SET(x)            (((x) << RDMA_REGION_12__LENGTH_LSB) & RDMA_REGION_12__LENGTH_MASK)
-#define RDMA_REGION_12__INDI_MSB                 1
-#define RDMA_REGION_12__INDI_LSB                 1
-#define RDMA_REGION_12__INDI_MASK                0x00000002
-#define RDMA_REGION_12__INDI_GET(x)              (((x) & RDMA_REGION_12__INDI_MASK) >> RDMA_REGION_12__INDI_LSB)
-#define RDMA_REGION_12__INDI_SET(x)              (((x) << RDMA_REGION_12__INDI_LSB) & RDMA_REGION_12__INDI_MASK)
-#define RDMA_REGION_12__NEXT_MSB                 0
-#define RDMA_REGION_12__NEXT_LSB                 0
-#define RDMA_REGION_12__NEXT_MASK                0x00000001
-#define RDMA_REGION_12__NEXT_GET(x)              (((x) & RDMA_REGION_12__NEXT_MASK) >> RDMA_REGION_12__NEXT_LSB)
-#define RDMA_REGION_12__NEXT_SET(x)              (((x) << RDMA_REGION_12__NEXT_LSB) & RDMA_REGION_12__NEXT_MASK)
-
-#define RDMA_REGION_13__ADDRESS                  0x00000054
-#define RDMA_REGION_13__OFFSET                   0x00000054
-#define RDMA_REGION_13__ADDR_MSB                 31
-#define RDMA_REGION_13__ADDR_LSB                 13
-#define RDMA_REGION_13__ADDR_MASK                0xffffe000
-#define RDMA_REGION_13__ADDR_GET(x)              (((x) & RDMA_REGION_13__ADDR_MASK) >> RDMA_REGION_13__ADDR_LSB)
-#define RDMA_REGION_13__ADDR_SET(x)              (((x) << RDMA_REGION_13__ADDR_LSB) & RDMA_REGION_13__ADDR_MASK)
-#define RDMA_REGION_13__LENGTH_MSB               12
-#define RDMA_REGION_13__LENGTH_LSB               2
-#define RDMA_REGION_13__LENGTH_MASK              0x00001ffc
-#define RDMA_REGION_13__LENGTH_GET(x)            (((x) & RDMA_REGION_13__LENGTH_MASK) >> RDMA_REGION_13__LENGTH_LSB)
-#define RDMA_REGION_13__LENGTH_SET(x)            (((x) << RDMA_REGION_13__LENGTH_LSB) & RDMA_REGION_13__LENGTH_MASK)
-#define RDMA_REGION_13__INDI_MSB                 1
-#define RDMA_REGION_13__INDI_LSB                 1
-#define RDMA_REGION_13__INDI_MASK                0x00000002
-#define RDMA_REGION_13__INDI_GET(x)              (((x) & RDMA_REGION_13__INDI_MASK) >> RDMA_REGION_13__INDI_LSB)
-#define RDMA_REGION_13__INDI_SET(x)              (((x) << RDMA_REGION_13__INDI_LSB) & RDMA_REGION_13__INDI_MASK)
-#define RDMA_REGION_13__NEXT_MSB                 0
-#define RDMA_REGION_13__NEXT_LSB                 0
-#define RDMA_REGION_13__NEXT_MASK                0x00000001
-#define RDMA_REGION_13__NEXT_GET(x)              (((x) & RDMA_REGION_13__NEXT_MASK) >> RDMA_REGION_13__NEXT_LSB)
-#define RDMA_REGION_13__NEXT_SET(x)              (((x) << RDMA_REGION_13__NEXT_LSB) & RDMA_REGION_13__NEXT_MASK)
-
-#define RDMA_REGION_14__ADDRESS                  0x00000058
-#define RDMA_REGION_14__OFFSET                   0x00000058
-#define RDMA_REGION_14__ADDR_MSB                 31
-#define RDMA_REGION_14__ADDR_LSB                 13
-#define RDMA_REGION_14__ADDR_MASK                0xffffe000
-#define RDMA_REGION_14__ADDR_GET(x)              (((x) & RDMA_REGION_14__ADDR_MASK) >> RDMA_REGION_14__ADDR_LSB)
-#define RDMA_REGION_14__ADDR_SET(x)              (((x) << RDMA_REGION_14__ADDR_LSB) & RDMA_REGION_14__ADDR_MASK)
-#define RDMA_REGION_14__LENGTH_MSB               12
-#define RDMA_REGION_14__LENGTH_LSB               2
-#define RDMA_REGION_14__LENGTH_MASK              0x00001ffc
-#define RDMA_REGION_14__LENGTH_GET(x)            (((x) & RDMA_REGION_14__LENGTH_MASK) >> RDMA_REGION_14__LENGTH_LSB)
-#define RDMA_REGION_14__LENGTH_SET(x)            (((x) << RDMA_REGION_14__LENGTH_LSB) & RDMA_REGION_14__LENGTH_MASK)
-#define RDMA_REGION_14__INDI_MSB                 1
-#define RDMA_REGION_14__INDI_LSB                 1
-#define RDMA_REGION_14__INDI_MASK                0x00000002
-#define RDMA_REGION_14__INDI_GET(x)              (((x) & RDMA_REGION_14__INDI_MASK) >> RDMA_REGION_14__INDI_LSB)
-#define RDMA_REGION_14__INDI_SET(x)              (((x) << RDMA_REGION_14__INDI_LSB) & RDMA_REGION_14__INDI_MASK)
-#define RDMA_REGION_14__NEXT_MSB                 0
-#define RDMA_REGION_14__NEXT_LSB                 0
-#define RDMA_REGION_14__NEXT_MASK                0x00000001
-#define RDMA_REGION_14__NEXT_GET(x)              (((x) & RDMA_REGION_14__NEXT_MASK) >> RDMA_REGION_14__NEXT_LSB)
-#define RDMA_REGION_14__NEXT_SET(x)              (((x) << RDMA_REGION_14__NEXT_LSB) & RDMA_REGION_14__NEXT_MASK)
-
-#define RDMA_REGION_15__ADDRESS                  0x0000005c
-#define RDMA_REGION_15__OFFSET                   0x0000005c
-#define RDMA_REGION_15__ADDR_MSB                 31
-#define RDMA_REGION_15__ADDR_LSB                 13
-#define RDMA_REGION_15__ADDR_MASK                0xffffe000
-#define RDMA_REGION_15__ADDR_GET(x)              (((x) & RDMA_REGION_15__ADDR_MASK) >> RDMA_REGION_15__ADDR_LSB)
-#define RDMA_REGION_15__ADDR_SET(x)              (((x) << RDMA_REGION_15__ADDR_LSB) & RDMA_REGION_15__ADDR_MASK)
-#define RDMA_REGION_15__LENGTH_MSB               12
-#define RDMA_REGION_15__LENGTH_LSB               2
-#define RDMA_REGION_15__LENGTH_MASK              0x00001ffc
-#define RDMA_REGION_15__LENGTH_GET(x)            (((x) & RDMA_REGION_15__LENGTH_MASK) >> RDMA_REGION_15__LENGTH_LSB)
-#define RDMA_REGION_15__LENGTH_SET(x)            (((x) << RDMA_REGION_15__LENGTH_LSB) & RDMA_REGION_15__LENGTH_MASK)
-#define RDMA_REGION_15__INDI_MSB                 1
-#define RDMA_REGION_15__INDI_LSB                 1
-#define RDMA_REGION_15__INDI_MASK                0x00000002
-#define RDMA_REGION_15__INDI_GET(x)              (((x) & RDMA_REGION_15__INDI_MASK) >> RDMA_REGION_15__INDI_LSB)
-#define RDMA_REGION_15__INDI_SET(x)              (((x) << RDMA_REGION_15__INDI_LSB) & RDMA_REGION_15__INDI_MASK)
-#define RDMA_REGION_15__NEXT_MSB                 0
-#define RDMA_REGION_15__NEXT_LSB                 0
-#define RDMA_REGION_15__NEXT_MASK                0x00000001
-#define RDMA_REGION_15__NEXT_GET(x)              (((x) & RDMA_REGION_15__NEXT_MASK) >> RDMA_REGION_15__NEXT_LSB)
-#define RDMA_REGION_15__NEXT_SET(x)              (((x) << RDMA_REGION_15__NEXT_LSB) & RDMA_REGION_15__NEXT_MASK)
-
-#define DMA_STATUS_ADDRESS                       0x00000060
-#define DMA_STATUS_OFFSET                        0x00000060
-#define DMA_STATUS_ERROR_CODE_MSB                14
-#define DMA_STATUS_ERROR_CODE_LSB                4
-#define DMA_STATUS_ERROR_CODE_MASK               0x00007ff0
-#define DMA_STATUS_ERROR_CODE_GET(x)             (((x) & DMA_STATUS_ERROR_CODE_MASK) >> DMA_STATUS_ERROR_CODE_LSB)
-#define DMA_STATUS_ERROR_CODE_SET(x)             (((x) << DMA_STATUS_ERROR_CODE_LSB) & DMA_STATUS_ERROR_CODE_MASK)
-#define DMA_STATUS_ERROR_MSB                     3
-#define DMA_STATUS_ERROR_LSB                     3
-#define DMA_STATUS_ERROR_MASK                    0x00000008
-#define DMA_STATUS_ERROR_GET(x)                  (((x) & DMA_STATUS_ERROR_MASK) >> DMA_STATUS_ERROR_LSB)
-#define DMA_STATUS_ERROR_SET(x)                  (((x) << DMA_STATUS_ERROR_LSB) & DMA_STATUS_ERROR_MASK)
-#define DMA_STATUS_DONE_MSB                      2
-#define DMA_STATUS_DONE_LSB                      2
-#define DMA_STATUS_DONE_MASK                     0x00000004
-#define DMA_STATUS_DONE_GET(x)                   (((x) & DMA_STATUS_DONE_MASK) >> DMA_STATUS_DONE_LSB)
-#define DMA_STATUS_DONE_SET(x)                   (((x) << DMA_STATUS_DONE_LSB) & DMA_STATUS_DONE_MASK)
-#define DMA_STATUS_STOPPED_MSB                   1
-#define DMA_STATUS_STOPPED_LSB                   1
-#define DMA_STATUS_STOPPED_MASK                  0x00000002
-#define DMA_STATUS_STOPPED_GET(x)                (((x) & DMA_STATUS_STOPPED_MASK) >> DMA_STATUS_STOPPED_LSB)
-#define DMA_STATUS_STOPPED_SET(x)                (((x) << DMA_STATUS_STOPPED_LSB) & DMA_STATUS_STOPPED_MASK)
-#define DMA_STATUS_RUNNING_MSB                   0
-#define DMA_STATUS_RUNNING_LSB                   0
-#define DMA_STATUS_RUNNING_MASK                  0x00000001
-#define DMA_STATUS_RUNNING_GET(x)                (((x) & DMA_STATUS_RUNNING_MASK) >> DMA_STATUS_RUNNING_LSB)
-#define DMA_STATUS_RUNNING_SET(x)                (((x) << DMA_STATUS_RUNNING_LSB) & DMA_STATUS_RUNNING_MASK)
-
-#define DMA_INT_EN_ADDRESS                       0x00000064
-#define DMA_INT_EN_OFFSET                        0x00000064
-#define DMA_INT_EN_ERROR_ENA_MSB                 3
-#define DMA_INT_EN_ERROR_ENA_LSB                 3
-#define DMA_INT_EN_ERROR_ENA_MASK                0x00000008
-#define DMA_INT_EN_ERROR_ENA_GET(x)              (((x) & DMA_INT_EN_ERROR_ENA_MASK) >> DMA_INT_EN_ERROR_ENA_LSB)
-#define DMA_INT_EN_ERROR_ENA_SET(x)              (((x) << DMA_INT_EN_ERROR_ENA_LSB) & DMA_INT_EN_ERROR_ENA_MASK)
-#define DMA_INT_EN_DONE_ENA_MSB                  2
-#define DMA_INT_EN_DONE_ENA_LSB                  2
-#define DMA_INT_EN_DONE_ENA_MASK                 0x00000004
-#define DMA_INT_EN_DONE_ENA_GET(x)               (((x) & DMA_INT_EN_DONE_ENA_MASK) >> DMA_INT_EN_DONE_ENA_LSB)
-#define DMA_INT_EN_DONE_ENA_SET(x)               (((x) << DMA_INT_EN_DONE_ENA_LSB) & DMA_INT_EN_DONE_ENA_MASK)
-#define DMA_INT_EN_STOPPED_ENA_MSB               1
-#define DMA_INT_EN_STOPPED_ENA_LSB               1
-#define DMA_INT_EN_STOPPED_ENA_MASK              0x00000002
-#define DMA_INT_EN_STOPPED_ENA_GET(x)            (((x) & DMA_INT_EN_STOPPED_ENA_MASK) >> DMA_INT_EN_STOPPED_ENA_LSB)
-#define DMA_INT_EN_STOPPED_ENA_SET(x)            (((x) << DMA_INT_EN_STOPPED_ENA_LSB) & DMA_INT_EN_STOPPED_ENA_MASK)
-
-
-#ifndef __ASSEMBLER__
-
-typedef struct rdma_reg_reg_s {
-  volatile unsigned int dma_config;
-  volatile unsigned int dma_control;
-  volatile unsigned int dma_src;
-  volatile unsigned int dma_dest;
-  volatile unsigned int dma_length;
-  volatile unsigned int vmc_base;
-  volatile unsigned int indirect_reg;
-  volatile unsigned int indirect_return;
-  volatile unsigned int rdma_region_0_;
-  volatile unsigned int rdma_region_1_;
-  volatile unsigned int rdma_region_2_;
-  volatile unsigned int rdma_region_3_;
-  volatile unsigned int rdma_region_4_;
-  volatile unsigned int rdma_region_5_;
-  volatile unsigned int rdma_region_6_;
-  volatile unsigned int rdma_region_7_;
-  volatile unsigned int rdma_region_8_;
-  volatile unsigned int rdma_region_9_;
-  volatile unsigned int rdma_region_10_;
-  volatile unsigned int rdma_region_11_;
-  volatile unsigned int rdma_region_12_;
-  volatile unsigned int rdma_region_13_;
-  volatile unsigned int rdma_region_14_;
-  volatile unsigned int rdma_region_15_;
-  volatile unsigned int dma_status;
-  volatile unsigned int dma_int_en;
-} rdma_reg_reg_t;
-
-#endif /* __ASSEMBLER__ */
-
-#endif /* _RDMA_REG_H_ */
index 0855de5f1400e84d5ab3e405d0f18aa5a24c95cf..fcafec88a6b92506add22f0b69404368287e697d 100644 (file)
 //===================================================================
 
 
-#ifdef WLAN_HEADERS
-
 #include "rtc_wlan_reg.h"
 
-
 #ifndef BT_HEADERS
 
 #define RESET_CONTROL_ADDRESS WLAN_RESET_CONTROL_ADDRESS
 #define RESET_CONTROL_SI0_RST_MASK WLAN_RESET_CONTROL_SI0_RST_MASK
 #define RESET_CONTROL_SI0_RST_GET(x) WLAN_RESET_CONTROL_SI0_RST_GET(x)
 #define RESET_CONTROL_SI0_RST_SET(x) WLAN_RESET_CONTROL_SI0_RST_SET(x)
-#define XTAL_CONTROL_ADDRESS WLAN_XTAL_CONTROL_ADDRESS
-#define XTAL_CONTROL_OFFSET WLAN_XTAL_CONTROL_OFFSET
-#define XTAL_CONTROL_TCXO_MSB WLAN_XTAL_CONTROL_TCXO_MSB
-#define XTAL_CONTROL_TCXO_LSB WLAN_XTAL_CONTROL_TCXO_LSB
-#define XTAL_CONTROL_TCXO_MASK WLAN_XTAL_CONTROL_TCXO_MASK
-#define XTAL_CONTROL_TCXO_GET(x) WLAN_XTAL_CONTROL_TCXO_GET(x)
-#define XTAL_CONTROL_TCXO_SET(x) WLAN_XTAL_CONTROL_TCXO_SET(x)
-#define TCXO_DETECT_ADDRESS WLAN_TCXO_DETECT_ADDRESS
-#define TCXO_DETECT_OFFSET WLAN_TCXO_DETECT_OFFSET
-#define TCXO_DETECT_PRESENT_MSB WLAN_TCXO_DETECT_PRESENT_MSB
-#define TCXO_DETECT_PRESENT_LSB WLAN_TCXO_DETECT_PRESENT_LSB
-#define TCXO_DETECT_PRESENT_MASK WLAN_TCXO_DETECT_PRESENT_MASK
-#define TCXO_DETECT_PRESENT_GET(x) WLAN_TCXO_DETECT_PRESENT_GET(x)
-#define TCXO_DETECT_PRESENT_SET(x) WLAN_TCXO_DETECT_PRESENT_SET(x)
-#define XTAL_TEST_ADDRESS WLAN_XTAL_TEST_ADDRESS
-#define XTAL_TEST_OFFSET WLAN_XTAL_TEST_OFFSET
-#define XTAL_TEST_NOTCXODET_MSB WLAN_XTAL_TEST_NOTCXODET_MSB
-#define XTAL_TEST_NOTCXODET_LSB WLAN_XTAL_TEST_NOTCXODET_LSB
-#define XTAL_TEST_NOTCXODET_MASK WLAN_XTAL_TEST_NOTCXODET_MASK
-#define XTAL_TEST_NOTCXODET_GET(x) WLAN_XTAL_TEST_NOTCXODET_GET(x)
-#define XTAL_TEST_NOTCXODET_SET(x) WLAN_XTAL_TEST_NOTCXODET_SET(x)
-#define QUADRATURE_ADDRESS WLAN_QUADRATURE_ADDRESS
-#define QUADRATURE_OFFSET WLAN_QUADRATURE_OFFSET
-#define QUADRATURE_ADC_MSB WLAN_QUADRATURE_ADC_MSB
-#define QUADRATURE_ADC_LSB WLAN_QUADRATURE_ADC_LSB
-#define QUADRATURE_ADC_MASK WLAN_QUADRATURE_ADC_MASK
-#define QUADRATURE_ADC_GET(x) WLAN_QUADRATURE_ADC_GET(x)
-#define QUADRATURE_ADC_SET(x) WLAN_QUADRATURE_ADC_SET(x)
-#define QUADRATURE_SEL_MSB WLAN_QUADRATURE_SEL_MSB
-#define QUADRATURE_SEL_LSB WLAN_QUADRATURE_SEL_LSB
-#define QUADRATURE_SEL_MASK WLAN_QUADRATURE_SEL_MASK
-#define QUADRATURE_SEL_GET(x) WLAN_QUADRATURE_SEL_GET(x)
-#define QUADRATURE_SEL_SET(x) WLAN_QUADRATURE_SEL_SET(x)
-#define QUADRATURE_DAC_MSB WLAN_QUADRATURE_DAC_MSB
-#define QUADRATURE_DAC_LSB WLAN_QUADRATURE_DAC_LSB
-#define QUADRATURE_DAC_MASK WLAN_QUADRATURE_DAC_MASK
-#define QUADRATURE_DAC_GET(x) WLAN_QUADRATURE_DAC_GET(x)
-#define QUADRATURE_DAC_SET(x) WLAN_QUADRATURE_DAC_SET(x)
-#define PLL_CONTROL_ADDRESS WLAN_PLL_CONTROL_ADDRESS
-#define PLL_CONTROL_OFFSET WLAN_PLL_CONTROL_OFFSET
-#define PLL_CONTROL_DIG_TEST_CLK_MSB WLAN_PLL_CONTROL_DIG_TEST_CLK_MSB
-#define PLL_CONTROL_DIG_TEST_CLK_LSB WLAN_PLL_CONTROL_DIG_TEST_CLK_LSB
-#define PLL_CONTROL_DIG_TEST_CLK_MASK WLAN_PLL_CONTROL_DIG_TEST_CLK_MASK
-#define PLL_CONTROL_DIG_TEST_CLK_GET(x) WLAN_PLL_CONTROL_DIG_TEST_CLK_GET(x)
-#define PLL_CONTROL_DIG_TEST_CLK_SET(x) WLAN_PLL_CONTROL_DIG_TEST_CLK_SET(x)
-#define PLL_CONTROL_MAC_OVERRIDE_MSB WLAN_PLL_CONTROL_MAC_OVERRIDE_MSB
-#define PLL_CONTROL_MAC_OVERRIDE_LSB WLAN_PLL_CONTROL_MAC_OVERRIDE_LSB
-#define PLL_CONTROL_MAC_OVERRIDE_MASK WLAN_PLL_CONTROL_MAC_OVERRIDE_MASK
-#define PLL_CONTROL_MAC_OVERRIDE_GET(x) WLAN_PLL_CONTROL_MAC_OVERRIDE_GET(x)
-#define PLL_CONTROL_MAC_OVERRIDE_SET(x) WLAN_PLL_CONTROL_MAC_OVERRIDE_SET(x)
-#define PLL_CONTROL_NOPWD_MSB WLAN_PLL_CONTROL_NOPWD_MSB
-#define PLL_CONTROL_NOPWD_LSB WLAN_PLL_CONTROL_NOPWD_LSB
-#define PLL_CONTROL_NOPWD_MASK WLAN_PLL_CONTROL_NOPWD_MASK
-#define PLL_CONTROL_NOPWD_GET(x) WLAN_PLL_CONTROL_NOPWD_GET(x)
-#define PLL_CONTROL_NOPWD_SET(x) WLAN_PLL_CONTROL_NOPWD_SET(x)
-#define PLL_CONTROL_UPDATING_MSB WLAN_PLL_CONTROL_UPDATING_MSB
-#define PLL_CONTROL_UPDATING_LSB WLAN_PLL_CONTROL_UPDATING_LSB
-#define PLL_CONTROL_UPDATING_MASK WLAN_PLL_CONTROL_UPDATING_MASK
-#define PLL_CONTROL_UPDATING_GET(x) WLAN_PLL_CONTROL_UPDATING_GET(x)
-#define PLL_CONTROL_UPDATING_SET(x) WLAN_PLL_CONTROL_UPDATING_SET(x)
-#define PLL_CONTROL_BYPASS_MSB WLAN_PLL_CONTROL_BYPASS_MSB
-#define PLL_CONTROL_BYPASS_LSB WLAN_PLL_CONTROL_BYPASS_LSB
-#define PLL_CONTROL_BYPASS_MASK WLAN_PLL_CONTROL_BYPASS_MASK
-#define PLL_CONTROL_BYPASS_GET(x) WLAN_PLL_CONTROL_BYPASS_GET(x)
-#define PLL_CONTROL_BYPASS_SET(x) WLAN_PLL_CONTROL_BYPASS_SET(x)
-#define PLL_CONTROL_REFDIV_MSB WLAN_PLL_CONTROL_REFDIV_MSB
-#define PLL_CONTROL_REFDIV_LSB WLAN_PLL_CONTROL_REFDIV_LSB
-#define PLL_CONTROL_REFDIV_MASK WLAN_PLL_CONTROL_REFDIV_MASK
-#define PLL_CONTROL_REFDIV_GET(x) WLAN_PLL_CONTROL_REFDIV_GET(x)
-#define PLL_CONTROL_REFDIV_SET(x) WLAN_PLL_CONTROL_REFDIV_SET(x)
-#define PLL_CONTROL_DIV_MSB WLAN_PLL_CONTROL_DIV_MSB
-#define PLL_CONTROL_DIV_LSB WLAN_PLL_CONTROL_DIV_LSB
-#define PLL_CONTROL_DIV_MASK WLAN_PLL_CONTROL_DIV_MASK
-#define PLL_CONTROL_DIV_GET(x) WLAN_PLL_CONTROL_DIV_GET(x)
-#define PLL_CONTROL_DIV_SET(x) WLAN_PLL_CONTROL_DIV_SET(x)
-#define PLL_SETTLE_ADDRESS WLAN_PLL_SETTLE_ADDRESS
-#define PLL_SETTLE_OFFSET WLAN_PLL_SETTLE_OFFSET
-#define PLL_SETTLE_TIME_MSB WLAN_PLL_SETTLE_TIME_MSB
-#define PLL_SETTLE_TIME_LSB WLAN_PLL_SETTLE_TIME_LSB
-#define PLL_SETTLE_TIME_MASK WLAN_PLL_SETTLE_TIME_MASK
-#define PLL_SETTLE_TIME_GET(x) WLAN_PLL_SETTLE_TIME_GET(x)
-#define PLL_SETTLE_TIME_SET(x) WLAN_PLL_SETTLE_TIME_SET(x)
-#define XTAL_SETTLE_ADDRESS WLAN_XTAL_SETTLE_ADDRESS
-#define XTAL_SETTLE_OFFSET WLAN_XTAL_SETTLE_OFFSET
-#define XTAL_SETTLE_TIME_MSB WLAN_XTAL_SETTLE_TIME_MSB
-#define XTAL_SETTLE_TIME_LSB WLAN_XTAL_SETTLE_TIME_LSB
-#define XTAL_SETTLE_TIME_MASK WLAN_XTAL_SETTLE_TIME_MASK
-#define XTAL_SETTLE_TIME_GET(x) WLAN_XTAL_SETTLE_TIME_GET(x)
-#define XTAL_SETTLE_TIME_SET(x) WLAN_XTAL_SETTLE_TIME_SET(x)
 #define CPU_CLOCK_ADDRESS WLAN_CPU_CLOCK_ADDRESS
 #define CPU_CLOCK_OFFSET WLAN_CPU_CLOCK_OFFSET
 #define CPU_CLOCK_STANDARD_MSB WLAN_CPU_CLOCK_STANDARD_MSB
 #define CLOCK_CONTROL_SI0_CLK_MASK WLAN_CLOCK_CONTROL_SI0_CLK_MASK
 #define CLOCK_CONTROL_SI0_CLK_GET(x) WLAN_CLOCK_CONTROL_SI0_CLK_GET(x)
 #define CLOCK_CONTROL_SI0_CLK_SET(x) WLAN_CLOCK_CONTROL_SI0_CLK_SET(x)
-#define BIAS_OVERRIDE_ADDRESS WLAN_BIAS_OVERRIDE_ADDRESS
-#define BIAS_OVERRIDE_OFFSET WLAN_BIAS_OVERRIDE_OFFSET
-#define BIAS_OVERRIDE_ON_MSB WLAN_BIAS_OVERRIDE_ON_MSB
-#define BIAS_OVERRIDE_ON_LSB WLAN_BIAS_OVERRIDE_ON_LSB
-#define BIAS_OVERRIDE_ON_MASK WLAN_BIAS_OVERRIDE_ON_MASK
-#define BIAS_OVERRIDE_ON_GET(x) WLAN_BIAS_OVERRIDE_ON_GET(x)
-#define BIAS_OVERRIDE_ON_SET(x) WLAN_BIAS_OVERRIDE_ON_SET(x)
-#define WDT_CONTROL_ADDRESS WLAN_WDT_CONTROL_ADDRESS
-#define WDT_CONTROL_OFFSET WLAN_WDT_CONTROL_OFFSET
-#define WDT_CONTROL_ACTION_MSB WLAN_WDT_CONTROL_ACTION_MSB
-#define WDT_CONTROL_ACTION_LSB WLAN_WDT_CONTROL_ACTION_LSB
-#define WDT_CONTROL_ACTION_MASK WLAN_WDT_CONTROL_ACTION_MASK
-#define WDT_CONTROL_ACTION_GET(x) WLAN_WDT_CONTROL_ACTION_GET(x)
-#define WDT_CONTROL_ACTION_SET(x) WLAN_WDT_CONTROL_ACTION_SET(x)
-#define WDT_STATUS_ADDRESS WLAN_WDT_STATUS_ADDRESS
-#define WDT_STATUS_OFFSET WLAN_WDT_STATUS_OFFSET
-#define WDT_STATUS_INTERRUPT_MSB WLAN_WDT_STATUS_INTERRUPT_MSB
-#define WDT_STATUS_INTERRUPT_LSB WLAN_WDT_STATUS_INTERRUPT_LSB
-#define WDT_STATUS_INTERRUPT_MASK WLAN_WDT_STATUS_INTERRUPT_MASK
-#define WDT_STATUS_INTERRUPT_GET(x) WLAN_WDT_STATUS_INTERRUPT_GET(x)
-#define WDT_STATUS_INTERRUPT_SET(x) WLAN_WDT_STATUS_INTERRUPT_SET(x)
-#define WDT_ADDRESS WLAN_WDT_ADDRESS
-#define WDT_OFFSET WLAN_WDT_OFFSET
-#define WDT_TARGET_MSB WLAN_WDT_TARGET_MSB
-#define WDT_TARGET_LSB WLAN_WDT_TARGET_LSB
-#define WDT_TARGET_MASK WLAN_WDT_TARGET_MASK
-#define WDT_TARGET_GET(x) WLAN_WDT_TARGET_GET(x)
-#define WDT_TARGET_SET(x) WLAN_WDT_TARGET_SET(x)
-#define WDT_COUNT_ADDRESS WLAN_WDT_COUNT_ADDRESS
-#define WDT_COUNT_OFFSET WLAN_WDT_COUNT_OFFSET
-#define WDT_COUNT_VALUE_MSB WLAN_WDT_COUNT_VALUE_MSB
-#define WDT_COUNT_VALUE_LSB WLAN_WDT_COUNT_VALUE_LSB
-#define WDT_COUNT_VALUE_MASK WLAN_WDT_COUNT_VALUE_MASK
-#define WDT_COUNT_VALUE_GET(x) WLAN_WDT_COUNT_VALUE_GET(x)
-#define WDT_COUNT_VALUE_SET(x) WLAN_WDT_COUNT_VALUE_SET(x)
-#define WDT_RESET_ADDRESS WLAN_WDT_RESET_ADDRESS
-#define WDT_RESET_OFFSET WLAN_WDT_RESET_OFFSET
-#define WDT_RESET_VALUE_MSB WLAN_WDT_RESET_VALUE_MSB
-#define WDT_RESET_VALUE_LSB WLAN_WDT_RESET_VALUE_LSB
-#define WDT_RESET_VALUE_MASK WLAN_WDT_RESET_VALUE_MASK
-#define WDT_RESET_VALUE_GET(x) WLAN_WDT_RESET_VALUE_GET(x)
-#define WDT_RESET_VALUE_SET(x) WLAN_WDT_RESET_VALUE_SET(x)
-#define INT_STATUS_ADDRESS WLAN_INT_STATUS_ADDRESS
-#define INT_STATUS_OFFSET WLAN_INT_STATUS_OFFSET
-#define INT_STATUS_HCI_UART_MSB WLAN_INT_STATUS_HCI_UART_MSB
-#define INT_STATUS_HCI_UART_LSB WLAN_INT_STATUS_HCI_UART_LSB
-#define INT_STATUS_HCI_UART_MASK WLAN_INT_STATUS_HCI_UART_MASK
-#define INT_STATUS_HCI_UART_GET(x) WLAN_INT_STATUS_HCI_UART_GET(x)
-#define INT_STATUS_HCI_UART_SET(x) WLAN_INT_STATUS_HCI_UART_SET(x)
-#define INT_STATUS_THERM_MSB WLAN_INT_STATUS_THERM_MSB
-#define INT_STATUS_THERM_LSB WLAN_INT_STATUS_THERM_LSB
-#define INT_STATUS_THERM_MASK WLAN_INT_STATUS_THERM_MASK
-#define INT_STATUS_THERM_GET(x) WLAN_INT_STATUS_THERM_GET(x)
-#define INT_STATUS_THERM_SET(x) WLAN_INT_STATUS_THERM_SET(x)
-#define INT_STATUS_EFUSE_OVERWRITE_MSB WLAN_INT_STATUS_EFUSE_OVERWRITE_MSB
-#define INT_STATUS_EFUSE_OVERWRITE_LSB WLAN_INT_STATUS_EFUSE_OVERWRITE_LSB
-#define INT_STATUS_EFUSE_OVERWRITE_MASK WLAN_INT_STATUS_EFUSE_OVERWRITE_MASK
-#define INT_STATUS_EFUSE_OVERWRITE_GET(x) WLAN_INT_STATUS_EFUSE_OVERWRITE_GET(x)
-#define INT_STATUS_EFUSE_OVERWRITE_SET(x) WLAN_INT_STATUS_EFUSE_OVERWRITE_SET(x)
-#define INT_STATUS_UART_MBOX_MSB WLAN_INT_STATUS_UART_MBOX_MSB
-#define INT_STATUS_UART_MBOX_LSB WLAN_INT_STATUS_UART_MBOX_LSB
-#define INT_STATUS_UART_MBOX_MASK WLAN_INT_STATUS_UART_MBOX_MASK
-#define INT_STATUS_UART_MBOX_GET(x) WLAN_INT_STATUS_UART_MBOX_GET(x)
-#define INT_STATUS_UART_MBOX_SET(x) WLAN_INT_STATUS_UART_MBOX_SET(x)
-#define INT_STATUS_GENERIC_MBOX_MSB WLAN_INT_STATUS_GENERIC_MBOX_MSB
-#define INT_STATUS_GENERIC_MBOX_LSB WLAN_INT_STATUS_GENERIC_MBOX_LSB
-#define INT_STATUS_GENERIC_MBOX_MASK WLAN_INT_STATUS_GENERIC_MBOX_MASK
-#define INT_STATUS_GENERIC_MBOX_GET(x) WLAN_INT_STATUS_GENERIC_MBOX_GET(x)
-#define INT_STATUS_GENERIC_MBOX_SET(x) WLAN_INT_STATUS_GENERIC_MBOX_SET(x)
-#define INT_STATUS_RDMA_MSB WLAN_INT_STATUS_RDMA_MSB
-#define INT_STATUS_RDMA_LSB WLAN_INT_STATUS_RDMA_LSB
-#define INT_STATUS_RDMA_MASK WLAN_INT_STATUS_RDMA_MASK
-#define INT_STATUS_RDMA_GET(x) WLAN_INT_STATUS_RDMA_GET(x)
-#define INT_STATUS_RDMA_SET(x) WLAN_INT_STATUS_RDMA_SET(x)
-#define INT_STATUS_BTCOEX_MSB WLAN_INT_STATUS_BTCOEX_MSB
-#define INT_STATUS_BTCOEX_LSB WLAN_INT_STATUS_BTCOEX_LSB
-#define INT_STATUS_BTCOEX_MASK WLAN_INT_STATUS_BTCOEX_MASK
-#define INT_STATUS_BTCOEX_GET(x) WLAN_INT_STATUS_BTCOEX_GET(x)
-#define INT_STATUS_BTCOEX_SET(x) WLAN_INT_STATUS_BTCOEX_SET(x)
-#define INT_STATUS_RTC_POWER_MSB WLAN_INT_STATUS_RTC_POWER_MSB
-#define INT_STATUS_RTC_POWER_LSB WLAN_INT_STATUS_RTC_POWER_LSB
-#define INT_STATUS_RTC_POWER_MASK WLAN_INT_STATUS_RTC_POWER_MASK
-#define INT_STATUS_RTC_POWER_GET(x) WLAN_INT_STATUS_RTC_POWER_GET(x)
-#define INT_STATUS_RTC_POWER_SET(x) WLAN_INT_STATUS_RTC_POWER_SET(x)
-#define INT_STATUS_MAC_MSB WLAN_INT_STATUS_MAC_MSB
-#define INT_STATUS_MAC_LSB WLAN_INT_STATUS_MAC_LSB
-#define INT_STATUS_MAC_MASK WLAN_INT_STATUS_MAC_MASK
-#define INT_STATUS_MAC_GET(x) WLAN_INT_STATUS_MAC_GET(x)
-#define INT_STATUS_MAC_SET(x) WLAN_INT_STATUS_MAC_SET(x)
-#define INT_STATUS_MAILBOX_MSB WLAN_INT_STATUS_MAILBOX_MSB
-#define INT_STATUS_MAILBOX_LSB WLAN_INT_STATUS_MAILBOX_LSB
-#define INT_STATUS_MAILBOX_MASK WLAN_INT_STATUS_MAILBOX_MASK
-#define INT_STATUS_MAILBOX_GET(x) WLAN_INT_STATUS_MAILBOX_GET(x)
-#define INT_STATUS_MAILBOX_SET(x) WLAN_INT_STATUS_MAILBOX_SET(x)
-#define INT_STATUS_RTC_ALARM_MSB WLAN_INT_STATUS_RTC_ALARM_MSB
-#define INT_STATUS_RTC_ALARM_LSB WLAN_INT_STATUS_RTC_ALARM_LSB
-#define INT_STATUS_RTC_ALARM_MASK WLAN_INT_STATUS_RTC_ALARM_MASK
-#define INT_STATUS_RTC_ALARM_GET(x) WLAN_INT_STATUS_RTC_ALARM_GET(x)
-#define INT_STATUS_RTC_ALARM_SET(x) WLAN_INT_STATUS_RTC_ALARM_SET(x)
-#define INT_STATUS_HF_TIMER_MSB WLAN_INT_STATUS_HF_TIMER_MSB
-#define INT_STATUS_HF_TIMER_LSB WLAN_INT_STATUS_HF_TIMER_LSB
-#define INT_STATUS_HF_TIMER_MASK WLAN_INT_STATUS_HF_TIMER_MASK
-#define INT_STATUS_HF_TIMER_GET(x) WLAN_INT_STATUS_HF_TIMER_GET(x)
-#define INT_STATUS_HF_TIMER_SET(x) WLAN_INT_STATUS_HF_TIMER_SET(x)
-#define INT_STATUS_LF_TIMER3_MSB WLAN_INT_STATUS_LF_TIMER3_MSB
-#define INT_STATUS_LF_TIMER3_LSB WLAN_INT_STATUS_LF_TIMER3_LSB
-#define INT_STATUS_LF_TIMER3_MASK WLAN_INT_STATUS_LF_TIMER3_MASK
-#define INT_STATUS_LF_TIMER3_GET(x) WLAN_INT_STATUS_LF_TIMER3_GET(x)
-#define INT_STATUS_LF_TIMER3_SET(x) WLAN_INT_STATUS_LF_TIMER3_SET(x)
-#define INT_STATUS_LF_TIMER2_MSB WLAN_INT_STATUS_LF_TIMER2_MSB
-#define INT_STATUS_LF_TIMER2_LSB WLAN_INT_STATUS_LF_TIMER2_LSB
-#define INT_STATUS_LF_TIMER2_MASK WLAN_INT_STATUS_LF_TIMER2_MASK
-#define INT_STATUS_LF_TIMER2_GET(x) WLAN_INT_STATUS_LF_TIMER2_GET(x)
-#define INT_STATUS_LF_TIMER2_SET(x) WLAN_INT_STATUS_LF_TIMER2_SET(x)
-#define INT_STATUS_LF_TIMER1_MSB WLAN_INT_STATUS_LF_TIMER1_MSB
-#define INT_STATUS_LF_TIMER1_LSB WLAN_INT_STATUS_LF_TIMER1_LSB
-#define INT_STATUS_LF_TIMER1_MASK WLAN_INT_STATUS_LF_TIMER1_MASK
-#define INT_STATUS_LF_TIMER1_GET(x) WLAN_INT_STATUS_LF_TIMER1_GET(x)
-#define INT_STATUS_LF_TIMER1_SET(x) WLAN_INT_STATUS_LF_TIMER1_SET(x)
-#define INT_STATUS_LF_TIMER0_MSB WLAN_INT_STATUS_LF_TIMER0_MSB
-#define INT_STATUS_LF_TIMER0_LSB WLAN_INT_STATUS_LF_TIMER0_LSB
-#define INT_STATUS_LF_TIMER0_MASK WLAN_INT_STATUS_LF_TIMER0_MASK
-#define INT_STATUS_LF_TIMER0_GET(x) WLAN_INT_STATUS_LF_TIMER0_GET(x)
-#define INT_STATUS_LF_TIMER0_SET(x) WLAN_INT_STATUS_LF_TIMER0_SET(x)
-#define INT_STATUS_KEYPAD_MSB WLAN_INT_STATUS_KEYPAD_MSB
-#define INT_STATUS_KEYPAD_LSB WLAN_INT_STATUS_KEYPAD_LSB
-#define INT_STATUS_KEYPAD_MASK WLAN_INT_STATUS_KEYPAD_MASK
-#define INT_STATUS_KEYPAD_GET(x) WLAN_INT_STATUS_KEYPAD_GET(x)
-#define INT_STATUS_KEYPAD_SET(x) WLAN_INT_STATUS_KEYPAD_SET(x)
-#define INT_STATUS_SI_MSB WLAN_INT_STATUS_SI_MSB
-#define INT_STATUS_SI_LSB WLAN_INT_STATUS_SI_LSB
-#define INT_STATUS_SI_MASK WLAN_INT_STATUS_SI_MASK
-#define INT_STATUS_SI_GET(x) WLAN_INT_STATUS_SI_GET(x)
-#define INT_STATUS_SI_SET(x) WLAN_INT_STATUS_SI_SET(x)
-#define INT_STATUS_GPIO_MSB WLAN_INT_STATUS_GPIO_MSB
-#define INT_STATUS_GPIO_LSB WLAN_INT_STATUS_GPIO_LSB
-#define INT_STATUS_GPIO_MASK WLAN_INT_STATUS_GPIO_MASK
-#define INT_STATUS_GPIO_GET(x) WLAN_INT_STATUS_GPIO_GET(x)
-#define INT_STATUS_GPIO_SET(x) WLAN_INT_STATUS_GPIO_SET(x)
-#define INT_STATUS_UART_MSB WLAN_INT_STATUS_UART_MSB
-#define INT_STATUS_UART_LSB WLAN_INT_STATUS_UART_LSB
-#define INT_STATUS_UART_MASK WLAN_INT_STATUS_UART_MASK
-#define INT_STATUS_UART_GET(x) WLAN_INT_STATUS_UART_GET(x)
-#define INT_STATUS_UART_SET(x) WLAN_INT_STATUS_UART_SET(x)
-#define INT_STATUS_ERROR_MSB WLAN_INT_STATUS_ERROR_MSB
-#define INT_STATUS_ERROR_LSB WLAN_INT_STATUS_ERROR_LSB
-#define INT_STATUS_ERROR_MASK WLAN_INT_STATUS_ERROR_MASK
-#define INT_STATUS_ERROR_GET(x) WLAN_INT_STATUS_ERROR_GET(x)
-#define INT_STATUS_ERROR_SET(x) WLAN_INT_STATUS_ERROR_SET(x)
-#define INT_STATUS_WDT_INT_MSB WLAN_INT_STATUS_WDT_INT_MSB
-#define INT_STATUS_WDT_INT_LSB WLAN_INT_STATUS_WDT_INT_LSB
-#define INT_STATUS_WDT_INT_MASK WLAN_INT_STATUS_WDT_INT_MASK
-#define INT_STATUS_WDT_INT_GET(x) WLAN_INT_STATUS_WDT_INT_GET(x)
-#define INT_STATUS_WDT_INT_SET(x) WLAN_INT_STATUS_WDT_INT_SET(x)
-#define LF_TIMER0_ADDRESS WLAN_LF_TIMER0_ADDRESS
-#define LF_TIMER0_OFFSET WLAN_LF_TIMER0_OFFSET
-#define LF_TIMER0_TARGET_MSB WLAN_LF_TIMER0_TARGET_MSB
-#define LF_TIMER0_TARGET_LSB WLAN_LF_TIMER0_TARGET_LSB
-#define LF_TIMER0_TARGET_MASK WLAN_LF_TIMER0_TARGET_MASK
-#define LF_TIMER0_TARGET_GET(x) WLAN_LF_TIMER0_TARGET_GET(x)
-#define LF_TIMER0_TARGET_SET(x) WLAN_LF_TIMER0_TARGET_SET(x)
-#define LF_TIMER_COUNT0_ADDRESS WLAN_LF_TIMER_COUNT0_ADDRESS
-#define LF_TIMER_COUNT0_OFFSET WLAN_LF_TIMER_COUNT0_OFFSET
-#define LF_TIMER_COUNT0_VALUE_MSB WLAN_LF_TIMER_COUNT0_VALUE_MSB
-#define LF_TIMER_COUNT0_VALUE_LSB WLAN_LF_TIMER_COUNT0_VALUE_LSB
-#define LF_TIMER_COUNT0_VALUE_MASK WLAN_LF_TIMER_COUNT0_VALUE_MASK
-#define LF_TIMER_COUNT0_VALUE_GET(x) WLAN_LF_TIMER_COUNT0_VALUE_GET(x)
-#define LF_TIMER_COUNT0_VALUE_SET(x) WLAN_LF_TIMER_COUNT0_VALUE_SET(x)
-#define LF_TIMER_CONTROL0_ADDRESS WLAN_LF_TIMER_CONTROL0_ADDRESS
-#define LF_TIMER_CONTROL0_OFFSET WLAN_LF_TIMER_CONTROL0_OFFSET
-#define LF_TIMER_CONTROL0_ENABLE_MSB WLAN_LF_TIMER_CONTROL0_ENABLE_MSB
-#define LF_TIMER_CONTROL0_ENABLE_LSB WLAN_LF_TIMER_CONTROL0_ENABLE_LSB
-#define LF_TIMER_CONTROL0_ENABLE_MASK WLAN_LF_TIMER_CONTROL0_ENABLE_MASK
-#define LF_TIMER_CONTROL0_ENABLE_GET(x) WLAN_LF_TIMER_CONTROL0_ENABLE_GET(x)
-#define LF_TIMER_CONTROL0_ENABLE_SET(x) WLAN_LF_TIMER_CONTROL0_ENABLE_SET(x)
-#define LF_TIMER_CONTROL0_AUTO_RESTART_MSB WLAN_LF_TIMER_CONTROL0_AUTO_RESTART_MSB
-#define LF_TIMER_CONTROL0_AUTO_RESTART_LSB WLAN_LF_TIMER_CONTROL0_AUTO_RESTART_LSB
-#define LF_TIMER_CONTROL0_AUTO_RESTART_MASK WLAN_LF_TIMER_CONTROL0_AUTO_RESTART_MASK
-#define LF_TIMER_CONTROL0_AUTO_RESTART_GET(x) WLAN_LF_TIMER_CONTROL0_AUTO_RESTART_GET(x)
-#define LF_TIMER_CONTROL0_AUTO_RESTART_SET(x) WLAN_LF_TIMER_CONTROL0_AUTO_RESTART_SET(x)
-#define LF_TIMER_CONTROL0_RESET_MSB WLAN_LF_TIMER_CONTROL0_RESET_MSB
-#define LF_TIMER_CONTROL0_RESET_LSB WLAN_LF_TIMER_CONTROL0_RESET_LSB
-#define LF_TIMER_CONTROL0_RESET_MASK WLAN_LF_TIMER_CONTROL0_RESET_MASK
-#define LF_TIMER_CONTROL0_RESET_GET(x) WLAN_LF_TIMER_CONTROL0_RESET_GET(x)
-#define LF_TIMER_CONTROL0_RESET_SET(x) WLAN_LF_TIMER_CONTROL0_RESET_SET(x)
-#define LF_TIMER_STATUS0_ADDRESS WLAN_LF_TIMER_STATUS0_ADDRESS
-#define LF_TIMER_STATUS0_OFFSET WLAN_LF_TIMER_STATUS0_OFFSET
-#define LF_TIMER_STATUS0_INTERRUPT_MSB WLAN_LF_TIMER_STATUS0_INTERRUPT_MSB
-#define LF_TIMER_STATUS0_INTERRUPT_LSB WLAN_LF_TIMER_STATUS0_INTERRUPT_LSB
-#define LF_TIMER_STATUS0_INTERRUPT_MASK WLAN_LF_TIMER_STATUS0_INTERRUPT_MASK
-#define LF_TIMER_STATUS0_INTERRUPT_GET(x) WLAN_LF_TIMER_STATUS0_INTERRUPT_GET(x)
-#define LF_TIMER_STATUS0_INTERRUPT_SET(x) WLAN_LF_TIMER_STATUS0_INTERRUPT_SET(x)
-#define LF_TIMER1_ADDRESS WLAN_LF_TIMER1_ADDRESS
-#define LF_TIMER1_OFFSET WLAN_LF_TIMER1_OFFSET
-#define LF_TIMER1_TARGET_MSB WLAN_LF_TIMER1_TARGET_MSB
-#define LF_TIMER1_TARGET_LSB WLAN_LF_TIMER1_TARGET_LSB
-#define LF_TIMER1_TARGET_MASK WLAN_LF_TIMER1_TARGET_MASK
-#define LF_TIMER1_TARGET_GET(x) WLAN_LF_TIMER1_TARGET_GET(x)
-#define LF_TIMER1_TARGET_SET(x) WLAN_LF_TIMER1_TARGET_SET(x)
-#define LF_TIMER_COUNT1_ADDRESS WLAN_LF_TIMER_COUNT1_ADDRESS
-#define LF_TIMER_COUNT1_OFFSET WLAN_LF_TIMER_COUNT1_OFFSET
-#define LF_TIMER_COUNT1_VALUE_MSB WLAN_LF_TIMER_COUNT1_VALUE_MSB
-#define LF_TIMER_COUNT1_VALUE_LSB WLAN_LF_TIMER_COUNT1_VALUE_LSB
-#define LF_TIMER_COUNT1_VALUE_MASK WLAN_LF_TIMER_COUNT1_VALUE_MASK
-#define LF_TIMER_COUNT1_VALUE_GET(x) WLAN_LF_TIMER_COUNT1_VALUE_GET(x)
-#define LF_TIMER_COUNT1_VALUE_SET(x) WLAN_LF_TIMER_COUNT1_VALUE_SET(x)
-#define LF_TIMER_CONTROL1_ADDRESS WLAN_LF_TIMER_CONTROL1_ADDRESS
-#define LF_TIMER_CONTROL1_OFFSET WLAN_LF_TIMER_CONTROL1_OFFSET
-#define LF_TIMER_CONTROL1_ENABLE_MSB WLAN_LF_TIMER_CONTROL1_ENABLE_MSB
-#define LF_TIMER_CONTROL1_ENABLE_LSB WLAN_LF_TIMER_CONTROL1_ENABLE_LSB
-#define LF_TIMER_CONTROL1_ENABLE_MASK WLAN_LF_TIMER_CONTROL1_ENABLE_MASK
-#define LF_TIMER_CONTROL1_ENABLE_GET(x) WLAN_LF_TIMER_CONTROL1_ENABLE_GET(x)
-#define LF_TIMER_CONTROL1_ENABLE_SET(x) WLAN_LF_TIMER_CONTROL1_ENABLE_SET(x)
-#define LF_TIMER_CONTROL1_AUTO_RESTART_MSB WLAN_LF_TIMER_CONTROL1_AUTO_RESTART_MSB
-#define LF_TIMER_CONTROL1_AUTO_RESTART_LSB WLAN_LF_TIMER_CONTROL1_AUTO_RESTART_LSB
-#define LF_TIMER_CONTROL1_AUTO_RESTART_MASK WLAN_LF_TIMER_CONTROL1_AUTO_RESTART_MASK
-#define LF_TIMER_CONTROL1_AUTO_RESTART_GET(x) WLAN_LF_TIMER_CONTROL1_AUTO_RESTART_GET(x)
-#define LF_TIMER_CONTROL1_AUTO_RESTART_SET(x) WLAN_LF_TIMER_CONTROL1_AUTO_RESTART_SET(x)
-#define LF_TIMER_CONTROL1_RESET_MSB WLAN_LF_TIMER_CONTROL1_RESET_MSB
-#define LF_TIMER_CONTROL1_RESET_LSB WLAN_LF_TIMER_CONTROL1_RESET_LSB
-#define LF_TIMER_CONTROL1_RESET_MASK WLAN_LF_TIMER_CONTROL1_RESET_MASK
-#define LF_TIMER_CONTROL1_RESET_GET(x) WLAN_LF_TIMER_CONTROL1_RESET_GET(x)
-#define LF_TIMER_CONTROL1_RESET_SET(x) WLAN_LF_TIMER_CONTROL1_RESET_SET(x)
-#define LF_TIMER_STATUS1_ADDRESS WLAN_LF_TIMER_STATUS1_ADDRESS
-#define LF_TIMER_STATUS1_OFFSET WLAN_LF_TIMER_STATUS1_OFFSET
-#define LF_TIMER_STATUS1_INTERRUPT_MSB WLAN_LF_TIMER_STATUS1_INTERRUPT_MSB
-#define LF_TIMER_STATUS1_INTERRUPT_LSB WLAN_LF_TIMER_STATUS1_INTERRUPT_LSB
-#define LF_TIMER_STATUS1_INTERRUPT_MASK WLAN_LF_TIMER_STATUS1_INTERRUPT_MASK
-#define LF_TIMER_STATUS1_INTERRUPT_GET(x) WLAN_LF_TIMER_STATUS1_INTERRUPT_GET(x)
-#define LF_TIMER_STATUS1_INTERRUPT_SET(x) WLAN_LF_TIMER_STATUS1_INTERRUPT_SET(x)
-#define LF_TIMER2_ADDRESS WLAN_LF_TIMER2_ADDRESS
-#define LF_TIMER2_OFFSET WLAN_LF_TIMER2_OFFSET
-#define LF_TIMER2_TARGET_MSB WLAN_LF_TIMER2_TARGET_MSB
-#define LF_TIMER2_TARGET_LSB WLAN_LF_TIMER2_TARGET_LSB
-#define LF_TIMER2_TARGET_MASK WLAN_LF_TIMER2_TARGET_MASK
-#define LF_TIMER2_TARGET_GET(x) WLAN_LF_TIMER2_TARGET_GET(x)
-#define LF_TIMER2_TARGET_SET(x) WLAN_LF_TIMER2_TARGET_SET(x)
-#define LF_TIMER_COUNT2_ADDRESS WLAN_LF_TIMER_COUNT2_ADDRESS
-#define LF_TIMER_COUNT2_OFFSET WLAN_LF_TIMER_COUNT2_OFFSET
-#define LF_TIMER_COUNT2_VALUE_MSB WLAN_LF_TIMER_COUNT2_VALUE_MSB
-#define LF_TIMER_COUNT2_VALUE_LSB WLAN_LF_TIMER_COUNT2_VALUE_LSB
-#define LF_TIMER_COUNT2_VALUE_MASK WLAN_LF_TIMER_COUNT2_VALUE_MASK
-#define LF_TIMER_COUNT2_VALUE_GET(x) WLAN_LF_TIMER_COUNT2_VALUE_GET(x)
-#define LF_TIMER_COUNT2_VALUE_SET(x) WLAN_LF_TIMER_COUNT2_VALUE_SET(x)
-#define LF_TIMER_CONTROL2_ADDRESS WLAN_LF_TIMER_CONTROL2_ADDRESS
-#define LF_TIMER_CONTROL2_OFFSET WLAN_LF_TIMER_CONTROL2_OFFSET
-#define LF_TIMER_CONTROL2_ENABLE_MSB WLAN_LF_TIMER_CONTROL2_ENABLE_MSB
-#define LF_TIMER_CONTROL2_ENABLE_LSB WLAN_LF_TIMER_CONTROL2_ENABLE_LSB
-#define LF_TIMER_CONTROL2_ENABLE_MASK WLAN_LF_TIMER_CONTROL2_ENABLE_MASK
-#define LF_TIMER_CONTROL2_ENABLE_GET(x) WLAN_LF_TIMER_CONTROL2_ENABLE_GET(x)
-#define LF_TIMER_CONTROL2_ENABLE_SET(x) WLAN_LF_TIMER_CONTROL2_ENABLE_SET(x)
-#define LF_TIMER_CONTROL2_AUTO_RESTART_MSB WLAN_LF_TIMER_CONTROL2_AUTO_RESTART_MSB
-#define LF_TIMER_CONTROL2_AUTO_RESTART_LSB WLAN_LF_TIMER_CONTROL2_AUTO_RESTART_LSB
-#define LF_TIMER_CONTROL2_AUTO_RESTART_MASK WLAN_LF_TIMER_CONTROL2_AUTO_RESTART_MASK
-#define LF_TIMER_CONTROL2_AUTO_RESTART_GET(x) WLAN_LF_TIMER_CONTROL2_AUTO_RESTART_GET(x)
-#define LF_TIMER_CONTROL2_AUTO_RESTART_SET(x) WLAN_LF_TIMER_CONTROL2_AUTO_RESTART_SET(x)
-#define LF_TIMER_CONTROL2_RESET_MSB WLAN_LF_TIMER_CONTROL2_RESET_MSB
-#define LF_TIMER_CONTROL2_RESET_LSB WLAN_LF_TIMER_CONTROL2_RESET_LSB
-#define LF_TIMER_CONTROL2_RESET_MASK WLAN_LF_TIMER_CONTROL2_RESET_MASK
-#define LF_TIMER_CONTROL2_RESET_GET(x) WLAN_LF_TIMER_CONTROL2_RESET_GET(x)
-#define LF_TIMER_CONTROL2_RESET_SET(x) WLAN_LF_TIMER_CONTROL2_RESET_SET(x)
-#define LF_TIMER_STATUS2_ADDRESS WLAN_LF_TIMER_STATUS2_ADDRESS
-#define LF_TIMER_STATUS2_OFFSET WLAN_LF_TIMER_STATUS2_OFFSET
-#define LF_TIMER_STATUS2_INTERRUPT_MSB WLAN_LF_TIMER_STATUS2_INTERRUPT_MSB
-#define LF_TIMER_STATUS2_INTERRUPT_LSB WLAN_LF_TIMER_STATUS2_INTERRUPT_LSB
-#define LF_TIMER_STATUS2_INTERRUPT_MASK WLAN_LF_TIMER_STATUS2_INTERRUPT_MASK
-#define LF_TIMER_STATUS2_INTERRUPT_GET(x) WLAN_LF_TIMER_STATUS2_INTERRUPT_GET(x)
-#define LF_TIMER_STATUS2_INTERRUPT_SET(x) WLAN_LF_TIMER_STATUS2_INTERRUPT_SET(x)
-#define LF_TIMER3_ADDRESS WLAN_LF_TIMER3_ADDRESS
-#define LF_TIMER3_OFFSET WLAN_LF_TIMER3_OFFSET
-#define LF_TIMER3_TARGET_MSB WLAN_LF_TIMER3_TARGET_MSB
-#define LF_TIMER3_TARGET_LSB WLAN_LF_TIMER3_TARGET_LSB
-#define LF_TIMER3_TARGET_MASK WLAN_LF_TIMER3_TARGET_MASK
-#define LF_TIMER3_TARGET_GET(x) WLAN_LF_TIMER3_TARGET_GET(x)
-#define LF_TIMER3_TARGET_SET(x) WLAN_LF_TIMER3_TARGET_SET(x)
-#define LF_TIMER_COUNT3_ADDRESS WLAN_LF_TIMER_COUNT3_ADDRESS
-#define LF_TIMER_COUNT3_OFFSET WLAN_LF_TIMER_COUNT3_OFFSET
-#define LF_TIMER_COUNT3_VALUE_MSB WLAN_LF_TIMER_COUNT3_VALUE_MSB
-#define LF_TIMER_COUNT3_VALUE_LSB WLAN_LF_TIMER_COUNT3_VALUE_LSB
-#define LF_TIMER_COUNT3_VALUE_MASK WLAN_LF_TIMER_COUNT3_VALUE_MASK
-#define LF_TIMER_COUNT3_VALUE_GET(x) WLAN_LF_TIMER_COUNT3_VALUE_GET(x)
-#define LF_TIMER_COUNT3_VALUE_SET(x) WLAN_LF_TIMER_COUNT3_VALUE_SET(x)
-#define LF_TIMER_CONTROL3_ADDRESS WLAN_LF_TIMER_CONTROL3_ADDRESS
-#define LF_TIMER_CONTROL3_OFFSET WLAN_LF_TIMER_CONTROL3_OFFSET
-#define LF_TIMER_CONTROL3_ENABLE_MSB WLAN_LF_TIMER_CONTROL3_ENABLE_MSB
-#define LF_TIMER_CONTROL3_ENABLE_LSB WLAN_LF_TIMER_CONTROL3_ENABLE_LSB
-#define LF_TIMER_CONTROL3_ENABLE_MASK WLAN_LF_TIMER_CONTROL3_ENABLE_MASK
-#define LF_TIMER_CONTROL3_ENABLE_GET(x) WLAN_LF_TIMER_CONTROL3_ENABLE_GET(x)
-#define LF_TIMER_CONTROL3_ENABLE_SET(x) WLAN_LF_TIMER_CONTROL3_ENABLE_SET(x)
-#define LF_TIMER_CONTROL3_AUTO_RESTART_MSB WLAN_LF_TIMER_CONTROL3_AUTO_RESTART_MSB
-#define LF_TIMER_CONTROL3_AUTO_RESTART_LSB WLAN_LF_TIMER_CONTROL3_AUTO_RESTART_LSB
-#define LF_TIMER_CONTROL3_AUTO_RESTART_MASK WLAN_LF_TIMER_CONTROL3_AUTO_RESTART_MASK
-#define LF_TIMER_CONTROL3_AUTO_RESTART_GET(x) WLAN_LF_TIMER_CONTROL3_AUTO_RESTART_GET(x)
-#define LF_TIMER_CONTROL3_AUTO_RESTART_SET(x) WLAN_LF_TIMER_CONTROL3_AUTO_RESTART_SET(x)
-#define LF_TIMER_CONTROL3_RESET_MSB WLAN_LF_TIMER_CONTROL3_RESET_MSB
-#define LF_TIMER_CONTROL3_RESET_LSB WLAN_LF_TIMER_CONTROL3_RESET_LSB
-#define LF_TIMER_CONTROL3_RESET_MASK WLAN_LF_TIMER_CONTROL3_RESET_MASK
-#define LF_TIMER_CONTROL3_RESET_GET(x) WLAN_LF_TIMER_CONTROL3_RESET_GET(x)
-#define LF_TIMER_CONTROL3_RESET_SET(x) WLAN_LF_TIMER_CONTROL3_RESET_SET(x)
-#define LF_TIMER_STATUS3_ADDRESS WLAN_LF_TIMER_STATUS3_ADDRESS
-#define LF_TIMER_STATUS3_OFFSET WLAN_LF_TIMER_STATUS3_OFFSET
-#define LF_TIMER_STATUS3_INTERRUPT_MSB WLAN_LF_TIMER_STATUS3_INTERRUPT_MSB
-#define LF_TIMER_STATUS3_INTERRUPT_LSB WLAN_LF_TIMER_STATUS3_INTERRUPT_LSB
-#define LF_TIMER_STATUS3_INTERRUPT_MASK WLAN_LF_TIMER_STATUS3_INTERRUPT_MASK
-#define LF_TIMER_STATUS3_INTERRUPT_GET(x) WLAN_LF_TIMER_STATUS3_INTERRUPT_GET(x)
-#define LF_TIMER_STATUS3_INTERRUPT_SET(x) WLAN_LF_TIMER_STATUS3_INTERRUPT_SET(x)
-#define HF_TIMER_ADDRESS WLAN_HF_TIMER_ADDRESS
-#define HF_TIMER_OFFSET WLAN_HF_TIMER_OFFSET
-#define HF_TIMER_TARGET_MSB WLAN_HF_TIMER_TARGET_MSB
-#define HF_TIMER_TARGET_LSB WLAN_HF_TIMER_TARGET_LSB
-#define HF_TIMER_TARGET_MASK WLAN_HF_TIMER_TARGET_MASK
-#define HF_TIMER_TARGET_GET(x) WLAN_HF_TIMER_TARGET_GET(x)
-#define HF_TIMER_TARGET_SET(x) WLAN_HF_TIMER_TARGET_SET(x)
-#define HF_TIMER_COUNT_ADDRESS WLAN_HF_TIMER_COUNT_ADDRESS
-#define HF_TIMER_COUNT_OFFSET WLAN_HF_TIMER_COUNT_OFFSET
-#define HF_TIMER_COUNT_VALUE_MSB WLAN_HF_TIMER_COUNT_VALUE_MSB
-#define HF_TIMER_COUNT_VALUE_LSB WLAN_HF_TIMER_COUNT_VALUE_LSB
-#define HF_TIMER_COUNT_VALUE_MASK WLAN_HF_TIMER_COUNT_VALUE_MASK
-#define HF_TIMER_COUNT_VALUE_GET(x) WLAN_HF_TIMER_COUNT_VALUE_GET(x)
-#define HF_TIMER_COUNT_VALUE_SET(x) WLAN_HF_TIMER_COUNT_VALUE_SET(x)
-#define HF_LF_COUNT_ADDRESS WLAN_HF_LF_COUNT_ADDRESS
-#define HF_LF_COUNT_OFFSET WLAN_HF_LF_COUNT_OFFSET
-#define HF_LF_COUNT_VALUE_MSB WLAN_HF_LF_COUNT_VALUE_MSB
-#define HF_LF_COUNT_VALUE_LSB WLAN_HF_LF_COUNT_VALUE_LSB
-#define HF_LF_COUNT_VALUE_MASK WLAN_HF_LF_COUNT_VALUE_MASK
-#define HF_LF_COUNT_VALUE_GET(x) WLAN_HF_LF_COUNT_VALUE_GET(x)
-#define HF_LF_COUNT_VALUE_SET(x) WLAN_HF_LF_COUNT_VALUE_SET(x)
-#define HF_TIMER_CONTROL_ADDRESS WLAN_HF_TIMER_CONTROL_ADDRESS
-#define HF_TIMER_CONTROL_OFFSET WLAN_HF_TIMER_CONTROL_OFFSET
-#define HF_TIMER_CONTROL_ENABLE_MSB WLAN_HF_TIMER_CONTROL_ENABLE_MSB
-#define HF_TIMER_CONTROL_ENABLE_LSB WLAN_HF_TIMER_CONTROL_ENABLE_LSB
-#define HF_TIMER_CONTROL_ENABLE_MASK WLAN_HF_TIMER_CONTROL_ENABLE_MASK
-#define HF_TIMER_CONTROL_ENABLE_GET(x) WLAN_HF_TIMER_CONTROL_ENABLE_GET(x)
-#define HF_TIMER_CONTROL_ENABLE_SET(x) WLAN_HF_TIMER_CONTROL_ENABLE_SET(x)
-#define HF_TIMER_CONTROL_ON_MSB WLAN_HF_TIMER_CONTROL_ON_MSB
-#define HF_TIMER_CONTROL_ON_LSB WLAN_HF_TIMER_CONTROL_ON_LSB
-#define HF_TIMER_CONTROL_ON_MASK WLAN_HF_TIMER_CONTROL_ON_MASK
-#define HF_TIMER_CONTROL_ON_GET(x) WLAN_HF_TIMER_CONTROL_ON_GET(x)
-#define HF_TIMER_CONTROL_ON_SET(x) WLAN_HF_TIMER_CONTROL_ON_SET(x)
-#define HF_TIMER_CONTROL_AUTO_RESTART_MSB WLAN_HF_TIMER_CONTROL_AUTO_RESTART_MSB
-#define HF_TIMER_CONTROL_AUTO_RESTART_LSB WLAN_HF_TIMER_CONTROL_AUTO_RESTART_LSB
-#define HF_TIMER_CONTROL_AUTO_RESTART_MASK WLAN_HF_TIMER_CONTROL_AUTO_RESTART_MASK
-#define HF_TIMER_CONTROL_AUTO_RESTART_GET(x) WLAN_HF_TIMER_CONTROL_AUTO_RESTART_GET(x)
-#define HF_TIMER_CONTROL_AUTO_RESTART_SET(x) WLAN_HF_TIMER_CONTROL_AUTO_RESTART_SET(x)
-#define HF_TIMER_CONTROL_RESET_MSB WLAN_HF_TIMER_CONTROL_RESET_MSB
-#define HF_TIMER_CONTROL_RESET_LSB WLAN_HF_TIMER_CONTROL_RESET_LSB
-#define HF_TIMER_CONTROL_RESET_MASK WLAN_HF_TIMER_CONTROL_RESET_MASK
-#define HF_TIMER_CONTROL_RESET_GET(x) WLAN_HF_TIMER_CONTROL_RESET_GET(x)
-#define HF_TIMER_CONTROL_RESET_SET(x) WLAN_HF_TIMER_CONTROL_RESET_SET(x)
-#define HF_TIMER_STATUS_ADDRESS WLAN_HF_TIMER_STATUS_ADDRESS
-#define HF_TIMER_STATUS_OFFSET WLAN_HF_TIMER_STATUS_OFFSET
-#define HF_TIMER_STATUS_INTERRUPT_MSB WLAN_HF_TIMER_STATUS_INTERRUPT_MSB
-#define HF_TIMER_STATUS_INTERRUPT_LSB WLAN_HF_TIMER_STATUS_INTERRUPT_LSB
-#define HF_TIMER_STATUS_INTERRUPT_MASK WLAN_HF_TIMER_STATUS_INTERRUPT_MASK
-#define HF_TIMER_STATUS_INTERRUPT_GET(x) WLAN_HF_TIMER_STATUS_INTERRUPT_GET(x)
-#define HF_TIMER_STATUS_INTERRUPT_SET(x) WLAN_HF_TIMER_STATUS_INTERRUPT_SET(x)
-#define RTC_CONTROL_ADDRESS WLAN_RTC_CONTROL_ADDRESS
-#define RTC_CONTROL_OFFSET WLAN_RTC_CONTROL_OFFSET
-#define RTC_CONTROL_ENABLE_MSB WLAN_RTC_CONTROL_ENABLE_MSB
-#define RTC_CONTROL_ENABLE_LSB WLAN_RTC_CONTROL_ENABLE_LSB
-#define RTC_CONTROL_ENABLE_MASK WLAN_RTC_CONTROL_ENABLE_MASK
-#define RTC_CONTROL_ENABLE_GET(x) WLAN_RTC_CONTROL_ENABLE_GET(x)
-#define RTC_CONTROL_ENABLE_SET(x) WLAN_RTC_CONTROL_ENABLE_SET(x)
-#define RTC_CONTROL_LOAD_RTC_MSB WLAN_RTC_CONTROL_LOAD_RTC_MSB
-#define RTC_CONTROL_LOAD_RTC_LSB WLAN_RTC_CONTROL_LOAD_RTC_LSB
-#define RTC_CONTROL_LOAD_RTC_MASK WLAN_RTC_CONTROL_LOAD_RTC_MASK
-#define RTC_CONTROL_LOAD_RTC_GET(x) WLAN_RTC_CONTROL_LOAD_RTC_GET(x)
-#define RTC_CONTROL_LOAD_RTC_SET(x) WLAN_RTC_CONTROL_LOAD_RTC_SET(x)
-#define RTC_CONTROL_LOAD_ALARM_MSB WLAN_RTC_CONTROL_LOAD_ALARM_MSB
-#define RTC_CONTROL_LOAD_ALARM_LSB WLAN_RTC_CONTROL_LOAD_ALARM_LSB
-#define RTC_CONTROL_LOAD_ALARM_MASK WLAN_RTC_CONTROL_LOAD_ALARM_MASK
-#define RTC_CONTROL_LOAD_ALARM_GET(x) WLAN_RTC_CONTROL_LOAD_ALARM_GET(x)
-#define RTC_CONTROL_LOAD_ALARM_SET(x) WLAN_RTC_CONTROL_LOAD_ALARM_SET(x)
-#define RTC_TIME_ADDRESS WLAN_RTC_TIME_ADDRESS
-#define RTC_TIME_OFFSET WLAN_RTC_TIME_OFFSET
-#define RTC_TIME_WEEK_DAY_MSB WLAN_RTC_TIME_WEEK_DAY_MSB
-#define RTC_TIME_WEEK_DAY_LSB WLAN_RTC_TIME_WEEK_DAY_LSB
-#define RTC_TIME_WEEK_DAY_MASK WLAN_RTC_TIME_WEEK_DAY_MASK
-#define RTC_TIME_WEEK_DAY_GET(x) WLAN_RTC_TIME_WEEK_DAY_GET(x)
-#define RTC_TIME_WEEK_DAY_SET(x) WLAN_RTC_TIME_WEEK_DAY_SET(x)
-#define RTC_TIME_HOUR_MSB WLAN_RTC_TIME_HOUR_MSB
-#define RTC_TIME_HOUR_LSB WLAN_RTC_TIME_HOUR_LSB
-#define RTC_TIME_HOUR_MASK WLAN_RTC_TIME_HOUR_MASK
-#define RTC_TIME_HOUR_GET(x) WLAN_RTC_TIME_HOUR_GET(x)
-#define RTC_TIME_HOUR_SET(x) WLAN_RTC_TIME_HOUR_SET(x)
-#define RTC_TIME_MINUTE_MSB WLAN_RTC_TIME_MINUTE_MSB
-#define RTC_TIME_MINUTE_LSB WLAN_RTC_TIME_MINUTE_LSB
-#define RTC_TIME_MINUTE_MASK WLAN_RTC_TIME_MINUTE_MASK
-#define RTC_TIME_MINUTE_GET(x) WLAN_RTC_TIME_MINUTE_GET(x)
-#define RTC_TIME_MINUTE_SET(x) WLAN_RTC_TIME_MINUTE_SET(x)
-#define RTC_TIME_SECOND_MSB WLAN_RTC_TIME_SECOND_MSB
-#define RTC_TIME_SECOND_LSB WLAN_RTC_TIME_SECOND_LSB
-#define RTC_TIME_SECOND_MASK WLAN_RTC_TIME_SECOND_MASK
-#define RTC_TIME_SECOND_GET(x) WLAN_RTC_TIME_SECOND_GET(x)
-#define RTC_TIME_SECOND_SET(x) WLAN_RTC_TIME_SECOND_SET(x)
-#define RTC_DATE_ADDRESS WLAN_RTC_DATE_ADDRESS
-#define RTC_DATE_OFFSET WLAN_RTC_DATE_OFFSET
-#define RTC_DATE_YEAR_MSB WLAN_RTC_DATE_YEAR_MSB
-#define RTC_DATE_YEAR_LSB WLAN_RTC_DATE_YEAR_LSB
-#define RTC_DATE_YEAR_MASK WLAN_RTC_DATE_YEAR_MASK
-#define RTC_DATE_YEAR_GET(x) WLAN_RTC_DATE_YEAR_GET(x)
-#define RTC_DATE_YEAR_SET(x) WLAN_RTC_DATE_YEAR_SET(x)
-#define RTC_DATE_MONTH_MSB WLAN_RTC_DATE_MONTH_MSB
-#define RTC_DATE_MONTH_LSB WLAN_RTC_DATE_MONTH_LSB
-#define RTC_DATE_MONTH_MASK WLAN_RTC_DATE_MONTH_MASK
-#define RTC_DATE_MONTH_GET(x) WLAN_RTC_DATE_MONTH_GET(x)
-#define RTC_DATE_MONTH_SET(x) WLAN_RTC_DATE_MONTH_SET(x)
-#define RTC_DATE_MONTH_DAY_MSB WLAN_RTC_DATE_MONTH_DAY_MSB
-#define RTC_DATE_MONTH_DAY_LSB WLAN_RTC_DATE_MONTH_DAY_LSB
-#define RTC_DATE_MONTH_DAY_MASK WLAN_RTC_DATE_MONTH_DAY_MASK
-#define RTC_DATE_MONTH_DAY_GET(x) WLAN_RTC_DATE_MONTH_DAY_GET(x)
-#define RTC_DATE_MONTH_DAY_SET(x) WLAN_RTC_DATE_MONTH_DAY_SET(x)
-#define RTC_SET_TIME_ADDRESS WLAN_RTC_SET_TIME_ADDRESS
-#define RTC_SET_TIME_OFFSET WLAN_RTC_SET_TIME_OFFSET
-#define RTC_SET_TIME_WEEK_DAY_MSB WLAN_RTC_SET_TIME_WEEK_DAY_MSB
-#define RTC_SET_TIME_WEEK_DAY_LSB WLAN_RTC_SET_TIME_WEEK_DAY_LSB
-#define RTC_SET_TIME_WEEK_DAY_MASK WLAN_RTC_SET_TIME_WEEK_DAY_MASK
-#define RTC_SET_TIME_WEEK_DAY_GET(x) WLAN_RTC_SET_TIME_WEEK_DAY_GET(x)
-#define RTC_SET_TIME_WEEK_DAY_SET(x) WLAN_RTC_SET_TIME_WEEK_DAY_SET(x)
-#define RTC_SET_TIME_HOUR_MSB WLAN_RTC_SET_TIME_HOUR_MSB
-#define RTC_SET_TIME_HOUR_LSB WLAN_RTC_SET_TIME_HOUR_LSB
-#define RTC_SET_TIME_HOUR_MASK WLAN_RTC_SET_TIME_HOUR_MASK
-#define RTC_SET_TIME_HOUR_GET(x) WLAN_RTC_SET_TIME_HOUR_GET(x)
-#define RTC_SET_TIME_HOUR_SET(x) WLAN_RTC_SET_TIME_HOUR_SET(x)
-#define RTC_SET_TIME_MINUTE_MSB WLAN_RTC_SET_TIME_MINUTE_MSB
-#define RTC_SET_TIME_MINUTE_LSB WLAN_RTC_SET_TIME_MINUTE_LSB
-#define RTC_SET_TIME_MINUTE_MASK WLAN_RTC_SET_TIME_MINUTE_MASK
-#define RTC_SET_TIME_MINUTE_GET(x) WLAN_RTC_SET_TIME_MINUTE_GET(x)
-#define RTC_SET_TIME_MINUTE_SET(x) WLAN_RTC_SET_TIME_MINUTE_SET(x)
-#define RTC_SET_TIME_SECOND_MSB WLAN_RTC_SET_TIME_SECOND_MSB
-#define RTC_SET_TIME_SECOND_LSB WLAN_RTC_SET_TIME_SECOND_LSB
-#define RTC_SET_TIME_SECOND_MASK WLAN_RTC_SET_TIME_SECOND_MASK
-#define RTC_SET_TIME_SECOND_GET(x) WLAN_RTC_SET_TIME_SECOND_GET(x)
-#define RTC_SET_TIME_SECOND_SET(x) WLAN_RTC_SET_TIME_SECOND_SET(x)
-#define RTC_SET_DATE_ADDRESS WLAN_RTC_SET_DATE_ADDRESS
-#define RTC_SET_DATE_OFFSET WLAN_RTC_SET_DATE_OFFSET
-#define RTC_SET_DATE_YEAR_MSB WLAN_RTC_SET_DATE_YEAR_MSB
-#define RTC_SET_DATE_YEAR_LSB WLAN_RTC_SET_DATE_YEAR_LSB
-#define RTC_SET_DATE_YEAR_MASK WLAN_RTC_SET_DATE_YEAR_MASK
-#define RTC_SET_DATE_YEAR_GET(x) WLAN_RTC_SET_DATE_YEAR_GET(x)
-#define RTC_SET_DATE_YEAR_SET(x) WLAN_RTC_SET_DATE_YEAR_SET(x)
-#define RTC_SET_DATE_MONTH_MSB WLAN_RTC_SET_DATE_MONTH_MSB
-#define RTC_SET_DATE_MONTH_LSB WLAN_RTC_SET_DATE_MONTH_LSB
-#define RTC_SET_DATE_MONTH_MASK WLAN_RTC_SET_DATE_MONTH_MASK
-#define RTC_SET_DATE_MONTH_GET(x) WLAN_RTC_SET_DATE_MONTH_GET(x)
-#define RTC_SET_DATE_MONTH_SET(x) WLAN_RTC_SET_DATE_MONTH_SET(x)
-#define RTC_SET_DATE_MONTH_DAY_MSB WLAN_RTC_SET_DATE_MONTH_DAY_MSB
-#define RTC_SET_DATE_MONTH_DAY_LSB WLAN_RTC_SET_DATE_MONTH_DAY_LSB
-#define RTC_SET_DATE_MONTH_DAY_MASK WLAN_RTC_SET_DATE_MONTH_DAY_MASK
-#define RTC_SET_DATE_MONTH_DAY_GET(x) WLAN_RTC_SET_DATE_MONTH_DAY_GET(x)
-#define RTC_SET_DATE_MONTH_DAY_SET(x) WLAN_RTC_SET_DATE_MONTH_DAY_SET(x)
-#define RTC_SET_ALARM_ADDRESS WLAN_RTC_SET_ALARM_ADDRESS
-#define RTC_SET_ALARM_OFFSET WLAN_RTC_SET_ALARM_OFFSET
-#define RTC_SET_ALARM_HOUR_MSB WLAN_RTC_SET_ALARM_HOUR_MSB
-#define RTC_SET_ALARM_HOUR_LSB WLAN_RTC_SET_ALARM_HOUR_LSB
-#define RTC_SET_ALARM_HOUR_MASK WLAN_RTC_SET_ALARM_HOUR_MASK
-#define RTC_SET_ALARM_HOUR_GET(x) WLAN_RTC_SET_ALARM_HOUR_GET(x)
-#define RTC_SET_ALARM_HOUR_SET(x) WLAN_RTC_SET_ALARM_HOUR_SET(x)
-#define RTC_SET_ALARM_MINUTE_MSB WLAN_RTC_SET_ALARM_MINUTE_MSB
-#define RTC_SET_ALARM_MINUTE_LSB WLAN_RTC_SET_ALARM_MINUTE_LSB
-#define RTC_SET_ALARM_MINUTE_MASK WLAN_RTC_SET_ALARM_MINUTE_MASK
-#define RTC_SET_ALARM_MINUTE_GET(x) WLAN_RTC_SET_ALARM_MINUTE_GET(x)
-#define RTC_SET_ALARM_MINUTE_SET(x) WLAN_RTC_SET_ALARM_MINUTE_SET(x)
-#define RTC_SET_ALARM_SECOND_MSB WLAN_RTC_SET_ALARM_SECOND_MSB
-#define RTC_SET_ALARM_SECOND_LSB WLAN_RTC_SET_ALARM_SECOND_LSB
-#define RTC_SET_ALARM_SECOND_MASK WLAN_RTC_SET_ALARM_SECOND_MASK
-#define RTC_SET_ALARM_SECOND_GET(x) WLAN_RTC_SET_ALARM_SECOND_GET(x)
-#define RTC_SET_ALARM_SECOND_SET(x) WLAN_RTC_SET_ALARM_SECOND_SET(x)
-#define RTC_CONFIG_ADDRESS WLAN_RTC_CONFIG_ADDRESS
-#define RTC_CONFIG_OFFSET WLAN_RTC_CONFIG_OFFSET
-#define RTC_CONFIG_BCD_MSB WLAN_RTC_CONFIG_BCD_MSB
-#define RTC_CONFIG_BCD_LSB WLAN_RTC_CONFIG_BCD_LSB
-#define RTC_CONFIG_BCD_MASK WLAN_RTC_CONFIG_BCD_MASK
-#define RTC_CONFIG_BCD_GET(x) WLAN_RTC_CONFIG_BCD_GET(x)
-#define RTC_CONFIG_BCD_SET(x) WLAN_RTC_CONFIG_BCD_SET(x)
-#define RTC_CONFIG_TWELVE_HOUR_MSB WLAN_RTC_CONFIG_TWELVE_HOUR_MSB
-#define RTC_CONFIG_TWELVE_HOUR_LSB WLAN_RTC_CONFIG_TWELVE_HOUR_LSB
-#define RTC_CONFIG_TWELVE_HOUR_MASK WLAN_RTC_CONFIG_TWELVE_HOUR_MASK
-#define RTC_CONFIG_TWELVE_HOUR_GET(x) WLAN_RTC_CONFIG_TWELVE_HOUR_GET(x)
-#define RTC_CONFIG_TWELVE_HOUR_SET(x) WLAN_RTC_CONFIG_TWELVE_HOUR_SET(x)
-#define RTC_CONFIG_DSE_MSB WLAN_RTC_CONFIG_DSE_MSB
-#define RTC_CONFIG_DSE_LSB WLAN_RTC_CONFIG_DSE_LSB
-#define RTC_CONFIG_DSE_MASK WLAN_RTC_CONFIG_DSE_MASK
-#define RTC_CONFIG_DSE_GET(x) WLAN_RTC_CONFIG_DSE_GET(x)
-#define RTC_CONFIG_DSE_SET(x) WLAN_RTC_CONFIG_DSE_SET(x)
-#define RTC_ALARM_STATUS_ADDRESS WLAN_RTC_ALARM_STATUS_ADDRESS
-#define RTC_ALARM_STATUS_OFFSET WLAN_RTC_ALARM_STATUS_OFFSET
-#define RTC_ALARM_STATUS_ENABLE_MSB WLAN_RTC_ALARM_STATUS_ENABLE_MSB
-#define RTC_ALARM_STATUS_ENABLE_LSB WLAN_RTC_ALARM_STATUS_ENABLE_LSB
-#define RTC_ALARM_STATUS_ENABLE_MASK WLAN_RTC_ALARM_STATUS_ENABLE_MASK
-#define RTC_ALARM_STATUS_ENABLE_GET(x) WLAN_RTC_ALARM_STATUS_ENABLE_GET(x)
-#define RTC_ALARM_STATUS_ENABLE_SET(x) WLAN_RTC_ALARM_STATUS_ENABLE_SET(x)
-#define RTC_ALARM_STATUS_INTERRUPT_MSB WLAN_RTC_ALARM_STATUS_INTERRUPT_MSB
-#define RTC_ALARM_STATUS_INTERRUPT_LSB WLAN_RTC_ALARM_STATUS_INTERRUPT_LSB
-#define RTC_ALARM_STATUS_INTERRUPT_MASK WLAN_RTC_ALARM_STATUS_INTERRUPT_MASK
-#define RTC_ALARM_STATUS_INTERRUPT_GET(x) WLAN_RTC_ALARM_STATUS_INTERRUPT_GET(x)
-#define RTC_ALARM_STATUS_INTERRUPT_SET(x) WLAN_RTC_ALARM_STATUS_INTERRUPT_SET(x)
-#define UART_WAKEUP_ADDRESS WLAN_UART_WAKEUP_ADDRESS
-#define UART_WAKEUP_OFFSET WLAN_UART_WAKEUP_OFFSET
-#define UART_WAKEUP_ENABLE_MSB WLAN_UART_WAKEUP_ENABLE_MSB
-#define UART_WAKEUP_ENABLE_LSB WLAN_UART_WAKEUP_ENABLE_LSB
-#define UART_WAKEUP_ENABLE_MASK WLAN_UART_WAKEUP_ENABLE_MASK
-#define UART_WAKEUP_ENABLE_GET(x) WLAN_UART_WAKEUP_ENABLE_GET(x)
-#define UART_WAKEUP_ENABLE_SET(x) WLAN_UART_WAKEUP_ENABLE_SET(x)
 #define RESET_CAUSE_ADDRESS WLAN_RESET_CAUSE_ADDRESS
 #define RESET_CAUSE_OFFSET WLAN_RESET_CAUSE_OFFSET
 #define RESET_CAUSE_LAST_MSB WLAN_RESET_CAUSE_LAST_MSB
 #define SYSTEM_SLEEP_DISABLE_MASK WLAN_SYSTEM_SLEEP_DISABLE_MASK
 #define SYSTEM_SLEEP_DISABLE_GET(x) WLAN_SYSTEM_SLEEP_DISABLE_GET(x)
 #define SYSTEM_SLEEP_DISABLE_SET(x) WLAN_SYSTEM_SLEEP_DISABLE_SET(x)
-#define SDIO_WRAPPER_ADDRESS WLAN_SDIO_WRAPPER_ADDRESS
-#define SDIO_WRAPPER_OFFSET WLAN_SDIO_WRAPPER_OFFSET
-#define SDIO_WRAPPER_SLEEP_MSB WLAN_SDIO_WRAPPER_SLEEP_MSB
-#define SDIO_WRAPPER_SLEEP_LSB WLAN_SDIO_WRAPPER_SLEEP_LSB
-#define SDIO_WRAPPER_SLEEP_MASK WLAN_SDIO_WRAPPER_SLEEP_MASK
-#define SDIO_WRAPPER_SLEEP_GET(x) WLAN_SDIO_WRAPPER_SLEEP_GET(x)
-#define SDIO_WRAPPER_SLEEP_SET(x) WLAN_SDIO_WRAPPER_SLEEP_SET(x)
-#define SDIO_WRAPPER_WAKEUP_MSB WLAN_SDIO_WRAPPER_WAKEUP_MSB
-#define SDIO_WRAPPER_WAKEUP_LSB WLAN_SDIO_WRAPPER_WAKEUP_LSB
-#define SDIO_WRAPPER_WAKEUP_MASK WLAN_SDIO_WRAPPER_WAKEUP_MASK
-#define SDIO_WRAPPER_WAKEUP_GET(x) WLAN_SDIO_WRAPPER_WAKEUP_GET(x)
-#define SDIO_WRAPPER_WAKEUP_SET(x) WLAN_SDIO_WRAPPER_WAKEUP_SET(x)
-#define SDIO_WRAPPER_SOC_ON_MSB WLAN_SDIO_WRAPPER_SOC_ON_MSB
-#define SDIO_WRAPPER_SOC_ON_LSB WLAN_SDIO_WRAPPER_SOC_ON_LSB
-#define SDIO_WRAPPER_SOC_ON_MASK WLAN_SDIO_WRAPPER_SOC_ON_MASK
-#define SDIO_WRAPPER_SOC_ON_GET(x) WLAN_SDIO_WRAPPER_SOC_ON_GET(x)
-#define SDIO_WRAPPER_SOC_ON_SET(x) WLAN_SDIO_WRAPPER_SOC_ON_SET(x)
-#define SDIO_WRAPPER_ON_MSB WLAN_SDIO_WRAPPER_ON_MSB
-#define SDIO_WRAPPER_ON_LSB WLAN_SDIO_WRAPPER_ON_LSB
-#define SDIO_WRAPPER_ON_MASK WLAN_SDIO_WRAPPER_ON_MASK
-#define SDIO_WRAPPER_ON_GET(x) WLAN_SDIO_WRAPPER_ON_GET(x)
-#define SDIO_WRAPPER_ON_SET(x) WLAN_SDIO_WRAPPER_ON_SET(x)
-#define MAC_SLEEP_CONTROL_ADDRESS WLAN_MAC_SLEEP_CONTROL_ADDRESS
-#define MAC_SLEEP_CONTROL_OFFSET WLAN_MAC_SLEEP_CONTROL_OFFSET
-#define MAC_SLEEP_CONTROL_ENABLE_MSB WLAN_MAC_SLEEP_CONTROL_ENABLE_MSB
-#define MAC_SLEEP_CONTROL_ENABLE_LSB WLAN_MAC_SLEEP_CONTROL_ENABLE_LSB
-#define MAC_SLEEP_CONTROL_ENABLE_MASK WLAN_MAC_SLEEP_CONTROL_ENABLE_MASK
-#define MAC_SLEEP_CONTROL_ENABLE_GET(x) WLAN_MAC_SLEEP_CONTROL_ENABLE_GET(x)
-#define MAC_SLEEP_CONTROL_ENABLE_SET(x) WLAN_MAC_SLEEP_CONTROL_ENABLE_SET(x)
-#define KEEP_AWAKE_ADDRESS WLAN_KEEP_AWAKE_ADDRESS
-#define KEEP_AWAKE_OFFSET WLAN_KEEP_AWAKE_OFFSET
-#define KEEP_AWAKE_COUNT_MSB WLAN_KEEP_AWAKE_COUNT_MSB
-#define KEEP_AWAKE_COUNT_LSB WLAN_KEEP_AWAKE_COUNT_LSB
-#define KEEP_AWAKE_COUNT_MASK WLAN_KEEP_AWAKE_COUNT_MASK
-#define KEEP_AWAKE_COUNT_GET(x) WLAN_KEEP_AWAKE_COUNT_GET(x)
-#define KEEP_AWAKE_COUNT_SET(x) WLAN_KEEP_AWAKE_COUNT_SET(x)
-#define LPO_CAL_TIME_ADDRESS WLAN_LPO_CAL_TIME_ADDRESS
-#define LPO_CAL_TIME_OFFSET WLAN_LPO_CAL_TIME_OFFSET
-#define LPO_CAL_TIME_LENGTH_MSB WLAN_LPO_CAL_TIME_LENGTH_MSB
-#define LPO_CAL_TIME_LENGTH_LSB WLAN_LPO_CAL_TIME_LENGTH_LSB
-#define LPO_CAL_TIME_LENGTH_MASK WLAN_LPO_CAL_TIME_LENGTH_MASK
-#define LPO_CAL_TIME_LENGTH_GET(x) WLAN_LPO_CAL_TIME_LENGTH_GET(x)
-#define LPO_CAL_TIME_LENGTH_SET(x) WLAN_LPO_CAL_TIME_LENGTH_SET(x)
 #define LPO_INIT_DIVIDEND_INT_ADDRESS WLAN_LPO_INIT_DIVIDEND_INT_ADDRESS
 #define LPO_INIT_DIVIDEND_INT_OFFSET WLAN_LPO_INIT_DIVIDEND_INT_OFFSET
 #define LPO_INIT_DIVIDEND_INT_VALUE_MSB WLAN_LPO_INIT_DIVIDEND_INT_VALUE_MSB
 #define LPO_CAL_COUNT_MASK WLAN_LPO_CAL_COUNT_MASK
 #define LPO_CAL_COUNT_GET(x) WLAN_LPO_CAL_COUNT_GET(x)
 #define LPO_CAL_COUNT_SET(x) WLAN_LPO_CAL_COUNT_SET(x)
-#define LPO_CAL_TEST_CONTROL_ADDRESS WLAN_LPO_CAL_TEST_CONTROL_ADDRESS
-#define LPO_CAL_TEST_CONTROL_OFFSET WLAN_LPO_CAL_TEST_CONTROL_OFFSET
-#define LPO_CAL_TEST_CONTROL_ENABLE_MSB WLAN_LPO_CAL_TEST_CONTROL_ENABLE_MSB
-#define LPO_CAL_TEST_CONTROL_ENABLE_LSB WLAN_LPO_CAL_TEST_CONTROL_ENABLE_LSB
-#define LPO_CAL_TEST_CONTROL_ENABLE_MASK WLAN_LPO_CAL_TEST_CONTROL_ENABLE_MASK
-#define LPO_CAL_TEST_CONTROL_ENABLE_GET(x) WLAN_LPO_CAL_TEST_CONTROL_ENABLE_GET(x)
-#define LPO_CAL_TEST_CONTROL_ENABLE_SET(x) WLAN_LPO_CAL_TEST_CONTROL_ENABLE_SET(x)
-#define LPO_CAL_TEST_CONTROL_RTC_CYCLES_MSB WLAN_LPO_CAL_TEST_CONTROL_RTC_CYCLES_MSB
-#define LPO_CAL_TEST_CONTROL_RTC_CYCLES_LSB WLAN_LPO_CAL_TEST_CONTROL_RTC_CYCLES_LSB
-#define LPO_CAL_TEST_CONTROL_RTC_CYCLES_MASK WLAN_LPO_CAL_TEST_CONTROL_RTC_CYCLES_MASK
-#define LPO_CAL_TEST_CONTROL_RTC_CYCLES_GET(x) WLAN_LPO_CAL_TEST_CONTROL_RTC_CYCLES_GET(x)
-#define LPO_CAL_TEST_CONTROL_RTC_CYCLES_SET(x) WLAN_LPO_CAL_TEST_CONTROL_RTC_CYCLES_SET(x)
-#define LPO_CAL_TEST_STATUS_ADDRESS WLAN_LPO_CAL_TEST_STATUS_ADDRESS
-#define LPO_CAL_TEST_STATUS_OFFSET WLAN_LPO_CAL_TEST_STATUS_OFFSET
-#define LPO_CAL_TEST_STATUS_READY_MSB WLAN_LPO_CAL_TEST_STATUS_READY_MSB
-#define LPO_CAL_TEST_STATUS_READY_LSB WLAN_LPO_CAL_TEST_STATUS_READY_LSB
-#define LPO_CAL_TEST_STATUS_READY_MASK WLAN_LPO_CAL_TEST_STATUS_READY_MASK
-#define LPO_CAL_TEST_STATUS_READY_GET(x) WLAN_LPO_CAL_TEST_STATUS_READY_GET(x)
-#define LPO_CAL_TEST_STATUS_READY_SET(x) WLAN_LPO_CAL_TEST_STATUS_READY_SET(x)
-#define LPO_CAL_TEST_STATUS_COUNT_MSB WLAN_LPO_CAL_TEST_STATUS_COUNT_MSB
-#define LPO_CAL_TEST_STATUS_COUNT_LSB WLAN_LPO_CAL_TEST_STATUS_COUNT_LSB
-#define LPO_CAL_TEST_STATUS_COUNT_MASK WLAN_LPO_CAL_TEST_STATUS_COUNT_MASK
-#define LPO_CAL_TEST_STATUS_COUNT_GET(x) WLAN_LPO_CAL_TEST_STATUS_COUNT_GET(x)
-#define LPO_CAL_TEST_STATUS_COUNT_SET(x) WLAN_LPO_CAL_TEST_STATUS_COUNT_SET(x)
-#define CHIP_ID_ADDRESS WLAN_CHIP_ID_ADDRESS
-#define CHIP_ID_OFFSET WLAN_CHIP_ID_OFFSET
-#define CHIP_ID_DEVICE_ID_MSB WLAN_CHIP_ID_DEVICE_ID_MSB
-#define CHIP_ID_DEVICE_ID_LSB WLAN_CHIP_ID_DEVICE_ID_LSB
-#define CHIP_ID_DEVICE_ID_MASK WLAN_CHIP_ID_DEVICE_ID_MASK
-#define CHIP_ID_DEVICE_ID_GET(x) WLAN_CHIP_ID_DEVICE_ID_GET(x)
-#define CHIP_ID_DEVICE_ID_SET(x) WLAN_CHIP_ID_DEVICE_ID_SET(x)
-#define CHIP_ID_CONFIG_ID_MSB WLAN_CHIP_ID_CONFIG_ID_MSB
-#define CHIP_ID_CONFIG_ID_LSB WLAN_CHIP_ID_CONFIG_ID_LSB
-#define CHIP_ID_CONFIG_ID_MASK WLAN_CHIP_ID_CONFIG_ID_MASK
-#define CHIP_ID_CONFIG_ID_GET(x) WLAN_CHIP_ID_CONFIG_ID_GET(x)
-#define CHIP_ID_CONFIG_ID_SET(x) WLAN_CHIP_ID_CONFIG_ID_SET(x)
-#define CHIP_ID_VERSION_ID_MSB WLAN_CHIP_ID_VERSION_ID_MSB
-#define CHIP_ID_VERSION_ID_LSB WLAN_CHIP_ID_VERSION_ID_LSB
-#define CHIP_ID_VERSION_ID_MASK WLAN_CHIP_ID_VERSION_ID_MASK
-#define CHIP_ID_VERSION_ID_GET(x) WLAN_CHIP_ID_VERSION_ID_GET(x)
-#define CHIP_ID_VERSION_ID_SET(x) WLAN_CHIP_ID_VERSION_ID_SET(x)
-#define DERIVED_RTC_CLK_ADDRESS WLAN_DERIVED_RTC_CLK_ADDRESS
-#define DERIVED_RTC_CLK_OFFSET WLAN_DERIVED_RTC_CLK_OFFSET
-#define DERIVED_RTC_CLK_EXTERNAL_DETECT_EN_MSB WLAN_DERIVED_RTC_CLK_EXTERNAL_DETECT_EN_MSB
-#define DERIVED_RTC_CLK_EXTERNAL_DETECT_EN_LSB WLAN_DERIVED_RTC_CLK_EXTERNAL_DETECT_EN_LSB
-#define DERIVED_RTC_CLK_EXTERNAL_DETECT_EN_MASK WLAN_DERIVED_RTC_CLK_EXTERNAL_DETECT_EN_MASK
-#define DERIVED_RTC_CLK_EXTERNAL_DETECT_EN_GET(x) WLAN_DERIVED_RTC_CLK_EXTERNAL_DETECT_EN_GET(x)
-#define DERIVED_RTC_CLK_EXTERNAL_DETECT_EN_SET(x) WLAN_DERIVED_RTC_CLK_EXTERNAL_DETECT_EN_SET(x)
-#define DERIVED_RTC_CLK_EXTERNAL_DETECT_MSB WLAN_DERIVED_RTC_CLK_EXTERNAL_DETECT_MSB
-#define DERIVED_RTC_CLK_EXTERNAL_DETECT_LSB WLAN_DERIVED_RTC_CLK_EXTERNAL_DETECT_LSB
-#define DERIVED_RTC_CLK_EXTERNAL_DETECT_MASK WLAN_DERIVED_RTC_CLK_EXTERNAL_DETECT_MASK
-#define DERIVED_RTC_CLK_EXTERNAL_DETECT_GET(x) WLAN_DERIVED_RTC_CLK_EXTERNAL_DETECT_GET(x)
-#define DERIVED_RTC_CLK_EXTERNAL_DETECT_SET(x) WLAN_DERIVED_RTC_CLK_EXTERNAL_DETECT_SET(x)
-#define DERIVED_RTC_CLK_FORCE_MSB WLAN_DERIVED_RTC_CLK_FORCE_MSB
-#define DERIVED_RTC_CLK_FORCE_LSB WLAN_DERIVED_RTC_CLK_FORCE_LSB
-#define DERIVED_RTC_CLK_FORCE_MASK WLAN_DERIVED_RTC_CLK_FORCE_MASK
-#define DERIVED_RTC_CLK_FORCE_GET(x) WLAN_DERIVED_RTC_CLK_FORCE_GET(x)
-#define DERIVED_RTC_CLK_FORCE_SET(x) WLAN_DERIVED_RTC_CLK_FORCE_SET(x)
-#define DERIVED_RTC_CLK_PERIOD_MSB WLAN_DERIVED_RTC_CLK_PERIOD_MSB
-#define DERIVED_RTC_CLK_PERIOD_LSB WLAN_DERIVED_RTC_CLK_PERIOD_LSB
-#define DERIVED_RTC_CLK_PERIOD_MASK WLAN_DERIVED_RTC_CLK_PERIOD_MASK
-#define DERIVED_RTC_CLK_PERIOD_GET(x) WLAN_DERIVED_RTC_CLK_PERIOD_GET(x)
-#define DERIVED_RTC_CLK_PERIOD_SET(x) WLAN_DERIVED_RTC_CLK_PERIOD_SET(x)
-#define POWER_REG_ADDRESS WLAN_POWER_REG_ADDRESS
-#define POWER_REG_OFFSET WLAN_POWER_REG_OFFSET
-#define POWER_REG_SLEEP_MAKE_N_BREAK_EN_MSB WLAN_POWER_REG_SLEEP_MAKE_N_BREAK_EN_MSB
-#define POWER_REG_SLEEP_MAKE_N_BREAK_EN_LSB WLAN_POWER_REG_SLEEP_MAKE_N_BREAK_EN_LSB
-#define POWER_REG_SLEEP_MAKE_N_BREAK_EN_MASK WLAN_POWER_REG_SLEEP_MAKE_N_BREAK_EN_MASK
-#define POWER_REG_SLEEP_MAKE_N_BREAK_EN_GET(x) WLAN_POWER_REG_SLEEP_MAKE_N_BREAK_EN_GET(x)
-#define POWER_REG_SLEEP_MAKE_N_BREAK_EN_SET(x) WLAN_POWER_REG_SLEEP_MAKE_N_BREAK_EN_SET(x)
-#define POWER_REG_DEBUG_EN_MSB WLAN_POWER_REG_DEBUG_EN_MSB
-#define POWER_REG_DEBUG_EN_LSB WLAN_POWER_REG_DEBUG_EN_LSB
-#define POWER_REG_DEBUG_EN_MASK WLAN_POWER_REG_DEBUG_EN_MASK
-#define POWER_REG_DEBUG_EN_GET(x) WLAN_POWER_REG_DEBUG_EN_GET(x)
-#define POWER_REG_DEBUG_EN_SET(x) WLAN_POWER_REG_DEBUG_EN_SET(x)
-#define POWER_REG_WLAN_BB_PWD_EN_MSB WLAN_POWER_REG_WLAN_BB_PWD_EN_MSB
-#define POWER_REG_WLAN_BB_PWD_EN_LSB WLAN_POWER_REG_WLAN_BB_PWD_EN_LSB
-#define POWER_REG_WLAN_BB_PWD_EN_MASK WLAN_POWER_REG_WLAN_BB_PWD_EN_MASK
-#define POWER_REG_WLAN_BB_PWD_EN_GET(x) WLAN_POWER_REG_WLAN_BB_PWD_EN_GET(x)
-#define POWER_REG_WLAN_BB_PWD_EN_SET(x) WLAN_POWER_REG_WLAN_BB_PWD_EN_SET(x)
-#define POWER_REG_WLAN_MAC_PWD_EN_MSB WLAN_POWER_REG_WLAN_MAC_PWD_EN_MSB
-#define POWER_REG_WLAN_MAC_PWD_EN_LSB WLAN_POWER_REG_WLAN_MAC_PWD_EN_LSB
-#define POWER_REG_WLAN_MAC_PWD_EN_MASK WLAN_POWER_REG_WLAN_MAC_PWD_EN_MASK
-#define POWER_REG_WLAN_MAC_PWD_EN_GET(x) WLAN_POWER_REG_WLAN_MAC_PWD_EN_GET(x)
-#define POWER_REG_WLAN_MAC_PWD_EN_SET(x) WLAN_POWER_REG_WLAN_MAC_PWD_EN_SET(x)
-#define POWER_REG_VLVL_MSB WLAN_POWER_REG_VLVL_MSB
-#define POWER_REG_VLVL_LSB WLAN_POWER_REG_VLVL_LSB
-#define POWER_REG_VLVL_MASK WLAN_POWER_REG_VLVL_MASK
-#define POWER_REG_VLVL_GET(x) WLAN_POWER_REG_VLVL_GET(x)
-#define POWER_REG_VLVL_SET(x) WLAN_POWER_REG_VLVL_SET(x)
-#define POWER_REG_CPU_INT_ENABLE_MSB WLAN_POWER_REG_CPU_INT_ENABLE_MSB
-#define POWER_REG_CPU_INT_ENABLE_LSB WLAN_POWER_REG_CPU_INT_ENABLE_LSB
-#define POWER_REG_CPU_INT_ENABLE_MASK WLAN_POWER_REG_CPU_INT_ENABLE_MASK
-#define POWER_REG_CPU_INT_ENABLE_GET(x) WLAN_POWER_REG_CPU_INT_ENABLE_GET(x)
-#define POWER_REG_CPU_INT_ENABLE_SET(x) WLAN_POWER_REG_CPU_INT_ENABLE_SET(x)
-#define POWER_REG_WLAN_ISO_DIS_MSB WLAN_POWER_REG_WLAN_ISO_DIS_MSB
-#define POWER_REG_WLAN_ISO_DIS_LSB WLAN_POWER_REG_WLAN_ISO_DIS_LSB
-#define POWER_REG_WLAN_ISO_DIS_MASK WLAN_POWER_REG_WLAN_ISO_DIS_MASK
-#define POWER_REG_WLAN_ISO_DIS_GET(x) WLAN_POWER_REG_WLAN_ISO_DIS_GET(x)
-#define POWER_REG_WLAN_ISO_DIS_SET(x) WLAN_POWER_REG_WLAN_ISO_DIS_SET(x)
-#define POWER_REG_WLAN_ISO_CNTL_MSB WLAN_POWER_REG_WLAN_ISO_CNTL_MSB
-#define POWER_REG_WLAN_ISO_CNTL_LSB WLAN_POWER_REG_WLAN_ISO_CNTL_LSB
-#define POWER_REG_WLAN_ISO_CNTL_MASK WLAN_POWER_REG_WLAN_ISO_CNTL_MASK
-#define POWER_REG_WLAN_ISO_CNTL_GET(x) WLAN_POWER_REG_WLAN_ISO_CNTL_GET(x)
-#define POWER_REG_WLAN_ISO_CNTL_SET(x) WLAN_POWER_REG_WLAN_ISO_CNTL_SET(x)
-#define POWER_REG_RADIO_PWD_EN_MSB WLAN_POWER_REG_RADIO_PWD_EN_MSB
-#define POWER_REG_RADIO_PWD_EN_LSB WLAN_POWER_REG_RADIO_PWD_EN_LSB
-#define POWER_REG_RADIO_PWD_EN_MASK WLAN_POWER_REG_RADIO_PWD_EN_MASK
-#define POWER_REG_RADIO_PWD_EN_GET(x) WLAN_POWER_REG_RADIO_PWD_EN_GET(x)
-#define POWER_REG_RADIO_PWD_EN_SET(x) WLAN_POWER_REG_RADIO_PWD_EN_SET(x)
-#define POWER_REG_SOC_ISO_EN_MSB WLAN_POWER_REG_SOC_ISO_EN_MSB
-#define POWER_REG_SOC_ISO_EN_LSB WLAN_POWER_REG_SOC_ISO_EN_LSB
-#define POWER_REG_SOC_ISO_EN_MASK WLAN_POWER_REG_SOC_ISO_EN_MASK
-#define POWER_REG_SOC_ISO_EN_GET(x) WLAN_POWER_REG_SOC_ISO_EN_GET(x)
-#define POWER_REG_SOC_ISO_EN_SET(x) WLAN_POWER_REG_SOC_ISO_EN_SET(x)
-#define POWER_REG_WLAN_ISO_EN_MSB WLAN_POWER_REG_WLAN_ISO_EN_MSB
-#define POWER_REG_WLAN_ISO_EN_LSB WLAN_POWER_REG_WLAN_ISO_EN_LSB
-#define POWER_REG_WLAN_ISO_EN_MASK WLAN_POWER_REG_WLAN_ISO_EN_MASK
-#define POWER_REG_WLAN_ISO_EN_GET(x) WLAN_POWER_REG_WLAN_ISO_EN_GET(x)
-#define POWER_REG_WLAN_ISO_EN_SET(x) WLAN_POWER_REG_WLAN_ISO_EN_SET(x)
-#define POWER_REG_WLAN_PWD_EN_MSB WLAN_POWER_REG_WLAN_PWD_EN_MSB
-#define POWER_REG_WLAN_PWD_EN_LSB WLAN_POWER_REG_WLAN_PWD_EN_LSB
-#define POWER_REG_WLAN_PWD_EN_MASK WLAN_POWER_REG_WLAN_PWD_EN_MASK
-#define POWER_REG_WLAN_PWD_EN_GET(x) WLAN_POWER_REG_WLAN_PWD_EN_GET(x)
-#define POWER_REG_WLAN_PWD_EN_SET(x) WLAN_POWER_REG_WLAN_PWD_EN_SET(x)
-#define POWER_REG_POWER_EN_MSB WLAN_POWER_REG_POWER_EN_MSB
-#define POWER_REG_POWER_EN_LSB WLAN_POWER_REG_POWER_EN_LSB
-#define POWER_REG_POWER_EN_MASK WLAN_POWER_REG_POWER_EN_MASK
-#define POWER_REG_POWER_EN_GET(x) WLAN_POWER_REG_POWER_EN_GET(x)
-#define POWER_REG_POWER_EN_SET(x) WLAN_POWER_REG_POWER_EN_SET(x)
-#define CORE_CLK_CTRL_ADDRESS WLAN_CORE_CLK_CTRL_ADDRESS
-#define CORE_CLK_CTRL_OFFSET WLAN_CORE_CLK_CTRL_OFFSET
-#define CORE_CLK_CTRL_DIV_MSB WLAN_CORE_CLK_CTRL_DIV_MSB
-#define CORE_CLK_CTRL_DIV_LSB WLAN_CORE_CLK_CTRL_DIV_LSB
-#define CORE_CLK_CTRL_DIV_MASK WLAN_CORE_CLK_CTRL_DIV_MASK
-#define CORE_CLK_CTRL_DIV_GET(x) WLAN_CORE_CLK_CTRL_DIV_GET(x)
-#define CORE_CLK_CTRL_DIV_SET(x) WLAN_CORE_CLK_CTRL_DIV_SET(x)
-#define GPIO_WAKEUP_CONTROL_ADDRESS WLAN_GPIO_WAKEUP_CONTROL_ADDRESS
-#define GPIO_WAKEUP_CONTROL_OFFSET WLAN_GPIO_WAKEUP_CONTROL_OFFSET
-#define GPIO_WAKEUP_CONTROL_ENABLE_MSB WLAN_GPIO_WAKEUP_CONTROL_ENABLE_MSB
-#define GPIO_WAKEUP_CONTROL_ENABLE_LSB WLAN_GPIO_WAKEUP_CONTROL_ENABLE_LSB
-#define GPIO_WAKEUP_CONTROL_ENABLE_MASK WLAN_GPIO_WAKEUP_CONTROL_ENABLE_MASK
-#define GPIO_WAKEUP_CONTROL_ENABLE_GET(x) WLAN_GPIO_WAKEUP_CONTROL_ENABLE_GET(x)
-#define GPIO_WAKEUP_CONTROL_ENABLE_SET(x) WLAN_GPIO_WAKEUP_CONTROL_ENABLE_SET(x)
 
-
-#endif
 #endif
-
-
-
index abf872650054d2aae6223d9f14fe417661ab19ad..5c048ff51b075cee59e7d2af40205bd073579ff3 100644 (file)
 #define WLAN_RESET_CONTROL_SI0_RST_GET(x)        (((x) & WLAN_RESET_CONTROL_SI0_RST_MASK) >> WLAN_RESET_CONTROL_SI0_RST_LSB)
 #define WLAN_RESET_CONTROL_SI0_RST_SET(x)        (((x) << WLAN_RESET_CONTROL_SI0_RST_LSB) & WLAN_RESET_CONTROL_SI0_RST_MASK)
 
-#define WLAN_XTAL_CONTROL_ADDRESS                0x00000004
-#define WLAN_XTAL_CONTROL_OFFSET                 0x00000004
-#define WLAN_XTAL_CONTROL_TCXO_MSB               0
-#define WLAN_XTAL_CONTROL_TCXO_LSB               0
-#define WLAN_XTAL_CONTROL_TCXO_MASK              0x00000001
-#define WLAN_XTAL_CONTROL_TCXO_GET(x)            (((x) & WLAN_XTAL_CONTROL_TCXO_MASK) >> WLAN_XTAL_CONTROL_TCXO_LSB)
-#define WLAN_XTAL_CONTROL_TCXO_SET(x)            (((x) << WLAN_XTAL_CONTROL_TCXO_LSB) & WLAN_XTAL_CONTROL_TCXO_MASK)
-
-#define WLAN_TCXO_DETECT_ADDRESS                 0x00000008
-#define WLAN_TCXO_DETECT_OFFSET                  0x00000008
-#define WLAN_TCXO_DETECT_PRESENT_MSB             0
-#define WLAN_TCXO_DETECT_PRESENT_LSB             0
-#define WLAN_TCXO_DETECT_PRESENT_MASK            0x00000001
-#define WLAN_TCXO_DETECT_PRESENT_GET(x)          (((x) & WLAN_TCXO_DETECT_PRESENT_MASK) >> WLAN_TCXO_DETECT_PRESENT_LSB)
-#define WLAN_TCXO_DETECT_PRESENT_SET(x)          (((x) << WLAN_TCXO_DETECT_PRESENT_LSB) & WLAN_TCXO_DETECT_PRESENT_MASK)
-
-#define WLAN_XTAL_TEST_ADDRESS                   0x0000000c
-#define WLAN_XTAL_TEST_OFFSET                    0x0000000c
-#define WLAN_XTAL_TEST_NOTCXODET_MSB             0
-#define WLAN_XTAL_TEST_NOTCXODET_LSB             0
-#define WLAN_XTAL_TEST_NOTCXODET_MASK            0x00000001
-#define WLAN_XTAL_TEST_NOTCXODET_GET(x)          (((x) & WLAN_XTAL_TEST_NOTCXODET_MASK) >> WLAN_XTAL_TEST_NOTCXODET_LSB)
-#define WLAN_XTAL_TEST_NOTCXODET_SET(x)          (((x) << WLAN_XTAL_TEST_NOTCXODET_LSB) & WLAN_XTAL_TEST_NOTCXODET_MASK)
-
-#define WLAN_QUADRATURE_ADDRESS                  0x00000010
-#define WLAN_QUADRATURE_OFFSET                   0x00000010
-#define WLAN_QUADRATURE_ADC_MSB                  7
-#define WLAN_QUADRATURE_ADC_LSB                  4
-#define WLAN_QUADRATURE_ADC_MASK                 0x000000f0
-#define WLAN_QUADRATURE_ADC_GET(x)               (((x) & WLAN_QUADRATURE_ADC_MASK) >> WLAN_QUADRATURE_ADC_LSB)
-#define WLAN_QUADRATURE_ADC_SET(x)               (((x) << WLAN_QUADRATURE_ADC_LSB) & WLAN_QUADRATURE_ADC_MASK)
-#define WLAN_QUADRATURE_SEL_MSB                  2
-#define WLAN_QUADRATURE_SEL_LSB                  2
-#define WLAN_QUADRATURE_SEL_MASK                 0x00000004
-#define WLAN_QUADRATURE_SEL_GET(x)               (((x) & WLAN_QUADRATURE_SEL_MASK) >> WLAN_QUADRATURE_SEL_LSB)
-#define WLAN_QUADRATURE_SEL_SET(x)               (((x) << WLAN_QUADRATURE_SEL_LSB) & WLAN_QUADRATURE_SEL_MASK)
-#define WLAN_QUADRATURE_DAC_MSB                  1
-#define WLAN_QUADRATURE_DAC_LSB                  0
-#define WLAN_QUADRATURE_DAC_MASK                 0x00000003
-#define WLAN_QUADRATURE_DAC_GET(x)               (((x) & WLAN_QUADRATURE_DAC_MASK) >> WLAN_QUADRATURE_DAC_LSB)
-#define WLAN_QUADRATURE_DAC_SET(x)               (((x) << WLAN_QUADRATURE_DAC_LSB) & WLAN_QUADRATURE_DAC_MASK)
-
-#define WLAN_PLL_CONTROL_ADDRESS                 0x00000014
-#define WLAN_PLL_CONTROL_OFFSET                  0x00000014
-#define WLAN_PLL_CONTROL_DIG_TEST_CLK_MSB        20
-#define WLAN_PLL_CONTROL_DIG_TEST_CLK_LSB        20
-#define WLAN_PLL_CONTROL_DIG_TEST_CLK_MASK       0x00100000
-#define WLAN_PLL_CONTROL_DIG_TEST_CLK_GET(x)     (((x) & WLAN_PLL_CONTROL_DIG_TEST_CLK_MASK) >> WLAN_PLL_CONTROL_DIG_TEST_CLK_LSB)
-#define WLAN_PLL_CONTROL_DIG_TEST_CLK_SET(x)     (((x) << WLAN_PLL_CONTROL_DIG_TEST_CLK_LSB) & WLAN_PLL_CONTROL_DIG_TEST_CLK_MASK)
-#define WLAN_PLL_CONTROL_MAC_OVERRIDE_MSB        19
-#define WLAN_PLL_CONTROL_MAC_OVERRIDE_LSB        19
-#define WLAN_PLL_CONTROL_MAC_OVERRIDE_MASK       0x00080000
-#define WLAN_PLL_CONTROL_MAC_OVERRIDE_GET(x)     (((x) & WLAN_PLL_CONTROL_MAC_OVERRIDE_MASK) >> WLAN_PLL_CONTROL_MAC_OVERRIDE_LSB)
-#define WLAN_PLL_CONTROL_MAC_OVERRIDE_SET(x)     (((x) << WLAN_PLL_CONTROL_MAC_OVERRIDE_LSB) & WLAN_PLL_CONTROL_MAC_OVERRIDE_MASK)
-#define WLAN_PLL_CONTROL_NOPWD_MSB               18
-#define WLAN_PLL_CONTROL_NOPWD_LSB               18
-#define WLAN_PLL_CONTROL_NOPWD_MASK              0x00040000
-#define WLAN_PLL_CONTROL_NOPWD_GET(x)            (((x) & WLAN_PLL_CONTROL_NOPWD_MASK) >> WLAN_PLL_CONTROL_NOPWD_LSB)
-#define WLAN_PLL_CONTROL_NOPWD_SET(x)            (((x) << WLAN_PLL_CONTROL_NOPWD_LSB) & WLAN_PLL_CONTROL_NOPWD_MASK)
-#define WLAN_PLL_CONTROL_UPDATING_MSB            17
-#define WLAN_PLL_CONTROL_UPDATING_LSB            17
-#define WLAN_PLL_CONTROL_UPDATING_MASK           0x00020000
-#define WLAN_PLL_CONTROL_UPDATING_GET(x)         (((x) & WLAN_PLL_CONTROL_UPDATING_MASK) >> WLAN_PLL_CONTROL_UPDATING_LSB)
-#define WLAN_PLL_CONTROL_UPDATING_SET(x)         (((x) << WLAN_PLL_CONTROL_UPDATING_LSB) & WLAN_PLL_CONTROL_UPDATING_MASK)
-#define WLAN_PLL_CONTROL_BYPASS_MSB              16
-#define WLAN_PLL_CONTROL_BYPASS_LSB              16
-#define WLAN_PLL_CONTROL_BYPASS_MASK             0x00010000
-#define WLAN_PLL_CONTROL_BYPASS_GET(x)           (((x) & WLAN_PLL_CONTROL_BYPASS_MASK) >> WLAN_PLL_CONTROL_BYPASS_LSB)
-#define WLAN_PLL_CONTROL_BYPASS_SET(x)           (((x) << WLAN_PLL_CONTROL_BYPASS_LSB) & WLAN_PLL_CONTROL_BYPASS_MASK)
-#define WLAN_PLL_CONTROL_REFDIV_MSB              15
-#define WLAN_PLL_CONTROL_REFDIV_LSB              12
-#define WLAN_PLL_CONTROL_REFDIV_MASK             0x0000f000
-#define WLAN_PLL_CONTROL_REFDIV_GET(x)           (((x) & WLAN_PLL_CONTROL_REFDIV_MASK) >> WLAN_PLL_CONTROL_REFDIV_LSB)
-#define WLAN_PLL_CONTROL_REFDIV_SET(x)           (((x) << WLAN_PLL_CONTROL_REFDIV_LSB) & WLAN_PLL_CONTROL_REFDIV_MASK)
-#define WLAN_PLL_CONTROL_DIV_MSB                 9
-#define WLAN_PLL_CONTROL_DIV_LSB                 0
-#define WLAN_PLL_CONTROL_DIV_MASK                0x000003ff
-#define WLAN_PLL_CONTROL_DIV_GET(x)              (((x) & WLAN_PLL_CONTROL_DIV_MASK) >> WLAN_PLL_CONTROL_DIV_LSB)
-#define WLAN_PLL_CONTROL_DIV_SET(x)              (((x) << WLAN_PLL_CONTROL_DIV_LSB) & WLAN_PLL_CONTROL_DIV_MASK)
-
-#define WLAN_PLL_SETTLE_ADDRESS                  0x00000018
-#define WLAN_PLL_SETTLE_OFFSET                   0x00000018
-#define WLAN_PLL_SETTLE_TIME_MSB                 11
-#define WLAN_PLL_SETTLE_TIME_LSB                 0
-#define WLAN_PLL_SETTLE_TIME_MASK                0x00000fff
-#define WLAN_PLL_SETTLE_TIME_GET(x)              (((x) & WLAN_PLL_SETTLE_TIME_MASK) >> WLAN_PLL_SETTLE_TIME_LSB)
-#define WLAN_PLL_SETTLE_TIME_SET(x)              (((x) << WLAN_PLL_SETTLE_TIME_LSB) & WLAN_PLL_SETTLE_TIME_MASK)
-
-#define WLAN_XTAL_SETTLE_ADDRESS                 0x0000001c
-#define WLAN_XTAL_SETTLE_OFFSET                  0x0000001c
-#define WLAN_XTAL_SETTLE_TIME_MSB                7
-#define WLAN_XTAL_SETTLE_TIME_LSB                0
-#define WLAN_XTAL_SETTLE_TIME_MASK               0x000000ff
-#define WLAN_XTAL_SETTLE_TIME_GET(x)             (((x) & WLAN_XTAL_SETTLE_TIME_MASK) >> WLAN_XTAL_SETTLE_TIME_LSB)
-#define WLAN_XTAL_SETTLE_TIME_SET(x)             (((x) << WLAN_XTAL_SETTLE_TIME_LSB) & WLAN_XTAL_SETTLE_TIME_MASK)
-
 #define WLAN_CPU_CLOCK_ADDRESS                   0x00000020
 #define WLAN_CPU_CLOCK_OFFSET                    0x00000020
 #define WLAN_CPU_CLOCK_STANDARD_MSB              1
 #define WLAN_CPU_CLOCK_STANDARD_GET(x)           (((x) & WLAN_CPU_CLOCK_STANDARD_MASK) >> WLAN_CPU_CLOCK_STANDARD_LSB)
 #define WLAN_CPU_CLOCK_STANDARD_SET(x)           (((x) << WLAN_CPU_CLOCK_STANDARD_LSB) & WLAN_CPU_CLOCK_STANDARD_MASK)
 
-#define WLAN_CLOCK_OUT_ADDRESS                   0x00000024
-#define WLAN_CLOCK_OUT_OFFSET                    0x00000024
-#define WLAN_CLOCK_OUT_SELECT_MSB                3
-#define WLAN_CLOCK_OUT_SELECT_LSB                0
-#define WLAN_CLOCK_OUT_SELECT_MASK               0x0000000f
-#define WLAN_CLOCK_OUT_SELECT_GET(x)             (((x) & WLAN_CLOCK_OUT_SELECT_MASK) >> WLAN_CLOCK_OUT_SELECT_LSB)
-#define WLAN_CLOCK_OUT_SELECT_SET(x)             (((x) << WLAN_CLOCK_OUT_SELECT_LSB) & WLAN_CLOCK_OUT_SELECT_MASK)
-
 #define WLAN_CLOCK_CONTROL_ADDRESS               0x00000028
 #define WLAN_CLOCK_CONTROL_OFFSET                0x00000028
 #define WLAN_CLOCK_CONTROL_LF_CLK32_MSB          2
 #define WLAN_CLOCK_CONTROL_SI0_CLK_GET(x)        (((x) & WLAN_CLOCK_CONTROL_SI0_CLK_MASK) >> WLAN_CLOCK_CONTROL_SI0_CLK_LSB)
 #define WLAN_CLOCK_CONTROL_SI0_CLK_SET(x)        (((x) << WLAN_CLOCK_CONTROL_SI0_CLK_LSB) & WLAN_CLOCK_CONTROL_SI0_CLK_MASK)
 
-#define WLAN_BIAS_OVERRIDE_ADDRESS               0x0000002c
-#define WLAN_BIAS_OVERRIDE_OFFSET                0x0000002c
-#define WLAN_BIAS_OVERRIDE_ON_MSB                0
-#define WLAN_BIAS_OVERRIDE_ON_LSB                0
-#define WLAN_BIAS_OVERRIDE_ON_MASK               0x00000001
-#define WLAN_BIAS_OVERRIDE_ON_GET(x)             (((x) & WLAN_BIAS_OVERRIDE_ON_MASK) >> WLAN_BIAS_OVERRIDE_ON_LSB)
-#define WLAN_BIAS_OVERRIDE_ON_SET(x)             (((x) << WLAN_BIAS_OVERRIDE_ON_LSB) & WLAN_BIAS_OVERRIDE_ON_MASK)
-
-#define WLAN_WDT_CONTROL_ADDRESS                 0x00000030
-#define WLAN_WDT_CONTROL_OFFSET                  0x00000030
-#define WLAN_WDT_CONTROL_ACTION_MSB              2
-#define WLAN_WDT_CONTROL_ACTION_LSB              0
-#define WLAN_WDT_CONTROL_ACTION_MASK             0x00000007
-#define WLAN_WDT_CONTROL_ACTION_GET(x)           (((x) & WLAN_WDT_CONTROL_ACTION_MASK) >> WLAN_WDT_CONTROL_ACTION_LSB)
-#define WLAN_WDT_CONTROL_ACTION_SET(x)           (((x) << WLAN_WDT_CONTROL_ACTION_LSB) & WLAN_WDT_CONTROL_ACTION_MASK)
-
-#define WLAN_WDT_STATUS_ADDRESS                  0x00000034
-#define WLAN_WDT_STATUS_OFFSET                   0x00000034
-#define WLAN_WDT_STATUS_INTERRUPT_MSB            0
-#define WLAN_WDT_STATUS_INTERRUPT_LSB            0
-#define WLAN_WDT_STATUS_INTERRUPT_MASK           0x00000001
-#define WLAN_WDT_STATUS_INTERRUPT_GET(x)         (((x) & WLAN_WDT_STATUS_INTERRUPT_MASK) >> WLAN_WDT_STATUS_INTERRUPT_LSB)
-#define WLAN_WDT_STATUS_INTERRUPT_SET(x)         (((x) << WLAN_WDT_STATUS_INTERRUPT_LSB) & WLAN_WDT_STATUS_INTERRUPT_MASK)
-
-#define WLAN_WDT_ADDRESS                         0x00000038
-#define WLAN_WDT_OFFSET                          0x00000038
-#define WLAN_WDT_TARGET_MSB                      21
-#define WLAN_WDT_TARGET_LSB                      0
-#define WLAN_WDT_TARGET_MASK                     0x003fffff
-#define WLAN_WDT_TARGET_GET(x)                   (((x) & WLAN_WDT_TARGET_MASK) >> WLAN_WDT_TARGET_LSB)
-#define WLAN_WDT_TARGET_SET(x)                   (((x) << WLAN_WDT_TARGET_LSB) & WLAN_WDT_TARGET_MASK)
-
-#define WLAN_WDT_COUNT_ADDRESS                   0x0000003c
-#define WLAN_WDT_COUNT_OFFSET                    0x0000003c
-#define WLAN_WDT_COUNT_VALUE_MSB                 21
-#define WLAN_WDT_COUNT_VALUE_LSB                 0
-#define WLAN_WDT_COUNT_VALUE_MASK                0x003fffff
-#define WLAN_WDT_COUNT_VALUE_GET(x)              (((x) & WLAN_WDT_COUNT_VALUE_MASK) >> WLAN_WDT_COUNT_VALUE_LSB)
-#define WLAN_WDT_COUNT_VALUE_SET(x)              (((x) << WLAN_WDT_COUNT_VALUE_LSB) & WLAN_WDT_COUNT_VALUE_MASK)
-
-#define WLAN_WDT_RESET_ADDRESS                   0x00000040
-#define WLAN_WDT_RESET_OFFSET                    0x00000040
-#define WLAN_WDT_RESET_VALUE_MSB                 0
-#define WLAN_WDT_RESET_VALUE_LSB                 0
-#define WLAN_WDT_RESET_VALUE_MASK                0x00000001
-#define WLAN_WDT_RESET_VALUE_GET(x)              (((x) & WLAN_WDT_RESET_VALUE_MASK) >> WLAN_WDT_RESET_VALUE_LSB)
-#define WLAN_WDT_RESET_VALUE_SET(x)              (((x) << WLAN_WDT_RESET_VALUE_LSB) & WLAN_WDT_RESET_VALUE_MASK)
-
-#define WLAN_INT_STATUS_ADDRESS                  0x00000044
-#define WLAN_INT_STATUS_OFFSET                   0x00000044
-#define WLAN_INT_STATUS_HCI_UART_MSB             21
-#define WLAN_INT_STATUS_HCI_UART_LSB             21
-#define WLAN_INT_STATUS_HCI_UART_MASK            0x00200000
-#define WLAN_INT_STATUS_HCI_UART_GET(x)          (((x) & WLAN_INT_STATUS_HCI_UART_MASK) >> WLAN_INT_STATUS_HCI_UART_LSB)
-#define WLAN_INT_STATUS_HCI_UART_SET(x)          (((x) << WLAN_INT_STATUS_HCI_UART_LSB) & WLAN_INT_STATUS_HCI_UART_MASK)
-#define WLAN_INT_STATUS_THERM_MSB                20
-#define WLAN_INT_STATUS_THERM_LSB                20
-#define WLAN_INT_STATUS_THERM_MASK               0x00100000
-#define WLAN_INT_STATUS_THERM_GET(x)             (((x) & WLAN_INT_STATUS_THERM_MASK) >> WLAN_INT_STATUS_THERM_LSB)
-#define WLAN_INT_STATUS_THERM_SET(x)             (((x) << WLAN_INT_STATUS_THERM_LSB) & WLAN_INT_STATUS_THERM_MASK)
-#define WLAN_INT_STATUS_EFUSE_OVERWRITE_MSB      19
-#define WLAN_INT_STATUS_EFUSE_OVERWRITE_LSB      19
-#define WLAN_INT_STATUS_EFUSE_OVERWRITE_MASK     0x00080000
-#define WLAN_INT_STATUS_EFUSE_OVERWRITE_GET(x)   (((x) & WLAN_INT_STATUS_EFUSE_OVERWRITE_MASK) >> WLAN_INT_STATUS_EFUSE_OVERWRITE_LSB)
-#define WLAN_INT_STATUS_EFUSE_OVERWRITE_SET(x)   (((x) << WLAN_INT_STATUS_EFUSE_OVERWRITE_LSB) & WLAN_INT_STATUS_EFUSE_OVERWRITE_MASK)
-#define WLAN_INT_STATUS_UART_MBOX_MSB            18
-#define WLAN_INT_STATUS_UART_MBOX_LSB            18
-#define WLAN_INT_STATUS_UART_MBOX_MASK           0x00040000
-#define WLAN_INT_STATUS_UART_MBOX_GET(x)         (((x) & WLAN_INT_STATUS_UART_MBOX_MASK) >> WLAN_INT_STATUS_UART_MBOX_LSB)
-#define WLAN_INT_STATUS_UART_MBOX_SET(x)         (((x) << WLAN_INT_STATUS_UART_MBOX_LSB) & WLAN_INT_STATUS_UART_MBOX_MASK)
-#define WLAN_INT_STATUS_GENERIC_MBOX_MSB         17
-#define WLAN_INT_STATUS_GENERIC_MBOX_LSB         17
-#define WLAN_INT_STATUS_GENERIC_MBOX_MASK        0x00020000
-#define WLAN_INT_STATUS_GENERIC_MBOX_GET(x)      (((x) & WLAN_INT_STATUS_GENERIC_MBOX_MASK) >> WLAN_INT_STATUS_GENERIC_MBOX_LSB)
-#define WLAN_INT_STATUS_GENERIC_MBOX_SET(x)      (((x) << WLAN_INT_STATUS_GENERIC_MBOX_LSB) & WLAN_INT_STATUS_GENERIC_MBOX_MASK)
-#define WLAN_INT_STATUS_RDMA_MSB                 16
-#define WLAN_INT_STATUS_RDMA_LSB                 16
-#define WLAN_INT_STATUS_RDMA_MASK                0x00010000
-#define WLAN_INT_STATUS_RDMA_GET(x)              (((x) & WLAN_INT_STATUS_RDMA_MASK) >> WLAN_INT_STATUS_RDMA_LSB)
-#define WLAN_INT_STATUS_RDMA_SET(x)              (((x) << WLAN_INT_STATUS_RDMA_LSB) & WLAN_INT_STATUS_RDMA_MASK)
-#define WLAN_INT_STATUS_BTCOEX_MSB               15
-#define WLAN_INT_STATUS_BTCOEX_LSB               15
-#define WLAN_INT_STATUS_BTCOEX_MASK              0x00008000
-#define WLAN_INT_STATUS_BTCOEX_GET(x)            (((x) & WLAN_INT_STATUS_BTCOEX_MASK) >> WLAN_INT_STATUS_BTCOEX_LSB)
-#define WLAN_INT_STATUS_BTCOEX_SET(x)            (((x) << WLAN_INT_STATUS_BTCOEX_LSB) & WLAN_INT_STATUS_BTCOEX_MASK)
-#define WLAN_INT_STATUS_RTC_POWER_MSB            14
-#define WLAN_INT_STATUS_RTC_POWER_LSB            14
-#define WLAN_INT_STATUS_RTC_POWER_MASK           0x00004000
-#define WLAN_INT_STATUS_RTC_POWER_GET(x)         (((x) & WLAN_INT_STATUS_RTC_POWER_MASK) >> WLAN_INT_STATUS_RTC_POWER_LSB)
-#define WLAN_INT_STATUS_RTC_POWER_SET(x)         (((x) << WLAN_INT_STATUS_RTC_POWER_LSB) & WLAN_INT_STATUS_RTC_POWER_MASK)
-#define WLAN_INT_STATUS_MAC_MSB                  13
-#define WLAN_INT_STATUS_MAC_LSB                  13
-#define WLAN_INT_STATUS_MAC_MASK                 0x00002000
-#define WLAN_INT_STATUS_MAC_GET(x)               (((x) & WLAN_INT_STATUS_MAC_MASK) >> WLAN_INT_STATUS_MAC_LSB)
-#define WLAN_INT_STATUS_MAC_SET(x)               (((x) << WLAN_INT_STATUS_MAC_LSB) & WLAN_INT_STATUS_MAC_MASK)
-#define WLAN_INT_STATUS_MAILBOX_MSB              12
-#define WLAN_INT_STATUS_MAILBOX_LSB              12
-#define WLAN_INT_STATUS_MAILBOX_MASK             0x00001000
-#define WLAN_INT_STATUS_MAILBOX_GET(x)           (((x) & WLAN_INT_STATUS_MAILBOX_MASK) >> WLAN_INT_STATUS_MAILBOX_LSB)
-#define WLAN_INT_STATUS_MAILBOX_SET(x)           (((x) << WLAN_INT_STATUS_MAILBOX_LSB) & WLAN_INT_STATUS_MAILBOX_MASK)
-#define WLAN_INT_STATUS_RTC_ALARM_MSB            11
-#define WLAN_INT_STATUS_RTC_ALARM_LSB            11
-#define WLAN_INT_STATUS_RTC_ALARM_MASK           0x00000800
-#define WLAN_INT_STATUS_RTC_ALARM_GET(x)         (((x) & WLAN_INT_STATUS_RTC_ALARM_MASK) >> WLAN_INT_STATUS_RTC_ALARM_LSB)
-#define WLAN_INT_STATUS_RTC_ALARM_SET(x)         (((x) << WLAN_INT_STATUS_RTC_ALARM_LSB) & WLAN_INT_STATUS_RTC_ALARM_MASK)
-#define WLAN_INT_STATUS_HF_TIMER_MSB             10
-#define WLAN_INT_STATUS_HF_TIMER_LSB             10
-#define WLAN_INT_STATUS_HF_TIMER_MASK            0x00000400
-#define WLAN_INT_STATUS_HF_TIMER_GET(x)          (((x) & WLAN_INT_STATUS_HF_TIMER_MASK) >> WLAN_INT_STATUS_HF_TIMER_LSB)
-#define WLAN_INT_STATUS_HF_TIMER_SET(x)          (((x) << WLAN_INT_STATUS_HF_TIMER_LSB) & WLAN_INT_STATUS_HF_TIMER_MASK)
-#define WLAN_INT_STATUS_LF_TIMER3_MSB            9
-#define WLAN_INT_STATUS_LF_TIMER3_LSB            9
-#define WLAN_INT_STATUS_LF_TIMER3_MASK           0x00000200
-#define WLAN_INT_STATUS_LF_TIMER3_GET(x)         (((x) & WLAN_INT_STATUS_LF_TIMER3_MASK) >> WLAN_INT_STATUS_LF_TIMER3_LSB)
-#define WLAN_INT_STATUS_LF_TIMER3_SET(x)         (((x) << WLAN_INT_STATUS_LF_TIMER3_LSB) & WLAN_INT_STATUS_LF_TIMER3_MASK)
-#define WLAN_INT_STATUS_LF_TIMER2_MSB            8
-#define WLAN_INT_STATUS_LF_TIMER2_LSB            8
-#define WLAN_INT_STATUS_LF_TIMER2_MASK           0x00000100
-#define WLAN_INT_STATUS_LF_TIMER2_GET(x)         (((x) & WLAN_INT_STATUS_LF_TIMER2_MASK) >> WLAN_INT_STATUS_LF_TIMER2_LSB)
-#define WLAN_INT_STATUS_LF_TIMER2_SET(x)         (((x) << WLAN_INT_STATUS_LF_TIMER2_LSB) & WLAN_INT_STATUS_LF_TIMER2_MASK)
-#define WLAN_INT_STATUS_LF_TIMER1_MSB            7
-#define WLAN_INT_STATUS_LF_TIMER1_LSB            7
-#define WLAN_INT_STATUS_LF_TIMER1_MASK           0x00000080
-#define WLAN_INT_STATUS_LF_TIMER1_GET(x)         (((x) & WLAN_INT_STATUS_LF_TIMER1_MASK) >> WLAN_INT_STATUS_LF_TIMER1_LSB)
-#define WLAN_INT_STATUS_LF_TIMER1_SET(x)         (((x) << WLAN_INT_STATUS_LF_TIMER1_LSB) & WLAN_INT_STATUS_LF_TIMER1_MASK)
-#define WLAN_INT_STATUS_LF_TIMER0_MSB            6
-#define WLAN_INT_STATUS_LF_TIMER0_LSB            6
-#define WLAN_INT_STATUS_LF_TIMER0_MASK           0x00000040
-#define WLAN_INT_STATUS_LF_TIMER0_GET(x)         (((x) & WLAN_INT_STATUS_LF_TIMER0_MASK) >> WLAN_INT_STATUS_LF_TIMER0_LSB)
-#define WLAN_INT_STATUS_LF_TIMER0_SET(x)         (((x) << WLAN_INT_STATUS_LF_TIMER0_LSB) & WLAN_INT_STATUS_LF_TIMER0_MASK)
-#define WLAN_INT_STATUS_KEYPAD_MSB               5
-#define WLAN_INT_STATUS_KEYPAD_LSB               5
-#define WLAN_INT_STATUS_KEYPAD_MASK              0x00000020
-#define WLAN_INT_STATUS_KEYPAD_GET(x)            (((x) & WLAN_INT_STATUS_KEYPAD_MASK) >> WLAN_INT_STATUS_KEYPAD_LSB)
-#define WLAN_INT_STATUS_KEYPAD_SET(x)            (((x) << WLAN_INT_STATUS_KEYPAD_LSB) & WLAN_INT_STATUS_KEYPAD_MASK)
-#define WLAN_INT_STATUS_SI_MSB                   4
-#define WLAN_INT_STATUS_SI_LSB                   4
-#define WLAN_INT_STATUS_SI_MASK                  0x00000010
-#define WLAN_INT_STATUS_SI_GET(x)                (((x) & WLAN_INT_STATUS_SI_MASK) >> WLAN_INT_STATUS_SI_LSB)
-#define WLAN_INT_STATUS_SI_SET(x)                (((x) << WLAN_INT_STATUS_SI_LSB) & WLAN_INT_STATUS_SI_MASK)
-#define WLAN_INT_STATUS_GPIO_MSB                 3
-#define WLAN_INT_STATUS_GPIO_LSB                 3
-#define WLAN_INT_STATUS_GPIO_MASK                0x00000008
-#define WLAN_INT_STATUS_GPIO_GET(x)              (((x) & WLAN_INT_STATUS_GPIO_MASK) >> WLAN_INT_STATUS_GPIO_LSB)
-#define WLAN_INT_STATUS_GPIO_SET(x)              (((x) << WLAN_INT_STATUS_GPIO_LSB) & WLAN_INT_STATUS_GPIO_MASK)
-#define WLAN_INT_STATUS_UART_MSB                 2
-#define WLAN_INT_STATUS_UART_LSB                 2
-#define WLAN_INT_STATUS_UART_MASK                0x00000004
-#define WLAN_INT_STATUS_UART_GET(x)              (((x) & WLAN_INT_STATUS_UART_MASK) >> WLAN_INT_STATUS_UART_LSB)
-#define WLAN_INT_STATUS_UART_SET(x)              (((x) << WLAN_INT_STATUS_UART_LSB) & WLAN_INT_STATUS_UART_MASK)
-#define WLAN_INT_STATUS_ERROR_MSB                1
-#define WLAN_INT_STATUS_ERROR_LSB                1
-#define WLAN_INT_STATUS_ERROR_MASK               0x00000002
-#define WLAN_INT_STATUS_ERROR_GET(x)             (((x) & WLAN_INT_STATUS_ERROR_MASK) >> WLAN_INT_STATUS_ERROR_LSB)
-#define WLAN_INT_STATUS_ERROR_SET(x)             (((x) << WLAN_INT_STATUS_ERROR_LSB) & WLAN_INT_STATUS_ERROR_MASK)
-#define WLAN_INT_STATUS_WDT_INT_MSB              0
-#define WLAN_INT_STATUS_WDT_INT_LSB              0
-#define WLAN_INT_STATUS_WDT_INT_MASK             0x00000001
-#define WLAN_INT_STATUS_WDT_INT_GET(x)           (((x) & WLAN_INT_STATUS_WDT_INT_MASK) >> WLAN_INT_STATUS_WDT_INT_LSB)
-#define WLAN_INT_STATUS_WDT_INT_SET(x)           (((x) << WLAN_INT_STATUS_WDT_INT_LSB) & WLAN_INT_STATUS_WDT_INT_MASK)
-
-#define WLAN_LF_TIMER0_ADDRESS                   0x00000048
-#define WLAN_LF_TIMER0_OFFSET                    0x00000048
-#define WLAN_LF_TIMER0_TARGET_MSB                31
-#define WLAN_LF_TIMER0_TARGET_LSB                0
-#define WLAN_LF_TIMER0_TARGET_MASK               0xffffffff
-#define WLAN_LF_TIMER0_TARGET_GET(x)             (((x) & WLAN_LF_TIMER0_TARGET_MASK) >> WLAN_LF_TIMER0_TARGET_LSB)
-#define WLAN_LF_TIMER0_TARGET_SET(x)             (((x) << WLAN_LF_TIMER0_TARGET_LSB) & WLAN_LF_TIMER0_TARGET_MASK)
-
-#define WLAN_LF_TIMER_COUNT0_ADDRESS             0x0000004c
-#define WLAN_LF_TIMER_COUNT0_OFFSET              0x0000004c
-#define WLAN_LF_TIMER_COUNT0_VALUE_MSB           31
-#define WLAN_LF_TIMER_COUNT0_VALUE_LSB           0
-#define WLAN_LF_TIMER_COUNT0_VALUE_MASK          0xffffffff
-#define WLAN_LF_TIMER_COUNT0_VALUE_GET(x)        (((x) & WLAN_LF_TIMER_COUNT0_VALUE_MASK) >> WLAN_LF_TIMER_COUNT0_VALUE_LSB)
-#define WLAN_LF_TIMER_COUNT0_VALUE_SET(x)        (((x) << WLAN_LF_TIMER_COUNT0_VALUE_LSB) & WLAN_LF_TIMER_COUNT0_VALUE_MASK)
-
-#define WLAN_LF_TIMER_CONTROL0_ADDRESS           0x00000050
-#define WLAN_LF_TIMER_CONTROL0_OFFSET            0x00000050
-#define WLAN_LF_TIMER_CONTROL0_ENABLE_MSB        2
-#define WLAN_LF_TIMER_CONTROL0_ENABLE_LSB        2
-#define WLAN_LF_TIMER_CONTROL0_ENABLE_MASK       0x00000004
-#define WLAN_LF_TIMER_CONTROL0_ENABLE_GET(x)     (((x) & WLAN_LF_TIMER_CONTROL0_ENABLE_MASK) >> WLAN_LF_TIMER_CONTROL0_ENABLE_LSB)
-#define WLAN_LF_TIMER_CONTROL0_ENABLE_SET(x)     (((x) << WLAN_LF_TIMER_CONTROL0_ENABLE_LSB) & WLAN_LF_TIMER_CONTROL0_ENABLE_MASK)
-#define WLAN_LF_TIMER_CONTROL0_AUTO_RESTART_MSB  1
-#define WLAN_LF_TIMER_CONTROL0_AUTO_RESTART_LSB  1
-#define WLAN_LF_TIMER_CONTROL0_AUTO_RESTART_MASK 0x00000002
-#define WLAN_LF_TIMER_CONTROL0_AUTO_RESTART_GET(x) (((x) & WLAN_LF_TIMER_CONTROL0_AUTO_RESTART_MASK) >> WLAN_LF_TIMER_CONTROL0_AUTO_RESTART_LSB)
-#define WLAN_LF_TIMER_CONTROL0_AUTO_RESTART_SET(x) (((x) << WLAN_LF_TIMER_CONTROL0_AUTO_RESTART_LSB) & WLAN_LF_TIMER_CONTROL0_AUTO_RESTART_MASK)
-#define WLAN_LF_TIMER_CONTROL0_RESET_MSB         0
-#define WLAN_LF_TIMER_CONTROL0_RESET_LSB         0
-#define WLAN_LF_TIMER_CONTROL0_RESET_MASK        0x00000001
-#define WLAN_LF_TIMER_CONTROL0_RESET_GET(x)      (((x) & WLAN_LF_TIMER_CONTROL0_RESET_MASK) >> WLAN_LF_TIMER_CONTROL0_RESET_LSB)
-#define WLAN_LF_TIMER_CONTROL0_RESET_SET(x)      (((x) << WLAN_LF_TIMER_CONTROL0_RESET_LSB) & WLAN_LF_TIMER_CONTROL0_RESET_MASK)
-
-#define WLAN_LF_TIMER_STATUS0_ADDRESS            0x00000054
-#define WLAN_LF_TIMER_STATUS0_OFFSET             0x00000054
-#define WLAN_LF_TIMER_STATUS0_INTERRUPT_MSB      0
-#define WLAN_LF_TIMER_STATUS0_INTERRUPT_LSB      0
-#define WLAN_LF_TIMER_STATUS0_INTERRUPT_MASK     0x00000001
-#define WLAN_LF_TIMER_STATUS0_INTERRUPT_GET(x)   (((x) & WLAN_LF_TIMER_STATUS0_INTERRUPT_MASK) >> WLAN_LF_TIMER_STATUS0_INTERRUPT_LSB)
-#define WLAN_LF_TIMER_STATUS0_INTERRUPT_SET(x)   (((x) << WLAN_LF_TIMER_STATUS0_INTERRUPT_LSB) & WLAN_LF_TIMER_STATUS0_INTERRUPT_MASK)
-
-#define WLAN_LF_TIMER1_ADDRESS                   0x00000058
-#define WLAN_LF_TIMER1_OFFSET                    0x00000058
-#define WLAN_LF_TIMER1_TARGET_MSB                31
-#define WLAN_LF_TIMER1_TARGET_LSB                0
-#define WLAN_LF_TIMER1_TARGET_MASK               0xffffffff
-#define WLAN_LF_TIMER1_TARGET_GET(x)             (((x) & WLAN_LF_TIMER1_TARGET_MASK) >> WLAN_LF_TIMER1_TARGET_LSB)
-#define WLAN_LF_TIMER1_TARGET_SET(x)             (((x) << WLAN_LF_TIMER1_TARGET_LSB) & WLAN_LF_TIMER1_TARGET_MASK)
-
-#define WLAN_LF_TIMER_COUNT1_ADDRESS             0x0000005c
-#define WLAN_LF_TIMER_COUNT1_OFFSET              0x0000005c
-#define WLAN_LF_TIMER_COUNT1_VALUE_MSB           31
-#define WLAN_LF_TIMER_COUNT1_VALUE_LSB           0
-#define WLAN_LF_TIMER_COUNT1_VALUE_MASK          0xffffffff
-#define WLAN_LF_TIMER_COUNT1_VALUE_GET(x)        (((x) & WLAN_LF_TIMER_COUNT1_VALUE_MASK) >> WLAN_LF_TIMER_COUNT1_VALUE_LSB)
-#define WLAN_LF_TIMER_COUNT1_VALUE_SET(x)        (((x) << WLAN_LF_TIMER_COUNT1_VALUE_LSB) & WLAN_LF_TIMER_COUNT1_VALUE_MASK)
-
-#define WLAN_LF_TIMER_CONTROL1_ADDRESS           0x00000060
-#define WLAN_LF_TIMER_CONTROL1_OFFSET            0x00000060
-#define WLAN_LF_TIMER_CONTROL1_ENABLE_MSB        2
-#define WLAN_LF_TIMER_CONTROL1_ENABLE_LSB        2
-#define WLAN_LF_TIMER_CONTROL1_ENABLE_MASK       0x00000004
-#define WLAN_LF_TIMER_CONTROL1_ENABLE_GET(x)     (((x) & WLAN_LF_TIMER_CONTROL1_ENABLE_MASK) >> WLAN_LF_TIMER_CONTROL1_ENABLE_LSB)
-#define WLAN_LF_TIMER_CONTROL1_ENABLE_SET(x)     (((x) << WLAN_LF_TIMER_CONTROL1_ENABLE_LSB) & WLAN_LF_TIMER_CONTROL1_ENABLE_MASK)
-#define WLAN_LF_TIMER_CONTROL1_AUTO_RESTART_MSB  1
-#define WLAN_LF_TIMER_CONTROL1_AUTO_RESTART_LSB  1
-#define WLAN_LF_TIMER_CONTROL1_AUTO_RESTART_MASK 0x00000002
-#define WLAN_LF_TIMER_CONTROL1_AUTO_RESTART_GET(x) (((x) & WLAN_LF_TIMER_CONTROL1_AUTO_RESTART_MASK) >> WLAN_LF_TIMER_CONTROL1_AUTO_RESTART_LSB)
-#define WLAN_LF_TIMER_CONTROL1_AUTO_RESTART_SET(x) (((x) << WLAN_LF_TIMER_CONTROL1_AUTO_RESTART_LSB) & WLAN_LF_TIMER_CONTROL1_AUTO_RESTART_MASK)
-#define WLAN_LF_TIMER_CONTROL1_RESET_MSB         0
-#define WLAN_LF_TIMER_CONTROL1_RESET_LSB         0
-#define WLAN_LF_TIMER_CONTROL1_RESET_MASK        0x00000001
-#define WLAN_LF_TIMER_CONTROL1_RESET_GET(x)      (((x) & WLAN_LF_TIMER_CONTROL1_RESET_MASK) >> WLAN_LF_TIMER_CONTROL1_RESET_LSB)
-#define WLAN_LF_TIMER_CONTROL1_RESET_SET(x)      (((x) << WLAN_LF_TIMER_CONTROL1_RESET_LSB) & WLAN_LF_TIMER_CONTROL1_RESET_MASK)
-
-#define WLAN_LF_TIMER_STATUS1_ADDRESS            0x00000064
-#define WLAN_LF_TIMER_STATUS1_OFFSET             0x00000064
-#define WLAN_LF_TIMER_STATUS1_INTERRUPT_MSB      0
-#define WLAN_LF_TIMER_STATUS1_INTERRUPT_LSB      0
-#define WLAN_LF_TIMER_STATUS1_INTERRUPT_MASK     0x00000001
-#define WLAN_LF_TIMER_STATUS1_INTERRUPT_GET(x)   (((x) & WLAN_LF_TIMER_STATUS1_INTERRUPT_MASK) >> WLAN_LF_TIMER_STATUS1_INTERRUPT_LSB)
-#define WLAN_LF_TIMER_STATUS1_INTERRUPT_SET(x)   (((x) << WLAN_LF_TIMER_STATUS1_INTERRUPT_LSB) & WLAN_LF_TIMER_STATUS1_INTERRUPT_MASK)
-
-#define WLAN_LF_TIMER2_ADDRESS                   0x00000068
-#define WLAN_LF_TIMER2_OFFSET                    0x00000068
-#define WLAN_LF_TIMER2_TARGET_MSB                31
-#define WLAN_LF_TIMER2_TARGET_LSB                0
-#define WLAN_LF_TIMER2_TARGET_MASK               0xffffffff
-#define WLAN_LF_TIMER2_TARGET_GET(x)             (((x) & WLAN_LF_TIMER2_TARGET_MASK) >> WLAN_LF_TIMER2_TARGET_LSB)
-#define WLAN_LF_TIMER2_TARGET_SET(x)             (((x) << WLAN_LF_TIMER2_TARGET_LSB) & WLAN_LF_TIMER2_TARGET_MASK)
-
-#define WLAN_LF_TIMER_COUNT2_ADDRESS             0x0000006c
-#define WLAN_LF_TIMER_COUNT2_OFFSET              0x0000006c
-#define WLAN_LF_TIMER_COUNT2_VALUE_MSB           31
-#define WLAN_LF_TIMER_COUNT2_VALUE_LSB           0
-#define WLAN_LF_TIMER_COUNT2_VALUE_MASK          0xffffffff
-#define WLAN_LF_TIMER_COUNT2_VALUE_GET(x)        (((x) & WLAN_LF_TIMER_COUNT2_VALUE_MASK) >> WLAN_LF_TIMER_COUNT2_VALUE_LSB)
-#define WLAN_LF_TIMER_COUNT2_VALUE_SET(x)        (((x) << WLAN_LF_TIMER_COUNT2_VALUE_LSB) & WLAN_LF_TIMER_COUNT2_VALUE_MASK)
-
-#define WLAN_LF_TIMER_CONTROL2_ADDRESS           0x00000070
-#define WLAN_LF_TIMER_CONTROL2_OFFSET            0x00000070
-#define WLAN_LF_TIMER_CONTROL2_ENABLE_MSB        2
-#define WLAN_LF_TIMER_CONTROL2_ENABLE_LSB        2
-#define WLAN_LF_TIMER_CONTROL2_ENABLE_MASK       0x00000004
-#define WLAN_LF_TIMER_CONTROL2_ENABLE_GET(x)     (((x) & WLAN_LF_TIMER_CONTROL2_ENABLE_MASK) >> WLAN_LF_TIMER_CONTROL2_ENABLE_LSB)
-#define WLAN_LF_TIMER_CONTROL2_ENABLE_SET(x)     (((x) << WLAN_LF_TIMER_CONTROL2_ENABLE_LSB) & WLAN_LF_TIMER_CONTROL2_ENABLE_MASK)
-#define WLAN_LF_TIMER_CONTROL2_AUTO_RESTART_MSB  1
-#define WLAN_LF_TIMER_CONTROL2_AUTO_RESTART_LSB  1
-#define WLAN_LF_TIMER_CONTROL2_AUTO_RESTART_MASK 0x00000002
-#define WLAN_LF_TIMER_CONTROL2_AUTO_RESTART_GET(x) (((x) & WLAN_LF_TIMER_CONTROL2_AUTO_RESTART_MASK) >> WLAN_LF_TIMER_CONTROL2_AUTO_RESTART_LSB)
-#define WLAN_LF_TIMER_CONTROL2_AUTO_RESTART_SET(x) (((x) << WLAN_LF_TIMER_CONTROL2_AUTO_RESTART_LSB) & WLAN_LF_TIMER_CONTROL2_AUTO_RESTART_MASK)
-#define WLAN_LF_TIMER_CONTROL2_RESET_MSB         0
-#define WLAN_LF_TIMER_CONTROL2_RESET_LSB         0
-#define WLAN_LF_TIMER_CONTROL2_RESET_MASK        0x00000001
-#define WLAN_LF_TIMER_CONTROL2_RESET_GET(x)      (((x) & WLAN_LF_TIMER_CONTROL2_RESET_MASK) >> WLAN_LF_TIMER_CONTROL2_RESET_LSB)
-#define WLAN_LF_TIMER_CONTROL2_RESET_SET(x)      (((x) << WLAN_LF_TIMER_CONTROL2_RESET_LSB) & WLAN_LF_TIMER_CONTROL2_RESET_MASK)
-
-#define WLAN_LF_TIMER_STATUS2_ADDRESS            0x00000074
-#define WLAN_LF_TIMER_STATUS2_OFFSET             0x00000074
-#define WLAN_LF_TIMER_STATUS2_INTERRUPT_MSB      0
-#define WLAN_LF_TIMER_STATUS2_INTERRUPT_LSB      0
-#define WLAN_LF_TIMER_STATUS2_INTERRUPT_MASK     0x00000001
-#define WLAN_LF_TIMER_STATUS2_INTERRUPT_GET(x)   (((x) & WLAN_LF_TIMER_STATUS2_INTERRUPT_MASK) >> WLAN_LF_TIMER_STATUS2_INTERRUPT_LSB)
-#define WLAN_LF_TIMER_STATUS2_INTERRUPT_SET(x)   (((x) << WLAN_LF_TIMER_STATUS2_INTERRUPT_LSB) & WLAN_LF_TIMER_STATUS2_INTERRUPT_MASK)
-
-#define WLAN_LF_TIMER3_ADDRESS                   0x00000078
-#define WLAN_LF_TIMER3_OFFSET                    0x00000078
-#define WLAN_LF_TIMER3_TARGET_MSB                31
-#define WLAN_LF_TIMER3_TARGET_LSB                0
-#define WLAN_LF_TIMER3_TARGET_MASK               0xffffffff
-#define WLAN_LF_TIMER3_TARGET_GET(x)             (((x) & WLAN_LF_TIMER3_TARGET_MASK) >> WLAN_LF_TIMER3_TARGET_LSB)
-#define WLAN_LF_TIMER3_TARGET_SET(x)             (((x) << WLAN_LF_TIMER3_TARGET_LSB) & WLAN_LF_TIMER3_TARGET_MASK)
-
-#define WLAN_LF_TIMER_COUNT3_ADDRESS             0x0000007c
-#define WLAN_LF_TIMER_COUNT3_OFFSET              0x0000007c
-#define WLAN_LF_TIMER_COUNT3_VALUE_MSB           31
-#define WLAN_LF_TIMER_COUNT3_VALUE_LSB           0
-#define WLAN_LF_TIMER_COUNT3_VALUE_MASK          0xffffffff
-#define WLAN_LF_TIMER_COUNT3_VALUE_GET(x)        (((x) & WLAN_LF_TIMER_COUNT3_VALUE_MASK) >> WLAN_LF_TIMER_COUNT3_VALUE_LSB)
-#define WLAN_LF_TIMER_COUNT3_VALUE_SET(x)        (((x) << WLAN_LF_TIMER_COUNT3_VALUE_LSB) & WLAN_LF_TIMER_COUNT3_VALUE_MASK)
-
-#define WLAN_LF_TIMER_CONTROL3_ADDRESS           0x00000080
-#define WLAN_LF_TIMER_CONTROL3_OFFSET            0x00000080
-#define WLAN_LF_TIMER_CONTROL3_ENABLE_MSB        2
-#define WLAN_LF_TIMER_CONTROL3_ENABLE_LSB        2
-#define WLAN_LF_TIMER_CONTROL3_ENABLE_MASK       0x00000004
-#define WLAN_LF_TIMER_CONTROL3_ENABLE_GET(x)     (((x) & WLAN_LF_TIMER_CONTROL3_ENABLE_MASK) >> WLAN_LF_TIMER_CONTROL3_ENABLE_LSB)
-#define WLAN_LF_TIMER_CONTROL3_ENABLE_SET(x)     (((x) << WLAN_LF_TIMER_CONTROL3_ENABLE_LSB) & WLAN_LF_TIMER_CONTROL3_ENABLE_MASK)
-#define WLAN_LF_TIMER_CONTROL3_AUTO_RESTART_MSB  1
-#define WLAN_LF_TIMER_CONTROL3_AUTO_RESTART_LSB  1
-#define WLAN_LF_TIMER_CONTROL3_AUTO_RESTART_MASK 0x00000002
-#define WLAN_LF_TIMER_CONTROL3_AUTO_RESTART_GET(x) (((x) & WLAN_LF_TIMER_CONTROL3_AUTO_RESTART_MASK) >> WLAN_LF_TIMER_CONTROL3_AUTO_RESTART_LSB)
-#define WLAN_LF_TIMER_CONTROL3_AUTO_RESTART_SET(x) (((x) << WLAN_LF_TIMER_CONTROL3_AUTO_RESTART_LSB) & WLAN_LF_TIMER_CONTROL3_AUTO_RESTART_MASK)
-#define WLAN_LF_TIMER_CONTROL3_RESET_MSB         0
-#define WLAN_LF_TIMER_CONTROL3_RESET_LSB         0
-#define WLAN_LF_TIMER_CONTROL3_RESET_MASK        0x00000001
-#define WLAN_LF_TIMER_CONTROL3_RESET_GET(x)      (((x) & WLAN_LF_TIMER_CONTROL3_RESET_MASK) >> WLAN_LF_TIMER_CONTROL3_RESET_LSB)
-#define WLAN_LF_TIMER_CONTROL3_RESET_SET(x)      (((x) << WLAN_LF_TIMER_CONTROL3_RESET_LSB) & WLAN_LF_TIMER_CONTROL3_RESET_MASK)
-
-#define WLAN_LF_TIMER_STATUS3_ADDRESS            0x00000084
-#define WLAN_LF_TIMER_STATUS3_OFFSET             0x00000084
-#define WLAN_LF_TIMER_STATUS3_INTERRUPT_MSB      0
-#define WLAN_LF_TIMER_STATUS3_INTERRUPT_LSB      0
-#define WLAN_LF_TIMER_STATUS3_INTERRUPT_MASK     0x00000001
-#define WLAN_LF_TIMER_STATUS3_INTERRUPT_GET(x)   (((x) & WLAN_LF_TIMER_STATUS3_INTERRUPT_MASK) >> WLAN_LF_TIMER_STATUS3_INTERRUPT_LSB)
-#define WLAN_LF_TIMER_STATUS3_INTERRUPT_SET(x)   (((x) << WLAN_LF_TIMER_STATUS3_INTERRUPT_LSB) & WLAN_LF_TIMER_STATUS3_INTERRUPT_MASK)
-
-#define WLAN_HF_TIMER_ADDRESS                    0x00000088
-#define WLAN_HF_TIMER_OFFSET                     0x00000088
-#define WLAN_HF_TIMER_TARGET_MSB                 31
-#define WLAN_HF_TIMER_TARGET_LSB                 12
-#define WLAN_HF_TIMER_TARGET_MASK                0xfffff000
-#define WLAN_HF_TIMER_TARGET_GET(x)              (((x) & WLAN_HF_TIMER_TARGET_MASK) >> WLAN_HF_TIMER_TARGET_LSB)
-#define WLAN_HF_TIMER_TARGET_SET(x)              (((x) << WLAN_HF_TIMER_TARGET_LSB) & WLAN_HF_TIMER_TARGET_MASK)
-
-#define WLAN_HF_TIMER_COUNT_ADDRESS              0x0000008c
-#define WLAN_HF_TIMER_COUNT_OFFSET               0x0000008c
-#define WLAN_HF_TIMER_COUNT_VALUE_MSB            31
-#define WLAN_HF_TIMER_COUNT_VALUE_LSB            12
-#define WLAN_HF_TIMER_COUNT_VALUE_MASK           0xfffff000
-#define WLAN_HF_TIMER_COUNT_VALUE_GET(x)         (((x) & WLAN_HF_TIMER_COUNT_VALUE_MASK) >> WLAN_HF_TIMER_COUNT_VALUE_LSB)
-#define WLAN_HF_TIMER_COUNT_VALUE_SET(x)         (((x) << WLAN_HF_TIMER_COUNT_VALUE_LSB) & WLAN_HF_TIMER_COUNT_VALUE_MASK)
-
-#define WLAN_HF_LF_COUNT_ADDRESS                 0x00000090
-#define WLAN_HF_LF_COUNT_OFFSET                  0x00000090
-#define WLAN_HF_LF_COUNT_VALUE_MSB               31
-#define WLAN_HF_LF_COUNT_VALUE_LSB               0
-#define WLAN_HF_LF_COUNT_VALUE_MASK              0xffffffff
-#define WLAN_HF_LF_COUNT_VALUE_GET(x)            (((x) & WLAN_HF_LF_COUNT_VALUE_MASK) >> WLAN_HF_LF_COUNT_VALUE_LSB)
-#define WLAN_HF_LF_COUNT_VALUE_SET(x)            (((x) << WLAN_HF_LF_COUNT_VALUE_LSB) & WLAN_HF_LF_COUNT_VALUE_MASK)
-
-#define WLAN_HF_TIMER_CONTROL_ADDRESS            0x00000094
-#define WLAN_HF_TIMER_CONTROL_OFFSET             0x00000094
-#define WLAN_HF_TIMER_CONTROL_ENABLE_MSB         3
-#define WLAN_HF_TIMER_CONTROL_ENABLE_LSB         3
-#define WLAN_HF_TIMER_CONTROL_ENABLE_MASK        0x00000008
-#define WLAN_HF_TIMER_CONTROL_ENABLE_GET(x)      (((x) & WLAN_HF_TIMER_CONTROL_ENABLE_MASK) >> WLAN_HF_TIMER_CONTROL_ENABLE_LSB)
-#define WLAN_HF_TIMER_CONTROL_ENABLE_SET(x)      (((x) << WLAN_HF_TIMER_CONTROL_ENABLE_LSB) & WLAN_HF_TIMER_CONTROL_ENABLE_MASK)
-#define WLAN_HF_TIMER_CONTROL_ON_MSB             2
-#define WLAN_HF_TIMER_CONTROL_ON_LSB             2
-#define WLAN_HF_TIMER_CONTROL_ON_MASK            0x00000004
-#define WLAN_HF_TIMER_CONTROL_ON_GET(x)          (((x) & WLAN_HF_TIMER_CONTROL_ON_MASK) >> WLAN_HF_TIMER_CONTROL_ON_LSB)
-#define WLAN_HF_TIMER_CONTROL_ON_SET(x)          (((x) << WLAN_HF_TIMER_CONTROL_ON_LSB) & WLAN_HF_TIMER_CONTROL_ON_MASK)
-#define WLAN_HF_TIMER_CONTROL_AUTO_RESTART_MSB   1
-#define WLAN_HF_TIMER_CONTROL_AUTO_RESTART_LSB   1
-#define WLAN_HF_TIMER_CONTROL_AUTO_RESTART_MASK  0x00000002
-#define WLAN_HF_TIMER_CONTROL_AUTO_RESTART_GET(x) (((x) & WLAN_HF_TIMER_CONTROL_AUTO_RESTART_MASK) >> WLAN_HF_TIMER_CONTROL_AUTO_RESTART_LSB)
-#define WLAN_HF_TIMER_CONTROL_AUTO_RESTART_SET(x) (((x) << WLAN_HF_TIMER_CONTROL_AUTO_RESTART_LSB) & WLAN_HF_TIMER_CONTROL_AUTO_RESTART_MASK)
-#define WLAN_HF_TIMER_CONTROL_RESET_MSB          0
-#define WLAN_HF_TIMER_CONTROL_RESET_LSB          0
-#define WLAN_HF_TIMER_CONTROL_RESET_MASK         0x00000001
-#define WLAN_HF_TIMER_CONTROL_RESET_GET(x)       (((x) & WLAN_HF_TIMER_CONTROL_RESET_MASK) >> WLAN_HF_TIMER_CONTROL_RESET_LSB)
-#define WLAN_HF_TIMER_CONTROL_RESET_SET(x)       (((x) << WLAN_HF_TIMER_CONTROL_RESET_LSB) & WLAN_HF_TIMER_CONTROL_RESET_MASK)
-
-#define WLAN_HF_TIMER_STATUS_ADDRESS             0x00000098
-#define WLAN_HF_TIMER_STATUS_OFFSET              0x00000098
-#define WLAN_HF_TIMER_STATUS_INTERRUPT_MSB       0
-#define WLAN_HF_TIMER_STATUS_INTERRUPT_LSB       0
-#define WLAN_HF_TIMER_STATUS_INTERRUPT_MASK      0x00000001
-#define WLAN_HF_TIMER_STATUS_INTERRUPT_GET(x)    (((x) & WLAN_HF_TIMER_STATUS_INTERRUPT_MASK) >> WLAN_HF_TIMER_STATUS_INTERRUPT_LSB)
-#define WLAN_HF_TIMER_STATUS_INTERRUPT_SET(x)    (((x) << WLAN_HF_TIMER_STATUS_INTERRUPT_LSB) & WLAN_HF_TIMER_STATUS_INTERRUPT_MASK)
-
-#define WLAN_RTC_CONTROL_ADDRESS                 0x0000009c
-#define WLAN_RTC_CONTROL_OFFSET                  0x0000009c
-#define WLAN_RTC_CONTROL_ENABLE_MSB              2
-#define WLAN_RTC_CONTROL_ENABLE_LSB              2
-#define WLAN_RTC_CONTROL_ENABLE_MASK             0x00000004
-#define WLAN_RTC_CONTROL_ENABLE_GET(x)           (((x) & WLAN_RTC_CONTROL_ENABLE_MASK) >> WLAN_RTC_CONTROL_ENABLE_LSB)
-#define WLAN_RTC_CONTROL_ENABLE_SET(x)           (((x) << WLAN_RTC_CONTROL_ENABLE_LSB) & WLAN_RTC_CONTROL_ENABLE_MASK)
-#define WLAN_RTC_CONTROL_LOAD_RTC_MSB            1
-#define WLAN_RTC_CONTROL_LOAD_RTC_LSB            1
-#define WLAN_RTC_CONTROL_LOAD_RTC_MASK           0x00000002
-#define WLAN_RTC_CONTROL_LOAD_RTC_GET(x)         (((x) & WLAN_RTC_CONTROL_LOAD_RTC_MASK) >> WLAN_RTC_CONTROL_LOAD_RTC_LSB)
-#define WLAN_RTC_CONTROL_LOAD_RTC_SET(x)         (((x) << WLAN_RTC_CONTROL_LOAD_RTC_LSB) & WLAN_RTC_CONTROL_LOAD_RTC_MASK)
-#define WLAN_RTC_CONTROL_LOAD_ALARM_MSB          0
-#define WLAN_RTC_CONTROL_LOAD_ALARM_LSB          0
-#define WLAN_RTC_CONTROL_LOAD_ALARM_MASK         0x00000001
-#define WLAN_RTC_CONTROL_LOAD_ALARM_GET(x)       (((x) & WLAN_RTC_CONTROL_LOAD_ALARM_MASK) >> WLAN_RTC_CONTROL_LOAD_ALARM_LSB)
-#define WLAN_RTC_CONTROL_LOAD_ALARM_SET(x)       (((x) << WLAN_RTC_CONTROL_LOAD_ALARM_LSB) & WLAN_RTC_CONTROL_LOAD_ALARM_MASK)
-
-#define WLAN_RTC_TIME_ADDRESS                    0x000000a0
-#define WLAN_RTC_TIME_OFFSET                     0x000000a0
-#define WLAN_RTC_TIME_WEEK_DAY_MSB               26
-#define WLAN_RTC_TIME_WEEK_DAY_LSB               24
-#define WLAN_RTC_TIME_WEEK_DAY_MASK              0x07000000
-#define WLAN_RTC_TIME_WEEK_DAY_GET(x)            (((x) & WLAN_RTC_TIME_WEEK_DAY_MASK) >> WLAN_RTC_TIME_WEEK_DAY_LSB)
-#define WLAN_RTC_TIME_WEEK_DAY_SET(x)            (((x) << WLAN_RTC_TIME_WEEK_DAY_LSB) & WLAN_RTC_TIME_WEEK_DAY_MASK)
-#define WLAN_RTC_TIME_HOUR_MSB                   21
-#define WLAN_RTC_TIME_HOUR_LSB                   16
-#define WLAN_RTC_TIME_HOUR_MASK                  0x003f0000
-#define WLAN_RTC_TIME_HOUR_GET(x)                (((x) & WLAN_RTC_TIME_HOUR_MASK) >> WLAN_RTC_TIME_HOUR_LSB)
-#define WLAN_RTC_TIME_HOUR_SET(x)                (((x) << WLAN_RTC_TIME_HOUR_LSB) & WLAN_RTC_TIME_HOUR_MASK)
-#define WLAN_RTC_TIME_MINUTE_MSB                 14
-#define WLAN_RTC_TIME_MINUTE_LSB                 8
-#define WLAN_RTC_TIME_MINUTE_MASK                0x00007f00
-#define WLAN_RTC_TIME_MINUTE_GET(x)              (((x) & WLAN_RTC_TIME_MINUTE_MASK) >> WLAN_RTC_TIME_MINUTE_LSB)
-#define WLAN_RTC_TIME_MINUTE_SET(x)              (((x) << WLAN_RTC_TIME_MINUTE_LSB) & WLAN_RTC_TIME_MINUTE_MASK)
-#define WLAN_RTC_TIME_SECOND_MSB                 6
-#define WLAN_RTC_TIME_SECOND_LSB                 0
-#define WLAN_RTC_TIME_SECOND_MASK                0x0000007f
-#define WLAN_RTC_TIME_SECOND_GET(x)              (((x) & WLAN_RTC_TIME_SECOND_MASK) >> WLAN_RTC_TIME_SECOND_LSB)
-#define WLAN_RTC_TIME_SECOND_SET(x)              (((x) << WLAN_RTC_TIME_SECOND_LSB) & WLAN_RTC_TIME_SECOND_MASK)
-
-#define WLAN_RTC_DATE_ADDRESS                    0x000000a4
-#define WLAN_RTC_DATE_OFFSET                     0x000000a4
-#define WLAN_RTC_DATE_YEAR_MSB                   23
-#define WLAN_RTC_DATE_YEAR_LSB                   16
-#define WLAN_RTC_DATE_YEAR_MASK                  0x00ff0000
-#define WLAN_RTC_DATE_YEAR_GET(x)                (((x) & WLAN_RTC_DATE_YEAR_MASK) >> WLAN_RTC_DATE_YEAR_LSB)
-#define WLAN_RTC_DATE_YEAR_SET(x)                (((x) << WLAN_RTC_DATE_YEAR_LSB) & WLAN_RTC_DATE_YEAR_MASK)
-#define WLAN_RTC_DATE_MONTH_MSB                  12
-#define WLAN_RTC_DATE_MONTH_LSB                  8
-#define WLAN_RTC_DATE_MONTH_MASK                 0x00001f00
-#define WLAN_RTC_DATE_MONTH_GET(x)               (((x) & WLAN_RTC_DATE_MONTH_MASK) >> WLAN_RTC_DATE_MONTH_LSB)
-#define WLAN_RTC_DATE_MONTH_SET(x)               (((x) << WLAN_RTC_DATE_MONTH_LSB) & WLAN_RTC_DATE_MONTH_MASK)
-#define WLAN_RTC_DATE_MONTH_DAY_MSB              5
-#define WLAN_RTC_DATE_MONTH_DAY_LSB              0
-#define WLAN_RTC_DATE_MONTH_DAY_MASK             0x0000003f
-#define WLAN_RTC_DATE_MONTH_DAY_GET(x)           (((x) & WLAN_RTC_DATE_MONTH_DAY_MASK) >> WLAN_RTC_DATE_MONTH_DAY_LSB)
-#define WLAN_RTC_DATE_MONTH_DAY_SET(x)           (((x) << WLAN_RTC_DATE_MONTH_DAY_LSB) & WLAN_RTC_DATE_MONTH_DAY_MASK)
-
-#define WLAN_RTC_SET_TIME_ADDRESS                0x000000a8
-#define WLAN_RTC_SET_TIME_OFFSET                 0x000000a8
-#define WLAN_RTC_SET_TIME_WEEK_DAY_MSB           26
-#define WLAN_RTC_SET_TIME_WEEK_DAY_LSB           24
-#define WLAN_RTC_SET_TIME_WEEK_DAY_MASK          0x07000000
-#define WLAN_RTC_SET_TIME_WEEK_DAY_GET(x)        (((x) & WLAN_RTC_SET_TIME_WEEK_DAY_MASK) >> WLAN_RTC_SET_TIME_WEEK_DAY_LSB)
-#define WLAN_RTC_SET_TIME_WEEK_DAY_SET(x)        (((x) << WLAN_RTC_SET_TIME_WEEK_DAY_LSB) & WLAN_RTC_SET_TIME_WEEK_DAY_MASK)
-#define WLAN_RTC_SET_TIME_HOUR_MSB               21
-#define WLAN_RTC_SET_TIME_HOUR_LSB               16
-#define WLAN_RTC_SET_TIME_HOUR_MASK              0x003f0000
-#define WLAN_RTC_SET_TIME_HOUR_GET(x)            (((x) & WLAN_RTC_SET_TIME_HOUR_MASK) >> WLAN_RTC_SET_TIME_HOUR_LSB)
-#define WLAN_RTC_SET_TIME_HOUR_SET(x)            (((x) << WLAN_RTC_SET_TIME_HOUR_LSB) & WLAN_RTC_SET_TIME_HOUR_MASK)
-#define WLAN_RTC_SET_TIME_MINUTE_MSB             14
-#define WLAN_RTC_SET_TIME_MINUTE_LSB             8
-#define WLAN_RTC_SET_TIME_MINUTE_MASK            0x00007f00
-#define WLAN_RTC_SET_TIME_MINUTE_GET(x)          (((x) & WLAN_RTC_SET_TIME_MINUTE_MASK) >> WLAN_RTC_SET_TIME_MINUTE_LSB)
-#define WLAN_RTC_SET_TIME_MINUTE_SET(x)          (((x) << WLAN_RTC_SET_TIME_MINUTE_LSB) & WLAN_RTC_SET_TIME_MINUTE_MASK)
-#define WLAN_RTC_SET_TIME_SECOND_MSB             6
-#define WLAN_RTC_SET_TIME_SECOND_LSB             0
-#define WLAN_RTC_SET_TIME_SECOND_MASK            0x0000007f
-#define WLAN_RTC_SET_TIME_SECOND_GET(x)          (((x) & WLAN_RTC_SET_TIME_SECOND_MASK) >> WLAN_RTC_SET_TIME_SECOND_LSB)
-#define WLAN_RTC_SET_TIME_SECOND_SET(x)          (((x) << WLAN_RTC_SET_TIME_SECOND_LSB) & WLAN_RTC_SET_TIME_SECOND_MASK)
-
-#define WLAN_RTC_SET_DATE_ADDRESS                0x000000ac
-#define WLAN_RTC_SET_DATE_OFFSET                 0x000000ac
-#define WLAN_RTC_SET_DATE_YEAR_MSB               23
-#define WLAN_RTC_SET_DATE_YEAR_LSB               16
-#define WLAN_RTC_SET_DATE_YEAR_MASK              0x00ff0000
-#define WLAN_RTC_SET_DATE_YEAR_GET(x)            (((x) & WLAN_RTC_SET_DATE_YEAR_MASK) >> WLAN_RTC_SET_DATE_YEAR_LSB)
-#define WLAN_RTC_SET_DATE_YEAR_SET(x)            (((x) << WLAN_RTC_SET_DATE_YEAR_LSB) & WLAN_RTC_SET_DATE_YEAR_MASK)
-#define WLAN_RTC_SET_DATE_MONTH_MSB              12
-#define WLAN_RTC_SET_DATE_MONTH_LSB              8
-#define WLAN_RTC_SET_DATE_MONTH_MASK             0x00001f00
-#define WLAN_RTC_SET_DATE_MONTH_GET(x)           (((x) & WLAN_RTC_SET_DATE_MONTH_MASK) >> WLAN_RTC_SET_DATE_MONTH_LSB)
-#define WLAN_RTC_SET_DATE_MONTH_SET(x)           (((x) << WLAN_RTC_SET_DATE_MONTH_LSB) & WLAN_RTC_SET_DATE_MONTH_MASK)
-#define WLAN_RTC_SET_DATE_MONTH_DAY_MSB          5
-#define WLAN_RTC_SET_DATE_MONTH_DAY_LSB          0
-#define WLAN_RTC_SET_DATE_MONTH_DAY_MASK         0x0000003f
-#define WLAN_RTC_SET_DATE_MONTH_DAY_GET(x)       (((x) & WLAN_RTC_SET_DATE_MONTH_DAY_MASK) >> WLAN_RTC_SET_DATE_MONTH_DAY_LSB)
-#define WLAN_RTC_SET_DATE_MONTH_DAY_SET(x)       (((x) << WLAN_RTC_SET_DATE_MONTH_DAY_LSB) & WLAN_RTC_SET_DATE_MONTH_DAY_MASK)
-
-#define WLAN_RTC_SET_ALARM_ADDRESS               0x000000b0
-#define WLAN_RTC_SET_ALARM_OFFSET                0x000000b0
-#define WLAN_RTC_SET_ALARM_HOUR_MSB              21
-#define WLAN_RTC_SET_ALARM_HOUR_LSB              16
-#define WLAN_RTC_SET_ALARM_HOUR_MASK             0x003f0000
-#define WLAN_RTC_SET_ALARM_HOUR_GET(x)           (((x) & WLAN_RTC_SET_ALARM_HOUR_MASK) >> WLAN_RTC_SET_ALARM_HOUR_LSB)
-#define WLAN_RTC_SET_ALARM_HOUR_SET(x)           (((x) << WLAN_RTC_SET_ALARM_HOUR_LSB) & WLAN_RTC_SET_ALARM_HOUR_MASK)
-#define WLAN_RTC_SET_ALARM_MINUTE_MSB            14
-#define WLAN_RTC_SET_ALARM_MINUTE_LSB            8
-#define WLAN_RTC_SET_ALARM_MINUTE_MASK           0x00007f00
-#define WLAN_RTC_SET_ALARM_MINUTE_GET(x)         (((x) & WLAN_RTC_SET_ALARM_MINUTE_MASK) >> WLAN_RTC_SET_ALARM_MINUTE_LSB)
-#define WLAN_RTC_SET_ALARM_MINUTE_SET(x)         (((x) << WLAN_RTC_SET_ALARM_MINUTE_LSB) & WLAN_RTC_SET_ALARM_MINUTE_MASK)
-#define WLAN_RTC_SET_ALARM_SECOND_MSB            6
-#define WLAN_RTC_SET_ALARM_SECOND_LSB            0
-#define WLAN_RTC_SET_ALARM_SECOND_MASK           0x0000007f
-#define WLAN_RTC_SET_ALARM_SECOND_GET(x)         (((x) & WLAN_RTC_SET_ALARM_SECOND_MASK) >> WLAN_RTC_SET_ALARM_SECOND_LSB)
-#define WLAN_RTC_SET_ALARM_SECOND_SET(x)         (((x) << WLAN_RTC_SET_ALARM_SECOND_LSB) & WLAN_RTC_SET_ALARM_SECOND_MASK)
-
-#define WLAN_RTC_CONFIG_ADDRESS                  0x000000b4
-#define WLAN_RTC_CONFIG_OFFSET                   0x000000b4
-#define WLAN_RTC_CONFIG_BCD_MSB                  2
-#define WLAN_RTC_CONFIG_BCD_LSB                  2
-#define WLAN_RTC_CONFIG_BCD_MASK                 0x00000004
-#define WLAN_RTC_CONFIG_BCD_GET(x)               (((x) & WLAN_RTC_CONFIG_BCD_MASK) >> WLAN_RTC_CONFIG_BCD_LSB)
-#define WLAN_RTC_CONFIG_BCD_SET(x)               (((x) << WLAN_RTC_CONFIG_BCD_LSB) & WLAN_RTC_CONFIG_BCD_MASK)
-#define WLAN_RTC_CONFIG_TWELVE_HOUR_MSB          1
-#define WLAN_RTC_CONFIG_TWELVE_HOUR_LSB          1
-#define WLAN_RTC_CONFIG_TWELVE_HOUR_MASK         0x00000002
-#define WLAN_RTC_CONFIG_TWELVE_HOUR_GET(x)       (((x) & WLAN_RTC_CONFIG_TWELVE_HOUR_MASK) >> WLAN_RTC_CONFIG_TWELVE_HOUR_LSB)
-#define WLAN_RTC_CONFIG_TWELVE_HOUR_SET(x)       (((x) << WLAN_RTC_CONFIG_TWELVE_HOUR_LSB) & WLAN_RTC_CONFIG_TWELVE_HOUR_MASK)
-#define WLAN_RTC_CONFIG_DSE_MSB                  0
-#define WLAN_RTC_CONFIG_DSE_LSB                  0
-#define WLAN_RTC_CONFIG_DSE_MASK                 0x00000001
-#define WLAN_RTC_CONFIG_DSE_GET(x)               (((x) & WLAN_RTC_CONFIG_DSE_MASK) >> WLAN_RTC_CONFIG_DSE_LSB)
-#define WLAN_RTC_CONFIG_DSE_SET(x)               (((x) << WLAN_RTC_CONFIG_DSE_LSB) & WLAN_RTC_CONFIG_DSE_MASK)
-
-#define WLAN_RTC_ALARM_STATUS_ADDRESS            0x000000b8
-#define WLAN_RTC_ALARM_STATUS_OFFSET             0x000000b8
-#define WLAN_RTC_ALARM_STATUS_ENABLE_MSB         1
-#define WLAN_RTC_ALARM_STATUS_ENABLE_LSB         1
-#define WLAN_RTC_ALARM_STATUS_ENABLE_MASK        0x00000002
-#define WLAN_RTC_ALARM_STATUS_ENABLE_GET(x)      (((x) & WLAN_RTC_ALARM_STATUS_ENABLE_MASK) >> WLAN_RTC_ALARM_STATUS_ENABLE_LSB)
-#define WLAN_RTC_ALARM_STATUS_ENABLE_SET(x)      (((x) << WLAN_RTC_ALARM_STATUS_ENABLE_LSB) & WLAN_RTC_ALARM_STATUS_ENABLE_MASK)
-#define WLAN_RTC_ALARM_STATUS_INTERRUPT_MSB      0
-#define WLAN_RTC_ALARM_STATUS_INTERRUPT_LSB      0
-#define WLAN_RTC_ALARM_STATUS_INTERRUPT_MASK     0x00000001
-#define WLAN_RTC_ALARM_STATUS_INTERRUPT_GET(x)   (((x) & WLAN_RTC_ALARM_STATUS_INTERRUPT_MASK) >> WLAN_RTC_ALARM_STATUS_INTERRUPT_LSB)
-#define WLAN_RTC_ALARM_STATUS_INTERRUPT_SET(x)   (((x) << WLAN_RTC_ALARM_STATUS_INTERRUPT_LSB) & WLAN_RTC_ALARM_STATUS_INTERRUPT_MASK)
-
-#define WLAN_UART_WAKEUP_ADDRESS                 0x000000bc
-#define WLAN_UART_WAKEUP_OFFSET                  0x000000bc
-#define WLAN_UART_WAKEUP_ENABLE_MSB              0
-#define WLAN_UART_WAKEUP_ENABLE_LSB              0
-#define WLAN_UART_WAKEUP_ENABLE_MASK             0x00000001
-#define WLAN_UART_WAKEUP_ENABLE_GET(x)           (((x) & WLAN_UART_WAKEUP_ENABLE_MASK) >> WLAN_UART_WAKEUP_ENABLE_LSB)
-#define WLAN_UART_WAKEUP_ENABLE_SET(x)           (((x) << WLAN_UART_WAKEUP_ENABLE_LSB) & WLAN_UART_WAKEUP_ENABLE_MASK)
-
-#define WLAN_RESET_CAUSE_ADDRESS                 0x000000c0
-#define WLAN_RESET_CAUSE_OFFSET                  0x000000c0
-#define WLAN_RESET_CAUSE_LAST_MSB                2
-#define WLAN_RESET_CAUSE_LAST_LSB                0
-#define WLAN_RESET_CAUSE_LAST_MASK               0x00000007
-#define WLAN_RESET_CAUSE_LAST_GET(x)             (((x) & WLAN_RESET_CAUSE_LAST_MASK) >> WLAN_RESET_CAUSE_LAST_LSB)
-#define WLAN_RESET_CAUSE_LAST_SET(x)             (((x) << WLAN_RESET_CAUSE_LAST_LSB) & WLAN_RESET_CAUSE_LAST_MASK)
-
 #define WLAN_SYSTEM_SLEEP_ADDRESS                0x000000c4
 #define WLAN_SYSTEM_SLEEP_OFFSET                 0x000000c4
 #define WLAN_SYSTEM_SLEEP_HOST_IF_MSB            4
 #define WLAN_SYSTEM_SLEEP_DISABLE_GET(x)         (((x) & WLAN_SYSTEM_SLEEP_DISABLE_MASK) >> WLAN_SYSTEM_SLEEP_DISABLE_LSB)
 #define WLAN_SYSTEM_SLEEP_DISABLE_SET(x)         (((x) << WLAN_SYSTEM_SLEEP_DISABLE_LSB) & WLAN_SYSTEM_SLEEP_DISABLE_MASK)
 
-#define WLAN_SDIO_WRAPPER_ADDRESS                0x000000c8
-#define WLAN_SDIO_WRAPPER_OFFSET                 0x000000c8
-#define WLAN_SDIO_WRAPPER_SLEEP_MSB              3
-#define WLAN_SDIO_WRAPPER_SLEEP_LSB              3
-#define WLAN_SDIO_WRAPPER_SLEEP_MASK             0x00000008
-#define WLAN_SDIO_WRAPPER_SLEEP_GET(x)           (((x) & WLAN_SDIO_WRAPPER_SLEEP_MASK) >> WLAN_SDIO_WRAPPER_SLEEP_LSB)
-#define WLAN_SDIO_WRAPPER_SLEEP_SET(x)           (((x) << WLAN_SDIO_WRAPPER_SLEEP_LSB) & WLAN_SDIO_WRAPPER_SLEEP_MASK)
-#define WLAN_SDIO_WRAPPER_WAKEUP_MSB             2
-#define WLAN_SDIO_WRAPPER_WAKEUP_LSB             2
-#define WLAN_SDIO_WRAPPER_WAKEUP_MASK            0x00000004
-#define WLAN_SDIO_WRAPPER_WAKEUP_GET(x)          (((x) & WLAN_SDIO_WRAPPER_WAKEUP_MASK) >> WLAN_SDIO_WRAPPER_WAKEUP_LSB)
-#define WLAN_SDIO_WRAPPER_WAKEUP_SET(x)          (((x) << WLAN_SDIO_WRAPPER_WAKEUP_LSB) & WLAN_SDIO_WRAPPER_WAKEUP_MASK)
-#define WLAN_SDIO_WRAPPER_SOC_ON_MSB             1
-#define WLAN_SDIO_WRAPPER_SOC_ON_LSB             1
-#define WLAN_SDIO_WRAPPER_SOC_ON_MASK            0x00000002
-#define WLAN_SDIO_WRAPPER_SOC_ON_GET(x)          (((x) & WLAN_SDIO_WRAPPER_SOC_ON_MASK) >> WLAN_SDIO_WRAPPER_SOC_ON_LSB)
-#define WLAN_SDIO_WRAPPER_SOC_ON_SET(x)          (((x) << WLAN_SDIO_WRAPPER_SOC_ON_LSB) & WLAN_SDIO_WRAPPER_SOC_ON_MASK)
-#define WLAN_SDIO_WRAPPER_ON_MSB                 0
-#define WLAN_SDIO_WRAPPER_ON_LSB                 0
-#define WLAN_SDIO_WRAPPER_ON_MASK                0x00000001
-#define WLAN_SDIO_WRAPPER_ON_GET(x)              (((x) & WLAN_SDIO_WRAPPER_ON_MASK) >> WLAN_SDIO_WRAPPER_ON_LSB)
-#define WLAN_SDIO_WRAPPER_ON_SET(x)              (((x) << WLAN_SDIO_WRAPPER_ON_LSB) & WLAN_SDIO_WRAPPER_ON_MASK)
-
-#define WLAN_MAC_SLEEP_CONTROL_ADDRESS           0x000000cc
-#define WLAN_MAC_SLEEP_CONTROL_OFFSET            0x000000cc
-#define WLAN_MAC_SLEEP_CONTROL_ENABLE_MSB        1
-#define WLAN_MAC_SLEEP_CONTROL_ENABLE_LSB        0
-#define WLAN_MAC_SLEEP_CONTROL_ENABLE_MASK       0x00000003
-#define WLAN_MAC_SLEEP_CONTROL_ENABLE_GET(x)     (((x) & WLAN_MAC_SLEEP_CONTROL_ENABLE_MASK) >> WLAN_MAC_SLEEP_CONTROL_ENABLE_LSB)
-#define WLAN_MAC_SLEEP_CONTROL_ENABLE_SET(x)     (((x) << WLAN_MAC_SLEEP_CONTROL_ENABLE_LSB) & WLAN_MAC_SLEEP_CONTROL_ENABLE_MASK)
-
-#define WLAN_KEEP_AWAKE_ADDRESS                  0x000000d0
-#define WLAN_KEEP_AWAKE_OFFSET                   0x000000d0
-#define WLAN_KEEP_AWAKE_COUNT_MSB                7
-#define WLAN_KEEP_AWAKE_COUNT_LSB                0
-#define WLAN_KEEP_AWAKE_COUNT_MASK               0x000000ff
-#define WLAN_KEEP_AWAKE_COUNT_GET(x)             (((x) & WLAN_KEEP_AWAKE_COUNT_MASK) >> WLAN_KEEP_AWAKE_COUNT_LSB)
-#define WLAN_KEEP_AWAKE_COUNT_SET(x)             (((x) << WLAN_KEEP_AWAKE_COUNT_LSB) & WLAN_KEEP_AWAKE_COUNT_MASK)
-
-#define WLAN_LPO_CAL_TIME_ADDRESS                0x000000d4
-#define WLAN_LPO_CAL_TIME_OFFSET                 0x000000d4
-#define WLAN_LPO_CAL_TIME_LENGTH_MSB             13
-#define WLAN_LPO_CAL_TIME_LENGTH_LSB             0
-#define WLAN_LPO_CAL_TIME_LENGTH_MASK            0x00003fff
-#define WLAN_LPO_CAL_TIME_LENGTH_GET(x)          (((x) & WLAN_LPO_CAL_TIME_LENGTH_MASK) >> WLAN_LPO_CAL_TIME_LENGTH_LSB)
-#define WLAN_LPO_CAL_TIME_LENGTH_SET(x)          (((x) << WLAN_LPO_CAL_TIME_LENGTH_LSB) & WLAN_LPO_CAL_TIME_LENGTH_MASK)
-
-#define WLAN_LPO_INIT_DIVIDEND_INT_ADDRESS       0x000000d8
-#define WLAN_LPO_INIT_DIVIDEND_INT_OFFSET        0x000000d8
-#define WLAN_LPO_INIT_DIVIDEND_INT_VALUE_MSB     23
-#define WLAN_LPO_INIT_DIVIDEND_INT_VALUE_LSB     0
-#define WLAN_LPO_INIT_DIVIDEND_INT_VALUE_MASK    0x00ffffff
-#define WLAN_LPO_INIT_DIVIDEND_INT_VALUE_GET(x)  (((x) & WLAN_LPO_INIT_DIVIDEND_INT_VALUE_MASK) >> WLAN_LPO_INIT_DIVIDEND_INT_VALUE_LSB)
-#define WLAN_LPO_INIT_DIVIDEND_INT_VALUE_SET(x)  (((x) << WLAN_LPO_INIT_DIVIDEND_INT_VALUE_LSB) & WLAN_LPO_INIT_DIVIDEND_INT_VALUE_MASK)
-
-#define WLAN_LPO_INIT_DIVIDEND_FRACTION_ADDRESS  0x000000dc
-#define WLAN_LPO_INIT_DIVIDEND_FRACTION_OFFSET   0x000000dc
-#define WLAN_LPO_INIT_DIVIDEND_FRACTION_VALUE_MSB 10
-#define WLAN_LPO_INIT_DIVIDEND_FRACTION_VALUE_LSB 0
-#define WLAN_LPO_INIT_DIVIDEND_FRACTION_VALUE_MASK 0x000007ff
-#define WLAN_LPO_INIT_DIVIDEND_FRACTION_VALUE_GET(x) (((x) & WLAN_LPO_INIT_DIVIDEND_FRACTION_VALUE_MASK) >> WLAN_LPO_INIT_DIVIDEND_FRACTION_VALUE_LSB)
-#define WLAN_LPO_INIT_DIVIDEND_FRACTION_VALUE_SET(x) (((x) << WLAN_LPO_INIT_DIVIDEND_FRACTION_VALUE_LSB) & WLAN_LPO_INIT_DIVIDEND_FRACTION_VALUE_MASK)
-
 #define WLAN_LPO_CAL_ADDRESS                     0x000000e0
 #define WLAN_LPO_CAL_OFFSET                      0x000000e0
 #define WLAN_LPO_CAL_ENABLE_MSB                  20
 #define WLAN_LPO_CAL_COUNT_GET(x)                (((x) & WLAN_LPO_CAL_COUNT_MASK) >> WLAN_LPO_CAL_COUNT_LSB)
 #define WLAN_LPO_CAL_COUNT_SET(x)                (((x) << WLAN_LPO_CAL_COUNT_LSB) & WLAN_LPO_CAL_COUNT_MASK)
 
-#define WLAN_LPO_CAL_TEST_CONTROL_ADDRESS        0x000000e4
-#define WLAN_LPO_CAL_TEST_CONTROL_OFFSET         0x000000e4
-#define WLAN_LPO_CAL_TEST_CONTROL_ENABLE_MSB     5
-#define WLAN_LPO_CAL_TEST_CONTROL_ENABLE_LSB     5
-#define WLAN_LPO_CAL_TEST_CONTROL_ENABLE_MASK    0x00000020
-#define WLAN_LPO_CAL_TEST_CONTROL_ENABLE_GET(x)  (((x) & WLAN_LPO_CAL_TEST_CONTROL_ENABLE_MASK) >> WLAN_LPO_CAL_TEST_CONTROL_ENABLE_LSB)
-#define WLAN_LPO_CAL_TEST_CONTROL_ENABLE_SET(x)  (((x) << WLAN_LPO_CAL_TEST_CONTROL_ENABLE_LSB) & WLAN_LPO_CAL_TEST_CONTROL_ENABLE_MASK)
-#define WLAN_LPO_CAL_TEST_CONTROL_RTC_CYCLES_MSB 4
-#define WLAN_LPO_CAL_TEST_CONTROL_RTC_CYCLES_LSB 0
-#define WLAN_LPO_CAL_TEST_CONTROL_RTC_CYCLES_MASK 0x0000001f
-#define WLAN_LPO_CAL_TEST_CONTROL_RTC_CYCLES_GET(x) (((x) & WLAN_LPO_CAL_TEST_CONTROL_RTC_CYCLES_MASK) >> WLAN_LPO_CAL_TEST_CONTROL_RTC_CYCLES_LSB)
-#define WLAN_LPO_CAL_TEST_CONTROL_RTC_CYCLES_SET(x) (((x) << WLAN_LPO_CAL_TEST_CONTROL_RTC_CYCLES_LSB) & WLAN_LPO_CAL_TEST_CONTROL_RTC_CYCLES_MASK)
-
-#define WLAN_LPO_CAL_TEST_STATUS_ADDRESS         0x000000e8
-#define WLAN_LPO_CAL_TEST_STATUS_OFFSET          0x000000e8
-#define WLAN_LPO_CAL_TEST_STATUS_READY_MSB       16
-#define WLAN_LPO_CAL_TEST_STATUS_READY_LSB       16
-#define WLAN_LPO_CAL_TEST_STATUS_READY_MASK      0x00010000
-#define WLAN_LPO_CAL_TEST_STATUS_READY_GET(x)    (((x) & WLAN_LPO_CAL_TEST_STATUS_READY_MASK) >> WLAN_LPO_CAL_TEST_STATUS_READY_LSB)
-#define WLAN_LPO_CAL_TEST_STATUS_READY_SET(x)    (((x) << WLAN_LPO_CAL_TEST_STATUS_READY_LSB) & WLAN_LPO_CAL_TEST_STATUS_READY_MASK)
-#define WLAN_LPO_CAL_TEST_STATUS_COUNT_MSB       15
-#define WLAN_LPO_CAL_TEST_STATUS_COUNT_LSB       0
-#define WLAN_LPO_CAL_TEST_STATUS_COUNT_MASK      0x0000ffff
-#define WLAN_LPO_CAL_TEST_STATUS_COUNT_GET(x)    (((x) & WLAN_LPO_CAL_TEST_STATUS_COUNT_MASK) >> WLAN_LPO_CAL_TEST_STATUS_COUNT_LSB)
-#define WLAN_LPO_CAL_TEST_STATUS_COUNT_SET(x)    (((x) << WLAN_LPO_CAL_TEST_STATUS_COUNT_LSB) & WLAN_LPO_CAL_TEST_STATUS_COUNT_MASK)
-
-#define WLAN_CHIP_ID_ADDRESS                     0x000000ec
-#define WLAN_CHIP_ID_OFFSET                      0x000000ec
-#define WLAN_CHIP_ID_DEVICE_ID_MSB               31
-#define WLAN_CHIP_ID_DEVICE_ID_LSB               16
-#define WLAN_CHIP_ID_DEVICE_ID_MASK              0xffff0000
-#define WLAN_CHIP_ID_DEVICE_ID_GET(x)            (((x) & WLAN_CHIP_ID_DEVICE_ID_MASK) >> WLAN_CHIP_ID_DEVICE_ID_LSB)
-#define WLAN_CHIP_ID_DEVICE_ID_SET(x)            (((x) << WLAN_CHIP_ID_DEVICE_ID_LSB) & WLAN_CHIP_ID_DEVICE_ID_MASK)
-#define WLAN_CHIP_ID_CONFIG_ID_MSB               15
-#define WLAN_CHIP_ID_CONFIG_ID_LSB               4
-#define WLAN_CHIP_ID_CONFIG_ID_MASK              0x0000fff0
-#define WLAN_CHIP_ID_CONFIG_ID_GET(x)            (((x) & WLAN_CHIP_ID_CONFIG_ID_MASK) >> WLAN_CHIP_ID_CONFIG_ID_LSB)
-#define WLAN_CHIP_ID_CONFIG_ID_SET(x)            (((x) << WLAN_CHIP_ID_CONFIG_ID_LSB) & WLAN_CHIP_ID_CONFIG_ID_MASK)
-#define WLAN_CHIP_ID_VERSION_ID_MSB              3
-#define WLAN_CHIP_ID_VERSION_ID_LSB              0
-#define WLAN_CHIP_ID_VERSION_ID_MASK             0x0000000f
-#define WLAN_CHIP_ID_VERSION_ID_GET(x)           (((x) & WLAN_CHIP_ID_VERSION_ID_MASK) >> WLAN_CHIP_ID_VERSION_ID_LSB)
-#define WLAN_CHIP_ID_VERSION_ID_SET(x)           (((x) << WLAN_CHIP_ID_VERSION_ID_LSB) & WLAN_CHIP_ID_VERSION_ID_MASK)
-
-#define WLAN_DERIVED_RTC_CLK_ADDRESS             0x000000f0
-#define WLAN_DERIVED_RTC_CLK_OFFSET              0x000000f0
-#define WLAN_DERIVED_RTC_CLK_EXTERNAL_DETECT_EN_MSB 20
-#define WLAN_DERIVED_RTC_CLK_EXTERNAL_DETECT_EN_LSB 20
-#define WLAN_DERIVED_RTC_CLK_EXTERNAL_DETECT_EN_MASK 0x00100000
-#define WLAN_DERIVED_RTC_CLK_EXTERNAL_DETECT_EN_GET(x) (((x) & WLAN_DERIVED_RTC_CLK_EXTERNAL_DETECT_EN_MASK) >> WLAN_DERIVED_RTC_CLK_EXTERNAL_DETECT_EN_LSB)
-#define WLAN_DERIVED_RTC_CLK_EXTERNAL_DETECT_EN_SET(x) (((x) << WLAN_DERIVED_RTC_CLK_EXTERNAL_DETECT_EN_LSB) & WLAN_DERIVED_RTC_CLK_EXTERNAL_DETECT_EN_MASK)
-#define WLAN_DERIVED_RTC_CLK_EXTERNAL_DETECT_MSB 18
-#define WLAN_DERIVED_RTC_CLK_EXTERNAL_DETECT_LSB 18
-#define WLAN_DERIVED_RTC_CLK_EXTERNAL_DETECT_MASK 0x00040000
-#define WLAN_DERIVED_RTC_CLK_EXTERNAL_DETECT_GET(x) (((x) & WLAN_DERIVED_RTC_CLK_EXTERNAL_DETECT_MASK) >> WLAN_DERIVED_RTC_CLK_EXTERNAL_DETECT_LSB)
-#define WLAN_DERIVED_RTC_CLK_EXTERNAL_DETECT_SET(x) (((x) << WLAN_DERIVED_RTC_CLK_EXTERNAL_DETECT_LSB) & WLAN_DERIVED_RTC_CLK_EXTERNAL_DETECT_MASK)
-#define WLAN_DERIVED_RTC_CLK_FORCE_MSB           17
-#define WLAN_DERIVED_RTC_CLK_FORCE_LSB           16
-#define WLAN_DERIVED_RTC_CLK_FORCE_MASK          0x00030000
-#define WLAN_DERIVED_RTC_CLK_FORCE_GET(x)        (((x) & WLAN_DERIVED_RTC_CLK_FORCE_MASK) >> WLAN_DERIVED_RTC_CLK_FORCE_LSB)
-#define WLAN_DERIVED_RTC_CLK_FORCE_SET(x)        (((x) << WLAN_DERIVED_RTC_CLK_FORCE_LSB) & WLAN_DERIVED_RTC_CLK_FORCE_MASK)
-#define WLAN_DERIVED_RTC_CLK_PERIOD_MSB          15
-#define WLAN_DERIVED_RTC_CLK_PERIOD_LSB          1
-#define WLAN_DERIVED_RTC_CLK_PERIOD_MASK         0x0000fffe
-#define WLAN_DERIVED_RTC_CLK_PERIOD_GET(x)       (((x) & WLAN_DERIVED_RTC_CLK_PERIOD_MASK) >> WLAN_DERIVED_RTC_CLK_PERIOD_LSB)
-#define WLAN_DERIVED_RTC_CLK_PERIOD_SET(x)       (((x) << WLAN_DERIVED_RTC_CLK_PERIOD_LSB) & WLAN_DERIVED_RTC_CLK_PERIOD_MASK)
-
-#define MAC_PCU_SLP32_MODE_ADDRESS               0x000000f4
-#define MAC_PCU_SLP32_MODE_OFFSET                0x000000f4
-#define MAC_PCU_SLP32_MODE_TSF2_WRITE_STATUS_MSB 24
-#define MAC_PCU_SLP32_MODE_TSF2_WRITE_STATUS_LSB 24
-#define MAC_PCU_SLP32_MODE_TSF2_WRITE_STATUS_MASK 0x01000000
-#define MAC_PCU_SLP32_MODE_TSF2_WRITE_STATUS_GET(x) (((x) & MAC_PCU_SLP32_MODE_TSF2_WRITE_STATUS_MASK) >> MAC_PCU_SLP32_MODE_TSF2_WRITE_STATUS_LSB)
-#define MAC_PCU_SLP32_MODE_TSF2_WRITE_STATUS_SET(x) (((x) << MAC_PCU_SLP32_MODE_TSF2_WRITE_STATUS_LSB) & MAC_PCU_SLP32_MODE_TSF2_WRITE_STATUS_MASK)
-#define MAC_PCU_SLP32_MODE_FORCE_BIAS_BLOCK_ON_MSB 23
-#define MAC_PCU_SLP32_MODE_FORCE_BIAS_BLOCK_ON_LSB 23
-#define MAC_PCU_SLP32_MODE_FORCE_BIAS_BLOCK_ON_MASK 0x00800000
-#define MAC_PCU_SLP32_MODE_FORCE_BIAS_BLOCK_ON_GET(x) (((x) & MAC_PCU_SLP32_MODE_FORCE_BIAS_BLOCK_ON_MASK) >> MAC_PCU_SLP32_MODE_FORCE_BIAS_BLOCK_ON_LSB)
-#define MAC_PCU_SLP32_MODE_FORCE_BIAS_BLOCK_ON_SET(x) (((x) << MAC_PCU_SLP32_MODE_FORCE_BIAS_BLOCK_ON_LSB) & MAC_PCU_SLP32_MODE_FORCE_BIAS_BLOCK_ON_MASK)
-#define MAC_PCU_SLP32_MODE_DISABLE_32KHZ_MSB     22
-#define MAC_PCU_SLP32_MODE_DISABLE_32KHZ_LSB     22
-#define MAC_PCU_SLP32_MODE_DISABLE_32KHZ_MASK    0x00400000
-#define MAC_PCU_SLP32_MODE_DISABLE_32KHZ_GET(x)  (((x) & MAC_PCU_SLP32_MODE_DISABLE_32KHZ_MASK) >> MAC_PCU_SLP32_MODE_DISABLE_32KHZ_LSB)
-#define MAC_PCU_SLP32_MODE_DISABLE_32KHZ_SET(x)  (((x) << MAC_PCU_SLP32_MODE_DISABLE_32KHZ_LSB) & MAC_PCU_SLP32_MODE_DISABLE_32KHZ_MASK)
-#define MAC_PCU_SLP32_MODE_TSF_WRITE_STATUS_MSB  21
-#define MAC_PCU_SLP32_MODE_TSF_WRITE_STATUS_LSB  21
-#define MAC_PCU_SLP32_MODE_TSF_WRITE_STATUS_MASK 0x00200000
-#define MAC_PCU_SLP32_MODE_TSF_WRITE_STATUS_GET(x) (((x) & MAC_PCU_SLP32_MODE_TSF_WRITE_STATUS_MASK) >> MAC_PCU_SLP32_MODE_TSF_WRITE_STATUS_LSB)
-#define MAC_PCU_SLP32_MODE_TSF_WRITE_STATUS_SET(x) (((x) << MAC_PCU_SLP32_MODE_TSF_WRITE_STATUS_LSB) & MAC_PCU_SLP32_MODE_TSF_WRITE_STATUS_MASK)
-#define MAC_PCU_SLP32_MODE_ENABLE_MSB            20
-#define MAC_PCU_SLP32_MODE_ENABLE_LSB            20
-#define MAC_PCU_SLP32_MODE_ENABLE_MASK           0x00100000
-#define MAC_PCU_SLP32_MODE_ENABLE_GET(x)         (((x) & MAC_PCU_SLP32_MODE_ENABLE_MASK) >> MAC_PCU_SLP32_MODE_ENABLE_LSB)
-#define MAC_PCU_SLP32_MODE_ENABLE_SET(x)         (((x) << MAC_PCU_SLP32_MODE_ENABLE_LSB) & MAC_PCU_SLP32_MODE_ENABLE_MASK)
-#define MAC_PCU_SLP32_MODE_HALF_CLK_LATENCY_MSB  19
-#define MAC_PCU_SLP32_MODE_HALF_CLK_LATENCY_LSB  0
-#define MAC_PCU_SLP32_MODE_HALF_CLK_LATENCY_MASK 0x000fffff
-#define MAC_PCU_SLP32_MODE_HALF_CLK_LATENCY_GET(x) (((x) & MAC_PCU_SLP32_MODE_HALF_CLK_LATENCY_MASK) >> MAC_PCU_SLP32_MODE_HALF_CLK_LATENCY_LSB)
-#define MAC_PCU_SLP32_MODE_HALF_CLK_LATENCY_SET(x) (((x) << MAC_PCU_SLP32_MODE_HALF_CLK_LATENCY_LSB) & MAC_PCU_SLP32_MODE_HALF_CLK_LATENCY_MASK)
-
-#define MAC_PCU_SLP32_WAKE_ADDRESS               0x000000f8
-#define MAC_PCU_SLP32_WAKE_OFFSET                0x000000f8
-#define MAC_PCU_SLP32_WAKE_XTL_TIME_MSB          15
-#define MAC_PCU_SLP32_WAKE_XTL_TIME_LSB          0
-#define MAC_PCU_SLP32_WAKE_XTL_TIME_MASK         0x0000ffff
-#define MAC_PCU_SLP32_WAKE_XTL_TIME_GET(x)       (((x) & MAC_PCU_SLP32_WAKE_XTL_TIME_MASK) >> MAC_PCU_SLP32_WAKE_XTL_TIME_LSB)
-#define MAC_PCU_SLP32_WAKE_XTL_TIME_SET(x)       (((x) << MAC_PCU_SLP32_WAKE_XTL_TIME_LSB) & MAC_PCU_SLP32_WAKE_XTL_TIME_MASK)
-
-#define MAC_PCU_SLP32_INC_ADDRESS                0x000000fc
-#define MAC_PCU_SLP32_INC_OFFSET                 0x000000fc
-#define MAC_PCU_SLP32_INC_TSF_INC_MSB            19
-#define MAC_PCU_SLP32_INC_TSF_INC_LSB            0
-#define MAC_PCU_SLP32_INC_TSF_INC_MASK           0x000fffff
-#define MAC_PCU_SLP32_INC_TSF_INC_GET(x)         (((x) & MAC_PCU_SLP32_INC_TSF_INC_MASK) >> MAC_PCU_SLP32_INC_TSF_INC_LSB)
-#define MAC_PCU_SLP32_INC_TSF_INC_SET(x)         (((x) << MAC_PCU_SLP32_INC_TSF_INC_LSB) & MAC_PCU_SLP32_INC_TSF_INC_MASK)
-
-#define MAC_PCU_SLP_MIB1_ADDRESS                 0x00000100
-#define MAC_PCU_SLP_MIB1_OFFSET                  0x00000100
-#define MAC_PCU_SLP_MIB1_SLEEP_CNT_MSB           31
-#define MAC_PCU_SLP_MIB1_SLEEP_CNT_LSB           0
-#define MAC_PCU_SLP_MIB1_SLEEP_CNT_MASK          0xffffffff
-#define MAC_PCU_SLP_MIB1_SLEEP_CNT_GET(x)        (((x) & MAC_PCU_SLP_MIB1_SLEEP_CNT_MASK) >> MAC_PCU_SLP_MIB1_SLEEP_CNT_LSB)
-#define MAC_PCU_SLP_MIB1_SLEEP_CNT_SET(x)        (((x) << MAC_PCU_SLP_MIB1_SLEEP_CNT_LSB) & MAC_PCU_SLP_MIB1_SLEEP_CNT_MASK)
-
-#define MAC_PCU_SLP_MIB2_ADDRESS                 0x00000104
-#define MAC_PCU_SLP_MIB2_OFFSET                  0x00000104
-#define MAC_PCU_SLP_MIB2_CYCLE_CNT_MSB           31
-#define MAC_PCU_SLP_MIB2_CYCLE_CNT_LSB           0
-#define MAC_PCU_SLP_MIB2_CYCLE_CNT_MASK          0xffffffff
-#define MAC_PCU_SLP_MIB2_CYCLE_CNT_GET(x)        (((x) & MAC_PCU_SLP_MIB2_CYCLE_CNT_MASK) >> MAC_PCU_SLP_MIB2_CYCLE_CNT_LSB)
-#define MAC_PCU_SLP_MIB2_CYCLE_CNT_SET(x)        (((x) << MAC_PCU_SLP_MIB2_CYCLE_CNT_LSB) & MAC_PCU_SLP_MIB2_CYCLE_CNT_MASK)
-
-#define MAC_PCU_SLP_MIB3_ADDRESS                 0x00000108
-#define MAC_PCU_SLP_MIB3_OFFSET                  0x00000108
-#define MAC_PCU_SLP_MIB3_PENDING_MSB             1
-#define MAC_PCU_SLP_MIB3_PENDING_LSB             1
-#define MAC_PCU_SLP_MIB3_PENDING_MASK            0x00000002
-#define MAC_PCU_SLP_MIB3_PENDING_GET(x)          (((x) & MAC_PCU_SLP_MIB3_PENDING_MASK) >> MAC_PCU_SLP_MIB3_PENDING_LSB)
-#define MAC_PCU_SLP_MIB3_PENDING_SET(x)          (((x) << MAC_PCU_SLP_MIB3_PENDING_LSB) & MAC_PCU_SLP_MIB3_PENDING_MASK)
-#define MAC_PCU_SLP_MIB3_CLR_CNT_MSB             0
-#define MAC_PCU_SLP_MIB3_CLR_CNT_LSB             0
-#define MAC_PCU_SLP_MIB3_CLR_CNT_MASK            0x00000001
-#define MAC_PCU_SLP_MIB3_CLR_CNT_GET(x)          (((x) & MAC_PCU_SLP_MIB3_CLR_CNT_MASK) >> MAC_PCU_SLP_MIB3_CLR_CNT_LSB)
-#define MAC_PCU_SLP_MIB3_CLR_CNT_SET(x)          (((x) << MAC_PCU_SLP_MIB3_CLR_CNT_LSB) & MAC_PCU_SLP_MIB3_CLR_CNT_MASK)
-
-#define WLAN_POWER_REG_ADDRESS                   0x0000010c
-#define WLAN_POWER_REG_OFFSET                    0x0000010c
-#define WLAN_POWER_REG_SLEEP_MAKE_N_BREAK_EN_MSB 15
-#define WLAN_POWER_REG_SLEEP_MAKE_N_BREAK_EN_LSB 15
-#define WLAN_POWER_REG_SLEEP_MAKE_N_BREAK_EN_MASK 0x00008000
-#define WLAN_POWER_REG_SLEEP_MAKE_N_BREAK_EN_GET(x) (((x) & WLAN_POWER_REG_SLEEP_MAKE_N_BREAK_EN_MASK) >> WLAN_POWER_REG_SLEEP_MAKE_N_BREAK_EN_LSB)
-#define WLAN_POWER_REG_SLEEP_MAKE_N_BREAK_EN_SET(x) (((x) << WLAN_POWER_REG_SLEEP_MAKE_N_BREAK_EN_LSB) & WLAN_POWER_REG_SLEEP_MAKE_N_BREAK_EN_MASK)
-#define WLAN_POWER_REG_DEBUG_EN_MSB              14
-#define WLAN_POWER_REG_DEBUG_EN_LSB              14
-#define WLAN_POWER_REG_DEBUG_EN_MASK             0x00004000
-#define WLAN_POWER_REG_DEBUG_EN_GET(x)           (((x) & WLAN_POWER_REG_DEBUG_EN_MASK) >> WLAN_POWER_REG_DEBUG_EN_LSB)
-#define WLAN_POWER_REG_DEBUG_EN_SET(x)           (((x) << WLAN_POWER_REG_DEBUG_EN_LSB) & WLAN_POWER_REG_DEBUG_EN_MASK)
-#define WLAN_POWER_REG_WLAN_BB_PWD_EN_MSB        13
-#define WLAN_POWER_REG_WLAN_BB_PWD_EN_LSB        13
-#define WLAN_POWER_REG_WLAN_BB_PWD_EN_MASK       0x00002000
-#define WLAN_POWER_REG_WLAN_BB_PWD_EN_GET(x)     (((x) & WLAN_POWER_REG_WLAN_BB_PWD_EN_MASK) >> WLAN_POWER_REG_WLAN_BB_PWD_EN_LSB)
-#define WLAN_POWER_REG_WLAN_BB_PWD_EN_SET(x)     (((x) << WLAN_POWER_REG_WLAN_BB_PWD_EN_LSB) & WLAN_POWER_REG_WLAN_BB_PWD_EN_MASK)
-#define WLAN_POWER_REG_WLAN_MAC_PWD_EN_MSB       12
-#define WLAN_POWER_REG_WLAN_MAC_PWD_EN_LSB       12
-#define WLAN_POWER_REG_WLAN_MAC_PWD_EN_MASK      0x00001000
-#define WLAN_POWER_REG_WLAN_MAC_PWD_EN_GET(x)    (((x) & WLAN_POWER_REG_WLAN_MAC_PWD_EN_MASK) >> WLAN_POWER_REG_WLAN_MAC_PWD_EN_LSB)
-#define WLAN_POWER_REG_WLAN_MAC_PWD_EN_SET(x)    (((x) << WLAN_POWER_REG_WLAN_MAC_PWD_EN_LSB) & WLAN_POWER_REG_WLAN_MAC_PWD_EN_MASK)
-#define WLAN_POWER_REG_VLVL_MSB                  11
-#define WLAN_POWER_REG_VLVL_LSB                  8
-#define WLAN_POWER_REG_VLVL_MASK                 0x00000f00
-#define WLAN_POWER_REG_VLVL_GET(x)               (((x) & WLAN_POWER_REG_VLVL_MASK) >> WLAN_POWER_REG_VLVL_LSB)
-#define WLAN_POWER_REG_VLVL_SET(x)               (((x) << WLAN_POWER_REG_VLVL_LSB) & WLAN_POWER_REG_VLVL_MASK)
-#define WLAN_POWER_REG_CPU_INT_ENABLE_MSB        7
-#define WLAN_POWER_REG_CPU_INT_ENABLE_LSB        7
-#define WLAN_POWER_REG_CPU_INT_ENABLE_MASK       0x00000080
-#define WLAN_POWER_REG_CPU_INT_ENABLE_GET(x)     (((x) & WLAN_POWER_REG_CPU_INT_ENABLE_MASK) >> WLAN_POWER_REG_CPU_INT_ENABLE_LSB)
-#define WLAN_POWER_REG_CPU_INT_ENABLE_SET(x)     (((x) << WLAN_POWER_REG_CPU_INT_ENABLE_LSB) & WLAN_POWER_REG_CPU_INT_ENABLE_MASK)
-#define WLAN_POWER_REG_WLAN_ISO_DIS_MSB          6
-#define WLAN_POWER_REG_WLAN_ISO_DIS_LSB          6
-#define WLAN_POWER_REG_WLAN_ISO_DIS_MASK         0x00000040
-#define WLAN_POWER_REG_WLAN_ISO_DIS_GET(x)       (((x) & WLAN_POWER_REG_WLAN_ISO_DIS_MASK) >> WLAN_POWER_REG_WLAN_ISO_DIS_LSB)
-#define WLAN_POWER_REG_WLAN_ISO_DIS_SET(x)       (((x) << WLAN_POWER_REG_WLAN_ISO_DIS_LSB) & WLAN_POWER_REG_WLAN_ISO_DIS_MASK)
-#define WLAN_POWER_REG_WLAN_ISO_CNTL_MSB         5
-#define WLAN_POWER_REG_WLAN_ISO_CNTL_LSB         5
-#define WLAN_POWER_REG_WLAN_ISO_CNTL_MASK        0x00000020
-#define WLAN_POWER_REG_WLAN_ISO_CNTL_GET(x)      (((x) & WLAN_POWER_REG_WLAN_ISO_CNTL_MASK) >> WLAN_POWER_REG_WLAN_ISO_CNTL_LSB)
-#define WLAN_POWER_REG_WLAN_ISO_CNTL_SET(x)      (((x) << WLAN_POWER_REG_WLAN_ISO_CNTL_LSB) & WLAN_POWER_REG_WLAN_ISO_CNTL_MASK)
-#define WLAN_POWER_REG_RADIO_PWD_EN_MSB          4
-#define WLAN_POWER_REG_RADIO_PWD_EN_LSB          4
-#define WLAN_POWER_REG_RADIO_PWD_EN_MASK         0x00000010
-#define WLAN_POWER_REG_RADIO_PWD_EN_GET(x)       (((x) & WLAN_POWER_REG_RADIO_PWD_EN_MASK) >> WLAN_POWER_REG_RADIO_PWD_EN_LSB)
-#define WLAN_POWER_REG_RADIO_PWD_EN_SET(x)       (((x) << WLAN_POWER_REG_RADIO_PWD_EN_LSB) & WLAN_POWER_REG_RADIO_PWD_EN_MASK)
-#define WLAN_POWER_REG_SOC_ISO_EN_MSB            3
-#define WLAN_POWER_REG_SOC_ISO_EN_LSB            3
-#define WLAN_POWER_REG_SOC_ISO_EN_MASK           0x00000008
-#define WLAN_POWER_REG_SOC_ISO_EN_GET(x)         (((x) & WLAN_POWER_REG_SOC_ISO_EN_MASK) >> WLAN_POWER_REG_SOC_ISO_EN_LSB)
-#define WLAN_POWER_REG_SOC_ISO_EN_SET(x)         (((x) << WLAN_POWER_REG_SOC_ISO_EN_LSB) & WLAN_POWER_REG_SOC_ISO_EN_MASK)
-#define WLAN_POWER_REG_WLAN_ISO_EN_MSB           2
-#define WLAN_POWER_REG_WLAN_ISO_EN_LSB           2
-#define WLAN_POWER_REG_WLAN_ISO_EN_MASK          0x00000004
-#define WLAN_POWER_REG_WLAN_ISO_EN_GET(x)        (((x) & WLAN_POWER_REG_WLAN_ISO_EN_MASK) >> WLAN_POWER_REG_WLAN_ISO_EN_LSB)
-#define WLAN_POWER_REG_WLAN_ISO_EN_SET(x)        (((x) << WLAN_POWER_REG_WLAN_ISO_EN_LSB) & WLAN_POWER_REG_WLAN_ISO_EN_MASK)
-#define WLAN_POWER_REG_WLAN_PWD_EN_MSB           1
-#define WLAN_POWER_REG_WLAN_PWD_EN_LSB           1
-#define WLAN_POWER_REG_WLAN_PWD_EN_MASK          0x00000002
-#define WLAN_POWER_REG_WLAN_PWD_EN_GET(x)        (((x) & WLAN_POWER_REG_WLAN_PWD_EN_MASK) >> WLAN_POWER_REG_WLAN_PWD_EN_LSB)
-#define WLAN_POWER_REG_WLAN_PWD_EN_SET(x)        (((x) << WLAN_POWER_REG_WLAN_PWD_EN_LSB) & WLAN_POWER_REG_WLAN_PWD_EN_MASK)
-#define WLAN_POWER_REG_POWER_EN_MSB              0
-#define WLAN_POWER_REG_POWER_EN_LSB              0
-#define WLAN_POWER_REG_POWER_EN_MASK             0x00000001
-#define WLAN_POWER_REG_POWER_EN_GET(x)           (((x) & WLAN_POWER_REG_POWER_EN_MASK) >> WLAN_POWER_REG_POWER_EN_LSB)
-#define WLAN_POWER_REG_POWER_EN_SET(x)           (((x) << WLAN_POWER_REG_POWER_EN_LSB) & WLAN_POWER_REG_POWER_EN_MASK)
-
-#define WLAN_CORE_CLK_CTRL_ADDRESS               0x00000110
-#define WLAN_CORE_CLK_CTRL_OFFSET                0x00000110
-#define WLAN_CORE_CLK_CTRL_DIV_MSB               2
-#define WLAN_CORE_CLK_CTRL_DIV_LSB               0
-#define WLAN_CORE_CLK_CTRL_DIV_MASK              0x00000007
-#define WLAN_CORE_CLK_CTRL_DIV_GET(x)            (((x) & WLAN_CORE_CLK_CTRL_DIV_MASK) >> WLAN_CORE_CLK_CTRL_DIV_LSB)
-#define WLAN_CORE_CLK_CTRL_DIV_SET(x)            (((x) << WLAN_CORE_CLK_CTRL_DIV_LSB) & WLAN_CORE_CLK_CTRL_DIV_MASK)
-
-#define WLAN_GPIO_WAKEUP_CONTROL_ADDRESS         0x00000114
-#define WLAN_GPIO_WAKEUP_CONTROL_OFFSET          0x00000114
-#define WLAN_GPIO_WAKEUP_CONTROL_ENABLE_MSB      0
-#define WLAN_GPIO_WAKEUP_CONTROL_ENABLE_LSB      0
-#define WLAN_GPIO_WAKEUP_CONTROL_ENABLE_MASK     0x00000001
-#define WLAN_GPIO_WAKEUP_CONTROL_ENABLE_GET(x)   (((x) & WLAN_GPIO_WAKEUP_CONTROL_ENABLE_MASK) >> WLAN_GPIO_WAKEUP_CONTROL_ENABLE_LSB)
-#define WLAN_GPIO_WAKEUP_CONTROL_ENABLE_SET(x)   (((x) << WLAN_GPIO_WAKEUP_CONTROL_ENABLE_LSB) & WLAN_GPIO_WAKEUP_CONTROL_ENABLE_MASK)
-
-#define HT_ADDRESS                               0x00000118
-#define HT_OFFSET                                0x00000118
-#define HT_MODE_MSB                              0
-#define HT_MODE_LSB                              0
-#define HT_MODE_MASK                             0x00000001
-#define HT_MODE_GET(x)                           (((x) & HT_MODE_MASK) >> HT_MODE_LSB)
-#define HT_MODE_SET(x)                           (((x) << HT_MODE_LSB) & HT_MODE_MASK)
-
-#define MAC_PCU_TSF_L32_ADDRESS                  0x0000011c
-#define MAC_PCU_TSF_L32_OFFSET                   0x0000011c
-#define MAC_PCU_TSF_L32_VALUE_MSB                31
-#define MAC_PCU_TSF_L32_VALUE_LSB                0
-#define MAC_PCU_TSF_L32_VALUE_MASK               0xffffffff
-#define MAC_PCU_TSF_L32_VALUE_GET(x)             (((x) & MAC_PCU_TSF_L32_VALUE_MASK) >> MAC_PCU_TSF_L32_VALUE_LSB)
-#define MAC_PCU_TSF_L32_VALUE_SET(x)             (((x) << MAC_PCU_TSF_L32_VALUE_LSB) & MAC_PCU_TSF_L32_VALUE_MASK)
-
-#define MAC_PCU_TSF_U32_ADDRESS                  0x00000120
-#define MAC_PCU_TSF_U32_OFFSET                   0x00000120
-#define MAC_PCU_TSF_U32_VALUE_MSB                31
-#define MAC_PCU_TSF_U32_VALUE_LSB                0
-#define MAC_PCU_TSF_U32_VALUE_MASK               0xffffffff
-#define MAC_PCU_TSF_U32_VALUE_GET(x)             (((x) & MAC_PCU_TSF_U32_VALUE_MASK) >> MAC_PCU_TSF_U32_VALUE_LSB)
-#define MAC_PCU_TSF_U32_VALUE_SET(x)             (((x) << MAC_PCU_TSF_U32_VALUE_LSB) & MAC_PCU_TSF_U32_VALUE_MASK)
-
-#define MAC_PCU_WBTIMER_ADDRESS                  0x00000124
-#define MAC_PCU_WBTIMER_OFFSET                   0x00000124
-#define MAC_PCU_WBTIMER_VALUE_MSB                31
-#define MAC_PCU_WBTIMER_VALUE_LSB                0
-#define MAC_PCU_WBTIMER_VALUE_MASK               0xffffffff
-#define MAC_PCU_WBTIMER_VALUE_GET(x)             (((x) & MAC_PCU_WBTIMER_VALUE_MASK) >> MAC_PCU_WBTIMER_VALUE_LSB)
-#define MAC_PCU_WBTIMER_VALUE_SET(x)             (((x) << MAC_PCU_WBTIMER_VALUE_LSB) & MAC_PCU_WBTIMER_VALUE_MASK)
-
-#define MAC_PCU_GENERIC_TIMERS_ADDRESS           0x00000140
-#define MAC_PCU_GENERIC_TIMERS_OFFSET            0x00000140
-#define MAC_PCU_GENERIC_TIMERS_DATA_MSB          31
-#define MAC_PCU_GENERIC_TIMERS_DATA_LSB          0
-#define MAC_PCU_GENERIC_TIMERS_DATA_MASK         0xffffffff
-#define MAC_PCU_GENERIC_TIMERS_DATA_GET(x)       (((x) & MAC_PCU_GENERIC_TIMERS_DATA_MASK) >> MAC_PCU_GENERIC_TIMERS_DATA_LSB)
-#define MAC_PCU_GENERIC_TIMERS_DATA_SET(x)       (((x) << MAC_PCU_GENERIC_TIMERS_DATA_LSB) & MAC_PCU_GENERIC_TIMERS_DATA_MASK)
-
-#define MAC_PCU_GENERIC_TIMERS_MODE_ADDRESS      0x00000180
-#define MAC_PCU_GENERIC_TIMERS_MODE_OFFSET       0x00000180
-#define MAC_PCU_GENERIC_TIMERS_MODE_ENABLE_MSB   15
-#define MAC_PCU_GENERIC_TIMERS_MODE_ENABLE_LSB   0
-#define MAC_PCU_GENERIC_TIMERS_MODE_ENABLE_MASK  0x0000ffff
-#define MAC_PCU_GENERIC_TIMERS_MODE_ENABLE_GET(x) (((x) & MAC_PCU_GENERIC_TIMERS_MODE_ENABLE_MASK) >> MAC_PCU_GENERIC_TIMERS_MODE_ENABLE_LSB)
-#define MAC_PCU_GENERIC_TIMERS_MODE_ENABLE_SET(x) (((x) << MAC_PCU_GENERIC_TIMERS_MODE_ENABLE_LSB) & MAC_PCU_GENERIC_TIMERS_MODE_ENABLE_MASK)
-
-#define MAC_PCU_GENERIC_TIMERS2_ADDRESS          0x000001c0
-#define MAC_PCU_GENERIC_TIMERS2_OFFSET           0x000001c0
-#define MAC_PCU_GENERIC_TIMERS2_DATA_MSB         31
-#define MAC_PCU_GENERIC_TIMERS2_DATA_LSB         0
-#define MAC_PCU_GENERIC_TIMERS2_DATA_MASK        0xffffffff
-#define MAC_PCU_GENERIC_TIMERS2_DATA_GET(x)      (((x) & MAC_PCU_GENERIC_TIMERS2_DATA_MASK) >> MAC_PCU_GENERIC_TIMERS2_DATA_LSB)
-#define MAC_PCU_GENERIC_TIMERS2_DATA_SET(x)      (((x) << MAC_PCU_GENERIC_TIMERS2_DATA_LSB) & MAC_PCU_GENERIC_TIMERS2_DATA_MASK)
-
-#define MAC_PCU_GENERIC_TIMERS_MODE2_ADDRESS     0x00000200
-#define MAC_PCU_GENERIC_TIMERS_MODE2_OFFSET      0x00000200
-#define MAC_PCU_GENERIC_TIMERS_MODE2_ENABLE_MSB  15
-#define MAC_PCU_GENERIC_TIMERS_MODE2_ENABLE_LSB  0
-#define MAC_PCU_GENERIC_TIMERS_MODE2_ENABLE_MASK 0x0000ffff
-#define MAC_PCU_GENERIC_TIMERS_MODE2_ENABLE_GET(x) (((x) & MAC_PCU_GENERIC_TIMERS_MODE2_ENABLE_MASK) >> MAC_PCU_GENERIC_TIMERS_MODE2_ENABLE_LSB)
-#define MAC_PCU_GENERIC_TIMERS_MODE2_ENABLE_SET(x) (((x) << MAC_PCU_GENERIC_TIMERS_MODE2_ENABLE_LSB) & MAC_PCU_GENERIC_TIMERS_MODE2_ENABLE_MASK)
-
-#define MAC_PCU_SLP1_ADDRESS                     0x00000204
-#define MAC_PCU_SLP1_OFFSET                      0x00000204
-#define MAC_PCU_SLP1_ASSUME_DTIM_MSB             19
-#define MAC_PCU_SLP1_ASSUME_DTIM_LSB             19
-#define MAC_PCU_SLP1_ASSUME_DTIM_MASK            0x00080000
-#define MAC_PCU_SLP1_ASSUME_DTIM_GET(x)          (((x) & MAC_PCU_SLP1_ASSUME_DTIM_MASK) >> MAC_PCU_SLP1_ASSUME_DTIM_LSB)
-#define MAC_PCU_SLP1_ASSUME_DTIM_SET(x)          (((x) << MAC_PCU_SLP1_ASSUME_DTIM_LSB) & MAC_PCU_SLP1_ASSUME_DTIM_MASK)
-#define MAC_PCU_SLP1_CAB_TIMEOUT_MSB             15
-#define MAC_PCU_SLP1_CAB_TIMEOUT_LSB             0
-#define MAC_PCU_SLP1_CAB_TIMEOUT_MASK            0x0000ffff
-#define MAC_PCU_SLP1_CAB_TIMEOUT_GET(x)          (((x) & MAC_PCU_SLP1_CAB_TIMEOUT_MASK) >> MAC_PCU_SLP1_CAB_TIMEOUT_LSB)
-#define MAC_PCU_SLP1_CAB_TIMEOUT_SET(x)          (((x) << MAC_PCU_SLP1_CAB_TIMEOUT_LSB) & MAC_PCU_SLP1_CAB_TIMEOUT_MASK)
-
-#define MAC_PCU_SLP2_ADDRESS                     0x00000208
-#define MAC_PCU_SLP2_OFFSET                      0x00000208
-#define MAC_PCU_SLP2_BEACON_TIMEOUT_MSB          15
-#define MAC_PCU_SLP2_BEACON_TIMEOUT_LSB          0
-#define MAC_PCU_SLP2_BEACON_TIMEOUT_MASK         0x0000ffff
-#define MAC_PCU_SLP2_BEACON_TIMEOUT_GET(x)       (((x) & MAC_PCU_SLP2_BEACON_TIMEOUT_MASK) >> MAC_PCU_SLP2_BEACON_TIMEOUT_LSB)
-#define MAC_PCU_SLP2_BEACON_TIMEOUT_SET(x)       (((x) << MAC_PCU_SLP2_BEACON_TIMEOUT_LSB) & MAC_PCU_SLP2_BEACON_TIMEOUT_MASK)
-
-#define MAC_PCU_RESET_TSF_ADDRESS                0x0000020c
-#define MAC_PCU_RESET_TSF_OFFSET                 0x0000020c
-#define MAC_PCU_RESET_TSF_ONE_SHOT2_MSB          25
-#define MAC_PCU_RESET_TSF_ONE_SHOT2_LSB          25
-#define MAC_PCU_RESET_TSF_ONE_SHOT2_MASK         0x02000000
-#define MAC_PCU_RESET_TSF_ONE_SHOT2_GET(x)       (((x) & MAC_PCU_RESET_TSF_ONE_SHOT2_MASK) >> MAC_PCU_RESET_TSF_ONE_SHOT2_LSB)
-#define MAC_PCU_RESET_TSF_ONE_SHOT2_SET(x)       (((x) << MAC_PCU_RESET_TSF_ONE_SHOT2_LSB) & MAC_PCU_RESET_TSF_ONE_SHOT2_MASK)
-#define MAC_PCU_RESET_TSF_ONE_SHOT_MSB           24
-#define MAC_PCU_RESET_TSF_ONE_SHOT_LSB           24
-#define MAC_PCU_RESET_TSF_ONE_SHOT_MASK          0x01000000
-#define MAC_PCU_RESET_TSF_ONE_SHOT_GET(x)        (((x) & MAC_PCU_RESET_TSF_ONE_SHOT_MASK) >> MAC_PCU_RESET_TSF_ONE_SHOT_LSB)
-#define MAC_PCU_RESET_TSF_ONE_SHOT_SET(x)        (((x) << MAC_PCU_RESET_TSF_ONE_SHOT_LSB) & MAC_PCU_RESET_TSF_ONE_SHOT_MASK)
-
-#define MAC_PCU_TSF_ADD_PLL_ADDRESS              0x00000210
-#define MAC_PCU_TSF_ADD_PLL_OFFSET               0x00000210
-#define MAC_PCU_TSF_ADD_PLL_VALUE_MSB            7
-#define MAC_PCU_TSF_ADD_PLL_VALUE_LSB            0
-#define MAC_PCU_TSF_ADD_PLL_VALUE_MASK           0x000000ff
-#define MAC_PCU_TSF_ADD_PLL_VALUE_GET(x)         (((x) & MAC_PCU_TSF_ADD_PLL_VALUE_MASK) >> MAC_PCU_TSF_ADD_PLL_VALUE_LSB)
-#define MAC_PCU_TSF_ADD_PLL_VALUE_SET(x)         (((x) << MAC_PCU_TSF_ADD_PLL_VALUE_LSB) & MAC_PCU_TSF_ADD_PLL_VALUE_MASK)
-
-#define SLEEP_RETENTION_ADDRESS                  0x00000214
-#define SLEEP_RETENTION_OFFSET                   0x00000214
-#define SLEEP_RETENTION_TIME_MSB                 9
-#define SLEEP_RETENTION_TIME_LSB                 2
-#define SLEEP_RETENTION_TIME_MASK                0x000003fc
-#define SLEEP_RETENTION_TIME_GET(x)              (((x) & SLEEP_RETENTION_TIME_MASK) >> SLEEP_RETENTION_TIME_LSB)
-#define SLEEP_RETENTION_TIME_SET(x)              (((x) << SLEEP_RETENTION_TIME_LSB) & SLEEP_RETENTION_TIME_MASK)
-#define SLEEP_RETENTION_MODE_MSB                 1
-#define SLEEP_RETENTION_MODE_LSB                 1
-#define SLEEP_RETENTION_MODE_MASK                0x00000002
-#define SLEEP_RETENTION_MODE_GET(x)              (((x) & SLEEP_RETENTION_MODE_MASK) >> SLEEP_RETENTION_MODE_LSB)
-#define SLEEP_RETENTION_MODE_SET(x)              (((x) << SLEEP_RETENTION_MODE_LSB) & SLEEP_RETENTION_MODE_MASK)
-#define SLEEP_RETENTION_ENABLE_MSB               0
-#define SLEEP_RETENTION_ENABLE_LSB               0
-#define SLEEP_RETENTION_ENABLE_MASK              0x00000001
-#define SLEEP_RETENTION_ENABLE_GET(x)            (((x) & SLEEP_RETENTION_ENABLE_MASK) >> SLEEP_RETENTION_ENABLE_LSB)
-#define SLEEP_RETENTION_ENABLE_SET(x)            (((x) << SLEEP_RETENTION_ENABLE_LSB) & SLEEP_RETENTION_ENABLE_MASK)
-
-#define BTCOEXCTRL_ADDRESS                       0x00000218
-#define BTCOEXCTRL_OFFSET                        0x00000218
-#define BTCOEXCTRL_WBTIMER_ENABLE_MSB            26
-#define BTCOEXCTRL_WBTIMER_ENABLE_LSB            26
-#define BTCOEXCTRL_WBTIMER_ENABLE_MASK           0x04000000
-#define BTCOEXCTRL_WBTIMER_ENABLE_GET(x)         (((x) & BTCOEXCTRL_WBTIMER_ENABLE_MASK) >> BTCOEXCTRL_WBTIMER_ENABLE_LSB)
-#define BTCOEXCTRL_WBTIMER_ENABLE_SET(x)         (((x) << BTCOEXCTRL_WBTIMER_ENABLE_LSB) & BTCOEXCTRL_WBTIMER_ENABLE_MASK)
-#define BTCOEXCTRL_WBSYNC_ON_BEACON_MSB          25
-#define BTCOEXCTRL_WBSYNC_ON_BEACON_LSB          25
-#define BTCOEXCTRL_WBSYNC_ON_BEACON_MASK         0x02000000
-#define BTCOEXCTRL_WBSYNC_ON_BEACON_GET(x)       (((x) & BTCOEXCTRL_WBSYNC_ON_BEACON_MASK) >> BTCOEXCTRL_WBSYNC_ON_BEACON_LSB)
-#define BTCOEXCTRL_WBSYNC_ON_BEACON_SET(x)       (((x) << BTCOEXCTRL_WBSYNC_ON_BEACON_LSB) & BTCOEXCTRL_WBSYNC_ON_BEACON_MASK)
-#define BTCOEXCTRL_PTA_MODE_MSB                  24
-#define BTCOEXCTRL_PTA_MODE_LSB                  23
-#define BTCOEXCTRL_PTA_MODE_MASK                 0x01800000
-#define BTCOEXCTRL_PTA_MODE_GET(x)               (((x) & BTCOEXCTRL_PTA_MODE_MASK) >> BTCOEXCTRL_PTA_MODE_LSB)
-#define BTCOEXCTRL_PTA_MODE_SET(x)               (((x) << BTCOEXCTRL_PTA_MODE_LSB) & BTCOEXCTRL_PTA_MODE_MASK)
-#define BTCOEXCTRL_FREQ_TIME_MSB                 22
-#define BTCOEXCTRL_FREQ_TIME_LSB                 18
-#define BTCOEXCTRL_FREQ_TIME_MASK                0x007c0000
-#define BTCOEXCTRL_FREQ_TIME_GET(x)              (((x) & BTCOEXCTRL_FREQ_TIME_MASK) >> BTCOEXCTRL_FREQ_TIME_LSB)
-#define BTCOEXCTRL_FREQ_TIME_SET(x)              (((x) << BTCOEXCTRL_FREQ_TIME_LSB) & BTCOEXCTRL_FREQ_TIME_MASK)
-#define BTCOEXCTRL_PRIORITY_TIME_MSB             17
-#define BTCOEXCTRL_PRIORITY_TIME_LSB             12
-#define BTCOEXCTRL_PRIORITY_TIME_MASK            0x0003f000
-#define BTCOEXCTRL_PRIORITY_TIME_GET(x)          (((x) & BTCOEXCTRL_PRIORITY_TIME_MASK) >> BTCOEXCTRL_PRIORITY_TIME_LSB)
-#define BTCOEXCTRL_PRIORITY_TIME_SET(x)          (((x) << BTCOEXCTRL_PRIORITY_TIME_LSB) & BTCOEXCTRL_PRIORITY_TIME_MASK)
-#define BTCOEXCTRL_SYNC_DET_EN_MSB               11
-#define BTCOEXCTRL_SYNC_DET_EN_LSB               11
-#define BTCOEXCTRL_SYNC_DET_EN_MASK              0x00000800
-#define BTCOEXCTRL_SYNC_DET_EN_GET(x)            (((x) & BTCOEXCTRL_SYNC_DET_EN_MASK) >> BTCOEXCTRL_SYNC_DET_EN_LSB)
-#define BTCOEXCTRL_SYNC_DET_EN_SET(x)            (((x) << BTCOEXCTRL_SYNC_DET_EN_LSB) & BTCOEXCTRL_SYNC_DET_EN_MASK)
-#define BTCOEXCTRL_IDLE_CNT_EN_MSB               10
-#define BTCOEXCTRL_IDLE_CNT_EN_LSB               10
-#define BTCOEXCTRL_IDLE_CNT_EN_MASK              0x00000400
-#define BTCOEXCTRL_IDLE_CNT_EN_GET(x)            (((x) & BTCOEXCTRL_IDLE_CNT_EN_MASK) >> BTCOEXCTRL_IDLE_CNT_EN_LSB)
-#define BTCOEXCTRL_IDLE_CNT_EN_SET(x)            (((x) << BTCOEXCTRL_IDLE_CNT_EN_LSB) & BTCOEXCTRL_IDLE_CNT_EN_MASK)
-#define BTCOEXCTRL_FRAME_CNT_EN_MSB              9
-#define BTCOEXCTRL_FRAME_CNT_EN_LSB              9
-#define BTCOEXCTRL_FRAME_CNT_EN_MASK             0x00000200
-#define BTCOEXCTRL_FRAME_CNT_EN_GET(x)           (((x) & BTCOEXCTRL_FRAME_CNT_EN_MASK) >> BTCOEXCTRL_FRAME_CNT_EN_LSB)
-#define BTCOEXCTRL_FRAME_CNT_EN_SET(x)           (((x) << BTCOEXCTRL_FRAME_CNT_EN_LSB) & BTCOEXCTRL_FRAME_CNT_EN_MASK)
-#define BTCOEXCTRL_CLK_CNT_EN_MSB                8
-#define BTCOEXCTRL_CLK_CNT_EN_LSB                8
-#define BTCOEXCTRL_CLK_CNT_EN_MASK               0x00000100
-#define BTCOEXCTRL_CLK_CNT_EN_GET(x)             (((x) & BTCOEXCTRL_CLK_CNT_EN_MASK) >> BTCOEXCTRL_CLK_CNT_EN_LSB)
-#define BTCOEXCTRL_CLK_CNT_EN_SET(x)             (((x) << BTCOEXCTRL_CLK_CNT_EN_LSB) & BTCOEXCTRL_CLK_CNT_EN_MASK)
-#define BTCOEXCTRL_GAP_MSB                       7
-#define BTCOEXCTRL_GAP_LSB                       0
-#define BTCOEXCTRL_GAP_MASK                      0x000000ff
-#define BTCOEXCTRL_GAP_GET(x)                    (((x) & BTCOEXCTRL_GAP_MASK) >> BTCOEXCTRL_GAP_LSB)
-#define BTCOEXCTRL_GAP_SET(x)                    (((x) << BTCOEXCTRL_GAP_LSB) & BTCOEXCTRL_GAP_MASK)
-
-#define WBSYNC_PRIORITY1_ADDRESS                 0x0000021c
-#define WBSYNC_PRIORITY1_OFFSET                  0x0000021c
-#define WBSYNC_PRIORITY1_BITMAP_MSB              31
-#define WBSYNC_PRIORITY1_BITMAP_LSB              0
-#define WBSYNC_PRIORITY1_BITMAP_MASK             0xffffffff
-#define WBSYNC_PRIORITY1_BITMAP_GET(x)           (((x) & WBSYNC_PRIORITY1_BITMAP_MASK) >> WBSYNC_PRIORITY1_BITMAP_LSB)
-#define WBSYNC_PRIORITY1_BITMAP_SET(x)           (((x) << WBSYNC_PRIORITY1_BITMAP_LSB) & WBSYNC_PRIORITY1_BITMAP_MASK)
-
-#define WBSYNC_PRIORITY2_ADDRESS                 0x00000220
-#define WBSYNC_PRIORITY2_OFFSET                  0x00000220
-#define WBSYNC_PRIORITY2_BITMAP_MSB              31
-#define WBSYNC_PRIORITY2_BITMAP_LSB              0
-#define WBSYNC_PRIORITY2_BITMAP_MASK             0xffffffff
-#define WBSYNC_PRIORITY2_BITMAP_GET(x)           (((x) & WBSYNC_PRIORITY2_BITMAP_MASK) >> WBSYNC_PRIORITY2_BITMAP_LSB)
-#define WBSYNC_PRIORITY2_BITMAP_SET(x)           (((x) << WBSYNC_PRIORITY2_BITMAP_LSB) & WBSYNC_PRIORITY2_BITMAP_MASK)
-
-#define WBSYNC_PRIORITY3_ADDRESS                 0x00000224
-#define WBSYNC_PRIORITY3_OFFSET                  0x00000224
-#define WBSYNC_PRIORITY3_BITMAP_MSB              31
-#define WBSYNC_PRIORITY3_BITMAP_LSB              0
-#define WBSYNC_PRIORITY3_BITMAP_MASK             0xffffffff
-#define WBSYNC_PRIORITY3_BITMAP_GET(x)           (((x) & WBSYNC_PRIORITY3_BITMAP_MASK) >> WBSYNC_PRIORITY3_BITMAP_LSB)
-#define WBSYNC_PRIORITY3_BITMAP_SET(x)           (((x) << WBSYNC_PRIORITY3_BITMAP_LSB) & WBSYNC_PRIORITY3_BITMAP_MASK)
-
-#define BTCOEX0_ADDRESS                          0x00000228
-#define BTCOEX0_OFFSET                           0x00000228
-#define BTCOEX0_SYNC_DUR_MSB                     7
-#define BTCOEX0_SYNC_DUR_LSB                     0
-#define BTCOEX0_SYNC_DUR_MASK                    0x000000ff
-#define BTCOEX0_SYNC_DUR_GET(x)                  (((x) & BTCOEX0_SYNC_DUR_MASK) >> BTCOEX0_SYNC_DUR_LSB)
-#define BTCOEX0_SYNC_DUR_SET(x)                  (((x) << BTCOEX0_SYNC_DUR_LSB) & BTCOEX0_SYNC_DUR_MASK)
-
-#define BTCOEX1_ADDRESS                          0x0000022c
-#define BTCOEX1_OFFSET                           0x0000022c
-#define BTCOEX1_CLK_THRES_MSB                    20
-#define BTCOEX1_CLK_THRES_LSB                    0
-#define BTCOEX1_CLK_THRES_MASK                   0x001fffff
-#define BTCOEX1_CLK_THRES_GET(x)                 (((x) & BTCOEX1_CLK_THRES_MASK) >> BTCOEX1_CLK_THRES_LSB)
-#define BTCOEX1_CLK_THRES_SET(x)                 (((x) << BTCOEX1_CLK_THRES_LSB) & BTCOEX1_CLK_THRES_MASK)
-
-#define BTCOEX2_ADDRESS                          0x00000230
-#define BTCOEX2_OFFSET                           0x00000230
-#define BTCOEX2_FRAME_THRES_MSB                  7
-#define BTCOEX2_FRAME_THRES_LSB                  0
-#define BTCOEX2_FRAME_THRES_MASK                 0x000000ff
-#define BTCOEX2_FRAME_THRES_GET(x)               (((x) & BTCOEX2_FRAME_THRES_MASK) >> BTCOEX2_FRAME_THRES_LSB)
-#define BTCOEX2_FRAME_THRES_SET(x)               (((x) << BTCOEX2_FRAME_THRES_LSB) & BTCOEX2_FRAME_THRES_MASK)
-
-#define BTCOEX3_ADDRESS                          0x00000234
-#define BTCOEX3_OFFSET                           0x00000234
-#define BTCOEX3_CLK_CNT_MSB                      20
-#define BTCOEX3_CLK_CNT_LSB                      0
-#define BTCOEX3_CLK_CNT_MASK                     0x001fffff
-#define BTCOEX3_CLK_CNT_GET(x)                   (((x) & BTCOEX3_CLK_CNT_MASK) >> BTCOEX3_CLK_CNT_LSB)
-#define BTCOEX3_CLK_CNT_SET(x)                   (((x) << BTCOEX3_CLK_CNT_LSB) & BTCOEX3_CLK_CNT_MASK)
-
-#define BTCOEX4_ADDRESS                          0x00000238
-#define BTCOEX4_OFFSET                           0x00000238
-#define BTCOEX4_FRAME_CNT_MSB                    7
-#define BTCOEX4_FRAME_CNT_LSB                    0
-#define BTCOEX4_FRAME_CNT_MASK                   0x000000ff
-#define BTCOEX4_FRAME_CNT_GET(x)                 (((x) & BTCOEX4_FRAME_CNT_MASK) >> BTCOEX4_FRAME_CNT_LSB)
-#define BTCOEX4_FRAME_CNT_SET(x)                 (((x) << BTCOEX4_FRAME_CNT_LSB) & BTCOEX4_FRAME_CNT_MASK)
-
-#define BTCOEX5_ADDRESS                          0x0000023c
-#define BTCOEX5_OFFSET                           0x0000023c
-#define BTCOEX5_IDLE_CNT_MSB                     15
-#define BTCOEX5_IDLE_CNT_LSB                     0
-#define BTCOEX5_IDLE_CNT_MASK                    0x0000ffff
-#define BTCOEX5_IDLE_CNT_GET(x)                  (((x) & BTCOEX5_IDLE_CNT_MASK) >> BTCOEX5_IDLE_CNT_LSB)
-#define BTCOEX5_IDLE_CNT_SET(x)                  (((x) << BTCOEX5_IDLE_CNT_LSB) & BTCOEX5_IDLE_CNT_MASK)
-
-#define BTCOEX6_ADDRESS                          0x00000240
-#define BTCOEX6_OFFSET                           0x00000240
-#define BTCOEX6_IDLE_RESET_LVL_BITMAP_MSB        31
-#define BTCOEX6_IDLE_RESET_LVL_BITMAP_LSB        0
-#define BTCOEX6_IDLE_RESET_LVL_BITMAP_MASK       0xffffffff
-#define BTCOEX6_IDLE_RESET_LVL_BITMAP_GET(x)     (((x) & BTCOEX6_IDLE_RESET_LVL_BITMAP_MASK) >> BTCOEX6_IDLE_RESET_LVL_BITMAP_LSB)
-#define BTCOEX6_IDLE_RESET_LVL_BITMAP_SET(x)     (((x) << BTCOEX6_IDLE_RESET_LVL_BITMAP_LSB) & BTCOEX6_IDLE_RESET_LVL_BITMAP_MASK)
-
-#define LOCK_ADDRESS                             0x00000244
-#define LOCK_OFFSET                              0x00000244
-#define LOCK_TLOCK_SLAVE_MSB                     31
-#define LOCK_TLOCK_SLAVE_LSB                     24
-#define LOCK_TLOCK_SLAVE_MASK                    0xff000000
-#define LOCK_TLOCK_SLAVE_GET(x)                  (((x) & LOCK_TLOCK_SLAVE_MASK) >> LOCK_TLOCK_SLAVE_LSB)
-#define LOCK_TLOCK_SLAVE_SET(x)                  (((x) << LOCK_TLOCK_SLAVE_LSB) & LOCK_TLOCK_SLAVE_MASK)
-#define LOCK_TUNLOCK_SLAVE_MSB                   23
-#define LOCK_TUNLOCK_SLAVE_LSB                   16
-#define LOCK_TUNLOCK_SLAVE_MASK                  0x00ff0000
-#define LOCK_TUNLOCK_SLAVE_GET(x)                (((x) & LOCK_TUNLOCK_SLAVE_MASK) >> LOCK_TUNLOCK_SLAVE_LSB)
-#define LOCK_TUNLOCK_SLAVE_SET(x)                (((x) << LOCK_TUNLOCK_SLAVE_LSB) & LOCK_TUNLOCK_SLAVE_MASK)
-#define LOCK_TLOCK_MASTER_MSB                    15
-#define LOCK_TLOCK_MASTER_LSB                    8
-#define LOCK_TLOCK_MASTER_MASK                   0x0000ff00
-#define LOCK_TLOCK_MASTER_GET(x)                 (((x) & LOCK_TLOCK_MASTER_MASK) >> LOCK_TLOCK_MASTER_LSB)
-#define LOCK_TLOCK_MASTER_SET(x)                 (((x) << LOCK_TLOCK_MASTER_LSB) & LOCK_TLOCK_MASTER_MASK)
-#define LOCK_TUNLOCK_MASTER_MSB                  7
-#define LOCK_TUNLOCK_MASTER_LSB                  0
-#define LOCK_TUNLOCK_MASTER_MASK                 0x000000ff
-#define LOCK_TUNLOCK_MASTER_GET(x)               (((x) & LOCK_TUNLOCK_MASTER_MASK) >> LOCK_TUNLOCK_MASTER_LSB)
-#define LOCK_TUNLOCK_MASTER_SET(x)               (((x) << LOCK_TUNLOCK_MASTER_LSB) & LOCK_TUNLOCK_MASTER_MASK)
-
-#define NOLOCK_PRIORITY_ADDRESS                  0x00000248
-#define NOLOCK_PRIORITY_OFFSET                   0x00000248
-#define NOLOCK_PRIORITY_BITMAP_MSB               31
-#define NOLOCK_PRIORITY_BITMAP_LSB               0
-#define NOLOCK_PRIORITY_BITMAP_MASK              0xffffffff
-#define NOLOCK_PRIORITY_BITMAP_GET(x)            (((x) & NOLOCK_PRIORITY_BITMAP_MASK) >> NOLOCK_PRIORITY_BITMAP_LSB)
-#define NOLOCK_PRIORITY_BITMAP_SET(x)            (((x) << NOLOCK_PRIORITY_BITMAP_LSB) & NOLOCK_PRIORITY_BITMAP_MASK)
-
-#define WBSYNC_ADDRESS                           0x0000024c
-#define WBSYNC_OFFSET                            0x0000024c
-#define WBSYNC_BTCLOCK_MSB                       31
-#define WBSYNC_BTCLOCK_LSB                       0
-#define WBSYNC_BTCLOCK_MASK                      0xffffffff
-#define WBSYNC_BTCLOCK_GET(x)                    (((x) & WBSYNC_BTCLOCK_MASK) >> WBSYNC_BTCLOCK_LSB)
-#define WBSYNC_BTCLOCK_SET(x)                    (((x) << WBSYNC_BTCLOCK_LSB) & WBSYNC_BTCLOCK_MASK)
-
-#define WBSYNC1_ADDRESS                          0x00000250
-#define WBSYNC1_OFFSET                           0x00000250
-#define WBSYNC1_BTCLOCK_MSB                      31
-#define WBSYNC1_BTCLOCK_LSB                      0
-#define WBSYNC1_BTCLOCK_MASK                     0xffffffff
-#define WBSYNC1_BTCLOCK_GET(x)                   (((x) & WBSYNC1_BTCLOCK_MASK) >> WBSYNC1_BTCLOCK_LSB)
-#define WBSYNC1_BTCLOCK_SET(x)                   (((x) << WBSYNC1_BTCLOCK_LSB) & WBSYNC1_BTCLOCK_MASK)
-
-#define WBSYNC2_ADDRESS                          0x00000254
-#define WBSYNC2_OFFSET                           0x00000254
-#define WBSYNC2_BTCLOCK_MSB                      31
-#define WBSYNC2_BTCLOCK_LSB                      0
-#define WBSYNC2_BTCLOCK_MASK                     0xffffffff
-#define WBSYNC2_BTCLOCK_GET(x)                   (((x) & WBSYNC2_BTCLOCK_MASK) >> WBSYNC2_BTCLOCK_LSB)
-#define WBSYNC2_BTCLOCK_SET(x)                   (((x) << WBSYNC2_BTCLOCK_LSB) & WBSYNC2_BTCLOCK_MASK)
-
-#define WBSYNC3_ADDRESS                          0x00000258
-#define WBSYNC3_OFFSET                           0x00000258
-#define WBSYNC3_BTCLOCK_MSB                      31
-#define WBSYNC3_BTCLOCK_LSB                      0
-#define WBSYNC3_BTCLOCK_MASK                     0xffffffff
-#define WBSYNC3_BTCLOCK_GET(x)                   (((x) & WBSYNC3_BTCLOCK_MASK) >> WBSYNC3_BTCLOCK_LSB)
-#define WBSYNC3_BTCLOCK_SET(x)                   (((x) << WBSYNC3_BTCLOCK_LSB) & WBSYNC3_BTCLOCK_MASK)
-
-#define WB_TIMER_TARGET_ADDRESS                  0x0000025c
-#define WB_TIMER_TARGET_OFFSET                   0x0000025c
-#define WB_TIMER_TARGET_VALUE_MSB                31
-#define WB_TIMER_TARGET_VALUE_LSB                0
-#define WB_TIMER_TARGET_VALUE_MASK               0xffffffff
-#define WB_TIMER_TARGET_VALUE_GET(x)             (((x) & WB_TIMER_TARGET_VALUE_MASK) >> WB_TIMER_TARGET_VALUE_LSB)
-#define WB_TIMER_TARGET_VALUE_SET(x)             (((x) << WB_TIMER_TARGET_VALUE_LSB) & WB_TIMER_TARGET_VALUE_MASK)
-
-#define WB_TIMER_SLOP_ADDRESS                    0x00000260
-#define WB_TIMER_SLOP_OFFSET                     0x00000260
-#define WB_TIMER_SLOP_VALUE_MSB                  9
-#define WB_TIMER_SLOP_VALUE_LSB                  0
-#define WB_TIMER_SLOP_VALUE_MASK                 0x000003ff
-#define WB_TIMER_SLOP_VALUE_GET(x)               (((x) & WB_TIMER_SLOP_VALUE_MASK) >> WB_TIMER_SLOP_VALUE_LSB)
-#define WB_TIMER_SLOP_VALUE_SET(x)               (((x) << WB_TIMER_SLOP_VALUE_LSB) & WB_TIMER_SLOP_VALUE_MASK)
-
-#define BTCOEX_INT_EN_ADDRESS                    0x00000264
-#define BTCOEX_INT_EN_OFFSET                     0x00000264
-#define BTCOEX_INT_EN_I2C_RECV_OVERFLOW_MSB      11
-#define BTCOEX_INT_EN_I2C_RECV_OVERFLOW_LSB      11
-#define BTCOEX_INT_EN_I2C_RECV_OVERFLOW_MASK     0x00000800
-#define BTCOEX_INT_EN_I2C_RECV_OVERFLOW_GET(x)   (((x) & BTCOEX_INT_EN_I2C_RECV_OVERFLOW_MASK) >> BTCOEX_INT_EN_I2C_RECV_OVERFLOW_LSB)
-#define BTCOEX_INT_EN_I2C_RECV_OVERFLOW_SET(x)   (((x) << BTCOEX_INT_EN_I2C_RECV_OVERFLOW_LSB) & BTCOEX_INT_EN_I2C_RECV_OVERFLOW_MASK)
-#define BTCOEX_INT_EN_I2C_TX_FAILED_MSB          10
-#define BTCOEX_INT_EN_I2C_TX_FAILED_LSB          10
-#define BTCOEX_INT_EN_I2C_TX_FAILED_MASK         0x00000400
-#define BTCOEX_INT_EN_I2C_TX_FAILED_GET(x)       (((x) & BTCOEX_INT_EN_I2C_TX_FAILED_MASK) >> BTCOEX_INT_EN_I2C_TX_FAILED_LSB)
-#define BTCOEX_INT_EN_I2C_TX_FAILED_SET(x)       (((x) << BTCOEX_INT_EN_I2C_TX_FAILED_LSB) & BTCOEX_INT_EN_I2C_TX_FAILED_MASK)
-#define BTCOEX_INT_EN_I2C_MESG_SENT_MSB          9
-#define BTCOEX_INT_EN_I2C_MESG_SENT_LSB          9
-#define BTCOEX_INT_EN_I2C_MESG_SENT_MASK         0x00000200
-#define BTCOEX_INT_EN_I2C_MESG_SENT_GET(x)       (((x) & BTCOEX_INT_EN_I2C_MESG_SENT_MASK) >> BTCOEX_INT_EN_I2C_MESG_SENT_LSB)
-#define BTCOEX_INT_EN_I2C_MESG_SENT_SET(x)       (((x) << BTCOEX_INT_EN_I2C_MESG_SENT_LSB) & BTCOEX_INT_EN_I2C_MESG_SENT_MASK)
-#define BTCOEX_INT_EN_ST_MESG_RECV_MSB           8
-#define BTCOEX_INT_EN_ST_MESG_RECV_LSB           8
-#define BTCOEX_INT_EN_ST_MESG_RECV_MASK          0x00000100
-#define BTCOEX_INT_EN_ST_MESG_RECV_GET(x)        (((x) & BTCOEX_INT_EN_ST_MESG_RECV_MASK) >> BTCOEX_INT_EN_ST_MESG_RECV_LSB)
-#define BTCOEX_INT_EN_ST_MESG_RECV_SET(x)        (((x) << BTCOEX_INT_EN_ST_MESG_RECV_LSB) & BTCOEX_INT_EN_ST_MESG_RECV_MASK)
-#define BTCOEX_INT_EN_WB_TIMER_MSB               7
-#define BTCOEX_INT_EN_WB_TIMER_LSB               7
-#define BTCOEX_INT_EN_WB_TIMER_MASK              0x00000080
-#define BTCOEX_INT_EN_WB_TIMER_GET(x)            (((x) & BTCOEX_INT_EN_WB_TIMER_MASK) >> BTCOEX_INT_EN_WB_TIMER_LSB)
-#define BTCOEX_INT_EN_WB_TIMER_SET(x)            (((x) << BTCOEX_INT_EN_WB_TIMER_LSB) & BTCOEX_INT_EN_WB_TIMER_MASK)
-#define BTCOEX_INT_EN_NOSYNC_MSB                 4
-#define BTCOEX_INT_EN_NOSYNC_LSB                 4
-#define BTCOEX_INT_EN_NOSYNC_MASK                0x00000010
-#define BTCOEX_INT_EN_NOSYNC_GET(x)              (((x) & BTCOEX_INT_EN_NOSYNC_MASK) >> BTCOEX_INT_EN_NOSYNC_LSB)
-#define BTCOEX_INT_EN_NOSYNC_SET(x)              (((x) << BTCOEX_INT_EN_NOSYNC_LSB) & BTCOEX_INT_EN_NOSYNC_MASK)
-#define BTCOEX_INT_EN_SYNC_MSB                   3
-#define BTCOEX_INT_EN_SYNC_LSB                   3
-#define BTCOEX_INT_EN_SYNC_MASK                  0x00000008
-#define BTCOEX_INT_EN_SYNC_GET(x)                (((x) & BTCOEX_INT_EN_SYNC_MASK) >> BTCOEX_INT_EN_SYNC_LSB)
-#define BTCOEX_INT_EN_SYNC_SET(x)                (((x) << BTCOEX_INT_EN_SYNC_LSB) & BTCOEX_INT_EN_SYNC_MASK)
-#define BTCOEX_INT_EN_END_MSB                    2
-#define BTCOEX_INT_EN_END_LSB                    2
-#define BTCOEX_INT_EN_END_MASK                   0x00000004
-#define BTCOEX_INT_EN_END_GET(x)                 (((x) & BTCOEX_INT_EN_END_MASK) >> BTCOEX_INT_EN_END_LSB)
-#define BTCOEX_INT_EN_END_SET(x)                 (((x) << BTCOEX_INT_EN_END_LSB) & BTCOEX_INT_EN_END_MASK)
-#define BTCOEX_INT_EN_FRAME_CNT_MSB              1
-#define BTCOEX_INT_EN_FRAME_CNT_LSB              1
-#define BTCOEX_INT_EN_FRAME_CNT_MASK             0x00000002
-#define BTCOEX_INT_EN_FRAME_CNT_GET(x)           (((x) & BTCOEX_INT_EN_FRAME_CNT_MASK) >> BTCOEX_INT_EN_FRAME_CNT_LSB)
-#define BTCOEX_INT_EN_FRAME_CNT_SET(x)           (((x) << BTCOEX_INT_EN_FRAME_CNT_LSB) & BTCOEX_INT_EN_FRAME_CNT_MASK)
-#define BTCOEX_INT_EN_CLK_CNT_MSB                0
-#define BTCOEX_INT_EN_CLK_CNT_LSB                0
-#define BTCOEX_INT_EN_CLK_CNT_MASK               0x00000001
-#define BTCOEX_INT_EN_CLK_CNT_GET(x)             (((x) & BTCOEX_INT_EN_CLK_CNT_MASK) >> BTCOEX_INT_EN_CLK_CNT_LSB)
-#define BTCOEX_INT_EN_CLK_CNT_SET(x)             (((x) << BTCOEX_INT_EN_CLK_CNT_LSB) & BTCOEX_INT_EN_CLK_CNT_MASK)
-
-#define BTCOEX_INT_STAT_ADDRESS                  0x00000268
-#define BTCOEX_INT_STAT_OFFSET                   0x00000268
-#define BTCOEX_INT_STAT_I2C_RECV_OVERFLOW_MSB    11
-#define BTCOEX_INT_STAT_I2C_RECV_OVERFLOW_LSB    11
-#define BTCOEX_INT_STAT_I2C_RECV_OVERFLOW_MASK   0x00000800
-#define BTCOEX_INT_STAT_I2C_RECV_OVERFLOW_GET(x) (((x) & BTCOEX_INT_STAT_I2C_RECV_OVERFLOW_MASK) >> BTCOEX_INT_STAT_I2C_RECV_OVERFLOW_LSB)
-#define BTCOEX_INT_STAT_I2C_RECV_OVERFLOW_SET(x) (((x) << BTCOEX_INT_STAT_I2C_RECV_OVERFLOW_LSB) & BTCOEX_INT_STAT_I2C_RECV_OVERFLOW_MASK)
-#define BTCOEX_INT_STAT_I2C_TX_FAILED_MSB        10
-#define BTCOEX_INT_STAT_I2C_TX_FAILED_LSB        10
-#define BTCOEX_INT_STAT_I2C_TX_FAILED_MASK       0x00000400
-#define BTCOEX_INT_STAT_I2C_TX_FAILED_GET(x)     (((x) & BTCOEX_INT_STAT_I2C_TX_FAILED_MASK) >> BTCOEX_INT_STAT_I2C_TX_FAILED_LSB)
-#define BTCOEX_INT_STAT_I2C_TX_FAILED_SET(x)     (((x) << BTCOEX_INT_STAT_I2C_TX_FAILED_LSB) & BTCOEX_INT_STAT_I2C_TX_FAILED_MASK)
-#define BTCOEX_INT_STAT_I2C_MESG_SENT_MSB        9
-#define BTCOEX_INT_STAT_I2C_MESG_SENT_LSB        9
-#define BTCOEX_INT_STAT_I2C_MESG_SENT_MASK       0x00000200
-#define BTCOEX_INT_STAT_I2C_MESG_SENT_GET(x)     (((x) & BTCOEX_INT_STAT_I2C_MESG_SENT_MASK) >> BTCOEX_INT_STAT_I2C_MESG_SENT_LSB)
-#define BTCOEX_INT_STAT_I2C_MESG_SENT_SET(x)     (((x) << BTCOEX_INT_STAT_I2C_MESG_SENT_LSB) & BTCOEX_INT_STAT_I2C_MESG_SENT_MASK)
-#define BTCOEX_INT_STAT_I2C_MESG_RECV_MSB        8
-#define BTCOEX_INT_STAT_I2C_MESG_RECV_LSB        8
-#define BTCOEX_INT_STAT_I2C_MESG_RECV_MASK       0x00000100
-#define BTCOEX_INT_STAT_I2C_MESG_RECV_GET(x)     (((x) & BTCOEX_INT_STAT_I2C_MESG_RECV_MASK) >> BTCOEX_INT_STAT_I2C_MESG_RECV_LSB)
-#define BTCOEX_INT_STAT_I2C_MESG_RECV_SET(x)     (((x) << BTCOEX_INT_STAT_I2C_MESG_RECV_LSB) & BTCOEX_INT_STAT_I2C_MESG_RECV_MASK)
-#define BTCOEX_INT_STAT_WB_TIMER_MSB             7
-#define BTCOEX_INT_STAT_WB_TIMER_LSB             7
-#define BTCOEX_INT_STAT_WB_TIMER_MASK            0x00000080
-#define BTCOEX_INT_STAT_WB_TIMER_GET(x)          (((x) & BTCOEX_INT_STAT_WB_TIMER_MASK) >> BTCOEX_INT_STAT_WB_TIMER_LSB)
-#define BTCOEX_INT_STAT_WB_TIMER_SET(x)          (((x) << BTCOEX_INT_STAT_WB_TIMER_LSB) & BTCOEX_INT_STAT_WB_TIMER_MASK)
-#define BTCOEX_INT_STAT_BTPRIORITY_STOMP_MSB     6
-#define BTCOEX_INT_STAT_BTPRIORITY_STOMP_LSB     6
-#define BTCOEX_INT_STAT_BTPRIORITY_STOMP_MASK    0x00000040
-#define BTCOEX_INT_STAT_BTPRIORITY_STOMP_GET(x)  (((x) & BTCOEX_INT_STAT_BTPRIORITY_STOMP_MASK) >> BTCOEX_INT_STAT_BTPRIORITY_STOMP_LSB)
-#define BTCOEX_INT_STAT_BTPRIORITY_STOMP_SET(x)  (((x) << BTCOEX_INT_STAT_BTPRIORITY_STOMP_LSB) & BTCOEX_INT_STAT_BTPRIORITY_STOMP_MASK)
-#define BTCOEX_INT_STAT_BTPRIORITY_MSB           5
-#define BTCOEX_INT_STAT_BTPRIORITY_LSB           5
-#define BTCOEX_INT_STAT_BTPRIORITY_MASK          0x00000020
-#define BTCOEX_INT_STAT_BTPRIORITY_GET(x)        (((x) & BTCOEX_INT_STAT_BTPRIORITY_MASK) >> BTCOEX_INT_STAT_BTPRIORITY_LSB)
-#define BTCOEX_INT_STAT_BTPRIORITY_SET(x)        (((x) << BTCOEX_INT_STAT_BTPRIORITY_LSB) & BTCOEX_INT_STAT_BTPRIORITY_MASK)
-#define BTCOEX_INT_STAT_NOSYNC_MSB               4
-#define BTCOEX_INT_STAT_NOSYNC_LSB               4
-#define BTCOEX_INT_STAT_NOSYNC_MASK              0x00000010
-#define BTCOEX_INT_STAT_NOSYNC_GET(x)            (((x) & BTCOEX_INT_STAT_NOSYNC_MASK) >> BTCOEX_INT_STAT_NOSYNC_LSB)
-#define BTCOEX_INT_STAT_NOSYNC_SET(x)            (((x) << BTCOEX_INT_STAT_NOSYNC_LSB) & BTCOEX_INT_STAT_NOSYNC_MASK)
-#define BTCOEX_INT_STAT_SYNC_MSB                 3
-#define BTCOEX_INT_STAT_SYNC_LSB                 3
-#define BTCOEX_INT_STAT_SYNC_MASK                0x00000008
-#define BTCOEX_INT_STAT_SYNC_GET(x)              (((x) & BTCOEX_INT_STAT_SYNC_MASK) >> BTCOEX_INT_STAT_SYNC_LSB)
-#define BTCOEX_INT_STAT_SYNC_SET(x)              (((x) << BTCOEX_INT_STAT_SYNC_LSB) & BTCOEX_INT_STAT_SYNC_MASK)
-#define BTCOEX_INT_STAT_END_MSB                  2
-#define BTCOEX_INT_STAT_END_LSB                  2
-#define BTCOEX_INT_STAT_END_MASK                 0x00000004
-#define BTCOEX_INT_STAT_END_GET(x)               (((x) & BTCOEX_INT_STAT_END_MASK) >> BTCOEX_INT_STAT_END_LSB)
-#define BTCOEX_INT_STAT_END_SET(x)               (((x) << BTCOEX_INT_STAT_END_LSB) & BTCOEX_INT_STAT_END_MASK)
-#define BTCOEX_INT_STAT_FRAME_CNT_MSB            1
-#define BTCOEX_INT_STAT_FRAME_CNT_LSB            1
-#define BTCOEX_INT_STAT_FRAME_CNT_MASK           0x00000002
-#define BTCOEX_INT_STAT_FRAME_CNT_GET(x)         (((x) & BTCOEX_INT_STAT_FRAME_CNT_MASK) >> BTCOEX_INT_STAT_FRAME_CNT_LSB)
-#define BTCOEX_INT_STAT_FRAME_CNT_SET(x)         (((x) << BTCOEX_INT_STAT_FRAME_CNT_LSB) & BTCOEX_INT_STAT_FRAME_CNT_MASK)
-#define BTCOEX_INT_STAT_CLK_CNT_MSB              0
-#define BTCOEX_INT_STAT_CLK_CNT_LSB              0
-#define BTCOEX_INT_STAT_CLK_CNT_MASK             0x00000001
-#define BTCOEX_INT_STAT_CLK_CNT_GET(x)           (((x) & BTCOEX_INT_STAT_CLK_CNT_MASK) >> BTCOEX_INT_STAT_CLK_CNT_LSB)
-#define BTCOEX_INT_STAT_CLK_CNT_SET(x)           (((x) << BTCOEX_INT_STAT_CLK_CNT_LSB) & BTCOEX_INT_STAT_CLK_CNT_MASK)
-
-#define BTPRIORITY_INT_EN_ADDRESS                0x0000026c
-#define BTPRIORITY_INT_EN_OFFSET                 0x0000026c
-#define BTPRIORITY_INT_EN_BITMAP_MSB             31
-#define BTPRIORITY_INT_EN_BITMAP_LSB             0
-#define BTPRIORITY_INT_EN_BITMAP_MASK            0xffffffff
-#define BTPRIORITY_INT_EN_BITMAP_GET(x)          (((x) & BTPRIORITY_INT_EN_BITMAP_MASK) >> BTPRIORITY_INT_EN_BITMAP_LSB)
-#define BTPRIORITY_INT_EN_BITMAP_SET(x)          (((x) << BTPRIORITY_INT_EN_BITMAP_LSB) & BTPRIORITY_INT_EN_BITMAP_MASK)
-
-#define BTPRIORITY_INT_STAT_ADDRESS              0x00000270
-#define BTPRIORITY_INT_STAT_OFFSET               0x00000270
-#define BTPRIORITY_INT_STAT_BITMAP_MSB           31
-#define BTPRIORITY_INT_STAT_BITMAP_LSB           0
-#define BTPRIORITY_INT_STAT_BITMAP_MASK          0xffffffff
-#define BTPRIORITY_INT_STAT_BITMAP_GET(x)        (((x) & BTPRIORITY_INT_STAT_BITMAP_MASK) >> BTPRIORITY_INT_STAT_BITMAP_LSB)
-#define BTPRIORITY_INT_STAT_BITMAP_SET(x)        (((x) << BTPRIORITY_INT_STAT_BITMAP_LSB) & BTPRIORITY_INT_STAT_BITMAP_MASK)
-
-#define BTPRIORITY_STOMP_INT_EN_ADDRESS          0x00000274
-#define BTPRIORITY_STOMP_INT_EN_OFFSET           0x00000274
-#define BTPRIORITY_STOMP_INT_EN_BITMAP_MSB       31
-#define BTPRIORITY_STOMP_INT_EN_BITMAP_LSB       0
-#define BTPRIORITY_STOMP_INT_EN_BITMAP_MASK      0xffffffff
-#define BTPRIORITY_STOMP_INT_EN_BITMAP_GET(x)    (((x) & BTPRIORITY_STOMP_INT_EN_BITMAP_MASK) >> BTPRIORITY_STOMP_INT_EN_BITMAP_LSB)
-#define BTPRIORITY_STOMP_INT_EN_BITMAP_SET(x)    (((x) << BTPRIORITY_STOMP_INT_EN_BITMAP_LSB) & BTPRIORITY_STOMP_INT_EN_BITMAP_MASK)
-
-#define BTPRIORITY_STOMP_INT_STAT_ADDRESS        0x00000278
-#define BTPRIORITY_STOMP_INT_STAT_OFFSET         0x00000278
-#define BTPRIORITY_STOMP_INT_STAT_BITMAP_MSB     31
-#define BTPRIORITY_STOMP_INT_STAT_BITMAP_LSB     0
-#define BTPRIORITY_STOMP_INT_STAT_BITMAP_MASK    0xffffffff
-#define BTPRIORITY_STOMP_INT_STAT_BITMAP_GET(x)  (((x) & BTPRIORITY_STOMP_INT_STAT_BITMAP_MASK) >> BTPRIORITY_STOMP_INT_STAT_BITMAP_LSB)
-#define BTPRIORITY_STOMP_INT_STAT_BITMAP_SET(x)  (((x) << BTPRIORITY_STOMP_INT_STAT_BITMAP_LSB) & BTPRIORITY_STOMP_INT_STAT_BITMAP_MASK)
-
-#define MAC_PCU_BMISS_TIMEOUT_ADDRESS            0x0000027c
-#define MAC_PCU_BMISS_TIMEOUT_OFFSET             0x0000027c
-#define MAC_PCU_BMISS_TIMEOUT_ENABLE_MSB         24
-#define MAC_PCU_BMISS_TIMEOUT_ENABLE_LSB         24
-#define MAC_PCU_BMISS_TIMEOUT_ENABLE_MASK        0x01000000
-#define MAC_PCU_BMISS_TIMEOUT_ENABLE_GET(x)      (((x) & MAC_PCU_BMISS_TIMEOUT_ENABLE_MASK) >> MAC_PCU_BMISS_TIMEOUT_ENABLE_LSB)
-#define MAC_PCU_BMISS_TIMEOUT_ENABLE_SET(x)      (((x) << MAC_PCU_BMISS_TIMEOUT_ENABLE_LSB) & MAC_PCU_BMISS_TIMEOUT_ENABLE_MASK)
-#define MAC_PCU_BMISS_TIMEOUT_VALUE_MSB          23
-#define MAC_PCU_BMISS_TIMEOUT_VALUE_LSB          0
-#define MAC_PCU_BMISS_TIMEOUT_VALUE_MASK         0x00ffffff
-#define MAC_PCU_BMISS_TIMEOUT_VALUE_GET(x)       (((x) & MAC_PCU_BMISS_TIMEOUT_VALUE_MASK) >> MAC_PCU_BMISS_TIMEOUT_VALUE_LSB)
-#define MAC_PCU_BMISS_TIMEOUT_VALUE_SET(x)       (((x) << MAC_PCU_BMISS_TIMEOUT_VALUE_LSB) & MAC_PCU_BMISS_TIMEOUT_VALUE_MASK)
-
-#define MAC_PCU_CAB_AWAKE_ADDRESS                0x00000280
-#define MAC_PCU_CAB_AWAKE_OFFSET                 0x00000280
-#define MAC_PCU_CAB_AWAKE_ENABLE_MSB             16
-#define MAC_PCU_CAB_AWAKE_ENABLE_LSB             16
-#define MAC_PCU_CAB_AWAKE_ENABLE_MASK            0x00010000
-#define MAC_PCU_CAB_AWAKE_ENABLE_GET(x)          (((x) & MAC_PCU_CAB_AWAKE_ENABLE_MASK) >> MAC_PCU_CAB_AWAKE_ENABLE_LSB)
-#define MAC_PCU_CAB_AWAKE_ENABLE_SET(x)          (((x) << MAC_PCU_CAB_AWAKE_ENABLE_LSB) & MAC_PCU_CAB_AWAKE_ENABLE_MASK)
-#define MAC_PCU_CAB_AWAKE_DURATION_MSB           15
-#define MAC_PCU_CAB_AWAKE_DURATION_LSB           0
-#define MAC_PCU_CAB_AWAKE_DURATION_MASK          0x0000ffff
-#define MAC_PCU_CAB_AWAKE_DURATION_GET(x)        (((x) & MAC_PCU_CAB_AWAKE_DURATION_MASK) >> MAC_PCU_CAB_AWAKE_DURATION_LSB)
-#define MAC_PCU_CAB_AWAKE_DURATION_SET(x)        (((x) << MAC_PCU_CAB_AWAKE_DURATION_LSB) & MAC_PCU_CAB_AWAKE_DURATION_MASK)
-
-#define LP_PERF_COUNTER_ADDRESS                  0x00000284
-#define LP_PERF_COUNTER_OFFSET                   0x00000284
-#define LP_PERF_COUNTER_EN_MSB                   0
-#define LP_PERF_COUNTER_EN_LSB                   0
-#define LP_PERF_COUNTER_EN_MASK                  0x00000001
-#define LP_PERF_COUNTER_EN_GET(x)                (((x) & LP_PERF_COUNTER_EN_MASK) >> LP_PERF_COUNTER_EN_LSB)
-#define LP_PERF_COUNTER_EN_SET(x)                (((x) << LP_PERF_COUNTER_EN_LSB) & LP_PERF_COUNTER_EN_MASK)
-
-#define LP_PERF_LIGHT_SLEEP_ADDRESS              0x00000288
-#define LP_PERF_LIGHT_SLEEP_OFFSET               0x00000288
-#define LP_PERF_LIGHT_SLEEP_CNT_MSB              31
-#define LP_PERF_LIGHT_SLEEP_CNT_LSB              0
-#define LP_PERF_LIGHT_SLEEP_CNT_MASK             0xffffffff
-#define LP_PERF_LIGHT_SLEEP_CNT_GET(x)           (((x) & LP_PERF_LIGHT_SLEEP_CNT_MASK) >> LP_PERF_LIGHT_SLEEP_CNT_LSB)
-#define LP_PERF_LIGHT_SLEEP_CNT_SET(x)           (((x) << LP_PERF_LIGHT_SLEEP_CNT_LSB) & LP_PERF_LIGHT_SLEEP_CNT_MASK)
-
-#define LP_PERF_DEEP_SLEEP_ADDRESS               0x0000028c
-#define LP_PERF_DEEP_SLEEP_OFFSET                0x0000028c
-#define LP_PERF_DEEP_SLEEP_CNT_MSB               31
-#define LP_PERF_DEEP_SLEEP_CNT_LSB               0
-#define LP_PERF_DEEP_SLEEP_CNT_MASK              0xffffffff
-#define LP_PERF_DEEP_SLEEP_CNT_GET(x)            (((x) & LP_PERF_DEEP_SLEEP_CNT_MASK) >> LP_PERF_DEEP_SLEEP_CNT_LSB)
-#define LP_PERF_DEEP_SLEEP_CNT_SET(x)            (((x) << LP_PERF_DEEP_SLEEP_CNT_LSB) & LP_PERF_DEEP_SLEEP_CNT_MASK)
-
-#define LP_PERF_ON_ADDRESS                       0x00000290
-#define LP_PERF_ON_OFFSET                        0x00000290
-#define LP_PERF_ON_CNT_MSB                       31
-#define LP_PERF_ON_CNT_LSB                       0
-#define LP_PERF_ON_CNT_MASK                      0xffffffff
-#define LP_PERF_ON_CNT_GET(x)                    (((x) & LP_PERF_ON_CNT_MASK) >> LP_PERF_ON_CNT_LSB)
-#define LP_PERF_ON_CNT_SET(x)                    (((x) << LP_PERF_ON_CNT_LSB) & LP_PERF_ON_CNT_MASK)
-
-#define ST_64_BIT_ADDRESS                        0x00000294
-#define ST_64_BIT_OFFSET                         0x00000294
-#define ST_64_BIT_TIMEOUT_MSB                    26
-#define ST_64_BIT_TIMEOUT_LSB                    9
-#define ST_64_BIT_TIMEOUT_MASK                   0x07fffe00
-#define ST_64_BIT_TIMEOUT_GET(x)                 (((x) & ST_64_BIT_TIMEOUT_MASK) >> ST_64_BIT_TIMEOUT_LSB)
-#define ST_64_BIT_TIMEOUT_SET(x)                 (((x) << ST_64_BIT_TIMEOUT_LSB) & ST_64_BIT_TIMEOUT_MASK)
-#define ST_64_BIT_REQ_ACK_NOT_PULLED_DOWN_MSB    8
-#define ST_64_BIT_REQ_ACK_NOT_PULLED_DOWN_LSB    8
-#define ST_64_BIT_REQ_ACK_NOT_PULLED_DOWN_MASK   0x00000100
-#define ST_64_BIT_REQ_ACK_NOT_PULLED_DOWN_GET(x) (((x) & ST_64_BIT_REQ_ACK_NOT_PULLED_DOWN_MASK) >> ST_64_BIT_REQ_ACK_NOT_PULLED_DOWN_LSB)
-#define ST_64_BIT_REQ_ACK_NOT_PULLED_DOWN_SET(x) (((x) << ST_64_BIT_REQ_ACK_NOT_PULLED_DOWN_LSB) & ST_64_BIT_REQ_ACK_NOT_PULLED_DOWN_MASK)
-#define ST_64_BIT_DRIVE_MODE_MSB                 7
-#define ST_64_BIT_DRIVE_MODE_LSB                 7
-#define ST_64_BIT_DRIVE_MODE_MASK                0x00000080
-#define ST_64_BIT_DRIVE_MODE_GET(x)              (((x) & ST_64_BIT_DRIVE_MODE_MASK) >> ST_64_BIT_DRIVE_MODE_LSB)
-#define ST_64_BIT_DRIVE_MODE_SET(x)              (((x) << ST_64_BIT_DRIVE_MODE_LSB) & ST_64_BIT_DRIVE_MODE_MASK)
-#define ST_64_BIT_CLOCK_GATE_MSB                 6
-#define ST_64_BIT_CLOCK_GATE_LSB                 6
-#define ST_64_BIT_CLOCK_GATE_MASK                0x00000040
-#define ST_64_BIT_CLOCK_GATE_GET(x)              (((x) & ST_64_BIT_CLOCK_GATE_MASK) >> ST_64_BIT_CLOCK_GATE_LSB)
-#define ST_64_BIT_CLOCK_GATE_SET(x)              (((x) << ST_64_BIT_CLOCK_GATE_LSB) & ST_64_BIT_CLOCK_GATE_MASK)
-#define ST_64_BIT_SOC_CLK_DIVIDE_RATIO_MSB       5
-#define ST_64_BIT_SOC_CLK_DIVIDE_RATIO_LSB       1
-#define ST_64_BIT_SOC_CLK_DIVIDE_RATIO_MASK      0x0000003e
-#define ST_64_BIT_SOC_CLK_DIVIDE_RATIO_GET(x)    (((x) & ST_64_BIT_SOC_CLK_DIVIDE_RATIO_MASK) >> ST_64_BIT_SOC_CLK_DIVIDE_RATIO_LSB)
-#define ST_64_BIT_SOC_CLK_DIVIDE_RATIO_SET(x)    (((x) << ST_64_BIT_SOC_CLK_DIVIDE_RATIO_LSB) & ST_64_BIT_SOC_CLK_DIVIDE_RATIO_MASK)
-#define ST_64_BIT_MODE_MSB                       0
-#define ST_64_BIT_MODE_LSB                       0
-#define ST_64_BIT_MODE_MASK                      0x00000001
-#define ST_64_BIT_MODE_GET(x)                    (((x) & ST_64_BIT_MODE_MASK) >> ST_64_BIT_MODE_LSB)
-#define ST_64_BIT_MODE_SET(x)                    (((x) << ST_64_BIT_MODE_LSB) & ST_64_BIT_MODE_MASK)
-
-#define MESSAGE_WR_ADDRESS                       0x00000298
-#define MESSAGE_WR_OFFSET                        0x00000298
-#define MESSAGE_WR_TYPE_MSB                      31
-#define MESSAGE_WR_TYPE_LSB                      0
-#define MESSAGE_WR_TYPE_MASK                     0xffffffff
-#define MESSAGE_WR_TYPE_GET(x)                   (((x) & MESSAGE_WR_TYPE_MASK) >> MESSAGE_WR_TYPE_LSB)
-#define MESSAGE_WR_TYPE_SET(x)                   (((x) << MESSAGE_WR_TYPE_LSB) & MESSAGE_WR_TYPE_MASK)
-
-#define MESSAGE_WR_P_ADDRESS                     0x0000029c
-#define MESSAGE_WR_P_OFFSET                      0x0000029c
-#define MESSAGE_WR_P_PARAMETER_MSB               31
-#define MESSAGE_WR_P_PARAMETER_LSB               0
-#define MESSAGE_WR_P_PARAMETER_MASK              0xffffffff
-#define MESSAGE_WR_P_PARAMETER_GET(x)            (((x) & MESSAGE_WR_P_PARAMETER_MASK) >> MESSAGE_WR_P_PARAMETER_LSB)
-#define MESSAGE_WR_P_PARAMETER_SET(x)            (((x) << MESSAGE_WR_P_PARAMETER_LSB) & MESSAGE_WR_P_PARAMETER_MASK)
-
-#define MESSAGE_RD_ADDRESS                       0x000002a0
-#define MESSAGE_RD_OFFSET                        0x000002a0
-#define MESSAGE_RD_TYPE_MSB                      31
-#define MESSAGE_RD_TYPE_LSB                      0
-#define MESSAGE_RD_TYPE_MASK                     0xffffffff
-#define MESSAGE_RD_TYPE_GET(x)                   (((x) & MESSAGE_RD_TYPE_MASK) >> MESSAGE_RD_TYPE_LSB)
-#define MESSAGE_RD_TYPE_SET(x)                   (((x) << MESSAGE_RD_TYPE_LSB) & MESSAGE_RD_TYPE_MASK)
-
-#define MESSAGE_RD_P_ADDRESS                     0x000002a4
-#define MESSAGE_RD_P_OFFSET                      0x000002a4
-#define MESSAGE_RD_P_PARAMETER_MSB               31
-#define MESSAGE_RD_P_PARAMETER_LSB               0
-#define MESSAGE_RD_P_PARAMETER_MASK              0xffffffff
-#define MESSAGE_RD_P_PARAMETER_GET(x)            (((x) & MESSAGE_RD_P_PARAMETER_MASK) >> MESSAGE_RD_P_PARAMETER_LSB)
-#define MESSAGE_RD_P_PARAMETER_SET(x)            (((x) << MESSAGE_RD_P_PARAMETER_LSB) & MESSAGE_RD_P_PARAMETER_MASK)
-
-#define CHIP_MODE_ADDRESS                        0x000002a8
-#define CHIP_MODE_OFFSET                         0x000002a8
-#define CHIP_MODE_BIT_MSB                        1
-#define CHIP_MODE_BIT_LSB                        0
-#define CHIP_MODE_BIT_MASK                       0x00000003
-#define CHIP_MODE_BIT_GET(x)                     (((x) & CHIP_MODE_BIT_MASK) >> CHIP_MODE_BIT_LSB)
-#define CHIP_MODE_BIT_SET(x)                     (((x) << CHIP_MODE_BIT_LSB) & CHIP_MODE_BIT_MASK)
-
-#define CLK_REQ_FALL_EDGE_ADDRESS                0x000002ac
-#define CLK_REQ_FALL_EDGE_OFFSET                 0x000002ac
-#define CLK_REQ_FALL_EDGE_EN_MSB                 31
-#define CLK_REQ_FALL_EDGE_EN_LSB                 31
-#define CLK_REQ_FALL_EDGE_EN_MASK                0x80000000
-#define CLK_REQ_FALL_EDGE_EN_GET(x)              (((x) & CLK_REQ_FALL_EDGE_EN_MASK) >> CLK_REQ_FALL_EDGE_EN_LSB)
-#define CLK_REQ_FALL_EDGE_EN_SET(x)              (((x) << CLK_REQ_FALL_EDGE_EN_LSB) & CLK_REQ_FALL_EDGE_EN_MASK)
-#define CLK_REQ_FALL_EDGE_DELAY_MSB              7
-#define CLK_REQ_FALL_EDGE_DELAY_LSB              0
-#define CLK_REQ_FALL_EDGE_DELAY_MASK             0x000000ff
-#define CLK_REQ_FALL_EDGE_DELAY_GET(x)           (((x) & CLK_REQ_FALL_EDGE_DELAY_MASK) >> CLK_REQ_FALL_EDGE_DELAY_LSB)
-#define CLK_REQ_FALL_EDGE_DELAY_SET(x)           (((x) << CLK_REQ_FALL_EDGE_DELAY_LSB) & CLK_REQ_FALL_EDGE_DELAY_MASK)
-
-#define OTP_ADDRESS                              0x000002b0
-#define OTP_OFFSET                               0x000002b0
-#define OTP_LDO25_EN_MSB                         1
-#define OTP_LDO25_EN_LSB                         1
-#define OTP_LDO25_EN_MASK                        0x00000002
-#define OTP_LDO25_EN_GET(x)                      (((x) & OTP_LDO25_EN_MASK) >> OTP_LDO25_EN_LSB)
-#define OTP_LDO25_EN_SET(x)                      (((x) << OTP_LDO25_EN_LSB) & OTP_LDO25_EN_MASK)
-#define OTP_VDD12_EN_MSB                         0
-#define OTP_VDD12_EN_LSB                         0
-#define OTP_VDD12_EN_MASK                        0x00000001
-#define OTP_VDD12_EN_GET(x)                      (((x) & OTP_VDD12_EN_MASK) >> OTP_VDD12_EN_LSB)
-#define OTP_VDD12_EN_SET(x)                      (((x) << OTP_VDD12_EN_LSB) & OTP_VDD12_EN_MASK)
-
-#define OTP_STATUS_ADDRESS                       0x000002b4
-#define OTP_STATUS_OFFSET                        0x000002b4
-#define OTP_STATUS_LDO25_EN_READY_MSB            1
-#define OTP_STATUS_LDO25_EN_READY_LSB            1
-#define OTP_STATUS_LDO25_EN_READY_MASK           0x00000002
-#define OTP_STATUS_LDO25_EN_READY_GET(x)         (((x) & OTP_STATUS_LDO25_EN_READY_MASK) >> OTP_STATUS_LDO25_EN_READY_LSB)
-#define OTP_STATUS_LDO25_EN_READY_SET(x)         (((x) << OTP_STATUS_LDO25_EN_READY_LSB) & OTP_STATUS_LDO25_EN_READY_MASK)
-#define OTP_STATUS_VDD12_EN_READY_MSB            0
-#define OTP_STATUS_VDD12_EN_READY_LSB            0
-#define OTP_STATUS_VDD12_EN_READY_MASK           0x00000001
-#define OTP_STATUS_VDD12_EN_READY_GET(x)         (((x) & OTP_STATUS_VDD12_EN_READY_MASK) >> OTP_STATUS_VDD12_EN_READY_LSB)
-#define OTP_STATUS_VDD12_EN_READY_SET(x)         (((x) << OTP_STATUS_VDD12_EN_READY_LSB) & OTP_STATUS_VDD12_EN_READY_MASK)
-
-#define PMU_ADDRESS                              0x000002b8
-#define PMU_OFFSET                               0x000002b8
-#define PMU_REG_WAKEUP_TIME_SEL_MSB              1
-#define PMU_REG_WAKEUP_TIME_SEL_LSB              0
-#define PMU_REG_WAKEUP_TIME_SEL_MASK             0x00000003
-#define PMU_REG_WAKEUP_TIME_SEL_GET(x)           (((x) & PMU_REG_WAKEUP_TIME_SEL_MASK) >> PMU_REG_WAKEUP_TIME_SEL_LSB)
-#define PMU_REG_WAKEUP_TIME_SEL_SET(x)           (((x) << PMU_REG_WAKEUP_TIME_SEL_LSB) & PMU_REG_WAKEUP_TIME_SEL_MASK)
-
-#define PMU_CONFIG_ADDRESS                       0x000002c0
-#define PMU_CONFIG_OFFSET                        0x000002c0
-#define PMU_CONFIG_VALUE_MSB                     15
-#define PMU_CONFIG_VALUE_LSB                     0
-#define PMU_CONFIG_VALUE_MASK                    0x0000ffff
-#define PMU_CONFIG_VALUE_GET(x)                  (((x) & PMU_CONFIG_VALUE_MASK) >> PMU_CONFIG_VALUE_LSB)
-#define PMU_CONFIG_VALUE_SET(x)                  (((x) << PMU_CONFIG_VALUE_LSB) & PMU_CONFIG_VALUE_MASK)
-
-#define PMU_BYPASS_ADDRESS                       0x000002c8
-#define PMU_BYPASS_OFFSET                        0x000002c8
-#define PMU_BYPASS_SWREG_MSB                     2
-#define PMU_BYPASS_SWREG_LSB                     2
-#define PMU_BYPASS_SWREG_MASK                    0x00000004
-#define PMU_BYPASS_SWREG_GET(x)                  (((x) & PMU_BYPASS_SWREG_MASK) >> PMU_BYPASS_SWREG_LSB)
-#define PMU_BYPASS_SWREG_SET(x)                  (((x) << PMU_BYPASS_SWREG_LSB) & PMU_BYPASS_SWREG_MASK)
-#define PMU_BYPASS_DREG_MSB                      1
-#define PMU_BYPASS_DREG_LSB                      1
-#define PMU_BYPASS_DREG_MASK                     0x00000002
-#define PMU_BYPASS_DREG_GET(x)                   (((x) & PMU_BYPASS_DREG_MASK) >> PMU_BYPASS_DREG_LSB)
-#define PMU_BYPASS_DREG_SET(x)                   (((x) << PMU_BYPASS_DREG_LSB) & PMU_BYPASS_DREG_MASK)
-#define PMU_BYPASS_PAREG_MSB                     0
-#define PMU_BYPASS_PAREG_LSB                     0
-#define PMU_BYPASS_PAREG_MASK                    0x00000001
-#define PMU_BYPASS_PAREG_GET(x)                  (((x) & PMU_BYPASS_PAREG_MASK) >> PMU_BYPASS_PAREG_LSB)
-#define PMU_BYPASS_PAREG_SET(x)                  (((x) << PMU_BYPASS_PAREG_LSB) & PMU_BYPASS_PAREG_MASK)
-
-#define MAC_PCU_TSF2_L32_ADDRESS                 0x000002cc
-#define MAC_PCU_TSF2_L32_OFFSET                  0x000002cc
-#define MAC_PCU_TSF2_L32_VALUE_MSB               31
-#define MAC_PCU_TSF2_L32_VALUE_LSB               0
-#define MAC_PCU_TSF2_L32_VALUE_MASK              0xffffffff
-#define MAC_PCU_TSF2_L32_VALUE_GET(x)            (((x) & MAC_PCU_TSF2_L32_VALUE_MASK) >> MAC_PCU_TSF2_L32_VALUE_LSB)
-#define MAC_PCU_TSF2_L32_VALUE_SET(x)            (((x) << MAC_PCU_TSF2_L32_VALUE_LSB) & MAC_PCU_TSF2_L32_VALUE_MASK)
-
-#define MAC_PCU_TSF2_U32_ADDRESS                 0x000002d0
-#define MAC_PCU_TSF2_U32_OFFSET                  0x000002d0
-#define MAC_PCU_TSF2_U32_VALUE_MSB               31
-#define MAC_PCU_TSF2_U32_VALUE_LSB               0
-#define MAC_PCU_TSF2_U32_VALUE_MASK              0xffffffff
-#define MAC_PCU_TSF2_U32_VALUE_GET(x)            (((x) & MAC_PCU_TSF2_U32_VALUE_MASK) >> MAC_PCU_TSF2_U32_VALUE_LSB)
-#define MAC_PCU_TSF2_U32_VALUE_SET(x)            (((x) << MAC_PCU_TSF2_U32_VALUE_LSB) & MAC_PCU_TSF2_U32_VALUE_MASK)
-
-#define MAC_PCU_GENERIC_TIMERS_MODE3_ADDRESS     0x000002d4
-#define MAC_PCU_GENERIC_TIMERS_MODE3_OFFSET      0x000002d4
-#define MAC_PCU_GENERIC_TIMERS_MODE3_OVERFLOW_INDEX_MSB 27
-#define MAC_PCU_GENERIC_TIMERS_MODE3_OVERFLOW_INDEX_LSB 24
-#define MAC_PCU_GENERIC_TIMERS_MODE3_OVERFLOW_INDEX_MASK 0x0f000000
-#define MAC_PCU_GENERIC_TIMERS_MODE3_OVERFLOW_INDEX_GET(x) (((x) & MAC_PCU_GENERIC_TIMERS_MODE3_OVERFLOW_INDEX_MASK) >> MAC_PCU_GENERIC_TIMERS_MODE3_OVERFLOW_INDEX_LSB)
-#define MAC_PCU_GENERIC_TIMERS_MODE3_OVERFLOW_INDEX_SET(x) (((x) << MAC_PCU_GENERIC_TIMERS_MODE3_OVERFLOW_INDEX_LSB) & MAC_PCU_GENERIC_TIMERS_MODE3_OVERFLOW_INDEX_MASK)
-#define MAC_PCU_GENERIC_TIMERS_MODE3_THRESH_MSB  19
-#define MAC_PCU_GENERIC_TIMERS_MODE3_THRESH_LSB  0
-#define MAC_PCU_GENERIC_TIMERS_MODE3_THRESH_MASK 0x000fffff
-#define MAC_PCU_GENERIC_TIMERS_MODE3_THRESH_GET(x) (((x) & MAC_PCU_GENERIC_TIMERS_MODE3_THRESH_MASK) >> MAC_PCU_GENERIC_TIMERS_MODE3_THRESH_LSB)
-#define MAC_PCU_GENERIC_TIMERS_MODE3_THRESH_SET(x) (((x) << MAC_PCU_GENERIC_TIMERS_MODE3_THRESH_LSB) & MAC_PCU_GENERIC_TIMERS_MODE3_THRESH_MASK)
-
-#define MAC_PCU_DIRECT_CONNECT_ADDRESS           0x000002d8
-#define MAC_PCU_DIRECT_CONNECT_OFFSET            0x000002d8
-#define MAC_PCU_DIRECT_CONNECT_STA_TSF_1_2_SEL_MSB 2
-#define MAC_PCU_DIRECT_CONNECT_STA_TSF_1_2_SEL_LSB 2
-#define MAC_PCU_DIRECT_CONNECT_STA_TSF_1_2_SEL_MASK 0x00000004
-#define MAC_PCU_DIRECT_CONNECT_STA_TSF_1_2_SEL_GET(x) (((x) & MAC_PCU_DIRECT_CONNECT_STA_TSF_1_2_SEL_MASK) >> MAC_PCU_DIRECT_CONNECT_STA_TSF_1_2_SEL_LSB)
-#define MAC_PCU_DIRECT_CONNECT_STA_TSF_1_2_SEL_SET(x) (((x) << MAC_PCU_DIRECT_CONNECT_STA_TSF_1_2_SEL_LSB) & MAC_PCU_DIRECT_CONNECT_STA_TSF_1_2_SEL_MASK)
-#define MAC_PCU_DIRECT_CONNECT_AP_TSF_1_2_SEL_MSB 1
-#define MAC_PCU_DIRECT_CONNECT_AP_TSF_1_2_SEL_LSB 1
-#define MAC_PCU_DIRECT_CONNECT_AP_TSF_1_2_SEL_MASK 0x00000002
-#define MAC_PCU_DIRECT_CONNECT_AP_TSF_1_2_SEL_GET(x) (((x) & MAC_PCU_DIRECT_CONNECT_AP_TSF_1_2_SEL_MASK) >> MAC_PCU_DIRECT_CONNECT_AP_TSF_1_2_SEL_LSB)
-#define MAC_PCU_DIRECT_CONNECT_AP_TSF_1_2_SEL_SET(x) (((x) << MAC_PCU_DIRECT_CONNECT_AP_TSF_1_2_SEL_LSB) & MAC_PCU_DIRECT_CONNECT_AP_TSF_1_2_SEL_MASK)
-#define MAC_PCU_DIRECT_CONNECT_AP_STA_ENABLE_MSB 0
-#define MAC_PCU_DIRECT_CONNECT_AP_STA_ENABLE_LSB 0
-#define MAC_PCU_DIRECT_CONNECT_AP_STA_ENABLE_MASK 0x00000001
-#define MAC_PCU_DIRECT_CONNECT_AP_STA_ENABLE_GET(x) (((x) & MAC_PCU_DIRECT_CONNECT_AP_STA_ENABLE_MASK) >> MAC_PCU_DIRECT_CONNECT_AP_STA_ENABLE_LSB)
-#define MAC_PCU_DIRECT_CONNECT_AP_STA_ENABLE_SET(x) (((x) << MAC_PCU_DIRECT_CONNECT_AP_STA_ENABLE_LSB) & MAC_PCU_DIRECT_CONNECT_AP_STA_ENABLE_MASK)
-
-#define THERM_CTRL1_ADDRESS                      0x000002dc
-#define THERM_CTRL1_OFFSET                       0x000002dc
-#define THERM_CTRL1_BYPASS_MSB                   16
-#define THERM_CTRL1_BYPASS_LSB                   16
-#define THERM_CTRL1_BYPASS_MASK                  0x00010000
-#define THERM_CTRL1_BYPASS_GET(x)                (((x) & THERM_CTRL1_BYPASS_MASK) >> THERM_CTRL1_BYPASS_LSB)
-#define THERM_CTRL1_BYPASS_SET(x)                (((x) << THERM_CTRL1_BYPASS_LSB) & THERM_CTRL1_BYPASS_MASK)
-#define THERM_CTRL1_WIDTH_ARBITOR_MSB            15
-#define THERM_CTRL1_WIDTH_ARBITOR_LSB            12
-#define THERM_CTRL1_WIDTH_ARBITOR_MASK           0x0000f000
-#define THERM_CTRL1_WIDTH_ARBITOR_GET(x)         (((x) & THERM_CTRL1_WIDTH_ARBITOR_MASK) >> THERM_CTRL1_WIDTH_ARBITOR_LSB)
-#define THERM_CTRL1_WIDTH_ARBITOR_SET(x)         (((x) << THERM_CTRL1_WIDTH_ARBITOR_LSB) & THERM_CTRL1_WIDTH_ARBITOR_MASK)
-#define THERM_CTRL1_WIDTH_MSB                    11
-#define THERM_CTRL1_WIDTH_LSB                    5
-#define THERM_CTRL1_WIDTH_MASK                   0x00000fe0
-#define THERM_CTRL1_WIDTH_GET(x)                 (((x) & THERM_CTRL1_WIDTH_MASK) >> THERM_CTRL1_WIDTH_LSB)
-#define THERM_CTRL1_WIDTH_SET(x)                 (((x) << THERM_CTRL1_WIDTH_LSB) & THERM_CTRL1_WIDTH_MASK)
-#define THERM_CTRL1_TYPE_MSB                     4
-#define THERM_CTRL1_TYPE_LSB                     3
-#define THERM_CTRL1_TYPE_MASK                    0x00000018
-#define THERM_CTRL1_TYPE_GET(x)                  (((x) & THERM_CTRL1_TYPE_MASK) >> THERM_CTRL1_TYPE_LSB)
-#define THERM_CTRL1_TYPE_SET(x)                  (((x) << THERM_CTRL1_TYPE_LSB) & THERM_CTRL1_TYPE_MASK)
-#define THERM_CTRL1_MEASURE_MSB                  2
-#define THERM_CTRL1_MEASURE_LSB                  2
-#define THERM_CTRL1_MEASURE_MASK                 0x00000004
-#define THERM_CTRL1_MEASURE_GET(x)               (((x) & THERM_CTRL1_MEASURE_MASK) >> THERM_CTRL1_MEASURE_LSB)
-#define THERM_CTRL1_MEASURE_SET(x)               (((x) << THERM_CTRL1_MEASURE_LSB) & THERM_CTRL1_MEASURE_MASK)
-#define THERM_CTRL1_INT_EN_MSB                   1
-#define THERM_CTRL1_INT_EN_LSB                   1
-#define THERM_CTRL1_INT_EN_MASK                  0x00000002
-#define THERM_CTRL1_INT_EN_GET(x)                (((x) & THERM_CTRL1_INT_EN_MASK) >> THERM_CTRL1_INT_EN_LSB)
-#define THERM_CTRL1_INT_EN_SET(x)                (((x) << THERM_CTRL1_INT_EN_LSB) & THERM_CTRL1_INT_EN_MASK)
-#define THERM_CTRL1_INT_STATUS_MSB               0
-#define THERM_CTRL1_INT_STATUS_LSB               0
-#define THERM_CTRL1_INT_STATUS_MASK              0x00000001
-#define THERM_CTRL1_INT_STATUS_GET(x)            (((x) & THERM_CTRL1_INT_STATUS_MASK) >> THERM_CTRL1_INT_STATUS_LSB)
-#define THERM_CTRL1_INT_STATUS_SET(x)            (((x) << THERM_CTRL1_INT_STATUS_LSB) & THERM_CTRL1_INT_STATUS_MASK)
-
-#define THERM_CTRL2_ADDRESS                      0x000002e0
-#define THERM_CTRL2_OFFSET                       0x000002e0
-#define THERM_CTRL2_ADC_OFF_MSB                  25
-#define THERM_CTRL2_ADC_OFF_LSB                  25
-#define THERM_CTRL2_ADC_OFF_MASK                 0x02000000
-#define THERM_CTRL2_ADC_OFF_GET(x)               (((x) & THERM_CTRL2_ADC_OFF_MASK) >> THERM_CTRL2_ADC_OFF_LSB)
-#define THERM_CTRL2_ADC_OFF_SET(x)               (((x) << THERM_CTRL2_ADC_OFF_LSB) & THERM_CTRL2_ADC_OFF_MASK)
-#define THERM_CTRL2_ADC_ON_MSB                   24
-#define THERM_CTRL2_ADC_ON_LSB                   24
-#define THERM_CTRL2_ADC_ON_MASK                  0x01000000
-#define THERM_CTRL2_ADC_ON_GET(x)                (((x) & THERM_CTRL2_ADC_ON_MASK) >> THERM_CTRL2_ADC_ON_LSB)
-#define THERM_CTRL2_ADC_ON_SET(x)                (((x) << THERM_CTRL2_ADC_ON_LSB) & THERM_CTRL2_ADC_ON_MASK)
-#define THERM_CTRL2_SAMPLE_MSB                   23
-#define THERM_CTRL2_SAMPLE_LSB                   16
-#define THERM_CTRL2_SAMPLE_MASK                  0x00ff0000
-#define THERM_CTRL2_SAMPLE_GET(x)                (((x) & THERM_CTRL2_SAMPLE_MASK) >> THERM_CTRL2_SAMPLE_LSB)
-#define THERM_CTRL2_SAMPLE_SET(x)                (((x) << THERM_CTRL2_SAMPLE_LSB) & THERM_CTRL2_SAMPLE_MASK)
-#define THERM_CTRL2_HIGH_MSB                     15
-#define THERM_CTRL2_HIGH_LSB                     8
-#define THERM_CTRL2_HIGH_MASK                    0x0000ff00
-#define THERM_CTRL2_HIGH_GET(x)                  (((x) & THERM_CTRL2_HIGH_MASK) >> THERM_CTRL2_HIGH_LSB)
-#define THERM_CTRL2_HIGH_SET(x)                  (((x) << THERM_CTRL2_HIGH_LSB) & THERM_CTRL2_HIGH_MASK)
-#define THERM_CTRL2_LOW_MSB                      7
-#define THERM_CTRL2_LOW_LSB                      0
-#define THERM_CTRL2_LOW_MASK                     0x000000ff
-#define THERM_CTRL2_LOW_GET(x)                   (((x) & THERM_CTRL2_LOW_MASK) >> THERM_CTRL2_LOW_LSB)
-#define THERM_CTRL2_LOW_SET(x)                   (((x) << THERM_CTRL2_LOW_LSB) & THERM_CTRL2_LOW_MASK)
-
-#define THERM_CTRL3_ADDRESS                      0x000002e4
-#define THERM_CTRL3_OFFSET                       0x000002e4
-#define THERM_CTRL3_ADC_GAIN_MSB                 16
-#define THERM_CTRL3_ADC_GAIN_LSB                 8
-#define THERM_CTRL3_ADC_GAIN_MASK                0x0001ff00
-#define THERM_CTRL3_ADC_GAIN_GET(x)              (((x) & THERM_CTRL3_ADC_GAIN_MASK) >> THERM_CTRL3_ADC_GAIN_LSB)
-#define THERM_CTRL3_ADC_GAIN_SET(x)              (((x) << THERM_CTRL3_ADC_GAIN_LSB) & THERM_CTRL3_ADC_GAIN_MASK)
-#define THERM_CTRL3_ADC_OFFSET_MSB               7
-#define THERM_CTRL3_ADC_OFFSET_LSB               0
-#define THERM_CTRL3_ADC_OFFSET_MASK              0x000000ff
-#define THERM_CTRL3_ADC_OFFSET_GET(x)            (((x) & THERM_CTRL3_ADC_OFFSET_MASK) >> THERM_CTRL3_ADC_OFFSET_LSB)
-#define THERM_CTRL3_ADC_OFFSET_SET(x)            (((x) << THERM_CTRL3_ADC_OFFSET_LSB) & THERM_CTRL3_ADC_OFFSET_MASK)
-
-
-#ifndef __ASSEMBLER__
-
-typedef struct rtc_wlan_reg_reg_s {
-  volatile unsigned int wlan_reset_control;
-  volatile unsigned int wlan_xtal_control;
-  volatile unsigned int wlan_tcxo_detect;
-  volatile unsigned int wlan_xtal_test;
-  volatile unsigned int wlan_quadrature;
-  volatile unsigned int wlan_pll_control;
-  volatile unsigned int wlan_pll_settle;
-  volatile unsigned int wlan_xtal_settle;
-  volatile unsigned int wlan_cpu_clock;
-  volatile unsigned int wlan_clock_out;
-  volatile unsigned int wlan_clock_control;
-  volatile unsigned int wlan_bias_override;
-  volatile unsigned int wlan_wdt_control;
-  volatile unsigned int wlan_wdt_status;
-  volatile unsigned int wlan_wdt;
-  volatile unsigned int wlan_wdt_count;
-  volatile unsigned int wlan_wdt_reset;
-  volatile unsigned int wlan_int_status;
-  volatile unsigned int wlan_lf_timer0;
-  volatile unsigned int wlan_lf_timer_count0;
-  volatile unsigned int wlan_lf_timer_control0;
-  volatile unsigned int wlan_lf_timer_status0;
-  volatile unsigned int wlan_lf_timer1;
-  volatile unsigned int wlan_lf_timer_count1;
-  volatile unsigned int wlan_lf_timer_control1;
-  volatile unsigned int wlan_lf_timer_status1;
-  volatile unsigned int wlan_lf_timer2;
-  volatile unsigned int wlan_lf_timer_count2;
-  volatile unsigned int wlan_lf_timer_control2;
-  volatile unsigned int wlan_lf_timer_status2;
-  volatile unsigned int wlan_lf_timer3;
-  volatile unsigned int wlan_lf_timer_count3;
-  volatile unsigned int wlan_lf_timer_control3;
-  volatile unsigned int wlan_lf_timer_status3;
-  volatile unsigned int wlan_hf_timer;
-  volatile unsigned int wlan_hf_timer_count;
-  volatile unsigned int wlan_hf_lf_count;
-  volatile unsigned int wlan_hf_timer_control;
-  volatile unsigned int wlan_hf_timer_status;
-  volatile unsigned int wlan_rtc_control;
-  volatile unsigned int wlan_rtc_time;
-  volatile unsigned int wlan_rtc_date;
-  volatile unsigned int wlan_rtc_set_time;
-  volatile unsigned int wlan_rtc_set_date;
-  volatile unsigned int wlan_rtc_set_alarm;
-  volatile unsigned int wlan_rtc_config;
-  volatile unsigned int wlan_rtc_alarm_status;
-  volatile unsigned int wlan_uart_wakeup;
-  volatile unsigned int wlan_reset_cause;
-  volatile unsigned int wlan_system_sleep;
-  volatile unsigned int wlan_sdio_wrapper;
-  volatile unsigned int wlan_mac_sleep_control;
-  volatile unsigned int wlan_keep_awake;
-  volatile unsigned int wlan_lpo_cal_time;
-  volatile unsigned int wlan_lpo_init_dividend_int;
-  volatile unsigned int wlan_lpo_init_dividend_fraction;
-  volatile unsigned int wlan_lpo_cal;
-  volatile unsigned int wlan_lpo_cal_test_control;
-  volatile unsigned int wlan_lpo_cal_test_status;
-  volatile unsigned int wlan_chip_id;
-  volatile unsigned int wlan_derived_rtc_clk;
-  volatile unsigned int mac_pcu_slp32_mode;
-  volatile unsigned int mac_pcu_slp32_wake;
-  volatile unsigned int mac_pcu_slp32_inc;
-  volatile unsigned int mac_pcu_slp_mib1;
-  volatile unsigned int mac_pcu_slp_mib2;
-  volatile unsigned int mac_pcu_slp_mib3;
-  volatile unsigned int wlan_power_reg;
-  volatile unsigned int wlan_core_clk_ctrl;
-  volatile unsigned int wlan_gpio_wakeup_control;
-  volatile unsigned int ht;
-  volatile unsigned int mac_pcu_tsf_l32;
-  volatile unsigned int mac_pcu_tsf_u32;
-  volatile unsigned int mac_pcu_wbtimer;
-  unsigned char pad0[24]; /* pad to 0x140 */
-  volatile unsigned int mac_pcu_generic_timers[16];
-  volatile unsigned int mac_pcu_generic_timers_mode;
-  unsigned char pad1[60]; /* pad to 0x1c0 */
-  volatile unsigned int mac_pcu_generic_timers2[16];
-  volatile unsigned int mac_pcu_generic_timers_mode2;
-  volatile unsigned int mac_pcu_slp1;
-  volatile unsigned int mac_pcu_slp2;
-  volatile unsigned int mac_pcu_reset_tsf;
-  volatile unsigned int mac_pcu_tsf_add_pll;
-  volatile unsigned int sleep_retention;
-  volatile unsigned int btcoexctrl;
-  volatile unsigned int wbsync_priority1;
-  volatile unsigned int wbsync_priority2;
-  volatile unsigned int wbsync_priority3;
-  volatile unsigned int btcoex0;
-  volatile unsigned int btcoex1;
-  volatile unsigned int btcoex2;
-  volatile unsigned int btcoex3;
-  volatile unsigned int btcoex4;
-  volatile unsigned int btcoex5;
-  volatile unsigned int btcoex6;
-  volatile unsigned int lock;
-  volatile unsigned int nolock_priority;
-  volatile unsigned int wbsync;
-  volatile unsigned int wbsync1;
-  volatile unsigned int wbsync2;
-  volatile unsigned int wbsync3;
-  volatile unsigned int wb_timer_target;
-  volatile unsigned int wb_timer_slop;
-  volatile unsigned int btcoex_int_en;
-  volatile unsigned int btcoex_int_stat;
-  volatile unsigned int btpriority_int_en;
-  volatile unsigned int btpriority_int_stat;
-  volatile unsigned int btpriority_stomp_int_en;
-  volatile unsigned int btpriority_stomp_int_stat;
-  volatile unsigned int mac_pcu_bmiss_timeout;
-  volatile unsigned int mac_pcu_cab_awake;
-  volatile unsigned int lp_perf_counter;
-  volatile unsigned int lp_perf_light_sleep;
-  volatile unsigned int lp_perf_deep_sleep;
-  volatile unsigned int lp_perf_on;
-  volatile unsigned int st_64_bit;
-  volatile unsigned int message_wr;
-  volatile unsigned int message_wr_p;
-  volatile unsigned int message_rd;
-  volatile unsigned int message_rd_p;
-  volatile unsigned int chip_mode;
-  volatile unsigned int clk_req_fall_edge;
-  volatile unsigned int otp;
-  volatile unsigned int otp_status;
-  volatile unsigned int pmu;
-  unsigned char pad2[4]; /* pad to 0x2c0 */
-  volatile unsigned int pmu_config[2];
-  volatile unsigned int pmu_bypass;
-  volatile unsigned int mac_pcu_tsf2_l32;
-  volatile unsigned int mac_pcu_tsf2_u32;
-  volatile unsigned int mac_pcu_generic_timers_mode3;
-  volatile unsigned int mac_pcu_direct_connect;
-  volatile unsigned int therm_ctrl1;
-  volatile unsigned int therm_ctrl2;
-  volatile unsigned int therm_ctrl3;
-} rtc_wlan_reg_reg_t;
-
-#endif /* __ASSEMBLER__ */
-
 #endif /* _RTC_WLAN_REG_H_ */
diff --git a/drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/si_reg.h b/drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/si_reg.h
deleted file mode 100644 (file)
index 2cd2e3c..0000000
+++ /dev/null
@@ -1,209 +0,0 @@
-// ------------------------------------------------------------------
-// Copyright (c) 2004-2010 Atheros Corporation.  All rights reserved.
-// 
-//
-// Permission to use, copy, modify, and/or distribute this software for any
-// purpose with or without fee is hereby granted, provided that the above
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-//
-//
-// ------------------------------------------------------------------
-//===================================================================
-// Author(s): ="Atheros"
-//===================================================================
-
-
-#ifndef _SI_REG_REG_H_
-#define _SI_REG_REG_H_
-
-#define SI_CONFIG_ADDRESS                        0x00000000
-#define SI_CONFIG_OFFSET                         0x00000000
-#define SI_CONFIG_ERR_INT_MSB                    19
-#define SI_CONFIG_ERR_INT_LSB                    19
-#define SI_CONFIG_ERR_INT_MASK                   0x00080000
-#define SI_CONFIG_ERR_INT_GET(x)                 (((x) & SI_CONFIG_ERR_INT_MASK) >> SI_CONFIG_ERR_INT_LSB)
-#define SI_CONFIG_ERR_INT_SET(x)                 (((x) << SI_CONFIG_ERR_INT_LSB) & SI_CONFIG_ERR_INT_MASK)
-#define SI_CONFIG_BIDIR_OD_DATA_MSB              18
-#define SI_CONFIG_BIDIR_OD_DATA_LSB              18
-#define SI_CONFIG_BIDIR_OD_DATA_MASK             0x00040000
-#define SI_CONFIG_BIDIR_OD_DATA_GET(x)           (((x) & SI_CONFIG_BIDIR_OD_DATA_MASK) >> SI_CONFIG_BIDIR_OD_DATA_LSB)
-#define SI_CONFIG_BIDIR_OD_DATA_SET(x)           (((x) << SI_CONFIG_BIDIR_OD_DATA_LSB) & SI_CONFIG_BIDIR_OD_DATA_MASK)
-#define SI_CONFIG_I2C_MSB                        16
-#define SI_CONFIG_I2C_LSB                        16
-#define SI_CONFIG_I2C_MASK                       0x00010000
-#define SI_CONFIG_I2C_GET(x)                     (((x) & SI_CONFIG_I2C_MASK) >> SI_CONFIG_I2C_LSB)
-#define SI_CONFIG_I2C_SET(x)                     (((x) << SI_CONFIG_I2C_LSB) & SI_CONFIG_I2C_MASK)
-#define SI_CONFIG_POS_SAMPLE_MSB                 7
-#define SI_CONFIG_POS_SAMPLE_LSB                 7
-#define SI_CONFIG_POS_SAMPLE_MASK                0x00000080
-#define SI_CONFIG_POS_SAMPLE_GET(x)              (((x) & SI_CONFIG_POS_SAMPLE_MASK) >> SI_CONFIG_POS_SAMPLE_LSB)
-#define SI_CONFIG_POS_SAMPLE_SET(x)              (((x) << SI_CONFIG_POS_SAMPLE_LSB) & SI_CONFIG_POS_SAMPLE_MASK)
-#define SI_CONFIG_POS_DRIVE_MSB                  6
-#define SI_CONFIG_POS_DRIVE_LSB                  6
-#define SI_CONFIG_POS_DRIVE_MASK                 0x00000040
-#define SI_CONFIG_POS_DRIVE_GET(x)               (((x) & SI_CONFIG_POS_DRIVE_MASK) >> SI_CONFIG_POS_DRIVE_LSB)
-#define SI_CONFIG_POS_DRIVE_SET(x)               (((x) << SI_CONFIG_POS_DRIVE_LSB) & SI_CONFIG_POS_DRIVE_MASK)
-#define SI_CONFIG_INACTIVE_DATA_MSB              5
-#define SI_CONFIG_INACTIVE_DATA_LSB              5
-#define SI_CONFIG_INACTIVE_DATA_MASK             0x00000020
-#define SI_CONFIG_INACTIVE_DATA_GET(x)           (((x) & SI_CONFIG_INACTIVE_DATA_MASK) >> SI_CONFIG_INACTIVE_DATA_LSB)
-#define SI_CONFIG_INACTIVE_DATA_SET(x)           (((x) << SI_CONFIG_INACTIVE_DATA_LSB) & SI_CONFIG_INACTIVE_DATA_MASK)
-#define SI_CONFIG_INACTIVE_CLK_MSB               4
-#define SI_CONFIG_INACTIVE_CLK_LSB               4
-#define SI_CONFIG_INACTIVE_CLK_MASK              0x00000010
-#define SI_CONFIG_INACTIVE_CLK_GET(x)            (((x) & SI_CONFIG_INACTIVE_CLK_MASK) >> SI_CONFIG_INACTIVE_CLK_LSB)
-#define SI_CONFIG_INACTIVE_CLK_SET(x)            (((x) << SI_CONFIG_INACTIVE_CLK_LSB) & SI_CONFIG_INACTIVE_CLK_MASK)
-#define SI_CONFIG_DIVIDER_MSB                    3
-#define SI_CONFIG_DIVIDER_LSB                    0
-#define SI_CONFIG_DIVIDER_MASK                   0x0000000f
-#define SI_CONFIG_DIVIDER_GET(x)                 (((x) & SI_CONFIG_DIVIDER_MASK) >> SI_CONFIG_DIVIDER_LSB)
-#define SI_CONFIG_DIVIDER_SET(x)                 (((x) << SI_CONFIG_DIVIDER_LSB) & SI_CONFIG_DIVIDER_MASK)
-
-#define SI_CS_ADDRESS                            0x00000004
-#define SI_CS_OFFSET                             0x00000004
-#define SI_CS_BIT_CNT_IN_LAST_BYTE_MSB           13
-#define SI_CS_BIT_CNT_IN_LAST_BYTE_LSB           11
-#define SI_CS_BIT_CNT_IN_LAST_BYTE_MASK          0x00003800
-#define SI_CS_BIT_CNT_IN_LAST_BYTE_GET(x)        (((x) & SI_CS_BIT_CNT_IN_LAST_BYTE_MASK) >> SI_CS_BIT_CNT_IN_LAST_BYTE_LSB)
-#define SI_CS_BIT_CNT_IN_LAST_BYTE_SET(x)        (((x) << SI_CS_BIT_CNT_IN_LAST_BYTE_LSB) & SI_CS_BIT_CNT_IN_LAST_BYTE_MASK)
-#define SI_CS_DONE_ERR_MSB                       10
-#define SI_CS_DONE_ERR_LSB                       10
-#define SI_CS_DONE_ERR_MASK                      0x00000400
-#define SI_CS_DONE_ERR_GET(x)                    (((x) & SI_CS_DONE_ERR_MASK) >> SI_CS_DONE_ERR_LSB)
-#define SI_CS_DONE_ERR_SET(x)                    (((x) << SI_CS_DONE_ERR_LSB) & SI_CS_DONE_ERR_MASK)
-#define SI_CS_DONE_INT_MSB                       9
-#define SI_CS_DONE_INT_LSB                       9
-#define SI_CS_DONE_INT_MASK                      0x00000200
-#define SI_CS_DONE_INT_GET(x)                    (((x) & SI_CS_DONE_INT_MASK) >> SI_CS_DONE_INT_LSB)
-#define SI_CS_DONE_INT_SET(x)                    (((x) << SI_CS_DONE_INT_LSB) & SI_CS_DONE_INT_MASK)
-#define SI_CS_START_MSB                          8
-#define SI_CS_START_LSB                          8
-#define SI_CS_START_MASK                         0x00000100
-#define SI_CS_START_GET(x)                       (((x) & SI_CS_START_MASK) >> SI_CS_START_LSB)
-#define SI_CS_START_SET(x)                       (((x) << SI_CS_START_LSB) & SI_CS_START_MASK)
-#define SI_CS_RX_CNT_MSB                         7
-#define SI_CS_RX_CNT_LSB                         4
-#define SI_CS_RX_CNT_MASK                        0x000000f0
-#define SI_CS_RX_CNT_GET(x)                      (((x) & SI_CS_RX_CNT_MASK) >> SI_CS_RX_CNT_LSB)
-#define SI_CS_RX_CNT_SET(x)                      (((x) << SI_CS_RX_CNT_LSB) & SI_CS_RX_CNT_MASK)
-#define SI_CS_TX_CNT_MSB                         3
-#define SI_CS_TX_CNT_LSB                         0
-#define SI_CS_TX_CNT_MASK                        0x0000000f
-#define SI_CS_TX_CNT_GET(x)                      (((x) & SI_CS_TX_CNT_MASK) >> SI_CS_TX_CNT_LSB)
-#define SI_CS_TX_CNT_SET(x)                      (((x) << SI_CS_TX_CNT_LSB) & SI_CS_TX_CNT_MASK)
-
-#define SI_TX_DATA0_ADDRESS                      0x00000008
-#define SI_TX_DATA0_OFFSET                       0x00000008
-#define SI_TX_DATA0_DATA3_MSB                    31
-#define SI_TX_DATA0_DATA3_LSB                    24
-#define SI_TX_DATA0_DATA3_MASK                   0xff000000
-#define SI_TX_DATA0_DATA3_GET(x)                 (((x) & SI_TX_DATA0_DATA3_MASK) >> SI_TX_DATA0_DATA3_LSB)
-#define SI_TX_DATA0_DATA3_SET(x)                 (((x) << SI_TX_DATA0_DATA3_LSB) & SI_TX_DATA0_DATA3_MASK)
-#define SI_TX_DATA0_DATA2_MSB                    23
-#define SI_TX_DATA0_DATA2_LSB                    16
-#define SI_TX_DATA0_DATA2_MASK                   0x00ff0000
-#define SI_TX_DATA0_DATA2_GET(x)                 (((x) & SI_TX_DATA0_DATA2_MASK) >> SI_TX_DATA0_DATA2_LSB)
-#define SI_TX_DATA0_DATA2_SET(x)                 (((x) << SI_TX_DATA0_DATA2_LSB) & SI_TX_DATA0_DATA2_MASK)
-#define SI_TX_DATA0_DATA1_MSB                    15
-#define SI_TX_DATA0_DATA1_LSB                    8
-#define SI_TX_DATA0_DATA1_MASK                   0x0000ff00
-#define SI_TX_DATA0_DATA1_GET(x)                 (((x) & SI_TX_DATA0_DATA1_MASK) >> SI_TX_DATA0_DATA1_LSB)
-#define SI_TX_DATA0_DATA1_SET(x)                 (((x) << SI_TX_DATA0_DATA1_LSB) & SI_TX_DATA0_DATA1_MASK)
-#define SI_TX_DATA0_DATA0_MSB                    7
-#define SI_TX_DATA0_DATA0_LSB                    0
-#define SI_TX_DATA0_DATA0_MASK                   0x000000ff
-#define SI_TX_DATA0_DATA0_GET(x)                 (((x) & SI_TX_DATA0_DATA0_MASK) >> SI_TX_DATA0_DATA0_LSB)
-#define SI_TX_DATA0_DATA0_SET(x)                 (((x) << SI_TX_DATA0_DATA0_LSB) & SI_TX_DATA0_DATA0_MASK)
-
-#define SI_TX_DATA1_ADDRESS                      0x0000000c
-#define SI_TX_DATA1_OFFSET                       0x0000000c
-#define SI_TX_DATA1_DATA7_MSB                    31
-#define SI_TX_DATA1_DATA7_LSB                    24
-#define SI_TX_DATA1_DATA7_MASK                   0xff000000
-#define SI_TX_DATA1_DATA7_GET(x)                 (((x) & SI_TX_DATA1_DATA7_MASK) >> SI_TX_DATA1_DATA7_LSB)
-#define SI_TX_DATA1_DATA7_SET(x)                 (((x) << SI_TX_DATA1_DATA7_LSB) & SI_TX_DATA1_DATA7_MASK)
-#define SI_TX_DATA1_DATA6_MSB                    23
-#define SI_TX_DATA1_DATA6_LSB                    16
-#define SI_TX_DATA1_DATA6_MASK                   0x00ff0000
-#define SI_TX_DATA1_DATA6_GET(x)                 (((x) & SI_TX_DATA1_DATA6_MASK) >> SI_TX_DATA1_DATA6_LSB)
-#define SI_TX_DATA1_DATA6_SET(x)                 (((x) << SI_TX_DATA1_DATA6_LSB) & SI_TX_DATA1_DATA6_MASK)
-#define SI_TX_DATA1_DATA5_MSB                    15
-#define SI_TX_DATA1_DATA5_LSB                    8
-#define SI_TX_DATA1_DATA5_MASK                   0x0000ff00
-#define SI_TX_DATA1_DATA5_GET(x)                 (((x) & SI_TX_DATA1_DATA5_MASK) >> SI_TX_DATA1_DATA5_LSB)
-#define SI_TX_DATA1_DATA5_SET(x)                 (((x) << SI_TX_DATA1_DATA5_LSB) & SI_TX_DATA1_DATA5_MASK)
-#define SI_TX_DATA1_DATA4_MSB                    7
-#define SI_TX_DATA1_DATA4_LSB                    0
-#define SI_TX_DATA1_DATA4_MASK                   0x000000ff
-#define SI_TX_DATA1_DATA4_GET(x)                 (((x) & SI_TX_DATA1_DATA4_MASK) >> SI_TX_DATA1_DATA4_LSB)
-#define SI_TX_DATA1_DATA4_SET(x)                 (((x) << SI_TX_DATA1_DATA4_LSB) & SI_TX_DATA1_DATA4_MASK)
-
-#define SI_RX_DATA0_ADDRESS                      0x00000010
-#define SI_RX_DATA0_OFFSET                       0x00000010
-#define SI_RX_DATA0_DATA3_MSB                    31
-#define SI_RX_DATA0_DATA3_LSB                    24
-#define SI_RX_DATA0_DATA3_MASK                   0xff000000
-#define SI_RX_DATA0_DATA3_GET(x)                 (((x) & SI_RX_DATA0_DATA3_MASK) >> SI_RX_DATA0_DATA3_LSB)
-#define SI_RX_DATA0_DATA3_SET(x)                 (((x) << SI_RX_DATA0_DATA3_LSB) & SI_RX_DATA0_DATA3_MASK)
-#define SI_RX_DATA0_DATA2_MSB                    23
-#define SI_RX_DATA0_DATA2_LSB                    16
-#define SI_RX_DATA0_DATA2_MASK                   0x00ff0000
-#define SI_RX_DATA0_DATA2_GET(x)                 (((x) & SI_RX_DATA0_DATA2_MASK) >> SI_RX_DATA0_DATA2_LSB)
-#define SI_RX_DATA0_DATA2_SET(x)                 (((x) << SI_RX_DATA0_DATA2_LSB) & SI_RX_DATA0_DATA2_MASK)
-#define SI_RX_DATA0_DATA1_MSB                    15
-#define SI_RX_DATA0_DATA1_LSB                    8
-#define SI_RX_DATA0_DATA1_MASK                   0x0000ff00
-#define SI_RX_DATA0_DATA1_GET(x)                 (((x) & SI_RX_DATA0_DATA1_MASK) >> SI_RX_DATA0_DATA1_LSB)
-#define SI_RX_DATA0_DATA1_SET(x)                 (((x) << SI_RX_DATA0_DATA1_LSB) & SI_RX_DATA0_DATA1_MASK)
-#define SI_RX_DATA0_DATA0_MSB                    7
-#define SI_RX_DATA0_DATA0_LSB                    0
-#define SI_RX_DATA0_DATA0_MASK                   0x000000ff
-#define SI_RX_DATA0_DATA0_GET(x)                 (((x) & SI_RX_DATA0_DATA0_MASK) >> SI_RX_DATA0_DATA0_LSB)
-#define SI_RX_DATA0_DATA0_SET(x)                 (((x) << SI_RX_DATA0_DATA0_LSB) & SI_RX_DATA0_DATA0_MASK)
-
-#define SI_RX_DATA1_ADDRESS                      0x00000014
-#define SI_RX_DATA1_OFFSET                       0x00000014
-#define SI_RX_DATA1_DATA7_MSB                    31
-#define SI_RX_DATA1_DATA7_LSB                    24
-#define SI_RX_DATA1_DATA7_MASK                   0xff000000
-#define SI_RX_DATA1_DATA7_GET(x)                 (((x) & SI_RX_DATA1_DATA7_MASK) >> SI_RX_DATA1_DATA7_LSB)
-#define SI_RX_DATA1_DATA7_SET(x)                 (((x) << SI_RX_DATA1_DATA7_LSB) & SI_RX_DATA1_DATA7_MASK)
-#define SI_RX_DATA1_DATA6_MSB                    23
-#define SI_RX_DATA1_DATA6_LSB                    16
-#define SI_RX_DATA1_DATA6_MASK                   0x00ff0000
-#define SI_RX_DATA1_DATA6_GET(x)                 (((x) & SI_RX_DATA1_DATA6_MASK) >> SI_RX_DATA1_DATA6_LSB)
-#define SI_RX_DATA1_DATA6_SET(x)                 (((x) << SI_RX_DATA1_DATA6_LSB) & SI_RX_DATA1_DATA6_MASK)
-#define SI_RX_DATA1_DATA5_MSB                    15
-#define SI_RX_DATA1_DATA5_LSB                    8
-#define SI_RX_DATA1_DATA5_MASK                   0x0000ff00
-#define SI_RX_DATA1_DATA5_GET(x)                 (((x) & SI_RX_DATA1_DATA5_MASK) >> SI_RX_DATA1_DATA5_LSB)
-#define SI_RX_DATA1_DATA5_SET(x)                 (((x) << SI_RX_DATA1_DATA5_LSB) & SI_RX_DATA1_DATA5_MASK)
-#define SI_RX_DATA1_DATA4_MSB                    7
-#define SI_RX_DATA1_DATA4_LSB                    0
-#define SI_RX_DATA1_DATA4_MASK                   0x000000ff
-#define SI_RX_DATA1_DATA4_GET(x)                 (((x) & SI_RX_DATA1_DATA4_MASK) >> SI_RX_DATA1_DATA4_LSB)
-#define SI_RX_DATA1_DATA4_SET(x)                 (((x) << SI_RX_DATA1_DATA4_LSB) & SI_RX_DATA1_DATA4_MASK)
-
-
-#ifndef __ASSEMBLER__
-
-typedef struct si_reg_reg_s {
-  volatile unsigned int si_config;
-  volatile unsigned int si_cs;
-  volatile unsigned int si_tx_data0;
-  volatile unsigned int si_tx_data1;
-  volatile unsigned int si_rx_data0;
-  volatile unsigned int si_rx_data1;
-} si_reg_reg_t;
-
-#endif /* __ASSEMBLER__ */
-
-#endif /* _SI_REG_H_ */
index a8eccaf6d745842b70d972d86db113bbc4b5dd2f..302b20bc1bade997d7e6394404128e0adaf3edc3 100644 (file)
 #ifndef _UART_REG_REG_H_
 #define _UART_REG_REG_H_
 
-#define UART_DATA_ADDRESS                        0x00000000
-#define UART_DATA_OFFSET                         0x00000000
-#define UART_DATA_TX_CSR_MSB                     9
-#define UART_DATA_TX_CSR_LSB                     9
-#define UART_DATA_TX_CSR_MASK                    0x00000200
-#define UART_DATA_TX_CSR_GET(x)                  (((x) & UART_DATA_TX_CSR_MASK) >> UART_DATA_TX_CSR_LSB)
-#define UART_DATA_TX_CSR_SET(x)                  (((x) << UART_DATA_TX_CSR_LSB) & UART_DATA_TX_CSR_MASK)
-#define UART_DATA_RX_CSR_MSB                     8
-#define UART_DATA_RX_CSR_LSB                     8
-#define UART_DATA_RX_CSR_MASK                    0x00000100
-#define UART_DATA_RX_CSR_GET(x)                  (((x) & UART_DATA_RX_CSR_MASK) >> UART_DATA_RX_CSR_LSB)
-#define UART_DATA_RX_CSR_SET(x)                  (((x) << UART_DATA_RX_CSR_LSB) & UART_DATA_RX_CSR_MASK)
-#define UART_DATA_TXRX_DATA_MSB                  7
-#define UART_DATA_TXRX_DATA_LSB                  0
-#define UART_DATA_TXRX_DATA_MASK                 0x000000ff
-#define UART_DATA_TXRX_DATA_GET(x)               (((x) & UART_DATA_TXRX_DATA_MASK) >> UART_DATA_TXRX_DATA_LSB)
-#define UART_DATA_TXRX_DATA_SET(x)               (((x) << UART_DATA_TXRX_DATA_LSB) & UART_DATA_TXRX_DATA_MASK)
-
-#define UART_CONTROL_ADDRESS                     0x00000004
-#define UART_CONTROL_OFFSET                      0x00000004
-#define UART_CONTROL_RX_BUSY_MSB                 15
-#define UART_CONTROL_RX_BUSY_LSB                 15
-#define UART_CONTROL_RX_BUSY_MASK                0x00008000
-#define UART_CONTROL_RX_BUSY_GET(x)              (((x) & UART_CONTROL_RX_BUSY_MASK) >> UART_CONTROL_RX_BUSY_LSB)
-#define UART_CONTROL_RX_BUSY_SET(x)              (((x) << UART_CONTROL_RX_BUSY_LSB) & UART_CONTROL_RX_BUSY_MASK)
-#define UART_CONTROL_TX_BUSY_MSB                 14
-#define UART_CONTROL_TX_BUSY_LSB                 14
-#define UART_CONTROL_TX_BUSY_MASK                0x00004000
-#define UART_CONTROL_TX_BUSY_GET(x)              (((x) & UART_CONTROL_TX_BUSY_MASK) >> UART_CONTROL_TX_BUSY_LSB)
-#define UART_CONTROL_TX_BUSY_SET(x)              (((x) << UART_CONTROL_TX_BUSY_LSB) & UART_CONTROL_TX_BUSY_MASK)
-#define UART_CONTROL_HOST_INT_ENABLE_MSB         13
-#define UART_CONTROL_HOST_INT_ENABLE_LSB         13
-#define UART_CONTROL_HOST_INT_ENABLE_MASK        0x00002000
-#define UART_CONTROL_HOST_INT_ENABLE_GET(x)      (((x) & UART_CONTROL_HOST_INT_ENABLE_MASK) >> UART_CONTROL_HOST_INT_ENABLE_LSB)
-#define UART_CONTROL_HOST_INT_ENABLE_SET(x)      (((x) << UART_CONTROL_HOST_INT_ENABLE_LSB) & UART_CONTROL_HOST_INT_ENABLE_MASK)
-#define UART_CONTROL_HOST_INT_MSB                12
-#define UART_CONTROL_HOST_INT_LSB                12
-#define UART_CONTROL_HOST_INT_MASK               0x00001000
-#define UART_CONTROL_HOST_INT_GET(x)             (((x) & UART_CONTROL_HOST_INT_MASK) >> UART_CONTROL_HOST_INT_LSB)
-#define UART_CONTROL_HOST_INT_SET(x)             (((x) << UART_CONTROL_HOST_INT_LSB) & UART_CONTROL_HOST_INT_MASK)
-#define UART_CONTROL_TX_BREAK_MSB                11
-#define UART_CONTROL_TX_BREAK_LSB                11
-#define UART_CONTROL_TX_BREAK_MASK               0x00000800
-#define UART_CONTROL_TX_BREAK_GET(x)             (((x) & UART_CONTROL_TX_BREAK_MASK) >> UART_CONTROL_TX_BREAK_LSB)
-#define UART_CONTROL_TX_BREAK_SET(x)             (((x) << UART_CONTROL_TX_BREAK_LSB) & UART_CONTROL_TX_BREAK_MASK)
-#define UART_CONTROL_RX_BREAK_MSB                10
-#define UART_CONTROL_RX_BREAK_LSB                10
-#define UART_CONTROL_RX_BREAK_MASK               0x00000400
-#define UART_CONTROL_RX_BREAK_GET(x)             (((x) & UART_CONTROL_RX_BREAK_MASK) >> UART_CONTROL_RX_BREAK_LSB)
-#define UART_CONTROL_RX_BREAK_SET(x)             (((x) << UART_CONTROL_RX_BREAK_LSB) & UART_CONTROL_RX_BREAK_MASK)
-#define UART_CONTROL_SERIAL_TX_READY_MSB         9
-#define UART_CONTROL_SERIAL_TX_READY_LSB         9
-#define UART_CONTROL_SERIAL_TX_READY_MASK        0x00000200
-#define UART_CONTROL_SERIAL_TX_READY_GET(x)      (((x) & UART_CONTROL_SERIAL_TX_READY_MASK) >> UART_CONTROL_SERIAL_TX_READY_LSB)
-#define UART_CONTROL_SERIAL_TX_READY_SET(x)      (((x) << UART_CONTROL_SERIAL_TX_READY_LSB) & UART_CONTROL_SERIAL_TX_READY_MASK)
-#define UART_CONTROL_TX_READY_ORIDE_MSB          8
-#define UART_CONTROL_TX_READY_ORIDE_LSB          8
-#define UART_CONTROL_TX_READY_ORIDE_MASK         0x00000100
-#define UART_CONTROL_TX_READY_ORIDE_GET(x)       (((x) & UART_CONTROL_TX_READY_ORIDE_MASK) >> UART_CONTROL_TX_READY_ORIDE_LSB)
-#define UART_CONTROL_TX_READY_ORIDE_SET(x)       (((x) << UART_CONTROL_TX_READY_ORIDE_LSB) & UART_CONTROL_TX_READY_ORIDE_MASK)
-#define UART_CONTROL_RX_READY_ORIDE_MSB          7
-#define UART_CONTROL_RX_READY_ORIDE_LSB          7
-#define UART_CONTROL_RX_READY_ORIDE_MASK         0x00000080
-#define UART_CONTROL_RX_READY_ORIDE_GET(x)       (((x) & UART_CONTROL_RX_READY_ORIDE_MASK) >> UART_CONTROL_RX_READY_ORIDE_LSB)
-#define UART_CONTROL_RX_READY_ORIDE_SET(x)       (((x) << UART_CONTROL_RX_READY_ORIDE_LSB) & UART_CONTROL_RX_READY_ORIDE_MASK)
-#define UART_CONTROL_DMA_ENABLE_MSB              6
-#define UART_CONTROL_DMA_ENABLE_LSB              6
-#define UART_CONTROL_DMA_ENABLE_MASK             0x00000040
-#define UART_CONTROL_DMA_ENABLE_GET(x)           (((x) & UART_CONTROL_DMA_ENABLE_MASK) >> UART_CONTROL_DMA_ENABLE_LSB)
-#define UART_CONTROL_DMA_ENABLE_SET(x)           (((x) << UART_CONTROL_DMA_ENABLE_LSB) & UART_CONTROL_DMA_ENABLE_MASK)
-#define UART_CONTROL_FLOW_ENABLE_MSB             5
-#define UART_CONTROL_FLOW_ENABLE_LSB             5
-#define UART_CONTROL_FLOW_ENABLE_MASK            0x00000020
-#define UART_CONTROL_FLOW_ENABLE_GET(x)          (((x) & UART_CONTROL_FLOW_ENABLE_MASK) >> UART_CONTROL_FLOW_ENABLE_LSB)
-#define UART_CONTROL_FLOW_ENABLE_SET(x)          (((x) << UART_CONTROL_FLOW_ENABLE_LSB) & UART_CONTROL_FLOW_ENABLE_MASK)
-#define UART_CONTROL_FLOW_INVERT_MSB             4
-#define UART_CONTROL_FLOW_INVERT_LSB             4
-#define UART_CONTROL_FLOW_INVERT_MASK            0x00000010
-#define UART_CONTROL_FLOW_INVERT_GET(x)          (((x) & UART_CONTROL_FLOW_INVERT_MASK) >> UART_CONTROL_FLOW_INVERT_LSB)
-#define UART_CONTROL_FLOW_INVERT_SET(x)          (((x) << UART_CONTROL_FLOW_INVERT_LSB) & UART_CONTROL_FLOW_INVERT_MASK)
-#define UART_CONTROL_IFC_ENABLE_MSB              3
-#define UART_CONTROL_IFC_ENABLE_LSB              3
-#define UART_CONTROL_IFC_ENABLE_MASK             0x00000008
-#define UART_CONTROL_IFC_ENABLE_GET(x)           (((x) & UART_CONTROL_IFC_ENABLE_MASK) >> UART_CONTROL_IFC_ENABLE_LSB)
-#define UART_CONTROL_IFC_ENABLE_SET(x)           (((x) << UART_CONTROL_IFC_ENABLE_LSB) & UART_CONTROL_IFC_ENABLE_MASK)
-#define UART_CONTROL_IFC_DCE_MSB                 2
-#define UART_CONTROL_IFC_DCE_LSB                 2
-#define UART_CONTROL_IFC_DCE_MASK                0x00000004
-#define UART_CONTROL_IFC_DCE_GET(x)              (((x) & UART_CONTROL_IFC_DCE_MASK) >> UART_CONTROL_IFC_DCE_LSB)
-#define UART_CONTROL_IFC_DCE_SET(x)              (((x) << UART_CONTROL_IFC_DCE_LSB) & UART_CONTROL_IFC_DCE_MASK)
-#define UART_CONTROL_PARITY_ENABLE_MSB           1
-#define UART_CONTROL_PARITY_ENABLE_LSB           1
-#define UART_CONTROL_PARITY_ENABLE_MASK          0x00000002
-#define UART_CONTROL_PARITY_ENABLE_GET(x)        (((x) & UART_CONTROL_PARITY_ENABLE_MASK) >> UART_CONTROL_PARITY_ENABLE_LSB)
-#define UART_CONTROL_PARITY_ENABLE_SET(x)        (((x) << UART_CONTROL_PARITY_ENABLE_LSB) & UART_CONTROL_PARITY_ENABLE_MASK)
-#define UART_CONTROL_PARITY_EVEN_MSB             0
-#define UART_CONTROL_PARITY_EVEN_LSB             0
-#define UART_CONTROL_PARITY_EVEN_MASK            0x00000001
-#define UART_CONTROL_PARITY_EVEN_GET(x)          (((x) & UART_CONTROL_PARITY_EVEN_MASK) >> UART_CONTROL_PARITY_EVEN_LSB)
-#define UART_CONTROL_PARITY_EVEN_SET(x)          (((x) << UART_CONTROL_PARITY_EVEN_LSB) & UART_CONTROL_PARITY_EVEN_MASK)
-
 #define UART_CLKDIV_ADDRESS                      0x00000008
 #define UART_CLKDIV_OFFSET                       0x00000008
 #define UART_CLKDIV_CLK_SCALE_MSB                23
 #define UART_CLKDIV_CLK_STEP_GET(x)              (((x) & UART_CLKDIV_CLK_STEP_MASK) >> UART_CLKDIV_CLK_STEP_LSB)
 #define UART_CLKDIV_CLK_STEP_SET(x)              (((x) << UART_CLKDIV_CLK_STEP_LSB) & UART_CLKDIV_CLK_STEP_MASK)
 
-#define UART_INT_ADDRESS                         0x0000000c
-#define UART_INT_OFFSET                          0x0000000c
-#define UART_INT_TX_EMPTY_INT_MSB                9
-#define UART_INT_TX_EMPTY_INT_LSB                9
-#define UART_INT_TX_EMPTY_INT_MASK               0x00000200
-#define UART_INT_TX_EMPTY_INT_GET(x)             (((x) & UART_INT_TX_EMPTY_INT_MASK) >> UART_INT_TX_EMPTY_INT_LSB)
-#define UART_INT_TX_EMPTY_INT_SET(x)             (((x) << UART_INT_TX_EMPTY_INT_LSB) & UART_INT_TX_EMPTY_INT_MASK)
-#define UART_INT_RX_FULL_INT_MSB                 8
-#define UART_INT_RX_FULL_INT_LSB                 8
-#define UART_INT_RX_FULL_INT_MASK                0x00000100
-#define UART_INT_RX_FULL_INT_GET(x)              (((x) & UART_INT_RX_FULL_INT_MASK) >> UART_INT_RX_FULL_INT_LSB)
-#define UART_INT_RX_FULL_INT_SET(x)              (((x) << UART_INT_RX_FULL_INT_LSB) & UART_INT_RX_FULL_INT_MASK)
-#define UART_INT_RX_BREAK_OFF_INT_MSB            7
-#define UART_INT_RX_BREAK_OFF_INT_LSB            7
-#define UART_INT_RX_BREAK_OFF_INT_MASK           0x00000080
-#define UART_INT_RX_BREAK_OFF_INT_GET(x)         (((x) & UART_INT_RX_BREAK_OFF_INT_MASK) >> UART_INT_RX_BREAK_OFF_INT_LSB)
-#define UART_INT_RX_BREAK_OFF_INT_SET(x)         (((x) << UART_INT_RX_BREAK_OFF_INT_LSB) & UART_INT_RX_BREAK_OFF_INT_MASK)
-#define UART_INT_RX_BREAK_ON_INT_MSB             6
-#define UART_INT_RX_BREAK_ON_INT_LSB             6
-#define UART_INT_RX_BREAK_ON_INT_MASK            0x00000040
-#define UART_INT_RX_BREAK_ON_INT_GET(x)          (((x) & UART_INT_RX_BREAK_ON_INT_MASK) >> UART_INT_RX_BREAK_ON_INT_LSB)
-#define UART_INT_RX_BREAK_ON_INT_SET(x)          (((x) << UART_INT_RX_BREAK_ON_INT_LSB) & UART_INT_RX_BREAK_ON_INT_MASK)
-#define UART_INT_RX_PARITY_ERR_INT_MSB           5
-#define UART_INT_RX_PARITY_ERR_INT_LSB           5
-#define UART_INT_RX_PARITY_ERR_INT_MASK          0x00000020
-#define UART_INT_RX_PARITY_ERR_INT_GET(x)        (((x) & UART_INT_RX_PARITY_ERR_INT_MASK) >> UART_INT_RX_PARITY_ERR_INT_LSB)
-#define UART_INT_RX_PARITY_ERR_INT_SET(x)        (((x) << UART_INT_RX_PARITY_ERR_INT_LSB) & UART_INT_RX_PARITY_ERR_INT_MASK)
-#define UART_INT_TX_OFLOW_ERR_INT_MSB            4
-#define UART_INT_TX_OFLOW_ERR_INT_LSB            4
-#define UART_INT_TX_OFLOW_ERR_INT_MASK           0x00000010
-#define UART_INT_TX_OFLOW_ERR_INT_GET(x)         (((x) & UART_INT_TX_OFLOW_ERR_INT_MASK) >> UART_INT_TX_OFLOW_ERR_INT_LSB)
-#define UART_INT_TX_OFLOW_ERR_INT_SET(x)         (((x) << UART_INT_TX_OFLOW_ERR_INT_LSB) & UART_INT_TX_OFLOW_ERR_INT_MASK)
-#define UART_INT_RX_OFLOW_ERR_INT_MSB            3
-#define UART_INT_RX_OFLOW_ERR_INT_LSB            3
-#define UART_INT_RX_OFLOW_ERR_INT_MASK           0x00000008
-#define UART_INT_RX_OFLOW_ERR_INT_GET(x)         (((x) & UART_INT_RX_OFLOW_ERR_INT_MASK) >> UART_INT_RX_OFLOW_ERR_INT_LSB)
-#define UART_INT_RX_OFLOW_ERR_INT_SET(x)         (((x) << UART_INT_RX_OFLOW_ERR_INT_LSB) & UART_INT_RX_OFLOW_ERR_INT_MASK)
-#define UART_INT_RX_FRAMING_ERR_INT_MSB          2
-#define UART_INT_RX_FRAMING_ERR_INT_LSB          2
-#define UART_INT_RX_FRAMING_ERR_INT_MASK         0x00000004
-#define UART_INT_RX_FRAMING_ERR_INT_GET(x)       (((x) & UART_INT_RX_FRAMING_ERR_INT_MASK) >> UART_INT_RX_FRAMING_ERR_INT_LSB)
-#define UART_INT_RX_FRAMING_ERR_INT_SET(x)       (((x) << UART_INT_RX_FRAMING_ERR_INT_LSB) & UART_INT_RX_FRAMING_ERR_INT_MASK)
-#define UART_INT_TX_READY_INT_MSB                1
-#define UART_INT_TX_READY_INT_LSB                1
-#define UART_INT_TX_READY_INT_MASK               0x00000002
-#define UART_INT_TX_READY_INT_GET(x)             (((x) & UART_INT_TX_READY_INT_MASK) >> UART_INT_TX_READY_INT_LSB)
-#define UART_INT_TX_READY_INT_SET(x)             (((x) << UART_INT_TX_READY_INT_LSB) & UART_INT_TX_READY_INT_MASK)
-#define UART_INT_RX_VALID_INT_MSB                0
-#define UART_INT_RX_VALID_INT_LSB                0
-#define UART_INT_RX_VALID_INT_MASK               0x00000001
-#define UART_INT_RX_VALID_INT_GET(x)             (((x) & UART_INT_RX_VALID_INT_MASK) >> UART_INT_RX_VALID_INT_LSB)
-#define UART_INT_RX_VALID_INT_SET(x)             (((x) << UART_INT_RX_VALID_INT_LSB) & UART_INT_RX_VALID_INT_MASK)
-
-#define UART_INT_EN_ADDRESS                      0x00000010
-#define UART_INT_EN_OFFSET                       0x00000010
-#define UART_INT_EN_TX_EMPTY_INT_EN_MSB          9
-#define UART_INT_EN_TX_EMPTY_INT_EN_LSB          9
-#define UART_INT_EN_TX_EMPTY_INT_EN_MASK         0x00000200
-#define UART_INT_EN_TX_EMPTY_INT_EN_GET(x)       (((x) & UART_INT_EN_TX_EMPTY_INT_EN_MASK) >> UART_INT_EN_TX_EMPTY_INT_EN_LSB)
-#define UART_INT_EN_TX_EMPTY_INT_EN_SET(x)       (((x) << UART_INT_EN_TX_EMPTY_INT_EN_LSB) & UART_INT_EN_TX_EMPTY_INT_EN_MASK)
-#define UART_INT_EN_RX_FULL_INT_EN_MSB           8
-#define UART_INT_EN_RX_FULL_INT_EN_LSB           8
-#define UART_INT_EN_RX_FULL_INT_EN_MASK          0x00000100
-#define UART_INT_EN_RX_FULL_INT_EN_GET(x)        (((x) & UART_INT_EN_RX_FULL_INT_EN_MASK) >> UART_INT_EN_RX_FULL_INT_EN_LSB)
-#define UART_INT_EN_RX_FULL_INT_EN_SET(x)        (((x) << UART_INT_EN_RX_FULL_INT_EN_LSB) & UART_INT_EN_RX_FULL_INT_EN_MASK)
-#define UART_INT_EN_RX_BREAK_OFF_INT_EN_MSB      7
-#define UART_INT_EN_RX_BREAK_OFF_INT_EN_LSB      7
-#define UART_INT_EN_RX_BREAK_OFF_INT_EN_MASK     0x00000080
-#define UART_INT_EN_RX_BREAK_OFF_INT_EN_GET(x)   (((x) & UART_INT_EN_RX_BREAK_OFF_INT_EN_MASK) >> UART_INT_EN_RX_BREAK_OFF_INT_EN_LSB)
-#define UART_INT_EN_RX_BREAK_OFF_INT_EN_SET(x)   (((x) << UART_INT_EN_RX_BREAK_OFF_INT_EN_LSB) & UART_INT_EN_RX_BREAK_OFF_INT_EN_MASK)
-#define UART_INT_EN_RX_BREAK_ON_INT_EN_MSB       6
-#define UART_INT_EN_RX_BREAK_ON_INT_EN_LSB       6
-#define UART_INT_EN_RX_BREAK_ON_INT_EN_MASK      0x00000040
-#define UART_INT_EN_RX_BREAK_ON_INT_EN_GET(x)    (((x) & UART_INT_EN_RX_BREAK_ON_INT_EN_MASK) >> UART_INT_EN_RX_BREAK_ON_INT_EN_LSB)
-#define UART_INT_EN_RX_BREAK_ON_INT_EN_SET(x)    (((x) << UART_INT_EN_RX_BREAK_ON_INT_EN_LSB) & UART_INT_EN_RX_BREAK_ON_INT_EN_MASK)
-#define UART_INT_EN_RX_PARITY_ERR_INT_EN_MSB     5
-#define UART_INT_EN_RX_PARITY_ERR_INT_EN_LSB     5
-#define UART_INT_EN_RX_PARITY_ERR_INT_EN_MASK    0x00000020
-#define UART_INT_EN_RX_PARITY_ERR_INT_EN_GET(x)  (((x) & UART_INT_EN_RX_PARITY_ERR_INT_EN_MASK) >> UART_INT_EN_RX_PARITY_ERR_INT_EN_LSB)
-#define UART_INT_EN_RX_PARITY_ERR_INT_EN_SET(x)  (((x) << UART_INT_EN_RX_PARITY_ERR_INT_EN_LSB) & UART_INT_EN_RX_PARITY_ERR_INT_EN_MASK)
-#define UART_INT_EN_TX_OFLOW_ERR_INT_EN_MSB      4
-#define UART_INT_EN_TX_OFLOW_ERR_INT_EN_LSB      4
-#define UART_INT_EN_TX_OFLOW_ERR_INT_EN_MASK     0x00000010
-#define UART_INT_EN_TX_OFLOW_ERR_INT_EN_GET(x)   (((x) & UART_INT_EN_TX_OFLOW_ERR_INT_EN_MASK) >> UART_INT_EN_TX_OFLOW_ERR_INT_EN_LSB)
-#define UART_INT_EN_TX_OFLOW_ERR_INT_EN_SET(x)   (((x) << UART_INT_EN_TX_OFLOW_ERR_INT_EN_LSB) & UART_INT_EN_TX_OFLOW_ERR_INT_EN_MASK)
-#define UART_INT_EN_RX_OFLOW_ERR_INT_EN_MSB      3
-#define UART_INT_EN_RX_OFLOW_ERR_INT_EN_LSB      3
-#define UART_INT_EN_RX_OFLOW_ERR_INT_EN_MASK     0x00000008
-#define UART_INT_EN_RX_OFLOW_ERR_INT_EN_GET(x)   (((x) & UART_INT_EN_RX_OFLOW_ERR_INT_EN_MASK) >> UART_INT_EN_RX_OFLOW_ERR_INT_EN_LSB)
-#define UART_INT_EN_RX_OFLOW_ERR_INT_EN_SET(x)   (((x) << UART_INT_EN_RX_OFLOW_ERR_INT_EN_LSB) & UART_INT_EN_RX_OFLOW_ERR_INT_EN_MASK)
-#define UART_INT_EN_RX_FRAMING_ERR_INT_EN_MSB    2
-#define UART_INT_EN_RX_FRAMING_ERR_INT_EN_LSB    2
-#define UART_INT_EN_RX_FRAMING_ERR_INT_EN_MASK   0x00000004
-#define UART_INT_EN_RX_FRAMING_ERR_INT_EN_GET(x) (((x) & UART_INT_EN_RX_FRAMING_ERR_INT_EN_MASK) >> UART_INT_EN_RX_FRAMING_ERR_INT_EN_LSB)
-#define UART_INT_EN_RX_FRAMING_ERR_INT_EN_SET(x) (((x) << UART_INT_EN_RX_FRAMING_ERR_INT_EN_LSB) & UART_INT_EN_RX_FRAMING_ERR_INT_EN_MASK)
-#define UART_INT_EN_TX_READY_INT_EN_MSB          1
-#define UART_INT_EN_TX_READY_INT_EN_LSB          1
-#define UART_INT_EN_TX_READY_INT_EN_MASK         0x00000002
-#define UART_INT_EN_TX_READY_INT_EN_GET(x)       (((x) & UART_INT_EN_TX_READY_INT_EN_MASK) >> UART_INT_EN_TX_READY_INT_EN_LSB)
-#define UART_INT_EN_TX_READY_INT_EN_SET(x)       (((x) << UART_INT_EN_TX_READY_INT_EN_LSB) & UART_INT_EN_TX_READY_INT_EN_MASK)
-#define UART_INT_EN_RX_VALID_INT_EN_MSB          0
-#define UART_INT_EN_RX_VALID_INT_EN_LSB          0
-#define UART_INT_EN_RX_VALID_INT_EN_MASK         0x00000001
-#define UART_INT_EN_RX_VALID_INT_EN_GET(x)       (((x) & UART_INT_EN_RX_VALID_INT_EN_MASK) >> UART_INT_EN_RX_VALID_INT_EN_LSB)
-#define UART_INT_EN_RX_VALID_INT_EN_SET(x)       (((x) << UART_INT_EN_RX_VALID_INT_EN_LSB) & UART_INT_EN_RX_VALID_INT_EN_MASK)
-
-
-#ifndef __ASSEMBLER__
-
-typedef struct uart_reg_reg_s {
-  volatile unsigned int uart_data;
-  volatile unsigned int uart_control;
-  volatile unsigned int uart_clkdiv;
-  volatile unsigned int uart_int;
-  volatile unsigned int uart_int_en;
-} uart_reg_reg_t;
-
-#endif /* __ASSEMBLER__ */
-
 #endif /* _UART_REG_H_ */
diff --git a/drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/umbox_reg.h b/drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/umbox_reg.h
deleted file mode 100644 (file)
index b233cbc..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-// ------------------------------------------------------------------
-// Copyright (c) 2004-2010 Atheros Corporation.  All rights reserved.
-// 
-//
-// Permission to use, copy, modify, and/or distribute this software for any
-// purpose with or without fee is hereby granted, provided that the above
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-//
-//
-// ------------------------------------------------------------------
-//===================================================================
-// Author(s): ="Atheros"
-//===================================================================
-
-
-#ifdef WLAN_HEADERS
-
-#include "umbox_wlan_reg.h"
-
-
-#ifndef BT_HEADERS
-
-
-
-#endif
-#endif
-
-
-
diff --git a/drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/umbox_wlan_reg.h b/drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/umbox_wlan_reg.h
deleted file mode 100644 (file)
index 4737a28..0000000
+++ /dev/null
@@ -1,322 +0,0 @@
-// ------------------------------------------------------------------
-// Copyright (c) 2004-2010 Atheros Corporation.  All rights reserved.
-// 
-//
-// Permission to use, copy, modify, and/or distribute this software for any
-// purpose with or without fee is hereby granted, provided that the above
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-//
-//
-// ------------------------------------------------------------------
-//===================================================================
-// Author(s): ="Atheros"
-//===================================================================
-
-
-#ifndef _UMBOX_WLAN_REG_REG_H_
-#define _UMBOX_WLAN_REG_REG_H_
-
-#define UMBOX_FIFO_ADDRESS                       0x00000000
-#define UMBOX_FIFO_OFFSET                        0x00000000
-#define UMBOX_FIFO_DATA_MSB                      8
-#define UMBOX_FIFO_DATA_LSB                      0
-#define UMBOX_FIFO_DATA_MASK                     0x000001ff
-#define UMBOX_FIFO_DATA_GET(x)                   (((x) & UMBOX_FIFO_DATA_MASK) >> UMBOX_FIFO_DATA_LSB)
-#define UMBOX_FIFO_DATA_SET(x)                   (((x) << UMBOX_FIFO_DATA_LSB) & UMBOX_FIFO_DATA_MASK)
-
-#define UMBOX_FIFO_STATUS_ADDRESS                0x00000008
-#define UMBOX_FIFO_STATUS_OFFSET                 0x00000008
-#define UMBOX_FIFO_STATUS_TX_EMPTY_MSB           3
-#define UMBOX_FIFO_STATUS_TX_EMPTY_LSB           3
-#define UMBOX_FIFO_STATUS_TX_EMPTY_MASK          0x00000008
-#define UMBOX_FIFO_STATUS_TX_EMPTY_GET(x)        (((x) & UMBOX_FIFO_STATUS_TX_EMPTY_MASK) >> UMBOX_FIFO_STATUS_TX_EMPTY_LSB)
-#define UMBOX_FIFO_STATUS_TX_EMPTY_SET(x)        (((x) << UMBOX_FIFO_STATUS_TX_EMPTY_LSB) & UMBOX_FIFO_STATUS_TX_EMPTY_MASK)
-#define UMBOX_FIFO_STATUS_TX_FULL_MSB            2
-#define UMBOX_FIFO_STATUS_TX_FULL_LSB            2
-#define UMBOX_FIFO_STATUS_TX_FULL_MASK           0x00000004
-#define UMBOX_FIFO_STATUS_TX_FULL_GET(x)         (((x) & UMBOX_FIFO_STATUS_TX_FULL_MASK) >> UMBOX_FIFO_STATUS_TX_FULL_LSB)
-#define UMBOX_FIFO_STATUS_TX_FULL_SET(x)         (((x) << UMBOX_FIFO_STATUS_TX_FULL_LSB) & UMBOX_FIFO_STATUS_TX_FULL_MASK)
-#define UMBOX_FIFO_STATUS_RX_EMPTY_MSB           1
-#define UMBOX_FIFO_STATUS_RX_EMPTY_LSB           1
-#define UMBOX_FIFO_STATUS_RX_EMPTY_MASK          0x00000002
-#define UMBOX_FIFO_STATUS_RX_EMPTY_GET(x)        (((x) & UMBOX_FIFO_STATUS_RX_EMPTY_MASK) >> UMBOX_FIFO_STATUS_RX_EMPTY_LSB)
-#define UMBOX_FIFO_STATUS_RX_EMPTY_SET(x)        (((x) << UMBOX_FIFO_STATUS_RX_EMPTY_LSB) & UMBOX_FIFO_STATUS_RX_EMPTY_MASK)
-#define UMBOX_FIFO_STATUS_RX_FULL_MSB            0
-#define UMBOX_FIFO_STATUS_RX_FULL_LSB            0
-#define UMBOX_FIFO_STATUS_RX_FULL_MASK           0x00000001
-#define UMBOX_FIFO_STATUS_RX_FULL_GET(x)         (((x) & UMBOX_FIFO_STATUS_RX_FULL_MASK) >> UMBOX_FIFO_STATUS_RX_FULL_LSB)
-#define UMBOX_FIFO_STATUS_RX_FULL_SET(x)         (((x) << UMBOX_FIFO_STATUS_RX_FULL_LSB) & UMBOX_FIFO_STATUS_RX_FULL_MASK)
-
-#define UMBOX_DMA_POLICY_ADDRESS                 0x0000000c
-#define UMBOX_DMA_POLICY_OFFSET                  0x0000000c
-#define UMBOX_DMA_POLICY_TX_QUANTUM_MSB          3
-#define UMBOX_DMA_POLICY_TX_QUANTUM_LSB          3
-#define UMBOX_DMA_POLICY_TX_QUANTUM_MASK         0x00000008
-#define UMBOX_DMA_POLICY_TX_QUANTUM_GET(x)       (((x) & UMBOX_DMA_POLICY_TX_QUANTUM_MASK) >> UMBOX_DMA_POLICY_TX_QUANTUM_LSB)
-#define UMBOX_DMA_POLICY_TX_QUANTUM_SET(x)       (((x) << UMBOX_DMA_POLICY_TX_QUANTUM_LSB) & UMBOX_DMA_POLICY_TX_QUANTUM_MASK)
-#define UMBOX_DMA_POLICY_TX_ORDER_MSB            2
-#define UMBOX_DMA_POLICY_TX_ORDER_LSB            2
-#define UMBOX_DMA_POLICY_TX_ORDER_MASK           0x00000004
-#define UMBOX_DMA_POLICY_TX_ORDER_GET(x)         (((x) & UMBOX_DMA_POLICY_TX_ORDER_MASK) >> UMBOX_DMA_POLICY_TX_ORDER_LSB)
-#define UMBOX_DMA_POLICY_TX_ORDER_SET(x)         (((x) << UMBOX_DMA_POLICY_TX_ORDER_LSB) & UMBOX_DMA_POLICY_TX_ORDER_MASK)
-#define UMBOX_DMA_POLICY_RX_QUANTUM_MSB          1
-#define UMBOX_DMA_POLICY_RX_QUANTUM_LSB          1
-#define UMBOX_DMA_POLICY_RX_QUANTUM_MASK         0x00000002
-#define UMBOX_DMA_POLICY_RX_QUANTUM_GET(x)       (((x) & UMBOX_DMA_POLICY_RX_QUANTUM_MASK) >> UMBOX_DMA_POLICY_RX_QUANTUM_LSB)
-#define UMBOX_DMA_POLICY_RX_QUANTUM_SET(x)       (((x) << UMBOX_DMA_POLICY_RX_QUANTUM_LSB) & UMBOX_DMA_POLICY_RX_QUANTUM_MASK)
-#define UMBOX_DMA_POLICY_RX_ORDER_MSB            0
-#define UMBOX_DMA_POLICY_RX_ORDER_LSB            0
-#define UMBOX_DMA_POLICY_RX_ORDER_MASK           0x00000001
-#define UMBOX_DMA_POLICY_RX_ORDER_GET(x)         (((x) & UMBOX_DMA_POLICY_RX_ORDER_MASK) >> UMBOX_DMA_POLICY_RX_ORDER_LSB)
-#define UMBOX_DMA_POLICY_RX_ORDER_SET(x)         (((x) << UMBOX_DMA_POLICY_RX_ORDER_LSB) & UMBOX_DMA_POLICY_RX_ORDER_MASK)
-
-#define UMBOX0_DMA_RX_DESCRIPTOR_BASE_ADDRESS    0x00000010
-#define UMBOX0_DMA_RX_DESCRIPTOR_BASE_OFFSET     0x00000010
-#define UMBOX0_DMA_RX_DESCRIPTOR_BASE_ADDRESS_MSB 27
-#define UMBOX0_DMA_RX_DESCRIPTOR_BASE_ADDRESS_LSB 2
-#define UMBOX0_DMA_RX_DESCRIPTOR_BASE_ADDRESS_MASK 0x0ffffffc
-#define UMBOX0_DMA_RX_DESCRIPTOR_BASE_ADDRESS_GET(x) (((x) & UMBOX0_DMA_RX_DESCRIPTOR_BASE_ADDRESS_MASK) >> UMBOX0_DMA_RX_DESCRIPTOR_BASE_ADDRESS_LSB)
-#define UMBOX0_DMA_RX_DESCRIPTOR_BASE_ADDRESS_SET(x) (((x) << UMBOX0_DMA_RX_DESCRIPTOR_BASE_ADDRESS_LSB) & UMBOX0_DMA_RX_DESCRIPTOR_BASE_ADDRESS_MASK)
-
-#define UMBOX0_DMA_RX_CONTROL_ADDRESS            0x00000014
-#define UMBOX0_DMA_RX_CONTROL_OFFSET             0x00000014
-#define UMBOX0_DMA_RX_CONTROL_RESUME_MSB         2
-#define UMBOX0_DMA_RX_CONTROL_RESUME_LSB         2
-#define UMBOX0_DMA_RX_CONTROL_RESUME_MASK        0x00000004
-#define UMBOX0_DMA_RX_CONTROL_RESUME_GET(x)      (((x) & UMBOX0_DMA_RX_CONTROL_RESUME_MASK) >> UMBOX0_DMA_RX_CONTROL_RESUME_LSB)
-#define UMBOX0_DMA_RX_CONTROL_RESUME_SET(x)      (((x) << UMBOX0_DMA_RX_CONTROL_RESUME_LSB) & UMBOX0_DMA_RX_CONTROL_RESUME_MASK)
-#define UMBOX0_DMA_RX_CONTROL_START_MSB          1
-#define UMBOX0_DMA_RX_CONTROL_START_LSB          1
-#define UMBOX0_DMA_RX_CONTROL_START_MASK         0x00000002
-#define UMBOX0_DMA_RX_CONTROL_START_GET(x)       (((x) & UMBOX0_DMA_RX_CONTROL_START_MASK) >> UMBOX0_DMA_RX_CONTROL_START_LSB)
-#define UMBOX0_DMA_RX_CONTROL_START_SET(x)       (((x) << UMBOX0_DMA_RX_CONTROL_START_LSB) & UMBOX0_DMA_RX_CONTROL_START_MASK)
-#define UMBOX0_DMA_RX_CONTROL_STOP_MSB           0
-#define UMBOX0_DMA_RX_CONTROL_STOP_LSB           0
-#define UMBOX0_DMA_RX_CONTROL_STOP_MASK          0x00000001
-#define UMBOX0_DMA_RX_CONTROL_STOP_GET(x)        (((x) & UMBOX0_DMA_RX_CONTROL_STOP_MASK) >> UMBOX0_DMA_RX_CONTROL_STOP_LSB)
-#define UMBOX0_DMA_RX_CONTROL_STOP_SET(x)        (((x) << UMBOX0_DMA_RX_CONTROL_STOP_LSB) & UMBOX0_DMA_RX_CONTROL_STOP_MASK)
-
-#define UMBOX0_DMA_TX_DESCRIPTOR_BASE_ADDRESS    0x00000018
-#define UMBOX0_DMA_TX_DESCRIPTOR_BASE_OFFSET     0x00000018
-#define UMBOX0_DMA_TX_DESCRIPTOR_BASE_ADDRESS_MSB 27
-#define UMBOX0_DMA_TX_DESCRIPTOR_BASE_ADDRESS_LSB 2
-#define UMBOX0_DMA_TX_DESCRIPTOR_BASE_ADDRESS_MASK 0x0ffffffc
-#define UMBOX0_DMA_TX_DESCRIPTOR_BASE_ADDRESS_GET(x) (((x) & UMBOX0_DMA_TX_DESCRIPTOR_BASE_ADDRESS_MASK) >> UMBOX0_DMA_TX_DESCRIPTOR_BASE_ADDRESS_LSB)
-#define UMBOX0_DMA_TX_DESCRIPTOR_BASE_ADDRESS_SET(x) (((x) << UMBOX0_DMA_TX_DESCRIPTOR_BASE_ADDRESS_LSB) & UMBOX0_DMA_TX_DESCRIPTOR_BASE_ADDRESS_MASK)
-
-#define UMBOX0_DMA_TX_CONTROL_ADDRESS            0x0000001c
-#define UMBOX0_DMA_TX_CONTROL_OFFSET             0x0000001c
-#define UMBOX0_DMA_TX_CONTROL_RESUME_MSB         2
-#define UMBOX0_DMA_TX_CONTROL_RESUME_LSB         2
-#define UMBOX0_DMA_TX_CONTROL_RESUME_MASK        0x00000004
-#define UMBOX0_DMA_TX_CONTROL_RESUME_GET(x)      (((x) & UMBOX0_DMA_TX_CONTROL_RESUME_MASK) >> UMBOX0_DMA_TX_CONTROL_RESUME_LSB)
-#define UMBOX0_DMA_TX_CONTROL_RESUME_SET(x)      (((x) << UMBOX0_DMA_TX_CONTROL_RESUME_LSB) & UMBOX0_DMA_TX_CONTROL_RESUME_MASK)
-#define UMBOX0_DMA_TX_CONTROL_START_MSB          1
-#define UMBOX0_DMA_TX_CONTROL_START_LSB          1
-#define UMBOX0_DMA_TX_CONTROL_START_MASK         0x00000002
-#define UMBOX0_DMA_TX_CONTROL_START_GET(x)       (((x) & UMBOX0_DMA_TX_CONTROL_START_MASK) >> UMBOX0_DMA_TX_CONTROL_START_LSB)
-#define UMBOX0_DMA_TX_CONTROL_START_SET(x)       (((x) << UMBOX0_DMA_TX_CONTROL_START_LSB) & UMBOX0_DMA_TX_CONTROL_START_MASK)
-#define UMBOX0_DMA_TX_CONTROL_STOP_MSB           0
-#define UMBOX0_DMA_TX_CONTROL_STOP_LSB           0
-#define UMBOX0_DMA_TX_CONTROL_STOP_MASK          0x00000001
-#define UMBOX0_DMA_TX_CONTROL_STOP_GET(x)        (((x) & UMBOX0_DMA_TX_CONTROL_STOP_MASK) >> UMBOX0_DMA_TX_CONTROL_STOP_LSB)
-#define UMBOX0_DMA_TX_CONTROL_STOP_SET(x)        (((x) << UMBOX0_DMA_TX_CONTROL_STOP_LSB) & UMBOX0_DMA_TX_CONTROL_STOP_MASK)
-
-#define UMBOX_FIFO_TIMEOUT_ADDRESS               0x00000020
-#define UMBOX_FIFO_TIMEOUT_OFFSET                0x00000020
-#define UMBOX_FIFO_TIMEOUT_ENABLE_SET_MSB        8
-#define UMBOX_FIFO_TIMEOUT_ENABLE_SET_LSB        8
-#define UMBOX_FIFO_TIMEOUT_ENABLE_SET_MASK       0x00000100
-#define UMBOX_FIFO_TIMEOUT_ENABLE_SET_GET(x)     (((x) & UMBOX_FIFO_TIMEOUT_ENABLE_SET_MASK) >> UMBOX_FIFO_TIMEOUT_ENABLE_SET_LSB)
-#define UMBOX_FIFO_TIMEOUT_ENABLE_SET_SET(x)     (((x) << UMBOX_FIFO_TIMEOUT_ENABLE_SET_LSB) & UMBOX_FIFO_TIMEOUT_ENABLE_SET_MASK)
-#define UMBOX_FIFO_TIMEOUT_VALUE_MSB             7
-#define UMBOX_FIFO_TIMEOUT_VALUE_LSB             0
-#define UMBOX_FIFO_TIMEOUT_VALUE_MASK            0x000000ff
-#define UMBOX_FIFO_TIMEOUT_VALUE_GET(x)          (((x) & UMBOX_FIFO_TIMEOUT_VALUE_MASK) >> UMBOX_FIFO_TIMEOUT_VALUE_LSB)
-#define UMBOX_FIFO_TIMEOUT_VALUE_SET(x)          (((x) << UMBOX_FIFO_TIMEOUT_VALUE_LSB) & UMBOX_FIFO_TIMEOUT_VALUE_MASK)
-
-#define UMBOX_INT_STATUS_ADDRESS                 0x00000024
-#define UMBOX_INT_STATUS_OFFSET                  0x00000024
-#define UMBOX_INT_STATUS_HCI_FRAMER_UNDERFLOW_MSB 9
-#define UMBOX_INT_STATUS_HCI_FRAMER_UNDERFLOW_LSB 9
-#define UMBOX_INT_STATUS_HCI_FRAMER_UNDERFLOW_MASK 0x00000200
-#define UMBOX_INT_STATUS_HCI_FRAMER_UNDERFLOW_GET(x) (((x) & UMBOX_INT_STATUS_HCI_FRAMER_UNDERFLOW_MASK) >> UMBOX_INT_STATUS_HCI_FRAMER_UNDERFLOW_LSB)
-#define UMBOX_INT_STATUS_HCI_FRAMER_UNDERFLOW_SET(x) (((x) << UMBOX_INT_STATUS_HCI_FRAMER_UNDERFLOW_LSB) & UMBOX_INT_STATUS_HCI_FRAMER_UNDERFLOW_MASK)
-#define UMBOX_INT_STATUS_HCI_FRAMER_OVERFLOW_MSB 8
-#define UMBOX_INT_STATUS_HCI_FRAMER_OVERFLOW_LSB 8
-#define UMBOX_INT_STATUS_HCI_FRAMER_OVERFLOW_MASK 0x00000100
-#define UMBOX_INT_STATUS_HCI_FRAMER_OVERFLOW_GET(x) (((x) & UMBOX_INT_STATUS_HCI_FRAMER_OVERFLOW_MASK) >> UMBOX_INT_STATUS_HCI_FRAMER_OVERFLOW_LSB)
-#define UMBOX_INT_STATUS_HCI_FRAMER_OVERFLOW_SET(x) (((x) << UMBOX_INT_STATUS_HCI_FRAMER_OVERFLOW_LSB) & UMBOX_INT_STATUS_HCI_FRAMER_OVERFLOW_MASK)
-#define UMBOX_INT_STATUS_RX_DMA_COMPLETE_MSB     7
-#define UMBOX_INT_STATUS_RX_DMA_COMPLETE_LSB     7
-#define UMBOX_INT_STATUS_RX_DMA_COMPLETE_MASK    0x00000080
-#define UMBOX_INT_STATUS_RX_DMA_COMPLETE_GET(x)  (((x) & UMBOX_INT_STATUS_RX_DMA_COMPLETE_MASK) >> UMBOX_INT_STATUS_RX_DMA_COMPLETE_LSB)
-#define UMBOX_INT_STATUS_RX_DMA_COMPLETE_SET(x)  (((x) << UMBOX_INT_STATUS_RX_DMA_COMPLETE_LSB) & UMBOX_INT_STATUS_RX_DMA_COMPLETE_MASK)
-#define UMBOX_INT_STATUS_TX_DMA_EOM_COMPLETE_MSB 6
-#define UMBOX_INT_STATUS_TX_DMA_EOM_COMPLETE_LSB 6
-#define UMBOX_INT_STATUS_TX_DMA_EOM_COMPLETE_MASK 0x00000040
-#define UMBOX_INT_STATUS_TX_DMA_EOM_COMPLETE_GET(x) (((x) & UMBOX_INT_STATUS_TX_DMA_EOM_COMPLETE_MASK) >> UMBOX_INT_STATUS_TX_DMA_EOM_COMPLETE_LSB)
-#define UMBOX_INT_STATUS_TX_DMA_EOM_COMPLETE_SET(x) (((x) << UMBOX_INT_STATUS_TX_DMA_EOM_COMPLETE_LSB) & UMBOX_INT_STATUS_TX_DMA_EOM_COMPLETE_MASK)
-#define UMBOX_INT_STATUS_TX_DMA_COMPLETE_MSB     5
-#define UMBOX_INT_STATUS_TX_DMA_COMPLETE_LSB     5
-#define UMBOX_INT_STATUS_TX_DMA_COMPLETE_MASK    0x00000020
-#define UMBOX_INT_STATUS_TX_DMA_COMPLETE_GET(x)  (((x) & UMBOX_INT_STATUS_TX_DMA_COMPLETE_MASK) >> UMBOX_INT_STATUS_TX_DMA_COMPLETE_LSB)
-#define UMBOX_INT_STATUS_TX_DMA_COMPLETE_SET(x)  (((x) << UMBOX_INT_STATUS_TX_DMA_COMPLETE_LSB) & UMBOX_INT_STATUS_TX_DMA_COMPLETE_MASK)
-#define UMBOX_INT_STATUS_HCI_SYNC_ERROR_MSB      4
-#define UMBOX_INT_STATUS_HCI_SYNC_ERROR_LSB      4
-#define UMBOX_INT_STATUS_HCI_SYNC_ERROR_MASK     0x00000010
-#define UMBOX_INT_STATUS_HCI_SYNC_ERROR_GET(x)   (((x) & UMBOX_INT_STATUS_HCI_SYNC_ERROR_MASK) >> UMBOX_INT_STATUS_HCI_SYNC_ERROR_LSB)
-#define UMBOX_INT_STATUS_HCI_SYNC_ERROR_SET(x)   (((x) << UMBOX_INT_STATUS_HCI_SYNC_ERROR_LSB) & UMBOX_INT_STATUS_HCI_SYNC_ERROR_MASK)
-#define UMBOX_INT_STATUS_TX_OVERFLOW_MSB         3
-#define UMBOX_INT_STATUS_TX_OVERFLOW_LSB         3
-#define UMBOX_INT_STATUS_TX_OVERFLOW_MASK        0x00000008
-#define UMBOX_INT_STATUS_TX_OVERFLOW_GET(x)      (((x) & UMBOX_INT_STATUS_TX_OVERFLOW_MASK) >> UMBOX_INT_STATUS_TX_OVERFLOW_LSB)
-#define UMBOX_INT_STATUS_TX_OVERFLOW_SET(x)      (((x) << UMBOX_INT_STATUS_TX_OVERFLOW_LSB) & UMBOX_INT_STATUS_TX_OVERFLOW_MASK)
-#define UMBOX_INT_STATUS_RX_UNDERFLOW_MSB        2
-#define UMBOX_INT_STATUS_RX_UNDERFLOW_LSB        2
-#define UMBOX_INT_STATUS_RX_UNDERFLOW_MASK       0x00000004
-#define UMBOX_INT_STATUS_RX_UNDERFLOW_GET(x)     (((x) & UMBOX_INT_STATUS_RX_UNDERFLOW_MASK) >> UMBOX_INT_STATUS_RX_UNDERFLOW_LSB)
-#define UMBOX_INT_STATUS_RX_UNDERFLOW_SET(x)     (((x) << UMBOX_INT_STATUS_RX_UNDERFLOW_LSB) & UMBOX_INT_STATUS_RX_UNDERFLOW_MASK)
-#define UMBOX_INT_STATUS_TX_NOT_EMPTY_MSB        1
-#define UMBOX_INT_STATUS_TX_NOT_EMPTY_LSB        1
-#define UMBOX_INT_STATUS_TX_NOT_EMPTY_MASK       0x00000002
-#define UMBOX_INT_STATUS_TX_NOT_EMPTY_GET(x)     (((x) & UMBOX_INT_STATUS_TX_NOT_EMPTY_MASK) >> UMBOX_INT_STATUS_TX_NOT_EMPTY_LSB)
-#define UMBOX_INT_STATUS_TX_NOT_EMPTY_SET(x)     (((x) << UMBOX_INT_STATUS_TX_NOT_EMPTY_LSB) & UMBOX_INT_STATUS_TX_NOT_EMPTY_MASK)
-#define UMBOX_INT_STATUS_RX_NOT_FULL_MSB         0
-#define UMBOX_INT_STATUS_RX_NOT_FULL_LSB         0
-#define UMBOX_INT_STATUS_RX_NOT_FULL_MASK        0x00000001
-#define UMBOX_INT_STATUS_RX_NOT_FULL_GET(x)      (((x) & UMBOX_INT_STATUS_RX_NOT_FULL_MASK) >> UMBOX_INT_STATUS_RX_NOT_FULL_LSB)
-#define UMBOX_INT_STATUS_RX_NOT_FULL_SET(x)      (((x) << UMBOX_INT_STATUS_RX_NOT_FULL_LSB) & UMBOX_INT_STATUS_RX_NOT_FULL_MASK)
-
-#define UMBOX_INT_ENABLE_ADDRESS                 0x00000028
-#define UMBOX_INT_ENABLE_OFFSET                  0x00000028
-#define UMBOX_INT_ENABLE_HCI_FRAMER_UNDERFLOW_MSB 9
-#define UMBOX_INT_ENABLE_HCI_FRAMER_UNDERFLOW_LSB 9
-#define UMBOX_INT_ENABLE_HCI_FRAMER_UNDERFLOW_MASK 0x00000200
-#define UMBOX_INT_ENABLE_HCI_FRAMER_UNDERFLOW_GET(x) (((x) & UMBOX_INT_ENABLE_HCI_FRAMER_UNDERFLOW_MASK) >> UMBOX_INT_ENABLE_HCI_FRAMER_UNDERFLOW_LSB)
-#define UMBOX_INT_ENABLE_HCI_FRAMER_UNDERFLOW_SET(x) (((x) << UMBOX_INT_ENABLE_HCI_FRAMER_UNDERFLOW_LSB) & UMBOX_INT_ENABLE_HCI_FRAMER_UNDERFLOW_MASK)
-#define UMBOX_INT_ENABLE_HCI_FRAMER_OVERFLOW_MSB 8
-#define UMBOX_INT_ENABLE_HCI_FRAMER_OVERFLOW_LSB 8
-#define UMBOX_INT_ENABLE_HCI_FRAMER_OVERFLOW_MASK 0x00000100
-#define UMBOX_INT_ENABLE_HCI_FRAMER_OVERFLOW_GET(x) (((x) & UMBOX_INT_ENABLE_HCI_FRAMER_OVERFLOW_MASK) >> UMBOX_INT_ENABLE_HCI_FRAMER_OVERFLOW_LSB)
-#define UMBOX_INT_ENABLE_HCI_FRAMER_OVERFLOW_SET(x) (((x) << UMBOX_INT_ENABLE_HCI_FRAMER_OVERFLOW_LSB) & UMBOX_INT_ENABLE_HCI_FRAMER_OVERFLOW_MASK)
-#define UMBOX_INT_ENABLE_RX_DMA_COMPLETE_MSB     7
-#define UMBOX_INT_ENABLE_RX_DMA_COMPLETE_LSB     7
-#define UMBOX_INT_ENABLE_RX_DMA_COMPLETE_MASK    0x00000080
-#define UMBOX_INT_ENABLE_RX_DMA_COMPLETE_GET(x)  (((x) & UMBOX_INT_ENABLE_RX_DMA_COMPLETE_MASK) >> UMBOX_INT_ENABLE_RX_DMA_COMPLETE_LSB)
-#define UMBOX_INT_ENABLE_RX_DMA_COMPLETE_SET(x)  (((x) << UMBOX_INT_ENABLE_RX_DMA_COMPLETE_LSB) & UMBOX_INT_ENABLE_RX_DMA_COMPLETE_MASK)
-#define UMBOX_INT_ENABLE_TX_DMA_EOM_COMPLETE_MSB 6
-#define UMBOX_INT_ENABLE_TX_DMA_EOM_COMPLETE_LSB 6
-#define UMBOX_INT_ENABLE_TX_DMA_EOM_COMPLETE_MASK 0x00000040
-#define UMBOX_INT_ENABLE_TX_DMA_EOM_COMPLETE_GET(x) (((x) & UMBOX_INT_ENABLE_TX_DMA_EOM_COMPLETE_MASK) >> UMBOX_INT_ENABLE_TX_DMA_EOM_COMPLETE_LSB)
-#define UMBOX_INT_ENABLE_TX_DMA_EOM_COMPLETE_SET(x) (((x) << UMBOX_INT_ENABLE_TX_DMA_EOM_COMPLETE_LSB) & UMBOX_INT_ENABLE_TX_DMA_EOM_COMPLETE_MASK)
-#define UMBOX_INT_ENABLE_TX_DMA_COMPLETE_MSB     5
-#define UMBOX_INT_ENABLE_TX_DMA_COMPLETE_LSB     5
-#define UMBOX_INT_ENABLE_TX_DMA_COMPLETE_MASK    0x00000020
-#define UMBOX_INT_ENABLE_TX_DMA_COMPLETE_GET(x)  (((x) & UMBOX_INT_ENABLE_TX_DMA_COMPLETE_MASK) >> UMBOX_INT_ENABLE_TX_DMA_COMPLETE_LSB)
-#define UMBOX_INT_ENABLE_TX_DMA_COMPLETE_SET(x)  (((x) << UMBOX_INT_ENABLE_TX_DMA_COMPLETE_LSB) & UMBOX_INT_ENABLE_TX_DMA_COMPLETE_MASK)
-#define UMBOX_INT_ENABLE_HCI_SYNC_ERROR_MSB      4
-#define UMBOX_INT_ENABLE_HCI_SYNC_ERROR_LSB      4
-#define UMBOX_INT_ENABLE_HCI_SYNC_ERROR_MASK     0x00000010
-#define UMBOX_INT_ENABLE_HCI_SYNC_ERROR_GET(x)   (((x) & UMBOX_INT_ENABLE_HCI_SYNC_ERROR_MASK) >> UMBOX_INT_ENABLE_HCI_SYNC_ERROR_LSB)
-#define UMBOX_INT_ENABLE_HCI_SYNC_ERROR_SET(x)   (((x) << UMBOX_INT_ENABLE_HCI_SYNC_ERROR_LSB) & UMBOX_INT_ENABLE_HCI_SYNC_ERROR_MASK)
-#define UMBOX_INT_ENABLE_TX_OVERFLOW_MSB         3
-#define UMBOX_INT_ENABLE_TX_OVERFLOW_LSB         3
-#define UMBOX_INT_ENABLE_TX_OVERFLOW_MASK        0x00000008
-#define UMBOX_INT_ENABLE_TX_OVERFLOW_GET(x)      (((x) & UMBOX_INT_ENABLE_TX_OVERFLOW_MASK) >> UMBOX_INT_ENABLE_TX_OVERFLOW_LSB)
-#define UMBOX_INT_ENABLE_TX_OVERFLOW_SET(x)      (((x) << UMBOX_INT_ENABLE_TX_OVERFLOW_LSB) & UMBOX_INT_ENABLE_TX_OVERFLOW_MASK)
-#define UMBOX_INT_ENABLE_RX_UNDERFLOW_MSB        2
-#define UMBOX_INT_ENABLE_RX_UNDERFLOW_LSB        2
-#define UMBOX_INT_ENABLE_RX_UNDERFLOW_MASK       0x00000004
-#define UMBOX_INT_ENABLE_RX_UNDERFLOW_GET(x)     (((x) & UMBOX_INT_ENABLE_RX_UNDERFLOW_MASK) >> UMBOX_INT_ENABLE_RX_UNDERFLOW_LSB)
-#define UMBOX_INT_ENABLE_RX_UNDERFLOW_SET(x)     (((x) << UMBOX_INT_ENABLE_RX_UNDERFLOW_LSB) & UMBOX_INT_ENABLE_RX_UNDERFLOW_MASK)
-#define UMBOX_INT_ENABLE_TX_NOT_EMPTY_MSB        1
-#define UMBOX_INT_ENABLE_TX_NOT_EMPTY_LSB        1
-#define UMBOX_INT_ENABLE_TX_NOT_EMPTY_MASK       0x00000002
-#define UMBOX_INT_ENABLE_TX_NOT_EMPTY_GET(x)     (((x) & UMBOX_INT_ENABLE_TX_NOT_EMPTY_MASK) >> UMBOX_INT_ENABLE_TX_NOT_EMPTY_LSB)
-#define UMBOX_INT_ENABLE_TX_NOT_EMPTY_SET(x)     (((x) << UMBOX_INT_ENABLE_TX_NOT_EMPTY_LSB) & UMBOX_INT_ENABLE_TX_NOT_EMPTY_MASK)
-#define UMBOX_INT_ENABLE_RX_NOT_FULL_MSB         0
-#define UMBOX_INT_ENABLE_RX_NOT_FULL_LSB         0
-#define UMBOX_INT_ENABLE_RX_NOT_FULL_MASK        0x00000001
-#define UMBOX_INT_ENABLE_RX_NOT_FULL_GET(x)      (((x) & UMBOX_INT_ENABLE_RX_NOT_FULL_MASK) >> UMBOX_INT_ENABLE_RX_NOT_FULL_LSB)
-#define UMBOX_INT_ENABLE_RX_NOT_FULL_SET(x)      (((x) << UMBOX_INT_ENABLE_RX_NOT_FULL_LSB) & UMBOX_INT_ENABLE_RX_NOT_FULL_MASK)
-
-#define UMBOX_DEBUG_ADDRESS                      0x0000002c
-#define UMBOX_DEBUG_OFFSET                       0x0000002c
-#define UMBOX_DEBUG_SEL_MSB                      2
-#define UMBOX_DEBUG_SEL_LSB                      0
-#define UMBOX_DEBUG_SEL_MASK                     0x00000007
-#define UMBOX_DEBUG_SEL_GET(x)                   (((x) & UMBOX_DEBUG_SEL_MASK) >> UMBOX_DEBUG_SEL_LSB)
-#define UMBOX_DEBUG_SEL_SET(x)                   (((x) << UMBOX_DEBUG_SEL_LSB) & UMBOX_DEBUG_SEL_MASK)
-
-#define UMBOX_FIFO_RESET_ADDRESS                 0x00000030
-#define UMBOX_FIFO_RESET_OFFSET                  0x00000030
-#define UMBOX_FIFO_RESET_INIT_MSB                0
-#define UMBOX_FIFO_RESET_INIT_LSB                0
-#define UMBOX_FIFO_RESET_INIT_MASK               0x00000001
-#define UMBOX_FIFO_RESET_INIT_GET(x)             (((x) & UMBOX_FIFO_RESET_INIT_MASK) >> UMBOX_FIFO_RESET_INIT_LSB)
-#define UMBOX_FIFO_RESET_INIT_SET(x)             (((x) << UMBOX_FIFO_RESET_INIT_LSB) & UMBOX_FIFO_RESET_INIT_MASK)
-
-#define UMBOX_HCI_FRAMER_ADDRESS                 0x00000034
-#define UMBOX_HCI_FRAMER_OFFSET                  0x00000034
-#define UMBOX_HCI_FRAMER_CRC_OVERRIDE_MSB        6
-#define UMBOX_HCI_FRAMER_CRC_OVERRIDE_LSB        6
-#define UMBOX_HCI_FRAMER_CRC_OVERRIDE_MASK       0x00000040
-#define UMBOX_HCI_FRAMER_CRC_OVERRIDE_GET(x)     (((x) & UMBOX_HCI_FRAMER_CRC_OVERRIDE_MASK) >> UMBOX_HCI_FRAMER_CRC_OVERRIDE_LSB)
-#define UMBOX_HCI_FRAMER_CRC_OVERRIDE_SET(x)     (((x) << UMBOX_HCI_FRAMER_CRC_OVERRIDE_LSB) & UMBOX_HCI_FRAMER_CRC_OVERRIDE_MASK)
-#define UMBOX_HCI_FRAMER_ENABLE_MSB              5
-#define UMBOX_HCI_FRAMER_ENABLE_LSB              5
-#define UMBOX_HCI_FRAMER_ENABLE_MASK             0x00000020
-#define UMBOX_HCI_FRAMER_ENABLE_GET(x)           (((x) & UMBOX_HCI_FRAMER_ENABLE_MASK) >> UMBOX_HCI_FRAMER_ENABLE_LSB)
-#define UMBOX_HCI_FRAMER_ENABLE_SET(x)           (((x) << UMBOX_HCI_FRAMER_ENABLE_LSB) & UMBOX_HCI_FRAMER_ENABLE_MASK)
-#define UMBOX_HCI_FRAMER_SYNC_ERROR_MSB          4
-#define UMBOX_HCI_FRAMER_SYNC_ERROR_LSB          4
-#define UMBOX_HCI_FRAMER_SYNC_ERROR_MASK         0x00000010
-#define UMBOX_HCI_FRAMER_SYNC_ERROR_GET(x)       (((x) & UMBOX_HCI_FRAMER_SYNC_ERROR_MASK) >> UMBOX_HCI_FRAMER_SYNC_ERROR_LSB)
-#define UMBOX_HCI_FRAMER_SYNC_ERROR_SET(x)       (((x) << UMBOX_HCI_FRAMER_SYNC_ERROR_LSB) & UMBOX_HCI_FRAMER_SYNC_ERROR_MASK)
-#define UMBOX_HCI_FRAMER_UNDERFLOW_MSB           3
-#define UMBOX_HCI_FRAMER_UNDERFLOW_LSB           3
-#define UMBOX_HCI_FRAMER_UNDERFLOW_MASK          0x00000008
-#define UMBOX_HCI_FRAMER_UNDERFLOW_GET(x)        (((x) & UMBOX_HCI_FRAMER_UNDERFLOW_MASK) >> UMBOX_HCI_FRAMER_UNDERFLOW_LSB)
-#define UMBOX_HCI_FRAMER_UNDERFLOW_SET(x)        (((x) << UMBOX_HCI_FRAMER_UNDERFLOW_LSB) & UMBOX_HCI_FRAMER_UNDERFLOW_MASK)
-#define UMBOX_HCI_FRAMER_OVERFLOW_MSB            2
-#define UMBOX_HCI_FRAMER_OVERFLOW_LSB            2
-#define UMBOX_HCI_FRAMER_OVERFLOW_MASK           0x00000004
-#define UMBOX_HCI_FRAMER_OVERFLOW_GET(x)         (((x) & UMBOX_HCI_FRAMER_OVERFLOW_MASK) >> UMBOX_HCI_FRAMER_OVERFLOW_LSB)
-#define UMBOX_HCI_FRAMER_OVERFLOW_SET(x)         (((x) << UMBOX_HCI_FRAMER_OVERFLOW_LSB) & UMBOX_HCI_FRAMER_OVERFLOW_MASK)
-#define UMBOX_HCI_FRAMER_CONFIG_MODE_MSB         1
-#define UMBOX_HCI_FRAMER_CONFIG_MODE_LSB         0
-#define UMBOX_HCI_FRAMER_CONFIG_MODE_MASK        0x00000003
-#define UMBOX_HCI_FRAMER_CONFIG_MODE_GET(x)      (((x) & UMBOX_HCI_FRAMER_CONFIG_MODE_MASK) >> UMBOX_HCI_FRAMER_CONFIG_MODE_LSB)
-#define UMBOX_HCI_FRAMER_CONFIG_MODE_SET(x)      (((x) << UMBOX_HCI_FRAMER_CONFIG_MODE_LSB) & UMBOX_HCI_FRAMER_CONFIG_MODE_MASK)
-
-
-#ifndef __ASSEMBLER__
-
-typedef struct umbox_wlan_reg_reg_s {
-  volatile unsigned int umbox_fifo[2];
-  volatile unsigned int umbox_fifo_status;
-  volatile unsigned int umbox_dma_policy;
-  volatile unsigned int umbox0_dma_rx_descriptor_base;
-  volatile unsigned int umbox0_dma_rx_control;
-  volatile unsigned int umbox0_dma_tx_descriptor_base;
-  volatile unsigned int umbox0_dma_tx_control;
-  volatile unsigned int umbox_fifo_timeout;
-  volatile unsigned int umbox_int_status;
-  volatile unsigned int umbox_int_enable;
-  volatile unsigned int umbox_debug;
-  volatile unsigned int umbox_fifo_reset;
-  volatile unsigned int umbox_hci_framer;
-} umbox_wlan_reg_reg_t;
-
-#endif /* __ASSEMBLER__ */
-
-#endif /* _UMBOX_WLAN_REG_H_ */
diff --git a/drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/vmc_reg.h b/drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/vmc_reg.h
deleted file mode 100644 (file)
index c3d8088..0000000
+++ /dev/null
@@ -1,167 +0,0 @@
-// ------------------------------------------------------------------
-// Copyright (c) 2004-2010 Atheros Corporation.  All rights reserved.
-// 
-//
-// Permission to use, copy, modify, and/or distribute this software for any
-// purpose with or without fee is hereby granted, provided that the above
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-//
-//
-// ------------------------------------------------------------------
-//===================================================================
-// Author(s): ="Atheros"
-//===================================================================
-
-
-#ifdef WLAN_HEADERS
-
-#include "vmc_wlan_reg.h"
-
-
-#ifndef BT_HEADERS
-
-#define MC_BCAM_VALID_ADDRESS WLAN_MC_BCAM_VALID_ADDRESS
-#define MC_BCAM_VALID_OFFSET WLAN_MC_BCAM_VALID_OFFSET
-#define MC_BCAM_VALID_BIT_MSB WLAN_MC_BCAM_VALID_BIT_MSB
-#define MC_BCAM_VALID_BIT_LSB WLAN_MC_BCAM_VALID_BIT_LSB
-#define MC_BCAM_VALID_BIT_MASK WLAN_MC_BCAM_VALID_BIT_MASK
-#define MC_BCAM_VALID_BIT_GET(x) WLAN_MC_BCAM_VALID_BIT_GET(x)
-#define MC_BCAM_VALID_BIT_SET(x) WLAN_MC_BCAM_VALID_BIT_SET(x)
-#define MC_BCAM_COMPARE_ADDRESS WLAN_MC_BCAM_COMPARE_ADDRESS
-#define MC_BCAM_COMPARE_OFFSET WLAN_MC_BCAM_COMPARE_OFFSET
-#define MC_BCAM_COMPARE_KEY_MSB WLAN_MC_BCAM_COMPARE_KEY_MSB
-#define MC_BCAM_COMPARE_KEY_LSB WLAN_MC_BCAM_COMPARE_KEY_LSB
-#define MC_BCAM_COMPARE_KEY_MASK WLAN_MC_BCAM_COMPARE_KEY_MASK
-#define MC_BCAM_COMPARE_KEY_GET(x) WLAN_MC_BCAM_COMPARE_KEY_GET(x)
-#define MC_BCAM_COMPARE_KEY_SET(x) WLAN_MC_BCAM_COMPARE_KEY_SET(x)
-#define MC_BCAM_TARGET_ADDRESS WLAN_MC_BCAM_TARGET_ADDRESS
-#define MC_BCAM_TARGET_OFFSET WLAN_MC_BCAM_TARGET_OFFSET
-#define MC_BCAM_TARGET_INST_MSB WLAN_MC_BCAM_TARGET_INST_MSB
-#define MC_BCAM_TARGET_INST_LSB WLAN_MC_BCAM_TARGET_INST_LSB
-#define MC_BCAM_TARGET_INST_MASK WLAN_MC_BCAM_TARGET_INST_MASK
-#define MC_BCAM_TARGET_INST_GET(x) WLAN_MC_BCAM_TARGET_INST_GET(x)
-#define MC_BCAM_TARGET_INST_SET(x) WLAN_MC_BCAM_TARGET_INST_SET(x)
-#define APB_ADDR_ERROR_CONTROL_ADDRESS WLAN_APB_ADDR_ERROR_CONTROL_ADDRESS
-#define APB_ADDR_ERROR_CONTROL_OFFSET WLAN_APB_ADDR_ERROR_CONTROL_OFFSET
-#define APB_ADDR_ERROR_CONTROL_QUAL_ENABLE_MSB WLAN_APB_ADDR_ERROR_CONTROL_QUAL_ENABLE_MSB
-#define APB_ADDR_ERROR_CONTROL_QUAL_ENABLE_LSB WLAN_APB_ADDR_ERROR_CONTROL_QUAL_ENABLE_LSB
-#define APB_ADDR_ERROR_CONTROL_QUAL_ENABLE_MASK WLAN_APB_ADDR_ERROR_CONTROL_QUAL_ENABLE_MASK
-#define APB_ADDR_ERROR_CONTROL_QUAL_ENABLE_GET(x) WLAN_APB_ADDR_ERROR_CONTROL_QUAL_ENABLE_GET(x)
-#define APB_ADDR_ERROR_CONTROL_QUAL_ENABLE_SET(x) WLAN_APB_ADDR_ERROR_CONTROL_QUAL_ENABLE_SET(x)
-#define APB_ADDR_ERROR_CONTROL_ENABLE_MSB WLAN_APB_ADDR_ERROR_CONTROL_ENABLE_MSB
-#define APB_ADDR_ERROR_CONTROL_ENABLE_LSB WLAN_APB_ADDR_ERROR_CONTROL_ENABLE_LSB
-#define APB_ADDR_ERROR_CONTROL_ENABLE_MASK WLAN_APB_ADDR_ERROR_CONTROL_ENABLE_MASK
-#define APB_ADDR_ERROR_CONTROL_ENABLE_GET(x) WLAN_APB_ADDR_ERROR_CONTROL_ENABLE_GET(x)
-#define APB_ADDR_ERROR_CONTROL_ENABLE_SET(x) WLAN_APB_ADDR_ERROR_CONTROL_ENABLE_SET(x)
-#define APB_ADDR_ERROR_STATUS_ADDRESS WLAN_APB_ADDR_ERROR_STATUS_ADDRESS
-#define APB_ADDR_ERROR_STATUS_OFFSET WLAN_APB_ADDR_ERROR_STATUS_OFFSET
-#define APB_ADDR_ERROR_STATUS_WRITE_MSB WLAN_APB_ADDR_ERROR_STATUS_WRITE_MSB
-#define APB_ADDR_ERROR_STATUS_WRITE_LSB WLAN_APB_ADDR_ERROR_STATUS_WRITE_LSB
-#define APB_ADDR_ERROR_STATUS_WRITE_MASK WLAN_APB_ADDR_ERROR_STATUS_WRITE_MASK
-#define APB_ADDR_ERROR_STATUS_WRITE_GET(x) WLAN_APB_ADDR_ERROR_STATUS_WRITE_GET(x)
-#define APB_ADDR_ERROR_STATUS_WRITE_SET(x) WLAN_APB_ADDR_ERROR_STATUS_WRITE_SET(x)
-#define APB_ADDR_ERROR_STATUS_ADDRESS_MSB WLAN_APB_ADDR_ERROR_STATUS_ADDRESS_MSB
-#define APB_ADDR_ERROR_STATUS_ADDRESS_LSB WLAN_APB_ADDR_ERROR_STATUS_ADDRESS_LSB
-#define APB_ADDR_ERROR_STATUS_ADDRESS_MASK WLAN_APB_ADDR_ERROR_STATUS_ADDRESS_MASK
-#define APB_ADDR_ERROR_STATUS_ADDRESS_GET(x) WLAN_APB_ADDR_ERROR_STATUS_ADDRESS_GET(x)
-#define APB_ADDR_ERROR_STATUS_ADDRESS_SET(x) WLAN_APB_ADDR_ERROR_STATUS_ADDRESS_SET(x)
-#define AHB_ADDR_ERROR_CONTROL_ADDRESS WLAN_AHB_ADDR_ERROR_CONTROL_ADDRESS
-#define AHB_ADDR_ERROR_CONTROL_OFFSET WLAN_AHB_ADDR_ERROR_CONTROL_OFFSET
-#define AHB_ADDR_ERROR_CONTROL_ENABLE_MSB WLAN_AHB_ADDR_ERROR_CONTROL_ENABLE_MSB
-#define AHB_ADDR_ERROR_CONTROL_ENABLE_LSB WLAN_AHB_ADDR_ERROR_CONTROL_ENABLE_LSB
-#define AHB_ADDR_ERROR_CONTROL_ENABLE_MASK WLAN_AHB_ADDR_ERROR_CONTROL_ENABLE_MASK
-#define AHB_ADDR_ERROR_CONTROL_ENABLE_GET(x) WLAN_AHB_ADDR_ERROR_CONTROL_ENABLE_GET(x)
-#define AHB_ADDR_ERROR_CONTROL_ENABLE_SET(x) WLAN_AHB_ADDR_ERROR_CONTROL_ENABLE_SET(x)
-#define AHB_ADDR_ERROR_STATUS_ADDRESS WLAN_AHB_ADDR_ERROR_STATUS_ADDRESS
-#define AHB_ADDR_ERROR_STATUS_OFFSET WLAN_AHB_ADDR_ERROR_STATUS_OFFSET
-#define AHB_ADDR_ERROR_STATUS_MAC_MSB WLAN_AHB_ADDR_ERROR_STATUS_MAC_MSB
-#define AHB_ADDR_ERROR_STATUS_MAC_LSB WLAN_AHB_ADDR_ERROR_STATUS_MAC_LSB
-#define AHB_ADDR_ERROR_STATUS_MAC_MASK WLAN_AHB_ADDR_ERROR_STATUS_MAC_MASK
-#define AHB_ADDR_ERROR_STATUS_MAC_GET(x) WLAN_AHB_ADDR_ERROR_STATUS_MAC_GET(x)
-#define AHB_ADDR_ERROR_STATUS_MAC_SET(x) WLAN_AHB_ADDR_ERROR_STATUS_MAC_SET(x)
-#define AHB_ADDR_ERROR_STATUS_MBOX_MSB WLAN_AHB_ADDR_ERROR_STATUS_MBOX_MSB
-#define AHB_ADDR_ERROR_STATUS_MBOX_LSB WLAN_AHB_ADDR_ERROR_STATUS_MBOX_LSB
-#define AHB_ADDR_ERROR_STATUS_MBOX_MASK WLAN_AHB_ADDR_ERROR_STATUS_MBOX_MASK
-#define AHB_ADDR_ERROR_STATUS_MBOX_GET(x) WLAN_AHB_ADDR_ERROR_STATUS_MBOX_GET(x)
-#define AHB_ADDR_ERROR_STATUS_MBOX_SET(x) WLAN_AHB_ADDR_ERROR_STATUS_MBOX_SET(x)
-#define AHB_ADDR_ERROR_STATUS_ADDRESS_MSB WLAN_AHB_ADDR_ERROR_STATUS_ADDRESS_MSB
-#define AHB_ADDR_ERROR_STATUS_ADDRESS_LSB WLAN_AHB_ADDR_ERROR_STATUS_ADDRESS_LSB
-#define AHB_ADDR_ERROR_STATUS_ADDRESS_MASK WLAN_AHB_ADDR_ERROR_STATUS_ADDRESS_MASK
-#define AHB_ADDR_ERROR_STATUS_ADDRESS_GET(x) WLAN_AHB_ADDR_ERROR_STATUS_ADDRESS_GET(x)
-#define AHB_ADDR_ERROR_STATUS_ADDRESS_SET(x) WLAN_AHB_ADDR_ERROR_STATUS_ADDRESS_SET(x)
-#define BCAM_CONFLICT_ERROR_ADDRESS WLAN_BCAM_CONFLICT_ERROR_ADDRESS
-#define BCAM_CONFLICT_ERROR_OFFSET WLAN_BCAM_CONFLICT_ERROR_OFFSET
-#define BCAM_CONFLICT_ERROR_IPORT_FLAG_MSB WLAN_BCAM_CONFLICT_ERROR_IPORT_FLAG_MSB
-#define BCAM_CONFLICT_ERROR_IPORT_FLAG_LSB WLAN_BCAM_CONFLICT_ERROR_IPORT_FLAG_LSB
-#define BCAM_CONFLICT_ERROR_IPORT_FLAG_MASK WLAN_BCAM_CONFLICT_ERROR_IPORT_FLAG_MASK
-#define BCAM_CONFLICT_ERROR_IPORT_FLAG_GET(x) WLAN_BCAM_CONFLICT_ERROR_IPORT_FLAG_GET(x)
-#define BCAM_CONFLICT_ERROR_IPORT_FLAG_SET(x) WLAN_BCAM_CONFLICT_ERROR_IPORT_FLAG_SET(x)
-#define BCAM_CONFLICT_ERROR_DPORT_FLAG_MSB WLAN_BCAM_CONFLICT_ERROR_DPORT_FLAG_MSB
-#define BCAM_CONFLICT_ERROR_DPORT_FLAG_LSB WLAN_BCAM_CONFLICT_ERROR_DPORT_FLAG_LSB
-#define BCAM_CONFLICT_ERROR_DPORT_FLAG_MASK WLAN_BCAM_CONFLICT_ERROR_DPORT_FLAG_MASK
-#define BCAM_CONFLICT_ERROR_DPORT_FLAG_GET(x) WLAN_BCAM_CONFLICT_ERROR_DPORT_FLAG_GET(x)
-#define BCAM_CONFLICT_ERROR_DPORT_FLAG_SET(x) WLAN_BCAM_CONFLICT_ERROR_DPORT_FLAG_SET(x)
-#define CPU_PERF_CNT_ADDRESS WLAN_CPU_PERF_CNT_ADDRESS
-#define CPU_PERF_CNT_OFFSET WLAN_CPU_PERF_CNT_OFFSET
-#define CPU_PERF_CNT_EN_MSB WLAN_CPU_PERF_CNT_EN_MSB
-#define CPU_PERF_CNT_EN_LSB WLAN_CPU_PERF_CNT_EN_LSB
-#define CPU_PERF_CNT_EN_MASK WLAN_CPU_PERF_CNT_EN_MASK
-#define CPU_PERF_CNT_EN_GET(x) WLAN_CPU_PERF_CNT_EN_GET(x)
-#define CPU_PERF_CNT_EN_SET(x) WLAN_CPU_PERF_CNT_EN_SET(x)
-#define CPU_INST_FETCH_ADDRESS WLAN_CPU_INST_FETCH_ADDRESS
-#define CPU_INST_FETCH_OFFSET WLAN_CPU_INST_FETCH_OFFSET
-#define CPU_INST_FETCH_CNT_MSB WLAN_CPU_INST_FETCH_CNT_MSB
-#define CPU_INST_FETCH_CNT_LSB WLAN_CPU_INST_FETCH_CNT_LSB
-#define CPU_INST_FETCH_CNT_MASK WLAN_CPU_INST_FETCH_CNT_MASK
-#define CPU_INST_FETCH_CNT_GET(x) WLAN_CPU_INST_FETCH_CNT_GET(x)
-#define CPU_INST_FETCH_CNT_SET(x) WLAN_CPU_INST_FETCH_CNT_SET(x)
-#define CPU_DATA_FETCH_ADDRESS WLAN_CPU_DATA_FETCH_ADDRESS
-#define CPU_DATA_FETCH_OFFSET WLAN_CPU_DATA_FETCH_OFFSET
-#define CPU_DATA_FETCH_CNT_MSB WLAN_CPU_DATA_FETCH_CNT_MSB
-#define CPU_DATA_FETCH_CNT_LSB WLAN_CPU_DATA_FETCH_CNT_LSB
-#define CPU_DATA_FETCH_CNT_MASK WLAN_CPU_DATA_FETCH_CNT_MASK
-#define CPU_DATA_FETCH_CNT_GET(x) WLAN_CPU_DATA_FETCH_CNT_GET(x)
-#define CPU_DATA_FETCH_CNT_SET(x) WLAN_CPU_DATA_FETCH_CNT_SET(x)
-#define CPU_RAM1_CONFLICT_ADDRESS WLAN_CPU_RAM1_CONFLICT_ADDRESS
-#define CPU_RAM1_CONFLICT_OFFSET WLAN_CPU_RAM1_CONFLICT_OFFSET
-#define CPU_RAM1_CONFLICT_CNT_MSB WLAN_CPU_RAM1_CONFLICT_CNT_MSB
-#define CPU_RAM1_CONFLICT_CNT_LSB WLAN_CPU_RAM1_CONFLICT_CNT_LSB
-#define CPU_RAM1_CONFLICT_CNT_MASK WLAN_CPU_RAM1_CONFLICT_CNT_MASK
-#define CPU_RAM1_CONFLICT_CNT_GET(x) WLAN_CPU_RAM1_CONFLICT_CNT_GET(x)
-#define CPU_RAM1_CONFLICT_CNT_SET(x) WLAN_CPU_RAM1_CONFLICT_CNT_SET(x)
-#define CPU_RAM2_CONFLICT_ADDRESS WLAN_CPU_RAM2_CONFLICT_ADDRESS
-#define CPU_RAM2_CONFLICT_OFFSET WLAN_CPU_RAM2_CONFLICT_OFFSET
-#define CPU_RAM2_CONFLICT_CNT_MSB WLAN_CPU_RAM2_CONFLICT_CNT_MSB
-#define CPU_RAM2_CONFLICT_CNT_LSB WLAN_CPU_RAM2_CONFLICT_CNT_LSB
-#define CPU_RAM2_CONFLICT_CNT_MASK WLAN_CPU_RAM2_CONFLICT_CNT_MASK
-#define CPU_RAM2_CONFLICT_CNT_GET(x) WLAN_CPU_RAM2_CONFLICT_CNT_GET(x)
-#define CPU_RAM2_CONFLICT_CNT_SET(x) WLAN_CPU_RAM2_CONFLICT_CNT_SET(x)
-#define CPU_RAM3_CONFLICT_ADDRESS WLAN_CPU_RAM3_CONFLICT_ADDRESS
-#define CPU_RAM3_CONFLICT_OFFSET WLAN_CPU_RAM3_CONFLICT_OFFSET
-#define CPU_RAM3_CONFLICT_CNT_MSB WLAN_CPU_RAM3_CONFLICT_CNT_MSB
-#define CPU_RAM3_CONFLICT_CNT_LSB WLAN_CPU_RAM3_CONFLICT_CNT_LSB
-#define CPU_RAM3_CONFLICT_CNT_MASK WLAN_CPU_RAM3_CONFLICT_CNT_MASK
-#define CPU_RAM3_CONFLICT_CNT_GET(x) WLAN_CPU_RAM3_CONFLICT_CNT_GET(x)
-#define CPU_RAM3_CONFLICT_CNT_SET(x) WLAN_CPU_RAM3_CONFLICT_CNT_SET(x)
-#define CPU_RAM4_CONFLICT_ADDRESS WLAN_CPU_RAM4_CONFLICT_ADDRESS
-#define CPU_RAM4_CONFLICT_OFFSET WLAN_CPU_RAM4_CONFLICT_OFFSET
-#define CPU_RAM4_CONFLICT_CNT_MSB WLAN_CPU_RAM4_CONFLICT_CNT_MSB
-#define CPU_RAM4_CONFLICT_CNT_LSB WLAN_CPU_RAM4_CONFLICT_CNT_LSB
-#define CPU_RAM4_CONFLICT_CNT_MASK WLAN_CPU_RAM4_CONFLICT_CNT_MASK
-#define CPU_RAM4_CONFLICT_CNT_GET(x) WLAN_CPU_RAM4_CONFLICT_CNT_GET(x)
-#define CPU_RAM4_CONFLICT_CNT_SET(x) WLAN_CPU_RAM4_CONFLICT_CNT_SET(x)
-
-
-#endif
-#endif
-
-
-
diff --git a/drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/vmc_wlan_reg.h b/drivers/staging/ath6kl/include/common/AR6002/hw4.0/hw/vmc_wlan_reg.h
deleted file mode 100644 (file)
index d28de39..0000000
+++ /dev/null
@@ -1,195 +0,0 @@
-// ------------------------------------------------------------------
-// Copyright (c) 2004-2010 Atheros Corporation.  All rights reserved.
-// 
-//
-// Permission to use, copy, modify, and/or distribute this software for any
-// purpose with or without fee is hereby granted, provided that the above
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-//
-//
-// ------------------------------------------------------------------
-//===================================================================
-// Author(s): ="Atheros"
-//===================================================================
-
-
-#ifndef _VMC_WLAN_REG_REG_H_
-#define _VMC_WLAN_REG_REG_H_
-
-#define WLAN_MC_BCAM_VALID_ADDRESS               0x00000000
-#define WLAN_MC_BCAM_VALID_OFFSET                0x00000000
-#define WLAN_MC_BCAM_VALID_BIT_MSB               0
-#define WLAN_MC_BCAM_VALID_BIT_LSB               0
-#define WLAN_MC_BCAM_VALID_BIT_MASK              0x00000001
-#define WLAN_MC_BCAM_VALID_BIT_GET(x)            (((x) & WLAN_MC_BCAM_VALID_BIT_MASK) >> WLAN_MC_BCAM_VALID_BIT_LSB)
-#define WLAN_MC_BCAM_VALID_BIT_SET(x)            (((x) << WLAN_MC_BCAM_VALID_BIT_LSB) & WLAN_MC_BCAM_VALID_BIT_MASK)
-
-#define WLAN_MC_BCAM_COMPARE_ADDRESS             0x00000200
-#define WLAN_MC_BCAM_COMPARE_OFFSET              0x00000200
-#define WLAN_MC_BCAM_COMPARE_KEY_MSB             19
-#define WLAN_MC_BCAM_COMPARE_KEY_LSB             2
-#define WLAN_MC_BCAM_COMPARE_KEY_MASK            0x000ffffc
-#define WLAN_MC_BCAM_COMPARE_KEY_GET(x)          (((x) & WLAN_MC_BCAM_COMPARE_KEY_MASK) >> WLAN_MC_BCAM_COMPARE_KEY_LSB)
-#define WLAN_MC_BCAM_COMPARE_KEY_SET(x)          (((x) << WLAN_MC_BCAM_COMPARE_KEY_LSB) & WLAN_MC_BCAM_COMPARE_KEY_MASK)
-
-#define WLAN_MC_BCAM_TARGET_ADDRESS              0x00000400
-#define WLAN_MC_BCAM_TARGET_OFFSET               0x00000400
-#define WLAN_MC_BCAM_TARGET_INST_MSB             31
-#define WLAN_MC_BCAM_TARGET_INST_LSB             0
-#define WLAN_MC_BCAM_TARGET_INST_MASK            0xffffffff
-#define WLAN_MC_BCAM_TARGET_INST_GET(x)          (((x) & WLAN_MC_BCAM_TARGET_INST_MASK) >> WLAN_MC_BCAM_TARGET_INST_LSB)
-#define WLAN_MC_BCAM_TARGET_INST_SET(x)          (((x) << WLAN_MC_BCAM_TARGET_INST_LSB) & WLAN_MC_BCAM_TARGET_INST_MASK)
-
-#define WLAN_APB_ADDR_ERROR_CONTROL_ADDRESS      0x00000600
-#define WLAN_APB_ADDR_ERROR_CONTROL_OFFSET       0x00000600
-#define WLAN_APB_ADDR_ERROR_CONTROL_QUAL_ENABLE_MSB 1
-#define WLAN_APB_ADDR_ERROR_CONTROL_QUAL_ENABLE_LSB 1
-#define WLAN_APB_ADDR_ERROR_CONTROL_QUAL_ENABLE_MASK 0x00000002
-#define WLAN_APB_ADDR_ERROR_CONTROL_QUAL_ENABLE_GET(x) (((x) & WLAN_APB_ADDR_ERROR_CONTROL_QUAL_ENABLE_MASK) >> WLAN_APB_ADDR_ERROR_CONTROL_QUAL_ENABLE_LSB)
-#define WLAN_APB_ADDR_ERROR_CONTROL_QUAL_ENABLE_SET(x) (((x) << WLAN_APB_ADDR_ERROR_CONTROL_QUAL_ENABLE_LSB) & WLAN_APB_ADDR_ERROR_CONTROL_QUAL_ENABLE_MASK)
-#define WLAN_APB_ADDR_ERROR_CONTROL_ENABLE_MSB   0
-#define WLAN_APB_ADDR_ERROR_CONTROL_ENABLE_LSB   0
-#define WLAN_APB_ADDR_ERROR_CONTROL_ENABLE_MASK  0x00000001
-#define WLAN_APB_ADDR_ERROR_CONTROL_ENABLE_GET(x) (((x) & WLAN_APB_ADDR_ERROR_CONTROL_ENABLE_MASK) >> WLAN_APB_ADDR_ERROR_CONTROL_ENABLE_LSB)
-#define WLAN_APB_ADDR_ERROR_CONTROL_ENABLE_SET(x) (((x) << WLAN_APB_ADDR_ERROR_CONTROL_ENABLE_LSB) & WLAN_APB_ADDR_ERROR_CONTROL_ENABLE_MASK)
-
-#define WLAN_APB_ADDR_ERROR_STATUS_ADDRESS       0x00000604
-#define WLAN_APB_ADDR_ERROR_STATUS_OFFSET        0x00000604
-#define WLAN_APB_ADDR_ERROR_STATUS_WRITE_MSB     25
-#define WLAN_APB_ADDR_ERROR_STATUS_WRITE_LSB     25
-#define WLAN_APB_ADDR_ERROR_STATUS_WRITE_MASK    0x02000000
-#define WLAN_APB_ADDR_ERROR_STATUS_WRITE_GET(x)  (((x) & WLAN_APB_ADDR_ERROR_STATUS_WRITE_MASK) >> WLAN_APB_ADDR_ERROR_STATUS_WRITE_LSB)
-#define WLAN_APB_ADDR_ERROR_STATUS_WRITE_SET(x)  (((x) << WLAN_APB_ADDR_ERROR_STATUS_WRITE_LSB) & WLAN_APB_ADDR_ERROR_STATUS_WRITE_MASK)
-#define WLAN_APB_ADDR_ERROR_STATUS_ADDRESS_MSB   24
-#define WLAN_APB_ADDR_ERROR_STATUS_ADDRESS_LSB   0
-#define WLAN_APB_ADDR_ERROR_STATUS_ADDRESS_MASK  0x01ffffff
-#define WLAN_APB_ADDR_ERROR_STATUS_ADDRESS_GET(x) (((x) & WLAN_APB_ADDR_ERROR_STATUS_ADDRESS_MASK) >> WLAN_APB_ADDR_ERROR_STATUS_ADDRESS_LSB)
-#define WLAN_APB_ADDR_ERROR_STATUS_ADDRESS_SET(x) (((x) << WLAN_APB_ADDR_ERROR_STATUS_ADDRESS_LSB) & WLAN_APB_ADDR_ERROR_STATUS_ADDRESS_MASK)
-
-#define WLAN_AHB_ADDR_ERROR_CONTROL_ADDRESS      0x00000608
-#define WLAN_AHB_ADDR_ERROR_CONTROL_OFFSET       0x00000608
-#define WLAN_AHB_ADDR_ERROR_CONTROL_ENABLE_MSB   0
-#define WLAN_AHB_ADDR_ERROR_CONTROL_ENABLE_LSB   0
-#define WLAN_AHB_ADDR_ERROR_CONTROL_ENABLE_MASK  0x00000001
-#define WLAN_AHB_ADDR_ERROR_CONTROL_ENABLE_GET(x) (((x) & WLAN_AHB_ADDR_ERROR_CONTROL_ENABLE_MASK) >> WLAN_AHB_ADDR_ERROR_CONTROL_ENABLE_LSB)
-#define WLAN_AHB_ADDR_ERROR_CONTROL_ENABLE_SET(x) (((x) << WLAN_AHB_ADDR_ERROR_CONTROL_ENABLE_LSB) & WLAN_AHB_ADDR_ERROR_CONTROL_ENABLE_MASK)
-
-#define WLAN_AHB_ADDR_ERROR_STATUS_ADDRESS       0x0000060c
-#define WLAN_AHB_ADDR_ERROR_STATUS_OFFSET        0x0000060c
-#define WLAN_AHB_ADDR_ERROR_STATUS_MAC_MSB       31
-#define WLAN_AHB_ADDR_ERROR_STATUS_MAC_LSB       31
-#define WLAN_AHB_ADDR_ERROR_STATUS_MAC_MASK      0x80000000
-#define WLAN_AHB_ADDR_ERROR_STATUS_MAC_GET(x)    (((x) & WLAN_AHB_ADDR_ERROR_STATUS_MAC_MASK) >> WLAN_AHB_ADDR_ERROR_STATUS_MAC_LSB)
-#define WLAN_AHB_ADDR_ERROR_STATUS_MAC_SET(x)    (((x) << WLAN_AHB_ADDR_ERROR_STATUS_MAC_LSB) & WLAN_AHB_ADDR_ERROR_STATUS_MAC_MASK)
-#define WLAN_AHB_ADDR_ERROR_STATUS_MBOX_MSB      30
-#define WLAN_AHB_ADDR_ERROR_STATUS_MBOX_LSB      30
-#define WLAN_AHB_ADDR_ERROR_STATUS_MBOX_MASK     0x40000000
-#define WLAN_AHB_ADDR_ERROR_STATUS_MBOX_GET(x)   (((x) & WLAN_AHB_ADDR_ERROR_STATUS_MBOX_MASK) >> WLAN_AHB_ADDR_ERROR_STATUS_MBOX_LSB)
-#define WLAN_AHB_ADDR_ERROR_STATUS_MBOX_SET(x)   (((x) << WLAN_AHB_ADDR_ERROR_STATUS_MBOX_LSB) & WLAN_AHB_ADDR_ERROR_STATUS_MBOX_MASK)
-#define WLAN_AHB_ADDR_ERROR_STATUS_ADDRESS_MSB   23
-#define WLAN_AHB_ADDR_ERROR_STATUS_ADDRESS_LSB   0
-#define WLAN_AHB_ADDR_ERROR_STATUS_ADDRESS_MASK  0x00ffffff
-#define WLAN_AHB_ADDR_ERROR_STATUS_ADDRESS_GET(x) (((x) & WLAN_AHB_ADDR_ERROR_STATUS_ADDRESS_MASK) >> WLAN_AHB_ADDR_ERROR_STATUS_ADDRESS_LSB)
-#define WLAN_AHB_ADDR_ERROR_STATUS_ADDRESS_SET(x) (((x) << WLAN_AHB_ADDR_ERROR_STATUS_ADDRESS_LSB) & WLAN_AHB_ADDR_ERROR_STATUS_ADDRESS_MASK)
-
-#define WLAN_BCAM_CONFLICT_ERROR_ADDRESS         0x00000610
-#define WLAN_BCAM_CONFLICT_ERROR_OFFSET          0x00000610
-#define WLAN_BCAM_CONFLICT_ERROR_IPORT_FLAG_MSB  1
-#define WLAN_BCAM_CONFLICT_ERROR_IPORT_FLAG_LSB  1
-#define WLAN_BCAM_CONFLICT_ERROR_IPORT_FLAG_MASK 0x00000002
-#define WLAN_BCAM_CONFLICT_ERROR_IPORT_FLAG_GET(x) (((x) & WLAN_BCAM_CONFLICT_ERROR_IPORT_FLAG_MASK) >> WLAN_BCAM_CONFLICT_ERROR_IPORT_FLAG_LSB)
-#define WLAN_BCAM_CONFLICT_ERROR_IPORT_FLAG_SET(x) (((x) << WLAN_BCAM_CONFLICT_ERROR_IPORT_FLAG_LSB) & WLAN_BCAM_CONFLICT_ERROR_IPORT_FLAG_MASK)
-#define WLAN_BCAM_CONFLICT_ERROR_DPORT_FLAG_MSB  0
-#define WLAN_BCAM_CONFLICT_ERROR_DPORT_FLAG_LSB  0
-#define WLAN_BCAM_CONFLICT_ERROR_DPORT_FLAG_MASK 0x00000001
-#define WLAN_BCAM_CONFLICT_ERROR_DPORT_FLAG_GET(x) (((x) & WLAN_BCAM_CONFLICT_ERROR_DPORT_FLAG_MASK) >> WLAN_BCAM_CONFLICT_ERROR_DPORT_FLAG_LSB)
-#define WLAN_BCAM_CONFLICT_ERROR_DPORT_FLAG_SET(x) (((x) << WLAN_BCAM_CONFLICT_ERROR_DPORT_FLAG_LSB) & WLAN_BCAM_CONFLICT_ERROR_DPORT_FLAG_MASK)
-
-#define WLAN_CPU_PERF_CNT_ADDRESS                0x00000614
-#define WLAN_CPU_PERF_CNT_OFFSET                 0x00000614
-#define WLAN_CPU_PERF_CNT_EN_MSB                 0
-#define WLAN_CPU_PERF_CNT_EN_LSB                 0
-#define WLAN_CPU_PERF_CNT_EN_MASK                0x00000001
-#define WLAN_CPU_PERF_CNT_EN_GET(x)              (((x) & WLAN_CPU_PERF_CNT_EN_MASK) >> WLAN_CPU_PERF_CNT_EN_LSB)
-#define WLAN_CPU_PERF_CNT_EN_SET(x)              (((x) << WLAN_CPU_PERF_CNT_EN_LSB) & WLAN_CPU_PERF_CNT_EN_MASK)
-
-#define WLAN_CPU_INST_FETCH_ADDRESS              0x00000618
-#define WLAN_CPU_INST_FETCH_OFFSET               0x00000618
-#define WLAN_CPU_INST_FETCH_CNT_MSB              31
-#define WLAN_CPU_INST_FETCH_CNT_LSB              0
-#define WLAN_CPU_INST_FETCH_CNT_MASK             0xffffffff
-#define WLAN_CPU_INST_FETCH_CNT_GET(x)           (((x) & WLAN_CPU_INST_FETCH_CNT_MASK) >> WLAN_CPU_INST_FETCH_CNT_LSB)
-#define WLAN_CPU_INST_FETCH_CNT_SET(x)           (((x) << WLAN_CPU_INST_FETCH_CNT_LSB) & WLAN_CPU_INST_FETCH_CNT_MASK)
-
-#define WLAN_CPU_DATA_FETCH_ADDRESS              0x0000061c
-#define WLAN_CPU_DATA_FETCH_OFFSET               0x0000061c
-#define WLAN_CPU_DATA_FETCH_CNT_MSB              31
-#define WLAN_CPU_DATA_FETCH_CNT_LSB              0
-#define WLAN_CPU_DATA_FETCH_CNT_MASK             0xffffffff
-#define WLAN_CPU_DATA_FETCH_CNT_GET(x)           (((x) & WLAN_CPU_DATA_FETCH_CNT_MASK) >> WLAN_CPU_DATA_FETCH_CNT_LSB)
-#define WLAN_CPU_DATA_FETCH_CNT_SET(x)           (((x) << WLAN_CPU_DATA_FETCH_CNT_LSB) & WLAN_CPU_DATA_FETCH_CNT_MASK)
-
-#define WLAN_CPU_RAM1_CONFLICT_ADDRESS           0x00000620
-#define WLAN_CPU_RAM1_CONFLICT_OFFSET            0x00000620
-#define WLAN_CPU_RAM1_CONFLICT_CNT_MSB           11
-#define WLAN_CPU_RAM1_CONFLICT_CNT_LSB           0
-#define WLAN_CPU_RAM1_CONFLICT_CNT_MASK          0x00000fff
-#define WLAN_CPU_RAM1_CONFLICT_CNT_GET(x)        (((x) & WLAN_CPU_RAM1_CONFLICT_CNT_MASK) >> WLAN_CPU_RAM1_CONFLICT_CNT_LSB)
-#define WLAN_CPU_RAM1_CONFLICT_CNT_SET(x)        (((x) << WLAN_CPU_RAM1_CONFLICT_CNT_LSB) & WLAN_CPU_RAM1_CONFLICT_CNT_MASK)
-
-#define WLAN_CPU_RAM2_CONFLICT_ADDRESS           0x00000624
-#define WLAN_CPU_RAM2_CONFLICT_OFFSET            0x00000624
-#define WLAN_CPU_RAM2_CONFLICT_CNT_MSB           11
-#define WLAN_CPU_RAM2_CONFLICT_CNT_LSB           0
-#define WLAN_CPU_RAM2_CONFLICT_CNT_MASK          0x00000fff
-#define WLAN_CPU_RAM2_CONFLICT_CNT_GET(x)        (((x) & WLAN_CPU_RAM2_CONFLICT_CNT_MASK) >> WLAN_CPU_RAM2_CONFLICT_CNT_LSB)
-#define WLAN_CPU_RAM2_CONFLICT_CNT_SET(x)        (((x) << WLAN_CPU_RAM2_CONFLICT_CNT_LSB) & WLAN_CPU_RAM2_CONFLICT_CNT_MASK)
-
-#define WLAN_CPU_RAM3_CONFLICT_ADDRESS           0x00000628
-#define WLAN_CPU_RAM3_CONFLICT_OFFSET            0x00000628
-#define WLAN_CPU_RAM3_CONFLICT_CNT_MSB           11
-#define WLAN_CPU_RAM3_CONFLICT_CNT_LSB           0
-#define WLAN_CPU_RAM3_CONFLICT_CNT_MASK          0x00000fff
-#define WLAN_CPU_RAM3_CONFLICT_CNT_GET(x)        (((x) & WLAN_CPU_RAM3_CONFLICT_CNT_MASK) >> WLAN_CPU_RAM3_CONFLICT_CNT_LSB)
-#define WLAN_CPU_RAM3_CONFLICT_CNT_SET(x)        (((x) << WLAN_CPU_RAM3_CONFLICT_CNT_LSB) & WLAN_CPU_RAM3_CONFLICT_CNT_MASK)
-
-#define WLAN_CPU_RAM4_CONFLICT_ADDRESS           0x0000062c
-#define WLAN_CPU_RAM4_CONFLICT_OFFSET            0x0000062c
-#define WLAN_CPU_RAM4_CONFLICT_CNT_MSB           11
-#define WLAN_CPU_RAM4_CONFLICT_CNT_LSB           0
-#define WLAN_CPU_RAM4_CONFLICT_CNT_MASK          0x00000fff
-#define WLAN_CPU_RAM4_CONFLICT_CNT_GET(x)        (((x) & WLAN_CPU_RAM4_CONFLICT_CNT_MASK) >> WLAN_CPU_RAM4_CONFLICT_CNT_LSB)
-#define WLAN_CPU_RAM4_CONFLICT_CNT_SET(x)        (((x) << WLAN_CPU_RAM4_CONFLICT_CNT_LSB) & WLAN_CPU_RAM4_CONFLICT_CNT_MASK)
-
-
-#ifndef __ASSEMBLER__
-
-typedef struct vmc_wlan_reg_reg_s {
-  volatile unsigned int wlan_mc_bcam_valid[128];
-  volatile unsigned int wlan_mc_bcam_compare[128];
-  volatile unsigned int wlan_mc_bcam_target[128];
-  volatile unsigned int wlan_apb_addr_error_control;
-  volatile unsigned int wlan_apb_addr_error_status;
-  volatile unsigned int wlan_ahb_addr_error_control;
-  volatile unsigned int wlan_ahb_addr_error_status;
-  volatile unsigned int wlan_bcam_conflict_error;
-  volatile unsigned int wlan_cpu_perf_cnt;
-  volatile unsigned int wlan_cpu_inst_fetch;
-  volatile unsigned int wlan_cpu_data_fetch;
-  volatile unsigned int wlan_cpu_ram1_conflict;
-  volatile unsigned int wlan_cpu_ram2_conflict;
-  volatile unsigned int wlan_cpu_ram3_conflict;
-  volatile unsigned int wlan_cpu_ram4_conflict;
-} vmc_wlan_reg_reg_t;
-
-#endif /* __ASSEMBLER__ */
-
-#endif /* _VMC_WLAN_REG_H_ */
diff --git a/drivers/staging/ath6kl/include/common/a_hci.h b/drivers/staging/ath6kl/include/common/a_hci.h
deleted file mode 100644 (file)
index 379d652..0000000
+++ /dev/null
@@ -1,682 +0,0 @@
-//-
-// Copyright (c) 2009-2010 Atheros Communications Inc.
-// All rights reserved.
-// 
-//
-// Permission to use, copy, modify, and/or distribute this software for any
-// purpose with or without fee is hereby granted, provided that the above
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-//
-//
-//
-//
-
-
-#ifndef __A_HCI_H__
-#define __A_HCI_H__
-
-#define HCI_CMD_OGF_MASK            0x3F
-#define HCI_CMD_OGF_SHIFT           10
-#define HCI_CMD_GET_OGF(opcode)     ((opcode >> HCI_CMD_OGF_SHIFT) & HCI_CMD_OGF_MASK)
-
-#define HCI_CMD_OCF_MASK            0x3FF
-#define HCI_CMD_OCF_SHIFT           0 
-#define HCI_CMD_GET_OCF(opcode)     (((opcode) >> HCI_CMD_OCF_SHIFT) & HCI_CMD_OCF_MASK)
-
-#define HCI_FORM_OPCODE(ocf, ogf)    ((ocf & HCI_CMD_OCF_MASK) << HCI_CMD_OCF_SHIFT | \
-                                          (ogf & HCI_CMD_OGF_MASK) << HCI_CMD_OGF_SHIFT)
-
-
-/*======== HCI Opcode groups ===============*/
-#define OGF_NOP                         0x00
-#define OGF_LINK_CONTROL                0x01
-#define OGF_LINK_POLICY                 0x03
-#define OGF_INFO_PARAMS                 0x04
-#define OGF_STATUS                      0x05
-#define OGF_TESTING                     0x06
-#define OGF_BLUETOOTH                   0x3E
-#define OGF_VENDOR_DEBUG                0x3F
-
-
-
-#define OCF_NOP                         0x00
-
-
-/*===== Link Control Commands Opcode===================*/
-#define OCF_HCI_Create_Physical_Link                0x35
-#define OCF_HCI_Accept_Physical_Link_Req            0x36
-#define OCF_HCI_Disconnect_Physical_Link            0x37
-#define OCF_HCI_Create_Logical_Link                 0x38
-#define OCF_HCI_Accept_Logical_Link                 0x39
-#define OCF_HCI_Disconnect_Logical_Link             0x3A
-#define OCF_HCI_Logical_Link_Cancel                 0x3B
-#define OCF_HCI_Flow_Spec_Modify                    0x3C
-
-
-
-/*===== Link Policy Commands Opcode====================*/
-#define OCF_HCI_Set_Event_Mask                      0x01
-#define OCF_HCI_Reset                               0x03
-#define OCF_HCI_Read_Conn_Accept_Timeout            0x15
-#define OCF_HCI_Write_Conn_Accept_Timeout           0x16
-#define OCF_HCI_Read_Link_Supervision_Timeout       0x36
-#define OCF_HCI_Write_Link_Supervision_Timeout      0x37
-#define OCF_HCI_Enhanced_Flush                      0x5F
-#define OCF_HCI_Read_Logical_Link_Accept_Timeout    0x61
-#define OCF_HCI_Write_Logical_Link_Accept_Timeout   0x62
-#define OCF_HCI_Set_Event_Mask_Page_2               0x63
-#define OCF_HCI_Read_Location_Data                  0x64
-#define OCF_HCI_Write_Location_Data                 0x65
-#define OCF_HCI_Read_Flow_Control_Mode              0x66
-#define OCF_HCI_Write_Flow_Control_Mode             0x67
-#define OCF_HCI_Read_BE_Flush_Timeout               0x69
-#define OCF_HCI_Write_BE_Flush_Timeout              0x6A
-#define OCF_HCI_Short_Range_Mode                    0x6B
-
-
-/*======== Info Commands Opcode========================*/
-#define OCF_HCI_Read_Local_Ver_Info                 0x01
-#define OCF_HCI_Read_Local_Supported_Cmds           0x02
-#define OCF_HCI_Read_Data_Block_Size                0x0A
-/*======== Status Commands Opcode======================*/
-#define OCF_HCI_Read_Failed_Contact_Counter         0x01
-#define OCF_HCI_Reset_Failed_Contact_Counter        0x02
-#define OCF_HCI_Read_Link_Quality                   0x03
-#define OCF_HCI_Read_RSSI                           0x05
-#define OCF_HCI_Read_Local_AMP_Info                 0x09    
-#define OCF_HCI_Read_Local_AMP_ASSOC                0x0A
-#define OCF_HCI_Write_Remote_AMP_ASSOC              0x0B
-
-
-/*======= AMP_ASSOC Specific TLV tags =================*/
-#define AMP_ASSOC_MAC_ADDRESS_INFO_TYPE             0x1
-#define AMP_ASSOC_PREF_CHAN_LIST                    0x2
-#define AMP_ASSOC_CONNECTED_CHAN                    0x3
-#define AMP_ASSOC_PAL_CAPABILITIES                  0x4
-#define AMP_ASSOC_PAL_VERSION                       0x5
-
-
-/*========= PAL Events =================================*/
-#define PAL_COMMAND_COMPLETE_EVENT                  0x0E
-#define PAL_COMMAND_STATUS_EVENT                    0x0F
-#define PAL_HARDWARE_ERROR_EVENT                    0x10
-#define PAL_FLUSH_OCCURRED_EVENT                    0x11
-#define PAL_LOOPBACK_EVENT                          0x19
-#define PAL_BUFFER_OVERFLOW_EVENT                   0x1A
-#define PAL_QOS_VIOLATION_EVENT                     0x1E
-#define PAL_ENHANCED_FLUSH_COMPLT_EVENT             0x39
-#define PAL_PHYSICAL_LINK_COMPL_EVENT               0x40
-#define PAL_CHANNEL_SELECT_EVENT                    0x41
-#define PAL_DISCONNECT_PHYSICAL_LINK_EVENT          0x42
-#define PAL_PHY_LINK_EARLY_LOSS_WARNING_EVENT       0x43
-#define PAL_PHY_LINK_RECOVERY_EVENT                 0x44
-#define PAL_LOGICAL_LINK_COMPL_EVENT                0x45
-#define PAL_DISCONNECT_LOGICAL_LINK_COMPL_EVENT     0x46
-#define PAL_FLOW_SPEC_MODIFY_COMPL_EVENT            0x47
-#define PAL_NUM_COMPL_DATA_BLOCK_EVENT              0x48
-#define PAL_SHORT_RANGE_MODE_CHANGE_COMPL_EVENT     0x4C
-#define PAL_AMP_STATUS_CHANGE_EVENT                 0x4D
-/*======== End of PAL events definition =================*/
-
-
-/*======== Timeouts (not part of HCI cmd, but input to PAL engine) =========*/
-#define Timer_Conn_Accept_TO                        0x01
-#define Timer_Link_Supervision_TO                   0x02
-
-#define NUM_HCI_COMMAND_PKTS                0x1
-
-
-/*====== NOP Cmd ============================*/
-#define HCI_CMD_NOP                     HCI_FORM_OPCODE(OCF_NOP, OGF_NOP)
-
-
-/*===== Link Control Commands================*/
-#define HCI_Create_Physical_Link        HCI_FORM_OPCODE(OCF_HCI_Create_Physical_Link, OGF_LINK_CONTROL)
-#define HCI_Accept_Physical_Link_Req    HCI_FORM_OPCODE(OCF_HCI_Accept_Physical_Link_Req, OGF_LINK_CONTROL)
-#define HCI_Disconnect_Physical_Link    HCI_FORM_OPCODE(OCF_HCI_Disconnect_Physical_Link, OGF_LINK_CONTROL)
-#define HCI_Create_Logical_Link         HCI_FORM_OPCODE(OCF_HCI_Create_Logical_Link, OGF_LINK_CONTROL)
-#define HCI_Accept_Logical_Link         HCI_FORM_OPCODE(OCF_HCI_Accept_Logical_Link, OGF_LINK_CONTROL)
-#define HCI_Disconnect_Logical_Link     HCI_FORM_OPCODE(OCF_HCI_Disconnect_Logical_Link, OGF_LINK_CONTROL)
-#define HCI_Logical_Link_Cancel         HCI_FORM_OPCODE(OCF_HCI_Logical_Link_Cancel, OGF_LINK_CONTROL)
-#define HCI_Flow_Spec_Modify            HCI_FORM_OPCODE(OCF_HCI_Flow_Spec_Modify, OGF_LINK_CONTROL)
-
-
-/*===== Link Policy Commands ================*/
-#define HCI_Set_Event_Mask              HCI_FORM_OPCODE(OCF_HCI_Set_Event_Mask, OGF_LINK_POLICY)
-#define HCI_Reset                       HCI_FORM_OPCODE(OCF_HCI_Reset, OGF_LINK_POLICY)
-#define HCI_Enhanced_Flush              HCI_FORM_OPCODE(OCF_HCI_Enhanced_Flush, OGF_LINK_POLICY)
-#define HCI_Read_Conn_Accept_Timeout    HCI_FORM_OPCODE(OCF_HCI_Read_Conn_Accept_Timeout, OGF_LINK_POLICY)
-#define HCI_Write_Conn_Accept_Timeout   HCI_FORM_OPCODE(OCF_HCI_Write_Conn_Accept_Timeout, OGF_LINK_POLICY)
-#define HCI_Read_Logical_Link_Accept_Timeout    HCI_FORM_OPCODE(OCF_HCI_Read_Logical_Link_Accept_Timeout, OGF_LINK_POLICY)
-#define HCI_Write_Logical_Link_Accept_Timeout   HCI_FORM_OPCODE(OCF_HCI_Write_Logical_Link_Accept_Timeout, OGF_LINK_POLICY)
-#define HCI_Read_Link_Supervision_Timeout       HCI_FORM_OPCODE(OCF_HCI_Read_Link_Supervision_Timeout, OGF_LINK_POLICY)
-#define HCI_Write_Link_Supervision_Timeout      HCI_FORM_OPCODE(OCF_HCI_Write_Link_Supervision_Timeout, OGF_LINK_POLICY)
-#define HCI_Read_Location_Data          HCI_FORM_OPCODE(OCF_HCI_Read_Location_Data, OGF_LINK_POLICY)
-#define HCI_Write_Location_Data         HCI_FORM_OPCODE(OCF_HCI_Write_Location_Data, OGF_LINK_POLICY)
-#define HCI_Set_Event_Mask_Page_2       HCI_FORM_OPCODE(OCF_HCI_Set_Event_Mask_Page_2, OGF_LINK_POLICY)
-#define HCI_Read_Flow_Control_Mode      HCI_FORM_OPCODE(OCF_HCI_Read_Flow_Control_Mode, OGF_LINK_POLICY)
-#define HCI_Write_Flow_Control_Mode     HCI_FORM_OPCODE(OCF_HCI_Write_Flow_Control_Mode, OGF_LINK_POLICY)
-#define HCI_Write_BE_Flush_Timeout      HCI_FORM_OPCODE(OCF_HCI_Write_BE_Flush_Timeout, OGF_LINK_POLICY)
-#define HCI_Read_BE_Flush_Timeout       HCI_FORM_OPCODE(OCF_HCI_Read_BE_Flush_Timeout, OGF_LINK_POLICY)
-#define HCI_Short_Range_Mode            HCI_FORM_OPCODE(OCF_HCI_Short_Range_Mode, OGF_LINK_POLICY)            
-
-
-/*===== Info Commands =====================*/
-#define HCI_Read_Local_Ver_Info         HCI_FORM_OPCODE(OCF_HCI_Read_Local_Ver_Info,  OGF_INFO_PARAMS)
-#define HCI_Read_Local_Supported_Cmds   HCI_FORM_OPCODE(OCF_HCI_Read_Local_Supported_Cmds, OGF_INFO_PARAMS)
-#define HCI_Read_Data_Block_Size        HCI_FORM_OPCODE(OCF_HCI_Read_Data_Block_Size, OGF_INFO_PARAMS)
-
-/*===== Status Commands =====================*/
-#define HCI_Read_Link_Quality           HCI_FORM_OPCODE(OCF_HCI_Read_Link_Quality, OGF_STATUS)
-#define HCI_Read_RSSI                   HCI_FORM_OPCODE(OCF_HCI_Read_RSSI, OGF_STATUS)
-#define HCI_Read_Local_AMP_Info         HCI_FORM_OPCODE(OCF_HCI_Read_Local_AMP_Info, OGF_STATUS)
-#define HCI_Read_Local_AMP_ASSOC        HCI_FORM_OPCODE(OCF_HCI_Read_Local_AMP_ASSOC, OGF_STATUS)
-#define HCI_Write_Remote_AMP_ASSOC      HCI_FORM_OPCODE(OCF_HCI_Write_Remote_AMP_ASSOC, OGF_STATUS)
-
-/*====== End of cmd definitions =============*/
-
-
-
-/*===== Timeouts(private - can't come from HCI)=================*/
-#define Conn_Accept_TO                  HCI_FORM_OPCODE(Timer_Conn_Accept_TO, OGF_VENDOR_DEBUG)
-#define Link_Supervision_TO             HCI_FORM_OPCODE(Timer_Link_Supervision_TO, OGF_VENDOR_DEBUG)
-
-/*----- PAL Constants (Sec 6 of Doc)------------------------*/
-#define Max80211_PAL_PDU_Size      1492
-#define Max80211_AMP_ASSOC_Len      672
-#define MinGUserPrio                4
-#define MaxGUserPrio                7
-#define BEUserPrio0                 0
-#define BEUserPrio1                 3
-#define Max80211BeaconPeriod        2000    /* in millisec */
-#define ShortRangeModePowerMax      4       /* dBm */
-
-/*------ PAL Protocol Identifiers (Sec5.1) ------------------*/
-typedef enum {
-    ACL_DATA = 0x01,
-    ACTIVITY_REPORT,
-    SECURED_FRAMES,
-    LINK_SUPERVISION_REQ,
-    LINK_SUPERVISION_RESP,
-}PAL_PROTOCOL_IDENTIFIERS;
-
-#define HCI_CMD_HDR_SZ          3
-#define HCI_EVENT_HDR_SIZE      2
-#define MAX_EVT_PKT_SZ          255
-#define AMP_ASSOC_MAX_FRAG_SZ   248
-#define AMP_MAX_GUARANTEED_BW   20000
-
-#define DEFAULT_CONN_ACCPT_TO   5000
-#define DEFAULT_LL_ACCPT_TO     5000
-#define DEFAULT_LSTO            10000
-
-#define PACKET_BASED_FLOW_CONTROL_MODE      0x00
-#define DATA_BLK_BASED_FLOW_CONTROL_MODE    0x01
-
-#define SERVICE_TYPE_BEST_EFFORT    0x01
-#define SERVICE_TYPE_GUARANTEED     0x02
-
-#define MAC_ADDR_LEN            6
-#define LINK_KEY_LEN            32
-
-typedef enum  {
-    ACL_DATA_PB_1ST_NON_AUTOMATICALLY_FLUSHABLE = 0x00,
-    ACL_DATA_PB_CONTINUING_FRAGMENT = 0x01,
-    ACL_DATA_PB_1ST_AUTOMATICALLY_FLUSHABLE = 0x02,
-    ACL_DATA_PB_COMPLETE_PDU = 0x03,
-} ACL_DATA_PB_FLAGS;
-#define ACL_DATA_PB_FLAGS_SHIFT     12
-
-typedef enum {
-    ACL_DATA_BC_POINT_TO_POINT = 0x00,
-} ACL_DATA_BC_FLAGS;
-#define ACL_DATA_BC_FLAGS_SHIFT     14
-
-/* Command pkt */
-typedef struct  hci_cmd_pkt_t {
-    u16 opcode;
-    u8 param_length;
-    u8 params[255];
-} POSTPACK HCI_CMD_PKT;
-
-#define ACL_DATA_HDR_SIZE   4   /* hdl_and flags + data_len */
-/* Data pkt */
-typedef struct  hci_acl_data_pkt_t {
-    u16 hdl_and_flags;
-    u16 data_len;
-    u8 data[Max80211_PAL_PDU_Size];
-} POSTPACK HCI_ACL_DATA_PKT;
-
-/* Event pkt */
-typedef struct  hci_event_pkt_t {
-    u8 event_code;
-    u8 param_len;
-    u8 params[256];
-} POSTPACK HCI_EVENT_PKT;
-
-
-/*============== HCI Command definitions ======================= */
-typedef struct hci_cmd_phy_link_t {
-    u16 opcode;
-    u8 param_length;
-    u8 phy_link_hdl;
-    u8 link_key_len;
-    u8 link_key_type;
-    u8 link_key[LINK_KEY_LEN];
-} POSTPACK HCI_CMD_PHY_LINK;
-
-typedef struct  hci_cmd_write_rem_amp_assoc_t {
-    u16 opcode;
-    u8 param_length;
-    u8 phy_link_hdl;
-    u16 len_so_far;
-    u16 amp_assoc_remaining_len;
-    u8 amp_assoc_frag[AMP_ASSOC_MAX_FRAG_SZ];
-} POSTPACK HCI_CMD_WRITE_REM_AMP_ASSOC;
-
-
-typedef struct  hci_cmd_opcode_hdl_t {
-    u16 opcode;
-    u8 param_length;
-    u16 hdl;
-} POSTPACK HCI_CMD_READ_LINK_QUAL,
-           HCI_CMD_FLUSH,
-           HCI_CMD_READ_LINK_SUPERVISION_TIMEOUT;
-
-typedef struct  hci_cmd_read_local_amp_assoc_t {
-    u16 opcode;
-    u8 param_length;
-    u8 phy_link_hdl;
-    u16 len_so_far;
-    u16 max_rem_amp_assoc_len;
-} POSTPACK HCI_CMD_READ_LOCAL_AMP_ASSOC;
-
-
-typedef struct hci_cmd_set_event_mask_t {
-    u16 opcode;
-    u8 param_length;
-    u64 mask;
-}POSTPACK HCI_CMD_SET_EVT_MASK, HCI_CMD_SET_EVT_MASK_PG_2;
-
-
-typedef struct  hci_cmd_enhanced_flush_t{
-    u16 opcode;
-    u8 param_length;
-    u16 hdl;
-    u8 type;
-} POSTPACK HCI_CMD_ENHANCED_FLUSH;
-
-
-typedef struct  hci_cmd_write_timeout_t {
-    u16 opcode;
-    u8 param_length;
-    u16 timeout;
-} POSTPACK  HCI_CMD_WRITE_TIMEOUT;
-
-typedef struct  hci_cmd_write_link_supervision_timeout_t {
-    u16 opcode;
-    u8 param_length;
-    u16 hdl;
-    u16 timeout;
-} POSTPACK HCI_CMD_WRITE_LINK_SUPERVISION_TIMEOUT;
-
-typedef struct  hci_cmd_write_flow_control_t {
-    u16 opcode;
-    u8 param_length;
-    u8 mode;
-} POSTPACK  HCI_CMD_WRITE_FLOW_CONTROL;
-
-typedef struct  location_data_cfg_t {
-    u8 reg_domain_aware;
-    u8 reg_domain[3];
-    u8 reg_options;
-} POSTPACK LOCATION_DATA_CFG;
-
-typedef struct  hci_cmd_write_location_data_t {
-    u16 opcode;
-    u8 param_length;
-    LOCATION_DATA_CFG   cfg;
-} POSTPACK  HCI_CMD_WRITE_LOCATION_DATA;
-
-
-typedef struct  flow_spec_t {
-    u8 id;
-    u8 service_type;
-    u16 max_sdu;
-    u32 sdu_inter_arrival_time;
-    u32 access_latency;
-    u32 flush_timeout;
-} POSTPACK FLOW_SPEC;
-
-
-typedef struct  hci_cmd_create_logical_link_t {
-    u16 opcode;
-    u8 param_length;
-    u8 phy_link_hdl;
-    FLOW_SPEC   tx_flow_spec;
-    FLOW_SPEC   rx_flow_spec;
-} POSTPACK HCI_CMD_CREATE_LOGICAL_LINK;
-
-typedef struct  hci_cmd_flow_spec_modify_t {
-    u16 opcode;
-    u8 param_length;
-    u16 hdl;
-    FLOW_SPEC   tx_flow_spec;
-    FLOW_SPEC   rx_flow_spec;
-} POSTPACK HCI_CMD_FLOW_SPEC_MODIFY;
-
-typedef struct hci_cmd_logical_link_cancel_t {
-    u16 opcode;
-    u8 param_length;
-    u8 phy_link_hdl;
-    u8 tx_flow_spec_id;
-} POSTPACK HCI_CMD_LOGICAL_LINK_CANCEL;
-
-typedef struct  hci_cmd_disconnect_logical_link_t {
-    u16 opcode;
-    u8 param_length;
-    u16 logical_link_hdl;
-} POSTPACK HCI_CMD_DISCONNECT_LOGICAL_LINK;
-
-typedef struct  hci_cmd_disconnect_phy_link_t {
-    u16 opcode;
-    u8 param_length;
-    u8 phy_link_hdl;
-} POSTPACK HCI_CMD_DISCONNECT_PHY_LINK;
-
-typedef struct  hci_cmd_srm_t {
-    u16 opcode;
-    u8 param_length;
-    u8 phy_link_hdl;
-    u8 mode;
-} POSTPACK HCI_CMD_SHORT_RANGE_MODE;
-/*============== HCI Command definitions end ======================= */
-
-
-
-/*============== HCI Event definitions ============================= */
-
-/* Command complete event */
-typedef struct  hci_event_cmd_complete_t {
-    u8 event_code;
-    u8 param_len;
-    u8 num_hci_cmd_pkts;
-    u16 opcode;
-    u8 params[255];
-} POSTPACK HCI_EVENT_CMD_COMPLETE;
-
-
-/* Command status event */
-typedef struct  hci_event_cmd_status_t {
-    u8 event_code;
-    u8 param_len;
-    u8 status;
-    u8 num_hci_cmd_pkts;
-    u16 opcode;
-} POSTPACK HCI_EVENT_CMD_STATUS;
-
-/* Hardware Error event */
-typedef struct  hci_event_hw_err_t {
-    u8 event_code;
-    u8 param_len;
-    u8 hw_err_code;
-} POSTPACK HCI_EVENT_HW_ERR;
-
-/* Flush occurred event */
-/* Qos Violation event */
-typedef struct  hci_event_handle_t {
-    u8 event_code;
-    u8 param_len;
-    u16 handle;
-} POSTPACK HCI_EVENT_FLUSH_OCCRD,
-           HCI_EVENT_QOS_VIOLATION;
-
-/* Loopback command event */
-typedef struct hci_loopback_cmd_t {
-    u8 event_code;
-    u8 param_len;
-    u8 params[252];
-} POSTPACK HCI_EVENT_LOOPBACK_CMD;
-
-/* Data buffer overflow event */
-typedef struct  hci_data_buf_overflow_t {
-    u8 event_code;
-    u8 param_len;
-    u8 link_type;
-} POSTPACK  HCI_EVENT_DATA_BUF_OVERFLOW;
-
-/* Enhanced Flush complete event */
-typedef struct hci_enhanced_flush_complt_t{
-    u8 event_code;
-    u8 param_len;
-    u16 hdl;
-} POSTPACK  HCI_EVENT_ENHANCED_FLUSH_COMPLT;
-
-/* Channel select event */
-typedef struct  hci_event_chan_select_t {
-    u8 event_code;
-    u8 param_len;
-    u8 phy_link_hdl;
-} POSTPACK HCI_EVENT_CHAN_SELECT;
-
-/* Physical Link Complete event */
-typedef struct  hci_event_phy_link_complete_event_t {
-    u8 event_code;
-    u8 param_len;
-    u8 status;
-    u8 phy_link_hdl;
-} POSTPACK HCI_EVENT_PHY_LINK_COMPLETE;
-
-/* Logical Link complete event */
-typedef struct hci_event_logical_link_complete_event_t {
-    u8 event_code;
-    u8 param_len;
-    u8 status;
-    u16 logical_link_hdl;
-    u8 phy_hdl;
-    u8 tx_flow_id;
-} POSTPACK HCI_EVENT_LOGICAL_LINK_COMPLETE_EVENT;
-
-/* Disconnect Logical Link complete event */
-typedef struct hci_event_disconnect_logical_link_event_t {
-    u8 event_code;
-    u8 param_len;
-    u8 status;
-    u16 logical_link_hdl;
-    u8 reason;
-} POSTPACK HCI_EVENT_DISCONNECT_LOGICAL_LINK_EVENT;
-
-/* Disconnect Physical Link complete event */
-typedef struct hci_event_disconnect_phy_link_complete_t {
-    u8 event_code;
-    u8 param_len;
-    u8 status;
-    u8 phy_link_hdl;
-    u8 reason;
-} POSTPACK HCI_EVENT_DISCONNECT_PHY_LINK_COMPLETE;
-
-typedef struct hci_event_physical_link_loss_early_warning_t{
-    u8 event_code;
-    u8 param_len;
-    u8 phy_hdl;
-    u8 reason;
-} POSTPACK HCI_EVENT_PHY_LINK_LOSS_EARLY_WARNING;
-
-typedef struct hci_event_physical_link_recovery_t{
-    u8 event_code;
-    u8 param_len;
-    u8 phy_hdl;
-} POSTPACK HCI_EVENT_PHY_LINK_RECOVERY;
-
-
-/* Flow spec modify complete event */
-/* Flush event */
-typedef struct hci_event_status_handle_t {
-    u8 event_code;
-    u8 param_len;
-    u8 status;
-    u16 handle;
-} POSTPACK HCI_EVENT_FLOW_SPEC_MODIFY,
-           HCI_EVENT_FLUSH;
-
-
-/* Num of completed data blocks event */
-typedef struct hci_event_num_of_compl_data_blks_t {
-    u8 event_code;
-    u8 param_len;
-    u16 num_data_blks;
-    u8 num_handles;
-    u8 params[255];
-} POSTPACK HCI_EVENT_NUM_COMPL_DATA_BLKS;
-
-/* Short range mode change complete event */
-typedef struct  hci_srm_cmpl_t {
-    u8 event_code;
-    u8 param_len;
-    u8 status;
-    u8 phy_link;
-    u8 state;
-} POSTPACK HCI_EVENT_SRM_COMPL;
-
-typedef struct hci_event_amp_status_change_t{
-    u8 event_code;
-    u8 param_len;
-    u8 status;
-    u8 amp_status;
-} POSTPACK HCI_EVENT_AMP_STATUS_CHANGE;
-
-/*============== Event definitions end =========================== */
-
-
-typedef struct  local_amp_info_resp_t {
-    u8 status;
-    u8 amp_status;
-    u32 total_bw;           /* kbps */
-    u32 max_guranteed_bw;   /* kbps */
-    u32 min_latency;
-    u32 max_pdu_size;
-    u8 amp_type;
-    u16 pal_capabilities;
-    u16 amp_assoc_len;
-    u32 max_flush_timeout;  /* in ms */
-    u32 be_flush_timeout;   /* in ms */
-} POSTPACK  LOCAL_AMP_INFO;
-
-typedef struct  amp_assoc_cmd_resp_t{
-    u8 status;
-    u8 phy_hdl;
-    u16 amp_assoc_len;
-    u8 amp_assoc_frag[AMP_ASSOC_MAX_FRAG_SZ];
-}POSTPACK AMP_ASSOC_CMD_RESP;
-
-
-enum PAL_HCI_CMD_STATUS {
-    PAL_HCI_CMD_PROCESSED,
-    PAL_HCI_CMD_IGNORED
-}; 
-
-
-/*============= HCI Error Codes =======================*/
-#define HCI_SUCCESS                             0x00
-#define HCI_ERR_UNKNOW_CMD                      0x01
-#define HCI_ERR_UNKNOWN_CONN_ID                 0x02
-#define HCI_ERR_HW_FAILURE                      0x03
-#define HCI_ERR_PAGE_TIMEOUT                    0x04
-#define HCI_ERR_AUTH_FAILURE                    0x05
-#define HCI_ERR_KEY_MISSING                     0x06
-#define HCI_ERR_MEM_CAP_EXECED                  0x07
-#define HCI_ERR_CON_TIMEOUT                     0x08
-#define HCI_ERR_CON_LIMIT_EXECED                0x09
-#define        HCI_ERR_ACL_CONN_ALRDY_EXISTS           0x0B
-#define        HCI_ERR_COMMAND_DISALLOWED                      0x0C
-#define HCI_ERR_CONN_REJ_BY_LIMIT_RES           0x0D
-#define HCI_ERR_CONN_REJ_BY_SEC                 0x0E
-#define HCI_ERR_CONN_REJ_BY_BAD_ADDR            0x0F
-#define HCI_ERR_CONN_ACCPT_TIMEOUT              0x10
-#define HCI_ERR_UNSUPPORT_FEATURE               0x11
-#define HCI_ERR_INVALID_HCI_CMD_PARAMS          0x12
-#define HCI_ERR_REMOTE_USER_TERMINATE_CONN      0x13
-#define HCI_ERR_CON_TERM_BY_HOST                0x16
-#define HCI_ERR_UNSPECIFIED_ERROR               0x1F
-#define HCI_ERR_ENCRYPTION_MODE_NOT_SUPPORT     0x25
-#define HCI_ERR_REQUESTED_QOS_NOT_SUPPORT       0x27
-#define HCI_ERR_QOS_UNACCEPTABLE_PARM           0x2C
-#define HCI_ERR_QOS_REJECTED                    0x2D
-#define HCI_ERR_CONN_REJ_NO_SUITABLE_CHAN       0x39
-
-/*============= HCI Error Codes End =======================*/
-
-
-/* Following are event return parameters.. part of HCI events 
- */
-typedef struct  timeout_read_t {
-    u8 status;
-    u16 timeout;
-}POSTPACK TIMEOUT_INFO;
-
-typedef struct  link_supervision_timeout_read_t {
-    u8 status;
-    u16 hdl;
-    u16 timeout;
-}POSTPACK LINK_SUPERVISION_TIMEOUT_INFO;
-
-typedef struct  status_hdl_t {
-    u8 status;
-    u16 hdl;
-}POSTPACK INFO_STATUS_HDL;
-
-typedef struct write_remote_amp_assoc_t{
-    u8 status;
-    u8 hdl;
-}POSTPACK WRITE_REMOTE_AMP_ASSOC_INFO;
-
-typedef struct  read_loc_info_t {
-    u8 status;
-    LOCATION_DATA_CFG   loc;
-}POSTPACK READ_LOC_INFO;
-
-typedef struct  read_flow_ctrl_mode_t {
-    u8 status;
-    u8 mode;
-}POSTPACK READ_FLWCTRL_INFO;
-
-typedef struct  read_data_blk_size_t {
-    u8 status;
-    u16 max_acl_data_pkt_len;
-    u16 data_block_len;
-    u16 total_num_data_blks;
-}POSTPACK READ_DATA_BLK_SIZE_INFO;
-
-/* Read Link quality info */
-typedef struct link_qual_t {
-    u8 status;
-    u16 hdl;
-    u8 link_qual;
-} POSTPACK READ_LINK_QUAL_INFO,
-            READ_RSSI_INFO;
-
-typedef struct ll_cancel_resp_t {
-    u8 status;
-    u8 phy_link_hdl;
-    u8 tx_flow_spec_id;
-} POSTPACK LL_CANCEL_RESP;
-
-typedef struct read_local_ver_info_t {
-    u8 status;
-    u8 hci_version;
-    u16 hci_revision;
-    u8 pal_version;
-    u16 manf_name;
-    u16 pal_sub_ver;
-} POSTPACK READ_LOCAL_VER_INFO;
-
-
-#endif  /* __A_HCI_H__ */
index e76624c5915cddfce6e4b7b3969696a0819a9aca..84e8db569a9fe8e1ceea042ada13b991d3f1437a 100644 (file)
 #ifndef __BMI_MSG_H__
 #define __BMI_MSG_H__
 
-#ifndef ATH_TARGET
-#include "athstartpack.h"
-#endif
-
 /*
  * Bootloader Messaging Interface (BMI)
  *
@@ -234,8 +230,4 @@ PREPACK struct bmi_target_info {
          * Note: Not supported on all versions of ROM firmware.
          */
 
-#ifndef ATH_TARGET
-#include "athendpack.h"
-#endif
-
 #endif /* __BMI_MSG_H__ */
diff --git a/drivers/staging/ath6kl/include/common/btcoexGpio.h b/drivers/staging/ath6kl/include/common/btcoexGpio.h
deleted file mode 100644 (file)
index 9d5a239..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-// Copyright (c) 2010 Atheros Communications Inc.
-// All rights reserved.
-// 
-//
-// Permission to use, copy, modify, and/or distribute this software for any
-// purpose with or without fee is hereby granted, provided that the above
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-//
-//
-
-#ifndef BTCOEX_GPIO_H_
-#define BTCOEX_GPIO_H_
-
-
-
-#ifdef FPGA
-#define GPIO_A      (15)
-#define GPIO_B      (16)
-#define GPIO_C      (17)
-#define GPIO_D      (18)
-#define GPIO_E      (19)
-#define GPIO_F      (21)
-#define GPIO_G      (21)
-#else
-#define GPIO_A      (0)
-#define GPIO_B      (5)
-#define GPIO_C      (6)
-#define GPIO_D      (7)
-#define GPIO_E      (7)
-#define GPIO_F      (7)
-#define GPIO_G      (7)
-#endif
-
-
-
-
-
-#define GPIO_DEBUG_WORD_1                                 (1<<GPIO_A)
-#define GPIO_DEBUG_WORD_2                   (1<<GPIO_B)
-#define GPIO_DEBUG_WORD_3                  ((1<<GPIO_B) | (1<<GPIO_A))
-#define GPIO_DEBUG_WORD_4     (1<<GPIO_C)
-#define GPIO_DEBUG_WORD_5    ((1<<GPIO_C) |               (1<<GPIO_A))
-#define GPIO_DEBUG_WORD_6    ((1<<GPIO_C) | (1<<GPIO_B))
-#define GPIO_DEBUG_WORD_7    ((1<<GPIO_C) | (1<<GPIO_B) | (1<<GPIO_A))
-
-#define GPIO_DEBUG_WORD_8     (1<<GPIO_D)
-#define GPIO_DEBUG_WORD_9    ((1<<GPIO_D) | GPIO_DEBUG_WORD_1)
-#define GPIO_DEBUG_WORD_10   ((1<<GPIO_D) | GPIO_DEBUG_WORD_2)
-#define GPIO_DEBUG_WORD_11   ((1<<GPIO_D) | GPIO_DEBUG_WORD_3)
-#define GPIO_DEBUG_WORD_12   ((1<<GPIO_D) | GPIO_DEBUG_WORD_4)
-#define GPIO_DEBUG_WORD_13   ((1<<GPIO_D) | GPIO_DEBUG_WORD_5)
-#define GPIO_DEBUG_WORD_14   ((1<<GPIO_D) | GPIO_DEBUG_WORD_6)
-#define GPIO_DEBUG_WORD_15   ((1<<GPIO_D) | GPIO_DEBUG_WORD_7)
-
-#define GPIO_DEBUG_WORD_16   (1<<GPIO_E)
-#define GPIO_DEBUG_WORD_17    ((1<<GPIO_E) | GPIO_DEBUG_WORD_1)
-#define GPIO_DEBUG_WORD_18   ((1<<GPIO_E) | GPIO_DEBUG_WORD_2)
-#define GPIO_DEBUG_WORD_19   ((1<<GPIO_E) | GPIO_DEBUG_WORD_3)
-#define GPIO_DEBUG_WORD_20   ((1<<GPIO_E) | GPIO_DEBUG_WORD_4)
-#define GPIO_DEBUG_WORD_21   ((1<<GPIO_E) | GPIO_DEBUG_WORD_5)
-#define GPIO_DEBUG_WORD_22   ((1<<GPIO_E) | GPIO_DEBUG_WORD_6)
-#define GPIO_DEBUG_WORD_23   ((1<<GPIO_E) | GPIO_DEBUG_WORD_7)
-
-
-
-extern void btcoexDbgPulseWord(u32 gpioPinMask);
-extern void btcoexDbgPulse(u32 pin);
-
-#ifdef CONFIG_BTCOEX_ENABLE_GPIO_DEBUG
-#define BTCOEX_DBG_PULSE_WORD(gpioPinMask)  (btcoexDbgPulseWord(gpioPinMask))
-#define BTCOEX_DBG_PULSE(pin)               (btcoexDbgPulse(pin))
-#else
-#define BTCOEX_DBG_PULSE_WORD(gpioPinMask)
-#define BTCOEX_DBG_PULSE(pin)
-
-#endif
-#endif
-
index b7a123086ccf823e49d36663937d07fca4dee04e..5566e568b83d94d2b3d58e16e9b94ee3291c1f24 100644 (file)
 #ifndef _DBGLOG_H_
 #define _DBGLOG_H_
 
-#ifndef ATH_TARGET
-#include "athstartpack.h"
-#endif
-
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -127,8 +123,4 @@ PREPACK struct dbglog_config_s {
 }
 #endif
 
-#ifndef ATH_TARGET
-#include "athendpack.h"
-#endif
-
 #endif /* _DBGLOG_H_ */
diff --git a/drivers/staging/ath6kl/include/common/dset_internal.h b/drivers/staging/ath6kl/include/common/dset_internal.h
deleted file mode 100644 (file)
index 6947533..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-//------------------------------------------------------------------------------
-// <copyright file="dset_internal.h" company="Atheros">
-//    Copyright (c) 2004-2010 Atheros Corporation.  All rights reserved.
-// 
-//
-// Permission to use, copy, modify, and/or distribute this software for any
-// purpose with or without fee is hereby granted, provided that the above
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-//
-//
-//------------------------------------------------------------------------------
-//==============================================================================
-// Author(s): ="Atheros"
-//==============================================================================
-
-
-#ifndef __DSET_INTERNAL_H__
-#define __DSET_INTERNAL_H__
-
-#ifndef ATH_TARGET
-#include "athstartpack.h"
-#endif
-
-/*
- * Internal dset definitions, common for DataSet layer.
- */
-
-#define DSET_TYPE_STANDARD      0
-#define DSET_TYPE_BPATCHED      1
-#define DSET_TYPE_COMPRESSED    2
-
-/* Dataset descriptor */
-
-typedef PREPACK struct dset_descriptor_s {
-  struct dset_descriptor_s  *next;         /* List link. NULL only at the last
-                                              descriptor */
-  u16 id;           /* Dset ID */
-  u16 size;         /* Dset size. */
-  void                      *DataPtr;      /* Pointer to raw data for standard
-                                              DataSet or pointer to original
-                                              dset_descriptor for patched
-                                              DataSet */
-  u32 data_type;    /* DSET_TYPE_*, above */
-
-  void                      *AuxPtr;       /* Additional data that might
-                                              needed for data_type. For
-                                              example, pointer to patch
-                                              Dataset descriptor for BPatch. */
-} POSTPACK dset_descriptor_t;
-
-#ifndef ATH_TARGET
-#include "athendpack.h"
-#endif
-
-#endif /* __DSET_INTERNAL_H__ */
diff --git a/drivers/staging/ath6kl/include/common/dsetid.h b/drivers/staging/ath6kl/include/common/dsetid.h
deleted file mode 100644 (file)
index 090e309..0000000
+++ /dev/null
@@ -1,134 +0,0 @@
-//------------------------------------------------------------------------------
-// <copyright file="dsetid.h" company="Atheros">
-//    Copyright (c) 2004-2010 Atheros Corporation.  All rights reserved.
-// 
-//
-// Permission to use, copy, modify, and/or distribute this software for any
-// purpose with or without fee is hereby granted, provided that the above
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-//
-//
-//------------------------------------------------------------------------------
-//==============================================================================
-// Author(s): ="Atheros"
-//==============================================================================
-
-
-#ifndef __DSETID_H__
-#define __DSETID_H__
-
-#ifndef ATH_TARGET
-#include "athstartpack.h"
-#endif
-
-/* Well-known DataSet IDs */
-#define DSETID_UNUSED                     0x00000000
-#define DSETID_BOARD_DATA                 0x00000001 /* Cal and board data */
-#define DSETID_REGDB                      0x00000002 /* Regulatory Database */
-#define DSETID_POWER_CONTROL              0x00000003 /* TX Pwr Lim & Ant Gain */
-#define DSETID_USER_CONFIG                0x00000004 /* User Configuration */
-
-#define DSETID_ANALOG_CONTROL_DATA_START  0x00000005
-#define DSETID_ANALOG_CONTROL_DATA_END    0x00000025
-/*
- * Get DSETID for various reference clock speeds.
- * For each speed there are three DataSets that correspond
- * to the three columns of bank6 data (addr, 11a, 11b/g).
- * This macro returns the dsetid of the first of those
- * three DataSets.
- */
-#define ANALOG_CONTROL_DATA_DSETID(refclk) \
-        (DSETID_ANALOG_CONTROL_DATA_START + 3*refclk)
-
-/*
- * There are TWO STARTUP_PATCH DataSets.
- * DSETID_STARTUP_PATCH is historical, and was applied before BMI on
- * earlier systems.  On AR6002, it is applied after BMI, just like
- * DSETID_STARTUP_PATCH2.
- */
-#define DSETID_STARTUP_PATCH              0x00000026
-#define DSETID_GPIO_CONFIG_PATCH          0x00000027
-#define DSETID_WLANREGS                   0x00000028 /* override wlan regs */
-#define DSETID_STARTUP_PATCH2             0x00000029
-
-#define DSETID_WOW_CONFIG                 0x00000090 /* WoW Configuration */
-
-/* Add WHAL_INI_DATA_ID to DSETID_INI_DATA for a specific WHAL INI table. */
-#define DSETID_INI_DATA                   0x00000100
-/* Reserved for WHAL INI Tables: 0x100..0x11f */
-#define DSETID_INI_DATA_END               0x0000011f
-
-#define DSETID_VENDOR_START               0x00010000 /* Vendor-defined DataSets */
-
-#define DSETID_INDEX_END                  0xfffffffe /* Reserved to indicate the
-                                                        end of a memory-based
-                                                        DataSet Index */
-#define DSETID_INDEX_FREE                 0xffffffff /* An unused index entry */
-
-/* 
- * PATCH DataSet format:
- * A list of patches, terminated by a patch with
- * address=PATCH_END.
- *
- * This allows for patches to be stored in flash.
- */
-PREPACK struct patch_s {
-    u32 *address;
-    u32 data;
-} POSTPACK ;
-
-/*
- * Skip some patches.  Can be used to erase a single patch in a
- * patch DataSet without having to re-write the DataSet.  May
- * also be used to embed information for use by subsequent
- * patch code.  The "data" in a PATCH_SKIP tells how many
- * bytes of length "patch_s" to skip.
- */
-#define PATCH_SKIP      ((u32 *)0x00000000)
-
-/*
- * Execute code at the address specified by "data".
- * The address of the patch structure is passed as
- * the one parameter.
- */
-#define PATCH_CODE_ABS  ((u32 *)0x00000001)
-
-/*
- * Same as PATCH_CODE_ABS, but treat "data" as an
- * offset from the start of the patch word.
- */
-#define PATCH_CODE_REL  ((u32 *)0x00000002)
-
-/* Mark the end of this patch DataSet. */
-#define PATCH_END       ((u32 *)0xffffffff)
-
-/*
- * A DataSet which contains a Binary Patch to some other DataSet
- * uses the original dsetid with the DSETID_BPATCH_FLAG bit set.
- * Such a BPatch DataSet consists of BPatch metadata followed by
- * the bdiff bytes.  BPatch metadata consists of a single 32-bit
- * word that contains the size of the BPatched final image.
- *
- * To create a suitable bdiff DataSet, use bdiff in host/tools/bdiff
- * to create "diffs":
- *  bdiff -q -O -nooldmd5 -nonewmd5 -d ORIGfile NEWfile diffs
- * Then add BPatch metadata to the start of "diffs".
- *
- * NB: There are some implementation-induced restrictions
- * on which DataSets can be BPatched.
- */
-#define DSETID_BPATCH_FLAG                0x80000000
-
-#ifndef ATH_TARGET
-#include "athendpack.h"
-#endif
-
-#endif /* __DSETID_H__ */
index 7027fac8f37edf47bbd7491499ea01c4ff17be64..9eb5fdfa746abdf21f79578f95a0eeae548b2409 100644 (file)
 #ifndef EPPING_TEST_H_
 #define EPPING_TEST_H_
 
-#ifndef ATH_TARGET
-#include "athstartpack.h"
-#endif
-
     /* alignment to 4-bytes */
 #define EPPING_ALIGNMENT_PAD  (((sizeof(struct htc_frame_hdr) + 3) & (~0x3)) - sizeof(struct htc_frame_hdr))
 
@@ -112,9 +108,4 @@ typedef PREPACK struct {
 #define HCI_TRANSPORT_STREAM_NUM  16  /* this number is higher than the define WMM AC classes so we
                                          can use this to distinguish packets */
 
-#ifndef ATH_TARGET
-#include "athendpack.h"
-#endif
-    
-    
 #endif /*EPPING_TEST_H_*/
index dd9afbd78ff9faf15947cc26d3dd5ef2387db6f3..ea11c14def439aa56fdc1664cd620ad6c9d7acda 100644 (file)
 #ifndef __GMBOXIF_H__
 #define __GMBOXIF_H__
 
-#ifndef ATH_TARGET
-#include "athstartpack.h"
-#endif
-
 /* GMBOX interface definitions */
     
 #define AR6K_GMBOX_CREDIT_COUNTER       1   /* we use credit counter 1 to track credits */
@@ -70,9 +66,5 @@ typedef PREPACK struct {
 #define MBOX_SIG_HCI_BRIDGE_PWR_SAV_OFF   4
 
 
-#ifndef ATH_TARGET
-#include "athendpack.h"
-#endif
-
 #endif /* __GMBOXIF_H__ */
 
diff --git a/drivers/staging/ath6kl/include/common/gpio.h b/drivers/staging/ath6kl/include/common/gpio.h
deleted file mode 100644 (file)
index f723066..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-//------------------------------------------------------------------------------
-// Copyright (c) 2005-2010 Atheros Corporation.  All rights reserved.
-//
-//
-// Permission to use, copy, modify, and/or distribute this software for any
-// purpose with or without fee is hereby granted, provided that the above
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-//
-//
-//
-// Author(s): ="Atheros"
-//------------------------------------------------------------------------------
-
-#define AR6001_GPIO_PIN_COUNT 18
-#define AR6002_GPIO_PIN_COUNT 18
-#define AR6003_GPIO_PIN_COUNT 28
-
-/*
- * Possible values for WMIX_GPIO_SET_REGISTER_CMDID.
- * NB: These match hardware order, so that addresses can
- * easily be computed.
- */
-#define GPIO_ID_OUT             0x00000000
-#define GPIO_ID_OUT_W1TS        0x00000001
-#define GPIO_ID_OUT_W1TC        0x00000002
-#define GPIO_ID_ENABLE          0x00000003
-#define GPIO_ID_ENABLE_W1TS     0x00000004
-#define GPIO_ID_ENABLE_W1TC     0x00000005
-#define GPIO_ID_IN              0x00000006
-#define GPIO_ID_STATUS          0x00000007
-#define GPIO_ID_STATUS_W1TS     0x00000008
-#define GPIO_ID_STATUS_W1TC     0x00000009
-#define GPIO_ID_PIN0            0x0000000a
-#define GPIO_ID_PIN(n)          (GPIO_ID_PIN0+(n))
-
-#define GPIO_LAST_REGISTER_ID   GPIO_ID_PIN(17)
-#define GPIO_ID_NONE            0xffffffff
diff --git a/drivers/staging/ath6kl/include/common/gpio_reg.h b/drivers/staging/ath6kl/include/common/gpio_reg.h
new file mode 100644 (file)
index 0000000..f9d425d
--- /dev/null
@@ -0,0 +1,9 @@
+#ifndef _GPIO_REG_REG_H_
+#define _GPIO_REG_REG_H_
+
+#define GPIO_PIN10_ADDRESS                       0x00000050
+#define GPIO_PIN11_ADDRESS                       0x00000054
+#define GPIO_PIN12_ADDRESS                       0x00000058
+#define GPIO_PIN13_ADDRESS                       0x0000005c
+
+#endif /* _GPIO_REG_H_ */
index b9d4495d4324c15fa2d2d2aa7f0396c12bc0277e..85cbfa89d670b619a321bb6118182477c3b006e1 100644 (file)
 #ifndef __HTC_H__
 #define __HTC_H__
 
-#ifndef ATH_TARGET
-#include "athstartpack.h"
-#endif
-
 #define A_OFFSETOF(type,field) (unsigned long)(&(((type *)NULL)->field))
 
 #define ASSEMBLE_UNALIGNED_UINT16(p,highbyte,lowbyte) \
@@ -227,10 +223,5 @@ typedef PREPACK struct {
     u8 LookAhead[4];     /* 4 byte lookahead */
 } POSTPACK HTC_BUNDLED_LOOKAHEAD_REPORT;
 
-#ifndef ATH_TARGET
-#include "athendpack.h"
-#endif
-
-
 #endif /* __HTC_H__ */
 
diff --git a/drivers/staging/ath6kl/include/common/ini_dset.h b/drivers/staging/ath6kl/include/common/ini_dset.h
deleted file mode 100644 (file)
index a9e05fa..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-//------------------------------------------------------------------------------
-// Copyright (c) 2004-2010 Atheros Corporation.  All rights reserved.
-//
-//
-// Permission to use, copy, modify, and/or distribute this software for any
-// purpose with or without fee is hereby granted, provided that the above
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-//
-//
-//
-// Author(s): ="Atheros"
-//------------------------------------------------------------------------------
-
-#ifndef _INI_DSET_H_
-#define _INI_DSET_H_
-
-/*
- * Each of these represents a WHAL INI table, which consists
- * of an "address column" followed by 1 or more "value columns".
- *
- * Software uses the base WHAL_INI_DATA_ID+column to access a
- * DataSet that holds a particular column of data.
- */
-typedef enum {
-#if defined(AR6002_REV4) || defined(AR6003)
-/* Add these definitions for compatibility  */
-#define WHAL_INI_DATA_ID_BB_RFGAIN_LNA1 WHAL_INI_DATA_ID_BB_RFGAIN
-#define WHAL_INI_DATA_ID_BB_RFGAIN_LNA2 WHAL_INI_DATA_ID_BB_RFGAIN
-    WHAL_INI_DATA_ID_NULL               =0,
-    WHAL_INI_DATA_ID_MODE_SPECIFIC      =1,  /* 2,3,4,5 */
-    WHAL_INI_DATA_ID_COMMON             =6,  /* 7 */
-    WHAL_INI_DATA_ID_BB_RFGAIN          =8,  /* 9,10 */
-#ifdef FPGA
-    WHAL_INI_DATA_ID_ANALOG_BANK0       =11, /* 12 */
-    WHAL_INI_DATA_ID_ANALOG_BANK1       =13, /* 14 */
-    WHAL_INI_DATA_ID_ANALOG_BANK2       =15, /* 16 */
-    WHAL_INI_DATA_ID_ANALOG_BANK3       =17, /* 18, 19 */
-    WHAL_INI_DATA_ID_ANALOG_BANK6       =20, /* 21,22 */
-    WHAL_INI_DATA_ID_ANALOG_BANK7       =23, /* 24 */
-    WHAL_INI_DATA_ID_ADDAC              =25, /* 26 */
-#else
-    WHAL_INI_DATA_ID_ANALOG_COMMON      =11, /* 12 */ 
-    WHAL_INI_DATA_ID_ANALOG_MODE_SPECIFIC=13, /* 14,15 */ 
-    WHAL_INI_DATA_ID_ANALOG_BANK6       =16, /* 17,18 */
-    WHAL_INI_DATA_ID_MODE_OVERRIDES     =19, /* 20,21,22,23 */
-    WHAL_INI_DATA_ID_COMMON_OVERRIDES   =24, /* 25 */
-    WHAL_INI_DATA_ID_ANALOG_OVERRIDES   =26, /* 27,28 */
-#endif /* FPGA */
-#else
-    WHAL_INI_DATA_ID_NULL               =0,
-    WHAL_INI_DATA_ID_MODE_SPECIFIC      =1,  /* 2,3 */
-    WHAL_INI_DATA_ID_COMMON             =4,  /* 5 */
-    WHAL_INI_DATA_ID_BB_RFGAIN          =6,  /* 7,8 */
-#define WHAL_INI_DATA_ID_BB_RFGAIN_LNA1 WHAL_INI_DATA_ID_BB_RFGAIN
-    WHAL_INI_DATA_ID_ANALOG_BANK1       =9,  /* 10 */
-    WHAL_INI_DATA_ID_ANALOG_BANK2       =11, /* 12 */
-    WHAL_INI_DATA_ID_ANALOG_BANK3       =13, /* 14, 15 */
-    WHAL_INI_DATA_ID_ANALOG_BANK6       =16, /* 17, 18 */
-    WHAL_INI_DATA_ID_ANALOG_BANK7       =19, /* 20 */
-    WHAL_INI_DATA_ID_MODE_OVERRIDES     =21, /* 22,23 */
-    WHAL_INI_DATA_ID_COMMON_OVERRIDES   =24, /* 25 */
-    WHAL_INI_DATA_ID_ANALOG_OVERRIDES   =26, /* 27,28 */
-    WHAL_INI_DATA_ID_BB_RFGAIN_LNA2     =29, /* 30,31 */
-#endif
-    WHAL_INI_DATA_ID_MAX                =31
-} WHAL_INI_DATA_ID;
-
-typedef PREPACK struct {
-    u16 freqIndex; // 1 - A mode 2 - B or G mode 0 - common
-    u16 offset;
-    u32 newValue;
-} POSTPACK INI_DSET_REG_OVERRIDE;
-
-#endif
diff --git a/drivers/staging/ath6kl/include/common/regDb.h b/drivers/staging/ath6kl/include/common/regDb.h
deleted file mode 100644 (file)
index f8245f1..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-//------------------------------------------------------------------------------
-// Copyright (c) 2005-2010 Atheros Corporation.  All rights reserved.
-// 
-//
-// Permission to use, copy, modify, and/or distribute this software for any
-// purpose with or without fee is hereby granted, provided that the above
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-//
-//
-//------------------------------------------------------------------------------
-//==============================================================================
-// Author(s): ="Atheros"
-//==============================================================================
-
-#ifndef __REG_DB_H__
-#define __REG_DB_H__
-
-#include "./regulatory/reg_dbschema.h"
-#include "./regulatory/reg_dbvalues.h"
-
-#endif  /* __REG_DB_H__ */
diff --git a/drivers/staging/ath6kl/include/common/regdump.h b/drivers/staging/ath6kl/include/common/regdump.h
deleted file mode 100644 (file)
index aa64821..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-//------------------------------------------------------------------------------
-// <copyright file="regdump.h" company="Atheros">
-//    Copyright (c) 2004-2010 Atheros Corporation.  All rights reserved.
-// 
-//
-// Permission to use, copy, modify, and/or distribute this software for any
-// purpose with or without fee is hereby granted, provided that the above
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-//
-//
-//------------------------------------------------------------------------------
-//==============================================================================
-// Author(s): ="Atheros"
-//==============================================================================
-
-#ifndef __REGDUMP_H__
-#define __REGDUMP_H__
-
-#ifndef ATH_TARGET
-#include "athstartpack.h"
-#endif
-
-#if defined(AR6001)
-#include "AR6001/AR6001_regdump.h"
-#endif
-#if defined(AR6002)
-#include "AR6002/AR6002_regdump.h"
-#endif
-
-#if !defined(__ASSEMBLER__)
-/*
- * Target CPU state at the time of failure is reflected
- * in a register dump, which the Host can fetch through
- * the diagnostic window.
- */
-PREPACK struct register_dump_s {
-    u32 target_id;               /* Target ID */
-    u32 assline;                 /* Line number (if assertion failure) */
-    u32 pc;                      /* Program Counter at time of exception */
-    u32 badvaddr;                /* Virtual address causing exception */
-    CPU_exception_frame_t exc_frame;  /* CPU-specific exception info */
-
-    /* Could copy top of stack here, too.... */
-} POSTPACK;
-#endif /* __ASSEMBLER__ */
-
-#ifndef ATH_TARGET
-#include "athendpack.h"
-#endif
-
-#endif /* __REGDUMP_H__ */
diff --git a/drivers/staging/ath6kl/include/common/regulatory/reg_dbschema.h b/drivers/staging/ath6kl/include/common/regulatory/reg_dbschema.h
deleted file mode 100644 (file)
index 4904040..0000000
+++ /dev/null
@@ -1,237 +0,0 @@
-//------------------------------------------------------------------------------
-// Copyright (c) 2005-2010 Atheros Corporation.  All rights reserved.
-// 
-//
-// Permission to use, copy, modify, and/or distribute this software for any
-// purpose with or without fee is hereby granted, provided that the above
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-//
-//
-//------------------------------------------------------------------------------
-//==============================================================================
-// Author(s): ="Atheros"
-//==============================================================================
-
-#ifndef __REG_DBSCHEMA_H__
-#define __REG_DBSCHEMA_H__
-
-/*
- * This file describes the regulatory DB schema, which is common between the
- * 'generator' and 'parser'. The 'generator' runs on a host(typically a x86
- * Linux) and spits outs two binary files, which follow the DB file
- * format(described below). The resultant output "regulatoryData_AG.bin"
- * is binary file which has information regarding A and G regulatory
- * information, while the "regulatoryData_G.bin" consists of G-ONLY regulatory
- * information. This binary file is parsed in the target for extracting
- * regulatory information.
- * 
- * The DB values used to populate the regulatory DB are defined in
- * reg_dbvalues.h
- *
- */
-
-/* Binary data file - Representation of Regulatory DB*/
-#define REG_DATA_FILE_AG    "./regulatoryData_AG.bin"
-#define REG_DATA_FILE_G     "./regulatoryData_G.bin"
-
-
-/* Table tags used to encode different tables in the database */
-enum data_tags_t{
-    REG_DMN_PAIR_MAPPING_TAG = 0,
-    REG_COUNTRY_CODE_TO_ENUM_RD_TAG,
-    REG_DMN_FREQ_BAND_regDmn5GhzFreq_TAG,
-    REG_DMN_FREQ_BAND_regDmn2Ghz11_BG_Freq_TAG,
-    REG_DOMAIN_TAG,
-    MAX_DB_TABLE_TAGS
-    };
-
-
-
-/*
- ****************************************************************************
- * Regulatory DB file format :
- * 4-bytes : "RGDB" (Magic Key)
- * 4-bytes : version (Default is 5379(my extn))
- * 4-bytes : length of file
- * dbType(4)
- * TAG(4)
- * Entries(1)entrySize(1)searchType(1)reserved[3]tableSize(2)"0xdeadbeef"(4)struct_data....
- * TAG(4)
- * Entries(1)entrySize(1)searchType(1)reserved[3]tableSize(2)"0xdeadbeef"(4)struct_data....
- * TAG(4)
- * Entries(1)entrySize(1)searchType(1)reserved[3]tableSize(2)"0xdeadbeef"(4)struct_data....
- * ...
- * ...
- ****************************************************************************
- *
- */
-
-/*
- * Length of the file would be filled in when the file is created and
- * it would include the header size.
- */
-
-#define REG_DB_KEY          "RGDB" /* Should be EXACTLY 4-bytes */
-#define REG_DB_VER           7802  /* Between 0-9999 */
-/*  REG_DB_VER history in reverse chronological order: 
- *  7802: 78 (ASCII code of N) + 02 (minor version number) - updated 10/21/09 
- *  7801: 78 (ASCII code of N) + 01 (minor version number, increment on further changes)
- *  1178: '11N' = 11 + ASCII code of N(78)
- *  5379: initial version, no 11N support
- */
-#define MAGIC_KEY_OFFSET    0
-#define VERSION_OFFSET      4
-#define FILE_SZ_OFFSET      8
-#define DB_TYPE_OFFSET      12
-
-#define MAGIC_KEY_SZ        4
-#define VERSION_SZ          4
-#define FILE_SZ_SZ          4
-#define DB_TYPE_SZ          4
-#define DB_TAG_SZ           4
-
-#define REGDB_GET_MAGICKEY(x)     ((char *)x + MAGIC_KEY_OFFSET) 
-#define REGDB_GET_VERSION(x)      ((char *)x + VERSION_OFFSET)
-#define REGDB_GET_FILESIZE(x)     *((unsigned int *)((char *)x + FILE_SZ_OFFSET))
-#define REGDB_GET_DBTYPE(x)       *((char *)x + DB_TYPE_OFFSET)
-
-#define REGDB_SET_FILESIZE(x, sz_) *((unsigned int *)((char *)x + FILE_SZ_OFFSET)) = (sz_)
-#define REGDB_IS_EOF(cur, begin)  ( REGDB_GET_FILESIZE(begin) > ((cur) - (begin)) )
-
-
-/* A Table can be search based on key as a parameter or accessed directly
- * by giving its index in to the table.
- */
-enum searchType {
-    KEY_BASED_TABLE_SEARCH = 1,
-    INDEX_BASED_TABLE_ACCESS
-    };
-
-
-/* Data is organised as different tables. There is a Master table, which
- * holds information regarding all the tables. It does not have any
- * knowledge about the attributes of the table it is holding
- * but has external view of the same(for ex, how many entries, record size,
- * how to search the table, total table size and reference to the data
- * instance of table).
- */
-typedef PREPACK struct dbMasterTable_t {    /* Hold ptrs to Table data structures */
-    u8     numOfEntries;
-    char entrySize;      /* Entry size per table row */
-    char searchType;     /* Index based access or key based */
-    char reserved[3];    /* for alignment */
-    u16 tableSize;      /* Size of this table */
-    char *dataPtr;       /* Ptr to the actual Table */
-} POSTPACK dbMasterTable;    /* Master table - table of tables */
-
-
-/* used to get the number of rows in a table */
-#define REGDB_NUM_OF_ROWS(a)    (sizeof (a) / sizeof (a[0]))
-
-/* 
- * Used to set the RegDomain bitmask which chooses which frequency
- * band specs are used.
- */
-
-#define BMLEN 2         /* Use 2 32-bit uint for channel bitmask */
-#define BMZERO {0,0}    /* BMLEN zeros */
-
-#define BM(_fa, _fb, _fc, _fd, _fe, _ff, _fg, _fh) \
-      {((((_fa >= 0) && (_fa < 32)) ? (((u32) 1) << _fa) : 0) | \
-    (((_fb >= 0) && (_fb < 32)) ? (((u32) 1) << _fb) : 0) | \
-    (((_fc >= 0) && (_fc < 32)) ? (((u32) 1) << _fc) : 0) | \
-    (((_fd >= 0) && (_fd < 32)) ? (((u32) 1) << _fd) : 0) | \
-    (((_fe >= 0) && (_fe < 32)) ? (((u32) 1) << _fe) : 0) | \
-    (((_ff >= 0) && (_ff < 32)) ? (((u32) 1) << _ff) : 0) | \
-    (((_fg >= 0) && (_fg < 32)) ? (((u32) 1) << _fg) : 0) | \
-    (((_fh >= 0) && (_fh < 32)) ? (((u32) 1) << _fh) : 0)), \
-       ((((_fa > 31) && (_fa < 64)) ? (((u32) 1) << (_fa - 32)) : 0) | \
-        (((_fb > 31) && (_fb < 64)) ? (((u32) 1) << (_fb - 32)) : 0) | \
-        (((_fc > 31) && (_fc < 64)) ? (((u32) 1) << (_fc - 32)) : 0) | \
-        (((_fd > 31) && (_fd < 64)) ? (((u32) 1) << (_fd - 32)) : 0) | \
-        (((_fe > 31) && (_fe < 64)) ? (((u32) 1) << (_fe - 32)) : 0) | \
-        (((_ff > 31) && (_ff < 64)) ? (((u32) 1) << (_ff - 32)) : 0) | \
-        (((_fg > 31) && (_fg < 64)) ? (((u32) 1) << (_fg - 32)) : 0) | \
-        (((_fh > 31) && (_fh < 64)) ? (((u32) 1) << (_fh - 32)) : 0))}
-
-
-/*
- * THE following table is the mapping of regdomain pairs specified by
- * a regdomain value to the individual unitary reg domains
- */
-
-typedef PREPACK struct reg_dmn_pair_mapping {
-    u16 regDmnEnum;    /* 16 bit reg domain pair */
-    u16 regDmn5GHz;    /* 5GHz reg domain */
-    u16 regDmn2GHz;    /* 2GHz reg domain */
-    u8 flags5GHz;     /* Requirements flags (AdHoc disallow etc) */
-    u8 flags2GHz;     /* Requirements flags (AdHoc disallow etc) */
-    u32 pscanMask;     /* Passive Scan flags which can override unitary domain passive scan
-                                   flags.  This value is used as a mask on the unitary flags*/
-} POSTPACK REG_DMN_PAIR_MAPPING;
-
-#define OFDM_YES (1 << 0)
-#define OFDM_NO  (0 << 0)
-#define MCS_HT20_YES   (1 << 1)
-#define MCS_HT20_NO    (0 << 1)
-#define MCS_HT40_A_YES (1 << 2)
-#define MCS_HT40_A_NO  (0 << 2)
-#define MCS_HT40_G_YES (1 << 3)
-#define MCS_HT40_G_NO  (0 << 3)
-
-typedef PREPACK struct {
-    u16 countryCode;
-    u16 regDmnEnum;
-    char isoName[3];
-    char allowMode;  /* what mode is allowed - bit 0: OFDM; bit 1: MCS_HT20; bit 2: MCS_HT40_A; bit 3: MCS_HT40_G */
-} POSTPACK COUNTRY_CODE_TO_ENUM_RD;
-
-/* lower 16 bits of ht40ChanMask */
-#define NO_FREQ_HT40    0x0     /* no freq is HT40 capable */
-#define F1_TO_F4_HT40   0xF     /* freq 1 to 4 in the block is ht40 capable */
-#define F2_TO_F3_HT40   0x6     /* freq 2 to 3 in the block is ht40 capable */
-#define F1_TO_F10_HT40  0x3FF   /* freq 1 to 10 in the block is ht40 capable */
-#define F3_TO_F11_HT40  0x7FC   /* freq 3 to 11 in the block is ht40 capable */
-#define F3_TO_F9_HT40   0x1FC   /* freq 3 to 9 in the block is ht40 capable */
-#define F1_TO_F8_HT40   0xFF    /* freq 1 to 8 in the block is ht40 capable */
-#define F1_TO_F4_F9_TO_F10_HT40   0x30F    /* freq 1 to 4, 9 to 10 in the block is ht40 capable */
-
-/* upper 16 bits of ht40ChanMask */
-#define FREQ_HALF_RATE      0x10000
-#define FREQ_QUARTER_RATE   0x20000
-
-typedef PREPACK struct RegDmnFreqBand {
-    u16 lowChannel;     /* Low channel center in MHz */
-    u16 highChannel;    /* High Channel center in MHz */
-    u8 power;          /* Max power (dBm) for channel range */
-    u8 channelSep;     /* Channel separation within the band */
-    u8 useDfs;         /* Use DFS in the RegDomain if corresponding bit is set */
-    u8 mode;           /* Mode of operation */
-    u32 usePassScan;    /* Use Passive Scan in the RegDomain if corresponding bit is set */
-    u32 ht40ChanMask;   /* lower 16 bits: indicate which frequencies in the block is HT40 capable
-                                   upper 16 bits: what rate (half/quarter) the channel is  */
-} POSTPACK REG_DMN_FREQ_BAND;
-
-
-
-typedef PREPACK struct regDomain {
-    u16 regDmnEnum;     /* value from EnumRd table */
-    u8 rdCTL;
-    u8 maxAntGain;
-    u8 dfsMask;        /* DFS bitmask for 5Ghz tables */
-    u8 flags;          /* Requirement flags (AdHoc disallow etc) */
-    u16 reserved;       /* for alignment */
-    u32 pscan;          /* Bitmask for passive scan */
-    u32 chan11a[BMLEN]; /* 64 bit bitmask for channel/band selection */
-    u32 chan11bg[BMLEN];/* 64 bit bitmask for channel/band selection */
-} POSTPACK REG_DOMAIN;
-
-#endif /* __REG_DBSCHEMA_H__ */
diff --git a/drivers/staging/ath6kl/include/common/regulatory/reg_dbvalues.h b/drivers/staging/ath6kl/include/common/regulatory/reg_dbvalues.h
deleted file mode 100644 (file)
index 278f903..0000000
+++ /dev/null
@@ -1,504 +0,0 @@
-//------------------------------------------------------------------------------
-// Copyright (c) 2005-2010 Atheros Corporation.  All rights reserved.
-// 
-//
-// Permission to use, copy, modify, and/or distribute this software for any
-// purpose with or without fee is hereby granted, provided that the above
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-//
-//
-//------------------------------------------------------------------------------
-//==============================================================================
-// Author(s): ="Atheros"
-//==============================================================================
-
-
-#ifndef __REG_DBVALUE_H__
-#define __REG_DBVALUE_H__
-
-/*
- * Numbering from ISO 3166
- */
-enum CountryCode {
-    CTRY_ALBANIA              = 8,       /* Albania */
-    CTRY_ALGERIA              = 12,      /* Algeria */
-    CTRY_ARGENTINA            = 32,      /* Argentina */
-    CTRY_ARMENIA              = 51,      /* Armenia */
-    CTRY_ARUBA                = 533,     /* Aruba */
-    CTRY_AUSTRALIA            = 36,      /* Australia (for STA) */
-    CTRY_AUSTRALIA_AP         = 5000,    /* Australia (for AP) */
-    CTRY_AUSTRIA              = 40,      /* Austria */
-    CTRY_AZERBAIJAN           = 31,      /* Azerbaijan */
-    CTRY_BAHRAIN              = 48,      /* Bahrain */
-    CTRY_BANGLADESH           = 50,      /* Bangladesh */
-    CTRY_BARBADOS             = 52,      /* Barbados */
-    CTRY_BELARUS              = 112,     /* Belarus */
-    CTRY_BELGIUM              = 56,      /* Belgium */
-    CTRY_BELIZE               = 84,      /* Belize */
-    CTRY_BOLIVIA              = 68,      /* Bolivia */
-    CTRY_BOSNIA_HERZEGOWANIA  = 70,      /* Bosnia & Herzegowania */
-    CTRY_BRAZIL               = 76,      /* Brazil */
-    CTRY_BRUNEI_DARUSSALAM    = 96,      /* Brunei Darussalam */
-    CTRY_BULGARIA             = 100,     /* Bulgaria */
-    CTRY_CAMBODIA             = 116,     /* Cambodia */
-    CTRY_CANADA               = 124,     /* Canada (for STA) */
-    CTRY_CANADA_AP            = 5001,    /* Canada (for AP) */
-    CTRY_CHILE                = 152,     /* Chile */
-    CTRY_CHINA                = 156,     /* People's Republic of China */
-    CTRY_COLOMBIA             = 170,     /* Colombia */
-    CTRY_COSTA_RICA           = 188,     /* Costa Rica */
-    CTRY_CROATIA              = 191,     /* Croatia */
-    CTRY_CYPRUS               = 196,
-    CTRY_CZECH                = 203,     /* Czech Republic */
-    CTRY_DENMARK              = 208,     /* Denmark */
-    CTRY_DOMINICAN_REPUBLIC   = 214,     /* Dominican Republic */
-    CTRY_ECUADOR              = 218,     /* Ecuador */
-    CTRY_EGYPT                = 818,     /* Egypt */
-    CTRY_EL_SALVADOR          = 222,     /* El Salvador */
-    CTRY_ESTONIA              = 233,     /* Estonia */
-    CTRY_FAEROE_ISLANDS       = 234,     /* Faeroe Islands */
-    CTRY_FINLAND              = 246,     /* Finland */
-    CTRY_FRANCE               = 250,     /* France */
-    CTRY_FRANCE2              = 255,     /* France2 */
-    CTRY_GEORGIA              = 268,     /* Georgia */
-    CTRY_GERMANY              = 276,     /* Germany */
-    CTRY_GREECE               = 300,     /* Greece */
-    CTRY_GREENLAND            = 304,     /* Greenland */
-    CTRY_GRENADA              = 308,     /* Grenada */
-    CTRY_GUAM                 = 316,     /* Guam */
-    CTRY_GUATEMALA            = 320,     /* Guatemala */
-    CTRY_HAITI                = 332,     /* Haiti */
-    CTRY_HONDURAS             = 340,     /* Honduras */
-    CTRY_HONG_KONG            = 344,     /* Hong Kong S.A.R., P.R.C. */
-    CTRY_HUNGARY              = 348,     /* Hungary */
-    CTRY_ICELAND              = 352,     /* Iceland */
-    CTRY_INDIA                = 356,     /* India */
-    CTRY_INDONESIA            = 360,     /* Indonesia */
-    CTRY_IRAN                 = 364,     /* Iran */
-    CTRY_IRAQ                 = 368,     /* Iraq */
-    CTRY_IRELAND              = 372,     /* Ireland */
-    CTRY_ISRAEL               = 376,     /* Israel */
-    CTRY_ITALY                = 380,     /* Italy */
-    CTRY_JAMAICA              = 388,     /* Jamaica */
-    CTRY_JAPAN                = 392,     /* Japan */
-    CTRY_JAPAN1               = 393,     /* Japan (JP1) */
-    CTRY_JAPAN2               = 394,     /* Japan (JP0) */
-    CTRY_JAPAN3               = 395,     /* Japan (JP1-1) */
-    CTRY_JAPAN4               = 396,     /* Japan (JE1) */
-    CTRY_JAPAN5               = 397,     /* Japan (JE2) */
-    CTRY_JAPAN6               = 399,     /* Japan (JP6) */
-    CTRY_JORDAN               = 400,     /* Jordan */
-    CTRY_KAZAKHSTAN           = 398,     /* Kazakhstan */
-    CTRY_KENYA                = 404,     /* Kenya */
-    CTRY_KOREA_NORTH          = 408,     /* North Korea */
-    CTRY_KOREA_ROC            = 410,     /* South Korea (for STA) */
-    CTRY_KOREA_ROC2           = 411,     /* South Korea */
-    CTRY_KOREA_ROC3           = 412,     /* South Korea (for AP) */
-    CTRY_KUWAIT               = 414,     /* Kuwait */
-    CTRY_LATVIA               = 428,     /* Latvia */
-    CTRY_LEBANON              = 422,     /* Lebanon */
-    CTRY_LIBYA                = 434,     /* Libya */
-    CTRY_LIECHTENSTEIN        = 438,     /* Liechtenstein */
-    CTRY_LITHUANIA            = 440,     /* Lithuania */
-    CTRY_LUXEMBOURG           = 442,     /* Luxembourg */
-    CTRY_MACAU                = 446,     /* Macau */
-    CTRY_MACEDONIA            = 807,     /* the Former Yugoslav Republic of Macedonia */
-    CTRY_MALAYSIA             = 458,     /* Malaysia */
-    CTRY_MALTA                = 470,     /* Malta */
-    CTRY_MEXICO               = 484,     /* Mexico */
-    CTRY_MONACO               = 492,     /* Principality of Monaco */
-    CTRY_MOROCCO              = 504,     /* Morocco */
-    CTRY_NEPAL                = 524,     /* Nepal */   
-    CTRY_NETHERLANDS          = 528,     /* Netherlands */
-    CTRY_NETHERLAND_ANTILLES  = 530,     /* Netherlands-Antilles */
-    CTRY_NEW_ZEALAND          = 554,     /* New Zealand */
-    CTRY_NICARAGUA            = 558,     /* Nicaragua */
-    CTRY_NORWAY               = 578,     /* Norway */
-    CTRY_OMAN                 = 512,     /* Oman */
-    CTRY_PAKISTAN             = 586,     /* Islamic Republic of Pakistan */
-    CTRY_PANAMA               = 591,     /* Panama */
-    CTRY_PARAGUAY             = 600,     /* Paraguay */
-    CTRY_PERU                 = 604,     /* Peru */
-    CTRY_PHILIPPINES          = 608,     /* Republic of the Philippines */
-    CTRY_POLAND               = 616,     /* Poland */
-    CTRY_PORTUGAL             = 620,     /* Portugal */
-    CTRY_PUERTO_RICO          = 630,     /* Puerto Rico */
-    CTRY_QATAR                = 634,     /* Qatar */
-    CTRY_ROMANIA              = 642,     /* Romania */
-    CTRY_RUSSIA               = 643,     /* Russia */
-    CTRY_SAUDI_ARABIA         = 682,     /* Saudi Arabia */
-    CTRY_MONTENEGRO           = 891,     /* Montenegro */
-    CTRY_SINGAPORE            = 702,     /* Singapore */
-    CTRY_SLOVAKIA             = 703,     /* Slovak Republic */
-    CTRY_SLOVENIA             = 705,     /* Slovenia */
-    CTRY_SOUTH_AFRICA         = 710,     /* South Africa */
-    CTRY_SPAIN                = 724,     /* Spain */
-    CTRY_SRILANKA             = 144,     /* Sri Lanka */
-    CTRY_SWEDEN               = 752,     /* Sweden */
-    CTRY_SWITZERLAND          = 756,     /* Switzerland */
-    CTRY_SYRIA                = 760,     /* Syria */
-    CTRY_TAIWAN               = 158,     /* Taiwan */
-    CTRY_THAILAND             = 764,     /* Thailand */
-    CTRY_TRINIDAD_Y_TOBAGO    = 780,     /* Trinidad y Tobago */
-    CTRY_TUNISIA              = 788,     /* Tunisia */
-    CTRY_TURKEY               = 792,     /* Turkey */
-    CTRY_UAE                  = 784,     /* U.A.E. */
-    CTRY_UKRAINE              = 804,     /* Ukraine */
-    CTRY_UNITED_KINGDOM       = 826,     /* United Kingdom */
-    CTRY_UNITED_STATES        = 840,     /* United States (for STA) */
-    CTRY_UNITED_STATES_AP     = 841,     /* United States (for AP) */
-    CTRY_UNITED_STATES_PS     = 842,     /* United States - public safety */
-    CTRY_URUGUAY              = 858,     /* Uruguay */
-    CTRY_UZBEKISTAN           = 860,     /* Uzbekistan */
-    CTRY_VENEZUELA            = 862,     /* Venezuela */
-    CTRY_VIET_NAM             = 704,     /* Viet Nam */
-    CTRY_YEMEN                = 887,     /* Yemen */
-    CTRY_ZIMBABWE             = 716      /* Zimbabwe */
-};
-
-#define CTRY_DEBUG      0
-#define CTRY_DEFAULT    0x1ff
-
-/*
- * The following regulatory domain definitions are
- * found in the EEPROM. Each regulatory domain
- * can operate in either a 5GHz or 2.4GHz wireless mode or
- * both 5GHz and 2.4GHz wireless modes.
- * In general, the value holds no special
- * meaning and is used to decode into either specific
- * 2.4GHz or 5GHz wireless mode for that particular
- * regulatory domain.
- *
- * Enumerated Regulatory Domain Information 8 bit values indicate that
- * the regdomain is really a pair of unitary regdomains.  12 bit values
- * are the real unitary regdomains and are the only ones which have the
- * frequency bitmasks and flags set.
- */
-
-enum EnumRd {
-    NO_ENUMRD   = 0x00,
-    NULL1_WORLD = 0x03,     /* For 11b-only countries (no 11a allowed) */
-    NULL1_ETSIB = 0x07,     /* Israel */
-    NULL1_ETSIC = 0x08,
-
-    FCC1_FCCA   = 0x10,     /* USA */
-    FCC1_WORLD  = 0x11,     /* Hong Kong */
-    FCC2_FCCA   = 0x20,     /* Canada */
-    FCC2_WORLD  = 0x21,     /* Australia & HK */
-    FCC2_ETSIC  = 0x22,
-    FCC3_FCCA   = 0x3A,     /* USA & Canada w/5470 band, 11h, DFS enabled */
-    FCC3_WORLD  = 0x3B,     /* USA & Canada w/5470 band, 11h, DFS enabled */
-    FCC4_FCCA   = 0x12,     /* FCC public safety plus UNII bands */
-    FCC5_FCCA   = 0x13,     /* US with no DFS */
-    FCC5_WORLD  = 0x16,     /* US with no DFS */
-    FCC6_FCCA   = 0x14,     /* Same as FCC2_FCCA but with 5600-5650MHz channels disabled for US & Canada APs */
-    FCC6_WORLD  = 0x23,     /* Same as FCC2_FCCA but with 5600-5650MHz channels disabled for Australia APs */
-
-    ETSI1_WORLD = 0x37,
-
-    ETSI2_WORLD = 0x35,     /* Hungary & others */
-    ETSI3_WORLD = 0x36,     /* France & others */
-    ETSI4_WORLD = 0x30,
-    ETSI4_ETSIC = 0x38,
-    ETSI5_WORLD = 0x39,
-    ETSI6_WORLD = 0x34,     /* Bulgaria */
-    ETSI_RESERVED   = 0x33,     /* Reserved (Do not used) */
-    FRANCE_RES  = 0x31,     /* Legacy France for OEM */
-
-    APL6_WORLD  = 0x5B,     /* Singapore */
-    APL4_WORLD  = 0x42,     /* Singapore */
-    APL3_FCCA   = 0x50,
-    APL_RESERVED    = 0x44,     /* Reserved (Do not used)  */
-    APL2_WORLD  = 0x45,     /* Korea */
-    APL2_APLC   = 0x46,
-    APL3_WORLD  = 0x47,
-    APL2_APLD   = 0x49,     /* Korea with 2.3G channels */
-    APL2_FCCA   = 0x4D,     /* Specific Mobile Customer */
-    APL1_WORLD  = 0x52,     /* Latin America */
-    APL1_FCCA   = 0x53,
-    APL1_ETSIC  = 0x55,
-    APL2_ETSIC  = 0x56,     /* Venezuela */
-    APL5_WORLD  = 0x58,     /* Chile */
-    APL7_FCCA   = 0x5C,
-    APL8_WORLD  = 0x5D,
-    APL9_WORLD  = 0x5E,
-    APL10_WORLD = 0x5F,     /* Korea 5GHz for STA */
-
-
-    MKK5_MKKA   = 0x99, /* This is a temporary value. MG and DQ have to give official one */
-    MKK5_FCCA   = 0x9A, /* This is a temporary value. MG and DQ have to give official one */
-    MKK5_MKKC   = 0x88,
-    MKK11_MKKA  = 0xD4,
-    MKK11_FCCA  = 0xD5,
-    MKK11_MKKC  = 0xD7,
-
-    /*
-     * World mode SKUs
-     */
-    WOR0_WORLD  = 0x60,     /* World0 (WO0 SKU) */
-    WOR1_WORLD  = 0x61,     /* World1 (WO1 SKU) */
-    WOR2_WORLD  = 0x62,     /* World2 (WO2 SKU) */
-    WOR3_WORLD  = 0x63,     /* World3 (WO3 SKU) */
-    WOR4_WORLD  = 0x64,     /* World4 (WO4 SKU) */  
-    WOR5_ETSIC  = 0x65,     /* World5 (WO5 SKU) */    
-
-    WOR01_WORLD = 0x66,     /* World0-1 (WW0-1 SKU) */
-    WOR02_WORLD = 0x67,     /* World0-2 (WW0-2 SKU) */
-    EU1_WORLD   = 0x68,     /* Same as World0-2 (WW0-2 SKU), except active scan ch1-13. No ch14 */
-
-    WOR9_WORLD  = 0x69,     /* World9 (WO9 SKU) */  
-    WORA_WORLD  = 0x6A,     /* WorldA (WOA SKU) */  
-    WORB_WORLD  = 0x6B,     /* WorldB (WOA SKU) */  
-    WORC_WORLD  = 0x6C,     /* WorldC (WOA SKU) */  
-
-    /*
-     * Regulator domains ending in a number (e.g. APL1,
-     * MK1, ETSI4, etc) apply to 5GHz channel and power
-     * information.  Regulator domains ending in a letter
-     * (e.g. APLA, FCCA, etc) apply to 2.4GHz channel and
-     * power information.
-     */
-    APL1        = 0x0150,   /* LAT & Asia */
-    APL2        = 0x0250,   /* LAT & Asia */
-    APL3        = 0x0350,   /* Taiwan */
-    APL4        = 0x0450,   /* Jordan */
-    APL5        = 0x0550,   /* Chile */
-    APL6        = 0x0650,   /* Singapore */
-    APL7        = 0x0750,   /* Taiwan */
-    APL8        = 0x0850,   /* Malaysia */
-    APL9        = 0x0950,   /* Korea */
-    APL10       = 0x1050,   /* Korea 5GHz */
-
-    ETSI1       = 0x0130,   /* Europe & others */
-    ETSI2       = 0x0230,   /* Europe & others */
-    ETSI3       = 0x0330,   /* Europe & others */
-    ETSI4       = 0x0430,   /* Europe & others */
-    ETSI5       = 0x0530,   /* Europe & others */
-    ETSI6       = 0x0630,   /* Europe & others */
-    ETSIB       = 0x0B30,   /* Israel */
-    ETSIC       = 0x0C30,   /* Latin America */
-
-    FCC1        = 0x0110,   /* US & others */
-    FCC2        = 0x0120,   /* Canada, Australia & New Zealand */
-    FCC3        = 0x0160,   /* US w/new middle band & DFS */    
-    FCC4        = 0x0165,
-    FCC5        = 0x0180,
-    FCC6        = 0x0610,
-    FCCA        = 0x0A10,    
-
-    APLD        = 0x0D50,   /* South Korea */
-
-    MKK1        = 0x0140,   /* Japan */
-    MKK2        = 0x0240,   /* Japan Extended */
-    MKK3        = 0x0340,   /* Japan new 5GHz */
-    MKK4        = 0x0440,   /* Japan new 5GHz */
-    MKK5        = 0x0540,   /* Japan new 5GHz */
-    MKK6        = 0x0640,   /* Japan new 5GHz */
-    MKK7        = 0x0740,   /* Japan new 5GHz */
-    MKK8        = 0x0840,   /* Japan new 5GHz */
-    MKK9        = 0x0940,   /* Japan new 5GHz */
-    MKK10       = 0x1040,   /* Japan new 5GHz */
-    MKK11       = 0x1140,   /* Japan new 5GHz */
-    MKK12       = 0x1240,   /* Japan new 5GHz */
-
-    MKKA        = 0x0A40,   /* Japan */
-    MKKC        = 0x0A50,
-
-    NULL1       = 0x0198,
-    WORLD       = 0x0199,
-    DEBUG_REG_DMN   = 0x01ff,
-    UNINIT_REG_DMN  = 0x0fff,
-};
-
-enum {                  /* conformance test limits */
-    FCC = 0x10,
-    MKK = 0x40,
-    ETSI    = 0x30,
-    NO_CTL  = 0xff,
-    CTL_11B = 1,
-    CTL_11G = 2
-};
-
-
-/*
- * The following are flags for different requirements per reg domain.
- * These requirements are either inhereted from the reg domain pair or
- * from the unitary reg domain if the reg domain pair flags value is
- * 0
- */
-
-enum {
-    NO_REQ              = 0x00,
-    DISALLOW_ADHOC_11A  = 0x01,
-    ADHOC_PER_11D       = 0x02,
-    ADHOC_NO_11A        = 0x04,
-    DISALLOW_ADHOC_11G  = 0x08
-};
-
-
-
-
-/*
- * The following describe the bit masks for different passive scan
- * capability/requirements per regdomain.
- */
-#define NO_PSCAN        0x00000000
-#define PSCAN_FCC       0x00000001
-#define PSCAN_ETSI      0x00000002
-#define PSCAN_MKK       0x00000004
-#define PSCAN_ETSIB     0x00000008
-#define PSCAN_ETSIC     0x00000010
-#define PSCAN_WWR       0x00000020
-#define PSCAN_DEFER     0xFFFFFFFF
-
-/* Bit masks for DFS per regdomain */
-
-enum {
-    NO_DFS   = 0x00,
-    DFS_FCC3 = 0x01,
-    DFS_ETSI = 0x02,
-    DFS_MKK  = 0x04
-};
-
-
-#define DEF_REGDMN      FCC1_FCCA
-
-/* 
- * The following table is the master list for all different freqeuncy
- * bands with the complete matrix of all possible flags and settings
- * for each band if it is used in ANY reg domain.
- *
- * The table of frequency bands is indexed by a bitmask.  The ordering
- * must be consistent with the enum below.  When adding a new
- * frequency band, be sure to match the location in the enum with the
- * comments 
- */
-
-/*
- * These frequency values are as per channel tags and regulatory domain
- * info. Please update them as database is updated.
- */
-#define A_FREQ_MIN              4920
-#define A_FREQ_MAX              5825
-
-#define A_CHAN0_FREQ            5000
-#define A_CHAN_MAX              ((A_FREQ_MAX - A_CHAN0_FREQ)/5)
-
-#define BG_FREQ_MIN             2412
-#define BG_FREQ_MAX             2484
-
-#define BG_CHAN0_FREQ           2407
-#define BG_CHAN_MIN             ((BG_FREQ_MIN - BG_CHAN0_FREQ)/5)
-#define BG_CHAN_MAX             14      /* corresponding to 2484 MHz */
-
-#define A_20MHZ_BAND_FREQ_MAX   5000
-
-
-/*
- * 5GHz 11A channel tags
- */
-
-enum {
-    F1_4920_4980,
-    F1_5040_5080,
-
-    F1_5120_5240,
-
-    F1_5180_5240,
-    F2_5180_5240,
-    F3_5180_5240,
-    F4_5180_5240,
-    F5_5180_5240,
-    F6_5180_5240,
-    F7_5180_5240,
-
-    F1_5260_5280,
-
-    F1_5260_5320,
-    F2_5260_5320,
-    F3_5260_5320,
-    F4_5260_5320,
-    F5_5260_5320,
-    F6_5260_5320,
-
-    F1_5260_5700,
-
-    F1_5280_5320,
-
-    F1_5500_5620,
-
-    F1_5500_5700,
-    F2_5500_5700,
-    F3_5500_5700,
-    F4_5500_5700,
-    F5_5500_5700,
-    F6_5500_5700,
-    F7_5500_5700,
-
-    F1_5745_5805,
-    F2_5745_5805,
-
-    F1_5745_5825,
-    F2_5745_5825,
-    F3_5745_5825,
-    F4_5745_5825,
-    F5_5745_5825,
-    F6_5745_5825,
-
-    W1_4920_4980,
-    W1_5040_5080,
-    W1_5170_5230,
-    W1_5180_5240,
-    W1_5260_5320,
-    W1_5745_5825,
-    W1_5500_5700,
-};
-
-
-/* 2.4 GHz table - for 11b and 11g info */
-enum {
-    BG1_2312_2372,
-    BG2_2312_2372,
-
-    BG1_2412_2472,
-    BG2_2412_2472,
-    BG3_2412_2472,
-    BG4_2412_2472,
-
-    BG1_2412_2462,
-    BG2_2412_2462,
-
-    BG1_2432_2442,
-
-    BG1_2457_2472,
-
-    BG1_2467_2472,
-
-    BG1_2484_2484, /* No G */
-    BG2_2484_2484, /* No G */
-
-    BG1_2512_2732,
-
-    WBG1_2312_2372,
-    WBG1_2412_2412,
-    WBG1_2417_2432,
-    WBG1_2437_2442,
-    WBG1_2447_2457,
-    WBG1_2462_2462,
-    WBG1_2467_2467,
-    WBG2_2467_2467,
-    WBG1_2472_2472,
-    WBG2_2472_2472,
-    WBG1_2484_2484, /* No G */
-    WBG2_2484_2484, /* No G */
-};
-    
-#endif /* __REG_DBVALUE_H__ */
index 794ae2182a77e27ae624a30a2a1b3d41ad00f334..c866cefbd8fd8051e0ec2d10a09c4a6493a8ab90 100644 (file)
 #ifndef __TARGADDRS_H__
 #define __TARGADDRS_H__
 
-#ifndef ATH_TARGET
-#include "athstartpack.h"
-#endif
-
 #if defined(AR6002)
 #include "AR6002/addrs.h"
 #endif
@@ -91,15 +87,7 @@ PREPACK struct host_interest_s {
     /* Pointer to debug logging header */
     u32 hi_dbglog_hdr;                             /* 0x08 */
 
-    /* Indicates whether or not flash is present on Target.
-     * NB: flash_is_present indicator is here not just
-     * because it might be of interest to the Host; but
-     * also because it's set early on by Target's startup
-     * asm code and we need it to have a special RAM address
-     * so that it doesn't get reinitialized with the rest
-     * of data.
-     */
-    u32 hi_flash_is_present;                       /* 0x0c */
+    u32 hi_unused1;                       /* 0x0c */
 
     /*
      * General-purpose flag bits, similar to AR6000_OPTION_* flags.
@@ -113,7 +101,7 @@ PREPACK struct host_interest_s {
      */
     u32 hi_serial_enable;                          /* 0x14 */
 
-    /* Start address of Flash DataSet index, if any */
+    /* Start address of DataSet index, if any */
     u32 hi_dset_list_head;                         /* 0x18 */
 
     /* Override Target application start address */
@@ -171,35 +159,179 @@ PREPACK struct host_interest_s {
     u32 hi_hci_uart_support_pins;                  /* 0xa4 */
         /* NOTE: byte [0] = RESET pin (bit 7 is polarity), bytes[1]..bytes[3] are for future use */
     u32 hi_hci_uart_pwr_mgmt_params;               /* 0xa8 */
-        /* 0xa8 - [0]: 1 = enable, 0 = disable
-         *        [1]: 0 = UART FC active low, 1 = UART FC active high
-         * 0xa9 - [7:0]: wakeup timeout in ms
-         * 0xaa, 0xab - [15:0]: idle timeout in ms
-         */       
-    /* Pointer to extended board Data  */
-    u32 hi_board_ext_data;                         /* 0xac */
-    u32 hi_board_ext_data_initialized;             /* 0xb0 */
+       /*
+        * 0xa8   - [1]: 0 = UART FC active low, 1 = UART FC active high
+        *      [31:16]: wakeup timeout in ms
+        */
+
+       /* Pointer to extended board data */
+       u32 hi_board_ext_data;                /* 0xac */
+       u32 hi_board_ext_data_config;         /* 0xb0 */
+
+       /*
+         * Bit [0]  :   valid
+         * Bit[31:16:   size
+       */
+       /*
+        * hi_reset_flag is used to do some stuff when target reset.
+        * such as restore app_start after warm reset or
+        * preserve host Interest area, or preserve ROM data, literals etc.
+        */
+       u32 hi_reset_flag;                            /* 0xb4 */
+       /* indicate hi_reset_flag is valid */
+       u32 hi_reset_flag_valid;                      /* 0xb8 */
+       u32 hi_hci_uart_pwr_mgmt_params_ext;           /* 0xbc */
+       /*
+        * 0xbc - [31:0]: idle timeout in ms
+        */
+       /* ACS flags */
+       u32 hi_acs_flags;                              /* 0xc0 */
+       u32 hi_console_flags;                          /* 0xc4 */
+       u32 hi_nvram_state;                            /* 0xc8 */
+       u32 hi_option_flag2;                           /* 0xcc */
+
+       /* If non-zero, override values sent to Host in WMI_READY event. */
+       u32 hi_sw_version_override;                    /* 0xd0 */
+       u32 hi_abi_version_override;                   /* 0xd4 */
+
+       /*
+        * Percentage of high priority RX traffic to total expected RX traffic -
+        * applicable only to ar6004
+        */
+       u32 hi_hp_rx_traffic_ratio;                    /* 0xd8 */
+
+       /* test applications flags */
+       u32 hi_test_apps_related    ;                  /* 0xdc */
+       /* location of test script */
+       u32 hi_ota_testscript;                         /* 0xe0 */
+       /* location of CAL data */
+       u32 hi_cal_data;                               /* 0xe4 */
+       /* Number of packet log buffers */
+        u32 hi_pktlog_num_buffers;                     /* 0xe8 */
+
 } POSTPACK;
 
 /* Bits defined in hi_option_flag */
 #define HI_OPTION_TIMER_WAR       0x01 /* Enable timer workaround */
 #define HI_OPTION_BMI_CRED_LIMIT  0x02 /* Limit BMI command credits */
 #define HI_OPTION_RELAY_DOT11_HDR 0x04 /* Relay Dot11 hdr to/from host */
-#define HI_OPTION_FW_MODE_LSB     0x08 /* low bit of MODE (see below) */
-#define HI_OPTION_FW_MODE_MSB     0x10 /* high bit of MODE (see below) */
-#define HI_OPTION_ENABLE_PROFILE  0x20 /* Enable CPU profiling */
-#define HI_OPTION_DISABLE_DBGLOG  0x40 /* Disable debug logging */
-#define HI_OPTION_SKIP_ERA_TRACKING  0x80 /* Skip Era Tracking */
-#define HI_OPTION_PAPRD_DISABLE      0x100 /* Disable PAPRD (debug) */
+/* MAC addr method 0-locally administred 1-globally unique addrs */
+#define HI_OPTION_MAC_ADDR_METHOD   0x08
+#define HI_OPTION_FW_BRIDGE         0x10 /* Firmware Bridging */
+#define HI_OPTION_ENABLE_PROFILE    0x20 /* Enable CPU profiling */
+#define HI_OPTION_DISABLE_DBGLOG    0x40 /* Disable debug logging */
+#define HI_OPTION_SKIP_ERA_TRACKING 0x80 /* Skip Era Tracking */
+#define HI_OPTION_PAPRD_DISABLE     0x100 /* Disable PAPRD (debug) */
+#define HI_OPTION_NUM_DEV_LSB       0x200
+#define HI_OPTION_NUM_DEV_MSB       0x800
+#define HI_OPTION_DEV_MODE_LSB      0x1000
+#define HI_OPTION_DEV_MODE_MSB      0x8000000
+/* Disable LowFreq Timer Stabilization */
+#define HI_OPTION_NO_LFT_STBL       0x10000000
+#define HI_OPTION_SKIP_REG_SCAN     0x20000000 /* Skip regulatory scan */
+/* Do regulatory scan during init beforesending WMI ready event to host */
+#define HI_OPTION_INIT_REG_SCAN     0x40000000
+#define HI_OPTION_SKIP_MEMMAP       0x80000000 /* REV6: Do not adjust memory
+                                                map */
+
+/* hi_option_flag2 options */
+#define HI_OPTION_OFFLOAD_AMSDU     0x01
+#define HI_OPTION_DFS_SUPPORT       0x02 /* Enable DFS support */
+
+#define HI_OPTION_MAC_ADDR_METHOD_SHIFT 3
 
 /* 2 bits of hi_option_flag are used to represent 3 modes */
 #define HI_OPTION_FW_MODE_IBSS    0x0 /* IBSS Mode */
 #define HI_OPTION_FW_MODE_BSS_STA 0x1 /* STA Mode */
 #define HI_OPTION_FW_MODE_AP      0x2 /* AP Mode */
 
-/* Fw Mode Mask */
-#define HI_OPTION_FW_MODE_MASK    0x3
-#define HI_OPTION_FW_MODE_SHIFT   0x3
+/* 2 bits of hi_option flag are usedto represent 4 submodes */
+#define HI_OPTION_FW_SUBMODE_NONE    0x0  /* Normal mode */
+#define HI_OPTION_FW_SUBMODE_P2PDEV  0x1  /* p2p device mode */
+#define HI_OPTION_FW_SUBMODE_P2PCLIENT 0x2 /* p2p client mode */
+#define HI_OPTION_FW_SUBMODE_P2PGO   0x3 /* p2p go mode */
+
+/* Num dev Mask */
+#define HI_OPTION_NUM_DEV_MASK    0x7
+#define HI_OPTION_NUM_DEV_SHIFT   0x9
+
+/* firmware bridging */
+#define HI_OPTION_FW_BRIDGE_SHIFT 0x04
+
+/* Fw Mode/SubMode Mask
+|------------------------------------------------------------------------------|
+|   SUB   |   SUB   |   SUB   |  SUB    |         |         |         |
+| MODE[3] | MODE[2] | MODE[1] | MODE[0] | MODE[3] | MODE[2] | MODE[1] | MODE[0|
+|   (2)   |   (2)   |   (2)   |   (2)   |   (2)   |   (2)   |   (2)   |   (2)
+|------------------------------------------------------------------------------|
+*/
+#define HI_OPTION_FW_MODE_BITS         0x2
+#define HI_OPTION_FW_MODE_MASK         0x3
+#define HI_OPTION_FW_MODE_SHIFT        0xC
+#define HI_OPTION_ALL_FW_MODE_MASK     0xFF
+
+#define HI_OPTION_FW_SUBMODE_BITS      0x2
+#define HI_OPTION_FW_SUBMODE_MASK      0x3
+#define HI_OPTION_FW_SUBMODE_SHIFT     0x14
+#define HI_OPTION_ALL_FW_SUBMODE_MASK  0xFF00
+#define HI_OPTION_ALL_FW_SUBMODE_SHIFT 0x8
+
+/* hi_reset_flag */
+
+/* preserve App Start address */
+#define HI_RESET_FLAG_PRESERVE_APP_START         0x01
+/* preserve host interest */
+#define HI_RESET_FLAG_PRESERVE_HOST_INTEREST     0x02
+#define HI_RESET_FLAG_PRESERVE_ROMDATA           0x04  /* preserve ROM data */
+#define HI_RESET_FLAG_PRESERVE_NVRAM_STATE       0x08
+#define HI_RESET_FLAG_PRESERVE_BOOT_INFO         0x10
+
+#define HI_RESET_FLAG_IS_VALID  0x12345678 /* indicate the reset flag is
+valid */
+
+#define ON_RESET_FLAGS_VALID() \
+       (HOST_INTEREST->hi_reset_flag_valid == HI_RESET_FLAG_IS_VALID)
+
+#define RESET_FLAGS_VALIDATE()  \
+       (HOST_INTEREST->hi_reset_flag_valid = HI_RESET_FLAG_IS_VALID)
+
+#define RESET_FLAGS_INVALIDATE() \
+       (HOST_INTEREST->hi_reset_flag_valid = 0)
+
+#define ON_RESET_PRESERVE_APP_START() \
+        (HOST_INTEREST->hi_reset_flag & HI_RESET_FLAG_PRESERVE_APP_START)
+
+#define ON_RESET_PRESERVE_NVRAM_STATE() \
+        (HOST_INTEREST->hi_reset_flag & HI_RESET_FLAG_PRESERVE_NVRAM_STATE)
+
+#define ON_RESET_PRESERVE_HOST_INTEREST() \
+        (HOST_INTEREST->hi_reset_flag & HI_RESET_FLAG_PRESERVE_HOST_INTEREST)
+
+#define ON_RESET_PRESERVE_ROMDATA() \
+        (HOST_INTEREST->hi_reset_flag & HI_RESET_FLAG_PRESERVE_ROMDATA)
+
+#define ON_RESET_PRESERVE_BOOT_INFO() \
+        (HOST_INTEREST->hi_reset_flag & HI_RESET_FLAG_PRESERVE_BOOT_INFO)
+
+#define HI_ACS_FLAGS_ENABLED        (1 << 0)    /* ACS is enabled */
+#define HI_ACS_FLAGS_USE_WWAN       (1 << 1)    /* Use physical WWAN device */
+#define HI_ACS_FLAGS_TEST_VAP       (1 << 2)    /* Use test VAP */
+
+/* CONSOLE FLAGS
+ *
+ * Bit Range  Meaning
+ * ---------  --------------------------------
+ *   2..0     UART ID (0 = Default)
+ *    3       Baud Select (0 = 9600, 1 = 115200)
+ *   30..4    Reserved
+ *    31      Enable Console
+ *
+ */
+
+#define HI_CONSOLE_FLAGS_ENABLE       (1 << 31)
+#define HI_CONSOLE_FLAGS_UART_MASK    (0x7)
+#define HI_CONSOLE_FLAGS_UART_SHIFT   0
+#define HI_CONSOLE_FLAGS_BAUD_SELECT  (1 << 3)
 
 /*
  * Intended for use by Host software, this macro returns the Target RAM
@@ -212,34 +344,52 @@ PREPACK struct host_interest_s {
 #define AR6003_HOST_INTEREST_ITEM_ADDRESS(item) \
     (u32)((unsigned long)&((((struct host_interest_s *)(AR6003_HOST_INTEREST_ADDRESS))->item)))
 
+#define AR6004_HOST_INTEREST_ITEM_ADDRESS(item) \
+        ((u32)&((((struct host_interest_s *)(AR6004_HOST_INTEREST_ADDRESS))->item)))
+
+
 #define HOST_INTEREST_DBGLOG_IS_ENABLED() \
         (!(HOST_INTEREST->hi_option_flag & HI_OPTION_DISABLE_DBGLOG))
 
+#define HOST_INTEREST_PKTLOG_IS_ENABLED() \
+        ((HOST_INTEREST->hi_pktlog_num_buffers))
+
+
 #define HOST_INTEREST_PROFILE_IS_ENABLED() \
         (HOST_INTEREST->hi_option_flag & HI_OPTION_ENABLE_PROFILE)
 
+#define LF_TIMER_STABILIZATION_IS_ENABLED() \
+        (!(HOST_INTEREST->hi_option_flag & HI_OPTION_NO_LFT_STBL))
+
+#define IS_AMSDU_OFFLAOD_ENABLED() \
+        ((HOST_INTEREST->hi_option_flag2 & HI_OPTION_OFFLOAD_AMSDU))
+
+#define HOST_INTEREST_DFS_IS_ENABLED() \
+        ((HOST_INTEREST->hi_option_flag2 & HI_OPTION_DFS_SUPPORT))
+
 /* Convert a Target virtual address into a Target physical address */
 #define AR6002_VTOP(vaddr) ((vaddr) & 0x001fffff)
 #define AR6003_VTOP(vaddr) ((vaddr) & 0x001fffff)
 #define TARG_VTOP(TargetType, vaddr) \
         (((TargetType) == TARGET_TYPE_AR6002) ? AR6002_VTOP(vaddr) : AR6003_VTOP(vaddr))
 
-/* override REV2 ROM's app start address */
-#define AR6002_REV2_APP_START_OVERRIDE    0x911A00
-#define AR6003_REV1_APP_START_OVERRIDE    0x944c00
-#define AR6003_REV1_OTP_DATA_ADDRESS      0x542800
-#define AR6003_REV2_APP_START_OVERRIDE    0x945000
-#define AR6003_REV2_OTP_DATA_ADDRESS      0x543800
-#define AR6003_BOARD_EXT_DATA_ADDRESS     0x57E600
+#define AR6003_REV2_APP_START_OVERRIDE          0x944C00
+#define AR6003_REV2_APP_LOAD_ADDRESS            0x543180
+#define AR6003_REV2_BOARD_EXT_DATA_ADDRESS      0x57E500
+#define AR6003_REV2_DATASET_PATCH_ADDRESS       0x57e884
+#define AR6003_REV2_RAM_RESERVE_SIZE            6912
+
+#define AR6003_REV3_APP_START_OVERRIDE          0x945d00
+#define AR6003_REV3_APP_LOAD_ADDRESS            0x545000
+#define AR6003_REV3_BOARD_EXT_DATA_ADDRESS      0x542330
+#define AR6003_REV3_DATASET_PATCH_ADDRESS       0x57FF74
+#define AR6003_REV3_RAM_RESERVE_SIZE            512
 
+#define AR6003_BOARD_EXT_DATA_ADDRESS           0x57E600
 
 /* # of u32 entries in targregs, used by DIAG_FETCH_TARG_REGS */
 #define AR6003_FETCH_TARG_REGS_COUNT 64
 
 #endif /* !__ASSEMBLER__ */
 
-#ifndef ATH_TARGET
-#include "athendpack.h"
-#endif
-
 #endif /* __TARGADDRS_H__ */
diff --git a/drivers/staging/ath6kl/include/common/wlan_dset.h b/drivers/staging/ath6kl/include/common/wlan_dset.h
deleted file mode 100644 (file)
index e775b25..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-//------------------------------------------------------------------------------
-// Copyright (c) 2007-2010 Atheros Corporation.  All rights reserved.
-// 
-//
-// Permission to use, copy, modify, and/or distribute this software for any
-// purpose with or without fee is hereby granted, provided that the above
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-//
-//
-//------------------------------------------------------------------------------
-//==============================================================================
-// Author(s): ="Atheros"
-//==============================================================================
-
-#ifndef __WLAN_DSET_H__
-#define __WLAN_DSET_H__
-
-typedef PREPACK struct wow_config_dset {
-
-    u8 valid_dset;
-    u8 gpio_enable;
-    u16 gpio_pin;
-} POSTPACK WOW_CONFIG_DSET;
-
-#endif
index 4e6343485362813b95d3500a7eeeb2a8fe7f404a..d9687443d32ce7a19073f8884fc5fd5f5585dadb 100644 (file)
 #ifndef _WMI_H_
 #define _WMI_H_
 
-#ifndef ATH_TARGET
-#include "athstartpack.h"
-#endif
-
 #include "wmix.h"
 #include "wlan_defs.h"
 
@@ -118,7 +114,7 @@ typedef enum {
 typedef enum {
     WMI_DATA_HDR_DATA_TYPE_802_3 = 0,
     WMI_DATA_HDR_DATA_TYPE_802_11,
-    WMI_DATA_HDR_DATA_TYPE_ACL,
+    WMI_DATA_HDR_DATA_TYPE_ACL, /* used to be used for the PAL */
 } WMI_DATA_HDR_DATA_TYPE;
 
 #define WMI_DATA_HDR_DATA_TYPE_MASK     0x3
@@ -159,6 +155,16 @@ typedef enum {
 #define WMI_DATA_HDR_GET_META(h)        (((h)->info2 >> WMI_DATA_HDR_META_SHIFT) & WMI_DATA_HDR_META_MASK)
 #define WMI_DATA_HDR_SET_META(h, _v)    ((h)->info2 = ((h)->info2 & ~(WMI_DATA_HDR_META_MASK << WMI_DATA_HDR_META_SHIFT)) | ((_v) << WMI_DATA_HDR_META_SHIFT))
 
+/* Macros for operating on WMI_DATA_HDR (info3) field */
+#define WMI_DATA_HDR_DEVID_MASK      0xF
+#define WMI_DATA_HDR_DEVID_SHIFT     0
+#define GET_DEVID(_v)                ((_v) & WMI_DATA_HDR_DEVID_MASK)
+
+#define WMI_DATA_HDR_GET_DEVID(h) \
+       (((h)->info3 >> WMI_DATA_HDR_DEVID_SHIFT) & WMI_DATA_HDR_DEVID_MASK)
+#define WMI_DATA_HDR_SET_DEVID(h, _v) \
+       ((h)->info3 = ((h)->info3 & ~(WMI_DATA_HDR_DEVID_MASK << WMI_DATA_HDR_DEVID_SHIFT)) | (GET_DEVID(_v) << WMI_DATA_HDR_DEVID_SHIFT))
+
 typedef PREPACK struct {
     s8 rssi;
     u8 info;               /* usage of 'info' field(8-bit):
@@ -175,7 +181,7 @@ typedef PREPACK struct {
                                      * b12          - A-MSDU?
                                      * b15:b13      - META_DATA_VERSION 0 - 7
                                      */
-    u16 reserved;
+    u16 info3;
 } POSTPACK WMI_DATA_HDR;
 
 /*
@@ -259,6 +265,17 @@ typedef PREPACK struct {
 
 
 #define WMI_GET_DEVICE_ID(info1) ((info1) & 0xF)
+/* Macros for operating on WMI_CMD_HDR (info1) field */
+#define WMI_CMD_HDR_DEVID_MASK      0xF
+#define WMI_CMD_HDR_DEVID_SHIFT     0
+#define GET_CMD_DEVID(_v)           ((_v) & WMI_CMD_HDR_DEVID_MASK)
+
+#define WMI_CMD_HDR_GET_DEVID(h) \
+       (((h)->info1 >> WMI_CMD_HDR_DEVID_SHIFT) & WMI_CMD_HDR_DEVID_MASK)
+#define WMI_CMD_HDR_SET_DEVID(h, _v) \
+       ((h)->info1 = ((h)->info1 & \
+               ~(WMI_CMD_HDR_DEVID_MASK << WMI_CMD_HDR_DEVID_SHIFT)) | \
+                (GET_CMD_DEVID(_v) << WMI_CMD_HDR_DEVID_SHIFT))
 
 /*
  * Control Path
@@ -433,13 +450,47 @@ typedef enum {
     WMI_SET_BTCOEX_BT_OPERATING_STATUS_CMDID,
     WMI_GET_BTCOEX_STATS_CMDID,
     WMI_GET_BTCOEX_CONFIG_CMDID,
-    WMI_GET_PMK_CMDID,
-    WMI_SET_PASSPHRASE_CMDID,
-    WMI_ENABLE_WAC_CMDID,
-    WMI_WAC_SCAN_REPLY_CMDID,
-    WMI_WAC_CTRL_REQ_CMDID,
-    WMI_SET_DIV_PARAMS_CMDID,
-    WMI_SET_EXCESS_TX_RETRY_THRES_CMDID,
+
+       WMI_SET_DFS_ENABLE_CMDID,   /* F034 */
+       WMI_SET_DFS_MINRSSITHRESH_CMDID,
+       WMI_SET_DFS_MAXPULSEDUR_CMDID,
+       WMI_DFS_RADAR_DETECTED_CMDID,
+
+       /* P2P CMDS */
+       WMI_P2P_SET_CONFIG_CMDID,    /* F038 */
+       WMI_WPS_SET_CONFIG_CMDID,
+       WMI_SET_REQ_DEV_ATTR_CMDID,
+       WMI_P2P_FIND_CMDID,
+       WMI_P2P_STOP_FIND_CMDID,
+       WMI_P2P_GO_NEG_START_CMDID,
+       WMI_P2P_LISTEN_CMDID,
+
+       WMI_CONFIG_TX_MAC_RULES_CMDID,    /* F040 */
+       WMI_SET_PROMISCUOUS_MODE_CMDID,
+       WMI_RX_FRAME_FILTER_CMDID,
+       WMI_SET_CHANNEL_CMDID,
+
+       /* WAC commands */
+       WMI_ENABLE_WAC_CMDID,
+       WMI_WAC_SCAN_REPLY_CMDID,
+       WMI_WAC_CTRL_REQ_CMDID,
+       WMI_SET_DIV_PARAMS_CMDID,
+
+       WMI_GET_PMK_CMDID,
+       WMI_SET_PASSPHRASE_CMDID,
+       WMI_SEND_ASSOC_RES_CMDID,
+       WMI_SET_ASSOC_REQ_RELAY_CMDID,
+       WMI_GET_RFKILL_MODE_CMDID,
+
+       /* ACS command, consists of sub-commands */
+       WMI_ACS_CTRL_CMDID,
+
+       /* Ultra low power store / recall commands */
+       WMI_STORERECALL_CONFIGURE_CMDID,
+       WMI_STORERECALL_RECALL_CMDID,
+       WMI_STORERECALL_HOST_READY_CMDID,
+       WMI_FORCE_TARGET_ASSERT_CMDID,
+       WMI_SET_EXCESS_TX_RETRY_THRES_CMDID,
 } WMI_COMMAND_ID;
 
 /*
@@ -470,6 +521,11 @@ typedef enum {
     LEAP_AUTH           = 0x04,  /* different from IEEE_AUTH_MODE definitions */
 } DOT11_AUTH_MODE;
 
+enum {
+       AUTH_IDLE,
+       AUTH_OPEN_IN_PROGRESS,
+};
+
 typedef enum {
     NONE_AUTH           = 0x01,
     WPA_AUTH            = 0x02,
@@ -560,7 +616,7 @@ typedef PREPACK struct {
  * WMI_SET_EXCESS_TX_RETRY_THRES_CMDID
  */
 typedef PREPACK struct {
-    A_UINT32 threshold;
+    u32 threshold;
 } POSTPACK WMI_SET_EXCESS_TX_RETRY_THRES_CMD;
 
 /*
@@ -1969,12 +2025,47 @@ typedef enum {
 #endif
     WMI_REPORT_BTCOEX_STATS_EVENTID,
     WMI_REPORT_BTCOEX_CONFIG_EVENTID,
-    WMI_ACM_REJECT_EVENTID,
-    WMI_THIN_RESERVED_START_EVENTID = 0x8000,
-    /* Events in this range are reserved for thinmode 
-     * See wmi_thin.h for actual definitions */
-    WMI_THIN_RESERVED_END_EVENTID = 0x8fff,
-
+       WMI_GET_PMK_EVENTID,
+
+       /* DFS Events */
+       WMI_DFS_HOST_ATTACH_EVENTID,
+       WMI_DFS_HOST_INIT_EVENTID,
+       WMI_DFS_RESET_DELAYLINES_EVENTID,
+       WMI_DFS_RESET_RADARQ_EVENTID,
+       WMI_DFS_RESET_AR_EVENTID,
+       WMI_DFS_RESET_ARQ_EVENTID,
+       WMI_DFS_SET_DUR_MULTIPLIER_EVENTID,
+       WMI_DFS_SET_BANGRADAR_EVENTID,
+       WMI_DFS_SET_DEBUGLEVEL_EVENTID,
+       WMI_DFS_PHYERR_EVENTID,
+       /* CCX Evants */
+       WMI_CCX_RM_STATUS_EVENTID,
+
+       /* P2P Events */
+       WMI_P2P_GO_NEG_RESULT_EVENTID,
+
+       WMI_WAC_SCAN_DONE_EVENTID,
+       WMI_WAC_REPORT_BSS_EVENTID,
+       WMI_WAC_START_WPS_EVENTID,
+       WMI_WAC_CTRL_REQ_REPLY_EVENTID,
+
+       /* RFKILL Events */
+       WMI_RFKILL_STATE_CHANGE_EVENTID,
+       WMI_RFKILL_GET_MODE_CMD_EVENTID,
+       WMI_THIN_RESERVED_START_EVENTID = 0x8000,
+
+       /*
+        * Events in this range are reserved for thinmode
+        * See wmi_thin.h for actual definitions
+        */
+       WMI_THIN_RESERVED_END_EVENTID = 0x8fff,
+
+       WMI_SET_CHANNEL_EVENTID,
+       WMI_ASSOC_REQ_EVENTID,
+
+       /* generic ACS event */
+       WMI_ACS_EVENTID,
+       WMI_REPORT_WMM_PARAMS_EVENTID
 } WMI_EVENT_ID;
 
 
@@ -3122,10 +3213,6 @@ typedef PREPACK struct {
  * End of AP mode definitions
  */
 
-#ifndef ATH_TARGET
-#include "athendpack.h"
-#endif
-
 #ifdef __cplusplus
 }
 #endif
diff --git a/drivers/staging/ath6kl/include/common/wmi_thin.h b/drivers/staging/ath6kl/include/common/wmi_thin.h
deleted file mode 100644 (file)
index 0a8364c..0000000
+++ /dev/null
@@ -1,347 +0,0 @@
-//------------------------------------------------------------------------------
-// <copyright file="wmi_thin.h" company="Atheros">
-//    Copyright (c) 2004-2010 Atheros Corporation.  All rights reserved.
-// 
-//
-// Permission to use, copy, modify, and/or distribute this software for any
-// purpose with or without fee is hereby granted, provided that the above
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-//
-//
-//------------------------------------------------------------------------------
-//==============================================================================
-// Author(s): ="Atheros"
-//==============================================================================
-
-/*
- * This file contains the definitions of the WMI protocol specified in the
- * Wireless Module Interface (WMI).  It includes definitions of all the
- * commands and events. Commands are messages from the host to the WM.
- * Events and Replies are messages from the WM to the host.
- *
- * Ownership of correctness in regards to WMI commands
- * belongs to the host driver and the WM is not required to validate
- * parameters for value, proper range, or any other checking.
- *
- */
-
-#ifndef _WMI_THIN_H_
-#define _WMI_THIN_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-typedef enum {
-    WMI_THIN_CONFIG_CMDID =  0x8000, // WMI_THIN_RESERVED_START 
-    WMI_THIN_SET_MIB_CMDID,
-    WMI_THIN_GET_MIB_CMDID,
-    WMI_THIN_JOIN_CMDID,
-    /* add new CMDID's here */
-    WMI_THIN_RESERVED_END_CMDID = 0x8fff // WMI_THIN_RESERVED_END
-} WMI_THIN_COMMAND_ID;
-
-typedef enum{
-    TEMPLATE_FRM_FIRST = 0,
-    TEMPLATE_FRM_PROBE_REQ =TEMPLATE_FRM_FIRST,
-    TEMPLATE_FRM_BEACON,
-    TEMPLATE_FRM_PROBE_RESP,
-    TEMPLATE_FRM_NULL,
-    TEMPLATE_FRM_QOS_NULL,
-    TEMPLATE_FRM_PSPOLL,
-    TEMPLATE_FRM_MAX
-}WMI_TEMPLATE_FRM_TYPE;
-
-/* TEMPLATE_FRM_LEN... represent the maximum allowable
- * data lengths (bytes) for each frame type */
-#define TEMPLATE_FRM_LEN_PROBE_REQ  (256) /* Symbian dictates a minimum of 256 for these 3 frame types */
-#define TEMPLATE_FRM_LEN_BEACON     (256)
-#define TEMPLATE_FRM_LEN_PROBE_RESP (256)
-#define TEMPLATE_FRM_LEN_NULL       (32)
-#define TEMPLATE_FRM_LEN_QOS_NULL   (32)
-#define TEMPLATE_FRM_LEN_PSPOLL     (32)
-#define TEMPLATE_FRM_LEN_SUM (TEMPLATE_FRM_LEN_PROBE_REQ + TEMPLATE_FRM_LEN_BEACON + TEMPLATE_FRM_LEN_PROBE_RESP + \
-            TEMPLATE_FRM_LEN_NULL + TEMPLATE_FRM_LEN_QOS_NULL + TEMPLATE_FRM_LEN_PSPOLL)
-
-
-/* MAC Header Build Rules */
-/*  These values allow the host to configure the 
- *  target code that is responsible for constructing
- *  the MAC header.  In cases where the MAC header
- *  is provided by the host framework, the target
- *  has a diminished responsibility over what fields
- *  it must write. This will vary from framework to framework.
- *  Symbian requires different behavior from MAC80211 which
- *  requires different behavior from MS Native Wifi. */
-#define WMI_WRT_VER_TYPE    0x00000001
-#define WMI_WRT_DURATION    0x00000002
-#define WMI_WRT_DIRECTION   0x00000004
-#define WMI_WRT_POWER       0x00000008
-#define WMI_WRT_WEP         0x00000010
-#define WMI_WRT_MORE        0x00000020
-#define WMI_WRT_BSSID       0x00000040
-#define WMI_WRT_QOS         0x00000080
-#define WMI_WRT_SEQNO       0x00000100
-#define WMI_GUARD_TX        0x00000200 /* prevents TX ops that are not allowed for a current state */
-#define WMI_WRT_DEFAULT_CONFIG  (WMI_WRT_VER_TYPE | WMI_WRT_DURATION | WMI_WRT_DIRECTION | \
-                                 WMI_WRT_POWER | WMI_WRT_MORE | WMI_WRT_WEP | WMI_WRT_BSSID | \
-                                 WMI_WRT_QOS | WMI_WRT_SEQNO | WMI_GUARD_TX)
-
-/* WMI_THIN_CONFIG_TXCOMPLETE -- Used to configure the params and content for 
- *  TX Complete messages the will come from the Target.  these messages are 
- *  disabled by default but can be enabled using this structure and the 
- *  WMI_THIN_CONFIG_CMDID. */
-typedef PREPACK struct {
-    u8 version; /* the versioned type of messages to use or 0 to disable */
-    u8 countThreshold; /* msg count threshold triggering a tx complete message */
-    u16 timeThreshold; /* timeout interval in MSEC triggering a tx complete message */
-} POSTPACK WMI_THIN_CONFIG_TXCOMPLETE;
-
-/* WMI_THIN_CONFIG_DECRYPT_ERR -- Used to configure behavior for received frames 
- *  that have decryption errors.  The default behavior is to discard the frame
- *  without notification. Alternately, the MAC Header is forwarded to the host 
- *  with the failed status. */
-typedef PREPACK struct {
-    u8 enable; /* 1 == send decrypt errors to the host, 0 == don't */
-    u8 reserved[3]; /* align padding */
-} POSTPACK WMI_THIN_CONFIG_DECRYPT_ERR;
-
-/* WMI_THIN_CONFIG_TX_MAC_RULES -- Used to configure behavior for transmitted
- *  frames that require partial MAC header construction. These rules 
- *  are used by the target to indicate which fields need to be written. */
-typedef PREPACK struct {
-    u32 rules; /* combination of WMI_WRT_... values */
-} POSTPACK WMI_THIN_CONFIG_TX_MAC_RULES;
-
-/* WMI_THIN_CONFIG_RX_FILTER_RULES -- Used to configure behavior for received
- *  frames as to which frames should get forwarded to the host and which
- *  should get processed internally. */
-typedef PREPACK struct {
-    u32 rules; /* combination of WMI_FILT_... values */
-} POSTPACK WMI_THIN_CONFIG_RX_FILTER_RULES;
-
-/* WMI_THIN_CONFIG_CMD -- Used to contain some combination of the above
- *  WMI_THIN_CONFIG_... structures. The actual combination is indicated 
- *  by the value of cfgField. Each bit in this field corresponds to 
- *  one of the above structures. */
-typedef PREPACK struct {
-#define WMI_THIN_CFG_TXCOMP         0x00000001
-#define WMI_THIN_CFG_DECRYPT        0x00000002
-#define WMI_THIN_CFG_MAC_RULES      0x00000004
-#define WMI_THIN_CFG_FILTER_RULES   0x00000008
-    u32 cfgField;   /* combination of WMI_THIN_CFG_... describes contents of config command */
-    u16 length;     /* length in bytes of appended sub-commands */
-    u8 reserved[2];   /* align padding */
-} POSTPACK WMI_THIN_CONFIG_CMD;
-
-/* MIB Access Identifiers tailored for Symbian. */
-enum {
-    MIB_ID_STA_MAC = 1,             // [READONLY]
-    MIB_ID_RX_LIFE_TIME,            // [NOT IMPLEMENTED]
-    MIB_ID_SLOT_TIME,               // [READ/WRITE]
-    MIB_ID_RTS_THRESHOLD,           // [READ/WRITE]
-    MIB_ID_CTS_TO_SELF,             // [READ/WRITE]
-    MIB_ID_TEMPLATE_FRAME,          // [WRITE ONLY]
-    MIB_ID_RXFRAME_FILTER,          // [READ/WRITE]
-    MIB_ID_BEACON_FILTER_TABLE,     // [WRITE ONLY]
-    MIB_ID_BEACON_FILTER,           // [READ/WRITE]
-    MIB_ID_BEACON_LOST_COUNT,       // [WRITE ONLY]
-    MIB_ID_RSSI_THRESHOLD,          // [WRITE ONLY]
-    MIB_ID_HT_CAP,                  // [NOT IMPLEMENTED]
-    MIB_ID_HT_OP,                   // [NOT IMPLEMENTED]
-    MIB_ID_HT_2ND_BEACON,           // [NOT IMPLEMENTED]
-    MIB_ID_HT_BLOCK_ACK,            // [NOT IMPLEMENTED]
-    MIB_ID_PREAMBLE,                // [READ/WRITE]
-    /*MIB_ID_GROUP_ADDR_TABLE,*/
-    /*MIB_ID_WEP_DEFAULT_KEY_ID */
-    /*MIB_ID_TX_POWER */
-    /*MIB_ID_ARP_IP_TABLE */
-    /*MIB_ID_SLEEP_MODE */
-    /*MIB_ID_WAKE_INTERVAL*/
-    /*MIB_ID_STAT_TABLE*/
-    /*MIB_ID_IBSS_PWR_SAVE*/
-    /*MIB_ID_COUNTERS_TABLE*/
-    /*MIB_ID_ETHERTYPE_FILTER*/
-    /*MIB_ID_BC_UDP_FILTER*/
-       
-};
-
-typedef PREPACK struct {
-    u8 addr[ATH_MAC_LEN];
-} POSTPACK WMI_THIN_MIB_STA_MAC;
-
-typedef PREPACK struct {
-    u32 time; // units == msec
-} POSTPACK WMI_THIN_MIB_RX_LIFE_TIME;
-
-typedef PREPACK struct {
-    u8 enable; //1 = on, 0 = off
-} POSTPACK WMI_THIN_MIB_CTS_TO_SELF;
-
-typedef PREPACK struct {
-    u32 time; // units == usec
-} POSTPACK WMI_THIN_MIB_SLOT_TIME;
-
-typedef PREPACK struct {
-    u16 length; //units == bytes
-} POSTPACK WMI_THIN_MIB_RTS_THRESHOLD;
-
-typedef PREPACK struct {
-    u8 type; // type of frame
-    u8 rate; // tx rate to be used (one of WMI_BIT_RATE)
-    u16 length; // num bytes following this structure as the template data
-} POSTPACK WMI_THIN_MIB_TEMPLATE_FRAME;
-
-typedef PREPACK struct {
-#define FRAME_FILTER_PROMISCUOUS 0x00000001
-#define FRAME_FILTER_BSSID       0x00000002
-    u32 filterMask;
-} POSTPACK WMI_THIN_MIB_RXFRAME_FILTER;
-
-
-#define IE_FILTER_TREATMENT_CHANGE 1
-#define IE_FILTER_TREATMENT_APPEAR 2
-
-typedef PREPACK struct {
-    u8 ie;
-    u8 treatment;
-} POSTPACK WMI_THIN_MIB_BEACON_FILTER_TABLE;
-
-typedef PREPACK struct {
-    u8 ie;
-    u8 treatment;
-    u8 oui[3];
-    u8 type;
-    u16 version;
-} POSTPACK WMI_THIN_MIB_BEACON_FILTER_TABLE_OUI;
-
-typedef PREPACK struct {
-    u16 numElements;
-    u8 entrySize; // sizeof(WMI_THIN_MIB_BEACON_FILTER_TABLE) on host cpu may be 2 may be 4
-    u8 reserved;
-} POSTPACK WMI_THIN_MIB_BEACON_FILTER_TABLE_HEADER; 
-
-typedef PREPACK struct {
-    u32 count; /* num beacons between deliveries */
-    u8 enable;
-    u8 reserved[3];
-} POSTPACK WMI_THIN_MIB_BEACON_FILTER;
-
-typedef PREPACK struct {
-    u32 count; /* num consec lost beacons after which send event */
-} POSTPACK WMI_THIN_MIB_BEACON_LOST_COUNT;
-
-typedef PREPACK struct {
-    u8 rssi; /* the low threshold which can trigger an event warning */
-    u8 tolerance; /* the range above and below the threshold to prevent event flooding to the host. */
-    u8 count; /* the sample count of consecutive frames necessary to trigger an event. */
-    u8 reserved[1]; /* padding */
-} POSTPACK WMI_THIN_MIB_RSSI_THRESHOLD;
-
-
-typedef PREPACK struct {
-    u32 cap;
-    u32 rxRateField;
-    u32 beamForming;
-    u8 addr[ATH_MAC_LEN];
-    u8 enable;
-    u8 stbc;
-    u8 maxAMPDU;
-    u8 msduSpacing;
-    u8 mcsFeedback;
-    u8 antennaSelCap;
-} POSTPACK WMI_THIN_MIB_HT_CAP;
-
-typedef PREPACK struct {
-    u32 infoField;
-    u32 basicRateField;
-    u8 protection;
-    u8 secondChanneloffset;
-    u8 channelWidth;
-    u8 reserved;
-} POSTPACK WMI_THIN_MIB_HT_OP;
-
-typedef PREPACK struct {
-#define SECOND_BEACON_PRIMARY   1
-#define SECOND_BEACON_EITHER    2
-#define SECOND_BEACON_SECONDARY 3
-    u8 cfg;
-    u8 reserved[3]; /* padding */
-} POSTPACK WMI_THIN_MIB_HT_2ND_BEACON;
-
-typedef PREPACK struct {
-    u8 txTIDField;
-    u8 rxTIDField;
-    u8 reserved[2]; /* padding */
-} POSTPACK WMI_THIN_MIB_HT_BLOCK_ACK;
-
-typedef PREPACK struct {
-    u8 enableLong; // 1 == long preamble, 0 == short preamble
-    u8 reserved[3];
-} POSTPACK WMI_THIN_MIB_PREAMBLE;
-
-typedef PREPACK struct {    
-    u16 length;     /* the length in bytes of the appended MIB data */
-    u8 mibID;      /* the ID of the MIB element being set */
-    u8 reserved; /* align padding */
-} POSTPACK WMI_THIN_SET_MIB_CMD;
-
-typedef PREPACK struct {    
-    u8 mibID;      /* the ID of the MIB element being set */
-    u8 reserved[3]; /* align padding */
-} POSTPACK WMI_THIN_GET_MIB_CMD;
-
-typedef PREPACK struct {
-    u32 basicRateMask; /* bit mask of basic rates */
-    u32 beaconIntval; /* TUs */
-    u16 atimWindow; /* TUs */
-    u16 channel; /* frequency in Mhz */
-    u8 networkType; /* INFRA_NETWORK | ADHOC_NETWORK */
-    u8 ssidLength; /* 0 - 32 */
-    u8 probe;      /* != 0 : issue probe req at start */
-    u8 reserved;   /* alignment */
-    u8     ssid[WMI_MAX_SSID_LEN];    
-    u8 bssid[ATH_MAC_LEN];
-} POSTPACK WMI_THIN_JOIN_CMD;
-
-typedef PREPACK struct {
-    u16 dtim; /* dtim interval in num beacons */
-    u16 aid; /* 80211 AID from Assoc resp */
-} POSTPACK WMI_THIN_POST_ASSOC_CMD;
-
-typedef enum {
-    WMI_THIN_EVENTID_RESERVED_START           = 0x8000,
-    WMI_THIN_GET_MIB_EVENTID,
-    WMI_THIN_JOIN_EVENTID,
-    
-    /* Add new THIN EVENTID's here */
-    WMI_THIN_EVENTID_RESERVED_END           = 0x8fff    
-} WMI_THIN_EVENT_ID;
-
-/* Possible values for WMI_THIN_JOIN_EVENT.result */
-typedef enum {
-    WMI_THIN_JOIN_RES_SUCCESS = 0, // device has joined the network
-    WMI_THIN_JOIN_RES_FAIL, // device failed for unspecified reason
-    WMI_THIN_JOIN_RES_TIMEOUT, // device failed due to no beacon rx in time limit
-    WMI_THIN_JOIN_RES_BAD_PARAM, // device failed due to bad cmd param.
-}WMI_THIN_JOIN_RESULT;
-
-typedef PREPACK struct {
-    u8 result; /* the result of the join cmd. one of WMI_THIN_JOIN_RESULT */
-    u8 reserved[3]; /* alignment */
-} POSTPACK WMI_THIN_JOIN_EVENT;
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _WMI_THIN_H_ */
index 36acba66d49f321115dee8083160209125e6ff9e..9435eab1b7f5be3dcbda353e839e19ffe8b9262f 100644 (file)
 extern "C" {
 #endif
 
-#ifndef ATH_TARGET
-#include "athstartpack.h"
-#endif
-
 #include "dbglog.h"
 
 /*
@@ -148,7 +144,6 @@ typedef PREPACK struct {
  * All masks are 18-bit masks with bit N operating on GPIO pin N.
  */
 
-#include "gpio.h"
 
 /*
  * Set GPIO pin output state.
@@ -268,9 +263,6 @@ typedef PREPACK struct {
     u32 count;
 } POSTPACK WMIX_PROF_COUNT_EVENT;
 
-#ifndef ATH_TARGET
-#include "athendpack.h"
-#endif
 
 #ifdef __cplusplus
 }
index b6063347229f300504828367108280d5ac8ff361..34db29958bcbf37edd671e8307a96880035f6dfd 100644 (file)
@@ -81,10 +81,6 @@ int ar6000_set_htc_params(struct hif_device *hifDevice,
                                u32 MboxIsrYieldValue,
                                u8 HtcControlBuffers);
 
-int ar6000_prepare_target(struct hif_device *hifDevice,
-                               u32 TargetType,
-                               u32 TargetVersion);
-
 int ar6000_set_hci_bridge_flags(struct hif_device *hifDevice,
                                      u32 TargetType,
                                      u32 Flags);
diff --git a/drivers/staging/ath6kl/include/gpio_api.h b/drivers/staging/ath6kl/include/gpio_api.h
deleted file mode 100644 (file)
index 6b4c547..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-//------------------------------------------------------------------------------
-// <copyright file="gpio_api.h" company="Atheros">
-//    Copyright (c) 2004-2010 Atheros Corporation.  All rights reserved.
-// 
-//
-// Permission to use, copy, modify, and/or distribute this software for any
-// purpose with or without fee is hereby granted, provided that the above
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-//
-//
-//------------------------------------------------------------------------------
-//==============================================================================
-// Host-side General Purpose I/O API.
-//
-// Author(s): ="Atheros"
-//==============================================================================
-#ifndef _GPIO_API_H_
-#define _GPIO_API_H_
-
-/*
- * Send a command to the Target in order to change output on GPIO pins.
- */
-int wmi_gpio_output_set(struct wmi_t *wmip,
-                             u32 set_mask,
-                             u32 clear_mask,
-                             u32 enable_mask,
-                             u32 disable_mask);
-
-/*
- * Send a command to the Target requesting input state of GPIO pins.
- */
-int wmi_gpio_input_get(struct wmi_t *wmip);
-
-/*
- * Send a command to the Target to change the value of a GPIO register.
- */
-int wmi_gpio_register_set(struct wmi_t *wmip,
-                               u32 gpioreg_id,
-                               u32 value);
-
-/*
- * Send a command to the Target to fetch the value of a GPIO register.
- */
-int wmi_gpio_register_get(struct wmi_t *wmip, u32 gpioreg_id);
-
-/*
- * Send a command to the Target, acknowledging some GPIO interrupts.
- */
-int wmi_gpio_intr_ack(struct wmi_t *wmip, u32 ack_mask);
-
-#endif /* _GPIO_API_H_ */
index 83650d5ce3fb255891fb527f7a13fdf0c5976cea..24200e778c3bcb58d692b0817f58bcba37f5fff8 100644 (file)
@@ -32,7 +32,6 @@ extern "C" {
 /* Header files */
 #include "a_config.h"
 #include "athdefs.h"
-#include "a_types.h"
 #include "a_osapi.h"
 #include "dl_list.h"
 
@@ -148,7 +147,7 @@ typedef enum {
  *
  *   HIF_DEVICE_GET_MBOX_BLOCK_SIZE
  *   input : none
- *   output : array of 4 A_UINT32s
+ *   output : array of 4 u32s
  *   notes: block size is returned for each mailbox (4)
  *
  *   HIF_DEVICE_GET_MBOX_ADDR
diff --git a/drivers/staging/ath6kl/include/target_reg_table.h b/drivers/staging/ath6kl/include/target_reg_table.h
deleted file mode 100644 (file)
index e2225d5..0000000
+++ /dev/null
@@ -1,244 +0,0 @@
-//------------------------------------------------------------------------------
-// <copyright file="target_reg_table.h" company="Atheros">
-//    Copyright (c) 2004-2010 Atheros Corporation.  All rights reserved.
-// 
-//
-// Permission to use, copy, modify, and/or distribute this software for any
-// purpose with or without fee is hereby granted, provided that the above
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-//
-//
-//------------------------------------------------------------------------------
-//==============================================================================
-// Target register table macros and structure definitions
-//
-// Author(s): ="Atheros"
-//==============================================================================
-
-#ifndef TARGET_REG_TABLE_H_
-#define TARGET_REG_TABLE_H_
-
-#include "targaddrs.h"
-
-/*** WARNING : Add to the end of the TABLE! do not change the order ****/
-typedef struct targetdef_s {
-    u32 d_RTC_BASE_ADDRESS;
-    u32 d_SYSTEM_SLEEP_OFFSET;
-    u32 d_SYSTEM_SLEEP_DISABLE_LSB;
-    u32 d_SYSTEM_SLEEP_DISABLE_MASK;
-    u32 d_CLOCK_CONTROL_OFFSET;
-    u32 d_CLOCK_CONTROL_SI0_CLK_MASK;
-    u32 d_RESET_CONTROL_OFFSET;
-    u32 d_RESET_CONTROL_SI0_RST_MASK;
-    u32 d_GPIO_BASE_ADDRESS;
-    u32 d_GPIO_PIN0_OFFSET;
-    u32 d_GPIO_PIN1_OFFSET;
-    u32 d_GPIO_PIN0_CONFIG_MASK;
-    u32 d_GPIO_PIN1_CONFIG_MASK;
-    u32 d_SI_CONFIG_BIDIR_OD_DATA_LSB;
-    u32 d_SI_CONFIG_BIDIR_OD_DATA_MASK;
-    u32 d_SI_CONFIG_I2C_LSB;
-    u32 d_SI_CONFIG_I2C_MASK;
-    u32 d_SI_CONFIG_POS_SAMPLE_LSB;
-    u32 d_SI_CONFIG_POS_SAMPLE_MASK;
-    u32 d_SI_CONFIG_INACTIVE_CLK_LSB;
-    u32 d_SI_CONFIG_INACTIVE_CLK_MASK;
-    u32 d_SI_CONFIG_INACTIVE_DATA_LSB;
-    u32 d_SI_CONFIG_INACTIVE_DATA_MASK;
-    u32 d_SI_CONFIG_DIVIDER_LSB;
-    u32 d_SI_CONFIG_DIVIDER_MASK;
-    u32 d_SI_BASE_ADDRESS;
-    u32 d_SI_CONFIG_OFFSET;
-    u32 d_SI_TX_DATA0_OFFSET;
-    u32 d_SI_TX_DATA1_OFFSET;
-    u32 d_SI_RX_DATA0_OFFSET;
-    u32 d_SI_RX_DATA1_OFFSET;
-    u32 d_SI_CS_OFFSET;
-    u32 d_SI_CS_DONE_ERR_MASK;
-    u32 d_SI_CS_DONE_INT_MASK;
-    u32 d_SI_CS_START_LSB;
-    u32 d_SI_CS_START_MASK;
-    u32 d_SI_CS_RX_CNT_LSB;
-    u32 d_SI_CS_RX_CNT_MASK;
-    u32 d_SI_CS_TX_CNT_LSB;
-    u32 d_SI_CS_TX_CNT_MASK;
-    u32 d_BOARD_DATA_SZ;
-    u32 d_BOARD_EXT_DATA_SZ;
-} TARGET_REGISTER_TABLE;
-
-#define BOARD_DATA_SZ_MAX 2048
-
-#if defined(MY_TARGET_DEF) /* { */
-
-#ifdef ATH_REG_TABLE_DIRECT_ASSIGN
-
-static struct targetdef_s my_target_def = {
-    RTC_BASE_ADDRESS,
-    SYSTEM_SLEEP_OFFSET,
-    SYSTEM_SLEEP_DISABLE_LSB,
-    SYSTEM_SLEEP_DISABLE_MASK,
-    CLOCK_CONTROL_OFFSET,
-    CLOCK_CONTROL_SI0_CLK_MASK,
-    RESET_CONTROL_OFFSET,
-    RESET_CONTROL_SI0_RST_MASK,
-    GPIO_BASE_ADDRESS,
-    GPIO_PIN0_OFFSET,
-    GPIO_PIN0_CONFIG_MASK,
-    GPIO_PIN1_OFFSET,
-    GPIO_PIN1_CONFIG_MASK,
-    SI_CONFIG_BIDIR_OD_DATA_LSB,
-    SI_CONFIG_BIDIR_OD_DATA_MASK,
-    SI_CONFIG_I2C_LSB,
-    SI_CONFIG_I2C_MASK,
-    SI_CONFIG_POS_SAMPLE_LSB,
-    SI_CONFIG_POS_SAMPLE_MASK,
-    SI_CONFIG_INACTIVE_CLK_LSB,
-    SI_CONFIG_INACTIVE_CLK_MASK,
-    SI_CONFIG_INACTIVE_DATA_LSB,
-    SI_CONFIG_INACTIVE_DATA_MASK,
-    SI_CONFIG_DIVIDER_LSB,
-    SI_CONFIG_DIVIDER_MASK,
-    SI_BASE_ADDRESS,
-    SI_CONFIG_OFFSET,
-    SI_TX_DATA0_OFFSET,
-    SI_TX_DATA1_OFFSET,
-    SI_RX_DATA0_OFFSET,
-    SI_RX_DATA1_OFFSET,
-    SI_CS_OFFSET,
-    SI_CS_DONE_ERR_MASK,
-    SI_CS_DONE_INT_MASK,
-    SI_CS_START_LSB,
-    SI_CS_START_MASK,
-    SI_CS_RX_CNT_LSB,
-    SI_CS_RX_CNT_MASK,
-    SI_CS_TX_CNT_LSB,
-    SI_CS_TX_CNT_MASK,
-    MY_TARGET_BOARD_DATA_SZ,
-    MY_TARGET_BOARD_EXT_DATA_SZ,
-};
-
-#else
-
-static struct targetdef_s my_target_def = {
-    .d_RTC_BASE_ADDRESS = RTC_BASE_ADDRESS,
-    .d_SYSTEM_SLEEP_OFFSET = SYSTEM_SLEEP_OFFSET,
-    .d_SYSTEM_SLEEP_DISABLE_LSB = SYSTEM_SLEEP_DISABLE_LSB,
-    .d_SYSTEM_SLEEP_DISABLE_MASK = SYSTEM_SLEEP_DISABLE_MASK,
-    .d_CLOCK_CONTROL_OFFSET = CLOCK_CONTROL_OFFSET,
-    .d_CLOCK_CONTROL_SI0_CLK_MASK = CLOCK_CONTROL_SI0_CLK_MASK,
-    .d_RESET_CONTROL_OFFSET = RESET_CONTROL_OFFSET,
-    .d_RESET_CONTROL_SI0_RST_MASK = RESET_CONTROL_SI0_RST_MASK,
-    .d_GPIO_BASE_ADDRESS = GPIO_BASE_ADDRESS,
-    .d_GPIO_PIN0_OFFSET = GPIO_PIN0_OFFSET,
-    .d_GPIO_PIN0_CONFIG_MASK = GPIO_PIN0_CONFIG_MASK,
-    .d_GPIO_PIN1_OFFSET = GPIO_PIN1_OFFSET,
-    .d_GPIO_PIN1_CONFIG_MASK = GPIO_PIN1_CONFIG_MASK,
-    .d_SI_CONFIG_BIDIR_OD_DATA_LSB = SI_CONFIG_BIDIR_OD_DATA_LSB,
-    .d_SI_CONFIG_BIDIR_OD_DATA_MASK = SI_CONFIG_BIDIR_OD_DATA_MASK,
-    .d_SI_CONFIG_I2C_LSB = SI_CONFIG_I2C_LSB,
-    .d_SI_CONFIG_I2C_MASK = SI_CONFIG_I2C_MASK,
-    .d_SI_CONFIG_POS_SAMPLE_LSB = SI_CONFIG_POS_SAMPLE_LSB,
-    .d_SI_CONFIG_POS_SAMPLE_MASK = SI_CONFIG_POS_SAMPLE_MASK,
-    .d_SI_CONFIG_INACTIVE_CLK_LSB = SI_CONFIG_INACTIVE_CLK_LSB,
-    .d_SI_CONFIG_INACTIVE_CLK_MASK = SI_CONFIG_INACTIVE_CLK_MASK,
-    .d_SI_CONFIG_INACTIVE_DATA_LSB = SI_CONFIG_INACTIVE_DATA_LSB,
-    .d_SI_CONFIG_INACTIVE_DATA_MASK = SI_CONFIG_INACTIVE_DATA_MASK,
-    .d_SI_CONFIG_DIVIDER_LSB = SI_CONFIG_DIVIDER_LSB,
-    .d_SI_CONFIG_DIVIDER_MASK = SI_CONFIG_DIVIDER_MASK,
-    .d_SI_BASE_ADDRESS = SI_BASE_ADDRESS,
-    .d_SI_CONFIG_OFFSET = SI_CONFIG_OFFSET,
-    .d_SI_TX_DATA0_OFFSET = SI_TX_DATA0_OFFSET,
-    .d_SI_TX_DATA1_OFFSET = SI_TX_DATA1_OFFSET,
-    .d_SI_RX_DATA0_OFFSET = SI_RX_DATA0_OFFSET,
-    .d_SI_RX_DATA1_OFFSET = SI_RX_DATA1_OFFSET,
-    .d_SI_CS_OFFSET = SI_CS_OFFSET,
-    .d_SI_CS_DONE_ERR_MASK = SI_CS_DONE_ERR_MASK,
-    .d_SI_CS_DONE_INT_MASK = SI_CS_DONE_INT_MASK,
-    .d_SI_CS_START_LSB = SI_CS_START_LSB,
-    .d_SI_CS_START_MASK = SI_CS_START_MASK,
-    .d_SI_CS_RX_CNT_LSB = SI_CS_RX_CNT_LSB,
-    .d_SI_CS_RX_CNT_MASK = SI_CS_RX_CNT_MASK,
-    .d_SI_CS_TX_CNT_LSB = SI_CS_TX_CNT_LSB,
-    .d_SI_CS_TX_CNT_MASK = SI_CS_TX_CNT_MASK,
-    .d_BOARD_DATA_SZ = MY_TARGET_BOARD_DATA_SZ,
-    .d_BOARD_EXT_DATA_SZ = MY_TARGET_BOARD_EXT_DATA_SZ,
-};
-
-#endif
-
-#if MY_TARGET_BOARD_DATA_SZ > BOARD_DATA_SZ_MAX
-#error "BOARD_DATA_SZ_MAX is too small"
-#endif
-
-struct targetdef_s *MY_TARGET_DEF = &my_target_def;
-
-#else /* } { */
-
-#define RTC_BASE_ADDRESS (targetdef->d_RTC_BASE_ADDRESS)
-#define SYSTEM_SLEEP_OFFSET (targetdef->d_SYSTEM_SLEEP_OFFSET)
-#define SYSTEM_SLEEP_DISABLE_LSB (targetdef->d_SYSTEM_SLEEP_DISABLE_LSB)
-#define SYSTEM_SLEEP_DISABLE_MASK (targetdef->d_SYSTEM_SLEEP_DISABLE_MASK)
-#define CLOCK_CONTROL_OFFSET (targetdef->d_CLOCK_CONTROL_OFFSET)
-#define CLOCK_CONTROL_SI0_CLK_MASK (targetdef->d_CLOCK_CONTROL_SI0_CLK_MASK)
-#define RESET_CONTROL_OFFSET (targetdef->d_RESET_CONTROL_OFFSET)
-#define RESET_CONTROL_SI0_RST_MASK (targetdef->d_RESET_CONTROL_SI0_RST_MASK)
-#define GPIO_BASE_ADDRESS (targetdef->d_GPIO_BASE_ADDRESS)
-#define GPIO_PIN0_OFFSET (targetdef->d_GPIO_PIN0_OFFSET)
-#define GPIO_PIN0_CONFIG_MASK (targetdef->d_GPIO_PIN0_CONFIG_MASK)
-#define GPIO_PIN1_OFFSET (targetdef->d_GPIO_PIN1_OFFSET)
-#define GPIO_PIN1_CONFIG_MASK (targetdef->d_GPIO_PIN1_CONFIG_MASK)
-#define SI_CONFIG_BIDIR_OD_DATA_LSB (targetdef->d_SI_CONFIG_BIDIR_OD_DATA_LSB)
-#define SI_CONFIG_BIDIR_OD_DATA_MASK (targetdef->d_SI_CONFIG_BIDIR_OD_DATA_MASK)
-#define SI_CONFIG_I2C_LSB (targetdef->d_SI_CONFIG_I2C_LSB)
-#define SI_CONFIG_I2C_MASK (targetdef->d_SI_CONFIG_I2C_MASK)
-#define SI_CONFIG_POS_SAMPLE_LSB (targetdef->d_SI_CONFIG_POS_SAMPLE_LSB)
-#define SI_CONFIG_POS_SAMPLE_MASK (targetdef->d_SI_CONFIG_POS_SAMPLE_MASK)
-#define SI_CONFIG_INACTIVE_CLK_LSB (targetdef->d_SI_CONFIG_INACTIVE_CLK_LSB)
-#define SI_CONFIG_INACTIVE_CLK_MASK (targetdef->d_SI_CONFIG_INACTIVE_CLK_MASK)
-#define SI_CONFIG_INACTIVE_DATA_LSB (targetdef->d_SI_CONFIG_INACTIVE_DATA_LSB)
-#define SI_CONFIG_INACTIVE_DATA_MASK (targetdef->d_SI_CONFIG_INACTIVE_DATA_MASK)
-#define SI_CONFIG_DIVIDER_LSB (targetdef->d_SI_CONFIG_DIVIDER_LSB)
-#define SI_CONFIG_DIVIDER_MASK (targetdef->d_SI_CONFIG_DIVIDER_MASK)
-#define SI_BASE_ADDRESS (targetdef->d_SI_BASE_ADDRESS)
-#define SI_CONFIG_OFFSET (targetdef->d_SI_CONFIG_OFFSET)
-#define SI_TX_DATA0_OFFSET (targetdef->d_SI_TX_DATA0_OFFSET)
-#define SI_TX_DATA1_OFFSET (targetdef->d_SI_TX_DATA1_OFFSET)
-#define SI_RX_DATA0_OFFSET (targetdef->d_SI_RX_DATA0_OFFSET)
-#define SI_RX_DATA1_OFFSET (targetdef->d_SI_RX_DATA1_OFFSET)
-#define SI_CS_OFFSET (targetdef->d_SI_CS_OFFSET)
-#define SI_CS_DONE_ERR_MASK (targetdef->d_SI_CS_DONE_ERR_MASK)
-#define SI_CS_DONE_INT_MASK (targetdef->d_SI_CS_DONE_INT_MASK)
-#define SI_CS_START_LSB (targetdef->d_SI_CS_START_LSB)
-#define SI_CS_START_MASK (targetdef->d_SI_CS_START_MASK)
-#define SI_CS_RX_CNT_LSB (targetdef->d_SI_CS_RX_CNT_LSB)
-#define SI_CS_RX_CNT_MASK (targetdef->d_SI_CS_RX_CNT_MASK)
-#define SI_CS_TX_CNT_LSB (targetdef->d_SI_CS_TX_CNT_LSB)
-#define SI_CS_TX_CNT_MASK (targetdef->d_SI_CS_TX_CNT_MASK)
-#define EEPROM_SZ (targetdef->d_BOARD_DATA_SZ)
-#define EEPROM_EXT_SZ (targetdef->d_BOARD_EXT_DATA_SZ)
-
-/* SET macros */
-#define SYSTEM_SLEEP_DISABLE_SET(x)              (((x) << SYSTEM_SLEEP_DISABLE_LSB) & SYSTEM_SLEEP_DISABLE_MASK)
-#define SI_CONFIG_BIDIR_OD_DATA_SET(x) (((x) << SI_CONFIG_BIDIR_OD_DATA_LSB) & SI_CONFIG_BIDIR_OD_DATA_MASK)
-#define SI_CONFIG_I2C_SET(x) (((x) << SI_CONFIG_I2C_LSB) & SI_CONFIG_I2C_MASK)
-#define SI_CONFIG_POS_SAMPLE_SET(x) (((x) << SI_CONFIG_POS_SAMPLE_LSB) & SI_CONFIG_POS_SAMPLE_MASK)
-#define SI_CONFIG_INACTIVE_CLK_SET(x) (((x) << SI_CONFIG_INACTIVE_CLK_LSB) & SI_CONFIG_INACTIVE_CLK_MASK)
-#define SI_CONFIG_INACTIVE_DATA_SET(x) (((x) << SI_CONFIG_INACTIVE_DATA_LSB) & SI_CONFIG_INACTIVE_DATA_MASK)
-#define SI_CONFIG_DIVIDER_SET(x) (((x) << SI_CONFIG_DIVIDER_LSB) & SI_CONFIG_DIVIDER_MASK)
-#define SI_CS_START_SET(x) (((x) << SI_CS_START_LSB) & SI_CS_START_MASK)
-#define SI_CS_RX_CNT_SET(x) (((x) << SI_CS_RX_CNT_LSB) & SI_CS_RX_CNT_MASK)
-#define SI_CS_TX_CNT_SET(x) (((x) << SI_CS_TX_CNT_LSB) & SI_CS_TX_CNT_MASK)
-
-#endif /* } */
-
-#endif /*TARGET_REG_TABLE_H_*/
-
-
index 4f18f4306465594a1801db42b43c3bb0c886f45a..e0ea2183019dd9a0d03d67791f49bbcd3a50e4f8 100644 (file)
@@ -24,7 +24,6 @@
 
 #include "a_config.h"
 #include "athdefs.h"
-#include "a_types.h"
 #include "a_osapi.h"
 #define ATH_MODULE_NAME misc
 #include "a_debug.h"
@@ -78,7 +77,7 @@ static int SendHCICommand(struct ar3k_config_info *pConfig,
     } while (false);
    
     if (pPacket != NULL) {
-        A_FREE(pPacket);
+        kfree(pPacket);
     }
         
     return status;
@@ -116,7 +115,7 @@ static int RecvHCIEvent(struct ar3k_config_info *pConfig,
     } while (false);
        
     if (pRecvPacket != NULL) {
-        A_FREE(pRecvPacket);    
+        kfree(pRecvPacket);    
     }
     
     return status;
@@ -203,7 +202,7 @@ int SendHCICommandWaitCommandComplete(struct ar3k_config_info *pConfig,
     } while (false);
 
     if (pBuffer != NULL) {
-        A_FREE(pBuffer);    
+        kfree(pBuffer);    
     }
     
     return status;    
@@ -268,7 +267,7 @@ static int AR3KConfigureHCIBaud(struct ar3k_config_info *pConfig)
     } while (false);
                         
     if (pBufferToFree != NULL) {
-        A_FREE(pBufferToFree);    
+        kfree(pBufferToFree);    
     }
         
     return status;
@@ -304,7 +303,7 @@ static int AR3KExitMinBoot(struct ar3k_config_info *pConfig)
     }
     
     if (pBufferToFree != NULL) {
-        A_FREE(pBufferToFree);    
+        kfree(pBufferToFree);    
     }
     
     return status;                                              
@@ -328,7 +327,7 @@ static int AR3KConfigureSendHCIReset(struct ar3k_config_info *pConfig)
     }
 
     if (pBufferToFree != NULL) {
-        A_FREE(pBufferToFree);
+        kfree(pBufferToFree);
     }
 
     return status;
@@ -382,7 +381,7 @@ static int AR3KEnableTLPM(struct ar3k_config_info *pConfig)
                                                &pEvent,
                                                &pBufferToFree);
     if (pBufferToFree != NULL) {
-        A_FREE(pBufferToFree);    
+        kfree(pBufferToFree);    
     }
     if (status) {
         AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("HostWakeup Config Failed! \n"));    
@@ -397,7 +396,7 @@ static int AR3KEnableTLPM(struct ar3k_config_info *pConfig)
                                                &pEvent,
                                                &pBufferToFree);
     if (pBufferToFree != NULL) {
-        A_FREE(pBufferToFree);    
+        kfree(pBufferToFree);    
     }
     if (status) {
         AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Target Wakeup Config Failed! \n"));    
@@ -412,7 +411,7 @@ static int AR3KEnableTLPM(struct ar3k_config_info *pConfig)
                                                &pEvent,
                                                &pBufferToFree);
     if (pBufferToFree != NULL) {
-        A_FREE(pBufferToFree);    
+        kfree(pBufferToFree);    
     }
     if (status) {
         AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("HostWakeup Enable Failed! \n"));    
@@ -427,7 +426,7 @@ static int AR3KEnableTLPM(struct ar3k_config_info *pConfig)
                                                &pEvent,
                                                &pBufferToFree);
     if (pBufferToFree != NULL) {
-        A_FREE(pBufferToFree);    
+        kfree(pBufferToFree);    
     }
     if (status) {
         AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Target Wakeup Enable Failed! \n"));    
@@ -442,7 +441,7 @@ static int AR3KEnableTLPM(struct ar3k_config_info *pConfig)
                                                &pEvent,
                                                &pBufferToFree);
     if (pBufferToFree != NULL) {
-        A_FREE(pBufferToFree);    
+        kfree(pBufferToFree);    
     }
     if (status) {
         AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Sleep Enable Failed! \n"));    
index 8393efe69f5b96460feae0336240c54dd29b9bbb..282ceac597b8f28d2191b08ebf4f5d867796f741 100644 (file)
@@ -222,7 +222,7 @@ int PSSendOps(void *arg)
         A_RELEASE_FIRMWARE(firmware);
         /* Parse the PS buffer to a global variable */
         status = AthDoParsePS(buffer,len);
-        A_FREE(buffer);
+        kfree(buffer);
     } else {
         A_RELEASE_FIRMWARE(firmware);
     }
@@ -256,7 +256,7 @@ int PSSendOps(void *arg)
                 A_RELEASE_FIRMWARE(firmware);
                 /* parse and store the Patch file contents to a global variables */
                 status = AthDoParsePatch(buffer,len);
-                A_FREE(buffer);
+                kfree(buffer);
             } else {
                 A_RELEASE_FIRMWARE(firmware);
             }
@@ -283,7 +283,7 @@ int PSSendOps(void *arg)
     &bufferToFree) == 0) {
         if(ReadPSEvent(event) == 0) { /* Exit if the status is success */
             if(bufferToFree != NULL) {
-                A_FREE(bufferToFree);
+                kfree(bufferToFree);
                 }
        
 #ifndef HCI_TRANSPORT_SDIO
@@ -295,7 +295,7 @@ int PSSendOps(void *arg)
                goto complete;
         }
         if(bufferToFree != NULL) {
-               A_FREE(bufferToFree);
+               kfree(bufferToFree);
         }
     } else {
         status = 0;
@@ -312,13 +312,13 @@ int PSSendOps(void *arg)
         &bufferToFree) == 0) {
             if(ReadPSEvent(event) != 0) { /* Exit if the status is success */
                 if(bufferToFree != NULL) {
-                    A_FREE(bufferToFree);
+                    kfree(bufferToFree);
                     }
                    status = 1;
                     goto complete;
             }
             if(bufferToFree != NULL) {
-                   A_FREE(bufferToFree);
+                   kfree(bufferToFree);
             }
         } else {
             status = 0;
@@ -376,10 +376,10 @@ complete:
         AthFreeCommandList(&HciCmdList,numCmds);
     }
     if(path) {
-        A_FREE(path);
+        kfree(path);
     }
     if(config_path) {
-        A_FREE(config_path);
+        kfree(config_path);
     }
     return status;
 }
@@ -511,7 +511,7 @@ int write_bdaddr(struct ar3k_config_info *pConfig,u8 *bdaddr,int type)
 
     }
     if(bufferToFree != NULL) {
-        A_FREE(bufferToFree);
+        kfree(bufferToFree);
    }
     return result;
 
@@ -527,7 +527,7 @@ int ReadVersionInfo(struct ar3k_config_info *pConfig)
 
     }
     if(bufferToFree != NULL) {
-        A_FREE(bufferToFree);
+        kfree(bufferToFree);
    }
     return result;
 }
@@ -564,7 +564,7 @@ int getDeviceType(struct ar3k_config_info *pConfig, u32 *code)
 
     }
     if(bufferToFree != NULL) {
-        A_FREE(bufferToFree);
+        kfree(bufferToFree);
    }
     return result;
 }
index 94a0939bfbf2fb538d71c92d2a953fe96a7d9122..c01c0cb0af4e83ced297d74b04b44b89d53733e7 100644 (file)
@@ -362,7 +362,7 @@ int AthParseFilesUnified(u8 *srcbuffer,u32 srclen, int FileFormat)
              {
                  AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("error\n"));
                  if(Buffer != NULL) {
-                     A_FREE(Buffer);
+                     kfree(Buffer);
                  }
                  return A_ERROR;
              }
@@ -401,7 +401,7 @@ int AthParseFilesUnified(u8 *srcbuffer,u32 srclen, int FileFormat)
                     if(uGetInputDataFormat(pCharLine, &stPS_DataFormat)) {
                         AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("uGetInputDataFormat fail\n"));
                      if(Buffer != NULL) {
-                             A_FREE(Buffer);
+                             kfree(Buffer);
                      }
                         return A_ERROR;
                     }    
@@ -422,7 +422,7 @@ int AthParseFilesUnified(u8 *srcbuffer,u32 srclen, int FileFormat)
                     if(uGetInputDataFormat(pCharLine, &stPS_DataFormat)) {
                         AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("uGetInputDataFormat fail \n"));
                      if(Buffer != NULL) {
-                             A_FREE(Buffer);
+                             kfree(Buffer);
                      }
                         return A_ERROR;
                     }
@@ -433,7 +433,7 @@ int AthParseFilesUnified(u8 *srcbuffer,u32 srclen, int FileFormat)
                     if (ByteCount > LINE_SIZE_MAX/2)
                     {
                      if(Buffer != NULL) {
-                             A_FREE(Buffer);
+                             kfree(Buffer);
                      }
                        return A_ERROR;
                     }
@@ -449,7 +449,7 @@ int AthParseFilesUnified(u8 *srcbuffer,u32 srclen, int FileFormat)
                         if(uGetInputDataFormat(pCharLine,&stPS_DataFormat)) {
                             AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("uGetInputDataFormat Fail\n"));
                             if(Buffer != NULL) {
-                                 A_FREE(Buffer);
+                                 kfree(Buffer);
                          }
                             return A_ERROR;
                         }
@@ -510,7 +510,7 @@ int AthParseFilesUnified(u8 *srcbuffer,u32 srclen, int FileFormat)
                     {
                        AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("\n Buffer over flow PS File too big!!!"));
                        if(Buffer != NULL) {
-                           A_FREE(Buffer);
+                           kfree(Buffer);
                        }
                        return A_ERROR;
                        //Sleep (3000);
@@ -524,7 +524,7 @@ int AthParseFilesUnified(u8 *srcbuffer,u32 srclen, int FileFormat)
              default:
              {
                    if(Buffer != NULL) {
-                       A_FREE(Buffer);
+                       kfree(Buffer);
                    }
                    return A_ERROR;
              }
@@ -541,13 +541,13 @@ int AthParseFilesUnified(u8 *srcbuffer,u32 srclen, int FileFormat)
    {
 
       if(Buffer != NULL) {
-           A_FREE(Buffer);
+           kfree(Buffer);
       }
       return A_ERROR;
    }
 
    if(Buffer != NULL) {
-        A_FREE(Buffer);
+        kfree(Buffer);
    }
    return 0;
 
@@ -609,7 +609,7 @@ int AthDoParsePatch(u8 *patchbuffer, u32 patchlen)
         /* Handle case when the number of patch buffer is more than the 20K */
         if(MAX_NUM_PATCH_ENTRY == Patch_Count) {
             for(i = 0; i < Patch_Count; i++) {
-                A_FREE(RamPatch[i].Data);
+                kfree(RamPatch[i].Data);
             }
             return A_ERROR;
         }
@@ -812,13 +812,13 @@ int AthCreateCommandList(struct ps_cmd_packet **HciPacketList, u32 *numPackets)
     for(count = 0; count < Patch_Count; count++) {
 
         AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Freeing Patch Buffer %d \r\n",count));
-        A_FREE(RamPatch[Patch_Count].Data);
+        kfree(RamPatch[Patch_Count].Data);
     }
 
     for(count = 0; count < Tag_Count; count++) {
 
         AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Freeing PS Buffer %d \r\n",count));
-        A_FREE(PsTagEntry[count].TagData);
+        kfree(PsTagEntry[count].TagData);
     }
 
 /* 
@@ -962,8 +962,8 @@ int AthFreeCommandList(struct ps_cmd_packet **HciPacketList, u32 numPackets)
         return A_ERROR;
     }
     for(i = 0; i < numPackets;i++) {
-        A_FREE((*HciPacketList)[i].Hcipacket);
+        kfree((*HciPacketList)[i].Hcipacket);
     }  
-    A_FREE(*HciPacketList);
+    kfree(*HciPacketList);
     return 0;
 }
index 9378efcd586efbeaa853a4f7c8bf976de42cf519..4e0f2f713a40edc53245ddb89e34ee19deccd8f5 100644 (file)
@@ -33,7 +33,6 @@
 #include "athdefs.h"
 #ifdef HCI_TRANSPORT_SDIO
 #include "a_config.h"
-#include "a_types.h"
 #include "a_osapi.h"
 #define ATH_MODULE_NAME misc
 #include "a_debug.h"
 #ifndef A_MALLOC
 #define A_MALLOC(size)  kmalloc((size),GFP_KERNEL)
 #endif /* A_MALLOC */
-
-
-#ifndef A_FREE
-#define A_FREE(addr)  kfree((addr))
-#endif /* A_MALLOC */
 #endif /* HCI_TRANSPORT_UART */
 
 /* String manipulation APIs */
index a23a52412b3d216db95a3fe32dd172076e03a04b..1ce539aa019bac11909aa029c421f2f54b7c2e67 100644 (file)
 
 #include "a_config.h"
 #include "athdefs.h"
-#include "a_types.h"
 
-#include "AR6002/hw2.0/hw/mbox_host_reg.h"
-#include "AR6002/hw2.0/hw/apb_map.h"
-#include "AR6002/hw2.0/hw/si_reg.h"
-#include "AR6002/hw2.0/hw/gpio_reg.h"
-#include "AR6002/hw2.0/hw/rtc_reg.h"
-#include "AR6002/hw2.0/hw/vmc_reg.h"
-#include "AR6002/hw2.0/hw/mbox_reg.h"
+#include "hw/mbox_host_reg.h"
+#include "gpio_reg.h"
+#include "hw/rtc_reg.h"
+#include "hw/mbox_reg.h"
+#include "hw/apb_map.h"
 
 #include "a_osapi.h"
 #include "targaddrs.h"
@@ -683,119 +680,6 @@ int ar6000_set_htc_params(struct hif_device *hifDevice,
     return status;
 }
 
-
-static int prepare_ar6002(struct hif_device *hifDevice, u32 TargetVersion)
-{
-    int status = 0;
-
-    /* placeholder */
-
-    return status;
-}
-
-static int prepare_ar6003(struct hif_device *hifDevice, u32 TargetVersion)
-{
-    int status = 0;
-
-    /* placeholder */
-
-    return status;
-}
-
-/* this function assumes the caller has already initialized the BMI APIs */
-int ar6000_prepare_target(struct hif_device *hifDevice,
-                               u32 TargetType,
-                               u32 TargetVersion)
-{
-    if (TargetType == TARGET_TYPE_AR6002) {
-            /* do any preparations for AR6002 devices */
-        return prepare_ar6002(hifDevice,TargetVersion);
-    } else if (TargetType == TARGET_TYPE_AR6003) {
-        return prepare_ar6003(hifDevice,TargetVersion);
-    }
-
-    return 0;
-}
-
-#if defined(CONFIG_AR6002_REV1_FORCE_HOST)
-/*
- * Call this function just before the call to BMIInit
- * in order to force* AR6002 rev 1.x firmware to detect a Host.
- * THIS IS FOR USE ONLY WITH AR6002 REV 1.x.
- * TBDXXX: Remove this function when REV 1.x is desupported.
- */
-int
-ar6002_REV1_reset_force_host (struct hif_device *hifDevice)
-{
-    s32 i;
-    struct forceROM_s {
-        u32 addr;
-        u32 data;
-    };
-    struct forceROM_s *ForceROM;
-    s32 szForceROM;
-    int status = 0;
-    u32 address;
-    u32 data;
-
-    /* Force AR6002 REV1.x to recognize Host presence.
-     *
-     * Note: Use RAM at 0x52df80..0x52dfa0 with ROM Remap entry 0
-     * so that this workaround functions with AR6002.war1.sh.  We
-     * could fold that entire workaround into this one, but it's not
-     * worth the effort at this point.  This workaround cannot be
-     * merged into the other workaround because this must be done
-     * before BMI.
-     */
-
-    static struct forceROM_s ForceROM_NEW[] = {
-        {0x52df80, 0x20f31c07},
-        {0x52df84, 0x92374420},
-        {0x52df88, 0x1d120c03},
-        {0x52df8c, 0xff8216f0},
-        {0x52df90, 0xf01d120c},
-        {0x52df94, 0x81004136},
-        {0x52df98, 0xbc9100bd},
-        {0x52df9c, 0x00bba100},
-
-        {0x00008000|MC_TCAM_TARGET_ADDRESS, 0x0012dfe0}, /* Use remap entry 0 */
-        {0x00008000|MC_TCAM_COMPARE_ADDRESS, 0x000e2380},
-        {0x00008000|MC_TCAM_MASK_ADDRESS, 0x00000000},
-        {0x00008000|MC_TCAM_VALID_ADDRESS, 0x00000001},
-
-        {0x00018000|(LOCAL_COUNT_ADDRESS+0x10), 0}, /* clear BMI credit counter */
-
-        {0x00004000|AR6002_RESET_CONTROL_ADDRESS, RESET_CONTROL_WARM_RST_MASK},
-    };
-
-    address = 0x004ed4b0; /* REV1 target software ID is stored here */
-    status = ar6000_ReadRegDiag(hifDevice, &address, &data);
-    if (status || (data != AR6002_VERSION_REV1)) {
-        return A_ERROR; /* Not AR6002 REV1 */
-    }
-
-    ForceROM = ForceROM_NEW;
-    szForceROM = sizeof(ForceROM_NEW)/sizeof(*ForceROM);
-
-    ATH_DEBUG_PRINTF (DBG_MISC_DRV, ATH_DEBUG_TRC, ("Force Target to recognize Host....\n"));
-    for (i = 0; i < szForceROM; i++)
-    {
-        if (ar6000_WriteRegDiag(hifDevice,
-                                &ForceROM[i].addr,
-                                &ForceROM[i].data) != 0)
-        {
-            ATH_DEBUG_PRINTF (DBG_MISC_DRV, ATH_DEBUG_TRC, ("Cannot force Target to recognize Host!\n"));
-            return A_ERROR;
-        }
-    }
-
-    A_MDELAY(1000);
-
-    return 0;
-}
-
-#endif /* CONFIG_AR6002_REV1_FORCE_HOST */
-
 void DebugDumpBytes(u8 *buffer, u16 length, char *pDescription)
 {
     char stream[60];
index 33fa0209026d7e3982602686f5e2419a47afd229..c777e98a756e38d2daca9b8d704c72e73b4c7ba6 100644 (file)
@@ -23,7 +23,6 @@
 
 #include "a_config.h"
 #include "athdefs.h"
-#include "a_types.h"
 #include "a_osapi.h"
 #define ATH_MODULE_NAME misc
 #include "a_debug.h"
diff --git a/drivers/staging/ath6kl/os/linux/ar6000_android.c b/drivers/staging/ath6kl/os/linux/ar6000_android.c
deleted file mode 100644 (file)
index 4aa75ee..0000000
+++ /dev/null
@@ -1,388 +0,0 @@
-//------------------------------------------------------------------------------
-// Copyright (c) 2004-2010 Atheros Communications Inc.
-// All rights reserved.
-//
-// 
-//
-// Permission to use, copy, modify, and/or distribute this software for any
-// purpose with or without fee is hereby granted, provided that the above
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-//
-//
-//
-// Author(s): ="Atheros"
-//------------------------------------------------------------------------------
-#include "ar6000_drv.h"
-#include "htc.h"
-#include <linux/vmalloc.h>
-#include <linux/fs.h>
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-#include <linux/earlysuspend.h>
-#endif
-
-bool enable_mmc_host_detect_change = false;
-static void ar6000_enable_mmchost_detect_change(int enable);
-
-
-char fwpath[256] = "/system/wifi";
-int wowledon;
-unsigned int enablelogcat;
-
-extern int bmienable;
-extern struct net_device *ar6000_devices[];
-extern char ifname[];
-
-const char def_ifname[] = "wlan0";
-module_param_string(fwpath, fwpath, sizeof(fwpath), 0644);
-module_param(enablelogcat, uint, 0644);
-module_param(wowledon, int, 0644);
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-static int screen_is_off;
-static struct early_suspend ar6k_early_suspend;
-#endif
-
-static int (*ar6000_avail_ev_p)(void *, void *);
-
-#if defined(CONFIG_ANDROID_LOGGER) && (!defined(CONFIG_MMC_MSM))
-int logger_write(const enum logidx index,
-                const unsigned char prio,
-                const char __kernel * const tag,
-                const char __kernel * const fmt,
-                ...)
-{
-    int ret = 0;
-    va_list vargs;
-    struct file *filp = (struct file *)-ENOENT;
-    mm_segment_t oldfs;
-    struct iovec vec[3];
-    int tag_bytes = strlen(tag) + 1, msg_bytes;
-    char *msg;      
-    va_start(vargs, fmt);
-    msg = kvasprintf(GFP_ATOMIC, fmt, vargs);
-    va_end(vargs);
-    if (!msg)
-        return -ENOMEM;
-    if (in_interrupt()) {
-        /* we have no choice since aio_write may be blocked */
-        printk(KERN_ALERT "%s", msg);
-        goto out_free_message;
-    }
-    msg_bytes = strlen(msg) + 1;
-    if (msg_bytes <= 1) /* empty message? */
-        goto out_free_message; /* don't bother, then */
-    if ((msg_bytes + tag_bytes + 1) > 2048) {
-        ret = -E2BIG;
-        goto out_free_message;
-    }
-            
-    vec[0].iov_base  = (unsigned char *) &prio;
-    vec[0].iov_len    = 1;
-    vec[1].iov_base   = (void *) tag;
-    vec[1].iov_len    = strlen(tag) + 1;
-    vec[2].iov_base   = (void *) msg;
-    vec[2].iov_len    = strlen(msg) + 1; 
-
-    oldfs = get_fs();
-    set_fs(KERNEL_DS);
-    do {
-        filp = filp_open("/dev/log/main", O_WRONLY, S_IRUSR);
-        if (IS_ERR(filp) || !filp->f_op) {
-            AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: filp_open /dev/log/main error\n", __FUNCTION__));
-            ret = -ENOENT;
-            break;
-        }
-
-        if (filp->f_op->aio_write) {
-            int nr_segs = sizeof(vec) / sizeof(vec[0]);
-            int len = vec[0].iov_len + vec[1].iov_len + vec[2].iov_len;
-            struct kiocb kiocb;
-            init_sync_kiocb(&kiocb, filp);
-            kiocb.ki_pos = 0;
-            kiocb.ki_left = len;
-            kiocb.ki_nbytes = len;
-            ret = filp->f_op->aio_write(&kiocb, vec, nr_segs, kiocb.ki_pos);
-        }
-        
-    } while (0);
-
-    if (!IS_ERR(filp)) {
-        filp_close(filp, NULL);
-    }
-    set_fs(oldfs);
-out_free_message:
-    kfree(msg);
-    return ret;
-}
-#endif
-
-int android_logger_lv(void *module, int mask)
-{
-    switch (mask) {
-    case ATH_DEBUG_ERR:
-        return 6;
-    case ATH_DEBUG_INFO:
-        return 4;
-    case ATH_DEBUG_WARN:
-        return 5; 
-    case ATH_DEBUG_TRC:        
-        return 3; 
-    default:
-#ifdef DEBUG
-        if (!module) {
-            return 3;
-        } else if (module == &GET_ATH_MODULE_DEBUG_VAR_NAME(driver)) {
-            return (mask <=ATH_DEBUG_MAKE_MODULE_MASK(3)) ? 3 : 2;
-        } else if (module == &GET_ATH_MODULE_DEBUG_VAR_NAME(htc)) {
-            return 2;
-        } else {
-            return 3;
-        }
-#else
-        return 3; /* DEBUG */
-#endif
-    }
-}
-
-static int android_readwrite_file(const char *filename, char *rbuf, const char *wbuf, size_t length)
-{
-    int ret = 0;
-    struct file *filp = (struct file *)-ENOENT;
-    mm_segment_t oldfs;
-    oldfs = get_fs();
-    set_fs(KERNEL_DS);
-    do {
-        int mode = (wbuf) ? O_RDWR : O_RDONLY;
-        filp = filp_open(filename, mode, S_IRUSR);
-        if (IS_ERR(filp) || !filp->f_op) {
-            AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: file %s filp_open error\n", __FUNCTION__, filename));
-            ret = -ENOENT;
-            break;
-        }
-    
-        if (length==0) {
-            /* Read the length of the file only */
-            struct inode    *inode;
-
-            inode = GET_INODE_FROM_FILEP(filp);
-            if (!inode) {
-                AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Get inode from %s failed\n", __FUNCTION__, filename));
-                ret = -ENOENT;
-                break;
-            }
-            ret = i_size_read(inode->i_mapping->host);
-            break;
-        }
-
-        if (wbuf) {
-            if ( (ret=filp->f_op->write(filp, wbuf, length, &filp->f_pos)) < 0) {
-                AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Write %u bytes to file %s error %d\n", __FUNCTION__, 
-                                length, filename, ret));
-                break;
-            }
-        } else {
-            if ( (ret=filp->f_op->read(filp, rbuf, length, &filp->f_pos)) < 0) {
-                AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Read %u bytes from file %s error %d\n", __FUNCTION__,
-                                length, filename, ret));
-                break;
-            }
-        }
-    } while (0);
-
-    if (!IS_ERR(filp)) {
-        filp_close(filp, NULL);
-    }
-    set_fs(oldfs);
-
-    return ret;
-}
-
-int android_request_firmware(const struct firmware **firmware_p, const char *name,
-                     struct device *device)
-{
-    int ret = 0;
-    struct firmware *firmware;
-    char filename[256];
-    const char *raw_filename = name;
-       *firmware_p = firmware = kzalloc(sizeof(*firmware), GFP_KERNEL);
-    if (!firmware) 
-               return -ENOMEM;
-       sprintf(filename, "%s/%s", fwpath, raw_filename);
-    do {
-        size_t length, bufsize, bmisize;
-
-        if ( (ret=android_readwrite_file(filename, NULL, NULL, 0)) < 0) {
-            break;
-        } else {
-            length = ret;
-        }
-    
-        bufsize = ALIGN(length, PAGE_SIZE);
-        bmisize = A_ROUND_UP(length, 4);
-        bufsize = max(bmisize, bufsize);
-        firmware->data = vmalloc(bufsize);
-        firmware->size = length;
-        if (!firmware->data) {
-            AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("%s: Cannot allocate buffer for firmware\n", __FUNCTION__));
-            ret = -ENOMEM;
-            break;
-        }
-    
-        if ( (ret=android_readwrite_file(filename, (char*)firmware->data, NULL, length)) != length) {
-            AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("%s: file read error, ret %d request %d\n", __FUNCTION__, ret, length));
-            ret = -1;
-            break;
-        }
-    
-    } while (0);
-
-    if (ret<0) {
-        if (firmware) {
-            if (firmware->data)
-                vfree(firmware->data);
-            kfree(firmware);
-        }
-        *firmware_p = NULL;
-    } else {
-        ret = 0;
-    }
-    return ret;    
-}
-
-void android_release_firmware(const struct firmware *firmware)
-{
-       if (firmware) {
-        if (firmware->data)
-            vfree(firmware->data);
-        kfree(firmware);
-    }
-}
-
-static int ar6000_android_avail_ev(void *context, void *hif_handle)
-{
-    int ret;
-    ar6000_enable_mmchost_detect_change(0);
-    ret = ar6000_avail_ev_p(context, hif_handle);
-    return ret;
-}
-
-/* Useful for qualcom platform to detect our wlan card for mmc stack */
-static void ar6000_enable_mmchost_detect_change(int enable)
-{
-#ifdef CONFIG_MMC_MSM
-#define MMC_MSM_DEV "msm_sdcc.1"
-    char buf[3];
-    int length;
-
-    if (!enable_mmc_host_detect_change) {
-        return;
-    }
-    length = snprintf(buf, sizeof(buf), "%d\n", enable ? 1 : 0);
-    if (android_readwrite_file("/sys/devices/platform/" MMC_MSM_DEV "/detect_change", 
-                               NULL, buf, length) < 0) {
-        /* fall back to polling */
-        android_readwrite_file("/sys/devices/platform/" MMC_MSM_DEV "/polling", NULL, buf, length);
-    }
-#endif
-}
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-static void android_early_suspend(struct early_suspend *h)
-{
-    screen_is_off = 1;
-}
-
-static void android_late_resume(struct early_suspend *h)
-{
-    screen_is_off = 0;
-}
-#endif
-
-void android_module_init(OSDRV_CALLBACKS *osdrvCallbacks)
-{
-    bmienable = 1;
-    if (ifname[0] == '\0')
-        strcpy(ifname, def_ifname);
-#ifdef CONFIG_HAS_EARLYSUSPEND
-    ar6k_early_suspend.suspend = android_early_suspend;
-    ar6k_early_suspend.resume  = android_late_resume;
-    ar6k_early_suspend.level   = EARLY_SUSPEND_LEVEL_BLANK_SCREEN;
-    register_early_suspend(&ar6k_early_suspend);
-#endif
-
-    ar6000_avail_ev_p = osdrvCallbacks->deviceInsertedHandler;
-    osdrvCallbacks->deviceInsertedHandler = ar6000_android_avail_ev;
-
-    ar6000_enable_mmchost_detect_change(1);
-}
-
-void android_module_exit(void)
-{
-#ifdef CONFIG_HAS_EARLYSUSPEND
-    unregister_early_suspend(&ar6k_early_suspend);
-#endif
-    ar6000_enable_mmchost_detect_change(1);
-}
-
-#ifdef CONFIG_PM
-void android_ar6k_check_wow_status(struct ar6_softc *ar, struct sk_buff *skb, bool isEvent)
-{
-    if (
-#ifdef CONFIG_HAS_EARLYSUSPEND
-        screen_is_off && 
-#endif 
-            skb && ar->arConnected) {
-        bool needWake = false;
-        if (isEvent) {
-            if (A_NETBUF_LEN(skb) >= sizeof(u16)) {
-                u16 cmd = *(const u16 *)A_NETBUF_DATA(skb);
-                switch (cmd) {
-                case WMI_CONNECT_EVENTID:
-                case WMI_DISCONNECT_EVENTID:
-                    needWake = true;
-                    break;
-                default:
-                    /* dont wake lock the system for other event */
-                    break;
-                }
-            }
-        } else if (A_NETBUF_LEN(skb) >= sizeof(ATH_MAC_HDR)) {
-            ATH_MAC_HDR *datap = (ATH_MAC_HDR *)A_NETBUF_DATA(skb);
-            if (!IEEE80211_IS_MULTICAST(datap->dstMac)) {
-                switch (A_BE2CPU16(datap->typeOrLen)) {
-                case 0x0800: /* IP */
-                case 0x888e: /* EAPOL */
-                case 0x88c7: /* RSN_PREAUTH */
-                case 0x88b4: /* WAPI */
-                     needWake = true;
-                     break;
-                case 0x0806: /* ARP is not important to hold wake lock */
-                default:
-                    break;
-                }
-            }
-        }
-        if (needWake) {
-            /* keep host wake up if there is any event and packate coming in*/
-            if (wowledon) {
-                char buf[32];
-                int len = sprintf(buf, "on");
-                android_readwrite_file("/sys/power/state", NULL, buf, len);
-
-                len = sprintf(buf, "%d", 127);
-                android_readwrite_file("/sys/class/leds/lcd-backlight/brightness",
-                                       NULL, buf,len);
-            }
-        }
-    }
-}
-#endif /* CONFIG_PM */
index 97d6ce63b5c06d25281a9f0850261c2e583dad4d..48dd9e3635967a61bdab81eac517c4076b8c29e1 100644 (file)
@@ -27,9 +27,7 @@
  */
 
 #include "ar6000_drv.h"
-#ifdef ATH6K_CONFIG_CFG80211
 #include "cfg80211.h"
-#endif /* ATH6K_CONFIG_CFG80211 */
 #include "htc.h"
 #include "wmi_filter_linux.h"
 #include "epping_test.h"
@@ -118,7 +116,6 @@ struct hci_transport_callbacks ar6kHciTransCallbacks = { NULL };
 #endif
 
 unsigned int processDot11Hdr = 0;
-int bmienable = BMIENABLE_DEFAULT;
 
 char ifname[IFNAMSIZ] = {0,};
 
@@ -134,6 +131,8 @@ unsigned int wlanNodeCaching = 1;
 unsigned int enableuartprint = ENABLEUARTPRINT_DEFAULT;
 unsigned int logWmiRawMsgs = 0;
 unsigned int enabletimerwar = 0;
+unsigned int num_device = 1;
+unsigned int regscanmode;
 unsigned int fwmode = 1;
 unsigned int mbox_yield_limit = 99;
 unsigned int enablerssicompensation = 0;
@@ -148,7 +147,6 @@ unsigned int panic_on_assert = 1;
 unsigned int nohifscattersupport = NOHIFSCATTERSUPPORT_DEFAULT;
 
 unsigned int setuphci = SETUPHCI_DEFAULT;
-unsigned int setuphcipal = SETUPHCIPAL_DEFAULT;
 unsigned int loghci = 0;
 unsigned int setupbtdev = SETUPBTDEV_DEFAULT;
 #ifndef EXPORT_HCI_BRIDGE_INTERFACE
@@ -156,15 +154,14 @@ unsigned int ar3khcibaud = AR3KHCIBAUD_DEFAULT;
 unsigned int hciuartscale = HCIUARTSCALE_DEFAULT;
 unsigned int hciuartstep = HCIUARTSTEP_DEFAULT;
 #endif
-#ifdef CONFIG_CHECKSUM_OFFLOAD
 unsigned int csumOffload=0;
 unsigned int csumOffloadTest=0;
-#endif
 unsigned int eppingtest=0;
+unsigned int mac_addr_method;
+unsigned int firmware_bridge;
 
 module_param_string(ifname, ifname, sizeof(ifname), 0644);
 module_param(wlaninitmode, int, 0644);
-module_param(bmienable, int, 0644);
 module_param(bypasswmi, bool, 0644);
 module_param(debuglevel, uint, 0644);
 module_param(tspecCompliance, int, 0644);
@@ -182,9 +179,7 @@ module_param(reduce_credit_dribble, int, 0644);
 module_param(allow_trace_signal, int, 0644);
 module_param(enablerssicompensation, uint, 0644);
 module_param(processDot11Hdr, uint, 0644);
-#ifdef CONFIG_CHECKSUM_OFFLOAD
 module_param(csumOffload, uint, 0644);
-#endif
 #ifdef CONFIG_HOST_TCMD_SUPPORT
 module_param(testmode, uint, 0644);
 #endif
@@ -192,7 +187,6 @@ module_param(irqprocmode, uint, 0644);
 module_param(nohifscattersupport, uint, 0644);
 module_param(panic_on_assert, uint, 0644);
 module_param(setuphci, uint, 0644);
-module_param(setuphcipal, uint, 0644);
 module_param(loghci, uint, 0644);
 module_param(setupbtdev, uint, 0644);
 #ifndef EXPORT_HCI_BRIDGE_INTERFACE
@@ -288,20 +282,11 @@ void ar6000_destroy(struct net_device *dev, unsigned int unregister);
 static void ar6000_detect_error(unsigned long ptr);
 static void    ar6000_set_multicast_list(struct net_device *dev);
 static struct net_device_stats *ar6000_get_stats(struct net_device *dev);
-static struct iw_statistics *ar6000_get_iwstats(struct net_device * dev);
 
 static void disconnect_timer_handler(unsigned long ptr);
 
 void read_rssi_compensation_param(struct ar6_softc *ar);
 
-    /* for android builds we call external APIs that handle firmware download and configuration */
-#ifdef ANDROID_ENV
-/* !!!! Interim android support to make it easier to patch the default driver for
- * android use. You must define an external source file ar6000_android.c that handles the following
- * APIs */
-extern void android_module_init(OSDRV_CALLBACKS *osdrvCallbacks);
-extern void android_module_exit(void);
-#endif
 /*
  * HTC service connection handlers
  */
@@ -321,9 +306,7 @@ static void ar6000_tx_complete(void *Context, struct htc_packet_queue *pPackets)
 
 static HTC_SEND_FULL_ACTION ar6000_tx_queue_full(void *Context, struct htc_packet *pPacket);
 
-#ifdef ATH_AR6K_11N_SUPPORT
 static void ar6000_alloc_netbufs(A_NETBUF_QUEUE_T *q, u16 num);
-#endif
 static void ar6000_deliver_frames_to_nw_stack(void * dev, void *osbuf);
 //static void ar6000_deliver_frames_to_bt_stack(void * dev, void *osbuf);
 
@@ -346,8 +329,6 @@ ar6000_sysfs_bmi_write(struct file *fp, struct kobject *kobj,
 static int
 ar6000_sysfs_bmi_init(struct ar6_softc *ar);
 
-/* HCI PAL callback function declarations */
-int ar6k_setup_hci_pal(struct ar6_softc *ar);
 void  ar6k_cleanup_hci_pal(struct ar6_softc *ar);
 
 static void
@@ -362,16 +343,13 @@ ar6000_sysfs_bmi_get_config(struct ar6_softc *ar, u32 mode);
 
 struct net_device *ar6000_devices[MAX_AR6000];
 static int is_netdev_registered;
-extern struct iw_handler_def ath_iw_handler_def;
 DECLARE_WAIT_QUEUE_HEAD(arEvent);
 static void ar6000_cookie_init(struct ar6_softc *ar);
 static void ar6000_cookie_cleanup(struct ar6_softc *ar);
 static void ar6000_free_cookie(struct ar6_softc *ar, struct ar_cookie * cookie);
 static struct ar_cookie *ar6000_alloc_cookie(struct ar6_softc *ar);
 
-#ifdef USER_KEYS
 static int ar6000_reinstall_keys(struct ar6_softc *ar,u8 key_op_ctrl);
-#endif
 
 #ifdef CONFIG_AP_VIRTUAL_ADAPTER_SUPPORT
 struct net_device *arApNetDev;
@@ -389,7 +367,6 @@ static struct net_device_ops ar6000_netdev_ops = {
     .ndo_open               = ar6000_open,
     .ndo_stop               = ar6000_close,
     .ndo_get_stats          = ar6000_get_stats,
-    .ndo_do_ioctl           = ar6000_ioctl,
     .ndo_start_xmit         = ar6000_data_tx,
     .ndo_set_multicast_list = ar6000_set_multicast_list,
 };
@@ -612,7 +589,6 @@ ar6000_dbglog_event(struct ar6_softc *ar, u32 dropped,
     send = dbglog_get_debug_fragment(&buffer[sent], length - sent,
                                      MAX_WIRELESS_EVENT_SIZE);
     while (send) {
-        ar6000_send_event_to_app(ar, WMIX_DBGLOG_EVENTID, (u8 *)&buffer[sent], send);
         sent += send;
         send = dbglog_get_debug_fragment(&buffer[sent], length - sent,
                                          MAX_WIRELESS_EVENT_SIZE);
@@ -631,7 +607,7 @@ static int __init
 ar6000_init_module(void)
 {
     static int probed = 0;
-    int status;
+    int r;
     OSDRV_CALLBACKS osdrvCallbacks;
 
     a_module_debug_support_init();
@@ -664,12 +640,6 @@ ar6000_init_module(void)
     osdrvCallbacks.devicePowerChangeHandler = ar6000_power_change_ev;
 #endif
 
-    ar6000_pm_init();
-
-#ifdef ANDROID_ENV
-    android_module_init(&osdrvCallbacks);
-#endif
-
 #ifdef DEBUG
     /* Set the debug flags if specified at load time */
     if(debugflags != 0)
@@ -687,13 +657,9 @@ ar6000_init_module(void)
     memset(&aptcTR, 0, sizeof(APTC_TRAFFIC_RECORD));
 #endif /* ADAPTIVE_POWER_THROUGHPUT_CONTROL */
 
-#ifdef CONFIG_HOST_GPIO_SUPPORT
-    ar6000_gpio_init();
-#endif /* CONFIG_HOST_GPIO_SUPPORT */
-
-    status = HIFInit(&osdrvCallbacks);
-    if (status)
-        return -ENODEV;
+    r = HIFInit(&osdrvCallbacks);
+    if (r)
+        return r;
 
     return 0;
 }
@@ -723,12 +689,6 @@ ar6000_cleanup_module(void)
 
     a_module_debug_support_cleanup();
 
-    ar6000_pm_exit();
-
-#ifdef ANDROID_ENV    
-    android_module_exit();
-#endif
-
     AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("ar6000_cleanup: success\n"));
 }
 
@@ -769,7 +729,6 @@ aptcTimerHandler(unsigned long arg)
 }
 #endif /* ADAPTIVE_POWER_THROUGHPUT_CONTROL */
 
-#ifdef ATH_AR6K_11N_SUPPORT
 static void
 ar6000_alloc_netbufs(A_NETBUF_QUEUE_T *q, u16 num)
 {
@@ -788,7 +747,6 @@ ar6000_alloc_netbufs(A_NETBUF_QUEUE_T *q, u16 num)
         A_PRINTF("%s(), allocation of netbuf failed", __func__);
     }
 }
-#endif
 
 static struct bin_attribute bmi_attr = {
     .attr = {.name = "bmi", .mode = 0600},
@@ -894,8 +852,6 @@ ar6000_sysfs_bmi_deinit(struct ar6_softc *ar)
     } \
 } while(0)
 
-#ifdef INIT_MODE_DRV_ENABLED
-
 #ifdef SOFTMAC_FILE_USED
 #define AR6002_MAC_ADDRESS_OFFSET     0x0A
 #define AR6003_MAC_ADDRESS_OFFSET     0x16
@@ -982,7 +938,7 @@ ar6000_softmac_update(struct ar6_softc *ar, u8 *eeprom_data, size_t size)
                 }
                 source = "softmac file";
             }
-            A_FREE(macbuf);
+            kfree(macbuf);
         }
         A_RELEASE_FIRMWARE(softmac_entry);
     }
@@ -1005,6 +961,8 @@ ar6000_transfer_bin_file(struct ar6_softc *ar, AR6K_BIN_FILE file, u32 address,
                 filename = AR6003_REV1_OTP_FILE;
             } else if (ar->arVersion.target_ver == AR6003_REV2_VERSION) {
                 filename = AR6003_REV2_OTP_FILE;
+                } else if (ar->arVersion.target_ver == AR6003_REV3_VERSION) {
+                        filename = AR6003_REV3_OTP_FILE;
             } else {
                 AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unknown firmware revision: %d\n", ar->arVersion.target_ver));
                 return A_ERROR;
@@ -1016,6 +974,8 @@ ar6000_transfer_bin_file(struct ar6_softc *ar, AR6K_BIN_FILE file, u32 address,
                 filename = AR6003_REV1_FIRMWARE_FILE;
             } else if (ar->arVersion.target_ver == AR6003_REV2_VERSION) {
                 filename = AR6003_REV2_FIRMWARE_FILE;
+                } else if (ar->arVersion.target_ver == AR6003_REV3_VERSION) {
+                        filename = AR6003_REV3_FIRMWARE_FILE;
             } else {
                 AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unknown firmware revision: %d\n", ar->arVersion.target_ver));
                 return A_ERROR;
@@ -1027,6 +987,8 @@ ar6000_transfer_bin_file(struct ar6_softc *ar, AR6K_BIN_FILE file, u32 address,
                     filename = AR6003_REV1_EPPING_FIRMWARE_FILE;
                 } else if (ar->arVersion.target_ver == AR6003_REV2_VERSION) {
                     filename = AR6003_REV2_EPPING_FIRMWARE_FILE;
+                } else if (ar->arVersion.target_ver == AR6003_REV3_VERSION) {
+                        filename = AR6003_REV3_EPPING_FIRMWARE_FILE;
                 } else {
                     AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("eppingtest : unsupported firmware revision: %d\n", 
                         ar->arVersion.target_ver));
@@ -1041,6 +1003,8 @@ ar6000_transfer_bin_file(struct ar6_softc *ar, AR6K_BIN_FILE file, u32 address,
                     filename = AR6003_REV1_TCMD_FIRMWARE_FILE;
                 } else if (ar->arVersion.target_ver == AR6003_REV2_VERSION) {
                     filename = AR6003_REV2_TCMD_FIRMWARE_FILE;
+                } else if (ar->arVersion.target_ver == AR6003_REV3_VERSION) {
+                        filename = AR6003_REV3_TCMD_FIRMWARE_FILE;
                 } else {
                     AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unknown firmware revision: %d\n", ar->arVersion.target_ver));
                     return A_ERROR;
@@ -1068,6 +1032,8 @@ ar6000_transfer_bin_file(struct ar6_softc *ar, AR6K_BIN_FILE file, u32 address,
                 filename = AR6003_REV1_PATCH_FILE;
             } else if (ar->arVersion.target_ver == AR6003_REV2_VERSION) {
                 filename = AR6003_REV2_PATCH_FILE;
+                } else if (ar->arVersion.target_ver == AR6003_REV3_VERSION) {
+                        filename = AR6003_REV3_PATCH_FILE;
             } else {
                 AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unknown firmware revision: %d\n", ar->arVersion.target_ver));
                 return A_ERROR;
@@ -1079,6 +1045,8 @@ ar6000_transfer_bin_file(struct ar6_softc *ar, AR6K_BIN_FILE file, u32 address,
                 filename = AR6003_REV1_BOARD_DATA_FILE;
             } else if (ar->arVersion.target_ver == AR6003_REV2_VERSION) {
                 filename = AR6003_REV2_BOARD_DATA_FILE;
+                } else if (ar->arVersion.target_ver == AR6003_REV3_VERSION) {
+                        filename = AR6003_REV3_BOARD_DATA_FILE;
             } else {
                 AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unknown firmware revision: %d\n", ar->arVersion.target_ver));
                 return A_ERROR;
@@ -1133,8 +1101,10 @@ ar6000_transfer_bin_file(struct ar6_softc *ar, AR6K_BIN_FILE file, u32 address,
             }
 
             /* Record the fact that extended board Data IS initialized */
-            param = 1;
-            bmifn(BMIWriteMemory(ar->arHifDevice, HOST_INTEREST_ITEM_ADDRESS(ar, hi_board_ext_data_initialized), (u8 *)&param, 4));
+            param = (board_ext_data_size << 16) | 1;
+            bmifn(BMIWriteMemory(ar->arHifDevice,
+            HOST_INTEREST_ITEM_ADDRESS(ar, hi_board_ext_data_config),
+                                      (unsigned char *)&param, 4));
         }
         fw_entry_size = board_data_size;
     }
@@ -1153,7 +1123,6 @@ ar6000_transfer_bin_file(struct ar6_softc *ar, AR6K_BIN_FILE file, u32 address,
     A_RELEASE_FIRMWARE(fw_entry);
     return 0;
 }
-#endif /* INIT_MODE_DRV_ENABLED */
 
 int
 ar6000_update_bdaddr(struct ar6_softc *ar)
@@ -1200,7 +1169,6 @@ ar6000_sysfs_bmi_get_config(struct ar6_softc *ar, u32 mode)
         }
 
         A_RELEASE_FIRMWARE(fw_entry);
-#ifdef INIT_MODE_DRV_ENABLED
     } else {
         /* The config is contained within the driver itself */
         int status;
@@ -1293,7 +1261,9 @@ ar6000_sysfs_bmi_get_config(struct ar6_softc *ar, u32 mode)
             bmifn(BMIWriteMemory(ar->arHifDevice, HOST_INTEREST_ITEM_ADDRESS(ar, hi_board_data_initialized), (u8 *)&param, 4));
 
             /* Transfer One time Programmable data */
-            AR6K_DATA_DOWNLOAD_ADDRESS(address, ar->arVersion.target_ver);
+           AR6K_APP_LOAD_ADDRESS(address, ar->arVersion.target_ver);
+           if (ar->arVersion.target_ver == AR6003_REV3_VERSION)
+                 address = 0x1234;
             status = ar6000_transfer_bin_file(ar, AR6K_OTP_FILE, address, true);
             if (status == 0) {
                 /* Execute the OTP code */
@@ -1309,7 +1279,9 @@ ar6000_sysfs_bmi_get_config(struct ar6_softc *ar, u32 mode)
         }
 
         /* Download Target firmware */
-        AR6K_DATA_DOWNLOAD_ADDRESS(address, ar->arVersion.target_ver);
+        AR6K_APP_LOAD_ADDRESS(address, ar->arVersion.target_ver);
+        if (ar->arVersion.target_ver == AR6003_REV3_VERSION)
+                address = 0x1234;
         if ((ar6000_transfer_bin_file(ar, AR6K_FIRMWARE_FILE, address, true)) != 0) {
             return A_ERROR;
         }
@@ -1318,25 +1290,16 @@ ar6000_sysfs_bmi_get_config(struct ar6_softc *ar, u32 mode)
         AR6K_APP_START_OVERRIDE_ADDRESS(address, ar->arVersion.target_ver);
         bmifn(BMISetAppStart(ar->arHifDevice, address));
 
-        /* Apply the patches */
-        AR6K_PATCH_DOWNLOAD_ADDRESS(address, ar->arVersion.target_ver);
-        if ((ar6000_transfer_bin_file(ar, AR6K_PATCH_FILE, address, false)) != 0) {
-            return A_ERROR;
-        }
-
-        param = address;
-        bmifn(BMIWriteMemory(ar->arHifDevice, HOST_INTEREST_ITEM_ADDRESS(ar, hi_dset_list_head), (u8 *)&param, 4));
-
-        if (ar->arTargetType == TARGET_TYPE_AR6003) {
-            if (ar->arVersion.target_ver == AR6003_REV1_VERSION) {
-                /* Reserve 5.5K of RAM */
-                param = 5632;
-            } else { /* AR6003_REV2_VERSION */
-                /* Reserve 6.5K of RAM */
-                param = 6656;
-            }
-            bmifn(BMIWriteMemory(ar->arHifDevice, HOST_INTEREST_ITEM_ADDRESS(ar, hi_end_RAM_reserve_sz), (u8 *)&param, 4));
-        }
+       if(ar->arTargetType == TARGET_TYPE_AR6003) {
+               AR6K_DATASET_PATCH_ADDRESS(address, ar->arVersion.target_ver);
+               if ((ar6000_transfer_bin_file(ar, AR6K_PATCH_FILE,
+                                             address, false)) != 0)
+                       return A_ERROR;
+               param = address;
+               bmifn(BMIWriteMemory(ar->arHifDevice,
+               HOST_INTEREST_ITEM_ADDRESS(ar, hi_dset_list_head),
+                                          (unsigned char *)&param, 4));
+       }
 
         /* Restore system sleep */
         address = RTC_BASE_ADDRESS + SYSTEM_SLEEP_ADDRESS;
@@ -1390,8 +1353,6 @@ ar6000_sysfs_bmi_get_config(struct ar6_softc *ar, u32 mode)
             msleep(1000);
         }
 #endif /* HTC_RAW_INTERFACE */
-
-#endif /* INIT_MODE_DRV_ENABLED */
     }
 
     return 0;
@@ -1470,7 +1431,11 @@ ar6000_configure_target(struct ar6_softc *ar)
             return A_ERROR;
         }
 
+        param |= (num_device << HI_OPTION_NUM_DEV_SHIFT);
         param |= (fwmode << HI_OPTION_FW_MODE_SHIFT);
+        param |= (mac_addr_method << HI_OPTION_MAC_ADDR_METHOD_SHIFT);
+        param |= (firmware_bridge << HI_OPTION_FW_BRIDGE_SHIFT);
+
 
         if (BMIWriteMemory(ar->arHifDevice,
             HOST_INTEREST_ITEM_ADDRESS(ar, hi_option_flag),
@@ -1518,18 +1483,34 @@ ar6000_configure_target(struct ar6_softc *ar)
      * It is difficult to patch the firmware boot code,
      * but possible in theory.
      */
-    if (ar->arTargetType == TARGET_TYPE_AR6003) {
-        param = AR6003_BOARD_EXT_DATA_ADDRESS; 
-        if (BMIWriteMemory(ar->arHifDevice,
-            HOST_INTEREST_ITEM_ADDRESS(ar, hi_board_ext_data),
-            (u8 *)&param,
-            4) != 0)
-        {
-            AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("BMIWriteMemory for hi_board_ext_data failed \n"));
-            return A_ERROR;
-        }
-    }
 
+       if (ar->arTargetType == TARGET_TYPE_AR6003) {
+               u32 ramReservedSz;
+               if (ar->arVersion.target_ver == AR6003_REV2_VERSION) {
+                       param = AR6003_REV2_BOARD_EXT_DATA_ADDRESS;
+                       ramReservedSz =  AR6003_REV2_RAM_RESERVE_SIZE;
+                } else {
+                       param = AR6003_REV3_BOARD_EXT_DATA_ADDRESS;
+                       ramReservedSz =  AR6003_REV3_RAM_RESERVE_SIZE;
+               }
+               if (BMIWriteMemory(ar->arHifDevice,
+                       HOST_INTEREST_ITEM_ADDRESS(ar, hi_board_ext_data),
+                                                  (u8 *)&param, 4) != 0) {
+                               AR_DEBUG_PRINTF(ATH_DEBUG_ERR,
+                                               ("BMIWriteMemory for "
+                                                "hi_board_ext_data failed\n"));
+                               return A_ERROR;
+               }
+               if (BMIWriteMemory(ar->arHifDevice,
+                                  HOST_INTEREST_ITEM_ADDRESS(ar,
+                                  hi_end_RAM_reserve_sz),
+                                  (u8 *)&ramReservedSz, 4) != 0) {
+                       AR_DEBUG_PRINTF(ATH_DEBUG_ERR ,
+                                       ("BMIWriteMemory for "
+                                        "hi_end_RAM_reserve_sz failed\n"));
+                       return A_ERROR;
+               }
+       }
 
         /* since BMIInit is called in the driver layer, we have to set the block
          * size here for the target */
@@ -1555,9 +1536,6 @@ init_netdev(struct net_device *dev, char *name)
 {
     dev->netdev_ops = &ar6000_netdev_ops;
     dev->watchdog_timeo = AR6000_TX_TIMEOUT;
-    dev->wireless_handlers = &ath_iw_handler_def;
-
-    ath_iw_handler_def.get_wireless_stats = ar6000_get_iwstats; /*Displayed via proc fs */
 
    /*
     * We need the OS to provide us with more headroom in order to
@@ -1575,10 +1553,6 @@ init_netdev(struct net_device *dev, char *name)
         strcpy(dev->name, name);
     }
 
-#ifdef SET_MODULE_OWNER
-    SET_MODULE_OWNER(dev);
-#endif
-
 #ifdef CONFIG_CHECKSUM_OFFLOAD
     if(csumOffload){
         dev->features |= NETIF_F_IP_CSUM; /*advertise kernel capability to do TCP/UDP CSUM offload for IPV4*/
@@ -1588,6 +1562,52 @@ init_netdev(struct net_device *dev, char *name)
     return;
 }
 
+static int __ath6kl_init_netdev(struct net_device *dev)
+{
+       int r;
+
+       rtnl_lock();
+       r = ar6000_init(dev);
+       rtnl_unlock();
+
+       if (r) {
+               AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("ar6000_avail: ar6000_init\n"));
+               return r;
+       }
+
+       return 0;
+}
+
+#ifdef HTC_RAW_INTERFACE
+static int ath6kl_init_netdev_wmi(struct net_device *dev)
+{
+       if (!eppingtest && bypasswmi)
+               return 0;
+
+       return __ath6kl_init_netdev(dev);
+}
+#else
+static int ath6kl_init_netdev_wmi(struct net_device *dev)
+{
+       return __ath6kl_init_netdev(dev);
+}
+#endif
+
+static int ath6kl_init_netdev(struct ar6_softc *ar)
+{
+       int r;
+
+        r = ar6000_sysfs_bmi_get_config(ar, wlaninitmode);
+        if (r) {
+               AR_DEBUG_PRINTF(ATH_DEBUG_ERR,
+                               ("ar6000_avail: "
+                                "ar6000_sysfs_bmi_get_config failed\n"));
+               return r;
+        }
+
+       return ath6kl_init_netdev_wmi(ar->arNetDev);
+}
+
 /*
  * HTC Event handlers
  */
@@ -1600,10 +1620,8 @@ ar6000_avail_ev(void *context, void *hif_handle)
     struct ar6_softc *ar;
     int device_index = 0;
     struct htc_init_info  htcInfo;
-#ifdef ATH6K_CONFIG_CFG80211
     struct wireless_dev *wdev;
-#endif /* ATH6K_CONFIG_CFG80211 */
-    int init_status = 0;
+    int r = 0;
     struct hif_device_os_device_info osDevInfo;
 
     memset(&osDevInfo, 0, sizeof(osDevInfo));
@@ -1630,22 +1648,12 @@ ar6000_avail_ev(void *context, void *hif_handle)
     /* we use another local "i" variable below.                      */
     device_index = i;
 
-#ifdef ATH6K_CONFIG_CFG80211
     wdev = ar6k_cfg80211_init(osDevInfo.pOSDevice);
     if (IS_ERR(wdev)) {
         AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: ar6k_cfg80211_init failed\n", __func__));
         return A_ERROR;
     }
     ar_netif = wdev_priv(wdev);
-#else
-    dev = alloc_etherdev(sizeof(struct ar6_softc));
-    if (dev == NULL) {
-        AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("ar6000_available: can't alloc etherdev\n"));
-        return A_ERROR;
-    }
-    ether_setup(dev);
-    ar_netif = ar6k_priv(dev);
-#endif /* ATH6K_CONFIG_CFG80211 */
 
     if (ar_netif == NULL) {
         AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: Can't allocate ar6k priv memory\n", __func__));
@@ -1655,7 +1663,6 @@ ar6000_avail_ev(void *context, void *hif_handle)
     A_MEMZERO(ar_netif, sizeof(struct ar6_softc));
     ar = (struct ar6_softc *)ar_netif;
 
-#ifdef ATH6K_CONFIG_CFG80211
     ar->wdev = wdev;
     wdev->iftype = NL80211_IFTYPE_STATION;
 
@@ -1671,15 +1678,10 @@ ar6000_avail_ev(void *context, void *hif_handle)
     wdev->netdev = dev;
     ar->arNetworkType = INFRA_NETWORK;
     ar->smeState = SME_DISCONNECTED;
-#endif /* ATH6K_CONFIG_CFG80211 */
+    ar->arAutoAuthStage = AUTH_IDLE;
 
     init_netdev(dev, ifname);
 
-#ifdef SET_NETDEV_DEV
-    if (ar_netif) { 
-        SET_NETDEV_DEV(dev, osDevInfo.pOSDevice);
-    }
-#endif 
 
     ar->arNetDev             = dev;
     ar->arHifDevice          = hif_handle;
@@ -1719,35 +1721,23 @@ ar6000_avail_ev(void *context, void *hif_handle)
 
     BMIInit();
 
-    if (bmienable) {
-        ar6000_sysfs_bmi_init(ar);
-    }
+    ar6000_sysfs_bmi_init(ar);
 
     {
         struct bmi_target_info targ_info;
 
-        if (BMIGetTargetInfo(ar->arHifDevice, &targ_info) != 0) {
-            init_status = A_ERROR;
+        r = BMIGetTargetInfo(ar->arHifDevice, &targ_info);
+        if (r)
             goto avail_ev_failed;
-        }
 
         ar->arVersion.target_ver = targ_info.target_ver;
         ar->arTargetType = targ_info.target_type;
-
-            /* do any target-specific preparation that can be done through BMI */
-        if (ar6000_prepare_target(ar->arHifDevice,
-                                  targ_info.target_type,
-                                  targ_info.target_ver) != 0) {
-            init_status = A_ERROR;
-            goto avail_ev_failed;
-        }
-
+       wdev->wiphy->hw_version = targ_info.target_ver;
     }
 
-    if (ar6000_configure_target(ar) != 0) {
-            init_status = A_ERROR;
+    r = ar6000_configure_target(ar);
+    if (r)
             goto avail_ev_failed;
-    }
 
     A_MEMZERO(&htcInfo,sizeof(htcInfo));
     htcInfo.pContext = ar;
@@ -1755,8 +1745,8 @@ ar6000_avail_ev(void *context, void *hif_handle)
 
     ar->arHtcTarget = HTCCreate(ar->arHifDevice,&htcInfo);
 
-    if (ar->arHtcTarget == NULL) {
-        init_status = A_ERROR;
+    if (!ar->arHtcTarget) {
+        r = -ENOMEM;
         goto avail_ev_failed;
     }
 
@@ -1767,22 +1757,19 @@ ar6000_avail_ev(void *context, void *hif_handle)
 #endif
 
 
-#ifdef CONFIG_CHECKSUM_OFFLOAD
     if(csumOffload){
         /*if external frame work is also needed, change and use an extended rxMetaVerion*/
         ar->rxMetaVersion=WMI_META_VERSION_2;
     }
-#endif
 
-#ifdef ATH_AR6K_11N_SUPPORT
-    if((ar->aggr_cntxt = aggr_init(ar6000_alloc_netbufs)) == NULL) {
+    ar->aggr_cntxt = aggr_init(ar6000_alloc_netbufs);
+    if (!ar->aggr_cntxt) {
             AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("%s() Failed to initialize aggr.\n", __func__));
-            init_status = A_ERROR;
+            r = -ENOMEM;
             goto avail_ev_failed;
     }
 
     aggr_register_rx_dispatcher(ar->aggr_cntxt, (void *)dev, ar6000_deliver_frames_to_nw_stack);
-#endif
 
     HIFClaimDevice(ar->arHifDevice, ar);
 
@@ -1791,46 +1778,20 @@ ar6000_avail_ev(void *context, void *hif_handle)
     /* when the module is unloaded.                                  */
     ar6000_devices[device_index] = dev;
 
-    /* Don't install the init function if BMI is requested */
-    if (!bmienable) {
-        ar6000_netdev_ops.ndo_init = ar6000_init;
-    } else {
-        AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("BMI enabled: %d\n", wlaninitmode));
-        if ((wlaninitmode == WLAN_INIT_MODE_UDEV) ||
-            (wlaninitmode == WLAN_INIT_MODE_DRV))
-        {
-            int status = 0;
-            do {
-                if ((status = ar6000_sysfs_bmi_get_config(ar, wlaninitmode)) != 0)
-                {
-                    AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("ar6000_avail: ar6000_sysfs_bmi_get_config failed\n"));
-                    break;
-                }
-#ifdef HTC_RAW_INTERFACE
-                if (!eppingtest && bypasswmi) {
-                    break; /* Don't call ar6000_init for ART */
-                }
-#endif 
-                rtnl_lock();
-                status = (ar6000_init(dev)==0) ? 0 : A_ERROR;
-                rtnl_unlock();
-                if (status) {
-                    AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("ar6000_avail: ar6000_init\n"));
-                }
-            } while (false);
-
-            if (status) {
-                init_status = status;
-                goto avail_ev_failed;
-            }
-        }
+    AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("BMI enabled: %d\n", wlaninitmode));
+    if ((wlaninitmode == WLAN_INIT_MODE_UDEV) ||
+        (wlaninitmode == WLAN_INIT_MODE_DRV)) {
+       r = ath6kl_init_netdev(ar);
+       if (r)
+            goto avail_ev_failed;
     }
 
     /* This runs the init function if registered */
-    if (register_netdev(dev)) {
+    r = register_netdev(dev);
+    if (r) {
         AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("ar6000_avail: register_netdev failed\n"));
         ar6000_destroy(dev, 0);
-        return A_ERROR;
+        return r;
     }
 
        is_netdev_registered = 1;
@@ -1843,13 +1804,10 @@ ar6000_avail_ev(void *context, void *hif_handle)
                     (unsigned long)ar));
 
 avail_ev_failed :
-    if (init_status) {
-        if (bmienable) { 
-            ar6000_sysfs_bmi_deinit(ar);  
-        }
-    }
+    if (r)
+        ar6000_sysfs_bmi_deinit(ar);  
 
-    return init_status;
+    return r;
 }
 
 static void ar6000_target_failure(void *Instance, int Status)
@@ -1880,9 +1838,6 @@ static void ar6000_target_failure(void *Instance, int Status)
             sip = true;
             errEvent.errorVal = WMI_TARGET_COM_ERR |
                                 WMI_TARGET_FATAL_ERR;
-            ar6000_send_event_to_app(ar, WMI_ERROR_REPORT_EVENTID,
-                                     (u8 *)&errEvent,
-                                     sizeof(WMI_TARGET_ERROR_REPORT_EVENT));
         }
     }
 }
@@ -1980,10 +1935,8 @@ ar6000_stop_endpoint(struct net_device *dev, bool keepprofile, bool getdbglogs)
                     ar6000_disconnect_event(ar, DISCONNECT_CMD, ar->arBssid, 0, NULL, 0);
                 }
             }
-#ifdef USER_KEYS
             ar->user_savedkeys_stat = USER_SAVEDKEYS_STAT_INIT;
             ar->user_key_ctrl      = 0;
-#endif
         }
 
          AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("%s(): WMI stopped\n", __func__));
@@ -2024,15 +1977,6 @@ ar6000_stop_endpoint(struct net_device *dev, bool keepprofile, bool getdbglogs)
         // END workaround
         if (setuphci)
                ar6000_cleanup_hci(ar);
-#endif
-#ifdef EXPORT_HCI_PAL_INTERFACE
-        if (setuphcipal && (NULL != ar6kHciPalCallbacks_g.cleanupTransport)) {
-           ar6kHciPalCallbacks_g.cleanupTransport(ar);
-        }
-#else
-                               /* cleanup hci pal driver data structures */
-        if(setuphcipal)
-          ar6k_cleanup_hci_pal(ar);
 #endif
         AR_DEBUG_PRINTF(ATH_DEBUG_INFO,(" Shutting down HTC .... \n"));
         /* stop HTC */
@@ -2094,9 +2038,6 @@ ar6000_destroy(struct net_device *dev, unsigned int unregister)
     if (ar->arWlanPowerState != WLAN_POWER_STATE_CUT_PWR) {
         /* only stop endpoint if we are not stop it in suspend_ev */
         ar6000_stop_endpoint(dev, false, true);
-    } else {
-        /* clear up the platform power state before rmmod */
-        plat_setup_power(1,0);
     }
 
     ar->arWlanState = WLAN_DISABLED;
@@ -2110,9 +2051,7 @@ ar6000_destroy(struct net_device *dev, unsigned int unregister)
         HIFReleaseDevice(ar->arHifDevice);
         HIFShutDownDevice(ar->arHifDevice);
     }
-#ifdef ATH_AR6K_11N_SUPPORT
     aggr_module_destroy(ar->aggr_cntxt);
-#endif
 
        /* Done with cookies */
     ar6000_cookie_cleanup(ar);
@@ -2120,9 +2059,7 @@ ar6000_destroy(struct net_device *dev, unsigned int unregister)
         /* cleanup any allocated AMSDU buffers */
     ar6000_cleanup_amsdu_rxbufs(ar);
 
-    if (bmienable) {
-        ar6000_sysfs_bmi_deinit(ar);
-    }
+    ar6000_sysfs_bmi_deinit(ar);
 
     /* Cleanup BMI */
     BMICleanup();
@@ -2134,7 +2071,7 @@ ar6000_destroy(struct net_device *dev, unsigned int unregister)
 
 #ifdef HTC_RAW_INTERFACE
     if (ar->arRawHtc) {
-        A_FREE(ar->arRawHtc);
+        kfree(ar->arRawHtc);
         ar->arRawHtc = NULL;
     }
 #endif 
@@ -2145,9 +2082,7 @@ ar6000_destroy(struct net_device *dev, unsigned int unregister)
     }
     free_netdev(dev);
 
-#ifdef ATH6K_CONFIG_CFG80211
     ar6k_cfg80211_deinit(ar);
-#endif /* ATH6K_CONFIG_CFG80211 */
 
 #ifdef CONFIG_AP_VIRTUL_ADAPTER_SUPPORT
     ar6000_remove_ap_interface();
@@ -2187,9 +2122,6 @@ static void ar6000_detect_error(unsigned long ptr)
         ar->arHBChallengeResp.seqNum = 0;
         errEvent.errorVal = WMI_TARGET_COM_ERR | WMI_TARGET_FATAL_ERR;
         AR6000_SPIN_UNLOCK(&ar->arLock, 0);
-        ar6000_send_event_to_app(ar, WMI_ERROR_REPORT_EVENTID,
-                                 (u8 *)&errEvent,
-                                 sizeof(WMI_TARGET_ERROR_REPORT_EVENT));
         return;
     }
 
@@ -2295,11 +2227,9 @@ ar6000_open(struct net_device *dev)
 
     spin_lock_irqsave(&ar->arLock, flags);
 
-#ifdef ATH6K_CONFIG_CFG80211
     if(ar->arWlanState == WLAN_DISABLED) {
         ar->arWlanState = WLAN_ENABLED;
     }
-#endif /* ATH6K_CONFIG_CFG80211 */
 
     if( ar->arConnected || bypasswmi) {
         netif_carrier_on(dev);
@@ -2316,12 +2246,9 @@ ar6000_open(struct net_device *dev)
 static int
 ar6000_close(struct net_device *dev)
 {
-#ifdef ATH6K_CONFIG_CFG80211
     struct ar6_softc    *ar = (struct ar6_softc *)ar6k_priv(dev);
-#endif /* ATH6K_CONFIG_CFG80211 */
     netif_stop_queue(dev);
 
-#ifdef ATH6K_CONFIG_CFG80211
     ar6000_disconnect(ar);
 
     if(ar->arWmiReady == true) {
@@ -2332,7 +2259,6 @@ ar6000_close(struct net_device *dev)
         ar->arWlanState = WLAN_DISABLED;
     }
        ar6k_cfg80211_scanComplete_event(ar, A_ECANCELED);
-#endif /* ATH6K_CONFIG_CFG80211 */
 
     return 0;
 }
@@ -2422,16 +2348,52 @@ u8 ar6000_endpoint_id2_ac(void * devt, HTC_ENDPOINT_ID ep )
     return(arEndpoint2Ac(ar, ep ));
 }
 
+#if defined(CONFIG_ATH6KL_ENABLE_COEXISTENCE)
+static int ath6kl_config_btcoex_params(struct ar6_softc *ar)
+{
+       int r;
+       WMI_SET_BTCOEX_COLOCATED_BT_DEV_CMD sbcb_cmd;
+       WMI_SET_BTCOEX_FE_ANT_CMD sbfa_cmd;
+
+       /* Configure the type of BT collocated with WLAN */
+       memset(&sbcb_cmd, 0, sizeof(WMI_SET_BTCOEX_COLOCATED_BT_DEV_CMD));
+       sbcb_cmd.btcoexCoLocatedBTdev = ATH6KL_BT_DEV;
+
+       r = wmi_set_btcoex_colocated_bt_dev_cmd(ar->arWmi, &sbcb_cmd);
+
+       if (r) {
+               AR_DEBUG_PRINTF(ATH_DEBUG_ERR,
+                               ("Unable to set collocated BT type\n"));
+               return r;
+       }
+
+       /* Configure the type of BT collocated with WLAN */
+       memset(&sbfa_cmd, 0, sizeof(WMI_SET_BTCOEX_FE_ANT_CMD));
+
+       sbfa_cmd.btcoexFeAntType = ATH6KL_BT_ANTENNA;
+
+       r = wmi_set_btcoex_fe_ant_cmd(ar->arWmi, &sbfa_cmd);
+       if (r) {
+               AR_DEBUG_PRINTF(ATH_DEBUG_ERR,
+                               ("Unable to set fornt end antenna configuration\n"));
+               return r;
+       }
+
+       return 0;
+}
+#else
+static int ath6kl_config_btcoex_params(struct ar6_softc *ar)
+{
+       return 0;
+}
+#endif /* CONFIG_ATH6KL_ENABLE_COEXISTENCE */
+
 /*
  * This function applies WLAN specific configuration defined in wlan_config.h
  */
 int ar6000_target_config_wlan_params(struct ar6_softc *ar)
 {
     int status = 0;
-#if defined(INIT_MODE_DRV_ENABLED) && defined(ENABLE_COEXISTENCE)
-    WMI_SET_BTCOEX_COLOCATED_BT_DEV_CMD sbcb_cmd;
-    WMI_SET_BTCOEX_FE_ANT_CMD sbfa_cmd;
-#endif /* INIT_MODE_DRV_ENABLED && ENABLE_COEXISTENCE */
 
 #ifdef CONFIG_HOST_TCMD_SUPPORT
     if (ar->arTargetMode != AR6000_WLAN_MODE) {
@@ -2449,39 +2411,9 @@ int ar6000_target_config_wlan_params(struct ar6_softc *ar)
         status = A_ERROR;
     }
 
-#if defined(INIT_MODE_DRV_ENABLED) && defined(ENABLE_COEXISTENCE)
-    /* Configure the type of BT collocated with WLAN */
-    memset(&sbcb_cmd, 0, sizeof(WMI_SET_BTCOEX_COLOCATED_BT_DEV_CMD));
-#ifdef CONFIG_AR600x_BT_QCOM
-    sbcb_cmd.btcoexCoLocatedBTdev = 1;
-#elif defined(CONFIG_AR600x_BT_CSR)
-    sbcb_cmd.btcoexCoLocatedBTdev = 2;
-#elif defined(CONFIG_AR600x_BT_AR3001)
-    sbcb_cmd.btcoexCoLocatedBTdev = 3;
-#else
-#error Unsupported Bluetooth Type
-#endif /* Collocated Bluetooth Type */
-
-    if ((wmi_set_btcoex_colocated_bt_dev_cmd(ar->arWmi, &sbcb_cmd)) != 0) {
-        AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Unable to set collocated BT type\n"));
-        status = A_ERROR;
-    }
-
-    /* Configure the type of BT collocated with WLAN */
-    memset(&sbfa_cmd, 0, sizeof(WMI_SET_BTCOEX_FE_ANT_CMD));
-#ifdef CONFIG_AR600x_DUAL_ANTENNA
-    sbfa_cmd.btcoexFeAntType = 2;
-#elif defined(CONFIG_AR600x_SINGLE_ANTENNA)
-    sbfa_cmd.btcoexFeAntType = 1;
-#else
-#error Unsupported Front-End Antenna Configuration
-#endif /* AR600x Front-End Antenna Configuration */
-
-    if ((wmi_set_btcoex_fe_ant_cmd(ar->arWmi, &sbfa_cmd)) != 0) {
-        AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Unable to set fornt end antenna configuration\n"));
-        status = A_ERROR;
-    }
-#endif /* INIT_MODE_DRV_ENABLED && ENABLE_COEXISTENCE */
+    status = ath6kl_config_btcoex_params(ar);
+    if (status)
+       return status;
 
 #if WLAN_CONFIG_IGNORE_POWER_SAVE_FAIL_EVENT_DURING_SCAN
     if ((wmi_pmparams_cmd(ar->arWmi, 0, 1, 0, 0, 1, IGNORE_POWER_SAVE_FAIL_EVENT_DURING_SCAN)) != 0) {
@@ -2736,13 +2668,6 @@ int ar6000_init(struct net_device *dev)
             status = ar6000_setup_hci(ar);
         }
 #endif
-#ifdef EXPORT_HCI_PAL_INTERFACE
-        if (setuphcipal && (NULL != ar6kHciPalCallbacks_g.setupTransport))
-          status = ar6kHciPalCallbacks_g.setupTransport(ar);
-#else
-        if(setuphcipal)
-          status = ar6k_setup_hci_pal(ar);
-#endif
 
     } while (false);
 
@@ -2751,6 +2676,38 @@ int ar6000_init(struct net_device *dev)
         goto ar6000_init_done;
     }
 
+       if (regscanmode) {
+               u32 param;
+
+               if (BMIReadMemory(ar->arHifDevice,
+                                 HOST_INTEREST_ITEM_ADDRESS(ar,
+                                                            hi_option_flag),
+                                                            (u8 *)&param,
+                                                            4) != 0) {
+                       AR_DEBUG_PRINTF(ATH_DEBUG_ERR,
+                                       ("BMIReadMemory forsetting "
+                                        "regscanmode failed\n"));
+                       return A_ERROR;
+               }
+
+               if (regscanmode == 1)
+                       param |= HI_OPTION_SKIP_REG_SCAN;
+               else if (regscanmode == 2)
+                       param |= HI_OPTION_INIT_REG_SCAN;
+
+               if (BMIWriteMemory(ar->arHifDevice,
+                                  HOST_INTEREST_ITEM_ADDRESS(ar,
+                                                             hi_option_flag),
+                                                             (u8 *)&param,
+                                                             4) != 0) {
+                       AR_DEBUG_PRINTF(ATH_DEBUG_ERR,
+                                       ("BMIWriteMemory forsetting "
+                                       "regscanmode failed\n"));
+                       return A_ERROR;
+               }
+               AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("Regulatory scan mode set\n"));
+       }
+
     /*
      * give our connected endpoints some buffers
      */
@@ -3095,7 +3052,6 @@ ar6000_data_tx(struct sk_buff *skb, struct net_device *dev)
         }
 
         if (ar->arWmiEnabled) {
-#ifdef CONFIG_CHECKSUM_OFFLOAD
         u8 csumStart=0;
         u8 csumDest=0;
         u8 csum=skb->ip_summed;
@@ -3104,7 +3060,6 @@ ar6000_data_tx(struct sk_buff *skb, struct net_device *dev)
                         sizeof(ATH_LLC_SNAP_HDR));
             csumDest=skb->csum_offset+csumStart;
         }
-#endif
             if (A_NETBUF_HEADROOM(skb) < dev->hard_header_len - LINUX_HACK_FUDGE_FACTOR) {
                 struct sk_buff  *newbuf;
 
@@ -3135,7 +3090,6 @@ ar6000_data_tx(struct sk_buff *skb, struct net_device *dev)
                     break;
                 }
             }
-#ifdef CONFIG_CHECKSUM_OFFLOAD
             if(csumOffload && (csum ==CHECKSUM_PARTIAL)){
                 WMI_TX_META_V2  metaV2;
                 metaV2.csumStart =csumStart;
@@ -3149,7 +3103,6 @@ ar6000_data_tx(struct sk_buff *skb, struct net_device *dev)
 
             }
             else
-#endif
             {
                 if (wmi_data_hdr_add(ar->arWmi, skb, DATA_MSGTYPE, bMoreData, dot11Hdr,0,NULL) != 0) {
                     AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("ar6000_data_tx - wmi_data_hdr_add failed\n"));
@@ -3704,8 +3657,23 @@ ar6000_rx(void *Context, struct htc_packet *pPacket)
                 WMI_DATA_HDR *dhdr = (WMI_DATA_HDR *)A_NETBUF_DATA(skb);
                 bool is_amsdu;
                 u8 tid;
-                bool is_acl_data_frame;
-                is_acl_data_frame = WMI_DATA_HDR_GET_DATA_TYPE(dhdr) == WMI_DATA_HDR_DATA_TYPE_ACL;
+
+               /*
+                * This check can be removed if after a while we do not
+                * see the warning. For now we leave it to ensure
+                * we drop these frames accordingly in case the
+                * target generates them for some reason. These
+                * were used for an internal PAL but that's not
+                * used or supported anymore. These frames should
+                * not come up from the target.
+                */
+                if (WARN_ON(WMI_DATA_HDR_GET_DATA_TYPE(dhdr) ==
+                           WMI_DATA_HDR_DATA_TYPE_ACL)) {
+                       AR6000_STAT_INC(ar, rx_errors);
+                       A_NETBUF_FREE(skb);
+                       return;
+               }
+
 #ifdef CONFIG_PM 
                 ar6000_check_wow_status(ar, NULL, false);
 #endif /* CONFIG_PM */
@@ -3727,7 +3695,7 @@ ar6000_rx(void *Context, struct htc_packet *pPacket)
                  * ACL data frames don't follow ethernet frame bounds for
                  * min length
                  */
-                if (ar->arNetworkType != AP_NETWORK &&  !is_acl_data_frame &&
+                if (ar->arNetworkType != AP_NETWORK &&
                     ((pPacket->ActualLength < minHdrLen) ||
                     (pPacket->ActualLength > AR6000_MAX_RX_MESSAGE_SIZE)))
                 {
@@ -3767,11 +3735,9 @@ ar6000_rx(void *Context, struct htc_packet *pPacket)
                             case WMI_META_VERSION_1:
                                 offset += sizeof(WMI_RX_META_V1);
                                 break;
-#ifdef CONFIG_CHECKSUM_OFFLOAD
                             case WMI_META_VERSION_2:
                                 offset += sizeof(WMI_RX_META_V2);
                                 break;
-#endif
                             default:
                                 break;
                         }
@@ -3841,7 +3807,6 @@ ar6000_rx(void *Context, struct htc_packet *pPacket)
                                 A_NETBUF_PULL((void*)skb, sizeof(WMI_RX_META_V1));
                                 break;
                             }
-#ifdef CONFIG_CHECKSUM_OFFLOAD
                         case WMI_META_VERSION_2:
                             {
                                 WMI_RX_META_V2 *pMeta = (WMI_RX_META_V2 *)A_NETBUF_DATA(skb);
@@ -3852,7 +3817,6 @@ ar6000_rx(void *Context, struct htc_packet *pPacket)
                                 A_NETBUF_PULL((void*)skb, sizeof(WMI_RX_META_V2));
                                 break;
                             }
-#endif
                         default:
                             break;
                     }
@@ -3862,7 +3826,7 @@ ar6000_rx(void *Context, struct htc_packet *pPacket)
                     /* NWF: print the 802.11 hdr bytes */
                     if(containsDot11Hdr) {
                         status = wmi_dot11_hdr_remove(ar->arWmi,skb);
-                    } else if(!is_amsdu && !is_acl_data_frame) {
+                    } else if(!is_amsdu) {
                         status = wmi_dot3_2_dix(skb);
                     }
 
@@ -3872,16 +3836,6 @@ ar6000_rx(void *Context, struct htc_packet *pPacket)
                         goto rx_done;
                     }
 
-                    if (is_acl_data_frame) {
-                        A_NETBUF_PUSH(skb, sizeof(int));
-                        *((short *)A_NETBUF_DATA(skb)) = WMI_ACL_DATA_EVENTID;
-                       /* send the data packet to PAL driver */
-                       if(ar6k_pal_config_g.fpar6k_pal_recv_pkt) {
-                               if((*ar6k_pal_config_g.fpar6k_pal_recv_pkt)(ar->hcipal_info, skb) == true)
-                                       goto rx_done;
-                       }
-                    }
-
                     if ((ar->arNetDev->flags & IFF_UP) == IFF_UP) {
                         if (ar->arNetworkType == AP_NETWORK) {
                             struct sk_buff *skb1 = NULL;
@@ -3915,9 +3869,7 @@ ar6000_rx(void *Context, struct htc_packet *pPacket)
                             }
                         }
                     }
-#ifdef ATH_AR6K_11N_SUPPORT
                     aggr_process_recv_frm(ar->aggr_cntxt, tid, seq_no, is_amsdu, (void **)&skb);
-#endif
                     ar6000_deliver_frames_to_nw_stack((void *) ar->arNetDev, (void *)skb);
                 }
             }
@@ -4146,93 +4098,6 @@ ar6000_get_stats(struct net_device *dev)
     return &ar->arNetStats;
 }
 
-static struct iw_statistics *
-ar6000_get_iwstats(struct net_device * dev)
-{
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-    TARGET_STATS *pStats = &ar->arTargetStats;
-    struct iw_statistics * pIwStats = &ar->arIwStats;
-    int rtnllocked;
-
-    if (ar->bIsDestroyProgress || ar->arWmiReady == false || ar->arWlanState == WLAN_DISABLED)
-    {
-        pIwStats->status = 0;
-        pIwStats->qual.qual = 0;
-        pIwStats->qual.level =0;
-        pIwStats->qual.noise = 0;
-        pIwStats->discard.code =0;
-        pIwStats->discard.retries=0;
-        pIwStats->miss.beacon =0;
-        return pIwStats;
-    }
-
-    /*
-     * The in_atomic function is used to determine if the scheduling is
-     * allowed in the current context or not. This was introduced in 2.6
-     * From what I have read on the differences between 2.4 and 2.6, the
-     * 2.4 kernel did not support preemption and so this check might not
-     * be required for 2.4 kernels.
-     */
-    if (in_atomic())
-    {
-        wmi_get_stats_cmd(ar->arWmi);
-
-        pIwStats->status = 1 ;
-        pIwStats->qual.qual = pStats->cs_aveBeacon_rssi - 161;
-        pIwStats->qual.level =pStats->cs_aveBeacon_rssi; /* noise is -95 dBm */
-        pIwStats->qual.noise = pStats->noise_floor_calibation;
-        pIwStats->discard.code = pStats->rx_decrypt_err;
-        pIwStats->discard.retries = pStats->tx_retry_cnt;
-        pIwStats->miss.beacon = pStats->cs_bmiss_cnt;
-        return pIwStats;
-    }
-
-    dev_hold(dev);   
-    rtnllocked = rtnl_is_locked();
-    if (rtnllocked) {
-        rtnl_unlock();
-    }
-    pIwStats->status = 0;
-
-    if (down_interruptible(&ar->arSem)) {
-        goto err_exit;
-    }
-    
-    do {
-
-        if (ar->bIsDestroyProgress || ar->arWlanState == WLAN_DISABLED) {
-            break;
-        }
-    
-        ar->statsUpdatePending = true;
-    
-        if(wmi_get_stats_cmd(ar->arWmi) != 0) {
-            break;
-        }
-    
-        wait_event_interruptible_timeout(arEvent, ar->statsUpdatePending == false, wmitimeout * HZ);
-        if (signal_pending(current)) {
-            AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("ar6000 : WMI get stats timeout \n"));
-            break;
-        }
-        pIwStats->status = 1 ;
-        pIwStats->qual.qual = pStats->cs_aveBeacon_rssi - 161;
-        pIwStats->qual.level =pStats->cs_aveBeacon_rssi;  /* noise is -95 dBm */
-        pIwStats->qual.noise = pStats->noise_floor_calibation;
-        pIwStats->discard.code = pStats->rx_decrypt_err;
-        pIwStats->discard.retries = pStats->tx_retry_cnt;
-        pIwStats->miss.beacon = pStats->cs_bmiss_cnt;
-    } while (0);
-    up(&ar->arSem);
-
-err_exit:
-    if (rtnllocked) {
-        rtnl_lock();
-    }
-    dev_put(dev);
-    return pIwStats;
-}
-
 void
 ar6000_ready_event(void *devt, u8 *datap, u8 phyCap, u32 sw_ver, u32 abi_ver)
 {
@@ -4254,6 +4119,29 @@ ar6000_ready_event(void *devt, u8 *datap, u8 phyCap, u32 sw_ver, u32 abi_ver)
     wake_up(&arEvent);
 }
 
+void ar6000_install_static_wep_keys(struct ar6_softc *ar)
+{
+    u8 index;
+    u8 keyUsage;
+
+    for (index = WMI_MIN_KEY_INDEX; index <= WMI_MAX_KEY_INDEX; index++) {
+        if (ar->arWepKeyList[index].arKeyLen) {
+            keyUsage = GROUP_USAGE;
+            if (index == ar->arDefTxKeyIndex) {
+                keyUsage |= TX_USAGE;
+            }
+            wmi_addKey_cmd(ar->arWmi,
+                           index,
+                           WEP_CRYPT,
+                           keyUsage,
+                           ar->arWepKeyList[index].arKeyLen,
+                           NULL,
+                           ar->arWepKeyList[index].arKey, KEY_OP_INIT_VAL, NULL,
+                           NO_SYNC_WMIFLAG);
+        }
+    }
+}
+
 void
 add_new_sta(struct ar6_softc *ar, u8 *mac, u16 aid, u8 *wpaie,
             u8 ielen, u8 keymgmt, u8 ucipher, u8 auth)
@@ -4344,7 +4232,7 @@ skip_key:
             default:
                 A_PRINTF("AUTH: Unknown\n");
                 break;
-        };
+        }
         switch (listenInterval&0xFF) {
             case WPA_PSK_AUTH:
                 A_PRINTF("KeyMgmt: WPA-PSK\n");
@@ -4355,7 +4243,7 @@ skip_key:
             default:
                 A_PRINTF("KeyMgmt: NONE\n");
                 break;
-        };
+        }
         switch (beaconInterval) {
             case AES_CRYPT:
                 A_PRINTF("Cipher: AES\n");
@@ -4374,7 +4262,7 @@ skip_key:
             default:
                 A_PRINTF("Cipher: NONE\n");
                 break;
-        };
+        }
 
         add_new_sta(ar, bssid, channel /*aid*/,
             assocInfo /* WPA IE */, assocRespLen /* IE len */,
@@ -4392,13 +4280,11 @@ skip_key:
         return;
     }
 
-#ifdef ATH6K_CONFIG_CFG80211
     ar6k_cfg80211_connect_event(ar, channel, bssid,
                                 listenInterval, beaconInterval,
                                 networkType, beaconIeLen,
                                 assocReqLen, assocRespLen,
                                 assocInfo);
-#endif /* ATH6K_CONFIG_CFG80211 */
 
     memcpy(ar->arBssid, bssid, sizeof(ar->arBssid));
     ar->arBssChannel = channel;
@@ -4495,7 +4381,6 @@ skip_key:
         wireless_send_event(ar->arNetDev, IWEVCUSTOM, &wrqu, buf);
     }
 
-#ifdef USER_KEYS
     if (ar->user_savedkeys_stat == USER_SAVEDKEYS_STAT_RUN &&
         ar->user_saved_keys.keyOk == true)
     {
@@ -4508,30 +4393,9 @@ skip_key:
         }
         ar6000_reinstall_keys(ar, key_op_ctrl);
     }
-#endif /* USER_KEYS */
 
     netif_wake_queue(ar->arNetDev);
 
-    /* For CFG80211 the key configuration and the default key comes in after connect so no point in plumbing invalid keys */
-#ifndef ATH6K_CONFIG_CFG80211
-    if ((networkType & ADHOC_NETWORK)      &&
-        (OPEN_AUTH == ar->arDot11AuthMode) &&
-        (NONE_AUTH == ar->arAuthMode)      &&
-        (WEP_CRYPT == ar->arPairwiseCrypto))
-    {
-        if (!ar->arConnected) {
-            wmi_addKey_cmd(ar->arWmi,
-                           ar->arDefTxKeyIndex,
-                           WEP_CRYPT,
-                           GROUP_USAGE | TX_USAGE,
-                           ar->arWepKeyList[ar->arDefTxKeyIndex].arKeyLen,
-                           NULL,
-                           ar->arWepKeyList[ar->arDefTxKeyIndex].arKey, KEY_OP_INIT_VAL, NULL,
-                           NO_SYNC_WMIFLAG);
-        }
-    }
-#endif /* ATH6K_CONFIG_CFG80211 */
-
     /* Update connect & link status atomically */
     spin_lock_irqsave(&ar->arLock, flags);
     ar->arConnected  = true;
@@ -4661,11 +4525,9 @@ ar6000_disconnect_event(struct ar6_softc *ar, u8 reason, u8 *bssid,
         return;
     }
 
-#ifdef ATH6K_CONFIG_CFG80211
     ar6k_cfg80211_disconnect_event(ar, reason, bssid,
                                    assocRespLen, assocInfo,
                                    protocolReasonStatus);
-#endif /* ATH6K_CONFIG_CFG80211 */
 
     /* Send disconnect event to supplicant */
     A_MEMZERO(&wrqu, sizeof(wrqu));
@@ -4751,13 +4613,11 @@ ar6000_disconnect_event(struct ar6_softc *ar, u8 reason, u8 *bssid,
         reconnect_flag = 0;
     }
 
-#ifdef USER_KEYS
     if (reason != CSERV_DISCONNECT)
     {
         ar->user_savedkeys_stat = USER_SAVEDKEYS_STAT_INIT;
         ar->user_key_ctrl      = 0;
     }
-#endif /* USER_KEYS */
 
     netif_stop_queue(ar->arNetDev);
     A_MEMZERO(ar->arBssid, sizeof(ar->arBssid));
@@ -4774,7 +4634,6 @@ ar6000_regDomain_event(struct ar6_softc *ar, u32 regCode)
     ar->arRegCode = regCode;
 }
 
-#ifdef ATH_AR6K_11N_SUPPORT
 void
 ar6000_aggr_rcv_addba_req_evt(struct ar6_softc *ar, WMI_ADDBA_REQ_EVENT *evt)
 {
@@ -4796,7 +4655,6 @@ ar6000_aggr_rcv_delba_req_evt(struct ar6_softc *ar, WMI_DELBA_EVENT *evt)
 {
     aggr_recv_delba_req_evt(ar->aggr_cntxt, evt->tid);
 }
-#endif
 
 void register_pal_cb(ar6k_pal_config_t *palConfig_p)
 {
@@ -4828,12 +4686,6 @@ ar6000_hci_event_rcv_evt(struct ar6_softc *ar, WMI_HCI_EVENT *cmd)
     buf += sizeof(int);
     memcpy(buf, cmd->buf, cmd->evt_buf_sz);
 
-    if(ar6k_pal_config_g.fpar6k_pal_recv_pkt)
-    {
-      /* pass the cmd packet to PAL driver */
-      if((*ar6k_pal_config_g.fpar6k_pal_recv_pkt)(ar->hcipal_info, osbuf) == true)
-        return;
-    }
     ar6000_deliver_frames_to_nw_stack(ar->arNetDev, osbuf);
     if(loghci) {
         A_PRINTF_LOG("HCI Event From PAL <-- \n");
@@ -4883,7 +4735,7 @@ ar6000_neighborReport_event(struct ar6_softc *ar, int numAps, WMI_NEIGHBOR_INFO
         memcpy(pmkcand->bssid.sa_data, info->bssid, ATH_MAC_LEN);
         wrqu.data.length = sizeof(struct iw_pmkid_cand);
         wireless_send_event(ar->arNetDev, IWEVPMKIDCAND, &wrqu, (char *)pmkcand);
-        A_FREE(pmkcand);
+        kfree(pmkcand);
 #else /* WIRELESS_EXT >= 18 */
         snprintf(buf, sizeof(buf), "%s%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x",
                  tag,
@@ -4918,9 +4770,7 @@ ar6000_tkip_micerr_event(struct ar6_softc *ar, u8 keyid, bool ismcast)
             tag, s->mac[0],s->mac[1],s->mac[2],s->mac[3],s->mac[4],s->mac[5]);
     } else {
 
-#ifdef ATH6K_CONFIG_CFG80211
     ar6k_cfg80211_tkip_micerr_event(ar, keyid, ismcast);
-#endif /* ATH6K_CONFIG_CFG80211 */
 
         A_PRINTF("AR6000 TKIP MIC error received for keyid %d %scast\n",
              keyid & 0x3, ismcast ? "multi": "uni");
@@ -4937,9 +4787,7 @@ void
 ar6000_scanComplete_event(struct ar6_softc *ar, int status)
 {
 
-#ifdef ATH6K_CONFIG_CFG80211
     ar6k_cfg80211_scanComplete_event(ar, status);
-#endif /* ATH6K_CONFIG_CFG80211 */
 
     if (!ar->arUserBssFilter) {
         wmi_bssfilter_cmd(ar->arWmi, NONE_BSS_FILTER, 0);
@@ -5097,19 +4945,13 @@ ar6000_rssiThreshold_event(struct ar6_softc *ar,  WMI_RSSI_THRESHOLD_VAL newThre
     userRssiThold.rssi = rssi;
     A_PRINTF("rssi Threshold range = %d tag = %d  rssi = %d\n", newThreshold,
              userRssiThold.tag, userRssiThold.rssi);
-
-    ar6000_send_event_to_app(ar, WMI_RSSI_THRESHOLD_EVENTID,(u8 *)&userRssiThold, sizeof(USER_RSSI_THOLD));
 }
 
 
 void
 ar6000_hbChallengeResp_event(struct ar6_softc *ar, u32 cookie, u32 source)
 {
-    if (source == APP_HB_CHALLENGE) {
-        /* Report it to the app in case it wants a positive acknowledgement */
-        ar6000_send_event_to_app(ar, WMIX_HB_CHALLENGE_RESP_EVENTID,
-                                 (u8 *)&cookie, sizeof(cookie));
-    } else {
+    if (source != APP_HB_CHALLENGE) {
         /* This would ignore the replys that come in after their due time */
         if (cookie == ar->arHBChallengeResp.seqNum) {
             ar->arHBChallengeResp.outstanding = false;
@@ -5562,100 +5404,6 @@ ar6000_alloc_cookie(struct ar6_softc  *ar)
     return cookie;
 }
 
-#ifdef SEND_EVENT_TO_APP
-/*
- * This function is used to send event which come from taget to
- * the application. The buf which send to application is include
- * the event ID and event content.
- */
-#define EVENT_ID_LEN   2
-void ar6000_send_event_to_app(struct ar6_softc *ar, u16 eventId,
-                              u8 *datap, int len)
-{
-
-#if (WIRELESS_EXT >= 15)
-
-/* note: IWEVCUSTOM only exists in wireless extensions after version 15 */
-
-    char *buf;
-    u16 size;
-    union iwreq_data wrqu;
-
-    size = len + EVENT_ID_LEN;
-
-    if (size > IW_CUSTOM_MAX) {
-        AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("WMI event ID : 0x%4.4X, len = %d too big for IWEVCUSTOM (max=%d) \n",
-                eventId, size, IW_CUSTOM_MAX));
-        return;
-    }
-
-    buf = A_MALLOC_NOWAIT(size);
-    if (NULL == buf){
-        AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("%s: failed to allocate %d bytes\n", __func__, size));
-        return;
-    }
-
-    A_MEMZERO(buf, size);
-    memcpy(buf, &eventId, EVENT_ID_LEN);
-    memcpy(buf+EVENT_ID_LEN, datap, len);
-
-    //AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("event ID = %d,len = %d\n",*(u16 *)buf, size));
-    A_MEMZERO(&wrqu, sizeof(wrqu));
-    wrqu.data.length = size;
-    wireless_send_event(ar->arNetDev, IWEVCUSTOM, &wrqu, buf);
-    A_FREE(buf);
-#endif
-
-
-}
-
-/*
- * This function is used to send events larger than 256 bytes
- * to the application. The buf which is sent to application
- * includes the event ID and event content.
- */
-void ar6000_send_generic_event_to_app(struct ar6_softc *ar, u16 eventId,
-                                      u8 *datap, int len)
-{
-
-#if (WIRELESS_EXT >= 18)
-
-/* IWEVGENIE exists in wireless extensions version 18 onwards */
-
-    char *buf;
-    u16 size;
-    union iwreq_data wrqu;
-
-    size = len + EVENT_ID_LEN;
-
-    if (size > IW_GENERIC_IE_MAX) {
-        AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("WMI event ID : 0x%4.4X, len = %d too big for IWEVGENIE (max=%d) \n",
-                        eventId, size, IW_GENERIC_IE_MAX));
-        return;
-    }
-
-    buf = A_MALLOC_NOWAIT(size);
-    if (NULL == buf){
-        AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("%s: failed to allocate %d bytes\n", __func__, size));
-        return;
-    }
-
-    A_MEMZERO(buf, size);
-    memcpy(buf, &eventId, EVENT_ID_LEN);
-    memcpy(buf+EVENT_ID_LEN, datap, len);
-
-    A_MEMZERO(&wrqu, sizeof(wrqu));
-    wrqu.data.length = size;
-    wireless_send_event(ar->arNetDev, IWEVGENIE, &wrqu, buf);
-
-    A_FREE(buf);
-
-#endif /* (WIRELESS_EXT >= 18) */
-
-}
-#endif /* SEND_EVENT_TO_APP */
-
-
 void
 ar6000_tx_retry_err_event(void *devt)
 {
@@ -5666,13 +5414,9 @@ void
 ar6000_snrThresholdEvent_rx(void *devt, WMI_SNR_THRESHOLD_VAL newThreshold, u8 snr)
 {
     WMI_SNR_THRESHOLD_EVENT event;
-    struct ar6_softc *ar = (struct ar6_softc *)devt;
 
     event.range = newThreshold;
     event.snr = snr;
-
-    ar6000_send_event_to_app(ar, WMI_SNR_THRESHOLD_EVENTID, (u8 *)&event,
-                             sizeof(WMI_SNR_THRESHOLD_EVENT));
 }
 
 void
@@ -5999,9 +5743,7 @@ void ap_wapi_rekey_event(struct ar6_softc *ar, u8 type, u8 *mac)
 }
 #endif
 
-#ifdef USER_KEYS
 static int
-
 ar6000_reinstall_keys(struct ar6_softc *ar, u8 key_op_ctrl)
 {
     int status = 0;
@@ -6046,7 +5788,6 @@ _reinstall_keys_out:
 
     return status;
 }
-#endif /* USER_KEYS */
 
 
 void
index 1a9042446bcb6a318dfab1a5d7656460fd35d9d8..1e0ace8b6d137958a30c3af67d1deb490e4386b4 100644 (file)
@@ -36,9 +36,6 @@
 extern unsigned int wmitimeout;
 extern wait_queue_head_t arEvent;
 
-#ifdef ANDROID_ENV
-extern void android_ar6k_check_wow_status(struct ar6_softc *ar, struct sk_buff *skb, bool isEvent);
-#endif
 #undef ATH_MODULE_NAME
 #define ATH_MODULE_NAME pm
 #define  ATH_DEBUG_PM       ATH_DEBUG_MAKE_MODULE_MASK(0)
@@ -283,10 +280,6 @@ void ar6000_check_wow_status(struct ar6_softc *ar, struct sk_buff *skb, bool isE
         /* Wow resume from irq interrupt */
         AR_DEBUG_PRINTF(ATH_DEBUG_PM, ("%s: WoW resume from irq thread status %d\n", __func__, ar->arWlanPowerState));
         ar6000_wow_resume(ar);
-    } else {
-#ifdef ANDROID_ENV
-        android_ar6k_check_wow_status(ar, skb, isEvent);
-#endif
     }
 }
 
@@ -309,37 +302,6 @@ int ar6000_power_change_ev(void *context, u32 config)
     return status;
 }
 
-static int ar6000_pm_probe(struct platform_device *pdev)
-{
-    plat_setup_power(1,1);
-    return 0;
-}
-
-static int ar6000_pm_remove(struct platform_device *pdev)
-{
-    plat_setup_power(0,1);
-    return 0;
-}
-
-static int ar6000_pm_suspend(struct platform_device *pdev, pm_message_t state)
-{
-    return 0;
-}
-
-static int ar6000_pm_resume(struct platform_device *pdev)
-{
-    return 0;
-}
-
-static struct platform_driver ar6000_pm_device = {
-    .probe      = ar6000_pm_probe,
-    .remove     = ar6000_pm_remove,
-    .suspend    = ar6000_pm_suspend,
-    .resume     = ar6000_pm_resume,
-    .driver     = {
-        .name = "wlan_ar6000_pm",
-    },
-};
 #endif /* CONFIG_PM */
 
 int
@@ -359,8 +321,6 @@ ar6000_setup_cut_power_state(struct ar6_softc *ar,  AR6000_WLAN_STATE state)
                 break;
             }
 
-            plat_setup_power(1,0);
-
             /* Change the state to ON */
             ar->arWlanPowerState = WLAN_POWER_STATE_ON;
 
@@ -373,17 +333,6 @@ ar6000_setup_cut_power_state(struct ar6_softc *ar,  AR6000_WLAN_STATE state)
                                 sizeof(HIF_DEVICE_POWER_CHANGE_TYPE));
 
             if (status == A_PENDING) {
-#ifdef ANDROID_ENV
-                 /* Wait for WMI ready event */
-                u32 timeleft = wait_event_interruptible_timeout(arEvent,
-                            (ar->arWmiReady == true), wmitimeout * HZ);
-                if (!timeleft || signal_pending(current)) {
-                    AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("ar6000 : Failed to get wmi ready \n"));
-                    status = A_ERROR;
-                    break;
-                }
-#endif
-                status = 0;
             } else if (status == 0) {
                 ar6000_restart_endpoint(ar->arNetDev);
                 status = 0;
@@ -403,8 +352,6 @@ ar6000_setup_cut_power_state(struct ar6_softc *ar,  AR6000_WLAN_STATE state)
                                 &config,
                                 sizeof(HIF_DEVICE_POWER_CHANGE_TYPE));
 
-            plat_setup_power(0,0);
-
             ar->arWlanPowerState = WLAN_POWER_STATE_CUT_PWR;
         }
     } while (0);
@@ -642,8 +589,6 @@ ar6000_update_wlan_pwr_state(struct ar6_softc *ar, AR6000_WLAN_STATE state, bool
         }
         if (pSleepEvent) {
             AR_DEBUG_PRINTF(ATH_DEBUG_PM, ("SENT WLAN Sleep Event %d\n", wmiSleepEvent.sleepState));
-            ar6000_send_event_to_app(ar, WMI_REPORT_SLEEP_STATE_EVENTID, (u8 *)pSleepEvent,
-                                     sizeof(WMI_REPORT_SLEEP_STATE_EVENTID));
         }
     }
     up(&ar->arSem);
@@ -679,25 +624,3 @@ ar6000_set_wlan_state(struct ar6_softc *ar, AR6000_WLAN_STATE state)
     status = ar6000_update_wlan_pwr_state(ar, state, false);
     return status;
 }
-
-void ar6000_pm_init()
-{
-    A_REGISTER_MODULE_DEBUG_INFO(pm);
-#ifdef CONFIG_PM
-    /*
-     * Register ar6000_pm_device into system.
-     * We should also add platform_device into the first item of array
-     * of devices[] in file arch/xxx/mach-xxx/board-xxxx.c
-     */
-    if (platform_driver_register(&ar6000_pm_device)) {
-        AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("ar6000: fail to register the power control driver.\n"));
-    }
-#endif /* CONFIG_PM */
-}
-
-void ar6000_pm_exit()
-{
-#ifdef CONFIG_PM
-    platform_driver_unregister(&ar6000_pm_device);
-#endif /* CONFIG_PM */
-}
diff --git a/drivers/staging/ath6kl/os/linux/ar6k_pal.c b/drivers/staging/ath6kl/os/linux/ar6k_pal.c
deleted file mode 100644 (file)
index 1f7179a..0000000
+++ /dev/null
@@ -1,479 +0,0 @@
-//------------------------------------------------------------------------------
-// Copyright (c) 2004-2010 Atheros Communications Inc.
-// All rights reserved.
-//
-// 
-//
-// Permission to use, copy, modify, and/or distribute this software for any
-// purpose with or without fee is hereby granted, provided that the above
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-//
-//
-//
-// Author(s): ="Atheros"
-//------------------------------------------------------------------------------
-
-#include "ar6000_drv.h"
-#ifdef AR6K_ENABLE_HCI_PAL
-#include <net/bluetooth/bluetooth.h>
-#include <net/bluetooth/hci_core.h>
-#include <ar6k_pal.h>
-
-extern unsigned int setupbtdev;
-#define bt_check_bit(val, bit) (val & bit)
-#define bt_set_bit(val, bit) (val |= bit)
-#define bt_clear_bit(val, bit) (val &= ~bit)
-
-/* export ATH_AR6K_DEBUG_HCI_PAL=yes in host/localmake.linux.inc
- * to enable debug information */
-#ifdef HCIPAL_DEBUG
-#define PRIN_LOG(format, args...) printk(KERN_ALERT "%s:%d - %s Msg:" format "\n",__FUNCTION__, __LINE__, __FILE__, ## args) 
-#else
-#define PRIN_LOG(format, args...)
-#endif
-
-/**********************************
- * HCI PAL private info structure 
- *********************************/
-typedef struct ar6k_hci_pal_info_s{
-
-       unsigned long ulFlags;
-#define HCI_NORMAL_MODE (1)
-#define HCI_REGISTERED (1<<1)
-       struct hci_dev *hdev;            /* BT Stack HCI dev */
-       struct ar6_softc *ar;
-
-}ar6k_hci_pal_info_t;
-
-/*** BT Stack Entrypoints *******/
-/***************************************
- * bt_open - open a handle to the device
- ***************************************/
-static int bt_open(struct hci_dev *hdev)
-{
-       PRIN_LOG("HCI PAL: bt_open - enter - x\n");
-       set_bit(HCI_RUNNING, &hdev->flags);
-       set_bit(HCI_UP, &hdev->flags);
-       set_bit(HCI_INIT, &hdev->flags);         
-       return 0;
-}
-
-/***************************************
- * bt_close - close handle to the device
- ***************************************/
-static int bt_close(struct hci_dev *hdev)
-{
-       PRIN_LOG("HCI PAL: bt_close - enter\n");
-       clear_bit(HCI_RUNNING, &hdev->flags);
-       return 0;
-}
-
-/*****************************
- * bt_ioctl - ioctl processing
- *****************************/
-static int bt_ioctl(struct hci_dev *hdev, unsigned int cmd, unsigned long arg)
-{
-       PRIN_LOG("HCI PAL: bt_ioctl - enter\n");
-       return -ENOIOCTLCMD;
-}
-
-/**************************************
- * bt_flush - flush outstanding packets
- **************************************/
-static int bt_flush(struct hci_dev *hdev)
-{
-       PRIN_LOG("HCI PAL: bt_flush - enter\n");
-       return 0;
-}
-
-/***************
- * bt_destruct  
- ***************/
-static void bt_destruct(struct hci_dev *hdev)
-{
-       PRIN_LOG("HCI PAL: bt_destruct - enter\n");
-       /* nothing to do here */
-}
-
-/****************************************************
- * Invoked from bluetooth stack via hdev->send()
- * to send the packet out via ar6k to PAL firmware.
- *
- * For HCI command packet wmi_send_hci_cmd() is invoked.
- * wmi_send_hci_cmd adds WMI_CMD_HDR and sends the packet
- * to PAL firmware.
- *
- * For HCI ACL data packet wmi_data_hdr_add is invoked 
- * to add WMI_DATA_HDR to the packet.  ar6000_acl_data_tx 
- * is then invoked to send the packet to PAL firmware.
- ******************************************************/
-static int btpal_send_frame(struct sk_buff *skb)
-{
-       struct hci_dev *hdev = (struct hci_dev *)skb->dev;
-       HCI_TRANSPORT_PACKET_TYPE type;
-       ar6k_hci_pal_info_t *pHciPalInfo;
-       int status = 0;
-       struct sk_buff *txSkb = NULL;
-       struct ar6_softc *ar;
-
-       if (!hdev) {
-               PRIN_LOG("HCI PAL: btpal_send_frame - no device\n");
-               return -ENODEV;
-       }
-
-       if (!test_bit(HCI_RUNNING, &hdev->flags)) {
-               PRIN_LOG("HCI PAL: btpal_send_frame - not open\n");
-               return -EBUSY;
-       }
-
-       pHciPalInfo = (ar6k_hci_pal_info_t *)hdev->driver_data;   
-       A_ASSERT(pHciPalInfo != NULL);
-       ar = pHciPalInfo->ar;
-
-       PRIN_LOG("+btpal_send_frame type: %d \n",bt_cb(skb)->pkt_type);
-       type = HCI_COMMAND_TYPE;
-
-       switch (bt_cb(skb)->pkt_type) {
-               case HCI_COMMAND_PKT:
-                       type = HCI_COMMAND_TYPE;
-                       hdev->stat.cmd_tx++;
-                       break;
-
-               case HCI_ACLDATA_PKT:
-                       type = HCI_ACL_TYPE;
-                       hdev->stat.acl_tx++;
-                       break;
-
-               case HCI_SCODATA_PKT:
-                       /* we don't support SCO over the pal */
-                       kfree_skb(skb);
-                       return 0;
-               default:
-                       A_ASSERT(false);
-                       kfree_skb(skb);
-                       return 0;
-       } 
-
-       if (AR_DEBUG_LVL_CHECK(ATH_DEBUG_HCI_DUMP)) {
-               A_PRINTF(">>> Send HCI %s packet len: %d\n",
-                               (type == HCI_COMMAND_TYPE) ? "COMMAND" : "ACL",
-                               skb->len);
-               if (type == HCI_COMMAND_TYPE) {
-                       PRIN_LOG("    HCI Command: OGF:0x%X OCF:0x%X \r\n", 
-                                       HCI_GET_OP_CODE(skb-data) >> 10, HCI_GET_OP_CODE(skb-data) & 0x3FF);
-               }
-               AR_DEBUG_PRINTBUF(skb->data,skb->len,"BT HCI SEND Packet Dump");
-       }
-
-       do {
-               if(type == HCI_COMMAND_TYPE)
-               {
-                       PRIN_LOG("HCI command");
-
-                       if (ar->arWmiReady == false)
-                       {
-                               PRIN_LOG("WMI not ready ");
-                               break;
-                       }
-
-                       if (wmi_send_hci_cmd(ar->arWmi, skb->data, skb->len) != 0)
-                       {
-                               PRIN_LOG("send hci cmd error");
-                               break;
-                       }
-               }
-               else if(type == HCI_ACL_TYPE)
-               {
-                       void *osbuf;
-
-                       PRIN_LOG("ACL data");
-                       if (ar->arWmiReady == false)
-                       {
-                               PRIN_LOG("WMI not ready");
-                               break;
-                       }
-
-                       /* need to add WMI header so allocate a skb with more space */
-                       txSkb = bt_skb_alloc(TX_PACKET_RSV_OFFSET + WMI_MAX_TX_META_SZ + 
-                                       sizeof(WMI_DATA_HDR) + skb->len, 
-                                       GFP_ATOMIC);
-
-                       if (txSkb == NULL) {
-                               status = A_NO_MEMORY;
-                               PRIN_LOG("No memory");
-                               break;
-                       }
-
-                       bt_cb(txSkb)->pkt_type = bt_cb(skb)->pkt_type;
-                       txSkb->dev = (void *)pHciPalInfo->hdev;
-                       skb_reserve(txSkb, TX_PACKET_RSV_OFFSET + WMI_MAX_TX_META_SZ + sizeof(WMI_DATA_HDR));
-                       memcpy(txSkb->data, skb->data, skb->len);
-                       skb_put(txSkb,skb->len);
-                       /* Add WMI packet type */
-                       osbuf = (void *)txSkb;
-
-                       if (wmi_data_hdr_add(ar->arWmi, osbuf, DATA_MSGTYPE, 0, WMI_DATA_HDR_DATA_TYPE_ACL,0,NULL) != 0) {
-                               PRIN_LOG("XIOCTL_ACL_DATA - wmi_data_hdr_add failed\n");
-                       } else {
-                               /* Send data buffer over HTC */
-                               PRIN_LOG("acl data tx");
-                               ar6000_acl_data_tx(osbuf, ar->arNetDev);
-                       }
-                       txSkb = NULL;
-               }
-       } while (false);
-
-       if (txSkb != NULL) {
-               PRIN_LOG("Free skb");
-               kfree_skb(txSkb);    
-       }
-       kfree_skb(skb);        
-       return 0;
-}
-
-
-/***********************************************
- * Unregister HCI device and free HCI device info
- ***********************************************/
-static void bt_cleanup_hci_pal(ar6k_hci_pal_info_t *pHciPalInfo)
-{   
-       int err;      
-
-       if (bt_check_bit(pHciPalInfo->ulFlags, HCI_REGISTERED)) {
-               bt_clear_bit(pHciPalInfo->ulFlags, HCI_REGISTERED);
-               clear_bit(HCI_RUNNING, &pHciPalInfo->hdev->flags);
-               clear_bit(HCI_UP, &pHciPalInfo->hdev->flags);
-               clear_bit(HCI_INIT, &pHciPalInfo->hdev->flags);   
-               A_ASSERT(pHciPalInfo->hdev != NULL);
-               /* unregister */
-               PRIN_LOG("Unregister PAL device");
-               if ((err = hci_unregister_dev(pHciPalInfo->hdev)) < 0) {
-                       PRIN_LOG("HCI PAL: failed to unregister with bluetooth %d\n",err);
-               }          
-       }
-
-       kfree(pHciPalInfo->hdev);
-       pHciPalInfo->hdev = NULL;
-}
-
-/*********************************************************
- * Allocate HCI device and store in PAL private info structure.
- *********************************************************/
-static int bt_setup_hci_pal(ar6k_hci_pal_info_t *pHciPalInfo)
-{
-       int status = 0;
-       struct hci_dev *pHciDev = NULL;
-
-       if (!setupbtdev) {
-               return 0;
-       } 
-
-       do {
-               /* allocate a BT HCI struct for this device */
-               pHciDev = hci_alloc_dev();
-               if (NULL == pHciDev) {
-                       PRIN_LOG("HCI PAL driver - failed to allocate BT HCI struct \n");
-                       status = A_NO_MEMORY;
-                       break;
-               }    
-
-               /* save the device, we'll register this later */
-               pHciPalInfo->hdev = pHciDev;       
-                SET_HCI_BUS_TYPE(pHciDev, HCI_VIRTUAL, HCI_80211);
-               pHciDev->driver_data = pHciPalInfo;
-               pHciDev->open     = bt_open;
-               pHciDev->close    = bt_close;
-               pHciDev->send     = btpal_send_frame;
-               pHciDev->ioctl    = bt_ioctl;
-               pHciDev->flush    = bt_flush;
-               pHciDev->destruct = bt_destruct;
-               pHciDev->owner = THIS_MODULE; 
-               /* driver is running in normal BT mode */
-               PRIN_LOG("Normal mode enabled");
-               bt_set_bit(pHciPalInfo->ulFlags, HCI_NORMAL_MODE);
-
-       } while (false);
-
-       if (status) {
-               bt_cleanup_hci_pal(pHciPalInfo);    
-       }
-       return status;
-}
-
-/**********************************************
- * Cleanup HCI device and free HCI PAL private info
- *********************************************/
-void ar6k_cleanup_hci_pal(void *ar_p)
-{
-       struct ar6_softc *ar = (struct ar6_softc *)ar_p;
-       ar6k_hci_pal_info_t *pHciPalInfo = (ar6k_hci_pal_info_t *)ar->hcipal_info;
-
-       if (pHciPalInfo != NULL) {
-               bt_cleanup_hci_pal(pHciPalInfo);   
-               A_FREE(pHciPalInfo);
-               ar->hcipal_info = NULL;
-       }
-}
-
-/****************************
- *  Register HCI device
- ****************************/
-static bool ar6k_pal_transport_ready(void *pHciPal)
-{
-       ar6k_hci_pal_info_t *pHciPalInfo = (ar6k_hci_pal_info_t *)pHciPal;
-
-       PRIN_LOG("HCI device transport ready");
-       if(pHciPalInfo == NULL)
-               return false;
-
-       if (hci_register_dev(pHciPalInfo->hdev) < 0) {
-               PRIN_LOG("Can't register HCI device");
-               hci_free_dev(pHciPalInfo->hdev);
-               return false;
-       }
-       PRIN_LOG("HCI device registered");
-       pHciPalInfo->ulFlags |= HCI_REGISTERED;
-       return true;
-}
-
-/**************************************************
- * Called from ar6k driver when command or ACL data 
- * packet is received. Pass the packet to bluetooth
- * stack via hci_recv_frame.
- **************************************************/
-bool ar6k_pal_recv_pkt(void *pHciPal, void *osbuf)
-{
-       struct sk_buff *skb = (struct sk_buff *)osbuf;
-       ar6k_hci_pal_info_t *pHciPalInfo;
-       bool success = false;
-       u8 btType = 0;
-       pHciPalInfo = (ar6k_hci_pal_info_t *)pHciPal;
-
-       do {
-
-               /* if normal mode is not enabled pass on to the stack
-                * by returning failure */
-               if(!(pHciPalInfo->ulFlags & HCI_NORMAL_MODE))
-               {
-                       PRIN_LOG("Normal mode not enabled");
-                       break;
-               }
-
-               if (!test_bit(HCI_RUNNING, &pHciPalInfo->hdev->flags)) {
-                       PRIN_LOG("HCI PAL: HCI - not running\n");
-                       break;
-               }
-
-               if(*((short *)A_NETBUF_DATA(skb)) == WMI_ACL_DATA_EVENTID)
-                       btType = HCI_ACLDATA_PKT;
-               else
-                       btType = HCI_EVENT_PKT;
-               /* pull 4 bytes which contains WMI packet type */
-               A_NETBUF_PULL(skb, sizeof(int));
-               bt_cb(skb)->pkt_type = btType;
-               skb->dev = (void *)pHciPalInfo->hdev;
-
-               /* pass the received event packet up the stack */    
-               if (hci_recv_frame(skb) != 0) {
-                       PRIN_LOG("HCI PAL: hci_recv_frame failed \n");
-                       break;
-               } else {
-                       PRIN_LOG("HCI PAL: Indicated RCV of type:%d, Length:%d \n",HCI_EVENT_PKT, skb->len);
-               }
-               PRIN_LOG("hci recv success");
-               success = true;
-       }while(false);
-       return success;
-}
-
-/**********************************************************
- * HCI PAL init function called from ar6k when it is loaded..
- * Allocates PAL private info, stores the same in ar6k private info.
- * Registers a HCI device.
- * Registers packet receive callback function with ar6k 
- **********************************************************/
-int ar6k_setup_hci_pal(void *ar_p)
-{
-       int status = 0;
-       ar6k_hci_pal_info_t *pHciPalInfo;
-       ar6k_pal_config_t ar6k_pal_config;
-       struct ar6_softc *ar = (struct ar6_softc *)ar_p;
-
-       do {
-
-               pHciPalInfo = (ar6k_hci_pal_info_t *)A_MALLOC(sizeof(ar6k_hci_pal_info_t));
-
-               if (NULL == pHciPalInfo) {
-                       status = A_NO_MEMORY;
-                       break;    
-               }
-
-               A_MEMZERO(pHciPalInfo, sizeof(ar6k_hci_pal_info_t));
-               ar->hcipal_info = pHciPalInfo;
-               pHciPalInfo->ar = ar;
-
-               status = bt_setup_hci_pal(pHciPalInfo);
-               if (status) {
-                       break;    
-               }
-
-               if(bt_check_bit(pHciPalInfo->ulFlags, HCI_NORMAL_MODE))
-                       PRIN_LOG("HCI PAL: running in normal mode... \n");    
-               else 
-                       PRIN_LOG("HCI PAL: running in test mode... \n");     
-
-               ar6k_pal_config.fpar6k_pal_recv_pkt = ar6k_pal_recv_pkt;
-               register_pal_cb(&ar6k_pal_config);
-               ar6k_pal_transport_ready(ar->hcipal_info);
-       } while (false);
-
-       if (status) {
-               ar6k_cleanup_hci_pal(ar);    
-       }
-       return status;
-}
-#else  /* AR6K_ENABLE_HCI_PAL */
-int ar6k_setup_hci_pal(void *ar_p)
-{
-       return 0;
-}
-void ar6k_cleanup_hci_pal(void *ar_p)
-{
-}
-#endif /* AR6K_ENABLE_HCI_PAL */
-
-#ifdef EXPORT_HCI_PAL_INTERFACE
-/*****************************************************
- * Register init and callback function with ar6k
- * when PAL driver is a separate kernel module.
- ****************************************************/
-int ar6k_register_hci_pal(struct hci_transport_callbacks *hciTransCallbacks);
-static int __init pal_init_module(void)
-{
-       struct hci_transport_callbacks hciTransCallbacks;
-
-       hciTransCallbacks.setupTransport = ar6k_setup_hci_pal;
-       hciTransCallbacks.cleanupTransport = ar6k_cleanup_hci_pal;
-
-       if(ar6k_register_hci_pal(&hciTransCallbacks) != 0)
-               return -ENODEV;
-
-       return 0;
-}
-
-static void __exit pal_cleanup_module(void)
-{
-}
-
-module_init(pal_init_module);
-module_exit(pal_cleanup_module);
-MODULE_LICENSE("Dual BSD/GPL");
-#endif
index bcca39418f904f9bfe90c1dabcb9ae226e8e94ba..31d7ba8299e7ab2df701d2d5d04c646140e6ce53 100644 (file)
@@ -172,6 +172,12 @@ ar6k_set_auth_type(struct ar6_softc *ar, enum nl80211_auth_type auth_type)
     case NL80211_AUTHTYPE_NETWORK_EAP:
         ar->arDot11AuthMode = LEAP_AUTH;
         break;
+
+    case NL80211_AUTHTYPE_AUTOMATIC:
+        ar->arDot11AuthMode = OPEN_AUTH;
+        ar->arAutoAuthStage = AUTH_OPEN_IN_PROGRESS;
+        break;
+
     default:
         ar->arDot11AuthMode = OPEN_AUTH;
         AR_DEBUG_PRINTF(ATH_DEBUG_INFO,
@@ -460,6 +466,8 @@ ar6k_cfg80211_connect_event(struct ar6_softc *ar, u16 channel,
     assocReqLen -= assocReqIeOffset;
     assocRespLen -= assocRespIeOffset;
 
+    ar->arAutoAuthStage = AUTH_IDLE;
+
     if((ADHOC_NETWORK & networkType)) {
         if(NL80211_IFTYPE_ADHOC != ar->wdev->iftype) {
             AR_DEBUG_PRINTF(ATH_DEBUG_INFO,
@@ -487,74 +495,83 @@ ar6k_cfg80211_connect_event(struct ar6_softc *ar, u16 channel,
                            ((ADHOC_NETWORK & networkType) ? WLAN_CAPABILITY_IBSS : WLAN_CAPABILITY_ESS),
                            ((ADHOC_NETWORK & networkType) ? WLAN_CAPABILITY_IBSS : WLAN_CAPABILITY_ESS));
 
-    if(!bss) {
-        if (ADHOC_NETWORK & networkType) {
+    /*
+     * Earlier we were updating the cfg about bss by making a beacon frame
+     * only if the entry for bss is not there. This can have some issue if
+     * ROAM event is generated and a heavy traffic is ongoing. The ROAM
+     * event is handled through a work queue and by the time it really gets
+     * handled, BSS would have been aged out. So it is better to update the
+     * cfg about BSS irrespective of its entry being present right now or
+     * not.
+     */
+
+    if (ADHOC_NETWORK & networkType) {
             /* construct 802.11 mgmt beacon */
             if(ptr_ie_buf) {
-                *ptr_ie_buf++ = WLAN_EID_SSID;
-                *ptr_ie_buf++ = ar->arSsidLen;
-                memcpy(ptr_ie_buf, ar->arSsid, ar->arSsidLen);
-                ptr_ie_buf +=ar->arSsidLen;
+                   *ptr_ie_buf++ = WLAN_EID_SSID;
+                   *ptr_ie_buf++ = ar->arSsidLen;
+                   memcpy(ptr_ie_buf, ar->arSsid, ar->arSsidLen);
+                   ptr_ie_buf +=ar->arSsidLen;
 
-                *ptr_ie_buf++ = WLAN_EID_IBSS_PARAMS;
-                *ptr_ie_buf++ = 2; /* length */
-                *ptr_ie_buf++ = 0; /* ATIM window */
-                *ptr_ie_buf++ = 0; /* ATIM window */
+                   *ptr_ie_buf++ = WLAN_EID_IBSS_PARAMS;
+                   *ptr_ie_buf++ = 2; /* length */
+                   *ptr_ie_buf++ = 0; /* ATIM window */
+                   *ptr_ie_buf++ = 0; /* ATIM window */
 
-                /* TODO: update ibss params and include supported rates,
-                 * DS param set, extened support rates, wmm. */
+                   /* TODO: update ibss params and include supported rates,
+                    * DS param set, extened support rates, wmm. */
 
-                ie_buf_len = ptr_ie_buf - ie_buf;
+                   ie_buf_len = ptr_ie_buf - ie_buf;
             }
 
             capability |= IEEE80211_CAPINFO_IBSS;
             if(WEP_CRYPT == ar->arPairwiseCrypto) {
-                capability |= IEEE80211_CAPINFO_PRIVACY;
+                   capability |= IEEE80211_CAPINFO_PRIVACY;
             }
             memcpy(source_mac, ar->arNetDev->dev_addr, ATH_MAC_LEN);
             ptr_ie_buf = ie_buf;
-        } else {
+    } else {
             capability = *(u16 *)(&assocInfo[beaconIeLen]);
             memcpy(source_mac, bssid, ATH_MAC_LEN);
             ptr_ie_buf = assocReqIe;
             ie_buf_len = assocReqLen;
-        }
+    }
 
-        size = offsetof(struct ieee80211_mgmt, u)
-             + sizeof(mgmt->u.beacon)
-             + ie_buf_len;
+    size = offsetof(struct ieee80211_mgmt, u)
+           + sizeof(mgmt->u.beacon)
+           + ie_buf_len;
 
-        ieeemgmtbuf = A_MALLOC_NOWAIT(size);
-        if(!ieeemgmtbuf) {
+    ieeemgmtbuf = A_MALLOC_NOWAIT(size);
+    if(!ieeemgmtbuf) {
             AR_DEBUG_PRINTF(ATH_DEBUG_ERR,
                             ("%s: ieeeMgmtbuf alloc error\n", __func__));
+           cfg80211_put_bss(bss);
             return;
-        }
+    }
 
-        A_MEMZERO(ieeemgmtbuf, size);
-        mgmt = (struct ieee80211_mgmt *)ieeemgmtbuf;
-        mgmt->frame_control = (IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
-        memcpy(mgmt->da, bcast_mac, ATH_MAC_LEN);
-        memcpy(mgmt->sa, source_mac, ATH_MAC_LEN);
-        memcpy(mgmt->bssid, bssid, ATH_MAC_LEN);
-        mgmt->u.beacon.beacon_int = beaconInterval;
-        mgmt->u.beacon.capab_info = capability;
-        memcpy(mgmt->u.beacon.variable, ptr_ie_buf, ie_buf_len);
+    A_MEMZERO(ieeemgmtbuf, size);
+    mgmt = (struct ieee80211_mgmt *)ieeemgmtbuf;
+    mgmt->frame_control = (IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
+    memcpy(mgmt->da, bcast_mac, ATH_MAC_LEN);
+    memcpy(mgmt->sa, source_mac, ATH_MAC_LEN);
+    memcpy(mgmt->bssid, bssid, ATH_MAC_LEN);
+    mgmt->u.beacon.beacon_int = beaconInterval;
+    mgmt->u.beacon.capab_info = capability;
+    memcpy(mgmt->u.beacon.variable, ptr_ie_buf, ie_buf_len);
 
-        ibss_channel = ieee80211_get_channel(ar->wdev->wiphy, (int)channel);
+    ibss_channel = ieee80211_get_channel(ar->wdev->wiphy, (int)channel);
 
-       AR_DEBUG_PRINTF(ATH_DEBUG_INFO,
-               ("%s: inform bss with bssid %pM channel %d beaconInterval %d "
-                       "capability 0x%x\n", __func__, mgmt->bssid,
-                       ibss_channel->hw_value, beaconInterval, capability));
+    AR_DEBUG_PRINTF(ATH_DEBUG_INFO,
+                   ("%s: inform bss with bssid %pM channel %d beaconInterval %d "
+                    "capability 0x%x\n", __func__, mgmt->bssid,
+                    ibss_channel->hw_value, beaconInterval, capability));
 
-        bss = cfg80211_inform_bss_frame(ar->wdev->wiphy,
-                                        ibss_channel, mgmt,
-                                        le16_to_cpu(size),
-                                        signal, GFP_KERNEL);
-        A_FREE(ieeemgmtbuf);
-        cfg80211_put_bss(bss);
-    }
+    bss = cfg80211_inform_bss_frame(ar->wdev->wiphy,
+                                   ibss_channel, mgmt,
+                                   le16_to_cpu(size),
+                                   signal, GFP_KERNEL);
+    kfree(ieeemgmtbuf);
+    cfg80211_put_bss(bss);
 
     if((ADHOC_NETWORK & networkType)) {
         cfg80211_ibss_joined(ar->arNetDev, bssid, GFP_KERNEL);
@@ -625,8 +642,14 @@ ar6k_cfg80211_disconnect_event(struct ar6_softc *ar, u8 reason,
                                u8 *assocInfo, u16 protocolReasonStatus)
 {
 
+    u16 status;
+
     AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s: reason=%u\n", __func__, reason));
 
+    if (ar->scan_request) {
+       cfg80211_scan_done(ar->scan_request, true);
+        ar->scan_request = NULL;
+    }
     if((ADHOC_NETWORK & ar->arNetworkType)) {
         if(NL80211_IFTYPE_ADHOC != ar->wdev->iftype) {
             AR_DEBUG_PRINTF(ATH_DEBUG_INFO,
@@ -651,23 +674,70 @@ ar6k_cfg80211_disconnect_event(struct ar6_softc *ar, u8 reason,
             /* connect cmd failed */
             wmi_disconnect_cmd(ar->arWmi);
         } else if (reason == DISCONNECT_CMD) {
-            /* connection loss due to disconnect cmd or low rssi */
-            ar->arConnectPending = false;   
-            if (ar->smeState == SME_CONNECTING) {
-                cfg80211_connect_result(ar->arNetDev, bssid,
-                                        NULL, 0,
-                                        NULL, 0,
-                                        WLAN_STATUS_UNSPECIFIED_FAILURE,
-                                        GFP_KERNEL);
-            } else {
-                cfg80211_disconnected(ar->arNetDev, reason, NULL, 0, GFP_KERNEL);
-            }
-            ar->smeState = SME_DISCONNECTED;
-        }
+               if (ar->arAutoAuthStage) {
+                       /*
+                        * If the current auth algorithm is open try shared
+                        * and make autoAuthStage idle. We do not make it
+                        * leap for now being.
+                        */
+                       if (ar->arDot11AuthMode == OPEN_AUTH) {
+                               struct ar_key *key = NULL;
+                               key = &ar->keys[ar->arDefTxKeyIndex];
+                               if (down_interruptible(&ar->arSem)) {
+                                       AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("%s: busy, couldn't get access\n", __func__));
+                                       return;
+                               }
+
+
+                               ar->arDot11AuthMode = SHARED_AUTH;
+                               ar->arAutoAuthStage = AUTH_IDLE;
+
+                               wmi_addKey_cmd(ar->arWmi, ar->arDefTxKeyIndex,
+                                               ar->arPairwiseCrypto,
+                                               GROUP_USAGE | TX_USAGE,
+                                               key->key_len,
+                                               NULL,
+                                               key->key, KEY_OP_INIT_VAL, NULL,
+                                               NO_SYNC_WMIFLAG);
+
+                               status = wmi_connect_cmd(ar->arWmi,
+                                                        ar->arNetworkType,
+                                                        ar->arDot11AuthMode,
+                                                        ar->arAuthMode,
+                                                        ar->arPairwiseCrypto,
+                                                        ar->arPairwiseCryptoLen,
+                                                        ar->arGroupCrypto,
+                                                        ar->arGroupCryptoLen,
+                                                        ar->arSsidLen,
+                                                        ar->arSsid,
+                                                        ar->arReqBssid,
+                                                        ar->arChannelHint,
+                                                        ar->arConnectCtrlFlags);
+                               up(&ar->arSem);
+
+                       } else if (ar->arDot11AuthMode == SHARED_AUTH) {
+                               /* should not reach here */
+                       }
+               } else {
+                       ar->arConnectPending = false;
+                       if (ar->smeState == SME_CONNECTING) {
+                               cfg80211_connect_result(ar->arNetDev, bssid,
+                                                       NULL, 0,
+                                                       NULL, 0,
+                                                       WLAN_STATUS_UNSPECIFIED_FAILURE,
+                                                       GFP_KERNEL);
+                       } else {
+                               cfg80211_disconnected(ar->arNetDev,
+                                                     reason,
+                                                     NULL, 0,
+                                                     GFP_KERNEL);
+                       }
+                       ar->smeState = SME_DISCONNECTED;
+               }
+       }
     } else {
-        if (reason != DISCONNECT_CMD) {
-            wmi_disconnect_cmd(ar->arWmi);
-        }
+           if (reason != DISCONNECT_CMD)
+                   wmi_disconnect_cmd(ar->arWmi);
     }
 }
 
@@ -729,7 +799,7 @@ ar6k_cfg80211_scan_node(void *arg, bss_t *ni)
                               le16_to_cpu(size),
                               signal, GFP_KERNEL);
 
-    A_FREE (ieeemgmtbuf);
+    kfree (ieeemgmtbuf);
 }
 
 static int
@@ -1205,10 +1275,10 @@ ar6k_cfg80211_set_power_mgmt(struct wiphy *wiphy,
 
     if(pmgmt) {
         AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s: Max Perf\n", __func__));
-        pwrMode.powerMode = MAX_PERF_POWER;
+        pwrMode.powerMode = REC_POWER;
     } else {
         AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s: Rec Power\n", __func__));
-        pwrMode.powerMode = REC_POWER;
+        pwrMode.powerMode = MAX_PERF_POWER;
     }
 
     if(wmi_powermode_cmd(ar->arWmi, pwrMode.powerMode) != 0) {
@@ -1391,6 +1461,151 @@ u32 cipher_suites[] = {
     WLAN_CIPHER_SUITE_CCMP,
 };
 
+bool is_rate_legacy(s32 rate)
+{
+       static const s32 legacy[] = { 1000, 2000, 5500, 11000,
+                                     6000, 9000, 12000, 18000, 24000,
+                                     36000, 48000, 54000 };
+       u8 i;
+
+       for (i = 0; i < ARRAY_SIZE(legacy); i++) {
+               if (rate == legacy[i])
+                       return true;
+       }
+
+       return false;
+}
+
+bool is_rate_ht20(s32 rate, u8 *mcs, bool *sgi)
+{
+       static const s32 ht20[] = { 6500, 13000, 19500, 26000, 39000,
+                                   52000, 58500, 65000, 72200 };
+       u8 i;
+
+       for (i = 0; i < ARRAY_SIZE(ht20); i++) {
+               if (rate == ht20[i]) {
+                       if (i == ARRAY_SIZE(ht20) - 1)
+                               /* last rate uses sgi */
+                               *sgi = true;
+                       else
+                               *sgi = false;
+
+                       *mcs = i;
+                       return true;
+               }
+       }
+       return false;
+}
+
+bool is_rate_ht40(s32 rate, u8 *mcs, bool *sgi)
+{
+       static const s32 ht40[] = { 13500, 27000, 40500, 54000,
+                                   81000, 108000, 121500, 135000,
+                                   150000 };
+       u8 i;
+
+       for (i = 0; i < ARRAY_SIZE(ht40); i++) {
+               if (rate == ht40[i]) {
+                       if (i == ARRAY_SIZE(ht40) - 1)
+                               /* last rate uses sgi */
+                               *sgi = true;
+                       else
+                               *sgi = false;
+
+                       *mcs = i;
+                       return true;
+               }
+       }
+
+       return false;
+}
+
+static int ar6k_get_station(struct wiphy *wiphy, struct net_device *dev,
+                           u8 *mac, struct station_info *sinfo)
+{
+       struct ar6_softc *ar = ar6k_priv(dev);
+       long left;
+       bool sgi;
+       s32 rate;
+       int ret;
+       u8 mcs;
+
+       if (memcmp(mac, ar->arBssid, ETH_ALEN) != 0)
+               return -ENOENT;
+
+       if (down_interruptible(&ar->arSem))
+               return -EBUSY;
+
+       ar->statsUpdatePending = true;
+
+       ret = wmi_get_stats_cmd(ar->arWmi);
+
+       if (ret != 0) {
+               up(&ar->arSem);
+               return -EIO;
+       }
+
+       left = wait_event_interruptible_timeout(arEvent,
+                                               ar->statsUpdatePending == false,
+                                               wmitimeout * HZ);
+
+       up(&ar->arSem);
+
+       if (left == 0)
+               return -ETIMEDOUT;
+       else if (left < 0)
+               return left;
+
+       if (ar->arTargetStats.rx_bytes) {
+               sinfo->rx_bytes = ar->arTargetStats.rx_bytes;
+               sinfo->filled |= STATION_INFO_RX_BYTES;
+               sinfo->rx_packets = ar->arTargetStats.rx_packets;
+               sinfo->filled |= STATION_INFO_RX_PACKETS;
+       }
+
+       if (ar->arTargetStats.tx_bytes) {
+               sinfo->tx_bytes = ar->arTargetStats.tx_bytes;
+               sinfo->filled |= STATION_INFO_TX_BYTES;
+               sinfo->tx_packets = ar->arTargetStats.tx_packets;
+               sinfo->filled |= STATION_INFO_TX_PACKETS;
+       }
+
+       sinfo->signal = ar->arTargetStats.cs_rssi;
+       sinfo->filled |= STATION_INFO_SIGNAL;
+
+       rate = ar->arTargetStats.tx_unicast_rate;
+
+       if (is_rate_legacy(rate)) {
+               sinfo->txrate.legacy = rate / 100;
+       } else if (is_rate_ht20(rate, &mcs, &sgi)) {
+               if (sgi) {
+                       sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
+                       sinfo->txrate.mcs = mcs - 1;
+               } else {
+                       sinfo->txrate.mcs = mcs;
+               }
+
+               sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
+       } else if (is_rate_ht40(rate, &mcs, &sgi)) {
+               if (sgi) {
+                       sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
+                       sinfo->txrate.mcs = mcs - 1;
+               } else {
+                       sinfo->txrate.mcs = mcs;
+               }
+
+               sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
+               sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
+       } else {
+               WARN(1, "invalid rate: %d", rate);
+               return 0;
+       }
+
+       sinfo->filled |= STATION_INFO_TX_BITRATE;
+
+       return 0;
+}
+
 static struct
 cfg80211_ops ar6k_cfg80211_ops = {
     .change_virtual_intf = ar6k_cfg80211_change_iface,
@@ -1411,6 +1626,7 @@ cfg80211_ops ar6k_cfg80211_ops = {
     .set_power_mgmt = ar6k_cfg80211_set_power_mgmt,
     .join_ibss = ar6k_cfg80211_join_ibss,
     .leave_ibss = ar6k_cfg80211_leave_ibss,
+    .get_station = ar6k_get_station,
 };
 
 struct wireless_dev *
diff --git a/drivers/staging/ath6kl/os/linux/eeprom.c b/drivers/staging/ath6kl/os/linux/eeprom.c
deleted file mode 100644 (file)
index 4cff9da..0000000
+++ /dev/null
@@ -1,574 +0,0 @@
-//------------------------------------------------------------------------------
-// Copyright (c) 2004-2010 Atheros Communications Inc.
-// All rights reserved.
-//
-// 
-//
-// Permission to use, copy, modify, and/or distribute this software for any
-// purpose with or without fee is hereby granted, provided that the above
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-//
-//
-//
-// Author(s): ="Atheros"
-//------------------------------------------------------------------------------
-
-
-#include "ar6000_drv.h"
-#include "htc.h"
-#include <linux/fs.h>
-
-#include "AR6002/hw2.0/hw/gpio_reg.h"
-#include "AR6002/hw2.0/hw/si_reg.h"
-
-//
-// defines
-//
-
-#define MAX_FILENAME 1023
-#define EEPROM_WAIT_LIMIT 16 
-
-#define HOST_INTEREST_ITEM_ADDRESS(item)          \
-        (AR6002_HOST_INTEREST_ITEM_ADDRESS(item))
-
-#define EEPROM_SZ 768
-
-/* soft mac */
-#define ATH_MAC_LEN                         6
-#define ATH_SOFT_MAC_TMP_BUF_LEN            64
-unsigned char mac_addr[ATH_MAC_LEN];
-unsigned char soft_mac_tmp_buf[ATH_SOFT_MAC_TMP_BUF_LEN];
-char *p_mac = NULL;
-/* soft mac */
-
-//
-// static variables
-//
-
-static u8 eeprom_data[EEPROM_SZ];
-static u32 sys_sleep_reg;
-static struct hif_device *p_bmi_device;
-
-//
-// Functions
-//
-
-/* soft mac */
-static int
-wmic_ether_aton(const char *orig, u8 *eth)
-{
-  const char *bufp;
-  int i;
-
-  i = 0;
-  for(bufp = orig; *bufp != '\0'; ++bufp) {
-    unsigned int val;
-       int h, l;
-
-       h = hex_to_bin(*bufp++);
-
-       if (h < 0) {
-               printk("%s: MAC value is invalid\n", __FUNCTION__);
-               break;
-       }
-
-       l = hex_to_bin(*bufp++);
-       if (l < 0) {
-               printk("%s: MAC value is invalid\n", __FUNCTION__);
-               break;
-       }
-
-       val = (h << 4) | l;
-
-    eth[i] = (unsigned char) (val & 0377);
-    if(++i == ATH_MAC_LEN) {
-           /* That's it.  Any trailing junk? */
-           if (*bufp != '\0') {
-                   return 0;
-           }
-           return 1;
-    }
-    if (*bufp != ':')
-           break;
-  }
-  return 0;
-}
-
-static void
-update_mac(unsigned char *eeprom, int size, unsigned char *macaddr)
-{
-       int i;
-       u16 *ptr = (u16 *)(eeprom+4);
-       u16 checksum = 0;
-
-       memcpy(eeprom+10,macaddr,6);
-
-       *ptr = 0;
-       ptr = (u16 *)eeprom;
-
-       for (i=0; i<size; i+=2) {
-               checksum ^= *ptr++;
-       }
-       checksum = ~checksum;
-
-       ptr = (u16 *)(eeprom+4);
-       *ptr = checksum;
-       return;
-}
-/* soft mac */
-
-/* Read a Target register and return its value. */
-inline void
-BMI_read_reg(u32 address, u32 *pvalue)
-{
-    BMIReadSOCRegister(p_bmi_device, address, pvalue);
-}
-
-/* Write a value to a Target register. */
-inline void
-BMI_write_reg(u32 address, u32 value)
-{
-    BMIWriteSOCRegister(p_bmi_device, address, value);
-}
-
-/* Read Target memory word and return its value. */
-inline void
-BMI_read_mem(u32 address, u32 *pvalue)
-{
-    BMIReadMemory(p_bmi_device, address, (u8*)(pvalue), 4);
-}
-
-/* Write a word to a Target memory. */
-inline void
-BMI_write_mem(u32 address, u8 *p_data, u32 sz)
-{
-    BMIWriteMemory(p_bmi_device, address, (u8*)(p_data), sz); 
-}
-
-/*
- * Enable and configure the Target's Serial Interface
- * so we can access the EEPROM.
- */
-static void
-enable_SI(struct hif_device *p_device)
-{
-    u32 regval;
-
-    printk("%s\n", __FUNCTION__);
-
-    p_bmi_device = p_device;
-
-    BMI_read_reg(RTC_BASE_ADDRESS+SYSTEM_SLEEP_OFFSET, &sys_sleep_reg);
-    BMI_write_reg(RTC_BASE_ADDRESS+SYSTEM_SLEEP_OFFSET, SYSTEM_SLEEP_DISABLE_SET(1)); //disable system sleep temporarily
-
-    BMI_read_reg(RTC_BASE_ADDRESS+CLOCK_CONTROL_OFFSET, &regval);
-    regval &= ~CLOCK_CONTROL_SI0_CLK_MASK;
-    BMI_write_reg(RTC_BASE_ADDRESS+CLOCK_CONTROL_OFFSET, regval);
-
-    BMI_read_reg(RTC_BASE_ADDRESS+RESET_CONTROL_OFFSET, &regval);
-    regval &= ~RESET_CONTROL_SI0_RST_MASK;
-    BMI_write_reg(RTC_BASE_ADDRESS+RESET_CONTROL_OFFSET, regval);
-
-
-    BMI_read_reg(GPIO_BASE_ADDRESS+GPIO_PIN0_OFFSET, &regval);
-    regval &= ~GPIO_PIN0_CONFIG_MASK;
-    BMI_write_reg(GPIO_BASE_ADDRESS+GPIO_PIN0_OFFSET, regval);
-
-    BMI_read_reg(GPIO_BASE_ADDRESS+GPIO_PIN1_OFFSET, &regval);
-    regval &= ~GPIO_PIN1_CONFIG_MASK;
-    BMI_write_reg(GPIO_BASE_ADDRESS+GPIO_PIN1_OFFSET, regval);
-
-    /* SI_CONFIG = 0x500a6; */
-    regval =    SI_CONFIG_BIDIR_OD_DATA_SET(1)  |
-                SI_CONFIG_I2C_SET(1)            |
-                SI_CONFIG_POS_SAMPLE_SET(1)     |
-                SI_CONFIG_INACTIVE_CLK_SET(1)   |
-                SI_CONFIG_INACTIVE_DATA_SET(1)   |
-                SI_CONFIG_DIVIDER_SET(6);
-    BMI_write_reg(SI_BASE_ADDRESS+SI_CONFIG_OFFSET, regval);
-    
-}
-
-static void
-disable_SI(void)
-{
-    u32 regval;
-    
-    printk("%s\n", __FUNCTION__);
-
-    BMI_write_reg(RTC_BASE_ADDRESS+RESET_CONTROL_OFFSET, RESET_CONTROL_SI0_RST_MASK);
-    BMI_read_reg(RTC_BASE_ADDRESS+CLOCK_CONTROL_OFFSET, &regval);
-    regval |= CLOCK_CONTROL_SI0_CLK_MASK;
-    BMI_write_reg(RTC_BASE_ADDRESS+CLOCK_CONTROL_OFFSET, regval);//Gate SI0 clock
-    BMI_write_reg(RTC_BASE_ADDRESS+SYSTEM_SLEEP_OFFSET, sys_sleep_reg); //restore system sleep setting
-}
-
-/*
- * Tell the Target to start an 8-byte read from EEPROM,
- * putting the results in Target RX_DATA registers.
- */
-static void
-request_8byte_read(int offset)
-{
-    u32 regval;
-
-//    printk("%s: request_8byte_read from offset 0x%x\n", __FUNCTION__, offset);
-
-    
-    /* SI_TX_DATA0 = read from offset */
-        regval =(0xa1<<16)|
-                ((offset & 0xff)<<8)    |
-                (0xa0 | ((offset & 0xff00)>>7));
-    
-        BMI_write_reg(SI_BASE_ADDRESS+SI_TX_DATA0_OFFSET, regval);
-
-        regval = SI_CS_START_SET(1)      |
-                SI_CS_RX_CNT_SET(8)     |
-                SI_CS_TX_CNT_SET(3);
-        BMI_write_reg(SI_BASE_ADDRESS+SI_CS_OFFSET, regval);
-}
-
-/*
- * Tell the Target to start a 4-byte write to EEPROM,
- * writing values from Target TX_DATA registers.
- */
-static void
-request_4byte_write(int offset, u32 data)
-{
-    u32 regval;
-
-    printk("%s: request_4byte_write (0x%x) to offset 0x%x\n", __FUNCTION__, data, offset);
-
-        /* SI_TX_DATA0 = write data to offset */
-        regval =    ((data & 0xffff) <<16)    |
-                ((offset & 0xff)<<8)    |
-                (0xa0 | ((offset & 0xff00)>>7));
-        BMI_write_reg(SI_BASE_ADDRESS+SI_TX_DATA0_OFFSET, regval);
-
-        regval =    data >> 16;
-        BMI_write_reg(SI_BASE_ADDRESS+SI_TX_DATA1_OFFSET, regval);
-
-        regval =    SI_CS_START_SET(1)      |
-                SI_CS_RX_CNT_SET(0)     |
-                SI_CS_TX_CNT_SET(6);
-        BMI_write_reg(SI_BASE_ADDRESS+SI_CS_OFFSET, regval);
-}
-
-/*
- * Check whether or not an EEPROM request that was started
- * earlier has completed yet.
- */
-static bool
-request_in_progress(void)
-{
-    u32 regval;
-
-    /* Wait for DONE_INT in SI_CS */
-    BMI_read_reg(SI_BASE_ADDRESS+SI_CS_OFFSET, &regval);
-
-//    printk("%s: request in progress SI_CS=0x%x\n", __FUNCTION__, regval);
-    if (regval & SI_CS_DONE_ERR_MASK) {
-        printk("%s: EEPROM signaled ERROR (0x%x)\n", __FUNCTION__, regval);
-    }
-
-    return (!(regval & SI_CS_DONE_INT_MASK));
-}
-
-/*
- * try to detect the type of EEPROM,16bit address or 8bit address
- */
-
-static void eeprom_type_detect(void)
-{
-    u32 regval;
-    u8 i = 0;
-
-    request_8byte_read(0x100);
-   /* Wait for DONE_INT in SI_CS */
-    do{
-        BMI_read_reg(SI_BASE_ADDRESS+SI_CS_OFFSET, &regval);
-        if (regval & SI_CS_DONE_ERR_MASK) {
-            printk("%s: ERROR : address type was wrongly set\n", __FUNCTION__);     
-            break;
-        }
-        if (i++ == EEPROM_WAIT_LIMIT) {
-            printk("%s: EEPROM not responding\n", __FUNCTION__);
-        }
-    } while(!(regval & SI_CS_DONE_INT_MASK));
-}
-
-/*
- * Extract the results of a completed EEPROM Read request
- * and return them to the caller.
- */
-inline void
-read_8byte_results(u32 *data)
-{
-    /* Read SI_RX_DATA0 and SI_RX_DATA1 */
-    BMI_read_reg(SI_BASE_ADDRESS+SI_RX_DATA0_OFFSET, &data[0]);
-    BMI_read_reg(SI_BASE_ADDRESS+SI_RX_DATA1_OFFSET, &data[1]);
-}
-
-
-/*
- * Wait for a previously started command to complete.
- * Timeout if the command is takes "too long".
- */
-static void
-wait_for_eeprom_completion(void)
-{
-    int i=0;
-
-    while (request_in_progress()) {
-        if (i++ == EEPROM_WAIT_LIMIT) {
-            printk("%s: EEPROM not responding\n", __FUNCTION__);
-        }
-    }
-}
-
-/*
- * High-level function which starts an 8-byte read,
- * waits for it to complete, and returns the result.
- */
-static void
-fetch_8bytes(int offset, u32 *data)
-{
-    request_8byte_read(offset);
-    wait_for_eeprom_completion();
-    read_8byte_results(data);
-
-    /* Clear any pending intr */
-    BMI_write_reg(SI_BASE_ADDRESS+SI_CS_OFFSET, SI_CS_DONE_INT_MASK);
-}
-
-/*
- * High-level function which starts a 4-byte write,
- * and waits for it to complete.
- */
-inline void
-commit_4bytes(int offset, u32 data)
-{
-    request_4byte_write(offset, data);
-    wait_for_eeprom_completion();
-}
-/* ATHENV */
-#ifdef ANDROID_ENV
-void eeprom_ar6000_transfer(struct hif_device *device, char *fake_file, char *p_mac)
-{
-    u32 first_word;
-    u32 board_data_addr;
-    int i;
-
-    printk("%s: Enter\n", __FUNCTION__);
-
-    enable_SI(device);
-    eeprom_type_detect();
-
-    if (fake_file) {
-        /*
-         * Transfer from file to Target RAM.
-         * Fetch source data from file.
-         */
-        mm_segment_t           oldfs;
-        struct file            *filp;
-        struct inode           *inode = NULL;
-        int                    length;
-
-        /* open file */
-        oldfs = get_fs();
-        set_fs(KERNEL_DS);
-        filp = filp_open(fake_file, O_RDONLY, S_IRUSR);
-
-        if (IS_ERR(filp)) {
-            printk("%s: file %s filp_open error\n", __FUNCTION__, fake_file);
-            set_fs(oldfs);
-            return;
-        }
-
-        if (!filp->f_op) {
-            printk("%s: File Operation Method Error\n", __FUNCTION__);
-            filp_close(filp, NULL);
-            set_fs(oldfs);
-            return;
-        }
-
-        inode = GET_INODE_FROM_FILEP(filep);
-        if (!inode) {
-            printk("%s: Get inode from filp failed\n", __FUNCTION__);
-            filp_close(filp, NULL);
-            set_fs(oldfs);
-            return;
-        }
-
-        printk("%s file offset opsition: %xh\n", __FUNCTION__, (unsigned)filp->f_pos);
-
-        /* file's size */
-        length = i_size_read(inode->i_mapping->host);
-        printk("%s: length=%d\n", __FUNCTION__, length);
-        if (length != EEPROM_SZ) {
-            printk("%s: The file's size is not as expected\n", __FUNCTION__);
-            filp_close(filp, NULL);
-            set_fs(oldfs);
-            return;
-        }
-
-        /* read data */
-        if (filp->f_op->read(filp, eeprom_data, length, &filp->f_pos) != length) {
-            printk("%s: file read error\n", __FUNCTION__);
-            filp_close(filp, NULL);
-            set_fs(oldfs);
-            return;
-        }
-
-        /* read data out successfully */
-        filp_close(filp, NULL);
-        set_fs(oldfs);
-    } else {
-        /*
-         * Read from EEPROM to file OR transfer from EEPROM to Target RAM.
-         * Fetch EEPROM_SZ Bytes of Board Data, 8 bytes at a time.
-         */
-
-        fetch_8bytes(0, (u32 *)(&eeprom_data[0]));
-
-        /* Check the first word of EEPROM for validity */
-        first_word = *((u32 *)eeprom_data);
-
-        if ((first_word == 0) || (first_word == 0xffffffff)) {
-            printk("Did not find EEPROM with valid Board Data.\n");
-        }
-
-        for (i=8; i<EEPROM_SZ; i+=8) {
-            fetch_8bytes(i, (u32 *)(&eeprom_data[i]));
-        }
-    }
-
-    /* soft mac */
-    if (p_mac) {
-
-        mm_segment_t           oldfs;
-        struct file            *filp;
-        struct inode           *inode = NULL;
-        int                    length;
-        
-        /* open file */
-        oldfs = get_fs();
-        set_fs(KERNEL_DS);
-        filp = filp_open(p_mac, O_RDONLY, S_IRUSR);
-        
-        printk("%s try to open file %s\n", __FUNCTION__, p_mac);
-
-        if (IS_ERR(filp)) {
-            printk("%s: file %s filp_open error\n", __FUNCTION__, p_mac);
-            set_fs(oldfs);
-            return;
-        }
-        
-        if (!filp->f_op) {
-            printk("%s: File Operation Method Error\n", __FUNCTION__);
-            filp_close(filp, NULL);
-            set_fs(oldfs);
-            return;
-        }
-        
-        inode = GET_INODE_FROM_FILEP(filep);
-        if (!inode) {
-            printk("%s: Get inode from filp failed\n", __FUNCTION__);
-            filp_close(filp, NULL);
-            set_fs(oldfs);
-            return;
-        }
-        
-        printk("%s file offset opsition: %xh\n", __FUNCTION__, (unsigned)filp->f_pos);
-        
-        /* file's size */
-        length = i_size_read(inode->i_mapping->host);
-        printk("%s: length=%d\n", __FUNCTION__, length);
-        if (length > ATH_SOFT_MAC_TMP_BUF_LEN) {
-            printk("%s: MAC file's size is not as expected\n", __FUNCTION__);
-            filp_close(filp, NULL);
-            set_fs(oldfs);
-            return;
-        }
-        
-        /* read data */
-        if (filp->f_op->read(filp, soft_mac_tmp_buf, length, &filp->f_pos) != length) {
-            printk("%s: file read error\n", __FUNCTION__);
-            filp_close(filp, NULL);
-            set_fs(oldfs);
-            return;
-        }
-
-#if 0
-        /* the data we just read */
-        printk("%s: mac address from the file:\n", __FUNCTION__);
-        for (i = 0; i < length; i++)
-            printk("[%c(0x%x)],", soft_mac_tmp_buf[i], soft_mac_tmp_buf[i]);
-        printk("\n");
-#endif
-
-        /* read data out successfully */
-        filp_close(filp, NULL);
-        set_fs(oldfs);
-
-        /* convert mac address */
-        if (!wmic_ether_aton(soft_mac_tmp_buf, mac_addr)) {
-            printk("%s: convert mac value fail\n", __FUNCTION__);
-            return;
-        }
-
-#if 0
-        /* the converted mac address */
-        printk("%s: the converted mac value\n", __FUNCTION__);
-        for (i = 0; i < ATH_MAC_LEN; i++)
-            printk("[0x%x],", mac_addr[i]);
-        printk("\n");
-#endif
-    }
-    /* soft mac */
-
-    /* Determine where in Target RAM to write Board Data */
-    BMI_read_mem( HOST_INTEREST_ITEM_ADDRESS(hi_board_data), &board_data_addr);
-    if (board_data_addr == 0) {
-        printk("hi_board_data is zero\n");
-    }
-
-    /* soft mac */
-#if 1
-    /* Update MAC address in RAM */
-    if (p_mac) {
-           update_mac(eeprom_data, EEPROM_SZ, mac_addr);
-    }
-#endif
-#if 0
-    /* mac address in eeprom array */
-    printk("%s: mac values in eeprom array\n", __FUNCTION__);
-    for (i = 10; i < 10 + 6; i++)
-        printk("[0x%x],", eeprom_data[i]);
-    printk("\n");
-#endif
-    /* soft mac */
-
-    /* Write EEPROM data to Target RAM */
-    BMI_write_mem(board_data_addr, ((u8 *)eeprom_data), EEPROM_SZ);
-
-    /* Record the fact that Board Data IS initialized */
-    {
-       u32 one = 1;
-       BMI_write_mem(HOST_INTEREST_ITEM_ADDRESS(hi_board_data_initialized),
-                     (u8 *)&one, sizeof(u32));
-    }
-
-    disable_SI();
-}
-#endif
-/* ATHENV */
-
index 442a2860d24abffbf8def06f5f3f39084d141be4..430998edacc4cdb8e8593fc08514aec81f7c7aab 100644 (file)
@@ -23,7 +23,6 @@
 //==============================================================================
 #include <a_config.h>
 #include <athdefs.h>
-#include "a_types.h"
 #include "a_osapi.h"
 #include "htc_api.h"
 #include "a_drv.h"
index 39e5798f5e80572b4bef56555b76a0a14fe18c64..6087edcb1d6a47f8fce95b13424eb63b2148afad 100644 (file)
@@ -26,7 +26,6 @@
 #include <linux/etherdevice.h>
 #include <a_config.h>
 #include <athdefs.h>
-#include "a_types.h"
 #include "a_osapi.h"
 #include "htc_api.h"
 #include "wmi.h"
@@ -582,11 +581,11 @@ void  ar6000_cleanup_hci(struct ar6_softc *ar)
         } 
         
         if (pHcidevInfo->pHTCStructAlloc != NULL) {
-            A_FREE(pHcidevInfo->pHTCStructAlloc);
+            kfree(pHcidevInfo->pHTCStructAlloc);
             pHcidevInfo->pHTCStructAlloc = NULL;    
         }
         
-        A_FREE(pHcidevInfo);
+        kfree(pHcidevInfo);
 #ifndef EXPORT_HCI_BRIDGE_INTERFACE
         ar->hcidev_info = NULL;
 #endif
index 89fd80a2c8ed6694960b4bf63fe71c86d8a8a570..22453b0873e4cb0e0481cad4bca11b0c247cdf22 100644 (file)
 #include <linux/if_arp.h>
 #include <linux/ip.h>
 #include <linux/wireless.h>
-#ifdef ATH6K_CONFIG_CFG80211
 #include <net/cfg80211.h>
-#endif /* ATH6K_CONFIG_CFG80211 */
 #include <linux/module.h>
 #include <asm/io.h>
 
 #include <a_config.h>
 #include <athdefs.h>
-#include "a_types.h"
 #include "a_osapi.h"
 #include "htc_api.h"
 #include "wmi.h"
@@ -51,8 +48,6 @@
 #include <ieee80211_ioctl.h>
 #include <wlan_api.h>
 #include <wmi_api.h>
-#include "gpio_api.h"
-#include "gpio.h"
 #include "pkt_log.h"
 #include "aggr_recv_api.h"
 #include <host_version.h>
@@ -76,7 +71,7 @@
 #include "hw/apb_map.h"
 #include "hw/rtc_reg.h"
 #include "hw/mbox_reg.h"
-#include "hw/gpio_reg.h"
+#include "gpio_reg.h"
 
 #define  ATH_DEBUG_DBG_LOG       ATH_DEBUG_MAKE_MODULE_MASK(0)
 #define  ATH_DEBUG_WLAN_CONNECT  ATH_DEBUG_MAKE_MODULE_MASK(1)
@@ -94,8 +89,6 @@
 #endif
 
 
-#ifdef USER_KEYS
-
 #define USER_SAVEDKEYS_STAT_INIT     0
 #define USER_SAVEDKEYS_STAT_RUN      1
 
@@ -106,7 +99,6 @@ struct USER_SAVEDKEYS {
     CRYPTO_TYPE               keyType;
     bool                    keyOk;
 };
-#endif
 
 #define DBG_INFO        0x00000001
 #define DBG_ERROR       0x00000002
@@ -215,35 +207,42 @@ typedef enum _AR6K_BIN_FILE {
 #define SETUPHCI_DEFAULT           0
 #endif /* SETUPHCI_ENABLED */
 
-#ifdef SETUPHCIPAL_ENABLED
-#define SETUPHCIPAL_DEFAULT           1
-#else
-#define SETUPHCIPAL_DEFAULT           0
-#endif /* SETUPHCIPAL_ENABLED */
-
 #ifdef SETUPBTDEV_ENABLED
 #define SETUPBTDEV_DEFAULT         1
 #else
 #define SETUPBTDEV_DEFAULT         0
 #endif /* SETUPBTDEV_ENABLED */
 
-#ifdef BMIENABLE_SET
-#define BMIENABLE_DEFAULT          1
-#else
-#define BMIENABLE_DEFAULT          0
-#endif /* BMIENABLE_SET */
-
 #ifdef ENABLEUARTPRINT_SET
 #define ENABLEUARTPRINT_DEFAULT    1
 #else
 #define ENABLEUARTPRINT_DEFAULT    0
 #endif /* ENABLEARTPRINT_SET */
 
-#ifdef ATH6K_CONFIG_HIF_VIRTUAL_SCATTER
+#ifdef ATH6KL_CONFIG_HIF_VIRTUAL_SCATTER
 #define NOHIFSCATTERSUPPORT_DEFAULT    1
-#else /* ATH6K_CONFIG_HIF_VIRTUAL_SCATTER */
+#else /* ATH6KL_CONFIG_HIF_VIRTUAL_SCATTER */
 #define NOHIFSCATTERSUPPORT_DEFAULT    0
-#endif /* ATH6K_CONFIG_HIF_VIRTUAL_SCATTER */
+#endif /* ATH6KL_CONFIG_HIF_VIRTUAL_SCATTER */
+
+
+#if defined(CONFIG_ATH6KL_ENABLE_COEXISTENCE)
+
+#ifdef CONFIG_AR600x_BT_QCOM
+#define ATH6KL_BT_DEV 1
+#elif defined(CONFIG_AR600x_BT_CSR)
+#define ATH6KL_BT_DEV 2
+#else
+#define ATH6KL_BT_DEV 3
+#endif
+
+#ifdef CONFIG_AR600x_DUAL_ANTENNA
+#define ATH6KL_BT_ANTENNA 2
+#else
+#define ATH6KL_BT_ANTENNA 1
+#endif
+
+#endif /* CONFIG_ATH6KL_ENABLE_COEXISTENCE */
 
 #ifdef AR600x_BT_AR3001
 #define AR3KHCIBAUD_DEFAULT        3000000
@@ -255,11 +254,7 @@ typedef enum _AR6K_BIN_FILE {
 #define HCIUARTSTEP_DEFAULT        0
 #endif /* AR600x_BT_AR3001 */
 
-#ifdef INIT_MODE_DRV_ENABLED
 #define WLAN_INIT_MODE_DEFAULT     WLAN_INIT_MODE_DRV
-#else
-#define WLAN_INIT_MODE_DEFAULT     WLAN_INIT_MODE_USR
-#endif /* INIT_MODE_DRV_ENABLED */
 
 #define AR6K_PATCH_DOWNLOAD_ADDRESS(_param, _ver) do { \
     if ((_ver) == AR6003_REV1_VERSION) { \
@@ -283,15 +278,37 @@ typedef enum _AR6K_BIN_FILE {
     } \
 } while (0)
 
+#define AR6K_DATASET_PATCH_ADDRESS(_param, _ver) do { \
+        if ((_ver) == AR6003_REV2_VERSION) { \
+                (_param) = AR6003_REV2_DATASET_PATCH_ADDRESS; \
+        } else if ((_ver) == AR6003_REV3_VERSION) { \
+                (_param) = AR6003_REV3_DATASET_PATCH_ADDRESS; \
+        } else { \
+        AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unknown Version: %d\n", _ver)); \
+        A_ASSERT(0); \
+        } \
+} while (0)
+
+#define AR6K_APP_LOAD_ADDRESS(_param, _ver) do { \
+        if ((_ver) == AR6003_REV2_VERSION) { \
+                (_param) = AR6003_REV2_APP_LOAD_ADDRESS; \
+        } else if ((_ver) == AR6003_REV3_VERSION) { \
+                (_param) = AR6003_REV3_APP_LOAD_ADDRESS; \
+        } else { \
+        AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unknown Version: %d\n", _ver)); \
+        A_ASSERT(0); \
+        } \
+} while (0)
+
 #define AR6K_APP_START_OVERRIDE_ADDRESS(_param, _ver) do { \
-    if ((_ver) == AR6003_REV1_VERSION) { \
-        (_param) = AR6003_REV1_APP_START_OVERRIDE; \
-    } else if ((_ver) == AR6003_REV2_VERSION) { \
-        (_param) = AR6003_REV2_APP_START_OVERRIDE; \
-    } else { \
-       AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unknown Version: %d\n", _ver)); \
-       A_ASSERT(0); \
-    } \
+        if ((_ver) == AR6003_REV2_VERSION) { \
+                (_param) = AR6003_REV2_APP_START_OVERRIDE; \
+        } else if ((_ver) == AR6003_REV3_VERSION) { \
+                (_param) = AR6003_REV3_APP_START_OVERRIDE; \
+        } else { \
+        AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unknown Version: %d\n", _ver)); \
+        A_ASSERT(0); \
+        } \
 } while (0)
 
 /* AR6003 1.0 definitions */
@@ -304,11 +321,11 @@ typedef enum _AR6K_BIN_FILE {
 #define AR6003_REV1_ART_FIRMWARE_FILE       "ath6k/AR6003/hw1.0/device.bin"
 #define AR6003_REV1_PATCH_FILE              "ath6k/AR6003/hw1.0/data.patch.bin"
 #define AR6003_REV1_EPPING_FIRMWARE_FILE    "ath6k/AR6003/hw1.0/endpointping.bin"
-#ifdef AR600x_SD31_XXX
+#ifdef CONFIG_AR600x_SD31_XXX
 #define AR6003_REV1_BOARD_DATA_FILE         "ath6k/AR6003/hw1.0/bdata.SD31.bin"
-#elif defined(AR600x_SD32_XXX)
+#elif defined(CONFIG_AR600x_SD32_XXX)
 #define AR6003_REV1_BOARD_DATA_FILE         "ath6k/AR6003/hw1.0/bdata.SD32.bin"
-#elif defined(AR600x_WB31_XXX)
+#elif defined(CONFIG_AR600x_WB31_XXX)
 #define AR6003_REV1_BOARD_DATA_FILE         "ath6k/AR6003/hw1.0/bdata.WB31.bin"
 #else
 #define AR6003_REV1_BOARD_DATA_FILE         "ath6k/AR6003/hw1.0/bdata.CUSTOM.bin"
@@ -324,16 +341,35 @@ typedef enum _AR6K_BIN_FILE {
 #define AR6003_REV2_ART_FIRMWARE_FILE       "ath6k/AR6003/hw2.0/device.bin"
 #define AR6003_REV2_PATCH_FILE              "ath6k/AR6003/hw2.0/data.patch.bin"
 #define AR6003_REV2_EPPING_FIRMWARE_FILE    "ath6k/AR6003/hw2.0/endpointping.bin"
-#ifdef AR600x_SD31_XXX
+#ifdef CONFIG_AR600x_SD31_XXX
 #define AR6003_REV2_BOARD_DATA_FILE         "ath6k/AR6003/hw2.0/bdata.SD31.bin"
-#elif defined(AR600x_SD32_XXX)
+#elif defined(CONFIG_AR600x_SD32_XXX)
 #define AR6003_REV2_BOARD_DATA_FILE         "ath6k/AR6003/hw2.0/bdata.SD32.bin"
-#elif defined(AR600x_WB31_XXX)
+#elif defined(CONFIG_AR600x_WB31_XXX)
 #define AR6003_REV2_BOARD_DATA_FILE         "ath6k/AR6003/hw2.0/bdata.WB31.bin"
 #else
 #define AR6003_REV2_BOARD_DATA_FILE         "ath6k/AR6003/hw2.0/bdata.CUSTOM.bin"
 #endif /* Board Data File */
 
+/* AR6003 3.0 definitions */
+#define AR6003_REV3_VERSION                 0x30000582
+#define AR6003_REV3_OTP_FILE                "ath6k/AR6003/hw2.1.1/otp.bin"
+#define AR6003_REV3_FIRMWARE_FILE           "ath6k/AR6003/hw2.1.1/athwlan.bin"
+#define AR6003_REV3_TCMD_FIRMWARE_FILE    "ath6k/AR6003/hw2.1.1/athtcmd_ram.bin"
+#define AR6003_REV3_ART_FIRMWARE_FILE       "ath6k/AR6003/hw2.1.1/device.bin"
+#define AR6003_REV3_PATCH_FILE            "ath6k/AR6003/hw2.1.1/data.patch.bin"
+#define AR6003_REV3_EPPING_FIRMWARE_FILE "ath6k/AR6003/hw2.1.1/endpointping.bin"
+#ifdef CONFIG_AR600x_SD31_XXX
+#define AR6003_REV3_BOARD_DATA_FILE       "ath6k/AR6003/hw2.1.1/bdata.SD31.bin"
+#elif defined(CONFIG_AR600x_SD32_XXX)
+#define AR6003_REV3_BOARD_DATA_FILE        "ath6k/AR6003/hw2.1.1/bdata.SD32.bin"
+#elif defined(CONFIG_AR600x_WB31_XXX)
+#define AR6003_REV3_BOARD_DATA_FILE        "ath6k/AR6003/hw2.1.1/bdata.WB31.bin"
+#else
+#define AR6003_REV3_BOARD_DATA_FILE      "ath6k/AR6003/hw2.1.1/bdata.CUSTOM.bin"
+#endif /* Board Data File */
+
+
 /* Power states */
 enum {
     WLAN_PWR_CTRL_UP = 0,
@@ -385,7 +421,6 @@ struct ar_wep_key {
     u8 arKey[64];
 } ;
 
-#ifdef ATH6K_CONFIG_CFG80211
 struct ar_key {
     u8 key[WLAN_MAX_KEY_LEN];
     u8 key_len;
@@ -399,8 +434,6 @@ enum {
     SME_CONNECTING,
     SME_CONNECTED
 };
-#endif /* ATH6K_CONFIG_CFG80211 */
-
 
 struct ar_node_mapping {
     u8 macAddress[6];
@@ -557,11 +590,9 @@ struct ar6_softc {
     u32 log_cnt;
     u32 dbglog_init_done;
     u32 arConnectCtrlFlags;
-#ifdef USER_KEYS
     s32 user_savedkeys_stat;
     u32 user_key_ctrl;
     struct USER_SAVEDKEYS   user_saved_keys;
-#endif
     USER_RSSI_THOLD rssi_map[12];
     u8 arUserBssFilter;
     u16 ap_profile_flag;    /* AP mode */
@@ -577,7 +608,6 @@ struct ar6_softc {
 #ifndef EXPORT_HCI_BRIDGE_INTERFACE
     void                    *hcidev_info;
 #endif
-    void                    *hcipal_info;
     WMI_AP_MODE_STAT        arAPStats;
     u8 ap_hidden_ssid;
     u8 ap_country_code[3];
@@ -597,12 +627,10 @@ struct ar6_softc {
        WMI_BTCOEX_STATS_EVENT  arBtcoexStats;
     s32 (*exitCallback)(void *config);  /* generic callback at AR6K exit */
     struct hif_device_os_device_info   osDevInfo;
-#ifdef ATH6K_CONFIG_CFG80211
     struct wireless_dev *wdev;
     struct cfg80211_scan_request    *scan_request;
     struct ar_key   keys[WMI_MAX_KEY_INDEX + 1];
     u32 smeState;
-#endif /* ATH6K_CONFIG_CFG80211 */
     u16 arWlanPowerState;
     bool                  arWlanOff;
 #ifdef CONFIG_PM
@@ -622,6 +650,7 @@ struct ar6_softc {
 #ifdef CONFIG_AP_VIRTUAL_ADAPTER_SUPPORT
     void                    *arApDev;
 #endif
+    u8 arAutoAuthStage;
 };
 
 #ifdef CONFIG_AP_VIRTUAL_ADAPTER_SUPPORT
@@ -632,30 +661,10 @@ struct ar_virtual_interface {
 };
 #endif /* CONFIG_AP_VIRTUAL_ADAPTER_SUPPORT */
 
-#ifdef ATH6K_CONFIG_CFG80211
 static inline void *ar6k_priv(struct net_device *dev)
 {
     return (wdev_priv(dev->ieee80211_ptr));
 }
-#else
-#ifdef CONFIG_AP_VIRTUAL_ADAPTER_SUPPORT
-static inline void *ar6k_priv(struct net_device *dev)
-{
-    extern struct net_device *arApNetDev;
-
-    if (arApNetDev == dev) {
-        /* return arDev saved in virtual interface context */
-        struct ar_virtual_interface *arVirDev;
-        arVirDev = netdev_priv(dev);
-        return arVirDev->arDev;   
-    } else {
-        return netdev_priv(dev);
-    }
-}
-#else
-#define ar6k_priv   netdev_priv
-#endif /* CONFIG_AP_VIRTUAL_ADAPTER_SUPPORT */
-#endif /* ATH6K_CONFIG_CFG80211 */
 
 #define SET_HCI_BUS_TYPE(pHciDev, __bus, __type) do { \
     (pHciDev)->bus = (__bus); \
@@ -701,9 +710,6 @@ struct ar_giwscan_param {
     spin_unlock_bh(lock);                                               \
 } while (0)
 
-int ar6000_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
-int ar6000_ioctl_dispatcher(struct net_device *dev, struct ifreq *rq, int cmd);
-void ar6000_gpio_init(void);
 void ar6000_init_profile_info(struct ar6_softc *ar);
 void ar6000_install_static_wep_keys(struct ar6_softc *ar);
 int ar6000_init(struct net_device *dev);
index 1acfb9cb7c736bc1f41c53d39b461aff6bc6a245..184dbdb50495fddf53486aa93d26eac479440a30 100644 (file)
@@ -83,11 +83,6 @@ s16 rssi_compensation_reverse_calc(struct ar6_softc *ar, s16 rssi, bool Above);
 
 void ar6000_dbglog_init_done(struct ar6_softc *ar);
 
-#ifdef SEND_EVENT_TO_APP
-void ar6000_send_event_to_app(struct ar6_softc *ar, u16 eventId, u8 *datap, int len);
-void ar6000_send_generic_event_to_app(struct ar6_softc *ar, u16 eventId, u8 *datap, int len);
-#endif
-
 #ifdef CONFIG_HOST_TCMD_SUPPORT
 void ar6000_tcmd_rx_report_event(void *devt, u8 *results, int len);
 #endif
@@ -183,9 +178,6 @@ int ar6000_power_change_ev(void *context, u32 config);
 void ar6000_check_wow_status(struct ar6_softc *ar, struct sk_buff *skb, bool isEvent);
 #endif
 
-void ar6000_pm_init(void);
-void ar6000_pm_exit(void);
-
 #ifdef CONFIG_AP_VIRTUAL_ADAPTER_SUPPORT
 int ar6000_add_ap_interface(struct ar6_softc *ar, char *ifname);
 int ar6000_remove_ap_interface(struct ar6_softc *ar);
index 66817c2c5022e5cf6f136128dbb960b2bc2894ef..3d5f01da543f8a93052e879804571f96cfda1cad 100644 (file)
@@ -620,7 +620,6 @@ typedef enum {
  */
 #define AR6000_XIOCTL_WMI_SET_TXOP                      57
 
-#ifdef USER_KEYS
 /*
  * arguments:
  * UINT32 cmd (AR6000_XIOCTL_USER_SETKEYS)
@@ -628,7 +627,6 @@ typedef enum {
  * uses struct ar6000_user_setkeys_info
  */
 #define AR6000_XIOCTL_USER_SETKEYS                      58
-#endif /* USER_KEYS */
 
 #define AR6000_XIOCTL_WMI_SET_KEEPALIVE                 59
 /*
@@ -942,7 +940,7 @@ typedef enum {
 
 #define AR6000_XIOCTL_HCI_CMD                       132
 
-#define AR6000_XIOCTL_ACL_DATA                      133
+#define AR6000_XIOCTL_ACL_DATA                      133 /* used to be used for PAL */
 
 #define AR6000_XIOCTL_WLAN_CONN_PRECEDENCE          134
 
diff --git a/drivers/staging/ath6kl/os/linux/include/athtypes_linux.h b/drivers/staging/ath6kl/os/linux/include/athtypes_linux.h
deleted file mode 100644 (file)
index 8cb5632..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// This file contains the definitions of the basic atheros data types.
-// It is used to map the data types in atheros files to a platform specific
-// type.
-// Copyright (c) 2004-2010 Atheros Communications Inc.
-// All rights reserved.
-//
-// 
-//
-// Permission to use, copy, modify, and/or distribute this software for any
-// purpose with or without fee is hereby granted, provided that the above
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-//
-//
-//
-// Author(s): ="Atheros"
-//------------------------------------------------------------------------------
-
-#ifndef _ATHTYPES_LINUX_H_
-#define _ATHTYPES_LINUX_H_
-
-#ifdef __KERNEL__
-#include <linux/types.h>
-#else
-#include <sys/types.h>
-#endif
-
-typedef int8_t      A_INT8;
-typedef int16_t     A_INT16;
-typedef int32_t     A_INT32;
-typedef int64_t     A_INT64;
-
-typedef u_int8_t     A_UINT8;
-typedef u_int16_t    A_UINT16;
-typedef u_int32_t    A_UINT32;
-typedef u_int64_t    A_UINT64;
-
-typedef char            A_CHAR;
-typedef unsigned long   A_ATH_TIMER;
-
-
-#endif /* _ATHTYPES_LINUX_H_ */
index 50f53d361049eefa5254af323e4448eec7d327fa..d4030e26b20c160c635f24134750fcaa6753b55b 100644 (file)
@@ -30,13 +30,6 @@ extern "C" {
 
 #include <linux/version.h>
 
-/*
- * Host-side GPIO support is optional.
- * If run-time access to GPIO pins is not required, then
- * this should be changed to #undef.
- */
-#define CONFIG_HOST_GPIO_SUPPORT
-
 /*
  * Host side Test Command support
  */
index 53b500c1835f4696f220c4cd1fb4186465ac2fce..07078b49583f1c7098e1cc89b9a9abf46c119ffb 100644 (file)
 #define A_MEMZERO(addr, len)            memset(addr, 0, len)
 #define A_MALLOC(size)                  kmalloc((size), GFP_KERNEL)
 #define A_MALLOC_NOWAIT(size)           kmalloc((size), GFP_ATOMIC)
-#define A_FREE(addr)                    kfree(addr)
-
-#if defined(ANDROID_ENV) && defined(CONFIG_ANDROID_LOGGER)
-extern unsigned int enablelogcat;
-extern int android_logger_lv(void* module, int mask);
-enum logidx { LOG_MAIN_IDX = 0 };
-extern int logger_write(const enum logidx idx, 
-                const unsigned char prio,
-                const char __kernel * const tag,
-                const char __kernel * const fmt,
-                ...);
-#define A_ANDROID_PRINTF(mask, module, tags, args...) do {  \
-    if (enablelogcat) \
-        logger_write(LOG_MAIN_IDX, android_logger_lv(module, mask), tags, args); \
-    else \
-        printk(KERN_ALERT args); \
-} while (0)
-#ifdef DEBUG
-#define A_LOGGER_MODULE_NAME(x) #x
-#define A_LOGGER(mask, mod, args...) \
-    A_ANDROID_PRINTF(mask, &GET_ATH_MODULE_DEBUG_VAR_NAME(mod), "ar6k_" A_LOGGER_MODULE_NAME(mod), args);
-#endif 
-#define A_PRINTF(args...) A_ANDROID_PRINTF(ATH_DEBUG_INFO, NULL, "ar6k_driver", args)
-#else
+
 #define A_LOGGER(mask, mod, args...)    printk(KERN_ALERT args)
 #define A_PRINTF(args...)               printk(KERN_ALERT args)
-#endif /* ANDROID */
+
 #define A_PRINTF_LOG(args...)           printk(args)
 #define A_SPRINTF(buf, args...)                        sprintf (buf, args)
 
@@ -211,17 +188,8 @@ extern unsigned int panic_on_assert;
 #define A_ASSERT(expr)
 #endif /* DEBUG */
 
-#ifdef ANDROID_ENV
-struct firmware;
-int android_request_firmware(const struct firmware **firmware_p, const char *filename,
-                     struct device *device);
-void android_release_firmware(const struct firmware *firmware);
-#define A_REQUEST_FIRMWARE(_ppf, _pfile, _dev) android_request_firmware(_ppf, _pfile, _dev)
-#define A_RELEASE_FIRMWARE(_pf) android_release_firmware(_pf)
-#else
 #define A_REQUEST_FIRMWARE(_ppf, _pfile, _dev) request_firmware(_ppf, _pfile, _dev)
 #define A_RELEASE_FIRMWARE(_pf) release_firmware(_pf)
-#endif 
 
 /*
  * Initialization of the network buffer subsystem
@@ -364,19 +332,8 @@ static inline void *A_ALIGN_TO_CACHE_LINE(void *ptr) {
 
 #define A_MEMZERO(addr, len)            memset((addr), 0, (len))
 #define A_MALLOC(size)                  malloc(size)
-#define A_FREE(addr)                    free(addr)
-
-#ifdef ANDROID
-#ifndef err
-#include <errno.h>
-#define err(_s, args...) do { \
-    fprintf(stderr, "%s: line %d ", __FILE__, __LINE__); \
-    fprintf(stderr, args); fprintf(stderr, ": %d\n", errno); \
-    exit(_s); } while (0)
-#endif
-#else
+
 #include <err.h>
-#endif
 
 #endif /* __KERNEL__ */
 
index 2de5cef26cceed7999fdc9dc23833dc51aa7f099..c1fe0c6e4fa100ccd15d3409a14f2e84d896c791 100644 (file)
  * If the firmware successly roams within the disconnect timeout
  * it sends a new connect event
  */
-#ifdef ANDROID_ENV
-#define WLAN_CONFIG_DISCONNECT_TIMEOUT 3
-#else
 #define WLAN_CONFIG_DISCONNECT_TIMEOUT 10
-#endif /* ANDROID_ENV */ 
 
 /*
  * This configuration item disables 11n support. 
  */
 #define WLAN_CONFIG_DISABLE_TX_BURSTING     0
 
-/*
- * Platform specific function to power ON/OFF AR6000 
- * and enable/disable SDIO card detection
- */
-#define plat_setup_power(on, detect)
-
 #endif /* _HOST_WLAN_CONFIG_H_ */
index d172625afa180182cdc322a952c1144cc1c789ce..1eb6f822d64e9f95b7d66fc59fd8cb4504fe7067 100644 (file)
@@ -266,7 +266,7 @@ u8 xioctl_filter[] = {
 (0xFF),                                         /* AR6000_XIOCTL_DELE_AGGR                         130  */
 (0xFF),                                         /* AR6000_XIOCTL_FETCH_TARGET_REGS                 131  */
 (0xFF),                                         /* AR6000_XIOCTL_HCI_CMD                           132  */
-(0xFF),                                         /* AR6000_XIOCTL_ACL_DATA                          133  */
+(0xFF),                                         /* AR6000_XIOCTL_ACL_DATA(used to be used for PAL) 133  */
 (0xFF),                                         /* AR6000_XIOCTL_WLAN_CONN_PRECEDENCE              134  */
 (AP_NETWORK),                                   /* AR6000_XIOCTL_AP_SET_11BG_RATESET               135  */
 (0xFF),
diff --git a/drivers/staging/ath6kl/os/linux/ioctl.c b/drivers/staging/ath6kl/os/linux/ioctl.c
deleted file mode 100644 (file)
index 0daa201..0000000
+++ /dev/null
@@ -1,4767 +0,0 @@
-//------------------------------------------------------------------------------
-// Copyright (c) 2004-2010 Atheros Communications Inc.
-// All rights reserved.
-//
-// 
-//
-// Permission to use, copy, modify, and/or distribute this software for any
-// purpose with or without fee is hereby granted, provided that the above
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-//
-//
-//
-// Author(s): ="Atheros"
-//------------------------------------------------------------------------------
-
-#include "ar6000_drv.h"
-#include "ieee80211_ioctl.h"
-#include "ar6kap_common.h"
-#include "targaddrs.h"
-#include "a_hci.h"
-#include "wlan_config.h"
-
-extern int enablerssicompensation;
-u32 tcmdRxFreq;
-extern unsigned int wmitimeout;
-extern A_WAITQUEUE_HEAD arEvent;
-extern int tspecCompliance;
-extern int bmienable;
-extern int loghci;
-
-static int
-ar6000_ioctl_get_roam_tbl(struct net_device *dev, struct ifreq *rq)
-{
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-
-    if (ar->arWmiReady == false) {
-        return -EIO;
-    }
-
-    if(wmi_get_roam_tbl_cmd(ar->arWmi) != 0) {
-        return -EIO;
-    }
-
-    return 0;
-}
-
-static int
-ar6000_ioctl_get_roam_data(struct net_device *dev, struct ifreq *rq)
-{
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-
-    if (ar->arWmiReady == false) {
-        return -EIO;
-    }
-
-
-    /* currently assume only roam times are required */
-    if(wmi_get_roam_data_cmd(ar->arWmi, ROAM_DATA_TIME) != 0) {
-        return -EIO;
-    }
-
-
-    return 0;
-}
-
-static int
-ar6000_ioctl_set_roam_ctrl(struct net_device *dev, char *userdata)
-{
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-    WMI_SET_ROAM_CTRL_CMD cmd;
-    u8 size = sizeof(cmd);
-
-    if (ar->arWmiReady == false) {
-        return -EIO;
-    }
-
-
-    if (copy_from_user(&cmd, userdata, size)) {
-        return -EFAULT;
-    }
-
-    if (cmd.roamCtrlType == WMI_SET_HOST_BIAS) {
-        if (cmd.info.bssBiasInfo.numBss > 1) {
-            size += (cmd.info.bssBiasInfo.numBss - 1) * sizeof(WMI_BSS_BIAS);
-        }
-    }
-
-    if (copy_from_user(&cmd, userdata, size)) {
-        return -EFAULT;
-    }
-
-    if(wmi_set_roam_ctrl_cmd(ar->arWmi, &cmd, size) != 0) {
-        return -EIO;
-    }
-
-    return 0;
-}
-
-static int
-ar6000_ioctl_set_powersave_timers(struct net_device *dev, char *userdata)
-{
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-    WMI_POWERSAVE_TIMERS_POLICY_CMD cmd;
-    u8 size = sizeof(cmd);
-
-    if (ar->arWmiReady == false) {
-        return -EIO;
-    }
-
-    if (copy_from_user(&cmd, userdata, size)) {
-        return -EFAULT;
-    }
-
-    if (copy_from_user(&cmd, userdata, size)) {
-        return -EFAULT;
-    }
-
-    if(wmi_set_powersave_timers_cmd(ar->arWmi, &cmd, size) != 0) {
-        return -EIO;
-    }
-
-    return 0;
-}
-
-static int
-ar6000_ioctl_set_qos_supp(struct net_device *dev, struct ifreq *rq)
-{
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-    WMI_SET_QOS_SUPP_CMD cmd;
-    int ret;
-
-    if ((dev->flags & IFF_UP) != IFF_UP) {
-        return -EIO;
-    }
-    if (ar->arWmiReady == false) {
-        return -EIO;
-    }
-
-    if (copy_from_user(&cmd, (char *)((unsigned int*)rq->ifr_data + 1),
-                                sizeof(cmd)))
-    {
-        return -EFAULT;
-    }
-
-    ret = wmi_set_qos_supp_cmd(ar->arWmi, cmd.status);
-
-    switch (ret) {
-        case 0:
-            return 0;
-        case A_EBUSY :
-            return -EBUSY;
-        case A_NO_MEMORY:
-            return -ENOMEM;
-        case A_EINVAL:
-        default:
-            return -EFAULT;
-    }
-}
-
-static int
-ar6000_ioctl_set_wmm(struct net_device *dev, struct ifreq *rq)
-{
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-    WMI_SET_WMM_CMD cmd;
-    int ret;
-
-    if ((dev->flags & IFF_UP) != IFF_UP) {
-        return -EIO;
-    }
-    if (ar->arWmiReady == false) {
-        return -EIO;
-    }
-
-    if (copy_from_user(&cmd, (char *)((unsigned int*)rq->ifr_data + 1),
-                                sizeof(cmd)))
-    {
-        return -EFAULT;
-    }
-
-    if (cmd.status == WMI_WMM_ENABLED) {
-        ar->arWmmEnabled = true;
-    } else {
-        ar->arWmmEnabled = false;
-    }
-
-    ret = wmi_set_wmm_cmd(ar->arWmi, cmd.status);
-
-    switch (ret) {
-        case 0:
-            return 0;
-        case A_EBUSY :
-            return -EBUSY;
-        case A_NO_MEMORY:
-            return -ENOMEM;
-        case A_EINVAL:
-        default:
-            return -EFAULT;
-    }
-}
-
-static int
-ar6000_ioctl_set_txop(struct net_device *dev, struct ifreq *rq)
-{
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-    WMI_SET_WMM_TXOP_CMD cmd;
-    int ret;
-
-    if ((dev->flags & IFF_UP) != IFF_UP) {
-        return -EIO;
-    }
-    if (ar->arWmiReady == false) {
-        return -EIO;
-    }
-
-    if (copy_from_user(&cmd, (char *)((unsigned int*)rq->ifr_data + 1),
-                                sizeof(cmd)))
-    {
-        return -EFAULT;
-    }
-
-    ret = wmi_set_wmm_txop(ar->arWmi, cmd.txopEnable);
-
-    switch (ret) {
-        case 0:
-            return 0;
-        case A_EBUSY :
-            return -EBUSY;
-        case A_NO_MEMORY:
-            return -ENOMEM;
-        case A_EINVAL:
-        default:
-            return -EFAULT;
-    }
-}
-
-static int
-ar6000_ioctl_get_rd(struct net_device *dev, struct ifreq *rq)
-{
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-    int ret = 0;
-
-    if ((dev->flags & IFF_UP) != IFF_UP || ar->arWmiReady == false) {
-        return -EIO;
-    }
-
-    if(copy_to_user((char *)((unsigned int*)rq->ifr_data + 1),
-                            &ar->arRegCode, sizeof(ar->arRegCode)))
-        ret = -EFAULT;
-
-    return ret;
-}
-
-static int
-ar6000_ioctl_set_country(struct net_device *dev, struct ifreq *rq)
-{
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-    WMI_AP_SET_COUNTRY_CMD cmd;
-    int ret;
-
-    if ((dev->flags & IFF_UP) != IFF_UP) {
-        return -EIO;
-    }
-    if (ar->arWmiReady == false) {
-        return -EIO;
-    }
-
-    if (copy_from_user(&cmd, (char *)((unsigned int*)rq->ifr_data + 1),
-                                sizeof(cmd)))
-    {
-        return -EFAULT;
-    }
-
-    ar->ap_profile_flag = 1; /* There is a change in profile */
-
-    ret = wmi_set_country(ar->arWmi, cmd.countryCode);
-    memcpy(ar->ap_country_code, cmd.countryCode, 3);
-
-    switch (ret) {
-        case 0:
-            return 0;
-        case A_EBUSY :
-            return -EBUSY;
-        case A_NO_MEMORY:
-            return -ENOMEM;
-        case A_EINVAL:
-        default:
-            return -EFAULT;
-    }
-}
-
-
-/* Get power mode command */
-static int
-ar6000_ioctl_get_power_mode(struct net_device *dev, struct ifreq *rq)
-{
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-    WMI_POWER_MODE_CMD power_mode;
-    int ret = 0;
-
-    if (ar->arWmiReady == false) {
-        return -EIO;
-    }
-
-    power_mode.powerMode = wmi_get_power_mode_cmd(ar->arWmi);
-    if (copy_to_user(rq->ifr_data, &power_mode, sizeof(WMI_POWER_MODE_CMD))) {
-        ret = -EFAULT;
-    }
-
-    return ret;
-}
-
-
-static int
-ar6000_ioctl_set_channelParams(struct net_device *dev, struct ifreq *rq)
-{
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-    WMI_CHANNEL_PARAMS_CMD cmd, *cmdp;
-    int ret = 0;
-
-    if (ar->arWmiReady == false) {
-        return -EIO;
-    }
-
-
-    if (copy_from_user(&cmd, rq->ifr_data, sizeof(cmd))) {
-        return -EFAULT;
-    }
-
-    if( (ar->arNextMode == AP_NETWORK) && (cmd.numChannels || cmd.scanParam) ) {
-        A_PRINTF("ERROR: Only wmode is allowed in AP mode\n");
-        return -EIO;
-    }
-
-    if (cmd.numChannels > 1) {
-        cmdp = A_MALLOC(130);
-        if (copy_from_user(cmdp, rq->ifr_data,
-                           sizeof (*cmdp) +
-                           ((cmd.numChannels - 1) * sizeof(u16))))
-        {
-            kfree(cmdp);
-            return -EFAULT;
-        }
-    } else {
-        cmdp = &cmd;
-    }
-
-    if ((ar->arPhyCapability == WMI_11G_CAPABILITY) &&
-        ((cmdp->phyMode == WMI_11A_MODE) || (cmdp->phyMode == WMI_11AG_MODE)))
-    {
-        ret = -EINVAL;
-    }
-
-    if (!ret &&
-        (wmi_set_channelParams_cmd(ar->arWmi, cmdp->scanParam, cmdp->phyMode,
-                                   cmdp->numChannels, cmdp->channelList)
-         != 0))
-    {
-        ret = -EIO;
-    }
-
-    if (cmd.numChannels > 1) {
-        kfree(cmdp);
-    }
-
-    ar->ap_wmode = cmdp->phyMode;
-    /* Set the profile change flag to allow a commit cmd */
-    ar->ap_profile_flag = 1;
-
-    return ret;
-}
-
-
-static int
-ar6000_ioctl_set_snr_threshold(struct net_device *dev, struct ifreq *rq)
-{
-
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-    WMI_SNR_THRESHOLD_PARAMS_CMD cmd;
-    int ret = 0;
-
-    if (ar->arWmiReady == false) {
-        return -EIO;
-    }
-
-    if (copy_from_user(&cmd, rq->ifr_data, sizeof(cmd))) {
-        return -EFAULT;
-    }
-
-    if( wmi_set_snr_threshold_params(ar->arWmi, &cmd) != 0 ) {
-        ret = -EIO;
-    }
-
-    return ret;
-}
-
-static int
-ar6000_ioctl_set_rssi_threshold(struct net_device *dev, struct ifreq *rq)
-{
-#define SWAP_THOLD(thold1, thold2) do { \
-    USER_RSSI_THOLD tmpThold;           \
-    tmpThold.tag = thold1.tag;          \
-    tmpThold.rssi = thold1.rssi;        \
-    thold1.tag = thold2.tag;            \
-    thold1.rssi = thold2.rssi;          \
-    thold2.tag = tmpThold.tag;          \
-    thold2.rssi = tmpThold.rssi;        \
-} while (0)
-
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-    WMI_RSSI_THRESHOLD_PARAMS_CMD cmd;
-    USER_RSSI_PARAMS rssiParams;
-    s32 i, j;
-    int ret = 0;
-
-    if (ar->arWmiReady == false) {
-        return -EIO;
-    }
-
-    if (copy_from_user((char *)&rssiParams, (char *)((unsigned int *)rq->ifr_data + 1), sizeof(USER_RSSI_PARAMS))) {
-        return -EFAULT;
-    }
-    cmd.weight = rssiParams.weight;
-    cmd.pollTime = rssiParams.pollTime;
-
-    memcpy(ar->rssi_map, &rssiParams.tholds, sizeof(ar->rssi_map));
-    /*
-     *  only 6 elements, so use bubble sorting, in ascending order
-     */
-    for (i = 5; i > 0; i--) {
-        for (j = 0; j < i; j++) { /* above tholds */
-            if (ar->rssi_map[j+1].rssi < ar->rssi_map[j].rssi) {
-                SWAP_THOLD(ar->rssi_map[j+1], ar->rssi_map[j]);
-            } else if (ar->rssi_map[j+1].rssi == ar->rssi_map[j].rssi) {
-                return -EFAULT;
-            }
-        }
-    }
-    for (i = 11; i > 6; i--) {
-        for (j = 6; j < i; j++) { /* below tholds */
-            if (ar->rssi_map[j+1].rssi < ar->rssi_map[j].rssi) {
-                SWAP_THOLD(ar->rssi_map[j+1], ar->rssi_map[j]);
-            } else if (ar->rssi_map[j+1].rssi == ar->rssi_map[j].rssi) {
-                return -EFAULT;
-            }
-        }
-    }
-
-#ifdef DEBUG
-    for (i = 0; i < 12; i++) {
-        AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("thold[%d].tag: %d, thold[%d].rssi: %d \n",
-                i, ar->rssi_map[i].tag, i, ar->rssi_map[i].rssi));
-    }
-#endif
-
-    if (enablerssicompensation) {
-        for (i = 0; i < 6; i++)
-            ar->rssi_map[i].rssi = rssi_compensation_reverse_calc(ar, ar->rssi_map[i].rssi, true);
-        for (i = 6; i < 12; i++)
-            ar->rssi_map[i].rssi = rssi_compensation_reverse_calc(ar, ar->rssi_map[i].rssi, false);
-    }
-
-    cmd.thresholdAbove1_Val = ar->rssi_map[0].rssi;
-    cmd.thresholdAbove2_Val = ar->rssi_map[1].rssi;
-    cmd.thresholdAbove3_Val = ar->rssi_map[2].rssi;
-    cmd.thresholdAbove4_Val = ar->rssi_map[3].rssi;
-    cmd.thresholdAbove5_Val = ar->rssi_map[4].rssi;
-    cmd.thresholdAbove6_Val = ar->rssi_map[5].rssi;
-    cmd.thresholdBelow1_Val = ar->rssi_map[6].rssi;
-    cmd.thresholdBelow2_Val = ar->rssi_map[7].rssi;
-    cmd.thresholdBelow3_Val = ar->rssi_map[8].rssi;
-    cmd.thresholdBelow4_Val = ar->rssi_map[9].rssi;
-    cmd.thresholdBelow5_Val = ar->rssi_map[10].rssi;
-    cmd.thresholdBelow6_Val = ar->rssi_map[11].rssi;
-
-    if( wmi_set_rssi_threshold_params(ar->arWmi, &cmd) != 0 ) {
-        ret = -EIO;
-    }
-
-    return ret;
-}
-
-static int
-ar6000_ioctl_set_lq_threshold(struct net_device *dev, struct ifreq *rq)
-{
-
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-    WMI_LQ_THRESHOLD_PARAMS_CMD cmd;
-    int ret = 0;
-
-    if (ar->arWmiReady == false) {
-        return -EIO;
-    }
-
-    if (copy_from_user(&cmd, (char *)((unsigned int *)rq->ifr_data + 1), sizeof(cmd))) {
-        return -EFAULT;
-    }
-
-    if( wmi_set_lq_threshold_params(ar->arWmi, &cmd) != 0 ) {
-        ret = -EIO;
-    }
-
-    return ret;
-}
-
-
-static int
-ar6000_ioctl_set_probedSsid(struct net_device *dev, struct ifreq *rq)
-{
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-    WMI_PROBED_SSID_CMD cmd;
-    int ret = 0;
-
-    if (ar->arWmiReady == false) {
-        return -EIO;
-    }
-
-    if (copy_from_user(&cmd, rq->ifr_data, sizeof(cmd))) {
-        return -EFAULT;
-    }
-
-    if (wmi_probedSsid_cmd(ar->arWmi, cmd.entryIndex, cmd.flag, cmd.ssidLength,
-                                  cmd.ssid) != 0)
-    {
-        ret = -EIO;
-    }
-
-    return ret;
-}
-
-static int
-ar6000_ioctl_set_badAp(struct net_device *dev, struct ifreq *rq)
-{
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-    WMI_ADD_BAD_AP_CMD cmd;
-    int ret = 0;
-
-    if (ar->arWmiReady == false) {
-        return -EIO;
-    }
-
-
-    if (copy_from_user(&cmd, rq->ifr_data, sizeof(cmd))) {
-        return -EFAULT;
-    }
-
-    if (cmd.badApIndex > WMI_MAX_BAD_AP_INDEX) {
-        return -EIO;
-    }
-
-    if (memcmp(cmd.bssid, null_mac, AR6000_ETH_ADDR_LEN) == 0) {
-        /*
-         * This is a delete badAP.
-         */
-        if (wmi_deleteBadAp_cmd(ar->arWmi, cmd.badApIndex) != 0) {
-            ret = -EIO;
-        }
-    } else {
-        if (wmi_addBadAp_cmd(ar->arWmi, cmd.badApIndex, cmd.bssid) != 0) {
-            ret = -EIO;
-        }
-    }
-
-    return ret;
-}
-
-static int
-ar6000_ioctl_create_qos(struct net_device *dev, struct ifreq *rq)
-{
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-    WMI_CREATE_PSTREAM_CMD cmd;
-    int ret;
-
-    if (ar->arWmiReady == false) {
-        return -EIO;
-    }
-
-
-    if (copy_from_user(&cmd, rq->ifr_data, sizeof(cmd))) {
-        return -EFAULT;
-    }
-
-    ret = wmi_verify_tspec_params(&cmd, tspecCompliance);
-    if (ret == 0)
-        ret = wmi_create_pstream_cmd(ar->arWmi, &cmd);
-
-    switch (ret) {
-        case 0:
-            return 0;
-        case A_EBUSY :
-            return -EBUSY;
-        case A_NO_MEMORY:
-            return -ENOMEM;
-        case A_EINVAL:
-        default:
-            return -EFAULT;
-    }
-}
-
-static int
-ar6000_ioctl_delete_qos(struct net_device *dev, struct ifreq *rq)
-{
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-    WMI_DELETE_PSTREAM_CMD cmd;
-    int ret = 0;
-
-    if (ar->arWmiReady == false) {
-        return -EIO;
-    }
-
-    if (copy_from_user(&cmd, rq->ifr_data, sizeof(cmd))) {
-        return -EFAULT;
-    }
-
-    ret = wmi_delete_pstream_cmd(ar->arWmi, cmd.trafficClass, cmd.tsid);
-
-    switch (ret) {
-        case 0:
-            return 0;
-        case A_EBUSY :
-            return -EBUSY;
-        case A_NO_MEMORY:
-            return -ENOMEM;
-        case A_EINVAL:
-        default:
-            return -EFAULT;
-    }
-}
-
-static int
-ar6000_ioctl_get_qos_queue(struct net_device *dev, struct ifreq *rq)
-{
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-    struct ar6000_queuereq qreq;
-    int ret = 0;
-
-    if (ar->arWmiReady == false) {
-        return -EIO;
-    }
-
-    if( copy_from_user(&qreq, rq->ifr_data,
-                  sizeof(struct ar6000_queuereq)))
-        return -EFAULT;
-
-    qreq.activeTsids = wmi_get_mapped_qos_queue(ar->arWmi, qreq.trafficClass);
-
-    if (copy_to_user(rq->ifr_data, &qreq,
-                 sizeof(struct ar6000_queuereq)))
-    {
-        ret = -EFAULT;
-    }
-
-    return ret;
-}
-
-#ifdef CONFIG_HOST_TCMD_SUPPORT
-static int
-ar6000_ioctl_tcmd_get_rx_report(struct net_device *dev,
-                                 struct ifreq *rq, u8 *data, u32 len)
-{
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-    u32 buf[4+TCMD_MAX_RATES];
-    int ret = 0;
-
-    if (ar->bIsDestroyProgress) {
-        return -EBUSY;
-    }
-
-    if (ar->arWmiReady == false) {
-        return -EIO;
-    }
-
-    if (down_interruptible(&ar->arSem)) {
-        return -ERESTARTSYS;
-    }
-
-    if (ar->bIsDestroyProgress) {
-        up(&ar->arSem);
-        return -EBUSY;
-    }
-
-    ar->tcmdRxReport = 0;
-    if (wmi_test_cmd(ar->arWmi, data, len) != 0) {
-        up(&ar->arSem);
-        return -EIO;
-    }
-
-    wait_event_interruptible_timeout(arEvent, ar->tcmdRxReport != 0, wmitimeout * HZ);
-
-    if (signal_pending(current)) {
-        ret = -EINTR;
-    }
-
-    buf[0] = ar->tcmdRxTotalPkt;
-    buf[1] = ar->tcmdRxRssi;
-    buf[2] = ar->tcmdRxcrcErrPkt;
-    buf[3] = ar->tcmdRxsecErrPkt;
-    memcpy(((u8 *)buf)+(4*sizeof(u32)), ar->tcmdRateCnt, sizeof(ar->tcmdRateCnt));
-    memcpy(((u8 *)buf)+(4*sizeof(u32))+(TCMD_MAX_RATES *sizeof(u16)), ar->tcmdRateCntShortGuard, sizeof(ar->tcmdRateCntShortGuard));
-
-    if (!ret && copy_to_user(rq->ifr_data, buf, sizeof(buf))) {
-        ret = -EFAULT;
-    }
-
-    up(&ar->arSem);
-
-    return ret;
-}
-
-void
-ar6000_tcmd_rx_report_event(void *devt, u8 *results, int len)
-{
-    struct ar6_softc *ar = (struct ar6_softc *)devt;
-    TCMD_CONT_RX * rx_rep = (TCMD_CONT_RX *)results;
-
-    if (enablerssicompensation) {
-        rx_rep->u.report.rssiInDBm = rssi_compensation_calc_tcmd(tcmdRxFreq, rx_rep->u.report.rssiInDBm,rx_rep->u.report.totalPkt);
-    }
-
-
-    ar->tcmdRxTotalPkt = rx_rep->u.report.totalPkt;
-    ar->tcmdRxRssi = rx_rep->u.report.rssiInDBm;
-    ar->tcmdRxcrcErrPkt = rx_rep->u.report.crcErrPkt;
-    ar->tcmdRxsecErrPkt = rx_rep->u.report.secErrPkt;
-    ar->tcmdRxReport = 1;
-    A_MEMZERO(ar->tcmdRateCnt,  sizeof(ar->tcmdRateCnt));
-    A_MEMZERO(ar->tcmdRateCntShortGuard,  sizeof(ar->tcmdRateCntShortGuard));
-    memcpy(ar->tcmdRateCnt, rx_rep->u.report.rateCnt, sizeof(ar->tcmdRateCnt));
-    memcpy(ar->tcmdRateCntShortGuard, rx_rep->u.report.rateCntShortGuard, sizeof(ar->tcmdRateCntShortGuard));
-
-    wake_up(&arEvent);
-}
-#endif /* CONFIG_HOST_TCMD_SUPPORT*/
-
-static int
-ar6000_ioctl_set_error_report_bitmask(struct net_device *dev, struct ifreq *rq)
-{
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-    WMI_TARGET_ERROR_REPORT_BITMASK cmd;
-    int ret = 0;
-
-    if (ar->arWmiReady == false) {
-        return -EIO;
-    }
-
-    if (copy_from_user(&cmd, rq->ifr_data, sizeof(cmd))) {
-        return -EFAULT;
-    }
-
-    ret = wmi_set_error_report_bitmask(ar->arWmi, cmd.bitmask);
-
-    return  (ret==0 ? ret : -EINVAL);
-}
-
-static int
-ar6000_clear_target_stats(struct net_device *dev)
-{
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-    TARGET_STATS *pStats = &ar->arTargetStats;
-    int ret = 0;
-
-    if (ar->arWmiReady == false) {
-       return -EIO;
-    }
-    AR6000_SPIN_LOCK(&ar->arLock, 0);
-    A_MEMZERO(pStats, sizeof(TARGET_STATS));
-    AR6000_SPIN_UNLOCK(&ar->arLock, 0);
-    return ret;
-}
-
-static int
-ar6000_ioctl_get_target_stats(struct net_device *dev, struct ifreq *rq)
-{
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-    TARGET_STATS_CMD cmd;
-    TARGET_STATS *pStats = &ar->arTargetStats;
-    int ret = 0;
-
-    if (ar->bIsDestroyProgress) {
-        return -EBUSY;
-    }
-    if (ar->arWmiReady == false) {
-        return -EIO;
-    }
-    if (copy_from_user(&cmd, rq->ifr_data, sizeof(cmd))) {
-        return -EFAULT;
-    }
-    if (down_interruptible(&ar->arSem)) {
-        return -ERESTARTSYS;
-    }
-    if (ar->bIsDestroyProgress) {
-        up(&ar->arSem);
-        return -EBUSY;
-    }
-
-    ar->statsUpdatePending = true;
-
-    if(wmi_get_stats_cmd(ar->arWmi) != 0) {
-        up(&ar->arSem);
-        return -EIO;
-    }
-
-    wait_event_interruptible_timeout(arEvent, ar->statsUpdatePending == false, wmitimeout * HZ);
-
-    if (signal_pending(current)) {
-        ret = -EINTR;
-    }
-
-    if (!ret && copy_to_user(rq->ifr_data, pStats, sizeof(*pStats))) {
-        ret = -EFAULT;
-    }
-
-    if (cmd.clearStats == 1) {
-        ret = ar6000_clear_target_stats(dev);
-    }
-
-    up(&ar->arSem);
-
-    return ret;
-}
-
-static int
-ar6000_ioctl_get_ap_stats(struct net_device *dev, struct ifreq *rq)
-{
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-    u32 action; /* Allocating only the desired space on the frame. Declaring is as a WMI_AP_MODE_STAT variable results in exceeding the compiler imposed limit on the maximum frame size */
-    WMI_AP_MODE_STAT *pStats = &ar->arAPStats;
-    int ret = 0;
-
-    if (ar->arWmiReady == false) {
-        return -EIO;
-    }
-    if (copy_from_user(&action, (char *)((unsigned int*)rq->ifr_data + 1),
-                                sizeof(u32)))
-    {
-        return -EFAULT;
-    }
-    if (action == AP_CLEAR_STATS) {
-        u8 i;
-        AR6000_SPIN_LOCK(&ar->arLock, 0);
-        for(i = 0; i < AP_MAX_NUM_STA; i++) {
-            pStats->sta[i].tx_bytes = 0;
-            pStats->sta[i].tx_pkts = 0;
-            pStats->sta[i].tx_error = 0;
-            pStats->sta[i].tx_discard = 0;
-            pStats->sta[i].rx_bytes = 0;
-            pStats->sta[i].rx_pkts = 0;
-            pStats->sta[i].rx_error = 0;
-            pStats->sta[i].rx_discard = 0;
-        }
-        AR6000_SPIN_UNLOCK(&ar->arLock, 0);
-        return ret;
-    }
-
-    if (down_interruptible(&ar->arSem)) {
-        return -ERESTARTSYS;
-    }
-
-    ar->statsUpdatePending = true;
-
-    if(wmi_get_stats_cmd(ar->arWmi) != 0) {
-        up(&ar->arSem);
-        return -EIO;
-    }
-
-    wait_event_interruptible_timeout(arEvent, ar->statsUpdatePending == false, wmitimeout * HZ);
-
-    if (signal_pending(current)) {
-        ret = -EINTR;
-    }
-
-    if (!ret && copy_to_user(rq->ifr_data, pStats, sizeof(*pStats))) {
-        ret = -EFAULT;
-    }
-
-    up(&ar->arSem);
-
-    return ret;
-}
-
-static int
-ar6000_ioctl_set_access_params(struct net_device *dev, struct ifreq *rq)
-{
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-    WMI_SET_ACCESS_PARAMS_CMD cmd;
-    int ret = 0;
-
-    if (ar->arWmiReady == false) {
-        return -EIO;
-    }
-
-    if (copy_from_user(&cmd, rq->ifr_data, sizeof(cmd))) {
-        return -EFAULT;
-    }
-
-    if (wmi_set_access_params_cmd(ar->arWmi, cmd.ac, cmd.txop, cmd.eCWmin, cmd.eCWmax,
-                                  cmd.aifsn) == 0)
-    {
-        ret = 0;
-    } else {
-        ret = -EINVAL;
-    }
-
-    return (ret);
-}
-
-static int
-ar6000_ioctl_set_disconnect_timeout(struct net_device *dev, struct ifreq *rq)
-{
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-    WMI_DISC_TIMEOUT_CMD cmd;
-    int ret = 0;
-
-    if (ar->arWmiReady == false) {
-        return -EIO;
-    }
-
-    if (copy_from_user(&cmd, rq->ifr_data, sizeof(cmd))) {
-        return -EFAULT;
-    }
-
-    if (wmi_disctimeout_cmd(ar->arWmi, cmd.disconnectTimeout) == 0)
-    {
-        ret = 0;
-    } else {
-        ret = -EINVAL;
-    }
-
-    return (ret);
-}
-
-static int
-ar6000_xioctl_set_voice_pkt_size(struct net_device *dev, char *userdata)
-{
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-    WMI_SET_VOICE_PKT_SIZE_CMD cmd;
-    int ret = 0;
-
-    if (ar->arWmiReady == false) {
-        return -EIO;
-    }
-
-    if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
-        return -EFAULT;
-    }
-
-    if (wmi_set_voice_pkt_size_cmd(ar->arWmi, cmd.voicePktSize) == 0)
-    {
-        ret = 0;
-    } else {
-        ret = -EINVAL;
-    }
-
-
-    return (ret);
-}
-
-static int
-ar6000_xioctl_set_max_sp_len(struct net_device *dev, char *userdata)
-{
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-    WMI_SET_MAX_SP_LEN_CMD cmd;
-    int ret = 0;
-
-    if (ar->arWmiReady == false) {
-        return -EIO;
-    }
-
-    if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
-        return -EFAULT;
-    }
-
-    if (wmi_set_max_sp_len_cmd(ar->arWmi, cmd.maxSPLen) == 0)
-    {
-        ret = 0;
-    } else {
-        ret = -EINVAL;
-    }
-
-    return (ret);
-}
-
-
-static int
-ar6000_xioctl_set_bt_status_cmd(struct net_device *dev, char *userdata)
-{
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-    WMI_SET_BT_STATUS_CMD cmd;
-    int ret = 0;
-
-    if (ar->arWmiReady == false) {
-        return -EIO;
-    }
-
-    if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
-        return -EFAULT;
-    }
-
-    if (wmi_set_bt_status_cmd(ar->arWmi, cmd.streamType, cmd.status) == 0)
-    {
-        ret = 0;
-    } else {
-        ret = -EINVAL;
-    }
-
-    return (ret);
-}
-
-static int
-ar6000_xioctl_set_bt_params_cmd(struct net_device *dev, char *userdata)
-{
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-    WMI_SET_BT_PARAMS_CMD cmd;
-    int ret = 0;
-
-    if (ar->arWmiReady == false) {
-        return -EIO;
-    }
-
-    if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
-        return -EFAULT;
-    }
-
-    if (wmi_set_bt_params_cmd(ar->arWmi, &cmd) == 0)
-    {
-        ret = 0;
-    } else {
-        ret = -EINVAL;
-    }
-
-    return (ret);
-}
-
-static int
-ar6000_xioctl_set_btcoex_fe_ant_cmd(struct net_device * dev, char *userdata)
-{
-       struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-       WMI_SET_BTCOEX_FE_ANT_CMD cmd;
-    int ret = 0;
-
-       if (ar->arWmiReady == false) {
-               return -EIO;
-       }
-       if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
-               return -EFAULT;
-       }
-
-    if (wmi_set_btcoex_fe_ant_cmd(ar->arWmi, &cmd) == 0)
-    {
-        ret = 0;
-    } else {
-        ret = -EINVAL;
-    }
-
-       return(ret);
-}
-
-static int
-ar6000_xioctl_set_btcoex_colocated_bt_dev_cmd(struct net_device * dev, char *userdata)
-{
-       struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-       WMI_SET_BTCOEX_COLOCATED_BT_DEV_CMD cmd;
-    int ret = 0;
-
-       if (ar->arWmiReady == false) {
-               return -EIO;
-       }
-
-       if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
-               return -EFAULT;
-       }
-
-    if (wmi_set_btcoex_colocated_bt_dev_cmd(ar->arWmi, &cmd) == 0)
-    {
-        ret = 0;
-    } else {
-        ret = -EINVAL;
-    }
-
-       return(ret);
-}
-
-static int
-ar6000_xioctl_set_btcoex_btinquiry_page_config_cmd(struct net_device * dev,  char *userdata)
-{
-       struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-       WMI_SET_BTCOEX_BTINQUIRY_PAGE_CONFIG_CMD cmd;
-    int ret = 0;
-
-       if (ar->arWmiReady == false) {
-               return -EIO;
-       }
-
-       if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
-               return -EFAULT;
-       }
-
-    if (wmi_set_btcoex_btinquiry_page_config_cmd(ar->arWmi, &cmd) == 0)
-    {
-        ret = 0;
-    } else {
-        ret = -EINVAL;
-    }
-
-       return(ret);
-}
-
-static int
-ar6000_xioctl_set_btcoex_sco_config_cmd(struct net_device * dev, char *userdata)
-{
-       struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-       WMI_SET_BTCOEX_SCO_CONFIG_CMD cmd;
-    int ret = 0;
-
-       if (ar->arWmiReady == false) {
-               return -EIO;
-       }
-
-       if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
-               return -EFAULT;
-       }
-
-    if (wmi_set_btcoex_sco_config_cmd(ar->arWmi, &cmd) == 0)
-    {
-        ret = 0;
-    } else {
-        ret = -EINVAL;
-    }
-
-       return(ret);
-}
-
-static int
-ar6000_xioctl_set_btcoex_a2dp_config_cmd(struct net_device * dev,
-                                                                                                               char *userdata)
-{
-       struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-       WMI_SET_BTCOEX_A2DP_CONFIG_CMD cmd;
-    int ret = 0;
-
-       if (ar->arWmiReady == false) {
-               return -EIO;
-       }
-
-       if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
-               return -EFAULT;
-       }
-
-    if (wmi_set_btcoex_a2dp_config_cmd(ar->arWmi, &cmd) == 0)
-    {
-        ret = 0;
-    } else {
-        ret = -EINVAL;
-    }
-
-       return(ret);
-}
-
-static int
-ar6000_xioctl_set_btcoex_aclcoex_config_cmd(struct net_device * dev, char *userdata)
-{
-       struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-       WMI_SET_BTCOEX_ACLCOEX_CONFIG_CMD cmd;
-    int ret = 0;
-
-       if (ar->arWmiReady == false) {
-               return -EIO;
-       }
-
-       if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
-               return -EFAULT;
-       }
-
-    if (wmi_set_btcoex_aclcoex_config_cmd(ar->arWmi, &cmd) == 0)
-    {
-        ret = 0;
-    } else {
-        ret = -EINVAL;
-    }
-
-       return(ret);
-}
-
-static int
-ar60000_xioctl_set_btcoex_debug_cmd(struct net_device * dev, char *userdata)
-{
-       struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-       WMI_SET_BTCOEX_DEBUG_CMD cmd;
-    int ret = 0;
-
-       if (ar->arWmiReady == false) {
-               return -EIO;
-       }
-
-       if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
-               return -EFAULT;
-       }
-
-    if (wmi_set_btcoex_debug_cmd(ar->arWmi, &cmd) == 0)
-    {
-        ret = 0;
-    } else {
-        ret = -EINVAL;
-    }
-
-       return(ret);
-}
-
-static int
-ar6000_xioctl_set_btcoex_bt_operating_status_cmd(struct net_device * dev, char *userdata)
-{
-     struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-     WMI_SET_BTCOEX_BT_OPERATING_STATUS_CMD cmd;
-     int ret = 0;
-
-    if (ar->arWmiReady == false) {
-       return -EIO;
-    }
-
-    if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
-       return -EFAULT;
-    }
-
-    if (wmi_set_btcoex_bt_operating_status_cmd(ar->arWmi, &cmd) == 0)
-    {
-        ret = 0;
-    } else {
-        ret = -EINVAL;
-    }
-    return(ret);
-}
-
-static int
-ar6000_xioctl_get_btcoex_config_cmd(struct net_device * dev, char *userdata,
-                                                                                       struct ifreq *rq)
-{
-
-       struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-    AR6000_BTCOEX_CONFIG btcoexConfig;
-    WMI_BTCOEX_CONFIG_EVENT *pbtcoexConfigEv = &ar->arBtcoexConfig;
-
-    int ret = 0;
-
-    if (ar->bIsDestroyProgress) {
-            return -EBUSY;
-    }
-    if (ar->arWmiReady == false) {
-            return -EIO;
-    }
-       if (copy_from_user(&btcoexConfig.configCmd, userdata, sizeof(AR6000_BTCOEX_CONFIG))) {
-               return -EFAULT;
-       }
-    if (down_interruptible(&ar->arSem)) {
-        return -ERESTARTSYS;
-    }
-
-    if (wmi_get_btcoex_config_cmd(ar->arWmi, (WMI_GET_BTCOEX_CONFIG_CMD *)&btcoexConfig.configCmd) != 0)
-    {
-       up(&ar->arSem);
-       return -EIO;
-    }
-
-    ar->statsUpdatePending = true;
-
-    wait_event_interruptible_timeout(arEvent, ar->statsUpdatePending == false, wmitimeout * HZ);
-
-    if (signal_pending(current)) {
-       ret = -EINTR;
-    }
-
-    if (!ret && copy_to_user(btcoexConfig.configEvent, pbtcoexConfigEv, sizeof(WMI_BTCOEX_CONFIG_EVENT))) {
-            ret = -EFAULT;
-    }
-    up(&ar->arSem);
-    return ret;
-}
-
-static int
-ar6000_xioctl_get_btcoex_stats_cmd(struct net_device * dev, char *userdata, struct ifreq *rq)
-{
-       struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-    AR6000_BTCOEX_STATS btcoexStats;
-    WMI_BTCOEX_STATS_EVENT *pbtcoexStats = &ar->arBtcoexStats;
-    int ret = 0;
-
-    if (ar->bIsDestroyProgress) {
-            return -EBUSY;
-    }
-    if (ar->arWmiReady == false) {
-            return -EIO;
-    }
-
-    if (down_interruptible(&ar->arSem)) {
-        return -ERESTARTSYS;
-    }
-
-       if (copy_from_user(&btcoexStats.statsEvent, userdata, sizeof(AR6000_BTCOEX_CONFIG))) {
-               return -EFAULT;
-       }
-
-    if (wmi_get_btcoex_stats_cmd(ar->arWmi) != 0)
-    {
-       up(&ar->arSem);
-       return -EIO;
-    }
-
-    ar->statsUpdatePending = true;
-
-    wait_event_interruptible_timeout(arEvent, ar->statsUpdatePending == false, wmitimeout * HZ);
-
-    if (signal_pending(current)) {
-       ret = -EINTR;
-    }
-
-    if (!ret && copy_to_user(btcoexStats.statsEvent, pbtcoexStats, sizeof(WMI_BTCOEX_STATS_EVENT))) {
-            ret = -EFAULT;
-    }
-
-
-    up(&ar->arSem);
-
-       return(ret);
-}
-
-static int
-ar6000_xioctl_set_excess_tx_retry_thres_cmd(struct net_device * dev, char * userdata)
-{
-    struct ar6_softc     *ar     = (struct ar6_softc *)ar6k_priv(dev);
-    WMI_SET_EXCESS_TX_RETRY_THRES_CMD cmd;
-    int ret = 0;
-
-    if (ar->arWmiReady == false) {
-        return -EIO;
-    }
-
-    if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
-        return -EFAULT;
-    }
-
-    if (wmi_set_excess_tx_retry_thres_cmd(ar->arWmi, &cmd) != 0)
-    {
-        ret = -EINVAL;
-    }
-    return(ret);
-}
-
-#ifdef CONFIG_HOST_GPIO_SUPPORT
-struct ar6000_gpio_intr_wait_cmd_s  gpio_intr_results;
-/* gpio_reg_results and gpio_data_available are protected by arSem */
-static struct ar6000_gpio_register_cmd_s gpio_reg_results;
-static bool gpio_data_available; /* Requested GPIO data available */
-static bool gpio_intr_available; /* GPIO interrupt info available */
-static bool gpio_ack_received;   /* GPIO ack was received */
-
-/* Host-side initialization for General Purpose I/O support */
-void ar6000_gpio_init(void)
-{
-    gpio_intr_available = false;
-    gpio_data_available = false;
-    gpio_ack_received   = false;
-}
-
-/*
- * Called when a GPIO interrupt is received from the Target.
- * intr_values shows which GPIO pins have interrupted.
- * input_values shows a recent value of GPIO pins.
- */
-void
-ar6000_gpio_intr_rx(u32 intr_mask, u32 input_values)
-{
-    gpio_intr_results.intr_mask = intr_mask;
-    gpio_intr_results.input_values = input_values;
-    *((volatile bool *)&gpio_intr_available) = true;
-    wake_up(&arEvent);
-}
-
-/*
- * This is called when a response is received from the Target
- * for a previous or ar6000_gpio_input_get or ar6000_gpio_register_get
- * call.
- */
-void
-ar6000_gpio_data_rx(u32 reg_id, u32 value)
-{
-    gpio_reg_results.gpioreg_id = reg_id;
-    gpio_reg_results.value = value;
-    *((volatile bool *)&gpio_data_available) = true;
-    wake_up(&arEvent);
-}
-
-/*
- * This is called when an acknowledgement is received from the Target
- * for a previous or ar6000_gpio_output_set or ar6000_gpio_register_set
- * call.
- */
-void
-ar6000_gpio_ack_rx(void)
-{
-    gpio_ack_received = true;
-    wake_up(&arEvent);
-}
-
-int
-ar6000_gpio_output_set(struct net_device *dev,
-                       u32 set_mask,
-                       u32 clear_mask,
-                       u32 enable_mask,
-                       u32 disable_mask)
-{
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-
-    gpio_ack_received = false;
-    return wmi_gpio_output_set(ar->arWmi,
-                set_mask, clear_mask, enable_mask, disable_mask);
-}
-
-static int
-ar6000_gpio_input_get(struct net_device *dev)
-{
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-
-    *((volatile bool *)&gpio_data_available) = false;
-    return wmi_gpio_input_get(ar->arWmi);
-}
-
-static int
-ar6000_gpio_register_set(struct net_device *dev,
-                         u32 gpioreg_id,
-                         u32 value)
-{
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-
-    gpio_ack_received = false;
-    return wmi_gpio_register_set(ar->arWmi, gpioreg_id, value);
-}
-
-static int
-ar6000_gpio_register_get(struct net_device *dev,
-                         u32 gpioreg_id)
-{
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-
-    *((volatile bool *)&gpio_data_available) = false;
-    return wmi_gpio_register_get(ar->arWmi, gpioreg_id);
-}
-
-static int
-ar6000_gpio_intr_ack(struct net_device *dev,
-                     u32 ack_mask)
-{
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-
-    gpio_intr_available = false;
-    return wmi_gpio_intr_ack(ar->arWmi, ack_mask);
-}
-#endif /* CONFIG_HOST_GPIO_SUPPORT */
-
-#if defined(CONFIG_TARGET_PROFILE_SUPPORT)
-static struct prof_count_s prof_count_results;
-static bool prof_count_available; /* Requested GPIO data available */
-
-static int
-prof_count_get(struct net_device *dev)
-{
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-
-    *((volatile bool *)&prof_count_available) = false;
-    return wmi_prof_count_get_cmd(ar->arWmi);
-}
-
-/*
- * This is called when a response is received from the Target
- * for a previous prof_count_get call.
- */
-void
-prof_count_rx(u32 addr, u32 count)
-{
-    prof_count_results.addr = addr;
-    prof_count_results.count = count;
-    *((volatile bool *)&prof_count_available) = true;
-    wake_up(&arEvent);
-}
-#endif /* CONFIG_TARGET_PROFILE_SUPPORT */
-
-
-static int
-ar6000_create_acl_data_osbuf(struct net_device *dev, u8 *userdata, void **p_osbuf)
-{
-    void *osbuf = NULL;
-    u8 tmp_space[8];
-    HCI_ACL_DATA_PKT *acl;
-    u8 hdr_size, *datap=NULL;
-    int ret = 0;
-
-    /* ACL is in data path. There is a need to create pool
-     * mechanism for allocating and freeing NETBUFs - ToDo later.
-     */
-
-    *p_osbuf = NULL;
-    acl = (HCI_ACL_DATA_PKT *)tmp_space;
-    hdr_size = sizeof(acl->hdl_and_flags) + sizeof(acl->data_len);
-
-    do {
-        if (a_copy_from_user(acl, userdata, hdr_size)) {
-            ret = A_EFAULT;
-            break;
-        }
-
-        osbuf = A_NETBUF_ALLOC(hdr_size + acl->data_len);
-        if (osbuf == NULL) {
-           ret = A_NO_MEMORY;
-           break;
-        }
-        A_NETBUF_PUT(osbuf, hdr_size + acl->data_len);
-        datap = (u8 *)A_NETBUF_DATA(osbuf);
-
-        /* Real copy to osbuf */
-        acl = (HCI_ACL_DATA_PKT *)(datap);
-        memcpy(acl, tmp_space, hdr_size);
-        if (a_copy_from_user(acl->data, userdata + hdr_size, acl->data_len)) {
-            ret = A_EFAULT;
-            break;
-        }
-    } while(false);
-
-    if (ret == 0) {
-        *p_osbuf = osbuf;
-    } else {
-        A_NETBUF_FREE(osbuf);
-    }
-    return ret;
-}
-
-
-
-int
-ar6000_ioctl_ap_setparam(struct ar6_softc *ar, int param, int value)
-{
-    int ret=0;
-
-    switch(param) {
-        case IEEE80211_PARAM_WPA:
-            switch (value) {
-                case WPA_MODE_WPA1:
-                    ar->arAuthMode = WPA_AUTH;
-                    break;
-                case WPA_MODE_WPA2:
-                    ar->arAuthMode = WPA2_AUTH;
-                    break;
-                case WPA_MODE_AUTO:
-                    ar->arAuthMode = WPA_AUTH | WPA2_AUTH;
-                    break;
-                case WPA_MODE_NONE:
-                    ar->arAuthMode = NONE_AUTH;
-                    break;
-            }
-            break;
-        case IEEE80211_PARAM_AUTHMODE:
-            if(value == IEEE80211_AUTH_WPA_PSK) {
-                if (WPA_AUTH == ar->arAuthMode) {
-                    ar->arAuthMode = WPA_PSK_AUTH;
-                } else if (WPA2_AUTH == ar->arAuthMode) {
-                    ar->arAuthMode = WPA2_PSK_AUTH;
-                } else if ((WPA_AUTH | WPA2_AUTH) == ar->arAuthMode) {
-                    ar->arAuthMode = WPA_PSK_AUTH | WPA2_PSK_AUTH;
-                } else {
-                    AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Error -  Setting PSK "\
-                        "mode when WPA param was set to %d\n",
-                        ar->arAuthMode));
-                    ret = -EIO;
-                }
-            }
-            break;
-        case IEEE80211_PARAM_UCASTCIPHER:
-            ar->arPairwiseCrypto = 0;
-            if(value & (1<<IEEE80211_CIPHER_AES_CCM)) {
-                ar->arPairwiseCrypto |= AES_CRYPT;
-            }
-            if(value & (1<<IEEE80211_CIPHER_TKIP)) {
-                ar->arPairwiseCrypto |= TKIP_CRYPT;
-            }
-            if(!ar->arPairwiseCrypto) {
-                AR_DEBUG_PRINTF(ATH_DEBUG_ERR,
-                           ("Error - Invalid cipher in WPA \n"));
-                ret = -EIO;
-            }
-            break;
-        case IEEE80211_PARAM_PRIVACY:
-            if(value == 0) {
-                ar->arDot11AuthMode      = OPEN_AUTH;
-                ar->arAuthMode           = NONE_AUTH;
-                ar->arPairwiseCrypto     = NONE_CRYPT;
-                ar->arPairwiseCryptoLen  = 0;
-                ar->arGroupCrypto        = NONE_CRYPT;
-                ar->arGroupCryptoLen     = 0;
-            }
-            break;
-#ifdef WAPI_ENABLE
-        case IEEE80211_PARAM_WAPI:
-            A_PRINTF("WAPI Policy: %d\n", value);
-            ar->arDot11AuthMode      = OPEN_AUTH;
-            ar->arAuthMode           = NONE_AUTH;
-            if(value & 0x1) {
-                ar->arPairwiseCrypto     = WAPI_CRYPT;
-                ar->arGroupCrypto        = WAPI_CRYPT;
-            } else {
-                ar->arPairwiseCrypto     = NONE_CRYPT;
-                ar->arGroupCrypto        = NONE_CRYPT;
-            }
-            break;
-#endif
-    }
-    return ret;
-}
-
-int
-ar6000_ioctl_setparam(struct ar6_softc *ar, int param, int value)
-{
-    bool profChanged = false;
-    int ret=0;
-
-    if(ar->arNextMode == AP_NETWORK) {
-        ar->ap_profile_flag = 1; /* There is a change in profile */
-        switch (param) {
-            case IEEE80211_PARAM_WPA:
-            case IEEE80211_PARAM_AUTHMODE:
-            case IEEE80211_PARAM_UCASTCIPHER:
-            case IEEE80211_PARAM_PRIVACY:
-            case IEEE80211_PARAM_WAPI:
-                ret = ar6000_ioctl_ap_setparam(ar, param, value);
-                return ret;
-        }
-    }
-
-    switch (param) {
-        case IEEE80211_PARAM_WPA:
-            switch (value) {
-                case WPA_MODE_WPA1:
-                    ar->arAuthMode = WPA_AUTH;
-                    profChanged    = true;
-                    break;
-                case WPA_MODE_WPA2:
-                    ar->arAuthMode = WPA2_AUTH;
-                    profChanged    = true;
-                    break;
-                case WPA_MODE_NONE:
-                    ar->arAuthMode = NONE_AUTH;
-                    profChanged    = true;
-                    break;
-            }
-            break;
-        case IEEE80211_PARAM_AUTHMODE:
-            switch(value) {
-                case IEEE80211_AUTH_WPA_PSK:
-                    if (WPA_AUTH == ar->arAuthMode) {
-                        ar->arAuthMode = WPA_PSK_AUTH;
-                        profChanged    = true;
-                    } else if (WPA2_AUTH == ar->arAuthMode) {
-                        ar->arAuthMode = WPA2_PSK_AUTH;
-                        profChanged    = true;
-                    } else {
-                        AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Error -  Setting PSK "\
-                            "mode when WPA param was set to %d\n",
-                            ar->arAuthMode));
-                        ret = -EIO;
-                    }
-                    break;
-                case IEEE80211_AUTH_WPA_CCKM:
-                    if (WPA2_AUTH == ar->arAuthMode) {
-                        ar->arAuthMode = WPA2_AUTH_CCKM;
-                    } else {
-                        ar->arAuthMode = WPA_AUTH_CCKM;
-                    }
-                    break;
-                default:
-                    break;
-            }
-            break;
-        case IEEE80211_PARAM_UCASTCIPHER:
-            switch (value) {
-                case IEEE80211_CIPHER_AES_CCM:
-                    ar->arPairwiseCrypto = AES_CRYPT;
-                    profChanged          = true;
-                    break;
-                case IEEE80211_CIPHER_TKIP:
-                    ar->arPairwiseCrypto = TKIP_CRYPT;
-                    profChanged          = true;
-                    break;
-                case IEEE80211_CIPHER_WEP:
-                    ar->arPairwiseCrypto = WEP_CRYPT;
-                    profChanged          = true;
-                    break;
-                case IEEE80211_CIPHER_NONE:
-                    ar->arPairwiseCrypto = NONE_CRYPT;
-                    profChanged          = true;
-                    break;
-            }
-            break;
-        case IEEE80211_PARAM_UCASTKEYLEN:
-            if (!IEEE80211_IS_VALID_WEP_CIPHER_LEN(value)) {
-                ret = -EIO;
-            } else {
-                ar->arPairwiseCryptoLen = value;
-            }
-            break;
-        case IEEE80211_PARAM_MCASTCIPHER:
-            switch (value) {
-                case IEEE80211_CIPHER_AES_CCM:
-                    ar->arGroupCrypto = AES_CRYPT;
-                    profChanged       = true;
-                    break;
-                case IEEE80211_CIPHER_TKIP:
-                    ar->arGroupCrypto = TKIP_CRYPT;
-                    profChanged       = true;
-                    break;
-                case IEEE80211_CIPHER_WEP:
-                    ar->arGroupCrypto = WEP_CRYPT;
-                    profChanged       = true;
-                    break;
-                case IEEE80211_CIPHER_NONE:
-                    ar->arGroupCrypto = NONE_CRYPT;
-                    profChanged       = true;
-                    break;
-            }
-            break;
-        case IEEE80211_PARAM_MCASTKEYLEN:
-            if (!IEEE80211_IS_VALID_WEP_CIPHER_LEN(value)) {
-                ret = -EIO;
-            } else {
-                ar->arGroupCryptoLen = value;
-            }
-            break;
-        case IEEE80211_PARAM_COUNTERMEASURES:
-            if (ar->arWmiReady == false) {
-                return -EIO;
-            }
-            wmi_set_tkip_countermeasures_cmd(ar->arWmi, value);
-            break;
-        default:
-            break;
-    }
-    if ((ar->arNextMode != AP_NETWORK) && (profChanged == true)) {
-        /*
-         * profile has changed.  Erase ssid to signal change
-         */
-        A_MEMZERO(ar->arSsid, sizeof(ar->arSsid));
-    }
-
-    return ret;
-}
-
-int
-ar6000_ioctl_setkey(struct ar6_softc *ar, struct ieee80211req_key *ik)
-{
-    KEY_USAGE keyUsage;
-    int status;
-    CRYPTO_TYPE keyType = NONE_CRYPT;
-
-#ifdef USER_KEYS
-    ar->user_saved_keys.keyOk = false;
-#endif
-    if ( (0 == memcmp(ik->ik_macaddr, null_mac, IEEE80211_ADDR_LEN)) ||
-         (0 == memcmp(ik->ik_macaddr, bcast_mac, IEEE80211_ADDR_LEN)) ) {
-        keyUsage = GROUP_USAGE;
-        if(ar->arNextMode == AP_NETWORK) {
-            memcpy(&ar->ap_mode_bkey, ik,
-                     sizeof(struct ieee80211req_key));
-#ifdef WAPI_ENABLE
-            if(ar->arPairwiseCrypto == WAPI_CRYPT) {
-                return ap_set_wapi_key(ar, ik);
-            }
-#endif
-        }
-#ifdef USER_KEYS
-        memcpy(&ar->user_saved_keys.bcast_ik, ik,
-                 sizeof(struct ieee80211req_key));
-#endif
-    } else {
-        keyUsage = PAIRWISE_USAGE;
-#ifdef USER_KEYS
-        memcpy(&ar->user_saved_keys.ucast_ik, ik,
-                 sizeof(struct ieee80211req_key));
-#endif
-#ifdef WAPI_ENABLE
-        if(ar->arNextMode == AP_NETWORK) {
-            if(ar->arPairwiseCrypto == WAPI_CRYPT) {
-                return ap_set_wapi_key(ar, ik);
-            }
-        }
-#endif
-    }
-
-    switch (ik->ik_type) {
-        case IEEE80211_CIPHER_WEP:
-            keyType = WEP_CRYPT;
-            break;
-        case IEEE80211_CIPHER_TKIP:
-            keyType = TKIP_CRYPT;
-            break;
-        case IEEE80211_CIPHER_AES_CCM:
-            keyType = AES_CRYPT;
-            break;
-        default:
-            break;
-    }
-#ifdef USER_KEYS
-    ar->user_saved_keys.keyType = keyType;
-#endif
-    if (IEEE80211_CIPHER_CCKM_KRK != ik->ik_type) {
-        if (NONE_CRYPT == keyType) {
-            return -EIO;
-        }
-
-        if ((WEP_CRYPT == keyType)&&(!ar->arConnected)) {
-             int index = ik->ik_keyix;
-
-            if (!IEEE80211_IS_VALID_WEP_CIPHER_LEN(ik->ik_keylen)) {
-                return -EIO;
-            }
-
-            A_MEMZERO(ar->arWepKeyList[index].arKey,
-                            sizeof(ar->arWepKeyList[index].arKey));
-            memcpy(ar->arWepKeyList[index].arKey, ik->ik_keydata, ik->ik_keylen);
-            ar->arWepKeyList[index].arKeyLen = ik->ik_keylen;
-
-            if(ik->ik_flags & IEEE80211_KEY_DEFAULT){
-                ar->arDefTxKeyIndex = index;
-            }
-
-            return 0;
-        }
-
-        if (((WPA_PSK_AUTH == ar->arAuthMode) || (WPA2_PSK_AUTH == ar->arAuthMode)) &&
-            (GROUP_USAGE & keyUsage))
-        {
-            A_UNTIMEOUT(&ar->disconnect_timer);
-        }
-
-        status = wmi_addKey_cmd(ar->arWmi, ik->ik_keyix, keyType, keyUsage,
-                                ik->ik_keylen, (u8 *)&ik->ik_keyrsc,
-                                ik->ik_keydata, KEY_OP_INIT_VAL, ik->ik_macaddr,
-                                SYNC_BOTH_WMIFLAG);
-
-        if (status) {
-            return -EIO;
-        }
-    } else {
-        status = wmi_add_krk_cmd(ar->arWmi, ik->ik_keydata);
-    }
-
-#ifdef USER_KEYS
-    ar->user_saved_keys.keyOk = true;
-#endif
-
-    return 0;
-}
-
-int ar6000_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
-{
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-    struct hif_device *hifDevice = ar->arHifDevice;
-    int ret = 0, param;
-    unsigned int address = 0;
-    unsigned int length = 0;
-    unsigned char *buffer;
-    char *userdata;
-    u32 connectCtrlFlags;
-
-
-    WMI_SET_AKMP_PARAMS_CMD  akmpParams;
-    WMI_SET_PMKID_LIST_CMD   pmkidInfo;
-
-    WMI_SET_HT_CAP_CMD htCap;
-    WMI_SET_HT_OP_CMD htOp;
-
-    /*
-     * ioctl operations may have to wait for the Target, so we cannot hold rtnl.
-     * Prevent the device from disappearing under us and release the lock during
-     * the ioctl operation.
-     */
-    dev_hold(dev);
-    rtnl_unlock();
-
-    if (cmd == AR6000_IOCTL_EXTENDED) {
-        /*
-         * This allows for many more wireless ioctls than would otherwise
-         * be available.  Applications embed the actual ioctl command in
-         * the first word of the parameter block, and use the command
-         * AR6000_IOCTL_EXTENDED_CMD on the ioctl call.
-         */
-       if (get_user(cmd, (int *)rq->ifr_data)) {
-           ret = -EFAULT;
-           goto ioctl_done;
-       }
-        userdata = (char *)(((unsigned int *)rq->ifr_data)+1);
-        if(is_xioctl_allowed(ar->arNextMode, cmd) != 0) {
-            A_PRINTF("xioctl: cmd=%d not allowed in this mode\n",cmd);
-            ret = -EOPNOTSUPP;
-            goto ioctl_done;
-    }
-    } else {
-        int ret = is_iwioctl_allowed(ar->arNextMode, cmd);
-        if(ret == A_ENOTSUP) {
-            A_PRINTF("iwioctl: cmd=0x%x not allowed in this mode\n", cmd);
-            ret = -EOPNOTSUPP;
-            goto ioctl_done;
-        } else if (ret == A_ERROR) {
-            /* It is not our ioctl (out of range ioctl) */
-            ret = -EOPNOTSUPP;
-            goto ioctl_done;
-        }
-        userdata = (char *)rq->ifr_data;
-    }
-
-    if ((ar->arWlanState == WLAN_DISABLED) &&
-        ((cmd != AR6000_XIOCTRL_WMI_SET_WLAN_STATE) &&
-         (cmd != AR6000_XIOCTL_GET_WLAN_SLEEP_STATE) &&
-         (cmd != AR6000_XIOCTL_DIAG_READ) &&
-         (cmd != AR6000_XIOCTL_DIAG_WRITE) &&
-         (cmd != AR6000_XIOCTL_SET_BT_HW_POWER_STATE) &&
-         (cmd != AR6000_XIOCTL_GET_BT_HW_POWER_STATE) &&
-         (cmd != AR6000_XIOCTL_ADD_AP_INTERFACE) &&
-         (cmd != AR6000_XIOCTL_REMOVE_AP_INTERFACE) &&
-         (cmd != AR6000_IOCTL_WMI_GETREV)))
-    {
-        ret = -EIO;
-        goto ioctl_done;
-    }
-
-    ret = 0;
-    switch(cmd)
-    {
-        case IEEE80211_IOCTL_SETPARAM:
-        {
-            int param, value;
-            int *ptr = (int *)rq->ifr_ifru.ifru_newname;
-            if (ar->arWmiReady == false) {
-                ret = -EIO;
-            } else {
-                param = *ptr++;
-                value = *ptr;
-                ret = ar6000_ioctl_setparam(ar,param,value);
-            }
-            break;
-        }
-        case IEEE80211_IOCTL_SETKEY:
-        {
-            struct ieee80211req_key keydata;
-            if (ar->arWmiReady == false) {
-                ret = -EIO;
-            } else if (copy_from_user(&keydata, userdata,
-                            sizeof(struct ieee80211req_key))) {
-                ret = -EFAULT;
-            } else {
-                ar6000_ioctl_setkey(ar, &keydata);
-            }
-            break;
-        }
-        case IEEE80211_IOCTL_DELKEY:
-        case IEEE80211_IOCTL_SETOPTIE:
-        {
-            //ret = -EIO;
-            break;
-        }
-        case IEEE80211_IOCTL_SETMLME:
-        {
-            struct ieee80211req_mlme mlme;
-            if (ar->arWmiReady == false) {
-                ret = -EIO;
-            } else if (copy_from_user(&mlme, userdata,
-                            sizeof(struct ieee80211req_mlme))) {
-                ret = -EFAULT;
-            } else {
-                switch (mlme.im_op) {
-                    case IEEE80211_MLME_AUTHORIZE:
-                        A_PRINTF("setmlme AUTHORIZE %02X:%02X\n",
-                            mlme.im_macaddr[4], mlme.im_macaddr[5]);
-                        break;
-                    case IEEE80211_MLME_UNAUTHORIZE:
-                        A_PRINTF("setmlme UNAUTHORIZE %02X:%02X\n",
-                            mlme.im_macaddr[4], mlme.im_macaddr[5]);
-                        break;
-                    case IEEE80211_MLME_DEAUTH:
-                        A_PRINTF("setmlme DEAUTH %02X:%02X\n",
-                            mlme.im_macaddr[4], mlme.im_macaddr[5]);
-                        //remove_sta(ar, mlme.im_macaddr);
-                        break;
-                    case IEEE80211_MLME_DISASSOC:
-                        A_PRINTF("setmlme DISASSOC %02X:%02X\n",
-                            mlme.im_macaddr[4], mlme.im_macaddr[5]);
-                        //remove_sta(ar, mlme.im_macaddr);
-                        break;
-                    default:
-                        ret = 0;
-                        goto ioctl_done;
-                }
-
-                wmi_ap_set_mlme(ar->arWmi, mlme.im_op, mlme.im_macaddr,
-                                mlme.im_reason);
-            }
-            break;
-        }
-        case IEEE80211_IOCTL_ADDPMKID:
-        {
-            struct ieee80211req_addpmkid  req;
-            if (ar->arWmiReady == false) {
-                ret = -EIO;
-            } else if (copy_from_user(&req, userdata, sizeof(struct ieee80211req_addpmkid))) {
-                ret = -EFAULT;
-            } else {
-                int status;
-
-                AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_CONNECT,("Add pmkid for %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x en=%d\n",
-                    req.pi_bssid[0], req.pi_bssid[1], req.pi_bssid[2],
-                    req.pi_bssid[3], req.pi_bssid[4], req.pi_bssid[5],
-                    req.pi_enable));
-
-                status = wmi_setPmkid_cmd(ar->arWmi, req.pi_bssid, req.pi_pmkid,
-                              req.pi_enable);
-
-                if (status) {
-                    ret = -EIO;
-                    goto ioctl_done;
-                }
-            }
-            break;
-        }
-#ifdef CONFIG_HOST_TCMD_SUPPORT
-        case AR6000_XIOCTL_TCMD_CONT_TX:
-            {
-                TCMD_CONT_TX txCmd;
-
-                if ((ar->tcmdPm == TCMD_PM_SLEEP) ||
-                    (ar->tcmdPm == TCMD_PM_DEEPSLEEP))
-                {
-                    A_PRINTF("Can NOT send tx tcmd when target is asleep! \n");
-                    ret = -EFAULT;
-                    goto ioctl_done;
-                }
-
-                if(copy_from_user(&txCmd, userdata, sizeof(TCMD_CONT_TX))) {
-                    ret = -EFAULT;
-                    goto ioctl_done;
-                } else {
-                    wmi_test_cmd(ar->arWmi,(u8 *)&txCmd, sizeof(TCMD_CONT_TX));
-                }
-            }
-            break;
-        case AR6000_XIOCTL_TCMD_CONT_RX:
-            {
-                TCMD_CONT_RX rxCmd;
-
-                if ((ar->tcmdPm == TCMD_PM_SLEEP) ||
-                    (ar->tcmdPm == TCMD_PM_DEEPSLEEP))
-                {
-                    A_PRINTF("Can NOT send rx tcmd when target is asleep! \n");
-                    ret = -EFAULT;
-                    goto ioctl_done;
-                }
-                if(copy_from_user(&rxCmd, userdata, sizeof(TCMD_CONT_RX))) {
-                    ret = -EFAULT;
-                    goto ioctl_done;
-                }
-
-                switch(rxCmd.act)
-                {
-                    case TCMD_CONT_RX_PROMIS:
-                    case TCMD_CONT_RX_FILTER:
-                    case TCMD_CONT_RX_SETMAC:
-                    case TCMD_CONT_RX_SET_ANT_SWITCH_TABLE:
-                         wmi_test_cmd(ar->arWmi,(u8 *)&rxCmd,
-                                                sizeof(TCMD_CONT_RX));
-                         tcmdRxFreq = rxCmd.u.para.freq;
-                         break;
-                    case TCMD_CONT_RX_REPORT:
-                         ar6000_ioctl_tcmd_get_rx_report(dev, rq,
-                         (u8 *)&rxCmd, sizeof(TCMD_CONT_RX));
-                         break;
-                    default:
-                         A_PRINTF("Unknown Cont Rx mode: %d\n",rxCmd.act);
-                         ret = -EINVAL;
-                         goto ioctl_done;
-                }
-            }
-            break;
-        case AR6000_XIOCTL_TCMD_PM:
-            {
-                TCMD_PM pmCmd;
-
-                if(copy_from_user(&pmCmd, userdata, sizeof(TCMD_PM))) {
-                    ret = -EFAULT;
-                    goto ioctl_done;
-                }
-                ar->tcmdPm = pmCmd.mode;
-                wmi_test_cmd(ar->arWmi, (u8 *)&pmCmd, sizeof(TCMD_PM));
-            }
-            break;
-#endif /* CONFIG_HOST_TCMD_SUPPORT */
-
-        case AR6000_XIOCTL_BMI_DONE:
-            if(bmienable)
-            {
-                rtnl_lock(); /* ar6000_init expects to be called holding rtnl lock */
-                ret = ar6000_init(dev);
-                rtnl_unlock();
-            }
-            else
-            {
-                ret = BMIDone(hifDevice);
-            }
-            break;
-
-        case AR6000_XIOCTL_BMI_READ_MEMORY:
-            if (get_user(address, (unsigned int *)userdata) ||
-               get_user(length, (unsigned int *)userdata + 1)) {
-               ret = -EFAULT;
-               break;
-           }
-
-            AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("Read Memory (address: 0x%x, length: %d)\n",
-                             address, length));
-            if ((buffer = (unsigned char *)A_MALLOC(length)) != NULL) {
-                A_MEMZERO(buffer, length);
-                ret = BMIReadMemory(hifDevice, address, buffer, length);
-                if (copy_to_user(rq->ifr_data, buffer, length)) {
-                    ret = -EFAULT;
-                }
-                A_FREE(buffer);
-            } else {
-                ret = -ENOMEM;
-            }
-            break;
-
-        case AR6000_XIOCTL_BMI_WRITE_MEMORY:
-            if (get_user(address, (unsigned int *)userdata) ||
-               get_user(length, (unsigned int *)userdata + 1)) {
-               ret = -EFAULT;
-               break;
-           }
-            AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("Write Memory (address: 0x%x, length: %d)\n",
-                             address, length));
-            if ((buffer = (unsigned char *)A_MALLOC(length)) != NULL) {
-                A_MEMZERO(buffer, length);
-                if (copy_from_user(buffer, &userdata[sizeof(address) +
-                                   sizeof(length)], length))
-                {
-                    ret = -EFAULT;
-                } else {
-                    ret = BMIWriteMemory(hifDevice, address, buffer, length);
-                }
-                A_FREE(buffer);
-            } else {
-                ret = -ENOMEM;
-            }
-            break;
-
-        case AR6000_XIOCTL_BMI_TEST:
-           AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("No longer supported\n"));
-           ret = -EOPNOTSUPP;
-           break;
-
-        case AR6000_XIOCTL_BMI_EXECUTE:
-            if (get_user(address, (unsigned int *)userdata) ||
-               get_user(param, (unsigned int *)userdata + 1)) {
-               ret = -EFAULT;
-               break;
-           }
-            AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("Execute (address: 0x%x, param: %d)\n",
-                             address, param));
-            ret = BMIExecute(hifDevice, address, (u32 *)&param);
-           /* return value */
-           if (put_user(param, (unsigned int *)rq->ifr_data)) {
-               ret = -EFAULT;
-               break;
-           }
-            break;
-
-        case AR6000_XIOCTL_BMI_SET_APP_START:
-           if (get_user(address, (unsigned int *)userdata)) {
-               ret = -EFAULT;
-               break;
-           }
-            AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("Set App Start (address: 0x%x)\n", address));
-            ret = BMISetAppStart(hifDevice, address);
-            break;
-
-        case AR6000_XIOCTL_BMI_READ_SOC_REGISTER:
-           if (get_user(address, (unsigned int *)userdata)) {
-               ret = -EFAULT;
-               break;
-           }
-            ret = BMIReadSOCRegister(hifDevice, address, (u32 *)&param);
-           /* return value */
-           if (put_user(param, (unsigned int *)rq->ifr_data)) {
-               ret = -EFAULT;
-               break;
-           }
-            break;
-
-        case AR6000_XIOCTL_BMI_WRITE_SOC_REGISTER:
-           if (get_user(address, (unsigned int *)userdata) ||
-               get_user(param, (unsigned int *)userdata + 1)) {
-               ret = -EFAULT;
-               break;
-           }
-            ret = BMIWriteSOCRegister(hifDevice, address, param);
-            break;
-
-#ifdef HTC_RAW_INTERFACE
-        case AR6000_XIOCTL_HTC_RAW_OPEN:
-            ret = 0;
-            if (!arRawIfEnabled(ar)) {
-                /* make sure block size is set in case the target was reset since last
-                  * BMI phase (i.e. flashup downloads) */
-                ret = ar6000_set_htc_params(ar->arHifDevice,
-                                            ar->arTargetType,
-                                            0,  /* use default yield */
-                                            0   /* use default number of HTC ctrl buffers */
-                                            );
-                if (ret) {
-                    break;
-                }
-                /* Terminate the BMI phase */
-                ret = BMIDone(hifDevice);
-                if (ret == 0) {
-                    ret = ar6000_htc_raw_open(ar);
-                }
-            }
-            break;
-
-        case AR6000_XIOCTL_HTC_RAW_CLOSE:
-            if (arRawIfEnabled(ar)) {
-                ret = ar6000_htc_raw_close(ar);
-                arRawIfEnabled(ar) = false;
-            } else {
-                ret = A_ERROR;
-            }
-            break;
-
-        case AR6000_XIOCTL_HTC_RAW_READ:
-            if (arRawIfEnabled(ar)) {
-                unsigned int streamID;
-               if (get_user(streamID, (unsigned int *)userdata) ||
-                   get_user(length, (unsigned int *)userdata + 1)) {
-                   ret = -EFAULT;
-                   break;
-               }
-                buffer = (unsigned char*)rq->ifr_data + sizeof(length);
-                ret = ar6000_htc_raw_read(ar, (HTC_RAW_STREAM_ID)streamID,
-                                          (char*)buffer, length);
-               if (put_user(ret, (unsigned int *)rq->ifr_data)) {
-                   ret = -EFAULT;
-                   break;
-               }
-            } else {
-                ret = A_ERROR;
-            }
-            break;
-
-        case AR6000_XIOCTL_HTC_RAW_WRITE:
-            if (arRawIfEnabled(ar)) {
-                unsigned int streamID;
-               if (get_user(streamID, (unsigned int *)userdata) ||
-                   get_user(length, (unsigned int *)userdata + 1)) {
-                   ret = -EFAULT;
-                   break;
-               }
-                buffer = (unsigned char*)userdata + sizeof(streamID) + sizeof(length);
-                ret = ar6000_htc_raw_write(ar, (HTC_RAW_STREAM_ID)streamID,
-                                           (char*)buffer, length);
-               if (put_user(ret, (unsigned int *)rq->ifr_data)) {
-                   ret = -EFAULT;
-                   break;
-               }
-            } else {
-                ret = A_ERROR;
-            }
-            break;
-#endif /* HTC_RAW_INTERFACE */
-
-        case AR6000_XIOCTL_BMI_LZ_STREAM_START:
-           if (get_user(address, (unsigned int *)userdata)) {
-               ret = -EFAULT;
-               break;
-           }
-            AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("Start Compressed Stream (address: 0x%x)\n", address));
-            ret = BMILZStreamStart(hifDevice, address);
-            break;
-
-        case AR6000_XIOCTL_BMI_LZ_DATA:
-           if (get_user(length, (unsigned int *)userdata)) {
-               ret = -EFAULT;
-               break;
-           }
-            AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("Send Compressed Data (length: %d)\n", length));
-            if ((buffer = (unsigned char *)A_MALLOC(length)) != NULL) {
-                A_MEMZERO(buffer, length);
-                if (copy_from_user(buffer, &userdata[sizeof(length)], length))
-                {
-                    ret = -EFAULT;
-                } else {
-                    ret = BMILZData(hifDevice, buffer, length);
-                }
-                A_FREE(buffer);
-            } else {
-                ret = -ENOMEM;
-            }
-            break;
-
-#if defined(CONFIG_TARGET_PROFILE_SUPPORT)
-        /*
-         * Optional support for Target-side profiling.
-         * Not needed in production.
-         */
-
-        /* Configure Target-side profiling */
-        case AR6000_XIOCTL_PROF_CFG:
-        {
-            u32 period;
-            u32 nbins;
-           if (get_user(period, (unsigned int *)userdata) ||
-               get_user(nbins, (unsigned int *)userdata + 1)) {
-               ret = -EFAULT;
-               break;
-           }
-
-            if (wmi_prof_cfg_cmd(ar->arWmi, period, nbins) != 0) {
-                ret = -EIO;
-            }
-
-            break;
-        }
-
-        /* Start a profiling bucket/bin at the specified address */
-        case AR6000_XIOCTL_PROF_ADDR_SET:
-        {
-            u32 addr;
-           if (get_user(addr, (unsigned int *)userdata)) {
-               ret = -EFAULT;
-               break;
-           }
-
-            if (wmi_prof_addr_set_cmd(ar->arWmi, addr) != 0) {
-                ret = -EIO;
-            }
-
-            break;
-        }
-
-        /* START Target-side profiling */
-        case AR6000_XIOCTL_PROF_START:
-            wmi_prof_start_cmd(ar->arWmi);
-            break;
-
-        /* STOP Target-side profiling */
-        case AR6000_XIOCTL_PROF_STOP:
-            wmi_prof_stop_cmd(ar->arWmi);
-            break;
-        case AR6000_XIOCTL_PROF_COUNT_GET:
-        {
-            if (ar->bIsDestroyProgress) {
-                ret = -EBUSY;
-                goto ioctl_done;
-            }
-            if (ar->arWmiReady == false) {
-                ret = -EIO;
-                goto ioctl_done;
-            }
-            if (down_interruptible(&ar->arSem)) {
-                ret = -ERESTARTSYS;
-                goto ioctl_done;
-            }
-            if (ar->bIsDestroyProgress) {
-                up(&ar->arSem);
-                ret = -EBUSY;
-                goto ioctl_done;
-            }
-
-            prof_count_available = false;
-            ret = prof_count_get(dev);
-            if (ret != 0) {
-                up(&ar->arSem);
-                ret = -EIO;
-                goto ioctl_done;
-            }
-
-            /* Wait for Target to respond. */
-            wait_event_interruptible(arEvent, prof_count_available);
-            if (signal_pending(current)) {
-                ret = -EINTR;
-            } else {
-                if (copy_to_user(userdata, &prof_count_results,
-                                 sizeof(prof_count_results)))
-                {
-                    ret = -EFAULT;
-                }
-            }
-            up(&ar->arSem);
-            break;
-        }
-#endif /* CONFIG_TARGET_PROFILE_SUPPORT */
-
-        case AR6000_IOCTL_WMI_GETREV:
-        {
-            if (copy_to_user(rq->ifr_data, &ar->arVersion,
-                             sizeof(ar->arVersion)))
-            {
-                ret = -EFAULT;
-            }
-            break;
-        }
-        case AR6000_IOCTL_WMI_SETPWR:
-        {
-            WMI_POWER_MODE_CMD pwrModeCmd;
-
-            if (ar->arWmiReady == false) {
-                ret = -EIO;
-            } else if (copy_from_user(&pwrModeCmd, userdata,
-                                   sizeof(pwrModeCmd)))
-            {
-                ret = -EFAULT;
-            } else {
-                if (wmi_powermode_cmd(ar->arWmi, pwrModeCmd.powerMode)
-                       != 0)
-                {
-                    ret = -EIO;
-                }
-            }
-            break;
-        }
-        case AR6000_IOCTL_WMI_SET_IBSS_PM_CAPS:
-        {
-            WMI_IBSS_PM_CAPS_CMD ibssPmCaps;
-
-            if (ar->arWmiReady == false) {
-                ret = -EIO;
-            } else if (copy_from_user(&ibssPmCaps, userdata,
-                                   sizeof(ibssPmCaps)))
-            {
-                ret = -EFAULT;
-            } else {
-                if (wmi_ibsspmcaps_cmd(ar->arWmi, ibssPmCaps.power_saving, ibssPmCaps.ttl,
-                    ibssPmCaps.atim_windows, ibssPmCaps.timeout_value) != 0)
-                {
-                    ret = -EIO;
-                }
-                AR6000_SPIN_LOCK(&ar->arLock, 0);
-                ar->arIbssPsEnable = ibssPmCaps.power_saving;
-                AR6000_SPIN_UNLOCK(&ar->arLock, 0);
-            }
-            break;
-        }
-        case AR6000_XIOCTL_WMI_SET_AP_PS:
-        {
-            WMI_AP_PS_CMD apPsCmd;
-
-            if (ar->arWmiReady == false) {
-                ret = -EIO;
-            } else if (copy_from_user(&apPsCmd, userdata,
-                                   sizeof(apPsCmd)))
-            {
-                ret = -EFAULT;
-            } else {
-                if (wmi_apps_cmd(ar->arWmi, apPsCmd.psType, apPsCmd.idle_time,
-                    apPsCmd.ps_period, apPsCmd.sleep_period) != 0)
-                {
-                    ret = -EIO;
-                }
-            }
-            break;
-        }
-        case AR6000_IOCTL_WMI_SET_PMPARAMS:
-        {
-            WMI_POWER_PARAMS_CMD pmParams;
-
-            if (ar->arWmiReady == false) {
-                ret = -EIO;
-            } else if (copy_from_user(&pmParams, userdata,
-                                      sizeof(pmParams)))
-            {
-                ret = -EFAULT;
-            } else {
-                if (wmi_pmparams_cmd(ar->arWmi, pmParams.idle_period,
-                                     pmParams.pspoll_number,
-                                     pmParams.dtim_policy,
-                                     pmParams.tx_wakeup_policy,
-                                     pmParams.num_tx_to_wakeup,
-#if WLAN_CONFIG_IGNORE_POWER_SAVE_FAIL_EVENT_DURING_SCAN
-                                     IGNORE_POWER_SAVE_FAIL_EVENT_DURING_SCAN 
-#else
-                                     SEND_POWER_SAVE_FAIL_EVENT_ALWAYS
-#endif
-                                     ) != 0)
-                {
-                    ret = -EIO;
-                }
-            }
-            break;
-        }
-        case AR6000_IOCTL_WMI_SETSCAN:
-        {
-            if (ar->arWmiReady == false) {
-                ret = -EIO;
-            } else if (copy_from_user(&ar->scParams, userdata,
-                                      sizeof(ar->scParams)))
-            {
-                ret = -EFAULT;
-            } else {
-                if (CAN_SCAN_IN_CONNECT(ar->scParams.scanCtrlFlags)) {
-                    ar->arSkipScan = false;
-                } else {
-                    ar->arSkipScan = true;
-                }
-
-                if (wmi_scanparams_cmd(ar->arWmi, ar->scParams.fg_start_period,
-                                       ar->scParams.fg_end_period,
-                                       ar->scParams.bg_period,
-                                       ar->scParams.minact_chdwell_time,
-                                       ar->scParams.maxact_chdwell_time,
-                                       ar->scParams.pas_chdwell_time,
-                                       ar->scParams.shortScanRatio,
-                                       ar->scParams.scanCtrlFlags,
-                                       ar->scParams.max_dfsch_act_time,
-                                       ar->scParams.maxact_scan_per_ssid) != 0)
-                {
-                    ret = -EIO;
-                }
-            }
-            break;
-        }
-        case AR6000_IOCTL_WMI_SETLISTENINT:
-        {
-            WMI_LISTEN_INT_CMD listenCmd;
-
-            if (ar->arWmiReady == false) {
-                ret = -EIO;
-            } else if (copy_from_user(&listenCmd, userdata,
-                                      sizeof(listenCmd)))
-            {
-                ret = -EFAULT;
-            } else {
-                    if (wmi_listeninterval_cmd(ar->arWmi, listenCmd.listenInterval, listenCmd.numBeacons) != 0) {
-                        ret = -EIO;
-                    } else {
-                        AR6000_SPIN_LOCK(&ar->arLock, 0);
-                        ar->arListenIntervalT = listenCmd.listenInterval;
-                        ar->arListenIntervalB = listenCmd.numBeacons;
-                        AR6000_SPIN_UNLOCK(&ar->arLock, 0);
-                    }
-
-                }
-            break;
-        }
-        case AR6000_IOCTL_WMI_SET_BMISS_TIME:
-        {
-            WMI_BMISS_TIME_CMD bmissCmd;
-
-            if (ar->arWmiReady == false) {
-                ret = -EIO;
-            } else if (copy_from_user(&bmissCmd, userdata,
-                                      sizeof(bmissCmd)))
-            {
-                ret = -EFAULT;
-            } else {
-                if (wmi_bmisstime_cmd(ar->arWmi, bmissCmd.bmissTime, bmissCmd.numBeacons) != 0) {
-                    ret = -EIO;
-                }
-            }
-            break;
-        }
-        case AR6000_IOCTL_WMI_SETBSSFILTER:
-        {
-            WMI_BSS_FILTER_CMD filt;
-
-            if (ar->arWmiReady == false) {
-                ret = -EIO;
-            } else if (copy_from_user(&filt, userdata,
-                                   sizeof(filt)))
-            {
-                ret = -EFAULT;
-            } else {
-                if (wmi_bssfilter_cmd(ar->arWmi, filt.bssFilter, filt.ieMask)
-                        != 0) {
-                    ret = -EIO;
-                } else {
-                    ar->arUserBssFilter = filt.bssFilter;
-                }
-            }
-            break;
-        }
-
-        case AR6000_IOCTL_WMI_SET_SNRTHRESHOLD:
-        {
-            ret = ar6000_ioctl_set_snr_threshold(dev, rq);
-            break;
-        }
-        case AR6000_XIOCTL_WMI_SET_RSSITHRESHOLD:
-        {
-            ret = ar6000_ioctl_set_rssi_threshold(dev, rq);
-            break;
-        }
-        case AR6000_XIOCTL_WMI_CLR_RSSISNR:
-        {
-            if (ar->arWmiReady == false) {
-                ret = -EIO;
-            }
-            ret = wmi_clr_rssi_snr(ar->arWmi);
-            break;
-        }
-        case AR6000_XIOCTL_WMI_SET_LQTHRESHOLD:
-        {
-            ret = ar6000_ioctl_set_lq_threshold(dev, rq);
-            break;
-        }
-        case AR6000_XIOCTL_WMI_SET_LPREAMBLE:
-        {
-            WMI_SET_LPREAMBLE_CMD setLpreambleCmd;
-
-            if (ar->arWmiReady == false) {
-                ret = -EIO;
-            } else if (copy_from_user(&setLpreambleCmd, userdata,
-                                   sizeof(setLpreambleCmd)))
-            {
-                ret = -EFAULT;
-            } else {
-                if (wmi_set_lpreamble_cmd(ar->arWmi, setLpreambleCmd.status,
-#if WLAN_CONFIG_DONOT_IGNORE_BARKER_IN_ERP 
-                           WMI_DONOT_IGNORE_BARKER_IN_ERP
-#else
-                           WMI_IGNORE_BARKER_IN_ERP
-#endif
-                ) != 0)
-                {
-                    ret = -EIO;
-                }
-            }
-
-            break;
-        }
-        case AR6000_XIOCTL_WMI_SET_RTS:
-        {
-            WMI_SET_RTS_CMD rtsCmd;
-            if (ar->arWmiReady == false) {
-                ret = -EIO;
-            } else if (copy_from_user(&rtsCmd, userdata,
-                                   sizeof(rtsCmd)))
-            {
-                ret = -EFAULT;
-            } else {
-                ar->arRTS = rtsCmd.threshold;
-                if (wmi_set_rts_cmd(ar->arWmi, rtsCmd.threshold)
-                       != 0)
-                {
-                    ret = -EIO;
-                }
-            }
-
-            break;
-        }
-        case AR6000_XIOCTL_WMI_SET_WMM:
-        {
-            ret = ar6000_ioctl_set_wmm(dev, rq);
-            break;
-        }
-       case AR6000_XIOCTL_WMI_SET_QOS_SUPP:
-        {
-            ret = ar6000_ioctl_set_qos_supp(dev, rq);
-            break;
-        }
-        case AR6000_XIOCTL_WMI_SET_TXOP:
-        {
-            ret = ar6000_ioctl_set_txop(dev, rq);
-            break;
-        }
-        case AR6000_XIOCTL_WMI_GET_RD:
-        {
-            ret = ar6000_ioctl_get_rd(dev, rq);
-            break;
-        }
-        case AR6000_IOCTL_WMI_SET_CHANNELPARAMS:
-        {
-            ret = ar6000_ioctl_set_channelParams(dev, rq);
-            break;
-        }
-        case AR6000_IOCTL_WMI_SET_PROBEDSSID:
-        {
-            ret = ar6000_ioctl_set_probedSsid(dev, rq);
-            break;
-        }
-        case AR6000_IOCTL_WMI_SET_BADAP:
-        {
-            ret = ar6000_ioctl_set_badAp(dev, rq);
-            break;
-        }
-        case AR6000_IOCTL_WMI_CREATE_QOS:
-        {
-            ret = ar6000_ioctl_create_qos(dev, rq);
-            break;
-        }
-        case AR6000_IOCTL_WMI_DELETE_QOS:
-        {
-            ret = ar6000_ioctl_delete_qos(dev, rq);
-            break;
-        }
-        case AR6000_IOCTL_WMI_GET_QOS_QUEUE:
-        {
-            ret = ar6000_ioctl_get_qos_queue(dev, rq);
-            break;
-        }
-        case AR6000_IOCTL_WMI_GET_TARGET_STATS:
-        {
-            ret = ar6000_ioctl_get_target_stats(dev, rq);
-            break;
-        }
-        case AR6000_IOCTL_WMI_SET_ERROR_REPORT_BITMASK:
-        {
-            ret = ar6000_ioctl_set_error_report_bitmask(dev, rq);
-            break;
-        }
-        case AR6000_IOCTL_WMI_SET_ASSOC_INFO:
-        {
-            WMI_SET_ASSOC_INFO_CMD cmd;
-            u8 assocInfo[WMI_MAX_ASSOC_INFO_LEN];
-
-            if (ar->arWmiReady == false) {
-                ret = -EIO;
-               break;
-           }
-
-           if (get_user(cmd.ieType, userdata)) {
-               ret = -EFAULT;
-               break;
-           }
-           if (cmd.ieType >= WMI_MAX_ASSOC_INFO_TYPE) {
-               ret = -EIO;
-               break;
-           }
-
-           if (get_user(cmd.bufferSize, userdata + 1) ||
-               (cmd.bufferSize > WMI_MAX_ASSOC_INFO_LEN) ||
-               copy_from_user(assocInfo, userdata + 2, cmd.bufferSize)) {
-               ret = -EFAULT;
-               break;
-           }
-           if (wmi_associnfo_cmd(ar->arWmi, cmd.ieType,
-                                 cmd.bufferSize, assocInfo) != 0) {
-               ret = -EIO;
-               break;
-           }
-            break;
-        }
-        case AR6000_IOCTL_WMI_SET_ACCESS_PARAMS:
-        {
-            ret = ar6000_ioctl_set_access_params(dev, rq);
-            break;
-        }
-        case AR6000_IOCTL_WMI_SET_DISC_TIMEOUT:
-        {
-            ret = ar6000_ioctl_set_disconnect_timeout(dev, rq);
-            break;
-        }
-        case AR6000_XIOCTL_FORCE_TARGET_RESET:
-        {
-            if (ar->arHtcTarget)
-            {
-//                HTCForceReset(htcTarget);
-            }
-            else
-            {
-                AR_DEBUG_PRINTF(ATH_DEBUG_WARN,("ar6000_ioctl cannot attempt reset.\n"));
-            }
-            break;
-        }
-        case AR6000_XIOCTL_TARGET_INFO:
-        case AR6000_XIOCTL_CHECK_TARGET_READY: /* backwards compatibility */
-        {
-            /* If we made it to here, then the Target exists and is ready. */
-
-            if (cmd == AR6000_XIOCTL_TARGET_INFO) {
-                if (copy_to_user((u32 *)rq->ifr_data, &ar->arVersion.target_ver,
-                                 sizeof(ar->arVersion.target_ver)))
-                {
-                    ret = -EFAULT;
-                }
-                if (copy_to_user(((u32 *)rq->ifr_data)+1, &ar->arTargetType,
-                                 sizeof(ar->arTargetType)))
-                {
-                    ret = -EFAULT;
-                }
-            }
-            break;
-        }
-        case AR6000_XIOCTL_WMI_SET_HB_CHALLENGE_RESP_PARAMS:
-        {
-            WMI_SET_HB_CHALLENGE_RESP_PARAMS_CMD hbparam;
-
-            if (copy_from_user(&hbparam, userdata, sizeof(hbparam)))
-            {
-                ret = -EFAULT;
-            } else {
-                AR6000_SPIN_LOCK(&ar->arLock, 0);
-                /* Start a cyclic timer with the parameters provided. */
-                if (hbparam.frequency) {
-                    ar->arHBChallengeResp.frequency = hbparam.frequency;
-                }
-                if (hbparam.threshold) {
-                    ar->arHBChallengeResp.missThres = hbparam.threshold;
-                }
-
-                /* Delete the pending timer and start a new one */
-                if (timer_pending(&ar->arHBChallengeResp.timer)) {
-                    A_UNTIMEOUT(&ar->arHBChallengeResp.timer);
-                }
-                A_TIMEOUT_MS(&ar->arHBChallengeResp.timer, ar->arHBChallengeResp.frequency * 1000, 0);
-                AR6000_SPIN_UNLOCK(&ar->arLock, 0);
-            }
-            break;
-        }
-        case AR6000_XIOCTL_WMI_GET_HB_CHALLENGE_RESP:
-        {
-            u32 cookie;
-
-            if (copy_from_user(&cookie, userdata, sizeof(cookie))) {
-                ret = -EFAULT;
-                goto ioctl_done;
-            }
-
-            /* Send the challenge on the control channel */
-            if (wmi_get_challenge_resp_cmd(ar->arWmi, cookie, APP_HB_CHALLENGE) != 0) {
-                ret = -EIO;
-                goto ioctl_done;
-            }
-            break;
-        }
-#ifdef USER_KEYS
-        case AR6000_XIOCTL_USER_SETKEYS:
-        {
-
-            ar->user_savedkeys_stat = USER_SAVEDKEYS_STAT_RUN;
-
-            if (copy_from_user(&ar->user_key_ctrl, userdata,
-                               sizeof(ar->user_key_ctrl)))
-            {
-                ret = -EFAULT;
-                goto ioctl_done;
-            }
-
-            A_PRINTF("ar6000 USER set key %x\n", ar->user_key_ctrl);
-            break;
-        }
-#endif /* USER_KEYS */
-
-#ifdef CONFIG_HOST_GPIO_SUPPORT
-        case AR6000_XIOCTL_GPIO_OUTPUT_SET:
-        {
-            struct ar6000_gpio_output_set_cmd_s gpio_output_set_cmd;
-
-            if (ar->bIsDestroyProgress) {
-                ret = -EBUSY;
-                goto ioctl_done;
-            }
-            if (ar->arWmiReady == false) {
-                ret = -EIO;
-                goto ioctl_done;
-            }
-            if (down_interruptible(&ar->arSem)) {
-                ret = -ERESTARTSYS;
-                goto ioctl_done;
-            }
-            if (ar->bIsDestroyProgress) {
-                up(&ar->arSem);
-                ret = -EBUSY;
-                goto ioctl_done;
-            }
-
-            if (copy_from_user(&gpio_output_set_cmd, userdata,
-                                sizeof(gpio_output_set_cmd)))
-            {
-                ret = -EFAULT;
-            } else {
-                ret = ar6000_gpio_output_set(dev,
-                                             gpio_output_set_cmd.set_mask,
-                                             gpio_output_set_cmd.clear_mask,
-                                             gpio_output_set_cmd.enable_mask,
-                                             gpio_output_set_cmd.disable_mask);
-                if (ret != 0) {
-                    ret = -EIO;
-                }
-            }
-            up(&ar->arSem);
-            break;
-        }
-        case AR6000_XIOCTL_GPIO_INPUT_GET:
-        {
-            if (ar->bIsDestroyProgress) {
-                ret = -EBUSY;
-                goto ioctl_done;
-            }
-            if (ar->arWmiReady == false) {
-                ret = -EIO;
-                goto ioctl_done;
-            }
-            if (down_interruptible(&ar->arSem)) {
-                ret = -ERESTARTSYS;
-                goto ioctl_done;
-            }
-            if (ar->bIsDestroyProgress) {
-                up(&ar->arSem);
-                ret = -EBUSY;
-                goto ioctl_done;
-            }
-
-            ret = ar6000_gpio_input_get(dev);
-            if (ret != 0) {
-                up(&ar->arSem);
-                ret = -EIO;
-                goto ioctl_done;
-            }
-
-            /* Wait for Target to respond. */
-            wait_event_interruptible(arEvent, gpio_data_available);
-            if (signal_pending(current)) {
-                ret = -EINTR;
-            } else {
-                A_ASSERT(gpio_reg_results.gpioreg_id == GPIO_ID_NONE);
-
-                if (copy_to_user(userdata, &gpio_reg_results.value,
-                                 sizeof(gpio_reg_results.value)))
-                {
-                    ret = -EFAULT;
-                }
-            }
-            up(&ar->arSem);
-            break;
-        }
-        case AR6000_XIOCTL_GPIO_REGISTER_SET:
-        {
-            struct ar6000_gpio_register_cmd_s gpio_register_cmd;
-
-            if (ar->bIsDestroyProgress) {
-                ret = -EBUSY;
-                goto ioctl_done;
-            }
-            if (ar->arWmiReady == false) {
-                ret = -EIO;
-                goto ioctl_done;
-            }
-            if (down_interruptible(&ar->arSem)) {
-                ret = -ERESTARTSYS;
-                goto ioctl_done;
-            }
-            if (ar->bIsDestroyProgress) {
-                up(&ar->arSem);
-                ret = -EBUSY;
-                goto ioctl_done;
-            }
-
-            if (copy_from_user(&gpio_register_cmd, userdata,
-                                sizeof(gpio_register_cmd)))
-            {
-                ret = -EFAULT;
-            } else {
-                ret = ar6000_gpio_register_set(dev,
-                                               gpio_register_cmd.gpioreg_id,
-                                               gpio_register_cmd.value);
-                if (ret != 0) {
-                    ret = -EIO;
-                }
-
-                /* Wait for acknowledgement from Target */
-                wait_event_interruptible(arEvent, gpio_ack_received);
-                if (signal_pending(current)) {
-                    ret = -EINTR;
-                }
-            }
-            up(&ar->arSem);
-            break;
-        }
-        case AR6000_XIOCTL_GPIO_REGISTER_GET:
-        {
-            struct ar6000_gpio_register_cmd_s gpio_register_cmd;
-
-            if (ar->bIsDestroyProgress) {
-                ret = -EBUSY;
-                goto ioctl_done;
-            }
-            if (ar->arWmiReady == false) {
-                ret = -EIO;
-                goto ioctl_done;
-            }
-            if (down_interruptible(&ar->arSem)) {
-                ret = -ERESTARTSYS;
-                goto ioctl_done;
-            }
-            if (ar->bIsDestroyProgress) {
-                up(&ar->arSem);
-                ret = -EBUSY;
-                goto ioctl_done;
-            }
-
-            if (copy_from_user(&gpio_register_cmd, userdata,
-                                sizeof(gpio_register_cmd)))
-            {
-                ret = -EFAULT;
-            } else {
-                ret = ar6000_gpio_register_get(dev, gpio_register_cmd.gpioreg_id);
-                if (ret != 0) {
-                    up(&ar->arSem);
-                    ret = -EIO;
-                    goto ioctl_done;
-                }
-
-                /* Wait for Target to respond. */
-                wait_event_interruptible(arEvent, gpio_data_available);
-                if (signal_pending(current)) {
-                    ret = -EINTR;
-                } else {
-                    A_ASSERT(gpio_register_cmd.gpioreg_id == gpio_reg_results.gpioreg_id);
-                    if (copy_to_user(userdata, &gpio_reg_results,
-                                     sizeof(gpio_reg_results)))
-                    {
-                        ret = -EFAULT;
-                    }
-                }
-            }
-            up(&ar->arSem);
-            break;
-        }
-        case AR6000_XIOCTL_GPIO_INTR_ACK:
-        {
-            struct ar6000_gpio_intr_ack_cmd_s gpio_intr_ack_cmd;
-
-            if (ar->bIsDestroyProgress) {
-                ret = -EBUSY;
-                goto ioctl_done;
-            }
-            if (ar->arWmiReady == false) {
-                ret = -EIO;
-                goto ioctl_done;
-            }
-            if (down_interruptible(&ar->arSem)) {
-                ret = -ERESTARTSYS;
-                goto ioctl_done;
-            }
-            if (ar->bIsDestroyProgress) {
-                up(&ar->arSem);
-                ret = -EBUSY;
-                goto ioctl_done;
-            }
-
-            if (copy_from_user(&gpio_intr_ack_cmd, userdata,
-                                sizeof(gpio_intr_ack_cmd)))
-            {
-                ret = -EFAULT;
-            } else {
-                ret = ar6000_gpio_intr_ack(dev, gpio_intr_ack_cmd.ack_mask);
-                if (ret != 0) {
-                    ret = -EIO;
-                }
-            }
-            up(&ar->arSem);
-            break;
-        }
-        case AR6000_XIOCTL_GPIO_INTR_WAIT:
-        {
-            /* Wait for Target to report an interrupt. */
-            wait_event_interruptible(arEvent, gpio_intr_available);
-
-            if (signal_pending(current)) {
-                ret = -EINTR;
-            } else {
-                if (copy_to_user(userdata, &gpio_intr_results,
-                                 sizeof(gpio_intr_results)))
-                {
-                    ret = -EFAULT;
-                }
-            }
-            break;
-        }
-#endif /* CONFIG_HOST_GPIO_SUPPORT */
-
-        case AR6000_XIOCTL_DBGLOG_CFG_MODULE:
-        {
-            struct ar6000_dbglog_module_config_s config;
-
-            if (copy_from_user(&config, userdata, sizeof(config))) {
-                ret = -EFAULT;
-                goto ioctl_done;
-            }
-
-            /* Send the challenge on the control channel */
-            if (wmi_config_debug_module_cmd(ar->arWmi, config.mmask,
-                                            config.tsr, config.rep,
-                                            config.size, config.valid) != 0)
-            {
-                ret = -EIO;
-                goto ioctl_done;
-            }
-            break;
-        }
-
-        case AR6000_XIOCTL_DBGLOG_GET_DEBUG_LOGS:
-        {
-            /* Send the challenge on the control channel */
-            if (ar6000_dbglog_get_debug_logs(ar) != 0)
-            {
-                ret = -EIO;
-                goto ioctl_done;
-            }
-            break;
-        }
-
-        case AR6000_XIOCTL_SET_ADHOC_BSSID:
-        {
-            WMI_SET_ADHOC_BSSID_CMD adhocBssid;
-
-            if (ar->arWmiReady == false) {
-                ret = -EIO;
-            } else if (copy_from_user(&adhocBssid, userdata,
-                                      sizeof(adhocBssid)))
-            {
-                ret = -EFAULT;
-            } else if (memcmp(adhocBssid.bssid, bcast_mac,
-                                AR6000_ETH_ADDR_LEN) == 0)
-            {
-                ret = -EFAULT;
-            } else {
-
-                memcpy(ar->arReqBssid, adhocBssid.bssid, sizeof(ar->arReqBssid));
-        }
-            break;
-        }
-
-        case AR6000_XIOCTL_SET_OPT_MODE:
-        {
-        WMI_SET_OPT_MODE_CMD optModeCmd;
-            struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-
-            if (ar->arWmiReady == false) {
-                ret = -EIO;
-            } else if (copy_from_user(&optModeCmd, userdata,
-                                      sizeof(optModeCmd)))
-            {
-                ret = -EFAULT;
-            } else if (ar->arConnected && optModeCmd.optMode == SPECIAL_ON) {
-                ret = -EFAULT;
-
-            } else if (wmi_set_opt_mode_cmd(ar->arWmi, optModeCmd.optMode)
-                       != 0)
-            {
-                ret = -EIO;
-            }
-            break;
-        }
-
-        case AR6000_XIOCTL_OPT_SEND_FRAME:
-        {
-            WMI_OPT_TX_FRAME_CMD optTxFrmCmd;
-            u8 data[MAX_OPT_DATA_LEN];
-
-            if (ar->arWmiReady == false) {
-                ret = -EIO;
-                break;
-            }
-
-            if (copy_from_user(&optTxFrmCmd, userdata, sizeof(optTxFrmCmd))) {
-                ret = -EFAULT;
-                break;
-            }
-
-            if (optTxFrmCmd.optIEDataLen > MAX_OPT_DATA_LEN) {
-                ret = -EINVAL;
-                break;
-            }
-
-            if (copy_from_user(data, userdata+sizeof(WMI_OPT_TX_FRAME_CMD) - 1,
-                                   optTxFrmCmd.optIEDataLen)) {
-                ret = -EFAULT;
-                break;
-            }
-
-            ret = wmi_opt_tx_frame_cmd(ar->arWmi,
-                                           optTxFrmCmd.frmType,
-                                           optTxFrmCmd.dstAddr,
-                                           optTxFrmCmd.bssid,
-                                           optTxFrmCmd.optIEDataLen,
-                                           data);
-            break;
-        }
-        case AR6000_XIOCTL_WMI_SETRETRYLIMITS:
-        {
-            WMI_SET_RETRY_LIMITS_CMD setRetryParams;
-
-            if (ar->arWmiReady == false) {
-                ret = -EIO;
-            } else if (copy_from_user(&setRetryParams, userdata,
-                                      sizeof(setRetryParams)))
-            {
-                ret = -EFAULT;
-            } else {
-                if (wmi_set_retry_limits_cmd(ar->arWmi, setRetryParams.frameType,
-                                          setRetryParams.trafficClass,
-                                          setRetryParams.maxRetries,
-                                          setRetryParams.enableNotify) != 0)
-                {
-                    ret = -EIO;
-                }
-                AR6000_SPIN_LOCK(&ar->arLock, 0);
-                ar->arMaxRetries = setRetryParams.maxRetries;
-                AR6000_SPIN_UNLOCK(&ar->arLock, 0);
-            }
-            break;
-        }
-
-        case AR6000_XIOCTL_SET_BEACON_INTVAL:
-        {
-            WMI_BEACON_INT_CMD bIntvlCmd;
-
-            if (ar->arWmiReady == false) {
-                ret = -EIO;
-            } else if (copy_from_user(&bIntvlCmd, userdata,
-                       sizeof(bIntvlCmd)))
-            {
-                ret = -EFAULT;
-            } else if (wmi_set_adhoc_bconIntvl_cmd(ar->arWmi, bIntvlCmd.beaconInterval)
-                        != 0)
-            {
-                ret = -EIO;
-            }
-            if(ret == 0) {
-                ar->ap_beacon_interval = bIntvlCmd.beaconInterval;
-                ar->ap_profile_flag = 1; /* There is a change in profile */
-            }
-            break;
-        }
-        case IEEE80211_IOCTL_SETAUTHALG:
-        {
-            struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-            struct ieee80211req_authalg req;
-
-            if (ar->arWmiReady == false) {
-                ret = -EIO;
-            } else if (copy_from_user(&req, userdata,
-                       sizeof(struct ieee80211req_authalg)))
-            {
-                ret = -EFAULT;
-            } else {
-                if (req.auth_alg & AUTH_ALG_OPEN_SYSTEM) {
-                    ar->arDot11AuthMode  |= OPEN_AUTH;
-                    ar->arPairwiseCrypto  = NONE_CRYPT;
-                    ar->arGroupCrypto     = NONE_CRYPT;
-                }
-                if (req.auth_alg & AUTH_ALG_SHARED_KEY) {
-                    ar->arDot11AuthMode  |= SHARED_AUTH;
-                    ar->arPairwiseCrypto  = WEP_CRYPT;
-                    ar->arGroupCrypto     = WEP_CRYPT;
-                    ar->arAuthMode        = NONE_AUTH;
-                }
-                if (req.auth_alg == AUTH_ALG_LEAP) {
-                    ar->arDot11AuthMode   = LEAP_AUTH;
-                }
-            }
-            break;
-        }
-
-        case AR6000_XIOCTL_SET_VOICE_PKT_SIZE:
-            ret = ar6000_xioctl_set_voice_pkt_size(dev, userdata);
-            break;
-
-        case AR6000_XIOCTL_SET_MAX_SP:
-            ret = ar6000_xioctl_set_max_sp_len(dev, userdata);
-            break;
-
-        case AR6000_XIOCTL_WMI_GET_ROAM_TBL:
-            ret = ar6000_ioctl_get_roam_tbl(dev, rq);
-            break;
-        case AR6000_XIOCTL_WMI_SET_ROAM_CTRL:
-            ret = ar6000_ioctl_set_roam_ctrl(dev, userdata);
-            break;
-        case AR6000_XIOCTRL_WMI_SET_POWERSAVE_TIMERS:
-            ret = ar6000_ioctl_set_powersave_timers(dev, userdata);
-            break;
-        case AR6000_XIOCTRL_WMI_GET_POWER_MODE:
-            ret = ar6000_ioctl_get_power_mode(dev, rq);
-            break;
-        case AR6000_XIOCTRL_WMI_SET_WLAN_STATE:
-        {
-            AR6000_WLAN_STATE state;
-           if (get_user(state, (unsigned int *)userdata))
-               ret = -EFAULT;
-           else if (ar6000_set_wlan_state(ar, state) != 0)
-                ret = -EIO;
-            break;
-        }
-        case AR6000_XIOCTL_WMI_GET_ROAM_DATA:
-            ret = ar6000_ioctl_get_roam_data(dev, rq);
-            break;
-
-        case AR6000_XIOCTL_WMI_SET_BT_STATUS:
-            ret = ar6000_xioctl_set_bt_status_cmd(dev, userdata);
-            break;
-
-        case AR6000_XIOCTL_WMI_SET_BT_PARAMS:
-            ret = ar6000_xioctl_set_bt_params_cmd(dev, userdata);
-            break;
-
-               case AR6000_XIOCTL_WMI_SET_BTCOEX_FE_ANT:
-                       ret = ar6000_xioctl_set_btcoex_fe_ant_cmd(dev, userdata);
-                       break;
-
-               case AR6000_XIOCTL_WMI_SET_BTCOEX_COLOCATED_BT_DEV:
-                       ret = ar6000_xioctl_set_btcoex_colocated_bt_dev_cmd(dev, userdata);
-                       break;
-
-               case AR6000_XIOCTL_WMI_SET_BTCOEX_BTINQUIRY_PAGE_CONFIG:
-                       ret = ar6000_xioctl_set_btcoex_btinquiry_page_config_cmd(dev, userdata);
-                       break;
-
-               case AR6000_XIOCTL_WMI_SET_BTCOEX_SCO_CONFIG:
-                       ret = ar6000_xioctl_set_btcoex_sco_config_cmd( dev, userdata);
-                       break;
-
-               case AR6000_XIOCTL_WMI_SET_BTCOEX_A2DP_CONFIG:
-                       ret = ar6000_xioctl_set_btcoex_a2dp_config_cmd(dev, userdata);
-                       break;
-
-               case AR6000_XIOCTL_WMI_SET_BTCOEX_ACLCOEX_CONFIG:
-                       ret = ar6000_xioctl_set_btcoex_aclcoex_config_cmd(dev, userdata);
-                       break;
-
-               case AR6000_XIOCTL_WMI_SET_BTCOEX_DEBUG:
-                       ret = ar60000_xioctl_set_btcoex_debug_cmd(dev, userdata);
-                       break;
-
-               case AR6000_XIOCTL_WMI_SET_BT_OPERATING_STATUS:
-                       ret = ar6000_xioctl_set_btcoex_bt_operating_status_cmd(dev, userdata);
-                       break;
-
-               case AR6000_XIOCTL_WMI_GET_BTCOEX_CONFIG:
-                       ret = ar6000_xioctl_get_btcoex_config_cmd(dev, userdata, rq);
-                       break;
-
-               case AR6000_XIOCTL_WMI_GET_BTCOEX_STATS:
-                       ret = ar6000_xioctl_get_btcoex_stats_cmd(dev, userdata, rq);
-                       break;
-
-        case AR6000_XIOCTL_WMI_STARTSCAN:
-        {
-            WMI_START_SCAN_CMD setStartScanCmd, *cmdp;
-
-            if (ar->arWmiReady == false) {
-                    ret = -EIO;
-                } else if (copy_from_user(&setStartScanCmd, userdata,
-                                          sizeof(setStartScanCmd)))
-                {
-                    ret = -EFAULT;
-                } else {
-                    if (setStartScanCmd.numChannels > 1) {
-                        cmdp = A_MALLOC(130);
-                        if (copy_from_user(cmdp, userdata,
-                                           sizeof (*cmdp) +
-                                           ((setStartScanCmd.numChannels - 1) *
-                                           sizeof(u16))))
-                        {
-                            kfree(cmdp);
-                            ret = -EFAULT;
-                            goto ioctl_done;
-                        }
-                    } else {
-                        cmdp = &setStartScanCmd;
-                    }
-
-                    if (wmi_startscan_cmd(ar->arWmi, cmdp->scanType,
-                                          cmdp->forceFgScan,
-                                          cmdp->isLegacy,
-                                          cmdp->homeDwellTime,
-                                          cmdp->forceScanInterval,
-                                          cmdp->numChannels,
-                                          cmdp->channelList) != 0)
-                    {
-                        ret = -EIO;
-                    }
-                }
-            break;
-        }
-        case AR6000_XIOCTL_WMI_SETFIXRATES:
-        {
-            WMI_FIX_RATES_CMD setFixRatesCmd;
-            int returnStatus;
-
-            if (ar->arWmiReady == false) {
-                    ret = -EIO;
-                } else if (copy_from_user(&setFixRatesCmd, userdata,
-                                          sizeof(setFixRatesCmd)))
-                {
-                    ret = -EFAULT;
-                } else {
-                    returnStatus = wmi_set_fixrates_cmd(ar->arWmi, setFixRatesCmd.fixRateMask);
-                    if (returnStatus == A_EINVAL) {
-                        ret = -EINVAL;
-                    } else if(returnStatus != 0) {
-                        ret = -EIO;
-                    } else {
-                        ar->ap_profile_flag = 1; /* There is a change in profile */
-                    }
-                }
-            break;
-        }
-
-        case AR6000_XIOCTL_WMI_GETFIXRATES:
-        {
-            WMI_FIX_RATES_CMD getFixRatesCmd;
-            struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-            int ret = 0;
-
-            if (ar->bIsDestroyProgress) {
-                ret = -EBUSY;
-                goto ioctl_done;
-            }
-            if (ar->arWmiReady == false) {
-                ret = -EIO;
-                goto ioctl_done;
-            }
-
-            if (down_interruptible(&ar->arSem)) {
-                ret = -ERESTARTSYS;
-                goto ioctl_done;
-            }
-            if (ar->bIsDestroyProgress) {
-                up(&ar->arSem);
-                ret = -EBUSY;
-                goto ioctl_done;
-            }
-            /* Used copy_from_user/copy_to_user to access user space data */
-            if (copy_from_user(&getFixRatesCmd, userdata, sizeof(getFixRatesCmd))) {
-                ret = -EFAULT;
-            } else {
-                ar->arRateMask = 0xFFFFFFFF;
-
-                if (wmi_get_ratemask_cmd(ar->arWmi) != 0) {
-                    up(&ar->arSem);
-                    ret = -EIO;
-                    goto ioctl_done;
-                }
-
-                wait_event_interruptible_timeout(arEvent, ar->arRateMask != 0xFFFFFFFF, wmitimeout * HZ);
-
-                if (signal_pending(current)) {
-                    ret = -EINTR;
-                }
-
-                if (!ret) {
-                    getFixRatesCmd.fixRateMask = ar->arRateMask;
-                }
-
-                if(copy_to_user(userdata, &getFixRatesCmd, sizeof(getFixRatesCmd))) {
-                   ret = -EFAULT;
-                }
-
-                up(&ar->arSem);
-            }
-            break;
-        }
-        case AR6000_XIOCTL_WMI_SET_AUTHMODE:
-        {
-            WMI_SET_AUTH_MODE_CMD setAuthMode;
-
-            if (ar->arWmiReady == false) {
-                ret = -EIO;
-            } else if (copy_from_user(&setAuthMode, userdata,
-                                      sizeof(setAuthMode)))
-            {
-                ret = -EFAULT;
-            } else {
-                if (wmi_set_authmode_cmd(ar->arWmi, setAuthMode.mode) != 0)
-                {
-                    ret = -EIO;
-                }
-            }
-            break;
-        }
-        case AR6000_XIOCTL_WMI_SET_REASSOCMODE:
-        {
-            WMI_SET_REASSOC_MODE_CMD setReassocMode;
-
-            if (ar->arWmiReady == false) {
-                ret = -EIO;
-            } else if (copy_from_user(&setReassocMode, userdata,
-                                      sizeof(setReassocMode)))
-            {
-                ret = -EFAULT;
-            } else {
-                if (wmi_set_reassocmode_cmd(ar->arWmi, setReassocMode.mode) != 0)
-                {
-                    ret = -EIO;
-                }
-            }
-            break;
-        }
-        case AR6000_XIOCTL_DIAG_READ:
-        {
-            u32 addr, data;
-           if (get_user(addr, (unsigned int *)userdata)) {
-               ret = -EFAULT;
-               break;
-           }
-            addr = TARG_VTOP(ar->arTargetType, addr);
-            if (ar6000_ReadRegDiag(ar->arHifDevice, &addr, &data) != 0) {
-                ret = -EIO;
-            }
-           if (put_user(data, (unsigned int *)userdata + 1)) {
-               ret = -EFAULT;
-               break;
-           }
-            break;
-        }
-        case AR6000_XIOCTL_DIAG_WRITE:
-        {
-            u32 addr, data;
-           if (get_user(addr, (unsigned int *)userdata) ||
-               get_user(data, (unsigned int *)userdata + 1)) {
-               ret = -EFAULT;
-               break;
-           }
-            addr = TARG_VTOP(ar->arTargetType, addr);
-            if (ar6000_WriteRegDiag(ar->arHifDevice, &addr, &data) != 0) {
-                ret = -EIO;
-            }
-            break;
-        }
-        case AR6000_XIOCTL_WMI_SET_KEEPALIVE:
-        {
-             WMI_SET_KEEPALIVE_CMD setKeepAlive;
-             if (ar->arWmiReady == false) {
-                 ret = -EIO;
-                 goto ioctl_done;
-             } else if (copy_from_user(&setKeepAlive, userdata,
-                        sizeof(setKeepAlive))){
-                 ret = -EFAULT;
-             } else {
-                 if (wmi_set_keepalive_cmd(ar->arWmi, setKeepAlive.keepaliveInterval) != 0) {
-                     ret = -EIO;
-               }
-             }
-             break;
-        }
-        case AR6000_XIOCTL_WMI_SET_PARAMS:
-        {
-             WMI_SET_PARAMS_CMD cmd;
-             if (ar->arWmiReady == false) {
-                 ret = -EIO;
-                 goto ioctl_done;
-             } else if (copy_from_user(&cmd, userdata,
-                        sizeof(cmd))){
-                 ret = -EFAULT;
-             } else if (copy_from_user(&cmd, userdata,
-                        sizeof(cmd) + cmd.length))
-            {
-                ret = -EFAULT;
-            } else {
-                 if (wmi_set_params_cmd(ar->arWmi, cmd.opcode, cmd.length, cmd.buffer) != 0) {
-                     ret = -EIO;
-               }
-             }
-             break;
-        }
-        case AR6000_XIOCTL_WMI_SET_MCAST_FILTER:
-        {
-             WMI_SET_MCAST_FILTER_CMD cmd;
-             if (ar->arWmiReady == false) {
-                 ret = -EIO;
-                 goto ioctl_done;
-             } else if (copy_from_user(&cmd, userdata,
-                        sizeof(cmd))){
-                 ret = -EFAULT;
-             } else {
-                 if (wmi_set_mcast_filter_cmd(ar->arWmi, cmd.multicast_mac[0],
-                                                                                     cmd.multicast_mac[1],
-                                                                                     cmd.multicast_mac[2],
-                                                                                     cmd.multicast_mac[3]) != 0) {
-                     ret = -EIO;
-               }
-             }
-             break;
-        }
-        case AR6000_XIOCTL_WMI_DEL_MCAST_FILTER:
-        {
-             WMI_SET_MCAST_FILTER_CMD cmd;
-             if (ar->arWmiReady == false) {
-                 ret = -EIO;
-                 goto ioctl_done;
-             } else if (copy_from_user(&cmd, userdata,
-                        sizeof(cmd))){
-                 ret = -EFAULT;
-             } else {
-                 if (wmi_del_mcast_filter_cmd(ar->arWmi, cmd.multicast_mac[0],
-                                                                                     cmd.multicast_mac[1],
-                                                                                     cmd.multicast_mac[2],
-                                                                                     cmd.multicast_mac[3]) != 0) {
-                     ret = -EIO;
-               }
-             }
-             break;
-        }
-        case AR6000_XIOCTL_WMI_MCAST_FILTER:
-        {
-             WMI_MCAST_FILTER_CMD cmd;
-             if (ar->arWmiReady == false) {
-                 ret = -EIO;
-                 goto ioctl_done;
-             } else if (copy_from_user(&cmd, userdata,
-                        sizeof(cmd))){
-                 ret = -EFAULT;
-             } else {
-                 if (wmi_mcast_filter_cmd(ar->arWmi, cmd.enable)  != 0) {
-                     ret = -EIO;
-               }
-             }
-             break;
-        }
-        case AR6000_XIOCTL_WMI_GET_KEEPALIVE:
-        {
-            struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-            WMI_GET_KEEPALIVE_CMD getKeepAlive;
-            int ret = 0;
-            if (ar->bIsDestroyProgress) {
-                ret =-EBUSY;
-                goto ioctl_done;
-            }
-            if (ar->arWmiReady == false) {
-               ret = -EIO;
-               goto ioctl_done;
-            }
-            if (down_interruptible(&ar->arSem)) {
-                ret = -ERESTARTSYS;
-                goto ioctl_done;
-            }
-            if (ar->bIsDestroyProgress) {
-                up(&ar->arSem);
-                ret = -EBUSY;
-                goto ioctl_done;
-            }
-            if (copy_from_user(&getKeepAlive, userdata,sizeof(getKeepAlive))) {
-               ret = -EFAULT;
-            } else {
-            getKeepAlive.keepaliveInterval = wmi_get_keepalive_cmd(ar->arWmi);
-            ar->arKeepaliveConfigured = 0xFF;
-            if (wmi_get_keepalive_configured(ar->arWmi) != 0){
-                up(&ar->arSem);
-                ret = -EIO;
-                goto ioctl_done;
-            }
-            wait_event_interruptible_timeout(arEvent, ar->arKeepaliveConfigured != 0xFF, wmitimeout * HZ);
-            if (signal_pending(current)) {
-                ret = -EINTR;
-            }
-
-            if (!ret) {
-                getKeepAlive.configured = ar->arKeepaliveConfigured;
-            }
-            if (copy_to_user(userdata, &getKeepAlive, sizeof(getKeepAlive))) {
-               ret = -EFAULT;
-            }
-            up(&ar->arSem);
-            }
-            break;
-        }
-        case AR6000_XIOCTL_WMI_SET_APPIE:
-        {
-            WMI_SET_APPIE_CMD appIEcmd;
-            u8 appIeInfo[IEEE80211_APPIE_FRAME_MAX_LEN];
-            u32 fType,ieLen;
-
-            if (ar->arWmiReady == false) {
-                ret = -EIO;
-                goto ioctl_done;
-            }
-           if (get_user(fType, (u32 *)userdata)) {
-               ret = -EFAULT;
-               break;
-           }
-            appIEcmd.mgmtFrmType = fType;
-            if (appIEcmd.mgmtFrmType >= IEEE80211_APPIE_NUM_OF_FRAME) {
-                ret = -EIO;
-            } else {
-               if (get_user(ieLen, (u32 *)(userdata + 4))) {
-                   ret = -EFAULT;
-                   break;
-               }
-                appIEcmd.ieLen = ieLen;
-                A_PRINTF("WPSIE: Type-%d, Len-%d\n",appIEcmd.mgmtFrmType, appIEcmd.ieLen);
-                if (appIEcmd.ieLen > IEEE80211_APPIE_FRAME_MAX_LEN) {
-                    ret = -EIO;
-                    break;
-                }
-                if (copy_from_user(appIeInfo, userdata + 8, appIEcmd.ieLen)) {
-                    ret = -EFAULT;
-                } else {
-                    if (wmi_set_appie_cmd(ar->arWmi, appIEcmd.mgmtFrmType,
-                                          appIEcmd.ieLen,  appIeInfo) != 0)
-                    {
-                        ret = -EIO;
-                    }
-                }
-            }
-            break;
-        }
-        case AR6000_XIOCTL_WMI_SET_MGMT_FRM_RX_FILTER:
-        {
-            WMI_BSS_FILTER_CMD cmd;
-            u32 filterType;
-
-            if (copy_from_user(&filterType, userdata, sizeof(u32)))
-            {
-                ret = -EFAULT;
-                goto ioctl_done;
-            }
-            if (filterType & (IEEE80211_FILTER_TYPE_BEACON |
-                                    IEEE80211_FILTER_TYPE_PROBE_RESP))
-            {
-                cmd.bssFilter = ALL_BSS_FILTER;
-            } else {
-                cmd.bssFilter = NONE_BSS_FILTER;
-            }
-            if (wmi_bssfilter_cmd(ar->arWmi, cmd.bssFilter, 0) != 0) {
-                ret = -EIO;
-            } else {
-                ar->arUserBssFilter = cmd.bssFilter;
-            }
-
-            AR6000_SPIN_LOCK(&ar->arLock, 0);
-            ar->arMgmtFilter = filterType;
-            AR6000_SPIN_UNLOCK(&ar->arLock, 0);
-            break;
-        }
-        case AR6000_XIOCTL_WMI_SET_WSC_STATUS:
-        {
-            u32 wsc_status;
-
-            if (ar->arWmiReady == false) {
-                ret = -EIO;
-                goto ioctl_done;
-            } else if (copy_from_user(&wsc_status, userdata, sizeof(u32)))
-            {
-                ret = -EFAULT;
-                goto ioctl_done;
-            }
-            if (wmi_set_wsc_status_cmd(ar->arWmi, wsc_status) != 0) {
-                ret = -EIO;
-            }
-            break;
-        }
-        case AR6000_XIOCTL_BMI_ROMPATCH_INSTALL:
-        {
-            u32 ROM_addr;
-            u32 RAM_addr;
-            u32 nbytes;
-            u32 do_activate;
-            u32 rompatch_id;
-
-           if (get_user(ROM_addr, (u32 *)userdata) ||
-               get_user(RAM_addr, (u32 *)userdata + 1) ||
-               get_user(nbytes, (u32 *)userdata + 2) ||
-               get_user(do_activate, (u32 *)userdata + 3)) {
-               ret = -EFAULT;
-               break;
-           }
-            AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("Install rompatch from ROM: 0x%x to RAM: 0x%x  length: %d\n",
-                             ROM_addr, RAM_addr, nbytes));
-            ret = BMIrompatchInstall(hifDevice, ROM_addr, RAM_addr,
-                                        nbytes, do_activate, &rompatch_id);
-            if (ret == 0) {
-               /* return value */
-               if (put_user(rompatch_id, (unsigned int *)rq->ifr_data)) {
-                   ret = -EFAULT;
-                   break;
-               }
-            }
-            break;
-        }
-
-        case AR6000_XIOCTL_BMI_ROMPATCH_UNINSTALL:
-        {
-            u32 rompatch_id;
-
-           if (get_user(rompatch_id, (u32 *)userdata)) {
-               ret = -EFAULT;
-               break;
-           }
-            AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("UNinstall rompatch_id %d\n", rompatch_id));
-            ret = BMIrompatchUninstall(hifDevice, rompatch_id);
-            break;
-        }
-
-        case AR6000_XIOCTL_BMI_ROMPATCH_ACTIVATE:
-        case AR6000_XIOCTL_BMI_ROMPATCH_DEACTIVATE:
-        {
-            u32 rompatch_count;
-
-           if (get_user(rompatch_count, (u32 *)userdata)) {
-               ret = -EFAULT;
-               break;
-           }
-            AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("Change rompatch activation count=%d\n", rompatch_count));
-            length = sizeof(u32) * rompatch_count;
-            if ((buffer = (unsigned char *)A_MALLOC(length)) != NULL) {
-                A_MEMZERO(buffer, length);
-                if (copy_from_user(buffer, &userdata[sizeof(rompatch_count)], length))
-                {
-                    ret = -EFAULT;
-                } else {
-                    if (cmd == AR6000_XIOCTL_BMI_ROMPATCH_ACTIVATE) {
-                        ret = BMIrompatchActivate(hifDevice, rompatch_count, (u32 *)buffer);
-                    } else {
-                        ret = BMIrompatchDeactivate(hifDevice, rompatch_count, (u32 *)buffer);
-                    }
-                }
-                A_FREE(buffer);
-            } else {
-                ret = -ENOMEM;
-            }
-
-            break;
-        }
-        case AR6000_XIOCTL_SET_IP:
-        {
-            WMI_SET_IP_CMD setIP;
-
-            if (ar->arWmiReady == false) {
-                ret = -EIO;
-            } else if (copy_from_user(&setIP, userdata,
-                                      sizeof(setIP)))
-            {
-                ret = -EFAULT;
-            } else {
-                if (wmi_set_ip_cmd(ar->arWmi,
-                                &setIP) != 0)
-                {
-                    ret = -EIO;
-                }
-            }
-            break;
-        }
-
-        case AR6000_XIOCTL_WMI_SET_HOST_SLEEP_MODE:
-        {
-            WMI_SET_HOST_SLEEP_MODE_CMD setHostSleepMode;
-
-            if (ar->arWmiReady == false) {
-                ret = -EIO;
-            } else if (copy_from_user(&setHostSleepMode, userdata,
-                                      sizeof(setHostSleepMode)))
-            {
-                ret = -EFAULT;
-            } else {
-                if (wmi_set_host_sleep_mode_cmd(ar->arWmi,
-                                &setHostSleepMode) != 0)
-                {
-                    ret = -EIO;
-                }
-            }
-            break;
-        }
-        case AR6000_XIOCTL_WMI_SET_WOW_MODE:
-        {
-            WMI_SET_WOW_MODE_CMD setWowMode;
-
-            if (ar->arWmiReady == false) {
-                ret = -EIO;
-            } else if (copy_from_user(&setWowMode, userdata,
-                                      sizeof(setWowMode)))
-            {
-                ret = -EFAULT;
-            } else {
-                if (wmi_set_wow_mode_cmd(ar->arWmi,
-                                &setWowMode) != 0)
-                {
-                    ret = -EIO;
-                }
-            }
-            break;
-        }
-        case AR6000_XIOCTL_WMI_GET_WOW_LIST:
-        {
-            WMI_GET_WOW_LIST_CMD getWowList;
-
-            if (ar->arWmiReady == false) {
-                ret = -EIO;
-            } else if (copy_from_user(&getWowList, userdata,
-                                      sizeof(getWowList)))
-            {
-                ret = -EFAULT;
-            } else {
-                if (wmi_get_wow_list_cmd(ar->arWmi,
-                                &getWowList) != 0)
-                {
-                    ret = -EIO;
-                }
-            }
-            break;
-        }
-        case AR6000_XIOCTL_WMI_ADD_WOW_PATTERN:
-        {
-#define WOW_PATTERN_SIZE 64
-#define WOW_MASK_SIZE 64
-
-            WMI_ADD_WOW_PATTERN_CMD cmd;
-            u8 mask_data[WOW_PATTERN_SIZE]={0};
-            u8 pattern_data[WOW_PATTERN_SIZE]={0};
-
-            do {
-                if (ar->arWmiReady == false) {
-                    ret = -EIO;
-                    break;        
-                } 
-                if(copy_from_user(&cmd, userdata,
-                            sizeof(WMI_ADD_WOW_PATTERN_CMD))) 
-                {
-                    ret = -EFAULT;
-                    break;        
-                }
-                if (copy_from_user(pattern_data,
-                                      userdata + 3,
-                                      cmd.filter_size)) 
-                {
-                    ret = -EFAULT;
-                    break;        
-                }
-                if (copy_from_user(mask_data,
-                                  (userdata + 3 + cmd.filter_size),
-                                  cmd.filter_size))
-                {
-                    ret = -EFAULT;
-                    break;
-                }
-                if (wmi_add_wow_pattern_cmd(ar->arWmi,
-                            &cmd, pattern_data, mask_data, cmd.filter_size) != 0)
-                {
-                    ret = -EIO;
-                }
-            } while(false);
-#undef WOW_PATTERN_SIZE
-#undef WOW_MASK_SIZE
-            break;
-        }
-        case AR6000_XIOCTL_WMI_DEL_WOW_PATTERN:
-        {
-            WMI_DEL_WOW_PATTERN_CMD delWowPattern;
-
-            if (ar->arWmiReady == false) {
-                ret = -EIO;
-            } else if (copy_from_user(&delWowPattern, userdata,
-                                      sizeof(delWowPattern)))
-            {
-                ret = -EFAULT;
-            } else {
-                if (wmi_del_wow_pattern_cmd(ar->arWmi,
-                                &delWowPattern) != 0)
-                {
-                    ret = -EIO;
-                }
-            }
-            break;
-        }
-        case AR6000_XIOCTL_DUMP_HTC_CREDIT_STATE:
-            if (ar->arHtcTarget != NULL) {
-#ifdef ATH_DEBUG_MODULE
-                HTCDumpCreditStates(ar->arHtcTarget);
-#endif /* ATH_DEBUG_MODULE */
-#ifdef HTC_EP_STAT_PROFILING
-                {
-                    struct htc_endpoint_stats stats;
-                    int i;
-
-                    for (i = 0; i < 5; i++) {
-                        if (HTCGetEndpointStatistics(ar->arHtcTarget,
-                                                     i,
-                                                     HTC_EP_STAT_SAMPLE_AND_CLEAR,
-                                                     &stats)) {
-                            A_PRINTF(KERN_ALERT"------- Profiling Endpoint : %d \n", i);
-                            A_PRINTF(KERN_ALERT"TxCreditLowIndications : %d \n", stats.TxCreditLowIndications);
-                            A_PRINTF(KERN_ALERT"TxIssued : %d \n", stats.TxIssued);
-                            A_PRINTF(KERN_ALERT"TxDropped: %d \n", stats.TxDropped);
-                            A_PRINTF(KERN_ALERT"TxPacketsBundled : %d \n", stats.TxPacketsBundled);
-                            A_PRINTF(KERN_ALERT"TxBundles : %d \n", stats.TxBundles);
-                            A_PRINTF(KERN_ALERT"TxCreditRpts : %d \n", stats.TxCreditRpts);
-                            A_PRINTF(KERN_ALERT"TxCreditsRptsFromRx : %d \n", stats.TxCreditRptsFromRx);
-                            A_PRINTF(KERN_ALERT"TxCreditsRptsFromOther : %d \n", stats.TxCreditRptsFromOther);
-                            A_PRINTF(KERN_ALERT"TxCreditsRptsFromEp0 : %d \n", stats.TxCreditRptsFromEp0);
-                            A_PRINTF(KERN_ALERT"TxCreditsFromRx : %d \n", stats.TxCreditsFromRx);
-                            A_PRINTF(KERN_ALERT"TxCreditsFromOther : %d \n", stats.TxCreditsFromOther);
-                            A_PRINTF(KERN_ALERT"TxCreditsFromEp0 : %d \n", stats.TxCreditsFromEp0);
-                            A_PRINTF(KERN_ALERT"TxCreditsConsummed : %d \n", stats.TxCreditsConsummed);
-                            A_PRINTF(KERN_ALERT"TxCreditsReturned : %d \n", stats.TxCreditsReturned);
-                            A_PRINTF(KERN_ALERT"RxReceived : %d \n", stats.RxReceived);
-                            A_PRINTF(KERN_ALERT"RxPacketsBundled : %d \n", stats.RxPacketsBundled);
-                            A_PRINTF(KERN_ALERT"RxLookAheads : %d \n", stats.RxLookAheads);
-                            A_PRINTF(KERN_ALERT"RxBundleLookAheads : %d \n", stats.RxBundleLookAheads);
-                            A_PRINTF(KERN_ALERT"RxBundleIndFromHdr : %d \n", stats.RxBundleIndFromHdr);
-                            A_PRINTF(KERN_ALERT"RxAllocThreshHit : %d \n", stats.RxAllocThreshHit);
-                            A_PRINTF(KERN_ALERT"RxAllocThreshBytes : %d \n", stats.RxAllocThreshBytes);
-                            A_PRINTF(KERN_ALERT"---- \n");
-
-                        }
-            }
-                }
-#endif
-            }
-            break;
-        case AR6000_XIOCTL_TRAFFIC_ACTIVITY_CHANGE:
-            if (ar->arHtcTarget != NULL) {
-                struct ar6000_traffic_activity_change data;
-
-                if (copy_from_user(&data, userdata, sizeof(data)))
-                {
-                    ret = -EFAULT;
-                    goto ioctl_done;
-                }
-                    /* note, this is used for testing (mbox ping testing), indicate activity
-                     * change using the stream ID as the traffic class */
-                ar6000_indicate_tx_activity(ar,
-                                            (u8)data.StreamID,
-                                            data.Active ? true : false);
-            }
-            break;
-        case AR6000_XIOCTL_WMI_SET_CONNECT_CTRL_FLAGS:
-            if (ar->arWmiReady == false) {
-                ret = -EIO;
-            } else if (copy_from_user(&connectCtrlFlags, userdata,
-                                      sizeof(connectCtrlFlags)))
-            {
-                ret = -EFAULT;
-            } else {
-                ar->arConnectCtrlFlags = connectCtrlFlags;
-            }
-            break;
-        case AR6000_XIOCTL_WMI_SET_AKMP_PARAMS:
-            if (ar->arWmiReady == false) {
-                ret = -EIO;
-            } else if (copy_from_user(&akmpParams, userdata,
-                                      sizeof(WMI_SET_AKMP_PARAMS_CMD)))
-            {
-                ret = -EFAULT;
-            } else {
-                if (wmi_set_akmp_params_cmd(ar->arWmi, &akmpParams) != 0) {
-                    ret = -EIO;
-                }
-            }
-            break;
-        case AR6000_XIOCTL_WMI_SET_PMKID_LIST:
-            if (ar->arWmiReady == false) {
-                ret = -EIO;
-            } else {
-                if (copy_from_user(&pmkidInfo.numPMKID, userdata,
-                                      sizeof(pmkidInfo.numPMKID)))
-                {
-                    ret = -EFAULT;
-                    break;
-                }
-                if (copy_from_user(&pmkidInfo.pmkidList,
-                                   userdata + sizeof(pmkidInfo.numPMKID),
-                                   pmkidInfo.numPMKID * sizeof(WMI_PMKID)))
-                {
-                    ret = -EFAULT;
-                    break;
-                }
-                if (wmi_set_pmkid_list_cmd(ar->arWmi, &pmkidInfo) != 0) {
-                    ret = -EIO;
-                }
-            }
-            break;
-        case AR6000_XIOCTL_WMI_GET_PMKID_LIST:
-            if (ar->arWmiReady == false) {
-                ret = -EIO;
-            } else  {
-                if (wmi_get_pmkid_list_cmd(ar->arWmi) != 0) {
-                    ret = -EIO;
-                }
-            }
-            break;
-        case AR6000_XIOCTL_WMI_ABORT_SCAN:
-            if (ar->arWmiReady == false) {
-                ret = -EIO;
-            }
-            ret = wmi_abort_scan_cmd(ar->arWmi);
-            break;
-        case AR6000_XIOCTL_AP_HIDDEN_SSID:
-        {
-            u8 hidden_ssid;
-            if (ar->arWmiReady == false) {
-                ret = -EIO;
-            } else if (copy_from_user(&hidden_ssid, userdata, sizeof(hidden_ssid))) {
-                ret = -EFAULT;
-            } else {
-                wmi_ap_set_hidden_ssid(ar->arWmi, hidden_ssid);
-                ar->ap_hidden_ssid = hidden_ssid;
-                ar->ap_profile_flag = 1; /* There is a change in profile */
-            }
-            break;
-        }
-        case AR6000_XIOCTL_AP_GET_STA_LIST:
-        {
-            if (ar->arWmiReady == false) {
-                ret = -EIO;
-            } else {
-                u8 i;
-                ap_get_sta_t temp;
-                A_MEMZERO(&temp, sizeof(temp));
-                for(i=0;i<AP_MAX_NUM_STA;i++) {
-                    memcpy(temp.sta[i].mac, ar->sta_list[i].mac, ATH_MAC_LEN);
-                    temp.sta[i].aid = ar->sta_list[i].aid;
-                    temp.sta[i].keymgmt = ar->sta_list[i].keymgmt;
-                    temp.sta[i].ucipher = ar->sta_list[i].ucipher;
-                    temp.sta[i].auth = ar->sta_list[i].auth;
-                }
-                if(copy_to_user((ap_get_sta_t *)rq->ifr_data, &temp,
-                                 sizeof(ar->sta_list))) {
-                    ret = -EFAULT;
-                }
-            }
-            break;
-        }
-        case AR6000_XIOCTL_AP_SET_NUM_STA:
-        {
-            u8 num_sta;
-            if (ar->arWmiReady == false) {
-                ret = -EIO;
-            } else if (copy_from_user(&num_sta, userdata, sizeof(num_sta))) {
-                ret = -EFAULT;
-            } else if(num_sta > AP_MAX_NUM_STA) {
-                /* value out of range */
-                ret = -EINVAL;
-            } else {
-                wmi_ap_set_num_sta(ar->arWmi, num_sta);
-            }
-            break;
-        }
-        case AR6000_XIOCTL_AP_SET_ACL_POLICY:
-        {
-            u8 policy;
-            if (ar->arWmiReady == false) {
-                ret = -EIO;
-            } else if (copy_from_user(&policy, userdata, sizeof(policy))) {
-                ret = -EFAULT;
-            } else if(policy == ar->g_acl.policy) {
-                /* No change in policy */
-            } else {
-                if(!(policy & AP_ACL_RETAIN_LIST_MASK)) {
-                    /* clear ACL list */
-                    memset(&ar->g_acl,0,sizeof(WMI_AP_ACL));
-                }
-                ar->g_acl.policy = policy;
-                wmi_ap_set_acl_policy(ar->arWmi, policy);
-            }
-            break;
-        }
-        case AR6000_XIOCTL_AP_SET_ACL_MAC:
-        {
-            WMI_AP_ACL_MAC_CMD    acl;
-            if (ar->arWmiReady == false) {
-                ret = -EIO;
-            } else if (copy_from_user(&acl, userdata, sizeof(acl))) {
-                ret = -EFAULT;
-            } else {
-                if(acl_add_del_mac(&ar->g_acl, &acl)) {
-                    wmi_ap_acl_mac_list(ar->arWmi, &acl);
-                } else {
-                    A_PRINTF("ACL list error\n");
-                    ret = -EIO;
-                }
-            }
-            break;
-        }
-        case AR6000_XIOCTL_AP_GET_ACL_LIST:
-        {
-            if (ar->arWmiReady == false) {
-                ret = -EIO;
-            } else if(copy_to_user((WMI_AP_ACL *)rq->ifr_data, &ar->g_acl,
-                                 sizeof(WMI_AP_ACL))) {
-                    ret = -EFAULT;
-            }
-            break;
-        }
-        case AR6000_XIOCTL_AP_COMMIT_CONFIG:
-        {
-            ret = ar6000_ap_mode_profile_commit(ar);
-            break;
-        }
-        case IEEE80211_IOCTL_GETWPAIE:
-        {
-            struct ieee80211req_wpaie wpaie;
-            if (ar->arWmiReady == false) {
-                ret = -EIO;
-            } else if (copy_from_user(&wpaie, userdata, sizeof(wpaie))) {
-                ret = -EFAULT;
-            } else if (ar6000_ap_mode_get_wpa_ie(ar, &wpaie)) {
-                ret = -EFAULT;
-            } else if(copy_to_user(userdata, &wpaie, sizeof(wpaie))) {
-                ret = -EFAULT;
-            }
-            break;
-        }
-        case AR6000_XIOCTL_AP_CONN_INACT_TIME:
-        {
-            u32 period;
-            if (ar->arWmiReady == false) {
-                ret = -EIO;
-            } else if (copy_from_user(&period, userdata, sizeof(period))) {
-                ret = -EFAULT;
-            } else {
-                wmi_ap_conn_inact_time(ar->arWmi, period);
-            }
-            break;
-        }
-        case AR6000_XIOCTL_AP_PROT_SCAN_TIME:
-        {
-            WMI_AP_PROT_SCAN_TIME_CMD  bgscan;
-            if (ar->arWmiReady == false) {
-                ret = -EIO;
-            } else if (copy_from_user(&bgscan, userdata, sizeof(bgscan))) {
-                ret = -EFAULT;
-            } else {
-                wmi_ap_bgscan_time(ar->arWmi, bgscan.period_min, bgscan.dwell_ms);
-            }
-            break;
-        }
-        case AR6000_XIOCTL_AP_SET_COUNTRY:
-        {
-            ret = ar6000_ioctl_set_country(dev, rq);
-            break;
-        }
-        case AR6000_XIOCTL_AP_SET_DTIM:
-        {
-            WMI_AP_SET_DTIM_CMD  d;
-            if (ar->arWmiReady == false) {
-                ret = -EIO;
-            } else if (copy_from_user(&d, userdata, sizeof(d))) {
-                ret = -EFAULT;
-            } else {
-                if(d.dtim > 0 && d.dtim < 11) {
-                    ar->ap_dtim_period = d.dtim;
-                    wmi_ap_set_dtim(ar->arWmi, d.dtim);
-                    ar->ap_profile_flag = 1; /* There is a change in profile */
-                } else {
-                    A_PRINTF("DTIM out of range. Valid range is [1-10]\n");
-                    ret = -EIO;
-                }
-            }
-            break;
-        }
-        case AR6000_XIOCTL_WMI_TARGET_EVENT_REPORT:
-        {
-            WMI_SET_TARGET_EVENT_REPORT_CMD evtCfgCmd;
-
-            if (ar->arWmiReady == false) {
-                ret = -EIO;
-            }
-            if (copy_from_user(&evtCfgCmd, userdata,
-                               sizeof(evtCfgCmd))) {
-                ret = -EFAULT;
-                break;
-            }
-            ret = wmi_set_target_event_report_cmd(ar->arWmi, &evtCfgCmd);
-            break;
-        }
-        case AR6000_XIOCTL_AP_INTRA_BSS_COMM:
-        {
-            u8 intra=0;
-            if (ar->arWmiReady == false) {
-                ret = -EIO;
-            } else if (copy_from_user(&intra, userdata, sizeof(intra))) {
-                ret = -EFAULT;
-            } else {
-                ar->intra_bss = (intra?1:0);
-            }
-            break;
-        }
-        case AR6000_XIOCTL_DUMP_MODULE_DEBUG_INFO:
-        {
-            struct drv_debug_module_s moduleinfo;
-
-            if (copy_from_user(&moduleinfo, userdata, sizeof(moduleinfo))) {
-                ret = -EFAULT;
-                break;
-            }
-
-            a_dump_module_debug_info_by_name(moduleinfo.modulename);
-            ret = 0;
-            break;
-        }
-        case AR6000_XIOCTL_MODULE_DEBUG_SET_MASK:
-        {
-            struct drv_debug_module_s moduleinfo;
-
-            if (copy_from_user(&moduleinfo, userdata, sizeof(moduleinfo))) {
-                ret = -EFAULT;
-                break;
-            }
-
-            if (a_set_module_mask(moduleinfo.modulename, moduleinfo.mask)) {
-                ret = -EFAULT;
-            }
-
-            break;
-        }
-        case AR6000_XIOCTL_MODULE_DEBUG_GET_MASK:
-        {
-            struct drv_debug_module_s moduleinfo;
-
-            if (copy_from_user(&moduleinfo, userdata, sizeof(moduleinfo))) {
-                ret = -EFAULT;
-                break;
-            }
-
-            if (a_get_module_mask(moduleinfo.modulename, &moduleinfo.mask)) {
-                ret = -EFAULT;
-                break;
-            }
-
-            if (copy_to_user(userdata, &moduleinfo, sizeof(moduleinfo))) {
-                ret = -EFAULT;
-                break;
-            }
-
-            break;
-        }
-#ifdef ATH_AR6K_11N_SUPPORT
-        case AR6000_XIOCTL_DUMP_RCV_AGGR_STATS:
-        {
-            PACKET_LOG *copy_of_pkt_log;
-
-            aggr_dump_stats(ar->aggr_cntxt, &copy_of_pkt_log);
-            if (copy_to_user(rq->ifr_data, copy_of_pkt_log, sizeof(PACKET_LOG))) {
-                ret = -EFAULT;
-            }
-            break;
-        }
-        case AR6000_XIOCTL_SETUP_AGGR:
-        {
-            WMI_ADDBA_REQ_CMD cmd;
-
-            if (ar->arWmiReady == false) {
-                ret = -EIO;
-            } else if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
-                ret = -EFAULT;
-            } else {
-                wmi_setup_aggr_cmd(ar->arWmi, cmd.tid);
-            }
-        }
-        break;
-
-        case AR6000_XIOCTL_DELE_AGGR:
-        {
-            WMI_DELBA_REQ_CMD cmd;
-
-            if (ar->arWmiReady == false) {
-                ret = -EIO;
-            } else if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
-                ret = -EFAULT;
-            } else {
-                wmi_delete_aggr_cmd(ar->arWmi, cmd.tid, cmd.is_sender_initiator);
-            }
-        }
-        break;
-
-        case AR6000_XIOCTL_ALLOW_AGGR:
-        {
-            WMI_ALLOW_AGGR_CMD cmd;
-
-            if (ar->arWmiReady == false) {
-                ret = -EIO;
-            } else if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
-                ret = -EFAULT;
-            } else {
-                wmi_allow_aggr_cmd(ar->arWmi, cmd.tx_allow_aggr, cmd.rx_allow_aggr);
-            }
-        }
-        break;
-
-        case AR6000_XIOCTL_SET_HT_CAP:
-        {
-            if (ar->arWmiReady == false) {
-                ret = -EIO;
-            } else if (copy_from_user(&htCap, userdata,
-                                      sizeof(htCap)))
-            {
-                ret = -EFAULT;
-            } else {
-
-                if (wmi_set_ht_cap_cmd(ar->arWmi, &htCap) != 0)
-                {
-                    ret = -EIO;
-                }
-            }
-            break;
-        }
-        case AR6000_XIOCTL_SET_HT_OP:
-        {
-             if (ar->arWmiReady == false) {
-                ret = -EIO;
-            } else if (copy_from_user(&htOp, userdata,
-                                      sizeof(htOp)))
-            {
-                 ret = -EFAULT;
-             } else {
-
-                if (wmi_set_ht_op_cmd(ar->arWmi, htOp.sta_chan_width) != 0)
-                {
-                     ret = -EIO;
-               }
-             }
-             break;
-        }
-#endif
-        case AR6000_XIOCTL_ACL_DATA:
-        {
-            void *osbuf = NULL;
-            if (ar->arWmiReady == false) {
-                ret = -EIO;
-            } else if (ar6000_create_acl_data_osbuf(dev, (u8 *)userdata, &osbuf) != 0) {
-                     ret = -EIO;
-            } else {
-                if (wmi_data_hdr_add(ar->arWmi, osbuf, DATA_MSGTYPE, 0, WMI_DATA_HDR_DATA_TYPE_ACL,0,NULL) != 0) {
-                    AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("XIOCTL_ACL_DATA - wmi_data_hdr_add failed\n"));
-                } else {
-                    /* Send data buffer over HTC */
-                    ar6000_acl_data_tx(osbuf, ar->arNetDev);
-                }
-            }
-            break;
-        }
-        case AR6000_XIOCTL_HCI_CMD:
-        {
-            char tmp_buf[512];
-            s8 i;
-            WMI_HCI_CMD *cmd = (WMI_HCI_CMD *)tmp_buf;
-            u8 size;
-
-            size = sizeof(cmd->cmd_buf_sz);
-            if (ar->arWmiReady == false) {
-                ret = -EIO;
-            } else if (copy_from_user(cmd, userdata, size)) {
-                 ret = -EFAULT;
-            } else if(copy_from_user(cmd->buf, userdata + size, cmd->cmd_buf_sz)) {
-                    ret = -EFAULT;
-            } else {
-                if (wmi_send_hci_cmd(ar->arWmi, cmd->buf, cmd->cmd_buf_sz) != 0) {
-                     ret = -EIO;
-                }else if(loghci) {
-                    A_PRINTF_LOG("HCI Command To PAL --> \n");
-                    for(i = 0; i < cmd->cmd_buf_sz; i++) {
-                        A_PRINTF_LOG("0x%02x ",cmd->buf[i]);
-                        if((i % 10) == 0) {
-                            A_PRINTF_LOG("\n");
-                        }
-                    }
-                    A_PRINTF_LOG("\n");
-                    A_PRINTF_LOG("==================================\n");
-                }
-            }
-            break;
-        }
-        case AR6000_XIOCTL_WLAN_CONN_PRECEDENCE:
-        {
-            WMI_SET_BT_WLAN_CONN_PRECEDENCE cmd;
-            if (ar->arWmiReady == false) {
-                ret = -EIO;
-            } else if (copy_from_user(&cmd, userdata, sizeof(cmd))) {
-                ret = -EFAULT;
-            } else {
-                if (cmd.precedence == BT_WLAN_CONN_PRECDENCE_WLAN ||
-                            cmd.precedence == BT_WLAN_CONN_PRECDENCE_PAL) {
-                    if ( wmi_set_wlan_conn_precedence_cmd(ar->arWmi, cmd.precedence) != 0) {
-                        ret = -EIO;
-                    }
-                } else {
-                    ret = -EINVAL;
-                }
-            }
-            break;
-        }
-        case AR6000_XIOCTL_AP_GET_STAT:
-        {
-            ret = ar6000_ioctl_get_ap_stats(dev, rq);
-            break;
-        }
-        case AR6000_XIOCTL_SET_TX_SELECT_RATES:
-        {
-            WMI_SET_TX_SELECT_RATES_CMD masks;
-
-             if (ar->arWmiReady == false) {
-                ret = -EIO;
-            } else if (copy_from_user(&masks, userdata,
-                                      sizeof(masks)))
-            {
-                 ret = -EFAULT;
-             } else {
-
-                if (wmi_set_tx_select_rates_cmd(ar->arWmi, masks.rateMasks) != 0)
-                {
-                     ret = -EIO;
-               }
-             }
-             break;
-        }
-        case AR6000_XIOCTL_AP_GET_HIDDEN_SSID:
-        {
-            WMI_AP_HIDDEN_SSID_CMD ssid;
-            ssid.hidden_ssid = ar->ap_hidden_ssid;
-
-            if (ar->arWmiReady == false) {
-                ret = -EIO;
-            } else if(copy_to_user((WMI_AP_HIDDEN_SSID_CMD *)rq->ifr_data,
-                                    &ssid, sizeof(WMI_AP_HIDDEN_SSID_CMD))) {
-                    ret = -EFAULT;
-            }
-            break;
-        }
-        case AR6000_XIOCTL_AP_GET_COUNTRY:
-        {
-            WMI_AP_SET_COUNTRY_CMD cty;
-            memcpy(cty.countryCode, ar->ap_country_code, 3);
-
-            if (ar->arWmiReady == false) {
-                ret = -EIO;
-            } else if(copy_to_user((WMI_AP_SET_COUNTRY_CMD *)rq->ifr_data,
-                                    &cty, sizeof(WMI_AP_SET_COUNTRY_CMD))) {
-                    ret = -EFAULT;
-            }
-            break;
-        }
-        case AR6000_XIOCTL_AP_GET_WMODE:
-        {
-            if (ar->arWmiReady == false) {
-                ret = -EIO;
-            } else if(copy_to_user((u8 *)rq->ifr_data,
-                                    &ar->ap_wmode, sizeof(u8))) {
-                    ret = -EFAULT;
-            }
-            break;
-        }
-        case AR6000_XIOCTL_AP_GET_DTIM:
-        {
-            WMI_AP_SET_DTIM_CMD dtim;
-            dtim.dtim = ar->ap_dtim_period;
-
-            if (ar->arWmiReady == false) {
-                ret = -EIO;
-            } else if(copy_to_user((WMI_AP_SET_DTIM_CMD *)rq->ifr_data,
-                                    &dtim, sizeof(WMI_AP_SET_DTIM_CMD))) {
-                    ret = -EFAULT;
-            }
-            break;
-        }
-        case AR6000_XIOCTL_AP_GET_BINTVL:
-        {
-            WMI_BEACON_INT_CMD bi;
-            bi.beaconInterval = ar->ap_beacon_interval;
-
-            if (ar->arWmiReady == false) {
-                ret = -EIO;
-            } else if(copy_to_user((WMI_BEACON_INT_CMD *)rq->ifr_data,
-                                    &bi, sizeof(WMI_BEACON_INT_CMD))) {
-                    ret = -EFAULT;
-            }
-            break;
-        }
-        case AR6000_XIOCTL_AP_GET_RTS:
-        {
-            WMI_SET_RTS_CMD rts;
-            rts.threshold = ar->arRTS;
-            
-            if (ar->arWmiReady == false) {
-                ret = -EIO;
-            } else if(copy_to_user((WMI_SET_RTS_CMD *)rq->ifr_data,
-                                    &rts, sizeof(WMI_SET_RTS_CMD))) {
-                    ret = -EFAULT;
-            }
-            break;
-        }
-        case AR6000_XIOCTL_FETCH_TARGET_REGS:
-        {
-            u32 targregs[AR6003_FETCH_TARG_REGS_COUNT];
-
-            if (ar->arTargetType == TARGET_TYPE_AR6003) {
-                ar6k_FetchTargetRegs(hifDevice, targregs);
-                if (copy_to_user((u32 *)rq->ifr_data, &targregs, sizeof(targregs)))
-                {
-                    ret = -EFAULT;
-                }
-            } else {
-                ret = -EOPNOTSUPP;
-            }
-            break;
-        }
-        case AR6000_XIOCTL_AP_SET_11BG_RATESET:
-        {
-            WMI_AP_SET_11BG_RATESET_CMD  rate;
-            if (ar->arWmiReady == false) {
-                ret = -EIO;
-            } else if (copy_from_user(&rate, userdata, sizeof(rate))) {
-                ret = -EFAULT;
-            } else {
-                wmi_ap_set_rateset(ar->arWmi, rate.rateset);
-            }
-            break;
-        }
-        case AR6000_XIOCTL_GET_WLAN_SLEEP_STATE:
-        {
-            WMI_REPORT_SLEEP_STATE_EVENT  wmiSleepEvent ;
-
-            if (ar->arWlanState == WLAN_ENABLED) {
-                wmiSleepEvent.sleepState = WMI_REPORT_SLEEP_STATUS_IS_AWAKE;
-            } else {
-                wmiSleepEvent.sleepState = WMI_REPORT_SLEEP_STATUS_IS_DEEP_SLEEP;
-            }
-            rq->ifr_ifru.ifru_ivalue = ar->arWlanState; /* return value */
-
-            ar6000_send_event_to_app(ar, WMI_REPORT_SLEEP_STATE_EVENTID, (u8 *)&wmiSleepEvent,
-                                     sizeof(WMI_REPORT_SLEEP_STATE_EVENTID));
-            break;
-        }
-#ifdef CONFIG_PM
-        case AR6000_XIOCTL_SET_BT_HW_POWER_STATE:
-        {
-            unsigned int state;
-           if (get_user(state, (unsigned int *)userdata)) {
-               ret = -EFAULT;
-               break;
-           }
-            if (ar6000_set_bt_hw_state(ar, state)!= 0) {
-                ret = -EIO;
-            }       
-        }
-            break;
-        case AR6000_XIOCTL_GET_BT_HW_POWER_STATE:
-            rq->ifr_ifru.ifru_ivalue = !ar->arBTOff; /* return value */
-            break;
-#endif
-
-        case AR6000_XIOCTL_WMI_SET_TX_SGI_PARAM:
-        {
-             WMI_SET_TX_SGI_PARAM_CMD SGICmd;
-
-             if (ar->arWmiReady == false) {
-                 ret = -EIO;
-             } else if (copy_from_user(&SGICmd, userdata,
-                                       sizeof(SGICmd))){
-                 ret = -EFAULT;
-             } else{
-                     if (wmi_SGI_cmd(ar->arWmi, SGICmd.sgiMask, SGICmd.sgiPERThreshold) != 0) {
-                         ret = -EIO;
-                     }
-
-             }
-             break;
-        }
-
-        case AR6000_XIOCTL_ADD_AP_INTERFACE:
-#ifdef CONFIG_AP_VIRTUAL_ADAPTER_SUPPORT
-        {
-            char ap_ifname[IFNAMSIZ] = {0,};
-            if (copy_from_user(ap_ifname, userdata, IFNAMSIZ)) {
-                ret = -EFAULT;
-            } else {
-                if (ar6000_add_ap_interface(ar, ap_ifname) != 0) {
-                    ret = -EIO;
-                } 
-            }
-        }
-#else
-            ret = -EOPNOTSUPP;
-#endif
-            break;
-        case AR6000_XIOCTL_REMOVE_AP_INTERFACE:
-#ifdef CONFIG_AP_VIRTUAL_ADAPTER_SUPPORT
-            if (ar6000_remove_ap_interface(ar) != 0) {
-                ret = -EIO;
-            } 
-#else
-            ret = -EOPNOTSUPP;
-#endif
-            break;
-
-        case AR6000_XIOCTL_WMI_SET_EXCESS_TX_RETRY_THRES:
-        {
-            ret = ar6000_xioctl_set_excess_tx_retry_thres_cmd(dev, userdata);
-            break;
-        }
-
-        default:
-            ret = -EOPNOTSUPP;
-    }
-
-ioctl_done:
-    rtnl_lock(); /* restore rtnl state */
-    dev_put(dev);
-
-    return ret;
-}
-
-u8 mac_cmp_wild(u8 *mac, u8 *new_mac, u8 wild, u8 new_wild)
-{
-    u8 i;
-
-    for(i=0;i<ATH_MAC_LEN;i++) {
-        if((wild & 1<<i) && (new_wild & 1<<i)) continue;
-        if(mac[i] != new_mac[i]) return 1;
-    }
-    if((memcmp(new_mac, null_mac, 6)==0) && new_wild &&
-        (wild != new_wild)) {
-        return 1;
-    }
-
-    return 0;
-}
-
-u8 acl_add_del_mac(WMI_AP_ACL *a, WMI_AP_ACL_MAC_CMD *acl)
-{
-    s8 already_avail=-1, free_slot=-1, i;
-
-    /* To check whether this mac is already there in our list */
-    for(i=AP_ACL_SIZE-1;i>=0;i--)
-    {
-        if(mac_cmp_wild(a->acl_mac[i], acl->mac, a->wildcard[i],
-            acl->wildcard)==0)
-                already_avail = i;
-
-        if(!((1 << i) & a->index))
-            free_slot = i;
-    }
-
-    if(acl->action == ADD_MAC_ADDR)
-    {
-        /* Dont add mac if it is already available */
-        if((already_avail >= 0) || (free_slot == -1))
-            return 0;
-
-        memcpy(a->acl_mac[free_slot], acl->mac, ATH_MAC_LEN);
-        a->index = a->index | (1 << free_slot);
-        acl->index = free_slot;
-        a->wildcard[free_slot] = acl->wildcard;
-        return 1;
-    }
-    else if(acl->action == DEL_MAC_ADDR)
-    {
-        if(acl->index > AP_ACL_SIZE)
-            return 0;
-
-        if(!(a->index & (1 << acl->index)))
-            return 0;
-
-        A_MEMZERO(a->acl_mac[acl->index],ATH_MAC_LEN);
-        a->index = a->index & ~(1 << acl->index);
-        a->wildcard[acl->index] = 0;
-        return 1;
-    }
-
-    return 0;
-}
index a9c96b315c4888319f629d9e1069e11d20f536c8..963a2fb76a9268c964716b6461993bd614524ce9 100644 (file)
@@ -22,7 +22,6 @@
 //------------------------------------------------------------------------------
 #include <a_config.h>
 #include "athdefs.h"
-#include "a_types.h"
 #include "a_osapi.h"
 #include "htc_packet.h"
 
diff --git a/drivers/staging/ath6kl/os/linux/wireless_ext.c b/drivers/staging/ath6kl/os/linux/wireless_ext.c
deleted file mode 100644 (file)
index 4b77943..0000000
+++ /dev/null
@@ -1,2723 +0,0 @@
-//------------------------------------------------------------------------------
-// Copyright (c) 2004-2010 Atheros Communications Inc.
-// All rights reserved.
-//
-// 
-//
-// Permission to use, copy, modify, and/or distribute this software for any
-// purpose with or without fee is hereby granted, provided that the above
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-//
-//
-//
-// Author(s): ="Atheros"
-//------------------------------------------------------------------------------
-
-#include "ar6000_drv.h"
-
-#define IWE_STREAM_ADD_EVENT(p1, p2, p3, p4, p5) \
-    iwe_stream_add_event((p1), (p2), (p3), (p4), (p5))
-
-#define IWE_STREAM_ADD_POINT(p1, p2, p3, p4, p5) \
-    iwe_stream_add_point((p1), (p2), (p3), (p4), (p5))
-
-#define IWE_STREAM_ADD_VALUE(p1, p2, p3, p4, p5, p6) \
-    iwe_stream_add_value((p1), (p2), (p3), (p4), (p5), (p6))
-
-static void ar6000_set_quality(struct iw_quality *iq, s8 rssi);
-extern unsigned int wmitimeout;
-extern A_WAITQUEUE_HEAD arEvent;
-
-#if WIRELESS_EXT > 14
-/*
- * Encode a WPA or RSN information element as a custom
- * element using the hostap format.
- */
-static u_int
-encode_ie(void *buf, size_t bufsize,
-    const u_int8_t *ie, size_t ielen,
-    const char *leader, size_t leader_len)
-{
-    u_int8_t *p;
-    int i;
-
-    if (bufsize < leader_len)
-        return 0;
-    p = buf;
-    memcpy(p, leader, leader_len);
-    bufsize -= leader_len;
-    p += leader_len;
-    for (i = 0; i < ielen && bufsize > 2; i++)
-    {
-        p += sprintf((char*)p, "%02x", ie[i]);
-        bufsize -= 2;
-    }
-    return (i == ielen ? p - (u_int8_t *)buf : 0);
-}
-#endif /* WIRELESS_EXT > 14 */
-
-static u8 get_bss_phy_capability(bss_t *bss)
-{
-    u8 capability = 0;
-    struct ieee80211_common_ie *cie = &bss->ni_cie;
-#define CHAN_IS_11A(x)              (!((x >= 2412) && (x <= 2484)))
-    if (CHAN_IS_11A(cie->ie_chan)) {
-        if (cie->ie_htcap) {
-            capability = WMI_11NA_CAPABILITY;
-        } else {
-            capability = WMI_11A_CAPABILITY;
-        }
-    } else if ((cie->ie_erp) || (cie->ie_xrates)) {
-        if (cie->ie_htcap) {
-            capability = WMI_11NG_CAPABILITY;
-        } else {
-            capability = WMI_11G_CAPABILITY;
-        }
-    }
-    return capability;
-}
-
-void
-ar6000_scan_node(void *arg, bss_t *ni)
-{
-    struct iw_event iwe;
-#if WIRELESS_EXT > 14
-    char buf[256];
-#endif
-    struct ar_giwscan_param *param;
-    char *current_ev;
-    char *end_buf;
-    struct ieee80211_common_ie  *cie;
-    char *current_val;
-    s32 j;
-    u32 rate_len, data_len = 0;
-
-    param = (struct ar_giwscan_param *)arg;
-
-    current_ev = param->current_ev;
-    end_buf = param->end_buf;
-
-    cie = &ni->ni_cie;
-
-    if ((end_buf - current_ev) > IW_EV_ADDR_LEN)
-    {
-        A_MEMZERO(&iwe, sizeof(iwe));
-        iwe.cmd = SIOCGIWAP;
-        iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
-        memcpy(iwe.u.ap_addr.sa_data, ni->ni_macaddr, 6);
-        current_ev = IWE_STREAM_ADD_EVENT(param->info, current_ev, end_buf,
-                                          &iwe, IW_EV_ADDR_LEN);
-    }
-    param->bytes_needed += IW_EV_ADDR_LEN;
-
-    data_len = cie->ie_ssid[1] + IW_EV_POINT_LEN;
-    if ((end_buf - current_ev) > data_len)
-    {
-        A_MEMZERO(&iwe, sizeof(iwe));
-        iwe.cmd = SIOCGIWESSID;
-        iwe.u.data.flags = 1;
-        iwe.u.data.length = cie->ie_ssid[1];
-        current_ev = IWE_STREAM_ADD_POINT(param->info, current_ev, end_buf,
-                                          &iwe, (char*)&cie->ie_ssid[2]);
-    }
-    param->bytes_needed += data_len;
-
-    if (cie->ie_capInfo & (IEEE80211_CAPINFO_ESS|IEEE80211_CAPINFO_IBSS)) {
-        if ((end_buf - current_ev) > IW_EV_UINT_LEN)
-        {
-            A_MEMZERO(&iwe, sizeof(iwe));
-            iwe.cmd = SIOCGIWMODE;
-            iwe.u.mode = cie->ie_capInfo & IEEE80211_CAPINFO_ESS ?
-                         IW_MODE_MASTER : IW_MODE_ADHOC;
-            current_ev = IWE_STREAM_ADD_EVENT(param->info, current_ev, end_buf,
-                                              &iwe, IW_EV_UINT_LEN);
-        }
-        param->bytes_needed += IW_EV_UINT_LEN;
-    }
-
-    if ((end_buf - current_ev) > IW_EV_FREQ_LEN)
-    {
-        A_MEMZERO(&iwe, sizeof(iwe));
-        iwe.cmd = SIOCGIWFREQ;
-        iwe.u.freq.m = cie->ie_chan * 100000;
-        iwe.u.freq.e = 1;
-        current_ev = IWE_STREAM_ADD_EVENT(param->info, current_ev, end_buf,
-                                          &iwe, IW_EV_FREQ_LEN);
-    }
-    param->bytes_needed += IW_EV_FREQ_LEN;
-
-    if ((end_buf - current_ev) > IW_EV_QUAL_LEN)
-    {
-        A_MEMZERO(&iwe, sizeof(iwe));
-        iwe.cmd = IWEVQUAL;
-        ar6000_set_quality(&iwe.u.qual, ni->ni_snr);
-        current_ev = IWE_STREAM_ADD_EVENT(param->info, current_ev, end_buf,
-                                          &iwe, IW_EV_QUAL_LEN);
-    }
-    param->bytes_needed += IW_EV_QUAL_LEN;
-
-    if ((end_buf - current_ev) > IW_EV_POINT_LEN)
-    {
-        A_MEMZERO(&iwe, sizeof(iwe));
-        iwe.cmd = SIOCGIWENCODE;
-        if (cie->ie_capInfo & IEEE80211_CAPINFO_PRIVACY) {
-            iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
-        } else {
-            iwe.u.data.flags = IW_ENCODE_DISABLED;
-        }
-        iwe.u.data.length = 0;
-        current_ev = IWE_STREAM_ADD_POINT(param->info, current_ev, end_buf,
-                                          &iwe, "");
-    }
-    param->bytes_needed += IW_EV_POINT_LEN;
-
-    /* supported bit rate */
-    A_MEMZERO(&iwe, sizeof(iwe));
-    iwe.cmd = SIOCGIWRATE;
-    iwe.u.bitrate.fixed = 0;
-    iwe.u.bitrate.disabled = 0;
-    iwe.u.bitrate.value = 0;
-    current_val = current_ev + IW_EV_LCP_LEN;
-    param->bytes_needed += IW_EV_LCP_LEN;
-
-    if (cie->ie_rates != NULL) {
-        rate_len = cie->ie_rates[1];
-        data_len = (rate_len * (IW_EV_PARAM_LEN - IW_EV_LCP_LEN));
-        if ((end_buf - current_ev) > data_len)
-        {
-            for (j = 0; j < rate_len; j++) {
-                    unsigned char val;
-                    val = cie->ie_rates[2 + j];
-                    iwe.u.bitrate.value =
-                        (val >= 0x80)? ((val - 0x80) * 500000): (val * 500000);
-                    current_val = IWE_STREAM_ADD_VALUE(param->info, current_ev,
-                                                       current_val, end_buf,
-                                                       &iwe, IW_EV_PARAM_LEN);
-            }
-        }
-        param->bytes_needed += data_len;
-    }
-
-    if (cie->ie_xrates != NULL) {
-        rate_len = cie->ie_xrates[1];
-        data_len = (rate_len * (IW_EV_PARAM_LEN - IW_EV_LCP_LEN));
-        if ((end_buf - current_ev) > data_len)
-        {
-            for (j = 0; j < rate_len; j++) {
-                    unsigned char val;
-                    val = cie->ie_xrates[2 + j];
-                    iwe.u.bitrate.value =
-                        (val >= 0x80)? ((val - 0x80) * 500000): (val * 500000);
-                    current_val = IWE_STREAM_ADD_VALUE(param->info, current_ev,
-                                                       current_val, end_buf,
-                                                       &iwe, IW_EV_PARAM_LEN);
-            }
-        }
-        param->bytes_needed += data_len;
-    }
-    /* remove fixed header if no rates were added */
-    if ((current_val - current_ev) > IW_EV_LCP_LEN)
-        current_ev = current_val;
-
-#if WIRELESS_EXT >= 18
-    /* IE */
-    if (cie->ie_wpa != NULL) {
-        data_len = cie->ie_wpa[1] + 2 + IW_EV_POINT_LEN;
-        if ((end_buf - current_ev) > data_len)
-        {
-            A_MEMZERO(&iwe, sizeof(iwe));
-            iwe.cmd = IWEVGENIE;
-            iwe.u.data.length = cie->ie_wpa[1] + 2;
-            current_ev = IWE_STREAM_ADD_POINT(param->info, current_ev, end_buf,
-                                              &iwe, (char*)cie->ie_wpa);
-        }
-        param->bytes_needed += data_len;
-    }
-
-    if (cie->ie_rsn != NULL && cie->ie_rsn[0] == IEEE80211_ELEMID_RSN) {
-        data_len = cie->ie_rsn[1] + 2 + IW_EV_POINT_LEN;
-        if ((end_buf - current_ev) > data_len)
-        {
-            A_MEMZERO(&iwe, sizeof(iwe));
-            iwe.cmd = IWEVGENIE;
-            iwe.u.data.length = cie->ie_rsn[1] + 2;
-            current_ev = IWE_STREAM_ADD_POINT(param->info, current_ev, end_buf,
-                                              &iwe, (char*)cie->ie_rsn);
-        }
-        param->bytes_needed += data_len;
-    }
-
-#endif /* WIRELESS_EXT >= 18 */
-
-    if ((end_buf - current_ev) > IW_EV_CHAR_LEN)
-    {
-        /* protocol */
-        A_MEMZERO(&iwe, sizeof(iwe));
-        iwe.cmd = SIOCGIWNAME;
-        switch (get_bss_phy_capability(ni)) {
-        case WMI_11A_CAPABILITY:
-            snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11a");
-            break;
-        case WMI_11G_CAPABILITY:
-            snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11g");
-            break;
-        case WMI_11NA_CAPABILITY:
-            snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11na");
-            break;
-        case WMI_11NG_CAPABILITY:
-            snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11ng");
-            break;
-        default:
-            snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11b");
-            break;
-        }
-        current_ev = IWE_STREAM_ADD_EVENT(param->info, current_ev, end_buf,
-                                          &iwe, IW_EV_CHAR_LEN);
-    }
-    param->bytes_needed += IW_EV_CHAR_LEN;
-
-#if WIRELESS_EXT > 14
-    A_MEMZERO(&iwe, sizeof(iwe));
-    iwe.cmd = IWEVCUSTOM;
-    iwe.u.data.length = snprintf(buf, sizeof(buf), "bcn_int=%d", cie->ie_beaconInt);
-    data_len = iwe.u.data.length + IW_EV_POINT_LEN;
-    if ((end_buf - current_ev) > data_len)
-    {
-        current_ev = IWE_STREAM_ADD_POINT(param->info, current_ev, end_buf,
-                                          &iwe, buf);
-    }
-    param->bytes_needed += data_len;
-
-#if WIRELESS_EXT < 18
-    if (cie->ie_wpa != NULL) {
-        static const char wpa_leader[] = "wpa_ie=";
-        data_len = (sizeof(wpa_leader) - 1) + ((cie->ie_wpa[1]+2) * 2) + IW_EV_POINT_LEN;
-        if ((end_buf - current_ev) > data_len)
-        {
-            A_MEMZERO(&iwe, sizeof(iwe));
-            iwe.cmd = IWEVCUSTOM;
-            iwe.u.data.length = encode_ie(buf, sizeof(buf), cie->ie_wpa,
-                                          cie->ie_wpa[1]+2,
-                                          wpa_leader, sizeof(wpa_leader)-1);
-
-            if (iwe.u.data.length != 0) {
-                current_ev = IWE_STREAM_ADD_POINT(param->info, current_ev, 
-                                                  end_buf, &iwe, buf);
-            }
-        }
-        param->bytes_needed += data_len;
-    }
-
-    if (cie->ie_rsn != NULL && cie->ie_rsn[0] == IEEE80211_ELEMID_RSN) {
-        static const char rsn_leader[] = "rsn_ie=";
-        data_len = (sizeof(rsn_leader) - 1) + ((cie->ie_rsn[1]+2) * 2) + IW_EV_POINT_LEN;
-        if ((end_buf - current_ev) > data_len)
-        {
-            A_MEMZERO(&iwe, sizeof(iwe));
-            iwe.cmd = IWEVCUSTOM;
-            iwe.u.data.length = encode_ie(buf, sizeof(buf), cie->ie_rsn,
-                                          cie->ie_rsn[1]+2,
-                                          rsn_leader, sizeof(rsn_leader)-1);
-
-            if (iwe.u.data.length != 0) {
-                current_ev = IWE_STREAM_ADD_POINT(param->info, current_ev, 
-                                                  end_buf, &iwe, buf);
-            }
-        }
-        param->bytes_needed += data_len;
-    }
-#endif /* WIRELESS_EXT < 18 */
-
-    if (cie->ie_wmm != NULL) {
-        static const char wmm_leader[] = "wmm_ie=";
-        data_len = (sizeof(wmm_leader) - 1) + ((cie->ie_wmm[1]+2) * 2) + IW_EV_POINT_LEN;
-        if ((end_buf - current_ev) > data_len)
-        {
-            A_MEMZERO(&iwe, sizeof(iwe));
-            iwe.cmd = IWEVCUSTOM;
-            iwe.u.data.length = encode_ie(buf, sizeof(buf), cie->ie_wmm,
-                                          cie->ie_wmm[1]+2,
-                                          wmm_leader, sizeof(wmm_leader)-1);
-            if (iwe.u.data.length != 0) {
-                current_ev = IWE_STREAM_ADD_POINT(param->info, current_ev,
-                                                  end_buf, &iwe, buf);
-            }
-        }
-        param->bytes_needed += data_len;
-    }
-
-    if (cie->ie_ath != NULL) {
-        static const char ath_leader[] = "ath_ie=";
-        data_len = (sizeof(ath_leader) - 1) + ((cie->ie_ath[1]+2) * 2) + IW_EV_POINT_LEN;
-        if ((end_buf - current_ev) > data_len)
-        {
-            A_MEMZERO(&iwe, sizeof(iwe));
-            iwe.cmd = IWEVCUSTOM;
-            iwe.u.data.length = encode_ie(buf, sizeof(buf), cie->ie_ath,
-                                          cie->ie_ath[1]+2,
-                                          ath_leader, sizeof(ath_leader)-1);
-            if (iwe.u.data.length != 0) {
-                current_ev = IWE_STREAM_ADD_POINT(param->info, current_ev,
-                                                  end_buf, &iwe, buf);
-            }
-        }
-        param->bytes_needed += data_len;
-    }
-
-#ifdef WAPI_ENABLE
-    if (cie->ie_wapi != NULL) {
-        static const char wapi_leader[] = "wapi_ie=";
-        data_len = (sizeof(wapi_leader) - 1) + ((cie->ie_wapi[1] + 2) * 2) + IW_EV_POINT_LEN;
-        if ((end_buf - current_ev) > data_len) {
-            A_MEMZERO(&iwe, sizeof(iwe));
-            iwe.cmd = IWEVCUSTOM;
-            iwe.u.data.length = encode_ie(buf, sizeof(buf), cie->ie_wapi,
-                                      cie->ie_wapi[1] + 2,
-                                      wapi_leader, sizeof(wapi_leader) - 1);
-            if (iwe.u.data.length != 0) {
-                current_ev = IWE_STREAM_ADD_POINT(param->info, current_ev,
-                                                  end_buf, &iwe, buf);
-            }
-        }
-        param->bytes_needed += data_len;
-    }
-#endif /* WAPI_ENABLE */
-
-#endif /* WIRELESS_EXT > 14 */
-
-#if WIRELESS_EXT >= 18
-    if (cie->ie_wsc != NULL) {
-        data_len = (cie->ie_wsc[1] + 2) + IW_EV_POINT_LEN;
-        if ((end_buf - current_ev) > data_len)
-        {
-            A_MEMZERO(&iwe, sizeof(iwe));
-            iwe.cmd = IWEVGENIE;
-            iwe.u.data.length = cie->ie_wsc[1] + 2;
-            current_ev = IWE_STREAM_ADD_POINT(param->info, current_ev, end_buf,
-                                              &iwe, (char*)cie->ie_wsc);
-        }
-        param->bytes_needed += data_len;
-    }
-#endif /* WIRELESS_EXT >= 18 */
-
-    param->current_ev = current_ev;
-}
-
-int
-ar6000_ioctl_giwscan(struct net_device *dev,
-            struct iw_request_info *info,
-            struct iw_point *data, char *extra)
-{
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-    struct ar_giwscan_param param;
-
-    if (is_iwioctl_allowed(ar->arNextMode, info->cmd) != 0) {
-        A_PRINTF("wext_ioctl: cmd=0x%x not allowed in this mode\n", info->cmd);
-        return -EOPNOTSUPP;
-    }
-
-    if (ar->arWlanState == WLAN_DISABLED) {
-        return -EIO;
-    }
-
-    if (ar->arWmiReady == false) {
-        return -EIO;
-    }
-
-    param.current_ev = extra;
-    param.end_buf = extra + data->length;
-    param.bytes_needed = 0;
-    param.info = info;
-
-    /* Translate data to WE format */
-    wmi_iterate_nodes(ar->arWmi, ar6000_scan_node, &param);
-
-    /* check if bytes needed is greater than bytes consumed */
-    if (param.bytes_needed > (param.current_ev - extra))
-    {
-        /* Request one byte more than needed, because when "data->length" equals bytes_needed,
-        it is not possible to add the last event data as all iwe_stream_add_xxxxx() functions
-        checks whether (cur_ptr + ev_len) < end_ptr, due to this one more retry would happen*/
-        data->length = param.bytes_needed + 1;
-
-        return -E2BIG;
-    }
-
-    return 0;
-}
-
-extern int reconnect_flag;
-/* SIOCSIWESSID */
-static int
-ar6000_ioctl_siwessid(struct net_device *dev,
-                     struct iw_request_info *info,
-                     struct iw_point *data, char *ssid)
-{
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-    int status;
-    u8 arNetworkType;
-    u8 prevMode = ar->arNetworkType;
-
-    if (is_iwioctl_allowed(ar->arNextMode, info->cmd) != 0) {
-        A_PRINTF("wext_ioctl: cmd=0x%x not allowed in this mode\n", info->cmd);
-        return -EOPNOTSUPP;
-    }
-
-    if (ar->bIsDestroyProgress) {
-        return -EBUSY;
-    }
-
-    if (ar->arWlanState == WLAN_DISABLED) {
-        return -EIO;
-    }
-
-    if (ar->arWmiReady == false) {
-        return -EIO;
-    }
-
-#if defined(WIRELESS_EXT)
-    if (WIRELESS_EXT >= 20) {
-        data->length += 1;
-    }
-#endif
-
-    /*
-     * iwconfig passes a null terminated string with length including this
-     * so we need to account for this
-     */
-    if (data->flags && (!data->length || (data->length == 1) ||
-        ((data->length - 1) > sizeof(ar->arSsid))))
-    {
-        /*
-         * ssid is invalid
-         */
-        return -EINVAL;
-    }
-
-    if (ar->arNextMode == AP_NETWORK) {
-        /* SSID change for AP network - Will take effect on commit */
-        if(memcmp(ar->arSsid,ssid,32) != 0) {
-             ar->arSsidLen = data->length - 1;
-            memcpy(ar->arSsid, ssid, ar->arSsidLen);
-            ar->ap_profile_flag = 1; /* There is a change in profile */
-        }
-        return 0;
-    } else if(ar->arNetworkType == AP_NETWORK) {
-        u8 ctr;
-        struct sk_buff *skb;
-
-        /* We are switching from AP to STA | IBSS mode, cleanup the AP state */
-        for (ctr=0; ctr < AP_MAX_NUM_STA; ctr++) {
-            remove_sta(ar, ar->sta_list[ctr].mac, 0);
-        }
-        A_MUTEX_LOCK(&ar->mcastpsqLock);
-        while (!A_NETBUF_QUEUE_EMPTY(&ar->mcastpsq)) {
-            skb = A_NETBUF_DEQUEUE(&ar->mcastpsq);
-            A_NETBUF_FREE(skb);
-        }
-        A_MUTEX_UNLOCK(&ar->mcastpsqLock);
-    }
-
-    /* Added for bug 25178, return an IOCTL error instead of target returning
-       Illegal parameter error when either the BSSID or channel is missing
-       and we cannot scan during connect.
-     */
-    if (data->flags) {
-        if (ar->arSkipScan == true &&
-            (ar->arChannelHint == 0 ||
-             (!ar->arReqBssid[0] && !ar->arReqBssid[1] && !ar->arReqBssid[2] &&
-              !ar->arReqBssid[3] && !ar->arReqBssid[4] && !ar->arReqBssid[5])))
-        {
-            return -EINVAL;
-        }
-    }
-
-    if (down_interruptible(&ar->arSem)) {
-        return -ERESTARTSYS;
-    }
-
-    if (ar->bIsDestroyProgress || ar->arWlanState == WLAN_DISABLED) {
-        up(&ar->arSem);
-        return -EBUSY;
-    }
-
-    if (ar->arTxPending[wmi_get_control_ep(ar->arWmi)]) {
-        /*
-         * sleep until the command queue drains
-         */
-        wait_event_interruptible_timeout(arEvent,
-            ar->arTxPending[wmi_get_control_ep(ar->arWmi)] == 0, wmitimeout * HZ);
-        if (signal_pending(current)) {
-            return -EINTR;
-        }
-    }
-
-    if (!data->flags) {
-        arNetworkType = ar->arNetworkType;
-#ifdef ATH6K_CONFIG_CFG80211
-        if (ar->arConnected) {
-#endif /* ATH6K_CONFIG_CFG80211 */
-            ar6000_init_profile_info(ar);
-#ifdef ATH6K_CONFIG_CFG80211
-        }
-#endif /* ATH6K_CONFIG_CFG80211 */
-        ar->arNetworkType = arNetworkType;
-    }
-
-    /* Update the arNetworkType */
-    ar->arNetworkType = ar->arNextMode;
-
-    if ((prevMode != AP_NETWORK) &&
-        ((ar->arSsidLen) || 
-        ((ar->arSsidLen == 0) && (ar->arConnected || ar->arConnectPending)) || 
-        (!data->flags)))
-    {
-        if ((!data->flags) ||
-            (memcmp(ar->arSsid, ssid, ar->arSsidLen) != 0) ||
-            (ar->arSsidLen != (data->length - 1)))
-        {
-            /*
-             * SSID set previously or essid off has been issued.
-             *
-             * Disconnect Command is issued in two cases after wmi is ready
-             * (1) ssid is different from the previous setting
-             * (2) essid off has been issued
-             *
-             */
-            if (ar->arWmiReady == true) {
-                reconnect_flag = 0;
-                status = wmi_setPmkid_cmd(ar->arWmi, ar->arBssid, NULL, 0);
-                ar6000_disconnect(ar);
-                A_MEMZERO(ar->arSsid, sizeof(ar->arSsid));
-                ar->arSsidLen = 0;
-                if (ar->arSkipScan == false) {
-                    A_MEMZERO(ar->arReqBssid, sizeof(ar->arReqBssid));
-                }
-                if (!data->flags) {
-                    up(&ar->arSem);
-                    return 0;
-                }
-            } else {
-                 up(&ar->arSem);
-            }
-        }
-        else
-        {
-            /*
-             * SSID is same, so we assume profile hasn't changed.
-             * If the interface is up and wmi is ready, we issue
-             * a reconnect cmd. Issue a reconnect only we are already
-             * connected.
-             */
-            if((ar->arConnected == true) && (ar->arWmiReady == true))
-            {
-                reconnect_flag = true;
-                status = wmi_reconnect_cmd(ar->arWmi,ar->arReqBssid,
-                                           ar->arChannelHint);
-                up(&ar->arSem);
-                if (status) {
-                    return -EIO;
-                }
-                return 0;
-            }
-            else{
-                /*
-                 * Dont return if connect is pending.
-                 */
-                if(!(ar->arConnectPending)) {
-                    up(&ar->arSem);
-                    return 0;
-                }
-            }
-        }
-    }
-
-    ar->arSsidLen = data->length - 1;
-    memcpy(ar->arSsid, ssid, ar->arSsidLen);
-
-    if (ar6000_connect_to_ap(ar)!= 0) {
-        up(&ar->arSem);
-        return -EIO;
-    }else{
-      up(&ar->arSem);
-    }
-    return 0;
-}
-
-/* SIOCGIWESSID */
-static int
-ar6000_ioctl_giwessid(struct net_device *dev,
-                     struct iw_request_info *info,
-                     struct iw_point *data, char *essid)
-{
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-
-    if (is_iwioctl_allowed(ar->arNextMode, info->cmd) != 0) {
-        A_PRINTF("wext_ioctl: cmd=0x%x not allowed in this mode\n", info->cmd);
-        return -EOPNOTSUPP;
-    }
-
-    if (ar->arWlanState == WLAN_DISABLED) {
-        return -EIO;
-    }
-
-    if (!ar->arSsidLen) {
-        return -EINVAL;
-    }
-
-    data->flags = 1;
-    data->length = ar->arSsidLen;
-    memcpy(essid, ar->arSsid, ar->arSsidLen);
-
-    return 0;
-}
-
-
-void ar6000_install_static_wep_keys(struct ar6_softc *ar)
-{
-    u8 index;
-    u8 keyUsage;
-
-    for (index = WMI_MIN_KEY_INDEX; index <= WMI_MAX_KEY_INDEX; index++) {
-        if (ar->arWepKeyList[index].arKeyLen) {
-            keyUsage = GROUP_USAGE;
-            if (index == ar->arDefTxKeyIndex) {
-                keyUsage |= TX_USAGE;
-            }
-            wmi_addKey_cmd(ar->arWmi,
-                           index,
-                           WEP_CRYPT,
-                           keyUsage,
-                           ar->arWepKeyList[index].arKeyLen,
-                           NULL,
-                           ar->arWepKeyList[index].arKey, KEY_OP_INIT_VAL, NULL,
-                           NO_SYNC_WMIFLAG);
-        }
-    }
-}
-
-/*
- * SIOCSIWRATE
- */
-int
-ar6000_ioctl_siwrate(struct net_device *dev,
-            struct iw_request_info *info,
-            struct iw_param *rrq, char *extra)
-{
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-    u32 kbps;
-    s8 rate_idx;
-
-    if (is_iwioctl_allowed(ar->arNextMode, info->cmd) != 0) {
-        A_PRINTF("wext_ioctl: cmd=0x%x not allowed in this mode\n", info->cmd);
-        return -EOPNOTSUPP;
-    }
-
-    if (rrq->fixed) {
-        kbps = rrq->value / 1000;           /* rrq->value is in bps */
-    } else {
-        kbps = -1;                          /* -1 indicates auto rate */
-    }
-    if(kbps != -1 && wmi_validate_bitrate(ar->arWmi, kbps, &rate_idx) != 0)
-    {
-        AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("BitRate is not Valid %d\n", kbps));
-        return -EINVAL;
-    }
-    ar->arBitRate = kbps;
-    if(ar->arWmiReady == true)
-    {
-        if (wmi_set_bitrate_cmd(ar->arWmi, kbps, -1, -1) != 0) {
-            return -EINVAL;
-        }
-    }
-    return 0;
-}
-
-/*
- * SIOCGIWRATE
- */
-int
-ar6000_ioctl_giwrate(struct net_device *dev,
-            struct iw_request_info *info,
-            struct iw_param *rrq, char *extra)
-{
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-    int ret = 0;
-
-    if (is_iwioctl_allowed(ar->arNextMode, info->cmd) != 0) {
-        A_PRINTF("wext_ioctl: cmd=0x%x not allowed in this mode\n", info->cmd);
-        return -EOPNOTSUPP;
-    }
-
-    if (ar->bIsDestroyProgress) {
-        return -EBUSY;
-    }
-
-    if (ar->arWlanState == WLAN_DISABLED) {
-        return -EIO;
-    }
-
-    if ((ar->arNextMode != AP_NETWORK && !ar->arConnected) || ar->arWmiReady == false) {
-        rrq->value = 1000 * 1000;       
-        return 0;
-    }
-
-    if (down_interruptible(&ar->arSem)) {
-        return -ERESTARTSYS;
-    }
-
-    if (ar->bIsDestroyProgress || ar->arWlanState == WLAN_DISABLED) {
-        up(&ar->arSem);
-        return -EBUSY;
-    }
-
-    ar->arBitRate = 0xFFFF;
-    if (wmi_get_bitrate_cmd(ar->arWmi) != 0) {
-        up(&ar->arSem);
-        return -EIO;
-    }
-    wait_event_interruptible_timeout(arEvent, ar->arBitRate != 0xFFFF, wmitimeout * HZ);
-    if (signal_pending(current)) {
-        ret = -EINTR;
-    }
-    /* If the interface is down or wmi is not ready or the target is not
-       connected - return the value stored in the device structure */
-    if (!ret) {
-        if (ar->arBitRate == -1) {
-            rrq->fixed = true;
-            rrq->value = 0;
-        } else {
-            rrq->value = ar->arBitRate * 1000;
-        }
-    }
-
-    up(&ar->arSem);
-
-    return ret;
-}
-
-/*
- * SIOCSIWTXPOW
- */
-static int
-ar6000_ioctl_siwtxpow(struct net_device *dev,
-             struct iw_request_info *info,
-             struct iw_param *rrq, char *extra)
-{
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-    u8 dbM;
-
-    if (is_iwioctl_allowed(ar->arNextMode, info->cmd) != 0) {
-        A_PRINTF("wext_ioctl: cmd=0x%x not allowed in this mode\n", info->cmd);
-        return -EOPNOTSUPP;
-    }
-
-    if (ar->arWlanState == WLAN_DISABLED) {
-        return -EIO;
-    }
-
-    if (rrq->disabled) {
-        return -EOPNOTSUPP;
-    }
-
-    if (rrq->fixed) {
-        if (rrq->flags != IW_TXPOW_DBM) {
-            return -EOPNOTSUPP;
-        }
-        ar->arTxPwr= dbM = rrq->value;
-        ar->arTxPwrSet = true;
-    } else {
-        ar->arTxPwr = dbM = 0;
-        ar->arTxPwrSet = false;
-    }
-    if(ar->arWmiReady == true)
-    {
-        AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_TX,("Set tx pwr cmd %d dbM\n", dbM));
-        wmi_set_txPwr_cmd(ar->arWmi, dbM);
-    }
-    return 0;
-}
-
-/*
- * SIOCGIWTXPOW
- */
-int
-ar6000_ioctl_giwtxpow(struct net_device *dev,
-            struct iw_request_info *info,
-            struct iw_param *rrq, char *extra)
-{
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-    int ret = 0;
-
-    if (is_iwioctl_allowed(ar->arNextMode, info->cmd) != 0) {
-        A_PRINTF("wext_ioctl: cmd=0x%x not allowed in this mode\n", info->cmd);
-        return -EOPNOTSUPP;
-    }
-
-    if (ar->bIsDestroyProgress) {
-        return -EBUSY;
-    }
-
-    if (ar->arWlanState == WLAN_DISABLED) {
-        return -EIO;
-    }
-
-    if (down_interruptible(&ar->arSem)) {
-        return -ERESTARTSYS;
-    }
-
-    if (ar->bIsDestroyProgress) {
-        up(&ar->arSem);
-        return -EBUSY;
-    }
-
-    if((ar->arWmiReady == true) && (ar->arConnected == true))
-    {
-        ar->arTxPwr = 0;
-
-        if (wmi_get_txPwr_cmd(ar->arWmi) != 0) {
-            up(&ar->arSem);
-            return -EIO;
-        }
-
-        wait_event_interruptible_timeout(arEvent, ar->arTxPwr != 0, wmitimeout * HZ);
-
-        if (signal_pending(current)) {
-            ret = -EINTR;
-         }
-    }
-   /* If the interace is down or wmi is not ready or target is not connected
-      then return value stored in the device structure */
-
-    if (!ret) {
-         if (ar->arTxPwrSet == true) {
-            rrq->fixed = true;
-        }
-        rrq->value = ar->arTxPwr;
-        rrq->flags = IW_TXPOW_DBM;
-        //
-        // IWLIST need this flag to get TxPower
-        //
-        rrq->disabled = 0;
-    }
-
-    up(&ar->arSem);
-
-    return ret;
-}
-
-/*
- * SIOCSIWRETRY
- * since iwconfig only provides us with one max retry value, we use it
- * to apply to data frames of the BE traffic class.
- */
-static int
-ar6000_ioctl_siwretry(struct net_device *dev,
-             struct iw_request_info *info,
-             struct iw_param *rrq, char *extra)
-{
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-
-    if (is_iwioctl_allowed(ar->arNextMode, info->cmd) != 0) {
-        A_PRINTF("wext_ioctl: cmd=0x%x not allowed in this mode\n", info->cmd);
-        return -EOPNOTSUPP;
-    }
-
-    if (ar->arWlanState == WLAN_DISABLED) {
-        return -EIO;
-    }
-
-    if (rrq->disabled) {
-        return -EOPNOTSUPP;
-    }
-
-    if ((rrq->flags & IW_RETRY_TYPE) != IW_RETRY_LIMIT) {
-        return -EOPNOTSUPP;
-    }
-
-    if ( !(rrq->value >= WMI_MIN_RETRIES) || !(rrq->value <= WMI_MAX_RETRIES)) {
-            return - EINVAL;
-    }
-    if(ar->arWmiReady == true)
-    {
-        if (wmi_set_retry_limits_cmd(ar->arWmi, DATA_FRAMETYPE, WMM_AC_BE,
-                                     rrq->value, 0) != 0){
-            return -EINVAL;
-        }
-    }
-    ar->arMaxRetries = rrq->value;
-    return 0;
-}
-
-/*
- * SIOCGIWRETRY
- */
-static int
-ar6000_ioctl_giwretry(struct net_device *dev,
-             struct iw_request_info *info,
-             struct iw_param *rrq, char *extra)
-{
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-
-    if (is_iwioctl_allowed(ar->arNextMode, info->cmd) != 0) {
-        A_PRINTF("wext_ioctl: cmd=0x%x not allowed in this mode\n", info->cmd);
-        return -EOPNOTSUPP;
-    }
-
-    if (ar->arWlanState == WLAN_DISABLED) {
-        return -EIO;
-    }
-
-    rrq->disabled = 0;
-    switch (rrq->flags & IW_RETRY_TYPE) {
-    case IW_RETRY_LIFETIME:
-        return -EOPNOTSUPP;
-        break;
-    case IW_RETRY_LIMIT:
-        rrq->flags = IW_RETRY_LIMIT;
-        switch (rrq->flags & IW_RETRY_MODIFIER) {
-        case IW_RETRY_MIN:
-            rrq->flags |= IW_RETRY_MIN;
-            rrq->value = WMI_MIN_RETRIES;
-            break;
-        case IW_RETRY_MAX:
-            rrq->flags |= IW_RETRY_MAX;
-            rrq->value = ar->arMaxRetries;
-            break;
-        }
-        break;
-    }
-    return 0;
-}
-
-/*
- * SIOCSIWENCODE
- */
-static int
-ar6000_ioctl_siwencode(struct net_device *dev,
-              struct iw_request_info *info,
-              struct iw_point *erq, char *keybuf)
-{
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-    int index;
-    s32 auth = 0;
-
-    if (is_iwioctl_allowed(ar->arNextMode, info->cmd) != 0) {
-        A_PRINTF("wext_ioctl: cmd=0x%x not allowed in this mode\n", info->cmd);
-        return -EOPNOTSUPP;
-    }
-
-    if(ar->arNextMode != AP_NETWORK) {
-    /*
-     *  Static WEP Keys should be configured before setting the SSID
-     */
-    if (ar->arSsid[0] && erq->length) {
-        return -EIO;
-    }
-    }
-
-    if (ar->arWlanState == WLAN_DISABLED) {
-        return -EIO;
-    }
-
-    index = erq->flags & IW_ENCODE_INDEX;
-
-    if (index && (((index - 1) < WMI_MIN_KEY_INDEX) ||
-                  ((index - 1) > WMI_MAX_KEY_INDEX)))
-    {
-        return -EIO;
-    }
-
-    if (erq->flags & IW_ENCODE_DISABLED) {
-        /*
-         * Encryption disabled
-         */
-        if (index) {
-            /*
-             * If key index was specified then clear the specified key
-             */
-            index--;
-            A_MEMZERO(ar->arWepKeyList[index].arKey,
-                      sizeof(ar->arWepKeyList[index].arKey));
-            ar->arWepKeyList[index].arKeyLen = 0;
-        }
-        ar->arDot11AuthMode       = OPEN_AUTH;
-        ar->arPairwiseCrypto      = NONE_CRYPT;
-        ar->arGroupCrypto         = NONE_CRYPT;
-        ar->arAuthMode            = NONE_AUTH;
-    } else {
-        /*
-         * Enabling WEP encryption
-         */
-        if (index) {
-            index--;                /* keyindex is off base 1 in iwconfig */
-        }
-
-        if (erq->flags & IW_ENCODE_OPEN) {
-            auth |= OPEN_AUTH;
-            ar->arDefTxKeyIndex = index;
-        }
-        if (erq->flags & IW_ENCODE_RESTRICTED) {
-            auth |= SHARED_AUTH;
-        }
-
-        if (!auth) {
-            auth = OPEN_AUTH;
-        }
-
-        if (erq->length) {
-            if (!IEEE80211_IS_VALID_WEP_CIPHER_LEN(erq->length)) {
-                return -EIO;
-            }
-
-            A_MEMZERO(ar->arWepKeyList[index].arKey,
-                      sizeof(ar->arWepKeyList[index].arKey));
-            memcpy(ar->arWepKeyList[index].arKey, keybuf, erq->length);
-            ar->arWepKeyList[index].arKeyLen = erq->length;
-            ar->arDot11AuthMode       = auth;
-        } else {
-            if (ar->arWepKeyList[index].arKeyLen == 0) {
-                return -EIO;
-            }
-            ar->arDefTxKeyIndex = index;
-
-            if(ar->arSsidLen && ar->arWepKeyList[index].arKeyLen) {
-                wmi_addKey_cmd(ar->arWmi,
-                               index,
-                               WEP_CRYPT,
-                               GROUP_USAGE | TX_USAGE,
-                               ar->arWepKeyList[index].arKeyLen,
-                               NULL,
-                               ar->arWepKeyList[index].arKey, KEY_OP_INIT_VAL, NULL,
-                               NO_SYNC_WMIFLAG);
-            }
-        }
-
-        ar->arPairwiseCrypto      = WEP_CRYPT;
-        ar->arGroupCrypto         = WEP_CRYPT;
-        ar->arAuthMode            = NONE_AUTH;
-    }
-
-    if(ar->arNextMode != AP_NETWORK) {
-    /*
-     * profile has changed.  Erase ssid to signal change
-     */
-        A_MEMZERO(ar->arSsid, sizeof(ar->arSsid));
-        ar->arSsidLen = 0;
-    }
-    ar->ap_profile_flag = 1; /* There is a change in profile */
-    return 0;
-}
-
-static int
-ar6000_ioctl_giwencode(struct net_device *dev,
-              struct iw_request_info *info,
-              struct iw_point *erq, char *key)
-{
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-    u8 keyIndex;
-    struct ar_wep_key *wk;
-
-    if (is_iwioctl_allowed(ar->arNextMode, info->cmd) != 0) {
-        A_PRINTF("wext_ioctl: cmd=0x%x not allowed in this mode\n", info->cmd);
-        return -EOPNOTSUPP;
-    }
-
-    if (ar->arWlanState == WLAN_DISABLED) {
-        return -EIO;
-    }
-
-    if (ar->arPairwiseCrypto == NONE_CRYPT) {
-        erq->length = 0;
-        erq->flags = IW_ENCODE_DISABLED;
-    } else {
-        if (ar->arPairwiseCrypto == WEP_CRYPT) {
-            /* get the keyIndex */
-            keyIndex = erq->flags & IW_ENCODE_INDEX;
-            if (0 == keyIndex) {
-                keyIndex = ar->arDefTxKeyIndex;
-            } else if ((keyIndex - 1 < WMI_MIN_KEY_INDEX) ||
-                       (keyIndex - 1 > WMI_MAX_KEY_INDEX))
-            {
-                keyIndex = WMI_MIN_KEY_INDEX;
-            } else {
-                keyIndex--;
-            }
-            erq->flags = keyIndex + 1;
-            erq->flags &= ~IW_ENCODE_DISABLED;
-            wk = &ar->arWepKeyList[keyIndex];
-            if (erq->length > wk->arKeyLen) {
-                erq->length = wk->arKeyLen;
-            }
-            if (wk->arKeyLen) {
-                memcpy(key, wk->arKey, erq->length);
-            }
-        } else {
-            erq->flags &= ~IW_ENCODE_DISABLED;
-            if (ar->user_saved_keys.keyOk) {
-                erq->length = ar->user_saved_keys.ucast_ik.ik_keylen;
-                if (erq->length) {
-                    memcpy(key, ar->user_saved_keys.ucast_ik.ik_keydata, erq->length);
-                }
-            } else {
-                erq->length = 1;    // not really printing any key but let iwconfig know enc is on
-            }
-        }
-
-        if (ar->arDot11AuthMode & OPEN_AUTH) {
-            erq->flags |= IW_ENCODE_OPEN;
-        }
-        if (ar->arDot11AuthMode & SHARED_AUTH) {
-            erq->flags |= IW_ENCODE_RESTRICTED;
-        }
-    }
-
-    return 0;
-}
-
-#if WIRELESS_EXT >= 18
-/*
- * SIOCSIWGENIE
- */
-static int
-ar6000_ioctl_siwgenie(struct net_device *dev,
-              struct iw_request_info *info,
-              struct iw_point *erq, char *extra)
-{
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-
-#ifdef WAPI_ENABLE
-    u8 *ie = erq->pointer;
-    u8 ie_type = ie[0];
-    u16 ie_length = erq->length;
-    u8 wapi_ie[128];
-#endif
-
-    if (ar->arWmiReady == false) {
-        return -EIO;
-    }
-#ifdef WAPI_ENABLE
-    if (ie_type == IEEE80211_ELEMID_WAPI) {
-        if (ie_length > 0) {
-            if (copy_from_user(wapi_ie, ie, ie_length)) {
-                return -EIO;
-            }
-        }
-        wmi_set_appie_cmd(ar->arWmi, WMI_FRAME_ASSOC_REQ, ie_length, wapi_ie);
-    } else if (ie_length == 0) {
-        wmi_set_appie_cmd(ar->arWmi, WMI_FRAME_ASSOC_REQ, ie_length, wapi_ie);
-    }
-#endif
-    return 0;
-}
-
-
-/*
- * SIOCGIWGENIE
- */
-static int
-ar6000_ioctl_giwgenie(struct net_device *dev,
-              struct iw_request_info *info,
-              struct iw_point *erq, char *extra)
-{
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-
-    if (ar->arWmiReady == false) {
-        return -EIO;
-    }
-    erq->length = 0;
-    erq->flags = 0;
-
-    return 0;
-}
-
-/*
- * SIOCSIWAUTH
- */
-static int
-ar6000_ioctl_siwauth(struct net_device *dev,
-              struct iw_request_info *info,
-              struct iw_param *data, char *extra)
-{
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-
-    bool profChanged;
-    u16 param;
-    s32 ret;
-    s32 value;
-
-    if (ar->arWmiReady == false) {
-        return -EIO;
-    }
-
-    if (ar->arWlanState == WLAN_DISABLED) {
-        return -EIO;
-    }
-
-    param = data->flags & IW_AUTH_INDEX;
-    value = data->value;
-    profChanged = true;
-    ret = 0;
-
-    switch (param) {
-        case IW_AUTH_WPA_VERSION:
-            if (value & IW_AUTH_WPA_VERSION_DISABLED) {
-                ar->arAuthMode = NONE_AUTH;
-            } else if (value & IW_AUTH_WPA_VERSION_WPA) {
-                    ar->arAuthMode = WPA_AUTH;
-            } else if (value & IW_AUTH_WPA_VERSION_WPA2) {
-                    ar->arAuthMode = WPA2_AUTH;
-            } else {
-                ret = -1;
-                profChanged    = false;
-            }
-            break;
-        case IW_AUTH_CIPHER_PAIRWISE:
-            if (value & IW_AUTH_CIPHER_NONE) {
-                ar->arPairwiseCrypto = NONE_CRYPT;
-                ar->arPairwiseCryptoLen = 0;
-            } else if (value & IW_AUTH_CIPHER_WEP40) {
-                ar->arPairwiseCrypto = WEP_CRYPT;
-                ar->arPairwiseCryptoLen = 5;
-            } else if (value & IW_AUTH_CIPHER_TKIP) {
-                ar->arPairwiseCrypto = TKIP_CRYPT;
-                ar->arPairwiseCryptoLen = 0;
-            } else if (value & IW_AUTH_CIPHER_CCMP) {
-                ar->arPairwiseCrypto = AES_CRYPT;
-                ar->arPairwiseCryptoLen = 0;
-            } else if (value & IW_AUTH_CIPHER_WEP104) {
-                ar->arPairwiseCrypto = WEP_CRYPT;
-                ar->arPairwiseCryptoLen = 13;
-            } else {
-                ret = -1;
-                profChanged    = false;
-            }
-            break;
-        case IW_AUTH_CIPHER_GROUP:
-            if (value & IW_AUTH_CIPHER_NONE) {
-                ar->arGroupCrypto = NONE_CRYPT;
-                ar->arGroupCryptoLen = 0;
-            } else if (value & IW_AUTH_CIPHER_WEP40) {
-                ar->arGroupCrypto = WEP_CRYPT;
-                ar->arGroupCryptoLen = 5;
-            } else if (value & IW_AUTH_CIPHER_TKIP) {
-                ar->arGroupCrypto = TKIP_CRYPT;
-                ar->arGroupCryptoLen = 0;
-            } else if (value & IW_AUTH_CIPHER_CCMP) {
-                ar->arGroupCrypto = AES_CRYPT;
-                ar->arGroupCryptoLen = 0;
-            } else if (value & IW_AUTH_CIPHER_WEP104) {
-                ar->arGroupCrypto = WEP_CRYPT;
-                ar->arGroupCryptoLen = 13;
-            } else {
-                ret = -1;
-                profChanged    = false;
-            }
-            break;
-        case IW_AUTH_KEY_MGMT:
-            if (value & IW_AUTH_KEY_MGMT_PSK) {
-                if (WPA_AUTH == ar->arAuthMode) {
-                    ar->arAuthMode = WPA_PSK_AUTH;
-                } else if (WPA2_AUTH == ar->arAuthMode) {
-                    ar->arAuthMode = WPA2_PSK_AUTH;
-                } else {
-                    ret = -1;
-                }
-            } else if (!(value & IW_AUTH_KEY_MGMT_802_1X)) {
-                ar->arAuthMode = NONE_AUTH;
-            }
-            break;
-        case IW_AUTH_TKIP_COUNTERMEASURES:
-            wmi_set_tkip_countermeasures_cmd(ar->arWmi, value);
-            profChanged    = false;
-            break;
-        case IW_AUTH_DROP_UNENCRYPTED:
-            profChanged    = false;
-            break;
-        case IW_AUTH_80211_AUTH_ALG:
-            ar->arDot11AuthMode = 0;
-            if (value & IW_AUTH_ALG_OPEN_SYSTEM) {
-                ar->arDot11AuthMode  |= OPEN_AUTH;
-            }
-            if (value & IW_AUTH_ALG_SHARED_KEY) {
-                ar->arDot11AuthMode  |= SHARED_AUTH;
-            }
-            if (value & IW_AUTH_ALG_LEAP) {
-                ar->arDot11AuthMode   = LEAP_AUTH;
-            }
-            if(ar->arDot11AuthMode == 0) {
-                ret = -1;
-                profChanged    = false;
-            }
-            break;
-        case IW_AUTH_WPA_ENABLED:
-            if (!value) {
-                ar->arAuthMode = NONE_AUTH;
-                /* when the supplicant is stopped, it calls this
-                 * handler with value=0. The followings need to be
-                 * reset if the STA were to connect again
-                 * without security
-                 */
-                ar->arDot11AuthMode = OPEN_AUTH;
-                ar->arPairwiseCrypto = NONE_CRYPT;
-                ar->arPairwiseCryptoLen = 0;
-                ar->arGroupCrypto = NONE_CRYPT;
-                ar->arGroupCryptoLen = 0;
-            }
-            break;
-        case IW_AUTH_RX_UNENCRYPTED_EAPOL:
-            profChanged    = false;
-            break;
-        case IW_AUTH_ROAMING_CONTROL:
-            profChanged    = false;
-            break;
-        case IW_AUTH_PRIVACY_INVOKED:
-            if (!value) {
-                ar->arPairwiseCrypto = NONE_CRYPT;
-                ar->arPairwiseCryptoLen = 0;
-                ar->arGroupCrypto = NONE_CRYPT;
-                ar->arGroupCryptoLen = 0;
-            }
-            break;
-#ifdef WAPI_ENABLE
-        case IW_AUTH_WAPI_ENABLED:
-            ar->arWapiEnable = value;
-            break;
-#endif
-        default:
-           ret = -1;
-           profChanged    = false;
-           break;
-    }
-
-    if (profChanged == true) {
-        /*
-         * profile has changed.  Erase ssid to signal change
-         */
-        A_MEMZERO(ar->arSsid, sizeof(ar->arSsid));
-        ar->arSsidLen = 0;
-    }
-
-    return ret;
-}
-
-
-/*
- * SIOCGIWAUTH
- */
-static int
-ar6000_ioctl_giwauth(struct net_device *dev,
-              struct iw_request_info *info,
-              struct iw_param *data, char *extra)
-{
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-    u16 param;
-    s32 ret;
-
-    if (ar->arWmiReady == false) {
-        return -EIO;
-    }
-
-    if (ar->arWlanState == WLAN_DISABLED) {
-        return -EIO;
-    }
-
-    param = data->flags & IW_AUTH_INDEX;
-    ret = 0;
-    data->value = 0;
-
-
-    switch (param) {
-        case IW_AUTH_WPA_VERSION:
-            if (ar->arAuthMode == NONE_AUTH) {
-                data->value |= IW_AUTH_WPA_VERSION_DISABLED;
-            } else if (ar->arAuthMode == WPA_AUTH) {
-                data->value |= IW_AUTH_WPA_VERSION_WPA;
-            } else if (ar->arAuthMode == WPA2_AUTH) {
-                data->value |= IW_AUTH_WPA_VERSION_WPA2;
-            } else {
-                ret = -1;
-            }
-            break;
-        case IW_AUTH_CIPHER_PAIRWISE:
-            if (ar->arPairwiseCrypto == NONE_CRYPT) {
-                data->value |= IW_AUTH_CIPHER_NONE;
-            } else if (ar->arPairwiseCrypto == WEP_CRYPT) {
-                if (ar->arPairwiseCryptoLen == 13) {
-                    data->value |= IW_AUTH_CIPHER_WEP104;
-                } else {
-                    data->value |= IW_AUTH_CIPHER_WEP40;
-                }
-            } else if (ar->arPairwiseCrypto == TKIP_CRYPT) {
-                data->value |= IW_AUTH_CIPHER_TKIP;
-            } else if (ar->arPairwiseCrypto == AES_CRYPT) {
-                data->value |= IW_AUTH_CIPHER_CCMP;
-            } else {
-                ret = -1;
-            }
-            break;
-        case IW_AUTH_CIPHER_GROUP:
-            if (ar->arGroupCrypto == NONE_CRYPT) {
-                    data->value |= IW_AUTH_CIPHER_NONE;
-            } else if (ar->arGroupCrypto == WEP_CRYPT) {
-                if (ar->arGroupCryptoLen == 13) {
-                    data->value |= IW_AUTH_CIPHER_WEP104;
-                } else {
-                    data->value |= IW_AUTH_CIPHER_WEP40;
-                }
-            } else if (ar->arGroupCrypto == TKIP_CRYPT) {
-                data->value |= IW_AUTH_CIPHER_TKIP;
-            } else if (ar->arGroupCrypto == AES_CRYPT) {
-                data->value |= IW_AUTH_CIPHER_CCMP;
-            } else {
-                ret = -1;
-            }
-            break;
-        case IW_AUTH_KEY_MGMT:
-            if ((ar->arAuthMode == WPA_PSK_AUTH) ||
-                (ar->arAuthMode == WPA2_PSK_AUTH)) {
-                data->value |= IW_AUTH_KEY_MGMT_PSK;
-            } else if ((ar->arAuthMode == WPA_AUTH) ||
-                       (ar->arAuthMode == WPA2_AUTH)) {
-                data->value |= IW_AUTH_KEY_MGMT_802_1X;
-            }
-            break;
-        case IW_AUTH_TKIP_COUNTERMEASURES:
-            // TODO. Save countermeassure enable/disable
-            data->value = 0;
-            break;
-        case IW_AUTH_DROP_UNENCRYPTED:
-            break;
-        case IW_AUTH_80211_AUTH_ALG:
-            if (ar->arDot11AuthMode == OPEN_AUTH) {
-                data->value |= IW_AUTH_ALG_OPEN_SYSTEM;
-            } else if (ar->arDot11AuthMode == SHARED_AUTH) {
-                data->value |= IW_AUTH_ALG_SHARED_KEY;
-            } else if (ar->arDot11AuthMode == LEAP_AUTH) {
-                data->value |= IW_AUTH_ALG_LEAP;
-            } else {
-                ret = -1;
-            }
-            break;
-        case IW_AUTH_WPA_ENABLED:
-            if (ar->arAuthMode == NONE_AUTH) {
-                data->value = 0;
-            } else {
-                data->value = 1;
-            }
-            break;
-        case IW_AUTH_RX_UNENCRYPTED_EAPOL:
-            break;
-        case IW_AUTH_ROAMING_CONTROL:
-            break;
-        case IW_AUTH_PRIVACY_INVOKED:
-            if (ar->arPairwiseCrypto == NONE_CRYPT) {
-                data->value = 0;
-            } else {
-                data->value = 1;
-            }
-            break;
-#ifdef WAPI_ENABLE
-        case IW_AUTH_WAPI_ENABLED:
-            data->value = ar->arWapiEnable;
-            break;
-#endif
-        default:
-           ret = -1;
-           break;
-    }
-
-    return 0;
-}
-
-/*
- * SIOCSIWPMKSA
- */
-static int
-ar6000_ioctl_siwpmksa(struct net_device *dev,
-              struct iw_request_info *info,
-              struct iw_point *data, char *extra)
-{
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-    s32 ret;
-    int status;
-    struct iw_pmksa *pmksa;
-
-    pmksa = (struct iw_pmksa *)extra;
-
-    if (ar->arWmiReady == false) {
-        return -EIO;
-    }
-
-    ret = 0;
-    status = 0;
-
-    switch (pmksa->cmd) {
-        case IW_PMKSA_ADD:
-            status = wmi_setPmkid_cmd(ar->arWmi, (u8 *)pmksa->bssid.sa_data, pmksa->pmkid, true);
-            break;
-        case IW_PMKSA_REMOVE:
-            status = wmi_setPmkid_cmd(ar->arWmi, (u8 *)pmksa->bssid.sa_data, pmksa->pmkid, false);
-            break;
-        case IW_PMKSA_FLUSH:
-            if (ar->arConnected == true) {
-                status = wmi_setPmkid_cmd(ar->arWmi, ar->arBssid, NULL, 0);
-            }
-            break;
-        default:
-            ret=-1;
-            break;
-    }
-    if (status) {
-        ret = -1;
-    }
-
-    return ret;
-}
-
-#ifdef WAPI_ENABLE
-
-#define PN_INIT 0x5c365c36
-
-static int ar6000_set_wapi_key(struct net_device *dev,
-              struct iw_request_info *info,
-              struct iw_point *erq, char *extra)
-{
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-    struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
-    KEY_USAGE   keyUsage = 0;
-    s32 keyLen;
-    u8 *keyData;
-    s32 index;
-    u32 *PN;
-    s32 i;
-    int    status;
-    u8 wapiKeyRsc[16];
-    CRYPTO_TYPE keyType = WAPI_CRYPT;
-    const u8 broadcastMac[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
-
-    index = erq->flags & IW_ENCODE_INDEX;
-    if (index && (((index - 1) < WMI_MIN_KEY_INDEX) ||
-                ((index - 1) > WMI_MAX_KEY_INDEX))) {
-        return -EIO;
-    }
-
-    index--;
-    if (index < 0 || index > 4) {
-        return -EIO;
-    }
-    keyData = (u8 *)(ext + 1);
-    keyLen = erq->length - sizeof(struct iw_encode_ext);
-    memcpy(wapiKeyRsc, ext->tx_seq, sizeof(wapiKeyRsc));
-
-    if (memcmp(ext->addr.sa_data, broadcastMac, sizeof(broadcastMac)) == 0) {
-        keyUsage |= GROUP_USAGE;
-        PN = (u32 *)wapiKeyRsc;
-        for (i = 0; i < 4; i++) {
-            PN[i] = PN_INIT;
-        }
-    } else {
-        keyUsage |= PAIRWISE_USAGE;
-    }
-    status = wmi_addKey_cmd(ar->arWmi,
-                            index,
-                            keyType,
-                            keyUsage,
-                            keyLen,
-                            wapiKeyRsc,
-                            keyData,
-                            KEY_OP_INIT_WAPIPN,
-                            NULL,
-                            SYNC_BEFORE_WMIFLAG);
-    if (0 != status) {
-        return -EIO;
-    }
-    return 0;
-}
-
-#endif
-
-/*
- * SIOCSIWENCODEEXT
- */
-static int
-ar6000_ioctl_siwencodeext(struct net_device *dev,
-              struct iw_request_info *info,
-              struct iw_point *erq, char *extra)
-{
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-    s32 index;
-    struct iw_encode_ext *ext;
-    KEY_USAGE keyUsage;
-    s32 keyLen;
-    u8 *keyData;
-    u8 keyRsc[8];
-    int status;
-    CRYPTO_TYPE keyType;
-#ifdef USER_KEYS
-    struct ieee80211req_key ik;
-#endif /* USER_KEYS */
-
-    if (ar->arWlanState == WLAN_DISABLED) {
-        return -EIO;
-    }
-
-#ifdef USER_KEYS
-    ar->user_saved_keys.keyOk = false;
-#endif /* USER_KEYS */
-
-    index = erq->flags & IW_ENCODE_INDEX;
-
-    if (index && (((index - 1) < WMI_MIN_KEY_INDEX) ||
-                  ((index - 1) > WMI_MAX_KEY_INDEX)))
-    {
-        return -EIO;
-    }
-
-    ext = (struct iw_encode_ext *)extra;
-    if (erq->flags & IW_ENCODE_DISABLED) {
-        /*
-         * Encryption disabled
-         */
-        if (index) {
-            /*
-             * If key index was specified then clear the specified key
-             */
-            index--;
-            A_MEMZERO(ar->arWepKeyList[index].arKey,
-                      sizeof(ar->arWepKeyList[index].arKey));
-            ar->arWepKeyList[index].arKeyLen = 0;
-        }
-    } else {
-        /*
-         * Enabling WEP encryption
-         */
-        if (index) {
-            index--;                /* keyindex is off base 1 in iwconfig */
-        }
-
-        keyUsage = 0;
-        keyLen = erq->length - sizeof(struct iw_encode_ext);
-
-        if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) {
-            keyUsage = TX_USAGE;
-            ar->arDefTxKeyIndex = index;
-            // Just setting the key index
-            if (keyLen == 0) {
-                return 0;
-            }
-        }
-
-        if (keyLen <= 0) {
-            return -EIO;
-        }
-
-        /* key follows iw_encode_ext */
-        keyData = (u8 *)(ext + 1);
-
-        switch (ext->alg) {
-            case IW_ENCODE_ALG_WEP:
-                keyType = WEP_CRYPT;
-#ifdef USER_KEYS
-                ik.ik_type = IEEE80211_CIPHER_WEP;
-#endif /* USER_KEYS */
-                if (!IEEE80211_IS_VALID_WEP_CIPHER_LEN(keyLen)) {
-                    return -EIO;
-                }
-
-                /* Check whether it is static wep. */
-                if (!ar->arConnected) {
-                    A_MEMZERO(ar->arWepKeyList[index].arKey,
-                          sizeof(ar->arWepKeyList[index].arKey));
-                    memcpy(ar->arWepKeyList[index].arKey, keyData, keyLen);
-                    ar->arWepKeyList[index].arKeyLen = keyLen;
-
-                    return 0;
-                }
-                break;
-            case IW_ENCODE_ALG_TKIP:
-                keyType = TKIP_CRYPT;
-#ifdef USER_KEYS
-                ik.ik_type = IEEE80211_CIPHER_TKIP;
-#endif /* USER_KEYS */
-                break;
-            case IW_ENCODE_ALG_CCMP:
-                keyType = AES_CRYPT;
-#ifdef USER_KEYS
-                ik.ik_type = IEEE80211_CIPHER_AES_CCM;
-#endif /* USER_KEYS */
-                break;
-#ifdef WAPI_ENABLE
-            case IW_ENCODE_ALG_SM4:
-                if (ar->arWapiEnable) {
-                    return ar6000_set_wapi_key(dev, info, erq, extra);
-                } else {
-                    return -EIO;
-                }
-#endif
-            case IW_ENCODE_ALG_PMK:
-                ar->arConnectCtrlFlags |= CONNECT_DO_WPA_OFFLOAD;
-                return wmi_set_pmk_cmd(ar->arWmi, keyData);
-            default:
-                return -EIO;
-        }
-
-
-        if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
-            keyUsage |= GROUP_USAGE;
-        } else {
-            keyUsage |= PAIRWISE_USAGE;
-        }
-
-        if (ext->ext_flags & IW_ENCODE_EXT_RX_SEQ_VALID) {
-            memcpy(keyRsc, ext->rx_seq, sizeof(keyRsc));
-        } else {
-            A_MEMZERO(keyRsc, sizeof(keyRsc));
-        }
-
-        if (((WPA_PSK_AUTH == ar->arAuthMode) || (WPA2_PSK_AUTH == ar->arAuthMode)) &&
-            (GROUP_USAGE & keyUsage))
-        {
-            A_UNTIMEOUT(&ar->disconnect_timer);
-        }
-
-         status = wmi_addKey_cmd(ar->arWmi, index, keyType, keyUsage,
-                            keyLen, keyRsc,
-                            keyData, KEY_OP_INIT_VAL,
-                            (u8 *)ext->addr.sa_data,
-                            SYNC_BOTH_WMIFLAG);
-         if (status) {
-            return -EIO;
-         }
-
-#ifdef USER_KEYS
-        ik.ik_keyix = index;
-        ik.ik_keylen = keyLen;
-        memcpy(ik.ik_keydata, keyData, keyLen);
-        memcpy(&ik.ik_keyrsc, keyRsc, sizeof(keyRsc));
-        memcpy(ik.ik_macaddr, ext->addr.sa_data, ETH_ALEN);
-        if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
-            memcpy(&ar->user_saved_keys.bcast_ik, &ik,
-                       sizeof(struct ieee80211req_key));
-        } else {
-            memcpy(&ar->user_saved_keys.ucast_ik, &ik,
-                      sizeof(struct ieee80211req_key));
-        }
-        ar->user_saved_keys.keyOk = true;
-#endif /* USER_KEYS */
-    }
-
-
-    return 0;
-}
-
-/*
- * SIOCGIWENCODEEXT
- */
-static int
-ar6000_ioctl_giwencodeext(struct net_device *dev,
-              struct iw_request_info *info,
-              struct iw_point *erq, char *extra)
-{
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-
-    if (ar->arWlanState == WLAN_DISABLED) {
-        return -EIO;
-    }
-
-    if (ar->arPairwiseCrypto == NONE_CRYPT) {
-        erq->length = 0;
-        erq->flags = IW_ENCODE_DISABLED;
-    } else {
-        erq->length = 0;
-    }
-
-    return 0;
-}
-#endif // WIRELESS_EXT >= 18
-
-#if WIRELESS_EXT > 20
-static int ar6000_ioctl_siwpower(struct net_device *dev,
-                 struct iw_request_info *info,
-                 union iwreq_data *wrqu, char *extra)
-{
-#ifndef ATH6K_CONFIG_OTA_MODE
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-    WMI_POWER_MODE power_mode;
-
-    if (ar->arWmiReady == false) {
-        return -EIO;
-    }
-
-    if (ar->arWlanState == WLAN_DISABLED) {
-        return -EIO;
-    }
-
-    if (wrqu->power.disabled)
-        power_mode = MAX_PERF_POWER;
-    else
-        power_mode = REC_POWER;
-
-    if (wmi_powermode_cmd(ar->arWmi, power_mode) < 0)
-        return -EIO;
-#endif
-    return 0;
-}
-
-static int ar6000_ioctl_giwpower(struct net_device *dev,
-                 struct iw_request_info *info,
-                 union iwreq_data *wrqu, char *extra)
-{
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-    WMI_POWER_MODE power_mode;
-
-    if (ar->arWmiReady == false) {
-        return -EIO;
-    }
-
-    if (ar->arWlanState == WLAN_DISABLED) {
-        return -EIO;
-    }
-
-    power_mode = wmi_get_power_mode_cmd(ar->arWmi);
-
-    if (power_mode == MAX_PERF_POWER)
-        wrqu->power.disabled = 1;
-    else
-        wrqu->power.disabled = 0;
-
-    return 0;
-}
-#endif // WIRELESS_EXT > 20
-
-/*
- * SIOCGIWNAME
- */
-int
-ar6000_ioctl_giwname(struct net_device *dev,
-           struct iw_request_info *info,
-           char *name, char *extra)
-{
-    u8 capability;
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-
-    if (is_iwioctl_allowed(ar->arNextMode, info->cmd) != 0) {
-        A_PRINTF("wext_ioctl: cmd=0x%x not allowed in this mode\n", info->cmd);
-        return -EOPNOTSUPP;
-    }
-
-    if (ar->arWlanState == WLAN_DISABLED) {
-        return -EIO;
-    }
-
-    capability = ar->arPhyCapability;
-    if(ar->arNetworkType == INFRA_NETWORK && ar->arConnected) {
-        bss_t *bss = wmi_find_node(ar->arWmi, ar->arBssid);
-        if (bss) {
-            capability = get_bss_phy_capability(bss);
-            wmi_node_return(ar->arWmi, bss);
-        }
-    }
-    switch (capability) {
-    case (WMI_11A_CAPABILITY):
-        strncpy(name, "AR6000 802.11a", IFNAMSIZ);
-        break;
-    case (WMI_11G_CAPABILITY):
-        strncpy(name, "AR6000 802.11g", IFNAMSIZ);
-        break;
-    case (WMI_11AG_CAPABILITY):
-        strncpy(name, "AR6000 802.11ag", IFNAMSIZ);
-        break;
-    case (WMI_11NA_CAPABILITY):
-        strncpy(name, "AR6000 802.11na", IFNAMSIZ);
-        break;
-    case (WMI_11NG_CAPABILITY):
-        strncpy(name, "AR6000 802.11ng", IFNAMSIZ);
-        break;
-    case (WMI_11NAG_CAPABILITY):
-        strncpy(name, "AR6000 802.11nag", IFNAMSIZ);
-        break;
-    default:
-        strncpy(name, "AR6000 802.11b", IFNAMSIZ);
-        break;
-    }
-
-    return 0;
-}
-
-/*
- * SIOCSIWFREQ
- */
-int
-ar6000_ioctl_siwfreq(struct net_device *dev,
-            struct iw_request_info *info,
-            struct iw_freq *freq, char *extra)
-{
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-
-    if (is_iwioctl_allowed(ar->arNextMode, info->cmd) != 0) {
-        A_PRINTF("wext_ioctl: cmd=0x%x not allowed in this mode\n", info->cmd);
-        return -EOPNOTSUPP;
-    }
-
-    if (ar->arWlanState == WLAN_DISABLED) {
-        return -EIO;
-    }
-
-    /*
-     * We support limiting the channels via wmiconfig.
-     *
-     * We use this command to configure the channel hint for the connect cmd
-     * so it is possible the target will end up connecting to a different
-     * channel.
-     */
-    if (freq->e > 1) {
-        return -EINVAL;
-    } else if (freq->e == 1) {
-        ar->arChannelHint = freq->m / 100000;
-    } else {
-        if(freq->m) {
-            ar->arChannelHint = wlan_ieee2freq(freq->m);
-        } else {
-            /* Auto Channel Selection */
-            ar->arChannelHint = 0;
-        }
-    }
-
-    ar->ap_profile_flag = 1; /* There is a change in profile */
-
-    A_PRINTF("channel hint set to %d\n", ar->arChannelHint);
-    return 0;
-}
-
-/*
- * SIOCGIWFREQ
- */
-int
-ar6000_ioctl_giwfreq(struct net_device *dev,
-                struct iw_request_info *info,
-                struct iw_freq *freq, char *extra)
-{
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-
-    if (is_iwioctl_allowed(ar->arNextMode, info->cmd) != 0) {
-        A_PRINTF("wext_ioctl: cmd=0x%x not allowed in this mode\n", info->cmd);
-        return -EOPNOTSUPP;
-    }
-
-    if (ar->arWlanState == WLAN_DISABLED) {
-        return -EIO;
-    }
-
-    if (ar->arNetworkType == AP_NETWORK) {
-        if(ar->arChannelHint) {
-            freq->m = ar->arChannelHint * 100000;
-        } else if(ar->arACS) {
-            freq->m = ar->arACS * 100000;
-        } else {
-            return -EINVAL;
-        }
-    } else {
-        if (ar->arConnected != true) {
-            return -EINVAL;
-        } else {
-            freq->m = ar->arBssChannel * 100000;
-        }
-    }
-
-    freq->e = 1;
-
-    return 0;
-}
-
-/*
- * SIOCSIWMODE
- */
-int
-ar6000_ioctl_siwmode(struct net_device *dev,
-            struct iw_request_info *info,
-            __u32 *mode, char *extra)
-{
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-
-    if (is_iwioctl_allowed(ar->arNextMode, info->cmd) != 0) {
-        A_PRINTF("wext_ioctl: cmd=0x%x not allowed in this mode\n", info->cmd);
-        return -EOPNOTSUPP;
-    }
-
-    if (ar->arWlanState == WLAN_DISABLED) {
-        return -EIO;
-    }
-
-    /*
-     * clear SSID during mode switch in connected state
-     */
-    if(!(ar->arNetworkType == (((*mode) == IW_MODE_INFRA) ? INFRA_NETWORK : ADHOC_NETWORK)) && (ar->arConnected == true) ){
-        A_MEMZERO(ar->arSsid, sizeof(ar->arSsid));
-        ar->arSsidLen = 0;
-    }
-
-    switch (*mode) {
-    case IW_MODE_INFRA:
-        ar->arNextMode = INFRA_NETWORK;
-        break;
-    case IW_MODE_ADHOC:
-        ar->arNextMode = ADHOC_NETWORK;
-        break;
-    case IW_MODE_MASTER:
-        ar->arNextMode = AP_NETWORK;
-        break;
-    default:
-        return -EINVAL;
-    }
-
-    /* clear all shared parameters between AP and STA|IBSS modes when we
-     * switch between them. Switch between STA & IBSS modes does'nt clear
-     * the shared profile. This is as per the original design for switching
-     * between STA & IBSS.
-     */
-    if (ar->arNetworkType == AP_NETWORK || ar->arNextMode == AP_NETWORK) {
-        ar->arDot11AuthMode      = OPEN_AUTH;
-        ar->arAuthMode           = NONE_AUTH;
-        ar->arPairwiseCrypto     = NONE_CRYPT;
-        ar->arPairwiseCryptoLen  = 0;
-        ar->arGroupCrypto        = NONE_CRYPT;
-        ar->arGroupCryptoLen     = 0;
-        ar->arChannelHint        = 0;
-        ar->arBssChannel         = 0;
-        A_MEMZERO(ar->arBssid, sizeof(ar->arBssid));
-        A_MEMZERO(ar->arSsid, sizeof(ar->arSsid));
-        ar->arSsidLen = 0;
-    }
-
-    /* SSID has to be cleared to trigger a profile change while switching
-     * between STA & IBSS modes having the same SSID
-     */
-    if (ar->arNetworkType != ar->arNextMode) {
-        A_MEMZERO(ar->arSsid, sizeof(ar->arSsid));
-        ar->arSsidLen = 0;
-    }
-
-    return 0;
-}
-
-/*
- * SIOCGIWMODE
- */
-int
-ar6000_ioctl_giwmode(struct net_device *dev,
-            struct iw_request_info *info,
-            __u32 *mode, char *extra)
-{
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-
-    if (is_iwioctl_allowed(ar->arNextMode, info->cmd) != 0) {
-        A_PRINTF("wext_ioctl: cmd=0x%x not allowed in this mode\n", info->cmd);
-        return -EOPNOTSUPP;
-    }
-
-    if (ar->arWlanState == WLAN_DISABLED) {
-        return -EIO;
-    }
-
-    switch (ar->arNetworkType) {
-    case INFRA_NETWORK:
-        *mode = IW_MODE_INFRA;
-        break;
-    case ADHOC_NETWORK:
-        *mode = IW_MODE_ADHOC;
-        break;
-    case AP_NETWORK:
-        *mode = IW_MODE_MASTER;
-        break;
-    default:
-        return -EIO;
-    }
-    return 0;
-}
-
-/*
- * SIOCSIWSENS
- */
-int
-ar6000_ioctl_siwsens(struct net_device *dev,
-            struct iw_request_info *info,
-            struct iw_param *sens, char *extra)
-{
-    return 0;
-}
-
-/*
- * SIOCGIWSENS
- */
-int
-ar6000_ioctl_giwsens(struct net_device *dev,
-            struct iw_request_info *info,
-            struct iw_param *sens, char *extra)
-{
-    sens->value = 0;
-    sens->fixed = 1;
-
-    return 0;
-}
-
-/*
- * SIOCGIWRANGE
- */
-int
-ar6000_ioctl_giwrange(struct net_device *dev,
-             struct iw_request_info *info,
-             struct iw_point *data, char *extra)
-{
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-    struct iw_range *range = (struct iw_range *) extra;
-    int i, ret = 0;
-
-    if (is_iwioctl_allowed(ar->arNextMode, info->cmd) != 0) {
-        A_PRINTF("wext_ioctl: cmd=0x%x not allowed in this mode\n", info->cmd);
-        return -EOPNOTSUPP;
-    }
-
-    if (ar->bIsDestroyProgress) {
-        return -EBUSY;
-    }
-
-    if (ar->arWmiReady == false) {
-        return -EIO;
-    }
-
-    if (down_interruptible(&ar->arSem)) {
-        return -ERESTARTSYS;
-    }
-
-    if (ar->bIsDestroyProgress) {
-        up(&ar->arSem);
-        return -EBUSY;
-    }
-
-    ar->arNumChannels = -1;
-    A_MEMZERO(ar->arChannelList, sizeof (ar->arChannelList));
-
-    if (wmi_get_channelList_cmd(ar->arWmi) != 0) {
-        up(&ar->arSem);
-        return -EIO;
-    }
-
-    wait_event_interruptible_timeout(arEvent, ar->arNumChannels != -1, wmitimeout * HZ);
-
-    if (signal_pending(current)) {
-        up(&ar->arSem);
-        return -EINTR;
-    }
-
-    data->length = sizeof(struct iw_range);
-    A_MEMZERO(range, sizeof(struct iw_range));
-
-    range->txpower_capa = 0;
-
-    range->min_pmp = 1 * 1024;
-    range->max_pmp = 65535 * 1024;
-    range->min_pmt = 1 * 1024;
-    range->max_pmt = 1000 * 1024;
-    range->pmp_flags = IW_POWER_PERIOD;
-    range->pmt_flags = IW_POWER_TIMEOUT;
-    range->pm_capa = 0;
-
-    range->we_version_compiled = WIRELESS_EXT;
-    range->we_version_source = 13;
-
-    range->retry_capa = IW_RETRY_LIMIT;
-    range->retry_flags = IW_RETRY_LIMIT;
-    range->min_retry = 0;
-    range->max_retry = 255;
-
-    range->num_frequency = range->num_channels = ar->arNumChannels;
-    for (i = 0; i < ar->arNumChannels; i++) {
-        range->freq[i].i = wlan_freq2ieee(ar->arChannelList[i]);
-        range->freq[i].m = ar->arChannelList[i] * 100000;
-        range->freq[i].e = 1;
-         /*
-         * Linux supports max of 32 channels, bail out once you
-         * reach the max.
-         */
-        if (i == IW_MAX_FREQUENCIES) {
-            break;
-        }
-    }
-
-    /* Max quality is max field value minus noise floor */
-    range->max_qual.qual  = 0xff - 161;
-
-    /*
-     * In order to use dBm measurements, 'level' must be lower
-     * than any possible measurement (see iw_print_stats() in
-     * wireless tools).  It's unclear how this is meant to be
-     * done, but setting zero in these values forces dBm and
-     * the actual numbers are not used.
-     */
-    range->max_qual.level = 0;
-    range->max_qual.noise = 0;
-
-    range->sensitivity = 3;
-
-    range->max_encoding_tokens = 4;
-    /* XXX query driver to find out supported key sizes */
-    range->num_encoding_sizes = 3;
-    range->encoding_size[0] = 5;        /* 40-bit */
-    range->encoding_size[1] = 13;       /* 104-bit */
-    range->encoding_size[2] = 16;       /* 128-bit */
-
-    range->num_bitrates = 0;
-
-    /* estimated maximum TCP throughput values (bps) */
-    range->throughput = 22000000;
-
-    range->min_rts = 0;
-    range->max_rts = 2347;
-    range->min_frag = 256;
-    range->max_frag = 2346;
-
-    up(&ar->arSem);
-
-    return ret;
-}
-
-
-/*
- * SIOCSIWAP
- * This ioctl is used to set the desired bssid for the connect command.
- */
-int
-ar6000_ioctl_siwap(struct net_device *dev,
-              struct iw_request_info *info,
-              struct sockaddr *ap_addr, char *extra)
-{
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-
-    if (is_iwioctl_allowed(ar->arNextMode, info->cmd) != 0) {
-        A_PRINTF("wext_ioctl: cmd=0x%x not allowed in this mode\n", info->cmd);
-        return -EOPNOTSUPP;
-    }
-
-    if (ar->arWlanState == WLAN_DISABLED) {
-        return -EIO;
-    }
-
-    if (ap_addr->sa_family != ARPHRD_ETHER) {
-        return -EIO;
-    }
-
-    if (memcmp(&ap_addr->sa_data, bcast_mac, AR6000_ETH_ADDR_LEN) == 0) {
-        A_MEMZERO(ar->arReqBssid, sizeof(ar->arReqBssid));
-    } else {
-        memcpy(ar->arReqBssid, &ap_addr->sa_data,  sizeof(ar->arReqBssid));
-    }
-
-    return 0;
-}
-
-/*
- * SIOCGIWAP
- */
-int
-ar6000_ioctl_giwap(struct net_device *dev,
-              struct iw_request_info *info,
-              struct sockaddr *ap_addr, char *extra)
-{
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-
-    if (is_iwioctl_allowed(ar->arNextMode, info->cmd) != 0) {
-        A_PRINTF("wext_ioctl: cmd=0x%x not allowed in this mode\n", info->cmd);
-        return -EOPNOTSUPP;
-    }
-
-    if (ar->arWlanState == WLAN_DISABLED) {
-        return -EIO;
-    }
-
-    if (ar->arNetworkType == AP_NETWORK) {
-        memcpy(&ap_addr->sa_data, dev->dev_addr, ATH_MAC_LEN);
-        ap_addr->sa_family = ARPHRD_ETHER;
-        return 0;
-    }
-
-    if (ar->arConnected != true) {
-        return -EINVAL;
-    }
-
-    memcpy(&ap_addr->sa_data, ar->arBssid, sizeof(ar->arBssid));
-    ap_addr->sa_family = ARPHRD_ETHER;
-
-    return 0;
-}
-
-#if (WIRELESS_EXT >= 18)
-/*
- * SIOCSIWMLME
- */
-int
-ar6000_ioctl_siwmlme(struct net_device *dev,
-            struct iw_request_info *info,
-            struct iw_point *data, char *extra)
-{
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-
-    if (is_iwioctl_allowed(ar->arNextMode, info->cmd) != 0) {
-        A_PRINTF("wext_ioctl: cmd=0x%x not allowed in this mode\n", info->cmd);
-        return -EOPNOTSUPP;
-    }
-
-    if (ar->bIsDestroyProgress) {
-        return -EBUSY;
-    }
-
-    if (ar->arWlanState == WLAN_DISABLED) {
-        return -EIO;
-    }
-
-    if (ar->arWmiReady == false) {
-        return -EIO;
-    }
-
-    if (down_interruptible(&ar->arSem)) {
-        return -ERESTARTSYS;
-    }
-
-    if (data->pointer && data->length == sizeof(struct iw_mlme)) {
-
-        u8 arNetworkType;
-        struct iw_mlme mlme;
-
-        if (copy_from_user(&mlme, data->pointer, sizeof(struct iw_mlme)))
-            return -EIO;
-
-        switch (mlme.cmd) {
-
-            case IW_MLME_DEAUTH:
-                /* fall through */
-            case IW_MLME_DISASSOC:
-                if ((ar->arConnected != true) ||
-                    (memcmp(ar->arBssid, mlme.addr.sa_data, 6) != 0)) {
-
-                    up(&ar->arSem);
-                    return -EINVAL;
-                }
-                wmi_setPmkid_cmd(ar->arWmi, ar->arBssid, NULL, 0);
-                arNetworkType = ar->arNetworkType;
-                ar6000_init_profile_info(ar);
-                ar->arNetworkType = arNetworkType;
-                reconnect_flag = 0;
-                ar6000_disconnect(ar);
-                A_MEMZERO(ar->arSsid, sizeof(ar->arSsid));
-                ar->arSsidLen = 0;
-                if (ar->arSkipScan == false) {
-                    A_MEMZERO(ar->arReqBssid, sizeof(ar->arReqBssid));
-                }
-                break;
-
-            case IW_MLME_AUTH:
-                /* fall through */
-            case IW_MLME_ASSOC:
-                /* fall through */
-            default:
-                up(&ar->arSem);
-                return -EOPNOTSUPP;
-        }
-    }
-
-    up(&ar->arSem);
-    return 0;
-}
-#endif /* WIRELESS_EXT >= 18 */
-
-/*
- * SIOCGIWAPLIST
- */
-int
-ar6000_ioctl_iwaplist(struct net_device *dev,
-            struct iw_request_info *info,
-            struct iw_point *data, char *extra)
-{
-    return -EIO;            /* for now */
-}
-
-/*
- * SIOCSIWSCAN
- */
-int
-ar6000_ioctl_siwscan(struct net_device *dev,
-                     struct iw_request_info *info,
-                     struct iw_point *data, char *extra)
-{
-#define ACT_DWELLTIME_DEFAULT   105
-#define HOME_TXDRAIN_TIME       100
-#define SCAN_INT                HOME_TXDRAIN_TIME + ACT_DWELLTIME_DEFAULT
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-    int ret = 0;
-
-    if (is_iwioctl_allowed(ar->arNextMode, info->cmd) != 0) {
-        A_PRINTF("wext_ioctl: cmd=0x%x not allowed in this mode\n", info->cmd);
-        return -EOPNOTSUPP;
-    }
-
-    if (ar->arWmiReady == false) {
-        return -EIO;
-    }
-
-    if (ar->arWlanState == WLAN_DISABLED) {
-        return -EIO;
-    }
-
-    /* If scan is issued in the middle of ongoing scan or connect,
-       dont issue another one */
-    if ( ar->scan_triggered > 0 ) {
-        ++ar->scan_triggered;
-        if (ar->scan_triggered < 5) {
-            return 0;
-        } else {
-            AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_SCAN,("Scan request is triggered over 5 times. Not scan complete event\n"));
-        }
-    } 
-
-    if (!ar->arUserBssFilter) {
-        if (wmi_bssfilter_cmd(ar->arWmi, ALL_BSS_FILTER, 0) != 0) {
-            return -EIO;
-        }
-    }
-
-    if (ar->arConnected) {
-        if  (wmi_get_stats_cmd(ar->arWmi) != 0) {
-            return -EIO;
-        }
-    }
-
-#ifdef ANDROID_ENV
-#if WIRELESS_EXT >= 18
-    if (data->pointer && (data->length == sizeof(struct iw_scan_req)))
-    {
-        if ((data->flags & IW_SCAN_THIS_ESSID) == IW_SCAN_THIS_ESSID)
-        {
-            struct iw_scan_req req;
-            if (copy_from_user(&req, data->pointer, sizeof(struct iw_scan_req)))
-                return -EIO;
-            if (wmi_probedSsid_cmd(ar->arWmi, 1, SPECIFIC_SSID_FLAG, req.essid_len, req.essid) != 0)
-                return -EIO;
-            ar->scanSpecificSsid = true;
-        }
-        else
-        {
-            if (ar->scanSpecificSsid) {
-                if (wmi_probedSsid_cmd(ar->arWmi, 1, DISABLE_SSID_FLAG, 0, NULL) != 0)
-                    return -EIO;
-                 ar->scanSpecificSsid = false;
-            }
-        }
-    }
-    else
-    {
-        if (ar->scanSpecificSsid) {
-            if (wmi_probedSsid_cmd(ar->arWmi, 1, DISABLE_SSID_FLAG, 0, NULL) != 0)
-                return -EIO;
-             ar->scanSpecificSsid = false;
-        }
-    }
-#endif
-#endif /* ANDROID_ENV */
-
-    if (wmi_startscan_cmd(ar->arWmi, WMI_LONG_SCAN, false, false, \
-                          0, 0, 0, NULL) != 0) {
-        ret = -EIO;
-    }
-
-    if (ret == 0) {
-        ar->scan_triggered = 1;
-    }
-
-    return ret;
-#undef  ACT_DWELLTIME_DEFAULT
-#undef HOME_TXDRAIN_TIME
-#undef SCAN_INT
-}
-
-
-/*
- * Units are in db above the noise floor. That means the
- * rssi values reported in the tx/rx descriptors in the
- * driver are the SNR expressed in db.
- *
- * If you assume that the noise floor is -95, which is an
- * excellent assumption 99.5 % of the time, then you can
- * derive the absolute signal level (i.e. -95 + rssi).
- * There are some other slight factors to take into account
- * depending on whether the rssi measurement is from 11b,
- * 11g, or 11a.   These differences are at most 2db and
- * can be documented.
- *
- * NB: various calculations are based on the orinoco/wavelan
- *     drivers for compatibility
- */
-static void
-ar6000_set_quality(struct iw_quality *iq, s8 rssi)
-{
-    if (rssi < 0) {
-        iq->qual = 0;
-    } else {
-        iq->qual = rssi;
-    }
-
-    /* NB: max is 94 because noise is hardcoded to 161 */
-    if (iq->qual > 94)
-        iq->qual = 94;
-
-    iq->noise = 161;        /* -95dBm */
-    iq->level = iq->noise + iq->qual;
-    iq->updated = 7;
-}
-
-
-int
-ar6000_ioctl_siwcommit(struct net_device *dev,
-                     struct iw_request_info *info,
-                     struct iw_point *data, char *extra)
-{
-    struct ar6_softc *ar = (struct ar6_softc *)ar6k_priv(dev);
-
-    if (is_iwioctl_allowed(ar->arNextMode, info->cmd) != 0) {
-        A_PRINTF("wext_ioctl: cmd=0x%x not allowed in this mode\n", info->cmd);
-        return -EOPNOTSUPP;
-    }
-
-    if (ar->arWmiReady == false) {
-        return -EIO;
-    }
-
-    if (ar->arWlanState == WLAN_DISABLED) {
-        return -EIO;
-    }
-
-    AR_DEBUG_PRINTF(ATH_DEBUG_WLAN_CONNECT,("AP: SSID %s freq %d authmode %d dot11 auth %d"\
-                    " PW crypto %d GRP crypto %d\n",
-                    ar->arSsid, ar->arChannelHint,
-                    ar->arAuthMode, ar->arDot11AuthMode,
-                    ar->arPairwiseCrypto, ar->arGroupCrypto));
-
-    ar6000_ap_mode_profile_commit(ar);
-
-    /* if there is a profile switch from STA|IBSS mode to AP mode,
-     * update the host driver association state for the STA|IBSS mode.
-     */
-    if (ar->arNetworkType != AP_NETWORK && ar->arNextMode == AP_NETWORK) {
-        /* Stop getting pkts from upper stack */
-        netif_stop_queue(ar->arNetDev);
-        A_MEMZERO(ar->arBssid, sizeof(ar->arBssid));
-        ar->arBssChannel = 0;
-        ar->arBeaconInterval = 0;
-
-        /* Flush the Tx queues */
-        ar6000_TxDataCleanup(ar);
-
-        /* Start getting pkts from upper stack */
-        netif_wake_queue(ar->arNetDev);
-    }
-
-    return 0;
-}
-
-#define W_PROTO(_x) wait_ ## _x
-#define WAIT_HANDLER_IMPL(_x, type) \
-int wait_ ## _x (struct net_device *dev, struct iw_request_info *info, type wrqu, char *extra) {\
-    int ret; \
-    dev_hold(dev); \
-    rtnl_unlock(); \
-    ret = _x(dev, info, wrqu, extra); \
-    rtnl_lock(); \
-    dev_put(dev); \
-    return ret;\
-}
-
-WAIT_HANDLER_IMPL(ar6000_ioctl_siwessid, struct iw_point *)
-WAIT_HANDLER_IMPL(ar6000_ioctl_giwrate, struct iw_param *)
-WAIT_HANDLER_IMPL(ar6000_ioctl_giwtxpow, struct iw_param *)
-WAIT_HANDLER_IMPL(ar6000_ioctl_giwrange, struct iw_point*)
-
-/* Structures to export the Wireless Handlers */
-static const iw_handler ath_handlers[] = {
-    (iw_handler) ar6000_ioctl_siwcommit,        /* SIOCSIWCOMMIT */
-    (iw_handler) ar6000_ioctl_giwname,          /* SIOCGIWNAME */
-    (iw_handler) NULL,                          /* SIOCSIWNWID */
-    (iw_handler) NULL,                          /* SIOCGIWNWID */
-    (iw_handler) ar6000_ioctl_siwfreq,          /* SIOCSIWFREQ */
-    (iw_handler) ar6000_ioctl_giwfreq,          /* SIOCGIWFREQ */
-    (iw_handler) ar6000_ioctl_siwmode,          /* SIOCSIWMODE */
-    (iw_handler) ar6000_ioctl_giwmode,          /* SIOCGIWMODE */
-    (iw_handler) ar6000_ioctl_siwsens,          /* SIOCSIWSENS */
-    (iw_handler) ar6000_ioctl_giwsens,          /* SIOCGIWSENS */
-    (iw_handler) NULL /* not _used */,          /* SIOCSIWRANGE */
-    (iw_handler) W_PROTO(ar6000_ioctl_giwrange),/* SIOCGIWRANGE */
-    (iw_handler) NULL /* not used */,           /* SIOCSIWPRIV */
-    (iw_handler) NULL /* kernel code */,        /* SIOCGIWPRIV */
-    (iw_handler) NULL /* not used */,           /* SIOCSIWSTATS */
-    (iw_handler) NULL /* kernel code */,        /* SIOCGIWSTATS */
-    (iw_handler) NULL,                          /* SIOCSIWSPY */
-    (iw_handler) NULL,                          /* SIOCGIWSPY */
-    (iw_handler) NULL,                          /* SIOCSIWTHRSPY */
-    (iw_handler) NULL,                          /* SIOCGIWTHRSPY */
-    (iw_handler) ar6000_ioctl_siwap,            /* SIOCSIWAP */
-    (iw_handler) ar6000_ioctl_giwap,            /* SIOCGIWAP */
-#if (WIRELESS_EXT >= 18)
-    (iw_handler) ar6000_ioctl_siwmlme,          /* SIOCSIWMLME */
-#else
-    (iw_handler) NULL,                          /* -- hole -- */
-#endif  /* WIRELESS_EXT >= 18 */
-    (iw_handler) ar6000_ioctl_iwaplist,         /* SIOCGIWAPLIST */
-    (iw_handler) ar6000_ioctl_siwscan,          /* SIOCSIWSCAN */
-    (iw_handler) ar6000_ioctl_giwscan,          /* SIOCGIWSCAN */
-    (iw_handler) W_PROTO(ar6000_ioctl_siwessid),/* SIOCSIWESSID */
-    (iw_handler) ar6000_ioctl_giwessid,         /* SIOCGIWESSID */
-    (iw_handler) NULL,                          /* SIOCSIWNICKN */
-    (iw_handler) NULL,                          /* SIOCGIWNICKN */
-    (iw_handler) NULL,                          /* -- hole -- */
-    (iw_handler) NULL,                          /* -- hole -- */
-    (iw_handler) ar6000_ioctl_siwrate,          /* SIOCSIWRATE */
-    (iw_handler) W_PROTO(ar6000_ioctl_giwrate), /* SIOCGIWRATE */
-    (iw_handler) NULL,                          /* SIOCSIWRTS */
-    (iw_handler) NULL,                          /* SIOCGIWRTS */
-    (iw_handler) NULL,                          /* SIOCSIWFRAG */
-    (iw_handler) NULL,                          /* SIOCGIWFRAG */
-    (iw_handler) ar6000_ioctl_siwtxpow,         /* SIOCSIWTXPOW */
-    (iw_handler) W_PROTO(ar6000_ioctl_giwtxpow),/* SIOCGIWTXPOW */
-    (iw_handler) ar6000_ioctl_siwretry,         /* SIOCSIWRETRY */
-    (iw_handler) ar6000_ioctl_giwretry,         /* SIOCGIWRETRY */
-    (iw_handler) ar6000_ioctl_siwencode,        /* SIOCSIWENCODE */
-    (iw_handler) ar6000_ioctl_giwencode,        /* SIOCGIWENCODE */
-#if WIRELESS_EXT > 20
-    (iw_handler) ar6000_ioctl_siwpower,         /* SIOCSIWPOWER */
-    (iw_handler) ar6000_ioctl_giwpower,         /* SIOCGIWPOWER */
-#endif // WIRELESS_EXT > 20
-#if WIRELESS_EXT >= 18
-    (iw_handler) NULL,                          /* -- hole -- */
-    (iw_handler) NULL,                          /* -- hole -- */
-    (iw_handler) ar6000_ioctl_siwgenie,         /* SIOCSIWGENIE */
-    (iw_handler) ar6000_ioctl_giwgenie,         /* SIOCGIWGENIE */
-    (iw_handler) ar6000_ioctl_siwauth,          /* SIOCSIWAUTH */
-    (iw_handler) ar6000_ioctl_giwauth,          /* SIOCGIWAUTH */
-    (iw_handler) ar6000_ioctl_siwencodeext,     /* SIOCSIWENCODEEXT */
-    (iw_handler) ar6000_ioctl_giwencodeext,     /* SIOCGIWENCODEEXT */
-    (iw_handler) ar6000_ioctl_siwpmksa,         /* SIOCSIWPMKSA */
-#endif // WIRELESS_EXT >= 18
-};
-
-struct iw_handler_def ath_iw_handler_def = {
-    .standard         = (iw_handler *)ath_handlers,
-    .num_standard     = ARRAY_SIZE(ath_handlers),
-    .private          = NULL,
-    .num_private      = 0,
-};
index 094b227b32c490f8255d042ffcef50baea34c161..9b1509ec5a7ba1b86236148796953fde18ffd219 100644 (file)
  *
  */
 
-#ifdef  ATH_AR6K_11N_SUPPORT
-
 #include <a_config.h>
 #include <athdefs.h>
-#include <a_types.h>
 #include <a_osapi.h>
 #include <a_debug.h>
 #include "pkt_log.h"
@@ -40,7 +37,7 @@ static void
 aggr_slice_amsdu(struct aggr_info *p_aggr, struct rxtid *rxtid, void **osbuf);
 
 static void
-aggr_timeout(A_ATH_TIMER arg);
+aggr_timeout(unsigned long arg);
 
 static void
 aggr_deque_frms(struct aggr_info *p_aggr, u8 tid, u16 seq_no, u8 order);
@@ -123,7 +120,7 @@ aggr_delete_tid_state(struct aggr_info *p_aggr, u8 tid)
     rxtid->hold_q_sz = 0;
 
     if(rxtid->hold_q) {
-        A_FREE(rxtid->hold_q);
+        kfree(rxtid->hold_q);
         rxtid->hold_q = NULL;
     }
 
@@ -154,7 +151,7 @@ aggr_module_destroy(void *cntxt)
                         A_NETBUF_FREE(rxtid->hold_q[k].osbuf);
                     }
                 }
-                A_FREE(rxtid->hold_q);
+                kfree(rxtid->hold_q);
             }
             /* Free the dispatch q contents*/
             while(A_NETBUF_QUEUE_SIZE(&rxtid->q)) {
@@ -168,7 +165,7 @@ aggr_module_destroy(void *cntxt)
         while(A_NETBUF_QUEUE_SIZE(&p_aggr->freeQ)) {
             A_NETBUF_FREE(A_NETBUF_DEQUEUE(&p_aggr->freeQ));
         }
-        A_FREE(p_aggr);
+        kfree(p_aggr);
     }
     A_PRINTF("out aggr_module_destroy\n");
 }
@@ -573,7 +570,7 @@ aggr_reset_state(void *cntxt)
 
 
 static void
-aggr_timeout(A_ATH_TIMER arg)
+aggr_timeout(unsigned long arg)
 {
     u8 i,j;
     struct aggr_info *p_aggr = (struct aggr_info *)arg;
@@ -662,5 +659,3 @@ aggr_dump_stats(void *cntxt, PACKET_LOG **log_buf)
     A_PRINTF("================================================\n\n");
 
 }
-
-#endif  /* ATH_AR6K_11N_SUPPORT */
index 532ab0eb20c3911dd962a8cdb641157332474a0c..cf47d0657e7008e7420434d121ebc216be3b0559 100644 (file)
@@ -23,8 +23,6 @@
 #ifndef _NET80211_IEEE80211_H_
 #define _NET80211_IEEE80211_H_
 
-#include "athstartpack.h"
-
 /*
  * 802.11 protocol definitions.
  */
@@ -396,6 +394,4 @@ enum ieee80211_authmode {
 
 #define IEEE80211_PS_MAX_QUEUE    50 /*Maximum no of buffers that can be queues for PS*/
 
-#include "athendpack.h"
-
 #endif /* _NET80211_IEEE80211_H_ */
index 1a3ac7dd5e34b715a75acaf7d398bda832b76882..0fe5f4b1346c939807c708e6aee2434a2f2e54d1 100644 (file)
@@ -24,7 +24,6 @@
 //==============================================================================
 #include <a_config.h>
 #include <athdefs.h>
-#include <a_types.h>
 #include <a_osapi.h>
 #define ATH_MODULE_NAME wlan
 #include <a_debug.h>
@@ -54,7 +53,7 @@ ATH_DEBUG_INSTANTIATE_MODULE_VAR(wlan,
 #endif
 
 #ifdef THREAD_X
-static void wlan_node_timeout(A_ATH_TIMER arg);
+static void wlan_node_timeout(unsigned long arg);
 #endif
 
 static bss_t * _ieee80211_find_node (struct ieee80211_node_table *nt,
@@ -72,7 +71,7 @@ wlan_node_alloc(struct ieee80211_node_table *nt, int wh_size)
         {
         ni->ni_buf = A_MALLOC_NOWAIT(wh_size);
         if (ni->ni_buf == NULL) {
-            A_FREE(ni);
+            kfree(ni);
             ni = NULL;
             return ni;
         }
@@ -104,9 +103,9 @@ void
 wlan_node_free(bss_t *ni)
 {
     if (ni->ni_buf != NULL) {
-        A_FREE(ni->ni_buf);
+        kfree(ni->ni_buf);
     }
-    A_FREE(ni);
+    kfree(ni);
 }
 
 void
@@ -375,7 +374,7 @@ wlan_refresh_inactive_nodes (struct ieee80211_node_table *nt)
 
 #ifdef THREAD_X
 static void
-wlan_node_timeout (A_ATH_TIMER arg)
+wlan_node_timeout (unsigned long arg)
 {
     struct ieee80211_node_table *nt = (struct ieee80211_node_table *)arg;
     bss_t *bss, *nextBss;
index 9ebfecff54f9a31402ae68abad45ea38ba87941e..07b8313b16e889b7af3847ae7fad997303b26b7c 100644 (file)
@@ -25,7 +25,6 @@
 
 #include "a_config.h"
 #include "athdefs.h"
-#include "a_types.h"
 #include "a_osapi.h"
 #include <wmi.h>
 #include <ieee80211.h>
index fd05e39f41185370c5dab7acca191d9f06208f84..bc91599d9bf6bb946227e2b353a06c0f57358218 100644 (file)
@@ -24,7 +24,6 @@
 //==============================================================================
 #include <a_config.h>
 #include <athdefs.h>
-#include <a_types.h>
 #include <a_osapi.h>
 
 /*
index a00bf0a598711b6459a3363204cdf0494484fe95..4a17f99ea143ac4a02482cf89f321a8315511fe3 100644 (file)
@@ -25,7 +25,6 @@
 
 #include <a_config.h>
 #include <athdefs.h>
-#include <a_types.h>
 #include <a_osapi.h>
 #include "htc.h"
 #include "htc_api.h"
@@ -35,7 +34,6 @@
 #include <ieee80211.h>
 #include <ieee80211_node.h>
 #include "dset_api.h"
-#include "gpio_api.h"
 #include "wmi_host.h"
 #include "a_drv.h"
 #include "a_drv_api.h"
@@ -129,14 +127,6 @@ wmi_get_pmkid_list_event_rx(struct wmi_t *wmip, u8 *datap, u32 len);
 static int
 wmi_set_params_event_rx(struct wmi_t *wmip, u8 *datap, u32 len);
 
-static int
-wmi_acm_reject_event_rx(struct wmi_t *wmip, u8 *datap, u32 len);
-
-#ifdef CONFIG_HOST_GPIO_SUPPORT
-static int wmi_gpio_intr_rx(struct wmi_t *wmip, u8 *datap, int len);
-static int wmi_gpio_data_rx(struct wmi_t *wmip, u8 *datap, int len);
-static int wmi_gpio_ack_rx(struct wmi_t *wmip, u8 *datap, int len);
-#endif /* CONFIG_HOST_GPIO_SUPPORT */
 
 #ifdef CONFIG_HOST_TCMD_SUPPORT
 static int
@@ -187,13 +177,11 @@ static int wmi_dtimexpiry_event_rx(struct wmi_t *wmip, u8 *datap,
 
 static int wmi_peer_node_event_rx (struct wmi_t *wmip, u8 *datap,
                                         int len);
-#ifdef ATH_AR6K_11N_SUPPORT
 static int wmi_addba_req_event_rx(struct wmi_t *, u8 *, int);
 static int wmi_addba_resp_event_rx(struct wmi_t *, u8 *, int);
 static int wmi_delba_req_event_rx(struct wmi_t *, u8 *, int);
 static int wmi_btcoex_config_event_rx(struct wmi_t *wmip, u8 *datap, int len);
 static int wmi_btcoex_stats_event_rx(struct wmi_t *wmip, u8 *datap, int len);
-#endif
 static int wmi_hci_event_rx(struct wmi_t *, u8 *, int);
 
 #ifdef WAPI_ENABLE
@@ -273,8 +261,6 @@ const u8 up_to_ac[]= {
                 WMM_AC_VO,
             };
 
-#include "athstartpack.h"
-
 /* This stuff is used when we want a simple layer-3 visibility */
 typedef PREPACK struct _iphdr {
     u8 ip_ver_hdrlen;          /* version and hdr length */
@@ -292,8 +278,6 @@ typedef PREPACK struct _iphdr {
     u8 ip_dst[4];
 } POSTPACK iphdr;
 
-#include "athendpack.h"
-
 static s16 rssi_event_value = 0;
 static s16 snr_event_value = 0;
 
@@ -381,7 +365,7 @@ wmi_shutdown(struct wmi_t *wmip)
             A_MUTEX_DELETE(&wmip->wmi_lock);
 #endif
         }
-        A_FREE(wmip);
+        kfree(wmip);
     }
 }
 
@@ -475,7 +459,6 @@ int wmi_meta_add(struct wmi_t *wmip, void *osbuf, u8 *pVersion,void *pTxMetaS)
                *pVersion = WMI_META_VERSION_1;
                return (0);
                }
-#ifdef CONFIG_CHECKSUM_OFFLOAD
        case WMI_META_VERSION_2:
                {
                WMI_TX_META_V2 *pV2 ;
@@ -487,7 +470,6 @@ int wmi_meta_add(struct wmi_t *wmip, void *osbuf, u8 *pVersion,void *pTxMetaS)
                memcpy(pV2,(WMI_TX_META_V2 *)pTxMetaS,sizeof(WMI_TX_META_V2));
                return (0);
                }
-#endif
        default:
                return (0);
     }
@@ -525,7 +507,8 @@ wmi_data_hdr_add(struct wmi_t *wmip, void *osbuf, u8 msgType, bool bMoreData,
     }
 
     WMI_DATA_HDR_SET_META(dtHdr, metaVersion);
-    //dtHdr->rssi = 0;
+
+    dtHdr->info3 = 0;
 
     return (0);
 }
@@ -865,17 +848,6 @@ wmi_control_rx_xtnd(struct wmi_t *wmip, void *osbuf)
         status = wmi_dset_data_req_rx(wmip, datap, len);
         break;
 #endif /* CONFIG_HOST_DSET_SUPPORT */
-#ifdef CONFIG_HOST_GPIO_SUPPORT
-    case (WMIX_GPIO_INTR_EVENTID):
-        wmi_gpio_intr_rx(wmip, datap, len);
-        break;
-    case (WMIX_GPIO_DATA_EVENTID):
-        wmi_gpio_data_rx(wmip, datap, len);
-        break;
-    case (WMIX_GPIO_ACK_EVENTID):
-        wmi_gpio_ack_rx(wmip, datap, len);
-        break;
-#endif /* CONFIG_HOST_GPIO_SUPPORT */
     case (WMIX_HB_CHALLENGE_RESP_EVENTID):
         wmi_hbChallengeResp_rx(wmip, datap, len);
         break;
@@ -967,23 +939,19 @@ wmi_control_rx(struct wmi_t *wmip, void *osbuf)
     case (WMI_READY_EVENTID):
         A_DPRINTF(DBG_WMI, (DBGFMT "WMI_READY_EVENTID\n", DBGARG));
         status = wmi_ready_event_rx(wmip, datap, len);
-        A_WMI_SEND_EVENT_TO_APP(wmip->wmi_devt, id, datap, len);
         A_WMI_DBGLOG_INIT_DONE(wmip->wmi_devt);
         break;
     case (WMI_CONNECT_EVENTID):
         A_DPRINTF(DBG_WMI, (DBGFMT "WMI_CONNECT_EVENTID\n", DBGARG));
         status = wmi_connect_event_rx(wmip, datap, len);
-        A_WMI_SEND_GENERIC_EVENT_TO_APP(wmip->wmi_devt, id, datap, len);
         break;
     case (WMI_DISCONNECT_EVENTID):
         A_DPRINTF(DBG_WMI, (DBGFMT "WMI_DISCONNECT_EVENTID\n", DBGARG));
         status = wmi_disconnect_event_rx(wmip, datap, len);
-        A_WMI_SEND_EVENT_TO_APP(wmip->wmi_devt, id, datap, len);
         break;
     case (WMI_PEER_NODE_EVENTID):
         A_DPRINTF (DBG_WMI, (DBGFMT "WMI_PEER_NODE_EVENTID\n", DBGARG));
         status = wmi_peer_node_event_rx(wmip, datap, len);
-        A_WMI_SEND_EVENT_TO_APP(wmip->wmi_devt, id, datap, len);
         break;
     case (WMI_TKIP_MICERR_EVENTID):
         A_DPRINTF(DBG_WMI, (DBGFMT "WMI_TKIP_MICERR_EVENTID\n", DBGARG));
@@ -1014,7 +982,6 @@ wmi_control_rx(struct wmi_t *wmip, void *osbuf)
             memcpy(bih->bssid, bih2.bssid, ATH_MAC_LEN);
 
             status = wmi_bssInfo_event_rx(wmip, datap, len);
-            A_WMI_SEND_GENERIC_EVENT_TO_APP(wmip->wmi_devt, id, datap, len);
         }
         break;
     case (WMI_REGDOMAIN_EVENTID):
@@ -1024,13 +991,6 @@ wmi_control_rx(struct wmi_t *wmip, void *osbuf)
     case (WMI_PSTREAM_TIMEOUT_EVENTID):
         A_DPRINTF(DBG_WMI, (DBGFMT "WMI_PSTREAM_TIMEOUT_EVENTID\n", DBGARG));
         status = wmi_pstream_timeout_event_rx(wmip, datap, len);
-            /* pstreams are fatpipe abstractions that get implicitly created.
-             * User apps only deal with thinstreams. creation of a thinstream
-             * by the user or data traffic flow in an AC triggers implicit
-             * pstream creation. Do we need to send this event to App..?
-             * no harm in sending it.
-             */
-        A_WMI_SEND_EVENT_TO_APP(wmip->wmi_devt, id, datap, len);
         break;
     case (WMI_NEIGHBOR_REPORT_EVENTID):
         A_DPRINTF(DBG_WMI, (DBGFMT "WMI_NEIGHBOR_REPORT_EVENTID\n", DBGARG));
@@ -1039,7 +999,6 @@ wmi_control_rx(struct wmi_t *wmip, void *osbuf)
     case (WMI_SCAN_COMPLETE_EVENTID):
         A_DPRINTF(DBG_WMI, (DBGFMT "WMI_SCAN_COMPLETE_EVENTID\n", DBGARG));
         status = wmi_scanComplete_rx(wmip, datap, len);
-        A_WMI_SEND_EVENT_TO_APP(wmip->wmi_devt, id, datap, len);
         break;
     case (WMI_CMDERROR_EVENTID):
         A_DPRINTF(DBG_WMI, (DBGFMT "WMI_CMDERROR_EVENTID\n", DBGARG));
@@ -1056,7 +1015,6 @@ wmi_control_rx(struct wmi_t *wmip, void *osbuf)
     case (WMI_ERROR_REPORT_EVENTID):
         A_DPRINTF(DBG_WMI, (DBGFMT "WMI_ERROR_REPORT_EVENTID\n", DBGARG));
         status = wmi_reportErrorEvent_rx(wmip, datap, len);
-        A_WMI_SEND_EVENT_TO_APP(wmip->wmi_devt, id, datap, len);
         break;
     case (WMI_OPT_RX_FRAME_EVENTID):
         A_DPRINTF(DBG_WMI, (DBGFMT "WMI_OPT_RX_FRAME_EVENTID\n", DBGARG));
@@ -1095,7 +1053,6 @@ wmi_control_rx(struct wmi_t *wmip, void *osbuf)
     case (WMI_TX_RETRY_ERR_EVENTID):
         A_DPRINTF(DBG_WMI, (DBGFMT "WMI_TX_RETRY_ERR_EVENTID\n", DBGARG));
         status = wmi_txRetryErrEvent_rx(wmip, datap, len);
-        A_WMI_SEND_EVENT_TO_APP(wmip->wmi_devt, id, datap, len);
         break;
     case (WMI_SNR_THRESHOLD_EVENTID):
         A_DPRINTF(DBG_WMI, (DBGFMT "WMI_SNR_THRESHOLD_EVENTID\n", DBGARG));
@@ -1104,7 +1061,6 @@ wmi_control_rx(struct wmi_t *wmip, void *osbuf)
     case (WMI_LQ_THRESHOLD_EVENTID):
         A_DPRINTF(DBG_WMI, (DBGFMT "WMI_LQ_THRESHOLD_EVENTID\n", DBGARG));
         status = wmi_lqThresholdEvent_rx(wmip, datap, len);
-        A_WMI_SEND_EVENT_TO_APP(wmip->wmi_devt, id, datap, len);
         break;
     case (WMI_APLIST_EVENTID):
         AR_DEBUG_PRINTF(ATH_DEBUG_WMI, ("Received APLIST Event\n"));
@@ -1133,11 +1089,6 @@ wmi_control_rx(struct wmi_t *wmip, void *osbuf)
         A_DPRINTF(DBG_WMI, (DBGFMT "WMI_SET_PARAMS_REPLY Event\n", DBGARG));
         status = wmi_set_params_event_rx(wmip, datap, len);
         break;
-    case (WMI_ACM_REJECT_EVENTID):
-        A_DPRINTF(DBG_WMI, (DBGFMT "WMI_SET_PARAMS_REPLY Event\n", DBGARG));
-        status = wmi_acm_reject_event_rx(wmip, datap, len);
-        break;         
-#ifdef ATH_AR6K_11N_SUPPORT
     case (WMI_ADDBA_REQ_EVENTID):
         status = wmi_addba_req_event_rx(wmip, datap, len);
         break;
@@ -1155,7 +1106,6 @@ wmi_control_rx(struct wmi_t *wmip, void *osbuf)
            A_DPRINTF(DBG_WMI, (DBGFMT "WMI_BTCOEX_STATS_EVENTID", DBGARG));
        status = wmi_btcoex_stats_event_rx(wmip, datap, len);
            break;
-#endif
     case (WMI_TX_COMPLETE_EVENTID):
         {
             int index;
@@ -1208,7 +1158,7 @@ wmi_simple_cmd(struct wmi_t *wmip, WMI_COMMAND_ID cmdid)
 /* Send a "simple" extended wmi command -- one with no arguments.
    Enabling this command only if GPIO or profiling support is enabled.
    This is to suppress warnings on some platforms */
-#if defined(CONFIG_HOST_GPIO_SUPPORT) || defined(CONFIG_TARGET_PROFILE_SUPPORT)
+#if defined(CONFIG_TARGET_PROFILE_SUPPORT)
 static int
 wmi_simple_cmd_xtnd(struct wmi_t *wmip, WMIX_COMMAND_ID cmdid)
 {
@@ -2298,46 +2248,6 @@ wmi_dbglog_event_rx(struct wmi_t *wmip, u8 *datap, int len)
     return 0;
 }
 
-#ifdef CONFIG_HOST_GPIO_SUPPORT
-static int
-wmi_gpio_intr_rx(struct wmi_t *wmip, u8 *datap, int len)
-{
-    WMIX_GPIO_INTR_EVENT *gpio_intr = (WMIX_GPIO_INTR_EVENT *)datap;
-
-    A_DPRINTF(DBG_WMI,
-        (DBGFMT "Enter - intrmask=0x%x input=0x%x.\n", DBGARG,
-        gpio_intr->intr_mask, gpio_intr->input_values));
-
-    A_WMI_GPIO_INTR_RX(gpio_intr->intr_mask, gpio_intr->input_values);
-
-    return 0;
-}
-
-static int
-wmi_gpio_data_rx(struct wmi_t *wmip, u8 *datap, int len)
-{
-    WMIX_GPIO_DATA_EVENT *gpio_data = (WMIX_GPIO_DATA_EVENT *)datap;
-
-    A_DPRINTF(DBG_WMI,
-        (DBGFMT "Enter - reg=%d value=0x%x\n", DBGARG,
-        gpio_data->reg_id, gpio_data->value));
-
-    A_WMI_GPIO_DATA_RX(gpio_data->reg_id, gpio_data->value);
-
-    return 0;
-}
-
-static int
-wmi_gpio_ack_rx(struct wmi_t *wmip, u8 *datap, int len)
-{
-    A_DPRINTF(DBG_WMI, (DBGFMT "Enter\n", DBGARG));
-
-    A_WMI_GPIO_ACK_RX();
-
-    return 0;
-}
-#endif /* CONFIG_HOST_GPIO_SUPPORT */
-
 /*
  * Called to send a wmi command. Command specific data is already built
  * on osbuf and current osbuf->data points to it.
@@ -3075,6 +2985,7 @@ wmi_dataSync_send(struct wmi_t *wmip, void *osbuf, HTC_ENDPOINT_ID eid)
     dtHdr->info =
       (SYNC_MSGTYPE & WMI_DATA_HDR_MSG_TYPE_MASK) << WMI_DATA_HDR_MSG_TYPE_SHIFT;
 
+    dtHdr->info3 = 0;
     A_DPRINTF(DBG_WMI, (DBGFMT "Enter - eid %d\n", DBGARG, eid));
 
     return (A_WMI_CONTROL_TX(wmip->wmi_devt, osbuf, eid));
@@ -4282,132 +4193,6 @@ wmi_set_powersave_timers_cmd(struct wmi_t *wmip,
                          NO_SYNC_WMIFLAG));
 }
 
-#ifdef CONFIG_HOST_GPIO_SUPPORT
-/* Send a command to Target to change GPIO output pins. */
-int
-wmi_gpio_output_set(struct wmi_t *wmip,
-                    u32 set_mask,
-                    u32 clear_mask,
-                    u32 enable_mask,
-                    u32 disable_mask)
-{
-    void *osbuf;
-    WMIX_GPIO_OUTPUT_SET_CMD *output_set;
-    int size;
-
-    size = sizeof(*output_set);
-
-    A_DPRINTF(DBG_WMI,
-        (DBGFMT "Enter - set=0x%x clear=0x%x enb=0x%x dis=0x%x\n", DBGARG,
-        set_mask, clear_mask, enable_mask, disable_mask));
-
-    osbuf = A_NETBUF_ALLOC(size);
-    if (osbuf == NULL) {
-        return A_NO_MEMORY;
-    }
-    A_NETBUF_PUT(osbuf, size);
-    output_set = (WMIX_GPIO_OUTPUT_SET_CMD *)(A_NETBUF_DATA(osbuf));
-
-    output_set->set_mask                   = set_mask;
-    output_set->clear_mask                 = clear_mask;
-    output_set->enable_mask                = enable_mask;
-    output_set->disable_mask               = disable_mask;
-
-    return (wmi_cmd_send_xtnd(wmip, osbuf, WMIX_GPIO_OUTPUT_SET_CMDID,
-                             NO_SYNC_WMIFLAG));
-}
-
-/* Send a command to the Target requesting state of the GPIO input pins */
-int
-wmi_gpio_input_get(struct wmi_t *wmip)
-{
-    A_DPRINTF(DBG_WMI, (DBGFMT "Enter\n", DBGARG));
-
-    return wmi_simple_cmd_xtnd(wmip, WMIX_GPIO_INPUT_GET_CMDID);
-}
-
-/* Send a command to the Target that changes the value of a GPIO register. */
-int
-wmi_gpio_register_set(struct wmi_t *wmip,
-                      u32 gpioreg_id,
-                      u32 value)
-{
-    void *osbuf;
-    WMIX_GPIO_REGISTER_SET_CMD *register_set;
-    int size;
-
-    size = sizeof(*register_set);
-
-    A_DPRINTF(DBG_WMI,
-        (DBGFMT "Enter - reg=%d value=0x%x\n", DBGARG, gpioreg_id, value));
-
-    osbuf = A_NETBUF_ALLOC(size);
-    if (osbuf == NULL) {
-        return A_NO_MEMORY;
-    }
-    A_NETBUF_PUT(osbuf, size);
-    register_set = (WMIX_GPIO_REGISTER_SET_CMD *)(A_NETBUF_DATA(osbuf));
-
-    register_set->gpioreg_id               = gpioreg_id;
-    register_set->value                    = value;
-
-    return (wmi_cmd_send_xtnd(wmip, osbuf, WMIX_GPIO_REGISTER_SET_CMDID,
-                             NO_SYNC_WMIFLAG));
-}
-
-/* Send a command to the Target to fetch the value of a GPIO register. */
-int
-wmi_gpio_register_get(struct wmi_t *wmip,
-                      u32 gpioreg_id)
-{
-    void *osbuf;
-    WMIX_GPIO_REGISTER_GET_CMD *register_get;
-    int size;
-
-    size = sizeof(*register_get);
-
-    A_DPRINTF(DBG_WMI, (DBGFMT "Enter - reg=%d\n", DBGARG, gpioreg_id));
-
-    osbuf = A_NETBUF_ALLOC(size);
-    if (osbuf == NULL) {
-        return A_NO_MEMORY;
-    }
-    A_NETBUF_PUT(osbuf, size);
-    register_get = (WMIX_GPIO_REGISTER_GET_CMD *)(A_NETBUF_DATA(osbuf));
-
-    register_get->gpioreg_id               = gpioreg_id;
-
-    return (wmi_cmd_send_xtnd(wmip, osbuf, WMIX_GPIO_REGISTER_GET_CMDID,
-                             NO_SYNC_WMIFLAG));
-}
-
-/* Send a command to the Target acknowledging some GPIO interrupts. */
-int
-wmi_gpio_intr_ack(struct wmi_t *wmip,
-                  u32 ack_mask)
-{
-    void *osbuf;
-    WMIX_GPIO_INTR_ACK_CMD *intr_ack;
-    int size;
-
-    size = sizeof(*intr_ack);
-
-    A_DPRINTF(DBG_WMI, (DBGFMT "Enter ack_mask=0x%x\n", DBGARG, ack_mask));
-
-    osbuf = A_NETBUF_ALLOC(size);
-    if (osbuf == NULL) {
-        return A_NO_MEMORY;
-    }
-    A_NETBUF_PUT(osbuf, size);
-    intr_ack = (WMIX_GPIO_INTR_ACK_CMD *)(A_NETBUF_DATA(osbuf));
-
-    intr_ack->ack_mask               = ack_mask;
-
-    return (wmi_cmd_send_xtnd(wmip, osbuf, WMIX_GPIO_INTR_ACK_CMDID,
-                             NO_SYNC_WMIFLAG));
-}
-#endif /* CONFIG_HOST_GPIO_SUPPORT */
-
 int
 wmi_set_access_params_cmd(struct wmi_t *wmip, u8 ac,  u16 txop, u8 eCWmin,
                           u8 eCWmax, u8 aifsn)
@@ -4683,8 +4468,6 @@ wmi_tcmd_test_report_rx(struct wmi_t *wmip, u8 *datap, int len)
 
    A_DPRINTF(DBG_WMI, (DBGFMT "Enter\n", DBGARG));
 
-   A_WMI_TCMD_RX_REPORT_EVENT(wmip->wmi_devt, datap, len);
-
    return 0;
 }
 
@@ -5500,19 +5283,6 @@ wmi_set_params_event_rx(struct wmi_t *wmip, u8 *datap, u32 len)
 }
 
 
-
-static int
-wmi_acm_reject_event_rx(struct wmi_t *wmip, u8 *datap, u32 len)
-{
-    WMI_ACM_REJECT_EVENT *ev;
-
-    ev = (WMI_ACM_REJECT_EVENT *)datap;
-    wmip->wmi_traffic_class = ev->trafficClass;
-    printk("ACM REJECT %d\n",wmip->wmi_traffic_class);
-    return 0;
-}
-
-
 #ifdef CONFIG_HOST_DSET_SUPPORT
 int
 wmi_dset_data_reply(struct wmi_t *wmip,
@@ -5877,7 +5647,7 @@ wmi_scan_indication (struct wmi_t *wmip)
 
     ar6000_scan_indication (wmip->wmi_devt, pAr6kScanIndEvent, size);
 
-    A_FREE(pAr6kScanIndEvent);
+    kfree(pAr6kScanIndEvent);
 }
 #endif
 
@@ -5995,7 +5765,6 @@ int wmi_add_current_bss (struct wmi_t *wmip, u8 *id, bss_t *bss)
     return 0;
 }
 
-#ifdef ATH_AR6K_11N_SUPPORT
 static int
 wmi_addba_req_event_rx(struct wmi_t *wmip, u8 *datap, int len)
 {
@@ -6048,7 +5817,6 @@ wmi_btcoex_stats_event_rx(struct wmi_t * wmip,u8 *datap,int len)
      return 0;
 
 }
-#endif
 
 static int
 wmi_hci_event_rx(struct wmi_t *wmip, u8 *datap, int len)
@@ -6372,7 +6140,6 @@ wmi_ap_set_rateset(struct wmi_t *wmip, u8 rateset)
     return (wmi_cmd_send(wmip, osbuf, WMI_AP_SET_11BG_RATESET_CMDID, NO_SYNC_WMIFLAG));
 }
 
-#ifdef ATH_AR6K_11N_SUPPORT
 int
 wmi_set_ht_cap_cmd(struct wmi_t *wmip, WMI_SET_HT_CAP_CMD *cmd)
 {
@@ -6418,7 +6185,6 @@ wmi_set_ht_op_cmd(struct wmi_t *wmip, u8 sta_chan_width)
     return (wmi_cmd_send(wmip, osbuf, WMI_SET_HT_OP_CMDID,
                          NO_SYNC_WMIFLAG));
 }
-#endif
 
 int
 wmi_set_tx_select_rates_cmd(struct wmi_t *wmip, u32 *pMaskArray)
@@ -6460,7 +6226,6 @@ wmi_send_hci_cmd(struct wmi_t *wmip, u8 *buf, u16 sz)
     return (wmi_cmd_send(wmip, osbuf, WMI_HCI_CMD_CMDID, NO_SYNC_WMIFLAG));
 }
 
-#ifdef ATH_AR6K_11N_SUPPORT
 int
 wmi_allow_aggr_cmd(struct wmi_t *wmip, u16 tx_tidmask, u16 rx_tidmask)
 {
@@ -6520,7 +6285,6 @@ wmi_delete_aggr_cmd(struct wmi_t *wmip, u8 tid, bool uplink)
     /* Delete the local aggr state, on host */
     return (wmi_cmd_send(wmip, osbuf, WMI_DELBA_REQ_CMDID, NO_SYNC_WMIFLAG));
 }
-#endif
 
 int
 wmi_set_rx_frame_format_cmd(struct wmi_t *wmip, u8 rxMetaVersion,
index b6f86354b69faa9ed3cc4795700a879d89ee6c7b..f4cf9b23481e0ffad692f3158ded5fec6a069151 100644 (file)
@@ -1,21 +1,26 @@
-menuconfig BRCM80211
-       tristate "Broadcom IEEE802.11n WLAN drivers"
-       depends on WLAN
+config BRCMUTIL
+       tristate
+       default n
 
 config BRCMSMAC
-       bool "Broadcom IEEE802.11n PCIe SoftMAC WLAN driver"
+       tristate "Broadcom IEEE802.11n PCIe SoftMAC WLAN driver"
+       default n
        depends on PCI
-       depends on BRCM80211 && MAC80211
+       depends on WLAN && MAC80211
+       select BRCMUTIL
        select FW_LOADER
+       select CRC_CCITT
        ---help---
          This module adds support for PCIe wireless adapters based on Broadcom
          IEEE802.11n SoftMAC chipsets.  If you choose to build a module, it'll
          be called brcmsmac.ko.
 
 config BRCMFMAC
-       bool "Broadcom IEEE802.11n embedded FullMAC WLAN driver"
+       tristate "Broadcom IEEE802.11n embedded FullMAC WLAN driver"
+       default n
        depends on MMC
-       depends on BRCM80211 && CFG80211
+       depends on WLAN && CFG80211
+       select BRCMUTIL
        select FW_LOADER
        select WIRELESS_EXT
        select WEXT_PRIV
@@ -28,6 +33,6 @@ config BRCMFMAC
 config BRCMDBG
        bool "Broadcom driver debug functions"
        default n
-       depends on BRCM80211
+       depends on BRCMSMAC || BRCMFMAC
        ---help---
          Selecting this enables additional code for debug purposes.
index c064cdf47f0d0358d94c5c2e3b38bdd9b8f7d965..e7b3f27847cf179d0601e5c7d483dce3a6d4ff51 100644 (file)
@@ -19,5 +19,6 @@
 subdir-ccflags-y                                       := -DBCMDMA32
 subdir-ccflags-$(CONFIG_BRCMDBG)       += -DBCMDBG -DBCMDBG_ASSERT
 
+obj-$(CONFIG_BRCMUTIL) += util/
 obj-$(CONFIG_BRCMFMAC) += brcmfmac/
 obj-$(CONFIG_BRCMSMAC) += brcmsmac/
index f8facb0786ec9c24e5fa7c847326d7572b22da99..8ad558675bd36f24feb75050bc8c788ad3432c8e 100644 (file)
@@ -1,90 +1,64 @@
-Broadcom Mac80211 driver
+Broadcom brcmsmac (mac80211-based softmac PCIe) and brcmfmac (SDIO) drivers.
 
-This is a driver in progress.  It has features still to be implemented well as
-bugs in current code.
+Completely open source host drivers, no binary object files.
 
+Support for the following chips:
+===============================
 
-What's here and not here
-=======================
-- Completely open source host driver, no binary object files
-- Features Broadcom's OneDriver architecture (single source base for
-  supported chips and architectures)
-- On-chip firmware loaded using standard request_firmware()
-- Support for BCM43224, BCM43225, BCM4313 (PCIe NIC)
-- Framework for supporting new chips, including mac80211-aware embedded chips
-- Does not support older PCI/PCIe chips with SSB backplane
-- Driver includes BMAC interface for transparent dongle support
-- Uses minstrel_ht rate algorithm
-- HW based encryption not enabled yet
+    brcmsmac (PCIe)
+    Name        Device ID
+    BCM4313     0x4727
+    BCM43224    0x4353
+    BCM43225    0x4357
 
+    brcmfmac (SDIO)
+    Name
+    BCM4329
 
-What's done
-==========
-- Integration with mac80211 stack
-- A-MPDU single & dual stream rates
-- BCM43224:    Dualband, Dual stream, 20MHz channels
-       Throughput (in chamber): ~85-90 Mbits/sec (in both 2.4 & 5 GHz bands)
-- BCM43225:    2.4 GHz, Dual Stream, 20MHz channels
-       Throughput (in chamber): ~85-90 Mbits/sec
-- BCM4313:             2.4 GHz, Single Stream
-       Throughput (in chamber): ~40 Mbits/sec
+Both brcmsmac and brcmfmac drivers require firmware files that need to be
+separately downloaded.
 
-
-Things To Be Done
-=================
-See the TODO file
-
-
-Firmware installation
+Firmware
 ======================
 Firmware is available from the Linux firmware repository at:
 
-       git://git.kernel.org/pub/scm/linux/kernel/git/dwmw2/linux-firmware.git
-       http://git.kernel.org/?p=linux/kernel/git/dwmw2/linux-firmware.git
-       https://git.kernel.org/?p=linux/kernel/git/dwmw2/linux-firmware.git
+    git://git.kernel.org/pub/scm/linux/kernel/git/dwmw2/linux-firmware.git
+    http://git.kernel.org/?p=linux/kernel/git/dwmw2/linux-firmware.git
+    https://git.kernel.org/?p=linux/kernel/git/dwmw2/linux-firmware.git
 
-For all chips, copy brcm/bcm43xx-0.fw and brcm/bcm43xx_hdr-0.fw to
-/lib/firmware/brcm (or wherever firmware is normally installed on your system).
 
-Currently supported chips
-==============
-PCI
-Name           Device ID
-BCM4313                0x4727
-BCM43224       0x4353
-BCM43225       0x4357
+===============================================================
+Broadcom brcmsmac driver
+===============================================================
+- Support for both 32 and 64 bit Linux kernels
 
 
-Bugs/Problems
-==============
-- Driver can get confused while scanning during high throughput, can cause
-  burping, hanging, and possible crashing.
-- Occasional hangs & burps with BCM43224 on 2.4 GHz with dual stream rates.
-- Occasional crashes with BCM43224 on multicore machines.
+Firmware installation
+======================
+Copy brcm/bcm43xx-0.fw and brcm/bcm43xx_hdr-0.fw to
+/lib/firmware/brcm (or wherever firmware is normally installed
+on your system).
 
 
-Note on Regulatory Implementation
-================================
-This generation of chips contain additional regulatory support independent of
-the driver. The devices use a single worldwide regulatory domain, with channels
-12-14 (2.4 GHz band) and channels 52-64 and 100-140 (5 GHz band) restricted to
-passive operation. Transmission on those channels is suppressed until
-appropriate other traffic is observed on those channels.
+===============================================================
+Broadcom brcmfmac driver
+===============================================================
+- Support for 32 bit Linux kernel, 64 bit untested
 
-Within the driver, we use the fictitious country code "X2" to represent this
-worldwide regulatory domain. There is currently no interface to configure a
-different domain.
 
-The driver reads the SROM country code from the chip and hands it up to
-mac80211 as the regulatory hint, however this information is otherwise unused
-with the driver.
+Firmware installation
+======================
+Copy brcm/bcm4329-fullmac-4.bin and brcm/bcm4329-fullmac-4.txt
+to /lib/firmware/brcm (or wherever firmware is normally installed on your
+system).
 
 
 Contact Info:
 =============
 Brett Rudley           brudley@broadcom.com
 Henry Ptasinski                henryp@broadcom.com
-Dowan Kim                      dowan@broadcom.com
+Dowan Kim              dowan@broadcom.com
 Roland Vossen          rvossen@broadcom.com
 Arend van Spriel       arend@broadcom.com
 
+For more info, refer to: http://linuxwireless.org/en/users/Drivers/brcm80211
index 24ebadbe4241f1ffd5178178d7d07b4eb6451fa5..e9c1393a2b92e6a37b8cbff236a8dc08824317e4 100644 (file)
@@ -1,51 +1,15 @@
-To Do List for Broadcom Mac80211 driver
-
-Features to be added
-=====================
-- 40 MHz channels
-- Power Save
-- AP
-- IBSS
-- HW-based encryption
-- LED support
-- RFKILL
-- Debugfs and debugability
-
-Code cleanup
-============
-- Use proper kernel coding standards
-- Remove overlap with system header files. (ie much of include/proto/*.h should
-  be removed)
-- Purge unused variables/data structs/functions BUT keep code related to
-  features that are being added (ie AP mode, 40 Mhz channels, IBSS etc).
-- Replace proprietary utility functions with public kernel versions.
+To Do List for Broadcom Mac80211 driver before getting in mainline
 
 Bugs
 ====
-- Various occasional asserts/hangs
-- Scanning during data transfer sometimes causes major slowdowns.  Sometimes
-  revcovers when scan is done, other times not.
-- Mac80211 API not completely implemented (ie ops_bss_info_changed,
-  ops_get_stats, etc)
-
-Other
-=====
-- wlc_mac80211.[ch], wl_mac80211.[ch] and linux_osl.c all need to be refactored
-    and combined.
-- Merge files that are partially duplicated between the softmac and fullmac
-  drivers
-- Replace driver's proprietary ssb interface with generic kernel ssb module
-  (only used when compiling for SDIO).
-- PCI and SDIO support are currently #ifdef'ed exclusive of each other, which
-  leads to a separate wl.ko for each.  This should be changed to runtime
-  handling of different interfaces so that a single binary driver can be built.
-- Add support for new chips (obviously an ongoing item).
+- Oops on AMPDU traffic, to be solved by new ucode (currently under test)
 
-Contact
-=====
-Brett Rudley <brudley@broadcom.com>
-Henry Ptasinski <henryp@broadcom.com>
-Dowan Kim <dowan@broadcom.com>
-Roland Vossen <rvossen@broadcom.com>
-Arend van Spriel <arend@broadcom.com>
+brcmfmac and brcmsmac
+=====================
+- ASSERTS not allowed in mainline, replace by warning + error handling
+- Replace printk and WL_ERROR() with proper routines
 
+brcmfmac
+=====================
+- Replace driver's proprietary ssb interface with generic kernel ssb module
+- Build and test on 64 bit linux kernel
index ac5a7d4ba80690e40c6ba5274b0e6e6fff5e3055..c5ec562c3645f9b69a0f60c27bddb46db2c32acc 100644 (file)
@@ -36,8 +36,7 @@ ccflags-$(CONFIG_BRCMDBG)     += -DDHD_DEBUG
 
 ccflags-y += \
        -Idrivers/staging/brcm80211/brcmfmac    \
-       -Idrivers/staging/brcm80211/include             \
-       -Idrivers/staging/brcm80211/util
+       -Idrivers/staging/brcm80211/include
 
 DHDOFILES = \
        wl_cfg80211.o \
@@ -51,13 +50,7 @@ DHDOFILES = \
        bcmsdh.o \
        bcmsdh_linux.o  \
        bcmsdh_sdmmc.o \
-       bcmsdh_sdmmc_linux.o \
-       aiutils.o \
-       siutils.o \
-       sbutils.o \
-       bcmutils.o \
-       bcmwifi.o \
-       hndpmu.o
+       bcmsdh_sdmmc_linux.o
 
-obj-m += brcmfmac.o
+obj-$(CONFIG_BRCMFMAC) += brcmfmac.o
 brcmfmac-objs += $(DHDOFILES)
index be29e423692072d57ea3e0f97f41ec2cbae5c7a2..139597f9cb07c5d48bed18984ec4747f4b4f3438 100644 (file)
@@ -1,37 +1,2 @@
-Broadcom fullmac driver
 
-This is production driver.
-
-What's here
-===========
-- Completely open source host driver, no binary object files
-- Features Broadcom's OneDriver architecture (single source base for
-  supported chips and architectures)
-- On-chip firmware loaded using standard request_firmware()
-- Support for BCM4329(SDIO)
-
-What's done
-==========
-- Integration with cfg80211 stack
-- Most of Mac functionality is performed in dongle
-- A-MPDU single stream rates
-- BCM4329:     Dualband, Single stream, 20MHz channels
-
-Firmware installation
-======================
-Firmware is available from the Linux firmware repository at:
-
-       git://git.kernel.org/pub/scm/linux/kernel/git/dwmw2/linux-firmware.git
-       http://git.kernel.org/?p=linux/kernel/git/dwmw2/linux-firmware.git
-       https://git.kernel.org/?p=linux/kernel/git/dwmw2/linux-firmware.git
-
-For 4329 chip, copy brcm/bcm4329-fullmac-4.bin and brcm/bcm4329-fullmac-4.txt
-to /lib/firmware/brcm (or wherever firmware is normally installed on your
-system).
-
-Contact Info:
-=============
-Brett Rudley   brudley@broadcom.com
-Henry Ptasinski henryp@broadcom.com
-Nohee Ko       noheek@broadcom.com
 
similarity index 52%
rename from drivers/staging/brcm80211/util/siutils_priv.h
rename to drivers/staging/brcm80211/brcmfmac/bcmchip.h
index a03ff617531a52af7b9128de2838a5c7c30b9db8..c0d4c3bf6d42f2ab8c3bebcfe4b6dc311789c2b2 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010 Broadcom Corporation
+ * Copyright (c) 2011 Broadcom Corporation
  *
  * Permission to use, copy, modify, and/or distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-#ifndef        _siutils_priv_h_
-#define        _siutils_priv_h_
+#ifndef _bcmchip_h_
+#define _bcmchip_h_
 
-/* Silicon Backplane externs */
-extern void sb_scan(si_t *sih, void *regs, uint devid);
-uint sb_coreid(si_t *sih);
-uint sb_corerev(si_t *sih);
-extern uint sb_corereg(si_t *sih, uint coreidx, uint regoff, uint mask,
-                      uint val);
-extern bool sb_iscoreup(si_t *sih);
-void *sb_setcoreidx(si_t *sih, uint coreidx);
-extern void sb_core_reset(si_t *sih, u32 bits, u32 resetbits);
-extern void sb_core_disable(si_t *sih, u32 bits);
-#endif                         /* _siutils_priv_h_ */
+/* Core reg address translation */
+#define CORE_CC_REG(base, field)       (base + offsetof(chipcregs_t, field))
+#define CORE_BUS_REG(base, field)      (base + offsetof(sdpcmd_regs_t, field))
+#define CORE_SB(base, field) \
+               (base + SBCONFIGOFF + offsetof(sbconfig_t, field))
+
+/* bcm4329 */
+/* SDIO device core, ID 0x829 */
+#define BCM4329_CORE_BUS_BASE          0x18011000
+/* internal memory core, ID 0x80e */
+#define BCM4329_CORE_SOCRAM_BASE       0x18003000
+/* ARM Cortex M3 core, ID 0x82a */
+#define BCM4329_CORE_ARM_BASE          0x18002000
+#define BCM4329_RAMSIZE                        0x48000
+
+#endif                         /* _bcmchip_h_ */
index 473f57d9f00b4895e60ae07b15b88c97dc46a582..3750fcf5a8718dafd0e711e8464dacc6f3659909 100644 (file)
 
 #include <linux/types.h>
 #include <linux/netdevice.h>
+#include <linux/pci_ids.h>
 #include <bcmdefs.h>
 #include <bcmdevs.h>
 #include <bcmutils.h>
 #include <hndsoc.h>
-#include <siutils.h>
 
 #include <bcmsdh.h>            /* BRCM API for SDIO
                         clients (such as wl, dhd) */
@@ -29,6 +29,8 @@
 #include <sbsdio.h>            /* BRCM sdio device core */
 
 #include <sdio.h>              /* sdio spec */
+#include "dngl_stats.h"
+#include "dhd.h"
 
 #define SDIOH_API_ACCESS_RETRY_LIMIT   2
 const uint bcmsdh_msglevel = BCMSDH_ERROR_VAL;
@@ -126,7 +128,7 @@ int bcmsdh_intr_enable(void *sdh)
        ASSERT(bcmsdh);
 
        status = sdioh_interrupt_set(bcmsdh->sdioh, true);
-       return SDIOH_API_SUCCESS(status) ? 0 : BCME_ERROR;
+       return SDIOH_API_SUCCESS(status) ? 0 : -EIO;
 }
 
 int bcmsdh_intr_disable(void *sdh)
@@ -136,7 +138,7 @@ int bcmsdh_intr_disable(void *sdh)
        ASSERT(bcmsdh);
 
        status = sdioh_interrupt_set(bcmsdh->sdioh, false);
-       return SDIOH_API_SUCCESS(status) ? 0 : BCME_ERROR;
+       return SDIOH_API_SUCCESS(status) ? 0 : -EIO;
 }
 
 int bcmsdh_intr_reg(void *sdh, bcmsdh_cb_fn_t fn, void *argh)
@@ -146,7 +148,7 @@ int bcmsdh_intr_reg(void *sdh, bcmsdh_cb_fn_t fn, void *argh)
        ASSERT(bcmsdh);
 
        status = sdioh_interrupt_register(bcmsdh->sdioh, fn, argh);
-       return SDIOH_API_SUCCESS(status) ? 0 : BCME_ERROR;
+       return SDIOH_API_SUCCESS(status) ? 0 : -EIO;
 }
 
 int bcmsdh_intr_dereg(void *sdh)
@@ -156,7 +158,7 @@ int bcmsdh_intr_dereg(void *sdh)
        ASSERT(bcmsdh);
 
        status = sdioh_interrupt_deregister(bcmsdh->sdioh);
-       return SDIOH_API_SUCCESS(status) ? 0 : BCME_ERROR;
+       return SDIOH_API_SUCCESS(status) ? 0 : -EIO;
 }
 
 #if defined(DHD_DEBUG)
@@ -174,7 +176,7 @@ int bcmsdh_devremove_reg(void *sdh, bcmsdh_cb_fn_t fn, void *argh)
        ASSERT(sdh);
 
        /* don't support yet */
-       return BCME_UNSUPPORTED;
+       return -ENOTSUPP;
 }
 
 u8 bcmsdh_cfg_read(void *sdh, uint fnc_num, u32 addr, int *err)
@@ -204,7 +206,7 @@ u8 bcmsdh_cfg_read(void *sdh, uint fnc_num, u32 addr, int *err)
                 && (retry++ < SDIOH_API_ACCESS_RETRY_LIMIT));
 #endif
        if (err)
-               *err = (SDIOH_API_SUCCESS(status) ? 0 : BCME_SDIO_ERROR);
+               *err = (SDIOH_API_SUCCESS(status) ? 0 : -EIO);
 
        BCMSDH_INFO(("%s:fun = %d, addr = 0x%x, u8data = 0x%x\n",
                     __func__, fnc_num, addr, data));
@@ -239,7 +241,7 @@ bcmsdh_cfg_write(void *sdh, uint fnc_num, u32 addr, u8 data, int *err)
                 && (retry++ < SDIOH_API_ACCESS_RETRY_LIMIT));
 #endif
        if (err)
-               *err = SDIOH_API_SUCCESS(status) ? 0 : BCME_SDIO_ERROR;
+               *err = SDIOH_API_SUCCESS(status) ? 0 : -EIO;
 
        BCMSDH_INFO(("%s:fun = %d, addr = 0x%x, u8data = 0x%x\n",
                     __func__, fnc_num, addr, data));
@@ -261,7 +263,7 @@ u32 bcmsdh_cfg_read_word(void *sdh, uint fnc_num, u32 addr, int *err)
                               fnc_num, addr, &data, 4);
 
        if (err)
-               *err = (SDIOH_API_SUCCESS(status) ? 0 : BCME_SDIO_ERROR);
+               *err = (SDIOH_API_SUCCESS(status) ? 0 : -EIO);
 
        BCMSDH_INFO(("%s:fun = %d, addr = 0x%x, u32data = 0x%x\n",
                     __func__, fnc_num, addr, data));
@@ -286,7 +288,7 @@ bcmsdh_cfg_write_word(void *sdh, uint fnc_num, u32 addr, u32 data,
                               SDIOH_WRITE, fnc_num, addr, &data, 4);
 
        if (err)
-               *err = (SDIOH_API_SUCCESS(status) ? 0 : BCME_SDIO_ERROR);
+               *err = (SDIOH_API_SUCCESS(status) ? 0 : -EIO);
 
        BCMSDH_INFO(("%s:fun = %d, addr = 0x%x, u32data = 0x%x\n",
                     __func__, fnc_num, addr, data));
@@ -317,7 +319,7 @@ int bcmsdh_cis_read(void *sdh, uint func, u8 * cis, uint length)
                tmp_buf = kmalloc(length, GFP_ATOMIC);
                if (tmp_buf == NULL) {
                        BCMSDH_ERROR(("%s: out of memory\n", __func__));
-                       return BCME_NOMEM;
+                       return -ENOMEM;
                }
                memcpy(tmp_buf, cis, length);
                for (tmp_ptr = tmp_buf, ptr = cis; ptr < (cis + length - 4);
@@ -329,7 +331,7 @@ int bcmsdh_cis_read(void *sdh, uint func, u8 * cis, uint length)
                kfree(tmp_buf);
        }
 
-       return SDIOH_API_SUCCESS(status) ? 0 : BCME_ERROR;
+       return SDIOH_API_SUCCESS(status) ? 0 : -EIO;
 }
 
 static int bcmsdhsdio_set_sbaddr_window(void *sdh, u32 address)
@@ -467,7 +469,7 @@ bcmsdh_recv_buf(void *sdh, u32 addr, uint fn, uint flags,
        /* Async not implemented yet */
        ASSERT(!(flags & SDIO_REQ_ASYNC));
        if (flags & SDIO_REQ_ASYNC)
-               return BCME_UNSUPPORTED;
+               return -ENOTSUPP;
 
        if (bar0 != bcmsdh->sbwad) {
                err = bcmsdhsdio_set_sbaddr_window(bcmsdh, bar0);
@@ -488,7 +490,7 @@ bcmsdh_recv_buf(void *sdh, u32 addr, uint fn, uint flags,
                                      SDIOH_READ, fn, addr, width, nbytes, buf,
                                      pkt);
 
-       return SDIOH_API_SUCCESS(status) ? 0 : BCME_SDIO_ERROR;
+       return SDIOH_API_SUCCESS(status) ? 0 : -EIO;
 }
 
 int
@@ -512,7 +514,7 @@ bcmsdh_send_buf(void *sdh, u32 addr, uint fn, uint flags,
        /* Async not implemented yet */
        ASSERT(!(flags & SDIO_REQ_ASYNC));
        if (flags & SDIO_REQ_ASYNC)
-               return BCME_UNSUPPORTED;
+               return -ENOTSUPP;
 
        if (bar0 != bcmsdh->sbwad) {
                err = bcmsdhsdio_set_sbaddr_window(bcmsdh, bar0);
@@ -533,7 +535,7 @@ bcmsdh_send_buf(void *sdh, u32 addr, uint fn, uint flags,
                                      SDIOH_WRITE, fn, addr, width, nbytes, buf,
                                      pkt);
 
-       return SDIOH_API_SUCCESS(status) ? 0 : BCME_ERROR;
+       return SDIOH_API_SUCCESS(status) ? 0 : -EIO;
 }
 
 int bcmsdh_rwdata(void *sdh, uint rw, u32 addr, u8 *buf, uint nbytes)
@@ -553,7 +555,7 @@ int bcmsdh_rwdata(void *sdh, uint rw, u32 addr, u8 *buf, uint nbytes)
                                 (rw ? SDIOH_WRITE : SDIOH_READ), SDIO_FUNC_1,
                                 addr, 4, nbytes, buf, NULL);
 
-       return SDIOH_API_SUCCESS(status) ? 0 : BCME_ERROR;
+       return SDIOH_API_SUCCESS(status) ? 0 : -EIO;
 }
 
 int bcmsdh_abort(void *sdh, uint fn)
@@ -580,7 +582,7 @@ int bcmsdh_stop(void *sdh)
 int bcmsdh_query_device(void *sdh)
 {
        bcmsdh_info_t *bcmsdh = (bcmsdh_info_t *) sdh;
-       bcmsdh->vendevid = (VENDOR_BROADCOM << 16) | 0;
+       bcmsdh->vendevid = (PCI_VENDOR_ID_BROADCOM << 16) | 0;
        return bcmsdh->vendevid;
 }
 
index ac5bbc8722e5ac586d5a7d6af361bc0c343e5b56..465f623760f3f4153e82cb7fca033e3a5415bec7 100644 (file)
@@ -43,6 +43,9 @@ extern void dhdsdio_isr(void *args);
 #include <linux/platform_device.h>
 #endif                         /* CONFIG_MACH_SANDGATE2G */
 
+#include "dngl_stats.h"
+#include "dhd.h"
+
 /**
  * SDIO Host Controller info
  */
@@ -87,11 +90,11 @@ bool bcmsdh_chipmatch(u16 vendor, u16 device)
                return true;
 
        /* Check for BRCM 27XX Standard host controller */
-       if (device == BCM27XX_SDIOH_ID && vendor == VENDOR_BROADCOM)
+       if (device == BCM27XX_SDIOH_ID && vendor == PCI_VENDOR_ID_BROADCOM)
                return true;
 
        /* Check for BRCM Standard host controller */
-       if (device == SDIOH_FPGA_ID && vendor == VENDOR_BROADCOM)
+       if (device == SDIOH_FPGA_ID && vendor == PCI_VENDOR_ID_BROADCOM)
                return true;
 
        /* Check for TI PCIxx21 Standard host controller */
@@ -111,8 +114,7 @@ bool bcmsdh_chipmatch(u16 vendor, u16 device)
 #endif                         /* BCMSDIOH_STD */
 #ifdef BCMSDIOH_SPI
        /* This is the PciSpiHost. */
-       if (device == SPIH_FPGA_ID && vendor == VENDOR_BROADCOM) {
-               WL_NONE("Found PCI SPI Host Controller\n");
+       if (device == SPIH_FPGA_ID && vendor == PCI_VENDOR_ID_BROADCOM) {
                return true;
        }
 #endif                         /* BCMSDIOH_SPI */
index 71c3571ee14314e1a975db29d0b5705d6c512795..c0ffbd35e0ca00e6b9ea24e301ad93bb048f7e2b 100644 (file)
 #include <linux/mmc/core.h>
 #include <linux/mmc/sdio_func.h>
 #include <linux/mmc/sdio_ids.h>
+#include <linux/suspend.h>
 
 #include <dngl_stats.h>
 #include <dhd.h>
 
-#if defined(CONFIG_PM_SLEEP)
-#include <linux/suspend.h>
-extern volatile bool dhd_mmc_suspend;
-#endif
 #include "bcmsdh_sdmmc.h"
 
 extern int sdio_function_init(void);
@@ -68,6 +65,13 @@ DHD_PM_RESUME_WAIT_INIT(sdioh_request_buffer_wait);
 int sdioh_sdmmc_card_regread(sdioh_info_t *sd, int func, u32 regaddr,
                             int regsize, u32 *data);
 
+void sdioh_sdio_set_host_pm_flags(int flag)
+{
+       if (sdio_set_host_pm_flags(gInstance->func[1], flag))
+               printk(KERN_ERR "%s: Failed to set pm_flags 0x%08x\n",\
+                        __func__, (unsigned int)flag);
+}
+
 static int sdioh_sdmmc_card_enablefuncs(sdioh_info_t *sd)
 {
        int err_ret;
@@ -416,7 +420,7 @@ sdioh_iovar_op(sdioh_info_t *si, const char *name,
 
        vi = bcm_iovar_lookup(sdioh_iovars, name);
        if (vi == NULL) {
-               bcmerror = BCME_UNSUPPORTED;
+               bcmerror = -ENOTSUPP;
                goto exit;
        }
 
@@ -465,7 +469,7 @@ sdioh_iovar_op(sdioh_info_t *si, const char *name,
 
        case IOV_GVAL(IOV_BLOCKSIZE):
                if ((u32) int_val > si->num_funcs) {
-                       bcmerror = BCME_BADARG;
+                       bcmerror = -EINVAL;
                        break;
                }
                int_val = (s32) si->client_block_size[int_val];
@@ -479,7 +483,7 @@ sdioh_iovar_op(sdioh_info_t *si, const char *name,
                        uint maxsize;
 
                        if (func > si->num_funcs) {
-                               bcmerror = BCME_BADARG;
+                               bcmerror = -EINVAL;
                                break;
                        }
 
@@ -497,7 +501,7 @@ sdioh_iovar_op(sdioh_info_t *si, const char *name,
                                maxsize = 0;
                        }
                        if (blksize > maxsize) {
-                               bcmerror = BCME_BADARG;
+                               bcmerror = -EINVAL;
                                break;
                        }
                        if (!blksize)
@@ -600,7 +604,7 @@ sdioh_iovar_op(sdioh_info_t *si, const char *name,
                            || sd_ptr->offset > SD_MaxCurCap) {
                                sd_err(("%s: bad offset 0x%x\n", __func__,
                                        sd_ptr->offset));
-                               bcmerror = BCME_BADARG;
+                               bcmerror = -EINVAL;
                                break;
                        }
 
@@ -630,7 +634,7 @@ sdioh_iovar_op(sdioh_info_t *si, const char *name,
                            || sd_ptr->offset > SD_MaxCurCap) {
                                sd_err(("%s: bad offset 0x%x\n", __func__,
                                        sd_ptr->offset));
-                               bcmerror = BCME_BADARG;
+                               bcmerror = -EINVAL;
                                break;
                        }
 
@@ -649,7 +653,7 @@ sdioh_iovar_op(sdioh_info_t *si, const char *name,
 
                        if (sdioh_cfg_read
                            (si, sd_ptr->func, sd_ptr->offset, &data)) {
-                               bcmerror = BCME_SDIO_ERROR;
+                               bcmerror = -EIO;
                                break;
                        }
 
@@ -665,14 +669,14 @@ sdioh_iovar_op(sdioh_info_t *si, const char *name,
 
                        if (sdioh_cfg_write
                            (si, sd_ptr->func, sd_ptr->offset, &data)) {
-                               bcmerror = BCME_SDIO_ERROR;
+                               bcmerror = -EIO;
                                break;
                        }
                        break;
                }
 
        default:
-               bcmerror = BCME_UNSUPPORTED;
+               bcmerror = -ENOTSUPP;
                break;
        }
 exit:
@@ -1006,17 +1010,16 @@ sdioh_request_packet(sdioh_info_t *sd, uint fix_inc, uint write, uint func,
 
 /*
  * This function takes a buffer or packet, and fixes everything up
- * so that in the
- * end, a DMA-able packet is created.
+ * so that in the end, a DMA-able packet is created.
  *
  * A buffer does not have an associated packet pointer,
  * and may or may not be aligned.
  * A packet may consist of a single packet, or a packet chain.
- * If it is a packet chain,
- * then all the packets in the chain must be properly aligned.
- * If the packet data is not
- * aligned, then there may only be one packet, and in this case,
- * it is copied to a new
+ * If it is a packet chain, then all the packets in the chain
+ * must be properly aligned.
+ *
+ * If the packet data is not aligned, then there may only be
+ * one packet, and in this case,  it is copied to a new
  * aligned packet.
  *
  */
@@ -1036,9 +1039,9 @@ sdioh_request_buffer(sdioh_info_t *sd, uint pio_dma, uint fix_inc, uint write,
        if (pkt == NULL) {
                sd_data(("%s: Creating new %s Packet, len=%d\n",
                         __func__, write ? "TX" : "RX", buflen_u));
-               mypkt = pkt_buf_get_skb(buflen_u);
+               mypkt = bcm_pkt_buf_get_skb(buflen_u);
                if (!mypkt) {
-                       sd_err(("%s: pkt_buf_get_skb failed: len %d\n",
+                       sd_err(("%s: bcm_pkt_buf_get_skb failed: len %d\n",
                                __func__, buflen_u));
                        return SDIOH_API_RC_FAIL;
                }
@@ -1054,7 +1057,7 @@ sdioh_request_buffer(sdioh_info_t *sd, uint pio_dma, uint fix_inc, uint write,
                if (!write)
                        memcpy(buffer, mypkt->data, buflen_u);
 
-               pkt_buf_free_skb(mypkt);
+               bcm_pkt_buf_free_skb(mypkt);
        } else if (((u32) (pkt->data) & DMA_ALIGN_MASK) != 0) {
                /* Case 2: We have a packet, but it is unaligned. */
 
@@ -1063,9 +1066,9 @@ sdioh_request_buffer(sdioh_info_t *sd, uint pio_dma, uint fix_inc, uint write,
 
                sd_data(("%s: Creating aligned %s Packet, len=%d\n",
                         __func__, write ? "TX" : "RX", pkt->len));
-               mypkt = pkt_buf_get_skb(pkt->len);
+               mypkt = bcm_pkt_buf_get_skb(pkt->len);
                if (!mypkt) {
-                       sd_err(("%s: pkt_buf_get_skb failed: len %d\n",
+                       sd_err(("%s: bcm_pkt_buf_get_skb failed: len %d\n",
                                __func__, pkt->len));
                        return SDIOH_API_RC_FAIL;
                }
@@ -1081,7 +1084,7 @@ sdioh_request_buffer(sdioh_info_t *sd, uint pio_dma, uint fix_inc, uint write,
                if (!write)
                        memcpy(pkt->data, mypkt->data, mypkt->len);
 
-               pkt_buf_free_skb(mypkt);
+               bcm_pkt_buf_free_skb(mypkt);
        } else {                /* case 3: We have a packet and
                                 it is aligned. */
                sd_data(("%s: Aligned %s Packet, direct DMA\n",
index d738d4da54431c50183bc85788c49fbd5e7303ad..2792a4dfe6511ad32a76d092f8ee06d73e6214f7 100644 (file)
@@ -27,6 +27,9 @@
 #include <linux/mmc/sdio_func.h>
 #include <linux/mmc/sdio_ids.h>
 
+#include "dngl_stats.h"
+#include "dhd.h"
+
 #if !defined(SDIO_VENDOR_ID_BROADCOM)
 #define SDIO_VENDOR_ID_BROADCOM                0x02d0
 #endif                         /* !defined(SDIO_VENDOR_ID_BROADCOM) */
@@ -151,11 +154,11 @@ int sdioh_sdmmc_osinit(sdioh_info_t *sd)
        sdos = kmalloc(sizeof(struct sdos_info), GFP_ATOMIC);
        sd->sdos_info = (void *)sdos;
        if (sdos == NULL)
-               return BCME_NOMEM;
+               return -ENOMEM;
 
        sdos->sd = sd;
        spin_lock_init(&sdos->lock);
-       return BCME_OK;
+       return 0;
 }
 
 void sdioh_sdmmc_osfree(sdioh_info_t *sd)
diff --git a/drivers/staging/brcm80211/brcmfmac/bcmutils.c b/drivers/staging/brcm80211/brcmfmac/bcmutils.c
deleted file mode 100644 (file)
index 8e1296a..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../util/bcmutils.c"
diff --git a/drivers/staging/brcm80211/brcmfmac/bcmwifi.c b/drivers/staging/brcm80211/brcmfmac/bcmwifi.c
deleted file mode 100644 (file)
index 9fe988c..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../util/bcmwifi.c"
index 60cf78213a079ea3f1bbead3727f2ee11f13692c..a726b493ea8d6f51025f40652b8eb1706b799d4e 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/random.h>
 #include <linux/spinlock.h>
 #include <linux/ethtool.h>
+#include <linux/suspend.h>
 #include <asm/uaccess.h>
 #include <asm/unaligned.h>
 /* The kernel threading is sdio-specific */
@@ -122,19 +123,22 @@ typedef struct dhd_pub {
 } dhd_pub_t;
 
 #if defined(CONFIG_PM_SLEEP)
-
+extern atomic_t dhd_mmc_suspend;
 #define DHD_PM_RESUME_WAIT_INIT(a) DECLARE_WAIT_QUEUE_HEAD(a);
-#define _DHD_PM_RESUME_WAIT(a, b) do {\
-                       int retry = 0; \
-                       while (dhd_mmc_suspend && retry++ != b) { \
-                               wait_event_timeout(a, false, HZ/100); \
-                       } \
-               }       while (0)
+#define _DHD_PM_RESUME_WAIT(a, b) do { \
+               int retry = 0; \
+               while (atomic_read(&dhd_mmc_suspend) && retry++ != b) { \
+                       wait_event_timeout(a, false, HZ/100); \
+               } \
+       }       while (0)
 #define DHD_PM_RESUME_WAIT(a)  _DHD_PM_RESUME_WAIT(a, 30)
 #define DHD_PM_RESUME_WAIT_FOREVER(a)  _DHD_PM_RESUME_WAIT(a, ~0)
 #define DHD_PM_RESUME_RETURN_ERROR(a)  \
-       do { if (dhd_mmc_suspend) return a; } while (0)
-#define DHD_PM_RESUME_RETURN   do { if (dhd_mmc_suspend) return; } while (0)
+       do { if (atomic_read(&dhd_mmc_suspend)) return a; } while (0)
+#define DHD_PM_RESUME_RETURN   do { \
+       if (atomic_read(&dhd_mmc_suspend)) \
+               return; \
+       } while (0)
 
 #define DHD_SPINWAIT_SLEEP_INIT(a) DECLARE_WAIT_QUEUE_HEAD(a);
 #define SPINWAIT_SLEEP(a, exp, us) do { \
@@ -397,4 +401,14 @@ extern char nv_path[MOD_PARAM_PATHLEN];
 extern void dhd_wait_for_event(dhd_pub_t *dhd, bool * lockvar);
 extern void dhd_wait_event_wakeup(dhd_pub_t *dhd);
 
+extern u32 g_assert_type;
+
+#ifdef BCMDBG
+#define ASSERT(exp) \
+         do { if (!(exp)) osl_assert(#exp, __FILE__, __LINE__); } while (0)
+extern void osl_assert(char *exp, char *file, int line);
+#else
+#define ASSERT(exp)    do {} while (0)
+#endif  /* defined(BCMDBG) */
+
 #endif                         /* _dhd_h_ */
index 39a4d001fbd0cb57991986cc2310cbf26d73dc1f..ba5a5cb7eede5599f760fc6784c756f01a7bfa49 100644 (file)
@@ -111,7 +111,7 @@ dhdcdc_query_ioctl(dhd_pub_t *dhd, int ifidx, uint cmd, void *buf, uint len)
        /* Respond "bcmerror" and "bcmerrorstr" with local cache */
        if (cmd == WLC_GET_VAR && buf) {
                if (!strcmp((char *)buf, "bcmerrorstr")) {
-                       strncpy((char *)buf, bcmerrorstr(dhd->dongle_error),
+                       strncpy((char *)buf, "bcm_error",
                                BCME_STRLEN);
                        goto done;
                } else if (!strcmp((char *)buf, "bcmerror")) {
@@ -253,9 +253,9 @@ dhd_prot_ioctl(dhd_pub_t *dhd, int ifidx, wl_ioctl_t *ioc, void *buf, int len)
                        "lastcmd=0x%x (%lu)\n",
                        ioc->cmd, (unsigned long)ioc->cmd, prot->lastcmd,
                        (unsigned long)prot->lastcmd));
-               if ((ioc->cmd == WLC_SET_VAR) || (ioc->cmd == WLC_GET_VAR)) {
+               if ((ioc->cmd == WLC_SET_VAR) || (ioc->cmd == WLC_GET_VAR))
                        DHD_TRACE(("iovar cmd=%s\n", (char *)buf));
-               }
+
                goto done;
        }
 
@@ -309,7 +309,7 @@ int
 dhd_prot_iovar_op(dhd_pub_t *dhdp, const char *name,
                  void *params, int plen, void *arg, int len, bool set)
 {
-       return BCME_UNSUPPORTED;
+       return -ENOTSUPP;
 }
 
 void dhd_prot_dump(dhd_pub_t *dhdp, struct bcmstrbuf *strbuf)
@@ -357,7 +357,7 @@ int dhd_prot_hdrpull(dhd_pub_t *dhd, int *ifidx, struct sk_buff *pktbuf)
        if (pktbuf->len < BDC_HEADER_LEN) {
                DHD_ERROR(("%s: rx data too short (%d < %d)\n", __func__,
                           pktbuf->len, BDC_HEADER_LEN));
-               return BCME_ERROR;
+               return -EBADE;
        }
 
        h = (struct bdc_header *)(pktbuf->data);
@@ -366,14 +366,14 @@ int dhd_prot_hdrpull(dhd_pub_t *dhd, int *ifidx, struct sk_buff *pktbuf)
        if (*ifidx >= DHD_MAX_IFS) {
                DHD_ERROR(("%s: rx data ifnum out of range (%d)\n",
                           __func__, *ifidx));
-               return BCME_ERROR;
+               return -EBADE;
        }
 
        if (((h->flags & BDC_FLAG_VER_MASK) >> BDC_FLAG_VER_SHIFT) !=
            BDC_PROTO_VER) {
                DHD_ERROR(("%s: non-BDC packet received, flags 0x%x\n",
                           dhd_ifname(dhd, *ifidx), h->flags));
-               return BCME_ERROR;
+               return -EBADE;
        }
 
        if (h->flags & BDC_FLAG_SUM_GOOD) {
@@ -416,7 +416,7 @@ int dhd_prot_attach(dhd_pub_t *dhd)
 
 fail:
        kfree(cdc);
-       return BCME_NOMEM;
+       return -ENOMEM;
 }
 
 /* ~NOTE~ What if another thread is waiting on the semaphore?  Holding it? */
index aa171f6181e950d14cdbb006ec26af47767ac551..0bfb93c0075a48b3e026322cda8bda70cad83869 100644 (file)
@@ -189,7 +189,7 @@ static int dhd_dump(dhd_pub_t *dhdp, char *buf, int buflen)
        /* Add any bus info */
        dhd_bus_dump(dhdp, strbuf);
 
-       return !strbuf->size ? BCME_BUFTOOSHORT : 0;
+       return !strbuf->size ? -EOVERFLOW : 0;
 }
 
 static int
@@ -225,7 +225,7 @@ dhd_doiovar(dhd_pub_t *dhd_pub, const bcm_iovar_t *vi, u32 actionid,
                break;
 
        case IOV_GVAL(IOV_BCMERRORSTR):
-               strncpy((char *)arg, bcmerrorstr(dhd_pub->bcmerror),
+               strncpy((char *)arg, "bcm_error",
                        BCME_STRLEN);
                ((char *)arg)[BCME_STRLEN - 1] = 0x00;
                break;
@@ -242,7 +242,7 @@ dhd_doiovar(dhd_pub_t *dhd_pub, const bcm_iovar_t *vi, u32 actionid,
 
        case IOV_SVAL(IOV_WDTICK):
                if (!dhd_pub->up) {
-                       bcmerror = BCME_NOTUP;
+                       bcmerror = -ENOLINK;
                        break;
                }
                dhd_os_wd_timer(dhd_pub, (uint) int_val);
@@ -289,7 +289,7 @@ dhd_doiovar(dhd_pub_t *dhd_pub, const bcm_iovar_t *vi, u32 actionid,
 
        case IOV_SVAL(IOV_IOCTLTIMEOUT):{
                        if (int_val <= 0)
-                               bcmerror = BCME_BADARG;
+                               bcmerror = -EINVAL;
                        else
                                dhd_os_set_ioctl_resp_timeout((unsigned int)
                                                              int_val);
@@ -297,7 +297,7 @@ dhd_doiovar(dhd_pub_t *dhd_pub, const bcm_iovar_t *vi, u32 actionid,
                }
 
        default:
-               bcmerror = BCME_UNSUPPORTED;
+               bcmerror = -ENOTSUPP;
                break;
        }
 
@@ -316,7 +316,7 @@ bool dhd_prec_enq(dhd_pub_t *dhdp, struct pktq *q, struct sk_buff *pkt,
         * exceeding total queue length
         */
        if (!pktq_pfull(q, prec) && !pktq_full(q)) {
-               pktq_penq(q, prec, pkt);
+               bcm_pktq_penq(q, prec, pkt);
                return true;
        }
 
@@ -324,7 +324,7 @@ bool dhd_prec_enq(dhd_pub_t *dhdp, struct pktq *q, struct sk_buff *pkt,
        if (pktq_pfull(q, prec))
                eprec = prec;
        else if (pktq_full(q)) {
-               p = pktq_peek_tail(q, &eprec);
+               p = bcm_pktq_peek_tail(q, &eprec);
                ASSERT(p);
                if (eprec > prec)
                        return false;
@@ -338,21 +338,21 @@ bool dhd_prec_enq(dhd_pub_t *dhdp, struct pktq *q, struct sk_buff *pkt,
                if (eprec == prec && !discard_oldest)
                        return false;   /* refuse newer (incoming) packet */
                /* Evict packet according to discard policy */
-               p = discard_oldest ? pktq_pdeq(q, eprec) : pktq_pdeq_tail(q,
-                                                 eprec);
+               p = discard_oldest ? bcm_pktq_pdeq(q, eprec) :
+                       bcm_pktq_pdeq_tail(q, eprec);
                if (p == NULL) {
-                       DHD_ERROR(("%s: pktq_penq() failed, oldest %d.",
+                       DHD_ERROR(("%s: bcm_pktq_penq() failed, oldest %d.",
                                   __func__, discard_oldest));
                        ASSERT(p);
                }
 
-               pkt_buf_free_skb(p);
+               bcm_pkt_buf_free_skb(p);
        }
 
        /* Enqueue */
-       p = pktq_penq(q, prec, pkt);
+       p = bcm_pktq_penq(q, prec, pkt);
        if (p == NULL) {
-               DHD_ERROR(("%s: pktq_penq() failed.", __func__));
+               DHD_ERROR(("%s: bcm_pktq_penq() failed.", __func__));
                ASSERT(p);
        }
 
@@ -381,7 +381,7 @@ dhd_iovar_op(dhd_pub_t *dhd_pub, const char *name,
 
        vi = bcm_iovar_lookup(dhd_iovars, name);
        if (vi == NULL) {
-               bcmerror = BCME_UNSUPPORTED;
+               bcmerror = -ENOTSUPP;
                goto exit;
        }
 
@@ -420,19 +420,19 @@ int dhd_ioctl(dhd_pub_t *dhd_pub, dhd_ioctl_t *ioc, void *buf, uint buflen)
        DHD_TRACE(("%s: Enter\n", __func__));
 
        if (!buf)
-               return BCME_BADARG;
+               return -EINVAL;
 
        switch (ioc->cmd) {
        case DHD_GET_MAGIC:
                if (buflen < sizeof(int))
-                       bcmerror = BCME_BUFTOOSHORT;
+                       bcmerror = -EOVERFLOW;
                else
                        *(int *)buf = DHD_IOCTL_MAGIC;
                break;
 
        case DHD_GET_VERSION:
                if (buflen < sizeof(int))
-                       bcmerror = -BCME_BUFTOOSHORT;
+                       bcmerror = -EOVERFLOW;
                else
                        *(int *)buf = DHD_IOCTL_VERSION;
                break;
@@ -448,7 +448,7 @@ int dhd_ioctl(dhd_pub_t *dhd_pub, dhd_ioctl_t *ioc, void *buf, uint buflen)
                                ;
 
                        if (*arg) {
-                               bcmerror = BCME_BUFTOOSHORT;
+                               bcmerror = -EOVERFLOW;
                                break;
                        }
 
@@ -464,7 +464,7 @@ int dhd_ioctl(dhd_pub_t *dhd_pub, dhd_ioctl_t *ioc, void *buf, uint buflen)
                                bcmerror =
                                    dhd_iovar_op(dhd_pub, buf, NULL, 0, arg,
                                                 arglen, IOV_SET);
-                       if (bcmerror != BCME_UNSUPPORTED)
+                       if (bcmerror != -ENOTSUPP)
                                break;
 
                        /* not in generic table, try protocol module */
@@ -476,7 +476,7 @@ int dhd_ioctl(dhd_pub_t *dhd_pub, dhd_ioctl_t *ioc, void *buf, uint buflen)
                                bcmerror = dhd_prot_iovar_op(dhd_pub, buf,
                                                             NULL, 0, arg,
                                                             arglen, IOV_SET);
-                       if (bcmerror != BCME_UNSUPPORTED)
+                       if (bcmerror != -ENOTSUPP)
                                break;
 
                        /* if still not found, try bus module */
@@ -493,7 +493,7 @@ int dhd_ioctl(dhd_pub_t *dhd_pub, dhd_ioctl_t *ioc, void *buf, uint buflen)
                }
 
        default:
-               bcmerror = BCME_UNSUPPORTED;
+               bcmerror = -ENOTSUPP;
        }
 
        return bcmerror;
@@ -586,6 +586,8 @@ static void wl_show_host_event(wl_event_msg_t *event, void *event_data)
        }
 
        DHD_EVENT(("EVENT: %s, event ID = %d\n", event_name, event_type));
+       DHD_EVENT(("flags 0x%04x, status %d, reason %d, auth_type %d MAC %s\n",
+                               flags, status, reason, auth_type, eabuf));
 
        if (flags & WLC_EVENT_MSG_LINK)
                link = true;
@@ -815,14 +817,14 @@ wl_host_event(struct dhd_info *dhd, int *ifidx, void *pktdata,
 
        if (memcmp(BRCM_OUI, &pvt_data->bcm_hdr.oui[0], DOT11_OUI_LEN)) {
                DHD_ERROR(("%s: mismatched OUI, bailing\n", __func__));
-               return BCME_ERROR;
+               return -EBADE;
        }
 
        /* BRCM event pkt may be unaligned - use xxx_ua to load user_subtype. */
        if (get_unaligned_be16(&pvt_data->bcm_hdr.usr_subtype) !=
            BCMILCP_BCM_SUBTYPE_EVENT) {
                DHD_ERROR(("%s: mismatched subtype, bailing\n", __func__));
-               return BCME_ERROR;
+               return -EBADE;
        }
 
        *data_ptr = &pvt_data[1];
@@ -902,7 +904,7 @@ wl_host_event(struct dhd_info *dhd, int *ifidx, void *pktdata,
        wl_show_host_event(event, event_data);
 #endif                         /* SHOW_EVENTS */
 
-       return BCME_OK;
+       return 0;
 }
 
 /* Convert user's input in hex pattern to byte-size mask */
index dd0375793875ce1cdffadf0ea5f27608cbabeca1..f356c564cfb99bf56390bfbfda38e6bb6be21193 100644 (file)
@@ -166,7 +166,7 @@ void wifi_del_dev(void)
 
 #if defined(CONFIG_PM_SLEEP)
 #include <linux/suspend.h>
-volatile bool dhd_mmc_suspend = false;
+atomic_t dhd_mmc_suspend;
 DECLARE_WAIT_QUEUE_HEAD(dhd_dpc_wait);
 #endif /*  defined(CONFIG_PM_SLEEP) */
 
@@ -325,7 +325,7 @@ uint dhd_roam = 1;
 uint dhd_radio_up = 1;
 
 /* Network inteface name */
-char iface_name[IFNAMSIZ];
+char iface_name[IFNAMSIZ] = "wlan";
 module_param_string(iface_name, iface_name, IFNAMSIZ, 0);
 
 /* The following are specific to the SDIO dongle */
@@ -385,10 +385,6 @@ module_param(dhd_pktgen_len, uint, 0);
 #define DHD_COMPILED
 #endif
 
-#if defined(CONFIG_WIRELESS_EXT)
-struct iw_statistics *dhd_get_wireless_stats(struct net_device *dev);
-#endif                         /* defined(CONFIG_WIRELESS_EXT) */
-
 static void dhd_dpc(unsigned long data);
 /* forward decl */
 extern int dhd_wait_pend8021x(struct net_device *dev);
@@ -411,11 +407,11 @@ static int dhd_sleep_pm_callback(struct notifier_block *nfb,
        switch (action) {
        case PM_HIBERNATION_PREPARE:
        case PM_SUSPEND_PREPARE:
-               dhd_mmc_suspend = true;
+               atomic_set(&dhd_mmc_suspend, true);
                return NOTIFY_OK;
        case PM_POST_HIBERNATION:
        case PM_POST_SUSPEND:
-               dhd_mmc_suspend = false;
+               atomic_set(&dhd_mmc_suspend, false);
                return NOTIFY_OK;
        }
        return 0;
@@ -1619,51 +1615,6 @@ static int dhd_ethtool(dhd_info_t *dhd, void *uaddr)
        return 0;
 }
 
-static s16 linuxbcmerrormap[] = { 0,   /* 0 */
-       -EINVAL,                /* BCME_ERROR */
-       -EINVAL,                /* BCME_BADARG */
-       -EINVAL,                /* BCME_BADOPTION */
-       -EINVAL,                /* BCME_NOTUP */
-       -EINVAL,                /* BCME_NOTDOWN */
-       -EINVAL,                /* BCME_NOTAP */
-       -EINVAL,                /* BCME_NOTSTA */
-       -EINVAL,                /* BCME_BADKEYIDX */
-       -EINVAL,                /* BCME_RADIOOFF */
-       -EINVAL,                /* BCME_NOTBANDLOCKED */
-       -EINVAL,                /* BCME_NOCLK */
-       -EINVAL,                /* BCME_BADRATESET */
-       -EINVAL,                /* BCME_BADBAND */
-       -E2BIG,                 /* BCME_BUFTOOSHORT */
-       -E2BIG,                 /* BCME_BUFTOOLONG */
-       -EBUSY,                 /* BCME_BUSY */
-       -EINVAL,                /* BCME_NOTASSOCIATED */
-       -EINVAL,                /* BCME_BADSSIDLEN */
-       -EINVAL,                /* BCME_OUTOFRANGECHAN */
-       -EINVAL,                /* BCME_BADCHAN */
-       -EFAULT,                /* BCME_BADADDR */
-       -ENOMEM,                /* BCME_NORESOURCE */
-       -EOPNOTSUPP,            /* BCME_UNSUPPORTED */
-       -EMSGSIZE,              /* BCME_BADLENGTH */
-       -EINVAL,                /* BCME_NOTREADY */
-       -EPERM,                 /* BCME_NOTPERMITTED */
-       -ENOMEM,                /* BCME_NOMEM */
-       -EINVAL,                /* BCME_ASSOCIATED */
-       -ERANGE,                /* BCME_RANGE */
-       -EINVAL,                /* BCME_NOTFOUND */
-       -EINVAL,                /* BCME_WME_NOT_ENABLED */
-       -EINVAL,                /* BCME_TSPEC_NOTFOUND */
-       -EINVAL,                /* BCME_ACM_NOTSUPPORTED */
-       -EINVAL,                /* BCME_NOT_WME_ASSOCIATION */
-       -EIO,                   /* BCME_SDIO_ERROR */
-       -ENODEV,                /* BCME_DONGLE_DOWN */
-       -EINVAL,                /* BCME_VERSION */
-       -EIO,                   /* BCME_TXFAIL */
-       -EIO,                   /* BCME_RXFAIL */
-       -EINVAL,                /* BCME_NODEVICE */
-       -EINVAL,                /* BCME_NMODE_DISABLED */
-       -ENODATA,               /* BCME_NONRESIDENT */
-};
-
 static int dhd_ioctl_entry(struct net_device *net, struct ifreq *ifr, int cmd)
 {
        dhd_info_t *dhd = *(dhd_info_t **) netdev_priv(net);
@@ -1699,7 +1650,7 @@ static int dhd_ioctl_entry(struct net_device *net, struct ifreq *ifr, int cmd)
 
        /* Copy the ioc control structure part of ioctl request */
        if (copy_from_user(&ioc, ifr->ifr_data, sizeof(wl_ioctl_t))) {
-               bcmerror = -BCME_BADADDR;
+               bcmerror = -EINVAL;
                goto done;
        }
 
@@ -1715,11 +1666,11 @@ static int dhd_ioctl_entry(struct net_device *net, struct ifreq *ifr, int cmd)
                {
                        buf = kmalloc(buflen, GFP_ATOMIC);
                        if (!buf) {
-                               bcmerror = -BCME_NOMEM;
+                               bcmerror = -ENOMEM;
                                goto done;
                        }
                        if (copy_from_user(buf, ioc.buf, buflen)) {
-                               bcmerror = -BCME_BADADDR;
+                               bcmerror = -EINVAL;
                                goto done;
                        }
                }
@@ -1728,12 +1679,12 @@ static int dhd_ioctl_entry(struct net_device *net, struct ifreq *ifr, int cmd)
        /* To differentiate between wl and dhd read 4 more byes */
        if ((copy_from_user(&driver, (char *)ifr->ifr_data + sizeof(wl_ioctl_t),
                            sizeof(uint)) != 0)) {
-               bcmerror = -BCME_BADADDR;
+               bcmerror = -EINVAL;
                goto done;
        }
 
        if (!capable(CAP_NET_ADMIN)) {
-               bcmerror = -BCME_EPERM;
+               bcmerror = -EPERM;
                goto done;
        }
 
@@ -1748,12 +1699,12 @@ static int dhd_ioctl_entry(struct net_device *net, struct ifreq *ifr, int cmd)
        /* send to dongle (must be up, and wl) */
        if ((dhd->pub.busstate != DHD_BUS_DATA)) {
                DHD_ERROR(("%s DONGLE_DOWN,__func__\n", __func__));
-               bcmerror = BCME_DONGLE_DOWN;
+               bcmerror = -EIO;
                goto done;
        }
 
        if (!dhd->pub.iswl) {
-               bcmerror = BCME_DONGLE_DOWN;
+               bcmerror = -EIO;
                goto done;
        }
 
@@ -1781,10 +1732,8 @@ done:
 
        if (bcmerror > 0)
                bcmerror = 0;
-       else if (bcmerror < BCME_LAST)
-               bcmerror = BCME_ERROR;
 
-       return linuxbcmerrormap[-bcmerror];
+       return bcmerror;
 }
 
 static int dhd_stop(struct net_device *net)
@@ -1997,7 +1946,6 @@ dhd_pub_t *dhd_attach(struct dhd_bus *bus, uint bus_hdrlen)
                        strcpy(fw_path, wl_cfg80211_get_fwname());
                        strcpy(nv_path, wl_cfg80211_get_nvramname());
                }
-               wl_cfg80211_dbg_level(DBG_CFG80211_GET());
        }
 
        /* Set up the watchdog timer */
@@ -2062,7 +2010,9 @@ dhd_pub_t *dhd_attach(struct dhd_bus *bus, uint bus_hdrlen)
        g_bus = bus;
 #endif
 #if defined(CONFIG_PM_SLEEP)
-       register_pm_notifier(&dhd_sleep_pm_notifier);
+       atomic_set(&dhd_mmc_suspend, false);
+       if (!IS_CFG80211_FAVORITE())
+               register_pm_notifier(&dhd_sleep_pm_notifier);
 #endif /* defined(CONFIG_PM_SLEEP) */
        /* && defined(DHD_GPL) */
        /* Init lock suspend to prevent kernel going to suspend */
@@ -2252,18 +2202,6 @@ int dhd_net_attach(dhd_pub_t *dhdp, int ifidx)
        net->hard_header_len = ETH_HLEN + dhd->pub.hdrlen;
        net->ethtool_ops = &dhd_ethtool_ops;
 
-#if defined(CONFIG_WIRELESS_EXT)
-       if (!IS_CFG80211_FAVORITE()) {
-#if WIRELESS_EXT < 19
-               net->get_wireless_stats = dhd_get_wireless_stats;
-#endif                         /* WIRELESS_EXT < 19 */
-#if WIRELESS_EXT > 12
-               net->wireless_handlers =
-                   (struct iw_handler_def *)&wl_iw_handler_def;
-#endif                         /* WIRELESS_EXT > 12 */
-       }
-#endif                         /* defined(CONFIG_WIRELESS_EXT) */
-
        dhd->pub.rxsz = net->mtu + net->hard_header_len + dhd->pub.hdrlen;
 
        memcpy(net->dev_addr, temp_addr, ETH_ALEN);
@@ -2280,7 +2218,7 @@ int dhd_net_attach(dhd_pub_t *dhdp, int ifidx)
 
 fail:
        net->netdev_ops = NULL;
-       return BCME_ERROR;
+       return -EBADE;
 }
 
 void dhd_bus_detach(dhd_pub_t *dhdp)
@@ -2368,7 +2306,8 @@ void dhd_detach(dhd_pub_t *dhdp)
                                wl_cfg80211_detach();
 
 #if defined(CONFIG_PM_SLEEP)
-                       unregister_pm_notifier(&dhd_sleep_pm_notifier);
+                       if (!IS_CFG80211_FAVORITE())
+                               unregister_pm_notifier(&dhd_sleep_pm_notifier);
 #endif /* defined(CONFIG_PM_SLEEP) */
                        /* && defined(DHD_GPL) */
                        free_netdev(ifp->net);
@@ -2670,21 +2609,6 @@ void dhd_os_sdtxunlock(dhd_pub_t *pub)
        dhd_os_sdunlock(pub);
 }
 
-#if defined(CONFIG_WIRELESS_EXT)
-struct iw_statistics *dhd_get_wireless_stats(struct net_device *dev)
-{
-       int res = 0;
-       dhd_info_t *dhd = *(dhd_info_t **) netdev_priv(dev);
-
-       res = wl_iw_get_wireless_stats(dev, &dhd->iw.wstats);
-
-       if (res == 0)
-               return &dhd->iw.wstats;
-       else
-               return NULL;
-}
-#endif /* defined(CONFIG_WIRELESS_EXT) */
-
 static int
 dhd_wl_host_event(dhd_info_t *dhd, int *ifidx, void *pktdata,
                  wl_event_msg_t *event, void **data)
@@ -2694,7 +2618,7 @@ dhd_wl_host_event(dhd_info_t *dhd, int *ifidx, void *pktdata,
        ASSERT(dhd != NULL);
 
        bcmerror = wl_host_event(dhd, ifidx, pktdata, event, data);
-       if (bcmerror != BCME_OK)
+       if (bcmerror != 0)
                return bcmerror;
 
 #if defined(CONFIG_WIRELESS_EXT)
@@ -2894,6 +2818,13 @@ int dhd_wait_pend8021x(struct net_device *dev)
        return pend;
 }
 
+void wl_os_wd_timer(struct net_device *ndev, uint wdtick)
+{
+       dhd_info_t *dhd = *(dhd_info_t **)netdev_priv(ndev);
+
+       dhd_os_wd_timer(&dhd->pub, wdtick);
+}
+
 #ifdef DHD_DEBUG
 int write_to_file(dhd_pub_t *dhd, u8 *buf, int size)
 {
index 464f52af1315b8fc3107cd209fa0a345275b4c93..a71c6f8ee8a388f943bef128ccb626b2cfce5fb8 100644 (file)
  */
 
 #include <linux/types.h>
-#include <bcmdefs.h>
+#include <linux/kernel.h>
+#include <linux/printk.h>
+#include <linux/pci_ids.h>
 #include <linux/netdevice.h>
+#include <bcmdefs.h>
 #include <bcmsdh.h>
 
 #ifdef BCMEMBEDIMAGE
@@ -27,8 +30,6 @@
 #include <bcmutils.h>
 #include <bcmdevs.h>
 
-#include <siutils.h>
-#include <hndpmu.h>
 #include <hndsoc.h>
 #ifdef DHD_DEBUG
 #include <hndrte_armtrap.h>
@@ -51,7 +52,7 @@
 #include <dhd_dbg.h>
 #include <dhdioctl.h>
 #include <sdiovar.h>
-#include <siutils_priv.h>
+#include <bcmchip.h>
 
 #ifndef DHDSDIO_MEM_DUMP_FNAME
 #define DHDSDIO_MEM_DUMP_FNAME         "mem_dump"
 /* Flags for SDH calls */
 #define F2SYNC (SDIO_REQ_4BYTE | SDIO_REQ_FIXED)
 
-/* Packet free applicable unconditionally for sdio and sdspi.  Conditional if
- * bufpool was present for gspi bus.
- */
-#define PKTFREE2()             if ((bus->bus != SPI_BUS) || bus->usebufpool) \
-                                                       pkt_buf_free_skb(pkt);
-
 /*
  * Conversion of 802.1D priority to precedence level
  */
@@ -165,12 +160,28 @@ typedef struct dhd_console {
 } dhd_console_t;
 #endif                         /* DHD_DEBUG */
 
+/* misc chip info needed by some of the routines */
+struct chip_info {
+       u32 chip;
+       u32 chiprev;
+       u32 cccorebase;
+       u32 ccrev;
+       u32 cccaps;
+       u32 buscorebase;
+       u32 buscorerev;
+       u32 buscoretype;
+       u32 ramcorebase;
+       u32 armcorebase;
+       u32 pmurev;
+       u32 ramsize;
+};
+
 /* Private data for SDIO bus interaction */
 typedef struct dhd_bus {
        dhd_pub_t *dhd;
 
        bcmsdh_info_t *sdh;     /* Handle for BCMSDH calls */
-       si_t *sih;              /* Handle for SI calls */
+       struct chip_info *ci;   /* Chip info struct */
        char *vars;             /* Variables (from CIS and/or other) */
        uint varsz;             /* Size of variables buffer */
        u32 sbaddr;             /* Current SB window pointer (-1, invalid) */
@@ -421,8 +432,6 @@ do { \
 
 #define HOSTINTMASK            (I_HMB_SW_MASK | I_CHIPACTIVE)
 
-#define GSPI_PR55150_BAILOUT
-
 #ifdef SDTEST
 static void dhdsdio_testrcv(dhd_bus_t *bus, void *pkt, uint seq);
 static void dhdsdio_sdtest_set(dhd_bus_t *bus, bool start);
@@ -447,10 +456,6 @@ static void dhdsdio_release_dongle(dhd_bus_t *bus);
 static uint process_nvram_vars(char *varbuf, uint len);
 
 static void dhd_dongle_setmemsize(struct dhd_bus *bus, int mem_size);
-static int dhd_bcmsdh_recv_buf(dhd_bus_t *bus, u32 addr, uint fn,
-                              uint flags, u8 *buf, uint nbytes,
-                              struct sk_buff *pkt, bcmsdh_cmplt_fn_t complete,
-                              void *handle);
 static int dhd_bcmsdh_send_buf(dhd_bus_t *bus, u32 addr, uint fn,
                               uint flags, u8 *buf, uint nbytes,
                               struct sk_buff *pkt, bcmsdh_cmplt_fn_t complete,
@@ -464,6 +469,23 @@ static int dhdsdio_download_nvram(struct dhd_bus *bus);
 #ifdef BCMEMBEDIMAGE
 static int dhdsdio_download_code_array(struct dhd_bus *bus);
 #endif
+static void dhdsdio_chip_disablecore(bcmsdh_info_t *sdh, u32 corebase);
+static int dhdsdio_chip_attach(struct dhd_bus *bus, void *regs);
+static void dhdsdio_chip_resetcore(bcmsdh_info_t *sdh, u32 corebase);
+static void dhdsdio_sdiod_drive_strength_init(struct dhd_bus *bus,
+                                       u32 drivestrength);
+static void dhdsdio_chip_detach(struct dhd_bus *bus);
+
+/* Packet free applicable unconditionally for sdio and sdspi.
+ * Conditional if bufpool was present for gspi bus.
+ */
+static void dhdsdio_pktfree2(dhd_bus_t *bus, struct sk_buff *pkt)
+{
+       dhd_os_sdlock_rxq(bus->dhd);
+       if ((bus->bus != SPI_BUS) || bus->usebufpool)
+               bcm_pkt_buf_free_skb(pkt);
+       dhd_os_sdunlock_rxq(bus->dhd);
+}
 
 static void dhd_dongle_setmemsize(struct dhd_bus *bus, int mem_size)
 {
@@ -511,8 +533,8 @@ static int dhdsdio_htclk(dhd_bus_t *bus, bool on, bool pendok)
                clkreq =
                    bus->alp_only ? SBSDIO_ALP_AVAIL_REQ : SBSDIO_HT_AVAIL_REQ;
 
-               if ((bus->sih->chip == BCM4329_CHIP_ID)
-                   && (bus->sih->chiprev == 0))
+               if ((bus->ci->chip == BCM4329_CHIP_ID)
+                   && (bus->ci->chiprev == 0))
                        clkreq |= SBSDIO_FORCE_ALP;
 
                bcmsdh_cfg_write(sdh, SDIO_FUNC_1, SBSDIO_FUNC1_CHIPCLKCSR,
@@ -520,11 +542,11 @@ static int dhdsdio_htclk(dhd_bus_t *bus, bool on, bool pendok)
                if (err) {
                        DHD_ERROR(("%s: HT Avail request error: %d\n",
                                   __func__, err));
-                       return BCME_ERROR;
+                       return -EBADE;
                }
 
-               if (pendok && ((bus->sih->buscoretype == PCMCIA_CORE_ID)
-                              && (bus->sih->buscorerev == 9))) {
+               if (pendok && ((bus->ci->buscoretype == PCMCIA_CORE_ID)
+                              && (bus->ci->buscorerev == 9))) {
                        u32 dummy, retries;
                        R_SDREG(dummy, &bus->regs->clockctlstatus, retries);
                }
@@ -536,7 +558,7 @@ static int dhdsdio_htclk(dhd_bus_t *bus, bool on, bool pendok)
                if (err) {
                        DHD_ERROR(("%s: HT Avail read error: %d\n",
                                   __func__, err));
-                       return BCME_ERROR;
+                       return -EBADE;
                }
 
                /* Go to pending and await interrupt if appropriate */
@@ -548,7 +570,7 @@ static int dhdsdio_htclk(dhd_bus_t *bus, bool on, bool pendok)
                        if (err) {
                                DHD_ERROR(("%s: Devctl error setting CA: %d\n",
                                        __func__, err));
-                               return BCME_ERROR;
+                               return -EBADE;
                        }
 
                        devctl |= SBSDIO_DEVCTL_CA_INT_ONLY;
@@ -557,7 +579,7 @@ static int dhdsdio_htclk(dhd_bus_t *bus, bool on, bool pendok)
                        DHD_INFO(("CLKCTL: set PENDING\n"));
                        bus->clkstate = CLK_PENDING;
 
-                       return BCME_OK;
+                       return 0;
                } else if (bus->clkstate == CLK_PENDING) {
                        /* Cancel CA-only interrupt filter */
                        devctl =
@@ -581,12 +603,12 @@ static int dhdsdio_htclk(dhd_bus_t *bus, bool on, bool pendok)
                if (err) {
                        DHD_ERROR(("%s: HT Avail request error: %d\n",
                                   __func__, err));
-                       return BCME_ERROR;
+                       return -EBADE;
                }
                if (!SBSDIO_CLKAV(clkctl, bus->alp_only)) {
                        DHD_ERROR(("%s: HT Avail timeout (%d): clkctl 0x%02x\n",
                                   __func__, PMU_MAX_TRANSITION_DLY, clkctl));
-                       return BCME_ERROR;
+                       return -EBADE;
                }
 
                /* Mark clock available */
@@ -630,10 +652,10 @@ static int dhdsdio_htclk(dhd_bus_t *bus, bool on, bool pendok)
                if (err) {
                        DHD_ERROR(("%s: Failed access turning clock off: %d\n",
                                   __func__, err));
-                       return BCME_ERROR;
+                       return -EBADE;
                }
        }
-       return BCME_OK;
+       return 0;
 }
 
 /* Change idle/active SD state */
@@ -653,7 +675,7 @@ static int dhdsdio_sdclk(dhd_bus_t *bus, bool on)
                        if (err) {
                                DHD_ERROR(("%s: error enabling sd_clock: %d\n",
                                           __func__, err));
-                               return BCME_ERROR;
+                               return -EBADE;
                        }
 
                        iovalue = bus->sd_mode;
@@ -662,7 +684,7 @@ static int dhdsdio_sdclk(dhd_bus_t *bus, bool on)
                        if (err) {
                                DHD_ERROR(("%s: error changing sd_mode: %d\n",
                                           __func__, err));
-                               return BCME_ERROR;
+                               return -EBADE;
                        }
                } else if (bus->idleclock != DHD_IDLE_ACTIVE) {
                        /* Restore clock speed */
@@ -672,7 +694,7 @@ static int dhdsdio_sdclk(dhd_bus_t *bus, bool on)
                        if (err) {
                                DHD_ERROR(("%s: error restoring sd_divisor: %d\n",
                                        __func__, err));
-                               return BCME_ERROR;
+                               return -EBADE;
                        }
                }
                bus->clkstate = CLK_SDONLY;
@@ -681,7 +703,7 @@ static int dhdsdio_sdclk(dhd_bus_t *bus, bool on)
                if ((bus->sd_divisor == -1) || (bus->sd_mode == -1)) {
                        DHD_TRACE(("%s: can't idle clock, divisor %d mode %d\n",
                                   __func__, bus->sd_divisor, bus->sd_mode));
-                       return BCME_ERROR;
+                       return -EBADE;
                }
                if (bus->idleclock == DHD_IDLE_STOP) {
                        if (sd1idle) {
@@ -694,7 +716,7 @@ static int dhdsdio_sdclk(dhd_bus_t *bus, bool on)
                                if (err) {
                                        DHD_ERROR(("%s: error changing sd_clock: %d\n",
                                                __func__, err));
-                                       return BCME_ERROR;
+                                       return -EBADE;
                                }
                        }
 
@@ -704,7 +726,7 @@ static int dhdsdio_sdclk(dhd_bus_t *bus, bool on)
                        if (err) {
                                DHD_ERROR(("%s: error disabling sd_clock: %d\n",
                                           __func__, err));
-                               return BCME_ERROR;
+                               return -EBADE;
                        }
                } else if (bus->idleclock != DHD_IDLE_ACTIVE) {
                        /* Set divisor to idle value */
@@ -714,13 +736,13 @@ static int dhdsdio_sdclk(dhd_bus_t *bus, bool on)
                        if (err) {
                                DHD_ERROR(("%s: error changing sd_divisor: %d\n",
                                        __func__, err));
-                               return BCME_ERROR;
+                               return -EBADE;
                        }
                }
                bus->clkstate = CLK_NONE;
        }
 
-       return BCME_OK;
+       return 0;
 }
 
 /* Transition SD and backplane clock readiness */
@@ -738,7 +760,7 @@ static int dhdsdio_clkctl(dhd_bus_t *bus, uint target, bool pendok)
                        dhd_os_wd_timer(bus->dhd, dhd_watchdog_ms);
                        bus->activity = true;
                }
-               return BCME_OK;
+               return 0;
        }
 
        switch (target) {
@@ -777,7 +799,7 @@ static int dhdsdio_clkctl(dhd_bus_t *bus, uint target, bool pendok)
        DHD_INFO(("dhdsdio_clkctl: %d -> %d\n", oldstate, bus->clkstate));
 #endif                         /* DHD_DEBUG */
 
-       return BCME_OK;
+       return 0;
 }
 
 int dhdsdio_bussleep(dhd_bus_t *bus, bool sleep)
@@ -792,13 +814,13 @@ int dhdsdio_bussleep(dhd_bus_t *bus, bool sleep)
 
        /* Done if we're already in the requested state */
        if (sleep == bus->sleeping)
-               return BCME_OK;
+               return 0;
 
        /* Going to sleep: set the alarm and turn off the lights... */
        if (sleep) {
                /* Don't sleep if something is pending */
                if (bus->dpc_sched || bus->rxskip || pktq_len(&bus->txq))
-                       return BCME_BUSY;
+                       return -EBUSY;
 
                /* Disable SDIO interrupts (no longer interested) */
                bcmsdh_intr_disable(bus->sdh);
@@ -818,8 +840,8 @@ int dhdsdio_bussleep(dhd_bus_t *bus, bool sleep)
                                 SBSDIO_FORCE_HW_CLKREQ_OFF, NULL);
 
                /* Isolate the bus */
-               if (bus->sih->chip != BCM4329_CHIP_ID
-                   && bus->sih->chip != BCM4319_CHIP_ID) {
+               if (bus->ci->chip != BCM4329_CHIP_ID
+                   && bus->ci->chip != BCM4319_CHIP_ID) {
                        bcmsdh_cfg_write(sdh, SDIO_FUNC_1, SBSDIO_DEVICE_CTL,
                                         SBSDIO_DEVCTL_PADS_ISO, NULL);
                }
@@ -835,8 +857,8 @@ int dhdsdio_bussleep(dhd_bus_t *bus, bool sleep)
 
                /* Force pad isolation off if possible
                         (in case power never toggled) */
-               if ((bus->sih->buscoretype == PCMCIA_CORE_ID)
-                   && (bus->sih->buscorerev >= 10))
+               if ((bus->ci->buscoretype == PCMCIA_CORE_ID)
+                   && (bus->ci->buscorerev >= 10))
                        bcmsdh_cfg_write(sdh, SDIO_FUNC_1, SBSDIO_DEVICE_CTL, 0,
                                         NULL);
 
@@ -864,7 +886,7 @@ int dhdsdio_bussleep(dhd_bus_t *bus, bool sleep)
                }
        }
 
-       return BCME_OK;
+       return 0;
 }
 
 #if defined(OOB_INTR_ONLY)
@@ -922,7 +944,7 @@ static int dhdsdio_txpkt(dhd_bus_t *bus, struct sk_buff *pkt, uint chan,
        sdh = bus->sdh;
 
        if (bus->dhd->dongle_reset) {
-               ret = BCME_NOTREADY;
+               ret = -EPERM;
                goto done;
        }
 
@@ -935,19 +957,19 @@ static int dhdsdio_txpkt(dhd_bus_t *bus, struct sk_buff *pkt, uint chan,
                        DHD_INFO(("%s: insufficient headroom %d for %d pad\n",
                                  __func__, skb_headroom(pkt), pad));
                        bus->dhd->tx_realloc++;
-                       new = pkt_buf_get_skb(pkt->len + DHD_SDALIGN);
+                       new = bcm_pkt_buf_get_skb(pkt->len + DHD_SDALIGN);
                        if (!new) {
                                DHD_ERROR(("%s: couldn't allocate new %d-byte "
                                        "packet\n",
                                        __func__, pkt->len + DHD_SDALIGN));
-                               ret = BCME_NOMEM;
+                               ret = -ENOMEM;
                                goto done;
                        }
 
                        PKTALIGN(new, pkt->len, DHD_SDALIGN);
                        memcpy(new->data, pkt->data, pkt->len);
                        if (free_pkt)
-                               pkt_buf_free_skb(pkt);
+                               bcm_pkt_buf_free_skb(pkt);
                        /* free the pkt if canned one is not used */
                        free_pkt = true;
                        pkt = new;
@@ -983,9 +1005,12 @@ static int dhdsdio_txpkt(dhd_bus_t *bus, struct sk_buff *pkt, uint chan,
        if (DHD_BYTES_ON() &&
            (((DHD_CTL_ON() && (chan == SDPCM_CONTROL_CHANNEL)) ||
              (DHD_DATA_ON() && (chan != SDPCM_CONTROL_CHANNEL))))) {
-               prhex("Tx Frame", frame, len);
+               printk(KERN_DEBUG "Tx Frame:\n");
+               print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, frame, len);
        } else if (DHD_HDRS_ON()) {
-               prhex("TxHdr", frame, min_t(u16, len, 16));
+               printk(KERN_DEBUG "TxHdr:\n");
+               print_hex_dump_bytes("", DUMP_PREFIX_OFFSET,
+                                    frame, min_t(u16, len, 16));
        }
 #endif
 
@@ -1019,7 +1044,7 @@ static int dhdsdio_txpkt(dhd_bus_t *bus, struct sk_buff *pkt, uint chan,
                    dhd_bcmsdh_send_buf(bus, bcmsdh_cur_sbwad(sdh), SDIO_FUNC_2,
                                        F2SYNC, frame, len, pkt, NULL, NULL);
                bus->f2txdata++;
-               ASSERT(ret != BCME_PENDING);
+               ASSERT(ret != -BCME_PENDING);
 
                if (ret < 0) {
                        /* On failure, abort the command
@@ -1061,14 +1086,14 @@ done:
        dhd_os_sdlock(bus->dhd);
 
        if (free_pkt)
-               pkt_buf_free_skb(pkt);
+               bcm_pkt_buf_free_skb(pkt);
 
        return ret;
 }
 
 int dhd_bus_txdata(struct dhd_bus *bus, struct sk_buff *pkt)
 {
-       int ret = BCME_ERROR;
+       int ret = -EBADE;
        uint datalen, prec;
 
        DHD_TRACE(("%s: Enter\n", __func__));
@@ -1110,11 +1135,11 @@ int dhd_bus_txdata(struct dhd_bus *bus, struct sk_buff *pkt)
                if (dhd_prec_enq(bus->dhd, &bus->txq, pkt, prec) == false) {
                        skb_pull(pkt, SDPCM_HDRLEN);
                        dhd_txcomplete(bus->dhd, pkt, false);
-                       pkt_buf_free_skb(pkt);
+                       bcm_pkt_buf_free_skb(pkt);
                        DHD_ERROR(("%s: out of bus->txq !!!\n", __func__));
-                       ret = BCME_NORESOURCE;
+                       ret = -ENOSR;
                } else {
-                       ret = BCME_OK;
+                       ret = 0;
                }
                dhd_os_sdunlock_txq(bus->dhd);
 
@@ -1183,7 +1208,7 @@ static uint dhdsdio_sendfromq(dhd_bus_t *bus, uint maxframes)
        /* Send frames until the limit or some other event */
        for (cnt = 0; (cnt < maxframes) && DATAOK(bus); cnt++) {
                dhd_os_sdlock_txq(bus->dhd);
-               pkt = pktq_mdeq(&bus->txq, tx_prec_map, &prec_out);
+               pkt = bcm_pktq_mdeq(&bus->txq, tx_prec_map, &prec_out);
                if (pkt == NULL) {
                        dhd_os_sdunlock_txq(bus->dhd);
                        break;
@@ -1313,10 +1338,15 @@ int dhd_bus_txctl(struct dhd_bus *bus, unsigned char *msg, uint msglen)
 
        if (ret == -1) {
 #ifdef DHD_DEBUG
-               if (DHD_BYTES_ON() && DHD_CTL_ON())
-                       prhex("Tx Frame", frame, len);
-               else if (DHD_HDRS_ON())
-                       prhex("TxHdr", frame, min_t(u16, len, 16));
+               if (DHD_BYTES_ON() && DHD_CTL_ON()) {
+                       printk(KERN_DEBUG "Tx Frame:\n");
+                       print_hex_dump_bytes("", DUMP_PREFIX_OFFSET,
+                                            frame, len);
+               } else if (DHD_HDRS_ON()) {
+                       printk(KERN_DEBUG "TxHdr:\n");
+                       print_hex_dump_bytes("", DUMP_PREFIX_OFFSET,
+                                            frame, min_t(u16, len, 16));
+               }
 #endif
 
                do {
@@ -1326,7 +1356,7 @@ int dhd_bus_txctl(struct dhd_bus *bus, unsigned char *msg, uint msglen)
                                                SDIO_FUNC_2, F2SYNC, frame, len,
                                                NULL, NULL, NULL);
 
-                       ASSERT(ret != BCME_PENDING);
+                       ASSERT(ret != -BCME_PENDING);
 
                        if (ret < 0) {
                                /* On failure, abort the command and
@@ -1669,7 +1699,7 @@ static int dhdsdio_pktgen_set(dhd_bus_t *bus, u8 *arg)
 
        memcpy(&pktgen, arg, sizeof(pktgen));
        if (pktgen.version != DHD_PKTGEN_VERSION)
-               return BCME_BADARG;
+               return -EINVAL;
 
        oldcnt = bus->pktgen_count;
        oldmode = bus->pktgen_mode;
@@ -1778,7 +1808,7 @@ static int dhdsdio_readshared(dhd_bus_t *bus, sdpcm_shared_t *sh)
        if (addr == 0 || ((~addr >> 16) & 0xffff) == (addr & 0xffff)) {
                DHD_ERROR(("%s: address (0x%08x) of sdpcm_shared invalid\n",
                           __func__, addr));
-               return BCME_ERROR;
+               return -EBADE;
        }
 
        /* Read hndrte_shared structure */
@@ -1801,10 +1831,10 @@ static int dhdsdio_readshared(dhd_bus_t *bus, sdpcm_shared_t *sh)
                           "is different than sdpcm_shared version %d in dongle\n",
                           __func__, SDPCM_SHARED_VERSION,
                           sh->flags & SDPCM_SHARED_VERSION_MASK));
-               return BCME_ERROR;
+               return -EBADE;
        }
 
-       return BCME_OK;
+       return 0;
 }
 
 static int dhdsdio_checkdied(dhd_bus_t *bus, u8 *data, uint size)
@@ -1830,7 +1860,7 @@ static int dhdsdio_checkdied(dhd_bus_t *bus, u8 *data, uint size)
                if (mbuffer == NULL) {
                        DHD_ERROR(("%s: kmalloc(%d) failed\n", __func__,
                                   msize));
-                       bcmerror = BCME_NOMEM;
+                       bcmerror = -ENOMEM;
                        goto done;
                }
        }
@@ -1838,7 +1868,7 @@ static int dhdsdio_checkdied(dhd_bus_t *bus, u8 *data, uint size)
        str = kmalloc(maxstrlen, GFP_ATOMIC);
        if (str == NULL) {
                DHD_ERROR(("%s: kmalloc(%d) failed\n", __func__, maxstrlen));
-               bcmerror = BCME_NOMEM;
+               bcmerror = -ENOMEM;
                goto done;
        }
 
@@ -2007,19 +2037,19 @@ static int dhdsdio_readconsole(dhd_bus_t *bus)
                c->bufsize = le32_to_cpu(c->log.buf_size);
                c->buf = kmalloc(c->bufsize, GFP_ATOMIC);
                if (c->buf == NULL)
-                       return BCME_NOMEM;
+                       return -ENOMEM;
        }
 
        idx = le32_to_cpu(c->log.idx);
 
        /* Protect against corrupt value */
        if (idx > c->bufsize)
-               return BCME_ERROR;
+               return -EBADE;
 
        /* Skip reading the console buffer if the index pointer
         has not moved */
        if (idx == c->last)
-               return BCME_OK;
+               return 0;
 
        /* Read the console buffer */
        addr = le32_to_cpu(c->log.buf);
@@ -2057,23 +2087,23 @@ static int dhdsdio_readconsole(dhd_bus_t *bus)
        }
 break2:
 
-       return BCME_OK;
+       return 0;
 }
 #endif                         /* DHD_DEBUG */
 
 int dhdsdio_downloadvars(dhd_bus_t *bus, void *arg, int len)
 {
-       int bcmerror = BCME_OK;
+       int bcmerror = 0;
 
        DHD_TRACE(("%s: Enter\n", __func__));
 
        /* Basic sanity checks */
        if (bus->dhd->up) {
-               bcmerror = BCME_NOTDOWN;
+               bcmerror = -EISCONN;
                goto err;
        }
        if (!len) {
-               bcmerror = BCME_BUFTOOSHORT;
+               bcmerror = -EOVERFLOW;
                goto err;
        }
 
@@ -2083,7 +2113,7 @@ int dhdsdio_downloadvars(dhd_bus_t *bus, void *arg, int len)
        bus->vars = kmalloc(len, GFP_ATOMIC);
        bus->varsz = bus->vars ? len : 0;
        if (bus->vars == NULL) {
-               bcmerror = BCME_NOMEM;
+               bcmerror = -ENOMEM;
                goto err;
        }
 
@@ -2122,7 +2152,7 @@ dhdsdio_doiovar(dhd_bus_t *bus, const bcm_iovar_t *vi, u32 actionid,
        /* Check if dongle is in reset. If so, only allow DEVRESET iovars */
        if (bus->dhd->dongle_reset && !(actionid == IOV_SVAL(IOV_DEVRESET) ||
                                        actionid == IOV_GVAL(IOV_DEVRESET))) {
-               bcmerror = BCME_NOTREADY;
+               bcmerror = -EPERM;
                goto exit;
        }
 
@@ -2182,7 +2212,7 @@ dhdsdio_doiovar(dhd_bus_t *bus, const bcm_iovar_t *vi, u32 actionid,
 
        case IOV_SVAL(IOV_IDLETIME):
                if ((int_val < 0) && (int_val != DHD_IDLE_IMMEDIATE))
-                       bcmerror = BCME_BADARG;
+                       bcmerror = -EINVAL;
                else
                        bus->idletime = int_val;
                break;
@@ -2228,7 +2258,7 @@ dhdsdio_doiovar(dhd_bus_t *bus, const bcm_iovar_t *vi, u32 actionid,
                                "0x%08x size %d dsize %d\n",
                                __func__, (set ? "set" : "get"),
                                address, size, dsize));
-                               bcmerror = BCME_BADARG;
+                               bcmerror = -EINVAL;
                                break;
                        }
 
@@ -2243,7 +2273,7 @@ dhdsdio_doiovar(dhd_bus_t *bus, const bcm_iovar_t *vi, u32 actionid,
                                DHD_ERROR(("%s: ramsize 0x%08x doesn't have %d "
                                "bytes at 0x%08x\n",
                                __func__, bus->orig_ramsize, size, address));
-                               bcmerror = BCME_BADARG;
+                               bcmerror = -EINVAL;
                                break;
                        }
 
@@ -2271,7 +2301,7 @@ dhdsdio_doiovar(dhd_bus_t *bus, const bcm_iovar_t *vi, u32 actionid,
 
        case IOV_SVAL(IOV_SDIOD_DRIVE):
                dhd_sdiod_drive_strength = int_val;
-               si_sdiod_drive_strength_init(bus->sih,
+               dhdsdio_sdiod_drive_strength_init(bus,
                                             dhd_sdiod_drive_strength);
                break;
 
@@ -2301,7 +2331,7 @@ dhdsdio_doiovar(dhd_bus_t *bus, const bcm_iovar_t *vi, u32 actionid,
 
        case IOV_SVAL(IOV_SDRXCHAIN):
                if (bool_val && !bus->sd_rxchain)
-                       bcmerror = BCME_UNSUPPORTED;
+                       bcmerror = -ENOTSUPP;
                else
                        bus->use_rxchain = bool_val;
                break;
@@ -2324,7 +2354,7 @@ dhdsdio_doiovar(dhd_bus_t *bus, const bcm_iovar_t *vi, u32 actionid,
                if (bus->varsz < (uint) len)
                        memcpy(arg, bus->vars, bus->varsz);
                else
-                       bcmerror = BCME_BUFTOOSHORT;
+                       bcmerror = -EOVERFLOW;
                break;
 #endif                         /* DHD_DEBUG */
 
@@ -2340,7 +2370,7 @@ dhdsdio_doiovar(dhd_bus_t *bus, const bcm_iovar_t *vi, u32 actionid,
                        size = sd_ptr->func;
                        int_val = (s32) bcmsdh_reg_read(bus->sdh, addr, size);
                        if (bcmsdh_regfail(bus->sdh))
-                               bcmerror = BCME_SDIO_ERROR;
+                               bcmerror = -EIO;
                        memcpy(arg, &int_val, sizeof(s32));
                        break;
                }
@@ -2356,7 +2386,7 @@ dhdsdio_doiovar(dhd_bus_t *bus, const bcm_iovar_t *vi, u32 actionid,
                        size = sd_ptr->func;
                        bcmsdh_reg_write(bus->sdh, addr, size, sd_ptr->value);
                        if (bcmsdh_regfail(bus->sdh))
-                               bcmerror = BCME_SDIO_ERROR;
+                               bcmerror = -EIO;
                        break;
                }
 
@@ -2373,7 +2403,7 @@ dhdsdio_doiovar(dhd_bus_t *bus, const bcm_iovar_t *vi, u32 actionid,
                        size = sdreg.func;
                        int_val = (s32) bcmsdh_reg_read(bus->sdh, addr, size);
                        if (bcmsdh_regfail(bus->sdh))
-                               bcmerror = BCME_SDIO_ERROR;
+                               bcmerror = -EIO;
                        memcpy(arg, &int_val, sizeof(s32));
                        break;
                }
@@ -2389,7 +2419,7 @@ dhdsdio_doiovar(dhd_bus_t *bus, const bcm_iovar_t *vi, u32 actionid,
                        size = sdreg.func;
                        bcmsdh_reg_write(bus->sdh, addr, size, sdreg.value);
                        if (bcmsdh_regfail(bus->sdh))
-                               bcmerror = BCME_SDIO_ERROR;
+                               bcmerror = -EIO;
                        break;
                }
 
@@ -2488,7 +2518,7 @@ dhdsdio_doiovar(dhd_bus_t *bus, const bcm_iovar_t *vi, u32 actionid,
                break;
 
        default:
-               bcmerror = BCME_UNSUPPORTED;
+               bcmerror = -ENOTSUPP;
                break;
        }
 
@@ -2525,7 +2555,7 @@ static int dhdsdio_write_vars(dhd_bus_t *bus)
        if (bus->vars) {
                vbuffer = kzalloc(varsize, GFP_ATOMIC);
                if (!vbuffer)
-                       return BCME_NOMEM;
+                       return -ENOMEM;
 
                memcpy(vbuffer, bus->vars, bus->varsz);
 
@@ -2537,7 +2567,7 @@ static int dhdsdio_write_vars(dhd_bus_t *bus)
                DHD_INFO(("Compare NVRAM dl & ul; varsize=%d\n", varsize));
                nvram_ularray = kmalloc(varsize, GFP_ATOMIC);
                if (!nvram_ularray)
-                       return BCME_NOMEM;
+                       return -ENOMEM;
 
                /* Upload image to verify downloaded contents. */
                memset(nvram_ularray, 0xaa, varsize);
@@ -2596,42 +2626,18 @@ static int dhdsdio_write_vars(dhd_bus_t *bus)
 static int dhdsdio_download_state(dhd_bus_t *bus, bool enter)
 {
        uint retries;
+       u32 regdata;
        int bcmerror = 0;
 
        /* To enter download state, disable ARM and reset SOCRAM.
         * To exit download state, simply reset ARM (default is RAM boot).
         */
        if (enter) {
-
                bus->alp_only = true;
 
-               if (!(si_setcore(bus->sih, ARM7S_CORE_ID, 0)) &&
-                   !(si_setcore(bus->sih, ARMCM3_CORE_ID, 0))) {
-                       DHD_ERROR(("%s: Failed to find ARM core!\n", __func__));
-                       bcmerror = BCME_ERROR;
-                       goto fail;
-               }
+               dhdsdio_chip_disablecore(bus->sdh, bus->ci->armcorebase);
 
-               si_core_disable(bus->sih, 0);
-               if (bcmsdh_regfail(bus->sdh)) {
-                       bcmerror = BCME_SDIO_ERROR;
-                       goto fail;
-               }
-
-               if (!(si_setcore(bus->sih, SOCRAM_CORE_ID, 0))) {
-                       DHD_ERROR(("%s: Failed to find SOCRAM core!\n",
-                                  __func__));
-                       bcmerror = BCME_ERROR;
-                       goto fail;
-               }
-
-               si_core_reset(bus->sih, 0, 0);
-               if (bcmsdh_regfail(bus->sdh)) {
-                       DHD_ERROR(("%s: Failure trying reset SOCRAM core?\n",
-                                  __func__));
-                       bcmerror = BCME_SDIO_ERROR;
-                       goto fail;
-               }
+               dhdsdio_chip_resetcore(bus->sdh, bus->ci->ramcorebase);
 
                /* Clear the top bit of memory */
                if (bus->ramsize) {
@@ -2640,17 +2646,14 @@ static int dhdsdio_download_state(dhd_bus_t *bus, bool enter)
                                         (u8 *)&zeros, 4);
                }
        } else {
-               if (!(si_setcore(bus->sih, SOCRAM_CORE_ID, 0))) {
-                       DHD_ERROR(("%s: Failed to find SOCRAM core!\n",
-                                  __func__));
-                       bcmerror = BCME_ERROR;
-                       goto fail;
-               }
-
-               if (!si_iscoreup(bus->sih)) {
+               regdata = bcmsdh_reg_read(bus->sdh,
+                       CORE_SB(bus->ci->ramcorebase, sbtmstatelow), 4);
+               regdata &= (SBTML_RESET | SBTML_REJ_MASK |
+                       (SICF_CLOCK_EN << SBTML_SICF_SHIFT));
+               if ((SICF_CLOCK_EN << SBTML_SICF_SHIFT) != regdata) {
                        DHD_ERROR(("%s: SOCRAM core is down after reset?\n",
                                   __func__));
-                       bcmerror = BCME_ERROR;
+                       bcmerror = -EBADE;
                        goto fail;
                }
 
@@ -2660,41 +2663,16 @@ static int dhdsdio_download_state(dhd_bus_t *bus, bool enter)
                        bcmerror = 0;
                }
 
-               if (!si_setcore(bus->sih, PCMCIA_CORE_ID, 0) &&
-                   !si_setcore(bus->sih, SDIOD_CORE_ID, 0)) {
-                       DHD_ERROR(("%s: Can't change back to SDIO core?\n",
-                                  __func__));
-                       bcmerror = BCME_ERROR;
-                       goto fail;
-               }
                W_SDREG(0xFFFFFFFF, &bus->regs->intstatus, retries);
 
-               if (!(si_setcore(bus->sih, ARM7S_CORE_ID, 0)) &&
-                   !(si_setcore(bus->sih, ARMCM3_CORE_ID, 0))) {
-                       DHD_ERROR(("%s: Failed to find ARM core!\n", __func__));
-                       bcmerror = BCME_ERROR;
-                       goto fail;
-               }
-
-               si_core_reset(bus->sih, 0, 0);
-               if (bcmsdh_regfail(bus->sdh)) {
-                       DHD_ERROR(("%s: Failure trying to reset ARM core?\n",
-                                  __func__));
-                       bcmerror = BCME_SDIO_ERROR;
-                       goto fail;
-               }
+               dhdsdio_chip_resetcore(bus->sdh, bus->ci->armcorebase);
 
                /* Allow HT Clock now that the ARM is running. */
                bus->alp_only = false;
 
                bus->dhd->busstate = DHD_BUS_LOAD;
        }
-
 fail:
-       /* Always return to SDIOD core */
-       if (!si_setcore(bus->sih, PCMCIA_CORE_ID, 0))
-               si_setcore(bus->sih, SDIOD_CORE_ID, 0);
-
        return bcmerror;
 }
 
@@ -2739,7 +2717,7 @@ dhd_bus_iovar_op(dhd_pub_t *dhdp, const char *name,
                if (set && strcmp(name, "sd_divisor") == 0) {
                        if (bcmsdh_iovar_op(bus->sdh, "sd_divisor", NULL, 0,
                                            &bus->sd_divisor, sizeof(s32),
-                                           false) != BCME_OK) {
+                                           false) != 0) {
                                bus->sd_divisor = -1;
                                DHD_ERROR(("%s: fail on %s get\n", __func__,
                                           name));
@@ -2752,7 +2730,7 @@ dhd_bus_iovar_op(dhd_pub_t *dhdp, const char *name,
                if (set && strcmp(name, "sd_mode") == 0) {
                        if (bcmsdh_iovar_op(bus->sdh, "sd_mode", NULL, 0,
                                            &bus->sd_mode, sizeof(s32),
-                                           false) != BCME_OK) {
+                                           false) != 0) {
                                bus->sd_mode = -1;
                                DHD_ERROR(("%s: fail on %s get\n", __func__,
                                           name));
@@ -2767,7 +2745,7 @@ dhd_bus_iovar_op(dhd_pub_t *dhdp, const char *name,
                        if (bcmsdh_iovar_op
                            (bus->sdh, "sd_blocksize", &fnum, sizeof(s32),
                             &bus->blocksize, sizeof(s32),
-                            false) != BCME_OK) {
+                            false) != 0) {
                                bus->blocksize = 0;
                                DHD_ERROR(("%s: fail on %s get\n", __func__,
                                           "sd_blocksize"));
@@ -2867,14 +2845,14 @@ void dhd_bus_stop(struct dhd_bus *bus, bool enforce_mutex)
        dhdsdio_clkctl(bus, CLK_SDONLY, false);
 
        /* Clear the data packet queues */
-       pktq_flush(&bus->txq, true);
+       bcm_pktq_flush(&bus->txq, true, NULL, NULL);
 
        /* Clear any held glomming stuff */
        if (bus->glomd)
-               pkt_buf_free_skb(bus->glomd);
+               bcm_pkt_buf_free_skb(bus->glomd);
 
        if (bus->glom)
-               pkt_buf_free_skb(bus->glom);
+               bcm_pkt_buf_free_skb(bus->glom);
 
        bus->glom = bus->glomd = NULL;
 
@@ -2948,14 +2926,11 @@ int dhd_bus_init(dhd_pub_t *dhdp, bool enforce_mutex)
 
        /* If F2 successfully enabled, set core and enable interrupts */
        if (ready == enable) {
-               /* Make sure we're talking to the core. */
-               bus->regs = si_setcore(bus->sih, PCMCIA_CORE_ID, 0);
-               if (!(bus->regs))
-                       bus->regs = si_setcore(bus->sih, SDIOD_CORE_ID, 0);
-
                /* Set up the interrupt mask and enable interrupts */
                bus->hostintmask = HOSTINTMASK;
-               W_SDREG(bus->hostintmask, &bus->regs->hostintmask, retries);
+               W_SDREG(bus->hostintmask,
+                       (unsigned int *)CORE_BUS_REG(bus->ci->buscorebase,
+                       hostintmask), retries);
 
                bcmsdh_cfg_write(bus->sdh, SDIO_FUNC_1, SBSDIO_WATERMARK,
                                 (u8) watermark, &err);
@@ -3134,12 +3109,11 @@ dhdsdio_read_control(dhd_bus_t *bus, u8 *hdr, uint len, uint doff)
        }
 
        /* Read remainder of frame body into the rxctl buffer */
-       sdret =
-           dhd_bcmsdh_recv_buf(bus, bcmsdh_cur_sbwad(sdh), SDIO_FUNC_2, F2SYNC,
-                               (bus->rxctl + firstread), rdlen, NULL, NULL,
-                               NULL);
+       sdret = bcmsdh_recv_buf(bus, bcmsdh_cur_sbwad(sdh), SDIO_FUNC_2,
+                               F2SYNC, (bus->rxctl + firstread), rdlen,
+                               NULL, NULL, NULL);
        bus->f2rxdata++;
-       ASSERT(sdret != BCME_PENDING);
+       ASSERT(sdret != -BCME_PENDING);
 
        /* Control frame failures need retransmission */
        if (sdret < 0) {
@@ -3153,8 +3127,10 @@ dhdsdio_read_control(dhd_bus_t *bus, u8 *hdr, uint len, uint doff)
 gotpkt:
 
 #ifdef DHD_DEBUG
-       if (DHD_BYTES_ON() && DHD_CTL_ON())
-               prhex("RxCtrl", bus->rxctl, len);
+       if (DHD_BYTES_ON() && DHD_CTL_ON()) {
+               printk(KERN_DEBUG "RxCtrl:\n");
+               print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, bus->rxctl, len);
+       }
 #endif
 
        /* Point to valid data and indicate its length */
@@ -3228,10 +3204,11 @@ static u8 dhdsdio_rxglom(dhd_bus_t *bus, u8 rxseq)
                        }
 
                        /* Allocate/chain packet for next subframe */
-                       pnext = pkt_buf_get_skb(sublen + DHD_SDALIGN);
+                       pnext = bcm_pkt_buf_get_skb(sublen + DHD_SDALIGN);
                        if (pnext == NULL) {
-                               DHD_ERROR(("%s: pkt_buf_get_skb failed, num %d len %d\n",
-                                          __func__, num, sublen));
+                               DHD_ERROR(("%s: bcm_pkt_buf_get_skb failed, "
+                                       "num %d len %d\n", __func__,
+                                       num, sublen));
                                break;
                        }
                        ASSERT(!(pnext->prev));
@@ -3264,13 +3241,13 @@ static u8 dhdsdio_rxglom(dhd_bus_t *bus, u8 rxseq)
                        pfirst = pnext = NULL;
                } else {
                        if (pfirst)
-                               pkt_buf_free_skb(pfirst);
+                               bcm_pkt_buf_free_skb(pfirst);
                        bus->glom = NULL;
                        num = 0;
                }
 
                /* Done with descriptor packet */
-               pkt_buf_free_skb(bus->glomd);
+               bcm_pkt_buf_free_skb(bus->glomd);
                bus->glomd = NULL;
                bus->nextlen = 0;
 
@@ -3291,27 +3268,23 @@ static u8 dhdsdio_rxglom(dhd_bus_t *bus, u8 rxseq)
                }
 
                pfirst = bus->glom;
-               dlen = (u16) pkttotlen(pfirst);
+               dlen = (u16) bcm_pkttotlen(pfirst);
 
                /* Do an SDIO read for the superframe.  Configurable iovar to
                 * read directly into the chained packet, or allocate a large
                 * packet and and copy into the chain.
                 */
                if (usechain) {
-                       errcode = dhd_bcmsdh_recv_buf(bus,
-                                                     bcmsdh_cur_sbwad
-                                                     (bus->sdh), SDIO_FUNC_2,
-                                                     F2SYNC,
-                                                     (u8 *) pfirst->data,
-                                                     dlen, pfirst, NULL, NULL);
+                       errcode = bcmsdh_recv_buf(bus,
+                                       bcmsdh_cur_sbwad(bus->sdh), SDIO_FUNC_2,
+                                       F2SYNC, (u8 *) pfirst->data, dlen,
+                                       pfirst, NULL, NULL);
                } else if (bus->dataptr) {
-                       errcode = dhd_bcmsdh_recv_buf(bus,
-                                                     bcmsdh_cur_sbwad
-                                                     (bus->sdh), SDIO_FUNC_2,
-                                                     F2SYNC, bus->dataptr,
-                                                     dlen, NULL, NULL, NULL);
-                       sublen =
-                           (u16) pktfrombuf(pfirst, 0, dlen,
+                       errcode = bcmsdh_recv_buf(bus,
+                                       bcmsdh_cur_sbwad(bus->sdh), SDIO_FUNC_2,
+                                       F2SYNC, bus->dataptr, dlen,
+                                       NULL, NULL, NULL);
+                       sublen = (u16) bcm_pktfrombuf(pfirst, 0, dlen,
                                                bus->dataptr);
                        if (sublen != dlen) {
                                DHD_ERROR(("%s: FAILED TO COPY, dlen %d sublen %d\n",
@@ -3325,7 +3298,7 @@ static u8 dhdsdio_rxglom(dhd_bus_t *bus, u8 rxseq)
                        errcode = -1;
                }
                bus->f2rxdata++;
-               ASSERT(errcode != BCME_PENDING);
+               ASSERT(errcode != -BCME_PENDING);
 
                /* On failure, kill the superframe, allow a couple retries */
                if (errcode < 0) {
@@ -3339,7 +3312,7 @@ static u8 dhdsdio_rxglom(dhd_bus_t *bus, u8 rxseq)
                                bus->glomerr = 0;
                                dhdsdio_rxfail(bus, true, false);
                                dhd_os_sdlock_rxq(bus->dhd);
-                               pkt_buf_free_skb(bus->glom);
+                               bcm_pkt_buf_free_skb(bus->glom);
                                dhd_os_sdunlock_rxq(bus->dhd);
                                bus->rxglomfail++;
                                bus->glom = NULL;
@@ -3348,8 +3321,9 @@ static u8 dhdsdio_rxglom(dhd_bus_t *bus, u8 rxseq)
                }
 #ifdef DHD_DEBUG
                if (DHD_GLOM_ON()) {
-                       prhex("SUPERFRAME", pfirst->data,
-                             min_t(int, pfirst->len, 48));
+                       printk(KERN_DEBUG "SUPERFRAME:\n");
+                       print_hex_dump_bytes("", DUMP_PREFIX_OFFSET,
+                               pfirst->data, min_t(int, pfirst->len, 48));
                }
 #endif
 
@@ -3430,8 +3404,11 @@ static u8 dhdsdio_rxglom(dhd_bus_t *bus, u8 rxseq)
                        chan = SDPCM_PACKET_CHANNEL(&dptr[SDPCM_FRAMETAG_LEN]);
                        doff = SDPCM_DOFFSET_VALUE(&dptr[SDPCM_FRAMETAG_LEN]);
 #ifdef DHD_DEBUG
-                       if (DHD_GLOM_ON())
-                               prhex("subframe", dptr, 32);
+                       if (DHD_GLOM_ON()) {
+                               printk(KERN_DEBUG "subframe:\n");
+                               print_hex_dump_bytes("", DUMP_PREFIX_OFFSET,
+                                                    dptr, 32);
+                       }
 #endif
 
                        if ((u16)~(sublen ^ check)) {
@@ -3468,7 +3445,7 @@ static u8 dhdsdio_rxglom(dhd_bus_t *bus, u8 rxseq)
                                bus->glomerr = 0;
                                dhdsdio_rxfail(bus, true, false);
                                dhd_os_sdlock_rxq(bus->dhd);
-                               pkt_buf_free_skb(bus->glom);
+                               bcm_pkt_buf_free_skb(bus->glom);
                                dhd_os_sdunlock_rxq(bus->dhd);
                                bus->rxglomfail++;
                                bus->glom = NULL;
@@ -3508,15 +3485,18 @@ static u8 dhdsdio_rxglom(dhd_bus_t *bus, u8 rxseq)
                                rxseq = seq;
                        }
 #ifdef DHD_DEBUG
-                       if (DHD_BYTES_ON() && DHD_DATA_ON())
-                               prhex("Rx Subframe Data", dptr, dlen);
+                       if (DHD_BYTES_ON() && DHD_DATA_ON()) {
+                               printk(KERN_DEBUG "Rx Subframe Data:\n");
+                               print_hex_dump_bytes("", DUMP_PREFIX_OFFSET,
+                                                    dptr, dlen);
+                       }
 #endif
 
                        __skb_trim(pfirst, sublen);
                        skb_pull(pfirst, doff);
 
                        if (pfirst->len == 0) {
-                               pkt_buf_free_skb(pfirst);
+                               bcm_pkt_buf_free_skb(pfirst);
                                if (plast) {
                                        plast->next = pnext;
                                } else {
@@ -3529,7 +3509,7 @@ static u8 dhdsdio_rxglom(dhd_bus_t *bus, u8 rxseq)
                                DHD_ERROR(("%s: rx protocol error\n",
                                           __func__));
                                bus->dhd->rx_errors++;
-                               pkt_buf_free_skb(pfirst);
+                               bcm_pkt_buf_free_skb(pfirst);
                                if (plast) {
                                        plast->next = pnext;
                                } else {
@@ -3552,8 +3532,9 @@ static u8 dhdsdio_rxglom(dhd_bus_t *bus, u8 rxseq)
                                __func__, num, pfirst, pfirst->data,
                                pfirst->len, pfirst->next,
                                pfirst->prev));
-                               prhex("", (u8 *) pfirst->data,
-                                     min_t(int, pfirst->len, 32));
+                               print_hex_dump_bytes("", DUMP_PREFIX_OFFSET,
+                                               pfirst->data,
+                                               min_t(int, pfirst->len, 32));
                        }
 #endif                         /* DHD_DEBUG */
                }
@@ -3578,7 +3559,6 @@ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished)
        u16 len, check; /* Extracted hardware header fields */
        u8 chan, seq, doff;     /* Extracted software header fields */
        u8 fcbits;              /* Extracted fcbits from software header */
-       u8 delta;
 
        struct sk_buff *pkt;            /* Packet for event or data frames */
        u16 pad;                /* Number of pad bytes to read */
@@ -3667,7 +3647,7 @@ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished)
                         */
                        /* Allocate a packet buffer */
                        dhd_os_sdlock_rxq(bus->dhd);
-                       pkt = pkt_buf_get_skb(rdlen + DHD_SDALIGN);
+                       pkt = bcm_pkt_buf_get_skb(rdlen + DHD_SDALIGN);
                        if (!pkt) {
                                if (bus->bus == SPI_BUS) {
                                        bus->usebufpool = false;
@@ -3684,16 +3664,13 @@ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished)
                                        ASSERT(bus->rxctl >= bus->rxbuf);
                                        rxbuf = bus->rxctl;
                                        /* Read the entire frame */
-                                       sdret = dhd_bcmsdh_recv_buf(bus,
-                                                   bcmsdh_cur_sbwad
-                                                   (sdh),
-                                                   SDIO_FUNC_2,
-                                                   F2SYNC,
-                                                   rxbuf,
-                                                   rdlen, NULL,
-                                                   NULL, NULL);
+                                       sdret = bcmsdh_recv_buf(bus,
+                                                   bcmsdh_cur_sbwad(sdh),
+                                                   SDIO_FUNC_2, F2SYNC,
+                                                   rxbuf, rdlen,
+                                                   NULL, NULL, NULL);
                                        bus->f2rxdata++;
-                                       ASSERT(sdret != BCME_PENDING);
+                                       ASSERT(sdret != -BCME_PENDING);
 
                                        /* Control frame failures need
                                         retransmission */
@@ -3713,8 +3690,11 @@ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished)
                                } else {
                                        /* Give up on data,
                                        request rtx of events */
-                                       DHD_ERROR(("%s (nextlen): pkt_buf_get_skb failed: len %d rdlen %d " "expected rxseq %d\n",
-                                               __func__, len, rdlen, rxseq));
+                                       DHD_ERROR(("%s (nextlen): "
+                                                  "bcm_pkt_buf_get_skb failed:"
+                                                  " len %d rdlen %d expected"
+                                                  " rxseq %d\n", __func__,
+                                                  len, rdlen, rxseq));
                                        /* Just go try again w/normal
                                        header read */
                                        dhd_os_sdunlock_rxq(bus->dhd);
@@ -3728,19 +3708,18 @@ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished)
                                PKTALIGN(pkt, rdlen, DHD_SDALIGN);
                                rxbuf = (u8 *) (pkt->data);
                                /* Read the entire frame */
-                               sdret =
-                                   dhd_bcmsdh_recv_buf(bus,
+                               sdret = bcmsdh_recv_buf(bus,
                                                bcmsdh_cur_sbwad(sdh),
                                                SDIO_FUNC_2, F2SYNC,
-                                               rxbuf, rdlen, pkt, NULL,
-                                               NULL);
+                                               rxbuf, rdlen,
+                                               pkt, NULL, NULL);
                                bus->f2rxdata++;
-                               ASSERT(sdret != BCME_PENDING);
+                               ASSERT(sdret != -BCME_PENDING);
 
                                if (sdret < 0) {
                                        DHD_ERROR(("%s (nextlen): read %d bytes failed: %d\n",
                                                __func__, rdlen, sdret));
-                                       pkt_buf_free_skb(pkt);
+                                       bcm_pkt_buf_free_skb(pkt);
                                        bus->dhd->rx_errors++;
                                        dhd_os_sdunlock_rxq(bus->dhd);
                                        /* Force retry w/normal header read.
@@ -3767,23 +3746,19 @@ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished)
                        if (!(len | check)) {
                                DHD_INFO(("%s (nextlen): read zeros in HW "
                                        "header???\n", __func__));
-                               dhd_os_sdlock_rxq(bus->dhd);
-                               PKTFREE2();
-                               dhd_os_sdunlock_rxq(bus->dhd);
-                               GSPI_PR55150_BAILOUT;
+                               dhdsdio_pktfree2(bus, pkt);
                                continue;
                        }
 
                        /* Validate check bytes */
                        if ((u16)~(len ^ check)) {
-                               DHD_ERROR(("%s (nextlen): HW hdr error: nextlen/len/check" " 0x%04x/0x%04x/0x%04x\n",
+                               DHD_ERROR(("%s (nextlen): HW hdr error:"
+                                       " nextlen/len/check"
+                                       " 0x%04x/0x%04x/0x%04x\n",
                                        __func__, nextlen, len, check));
-                               dhd_os_sdlock_rxq(bus->dhd);
-                               PKTFREE2();
-                               dhd_os_sdunlock_rxq(bus->dhd);
                                bus->rx_badhdr++;
                                dhdsdio_rxfail(bus, false, false);
-                               GSPI_PR55150_BAILOUT;
+                               dhdsdio_pktfree2(bus, pkt);
                                continue;
                        }
 
@@ -3791,10 +3766,7 @@ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished)
                        if (len < SDPCM_HDRLEN) {
                                DHD_ERROR(("%s (nextlen): HW hdr length "
                                        "invalid: %d\n", __func__, len));
-                               dhd_os_sdlock_rxq(bus->dhd);
-                               PKTFREE2();
-                               dhd_os_sdunlock_rxq(bus->dhd);
-                               GSPI_PR55150_BAILOUT;
+                               dhdsdio_pktfree2(bus, pkt);
                                continue;
                        }
 
@@ -3803,31 +3775,25 @@ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished)
                        if (len_consistent) {
                                /* Mismatch, force retry w/normal
                                        header (may be >4K) */
-                               DHD_ERROR(("%s (nextlen): mismatch, nextlen %d len %d rnd %d; " "expected rxseq %d\n",
+                               DHD_ERROR(("%s (nextlen): mismatch, "
+                                       "nextlen %d len %d rnd %d; "
+                                       "expected rxseq %d\n",
                                        __func__, nextlen,
                                        len, roundup(len, 16), rxseq));
-                               dhd_os_sdlock_rxq(bus->dhd);
-                               PKTFREE2();
-                               dhd_os_sdunlock_rxq(bus->dhd);
-                               dhdsdio_rxfail(bus, true,
-                                              (bus->bus ==
-                                               SPI_BUS) ? false : true);
-                               GSPI_PR55150_BAILOUT;
+                               dhdsdio_rxfail(bus, true, (bus->bus != SPI_BUS));
+                               dhdsdio_pktfree2(bus, pkt);
                                continue;
                        }
 
                        /* Extract software header fields */
-                       chan =
-                           SDPCM_PACKET_CHANNEL(&bus->rxhdr
-                                                [SDPCM_FRAMETAG_LEN]);
-                       seq =
-                           SDPCM_PACKET_SEQUENCE(&bus->rxhdr
-                                                 [SDPCM_FRAMETAG_LEN]);
-                       doff =
-                           SDPCM_DOFFSET_VALUE(&bus->rxhdr
-                                               [SDPCM_FRAMETAG_LEN]);
-                       txmax =
-                           SDPCM_WINDOW_VALUE(&bus->rxhdr[SDPCM_FRAMETAG_LEN]);
+                       chan = SDPCM_PACKET_CHANNEL(
+                                       &bus->rxhdr[SDPCM_FRAMETAG_LEN]);
+                       seq = SDPCM_PACKET_SEQUENCE(
+                                       &bus->rxhdr[SDPCM_FRAMETAG_LEN]);
+                       doff = SDPCM_DOFFSET_VALUE(
+                                       &bus->rxhdr[SDPCM_FRAMETAG_LEN]);
+                       txmax = SDPCM_WINDOW_VALUE(
+                                       &bus->rxhdr[SDPCM_FRAMETAG_LEN]);
 
                        bus->nextlen =
                            bus->rxhdr[SDPCM_FRAMETAG_LEN +
@@ -3839,21 +3805,18 @@ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished)
                        }
 
                        bus->dhd->rx_readahead_cnt++;
+
                        /* Handle Flow Control */
-                       fcbits =
-                           SDPCM_FCMASK_VALUE(&bus->rxhdr[SDPCM_FRAMETAG_LEN]);
+                       fcbits = SDPCM_FCMASK_VALUE(
+                                       &bus->rxhdr[SDPCM_FRAMETAG_LEN]);
 
-                       delta = 0;
-                       if (~bus->flowcontrol & fcbits) {
-                               bus->fc_xoff++;
-                               delta = 1;
-                       }
-                       if (bus->flowcontrol & ~fcbits) {
-                               bus->fc_xon++;
-                               delta = 1;
-                       }
+                       if (bus->flowcontrol != fcbits) {
+                               if (~bus->flowcontrol & fcbits)
+                                       bus->fc_xoff++;
+
+                               if (bus->flowcontrol & ~fcbits)
+                                       bus->fc_xon++;
 
-                       if (delta) {
                                bus->fc_rcvd++;
                                bus->flowcontrol = fcbits;
                        }
@@ -3876,33 +3839,30 @@ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished)
                        bus->tx_max = txmax;
 
 #ifdef DHD_DEBUG
-                       if (DHD_BYTES_ON() && DHD_DATA_ON())
-                               prhex("Rx Data", rxbuf, len);
-                       else if (DHD_HDRS_ON())
-                               prhex("RxHdr", bus->rxhdr, SDPCM_HDRLEN);
+                       if (DHD_BYTES_ON() && DHD_DATA_ON()) {
+                               printk(KERN_DEBUG "Rx Data:\n");
+                               print_hex_dump_bytes("", DUMP_PREFIX_OFFSET,
+                                                    rxbuf, len);
+                       } else if (DHD_HDRS_ON()) {
+                               printk(KERN_DEBUG "RxHdr:\n");
+                               print_hex_dump_bytes("", DUMP_PREFIX_OFFSET,
+                                                    bus->rxhdr, SDPCM_HDRLEN);
+                       }
 #endif
 
                        if (chan == SDPCM_CONTROL_CHANNEL) {
                                if (bus->bus == SPI_BUS) {
                                        dhdsdio_read_control(bus, rxbuf, len,
                                                             doff);
-                                       if (bus->usebufpool) {
-                                               dhd_os_sdlock_rxq(bus->dhd);
-                                               pkt_buf_free_skb(pkt);
-                                               dhd_os_sdunlock_rxq(bus->dhd);
-                                       }
-                                       continue;
                                } else {
                                        DHD_ERROR(("%s (nextlen): readahead on control" " packet %d?\n",
                                                __func__, seq));
                                        /* Force retry w/normal header read */
                                        bus->nextlen = 0;
                                        dhdsdio_rxfail(bus, false, true);
-                                       dhd_os_sdlock_rxq(bus->dhd);
-                                       PKTFREE2();
-                                       dhd_os_sdunlock_rxq(bus->dhd);
-                                       continue;
                                }
+                               dhdsdio_pktfree2(bus, pkt);
+                               continue;
                        }
 
                        if ((bus->bus == SPI_BUS) && !bus->usebufpool) {
@@ -3915,11 +3875,8 @@ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished)
                        if ((doff < SDPCM_HDRLEN) || (doff > len)) {
                                DHD_ERROR(("%s (nextlen): bad data offset %d: HW len %d min %d\n",
                                        __func__, doff, len, SDPCM_HDRLEN));
-                               dhd_os_sdlock_rxq(bus->dhd);
-                               PKTFREE2();
-                               dhd_os_sdunlock_rxq(bus->dhd);
-                               ASSERT(0);
                                dhdsdio_rxfail(bus, false, false);
+                               dhdsdio_pktfree2(bus, pkt);
                                continue;
                        }
 
@@ -3931,12 +3888,11 @@ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished)
                        break;
 
                /* Read frame header (hardware and software) */
-               sdret =
-                   dhd_bcmsdh_recv_buf(bus, bcmsdh_cur_sbwad(sdh), SDIO_FUNC_2,
-                                       F2SYNC, bus->rxhdr, firstread, NULL,
-                                       NULL, NULL);
+               sdret = bcmsdh_recv_buf(bus, bcmsdh_cur_sbwad(sdh),
+                               SDIO_FUNC_2, F2SYNC, bus->rxhdr, firstread,
+                               NULL, NULL, NULL);
                bus->f2rxhdrs++;
-               ASSERT(sdret != BCME_PENDING);
+               ASSERT(sdret != -BCME_PENDING);
 
                if (sdret < 0) {
                        DHD_ERROR(("%s: RXHEADER FAILED: %d\n", __func__,
@@ -3946,8 +3902,11 @@ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished)
                        continue;
                }
 #ifdef DHD_DEBUG
-               if (DHD_BYTES_ON() || DHD_HDRS_ON())
-                       prhex("RxHdr", bus->rxhdr, SDPCM_HDRLEN);
+               if (DHD_BYTES_ON() || DHD_HDRS_ON()) {
+                       printk(KERN_DEBUG "RxHdr:\n");
+                       print_hex_dump_bytes("", DUMP_PREFIX_OFFSET,
+                                            bus->rxhdr, SDPCM_HDRLEN);
+               }
 #endif
 
                /* Extract hardware header fields */
@@ -4006,17 +3965,13 @@ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished)
                /* Handle Flow Control */
                fcbits = SDPCM_FCMASK_VALUE(&bus->rxhdr[SDPCM_FRAMETAG_LEN]);
 
-               delta = 0;
-               if (~bus->flowcontrol & fcbits) {
-                       bus->fc_xoff++;
-                       delta = 1;
-               }
-               if (bus->flowcontrol & ~fcbits) {
-                       bus->fc_xon++;
-                       delta = 1;
-               }
+               if (bus->flowcontrol != fcbits) {
+                       if (~bus->flowcontrol & fcbits)
+                               bus->fc_xoff++;
+
+                       if (bus->flowcontrol & ~fcbits)
+                               bus->fc_xon++;
 
-               if (delta) {
                        bus->fc_rcvd++;
                        bus->flowcontrol = fcbits;
                }
@@ -4077,11 +4032,11 @@ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished)
                }
 
                dhd_os_sdlock_rxq(bus->dhd);
-               pkt = pkt_buf_get_skb(rdlen + firstread + DHD_SDALIGN);
+               pkt = bcm_pkt_buf_get_skb(rdlen + firstread + DHD_SDALIGN);
                if (!pkt) {
                        /* Give up on data, request rtx of events */
-                       DHD_ERROR(("%s: pkt_buf_get_skb failed: rdlen %d chan %d\n",
-                                  __func__, rdlen, chan));
+                       DHD_ERROR(("%s: bcm_pkt_buf_get_skb failed: rdlen %d "
+                               "chan %d\n", __func__, rdlen, chan));
                        bus->dhd->rx_dropped++;
                        dhd_os_sdunlock_rxq(bus->dhd);
                        dhdsdio_rxfail(bus, false, RETRYCHAN(chan));
@@ -4097,12 +4052,11 @@ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished)
                PKTALIGN(pkt, rdlen, DHD_SDALIGN);
 
                /* Read the remaining frame data */
-               sdret =
-                   dhd_bcmsdh_recv_buf(bus, bcmsdh_cur_sbwad(sdh), SDIO_FUNC_2,
+               sdret = bcmsdh_recv_buf(bus, bcmsdh_cur_sbwad(sdh), SDIO_FUNC_2,
                                        F2SYNC, ((u8 *) (pkt->data)), rdlen,
                                        pkt, NULL, NULL);
                bus->f2rxdata++;
-               ASSERT(sdret != BCME_PENDING);
+               ASSERT(sdret != -BCME_PENDING);
 
                if (sdret < 0) {
                        DHD_ERROR(("%s: read %d %s bytes failed: %d\n",
@@ -4113,7 +4067,7 @@ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished)
                                       ? "data" : "test")),
                                   sdret));
                        dhd_os_sdlock_rxq(bus->dhd);
-                       pkt_buf_free_skb(pkt);
+                       bcm_pkt_buf_free_skb(pkt);
                        dhd_os_sdunlock_rxq(bus->dhd);
                        bus->dhd->rx_errors++;
                        dhdsdio_rxfail(bus, true, RETRYCHAN(chan));
@@ -4125,8 +4079,11 @@ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished)
                memcpy(pkt->data, bus->rxhdr, firstread);
 
 #ifdef DHD_DEBUG
-               if (DHD_BYTES_ON() && DHD_DATA_ON())
-                       prhex("Rx Data", pkt->data, len);
+               if (DHD_BYTES_ON() && DHD_DATA_ON()) {
+                       printk(KERN_DEBUG "Rx Data:\n");
+                       print_hex_dump_bytes("", DUMP_PREFIX_OFFSET,
+                                            pkt->data, len);
+               }
 #endif
 
 deliver:
@@ -4137,7 +4094,10 @@ deliver:
                                        __func__, len));
 #ifdef DHD_DEBUG
                                if (DHD_GLOM_ON()) {
-                                       prhex("Glom Data", pkt->data, len);
+                                       printk(KERN_DEBUG "Glom Data:\n");
+                                       print_hex_dump_bytes("",
+                                                            DUMP_PREFIX_OFFSET,
+                                                            pkt->data, len);
                                }
 #endif
                                __skb_trim(pkt, len);
@@ -4166,13 +4126,13 @@ deliver:
 
                if (pkt->len == 0) {
                        dhd_os_sdlock_rxq(bus->dhd);
-                       pkt_buf_free_skb(pkt);
+                       bcm_pkt_buf_free_skb(pkt);
                        dhd_os_sdunlock_rxq(bus->dhd);
                        continue;
                } else if (dhd_prot_hdrpull(bus->dhd, &ifidx, pkt) != 0) {
                        DHD_ERROR(("%s: rx protocol error\n", __func__));
                        dhd_os_sdlock_rxq(bus->dhd);
-                       pkt_buf_free_skb(pkt);
+                       bcm_pkt_buf_free_skb(pkt);
                        dhd_os_sdunlock_rxq(bus->dhd);
                        bus->dhd->rx_errors++;
                        continue;
@@ -4245,16 +4205,16 @@ static u32 dhdsdio_hostmail(dhd_bus_t *bus)
 
        /*
         * Flow Control has been moved into the RX headers and this out of band
-        * method isn't used any more.  Leae this here for possibly
-        * remaining backward
-        * compatible with older dongles
+        * method isn't used any more.
+        * remaining backward compatible with older dongles.
         */
        if (hmb_data & HMB_DATA_FC) {
-               fcbits =
-                   (hmb_data & HMB_DATA_FCDATA_MASK) >> HMB_DATA_FCDATA_SHIFT;
+               fcbits = (hmb_data & HMB_DATA_FCDATA_MASK) >>
+                                                       HMB_DATA_FCDATA_SHIFT;
 
                if (fcbits & ~bus->flowcontrol)
                        bus->fc_xoff++;
+
                if (bus->flowcontrol & ~fcbits)
                        bus->fc_xon++;
 
@@ -4454,7 +4414,7 @@ clkwait:
                                        F2SYNC, (u8 *) bus->ctrl_frame_buf,
                                        (u32) bus->ctrl_frame_len, NULL,
                                        NULL, NULL);
-               ASSERT(ret != BCME_PENDING);
+               ASSERT(ret != -BCME_PENDING);
 
                if (ret < 0) {
                        /* On failure, abort the command and
@@ -4493,7 +4453,7 @@ clkwait:
        }
        /* Send queued frames (limit 1 if rx may still be pending) */
        else if ((bus->clkstate == CLK_AVAIL) && !bus->fcstate &&
-                pktq_mlen(&bus->txq, ~bus->flowcontrol) && txlimit
+                bcm_pktq_mlen(&bus->txq, ~bus->flowcontrol) && txlimit
                 && DATAOK(bus)) {
                framecnt = rxdone ? txlimit : min(txlimit, dhd_txminmax);
                framecnt = dhdsdio_sendfromq(bus, framecnt);
@@ -4514,7 +4474,7 @@ clkwait:
                        "I_CHIPACTIVE interrupt\n", __func__));
                resched = true;
        } else if (bus->intstatus || bus->ipend ||
-               (!bus->fcstate && pktq_mlen(&bus->txq, ~bus->flowcontrol) &&
+               (!bus->fcstate && bcm_pktq_mlen(&bus->txq, ~bus->flowcontrol) &&
                        DATAOK(bus)) || PKT_AVAILABLE()) {
                resched = true;
        }
@@ -4648,11 +4608,12 @@ static void dhdsdio_pktgen(dhd_bus_t *bus)
 
                /* Allocate an appropriate-sized packet */
                len = bus->pktgen_len;
-               pkt = pkt_buf_get_skb(
+               pkt = bcm_pkt_buf_get_skb(
                        (len + SDPCM_HDRLEN + SDPCM_TEST_HDRLEN + DHD_SDALIGN),
                        true);
                if (!pkt) {
-                       DHD_ERROR(("%s: pkt_buf_get_skb failed!\n", __func__));
+                       DHD_ERROR(("%s: bcm_pkt_buf_get_skb failed!\n",
+                               __func__));
                        break;
                }
                PKTALIGN(pkt, (len + SDPCM_HDRLEN + SDPCM_TEST_HDRLEN),
@@ -4679,7 +4640,7 @@ static void dhdsdio_pktgen(dhd_bus_t *bus)
                default:
                        DHD_ERROR(("Unrecognized pktgen mode %d\n",
                                   bus->pktgen_mode));
-                       pkt_buf_free_skb(pkt, true);
+                       bcm_pkt_buf_free_skb(pkt, true);
                        bus->pktgen_count = 0;
                        return;
                }
@@ -4697,8 +4658,9 @@ static void dhdsdio_pktgen(dhd_bus_t *bus)
 #ifdef DHD_DEBUG
                if (DHD_BYTES_ON() && DHD_DATA_ON()) {
                        data = (u8 *) (pkt->data) + SDPCM_HDRLEN;
-                       prhex("dhdsdio_pktgen: Tx Data", data,
-                             pkt->len - SDPCM_HDRLEN);
+                       printk(KERN_DEBUG "dhdsdio_pktgen: Tx Data:\n");
+                       print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, data,
+                                            pkt->len - SDPCM_HDRLEN);
                }
 #endif
 
@@ -4727,10 +4689,10 @@ static void dhdsdio_sdtest_set(dhd_bus_t *bus, bool start)
        u8 *data;
 
        /* Allocate the packet */
-       pkt = pkt_buf_get_skb(SDPCM_HDRLEN + SDPCM_TEST_HDRLEN + DHD_SDALIGN,
-                       true);
+       pkt = bcm_pkt_buf_get_skb(SDPCM_HDRLEN + SDPCM_TEST_HDRLEN +
+               DHD_SDALIGN, true);
        if (!pkt) {
-               DHD_ERROR(("%s: pkt_buf_get_skb failed!\n", __func__));
+               DHD_ERROR(("%s: bcm_pkt_buf_get_skb failed!\n", __func__));
                return;
        }
        PKTALIGN(pkt, (SDPCM_HDRLEN + SDPCM_TEST_HDRLEN), DHD_SDALIGN);
@@ -4762,7 +4724,7 @@ static void dhdsdio_testrcv(dhd_bus_t *bus, struct sk_buff *pkt, uint seq)
        if (pktlen < SDPCM_TEST_HDRLEN) {
                DHD_ERROR(("dhdsdio_restrcv: toss runt frame, pktlen %d\n",
                           pktlen));
-               pkt_buf_free_skb(pkt, false);
+               bcm_pkt_buf_free_skb(pkt, false);
                return;
        }
 
@@ -4780,7 +4742,7 @@ static void dhdsdio_testrcv(dhd_bus_t *bus, struct sk_buff *pkt, uint seq)
                        DHD_ERROR(("dhdsdio_testrcv: frame length mismatch, "
                                "pktlen %d seq %d" " cmd %d extra %d len %d\n",
                                pktlen, seq, cmd, extra, len));
-                       pkt_buf_free_skb(pkt, false);
+                       bcm_pkt_buf_free_skb(pkt, false);
                        return;
                }
        }
@@ -4795,14 +4757,14 @@ static void dhdsdio_testrcv(dhd_bus_t *bus, struct sk_buff *pkt, uint seq)
                        bus->pktgen_sent++;
                } else {
                        bus->pktgen_fail++;
-                       pkt_buf_free_skb(pkt, false);
+                       bcm_pkt_buf_free_skb(pkt, false);
                }
                bus->pktgen_rcvd++;
                break;
 
        case SDPCM_TEST_ECHORSP:
                if (bus->ext_loop) {
-                       pkt_buf_free_skb(pkt, false);
+                       bcm_pkt_buf_free_skb(pkt, false);
                        bus->pktgen_rcvd++;
                        break;
                }
@@ -4815,12 +4777,12 @@ static void dhdsdio_testrcv(dhd_bus_t *bus, struct sk_buff *pkt, uint seq)
                                break;
                        }
                }
-               pkt_buf_free_skb(pkt, false);
+               bcm_pkt_buf_free_skb(pkt, false);
                bus->pktgen_rcvd++;
                break;
 
        case SDPCM_TEST_DISCARD:
-               pkt_buf_free_skb(pkt, false);
+               bcm_pkt_buf_free_skb(pkt, false);
                bus->pktgen_rcvd++;
                break;
 
@@ -4830,7 +4792,7 @@ static void dhdsdio_testrcv(dhd_bus_t *bus, struct sk_buff *pkt, uint seq)
                DHD_INFO(("dhdsdio_testrcv: unsupported or unknown command, "
                        "pktlen %d seq %d" " cmd %d extra %d len %d\n",
                        pktlen, seq, cmd, extra, len));
-               pkt_buf_free_skb(pkt, false);
+               bcm_pkt_buf_free_skb(pkt, false);
                break;
        }
 
@@ -4952,7 +4914,7 @@ extern int dhd_bus_console_in(dhd_pub_t *dhdp, unsigned char *msg, uint msglen)
 
        /* Address could be zero if CONSOLE := 0 in dongle Makefile */
        if (bus->console_addr == 0)
-               return BCME_UNSUPPORTED;
+               return -ENOTSUPP;
 
        /* Exclusive bus access */
        dhd_os_sdlock(bus->dhd);
@@ -4960,7 +4922,7 @@ extern int dhd_bus_console_in(dhd_pub_t *dhdp, unsigned char *msg, uint msglen)
        /* Don't allow input if dongle is in reset */
        if (bus->dhd->dongle_reset) {
                dhd_os_sdunlock(bus->dhd);
-               return BCME_NOTREADY;
+               return -EPERM;
        }
 
        /* Request clock to allow SDIO accesses */
@@ -4991,7 +4953,7 @@ extern int dhd_bus_console_in(dhd_pub_t *dhdp, unsigned char *msg, uint msglen)
        /* Bump dongle by sending an empty event pkt.
         * sdpcm_sendup (RX) checks for virtual console input.
         */
-       pkt = pkt_buf_get_skb(4 + SDPCM_RESERVE);
+       pkt = bcm_pkt_buf_get_skb(4 + SDPCM_RESERVE);
        if ((pkt != NULL) && bus->clkstate == CLK_AVAIL)
                dhdsdio_txpkt(bus, pkt, SDPCM_EVENT_CHANNEL, true);
 
@@ -5089,7 +5051,7 @@ static void *dhdsdio_probe(u16 venid, u16 devid, u16 bus_no,
        /* Check the Vendor ID */
        switch (venid) {
        case 0x0000:
-       case VENDOR_BROADCOM:
+       case PCI_VENDOR_ID_BROADCOM:
                break;
        default:
                DHD_ERROR(("%s: unknown vendor: 0x%04x\n", __func__, venid));
@@ -5179,7 +5141,7 @@ static void *dhdsdio_probe(u16 venid, u16 devid, u16 bus_no,
        /* if firmware path present try to download and bring up bus */
        ret = dhd_bus_start(bus->dhd);
        if (ret != 0) {
-               if (ret == BCME_NOTUP) {
+               if (ret == -ENOLINK) {
                        DHD_ERROR(("%s: dongle is not responding\n", __func__));
                        goto fail;
                }
@@ -5215,7 +5177,10 @@ dhdsdio_probe_attach(struct dhd_bus *bus, void *sdh, void *regsva, u16 devid)
 
 #endif                         /* DHD_DEBUG */
 
-       /* Force PLL off until si_attach() programs PLL control regs */
+       /*
+        * Force PLL off until dhdsdio_chip_attach()
+        * programs PLL control regs
+        */
 
        bcmsdh_cfg_write(sdh, SDIO_FUNC_1, SBSDIO_FUNC1_CHIPCLKCSR,
                         DHD_INIT_CLKCTL1, &err);
@@ -5281,34 +5246,26 @@ dhdsdio_probe_attach(struct dhd_bus *bus, void *sdh, void *regsva, u16 devid)
        }
 #endif                         /* DHD_DEBUG */
 
-       /* si_attach() will provide an SI handle and scan the backplane */
-       bus->sih = si_attach((uint) devid, regsva, DHD_BUS, sdh,
-                                  &bus->vars, &bus->varsz);
-       if (!(bus->sih)) {
-               DHD_ERROR(("%s: si_attach failed!\n", __func__));
+       if (dhdsdio_chip_attach(bus, regsva)) {
+               DHD_ERROR(("%s: dhdsdio_chip_attach failed!\n", __func__));
                goto fail;
        }
 
-       bcmsdh_chipinfo(sdh, bus->sih->chip, bus->sih->chiprev);
+       bcmsdh_chipinfo(sdh, bus->ci->chip, bus->ci->chiprev);
 
-       if (!dhdsdio_chipmatch((u16) bus->sih->chip)) {
+       if (!dhdsdio_chipmatch((u16) bus->ci->chip)) {
                DHD_ERROR(("%s: unsupported chip: 0x%04x\n",
-                          __func__, bus->sih->chip));
+                          __func__, bus->ci->chip));
                goto fail;
        }
 
-       si_sdiod_drive_strength_init(bus->sih, dhd_sdiod_drive_strength);
+       dhdsdio_sdiod_drive_strength_init(bus, dhd_sdiod_drive_strength);
 
        /* Get info on the ARM and SOCRAM cores... */
        if (!DHD_NOPMU(bus)) {
-               if ((si_setcore(bus->sih, ARM7S_CORE_ID, 0)) ||
-                   (si_setcore(bus->sih, ARMCM3_CORE_ID, 0))) {
-                       bus->armrev = si_corerev(bus->sih);
-               } else {
-                       DHD_ERROR(("%s: failed to find ARM core!\n", __func__));
-                       goto fail;
-               }
-               bus->orig_ramsize = si_socram_size(bus->sih);
+               bus->armrev = SBCOREREV(bcmsdh_reg_read(bus->sdh,
+                       CORE_SB(bus->ci->armcorebase, sbidhigh), 4));
+               bus->orig_ramsize = bus->ci->ramsize;
                if (!(bus->orig_ramsize)) {
                        DHD_ERROR(("%s: failed to find SOCRAM memory!\n",
                                   __func__));
@@ -5322,22 +5279,12 @@ dhdsdio_probe_attach(struct dhd_bus *bus, void *sdh, void *regsva, u16 devid)
                           bus->ramsize, bus->orig_ramsize));
        }
 
-       /* ...but normally deal with the SDPCMDEV core */
-       bus->regs = si_setcore(bus->sih, PCMCIA_CORE_ID, 0);
-       if (!bus->regs) {
-               bus->regs = si_setcore(bus->sih, SDIOD_CORE_ID, 0);
-               if (!bus->regs) {
-                       DHD_ERROR(("%s: failed to find SDIODEV core!\n",
-                                       __func__));
-                       goto fail;
-               }
-       }
-       bus->sdpcmrev = si_corerev(bus->sih);
+       bus->regs = (void *)bus->ci->buscorebase;
 
        /* Set core control so an SDIO reset does a backplane reset */
        OR_REG(&bus->regs->corecontrol, CC_BPRESEN);
 
-       pktq_init(&bus->txq, (PRIOMASK + 1), TXQLEN);
+       bcm_pktq_init(&bus->txq, (PRIOMASK + 1), TXQLEN);
 
        /* Locate an appropriately-aligned portion of hdrbuf */
        bus->rxhdr = (u8 *) roundup((unsigned long)&bus->hdrbuf[0], DHD_SDALIGN);
@@ -5425,7 +5372,7 @@ static bool dhdsdio_probe_init(dhd_bus_t *bus, void *sdh)
        /* Query the SD clock speed */
        if (bcmsdh_iovar_op(sdh, "sd_divisor", NULL, 0,
                            &bus->sd_divisor, sizeof(s32),
-                           false) != BCME_OK) {
+                           false) != 0) {
                DHD_ERROR(("%s: fail on %s get\n", __func__, "sd_divisor"));
                bus->sd_divisor = -1;
        } else {
@@ -5435,7 +5382,7 @@ static bool dhdsdio_probe_init(dhd_bus_t *bus, void *sdh)
 
        /* Query the SD bus mode */
        if (bcmsdh_iovar_op(sdh, "sd_mode", NULL, 0,
-                           &bus->sd_mode, sizeof(s32), false) != BCME_OK) {
+                           &bus->sd_mode, sizeof(s32), false) != 0) {
                DHD_ERROR(("%s: fail on %s get\n", __func__, "sd_mode"));
                bus->sd_mode = -1;
        } else {
@@ -5446,7 +5393,7 @@ static bool dhdsdio_probe_init(dhd_bus_t *bus, void *sdh)
        /* Query the F2 block size, set roundup accordingly */
        fnum = 2;
        if (bcmsdh_iovar_op(sdh, "sd_blocksize", &fnum, sizeof(s32),
-                           &bus->blocksize, sizeof(s32), false) != BCME_OK) {
+                           &bus->blocksize, sizeof(s32), false) != 0) {
                bus->blocksize = 0;
                DHD_ERROR(("%s: fail on %s get\n", __func__, "sd_blocksize"));
        } else {
@@ -5459,7 +5406,7 @@ static bool dhdsdio_probe_init(dhd_bus_t *bus, void *sdh)
                 default to use if supported */
        if (bcmsdh_iovar_op(sdh, "sd_rxchain", NULL, 0,
                            &bus->sd_rxchain, sizeof(s32),
-                           false) != BCME_OK) {
+                           false) != 0) {
                bus->sd_rxchain = false;
        } else {
                DHD_INFO(("%s: bus module (through bcmsdh API) %s chaining\n",
@@ -5509,10 +5456,8 @@ static void dhdsdio_release(dhd_bus_t *bus)
                bcmsdh_intr_dereg(bus->sdh);
 
                if (bus->dhd) {
-
-                       dhdsdio_release_dongle(bus);
-
                        dhd_detach(bus->dhd);
+                       dhdsdio_release_dongle(bus);
                        bus->dhd = NULL;
                }
 
@@ -5548,13 +5493,10 @@ static void dhdsdio_release_dongle(dhd_bus_t *bus)
        if (bus->dhd && bus->dhd->dongle_reset)
                return;
 
-       if (bus->sih) {
+       if (bus->ci) {
                dhdsdio_clkctl(bus, CLK_AVAIL, false);
-#if !defined(BCMLXSDMMC)
-               si_watchdog(bus->sih, 4);
-#endif                         /* !defined(BCMLXSDMMC) */
                dhdsdio_clkctl(bus, CLK_NONE, false);
-               si_detach(bus->sih);
+               dhdsdio_chip_detach(bus);
                if (bus->vars && bus->varsz)
                        kfree(bus->vars);
                bus->vars = NULL;
@@ -5642,7 +5584,7 @@ static int dhdsdio_download_code_array(struct dhd_bus *bus)
 
                ularray = kmalloc(bus->ramsize, GFP_ATOMIC);
                if (!ularray) {
-                       bcmerror = BCME_NOMEM;
+                       bcmerror = -ENOMEM;
                        goto err;
                }
                /* Upload image to verify downloaded contents. */
@@ -5865,7 +5807,7 @@ static int dhdsdio_download_nvram(struct dhd_bus *bus)
        } else {
                DHD_ERROR(("%s: error reading nvram file: %d\n",
                           __func__, len));
-               bcmerror = BCME_SDIO_ERROR;
+               bcmerror = -EIO;
        }
 
 err:
@@ -5954,19 +5896,6 @@ err:
        return bcmerror;
 }
 
-static int
-dhd_bcmsdh_recv_buf(dhd_bus_t *bus, u32 addr, uint fn, uint flags,
-                   u8 *buf, uint nbytes, struct sk_buff *pkt,
-                   bcmsdh_cmplt_fn_t complete, void *handle)
-{
-       int status;
-
-       /* 4329: GSPI check */
-       status =
-           bcmsdh_recv_buf(bus->sdh, addr, fn, flags, buf, nbytes, pkt,
-                           complete, handle);
-       return status;
-}
 
 static int
 dhd_bcmsdh_send_buf(dhd_bus_t *bus, u32 addr, uint fn, uint flags,
@@ -5980,8 +5909,8 @@ dhd_bcmsdh_send_buf(dhd_bus_t *bus, u32 addr, uint fn, uint flags,
 
 uint dhd_bus_chip(struct dhd_bus *bus)
 {
-       ASSERT(bus->sih != NULL);
-       return bus->sih->chip;
+       ASSERT(bus->ci != NULL);
+       return bus->ci->chip;
 }
 
 void *dhd_bus_pub(struct dhd_bus *bus)
@@ -6023,7 +5952,7 @@ int dhd_bus_devreset(dhd_pub_t *dhdp, u8 flag)
                        DHD_TRACE(("%s:  WLAN OFF DONE\n", __func__));
                        /* App can now remove power from device */
                } else
-                       bcmerror = BCME_SDIO_ERROR;
+                       bcmerror = -EIO;
        } else {
                /* App must have restored power to device before calling */
 
@@ -6058,15 +5987,404 @@ int dhd_bus_devreset(dhd_pub_t *dhdp, u8 flag)
                                        DHD_TRACE(("%s: WLAN ON DONE\n",
                                                   __func__));
                                } else
-                                       bcmerror = BCME_SDIO_ERROR;
+                                       bcmerror = -EIO;
                        } else
-                               bcmerror = BCME_SDIO_ERROR;
+                               bcmerror = -EIO;
                } else {
-                       bcmerror = BCME_NOTDOWN;
+                       bcmerror = -EISCONN;
                        DHD_ERROR(("%s: Set DEVRESET=false invoked when device "
                                "is on\n", __func__));
-                       bcmerror = BCME_SDIO_ERROR;
+                       bcmerror = -EIO;
                }
        }
        return bcmerror;
 }
+
+static int
+dhdsdio_chip_recognition(bcmsdh_info_t *sdh, struct chip_info *ci, void *regs)
+{
+       u32 regdata;
+
+       /*
+        * Get CC core rev
+        * Chipid is assume to be at offset 0 from regs arg
+        * For different chiptypes or old sdio hosts w/o chipcommon,
+        * other ways of recognition should be added here.
+        */
+       ci->cccorebase = (u32)regs;
+       regdata = bcmsdh_reg_read(sdh, CORE_CC_REG(ci->cccorebase, chipid), 4);
+       ci->chip = regdata & CID_ID_MASK;
+       ci->chiprev = (regdata & CID_REV_MASK) >> CID_REV_SHIFT;
+
+       DHD_INFO(("%s: chipid=0x%x chiprev=%d\n",
+               __func__, ci->chip, ci->chiprev));
+
+       /* Address of cores for new chips should be added here */
+       switch (ci->chip) {
+       case BCM4329_CHIP_ID:
+               ci->buscorebase = BCM4329_CORE_BUS_BASE;
+               ci->ramcorebase = BCM4329_CORE_SOCRAM_BASE;
+               ci->armcorebase = BCM4329_CORE_ARM_BASE;
+               ci->ramsize = BCM4329_RAMSIZE;
+               break;
+       default:
+               DHD_ERROR(("%s: chipid 0x%x is not supported\n",
+                       __func__, ci->chip));
+               return -ENODEV;
+       }
+
+       regdata = bcmsdh_reg_read(sdh,
+               CORE_SB(ci->cccorebase, sbidhigh), 4);
+       ci->ccrev = SBCOREREV(regdata);
+
+       regdata = bcmsdh_reg_read(sdh,
+               CORE_CC_REG(ci->cccorebase, pmucapabilities), 4);
+       ci->pmurev = regdata & PCAP_REV_MASK;
+
+       regdata = bcmsdh_reg_read(sdh, CORE_SB(ci->buscorebase, sbidhigh), 4);
+       ci->buscorerev = SBCOREREV(regdata);
+       ci->buscoretype = (regdata & SBIDH_CC_MASK) >> SBIDH_CC_SHIFT;
+
+       DHD_INFO(("%s: ccrev=%d, pmurev=%d, buscore rev/type=%d/0x%x\n",
+               __func__, ci->ccrev, ci->pmurev,
+               ci->buscorerev, ci->buscoretype));
+
+       /* get chipcommon capabilites */
+       ci->cccaps = bcmsdh_reg_read(sdh,
+               CORE_CC_REG(ci->cccorebase, capabilities), 4);
+
+       return 0;
+}
+
+static void
+dhdsdio_chip_disablecore(bcmsdh_info_t *sdh, u32 corebase)
+{
+       u32 regdata;
+
+       regdata = bcmsdh_reg_read(sdh,
+               CORE_SB(corebase, sbtmstatelow), 4);
+       if (regdata & SBTML_RESET)
+               return;
+
+       regdata = bcmsdh_reg_read(sdh,
+               CORE_SB(corebase, sbtmstatelow), 4);
+       if ((regdata & (SICF_CLOCK_EN << SBTML_SICF_SHIFT)) != 0) {
+               /*
+                * set target reject and spin until busy is clear
+                * (preserve core-specific bits)
+                */
+               regdata = bcmsdh_reg_read(sdh,
+                       CORE_SB(corebase, sbtmstatelow), 4);
+               bcmsdh_reg_write(sdh, CORE_SB(corebase, sbtmstatelow), 4,
+                       regdata | SBTML_REJ);
+
+               regdata = bcmsdh_reg_read(sdh,
+                       CORE_SB(corebase, sbtmstatelow), 4);
+               udelay(1);
+               SPINWAIT((bcmsdh_reg_read(sdh,
+                       CORE_SB(corebase, sbtmstatehigh), 4) &
+                       SBTMH_BUSY), 100000);
+
+               regdata = bcmsdh_reg_read(sdh,
+                       CORE_SB(corebase, sbtmstatehigh), 4);
+               if (regdata & SBTMH_BUSY)
+                       DHD_ERROR(("%s: ARM core still busy\n", __func__));
+
+               regdata = bcmsdh_reg_read(sdh,
+                       CORE_SB(corebase, sbidlow), 4);
+               if (regdata & SBIDL_INIT) {
+                       regdata = bcmsdh_reg_read(sdh,
+                               CORE_SB(corebase, sbimstate), 4) |
+                               SBIM_RJ;
+                       bcmsdh_reg_write(sdh,
+                               CORE_SB(corebase, sbimstate), 4,
+                               regdata);
+                       regdata = bcmsdh_reg_read(sdh,
+                               CORE_SB(corebase, sbimstate), 4);
+                       udelay(1);
+                       SPINWAIT((bcmsdh_reg_read(sdh,
+                               CORE_SB(corebase, sbimstate), 4) &
+                               SBIM_BY), 100000);
+               }
+
+               /* set reset and reject while enabling the clocks */
+               bcmsdh_reg_write(sdh,
+                       CORE_SB(corebase, sbtmstatelow), 4,
+                       (((SICF_FGC | SICF_CLOCK_EN) << SBTML_SICF_SHIFT) |
+                       SBTML_REJ | SBTML_RESET));
+               regdata = bcmsdh_reg_read(sdh,
+                       CORE_SB(corebase, sbtmstatelow), 4);
+               udelay(10);
+
+               /* clear the initiator reject bit */
+               regdata = bcmsdh_reg_read(sdh,
+                       CORE_SB(corebase, sbidlow), 4);
+               if (regdata & SBIDL_INIT) {
+                       regdata = bcmsdh_reg_read(sdh,
+                               CORE_SB(corebase, sbimstate), 4) &
+                               ~SBIM_RJ;
+                       bcmsdh_reg_write(sdh,
+                               CORE_SB(corebase, sbimstate), 4,
+                               regdata);
+               }
+       }
+
+       /* leave reset and reject asserted */
+       bcmsdh_reg_write(sdh, CORE_SB(corebase, sbtmstatelow), 4,
+               (SBTML_REJ | SBTML_RESET));
+       udelay(1);
+}
+
+static int
+dhdsdio_chip_attach(struct dhd_bus *bus, void *regs)
+{
+       struct chip_info *ci;
+       int err;
+       u8 clkval, clkset;
+
+       DHD_TRACE(("%s: Enter\n", __func__));
+
+       /* alloc chip_info_t */
+       ci = kmalloc(sizeof(struct chip_info), GFP_ATOMIC);
+       if (NULL == ci) {
+               DHD_ERROR(("%s: malloc failed!\n", __func__));
+               return -ENOMEM;
+       }
+
+       memset((unsigned char *)ci, 0, sizeof(struct chip_info));
+
+       /* bus/core/clk setup for register access */
+       /* Try forcing SDIO core to do ALPAvail request only */
+       clkset = SBSDIO_FORCE_HW_CLKREQ_OFF | SBSDIO_ALP_AVAIL_REQ;
+       bcmsdh_cfg_write(bus->sdh, SDIO_FUNC_1, SBSDIO_FUNC1_CHIPCLKCSR,
+                       clkset, &err);
+       if (err) {
+               DHD_ERROR(("%s: error writing for HT off\n", __func__));
+               goto fail;
+       }
+
+       /* If register supported, wait for ALPAvail and then force ALP */
+       /* This may take up to 15 milliseconds */
+       clkval = bcmsdh_cfg_read(bus->sdh, SDIO_FUNC_1,
+                       SBSDIO_FUNC1_CHIPCLKCSR, NULL);
+       if ((clkval & ~SBSDIO_AVBITS) == clkset) {
+               SPINWAIT(((clkval =
+                               bcmsdh_cfg_read(bus->sdh, SDIO_FUNC_1,
+                                               SBSDIO_FUNC1_CHIPCLKCSR,
+                                               NULL)),
+                               !SBSDIO_ALPAV(clkval)),
+                               PMU_MAX_TRANSITION_DLY);
+               if (!SBSDIO_ALPAV(clkval)) {
+                       DHD_ERROR(("%s: timeout on ALPAV wait, clkval 0x%02x\n",
+                               __func__, clkval));
+                       err = -EBUSY;
+                       goto fail;
+               }
+               clkset = SBSDIO_FORCE_HW_CLKREQ_OFF |
+                               SBSDIO_FORCE_ALP;
+               bcmsdh_cfg_write(bus->sdh, SDIO_FUNC_1,
+                               SBSDIO_FUNC1_CHIPCLKCSR,
+                               clkset, &err);
+               udelay(65);
+       } else {
+               DHD_ERROR(("%s: ChipClkCSR access: wrote 0x%02x read 0x%02x\n",
+                       __func__, clkset, clkval));
+               err = -EACCES;
+               goto fail;
+       }
+
+       /* Also, disable the extra SDIO pull-ups */
+       bcmsdh_cfg_write(bus->sdh, SDIO_FUNC_1, SBSDIO_FUNC1_SDIOPULLUP, 0,
+                        NULL);
+
+       err = dhdsdio_chip_recognition(bus->sdh, ci, regs);
+       if (err)
+               goto fail;
+
+       /*
+        * Make sure any on-chip ARM is off (in case strapping is wrong),
+        * or downloaded code was already running.
+        */
+       dhdsdio_chip_disablecore(bus->sdh, ci->armcorebase);
+
+       bcmsdh_reg_write(bus->sdh,
+               CORE_CC_REG(ci->cccorebase, gpiopullup), 4, 0);
+       bcmsdh_reg_write(bus->sdh,
+               CORE_CC_REG(ci->cccorebase, gpiopulldown), 4, 0);
+
+       /* Disable F2 to clear any intermediate frame state on the dongle */
+       bcmsdh_cfg_write(bus->sdh, SDIO_FUNC_0, SDIOD_CCCR_IOEN,
+               SDIO_FUNC_ENABLE_1, NULL);
+
+       /* WAR: cmd52 backplane read so core HW will drop ALPReq */
+       clkval = bcmsdh_cfg_read(bus->sdh, SDIO_FUNC_1,
+                       0, NULL);
+
+       /* Done with backplane-dependent accesses, can drop clock... */
+       bcmsdh_cfg_write(bus->sdh, SDIO_FUNC_1, SBSDIO_FUNC1_CHIPCLKCSR, 0,
+                        NULL);
+
+       bus->ci = ci;
+       return 0;
+fail:
+       bus->ci = NULL;
+       kfree(ci);
+       return err;
+}
+
+static void
+dhdsdio_chip_resetcore(bcmsdh_info_t *sdh, u32 corebase)
+{
+       u32 regdata;
+
+       /*
+        * Must do the disable sequence first to work for
+        * arbitrary current core state.
+        */
+       dhdsdio_chip_disablecore(sdh, corebase);
+
+       /*
+        * Now do the initialization sequence.
+        * set reset while enabling the clock and
+        * forcing them on throughout the core
+        */
+       bcmsdh_reg_write(sdh, CORE_SB(corebase, sbtmstatelow), 4,
+               ((SICF_FGC | SICF_CLOCK_EN) << SBTML_SICF_SHIFT) |
+               SBTML_RESET);
+       udelay(1);
+
+       regdata = bcmsdh_reg_read(sdh, CORE_SB(corebase, sbtmstatehigh), 4);
+       if (regdata & SBTMH_SERR)
+               bcmsdh_reg_write(sdh, CORE_SB(corebase, sbtmstatehigh), 4, 0);
+
+       regdata = bcmsdh_reg_read(sdh, CORE_SB(corebase, sbimstate), 4);
+       if (regdata & (SBIM_IBE | SBIM_TO))
+               bcmsdh_reg_write(sdh, CORE_SB(corebase, sbimstate), 4,
+                       regdata & ~(SBIM_IBE | SBIM_TO));
+
+       /* clear reset and allow it to propagate throughout the core */
+       bcmsdh_reg_write(sdh, CORE_SB(corebase, sbtmstatelow), 4,
+               (SICF_FGC << SBTML_SICF_SHIFT) |
+               (SICF_CLOCK_EN << SBTML_SICF_SHIFT));
+       udelay(1);
+
+       /* leave clock enabled */
+       bcmsdh_reg_write(sdh, CORE_SB(corebase, sbtmstatelow), 4,
+               (SICF_CLOCK_EN << SBTML_SICF_SHIFT));
+       udelay(1);
+}
+
+/* SDIO Pad drive strength to select value mappings */
+struct sdiod_drive_str {
+       u8 strength;    /* Pad Drive Strength in mA */
+       u8 sel;         /* Chip-specific select value */
+};
+
+/* SDIO Drive Strength to sel value table for PMU Rev 1 */
+static const struct sdiod_drive_str sdiod_drive_strength_tab1[] = {
+       {
+       4, 0x2}, {
+       2, 0x3}, {
+       1, 0x0}, {
+       0, 0x0}
+       };
+
+/* SDIO Drive Strength to sel value table for PMU Rev 2, 3 */
+static const struct sdiod_drive_str sdiod_drive_strength_tab2[] = {
+       {
+       12, 0x7}, {
+       10, 0x6}, {
+       8, 0x5}, {
+       6, 0x4}, {
+       4, 0x2}, {
+       2, 0x1}, {
+       0, 0x0}
+       };
+
+/* SDIO Drive Strength to sel value table for PMU Rev 8 (1.8V) */
+static const struct sdiod_drive_str sdiod_drive_strength_tab3[] = {
+       {
+       32, 0x7}, {
+       26, 0x6}, {
+       22, 0x5}, {
+       16, 0x4}, {
+       12, 0x3}, {
+       8, 0x2}, {
+       4, 0x1}, {
+       0, 0x0}
+       };
+
+#define SDIOD_DRVSTR_KEY(chip, pmu)     (((chip) << 16) | (pmu))
+
+static void
+dhdsdio_sdiod_drive_strength_init(struct dhd_bus *bus, u32 drivestrength) {
+       struct sdiod_drive_str *str_tab = NULL;
+       u32 str_mask = 0;
+       u32 str_shift = 0;
+       char chn[8];
+
+       if (!(bus->ci->cccaps & CC_CAP_PMU))
+               return;
+
+       switch (SDIOD_DRVSTR_KEY(bus->ci->chip, bus->ci->pmurev)) {
+       case SDIOD_DRVSTR_KEY(BCM4325_CHIP_ID, 1):
+               str_tab = (struct sdiod_drive_str *)&sdiod_drive_strength_tab1;
+               str_mask = 0x30000000;
+               str_shift = 28;
+               break;
+       case SDIOD_DRVSTR_KEY(BCM4325_CHIP_ID, 2):
+       case SDIOD_DRVSTR_KEY(BCM4325_CHIP_ID, 3):
+               str_tab = (struct sdiod_drive_str *)&sdiod_drive_strength_tab2;
+               str_mask = 0x00003800;
+               str_shift = 11;
+               break;
+       case SDIOD_DRVSTR_KEY(BCM4336_CHIP_ID, 8):
+               str_tab = (struct sdiod_drive_str *)&sdiod_drive_strength_tab3;
+               str_mask = 0x00003800;
+               str_shift = 11;
+               break;
+       default:
+               DHD_ERROR(("No SDIO Drive strength init"
+                       "done for chip %s rev %d pmurev %d\n",
+                       bcm_chipname(bus->ci->chip, chn, 8),
+                       bus->ci->chiprev, bus->ci->pmurev));
+               break;
+       }
+
+       if (str_tab != NULL) {
+               u32 drivestrength_sel = 0;
+               u32 cc_data_temp;
+               int i;
+
+               for (i = 0; str_tab[i].strength != 0; i++) {
+                       if (drivestrength >= str_tab[i].strength) {
+                               drivestrength_sel = str_tab[i].sel;
+                               break;
+                       }
+               }
+
+               bcmsdh_reg_write(bus->sdh,
+                       CORE_CC_REG(bus->ci->cccorebase, chipcontrol_addr),
+                       4, 1);
+               cc_data_temp = bcmsdh_reg_read(bus->sdh,
+                       CORE_CC_REG(bus->ci->cccorebase, chipcontrol_addr), 4);
+               cc_data_temp &= ~str_mask;
+               drivestrength_sel <<= str_shift;
+               cc_data_temp |= drivestrength_sel;
+               bcmsdh_reg_write(bus->sdh,
+                       CORE_CC_REG(bus->ci->cccorebase, chipcontrol_addr),
+                       4, cc_data_temp);
+
+               DHD_INFO(("SDIO: %dmA drive strength selected, set to 0x%08x\n",
+                       drivestrength, cc_data_temp));
+       }
+}
+
+static void
+dhdsdio_chip_detach(struct dhd_bus *bus)
+{
+       DHD_TRACE(("%s: Enter\n", __func__));
+
+       kfree(bus->ci);
+       bus->ci = NULL;
+}
diff --git a/drivers/staging/brcm80211/brcmfmac/hndpmu.c b/drivers/staging/brcm80211/brcmfmac/hndpmu.c
deleted file mode 100644 (file)
index e841da6..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../util/hndpmu.c"
diff --git a/drivers/staging/brcm80211/brcmfmac/sbutils.c b/drivers/staging/brcm80211/brcmfmac/sbutils.c
deleted file mode 100644 (file)
index 64496b8..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../util/sbutils.c"
diff --git a/drivers/staging/brcm80211/brcmfmac/siutils.c b/drivers/staging/brcm80211/brcmfmac/siutils.c
deleted file mode 100644 (file)
index f428e99..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../util/siutils.c"
index 555b056b49b1db6f60b0b82245eb2338b6f39021..e3b409bb9847b708444ae03e88beda648630b5f4 100644 (file)
 #include <linux/firmware.h>
 #include <wl_cfg80211.h>
 
+void sdioh_sdio_set_host_pm_flags(int flag);
+
 static struct sdio_func *cfg80211_sdio_func;
 static struct wl_dev *wl_cfg80211_dev;
 static const u8 ether_bcast[ETH_ALEN] = {255, 255, 255, 255, 255, 255};
 
-u32 wl_dbg_level = WL_DBG_ERR | WL_DBG_INFO;
+u32 wl_dbg_level = WL_DBG_ERR;
 
 #define WL_4329_FW_FILE "brcm/bcm4329-fullmac-4.bin"
 #define WL_4329_NVRAM_FILE "brcm/bcm4329-fullmac-4.txt"
@@ -180,41 +182,34 @@ static void wl_init_prof(struct wl_profile *prof);
 ** cfg80211 connect utilites
 */
 static s32 wl_set_wpa_version(struct net_device *dev,
-                               struct cfg80211_connect_params *sme);
+                       struct cfg80211_connect_params *sme);
 static s32 wl_set_auth_type(struct net_device *dev,
-                             struct cfg80211_connect_params *sme);
+                       struct cfg80211_connect_params *sme);
 static s32 wl_set_set_cipher(struct net_device *dev,
-                              struct cfg80211_connect_params *sme);
+                       struct cfg80211_connect_params *sme);
 static s32 wl_set_key_mgmt(struct net_device *dev,
-                            struct cfg80211_connect_params *sme);
+                       struct cfg80211_connect_params *sme);
 static s32 wl_set_set_sharedkey(struct net_device *dev,
-                                 struct cfg80211_connect_params *sme);
+                       struct cfg80211_connect_params *sme);
 static s32 wl_get_assoc_ies(struct wl_priv *wl);
+static void wl_clear_assoc_ies(struct wl_priv *wl);
 static void wl_ch_to_chanspec(int ch,
        struct wl_join_params *join_params, size_t *join_params_size);
 
 /*
 ** information element utilities
 */
-static void wl_rst_ie(struct wl_priv *wl);
 static __used s32 wl_add_ie(struct wl_priv *wl, u8 t, u8 l, u8 *v);
-static s32 wl_mrg_ie(struct wl_priv *wl, u8 *ie_stream, u16 ie_size);
-static s32 wl_cp_ie(struct wl_priv *wl, u8 *dst, u16 dst_size);
-static u32 wl_get_ielen(struct wl_priv *wl);
-
 static s32 wl_mode_to_nl80211_iftype(s32 mode);
-
 static struct wireless_dev *wl_alloc_wdev(s32 sizeof_iface,
-                                         struct device *dev);
+                       struct device *dev);
 static void wl_free_wdev(struct wl_priv *wl);
-
 static s32 wl_inform_bss(struct wl_priv *wl);
 static s32 wl_inform_single_bss(struct wl_priv *wl, struct wl_bss_info *bi);
 static s32 wl_update_bss_info(struct wl_priv *wl);
-
 static s32 wl_add_keyext(struct wiphy *wiphy, struct net_device *dev,
-                          u8 key_idx, const u8 *mac_addr,
-                          struct key_params *params);
+                       u8 key_idx, const u8 *mac_addr,
+                       struct key_params *params);
 
 /*
 ** key indianess swap utilities
@@ -240,7 +235,6 @@ static void *wl_get_drvdata(struct wl_dev *dev);
 ** ibss mode utilities
 */
 static bool wl_is_ibssmode(struct wl_priv *wl);
-static bool wl_is_ibssstarter(struct wl_priv *wl);
 
 /*
 ** dongle up/down , default configuration utilities
@@ -248,7 +242,6 @@ static bool wl_is_ibssstarter(struct wl_priv *wl);
 static bool wl_is_linkdown(struct wl_priv *wl, const wl_event_msg_t *e);
 static bool wl_is_linkup(struct wl_priv *wl, const wl_event_msg_t *e);
 static bool wl_is_nonetwork(struct wl_priv *wl, const wl_event_msg_t *e);
-static void wl_link_up(struct wl_priv *wl);
 static void wl_link_down(struct wl_priv *wl);
 static s32 wl_dongle_mode(struct net_device *ndev, s32 iftype);
 static s32 __wl_cfg80211_up(struct wl_priv *wl);
@@ -266,18 +259,19 @@ static s32 wl_dongle_up(struct net_device *ndev, u32 up);
 static s32 wl_dongle_power(struct net_device *ndev, u32 power_mode);
 static s32 wl_dongle_glom(struct net_device *ndev, u32 glom,
                            u32 dongle_align);
-static s32 wl_dongle_roam(struct net_device *ndev, u32 roamvar,
-                           u32 bcn_timeout);
-static s32 wl_dongle_eventmsg(struct net_device *ndev);
-static s32 wl_dongle_scantime(struct net_device *ndev, s32 scan_assoc_time,
-                               s32 scan_unassoc_time);
 static s32 wl_dongle_offload(struct net_device *ndev, s32 arpoe,
                               s32 arp_ol);
 static s32 wl_pattern_atoh(s8 *src, s8 *dst);
 static s32 wl_dongle_filter(struct net_device *ndev, u32 filter_mode);
 static s32 wl_update_wiphybands(struct wl_priv *wl);
 #endif                         /* !EMBEDDED_PLATFORM */
+
+static s32 wl_dongle_eventmsg(struct net_device *ndev);
+static s32 wl_dongle_scantime(struct net_device *ndev, s32 scan_assoc_time,
+                               s32 scan_unassoc_time, s32 scan_passive_time);
 static s32 wl_config_dongle(struct wl_priv *wl, bool need_lock);
+static s32 wl_dongle_roam(struct net_device *ndev, u32 roamvar,
+                           u32 bcn_timeout);
 
 /*
 ** iscan handler
@@ -352,30 +346,6 @@ do {                                                                       \
 } while (0)
 
 extern int dhd_wait_pend8021x(struct net_device *dev);
-
-#if (WL_DBG_LEVEL > 0)
-#define WL_DBG_ESTR_MAX        32
-static s8 wl_dbg_estr[][WL_DBG_ESTR_MAX] = {
-       "SET_SSID", "JOIN", "START", "AUTH", "AUTH_IND",
-       "DEAUTH", "DEAUTH_IND", "ASSOC", "ASSOC_IND", "REASSOC",
-       "REASSOC_IND", "DISASSOC", "DISASSOC_IND", "QUIET_START", "QUIET_END",
-       "BEACON_RX", "LINK", "MIC_ERROR", "NDIS_LINK", "ROAM",
-       "TXFAIL", "PMKID_CACHE", "RETROGRADE_TSF", "PRUNE", "AUTOAUTH",
-       "EAPOL_MSG", "SCAN_COMPLETE", "ADDTS_IND", "DELTS_IND", "BCNSENT_IND",
-       "BCNRX_MSG", "BCNLOST_MSG", "ROAM_PREP", "PFN_NET_FOUND",
-       "PFN_NET_LOST",
-       "RESET_COMPLETE", "JOIN_START", "ROAM_START", "ASSOC_START",
-       "IBSS_ASSOC",
-       "RADIO", "PSM_WATCHDOG",
-       "PROBREQ_MSG",
-       "SCAN_CONFIRM_IND", "PSK_SUP", "COUNTRY_CODE_CHANGED",
-       "EXCEEDED_MEDIUM_TIME", "ICV_ERROR",
-       "UNICAST_DECODE_ERROR", "MULTICAST_DECODE_ERROR", "TRACE",
-       "IF",
-       "RSSI", "PFN_SCAN_COMPLETE", "ACTION_FRAME", "ACTION_FRAME_COMPLETE",
-};
-#endif                         /* WL_DBG_LEVEL */
-
 #define CHAN2G(_channel, _freq, _flags) {                      \
        .band                   = IEEE80211_BAND_2GHZ,          \
        .center_freq            = (_freq),                      \
@@ -604,10 +574,11 @@ wl_cfg80211_change_iface(struct wiphy *wiphy, struct net_device *ndev,
        struct wl_priv *wl = wiphy_to_wl(wiphy);
        struct wireless_dev *wdev;
        s32 infra = 0;
-       s32 ap = 0;
        s32 err = 0;
 
+       WL_TRACE("Enter\n");
        CHECK_SYS_UP();
+
        switch (type) {
        case NL80211_IFTYPE_MONITOR:
        case NL80211_IFTYPE_WDS:
@@ -616,32 +587,34 @@ wl_cfg80211_change_iface(struct wiphy *wiphy, struct net_device *ndev,
                return -EOPNOTSUPP;
        case NL80211_IFTYPE_ADHOC:
                wl->conf->mode = WL_MODE_IBSS;
+               infra = 0;
                break;
        case NL80211_IFTYPE_STATION:
                wl->conf->mode = WL_MODE_BSS;
                infra = 1;
                break;
        default:
-               return -EINVAL;
+               err = -EINVAL;
+               goto done;
        }
+
        infra = cpu_to_le32(infra);
-       ap = cpu_to_le32(ap);
-       wdev = ndev->ieee80211_ptr;
-       wdev->iftype = type;
-       WL_DBG("%s : ap (%d), infra (%d)\n", ndev->name, ap, infra);
        err = wl_dev_ioctl(ndev, WLC_SET_INFRA, &infra, sizeof(infra));
        if (unlikely(err)) {
                WL_ERR("WLC_SET_INFRA error (%d)\n", err);
-               return err;
-       }
-       err = wl_dev_ioctl(ndev, WLC_SET_AP, &ap, sizeof(ap));
-       if (unlikely(err)) {
-               WL_ERR("WLC_SET_AP error (%d)\n", err);
-               return err;
+               err = -EAGAIN;
+       } else {
+               wdev = ndev->ieee80211_ptr;
+               wdev->iftype = type;
        }
 
-       /* -EINPROGRESS: Call commit handler */
-       return -EINPROGRESS;
+       WL_INFO("IF Type = %s\n",
+               (wl->conf->mode == WL_MODE_IBSS) ? "Adhoc" : "Infra");
+
+done:
+       WL_TRACE("Exit\n");
+
+       return err;
 }
 
 static void wl_iscan_prep(struct wl_scan_params *params, struct wlc_ssid *ssid)
@@ -740,7 +713,7 @@ static s32 wl_do_iscan(struct wl_priv *wl)
        err = wl_dev_ioctl(wl_to_ndev(wl), WLC_SET_PASSIVE_SCAN,
                        &passive_scan, sizeof(passive_scan));
        if (unlikely(err)) {
-               WL_DBG("error (%d)\n", err);
+               WL_ERR("error (%d)\n", err);
                return err;
        }
        wl_set_mpc(ndev, 0);
@@ -774,26 +747,25 @@ __wl_cfg80211_scan(struct wiphy *wiphy, struct net_device *ndev,
                       (int)wl->status);
                return -EAGAIN;
        }
+       if (test_bit(WL_STATUS_CONNECTING, &wl->status)) {
+               WL_ERR("Connecting : status (%d)\n",
+                      (int)wl->status);
+               return -EAGAIN;
+       }
 
        iscan_req = false;
        spec_scan = false;
-       if (request) {          /* scan bss */
+       if (request) {
+               /* scan bss */
                ssids = request->ssids;
-               if (wl->iscan_on && (!ssids || !ssids->ssid_len)) {     /* for
-                                                        * specific scan,
-                                                        * ssids->ssid_len has
-                                                        * non-zero(ssid string)
-                                                        * length.
-                                                        * Otherwise this is 0.
-                                                        * we do not iscan for
-                                                        * specific scan request
-                                                        */
+               if (wl->iscan_on && (!ssids || !ssids->ssid_len))
                        iscan_req = true;
-               }
-       } else {                /* scan in ibss */
+       } else {
+               /* scan in ibss */
                /* we don't do iscan in ibss */
                ssids = this_ssid;
        }
+
        wl->scan_request = request;
        set_bit(WL_STATUS_SCANNING, &wl->status);
        if (iscan_req) {
@@ -803,7 +775,7 @@ __wl_cfg80211_scan(struct wiphy *wiphy, struct net_device *ndev,
                else
                        goto scan_out;
        } else {
-               WL_DBG("ssid \"%s\", ssid_len (%d)\n",
+               WL_SCAN("ssid \"%s\", ssid_len (%d)\n",
                       ssids->ssid, ssids->ssid_len);
                memset(&sr->ssid, 0, sizeof(sr->ssid));
                sr->ssid.SSID_len =
@@ -811,13 +783,11 @@ __wl_cfg80211_scan(struct wiphy *wiphy, struct net_device *ndev,
                if (sr->ssid.SSID_len) {
                        memcpy(sr->ssid.SSID, ssids->ssid, sr->ssid.SSID_len);
                        sr->ssid.SSID_len = cpu_to_le32(sr->ssid.SSID_len);
-                       WL_DBG("Specific scan ssid=\"%s\" len=%d\n",
-                              sr->ssid.SSID, sr->ssid.SSID_len);
                        spec_scan = true;
                } else {
-                       WL_DBG("Broadcast scan\n");
+                       WL_SCAN("Broadcast scan\n");
                }
-               WL_DBG("sr->ssid.SSID_len (%d)\n", sr->ssid.SSID_len);
+
                passive_scan = wl->active_scan ? 0 : 1;
                err = wl_dev_ioctl(ndev, WLC_SET_PASSIVE_SCAN,
                                &passive_scan, sizeof(passive_scan));
@@ -854,13 +824,15 @@ wl_cfg80211_scan(struct wiphy *wiphy, struct net_device *ndev,
 {
        s32 err = 0;
 
+       WL_TRACE("Enter\n");
+
        CHECK_SYS_UP();
+
        err = __wl_cfg80211_scan(wiphy, ndev, request, NULL);
-       if (unlikely(err)) {
-               WL_DBG("scan error (%d)\n", err);
-               return err;
-       }
+       if (unlikely(err))
+               WL_ERR("scan error (%d)\n", err);
 
+       WL_TRACE("Exit\n");
        return err;
 }
 
@@ -875,9 +847,8 @@ static s32 wl_dev_intvar_set(struct net_device *dev, s8 *name, s32 val)
        BUG_ON(!len);
 
        err = wl_dev_ioctl(dev, WLC_SET_VAR, buf, len);
-       if (unlikely(err)) {
+       if (unlikely(err))
                WL_ERR("error (%d)\n", err);
-       }
 
        return err;
 }
@@ -898,9 +869,9 @@ wl_dev_intvar_get(struct net_device *dev, s8 *name, s32 *retval)
                        sizeof(var.buf));
        BUG_ON(!len);
        err = wl_dev_ioctl(dev, WLC_GET_VAR, &var, len);
-       if (unlikely(err)) {
+       if (unlikely(err))
                WL_ERR("error (%d)\n", err);
-       }
+
        *retval = le32_to_cpu(var.val);
 
        return err;
@@ -911,10 +882,9 @@ static s32 wl_set_rts(struct net_device *dev, u32 rts_threshold)
        s32 err = 0;
 
        err = wl_dev_intvar_set(dev, "rtsthresh", rts_threshold);
-       if (unlikely(err)) {
+       if (unlikely(err))
                WL_ERR("Error (%d)\n", err);
-               return err;
-       }
+
        return err;
 }
 
@@ -923,10 +893,9 @@ static s32 wl_set_frag(struct net_device *dev, u32 frag_threshold)
        s32 err = 0;
 
        err = wl_dev_intvar_set(dev, "fragthresh", frag_threshold);
-       if (unlikely(err)) {
+       if (unlikely(err))
                WL_ERR("Error (%d)\n", err);
-               return err;
-       }
+
        return err;
 }
 
@@ -950,37 +919,40 @@ static s32 wl_cfg80211_set_wiphy_params(struct wiphy *wiphy, u32 changed)
        struct net_device *ndev = wl_to_ndev(wl);
        s32 err = 0;
 
+       WL_TRACE("Enter\n");
        CHECK_SYS_UP();
+
        if (changed & WIPHY_PARAM_RTS_THRESHOLD &&
            (wl->conf->rts_threshold != wiphy->rts_threshold)) {
                wl->conf->rts_threshold = wiphy->rts_threshold;
                err = wl_set_rts(ndev, wl->conf->rts_threshold);
                if (!err)
-                       return err;
+                       goto done;
        }
        if (changed & WIPHY_PARAM_FRAG_THRESHOLD &&
            (wl->conf->frag_threshold != wiphy->frag_threshold)) {
                wl->conf->frag_threshold = wiphy->frag_threshold;
                err = wl_set_frag(ndev, wl->conf->frag_threshold);
                if (!err)
-                       return err;
+                       goto done;
        }
        if (changed & WIPHY_PARAM_RETRY_LONG
            && (wl->conf->retry_long != wiphy->retry_long)) {
                wl->conf->retry_long = wiphy->retry_long;
                err = wl_set_retry(ndev, wl->conf->retry_long, true);
                if (!err)
-                       return err;
+                       goto done;
        }
        if (changed & WIPHY_PARAM_RETRY_SHORT
            && (wl->conf->retry_short != wiphy->retry_short)) {
                wl->conf->retry_short = wiphy->retry_short;
                err = wl_set_retry(ndev, wl->conf->retry_short, false);
-               if (!err) {
-                       return err;
-               }
+               if (!err)
+                       goto done;
        }
 
+done:
+       WL_TRACE("Exit\n");
        return err;
 }
 
@@ -989,68 +961,139 @@ wl_cfg80211_join_ibss(struct wiphy *wiphy, struct net_device *dev,
                      struct cfg80211_ibss_params *params)
 {
        struct wl_priv *wl = wiphy_to_wl(wiphy);
-       struct cfg80211_bss *bss;
-       struct ieee80211_channel *chan;
        struct wl_join_params join_params;
-       struct cfg80211_ssid ssid;
-       s32 scan_retry = 0;
+       size_t join_params_size = 0;
        s32 err = 0;
+       s32 wsec = 0;
+       s32 bcnprd;
 
+       WL_TRACE("Enter\n");
        CHECK_SYS_UP();
-       if (params->bssid) {
-               WL_ERR("Invalid bssid\n");
+
+       if (params->ssid)
+               WL_CONN("SSID: %s\n", params->ssid);
+       else {
+               WL_CONN("SSID: NULL, Not supported\n");
                return -EOPNOTSUPP;
        }
-       bss = cfg80211_get_ibss(wiphy, NULL, params->ssid, params->ssid_len);
-       if (!bss) {
-               memcpy(ssid.ssid, params->ssid, params->ssid_len);
-               ssid.ssid_len = params->ssid_len;
-               do {
-                       if (unlikely
-                           (__wl_cfg80211_scan(wiphy, dev, NULL, &ssid) ==
-                            -EBUSY)) {
-                               wl_delay(150);
-                       } else {
-                               break;
-                       }
-               } while (++scan_retry < WL_SCAN_RETRY_MAX);
-               rtnl_unlock();  /* to allow scan_inform to paropagate
-                                        to cfg80211 plane */
-               schedule_timeout_interruptible(4 * HZ); /* wait 4 secons
-                                                till scan done.... */
-               rtnl_lock();
-               bss = cfg80211_get_ibss(wiphy, NULL,
-                                       params->ssid, params->ssid_len);
+
+       if (params->bssid)
+               WL_CONN("BSSID: %02X %02X %02X %02X %02X %02X\n",
+               params->bssid[0], params->bssid[1], params->bssid[2],
+               params->bssid[3], params->bssid[4], params->bssid[5]);
+       else
+               WL_CONN("No BSSID specified\n");
+
+       if (params->channel)
+               WL_CONN("channel: %d\n", params->channel->center_freq);
+       else
+               WL_CONN("no channel specified\n");
+
+       if (params->channel_fixed)
+               WL_CONN("fixed channel required\n");
+       else
+               WL_CONN("no fixed channel required\n");
+
+       if (params->ie && params->ie_len)
+               WL_CONN("ie len: %d\n", params->ie_len);
+       else
+               WL_CONN("no ie specified\n");
+
+       if (params->beacon_interval)
+               WL_CONN("beacon interval: %d\n", params->beacon_interval);
+       else
+               WL_CONN("no beacon interval specified\n");
+
+       if (params->basic_rates)
+               WL_CONN("basic rates: %08X\n", params->basic_rates);
+       else
+               WL_CONN("no basic rates specified\n");
+
+       if (params->privacy)
+               WL_CONN("privacy required\n");
+       else
+               WL_CONN("no privacy required\n");
+
+       /* Configure Privacy for starter */
+       if (params->privacy)
+               wsec |= WEP_ENABLED;
+
+       err = wl_dev_intvar_set(dev, "wsec", wsec);
+       if (unlikely(err)) {
+               WL_ERR("wsec failed (%d)\n", err);
+               goto done;
        }
-       if (bss) {
-               wl->ibss_starter = false;
-               WL_DBG("Found IBSS\n");
+
+       /* Configure Beacon Interval for starter */
+       if (params->beacon_interval)
+               bcnprd = cpu_to_le32(params->beacon_interval);
+       else
+               bcnprd = cpu_to_le32(100);
+
+       err = wl_dev_ioctl(dev, WLC_SET_BCNPRD, &bcnprd, sizeof(bcnprd));
+       if (unlikely(err)) {
+               WL_ERR("WLC_SET_BCNPRD failed (%d)\n", err);
+               goto done;
+       }
+
+       /* Configure required join parameter */
+       memset(&join_params, 0, sizeof(wl_join_params_t));
+
+       /* SSID */
+       join_params.ssid.SSID_len =
+                       (params->ssid_len > 32) ? 32 : params->ssid_len;
+       memcpy(join_params.ssid.SSID, params->ssid, join_params.ssid.SSID_len);
+       join_params.ssid.SSID_len = cpu_to_le32(join_params.ssid.SSID_len);
+       join_params_size = sizeof(join_params.ssid);
+       wl_update_prof(wl, NULL, &join_params.ssid, WL_PROF_SSID);
+
+       /* BSSID */
+       if (params->bssid) {
+               memcpy(join_params.params.bssid, params->bssid, ETH_ALEN);
+               join_params_size =
+                       sizeof(join_params.ssid) + WL_ASSOC_PARAMS_FIXED_SIZE;
        } else {
-               wl->ibss_starter = true;
+               memcpy(join_params.params.bssid, ether_bcast, ETH_ALEN);
        }
-       chan = params->channel;
-       if (chan)
-               wl->channel = ieee80211_frequency_to_channel(chan->center_freq);
-       /*
-        ** Join with specific BSSID and cached SSID
-        ** If SSID is zero join based on BSSID only
-        */
-       memset(&join_params, 0, sizeof(join_params));
-       memcpy((void *)join_params.ssid.SSID, (void *)params->ssid,
-              params->ssid_len);
-       join_params.ssid.SSID_len = cpu_to_le32(params->ssid_len);
-       if (params->bssid)
-               memcpy(&join_params.params.bssid, params->bssid,
-                      ETH_ALEN);
-       else
-               memset(&join_params.params.bssid, 0, ETH_ALEN);
+       wl_update_prof(wl, NULL, &join_params.params.bssid, WL_PROF_BSSID);
+
+       /* Channel */
+       if (params->channel) {
+               u32 target_channel;
+
+               wl->channel =
+                       ieee80211_frequency_to_channel(
+                               params->channel->center_freq);
+               if (params->channel_fixed) {
+                       /* adding chanspec */
+                       wl_ch_to_chanspec(wl->channel,
+                               &join_params, &join_params_size);
+               }
+
+               /* set channel for starter */
+               target_channel = cpu_to_le32(wl->channel);
+               err = wl_dev_ioctl(dev, WLC_SET_CHANNEL,
+                       &target_channel, sizeof(target_channel));
+               if (unlikely(err)) {
+                       WL_ERR("WLC_SET_CHANNEL failed (%d)\n", err);
+                       goto done;
+               }
+       } else
+               wl->channel = 0;
 
-       err = wl_dev_ioctl(dev, WLC_SET_SSID, &join_params,
-                       sizeof(join_params));
+       wl->ibss_starter = false;
+
+
+       err = wl_dev_ioctl(dev, WLC_SET_SSID, &join_params, join_params_size);
        if (unlikely(err)) {
-               WL_ERR("Error (%d)\n", err);
-               return err;
+               WL_ERR("WLC_SET_SSID failed (%d)\n", err);
+               goto done;
        }
+
+       set_bit(WL_STATUS_CONNECTING, &wl->status);
+
+done:
+       WL_TRACE("Exit\n");
        return err;
 }
 
@@ -1059,9 +1102,13 @@ static s32 wl_cfg80211_leave_ibss(struct wiphy *wiphy, struct net_device *dev)
        struct wl_priv *wl = wiphy_to_wl(wiphy);
        s32 err = 0;
 
+       WL_TRACE("Enter\n");
        CHECK_SYS_UP();
+
        wl_link_down(wl);
 
+       WL_TRACE("Exit\n");
+
        return err;
 }
 
@@ -1079,7 +1126,7 @@ wl_set_wpa_version(struct net_device *dev, struct cfg80211_connect_params *sme)
                val = WPA2_AUTH_PSK | WPA2_AUTH_UNSPECIFIED;
        else
                val = WPA_AUTH_DISABLED;
-       WL_DBG("setting wpa_auth to 0x%0x\n", val);
+       WL_CONN("setting wpa_auth to 0x%0x\n", val);
        err = wl_dev_intvar_set(dev, "wpa_auth", val);
        if (unlikely(err)) {
                WL_ERR("set wpa_auth failed (%d)\n", err);
@@ -1101,18 +1148,18 @@ wl_set_auth_type(struct net_device *dev, struct cfg80211_connect_params *sme)
        switch (sme->auth_type) {
        case NL80211_AUTHTYPE_OPEN_SYSTEM:
                val = 0;
-               WL_DBG("open system\n");
+               WL_CONN("open system\n");
                break;
        case NL80211_AUTHTYPE_SHARED_KEY:
                val = 1;
-               WL_DBG("shared key\n");
+               WL_CONN("shared key\n");
                break;
        case NL80211_AUTHTYPE_AUTOMATIC:
                val = 2;
-               WL_DBG("automatic\n");
+               WL_CONN("automatic\n");
                break;
        case NL80211_AUTHTYPE_NETWORK_EAP:
-               WL_DBG("network eap\n");
+               WL_CONN("network eap\n");
        default:
                val = 2;
                WL_ERR("invalid auth type (%d)\n", sme->auth_type);
@@ -1181,7 +1228,7 @@ wl_set_set_cipher(struct net_device *dev, struct cfg80211_connect_params *sme)
                }
        }
 
-       WL_DBG("pval (%d) gval (%d)\n", pval, gval);
+       WL_CONN("pval (%d) gval (%d)\n", pval, gval);
        err = wl_dev_intvar_set(dev, "wsec", pval | gval);
        if (unlikely(err)) {
                WL_ERR("error (%d)\n", err);
@@ -1237,7 +1284,7 @@ wl_set_key_mgmt(struct net_device *dev, struct cfg80211_connect_params *sme)
                        }
                }
 
-               WL_DBG("setting wpa_auth to %d\n", val);
+               WL_CONN("setting wpa_auth to %d\n", val);
                err = wl_dev_intvar_set(dev, "wpa_auth", val);
                if (unlikely(err)) {
                        WL_ERR("could not set wpa_auth (%d)\n", err);
@@ -1260,10 +1307,10 @@ wl_set_set_sharedkey(struct net_device *dev,
        s32 val;
        s32 err = 0;
 
-       WL_DBG("key len (%d)\n", sme->key_len);
+       WL_CONN("key len (%d)\n", sme->key_len);
        if (sme->key_len) {
                sec = wl_read_prof(wl, WL_PROF_SEC);
-               WL_DBG("wpa_versions 0x%x cipher_pairwise 0x%x\n",
+               WL_CONN("wpa_versions 0x%x cipher_pairwise 0x%x\n",
                       sec->wpa_versions, sec->cipher_pairwise);
                if (!
                    (sec->wpa_versions & (NL80211_WPA_VERSION_1 |
@@ -1292,9 +1339,9 @@ wl_set_set_sharedkey(struct net_device *dev,
                                return -EINVAL;
                        }
                        /* Set the new key/index */
-                       WL_DBG("key length (%d) key index (%d) algo (%d)\n",
+                       WL_CONN("key length (%d) key index (%d) algo (%d)\n",
                               key.len, key.index, key.algo);
-                       WL_DBG("key \"%s\"\n", key.data);
+                       WL_CONN("key \"%s\"\n", key.data);
                        swap_key_from_BE(&key);
                        err = wl_dev_ioctl(dev, WLC_SET_KEY, &key,
                                        sizeof(key));
@@ -1303,7 +1350,7 @@ wl_set_set_sharedkey(struct net_device *dev,
                                return err;
                        }
                        if (sec->auth_type == NL80211_AUTHTYPE_OPEN_SYSTEM) {
-                               WL_DBG("set auth_type to shared key\n");
+                               WL_CONN("set auth_type to shared key\n");
                                val = 1;        /* shared key */
                                err = wl_dev_intvar_set(dev, "auth", val);
                                if (unlikely(err)) {
@@ -1327,17 +1374,24 @@ wl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev,
 
        s32 err = 0;
 
+       WL_TRACE("Enter\n");
        CHECK_SYS_UP();
+
        if (unlikely(!sme->ssid)) {
                WL_ERR("Invalid ssid\n");
                return -EOPNOTSUPP;
        }
+
        if (chan) {
-               wl->channel = ieee80211_frequency_to_channel(chan->center_freq);
-               WL_DBG("channel (%d), center_req (%d)\n",
-                      wl->channel, chan->center_freq);
-       }
-       WL_DBG("ie (%p), ie_len (%zd)\n", sme->ie, sme->ie_len);
+               wl->channel =
+                       ieee80211_frequency_to_channel(chan->center_freq);
+               WL_CONN("channel (%d), center_req (%d)\n",
+                       wl->channel, chan->center_freq);
+       } else
+               wl->channel = 0;
+
+       WL_INFO("ie (%p), ie_len (%zd)\n", sme->ie, sme->ie_len);
+
        err = wl_set_wpa_version(dev, sme);
        if (unlikely(err))
                return err;
@@ -1370,15 +1424,18 @@ wl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev,
        memcpy(&join_params.ssid.SSID, sme->ssid, join_params.ssid.SSID_len);
        join_params.ssid.SSID_len = cpu_to_le32(join_params.ssid.SSID_len);
        wl_update_prof(wl, NULL, &join_params.ssid, WL_PROF_SSID);
-       memcpy(join_params.params.bssid, ether_bcast, ETH_ALEN);
 
-       wl_ch_to_chanspec(wl->channel, &join_params, &join_params_size);
-       WL_DBG("join_param_size %zu\n", join_params_size);
+       if (sme->bssid)
+               memcpy(join_params.params.bssid, sme->bssid, ETH_ALEN);
+       else
+               memcpy(join_params.params.bssid, ether_bcast, ETH_ALEN);
 
        if (join_params.ssid.SSID_len < IEEE80211_MAX_SSID_LEN) {
-               WL_DBG("ssid \"%s\", len (%d)\n",
+               WL_CONN("ssid \"%s\", len (%d)\n",
                       join_params.ssid.SSID, join_params.ssid.SSID_len);
        }
+
+       wl_ch_to_chanspec(wl->channel, &join_params, &join_params_size);
        err = wl_dev_ioctl(dev, WLC_SET_SSID, &join_params, join_params_size);
        if (unlikely(err)) {
                WL_ERR("error (%d)\n", err);
@@ -1386,6 +1443,7 @@ wl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev,
        }
        set_bit(WL_STATUS_CONNECTING, &wl->status);
 
+       WL_TRACE("Exit\n");
        return err;
 }
 
@@ -1395,24 +1453,24 @@ wl_cfg80211_disconnect(struct wiphy *wiphy, struct net_device *dev,
 {
        struct wl_priv *wl = wiphy_to_wl(wiphy);
        scb_val_t scbval;
-       bool act = false;
        s32 err = 0;
 
-       WL_DBG("Reason %d\n", reason_code);
+       WL_TRACE("Enter. Reason code = %d\n", reason_code);
        CHECK_SYS_UP();
-       act = *(bool *) wl_read_prof(wl, WL_PROF_ACT);
-       if (likely(act)) {
-               scbval.val = reason_code;
-               memcpy(&scbval.ea, &wl->bssid, ETH_ALEN);
-               scbval.val = cpu_to_le32(scbval.val);
-               err = wl_dev_ioctl(dev, WLC_DISASSOC, &scbval,
-                               sizeof(scb_val_t));
-               if (unlikely(err)) {
-                       WL_ERR("error (%d)\n", err);
-                       return err;
-               }
-       }
 
+       clear_bit(WL_STATUS_CONNECTED, &wl->status);
+
+       scbval.val = reason_code;
+       memcpy(&scbval.ea, wl_read_prof(wl, WL_PROF_BSSID), ETH_ALEN);
+       scbval.val = cpu_to_le32(scbval.val);
+       err = wl_dev_ioctl(dev, WLC_DISASSOC, &scbval,
+                       sizeof(scb_val_t));
+       if (unlikely(err))
+               WL_ERR("error (%d)\n", err);
+
+       wl->link_up = false;
+
+       WL_TRACE("Exit\n");
        return err;
 }
 
@@ -1427,20 +1485,24 @@ wl_cfg80211_set_tx_power(struct wiphy *wiphy,
        s32 err = 0;
        s32 disable = 0;
 
+       WL_TRACE("Enter\n");
        CHECK_SYS_UP();
+
        switch (type) {
        case NL80211_TX_POWER_AUTOMATIC:
                break;
        case NL80211_TX_POWER_LIMITED:
                if (dbm < 0) {
                        WL_ERR("TX_POWER_LIMITED - dbm is negative\n");
-                       return -EINVAL;
+                       err = -EINVAL;
+                       goto done;
                }
                break;
        case NL80211_TX_POWER_FIXED:
                if (dbm < 0) {
                        WL_ERR("TX_POWER_FIXED - dbm is negative\n");
-                       return -EINVAL;
+                       err = -EINVAL;
+                       goto done;
                }
                break;
        }
@@ -1448,10 +1510,8 @@ wl_cfg80211_set_tx_power(struct wiphy *wiphy,
        disable = WL_RADIO_SW_DISABLE << 16;
        disable = cpu_to_le32(disable);
        err = wl_dev_ioctl(ndev, WLC_SET_RADIO, &disable, sizeof(disable));
-       if (unlikely(err)) {
+       if (unlikely(err))
                WL_ERR("WLC_SET_RADIO error (%d)\n", err);
-               return err;
-       }
 
        if (dbm > 0xffff)
                txpwrmw = 0xffff;
@@ -1459,12 +1519,12 @@ wl_cfg80211_set_tx_power(struct wiphy *wiphy,
                txpwrmw = (u16) dbm;
        err = wl_dev_intvar_set(ndev, "qtxpower",
                        (s32) (bcm_mw_to_qdbm(txpwrmw)));
-       if (unlikely(err)) {
+       if (unlikely(err))
                WL_ERR("qtxpower error (%d)\n", err);
-               return err;
-       }
        wl->conf->tx_power = dbm;
 
+done:
+       WL_TRACE("Exit\n");
        return err;
 }
 
@@ -1476,15 +1536,20 @@ static s32 wl_cfg80211_get_tx_power(struct wiphy *wiphy, s32 *dbm)
        u8 result;
        s32 err = 0;
 
+       WL_TRACE("Enter\n");
        CHECK_SYS_UP();
+
        err = wl_dev_intvar_get(ndev, "qtxpower", &txpwrdbm);
        if (unlikely(err)) {
                WL_ERR("error (%d)\n", err);
-               return err;
+               goto done;
        }
+
        result = (u8) (txpwrdbm & ~WL_TXPWR_OVERRIDE);
        *dbm = (s32) bcm_qdbm_to_mw(result);
 
+done:
+       WL_TRACE("Exit\n");
        return err;
 }
 
@@ -1496,14 +1561,16 @@ wl_cfg80211_config_default_key(struct wiphy *wiphy, struct net_device *dev,
        s32 wsec;
        s32 err = 0;
 
-       WL_DBG("key index (%d)\n", key_idx);
+       WL_TRACE("Enter\n");
+       WL_CONN("key index (%d)\n", key_idx);
        CHECK_SYS_UP();
 
        err = wl_dev_ioctl(dev, WLC_GET_WSEC, &wsec, sizeof(wsec));
        if (unlikely(err)) {
                WL_ERR("WLC_GET_WSEC error (%d)\n", err);
-               return err;
+               goto done;
        }
+
        wsec = le32_to_cpu(wsec);
        if (wsec & WEP_ENABLED) {
                /* Just select a new current key */
@@ -1511,10 +1578,11 @@ wl_cfg80211_config_default_key(struct wiphy *wiphy, struct net_device *dev,
                index = cpu_to_le32(index);
                err = wl_dev_ioctl(dev, WLC_SET_KEY_PRIMARY, &index,
                                sizeof(index));
-               if (unlikely(err)) {
+               if (unlikely(err))
                        WL_ERR("error (%d)\n", err);
-               }
        }
+done:
+       WL_TRACE("Exit\n");
        return err;
 }
 
@@ -1547,7 +1615,7 @@ wl_add_keyext(struct wiphy *wiphy, struct net_device *dev,
                        return -EINVAL;
                }
 
-               WL_DBG("Setting the key index %d\n", key.index);
+               WL_CONN("Setting the key index %d\n", key.index);
                memcpy(key.data, params->key, key.len);
 
                if (params->cipher == WLAN_CIPHER_SUITE_TKIP) {
@@ -1571,23 +1639,23 @@ wl_add_keyext(struct wiphy *wiphy, struct net_device *dev,
                switch (params->cipher) {
                case WLAN_CIPHER_SUITE_WEP40:
                        key.algo = CRYPTO_ALGO_WEP1;
-                       WL_DBG("WLAN_CIPHER_SUITE_WEP40\n");
+                       WL_CONN("WLAN_CIPHER_SUITE_WEP40\n");
                        break;
                case WLAN_CIPHER_SUITE_WEP104:
                        key.algo = CRYPTO_ALGO_WEP128;
-                       WL_DBG("WLAN_CIPHER_SUITE_WEP104\n");
+                       WL_CONN("WLAN_CIPHER_SUITE_WEP104\n");
                        break;
                case WLAN_CIPHER_SUITE_TKIP:
                        key.algo = CRYPTO_ALGO_TKIP;
-                       WL_DBG("WLAN_CIPHER_SUITE_TKIP\n");
+                       WL_CONN("WLAN_CIPHER_SUITE_TKIP\n");
                        break;
                case WLAN_CIPHER_SUITE_AES_CMAC:
                        key.algo = CRYPTO_ALGO_AES_CCM;
-                       WL_DBG("WLAN_CIPHER_SUITE_AES_CMAC\n");
+                       WL_CONN("WLAN_CIPHER_SUITE_AES_CMAC\n");
                        break;
                case WLAN_CIPHER_SUITE_CCMP:
                        key.algo = CRYPTO_ALGO_AES_CCM;
-                       WL_DBG("WLAN_CIPHER_SUITE_CCMP\n");
+                       WL_CONN("WLAN_CIPHER_SUITE_CCMP\n");
                        break;
                default:
                        WL_ERR("Invalid cipher (0x%x)\n", params->cipher);
@@ -1614,12 +1682,16 @@ wl_cfg80211_add_key(struct wiphy *wiphy, struct net_device *dev,
        s32 val;
        s32 wsec;
        s32 err = 0;
+       u8 keybuf[8];
 
-       WL_DBG("key index (%d)\n", key_idx);
+       WL_TRACE("Enter\n");
+       WL_CONN("key index (%d)\n", key_idx);
        CHECK_SYS_UP();
 
-       if (mac_addr)
+       if (mac_addr) {
+               WL_TRACE("Exit");
                return wl_add_keyext(wiphy, dev, key_idx, mac_addr, params);
+       }
        memset(&key, 0, sizeof(key));
 
        key.len = (u32) params->key_len;
@@ -1627,7 +1699,8 @@ wl_cfg80211_add_key(struct wiphy *wiphy, struct net_device *dev,
 
        if (unlikely(key.len > sizeof(key.data))) {
                WL_ERR("Too long key length (%u)\n", key.len);
-               return -EINVAL;
+               err = -EINVAL;
+               goto done;
        }
        memcpy(key.data, params->key, key.len);
 
@@ -1635,27 +1708,31 @@ wl_cfg80211_add_key(struct wiphy *wiphy, struct net_device *dev,
        switch (params->cipher) {
        case WLAN_CIPHER_SUITE_WEP40:
                key.algo = CRYPTO_ALGO_WEP1;
-               WL_DBG("WLAN_CIPHER_SUITE_WEP40\n");
+               WL_CONN("WLAN_CIPHER_SUITE_WEP40\n");
                break;
        case WLAN_CIPHER_SUITE_WEP104:
                key.algo = CRYPTO_ALGO_WEP128;
-               WL_DBG("WLAN_CIPHER_SUITE_WEP104\n");
+               WL_CONN("WLAN_CIPHER_SUITE_WEP104\n");
                break;
        case WLAN_CIPHER_SUITE_TKIP:
+               memcpy(keybuf, &key.data[24], sizeof(keybuf));
+               memcpy(&key.data[24], &key.data[16], sizeof(keybuf));
+               memcpy(&key.data[16], keybuf, sizeof(keybuf));
                key.algo = CRYPTO_ALGO_TKIP;
-               WL_DBG("WLAN_CIPHER_SUITE_TKIP\n");
+               WL_CONN("WLAN_CIPHER_SUITE_TKIP\n");
                break;
        case WLAN_CIPHER_SUITE_AES_CMAC:
                key.algo = CRYPTO_ALGO_AES_CCM;
-               WL_DBG("WLAN_CIPHER_SUITE_AES_CMAC\n");
+               WL_CONN("WLAN_CIPHER_SUITE_AES_CMAC\n");
                break;
        case WLAN_CIPHER_SUITE_CCMP:
                key.algo = CRYPTO_ALGO_AES_CCM;
-               WL_DBG("WLAN_CIPHER_SUITE_CCMP\n");
+               WL_CONN("WLAN_CIPHER_SUITE_CCMP\n");
                break;
        default:
                WL_ERR("Invalid cipher (0x%x)\n", params->cipher);
-               return -EINVAL;
+               err = -EINVAL;
+               goto done;
        }
 
        /* Set the new key/index */
@@ -1663,30 +1740,30 @@ wl_cfg80211_add_key(struct wiphy *wiphy, struct net_device *dev,
        err = wl_dev_ioctl(dev, WLC_SET_KEY, &key, sizeof(key));
        if (unlikely(err)) {
                WL_ERR("WLC_SET_KEY error (%d)\n", err);
-               return err;
+               goto done;
        }
 
        val = WEP_ENABLED;
        err = wl_dev_intvar_get(dev, "wsec", &wsec);
        if (unlikely(err)) {
                WL_ERR("get wsec error (%d)\n", err);
-               return err;
+               goto done;
        }
        wsec &= ~(WEP_ENABLED);
        wsec |= val;
        err = wl_dev_intvar_set(dev, "wsec", wsec);
        if (unlikely(err)) {
                WL_ERR("set wsec error (%d)\n", err);
-               return err;
+               goto done;
        }
 
        val = 1;                /* assume shared key. otherwise 0 */
        val = cpu_to_le32(val);
        err = wl_dev_ioctl(dev, WLC_SET_AUTH, &val, sizeof(val));
-       if (unlikely(err)) {
+       if (unlikely(err))
                WL_ERR("WLC_SET_AUTH error (%d)\n", err);
-               return err;
-       }
+done:
+       WL_TRACE("Exit\n");
        return err;
 }
 
@@ -1699,6 +1776,7 @@ wl_cfg80211_del_key(struct wiphy *wiphy, struct net_device *dev,
        s32 val;
        s32 wsec;
 
+       WL_TRACE("Enter\n");
        CHECK_SYS_UP();
        memset(&key, 0, sizeof(key));
 
@@ -1706,34 +1784,39 @@ wl_cfg80211_del_key(struct wiphy *wiphy, struct net_device *dev,
        key.flags = WL_PRIMARY_KEY;
        key.algo = CRYPTO_ALGO_OFF;
 
-       WL_DBG("key index (%d)\n", key_idx);
+       WL_CONN("key index (%d)\n", key_idx);
        /* Set the new key/index */
        swap_key_from_BE(&key);
        err = wl_dev_ioctl(dev, WLC_SET_KEY, &key, sizeof(key));
        if (unlikely(err)) {
                if (err == -EINVAL) {
-                       if (key.index >= DOT11_MAX_DEFAULT_KEYS) {
+                       if (key.index >= DOT11_MAX_DEFAULT_KEYS)
                                /* we ignore this key index in this case */
-                               WL_DBG("invalid key index (%d)\n", key_idx);
-                       }
-               } else {
+                               WL_ERR("invalid key index (%d)\n", key_idx);
+               } else
                        WL_ERR("WLC_SET_KEY error (%d)\n", err);
-               }
-               return err;
+
+               /* Ignore this error, may happen during DISASSOC */
+               err = -EAGAIN;
+               goto done;
        }
 
        val = 0;
        err = wl_dev_intvar_get(dev, "wsec", &wsec);
        if (unlikely(err)) {
                WL_ERR("get wsec error (%d)\n", err);
-               return err;
+               /* Ignore this error, may happen during DISASSOC */
+               err = -EAGAIN;
+               goto done;
        }
        wsec &= ~(WEP_ENABLED);
        wsec |= val;
        err = wl_dev_intvar_set(dev, "wsec", wsec);
        if (unlikely(err)) {
                WL_ERR("set wsec error (%d)\n", err);
-               return err;
+               /* Ignore this error, may happen during DISASSOC */
+               err = -EAGAIN;
+               goto done;
        }
 
        val = 0;                /* assume open key. otherwise 1 */
@@ -1741,8 +1824,11 @@ wl_cfg80211_del_key(struct wiphy *wiphy, struct net_device *dev,
        err = wl_dev_ioctl(dev, WLC_SET_AUTH, &val, sizeof(val));
        if (unlikely(err)) {
                WL_ERR("WLC_SET_AUTH error (%d)\n", err);
-               return err;
+               /* Ignore this error, may happen during DISASSOC */
+               err = -EAGAIN;
        }
+done:
+       WL_TRACE("Exit\n");
        return err;
 }
 
@@ -1758,7 +1844,8 @@ wl_cfg80211_get_key(struct wiphy *wiphy, struct net_device *dev,
        s32 wsec;
        s32 err = 0;
 
-       WL_DBG("key index (%d)\n", key_idx);
+       WL_TRACE("Enter\n");
+       WL_CONN("key index (%d)\n", key_idx);
        CHECK_SYS_UP();
 
        memset(&key, 0, sizeof(key));
@@ -1771,7 +1858,9 @@ wl_cfg80211_get_key(struct wiphy *wiphy, struct net_device *dev,
        err = wl_dev_ioctl(dev, WLC_GET_WSEC, &wsec, sizeof(wsec));
        if (unlikely(err)) {
                WL_ERR("WLC_GET_WSEC error (%d)\n", err);
-               return err;
+               /* Ignore this error, may happen during DISASSOC */
+               err = -EAGAIN;
+               goto done;
        }
        wsec = le32_to_cpu(wsec);
        switch (wsec) {
@@ -1779,26 +1868,29 @@ wl_cfg80211_get_key(struct wiphy *wiphy, struct net_device *dev,
                sec = wl_read_prof(wl, WL_PROF_SEC);
                if (sec->cipher_pairwise & WLAN_CIPHER_SUITE_WEP40) {
                        params.cipher = WLAN_CIPHER_SUITE_WEP40;
-                       WL_DBG("WLAN_CIPHER_SUITE_WEP40\n");
+                       WL_CONN("WLAN_CIPHER_SUITE_WEP40\n");
                } else if (sec->cipher_pairwise & WLAN_CIPHER_SUITE_WEP104) {
                        params.cipher = WLAN_CIPHER_SUITE_WEP104;
-                       WL_DBG("WLAN_CIPHER_SUITE_WEP104\n");
+                       WL_CONN("WLAN_CIPHER_SUITE_WEP104\n");
                }
                break;
        case TKIP_ENABLED:
                params.cipher = WLAN_CIPHER_SUITE_TKIP;
-               WL_DBG("WLAN_CIPHER_SUITE_TKIP\n");
+               WL_CONN("WLAN_CIPHER_SUITE_TKIP\n");
                break;
        case AES_ENABLED:
                params.cipher = WLAN_CIPHER_SUITE_AES_CMAC;
-               WL_DBG("WLAN_CIPHER_SUITE_AES_CMAC\n");
+               WL_CONN("WLAN_CIPHER_SUITE_AES_CMAC\n");
                break;
        default:
                WL_ERR("Invalid algo (0x%x)\n", wsec);
-               return -EINVAL;
+               err = -EINVAL;
+               goto done;
        }
-
        callback(cookie, &params);
+
+done:
+       WL_TRACE("Exit\n");
        return err;
 }
 
@@ -1807,6 +1899,7 @@ wl_cfg80211_config_default_mgmt_key(struct wiphy *wiphy,
                                    struct net_device *dev, u8 key_idx)
 {
        WL_INFO("Not supported\n");
+
        CHECK_SYS_UP();
        return -EOPNOTSUPP;
 }
@@ -1820,12 +1913,20 @@ wl_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
        int rssi;
        s32 rate;
        s32 err = 0;
+       u8 *bssid = wl_read_prof(wl, WL_PROF_BSSID);
 
+       WL_TRACE("Enter\n");
        CHECK_SYS_UP();
+
        if (unlikely
-           (memcmp(mac, wl_read_prof(wl, WL_PROF_BSSID), ETH_ALEN))) {
-               WL_ERR("Wrong Mac address\n");
-               return -ENOENT;
+           (memcmp(mac, bssid, ETH_ALEN))) {
+               WL_ERR("Wrong Mac address cfg_mac-%X:%X:%X:%X:%X:%X"
+                       "wl_bssid-%X:%X:%X:%X:%X:%X\n",
+                       mac[0], mac[1], mac[2], mac[3], mac[4], mac[5],
+                       bssid[0], bssid[1], bssid[2], bssid[3],
+                       bssid[4], bssid[5]);
+               err = -ENOENT;
+               goto done;
        }
 
        /* Report the current tx rate */
@@ -1836,7 +1937,7 @@ wl_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
                rate = le32_to_cpu(rate);
                sinfo->filled |= STATION_INFO_TX_BITRATE;
                sinfo->txrate.legacy = rate * 5;
-               WL_DBG("Rate %d Mbps\n", rate / 2);
+               WL_CONN("Rate %d Mbps\n", rate / 2);
        }
 
        if (test_bit(WL_STATUS_CONNECTED, &wl->status)) {
@@ -1845,14 +1946,15 @@ wl_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
                                sizeof(scb_val_t));
                if (unlikely(err)) {
                        WL_ERR("Could not get rssi (%d)\n", err);
-                       return err;
                }
                rssi = le32_to_cpu(scb_val.val);
                sinfo->filled |= STATION_INFO_SIGNAL;
                sinfo->signal = rssi;
-               WL_DBG("RSSI %d dBm\n", rssi);
+               WL_CONN("RSSI %d dBm\n", rssi);
        }
 
+done:
+       WL_TRACE("Exit\n");
        return err;
 }
 
@@ -1863,18 +1965,21 @@ wl_cfg80211_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev,
        s32 pm;
        s32 err = 0;
 
+       WL_TRACE("Enter\n");
        CHECK_SYS_UP();
+
        pm = enabled ? PM_FAST : PM_OFF;
        pm = cpu_to_le32(pm);
-       WL_DBG("power save %s\n", (pm ? "enabled" : "disabled"));
+       WL_INFO("power save %s\n", (pm ? "enabled" : "disabled"));
+
        err = wl_dev_ioctl(dev, WLC_SET_PM, &pm, sizeof(pm));
        if (unlikely(err)) {
                if (err == -ENODEV)
-                       WL_DBG("net_device is not ready yet\n");
+                       WL_ERR("net_device is not ready yet\n");
                else
                        WL_ERR("error (%d)\n", err);
-               return err;
        }
+       WL_TRACE("Exit\n");
        return err;
 }
 
@@ -1918,14 +2023,16 @@ wl_cfg80211_set_bitrate_mask(struct wiphy *wiphy, struct net_device *dev,
        u32 legacy;
        s32 err = 0;
 
+       WL_TRACE("Enter\n");
        CHECK_SYS_UP();
+
        /* addr param is always NULL. ignore it */
        /* Get current rateset */
        err = wl_dev_ioctl(dev, WLC_GET_CURR_RATESET, &rateset,
                        sizeof(rateset));
        if (unlikely(err)) {
                WL_ERR("could not get current rateset (%d)\n", err);
-               return err;
+               goto done;
        }
 
        rateset.count = le32_to_cpu(rateset.count);
@@ -1936,15 +2043,14 @@ wl_cfg80211_set_bitrate_mask(struct wiphy *wiphy, struct net_device *dev,
 
        val = wl_g_rates[legacy - 1].bitrate * 100000;
 
-       if (val < rateset.count) {
+       if (val < rateset.count)
                /* Select rate by rateset index */
                rate = rateset.rates[val] & 0x7f;
-       } else {
+       else
                /* Specified rate in bps */
                rate = val / 500000;
-       }
 
-       WL_DBG("rate %d mbps\n", rate / 2);
+       WL_CONN("rate %d mbps\n", rate / 2);
 
        /*
         *
@@ -1955,40 +2061,105 @@ wl_cfg80211_set_bitrate_mask(struct wiphy *wiphy, struct net_device *dev,
        err_a = wl_dev_intvar_set(dev, "a_rate", rate);
        if (unlikely(err_bg && err_a)) {
                WL_ERR("could not set fixed rate (%d) (%d)\n", err_bg, err_a);
-               return err_bg | err_a;
+               err = err_bg | err_a;
        }
 
+done:
+       WL_TRACE("Exit\n");
        return err;
 }
 
 static s32 wl_cfg80211_resume(struct wiphy *wiphy)
 {
-       s32 err = 0;
+       struct wl_priv *wl = wiphy_to_wl(wiphy);
+       struct net_device *ndev = wl_to_ndev(wl);
 
-       CHECK_SYS_UP();
-       wl_invoke_iscan(wiphy_to_wl(wiphy));
+       /*
+        * Check for WL_STATUS_READY before any function call which
+        * could result is bus access. Don't block the resume for
+        * any driver error conditions
+        */
+       WL_TRACE("Enter\n");
 
-       return err;
+#if defined(CONFIG_PM_SLEEP)
+       atomic_set(&dhd_mmc_suspend, false);
+#endif /*  defined(CONFIG_PM_SLEEP) */
+
+       if (test_bit(WL_STATUS_READY, &wl->status)) {
+               /* Turn on Watchdog timer */
+               wl_os_wd_timer(ndev, dhd_watchdog_ms);
+               wl_invoke_iscan(wiphy_to_wl(wiphy));
+       }
+
+       WL_TRACE("Exit\n");
+       return 0;
 }
 
 static s32 wl_cfg80211_suspend(struct wiphy *wiphy)
 {
        struct wl_priv *wl = wiphy_to_wl(wiphy);
        struct net_device *ndev = wl_to_ndev(wl);
-       s32 err = 0;
+
+       WL_TRACE("Enter\n");
+
+       /*
+        * Check for WL_STATUS_READY before any function call which
+        * could result is bus access. Don't block the suspend for
+        * any driver error conditions
+        */
+
+       /*
+        * While going to suspend if associated with AP disassociate
+        * from AP to save power while system is in suspended state
+        */
+       if (test_bit(WL_STATUS_CONNECTED, &wl->status) &&
+               test_bit(WL_STATUS_READY, &wl->status)) {
+               WL_INFO("Disassociating from AP"
+                       " while entering suspend state\n");
+               wl_link_down(wl);
+
+               /*
+                * Make sure WPA_Supplicant receives all the event
+                * generated due to DISASSOC call to the fw to keep
+                * the state fw and WPA_Supplicant state consistent
+                */
+               rtnl_unlock();
+               wl_delay(500);
+               rtnl_lock();
+       }
 
        set_bit(WL_STATUS_SCAN_ABORTING, &wl->status);
-       wl_term_iscan(wl);
+       if (test_bit(WL_STATUS_READY, &wl->status))
+               wl_term_iscan(wl);
+
        if (wl->scan_request) {
-               cfg80211_scan_done(wl->scan_request, true);     /* true means
-                                                                abort */
-               wl_set_mpc(ndev, 1);
+               /* Indidate scan abort to cfg80211 layer */
+               WL_INFO("Terminating scan in progress\n");
+               cfg80211_scan_done(wl->scan_request, true);
                wl->scan_request = NULL;
        }
        clear_bit(WL_STATUS_SCANNING, &wl->status);
        clear_bit(WL_STATUS_SCAN_ABORTING, &wl->status);
+       clear_bit(WL_STATUS_CONNECTING, &wl->status);
+       clear_bit(WL_STATUS_CONNECTED, &wl->status);
 
-       return err;
+       /* Inform SDIO stack not to switch off power to the chip */
+       sdioh_sdio_set_host_pm_flags(MMC_PM_KEEP_POWER);
+
+       /* Turn off watchdog timer */
+       if (test_bit(WL_STATUS_READY, &wl->status)) {
+               WL_INFO("Terminate watchdog timer and enable MPC\n");
+               wl_set_mpc(ndev, 1);
+               wl_os_wd_timer(ndev, 0);
+       }
+
+#if defined(CONFIG_PM_SLEEP)
+       atomic_set(&dhd_mmc_suspend, true);
+#endif /*  defined(CONFIG_PM_SLEEP) */
+
+       WL_TRACE("Exit\n");
+
+       return 0;
 }
 
 static __used s32
@@ -1997,18 +2168,17 @@ wl_update_pmklist(struct net_device *dev, struct wl_pmk_list *pmk_list,
 {
        int i, j;
 
-       WL_DBG("No of elements %d\n", pmk_list->pmkids.npmkid);
+       WL_CONN("No of elements %d\n", pmk_list->pmkids.npmkid);
        for (i = 0; i < pmk_list->pmkids.npmkid; i++) {
-               WL_DBG("PMKID[%d]: %pM =\n", i,
+               WL_CONN("PMKID[%d]: %pM =\n", i,
                        &pmk_list->pmkids.pmkid[i].BSSID);
-               for (j = 0; j < WLAN_PMKID_LEN; j++) {
-                       WL_DBG("%02x\n", pmk_list->pmkids.pmkid[i].PMKID[j]);
-               }
+               for (j = 0; j < WLAN_PMKID_LEN; j++)
+                       WL_CONN("%02x\n", pmk_list->pmkids.pmkid[i].PMKID[j]);
        }
-       if (likely(!err)) {
-               err = wl_dev_bufvar_set(dev, "pmkid_info", (char *)pmk_list,
+
+       if (likely(!err))
+               wl_dev_bufvar_set(dev, "pmkid_info", (char *)pmk_list,
                                        sizeof(*pmk_list));
-       }
 
        return err;
 }
@@ -2021,7 +2191,9 @@ wl_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
        s32 err = 0;
        int i;
 
+       WL_TRACE("Enter\n");
        CHECK_SYS_UP();
+
        for (i = 0; i < wl->pmk_list->pmkids.npmkid; i++)
                if (!memcmp(pmksa->bssid, &wl->pmk_list->pmkids.pmkid[i].BSSID,
                            ETH_ALEN))
@@ -2033,19 +2205,19 @@ wl_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
                       WLAN_PMKID_LEN);
                if (i == wl->pmk_list->pmkids.npmkid)
                        wl->pmk_list->pmkids.npmkid++;
-       } else {
+       } else
                err = -EINVAL;
-       }
-       WL_DBG("set_pmksa,IW_PMKSA_ADD - PMKID: %pM =\n",
+
+       WL_CONN("set_pmksa,IW_PMKSA_ADD - PMKID: %pM =\n",
               &wl->pmk_list->pmkids.pmkid[wl->pmk_list->pmkids.npmkid].BSSID);
-       for (i = 0; i < WLAN_PMKID_LEN; i++) {
-               WL_DBG("%02x\n",
+       for (i = 0; i < WLAN_PMKID_LEN; i++)
+               WL_CONN("%02x\n",
                       wl->pmk_list->pmkids.pmkid[wl->pmk_list->pmkids.npmkid].
                       PMKID[i]);
-       }
 
        err = wl_update_pmklist(dev, wl->pmk_list, err);
 
+       WL_TRACE("Exit\n");
        return err;
 }
 
@@ -2058,15 +2230,15 @@ wl_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
        s32 err = 0;
        int i;
 
+       WL_TRACE("Enter\n");
        CHECK_SYS_UP();
        memcpy(&pmkid.pmkid[0].BSSID, pmksa->bssid, ETH_ALEN);
        memcpy(&pmkid.pmkid[0].PMKID, pmksa->pmkid, WLAN_PMKID_LEN);
 
-       WL_DBG("del_pmksa,IW_PMKSA_REMOVE - PMKID: %pM =\n",
+       WL_CONN("del_pmksa,IW_PMKSA_REMOVE - PMKID: %pM =\n",
               &pmkid.pmkid[0].BSSID);
-       for (i = 0; i < WLAN_PMKID_LEN; i++) {
-               WL_DBG("%02x\n", pmkid.pmkid[0].PMKID[i]);
-       }
+       for (i = 0; i < WLAN_PMKID_LEN; i++)
+               WL_CONN("%02x\n", pmkid.pmkid[0].PMKID[i]);
 
        for (i = 0; i < wl->pmk_list->pmkids.npmkid; i++)
                if (!memcmp
@@ -2086,12 +2258,12 @@ wl_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
                               WLAN_PMKID_LEN);
                }
                wl->pmk_list->pmkids.npmkid--;
-       } else {
+       } else
                err = -EINVAL;
-       }
 
        err = wl_update_pmklist(dev, wl->pmk_list, err);
 
+       WL_TRACE("Exit\n");
        return err;
 
 }
@@ -2102,9 +2274,13 @@ wl_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
        struct wl_priv *wl = wiphy_to_wl(wiphy);
        s32 err = 0;
 
+       WL_TRACE("Enter\n");
        CHECK_SYS_UP();
+
        memset(wl->pmk_list, 0, sizeof(*wl->pmk_list));
        err = wl_update_pmklist(dev, wl->pmk_list, err);
+
+       WL_TRACE("Exit\n");
        return err;
 
 }
@@ -2235,7 +2411,7 @@ static s32 wl_inform_bss(struct wl_priv *wl)
                       bss_list->version);
                return -EOPNOTSUPP;
        }
-       WL_DBG("scanned AP count (%d)\n", bss_list->count);
+       WL_SCAN("scanned AP count (%d)\n", bss_list->count);
        bi = next_bss(bss_list, bi);
        for_each_bss(bss_list, bi, i) {
                err = wl_inform_single_bss(wl, bi);
@@ -2245,89 +2421,137 @@ static s32 wl_inform_bss(struct wl_priv *wl)
        return err;
 }
 
+
 static s32 wl_inform_single_bss(struct wl_priv *wl, struct wl_bss_info *bi)
 {
        struct wiphy *wiphy = wl_to_wiphy(wl);
-       struct ieee80211_mgmt *mgmt;
-       struct ieee80211_channel *channel;
+       struct ieee80211_channel *notify_channel;
+       struct cfg80211_bss *bss;
        struct ieee80211_supported_band *band;
-       struct wl_cfg80211_bss_info *notif_bss_info;
-       struct wl_scan_req *sr = wl_to_sr(wl);
-       struct beacon_proberesp *beacon_proberesp;
-       s32 mgmt_type;
-       u32 signal;
-       u32 freq;
        s32 err = 0;
+       u16 channel;
+       u32 freq;
+       u64 notify_timestamp;
+       u16 notify_capability;
+       u16 notify_interval;
+       u8 *notify_ie;
+       size_t notify_ielen;
+       s32 notify_signal;
 
        if (unlikely(le32_to_cpu(bi->length) > WL_BSS_INFO_MAX)) {
-               WL_DBG("Beacon is larger than buffer. Discarding\n");
-               return err;
-       }
-       notif_bss_info =
-           kzalloc(sizeof(*notif_bss_info) + sizeof(*mgmt) - sizeof(u8) +
-                   WL_BSS_INFO_MAX, GFP_KERNEL);
-       if (unlikely(!notif_bss_info)) {
-               WL_ERR("notif_bss_info alloc failed\n");
-               return -ENOMEM;
+               WL_ERR("Bss info is larger than buffer. Discarding\n");
+               return 0;
        }
-       mgmt = (struct ieee80211_mgmt *)notif_bss_info->frame_buf;
-       notif_bss_info->channel =
-               bi->ctl_ch ? bi->ctl_ch : CHSPEC_CHANNEL(bi->chanspec);
 
-       if (notif_bss_info->channel <= CH_MAX_2G_CHANNEL)
+       channel = bi->ctl_ch ? bi->ctl_ch :
+                               CHSPEC_CHANNEL(le16_to_cpu(bi->chanspec));
+
+       if (channel <= CH_MAX_2G_CHANNEL)
                band = wiphy->bands[IEEE80211_BAND_2GHZ];
        else
                band = wiphy->bands[IEEE80211_BAND_5GHZ];
-       notif_bss_info->rssi = bi->RSSI;
-       memcpy(mgmt->bssid, &bi->BSSID, ETH_ALEN);
-       mgmt_type = wl->active_scan ?
-               IEEE80211_STYPE_PROBE_RESP : IEEE80211_STYPE_BEACON;
-       if (!memcmp(bi->SSID, sr->ssid.SSID, bi->SSID_len)) {
-               mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
-                                                       mgmt_type);
-       }
-       beacon_proberesp = wl->active_scan ?
-               (struct beacon_proberesp *)&mgmt->u.probe_resp :
-               (struct beacon_proberesp *)&mgmt->u.beacon;
-       beacon_proberesp->timestamp = 0;
-       beacon_proberesp->beacon_int = cpu_to_le16(bi->beacon_period);
-       beacon_proberesp->capab_info = cpu_to_le16(bi->capability);
-       wl_rst_ie(wl);
-       /*
-       * wl_add_ie is not necessary because it can only add duplicated
-       * SSID, rate information to frame_buf
-       */
-       /*
-       * wl_add_ie(wl, WLAN_EID_SSID, bi->SSID_len, bi->SSID);
-       * wl_add_ie(wl, WLAN_EID_SUPP_RATES, bi->rateset.count,
-       * bi->rateset.rates);
-       */
-       wl_mrg_ie(wl, ((u8 *) bi) + bi->ie_offset, bi->ie_length);
-       wl_cp_ie(wl, beacon_proberesp->variable, WL_BSS_INFO_MAX -
-                offsetof(struct wl_cfg80211_bss_info, frame_buf));
-       notif_bss_info->frame_len =
-           offsetof(struct ieee80211_mgmt,
-                    u.beacon.variable) + wl_get_ielen(wl);
-       freq = ieee80211_channel_to_frequency(notif_bss_info->channel,
-                                             band->band);
-
-       channel = ieee80211_get_channel(wiphy, freq);
-
-       WL_DBG("SSID : \"%s\", rssi %d, channel %d, capability : 0x04%x, bssid %pM\n",
-              bi->SSID,
-              notif_bss_info->rssi, notif_bss_info->channel,
-              mgmt->u.beacon.capab_info, &bi->BSSID);
-
-       signal = notif_bss_info->rssi * 100;
-       if (unlikely(!cfg80211_inform_bss_frame(wiphy, channel, mgmt,
-                                               le16_to_cpu
-                                               (notif_bss_info->frame_len),
-                                               signal, GFP_KERNEL))) {
+
+       freq = ieee80211_channel_to_frequency(channel, band->band);
+       notify_channel = ieee80211_get_channel(wiphy, freq);
+
+       notify_timestamp = jiffies_to_msecs(jiffies)*1000; /* uSec */
+       notify_capability = le16_to_cpu(bi->capability);
+       notify_interval = le16_to_cpu(bi->beacon_period);
+       notify_ie = (u8 *)bi + le16_to_cpu(bi->ie_offset);
+       notify_ielen = le16_to_cpu(bi->ie_length);
+       notify_signal = (s16)le16_to_cpu(bi->RSSI) * 100;
+
+       WL_CONN("bssid: %2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n",
+                       bi->BSSID[0], bi->BSSID[1], bi->BSSID[2],
+                       bi->BSSID[3], bi->BSSID[4], bi->BSSID[5]);
+       WL_CONN("Channel: %d(%d)\n", channel, freq);
+       WL_CONN("Capability: %X\n", notify_capability);
+       WL_CONN("Beacon interval: %d\n", notify_interval);
+       WL_CONN("Signal: %d\n", notify_signal);
+       WL_CONN("notify_timestamp: %#018llx\n", notify_timestamp);
+
+       bss = cfg80211_inform_bss(wiphy, notify_channel, (const u8 *)bi->BSSID,
+               notify_timestamp, notify_capability, notify_interval, notify_ie,
+               notify_ielen, notify_signal, GFP_KERNEL);
+
+       if (unlikely(!bss)) {
                WL_ERR("cfg80211_inform_bss_frame error\n");
-               kfree(notif_bss_info);
                return -EINVAL;
        }
-       kfree(notif_bss_info);
+
+       return err;
+}
+
+static s32
+wl_inform_ibss(struct wl_priv *wl, struct net_device *dev, const u8 *bssid)
+{
+       struct wiphy *wiphy = wl_to_wiphy(wl);
+       struct ieee80211_channel *notify_channel;
+       struct wl_bss_info *bi = NULL;
+       struct ieee80211_supported_band *band;
+       u8 *buf = NULL;
+       s32 err = 0;
+       u16 channel;
+       u32 freq;
+       u64 notify_timestamp;
+       u16 notify_capability;
+       u16 notify_interval;
+       u8 *notify_ie;
+       size_t notify_ielen;
+       s32 notify_signal;
+
+       WL_TRACE("Enter\n");
+
+       buf = kzalloc(WL_BSS_INFO_MAX, GFP_KERNEL);
+       if (buf == NULL) {
+               WL_ERR("kzalloc() failed\n");
+               err = -ENOMEM;
+               goto CleanUp;
+       }
+
+       *(u32 *)buf = cpu_to_le32(WL_BSS_INFO_MAX);
+
+       err = wl_dev_ioctl(dev, WLC_GET_BSS_INFO, buf, WL_BSS_INFO_MAX);
+       if (unlikely(err)) {
+               WL_ERR("WLC_GET_BSS_INFO failed: %d\n", err);
+               goto CleanUp;
+       }
+
+       bi = (wl_bss_info_t *)(buf + 4);
+
+       channel = bi->ctl_ch ? bi->ctl_ch :
+                               CHSPEC_CHANNEL(le16_to_cpu(bi->chanspec));
+
+       if (channel <= CH_MAX_2G_CHANNEL)
+               band = wiphy->bands[IEEE80211_BAND_2GHZ];
+       else
+               band = wiphy->bands[IEEE80211_BAND_5GHZ];
+
+       freq = ieee80211_channel_to_frequency(channel, band->band);
+       notify_channel = ieee80211_get_channel(wiphy, freq);
+
+       notify_timestamp = jiffies_to_msecs(jiffies)*1000; /* uSec */
+       notify_capability = le16_to_cpu(bi->capability);
+       notify_interval = le16_to_cpu(bi->beacon_period);
+       notify_ie = (u8 *)bi + le16_to_cpu(bi->ie_offset);
+       notify_ielen = le16_to_cpu(bi->ie_length);
+       notify_signal = (s16)le16_to_cpu(bi->RSSI) * 100;
+
+       WL_CONN("channel: %d(%d)\n", channel, freq);
+       WL_CONN("capability: %X\n", notify_capability);
+       WL_CONN("beacon interval: %d\n", notify_interval);
+       WL_CONN("signal: %d\n", notify_signal);
+       WL_CONN("notify_timestamp: %#018llx\n", notify_timestamp);
+
+       cfg80211_inform_bss(wiphy, notify_channel, bssid,
+               notify_timestamp, notify_capability, notify_interval,
+               notify_ie, notify_ielen, notify_signal, GFP_KERNEL);
+
+CleanUp:
+
+       kfree(buf);
+
+       WL_TRACE("Exit\n");
 
        return err;
 }
@@ -2335,17 +2559,12 @@ static s32 wl_inform_single_bss(struct wl_priv *wl, struct wl_bss_info *bi)
 static bool wl_is_linkup(struct wl_priv *wl, const wl_event_msg_t *e)
 {
        u32 event = be32_to_cpu(e->event_type);
-       u16 flags = be16_to_cpu(e->flags);
+       u32 status = be32_to_cpu(e->status);
 
-       if (event == WLC_E_LINK) {
-               if (flags & WLC_EVENT_MSG_LINK) {
-                       if (wl_is_ibssmode(wl)) {
-                               if (wl_is_ibssstarter(wl)) {
-                               }
-                       } else {
-                               return true;
-                       }
-               }
+       if (event == WLC_E_SET_SSID && status == WLC_E_STATUS_SUCCESS) {
+               WL_CONN("Processing set ssid\n");
+               wl->link_up = true;
+               return true;
        }
 
        return false;
@@ -2356,13 +2575,10 @@ static bool wl_is_linkdown(struct wl_priv *wl, const wl_event_msg_t *e)
        u32 event = be32_to_cpu(e->event_type);
        u16 flags = be16_to_cpu(e->flags);
 
-       if (event == WLC_E_DEAUTH_IND || event == WLC_E_DISASSOC_IND) {
+       if (event == WLC_E_LINK && (!(flags & WLC_EVENT_MSG_LINK))) {
+               WL_CONN("Processing link down\n");
                return true;
-       } else if (event == WLC_E_LINK) {
-               if (!(flags & WLC_EVENT_MSG_LINK))
-                       return true;
        }
-
        return false;
 }
 
@@ -2370,10 +2586,17 @@ static bool wl_is_nonetwork(struct wl_priv *wl, const wl_event_msg_t *e)
 {
        u32 event = be32_to_cpu(e->event_type);
        u32 status = be32_to_cpu(e->status);
+       u16 flags = be16_to_cpu(e->flags);
 
-       if (event == WLC_E_SET_SSID || event == WLC_E_LINK) {
-               if (status == WLC_E_STATUS_NO_NETWORKS)
-                       return true;
+       if (event == WLC_E_LINK && status == WLC_E_STATUS_NO_NETWORKS) {
+               WL_CONN("Processing Link %s & no network found\n",
+                               flags & WLC_EVENT_MSG_LINK ? "up" : "down");
+               return true;
+       }
+
+       if (event == WLC_E_SET_SSID && status != WLC_E_STATUS_SUCCESS) {
+               WL_CONN("Processing connecting & no network found\n");
+               return true;
        }
 
        return false;
@@ -2383,30 +2606,39 @@ static s32
 wl_notify_connect_status(struct wl_priv *wl, struct net_device *ndev,
                         const wl_event_msg_t *e, void *data)
 {
-       bool act;
        s32 err = 0;
 
        if (wl_is_linkup(wl, e)) {
-               wl_link_up(wl);
+               WL_CONN("Linkup\n");
                if (wl_is_ibssmode(wl)) {
-                       cfg80211_ibss_joined(ndev, (s8 *)&e->addr,
-                                            GFP_KERNEL);
-                       WL_DBG("joined in IBSS network\n");
-               } else {
+                       wl_update_prof(wl, NULL, (void *)e->addr,
+                               WL_PROF_BSSID);
+                       wl_inform_ibss(wl, ndev, e->addr);
+                       cfg80211_ibss_joined(ndev, e->addr, GFP_KERNEL);
+                       clear_bit(WL_STATUS_CONNECTING, &wl->status);
+                       set_bit(WL_STATUS_CONNECTED, &wl->status);
+               } else
                        wl_bss_connect_done(wl, ndev, e, data, true);
-                       WL_DBG("joined in BSS network \"%s\"\n",
-                              ((struct wlc_ssid *)
-                               wl_read_prof(wl, WL_PROF_SSID))->SSID);
-               }
-               act = true;
-               wl_update_prof(wl, e, &act, WL_PROF_ACT);
        } else if (wl_is_linkdown(wl, e)) {
-               cfg80211_disconnected(ndev, 0, NULL, 0, GFP_KERNEL);
-               clear_bit(WL_STATUS_CONNECTED, &wl->status);
-               wl_link_down(wl);
+               WL_CONN("Linkdown\n");
+               if (wl_is_ibssmode(wl)) {
+                       if (test_and_clear_bit(WL_STATUS_CONNECTED,
+                               &wl->status))
+                               wl_link_down(wl);
+               } else {
+                       if (test_and_clear_bit(WL_STATUS_CONNECTED,
+                               &wl->status)) {
+                               cfg80211_disconnected(ndev, 0, NULL, 0,
+                                       GFP_KERNEL);
+                               wl_link_down(wl);
+                       }
+               }
                wl_init_prof(wl->profile);
        } else if (wl_is_nonetwork(wl, e)) {
-               wl_bss_connect_done(wl, ndev, e, data, false);
+               if (wl_is_ibssmode(wl))
+                       clear_bit(WL_STATUS_CONNECTING, &wl->status);
+               else
+                       wl_bss_connect_done(wl, ndev, e, data, false);
        }
 
        return err;
@@ -2416,12 +2648,16 @@ static s32
 wl_notify_roaming_status(struct wl_priv *wl, struct net_device *ndev,
                         const wl_event_msg_t *e, void *data)
 {
-       bool act;
        s32 err = 0;
+       u32 event = be32_to_cpu(e->event_type);
+       u32 status = be32_to_cpu(e->status);
 
-       wl_bss_roaming_done(wl, ndev, e, data);
-       act = true;
-       wl_update_prof(wl, e, &act, WL_PROF_ACT);
+       if (event == WLC_E_ROAM && status == WLC_E_STATUS_SUCCESS) {
+               if (test_bit(WL_STATUS_CONNECTED, &wl->status))
+                       wl_bss_roaming_done(wl, ndev, e, data);
+               else
+                       wl_bss_connect_done(wl, ndev, e, data, true);
+       }
 
        return err;
 }
@@ -2468,6 +2704,8 @@ static s32 wl_get_assoc_ies(struct wl_priv *wl)
        u32 resp_len;
        s32 err = 0;
 
+       wl_clear_assoc_ies(wl);
+
        err = wl_dev_bufvar_get(ndev, "assoc_info", wl->extra_buf,
                                WL_ASSOC_INFO_MAX);
        if (unlikely(err)) {
@@ -2505,12 +2743,25 @@ static s32 wl_get_assoc_ies(struct wl_priv *wl)
                conn_info->resp_ie_len = 0;
                conn_info->resp_ie = NULL;
        }
-       WL_DBG("req len (%d) resp len (%d)\n",
+       WL_CONN("req len (%d) resp len (%d)\n",
               conn_info->req_ie_len, conn_info->resp_ie_len);
 
        return err;
 }
 
+static void wl_clear_assoc_ies(struct wl_priv *wl)
+{
+       struct wl_connect_info *conn_info = wl_to_conn(wl);
+
+       kfree(conn_info->req_ie);
+       conn_info->req_ie = NULL;
+       conn_info->req_ie_len = 0;
+       kfree(conn_info->resp_ie);
+       conn_info->resp_ie = NULL;
+       conn_info->resp_ie_len = 0;
+}
+
+
 static void wl_ch_to_chanspec(int ch, struct wl_join_params *join_params,
        size_t *join_params_size)
 {
@@ -2520,7 +2771,7 @@ static void wl_ch_to_chanspec(int ch, struct wl_join_params *join_params,
                join_params->params.chanspec_num = 1;
                join_params->params.chanspec_list[0] = ch;
 
-               if (join_params->params.chanspec_list[0])
+               if (join_params->params.chanspec_list[0] <= CH_MAX_2G_CHANNEL)
                        chanspec |= WL_CHANSPEC_BAND_2G;
                else
                        chanspec |= WL_CHANSPEC_BAND_5G;
@@ -2539,14 +2790,14 @@ static void wl_ch_to_chanspec(int ch, struct wl_join_params *join_params,
                join_params->params.chanspec_num =
                        cpu_to_le32(join_params->params.chanspec_num);
 
-               WL_DBG("join_params->params.chanspec_list[0]= %#X, channel %d, chanspec %#X\n",
+               WL_CONN("join_params->params.chanspec_list[0]= %#X,"
+                       "channel %d, chanspec %#X\n",
                       join_params->params.chanspec_list[0], ch, chanspec);
        }
 }
 
 static s32 wl_update_bss_info(struct wl_priv *wl)
 {
-       struct cfg80211_bss *bss;
        struct wl_bss_info *bi;
        struct wlc_ssid *ssid;
        struct bcm_tlv *tim;
@@ -2556,67 +2807,52 @@ static s32 wl_update_bss_info(struct wl_priv *wl)
        u8 *ie;
        s32 err = 0;
 
+       WL_TRACE("Enter\n");
        if (wl_is_ibssmode(wl))
                return err;
 
        ssid = (struct wlc_ssid *)wl_read_prof(wl, WL_PROF_SSID);
-       bss =
-           cfg80211_get_bss(wl_to_wiphy(wl), NULL, (s8 *)&wl->bssid,
-                            ssid->SSID, ssid->SSID_len, WLAN_CAPABILITY_ESS,
-                            WLAN_CAPABILITY_ESS);
 
-       rtnl_lock();
-       if (unlikely(!bss)) {
-               WL_DBG("Could not find the AP\n");
-               *(u32 *) wl->extra_buf = cpu_to_le32(WL_EXTRA_BUF_MAX);
-               err = wl_dev_ioctl(wl_to_ndev(wl), WLC_GET_BSS_INFO,
-                               wl->extra_buf, WL_EXTRA_BUF_MAX);
-               if (unlikely(err)) {
-                       WL_ERR("Could not get bss info %d\n", err);
-                       goto update_bss_info_out;
-               }
-               bi = (struct wl_bss_info *)(wl->extra_buf + 4);
-               if (unlikely(memcmp(&bi->BSSID, &wl->bssid, ETH_ALEN))) {
-                       err = -EIO;
-                       goto update_bss_info_out;
-               }
-               err = wl_inform_single_bss(wl, bi);
-               if (unlikely(err))
-                       goto update_bss_info_out;
-
-               ie = ((u8 *)bi) + bi->ie_offset;
-               ie_len = bi->ie_length;
-               beacon_interval = cpu_to_le16(bi->beacon_period);
-       } else {
-               WL_DBG("Found the AP in the list - BSSID %pM\n", bss->bssid);
-               ie = bss->information_elements;
-               ie_len = bss->len_information_elements;
-               beacon_interval = bss->beacon_interval;
-               cfg80211_put_bss(bss);
+       *(u32 *)wl->extra_buf = cpu_to_le32(WL_EXTRA_BUF_MAX);
+       err = wl_dev_ioctl(wl_to_ndev(wl), WLC_GET_BSS_INFO,
+                       wl->extra_buf, WL_EXTRA_BUF_MAX);
+       if (unlikely(err)) {
+               WL_ERR("Could not get bss info %d\n", err);
+               goto update_bss_info_out;
        }
 
+       bi = (struct wl_bss_info *)(wl->extra_buf + 4);
+       err = wl_inform_single_bss(wl, bi);
+       if (unlikely(err))
+               goto update_bss_info_out;
+
+       ie = ((u8 *)bi) + bi->ie_offset;
+       ie_len = bi->ie_length;
+       beacon_interval = cpu_to_le16(bi->beacon_period);
+
        tim = bcm_parse_tlvs(ie, ie_len, WLAN_EID_TIM);
-       if (tim) {
+       if (tim)
                dtim_period = tim->data[1];
-       else {
+       else {
                /*
                * active scan was done so we could not get dtim
                * information out of probe response.
                * so we speficially query dtim information to dongle.
                */
-               err = wl_dev_ioctl(wl_to_ndev(wl), WLC_GET_DTIMPRD,
-                       &dtim_period, sizeof(dtim_period));
+               u32 var;
+               err = wl_dev_intvar_get(wl_to_ndev(wl), "dtim_assoc", &var);
                if (unlikely(err)) {
-                       WL_ERR("WLC_GET_DTIMPRD error (%d)\n", err);
+                       WL_ERR("wl dtim_assoc failed (%d)\n", err);
                        goto update_bss_info_out;
                }
+               dtim_period = (u8)var;
        }
 
        wl_update_prof(wl, NULL, &beacon_interval, WL_PROF_BEACONINT);
        wl_update_prof(wl, NULL, &dtim_period, WL_PROF_DTIMPERIOD);
 
 update_bss_info_out:
-       rtnl_unlock();
+       WL_TRACE("Exit");
        return err;
 }
 
@@ -2627,17 +2863,20 @@ wl_bss_roaming_done(struct wl_priv *wl, struct net_device *ndev,
        struct wl_connect_info *conn_info = wl_to_conn(wl);
        s32 err = 0;
 
+       WL_TRACE("Enter\n");
+
        wl_get_assoc_ies(wl);
-       memcpy(&wl->bssid, &e->addr, ETH_ALEN);
+       wl_update_prof(wl, NULL, &e->addr, WL_PROF_BSSID);
        wl_update_bss_info(wl);
+
        cfg80211_roamed(ndev,
-                       (u8 *)&wl->bssid,
+                       (u8 *)wl_read_prof(wl, WL_PROF_BSSID),
                        conn_info->req_ie, conn_info->req_ie_len,
                        conn_info->resp_ie, conn_info->resp_ie_len, GFP_KERNEL);
-       WL_DBG("Report roaming result\n");
+       WL_CONN("Report roaming result\n");
 
        set_bit(WL_STATUS_CONNECTED, &wl->status);
-
+       WL_TRACE("Exit\n");
        return err;
 }
 
@@ -2648,30 +2887,28 @@ wl_bss_connect_done(struct wl_priv *wl, struct net_device *ndev,
        struct wl_connect_info *conn_info = wl_to_conn(wl);
        s32 err = 0;
 
-       wl_get_assoc_ies(wl);
-       memcpy(&wl->bssid, &e->addr, ETH_ALEN);
-       wl_update_bss_info(wl);
+       WL_TRACE("Enter\n");
+
        if (test_and_clear_bit(WL_STATUS_CONNECTING, &wl->status)) {
+               if (completed) {
+                       wl_get_assoc_ies(wl);
+                       wl_update_prof(wl, NULL, &e->addr, WL_PROF_BSSID);
+                       wl_update_bss_info(wl);
+               }
                cfg80211_connect_result(ndev,
-                                       (u8 *)&wl->bssid,
+                                       (u8 *)wl_read_prof(wl, WL_PROF_BSSID),
                                        conn_info->req_ie,
                                        conn_info->req_ie_len,
                                        conn_info->resp_ie,
                                        conn_info->resp_ie_len,
                                        completed ? WLAN_STATUS_SUCCESS : WLAN_STATUS_AUTH_TIMEOUT,
                                        GFP_KERNEL);
-               WL_DBG("Report connect result - connection %s\n",
-                      completed ? "succeeded" : "failed");
-       } else {
-               cfg80211_roamed(ndev,
-                               (u8 *)&wl->bssid,
-                               conn_info->req_ie, conn_info->req_ie_len,
-                               conn_info->resp_ie, conn_info->resp_ie_len,
-                               GFP_KERNEL);
-               WL_DBG("Report roaming result\n");
+               if (completed)
+                       set_bit(WL_STATUS_CONNECTED, &wl->status);
+               WL_CONN("Report connect result - connection %s\n",
+                               completed ? "succeeded" : "failed");
        }
-       set_bit(WL_STATUS_CONNECTED, &wl->status);
-
+       WL_TRACE("Exit\n");
        return err;
 }
 
@@ -2703,37 +2940,45 @@ wl_notify_scan_status(struct wl_priv *wl, struct net_device *ndev,
        struct wl_scan_results *bss_list;
        u32 len = WL_SCAN_BUF_MAX;
        s32 err = 0;
+       bool scan_abort = false;
+
+       WL_TRACE("Enter\n");
 
-       if (wl->iscan_on && wl->iscan_kickstart)
+       if (wl->iscan_on && wl->iscan_kickstart) {
+               WL_TRACE("Exit\n");
                return wl_wakeup_iscan(wl_to_iscan(wl));
+       }
 
        if (unlikely(!test_and_clear_bit(WL_STATUS_SCANNING, &wl->status))) {
                WL_ERR("Scan complete while device not scanning\n");
-               return -EINVAL;
-       }
-       if (unlikely(!wl->scan_request)) {
+               scan_abort = true;
+               err = -EINVAL;
+               goto scan_done_out;
        }
-       rtnl_lock();
+
        err = wl_dev_ioctl(ndev, WLC_GET_CHANNEL, &channel_inform,
                        sizeof(channel_inform));
        if (unlikely(err)) {
                WL_ERR("scan busy (%d)\n", err);
+               scan_abort = true;
                goto scan_done_out;
        }
        channel_inform.scan_channel = le32_to_cpu(channel_inform.scan_channel);
        if (unlikely(channel_inform.scan_channel)) {
 
-               WL_DBG("channel_inform.scan_channel (%d)\n",
+               WL_CONN("channel_inform.scan_channel (%d)\n",
                       channel_inform.scan_channel);
        }
        wl->bss_list = wl->scan_results;
        bss_list = wl->bss_list;
        memset(bss_list, 0, len);
        bss_list->buflen = cpu_to_le32(len);
+
        err = wl_dev_ioctl(ndev, WLC_SCAN_RESULTS, bss_list, len);
        if (unlikely(err)) {
                WL_ERR("%s Scan_results error (%d)\n", ndev->name, err);
                err = -EINVAL;
+               scan_abort = true;
                goto scan_done_out;
        }
        bss_list->buflen = le32_to_cpu(bss_list->buflen);
@@ -2741,16 +2986,21 @@ wl_notify_scan_status(struct wl_priv *wl, struct net_device *ndev,
        bss_list->count = le32_to_cpu(bss_list->count);
 
        err = wl_inform_bss(wl);
-       if (err)
+       if (err) {
+               scan_abort = true;
                goto scan_done_out;
+       }
 
 scan_done_out:
        if (wl->scan_request) {
-               cfg80211_scan_done(wl->scan_request, false);
+               WL_SCAN("calling cfg80211_scan_done\n");
+               cfg80211_scan_done(wl->scan_request, scan_abort);
                wl_set_mpc(ndev, 1);
                wl->scan_request = NULL;
        }
-       rtnl_unlock();
+
+       WL_TRACE("Exit\n");
+
        return err;
 }
 
@@ -2773,12 +3023,7 @@ static void wl_init_eloop_handler(struct wl_event_loop *el)
 {
        memset(el, 0, sizeof(*el));
        el->handler[WLC_E_SCAN_COMPLETE] = wl_notify_scan_status;
-       el->handler[WLC_E_JOIN] = wl_notify_connect_status;
        el->handler[WLC_E_LINK] = wl_notify_connect_status;
-       el->handler[WLC_E_DEAUTH_IND] = wl_notify_connect_status;
-       el->handler[WLC_E_DISASSOC_IND] = wl_notify_connect_status;
-       el->handler[WLC_E_ASSOC_IND] = wl_notify_connect_status;
-       el->handler[WLC_E_REASSOC_IND] = wl_notify_connect_status;
        el->handler[WLC_E_ROAM] = wl_notify_roaming_status;
        el->handler[WLC_E_MIC_ERROR] = wl_notify_mic_status;
        el->handler[WLC_E_SET_SSID] = wl_notify_connect_status;
@@ -2912,6 +3157,8 @@ static void wl_notify_iscan_complete(struct wl_iscan_ctrl *iscan, bool aborted)
                return;
        }
        if (likely(wl->scan_request)) {
+               WL_SCAN("ISCAN Completed scan: %s\n",
+                               aborted ? "Aborted" : "Done");
                cfg80211_scan_done(wl->scan_request, aborted);
                wl_set_mpc(ndev, 1);
                wl->scan_request = NULL;
@@ -2922,7 +3169,7 @@ static void wl_notify_iscan_complete(struct wl_iscan_ctrl *iscan, bool aborted)
 static s32 wl_wakeup_iscan(struct wl_iscan_ctrl *iscan)
 {
        if (likely(iscan->state != WL_ISCAN_STATE_IDLE)) {
-               WL_DBG("wake up iscan\n");
+               WL_SCAN("wake up iscan\n");
                up(&iscan->sync);
                return 0;
        }
@@ -2958,8 +3205,8 @@ wl_get_iscan_results(struct wl_iscan_ctrl *iscan, u32 *status,
        results->buflen = le32_to_cpu(results->buflen);
        results->version = le32_to_cpu(results->version);
        results->count = le32_to_cpu(results->count);
-       WL_DBG("results->count = %d\n", results->count);
-       WL_DBG("results->buflen = %d\n", results->buflen);
+       WL_SCAN("results->count = %d\n", results->count);
+       WL_SCAN("results->buflen = %d\n", results->buflen);
        *status = le32_to_cpu(list_buf->status);
        *bss_list = results;
 
@@ -3053,7 +3300,7 @@ static s32 wl_iscan_thread(void *data)
                del_timer_sync(&iscan->timer);
                iscan->timer_on = 0;
        }
-       WL_DBG("%s was terminated\n", __func__);
+       WL_SCAN("ISCAN thread terminated\n");
 
        return 0;
 }
@@ -3064,7 +3311,7 @@ static void wl_iscan_timer(unsigned long data)
 
        if (iscan) {
                iscan->timer_on = 0;
-               WL_DBG("timer expired\n");
+               WL_SCAN("timer expired\n");
                wl_wakeup_iscan(iscan);
        }
 }
@@ -3191,7 +3438,7 @@ s32 wl_cfg80211_attach(struct net_device *ndev, void *data)
                WL_ERR("wl_cfg80211_dev is invalid\n");
                return -ENOMEM;
        }
-       WL_DBG("func %p\n", wl_cfg80211_get_sdio_func());
+       WL_INFO("func %p\n", wl_cfg80211_get_sdio_func());
        wdev = wl_alloc_wdev(sizeof(struct wl_iface), &wl_cfg80211_get_sdio_func()->dev);
        if (IS_ERR(wdev))
                return -ENOMEM;
@@ -3211,7 +3458,6 @@ s32 wl_cfg80211_attach(struct net_device *ndev, void *data)
                goto cfg80211_attach_out;
        }
        wl_set_drvdata(wl_cfg80211_dev, ci);
-       set_bit(WL_STATUS_READY, &wl->status);
 
        return err;
 
@@ -3255,16 +3501,16 @@ static s32 wl_event_handler(void *data)
                        WL_ERR("event queue empty...\n");
                        BUG();
                }
-               WL_DBG("event type (%d)\n", e->etype);
+               WL_INFO("event type (%d)\n", e->etype);
                if (wl->el.handler[e->etype]) {
                        wl->el.handler[e->etype] (wl, wl_to_ndev(wl), &e->emsg,
                                                  e->edata);
                } else {
-                       WL_DBG("Unknown Event (%d): ignoring\n", e->etype);
+                       WL_INFO("Unknown Event (%d): ignoring\n", e->etype);
                }
                wl_put_event(e);
        }
-       WL_DBG("%s was terminated\n", __func__);
+       WL_INFO("was terminated\n");
        return 0;
 }
 
@@ -3273,11 +3519,7 @@ wl_cfg80211_event(struct net_device *ndev, const wl_event_msg_t * e, void *data)
 {
        u32 event_type = be32_to_cpu(e->event_type);
        struct wl_priv *wl = ndev_to_wl(ndev);
-#if (WL_DBG_LEVEL > 0)
-       s8 *estr = (event_type <= sizeof(wl_dbg_estr) / WL_DBG_ESTR_MAX - 1) ?
-           wl_dbg_estr[event_type] : (s8 *) "Unknown";
-#endif                         /* (WL_DBG_LEVEL > 0) */
-       WL_DBG("event_type (%d):" "WLC_E_" "%s\n", event_type, estr);
+
        if (likely(!wl_enq_event(wl, event_type, e, data)))
                wl_wakeup_event(wl);
 }
@@ -3370,7 +3612,6 @@ struct sdio_func *wl_cfg80211_get_sdio_func(void)
 static s32 wl_dongle_mode(struct net_device *ndev, s32 iftype)
 {
        s32 infra = 0;
-       s32 ap = 0;
        s32 err = 0;
 
        switch (iftype) {
@@ -3381,6 +3622,7 @@ static s32 wl_dongle_mode(struct net_device *ndev, s32 iftype)
                err = -EINVAL;
                return err;
        case NL80211_IFTYPE_ADHOC:
+               infra = 0;
                break;
        case NL80211_IFTYPE_STATION:
                infra = 1;
@@ -3391,20 +3633,13 @@ static s32 wl_dongle_mode(struct net_device *ndev, s32 iftype)
                return err;
        }
        infra = cpu_to_le32(infra);
-       ap = cpu_to_le32(ap);
-       WL_DBG("%s ap (%d), infra (%d)\n", ndev->name, ap, infra);
        err = wl_dev_ioctl(ndev, WLC_SET_INFRA, &infra, sizeof(infra));
        if (unlikely(err)) {
                WL_ERR("WLC_SET_INFRA error (%d)\n", err);
                return err;
        }
-       err = wl_dev_ioctl(ndev, WLC_SET_AP, &ap, sizeof(ap));
-       if (unlikely(err)) {
-               WL_ERR("WLC_SET_AP error (%d)\n", err);
-               return err;
-       }
 
-       return -EINPROGRESS;
+       return 0;
 }
 
 #ifndef EMBEDDED_PLATFORM
@@ -3464,116 +3699,6 @@ dongle_glom_out:
        return err;
 }
 
-static s32
-wl_dongle_roam(struct net_device *ndev, u32 roamvar, u32 bcn_timeout)
-{
-       s8 iovbuf[WL_EVENTING_MASK_LEN + 12];   /*  Room for "event_msgs" +
-                                                '\0' + bitvec  */
-       s32 err = 0;
-
-       /* Setup timeout if Beacons are lost and roam is
-                off to report link down */
-       if (roamvar) {
-               bcm_mkiovar("bcn_timeout", (char *)&bcn_timeout, 4, iovbuf,
-                           sizeof(iovbuf));
-               err = wl_dev_ioctl(ndev, WLC_SET_VAR, iovbuf, sizeof(iovbuf));
-               if (unlikely(err)) {
-                       WL_ERR("bcn_timeout error (%d)\n", err);
-                       goto dongle_rom_out;
-               }
-       }
-       /* Enable/Disable built-in roaming to allow supplicant
-                to take care of roaming */
-       bcm_mkiovar("roam_off", (char *)&roamvar, 4, iovbuf, sizeof(iovbuf));
-       err = wl_dev_ioctl(ndev, WLC_SET_VAR, iovbuf, sizeof(iovbuf));
-       if (unlikely(err)) {
-               WL_ERR("roam_off error (%d)\n", err);
-               goto dongle_rom_out;
-       }
-dongle_rom_out:
-       return err;
-}
-
-static s32 wl_dongle_eventmsg(struct net_device *ndev)
-{
-
-       s8 iovbuf[WL_EVENTING_MASK_LEN + 12];   /*  Room for "event_msgs" +
-                                                '\0' + bitvec  */
-       s8 eventmask[WL_EVENTING_MASK_LEN];
-       s32 err = 0;
-
-       /* Setup event_msgs */
-       bcm_mkiovar("event_msgs", eventmask, WL_EVENTING_MASK_LEN, iovbuf,
-                   sizeof(iovbuf));
-       err = wl_dev_ioctl(ndev, WLC_GET_VAR, iovbuf, sizeof(iovbuf));
-       if (unlikely(err)) {
-               WL_ERR("Get event_msgs error (%d)\n", err);
-               goto dongle_eventmsg_out;
-       }
-       memcpy(eventmask, iovbuf, WL_EVENTING_MASK_LEN);
-
-       setbit(eventmask, WLC_E_SET_SSID);
-       setbit(eventmask, WLC_E_PRUNE);
-       setbit(eventmask, WLC_E_AUTH);
-       setbit(eventmask, WLC_E_REASSOC);
-       setbit(eventmask, WLC_E_REASSOC_IND);
-       setbit(eventmask, WLC_E_DEAUTH_IND);
-       setbit(eventmask, WLC_E_DISASSOC_IND);
-       setbit(eventmask, WLC_E_DISASSOC);
-       setbit(eventmask, WLC_E_JOIN);
-       setbit(eventmask, WLC_E_ASSOC_IND);
-       setbit(eventmask, WLC_E_PSK_SUP);
-       setbit(eventmask, WLC_E_LINK);
-       setbit(eventmask, WLC_E_NDIS_LINK);
-       setbit(eventmask, WLC_E_MIC_ERROR);
-       setbit(eventmask, WLC_E_PMKID_CACHE);
-       setbit(eventmask, WLC_E_TXFAIL);
-       setbit(eventmask, WLC_E_JOIN_START);
-       setbit(eventmask, WLC_E_SCAN_COMPLETE);
-
-       bcm_mkiovar("event_msgs", eventmask, WL_EVENTING_MASK_LEN, iovbuf,
-                   sizeof(iovbuf));
-       err = wl_dev_ioctl(ndev, WLC_SET_VAR, iovbuf, sizeof(iovbuf));
-       if (unlikely(err)) {
-               WL_ERR("Set event_msgs error (%d)\n", err);
-               goto dongle_eventmsg_out;
-       }
-
-dongle_eventmsg_out:
-       return err;
-}
-
-static s32
-wl_dongle_scantime(struct net_device *ndev, s32 scan_assoc_time,
-                  s32 scan_unassoc_time)
-{
-       s32 err = 0;
-
-       err = wl_dev_ioctl(ndev, WLC_SET_SCAN_CHANNEL_TIME, &scan_assoc_time,
-                       sizeof(scan_assoc_time));
-       if (err) {
-               if (err == -EOPNOTSUPP) {
-                       WL_INFO("Scan assoc time is not supported\n");
-               } else {
-                       WL_ERR("Scan assoc time error (%d)\n", err);
-               }
-               goto dongle_scantime_out;
-       }
-       err = wl_dev_ioctl(ndev, WLC_SET_SCAN_UNASSOC_TIME, &scan_unassoc_time,
-                       sizeof(scan_unassoc_time));
-       if (err) {
-               if (err == -EOPNOTSUPP) {
-                       WL_INFO("Scan unassoc time is not supported\n");
-               } else {
-                       WL_ERR("Scan unassoc time error (%d)\n", err);
-               }
-               goto dongle_scantime_out;
-       }
-
-dongle_scantime_out:
-       return err;
-}
-
 static s32
 wl_dongle_offload(struct net_device *ndev, s32 arpoe, s32 arp_ol)
 {
@@ -3722,6 +3847,154 @@ dongle_filter_out:
 }
 #endif                         /* !EMBEDDED_PLATFORM */
 
+static s32 wl_dongle_eventmsg(struct net_device *ndev)
+{
+       s8 iovbuf[WL_EVENTING_MASK_LEN + 12];   /*  Room for "event_msgs" +
+                                                '\0' + bitvec  */
+       s8 eventmask[WL_EVENTING_MASK_LEN];
+       s32 err = 0;
+
+       WL_TRACE("Enter\n");
+
+       /* Setup event_msgs */
+       bcm_mkiovar("event_msgs", eventmask, WL_EVENTING_MASK_LEN, iovbuf,
+                   sizeof(iovbuf));
+       err = wl_dev_ioctl(ndev, WLC_GET_VAR, iovbuf, sizeof(iovbuf));
+       if (unlikely(err)) {
+               WL_ERR("Get event_msgs error (%d)\n", err);
+               goto dongle_eventmsg_out;
+       }
+       memcpy(eventmask, iovbuf, WL_EVENTING_MASK_LEN);
+
+       setbit(eventmask, WLC_E_SET_SSID);
+       setbit(eventmask, WLC_E_ROAM);
+       setbit(eventmask, WLC_E_PRUNE);
+       setbit(eventmask, WLC_E_AUTH);
+       setbit(eventmask, WLC_E_REASSOC);
+       setbit(eventmask, WLC_E_REASSOC_IND);
+       setbit(eventmask, WLC_E_DEAUTH_IND);
+       setbit(eventmask, WLC_E_DISASSOC_IND);
+       setbit(eventmask, WLC_E_DISASSOC);
+       setbit(eventmask, WLC_E_JOIN);
+       setbit(eventmask, WLC_E_ASSOC_IND);
+       setbit(eventmask, WLC_E_PSK_SUP);
+       setbit(eventmask, WLC_E_LINK);
+       setbit(eventmask, WLC_E_NDIS_LINK);
+       setbit(eventmask, WLC_E_MIC_ERROR);
+       setbit(eventmask, WLC_E_PMKID_CACHE);
+       setbit(eventmask, WLC_E_TXFAIL);
+       setbit(eventmask, WLC_E_JOIN_START);
+       setbit(eventmask, WLC_E_SCAN_COMPLETE);
+
+       bcm_mkiovar("event_msgs", eventmask, WL_EVENTING_MASK_LEN, iovbuf,
+                   sizeof(iovbuf));
+       err = wl_dev_ioctl(ndev, WLC_SET_VAR, iovbuf, sizeof(iovbuf));
+       if (unlikely(err)) {
+               WL_ERR("Set event_msgs error (%d)\n", err);
+               goto dongle_eventmsg_out;
+       }
+
+dongle_eventmsg_out:
+       WL_TRACE("Exit\n");
+       return err;
+}
+
+static s32
+wl_dongle_roam(struct net_device *ndev, u32 roamvar, u32 bcn_timeout)
+{
+       s8 iovbuf[32];
+       s32 roamtrigger[2];
+       s32 roam_delta[2];
+       s32 err = 0;
+
+       /*
+        * Setup timeout if Beacons are lost and roam is
+        * off to report link down
+        */
+       if (roamvar) {
+               bcm_mkiovar("bcn_timeout", (char *)&bcn_timeout,
+                       sizeof(bcn_timeout), iovbuf, sizeof(iovbuf));
+               err = wl_dev_ioctl(ndev, WLC_SET_VAR, iovbuf, sizeof(iovbuf));
+               if (unlikely(err)) {
+                       WL_ERR("bcn_timeout error (%d)\n", err);
+                       goto dongle_rom_out;
+               }
+       }
+
+       /*
+        * Enable/Disable built-in roaming to allow supplicant
+        * to take care of roaming
+        */
+       WL_INFO("Internal Roaming = %s\n", roamvar ? "Off" : "On");
+       bcm_mkiovar("roam_off", (char *)&roamvar,
+                               sizeof(roamvar), iovbuf, sizeof(iovbuf));
+       err = wl_dev_ioctl(ndev, WLC_SET_VAR, iovbuf, sizeof(iovbuf));
+       if (unlikely(err)) {
+               WL_ERR("roam_off error (%d)\n", err);
+               goto dongle_rom_out;
+       }
+
+       roamtrigger[0] = WL_ROAM_TRIGGER_LEVEL;
+       roamtrigger[1] = WLC_BAND_ALL;
+       err = wl_dev_ioctl(ndev, WLC_SET_ROAM_TRIGGER,
+                       (void *)roamtrigger, sizeof(roamtrigger));
+       if (unlikely(err)) {
+               WL_ERR("WLC_SET_ROAM_TRIGGER error (%d)\n", err);
+               goto dongle_rom_out;
+       }
+
+       roam_delta[0] = WL_ROAM_DELTA;
+       roam_delta[1] = WLC_BAND_ALL;
+       err = wl_dev_ioctl(ndev, WLC_SET_ROAM_DELTA,
+                               (void *)roam_delta, sizeof(roam_delta));
+       if (unlikely(err)) {
+               WL_ERR("WLC_SET_ROAM_DELTA error (%d)\n", err);
+               goto dongle_rom_out;
+       }
+
+dongle_rom_out:
+       return err;
+}
+
+static s32
+wl_dongle_scantime(struct net_device *ndev, s32 scan_assoc_time,
+               s32 scan_unassoc_time, s32 scan_passive_time)
+{
+       s32 err = 0;
+
+       err = wl_dev_ioctl(ndev, WLC_SET_SCAN_CHANNEL_TIME, &scan_assoc_time,
+                       sizeof(scan_assoc_time));
+       if (err) {
+               if (err == -EOPNOTSUPP)
+                       WL_INFO("Scan assoc time is not supported\n");
+               else
+                       WL_ERR("Scan assoc time error (%d)\n", err);
+               goto dongle_scantime_out;
+       }
+       err = wl_dev_ioctl(ndev, WLC_SET_SCAN_UNASSOC_TIME, &scan_unassoc_time,
+                       sizeof(scan_unassoc_time));
+       if (err) {
+               if (err == -EOPNOTSUPP)
+                       WL_INFO("Scan unassoc time is not supported\n");
+               else
+                       WL_ERR("Scan unassoc time error (%d)\n", err);
+               goto dongle_scantime_out;
+       }
+
+       err = wl_dev_ioctl(ndev, WLC_SET_SCAN_PASSIVE_TIME, &scan_passive_time,
+                       sizeof(scan_passive_time));
+       if (err) {
+               if (err == -EOPNOTSUPP)
+                       WL_INFO("Scan passive time is not supported\n");
+               else
+                       WL_ERR("Scan passive time error (%d)\n", err);
+               goto dongle_scantime_out;
+       }
+
+dongle_scantime_out:
+       return err;
+}
+
 s32 wl_config_dongle(struct wl_priv *wl, bool need_lock)
 {
 #ifndef DHD_SDALIGN
@@ -3750,20 +4023,22 @@ s32 wl_config_dongle(struct wl_priv *wl, bool need_lock)
        if (unlikely(err))
                goto default_conf_out;
        err = wl_dongle_glom(ndev, 0, DHD_SDALIGN);
-       if (unlikely(err))
-               goto default_conf_out;
-       err = wl_dongle_roam(ndev, (wl->roam_on ? 0 : 1), 3);
-       if (unlikely(err))
-               goto default_conf_out;
-       err = wl_dongle_eventmsg(ndev);
        if (unlikely(err))
                goto default_conf_out;
 
-       wl_dongle_scantime(ndev, 40, 80);
        wl_dongle_offload(ndev, 1, 0xf);
        wl_dongle_filter(ndev, 1);
-#endif                         /* !EMBEDDED_PLATFORM */
+#endif /* !EMBEDDED_PLATFORM */
 
+       wl_dongle_scantime(ndev, WL_SCAN_CHANNEL_TIME,
+                       WL_SCAN_UNASSOC_TIME, WL_SCAN_PASSIVE_TIME);
+
+       err = wl_dongle_eventmsg(ndev);
+       if (unlikely(err))
+               goto default_conf_out;
+       err = wl_dongle_roam(ndev, (wl->roam_on ? 0 : 1), WL_BEACON_TIMEOUT);
+       if (unlikely(err))
+               goto default_conf_out;
        err = wl_dongle_mode(ndev, wdev->iftype);
        if (unlikely(err && err != -EINPROGRESS))
                goto default_conf_out;
@@ -3798,7 +4073,7 @@ static s32 wl_update_wiphybands(struct wl_priv *wl)
        }
 
        phy = ((char *)&phy_list)[1];
-       WL_DBG("%c phy\n", phy);
+       WL_INFO("%c phy\n", phy);
        if (phy == 'n' || phy == 'a') {
                wiphy = wl_to_wiphy(wl);
                wiphy->bands[IEEE80211_BAND_5GHZ] = &__wl_band_5ghz_n;
@@ -3811,6 +4086,8 @@ static s32 __wl_cfg80211_up(struct wl_priv *wl)
 {
        s32 err = 0;
 
+       set_bit(WL_STATUS_READY, &wl->status);
+
        wl_debugfs_add_netdev_params(wl);
 
        err = wl_config_dongle(wl, false);
@@ -3818,41 +4095,29 @@ static s32 __wl_cfg80211_up(struct wl_priv *wl)
                return err;
 
        wl_invoke_iscan(wl);
-       set_bit(WL_STATUS_READY, &wl->status);
+
        return err;
 }
 
 static s32 __wl_cfg80211_down(struct wl_priv *wl)
 {
-       s32 err = 0;
-
-       /* Check if cfg80211 interface is already down */
-       if (!test_bit(WL_STATUS_READY, &wl->status))
-               return err;     /* it is even not ready */
-
        set_bit(WL_STATUS_SCAN_ABORTING, &wl->status);
        wl_term_iscan(wl);
        if (wl->scan_request) {
-               cfg80211_scan_done(wl->scan_request, true);     /* true
-                                                                means abort */
-               /* wl_set_mpc(wl_to_ndev(wl), 1); */    /* BUG
-                                               * this operation cannot help
-                                               * but here because sdio
-                                               * is already down through
-                                               * rmmod process.
-                                               * Need to figure out how to
-                                               * address this issue
-                                               */
+               cfg80211_scan_done(wl->scan_request, true);
+               /* May need to perform this to cover rmmod */
+               /* wl_set_mpc(wl_to_ndev(wl), 1); */
                wl->scan_request = NULL;
        }
        clear_bit(WL_STATUS_READY, &wl->status);
        clear_bit(WL_STATUS_SCANNING, &wl->status);
        clear_bit(WL_STATUS_SCAN_ABORTING, &wl->status);
+       clear_bit(WL_STATUS_CONNECTING, &wl->status);
        clear_bit(WL_STATUS_CONNECTED, &wl->status);
 
        wl_debugfs_remove_netdev(wl);
 
-       return err;
+       return 0;
 }
 
 s32 wl_cfg80211_up(void)
@@ -3897,8 +4162,6 @@ static void *wl_read_prof(struct wl_priv *wl, s32 item)
        switch (item) {
        case WL_PROF_SEC:
                return &wl->profile->sec;
-       case WL_PROF_ACT:
-               return &wl->profile->active;
        case WL_PROF_BSSID:
                return &wl->profile->bssid;
        case WL_PROF_SSID:
@@ -3932,9 +4195,6 @@ wl_update_prof(struct wl_priv *wl, const wl_event_msg_t *e, void *data,
        case WL_PROF_SEC:
                memcpy(&wl->profile->sec, data, sizeof(wl->profile->sec));
                break;
-       case WL_PROF_ACT:
-               wl->profile->active = *(bool *)data;
-               break;
        case WL_PROF_BEACONINT:
                wl->profile->beacon_interval = *(u16 *)data;
                break;
@@ -3950,34 +4210,11 @@ wl_update_prof(struct wl_priv *wl, const wl_event_msg_t *e, void *data,
        return err;
 }
 
-void wl_cfg80211_dbg_level(u32 level)
-{
-       /*
-       * prohibit to change debug level
-       * by insmod parameter.
-       * eventually debug level will be configured
-       * in compile time by using CONFIG_XXX
-       */
-       /* wl_dbg_level = level; */
-}
-
 static bool wl_is_ibssmode(struct wl_priv *wl)
 {
        return wl->conf->mode == WL_MODE_IBSS;
 }
 
-static bool wl_is_ibssstarter(struct wl_priv *wl)
-{
-       return wl->ibss_starter;
-}
-
-static void wl_rst_ie(struct wl_priv *wl)
-{
-       struct wl_ie *ie = wl_to_ie(wl);
-
-       ie->offset = 0;
-}
-
 static __used s32 wl_add_ie(struct wl_priv *wl, u8 t, u8 l, u8 *v)
 {
        struct wl_ie *ie = wl_to_ie(wl);
@@ -3995,58 +4232,24 @@ static __used s32 wl_add_ie(struct wl_priv *wl, u8 t, u8 l, u8 *v)
        return err;
 }
 
-static s32 wl_mrg_ie(struct wl_priv *wl, u8 *ie_stream, u16 ie_size)
-{
-       struct wl_ie *ie = wl_to_ie(wl);
-       s32 err = 0;
 
-       if (unlikely(ie->offset + ie_size > WL_TLV_INFO_MAX)) {
-               WL_ERR("ei_stream crosses buffer boundary\n");
-               return -ENOSPC;
-       }
-       memcpy(&ie->buf[ie->offset], ie_stream, ie_size);
-       ie->offset += ie_size;
-
-       return err;
-}
-
-static s32 wl_cp_ie(struct wl_priv *wl, u8 *dst, u16 dst_size)
+static void wl_link_down(struct wl_priv *wl)
 {
-       struct wl_ie *ie = wl_to_ie(wl);
+       struct net_device *dev = NULL;
        s32 err = 0;
 
-       if (unlikely(ie->offset > dst_size)) {
-               WL_ERR("dst_size is not enough\n");
-               return -ENOSPC;
-       }
-       memcpy(dst, &ie->buf[0], ie->offset);
-
-       return err;
-}
-
-static u32 wl_get_ielen(struct wl_priv *wl)
-{
-       struct wl_ie *ie = wl_to_ie(wl);
-
-       return ie->offset;
-}
-
-static void wl_link_up(struct wl_priv *wl)
-{
-       wl->link_up = true;
-}
-
-static void wl_link_down(struct wl_priv *wl)
-{
-       struct wl_connect_info *conn_info = wl_to_conn(wl);
+       WL_TRACE("Enter\n");
+       clear_bit(WL_STATUS_CONNECTED, &wl->status);
 
-       wl->link_up = false;
-       kfree(conn_info->req_ie);
-       conn_info->req_ie = NULL;
-       conn_info->req_ie_len = 0;
-       kfree(conn_info->resp_ie);
-       conn_info->resp_ie = NULL;
-       conn_info->resp_ie_len = 0;
+       if (wl->link_up) {
+               dev = wl_to_ndev(wl);
+               WL_INFO("Call WLC_DISASSOC to stop excess roaming\n ");
+               err = wl_dev_ioctl(dev, WLC_DISASSOC, NULL, 0);
+               if (unlikely(err))
+                       WL_ERR("WLC_DISASSOC failed (%d)\n", err);
+               wl->link_up = false;
+       }
+       WL_TRACE("Exit\n");
 }
 
 static void wl_lock_eq(struct wl_priv *wl)
@@ -4116,7 +4319,7 @@ void *wl_cfg80211_request_fw(s8 *file_name)
        const struct firmware *fw_entry = NULL;
        s32 err = 0;
 
-       WL_DBG("file name : \"%s\"\n", file_name);
+       WL_INFO("file name : \"%s\"\n", file_name);
        wl = WL_PRIV_GET();
 
        if (!test_bit(WL_FW_LOADING_DONE, &wl->fw->status)) {
@@ -4129,7 +4332,7 @@ void *wl_cfg80211_request_fw(s8 *file_name)
                set_bit(WL_FW_LOADING_DONE, &wl->fw->status);
                fw_entry = wl->fw->fw_entry;
                if (fw_entry) {
-                       WL_DBG("fw size (%zd), data (%p)\n",
+                       WL_INFO("fw size (%zd), data (%p)\n",
                               fw_entry->size, fw_entry->data);
                }
        } else if (!test_bit(WL_NVRAM_LOADING_DONE, &wl->fw->status)) {
@@ -4142,11 +4345,11 @@ void *wl_cfg80211_request_fw(s8 *file_name)
                set_bit(WL_NVRAM_LOADING_DONE, &wl->fw->status);
                fw_entry = wl->fw->fw_entry;
                if (fw_entry) {
-                       WL_DBG("nvram size (%zd), data (%p)\n",
+                       WL_INFO("nvram size (%zd), data (%p)\n",
                               fw_entry->size, fw_entry->data);
                }
        } else {
-               WL_DBG("Downloading already done. Nothing to do more\n");
+               WL_INFO("Downloading already done. Nothing to do more\n");
                err = -EPERM;
        }
 
@@ -4179,13 +4382,16 @@ s8 *wl_cfg80211_get_nvramname(void)
 static void wl_set_mpc(struct net_device *ndev, int mpc)
 {
        s32 err = 0;
+       struct wl_priv *wl = ndev_to_wl(ndev);
 
-       err = wl_dev_intvar_set(ndev, "mpc", mpc);
-       if (unlikely(err)) {
-               WL_ERR("fail to set mpc\n");
-               return;
+       if (test_bit(WL_STATUS_READY, &wl->status)) {
+               err = wl_dev_intvar_set(ndev, "mpc", mpc);
+               if (unlikely(err)) {
+                       WL_ERR("fail to set mpc\n");
+                       return;
+               }
+               WL_INFO("MPC : %d\n", mpc);
        }
-       WL_DBG("MPC : %d\n", mpc);
 }
 
 static int wl_debugfs_add_netdev_params(struct wl_priv *wl)
index 5112160e0ae372380144b435abe9b92ce2101cd9..996033cf9b09a6da5386149f6c504ba54bc8e270 100644 (file)
@@ -28,45 +28,73 @@ struct wl_priv;
 struct wl_security;
 struct wl_ibss;
 
-#define WL_DBG_NONE    0
-#define WL_DBG_DBG     (1 << 2)
-#define WL_DBG_INFO    (1 << 1)
-#define WL_DBG_ERR     (1 << 0)
-#define WL_DBG_MASK ((WL_DBG_DBG | WL_DBG_INFO | WL_DBG_ERR) << 1)
-
-#define WL_DBG_LEVEL 1         /* 0 invalidates all debug messages.
-                                default is 1 */
+#define WL_DBG_NONE            0
+#define WL_DBG_CONN            (1 << 5)
+#define WL_DBG_SCAN            (1 << 4)
+#define WL_DBG_TRACE           (1 << 3)
+#define WL_DBG_INFO            (1 << 1)
+#define WL_DBG_ERR             (1 << 0)
+#define WL_DBG_MASK            ((WL_DBG_INFO | WL_DBG_ERR | WL_DBG_TRACE) | \
+                               (WL_DBG_SCAN) | (WL_DBG_CONN))
+
 #define        WL_ERR(fmt, args...)                                    \
 do {                                                           \
        if (wl_dbg_level & WL_DBG_ERR) {                        \
                if (net_ratelimit()) {                          \
                        printk(KERN_ERR "ERROR @%s : " fmt,     \
-                              __func__, ##args);               \
+                               __func__, ##args);              \
                }                                               \
        }                                                       \
 } while (0)
 
+#if (defined BCMDBG)
 #define        WL_INFO(fmt, args...)                                   \
 do {                                                           \
        if (wl_dbg_level & WL_DBG_INFO) {                       \
                if (net_ratelimit()) {                          \
                        printk(KERN_ERR "INFO @%s : " fmt,      \
-                              __func__, ##args);               \
+                               __func__, ##args);              \
+               }                                               \
+       }                                                       \
+} while (0)
+
+#define        WL_TRACE(fmt, args...)                                  \
+do {                                                           \
+       if (wl_dbg_level & WL_DBG_TRACE) {                      \
+               if (net_ratelimit()) {                          \
+                       printk(KERN_ERR "TRACE @%s : " fmt,     \
+                               __func__, ##args);              \
                }                                               \
        }                                                       \
 } while (0)
 
-#if (WL_DBG_LEVEL > 0)
-#define        WL_DBG(fmt, args...)                                    \
+#define        WL_SCAN(fmt, args...)                                   \
 do {                                                           \
-       if (wl_dbg_level & WL_DBG_DBG) {                        \
-               printk(KERN_ERR "DEBUG @%s :" fmt,              \
-                      __func__, ##args);                       \
+       if (wl_dbg_level & WL_DBG_SCAN) {                       \
+               if (net_ratelimit()) {                          \
+                       printk(KERN_ERR "SCAN @%s : " fmt,      \
+                               __func__, ##args);              \
+               }                                               \
        }                                                       \
 } while (0)
-#else                          /* !(WL_DBG_LEVEL > 0) */
-#define        WL_DBG(fmt, args...) noprintk(fmt, ##args)
-#endif                         /* (WL_DBG_LEVEL > 0) */
+
+#define        WL_CONN(fmt, args...)                                   \
+do {                                                           \
+       if (wl_dbg_level & WL_DBG_CONN) {                       \
+               if (net_ratelimit()) {                          \
+                       printk(KERN_ERR "CONN @%s : " fmt,      \
+                               __func__, ##args);              \
+               }                                               \
+       }                                                       \
+} while (0)
+
+#else /* (defined BCMDBG) */
+#define        WL_INFO(fmt, args...)
+#define        WL_TRACE(fmt, args...)
+#define        WL_SCAN(fmt, args...)
+#define        WL_CONN(fmt, args...)
+#endif /* (defined BCMDBG) */
+
 
 #define WL_SCAN_RETRY_MAX      3       /* used for ibss scan */
 #define WL_NUM_SCAN_MAX                1
@@ -95,6 +123,14 @@ do {                                                                \
                                 */
 #define WL_FILE_NAME_MAX               256
 
+#define WL_ROAM_TRIGGER_LEVEL          -75
+#define WL_ROAM_DELTA                  20
+#define WL_BEACON_TIMEOUT              3
+
+#define WL_SCAN_CHANNEL_TIME           40
+#define WL_SCAN_UNASSOC_TIME           40
+#define WL_SCAN_PASSIVE_TIME           120
+
 /* dongle status */
 enum wl_status {
        WL_STATUS_READY,
@@ -227,7 +263,6 @@ struct wl_profile {
        struct wl_security sec;
        struct wl_ibss ibss;
        s32 band;
-       bool active;
 };
 
 /* dongle iscan event loop */
@@ -298,7 +333,6 @@ struct wl_priv {
                                                 cfg80211 layer */
        struct wl_ie ie;        /* information element object for
                                         internal purpose */
-       u8 bssid[ETH_ALEN];     /* bssid of currently engaged network */
        struct semaphore event_sync;    /* for synchronization of main event
                                         thread */
        struct wl_profile *profile;     /* holding dongle profile */
@@ -375,5 +409,6 @@ extern s8 *wl_cfg80211_get_fwname(void);    /* get firmware name for
                                                 the dongle */
 extern s8 *wl_cfg80211_get_nvramname(void);    /* get nvram name for
                                                 the dongle */
+extern void wl_os_wd_timer(struct net_device *ndev, uint wdtick);
 
 #endif                         /* _wl_cfg80211_h_ */
index b49957fb758663e9a6a89f278061b820c0d8304f..929ceaf363bea7df2b8e51a4d114bcb1acaa5ff8 100644 (file)
@@ -69,8 +69,6 @@ uint wl_msg_level = WL_ERROR_VAL;
 #define MAX_WLIW_IOCTL_LEN 1024
 
 #ifdef CONFIG_WIRELESS_EXT
-
-extern struct iw_statistics *dhd_get_wireless_stats(struct net_device *dev);
 extern int dhd_wait_pend8021x(struct net_device *dev);
 #endif
 
@@ -119,6 +117,9 @@ iscan_info_t *g_iscan;
 
 static const u8 ether_bcast[ETH_ALEN] = {255, 255, 255, 255, 255, 255};
 
+/* Global ASSERT type flag */
+u32 g_assert_type;
+
 static void wl_iw_timerfunc(unsigned long data);
 static void wl_iw_set_event_mask(struct net_device *dev);
 static int wl_iw_iscan(iscan_info_t *iscan, wlc_ssid_t *ssid, u16 action);
@@ -372,7 +373,7 @@ wl_iw_set_freq(struct net_device *dev,
                if (fwrq->m > 4000 && fwrq->m < 5000)
                        sf = WF_CHAN_FACTOR_4_G;
 
-               chan = wf_mhz2channel(fwrq->m, sf);
+               chan = bcm_mhz2channel(fwrq->m, sf);
        }
        chan = cpu_to_le32(chan);
 
@@ -495,9 +496,7 @@ wl_iw_get_range(struct net_device *dev,
        list = (wl_u32_list_t *) channels;
 
        dwrq->length = sizeof(struct iw_range);
-       memset(range, 0, sizeof(range));
-
-       range->min_nwid = range->max_nwid = 0;
+       memset(range, 0, sizeof(*range));
 
        list->count = cpu_to_le32(MAXCHANNEL);
        error = dev_wlc_ioctl(dev, WLC_GET_VALID_CHANNELS, channels,
@@ -3131,7 +3130,7 @@ const struct iw_handler_def wl_iw_handler_def = {
        .private_args = 0,
 
 #if WIRELESS_EXT >= 19
-       .get_wireless_stats = dhd_get_wireless_stats,
+       .get_wireless_stats = NULL,
 #endif
 };
 #endif                         /* WIRELESS_EXT > 12 */
@@ -3548,103 +3547,6 @@ void wl_iw_event(struct net_device *dev, wl_event_msg_t *e, void *data)
 #endif                         /* WIRELESS_EXT > 13 */
 }
 
-int
-wl_iw_get_wireless_stats(struct net_device *dev, struct iw_statistics *wstats)
-{
-       int res = 0;
-       struct wl_cnt cnt;
-       int phy_noise;
-       int rssi;
-       scb_val_t scb_val;
-
-       phy_noise = 0;
-       res = dev_wlc_ioctl(dev, WLC_GET_PHY_NOISE, &phy_noise,
-                               sizeof(phy_noise));
-       if (res)
-               goto done;
-
-       phy_noise = le32_to_cpu(phy_noise);
-       WL_TRACE("wl_iw_get_wireless_stats phy noise=%d\n", phy_noise);
-
-       memset(&scb_val, 0, sizeof(scb_val_t));
-       res = dev_wlc_ioctl(dev, WLC_GET_RSSI, &scb_val, sizeof(scb_val_t));
-       if (res)
-               goto done;
-
-       rssi = le32_to_cpu(scb_val.val);
-       WL_TRACE("wl_iw_get_wireless_stats rssi=%d\n", rssi);
-       if (rssi <= WL_IW_RSSI_NO_SIGNAL)
-               wstats->qual.qual = 0;
-       else if (rssi <= WL_IW_RSSI_VERY_LOW)
-               wstats->qual.qual = 1;
-       else if (rssi <= WL_IW_RSSI_LOW)
-               wstats->qual.qual = 2;
-       else if (rssi <= WL_IW_RSSI_GOOD)
-               wstats->qual.qual = 3;
-       else if (rssi <= WL_IW_RSSI_VERY_GOOD)
-               wstats->qual.qual = 4;
-       else
-               wstats->qual.qual = 5;
-
-       wstats->qual.level = 0x100 + rssi;
-       wstats->qual.noise = 0x100 + phy_noise;
-#if WIRELESS_EXT > 18
-       wstats->qual.updated |= (IW_QUAL_ALL_UPDATED | IW_QUAL_DBM);
-#else
-       wstats->qual.updated |= 7;
-#endif
-
-#if WIRELESS_EXT > 11
-       WL_TRACE("wl_iw_get_wireless_stats counters=%zu\n",
-                sizeof(struct wl_cnt));
-
-       memset(&cnt, 0, sizeof(struct wl_cnt));
-       res =
-           dev_wlc_bufvar_get(dev, "counters", (char *)&cnt,
-                              sizeof(struct wl_cnt));
-       if (res) {
-               WL_ERROR("wl_iw_get_wireless_stats counters failed error=%d\n",
-                        res);
-               goto done;
-       }
-
-       cnt.version = le16_to_cpu(cnt.version);
-       if (cnt.version != WL_CNT_T_VERSION) {
-               WL_TRACE("\tIncorrect counter version: expected %d; got %d\n",
-                        WL_CNT_T_VERSION, cnt.version);
-               goto done;
-       }
-
-       wstats->discard.nwid = 0;
-       wstats->discard.code = le32_to_cpu(cnt.rxundec);
-       wstats->discard.fragment = le32_to_cpu(cnt.rxfragerr);
-       wstats->discard.retries = le32_to_cpu(cnt.txfail);
-       wstats->discard.misc = le32_to_cpu(cnt.rxrunt) +
-               le32_to_cpu(cnt.rxgiant);
-       wstats->miss.beacon = 0;
-
-       WL_TRACE("wl_iw_get_wireless_stats counters txframe=%d txbyte=%d\n",
-                le32_to_cpu(cnt.txframe), le32_to_cpu(cnt.txbyte));
-       WL_TRACE("wl_iw_get_wireless_stats counters rxfrmtoolong=%d\n",
-                 le32_to_cpu(cnt.rxfrmtoolong));
-       WL_TRACE("wl_iw_get_wireless_stats counters rxbadplcp=%d\n",
-                 le32_to_cpu(cnt.rxbadplcp));
-       WL_TRACE("wl_iw_get_wireless_stats counters rxundec=%d\n",
-                 le32_to_cpu(cnt.rxundec));
-       WL_TRACE("wl_iw_get_wireless_stats counters rxfragerr=%d\n",
-                 le32_to_cpu(cnt.rxfragerr));
-       WL_TRACE("wl_iw_get_wireless_stats counters txfail=%d\n",
-                 le32_to_cpu(cnt.txfail));
-       WL_TRACE("wl_iw_get_wireless_stats counters rxrunt=%d\n",
-                 le32_to_cpu(cnt.rxrunt));
-       WL_TRACE("wl_iw_get_wireless_stats counters rxgiant=%d\n",
-                 le32_to_cpu(cnt.rxgiant));
-#endif                         /* WIRELESS_EXT > 11 */
-
-done:
-       return res;
-}
-
 int wl_iw_attach(struct net_device *dev, void *dhdp)
 {
        int params_size;
@@ -3672,8 +3574,10 @@ int wl_iw_attach(struct net_device *dev, void *dhdp)
                return -ENOMEM;
 
        iscan->iscan_ex_params_p = kmalloc(params_size, GFP_KERNEL);
-       if (!iscan->iscan_ex_params_p)
+       if (!iscan->iscan_ex_params_p) {
+               kfree(iscan);
                return -ENOMEM;
+       }
        iscan->iscan_ex_param_size = params_size;
        iscan->sysioc_tsk = NULL;
 
@@ -3742,3 +3646,50 @@ void wl_iw_detach(void)
 
        g_scan = NULL;
 }
+
+#if defined(BCMDBG)
+void osl_assert(char *exp, char *file, int line)
+{
+       char tempbuf[256];
+       char *basename;
+
+       basename = strrchr(file, '/');
+       /* skip the '/' */
+       if (basename)
+               basename++;
+
+       if (!basename)
+               basename = file;
+
+       snprintf(tempbuf, 256,
+                "assertion \"%s\" failed: file \"%s\", line %d\n", exp,
+                basename, line);
+
+       /*
+        * Print assert message and give it time to
+        * be written to /var/log/messages
+        */
+       if (!in_interrupt()) {
+               const int delay = 3;
+               printk(KERN_ERR "%s", tempbuf);
+               printk(KERN_ERR "panic in %d seconds\n", delay);
+               set_current_state(TASK_INTERRUPTIBLE);
+               schedule_timeout(delay * HZ);
+       }
+
+       switch (g_assert_type) {
+       case 0:
+               panic(KERN_ERR "%s", tempbuf);
+               break;
+       case 1:
+               printk(KERN_ERR "%s", tempbuf);
+               BUG();
+               break;
+       case 2:
+               printk(KERN_ERR "%s", tempbuf);
+               break;
+       default:
+               break;
+       }
+}
+#endif                         /* defined(BCMDBG) */
index c4aafe5cf7f52f72c509db0501d1eab60e94feb4..8d75fe19ca9aecc0285756eccfec3431c80ddd39 100644 (file)
@@ -25,7 +25,6 @@ ccflags-y :=                          \
        -DBCMNVRAMR                             \
        -Idrivers/staging/brcm80211/brcmsmac \
        -Idrivers/staging/brcm80211/brcmsmac/phy \
-       -Idrivers/staging/brcm80211/util \
        -Idrivers/staging/brcm80211/include
 
 BRCMSMAC_OFILES := \
@@ -38,26 +37,23 @@ BRCMSMAC_OFILES := \
        wlc_channel.o \
        wlc_main.o \
        wlc_phy_shim.o \
+       wlc_pmu.o \
        wlc_rate.o \
        wlc_stf.o \
+       aiutils.o \
        phy/wlc_phy_cmn.o \
        phy/wlc_phy_lcn.o \
        phy/wlc_phy_n.o \
        phy/wlc_phytbl_lcn.o \
        phy/wlc_phytbl_n.o \
-       ../util/aiutils.o \
-       ../util/siutils.o \
-       ../util/bcmutils.o \
-       ../util/bcmwifi.o \
-       ../util/bcmotp.o \
-       ../util/bcmsrom.o \
-       ../util/hnddma.o \
-       ../util/hndpmu.o \
-       ../util/nicpci.o \
-       ../util/qmath.o \
-       ../util/nvram/nvram_ro.o
+       phy/wlc_phy_qmath.o \
+       bcmotp.o \
+       bcmsrom.o \
+       hnddma.o \
+       nicpci.o \
+       nvram.o
 
 MODULEPFX := brcmsmac
 
-obj- += $(MODULEPFX).o
+obj-$(CONFIG_BRCMSMAC) += $(MODULEPFX).o
 $(MODULEPFX)-objs      = $(BRCMSMAC_OFILES)
similarity index 55%
rename from drivers/staging/brcm80211/util/siutils.c
rename to drivers/staging/brcm80211/brcmsmac/aiutils.c
index 6ebd7f58af8161baab08d59684d88691b21a0530..a61185f70a7cd950a078bfc26840ba1cc19540eb 100644 (file)
 #include <linux/module.h>
 #include <linux/pci.h>
 #include <bcmutils.h>
-#include <siutils.h>
-#include <bcmdevs.h>
+#include <aiutils.h>
 #include <hndsoc.h>
 #include <sbchipc.h>
+#include <pcicfg.h>
+#include <bcmdevs.h>
+
+/* ********** from siutils.c *********** */
 #include <pci_core.h>
 #include <pcie_core.h>
 #include <nicpci.h>
 #include <bcmnvram.h>
 #include <bcmsrom.h>
-#include <pcicfg.h>
-#include <sbsocram.h>
-#ifdef BCMSDIO
-#include <bcmsdh.h>
-#include <sdio.h>
-#include <sbsdio.h>
-#include <sbhnddma.h>
-#include <sbsdpcmdev.h>
-#include <bcmsdpcm.h>
-#endif                         /* BCMSDIO */
-#include <hndpmu.h>
-
-/* this file now contains only definitions for sb functions, only necessary
-*for devices using Sonics backplanes (bcm4329)
-*/
+#include <wlc_pmu.h>
+
+#define BCM47162_DMP() ((sih->chip == BCM47162_CHIP_ID) && \
+               (sih->chiprev == 0) && \
+               (sii->coreid[sii->curidx] == MIPS74K_CORE_ID))
+
+/* EROM parsing */
+
+static u32
+get_erom_ent(si_t *sih, u32 **eromptr, u32 mask, u32 match)
+{
+       u32 ent;
+       uint inv = 0, nom = 0;
+
+       while (true) {
+               ent = R_REG(*eromptr);
+               (*eromptr)++;
+
+               if (mask == 0)
+                       break;
+
+               if ((ent & ER_VALID) == 0) {
+                       inv++;
+                       continue;
+               }
+
+               if (ent == (ER_END | ER_VALID))
+                       break;
+
+               if ((ent & mask) == match)
+                       break;
+
+               nom++;
+       }
+
+       SI_VMSG(("%s: Returning ent 0x%08x\n", __func__, ent));
+       if (inv + nom) {
+               SI_VMSG(("  after %d invalid and %d non-matching entries\n",
+                        inv, nom));
+       }
+       return ent;
+}
+
+static u32
+get_asd(si_t *sih, u32 **eromptr, uint sp, uint ad, uint st,
+       u32 *addrl, u32 *addrh, u32 *sizel, u32 *sizeh)
+{
+       u32 asd, sz, szd;
+
+       asd = get_erom_ent(sih, eromptr, ER_VALID, ER_VALID);
+       if (((asd & ER_TAG1) != ER_ADD) ||
+           (((asd & AD_SP_MASK) >> AD_SP_SHIFT) != sp) ||
+           ((asd & AD_ST_MASK) != st)) {
+               /* This is not what we want, "push" it back */
+               (*eromptr)--;
+               return 0;
+       }
+       *addrl = asd & AD_ADDR_MASK;
+       if (asd & AD_AG32)
+               *addrh = get_erom_ent(sih, eromptr, 0, 0);
+       else
+               *addrh = 0;
+       *sizeh = 0;
+       sz = asd & AD_SZ_MASK;
+       if (sz == AD_SZ_SZD) {
+               szd = get_erom_ent(sih, eromptr, 0, 0);
+               *sizel = szd & SD_SZ_MASK;
+               if (szd & SD_SG32)
+                       *sizeh = get_erom_ent(sih, eromptr, 0, 0);
+       } else
+               *sizel = AD_SZ_BASE << (sz >> AD_SZ_SHIFT);
+
+       SI_VMSG(("  SP %d, ad %d: st = %d, 0x%08x_0x%08x @ 0x%08x_0x%08x\n",
+                sp, ad, st, *sizeh, *sizel, *addrh, *addrl));
+
+       return asd;
+}
+
+static void ai_hwfixup(si_info_t *sii)
+{
+}
+
+/* parse the enumeration rom to identify all cores */
+void ai_scan(si_t *sih, void *regs, uint devid)
+{
+       si_info_t *sii = SI_INFO(sih);
+       chipcregs_t *cc = (chipcregs_t *) regs;
+       u32 erombase, *eromptr, *eromlim;
+
+       erombase = R_REG(&cc->eromptr);
+
+       switch (sih->bustype) {
+       case SI_BUS:
+               eromptr = (u32 *) REG_MAP(erombase, SI_CORE_SIZE);
+               break;
+
+       case PCI_BUS:
+               /* Set wrappers address */
+               sii->curwrap = (void *)((unsigned long)regs + SI_CORE_SIZE);
+
+               /* Now point the window at the erom */
+               pci_write_config_dword(sii->pbus, PCI_BAR0_WIN, erombase);
+               eromptr = regs;
+               break;
+
+       case SPI_BUS:
+       case SDIO_BUS:
+               eromptr = (u32 *)(unsigned long)erombase;
+               break;
+
+       default:
+               SI_ERROR(("Don't know how to do AXI enumertion on bus %d\n",
+                         sih->bustype));
+               return;
+       }
+       eromlim = eromptr + (ER_REMAPCONTROL / sizeof(u32));
+
+       SI_VMSG(("ai_scan: regs = 0x%p, erombase = 0x%08x, eromptr = 0x%p, eromlim = 0x%p\n", regs, erombase, eromptr, eromlim));
+       while (eromptr < eromlim) {
+               u32 cia, cib, cid, mfg, crev, nmw, nsw, nmp, nsp;
+               u32 mpd, asd, addrl, addrh, sizel, sizeh;
+               u32 *base;
+               uint i, j, idx;
+               bool br;
+
+               br = false;
+
+               /* Grok a component */
+               cia = get_erom_ent(sih, &eromptr, ER_TAG, ER_CI);
+               if (cia == (ER_END | ER_VALID)) {
+                       SI_VMSG(("Found END of erom after %d cores\n",
+                                sii->numcores));
+                       ai_hwfixup(sii);
+                       return;
+               }
+               base = eromptr - 1;
+               cib = get_erom_ent(sih, &eromptr, 0, 0);
+
+               if ((cib & ER_TAG) != ER_CI) {
+                       SI_ERROR(("CIA not followed by CIB\n"));
+                       goto error;
+               }
+
+               cid = (cia & CIA_CID_MASK) >> CIA_CID_SHIFT;
+               mfg = (cia & CIA_MFG_MASK) >> CIA_MFG_SHIFT;
+               crev = (cib & CIB_REV_MASK) >> CIB_REV_SHIFT;
+               nmw = (cib & CIB_NMW_MASK) >> CIB_NMW_SHIFT;
+               nsw = (cib & CIB_NSW_MASK) >> CIB_NSW_SHIFT;
+               nmp = (cib & CIB_NMP_MASK) >> CIB_NMP_SHIFT;
+               nsp = (cib & CIB_NSP_MASK) >> CIB_NSP_SHIFT;
+
+               SI_VMSG(("Found component 0x%04x/0x%04x rev %d at erom addr 0x%p, with nmw = %d, " "nsw = %d, nmp = %d & nsp = %d\n", mfg, cid, crev, base, nmw, nsw, nmp, nsp));
+
+               if (((mfg == MFGID_ARM) && (cid == DEF_AI_COMP)) || (nsp == 0))
+                       continue;
+               if ((nmw + nsw == 0)) {
+                       /* A component which is not a core */
+                       if (cid == OOB_ROUTER_CORE_ID) {
+                               asd = get_asd(sih, &eromptr, 0, 0, AD_ST_SLAVE,
+                                             &addrl, &addrh, &sizel, &sizeh);
+                               if (asd != 0) {
+                                       sii->oob_router = addrl;
+                               }
+                       }
+                       continue;
+               }
+
+               idx = sii->numcores;
+/*             sii->eromptr[idx] = base; */
+               sii->cia[idx] = cia;
+               sii->cib[idx] = cib;
+               sii->coreid[idx] = cid;
+
+               for (i = 0; i < nmp; i++) {
+                       mpd = get_erom_ent(sih, &eromptr, ER_VALID, ER_VALID);
+                       if ((mpd & ER_TAG) != ER_MP) {
+                               SI_ERROR(("Not enough MP entries for component 0x%x\n", cid));
+                               goto error;
+                       }
+                       SI_VMSG(("  Master port %d, mp: %d id: %d\n", i,
+                                (mpd & MPD_MP_MASK) >> MPD_MP_SHIFT,
+                                (mpd & MPD_MUI_MASK) >> MPD_MUI_SHIFT));
+               }
+
+               /* First Slave Address Descriptor should be port 0:
+                * the main register space for the core
+                */
+               asd =
+                   get_asd(sih, &eromptr, 0, 0, AD_ST_SLAVE, &addrl, &addrh,
+                           &sizel, &sizeh);
+               if (asd == 0) {
+                       /* Try again to see if it is a bridge */
+                       asd =
+                           get_asd(sih, &eromptr, 0, 0, AD_ST_BRIDGE, &addrl,
+                                   &addrh, &sizel, &sizeh);
+                       if (asd != 0)
+                               br = true;
+                       else if ((addrh != 0) || (sizeh != 0)
+                                || (sizel != SI_CORE_SIZE)) {
+                               SI_ERROR(("First Slave ASD for core 0x%04x malformed " "(0x%08x)\n", cid, asd));
+                               goto error;
+                       }
+               }
+               sii->coresba[idx] = addrl;
+               sii->coresba_size[idx] = sizel;
+               /* Get any more ASDs in port 0 */
+               j = 1;
+               do {
+                       asd =
+                           get_asd(sih, &eromptr, 0, j, AD_ST_SLAVE, &addrl,
+                                   &addrh, &sizel, &sizeh);
+                       if ((asd != 0) && (j == 1) && (sizel == SI_CORE_SIZE)) {
+                               sii->coresba2[idx] = addrl;
+                               sii->coresba2_size[idx] = sizel;
+                       }
+                       j++;
+               } while (asd != 0);
+
+               /* Go through the ASDs for other slave ports */
+               for (i = 1; i < nsp; i++) {
+                       j = 0;
+                       do {
+                               asd =
+                                   get_asd(sih, &eromptr, i, j++, AD_ST_SLAVE,
+                                           &addrl, &addrh, &sizel, &sizeh);
+                       } while (asd != 0);
+                       if (j == 0) {
+                               SI_ERROR((" SP %d has no address descriptors\n",
+                                         i));
+                               goto error;
+                       }
+               }
+
+               /* Now get master wrappers */
+               for (i = 0; i < nmw; i++) {
+                       asd =
+                           get_asd(sih, &eromptr, i, 0, AD_ST_MWRAP, &addrl,
+                                   &addrh, &sizel, &sizeh);
+                       if (asd == 0) {
+                               SI_ERROR(("Missing descriptor for MW %d\n", i));
+                               goto error;
+                       }
+                       if ((sizeh != 0) || (sizel != SI_CORE_SIZE)) {
+                               SI_ERROR(("Master wrapper %d is not 4KB\n", i));
+                               goto error;
+                       }
+                       if (i == 0)
+                               sii->wrapba[idx] = addrl;
+               }
+
+               /* And finally slave wrappers */
+               for (i = 0; i < nsw; i++) {
+                       uint fwp = (nsp == 1) ? 0 : 1;
+                       asd =
+                           get_asd(sih, &eromptr, fwp + i, 0, AD_ST_SWRAP,
+                                   &addrl, &addrh, &sizel, &sizeh);
+                       if (asd == 0) {
+                               SI_ERROR(("Missing descriptor for SW %d\n", i));
+                               goto error;
+                       }
+                       if ((sizeh != 0) || (sizel != SI_CORE_SIZE)) {
+                               SI_ERROR(("Slave wrapper %d is not 4KB\n", i));
+                               goto error;
+                       }
+                       if ((nmw == 0) && (i == 0))
+                               sii->wrapba[idx] = addrl;
+               }
+
+               /* Don't record bridges */
+               if (br)
+                       continue;
+
+               /* Done with core */
+               sii->numcores++;
+       }
+
+       SI_ERROR(("Reached end of erom without finding END"));
+
+ error:
+       sii->numcores = 0;
+       return;
+}
 
-/* if an amba SDIO device is supported, please further restrict the inclusion
- * of this file
+/* This function changes the logical "focus" to the indicated core.
+ * Return the current core's virtual address.
  */
-#ifdef BCMSDIO
-#include "siutils_priv.h"
-#endif
+void *ai_setcoreidx(si_t *sih, uint coreidx)
+{
+       si_info_t *sii = SI_INFO(sih);
+       u32 addr = sii->coresba[coreidx];
+       u32 wrap = sii->wrapba[coreidx];
+       void *regs;
+
+       if (coreidx >= sii->numcores)
+               return NULL;
+
+       switch (sih->bustype) {
+       case SI_BUS:
+               /* map new one */
+               if (!sii->regs[coreidx]) {
+                       sii->regs[coreidx] = REG_MAP(addr, SI_CORE_SIZE);
+               }
+               sii->curmap = regs = sii->regs[coreidx];
+               if (!sii->wrappers[coreidx]) {
+                       sii->wrappers[coreidx] = REG_MAP(wrap, SI_CORE_SIZE);
+               }
+               sii->curwrap = sii->wrappers[coreidx];
+               break;
+
+       case PCI_BUS:
+               /* point bar0 window */
+               pci_write_config_dword(sii->pbus, PCI_BAR0_WIN, addr);
+               regs = sii->curmap;
+               /* point bar0 2nd 4KB window */
+               pci_write_config_dword(sii->pbus, PCI_BAR0_WIN2, wrap);
+               break;
+
+       case SPI_BUS:
+       case SDIO_BUS:
+               sii->curmap = regs = (void *)(unsigned long)addr;
+               sii->curwrap = (void *)(unsigned long)wrap;
+               break;
+
+       default:
+               regs = NULL;
+               break;
+       }
+
+       sii->curmap = regs;
+       sii->curidx = coreidx;
+
+       return regs;
+}
+
+/* Return the number of address spaces in current core */
+int ai_numaddrspaces(si_t *sih)
+{
+       return 2;
+}
+
+/* Return the address of the nth address space in the current core */
+u32 ai_addrspace(si_t *sih, uint asidx)
+{
+       si_info_t *sii;
+       uint cidx;
+
+       sii = SI_INFO(sih);
+       cidx = sii->curidx;
+
+       if (asidx == 0)
+               return sii->coresba[cidx];
+       else if (asidx == 1)
+               return sii->coresba2[cidx];
+       else {
+               SI_ERROR(("%s: Need to parse the erom again to find addr space %d\n", __func__, asidx));
+               return 0;
+       }
+}
+
+/* Return the size of the nth address space in the current core */
+u32 ai_addrspacesize(si_t *sih, uint asidx)
+{
+       si_info_t *sii;
+       uint cidx;
+
+       sii = SI_INFO(sih);
+       cidx = sii->curidx;
+
+       if (asidx == 0)
+               return sii->coresba_size[cidx];
+       else if (asidx == 1)
+               return sii->coresba2_size[cidx];
+       else {
+               SI_ERROR(("%s: Need to parse the erom again to find addr space %d\n", __func__, asidx));
+               return 0;
+       }
+}
+
+uint ai_flag(si_t *sih)
+{
+       si_info_t *sii;
+       aidmp_t *ai;
+
+       sii = SI_INFO(sih);
+       if (BCM47162_DMP()) {
+               SI_ERROR(("%s: Attempting to read MIPS DMP registers on 47162a0", __func__));
+               return sii->curidx;
+       }
+       ai = sii->curwrap;
+
+       return R_REG(&ai->oobselouta30) & 0x1f;
+}
+
+void ai_setint(si_t *sih, int siflag)
+{
+}
+
+uint ai_corevendor(si_t *sih)
+{
+       si_info_t *sii;
+       u32 cia;
+
+       sii = SI_INFO(sih);
+       cia = sii->cia[sii->curidx];
+       return (cia & CIA_MFG_MASK) >> CIA_MFG_SHIFT;
+}
+
+uint ai_corerev(si_t *sih)
+{
+       si_info_t *sii;
+       u32 cib;
+
+       sii = SI_INFO(sih);
+       cib = sii->cib[sii->curidx];
+       return (cib & CIB_REV_MASK) >> CIB_REV_SHIFT;
+}
+
+bool ai_iscoreup(si_t *sih)
+{
+       si_info_t *sii;
+       aidmp_t *ai;
+
+       sii = SI_INFO(sih);
+       ai = sii->curwrap;
+
+       return (((R_REG(&ai->ioctrl) & (SICF_FGC | SICF_CLOCK_EN)) ==
+                SICF_CLOCK_EN)
+               && ((R_REG(&ai->resetctrl) & AIRC_RESET) == 0));
+}
+
+void ai_core_cflags_wo(si_t *sih, u32 mask, u32 val)
+{
+       si_info_t *sii;
+       aidmp_t *ai;
+       u32 w;
+
+       sii = SI_INFO(sih);
 
+       if (BCM47162_DMP()) {
+               SI_ERROR(("%s: Accessing MIPS DMP register (ioctrl) on 47162a0",
+                         __func__));
+               return;
+       }
+
+       ai = sii->curwrap;
+
+       if (mask || val) {
+               w = ((R_REG(&ai->ioctrl) & ~mask) | val);
+               W_REG(&ai->ioctrl, w);
+       }
+}
+
+u32 ai_core_cflags(si_t *sih, u32 mask, u32 val)
+{
+       si_info_t *sii;
+       aidmp_t *ai;
+       u32 w;
+
+       sii = SI_INFO(sih);
+       if (BCM47162_DMP()) {
+               SI_ERROR(("%s: Accessing MIPS DMP register (ioctrl) on 47162a0",
+                         __func__));
+               return 0;
+       }
+
+       ai = sii->curwrap;
+
+       if (mask || val) {
+               w = ((R_REG(&ai->ioctrl) & ~mask) | val);
+               W_REG(&ai->ioctrl, w);
+       }
+
+       return R_REG(&ai->ioctrl);
+}
+
+u32 ai_core_sflags(si_t *sih, u32 mask, u32 val)
+{
+       si_info_t *sii;
+       aidmp_t *ai;
+       u32 w;
+
+       sii = SI_INFO(sih);
+       if (BCM47162_DMP()) {
+               SI_ERROR(("%s: Accessing MIPS DMP register (iostatus) on 47162a0", __func__));
+               return 0;
+       }
+
+       ai = sii->curwrap;
+
+       if (mask || val) {
+               w = ((R_REG(&ai->iostatus) & ~mask) | val);
+               W_REG(&ai->iostatus, w);
+       }
+
+       return R_REG(&ai->iostatus);
+}
+
+/* *************** from siutils.c ************** */
 /* local prototypes */
-static si_info_t *si_doattach(si_info_t *sii, uint devid, void *regs,
+static si_info_t *ai_doattach(si_info_t *sii, uint devid, void *regs,
                              uint bustype, void *sdh, char **vars,
                              uint *varsz);
-static bool si_buscore_prep(si_info_t *sii, uint bustype, uint devid,
+static bool ai_buscore_prep(si_info_t *sii, uint bustype, uint devid,
                            void *sdh);
-static bool si_buscore_setup(si_info_t *sii, chipcregs_t *cc, uint bustype,
+static bool ai_buscore_setup(si_info_t *sii, chipcregs_t *cc, uint bustype,
                             u32 savewin, uint *origidx, void *regs);
-static void si_nvram_process(si_info_t *sii, char *pvars);
+static void ai_nvram_process(si_info_t *sii, char *pvars);
 
 /* dev path concatenation util */
-static char *si_devpathvar(si_t *sih, char *var, int len, const char *name);
-static bool _si_clkctl_cc(si_info_t *sii, uint mode);
-static bool si_ispcie(si_info_t *sii);
-static uint socram_banksize(si_info_t *sii, sbsocramregs_t *r,
-                                       u8 idx, u8 mtype);
+static char *ai_devpathvar(si_t *sih, char *var, int len, const char *name);
+static bool _ai_clkctl_cc(si_info_t *sii, uint mode);
+static bool ai_ispcie(si_info_t *sii);
 
 /* global variable to indicate reservation/release of gpio's */
-static u32 si_gpioreservation;
+static u32 ai_gpioreservation;
 
 /*
  * Allocate a si handle.
@@ -82,7 +558,7 @@ static u32 si_gpioreservation;
  * vars - pointer to a pointer area for "environment" variables
  * varsz - pointer to int to return the size of the vars
  */
-si_t *si_attach(uint devid, void *regs, uint bustype,
+si_t *ai_attach(uint devid, void *regs, uint bustype,
                void *sdh, char **vars, uint *varsz)
 {
        si_info_t *sii;
@@ -94,7 +570,7 @@ si_t *si_attach(uint devid, void *regs, uint bustype,
                return NULL;
        }
 
-       if (si_doattach(sii, devid, regs, bustype, sdh, vars, varsz) ==
+       if (ai_doattach(sii, devid, regs, bustype, sdh, vars, varsz) ==
            NULL) {
                kfree(sii);
                return NULL;
@@ -108,74 +584,26 @@ si_t *si_attach(uint devid, void *regs, uint bustype,
 /* global kernel resource */
 static si_info_t ksii;
 
-static bool si_buscore_prep(si_info_t *sii, uint bustype, uint devid,
+static bool ai_buscore_prep(si_info_t *sii, uint bustype, uint devid,
                            void *sdh)
 {
-
-#ifndef BRCM_FULLMAC
        /* kludge to enable the clock on the 4306 which lacks a slowclock */
-       if (bustype == PCI_BUS && !si_ispcie(sii))
-               si_clkctl_xtal(&sii->pub, XTAL | PLL, ON);
-#endif
-
-#if defined(BCMSDIO)
-       if (bustype == SDIO_BUS) {
-               int err;
-               u8 clkset;
-
-               /* Try forcing SDIO core to do ALPAvail request only */
-               clkset = SBSDIO_FORCE_HW_CLKREQ_OFF | SBSDIO_ALP_AVAIL_REQ;
-               bcmsdh_cfg_write(sdh, SDIO_FUNC_1, SBSDIO_FUNC1_CHIPCLKCSR,
-                                clkset, &err);
-               if (!err) {
-                       u8 clkval;
-
-                       /* If register supported, wait for ALPAvail and then force ALP */
-                       clkval =
-                           bcmsdh_cfg_read(sdh, SDIO_FUNC_1,
-                                           SBSDIO_FUNC1_CHIPCLKCSR, NULL);
-                       if ((clkval & ~SBSDIO_AVBITS) == clkset) {
-                               SPINWAIT(((clkval =
-                                          bcmsdh_cfg_read(sdh, SDIO_FUNC_1,
-                                                          SBSDIO_FUNC1_CHIPCLKCSR,
-                                                          NULL)),
-                                         !SBSDIO_ALPAV(clkval)),
-                                        PMU_MAX_TRANSITION_DLY);
-                               if (!SBSDIO_ALPAV(clkval)) {
-                                       SI_ERROR(("timeout on ALPAV wait, clkval 0x%02x\n", clkval));
-                                       return false;
-                               }
-                               clkset =
-                                   SBSDIO_FORCE_HW_CLKREQ_OFF |
-                                   SBSDIO_FORCE_ALP;
-                               bcmsdh_cfg_write(sdh, SDIO_FUNC_1,
-                                                SBSDIO_FUNC1_CHIPCLKCSR,
-                                                clkset, &err);
-                               udelay(65);
-                       }
-               }
-
-               /* Also, disable the extra SDIO pull-ups */
-               bcmsdh_cfg_write(sdh, SDIO_FUNC_1, SBSDIO_FUNC1_SDIOPULLUP, 0,
-                                NULL);
-       }
-#endif                         /* defined(BCMSDIO) */
-
+       if (bustype == PCI_BUS && !ai_ispcie(sii))
+               ai_clkctl_xtal(&sii->pub, XTAL | PLL, ON);
        return true;
 }
 
-static bool si_buscore_setup(si_info_t *sii, chipcregs_t *cc, uint bustype,
+static bool ai_buscore_setup(si_info_t *sii, chipcregs_t *cc, uint bustype,
                             u32 savewin, uint *origidx, void *regs)
 {
        bool pci, pcie;
        uint i;
        uint pciidx, pcieidx, pcirev, pcierev;
 
-       cc = si_setcoreidx(&sii->pub, SI_CC_IDX);
-       ASSERT(cc);
+       cc = ai_setcoreidx(&sii->pub, SI_CC_IDX);
 
        /* get chipcommon rev */
-       sii->pub.ccrev = (int)si_corerev(&sii->pub);
+       sii->pub.ccrev = (int)ai_corerev(&sii->pub);
 
        /* get chipcommon chipstatus */
        if (sii->pub.ccrev >= 11)
@@ -185,22 +613,15 @@ static bool si_buscore_setup(si_info_t *sii, chipcregs_t *cc, uint bustype,
        sii->pub.cccaps = R_REG(&cc->capabilities);
        /* get chipcommon extended capabilities */
 
-#ifndef BRCM_FULLMAC
        if (sii->pub.ccrev >= 35)
                sii->pub.cccaps_ext = R_REG(&cc->capabilities_ext);
-#endif
+
        /* get pmu rev and caps */
        if (sii->pub.cccaps & CC_CAP_PMU) {
                sii->pub.pmucaps = R_REG(&cc->pmucapabilities);
                sii->pub.pmurev = sii->pub.pmucaps & PCAP_REV_MASK;
        }
 
-       /*
-          SI_MSG(("Chipc: rev %d, caps 0x%x, chipst 0x%x pmurev %d, pmucaps 0x%x\n",
-          sii->pub.ccrev, sii->pub.cccaps, sii->pub.chipst, sii->pub.pmurev,
-          sii->pub.pmucaps));
-        */
-
        /* figure out bus/orignal core idx */
        sii->pub.buscoretype = NODEV_CORE_ID;
        sii->pub.buscorerev = NOREV;
@@ -213,9 +634,9 @@ static bool si_buscore_setup(si_info_t *sii, chipcregs_t *cc, uint bustype,
        for (i = 0; i < sii->numcores; i++) {
                uint cid, crev;
 
-               si_setcoreidx(&sii->pub, i);
-               cid = si_coreid(&sii->pub);
-               crev = si_corerev(&sii->pub);
+               ai_setcoreidx(&sii->pub, i);
+               cid = ai_coreid(&sii->pub);
+               crev = ai_corerev(&sii->pub);
 
                /* Display cores found */
                SI_VMSG(("CORE[%d]: id 0x%x rev %d base 0x%x regs 0x%p\n",
@@ -232,15 +653,6 @@ static bool si_buscore_setup(si_info_t *sii, chipcregs_t *cc, uint bustype,
                                pcie = true;
                        }
                }
-#ifdef BCMSDIO
-               else if (((bustype == SDIO_BUS) ||
-                         (bustype == SPI_BUS)) &&
-                        ((cid == PCMCIA_CORE_ID) || (cid == SDIOD_CORE_ID))) {
-                       sii->pub.buscorerev = crev;
-                       sii->pub.buscoretype = cid;
-                       sii->pub.buscoreidx = i;
-               }
-#endif                         /* BCMSDIO */
 
                /* find the core idx before entering this func. */
                if ((savewin && (savewin == sii->coresba[i])) ||
@@ -248,22 +660,8 @@ static bool si_buscore_setup(si_info_t *sii, chipcregs_t *cc, uint bustype,
                        *origidx = i;
        }
 
-#ifdef BRCM_FULLMAC
-       SI_MSG(("Buscore id/type/rev %d/0x%x/%d\n", sii->pub.buscoreidx,
-               sii->pub.buscoretype, sii->pub.buscorerev));
-
-       /* Make sure any on-chip ARM is off (in case strapping is wrong),
-       * or downloaded code was
-       * already running.
-       */
-       if ((bustype == SDIO_BUS) || (bustype == SPI_BUS)) {
-               if (si_setcore(&sii->pub, ARM7S_CORE_ID, 0) ||
-                       si_setcore(&sii->pub, ARMCM3_CORE_ID, 0))
-                       si_core_disable(&sii->pub, 0);
-       }
-#else
        if (pci && pcie) {
-               if (si_ispcie(sii))
+               if (ai_ispcie(sii))
                        pci = false;
                else
                        pcie = false;
@@ -289,212 +687,71 @@ static bool si_buscore_setup(si_info_t *sii, chipcregs_t *cc, uint bustype,
                                        &sii->pub, sii->pbus,
                                        (void *)PCIEREGS(sii));
                                if (sii->pch == NULL)
-                                       return false;
-                       }
-               }
-               if (si_pci_fixcfg(&sii->pub)) {
-                       SI_ERROR(("si_doattach: sb_pci_fixcfg failed\n"));
-                       return false;
-               }
-       }
-#endif
-       /* return to the original core */
-       si_setcoreidx(&sii->pub, *origidx);
-
-       return true;
-}
-
-static __used void si_nvram_process(si_info_t *sii, char *pvars)
-{
-       uint w = 0;
-
-       /* get boardtype and boardrev */
-       switch (sii->pub.bustype) {
-       case PCI_BUS:
-               /* do a pci config read to get subsystem id and subvendor id */
-               pci_read_config_dword(sii->pbus, PCI_CFG_SVID, &w);
-               /* Let nvram variables override subsystem Vend/ID */
-               sii->pub.boardvendor = (u16)si_getdevpathintvar(&sii->pub,
-                       "boardvendor");
-               if (sii->pub.boardvendor == 0)
-                       sii->pub.boardvendor = w & 0xffff;
-               else
-                       SI_ERROR(("Overriding boardvendor: 0x%x instead of 0x%x\n", sii->pub.boardvendor, w & 0xffff));
-               sii->pub.boardtype = (u16)si_getdevpathintvar(&sii->pub,
-                       "boardtype");
-               if (sii->pub.boardtype == 0)
-                       sii->pub.boardtype = (w >> 16) & 0xffff;
-               else
-                       SI_ERROR(("Overriding boardtype: 0x%x instead of 0x%x\n", sii->pub.boardtype, (w >> 16) & 0xffff));
-               break;
-
-#ifdef BCMSDIO
-       case SDIO_BUS:
-#endif
-               sii->pub.boardvendor = getintvar(pvars, "manfid");
-               sii->pub.boardtype = getintvar(pvars, "prodid");
-               break;
-
-#ifdef BCMSDIO
-       case SPI_BUS:
-               sii->pub.boardvendor = VENDOR_BROADCOM;
-               sii->pub.boardtype = SPI_BOARD;
-               break;
-#endif
-
-       case SI_BUS:
-       case JTAG_BUS:
-               sii->pub.boardvendor = VENDOR_BROADCOM;
-               sii->pub.boardtype = getintvar(pvars, "prodid");
-               if (pvars == NULL || (sii->pub.boardtype == 0)) {
-                       sii->pub.boardtype = getintvar(NULL, "boardtype");
-                       if (sii->pub.boardtype == 0)
-                               sii->pub.boardtype = 0xffff;
-               }
-               break;
-       }
-
-       if (sii->pub.boardtype == 0) {
-               SI_ERROR(("si_doattach: unknown board type\n"));
-               ASSERT(sii->pub.boardtype);
-       }
-
-       sii->pub.boardflags = getintvar(pvars, "boardflags");
-}
-
-/* this is will make Sonics calls directly, since Sonics is no longer supported in the Si abstraction */
-/* this has been customized for the bcm 4329 ONLY */
-#ifdef BCMSDIO
-static si_info_t *si_doattach(si_info_t *sii, uint devid,
-                             void *regs, uint bustype, void *pbus,
-                             char **vars, uint *varsz)
-{
-       struct si_pub *sih = &sii->pub;
-       u32 w, savewin;
-       chipcregs_t *cc;
-       char *pvars = NULL;
-       uint origidx;
-
-       ASSERT(GOODREGS(regs));
-
-       memset((unsigned char *) sii, 0, sizeof(si_info_t));
-
-       savewin = 0;
-
-       sih->buscoreidx = BADIDX;
-
-       sii->curmap = regs;
-       sii->pbus = pbus;
-
-       /* find Chipcommon address */
-       cc = (chipcregs_t *) sii->curmap;
-       sih->bustype = bustype;
-
-       /* bus/core/clk setup for register access */
-       if (!si_buscore_prep(sii, bustype, devid, pbus)) {
-               SI_ERROR(("si_doattach: si_core_clk_prep failed %d\n",
-                         bustype));
-               return NULL;
-       }
-
-       /* ChipID recognition.
-        *   We assume we can read chipid at offset 0 from the regs arg.
-        *   If we add other chiptypes (or if we need to support old sdio hosts w/o chipcommon),
-        *   some way of recognizing them needs to be added here.
-        */
-       w = R_REG(&cc->chipid);
-       sih->socitype = (w & CID_TYPE_MASK) >> CID_TYPE_SHIFT;
-       /* Might as wll fill in chip id rev & pkg */
-       sih->chip = w & CID_ID_MASK;
-       sih->chiprev = (w & CID_REV_MASK) >> CID_REV_SHIFT;
-       sih->chippkg = (w & CID_PKG_MASK) >> CID_PKG_SHIFT;
-
-       if ((sih->chip == BCM4329_CHIP_ID) &&
-               (sih->chippkg != BCM4329_289PIN_PKG_ID))
-                       sih->chippkg = BCM4329_182PIN_PKG_ID;
-
-       sih->issim = IS_SIM(sih->chippkg);
-
-       /* scan for cores */
-       /* SI_MSG(("Found chip type SB (0x%08x)\n", w)); */
-       sb_scan(&sii->pub, regs, devid);
-
-       /* no cores found, bail out */
-       if (sii->numcores == 0) {
-               SI_ERROR(("si_doattach: could not find any cores\n"));
-               return NULL;
-       }
-       /* bus/core/clk setup */
-       origidx = SI_CC_IDX;
-       if (!si_buscore_setup(sii, cc, bustype, savewin, &origidx, regs)) {
-               SI_ERROR(("si_doattach: si_buscore_setup failed\n"));
-               goto exit;
-       }
-
-#ifdef BRCM_FULLMAC
-       pvars = NULL;
-#else
-       /* Init nvram from flash if it exists */
-       nvram_init((void *)&(sii->pub));
-
-       /* Init nvram from sprom/otp if they exist */
-       if (srom_var_init
-           (&sii->pub, bustype, regs, sii->osh, vars, varsz)) {
-               SI_ERROR(("si_doattach: srom_var_init failed: bad srom\n"));
-               goto exit;
+                                       return false;
+                       }
+               }
+               if (ai_pci_fixcfg(&sii->pub)) {
+                       SI_ERROR(("si_doattach: si_pci_fixcfg failed\n"));
+                       return false;
+               }
        }
-       pvars = vars ? *vars : NULL;
-       si_nvram_process(sii, pvars);
-#endif
 
-       /* === NVRAM, clock is ready === */
+       /* return to the original core */
+       ai_setcoreidx(&sii->pub, *origidx);
 
-#ifdef BRCM_FULLMAC
-       if (sii->pub.ccrev >= 20) {
-#endif
-       cc = (chipcregs_t *) si_setcore(sih, CC_CORE_ID, 0);
-       W_REG(&cc->gpiopullup, 0);
-       W_REG(&cc->gpiopulldown, 0);
-       sb_setcoreidx(sih, origidx);
-#ifdef BRCM_FULLMAC
-       }
-#endif
+       return true;
+}
 
-#ifndef BRCM_FULLMAC
-       /* PMU specific initializations */
-       if (PMUCTL_ENAB(sih)) {
-               u32 xtalfreq;
-               si_pmu_init(sih);
-               si_pmu_chip_init(sih);
-               xtalfreq = getintvar(pvars, "xtalfreq");
-               /* If xtalfreq var not available, try to measure it */
-               if (xtalfreq == 0)
-                       xtalfreq = si_pmu_measure_alpclk(sih);
-               si_pmu_pll_init(sih, xtalfreq);
-               si_pmu_res_init(sih);
-               si_pmu_swreg_init(sih);
-       }
+static __used void ai_nvram_process(si_info_t *sii, char *pvars)
+{
+       uint w = 0;
 
-       /* setup the GPIO based LED powersave register */
-       w = getintvar(pvars, "leddc");
-       if (w == 0)
-               w = DEFAULT_GPIOTIMERVAL;
-       sb_corereg(sih, SI_CC_IDX, offsetof(chipcregs_t, gpiotimerval), ~0, w);
+       /* get boardtype and boardrev */
+       switch (sii->pub.bustype) {
+       case PCI_BUS:
+               /* do a pci config read to get subsystem id and subvendor id */
+               pci_read_config_dword(sii->pbus, PCI_SUBSYSTEM_VENDOR_ID, &w);
+               /* Let nvram variables override subsystem Vend/ID */
+               sii->pub.boardvendor = (u16)ai_getdevpathintvar(&sii->pub,
+                       "boardvendor");
+               if (sii->pub.boardvendor == 0)
+                       sii->pub.boardvendor = w & 0xffff;
+               else
+                       SI_ERROR(("Overriding boardvendor: 0x%x instead of "
+                                 "0x%x\n", sii->pub.boardvendor, w & 0xffff));
+               sii->pub.boardtype = (u16)ai_getdevpathintvar(&sii->pub,
+                       "boardtype");
+               if (sii->pub.boardtype == 0)
+                       sii->pub.boardtype = (w >> 16) & 0xffff;
+               else
+                       SI_ERROR(("Overriding boardtype: 0x%x instead of 0x%x\n"
+                                 , sii->pub.boardtype, (w >> 16) & 0xffff));
+               break;
 
-#ifdef BCMDBG
-       /* clear any previous epidiag-induced target abort */
-       sb_taclear(sih, false);
-#endif                         /* BCMDBG */
-#endif
+               sii->pub.boardvendor = getintvar(pvars, "manfid");
+               sii->pub.boardtype = getintvar(pvars, "prodid");
+               break;
 
-       return sii;
+       case SI_BUS:
+       case JTAG_BUS:
+               sii->pub.boardvendor = PCI_VENDOR_ID_BROADCOM;
+               sii->pub.boardtype = getintvar(pvars, "prodid");
+               if (pvars == NULL || (sii->pub.boardtype == 0)) {
+                       sii->pub.boardtype = getintvar(NULL, "boardtype");
+                       if (sii->pub.boardtype == 0)
+                               sii->pub.boardtype = 0xffff;
+               }
+               break;
+       }
 
- exit:
-       return NULL;
+       if (sii->pub.boardtype == 0) {
+               SI_ERROR(("si_doattach: unknown board type\n"));
+       }
+
+       sii->pub.boardflags = getintvar(pvars, "boardflags");
 }
 
-#else                          /* BCMSDIO */
-static si_info_t *si_doattach(si_info_t *sii, uint devid,
+static si_info_t *ai_doattach(si_info_t *sii, uint devid,
                              void *regs, uint bustype, void *pbus,
                              char **vars, uint *varsz)
 {
@@ -502,10 +759,9 @@ static si_info_t *si_doattach(si_info_t *sii, uint devid,
        u32 w, savewin;
        chipcregs_t *cc;
        char *pvars = NULL;
+       uint socitype;
        uint origidx;
 
-       ASSERT(GOODREGS(regs));
-
        memset((unsigned char *) sii, 0, sizeof(si_info_t));
 
        savewin = 0;
@@ -541,19 +797,21 @@ static si_info_t *si_doattach(si_info_t *sii, uint devid,
        sih->bustype = bustype;
 
        /* bus/core/clk setup for register access */
-       if (!si_buscore_prep(sii, bustype, devid, pbus)) {
+       if (!ai_buscore_prep(sii, bustype, devid, pbus)) {
                SI_ERROR(("si_doattach: si_core_clk_prep failed %d\n",
                          bustype));
                return NULL;
        }
 
-       /* ChipID recognition.
+       /*
+        * ChipID recognition.
         *   We assume we can read chipid at offset 0 from the regs arg.
-        *   If we add other chiptypes (or if we need to support old sdio hosts w/o chipcommon),
-        *   some way of recognizing them needs to be added here.
+        *   If we add other chiptypes (or if we need to support old sdio
+        *   hosts w/o chipcommon), some way of recognizing them needs to
+        *   be added here.
         */
        w = R_REG(&cc->chipid);
-       sih->socitype = (w & CID_TYPE_MASK) >> CID_TYPE_SHIFT;
+       socitype = (w & CID_TYPE_MASK) >> CID_TYPE_SHIFT;
        /* Might as wll fill in chip id rev & pkg */
        sih->chip = w & CID_ID_MASK;
        sih->chiprev = (w & CID_REV_MASK) >> CID_REV_SHIFT;
@@ -562,7 +820,7 @@ static si_info_t *si_doattach(si_info_t *sii, uint devid,
        sih->issim = IS_SIM(sih->chippkg);
 
        /* scan for cores */
-       if (sii->pub.socitype == SOCI_AI) {
+       if (socitype == SOCI_AI) {
                SI_MSG(("Found chip type AI (0x%08x)\n", w));
                /* pass chipc address instead of original core base */
                ai_scan(&sii->pub, (void *)cc, devid);
@@ -577,7 +835,7 @@ static si_info_t *si_doattach(si_info_t *sii, uint devid,
        }
        /* bus/core/clk setup */
        origidx = SI_CC_IDX;
-       if (!si_buscore_setup(sii, cc, bustype, savewin, &origidx, regs)) {
+       if (!ai_buscore_setup(sii, cc, bustype, savewin, &origidx, regs)) {
                SI_ERROR(("si_doattach: si_buscore_setup failed\n"));
                goto exit;
        }
@@ -602,7 +860,7 @@ static si_info_t *si_doattach(si_info_t *sii, uint devid,
        }
 
        /* Init nvram from flash if it exists */
-       nvram_init((void *)&(sii->pub));
+       nvram_init();
 
        /* Init nvram from sprom/otp if they exist */
        if (srom_var_init
@@ -611,13 +869,13 @@ static si_info_t *si_doattach(si_info_t *sii, uint devid,
                goto exit;
        }
        pvars = vars ? *vars : NULL;
-       si_nvram_process(sii, pvars);
+       ai_nvram_process(sii, pvars);
 
        /* === NVRAM, clock is ready === */
-       cc = (chipcregs_t *) si_setcore(sih, CC_CORE_ID, 0);
+       cc = (chipcregs_t *) ai_setcore(sih, CC_CORE_ID, 0);
        W_REG(&cc->gpiopullup, 0);
        W_REG(&cc->gpiopulldown, 0);
-       si_setcoreidx(sih, origidx);
+       ai_setcoreidx(sih, origidx);
 
        /* PMU specific initializations */
        if (PMUCTL_ENAB(sih)) {
@@ -637,19 +895,21 @@ static si_info_t *si_doattach(si_info_t *sii, uint devid,
        w = getintvar(pvars, "leddc");
        if (w == 0)
                w = DEFAULT_GPIOTIMERVAL;
-       si_corereg(sih, SI_CC_IDX, offsetof(chipcregs_t, gpiotimerval), ~0, w);
+       ai_corereg(sih, SI_CC_IDX, offsetof(chipcregs_t, gpiotimerval), ~0, w);
 
        if (PCIE(sii)) {
-               ASSERT(sii->pch != NULL);
                pcicore_attach(sii->pch, pvars, SI_DOATTACH);
        }
 
        if ((sih->chip == BCM43224_CHIP_ID) ||
            (sih->chip == BCM43421_CHIP_ID)) {
-               /* enable 12 mA drive strenth for 43224 and set chipControl register bit 15 */
+               /*
+                * enable 12 mA drive strenth for 43224 and
+                * set chipControl register bit 15
+                */
                if (sih->chiprev == 0) {
                        SI_MSG(("Applying 43224A0 WARs\n"));
-                       si_corereg(sih, SI_CC_IDX,
+                       ai_corereg(sih, SI_CC_IDX,
                                   offsetof(chipcregs_t, chipcontrol),
                                   CCTRL43224_GPIO_TOGGLE,
                                   CCTRL43224_GPIO_TOGGLE);
@@ -664,7 +924,10 @@ static si_info_t *si_doattach(si_info_t *sii, uint devid,
        }
 
        if (sih->chip == BCM4313_CHIP_ID) {
-               /* enable 12 mA drive strenth for 4313 and set chipControl register bit 1 */
+               /*
+                * enable 12 mA drive strenth for 4313 and
+                * set chipControl register bit 1
+                */
                SI_MSG(("Applying 4313 WARs\n"));
                si_pmu_chipcontrol(sih, 0, CCTRL_4313_12MA_LED_DRIVE,
                                   CCTRL_4313_12MA_LED_DRIVE);
@@ -672,7 +935,7 @@ static si_info_t *si_doattach(si_info_t *sii, uint devid,
 
        if (sih->chip == BCM4331_CHIP_ID) {
                /* Enable Ext PA lines depending on chip package option */
-               si_chipcontrl_epa4331(sih, true);
+               ai_chipcontrl_epa4331(sih, true);
        }
 
        return sii;
@@ -685,16 +948,15 @@ static si_info_t *si_doattach(si_info_t *sii, uint devid,
 
        return NULL;
 }
-#endif                         /* BCMSDIO */
 
 /* may be called with core in reset */
-void si_detach(si_t *sih)
+void ai_detach(si_t *sih)
 {
        si_info_t *sii;
        uint idx;
 
        struct si_pub *si_local = NULL;
-       memcpy(&si_local, &sih, sizeof(si_t **));
+       bcopy(&sih, &si_local, sizeof(si_t **));
 
        sii = SI_INFO(sih);
 
@@ -708,24 +970,21 @@ void si_detach(si_t *sih)
                                sii->regs[idx] = NULL;
                        }
 
-#ifndef BRCM_FULLMAC
-       nvram_exit((void *)si_local);   /* free up nvram buffers */
+       nvram_exit();   /* free up nvram buffers */
 
        if (sih->bustype == PCI_BUS) {
                if (sii->pch)
                        pcicore_deinit(sii->pch);
                sii->pch = NULL;
        }
-#endif
-#if !defined(BCMBUSTYPE) || (BCMBUSTYPE == SI_BUS)
+
        if (sii != &ksii)
-#endif                         /* !BCMBUSTYPE || (BCMBUSTYPE == SI_BUS) */
                kfree(sii);
 }
 
 /* register driver interrupt disabling and restoring callback functions */
 void
-si_register_intr_callback(si_t *sih, void *intrsoff_fn, void *intrsrestore_fn,
+ai_register_intr_callback(si_t *sih, void *intrsoff_fn, void *intrsrestore_fn,
                          void *intrsenabled_fn, void *intr_arg)
 {
        si_info_t *sii;
@@ -741,7 +1000,7 @@ si_register_intr_callback(si_t *sih, void *intrsoff_fn, void *intrsrestore_fn,
        sii->dev_coreid = sii->coreid[sii->curidx];
 }
 
-void si_deregister_intr_callback(si_t *sih)
+void ai_deregister_intr_callback(si_t *sih)
 {
        si_info_t *sii;
 
@@ -749,35 +1008,15 @@ void si_deregister_intr_callback(si_t *sih)
        sii->intrsoff_fn = NULL;
 }
 
-uint si_flag(si_t *sih)
-{
-       if (sih->socitype == SOCI_AI)
-               return ai_flag(sih);
-       else {
-               ASSERT(0);
-               return 0;
-       }
-}
-
-void si_setint(si_t *sih, int siflag)
-{
-       if (sih->socitype == SOCI_AI)
-               ai_setint(sih, siflag);
-       else
-               ASSERT(0);
-}
-
-#ifndef BCMSDIO
-uint si_coreid(si_t *sih)
+uint ai_coreid(si_t *sih)
 {
        si_info_t *sii;
 
        sii = SI_INFO(sih);
        return sii->coreid[sii->curidx];
 }
-#endif
 
-uint si_coreidx(si_t *sih)
+uint ai_coreidx(si_t *sih)
 {
        si_info_t *sii;
 
@@ -785,25 +1024,13 @@ uint si_coreidx(si_t *sih)
        return sii->curidx;
 }
 
-bool si_backplane64(si_t *sih)
+bool ai_backplane64(si_t *sih)
 {
        return (sih->cccaps & CC_CAP_BKPLN64) != 0;
 }
 
-#ifndef BCMSDIO
-uint si_corerev(si_t *sih)
-{
-       if (sih->socitype == SOCI_AI)
-               return ai_corerev(sih);
-       else {
-               ASSERT(0);
-               return 0;
-       }
-}
-#endif
-
 /* return index of coreid or BADIDX if not found */
-uint si_findcoreidx(si_t *sih, uint coreid, uint coreunit)
+uint ai_findcoreidx(si_t *sih, uint coreid, uint coreunit)
 {
        si_info_t *sii;
        uint found;
@@ -826,42 +1053,22 @@ uint si_findcoreidx(si_t *sih, uint coreid, uint coreunit)
 /*
  * This function changes logical "focus" to the indicated core;
  * must be called with interrupts off.
- * Moreover, callers should keep interrupts off during switching out of and back to d11 core
+ * Moreover, callers should keep interrupts off during switching
+ * out of and back to d11 core.
  */
-void *si_setcore(si_t *sih, uint coreid, uint coreunit)
+void *ai_setcore(si_t *sih, uint coreid, uint coreunit)
 {
        uint idx;
 
-       idx = si_findcoreidx(sih, coreid, coreunit);
+       idx = ai_findcoreidx(sih, coreid, coreunit);
        if (!GOODIDX(idx))
                return NULL;
 
-       if (sih->socitype == SOCI_AI)
-               return ai_setcoreidx(sih, idx);
-       else {
-#ifdef BCMSDIO
-               return sb_setcoreidx(sih, idx);
-#else
-               ASSERT(0);
-               return NULL;
-#endif
-       }
-}
-
-#ifndef BCMSDIO
-void *si_setcoreidx(si_t *sih, uint coreidx)
-{
-       if (sih->socitype == SOCI_AI)
-               return ai_setcoreidx(sih, coreidx);
-       else {
-               ASSERT(0);
-               return NULL;
-       }
+       return ai_setcoreidx(sih, idx);
 }
-#endif
 
-/* Turn off interrupt as required by sb_setcore, before switch core */
-void *si_switch_core(si_t *sih, uint coreid, uint *origidx, uint *intr_val)
+/* Turn off interrupt as required by ai_setcore, before switch core */
+void *ai_switch_core(si_t *sih, uint coreid, uint *origidx, uint *intr_val)
 {
        void *cc;
        si_info_t *sii;
@@ -881,14 +1088,12 @@ void *si_switch_core(si_t *sih, uint coreid, uint *origidx, uint *intr_val)
        }
        INTR_OFF(sii, *intr_val);
        *origidx = sii->curidx;
-       cc = si_setcore(sih, coreid, 0);
-       ASSERT(cc != NULL);
-
+       cc = ai_setcore(sih, coreid, 0);
        return cc;
 }
 
 /* restore coreidx and restore interrupt */
-void si_restore_core(si_t *sih, uint coreid, uint intr_val)
+void ai_restore_core(si_t *sih, uint coreid, uint intr_val)
 {
        si_info_t *sii;
 
@@ -897,183 +1102,173 @@ void si_restore_core(si_t *sih, uint coreid, uint intr_val)
            && ((coreid == CC_CORE_ID) || (coreid == sih->buscoretype)))
                return;
 
-       si_setcoreidx(sih, coreid);
+       ai_setcoreidx(sih, coreid);
        INTR_RESTORE(sii, intr_val);
 }
 
-u32 si_core_cflags(si_t *sih, u32 mask, u32 val)
+void ai_write_wrapperreg(si_t *sih, u32 offset, u32 val)
 {
-       if (sih->socitype == SOCI_AI)
-               return ai_core_cflags(sih, mask, val);
-       else {
-               ASSERT(0);
-               return 0;
-       }
+       si_info_t *sii = SI_INFO(sih);
+       u32 *w = (u32 *) sii->curwrap;
+       W_REG(w + (offset / 4), val);
+       return;
 }
 
-u32 si_core_sflags(si_t *sih, u32 mask, u32 val)
+/*
+ * Switch to 'coreidx', issue a single arbitrary 32bit register mask&set
+ * operation, switch back to the original core, and return the new value.
+ *
+ * When using the silicon backplane, no fiddling with interrupts or core
+ * switches is needed.
+ *
+ * Also, when using pci/pcie, we can optimize away the core switching for pci
+ * registers and (on newer pci cores) chipcommon registers.
+ */
+uint ai_corereg(si_t *sih, uint coreidx, uint regoff, uint mask, uint val)
 {
-       if (sih->socitype == SOCI_AI)
-               return ai_core_sflags(sih, mask, val);
-       else {
-               ASSERT(0);
+       uint origidx = 0;
+       u32 *r = NULL;
+       uint w;
+       uint intr_val = 0;
+       bool fast = false;
+       si_info_t *sii;
+
+       sii = SI_INFO(sih);
+
+       if (coreidx >= SI_MAXCORES)
                return 0;
-       }
-}
 
-bool si_iscoreup(si_t *sih)
-{
-       if (sih->socitype == SOCI_AI)
-               return ai_iscoreup(sih);
-       else {
-#ifdef BCMSDIO
-               return sb_iscoreup(sih);
-#else
-               ASSERT(0);
-               return false;
-#endif
+       if (sih->bustype == SI_BUS) {
+               /* If internal bus, we can always get at everything */
+               fast = true;
+               /* map if does not exist */
+               if (!sii->regs[coreidx]) {
+                       sii->regs[coreidx] = REG_MAP(sii->coresba[coreidx],
+                                                    SI_CORE_SIZE);
+               }
+               r = (u32 *) ((unsigned char *) sii->regs[coreidx] + regoff);
+       } else if (sih->bustype == PCI_BUS) {
+               /*
+                * If pci/pcie, we can get at pci/pcie regs
+                * and on newer cores to chipc
+                */
+               if ((sii->coreid[coreidx] == CC_CORE_ID) && SI_FAST(sii)) {
+                       /* Chipc registers are mapped at 12KB */
+
+                       fast = true;
+                       r = (u32 *) ((char *)sii->curmap +
+                                       PCI_16KB0_CCREGS_OFFSET + regoff);
+               } else if (sii->pub.buscoreidx == coreidx) {
+                       /*
+                        * pci registers are at either in the last 2KB of
+                        * an 8KB window or, in pcie and pci rev 13 at 8KB
+                        */
+                       fast = true;
+                       if (SI_FAST(sii))
+                               r = (u32 *) ((char *)sii->curmap +
+                                               PCI_16KB0_PCIREGS_OFFSET +
+                                               regoff);
+                       else
+                               r = (u32 *) ((char *)sii->curmap +
+                                               ((regoff >= SBCONFIGOFF) ?
+                                                PCI_BAR0_PCISBR_OFFSET :
+                                                PCI_BAR0_PCIREGS_OFFSET) +
+                                               regoff);
+               }
        }
-}
 
-void si_write_wrapperreg(si_t *sih, u32 offset, u32 val)
-{
-       /* only for 4319, no requirement for SOCI_SB */
-       if (sih->socitype == SOCI_AI) {
-               ai_write_wrap_reg(sih, offset, val);
-       }
-}
+       if (!fast) {
+               INTR_OFF(sii, intr_val);
 
-uint si_corereg(si_t *sih, uint coreidx, uint regoff, uint mask, uint val)
-{
+               /* save current core index */
+               origidx = ai_coreidx(&sii->pub);
 
-       if (sih->socitype == SOCI_AI)
-               return ai_corereg(sih, coreidx, regoff, mask, val);
-       else {
-#ifdef BCMSDIO
-               return sb_corereg(sih, coreidx, regoff, mask, val);
-#else
-               ASSERT(0);
-               return 0;
-#endif
+               /* switch core */
+               r = (u32 *) ((unsigned char *) ai_setcoreidx(&sii->pub, coreidx)
+                               + regoff);
        }
-}
 
-void si_core_disable(si_t *sih, u32 bits)
-{
+       /* mask and set */
+       if (mask || val) {
+               w = (R_REG(r) & ~mask) | val;
+               W_REG(r, w);
+       }
 
-       if (sih->socitype == SOCI_AI)
-               ai_core_disable(sih, bits);
-#ifdef BCMSDIO
-       else
-               sb_core_disable(sih, bits);
-#endif
-}
+       /* readback */
+       w = R_REG(r);
 
-void si_core_reset(si_t *sih, u32 bits, u32 resetbits)
-{
-       if (sih->socitype == SOCI_AI)
-               ai_core_reset(sih, bits, resetbits);
-#ifdef BCMSDIO
-       else
-               sb_core_reset(sih, bits, resetbits);
-#endif
-}
+       if (!fast) {
+               /* restore core index */
+               if (origidx != coreidx)
+                       ai_setcoreidx(&sii->pub, origidx);
 
-u32 si_alp_clock(si_t *sih)
-{
-       if (PMUCTL_ENAB(sih))
-               return si_pmu_alp_clock(sih);
+               INTR_RESTORE(sii, intr_val);
+       }
 
-       return ALP_CLOCK;
+       return w;
 }
 
-u32 si_ilp_clock(si_t *sih)
+void ai_core_disable(si_t *sih, u32 bits)
 {
-       if (PMUCTL_ENAB(sih))
-               return si_pmu_ilp_clock(sih);
-
-       return ILP_CLOCK;
-}
+       si_info_t *sii;
+       u32 dummy;
+       aidmp_t *ai;
 
-/* set chip watchdog reset timer to fire in 'ticks' */
-#ifdef BRCM_FULLMAC
-void
-si_watchdog(si_t *sih, uint ticks)
-{
-       if (PMUCTL_ENAB(sih)) {
+       sii = SI_INFO(sih);
 
-               if ((sih->chip == BCM4319_CHIP_ID) && (sih->chiprev == 0) &&
-                       (ticks != 0)) {
-                       si_corereg(sih, SI_CC_IDX, offsetof(chipcregs_t,
-                       clk_ctl_st), ~0, 0x2);
-                       si_setcore(sih, USB20D_CORE_ID, 0);
-                       si_core_disable(sih, 1);
-                       si_setcore(sih, CC_CORE_ID, 0);
-               }
+       ai = sii->curwrap;
 
-               if (ticks == 1)
-                       ticks = 2;
-               si_corereg(sih, SI_CC_IDX, offsetof(chipcregs_t, pmuwatchdog),
-                       ~0, ticks);
-       } else {
-               /* instant NMI */
-               si_corereg(sih, SI_CC_IDX, offsetof(chipcregs_t, watchdog),
-                       ~0, ticks);
-       }
-}
-#else
-void si_watchdog(si_t *sih, uint ticks)
-{
-       uint nb, maxt;
+       /* if core is already in reset, just return */
+       if (R_REG(&ai->resetctrl) & AIRC_RESET)
+               return;
 
-       if (PMUCTL_ENAB(sih)) {
+       W_REG(&ai->ioctrl, bits);
+       dummy = R_REG(&ai->ioctrl);
+       udelay(10);
 
-               if ((sih->chip == BCM4319_CHIP_ID) &&
-                   (sih->chiprev == 0) && (ticks != 0)) {
-                       si_corereg(sih, SI_CC_IDX,
-                                  offsetof(chipcregs_t, clk_ctl_st), ~0, 0x2);
-                       si_setcore(sih, USB20D_CORE_ID, 0);
-                       si_core_disable(sih, 1);
-                       si_setcore(sih, CC_CORE_ID, 0);
-               }
+       W_REG(&ai->resetctrl, AIRC_RESET);
+       udelay(1);
+}
 
-               nb = (sih->ccrev < 26) ? 16 : ((sih->ccrev >= 37) ? 32 : 24);
-               /* The mips compiler uses the sllv instruction,
-                * so we specially handle the 32-bit case.
-                */
-               if (nb == 32)
-                       maxt = 0xffffffff;
-               else
-                       maxt = ((1 << nb) - 1);
+/* reset and re-enable a core
+ * inputs:
+ * bits - core specific bits that are set during and after reset sequence
+ * resetbits - core specific bits that are set only during reset sequence
+ */
+void ai_core_reset(si_t *sih, u32 bits, u32 resetbits)
+{
+       si_info_t *sii;
+       aidmp_t *ai;
+       u32 dummy;
 
-               if (ticks == 1)
-                       ticks = 2;
-               else if (ticks > maxt)
-                       ticks = maxt;
+       sii = SI_INFO(sih);
+       ai = sii->curwrap;
 
-               si_corereg(sih, SI_CC_IDX, offsetof(chipcregs_t, pmuwatchdog),
-                          ~0, ticks);
-       } else {
-               /* make sure we come up in fast clock mode; or if clearing, clear clock */
-               si_clkctl_cc(sih, ticks ? CLK_FAST : CLK_DYNAMIC);
-               maxt = (1 << 28) - 1;
-               if (ticks > maxt)
-                       ticks = maxt;
+       /*
+        * Must do the disable sequence first to work
+        * for arbitrary current core state.
+        */
+       ai_core_disable(sih, (bits | resetbits));
 
-               si_corereg(sih, SI_CC_IDX, offsetof(chipcregs_t, watchdog), ~0,
-                          ticks);
-       }
+       /*
+        * Now do the initialization sequence.
+        */
+       W_REG(&ai->ioctrl, (bits | SICF_FGC | SICF_CLOCK_EN));
+       dummy = R_REG(&ai->ioctrl);
+       W_REG(&ai->resetctrl, 0);
+       udelay(1);
+
+       W_REG(&ai->ioctrl, (bits | SICF_CLOCK_EN));
+       dummy = R_REG(&ai->ioctrl);
+       udelay(1);
 }
-#endif
 
 /* return the slow clock source - LPO, XTAL, or PCI */
-static uint si_slowclk_src(si_info_t *sii)
+static uint ai_slowclk_src(si_info_t *sii)
 {
        chipcregs_t *cc;
        u32 val;
 
-       ASSERT(SI_FAST(sii) || si_coreid(&sii->pub) == CC_CORE_ID);
-
        if (sii->pub.ccrev < 6) {
                if (sii->pub.bustype == PCI_BUS) {
                        pci_read_config_dword(sii->pbus, PCI_GPIO_OUT,
@@ -1083,24 +1278,22 @@ static uint si_slowclk_src(si_info_t *sii)
                }
                return SCC_SS_XTAL;
        } else if (sii->pub.ccrev < 10) {
-               cc = (chipcregs_t *) si_setcoreidx(&sii->pub, sii->curidx);
+               cc = (chipcregs_t *) ai_setcoreidx(&sii->pub, sii->curidx);
                return R_REG(&cc->slow_clk_ctl) & SCC_SS_MASK;
        } else                  /* Insta-clock */
                return SCC_SS_XTAL;
 }
 
-/* return the ILP (slowclock) min or max frequency */
-static uint si_slowclk_freq(si_info_t *sii, bool max_freq, chipcregs_t *cc)
+/*
+* return the ILP (slowclock) min or max frequency
+* precondition: we've established the chip has dynamic clk control
+*/
+static uint ai_slowclk_freq(si_info_t *sii, bool max_freq, chipcregs_t *cc)
 {
        u32 slowclk;
        uint div;
 
-       ASSERT(SI_FAST(sii) || si_coreid(&sii->pub) == CC_CORE_ID);
-
-       /* shouldn't be here unless we've established the chip has dynamic clk control */
-       ASSERT(R_REG(&cc->capabilities) & CC_CAP_PWR_CTL);
-
-       slowclk = si_slowclk_src(sii);
+       slowclk = ai_slowclk_src(sii);
        if (sii->pub.ccrev < 6) {
                if (slowclk == SCC_SS_PCI)
                        return max_freq ? (PCIMAXFREQ / 64)
@@ -1120,8 +1313,6 @@ static uint si_slowclk_freq(si_info_t *sii, bool max_freq, chipcregs_t *cc)
                else if (slowclk == SCC_SS_PCI)
                        return max_freq ? (PCIMAXFREQ / div)
                                : (PCIMINFREQ / div);
-               else
-                       ASSERT(0);
        } else {
                /* Chipc rev 10 is InstaClock */
                div = R_REG(&cc->system_clk_ctl) >> SYCC_CD_SHIFT;
@@ -1131,7 +1322,7 @@ static uint si_slowclk_freq(si_info_t *sii, bool max_freq, chipcregs_t *cc)
        return 0;
 }
 
-static void si_clkctl_setdelay(si_info_t *sii, void *chipcregs)
+static void ai_clkctl_setdelay(si_info_t *sii, void *chipcregs)
 {
        chipcregs_t *cc = (chipcregs_t *) chipcregs;
        uint slowmaxfreq, pll_delay, slowclk;
@@ -1139,17 +1330,19 @@ static void si_clkctl_setdelay(si_info_t *sii, void *chipcregs)
 
        pll_delay = PLL_DELAY;
 
-       /* If the slow clock is not sourced by the xtal then add the xtal_on_delay
-        * since the xtal will also be powered down by dynamic clk control logic.
+       /*
+        * If the slow clock is not sourced by the xtal then
+        * add the xtal_on_delay since the xtal will also be
+        * powered down by dynamic clk control logic.
         */
 
-       slowclk = si_slowclk_src(sii);
+       slowclk = ai_slowclk_src(sii);
        if (slowclk != SCC_SS_XTAL)
                pll_delay += XTAL_ON_DELAY;
 
        /* Starting with 4318 it is ILP that is used for the delays */
        slowmaxfreq =
-           si_slowclk_freq(sii, (sii->pub.ccrev >= 10) ? false : true, cc);
+           ai_slowclk_freq(sii, (sii->pub.ccrev >= 10) ? false : true, cc);
 
        pll_on_delay = ((slowmaxfreq * pll_delay) + 999999) / 1000000;
        fref_sel_delay = ((slowmaxfreq * FREF_DELAY) + 999999) / 1000000;
@@ -1159,7 +1352,7 @@ static void si_clkctl_setdelay(si_info_t *sii, void *chipcregs)
 }
 
 /* initialize power control delay registers */
-void si_clkctl_init(si_t *sih)
+void ai_clkctl_init(si_t *sih)
 {
        si_info_t *sii;
        uint origidx = 0;
@@ -1173,7 +1366,7 @@ void si_clkctl_init(si_t *sih)
        fast = SI_FAST(sii);
        if (!fast) {
                origidx = sii->curidx;
-               cc = (chipcregs_t *) si_setcore(sih, CC_CORE_ID, 0);
+               cc = (chipcregs_t *) ai_setcore(sih, CC_CORE_ID, 0);
                if (cc == NULL)
                        return;
        } else {
@@ -1181,21 +1374,23 @@ void si_clkctl_init(si_t *sih)
                if (cc == NULL)
                        return;
        }
-       ASSERT(cc != NULL);
 
        /* set all Instaclk chip ILP to 1 MHz */
        if (sih->ccrev >= 10)
                SET_REG(&cc->system_clk_ctl, SYCC_CD_MASK,
                        (ILP_DIV_1MHZ << SYCC_CD_SHIFT));
 
-       si_clkctl_setdelay(sii, (void *)cc);
+       ai_clkctl_setdelay(sii, (void *)cc);
 
        if (!fast)
-               si_setcoreidx(sih, origidx);
+               ai_setcoreidx(sih, origidx);
 }
 
-/* return the value suitable for writing to the dot11 core FAST_PWRUP_DELAY register */
-u16 si_clkctl_fast_pwrup_delay(si_t *sih)
+/*
+ * return the value suitable for writing to the
+ * dot11 core FAST_PWRUP_DELAY register
+ */
+u16 ai_clkctl_fast_pwrup_delay(si_t *sih)
 {
        si_info_t *sii;
        uint origidx = 0;
@@ -1221,7 +1416,7 @@ u16 si_clkctl_fast_pwrup_delay(si_t *sih)
        if (!fast) {
                origidx = sii->curidx;
                INTR_OFF(sii, intr_val);
-               cc = (chipcregs_t *) si_setcore(sih, CC_CORE_ID, 0);
+               cc = (chipcregs_t *) ai_setcore(sih, CC_CORE_ID, 0);
                if (cc == NULL)
                        goto done;
        } else {
@@ -1229,22 +1424,21 @@ u16 si_clkctl_fast_pwrup_delay(si_t *sih)
                if (cc == NULL)
                        goto done;
        }
-       ASSERT(cc != NULL);
 
-       slowminfreq = si_slowclk_freq(sii, false, cc);
+       slowminfreq = ai_slowclk_freq(sii, false, cc);
        fpdelay = (((R_REG(&cc->pll_on_delay) + 2) * 1000000) +
                   (slowminfreq - 1)) / slowminfreq;
 
  done:
        if (!fast) {
-               si_setcoreidx(sih, origidx);
+               ai_setcoreidx(sih, origidx);
                INTR_RESTORE(sii, intr_val);
        }
        return fpdelay;
 }
 
 /* turn primary xtal and/or pll off/on */
-int si_clkctl_xtal(si_t *sih, uint what, bool on)
+int ai_clkctl_xtal(si_t *sih, uint what, bool on)
 {
        si_info_t *sii;
        u32 in, out, outen;
@@ -1253,11 +1447,6 @@ int si_clkctl_xtal(si_t *sih, uint what, bool on)
 
        switch (sih->bustype) {
 
-#ifdef BCMSDIO
-       case SDIO_BUS:
-               return -1;
-#endif                         /* BCMSDIO */
-
        case PCI_BUS:
                /* pcie core doesn't have any mapping to control the xtal pu */
                if (PCIE(sii))
@@ -1319,14 +1508,14 @@ int si_clkctl_xtal(si_t *sih, uint what, bool on)
 }
 
 /*
- *  clock control policy function through chipcommon
+ *  clock control policy function throught chipcommon
  *
  *    set dynamic clk control mode (forceslow, forcefast, dynamic)
  *    returns true if we are forcing fast clock
  *    this is a wrapper over the next internal function
  *      to allow flexible policy settings for outside caller
  */
-bool si_clkctl_cc(si_t *sih, uint mode)
+bool ai_clkctl_cc(si_t *sih, uint mode)
 {
        si_info_t *sii;
 
@@ -1339,11 +1528,11 @@ bool si_clkctl_cc(si_t *sih, uint mode)
        if (PCI_FORCEHT(sii))
                return mode == CLK_FAST;
 
-       return _si_clkctl_cc(sii, mode);
+       return _ai_clkctl_cc(sii, mode);
 }
 
 /* clk control mechanism through chipcommon, no policy checking */
-static bool _si_clkctl_cc(si_info_t *sii, uint mode)
+static bool _ai_clkctl_cc(si_info_t *sii, uint mode)
 {
        uint origidx = 0;
        chipcregs_t *cc;
@@ -1355,25 +1544,21 @@ static bool _si_clkctl_cc(si_info_t *sii, uint mode)
        if (sii->pub.ccrev < 6)
                return false;
 
-       /* Chips with ccrev 10 are EOL and they don't have SYCC_HR which we use below */
-       ASSERT(sii->pub.ccrev != 10);
-
        if (!fast) {
                INTR_OFF(sii, intr_val);
                origidx = sii->curidx;
 
                if ((sii->pub.bustype == SI_BUS) &&
-                   si_setcore(&sii->pub, MIPS33_CORE_ID, 0) &&
-                   (si_corerev(&sii->pub) <= 7) && (sii->pub.ccrev >= 10))
+                   ai_setcore(&sii->pub, MIPS33_CORE_ID, 0) &&
+                   (ai_corerev(&sii->pub) <= 7) && (sii->pub.ccrev >= 10))
                        goto done;
 
-               cc = (chipcregs_t *) si_setcore(&sii->pub, CC_CORE_ID, 0);
+               cc = (chipcregs_t *) ai_setcore(&sii->pub, CC_CORE_ID, 0);
        } else {
                cc = (chipcregs_t *) CCREGS_FAST(sii);
                if (cc == NULL)
                        goto done;
        }
-       ASSERT(cc != NULL);
 
        if (!CCCTL_ENAB(&sii->pub) && (sii->pub.ccrev < 20))
                goto done;
@@ -1381,8 +1566,11 @@ static bool _si_clkctl_cc(si_info_t *sii, uint mode)
        switch (mode) {
        case CLK_FAST:          /* FORCEHT, fast (pll) clock */
                if (sii->pub.ccrev < 10) {
-                       /* don't forget to force xtal back on before we clear SCC_DYN_XTAL.. */
-                       si_clkctl_xtal(&sii->pub, XTAL, ON);
+                       /*
+                        * don't forget to force xtal back
+                        * on before we clear SCC_DYN_XTAL..
+                        */
+                       ai_clkctl_xtal(&sii->pub, XTAL, ON);
                        SET_REG(&cc->slow_clk_ctl,
                                (SCC_XC | SCC_FS | SCC_IP), SCC_IP);
                } else if (sii->pub.ccrev < 20) {
@@ -1396,7 +1584,6 @@ static bool _si_clkctl_cc(si_info_t *sii, uint mode)
                        u32 htavail = CCS_HTAVAIL;
                        SPINWAIT(((R_REG(&cc->clk_ctl_st) & htavail)
                                  == 0), PMU_MAX_TRANSITION_DLY);
-                       ASSERT(R_REG(&cc->clk_ctl_st) & htavail);
                } else {
                        udelay(PLL_DELAY);
                }
@@ -1410,9 +1597,12 @@ static bool _si_clkctl_cc(si_info_t *sii, uint mode)
                                scc |= SCC_XC;
                        W_REG(&cc->slow_clk_ctl, scc);
 
-                       /* for dynamic control, we have to release our xtal_pu "force on" */
+                       /*
+                        * for dynamic control, we have to
+                        * release our xtal_pu "force on"
+                        */
                        if (scc & SCC_XC)
-                               si_clkctl_xtal(&sii->pub, XTAL, OFF);
+                               ai_clkctl_xtal(&sii->pub, XTAL, OFF);
                } else if (sii->pub.ccrev < 20) {
                        /* Instaclock */
                        AND_REG(&cc->system_clk_ctl, ~SYCC_HR);
@@ -1422,50 +1612,39 @@ static bool _si_clkctl_cc(si_info_t *sii, uint mode)
                break;
 
        default:
-               ASSERT(0);
+               break;
        }
 
  done:
        if (!fast) {
-               si_setcoreidx(&sii->pub, origidx);
+               ai_setcoreidx(&sii->pub, origidx);
                INTR_RESTORE(sii, intr_val);
        }
        return mode == CLK_FAST;
 }
 
 /* Build device path. Support SI, PCI, and JTAG for now. */
-int si_devpath(si_t *sih, char *path, int size)
+int ai_devpath(si_t *sih, char *path, int size)
 {
        int slen;
 
-       ASSERT(path != NULL);
-       ASSERT(size >= SI_DEVPATH_BUFSZ);
-
        if (!path || size <= 0)
                return -1;
 
        switch (sih->bustype) {
        case SI_BUS:
        case JTAG_BUS:
-               slen = snprintf(path, (size_t) size, "sb/%u/", si_coreidx(sih));
+               slen = snprintf(path, (size_t) size, "sb/%u/", ai_coreidx(sih));
                break;
        case PCI_BUS:
-               ASSERT((SI_INFO(sih))->pbus != NULL);
                slen = snprintf(path, (size_t) size, "pci/%u/%u/",
                        ((struct pci_dev *)((SI_INFO(sih))->pbus))->bus->number,
                        PCI_SLOT(
                            ((struct pci_dev *)((SI_INFO(sih))->pbus))->devfn));
                break;
 
-#ifdef BCMSDIO
-       case SDIO_BUS:
-               SI_ERROR(("si_devpath: device 0 assumed\n"));
-               slen = snprintf(path, (size_t) size, "sd/%u/", si_coreidx(sih));
-               break;
-#endif
        default:
                slen = -1;
-               ASSERT(0);
                break;
        }
 
@@ -1478,47 +1657,47 @@ int si_devpath(si_t *sih, char *path, int size)
 }
 
 /* Get a variable, but only if it has a devpath prefix */
-char *si_getdevpathvar(si_t *sih, const char *name)
+char *ai_getdevpathvar(si_t *sih, const char *name)
 {
        char varname[SI_DEVPATH_BUFSZ + 32];
 
-       si_devpathvar(sih, varname, sizeof(varname), name);
+       ai_devpathvar(sih, varname, sizeof(varname), name);
 
        return getvar(NULL, varname);
 }
 
 /* Get a variable, but only if it has a devpath prefix */
-int si_getdevpathintvar(si_t *sih, const char *name)
+int ai_getdevpathintvar(si_t *sih, const char *name)
 {
 #if defined(BCMBUSTYPE) && (BCMBUSTYPE == SI_BUS)
        return getintvar(NULL, name);
 #else
        char varname[SI_DEVPATH_BUFSZ + 32];
 
-       si_devpathvar(sih, varname, sizeof(varname), name);
+       ai_devpathvar(sih, varname, sizeof(varname), name);
 
        return getintvar(NULL, varname);
 #endif
 }
 
-char *si_getnvramflvar(si_t *sih, const char *name)
+char *ai_getnvramflvar(si_t *sih, const char *name)
 {
        return getvar(NULL, name);
 }
 
 /* Concatenate the dev path with a varname into the given 'var' buffer
- * and return the 'var' pointer.
- * Nothing is done to the arguments if len == 0 or var is NULL, var is still returned.
- * On overflow, the first char will be set to '\0'.
+ * and return the 'var' pointer. Nothing is done to the arguments if
+ * len == 0 or var is NULL, var is still returned. On overflow, the
+ * first char will be set to '\0'.
  */
-static char *si_devpathvar(si_t *sih, char *var, int len, const char *name)
+static char *ai_devpathvar(si_t *sih, char *var, int len, const char *name)
 {
        uint path_len;
 
        if (!var || len <= 0)
                return var;
 
-       if (si_devpath(sih, var, len) == 0) {
+       if (ai_devpath(sih, var, len) == 0) {
                path_len = strlen(var);
 
                if (strlen(name) + 1 > (uint) (len - path_len))
@@ -1531,7 +1710,7 @@ static char *si_devpathvar(si_t *sih, char *var, int len, const char *name)
 }
 
 /* return true if PCIE capability exists in the pci config space */
-static __used bool si_ispcie(si_info_t *sii)
+static __used bool ai_ispcie(si_info_t *sii)
 {
        u8 cap_ptr;
 
@@ -1539,7 +1718,7 @@ static __used bool si_ispcie(si_info_t *sii)
                return false;
 
        cap_ptr =
-           pcicore_find_pci_capability(sii->pbus, PCI_CAP_PCIECAP_ID, NULL,
+           pcicore_find_pci_capability(sii->pbus, PCI_CAP_ID_EXP, NULL,
                                        NULL);
        if (!cap_ptr)
                return false;
@@ -1547,46 +1726,7 @@ static __used bool si_ispcie(si_info_t *sii)
        return true;
 }
 
-#ifdef BCMSDIO
-/* initialize the sdio core */
-void si_sdio_init(si_t *sih)
-{
-       si_info_t *sii = SI_INFO(sih);
-
-       if (((sih->buscoretype == PCMCIA_CORE_ID) && (sih->buscorerev >= 8)) ||
-           (sih->buscoretype == SDIOD_CORE_ID)) {
-               uint idx;
-               sdpcmd_regs_t *sdpregs;
-
-               /* get the current core index */
-               idx = sii->curidx;
-               ASSERT(idx == si_findcoreidx(sih, D11_CORE_ID, 0));
-
-               /* switch to sdio core */
-               sdpregs = (sdpcmd_regs_t *) si_setcore(sih, PCMCIA_CORE_ID, 0);
-               if (!sdpregs)
-                       sdpregs =
-                           (sdpcmd_regs_t *) si_setcore(sih, SDIOD_CORE_ID, 0);
-               ASSERT(sdpregs);
-
-               SI_MSG(("si_sdio_init: For PCMCIA/SDIO Corerev %d, enable ints from core %d " "through SD core %d (%p)\n", sih->buscorerev, idx, sii->curidx, sdpregs));
-
-               /* enable backplane error and core interrupts */
-               W_REG(&sdpregs->hostintmask, I_SBINT);
-               W_REG(&sdpregs->sbintmask,
-                     (I_SB_SERR | I_SB_RESPERR | (1 << idx)));
-
-               /* switch back to previous core */
-               si_setcoreidx(sih, idx);
-       }
-
-       /* enable interrupts */
-       bcmsdh_intr_enable(sii->pbus);
-
-}
-#endif                         /* BCMSDIO */
-
-bool si_pci_war16165(si_t *sih)
+bool ai_pci_war16165(si_t *sih)
 {
        si_info_t *sii;
 
@@ -1595,7 +1735,7 @@ bool si_pci_war16165(si_t *sih)
        return PCI(sii) && (sih->buscorerev <= 10);
 }
 
-void si_pci_up(si_t *sih)
+void ai_pci_up(si_t *sih)
 {
        si_info_t *sii;
 
@@ -1606,7 +1746,7 @@ void si_pci_up(si_t *sih)
                return;
 
        if (PCI_FORCEHT(sii))
-               _si_clkctl_cc(sii, CLK_FAST);
+               _ai_clkctl_cc(sii, CLK_FAST);
 
        if (PCIE(sii))
                pcicore_up(sii->pch, SI_PCIUP);
@@ -1614,7 +1754,7 @@ void si_pci_up(si_t *sih)
 }
 
 /* Unconfigure and/or apply various WARs when system is going to sleep mode */
-void si_pci_sleep(si_t *sih)
+void ai_pci_sleep(si_t *sih)
 {
        si_info_t *sii;
 
@@ -1624,7 +1764,7 @@ void si_pci_sleep(si_t *sih)
 }
 
 /* Unconfigure and/or apply various WARs when going down */
-void si_pci_down(si_t *sih)
+void ai_pci_down(si_t *sih)
 {
        si_info_t *sii;
 
@@ -1636,7 +1776,7 @@ void si_pci_down(si_t *sih)
 
        /* release FORCEHT since chip is going to "down" state */
        if (PCI_FORCEHT(sii))
-               _si_clkctl_cc(sii, CLK_DYNAMIC);
+               _ai_clkctl_cc(sii, CLK_DYNAMIC);
 
        pcicore_down(sii->pch, SI_PCIDOWN);
 }
@@ -1645,7 +1785,7 @@ void si_pci_down(si_t *sih)
  * Configure the pci core for pci client (NIC) action
  * coremask is the bitvec of cores by index to be enabled.
  */
-void si_pci_setup(si_t *sih, uint coremask)
+void ai_pci_setup(si_t *sih, uint coremask)
 {
        si_info_t *sii;
        struct sbpciregs *pciregs = NULL;
@@ -1657,18 +1797,15 @@ void si_pci_setup(si_t *sih, uint coremask)
        if (sii->pub.bustype != PCI_BUS)
                return;
 
-       ASSERT(PCI(sii) || PCIE(sii));
-       ASSERT(sii->pub.buscoreidx != BADIDX);
-
        if (PCI(sii)) {
                /* get current core index */
                idx = sii->curidx;
 
                /* we interrupt on this backplane flag number */
-               siflag = si_flag(sih);
+               siflag = ai_flag(sih);
 
                /* switch over to pci core */
-               pciregs = (struct sbpciregs *)si_setcoreidx(sih, sii->pub.buscoreidx);
+               pciregs = ai_setcoreidx(sih, sii->pub.buscoreidx);
        }
 
        /*
@@ -1682,7 +1819,7 @@ void si_pci_setup(si_t *sih, uint coremask)
                pci_write_config_dword(sii->pbus, PCI_INT_MASK, w);
        } else {
                /* set sbintvec bit for our flag number */
-               si_setint(sih, siflag);
+               ai_setint(sih, siflag);
        }
 
        if (PCI(sii)) {
@@ -1698,7 +1835,7 @@ void si_pci_setup(si_t *sih, uint coremask)
                }
 
                /* switch back to previous core */
-               si_setcoreidx(sih, idx);
+               ai_setcoreidx(sih, idx);
        }
 }
 
@@ -1706,7 +1843,7 @@ void si_pci_setup(si_t *sih, uint coremask)
  * Fixup SROMless PCI device's configuration.
  * The current core may be changed upon return.
  */
-int si_pci_fixcfg(si_t *sih)
+int ai_pci_fixcfg(si_t *sih)
 {
        uint origidx, pciidx;
        struct sbpciregs *pciregs = NULL;
@@ -1716,26 +1853,21 @@ int si_pci_fixcfg(si_t *sih)
 
        si_info_t *sii = SI_INFO(sih);
 
-       ASSERT(sii->pub.bustype == PCI_BUS);
-
        /* Fixup PI in SROM shadow area to enable the correct PCI core access */
        /* save the current index */
-       origidx = si_coreidx(&sii->pub);
+       origidx = ai_coreidx(&sii->pub);
 
        /* check 'pi' is correct and fix it if not */
        if (sii->pub.buscoretype == PCIE_CORE_ID) {
-               pcieregs =
-                   (sbpcieregs_t *) si_setcore(&sii->pub, PCIE_CORE_ID, 0);
+               pcieregs = ai_setcore(&sii->pub, PCIE_CORE_ID, 0);
                regs = pcieregs;
-               ASSERT(pcieregs != NULL);
                reg16 = &pcieregs->sprom[SRSH_PI_OFFSET];
        } else if (sii->pub.buscoretype == PCI_CORE_ID) {
-               pciregs = (struct sbpciregs *)si_setcore(&sii->pub, PCI_CORE_ID, 0);
+               pciregs = ai_setcore(&sii->pub, PCI_CORE_ID, 0);
                regs = pciregs;
-               ASSERT(pciregs != NULL);
                reg16 = &pciregs->sprom[SRSH_PI_OFFSET];
        }
-       pciidx = si_coreidx(&sii->pub);
+       pciidx = ai_coreidx(&sii->pub);
        val16 = R_REG(reg16);
        if (((val16 & SRSH_PI_MASK) >> SRSH_PI_SHIFT) != (u16) pciidx) {
                val16 =
@@ -1745,14 +1877,14 @@ int si_pci_fixcfg(si_t *sih)
        }
 
        /* restore the original index */
-       si_setcoreidx(&sii->pub, origidx);
+       ai_setcoreidx(&sii->pub, origidx);
 
        pcicore_hwup(sii->pch);
        return 0;
 }
 
 /* mask&set gpiocontrol bits */
-u32 si_gpiocontrol(si_t *sih, u32 mask, u32 val, u8 priority)
+u32 ai_gpiocontrol(si_t *sih, u32 mask, u32 val, u8 priority)
 {
        uint regoff;
 
@@ -1763,98 +1895,16 @@ u32 si_gpiocontrol(si_t *sih, u32 mask, u32 val, u8 priority)
         */
        if ((priority != GPIO_HI_PRIORITY) &&
            (sih->bustype == SI_BUS) && (val || mask)) {
-               mask = priority ? (si_gpioreservation & mask) :
-                   ((si_gpioreservation | mask) & ~(si_gpioreservation));
+               mask = priority ? (ai_gpioreservation & mask) :
+                   ((ai_gpioreservation | mask) & ~(ai_gpioreservation));
                val &= mask;
        }
 
        regoff = offsetof(chipcregs_t, gpiocontrol);
-       return si_corereg(sih, SI_CC_IDX, regoff, mask, val);
-}
-
-/* Return the size of the specified SOCRAM bank */
-static uint
-socram_banksize(si_info_t *sii, sbsocramregs_t *regs, u8 index,
-               u8 mem_type)
-{
-       uint banksize, bankinfo;
-       uint bankidx = index | (mem_type << SOCRAM_BANKIDX_MEMTYPE_SHIFT);
-
-       ASSERT(mem_type <= SOCRAM_MEMTYPE_DEVRAM);
-
-       W_REG(&regs->bankidx, bankidx);
-       bankinfo = R_REG(&regs->bankinfo);
-       banksize =
-           SOCRAM_BANKINFO_SZBASE * ((bankinfo & SOCRAM_BANKINFO_SZMASK) + 1);
-       return banksize;
-}
-
-/* Return the RAM size of the SOCRAM core */
-u32 si_socram_size(si_t *sih)
-{
-       si_info_t *sii;
-       uint origidx;
-       uint intr_val = 0;
-
-       sbsocramregs_t *regs;
-       bool wasup;
-       uint corerev;
-       u32 coreinfo;
-       uint memsize = 0;
-
-       sii = SI_INFO(sih);
-
-       /* Block ints and save current core */
-       INTR_OFF(sii, intr_val);
-       origidx = si_coreidx(sih);
-
-       /* Switch to SOCRAM core */
-       regs = si_setcore(sih, SOCRAM_CORE_ID, 0);
-       if (!regs)
-               goto done;
-
-       /* Get info for determining size */
-       wasup = si_iscoreup(sih);
-       if (!wasup)
-               si_core_reset(sih, 0, 0);
-       corerev = si_corerev(sih);
-       coreinfo = R_REG(&regs->coreinfo);
-
-       /* Calculate size from coreinfo based on rev */
-       if (corerev == 0)
-               memsize = 1 << (16 + (coreinfo & SRCI_MS0_MASK));
-       else if (corerev < 3) {
-               memsize = 1 << (SR_BSZ_BASE + (coreinfo & SRCI_SRBSZ_MASK));
-               memsize *= (coreinfo & SRCI_SRNB_MASK) >> SRCI_SRNB_SHIFT;
-       } else if ((corerev <= 7) || (corerev == 12)) {
-               uint nb = (coreinfo & SRCI_SRNB_MASK) >> SRCI_SRNB_SHIFT;
-               uint bsz = (coreinfo & SRCI_SRBSZ_MASK);
-               uint lss = (coreinfo & SRCI_LSS_MASK) >> SRCI_LSS_SHIFT;
-               if (lss != 0)
-                       nb--;
-               memsize = nb * (1 << (bsz + SR_BSZ_BASE));
-               if (lss != 0)
-                       memsize += (1 << ((lss - 1) + SR_BSZ_BASE));
-       } else {
-               u8 i;
-               uint nb = (coreinfo & SRCI_SRNB_MASK) >> SRCI_SRNB_SHIFT;
-               for (i = 0; i < nb; i++)
-                       memsize +=
-                           socram_banksize(sii, regs, i, SOCRAM_MEMTYPE_RAM);
-       }
-
-       /* Return to previous state and core */
-       if (!wasup)
-               si_core_disable(sih, 0);
-       si_setcoreidx(sih, origidx);
-
- done:
-       INTR_RESTORE(sii, intr_val);
-
-       return memsize;
+       return ai_corereg(sih, SI_CC_IDX, regoff, mask, val);
 }
 
-void si_chipcontrl_epa4331(si_t *sih, bool on)
+void ai_chipcontrl_epa4331(si_t *sih, bool on)
 {
        si_info_t *sii;
        chipcregs_t *cc;
@@ -1862,9 +1912,9 @@ void si_chipcontrl_epa4331(si_t *sih, bool on)
        u32 val;
 
        sii = SI_INFO(sih);
-       origidx = si_coreidx(sih);
+       origidx = ai_coreidx(sih);
 
-       cc = (chipcregs_t *) si_setcore(sih, CC_CORE_ID, 0);
+       cc = (chipcregs_t *) ai_setcore(sih, CC_CORE_ID, 0);
 
        val = R_REG(&cc->chipcontrol);
 
@@ -1884,30 +1934,30 @@ void si_chipcontrl_epa4331(si_t *sih, bool on)
                W_REG(&cc->chipcontrol, val);
        }
 
-       si_setcoreidx(sih, origidx);
+       ai_setcoreidx(sih, origidx);
 }
 
 /* Enable BT-COEX & Ex-PA for 4313 */
-void si_epa_4313war(si_t *sih)
+void ai_epa_4313war(si_t *sih)
 {
        si_info_t *sii;
        chipcregs_t *cc;
        uint origidx;
 
        sii = SI_INFO(sih);
-       origidx = si_coreidx(sih);
+       origidx = ai_coreidx(sih);
 
-       cc = (chipcregs_t *) si_setcore(sih, CC_CORE_ID, 0);
+       cc = (chipcregs_t *) ai_setcore(sih, CC_CORE_ID, 0);
 
        /* EPA Fix */
        W_REG(&cc->gpiocontrol,
              R_REG(&cc->gpiocontrol) | GPIO_CTRL_EPA_EN_MASK);
 
-       si_setcoreidx(sih, origidx);
+       ai_setcoreidx(sih, origidx);
 }
 
 /* check if the device is removed */
-bool si_deviceremoved(si_t *sih)
+bool ai_deviceremoved(si_t *sih)
 {
        u32 w;
        si_info_t *sii;
@@ -1916,16 +1966,15 @@ bool si_deviceremoved(si_t *sih)
 
        switch (sih->bustype) {
        case PCI_BUS:
-               ASSERT(sii->pbus != NULL);
-               pci_read_config_dword(sii->pbus, PCI_CFG_VID, &w);
-               if ((w & 0xFFFF) != VENDOR_BROADCOM)
+               pci_read_config_dword(sii->pbus, PCI_VENDOR_ID, &w);
+               if ((w & 0xFFFF) != PCI_VENDOR_ID_BROADCOM)
                        return true;
                break;
        }
        return false;
 }
 
-bool si_is_sprom_available(si_t *sih)
+bool ai_is_sprom_available(si_t *sih)
 {
        if (sih->ccrev >= 31) {
                si_info_t *sii;
@@ -1938,9 +1987,9 @@ bool si_is_sprom_available(si_t *sih)
 
                sii = SI_INFO(sih);
                origidx = sii->curidx;
-               cc = si_setcoreidx(sih, SI_CC_IDX);
+               cc = ai_setcoreidx(sih, SI_CC_IDX);
                sromctrl = R_REG(&cc->sromcontrol);
-               si_setcoreidx(sih, origidx);
+               ai_setcoreidx(sih, origidx);
                return sromctrl & SRC_PRESENT;
        }
 
@@ -1962,7 +2011,7 @@ bool si_is_sprom_available(si_t *sih)
        }
 }
 
-bool si_is_otp_disabled(si_t *sih)
+bool ai_is_otp_disabled(si_t *sih)
 {
        switch (sih->chip) {
        case BCM4329_CHIP_ID:
@@ -1990,17 +2039,16 @@ bool si_is_otp_disabled(si_t *sih)
        }
 }
 
-bool si_is_otp_powered(si_t *sih)
+bool ai_is_otp_powered(si_t *sih)
 {
        if (PMUCTL_ENAB(sih))
                return si_pmu_is_otp_powered(sih);
        return true;
 }
 
-void si_otp_power(si_t *sih, bool on)
+void ai_otp_power(si_t *sih, bool on)
 {
        if (PMUCTL_ENAB(sih))
                si_pmu_otp_power(sih, on);
        udelay(1000);
 }
-
diff --git a/drivers/staging/brcm80211/brcmsmac/aiutils.h b/drivers/staging/brcm80211/brcmsmac/aiutils.h
new file mode 100644 (file)
index 0000000..b98099e
--- /dev/null
@@ -0,0 +1,546 @@
+/*
+ * Copyright (c) 2011 Broadcom Corporation
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef        _aiutils_h_
+#define        _aiutils_h_
+
+/* cpp contortions to concatenate w/arg prescan */
+#ifndef PAD
+#define        _PADLINE(line)  pad ## line
+#define        _XSTR(line)     _PADLINE(line)
+#define        PAD             _XSTR(__LINE__)
+#endif
+
+/* Include the soci specific files */
+#include <aidmp.h>
+
+/*
+ * SOC Interconnect Address Map.
+ * All regions may not exist on all chips.
+ */
+/* Physical SDRAM */
+#define SI_SDRAM_BASE          0x00000000
+/* Host Mode sb2pcitranslation0 (64 MB) */
+#define SI_PCI_MEM             0x08000000
+#define SI_PCI_MEM_SZ          (64 * 1024 * 1024)
+/* Host Mode sb2pcitranslation1 (64 MB) */
+#define SI_PCI_CFG             0x0c000000
+/* Byteswapped Physical SDRAM */
+#define        SI_SDRAM_SWAPPED        0x10000000
+/* Region 2 for sdram (512 MB) */
+#define SI_SDRAM_R2            0x80000000
+
+#ifdef SI_ENUM_BASE_VARIABLE
+#define SI_ENUM_BASE           (sii->pub.si_enum_base)
+#else
+#define SI_ENUM_BASE           0x18000000      /* Enumeration space base */
+#endif                         /* SI_ENUM_BASE_VARIABLE */
+
+/* Wrapper space base */
+#define SI_WRAP_BASE           0x18100000
+/* each core gets 4Kbytes for registers */
+#define SI_CORE_SIZE           0x1000
+/*
+ * Max cores (this is arbitrary, for software
+ * convenience and could be changed if we
+ * make any larger chips
+ */
+#define        SI_MAXCORES             16
+
+/* On-chip RAM on chips that also have DDR */
+#define        SI_FASTRAM              0x19000000
+#define        SI_FASTRAM_SWAPPED      0x19800000
+
+/* Flash Region 2 (region 1 shadowed here) */
+#define        SI_FLASH2               0x1c000000
+/* Size of Flash Region 2 */
+#define        SI_FLASH2_SZ            0x02000000
+/* ARM Cortex-M3 ROM */
+#define        SI_ARMCM3_ROM           0x1e000000
+/* MIPS Flash Region 1 */
+#define        SI_FLASH1               0x1fc00000
+/* MIPS Size of Flash Region 1 */
+#define        SI_FLASH1_SZ            0x00400000
+/* ARM7TDMI-S ROM */
+#define        SI_ARM7S_ROM            0x20000000
+/* ARM Cortex-M3 SRAM Region 2 */
+#define        SI_ARMCM3_SRAM2         0x60000000
+/* ARM7TDMI-S SRAM Region 2 */
+#define        SI_ARM7S_SRAM2          0x80000000
+/* ARM Flash Region 1 */
+#define        SI_ARM_FLASH1           0xffff0000
+/* ARM Size of Flash Region 1 */
+#define        SI_ARM_FLASH1_SZ        0x00010000
+
+/* Client Mode sb2pcitranslation2 (1 GB) */
+#define SI_PCI_DMA             0x40000000
+/* Client Mode sb2pcitranslation2 (1 GB) */
+#define SI_PCI_DMA2            0x80000000
+/* Client Mode sb2pcitranslation2 size in bytes */
+#define SI_PCI_DMA_SZ          0x40000000
+/* PCIE Client Mode sb2pcitranslation2 (2 ZettaBytes), low 32 bits */
+#define SI_PCIE_DMA_L32                0x00000000
+/* PCIE Client Mode sb2pcitranslation2 (2 ZettaBytes), high 32 bits */
+#define SI_PCIE_DMA_H32                0x80000000
+
+/* core codes */
+#define        NODEV_CORE_ID           0x700   /* Invalid coreid */
+#define        CC_CORE_ID              0x800   /* chipcommon core */
+#define        ILINE20_CORE_ID         0x801   /* iline20 core */
+#define        SRAM_CORE_ID            0x802   /* sram core */
+#define        SDRAM_CORE_ID           0x803   /* sdram core */
+#define        PCI_CORE_ID             0x804   /* pci core */
+#define        MIPS_CORE_ID            0x805   /* mips core */
+#define        ENET_CORE_ID            0x806   /* enet mac core */
+#define        CODEC_CORE_ID           0x807   /* v90 codec core */
+#define        USB_CORE_ID             0x808   /* usb 1.1 host/device core */
+#define        ADSL_CORE_ID            0x809   /* ADSL core */
+#define        ILINE100_CORE_ID        0x80a   /* iline100 core */
+#define        IPSEC_CORE_ID           0x80b   /* ipsec core */
+#define        UTOPIA_CORE_ID          0x80c   /* utopia core */
+#define        PCMCIA_CORE_ID          0x80d   /* pcmcia core */
+#define        SOCRAM_CORE_ID          0x80e   /* internal memory core */
+#define        MEMC_CORE_ID            0x80f   /* memc sdram core */
+#define        OFDM_CORE_ID            0x810   /* OFDM phy core */
+#define        EXTIF_CORE_ID           0x811   /* external interface core */
+#define        D11_CORE_ID             0x812   /* 802.11 MAC core */
+#define        APHY_CORE_ID            0x813   /* 802.11a phy core */
+#define        BPHY_CORE_ID            0x814   /* 802.11b phy core */
+#define        GPHY_CORE_ID            0x815   /* 802.11g phy core */
+#define        MIPS33_CORE_ID          0x816   /* mips3302 core */
+#define        USB11H_CORE_ID          0x817   /* usb 1.1 host core */
+#define        USB11D_CORE_ID          0x818   /* usb 1.1 device core */
+#define        USB20H_CORE_ID          0x819   /* usb 2.0 host core */
+#define        USB20D_CORE_ID          0x81a   /* usb 2.0 device core */
+#define        SDIOH_CORE_ID           0x81b   /* sdio host core */
+#define        ROBO_CORE_ID            0x81c   /* roboswitch core */
+#define        ATA100_CORE_ID          0x81d   /* parallel ATA core */
+#define        SATAXOR_CORE_ID         0x81e   /* serial ATA & XOR DMA core */
+#define        GIGETH_CORE_ID          0x81f   /* gigabit ethernet core */
+#define        PCIE_CORE_ID            0x820   /* pci express core */
+#define        NPHY_CORE_ID            0x821   /* 802.11n 2x2 phy core */
+#define        SRAMC_CORE_ID           0x822   /* SRAM controller core */
+#define        MINIMAC_CORE_ID         0x823   /* MINI MAC/phy core */
+#define        ARM11_CORE_ID           0x824   /* ARM 1176 core */
+#define        ARM7S_CORE_ID           0x825   /* ARM7tdmi-s core */
+#define        LPPHY_CORE_ID           0x826   /* 802.11a/b/g phy core */
+#define        PMU_CORE_ID             0x827   /* PMU core */
+#define        SSNPHY_CORE_ID          0x828   /* 802.11n single-stream phy core */
+#define        SDIOD_CORE_ID           0x829   /* SDIO device core */
+#define        ARMCM3_CORE_ID          0x82a   /* ARM Cortex M3 core */
+#define        HTPHY_CORE_ID           0x82b   /* 802.11n 4x4 phy core */
+#define        MIPS74K_CORE_ID         0x82c   /* mips 74k core */
+#define        GMAC_CORE_ID            0x82d   /* Gigabit MAC core */
+#define        DMEMC_CORE_ID           0x82e   /* DDR1/2 memory controller core */
+#define        PCIERC_CORE_ID          0x82f   /* PCIE Root Complex core */
+#define        OCP_CORE_ID             0x830   /* OCP2OCP bridge core */
+#define        SC_CORE_ID              0x831   /* shared common core */
+#define        AHB_CORE_ID             0x832   /* OCP2AHB bridge core */
+#define        SPIH_CORE_ID            0x833   /* SPI host core */
+#define        I2S_CORE_ID             0x834   /* I2S core */
+#define        DMEMS_CORE_ID           0x835   /* SDR/DDR1 memory controller core */
+#define        DEF_SHIM_COMP           0x837   /* SHIM component in ubus/6362 */
+#define OOB_ROUTER_CORE_ID     0x367   /* OOB router core ID */
+#define        DEF_AI_COMP             0xfff   /* Default component, in ai chips it
+                                        * maps all unused address ranges
+                                        */
+
+/* There are TWO constants on all HND chips: SI_ENUM_BASE above,
+ * and chipcommon being the first core:
+ */
+#define        SI_CC_IDX               0
+
+/* SOC Interconnect types (aka chip types) */
+#define        SOCI_AI                 1
+
+/* Common core control flags */
+#define        SICF_BIST_EN            0x8000
+#define        SICF_PME_EN             0x4000
+#define        SICF_CORE_BITS          0x3ffc
+#define        SICF_FGC                0x0002
+#define        SICF_CLOCK_EN           0x0001
+
+/* Common core status flags */
+#define        SISF_BIST_DONE          0x8000
+#define        SISF_BIST_ERROR         0x4000
+#define        SISF_GATED_CLK          0x2000
+#define        SISF_DMA64              0x1000
+#define        SISF_CORE_BITS          0x0fff
+
+/* A register that is common to all cores to
+ * communicate w/PMU regarding clock control.
+ */
+#define SI_CLK_CTL_ST          0x1e0   /* clock control and status */
+
+/* clk_ctl_st register */
+#define        CCS_FORCEALP            0x00000001      /* force ALP request */
+#define        CCS_FORCEHT             0x00000002      /* force HT request */
+#define        CCS_FORCEILP            0x00000004      /* force ILP request */
+#define        CCS_ALPAREQ             0x00000008      /* ALP Avail Request */
+#define        CCS_HTAREQ              0x00000010      /* HT Avail Request */
+#define        CCS_FORCEHWREQOFF       0x00000020      /* Force HW Clock Request Off */
+#define CCS_ERSRC_REQ_MASK     0x00000700      /* external resource requests */
+#define CCS_ERSRC_REQ_SHIFT    8
+#define        CCS_ALPAVAIL            0x00010000      /* ALP is available */
+#define        CCS_HTAVAIL             0x00020000      /* HT is available */
+#define CCS_BP_ON_APL          0x00040000      /* RO: running on ALP clock */
+#define CCS_BP_ON_HT           0x00080000      /* RO: running on HT clock */
+#define CCS_ERSRC_STS_MASK     0x07000000      /* external resource status */
+#define CCS_ERSRC_STS_SHIFT    24
+
+/* HT avail in chipc and pcmcia on 4328a0 */
+#define        CCS0_HTAVAIL            0x00010000
+/* ALP avail in chipc and pcmcia on 4328a0 */
+#define        CCS0_ALPAVAIL           0x00020000
+
+/* Not really related to SOC Interconnect, but a couple of software
+ * conventions for the use the flash space:
+ */
+
+/* Minumum amount of flash we support */
+#define FLASH_MIN              0x00020000      /* Minimum flash size */
+
+/* A boot/binary may have an embedded block that describes its size  */
+#define        BISZ_OFFSET             0x3e0   /* At this offset into the binary */
+#define        BISZ_MAGIC              0x4249535a      /* Marked with value: 'BISZ' */
+#define        BISZ_MAGIC_IDX          0       /* Word 0: magic */
+#define        BISZ_TXTST_IDX          1       /*      1: text start */
+#define        BISZ_TXTEND_IDX         2       /*      2: text end */
+#define        BISZ_DATAST_IDX         3       /*      3: data start */
+#define        BISZ_DATAEND_IDX        4       /*      4: data end */
+#define        BISZ_BSSST_IDX          5       /*      5: bss start */
+#define        BISZ_BSSEND_IDX         6       /*      6: bss end */
+#define BISZ_SIZE              7       /* descriptor size in 32-bit integers */
+
+#define        SI_INFO(sih)    (si_info_t *)sih
+
+#define        GOODCOREADDR(x, b) \
+       (((x) >= (b)) && ((x) < ((b) + SI_MAXCORES * SI_CORE_SIZE)) && \
+               IS_ALIGNED((x), SI_CORE_SIZE))
+#define        GOODREGS(regs) \
+       ((regs) != NULL && IS_ALIGNED((unsigned long)(regs), SI_CORE_SIZE))
+#define BADCOREADDR    0
+#define        GOODIDX(idx)    (((uint)idx) < SI_MAXCORES)
+#define        NOREV           -1      /* Invalid rev */
+
+/* Newer chips can access PCI/PCIE and CC core without requiring to change
+ * PCI BAR0 WIN
+ */
+#define SI_FAST(si) (((si)->pub.buscoretype == PCIE_CORE_ID) ||        \
+                    (((si)->pub.buscoretype == PCI_CORE_ID) && \
+                     (si)->pub.buscorerev >= 13))
+
+#define PCIEREGS(si) (((char *)((si)->curmap) + PCI_16KB0_PCIREGS_OFFSET))
+#define CCREGS_FAST(si) (((char *)((si)->curmap) + PCI_16KB0_CCREGS_OFFSET))
+
+/*
+ * Macros to disable/restore function core(D11, ENET, ILINE20, etc) interrupts
+ * before after core switching to avoid invalid register accesss inside ISR.
+ */
+#define INTR_OFF(si, intr_val) \
+       if ((si)->intrsoff_fn && \
+           (si)->coreid[(si)->curidx] == (si)->dev_coreid) \
+               intr_val = (*(si)->intrsoff_fn)((si)->intr_arg)
+#define INTR_RESTORE(si, intr_val) \
+       if ((si)->intrsrestore_fn && \
+           (si)->coreid[(si)->curidx] == (si)->dev_coreid) \
+               (*(si)->intrsrestore_fn)((si)->intr_arg, intr_val)
+
+/* dynamic clock control defines */
+#define        LPOMINFREQ              25000   /* low power oscillator min */
+#define        LPOMAXFREQ              43000   /* low power oscillator max */
+#define        XTALMINFREQ             19800000        /* 20 MHz - 1% */
+#define        XTALMAXFREQ             20200000        /* 20 MHz + 1% */
+#define        PCIMINFREQ              25000000        /* 25 MHz */
+#define        PCIMAXFREQ              34000000        /* 33 MHz + fudge */
+
+#define        ILP_DIV_5MHZ            0       /* ILP = 5 MHz */
+#define        ILP_DIV_1MHZ            4       /* ILP = 1 MHz */
+
+#define PCI(si)                (((si)->pub.bustype == PCI_BUS) &&      \
+                        ((si)->pub.buscoretype == PCI_CORE_ID))
+#define PCIE(si)       (((si)->pub.bustype == PCI_BUS) &&      \
+                        ((si)->pub.buscoretype == PCIE_CORE_ID))
+#define PCI_FORCEHT(si)        \
+       (PCIE(si) && (si->pub.chip == BCM4716_CHIP_ID))
+
+/* GPIO Based LED powersave defines */
+#define DEFAULT_GPIO_ONTIME    10      /* Default: 10% on */
+#define DEFAULT_GPIO_OFFTIME   90      /* Default: 10% on */
+
+#ifndef DEFAULT_GPIOTIMERVAL
+#define DEFAULT_GPIOTIMERVAL \
+       ((DEFAULT_GPIO_ONTIME << GPIO_ONTIME_SHIFT) | DEFAULT_GPIO_OFFTIME)
+#endif
+
+/*
+ * Data structure to export all chip specific common variables
+ *   public (read-only) portion of aiutils handle returned by si_attach()
+ */
+struct si_pub {
+       uint bustype;           /* SI_BUS, PCI_BUS */
+       uint buscoretype;       /* PCI_CORE_ID, PCIE_CORE_ID, PCMCIA_CORE_ID */
+       uint buscorerev;        /* buscore rev */
+       uint buscoreidx;        /* buscore index */
+       int ccrev;              /* chip common core rev */
+       u32 cccaps;             /* chip common capabilities */
+       u32 cccaps_ext; /* chip common capabilities extension */
+       int pmurev;             /* pmu core rev */
+       u32 pmucaps;            /* pmu capabilities */
+       uint boardtype;         /* board type */
+       uint boardvendor;       /* board vendor */
+       uint boardflags;        /* board flags */
+       uint boardflags2;       /* board flags2 */
+       uint chip;              /* chip number */
+       uint chiprev;           /* chip revision */
+       uint chippkg;           /* chip package option */
+       u32 chipst;             /* chip status */
+       bool issim;             /* chip is in simulation or emulation */
+       uint socirev;           /* SOC interconnect rev */
+       bool pci_pr32414;
+
+};
+
+/*
+ * for HIGH_ONLY driver, the si_t must be writable to allow states sync from
+ * BMAC to HIGH driver for monolithic driver, it is readonly to prevent accident
+ * change
+ */
+typedef const struct si_pub si_t;
+
+/*
+ * Many of the routines below take an 'sih' handle as their first arg.
+ * Allocate this by calling si_attach().  Free it by calling si_detach().
+ * At any one time, the sih is logically focused on one particular si core
+ * (the "current core").
+ * Use si_setcore() or si_setcoreidx() to change the association to another core
+ */
+
+#define        BADIDX          (SI_MAXCORES + 1)
+
+/* clkctl xtal what flags */
+#define        XTAL                    0x1     /* primary crystal oscillator (2050) */
+#define        PLL                     0x2     /* main chip pll */
+
+/* clkctl clk mode */
+#define        CLK_FAST                0       /* force fast (pll) clock */
+#define        CLK_DYNAMIC             2       /* enable dynamic clock control */
+
+/* GPIO usage priorities */
+#define GPIO_DRV_PRIORITY      0       /* Driver */
+#define GPIO_APP_PRIORITY      1       /* Application */
+#define GPIO_HI_PRIORITY       2       /* Highest priority. Ignore GPIO
+                                        * reservation
+                                        */
+
+/* GPIO pull up/down */
+#define GPIO_PULLUP            0
+#define GPIO_PULLDN            1
+
+/* GPIO event regtype */
+#define GPIO_REGEVT            0       /* GPIO register event */
+#define GPIO_REGEVT_INTMSK     1       /* GPIO register event int mask */
+#define GPIO_REGEVT_INTPOL     2       /* GPIO register event int polarity */
+
+/* device path */
+#define SI_DEVPATH_BUFSZ       16      /* min buffer size in bytes */
+
+/* SI routine enumeration: to be used by update function with multiple hooks */
+#define        SI_DOATTACH     1
+#define SI_PCIDOWN     2
+#define SI_PCIUP       3
+
+#define        ISSIM_ENAB(sih) 0
+
+/* PMU clock/power control */
+#if defined(BCMPMUCTL)
+#define PMUCTL_ENAB(sih)       (BCMPMUCTL)
+#else
+#define PMUCTL_ENAB(sih)       ((sih)->cccaps & CC_CAP_PMU)
+#endif
+
+/* chipcommon clock/power control (exclusive with PMU's) */
+#if defined(BCMPMUCTL) && BCMPMUCTL
+#define CCCTL_ENAB(sih)                (0)
+#define CCPLL_ENAB(sih)                (0)
+#else
+#define CCCTL_ENAB(sih)                ((sih)->cccaps & CC_CAP_PWR_CTL)
+#define CCPLL_ENAB(sih)                ((sih)->cccaps & CC_CAP_PLL_MASK)
+#endif
+
+typedef void (*gpio_handler_t) (u32 stat, void *arg);
+
+/* External PA enable mask */
+#define GPIO_CTRL_EPA_EN_MASK 0x40
+
+#define        SI_ERROR(args)
+
+#ifdef BCMDBG
+#define        SI_MSG(args)    printk args
+#else
+#define        SI_MSG(args)
+#endif                         /* BCMDBG */
+
+/* Define SI_VMSG to printf for verbose debugging, but don't check it in */
+#define        SI_VMSG(args)
+
+#define        IS_SIM(chippkg) \
+       ((chippkg == HDLSIM_PKG_ID) || (chippkg == HWSIM_PKG_ID))
+
+typedef u32(*si_intrsoff_t) (void *intr_arg);
+typedef void (*si_intrsrestore_t) (void *intr_arg, u32 arg);
+typedef bool(*si_intrsenabled_t) (void *intr_arg);
+
+typedef struct gpioh_item {
+       void *arg;
+       bool level;
+       gpio_handler_t handler;
+       u32 event;
+       struct gpioh_item *next;
+} gpioh_item_t;
+
+/* misc si info needed by some of the routines */
+typedef struct si_info {
+       struct si_pub pub;      /* back plane public state (must be first) */
+       void *pbus;             /* handle to bus (pci/sdio/..) */
+       uint dev_coreid;        /* the core provides driver functions */
+       void *intr_arg;         /* interrupt callback function arg */
+       si_intrsoff_t intrsoff_fn;      /* turns chip interrupts off */
+       si_intrsrestore_t intrsrestore_fn; /* restore chip interrupts */
+       si_intrsenabled_t intrsenabled_fn; /* check if interrupts are enabled */
+
+       void *pch;              /* PCI/E core handle */
+
+       gpioh_item_t *gpioh_head;       /* GPIO event handlers list */
+
+       bool memseg;            /* flag to toggle MEM_SEG register */
+
+       char *vars;
+       uint varsz;
+
+       void *curmap;           /* current regs va */
+       void *regs[SI_MAXCORES];        /* other regs va */
+
+       uint curidx;            /* current core index */
+       uint numcores;          /* # discovered cores */
+       uint coreid[SI_MAXCORES]; /* id of each core */
+       u32 coresba[SI_MAXCORES]; /* backplane address of each core */
+       void *regs2[SI_MAXCORES]; /* 2nd virtual address per core (usbh20) */
+       u32 coresba2[SI_MAXCORES]; /* 2nd phys address per core (usbh20) */
+       u32 coresba_size[SI_MAXCORES]; /* backplane address space size */
+       u32 coresba2_size[SI_MAXCORES]; /* second address space size */
+
+       void *curwrap;          /* current wrapper va */
+       void *wrappers[SI_MAXCORES];    /* other cores wrapper va */
+       u32 wrapba[SI_MAXCORES];        /* address of controlling wrapper */
+
+       u32 cia[SI_MAXCORES];   /* erom cia entry for each core */
+       u32 cib[SI_MAXCORES];   /* erom cia entry for each core */
+       u32 oob_router; /* oob router registers for axi */
+} si_info_t;
+
+/* AMBA Interconnect exported externs */
+extern void ai_scan(si_t *sih, void *regs, uint devid);
+
+extern uint ai_flag(si_t *sih);
+extern void ai_setint(si_t *sih, int siflag);
+extern uint ai_coreidx(si_t *sih);
+extern uint ai_corevendor(si_t *sih);
+extern uint ai_corerev(si_t *sih);
+extern bool ai_iscoreup(si_t *sih);
+extern void *ai_setcoreidx(si_t *sih, uint coreidx);
+extern u32 ai_core_cflags(si_t *sih, u32 mask, u32 val);
+extern void ai_core_cflags_wo(si_t *sih, u32 mask, u32 val);
+extern u32 ai_core_sflags(si_t *sih, u32 mask, u32 val);
+extern uint ai_corereg(si_t *sih, uint coreidx, uint regoff, uint mask,
+                      uint val);
+extern void ai_core_reset(si_t *sih, u32 bits, u32 resetbits);
+extern void ai_core_disable(si_t *sih, u32 bits);
+extern int ai_numaddrspaces(si_t *sih);
+extern u32 ai_addrspace(si_t *sih, uint asidx);
+extern u32 ai_addrspacesize(si_t *sih, uint asidx);
+extern void ai_write_wrap_reg(si_t *sih, u32 offset, u32 val);
+
+/* === exported functions === */
+extern si_t *ai_attach(uint pcidev, void *regs, uint bustype,
+                      void *sdh, char **vars, uint *varsz);
+
+extern void ai_detach(si_t *sih);
+extern bool ai_pci_war16165(si_t *sih);
+
+extern uint ai_coreid(si_t *sih);
+extern uint ai_corerev(si_t *sih);
+extern uint ai_corereg(si_t *sih, uint coreidx, uint regoff, uint mask,
+               uint val);
+extern void ai_write_wrapperreg(si_t *sih, u32 offset, u32 val);
+extern u32 ai_core_cflags(si_t *sih, u32 mask, u32 val);
+extern u32 ai_core_sflags(si_t *sih, u32 mask, u32 val);
+extern bool ai_iscoreup(si_t *sih);
+extern uint ai_findcoreidx(si_t *sih, uint coreid, uint coreunit);
+extern void *ai_setcoreidx(si_t *sih, uint coreidx);
+extern void *ai_setcore(si_t *sih, uint coreid, uint coreunit);
+extern void *ai_switch_core(si_t *sih, uint coreid, uint *origidx,
+                           uint *intr_val);
+extern void ai_restore_core(si_t *sih, uint coreid, uint intr_val);
+extern void ai_core_reset(si_t *sih, u32 bits, u32 resetbits);
+extern void ai_core_disable(si_t *sih, u32 bits);
+extern u32 ai_alp_clock(si_t *sih);
+extern u32 ai_ilp_clock(si_t *sih);
+extern void ai_pci_setup(si_t *sih, uint coremask);
+extern void ai_setint(si_t *sih, int siflag);
+extern bool ai_backplane64(si_t *sih);
+extern void ai_register_intr_callback(si_t *sih, void *intrsoff_fn,
+                                     void *intrsrestore_fn,
+                                     void *intrsenabled_fn, void *intr_arg);
+extern void ai_deregister_intr_callback(si_t *sih);
+extern void ai_clkctl_init(si_t *sih);
+extern u16 ai_clkctl_fast_pwrup_delay(si_t *sih);
+extern bool ai_clkctl_cc(si_t *sih, uint mode);
+extern int ai_clkctl_xtal(si_t *sih, uint what, bool on);
+extern bool ai_deviceremoved(si_t *sih);
+extern u32 ai_gpiocontrol(si_t *sih, u32 mask, u32 val,
+                            u8 priority);
+
+/* OTP status */
+extern bool ai_is_otp_disabled(si_t *sih);
+extern bool ai_is_otp_powered(si_t *sih);
+extern void ai_otp_power(si_t *sih, bool on);
+
+/* SPROM availability */
+extern bool ai_is_sprom_available(si_t *sih);
+
+/*
+ * Build device path. Path size must be >= SI_DEVPATH_BUFSZ.
+ * The returned path is NULL terminated and has trailing '/'.
+ * Return 0 on success, nonzero otherwise.
+ */
+extern int ai_devpath(si_t *sih, char *path, int size);
+/* Read variable with prepending the devpath to the name */
+extern char *ai_getdevpathvar(si_t *sih, const char *name);
+extern int ai_getdevpathintvar(si_t *sih, const char *name);
+
+extern void ai_pci_sleep(si_t *sih);
+extern void ai_pci_down(si_t *sih);
+extern void ai_pci_up(si_t *sih);
+extern int ai_pci_fixcfg(si_t *sih);
+
+extern void ai_chipcontrl_epa4331(si_t *sih, bool on);
+/* Enable Ex-PA for 4313 */
+extern void ai_epa_4313war(si_t *sih);
+
+char *ai_getnvramflvar(si_t *sih, const char *name);
+
+#endif                         /* _aiutils_h_ */
similarity index 90%
rename from drivers/staging/brcm80211/util/bcmotp.c
rename to drivers/staging/brcm80211/brcmsmac/bcmotp.c
index 17991212a22d7a6ed73ae1ad7e8368a4a6ceb1f0..d09628b5a88e8b7be95fc2de1aef11653e1be7e5 100644 (file)
 #include <linux/delay.h>
 #include <linux/kernel.h>
 #include <linux/string.h>
-#include <bcmdefs.h>
 #include <linux/module.h>
 #include <linux/pci.h>
+#include <linux/crc-ccitt.h>
+
+#include <bcmdefs.h>
 #include <bcmdevs.h>
 #include <bcmutils.h>
-#include <siutils.h>
+#include <aiutils.h>
 #include <hndsoc.h>
 #include <sbchipc.h>
 #include <bcmotp.h>
-#include "siutils_priv.h"
 
 /*
  * There are two different OTP controllers so far:
@@ -177,9 +178,6 @@ static u16 ipxotp_otpr(void *oh, chipcregs_t *cc, uint wn)
 
        oi = (otpinfo_t *) oh;
 
-       ASSERT(wn < oi->wsize);
-       ASSERT(cc != NULL);
-
        return R_REG(&cc->sromotp[wn]);
 }
 
@@ -229,7 +227,7 @@ static int ipxotp_max_rgnsz(si_t *sih, int osizew)
                ret = osizew * 2 - OTP_SZ_FU_72 - OTP_SZ_CHECKSUM;
                break;
        default:
-               ASSERT(0);      /* Don't know about this chip */
+               break;  /* Don't know about this chip */
        }
 
        return ret;
@@ -313,19 +311,16 @@ static void *ipxotp_init(si_t *sih)
        otpinfo_t *oi;
 
        /* Make sure we're running IPX OTP */
-       ASSERT(OTPTYPE_IPX(sih->ccrev));
        if (!OTPTYPE_IPX(sih->ccrev))
                return NULL;
 
        /* Make sure OTP is not disabled */
-       if (si_is_otp_disabled(sih)) {
+       if (ai_is_otp_disabled(sih))
                return NULL;
-       }
 
        /* Make sure OTP is powered up */
-       if (!si_is_otp_powered(sih)) {
+       if (!ai_is_otp_powered(sih))
                return NULL;
-       }
 
        oi = &otpinfo;
 
@@ -360,13 +355,12 @@ static void *ipxotp_init(si_t *sih)
        }
 
        /* Retrieve OTP region info */
-       idx = si_coreidx(sih);
-       cc = si_setcoreidx(sih, SI_CC_IDX);
-       ASSERT(cc != NULL);
+       idx = ai_coreidx(sih);
+       cc = ai_setcoreidx(sih, SI_CC_IDX);
 
        _ipxotp_init(oi, cc);
 
-       si_setcoreidx(sih, idx);
+       ai_setcoreidx(sih, idx);
 
        return (void *)oi;
 }
@@ -384,11 +378,11 @@ static int ipxotp_read_region(void *oh, int region, u16 *data, uint *wlen)
                sz = (uint) oi->hwlim - oi->hwbase;
                if (!(oi->status & OTPS_GUP_HW)) {
                        *wlen = sz;
-                       return BCME_NOTFOUND;
+                       return -ENODATA;
                }
                if (*wlen < sz) {
                        *wlen = sz;
-                       return BCME_BUFTOOSHORT;
+                       return -EOVERFLOW;
                }
                base = oi->hwbase;
                break;
@@ -396,11 +390,11 @@ static int ipxotp_read_region(void *oh, int region, u16 *data, uint *wlen)
                sz = ((uint) oi->swlim - oi->swbase);
                if (!(oi->status & OTPS_GUP_SW)) {
                        *wlen = sz;
-                       return BCME_NOTFOUND;
+                       return -ENODATA;
                }
                if (*wlen < sz) {
                        *wlen = sz;
-                       return BCME_BUFTOOSHORT;
+                       return -EOVERFLOW;
                }
                base = oi->swbase;
                break;
@@ -408,11 +402,11 @@ static int ipxotp_read_region(void *oh, int region, u16 *data, uint *wlen)
                sz = OTPGU_CI_SZ;
                if (!(oi->status & OTPS_GUP_CI)) {
                        *wlen = sz;
-                       return BCME_NOTFOUND;
+                       return -ENODATA;
                }
                if (*wlen < sz) {
                        *wlen = sz;
-                       return BCME_BUFTOOSHORT;
+                       return -EOVERFLOW;
                }
                base = oi->otpgu_base + OTPGU_CI_OFF;
                break;
@@ -420,11 +414,11 @@ static int ipxotp_read_region(void *oh, int region, u16 *data, uint *wlen)
                sz = (uint) oi->flim - oi->fbase;
                if (!(oi->status & OTPS_GUP_FUSE)) {
                        *wlen = sz;
-                       return BCME_NOTFOUND;
+                       return -ENODATA;
                }
                if (*wlen < sz) {
                        *wlen = sz;
-                       return BCME_BUFTOOSHORT;
+                       return -EOVERFLOW;
                }
                base = oi->fbase;
                break;
@@ -432,34 +426,33 @@ static int ipxotp_read_region(void *oh, int region, u16 *data, uint *wlen)
                sz = ((uint) oi->flim - oi->hwbase);
                if (!(oi->status & (OTPS_GUP_HW | OTPS_GUP_SW))) {
                        *wlen = sz;
-                       return BCME_NOTFOUND;
+                       return -ENODATA;
                }
                if (*wlen < sz) {
                        *wlen = sz;
-                       return BCME_BUFTOOSHORT;
+                       return -EOVERFLOW;
                }
                base = oi->hwbase;
                break;
        default:
-               return BCME_BADARG;
+               return -EINVAL;
        }
 
-       idx = si_coreidx(oi->sih);
-       cc = si_setcoreidx(oi->sih, SI_CC_IDX);
-       ASSERT(cc != NULL);
+       idx = ai_coreidx(oi->sih);
+       cc = ai_setcoreidx(oi->sih, SI_CC_IDX);
 
        /* Read the data */
        for (i = 0; i < sz; i++)
                data[i] = ipxotp_otpr(oh, cc, base + i);
 
-       si_setcoreidx(oi->sih, idx);
+       ai_setcoreidx(oi->sih, idx);
        *wlen = sz;
        return 0;
 }
 
 static int ipxotp_nvread(void *oh, char *data, uint *len)
 {
-       return BCME_UNSUPPORTED;
+       return -ENOTSUPP;
 }
 
 static otp_fn_t ipxotp_fn = {
@@ -567,14 +560,8 @@ static int hndotp_size(void *oh)
 
 static u16 hndotp_otpr(void *oh, chipcregs_t *cc, uint wn)
 {
-#ifdef BCMDBG
-       otpinfo_t *oi = (otpinfo_t *) oh;
-#endif
        volatile u16 *ptr;
 
-       ASSERT(wn < ((oi->size / 2) + OTP_RC_LIM_OFF));
-       ASSERT(cc != NULL);
-
        ptr = (volatile u16 *)((volatile char *)cc + CC_SROM_OTP);
        return R_REG(&ptr[wn]);
 }
@@ -584,10 +571,6 @@ static u16 hndotp_otproff(void *oh, chipcregs_t *cc, int woff)
        otpinfo_t *oi = (otpinfo_t *) oh;
        volatile u16 *ptr;
 
-       ASSERT(woff >= (-((int)oi->size / 2)));
-       ASSERT(woff < OTP_LIM_OFF);
-       ASSERT(cc != NULL);
-
        ptr = (volatile u16 *)((volatile char *)cc + CC_SROM_OTP);
 
        return R_REG(&ptr[(oi->size / 2) + woff]);
@@ -631,10 +614,10 @@ static void *hndotp_init(si_t *sih)
 
        oi = &otpinfo;
 
-       idx = si_coreidx(sih);
+       idx = ai_coreidx(sih);
 
        /* Check for otp */
-       cc = si_setcoreidx(sih, SI_CC_IDX);
+       cc = ai_setcoreidx(sih, SI_CC_IDX);
        if (cc != NULL) {
                cap = R_REG(&cc->capabilities);
                if ((cap & CC_CAP_OTPSIZE) == 0) {
@@ -642,11 +625,7 @@ static void *hndotp_init(si_t *sih)
                        goto out;
                }
 
-               /* As of right now, support only 4320a2, 4311a1 and 4312 */
-               ASSERT((oi->ccrev == 12) || (oi->ccrev == 17)
-                      || (oi->ccrev == 22));
-               if (!
-                   ((oi->ccrev == 12) || (oi->ccrev == 17)
+               if (!((oi->ccrev == 12) || (oi->ccrev == 17)
                     || (oi->ccrev == 22)))
                        return NULL;
 
@@ -690,7 +669,7 @@ static void *hndotp_init(si_t *sih)
        }
 
  out:                          /* All done */
-       si_setcoreidx(sih, idx);
+       ai_setcoreidx(sih, idx);
 
        return ret;
 }
@@ -702,25 +681,30 @@ static int hndotp_read_region(void *oh, int region, u16 *data, uint *wlen)
        chipcregs_t *cc;
        int i;
 
-       /* Only support HW region (no active chips use HND OTP SW region) */
-       ASSERT(region == OTP_HW_REGION);
+
+       if (region != OTP_HW_REGION) {
+               /*
+                * Only support HW region
+                * (no active chips use HND OTP SW region)
+                * */
+               return -ENOTSUPP;
+       }
 
        /* Region empty? */
        st = oi->hwprot | oi->signvalid;
        if ((st & region) == 0)
-               return BCME_NOTFOUND;
+               return -ENODATA;
 
        *wlen =
            ((int)*wlen < oi->boundary / 2) ? *wlen : (uint) oi->boundary / 2;
 
-       idx = si_coreidx(oi->sih);
-       cc = si_setcoreidx(oi->sih, SI_CC_IDX);
-       ASSERT(cc != NULL);
+       idx = ai_coreidx(oi->sih);
+       cc = ai_setcoreidx(oi->sih, SI_CC_IDX);
 
        for (i = 0; i < (int)*wlen; i++)
                data[i] = hndotp_otpr(oh, cc, i);
 
-       si_setcoreidx(oi->sih, idx);
+       ai_setcoreidx(oi->sih, idx);
 
        return 0;
 }
@@ -737,9 +721,8 @@ static int hndotp_nvread(void *oh, char *data, uint *len)
        u16 *rawotp = NULL;
 
        /* save the orig core */
-       idx = si_coreidx(oi->sih);
-       cc = si_setcoreidx(oi->sih, SI_CC_IDX);
-       ASSERT(cc != NULL);
+       idx = ai_coreidx(oi->sih);
+       cc = ai_setcoreidx(oi->sih, SI_CC_IDX);
 
        st = hndotp_status(oh);
        if (!(st & (OTP_HW_REGION | OTP_SW_REGION))) {
@@ -797,8 +780,8 @@ static int hndotp_nvread(void *oh, char *data, uint *len)
                        /* Bad length, try to find another chunk anyway */
                        rsz = 6;
                }
-               if (hndcrc16((u8 *) &rawotp[i], rsz,
-                            CRC16_INIT_VALUE) == CRC16_GOOD_VALUE) {
+               if (crc_ccitt(CRC16_INIT_VALUE, (u8 *) &rawotp[i], rsz) ==
+                       CRC16_GOOD_VALUE) {
                        /* Good crc, copy the vars */
                        gchunks++;
                        dsz = rsz - 6;
@@ -831,7 +814,7 @@ static int hndotp_nvread(void *oh, char *data, uint *len)
 
  out:
        kfree(rawotp);
-       si_setcoreidx(oi->sih, idx);
+       ai_setcoreidx(oi->sih, idx);
 
        return rc;
 }
@@ -876,10 +859,10 @@ int otp_size(void *oh)
 u16 otp_read_bit(void *oh, uint offset)
 {
        otpinfo_t *oi = (otpinfo_t *) oh;
-       uint idx = si_coreidx(oi->sih);
-       chipcregs_t *cc = si_setcoreidx(oi->sih, SI_CC_IDX);
+       uint idx = ai_coreidx(oi->sih);
+       chipcregs_t *cc = ai_setcoreidx(oi->sih, SI_CC_IDX);
        u16 readBit = (u16) oi->fn->read_bit(oh, cc, offset);
-       si_setcoreidx(oi->sih, idx);
+       ai_setcoreidx(oi->sih, idx);
        return readBit;
 }
 
@@ -921,18 +904,18 @@ otp_read_region(si_t *sih, int region, u16 *data,
        void *oh;
        int err = 0;
 
-       wasup = si_is_otp_powered(sih);
+       wasup = ai_is_otp_powered(sih);
        if (!wasup)
-               si_otp_power(sih, true);
+               ai_otp_power(sih, true);
 
-       if (!si_is_otp_powered(sih) || si_is_otp_disabled(sih)) {
-               err = BCME_NOTREADY;
+       if (!ai_is_otp_powered(sih) || ai_is_otp_disabled(sih)) {
+               err = -EPERM;
                goto out;
        }
 
        oh = otp_init(sih);
        if (oh == NULL) {
-               err = BCME_ERROR;
+               err = -EBADE;
                goto out;
        }
 
@@ -940,7 +923,7 @@ otp_read_region(si_t *sih, int region, u16 *data,
 
  out:
        if (!wasup)
-               si_otp_power(sih, false);
+               ai_otp_power(sih, false);
 
        return err;
 }
diff --git a/drivers/staging/brcm80211/brcmsmac/bcmsrom.c b/drivers/staging/brcm80211/brcmsmac/bcmsrom.c
new file mode 100644 (file)
index 0000000..bbfc642
--- /dev/null
@@ -0,0 +1,714 @@
+/*
+ * Copyright (c) 2010 Broadcom Corporation
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+#include <linux/kernel.h>
+#include <linux/string.h>
+#include <linux/etherdevice.h>
+#include <bcmdefs.h>
+#include <linux/module.h>
+#include <linux/pci.h>
+#include <stdarg.h>
+#include <bcmutils.h>
+#include <hndsoc.h>
+#include <sbchipc.h>
+#include <bcmdevs.h>
+#include <pcicfg.h>
+#include <aiutils.h>
+#include <bcmsrom.h>
+#include <bcmsrom_tbl.h>
+
+#include <bcmnvram.h>
+#include <bcmotp.h>
+
+#define SROM_OFFSET(sih) ((sih->ccrev > 31) ? \
+       (((sih->cccaps & CC_CAP_SROM) == 0) ? NULL : \
+        ((u8 *)curmap + PCI_16KB0_CCREGS_OFFSET + CC_SROM_OTP)) : \
+       ((u8 *)curmap + PCI_BAR0_SPROM_OFFSET))
+
+#if defined(BCMDBG)
+#define WRITE_ENABLE_DELAY     500     /* 500 ms after write enable/disable toggle */
+#define WRITE_WORD_DELAY       20      /* 20 ms between each word write */
+#endif
+
+typedef struct varbuf {
+       char *base;             /* pointer to buffer base */
+       char *buf;              /* pointer to current position */
+       unsigned int size;      /* current (residual) size in bytes */
+} varbuf_t;
+extern char *_vars;
+extern uint _varsz;
+
+static int initvars_srom_si(si_t *sih, void *curmap, char **vars, uint *count);
+static void _initvars_srom_pci(u8 sromrev, u16 *srom, uint off, varbuf_t *b);
+static int initvars_srom_pci(si_t *sih, void *curmap, char **vars, uint *count);
+static int initvars_flash_si(si_t *sih, char **vars, uint *count);
+static int sprom_read_pci(si_t *sih, u16 *sprom,
+                         uint wordoff, u16 *buf, uint nwords, bool check_crc);
+#if defined(BCMNVRAMR)
+static int otp_read_pci(si_t *sih, u16 *buf, uint bufsz);
+#endif
+static u16 srom_cc_cmd(si_t *sih, void *ccregs, u32 cmd,
+                         uint wordoff, u16 data);
+
+static int initvars_table(char *start, char *end,
+                         char **vars, uint *count);
+static int initvars_flash(si_t *sih, char **vp,
+                         uint len);
+
+/* Initialization of varbuf structure */
+static void varbuf_init(varbuf_t *b, char *buf, uint size)
+{
+       b->size = size;
+       b->base = b->buf = buf;
+}
+
+/* append a null terminated var=value string */
+static int varbuf_append(varbuf_t *b, const char *fmt, ...)
+{
+       va_list ap;
+       int r;
+       size_t len;
+       char *s;
+
+       if (b->size < 2)
+               return 0;
+
+       va_start(ap, fmt);
+       r = vsnprintf(b->buf, b->size, fmt, ap);
+       va_end(ap);
+
+       /* C99 snprintf behavior returns r >= size on overflow,
+        * others return -1 on overflow.
+        * All return -1 on format error.
+        * We need to leave room for 2 null terminations, one for the current var
+        * string, and one for final null of the var table. So check that the
+        * strlen written, r, leaves room for 2 chars.
+        */
+       if ((r == -1) || (r > (int)(b->size - 2))) {
+               b->size = 0;
+               return 0;
+       }
+
+       /* Remove any earlier occurrence of the same variable */
+       s = strchr(b->buf, '=');
+       if (s != NULL) {
+               len = (size_t) (s - b->buf);
+               for (s = b->base; s < b->buf;) {
+                       if ((memcmp(s, b->buf, len) == 0) && s[len] == '=') {
+                               len = strlen(s) + 1;
+                               memmove(s, (s + len),
+                                       ((b->buf + r + 1) - (s + len)));
+                               b->buf -= len;
+                               b->size += (unsigned int)len;
+                               break;
+                       }
+
+                       while (*s++)
+                               ;
+               }
+       }
+
+       /* skip over this string's null termination */
+       r++;
+       b->size -= r;
+       b->buf += r;
+
+       return r;
+}
+
+/*
+ * Initialize local vars from the right source for this platform.
+ * Return 0 on success, nonzero on error.
+ */
+int srom_var_init(si_t *sih, uint bustype, void *curmap,
+                 char **vars, uint *count)
+{
+       uint len;
+
+       len = 0;
+
+       if (vars == NULL || count == NULL)
+               return 0;
+
+       *vars = NULL;
+       *count = 0;
+
+       switch (bustype) {
+       case SI_BUS:
+       case JTAG_BUS:
+               return initvars_srom_si(sih, curmap, vars, count);
+
+       case PCI_BUS:
+               if (curmap == NULL)
+                       return -1;
+
+               return initvars_srom_pci(sih, curmap, vars, count);
+
+       default:
+               break;
+       }
+       return -1;
+}
+
+/* In chips with chipcommon rev 32 and later, the srom is in chipcommon,
+ * not in the bus cores.
+ */
+static u16
+srom_cc_cmd(si_t *sih, void *ccregs, u32 cmd,
+           uint wordoff, u16 data)
+{
+       chipcregs_t *cc = (chipcregs_t *) ccregs;
+       uint wait_cnt = 1000;
+
+       if ((cmd == SRC_OP_READ) || (cmd == SRC_OP_WRITE)) {
+               W_REG(&cc->sromaddress, wordoff * 2);
+               if (cmd == SRC_OP_WRITE)
+                       W_REG(&cc->sromdata, data);
+       }
+
+       W_REG(&cc->sromcontrol, SRC_START | cmd);
+
+       while (wait_cnt--) {
+               if ((R_REG(&cc->sromcontrol) & SRC_BUSY) == 0)
+                       break;
+       }
+
+       if (!wait_cnt) {
+               return 0xffff;
+       }
+       if (cmd == SRC_OP_READ)
+               return (u16) R_REG(&cc->sromdata);
+       else
+               return 0xffff;
+}
+
+static inline void ltoh16_buf(u16 *buf, unsigned int size)
+{
+       for (size /= 2; size; size--)
+               *(buf + size) = le16_to_cpu(*(buf + size));
+}
+
+static inline void htol16_buf(u16 *buf, unsigned int size)
+{
+       for (size /= 2; size; size--)
+               *(buf + size) = cpu_to_le16(*(buf + size));
+}
+
+/*
+ * Read in and validate sprom.
+ * Return 0 on success, nonzero on error.
+ */
+static int
+sprom_read_pci(si_t *sih, u16 *sprom, uint wordoff,
+              u16 *buf, uint nwords, bool check_crc)
+{
+       int err = 0;
+       uint i;
+       void *ccregs = NULL;
+
+       /* read the sprom */
+       for (i = 0; i < nwords; i++) {
+
+               if (sih->ccrev > 31 && ISSIM_ENAB(sih)) {
+                       /* use indirect since direct is too slow on QT */
+                       if ((sih->cccaps & CC_CAP_SROM) == 0)
+                               return 1;
+
+                       ccregs = (void *)((u8 *) sprom - CC_SROM_OTP);
+                       buf[i] =
+                           srom_cc_cmd(sih, ccregs, SRC_OP_READ,
+                                       wordoff + i, 0);
+
+               } else {
+                       if (ISSIM_ENAB(sih))
+                               buf[i] = R_REG(&sprom[wordoff + i]);
+
+                       buf[i] = R_REG(&sprom[wordoff + i]);
+               }
+
+       }
+
+       /* bypass crc checking for simulation to allow srom hack */
+       if (ISSIM_ENAB(sih))
+               return err;
+
+       if (check_crc) {
+
+               if (buf[0] == 0xffff) {
+                       /* The hardware thinks that an srom that starts with 0xffff
+                        * is blank, regardless of the rest of the content, so declare
+                        * it bad.
+                        */
+                       return 1;
+               }
+
+               /* fixup the endianness so crc8 will pass */
+               htol16_buf(buf, nwords * 2);
+               if (bcm_crc8((u8 *) buf, nwords * 2, CRC8_INIT_VALUE) !=
+                   CRC8_GOOD_VALUE) {
+                       /* DBG only pci always read srom4 first, then srom8/9 */
+                       err = 1;
+               }
+               /* now correct the endianness of the byte array */
+               ltoh16_buf(buf, nwords * 2);
+       }
+       return err;
+}
+
+#if defined(BCMNVRAMR)
+static int otp_read_pci(si_t *sih, u16 *buf, uint bufsz)
+{
+       u8 *otp;
+       uint sz = OTP_SZ_MAX / 2;       /* size in words */
+       int err = 0;
+
+       otp = kzalloc(OTP_SZ_MAX, GFP_ATOMIC);
+       if (otp == NULL) {
+               return -EBADE;
+       }
+
+       err = otp_read_region(sih, OTP_HW_RGN, (u16 *) otp, &sz);
+
+       memcpy(buf, otp, bufsz);
+
+       kfree(otp);
+
+       /* Check CRC */
+       if (buf[0] == 0xffff) {
+               /* The hardware thinks that an srom that starts with 0xffff
+                * is blank, regardless of the rest of the content, so declare
+                * it bad.
+                */
+               return 1;
+       }
+
+       /* fixup the endianness so crc8 will pass */
+       htol16_buf(buf, bufsz);
+       if (bcm_crc8((u8 *) buf, SROM4_WORDS * 2, CRC8_INIT_VALUE) !=
+           CRC8_GOOD_VALUE) {
+               err = 1;
+       }
+       /* now correct the endianness of the byte array */
+       ltoh16_buf(buf, bufsz);
+
+       return err;
+}
+#endif                         /* defined(BCMNVRAMR) */
+/*
+* Create variable table from memory.
+* Return 0 on success, nonzero on error.
+*/
+static int initvars_table(char *start, char *end,
+                         char **vars, uint *count)
+{
+       int c = (int)(end - start);
+
+       /* do it only when there is more than just the null string */
+       if (c > 1) {
+               char *vp = kmalloc(c, GFP_ATOMIC);
+               if (!vp)
+                       return -ENOMEM;
+               memcpy(vp, start, c);
+               *vars = vp;
+               *count = c;
+       } else {
+               *vars = NULL;
+               *count = 0;
+       }
+
+       return 0;
+}
+
+/*
+ * Find variables with <devpath> from flash. 'base' points to the beginning
+ * of the table upon enter and to the end of the table upon exit when success.
+ * Return 0 on success, nonzero on error.
+ */
+static int initvars_flash(si_t *sih, char **base, uint len)
+{
+       char *vp = *base;
+       char *flash;
+       int err;
+       char *s;
+       uint l, dl, copy_len;
+       char devpath[SI_DEVPATH_BUFSZ];
+
+       /* allocate memory and read in flash */
+       flash = kmalloc(NVRAM_SPACE, GFP_ATOMIC);
+       if (!flash)
+               return -ENOMEM;
+       err = nvram_getall(flash, NVRAM_SPACE);
+       if (err)
+               goto exit;
+
+       ai_devpath(sih, devpath, sizeof(devpath));
+
+       /* grab vars with the <devpath> prefix in name */
+       dl = strlen(devpath);
+       for (s = flash; s && *s; s += l + 1) {
+               l = strlen(s);
+
+               /* skip non-matching variable */
+               if (strncmp(s, devpath, dl))
+                       continue;
+
+               /* is there enough room to copy? */
+               copy_len = l - dl + 1;
+               if (len < copy_len) {
+                       err = -EOVERFLOW;
+                       goto exit;
+               }
+
+               /* no prefix, just the name=value */
+               strncpy(vp, &s[dl], copy_len);
+               vp += copy_len;
+               len -= copy_len;
+       }
+
+       /* add null string as terminator */
+       if (len < 1) {
+               err = -EOVERFLOW;
+               goto exit;
+       }
+       *vp++ = '\0';
+
+       *base = vp;
+
+ exit: kfree(flash);
+       return err;
+}
+
+/*
+ * Initialize nonvolatile variable table from flash.
+ * Return 0 on success, nonzero on error.
+ */
+static int initvars_flash_si(si_t *sih, char **vars, uint *count)
+{
+       char *vp, *base;
+       int err;
+
+       base = vp = kmalloc(MAXSZ_NVRAM_VARS, GFP_ATOMIC);
+       if (!vp)
+               return -ENOMEM;
+
+       err = initvars_flash(sih, &vp, MAXSZ_NVRAM_VARS);
+       if (err == 0)
+               err = initvars_table(base, vp, vars, count);
+
+       kfree(base);
+
+       return err;
+}
+
+/* Parse SROM and create name=value pairs. 'srom' points to
+ * the SROM word array. 'off' specifies the offset of the
+ * first word 'srom' points to, which should be either 0 or
+ * SROM3_SWRG_OFF (full SROM or software region).
+ */
+
+static uint mask_shift(u16 mask)
+{
+       uint i;
+       for (i = 0; i < (sizeof(mask) << 3); i++) {
+               if (mask & (1 << i))
+                       return i;
+       }
+       return 0;
+}
+
+static uint mask_width(u16 mask)
+{
+       int i;
+       for (i = (sizeof(mask) << 3) - 1; i >= 0; i--) {
+               if (mask & (1 << i))
+                       return (uint) (i - mask_shift(mask) + 1);
+       }
+       return 0;
+}
+
+static void _initvars_srom_pci(u8 sromrev, u16 *srom, uint off, varbuf_t *b)
+{
+       u16 w;
+       u32 val;
+       const sromvar_t *srv;
+       uint width;
+       uint flags;
+       u32 sr = (1 << sromrev);
+
+       varbuf_append(b, "sromrev=%d", sromrev);
+
+       for (srv = pci_sromvars; srv->name != NULL; srv++) {
+               const char *name;
+
+               if ((srv->revmask & sr) == 0)
+                       continue;
+
+               if (srv->off < off)
+                       continue;
+
+               flags = srv->flags;
+               name = srv->name;
+
+               /* This entry is for mfgc only. Don't generate param for it, */
+               if (flags & SRFL_NOVAR)
+                       continue;
+
+               if (flags & SRFL_ETHADDR) {
+                       u8 ea[ETH_ALEN];
+
+                       ea[0] = (srom[srv->off - off] >> 8) & 0xff;
+                       ea[1] = srom[srv->off - off] & 0xff;
+                       ea[2] = (srom[srv->off + 1 - off] >> 8) & 0xff;
+                       ea[3] = srom[srv->off + 1 - off] & 0xff;
+                       ea[4] = (srom[srv->off + 2 - off] >> 8) & 0xff;
+                       ea[5] = srom[srv->off + 2 - off] & 0xff;
+
+                       varbuf_append(b, "%s=%pM", name, ea);
+               } else {
+                       w = srom[srv->off - off];
+                       val = (w & srv->mask) >> mask_shift(srv->mask);
+                       width = mask_width(srv->mask);
+
+                       while (srv->flags & SRFL_MORE) {
+                               srv++;
+                               if (srv->off == 0 || srv->off < off)
+                                       continue;
+
+                               w = srom[srv->off - off];
+                               val +=
+                                   ((w & srv->mask) >> mask_shift(srv->
+                                                                  mask)) <<
+                                   width;
+                               width += mask_width(srv->mask);
+                       }
+
+                       if ((flags & SRFL_NOFFS)
+                           && ((int)val == (1 << width) - 1))
+                               continue;
+
+                       if (flags & SRFL_CCODE) {
+                               if (val == 0)
+                                       varbuf_append(b, "ccode=");
+                               else
+                                       varbuf_append(b, "ccode=%c%c",
+                                                     (val >> 8), (val & 0xff));
+                       }
+                       /* LED Powersave duty cycle has to be scaled:
+                        *(oncount >> 24) (offcount >> 8)
+                        */
+                       else if (flags & SRFL_LEDDC) {
+                               u32 w32 = (((val >> 8) & 0xff) << 24) | /* oncount */
+                                   (((val & 0xff)) << 8);      /* offcount */
+                               varbuf_append(b, "leddc=%d", w32);
+                       } else if (flags & SRFL_PRHEX)
+                               varbuf_append(b, "%s=0x%x", name, val);
+                       else if ((flags & SRFL_PRSIGN)
+                                && (val & (1 << (width - 1))))
+                               varbuf_append(b, "%s=%d", name,
+                                             (int)(val | (~0 << width)));
+                       else
+                               varbuf_append(b, "%s=%u", name, val);
+               }
+       }
+
+       if (sromrev >= 4) {
+               /* Do per-path variables */
+               uint p, pb, psz;
+
+               if (sromrev >= 8) {
+                       pb = SROM8_PATH0;
+                       psz = SROM8_PATH1 - SROM8_PATH0;
+               } else {
+                       pb = SROM4_PATH0;
+                       psz = SROM4_PATH1 - SROM4_PATH0;
+               }
+
+               for (p = 0; p < MAX_PATH_SROM; p++) {
+                       for (srv = perpath_pci_sromvars; srv->name != NULL;
+                            srv++) {
+                               if ((srv->revmask & sr) == 0)
+                                       continue;
+
+                               if (pb + srv->off < off)
+                                       continue;
+
+                               /* This entry is for mfgc only. Don't generate param for it, */
+                               if (srv->flags & SRFL_NOVAR)
+                                       continue;
+
+                               w = srom[pb + srv->off - off];
+                               val = (w & srv->mask) >> mask_shift(srv->mask);
+                               width = mask_width(srv->mask);
+
+                               /* Cheating: no per-path var is more than 1 word */
+
+                               if ((srv->flags & SRFL_NOFFS)
+                                   && ((int)val == (1 << width) - 1))
+                                       continue;
+
+                               if (srv->flags & SRFL_PRHEX)
+                                       varbuf_append(b, "%s%d=0x%x", srv->name,
+                                                     p, val);
+                               else
+                                       varbuf_append(b, "%s%d=%d", srv->name,
+                                                     p, val);
+                       }
+                       pb += psz;
+               }
+       }
+}
+
+/*
+ * Initialize nonvolatile variable table from sprom.
+ * Return 0 on success, nonzero on error.
+ */
+static int initvars_srom_pci(si_t *sih, void *curmap, char **vars, uint *count)
+{
+       u16 *srom, *sromwindow;
+       u8 sromrev = 0;
+       u32 sr;
+       varbuf_t b;
+       char *vp, *base = NULL;
+       bool flash = false;
+       int err = 0;
+
+       /*
+        * Apply CRC over SROM content regardless SROM is present or not,
+        * and use variable <devpath>sromrev's existence in flash to decide
+        * if we should return an error when CRC fails or read SROM variables
+        * from flash.
+        */
+       srom = kmalloc(SROM_MAX, GFP_ATOMIC);
+       if (!srom)
+               return -2;
+
+       sromwindow = (u16 *) SROM_OFFSET(sih);
+       if (ai_is_sprom_available(sih)) {
+               err =
+                   sprom_read_pci(sih, sromwindow, 0, srom, SROM_WORDS,
+                                  true);
+
+               if ((srom[SROM4_SIGN] == SROM4_SIGNATURE) ||
+                   (((sih->buscoretype == PCIE_CORE_ID)
+                     && (sih->buscorerev >= 6))
+                    || ((sih->buscoretype == PCI_CORE_ID)
+                        && (sih->buscorerev >= 0xe)))) {
+                       /* sromrev >= 4, read more */
+                       err =
+                           sprom_read_pci(sih, sromwindow, 0, srom,
+                                          SROM4_WORDS, true);
+                       sromrev = srom[SROM4_CRCREV] & 0xff;
+               } else if (err == 0) {
+                       /* srom is good and is rev < 4 */
+                       /* top word of sprom contains version and crc8 */
+                       sromrev = srom[SROM_CRCREV] & 0xff;
+                       /* bcm4401 sroms misprogrammed */
+                       if (sromrev == 0x10)
+                               sromrev = 1;
+               }
+       }
+#if defined(BCMNVRAMR)
+       /* Use OTP if SPROM not available */
+       else {
+               err = otp_read_pci(sih, srom, SROM_MAX);
+               if (err == 0)
+                       /* OTP only contain SROM rev8/rev9 for now */
+                       sromrev = srom[SROM4_CRCREV] & 0xff;
+               else
+                       err = 1;
+       }
+#else
+       else
+               err = 1;
+#endif
+
+       /*
+        * We want internal/wltest driver to come up with default
+        * sromvars so we can program a blank SPROM/OTP.
+        */
+       if (err) {
+               char *value;
+               u32 val;
+               val = 0;
+
+               value = ai_getdevpathvar(sih, "sromrev");
+               if (value) {
+                       sromrev = (u8) simple_strtoul(value, NULL, 0);
+                       flash = true;
+                       goto varscont;
+               }
+
+               value = ai_getnvramflvar(sih, "sromrev");
+               if (value) {
+                       err = 0;
+                       goto errout;
+               }
+
+               {
+                       err = -1;
+                       goto errout;
+               }
+       }
+
+ varscont:
+       /* Bitmask for the sromrev */
+       sr = 1 << sromrev;
+
+       /* srom version check: Current valid versions: 1, 2, 3, 4, 5, 8, 9 */
+       if ((sr & 0x33e) == 0) {
+               err = -2;
+               goto errout;
+       }
+
+       base = vp = kmalloc(MAXSZ_NVRAM_VARS, GFP_ATOMIC);
+       if (!vp) {
+               err = -2;
+               goto errout;
+       }
+
+       /* read variables from flash */
+       if (flash) {
+               err = initvars_flash(sih, &vp, MAXSZ_NVRAM_VARS);
+               if (err)
+                       goto errout;
+               goto varsdone;
+       }
+
+       varbuf_init(&b, base, MAXSZ_NVRAM_VARS);
+
+       /* parse SROM into name=value pairs. */
+       _initvars_srom_pci(sromrev, srom, 0, &b);
+
+       /* final nullbyte terminator */
+       vp = b.buf;
+       *vp++ = '\0';
+
+ varsdone:
+       err = initvars_table(base, vp, vars, count);
+
+ errout:
+       if (base)
+               kfree(base);
+
+       kfree(srom);
+       return err;
+}
+
+
+static int initvars_srom_si(si_t *sih, void *curmap, char **vars, uint *varsz)
+{
+       /* Search flash nvram section for srom variables */
+       return initvars_flash_si(sih, vars, varsz);
+}
similarity index 89%
rename from drivers/staging/brcm80211/util/bcmsrom_tbl.h
rename to drivers/staging/brcm80211/brcmsmac/bcmsrom_tbl.h
index 22ae7c1c18fb1d65b1f844fab1b01fb6024810b8..f4b3e61dc37d54d959830b7c56bc9b69660d9920 100644 (file)
@@ -17,7 +17,6 @@
 #ifndef        _bcmsrom_tbl_h_
 #define        _bcmsrom_tbl_h_
 
-#include "sbpcmcia.h"
 #include "wlioctl.h"
 
 typedef struct {
@@ -511,73 +510,4 @@ typedef struct {
 #define OTP_MANFID     (0xff - 3)      /* CISTPL_MANFID */
 #define OTP_RAW1       (0xff - 4)      /* Like RAW, but comes first */
 
-static const cis_tuple_t cis_hnbuvars[] = {
-       {OTP_RAW1, 0, ""},      /* special case */
-       {OTP_VERS_1, 0, "smanf sproductname"},  /* special case (non BRCM tuple) */
-       {OTP_MANFID, 4, "2manfid 2prodid"},     /* special case (non BRCM tuple) */
-       {HNBU_SROMREV, 2, "1sromrev"},
-       /* NOTE: subdevid is also written to boardtype.
-        *       Need to write HNBU_BOARDTYPE to change it if it is different.
-        */
-       {HNBU_CHIPID, 11, "2vendid 2devid 2chiprev 2subvendid 2subdevid"},
-       {HNBU_BOARDREV, 3, "2boardrev"},
-       {HNBU_PAPARMS, 10, "2pa0b0 2pa0b1 2pa0b2 1pa0itssit 1pa0maxpwr 1opo"},
-       {HNBU_AA, 3, "1aa2g 1aa5g"},
-       {HNBU_AA, 3, "1aa0 1aa1"},      /* backward compatibility */
-       {HNBU_AG, 5, "1ag0 1ag1 1ag2 1ag3"},
-       {HNBU_BOARDFLAGS, 9, "4boardflags 4boardflags2"},
-       {HNBU_LEDS, 5, "1ledbh0 1ledbh1 1ledbh2 1ledbh3"},
-       {HNBU_CCODE, 4, "2ccode 1cctl"},
-       {HNBU_CCKPO, 3, "2cckpo"},
-       {HNBU_OFDMPO, 5, "4ofdmpo"},
-       {HNBU_RDLID, 3, "2rdlid"},
-       {HNBU_RSSISMBXA2G, 3, "0rssismf2g 0rssismc2g 0rssisav2g 0bxa2g"},       /* special case */
-       {HNBU_RSSISMBXA5G, 3, "0rssismf5g 0rssismc5g 0rssisav5g 0bxa5g"},       /* special case */
-       {HNBU_XTALFREQ, 5, "4xtalfreq"},
-       {HNBU_TRI2G, 2, "1tri2g"},
-       {HNBU_TRI5G, 4, "1tri5gl 1tri5g 1tri5gh"},
-       {HNBU_RXPO2G, 2, "1rxpo2g"},
-       {HNBU_RXPO5G, 2, "1rxpo5g"},
-       {HNBU_BOARDNUM, 3, "2boardnum"},
-       {HNBU_MACADDR, 7, "6macaddr"},  /* special case */
-       {HNBU_RDLSN, 3, "2rdlsn"},
-       {HNBU_BOARDTYPE, 3, "2boardtype"},
-       {HNBU_LEDDC, 3, "2leddc"},
-       {HNBU_RDLRNDIS, 2, "1rdlndis"},
-       {HNBU_CHAINSWITCH, 5, "1txchain 1rxchain 2antswitch"},
-       {HNBU_REGREV, 2, "1regrev"},
-       {HNBU_FEM, 5, "0antswctl2g, 0triso2g, 0pdetrange2g, 0extpagain2g, 0tssipos2g" "0antswctl5g, 0triso5g, 0pdetrange5g, 0extpagain5g, 0tssipos5g"}, /* special case */
-       {HNBU_PAPARMS_C0, 31, "1maxp2ga0 1itt2ga0 2pa2gw0a0 2pa2gw1a0 "
-        "2pa2gw2a0 1maxp5ga0 1itt5ga0 1maxp5gha0 1maxp5gla0 2pa5gw0a0 "
-        "2pa5gw1a0 2pa5gw2a0 2pa5glw0a0 2pa5glw1a0 2pa5glw2a0 2pa5ghw0a0 "
-        "2pa5ghw1a0 2pa5ghw2a0"},
-       {HNBU_PAPARMS_C1, 31, "1maxp2ga1 1itt2ga1 2pa2gw0a1 2pa2gw1a1 "
-        "2pa2gw2a1 1maxp5ga1 1itt5ga1 1maxp5gha1 1maxp5gla1 2pa5gw0a1 "
-        "2pa5gw1a1 2pa5gw2a1 2pa5glw0a1 2pa5glw1a1 2pa5glw2a1 2pa5ghw0a1 "
-        "2pa5ghw1a1 2pa5ghw2a1"},
-       {HNBU_PO_CCKOFDM, 19, "2cck2gpo 4ofdm2gpo 4ofdm5gpo 4ofdm5glpo "
-        "4ofdm5ghpo"},
-       {HNBU_PO_MCS2G, 17, "2mcs2gpo0 2mcs2gpo1 2mcs2gpo2 2mcs2gpo3 "
-        "2mcs2gpo4 2mcs2gpo5 2mcs2gpo6 2mcs2gpo7"},
-       {HNBU_PO_MCS5GM, 17, "2mcs5gpo0 2mcs5gpo1 2mcs5gpo2 2mcs5gpo3 "
-        "2mcs5gpo4 2mcs5gpo5 2mcs5gpo6 2mcs5gpo7"},
-       {HNBU_PO_MCS5GLH, 33, "2mcs5glpo0 2mcs5glpo1 2mcs5glpo2 2mcs5glpo3 "
-        "2mcs5glpo4 2mcs5glpo5 2mcs5glpo6 2mcs5glpo7 "
-        "2mcs5ghpo0 2mcs5ghpo1 2mcs5ghpo2 2mcs5ghpo3 "
-        "2mcs5ghpo4 2mcs5ghpo5 2mcs5ghpo6 2mcs5ghpo7"},
-       {HNBU_CCKFILTTYPE, 2, "1cckdigfilttype"},
-       {HNBU_PO_CDD, 3, "2cddpo"},
-       {HNBU_PO_STBC, 3, "2stbcpo"},
-       {HNBU_PO_40M, 3, "2bw40po"},
-       {HNBU_PO_40MDUP, 3, "2bwduppo"},
-       {HNBU_RDLRWU, 2, "1rdlrwu"},
-       {HNBU_WPS, 3, "1wpsgpio 1wpsled"},
-       {HNBU_USBFS, 2, "1usbfs"},
-       {HNBU_CUSTOM1, 5, "4customvar1"},
-       {OTP_RAW, 0, ""},       /* special case */
-       {HNBU_OFDMPO5G, 13, "4ofdm5gpo 4ofdm5glpo 4ofdm5ghpo"},
-       {HNBU_USBEPNUM, 3, "2usbepnum"},
-       {0xFF, 0, ""}
-};
-
 #endif                         /* _bcmsrom_tbl_h_ */
index a9d182f49023450630d8667dd950b5f7d7762b03..d91e4189a3e87f33031c46eec5ea3002faf89810 100644 (file)
@@ -17,6 +17,8 @@
 #ifndef        _D11_H
 #define        _D11_H
 
+#include <sbconfig.h>
+
 #ifndef WL_RSSI_ANT_MAX
 #define WL_RSSI_ANT_MAX                4       /* max possible rx antennas */
 #elif WL_RSSI_ANT_MAX != 4
similarity index 94%
rename from drivers/staging/brcm80211/util/hnddma.c
rename to drivers/staging/brcm80211/brcmsmac/hnddma.c
index be339feae77d916fa28494d78d62eab003ee48bb..f607315f8143c83931b67cea7e4db55d06fc169a 100644 (file)
@@ -22,7 +22,7 @@
 #include <bcmdevs.h>
 #include <hndsoc.h>
 #include <bcmutils.h>
-#include <siutils.h>
+#include <aiutils.h>
 
 #include <sbhnddma.h>
 #include <hnddma.h>
@@ -293,23 +293,10 @@ struct hnddma_pub *dma_attach(char *name, si_t *sih,
 
        di->msg_level = msg_level ? msg_level : &dma_msg_level;
 
-       /* old chips w/o sb is no longer supported */
-       ASSERT(sih != NULL);
 
-       di->dma64 = ((si_core_sflags(sih, 0, 0) & SISF_DMA64) == SISF_DMA64);
-
-       /* check arguments */
-       ASSERT(ISPOWEROF2(ntxd));
-       ASSERT(ISPOWEROF2(nrxd));
-
-       if (nrxd == 0)
-               ASSERT(dmaregsrx == NULL);
-       if (ntxd == 0)
-               ASSERT(dmaregstx == NULL);
+       di->dma64 = ((ai_core_sflags(sih, 0, 0) & SISF_DMA64) == SISF_DMA64);
 
        /* init dma reg pointer */
-       ASSERT(ntxd <= D64MAXDD);
-       ASSERT(nrxd <= D64MAXDD);
        di->d64txregs = (dma64regs_t *) dmaregstx;
        di->d64rxregs = (dma64regs_t *) dmaregsrx;
        di->hnddma.di_fn = (const di_fcn_t *)&dma64proc;
@@ -369,11 +356,11 @@ struct hnddma_pub *dma_attach(char *name, si_t *sih,
        di->dataoffsetlow = di->dataoffsetlow + SI_SDRAM_SWAPPED;
 #endif                         /* defined(__mips__) && defined(IL_BIGENDIAN) */
        /* WAR64450 : DMACtl.Addr ext fields are not supported in SDIOD core. */
-       if ((si_coreid(sih) == SDIOD_CORE_ID)
-           && ((si_corerev(sih) > 0) && (si_corerev(sih) <= 2)))
+       if ((ai_coreid(sih) == SDIOD_CORE_ID)
+           && ((ai_corerev(sih) > 0) && (ai_corerev(sih) <= 2)))
                di->addrext = 0;
-       else if ((si_coreid(sih) == I2S_CORE_ID) &&
-                ((si_corerev(sih) == 0) || (si_corerev(sih) == 1)))
+       else if ((ai_coreid(sih) == I2S_CORE_ID) &&
+                ((ai_corerev(sih) == 0) || (ai_corerev(sih) == 1)))
                di->addrext = 0;
        else
                di->addrext = _dma_isaddrext(di);
@@ -488,7 +475,6 @@ dma64_dd_upd(dma_info_t *di, dma64dd_t *ddring, dmaaddr_t pa, uint outidx,
 #else
        if ((di->dataoffsetlow == 0) || !(PHYSADDRLO(pa) & PCI32ADDR_HIGH)) {
 #endif                         /* defined(__mips__) && defined(IL_BIGENDIAN) */
-               ASSERT((PHYSADDRHI(pa) & PCI64ADDR_HIGH) == 0);
 
                W_SM(&ddring[outidx].addrlow,
                     BUS_SWAP32(PHYSADDRLO(pa) + di->dataoffsetlow));
@@ -499,11 +485,9 @@ dma64_dd_upd(dma_info_t *di, dma64dd_t *ddring, dmaaddr_t pa, uint outidx,
        } else {
                /* address extension for 32-bit PCI */
                u32 ae;
-               ASSERT(di->addrext);
 
                ae = (PHYSADDRLO(pa) & PCI32ADDR_HIGH) >> PCI32ADDR_HIGH_SHIFT;
                PHYSADDRLO(pa) &= ~PCI32ADDR_HIGH;
-               ASSERT(PHYSADDRHI(pa) == 0);
 
                ctrl2 |= (ae << D64_CTRL2_AE_SHIFT) & D64_CTRL2_AE;
                W_SM(&ddring[outidx].addrlow,
@@ -544,10 +528,6 @@ static void _dma_detach(dma_info_t *di)
 
        DMA_TRACE(("%s: dma_detach\n", di->name));
 
-       /* shouldn't be here if descriptors are unreclaimed */
-       ASSERT(di->txin == di->txout);
-       ASSERT(di->rxin == di->rxout);
-
        /* free dma descriptor rings */
        if (di->txd64)
                pci_free_consistent(di->pbus, di->txdalloc,
@@ -602,14 +582,12 @@ static bool _dma_isaddrext(dma_info_t *di)
                if (!_dma64_addrext(di->d64txregs)) {
                        DMA_ERROR(("%s: _dma_isaddrext: DMA64 tx doesn't have "
                                   "AE set\n", di->name));
-                       ASSERT(0);
                }
                return true;
        } else if (di->d64rxregs != NULL) {
                if (!_dma64_addrext(di->d64rxregs)) {
                        DMA_ERROR(("%s: _dma_isaddrext: DMA64 rx doesn't have "
                                   "AE set\n", di->name));
-                       ASSERT(0);
                }
                return true;
        }
@@ -642,8 +620,6 @@ static void _dma_ddtable_init(dma_info_t *di, uint direction, dmaaddr_t pa)
        } else {
                /* DMA64 32bits address extension */
                u32 ae;
-               ASSERT(di->addrext);
-               ASSERT(PHYSADDRHI(pa) == 0);
 
                /* shift the high bit(s) from pa to ae */
                ae = (PHYSADDRLO(pa) & PCI32ADDR_HIGH) >>
@@ -738,7 +714,7 @@ _dma_rx_param_get(dma_info_t *di, u16 *rxoffset, u16 *rxbufsize)
  *   After it reaches the max size of buffer, the data continues in next DMA descriptor
  *   buffer WITHOUT DMA header
  */
-static void *BCMFASTPATH _dma_rx(dma_info_t *di)
+static void *_dma_rx(dma_info_t *di)
 {
        struct sk_buff *p, *head, *tail;
        uint len;
@@ -752,16 +728,7 @@ static void *BCMFASTPATH _dma_rx(dma_info_t *di)
 
        len = le16_to_cpu(*(u16 *) (head->data));
        DMA_TRACE(("%s: dma_rx len %d\n", di->name, len));
-
-#if defined(__mips__)
-#define OSL_UNCACHED(va)        ((void *)KSEG1ADDR((va)))
-       if (!len) {
-               while (!(len = *(u16 *) OSL_UNCACHED(head->data)))
-                       udelay(1);
-
-               *(u16 *) (head->data) = cpu_to_le16((u16) len);
-       }
-#endif                         /* defined(__mips__) */
+       dma_spin_for_len(len, head);
 
        /* set actual length */
        pkt_len = min((di->rxoffset + len), di->rxbufsize);
@@ -783,7 +750,6 @@ static void *BCMFASTPATH _dma_rx(dma_info_t *di)
 #ifdef BCMDBG
                if (resid > 0) {
                        uint cur;
-                       ASSERT(p == NULL);
                        cur =
                            B2I(((R_REG(&di->d64rxregs->status0) &
                                  D64_RS0_CD_MASK) -
@@ -797,7 +763,7 @@ static void *BCMFASTPATH _dma_rx(dma_info_t *di)
                if ((di->hnddma.dmactrlflags & DMA_CTRL_RXMULTI) == 0) {
                        DMA_ERROR(("%s: dma_rx: bad frame length (%d)\n",
                                   di->name, len));
-                       pkt_buf_free_skb(head);
+                       bcm_pkt_buf_free_skb(head);
                        di->hnddma.rxgiants++;
                        goto next_frame;
                }
@@ -811,7 +777,7 @@ static void *BCMFASTPATH _dma_rx(dma_info_t *di)
  *  this will stall the rx dma and user might want to call rxfill again asap
  *  This unlikely happens on memory-rich NIC, but often on memory-constrained dongle
  */
-static bool BCMFASTPATH _dma_rxfill(dma_info_t *di)
+static bool _dma_rxfill(dma_info_t *di)
 {
        struct sk_buff *p;
        u16 rxin, rxout;
@@ -845,7 +811,7 @@ static bool BCMFASTPATH _dma_rxfill(dma_info_t *di)
                   size to be allocated
                 */
 
-               p = pkt_buf_get_skb(di->rxbufsize + extra_offset);
+               p = bcm_pkt_buf_get_skb(di->rxbufsize + extra_offset);
 
                if (p == NULL) {
                        DMA_ERROR(("%s: dma_rxfill: out of rxbufs\n",
@@ -874,10 +840,7 @@ static bool BCMFASTPATH _dma_rxfill(dma_info_t *di)
                pa = pci_map_single(di->pbus, p->data,
                        di->rxbufsize, PCI_DMA_FROMDEVICE);
 
-               ASSERT(IS_ALIGNED(PHYSADDRLO(pa), 4));
-
                /* save the free packet pointer */
-               ASSERT(di->rxp[rxout] == NULL);
                di->rxp[rxout] = p;
 
                /* reset flags for each descriptor */
@@ -946,10 +909,10 @@ static void _dma_rxreclaim(dma_info_t *di)
        DMA_TRACE(("%s: dma_rxreclaim\n", di->name));
 
        while ((p = _dma_getnextrxp(di, true)))
-               pkt_buf_free_skb(p);
+               bcm_pkt_buf_free_skb(p);
 }
 
-static void *BCMFASTPATH _dma_getnextrxp(dma_info_t *di, bool forceall)
+static void *_dma_getnextrxp(dma_info_t *di, bool forceall)
 {
        if (di->nrxd == 0)
                return NULL;
@@ -1019,8 +982,6 @@ static uint _dma_ctrlflags(dma_info_t *di, uint mask, uint flags)
                return 0;
        }
 
-       ASSERT((flags & ~mask) == 0);
-
        dmactrlflags &= ~mask;
        dmactrlflags |= flags;
 
@@ -1053,9 +1014,6 @@ static unsigned long _dma_getvar(dma_info_t *di, const char *name)
 {
        if (!strcmp(name, "&txavail"))
                return (unsigned long)&(di->hnddma.txavail);
-       else {
-               ASSERT(0);
-       }
        return 0;
 }
 
@@ -1063,8 +1021,6 @@ static
 u8 dma_align_sizetobits(uint size)
 {
        u8 bitpos = 0;
-       ASSERT(size);
-       ASSERT(!(size & (size - 1)));
        while (size >>= 1) {
                bitpos++;
        }
@@ -1171,7 +1127,7 @@ static bool dma64_txsuspended(dma_info_t *di)
             D64_XC_SE);
 }
 
-static void BCMFASTPATH dma64_txreclaim(dma_info_t *di, txd_range_t range)
+static void dma64_txreclaim(dma_info_t *di, txd_range_t range)
 {
        void *p;
 
@@ -1187,7 +1143,7 @@ static void BCMFASTPATH dma64_txreclaim(dma_info_t *di, txd_range_t range)
        while ((p = dma64_getnexttxp(di, range))) {
                /* For unframed data, we don't have any packets to free */
                if (!(di->hnddma.dmactrlflags & DMA_CTRL_UNFRAMED))
-                       pkt_buf_free_skb(p);
+                       bcm_pkt_buf_free_skb(p);
        }
 }
 
@@ -1230,12 +1186,8 @@ static bool dma64_alloc(dma_info_t *di, uint direction)
                di->txdalign = (uint) ((s8 *)di->txd64 - (s8 *) va);
                PHYSADDRLOSET(di->txdpa,
                              PHYSADDRLO(di->txdpaorig) + di->txdalign);
-               /* Make sure that alignment didn't overflow */
-               ASSERT(PHYSADDRLO(di->txdpa) >= PHYSADDRLO(di->txdpaorig));
-
                PHYSADDRHISET(di->txdpa, PHYSADDRHI(di->txdpaorig));
                di->txdalloc = alloced;
-               ASSERT(IS_ALIGNED((unsigned long)di->txd64, align));
        } else {
                va = dma_ringalloc(di, D64RINGALIGN, size, &align_bits,
                        &alloced, &di->rxdpaorig);
@@ -1248,12 +1200,8 @@ static bool dma64_alloc(dma_info_t *di, uint direction)
                di->rxdalign = (uint) ((s8 *)di->rxd64 - (s8 *) va);
                PHYSADDRLOSET(di->rxdpa,
                              PHYSADDRLO(di->rxdpaorig) + di->rxdalign);
-               /* Make sure that alignment didn't overflow */
-               ASSERT(PHYSADDRLO(di->rxdpa) >= PHYSADDRLO(di->rxdpaorig));
-
                PHYSADDRHISET(di->rxdpa, PHYSADDRHI(di->rxdpaorig));
                di->rxdalloc = alloced;
-               ASSERT(IS_ALIGNED((unsigned long)di->rxd64, align));
        }
 
        return true;
@@ -1396,7 +1344,6 @@ static int dma64_txunframed(dma_info_t *di, void *buf, uint len, bool commit)
                flags |= D64_CTRL1_EOT;
 
        dma64_dd_upd(di, di->txd64, pa, txout, &flags, len);
-       ASSERT(di->txp[txout] == NULL);
 
        /* save the buffer pointer - used by dma_getpos */
        di->txp[txout] = buf;
@@ -1427,7 +1374,7 @@ static int dma64_txunframed(dma_info_t *di, void *buf, uint len, bool commit)
  * WARNING: call must check the return value for error.
  *   the error(toss frames) could be fatal and cause many subsequent hard to debug problems
  */
-static int BCMFASTPATH dma64_txfast(dma_info_t *di, struct sk_buff *p0,
+static int dma64_txfast(dma_info_t *di, struct sk_buff *p0,
                                    bool commit)
 {
        struct sk_buff *p, *next;
@@ -1451,9 +1398,6 @@ static int BCMFASTPATH dma64_txfast(dma_info_t *di, struct sk_buff *p0,
 
                data = p->data;
                len = p->len;
-#ifdef BCM_DMAPAD
-               len += PKTDMAPAD(di->osh, p);
-#endif                         /* BCM_DMAPAD */
                next = p->next;
 
                /* return nonzero if out of tx descriptors */
@@ -1504,7 +1448,6 @@ static int BCMFASTPATH dma64_txfast(dma_info_t *di, struct sk_buff *p0,
                                pa = map->segs[j - 1].addr;
                        }
                        dma64_dd_upd(di, di->txd64, pa, txout, &flags, len);
-                       ASSERT(di->txp[txout] == NULL);
 
                        txout = NEXTTXD(txout);
                }
@@ -1537,7 +1480,7 @@ static int BCMFASTPATH dma64_txfast(dma_info_t *di, struct sk_buff *p0,
 
  outoftxd:
        DMA_ERROR(("%s: dma_txfast: out of txds !!!\n", di->name));
-       pkt_buf_free_skb(p0);
+       bcm_pkt_buf_free_skb(p0);
        di->hnddma.txavail = 0;
        di->hnddma.txnobuf++;
        return -1;
@@ -1553,7 +1496,7 @@ static int BCMFASTPATH dma64_txfast(dma_info_t *di, struct sk_buff *p0,
  * If range is HNDDMA_RANGE_ALL, reclaim all txd(s) posted to the ring and
  * return associated packet regardless of the value of hardware pointers.
  */
-static void *BCMFASTPATH dma64_getnexttxp(dma_info_t *di, txd_range_t range)
+static void *dma64_getnexttxp(dma_info_t *di, txd_range_t range)
 {
        u16 start, end, i;
        u16 active_desc;
@@ -1645,15 +1588,12 @@ static void *BCMFASTPATH dma64_getnexttxp(dma_info_t *di, txd_range_t range)
        return NULL;
 }
 
-static void *BCMFASTPATH dma64_getnextrxp(dma_info_t *di, bool forceall)
+static void *dma64_getnextrxp(dma_info_t *di, bool forceall)
 {
        uint i, curr;
        void *rxp;
        dmaaddr_t pa;
 
-       /* if forcing, dma engine must be disabled */
-       ASSERT(!forceall || !dma64_rxenabled(di));
-
        i = di->rxin;
 
        /* return if no packets posted */
@@ -1670,7 +1610,6 @@ static void *BCMFASTPATH dma64_getnextrxp(dma_info_t *di, bool forceall)
 
        /* get the packet pointer that corresponds to the rx descriptor */
        rxp = di->rxp[i];
-       ASSERT(rxp);
        di->rxp[i] = NULL;
 
        PHYSADDRLOSET(pa,
@@ -1712,8 +1651,6 @@ static void dma64_txrotate(dma_info_t *di)
        u32 w;
        u16 first, last;
 
-       ASSERT(dma64_txsuspendedidle(di));
-
        nactive = _dma_txactive(di);
        ad = (u16) (B2I
                       ((((R_REG(&di->d64txregs->status1) &
@@ -1721,8 +1658,6 @@ static void dma64_txrotate(dma_info_t *di)
                          - di->xmtptrbase) & D64_XS1_AD_MASK), dma64dd_t));
        rot = TXD(ad - di->txin);
 
-       ASSERT(rot < di->ntxd);
-
        /* full-ring case is a lot harder - don't worry about this */
        if (rot >= (di->ntxd - nactive)) {
                DMA_ERROR(("%s: dma_txrotate: ring full - punt\n", di->name));
@@ -1756,7 +1691,6 @@ static void dma64_txrotate(dma_info_t *di)
                W_SM(&di->txd64[old].addrhigh, BUS_SWAP32(0xdeadbeef));
 
                /* move the corresponding txp[] entry */
-               ASSERT(di->txp[new] == NULL);
                di->txp[new] = di->txp[old];
 
                /* Move the map */
@@ -1783,16 +1717,16 @@ uint dma_addrwidth(si_t *sih, void *dmaregs)
 {
        /* Perform 64-bit checks only if we want to advertise 64-bit (> 32bit) capability) */
        /* DMA engine is 64-bit capable */
-       if ((si_core_sflags(sih, 0, 0) & SISF_DMA64) == SISF_DMA64) {
+       if ((ai_core_sflags(sih, 0, 0) & SISF_DMA64) == SISF_DMA64) {
                /* backplane are 64-bit capable */
-               if (si_backplane64(sih))
+               if (ai_backplane64(sih))
                        /* If bus is System Backplane or PCIE then we can access 64-bits */
                        if ((sih->bustype == SI_BUS) ||
                            ((sih->bustype == PCI_BUS) &&
                             (sih->buscoretype == PCIE_CORE_ID)))
                                return DMADDRWIDTH_64;
        }
-       ASSERT(0); /* DMA hardware not supported by this driver*/
+       /* DMA hardware not supported by this driver*/
        return DMADDRWIDTH_64;
 }
 
similarity index 92%
rename from drivers/staging/brcm80211/util/nicpci.c
rename to drivers/staging/brcm80211/brcmsmac/nicpci.c
index a1fb2f08984d5173d4dd8fe38270bd16434701ee..18b844a8d2fb370fb67098c2f5dad01cf7cb6146 100644 (file)
@@ -19,7 +19,8 @@
 #include <linux/pci.h>
 #include <bcmdefs.h>
 #include <bcmutils.h>
-#include <siutils.h>
+#include <bcmnvram.h>
+#include <aiutils.h>
 #include <hndsoc.h>
 #include <bcmdevs.h>
 #include <sbchipc.h>
@@ -83,8 +84,6 @@ void *pcicore_init(si_t *sih, void *pdev, void *regs)
 {
        pcicore_info_t *pi;
 
-       ASSERT(sih->bustype == PCI_BUS);
-
        /* alloc pcicore_info_t */
        pi = kzalloc(sizeof(pcicore_info_t), GFP_ATOMIC);
        if (pi == NULL) {
@@ -98,10 +97,8 @@ void *pcicore_init(si_t *sih, void *pdev, void *regs)
        if (sih->buscoretype == PCIE_CORE_ID) {
                u8 cap_ptr;
                pi->regs.pcieregs = (sbpcieregs_t *) regs;
-               cap_ptr =
-                   pcicore_find_pci_capability(pi->dev, PCI_CAP_PCIECAP_ID,
-                                               NULL, NULL);
-               ASSERT(cap_ptr);
+               cap_ptr = pcicore_find_pci_capability(pi->dev, PCI_CAP_ID_EXP,
+                                                     NULL, NULL);
                pi->pciecap_lcreg_offset = cap_ptr + PCIE_CAP_LINKCTRL_OFFSET;
        } else
                pi->regs.pciregs = (struct sbpciregs *) regs;
@@ -130,16 +127,16 @@ pcicore_find_pci_capability(void *dev, u8 req_cap_id,
        u8 byte_val;
 
        /* check for Header type 0 */
-       pci_read_config_byte(dev, PCI_CFG_HDR, &byte_val);
-       if ((byte_val & 0x7f) != PCI_HEADER_NORMAL)
+       pci_read_config_byte(dev, PCI_HEADER_TYPE, &byte_val);
+       if ((byte_val & 0x7f) != PCI_HEADER_TYPE_NORMAL)
                goto end;
 
        /* check if the capability pointer field exists */
-       pci_read_config_byte(dev, PCI_CFG_STAT, &byte_val);
-       if (!(byte_val & PCI_CAPPTR_PRESENT))
+       pci_read_config_byte(dev, PCI_STATUS, &byte_val);
+       if (!(byte_val & PCI_STATUS_CAP_LIST))
                goto end;
 
-       pci_read_config_byte(dev, PCI_CFG_CAPPTR, &cap_ptr);
+       pci_read_config_byte(dev, PCI_CAPABILITY_LIST, &cap_ptr);
        /* check if the capability pointer is 0x00 */
        if (cap_ptr == 0x00)
                goto end;
@@ -167,8 +164,8 @@ pcicore_find_pci_capability(void *dev, u8 req_cap_id,
                *buflen = 0;
                /* copy the cpability data excluding cap ID and next ptr */
                cap_data = cap_ptr + 2;
-               if ((bufsize + cap_data) > SZPCR)
-                       bufsize = SZPCR - cap_data;
+               if ((bufsize + cap_data) > PCI_SZPCR)
+                       bufsize = PCI_SZPCR - cap_data;
                *buflen = bufsize;
                while (bufsize--) {
                        pci_read_config_byte(dev, cap_data, buf);
@@ -187,8 +184,6 @@ pcie_readreg(sbpcieregs_t *pcieregs, uint addrtype,
 {
        uint retval = 0xFFFFFFFF;
 
-       ASSERT(pcieregs != NULL);
-
        switch (addrtype) {
        case PCIE_CONFIGREGS:
                W_REG((&pcieregs->configaddr), offset);
@@ -201,7 +196,6 @@ pcie_readreg(sbpcieregs_t *pcieregs, uint addrtype,
                retval = R_REG(&(pcieregs->pcieinddata));
                break;
        default:
-               ASSERT(0);
                break;
        }
 
@@ -212,8 +206,6 @@ uint
 pcie_writereg(sbpcieregs_t *pcieregs, uint addrtype,
              uint offset, uint val)
 {
-       ASSERT(pcieregs != NULL);
-
        switch (addrtype) {
        case PCIE_CONFIGREGS:
                W_REG((&pcieregs->configaddr), offset);
@@ -224,7 +216,6 @@ pcie_writereg(sbpcieregs_t *pcieregs, uint addrtype,
                W_REG((&pcieregs->pcieinddata), val);
                break;
        default:
-               ASSERT(0);
                break;
        }
        return 0;
@@ -384,7 +375,6 @@ static void pcie_extendL1timer(pcicore_info_t *pi, bool extend)
 static void pcie_clkreq_upd(pcicore_info_t *pi, uint state)
 {
        si_t *sih = pi->sih;
-       ASSERT(PCIE_PUB(sih));
 
        switch (state) {
        case SI_DOATTACH:
@@ -393,10 +383,10 @@ static void pcie_clkreq_upd(pcicore_info_t *pi, uint state)
                break;
        case SI_PCIDOWN:
                if (sih->buscorerev == 6) {     /* turn on serdes PLL down */
-                       si_corereg(sih, SI_CC_IDX,
+                       ai_corereg(sih, SI_CC_IDX,
                                   offsetof(chipcregs_t, chipcontrol_addr), ~0,
                                   0);
-                       si_corereg(sih, SI_CC_IDX,
+                       ai_corereg(sih, SI_CC_IDX,
                                   offsetof(chipcregs_t, chipcontrol_data),
                                   ~0x40, 0);
                } else if (pi->pcie_pr42767) {
@@ -405,10 +395,10 @@ static void pcie_clkreq_upd(pcicore_info_t *pi, uint state)
                break;
        case SI_PCIUP:
                if (sih->buscorerev == 6) {     /* turn off serdes PLL down */
-                       si_corereg(sih, SI_CC_IDX,
+                       ai_corereg(sih, SI_CC_IDX,
                                   offsetof(chipcregs_t, chipcontrol_addr), ~0,
                                   0);
-                       si_corereg(sih, SI_CC_IDX,
+                       ai_corereg(sih, SI_CC_IDX,
                                   offsetof(chipcregs_t, chipcontrol_data),
                                   ~0x40, 0x40);
                } else if (PCIE_ASPM(sih)) {    /* disable clkreq */
@@ -416,7 +406,6 @@ static void pcie_clkreq_upd(pcicore_info_t *pi, uint state)
                }
                break;
        default:
-               ASSERT(0);
                break;
        }
 }
@@ -534,10 +523,8 @@ static void pcie_war_noplldown(pcicore_info_t *pi)
        sbpcieregs_t *pcieregs = pi->regs.pcieregs;
        u16 *reg16;
 
-       ASSERT(pi->sih->buscorerev == 7);
-
        /* turn off serdes PLL down */
-       si_corereg(pi->sih, SI_CC_IDX, offsetof(chipcregs_t, chipcontrol),
+       ai_corereg(pi->sih, SI_CC_IDX, offsetof(chipcregs_t, chipcontrol),
                   CHIPCTRL_4321_PLL_DOWN, CHIPCTRL_4321_PLL_DOWN);
 
        /*  clear srom shadow backdoor */
@@ -693,16 +680,15 @@ bool pcicore_pmecap_fast(void *pch)
        u8 cap_ptr;
        u32 pmecap;
 
-       cap_ptr =
-           pcicore_find_pci_capability(pi->dev, PCI_CAP_POWERMGMTCAP_ID, NULL,
-                                       NULL);
+       cap_ptr = pcicore_find_pci_capability(pi->dev, PCI_CAP_ID_PM, NULL,
+                                             NULL);
 
        if (!cap_ptr)
                return false;
 
        pci_read_config_dword(pi->dev, cap_ptr, &pmecap);
 
-       return (pmecap & PME_CAP_PM_STATES) != 0;
+       return (pmecap & (PCI_PM_CAP_PME_MASK << 16)) != 0;
 }
 
 /* return true if PM capability exists in the pci config space
@@ -714,10 +700,9 @@ static bool pcicore_pmecap(pcicore_info_t *pi)
        u32 pmecap;
 
        if (!pi->pmecap_offset) {
-               cap_ptr =
-                   pcicore_find_pci_capability(pi->dev,
-                                               PCI_CAP_POWERMGMTCAP_ID, NULL,
-                                               NULL);
+               cap_ptr = pcicore_find_pci_capability(pi->dev,
+                                                     PCI_CAP_ID_PM,
+                                                     NULL, NULL);
                if (!cap_ptr)
                        return false;
 
@@ -727,7 +712,7 @@ static bool pcicore_pmecap(pcicore_info_t *pi)
                                        &pmecap);
 
                /* At least one state can generate PME */
-               pi->pmecap = (pmecap & PME_CAP_PM_STATES) != 0;
+               pi->pmecap = (pmecap & (PCI_PM_CAP_PME_MASK << 16)) != 0;
        }
 
        return pi->pmecap;
@@ -743,11 +728,11 @@ void pcicore_pmeen(void *pch)
        if (!pcicore_pmecap(pi))
                return;
 
-       pci_read_config_dword(pi->dev, pi->pmecap_offset + PME_CSR_OFFSET,
+       pci_read_config_dword(pi->dev, pi->pmecap_offset + PCI_PM_CTRL,
                                &w);
-       w |= (PME_CSR_PME_EN);
+       w |= (PCI_PM_CTRL_PME_ENABLE);
        pci_write_config_dword(pi->dev,
-                               pi->pmecap_offset + PME_CSR_OFFSET, w);
+                               pi->pmecap_offset + PCI_PM_CTRL, w);
 }
 
 /*
@@ -761,10 +746,10 @@ bool pcicore_pmestat(void *pch)
        if (!pcicore_pmecap(pi))
                return false;
 
-       pci_read_config_dword(pi->dev, pi->pmecap_offset + PME_CSR_OFFSET,
+       pci_read_config_dword(pi->dev, pi->pmecap_offset + PCI_PM_CTRL,
                                &w);
 
-       return (w & PME_CSR_PME_STAT) == PME_CSR_PME_STAT;
+       return (w & PCI_PM_CTRL_PME_STATUS) == PCI_PM_CTRL_PME_STATUS;
 }
 
 /* Disable PME generation, clear the PME status bit if set
@@ -777,16 +762,16 @@ void pcicore_pmeclr(void *pch)
        if (!pcicore_pmecap(pi))
                return;
 
-       pci_read_config_dword(pi->dev, pi->pmecap_offset + PME_CSR_OFFSET,
+       pci_read_config_dword(pi->dev, pi->pmecap_offset + PCI_PM_CTRL,
                                &w);
 
        PCI_ERROR(("pcicore_pci_pmeclr PMECSR : 0x%x\n", w));
 
        /* PMESTAT is cleared by writing 1 to it */
-       w &= ~(PME_CSR_PME_EN);
+       w &= ~(PCI_PM_CTRL_PME_ENABLE);
 
        pci_write_config_dword(pi->dev,
-                               pi->pmecap_offset + PME_CSR_OFFSET, w);
+                               pi->pmecap_offset + PCI_PM_CTRL, w);
 }
 
 u32 pcie_lcreg(void *pch, u32 mask, u32 val)
similarity index 76%
rename from drivers/staging/brcm80211/util/nvram/nvram_ro.c
rename to drivers/staging/brcm80211/brcmsmac/nvram.c
index a697ff10ef36a3657f17ac520b19977a67a01f58..085ec0b9224f798588d7b4e33b4bb1011bb202f9 100644 (file)
 #include <linux/string.h>
 #include <bcmdefs.h>
 #include <bcmutils.h>
-#include <siutils.h>
 #include <bcmnvram.h>
 #include <sbchipc.h>
-#include <bcmsrom.h>
-#include <bcmotp.h>
 #include <bcmdevs.h>
 #include <hndsoc.h>
 
@@ -43,36 +40,7 @@ static vars_t *vars;
 
 static char *findvar(char *vars, char *lim, const char *name);
 
-#if defined(FLASH)
-/* copy flash to ram */
-static void get_flash_nvram(si_t *sih, struct nvram_header *nvh)
-{
-       uint nvs, bufsz;
-       vars_t *new;
-
-       nvs = R_REG(&nvh->len) - sizeof(struct nvram_header);
-       bufsz = nvs + VARS_T_OH;
-
-       new = kmalloc(bufsz, GFP_ATOMIC);
-       if (new == NULL) {
-               NVR_MSG(("Out of memory for flash vars\n"));
-               return;
-       }
-       new->vars = (char *)new + VARS_T_OH;
-
-       new->bufsz = bufsz;
-       new->size = nvs;
-       new->next = vars;
-       vars = new;
-
-       memcpy(new->vars, &nvh[1], nvs);
-
-       NVR_MSG(("%s: flash nvram @ %p, copied %d bytes to %p\n", __func__,
-                nvh, nvs, new->vars));
-}
-#endif                         /* FLASH */
-
-int nvram_init(void *si)
+int nvram_init(void)
 {
 
        /* Make sure we read nvram in flash just once before freeing the memory */
@@ -83,14 +51,14 @@ int nvram_init(void *si)
        return 0;
 }
 
-int nvram_append(void *si, char *varlst, uint varsz)
+int nvram_append(char *varlst, uint varsz)
 {
        uint bufsz = VARS_T_OH;
        vars_t *new;
 
        new = kmalloc(bufsz, GFP_ATOMIC);
        if (new == NULL)
-               return BCME_NOMEM;
+               return -ENOMEM;
 
        new->vars = varlst;
        new->bufsz = bufsz;
@@ -98,17 +66,14 @@ int nvram_append(void *si, char *varlst, uint varsz)
        new->next = vars;
        vars = new;
 
-       return BCME_OK;
+       return 0;
 }
 
-void nvram_exit(void *si)
+void nvram_exit(void)
 {
        vars_t *this, *next;
-       si_t *sih;
 
-       sih = (si_t *) si;
        this = vars;
-
        if (this)
                kfree(this->vars);
 
@@ -138,6 +103,49 @@ static char *findvar(char *vars, char *lim, const char *name)
        return NULL;
 }
 
+/*
+ * Search the name=value vars for a specific one and return its value.
+ * Returns NULL if not found.
+ */
+char *getvar(char *vars, const char *name)
+{
+       char *s;
+       int len;
+
+       if (!name)
+               return NULL;
+
+       len = strlen(name);
+       if (len == 0)
+               return NULL;
+
+       /* first look in vars[] */
+       for (s = vars; s && *s;) {
+               if ((memcmp(s, name, len) == 0) && (s[len] == '='))
+                       return &s[len + 1];
+
+               while (*s++)
+                       ;
+       }
+       /* then query nvram */
+       return nvram_get(name);
+}
+
+/*
+ * Search the vars for a specific one and return its value as
+ * an integer. Returns 0 if not found.
+ */
+int getintvar(char *vars, const char *name)
+{
+       char *val;
+
+       val = getvar(vars, name);
+       if (val == NULL)
+               return 0;
+
+       return simple_strtoul(val, NULL, 0);
+}
+
 char *nvram_get(const char *name)
 {
        char *v = NULL;
@@ -162,7 +170,7 @@ int nvram_unset(const char *name)
        return 0;
 }
 
-int nvram_reset(void *si)
+int nvram_reset(void)
 {
        return 0;
 }
@@ -189,7 +197,7 @@ int nvram_getall(char *buf, int count)
                while ((from < lim) && (*from)) {
                        len = strlen(from) + 1;
                        if (resid < (acc + len))
-                               return BCME_BUFTOOSHORT;
+                               return -EOVERFLOW;
                        memcpy(to, from, len);
                        acc += len;
                        from += len;
@@ -201,7 +209,7 @@ int nvram_getall(char *buf, int count)
                this = this->next;
        }
        if (resid < 1)
-               return BCME_BUFTOOSHORT;
+               return -EOVERFLOW;
        *buf = '\0';
        return 0;
 }
index 8f75af2ffc5856bb43f52afddedfc636d03898b5..6cba4dfbc3ddd170dd8ac2d62d21fd762f2681b0 100644 (file)
 
 #include <linux/kernel.h>
 #include <linux/string.h>
-#include <bcmdefs.h>
+#include <linux/bitops.h>
 #include <linux/delay.h>
 #include <linux/module.h>
 #include <linux/pci.h>
+
+#include <bcmdefs.h>
 #include <bcmnvram.h>
 #include <sbchipc.h>
 #include <bcmdevs.h>
@@ -155,8 +157,6 @@ char *phy_getvar(phy_info_t *pi, const char *name)
        char *s;
        int len;
 
-       ASSERT(pi->vars != (char *)&pi->vars);
-
        if (!name)
                return NULL;
 
@@ -241,7 +241,7 @@ u16 read_radio_reg(phy_info_t *pi, u16 addr)
                break;
 
        default:
-               ASSERT(VALID_PHYTYPE(pi->pubpi.phy_type));
+               break;
        }
 
        if ((D11REV_GE(pi->sh->corerev, 24)) ||
@@ -391,16 +391,6 @@ void write_phy_channel_reg(phy_info_t *pi, uint val)
        W_REG(&pi->regs->phychannel, val);
 }
 
-#if defined(BCMDBG)
-static bool wlc_phy_war41476(phy_info_t *pi)
-{
-       u32 mc = R_REG(&pi->regs->maccontrol);
-
-       return ((mc & MCTL_EN_MAC) == 0)
-           || ((mc & MCTL_PHYLOCK) == MCTL_PHYLOCK);
-}
-#endif
-
 u16 read_phy_reg(phy_info_t *pi, u16 addr)
 {
        d11regs_t *regs;
@@ -412,10 +402,6 @@ u16 read_phy_reg(phy_info_t *pi, u16 addr)
        (void)R_REG(&regs->phyregaddr);
 #endif
 
-       ASSERT(!
-              (D11REV_IS(pi->sh->corerev, 11)
-               || D11REV_IS(pi->sh->corerev, 12)) || wlc_phy_war41476(pi));
-
        pi->phy_wreg = 0;
        return R_REG(&regs->phyregdata);
 }
@@ -455,10 +441,6 @@ void and_phy_reg(phy_info_t *pi, u16 addr, u16 val)
        (void)R_REG(&regs->phyregaddr);
 #endif
 
-       ASSERT(!
-              (D11REV_IS(pi->sh->corerev, 11)
-               || D11REV_IS(pi->sh->corerev, 12)) || wlc_phy_war41476(pi));
-
        W_REG(&regs->phyregdata, (R_REG(&regs->phyregdata) & val));
        pi->phy_wreg = 0;
 }
@@ -474,10 +456,6 @@ void or_phy_reg(phy_info_t *pi, u16 addr, u16 val)
        (void)R_REG(&regs->phyregaddr);
 #endif
 
-       ASSERT(!
-              (D11REV_IS(pi->sh->corerev, 11)
-               || D11REV_IS(pi->sh->corerev, 12)) || wlc_phy_war41476(pi));
-
        W_REG(&regs->phyregdata, (R_REG(&regs->phyregdata) | val));
        pi->phy_wreg = 0;
 }
@@ -493,10 +471,6 @@ void mod_phy_reg(phy_info_t *pi, u16 addr, u16 mask, u16 val)
        (void)R_REG(&regs->phyregaddr);
 #endif
 
-       ASSERT(!
-              (D11REV_IS(pi->sh->corerev, 11)
-               || D11REV_IS(pi->sh->corerev, 12)) || wlc_phy_war41476(pi));
-
        W_REG(&regs->phyregdata,
              ((R_REG(&regs->phyregdata) & ~mask) | (val & mask)));
        pi->phy_wreg = 0;
@@ -579,14 +553,12 @@ shared_phy_t *wlc_phy_shared_attach(shared_phy_params_t *shp)
 void wlc_phy_shared_detach(shared_phy_t *phy_sh)
 {
        if (phy_sh) {
-               if (phy_sh->phy_head) {
-                       ASSERT(!phy_sh->phy_head);
-               }
                kfree(phy_sh);
        }
 }
 
-wlc_phy_t *wlc_phy_attach(shared_phy_t *sh, void *regs, int bandtype, char *vars)
+wlc_phy_t *wlc_phy_attach(shared_phy_t *sh, void *regs, int bandtype,
+                         char *vars, struct wiphy *wiphy)
 {
        phy_info_t *pi;
        u32 sflags = 0;
@@ -596,7 +568,7 @@ wlc_phy_t *wlc_phy_attach(shared_phy_t *sh, void *regs, int bandtype, char *vars
        if (D11REV_IS(sh->corerev, 4))
                sflags = SISF_2G_PHY | SISF_5G_PHY;
        else
-               sflags = si_core_sflags(sh->sih, 0, 0);
+               sflags = ai_core_sflags(sh->sih, 0, 0);
 
        if (BAND_5G(bandtype)) {
                if ((sflags & (SISF_5G_PHY | SISF_DB_PHY)) == 0) {
@@ -616,6 +588,7 @@ wlc_phy_t *wlc_phy_attach(shared_phy_t *sh, void *regs, int bandtype, char *vars
        if (pi == NULL) {
                return NULL;
        }
+       pi->wiphy = wiphy;
        pi->regs = (d11regs_t *) regs;
        pi->sh = sh;
        pi->phy_init_por = true;
@@ -781,8 +754,6 @@ void wlc_phy_detach(wlc_phy_t *pih)
                        pi->sh->phy_head = pi->next;
                else if (pi->sh->phy_head->next == pi)
                        pi->sh->phy_head->next = NULL;
-               else
-                       ASSERT(0);
 
                if (pi->pi_fptr.detach)
                        (pi->pi_fptr.detach) (pi);
@@ -894,7 +865,6 @@ u32 wlc_phy_clk_bwbits(wlc_phy_t *pih)
                        phy_bw_clkbits = SICF_BW40;
                        break;
                default:
-                       ASSERT(0);
                        break;
                }
        }
@@ -962,24 +932,20 @@ void WLBANDINITFN(wlc_phy_init) (wlc_phy_t *pih, chanspec_t chanspec)
        pi->radio_chanspec = chanspec;
 
        mc = R_REG(&pi->regs->maccontrol);
-       if ((mc & MCTL_EN_MAC) != 0) {
-               ASSERT((const char *)
-                      "wlc_phy_init: Called with the MAC running!" == NULL);
-       }
-
-       ASSERT(pi != NULL);
+       if (WARN(mc & MCTL_EN_MAC, "HW error MAC running on init"))
+               return;
 
        if (!(pi->measure_hold & PHY_HOLD_FOR_SCAN)) {
                pi->measure_hold |= PHY_HOLD_FOR_NOT_ASSOC;
        }
 
-       if (D11REV_GE(pi->sh->corerev, 5))
-               ASSERT(si_core_sflags(pi->sh->sih, 0, 0) & SISF_FCLKA);
+       if (WARN(!(ai_core_sflags(pi->sh->sih, 0, 0) & SISF_FCLKA),
+                "HW error SISF_FCLKA\n"))
+               return;
 
        phy_init = pi->pi_fptr.init;
 
        if (phy_init == NULL) {
-               ASSERT(phy_init != NULL);
                return;
        }
 
@@ -1013,7 +979,9 @@ void wlc_phy_cal_init(wlc_phy_t *pih)
        phy_info_t *pi = (phy_info_t *) pih;
        initfn_t cal_init = NULL;
 
-       ASSERT((R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC) == 0);
+       if (WARN((R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC) != 0,
+                "HW error: MAC enabled during phy cal\n"))
+               return;
 
        if (!pi->initialized) {
                cal_init = pi->pi_fptr.calinit;
@@ -1029,8 +997,6 @@ int wlc_phy_down(wlc_phy_t *pih)
        phy_info_t *pi = (phy_info_t *) pih;
        int callbacks = 0;
 
-       ASSERT(pi->phytest_on == false);
-
        if (pi->phycal_timer
            && !wlapi_del_timer(pi->sh->physhim, pi->phycal_timer))
                callbacks++;
@@ -1070,8 +1036,6 @@ wlc_phy_table_addr(phy_info_t *pi, uint tbl_id, uint tbl_offset,
 
 void wlc_phy_table_data_write(phy_info_t *pi, uint width, u32 val)
 {
-       ASSERT((width == 8) || (width == 16) || (width == 32));
-
        if ((pi->sh->chip == BCM43224_CHIP_ID ||
             pi->sh->chip == BCM43421_CHIP_ID) &&
            (pi->sh->chiprev == 1) &&
@@ -1105,8 +1069,6 @@ wlc_phy_write_table(phy_info_t *pi, const phytbl_info_t *ptbl_info,
        const u16 *ptbl_16b = (const u16 *)ptbl_info->tbl_ptr;
        const u32 *ptbl_32b = (const u32 *)ptbl_info->tbl_ptr;
 
-       ASSERT((tbl_width == 8) || (tbl_width == 16) || (tbl_width == 32));
-
        write_phy_reg(pi, tblAddr, (tbl_id << 10) | tbl_offset);
 
        for (idx = 0; idx < ptbl_info->tbl_len; idx++) {
@@ -1148,8 +1110,6 @@ wlc_phy_read_table(phy_info_t *pi, const phytbl_info_t *ptbl_info,
        u16 *ptbl_16b = (u16 *)ptbl_info->tbl_ptr;
        u32 *ptbl_32b = (u32 *)ptbl_info->tbl_ptr;
 
-       ASSERT((tbl_width == 8) || (tbl_width == 16) || (tbl_width == 32));
-
        write_phy_reg(pi, tblAddr, (tbl_id << 10) | tbl_offset);
 
        for (idx = 0; idx < ptbl_info->tbl_len; idx++) {
@@ -1243,8 +1203,6 @@ void wlc_phy_do_dummy_tx(phy_info_t *pi, bool ofdm, bool pa_on)
        };
        u32 *dummypkt;
 
-       ASSERT((R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC) == 0);
-
        dummypkt = (u32 *) (ofdm ? ofdmpkt : cckpkt);
        wlapi_bmac_write_template_ram(pi->sh->physhim, 0, DUMMY_PKT_LEN,
                                      dummypkt);
@@ -1258,7 +1216,6 @@ void wlc_phy_do_dummy_tx(phy_info_t *pi, bool ofdm, bool pa_on)
 
        W_REG(&regs->txe_phyctl, (ofdm ? 1 : 0) | PHY_TXC_ANT_0);
        if (ISNPHY(pi) || ISLCNPHY(pi)) {
-               ASSERT(ofdm);
                W_REG(&regs->txe_phyctl1, 0x1A02);
        }
 
@@ -1317,7 +1274,6 @@ void wlc_phy_do_dummy_tx(phy_info_t *pi, bool ofdm, bool pa_on)
 void wlc_phy_hold_upd(wlc_phy_t *pih, mbool id, bool set)
 {
        phy_info_t *pi = (phy_info_t *) pih;
-       ASSERT(id);
 
        if (set) {
                mboolset(pi->measure_hold, id);
@@ -1439,8 +1395,6 @@ void wlc_phy_chanspec_set(wlc_phy_t *ppi, chanspec_t chanspec)
        u16 m_cur_channel;
        chansetfn_t chanspec_set = NULL;
 
-       ASSERT(!wf_chspec_malformed(chanspec));
-
        m_cur_channel = CHSPEC_CHANNEL(chanspec);
        if (CHSPEC_IS5G(chanspec))
                m_cur_channel |= D11_CURCHANNEL_5G;
@@ -1480,8 +1434,7 @@ int wlc_phy_chanspec_bandrange_get(phy_info_t *pi, chanspec_t chanspec)
                range = wlc_phy_get_chan_freq_range_nphy(pi, channel);
        } else if (ISLCNPHY(pi)) {
                range = wlc_phy_chanspec_freq2bandrange_lpssn(freq);
-       } else
-               ASSERT(0);
+       }
 
        return range;
 }
@@ -1511,8 +1464,6 @@ wlc_phy_chanspec_band_validch(wlc_phy_t *ppi, uint band, chanvec_t *channels)
        uint i;
        uint channel;
 
-       ASSERT((band == WLC_BAND_2G) || (band == WLC_BAND_5G));
-
        memset(channels, 0, sizeof(chanvec_t));
 
        for (i = 0; i < ARRAY_SIZE(chan_info_all); i++) {
@@ -1535,8 +1486,6 @@ chanspec_t wlc_phy_chanspec_band_firstch(wlc_phy_t *ppi, uint band)
        uint channel;
        chanspec_t chspec;
 
-       ASSERT((band == WLC_BAND_2G) || (band == WLC_BAND_5G));
-
        for (i = 0; i < ARRAY_SIZE(chan_info_all); i++) {
                channel = chan_info_all[i].chan;
 
@@ -1572,8 +1521,6 @@ chanspec_t wlc_phy_chanspec_band_firstch(wlc_phy_t *ppi, uint band)
                        return chspec;
        }
 
-       ASSERT(0);
-
        return (chanspec_t) INVCHANSPEC;
 }
 
@@ -1581,7 +1528,6 @@ int wlc_phy_txpower_get(wlc_phy_t *ppi, uint *qdbm, bool *override)
 {
        phy_info_t *pi = (phy_info_t *) ppi;
 
-       ASSERT(qdbm != NULL);
        *qdbm = pi->tx_user_target[0];
        if (override != NULL)
                *override = pi->txpwroverride;
@@ -1703,7 +1649,6 @@ wlc_phy_txpower_sromlimit(wlc_phy_t *ppi, uint channel, u8 *min_pwr,
                                break;
                        }
                }
-               ASSERT(i < ARRAY_SIZE(chan_info_all));
 
                if (pi->hwtxpwr) {
                        *max_pwr = pi->hwtxpwr[i];
@@ -2134,7 +2079,6 @@ void wlc_phy_txpower_update_shm(phy_info_t *pi)
 {
        int j;
        if (ISNPHY(pi)) {
-               ASSERT(0);
                return;
        }
 
@@ -2466,8 +2410,6 @@ void wlc_phy_ant_rxdiv_set(wlc_phy_t *ppi, u8 val)
                        mod_phy_reg(pi, 0x410, (0x1 << 1), 0x00 << 1);
                        mod_phy_reg(pi, 0x410, (0x1 << 0), (u16) val << 0);
                }
-       } else {
-               ASSERT(0);
        }
 
        if (!suspend)
@@ -2483,7 +2425,6 @@ wlc_phy_noise_calc_phy(phy_info_t *pi, u32 *cmplx_pwr, s8 *pwr_ant)
        u8 i;
 
        memset((u8 *) cmplx_pwr_dbm, 0, sizeof(cmplx_pwr_dbm));
-       ASSERT(pi->pubpi.phy_corenum <= PHY_CORE_MAX);
        wlc_phy_compute_dB(cmplx_pwr, cmplx_pwr_dbm, pi->pubpi.phy_corenum);
 
        for (i = 0; i < pi->pubpi.phy_corenum; i++) {
@@ -2529,7 +2470,6 @@ wlc_phy_noise_sample_request(wlc_phy_t *pih, u8 reason, u8 ch)
                break;
 
        default:
-               ASSERT(0);
                break;
        }
 
@@ -2678,7 +2618,6 @@ static s8 wlc_phy_noise_read_shmem(phy_info_t *pi)
        s8 noise_dbm = PHY_NOISE_FIXED_VAL_NPHY;
        u8 idx, core;
 
-       ASSERT(pi->pubpi.phy_corenum <= PHY_CORE_MAX);
        memset((u8 *) cmplx_pwr, 0, sizeof(cmplx_pwr));
        memset((u8 *) noise_dbm_ant, 0, sizeof(noise_dbm_ant));
 
@@ -2760,8 +2699,6 @@ void wlc_phy_noise_sample_intr(wlc_phy_t *pih)
                channel = jssi_aux & D11_CURCHANNEL_MAX;
 
                noise_dbm = wlc_phy_noise_read_shmem(pi);
-       } else {
-               ASSERT(0);
        }
 
        wlc_phy_noise_cb(pi, channel, noise_dbm);
@@ -2811,25 +2748,20 @@ s8 lcnphy_gain_index_offset_for_pkt_rssi[] = {
 
 void wlc_phy_compute_dB(u32 *cmplx_pwr, s8 *p_cmplx_pwr_dB, u8 core)
 {
-       u8 shift_ct, lsb, msb, secondmsb, i;
+       u8 msb, secondmsb, i;
        u32 tmp;
 
        for (i = 0; i < core; i++) {
+               secondmsb = 0;
                tmp = cmplx_pwr[i];
-               shift_ct = msb = secondmsb = 0;
-               while (tmp != 0) {
-                       tmp = tmp >> 1;
-                       shift_ct++;
-                       lsb = (u8) (tmp & 1);
-                       if (lsb == 1)
-                               msb = shift_ct;
-               }
-               secondmsb = (u8) ((cmplx_pwr[i] >> (msb - 1)) & 1);
+               msb = fls(tmp);
+               if (msb)
+                       secondmsb = (u8) ((tmp >> (--msb - 1)) & 1);
                p_cmplx_pwr_dB[i] = (s8) (3 * msb + 2 * secondmsb);
        }
 }
 
-void BCMFASTPATH wlc_phy_rssi_compute(wlc_phy_t *pih, void *ctx)
+void wlc_phy_rssi_compute(wlc_phy_t *pih, void *ctx)
 {
        wlc_d11rxhdr_t *wlc_rxhdr = (wlc_d11rxhdr_t *) ctx;
        d11rxhdr_t *rxh = &wlc_rxhdr->rxhdr;
@@ -2871,10 +2803,7 @@ void BCMFASTPATH wlc_phy_rssi_compute(wlc_phy_t *pih, void *ctx)
                        rssi -= 256;
        } else if (radioid == BCM2055_ID || radioid == BCM2056_ID
                   || radioid == BCM2057_ID) {
-               ASSERT(ISNPHY(pi));
                rssi = wlc_phy_rssi_compute_nphy(pi, wlc_rxhdr);
-       } else {
-               ASSERT((const char *)"Unknown radio" == NULL);
        }
 
  end:
@@ -2900,9 +2829,6 @@ void wlc_phy_set_deaf(wlc_phy_t *ppi, bool user_flag)
                wlc_lcnphy_deaf_mode(pi, true);
        else if (ISNPHY(pi))
                wlc_nphy_deaf_mode(pi, true);
-       else {
-               ASSERT(0);
-       }
 }
 
 void wlc_phy_watchdog(wlc_phy_t *pih)
@@ -3163,13 +3089,9 @@ void wlc_phy_cal_perical(wlc_phy_t *pih, u8 reason)
                        } else if (pi->nphy_perical == PHY_PERICAL_SPHASE)
                                wlc_phy_cal_perical_nphy_run(pi,
                                                             PHY_PERICAL_AUTO);
-                       else {
-                               ASSERT(0);
-                       }
                }
                break;
        default:
-               ASSERT(0);
                break;
        }
 }
@@ -3192,25 +3114,6 @@ u8 wlc_phy_nbits(s32 value)
        return nbits;
 }
 
-u32 wlc_phy_sqrt_int(u32 value)
-{
-       u32 root = 0, shift = 0;
-
-       for (shift = 0; shift < 32; shift += 2) {
-               if (((0x40000000 >> shift) + root) <= value) {
-                       value -= ((0x40000000 >> shift) + root);
-                       root = (root >> 1) | (0x40000000 >> shift);
-               } else {
-                       root = root >> 1;
-               }
-       }
-
-       if (root < value)
-               ++root;
-
-       return root;
-}
-
 void wlc_phy_stf_chain_init(wlc_phy_t *pih, u8 txchain, u8 rxchain)
 {
        phy_info_t *pi = (phy_info_t *) pih;
@@ -3311,12 +3214,12 @@ void wlc_lcnphy_epa_switch(phy_info_t *pi, bool mode)
                                mod_phy_reg(pi, 0x44c, (0x1 << 2), (1) << 2);
 
                        }
-                       si_corereg(pi->sh->sih, SI_CC_IDX,
+                       ai_corereg(pi->sh->sih, SI_CC_IDX,
                                   offsetof(chipcregs_t, gpiocontrol), ~0x0,
                                   0x0);
-                       si_corereg(pi->sh->sih, SI_CC_IDX,
+                       ai_corereg(pi->sh->sih, SI_CC_IDX,
                                   offsetof(chipcregs_t, gpioout), 0x40, 0x40);
-                       si_corereg(pi->sh->sih, SI_CC_IDX,
+                       ai_corereg(pi->sh->sih, SI_CC_IDX,
                                   offsetof(chipcregs_t, gpioouten), 0x40,
                                   0x40);
                } else {
@@ -3324,11 +3227,11 @@ void wlc_lcnphy_epa_switch(phy_info_t *pi, bool mode)
 
                        mod_phy_reg(pi, 0x44d, (0x1 << 2), (0) << 2);
 
-                       si_corereg(pi->sh->sih, SI_CC_IDX,
+                       ai_corereg(pi->sh->sih, SI_CC_IDX,
                                   offsetof(chipcregs_t, gpioout), 0x40, 0x00);
-                       si_corereg(pi->sh->sih, SI_CC_IDX,
+                       ai_corereg(pi->sh->sih, SI_CC_IDX,
                                   offsetof(chipcregs_t, gpioouten), 0x40, 0x0);
-                       si_corereg(pi->sh->sih, SI_CC_IDX,
+                       ai_corereg(pi->sh->sih, SI_CC_IDX,
                                   offsetof(chipcregs_t, gpiocontrol), ~0x0,
                                   0x40);
                }
@@ -3387,33 +3290,6 @@ wlc_phy_get_pwrdet_offsets(phy_info_t *pi, s8 *cckoffset, s8 *ofdmoffset)
        *ofdmoffset = 0;
 }
 
-u32 wlc_phy_qdiv_roundup(u32 dividend, u32 divisor, u8 precision)
-{
-       u32 quotient, remainder, roundup, rbit;
-
-       ASSERT(divisor);
-
-       quotient = dividend / divisor;
-       remainder = dividend % divisor;
-       rbit = divisor & 1;
-       roundup = (divisor >> 1) + rbit;
-
-       while (precision--) {
-               quotient <<= 1;
-               if (remainder >= roundup) {
-                       quotient++;
-                       remainder = ((remainder - roundup) << 1) + rbit;
-               } else {
-                       remainder <<= 1;
-               }
-       }
-
-       if (remainder >= roundup)
-               quotient++;
-
-       return quotient;
-}
-
 s8 wlc_phy_upd_rssi_offset(phy_info_t *pi, s8 rssi, chanspec_t chanspec)
 {
 
index bf962d5b339af57fe9a40903c1038099ee96ab57..8939153efa56d257770776cb225113a113c77705 100644 (file)
 #define _wlc_phy_h_
 
 #include <wlioctl.h>
-#include <siutils.h>
+#include <aiutils.h>
 #include <d11.h>
 #include <wlc_phy_shim.h>
+#include <net/mac80211.h>      /* struct wiphy */
 
 #define        IDCODE_VER_MASK         0x0000000f
 #define        IDCODE_VER_SHIFT        0
@@ -149,7 +150,7 @@ typedef struct shared_phy_params {
 extern shared_phy_t *wlc_phy_shared_attach(shared_phy_params_t *shp);
 extern void wlc_phy_shared_detach(shared_phy_t *phy_sh);
 extern wlc_phy_t *wlc_phy_attach(shared_phy_t *sh, void *regs, int bandtype,
-                                char *vars);
+                                char *vars, struct wiphy *wiphy);
 extern void wlc_phy_detach(wlc_phy_t *ppi);
 
 extern bool wlc_phy_get_phyversion(wlc_phy_t *pih, u16 *phytype,
index 6e12a95c736051de60b8f4604fc5f17d5ed0fe9d..10cbf520474fcf7e918798d27168ceb835ad28b3 100644 (file)
@@ -936,6 +936,7 @@ struct phy_info {
        u8 phycal_tempdelta;
        u32 mcs20_po;
        u32 mcs40_po;
+       struct wiphy *wiphy;
 };
 
 typedef s32 fixed;
@@ -1024,7 +1025,6 @@ extern void wlc_phy_txpower_update_shm(phy_info_t *pi);
 
 extern void wlc_phy_cordic(fixed theta, cs32 *val);
 extern u8 wlc_phy_nbits(s32 value);
-extern u32 wlc_phy_sqrt_int(u32 value);
 extern void wlc_phy_compute_dB(u32 *cmplx_pwr, s8 *p_dB, u8 core);
 
 extern uint wlc_phy_init_radio_regs_allbands(phy_info_t *pi,
@@ -1093,8 +1093,6 @@ extern void wlc_lcnphy_epa_switch(phy_info_t *pi, bool mode);
 extern void wlc_2064_vco_cal(phy_info_t *pi);
 
 extern void wlc_phy_txpower_recalc_target(phy_info_t *pi);
-extern u32 wlc_phy_qdiv_roundup(u32 dividend, u32 divisor,
-                                  u8 precision);
 
 #define LCNPHY_TBL_ID_PAPDCOMPDELTATBL 0x18
 #define LCNPHY_TX_POWER_TABLE_SIZE     128
index a5a7bb82ab42619c2767cf49259b57c2db7216b1..b8864c5b7a199cb11d4f4d548da37c127005b57c 100644 (file)
 #include <linux/bitops.h>
 #include <linux/delay.h>
 #include <wlc_cfg.h>
-#include <qmath.h>
 #include <linux/pci.h>
-#include <siutils.h>
-#include <hndpmu.h>
+#include <aiutils.h>
+#include <wlc_pmu.h>
+#include <bcmnvram.h>
 
 #include <bcmdevs.h>
 #include <sbhnddma.h>
 
-#include <wlc_phy_radio.h>
-#include <wlc_phy_int.h>
-#include <wlc_phy_lcn.h>
-#include <wlc_phytbl_lcn.h>
+#include "wlc_phy_radio.h"
+#include "wlc_phy_int.h"
+#include "wlc_phy_qmath.h"
+#include "wlc_phy_lcn.h"
+#include "wlc_phytbl_lcn.h"
 
 #define PLL_2064_NDIV          90
 #define PLL_2064_LOW_END_VCO   3000
@@ -1081,8 +1082,6 @@ wlc_lcnphy_qdiv_roundup(u32 dividend, u32 divisor, u8 precision)
 {
        u32 quotient, remainder, roundup, rbit;
 
-       ASSERT(divisor);
-
        quotient = dividend / divisor;
        remainder = dividend % divisor;
        rbit = divisor & 1;
@@ -1780,11 +1779,6 @@ void wlc_lcnphy_set_tx_pwr_ctrl(phy_info_t *pi, u16 mode)
        s8 index;
        phy_info_lcnphy_t *pi_lcn = pi->u.pi_lcnphy;
 
-       ASSERT((LCNPHY_TX_PWR_CTRL_OFF == mode) ||
-              (LCNPHY_TX_PWR_CTRL_SW == mode) ||
-              (LCNPHY_TX_PWR_CTRL_HW == mode) ||
-              (LCNPHY_TX_PWR_CTRL_TEMPBASED == mode));
-
        mode = wlc_lcnphy_set_tx_pwr_ctrl_mode(pi, mode);
        old_mode = wlc_lcnphy_set_tx_pwr_ctrl_mode(pi, old_mode);
 
@@ -1904,16 +1898,14 @@ wlc_lcnphy_tx_iqlo_cal(phy_info_t *pi,
                break;
 
        case LCNPHY_CAL_RECAL:
-               ASSERT(pi_lcn->lcnphy_cal_results.txiqlocal_bestcoeffs_valid);
-
                start_coeffs = syst_coeffs;
-
                cal_cmds = commands_recal;
                n_cal_cmds = ARRAY_SIZE(commands_recal);
                command_nums = command_nums_recal;
                break;
+
        default:
-               ASSERT(false);
+               break;
        }
 
        wlc_lcnphy_common_write_table(pi, LCNPHY_TBL_ID_IQLOCAL,
@@ -2460,8 +2452,6 @@ void wlc_lcnphy_set_tx_pwr_by_index(phy_info_t *pi, int index)
        lcnphy_txgains_t gains;
        phy_info_lcnphy_t *pi_lcn = pi->u.pi_lcnphy;
 
-       ASSERT(index <= LCNPHY_MAX_TX_POWER_INDEX);
-
        pi_lcn->lcnphy_tx_power_idx_override = (s8) index;
        pi_lcn->lcnphy_current_index = (u8) index;
 
@@ -2760,7 +2750,6 @@ wlc_lcnphy_start_tx_tone(phy_info_t *pi, s32 f_kHz, u16 max_val,
                do {
                        bw = phy_bw * 1000 * k;
                        num_samps = bw / ABS(f_kHz);
-                       ASSERT(num_samps <= ARRAY_SIZE(data_buf));
                        k++;
                } while ((num_samps * (u32) (ABS(f_kHz))) != bw);
        } else
@@ -3255,7 +3244,7 @@ static bool wlc_lcnphy_calc_rx_iq_comp(phy_info_t *pi, u16 num_samps)
        }
        b /= temp;
        b -= a * a;
-       b = (s32) wlc_phy_sqrt_int((u32) b);
+       b = (s32) int_sqrt((unsigned long) b);
        b -= (1 << 10);
        a0_new = (u16) (a & 0x3ff);
        b0_new = (u16) (b & 0x3ff);
@@ -3298,8 +3287,6 @@ wlc_lcnphy_rx_iq_cal(phy_info_t *pi, const lcnphy_rx_iqcomp_t *iqcomp,
                return false;
        }
        if (module == 2) {
-               ASSERT(iqcomp_sz);
-
                while (iqcomp_sz--) {
                        if (iqcomp[iqcomp_sz].chan ==
                            CHSPEC_CHANNEL(pi->radio_chanspec)) {
@@ -3313,7 +3300,6 @@ wlc_lcnphy_rx_iq_cal(phy_info_t *pi, const lcnphy_rx_iqcomp_t *iqcomp,
                                break;
                        }
                }
-               ASSERT(result);
                goto cal_done;
        }
 
@@ -3584,9 +3570,6 @@ void wlc_lcnphy_calib_modes(phy_info_t *pi, uint mode)
                if (wlc_lcnphy_tempsense_based_pwr_ctrl_enabled(pi))
                        wlc_lcnphy_tx_power_adjustment((wlc_phy_t *) pi);
                break;
-       default:
-               ASSERT(0);
-               break;
        }
 }
 
@@ -5071,9 +5054,7 @@ bool wlc_phy_attach_lcnphy(phy_info_t *pi)
                pi->hwpwrctrl_capable = true;
        }
 
-       pi->xtalfreq = si_alp_clock(pi->sh->sih);
-       ASSERT(0 == (pi->xtalfreq % 1000));
-
+       pi->xtalfreq = si_pmu_alp_clock(pi->sh->sih);
        pi_lcn->lcnphy_papd_rxGnCtrl_init = 0;
 
        pi->pi_fptr.init = wlc_phy_init_lcnphy;
@@ -5293,9 +5274,7 @@ wlc_lcnphy_load_tx_iir_filter(phy_info_t *pi, bool is_ofdm, s16 filt_type)
                        }
                }
 
-               if (filt_index == -1) {
-                       ASSERT(false);
-               } else {
+               if (filt_index != -1) {
                        for (j = 0; j < LCNPHY_NUM_DIG_FILT_COEFFS; j++) {
                                write_phy_reg(pi, addr[j],
                                              LCNPHY_txdigfiltcoeffs_cck
@@ -5310,9 +5289,7 @@ wlc_lcnphy_load_tx_iir_filter(phy_info_t *pi, bool is_ofdm, s16 filt_type)
                        }
                }
 
-               if (filt_index == -1) {
-                       ASSERT(false);
-               } else {
+               if (filt_index != -1) {
                        for (j = 0; j < LCNPHY_NUM_DIG_FILT_COEFFS; j++) {
                                write_phy_reg(pi, addr_ofdm[j],
                                              LCNPHY_txdigfiltcoeffs_ofdm
index 7947c6028b6e8c8cbb44e93538f20d60643f1733..71275094e810b8cf66591d9654174dac99034e94 100644 (file)
@@ -20,9 +20,9 @@
 #include <wlc_cfg.h>
 #include <linux/delay.h>
 #include <linux/pci.h>
-#include <siutils.h>
+#include <aiutils.h>
 #include <sbchipc.h>
-#include <hndpmu.h>
+#include <wlc_pmu.h>
 
 #include <bcmdevs.h>
 #include <sbhnddma.h>
@@ -14218,8 +14218,6 @@ static void WLBANDINITFN(wlc_phy_bphy_init_nphy) (phy_info_t *pi)
 {
        u16 addr, val;
 
-       ASSERT(ISNPHY(pi));
-
        val = 0x1e1f;
        for (addr = (NPHY_TO_BPHY_OFF + BPHY_RSSI_LUT);
             addr <= (NPHY_TO_BPHY_OFF + BPHY_RSSI_LUT_END); addr++) {
@@ -14367,8 +14365,6 @@ static void WLBANDINITFN(wlc_phy_tbl_init_nphy) (phy_info_t *pi)
                        break;
 
                default:
-
-                       ASSERT(0);
                        break;
                }
 
@@ -14401,8 +14397,6 @@ static void WLBANDINITFN(wlc_phy_tbl_init_nphy) (phy_info_t *pi)
                                                                 [idx]);
                                        break;
                                default:
-
-                                       ASSERT(0);
                                        break;
                                }
                        } else {
@@ -14550,7 +14544,7 @@ void WLBANDINITFN(wlc_phy_init_nphy) (phy_info_t *pi)
             (pi->sh->chippkg == BCM4718_PKG_ID))) {
                if ((pi->sh->boardflags & BFL_EXTLNA) &&
                    (CHSPEC_IS2G(pi->radio_chanspec))) {
-                       si_corereg(pi->sh->sih, SI_CC_IDX,
+                       ai_corereg(pi->sh->sih, SI_CC_IDX,
                                   offsetof(chipcregs_t, chipcontrol), 0x40,
                                   0x40);
                }
@@ -14564,17 +14558,15 @@ void WLBANDINITFN(wlc_phy_init_nphy) (phy_info_t *pi)
        if ((pi->nphy_gband_spurwar2_en) && CHSPEC_IS2G(pi->radio_chanspec) &&
            CHSPEC_IS40(pi->radio_chanspec)) {
 
-               regs = (d11regs_t *) si_switch_core(pi->sh->sih, D11_CORE_ID,
+               regs = (d11regs_t *) ai_switch_core(pi->sh->sih, D11_CORE_ID,
                                                    &origidx, &intr_val);
-               ASSERT(regs != NULL);
-
                d11_clk_ctl_st = R_REG(&regs->clk_ctl_st);
                AND_REG(&regs->clk_ctl_st,
                        ~(CCS_FORCEHT | CCS_HTAREQ));
 
                W_REG(&regs->clk_ctl_st, d11_clk_ctl_st);
 
-               si_restore_core(pi->sh->sih, origidx, intr_val);
+               ai_restore_core(pi->sh->sih, origidx, intr_val);
        }
 
        pi->use_int_tx_iqlo_cal_nphy =
@@ -14783,10 +14775,7 @@ void WLBANDINITFN(wlc_phy_init_nphy) (phy_info_t *pi)
                                                rfpwr_offset = (s16)
                                                    nphy_papd_padgain_dlt_2g_2057rev7
                                                    [pad_gn];
-                                       } else {
-                                               ASSERT(0);
                                        }
-
                                } else {
                                        if ((pi->pubpi.radiorev == 3) ||
                                            (pi->pubpi.radiorev == 4) ||
@@ -14800,8 +14789,6 @@ void WLBANDINITFN(wlc_phy_init_nphy) (phy_info_t *pi)
                                                rfpwr_offset = (s16)
                                                    nphy_papd_pgagain_dlt_5g_2057rev7
                                                    [pga_gn];
-                                       } else {
-                                               ASSERT(0);
                                        }
                                }
                                wlc_phy_table_write_nphy(pi,
@@ -14905,10 +14892,10 @@ void WLBANDINITFN(wlc_phy_init_nphy) (phy_info_t *pi)
                                }
 
                                if (wlc_phy_cal_txiqlo_nphy
-                                   (pi, target_gain, true, false) == BCME_OK) {
+                                   (pi, target_gain, true, false) == 0) {
                                        if (wlc_phy_cal_rxiq_nphy
                                            (pi, target_gain, 2,
-                                            false) == BCME_OK) {
+                                            false) == 0) {
                                                wlc_phy_savecal_nphy(pi);
 
                                        }
@@ -14963,8 +14950,6 @@ static void wlc_phy_resetcca_nphy(phy_info_t *pi)
 {
        u16 val;
 
-       ASSERT(0 == (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC));
-
        wlapi_bmac_phyclk_fgc(pi->sh->physhim, ON);
 
        val = read_phy_reg(pi, 0x01);
@@ -16130,8 +16115,6 @@ static void wlc_phy_workarounds_nphy(phy_info_t *pi)
                                                 0x18, 16, bcm_adc_vmid);
                        wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 4,
                                                 0x1c, 16, bcm_adc_gain);
-               } else {
-                       ASSERT(0);
                }
 
                write_radio_reg(pi,
@@ -17418,8 +17401,10 @@ static void wlc_phy_radio_postinit_2055(phy_info_t *pi)
        SPINWAIT(((read_radio_reg(pi, RADIO_2055_CAL_COUNTER_OUT2) &
                   RADIO_2055_RCAL_DONE) != RADIO_2055_RCAL_DONE), 2000);
 
-       ASSERT((read_radio_reg(pi, RADIO_2055_CAL_COUNTER_OUT2) &
-               RADIO_2055_RCAL_DONE) == RADIO_2055_RCAL_DONE);
+       if (WARN((read_radio_reg(pi, RADIO_2055_CAL_COUNTER_OUT2) &
+                RADIO_2055_RCAL_DONE) != RADIO_2055_RCAL_DONE,
+                "HW error: radio calibration1\n"))
+               return;
 
        and_radio_reg(pi, RADIO_2055_CAL_LPO_CNTRL,
                      ~(RADIO_2055_CAL_LPO_ENABLE));
@@ -17510,7 +17495,6 @@ static void wlc_phy_radio_init_2056(phy_info_t *pi)
                        break;
 
                default:
-                       ASSERT(0);
                        break;
                }
        }
@@ -17571,7 +17555,6 @@ static void wlc_phy_radio_init_2057(phy_info_t *pi)
 
                                regs_2057_ptr = regs_2057_rev5v1;
                        } else {
-                               ASSERT(0);
                                break;
                        }
 
@@ -17586,11 +17569,8 @@ static void wlc_phy_radio_init_2057(phy_info_t *pi)
                        break;
 
                default:
-                       ASSERT(0);
                        break;
                }
-       } else {
-               ASSERT(0);
        }
 
        wlc_phy_init_radio_regs_allbands(pi, regs_2057_ptr);
@@ -17708,7 +17688,6 @@ wlc_phy_chan2freq_nphy(phy_info_t *pi, uint channel, int *f,
                }
 
                if (i >= tbl_len) {
-                       ASSERT(i < tbl_len);
                        goto fail;
                }
                if (pi->pubpi.radiorev == 5) {
@@ -17765,7 +17744,6 @@ wlc_phy_chan2freq_nphy(phy_info_t *pi, uint channel, int *f,
                }
 
                if (i >= tbl_len) {
-                       ASSERT(i < tbl_len);
                        goto fail;
                }
                *t1 = &chan_info_tbl_p_1[i];
@@ -17777,7 +17755,6 @@ wlc_phy_chan2freq_nphy(phy_info_t *pi, uint channel, int *f,
                                break;
 
                if (i >= ARRAY_SIZE(chan_info_nphy_2055)) {
-                       ASSERT(i < ARRAY_SIZE(chan_info_nphy_2055));
                        goto fail;
                }
                *t3 = &chan_info_nphy_2055[i];
@@ -18276,7 +18253,9 @@ static u16 wlc_phy_radio205x_rcal(phy_info_t *pi)
                        udelay(100);
                }
 
-               ASSERT(i < MAX_205x_RCAL_WAITLOOPS);
+               if (WARN(i == MAX_205x_RCAL_WAITLOOPS,
+                        "HW error: radio calib2"))
+                       return 0;
 
                mod_radio_reg(pi, RADIO_2057_RCAL_CONFIG, 0x2, 0x0);
 
@@ -18325,7 +18304,9 @@ static u16 wlc_phy_radio205x_rcal(phy_info_t *pi)
                        udelay(100);
                }
 
-               ASSERT(i < MAX_205x_RCAL_WAITLOOPS);
+               if (WARN(i == MAX_205x_RCAL_WAITLOOPS,
+                        "HW error: radio calib3"))
+                       return 0;
 
                write_radio_reg(pi, RADIO_2056_SYN_RCAL_MASTER | RADIO_2056_SYN,
                                0x1);
@@ -18572,8 +18553,6 @@ static u16 wlc_phy_radio2057_rccal(phy_info_t *pi)
                udelay(500);
        }
 
-       ASSERT(rccal_valid & 0x2);
-
        write_radio_reg(pi, RADIO_2057_RCCAL_START_R1_Q1_P1, 0x15);
 
        rccal_valid = 0;
@@ -18596,8 +18575,6 @@ static u16 wlc_phy_radio2057_rccal(phy_info_t *pi)
                udelay(500);
        }
 
-       ASSERT(rccal_valid & 0x2);
-
        write_radio_reg(pi, RADIO_2057_RCCAL_START_R1_Q1_P1, 0x15);
 
        rccal_valid = 0;
@@ -18621,7 +18598,8 @@ static u16 wlc_phy_radio2057_rccal(phy_info_t *pi)
                udelay(500);
        }
 
-       ASSERT(rccal_valid & 0x2);
+       if (WARN(!(rccal_valid & 0x2), "HW error: radio calib4"))
+               return 0;
 
        write_radio_reg(pi, RADIO_2057_RCCAL_START_R1_Q1_P1, 0x15);
 
@@ -19585,8 +19563,6 @@ void wlc_phy_antsel_init(wlc_phy_t *ppi, bool lut_init)
                                                 1, 0x08, 16, &v2);
                        wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_ANTSWCTRLLUT,
                                                 1, 0x0C, 16, &v3);
-               } else {
-                       ASSERT(0);
                }
 
                if (pi->srom_fem5g.antswctrllut == 0) {
@@ -19598,15 +19574,13 @@ void wlc_phy_antsel_init(wlc_phy_t *ppi, bool lut_init)
                                                 1, 0x18, 16, &v2);
                        wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_ANTSWCTRLLUT,
                                                 1, 0x1C, 16, &v3);
-               } else {
-                       ASSERT(0);
                }
        } else {
 
                write_phy_reg(pi, 0xc8, 0x0);
                write_phy_reg(pi, 0xc9, 0x0);
 
-               si_gpiocontrol(pi->sh->sih, mask, mask, GPIO_DRV_PRIORITY);
+               ai_gpiocontrol(pi->sh->sih, mask, mask, GPIO_DRV_PRIORITY);
 
                mc = R_REG(&pi->regs->maccontrol);
                mc &= ~MCTL_GPOUT_SEL_MASK;
@@ -19703,8 +19677,7 @@ void wlc_phy_force_rfseq_nphy(phy_info_t *pi, u8 cmd)
        or_phy_reg(pi, 0xa3, trigger_mask);
        SPINWAIT((read_phy_reg(pi, 0xa4) & status_mask), 200000);
        write_phy_reg(pi, 0xa1, orig_RfseqCoreActv);
-
-       ASSERT((read_phy_reg(pi, 0xa4) & status_mask) == 0);
+       WARN(read_phy_reg(pi, 0xa4) & status_mask, "HW error in rf");
 }
 
 static void
@@ -19718,8 +19691,6 @@ wlc_phy_set_rfseq_nphy(phy_info_t *pi, u8 cmd, u8 *events, u8 *dlys,
                    3) ? NPHY_REV3_RFSEQ_CMD_END : NPHY_RFSEQ_CMD_END;
        u8 end_dly = 1;
 
-       ASSERT(len <= 16);
-
        if (pi->phyhang_avoid)
                wlc_phy_stay_in_carriersearch_nphy(pi, true);
 
@@ -21467,7 +21438,7 @@ static void wlc_phy_rssi_cal_nphy_rev2(phy_info_t *pi, u8 rssi_type)
        wlc_phy_resetcca_nphy(pi);
 }
 
-int BCMFASTPATH
+int
 wlc_phy_rssi_compute_nphy(phy_info_t *pi, wlc_d11rxhdr_t *wlc_rxh)
 {
        d11rxhdr_t *rxh = &wlc_rxh->rxhdr;
@@ -21503,8 +21474,6 @@ wlc_phy_rssi_compute_nphy(phy_info_t *pi, wlc_d11rxhdr_t *wlc_rxh)
                rxpwr = (rxpwr0 < rxpwr1) ? rxpwr0 : rxpwr1;
        else if (pi->sh->rssi_mode == RSSI_ANT_MERGE_AVG)
                rxpwr = (rxpwr0 + rxpwr1) >> 1;
-       else
-               ASSERT(0);
 
        return rxpwr;
 }
@@ -21588,8 +21557,9 @@ wlc_phy_rfctrlintc_override_nphy(phy_info_t *pi, u8 field, u16 value,
 
                                        SPINWAIT(((read_phy_reg(pi, 0x78) & val)
                                                  != 0), 10000);
-                                       ASSERT((read_phy_reg(pi, 0x78) & val) ==
-                                              0);
+                                       if (WARN(read_phy_reg(pi, 0x78) & val,
+                                               "HW error: override failed"))
+                                               return;
 
                                        mask = (0x1 << 0);
                                        val = 0 << 0;
@@ -22233,8 +22203,6 @@ static void wlc_phy_rssi_cal_nphy_rev3(phy_info_t *pi)
 
 static void wlc_phy_restore_rssical_nphy(phy_info_t *pi)
 {
-       ASSERT(NREV_GE(pi->pubpi.phy_rev, 3));
-
        if (CHSPEC_IS2G(pi->radio_chanspec)) {
                if (pi->nphy_rssical_chanspec_2G == 0)
                        return;
@@ -22399,13 +22367,13 @@ wlc_phy_tx_tone_nphy(phy_info_t *pi, u32 f_kHz, u16 max_val,
        num_samps =
                wlc_phy_gen_load_samples_nphy(pi, f_kHz, max_val, dac_test_mode);
        if (num_samps == 0) {
-               return BCME_ERROR;
+               return -EBADE;
        }
 
        wlc_phy_runsamples_nphy(pi, num_samps, loops, wait, iqmode,
                                dac_test_mode, modify_bbmult);
 
-       return BCME_OK;
+       return 0;
 }
 
 static void
@@ -22775,8 +22743,6 @@ wlc_phy_iqcal_gainparams_nphy(phy_info_t *pi, u16 core_no,
                        }
                }
 
-               ASSERT(idx != -1);
-
                params->txgm = tbl_iqcal_gainparams_nphy[band_idx][k][1];
                params->pga = tbl_iqcal_gainparams_nphy[band_idx][k][2];
                params->pad = tbl_iqcal_gainparams_nphy[band_idx][k][3];
@@ -23855,8 +23821,6 @@ void wlc_phy_cal_perical_nphy_run(phy_info_t *pi, u8 caltype)
        if (PHY_MUTED(pi))
                return;
 
-       ASSERT(pi->nphy_perical != PHY_PERICAL_DISABLE);
-
        if (caltype == PHY_PERICAL_AUTO)
                fullcal = (pi->radio_chanspec != pi->nphy_txiqlocal_chanspec);
        else if (caltype == PHY_PERICAL_PARTIAL)
@@ -23913,7 +23877,7 @@ void wlc_phy_cal_perical_nphy_run(phy_info_t *pi, u8 caltype)
 
                        target_gain = pi->nphy_cal_target_gain;
                }
-               if (BCME_OK ==
+               if (0 ==
                    wlc_phy_cal_txiqlo_nphy(pi, target_gain, fullcal, mphase)) {
                        if (PHY_IPA(pi))
                                wlc_phy_a4(pi, true);
@@ -23925,7 +23889,7 @@ void wlc_phy_cal_perical_nphy_run(phy_info_t *pi, u8 caltype)
                        wlapi_suspend_mac_and_wait(pi->sh->physhim);
                        wlc_phyreg_enter((wlc_phy_t *) pi);
 
-                       if (BCME_OK == wlc_phy_cal_rxiq_nphy(pi, target_gain,
+                       if (0 == wlc_phy_cal_rxiq_nphy(pi, target_gain,
                                                             (pi->
                                                              first_cal_after_assoc
                                                              || (pi->
@@ -23955,8 +23919,6 @@ void wlc_phy_cal_perical_nphy_run(phy_info_t *pi, u8 caltype)
                        wlc_phy_radio205x_vcocal_nphy(pi);
                }
        } else {
-               ASSERT(pi->nphy_perical >= PHY_PERICAL_MPHASE);
-
                switch (pi->mphase_cal_phase_id) {
                case MPHASE_CAL_STATE_INIT:
                        pi->nphy_perical_last = pi->sh->now;
@@ -23980,7 +23942,7 @@ void wlc_phy_cal_perical_nphy_run(phy_info_t *pi, u8 caltype)
 
                        if (wlc_phy_cal_txiqlo_nphy
                            (pi, pi->nphy_cal_target_gain, fullcal,
-                            true) != BCME_OK) {
+                            true) != 0) {
 
                                wlc_phy_cal_perical_mphase_reset(pi);
                                break;
@@ -24012,7 +23974,7 @@ void wlc_phy_cal_perical_nphy_run(phy_info_t *pi, u8 caltype)
                                                  (pi->first_cal_after_assoc ||
                                                   (pi->cal_type_override ==
                                                    PHY_PERICAL_FULL)) ? 2 : 0,
-                                                 false) == BCME_OK) {
+                                                 false) == 0) {
                                wlc_phy_savecal_nphy(pi);
                        }
 
@@ -24052,7 +24014,6 @@ void wlc_phy_cal_perical_nphy_run(phy_info_t *pi, u8 caltype)
                        break;
 
                default:
-                       ASSERT(0);
                        wlc_phy_cal_perical_mphase_reset(pi);
                        break;
                }
@@ -24116,7 +24077,7 @@ wlc_phy_cal_txiqlo_nphy(phy_info_t *pi, nphy_txgains_t target_gain,
        void *tbl_ptr;
        bool ladder_updated[2];
        u8 mphase_cal_lastphase = 0;
-       int bcmerror = BCME_OK;
+       int bcmerror = 0;
        bool phyhang_avoid_state = false;
 
        u16 tbl_tx_iqlo_cal_loft_ladder_20[] = {
@@ -24242,13 +24203,13 @@ wlc_phy_cal_txiqlo_nphy(phy_info_t *pi, nphy_txgains_t target_gain,
 
        if (pi->mphase_cal_phase_id > MPHASE_CAL_STATE_TXPHASE0) {
                wlc_phy_runsamples_nphy(pi, phy_bw * 8, 0xffff, 0, 1, 0, false);
-               bcmerror = BCME_OK;
+               bcmerror = 0;
        } else {
                bcmerror =
                    wlc_phy_tx_tone_nphy(pi, tone_freq, max_val, 1, 0, false);
        }
 
-       if (bcmerror == BCME_OK) {
+       if (bcmerror == 0) {
 
                if (pi->mphase_cal_phase_id > MPHASE_CAL_STATE_TXPHASE0) {
                        tbl_ptr = pi->mphase_txcal_bestcoeffs;
@@ -24361,7 +24322,9 @@ wlc_phy_cal_txiqlo_nphy(phy_info_t *pi, nphy_txgains_t target_gain,
 
                        SPINWAIT(((read_phy_reg(pi, 0xc0) & 0xc000) != 0),
                                 20000);
-                       ASSERT((read_phy_reg(pi, 0xc0) & 0xc000) == 0);
+                       if (WARN(read_phy_reg(pi, 0xc0) & 0xc000,
+                                "HW error: txiq calib"))
+                               return -EIO;
 
                        wlc_phy_table_read_nphy(pi, NPHY_TBL_ID_IQLOCAL,
                                                tbl_len, 96, 16, tbl_buf);
@@ -24468,8 +24431,6 @@ static void wlc_phy_reapply_txcal_coeffs_nphy(phy_info_t *pi)
 {
        u16 tbl_buf[7];
 
-       ASSERT(NREV_LT(pi->pubpi.phy_rev, 2));
-
        if ((pi->nphy_txiqlocal_chanspec == pi->radio_chanspec) &&
            (pi->nphy_txiqlocal_coeffsvalid)) {
                wlc_phy_table_read_nphy(pi, NPHY_TBL_ID_IQLOCAL,
@@ -24544,10 +24505,11 @@ wlc_phy_rx_iq_est_nphy(phy_info_t *pi, phy_iq_est_t *est, u16 num_samps,
 
        SPINWAIT(((read_phy_reg(pi, 0x129) & NPHY_IqestCmd_iqstart) != 0),
                 10000);
-       ASSERT((read_phy_reg(pi, 0x129) & NPHY_IqestCmd_iqstart) == 0);
+       if (WARN(read_phy_reg(pi, 0x129) & NPHY_IqestCmd_iqstart,
+                "HW error: rxiq est"))
+               return;
 
        if ((read_phy_reg(pi, 0x129) & NPHY_IqestCmd_iqstart) == 0) {
-               ASSERT(pi->pubpi.phy_corenum <= PHY_CORE_MAX);
                for (core = 0; core < pi->pubpi.phy_corenum; core++) {
                        est[core].i_pwr =
                            (read_phy_reg(pi, NPHY_IqestipwrAccHi(core)) << 16)
@@ -24572,7 +24534,7 @@ static void wlc_phy_calc_rx_iq_comp_nphy(phy_info_t *pi, u8 core_mask)
        u32 ii = 0, qq = 0;
        s16 iq_nbits, qq_nbits, brsh, arsh;
        s32 a, b, temp;
-       int bcmerror = BCME_OK;
+       int bcmerror = 0;
        uint cal_retry = 0;
 
        if (core_mask == 0x0)
@@ -24602,7 +24564,7 @@ static void wlc_phy_calc_rx_iq_comp_nphy(phy_info_t *pi, u8 core_mask)
                }
 
                if ((ii + qq) < NPHY_MIN_RXIQ_PWR) {
-                       bcmerror = BCME_ERROR;
+                       bcmerror = -EBADE;
                        break;
                }
 
@@ -24614,14 +24576,14 @@ static void wlc_phy_calc_rx_iq_comp_nphy(phy_info_t *pi, u8 core_mask)
                        a = (-(iq << (30 - iq_nbits)) + (ii >> (1 + arsh)));
                        temp = (s32) (ii >> arsh);
                        if (temp == 0) {
-                               bcmerror = BCME_ERROR;
+                               bcmerror = -EBADE;
                                break;
                        }
                } else {
                        a = (-(iq << (30 - iq_nbits)) + (ii << (-1 - arsh)));
                        temp = (s32) (ii << -arsh);
                        if (temp == 0) {
-                               bcmerror = BCME_ERROR;
+                               bcmerror = -EBADE;
                                break;
                        }
                }
@@ -24633,20 +24595,20 @@ static void wlc_phy_calc_rx_iq_comp_nphy(phy_info_t *pi, u8 core_mask)
                        b = (qq << (31 - qq_nbits));
                        temp = (s32) (ii >> brsh);
                        if (temp == 0) {
-                               bcmerror = BCME_ERROR;
+                               bcmerror = -EBADE;
                                break;
                        }
                } else {
                        b = (qq << (31 - qq_nbits));
                        temp = (s32) (ii << -brsh);
                        if (temp == 0) {
-                               bcmerror = BCME_ERROR;
+                               bcmerror = -EBADE;
                                break;
                        }
                }
                b /= temp;
                b -= a * a;
-               b = (s32) wlc_phy_sqrt_int((u32) b);
+               b = (s32) int_sqrt((unsigned long) b);
                b -= (1 << 10);
 
                if ((curr_core == PHY_CORE_0) && (core_mask & 0x1)) {
@@ -24671,7 +24633,7 @@ static void wlc_phy_calc_rx_iq_comp_nphy(phy_info_t *pi, u8 core_mask)
                }
        }
 
-       if (bcmerror != BCME_OK) {
+       if (bcmerror != 0) {
                printk("%s: Failed, cnt = %d\n", __func__, cal_retry);
 
                if (cal_retry < CAL_RETRY_CNT) {
@@ -25451,7 +25413,7 @@ wlc_phy_rxcal_gainctrl_nphy_rev5(phy_info_t *pi, u8 rx_core,
                        break;
 
                default:
-                       ASSERT(0);
+                       break;
                }
 
                if ((curr_gaintbl_index < 0) ||
@@ -25916,7 +25878,7 @@ wlc_phy_cal_rxiq_nphy_rev3(phy_info_t *pi, nphy_txgains_t target_gain,
 
        wlc_phy_stay_in_carriersearch_nphy(pi, false);
 
-       return BCME_OK;
+       return 0;
 }
 
 static int
@@ -25941,7 +25903,7 @@ wlc_phy_cal_rxiq_nphy_rev2(phy_info_t *pi, nphy_txgains_t target_gain,
        u16 cal_gain[2];
        nphy_iqcal_params_t cal_params[2];
        u8 phy_bw;
-       int bcmerror = BCME_OK;
+       int bcmerror = 0;
        bool first_playtone = true;
 
        wlc_phy_stay_in_carriersearch_nphy(pi, true);
@@ -26091,7 +26053,7 @@ wlc_phy_cal_rxiq_nphy_rev2(phy_info_t *pi, nphy_txgains_t target_gain,
                                                        0, 0, 0, true);
                        }
 
-                       if (bcmerror == BCME_OK) {
+                       if (bcmerror == 0) {
                                if (gain_pass < 3) {
 
                                        wlc_phy_rx_iq_est_nphy(pi, est,
@@ -26114,7 +26076,7 @@ wlc_phy_cal_rxiq_nphy_rev2(phy_info_t *pi, nphy_txgains_t target_gain,
                                wlc_phy_stopplayback_nphy(pi);
                        }
 
-                       if (bcmerror != BCME_OK)
+                       if (bcmerror != 0)
                                break;
                }
 
@@ -26130,7 +26092,7 @@ wlc_phy_cal_rxiq_nphy_rev2(phy_info_t *pi, nphy_txgains_t target_gain,
                              0xa7, orig_AfectrlCore);
                write_phy_reg(pi, 0xa2, orig_RfseqCoreActv);
 
-               if (bcmerror != BCME_OK)
+               if (bcmerror != 0)
                        break;
        }
 
@@ -26270,8 +26232,6 @@ static u32 *wlc_phy_get_ipa_gaintbl_nphy(phy_info_t *pi)
 
                                tx_pwrctrl_tbl =
                                    nphy_tpc_txgain_ipa_2g_2057rev7;
-                       } else {
-                               ASSERT(0);
                        }
 
                } else if (NREV_IS(pi->pubpi.phy_rev, 6)) {
@@ -26303,8 +26263,6 @@ static u32 *wlc_phy_get_ipa_gaintbl_nphy(phy_info_t *pi)
 
                                tx_pwrctrl_tbl =
                                    nphy_tpc_txgain_ipa_5g_2057rev7;
-                       } else {
-                               ASSERT(0);
                        }
 
                } else {
@@ -26347,8 +26305,6 @@ wlc_phy_papd_cal_setup_nphy(phy_info_t *pi, nphy_papd_restore_state *state,
                                   || (pi->pubpi.radiorev == 6)) {
 
                                mixgain = 0x00;
-                       } else {
-                               ASSERT(0);
                        }
 
                } else {
@@ -26361,8 +26317,6 @@ wlc_phy_papd_cal_setup_nphy(phy_info_t *pi, nphy_papd_restore_state *state,
                                   || (pi->pubpi.radiorev == 8)) {
 
                                mixgain = 0x0;
-                       } else {
-                               ASSERT(0);
                        }
                }
 
@@ -26464,8 +26418,6 @@ wlc_phy_papd_cal_setup_nphy(phy_info_t *pi, nphy_papd_restore_state *state,
                                WRITE_RADIO_REG3(pi, RADIO_2057, TX, core,
                                                 TXRXCOUPLE_2G_ATTEN, 0xf0);
 
-                       } else {
-                               ASSERT(0);
                        }
 
                        WRITE_RADIO_REG3(pi, RADIO_2057, TX, off_core,
@@ -26724,8 +26676,6 @@ wlc_phy_a1_nphy(phy_info_t *pi, u8 core, u32 winsz, u32 start,
        u32 *buf, *src, *dst, sz;
 
        sz = end - start + 1;
-       ASSERT(end > start);
-       ASSERT(end < NPHY_PAPD_EPS_TBL_SIZE);
 
        buf = kmalloc(2 * sizeof(u32) * NPHY_PAPD_EPS_TBL_SIZE, GFP_ATOMIC);
        if (NULL == buf) {
@@ -26787,8 +26737,6 @@ wlc_phy_a2_nphy(phy_info_t *pi, nphy_ipa_txcalgains_t *txgains,
 
        phy_a7 = (core == PHY_CORE_0) ? 1 : 0;
 
-       ASSERT((cal_mode == CAL_FULL) || (cal_mode == CAL_GCTRL)
-              || (cal_mode == CAL_SOFT));
        phy_a6 = ((cal_mode == CAL_GCTRL)
                  || (cal_mode == CAL_SOFT)) ? true : false;
 
@@ -27333,8 +27281,6 @@ static void wlc_phy_a4(phy_info_t *pi, bool full_cal)
                                                            nphy_papd_cal_gain_index
                                                            [phy_b5], phy_b5);
 
-                               } else {
-                                       ASSERT(0);
                                }
 
                                phy_b1[phy_b5].gains.pad[phy_b5] =
@@ -27417,8 +27363,6 @@ static void wlc_phy_a4(phy_info_t *pi, bool full_cal)
                                            -(nphy_papd_padgain_dlt_2g_2057rev7
                                              [phy_b8]
                                              + 1) / 2;
-                               } else {
-                                       ASSERT(0);
                                }
                        } else {
                                phy_b7 = phy_b1[phy_b5].gains.pga[phy_b5];
@@ -27435,8 +27379,6 @@ static void wlc_phy_a4(phy_info_t *pi, bool full_cal)
                                            -(nphy_papd_pgagain_dlt_5g_2057rev7
                                              [phy_b7]
                                              + 1) / 2;
-                               } else {
-                                       ASSERT(0);
                                }
 
                                phy_b10 = -9;
@@ -27536,8 +27478,6 @@ void wlc_phy_txpwr_fixpower_nphy(phy_info_t *pi)
        u8 txpi[2], chan_freq_range;
        s32 rfpwr_offset;
 
-       ASSERT(pi->nphy_txpwrctrl == PHY_TPC_HW_OFF);
-
        if (pi->phyhang_avoid)
                wlc_phy_stay_in_carriersearch_nphy(pi, true);
 
@@ -29179,7 +29119,6 @@ wlc_phy_txpower_sromlimit_get_nphy(phy_info_t *pi, uint chan, u8 *max_pwr,
                *max_pwr = pi->tx_srom_max_rate_5g_hi[txp_rate_idx];
                break;
        default:
-               ASSERT(0);
                *max_pwr = pi->tx_srom_max_rate_2g[txp_rate_idx];
                break;
        }
@@ -29191,8 +29130,6 @@ void wlc_phy_stay_in_carriersearch_nphy(phy_info_t *pi, bool enable)
 {
        u16 clip_off[] = { 0xffff, 0xffff };
 
-       ASSERT(0 == (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC));
-
        if (enable) {
                if (pi->nphy_deaf_count == 0) {
                        pi->classifier_state =
@@ -29207,8 +29144,6 @@ void wlc_phy_stay_in_carriersearch_nphy(phy_info_t *pi, bool enable)
                wlc_phy_resetcca_nphy(pi);
 
        } else {
-               ASSERT(pi->nphy_deaf_count > 0);
-
                pi->nphy_deaf_count--;
 
                if (pi->nphy_deaf_count == 0) {
diff --git a/drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_qmath.c b/drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_qmath.c
new file mode 100644 (file)
index 0000000..c98176f
--- /dev/null
@@ -0,0 +1,296 @@
+/*
+ * Copyright (c) 2010 Broadcom Corporation
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <linux/types.h>
+
+#include "wlc_phy_qmath.h"
+
+/*
+Description: This function make 16 bit unsigned multiplication. To fit the output into
+16 bits the 32 bit multiplication result is right shifted by 16 bits.
+*/
+u16 qm_mulu16(u16 op1, u16 op2)
+{
+       return (u16) (((u32) op1 * (u32) op2) >> 16);
+}
+
+/*
+Description: This function make 16 bit multiplication and return the result in 16 bits.
+To fit the multiplication result into 16 bits the multiplication result is right shifted by
+15 bits. Right shifting 15 bits instead of 16 bits is done to remove the extra sign bit formed
+due to the multiplication.
+When both the 16bit inputs are 0x8000 then the output is saturated to 0x7fffffff.
+*/
+s16 qm_muls16(s16 op1, s16 op2)
+{
+       s32 result;
+       if (op1 == (s16) 0x8000 && op2 == (s16) 0x8000) {
+               result = 0x7fffffff;
+       } else {
+               result = ((s32) (op1) * (s32) (op2));
+       }
+       return (s16) (result >> 15);
+}
+
+/*
+Description: This function add two 32 bit numbers and return the 32bit result.
+If the result overflow 32 bits, the output will be saturated to 32bits.
+*/
+s32 qm_add32(s32 op1, s32 op2)
+{
+       s32 result;
+       result = op1 + op2;
+       if (op1 < 0 && op2 < 0 && result > 0) {
+               result = 0x80000000;
+       } else if (op1 > 0 && op2 > 0 && result < 0) {
+               result = 0x7fffffff;
+       }
+       return result;
+}
+
+/*
+Description: This function add two 16 bit numbers and return the 16bit result.
+If the result overflow 16 bits, the output will be saturated to 16bits.
+*/
+s16 qm_add16(s16 op1, s16 op2)
+{
+       s16 result;
+       s32 temp = (s32) op1 + (s32) op2;
+       if (temp > (s32) 0x7fff) {
+               result = (s16) 0x7fff;
+       } else if (temp < (s32) 0xffff8000) {
+               result = (s16) 0xffff8000;
+       } else {
+               result = (s16) temp;
+       }
+       return result;
+}
+
+/*
+Description: This function make 16 bit subtraction and return the 16bit result.
+If the result overflow 16 bits, the output will be saturated to 16bits.
+*/
+s16 qm_sub16(s16 op1, s16 op2)
+{
+       s16 result;
+       s32 temp = (s32) op1 - (s32) op2;
+       if (temp > (s32) 0x7fff) {
+               result = (s16) 0x7fff;
+       } else if (temp < (s32) 0xffff8000) {
+               result = (s16) 0xffff8000;
+       } else {
+               result = (s16) temp;
+       }
+       return result;
+}
+
+/*
+Description: This function make a 32 bit saturated left shift when the specified shift
+is +ve. This function will make a 32 bit right shift when the specified shift is -ve.
+This function return the result after shifting operation.
+*/
+s32 qm_shl32(s32 op, int shift)
+{
+       int i;
+       s32 result;
+       result = op;
+       if (shift > 31)
+               shift = 31;
+       else if (shift < -31)
+               shift = -31;
+       if (shift >= 0) {
+               for (i = 0; i < shift; i++) {
+                       result = qm_add32(result, result);
+               }
+       } else {
+               result = result >> (-shift);
+       }
+       return result;
+}
+
+/*
+Description: This function make a 16 bit saturated left shift when the specified shift
+is +ve. This function will make a 16 bit right shift when the specified shift is -ve.
+This function return the result after shifting operation.
+*/
+s16 qm_shl16(s16 op, int shift)
+{
+       int i;
+       s16 result;
+       result = op;
+       if (shift > 15)
+               shift = 15;
+       else if (shift < -15)
+               shift = -15;
+       if (shift > 0) {
+               for (i = 0; i < shift; i++) {
+                       result = qm_add16(result, result);
+               }
+       } else {
+               result = result >> (-shift);
+       }
+       return result;
+}
+
+/*
+Description: This function make a 16 bit right shift when shift is +ve.
+This function make a 16 bit saturated left shift when shift is -ve. This function
+return the result of the shift operation.
+*/
+s16 qm_shr16(s16 op, int shift)
+{
+       return qm_shl16(op, -shift);
+}
+
+/*
+Description: This function return the number of redundant sign bits in a 32 bit number.
+Example: qm_norm32(0x00000080) = 23
+*/
+s16 qm_norm32(s32 op)
+{
+       u16 u16extraSignBits;
+       if (op == 0) {
+               return 31;
+       } else {
+               u16extraSignBits = 0;
+               while ((op >> 31) == (op >> 30)) {
+                       u16extraSignBits++;
+                       op = op << 1;
+               }
+       }
+       return u16extraSignBits;
+}
+
+/* This table is log2(1+(i/32)) where i=[0:1:31], in q.15 format */
+static const s16 log_table[] = {
+       0,
+       1455,
+       2866,
+       4236,
+       5568,
+       6863,
+       8124,
+       9352,
+       10549,
+       11716,
+       12855,
+       13968,
+       15055,
+       16117,
+       17156,
+       18173,
+       19168,
+       20143,
+       21098,
+       22034,
+       22952,
+       23852,
+       24736,
+       25604,
+       26455,
+       27292,
+       28114,
+       28922,
+       29717,
+       30498,
+       31267,
+       32024
+};
+
+#define LOG_TABLE_SIZE 32      /* log_table size */
+#define LOG2_LOG_TABLE_SIZE 5  /* log2(log_table size) */
+#define Q_LOG_TABLE 15         /* qformat of log_table */
+#define LOG10_2                19728   /* log10(2) in q.16 */
+
+/*
+Description:
+This routine takes the input number N and its q format qN and compute
+the log10(N). This routine first normalizes the input no N.    Then N is in mag*(2^x) format.
+mag is any number in the range 2^30-(2^31 - 1). Then log2(mag * 2^x) = log2(mag) + x is computed.
+From that log10(mag * 2^x) = log2(mag * 2^x) * log10(2) is computed.
+This routine looks the log2 value in the table considering LOG2_LOG_TABLE_SIZE+1 MSBs.
+As the MSB is always 1, only next LOG2_OF_LOG_TABLE_SIZE MSBs are used for table lookup.
+Next 16 MSBs are used for interpolation.
+Inputs:
+N - number to which log10 has to be found.
+qN - q format of N
+log10N - address where log10(N) will be written.
+qLog10N - address where log10N qformat will be written.
+Note/Problem:
+For accurate results input should be in normalized or near normalized form.
+*/
+void qm_log10(s32 N, s16 qN, s16 *log10N, s16 *qLog10N)
+{
+       s16 s16norm, s16tableIndex, s16errorApproximation;
+       u16 u16offset;
+       s32 s32log;
+
+       /* normalize the N. */
+       s16norm = qm_norm32(N);
+       N = N << s16norm;
+
+       /* The qformat of N after normalization.
+        * -30 is added to treat the no as between 1.0 to 2.0
+        * i.e. after adding the -30 to the qformat the decimal point will be
+        * just rigtht of the MSB. (i.e. after sign bit and 1st MSB). i.e.
+        * at the right side of 30th bit.
+        */
+       qN = qN + s16norm - 30;
+
+       /* take the table index as the LOG2_OF_LOG_TABLE_SIZE bits right of the MSB */
+       s16tableIndex = (s16) (N >> (32 - (2 + LOG2_LOG_TABLE_SIZE)));
+
+       /* remove the MSB. the MSB is always 1 after normalization. */
+       s16tableIndex =
+           s16tableIndex & (s16) ((1 << LOG2_LOG_TABLE_SIZE) - 1);
+
+       /* remove the (1+LOG2_OF_LOG_TABLE_SIZE) MSBs in the N. */
+       N = N & ((1 << (32 - (2 + LOG2_LOG_TABLE_SIZE))) - 1);
+
+       /* take the offset as the 16 MSBS after table index.
+        */
+       u16offset = (u16) (N >> (32 - (2 + LOG2_LOG_TABLE_SIZE + 16)));
+
+       /* look the log value in the table. */
+       s32log = log_table[s16tableIndex];      /* q.15 format */
+
+       /* interpolate using the offset. */
+       s16errorApproximation = (s16) qm_mulu16(u16offset, (u16) (log_table[s16tableIndex + 1] - log_table[s16tableIndex]));    /* q.15 */
+
+       s32log = qm_add16((s16) s32log, s16errorApproximation); /* q.15 format */
+
+       /* adjust for the qformat of the N as
+        * log2(mag * 2^x) = log2(mag) + x
+        */
+       s32log = qm_add32(s32log, ((s32) -qN) << 15);   /* q.15 format */
+
+       /* normalize the result. */
+       s16norm = qm_norm32(s32log);
+
+       /* bring all the important bits into lower 16 bits */
+       s32log = qm_shl32(s32log, s16norm - 16);        /* q.15+s16norm-16 format */
+
+       /* compute the log10(N) by multiplying log2(N) with log10(2).
+        * as log10(mag * 2^x) = log2(mag * 2^x) * log10(2)
+        * log10N in q.15+s16norm-16+1 (LOG10_2 is in q.16)
+        */
+       *log10N = qm_muls16((s16) s32log, (s16) LOG10_2);
+
+       /* write the q format of the result. */
+       *qLog10N = 15 + s16norm - 16 + 1;
+
+       return;
+}
similarity index 63%
rename from drivers/staging/brcm80211/include/qmath.h
rename to drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_qmath.h
index 5f525dbcd46e9a75f7e99bd0ba4d707fbc8ec33e..3dcee1c4aa654486e8c5095d4785015d2fdf0724 100644 (file)
 #ifndef __QMATH_H__
 #define __QMATH_H__
 
-s16 qm_sat32(s32 op);
-
-s32 qm_mul321616(s16 op1, s16 op2);
-
-s16 qm_mul16(s16 op1, s16 op2);
-
-s32 qm_muls321616(s16 op1, s16 op2);
-
 u16 qm_mulu16(u16 op1, u16 op2);
 
 s16 qm_muls16(s16 op1, s16 op2);
@@ -35,44 +27,14 @@ s16 qm_add16(s16 op1, s16 op2);
 
 s16 qm_sub16(s16 op1, s16 op2);
 
-s32 qm_sub32(s32 op1, s32 op2);
-
-s32 qm_mac321616(s32 acc, s16 op1, s16 op2);
-
 s32 qm_shl32(s32 op, int shift);
 
-s32 qm_shr32(s32 op, int shift);
-
 s16 qm_shl16(s16 op, int shift);
 
 s16 qm_shr16(s16 op, int shift);
 
-s16 qm_norm16(s16 op);
-
 s16 qm_norm32(s32 op);
 
-s16 qm_div_s(s16 num, s16 denom);
-
-s16 qm_abs16(s16 op);
-
-s16 qm_div16(s16 num, s16 denom, s16 *qQuotient);
-
-s32 qm_abs32(s32 op);
-
-s16 qm_div163232(s32 num, s32 denom, s16 *qquotient);
-
-s32 qm_mul323216(s32 op1, s16 op2);
-
-s32 qm_mulsu321616(s16 op1, u16 op2);
-
-s32 qm_muls323216(s32 op1, s16 op2);
-
-s32 qm_mul32(s32 a, s32 b);
-
-s32 qm_muls32(s32 a, s32 b);
-
 void qm_log10(s32 N, s16 qN, s16 *log10N, s16 *qLog10N);
 
-void qm_1byN(s32 N, s16 qN, s32 *result, s16 *qResult);
-
 #endif                         /* #ifndef __QMATH_H__ */
index 54af257598c2cf34312b6df91c64987b2114b5d1..5582de3ee721a953e09e1ef29604a6205a5aa9d4 100644 (file)
 #ifndef _wl_dbg_h_
 #define _wl_dbg_h_
 
+#include <linux/device.h>                      /* dev_err() */
+
 /* wl_msg_level is a bit vector with defs in wlioctl.h */
 extern u32 wl_msg_level;
 
-#define WL_NONE(fmt, args...) no_printk(fmt, ##args)
-
-#define WL_PRINT(level, fmt, args...)          \
+#define BCMMSG(dev, fmt, args...)              \
 do {                                           \
-       if (wl_msg_level & level)               \
-               printk(fmt, ##args);            \
+       if (wl_msg_level & WL_TRACE_VAL)        \
+               wiphy_err(dev, "%s: " fmt, __func__, ##args);   \
 } while (0)
 
 #ifdef BCMDBG
 
-#define        WL_ERROR(fmt, args...)  WL_PRINT(WL_ERROR_VAL, fmt, ##args)
-#define        WL_TRACE(fmt, args...)  WL_PRINT(WL_TRACE_VAL, fmt, ##args)
-#define WL_AMPDU(fmt, args...) WL_PRINT(WL_AMPDU_VAL, fmt, ##args)
-#define WL_FFPLD(fmt, args...) WL_PRINT(WL_FFPLD_VAL, fmt, ##args)
-
-#define WL_ERROR_ON()          (wl_msg_level & WL_ERROR_VAL)
 
 /* Extra message control for AMPDU debugging */
 #define   WL_AMPDU_UPDN_VAL    0x00000001      /* Config up/down related  */
@@ -78,12 +72,6 @@ do {                                         \
 
 #else                          /* BCMDBG */
 
-#define        WL_ERROR(fmt, args...)          no_printk(fmt, ##args)
-#define        WL_TRACE(fmt, args...)          no_printk(fmt, ##args)
-#define WL_AMPDU(fmt, args...)         no_printk(fmt, ##args)
-#define WL_FFPLD(fmt, args...)         no_printk(fmt, ##args)
-
-#define WL_ERROR_ON()          0
 
 #define WL_AMPDU_UPDN(fmt, args...)    no_printk(fmt, ##args)
 #define WL_AMPDU_RX(fmt, args...)      no_printk(fmt, ##args)
@@ -99,4 +87,6 @@ do {                                          \
 
 #endif                         /* BCMDBG */
 
+#define WL_ERROR_ON()          (wl_msg_level & WL_ERROR_VAL)
+
 #endif                         /* _wl_dbg_h_ */
index 9ff760f4c8655293610c3351f17553bab0443d8f..0fe0b24b586f538e8a3a3ba4ae90b170afb93499 100644 (file)
@@ -42,5 +42,6 @@ extern void wl_free_timer(struct wl_info *wl, struct wl_timer *timer);
 extern void wl_add_timer(struct wl_info *wl, struct wl_timer *timer, uint ms,
                         int periodic);
 extern bool wl_del_timer(struct wl_info *wl, struct wl_timer *timer);
+extern void wl_msleep(struct wl_info *wl, uint ms);
 
 #endif                         /* _wl_export_h_ */
index c1b07ae316746f384edd65d5f18d1bc578a271a8..6c6236c969b707d26189458364cd91f7cf3b9f01 100644 (file)
@@ -30,6 +30,7 @@
 #include <bcmdefs.h>
 #include <bcmwifi.h>
 #include <bcmutils.h>
+#include <bcmnvram.h>
 #include <pcicfg.h>
 #include <wlioctl.h>
 #include <sbhnddma.h>
@@ -48,6 +49,8 @@
 #include "wl_ucode.h"
 #include "wl_mac80211.h"
 
+#define N_TX_QUEUES    4 /* #tx queues on mac80211<->driver interface */
+
 static void wl_timer(unsigned long data);
 static void _wl_timer(struct wl_timer *t);
 
@@ -81,6 +84,7 @@ static int __devinit wl_pci_probe(struct pci_dev *pdev,
                                  const struct pci_device_id *ent);
 static void wl_remove(struct pci_dev *pdev);
 static void wl_free(struct wl_info *wl);
+static void wl_set_basic_rate(struct wl_rateset *rs, u16 rate, bool is_br);
 
 MODULE_AUTHOR("Broadcom Corporation");
 MODULE_DESCRIPTION("Broadcom 802.11n wireless LAN driver.");
@@ -129,7 +133,6 @@ static void wl_ops_sw_scan_complete(struct ieee80211_hw *hw);
 static void wl_ops_set_tsf(struct ieee80211_hw *hw, u64 tsf);
 static int wl_ops_get_stats(struct ieee80211_hw *hw,
                            struct ieee80211_low_level_stats *stats);
-static int wl_ops_set_rts_threshold(struct ieee80211_hw *hw, u32 value);
 static void wl_ops_sta_notify(struct ieee80211_hw *hw,
                              struct ieee80211_vif *vif,
                              enum sta_notify_cmd cmd,
@@ -147,6 +150,7 @@ static int wl_ops_ampdu_action(struct ieee80211_hw *hw,
                               struct ieee80211_sta *sta, u16 tid, u16 *ssn,
                               u8 buf_size);
 static void wl_ops_rfkill_poll(struct ieee80211_hw *hw);
+static void wl_ops_flush(struct ieee80211_hw *hw, bool drop);
 
 static void wl_ops_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
 {
@@ -154,7 +158,7 @@ static void wl_ops_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
 
        WL_LOCK(wl);
        if (!wl->pub->up) {
-               WL_ERROR("ops->tx called while down\n");
+               wiphy_err(wl->wiphy, "ops->tx called while down\n");
                kfree_skb(skb);
                goto done;
        }
@@ -169,7 +173,6 @@ static int wl_ops_start(struct ieee80211_hw *hw)
        bool blocked;
        /*
          struct ieee80211_channel *curchan = hw->conf.channel;
-         WL_NONE("%s : Initial channel: %d\n", __func__, curchan->hw_value);
        */
 
        ieee80211_wake_queues(hw);
@@ -184,10 +187,6 @@ static int wl_ops_start(struct ieee80211_hw *hw)
 
 static void wl_ops_stop(struct ieee80211_hw *hw)
 {
-#ifdef BRCMDBG
-       struct wl_info *wl = hw->priv;
-       ASSERT(wl);
-#endif /*BRCMDBG*/
        ieee80211_stop_queues(hw);
 }
 
@@ -203,8 +202,8 @@ wl_ops_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
            vif->type != NL80211_IFTYPE_STATION &&
            vif->type != NL80211_IFTYPE_WDS &&
            vif->type != NL80211_IFTYPE_ADHOC) {
-               WL_ERROR("%s: Attempt to add type %d, only STA for now\n",
-                        __func__, vif->type);
+               wiphy_err(hw->wiphy, "%s: Attempt to add type %d, only"
+                         " STA for now\n", __func__, vif->type);
                return -EOPNOTSUPP;
        }
 
@@ -214,7 +213,8 @@ wl_ops_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
        WL_UNLOCK(wl);
 
        if (err != 0) {
-               WL_ERROR("%s: wl_up() returned %d\n", __func__, err);
+               wiphy_err(hw->wiphy, "%s: wl_up() returned %d\n", __func__,
+                         err);
        }
        return err;
 }
@@ -249,7 +249,8 @@ ieee_set_channel(struct ieee80211_hw *hw, struct ieee80211_channel *chan,
                break;
        case NL80211_CHAN_HT40MINUS:
        case NL80211_CHAN_HT40PLUS:
-               WL_ERROR("%s: Need to implement 40 Mhz Channels!\n", __func__);
+               wiphy_err(hw->wiphy,
+                         "%s: Need to implement 40 Mhz Channels!\n", __func__);
                err = 1;
                break;
        }
@@ -265,39 +266,41 @@ static int wl_ops_config(struct ieee80211_hw *hw, u32 changed)
        struct wl_info *wl = HW_TO_WL(hw);
        int err = 0;
        int new_int;
+       struct wiphy *wiphy = hw->wiphy;
 
        WL_LOCK(wl);
        if (changed & IEEE80211_CONF_CHANGE_LISTEN_INTERVAL) {
                if (wlc_iovar_setint
                    (wl->wlc, "bcn_li_bcn", conf->listen_interval)) {
-                       WL_ERROR("%s: Error setting listen_interval\n",
-                                __func__);
+                       wiphy_err(wiphy, "%s: Error setting listen_interval\n",
+                                 __func__);
                        err = -EIO;
                        goto config_out;
                }
                wlc_iovar_getint(wl->wlc, "bcn_li_bcn", &new_int);
-               ASSERT(new_int == conf->listen_interval);
        }
        if (changed & IEEE80211_CONF_CHANGE_MONITOR)
-               WL_ERROR("%s: change monitor mode: %s (implement)\n", __func__,
-                        conf->flags & IEEE80211_CONF_MONITOR ?
-                               "true" : "false");
+               wiphy_err(wiphy, "%s: change monitor mode: %s (implement)\n",
+                         __func__, conf->flags & IEEE80211_CONF_MONITOR ?
+                         "true" : "false");
        if (changed & IEEE80211_CONF_CHANGE_PS)
-               WL_ERROR("%s: change power-save mode: %s (implement)\n",
-                        __func__, conf->flags & IEEE80211_CONF_PS ?
-                               "true" : "false");
+               wiphy_err(wiphy, "%s: change power-save mode: %s (implement)\n",
+                         __func__, conf->flags & IEEE80211_CONF_PS ?
+                         "true" : "false");
 
        if (changed & IEEE80211_CONF_CHANGE_POWER) {
                if (wlc_iovar_setint
                    (wl->wlc, "qtxpower", conf->power_level * 4)) {
-                       WL_ERROR("%s: Error setting power_level\n", __func__);
+                       wiphy_err(wiphy, "%s: Error setting power_level\n",
+                                 __func__);
                        err = -EIO;
                        goto config_out;
                }
                wlc_iovar_getint(wl->wlc, "qtxpower", &new_int);
                if (new_int != (conf->power_level * 4))
-                       WL_ERROR("%s: Power level req != actual, %d %d\n",
-                                __func__, conf->power_level * 4, new_int);
+                       wiphy_err(wiphy, "%s: Power level req != actual, %d %d"
+                                 "\n", __func__, conf->power_level * 4,
+                                 new_int);
        }
        if (changed & IEEE80211_CONF_CHANGE_CHANNEL) {
                err = ieee_set_channel(hw, conf->channel, conf->channel_type);
@@ -306,13 +309,13 @@ static int wl_ops_config(struct ieee80211_hw *hw, u32 changed)
                if (wlc_set
                    (wl->wlc, WLC_SET_SRL,
                     conf->short_frame_max_tx_count) < 0) {
-                       WL_ERROR("%s: Error setting srl\n", __func__);
+                       wiphy_err(wiphy, "%s: Error setting srl\n", __func__);
                        err = -EIO;
                        goto config_out;
                }
                if (wlc_set(wl->wlc, WLC_SET_LRL, conf->long_frame_max_tx_count)
                    < 0) {
-                       WL_ERROR("%s: Error setting lrl\n", __func__);
+                       wiphy_err(wiphy, "%s: Error setting lrl\n", __func__);
                        err = -EIO;
                        goto config_out;
                }
@@ -329,25 +332,18 @@ wl_ops_bss_info_changed(struct ieee80211_hw *hw,
                        struct ieee80211_bss_conf *info, u32 changed)
 {
        struct wl_info *wl = HW_TO_WL(hw);
+       struct wiphy *wiphy = hw->wiphy;
        int val;
 
        if (changed & BSS_CHANGED_ASSOC) {
                /* association status changed (associated/disassociated)
                 * also implies a change in the AID.
                 */
-               WL_ERROR("%s: %s: %sassociated\n", KBUILD_MODNAME, __func__,
-                        info->assoc ? "" : "dis");
+               wiphy_err(wiphy, "%s: %s: %sassociated\n", KBUILD_MODNAME,
+                         __func__, info->assoc ? "" : "dis");
+               WL_LOCK(wl);
                wlc_associate_upd(wl->wlc, info->assoc);
-       }
-       if (changed & BSS_CHANGED_ERP_CTS_PROT) {
-               /* CTS protection changed */
-               WL_ERROR("%s: use_cts_prot: %s (implement)\n", __func__,
-                       info->use_cts_prot ? "true" : "false");
-       }
-       if (changed & BSS_CHANGED_ERP_PREAMBLE) {
-               /* preamble changed */
-               WL_ERROR("%s: short preamble: %s (implement)\n", __func__,
-                       info->use_short_preamble ? "true" : "false");
+               WL_UNLOCK(wl);
        }
        if (changed & BSS_CHANGED_ERP_SLOT) {
                /* slot timing changed */
@@ -363,29 +359,57 @@ wl_ops_bss_info_changed(struct ieee80211_hw *hw,
        if (changed & BSS_CHANGED_HT) {
                /* 802.11n parameters changed */
                u16 mode = info->ht_operation_mode;
-               WL_NONE("%s: HT mode: 0x%04X\n", __func__, mode);
+
+               WL_LOCK(wl);
                wlc_protection_upd(wl->wlc, WLC_PROT_N_CFG,
                        mode & IEEE80211_HT_OP_MODE_PROTECTION);
                wlc_protection_upd(wl->wlc, WLC_PROT_N_NONGF,
                        mode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT);
                wlc_protection_upd(wl->wlc, WLC_PROT_N_OBSS,
                        mode & IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT);
+               WL_UNLOCK(wl);
        }
        if (changed & BSS_CHANGED_BASIC_RATES) {
-               /* Basic rateset changed */
-               WL_ERROR("%s: Need to change Basic Rates: 0x%x (implement)\n",
-                        __func__, (u32) info->basic_rates);
+               struct ieee80211_supported_band *bi;
+               u32 br_mask, i;
+               u16 rate;
+               struct wl_rateset rs;
+               int error;
+
+               /* retrieve the current rates */
+               WL_LOCK(wl);
+               error = wlc_ioctl(wl->wlc, WLC_GET_CURR_RATESET,
+                                 &rs, sizeof(rs), NULL);
+               WL_UNLOCK(wl);
+               if (error) {
+                       wiphy_err(wiphy, "%s: retrieve rateset failed: %d\n",
+                                 __func__, error);
+                       return;
+               }
+               br_mask = info->basic_rates;
+               bi = hw->wiphy->bands[wlc_get_curband(wl->wlc)];
+               for (i = 0; i < bi->n_bitrates; i++) {
+                       /* convert to internal rate value */
+                       rate = (bi->bitrates[i].bitrate << 1) / 10;
+
+                       /* set/clear basic rate flag */
+                       wl_set_basic_rate(&rs, rate, br_mask & 1);
+                       br_mask >>= 1;
+               }
+
+               /* update the rate set */
+               WL_LOCK(wl);
+               wlc_ioctl(wl->wlc, WLC_SET_RATESET, &rs, sizeof(rs), NULL);
+               WL_UNLOCK(wl);
        }
        if (changed & BSS_CHANGED_BEACON_INT) {
                /* Beacon interval changed */
-               WL_NONE("%s: Beacon Interval: %d\n",
-                       __func__, info->beacon_int);
+               WL_LOCK(wl);
                wlc_set(wl->wlc, WLC_SET_BCNPRD, info->beacon_int);
+               WL_UNLOCK(wl);
        }
        if (changed & BSS_CHANGED_BSSID) {
                /* BSSID changed, for whatever reason (IBSS and managed mode) */
-               WL_NONE("%s: new BSSID: aid %d  bss:%pM\n", __func__,
-                       info->aid, info->bssid);
                WL_LOCK(wl);
                wlc_set_addrmatch(wl->wlc, RCM_BSSID_OFFSET,
                                  info->bssid);
@@ -393,41 +417,42 @@ wl_ops_bss_info_changed(struct ieee80211_hw *hw,
        }
        if (changed & BSS_CHANGED_BEACON) {
                /* Beacon data changed, retrieve new beacon (beaconing modes) */
-               WL_ERROR("%s: beacon changed\n", __func__);
+               wiphy_err(wiphy, "%s: beacon changed\n", __func__);
        }
        if (changed & BSS_CHANGED_BEACON_ENABLED) {
                /* Beaconing should be enabled/disabled (beaconing modes) */
-               WL_ERROR("%s: Beacon enabled: %s\n", __func__,
-                        info->enable_beacon ? "true" : "false");
+               wiphy_err(wiphy, "%s: Beacon enabled: %s\n", __func__,
+                         info->enable_beacon ? "true" : "false");
        }
        if (changed & BSS_CHANGED_CQM) {
                /* Connection quality monitor config changed */
-               WL_ERROR("%s: cqm change: threshold %d, hys %d (implement)\n",
-                       __func__, info->cqm_rssi_thold, info->cqm_rssi_hyst);
+               wiphy_err(wiphy, "%s: cqm change: threshold %d, hys %d "
+                         " (implement)\n", __func__, info->cqm_rssi_thold,
+                         info->cqm_rssi_hyst);
        }
        if (changed & BSS_CHANGED_IBSS) {
                /* IBSS join status changed */
-               WL_ERROR("%s: IBSS joined: %s (implement)\n", __func__,
-                       info->ibss_joined ? "true" : "false");
+               wiphy_err(wiphy, "%s: IBSS joined: %s (implement)\n", __func__,
+                         info->ibss_joined ? "true" : "false");
        }
        if (changed & BSS_CHANGED_ARP_FILTER) {
                /* Hardware ARP filter address list or state changed */
-               WL_ERROR("%s: arp filtering: enabled %s, count %d (implement)\n",
-                       __func__, info->arp_filter_enabled ? "true" : "false",
-                       info->arp_addr_cnt);
+               wiphy_err(wiphy, "%s: arp filtering: enabled %s, count %d"
+                         " (implement)\n", __func__, info->arp_filter_enabled ?
+                         "true" : "false", info->arp_addr_cnt);
        }
        if (changed & BSS_CHANGED_QOS) {
                /*
                 * QoS for this association was enabled/disabled.
                 * Note that it is only ever disabled for station mode.
                 */
-               WL_ERROR("%s: qos enabled: %s (implement)\n", __func__,
-                       info->qos ? "true" : "false");
+               wiphy_err(wiphy, "%s: qos enabled: %s (implement)\n", __func__,
+                         info->qos ? "true" : "false");
        }
        if (changed & BSS_CHANGED_IDLE) {
                /* Idle changed for this BSS/interface */
-               WL_ERROR("%s: BSS idle: %s (implement)\n", __func__,
-                       info->idle ? "true" : "false");
+               wiphy_err(wiphy, "%s: BSS idle: %s (implement)\n", __func__,
+                         info->idle ? "true" : "false");
        }
        return;
 }
@@ -438,23 +463,23 @@ wl_ops_configure_filter(struct ieee80211_hw *hw,
                        unsigned int *total_flags, u64 multicast)
 {
        struct wl_info *wl = hw->priv;
+       struct wiphy *wiphy = hw->wiphy;
 
        changed_flags &= MAC_FILTERS;
        *total_flags &= MAC_FILTERS;
        if (changed_flags & FIF_PROMISC_IN_BSS)
-               WL_ERROR("FIF_PROMISC_IN_BSS\n");
+               wiphy_err(wiphy, "FIF_PROMISC_IN_BSS\n");
        if (changed_flags & FIF_ALLMULTI)
-               WL_ERROR("FIF_ALLMULTI\n");
+               wiphy_err(wiphy, "FIF_ALLMULTI\n");
        if (changed_flags & FIF_FCSFAIL)
-               WL_ERROR("FIF_FCSFAIL\n");
+               wiphy_err(wiphy, "FIF_FCSFAIL\n");
        if (changed_flags & FIF_PLCPFAIL)
-               WL_ERROR("FIF_PLCPFAIL\n");
+               wiphy_err(wiphy, "FIF_PLCPFAIL\n");
        if (changed_flags & FIF_CONTROL)
-               WL_ERROR("FIF_CONTROL\n");
+               wiphy_err(wiphy, "FIF_CONTROL\n");
        if (changed_flags & FIF_OTHER_BSS)
-               WL_ERROR("FIF_OTHER_BSS\n");
+               wiphy_err(wiphy, "FIF_OTHER_BSS\n");
        if (changed_flags & FIF_BCN_PRBRESP_PROMISC) {
-               WL_NONE("FIF_BCN_PRBRESP_PROMISC\n");
                WL_LOCK(wl);
                if (*total_flags & FIF_BCN_PRBRESP_PROMISC) {
                        wl->pub->mac80211_state |= MAC80211_PROMISC_BCNS;
@@ -471,14 +496,12 @@ wl_ops_configure_filter(struct ieee80211_hw *hw,
 static int
 wl_ops_set_tim(struct ieee80211_hw *hw, struct ieee80211_sta *sta, bool set)
 {
-       WL_NONE("%s: Enter\n", __func__);
        return 0;
 }
 
 static void wl_ops_sw_scan_start(struct ieee80211_hw *hw)
 {
        struct wl_info *wl = hw->priv;
-       WL_NONE("Scan Start\n");
        WL_LOCK(wl);
        wlc_scan_start(wl->wlc);
        WL_UNLOCK(wl);
@@ -488,7 +511,6 @@ static void wl_ops_sw_scan_start(struct ieee80211_hw *hw)
 static void wl_ops_sw_scan_complete(struct ieee80211_hw *hw)
 {
        struct wl_info *wl = hw->priv;
-       WL_NONE("Scan Complete\n");
        WL_LOCK(wl);
        wlc_scan_stop(wl->wlc);
        WL_UNLOCK(wl);
@@ -497,7 +519,7 @@ static void wl_ops_sw_scan_complete(struct ieee80211_hw *hw)
 
 static void wl_ops_set_tsf(struct ieee80211_hw *hw, u64 tsf)
 {
-       WL_ERROR("%s: Enter\n", __func__);
+       wiphy_err(hw->wiphy, "%s: Enter\n", __func__);
        return;
 }
 
@@ -510,20 +532,10 @@ wl_ops_get_stats(struct ieee80211_hw *hw,
 
        WL_LOCK(wl);
        cnt = wl->pub->_cnt;
-       stats->dot11ACKFailureCount = cnt->txnoack;
-       stats->dot11RTSFailureCount = cnt->txnocts;
-       stats->dot11FCSErrorCount = cnt->rxcrc;
-       stats->dot11RTSSuccessCount = cnt->txrts;
-       WL_UNLOCK(wl);
-       return 0;
-}
-
-static int wl_ops_set_rts_threshold(struct ieee80211_hw *hw, u32 value)
-{
-       struct wl_info *wl = hw->priv;
-
-       WL_LOCK(wl);
-       wlc_iovar_setint(wl->wlc, "rtsthresh", value & 0xFFFF);
+       stats->dot11ACKFailureCount = 0;
+       stats->dot11RTSFailureCount = 0;
+       stats->dot11FCSErrorCount = 0;
+       stats->dot11RTSSuccessCount = 0;
        WL_UNLOCK(wl);
        return 0;
 }
@@ -532,10 +544,10 @@ static void
 wl_ops_sta_notify(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
                  enum sta_notify_cmd cmd, struct ieee80211_sta *sta)
 {
-       WL_NONE("%s: Enter\n", __func__);
        switch (cmd) {
        default:
-               WL_ERROR("%s: Unknown cmd = %d\n", __func__, cmd);
+               wiphy_err(hw->wiphy, "%s: Unknown cmd = %d\n", __func__,
+                         cmd);
                break;
        }
        return;
@@ -547,12 +559,8 @@ wl_ops_conf_tx(struct ieee80211_hw *hw, u16 queue,
 {
        struct wl_info *wl = hw->priv;
 
-       WL_NONE("%s: Enter (WME config)\n", __func__);
-       WL_NONE("queue %d, txop %d, cwmin %d, cwmax %d, aifs %d\n", queue,
-                params->txop, params->cw_min, params->cw_max, params->aifs);
-
        WL_LOCK(wl);
-       wlc_wme_setparams(wl->wlc, queue, (void *)params, true);
+       wlc_wme_setparams(wl->wlc, queue, params, true);
        WL_UNLOCK(wl);
 
        return 0;
@@ -560,7 +568,7 @@ wl_ops_conf_tx(struct ieee80211_hw *hw, u16 queue,
 
 static u64 wl_ops_get_tsf(struct ieee80211_hw *hw)
 {
-       WL_ERROR("%s: Enter\n", __func__);
+       wiphy_err(hw->wiphy, "%s: Enter\n", __func__);
        return 0;
 }
 
@@ -585,7 +593,7 @@ wl_ops_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
        wl->pub->global_ampdu = &(scb->scb_ampdu);
        wl->pub->global_ampdu->scb = scb;
        wl->pub->global_ampdu->max_pdu = 16;
-       pktq_init(&scb->scb_ampdu.txq, AMPDU_MAX_SCB_TID,
+       bcm_pktq_init(&scb->scb_ampdu.txq, AMPDU_MAX_SCB_TID,
                  AMPDU_MAX_SCB_TID * PKTQ_LEN_DEFAULT);
 
        sta->ht_cap.ht_supported = true;
@@ -603,7 +611,6 @@ static int
 wl_ops_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
                  struct ieee80211_sta *sta)
 {
-       WL_NONE("%s: Enter\n", __func__);
        return 0;
 }
 
@@ -614,27 +621,25 @@ wl_ops_ampdu_action(struct ieee80211_hw *hw,
                    struct ieee80211_sta *sta, u16 tid, u16 *ssn,
                    u8 buf_size)
 {
-#if defined(BCMDBG)
        struct scb *scb = (struct scb *)sta->drv_priv;
-#endif
        struct wl_info *wl = hw->priv;
        int status;
 
-       ASSERT(scb->magic == SCB_MAGIC);
+       if (WARN_ON(scb->magic != SCB_MAGIC))
+               return -EIDRM;
        switch (action) {
        case IEEE80211_AMPDU_RX_START:
-               WL_NONE("%s: action = IEEE80211_AMPDU_RX_START\n", __func__);
                break;
        case IEEE80211_AMPDU_RX_STOP:
-               WL_NONE("%s: action = IEEE80211_AMPDU_RX_STOP\n", __func__);
                break;
        case IEEE80211_AMPDU_TX_START:
                WL_LOCK(wl);
                status = wlc_aggregatable(wl->wlc, tid);
                WL_UNLOCK(wl);
                if (!status) {
-                       /* WL_ERROR("START: tid %d is not agg' able, return FAILURE to stack\n", tid); */
-                       return -1;
+                       wiphy_err(wl->wiphy, "START: tid %d is not agg\'able\n",
+                                 tid);
+                       return -EINVAL;
                }
                /* XXX: Use the starting sequence number provided ... */
                *ssn = 0;
@@ -650,11 +655,10 @@ wl_ops_ampdu_action(struct ieee80211_hw *hw,
        case IEEE80211_AMPDU_TX_OPERATIONAL:
                /* Not sure what to do here */
                /* Power save wakeup */
-               WL_NONE("%s: action = IEEE80211_AMPDU_TX_OPERATIONAL\n",
-                       __func__);
                break;
        default:
-               WL_ERROR("%s: Invalid command, ignoring\n", __func__);
+               wiphy_err(wl->wiphy, "%s: Invalid command, ignoring\n",
+                         __func__);
        }
 
        return 0;
@@ -669,10 +673,21 @@ static void wl_ops_rfkill_poll(struct ieee80211_hw *hw)
        blocked = wlc_check_radio_disabled(wl->wlc);
        WL_UNLOCK(wl);
 
-       WL_NONE("wl: rfkill_poll: %d\n", blocked);
        wiphy_rfkill_set_hw_state(wl->pub->ieee_hw->wiphy, blocked);
 }
 
+static void wl_ops_flush(struct ieee80211_hw *hw, bool drop)
+{
+       struct wl_info *wl = HW_TO_WL(hw);
+
+       no_printk("%s: drop = %s\n", __func__, drop ? "true" : "false");
+
+       /* wait for packet queue and dma fifos to run empty */
+       WL_LOCK(wl);
+       wlc_wait_for_tx_completion(wl->wlc, drop);
+       WL_UNLOCK(wl);
+}
+
 static const struct ieee80211_ops wl_ops = {
        .tx = wl_ops_tx,
        .start = wl_ops_start,
@@ -687,7 +702,6 @@ static const struct ieee80211_ops wl_ops = {
        .sw_scan_complete = wl_ops_sw_scan_complete,
        .set_tsf = wl_ops_set_tsf,
        .get_stats = wl_ops_get_stats,
-       .set_rts_threshold = wl_ops_set_rts_threshold,
        .sta_notify = wl_ops_sta_notify,
        .conf_tx = wl_ops_conf_tx,
        .get_tsf = wl_ops_get_tsf,
@@ -695,6 +709,7 @@ static const struct ieee80211_ops wl_ops = {
        .sta_remove = wl_ops_sta_remove,
        .ampdu_action = wl_ops_ampdu_action,
        .rfkill_poll = wl_ops_rfkill_poll,
+       .flush = wl_ops_flush,
 };
 
 /*
@@ -702,8 +717,6 @@ static const struct ieee80211_ops wl_ops = {
  */
 static int wl_set_hint(struct wl_info *wl, char *abbrev)
 {
-       WL_NONE("%s: Sending country code %c%c to MAC80211\n",
-                __func__, abbrev[0], abbrev[1]);
        return regulatory_hint(wl->pub->ieee_hw->wiphy, abbrev);
 }
 
@@ -724,7 +737,7 @@ static int wl_set_hint(struct wl_info *wl, char *abbrev)
 static struct wl_info *wl_attach(u16 vendor, u16 device, unsigned long regs,
                            uint bustype, void *btparam, uint irq)
 {
-       struct wl_info *wl;
+       struct wl_info *wl = NULL;
        int unit, err;
 
        unsigned long base_addr;
@@ -735,14 +748,16 @@ static struct wl_info *wl_attach(u16 vendor, u16 device, unsigned long regs,
        err = 0;
 
        if (unit < 0) {
-               WL_ERROR("wl%d: unit number overflow, exiting\n", unit);
                return NULL;
        }
 
        /* allocate private info */
        hw = pci_get_drvdata(btparam);  /* btparam == pdev */
-       wl = hw->priv;
-       ASSERT(wl);
+       if (hw != NULL)
+               wl = hw->priv;
+       if (WARN_ON(hw == NULL) || WARN_ON(wl == NULL))
+               return NULL;
+       wl->wiphy = hw->wiphy;
 
        atomic_set(&wl->callbacks, 0);
 
@@ -759,13 +774,13 @@ static struct wl_info *wl_attach(u16 vendor, u16 device, unsigned long regs,
                /* Do nothing */
        } else {
                bustype = PCI_BUS;
-               WL_TRACE("force to PCI\n");
+               BCMMSG(wl->wiphy, "force to PCI\n");
        }
        wl->bcm_bustype = bustype;
 
        wl->regsva = ioremap_nocache(base_addr, PCI_BAR0_WINSZ);
        if (wl->regsva == NULL) {
-               WL_ERROR("wl%d: ioremap() failed\n", unit);
+               wiphy_err(wl->wiphy, "wl%d: ioremap() failed\n", unit);
                goto fail;
        }
        spin_lock_init(&wl->lock);
@@ -773,11 +788,11 @@ static struct wl_info *wl_attach(u16 vendor, u16 device, unsigned long regs,
 
        /* prepare ucode */
        if (wl_request_fw(wl, (struct pci_dev *)btparam) < 0) {
-               WL_ERROR("%s: Failed to find firmware usually in %s\n",
-                        KBUILD_MODNAME, "/lib/firmware/brcm");
+               wiphy_err(wl->wiphy, "%s: Failed to find firmware usually in "
+                         "%s\n", KBUILD_MODNAME, "/lib/firmware/brcm");
                wl_release_fw(wl);
                wl_remove((struct pci_dev *)btparam);
-               goto fail1;
+               return NULL;
        }
 
        /* common load-time initialization */
@@ -785,24 +800,22 @@ static struct wl_info *wl_attach(u16 vendor, u16 device, unsigned long regs,
                             wl->regsva, wl->bcm_bustype, btparam, &err);
        wl_release_fw(wl);
        if (!wl->wlc) {
-               WL_ERROR("%s: wlc_attach() failed with code %d\n",
-                        KBUILD_MODNAME, err);
+               wiphy_err(wl->wiphy, "%s: wlc_attach() failed with code %d\n",
+                         KBUILD_MODNAME, err);
                goto fail;
        }
        wl->pub = wlc_pub(wl->wlc);
 
        wl->pub->ieee_hw = hw;
-       ASSERT(wl->pub->ieee_hw);
-       ASSERT(wl->pub->ieee_hw->priv == wl);
-
 
        if (wlc_iovar_setint(wl->wlc, "mpc", 0)) {
-               WL_ERROR("wl%d: Error setting MPC variable to 0\n", unit);
+               wiphy_err(wl->wiphy, "wl%d: Error setting MPC variable to 0\n",
+                         unit);
        }
 
        /* register our interrupt handler */
        if (request_irq(irq, wl_isr, IRQF_SHARED, KBUILD_MODNAME, wl)) {
-               WL_ERROR("wl%d: request_irq() failed\n", unit);
+               wiphy_err(wl->wiphy, "wl%d: request_irq() failed\n", unit);
                goto fail;
        }
        wl->irq = irq;
@@ -812,18 +825,20 @@ static struct wl_info *wl_attach(u16 vendor, u16 device, unsigned long regs,
                            NULL);
 
        if (ieee_hw_init(hw)) {
-               WL_ERROR("wl%d: %s: ieee_hw_init failed!\n", unit, __func__);
+               wiphy_err(wl->wiphy, "wl%d: %s: ieee_hw_init failed!\n", unit,
+                         __func__);
                goto fail;
        }
 
        memcpy(perm, &wl->pub->cur_etheraddr, ETH_ALEN);
-       ASSERT(is_valid_ether_addr(perm));
+       if (WARN_ON(!is_valid_ether_addr(perm)))
+               goto fail;
        SET_IEEE80211_PERM_ADDR(hw, perm);
 
        err = ieee80211_register_hw(hw);
        if (err) {
-               WL_ERROR("%s: ieee80211_register_hw failed, status %d\n",
-                        __func__, err);
+               wiphy_err(wl->wiphy, "%s: ieee80211_register_hw failed, status"
+                         "%d\n", __func__, err);
        }
 
        if (wl->pub->srom_ccode[0])
@@ -831,8 +846,8 @@ static struct wl_info *wl_attach(u16 vendor, u16 device, unsigned long regs,
        else
                err = wl_set_hint(wl, "US");
        if (err) {
-               WL_ERROR("%s: regulatory_hint failed, status %d\n",
-                        __func__, err);
+               wiphy_err(wl->wiphy, "%s: regulatory_hint failed, status %d\n",
+                         __func__, err);
        }
 
        wl_found++;
@@ -840,7 +855,6 @@ static struct wl_info *wl_attach(u16 vendor, u16 device, unsigned long regs,
 
 fail:
        wl_free(wl);
-fail1:
        return NULL;
 }
 
@@ -1027,9 +1041,8 @@ static int ieee_hw_rate_init(struct ieee80211_hw *hw)
        hw->wiphy->bands[IEEE80211_BAND_5GHZ] = NULL;
 
        if (wlc_get(wl->wlc, WLC_GET_PHYLIST, (int *)&phy_list) < 0) {
-               WL_ERROR("Phy list failed\n");
+               wiphy_err(hw->wiphy, "Phy list failed\n");
        }
-       WL_NONE("%s: phylist = %c\n", __func__, phy_list[0]);
 
        if (phy_list[0] == 'n' || phy_list[0] == 'c') {
                if (phy_list[0] == 'c') {
@@ -1039,8 +1052,7 @@ static int ieee_hw_rate_init(struct ieee80211_hw *hw)
                }
                hw->wiphy->bands[IEEE80211_BAND_2GHZ] = &wl_band_2GHz_nphy;
        } else {
-               BUG();
-               return -1;
+               return -EPERM;
        }
 
        /* Assume all bands use the same phy.  True for 11n devices. */
@@ -1050,12 +1062,9 @@ static int ieee_hw_rate_init(struct ieee80211_hw *hw)
                        hw->wiphy->bands[IEEE80211_BAND_5GHZ] =
                            &wl_band_5GHz_nphy;
                } else {
-                       return -1;
+                       return -EPERM;
                }
        }
-
-       WL_NONE("%s: 2ghz = %d, 5ghz = %d\n", __func__, 1, has_5g);
-
        return 0;
 }
 
@@ -1070,8 +1079,7 @@ static int ieee_hw_init(struct ieee80211_hw *hw)
            | IEEE80211_HW_AMPDU_AGGREGATION;
 
        hw->extra_tx_headroom = wlc_get_header_len();
-       /* FIXME: should get this from wlc->machwcap */
-       hw->queues = 4;
+       hw->queues = N_TX_QUEUES;
        /* FIXME: this doesn't seem to be used properly in minstrel_ht.
         * mac80211/status.c:ieee80211_tx_status() checks this value,
         * but mac80211/rc80211_minstrel_ht.c:minstrel_ht_get_rate()
@@ -1104,11 +1112,9 @@ wl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        struct ieee80211_hw *hw;
        u32 val;
 
-       ASSERT(pdev);
-
-       WL_TRACE("%s: bus %d slot %d func %d irq %d\n",
-                __func__, pdev->bus->number, PCI_SLOT(pdev->devfn),
-                PCI_FUNC(pdev->devfn), pdev->irq);
+       dev_info(&pdev->dev, "bus %d slot %d func %d irq %d\n",
+              pdev->bus->number, PCI_SLOT(pdev->devfn),
+              PCI_FUNC(pdev->devfn), pdev->irq);
 
        if ((pdev->vendor != PCI_VENDOR_ID_BROADCOM) ||
            (((pdev->device & 0xff00) != 0x4300) &&
@@ -1118,9 +1124,9 @@ wl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 
        rc = pci_enable_device(pdev);
        if (rc) {
-               WL_ERROR("%s: Cannot enable device %d-%d_%d\n",
-                        __func__, pdev->bus->number, PCI_SLOT(pdev->devfn),
-                        PCI_FUNC(pdev->devfn));
+               pr_err("%s: Cannot enable device %d-%d_%d\n",
+                      __func__, pdev->bus->number, PCI_SLOT(pdev->devfn),
+                      PCI_FUNC(pdev->devfn));
                return -ENODEV;
        }
        pci_set_master(pdev);
@@ -1131,9 +1137,8 @@ wl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 
        hw = ieee80211_alloc_hw(sizeof(struct wl_info), &wl_ops);
        if (!hw) {
-               WL_ERROR("%s: ieee80211_alloc_hw failed\n", __func__);
-               rc = -ENOMEM;
-               goto err_1;
+               pr_err("%s: ieee80211_alloc_hw failed\n", __func__);
+               return -ENOMEM;
        }
 
        SET_IEEE80211_DEV(hw, &pdev->dev);
@@ -1146,14 +1151,11 @@ wl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
                       PCI_BUS, pdev, pdev->irq);
 
        if (!wl) {
-               WL_ERROR("%s: %s: wl_attach failed!\n",
-                        KBUILD_MODNAME, __func__);
+               pr_err("%s: %s: wl_attach failed!\n", KBUILD_MODNAME,
+                      __func__);
                return -ENODEV;
        }
        return 0;
- err_1:
-       WL_ERROR("%s: err_1: Major hoarkage\n", __func__);
-       return 0;
 }
 
 static int wl_suspend(struct pci_dev *pdev, pm_message_t state)
@@ -1161,12 +1163,11 @@ static int wl_suspend(struct pci_dev *pdev, pm_message_t state)
        struct wl_info *wl;
        struct ieee80211_hw *hw;
 
-       WL_TRACE("wl: wl_suspend\n");
-
        hw = pci_get_drvdata(pdev);
        wl = HW_TO_WL(hw);
        if (!wl) {
-               WL_ERROR("wl: wl_suspend: pci_get_drvdata failed\n");
+               wiphy_err(wl->wiphy,
+                         "wl_suspend: pci_get_drvdata failed\n");
                return -ENODEV;
        }
 
@@ -1187,11 +1188,11 @@ static int wl_resume(struct pci_dev *pdev)
        int err = 0;
        u32 val;
 
-       WL_TRACE("wl: wl_resume\n");
        hw = pci_get_drvdata(pdev);
        wl = HW_TO_WL(hw);
        if (!wl) {
-               WL_ERROR("wl: wl_resume: pci_get_drvdata failed\n");
+               wiphy_err(wl->wiphy,
+                         "wl: wl_resume: pci_get_drvdata failed\n");
                return -ENODEV;
        }
 
@@ -1231,7 +1232,7 @@ static void wl_remove(struct pci_dev *pdev)
        hw = pci_get_drvdata(pdev);
        wl = HW_TO_WL(hw);
        if (!wl) {
-               WL_ERROR("wl: wl_remove: pci_get_drvdata failed\n");
+               pr_err("wl: wl_remove: pci_get_drvdata failed\n");
                return;
        }
 
@@ -1239,7 +1240,7 @@ static void wl_remove(struct pci_dev *pdev)
        status = wlc_chipmatch(pdev->vendor, pdev->device);
        WL_UNLOCK(wl);
        if (!status) {
-               WL_ERROR("wl: wl_remove: wlc_chipmatch failed\n");
+               wiphy_err(wl->wiphy, "wl: wl_remove: wlc_chipmatch failed\n");
                return;
        }
        if (wl->wlc) {
@@ -1249,7 +1250,6 @@ static void wl_remove(struct pci_dev *pdev)
                WL_LOCK(wl);
                wl_down(wl);
                WL_UNLOCK(wl);
-               WL_NONE("%s: Down\n", __func__);
        }
        pci_disable_device(pdev);
 
@@ -1342,7 +1342,6 @@ static void wl_free(struct wl_info *wl)
 {
        struct wl_timer *t, *next;
 
-       ASSERT(wl);
        /* free ucode data */
        if (wl->fw.fw_cnt)
                wl_ucode_data_free();
@@ -1389,13 +1388,30 @@ static void wl_free(struct wl_info *wl)
        wl->regsva = NULL;
 }
 
+/* flags the given rate in rateset as requested */
+static void wl_set_basic_rate(struct wl_rateset *rs, u16 rate, bool is_br)
+{
+       u32 i;
+
+       for (i = 0; i < rs->count; i++) {
+               if (rate != (rs->rates[i] & 0x7f))
+                       continue;
+
+               if (is_br)
+                       rs->rates[i] |= WLC_RATE_FLAG;
+               else
+                       rs->rates[i] &= WLC_RATE_MASK;
+               return;
+       }
+}
+
 /*
  * precondition: perimeter lock has been acquired
  */
 void wl_txflowcontrol(struct wl_info *wl, struct wl_if *wlif, bool state,
                      int prio)
 {
-       WL_ERROR("Shouldn't be here %s\n", __func__);
+       wiphy_err(wl->wiphy, "Shouldn't be here %s\n", __func__);
 }
 
 /*
@@ -1403,8 +1419,7 @@ void wl_txflowcontrol(struct wl_info *wl, struct wl_if *wlif, bool state,
  */
 void wl_init(struct wl_info *wl)
 {
-       WL_TRACE("wl%d: wl_init\n", wl->pub->unit);
-
+       BCMMSG(WL_TO_HW(wl)->wiphy, "wl%d\n", wl->pub->unit);
        wl_reset(wl);
 
        wlc_init(wl->wlc);
@@ -1415,8 +1430,7 @@ void wl_init(struct wl_info *wl)
  */
 uint wl_reset(struct wl_info *wl)
 {
-       WL_TRACE("wl%d: wl_reset\n", wl->pub->unit);
-
+       BCMMSG(WL_TO_HW(wl)->wiphy, "wl%d\n", wl->pub->unit);
        wlc_reset(wl->wlc);
 
        /* dpc will not be rescheduled */
@@ -1429,7 +1443,7 @@ uint wl_reset(struct wl_info *wl)
  * These are interrupt on/off entry points. Disable interrupts
  * during interrupt state transition.
  */
-void BCMFASTPATH wl_intrson(struct wl_info *wl)
+void wl_intrson(struct wl_info *wl)
 {
        unsigned long flags;
 
@@ -1446,7 +1460,7 @@ bool wl_alloc_dma_resources(struct wl_info *wl, uint addrwidth)
        return true;
 }
 
-u32 BCMFASTPATH wl_intrsoff(struct wl_info *wl)
+u32 wl_intrsoff(struct wl_info *wl)
 {
        unsigned long flags;
        u32 status;
@@ -1503,7 +1517,7 @@ void wl_down(struct wl_info *wl)
        WL_LOCK(wl);
 }
 
-static irqreturn_t BCMFASTPATH wl_isr(int irq, void *dev_id)
+static irqreturn_t wl_isr(int irq, void *dev_id)
 {
        struct wl_info *wl;
        bool ours, wantdpc;
@@ -1521,7 +1535,6 @@ static irqreturn_t BCMFASTPATH wl_isr(int irq, void *dev_id)
 
                        /* ...and call the second level interrupt handler */
                        /* schedule dpc */
-                       ASSERT(wl->resched == false);
                        tasklet_schedule(&wl->tasklet);
                }
        }
@@ -1531,7 +1544,7 @@ static irqreturn_t BCMFASTPATH wl_isr(int irq, void *dev_id)
        return IRQ_RETVAL(ours);
 }
 
-static void BCMFASTPATH wl_dpc(unsigned long data)
+static void wl_dpc(unsigned long data)
 {
        struct wl_info *wl;
 
@@ -1613,7 +1626,8 @@ struct wl_timer *wl_init_timer(struct wl_info *wl, void (*fn) (void *arg),
 
        t = kzalloc(sizeof(struct wl_timer), GFP_ATOMIC);
        if (!t) {
-               WL_ERROR("wl%d: wl_init_timer: out of memory\n", wl->pub->unit);
+               wiphy_err(wl->wiphy, "wl%d: wl_init_timer: out of memory\n",
+                         wl->pub->unit);
                return 0;
        }
 
@@ -1644,12 +1658,10 @@ void wl_add_timer(struct wl_info *wl, struct wl_timer *t, uint ms, int periodic)
 {
 #ifdef BCMDBG
        if (t->set) {
-               WL_ERROR("%s: Already set. Name: %s, per %d\n",
-                        __func__, t->name, periodic);
+               wiphy_err(wl->wiphy, "%s: Already set. Name: %s, per %d\n",
+                         __func__, t->name, periodic);
        }
 #endif
-       ASSERT(!t->set);
-
        t->ms = ms;
        t->periodic = (bool) periodic;
        t->set = true;
@@ -1719,37 +1731,6 @@ void wl_free_timer(struct wl_info *wl, struct wl_timer *t)
  */
 static int wl_linux_watchdog(void *ctx)
 {
-       struct wl_info *wl = (struct wl_info *) ctx;
-       struct wl_cnt *cnt;
-       struct net_device_stats *stats = NULL;
-       uint id;
-       /* refresh stats */
-       if (wl->pub->up) {
-               ASSERT(wl->stats_id < 2);
-
-               cnt = wl->pub->_cnt;
-               id = 1 - wl->stats_id;
-               stats = &wl->stats_watchdog[id];
-               stats->rx_packets = cnt->rxframe;
-               stats->tx_packets = cnt->txframe;
-               stats->rx_bytes = cnt->rxbyte;
-               stats->tx_bytes = cnt->txbyte;
-               stats->rx_errors = cnt->rxerror;
-               stats->tx_errors = cnt->txerror;
-               stats->collisions = 0;
-
-               stats->rx_length_errors = 0;
-               stats->rx_over_errors = cnt->rxoflo;
-               stats->rx_crc_errors = cnt->rxcrc;
-               stats->rx_frame_errors = 0;
-               stats->rx_fifo_errors = cnt->rxoflo;
-               stats->rx_missed_errors = 0;
-
-               stats->tx_fifo_errors = cnt->txuflo;
-
-               wl->stats_id = id;
-       }
-
        return 0;
 }
 
@@ -1780,8 +1761,8 @@ int wl_ucode_init_buf(struct wl_info *wl, void **pbuf, u32 idx)
                                pdata = wl->fw.fw_bin[i]->data + hdr->offset;
                                *pbuf = kmalloc(hdr->len, GFP_ATOMIC);
                                if (*pbuf == NULL) {
-                                       WL_ERROR("fail to alloc %d bytes\n",
-                                                hdr->len);
+                                       wiphy_err(wl->wiphy, "fail to alloc %d"
+                                                 " bytes\n", hdr->len);
                                        goto fail;
                                }
                                memcpy(*pbuf, pdata, hdr->len);
@@ -1789,10 +1770,11 @@ int wl_ucode_init_buf(struct wl_info *wl, void **pbuf, u32 idx)
                        }
                }
        }
-       WL_ERROR("ERROR: ucode buf tag:%d can not be found!\n", idx);
+       wiphy_err(wl->wiphy, "ERROR: ucode buf tag:%d can not be found!\n",
+                 idx);
        *pbuf = NULL;
 fail:
-       return BCME_NOTFOUND;
+       return -ENODATA;
 }
 
 /*
@@ -1810,14 +1792,18 @@ int wl_ucode_init_uint(struct wl_info *wl, u32 *data, u32 idx)
                     entry++, hdr++) {
                        if (hdr->idx == idx) {
                                pdata = wl->fw.fw_bin[i]->data + hdr->offset;
-                               ASSERT(hdr->len == 4);
+                               if (hdr->len != 4) {
+                                       wiphy_err(wl->wiphy,
+                                                 "ERROR: fw hdr len\n");
+                                       return -ENOMSG;
+                               }
                                *data = *((u32 *) pdata);
                                return 0;
                        }
                }
        }
-       WL_ERROR("ERROR: ucode tag:%d can not be found!\n", idx);
-       return -1;
+       wiphy_err(wl->wiphy, "ERROR: ucode tag:%d can not be found!\n", idx);
+       return -ENOMSG;
 }
 
 /*
@@ -1837,26 +1823,22 @@ static int wl_request_fw(struct wl_info *wl, struct pci_dev *pdev)
                        break;
                sprintf(fw_name, "%s-%d.fw", wl_firmwares[i],
                        UCODE_LOADER_API_VER);
-               WL_NONE("request fw %s\n", fw_name);
                status = request_firmware(&wl->fw.fw_bin[i], fw_name, device);
                if (status) {
-                       WL_ERROR("%s: fail to load firmware %s\n",
-                                KBUILD_MODNAME, fw_name);
+                       wiphy_err(wl->wiphy, "%s: fail to load firmware %s\n",
+                                 KBUILD_MODNAME, fw_name);
                        return status;
                }
-               WL_NONE("request fw %s\n", fw_name);
                sprintf(fw_name, "%s_hdr-%d.fw", wl_firmwares[i],
                        UCODE_LOADER_API_VER);
                status = request_firmware(&wl->fw.fw_hdr[i], fw_name, device);
                if (status) {
-                       WL_ERROR("%s: fail to load firmware %s\n",
-                                KBUILD_MODNAME, fw_name);
+                       wiphy_err(wl->wiphy, "%s: fail to load firmware %s\n",
+                                 KBUILD_MODNAME, fw_name);
                        return status;
                }
                wl->fw.hdr_num_entries[i] =
                    wl->fw.fw_hdr[i]->size / (sizeof(struct wl_fw_hdr));
-               WL_NONE("request fw %s find: %d entries\n",
-                       fw_name, wl->fw.hdr_num_entries[i]);
        }
        wl->fw.fw_cnt = i;
        return wl_ucode_data_init(wl);
@@ -1904,16 +1886,17 @@ int wl_check_firmwares(struct wl_info *wl)
                if (fw == NULL && fw_hdr == NULL) {
                        break;
                } else if (fw == NULL || fw_hdr == NULL) {
-                       WL_ERROR("%s: invalid bin/hdr fw\n", __func__);
+                       wiphy_err(wl->wiphy, "%s: invalid bin/hdr fw\n",
+                                 __func__);
                        rc = -EBADF;
                } else if (fw_hdr->size % sizeof(struct wl_fw_hdr)) {
-                       WL_ERROR("%s: non integral fw hdr file size %zu/%zu\n",
-                                __func__, fw_hdr->size,
-                                sizeof(struct wl_fw_hdr));
+                       wiphy_err(wl->wiphy, "%s: non integral fw hdr file "
+                               "size %zu/%zu\n", __func__, fw_hdr->size,
+                               sizeof(struct wl_fw_hdr));
                        rc = -EBADF;
                } else if (fw->size < MIN_FW_SIZE || fw->size > MAX_FW_SIZE) {
-                       WL_ERROR("%s: out of bounds fw file size %zu\n",
-                                __func__, fw->size);
+                       wiphy_err(wl->wiphy, "%s: out of bounds fw file size "
+                                 "%zu\n", __func__, fw->size);
                        rc = -EBADF;
                } else {
                        /* check if ucode section overruns firmware image */
@@ -1922,15 +1905,17 @@ int wl_check_firmwares(struct wl_info *wl)
                             !rc; entry++, ucode_hdr++) {
                                if (ucode_hdr->offset + ucode_hdr->len >
                                    fw->size) {
-                                       WL_ERROR("%s: conflicting bin/hdr\n",
-                                                __func__);
+                                       wiphy_err(wl->wiphy,
+                                                 "%s: conflicting bin/hdr\n",
+                                                 __func__);
                                        rc = -EBADF;
                                }
                        }
                }
        }
        if (rc == 0 && wl->fw.fw_cnt != i) {
-               WL_ERROR("%s: invalid fw_cnt=%d\n", __func__, wl->fw.fw_cnt);
+               wiphy_err(wl->wiphy, "%s: invalid fw_cnt=%d\n", __func__,
+                       wl->fw.fw_cnt);
                rc = -EBADF;
        }
        return rc;
@@ -1943,8 +1928,6 @@ bool wl_rfkill_set_hw_state(struct wl_info *wl)
 {
        bool blocked = wlc_check_radio_disabled(wl->wlc);
 
-       WL_NONE("%s: update hw state: blocked=%s\n", __func__,
-               blocked ? "true" : "false");
        WL_UNLOCK(wl);
        wiphy_rfkill_set_hw_state(wl->pub->ieee_hw->wiphy, blocked);
        if (blocked)
@@ -1952,3 +1935,13 @@ bool wl_rfkill_set_hw_state(struct wl_info *wl)
        WL_LOCK(wl);
        return blocked;
 }
+
+/*
+ * precondition: perimeter lock has been acquired
+ */
+void wl_msleep(struct wl_info *wl, uint ms)
+{
+       WL_UNLOCK(wl);
+       msleep(ms);
+       WL_LOCK(wl);
+}
index f3198ccd5f58cf0bf22aaa421483d663981b7b06..e703d8bb94d6043dc6e491f2431be69ab27f944d 100644 (file)
@@ -67,11 +67,8 @@ struct wl_info {
 #ifdef LINUXSTA_PS
        u32 pci_psstate[16];    /* pci ps-state save/restore */
 #endif
-       /* RPC, handle, lock, txq, workitem */
-       uint stats_id;          /* the current set of stats */
-       /* ping-pong stats counters updated by Linux watchdog */
-       struct net_device_stats stats_watchdog[2];
        struct wl_firmware fw;
+       struct wiphy *wiphy;
 };
 
 #define WL_LOCK(wl)    spin_lock_bh(&(wl)->lock)
index e928fa10834ef8ba8e10243cf86bd316e4e7e93d..82c64cd4486fbeec180f69c2e7b8c13de4e47262 100644 (file)
@@ -18,7 +18,7 @@
 
 #include <bcmdefs.h>
 #include <bcmutils.h>
-#include <siutils.h>
+#include <aiutils.h>
 #include <wlioctl.h>
 #include <sbhnddma.h>
 
@@ -43,17 +43,7 @@ static struct wlc_pub *wlc_pub_malloc(uint unit,
 static void wlc_pub_mfree(struct wlc_pub *pub);
 static void wlc_tunables_init(wlc_tunables_t *tunables, uint devid);
 
-void *wlc_calloc(uint unit, uint size)
-{
-       void *item;
-
-       item = kzalloc(size, GFP_ATOMIC);
-       if (item == NULL)
-               WL_ERROR("wl%d: %s: out of memory\n", unit, __func__);
-       return item;
-}
-
-void wlc_tunables_init(wlc_tunables_t *tunables, uint devid)
+static void wlc_tunables_init(wlc_tunables_t *tunables, uint devid)
 {
        tunables->ntxd = NTXD;
        tunables->nrxd = NRXD;
@@ -75,14 +65,13 @@ static struct wlc_pub *wlc_pub_malloc(uint unit, uint *err, uint devid)
 {
        struct wlc_pub *pub;
 
-       pub = wlc_calloc(unit, sizeof(struct wlc_pub));
+       pub = kzalloc(sizeof(struct wlc_pub), GFP_ATOMIC);
        if (pub == NULL) {
                *err = 1001;
                goto fail;
        }
 
-       pub->tunables = wlc_calloc(unit,
-               sizeof(wlc_tunables_t));
+       pub->tunables = kzalloc(sizeof(wlc_tunables_t), GFP_ATOMIC);
        if (pub->tunables == NULL) {
                *err = 1028;
                goto fail;
@@ -91,12 +80,7 @@ static struct wlc_pub *wlc_pub_malloc(uint unit, uint *err, uint devid)
        /* need to init the tunables now */
        wlc_tunables_init(pub->tunables, devid);
 
-       pub->_cnt = wlc_calloc(unit, sizeof(struct wl_cnt));
-       if (pub->_cnt == NULL)
-               goto fail;
-
-       pub->multicast = (u8 *)wlc_calloc(unit,
-               (ETH_ALEN * MAXMULTILIST));
+       pub->multicast = kzalloc(ETH_ALEN * MAXMULTILIST, GFP_ATOMIC);
        if (pub->multicast == NULL) {
                *err = 1003;
                goto fail;
@@ -115,7 +99,6 @@ static void wlc_pub_mfree(struct wlc_pub *pub)
                return;
 
        kfree(pub->multicast);
-       kfree(pub->_cnt);
        kfree(pub->tunables);
        kfree(pub);
 }
@@ -124,12 +107,11 @@ static struct wlc_bsscfg *wlc_bsscfg_malloc(uint unit)
 {
        struct wlc_bsscfg *cfg;
 
-       cfg = (struct wlc_bsscfg *) wlc_calloc(unit, sizeof(struct wlc_bsscfg));
+       cfg = kzalloc(sizeof(struct wlc_bsscfg), GFP_ATOMIC);
        if (cfg == NULL)
                goto fail;
 
-       cfg->current_bss = (wlc_bss_info_t *)wlc_calloc(unit,
-               sizeof(wlc_bss_info_t));
+       cfg->current_bss = kzalloc(sizeof(wlc_bss_info_t), GFP_ATOMIC);
        if (cfg->current_bss == NULL)
                goto fail;
 
@@ -150,7 +132,8 @@ static void wlc_bsscfg_mfree(struct wlc_bsscfg *cfg)
        kfree(cfg);
 }
 
-void wlc_bsscfg_ID_assign(struct wlc_info *wlc, struct wlc_bsscfg *bsscfg)
+static void wlc_bsscfg_ID_assign(struct wlc_info *wlc,
+                                struct wlc_bsscfg *bsscfg)
 {
        bsscfg->ID = wlc->next_bsscfg_ID;
        wlc->next_bsscfg_ID++;
@@ -163,7 +146,7 @@ struct wlc_info *wlc_attach_malloc(uint unit, uint *err, uint devid)
 {
        struct wlc_info *wlc;
 
-       wlc = (struct wlc_info *) wlc_calloc(unit, sizeof(struct wlc_info));
+       wlc = kzalloc(sizeof(struct wlc_info), GFP_ATOMIC);
        if (wlc == NULL) {
                *err = 1002;
                goto fail;
@@ -181,16 +164,15 @@ struct wlc_info *wlc_attach_malloc(uint unit, uint *err, uint devid)
 
        /* allocate struct wlc_hw_info state structure */
 
-       wlc->hw = (struct wlc_hw_info *)wlc_calloc(unit,
-                       sizeof(struct wlc_hw_info));
+       wlc->hw = kzalloc(sizeof(struct wlc_hw_info), GFP_ATOMIC);
        if (wlc->hw == NULL) {
                *err = 1005;
                goto fail;
        }
        wlc->hw->wlc = wlc;
 
-       wlc->hw->bandstate[0] = wlc_calloc(unit,
-               (sizeof(struct wlc_hwband) * MAXBANDS));
+       wlc->hw->bandstate[0] =
+               kzalloc(sizeof(struct wlc_hwband) * MAXBANDS, GFP_ATOMIC);
        if (wlc->hw->bandstate[0] == NULL) {
                *err = 1006;
                goto fail;
@@ -204,15 +186,14 @@ struct wlc_info *wlc_attach_malloc(uint unit, uint *err, uint devid)
                }
        }
 
-       wlc->modulecb = wlc_calloc(unit,
-               sizeof(struct modulecb) * WLC_MAXMODULES);
+       wlc->modulecb =
+               kzalloc(sizeof(struct modulecb) * WLC_MAXMODULES, GFP_ATOMIC);
        if (wlc->modulecb == NULL) {
                *err = 1009;
                goto fail;
        }
 
-       wlc->default_bss = (wlc_bss_info_t *)wlc_calloc(unit,
-               sizeof(wlc_bss_info_t));
+       wlc->default_bss = kzalloc(sizeof(wlc_bss_info_t), GFP_ATOMIC);
        if (wlc->default_bss == NULL) {
                *err = 1010;
                goto fail;
@@ -225,15 +206,16 @@ struct wlc_info *wlc_attach_malloc(uint unit, uint *err, uint devid)
        }
        wlc_bsscfg_ID_assign(wlc, wlc->cfg);
 
-       wlc->pkt_callback = wlc_calloc(unit,
-               (sizeof(struct pkt_cb) * (wlc->pub->tunables->maxpktcb + 1)));
+       wlc->pkt_callback = kzalloc(sizeof(struct pkt_cb) *
+                                   (wlc->pub->tunables->maxpktcb + 1),
+                                   GFP_ATOMIC);
        if (wlc->pkt_callback == NULL) {
                *err = 1013;
                goto fail;
        }
 
-       wlc->wsec_def_keys[0] = (wsec_key_t *)wlc_calloc(unit,
-               (sizeof(wsec_key_t) * WLC_DEFAULT_KEYS));
+       wlc->wsec_def_keys[0] =
+               kzalloc(sizeof(wsec_key_t) * WLC_DEFAULT_KEYS, GFP_ATOMIC);
        if (wlc->wsec_def_keys[0] == NULL) {
                *err = 1015;
                goto fail;
@@ -246,21 +228,20 @@ struct wlc_info *wlc_attach_malloc(uint unit, uint *err, uint devid)
                }
        }
 
-       wlc->protection = wlc_calloc(unit,
-               sizeof(struct wlc_protection));
+       wlc->protection = kzalloc(sizeof(struct wlc_protection), GFP_ATOMIC);
        if (wlc->protection == NULL) {
                *err = 1016;
                goto fail;
        }
 
-       wlc->stf = wlc_calloc(unit, sizeof(struct wlc_stf));
+       wlc->stf = kzalloc(sizeof(struct wlc_stf), GFP_ATOMIC);
        if (wlc->stf == NULL) {
                *err = 1017;
                goto fail;
        }
 
-       wlc->bandstate[0] = (struct wlcband *)wlc_calloc(unit,
-                               (sizeof(struct wlcband)*MAXBANDS));
+       wlc->bandstate[0] =
+               kzalloc(sizeof(struct wlcband)*MAXBANDS, GFP_ATOMIC);
        if (wlc->bandstate[0] == NULL) {
                *err = 1025;
                goto fail;
@@ -274,15 +255,14 @@ struct wlc_info *wlc_attach_malloc(uint unit, uint *err, uint devid)
                }
        }
 
-       wlc->corestate = (struct wlccore *)wlc_calloc(unit,
-                                                     sizeof(struct wlccore));
+       wlc->corestate = kzalloc(sizeof(struct wlccore), GFP_ATOMIC);
        if (wlc->corestate == NULL) {
                *err = 1026;
                goto fail;
        }
 
        wlc->corestate->macstat_snapshot =
-               (macstat_t *)wlc_calloc(unit, sizeof(macstat_t));
+               kzalloc(sizeof(macstat_t), GFP_ATOMIC);
        if (wlc->corestate->macstat_snapshot == NULL) {
                *err = 1027;
                goto fail;
index 1fb7430b26a970473b64bbae33feb8e9589ffbf7..95f951eb2b2fe523a69750cf1ea545c341c4db19 100644 (file)
@@ -14,7 +14,5 @@
  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-extern void *wlc_calloc(uint unit, uint size);
-
 extern struct wlc_info *wlc_attach_malloc(uint unit, uint *err, uint devid);
 extern void wlc_detach_mfree(struct wlc_info *wlc);
index f00865957881a51ec783cba4b51d5cc27ee1791c..85ad7009605690a51229043eec50cb83ca6bc3e7 100644 (file)
@@ -18,7 +18,7 @@
 
 #include <bcmdefs.h>
 #include <bcmutils.h>
-#include <siutils.h>
+#include <aiutils.h>
 #include <wlioctl.h>
 #include <sbhnddma.h>
 #include <hnddma.h>
 #include "wlc_main.h"
 #include "wlc_ampdu.h"
 
-/*
- *     Disable AMPDU statistics counters for now
- */
-#define WLCNTINCR(a)
-#define WLCNTADD(a, b)
-
 #define AMPDU_MAX_MPDU         32      /* max number of mpdus in an ampdu */
 #define AMPDU_NUM_MPDU_LEGACY  16      /* max number of mpdus in an ampdu to a legacy */
 #define AMPDU_TX_BA_MAX_WSIZE  64      /* max Tx ba window size (in pdu) */
        AMPDU_DELIMITER_LEN + 3\
        + DOT11_A4_HDR_LEN + DOT11_QOS_LEN + DOT11_IV_MAX_LEN)
 
-#ifdef BCMDBG
-u32 wl_ampdu_dbg =
-    WL_AMPDU_UPDN_VAL |
-    WL_AMPDU_ERR_VAL |
-    WL_AMPDU_TX_VAL |
-    WL_AMPDU_RX_VAL |
-    WL_AMPDU_CTL_VAL |
-    WL_AMPDU_HW_VAL | WL_AMPDU_HWTXS_VAL | WL_AMPDU_HWDBG_VAL;
-#endif
-
 /* structure to hold tx fifo information and pre-loading state
  * counters specific to tx underflows of ampdus
  * some counters might be redundant with the ones in wlc or ampdu structures.
@@ -130,6 +114,12 @@ struct ampdu_info {
 
 };
 
+/* used for flushing ampdu packets */
+struct cb_del_ampdu_pars {
+       struct ieee80211_sta *sta;
+       u16 tid;
+};
+
 #define AMPDU_CLEANUPFLAG_RX   (0x1)
 #define AMPDU_CLEANUPFLAG_TX   (0x2)
 
@@ -143,9 +133,6 @@ static void wlc_ffpld_calc_mcs2ampdu_table(struct ampdu_info *ampdu, int f);
 static scb_ampdu_tid_ini_t *wlc_ampdu_init_tid_ini(struct ampdu_info *ampdu,
                                                   scb_ampdu_t *scb_ampdu,
                                                   u8 tid, bool override);
-static void ampdu_cleanup_tid_ini(struct ampdu_info *ampdu,
-                                 scb_ampdu_t *scb_ampdu,
-                                 u8 tid, bool force);
 static void ampdu_update_max_txlen(struct ampdu_info *ampdu, u8 dur);
 static void scb_ampdu_update_config(struct ampdu_info *ampdu, struct scb *scb);
 static void scb_ampdu_update_config_all(struct ampdu_info *ampdu);
@@ -164,17 +151,10 @@ struct ampdu_info *wlc_ampdu_attach(struct wlc_info *wlc)
        struct ampdu_info *ampdu;
        int i;
 
-       /* some code depends on packed structures */
-       ASSERT(DOT11_MAXNUMFRAGS == NBITS(u16));
-       ASSERT(ISPOWEROF2(AMPDU_TX_BA_MAX_WSIZE));
-       ASSERT(ISPOWEROF2(AMPDU_RX_BA_MAX_WSIZE));
-       ASSERT(wlc->pub->tunables->ampdunummpdu <= AMPDU_MAX_MPDU);
-       ASSERT(wlc->pub->tunables->ampdunummpdu > 0);
-
        ampdu = kzalloc(sizeof(struct ampdu_info), GFP_ATOMIC);
        if (!ampdu) {
-               WL_ERROR("wl%d: wlc_ampdu_attach: out of mem\n",
-                        wlc->pub->unit);
+               wiphy_err(wlc->wiphy, "wl%d: wlc_ampdu_attach: out of mem\n",
+                         wlc->pub->unit);
                return NULL;
        }
        ampdu->wlc = wlc;
@@ -237,27 +217,6 @@ void wlc_ampdu_detach(struct ampdu_info *ampdu)
        kfree(ampdu);
 }
 
-void scb_ampdu_cleanup(struct ampdu_info *ampdu, struct scb *scb)
-{
-       scb_ampdu_t *scb_ampdu = SCB_AMPDU_CUBBY(ampdu, scb);
-       u8 tid;
-
-       WL_AMPDU_UPDN("scb_ampdu_cleanup: enter\n");
-       ASSERT(scb_ampdu);
-
-       for (tid = 0; tid < AMPDU_MAX_SCB_TID; tid++) {
-               ampdu_cleanup_tid_ini(ampdu, scb_ampdu, tid, false);
-       }
-}
-
-/* reset the ampdu state machine so that it can gracefully handle packets that were
- * freed from the dma and tx queues during reinit
- */
-void wlc_ampdu_reset(struct ampdu_info *ampdu)
-{
-       WL_NONE("%s: Entering\n", __func__);
-}
-
 static void scb_ampdu_update_config(struct ampdu_info *ampdu, struct scb *scb)
 {
        scb_ampdu_t *scb_ampdu = SCB_AMPDU_CUBBY(ampdu, scb);
@@ -284,11 +243,9 @@ static void scb_ampdu_update_config(struct ampdu_info *ampdu, struct scb *scb)
        scb_ampdu->release = min(scb_ampdu->release,
                                 ampdu->fifo_tb[TX_AC_BE_FIFO].
                                 mcs2ampdu_table[FFPLD_MAX_MCS]);
-
-       ASSERT(scb_ampdu->release);
 }
 
-void scb_ampdu_update_config_all(struct ampdu_info *ampdu)
+static void scb_ampdu_update_config_all(struct ampdu_info *ampdu)
 {
        scb_ampdu_update_config(ampdu, ampdu->wlc->pub->global_scb);
 }
@@ -336,7 +293,7 @@ static int wlc_ffpld_check_txfunfl(struct wlc_info *wlc, int fid)
                         M_UCODE_MACSTAT + offsetof(macstat_t, txfunfl[fid]));
        new_txunfl = (u16) (cur_txunfl - fifo->prev_txfunfl);
        if (new_txunfl == 0) {
-               WL_FFPLD("check_txunfl : TX status FRAG set but no tx underflows\n");
+               BCMMSG(wlc->wiphy, "TX status FRAG set but no tx underflows\n");
                return -1;
        }
        fifo->prev_txfunfl = cur_txunfl;
@@ -346,7 +303,6 @@ static int wlc_ffpld_check_txfunfl(struct wlc_info *wlc, int fid)
 
        /* check if fifo is big enough */
        if (wlc_xmtfifo_sz_get(wlc, fid, &xmtfifo_sz)) {
-               WL_FFPLD("check_txunfl : get xmtfifo_sz failed\n");
                return -1;
        }
 
@@ -360,8 +316,8 @@ static int wlc_ffpld_check_txfunfl(struct wlc_info *wlc, int fid)
        if (fifo->accum_txfunfl < 10)
                return 0;
 
-       WL_FFPLD("ampdu_count %d  tx_underflows %d\n",
-                current_ampdu_cnt, fifo->accum_txfunfl);
+       BCMMSG(wlc->wiphy, "ampdu_count %d  tx_underflows %d\n",
+               current_ampdu_cnt, fifo->accum_txfunfl);
 
        /*
           compute the current ratio of tx unfl per ampdu.
@@ -388,7 +344,6 @@ static int wlc_ffpld_check_txfunfl(struct wlc_info *wlc, int fid)
         */
 
        if (fifo->ampdu_pld_size >= max_mpdu * FFPLD_MPDU_SIZE) {
-               WL_FFPLD(("tx fifo pld : max ampdu fits in fifo\n)"));
                fifo->accum_txfunfl = 0;
                return 0;
        }
@@ -406,7 +361,7 @@ static int wlc_ffpld_check_txfunfl(struct wlc_info *wlc, int fid)
                /*
                   compute a new dma xfer rate for max_mpdu @ max mcs.
                   This is the minimum dma rate that
-                  can achieve no unferflow condition for the current mpdu size.
+                  can achieve no underflow condition for the current mpdu size.
                 */
                /* note : we divide/multiply by 100 to avoid integer overflows */
                fifo->dmaxferrate =
@@ -414,8 +369,9 @@ static int wlc_ffpld_check_txfunfl(struct wlc_info *wlc, int fid)
                      (max_mpdu * FFPLD_MPDU_SIZE - fifo->ampdu_pld_size))
                     / (max_mpdu * FFPLD_MPDU_SIZE)) * 100;
 
-               WL_FFPLD("DMA estimated transfer rate %d; pre-load size %d\n",
-                        fifo->dmaxferrate, fifo->ampdu_pld_size);
+               BCMMSG(wlc->wiphy, "DMA estimated transfer rate %d; "
+                       "pre-load size %d\n",
+                       fifo->dmaxferrate, fifo->ampdu_pld_size);
        } else {
 
                /* decrease ampdu size */
@@ -469,7 +425,7 @@ static void wlc_ffpld_calc_mcs2ampdu_table(struct ampdu_info *ampdu, int f)
        }
 }
 
-static void BCMFASTPATH
+static void
 wlc_ampdu_agg(struct ampdu_info *ampdu, struct scb *scb, struct sk_buff *p,
              uint prec)
 {
@@ -487,7 +443,7 @@ wlc_ampdu_agg(struct ampdu_info *ampdu, struct scb *scb, struct sk_buff *p,
        return;
 }
 
-int BCMFASTPATH
+int
 wlc_sendampdu(struct ampdu_info *ampdu, struct wlc_txq_info *qi,
              struct sk_buff **pdu, int prec)
 {
@@ -521,35 +477,31 @@ wlc_sendampdu(struct ampdu_info *ampdu, struct wlc_txq_info *qi,
        bool fbr_iscck;
        struct ieee80211_tx_info *tx_info;
        u16 qlen;
+       struct wiphy *wiphy;
 
        wlc = ampdu->wlc;
+       wiphy = wlc->wiphy;
        p = *pdu;
 
-       ASSERT(p);
-
        tid = (u8) (p->priority);
-       ASSERT(tid < AMPDU_MAX_SCB_TID);
 
        f = ampdu->fifo_tb + prio2fifo[tid];
 
        scb = wlc->pub->global_scb;
-       ASSERT(scb->magic == SCB_MAGIC);
-
        scb_ampdu = SCB_AMPDU_CUBBY(ampdu, scb);
-       ASSERT(scb_ampdu);
        ini = &scb_ampdu->ini[tid];
 
        /* Let pressure continue to build ... */
        qlen = pktq_plen(&qi->q, prec);
        if (ini->tx_in_transit > 0 && qlen < scb_ampdu->max_pdu) {
-               return BCME_BUSY;
+               return -EBUSY;
        }
 
        wlc_ampdu_agg(ampdu, scb, p, tid);
 
        if (wlc->block_datafifo) {
-               WL_ERROR("%s: Fifo blocked\n", __func__);
-               return BCME_BUSY;
+               wiphy_err(wiphy, "%s: Fifo blocked\n", __func__);
+               return -EBUSY;
        }
        rr_retry_limit = ampdu->rr_retry_limit_tid[tid];
        ampdu_len = 0;
@@ -563,32 +515,29 @@ wlc_sendampdu(struct ampdu_info *ampdu, struct wlc_txq_info *qi,
                if (tx_info->flags & IEEE80211_TX_CTL_AMPDU) {
                        err = wlc_prep_pdu(wlc, p, &fifo);
                } else {
-                       WL_ERROR("%s: AMPDU flag is off!\n", __func__);
+                       wiphy_err(wiphy, "%s: AMPDU flag is off!\n", __func__);
                        *pdu = NULL;
                        err = 0;
                        break;
                }
 
                if (err) {
-                       if (err == BCME_BUSY) {
-                               WL_ERROR("wl%d: wlc_sendampdu: prep_xdu retry; seq 0x%x\n",
-                                        wlc->pub->unit, seq);
-                               WLCNTINCR(ampdu->cnt->sduretry);
+                       if (err == -EBUSY) {
+                               wiphy_err(wiphy, "wl%d: wlc_sendampdu: "
+                                         "prep_xdu retry; seq 0x%x\n",
+                                         wlc->pub->unit, seq);
                                *pdu = p;
                                break;
                        }
 
                        /* error in the packet; reject it */
-                       WL_AMPDU_ERR("wl%d: wlc_sendampdu: prep_xdu rejected; seq 0x%x\n",
-                                    wlc->pub->unit, seq);
-                       WLCNTINCR(ampdu->cnt->sdurejected);
-
+                       wiphy_err(wiphy, "wl%d: wlc_sendampdu: prep_xdu "
+                                 "rejected; seq 0x%x\n", wlc->pub->unit, seq);
                        *pdu = NULL;
                        break;
                }
 
                /* pkt is good to be aggregated */
-               ASSERT(tx_info->flags & IEEE80211_TX_CTL_AMPDU);
                txh = (d11txh_t *) p->data;
                plcp = (u8 *) (txh + 1);
                h = (struct ieee80211_hdr *)(plcp + D11_PHY_HDR_LEN);
@@ -599,7 +548,6 @@ wlc_sendampdu(struct ampdu_info *ampdu, struct wlc_txq_info *qi,
                mcl = le16_to_cpu(txh->MacTxControlLow);
                mcl &= ~TXC_AMPDU_MASK;
                fbr_iscck = !(le16_to_cpu(txh->XtraFrameTypes) & 0x3);
-               ASSERT(!fbr_iscck);
                txh->PreloadSize = 0;   /* always default to 0 */
 
                /*  Handle retry limits */
@@ -607,7 +555,6 @@ wlc_sendampdu(struct ampdu_info *ampdu, struct wlc_txq_info *qi,
                        txrate[0].count++;
                        rr = true;
                        fbr = false;
-                       ASSERT(!fbr);
                } else {
                        fbr = true;
                        rr = false;
@@ -622,8 +569,8 @@ wlc_sendampdu(struct ampdu_info *ampdu, struct wlc_txq_info *qi,
                ndelim = txh->RTSPLCPFallback[AMPDU_FBR_NULL_DELIM];
                seg_cnt += 1;
 
-               WL_AMPDU_TX("wl%d: wlc_sendampdu: mpdu %d plcp_len %d\n",
-                           wlc->pub->unit, count, len);
+               BCMMSG(wlc->wiphy, "wl%d: mpdu %d plcp_len %d\n",
+                       wlc->pub->unit, count, len);
 
                /*
                 * aggregateable mpdu. For ucode/hw agg,
@@ -651,10 +598,11 @@ wlc_sendampdu(struct ampdu_info *ampdu, struct wlc_txq_info *qi,
                len = roundup(len, 4);
                ampdu_len += (len + (ndelim + 1) * AMPDU_DELIMITER_LEN);
 
-               dma_len += (u16) pkttotlen(p);
+               dma_len += (u16) bcm_pkttotlen(p);
 
-               WL_AMPDU_TX("wl%d: wlc_sendampdu: ampdu_len %d seg_cnt %d null delim %d\n",
-                           wlc->pub->unit, ampdu_len, seg_cnt, ndelim);
+               BCMMSG(wlc->wiphy, "wl%d: ampdu_len %d"
+                       " seg_cnt %d null delim %d\n",
+                       wlc->pub->unit, ampdu_len, seg_cnt, ndelim);
 
                txh->MacTxControlLow = cpu_to_le16(mcl);
 
@@ -679,15 +627,14 @@ wlc_sendampdu(struct ampdu_info *ampdu, struct wlc_txq_info *qi,
                        is40 = (plcp0 & MIMO_PLCP_40MHZ) ? 1 : 0;
                        sgi = PLCP3_ISSGI(plcp3) ? 1 : 0;
                        mcs = plcp0 & ~MIMO_PLCP_40MHZ;
-                       ASSERT(mcs < MCS_TABLE_SIZE);
                        maxlen =
                            min(scb_ampdu->max_rxlen,
                                ampdu->max_txlen[mcs][is40][sgi]);
 
-                       WL_NONE("sendampdu: sgi %d, is40 %d, mcs %d\n",
-                               sgi, is40, mcs);
-
-                       maxlen = 64 * 1024;     /* XXX Fix me to honor real max_rxlen */
+                       /* XXX Fix me to honor real max_rxlen */
+                       /* can fix this as soon as ampdu_action() in mac80211.h
+                        * gets extra u8buf_size par */
+                       maxlen = 64 * 1024;
 
                        if (is40)
                                mimo_ctlchbw =
@@ -728,14 +675,13 @@ wlc_sendampdu(struct ampdu_info *ampdu, struct wlc_txq_info *qi,
                /* test whether to add more */
                if ((MCS_RATE(mcs, true, false) >= f->dmaxferrate) &&
                    (count == f->mcs2ampdu_table[mcs])) {
-                       WL_AMPDU_ERR("wl%d: PR 37644: stopping ampdu at %d for mcs %d\n",
-                                    wlc->pub->unit, count, mcs);
+                       BCMMSG(wlc->wiphy, "wl%d: PR 37644: stopping"
+                               " ampdu at %d for mcs %d\n",
+                               wlc->pub->unit, count, mcs);
                        break;
                }
 
                if (count == scb_ampdu->max_pdu) {
-                       WL_NONE("Stop taking from q, reached %d deep\n",
-                               scb_ampdu->max_pdu);
                        break;
                }
 
@@ -748,26 +694,24 @@ wlc_sendampdu(struct ampdu_info *ampdu, struct wlc_txq_info *qi,
                            ((u8) (p->priority) == tid)) {
 
                                plen =
-                                   pkttotlen(p) + AMPDU_MAX_MPDU_OVERHEAD;
+                                   bcm_pkttotlen(p) + AMPDU_MAX_MPDU_OVERHEAD;
                                plen = max(scb_ampdu->min_len, plen);
 
                                if ((plen + ampdu_len) > maxlen) {
                                        p = NULL;
-                                       WL_ERROR("%s: Bogus plen #1\n",
-                                                __func__);
-                                       ASSERT(3 == 4);
+                                       wiphy_err(wiphy, "%s: Bogus plen #1\n",
+                                               __func__);
                                        continue;
                                }
 
                                /* check if there are enough descriptors available */
                                if (TXAVAIL(wlc, fifo) <= (seg_cnt + 1)) {
-                                       WL_ERROR("%s: No fifo space   !!!!!!\n",
-                                                __func__);
+                                       wiphy_err(wiphy, "%s: No fifo space  "
+                                                 "!!\n", __func__);
                                        p = NULL;
                                        continue;
                                }
-                               p = pktq_pdeq(&qi->q, prec);
-                               ASSERT(p);
+                               p = bcm_pktq_pdeq(&qi->q, prec);
                        } else {
                                p = NULL;
                        }
@@ -777,8 +721,6 @@ wlc_sendampdu(struct ampdu_info *ampdu, struct wlc_txq_info *qi,
        ini->tx_in_transit += count;
 
        if (count) {
-               WLCNTADD(ampdu->cnt->txmpdu, count);
-
                /* patch up the last txh */
                txh = (d11txh_t *) pkt[count - 1]->data;
                mcl = le16_to_cpu(txh->MacTxControlLow);
@@ -861,22 +803,20 @@ wlc_sendampdu(struct ampdu_info *ampdu, struct wlc_txq_info *qi,
 
                /* set flag and plcp for fallback rate */
                if (fbr) {
-                       WLCNTADD(ampdu->cnt->txfbr_mpdu, count);
-                       WLCNTINCR(ampdu->cnt->txfbr_ampdu);
                        mch |= TXC_AMPDU_FBR;
                        txh->MacTxControlHigh = cpu_to_le16(mch);
                        WLC_SET_MIMO_PLCP_AMPDU(plcp);
                        WLC_SET_MIMO_PLCP_AMPDU(txh->FragPLCPFallback);
                }
 
-               WL_AMPDU_TX("wl%d: wlc_sendampdu: count %d ampdu_len %d\n",
-                           wlc->pub->unit, count, ampdu_len);
+               BCMMSG(wlc->wiphy, "wl%d: count %d ampdu_len %d\n",
+                       wlc->pub->unit, count, ampdu_len);
 
                /* inform rate_sel if it this is a rate probe pkt */
                frameid = le16_to_cpu(txh->TxFrameID);
                if (frameid & TXFID_RATE_PROBE_MASK) {
-                       WL_ERROR("%s: XXX what to do with TXFID_RATE_PROBE_MASK!?\n",
-                                __func__);
+                       wiphy_err(wiphy, "%s: XXX what to do with "
+                                 "TXFID_RATE_PROBE_MASK!?\n", __func__);
                }
                for (i = 0; i < count; i++)
                        wlc_txfifo(wlc, fifo, pkt[i], i == (count - 1),
@@ -887,7 +827,7 @@ wlc_sendampdu(struct ampdu_info *ampdu, struct wlc_txq_info *qi,
        return err;
 }
 
-void BCMFASTPATH
+void
 wlc_ampdu_dotxstatus(struct ampdu_info *ampdu, struct scb *scb,
                     struct sk_buff *p, tx_status_t *txs)
 {
@@ -898,8 +838,6 @@ wlc_ampdu_dotxstatus(struct ampdu_info *ampdu, struct scb *scb,
        struct ieee80211_tx_info *tx_info;
 
        tx_info = IEEE80211_SKB_CB(p);
-       ASSERT(tx_info->flags & IEEE80211_TX_CTL_AMPDU);
-       ASSERT(txs->status & TX_STATUS_AMPDU);
 
        /* BMAC_NOTE: For the split driver, second level txstatus comes later
         * So if the ACK was received then wait for the second level else just
@@ -913,22 +851,16 @@ wlc_ampdu_dotxstatus(struct ampdu_info *ampdu, struct scb *scb,
                        udelay(1);
                        status_delay++;
                        if (status_delay > 10) {
-                               ASSERT(status_delay <= 10);
-                               return;
+                               return; /* error condition */
                        }
                }
 
-               ASSERT(!(s1 & TX_STATUS_INTERMEDIATE));
-               ASSERT(s1 & TX_STATUS_AMPDU);
                s2 = R_REG(&wlc->regs->frmtxstatus2);
        }
 
        if (likely(scb)) {
-               ASSERT(scb->magic == SCB_MAGIC);
                scb_ampdu = SCB_AMPDU_CUBBY(ampdu, scb);
-               ASSERT(scb_ampdu);
                ini = SCB_AMPDU_INI(scb_ampdu, p->priority);
-               ASSERT(ini->scb == scb);
                wlc_ampdu_dotxstatus_complete(ampdu, scb, p, txs, s1, s2);
        } else {
                /* loop through all pkts and free */
@@ -939,21 +871,19 @@ wlc_ampdu_dotxstatus(struct ampdu_info *ampdu, struct scb *scb,
                        tx_info = IEEE80211_SKB_CB(p);
                        txh = (d11txh_t *) p->data;
                        mcl = le16_to_cpu(txh->MacTxControlLow);
-                       ASSERT(tx_info->flags & IEEE80211_TX_CTL_AMPDU);
-                       pkt_buf_free_skb(p);
+                       bcm_pkt_buf_free_skb(p);
                        /* break out if last packet of ampdu */
                        if (((mcl & TXC_AMPDU_MASK) >> TXC_AMPDU_SHIFT) ==
                            TXC_AMPDU_LAST)
                                break;
                        p = GETNEXTTXP(wlc, queue);
-                       ASSERT(p != NULL);
                }
                wlc_txfifo_complete(wlc, queue, ampdu->txpkt_weight);
        }
        wlc_ampdu_txflowcontrol(wlc, scb_ampdu, ini);
 }
 
-void
+static void
 rate_status(struct wlc_info *wlc, struct ieee80211_tx_info *tx_info,
            tx_status_t *txs, u8 mcs)
 {
@@ -969,7 +899,7 @@ rate_status(struct wlc_info *wlc, struct ieee80211_tx_info *tx_info,
 
 #define SHORTNAME "AMPDU status"
 
-static void BCMFASTPATH
+static void
 wlc_ampdu_dotxstatus_complete(struct ampdu_info *ampdu, struct scb *scb,
                              struct sk_buff *p, tx_status_t *txs,
                              u32 s1, u32 s2)
@@ -991,30 +921,21 @@ wlc_ampdu_dotxstatus_complete(struct ampdu_info *ampdu, struct scb *scb,
        u8 antselid = 0;
        u8 retry_limit, rr_retry_limit;
        struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(p);
+       struct wiphy *wiphy = wlc->wiphy;
 
 #ifdef BCMDBG
        u8 hole[AMPDU_MAX_MPDU];
        memset(hole, 0, sizeof(hole));
 #endif
 
-       ASSERT(tx_info->flags & IEEE80211_TX_CTL_AMPDU);
-       ASSERT(txs->status & TX_STATUS_AMPDU);
-
        scb_ampdu = SCB_AMPDU_CUBBY(ampdu, scb);
-       ASSERT(scb_ampdu);
-
        tid = (u8) (p->priority);
 
        ini = SCB_AMPDU_INI(scb_ampdu, tid);
        retry_limit = ampdu->retry_limit_tid[tid];
        rr_retry_limit = ampdu->rr_retry_limit_tid[tid];
-
-       ASSERT(ini->scb == scb);
-
        memset(bitmap, 0, sizeof(bitmap));
        queue = txs->frameid & TXFID_QUEUE_MASK;
-       ASSERT(queue < AC_COUNT);
-
        supr_status = txs->status & TX_STATUS_SUPR_MASK;
 
        if (txs->status & TX_STATUS_ACK_RCV) {
@@ -1022,13 +943,13 @@ wlc_ampdu_dotxstatus_complete(struct ampdu_info *ampdu, struct scb *scb,
                        update_rate = false;
                }
 
-               ASSERT(txs->status & TX_STATUS_INTERMEDIATE);
+               WARN_ON(!(txs->status & TX_STATUS_INTERMEDIATE));
                start_seq = txs->sequence >> SEQNUM_SHIFT;
                bitmap[0] = (txs->status & TX_STATUS_BA_BMAP03_MASK) >>
                    TX_STATUS_BA_BMAP03_SHIFT;
 
-               ASSERT(!(s1 & TX_STATUS_INTERMEDIATE));
-               ASSERT(s1 & TX_STATUS_AMPDU);
+               WARN_ON(s1 & TX_STATUS_INTERMEDIATE);
+               WARN_ON(!(s1 & TX_STATUS_AMPDU));
 
                bitmap[0] |=
                    (s1 & TX_STATUS_BA_BMAP47_MASK) <<
@@ -1044,30 +965,24 @@ wlc_ampdu_dotxstatus_complete(struct ampdu_info *ampdu, struct scb *scb,
 
                ba_recd = true;
        } else {
-               WLCNTINCR(ampdu->cnt->noba);
                if (supr_status) {
                        update_rate = false;
                        if (supr_status == TX_STATUS_SUPR_BADCH) {
-                               WL_ERROR("%s: Pkt tx suppressed, illegal channel possibly %d\n",
-                                        __func__,
-                                        CHSPEC_CHANNEL(wlc->default_bss->chanspec));
+                               wiphy_err(wiphy, "%s: Pkt tx suppressed, "
+                                         "illegal channel possibly %d\n",
+                                         __func__, CHSPEC_CHANNEL(
+                                         wlc->default_bss->chanspec));
                        } else {
-                               if (supr_status == TX_STATUS_SUPR_FRAG)
-                                       WL_NONE("%s: AMPDU frag err\n",
-                                               __func__);
-                               else
-                                       WL_ERROR("%s: wlc_ampdu_dotxstatus: supr_status 0x%x\n",
+                               if (supr_status != TX_STATUS_SUPR_FRAG)
+                                       wiphy_err(wiphy, "%s: wlc_ampdu_dotx"
+                                                 "status:supr_status 0x%x\n",
                                                 __func__, supr_status);
                        }
                        /* no need to retry for badch; will fail again */
                        if (supr_status == TX_STATUS_SUPR_BADCH ||
                            supr_status == TX_STATUS_SUPR_EXPTIME) {
                                retry = false;
-                               wlc->pub->_cnt->txchanrej++;
                        } else if (supr_status == TX_STATUS_SUPR_EXPTIME) {
-
-                               wlc->pub->_cnt->txexptime++;
-
                                /* TX underflow : try tuning pre-loading or ampdu size */
                        } else if (supr_status == TX_STATUS_SUPR_FRAG) {
                                /* if there were underflows, but pre-loading is not active,
@@ -1080,12 +995,12 @@ wlc_ampdu_dotxstatus_complete(struct ampdu_info *ampdu, struct scb *scb,
                        }
                } else if (txs->phyerr) {
                        update_rate = false;
-                       wlc->pub->_cnt->txphyerr++;
-                       WL_ERROR("wl%d: wlc_ampdu_dotxstatus: tx phy error (0x%x)\n",
-                                wlc->pub->unit, txs->phyerr);
+                       wiphy_err(wiphy, "wl%d: wlc_ampdu_dotxstatus: tx phy "
+                                 "error (0x%x)\n", wlc->pub->unit,
+                                 txs->phyerr);
 
                        if (WL_ERROR_ON()) {
-                               prpkt("txpkt (AMPDU)", p);
+                               bcm_prpkt("txpkt (AMPDU)", p);
                                wlc_print_txdesc((d11txh_t *) p->data);
                        }
                        wlc_print_txstatus(txs);
@@ -1095,7 +1010,6 @@ wlc_ampdu_dotxstatus_complete(struct ampdu_info *ampdu, struct scb *scb,
        /* loop through all pkts and retry if not acked */
        while (p) {
                tx_info = IEEE80211_SKB_CB(p);
-               ASSERT(tx_info->flags & IEEE80211_TX_CTL_AMPDU);
                txh = (d11txh_t *) p->data;
                mcl = le16_to_cpu(txh->MacTxControlLow);
                plcp = (u8 *) (txh + 1);
@@ -1111,11 +1025,10 @@ wlc_ampdu_dotxstatus_complete(struct ampdu_info *ampdu, struct scb *scb,
                ack_recd = false;
                if (ba_recd) {
                        bindex = MODSUB_POW2(seq, start_seq, SEQNUM_MAX);
-
-                       WL_AMPDU_TX("%s: tid %d seq is %d, start_seq is %d, bindex is %d set %d, index %d\n",
-                                   __func__, tid, seq, start_seq, bindex,
-                                   isset(bitmap, bindex), index);
-
+                       BCMMSG(wlc->wiphy, "tid %d seq %d,"
+                               " start_seq %d, bindex %d set %d, index %d\n",
+                               tid, seq, start_seq, bindex,
+                               isset(bitmap, bindex), index);
                        /* if acked then clear bit and free packet */
                        if ((bindex < AMPDU_TX_BA_MAX_WSIZE)
                            && isset(bitmap, bindex)) {
@@ -1123,21 +1036,12 @@ wlc_ampdu_dotxstatus_complete(struct ampdu_info *ampdu, struct scb *scb,
                                ini->txretry[index] = 0;
 
                                /* ampdu_ack_len: number of acked aggregated frames */
-                               /* ampdu_ack_map: block ack bit map for the aggregation */
                                /* ampdu_len: number of aggregated frames */
                                rate_status(wlc, tx_info, txs, mcs);
                                tx_info->flags |= IEEE80211_TX_STAT_ACK;
                                tx_info->flags |= IEEE80211_TX_STAT_AMPDU;
-
-                               /* XXX TODO: Make these accurate. */
                                tx_info->status.ampdu_ack_len =
-                                   (txs->
-                                    status & TX_STATUS_FRM_RTX_MASK) >>
-                                   TX_STATUS_FRM_RTX_SHIFT;
-                               tx_info->status.ampdu_len =
-                                   (txs->
-                                    status & TX_STATUS_FRM_RTX_MASK) >>
-                                   TX_STATUS_FRM_RTX_SHIFT;
+                                       tx_info->status.ampdu_len = 1;
 
                                skb_pull(p, D11_PHY_HDR_LEN);
                                skb_pull(p, D11_TXH_LEN);
@@ -1163,12 +1067,15 @@ wlc_ampdu_dotxstatus_complete(struct ampdu_info *ampdu, struct scb *scb,
                                /* Retry timeout */
                                ini->tx_in_transit--;
                                ieee80211_tx_info_clear_status(tx_info);
+                               tx_info->status.ampdu_ack_len = 0;
+                               tx_info->status.ampdu_len = 1;
                                tx_info->flags |=
                                    IEEE80211_TX_STAT_AMPDU_NO_BACK;
                                skb_pull(p, D11_PHY_HDR_LEN);
                                skb_pull(p, D11_TXH_LEN);
-                               WL_ERROR("%s: BA Timeout, seq %d, in_transit %d\n",
-                                        SHORTNAME, seq, ini->tx_in_transit);
+                               wiphy_err(wiphy, "%s: BA Timeout, seq %d, in_"
+                                       "transit %d\n", SHORTNAME, seq,
+                                       ini->tx_in_transit);
                                ieee80211_tx_status_irqsafe(wlc->pub->ieee_hw,
                                                            p);
                        }
@@ -1181,12 +1088,8 @@ wlc_ampdu_dotxstatus_complete(struct ampdu_info *ampdu, struct scb *scb,
                        break;
 
                p = GETNEXTTXP(wlc, queue);
-               if (p == NULL) {
-                       ASSERT(p);
-                       break;
-               }
        }
-       wlc_send_q(wlc, wlc->active_queue);
+       wlc_send_q(wlc);
 
        /* update rate state */
        antselid = wlc_antsel_antsel2id(wlc->asi, mimoantsel);
@@ -1194,28 +1097,6 @@ wlc_ampdu_dotxstatus_complete(struct ampdu_info *ampdu, struct scb *scb,
        wlc_txfifo_complete(wlc, queue, ampdu->txpkt_weight);
 }
 
-static void
-ampdu_cleanup_tid_ini(struct ampdu_info *ampdu, scb_ampdu_t *scb_ampdu, u8 tid,
-                     bool force)
-{
-       scb_ampdu_tid_ini_t *ini;
-       ini = SCB_AMPDU_INI(scb_ampdu, tid);
-       if (!ini)
-               return;
-
-       WL_AMPDU_CTL("wl%d: ampdu_cleanup_tid_ini: tid %d\n",
-                    ampdu->wlc->pub->unit, tid);
-
-       if (ini->tx_in_transit && !force)
-               return;
-
-       scb_ampdu = SCB_AMPDU_CUBBY(ampdu, ini->scb);
-       ASSERT(ini == &scb_ampdu->ini[ini->tid]);
-
-       /* free all buffered tx packets */
-       pktq_pflush(&scb_ampdu->txq, ini->tid, true, NULL, 0);
-}
-
 /* initialize the initiator code for tid */
 static scb_ampdu_tid_ini_t *wlc_ampdu_init_tid_ini(struct ampdu_info *ampdu,
                                                   scb_ampdu_t *scb_ampdu,
@@ -1223,14 +1104,10 @@ static scb_ampdu_tid_ini_t *wlc_ampdu_init_tid_ini(struct ampdu_info *ampdu,
 {
        scb_ampdu_tid_ini_t *ini;
 
-       ASSERT(scb_ampdu);
-       ASSERT(scb_ampdu->scb);
-       ASSERT(SCB_AMPDU(scb_ampdu->scb));
-       ASSERT(tid < AMPDU_MAX_SCB_TID);
-
        /* check for per-tid control of ampdu */
        if (!ampdu->ini_enable[tid]) {
-               WL_ERROR("%s: Rejecting tid %d\n", __func__, tid);
+               wiphy_err(ampdu->wlc->wiphy, "%s: Rejecting tid %d\n",
+                         __func__, tid);
                return NULL;
        }
 
@@ -1238,8 +1115,6 @@ static scb_ampdu_tid_ini_t *wlc_ampdu_init_tid_ini(struct ampdu_info *ampdu,
        ini->tid = tid;
        ini->scb = scb_ampdu->scb;
        ini->magic = INI_MAGIC;
-       WLCNTINCR(ampdu->cnt->txaddbareq);
-
        return ini;
 }
 
@@ -1251,14 +1126,14 @@ static int wlc_ampdu_set(struct ampdu_info *ampdu, bool on)
 
        if (on) {
                if (!N_ENAB(wlc->pub)) {
-                       WL_AMPDU_ERR("wl%d: driver not nmode enabled\n",
-                                    wlc->pub->unit);
-                       return BCME_UNSUPPORTED;
+                       wiphy_err(ampdu->wlc->wiphy, "wl%d: driver not "
+                               "nmode enabled\n", wlc->pub->unit);
+                       return -ENOTSUPP;
                }
                if (!wlc_ampdu_cap(ampdu)) {
-                       WL_AMPDU_ERR("wl%d: device not ampdu capable\n",
-                                    wlc->pub->unit);
-                       return BCME_UNSUPPORTED;
+                       wiphy_err(ampdu->wlc->wiphy, "wl%d: device not "
+                               "ampdu capable\n", wlc->pub->unit);
+                       return -ENOTSUPP;
                }
                wlc->pub->_ampdu = on;
        }
@@ -1295,43 +1170,6 @@ static void ampdu_update_max_txlen(struct ampdu_info *ampdu, u8 dur)
        }
 }
 
-u8 BCMFASTPATH
-wlc_ampdu_null_delim_cnt(struct ampdu_info *ampdu, struct scb *scb,
-                        ratespec_t rspec, int phylen)
-{
-       scb_ampdu_t *scb_ampdu;
-       int bytes, cnt, tmp;
-       u8 tx_density;
-
-       ASSERT(scb);
-       ASSERT(SCB_AMPDU(scb));
-
-       scb_ampdu = SCB_AMPDU_CUBBY(ampdu, scb);
-       ASSERT(scb_ampdu);
-
-       if (scb_ampdu->mpdu_density == 0)
-               return 0;
-
-       /* RSPEC2RATE is in kbps units ==> ~RSPEC2RATE/2^13 is in bytes/usec
-          density x is in 2^(x-4) usec
-          ==> # of bytes needed for req density = rate/2^(17-x)
-          ==> # of null delimiters = ceil(ceil(rate/2^(17-x)) - phylen)/4)
-        */
-
-       tx_density = scb_ampdu->mpdu_density;
-
-       ASSERT(tx_density <= AMPDU_MAX_MPDU_DENSITY);
-       tmp = 1 << (17 - tx_density);
-       bytes = CEIL(RSPEC2RATE(rspec), tmp);
-
-       if (bytes > phylen) {
-               cnt = CEIL(bytes - phylen, AMPDU_DELIMITER_LEN);
-               ASSERT(cnt <= 255);
-               return (u8) cnt;
-       } else
-               return 0;
-}
-
 void wlc_ampdu_macaddr_upd(struct wlc_info *wlc)
 {
        char template[T_RAM_ACCESS_SZ * 2];
@@ -1363,17 +1201,11 @@ void wlc_ampdu_shm_upd(struct ampdu_info *ampdu)
        }
 }
 
-struct cb_del_ampdu_pars {
-       struct ieee80211_sta *sta;
-       u16 tid;
-};
-
 /*
  * callback function that helps flushing ampdu packets from a priority queue
  */
-static bool cb_del_ampdu_pkt(void *p, int arg_a)
+static bool cb_del_ampdu_pkt(struct sk_buff *mpdu, void *arg_a)
 {
-       struct sk_buff *mpdu = (struct sk_buff *)p;
        struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(mpdu);
        struct cb_del_ampdu_pars *ampdu_pars =
                                 (struct cb_del_ampdu_pars *)arg_a;
@@ -1406,7 +1238,7 @@ static void dma_cb_fn_ampdu(void *txi, void *arg_a)
 void wlc_ampdu_flush(struct wlc_info *wlc,
                     struct ieee80211_sta *sta, u16 tid)
 {
-       struct wlc_txq_info *qi = wlc->active_queue;
+       struct wlc_txq_info *qi = wlc->pkt_queue;
        struct pktq *pq = &qi->q;
        int prec;
        struct cb_del_ampdu_pars ampdu_pars;
@@ -1414,8 +1246,8 @@ void wlc_ampdu_flush(struct wlc_info *wlc,
        ampdu_pars.sta = sta;
        ampdu_pars.tid = tid;
        for (prec = 0; prec < pq->num_prec; prec++) {
-               pktq_pflush(pq, prec, true, cb_del_ampdu_pkt,
-                           (int)&ampdu_pars);
+               bcm_pktq_pflush(pq, prec, true, cb_del_ampdu_pkt,
+                           (void *)&ampdu_pars);
        }
        wlc_inval_dma_pkts(wlc->hw, sta, dma_cb_fn_ampdu);
 }
index 17e9ebc0dfe2c447375b10a2d6683410c0107d9d..63d403b036f463a692237236f6952c9168aa944b 100644 (file)
@@ -23,10 +23,7 @@ extern int wlc_sendampdu(struct ampdu_info *ampdu, struct wlc_txq_info *qi,
                         struct sk_buff **aggp, int prec);
 extern void wlc_ampdu_dotxstatus(struct ampdu_info *ampdu, struct scb *scb,
                                 struct sk_buff *p, tx_status_t *txs);
-extern void wlc_ampdu_reset(struct ampdu_info *ampdu);
 extern void wlc_ampdu_macaddr_upd(struct wlc_info *wlc);
 extern void wlc_ampdu_shm_upd(struct ampdu_info *ampdu);
-extern u8 wlc_ampdu_null_delim_cnt(struct ampdu_info *ampdu, struct scb *scb,
-                                     ratespec_t rspec, int phylen);
 
 #endif                         /* _wlc_ampdu_h_ */
index 85a73a978d4f34e1d371ef12a2b39f6f8721a3db..111ef32b7ac442f3493b1dc587a46c499fdc0e92 100644 (file)
@@ -22,7 +22,8 @@
 
 #include <bcmdefs.h>
 #include <bcmutils.h>
-#include <siutils.h>
+#include <bcmnvram.h>
+#include <aiutils.h>
 #include <bcmdevs.h>
 #include <sbhnddma.h>
 #include <wlioctl.h>
@@ -98,8 +99,8 @@ struct antsel_info *wlc_antsel_attach(struct wlc_info *wlc)
 
        asi = kzalloc(sizeof(struct antsel_info), GFP_ATOMIC);
        if (!asi) {
-               WL_ERROR("wl%d: wlc_antsel_attach: out of mem\n",
-                        wlc->pub->unit);
+               wiphy_err(wlc->wiphy, "wl%d: wlc_antsel_attach: out of mem\n",
+                         wlc->pub->unit);
                return NULL;
        }
 
@@ -128,8 +129,8 @@ struct antsel_info *wlc_antsel_attach(struct wlc_info *wlc)
                                asi->antsel_avail = false;
                        } else {
                                asi->antsel_avail = false;
-                               WL_ERROR("wlc_antsel_attach: 2o3 board cfg invalid\n");
-                               ASSERT(0);
+                               wiphy_err(wlc->wiphy, "wlc_antsel_attach: 2o3 "
+                                         "board cfg invalid\n");
                        }
                        break;
                default:
@@ -200,7 +201,7 @@ wlc_antsel_init_cfg(struct antsel_info *asi, wlc_antselcfg_t *antsel,
        }
 }
 
-void BCMFASTPATH
+void
 wlc_antsel_antcfg_get(struct antsel_info *asi, bool usedef, bool sel,
                      u8 antselid, u8 fbantselid, u8 *antcfg,
                      u8 *fbantcfg)
@@ -297,8 +298,6 @@ static int wlc_antsel_cfgupd(struct antsel_info *asi, wlc_antselcfg_t *antsel)
        u8 ant_cfg;
        u16 mimo_antsel;
 
-       ASSERT(asi->antsel_type != ANTSEL_NA);
-
        /* 1) Update TX antconfig for all frames that are not unicast data
         *    (aka default TX)
         */
index 4b6e181c7dc9cead08bb8d1e6b5da9922fba29db..453492610613490702125c66411d189558501188 100644 (file)
 #include <bcmdefs.h>
 #include <bcmdevs.h>
 #include <bcmwifi.h>
-#include <siutils.h>
+#include <aiutils.h>
 #include <bcmsrom.h>
 #include <bcmotp.h>
 #include <bcmutils.h>
+#include <bcmnvram.h>
 #include <wlioctl.h>
 #include <sbconfig.h>
 #include <sbchipc.h>
 #include <pcicfg.h>
 #include <sbhnddma.h>
 #include <hnddma.h>
-#include <hndpmu.h>
 
 #include "wlc_types.h"
+#include "wlc_pmu.h"
 #include "d11.h"
 #include "wlc_cfg.h"
 #include "wlc_rate.h"
@@ -200,6 +201,8 @@ static void wlc_bmac_update_slot_timing(struct wlc_hw_info *wlc_hw,
 
 static void WLBANDINITFN(wlc_ucode_bsinit) (struct wlc_hw_info *wlc_hw)
 {
+       struct wiphy *wiphy = wlc_hw->wlc->wiphy;
+
        /* init microcode host flags */
        wlc_write_mhf(wlc_hw, wlc_hw->band->mhfs);
 
@@ -208,20 +211,21 @@ static void WLBANDINITFN(wlc_ucode_bsinit) (struct wlc_hw_info *wlc_hw)
                if (WLCISNPHY(wlc_hw->band)) {
                        wlc_write_inits(wlc_hw, d11n0bsinitvals16);
                } else {
-                       WL_ERROR("%s: wl%d: unsupported phy in corerev %d\n",
-                                __func__, wlc_hw->unit, wlc_hw->corerev);
+                       wiphy_err(wiphy, "%s: wl%d: unsupported phy in corerev"
+                                 " %d\n", __func__, wlc_hw->unit,
+                                 wlc_hw->corerev);
                }
        } else {
                if (D11REV_IS(wlc_hw->corerev, 24)) {
                        if (WLCISLCNPHY(wlc_hw->band)) {
                                wlc_write_inits(wlc_hw, d11lcn0bsinitvals24);
                        } else
-                               WL_ERROR("%s: wl%d: unsupported phy in corerev %d\n",
-                                        __func__, wlc_hw->unit,
-                                        wlc_hw->corerev);
+                               wiphy_err(wiphy, "%s: wl%d: unsupported phy in"
+                                         " core rev %d\n", __func__,
+                                         wlc_hw->unit, wlc_hw->corerev);
                } else {
-                       WL_ERROR("%s: wl%d: unsupported corerev %d\n",
-                                __func__, wlc_hw->unit, wlc_hw->corerev);
+                       wiphy_err(wiphy, "%s: wl%d: unsupported corerev %d\n",
+                               __func__, wlc_hw->unit, wlc_hw->corerev);
                }
        }
 }
@@ -232,12 +236,9 @@ static u32 WLBANDINITFN(wlc_setband_inact) (struct wlc_info *wlc, uint bandunit)
        struct wlc_hw_info *wlc_hw = wlc->hw;
        u32 macintmask;
 
-       WL_TRACE("wl%d: wlc_setband_inact\n", wlc_hw->unit);
+       BCMMSG(wlc->wiphy, "wl%d\n", wlc_hw->unit);
 
-       ASSERT(bandunit != wlc_hw->band->bandunit);
-       ASSERT(si_iscoreup(wlc_hw->sih));
-       ASSERT((R_REG(&wlc_hw->regs->maccontrol) & MCTL_EN_MAC) ==
-              0);
+       WARN_ON((R_REG(&wlc_hw->regs->maccontrol) & MCTL_EN_MAC) != 0);
 
        /* disable interrupts */
        macintmask = wl_intrsoff(wlc->wl);
@@ -245,8 +246,6 @@ static u32 WLBANDINITFN(wlc_setband_inact) (struct wlc_info *wlc, uint bandunit)
        /* radio off */
        wlc_phy_switch_radio(wlc_hw->band->pi, OFF);
 
-       ASSERT(wlc_hw->clk);
-
        wlc_bmac_core_phy_clk(wlc_hw, OFF);
 
        wlc_setxband(wlc_hw, bandunit);
@@ -259,7 +258,7 @@ static u32 WLBANDINITFN(wlc_setband_inact) (struct wlc_info *wlc, uint bandunit)
  * Return true if more frames need to be processed. false otherwise.
  * Param 'bound' indicates max. # frames to process before break out.
  */
-static bool BCMFASTPATH
+static bool
 wlc_bmac_recv(struct wlc_hw_info *wlc_hw, uint fifo, bool bound)
 {
        struct sk_buff *p;
@@ -267,10 +266,9 @@ wlc_bmac_recv(struct wlc_hw_info *wlc_hw, uint fifo, bool bound)
        struct sk_buff *tail = NULL;
        uint n = 0;
        uint bound_limit = bound ? wlc_hw->wlc->pub->tunables->rxbnd : -1;
-       u32 tsf_h, tsf_l;
        wlc_d11rxhdr_t *wlc_rxhdr = NULL;
 
-       WL_TRACE("wl%d: %s\n", wlc_hw->unit, __func__);
+       BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit);
        /* gather received frames */
        while ((p = dma_rx(wlc_hw->di[fifo]))) {
 
@@ -286,9 +284,6 @@ wlc_bmac_recv(struct wlc_hw_info *wlc_hw, uint fifo, bool bound)
                        break;
        }
 
-       /* get the TSF REG reading */
-       wlc_bmac_read_tsf(wlc_hw, &tsf_l, &tsf_h);
-
        /* post more rbufs */
        dma_rxfill(wlc_hw->di[fifo]);
 
@@ -297,9 +292,7 @@ wlc_bmac_recv(struct wlc_hw_info *wlc_hw, uint fifo, bool bound)
                head = head->prev;
                p->prev = NULL;
 
-               /* record the tsf_l in wlc_rxd11hdr */
                wlc_rxhdr = (wlc_d11rxhdr_t *) p->data;
-               wlc_rxhdr->tsf_l = cpu_to_le32(tsf_l);
 
                /* compute the RSSI from d11rxhdr and record it in wlc_rxd11hr */
                wlc_phy_rssi_compute(wlc_hw->band->pi, wlc_rxhdr);
@@ -314,15 +307,17 @@ wlc_bmac_recv(struct wlc_hw_info *wlc_hw, uint fifo, bool bound)
  *   Return true if another dpc needs to be re-scheduled. false otherwise.
  *   Param 'bounded' indicates if applicable loops should be bounded.
  */
-bool BCMFASTPATH wlc_dpc(struct wlc_info *wlc, bool bounded)
+bool wlc_dpc(struct wlc_info *wlc, bool bounded)
 {
        u32 macintstatus;
        struct wlc_hw_info *wlc_hw = wlc->hw;
        d11regs_t *regs = wlc_hw->regs;
        bool fatal = false;
+       struct wiphy *wiphy = wlc->wiphy;
 
        if (DEVICEREMOVED(wlc)) {
-               WL_ERROR("wl%d: %s: dead chip\n", wlc_hw->unit, __func__);
+               wiphy_err(wiphy, "wl%d: %s: dead chip\n", wlc_hw->unit,
+                         __func__);
                wl_down(wlc->wl);
                return false;
        }
@@ -331,13 +326,10 @@ bool BCMFASTPATH wlc_dpc(struct wlc_info *wlc, bool bounded)
        macintstatus = wlc->macintstatus;
        wlc->macintstatus = 0;
 
-       WL_TRACE("wl%d: wlc_dpc: macintstatus 0x%x\n",
-                wlc_hw->unit, macintstatus);
+       BCMMSG(wlc->wiphy, "wl%d: macintstatus 0x%x\n",
+              wlc_hw->unit, macintstatus);
 
-       if (macintstatus & MI_PRQ) {
-               /* Process probe request FIFO */
-               ASSERT(0 && "PRQ Interrupt in non-MBSS");
-       }
+       WARN_ON(macintstatus & MI_PRQ); /* PRQ Interrupt in non-MBSS */
 
        /* BCN template is available */
        /* ZZZ: Use AP_ACTIVE ? */
@@ -355,7 +347,7 @@ bool BCMFASTPATH wlc_dpc(struct wlc_info *wlc, bool bounded)
                if (wlc_bmac_txstatus(wlc->hw, bounded, &fatal))
                        wlc->macintstatus |= MI_TFS;
                if (fatal) {
-                       WL_ERROR("MI_TFS: fatal\n");
+                       wiphy_err(wiphy, "MI_TFS: fatal\n");
                        goto fatal;
                }
        }
@@ -365,17 +357,11 @@ bool BCMFASTPATH wlc_dpc(struct wlc_info *wlc, bool bounded)
 
        /* ATIM window end */
        if (macintstatus & MI_ATIMWINEND) {
-               WL_TRACE("wlc_isr: end of ATIM window\n");
-
+               BCMMSG(wlc->wiphy, "end of ATIM window\n");
                OR_REG(&regs->maccommand, wlc->qvalid);
                wlc->qvalid = 0;
        }
 
-       /* phy tx error */
-       if (macintstatus & MI_PHYTXERR) {
-               wlc->pub->_cnt->txphyerr++;
-       }
-
        /* received data or control frame, MI_DMAINT is indication of RX_FIFO interrupt */
        if (macintstatus & MI_DMAINT) {
                if (wlc_bmac_recv(wlc_hw, RX_FIFO, bounded)) {
@@ -386,7 +372,7 @@ bool BCMFASTPATH wlc_dpc(struct wlc_info *wlc, bool bounded)
        /* TX FIFO suspend/flush completion */
        if (macintstatus & MI_TXSTOP) {
                if (wlc_bmac_tx_fifo_suspended(wlc_hw, TX_DATA_FIFO)) {
-                       /*      WL_ERROR("dpc: fifo_suspend_comlete\n"); */
+                       /* wiphy_err(wiphy, "dpc: fifo_suspend_comlete\n"); */
                }
        }
 
@@ -396,15 +382,12 @@ bool BCMFASTPATH wlc_dpc(struct wlc_info *wlc, bool bounded)
        }
 
        if (macintstatus & MI_GP0) {
-               WL_ERROR("wl%d: PSM microcode watchdog fired at %d (seconds). Resetting.\n",
-                        wlc_hw->unit, wlc_hw->now);
+               wiphy_err(wiphy, "wl%d: PSM microcode watchdog fired at %d "
+                       "(seconds). Resetting.\n", wlc_hw->unit, wlc_hw->now);
 
                printk_once("%s : PSM Watchdog, chipid 0x%x, chiprev 0x%x\n",
                                        __func__, wlc_hw->sih->chip,
                                        wlc_hw->sih->chiprev);
-
-               wlc->pub->_cnt->psmwds++;
-
                /* big hammer */
                wl_init(wlc->wl);
        }
@@ -415,20 +398,14 @@ bool BCMFASTPATH wlc_dpc(struct wlc_info *wlc, bool bounded)
        }
 
        if (macintstatus & MI_RFDISABLE) {
-               WL_TRACE("wl%d: BMAC Detected a change on the RF Disable Input\n", wlc_hw->unit);
-
-               wlc->pub->_cnt->rfdisable++;
+               BCMMSG(wlc->wiphy, "wl%d: BMAC Detected a change on the"
+                      " RF Disable Input\n", wlc_hw->unit);
                wl_rfkill_set_hw_state(wlc->wl);
        }
 
        /* send any enq'd tx packets. Just makes sure to jump start tx */
-       if (!pktq_empty(&wlc->active_queue->q))
-               wlc_send_q(wlc, wlc->active_queue);
-
-       ASSERT(wlc_ps_check(wlc));
-
-       /* make sure the bound indication and the implementation are in sync */
-       ASSERT(bounded == true || wlc->macintstatus == 0);
+       if (!pktq_empty(&wlc->pkt_queue->q))
+               wlc_send_q(wlc);
 
        /* it isn't done and needs to be resched if macintstatus is non-zero */
        return wlc->macintstatus != 0;
@@ -444,7 +421,7 @@ void wlc_bmac_watchdog(void *arg)
        struct wlc_info *wlc = (struct wlc_info *) arg;
        struct wlc_hw_info *wlc_hw = wlc->hw;
 
-       WL_TRACE("wl%d: wlc_bmac_watchdog\n", wlc_hw->unit);
+       BCMMSG(wlc->wiphy, "wl%d\n", wlc_hw->unit);
 
        if (!wlc_hw->up)
                return;
@@ -467,8 +444,7 @@ wlc_bmac_set_chanspec(struct wlc_hw_info *wlc_hw, chanspec_t chanspec,
 {
        uint bandunit;
 
-       WL_TRACE("wl%d: wlc_bmac_set_chanspec 0x%x\n",
-                wlc_hw->unit, chanspec);
+       BCMMSG(wlc_hw->wlc->wiphy, "wl%d: 0x%x\n", wlc_hw->unit, chanspec);
 
        wlc_hw->chanspec = chanspec;
 
@@ -522,6 +498,7 @@ static bool wlc_bmac_attach_dmapio(struct wlc_info *wlc, uint j, bool wme)
        struct wlc_hw_info *wlc_hw = wlc->hw;
        uint unit = wlc_hw->unit;
        wlc_tunables_t *tune = wlc->pub->tunables;
+       struct wiphy *wiphy = wlc->wiphy;
 
        /* name and offsets for dma_attach */
        snprintf(name, sizeof(name), "wl%d", unit);
@@ -537,8 +514,8 @@ static bool wlc_bmac_attach_dmapio(struct wlc_info *wlc, uint j, bool wme)
                    dma_addrwidth(wlc_hw->sih, DMAREG(wlc_hw, DMA_TX, 0));
 
                if (!wl_alloc_dma_resources(wlc_hw->wlc->wl, addrwidth)) {
-                       WL_ERROR("wl%d: wlc_attach: alloc_dma_resources failed\n",
-                                unit);
+                       wiphy_err(wiphy, "wl%d: wlc_attach: alloc_dma_"
+                                 "resources failed\n", unit);
                        return false;
                }
 
@@ -547,8 +524,6 @@ static bool wlc_bmac_attach_dmapio(struct wlc_info *wlc, uint j, bool wme)
                 * TX: TX_AC_BK_FIFO (TX AC Background data packets)
                 * RX: RX_FIFO (RX data packets)
                 */
-               ASSERT(TX_AC_BK_FIFO == 0);
-               ASSERT(RX_FIFO == 0);
                wlc_hw->di[0] = dma_attach(name, wlc_hw->sih,
                                           (wme ? DMAREG(wlc_hw, DMA_TX, 0) :
                                            NULL), DMAREG(wlc_hw, DMA_RX, 0),
@@ -563,8 +538,6 @@ static bool wlc_bmac_attach_dmapio(struct wlc_info *wlc, uint j, bool wme)
                 *   (legacy) TX_DATA_FIFO (TX data packets)
                 * RX: UNUSED
                 */
-               ASSERT(TX_AC_BE_FIFO == 1);
-               ASSERT(TX_DATA_FIFO == 1);
                wlc_hw->di[1] = dma_attach(name, wlc_hw->sih,
                                           DMAREG(wlc_hw, DMA_TX, 1), NULL,
                                           tune->ntxd, 0, 0, -1, 0, 0,
@@ -576,7 +549,6 @@ static bool wlc_bmac_attach_dmapio(struct wlc_info *wlc, uint j, bool wme)
                 * TX: TX_AC_VI_FIFO (TX AC Video data packets)
                 * RX: UNUSED
                 */
-               ASSERT(TX_AC_VI_FIFO == 2);
                wlc_hw->di[2] = dma_attach(name, wlc_hw->sih,
                                           DMAREG(wlc_hw, DMA_TX, 2), NULL,
                                           tune->ntxd, 0, 0, -1, 0, 0,
@@ -587,8 +559,6 @@ static bool wlc_bmac_attach_dmapio(struct wlc_info *wlc, uint j, bool wme)
                 * TX: TX_AC_VO_FIFO (TX AC Voice data packets)
                 *   (legacy) TX_CTL_FIFO (TX control & mgmt packets)
                 */
-               ASSERT(TX_AC_VO_FIFO == 3);
-               ASSERT(TX_CTL_FIFO == 3);
                wlc_hw->di[3] = dma_attach(name, wlc_hw->sih,
                                           DMAREG(wlc_hw, DMA_TX, 3),
                                           NULL, tune->ntxd, 0, 0, -1,
@@ -597,7 +567,8 @@ static bool wlc_bmac_attach_dmapio(struct wlc_info *wlc, uint j, bool wme)
 /* Cleaner to leave this as if with AP defined */
 
                if (dma_attach_err) {
-                       WL_ERROR("wl%d: wlc_attach: dma_attach failed\n", unit);
+                       wiphy_err(wiphy, "wl%d: wlc_attach: dma_attach failed"
+                                 "\n", unit);
                        return false;
                }
 
@@ -644,11 +615,10 @@ int wlc_bmac_attach(struct wlc_info *wlc, u16 vendor, u16 device, uint unit,
        uint j;
        bool wme = false;
        shared_phy_params_t sha_params;
+       struct wiphy *wiphy = wlc->wiphy;
 
-       WL_TRACE("wl%d: wlc_bmac_attach: vendor 0x%x device 0x%x\n",
-                unit, vendor, device);
-
-       ASSERT(sizeof(wlc_d11rxhdr_t) <= WL_HWRXOFF);
+       BCMMSG(wlc->wiphy, "wl%d: vendor 0x%x device 0x%x\n", unit, vendor,
+               device);
 
        wme = true;
 
@@ -666,10 +636,11 @@ int wlc_bmac_attach(struct wlc_info *wlc, u16 vendor, u16 device, uint unit,
         * Also initialize software state that depends on the particular hardware
         * we are running.
         */
-       wlc_hw->sih = si_attach((uint) device, regsva, bustype, btparam,
+       wlc_hw->sih = ai_attach((uint) device, regsva, bustype, btparam,
                                &wlc_hw->vars, &wlc_hw->vars_size);
        if (wlc_hw->sih == NULL) {
-               WL_ERROR("wl%d: wlc_bmac_attach: si_attach failed\n", unit);
+               wiphy_err(wiphy, "wl%d: wlc_bmac_attach: si_attach failed\n",
+                         unit);
                err = 11;
                goto fail;
        }
@@ -689,21 +660,23 @@ int wlc_bmac_attach(struct wlc_info *wlc, u16 vendor, u16 device, uint unit,
                var = getvar(vars, "vendid");
                if (var) {
                        vendor = (u16) simple_strtoul(var, NULL, 0);
-                       WL_ERROR("Overriding vendor id = 0x%x\n", vendor);
+                       wiphy_err(wiphy, "Overriding vendor id = 0x%x\n",
+                                 vendor);
                }
                var = getvar(vars, "devid");
                if (var) {
                        u16 devid = (u16) simple_strtoul(var, NULL, 0);
                        if (devid != 0xffff) {
                                device = devid;
-                               WL_ERROR("Overriding device id = 0x%x\n",
-                                        device);
+                               wiphy_err(wiphy, "Overriding device id = 0x%x"
+                                         "\n", device);
                        }
                }
 
                /* verify again the device is supported */
                if (!wlc_chipmatch(vendor, device)) {
-                       WL_ERROR("wl%d: wlc_bmac_attach: Unsupported vendor/device (0x%x/0x%x)\n",
+                       wiphy_err(wiphy, "wl%d: wlc_bmac_attach: Unsupported "
+                               "vendor/device (0x%x/0x%x)\n",
                                 unit, vendor, device);
                        err = 12;
                        goto fail;
@@ -714,8 +687,8 @@ int wlc_bmac_attach(struct wlc_info *wlc, u16 vendor, u16 device, uint unit,
        wlc_hw->deviceid = device;
 
        /* set bar0 window to point at D11 core */
-       wlc_hw->regs = (d11regs_t *) si_setcore(wlc_hw->sih, D11_CORE_ID, 0);
-       wlc_hw->corerev = si_corerev(wlc_hw->sih);
+       wlc_hw->regs = (d11regs_t *) ai_setcore(wlc_hw->sih, D11_CORE_ID, 0);
+       wlc_hw->corerev = ai_corerev(wlc_hw->sih);
 
        regs = wlc_hw->regs;
 
@@ -728,7 +701,7 @@ int wlc_bmac_attach(struct wlc_info *wlc, u16 vendor, u16 device, uint unit,
        }
 
        /* initialize power control registers */
-       si_clkctl_init(wlc_hw->sih);
+       ai_clkctl_init(wlc_hw->sih);
 
        /* request fastclock and force fastclock for the rest of attach
         * bring the d11 core out of reset.
@@ -739,8 +712,8 @@ int wlc_bmac_attach(struct wlc_info *wlc, u16 vendor, u16 device, uint unit,
        wlc_bmac_corereset(wlc_hw, WLC_USE_COREFLAGS);
 
        if (!wlc_bmac_validate_chip_access(wlc_hw)) {
-               WL_ERROR("wl%d: wlc_bmac_attach: validate_chip_access failed\n",
-                        unit);
+               wiphy_err(wiphy, "wl%d: wlc_bmac_attach: validate_chip_access "
+                       "failed\n", unit);
                err = 14;
                goto fail;
        }
@@ -752,7 +725,8 @@ int wlc_bmac_attach(struct wlc_info *wlc, u16 vendor, u16 device, uint unit,
                j = BOARDREV_PROMOTED;
        wlc_hw->boardrev = (u16) j;
        if (!wlc_validboardtype(wlc_hw)) {
-               WL_ERROR("wl%d: wlc_bmac_attach: Unsupported Broadcom board type (0x%x)" " or revision level (0x%x)\n",
+               wiphy_err(wiphy, "wl%d: wlc_bmac_attach: Unsupported Broadcom "
+                       "board type (0x%x)" " or revision level (0x%x)\n",
                         unit, wlc_hw->sih->boardtype, wlc_hw->boardrev);
                err = 15;
                goto fail;
@@ -765,7 +739,7 @@ int wlc_bmac_attach(struct wlc_info *wlc, u16 vendor, u16 device, uint unit,
                wlc_bmac_pllreq(wlc_hw, true, WLC_PLLREQ_SHARED);
 
        if ((wlc_hw->sih->bustype == PCI_BUS)
-           && (si_pci_war16165(wlc_hw->sih)))
+           && (ai_pci_war16165(wlc_hw->sih)))
                wlc->war16165 = true;
 
        /* check device id(srom, nvram etc.) to set bands */
@@ -794,8 +768,8 @@ int wlc_bmac_attach(struct wlc_info *wlc, u16 vendor, u16 device, uint unit,
        wlc_hw->physhim = wlc_phy_shim_attach(wlc_hw, wlc->wl, wlc);
 
        if (wlc_hw->physhim == NULL) {
-               WL_ERROR("wl%d: wlc_bmac_attach: wlc_phy_shim_attach failed\n",
-                        unit);
+               wiphy_err(wiphy, "wl%d: wlc_bmac_attach: wlc_phy_shim_attach "
+                       "failed\n", unit);
                err = 25;
                goto fail;
        }
@@ -844,23 +818,22 @@ int wlc_bmac_attach(struct wlc_info *wlc, u16 vendor, u16 device, uint unit,
                wlc_hw->band->bandtype = j ? WLC_BAND_5G : WLC_BAND_2G;
                wlc->band->bandunit = j;
                wlc->band->bandtype = j ? WLC_BAND_5G : WLC_BAND_2G;
-               wlc->core->coreidx = si_coreidx(wlc_hw->sih);
+               wlc->core->coreidx = ai_coreidx(wlc_hw->sih);
 
                wlc_hw->machwcap = R_REG(&regs->machwcap);
                wlc_hw->machwcap_backup = wlc_hw->machwcap;
 
                /* init tx fifo size */
-               ASSERT((wlc_hw->corerev - XMTFIFOTBL_STARTREV) <
-                      ARRAY_SIZE(xmtfifo_sz));
                wlc_hw->xmtfifo_sz =
                    xmtfifo_sz[(wlc_hw->corerev - XMTFIFOTBL_STARTREV)];
 
                /* Get a phy for this band */
                wlc_hw->band->pi = wlc_phy_attach(wlc_hw->phy_sh,
-                       (void *)regs, wlc_bmac_bandtype(wlc_hw), vars);
+                       (void *)regs, wlc_bmac_bandtype(wlc_hw), vars,
+                       wlc->wiphy);
                if (wlc_hw->band->pi == NULL) {
-                       WL_ERROR("wl%d: wlc_bmac_attach: wlc_phy_attach failed\n",
-                                unit);
+                       wiphy_err(wiphy, "wl%d: wlc_bmac_attach: wlc_phy_"
+                                 "attach failed\n", unit);
                        err = 17;
                        goto fail;
                }
@@ -890,9 +863,9 @@ int wlc_bmac_attach(struct wlc_info *wlc, u16 vendor, u16 device, uint unit,
                                goto bad_phy;
                } else {
  bad_phy:
-                       WL_ERROR("wl%d: wlc_bmac_attach: unsupported phy type/rev (%d/%d)\n",
-                                unit,
-                                wlc_hw->band->phytype, wlc_hw->band->phyrev);
+                       wiphy_err(wiphy, "wl%d: wlc_bmac_attach: unsupported "
+                                 "phy type/rev (%d/%d)\n", unit,
+                                 wlc_hw->band->phytype, wlc_hw->band->phyrev);
                        err = 18;
                        goto fail;
                }
@@ -925,10 +898,10 @@ int wlc_bmac_attach(struct wlc_info *wlc, u16 vendor, u16 device, uint unit,
 
        /* Match driver "down" state */
        if (wlc_hw->sih->bustype == PCI_BUS)
-               si_pci_down(wlc_hw->sih);
+               ai_pci_down(wlc_hw->sih);
 
        /* register sb interrupt callback functions */
-       si_register_intr_callback(wlc_hw->sih, (void *)wlc_wlintrsoff,
+       ai_register_intr_callback(wlc_hw->sih, (void *)wlc_wlintrsoff,
                                  (void *)wlc_wlintrsrestore, NULL, wlc);
 
        /* turn off pll and xtal to match driver "down" state */
@@ -947,27 +920,30 @@ int wlc_bmac_attach(struct wlc_info *wlc, u16 vendor, u16 device, uint unit,
        /* init etheraddr state variables */
        macaddr = wlc_get_macaddr(wlc_hw);
        if (macaddr == NULL) {
-               WL_ERROR("wl%d: wlc_bmac_attach: macaddr not found\n", unit);
+               wiphy_err(wiphy, "wl%d: wlc_bmac_attach: macaddr not found\n",
+                         unit);
                err = 21;
                goto fail;
        }
        bcm_ether_atoe(macaddr, wlc_hw->etheraddr);
        if (is_broadcast_ether_addr(wlc_hw->etheraddr) ||
            is_zero_ether_addr(wlc_hw->etheraddr)) {
-               WL_ERROR("wl%d: wlc_bmac_attach: bad macaddr %s\n",
-                        unit, macaddr);
+               wiphy_err(wiphy, "wl%d: wlc_bmac_attach: bad macaddr %s\n",
+                         unit, macaddr);
                err = 22;
                goto fail;
        }
 
-       WL_TRACE("%s:: deviceid 0x%x nbands %d board 0x%x macaddr: %s\n",
-                __func__, wlc_hw->deviceid, wlc_hw->_nbands,
+       BCMMSG(wlc->wiphy,
+                "deviceid 0x%x nbands %d board 0x%x macaddr: %s\n",
+                wlc_hw->deviceid, wlc_hw->_nbands,
                 wlc_hw->sih->boardtype, macaddr);
 
        return err;
 
  fail:
-       WL_ERROR("wl%d: wlc_bmac_attach: failed with err %d\n", unit, err);
+       wiphy_err(wiphy, "wl%d: wlc_bmac_attach: failed with err %d\n", unit,
+                 err);
        return err;
 }
 
@@ -1011,10 +987,10 @@ int wlc_bmac_detach(struct wlc_info *wlc)
                /* detach interrupt sync mechanism since interrupt is disabled and per-port
                 * interrupt object may has been freed. this must be done before sb core switch
                 */
-               si_deregister_intr_callback(wlc_hw->sih);
+               ai_deregister_intr_callback(wlc_hw->sih);
 
                if (wlc_hw->sih->bustype == PCI_BUS)
-                       si_pci_sleep(wlc_hw->sih);
+                       ai_pci_sleep(wlc_hw->sih);
        }
 
        wlc_bmac_detach_dmapio(wlc_hw);
@@ -1039,7 +1015,7 @@ int wlc_bmac_detach(struct wlc_info *wlc)
        wlc_hw->vars = NULL;
 
        if (wlc_hw->sih) {
-               si_detach(wlc_hw->sih);
+               ai_detach(wlc_hw->sih);
                wlc_hw->sih = NULL;
        }
 
@@ -1049,9 +1025,7 @@ int wlc_bmac_detach(struct wlc_info *wlc)
 
 void wlc_bmac_reset(struct wlc_hw_info *wlc_hw)
 {
-       WL_TRACE("wl%d: wlc_bmac_reset\n", wlc_hw->unit);
-
-       wlc_hw->wlc->pub->_cnt->reset++;
+       BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit);
 
        /* reset the core */
        if (!DEVICEREMOVED(wlc_hw->wlc))
@@ -1070,7 +1044,7 @@ wlc_bmac_init(struct wlc_hw_info *wlc_hw, chanspec_t chanspec,
        bool fastclk;
        struct wlc_info *wlc = wlc_hw->wlc;
 
-       WL_TRACE("wl%d: wlc_bmac_init\n", wlc_hw->unit);
+       BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit);
 
        /* request FAST clock if not on */
        fastclk = wlc_hw->forcefastclk;
@@ -1119,16 +1093,14 @@ int wlc_bmac_up_prep(struct wlc_hw_info *wlc_hw)
 {
        uint coremask;
 
-       WL_TRACE("wl%d: %s:\n", wlc_hw->unit, __func__);
-
-       ASSERT(wlc_hw->wlc->pub->hw_up && wlc_hw->wlc->macintmask == 0);
+       BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit);
 
        /*
         * Enable pll and xtal, initialize the power control registers,
         * and force fastclock for the remainder of wlc_up().
         */
        wlc_bmac_xtal(wlc_hw, ON);
-       si_clkctl_init(wlc_hw->sih);
+       ai_clkctl_init(wlc_hw->sih);
        wlc_clkctl_clk(wlc_hw, CLK_FAST);
 
        /*
@@ -1138,9 +1110,7 @@ int wlc_bmac_up_prep(struct wlc_hw_info *wlc_hw)
        coremask = (1 << wlc_hw->wlc->core->coreidx);
 
        if (wlc_hw->sih->bustype == PCI_BUS)
-               si_pci_setup(wlc_hw->sih, coremask);
-
-       ASSERT(si_coreid(wlc_hw->sih) == D11_CORE_ID);
+               ai_pci_setup(wlc_hw->sih, coremask);
 
        /*
         * Need to read the hwradio status here to cover the case where the system
@@ -1149,13 +1119,13 @@ int wlc_bmac_up_prep(struct wlc_hw_info *wlc_hw)
        if (wlc_bmac_radio_read_hwdisabled(wlc_hw)) {
                /* put SB PCI in down state again */
                if (wlc_hw->sih->bustype == PCI_BUS)
-                       si_pci_down(wlc_hw->sih);
+                       ai_pci_down(wlc_hw->sih);
                wlc_bmac_xtal(wlc_hw, OFF);
-               return BCME_RADIOOFF;
+               return -ENOMEDIUM;
        }
 
        if (wlc_hw->sih->bustype == PCI_BUS)
-               si_pci_up(wlc_hw->sih);
+               ai_pci_up(wlc_hw->sih);
 
        /* reset the d11 core */
        wlc_bmac_corereset(wlc_hw, WLC_USE_COREFLAGS);
@@ -1165,14 +1135,13 @@ int wlc_bmac_up_prep(struct wlc_hw_info *wlc_hw)
 
 int wlc_bmac_up_finish(struct wlc_hw_info *wlc_hw)
 {
-       WL_TRACE("wl%d: %s:\n", wlc_hw->unit, __func__);
+       BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit);
 
        wlc_hw->up = true;
        wlc_phy_hw_state_upd(wlc_hw->band->pi, true);
 
        /* FULLY enable dynamic power control and d11 core interrupt */
        wlc_clkctl_clk(wlc_hw, CLK_DYNAMIC);
-       ASSERT(wlc_hw->wlc->macintmask == 0);
        wl_intrson(wlc_hw->wlc->wl);
        return 0;
 }
@@ -1182,7 +1151,7 @@ int wlc_bmac_down_prep(struct wlc_hw_info *wlc_hw)
        bool dev_gone;
        uint callbacks = 0;
 
-       WL_TRACE("wl%d: %s:\n", wlc_hw->unit, __func__);
+       BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit);
 
        if (!wlc_hw->up)
                return callbacks;
@@ -1210,7 +1179,7 @@ int wlc_bmac_down_finish(struct wlc_hw_info *wlc_hw)
        uint callbacks = 0;
        bool dev_gone;
 
-       WL_TRACE("wl%d: %s:\n", wlc_hw->unit, __func__);
+       BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit);
 
        if (!wlc_hw->up)
                return callbacks;
@@ -1230,7 +1199,7 @@ int wlc_bmac_down_finish(struct wlc_hw_info *wlc_hw)
        } else {
 
                /* Reset and disable the core */
-               if (si_iscoreup(wlc_hw->sih)) {
+               if (ai_iscoreup(wlc_hw->sih)) {
                        if (R_REG(&wlc_hw->regs->maccontrol) &
                            MCTL_EN_MAC)
                                wlc_suspend_mac_and_wait(wlc_hw->wlc);
@@ -1241,7 +1210,7 @@ int wlc_bmac_down_finish(struct wlc_hw_info *wlc_hw)
                /* turn off primary xtal and pll */
                if (!wlc_hw->noreset) {
                        if (wlc_hw->sih->bustype == PCI_BUS)
-                               si_pci_down(wlc_hw->sih);
+                               ai_pci_down(wlc_hw->sih);
                        wlc_bmac_xtal(wlc_hw, OFF);
                }
        }
@@ -1257,8 +1226,6 @@ void wlc_bmac_wait_for_wake(struct wlc_hw_info *wlc_hw)
        /* wait until ucode is no longer asleep */
        SPINWAIT((wlc_bmac_read_shm(wlc_hw, M_UCODE_DBGST) ==
                  DBGST_ASLEEP), wlc_hw->wlc->fastpwrup_dly);
-
-       ASSERT(wlc_bmac_read_shm(wlc_hw, M_UCODE_DBGST) != DBGST_ASLEEP);
 }
 
 void wlc_bmac_hw_etheraddr(struct wlc_hw_info *wlc_hw, u8 *ea)
@@ -1292,9 +1259,9 @@ static void wlc_clkctl_clk(struct wlc_hw_info *wlc_hw, uint mode)
                                           (&wlc_hw->regs->
                                            clk_ctl_st) & CCS_HTAVAIL) == 0),
                                         PMU_MAX_TRANSITION_DLY);
-                               ASSERT(R_REG
-                                      (&wlc_hw->regs->
-                                       clk_ctl_st) & CCS_HTAVAIL);
+                               WARN_ON(!(R_REG
+                                         (&wlc_hw->regs->
+                                          clk_ctl_st) & CCS_HTAVAIL));
                        } else {
                                if ((wlc_hw->sih->pmurev == 0) &&
                                    (R_REG
@@ -1316,11 +1283,12 @@ static void wlc_clkctl_clk(struct wlc_hw_info *wlc_hw, uint mode)
                 * then use FCA to verify mac is running fast clock
                 */
 
-               wlc_hw->forcefastclk = si_clkctl_cc(wlc_hw->sih, mode);
+               wlc_hw->forcefastclk = ai_clkctl_cc(wlc_hw->sih, mode);
 
                /* check fast clock is available (if core is not in reset) */
                if (wlc_hw->forcefastclk && wlc_hw->clk)
-                       ASSERT(si_core_sflags(wlc_hw->sih, 0, 0) & SISF_FCLKA);
+                       WARN_ON(!(ai_core_sflags(wlc_hw->sih, 0, 0) &
+                                 SISF_FCLKA));
 
                /* keep the ucode wake bit on if forcefastclk is on
                 * since we do not want ucode to put us back to slow clock
@@ -1382,9 +1350,8 @@ wlc_bmac_mhf(struct wlc_hw_info *wlc_hw, u8 idx, u16 mask, u16 val,
        };
        struct wlc_hwband *band;
 
-       ASSERT((val & ~mask) == 0);
-       ASSERT(idx < MHFMAX);
-       ASSERT(ARRAY_SIZE(addr) == MHFMAX);
+       if ((val & ~mask) || idx >= MHFMAX)
+               return; /* error condition */
 
        switch (bands) {
                /* Current band only or all bands,
@@ -1401,8 +1368,7 @@ wlc_bmac_mhf(struct wlc_hw_info *wlc_hw, u8 idx, u16 mask, u16 val,
                band = wlc_hw->bandstate[BAND_2G_INDEX];
                break;
        default:
-               ASSERT(0);
-               band = NULL;
+               band = NULL;    /* error condition */
        }
 
        if (band) {
@@ -1429,8 +1395,9 @@ wlc_bmac_mhf(struct wlc_hw_info *wlc_hw, u8 idx, u16 mask, u16 val,
 u16 wlc_bmac_mhf_get(struct wlc_hw_info *wlc_hw, u8 idx, int bands)
 {
        struct wlc_hwband *band;
-       ASSERT(idx < MHFMAX);
 
+       if (idx >= MHFMAX)
+               return 0; /* error condition */
        switch (bands) {
        case WLC_BAND_AUTO:
                band = wlc_hw->band;
@@ -1442,8 +1409,7 @@ u16 wlc_bmac_mhf_get(struct wlc_hw_info *wlc_hw, u8 idx, int bands)
                band = wlc_hw->bandstate[BAND_2G_INDEX];
                break;
        default:
-               ASSERT(0);
-               band = NULL;
+               band = NULL;            /* error condition */
        }
 
        if (!band)
@@ -1460,8 +1426,6 @@ static void wlc_write_mhf(struct wlc_hw_info *wlc_hw, u16 *mhfs)
                M_HOST_FLAGS5
        };
 
-       ASSERT(ARRAY_SIZE(addr) == MHFMAX);
-
        for (idx = 0; idx < MHFMAX; idx++) {
                wlc_bmac_write_shm(wlc_hw, addr[idx], mhfs[idx]);
        }
@@ -1486,8 +1450,8 @@ void wlc_bmac_mctrl(struct wlc_hw_info *wlc_hw, u32 mask, u32 val)
        u32 maccontrol;
        u32 new_maccontrol;
 
-       ASSERT((val & ~mask) == 0);
-
+       if (val & ~mask)
+               return; /* error condition */
        maccontrol = wlc_hw->maccontrol;
        new_maccontrol = (maccontrol & ~mask) | val;
 
@@ -1522,8 +1486,6 @@ static void wlc_mctrl_write(struct wlc_hw_info *wlc_hw)
 
 void wlc_ucode_wake_override_set(struct wlc_hw_info *wlc_hw, u32 override_bit)
 {
-       ASSERT((wlc_hw->wake_override & override_bit) == 0);
-
        if (wlc_hw->wake_override || (wlc_hw->maccontrol & MCTL_WAKE)) {
                mboolset(wlc_hw->wake_override, override_bit);
                return;
@@ -1539,8 +1501,6 @@ void wlc_ucode_wake_override_set(struct wlc_hw_info *wlc_hw, u32 override_bit)
 
 void wlc_ucode_wake_override_clear(struct wlc_hw_info *wlc_hw, u32 override_bit)
 {
-       ASSERT(wlc_hw->wake_override & override_bit);
-
        mboolclr(wlc_hw->wake_override, override_bit);
 
        if (wlc_hw->wake_override || (wlc_hw->maccontrol & MCTL_WAKE))
@@ -1590,33 +1550,6 @@ static void wlc_ucode_mute_override_clear(struct wlc_hw_info *wlc_hw)
        wlc_mctrl_write(wlc_hw);
 }
 
-/*
- * Write a MAC address to the rcmta structure
- */
-void
-wlc_bmac_set_rcmta(struct wlc_hw_info *wlc_hw, int idx,
-                  const u8 *addr)
-{
-       d11regs_t *regs = wlc_hw->regs;
-       volatile u16 *objdata16 = (volatile u16 *)&regs->objdata;
-       u32 mac_hm;
-       u16 mac_l;
-
-       WL_TRACE("wl%d: %s\n", wlc_hw->unit, __func__);
-
-       mac_hm =
-           (addr[3] << 24) | (addr[2] << 16) |
-           (addr[1] << 8) | addr[0];
-       mac_l = (addr[5] << 8) | addr[4];
-
-       W_REG(&regs->objaddr, (OBJADDR_RCMTA_SEL | (idx * 2)));
-       (void)R_REG(&regs->objaddr);
-       W_REG(&regs->objdata, mac_hm);
-       W_REG(&regs->objaddr, (OBJADDR_RCMTA_SEL | ((idx * 2) + 1)));
-       (void)R_REG(&regs->objaddr);
-       W_REG(objdata16, mac_l);
-}
-
 /*
  * Write a MAC address to the given match reg offset in the RXE match engine.
  */
@@ -1629,9 +1562,8 @@ wlc_bmac_set_addrmatch(struct wlc_hw_info *wlc_hw, int match_reg_offset,
        u16 mac_m;
        u16 mac_h;
 
-       WL_TRACE("wl%d: wlc_bmac_set_addrmatch\n", wlc_hw->unit);
-
-       ASSERT(match_reg_offset < RCM_SIZE);
+       BCMMSG(wlc_hw->wlc->wiphy, "wl%d: wlc_bmac_set_addrmatch\n",
+                wlc_hw->unit);
 
        regs = wlc_hw->regs;
        mac_l = addr[0] | (addr[1] << 8);
@@ -1653,17 +1585,9 @@ wlc_bmac_write_template_ram(struct wlc_hw_info *wlc_hw, int offset, int len,
        d11regs_t *regs;
        u32 word;
        bool be_bit;
-#ifdef IL_BIGENDIAN
-       volatile u16 *dptr = NULL;
-#endif                         /* IL_BIGENDIAN */
-       WL_TRACE("wl%d: wlc_bmac_write_template_ram\n", wlc_hw->unit);
+       BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit);
 
        regs = wlc_hw->regs;
-
-       ASSERT(IS_ALIGNED(offset, sizeof(u32)));
-       ASSERT(IS_ALIGNED(len, sizeof(u32)));
-       ASSERT((offset & ~0xffff) == 0);
-
        W_REG(&regs->tplatewrptr, offset);
 
        /* if MCTL_BIGEND bit set in mac control register,
@@ -1716,8 +1640,6 @@ void wlc_bmac_bw_set(struct wlc_hw_info *wlc_hw, u16 bw)
 
        wlc_phy_bw_state_set(wlc_hw->band->pi, bw);
 
-       ASSERT(wlc_hw->clk);
-
        wlc_bmac_phy_reset(wlc_hw);
        wlc_phy_init(wlc_hw->band->pi, wlc_phy_chanspec_get(wlc_hw->band->pi));
 
@@ -1734,7 +1656,6 @@ wlc_write_hw_bcntemplate0(struct wlc_hw_info *wlc_hw, void *bcn, int len)
        wlc_bmac_write_template_ram(wlc_hw, T_BCN0_TPL_BASE, (len + 3) & ~3,
                                    bcn);
        /* write beacon length to SCR */
-       ASSERT(len < 65536);
        wlc_bmac_write_shm(wlc_hw, M_BCN0_FRM_BYTESZ, (u16) len);
        /* mark beacon0 valid */
        OR_REG(&regs->maccommand, MCMD_BCN0VLD);
@@ -1748,7 +1669,6 @@ wlc_write_hw_bcntemplate1(struct wlc_hw_info *wlc_hw, void *bcn, int len)
        wlc_bmac_write_template_ram(wlc_hw, T_BCN1_TPL_BASE, (len + 3) & ~3,
                                    bcn);
        /* write beacon length to SCR */
-       ASSERT(len < 65536);
        wlc_bmac_write_shm(wlc_hw, M_BCN1_FRM_BYTESZ, (u16) len);
        /* mark beacon1 valid */
        OR_REG(&regs->maccommand, MCMD_BCN1VLD);
@@ -1772,8 +1692,6 @@ wlc_bmac_write_hw_bcntemplates(struct wlc_hw_info *wlc_hw, void *bcn, int len,
                else if (!
                         (R_REG(&regs->maccommand) & MCMD_BCN1VLD))
                        wlc_write_hw_bcntemplate1(wlc_hw, bcn, len);
-               else            /* one template should always have been available */
-                       ASSERT(0);
        }
 }
 
@@ -1800,15 +1718,8 @@ WLBANDINITFN(wlc_bmac_bsinit) (struct wlc_info *wlc, chanspec_t chanspec)
 {
        struct wlc_hw_info *wlc_hw = wlc->hw;
 
-       WL_TRACE("wl%d: wlc_bmac_bsinit: bandunit %d\n",
-                wlc_hw->unit, wlc_hw->band->bandunit);
-
-       /* sanity check */
-       if (PHY_TYPE(R_REG(&wlc_hw->regs->phyversion)) !=
-           PHY_TYPE_LCNXN)
-               ASSERT((uint)
-                      PHY_TYPE(R_REG(&wlc_hw->regs->phyversion))
-                      == wlc_hw->band->phytype);
+       BCMMSG(wlc->wiphy, "wl%d: bandunit %d\n", wlc_hw->unit,
+               wlc_hw->band->bandunit);
 
        wlc_ucode_bsinit(wlc_hw);
 
@@ -1837,23 +1748,23 @@ WLBANDINITFN(wlc_bmac_bsinit) (struct wlc_info *wlc, chanspec_t chanspec)
 
 static void wlc_bmac_core_phy_clk(struct wlc_hw_info *wlc_hw, bool clk)
 {
-       WL_TRACE("wl%d: wlc_bmac_core_phy_clk: clk %d\n", wlc_hw->unit, clk);
+       BCMMSG(wlc_hw->wlc->wiphy, "wl%d: clk %d\n", wlc_hw->unit, clk);
 
        wlc_hw->phyclk = clk;
 
        if (OFF == clk) {       /* clear gmode bit, put phy into reset */
 
-               si_core_cflags(wlc_hw->sih, (SICF_PRST | SICF_FGC | SICF_GMODE),
+               ai_core_cflags(wlc_hw->sih, (SICF_PRST | SICF_FGC | SICF_GMODE),
                               (SICF_PRST | SICF_FGC));
                udelay(1);
-               si_core_cflags(wlc_hw->sih, (SICF_PRST | SICF_FGC), SICF_PRST);
+               ai_core_cflags(wlc_hw->sih, (SICF_PRST | SICF_FGC), SICF_PRST);
                udelay(1);
 
        } else {                /* take phy out of reset */
 
-               si_core_cflags(wlc_hw->sih, (SICF_PRST | SICF_FGC), SICF_FGC);
+               ai_core_cflags(wlc_hw->sih, (SICF_PRST | SICF_FGC), SICF_FGC);
                udelay(1);
-               si_core_cflags(wlc_hw->sih, (SICF_FGC), 0);
+               ai_core_cflags(wlc_hw->sih, (SICF_FGC), 0);
                udelay(1);
 
        }
@@ -1862,18 +1773,18 @@ static void wlc_bmac_core_phy_clk(struct wlc_hw_info *wlc_hw, bool clk)
 /* Perform a soft reset of the PHY PLL */
 void wlc_bmac_core_phypll_reset(struct wlc_hw_info *wlc_hw)
 {
-       WL_TRACE("wl%d: wlc_bmac_core_phypll_reset\n", wlc_hw->unit);
+       BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit);
 
-       si_corereg(wlc_hw->sih, SI_CC_IDX,
+       ai_corereg(wlc_hw->sih, SI_CC_IDX,
                   offsetof(chipcregs_t, chipcontrol_addr), ~0, 0);
        udelay(1);
-       si_corereg(wlc_hw->sih, SI_CC_IDX,
+       ai_corereg(wlc_hw->sih, SI_CC_IDX,
                   offsetof(chipcregs_t, chipcontrol_data), 0x4, 0);
        udelay(1);
-       si_corereg(wlc_hw->sih, SI_CC_IDX,
+       ai_corereg(wlc_hw->sih, SI_CC_IDX,
                   offsetof(chipcregs_t, chipcontrol_data), 0x4, 4);
        udelay(1);
-       si_corereg(wlc_hw->sih, SI_CC_IDX,
+       ai_corereg(wlc_hw->sih, SI_CC_IDX,
                   offsetof(chipcregs_t, chipcontrol_data), 0x4, 0);
        udelay(1);
 }
@@ -1888,18 +1799,18 @@ void wlc_bmac_phyclk_fgc(struct wlc_hw_info *wlc_hw, bool clk)
                return;
 
        if (ON == clk)
-               si_core_cflags(wlc_hw->sih, SICF_FGC, SICF_FGC);
+               ai_core_cflags(wlc_hw->sih, SICF_FGC, SICF_FGC);
        else
-               si_core_cflags(wlc_hw->sih, SICF_FGC, 0);
+               ai_core_cflags(wlc_hw->sih, SICF_FGC, 0);
 
 }
 
 void wlc_bmac_macphyclk_set(struct wlc_hw_info *wlc_hw, bool clk)
 {
        if (ON == clk)
-               si_core_cflags(wlc_hw->sih, SICF_MPCLKE, SICF_MPCLKE);
+               ai_core_cflags(wlc_hw->sih, SICF_MPCLKE, SICF_MPCLKE);
        else
-               si_core_cflags(wlc_hw->sih, SICF_MPCLKE, 0);
+               ai_core_cflags(wlc_hw->sih, SICF_MPCLKE, 0);
 }
 
 void wlc_bmac_phy_reset(struct wlc_hw_info *wlc_hw)
@@ -1908,7 +1819,7 @@ void wlc_bmac_phy_reset(struct wlc_hw_info *wlc_hw)
        u32 phy_bw_clkbits;
        bool phy_in_reset = false;
 
-       WL_TRACE("wl%d: wlc_bmac_phy_reset\n", wlc_hw->unit);
+       BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit);
 
        if (pih == NULL)
                return;
@@ -1919,7 +1830,7 @@ void wlc_bmac_phy_reset(struct wlc_hw_info *wlc_hw)
        if (WLCISNPHY(wlc_hw->band) && NREV_GE(wlc_hw->band->phyrev, 3) &&
            NREV_LE(wlc_hw->band->phyrev, 4)) {
                /* Set the PHY bandwidth */
-               si_core_cflags(wlc_hw->sih, SICF_BWMASK, phy_bw_clkbits);
+               ai_core_cflags(wlc_hw->sih, SICF_BWMASK, phy_bw_clkbits);
 
                udelay(1);
 
@@ -1927,12 +1838,12 @@ void wlc_bmac_phy_reset(struct wlc_hw_info *wlc_hw)
                wlc_bmac_core_phypll_reset(wlc_hw);
 
                /* reset the PHY */
-               si_core_cflags(wlc_hw->sih, (SICF_PRST | SICF_PCLKE),
+               ai_core_cflags(wlc_hw->sih, (SICF_PRST | SICF_PCLKE),
                               (SICF_PRST | SICF_PCLKE));
                phy_in_reset = true;
        } else {
 
-               si_core_cflags(wlc_hw->sih,
+               ai_core_cflags(wlc_hw->sih,
                               (SICF_PRST | SICF_PCLKE | SICF_BWMASK),
                               (SICF_PRST | SICF_PCLKE | phy_bw_clkbits));
        }
@@ -1951,13 +1862,9 @@ WLBANDINITFN(wlc_bmac_setband) (struct wlc_hw_info *wlc_hw, uint bandunit,
        struct wlc_info *wlc = wlc_hw->wlc;
        u32 macintmask;
 
-       ASSERT(NBANDS_HW(wlc_hw) > 1);
-       ASSERT(bandunit != wlc_hw->band->bandunit);
-
        /* Enable the d11 core before accessing it */
-       if (!si_iscoreup(wlc_hw->sih)) {
-               si_core_reset(wlc_hw->sih, 0, 0);
-               ASSERT(si_iscoreup(wlc_hw->sih));
+       if (!ai_iscoreup(wlc_hw->sih)) {
+               ai_core_reset(wlc_hw->sih, 0, 0);
                wlc_mctrl_reset(wlc_hw);
        }
 
@@ -1983,14 +1890,14 @@ WLBANDINITFN(wlc_bmac_setband) (struct wlc_hw_info *wlc_hw, uint bandunit,
        wl_intrsrestore(wlc->wl, macintmask);
 
        /* ucode should still be suspended.. */
-       ASSERT((R_REG(&wlc_hw->regs->maccontrol) & MCTL_EN_MAC) ==
-              0);
+       WARN_ON((R_REG(&wlc_hw->regs->maccontrol) & MCTL_EN_MAC) != 0);
 }
 
 /* low-level band switch utility routine */
 void WLBANDINITFN(wlc_setxband) (struct wlc_hw_info *wlc_hw, uint bandunit)
 {
-       WL_TRACE("wl%d: wlc_setxband: bandunit %d\n", wlc_hw->unit, bandunit);
+       BCMMSG(wlc_hw->wlc->wiphy, "wl%d: bandunit %d\n", wlc_hw->unit,
+               bandunit);
 
        wlc_hw->band = wlc_hw->bandstate[bandunit];
 
@@ -1999,7 +1906,7 @@ void WLBANDINITFN(wlc_setxband) (struct wlc_hw_info *wlc_hw, uint bandunit)
 
        /* set gmode core flag */
        if (wlc_hw->sbclk && !wlc_hw->noreset) {
-               si_core_cflags(wlc_hw->sih, SICF_GMODE,
+               ai_core_cflags(wlc_hw->sih, SICF_GMODE,
                               ((bandunit == 0) ? SICF_GMODE : 0));
        }
 }
@@ -2009,7 +1916,8 @@ static bool wlc_isgoodchip(struct wlc_hw_info *wlc_hw)
 
        /* reject unsupported corerev */
        if (!VALID_COREREV(wlc_hw->corerev)) {
-               WL_ERROR("unsupported core rev %d\n", wlc_hw->corerev);
+               wiphy_err(wlc_hw->wlc->wiphy, "unsupported core rev %d\n",
+                         wlc_hw->corerev);
                return false;
        }
 
@@ -2034,7 +1942,7 @@ static bool wlc_validboardtype(struct wlc_hw_info *wlc_hw)
                        goodboard = false;
        }
 
-       if (wlc_hw->sih->boardvendor != VENDOR_BROADCOM)
+       if (wlc_hw->sih->boardvendor != PCI_VENDOR_ID_BROADCOM)
                return goodboard;
 
        return goodboard;
@@ -2057,8 +1965,8 @@ static char *wlc_get_macaddr(struct wlc_hw_info *wlc_hw)
 
        macaddr = getvar(wlc_hw->vars, varname);
        if (macaddr == NULL) {
-               WL_ERROR("wl%d: wlc_get_macaddr: macaddr getvar(%s) not found\n",
-                        wlc_hw->unit, varname);
+               wiphy_err(wlc_hw->wlc->wiphy, "wl%d: wlc_get_macaddr: macaddr "
+                         "getvar(%s) not found\n", wlc_hw->unit, varname);
        }
 
        return macaddr;
@@ -2094,9 +2002,9 @@ bool wlc_bmac_radio_read_hwdisabled(struct wlc_hw_info *wlc_hw)
                    (wlc_hw->sih->chip == BCM43225_CHIP_ID) ||
                    (wlc_hw->sih->chip == BCM43421_CHIP_ID))
                        wlc_hw->regs =
-                           (d11regs_t *) si_setcore(wlc_hw->sih, D11_CORE_ID,
+                           (d11regs_t *) ai_setcore(wlc_hw->sih, D11_CORE_ID,
                                                     0);
-               si_core_reset(wlc_hw->sih, flags, resetbits);
+               ai_core_reset(wlc_hw->sih, flags, resetbits);
                wlc_mctrl_reset(wlc_hw);
        }
 
@@ -2104,7 +2012,7 @@ bool wlc_bmac_radio_read_hwdisabled(struct wlc_hw_info *wlc_hw)
 
        /* put core back into reset */
        if (!clk)
-               si_core_disable(wlc_hw->sih, 0);
+               ai_core_disable(wlc_hw->sih, 0);
 
        if (!xtal)
                wlc_bmac_xtal(wlc_hw, OFF);
@@ -2118,25 +2026,25 @@ void wlc_bmac_hw_up(struct wlc_hw_info *wlc_hw)
        if (wlc_hw->wlc->pub->hw_up)
                return;
 
-       WL_TRACE("wl%d: %s:\n", wlc_hw->unit, __func__);
+       BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit);
 
        /*
         * Enable pll and xtal, initialize the power control registers,
         * and force fastclock for the remainder of wlc_up().
         */
        wlc_bmac_xtal(wlc_hw, ON);
-       si_clkctl_init(wlc_hw->sih);
+       ai_clkctl_init(wlc_hw->sih);
        wlc_clkctl_clk(wlc_hw, CLK_FAST);
 
        if (wlc_hw->sih->bustype == PCI_BUS) {
-               si_pci_fixcfg(wlc_hw->sih);
+               ai_pci_fixcfg(wlc_hw->sih);
 
                /* AI chip doesn't restore bar0win2 on hibernation/resume, need sw fixup */
                if ((wlc_hw->sih->chip == BCM43224_CHIP_ID) ||
                    (wlc_hw->sih->chip == BCM43225_CHIP_ID) ||
                    (wlc_hw->sih->chip == BCM43421_CHIP_ID))
                        wlc_hw->regs =
-                           (d11regs_t *) si_setcore(wlc_hw->sih, D11_CORE_ID,
+                           (d11regs_t *) ai_setcore(wlc_hw->sih, D11_CORE_ID,
                                                     0);
        }
 
@@ -2151,7 +2059,7 @@ void wlc_bmac_hw_up(struct wlc_hw_info *wlc_hw)
                if (!
                    (wlc_hw->boardrev >= 0x1250
                     && (wlc_hw->boardflags & BFL_FEM_BT)))
-                       si_epa_4313war(wlc_hw->sih);
+                       ai_epa_4313war(wlc_hw->sih);
        }
 }
 
@@ -2179,7 +2087,7 @@ void wlc_bmac_corereset(struct wlc_hw_info *wlc_hw, u32 flags)
        if (flags == WLC_USE_COREFLAGS)
                flags = (wlc_hw->band->pi ? wlc_hw->band->core_flags : 0);
 
-       WL_TRACE("wl%d: %s\n", wlc_hw->unit, __func__);
+       BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit);
 
        regs = wlc_hw->regs;
 
@@ -2189,17 +2097,19 @@ void wlc_bmac_corereset(struct wlc_hw_info *wlc_hw, u32 flags)
                wlc_clkctl_clk(wlc_hw, CLK_FAST);
 
        /* reset the dma engines except first time thru */
-       if (si_iscoreup(wlc_hw->sih)) {
+       if (ai_iscoreup(wlc_hw->sih)) {
                for (i = 0; i < NFIFO; i++)
                        if ((wlc_hw->di[i]) && (!dma_txreset(wlc_hw->di[i]))) {
-                               WL_ERROR("wl%d: %s: dma_txreset[%d]: cannot stop dma\n",
-                                        wlc_hw->unit, __func__, i);
+                               wiphy_err(wlc_hw->wlc->wiphy, "wl%d: %s: "
+                                         "dma_txreset[%d]: cannot stop dma\n",
+                                          wlc_hw->unit, __func__, i);
                        }
 
                if ((wlc_hw->di[RX_FIFO])
                    && (!wlc_dma_rxreset(wlc_hw, RX_FIFO))) {
-                       WL_ERROR("wl%d: %s: dma_rxreset[%d]: cannot stop dma\n",
-                                wlc_hw->unit, __func__, RX_FIFO);
+                       wiphy_err(wlc_hw->wlc->wiphy, "wl%d: %s: dma_rxreset"
+                                 "[%d]: cannot stop dma\n",
+                                 wlc_hw->unit, __func__, RX_FIFO);
                }
        }
        /* if noreset, just stop the psm and return */
@@ -2224,7 +2134,7 @@ void wlc_bmac_corereset(struct wlc_hw_info *wlc_hw, u32 flags)
         *  with other driver like mips/arm since they may touch chipcommon as well.
         */
        wlc_hw->clk = false;
-       si_core_reset(wlc_hw->sih, flags, resetbits);
+       ai_core_reset(wlc_hw->sih, flags, resetbits);
        wlc_hw->clk = true;
        if (wlc_hw->band && wlc_hw->band->pi)
                wlc_phy_hw_clk_state_upd(wlc_hw->band->pi, true);
@@ -2315,10 +2225,11 @@ static void wlc_coreinit(struct wlc_info *wlc)
        bool fifosz_fixup = false;
        int err = 0;
        u16 buf[NFIFO];
+       struct wiphy *wiphy = wlc->wiphy;
 
        regs = wlc_hw->regs;
 
-       WL_TRACE("wl%d: wlc_coreinit\n", wlc_hw->unit);
+       BCMMSG(wlc->wiphy, "wl%d\n", wlc_hw->unit);
 
        /* reset PSM */
        wlc_bmac_mctrl(wlc_hw, ~0, (MCTL_IHR_EN | MCTL_PSM_JMP_0 | MCTL_WAKE));
@@ -2338,29 +2249,31 @@ static void wlc_coreinit(struct wlc_info *wlc)
        SPINWAIT(((R_REG(&regs->macintstatus) & MI_MACSSPNDD) == 0),
                 1000 * 1000);
        if ((R_REG(&regs->macintstatus) & MI_MACSSPNDD) == 0)
-               WL_ERROR("wl%d: wlc_coreinit: ucode did not self-suspend!\n",
-                        wlc_hw->unit);
+               wiphy_err(wiphy, "wl%d: wlc_coreinit: ucode did not self-"
+                         "suspend!\n", wlc_hw->unit);
 
        wlc_gpio_init(wlc);
 
-       sflags = si_core_sflags(wlc_hw->sih, 0, 0);
+       sflags = ai_core_sflags(wlc_hw->sih, 0, 0);
 
        if (D11REV_IS(wlc_hw->corerev, 23)) {
                if (WLCISNPHY(wlc_hw->band))
                        wlc_write_inits(wlc_hw, d11n0initvals16);
                else
-                       WL_ERROR("%s: wl%d: unsupported phy in corerev %d\n",
-                                __func__, wlc_hw->unit, wlc_hw->corerev);
+                       wiphy_err(wiphy, "%s: wl%d: unsupported phy in corerev"
+                                 " %d\n", __func__, wlc_hw->unit,
+                                 wlc_hw->corerev);
        } else if (D11REV_IS(wlc_hw->corerev, 24)) {
                if (WLCISLCNPHY(wlc_hw->band)) {
                        wlc_write_inits(wlc_hw, d11lcn0initvals24);
                } else {
-                       WL_ERROR("%s: wl%d: unsupported phy in corerev %d\n",
-                                __func__, wlc_hw->unit, wlc_hw->corerev);
+                       wiphy_err(wiphy, "%s: wl%d: unsupported phy in corerev"
+                                 " %d\n", __func__, wlc_hw->unit,
+                                 wlc_hw->corerev);
                }
        } else {
-               WL_ERROR("%s: wl%d: unsupported corerev %d\n",
-                        __func__, wlc_hw->unit, wlc_hw->corerev);
+               wiphy_err(wiphy, "%s: wl%d: unsupported corerev %d\n",
+                         __func__, wlc_hw->unit, wlc_hw->corerev);
        }
 
        /* For old ucode, txfifo sizes needs to be modified(increased) */
@@ -2402,13 +2315,13 @@ static void wlc_coreinit(struct wlc_info *wlc)
                err = -1;
        }
        if (err != 0) {
-               WL_ERROR("wlc_coreinit: txfifo mismatch: ucode size %d driver size %d index %d\n",
-                        buf[i], wlc_hw->xmtfifo_sz[i], i);
-               ASSERT(0);
+               wiphy_err(wiphy, "wlc_coreinit: txfifo mismatch: ucode size %d"
+                         " driver size %d index %d\n", buf[i],
+                         wlc_hw->xmtfifo_sz[i], i);
        }
 
        /* make sure we can still talk to the mac */
-       ASSERT(R_REG(&regs->maccontrol) != 0xffffffff);
+       WARN_ON(R_REG(&regs->maccontrol) == 0xffffffff);
 
        /* band-specific inits done by wlc_bsinit() */
 
@@ -2437,7 +2350,7 @@ static void wlc_coreinit(struct wlc_info *wlc)
        wlc_bmac_macphyclk_set(wlc_hw, ON);
 
        /* program dynamic clock control fast powerup delay register */
-       wlc->fastpwrup_dly = si_clkctl_fast_pwrup_delay(wlc_hw->sih);
+       wlc->fastpwrup_dly = ai_clkctl_fast_pwrup_delay(wlc_hw->sih);
        W_REG(&regs->scc_fastpwrup_dly, wlc->fastpwrup_dly);
 
        /* tell the ucode the corerev */
@@ -2554,7 +2467,6 @@ static void wlc_gpio_init(struct wlc_info *wlc)
                wlc_phy_antsel_init(wlc_hw->band->pi, false);
 
        } else if (wlc_hw->antsel_type == ANTSEL_2x4) {
-               ASSERT((gm & BOARD_GPIO_12) == 0);
                gm |= gc |= (BOARD_GPIO_12 | BOARD_GPIO_13);
                /*
                 * The board itself is powered by these GPIOs
@@ -2581,7 +2493,7 @@ static void wlc_gpio_init(struct wlc_info *wlc)
                gm |= gc |= BOARD_GPIO_PACTRL;
 
        /* apply to gpiocontrol register */
-       si_gpiocontrol(wlc_hw->sih, gm, gc, GPIO_DRV_PRIORITY);
+       ai_gpiocontrol(wlc_hw->sih, gm, gc, GPIO_DRV_PRIORITY);
 }
 
 static void wlc_ucode_download(struct wlc_hw_info *wlc_hw)
@@ -2598,16 +2510,18 @@ static void wlc_ucode_download(struct wlc_hw_info *wlc_hw)
                                        bcm43xx_16_mimosz);
                        wlc_hw->ucode_loaded = true;
                } else
-                       WL_ERROR("%s: wl%d: unsupported phy in corerev %d\n",
-                                __func__, wlc_hw->unit, wlc_hw->corerev);
+                       wiphy_err(wlc->wiphy, "%s: wl%d: unsupported phy in "
+                                 "corerev %d\n",
+                                 __func__, wlc_hw->unit, wlc_hw->corerev);
        } else if (D11REV_IS(wlc_hw->corerev, 24)) {
                if (WLCISLCNPHY(wlc_hw->band)) {
                        wlc_ucode_write(wlc_hw, bcm43xx_24_lcn,
                                        bcm43xx_24_lcnsz);
                        wlc_hw->ucode_loaded = true;
                } else {
-                       WL_ERROR("%s: wl%d: unsupported phy in corerev %d\n",
-                                __func__, wlc_hw->unit, wlc_hw->corerev);
+                       wiphy_err(wlc->wiphy, "%s: wl%d: unsupported phy in "
+                                 "corerev %d\n",
+                                 __func__, wlc_hw->unit, wlc_hw->corerev);
                }
        }
 }
@@ -2618,9 +2532,7 @@ static void wlc_ucode_write(struct wlc_hw_info *wlc_hw, const u32 ucode[],
        uint i;
        uint count;
 
-       WL_TRACE("wl%d: wlc_ucode_write\n", wlc_hw->unit);
-
-       ASSERT(IS_ALIGNED(nbytes, sizeof(u32)));
+       BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit);
 
        count = (nbytes / sizeof(u32));
 
@@ -2636,13 +2548,11 @@ static void wlc_write_inits(struct wlc_hw_info *wlc_hw,
        int i;
        volatile u8 *base;
 
-       WL_TRACE("wl%d: wlc_write_inits\n", wlc_hw->unit);
+       BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit);
 
        base = (volatile u8 *)wlc_hw->regs;
 
        for (i = 0; inits[i].addr != 0xffff; i++) {
-               ASSERT((inits[i].size == 2) || (inits[i].size == 4));
-
                if (inits[i].size == 2)
                        W_REG((u16 *)(base + inits[i].addr),
                              inits[i].value);
@@ -2700,6 +2610,7 @@ void wlc_bmac_fifoerrors(struct wlc_hw_info *wlc_hw)
        uint unit;
        uint intstatus, idx;
        d11regs_t *regs = wlc_hw->regs;
+       struct wiphy *wiphy = wlc_hw->wlc->wiphy;
 
        unit = wlc_hw->unit;
 
@@ -2710,46 +2621,41 @@ void wlc_bmac_fifoerrors(struct wlc_hw_info *wlc_hw)
                if (!intstatus)
                        continue;
 
-               WL_TRACE("wl%d: wlc_bmac_fifoerrors: intstatus%d 0x%x\n",
-                        unit, idx, intstatus);
+               BCMMSG(wlc_hw->wlc->wiphy, "wl%d: intstatus%d 0x%x\n",
+                       unit, idx, intstatus);
 
                if (intstatus & I_RO) {
-                       WL_ERROR("wl%d: fifo %d: receive fifo overflow\n",
-                                unit, idx);
-                       wlc_hw->wlc->pub->_cnt->rxoflo++;
+                       wiphy_err(wiphy, "wl%d: fifo %d: receive fifo "
+                                 "overflow\n", unit, idx);
                        fatal = true;
                }
 
                if (intstatus & I_PC) {
-                       WL_ERROR("wl%d: fifo %d: descriptor error\n",
+                       wiphy_err(wiphy, "wl%d: fifo %d: descriptor error\n",
                                 unit, idx);
-                       wlc_hw->wlc->pub->_cnt->dmade++;
                        fatal = true;
                }
 
                if (intstatus & I_PD) {
-                       WL_ERROR("wl%d: fifo %d: data error\n", unit, idx);
-                       wlc_hw->wlc->pub->_cnt->dmada++;
+                       wiphy_err(wiphy, "wl%d: fifo %d: data error\n", unit,
+                                 idx);
                        fatal = true;
                }
 
                if (intstatus & I_DE) {
-                       WL_ERROR("wl%d: fifo %d: descriptor protocol error\n",
-                                unit, idx);
-                       wlc_hw->wlc->pub->_cnt->dmape++;
+                       wiphy_err(wiphy, "wl%d: fifo %d: descriptor protocol "
+                                 "error\n", unit, idx);
                        fatal = true;
                }
 
                if (intstatus & I_RU) {
-                       WL_ERROR("wl%d: fifo %d: receive descriptor underflow\n",
-                                idx, unit);
-                       wlc_hw->wlc->pub->_cnt->rxuflo[idx]++;
+                       wiphy_err(wiphy, "wl%d: fifo %d: receive descriptor "
+                                 "underflow\n", idx, unit);
                }
 
                if (intstatus & I_XU) {
-                       WL_ERROR("wl%d: fifo %d: transmit fifo underflow\n",
-                                idx, unit);
-                       wlc_hw->wlc->pub->_cnt->txuflo++;
+                       wiphy_err(wiphy, "wl%d: fifo %d: transmit fifo "
+                                 "underflow\n", idx, unit);
                        fatal = true;
                }
 
@@ -2765,7 +2671,6 @@ void wlc_bmac_fifoerrors(struct wlc_hw_info *wlc_hw)
 void wlc_intrson(struct wlc_info *wlc)
 {
        struct wlc_hw_info *wlc_hw = wlc->hw;
-       ASSERT(wlc->defmacintmask);
        wlc->macintmask = wlc->defmacintmask;
        W_REG(&wlc_hw->regs->macintmask, wlc->macintmask);
 }
@@ -2859,7 +2764,7 @@ static void wlc_bmac_mute(struct wlc_hw_info *wlc_hw, bool on, mbool flags)
 int wlc_bmac_xmtfifo_sz_get(struct wlc_hw_info *wlc_hw, uint fifo, uint *blocks)
 {
        if (fifo >= NFIFO)
-               return BCME_RANGE;
+               return -EINVAL;
 
        *blocks = wlc_hw->xmtfifo_sz[fifo];
 
@@ -2962,7 +2867,8 @@ static inline u32 wlc_intstatus(struct wlc_info *wlc, bool in_isr)
        /* macintstatus includes a DMA interrupt summary bit */
        macintstatus = R_REG(&regs->macintstatus);
 
-       WL_TRACE("wl%d: macintstatus: 0x%x\n", wlc_hw->unit, macintstatus);
+       BCMMSG(wlc->wiphy, "wl%d: macintstatus: 0x%x\n", wlc_hw->unit,
+                macintstatus);
 
        /* detect cardbus removed, in power down(suspend) and in reset */
        if (DEVICEREMOVED(wlc))
@@ -3013,8 +2919,6 @@ bool wlc_intrsupd(struct wlc_info *wlc)
 {
        u32 macintstatus;
 
-       ASSERT(wlc->macintstatus != 0);
-
        /* read and clear macintstatus and intstatus registers */
        macintstatus = wlc_intstatus(wlc, false);
 
@@ -3034,7 +2938,7 @@ bool wlc_intrsupd(struct wlc_info *wlc)
  * *wantdpc will be set to true if further wlc_dpc() processing is required,
  * false otherwise.
  */
-bool BCMFASTPATH wlc_isr(struct wlc_info *wlc, bool *wantdpc)
+bool wlc_isr(struct wlc_info *wlc, bool *wantdpc)
 {
        struct wlc_hw_info *wlc_hw = wlc->hw;
        u32 macintstatus;
@@ -3048,7 +2952,8 @@ bool BCMFASTPATH wlc_isr(struct wlc_info *wlc, bool *wantdpc)
        macintstatus = wlc_intstatus(wlc, true);
 
        if (macintstatus == 0xffffffff)
-               WL_ERROR("DEVICEREMOVED detected in the ISR code path\n");
+               wiphy_err(wlc->wiphy, "DEVICEREMOVED detected in the ISR code"
+                         " path\n");
 
        /* it is not for us */
        if (macintstatus == 0)
@@ -3057,14 +2962,13 @@ bool BCMFASTPATH wlc_isr(struct wlc_info *wlc, bool *wantdpc)
        *wantdpc = true;
 
        /* save interrupt status bits */
-       ASSERT(wlc->macintstatus == 0);
        wlc->macintstatus = macintstatus;
 
        return true;
 
 }
 
-static bool BCMFASTPATH
+static bool
 wlc_bmac_dotxstatus(struct wlc_hw_info *wlc_hw, tx_status_t *txs, u32 s2)
 {
        /* discard intermediate indications for ucode with one legitimate case:
@@ -3083,7 +2987,7 @@ wlc_bmac_dotxstatus(struct wlc_hw_info *wlc_hw, tx_status_t *txs, u32 s2)
 /* process tx completion events in BMAC
  * Return true if more tx status need to be processed. false otherwise.
  */
-static bool BCMFASTPATH
+static bool
 wlc_bmac_txstatus(struct wlc_hw_info *wlc_hw, bool bound, bool *fatal)
 {
        bool morepending = false;
@@ -3098,7 +3002,7 @@ wlc_bmac_txstatus(struct wlc_hw_info *wlc_hw, bool bound, bool *fatal)
         */
        uint max_tx_num = bound ? wlc->pub->tunables->txsbnd : -1;
 
-       WL_TRACE("wl%d: wlc_bmac_txstatus\n", wlc_hw->unit);
+       BCMMSG(wlc->wiphy, "wl%d\n", wlc_hw->unit);
 
        txs = &txstatus;
        regs = wlc_hw->regs;
@@ -3106,9 +3010,8 @@ wlc_bmac_txstatus(struct wlc_hw_info *wlc_hw, bool bound, bool *fatal)
               && (s1 = R_REG(&regs->frmtxstatus)) & TXS_V) {
 
                if (s1 == 0xffffffff) {
-                       WL_ERROR("wl%d: %s: dead chip\n",
+                       wiphy_err(wlc->wiphy, "wl%d: %s: dead chip\n",
                                wlc_hw->unit, __func__);
-                       ASSERT(s1 != 0xffffffff);
                        return morepending;
                }
 
@@ -3133,8 +3036,8 @@ wlc_bmac_txstatus(struct wlc_hw_info *wlc_hw, bool bound, bool *fatal)
        if (n >= max_tx_num)
                morepending = true;
 
-       if (!pktq_empty(&wlc->active_queue->q))
-               wlc_send_q(wlc, wlc->active_queue);
+       if (!pktq_empty(&wlc->pkt_queue->q))
+               wlc_send_q(wlc);
 
        return morepending;
 }
@@ -3144,9 +3047,10 @@ void wlc_suspend_mac_and_wait(struct wlc_info *wlc)
        struct wlc_hw_info *wlc_hw = wlc->hw;
        d11regs_t *regs = wlc_hw->regs;
        u32 mc, mi;
+       struct wiphy *wiphy = wlc->wiphy;
 
-       WL_TRACE("wl%d: wlc_suspend_mac_and_wait: bandunit %d\n",
-                wlc_hw->unit, wlc_hw->band->bandunit);
+       BCMMSG(wlc->wiphy, "wl%d: bandunit %d\n", wlc_hw->unit,
+               wlc_hw->band->bandunit);
 
        /*
         * Track overlapping suspend requests
@@ -3161,21 +3065,23 @@ void wlc_suspend_mac_and_wait(struct wlc_info *wlc)
        mc = R_REG(&regs->maccontrol);
 
        if (mc == 0xffffffff) {
-               WL_ERROR("wl%d: %s: dead chip\n", wlc_hw->unit, __func__);
+               wiphy_err(wiphy, "wl%d: %s: dead chip\n", wlc_hw->unit,
+                         __func__);
                wl_down(wlc->wl);
                return;
        }
-       ASSERT(!(mc & MCTL_PSM_JMP_0));
-       ASSERT(mc & MCTL_PSM_RUN);
-       ASSERT(mc & MCTL_EN_MAC);
+       WARN_ON(mc & MCTL_PSM_JMP_0);
+       WARN_ON(!(mc & MCTL_PSM_RUN));
+       WARN_ON(!(mc & MCTL_EN_MAC));
 
        mi = R_REG(&regs->macintstatus);
        if (mi == 0xffffffff) {
-               WL_ERROR("wl%d: %s: dead chip\n", wlc_hw->unit, __func__);
+               wiphy_err(wiphy, "wl%d: %s: dead chip\n", wlc_hw->unit,
+                         __func__);
                wl_down(wlc->wl);
                return;
        }
-       ASSERT(!(mi & MI_MACSSPNDD));
+       WARN_ON(mi & MI_MACSSPNDD);
 
        wlc_bmac_mctrl(wlc_hw, MCTL_EN_MAC, 0);
 
@@ -3183,24 +3089,26 @@ void wlc_suspend_mac_and_wait(struct wlc_info *wlc)
                 WLC_MAX_MAC_SUSPEND);
 
        if (!(R_REG(&regs->macintstatus) & MI_MACSSPNDD)) {
-               WL_ERROR("wl%d: wlc_suspend_mac_and_wait: waited %d uS and MI_MACSSPNDD is still not on.\n",
-                        wlc_hw->unit, WLC_MAX_MAC_SUSPEND);
-               WL_ERROR("wl%d: psmdebug 0x%08x, phydebug 0x%08x, psm_brc 0x%04x\n",
-                        wlc_hw->unit,
-                        R_REG(&regs->psmdebug),
-                        R_REG(&regs->phydebug),
-                        R_REG(&regs->psm_brc));
+               wiphy_err(wiphy, "wl%d: wlc_suspend_mac_and_wait: waited %d uS"
+                         " and MI_MACSSPNDD is still not on.\n",
+                         wlc_hw->unit, WLC_MAX_MAC_SUSPEND);
+               wiphy_err(wiphy, "wl%d: psmdebug 0x%08x, phydebug 0x%08x, "
+                         "psm_brc 0x%04x\n", wlc_hw->unit,
+                         R_REG(&regs->psmdebug),
+                         R_REG(&regs->phydebug),
+                         R_REG(&regs->psm_brc));
        }
 
        mc = R_REG(&regs->maccontrol);
        if (mc == 0xffffffff) {
-               WL_ERROR("wl%d: %s: dead chip\n", wlc_hw->unit, __func__);
+               wiphy_err(wiphy, "wl%d: %s: dead chip\n", wlc_hw->unit,
+                         __func__);
                wl_down(wlc->wl);
                return;
        }
-       ASSERT(!(mc & MCTL_PSM_JMP_0));
-       ASSERT(mc & MCTL_PSM_RUN);
-       ASSERT(!(mc & MCTL_EN_MAC));
+       WARN_ON(mc & MCTL_PSM_JMP_0);
+       WARN_ON(!(mc & MCTL_PSM_RUN));
+       WARN_ON(mc & MCTL_EN_MAC);
 }
 
 void wlc_enable_mac(struct wlc_info *wlc)
@@ -3209,32 +3117,31 @@ void wlc_enable_mac(struct wlc_info *wlc)
        d11regs_t *regs = wlc_hw->regs;
        u32 mc, mi;
 
-       WL_TRACE("wl%d: wlc_enable_mac: bandunit %d\n",
-                wlc_hw->unit, wlc->band->bandunit);
+       BCMMSG(wlc->wiphy, "wl%d: bandunit %d\n", wlc_hw->unit,
+               wlc->band->bandunit);
 
        /*
         * Track overlapping suspend requests
         */
-       ASSERT(wlc_hw->mac_suspend_depth > 0);
        wlc_hw->mac_suspend_depth--;
        if (wlc_hw->mac_suspend_depth > 0)
                return;
 
        mc = R_REG(&regs->maccontrol);
-       ASSERT(!(mc & MCTL_PSM_JMP_0));
-       ASSERT(!(mc & MCTL_EN_MAC));
-       ASSERT(mc & MCTL_PSM_RUN);
+       WARN_ON(mc & MCTL_PSM_JMP_0);
+       WARN_ON(mc & MCTL_EN_MAC);
+       WARN_ON(!(mc & MCTL_PSM_RUN));
 
        wlc_bmac_mctrl(wlc_hw, MCTL_EN_MAC, MCTL_EN_MAC);
        W_REG(&regs->macintstatus, MI_MACSSPNDD);
 
        mc = R_REG(&regs->maccontrol);
-       ASSERT(!(mc & MCTL_PSM_JMP_0));
-       ASSERT(mc & MCTL_EN_MAC);
-       ASSERT(mc & MCTL_PSM_RUN);
+       WARN_ON(mc & MCTL_PSM_JMP_0);
+       WARN_ON(!(mc & MCTL_EN_MAC));
+       WARN_ON(!(mc & MCTL_PSM_RUN));
 
        mi = R_REG(&regs->macintstatus);
-       ASSERT(!(mi & MI_MACSSPNDD));
+       WARN_ON(mi & MI_MACSSPNDD);
 
        wlc_ucode_wake_override_clear(wlc_hw, WLC_WAKE_OVERRIDE_MACSUSPEND);
 }
@@ -3314,7 +3221,7 @@ void wlc_bmac_band_stf_ss_set(struct wlc_hw_info *wlc_hw, u8 stf_mode)
                wlc_upd_ofdm_pctl1_table(wlc_hw);
 }
 
-void BCMFASTPATH
+void
 wlc_bmac_read_tsf(struct wlc_hw_info *wlc_hw, u32 *tsf_l_ptr,
                  u32 *tsf_h_ptr)
 {
@@ -3331,8 +3238,9 @@ static bool wlc_bmac_validate_chip_access(struct wlc_hw_info *wlc_hw)
 {
        d11regs_t *regs;
        u32 w, val;
+       struct wiphy *wiphy = wlc_hw->wlc->wiphy;
 
-       WL_TRACE("wl%d: validate_chip_access\n", wlc_hw->unit);
+       BCMMSG(wiphy, "wl%d\n", wlc_hw->unit);
 
        regs = wlc_hw->regs;
 
@@ -3351,8 +3259,8 @@ static bool wlc_bmac_validate_chip_access(struct wlc_hw_info *wlc_hw)
        (void)R_REG(&regs->objaddr);
        val = R_REG(&regs->objdata);
        if (val != (u32) 0xaa5555aa) {
-               WL_ERROR("wl%d: validate_chip_access: SHM = 0x%x, expected 0xaa5555aa\n",
-                        wlc_hw->unit, val);
+               wiphy_err(wiphy, "wl%d: validate_chip_access: SHM = 0x%x, "
+                         "expected 0xaa5555aa\n", wlc_hw->unit, val);
                return false;
        }
 
@@ -3364,8 +3272,8 @@ static bool wlc_bmac_validate_chip_access(struct wlc_hw_info *wlc_hw)
        (void)R_REG(&regs->objaddr);
        val = R_REG(&regs->objdata);
        if (val != (u32) 0x55aaaa55) {
-               WL_ERROR("wl%d: validate_chip_access: SHM = 0x%x, expected 0x55aaaa55\n",
-                        wlc_hw->unit, val);
+               wiphy_err(wiphy, "wl%d: validate_chip_access: SHM = 0x%x, "
+                         "expected 0x55aaaa55\n", wlc_hw->unit, val);
                return false;
        }
 
@@ -3379,10 +3287,10 @@ static bool wlc_bmac_validate_chip_access(struct wlc_hw_info *wlc_hw)
        w = R_REG(&regs->maccontrol);
        if ((w != (MCTL_IHR_EN | MCTL_WAKE)) &&
            (w != (MCTL_IHR_EN | MCTL_GMODE | MCTL_WAKE))) {
-               WL_ERROR("wl%d: validate_chip_access: maccontrol = 0x%x, expected 0x%x or 0x%x\n",
-                        wlc_hw->unit, w,
-                        (MCTL_IHR_EN | MCTL_WAKE),
-                        (MCTL_IHR_EN | MCTL_GMODE | MCTL_WAKE));
+               wiphy_err(wiphy, "wl%d: validate_chip_access: maccontrol = "
+                         "0x%x, expected 0x%x or 0x%x\n", wlc_hw->unit, w,
+                         (MCTL_IHR_EN | MCTL_WAKE),
+                         (MCTL_IHR_EN | MCTL_GMODE | MCTL_WAKE));
                return false;
        }
 
@@ -3396,7 +3304,7 @@ void wlc_bmac_core_phypll_ctl(struct wlc_hw_info *wlc_hw, bool on)
        d11regs_t *regs;
        u32 tmp;
 
-       WL_TRACE("wl%d: wlc_bmac_core_phypll_ctl\n", wlc_hw->unit);
+       BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit);
 
        tmp = 0;
        regs = wlc_hw->regs;
@@ -3413,9 +3321,8 @@ void wlc_bmac_core_phypll_ctl(struct wlc_hw_info *wlc_hw, bool on)
                        tmp = R_REG(&regs->clk_ctl_st);
                        if ((tmp & (CCS_ERSRC_AVAIL_HT)) !=
                            (CCS_ERSRC_AVAIL_HT)) {
-                               WL_ERROR("%s: turn on PHY PLL failed\n",
-                                        __func__);
-                               ASSERT(0);
+                               wiphy_err(wlc_hw->wlc->wiphy, "%s: turn on PHY"
+                                         " PLL failed\n", __func__);
                        }
                } else {
                        OR_REG(&regs->clk_ctl_st,
@@ -3431,9 +3338,8 @@ void wlc_bmac_core_phypll_ctl(struct wlc_hw_info *wlc_hw, bool on)
                             (CCS_ERSRC_AVAIL_D11PLL | CCS_ERSRC_AVAIL_PHYPLL))
                            !=
                            (CCS_ERSRC_AVAIL_D11PLL | CCS_ERSRC_AVAIL_PHYPLL)) {
-                               WL_ERROR("%s: turn on PHY PLL failed\n",
-                                        __func__);
-                               ASSERT(0);
+                               wiphy_err(wlc_hw->wlc->wiphy, "%s: turn on "
+                                         "PHY PLL failed\n", __func__);
                        }
                }
        } else {
@@ -3449,9 +3355,7 @@ void wlc_coredisable(struct wlc_hw_info *wlc_hw)
 {
        bool dev_gone;
 
-       WL_TRACE("wl%d: %s\n", wlc_hw->unit, __func__);
-
-       ASSERT(!wlc_hw->up);
+       BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit);
 
        dev_gone = DEVICEREMOVED(wlc_hw->wlc);
 
@@ -3477,24 +3381,24 @@ void wlc_coredisable(struct wlc_hw_info *wlc_hw)
 
        /* remove gpio controls */
        if (wlc_hw->ucode_dbgsel)
-               si_gpiocontrol(wlc_hw->sih, ~0, 0, GPIO_DRV_PRIORITY);
+               ai_gpiocontrol(wlc_hw->sih, ~0, 0, GPIO_DRV_PRIORITY);
 
        wlc_hw->clk = false;
-       si_core_disable(wlc_hw->sih, 0);
+       ai_core_disable(wlc_hw->sih, 0);
        wlc_phy_hw_clk_state_upd(wlc_hw->band->pi, false);
 }
 
 /* power both the pll and external oscillator on/off */
 static void wlc_bmac_xtal(struct wlc_hw_info *wlc_hw, bool want)
 {
-       WL_TRACE("wl%d: wlc_bmac_xtal: want %d\n", wlc_hw->unit, want);
+       BCMMSG(wlc_hw->wlc->wiphy, "wl%d: want %d\n", wlc_hw->unit, want);
 
        /* dont power down if plldown is false or we must poll hw radio disable */
        if (!want && wlc_hw->pllreq)
                return;
 
        if (wlc_hw->sih)
-               si_clkctl_xtal(wlc_hw->sih, XTAL | PLL, want);
+               ai_clkctl_xtal(wlc_hw->sih, XTAL | PLL, want);
 
        wlc_hw->sbclk = want;
        if (!wlc_hw->sbclk) {
@@ -3516,8 +3420,7 @@ static void wlc_flushqueues(struct wlc_info *wlc)
                if (wlc_hw->di[i]) {
                        dma_txreclaim(wlc_hw->di[i], HNDDMA_RANGE_ALL);
                        TXPKTPENDCLR(wlc, i);
-                       WL_TRACE("wlc_flushqueues: pktpend fifo %d cleared\n",
-                                i);
+                       BCMMSG(wlc->wiphy, "pktpend fifo %d clrd\n", i);
                }
 
        /* free any posted rx packets */
@@ -3534,26 +3437,6 @@ void wlc_bmac_write_shm(struct wlc_hw_info *wlc_hw, uint offset, u16 v)
        wlc_bmac_write_objmem(wlc_hw, offset, v, OBJADDR_SHM_SEL);
 }
 
-/* Set a range of shared memory to a value.
- * SHM 'offset' needs to be an even address and
- * Buffer length 'len' must be an even number of bytes
- */
-void wlc_bmac_set_shm(struct wlc_hw_info *wlc_hw, uint offset, u16 v, int len)
-{
-       int i;
-
-       /* offset and len need to be even */
-       ASSERT((offset & 1) == 0);
-       ASSERT((len & 1) == 0);
-
-       if (len <= 0)
-               return;
-
-       for (i = 0; i < len; i += 2) {
-               wlc_bmac_write_objmem(wlc_hw, offset + i, v, OBJADDR_SHM_SEL);
-       }
-}
-
 static u16
 wlc_bmac_read_objmem(struct wlc_hw_info *wlc_hw, uint offset, u32 sel)
 {
@@ -3562,8 +3445,6 @@ wlc_bmac_read_objmem(struct wlc_hw_info *wlc_hw, uint offset, u32 sel)
        volatile u16 *objdata_hi = objdata_lo + 1;
        u16 v;
 
-       ASSERT((offset & 1) == 0);
-
        W_REG(&regs->objaddr, sel | (offset >> 2));
        (void)R_REG(&regs->objaddr);
        if (offset & 2) {
@@ -3582,8 +3463,6 @@ wlc_bmac_write_objmem(struct wlc_hw_info *wlc_hw, uint offset, u16 v, u32 sel)
        volatile u16 *objdata_lo = (volatile u16 *)&regs->objdata;
        volatile u16 *objdata_hi = objdata_lo + 1;
 
-       ASSERT((offset & 1) == 0);
-
        W_REG(&regs->objaddr, sel | (offset >> 2));
        (void)R_REG(&regs->objaddr);
        if (offset & 2) {
@@ -3606,11 +3485,7 @@ wlc_bmac_copyto_objmem(struct wlc_hw_info *wlc_hw, uint offset, const void *buf,
        const u8 *p = (const u8 *)buf;
        int i;
 
-       /* offset and len need to be even */
-       ASSERT((offset & 1) == 0);
-       ASSERT((len & 1) == 0);
-
-       if (len <= 0)
+       if (len <= 0 || (offset & 1) || (len & 1))
                return;
 
        for (i = 0; i < len; i += 2) {
@@ -3632,11 +3507,7 @@ wlc_bmac_copyfrom_objmem(struct wlc_hw_info *wlc_hw, uint offset, void *buf,
        u8 *p = (u8 *) buf;
        int i;
 
-       /* offset and len need to be even */
-       ASSERT((offset & 1) == 0);
-       ASSERT((len & 1) == 0);
-
-       if (len <= 0)
+       if (len <= 0 || (offset & 1) || (len & 1))
                return;
 
        for (i = 0; i < len; i += 2) {
@@ -3648,8 +3519,8 @@ wlc_bmac_copyfrom_objmem(struct wlc_hw_info *wlc_hw, uint offset, void *buf,
 
 void wlc_bmac_copyfrom_vars(struct wlc_hw_info *wlc_hw, char **buf, uint *len)
 {
-       WL_TRACE("wlc_bmac_copyfrom_vars, nvram vars totlen=%d\n",
-                wlc_hw->vars_size);
+       BCMMSG(wlc_hw->wlc->wiphy, "nvram vars totlen=%d\n",
+               wlc_hw->vars_size);
 
        *buf = wlc_hw->vars;
        *len = wlc_hw->vars_size;
@@ -3673,15 +3544,8 @@ void wlc_bmac_retrylimit_upd(struct wlc_hw_info *wlc_hw, u16 SRL, u16 LRL)
        }
 }
 
-void wlc_bmac_set_noreset(struct wlc_hw_info *wlc_hw, bool noreset_flag)
-{
-       wlc_hw->noreset = noreset_flag;
-}
-
 void wlc_bmac_pllreq(struct wlc_hw_info *wlc_hw, bool set, mbool req_bit)
 {
-       ASSERT(req_bit);
-
        if (set) {
                if (mboolisset(wlc_hw->pllreq, req_bit))
                        return;
@@ -3709,12 +3573,6 @@ void wlc_bmac_pllreq(struct wlc_hw_info *wlc_hw, bool set, mbool req_bit)
        return;
 }
 
-/* this will be true for all ai chips */
-bool wlc_bmac_taclear(struct wlc_hw_info *wlc_hw, bool ta_ok)
-{
-       return true;
-}
-
 u16 wlc_bmac_rate_shm_offset(struct wlc_hw_info *wlc_hw, u8 rate)
 {
        u16 table_ptr;
@@ -3730,7 +3588,7 @@ u16 wlc_bmac_rate_shm_offset(struct wlc_hw_info *wlc_hw, u8 rate)
        /* for a given rate, the LS-nibble of the PLCP SIGNAL field is
         * the index into the rate table.
         */
-       phy_rate = rate_info[rate] & RATE_MASK;
+       phy_rate = rate_info[rate] & WLC_RATE_MASK;
        index = phy_rate & 0xf;
 
        /* Find the SHM pointer to the rate table entry by looking in the
index 9c2c658d05abce3862175aeba44cf5e69aaecbe4..a5dccc273ac5adb409b80d441033d2adae617c4d 100644 (file)
@@ -130,8 +130,6 @@ extern int wlc_bmac_state_get(struct wlc_hw_info *wlc_hw,
                              wlc_bmac_state_t *state);
 extern void wlc_bmac_write_shm(struct wlc_hw_info *wlc_hw, uint offset, u16 v);
 extern u16 wlc_bmac_read_shm(struct wlc_hw_info *wlc_hw, uint offset);
-extern void wlc_bmac_set_shm(struct wlc_hw_info *wlc_hw, uint offset, u16 v,
-                            int len);
 extern void wlc_bmac_write_template_ram(struct wlc_hw_info *wlc_hw, int offset,
                                        int len, void *buf);
 extern void wlc_bmac_copyfrom_vars(struct wlc_hw_info *wlc_hw, char **buf,
@@ -151,8 +149,6 @@ extern void wlc_ucode_wake_override_set(struct wlc_hw_info *wlc_hw,
 extern void wlc_ucode_wake_override_clear(struct wlc_hw_info *wlc_hw,
                                          u32 override_bit);
 
-extern void wlc_bmac_set_rcmta(struct wlc_hw_info *wlc_hw, int idx,
-                              const u8 *addr);
 extern void wlc_bmac_set_addrmatch(struct wlc_hw_info *wlc_hw,
                                   int match_reg_offset,
                                   const u8 *addr);
@@ -163,7 +159,6 @@ extern void wlc_bmac_read_tsf(struct wlc_hw_info *wlc_hw, u32 *tsf_l_ptr,
                              u32 *tsf_h_ptr);
 extern void wlc_bmac_set_cwmin(struct wlc_hw_info *wlc_hw, u16 newmin);
 extern void wlc_bmac_set_cwmax(struct wlc_hw_info *wlc_hw, u16 newmax);
-extern void wlc_bmac_set_noreset(struct wlc_hw_info *wlc, bool noreset_flag);
 
 extern void wlc_bmac_retrylimit_upd(struct wlc_hw_info *wlc_hw, u16 SRL,
                                    u16 LRL);
@@ -176,7 +171,6 @@ extern void wlc_bmac_fifoerrors(struct wlc_hw_info *wlc_hw);
 extern void wlc_bmac_bw_set(struct wlc_hw_info *wlc_hw, u16 bw);
 extern void wlc_bmac_pllreq(struct wlc_hw_info *wlc_hw, bool set,
                            mbool req_bit);
-extern bool wlc_bmac_taclear(struct wlc_hw_info *wlc_hw, bool ta_ok);
 extern void wlc_bmac_hw_up(struct wlc_hw_info *wlc_hw);
 extern u16 wlc_bmac_rate_shm_offset(struct wlc_hw_info *wlc_hw, u8 rate);
 extern void wlc_bmac_antsel_set(struct wlc_hw_info *wlc_hw, u32 antsel_avail);
index bbcff4fb5147e8840c9ce8ff907f897d746fb931..2572541bde9b6a94c1b7dbb72e9ed3eb3336494f 100644 (file)
@@ -122,9 +122,6 @@ struct wlc_bsscfg {
 #define HWBCN_ENAB(cfg)                (((cfg)->flags & WLC_BSSCFG_HW_BCN) != 0)
 #define HWPRB_ENAB(cfg)                (((cfg)->flags & WLC_BSSCFG_HW_PRB) != 0)
 
-extern void wlc_bsscfg_ID_assign(struct wlc_info *wlc,
-                                struct wlc_bsscfg *bsscfg);
-
 /* Extend N_ENAB to per-BSS */
 #define BSS_N_ENAB(wlc, cfg) \
        (N_ENAB((wlc)->pub) && !((cfg)->flags & WLC_BSSCFG_11N_DISABLE))
index 96161c0ab65a3e22593abbb3b2538682949d5400..a3a2bf9b4f12f1642809311d7c12034d58e076d7 100644 (file)
@@ -21,7 +21,8 @@
 
 #include <bcmdefs.h>
 #include <bcmutils.h>
-#include <siutils.h>
+#include <bcmnvram.h>
+#include <aiutils.h>
 #include <sbhnddma.h>
 #include <wlioctl.h>
 
@@ -106,7 +107,8 @@ static void wlc_channel_min_txpower_limits_with_local_constraint(wlc_cm_info_t *
                                                                 *txpwr,
                                                                 u8
                                                                 local_constraint_qdbm);
-void wlc_locale_add_channels(chanvec_t *target, const chanvec_t *channels);
+static void wlc_locale_add_channels(chanvec_t *target,
+                                   const chanvec_t *channels);
 static const locale_mimo_info_t *wlc_get_mimo_2g(u8 locale_idx);
 static const locale_mimo_info_t *wlc_get_mimo_5g(u8 locale_idx);
 
@@ -396,7 +398,8 @@ static const chanvec_t *g_table_locale_base[] = {
        &locale_5g_HIGH4
 };
 
-void wlc_locale_add_channels(chanvec_t *target, const chanvec_t *channels)
+static void wlc_locale_add_channels(chanvec_t *target,
+                                   const chanvec_t *channels)
 {
        u8 i;
        for (i = 0; i < sizeof(chanvec_t); i++) {
@@ -594,10 +597,7 @@ struct chan20_info chan20_info[] = {
 static const locale_info_t *wlc_get_locale_2g(u8 locale_idx)
 {
        if (locale_idx >= ARRAY_SIZE(g_locale_2g_table)) {
-               WL_ERROR("%s: locale 2g index size out of range %d\n",
-                        __func__, locale_idx);
-               ASSERT(locale_idx < ARRAY_SIZE(g_locale_2g_table));
-               return NULL;
+               return NULL; /* error condition */
        }
        return g_locale_2g_table[locale_idx];
 }
@@ -605,29 +605,22 @@ static const locale_info_t *wlc_get_locale_2g(u8 locale_idx)
 static const locale_info_t *wlc_get_locale_5g(u8 locale_idx)
 {
        if (locale_idx >= ARRAY_SIZE(g_locale_5g_table)) {
-               WL_ERROR("%s: locale 5g index size out of range %d\n",
-                        __func__, locale_idx);
-               ASSERT(locale_idx < ARRAY_SIZE(g_locale_5g_table));
-               return NULL;
+               return NULL; /* error condition */
        }
        return g_locale_5g_table[locale_idx];
 }
 
-const locale_mimo_info_t *wlc_get_mimo_2g(u8 locale_idx)
+static const locale_mimo_info_t *wlc_get_mimo_2g(u8 locale_idx)
 {
        if (locale_idx >= ARRAY_SIZE(g_mimo_2g_table)) {
-               WL_ERROR("%s: mimo 2g index size out of range %d\n",
-                        __func__, locale_idx);
                return NULL;
        }
        return g_mimo_2g_table[locale_idx];
 }
 
-const locale_mimo_info_t *wlc_get_mimo_5g(u8 locale_idx)
+static const locale_mimo_info_t *wlc_get_mimo_5g(u8 locale_idx)
 {
        if (locale_idx >= ARRAY_SIZE(g_mimo_5g_table)) {
-               WL_ERROR("%s: mimo 5g index size out of range %d\n",
-                        __func__, locale_idx);
                return NULL;
        }
        return g_mimo_5g_table[locale_idx];
@@ -641,11 +634,12 @@ wlc_cm_info_t *wlc_channel_mgr_attach(struct wlc_info *wlc)
        struct wlc_pub *pub = wlc->pub;
        char *ccode;
 
-       WL_TRACE("wl%d: wlc_channel_mgr_attach\n", wlc->pub->unit);
+       BCMMSG(wlc->wiphy, "wl%d\n", wlc->pub->unit);
 
        wlc_cm = kzalloc(sizeof(wlc_cm_info_t), GFP_ATOMIC);
        if (wlc_cm == NULL) {
-               WL_ERROR("wl%d: %s: out of memory", pub->unit, __func__);
+               wiphy_err(wlc->wiphy, "wl%d: %s: out of memory", pub->unit,
+                         __func__);
                return NULL;
        }
        wlc_cm->pub = pub;
@@ -656,9 +650,6 @@ wlc_cm_info_t *wlc_channel_mgr_attach(struct wlc_info *wlc)
        ccode = getvar(wlc->pub->vars, "ccode");
        if (ccode) {
                strncpy(wlc->pub->srom_ccode, ccode, WLC_CNTRY_BUF_SZ - 1);
-               WL_NONE("%s: SROM country code is %c%c\n",
-                       __func__,
-                       wlc->pub->srom_ccode[0], wlc->pub->srom_ccode[1]);
        }
 
        /* internal country information which must match regulatory constraints in firmware */
@@ -666,8 +657,6 @@ wlc_cm_info_t *wlc_channel_mgr_attach(struct wlc_info *wlc)
        strncpy(country_abbrev, "X2", sizeof(country_abbrev) - 1);
        country = wlc_country_lookup(wlc, country_abbrev);
 
-       ASSERT(country != NULL);
-
        /* save default country for exiting 11d regulatory mode */
        strncpy(wlc->country_default, country_abbrev, WLC_CNTRY_BUF_SZ - 1);
 
@@ -708,10 +697,6 @@ wlc_set_countrycode_rev(wlc_cm_info_t *wlc_cm,
        char mapped_ccode[WLC_CNTRY_BUF_SZ];
        uint mapped_regrev;
 
-       WL_NONE("%s: (country_abbrev \"%s\", ccode \"%s\", regrev %d) SPROM \"%s\"/%u\n",
-               __func__, country_abbrev, ccode, regrev,
-               wlc_cm->srom_ccode, wlc_cm->srom_regrev);
-
        /* if regrev is -1, lookup the mapped country code,
         * otherwise use the ccode and regrev directly
         */
@@ -722,14 +707,13 @@ wlc_set_countrycode_rev(wlc_cm_info_t *wlc_cm,
                                        &mapped_regrev);
        } else {
                /* find the matching built-in country definition */
-               ASSERT(0);
                country = wlc_country_lookup_direct(ccode, regrev);
                strncpy(mapped_ccode, ccode, WLC_CNTRY_BUF_SZ);
                mapped_regrev = regrev;
        }
 
        if (country == NULL)
-               return BCME_BADARG;
+               return -EINVAL;
 
        /* set the driver state for the country */
        wlc_set_country_common(wlc_cm, country_abbrev, mapped_ccode,
@@ -752,8 +736,6 @@ wlc_set_country_common(wlc_cm_info_t *wlc_cm,
        struct wlc_info *wlc = wlc_cm->wlc;
        char prev_country_abbrev[WLC_CNTRY_BUF_SZ];
 
-       ASSERT(country != NULL);
-
        /* save current country state */
        wlc_cm->country = country;
 
@@ -821,8 +803,8 @@ static const country_info_t *wlc_countrycode_map(wlc_cm_info_t *wlc_cm,
 
        /* check for currently supported ccode size */
        if (strlen(ccode) > (WLC_CNTRY_BUF_SZ - 1)) {
-               WL_ERROR("wl%d: %s: ccode \"%s\" too long for match\n",
-                        wlc->pub->unit, __func__, ccode);
+               wiphy_err(wlc->wiphy, "wl%d: %s: ccode \"%s\" too long for "
+                         "match\n", wlc->pub->unit, __func__, ccode);
                return NULL;
        }
 
@@ -837,8 +819,7 @@ static const country_info_t *wlc_countrycode_map(wlc_cm_info_t *wlc_cm,
        if (!strcmp(srom_ccode, ccode)) {
                *mapped_regrev = srom_regrev;
                mapped = 0;
-               WL_ERROR("srom_code == ccode %s\n", __func__);
-               ASSERT(0);
+               wiphy_err(wlc->wiphy, "srom_code == ccode %s\n", __func__);
        } else {
                mapped =
                    wlc_country_aggregate_map(wlc_cm, ccode, mapped_ccode,
@@ -851,7 +832,6 @@ static const country_info_t *wlc_countrycode_map(wlc_cm_info_t *wlc_cm,
        /* if there is not an exact rev match, default to rev zero */
        if (country == NULL && *mapped_regrev != 0) {
                *mapped_regrev = 0;
-               ASSERT(0);
                country =
                    wlc_country_lookup_direct(mapped_ccode, *mapped_regrev);
        }
@@ -888,9 +868,6 @@ static const country_info_t *wlc_country_lookup_direct(const char *ccode,
                        return &cntry_locales[i].country;
                }
        }
-
-       WL_ERROR("%s: Returning NULL\n", __func__);
-       ASSERT(0);
        return NULL;
 }
 
@@ -911,12 +888,10 @@ wlc_channels_init(wlc_cm_info_t *wlc_cm, const country_info_t *country)
                li = BAND_5G(band->bandtype) ?
                    wlc_get_locale_5g(country->locale_5G) :
                    wlc_get_locale_2g(country->locale_2G);
-               ASSERT(li);
                wlc_cm->bandstate[band->bandunit].locale_flags = li->flags;
                li_mimo = BAND_5G(band->bandtype) ?
                    wlc_get_mimo_5g(country->locale_mimo_5G) :
                    wlc_get_mimo_2g(country->locale_mimo_2G);
-               ASSERT(li_mimo);
 
                /* merge the mimo non-mimo locale flags */
                wlc_cm->bandstate[band->bandunit].locale_flags |=
@@ -968,9 +943,10 @@ static void wlc_channels_commit(wlc_cm_info_t *wlc_cm)
        if (chan == INVCHANNEL) {
                /* country/locale with no valid channels, set the radio disable bit */
                mboolset(wlc->pub->radio_disabled, WL_RADIO_COUNTRY_DISABLE);
-               WL_ERROR("wl%d: %s: no valid channel for \"%s\" nbands %d bandlocked %d\n",
-                        wlc->pub->unit, __func__,
-                        wlc_cm->country_abbrev, NBANDS(wlc), wlc->bandlocked);
+               wiphy_err(wlc->wiphy, "wl%d: %s: no valid channel for \"%s\" "
+                         "nbands %d bandlocked %d\n", wlc->pub->unit,
+                         __func__, wlc_cm->country_abbrev, NBANDS(wlc),
+                         wlc->bandlocked);
        } else
            if (mboolisset(wlc->pub->radio_disabled,
                WL_RADIO_COUNTRY_DISABLE)) {
@@ -1520,10 +1496,9 @@ wlc_valid_chanspec_ext(wlc_cm_info_t *wlc_cm, chanspec_t chspec, bool dualband)
        u8 channel = CHSPEC_CHANNEL(chspec);
 
        /* check the chanspec */
-       if (wf_chspec_malformed(chspec)) {
-               WL_ERROR("wl%d: malformed chanspec 0x%x\n",
-                        wlc->pub->unit, chspec);
-               ASSERT(0);
+       if (bcm_chspec_malformed(chspec)) {
+               wiphy_err(wlc->wiphy, "wl%d: malformed chanspec 0x%x\n",
+                       wlc->pub->unit, chspec);
                return false;
        }
 
index 50a4e38b4cca3a5db31d94a528b045386e7630af..cab10c73793712fdc5fe92e0466012bf8d83cdce 100644 (file)
@@ -115,7 +115,7 @@ typedef struct wsec_key {
 #define WSEC_IBSS_PEER_GROUP_KEY       (1 << 7)        /* Flag: group key for a IBSS PEER */
 #define WSEC_ICV_ERROR         (1 << 8)        /* Provoke deliberate ICV error */
 
-#define wlc_key_insert(a, b, c, d, e, f, g, h, i, j) (BCME_ERROR)
+#define wlc_key_insert(a, b, c, d, e, f, g, h, i, j) (-EBADE)
 #define wlc_key_update(a, b, c) do {} while (0)
 #define wlc_key_remove(a, b, c) do {} while (0)
 #define wlc_key_remove_all(a, b) do {} while (0)
@@ -126,12 +126,12 @@ typedef struct wsec_key {
 #define wlc_key_hw_init(a, b, c)  do {} while (0)
 #define wlc_key_hw_wowl_init(a, b, c, d) do {} while (0)
 #define wlc_key_sw_wowl_update(a, b, c, d, e) do {} while (0)
-#define wlc_key_sw_wowl_create(a, b, c) (BCME_ERROR)
+#define wlc_key_sw_wowl_create(a, b, c) (-EBADE)
 #define wlc_key_iv_update(a, b, c, d, e) do {(void)e; } while (0)
 #define wlc_key_iv_init(a, b, c) do {} while (0)
-#define wlc_key_set_error(a, b, c) (BCME_ERROR)
-#define wlc_key_dump_hw(a, b) (BCME_ERROR)
-#define wlc_key_dump_sw(a, b) (BCME_ERROR)
+#define wlc_key_set_error(a, b, c) (-EBADE)
+#define wlc_key_dump_hw(a, b) (-EBADE)
+#define wlc_key_dump_sw(a, b) (-EBADE)
 #define wlc_key_defkeyflag(a) (0)
 #define wlc_rcmta_add_bssid(a, b) do {} while (0)
 #define wlc_rcmta_del_bssid(a, b) do {} while (0)
index ab7ab850e199275703e5dfca1826a9e681ae4f8e..4b4a31eff90c9f7cd2f4ae69552e2d47460d9faa 100644 (file)
 #include <linux/kernel.h>
 #include <linux/ctype.h>
 #include <linux/etherdevice.h>
+#include <linux/pci_ids.h>
 #include <net/mac80211.h>
 
 #include <bcmdefs.h>
 #include <bcmdevs.h>
 #include <bcmutils.h>
 #include <bcmwifi.h>
-#include <siutils.h>
+#include <bcmnvram.h>
+#include <aiutils.h>
 #include <pcicfg.h>
 #include <bcmsrom.h>
 #include <wlioctl.h>
 #include <sbhnddma.h>
 #include <hnddma.h>
-#include <hndpmu.h>
 
+#include "wlc_pmu.h"
 #include "d11.h"
 #include "wlc_types.h"
 #include "wlc_cfg.h"
 #include "wlc_alloc.h"
 #include "wl_dbg.h"
 
-/*
- *     Disable statistics counting for WME
- */
-#define WLCNTSET(a, b)
-#define WLCNTINCR(a)
-#define WLCNTADD(a, b)
+#include "wl_mac80211.h"
 
 /*
  * WPA(2) definitions
@@ -242,7 +239,7 @@ static const u8 acbitmap2maxprio[] = {
 #define WLC_REPLAY_CNTRS_VALUE WPA_CAP_16_REPLAY_CNTRS
 
 /* local prototypes */
-static u16 BCMFASTPATH wlc_d11hdrs_mac80211(struct wlc_info *wlc,
+static u16 wlc_d11hdrs_mac80211(struct wlc_info *wlc,
                                               struct ieee80211_hw *hw,
                                               struct sk_buff *p,
                                               struct scb *scb, uint frag,
@@ -250,8 +247,6 @@ static u16 BCMFASTPATH wlc_d11hdrs_mac80211(struct wlc_info *wlc,
                                               uint next_frag_len,
                                               wsec_key_t *key,
                                               ratespec_t rspec_override);
-
-static void wlc_ctrupd_cache(u16 cur_stat, u16 *macstat_snapshot, u32 *macstat);
 static void wlc_bss_default_init(struct wlc_info *wlc);
 static void wlc_ucode_mac_upd(struct wlc_info *wlc);
 static ratespec_t mac80211_wlc_set_nrate(struct wlc_info *wlc,
@@ -273,13 +268,13 @@ static void wlc_txflowcontrol_signal(struct wlc_info *wlc,
                                     struct wlc_txq_info *qi,
                                     bool on, int prio);
 static void wlc_txflowcontrol_reset(struct wlc_info *wlc);
-static u16 wlc_compute_airtime(struct wlc_info *wlc, ratespec_t rspec,
-                                 uint length);
-static void wlc_compute_cck_plcp(ratespec_t rate, uint length, u8 *plcp);
+static void wlc_compute_cck_plcp(struct wlc_info *wlc, ratespec_t rate,
+                                uint length, u8 *plcp);
 static void wlc_compute_ofdm_plcp(ratespec_t rate, uint length, u8 *plcp);
 static void wlc_compute_mimo_plcp(ratespec_t rate, uint length, u8 *plcp);
 static u16 wlc_compute_frame_dur(struct wlc_info *wlc, ratespec_t rate,
                                    u8 preamble_type, uint next_frag_len);
+static u64 wlc_recover_tsf64(struct wlc_info *wlc, struct wlc_d11rxhdr *rxh);
 static void wlc_recvctl(struct wlc_info *wlc,
                        d11rxhdr_t *rxh, struct sk_buff *p);
 static uint wlc_calc_frame_len(struct wlc_info *wlc, ratespec_t rate,
@@ -320,35 +315,6 @@ static void wlc_ofdm_rateset_war(struct wlc_info *wlc);
 static int _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
                      struct wlc_if *wlcif);
 
-#if defined(BCMDBG)
-void wlc_get_rcmta(struct wlc_info *wlc, int idx, u8 *addr)
-{
-       d11regs_t *regs = wlc->regs;
-       u32 v32;
-
-       WL_TRACE("wl%d: %s\n", WLCWLUNIT(wlc), __func__);
-
-       W_REG(&regs->objaddr, (OBJADDR_RCMTA_SEL | (idx * 2)));
-       (void)R_REG(&regs->objaddr);
-       v32 = R_REG(&regs->objdata);
-       addr[0] = (u8) v32;
-       addr[1] = (u8) (v32 >> 8);
-       addr[2] = (u8) (v32 >> 16);
-       addr[3] = (u8) (v32 >> 24);
-       W_REG(&regs->objaddr, (OBJADDR_RCMTA_SEL | ((idx * 2) + 1)));
-       (void)R_REG(&regs->objaddr);
-       v32 = R_REG(&regs->objdata);
-       addr[4] = (u8) v32;
-       addr[5] = (u8) (v32 >> 8);
-}
-#endif                         /* defined(BCMDBG) */
-
-/* keep the chip awake if needed */
-bool wlc_stay_awake(struct wlc_info *wlc)
-{
-       return true;
-}
-
 /* conditions under which the PM bit should be set in outgoing frames and STAY_AWAKE is meaningful
  */
 bool wlc_ps_allowed(struct wlc_info *wlc)
@@ -380,7 +346,7 @@ bool wlc_ps_allowed(struct wlc_info *wlc)
 
 void wlc_reset(struct wlc_info *wlc)
 {
-       WL_TRACE("wl%d: wlc_reset\n", wlc->pub->unit);
+       BCMMSG(wlc->wiphy, "wl%d\n", wlc->pub->unit);
 
        wlc->check_for_unaligned_tbtt = false;
 
@@ -392,14 +358,14 @@ void wlc_reset(struct wlc_info *wlc)
                sizeof(macstat_t));
 
        wlc_bmac_reset(wlc->hw);
-       wlc_ampdu_reset(wlc->ampdu);
        wlc->txretried = 0;
 
 }
 
 void wlc_fatal_error(struct wlc_info *wlc)
 {
-       WL_ERROR("wl%d: fatal error, reinitializing\n", wlc->pub->unit);
+       wiphy_err(wlc->wiphy, "wl%d: fatal error, reinitializing\n",
+                 wlc->pub->unit);
        wl_init(wlc->wl);
 }
 
@@ -414,11 +380,6 @@ static chanspec_t wlc_init_chanspec(struct wlc_info *wlc)
            1 | WL_CHANSPEC_BW_20 | WL_CHANSPEC_CTL_SB_NONE |
            WL_CHANSPEC_BAND_2G;
 
-       /* make sure the channel is on the supported band if we are band-restricted */
-       if (wlc->bandlocked || NBANDS(wlc) == 1) {
-               ASSERT(CHSPEC_WLCBANDUNIT(chanspec) == wlc->band->bandunit);
-       }
-       ASSERT(wlc_valid_chanspec_db(wlc->cmi, chanspec));
        return chanspec;
 }
 
@@ -440,7 +401,7 @@ void wlc_init(struct wlc_info *wlc)
        struct wlc_bsscfg *bsscfg;
        bool mute = false;
 
-       WL_TRACE("wl%d: wlc_init\n", wlc->pub->unit);
+       BCMMSG(wlc->wiphy, "wl%d\n", wlc->pub->unit);
 
        regs = wlc->regs;
 
@@ -463,7 +424,6 @@ void wlc_init(struct wlc_info *wlc)
        wlc_bcn_li_upd(wlc);
        wlc->bcn_wait_prd =
            (u8) (wlc_bmac_read_shm(wlc->hw, M_NOSLPZNATDTIM) >> 10);
-       ASSERT(wlc->bcn_wait_prd > 0);
 
        /* the world is new again, so is our reported rate */
        wlc_reprate_init(wlc);
@@ -524,7 +484,7 @@ void wlc_init(struct wlc_info *wlc)
        /* Enable EDCF mode (while the MAC is suspended) */
        if (EDCF_ENAB(wlc->pub)) {
                OR_REG(&regs->ifs_ctl, IFS_USEEDCF);
-               wlc_edcf_setparams(wlc->cfg, false);
+               wlc_edcf_setparams(wlc, false);
        }
 
        /* Init precedence maps for empty FIFOs */
@@ -559,7 +519,6 @@ void wlc_init(struct wlc_info *wlc)
        if (WLC_WME_RETRY_SHORT_GET(wlc, 0) == 0) {     /* Uninitialized; read from HW */
                int ac;
 
-               ASSERT(wlc->clk);
                for (ac = 0; ac < AC_COUNT; ac++) {
                        wlc->wme_retries[ac] =
                            wlc_read_shm(wlc, M_AC_TXLMT_ADDR(ac));
@@ -604,82 +563,27 @@ void wlc_mac_promisc(struct wlc_info *wlc)
        wlc_mctrl(wlc, MCTL_PROMISC | MCTL_KEEPCONTROL, promisc_bits);
 }
 
-/* check if hps and wake states of sw and hw are in sync */
-bool wlc_ps_check(struct wlc_info *wlc)
-{
-       bool res = true;
-       bool hps, wake;
-       bool wake_ok;
-
-       if (!AP_ACTIVE(wlc)) {
-               u32 tmp;
-               tmp = R_REG(&wlc->regs->maccontrol);
-
-               /*
-                * If deviceremoved is detected, then don't take any action as
-                * this can be called in any context. Assume that caller will
-                * take care of the condition. This is just to avoid assert
-                */
-               if (tmp == 0xffffffff) {
-                       WL_ERROR("wl%d: %s: dead chip\n",
-                                wlc->pub->unit, __func__);
-                       return DEVICEREMOVED(wlc);
-               }
-
-               hps = PS_ALLOWED(wlc);
-
-               if (hps != ((tmp & MCTL_HPS) != 0)) {
-                       int idx;
-                       struct wlc_bsscfg *cfg;
-                       WL_ERROR("wl%d: hps not sync, sw %d, maccontrol 0x%x\n",
-                                wlc->pub->unit, hps, tmp);
-                       FOREACH_BSS(wlc, idx, cfg) {
-                               if (!BSSCFG_STA(cfg))
-                                       continue;
-                       }
-
-                       res = false;
-               }
-               /* For a monolithic build the wake check can be exact since it looks at wake
-                * override bits. The MCTL_WAKE bit should match the 'wake' value.
-                */
-               wake = STAY_AWAKE(wlc) || wlc->hw->wake_override;
-               wake_ok = (wake == ((tmp & MCTL_WAKE) != 0));
-               if (hps && !wake_ok) {
-                       WL_ERROR("wl%d: wake not sync, sw %d maccontrol 0x%x\n",
-                                wlc->pub->unit, wake, tmp);
-                       res = false;
-               }
-       }
-       ASSERT(res);
-       return res;
-}
-
 /* push sw hps and wake state through hardware */
 void wlc_set_ps_ctrl(struct wlc_info *wlc)
 {
        u32 v1, v2;
-       bool hps, wake;
+       bool hps;
        bool awake_before;
 
        hps = PS_ALLOWED(wlc);
-       wake = hps ? (STAY_AWAKE(wlc)) : true;
 
-       WL_TRACE("wl%d: wlc_set_ps_ctrl: hps %d wake %d\n",
-                wlc->pub->unit, hps, wake);
+       BCMMSG(wlc->wiphy, "wl%d: hps %d\n", wlc->pub->unit, hps);
 
        v1 = R_REG(&wlc->regs->maccontrol);
-       v2 = 0;
+       v2 = MCTL_WAKE;
        if (hps)
                v2 |= MCTL_HPS;
-       if (wake)
-               v2 |= MCTL_WAKE;
 
        wlc_mctrl(wlc, MCTL_WAKE | MCTL_HPS, v2);
 
        awake_before = ((v1 & MCTL_WAKE) || ((v1 & MCTL_HPS) == 0));
 
-       if (wake && !awake_before)
+       if (!awake_before)
                wlc_bmac_wait_for_wake(wlc->hw);
 
 }
@@ -730,8 +634,6 @@ void wlc_switch_shortslot(struct wlc_info *wlc, bool shortslot)
        int idx;
        struct wlc_bsscfg *cfg;
 
-       ASSERT(wlc->band->gmode);
-
        /* use the override if it is set */
        if (wlc->shortslot_override != WLC_SHORTSLOT_AUTO)
                shortslot = (wlc->shortslot_override == WLC_SHORTSLOT_ON);
@@ -762,8 +664,8 @@ static u8 wlc_local_constraint_qdbm(struct wlc_info *wlc)
 
        local = WLC_TXPWR_MAX;
        if (wlc->pub->associated &&
-           (wf_chspec_ctlchan(wlc->chanspec) ==
-            wf_chspec_ctlchan(wlc->home_chanspec))) {
+           (bcm_chspec_ctlchan(wlc->chanspec) ==
+            bcm_chspec_ctlchan(wlc->home_chanspec))) {
 
                /* get the local power constraint if we are on the AP's
                 * channel [802.11h, 7.3.2.13]
@@ -826,9 +728,8 @@ void wlc_set_chanspec(struct wlc_info *wlc, chanspec_t chanspec)
        chanspec_t old_chanspec = wlc->chanspec;
 
        if (!wlc_valid_chanspec_db(wlc->cmi, chanspec)) {
-               WL_ERROR("wl%d: %s: Bad channel %d\n",
-                        wlc->pub->unit, __func__, CHSPEC_CHANNEL(chanspec));
-               ASSERT(wlc_valid_chanspec_db(wlc->cmi, chanspec));
+               wiphy_err(wlc->wiphy, "wl%d: %s: Bad channel %d\n",
+                         wlc->pub->unit, __func__, CHSPEC_CHANNEL(chanspec));
                return;
        }
 
@@ -838,9 +739,10 @@ void wlc_set_chanspec(struct wlc_info *wlc, chanspec_t chanspec)
                if (wlc->band->bandunit != bandunit || wlc->bandinit_pending) {
                        switchband = true;
                        if (wlc->bandlocked) {
-                               WL_ERROR("wl%d: %s: chspec %d band is locked!\n",
-                                        wlc->pub->unit, __func__,
-                                        CHSPEC_CHANNEL(chanspec));
+                               wiphy_err(wlc->wiphy, "wl%d: %s: chspec %d "
+                                         "band is locked!\n",
+                                         wlc->pub->unit, __func__,
+                                         CHSPEC_CHANNEL(chanspec));
                                return;
                        }
                        /* BMAC_NOTE: should the setband call come after the wlc_bmac_chanspec() ?
@@ -852,8 +754,6 @@ void wlc_set_chanspec(struct wlc_info *wlc, chanspec_t chanspec)
                }
        }
 
-       ASSERT(N_ENAB(wlc->pub) || !CHSPEC_IS40(chanspec));
-
        /* sync up phy/radio chanspec */
        wlc_set_phy_chanspec(wlc, chanspec);
 
@@ -887,7 +787,7 @@ static int wlc_get_current_txpwr(struct wlc_info *wlc, void *pwr, uint len)
        if (len == sizeof(tx_power_legacy_t))
                old_power = (tx_power_legacy_t *) pwr;
        else if (len < sizeof(tx_power_t))
-               return BCME_BUFTOOSHORT;
+               return -EOVERFLOW;
 
        memset(&power, 0, sizeof(tx_power_t));
 
@@ -1098,10 +998,10 @@ ratespec_t wlc_lowest_basic_rspec(struct wlc_info *wlc, wlc_rateset_t *rs)
        uint i;
 
        /* Use the lowest basic rate */
-       lowest_basic_rspec = rs->rates[0] & RATE_MASK;
+       lowest_basic_rspec = rs->rates[0] & WLC_RATE_MASK;
        for (i = 0; i < rs->count; i++) {
                if (rs->rates[i] & WLC_RATE_FLAG) {
-                       lowest_basic_rspec = rs->rates[i] & RATE_MASK;
+                       lowest_basic_rspec = rs->rates[i] & WLC_RATE_MASK;
                        break;
                }
        }
@@ -1141,7 +1041,7 @@ void wlc_beacon_phytxctl_txant_upd(struct wlc_info *wlc, ratespec_t bcn_rspec)
 */
 void wlc_protection_upd(struct wlc_info *wlc, uint idx, int val)
 {
-       WL_TRACE("wlc_protection_upd: idx %d, val %d\n", idx, val);
+       BCMMSG(wlc->wiphy, "idx %d, val %d\n", idx, val);
 
        switch (idx) {
        case WLC_PROT_G_SPEC:
@@ -1179,7 +1079,6 @@ void wlc_protection_upd(struct wlc_info *wlc, uint idx, int val)
                break;
 
        default:
-               ASSERT(0);
                break;
        }
 
@@ -1252,14 +1151,12 @@ static void wlc_bandinit_ordered(struct wlc_info *wlc, chanspec_t chanspec)
        uint parkband;
        uint i, band_order[2];
 
-       WL_TRACE("wl%d: wlc_bandinit_ordered\n", wlc->pub->unit);
+       BCMMSG(wlc->wiphy, "wl%d\n", wlc->pub->unit);
        /*
         * We might have been bandlocked during down and the chip power-cycled (hibernate).
         * figure out the right band to park on
         */
        if (wlc->bandlocked || NBANDS(wlc) == 1) {
-               ASSERT(CHSPEC_WLCBANDUNIT(chanspec) == wlc->band->bandunit);
-
                parkband = wlc->band->bandunit; /* updated in wlc_bandlock() */
                band_order[0] = band_order[1] = parkband;
        } else {
@@ -1281,7 +1178,7 @@ static void wlc_bandinit_ordered(struct wlc_info *wlc, chanspec_t chanspec)
 
                /* fill in hw_rate */
                wlc_rateset_filter(&default_rateset, &wlc->band->hw_rateset,
-                                  false, WLC_RATES_CCK_OFDM, RATE_MASK,
+                                  false, WLC_RATES_CCK_OFDM, WLC_RATE_MASK,
                                   (bool) N_ENAB(wlc->pub));
 
                /* init basic rate lookup */
@@ -1295,7 +1192,7 @@ static void wlc_bandinit_ordered(struct wlc_info *wlc, chanspec_t chanspec)
 /* band-specific init */
 static void WLBANDINITFN(wlc_bsinit) (struct wlc_info *wlc)
 {
-       WL_TRACE("wl%d: wlc_bsinit: bandunit %d\n",
+       BCMMSG(wlc->wiphy, "wl%d: bandunit %d\n",
                 wlc->pub->unit, wlc->band->bandunit);
 
        /* write ucode ACK/CTS rate table */
@@ -1315,10 +1212,6 @@ static void WLBANDINITFN(wlc_setband) (struct wlc_info *wlc, uint bandunit)
        int idx;
        struct wlc_bsscfg *cfg;
 
-       ASSERT(NBANDS(wlc) > 1);
-       ASSERT(!wlc->bandlocked);
-       ASSERT(bandunit != wlc->band->bandunit || wlc->bandinit_pending);
-
        wlc->band = wlc->bandstate[bandunit];
 
        if (!wlc->pub->up)
@@ -1355,41 +1248,28 @@ void wlc_wme_initparams_sta(struct wlc_info *wlc, wme_param_ie_t *pe)
                  cpu_to_le16(EDCF_AC_VO_TXOP_STA)}
                 }
        };
-
-       ASSERT(sizeof(*pe) == WME_PARAM_IE_LEN);
        memcpy(pe, &stadef, sizeof(*pe));
 }
 
-void wlc_wme_setparams(struct wlc_info *wlc, u16 aci, void *arg, bool suspend)
+void wlc_wme_setparams(struct wlc_info *wlc, u16 aci,
+                      const struct ieee80211_tx_queue_params *params,
+                      bool suspend)
 {
        int i;
        shm_acparams_t acp_shm;
        u16 *shm_entry;
-       struct ieee80211_tx_queue_params *params = arg;
-
-       ASSERT(wlc);
 
        /* Only apply params if the core is out of reset and has clocks */
        if (!wlc->clk) {
-               WL_ERROR("wl%d: %s : no-clock\n", wlc->pub->unit, __func__);
+               wiphy_err(wlc->wiphy, "wl%d: %s : no-clock\n", wlc->pub->unit,
+                         __func__);
                return;
        }
 
-       /*
-        * AP uses AC params from wme_param_ie_ap.
-        * AP advertises AC params from wme_param_ie.
-        * STA uses AC params from wme_param_ie.
-        */
-
        wlc->wme_admctl = 0;
 
        do {
                memset((char *)&acp_shm, 0, sizeof(shm_acparams_t));
-               /* find out which ac this set of params applies to */
-               ASSERT(aci < AC_COUNT);
-               /* set the admission control policy for this AC */
-               /* wlc->wme_admctl |= 1 << aci; *//* should be set ??  seems like off by default */
-
                /* fill in shm ac params struct */
                acp_shm.txop = le16_to_cpu(params->txop);
                /* convert from units of 32us to us for ucode */
@@ -1403,8 +1283,8 @@ void wlc_wme_setparams(struct wlc_info *wlc, u16 aci, void *arg, bool suspend)
 
                if (acp_shm.aifs < EDCF_AIFSN_MIN
                    || acp_shm.aifs > EDCF_AIFSN_MAX) {
-                       WL_ERROR("wl%d: wlc_edcf_setparams: bad aifs %d\n",
-                                wlc->pub->unit, acp_shm.aifs);
+                       wiphy_err(wlc->wiphy, "wl%d: wlc_edcf_setparams: bad "
+                                 "aifs %d\n", wlc->pub->unit, acp_shm.aifs);
                        continue;
                }
 
@@ -1439,20 +1319,14 @@ void wlc_wme_setparams(struct wlc_info *wlc, u16 aci, void *arg, bool suspend)
 
 }
 
-void wlc_edcf_setparams(struct wlc_bsscfg *cfg, bool suspend)
+void wlc_edcf_setparams(struct wlc_info *wlc, bool suspend)
 {
-       struct wlc_info *wlc = cfg->wlc;
-       uint aci, i, j;
+       u16 aci;
+       int i_ac;
        edcf_acparam_t *edcf_acp;
-       shm_acparams_t acp_shm;
-       u16 *shm_entry;
 
-       ASSERT(cfg);
-       ASSERT(wlc);
-
-       /* Only apply params if the core is out of reset and has clocks */
-       if (!wlc->clk)
-               return;
+       struct ieee80211_tx_queue_params txq_pars;
+       struct ieee80211_tx_queue_params *params = &txq_pars;
 
        /*
         * AP uses AC params from wme_param_ie_ap.
@@ -1462,59 +1336,24 @@ void wlc_edcf_setparams(struct wlc_bsscfg *cfg, bool suspend)
 
        edcf_acp = (edcf_acparam_t *) &wlc->wme_param_ie.acparam[0];
 
-       wlc->wme_admctl = 0;
-
-       for (i = 0; i < AC_COUNT; i++, edcf_acp++) {
-               memset((char *)&acp_shm, 0, sizeof(shm_acparams_t));
+       for (i_ac = 0; i_ac < AC_COUNT; i_ac++, edcf_acp++) {
                /* find out which ac this set of params applies to */
                aci = (edcf_acp->ACI & EDCF_ACI_MASK) >> EDCF_ACI_SHIFT;
-               ASSERT(aci < AC_COUNT);
                /* set the admission control policy for this AC */
                if (edcf_acp->ACI & EDCF_ACM_MASK) {
                        wlc->wme_admctl |= 1 << aci;
                }
 
                /* fill in shm ac params struct */
-               acp_shm.txop = le16_to_cpu(edcf_acp->TXOP);
-               /* convert from units of 32us to us for ucode */
-               wlc->edcf_txop[aci] = acp_shm.txop =
-                   EDCF_TXOP2USEC(acp_shm.txop);
-               acp_shm.aifs = (edcf_acp->ACI & EDCF_AIFSN_MASK);
-
-               if (aci == AC_VI && acp_shm.txop == 0
-                   && acp_shm.aifs < EDCF_AIFSN_MAX)
-                       acp_shm.aifs++;
-
-               if (acp_shm.aifs < EDCF_AIFSN_MIN
-                   || acp_shm.aifs > EDCF_AIFSN_MAX) {
-                       WL_ERROR("wl%d: wlc_edcf_setparams: bad aifs %d\n",
-                                wlc->pub->unit, acp_shm.aifs);
-                       continue;
-               }
+               params->txop = edcf_acp->TXOP;
+               params->aifs = edcf_acp->ACI;
 
                /* CWmin = 2^(ECWmin) - 1 */
-               acp_shm.cwmin = EDCF_ECW2CW(edcf_acp->ECW & EDCF_ECWMIN_MASK);
+               params->cw_min = EDCF_ECW2CW(edcf_acp->ECW & EDCF_ECWMIN_MASK);
                /* CWmax = 2^(ECWmax) - 1 */
-               acp_shm.cwmax = EDCF_ECW2CW((edcf_acp->ECW & EDCF_ECWMAX_MASK)
+               params->cw_max = EDCF_ECW2CW((edcf_acp->ECW & EDCF_ECWMAX_MASK)
                                            >> EDCF_ECWMAX_SHIFT);
-               acp_shm.cwcur = acp_shm.cwmin;
-               acp_shm.bslots =
-                   R_REG(&wlc->regs->tsf_random) & acp_shm.cwcur;
-               acp_shm.reggap = acp_shm.bslots + acp_shm.aifs;
-               /* Indicate the new params to the ucode */
-               acp_shm.status = wlc_read_shm(wlc, (M_EDCF_QINFO +
-                                                   wme_shmemacindex(aci) *
-                                                   M_EDCF_QLEN +
-                                                   M_EDCF_STATUS_OFF));
-               acp_shm.status |= WME_STATUS_NEWAC;
-
-               /* Fill in shm acparam table */
-               shm_entry = (u16 *) &acp_shm;
-               for (j = 0; j < (int)sizeof(shm_acparams_t); j += 2)
-                       wlc_write_shm(wlc,
-                                     M_EDCF_QINFO +
-                                     wme_shmemacindex(aci) * M_EDCF_QLEN + j,
-                                     *shm_entry++);
+               wlc_wme_setparams(wlc, aci, params, suspend);
        }
 
        if (suspend)
@@ -1535,14 +1374,16 @@ bool wlc_timers_init(struct wlc_info *wlc, int unit)
        wlc->wdtimer = wl_init_timer(wlc->wl, wlc_watchdog_by_timer,
                wlc, "watchdog");
        if (!wlc->wdtimer) {
-               WL_ERROR("wl%d:  wl_init_timer for wdtimer failed\n", unit);
+               wiphy_err(wlc->wiphy, "wl%d:  wl_init_timer for wdtimer "
+                         "failed\n", unit);
                goto fail;
        }
 
        wlc->radio_timer = wl_init_timer(wlc->wl, wlc_radio_timer,
                wlc, "radio");
        if (!wlc->radio_timer) {
-               WL_ERROR("wl%d:  wl_init_timer for radio_timer failed\n", unit);
+               wiphy_err(wlc->wiphy, "wl%d:  wl_init_timer for radio_timer "
+                         "failed\n", unit);
                goto fail;
        }
 
@@ -1689,20 +1530,23 @@ static uint wlc_attach_module(struct wlc_info *wlc)
 
        wlc->asi = wlc_antsel_attach(wlc);
        if (wlc->asi == NULL) {
-               WL_ERROR("wl%d: wlc_attach: wlc_antsel_attach failed\n", unit);
+               wiphy_err(wlc->wiphy, "wl%d: wlc_attach: wlc_antsel_attach "
+                         "failed\n", unit);
                err = 44;
                goto fail;
        }
 
        wlc->ampdu = wlc_ampdu_attach(wlc);
        if (wlc->ampdu == NULL) {
-               WL_ERROR("wl%d: wlc_attach: wlc_ampdu_attach failed\n", unit);
+               wiphy_err(wlc->wiphy, "wl%d: wlc_attach: wlc_ampdu_attach "
+                         "failed\n", unit);
                err = 50;
                goto fail;
        }
 
        if ((wlc_stf_attach(wlc) != 0)) {
-               WL_ERROR("wl%d: wlc_attach: wlc_stf_attach failed\n", unit);
+               wiphy_err(wlc->wiphy, "wl%d: wlc_attach: wlc_stf_attach "
+                         "failed\n", unit);
                err = 68;
                goto fail;
        }
@@ -1720,56 +1564,21 @@ struct wlc_pub *wlc_pub(void *wlc)
 /*
  * The common driver entry routine. Error codes should be unique
  */
-void *wlc_attach(void *wl, u16 vendor, u16 device, uint unit, bool piomode,
-                void *regsva, uint bustype, void *btparam, uint *perr)
+void *wlc_attach(struct wl_info *wl, u16 vendor, u16 device, uint unit,
+                bool piomode, void *regsva, uint bustype, void *btparam,
+                uint *perr)
 {
        struct wlc_info *wlc;
        uint err = 0;
        uint j;
        struct wlc_pub *pub;
-       struct wlc_txq_info *qi;
        uint n_disabled;
 
-       WL_NONE("wl%d: %s: vendor 0x%x device 0x%x\n",
-               unit, __func__, vendor, device);
-
-       ASSERT(WSEC_MAX_RCMTA_KEYS <= WSEC_MAX_KEYS);
-       ASSERT(WSEC_MAX_DEFAULT_KEYS == WLC_DEFAULT_KEYS);
-
-       /* some code depends on packed structures */
-       ASSERT(sizeof(struct ethhdr) == ETH_HLEN);
-       ASSERT(sizeof(d11regs_t) == SI_CORE_SIZE);
-       ASSERT(sizeof(ofdm_phy_hdr_t) == D11_PHY_HDR_LEN);
-       ASSERT(sizeof(cck_phy_hdr_t) == D11_PHY_HDR_LEN);
-       ASSERT(sizeof(d11txh_t) == D11_TXH_LEN);
-       ASSERT(sizeof(d11rxhdr_t) == RXHDR_LEN);
-       ASSERT(sizeof(struct ieee80211_hdr) == DOT11_A4_HDR_LEN);
-       ASSERT(sizeof(struct ieee80211_rts) == DOT11_RTS_LEN);
-       ASSERT(sizeof(tx_status_t) == TXSTATUS_LEN);
-       ASSERT(sizeof(struct ieee80211_ht_cap) == HT_CAP_IE_LEN);
-#ifdef BRCM_FULLMAC
-       ASSERT(offsetof(wl_scan_params_t, channel_list) ==
-              WL_SCAN_PARAMS_FIXED_SIZE);
-#endif
-       ASSERT(IS_ALIGNED(offsetof(wsec_key_t, data), sizeof(u32)));
-       ASSERT(ISPOWEROF2(MA_WINDOW_SZ));
-
-       ASSERT(sizeof(wlc_d11rxhdr_t) <= WL_HWRXOFF);
-
-       /*
-        * Number of replay counters value used in WPA IE must match # rxivs
-        * supported in wsec_key_t struct. See 802.11i/D3.0 sect. 7.3.2.17
-        * 'RSN Information Element' figure 8 for this mapping.
-        */
-       ASSERT((WPA_CAP_16_REPLAY_CNTRS == WLC_REPLAY_CNTRS_VALUE
-               && 16 == WLC_NUMRXIVS)
-              || (WPA_CAP_4_REPLAY_CNTRS == WLC_REPLAY_CNTRS_VALUE
-                  && 4 == WLC_NUMRXIVS));
-
        /* allocate struct wlc_info state and its substructures */
        wlc = (struct wlc_info *) wlc_attach_malloc(unit, &err, device);
        if (wlc == NULL)
                goto fail;
+       wlc->wiphy = wl->wiphy;
        pub = wlc->pub;
 
 #if defined(BCMDBG)
@@ -1892,7 +1701,7 @@ void *wlc_attach(void *wl, u16 vendor, u16 device, uint unit, bool piomode,
                /* fill in hw_rateset (used early by WLC_SET_RATESET) */
                wlc_rateset_filter(&wlc->band->defrateset,
                                   &wlc->band->hw_rateset, false,
-                                  WLC_RATES_CCK_OFDM, RATE_MASK,
+                                  WLC_RATES_CCK_OFDM, WLC_RATE_MASK,
                                   (bool) N_ENAB(wlc->pub));
        }
 
@@ -1905,7 +1714,8 @@ void *wlc_attach(void *wl, u16 vendor, u16 device, uint unit, bool piomode,
                goto fail;
 
        if (!wlc_timers_init(wlc, unit)) {
-               WL_ERROR("wl%d: %s: wlc_init_timer failed\n", unit, __func__);
+               wiphy_err(wl->wiphy, "wl%d: %s: wlc_init_timer failed\n", unit,
+                         __func__);
                err = 32;
                goto fail;
        }
@@ -1913,8 +1723,8 @@ void *wlc_attach(void *wl, u16 vendor, u16 device, uint unit, bool piomode,
        /* depend on rateset, gmode */
        wlc->cmi = wlc_channel_mgr_attach(wlc);
        if (!wlc->cmi) {
-               WL_ERROR("wl%d: %s: wlc_channel_mgr_attach failed\n",
-                        unit, __func__);
+               wiphy_err(wl->wiphy, "wl%d: %s: wlc_channel_mgr_attach failed"
+                         "\n", unit, __func__);
                err = 33;
                goto fail;
        }
@@ -1927,26 +1737,19 @@ void *wlc_attach(void *wl, u16 vendor, u16 device, uint unit, bool piomode,
         */
 
        /* allocate our initial queue */
-       qi = wlc_txq_alloc(wlc);
-       if (qi == NULL) {
-               WL_ERROR("wl%d: %s: failed to malloc tx queue\n",
-                        unit, __func__);
+       wlc->pkt_queue = wlc_txq_alloc(wlc);
+       if (wlc->pkt_queue == NULL) {
+               wiphy_err(wl->wiphy, "wl%d: %s: failed to malloc tx queue\n",
+                         unit, __func__);
                err = 100;
                goto fail;
        }
-       wlc->active_queue = qi;
 
        wlc->bsscfg[0] = wlc->cfg;
        wlc->cfg->_idx = 0;
        wlc->cfg->wlc = wlc;
        pub->txmaxpkts = MAXTXPKTS;
 
-       pub->_cnt->version = WL_CNT_T_VERSION;
-       pub->_cnt->length = sizeof(struct wl_cnt);
-
-       WLCNTSET(pub->_wme_cnt->version, WL_WME_CNT_VERSION);
-       WLCNTSET(pub->_wme_cnt->length, sizeof(wl_wme_cnt_t));
-
        wlc_wme_initparams_sta(wlc, &wlc->wme_param_ie);
 
        wlc->mimoft = FT_HT;
@@ -2014,7 +1817,8 @@ void *wlc_attach(void *wl, u16 vendor, u16 device, uint unit, bool piomode,
        return (void *)wlc;
 
  fail:
-       WL_ERROR("wl%d: %s: failed with err %d\n", unit, __func__, err);
+       wiphy_err(wl->wiphy, "wl%d: %s: failed with err %d\n",
+                 unit, __func__, err);
        if (wlc)
                wlc_detach(wlc);
 
@@ -2032,8 +1836,8 @@ static void wlc_attach_antgain_init(struct wlc_info *wlc)
                /* default antenna gain for srom rev 1 is 2 dBm (8 qdbm) */
                wlc->band->antgain = 8;
        } else if (wlc->band->antgain == -1) {
-               WL_ERROR("wl%d: %s: Invalid antennas available in srom, using 2dB\n",
-                        unit, __func__);
+               wiphy_err(wlc->wiphy, "wl%d: %s: Invalid antennas available in"
+                         " srom, using 2dB\n", unit, __func__);
                wlc->band->antgain = 8;
        } else {
                s8 gain, fract;
@@ -2072,8 +1876,8 @@ static bool wlc_attach_stf_ant_init(struct wlc_info *wlc)
                aa = (s8) getintvar(vars,
                                      (BAND_5G(bandtype) ? "aa1" : "aa0"));
        if ((aa < 1) || (aa > 15)) {
-               WL_ERROR("wl%d: %s: Invalid antennas available in srom (0x%x), using 3\n",
-                        unit, __func__, aa);
+               wiphy_err(wlc->wiphy, "wl%d: %s: Invalid antennas available in"
+                         " srom (0x%x), using 3\n", unit, __func__, aa);
                aa = 3;
        }
 
@@ -2134,15 +1938,12 @@ static void wlc_detach_module(struct wlc_info *wlc)
  */
 uint wlc_detach(struct wlc_info *wlc)
 {
-       uint i;
        uint callbacks = 0;
 
        if (wlc == NULL)
                return 0;
 
-       WL_TRACE("wl%d: %s\n", wlc->pub->unit, __func__);
-
-       ASSERT(!wlc->pub->up);
+       BCMMSG(wlc->wiphy, "wl%d\n", wlc->pub->unit);
 
        callbacks += wlc_bmac_detach(wlc);
 
@@ -2182,13 +1983,6 @@ uint wlc_detach(struct wlc_info *wlc)
        while (wlc->tx_queues != NULL)
                wlc_txq_free(wlc, wlc->tx_queues);
 
-       /*
-        * consistency check: wlc_module_register/wlc_module_unregister calls
-        * should match therefore nothing should be left here.
-        */
-       for (i = 0; i < WLC_MAXMODULES; i++)
-               ASSERT(wlc->modulecb[i].name[0] == '\0');
-
        wlc_detach_mfree(wlc);
        return callbacks;
 }
@@ -2300,8 +2094,6 @@ static void wlc_radio_upd(struct wlc_info *wlc)
 /* maintain LED behavior in down state */
 static void wlc_down_led_upd(struct wlc_info *wlc)
 {
-       ASSERT(!wlc->pub->up);
-
        /* maintain LEDs while in down state, turn on sbclk if not available yet */
        /* turn on sbclk if necessary */
        if (!AP_ENAB(wlc->pub)) {
@@ -2349,7 +2141,8 @@ static void wlc_radio_timer(void *arg)
        struct wlc_info *wlc = (struct wlc_info *) arg;
 
        if (DEVICEREMOVED(wlc)) {
-               WL_ERROR("wl%d: %s: dead chip\n", wlc->pub->unit, __func__);
+               wiphy_err(wlc->wiphy, "wl%d: %s: dead chip\n", wlc->pub->unit,
+                       __func__);
                wl_down(wlc->wl);
                return;
        }
@@ -2358,8 +2151,6 @@ static void wlc_radio_timer(void *arg)
        if (wlc->mpc_offcnt < WLC_MPC_MAX_DELAYCNT)
                wlc->mpc_offcnt++;
 
-       /* validate all the reasons driver could be down and running this radio_timer */
-       ASSERT(wlc->pub->radio_disabled || wlc->down_override);
        wlc_radio_hwdisable_upd(wlc);
        wlc_radio_upd(wlc);
 }
@@ -2381,56 +2172,11 @@ bool wlc_radio_monitor_stop(struct wlc_info *wlc)
        if (!wlc->radio_monitor)
                return true;
 
-       ASSERT((wlc->pub->wlfeatureflag & WL_SWFL_NOHWRADIO) !=
-              WL_SWFL_NOHWRADIO);
-
        wlc->radio_monitor = false;
        wlc_pllreq(wlc, false, WLC_PLLREQ_RADIO_MON);
        return wl_del_timer(wlc->wl, wlc->radio_timer);
 }
 
-/* bring the driver down, but don't reset hardware */
-void wlc_out(struct wlc_info *wlc)
-{
-       wlc_bmac_set_noreset(wlc->hw, true);
-       wlc_radio_upd(wlc);
-       wl_down(wlc->wl);
-       wlc_bmac_set_noreset(wlc->hw, false);
-
-       /* core clk is true in BMAC driver due to noreset, need to mirror it in HIGH */
-       wlc->clk = true;
-
-       /* This will make sure that when 'up' is done
-        * after 'out' it'll restore hardware (especially gpios)
-        */
-       wlc->pub->hw_up = false;
-}
-
-#if defined(BCMDBG)
-/* Verify the sanity of wlc->tx_prec_map. This can be done only by making sure that
- * if there is no packet pending for the FIFO, then the corresponding prec bits should be set
- * in prec_map. Of course, ignore this rule when block_datafifo is set
- */
-static bool wlc_tx_prec_map_verify(struct wlc_info *wlc)
-{
-       /* For non-WME, both fifos have overlapping prec_map. So it's an error only if both
-        * fail the check.
-        */
-       if (!EDCF_ENAB(wlc->pub)) {
-               if (!(WLC_TX_FIFO_CHECK(wlc, TX_DATA_FIFO) ||
-                     WLC_TX_FIFO_CHECK(wlc, TX_CTL_FIFO)))
-                       return false;
-               else
-                       return true;
-       }
-
-       return WLC_TX_FIFO_CHECK(wlc, TX_AC_BK_FIFO)
-               && WLC_TX_FIFO_CHECK(wlc, TX_AC_BE_FIFO)
-               && WLC_TX_FIFO_CHECK(wlc, TX_AC_VI_FIFO)
-               && WLC_TX_FIFO_CHECK(wlc, TX_AC_VO_FIFO);
-}
-#endif                         /* BCMDBG */
-
 static void wlc_watchdog_by_timer(void *arg)
 {
        struct wlc_info *wlc = (struct wlc_info *) arg;
@@ -2450,13 +2196,14 @@ static void wlc_watchdog(void *arg)
        int i;
        struct wlc_bsscfg *cfg;
 
-       WL_TRACE("wl%d: wlc_watchdog\n", wlc->pub->unit);
+       BCMMSG(wlc->wiphy, "wl%d\n", wlc->pub->unit);
 
        if (!wlc->pub->up)
                return;
 
        if (DEVICEREMOVED(wlc)) {
-               WL_ERROR("wl%d: %s: dead chip\n", wlc->pub->unit, __func__);
+               wiphy_err(wlc->wiphy, "wl%d: %s: dead chip\n", wlc->pub->unit,
+                         __func__);
                wl_down(wlc->wl);
                return;
        }
@@ -2480,9 +2227,6 @@ static void wlc_watchdog(void *arg)
        /* radio sync: sw/hw/mpc --> radio_disable/radio_enable */
        wlc_radio_hwdisable_upd(wlc);
        wlc_radio_upd(wlc);
-       /* if ismpc, driver should be in down state if up/down is allowed */
-       if (wlc->mpc && wlc_ismpc(wlc))
-               ASSERT(!wlc->pub->up);
        /* if radio is disable, driver may be down, quit here */
        if (wlc->pub->radio_disabled)
                return;
@@ -2515,23 +2259,16 @@ static void wlc_watchdog(void *arg)
                wlc->tempsense_lasttime = wlc->pub->now;
                wlc_tempsense_upd(wlc);
        }
-       /* BMAC_NOTE: for HIGH_ONLY driver, this seems being called after RPC bus failed */
-       ASSERT(wlc_bmac_taclear(wlc->hw, true));
-
-       /* Verify that tx_prec_map and fifos are in sync to avoid lock ups */
-       ASSERT(wlc_tx_prec_map_verify(wlc));
-
-       ASSERT(wlc_ps_check(wlc));
 }
 
 /* make interface operational */
 int wlc_up(struct wlc_info *wlc)
 {
-       WL_TRACE("wl%d: %s:\n", wlc->pub->unit, __func__);
+       BCMMSG(wlc->wiphy, "wl%d\n", wlc->pub->unit);
 
        /* HW is turned off so don't try to access it */
        if (wlc->pub->hw_off || DEVICEREMOVED(wlc))
-               return BCME_RADIOOFF;
+               return -ENOMEDIUM;
 
        if (!wlc->pub->hw_up) {
                wlc_bmac_hw_up(wlc->hw);
@@ -2556,11 +2293,11 @@ int wlc_up(struct wlc_info *wlc)
         * if radio is disabled, abort up, lower power, start radio timer and return 0(for NDIS)
         * don't call radio_update to avoid looping wlc_up.
         *
-        * wlc_bmac_up_prep() returns either 0 or BCME_RADIOOFF only
+        * wlc_bmac_up_prep() returns either 0 or -BCME_RADIOOFF only
         */
        if (!wlc->pub->radio_disabled) {
                int status = wlc_bmac_up_prep(wlc->hw);
-               if (status == BCME_RADIOOFF) {
+               if (status == -ENOMEDIUM) {
                        if (!mboolisset
                            (wlc->pub->radio_disabled, WL_RADIO_HW_DISABLE)) {
                                int idx;
@@ -2572,12 +2309,13 @@ int wlc_up(struct wlc_info *wlc)
                                        if (!BSSCFG_STA(bsscfg)
                                            || !bsscfg->enable || !bsscfg->BSS)
                                                continue;
-                                       WL_ERROR("wl%d.%d: wlc_up: rfdisable -> " "wlc_bsscfg_disable()\n",
-                                                wlc->pub->unit, idx);
+                                       wiphy_err(wlc->wiphy, "wl%d.%d: wlc_up"
+                                                 ": rfdisable -> "
+                                                 "wlc_bsscfg_disable()\n",
+                                                  wlc->pub->unit, idx);
                                }
                        }
-               } else
-                       ASSERT(!status);
+               }
        }
 
        if (wlc->pub->radio_disabled) {
@@ -2621,7 +2359,6 @@ int wlc_up(struct wlc_info *wlc)
        wlc_wme_retries_write(wlc);
 
        /* start one second watchdog timer */
-       ASSERT(!wlc->WDarmed);
        wl_add_timer(wlc->wl, wlc->wdtimer, TIMER_INTERVAL_WATCHDOG, true);
        wlc->WDarmed = true;
 
@@ -2673,12 +2410,12 @@ uint wlc_down(struct wlc_info *wlc)
        bool dev_gone = false;
        struct wlc_txq_info *qi;
 
-       WL_TRACE("wl%d: %s:\n", wlc->pub->unit, __func__);
+       BCMMSG(wlc->wiphy, "wl%d\n", wlc->pub->unit);
 
        /* check if we are already in the going down path */
        if (wlc->going_down) {
-               WL_ERROR("wl%d: %s: Driver going down so return\n",
-                        wlc->pub->unit, __func__);
+               wiphy_err(wlc->wiphy, "wl%d: %s: Driver going down so return"
+                         "\n", wlc->pub->unit, __func__);
                return 0;
        }
        if (!wlc->pub->up)
@@ -2707,9 +2444,6 @@ uint wlc_down(struct wlc_info *wlc)
        /* cancel all other timers */
        callbacks += wlc_down_del_timer(wlc);
 
-       /* interrupt must have been blocked */
-       ASSERT((wlc->macintmask == 0) || !wlc->pub->up);
-
        wlc->pub->up = false;
 
        wlc_phy_mute_upd(wlc->band->pi, false, PHY_MUTE_ALL);
@@ -2719,8 +2453,7 @@ uint wlc_down(struct wlc_info *wlc)
 
        /* flush tx queues */
        for (qi = wlc->tx_queues; qi != NULL; qi = qi->next) {
-               pktq_flush(&qi->q, true, NULL, 0);
-               ASSERT(pktq_empty(&qi->q));
+               bcm_pktq_flush(&qi->q, true, NULL, NULL);
        }
 
        callbacks += wlc_bmac_down_finish(wlc->hw);
@@ -2728,13 +2461,6 @@ uint wlc_down(struct wlc_info *wlc)
        /* wlc_bmac_down_finish has done wlc_coredisable(). so clk is off */
        wlc->clk = false;
 
-#ifdef BCMDBG
-       /* Since all the packets should have been freed,
-        * all callbacks should have been called
-        */
-       for (i = 1; i <= wlc->pub->tunables->maxpktcb; i++)
-               ASSERT(wlc->pkt_callback[i].fn == NULL);
-#endif
        wlc->going_down = false;
        return callbacks;
 }
@@ -2761,7 +2487,7 @@ int wlc_set_gmode(struct wlc_info *wlc, u8 gmode, bool config)
         * Gmode is not GMODE_LEGACY_B
         */
        if (N_ENAB(wlc->pub) && gmode == GMODE_LEGACY_B)
-               return BCME_UNSUPPORTED;
+               return -ENOTSUPP;
 
        /* verify that we are dealing with 2G band and grab the band pointer */
        if (wlc->band->bandtype == WLC_BAND_2G)
@@ -2770,12 +2496,12 @@ int wlc_set_gmode(struct wlc_info *wlc, u8 gmode, bool config)
                 (wlc->bandstate[OTHERBANDUNIT(wlc)]->bandtype == WLC_BAND_2G))
                band = wlc->bandstate[OTHERBANDUNIT(wlc)];
        else
-               return BCME_BADBAND;
+               return -EINVAL;
 
        /* Legacy or bust when no OFDM is supported by regulatory */
        if ((wlc_channel_locale_flags_in_band(wlc->cmi, band->bandunit) &
             WLC_NO_OFDM) && (gmode != GMODE_LEGACY_B))
-               return BCME_RANGE;
+               return -EINVAL;
 
        /* update configuration value */
        if (config == true)
@@ -2823,9 +2549,9 @@ int wlc_set_gmode(struct wlc_info *wlc, u8 gmode, bool config)
 
        default:
                /* Error */
-               WL_ERROR("wl%d: %s: invalid gmode %d\n",
-                        wlc->pub->unit, __func__, gmode);
-               return BCME_UNSUPPORTED;
+               wiphy_err(wlc->wiphy, "wl%d: %s: invalid gmode %d\n",
+                         wlc->pub->unit, __func__, gmode);
+               return -ENOTSUPP;
        }
 
        /*
@@ -2904,11 +2630,11 @@ static int wlc_nmode_validate(struct wlc_info *wlc, s32 nmode)
        case WL_11N_2x2:
        case WL_11N_3x3:
                if (!(WLC_PHY_11N_CAP(wlc->band)))
-                       err = BCME_BADBAND;
+                       err = -EINVAL;
                break;
 
        default:
-               err = BCME_RANGE;
+               err = -EINVAL;
                break;
        }
 
@@ -2921,7 +2647,6 @@ int wlc_set_nmode(struct wlc_info *wlc, s32 nmode)
        int err;
 
        err = wlc_nmode_validate(wlc, nmode);
-       ASSERT(err == 0);
        if (err)
                return err;
 
@@ -2950,7 +2675,6 @@ int wlc_set_nmode(struct wlc_info *wlc, s32 nmode)
                        nmode = WL_11N_2x2;
        case WL_11N_2x2:
        case WL_11N_3x3:
-               ASSERT(WLC_PHY_11N_CAP(wlc->band));
                /* force GMODE_AUTO if NMODE is ON */
                wlc_set_gmode(wlc, GMODE_AUTO, true);
                if (nmode == WL_11N_3x3)
@@ -2967,7 +2691,6 @@ int wlc_set_nmode(struct wlc_info *wlc, s32 nmode)
                break;
 
        default:
-               ASSERT(0);
                break;
        }
 
@@ -2983,7 +2706,7 @@ static int wlc_set_rateset(struct wlc_info *wlc, wlc_rateset_t *rs_arg)
 
        /* check for bad count value */
        if ((rs.count == 0) || (rs.count > WLC_NUMRATES))
-               return BCME_BADRATESET;
+               return -EINVAL;
 
        /* try the current band */
        bandunit = wlc->band->bandunit;
@@ -3005,7 +2728,7 @@ static int wlc_set_rateset(struct wlc_info *wlc, wlc_rateset_t *rs_arg)
                        goto good;
        }
 
-       return BCME_ERROR;
+       return -EBADE;
 
  good:
        /* apply new rateset */
@@ -3067,8 +2790,8 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
        wlc_bss_info_t *current_bss;
 
        /* update bsscfg pointer */
-       bsscfg = NULL;          /* XXX: Hack bsscfg to be size one and use this globally */
-       current_bss = NULL;
+       bsscfg = wlc->cfg;
+       current_bss = bsscfg->current_bss;
 
        /* initialize the following to get rid of compiler warning */
        nextscb = NULL;
@@ -3078,13 +2801,12 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
 
        /* If the device is turned off, then it's not "removed" */
        if (!wlc->pub->hw_off && DEVICEREMOVED(wlc)) {
-               WL_ERROR("wl%d: %s: dead chip\n", wlc->pub->unit, __func__);
+               wiphy_err(wlc->wiphy, "wl%d: %s: dead chip\n", wlc->pub->unit,
+                         __func__);
                wl_down(wlc->wl);
-               return BCME_ERROR;
+               return -EBADE;
        }
 
-       ASSERT(!(wlc->pub->hw_off && wlc->pub->up));
-
        /* default argument is generic integer */
        pval = arg ? (int *)arg:NULL;
 
@@ -3096,11 +2818,6 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
 
        /* bool conversion to avoid duplication below */
        bool_val = val != 0;
-
-       if (cmd != WLC_SET_CHANNEL)
-               WL_NONE("WLC_IOCTL: cmd %d val 0x%x (%d) len %d\n",
-                       cmd, (uint)val, val, len);
-
        bcmerror = 0;
        regs = wlc->regs;
 
@@ -3118,9 +2835,10 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
 
        default:
                if ((arg == NULL) || (len <= 0)) {
-                       WL_ERROR("wl%d: %s: Command %d needs arguments\n",
-                                wlc->pub->unit, __func__, cmd);
-                       bcmerror = BCME_BADARG;
+                       wiphy_err(wlc->wiphy, "wl%d: %s: Command %d needs "
+                                 "arguments\n",
+                                 wlc->pub->unit, __func__, cmd);
+                       bcmerror = -EINVAL;
                        goto done;
                }
        }
@@ -3144,7 +2862,10 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
        case WLC_GET_CHANNEL:{
                        channel_info_t *ci = (channel_info_t *) arg;
 
-                       ASSERT(len > (int)sizeof(ci));
+                       if (len <= (int)sizeof(ci)) {
+                               bcmerror = EOVERFLOW;
+                               goto done;
+                       }
 
                        ci->hw_channel =
                            CHSPEC_CHANNEL(WLC_BAND_PI_RADIO_CHANSPEC);
@@ -3159,12 +2880,12 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
                        chanspec_t chspec = CH20MHZ_CHSPEC(val);
 
                        if (val < 0 || val > MAXCHANNEL) {
-                               bcmerror = BCME_OUTOFRANGECHAN;
+                               bcmerror = -EINVAL;
                                break;
                        }
 
                        if (!wlc_valid_chanspec_db(wlc->cmi, chspec)) {
-                               bcmerror = BCME_BADCHAN;
+                               bcmerror = -EINVAL;
                                break;
                        }
 
@@ -3191,7 +2912,7 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
 #if defined(BCMDBG)
        case WLC_GET_UCFLAGS:
                if (!wlc->pub->up) {
-                       bcmerror = BCME_NOTUP;
+                       bcmerror = -ENOLINK;
                        break;
                }
 
@@ -3206,7 +2927,7 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
                        break;
 
                if (val >= MHFMAX) {
-                       bcmerror = BCME_RANGE;
+                       bcmerror = -EINVAL;
                        break;
                }
 
@@ -3215,7 +2936,7 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
 
        case WLC_SET_UCFLAGS:
                if (!wlc->pub->up) {
-                       bcmerror = BCME_NOTUP;
+                       bcmerror = -ENOLINK;
                        break;
                }
 
@@ -3231,7 +2952,7 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
 
                i = (u16) val;
                if (i >= MHFMAX) {
-                       bcmerror = BCME_RANGE;
+                       bcmerror = -EINVAL;
                        break;
                }
 
@@ -3253,7 +2974,7 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
                        break;
 
                if (val & 1) {
-                       bcmerror = BCME_BADADDR;
+                       bcmerror = -EINVAL;
                        break;
                }
 
@@ -3274,7 +2995,7 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
                        break;
 
                if (val & 1) {
-                       bcmerror = BCME_BADADDR;
+                       bcmerror = -EINVAL;
                        break;
                }
 
@@ -3288,7 +3009,7 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
                band = WLC_BAND_AUTO;
 
                if (len < (int)(sizeof(rw_reg_t) - sizeof(uint))) {
-                       bcmerror = BCME_BUFTOOSHORT;
+                       bcmerror = -EOVERFLOW;
                        break;
                }
 
@@ -3301,7 +3022,7 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
                        break;
 
                if ((r->byteoff + r->size) > sizeof(d11regs_t)) {
-                       bcmerror = BCME_BADADDR;
+                       bcmerror = -EINVAL;
                        break;
                }
                if (r->size == sizeof(u32))
@@ -3313,7 +3034,7 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
                            R_REG((u16 *)((unsigned char *)(unsigned long)regs +
                                              r->byteoff));
                else
-                       bcmerror = BCME_BADADDR;
+                       bcmerror = -EINVAL;
                break;
 
        case WLC_W_REG:
@@ -3322,7 +3043,7 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
                band = WLC_BAND_AUTO;
 
                if (len < (int)(sizeof(rw_reg_t) - sizeof(uint))) {
-                       bcmerror = BCME_BUFTOOSHORT;
+                       bcmerror = -EOVERFLOW;
                        break;
                }
 
@@ -3335,7 +3056,7 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
                        break;
 
                if (r->byteoff + r->size > sizeof(d11regs_t)) {
-                       bcmerror = BCME_BADADDR;
+                       bcmerror = -EINVAL;
                        break;
                }
                if (r->size == sizeof(u32))
@@ -3345,7 +3066,7 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
                        W_REG((u16 *)((unsigned char *)(unsigned long) regs +
                                          r->byteoff), r->val);
                else
-                       bcmerror = BCME_BADADDR;
+                       bcmerror = -EINVAL;
                break;
 #endif                         /* BCMDBG */
 
@@ -3393,7 +3114,7 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
        case WLC_SET_ANTDIV:
                /* values are -1=driver default, 0=force0, 1=force1, 2=start1, 3=start0 */
                if ((val < -1) || (val > 3)) {
-                       bcmerror = BCME_RANGE;
+                       bcmerror = -EINVAL;
                        break;
                }
 
@@ -3408,13 +3129,13 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
                        u16 rxstatus;
 
                        if (!wlc->pub->up) {
-                               bcmerror = BCME_NOTUP;
+                               bcmerror = -ENOLINK;
                                break;
                        }
 
                        rxstatus = R_REG(&wlc->regs->phyrxstatus0);
                        if (rxstatus == 0xdead || rxstatus == (u16) -1) {
-                               bcmerror = BCME_ERROR;
+                               bcmerror = -EBADE;
                                break;
                        }
                        *pval = (rxstatus & PRXS0_RXANT_UPSUBBAND) ? 1 : 0;
@@ -3424,7 +3145,7 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
 #if defined(BCMDBG)
        case WLC_GET_UCANTDIV:
                if (!wlc->clk) {
-                       bcmerror = BCME_NOCLK;
+                       bcmerror = -EIO;
                        break;
                }
 
@@ -3435,13 +3156,13 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
 
        case WLC_SET_UCANTDIV:{
                        if (!wlc->pub->up) {
-                               bcmerror = BCME_NOTUP;
+                               bcmerror = -ENOLINK;
                                break;
                        }
 
                        /* if multiband, band must be locked */
                        if (IS_MBAND_UNLOCKED(wlc)) {
-                               bcmerror = BCME_NOTBANDLOCKED;
+                               bcmerror = -ENOMEDIUM;
                                break;
                        }
 
@@ -3467,7 +3188,7 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
                        }
                        wlc_wme_retries_write(wlc);
                } else
-                       bcmerror = BCME_RANGE;
+                       bcmerror = -EINVAL;
                break;
 
        case WLC_GET_LRL:
@@ -3486,7 +3207,7 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
                        }
                        wlc_wme_retries_write(wlc);
                } else
-                       bcmerror = BCME_RANGE;
+                       bcmerror = -EINVAL;
                break;
 
        case WLC_GET_CWMIN:
@@ -3495,14 +3216,14 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
 
        case WLC_SET_CWMIN:
                if (!wlc->clk) {
-                       bcmerror = BCME_NOCLK;
+                       bcmerror = -EIO;
                        break;
                }
 
                if (val >= 1 && val <= 255) {
                        wlc_set_cwmin(wlc, (u16) val);
                } else
-                       bcmerror = BCME_RANGE;
+                       bcmerror = -EINVAL;
                break;
 
        case WLC_GET_CWMAX:
@@ -3511,14 +3232,14 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
 
        case WLC_SET_CWMAX:
                if (!wlc->clk) {
-                       bcmerror = BCME_NOCLK;
+                       bcmerror = -EIO;
                        break;
                }
 
                if (val >= 255 && val <= 2047) {
                        wlc_set_cwmax(wlc, (u16) val);
                } else
-                       bcmerror = BCME_RANGE;
+                       bcmerror = -EINVAL;
                break;
 
        case WLC_GET_RADIO:     /* use mask if don't want to expose some internal bits */
@@ -3539,9 +3260,9 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
                        if ((radiomask == 0) || (radiomask & ~validbits)
                            || (radioval & ~validbits)
                            || ((radioval & ~radiomask) != 0)) {
-                               WL_ERROR("SET_RADIO with wrong bits 0x%x\n",
-                                        val);
-                               bcmerror = BCME_RANGE;
+                               wiphy_err(wlc->wiphy, "SET_RADIO with wrong "
+                                         "bits 0x%x\n", val);
+                               bcmerror = -EINVAL;
                                break;
                        }
 
@@ -3566,7 +3287,7 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
                        wsec_key_t *src_key = wlc->wsec_keys[val];
 
                        if (len < (int)sizeof(key)) {
-                               bcmerror = BCME_BUFTOOSHORT;
+                               bcmerror = -EOVERFLOW;
                                break;
                        }
 
@@ -3586,7 +3307,7 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
 
                        memcpy(arg, &key, sizeof(key));
                } else
-                       bcmerror = BCME_BADKEYIDX;
+                       bcmerror = -EINVAL;
                break;
 #endif                         /* defined(BCMDBG) */
 
@@ -3600,7 +3321,7 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
                        wsec_key_t *key;
 
                        if (len < DOT11_WPA_KEY_RSC_LEN) {
-                               bcmerror = BCME_BUFTOOSHORT;
+                               bcmerror = -EOVERFLOW;
                                break;
                        }
 
@@ -3637,7 +3358,7 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
 
                                memcpy(arg, seq, sizeof(seq));
                        } else {
-                               bcmerror = BCME_BADKEYIDX;
+                               bcmerror = -EINVAL;
                        }
                        break;
                }
@@ -3646,13 +3367,13 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
                        wl_rateset_t *ret_rs = (wl_rateset_t *) arg;
                        wlc_rateset_t *rs;
 
-                       if (bsscfg->associated)
+                       if (wlc->pub->associated)
                                rs = &current_bss->rateset;
                        else
                                rs = &wlc->default_bss->rateset;
 
                        if (len < (int)(rs->count + sizeof(rs->count))) {
-                               bcmerror = BCME_BUFTOOSHORT;
+                               bcmerror = -EOVERFLOW;
                                break;
                        }
 
@@ -3670,7 +3391,7 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
                        wlc_default_rateset(wlc, (wlc_rateset_t *) &rs);
 
                        if (len < (int)(rs.count + sizeof(rs.count))) {
-                               bcmerror = BCME_BUFTOOSHORT;
+                               bcmerror = -EOVERFLOW;
                                break;
                        }
 
@@ -3685,12 +3406,12 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
                        wl_rateset_t *in_rs = (wl_rateset_t *) arg;
 
                        if (len < (int)(in_rs->count + sizeof(in_rs->count))) {
-                               bcmerror = BCME_BUFTOOSHORT;
+                               bcmerror = -EOVERFLOW;
                                break;
                        }
 
                        if (in_rs->count > WLC_NUMRATES) {
-                               bcmerror = BCME_BUFTOOLONG;
+                               bcmerror = -ENOBUFS;
                                break;
                        }
 
@@ -3733,7 +3454,7 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
                    && val <= DOT11_MAX_BEACON_PERIOD) {
                        wlc->default_bss->beacon_period = (u16) val;
                } else
-                       bcmerror = BCME_RANGE;
+                       bcmerror = -EINVAL;
                break;
 
        case WLC_GET_DTIMPRD:
@@ -3749,7 +3470,7 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
                    && val <= DOT11_MAX_DTIM_PERIOD) {
                        wlc->default_bss->dtim_period = (u8) val;
                } else
-                       bcmerror = BCME_RANGE;
+                       bcmerror = -EINVAL;
                break;
 
 #ifdef SUPPORT_PS
@@ -3765,7 +3486,7 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
                        /* Change watchdog driver to align watchdog with tbtt if possible */
                        wlc_watchdog_upd(wlc, PS_ALLOWED(wlc));
                } else
-                       bcmerror = BCME_ERROR;
+                       bcmerror = -EBADE;
                break;
 #endif                         /* SUPPORT_PS */
 
@@ -3773,7 +3494,7 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
 #ifdef BCMDBG
        case WLC_GET_WAKE:
                if (AP_ENAB(wlc->pub)) {
-                       bcmerror = BCME_NOTSTA;
+                       bcmerror = -BCME_NOTSTA;
                        break;
                }
                *pval = wlc->wake;
@@ -3781,7 +3502,7 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
 
        case WLC_SET_WAKE:
                if (AP_ENAB(wlc->pub)) {
-                       bcmerror = BCME_NOTSTA;
+                       bcmerror = -BCME_NOTSTA;
                        break;
                }
 
@@ -3816,24 +3537,6 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
                wlc->default_bss->atim_window = (u32) val;
                break;
 
-       case WLC_GET_PKTCNTS:{
-                       get_pktcnt_t *pktcnt = (get_pktcnt_t *) pval;
-                       wlc_statsupd(wlc);
-                       pktcnt->rx_good_pkt = wlc->pub->_cnt->rxframe;
-                       pktcnt->rx_bad_pkt = wlc->pub->_cnt->rxerror;
-                       pktcnt->tx_good_pkt =
-                           wlc->pub->_cnt->txfrmsnt;
-                       pktcnt->tx_bad_pkt =
-                           wlc->pub->_cnt->txerror +
-                           wlc->pub->_cnt->txfail;
-                       if (len >= (int)sizeof(get_pktcnt_t)) {
-                               /* Be backward compatible - only if buffer is large enough  */
-                               pktcnt->rx_ocast_good_pkt =
-                                   wlc->pub->_cnt->rxmfrmocast;
-                       }
-                       break;
-               }
-
 #ifdef SUPPORT_HWKEY
        case WLC_GET_WSEC:
                bcmerror =
@@ -3876,7 +3579,7 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
                {
                        unsigned char *cp = arg;
                        if (len < 3) {
-                               bcmerror = BCME_BUFTOOSHORT;
+                               bcmerror = -EOVERFLOW;
                                break;
                        }
 
@@ -3902,7 +3605,7 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
        case WLC_SET_SHORTSLOT_OVERRIDE:
                if ((val != WLC_SHORTSLOT_AUTO) &&
                    (val != WLC_SHORTSLOT_OFF) && (val != WLC_SHORTSLOT_ON)) {
-                       bcmerror = BCME_RANGE;
+                       bcmerror = -EINVAL;
                        break;
                }
 
@@ -3959,7 +3662,7 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
                if (!wlc->pub->associated)
                        bcmerror = wlc_set_gmode(wlc, (u8) val, true);
                else {
-                       bcmerror = BCME_ASSOCIATED;
+                       bcmerror = -EISCONN;
                        break;
                }
                break;
@@ -3976,7 +3679,7 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
                if ((val != WLC_PROTECTION_CTL_OFF) &&
                    (val != WLC_PROTECTION_CTL_LOCAL) &&
                    (val != WLC_PROTECTION_CTL_OVERLAP)) {
-                       bcmerror = BCME_RANGE;
+                       bcmerror = -EINVAL;
                        break;
                }
 
@@ -3995,7 +3698,7 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
        case WLC_SET_GMODE_PROTECTION_OVERRIDE:
                if ((val != WLC_PROTECTION_AUTO) &&
                    (val != WLC_PROTECTION_OFF) && (val != WLC_PROTECTION_ON)) {
-                       bcmerror = BCME_RANGE;
+                       bcmerror = -EINVAL;
                        break;
                }
 
@@ -4008,14 +3711,14 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
 
                        /* copyin */
                        if (len < (int)sizeof(wlc_rateset_t)) {
-                               bcmerror = BCME_BUFTOOSHORT;
+                               bcmerror = -EOVERFLOW;
                                break;
                        }
                        memcpy(&rs, arg, sizeof(wlc_rateset_t));
 
                        /* check for bad count value */
                        if (rs.count > WLC_NUMRATES) {
-                               bcmerror = BCME_BADRATESET;     /* invalid rateset */
+                               bcmerror = -EINVAL;
                                break;
                        }
 
@@ -4023,7 +3726,8 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
                        if (!(wlc->band->gmode ||
                              ((NBANDS(wlc) > 1)
                               && wlc->bandstate[OTHERBANDUNIT(wlc)]->gmode))) {
-                               bcmerror = BCME_BADBAND;        /* gmode only command when not in gmode */
+                               /* gmode only command when not in gmode */
+                               bcmerror = -EINVAL;
                                break;
                        }
 
@@ -4034,15 +3738,19 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
                                break;
                        }
 
-                       /* validate rateset by comparing pre and post sorted against 11g hw rates */
-                       wlc_rateset_filter(&rs, &new, false, WLC_RATES_CCK_OFDM,
-                                          RATE_MASK, BSS_N_ENAB(wlc, bsscfg));
+                       /*
+                        * validate rateset by comparing pre and
+                        * post sorted against 11g hw rates
+                        */
+                       wlc_rateset_filter(&rs, &new, false,
+                                          WLC_RATES_CCK_OFDM, WLC_RATE_MASK,
+                                          BSS_N_ENAB(wlc, bsscfg));
                        wlc_rate_hwrs_filter_sort_validate(&new,
                                                           &cck_ofdm_rates,
                                                           false,
                                                           wlc->stf->txstreams);
                        if (rs.count != new.count) {
-                               bcmerror = BCME_BADRATESET;     /* invalid rateset */
+                               bcmerror = -EINVAL;
                                break;
                        }
 
@@ -4064,11 +3772,12 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
                if (!(wlc->band->gmode ||
                      ((NBANDS(wlc) > 1)
                       && wlc->bandstate[OTHERBANDUNIT(wlc)]->gmode))) {
-                       bcmerror = BCME_BADBAND;        /* gmode only command when not in gmode */
+                       /* gmode only command when not in gmode */
+                       bcmerror = -EINVAL;
                        break;
                }
                if (len < (int)sizeof(wlc_rateset_t)) {
-                       bcmerror = BCME_BUFTOOSHORT;
+                       bcmerror = -EOVERFLOW;
                        break;
                }
                memcpy(arg, &wlc->sup_rates_override, sizeof(wlc_rateset_t));
@@ -4081,11 +3790,11 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
 
        case WLC_SET_PRB_RESP_TIMEOUT:
                if (wlc->pub->up) {
-                       bcmerror = BCME_NOTDOWN;
+                       bcmerror = -EISCONN;
                        break;
                }
                if (val < 0 || val >= 0xFFFF) {
-                       bcmerror = BCME_RANGE;  /* bad value */
+                       bcmerror = -EINVAL;     /* bad value */
                        break;
                }
                wlc->prb_resp_timeout = (u16) val;
@@ -4099,7 +3808,7 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
                        if (key != NULL) {
                                *pval = key->id == val ? true : false;
                        } else {
-                               bcmerror = BCME_BADKEYIDX;
+                               bcmerror = -EINVAL;
                        }
                        break;
                }
@@ -4107,7 +3816,7 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
        case WLC_SET_KEY_PRIMARY:{
                        wsec_key_t *key, *old_key;
 
-                       bcmerror = BCME_BADKEYIDX;
+                       bcmerror = -EINVAL;
 
                        /* treat the 'val' parm as the key id */
                        for (i = 0; i < WSEC_MAX_DEFAULT_KEYS; i++) {
@@ -4119,7 +3828,7 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
                                                    ~WSEC_PRIMARY_KEY;
                                        key->flags |= WSEC_PRIMARY_KEY;
                                        bsscfg->wsec_index = i;
-                                       bcmerror = BCME_OK;
+                                       bcmerror = 0;
                                }
                        }
                        break;
@@ -4141,7 +3850,7 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
                                ;
 
                        if (i == (uint) len) {
-                               bcmerror = BCME_BUFTOOSHORT;
+                               bcmerror = -EOVERFLOW;
                                break;
                        }
                        i++;    /* include the null in the string length */
@@ -4162,37 +3871,25 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
                }
 
        case WLC_SET_WSEC_PMK:
-               bcmerror = BCME_UNSUPPORTED;
+               bcmerror = -ENOTSUPP;
                break;
 
 #if defined(BCMDBG)
        case WLC_CURRENT_PWR:
                if (!wlc->pub->up)
-                       bcmerror = BCME_NOTUP;
+                       bcmerror = -ENOLINK;
                else
                        bcmerror = wlc_get_current_txpwr(wlc, arg, len);
                break;
 #endif
 
        case WLC_LAST:
-               WL_ERROR("%s: WLC_LAST\n", __func__);
+               wiphy_err(wlc->wiphy, "%s: WLC_LAST\n", __func__);
        }
  done:
 
-       if (bcmerror) {
-               if (VALID_BCMERROR(bcmerror))
-                       wlc->pub->bcmerror = bcmerror;
-               else {
-                       bcmerror = 0;
-               }
-
-       }
-       /* BMAC_NOTE: for HIGH_ONLY driver, this seems being called after RPC bus failed */
-       /* In hw_off condition, IOCTLs that reach here are deemed safe but taclear would
-        * certainly result in getting -1 for register reads. So skip ta_clear altogether
-        */
-       if (!(wlc->pub->hw_off))
-               ASSERT(wlc_bmac_taclear(wlc->hw, ta_ok) || !ta_ok);
+       if (bcmerror)
+               wlc->pub->bcmerror = bcmerror;
 
        return bcmerror;
 }
@@ -4203,30 +3900,20 @@ int wlc_iocregchk(struct wlc_info *wlc, uint band)
 {
        /* if band is specified, it must be the current band */
        if ((band != WLC_BAND_AUTO) && (band != (uint) wlc->band->bandtype))
-               return BCME_BADBAND;
+               return -EINVAL;
 
        /* if multiband and band is not specified, band must be locked */
        if ((band == WLC_BAND_AUTO) && IS_MBAND_UNLOCKED(wlc))
-               return BCME_NOTBANDLOCKED;
+               return -ENOMEDIUM;
 
        /* must have core clocks */
        if (!wlc->clk)
-               return BCME_NOCLK;
+               return -EIO;
 
        return 0;
 }
 #endif                         /* defined(BCMDBG) */
 
-#if defined(BCMDBG)
-/* For some ioctls, make sure that the pi pointer matches the current phy */
-int wlc_iocpichk(struct wlc_info *wlc, uint phytype)
-{
-       if (wlc->band->phytype != phytype)
-               return BCME_BADBAND;
-       return 0;
-}
-#endif
-
 /* Look up the given var name in the given table */
 static const bcm_iovar_t *wlc_iovar_lookup(const bcm_iovar_t *table,
                                           const char *name)
@@ -4241,8 +3928,6 @@ static const bcm_iovar_t *wlc_iovar_lookup(const bcm_iovar_t *table,
        else
                lookup_name = name;
 
-       ASSERT(table != NULL);
-
        for (vi = table; vi->name; vi++) {
                if (!strcmp(vi->name, lookup_name))
                        return vi;
@@ -4266,21 +3951,6 @@ int wlc_iovar_setint(struct wlc_info *wlc, const char *name, int arg)
                            IOV_SET, NULL);
 }
 
-/* simplified s8 get interface for common WLC_GET_VAR ioctl handler */
-int wlc_iovar_gets8(struct wlc_info *wlc, const char *name, s8 *arg)
-{
-       int iovar_int;
-       int err;
-
-       err =
-           wlc_iovar_op(wlc, name, NULL, 0, &iovar_int, sizeof(iovar_int),
-                        IOV_GET, NULL);
-       if (!err)
-               *arg = (s8) iovar_int;
-
-       return err;
-}
-
 /*
  * register iovar table, watchdog and down handlers.
  * calling function must keep 'iovars' until wlc_module_unregister is called.
@@ -4293,9 +3963,6 @@ int wlc_module_register(struct wlc_pub *pub, const bcm_iovar_t *iovars,
        struct wlc_info *wlc = (struct wlc_info *) pub->wlc;
        int i;
 
-       ASSERT(name != NULL);
-       ASSERT(i_fn != NULL || w_fn != NULL || d_fn != NULL);
-
        /* find an empty entry and just add, no duplication check! */
        for (i = 0; i < WLC_MAXMODULES; i++) {
                if (wlc->modulecb[i].name[0] == '\0') {
@@ -4310,9 +3977,7 @@ int wlc_module_register(struct wlc_pub *pub, const bcm_iovar_t *iovars,
                }
        }
 
-       /* it is time to increase the capacity */
-       ASSERT(i < WLC_MAXMODULES);
-       return BCME_NORESOURCE;
+       return -ENOSR;
 }
 
 /* unregister module callbacks */
@@ -4322,9 +3987,7 @@ int wlc_module_unregister(struct wlc_pub *pub, const char *name, void *hdl)
        int i;
 
        if (wlc == NULL)
-               return BCME_NOTFOUND;
-
-       ASSERT(name != NULL);
+               return -ENODATA;
 
        for (i = 0; i < WLC_MAXMODULES; i++) {
                if (!strcmp(wlc->modulecb[i].name, name) &&
@@ -4335,7 +3998,7 @@ int wlc_module_unregister(struct wlc_pub *pub, const char *name, void *hdl)
        }
 
        /* table not found! */
-       return BCME_NOTFOUND;
+       return -ENODATA;
 }
 
 /* Write WME tunable parameters for retransmit/max rate from wlc struct to ucode */
@@ -4371,23 +4034,11 @@ wlc_iovar_op(struct wlc_info *wlc, const char *name,
        u32 actionid;
        int i;
 
-       ASSERT(name != NULL);
-
-       ASSERT(len >= 0);
-
-       /* Get MUST have return space */
-       ASSERT(set || (arg && len));
-
-       ASSERT(!(wlc->pub->hw_off && wlc->pub->up));
-
-       /* Set does NOT take qualifiers */
-       ASSERT(!set || (!params && !p_len));
-
        if (!set && (len == sizeof(int)) &&
            !(IS_ALIGNED((unsigned long)(arg), (uint) sizeof(int)))) {
-               WL_ERROR("wl%d: %s unaligned get ptr for %s\n",
-                        wlc->pub->unit, __func__, name);
-               ASSERT(0);
+               wiphy_err(wlc->wiphy, "wl%d: %s unaligned get ptr for %s\n",
+                         wlc->pub->unit, __func__, name);
+               return -ENOTSUPP;
        }
 
        /* find the given iovar name */
@@ -4400,8 +4051,7 @@ wlc_iovar_op(struct wlc_info *wlc, const char *name,
        }
        /* iovar name not found */
        if (i >= WLC_MAXMODULES) {
-               err = BCME_UNSUPPORTED;
-               goto exit;
+               return -ENOTSUPP;
        }
 
        /* set up 'params' pointer in case this is a set command so that
@@ -4426,8 +4076,6 @@ wlc_iovar_op(struct wlc_info *wlc, const char *name,
        err = wlc->modulecb[i].iovar_fn(wlc->modulecb[i].hdl, vi, actionid,
                                        name, params, p_len, arg, len, val_size,
                                        wlcif);
-
- exit:
        return err;
 }
 
@@ -4443,22 +4091,22 @@ wlc_iovar_check(struct wlc_pub *pub, const bcm_iovar_t *vi, void *arg, int len,
        if (set) {
                if (((vi->flags & IOVF_SET_DOWN) && wlc->pub->up) ||
                    ((vi->flags & IOVF_SET_UP) && !wlc->pub->up)) {
-                       err = (wlc->pub->up ? BCME_NOTDOWN : BCME_NOTUP);
+                       err = (wlc->pub->up ? -EISCONN : -ENOLINK);
                } else if ((vi->flags & IOVF_SET_BAND)
                           && IS_MBAND_UNLOCKED(wlc)) {
-                       err = BCME_NOTBANDLOCKED;
+                       err = -ENOMEDIUM;
                } else if ((vi->flags & IOVF_SET_CLK) && !wlc->clk) {
-                       err = BCME_NOCLK;
+                       err = -EIO;
                }
        } else {
                if (((vi->flags & IOVF_GET_DOWN) && wlc->pub->up) ||
                    ((vi->flags & IOVF_GET_UP) && !wlc->pub->up)) {
-                       err = (wlc->pub->up ? BCME_NOTDOWN : BCME_NOTUP);
+                       err = (wlc->pub->up ? -EISCONN : -ENOLINK);
                } else if ((vi->flags & IOVF_GET_BAND)
                           && IS_MBAND_UNLOCKED(wlc)) {
-                       err = BCME_NOTBANDLOCKED;
+                       err = -ENOMEDIUM;
                } else if ((vi->flags & IOVF_GET_CLK) && !wlc->clk) {
-                       err = BCME_NOCLK;
+                       err = -EIO;
                }
        }
 
@@ -4513,7 +4161,7 @@ wlc_doiovar(void *hdl, const bcm_iovar_t *vi, u32 actionid,
        bool bool_val2;
        wlc_bss_info_t *current_bss;
 
-       WL_TRACE("wl%d: %s\n", wlc->pub->unit, __func__);
+       BCMMSG(wlc->wiphy, "wl%d\n", wlc->pub->unit);
 
        bsscfg = NULL;
        current_bss = NULL;
@@ -4537,8 +4185,7 @@ wlc_doiovar(void *hdl, const bcm_iovar_t *vi, u32 actionid,
        bool_val = (int_val != 0) ? true : false;
        bool_val2 = (int_val2 != 0) ? true : false;
 
-       WL_TRACE("wl%d: %s: id %d\n",
-                wlc->pub->unit, __func__, IOV_ID(actionid));
+       BCMMSG(wlc->wiphy, "wl%d: id %d\n", wlc->pub->unit, IOV_ID(actionid));
        /* Do the actual parameter implementation */
        switch (actionid) {
        case IOV_SVAL(IOV_RTSTHRESH):
@@ -4551,7 +4198,7 @@ wlc_doiovar(void *hdl, const bcm_iovar_t *vi, u32 actionid,
 
                        err = wlc_phy_txpower_get(wlc->band->pi, &qdbm,
                                &override);
-                       if (err != BCME_OK)
+                       if (err != 0)
                                return err;
 
                        /* Return qdbm units */
@@ -4599,8 +4246,9 @@ wlc_doiovar(void *hdl, const bcm_iovar_t *vi, u32 actionid,
                break;
 
        default:
-               WL_ERROR("wl%d: %s: unsupported\n", wlc->pub->unit, __func__);
-               err = BCME_UNSUPPORTED;
+               wiphy_err(wlc->wiphy, "wl%d: %s: unsupported\n",
+                         wlc->pub->unit, __func__);
+               err = -ENOTSUPP;
                break;
        }
 
@@ -4635,7 +4283,7 @@ wlc_iovar_rangecheck(struct wlc_info *wlc, u32 val, const bcm_iovar_t *vi)
                /* Signed values are checked against max_val and min_val */
                if ((s32) val < (s32) min_val
                    || (s32) val > (s32) max_val)
-                       err = BCME_RANGE;
+                       err = -EINVAL;
                break;
 
        case IOVT_UINT32:
@@ -4649,7 +4297,7 @@ wlc_iovar_rangecheck(struct wlc_info *wlc, u32 val, const bcm_iovar_t *vi)
                if (vi->flags & IOVF_NTRL)
                        min_val = 1;
                if ((val < min_val) || (val > max_val))
-                       err = BCME_RANGE;
+                       err = -EINVAL;
                break;
        }
 
@@ -4708,24 +4356,6 @@ void wlc_print_txstatus(tx_status_t *txs)
 #endif                         /* defined(BCMDBG) */
 }
 
-static void
-wlc_ctrupd_cache(u16 cur_stat, u16 *macstat_snapshot, u32 *macstat)
-{
-       u16 v;
-       u16 delta;
-
-       v = le16_to_cpu(cur_stat);
-       delta = (u16)(v - *macstat_snapshot);
-
-       if (delta != 0) {
-               *macstat += delta;
-               *macstat_snapshot = v;
-       }
-}
-
-#define MACSTATUPD(name) \
-       wlc_ctrupd_cache(macstats.name, &wlc->core->macstat_snapshot->name, &wlc->pub->_cnt->name)
-
 void wlc_statsupd(struct wlc_info *wlc)
 {
        int i;
@@ -4753,68 +4383,12 @@ void wlc_statsupd(struct wlc_info *wlc)
        wlc_bmac_copyfrom_shm(wlc->hw, M_UCODE_MACSTAT,
                              &macstats, sizeof(macstat_t));
 
-       /* update mac stats */
-       MACSTATUPD(txallfrm);
-       MACSTATUPD(txrtsfrm);
-       MACSTATUPD(txctsfrm);
-       MACSTATUPD(txackfrm);
-       MACSTATUPD(txdnlfrm);
-       MACSTATUPD(txbcnfrm);
-       for (i = 0; i < NFIFO; i++)
-               MACSTATUPD(txfunfl[i]);
-       MACSTATUPD(txtplunfl);
-       MACSTATUPD(txphyerr);
-       MACSTATUPD(rxfrmtoolong);
-       MACSTATUPD(rxfrmtooshrt);
-       MACSTATUPD(rxinvmachdr);
-       MACSTATUPD(rxbadfcs);
-       MACSTATUPD(rxbadplcp);
-       MACSTATUPD(rxcrsglitch);
-       MACSTATUPD(rxstrt);
-       MACSTATUPD(rxdfrmucastmbss);
-       MACSTATUPD(rxmfrmucastmbss);
-       MACSTATUPD(rxcfrmucast);
-       MACSTATUPD(rxrtsucast);
-       MACSTATUPD(rxctsucast);
-       MACSTATUPD(rxackucast);
-       MACSTATUPD(rxdfrmocast);
-       MACSTATUPD(rxmfrmocast);
-       MACSTATUPD(rxcfrmocast);
-       MACSTATUPD(rxrtsocast);
-       MACSTATUPD(rxctsocast);
-       MACSTATUPD(rxdfrmmcast);
-       MACSTATUPD(rxmfrmmcast);
-       MACSTATUPD(rxcfrmmcast);
-       MACSTATUPD(rxbeaconmbss);
-       MACSTATUPD(rxdfrmucastobss);
-       MACSTATUPD(rxbeaconobss);
-       MACSTATUPD(rxrsptmout);
-       MACSTATUPD(bcntxcancl);
-       MACSTATUPD(rxf0ovfl);
-       MACSTATUPD(rxf1ovfl);
-       MACSTATUPD(rxf2ovfl);
-       MACSTATUPD(txsfovfl);
-       MACSTATUPD(pmqovfl);
-       MACSTATUPD(rxcgprqfrm);
-       MACSTATUPD(rxcgprsqovfl);
-       MACSTATUPD(txcgprsfail);
-       MACSTATUPD(txcgprssuc);
-       MACSTATUPD(prs_timeout);
-       MACSTATUPD(rxnack);
-       MACSTATUPD(frmscons);
-       MACSTATUPD(txnack);
-       MACSTATUPD(txglitch_nack);
-       MACSTATUPD(txburst);
-       MACSTATUPD(phywatchdog);
-       MACSTATUPD(pktengrxducast);
-       MACSTATUPD(pktengrxdmcast);
-
 #ifdef BCMDBG
        /* check for rx fifo 0 overflow */
        delta = (u16) (wlc->core->macstat_snapshot->rxf0ovfl - rxf0ovfl);
        if (delta)
-               WL_ERROR("wl%d: %u rx fifo 0 overflows!\n",
-                        wlc->pub->unit, delta);
+               wiphy_err(wlc->wiphy, "wl%d: %u rx fifo 0 overflows!\n",
+                         wlc->pub->unit, delta);
 
        /* check for tx fifo underflows */
        for (i = 0; i < NFIFO; i++) {
@@ -4822,57 +4396,23 @@ void wlc_statsupd(struct wlc_info *wlc)
                    (u16) (wlc->core->macstat_snapshot->txfunfl[i] -
                              txfunfl[i]);
                if (delta)
-                       WL_ERROR("wl%d: %u tx fifo %d underflows!\n",
-                                wlc->pub->unit, delta, i);
+                       wiphy_err(wlc->wiphy, "wl%d: %u tx fifo %d underflows!"
+                                 "\n", wlc->pub->unit, delta, i);
        }
 #endif                         /* BCMDBG */
 
-       /* dot11 counter update */
-
-       WLCNTSET(wlc->pub->_cnt->txrts,
-                (wlc->pub->_cnt->rxctsucast -
-                 wlc->pub->_cnt->d11cnt_txrts_off));
-       WLCNTSET(wlc->pub->_cnt->rxcrc,
-                (wlc->pub->_cnt->rxbadfcs - wlc->pub->_cnt->d11cnt_rxcrc_off));
-       WLCNTSET(wlc->pub->_cnt->txnocts,
-                ((wlc->pub->_cnt->txrtsfrm - wlc->pub->_cnt->rxctsucast) -
-                 wlc->pub->_cnt->d11cnt_txnocts_off));
-
        /* merge counters from dma module */
        for (i = 0; i < NFIFO; i++) {
                if (wlc->hw->di[i]) {
-                       WLCNTADD(wlc->pub->_cnt->txnobuf,
-                                (wlc->hw->di[i])->txnobuf);
-                       WLCNTADD(wlc->pub->_cnt->rxnobuf,
-                                (wlc->hw->di[i])->rxnobuf);
-                       WLCNTADD(wlc->pub->_cnt->rxgiant,
-                                (wlc->hw->di[i])->rxgiants);
                        dma_counterreset(wlc->hw->di[i]);
                }
        }
-
-       /*
-        * Aggregate transmit and receive errors that probably resulted
-        * in the loss of a frame are computed on the fly.
-        */
-       WLCNTSET(wlc->pub->_cnt->txerror,
-                wlc->pub->_cnt->txnobuf + wlc->pub->_cnt->txnoassoc +
-                wlc->pub->_cnt->txuflo + wlc->pub->_cnt->txrunt +
-                wlc->pub->_cnt->dmade + wlc->pub->_cnt->dmada +
-                wlc->pub->_cnt->dmape);
-       WLCNTSET(wlc->pub->_cnt->rxerror,
-                wlc->pub->_cnt->rxoflo + wlc->pub->_cnt->rxnobuf +
-                wlc->pub->_cnt->rxfragerr + wlc->pub->_cnt->rxrunt +
-                wlc->pub->_cnt->rxgiant + wlc->pub->_cnt->rxnoscb +
-                wlc->pub->_cnt->rxbadsrcmac);
-       for (i = 0; i < NFIFO; i++)
-               wlc->pub->_cnt->rxerror += wlc->pub->_cnt->rxuflo[i];
 }
 
 bool wlc_chipmatch(u16 vendor, u16 device)
 {
-       if (vendor != VENDOR_BROADCOM) {
-               WL_ERROR("wlc_chipmatch: unknown vendor id %04x\n", vendor);
+       if (vendor != PCI_VENDOR_ID_BROADCOM) {
+               pr_err("wlc_chipmatch: unknown vendor id %04x\n", vendor);
                return false;
        }
 
@@ -4884,7 +4424,7 @@ bool wlc_chipmatch(u16 vendor, u16 device)
        if ((device == BCM43236_D11N_ID) || (device == BCM43236_D11N2G_ID))
                return true;
 
-       WL_ERROR("wlc_chipmatch: unknown device id %04x\n", device);
+       pr_err("wlc_chipmatch: unknown device id %04x\n", device);
        return false;
 }
 
@@ -4923,7 +4463,9 @@ void wlc_print_txdesc(d11txh_t *txh)
        char hexbuf[256];
 
        /* add plcp header along with txh descriptor */
-       prhex("Raw TxDesc + plcp header", (unsigned char *) txh, sizeof(d11txh_t) + 48);
+       printk(KERN_DEBUG "Raw TxDesc + plcp header:\n");
+       print_hex_dump_bytes("", DUMP_PREFIX_OFFSET,
+                            txh, sizeof(d11txh_t) + 48);
 
        printk(KERN_DEBUG "TxCtlLow: %04x ", mtcl);
        printk(KERN_DEBUG "TxCtlHigh: %04x ", mtch);
@@ -4994,7 +4536,8 @@ void wlc_print_rxh(d11rxhdr_t *rxh)
                {0, NULL}
        };
 
-       prhex("Raw RxDesc", (unsigned char *) rxh, sizeof(d11rxhdr_t));
+       printk(KERN_DEBUG "Raw RxDesc:\n");
+       print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, rxh, sizeof(d11rxhdr_t));
 
        bcm_format_flags(macstat_flags, macstatus1, flagstr, 64);
 
@@ -5033,8 +4576,6 @@ int wlc_format_ssid(char *buf, const unsigned char ssid[], uint ssid_len)
                }
        }
        *p = '\0';
-       ASSERT(p < endp);
-
        return (int)(p - buf);
 }
 #endif                         /* defined(BCMDBG) */
@@ -5055,13 +4596,13 @@ static u16 wlc_rate_shm_offset(struct wlc_info *wlc, u8 rate)
  *
  * Returns true if packet consumed (queued), false if not.
  */
-bool BCMFASTPATH
+bool
 wlc_prec_enq(struct wlc_info *wlc, struct pktq *q, void *pkt, int prec)
 {
        return wlc_prec_enq_head(wlc, q, pkt, prec, false);
 }
 
-bool BCMFASTPATH
+bool
 wlc_prec_enq_head(struct wlc_info *wlc, struct pktq *q, struct sk_buff *pkt,
                  int prec, bool head)
 {
@@ -5072,11 +4613,10 @@ wlc_prec_enq_head(struct wlc_info *wlc, struct pktq *q, struct sk_buff *pkt,
        if (pktq_pfull(q, prec))
                eprec = prec;
        else if (pktq_full(q)) {
-               p = pktq_peek_tail(q, &eprec);
-               ASSERT(p != NULL);
+               p = bcm_pktq_peek_tail(q, &eprec);
                if (eprec > prec) {
-                       WL_ERROR("%s: Failing: eprec %d > prec %d\n",
-                                __func__, eprec, prec);
+                       wiphy_err(wlc->wiphy, "%s: Failing: eprec %d > prec %d"
+                                 "\n", __func__, eprec, prec);
                        return false;
                }
        }
@@ -5085,69 +4625,51 @@ wlc_prec_enq_head(struct wlc_info *wlc, struct pktq *q, struct sk_buff *pkt,
        if (eprec >= 0) {
                bool discard_oldest;
 
-               /* Detect queueing to unconfigured precedence */
-               ASSERT(!pktq_pempty(q, eprec));
-
                discard_oldest = AC_BITMAP_TST(wlc->wme_dp, eprec);
 
                /* Refuse newer packet unless configured to discard oldest */
                if (eprec == prec && !discard_oldest) {
-                       WL_ERROR("%s: No where to go, prec == %d\n",
-                                __func__, prec);
+                       wiphy_err(wlc->wiphy, "%s: No where to go, prec == %d"
+                                 "\n", __func__, prec);
                        return false;
                }
 
                /* Evict packet according to discard policy */
-               p = discard_oldest ? pktq_pdeq(q, eprec) : pktq_pdeq_tail(q,
-                                                                         eprec);
-               ASSERT(p != NULL);
-
-               /* Increment wme stats */
-               if (WME_ENAB(wlc->pub)) {
-                       WLCNTINCR(wlc->pub->_wme_cnt->
-                                 tx_failed[WME_PRIO2AC(p->priority)].packets);
-                       WLCNTADD(wlc->pub->_wme_cnt->
-                                tx_failed[WME_PRIO2AC(p->priority)].bytes,
-                                pkttotlen(p));
-               }
-               pkt_buf_free_skb(p);
-               wlc->pub->_cnt->txnobuf++;
+               p = discard_oldest ? bcm_pktq_pdeq(q, eprec) :
+                       bcm_pktq_pdeq_tail(q, eprec);
+               bcm_pkt_buf_free_skb(p);
        }
 
        /* Enqueue */
        if (head)
-               p = pktq_penq_head(q, prec, pkt);
+               p = bcm_pktq_penq_head(q, prec, pkt);
        else
-               p = pktq_penq(q, prec, pkt);
-       ASSERT(p != NULL);
+               p = bcm_pktq_penq(q, prec, pkt);
 
        return true;
 }
 
-void BCMFASTPATH wlc_txq_enq(void *ctx, struct scb *scb, struct sk_buff *sdu,
+void wlc_txq_enq(void *ctx, struct scb *scb, struct sk_buff *sdu,
                             uint prec)
 {
        struct wlc_info *wlc = (struct wlc_info *) ctx;
-       struct wlc_txq_info *qi = wlc->active_queue;    /* Check me */
+       struct wlc_txq_info *qi = wlc->pkt_queue;       /* Check me */
        struct pktq *q = &qi->q;
        int prio;
 
        prio = sdu->priority;
 
-       ASSERT(pktq_max(q) >= wlc->pub->tunables->datahiwat);
-
        if (!wlc_prec_enq(wlc, q, sdu, prec)) {
                if (!EDCF_ENAB(wlc->pub)
                    || (wlc->pub->wlfeatureflag & WL_SWFL_FLOWCONTROL))
-                       WL_ERROR("wl%d: wlc_txq_enq: txq overflow\n",
-                                wlc->pub->unit);
+                       wiphy_err(wlc->wiphy, "wl%d: wlc_txq_enq: txq overflow"
+                                 "\n", wlc->pub->unit);
 
                /*
                 * XXX we might hit this condtion in case
                 * packet flooding from mac80211 stack
                 */
-               pkt_buf_free_skb(sdu);
-               wlc->pub->_cnt->txnobuf++;
+               bcm_pkt_buf_free_skb(sdu);
        }
 
        /* Check if flow control needs to be turned on after enqueuing the packet
@@ -5167,7 +4689,7 @@ void BCMFASTPATH wlc_txq_enq(void *ctx, struct scb *scb, struct sk_buff *sdu,
        }
 }
 
-bool BCMFASTPATH
+bool
 wlc_sendpkt_mac80211(struct wlc_info *wlc, struct sk_buff *sdu,
                     struct ieee80211_hw *hw)
 {
@@ -5177,43 +4699,30 @@ wlc_sendpkt_mac80211(struct wlc_info *wlc, struct sk_buff *sdu,
        struct scb *scb = &global_scb;
        struct ieee80211_hdr *d11_header = (struct ieee80211_hdr *)(sdu->data);
 
-       ASSERT(sdu);
-
        /* 802.11 standard requires management traffic to go at highest priority */
        prio = ieee80211_is_data(d11_header->frame_control) ? sdu->priority :
                MAXPRIO;
        fifo = prio2fifo[prio];
-
-       ASSERT((uint) skb_headroom(sdu) >= TXOFF);
-       ASSERT(!(sdu->next));
-       ASSERT(!(sdu->prev));
-       ASSERT(fifo < NFIFO);
-
        pkt = sdu;
        if (unlikely
            (wlc_d11hdrs_mac80211(wlc, hw, pkt, scb, 0, 1, fifo, 0, NULL, 0)))
                return -EINVAL;
        wlc_txq_enq(wlc, scb, pkt, WLC_PRIO_TO_PREC(prio));
-       wlc_send_q(wlc, wlc->active_queue);
-
-       wlc->pub->_cnt->ieee_tx++;
+       wlc_send_q(wlc);
        return 0;
 }
 
-void BCMFASTPATH wlc_send_q(struct wlc_info *wlc, struct wlc_txq_info *qi)
+void wlc_send_q(struct wlc_info *wlc)
 {
        struct sk_buff *pkt[DOT11_MAXNUMFRAGS];
        int prec;
        u16 prec_map;
        int err = 0, i, count;
        uint fifo;
+       struct wlc_txq_info *qi = wlc->pkt_queue;
        struct pktq *q = &qi->q;
        struct ieee80211_tx_info *tx_info;
 
-       /* only do work for the active queue */
-       if (qi != wlc->active_queue)
-               return;
-
        if (in_send_q)
                return;
        else
@@ -5224,7 +4733,7 @@ void BCMFASTPATH wlc_send_q(struct wlc_info *wlc, struct wlc_txq_info *qi)
        /* Send all the enq'd pkts that we can.
         * Dequeue packets with precedence with empty HW fifo only
         */
-       while (prec_map && (pkt[0] = pktq_mdeq(q, prec_map, &prec))) {
+       while (prec_map && (pkt[0] = bcm_pktq_mdeq(q, prec_map, &prec))) {
                tx_info = IEEE80211_SKB_CB(pkt[0]);
                if (tx_info->flags & IEEE80211_TX_CTL_AMPDU) {
                        err = wlc_sendampdu(wlc->ampdu, qi, pkt, prec);
@@ -5238,8 +4747,8 @@ void BCMFASTPATH wlc_send_q(struct wlc_info *wlc, struct wlc_txq_info *qi)
                        }
                }
 
-               if (err == BCME_BUSY) {
-                       pktq_penq_head(q, prec, pkt[0]);
+               if (err == -EBUSY) {
+                       bcm_pktq_penq_head(q, prec, pkt[0]);
                        /* If send failed due to any other reason than a change in
                         * HW FIFO condition, quit. Otherwise, read the new prec_map!
                         */
@@ -5290,14 +4799,13 @@ bcmc_fid_generate(struct wlc_info *wlc, struct wlc_bsscfg *bsscfg,
        return frameid;
 }
 
-void BCMFASTPATH
+void
 wlc_txfifo(struct wlc_info *wlc, uint fifo, struct sk_buff *p, bool commit,
           s8 txpktpend)
 {
        u16 frameid = INVALIDFID;
        d11txh_t *txh;
 
-       ASSERT(fifo < NFIFO);
        txh = (d11txh_t *) (p->data);
 
        /* When a BC/MC frame is being committed to the BCMC fifo via DMA (NOT PIO), update
@@ -5317,7 +4825,7 @@ wlc_txfifo(struct wlc_info *wlc, uint fifo, struct sk_buff *p, bool commit,
         */
        if (commit) {
                TXPKTPENDINC(wlc, fifo, txpktpend);
-               WL_TRACE("wlc_txfifo, pktpend inc %d to %d\n",
+               BCMMSG(wlc->wiphy, "pktpend inc %d to %d\n",
                         txpktpend, TXPKTPENDGET(wlc, fifo));
        }
 
@@ -5326,57 +4834,11 @@ wlc_txfifo(struct wlc_info *wlc, uint fifo, struct sk_buff *p, bool commit,
                BCMCFID(wlc, frameid);
 
        if (dma_txfast(wlc->hw->di[fifo], p, commit) < 0) {
-               WL_ERROR("wlc_txfifo: fatal, toss frames !!!\n");
+               wiphy_err(wlc->wiphy, "wlc_txfifo: fatal, toss frames !!!\n");
        }
 }
 
-static u16
-wlc_compute_airtime(struct wlc_info *wlc, ratespec_t rspec, uint length)
-{
-       u16 usec = 0;
-       uint mac_rate = RSPEC2RATE(rspec);
-       uint nsyms;
-
-       if (IS_MCS(rspec)) {
-               /* not supported yet */
-               ASSERT(0);
-       } else if (IS_OFDM(rspec)) {
-               /* nsyms = Ceiling(Nbits / (Nbits/sym))
-                *
-                * Nbits = length * 8
-                * Nbits/sym = Mbps * 4 = mac_rate * 2
-                */
-               nsyms = CEIL((length * 8), (mac_rate * 2));
-
-               /* usec = symbols * usec/symbol */
-               usec = (u16) (nsyms * APHY_SYMBOL_TIME);
-               return usec;
-       } else {
-               switch (mac_rate) {
-               case WLC_RATE_1M:
-                       usec = length << 3;
-                       break;
-               case WLC_RATE_2M:
-                       usec = length << 2;
-                       break;
-               case WLC_RATE_5M5:
-                       usec = (length << 4) / 11;
-                       break;
-               case WLC_RATE_11M:
-                       usec = (length << 3) / 11;
-                       break;
-               default:
-                       WL_ERROR("wl%d: wlc_compute_airtime: unsupported rspec 0x%x\n",
-                                wlc->pub->unit, rspec);
-                       ASSERT((const char *)"Bad phy_rate" == NULL);
-                       break;
-               }
-       }
-
-       return usec;
-}
-
-void BCMFASTPATH
+void
 wlc_compute_plcp(struct wlc_info *wlc, ratespec_t rspec, uint length, u8 *plcp)
 {
        if (IS_MCS(rspec)) {
@@ -5384,7 +4846,7 @@ wlc_compute_plcp(struct wlc_info *wlc, ratespec_t rspec, uint length, u8 *plcp)
        } else if (IS_OFDM(rspec)) {
                wlc_compute_ofdm_plcp(rspec, length, plcp);
        } else {
-               wlc_compute_cck_plcp(rspec, length, plcp);
+               wlc_compute_cck_plcp(wlc, rspec, length, plcp);
        }
        return;
 }
@@ -5393,7 +4855,6 @@ wlc_compute_plcp(struct wlc_info *wlc, ratespec_t rspec, uint length, u8 *plcp)
 static void wlc_compute_mimo_plcp(ratespec_t rspec, uint length, u8 *plcp)
 {
        u8 mcs = (u8) (rspec & RSPEC_RATE_MASK);
-       ASSERT(IS_MCS(rspec));
        plcp[0] = mcs;
        if (RSPEC_IS40MHZ(rspec) || (mcs == 32))
                plcp[0] |= MIMO_PLCP_40MHZ;
@@ -5405,19 +4866,15 @@ static void wlc_compute_mimo_plcp(ratespec_t rspec, uint length, u8 *plcp)
 }
 
 /* Rate: 802.11 rate code, length: PSDU length in octets */
-static void BCMFASTPATH
+static void
 wlc_compute_ofdm_plcp(ratespec_t rspec, u32 length, u8 *plcp)
 {
        u8 rate_signal;
        u32 tmp = 0;
        int rate = RSPEC2RATE(rspec);
 
-       ASSERT(IS_OFDM(rspec));
-
        /* encode rate per 802.11a-1999 sec 17.3.4.1, with lsb transmitted first */
-       rate_signal = rate_info[rate] & RATE_MASK;
-       ASSERT(rate_signal != 0);
-
+       rate_signal = rate_info[rate] & WLC_RATE_MASK;
        memset(plcp, 0, D11_PHY_HDR_LEN);
        D11A_PHY_HDR_SRATE((ofdm_phy_hdr_t *) plcp, rate_signal);
 
@@ -5436,7 +4893,8 @@ wlc_compute_ofdm_plcp(ratespec_t rspec, u32 length, u8 *plcp)
  * Broken out for PRQ.
  */
 
-static void wlc_cck_plcp_set(int rate_500, uint length, u8 *plcp)
+static void wlc_cck_plcp_set(struct wlc_info *wlc, int rate_500, uint length,
+                            u8 *plcp)
 {
        u16 usec = 0;
        u8 le = 0;
@@ -5463,7 +4921,8 @@ static void wlc_cck_plcp_set(int rate_500, uint length, u8 *plcp)
                break;
 
        default:
-               WL_ERROR("wlc_cck_plcp_set: unsupported rate %d\n", rate_500);
+               wiphy_err(wlc->wiphy, "wlc_cck_plcp_set: unsupported rate %d"
+                         "\n", rate_500);
                rate_500 = WLC_RATE_1M;
                usec = length << 3;
                break;
@@ -5481,13 +4940,12 @@ static void wlc_cck_plcp_set(int rate_500, uint length, u8 *plcp)
 }
 
 /* Rate: 802.11 rate code, length: PSDU length in octets */
-static void wlc_compute_cck_plcp(ratespec_t rspec, uint length, u8 *plcp)
+static void wlc_compute_cck_plcp(struct wlc_info *wlc, ratespec_t rspec,
+                                uint length, u8 *plcp)
 {
        int rate = RSPEC2RATE(rspec);
 
-       ASSERT(IS_CCK(rspec));
-
-       wlc_cck_plcp_set(rate, length, plcp);
+       wlc_cck_plcp_set(wlc, rate, length, plcp);
 }
 
 /* wlc_compute_frame_dur()
@@ -5500,7 +4958,7 @@ static void wlc_compute_cck_plcp(ratespec_t rspec, uint length, u8 *plcp)
  * next_frag_len       next MPDU length in bytes
  * preamble_type       use short/GF or long/MM PLCP header
  */
-static u16 BCMFASTPATH
+static u16
 wlc_compute_frame_dur(struct wlc_info *wlc, ratespec_t rate, u8 preamble_type,
                      uint next_frag_len)
 {
@@ -5534,7 +4992,7 @@ wlc_compute_frame_dur(struct wlc_info *wlc, ratespec_t rate, u8 preamble_type,
  * rate                        next MPDU rate in unit of 500kbps
  * frame_len           next MPDU frame length in bytes
  */
-u16 BCMFASTPATH
+u16
 wlc_compute_rtscts_dur(struct wlc_info *wlc, bool cts_only, ratespec_t rts_rate,
                       ratespec_t frame_rate, u8 rts_preamble_type,
                       u8 frame_preamble_type, uint frame_len, bool ba)
@@ -5566,33 +5024,7 @@ wlc_compute_rtscts_dur(struct wlc_info *wlc, bool cts_only, ratespec_t rts_rate,
        return dur;
 }
 
-static bool wlc_phy_rspec_check(struct wlc_info *wlc, u16 bw, ratespec_t rspec)
-{
-       if (IS_MCS(rspec)) {
-               uint mcs = rspec & RSPEC_RATE_MASK;
-
-               if (mcs < 8) {
-                       ASSERT(RSPEC_STF(rspec) < PHY_TXC1_MODE_SDM);
-               } else if ((mcs >= 8) && (mcs <= 23)) {
-                       ASSERT(RSPEC_STF(rspec) == PHY_TXC1_MODE_SDM);
-               } else if (mcs == 32) {
-                       ASSERT(RSPEC_STF(rspec) < PHY_TXC1_MODE_SDM);
-                       ASSERT(bw == PHY_TXC1_BW_40MHZ_DUP);
-               }
-       } else if (IS_OFDM(rspec)) {
-               ASSERT(RSPEC_STF(rspec) < PHY_TXC1_MODE_STBC);
-       } else {
-               ASSERT(IS_CCK(rspec));
-
-               ASSERT((bw == PHY_TXC1_BW_20MHZ)
-                      || (bw == PHY_TXC1_BW_20MHZ_UP));
-               ASSERT(RSPEC_STF(rspec) == PHY_TXC1_MODE_SISO);
-       }
-
-       return true;
-}
-
-u16 BCMFASTPATH wlc_phytxctl1_calc(struct wlc_info *wlc, ratespec_t rspec)
+u16 wlc_phytxctl1_calc(struct wlc_info *wlc, ratespec_t rspec)
 {
        u16 phyctl1 = 0;
        u16 bw;
@@ -5603,12 +5035,10 @@ u16 BCMFASTPATH wlc_phytxctl1_calc(struct wlc_info *wlc, ratespec_t rspec)
                bw = RSPEC_GET_BW(rspec);
                /* 10Mhz is not supported yet */
                if (bw < PHY_TXC1_BW_20MHZ) {
-                       WL_ERROR("wlc_phytxctl1_calc: bw %d is not supported yet, set to 20L\n",
-                                bw);
+                       wiphy_err(wlc->wiphy, "wlc_phytxctl1_calc: bw %d is "
+                                 "not supported yet, set to 20L\n", bw);
                        bw = PHY_TXC1_BW_20MHZ;
                }
-
-               wlc_phy_rspec_check(wlc, bw, rspec);
        }
 
        if (IS_MCS(rspec)) {
@@ -5629,8 +5059,8 @@ u16 BCMFASTPATH wlc_phytxctl1_calc(struct wlc_info *wlc, ratespec_t rspec)
                /* get the phyctl byte from rate phycfg table */
                phycfg = wlc_rate_legacy_phyctl(RSPEC2RATE(rspec));
                if (phycfg == -1) {
-                       WL_ERROR("wlc_phytxctl1_calc: wrong legacy OFDM/CCK rate\n");
-                       ASSERT(0);
+                       wiphy_err(wlc->wiphy, "wlc_phytxctl1_calc: wrong "
+                                 "legacy OFDM/CCK rate\n");
                        phycfg = 0;
                }
                /* set the upper byte of phyctl1 */
@@ -5638,18 +5068,10 @@ u16 BCMFASTPATH wlc_phytxctl1_calc(struct wlc_info *wlc, ratespec_t rspec)
                    (bw | (phycfg << 8) |
                     (RSPEC_STF(rspec) << PHY_TXC1_MODE_SHIFT));
        }
-
-#ifdef BCMDBG
-       /* phy clock must support 40Mhz if tx descriptor uses it */
-       if ((phyctl1 & PHY_TXC1_BW_MASK) >= PHY_TXC1_BW_40MHZ) {
-               ASSERT(CHSPEC_WLC_BW(wlc->chanspec) == WLC_40_MHZ);
-               ASSERT(wlc->chanspec == wlc_phy_chanspec_get(wlc->band->pi));
-       }
-#endif                         /* BCMDBG */
        return phyctl1;
 }
 
-ratespec_t BCMFASTPATH
+ratespec_t
 wlc_rspec_to_rts_rspec(struct wlc_info *wlc, ratespec_t rspec, bool use_rspec,
                       u16 mimo_ctlchbw)
 {
@@ -5705,7 +5127,7 @@ wlc_rspec_to_rts_rspec(struct wlc_info *wlc, ratespec_t rspec, bool use_rspec,
  * headroom == D11_PHY_HDR_LEN + D11_TXH_LEN (D11_TXH_LEN is now 104 bytes)
  *
  */
-static u16 BCMFASTPATH
+static u16
 wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw,
                     struct sk_buff *p, struct scb *scb, uint frag,
                     uint nfrags, uint queue, uint next_frag_len,
@@ -5744,14 +5166,12 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw,
        u16 mimo_txbw;
        u8 mimo_preamble_type;
 
-       ASSERT(queue < NFIFO);
-
        /* locate 802.11 MAC header */
        h = (struct ieee80211_hdr *)(p->data);
        qos = ieee80211_is_data_qos(h->frame_control);
 
        /* compute length of frame in bytes for use in PLCP computations */
-       len = pkttotlen(p);
+       len = bcm_pkttotlen(p);
        phylen = len + FCS_LEN;
 
        /* If WEP enabled, add room in phylen for the additional bytes of
@@ -5765,7 +5185,6 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw,
 
        /* Get tx_info */
        tx_info = IEEE80211_SKB_CB(p);
-       ASSERT(tx_info);
 
        /* add PLCP */
        plcp = skb_push(p, D11_PHY_HDR_LEN);
@@ -5777,10 +5196,9 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw,
        /* setup frameid */
        if (tx_info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ) {
                /* non-AP STA should never use BCMC queue */
-               ASSERT(queue != TX_BCMC_FIFO);
                if (queue == TX_BCMC_FIFO) {
-                       WL_ERROR("wl%d: %s: ASSERT queue == TX_BCMC!\n",
-                                WLCWLUNIT(wlc), __func__);
+                       wiphy_err(wlc->wiphy, "wl%d: %s: ASSERT queue == "
+                                 "TX_BCMC!\n", WLCWLUNIT(wlc), __func__);
                        frameid = bcmc_fid_generate(wlc, NULL, txh);
                } else {
                        /* Increment the counter for first fragment */
@@ -5803,13 +5221,9 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw,
        if (SCB_PS(scb) || ieee80211_is_beacon(h->frame_control))
                mcl |= TXC_IGNOREPMQ;
 
-       ASSERT(hw->max_rates <= IEEE80211_TX_MAX_RATES);
-       ASSERT(hw->max_rates == 2);
-
        txrate[0] = tx_info->control.rates;
        txrate[1] = txrate[0] + 1;
 
-       ASSERT(txrate[0]->idx >= 0);
        /* if rate control algorithm didn't give us a fallback rate, use the primary rate */
        if (txrate[1]->idx < 0) {
                txrate[1] = txrate[0];
@@ -5819,7 +5233,6 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw,
                is_mcs[k] =
                    txrate[k]->flags & IEEE80211_TX_RC_MCS ? true : false;
                if (!is_mcs[k]) {
-                       ASSERT(!(tx_info->flags & IEEE80211_TX_CTL_AMPDU));
                        if ((txrate[k]->idx >= 0)
                            && (txrate[k]->idx <
                                hw->wiphy->bands[tx_info->band]->n_bitrates)) {
@@ -5831,10 +5244,6 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw,
                                    flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE ?
                                    true : false;
                        } else {
-                               ASSERT((txrate[k]->idx >= 0) &&
-                                      (txrate[k]->idx <
-                                       hw->wiphy->bands[tx_info->band]->
-                                       n_bitrates));
                                rate_val[k] = WLC_RATE_1M;
                        }
                } else {
@@ -5857,7 +5266,6 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw,
 
                /* (1) RATE: determine and validate primary rate and fallback rates */
                if (!RSPEC_ACTIVE(rspec[k])) {
-                       ASSERT(RSPEC_ACTIVE(rspec[k]));
                        rspec[k] = WLC_RATE_1M;
                } else {
                        if (!is_multicast_ether_addr(h->addr1)) {
@@ -5885,7 +5293,6 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw,
                                    && WLC_STF_SS_STBC_TX(wlc, scb)) {
                                        u8 stc;
 
-                                       ASSERT(WLC_STBC_CAP_PHY(wlc));
                                        stc = 1;        /* Nss for single stream is always 1 */
                                        rspec[k] |=
                                            (PHY_TXC1_MODE_STBC <<
@@ -5918,7 +5325,6 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw,
                                        if (wlc->ofdm_40txbw != AUTO)
                                                mimo_txbw = wlc->ofdm_40txbw;
                                } else {
-                                       ASSERT(IS_CCK(rspec[k]));
                                        if (wlc->cck_40txbw != AUTO)
                                                mimo_txbw = wlc->cck_40txbw;
                                }
@@ -5957,9 +5363,9 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw,
 
                        if ((txrate[k]->flags & IEEE80211_TX_RC_MCS)
                            && (!IS_MCS(rspec[k]))) {
-                               WL_ERROR("wl%d: %s: IEEE80211_TX_RC_MCS != IS_MCS(rspec)\n",
-                                        WLCWLUNIT(wlc), __func__);
-                               ASSERT(0 && "Rate mismatch");
+                               wiphy_err(wlc->wiphy, "wl%d: %s: IEEE80211_TX_"
+                                         "RC_MCS != IS_MCS(rspec)\n",
+                                         WLCWLUNIT(wlc), __func__);
                        }
 
                        if (IS_MCS(rspec[k])) {
@@ -5973,22 +5379,15 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw,
                                }
                        }
 
-                       /* mimo bw field MUST now be valid in the rspec (it affects duration calculations) */
-                       ASSERT(VALID_RATE_DBG(wlc, rspec[0]));
-
                        /* should be better conditionalized */
                        if (!IS_MCS(rspec[0])
                            && (tx_info->control.rates[0].
                                flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE))
                                preamble_type[k] = WLC_SHORT_PREAMBLE;
-
-                       ASSERT(!IS_MCS(rspec[0])
-                              || WLC_IS_MIMO_PREAMBLE(preamble_type[k]));
                }
        } else {
                for (k = 0; k < hw->max_rates; k++) {
                        /* Set ctrlchbw as 20Mhz */
-                       ASSERT(!IS_MCS(rspec[k]));
                        rspec[k] &= ~RSPEC_BW_MASK;
                        rspec[k] |= (PHY_TXC1_BW_20MHZ << RSPEC_BW_SHIFT);
 
@@ -6080,8 +5479,6 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw,
        /* Set fallback rate preamble type */
        if ((preamble_type[1] == WLC_SHORT_PREAMBLE) ||
            (preamble_type[1] == WLC_GF_PREAMBLE)) {
-               ASSERT((preamble_type[1] == WLC_GF_PREAMBLE) ||
-                      (!IS_MCS(rspec[1])));
                if (RSPEC2RATE(rspec[1]) != WLC_RATE_1M)
                        mch |= TXC_PREAMBLE_DATA_FB_SHORT;
        }
@@ -6146,7 +5543,6 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw,
                }
 
                /* RTS PLCP header */
-               ASSERT(IS_ALIGNED((unsigned long)txh->RTSPhyHeader, sizeof(u16)));
                rts_plcp = txh->RTSPhyHeader;
                if (use_cts)
                        rts_phylen = DOT11_CTS_LEN + FCS_LEN;
@@ -6229,11 +5625,8 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw,
        phyctl = FRAMETYPE(rspec[0], wlc->mimoft);
        if ((preamble_type[0] == WLC_SHORT_PREAMBLE) ||
            (preamble_type[0] == WLC_GF_PREAMBLE)) {
-               ASSERT((preamble_type[0] == WLC_GF_PREAMBLE)
-                      || !IS_MCS(rspec[0]));
                if (RSPEC2RATE(rspec[0]) != WLC_RATE_1M)
                        phyctl |= PHY_TXC_SHORT_HDR;
-               wlc->pub->_cnt->txprshort++;
        }
 
        /* phytxant is properly bit shifted */
@@ -6274,21 +5667,10 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw,
                }
        }
 
-       if (IS_MCS(rspec[0]))
-               ASSERT(IS_MCS(rspec[1]));
-
-       ASSERT(!IS_MCS(rspec[0]) ||
-              ((preamble_type[0] == WLC_MM_PREAMBLE) == (txh->MModeLen != 0)));
-       ASSERT(!IS_MCS(rspec[1]) ||
-              ((preamble_type[1] == WLC_MM_PREAMBLE) ==
-               (txh->MModeFbrLen != 0)));
-
        ac = skb_get_queue_mapping(p);
        if (SCB_WME(scb) && qos && wlc->edcf_txop[ac]) {
                uint frag_dur, dur, dur_fallback;
 
-               ASSERT(!is_multicast_ether_addr(h->addr1));
-
                /* WME: Update TXOP threshold */
                if ((!(tx_info->flags & IEEE80211_TX_CTL_AMPDU)) && (frag == 0)) {
                        frag_dur =
@@ -6359,16 +5741,18 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw,
                                        }
                                }
                        } else
-                               WL_ERROR("wl%d: %s txop invalid for rate %d\n",
-                                        wlc->pub->unit, fifo_names[queue],
-                                        RSPEC2RATE(rspec[0]));
+                               wiphy_err(wlc->wiphy, "wl%d: %s txop invalid "
+                                         "for rate %d\n",
+                                         wlc->pub->unit, fifo_names[queue],
+                                         RSPEC2RATE(rspec[0]));
 
                        if (dur > wlc->edcf_txop[ac])
-                               WL_ERROR("wl%d: %s: %s txop exceeded phylen %d/%d dur %d/%d\n",
-                                        wlc->pub->unit, __func__,
-                                        fifo_names[queue],
-                                        phylen, wlc->fragthresh[queue],
-                                        dur, wlc->edcf_txop[ac]);
+                               wiphy_err(wlc->wiphy, "wl%d: %s: %s txop "
+                                         "exceeded phylen %d/%d dur %d/%d\n",
+                                         wlc->pub->unit, __func__,
+                                         fifo_names[queue],
+                                         phylen, wlc->fragthresh[queue],
+                                         dur, wlc->edcf_txop[ac]);
                }
        }
 
@@ -6379,8 +5763,6 @@ void wlc_tbtt(struct wlc_info *wlc, d11regs_t *regs)
 {
        struct wlc_bsscfg *cfg = wlc->cfg;
 
-       wlc->pub->_cnt->tbtt++;
-
        if (BSSCFG_STA(cfg)) {
                /* run watchdog here if the watchdog timer is not armed */
                if (WLC_WATCHDOG_TBTT(wlc)) {
@@ -6410,127 +5792,6 @@ void wlc_tbtt(struct wlc_info *wlc, d11regs_t *regs)
        }
 }
 
-/* GP timer is a freerunning 32 bit counter, decrements at 1 us rate */
-void wlc_hwtimer_gptimer_set(struct wlc_info *wlc, uint us)
-{
-       W_REG(&wlc->regs->gptimer, us);
-}
-
-void wlc_hwtimer_gptimer_abort(struct wlc_info *wlc)
-{
-       W_REG(&wlc->regs->gptimer, 0);
-}
-
-static void wlc_hwtimer_gptimer_cb(struct wlc_info *wlc)
-{
-       /* when interrupt is generated, the counter is loaded with last value
-        * written and continue to decrement. So it has to be cleaned first
-        */
-       W_REG(&wlc->regs->gptimer, 0);
-}
-
-/*
- * This fn has all the high level dpc processing from wlc_dpc.
- * POLICY: no macinstatus change, no bounding loop.
- *         All dpc bounding should be handled in BMAC dpc, like txstatus and rxint
- */
-void wlc_high_dpc(struct wlc_info *wlc, u32 macintstatus)
-{
-       d11regs_t *regs = wlc->regs;
-#ifdef BCMDBG
-       char flagstr[128];
-       static const bcm_bit_desc_t int_flags[] = {
-               {MI_MACSSPNDD, "MACSSPNDD"},
-               {MI_BCNTPL, "BCNTPL"},
-               {MI_TBTT, "TBTT"},
-               {MI_BCNSUCCESS, "BCNSUCCESS"},
-               {MI_BCNCANCLD, "BCNCANCLD"},
-               {MI_ATIMWINEND, "ATIMWINEND"},
-               {MI_PMQ, "PMQ"},
-               {MI_NSPECGEN_0, "NSPECGEN_0"},
-               {MI_NSPECGEN_1, "NSPECGEN_1"},
-               {MI_MACTXERR, "MACTXERR"},
-               {MI_NSPECGEN_3, "NSPECGEN_3"},
-               {MI_PHYTXERR, "PHYTXERR"},
-               {MI_PME, "PME"},
-               {MI_GP0, "GP0"},
-               {MI_GP1, "GP1"},
-               {MI_DMAINT, "DMAINT"},
-               {MI_TXSTOP, "TXSTOP"},
-               {MI_CCA, "CCA"},
-               {MI_BG_NOISE, "BG_NOISE"},
-               {MI_DTIM_TBTT, "DTIM_TBTT"},
-               {MI_PRQ, "PRQ"},
-               {MI_PWRUP, "PWRUP"},
-               {MI_RFDISABLE, "RFDISABLE"},
-               {MI_TFS, "TFS"},
-               {MI_PHYCHANGED, "PHYCHANGED"},
-               {MI_TO, "TO"},
-               {0, NULL}
-       };
-
-       if (macintstatus & ~(MI_TBTT | MI_TXSTOP)) {
-               bcm_format_flags(int_flags, macintstatus, flagstr,
-                                sizeof(flagstr));
-               WL_TRACE("wl%d: macintstatus 0x%x %s\n",
-                        wlc->pub->unit, macintstatus, flagstr);
-       }
-#endif                         /* BCMDBG */
-
-       if (macintstatus & MI_PRQ) {
-               /* Process probe request FIFO */
-               ASSERT(0 && "PRQ Interrupt in non-MBSS");
-       }
-
-       /* TBTT indication */
-       /* ucode only gives either TBTT or DTIM_TBTT, not both */
-       if (macintstatus & (MI_TBTT | MI_DTIM_TBTT))
-               wlc_tbtt(wlc, regs);
-
-       if (macintstatus & MI_GP0) {
-               WL_ERROR("wl%d: PSM microcode watchdog fired at %d (seconds). Resetting.\n",
-                        wlc->pub->unit, wlc->pub->now);
-
-               printk_once("%s : PSM Watchdog, chipid 0x%x, chiprev 0x%x\n",
-                                       __func__, wlc->pub->sih->chip,
-                                       wlc->pub->sih->chiprev);
-
-               wlc->pub->_cnt->psmwds++;
-
-               /* big hammer */
-               wl_init(wlc->wl);
-       }
-
-       /* gptimer timeout */
-       if (macintstatus & MI_TO) {
-               wlc_hwtimer_gptimer_cb(wlc);
-       }
-
-       if (macintstatus & MI_RFDISABLE) {
-               WL_ERROR("wl%d: MAC Detected a change on the RF Disable Input 0x%x\n",
-                        wlc->pub->unit,
-                        R_REG(&regs->phydebug) & PDBG_RFD);
-               /* delay the cleanup to wl_down in IBSS case */
-               if ((R_REG(&regs->phydebug) & PDBG_RFD)) {
-                       int idx;
-                       struct wlc_bsscfg *bsscfg;
-                       FOREACH_BSS(wlc, idx, bsscfg) {
-                               if (!BSSCFG_STA(bsscfg) || !bsscfg->enable
-                                   || !bsscfg->BSS)
-                                       continue;
-                               WL_ERROR("wl%d: wlc_dpc: rfdisable -> wlc_bsscfg_disable()\n",
-                                        wlc->pub->unit);
-                       }
-               }
-       }
-
-       /* send any enq'd tx packets. Just makes sure to jump start tx */
-       if (!pktq_empty(&wlc->active_queue->q))
-               wlc_send_q(wlc, wlc->active_queue);
-
-       ASSERT(wlc_ps_check(wlc));
-}
-
 static void wlc_war16165(struct wlc_info *wlc, bool tx)
 {
        if (tx) {
@@ -6546,7 +5807,7 @@ static void wlc_war16165(struct wlc_info *wlc, bool tx)
 
 /* process an individual tx_status_t */
 /* WLC_HIGH_API */
-bool BCMFASTPATH
+bool
 wlc_dotxstatus(struct wlc_info *wlc, tx_status_t *txs, u32 frm_tx2)
 {
        struct sk_buff *p;
@@ -6572,16 +5833,12 @@ wlc_dotxstatus(struct wlc_info *wlc, tx_status_t *txs, u32 frm_tx2)
         */
        if (!(txs->status & TX_STATUS_AMPDU)
            && (txs->status & TX_STATUS_INTERMEDIATE)) {
-               WLCNTADD(wlc->pub->_cnt->txnoack,
-                        ((txs->
-                          status & TX_STATUS_FRM_RTX_MASK) >>
-                         TX_STATUS_FRM_RTX_SHIFT));
-               WL_ERROR("%s: INTERMEDIATE but not AMPDU\n", __func__);
+               wiphy_err(wlc->wiphy, "%s: INTERMEDIATE but not AMPDU\n",
+                         __func__);
                return false;
        }
 
        queue = txs->frameid & TXFID_QUEUE_MASK;
-       ASSERT(queue < NFIFO);
        if (queue >= NFIFO) {
                p = NULL;
                goto fatal;
@@ -6598,41 +5855,31 @@ wlc_dotxstatus(struct wlc_info *wlc, tx_status_t *txs, u32 frm_tx2)
 
        if (txs->phyerr) {
                if (WL_ERROR_ON()) {
-                       WL_ERROR("phyerr 0x%x, rate 0x%x\n",
-                                txs->phyerr, txh->MainRates);
+                       wiphy_err(wlc->wiphy, "phyerr 0x%x, rate 0x%x\n",
+                                 txs->phyerr, txh->MainRates);
                        wlc_print_txdesc(txh);
                }
                wlc_print_txstatus(txs);
        }
 
-       ASSERT(txs->frameid == cpu_to_le16(txh->TxFrameID));
        if (txs->frameid != cpu_to_le16(txh->TxFrameID))
                goto fatal;
-
        tx_info = IEEE80211_SKB_CB(p);
        h = (struct ieee80211_hdr *)((u8 *) (txh + 1) + D11_PHY_HDR_LEN);
 
        if (tx_info->control.sta)
                scb = (struct scb *)tx_info->control.sta->drv_priv;
 
-       if (N_ENAB(wlc->pub)) {
-               u8 *plcp = (u8 *) (txh + 1);
-               if (PLCP3_ISSGI(plcp[3]))
-                       wlc->pub->_cnt->txmpdu_sgi++;
-               if (PLCP3_ISSTBC(plcp[3]))
-                       wlc->pub->_cnt->txmpdu_stbc++;
-       }
-
        if (tx_info->flags & IEEE80211_TX_CTL_AMPDU) {
-               ASSERT((mcl & TXC_AMPDU_MASK) != TXC_AMPDU_NONE);
                wlc_ampdu_dotxstatus(wlc->ampdu, scb, p, txs);
                return false;
        }
 
        supr_status = txs->status & TX_STATUS_SUPR_MASK;
        if (supr_status == TX_STATUS_SUPR_BADCH)
-               WL_NONE("%s: Pkt tx suppressed, possibly channel %d\n",
-                       __func__, CHSPEC_CHANNEL(wlc->default_bss->chanspec));
+               BCMMSG(wlc->wiphy,
+                      "%s: Pkt tx suppressed, possibly channel %d\n",
+                      __func__, CHSPEC_CHANNEL(wlc->default_bss->chanspec));
 
        tx_rts = cpu_to_le16(txh->MacTxControlLow) & TXC_SENDRTS;
        tx_frame_count =
@@ -6643,7 +5890,7 @@ wlc_dotxstatus(struct wlc_info *wlc, tx_status_t *txs, u32 frm_tx2)
        lastframe = !ieee80211_has_morefrags(h->frame_control);
 
        if (!lastframe) {
-               WL_ERROR("Not last frame!\n");
+               wiphy_err(wlc->wiphy, "Not last frame!\n");
        } else {
                u16 sfbl, lfbl;
                ieee80211_tx_info_clear_status(tx_info);
@@ -6679,7 +5926,7 @@ wlc_dotxstatus(struct wlc_info *wlc, tx_status_t *txs, u32 frm_tx2)
                        tx_info->flags |= IEEE80211_TX_STAT_ACK;
        }
 
-       totlen = pkttotlen(p);
+       totlen = bcm_pkttotlen(p);
        free_pdu = true;
 
        wlc_txfifo_complete(wlc, queue, 1);
@@ -6692,33 +5939,30 @@ wlc_dotxstatus(struct wlc_info *wlc, tx_status_t *txs, u32 frm_tx2)
                skb_pull(p, D11_PHY_HDR_LEN);
                skb_pull(p, D11_TXH_LEN);
                ieee80211_tx_status_irqsafe(wlc->pub->ieee_hw, p);
-               wlc->pub->_cnt->ieee_tx_status++;
        } else {
-               WL_ERROR("%s: Not last frame => not calling tx_status\n",
-                        __func__);
+               wiphy_err(wlc->wiphy, "%s: Not last frame => not calling "
+                         "tx_status\n", __func__);
        }
 
        return false;
 
  fatal:
-       ASSERT(0);
        if (p)
-               pkt_buf_free_skb(p);
+               bcm_pkt_buf_free_skb(p);
 
        return true;
 
 }
 
-void BCMFASTPATH
+void
 wlc_txfifo_complete(struct wlc_info *wlc, uint fifo, s8 txpktpend)
 {
        TXPKTPENDDEC(wlc, fifo, txpktpend);
-       WL_TRACE("wlc_txfifo_complete, pktpend dec %d to %d\n",
-                txpktpend, TXPKTPENDGET(wlc, fifo));
+       BCMMSG(wlc->wiphy, "pktpend dec %d to %d\n", txpktpend,
+               TXPKTPENDGET(wlc, fifo));
 
        /* There is more room; mark precedences related to this FIFO sendable */
        WLC_TX_FIFO_ENAB(wlc, fifo);
-       ASSERT(TXPKTPENDGET(wlc, fifo) >= 0);
 
        if (!TXPKTPENDTOT(wlc)) {
                if (wlc->block_datafifo & DATA_BLOCK_TX_SUPR)
@@ -6735,84 +5979,6 @@ wlc_txfifo_complete(struct wlc_info *wlc, uint fifo, s8 txpktpend)
        /* figure out which bsscfg is being worked on... */
 }
 
-/* Given the beacon interval in kus, and a 64 bit TSF in us,
- * return the offset (in us) of the TSF from the last TBTT
- */
-u32 wlc_calc_tbtt_offset(u32 bp, u32 tsf_h, u32 tsf_l)
-{
-       u32 k, btklo, btkhi, offset;
-
-       /* TBTT is always an even multiple of the beacon_interval,
-        * so the TBTT less than or equal to the beacon timestamp is
-        * the beacon timestamp minus the beacon timestamp modulo
-        * the beacon interval.
-        *
-        * TBTT = BT - (BT % BIu)
-        *      = (BTk - (BTk % BP)) * 2^10
-        *
-        * BT = beacon timestamp (usec, 64bits)
-        * BTk = beacon timestamp (Kusec, 54bits)
-        * BP = beacon interval (Kusec, 16bits)
-        * BIu = BP * 2^10 = beacon interval (usec, 26bits)
-        *
-        * To keep the calculations in u32s, the modulo operation
-        * on the high part of BT needs to be done in parts using the
-        * relations:
-        * X*Y mod Z = ((X mod Z) * (Y mod Z)) mod Z
-        * and
-        * (X + Y) mod Z = ((X mod Z) + (Y mod Z)) mod Z
-        *
-        * So, if BTk[n] = u16 n [0,3] of BTk.
-        * BTk % BP = SUM((BTk[n] * 2^16n) % BP , 0<=n<4) % BP
-        * and the SUM term can be broken down:
-        * (BTk[n] *     2^16n)    % BP
-        * (BTk[n] * (2^16n % BP)) % BP
-        *
-        * Create a set of power of 2 mod BP constants:
-        * K[n] = 2^(16n) % BP
-        *      = (K[n-1] * 2^16) % BP
-        * K[2] = 2^32 % BP = ((2^16 % BP) * 2^16) % BP
-        *
-        * BTk % BP = BTk[0-1] % BP +
-        *            (BTk[2] * K[2]) % BP +
-        *            (BTk[3] * K[3]) % BP
-        *
-        * Since K[n] < 2^16 and BTk[n] is < 2^16, then BTk[n] * K[n] < 2^32
-        */
-
-       /* BTk = BT >> 10, btklo = BTk[0-3], bkthi = BTk[4-6] */
-       btklo = (tsf_h << 22) | (tsf_l >> 10);
-       btkhi = tsf_h >> 10;
-
-       /* offset = BTk % BP */
-       offset = btklo % bp;
-
-       /* K[2] = ((2^16 % BP) * 2^16) % BP */
-       k = (u32) (1 << 16) % bp;
-       k = (u32) (k * 1 << 16) % (u32) bp;
-
-       /* offset += (BTk[2] * K[2]) % BP */
-       offset += ((btkhi & 0xffff) * k) % bp;
-
-       /* BTk[3] */
-       btkhi = btkhi >> 16;
-
-       /* k[3] = (K[2] * 2^16) % BP */
-       k = (k << 16) % bp;
-
-       /* offset += (BTk[3] * K[3]) % BP */
-       offset += ((btkhi & 0xffff) * k) % bp;
-
-       offset = offset % bp;
-
-       /* convert offset from kus to us by shifting up 10 bits and
-        * add in the low 10 bits of tsf that we ignored
-        */
-       offset = (offset << 10) + (tsf_l & 0x3FF);
-
-       return offset;
-}
-
 /* Update beacon listen interval in shared memory */
 void wlc_bcn_li_upd(struct wlc_info *wlc)
 {
@@ -6827,25 +5993,56 @@ void wlc_bcn_li_upd(struct wlc_info *wlc)
                              (wlc->bcn_li_dtim << 8) | wlc->bcn_li_bcn);
 }
 
+/*
+ * recover 64bit TSF value from the 16bit TSF value in the rx header
+ * given the assumption that the TSF passed in header is within 65ms
+ * of the current tsf.
+ *
+ * 6       5       4       4       3       2       1
+ * 3.......6.......8.......0.......2.......4.......6.......8......0
+ * |<---------- tsf_h ----------->||<--- tsf_l -->||<-RxTSFTime ->|
+ *
+ * The RxTSFTime are the lowest 16 bits and provided by the ucode. The
+ * tsf_l is filled in by wlc_bmac_recv, which is done earlier in the
+ * receive call sequence after rx interrupt. Only the higher 16 bits
+ * are used. Finally, the tsf_h is read from the tsf register.
+ */
+static u64 wlc_recover_tsf64(struct wlc_info *wlc, struct wlc_d11rxhdr *rxh)
+{
+       u32 tsf_h, tsf_l;
+       u16 rx_tsf_0_15, rx_tsf_16_31;
+
+       wlc_bmac_read_tsf(wlc->hw, &tsf_l, &tsf_h);
+
+       rx_tsf_16_31 = (u16)(tsf_l >> 16);
+       rx_tsf_0_15 = rxh->rxhdr.RxTSFTime;
+
+       /*
+        * a greater tsf time indicates the low 16 bits of
+        * tsf_l wrapped, so decrement the high 16 bits.
+        */
+       if ((u16)tsf_l < rx_tsf_0_15) {
+               rx_tsf_16_31 -= 1;
+               if (rx_tsf_16_31 == 0xffff)
+                       tsf_h -= 1;
+       }
+
+       return ((u64)tsf_h << 32) | (((u32)rx_tsf_16_31 << 16) + rx_tsf_0_15);
+}
+
 static void
 prep_mac80211_status(struct wlc_info *wlc, d11rxhdr_t *rxh, struct sk_buff *p,
                     struct ieee80211_rx_status *rx_status)
 {
-       u32 tsf_l, tsf_h;
        wlc_d11rxhdr_t *wlc_rxh = (wlc_d11rxhdr_t *) rxh;
        int preamble;
        int channel;
        ratespec_t rspec;
        unsigned char *plcp;
 
-#if 0
-       /* Clearly, this is bogus -- reading the TSF now is wrong */
-       wlc_read_tsf(wlc, &tsf_l, &tsf_h);      /* mactime */
-       rx_status->mactime = tsf_h;
-       rx_status->mactime <<= 32;
-       rx_status->mactime |= tsf_l;
-       rx_status->flag |= RX_FLAG_MACTIME_MPDU; /* clearly wrong */
-#endif
+       /* fill in TSF and flag its presence */
+       rx_status->mactime = wlc_recover_tsf64(wlc, wlc_rxh);
+       rx_status->flag |= RX_FLAG_MACTIME_MPDU;
 
        channel = WLC_CHAN_CHANNEL(rxh->RxChan);
 
@@ -6912,7 +6109,7 @@ prep_mac80211_status(struct wlc_info *wlc, d11rxhdr_t *rxh, struct sk_buff *p,
                        rx_status->rate_idx = 11;
                        break;
                default:
-                       WL_ERROR("%s: Unknown rate\n", __func__);
+                       wiphy_err(wlc->wiphy, "%s: Unknown rate\n", __func__);
                }
 
                /* Determine short preamble and rate_idx */
@@ -6923,7 +6120,8 @@ prep_mac80211_status(struct wlc_info *wlc, d11rxhdr_t *rxh, struct sk_buff *p,
                } else if (IS_OFDM(rspec)) {
                        rx_status->flag |= RX_FLAG_SHORTPRE;
                } else {
-                       WL_ERROR("%s: Unknown modulation\n", __func__);
+                       wiphy_err(wlc->wiphy, "%s: Unknown modulation\n",
+                                 __func__);
                }
        }
 
@@ -6932,11 +6130,13 @@ prep_mac80211_status(struct wlc_info *wlc, d11rxhdr_t *rxh, struct sk_buff *p,
 
        if (rxh->RxStatus1 & RXS_DECERR) {
                rx_status->flag |= RX_FLAG_FAILED_PLCP_CRC;
-               WL_ERROR("%s:  RX_FLAG_FAILED_PLCP_CRC\n", __func__);
+               wiphy_err(wlc->wiphy, "%s:  RX_FLAG_FAILED_PLCP_CRC\n",
+                         __func__);
        }
        if (rxh->RxStatus1 & RXS_FCSERR) {
                rx_status->flag |= RX_FLAG_FAILED_FCS_CRC;
-               WL_ERROR("%s:  RX_FLAG_FAILED_FCS_CRC\n", __func__);
+               wiphy_err(wlc->wiphy, "%s:  RX_FLAG_FAILED_FCS_CRC\n",
+                         __func__);
        }
 }
 
@@ -6945,14 +6145,6 @@ wlc_recvctl(struct wlc_info *wlc, d11rxhdr_t *rxh, struct sk_buff *p)
 {
        int len_mpdu;
        struct ieee80211_rx_status rx_status;
-#if defined(BCMDBG)
-       struct sk_buff *skb = p;
-#endif                         /* BCMDBG */
-       /* Todo:
-        * Cache plcp for first MPDU of AMPD and use chacched version for INTERMEDIATE.
-        * Test for INTERMEDIATE  like so:
-        * if (!(plcp[0] | plcp[1] | plcp[2]))
-        */
 
        memset(&rx_status, 0, sizeof(rx_status));
        prep_mac80211_status(wlc, rxh, p, &rx_status);
@@ -6962,48 +6154,25 @@ wlc_recvctl(struct wlc_info *wlc, d11rxhdr_t *rxh, struct sk_buff *p)
        skb_pull(p, D11_PHY_HDR_LEN);
        __skb_trim(p, len_mpdu);
 
-       ASSERT(!(p->next));
-       ASSERT(!(p->prev));
-
-       ASSERT(IS_ALIGNED((unsigned long)skb->data, 2));
-
        memcpy(IEEE80211_SKB_RXCB(p), &rx_status, sizeof(rx_status));
        ieee80211_rx_irqsafe(wlc->pub->ieee_hw, p);
-
-       wlc->pub->_cnt->ieee_rx++;
        return;
 }
 
-void wlc_bss_list_free(struct wlc_info *wlc, struct wlc_bss_list *bss_list)
-{
-       uint index;
-
-       if (!bss_list) {
-               WL_ERROR("%s: Attempting to free NULL list\n", __func__);
-               return;
-       }
-       /* inspect all BSS descriptor */
-       for (index = 0; index < bss_list->count; index++) {
-               kfree(bss_list->ptrs[index]);
-               bss_list->ptrs[index] = NULL;
-       }
-       bss_list->count = 0;
-}
-
 /* Process received frames */
 /*
  * Return true if more frames need to be processed. false otherwise.
  * Param 'bound' indicates max. # frames to process before break out.
  */
 /* WLC_HIGH_API */
-void BCMFASTPATH wlc_recv(struct wlc_info *wlc, struct sk_buff *p)
+void wlc_recv(struct wlc_info *wlc, struct sk_buff *p)
 {
        d11rxhdr_t *rxh;
        struct ieee80211_hdr *h;
        uint len;
        bool is_amsdu;
 
-       WL_TRACE("wl%d: wlc_recv\n", wlc->pub->unit);
+       BCMMSG(wlc->wiphy, "wl%d\n", wlc->pub->unit);
 
        /* frame starts with rxhdr */
        rxh = (d11rxhdr_t *) (p->data);
@@ -7027,9 +6196,8 @@ void BCMFASTPATH wlc_recv(struct wlc_info *wlc, struct sk_buff *p)
        /* MAC inserts 2 pad bytes for a4 headers or QoS or A-MSDU subframes */
        if (rxh->RxStatus1 & RXS_PBPRES) {
                if (p->len < 2) {
-                       wlc->pub->_cnt->rxrunt++;
-                       WL_ERROR("wl%d: wlc_recv: rcvd runt of len %d\n",
-                                wlc->pub->unit, p->len);
+                       wiphy_err(wlc->wiphy, "wl%d: wlc_recv: rcvd runt of "
+                                 "len %d\n", wlc->pub->unit, p->len);
                        goto toss;
                }
                skb_pull(p, 2);
@@ -7040,17 +6208,17 @@ void BCMFASTPATH wlc_recv(struct wlc_info *wlc, struct sk_buff *p)
 
        if (rxh->RxStatus1 & RXS_FCSERR) {
                if (wlc->pub->mac80211_state & MAC80211_PROMISC_BCNS) {
-                       WL_ERROR("FCSERR while scanning******* - tossing\n");
+                       wiphy_err(wlc->wiphy, "FCSERR while scanning******* -"
+                                 " tossing\n");
                        goto toss;
                } else {
-                       WL_ERROR("RCSERR!!!\n");
+                       wiphy_err(wlc->wiphy, "RCSERR!!!\n");
                        goto toss;
                }
        }
 
        /* check received pkt has at least frame control field */
        if (len < D11_PHY_HDR_LEN + sizeof(h->frame_control)) {
-               wlc->pub->_cnt->rxrunt++;
                goto toss;
        }
 
@@ -7064,13 +6232,12 @@ void BCMFASTPATH wlc_recv(struct wlc_info *wlc, struct sk_buff *p)
                    ieee80211_is_mgmt(h->frame_control)) {
                        if ((is_zero_ether_addr(h->addr2) ||
                             is_multicast_ether_addr(h->addr2))) {
-                               WL_ERROR("wl%d: %s: dropping a frame with "
-                                        "invalid src mac address, a2: %pM\n",
+                               wiphy_err(wlc->wiphy, "wl%d: %s: dropping a "
+                                         "frame with invalid src mac address,"
+                                         " a2: %pM\n",
                                         wlc->pub->unit, __func__, h->addr2);
-                               wlc->pub->_cnt->rxbadsrcmac++;
                                goto toss;
                        }
-                       wlc->pub->_cnt->rxfrag++;
                }
        }
 
@@ -7085,7 +6252,7 @@ void BCMFASTPATH wlc_recv(struct wlc_info *wlc, struct sk_buff *p)
        return;
 
  toss:
-       pkt_buf_free_skb(p);
+       bcm_pkt_buf_free_skb(p);
 }
 
 /* calculate frame duration for Mixed-mode L-SIG spoofing, return
@@ -7094,12 +6261,12 @@ void BCMFASTPATH wlc_recv(struct wlc_info *wlc, struct sk_buff *p)
  * Formula given by HT PHY Spec v 1.13
  *   len = 3(nsyms + nstream + 3) - 3
  */
-u16 BCMFASTPATH
+u16
 wlc_calc_lsig_len(struct wlc_info *wlc, ratespec_t ratespec, uint mac_len)
 {
        uint nsyms, len = 0, kNdps;
 
-       WL_TRACE("wl%d: wlc_calc_lsig_len: rate %d, len%d\n",
+       BCMMSG(wlc->wiphy, "wl%d: rate %d, len%d\n",
                 wlc->pub->unit, RSPEC2RATE(ratespec), mac_len);
 
        if (IS_MCS(ratespec)) {
@@ -7107,7 +6274,6 @@ wlc_calc_lsig_len(struct wlc_info *wlc, ratespec_t ratespec, uint mac_len)
                /* MCS_TXS(mcs) returns num tx streams - 1 */
                int tot_streams = (MCS_TXS(mcs) + 1) + RSPEC_STC(ratespec);
 
-               ASSERT(WLC_PHY_11N_CAP(wlc->band));
                /* the payload duration calculation matches that of regular ofdm */
                /* 1000Ndbps = kbps * 4 */
                kNdps =
@@ -7135,7 +6301,7 @@ wlc_calc_lsig_len(struct wlc_info *wlc, ratespec_t ratespec, uint mac_len)
 }
 
 /* calculate frame duration of a given rate and length, return time in usec unit */
-uint BCMFASTPATH
+uint
 wlc_calc_frame_time(struct wlc_info *wlc, ratespec_t ratespec, u8 preamble_type,
                    uint mac_len)
 {
@@ -7143,19 +6309,17 @@ wlc_calc_frame_time(struct wlc_info *wlc, ratespec_t ratespec, u8 preamble_type,
        uint rate = RSPEC2RATE(ratespec);
 
        if (rate == 0) {
-               ASSERT(0);
-               WL_ERROR("wl%d: WAR: using rate of 1 mbps\n", wlc->pub->unit);
+               wiphy_err(wlc->wiphy, "wl%d: WAR: using rate of 1 mbps\n",
+                         wlc->pub->unit);
                rate = WLC_RATE_1M;
        }
 
-       WL_TRACE("wl%d: wlc_calc_frame_time: rspec 0x%x, preamble_type %d, len%d\n",
+       BCMMSG(wlc->wiphy, "wl%d: rspec 0x%x, preamble_type %d, len%d\n",
                 wlc->pub->unit, ratespec, preamble_type, mac_len);
 
        if (IS_MCS(ratespec)) {
                uint mcs = ratespec & RSPEC_RATE_MASK;
                int tot_streams = MCS_TXS(mcs) + RSPEC_STC(ratespec);
-               ASSERT(WLC_PHY_11N_CAP(wlc->band));
-               ASSERT(WLC_IS_MIMO_PREAMBLE(preamble_type));
 
                dur = PREN_PREAMBLE + (tot_streams * PREN_PREAMBLE_EXT);
                if (preamble_type == WLC_MM_PREAMBLE)
@@ -7213,13 +6377,12 @@ wlc_calc_frame_len(struct wlc_info *wlc, ratespec_t ratespec, u8 preamble_type,
        uint nsyms, mac_len, Ndps, kNdps;
        uint rate = RSPEC2RATE(ratespec);
 
-       WL_TRACE("wl%d: wlc_calc_frame_len: rspec 0x%x, preamble_type %d, dur %d\n",
+       BCMMSG(wlc->wiphy, "wl%d: rspec 0x%x, preamble_type %d, dur %d\n",
                 wlc->pub->unit, ratespec, preamble_type, dur);
 
        if (IS_MCS(ratespec)) {
                uint mcs = ratespec & RSPEC_RATE_MASK;
                int tot_streams = MCS_TXS(mcs) + RSPEC_STC(ratespec);
-               ASSERT(WLC_PHY_11N_CAP(wlc->band));
                dur -= PREN_PREAMBLE + (tot_streams * PREN_PREAMBLE_EXT);
                /* payload calculation matches that of regular ofdm */
                if (BAND_2G(wlc->band->bandtype))
@@ -7256,33 +6419,29 @@ wlc_calc_frame_len(struct wlc_info *wlc, ratespec_t ratespec, u8 preamble_type,
 static uint
 wlc_calc_ba_time(struct wlc_info *wlc, ratespec_t rspec, u8 preamble_type)
 {
-       WL_TRACE("wl%d: wlc_calc_ba_time: rspec 0x%x, preamble_type %d\n",
-                wlc->pub->unit, rspec, preamble_type);
+       BCMMSG(wlc->wiphy, "wl%d: rspec 0x%x, "
+                "preamble_type %d\n", wlc->pub->unit, rspec, preamble_type);
        /* Spec 9.6: ack rate is the highest rate in BSSBasicRateSet that is less than
         * or equal to the rate of the immediately previous frame in the FES
         */
        rspec = WLC_BASIC_RATE(wlc, rspec);
-       ASSERT(VALID_RATE_DBG(wlc, rspec));
-
        /* BA len == 32 == 16(ctl hdr) + 4(ba len) + 8(bitmap) + 4(fcs) */
        return wlc_calc_frame_time(wlc, rspec, preamble_type,
                                   (DOT11_BA_LEN + DOT11_BA_BITMAP_LEN +
                                    FCS_LEN));
 }
 
-static uint BCMFASTPATH
+static uint
 wlc_calc_ack_time(struct wlc_info *wlc, ratespec_t rspec, u8 preamble_type)
 {
        uint dur = 0;
 
-       WL_TRACE("wl%d: wlc_calc_ack_time: rspec 0x%x, preamble_type %d\n",
-                wlc->pub->unit, rspec, preamble_type);
+       BCMMSG(wlc->wiphy, "wl%d: rspec 0x%x, preamble_type %d\n",
+               wlc->pub->unit, rspec, preamble_type);
        /* Spec 9.6: ack rate is the highest rate in BSSBasicRateSet that is less than
         * or equal to the rate of the immediately previous frame in the FES
         */
        rspec = WLC_BASIC_RATE(wlc, rspec);
-       ASSERT(VALID_RATE_DBG(wlc, rspec));
-
        /* ACK frame len == 14 == 2(fc) + 2(dur) + 6(ra) + 4(fcs) */
        dur =
            wlc_calc_frame_time(wlc, rspec, preamble_type,
@@ -7293,8 +6452,8 @@ wlc_calc_ack_time(struct wlc_info *wlc, ratespec_t rspec, u8 preamble_type)
 static uint
 wlc_calc_cts_time(struct wlc_info *wlc, ratespec_t rspec, u8 preamble_type)
 {
-       WL_TRACE("wl%d: wlc_calc_cts_time: ratespec 0x%x, preamble_type %d\n",
-                wlc->pub->unit, rspec, preamble_type);
+       BCMMSG(wlc->wiphy, "wl%d: ratespec 0x%x, preamble_type %d\n",
+               wlc->pub->unit, rspec, preamble_type);
        return wlc_calc_ack_time(wlc, rspec, preamble_type);
 }
 
@@ -7320,11 +6479,12 @@ void wlc_rate_lookup_init(struct wlc_info *wlc, wlc_rateset_t *rateset)
                        continue;
 
                /* mask off basic bit */
-               rate = (rateset->rates[i] & RATE_MASK);
+               rate = (rateset->rates[i] & WLC_RATE_MASK);
 
                if (rate > WLC_MAXRATE) {
-                       WL_ERROR("wlc_rate_lookup_init: invalid rate 0x%X in rate set\n",
-                                rateset->rates[i]);
+                       wiphy_err(wlc->wiphy, "wlc_rate_lookup_init: invalid "
+                                 "rate 0x%X in rate set\n",
+                                 rateset->rates[i]);
                        continue;
                }
 
@@ -7347,7 +6507,6 @@ void wlc_rate_lookup_init(struct wlc_info *wlc, wlc_rateset_t *rateset)
 
        for (i = 0; i < wlc->band->hw_rateset.count; i++) {
                rate = wlc->band->hw_rateset.rates[i];
-               ASSERT(rate <= WLC_MAXRATE);
 
                if (br[rate] != 0) {
                        /* This rate is a basic rate.
@@ -7406,8 +6565,8 @@ static void wlc_write_rate_shm(struct wlc_info *wlc, u8 rate, u8 basic_rate)
         * for a given rate, the LS-nibble of the PLCP SIGNAL field is
         * the index into the rate table.
         */
-       phy_rate = rate_info[rate] & RATE_MASK;
-       basic_phy_rate = rate_info[basic_rate] & RATE_MASK;
+       phy_rate = rate_info[rate] & WLC_RATE_MASK;
+       basic_phy_rate = rate_info[basic_rate] & WLC_RATE_MASK;
        index = phy_rate & 0xf;
        basic_index = basic_phy_rate & 0xf;
 
@@ -7447,14 +6606,13 @@ void wlc_set_ratetable(struct wlc_info *wlc)
        uint i;
 
        rs_dflt = wlc_rateset_get_hwrs(wlc);
-       ASSERT(rs_dflt != NULL);
 
        wlc_rateset_copy(rs_dflt, &rs);
        wlc_rateset_mcs_upd(&rs, wlc->stf->txstreams);
 
        /* walk the phy rate table and update SHM basic rate lookup table */
        for (i = 0; i < rs.count; i++) {
-               rate = rs.rates[i] & RATE_MASK;
+               rate = rs.rates[i] & WLC_RATE_MASK;
 
                /* for a given rate WLC_BASIC_RATE returns the rate at
                 * which a response ACK/CTS should be sent.
@@ -7464,7 +6622,7 @@ void wlc_set_ratetable(struct wlc_info *wlc)
                        /* This should only happen if we are using a
                         * restricted rateset.
                         */
-                       basic_rate = rs.rates[0] & RATE_MASK;
+                       basic_rate = rs.rates[0] & WLC_RATE_MASK;
                }
 
                wlc_write_rate_shm(wlc, rate, basic_rate);
@@ -7503,8 +6661,8 @@ bool wlc_valid_rate(struct wlc_info *wlc, ratespec_t rspec, int band,
                        return true;
  error:
        if (verbose) {
-               WL_ERROR("wl%d: wlc_valid_rate: rate spec 0x%x not in hw_rateset\n",
-                        wlc->pub->unit, rspec);
+               wiphy_err(wlc->wiphy, "wl%d: wlc_valid_rate: rate spec 0x%x "
+                         "not in hw_rateset\n", wlc->pub->unit, rspec);
        }
 
        return false;
@@ -7526,7 +6684,6 @@ static void wlc_update_mimo_band_bwcap(struct wlc_info *wlc, u8 bwcap)
                        else
                                band->mimo_cap_40 = false;
                } else {
-                       ASSERT(band->bandtype == WLC_BAND_2G);
                        if (bwcap == WLC_N_BW_40ALL)
                                band->mimo_cap_40 = true;
                        else
@@ -7550,14 +6707,13 @@ void wlc_mod_prb_rsp_rate_table(struct wlc_info *wlc, uint frame_len)
        sifs = SIFS(wlc->band);
 
        rs_dflt = wlc_rateset_get_hwrs(wlc);
-       ASSERT(rs_dflt != NULL);
 
        wlc_rateset_copy(rs_dflt, &rs);
        wlc_rateset_mcs_upd(&rs, wlc->stf->txstreams);
 
        /* walk the phy rate table and update MAC core SHM basic rate table entries */
        for (i = 0; i < rs.count; i++) {
-               rate = rs.rates[i] & RATE_MASK;
+               rate = rs.rates[i] & WLC_RATE_MASK;
 
                entry_ptr = wlc_rate_shm_offset(wlc, rate);
 
@@ -7579,41 +6735,6 @@ void wlc_mod_prb_rsp_rate_table(struct wlc_info *wlc, uint frame_len)
        }
 }
 
-u16
-wlc_compute_bcntsfoff(struct wlc_info *wlc, ratespec_t rspec,
-                     bool short_preamble, bool phydelay)
-{
-       uint bcntsfoff = 0;
-
-       if (IS_MCS(rspec)) {
-               WL_ERROR("wl%d: recd beacon with mcs rate; rspec 0x%x\n",
-                        wlc->pub->unit, rspec);
-       } else if (IS_OFDM(rspec)) {
-               /* tx delay from MAC through phy to air (2.1 usec) +
-                * phy header time (preamble + PLCP SIGNAL == 20 usec) +
-                * PLCP SERVICE + MAC header time (SERVICE + FC + DUR + A1 + A2 + A3 + SEQ == 26
-                * bytes at beacon rate)
-                */
-               bcntsfoff += phydelay ? D11A_PHY_TX_DELAY : 0;
-               bcntsfoff += APHY_PREAMBLE_TIME + APHY_SIGNAL_TIME;
-               bcntsfoff +=
-                   wlc_compute_airtime(wlc, rspec,
-                                       APHY_SERVICE_NBITS / 8 +
-                                       DOT11_MAC_HDR_LEN);
-       } else {
-               /* tx delay from MAC through phy to air (3.4 usec) +
-                * phy header time (long preamble + PLCP == 192 usec) +
-                * MAC header time (FC + DUR + A1 + A2 + A3 + SEQ == 24 bytes at beacon rate)
-                */
-               bcntsfoff += phydelay ? D11B_PHY_TX_DELAY : 0;
-               bcntsfoff +=
-                   short_preamble ? D11B_PHY_SPREHDR_TIME :
-                   D11B_PHY_LPREHDR_TIME;
-               bcntsfoff += wlc_compute_airtime(wlc, rspec, DOT11_MAC_HDR_LEN);
-       }
-       return (u16) (bcntsfoff);
-}
-
 /*     Max buffering needed for beacon template/prb resp template is 142 bytes.
  *
  *     PLCP header is 6 bytes.
@@ -7635,10 +6756,6 @@ wlc_bcn_prb_template(struct wlc_info *wlc, u16 type, ratespec_t bcn_rspec,
        struct ieee80211_mgmt *h;
        int hdr_len, body_len;
 
-       ASSERT(*len >= 142);
-       ASSERT(type == IEEE80211_STYPE_BEACON ||
-              type == IEEE80211_STYPE_PROBE_RESP);
-
        if (MBSS_BCN_ENAB(cfg) && type == IEEE80211_STYPE_BEACON)
                hdr_len = DOT11_MAC_HDR_LEN;
        else
@@ -7730,12 +6847,6 @@ void wlc_bss_update_beacon(struct wlc_info *wlc, struct wlc_bsscfg *cfg)
 
                wlc->bcn_rspec =
                    wlc_lowest_basic_rspec(wlc, &cfg->current_bss->rateset);
-               ASSERT(wlc_valid_rate
-                      (wlc, wlc->bcn_rspec,
-                       CHSPEC_IS2G(cfg->current_bss->
-                                   chanspec) ? WLC_BAND_2G : WLC_BAND_5G,
-                       true));
-
                /* update the template and ucode shm */
                wlc_bcn_prb_template(wlc, IEEE80211_STYPE_BEACON,
                                     wlc->bcn_rspec, cfg, bcn, &len);
@@ -7825,7 +6936,7 @@ wlc_bss_update_probe_resp(struct wlc_info *wlc, struct wlc_bsscfg *cfg,
                if (suspend)
                        wlc_enable_mac(wlc);
        } else {                /* Generating probe resp in sw; update local template */
-               ASSERT(0 && "No software probe response support without MBSS");
+               /* error: No software probe response support without MBSS */
        }
 }
 
@@ -7837,11 +6948,8 @@ int wlc_prep_pdu(struct wlc_info *wlc, struct sk_buff *pdu, uint *fifop)
        struct ieee80211_hdr *h;
        struct scb *scb;
 
-       ASSERT(pdu);
        txh = (d11txh_t *) (pdu->data);
-       ASSERT(txh);
        h = (struct ieee80211_hdr *)((u8 *) (txh + 1) + D11_PHY_HDR_LEN);
-       ASSERT(h);
 
        /* get the pkt queue info. This was put at wlc_sendctl or wlc_send for PDU */
        fifo = le16_to_cpu(txh->TxFrameID) & TXFID_QUEUE_MASK;
@@ -7854,12 +6962,8 @@ int wlc_prep_pdu(struct wlc_info *wlc, struct sk_buff *pdu, uint *fifop)
        if (TXAVAIL(wlc, fifo) < MAX_DMA_SEGS) {
                /* Mark precedences related to this FIFO, unsendable */
                WLC_TX_FIFO_CLEAR(wlc, fifo);
-               return BCME_BUSY;
+               return -EBUSY;
        }
-
-       if (!ieee80211_is_data(txh->MacFrameControl))
-               wlc->pub->_cnt->txctl++;
-
        return 0;
 }
 
@@ -7889,7 +6993,7 @@ int wlc_get_revision_info(struct wlc_info *wlc, void *buf, uint len)
        wlc_rev_info_t *rinfo = (wlc_rev_info_t *) buf;
 
        if (len < WL_REV_INFO_LEGACY_LENGTH)
-               return BCME_BUFTOOSHORT;
+               return -EOVERFLOW;
 
        rinfo->vendorid = wlc->vendorid;
        rinfo->deviceid = wlc->deviceid;
@@ -7915,13 +7019,13 @@ int wlc_get_revision_info(struct wlc_info *wlc, void *buf, uint len)
                rinfo->chippkg = wlc->pub->sih->chippkg;
        }
 
-       return BCME_OK;
+       return 0;
 }
 
 void wlc_default_rateset(struct wlc_info *wlc, wlc_rateset_t *rs)
 {
        wlc_rateset_default(rs, NULL, wlc->band->phytype, wlc->band->bandtype,
-                           false, RATE_MASK_FULL, (bool) N_ENAB(wlc->pub),
+                           false, WLC_RATE_MASK_FULL, (bool) N_ENAB(wlc->pub),
                            CHSPEC_WLC_BW(wlc->default_bss->chanspec),
                            wlc->stf->txstreams);
 }
@@ -7943,8 +7047,6 @@ static void wlc_bss_default_init(struct wlc_info *wlc)
         * starting from the 2G channels
         */
        chanspec = CH20MHZ_CHSPEC(1);
-       ASSERT(chanspec != INVCHANSPEC);
-
        wlc->home_chanspec = bi->chanspec = chanspec;
 
        /* find the band of our default channel */
@@ -7954,24 +7056,13 @@ static void wlc_bss_default_init(struct wlc_info *wlc)
 
        /* init bss rates to the band specific default rate set */
        wlc_rateset_default(&bi->rateset, NULL, band->phytype, band->bandtype,
-                           false, RATE_MASK_FULL, (bool) N_ENAB(wlc->pub),
+                           false, WLC_RATE_MASK_FULL, (bool) N_ENAB(wlc->pub),
                            CHSPEC_WLC_BW(chanspec), wlc->stf->txstreams);
 
        if (N_ENAB(wlc->pub))
                bi->flags |= WLC_BSS_HT;
 }
 
-void
-wlc_uint64_sub(u32 *a_high, u32 *a_low, u32 b_high, u32 b_low)
-{
-       if (b_low > *a_low) {
-               /* low half needs a carry */
-               b_high += 1;
-       }
-       *a_low -= b_low;
-       *a_high -= b_high;
-}
-
 static ratespec_t
 mac80211_wlc_set_nrate(struct wlc_info *wlc, struct wlcband *cur_band,
                       u32 int_val)
@@ -7993,9 +7084,9 @@ mac80211_wlc_set_nrate(struct wlc_info *wlc, struct wlcband *cur_band,
        if (N_ENAB(wlc->pub) && ismcs) {
                /* mcs only allowed when nmode */
                if (stf > PHY_TXC1_MODE_SDM) {
-                       WL_ERROR("wl%d: %s: Invalid stf\n",
+                       wiphy_err(wlc->wiphy, "wl%d: %s: Invalid stf\n",
                                 WLCWLUNIT(wlc), __func__);
-                       bcmerror = BCME_RANGE;
+                       bcmerror = -EINVAL;
                        goto done;
                }
 
@@ -8004,17 +7095,18 @@ mac80211_wlc_set_nrate(struct wlc_info *wlc, struct wlcband *cur_band,
                        if (!CHSPEC_IS40(wlc->home_chanspec) ||
                            ((stf != PHY_TXC1_MODE_SISO)
                             && (stf != PHY_TXC1_MODE_CDD))) {
-                               WL_ERROR("wl%d: %s: Invalid mcs 32\n",
-                                        WLCWLUNIT(wlc), __func__);
-                               bcmerror = BCME_RANGE;
+                               wiphy_err(wlc->wiphy, "wl%d: %s: Invalid mcs "
+                                         "32\n", WLCWLUNIT(wlc), __func__);
+                               bcmerror = -EINVAL;
                                goto done;
                        }
                        /* mcs > 7 must use stf SDM */
                } else if (rate > HIGHEST_SINGLE_STREAM_MCS) {
                        /* mcs > 7 must use stf SDM */
                        if (stf != PHY_TXC1_MODE_SDM) {
-                               WL_TRACE("wl%d: %s: enabling SDM mode for mcs %d\n",
-                                        WLCWLUNIT(wlc), __func__, rate);
+                               BCMMSG(wlc->wiphy, "wl%d: enabling "
+                                        "SDM mode for mcs %d\n",
+                                        WLCWLUNIT(wlc), rate);
                                stf = PHY_TXC1_MODE_SDM;
                        }
                } else {
@@ -8022,38 +7114,38 @@ mac80211_wlc_set_nrate(struct wlc_info *wlc, struct wlcband *cur_band,
                        if ((stf > PHY_TXC1_MODE_STBC) ||
                            (!WLC_STBC_CAP_PHY(wlc)
                             && (stf == PHY_TXC1_MODE_STBC))) {
-                               WL_ERROR("wl%d: %s: Invalid STBC\n",
-                                        WLCWLUNIT(wlc), __func__);
-                               bcmerror = BCME_RANGE;
+                               wiphy_err(wlc->wiphy, "wl%d: %s: Invalid STBC"
+                                         "\n", WLCWLUNIT(wlc), __func__);
+                               bcmerror = -EINVAL;
                                goto done;
                        }
                }
        } else if (IS_OFDM(rate)) {
                if ((stf != PHY_TXC1_MODE_CDD) && (stf != PHY_TXC1_MODE_SISO)) {
-                       WL_ERROR("wl%d: %s: Invalid OFDM\n",
-                                WLCWLUNIT(wlc), __func__);
-                       bcmerror = BCME_RANGE;
+                       wiphy_err(wlc->wiphy, "wl%d: %s: Invalid OFDM\n",
+                                 WLCWLUNIT(wlc), __func__);
+                       bcmerror = -EINVAL;
                        goto done;
                }
        } else if (IS_CCK(rate)) {
                if ((cur_band->bandtype != WLC_BAND_2G)
                    || (stf != PHY_TXC1_MODE_SISO)) {
-                       WL_ERROR("wl%d: %s: Invalid CCK\n",
-                                WLCWLUNIT(wlc), __func__);
-                       bcmerror = BCME_RANGE;
+                       wiphy_err(wlc->wiphy, "wl%d: %s: Invalid CCK\n",
+                                 WLCWLUNIT(wlc), __func__);
+                       bcmerror = -EINVAL;
                        goto done;
                }
        } else {
-               WL_ERROR("wl%d: %s: Unknown rate type\n",
-                        WLCWLUNIT(wlc), __func__);
-               bcmerror = BCME_RANGE;
+               wiphy_err(wlc->wiphy, "wl%d: %s: Unknown rate type\n",
+                         WLCWLUNIT(wlc), __func__);
+               bcmerror = -EINVAL;
                goto done;
        }
        /* make sure multiple antennae are available for non-siso rates */
        if ((stf != PHY_TXC1_MODE_SISO) && (wlc->stf->txstreams == 1)) {
-               WL_ERROR("wl%d: %s: SISO antenna but !SISO request\n",
-                        WLCWLUNIT(wlc), __func__);
-               bcmerror = BCME_RANGE;
+               wiphy_err(wlc->wiphy, "wl%d: %s: SISO antenna but !SISO "
+                         "request\n", WLCWLUNIT(wlc), __func__);
+               bcmerror = -EINVAL;
                goto done;
        }
 
@@ -8082,8 +7174,7 @@ mac80211_wlc_set_nrate(struct wlc_info *wlc, struct wlcband *cur_band,
        }
 
        return rspec;
- done:
-       WL_ERROR("Hoark\n");
+done:
        return rate;
 }
 
@@ -8097,8 +7188,9 @@ wlc_duty_cycle_set(struct wlc_info *wlc, int duty_cycle, bool isOFDM,
            isOFDM ? M_TX_IDLE_BUSY_RATIO_X_16_OFDM :
            M_TX_IDLE_BUSY_RATIO_X_16_CCK;
        if (duty_cycle > 100 || duty_cycle < 0) {
-               WL_ERROR("wl%d:  duty cycle value off limit\n", wlc->pub->unit);
-               return BCME_RANGE;
+               wiphy_err(wlc->wiphy, "wl%d:  duty cycle value off limit\n",
+                         wlc->pub->unit);
+               return -EINVAL;
        }
        if (duty_cycle)
                idle_busy_ratio_x_16 = (100 - duty_cycle) * 16 / duty_cycle;
@@ -8111,7 +7203,7 @@ wlc_duty_cycle_set(struct wlc_info *wlc, int duty_cycle, bool isOFDM,
        else
                wlc->tx_duty_cycle_cck = (u16) duty_cycle;
 
-       return BCME_OK;
+       return 0;
 }
 
 /* Read a single u16 from shared memory.
@@ -8130,22 +7222,6 @@ void wlc_write_shm(struct wlc_info *wlc, uint offset, u16 v)
        wlc_bmac_write_shm(wlc->hw, offset, v);
 }
 
-/* Set a range of shared memory to a value.
- * SHM 'offset' needs to be an even address and
- * Range length 'len' must be an even number of bytes
- */
-void wlc_set_shm(struct wlc_info *wlc, uint offset, u16 v, int len)
-{
-       /* offset and len need to be even */
-       ASSERT((offset & 1) == 0);
-       ASSERT((len & 1) == 0);
-
-       if (len <= 0)
-               return;
-
-       wlc_bmac_set_shm(wlc->hw, offset, v, len);
-}
-
 /* Copy a buffer to shared memory.
  * SHM 'offset' needs to be an even address and
  * Buffer length 'len' must be an even number of bytes
@@ -8153,29 +7229,11 @@ void wlc_set_shm(struct wlc_info *wlc, uint offset, u16 v, int len)
 void wlc_copyto_shm(struct wlc_info *wlc, uint offset, const void *buf, int len)
 {
        /* offset and len need to be even */
-       ASSERT((offset & 1) == 0);
-       ASSERT((len & 1) == 0);
-
-       if (len <= 0)
+       if (len <= 0 || (offset & 1) || (len & 1))
                return;
-       wlc_bmac_copyto_objmem(wlc->hw, offset, buf, len, OBJADDR_SHM_SEL);
-
-}
 
-/* Copy from shared memory to a buffer.
- * SHM 'offset' needs to be an even address and
- * Buffer length 'len' must be an even number of bytes
- */
-void wlc_copyfrom_shm(struct wlc_info *wlc, uint offset, void *buf, int len)
-{
-       /* offset and len need to be even */
-       ASSERT((offset & 1) == 0);
-       ASSERT((len & 1) == 0);
-
-       if (len <= 0)
-               return;
+       wlc_bmac_copyto_objmem(wlc->hw, offset, buf, len, OBJADDR_SHM_SEL);
 
-       wlc_bmac_copyfrom_objmem(wlc->hw, offset, buf, len, OBJADDR_SHM_SEL);
 }
 
 /* wrapper BMAC functions to for HIGH driver access */
@@ -8184,21 +7242,11 @@ void wlc_mctrl(struct wlc_info *wlc, u32 mask, u32 val)
        wlc_bmac_mctrl(wlc->hw, mask, val);
 }
 
-void wlc_corereset(struct wlc_info *wlc, u32 flags)
-{
-       wlc_bmac_corereset(wlc->hw, flags);
-}
-
 void wlc_mhf(struct wlc_info *wlc, u8 idx, u16 mask, u16 val, int bands)
 {
        wlc_bmac_mhf(wlc->hw, idx, mask, val, bands);
 }
 
-u16 wlc_mhf_get(struct wlc_info *wlc, u8 idx, int bands)
-{
-       return wlc_bmac_mhf_get(wlc->hw, idx, bands);
-}
-
 int wlc_xmtfifo_sz_get(struct wlc_info *wlc, uint fifo, uint *blocks)
 {
        return wlc_bmac_xmtfifo_sz_get(wlc->hw, fifo, blocks);
@@ -8225,16 +7273,6 @@ wlc_set_addrmatch(struct wlc_info *wlc, int match_reg_offset,
                memcpy(wlc->cfg->BSSID, addr, ETH_ALEN);
 }
 
-void wlc_set_rcmta(struct wlc_info *wlc, int idx, const u8 *addr)
-{
-       wlc_bmac_set_rcmta(wlc->hw, idx, addr);
-}
-
-void wlc_read_tsf(struct wlc_info *wlc, u32 *tsf_l_ptr, u32 *tsf_h_ptr)
-{
-       wlc_bmac_read_tsf(wlc->hw, tsf_l_ptr, tsf_h_ptr);
-}
-
 void wlc_set_cwmin(struct wlc_info *wlc, u16 newmin)
 {
        wlc->band->CWmin = newmin;
@@ -8247,12 +7285,6 @@ void wlc_set_cwmax(struct wlc_info *wlc, u16 newmax)
        wlc_bmac_set_cwmax(wlc->hw, newmax);
 }
 
-void wlc_fifoerrors(struct wlc_info *wlc)
-{
-
-       wlc_bmac_fifoerrors(wlc->hw);
-}
-
 /* Search mem rw utilities */
 
 void wlc_pllreq(struct wlc_info *wlc, bool set, mbool req_bit)
@@ -8264,17 +7296,6 @@ void wlc_reset_bmac_done(struct wlc_info *wlc)
 {
 }
 
-void wlc_ht_mimops_cap_update(struct wlc_info *wlc, u8 mimops_mode)
-{
-       wlc->ht_cap.cap_info &= ~IEEE80211_HT_CAP_SM_PS;
-       wlc->ht_cap.cap_info |= (mimops_mode << IEEE80211_HT_CAP_SM_PS_SHIFT);
-
-       if (AP_ENAB(wlc->pub) && wlc->clk) {
-               wlc_update_beacon(wlc);
-               wlc_update_probe_resp(wlc, true);
-       }
-}
-
 /* check for the particular priority flow control bit being set */
 bool
 wlc_txflowcontrol_prio_isset(struct wlc_info *wlc, struct wlc_txq_info *q,
@@ -8285,7 +7306,6 @@ wlc_txflowcontrol_prio_isset(struct wlc_info *wlc, struct wlc_txq_info *q,
        if (prio == ALLPRIO) {
                prio_mask = TXQ_STOP_FOR_PRIOFC_MASK;
        } else {
-               ASSERT(prio >= 0 && prio <= MAXPRIO);
                prio_mask = NBITVAL(prio);
        }
 
@@ -8299,12 +7319,11 @@ void wlc_txflowcontrol(struct wlc_info *wlc, struct wlc_txq_info *qi,
        uint prio_bits;
        uint cur_bits;
 
-       WL_TRACE("%s: flow control kicks in\n", __func__);
+       BCMMSG(wlc->wiphy, "flow control kicks in\n");
 
        if (prio == ALLPRIO) {
                prio_bits = TXQ_STOP_FOR_PRIOFC_MASK;
        } else {
-               ASSERT(prio >= 0 && prio <= MAXPRIO);
                prio_bits = NBITVAL(prio);
        }
 
@@ -8341,9 +7360,6 @@ wlc_txflowcontrol_override(struct wlc_info *wlc, struct wlc_txq_info *qi,
 {
        uint prev_override;
 
-       ASSERT(override != 0);
-       ASSERT((override & TXQ_STOP_FOR_PRIOFC_MASK) == 0);
-
        prev_override = (qi->stopped & ~TXQ_STOP_FOR_PRIOFC_MASK);
 
        /* Update the flow control bits and do an early return if there is
@@ -8411,7 +7427,7 @@ static struct wlc_txq_info *wlc_txq_alloc(struct wlc_info *wlc)
 {
        struct wlc_txq_info *qi, *p;
 
-       qi = wlc_calloc(wlc->pub->unit, sizeof(struct wlc_txq_info));
+       qi = kzalloc(sizeof(struct wlc_txq_info), GFP_ATOMIC);
        if (qi != NULL) {
                /*
                 * Have enough room for control packets along with HI watermark
@@ -8419,7 +7435,7 @@ static struct wlc_txq_info *wlc_txq_alloc(struct wlc_info *wlc)
                 * leave PS mode. The watermark for flowcontrol to OS packets
                 * will remain the same
                 */
-               pktq_init(&qi->q, WLC_PREC_COUNT,
+               bcm_pktq_init(&qi->q, WLC_PREC_COUNT,
                          (2 * wlc->pub->tunables->datahiwat) + PKTQ_LEN_DEFAULT
                          + wlc->pub->psq_pkts_total);
 
@@ -8450,7 +7466,6 @@ static void wlc_txq_free(struct wlc_info *wlc, struct wlc_txq_info *qi)
        else {
                while (p != NULL && p->next != qi)
                        p = p->next;
-               ASSERT(p->next == qi);
                if (p != NULL)
                        p->next = p->next->next;
        }
@@ -8494,3 +7509,21 @@ void wlc_inval_dma_pkts(struct wlc_hw_info *hw,
                        dma_walk_packets(dmah, dma_callback_fn, sta);
        }
 }
+
+int wlc_get_curband(struct wlc_info *wlc)
+{
+       return wlc->band->bandunit;
+}
+
+void wlc_wait_for_tx_completion(struct wlc_info *wlc, bool drop)
+{
+       /* flush packet queue when requested */
+       if (drop)
+               bcm_pktq_flush(&wlc->pkt_queue->q, false, NULL, NULL);
+
+       /* wait for queue and DMA fifos to run dry */
+       while (!pktq_empty(&wlc->pkt_queue->q) ||
+              TXPKTPENDTOT(wlc) > 0) {
+               wl_msleep(wlc->wl, 1);
+       }
+}
index 960f82cbfbc9843e24a2d7fa8162d91d4bbb031b..fb48dfcb97d529cc1aa1fd56f7db3dbbe0350fd8 100644 (file)
@@ -98,7 +98,6 @@ struct wlc_bss_list {
        (cfg)->wsec_portopen : true)
 
 #define PS_ALLOWED(wlc)        wlc_ps_allowed(wlc)
-#define STAY_AWAKE(wlc) wlc_stay_awake(wlc)
 
 #define DATA_BLOCK_TX_SUPR     (1 << 4)
 
@@ -166,9 +165,6 @@ extern const u8 prio2fifo[];
 #define WLC_PLLREQ_RADIO_MON   0x2     /* hold pll for radio monitor register checking */
 #define WLC_PLLREQ_FLIP                0x4     /* hold/release pll for some short operation */
 
-/* Do we support this rate? */
-#define VALID_RATE_DBG(wlc, rspec) wlc_valid_rate(wlc, rspec, WLC_BAND_AUTO, true)
-
 /*
  * Macros to check if AP or STA is active.
  * AP Active means more than just configured: driver and BSS are "up";
@@ -196,7 +192,7 @@ extern const u8 prio2fifo[];
        ((wlc->hw->clk) ?   \
        ((R_REG(&wlc->hw->regs->maccontrol) & \
        (MCTL_PSM_JMP_0 | MCTL_IHR_EN)) != MCTL_IHR_EN) : \
-       (si_deviceremoved(wlc->hw->sih)))
+       (ai_deviceremoved(wlc->hw->sih)))
 
 #define WLCWLUNIT(wlc)         ((wlc)->pub->unit)
 
@@ -746,9 +742,7 @@ struct wlc_info {
        u16 next_bsscfg_ID;
 
        struct wlc_if *wlcif_list;      /* linked list of wlc_if structs */
-       struct wlc_txq_info *active_queue; /* txq for the currently active
-                                           * transmit context
-                                           */
+       struct wlc_txq_info *pkt_queue; /* txq for transmit packets */
        u32 mpc_dur;            /* total time (ms) in mpc mode except for the
                                 * portion since radio is turned off last time
                                 */
@@ -757,6 +751,7 @@ struct wlc_info {
                                 */
        bool pr80838_war;
        uint hwrxoff;
+       struct wiphy *wiphy;
 };
 
 /* antsel module specific state */
@@ -794,7 +789,6 @@ struct antsel_info {
 #define WLC_IS_MATCH_SSID(wlc, ssid1, ssid2, len1, len2) \
        ((len1 == len2) && !memcmp(ssid1, ssid2, len1))
 
-extern void wlc_high_dpc(struct wlc_info *wlc, u32 macintstatus);
 extern void wlc_fatal_error(struct wlc_info *wlc);
 extern void wlc_bmac_rpc_watchdog(struct wlc_info *wlc);
 extern void wlc_recv(struct wlc_info *wlc, struct sk_buff *p);
@@ -811,21 +805,10 @@ extern void wlc_write_template_ram(struct wlc_info *wlc, int offset, int len,
                                   void *buf);
 extern void wlc_write_hw_bcntemplates(struct wlc_info *wlc, void *bcn, int len,
                                      bool both);
-#if defined(BCMDBG)
-extern void wlc_get_rcmta(struct wlc_info *wlc, int idx,
-                         u8 *addr);
-#endif
-extern void wlc_set_rcmta(struct wlc_info *wlc, int idx,
-                         const u8 *addr);
-extern void wlc_read_tsf(struct wlc_info *wlc, u32 *tsf_l_ptr,
-                        u32 *tsf_h_ptr);
 extern void wlc_set_cwmin(struct wlc_info *wlc, u16 newmin);
 extern void wlc_set_cwmax(struct wlc_info *wlc, u16 newmax);
-extern void wlc_fifoerrors(struct wlc_info *wlc);
 extern void wlc_pllreq(struct wlc_info *wlc, bool set, mbool req_bit);
 extern void wlc_reset_bmac_done(struct wlc_info *wlc);
-extern void wlc_hwtimer_gptimer_set(struct wlc_info *wlc, uint us);
-extern void wlc_hwtimer_gptimer_abort(struct wlc_info *wlc);
 
 #if defined(BCMDBG)
 extern void wlc_print_rxh(d11rxhdr_t *rxh);
@@ -860,7 +843,7 @@ extern void wlc_txflowcontrol_override(struct wlc_info *wlc,
                                       bool on, uint override);
 extern bool wlc_txflowcontrol_prio_isset(struct wlc_info *wlc,
                                         struct wlc_txq_info *qi, int prio);
-extern void wlc_send_q(struct wlc_info *wlc, struct wlc_txq_info *qi);
+extern void wlc_send_q(struct wlc_info *wlc);
 extern int wlc_prep_pdu(struct wlc_info *wlc, struct sk_buff *pdu, uint *fifo);
 
 extern u16 wlc_calc_lsig_len(struct wlc_info *wlc, ratespec_t ratespec,
@@ -883,21 +866,14 @@ extern void wlc_dump_ie(struct wlc_info *wlc, bcm_tlv_t *ie,
                        struct bcmstrbuf *b);
 #endif
 
-extern bool wlc_ps_check(struct wlc_info *wlc);
 extern void wlc_reprate_init(struct wlc_info *wlc);
 extern void wlc_bsscfg_reprate_init(struct wlc_bsscfg *bsscfg);
-extern void wlc_uint64_sub(u32 *a_high, u32 *a_low, u32 b_high,
-                          u32 b_low);
-extern u32 wlc_calc_tbtt_offset(u32 bi, u32 tsf_h, u32 tsf_l);
 
 /* Shared memory access */
 extern void wlc_write_shm(struct wlc_info *wlc, uint offset, u16 v);
 extern u16 wlc_read_shm(struct wlc_info *wlc, uint offset);
-extern void wlc_set_shm(struct wlc_info *wlc, uint offset, u16 v, int len);
 extern void wlc_copyto_shm(struct wlc_info *wlc, uint offset, const void *buf,
                           int len);
-extern void wlc_copyfrom_shm(struct wlc_info *wlc, uint offset, void *buf,
-                            int len);
 
 extern void wlc_update_beacon(struct wlc_info *wlc);
 extern void wlc_bss_update_beacon(struct wlc_info *wlc,
@@ -935,14 +911,13 @@ extern void wlc_print_ies(struct wlc_info *wlc, u8 *ies, uint ies_len);
 #endif
 
 extern int wlc_set_nmode(struct wlc_info *wlc, s32 nmode);
-extern void wlc_ht_mimops_cap_update(struct wlc_info *wlc, u8 mimops_mode);
 extern void wlc_mimops_action_ht_send(struct wlc_info *wlc,
                                      struct wlc_bsscfg *bsscfg,
                                      u8 mimops_mode);
 
 extern void wlc_switch_shortslot(struct wlc_info *wlc, bool shortslot);
 extern void wlc_set_bssid(struct wlc_bsscfg *cfg);
-extern void wlc_edcf_setparams(struct wlc_bsscfg *cfg, bool suspend);
+extern void wlc_edcf_setparams(struct wlc_info *wlc, bool suspend);
 
 extern void wlc_set_ratetable(struct wlc_info *wlc);
 extern int wlc_set_mac(struct wlc_bsscfg *cfg);
@@ -951,20 +926,14 @@ extern void wlc_beacon_phytxctl_txant_upd(struct wlc_info *wlc,
 extern void wlc_mod_prb_rsp_rate_table(struct wlc_info *wlc, uint frame_len);
 extern ratespec_t wlc_lowest_basic_rspec(struct wlc_info *wlc,
                                         wlc_rateset_t *rs);
-extern u16 wlc_compute_bcntsfoff(struct wlc_info *wlc, ratespec_t rspec,
-                                   bool short_preamble, bool phydelay);
 extern void wlc_radio_disable(struct wlc_info *wlc);
 extern void wlc_bcn_li_upd(struct wlc_info *wlc);
 
 extern int wlc_get_revision_info(struct wlc_info *wlc, void *buf, uint len);
-extern void wlc_out(struct wlc_info *wlc);
 extern void wlc_set_home_chanspec(struct wlc_info *wlc, chanspec_t chanspec);
 extern void wlc_watchdog_upd(struct wlc_info *wlc, bool tbtt);
 extern bool wlc_ps_allowed(struct wlc_info *wlc);
 extern bool wlc_stay_awake(struct wlc_info *wlc);
 extern void wlc_wme_initparams_sta(struct wlc_info *wlc, wme_param_ie_t *pe);
 
-extern void wlc_bss_list_free(struct wlc_info *wlc,
-                             struct wlc_bss_list *bss_list);
-extern void wlc_ht_mimops_cap_update(struct wlc_info *wlc, u8 mimops_mode);
 #endif                         /* _wlc_h_ */
index 96d36001f460622b1fe84bbfba0f16b24e639966..16fea021f4a5697e811b7e8fadca378f3dcee98a 100644 (file)
 #include <bcmdefs.h>
 #include <bcmutils.h>
 #include <bcmwifi.h>
-#include <siutils.h>
+#include <aiutils.h>
 #include <wlioctl.h>
 #include <sbconfig.h>
 #include <sbchipc.h>
 #include <pcicfg.h>
 #include <sbhnddma.h>
 #include <hnddma.h>
-#include <hndpmu.h>
+#include <wlc_pmu.h>
 
 #include "wlc_types.h"
 #include "wl_dbg.h"
@@ -68,8 +68,9 @@ wlc_phy_shim_info_t *wlc_phy_shim_attach(struct wlc_hw_info *wlc_hw,
 
        physhim = kzalloc(sizeof(wlc_phy_shim_info_t), GFP_ATOMIC);
        if (!physhim) {
-               WL_ERROR("wl%d: wlc_phy_shim_attach: out of mem\n",
-                        wlc_hw->unit);
+               wiphy_err(wlc_hw->wlc->wiphy,
+                         "wl%d: wlc_phy_shim_attach: out of mem\n",
+                         wlc_hw->unit);
                return NULL;
        }
        physhim->wlc_hw = wlc_hw;
similarity index 67%
rename from drivers/staging/brcm80211/util/hndpmu.c
rename to drivers/staging/brcm80211/brcmsmac/wlc_pmu.c
index 59e3ede89fe78d74daccb0d498b6bf444ce6c995..82986bd1ccfacd4aebd670e9a44e473b9c37294f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010 Broadcom Corporation
+ * Copyright (c) 2011 Broadcom Corporation
  *
  * Permission to use, copy, modify, and/or distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
-#include <linux/delay.h>
 #include <linux/kernel.h>
-#include <linux/string.h>
-#include <linux/module.h>
-#include <linux/pci.h>
-#include <bcmdefs.h>
-#include <bcmutils.h>
-#include <siutils.h>
+#include <linux/types.h>
+#include <linux/delay.h>
+#include <linux/io.h>
+
 #include <bcmdevs.h>
-#include <hndsoc.h>
 #include <sbchipc.h>
-#include <hndpmu.h>
-#include "siutils_priv.h"
-
-#define        PMU_ERROR(args)
-
-#ifdef BCMDBG
-#define        PMU_MSG(args)   printk args
-
-/* debug-only definitions */
-/* #define BCMDBG_FORCEHT */
-/* #define CHIPC_UART_ALWAYS_ON */
-#else
-#define        PMU_MSG(args)
-#endif                         /* BCMDBG */
+#include <bcmutils.h>
+#include <bcmnvram.h>
+#include "wlc_pmu.h"
 
-/* To check in verbose debugging messages not intended
- * to be on except on private builds.
+/*
+ * d11 slow to fast clock transition time in slow clock cycles
  */
-#define        PMU_NONE(args)
-
-/* PLL controls/clocks */
-static void si_pmu1_pllinit0(si_t *sih, chipcregs_t *cc, u32 xtal);
-static u32 si_pmu1_cpuclk0(si_t *sih, chipcregs_t *cc);
-static u32 si_pmu1_alpclk0(si_t *sih, chipcregs_t *cc);
+#define D11SCC_SLOW2FAST_TRANSITION    2
 
-/* PMU resources */
-static bool si_pmu_res_depfltr_bb(si_t *sih);
-static bool si_pmu_res_depfltr_ncb(si_t *sih);
-static bool si_pmu_res_depfltr_paldo(si_t *sih);
-static bool si_pmu_res_depfltr_npaldo(si_t *sih);
-static u32 si_pmu_res_deps(si_t *sih, chipcregs_t *cc, u32 rsrcs, bool all);
-static uint si_pmu_res_uptime(si_t *sih, chipcregs_t *cc, u8 rsrc);
-static void si_pmu_res_masks(si_t *sih, u32 * pmin, u32 * pmax);
-static void si_pmu_spuravoid_pllupdate(si_t *sih, chipcregs_t *cc,
-                                      u8 spuravoid);
+/*
+ * external LPO crystal frequency
+ */
+#define EXT_ILP_HZ 32768
 
-static void si_pmu_set_4330_plldivs(si_t *sih);
+/*
+ * Duration for ILP clock frequency measurment in milliseconds
+ *
+ * remark: 1000 must be an integer multiple of this duration
+ */
+#define ILP_CALC_DUR   10
 
-/* FVCO frequency */
+/*
+ * FVCO frequency
+ */
 #define FVCO_880       880000  /* 880MHz */
 #define FVCO_1760      1760000 /* 1760MHz */
 #define FVCO_1440      1440000 /* 1440MHz */
 #define FVCO_960       960000  /* 960MHz */
 
-/* Read/write a chipcontrol reg */
-u32 si_pmu_chipcontrol(si_t *sih, uint reg, u32 mask, u32 val)
-{
-       si_corereg(sih, SI_CC_IDX, offsetof(chipcregs_t, chipcontrol_addr), ~0,
-                  reg);
-       return si_corereg(sih, SI_CC_IDX,
-                         offsetof(chipcregs_t, chipcontrol_data), mask, val);
-}
-
-/* Read/write a regcontrol reg */
-u32 si_pmu_regcontrol(si_t *sih, uint reg, u32 mask, u32 val)
-{
-       si_corereg(sih, SI_CC_IDX, offsetof(chipcregs_t, regcontrol_addr), ~0,
-                  reg);
-       return si_corereg(sih, SI_CC_IDX,
-                         offsetof(chipcregs_t, regcontrol_data), mask, val);
-}
-
-/* Read/write a pllcontrol reg */
-u32 si_pmu_pllcontrol(si_t *sih, uint reg, u32 mask, u32 val)
-{
-       si_corereg(sih, SI_CC_IDX, offsetof(chipcregs_t, pllcontrol_addr), ~0,
-                  reg);
-       return si_corereg(sih, SI_CC_IDX,
-                         offsetof(chipcregs_t, pllcontrol_data), mask, val);
-}
-
-/* PMU PLL update */
-void si_pmu_pllupd(si_t *sih)
-{
-       si_corereg(sih, SI_CC_IDX, offsetof(chipcregs_t, pmucontrol),
-                  PCTL_PLL_PLLCTL_UPD, PCTL_PLL_PLLCTL_UPD);
-}
-
-/* Setup switcher voltage */
-void si_pmu_set_switcher_voltage(si_t *sih, u8 bb_voltage, u8 rf_voltage)
-{
-       chipcregs_t *cc;
-       uint origidx;
-
-       ASSERT(sih->cccaps & CC_CAP_PMU);
-
-       /* Remember original core before switch to chipc */
-       origidx = si_coreidx(sih);
-       cc = si_setcoreidx(sih, SI_CC_IDX);
-       ASSERT(cc != NULL);
-
-       W_REG(&cc->regcontrol_addr, 0x01);
-       W_REG(&cc->regcontrol_data, (u32) (bb_voltage & 0x1f) << 22);
-
-       W_REG(&cc->regcontrol_addr, 0x00);
-       W_REG(&cc->regcontrol_data, (u32) (rf_voltage & 0x1f) << 14);
-
-       /* Return to original core */
-       si_setcoreidx(sih, origidx);
-}
-
-void si_pmu_set_ldo_voltage(si_t *sih, u8 ldo, u8 voltage)
-{
-       u8 sr_cntl_shift = 0, rc_shift = 0, shift = 0, mask = 0;
-       u8 addr = 0;
+/*
+ * PMU crystal table indices for 1440MHz fvco
+ */
+#define PMU1_XTALTAB0_1440_12000K      0
+#define PMU1_XTALTAB0_1440_13000K      1
+#define PMU1_XTALTAB0_1440_14400K      2
+#define PMU1_XTALTAB0_1440_15360K      3
+#define PMU1_XTALTAB0_1440_16200K      4
+#define PMU1_XTALTAB0_1440_16800K      5
+#define PMU1_XTALTAB0_1440_19200K      6
+#define PMU1_XTALTAB0_1440_19800K      7
+#define PMU1_XTALTAB0_1440_20000K      8
+#define PMU1_XTALTAB0_1440_25000K      9
+#define PMU1_XTALTAB0_1440_26000K      10
+#define PMU1_XTALTAB0_1440_30000K      11
+#define PMU1_XTALTAB0_1440_37400K      12
+#define PMU1_XTALTAB0_1440_38400K      13
+#define PMU1_XTALTAB0_1440_40000K      14
+#define PMU1_XTALTAB0_1440_48000K      15
 
-       ASSERT(sih->cccaps & CC_CAP_PMU);
+/*
+ * PMU crystal table indices for 960MHz fvco
+ */
+#define PMU1_XTALTAB0_960_12000K       0
+#define PMU1_XTALTAB0_960_13000K       1
+#define PMU1_XTALTAB0_960_14400K       2
+#define PMU1_XTALTAB0_960_15360K       3
+#define PMU1_XTALTAB0_960_16200K       4
+#define PMU1_XTALTAB0_960_16800K       5
+#define PMU1_XTALTAB0_960_19200K       6
+#define PMU1_XTALTAB0_960_19800K       7
+#define PMU1_XTALTAB0_960_20000K       8
+#define PMU1_XTALTAB0_960_25000K       9
+#define PMU1_XTALTAB0_960_26000K       10
+#define PMU1_XTALTAB0_960_30000K       11
+#define PMU1_XTALTAB0_960_37400K       12
+#define PMU1_XTALTAB0_960_38400K       13
+#define PMU1_XTALTAB0_960_40000K       14
+#define PMU1_XTALTAB0_960_48000K       15
 
-       switch (sih->chip) {
-       case BCM4336_CHIP_ID:
-               switch (ldo) {
-               case SET_LDO_VOLTAGE_CLDO_PWM:
-                       addr = 4;
-                       rc_shift = 1;
-                       mask = 0xf;
-                       break;
-               case SET_LDO_VOLTAGE_CLDO_BURST:
-                       addr = 4;
-                       rc_shift = 5;
-                       mask = 0xf;
-                       break;
-               case SET_LDO_VOLTAGE_LNLDO1:
-                       addr = 4;
-                       rc_shift = 17;
-                       mask = 0xf;
-                       break;
-               default:
-                       ASSERT(false);
-                       return;
-               }
-               break;
-       case BCM4330_CHIP_ID:
-               switch (ldo) {
-               case SET_LDO_VOLTAGE_CBUCK_PWM:
-                       addr = 3;
-                       rc_shift = 0;
-                       mask = 0x1f;
-                       break;
-               default:
-                       ASSERT(false);
-                       break;
-               }
-               break;
-       default:
-               ASSERT(false);
-               return;
-       }
+/*
+ * PMU crystal table indices for 880MHz fvco
+ */
+#define PMU1_XTALTAB0_880_12000K       0
+#define PMU1_XTALTAB0_880_13000K       1
+#define PMU1_XTALTAB0_880_14400K       2
+#define PMU1_XTALTAB0_880_15360K       3
+#define PMU1_XTALTAB0_880_16200K       4
+#define PMU1_XTALTAB0_880_16800K       5
+#define PMU1_XTALTAB0_880_19200K       6
+#define PMU1_XTALTAB0_880_19800K       7
+#define PMU1_XTALTAB0_880_20000K       8
+#define PMU1_XTALTAB0_880_24000K       9
+#define PMU1_XTALTAB0_880_25000K       10
+#define PMU1_XTALTAB0_880_26000K       11
+#define PMU1_XTALTAB0_880_30000K       12
+#define PMU1_XTALTAB0_880_37400K       13
+#define PMU1_XTALTAB0_880_38400K       14
+#define PMU1_XTALTAB0_880_40000K       15
 
-       shift = sr_cntl_shift + rc_shift;
+/*
+ * crystal frequency values
+ */
+#define XTAL_FREQ_24000MHZ             24000
+#define XTAL_FREQ_30000MHZ             30000
+#define XTAL_FREQ_37400MHZ             37400
+#define XTAL_FREQ_48000MHZ             48000
 
-       si_corereg(sih, SI_CC_IDX, offsetof(chipcregs_t, regcontrol_addr),
-                  ~0, addr);
-       si_corereg(sih, SI_CC_IDX, offsetof(chipcregs_t, regcontrol_data),
-                  mask << shift, (voltage & mask) << shift);
-}
+/*
+ * Resource dependancies mask change action
+ *
+ * @RES_DEPEND_SET: Override the dependancies mask
+ * @RES_DEPEND_ADD: Add to the  dependancies mask
+ * @RES_DEPEND_REMOVE: Remove from the dependancies mask
+ */
+#define RES_DEPEND_SET         0
+#define RES_DEPEND_ADD         1
+#define RES_DEPEND_REMOVE      -1
 
 /* d11 slow to fast clock transition time in slow clock cycles */
 #define D11SCC_SLOW2FAST_TRANSITION    2
 
-u16 si_pmu_fast_pwrup_delay(si_t *sih)
-{
-       uint delay = PMU_MAX_TRANSITION_DLY;
-       chipcregs_t *cc;
-       uint origidx;
-#ifdef BCMDBG
-       char chn[8];
-       chn[0] = 0;             /* to suppress compile error */
-#endif
-
-       ASSERT(sih->cccaps & CC_CAP_PMU);
-
-       /* Remember original core before switch to chipc */
-       origidx = si_coreidx(sih);
-       cc = si_setcoreidx(sih, SI_CC_IDX);
-       ASSERT(cc != NULL);
-
-       switch (sih->chip) {
-       case BCM43224_CHIP_ID:
-       case BCM43225_CHIP_ID:
-       case BCM43421_CHIP_ID:
-       case BCM43235_CHIP_ID:
-       case BCM43236_CHIP_ID:
-       case BCM43238_CHIP_ID:
-       case BCM4331_CHIP_ID:
-       case BCM6362_CHIP_ID:
-       case BCM4313_CHIP_ID:
-               delay = ISSIM_ENAB(sih) ? 70 : 3700;
-               break;
-       case BCM4329_CHIP_ID:
-               if (ISSIM_ENAB(sih))
-                       delay = 70;
-               else {
-                       u32 ilp = si_ilp_clock(sih);
-                       delay =
-                           (si_pmu_res_uptime(sih, cc, RES4329_HT_AVAIL) +
-                            D11SCC_SLOW2FAST_TRANSITION) * ((1000000 + ilp -
-                                                             1) / ilp);
-                       delay = (11 * delay) / 10;
-               }
-               break;
-       case BCM4319_CHIP_ID:
-               delay = ISSIM_ENAB(sih) ? 70 : 3700;
-               break;
-       case BCM4336_CHIP_ID:
-               if (ISSIM_ENAB(sih))
-                       delay = 70;
-               else {
-                       u32 ilp = si_ilp_clock(sih);
-                       delay =
-                           (si_pmu_res_uptime(sih, cc, RES4336_HT_AVAIL) +
-                            D11SCC_SLOW2FAST_TRANSITION) * ((1000000 + ilp -
-                                                             1) / ilp);
-                       delay = (11 * delay) / 10;
-               }
-               break;
-       case BCM4330_CHIP_ID:
-               if (ISSIM_ENAB(sih))
-                       delay = 70;
-               else {
-                       u32 ilp = si_ilp_clock(sih);
-                       delay =
-                           (si_pmu_res_uptime(sih, cc, RES4330_HT_AVAIL) +
-                            D11SCC_SLOW2FAST_TRANSITION) * ((1000000 + ilp -
-                                                             1) / ilp);
-                       delay = (11 * delay) / 10;
-               }
-               break;
-       default:
-               break;
-       }
-       /* Return to original core */
-       si_setcoreidx(sih, origidx);
-
-       return (u16) delay;
-}
-
-u32 si_pmu_force_ilp(si_t *sih, bool force)
-{
-       chipcregs_t *cc;
-       uint origidx;
-       u32 oldpmucontrol;
-
-       ASSERT(sih->cccaps & CC_CAP_PMU);
-
-       /* Remember original core before switch to chipc */
-       origidx = si_coreidx(sih);
-       cc = si_setcoreidx(sih, SI_CC_IDX);
-       ASSERT(cc != NULL);
-
-       oldpmucontrol = R_REG(&cc->pmucontrol);
-       if (force)
-               W_REG(&cc->pmucontrol, oldpmucontrol &
-                     ~(PCTL_HT_REQ_EN | PCTL_ALP_REQ_EN));
-       else
-               W_REG(&cc->pmucontrol, oldpmucontrol |
-                     (PCTL_HT_REQ_EN | PCTL_ALP_REQ_EN));
-
-       /* Return to original core */
-       si_setcoreidx(sih, origidx);
-
-       return oldpmucontrol;
-}
-
 /* Setup resource up/down timers */
 typedef struct {
        u8 resnum;
@@ -301,15 +145,28 @@ typedef struct {
         bool(*filter) (si_t *sih);     /* action is taken when filter is NULL or return true */
 } pmu_res_depend_t;
 
-/* Resource dependancies mask change action */
-#define RES_DEPEND_SET         0       /* Override the dependancies mask */
-#define RES_DEPEND_ADD         1       /* Add to the  dependancies mask */
-#define RES_DEPEND_REMOVE      -1      /* Remove from the dependancies mask */
-
-static const pmu_res_updown_t bcm4328a0_res_updown[] = {
-       {
-       RES4328_EXT_SWITCHER_PWM, 0x0101}, {
-       RES4328_BB_SWITCHER_PWM, 0x1f01}, {
+/* setup pll and query clock speed */
+typedef struct {
+       u16 fref;
+       u8 xf;
+       u8 p1div;
+       u8 p2div;
+       u8 ndiv_int;
+       u32 ndiv_frac;
+} pmu1_xtaltab0_t;
+
+/*
+ * prototypes used in resource tables
+ */
+static bool si_pmu_res_depfltr_bb(si_t *sih);
+static bool si_pmu_res_depfltr_ncb(si_t *sih);
+static bool si_pmu_res_depfltr_paldo(si_t *sih);
+static bool si_pmu_res_depfltr_npaldo(si_t *sih);
+
+static const pmu_res_updown_t bcm4328a0_res_updown[] = {
+       {
+       RES4328_EXT_SWITCHER_PWM, 0x0101}, {
+       RES4328_BB_SWITCHER_PWM, 0x1f01}, {
        RES4328_BB_SWITCHER_BURST, 0x010f}, {
        RES4328_BB_EXT_SWITCHER_BURST, 0x0101}, {
        RES4328_ILP_REQUEST, 0x0202}, {
@@ -561,6 +418,92 @@ static const pmu_res_depend_t bcm4330a0_res_depend[] = {
        PMURES_BIT(RES4330_HT_AVAIL), RES_DEPEND_ADD, 0, NULL}
 };
 
+/* the following table is based on 1440Mhz fvco */
+static const pmu1_xtaltab0_t pmu1_xtaltab0_1440[] = {
+       {
+       12000, 1, 1, 1, 0x78, 0x0}, {
+       13000, 2, 1, 1, 0x6E, 0xC4EC4E}, {
+       14400, 3, 1, 1, 0x64, 0x0}, {
+       15360, 4, 1, 1, 0x5D, 0xC00000}, {
+       16200, 5, 1, 1, 0x58, 0xE38E38}, {
+       16800, 6, 1, 1, 0x55, 0xB6DB6D}, {
+       19200, 7, 1, 1, 0x4B, 0}, {
+       19800, 8, 1, 1, 0x48, 0xBA2E8B}, {
+       20000, 9, 1, 1, 0x48, 0x0}, {
+       25000, 10, 1, 1, 0x39, 0x999999}, {
+       26000, 11, 1, 1, 0x37, 0x627627}, {
+       30000, 12, 1, 1, 0x30, 0x0}, {
+       37400, 13, 2, 1, 0x4D, 0x15E76}, {
+       38400, 13, 2, 1, 0x4B, 0x0}, {
+       40000, 14, 2, 1, 0x48, 0x0}, {
+       48000, 15, 2, 1, 0x3c, 0x0}, {
+       0, 0, 0, 0, 0, 0}
+};
+
+static const pmu1_xtaltab0_t pmu1_xtaltab0_960[] = {
+       {
+       12000, 1, 1, 1, 0x50, 0x0}, {
+       13000, 2, 1, 1, 0x49, 0xD89D89}, {
+       14400, 3, 1, 1, 0x42, 0xAAAAAA}, {
+       15360, 4, 1, 1, 0x3E, 0x800000}, {
+       16200, 5, 1, 1, 0x39, 0x425ED0}, {
+       16800, 6, 1, 1, 0x39, 0x249249}, {
+       19200, 7, 1, 1, 0x32, 0x0}, {
+       19800, 8, 1, 1, 0x30, 0x7C1F07}, {
+       20000, 9, 1, 1, 0x30, 0x0}, {
+       25000, 10, 1, 1, 0x26, 0x666666}, {
+       26000, 11, 1, 1, 0x24, 0xEC4EC4}, {
+       30000, 12, 1, 1, 0x20, 0x0}, {
+       37400, 13, 2, 1, 0x33, 0x563EF9}, {
+       38400, 14, 2, 1, 0x32, 0x0}, {
+       40000, 15, 2, 1, 0x30, 0x0}, {
+       48000, 16, 2, 1, 0x28, 0x0}, {
+       0, 0, 0, 0, 0, 0}
+};
+
+static const pmu1_xtaltab0_t pmu1_xtaltab0_880_4329[] = {
+       {
+       12000, 1, 3, 22, 0x9, 0xFFFFEF}, {
+       13000, 2, 1, 6, 0xb, 0x483483}, {
+       14400, 3, 1, 10, 0xa, 0x1C71C7}, {
+       15360, 4, 1, 5, 0xb, 0x755555}, {
+       16200, 5, 1, 10, 0x5, 0x6E9E06}, {
+       16800, 6, 1, 10, 0x5, 0x3Cf3Cf}, {
+       19200, 7, 1, 4, 0xb, 0x755555}, {
+       19800, 8, 1, 11, 0x4, 0xA57EB}, {
+       20000, 9, 1, 11, 0x4, 0x0}, {
+       24000, 10, 3, 11, 0xa, 0x0}, {
+       25000, 11, 5, 16, 0xb, 0x0}, {
+       26000, 12, 1, 1, 0x21, 0xD89D89}, {
+       30000, 13, 3, 8, 0xb, 0x0}, {
+       37400, 14, 3, 1, 0x46, 0x969696}, {
+       38400, 15, 1, 1, 0x16, 0xEAAAAA}, {
+       40000, 16, 1, 2, 0xb, 0}, {
+       0, 0, 0, 0, 0, 0}
+};
+
+/* the following table is based on 880Mhz fvco */
+static const pmu1_xtaltab0_t pmu1_xtaltab0_880[] = {
+       {
+       12000, 1, 3, 22, 0x9, 0xFFFFEF}, {
+       13000, 2, 1, 6, 0xb, 0x483483}, {
+       14400, 3, 1, 10, 0xa, 0x1C71C7}, {
+       15360, 4, 1, 5, 0xb, 0x755555}, {
+       16200, 5, 1, 10, 0x5, 0x6E9E06}, {
+       16800, 6, 1, 10, 0x5, 0x3Cf3Cf}, {
+       19200, 7, 1, 4, 0xb, 0x755555}, {
+       19800, 8, 1, 11, 0x4, 0xA57EB}, {
+       20000, 9, 1, 11, 0x4, 0x0}, {
+       24000, 10, 3, 11, 0xa, 0x0}, {
+       25000, 11, 5, 16, 0xb, 0x0}, {
+       26000, 12, 1, 2, 0x10, 0xEC4EC4}, {
+       30000, 13, 3, 8, 0xb, 0x0}, {
+       33600, 14, 1, 2, 0xd, 0x186186}, {
+       38400, 15, 1, 2, 0xb, 0x755555}, {
+       40000, 16, 1, 2, 0xb, 0}, {
+       0, 0, 0, 0, 0, 0}
+};
+
 /* true if the power topology uses the buck boost to provide 3.3V to VDDIO_RF and WLAN PA */
 static bool si_pmu_res_depfltr_bb(si_t *sih)
 {
@@ -586,8 +529,26 @@ static bool si_pmu_res_depfltr_npaldo(si_t *sih)
        return (sih->boardflags & BFL_PALDO) == 0;
 }
 
-#define BCM94325_BBVDDIOSD_BOARDS(sih) (sih->boardtype == BCM94325DEVBU_BOARD || \
-                                       sih->boardtype == BCM94325BGABU_BOARD)
+/* Return dependancies (direct or all/indirect) for the given resources */
+static u32
+si_pmu_res_deps(si_t *sih, chipcregs_t *cc, u32 rsrcs,
+               bool all)
+{
+       u32 deps = 0;
+       u32 i;
+
+       for (i = 0; i <= PMURES_MAX_RESNUM; i++) {
+               if (!(rsrcs & PMURES_BIT(i)))
+                       continue;
+               W_REG(&cc->res_table_sel, i);
+               deps |= R_REG(&cc->res_dep_mask);
+       }
+
+       return !all ? deps : (deps
+                             ? (deps |
+                                si_pmu_res_deps(sih, cc, deps,
+                                                true)) : 0);
+}
 
 /* Determine min/max rsrc masks. Value 0 leaves hardware at default. */
 static void si_pmu_res_masks(si_t *sih, u32 * pmin, u32 * pmax)
@@ -663,13 +624,11 @@ static void si_pmu_res_masks(si_t *sih, u32 * pmin, u32 * pmax)
        /* Apply nvram override to min mask */
        val = getvar(NULL, "rmin");
        if (val != NULL) {
-               PMU_MSG(("Applying rmin=%s to min_mask\n", val));
                min_mask = (u32) simple_strtoul(val, NULL, 0);
        }
        /* Apply nvram override to max mask */
        val = getvar(NULL, "rmax");
        if (val != NULL) {
-               PMU_MSG(("Applying rmax=%s to max_mask\n", val));
                max_mask = (u32) simple_strtoul(val, NULL, 0);
        }
 
@@ -677,1535 +636,823 @@ static void si_pmu_res_masks(si_t *sih, u32 * pmin, u32 * pmax)
        *pmax = max_mask;
 }
 
-/* initialize PMU resources */
-void si_pmu_res_init(si_t *sih)
-{
-       chipcregs_t *cc;
-       uint origidx;
-       const pmu_res_updown_t *pmu_res_updown_table = NULL;
-       uint pmu_res_updown_table_sz = 0;
-       const pmu_res_depend_t *pmu_res_depend_table = NULL;
-       uint pmu_res_depend_table_sz = 0;
+/* Return up time in ILP cycles for the given resource. */
+static uint
+si_pmu_res_uptime(si_t *sih, chipcregs_t *cc, u8 rsrc) {
+       u32 deps;
+       uint up, i, dup, dmax;
        u32 min_mask = 0, max_mask = 0;
-       char name[8], *val;
-       uint i, rsrcs;
 
-       ASSERT(sih->cccaps & CC_CAP_PMU);
+       /* uptime of resource 'rsrc' */
+       W_REG(&cc->res_table_sel, rsrc);
+       up = (R_REG(&cc->res_updn_timer) >> 8) & 0xff;
+
+       /* direct dependancies of resource 'rsrc' */
+       deps = si_pmu_res_deps(sih, cc, PMURES_BIT(rsrc), false);
+       for (i = 0; i <= PMURES_MAX_RESNUM; i++) {
+               if (!(deps & PMURES_BIT(i)))
+                       continue;
+               deps &= ~si_pmu_res_deps(sih, cc, PMURES_BIT(i), true);
+       }
+       si_pmu_res_masks(sih, &min_mask, &max_mask);
+       deps &= ~min_mask;
 
-       /* Remember original core before switch to chipc */
-       origidx = si_coreidx(sih);
-       cc = si_setcoreidx(sih, SI_CC_IDX);
-       ASSERT(cc != NULL);
+       /* max uptime of direct dependancies */
+       dmax = 0;
+       for (i = 0; i <= PMURES_MAX_RESNUM; i++) {
+               if (!(deps & PMURES_BIT(i)))
+                       continue;
+               dup = si_pmu_res_uptime(sih, cc, (u8) i);
+               if (dmax < dup)
+                       dmax = dup;
+       }
+
+       return up + dmax + PMURES_UP_TRANSITION;
+}
+
+static void
+si_pmu_spuravoid_pllupdate(si_t *sih, chipcregs_t *cc, u8 spuravoid)
+{
+       u32 tmp = 0;
+       u8 phypll_offset = 0;
+       u8 bcm5357_bcm43236_p1div[] = { 0x1, 0x5, 0x5 };
+       u8 bcm5357_bcm43236_ndiv[] = { 0x30, 0xf6, 0xfc };
 
        switch (sih->chip) {
-       case BCM4329_CHIP_ID:
-               /* Optimize resources up/down timers */
-               if (ISSIM_ENAB(sih)) {
-                       pmu_res_updown_table = NULL;
-                       pmu_res_updown_table_sz = 0;
-               } else {
-                       pmu_res_updown_table = bcm4329_res_updown;
-                       pmu_res_updown_table_sz = ARRAY_SIZE(bcm4329_res_updown);
-               }
-               /* Optimize resources dependencies */
-               pmu_res_depend_table = bcm4329_res_depend;
-               pmu_res_depend_table_sz = ARRAY_SIZE(bcm4329_res_depend);
+       case BCM5357_CHIP_ID:
+       case BCM43235_CHIP_ID:
+       case BCM43236_CHIP_ID:
+       case BCM43238_CHIP_ID:
+
+               /*
+                * BCM5357 needs to touch PLL1_PLLCTL[02],
+                * so offset PLL0_PLLCTL[02] by 6
+                */
+               phypll_offset = (sih->chip == BCM5357_CHIP_ID) ? 6 : 0;
+
+               /* RMW only the P1 divider */
+               W_REG(&cc->pllcontrol_addr,
+                     PMU1_PLL0_PLLCTL0 + phypll_offset);
+               tmp = R_REG(&cc->pllcontrol_data);
+               tmp &= (~(PMU1_PLL0_PC0_P1DIV_MASK));
+               tmp |=
+                   (bcm5357_bcm43236_p1div[spuravoid] <<
+                    PMU1_PLL0_PC0_P1DIV_SHIFT);
+               W_REG(&cc->pllcontrol_data, tmp);
+
+               /* RMW only the int feedback divider */
+               W_REG(&cc->pllcontrol_addr,
+                     PMU1_PLL0_PLLCTL2 + phypll_offset);
+               tmp = R_REG(&cc->pllcontrol_data);
+               tmp &= ~(PMU1_PLL0_PC2_NDIV_INT_MASK);
+               tmp |=
+                   (bcm5357_bcm43236_ndiv[spuravoid]) <<
+                   PMU1_PLL0_PC2_NDIV_INT_SHIFT;
+               W_REG(&cc->pllcontrol_data, tmp);
+
+               tmp = 1 << 10;
                break;
 
-       case BCM4319_CHIP_ID:
-               /* Optimize resources up/down timers */
-               if (ISSIM_ENAB(sih)) {
-                       pmu_res_updown_table = bcm4319a0_res_updown_qt;
-                       pmu_res_updown_table_sz =
-                           ARRAY_SIZE(bcm4319a0_res_updown_qt);
+       case BCM4331_CHIP_ID:
+               if (spuravoid == 2) {
+                       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0);
+                       W_REG(&cc->pllcontrol_data, 0x11500014);
+                       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2);
+                       W_REG(&cc->pllcontrol_data, 0x0FC00a08);
+               } else if (spuravoid == 1) {
+                       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0);
+                       W_REG(&cc->pllcontrol_data, 0x11500014);
+                       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2);
+                       W_REG(&cc->pllcontrol_data, 0x0F600a08);
                } else {
-                       pmu_res_updown_table = bcm4319a0_res_updown;
-                       pmu_res_updown_table_sz =
-                           ARRAY_SIZE(bcm4319a0_res_updown);
+                       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0);
+                       W_REG(&cc->pllcontrol_data, 0x11100014);
+                       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2);
+                       W_REG(&cc->pllcontrol_data, 0x03000a08);
                }
-               /* Optimize resources dependancies masks */
-               pmu_res_depend_table = bcm4319a0_res_depend;
-               pmu_res_depend_table_sz = ARRAY_SIZE(bcm4319a0_res_depend);
+               tmp = 1 << 10;
                break;
 
-       case BCM4336_CHIP_ID:
-               /* Optimize resources up/down timers */
-               if (ISSIM_ENAB(sih)) {
-                       pmu_res_updown_table = bcm4336a0_res_updown_qt;
-                       pmu_res_updown_table_sz =
-                           ARRAY_SIZE(bcm4336a0_res_updown_qt);
-               } else {
-                       pmu_res_updown_table = bcm4336a0_res_updown;
-                       pmu_res_updown_table_sz =
-                           ARRAY_SIZE(bcm4336a0_res_updown);
-               }
-               /* Optimize resources dependancies masks */
-               pmu_res_depend_table = bcm4336a0_res_depend;
-               pmu_res_depend_table_sz = ARRAY_SIZE(bcm4336a0_res_depend);
-               break;
-
-       case BCM4330_CHIP_ID:
-               /* Optimize resources up/down timers */
-               if (ISSIM_ENAB(sih)) {
-                       pmu_res_updown_table = bcm4330a0_res_updown_qt;
-                       pmu_res_updown_table_sz =
-                           ARRAY_SIZE(bcm4330a0_res_updown_qt);
+       case BCM43224_CHIP_ID:
+       case BCM43225_CHIP_ID:
+       case BCM43421_CHIP_ID:
+       case BCM6362_CHIP_ID:
+               if (spuravoid == 1) {
+                       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0);
+                       W_REG(&cc->pllcontrol_data, 0x11500010);
+                       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL1);
+                       W_REG(&cc->pllcontrol_data, 0x000C0C06);
+                       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2);
+                       W_REG(&cc->pllcontrol_data, 0x0F600a08);
+                       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL3);
+                       W_REG(&cc->pllcontrol_data, 0x00000000);
+                       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL4);
+                       W_REG(&cc->pllcontrol_data, 0x2001E920);
+                       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL5);
+                       W_REG(&cc->pllcontrol_data, 0x88888815);
                } else {
-                       pmu_res_updown_table = bcm4330a0_res_updown;
-                       pmu_res_updown_table_sz =
-                           ARRAY_SIZE(bcm4330a0_res_updown);
-               }
-               /* Optimize resources dependancies masks */
-               pmu_res_depend_table = bcm4330a0_res_depend;
-               pmu_res_depend_table_sz = ARRAY_SIZE(bcm4330a0_res_depend);
-               break;
-
-       default:
-               break;
-       }
-
-       /* # resources */
-       rsrcs = (sih->pmucaps & PCAP_RC_MASK) >> PCAP_RC_SHIFT;
-
-       /* Program up/down timers */
-       while (pmu_res_updown_table_sz--) {
-               ASSERT(pmu_res_updown_table != NULL);
-               PMU_MSG(("Changing rsrc %d res_updn_timer to 0x%x\n",
-                        pmu_res_updown_table[pmu_res_updown_table_sz].resnum,
-                        pmu_res_updown_table[pmu_res_updown_table_sz].updown));
-               W_REG(&cc->res_table_sel,
-                     pmu_res_updown_table[pmu_res_updown_table_sz].resnum);
-               W_REG(&cc->res_updn_timer,
-                     pmu_res_updown_table[pmu_res_updown_table_sz].updown);
-       }
-       /* Apply nvram overrides to up/down timers */
-       for (i = 0; i < rsrcs; i++) {
-               snprintf(name, sizeof(name), "r%dt", i);
-               val = getvar(NULL, name);
-               if (val == NULL)
-                       continue;
-               PMU_MSG(("Applying %s=%s to rsrc %d res_updn_timer\n", name,
-                        val, i));
-               W_REG(&cc->res_table_sel, (u32) i);
-               W_REG(&cc->res_updn_timer,
-                     (u32) simple_strtoul(val, NULL, 0));
-       }
-
-       /* Program resource dependencies table */
-       while (pmu_res_depend_table_sz--) {
-               ASSERT(pmu_res_depend_table != NULL);
-               if (pmu_res_depend_table[pmu_res_depend_table_sz].filter != NULL
-                   && !(pmu_res_depend_table[pmu_res_depend_table_sz].
-                        filter) (sih))
-                       continue;
-               for (i = 0; i < rsrcs; i++) {
-                       if ((pmu_res_depend_table[pmu_res_depend_table_sz].
-                            res_mask & PMURES_BIT(i)) == 0)
-                               continue;
-                       W_REG(&cc->res_table_sel, i);
-                       switch (pmu_res_depend_table[pmu_res_depend_table_sz].
-                               action) {
-                       case RES_DEPEND_SET:
-                               PMU_MSG(("Changing rsrc %d res_dep_mask to 0x%x\n", i, pmu_res_depend_table[pmu_res_depend_table_sz].depend_mask));
-                               W_REG(&cc->res_dep_mask,
-                                     pmu_res_depend_table
-                                     [pmu_res_depend_table_sz].depend_mask);
-                               break;
-                       case RES_DEPEND_ADD:
-                               PMU_MSG(("Adding 0x%x to rsrc %d res_dep_mask\n", pmu_res_depend_table[pmu_res_depend_table_sz].depend_mask, i));
-                               OR_REG(&cc->res_dep_mask,
-                                      pmu_res_depend_table
-                                      [pmu_res_depend_table_sz].depend_mask);
-                               break;
-                       case RES_DEPEND_REMOVE:
-                               PMU_MSG(("Removing 0x%x from rsrc %d res_dep_mask\n", pmu_res_depend_table[pmu_res_depend_table_sz].depend_mask, i));
-                               AND_REG(&cc->res_dep_mask,
-                                       ~pmu_res_depend_table
-                                       [pmu_res_depend_table_sz].depend_mask);
-                               break;
-                       default:
-                               ASSERT(0);
-                               break;
-                       }
-               }
-       }
-       /* Apply nvram overrides to dependancies masks */
-       for (i = 0; i < rsrcs; i++) {
-               snprintf(name, sizeof(name), "r%dd", i);
-               val = getvar(NULL, name);
-               if (val == NULL)
-                       continue;
-               PMU_MSG(("Applying %s=%s to rsrc %d res_dep_mask\n", name, val,
-                        i));
-               W_REG(&cc->res_table_sel, (u32) i);
-               W_REG(&cc->res_dep_mask,
-                     (u32) simple_strtoul(val, NULL, 0));
-       }
-
-       /* Determine min/max rsrc masks */
-       si_pmu_res_masks(sih, &min_mask, &max_mask);
-
-       /* It is required to program max_mask first and then min_mask */
-
-       /* Program max resource mask */
-
-       if (max_mask) {
-               PMU_MSG(("Changing max_res_mask to 0x%x\n", max_mask));
-               W_REG(&cc->max_res_mask, max_mask);
-       }
-
-       /* Program min resource mask */
-
-       if (min_mask) {
-               PMU_MSG(("Changing min_res_mask to 0x%x\n", min_mask));
-               W_REG(&cc->min_res_mask, min_mask);
-       }
-
-       /* Add some delay; allow resources to come up and settle. */
-       mdelay(2);
-
-       /* Return to original core */
-       si_setcoreidx(sih, origidx);
-}
-
-/* setup pll and query clock speed */
-typedef struct {
-       u16 freq;
-       u8 xf;
-       u8 wbint;
-       u32 wbfrac;
-} pmu0_xtaltab0_t;
-
-/* the following table is based on 880Mhz fvco */
-static const pmu0_xtaltab0_t pmu0_xtaltab0[] = {
-       {
-       12000, 1, 73, 349525}, {
-       13000, 2, 67, 725937}, {
-       14400, 3, 61, 116508}, {
-       15360, 4, 57, 305834}, {
-       16200, 5, 54, 336579}, {
-       16800, 6, 52, 399457}, {
-       19200, 7, 45, 873813}, {
-       19800, 8, 44, 466033}, {
-       20000, 9, 44, 0}, {
-       25000, 10, 70, 419430}, {
-       26000, 11, 67, 725937}, {
-       30000, 12, 58, 699050}, {
-       38400, 13, 45, 873813}, {
-       40000, 14, 45, 0}, {
-       0, 0, 0, 0}
-};
-
-#define PMU0_XTAL0_DEFAULT     8
-
-/* setup pll and query clock speed */
-typedef struct {
-       u16 fref;
-       u8 xf;
-       u8 p1div;
-       u8 p2div;
-       u8 ndiv_int;
-       u32 ndiv_frac;
-} pmu1_xtaltab0_t;
-
-static const pmu1_xtaltab0_t pmu1_xtaltab0_880_4329[] = {
-       {
-       12000, 1, 3, 22, 0x9, 0xFFFFEF}, {
-       13000, 2, 1, 6, 0xb, 0x483483}, {
-       14400, 3, 1, 10, 0xa, 0x1C71C7}, {
-       15360, 4, 1, 5, 0xb, 0x755555}, {
-       16200, 5, 1, 10, 0x5, 0x6E9E06}, {
-       16800, 6, 1, 10, 0x5, 0x3Cf3Cf}, {
-       19200, 7, 1, 4, 0xb, 0x755555}, {
-       19800, 8, 1, 11, 0x4, 0xA57EB}, {
-       20000, 9, 1, 11, 0x4, 0x0}, {
-       24000, 10, 3, 11, 0xa, 0x0}, {
-       25000, 11, 5, 16, 0xb, 0x0}, {
-       26000, 12, 1, 1, 0x21, 0xD89D89}, {
-       30000, 13, 3, 8, 0xb, 0x0}, {
-       37400, 14, 3, 1, 0x46, 0x969696}, {
-       38400, 15, 1, 1, 0x16, 0xEAAAAA}, {
-       40000, 16, 1, 2, 0xb, 0}, {
-       0, 0, 0, 0, 0, 0}
-};
-
-/* the following table is based on 880Mhz fvco */
-static const pmu1_xtaltab0_t pmu1_xtaltab0_880[] = {
-       {
-       12000, 1, 3, 22, 0x9, 0xFFFFEF}, {
-       13000, 2, 1, 6, 0xb, 0x483483}, {
-       14400, 3, 1, 10, 0xa, 0x1C71C7}, {
-       15360, 4, 1, 5, 0xb, 0x755555}, {
-       16200, 5, 1, 10, 0x5, 0x6E9E06}, {
-       16800, 6, 1, 10, 0x5, 0x3Cf3Cf}, {
-       19200, 7, 1, 4, 0xb, 0x755555}, {
-       19800, 8, 1, 11, 0x4, 0xA57EB}, {
-       20000, 9, 1, 11, 0x4, 0x0}, {
-       24000, 10, 3, 11, 0xa, 0x0}, {
-       25000, 11, 5, 16, 0xb, 0x0}, {
-       26000, 12, 1, 2, 0x10, 0xEC4EC4}, {
-       30000, 13, 3, 8, 0xb, 0x0}, {
-       33600, 14, 1, 2, 0xd, 0x186186}, {
-       38400, 15, 1, 2, 0xb, 0x755555}, {
-       40000, 16, 1, 2, 0xb, 0}, {
-       0, 0, 0, 0, 0, 0}
-};
-
-#define PMU1_XTALTAB0_880_12000K       0
-#define PMU1_XTALTAB0_880_13000K       1
-#define PMU1_XTALTAB0_880_14400K       2
-#define PMU1_XTALTAB0_880_15360K       3
-#define PMU1_XTALTAB0_880_16200K       4
-#define PMU1_XTALTAB0_880_16800K       5
-#define PMU1_XTALTAB0_880_19200K       6
-#define PMU1_XTALTAB0_880_19800K       7
-#define PMU1_XTALTAB0_880_20000K       8
-#define PMU1_XTALTAB0_880_24000K       9
-#define PMU1_XTALTAB0_880_25000K       10
-#define PMU1_XTALTAB0_880_26000K       11
-#define PMU1_XTALTAB0_880_30000K       12
-#define PMU1_XTALTAB0_880_37400K       13
-#define PMU1_XTALTAB0_880_38400K       14
-#define PMU1_XTALTAB0_880_40000K       15
-
-/* the following table is based on 1760Mhz fvco */
-static const pmu1_xtaltab0_t pmu1_xtaltab0_1760[] = {
-       {
-       12000, 1, 3, 44, 0x9, 0xFFFFEF}, {
-       13000, 2, 1, 12, 0xb, 0x483483}, {
-       14400, 3, 1, 20, 0xa, 0x1C71C7}, {
-       15360, 4, 1, 10, 0xb, 0x755555}, {
-       16200, 5, 1, 20, 0x5, 0x6E9E06}, {
-       16800, 6, 1, 20, 0x5, 0x3Cf3Cf}, {
-       19200, 7, 1, 18, 0x5, 0x17B425}, {
-       19800, 8, 1, 22, 0x4, 0xA57EB}, {
-       20000, 9, 1, 22, 0x4, 0x0}, {
-       24000, 10, 3, 22, 0xa, 0x0}, {
-       25000, 11, 5, 32, 0xb, 0x0}, {
-       26000, 12, 1, 4, 0x10, 0xEC4EC4}, {
-       30000, 13, 3, 16, 0xb, 0x0}, {
-       38400, 14, 1, 10, 0x4, 0x955555}, {
-       40000, 15, 1, 4, 0xb, 0}, {
-       0, 0, 0, 0, 0, 0}
-};
-
-/* table index */
-#define PMU1_XTALTAB0_1760_12000K      0
-#define PMU1_XTALTAB0_1760_13000K      1
-#define PMU1_XTALTAB0_1760_14400K      2
-#define PMU1_XTALTAB0_1760_15360K      3
-#define PMU1_XTALTAB0_1760_16200K      4
-#define PMU1_XTALTAB0_1760_16800K      5
-#define PMU1_XTALTAB0_1760_19200K      6
-#define PMU1_XTALTAB0_1760_19800K      7
-#define PMU1_XTALTAB0_1760_20000K      8
-#define PMU1_XTALTAB0_1760_24000K      9
-#define PMU1_XTALTAB0_1760_25000K      10
-#define PMU1_XTALTAB0_1760_26000K      11
-#define PMU1_XTALTAB0_1760_30000K      12
-#define PMU1_XTALTAB0_1760_38400K      13
-#define PMU1_XTALTAB0_1760_40000K      14
-
-/* the following table is based on 1440Mhz fvco */
-static const pmu1_xtaltab0_t pmu1_xtaltab0_1440[] = {
-       {
-       12000, 1, 1, 1, 0x78, 0x0}, {
-       13000, 2, 1, 1, 0x6E, 0xC4EC4E}, {
-       14400, 3, 1, 1, 0x64, 0x0}, {
-       15360, 4, 1, 1, 0x5D, 0xC00000}, {
-       16200, 5, 1, 1, 0x58, 0xE38E38}, {
-       16800, 6, 1, 1, 0x55, 0xB6DB6D}, {
-       19200, 7, 1, 1, 0x4B, 0}, {
-       19800, 8, 1, 1, 0x48, 0xBA2E8B}, {
-       20000, 9, 1, 1, 0x48, 0x0}, {
-       25000, 10, 1, 1, 0x39, 0x999999}, {
-       26000, 11, 1, 1, 0x37, 0x627627}, {
-       30000, 12, 1, 1, 0x30, 0x0}, {
-       37400, 13, 2, 1, 0x4D, 0x15E76}, {
-       38400, 13, 2, 1, 0x4B, 0x0}, {
-       40000, 14, 2, 1, 0x48, 0x0}, {
-       48000, 15, 2, 1, 0x3c, 0x0}, {
-       0, 0, 0, 0, 0, 0}
-};
-
-/* table index */
-#define PMU1_XTALTAB0_1440_12000K      0
-#define PMU1_XTALTAB0_1440_13000K      1
-#define PMU1_XTALTAB0_1440_14400K      2
-#define PMU1_XTALTAB0_1440_15360K      3
-#define PMU1_XTALTAB0_1440_16200K      4
-#define PMU1_XTALTAB0_1440_16800K      5
-#define PMU1_XTALTAB0_1440_19200K      6
-#define PMU1_XTALTAB0_1440_19800K      7
-#define PMU1_XTALTAB0_1440_20000K      8
-#define PMU1_XTALTAB0_1440_25000K      9
-#define PMU1_XTALTAB0_1440_26000K      10
-#define PMU1_XTALTAB0_1440_30000K      11
-#define PMU1_XTALTAB0_1440_37400K      12
-#define PMU1_XTALTAB0_1440_38400K      13
-#define PMU1_XTALTAB0_1440_40000K      14
-#define PMU1_XTALTAB0_1440_48000K      15
-
-#define XTAL_FREQ_24000MHZ             24000
-#define XTAL_FREQ_30000MHZ             30000
-#define XTAL_FREQ_37400MHZ             37400
-#define XTAL_FREQ_48000MHZ             48000
-
-static const pmu1_xtaltab0_t pmu1_xtaltab0_960[] = {
-       {
-       12000, 1, 1, 1, 0x50, 0x0}, {
-       13000, 2, 1, 1, 0x49, 0xD89D89}, {
-       14400, 3, 1, 1, 0x42, 0xAAAAAA}, {
-       15360, 4, 1, 1, 0x3E, 0x800000}, {
-       16200, 5, 1, 1, 0x39, 0x425ED0}, {
-       16800, 6, 1, 1, 0x39, 0x249249}, {
-       19200, 7, 1, 1, 0x32, 0x0}, {
-       19800, 8, 1, 1, 0x30, 0x7C1F07}, {
-       20000, 9, 1, 1, 0x30, 0x0}, {
-       25000, 10, 1, 1, 0x26, 0x666666}, {
-       26000, 11, 1, 1, 0x24, 0xEC4EC4}, {
-       30000, 12, 1, 1, 0x20, 0x0}, {
-       37400, 13, 2, 1, 0x33, 0x563EF9}, {
-       38400, 14, 2, 1, 0x32, 0x0}, {
-       40000, 15, 2, 1, 0x30, 0x0}, {
-       48000, 16, 2, 1, 0x28, 0x0}, {
-       0, 0, 0, 0, 0, 0}
-};
-
-/* table index */
-#define PMU1_XTALTAB0_960_12000K       0
-#define PMU1_XTALTAB0_960_13000K       1
-#define PMU1_XTALTAB0_960_14400K       2
-#define PMU1_XTALTAB0_960_15360K       3
-#define PMU1_XTALTAB0_960_16200K       4
-#define PMU1_XTALTAB0_960_16800K       5
-#define PMU1_XTALTAB0_960_19200K       6
-#define PMU1_XTALTAB0_960_19800K       7
-#define PMU1_XTALTAB0_960_20000K       8
-#define PMU1_XTALTAB0_960_25000K       9
-#define PMU1_XTALTAB0_960_26000K       10
-#define PMU1_XTALTAB0_960_30000K       11
-#define PMU1_XTALTAB0_960_37400K       12
-#define PMU1_XTALTAB0_960_38400K       13
-#define PMU1_XTALTAB0_960_40000K       14
-#define PMU1_XTALTAB0_960_48000K       15
-
-/* select xtal table for each chip */
-static const pmu1_xtaltab0_t *si_pmu1_xtaltab0(si_t *sih)
-{
-#ifdef BCMDBG
-       char chn[8];
-#endif
-       switch (sih->chip) {
-       case BCM4329_CHIP_ID:
-               return pmu1_xtaltab0_880_4329;
-       case BCM4319_CHIP_ID:
-               return pmu1_xtaltab0_1440;
-       case BCM4336_CHIP_ID:
-               return pmu1_xtaltab0_960;
-       case BCM4330_CHIP_ID:
-               if (CST4330_CHIPMODE_SDIOD(sih->chipst))
-                       return pmu1_xtaltab0_960;
-               else
-                       return pmu1_xtaltab0_1440;
-       default:
-               PMU_MSG(("si_pmu1_xtaltab0: Unknown chipid %s\n",
-                        bcm_chipname(sih->chip, chn, 8)));
-               break;
-       }
-       ASSERT(0);
-       return NULL;
-}
-
-/* select default xtal frequency for each chip */
-static const pmu1_xtaltab0_t *si_pmu1_xtaldef0(si_t *sih)
-{
-#ifdef BCMDBG
-       char chn[8];
-#endif
-
-       switch (sih->chip) {
-       case BCM4329_CHIP_ID:
-               /* Default to 38400Khz */
-               return &pmu1_xtaltab0_880_4329[PMU1_XTALTAB0_880_38400K];
-       case BCM4319_CHIP_ID:
-               /* Default to 30000Khz */
-               return &pmu1_xtaltab0_1440[PMU1_XTALTAB0_1440_30000K];
-       case BCM4336_CHIP_ID:
-               /* Default to 26000Khz */
-               return &pmu1_xtaltab0_960[PMU1_XTALTAB0_960_26000K];
-       case BCM4330_CHIP_ID:
-               /* Default to 37400Khz */
-               if (CST4330_CHIPMODE_SDIOD(sih->chipst))
-                       return &pmu1_xtaltab0_960[PMU1_XTALTAB0_960_37400K];
-               else
-                       return &pmu1_xtaltab0_1440[PMU1_XTALTAB0_1440_37400K];
-       default:
-               PMU_MSG(("si_pmu1_xtaldef0: Unknown chipid %s\n",
-                        bcm_chipname(sih->chip, chn, 8)));
-               break;
-       }
-       ASSERT(0);
-       return NULL;
-}
-
-/* select default pll fvco for each chip */
-static u32 si_pmu1_pllfvco0(si_t *sih)
-{
-#ifdef BCMDBG
-       char chn[8];
-#endif
-
-       switch (sih->chip) {
-       case BCM4329_CHIP_ID:
-               return FVCO_880;
-       case BCM4319_CHIP_ID:
-               return FVCO_1440;
-       case BCM4336_CHIP_ID:
-               return FVCO_960;
-       case BCM4330_CHIP_ID:
-               if (CST4330_CHIPMODE_SDIOD(sih->chipst))
-                       return FVCO_960;
-               else
-                       return FVCO_1440;
-       default:
-               PMU_MSG(("si_pmu1_pllfvco0: Unknown chipid %s\n",
-                        bcm_chipname(sih->chip, chn, 8)));
-               break;
-       }
-       ASSERT(0);
-       return 0;
-}
-
-/* query alp/xtal clock frequency */
-static u32
-si_pmu1_alpclk0(si_t *sih, chipcregs_t *cc)
-{
-       const pmu1_xtaltab0_t *xt;
-       u32 xf;
-
-       /* Find the frequency in the table */
-       xf = (R_REG(&cc->pmucontrol) & PCTL_XTALFREQ_MASK) >>
-           PCTL_XTALFREQ_SHIFT;
-       for (xt = si_pmu1_xtaltab0(sih); xt != NULL && xt->fref != 0; xt++)
-               if (xt->xf == xf)
-                       break;
-       /* Could not find it so assign a default value */
-       if (xt == NULL || xt->fref == 0)
-               xt = si_pmu1_xtaldef0(sih);
-       ASSERT(xt != NULL && xt->fref != 0);
-
-       return xt->fref * 1000;
-}
-
-/* Set up PLL registers in the PMU as per the crystal speed.
- * XtalFreq field in pmucontrol register being 0 indicates the PLL
- * is not programmed and the h/w default is assumed to work, in which
- * case the xtal frequency is unknown to the s/w so we need to call
- * si_pmu1_xtaldef0() wherever it is needed to return a default value.
- */
-static void si_pmu1_pllinit0(si_t *sih, chipcregs_t *cc, u32 xtal)
-{
-       const pmu1_xtaltab0_t *xt;
-       u32 tmp;
-       u32 buf_strength = 0;
-       u8 ndiv_mode = 1;
-
-       /* Use h/w default PLL config */
-       if (xtal == 0) {
-               PMU_MSG(("Unspecified xtal frequency, skip PLL configuration\n"));
-               return;
-       }
-
-       /* Find the frequency in the table */
-       for (xt = si_pmu1_xtaltab0(sih); xt != NULL && xt->fref != 0; xt++)
-               if (xt->fref == xtal)
-                       break;
-
-       /* Check current PLL state, bail out if it has been programmed or
-        * we don't know how to program it.
-        */
-       if (xt == NULL || xt->fref == 0) {
-               PMU_MSG(("Unsupported xtal frequency %d.%d MHz, skip PLL configuration\n", xtal / 1000, xtal % 1000));
-               return;
-       }
-       /*  for 4319 bootloader already programs the PLL but bootloader does not program the
-          PLL4 and PLL5. So Skip this check for 4319
-        */
-       if ((((R_REG(&cc->pmucontrol) & PCTL_XTALFREQ_MASK) >>
-             PCTL_XTALFREQ_SHIFT) == xt->xf) &&
-           !((sih->chip == BCM4319_CHIP_ID)
-             || (sih->chip == BCM4330_CHIP_ID))) {
-               PMU_MSG(("PLL already programmed for %d.%d MHz\n",
-                        xt->fref / 1000, xt->fref % 1000));
-               return;
-       }
-
-       PMU_MSG(("XTAL %d.%d MHz (%d)\n", xtal / 1000, xtal % 1000, xt->xf));
-       PMU_MSG(("Programming PLL for %d.%d MHz\n", xt->fref / 1000,
-                xt->fref % 1000));
-
-       switch (sih->chip) {
-       case BCM4329_CHIP_ID:
-               /* Change the BBPLL drive strength to 8 for all channels */
-               buf_strength = 0x888888;
-               AND_REG(&cc->min_res_mask,
-                       ~(PMURES_BIT(RES4329_BBPLL_PWRSW_PU) |
-                         PMURES_BIT(RES4329_HT_AVAIL)));
-               AND_REG(&cc->max_res_mask,
-                       ~(PMURES_BIT(RES4329_BBPLL_PWRSW_PU) |
-                         PMURES_BIT(RES4329_HT_AVAIL)));
-               SPINWAIT(R_REG(&cc->clk_ctl_st) & CCS_HTAVAIL,
-                        PMU_MAX_TRANSITION_DLY);
-               ASSERT(!(R_REG(&cc->clk_ctl_st) & CCS_HTAVAIL));
-               W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL4);
-               if (xt->fref == 38400)
-                       tmp = 0x200024C0;
-               else if (xt->fref == 37400)
-                       tmp = 0x20004500;
-               else if (xt->fref == 26000)
-                       tmp = 0x200024C0;
-               else
-                       tmp = 0x200005C0;       /* Chip Dflt Settings */
-               W_REG(&cc->pllcontrol_data, tmp);
-               W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL5);
-               tmp =
-                   R_REG(&cc->pllcontrol_data) & PMU1_PLL0_PC5_CLK_DRV_MASK;
-               if ((xt->fref == 38400) || (xt->fref == 37400)
-                   || (xt->fref == 26000))
-                       tmp |= 0x15;
-               else
-                       tmp |= 0x25;    /* Chip Dflt Settings */
-               W_REG(&cc->pllcontrol_data, tmp);
+                       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0);
+                       W_REG(&cc->pllcontrol_data, 0x11100010);
+                       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL1);
+                       W_REG(&cc->pllcontrol_data, 0x000c0c06);
+                       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2);
+                       W_REG(&cc->pllcontrol_data, 0x03000a08);
+                       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL3);
+                       W_REG(&cc->pllcontrol_data, 0x00000000);
+                       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL4);
+                       W_REG(&cc->pllcontrol_data, 0x200005c0);
+                       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL5);
+                       W_REG(&cc->pllcontrol_data, 0x88888815);
+               }
+               tmp = 1 << 10;
                break;
 
-       case BCM4319_CHIP_ID:
-               /* Change the BBPLL drive strength to 2 for all channels */
-               buf_strength = 0x222222;
-
-               /* Make sure the PLL is off */
-               /* WAR65104: Disable the HT_AVAIL resource first and then
-                * after a delay (more than downtime for HT_AVAIL) remove the
-                * BBPLL resource; backplane clock moves to ALP from HT.
-                */
-               AND_REG(&cc->min_res_mask,
-                       ~(PMURES_BIT(RES4319_HT_AVAIL)));
-               AND_REG(&cc->max_res_mask,
-                       ~(PMURES_BIT(RES4319_HT_AVAIL)));
-
-               udelay(100);
-               AND_REG(&cc->min_res_mask,
-                       ~(PMURES_BIT(RES4319_BBPLL_PWRSW_PU)));
-               AND_REG(&cc->max_res_mask,
-                       ~(PMURES_BIT(RES4319_BBPLL_PWRSW_PU)));
-
-               udelay(100);
-               SPINWAIT(R_REG(&cc->clk_ctl_st) & CCS_HTAVAIL,
-                        PMU_MAX_TRANSITION_DLY);
-               ASSERT(!(R_REG(&cc->clk_ctl_st) & CCS_HTAVAIL));
+               W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0);
+               W_REG(&cc->pllcontrol_data, 0x11100008);
+               W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL1);
+               W_REG(&cc->pllcontrol_data, 0x0c000c06);
+               W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2);
+               W_REG(&cc->pllcontrol_data, 0x03000a08);
+               W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL3);
+               W_REG(&cc->pllcontrol_data, 0x00000000);
                W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL4);
-               tmp = 0x200005c0;
-               W_REG(&cc->pllcontrol_data, tmp);
-               break;
-
-       case BCM4336_CHIP_ID:
-               AND_REG(&cc->min_res_mask,
-                       ~(PMURES_BIT(RES4336_HT_AVAIL) |
-                         PMURES_BIT(RES4336_MACPHY_CLKAVAIL)));
-               AND_REG(&cc->max_res_mask,
-                       ~(PMURES_BIT(RES4336_HT_AVAIL) |
-                         PMURES_BIT(RES4336_MACPHY_CLKAVAIL)));
-               udelay(100);
-               SPINWAIT(R_REG(&cc->clk_ctl_st) & CCS_HTAVAIL,
-                        PMU_MAX_TRANSITION_DLY);
-               ASSERT(!(R_REG(&cc->clk_ctl_st) & CCS_HTAVAIL));
-               break;
+               W_REG(&cc->pllcontrol_data, 0x200005c0);
+               W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL5);
+               W_REG(&cc->pllcontrol_data, 0x88888855);
 
-       case BCM4330_CHIP_ID:
-               AND_REG(&cc->min_res_mask,
-                       ~(PMURES_BIT(RES4330_HT_AVAIL) |
-                         PMURES_BIT(RES4330_MACPHY_CLKAVAIL)));
-               AND_REG(&cc->max_res_mask,
-                       ~(PMURES_BIT(RES4330_HT_AVAIL) |
-                         PMURES_BIT(RES4330_MACPHY_CLKAVAIL)));
-               udelay(100);
-               SPINWAIT(R_REG(&cc->clk_ctl_st) & CCS_HTAVAIL,
-                        PMU_MAX_TRANSITION_DLY);
-               ASSERT(!(R_REG(&cc->clk_ctl_st) & CCS_HTAVAIL));
+               tmp = 1 << 10;
                break;
 
-       default:
-               ASSERT(0);
-       }
-
-       PMU_MSG(("Done masking\n"));
-
-       /* Write p1div and p2div to pllcontrol[0] */
-       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0);
-       tmp = R_REG(&cc->pllcontrol_data) &
-           ~(PMU1_PLL0_PC0_P1DIV_MASK | PMU1_PLL0_PC0_P2DIV_MASK);
-       tmp |=
-           ((xt->
-             p1div << PMU1_PLL0_PC0_P1DIV_SHIFT) & PMU1_PLL0_PC0_P1DIV_MASK) |
-           ((xt->
-             p2div << PMU1_PLL0_PC0_P2DIV_SHIFT) & PMU1_PLL0_PC0_P2DIV_MASK);
-       W_REG(&cc->pllcontrol_data, tmp);
-
-       if ((sih->chip == BCM4330_CHIP_ID))
-               si_pmu_set_4330_plldivs(sih);
+       case BCM4716_CHIP_ID:
+       case BCM4748_CHIP_ID:
+       case BCM47162_CHIP_ID:
+               if (spuravoid == 1) {
+                       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0);
+                       W_REG(&cc->pllcontrol_data, 0x11500060);
+                       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL1);
+                       W_REG(&cc->pllcontrol_data, 0x080C0C06);
+                       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2);
+                       W_REG(&cc->pllcontrol_data, 0x0F600000);
+                       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL3);
+                       W_REG(&cc->pllcontrol_data, 0x00000000);
+                       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL4);
+                       W_REG(&cc->pllcontrol_data, 0x2001E924);
+                       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL5);
+                       W_REG(&cc->pllcontrol_data, 0x88888815);
+               } else {
+                       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0);
+                       W_REG(&cc->pllcontrol_data, 0x11100060);
+                       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL1);
+                       W_REG(&cc->pllcontrol_data, 0x080c0c06);
+                       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2);
+                       W_REG(&cc->pllcontrol_data, 0x03000000);
+                       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL3);
+                       W_REG(&cc->pllcontrol_data, 0x00000000);
+                       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL4);
+                       W_REG(&cc->pllcontrol_data, 0x200005c0);
+                       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL5);
+                       W_REG(&cc->pllcontrol_data, 0x88888815);
+               }
 
-       if ((sih->chip == BCM4329_CHIP_ID)
-           && (sih->chiprev == 0)) {
+               tmp = 3 << 9;
+               break;
 
+       case BCM4319_CHIP_ID:
+               W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0);
+               W_REG(&cc->pllcontrol_data, 0x11100070);
                W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL1);
-               tmp = R_REG(&cc->pllcontrol_data);
-               tmp = tmp & (~DOT11MAC_880MHZ_CLK_DIVISOR_MASK);
-               tmp = tmp | DOT11MAC_880MHZ_CLK_DIVISOR_VAL;
-               W_REG(&cc->pllcontrol_data, tmp);
-       }
-       if ((sih->chip == BCM4319_CHIP_ID) ||
-           (sih->chip == BCM4336_CHIP_ID) ||
-           (sih->chip == BCM4330_CHIP_ID))
-               ndiv_mode = PMU1_PLL0_PC2_NDIV_MODE_MFB;
-       else
-               ndiv_mode = PMU1_PLL0_PC2_NDIV_MODE_MASH;
-
-       /* Write ndiv_int and ndiv_mode to pllcontrol[2] */
-       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2);
-       tmp = R_REG(&cc->pllcontrol_data) &
-           ~(PMU1_PLL0_PC2_NDIV_INT_MASK | PMU1_PLL0_PC2_NDIV_MODE_MASK);
-       tmp |=
-           ((xt->
-             ndiv_int << PMU1_PLL0_PC2_NDIV_INT_SHIFT) &
-            PMU1_PLL0_PC2_NDIV_INT_MASK) | ((ndiv_mode <<
-                                             PMU1_PLL0_PC2_NDIV_MODE_SHIFT) &
-                                            PMU1_PLL0_PC2_NDIV_MODE_MASK);
-       W_REG(&cc->pllcontrol_data, tmp);
-
-       /* Write ndiv_frac to pllcontrol[3] */
-       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL3);
-       tmp = R_REG(&cc->pllcontrol_data) & ~PMU1_PLL0_PC3_NDIV_FRAC_MASK;
-       tmp |= ((xt->ndiv_frac << PMU1_PLL0_PC3_NDIV_FRAC_SHIFT) &
-               PMU1_PLL0_PC3_NDIV_FRAC_MASK);
-       W_REG(&cc->pllcontrol_data, tmp);
-
-       /* Write clock driving strength to pllcontrol[5] */
-       if (buf_strength) {
-               PMU_MSG(("Adjusting PLL buffer drive strength: %x\n",
-                        buf_strength));
-
+               W_REG(&cc->pllcontrol_data, 0x1014140a);
                W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL5);
-               tmp =
-                   R_REG(&cc->pllcontrol_data) & ~PMU1_PLL0_PC5_CLK_DRV_MASK;
-               tmp |= (buf_strength << PMU1_PLL0_PC5_CLK_DRV_SHIFT);
-               W_REG(&cc->pllcontrol_data, tmp);
-       }
-
-       PMU_MSG(("Done pll\n"));
+               W_REG(&cc->pllcontrol_data, 0x88888854);
 
-       /* to operate the 4319 usb in 24MHz/48MHz; chipcontrol[2][84:83] needs
-        * to be updated.
-        */
-       if ((sih->chip == BCM4319_CHIP_ID)
-           && (xt->fref != XTAL_FREQ_30000MHZ)) {
-               W_REG(&cc->chipcontrol_addr, PMU1_PLL0_CHIPCTL2);
-               tmp =
-                   R_REG(&cc->chipcontrol_data) & ~CCTL_4319USB_XTAL_SEL_MASK;
-               if (xt->fref == XTAL_FREQ_24000MHZ) {
-                       tmp |=
-                           (CCTL_4319USB_24MHZ_PLL_SEL <<
-                            CCTL_4319USB_XTAL_SEL_SHIFT);
-               } else if (xt->fref == XTAL_FREQ_48000MHZ) {
-                       tmp |=
-                           (CCTL_4319USB_48MHZ_PLL_SEL <<
-                            CCTL_4319USB_XTAL_SEL_SHIFT);
+               if (spuravoid == 1) {
+                       /* spur_avoid ON, so enable 41/82/164Mhz clock mode */
+                       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2);
+                       W_REG(&cc->pllcontrol_data, 0x05201828);
+               } else {
+                       /* enable 40/80/160Mhz clock mode */
+                       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2);
+                       W_REG(&cc->pllcontrol_data, 0x05001828);
                }
-               W_REG(&cc->chipcontrol_data, tmp);
-       }
-
-       /* Flush deferred pll control registers writes */
-       if (sih->pmurev >= 2)
-               OR_REG(&cc->pmucontrol, PCTL_PLL_PLLCTL_UPD);
-
-       /* Write XtalFreq. Set the divisor also. */
-       tmp = R_REG(&cc->pmucontrol) &
-           ~(PCTL_ILP_DIV_MASK | PCTL_XTALFREQ_MASK);
-       tmp |= (((((xt->fref + 127) / 128) - 1) << PCTL_ILP_DIV_SHIFT) &
-               PCTL_ILP_DIV_MASK) |
-           ((xt->xf << PCTL_XTALFREQ_SHIFT) & PCTL_XTALFREQ_MASK);
-
-       if ((sih->chip == BCM4329_CHIP_ID)
-           && sih->chiprev == 0) {
-               /* clear the htstretch before clearing HTReqEn */
-               AND_REG(&cc->clkstretch, ~CSTRETCH_HT);
-               tmp &= ~PCTL_HT_REQ_EN;
-       }
-
-       W_REG(&cc->pmucontrol, tmp);
-}
-
-/* query the CPU clock frequency */
-static u32
-si_pmu1_cpuclk0(si_t *sih, chipcregs_t *cc)
-{
-       u32 tmp, m1div;
-#ifdef BCMDBG
-       u32 ndiv_int, ndiv_frac, p2div, p1div, fvco;
-       u32 fref;
-#endif
-       u32 FVCO = si_pmu1_pllfvco0(sih);
-
-       /* Read m1div from pllcontrol[1] */
-       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL1);
-       tmp = R_REG(&cc->pllcontrol_data);
-       m1div = (tmp & PMU1_PLL0_PC1_M1DIV_MASK) >> PMU1_PLL0_PC1_M1DIV_SHIFT;
-
-#ifdef BCMDBG
-       /* Read p2div/p1div from pllcontrol[0] */
-       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0);
-       tmp = R_REG(&cc->pllcontrol_data);
-       p2div = (tmp & PMU1_PLL0_PC0_P2DIV_MASK) >> PMU1_PLL0_PC0_P2DIV_SHIFT;
-       p1div = (tmp & PMU1_PLL0_PC0_P1DIV_MASK) >> PMU1_PLL0_PC0_P1DIV_SHIFT;
-
-       /* Calculate fvco based on xtal freq and ndiv and pdiv */
-       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2);
-       tmp = R_REG(&cc->pllcontrol_data);
-       ndiv_int =
-           (tmp & PMU1_PLL0_PC2_NDIV_INT_MASK) >> PMU1_PLL0_PC2_NDIV_INT_SHIFT;
-
-       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL3);
-       tmp = R_REG(&cc->pllcontrol_data);
-       ndiv_frac =
-           (tmp & PMU1_PLL0_PC3_NDIV_FRAC_MASK) >>
-           PMU1_PLL0_PC3_NDIV_FRAC_SHIFT;
+               break;
+       case BCM4336_CHIP_ID:
+               /* Looks like these are only for default xtal freq 26MHz */
+               W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0);
+               W_REG(&cc->pllcontrol_data, 0x02100020);
 
-       fref = si_pmu1_alpclk0(sih, cc) / 1000;
+               W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL1);
+               W_REG(&cc->pllcontrol_data, 0x0C0C0C0C);
 
-       fvco = (fref * ndiv_int) << 8;
-       fvco += (fref * (ndiv_frac >> 12)) >> 4;
-       fvco += (fref * (ndiv_frac & 0xfff)) >> 12;
-       fvco >>= 8;
-       fvco *= p2div;
-       fvco /= p1div;
-       fvco /= 1000;
-       fvco *= 1000;
+               W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2);
+               W_REG(&cc->pllcontrol_data, 0x01240C0C);
 
-       PMU_MSG(("si_pmu1_cpuclk0: ndiv_int %u ndiv_frac %u p2div %u p1div %u fvco %u\n", ndiv_int, ndiv_frac, p2div, p1div, fvco));
+               W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL4);
+               W_REG(&cc->pllcontrol_data, 0x202C2820);
 
-       FVCO = fvco;
-#endif                         /* BCMDBG */
+               W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL5);
+               W_REG(&cc->pllcontrol_data, 0x88888825);
 
-       /* Return ARM/SB clock */
-       return FVCO / m1div * 1000;
-}
+               W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL3);
+               if (spuravoid == 1)
+                       W_REG(&cc->pllcontrol_data, 0x00EC4EC4);
+               else
+                       W_REG(&cc->pllcontrol_data, 0x00762762);
 
-/* initialize PLL */
-void si_pmu_pll_init(si_t *sih, uint xtalfreq)
-{
-       chipcregs_t *cc;
-       uint origidx;
-#ifdef BCMDBG
-       char chn[8];
-#endif
+               tmp = PCTL_PLL_PLLCTL_UPD;
+               break;
 
-       ASSERT(sih->cccaps & CC_CAP_PMU);
+       default:
+               /* bail out */
+               return;
+       }
 
-       /* Remember original core before switch to chipc */
-       origidx = si_coreidx(sih);
-       cc = si_setcoreidx(sih, SI_CC_IDX);
-       ASSERT(cc != NULL);
+       tmp |= R_REG(&cc->pmucontrol);
+       W_REG(&cc->pmucontrol, tmp);
+}
 
+/* select default xtal frequency for each chip */
+static const pmu1_xtaltab0_t *si_pmu1_xtaldef0(si_t *sih)
+{
        switch (sih->chip) {
        case BCM4329_CHIP_ID:
-               if (xtalfreq == 0)
-                       xtalfreq = 38400;
-               si_pmu1_pllinit0(sih, cc, xtalfreq);
-               break;
-       case BCM4313_CHIP_ID:
-       case BCM43224_CHIP_ID:
-       case BCM43225_CHIP_ID:
-       case BCM43421_CHIP_ID:
-       case BCM43235_CHIP_ID:
-       case BCM43236_CHIP_ID:
-       case BCM43238_CHIP_ID:
-       case BCM4331_CHIP_ID:
-       case BCM6362_CHIP_ID:
-               /* ??? */
-               break;
+               /* Default to 38400Khz */
+               return &pmu1_xtaltab0_880_4329[PMU1_XTALTAB0_880_38400K];
        case BCM4319_CHIP_ID:
+               /* Default to 30000Khz */
+               return &pmu1_xtaltab0_1440[PMU1_XTALTAB0_1440_30000K];
        case BCM4336_CHIP_ID:
+               /* Default to 26000Khz */
+               return &pmu1_xtaltab0_960[PMU1_XTALTAB0_960_26000K];
        case BCM4330_CHIP_ID:
-               si_pmu1_pllinit0(sih, cc, xtalfreq);
-               break;
+               /* Default to 37400Khz */
+               if (CST4330_CHIPMODE_SDIOD(sih->chipst))
+                       return &pmu1_xtaltab0_960[PMU1_XTALTAB0_960_37400K];
+               else
+                       return &pmu1_xtaltab0_1440[PMU1_XTALTAB0_1440_37400K];
        default:
-               PMU_MSG(("No PLL init done for chip %s rev %d pmurev %d\n",
-                        bcm_chipname(sih->chip, chn, 8), sih->chiprev,
-                        sih->pmurev));
                break;
        }
-
-#ifdef BCMDBG_FORCEHT
-       OR_REG(&cc->clk_ctl_st, CCS_FORCEHT);
-#endif
-
-       /* Return to original core */
-       si_setcoreidx(sih, origidx);
+       return NULL;
 }
 
-/* query alp/xtal clock frequency */
-u32 si_pmu_alp_clock(si_t *sih)
+/* select xtal table for each chip */
+static const pmu1_xtaltab0_t *si_pmu1_xtaltab0(si_t *sih)
 {
-       chipcregs_t *cc;
-       uint origidx;
-       u32 clock = ALP_CLOCK;
-#ifdef BCMDBG
-       char chn[8];
-#endif
-
-       ASSERT(sih->cccaps & CC_CAP_PMU);
-
-       /* Remember original core before switch to chipc */
-       origidx = si_coreidx(sih);
-       cc = si_setcoreidx(sih, SI_CC_IDX);
-       ASSERT(cc != NULL);
-
        switch (sih->chip) {
-       case BCM43224_CHIP_ID:
-       case BCM43225_CHIP_ID:
-       case BCM43421_CHIP_ID:
-       case BCM43235_CHIP_ID:
-       case BCM43236_CHIP_ID:
-       case BCM43238_CHIP_ID:
-       case BCM4331_CHIP_ID:
-       case BCM6362_CHIP_ID:
-       case BCM4716_CHIP_ID:
-       case BCM4748_CHIP_ID:
-       case BCM47162_CHIP_ID:
-       case BCM4313_CHIP_ID:
-       case BCM5357_CHIP_ID:
-               /* always 20Mhz */
-               clock = 20000 * 1000;
-               break;
        case BCM4329_CHIP_ID:
+               return pmu1_xtaltab0_880_4329;
        case BCM4319_CHIP_ID:
+               return pmu1_xtaltab0_1440;
        case BCM4336_CHIP_ID:
+               return pmu1_xtaltab0_960;
        case BCM4330_CHIP_ID:
-
-               clock = si_pmu1_alpclk0(sih, cc);
-               break;
-       case BCM5356_CHIP_ID:
-               /* always 25Mhz */
-               clock = 25000 * 1000;
-               break;
+               if (CST4330_CHIPMODE_SDIOD(sih->chipst))
+                       return pmu1_xtaltab0_960;
+               else
+                       return pmu1_xtaltab0_1440;
        default:
-               PMU_MSG(("No ALP clock specified "
-                        "for chip %s rev %d pmurev %d, using default %d Hz\n",
-                        bcm_chipname(sih->chip, chn, 8), sih->chiprev,
-                        sih->pmurev, clock));
                break;
        }
-
-       /* Return to original core */
-       si_setcoreidx(sih, origidx);
-       return clock;
+       return NULL;
 }
 
-/* Find the output of the "m" pll divider given pll controls that start with
- * pllreg "pll0" i.e. 12 for main 6 for phy, 0 for misc.
- */
+/* query alp/xtal clock frequency */
 static u32
-si_pmu5_clock(si_t *sih, chipcregs_t *cc, uint pll0, uint m) {
-       u32 tmp, div, ndiv, p1, p2, fc;
-
-       if ((pll0 & 3) || (pll0 > PMU4716_MAINPLL_PLL0)) {
-               PMU_ERROR(("%s: Bad pll0: %d\n", __func__, pll0));
-               return 0;
-       }
+si_pmu1_alpclk0(si_t *sih, chipcregs_t *cc)
+{
+       const pmu1_xtaltab0_t *xt;
+       u32 xf;
 
-       /* Strictly there is an m5 divider, but I'm not sure we use it */
-       if ((m == 0) || (m > 4)) {
-               PMU_ERROR(("%s: Bad m divider: %d\n", __func__, m));
-               return 0;
-       }
+       /* Find the frequency in the table */
+       xf = (R_REG(&cc->pmucontrol) & PCTL_XTALFREQ_MASK) >>
+           PCTL_XTALFREQ_SHIFT;
+       for (xt = si_pmu1_xtaltab0(sih); xt != NULL && xt->fref != 0; xt++)
+               if (xt->xf == xf)
+                       break;
+       /* Could not find it so assign a default value */
+       if (xt == NULL || xt->fref == 0)
+               xt = si_pmu1_xtaldef0(sih);
+       return xt->fref * 1000;
+}
 
-       if (sih->chip == BCM5357_CHIP_ID) {
-               /* Detect failure in clock setting */
-               if ((R_REG(&cc->chipstatus) & 0x40000) != 0)
-                       return 133 * 1000000;
+/* select default pll fvco for each chip */
+static u32 si_pmu1_pllfvco0(si_t *sih)
+{
+       switch (sih->chip) {
+       case BCM4329_CHIP_ID:
+               return FVCO_880;
+       case BCM4319_CHIP_ID:
+               return FVCO_1440;
+       case BCM4336_CHIP_ID:
+               return FVCO_960;
+       case BCM4330_CHIP_ID:
+               if (CST4330_CHIPMODE_SDIOD(sih->chipst))
+                       return FVCO_960;
+               else
+                       return FVCO_1440;
+       default:
+               break;
        }
+       return 0;
+}
 
-       W_REG(&cc->pllcontrol_addr, pll0 + PMU5_PLL_P1P2_OFF);
-       (void)R_REG(&cc->pllcontrol_addr);
-       tmp = R_REG(&cc->pllcontrol_data);
-       p1 = (tmp & PMU5_PLL_P1_MASK) >> PMU5_PLL_P1_SHIFT;
-       p2 = (tmp & PMU5_PLL_P2_MASK) >> PMU5_PLL_P2_SHIFT;
-
-       W_REG(&cc->pllcontrol_addr, pll0 + PMU5_PLL_M14_OFF);
-       (void)R_REG(&cc->pllcontrol_addr);
-       tmp = R_REG(&cc->pllcontrol_data);
-       div = (tmp >> ((m - 1) * PMU5_PLL_MDIV_WIDTH)) & PMU5_PLL_MDIV_MASK;
-
-       W_REG(&cc->pllcontrol_addr, pll0 + PMU5_PLL_NM5_OFF);
-       (void)R_REG(&cc->pllcontrol_addr);
-       tmp = R_REG(&cc->pllcontrol_data);
-       ndiv = (tmp & PMU5_PLL_NDIV_MASK) >> PMU5_PLL_NDIV_SHIFT;
+static void si_pmu_set_4330_plldivs(si_t *sih)
+{
+       u32 FVCO = si_pmu1_pllfvco0(sih) / 1000;
+       u32 m1div, m2div, m3div, m4div, m5div, m6div;
+       u32 pllc1, pllc2;
 
-       /* Do calculation in Mhz */
-       fc = si_pmu_alp_clock(sih) / 1000000;
-       fc = (p1 * ndiv * fc) / p2;
+       m2div = m3div = m4div = m6div = FVCO / 80;
+       m5div = FVCO / 160;
 
-       PMU_NONE(("%s: p1=%d, p2=%d, ndiv=%d(0x%x), m%d=%d; fc=%d, clock=%d\n",
-                 __func__, p1, p2, ndiv, ndiv, m, div, fc, fc / div));
+       if (CST4330_CHIPMODE_SDIOD(sih->chipst))
+               m1div = FVCO / 80;
+       else
+               m1div = FVCO / 90;
+       pllc1 =
+           (m1div << PMU1_PLL0_PC1_M1DIV_SHIFT) | (m2div <<
+                                                   PMU1_PLL0_PC1_M2DIV_SHIFT) |
+           (m3div << PMU1_PLL0_PC1_M3DIV_SHIFT) | (m4div <<
+                                                   PMU1_PLL0_PC1_M4DIV_SHIFT);
+       si_pmu_pllcontrol(sih, PMU1_PLL0_PLLCTL1, ~0, pllc1);
 
-       /* Return clock in Hertz */
-       return (fc / div) * 1000000;
+       pllc2 = si_pmu_pllcontrol(sih, PMU1_PLL0_PLLCTL1, 0, 0);
+       pllc2 &= ~(PMU1_PLL0_PC2_M5DIV_MASK | PMU1_PLL0_PC2_M6DIV_MASK);
+       pllc2 |=
+           ((m5div << PMU1_PLL0_PC2_M5DIV_SHIFT) |
+            (m6div << PMU1_PLL0_PC2_M6DIV_SHIFT));
+       si_pmu_pllcontrol(sih, PMU1_PLL0_PLLCTL2, ~0, pllc2);
 }
 
-/* query backplane clock frequency */
-/* For designs that feed the same clock to both backplane
- * and CPU just return the CPU clock speed.
+/* Set up PLL registers in the PMU as per the crystal speed.
+ * XtalFreq field in pmucontrol register being 0 indicates the PLL
+ * is not programmed and the h/w default is assumed to work, in which
+ * case the xtal frequency is unknown to the s/w so we need to call
+ * si_pmu1_xtaldef0() wherever it is needed to return a default value.
  */
-u32 si_pmu_si_clock(si_t *sih)
+static void si_pmu1_pllinit0(si_t *sih, chipcregs_t *cc, u32 xtal)
 {
-       chipcregs_t *cc;
-       uint origidx;
-       u32 clock = HT_CLOCK;
-#ifdef BCMDBG
-       char chn[8];
-#endif
+       const pmu1_xtaltab0_t *xt;
+       u32 tmp;
+       u32 buf_strength = 0;
+       u8 ndiv_mode = 1;
 
-       ASSERT(sih->cccaps & CC_CAP_PMU);
+       /* Use h/w default PLL config */
+       if (xtal == 0) {
+               return;
+       }
 
-       /* Remember original core before switch to chipc */
-       origidx = si_coreidx(sih);
-       cc = si_setcoreidx(sih, SI_CC_IDX);
-       ASSERT(cc != NULL);
+       /* Find the frequency in the table */
+       for (xt = si_pmu1_xtaltab0(sih); xt != NULL && xt->fref != 0; xt++)
+               if (xt->fref == xtal)
+                       break;
+
+       /* Check current PLL state, bail out if it has been programmed or
+        * we don't know how to program it.
+        */
+       if (xt == NULL || xt->fref == 0) {
+               return;
+       }
+       /* for 4319 bootloader already programs the PLL but bootloader does not
+        * program the PLL4 and PLL5. So Skip this check for 4319
+        */
+       if ((((R_REG(&cc->pmucontrol) & PCTL_XTALFREQ_MASK) >>
+             PCTL_XTALFREQ_SHIFT) == xt->xf) &&
+           !((sih->chip == BCM4319_CHIP_ID)
+             || (sih->chip == BCM4330_CHIP_ID)))
+               return;
 
        switch (sih->chip) {
-       case BCM43224_CHIP_ID:
-       case BCM43225_CHIP_ID:
-       case BCM43421_CHIP_ID:
-       case BCM4331_CHIP_ID:
-       case BCM6362_CHIP_ID:
-               /* 96MHz backplane clock */
-               clock = 96000 * 1000;
-               break;
-       case BCM4716_CHIP_ID:
-       case BCM4748_CHIP_ID:
-       case BCM47162_CHIP_ID:
-               clock =
-                   si_pmu5_clock(sih, cc, PMU4716_MAINPLL_PLL0,
-                                 PMU5_MAINPLL_SI);
-               break;
        case BCM4329_CHIP_ID:
-               if (sih->chiprev == 0)
-                       clock = 38400 * 1000;
+               /* Change the BBPLL drive strength to 8 for all channels */
+               buf_strength = 0x888888;
+               AND_REG(&cc->min_res_mask,
+                       ~(PMURES_BIT(RES4329_BBPLL_PWRSW_PU) |
+                         PMURES_BIT(RES4329_HT_AVAIL)));
+               AND_REG(&cc->max_res_mask,
+                       ~(PMURES_BIT(RES4329_BBPLL_PWRSW_PU) |
+                         PMURES_BIT(RES4329_HT_AVAIL)));
+               SPINWAIT(R_REG(&cc->clk_ctl_st) & CCS_HTAVAIL,
+                        PMU_MAX_TRANSITION_DLY);
+               W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL4);
+               if (xt->fref == 38400)
+                       tmp = 0x200024C0;
+               else if (xt->fref == 37400)
+                       tmp = 0x20004500;
+               else if (xt->fref == 26000)
+                       tmp = 0x200024C0;
+               else
+                       tmp = 0x200005C0;       /* Chip Dflt Settings */
+               W_REG(&cc->pllcontrol_data, tmp);
+               W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL5);
+               tmp =
+                   R_REG(&cc->pllcontrol_data) & PMU1_PLL0_PC5_CLK_DRV_MASK;
+               if ((xt->fref == 38400) || (xt->fref == 37400)
+                   || (xt->fref == 26000))
+                       tmp |= 0x15;
                else
-                       clock = si_pmu1_cpuclk0(sih, cc);
+                       tmp |= 0x25;    /* Chip Dflt Settings */
+               W_REG(&cc->pllcontrol_data, tmp);
+               break;
+
+       case BCM4319_CHIP_ID:
+               /* Change the BBPLL drive strength to 2 for all channels */
+               buf_strength = 0x222222;
+
+               /* Make sure the PLL is off */
+               /* WAR65104: Disable the HT_AVAIL resource first and then
+                * after a delay (more than downtime for HT_AVAIL) remove the
+                * BBPLL resource; backplane clock moves to ALP from HT.
+                */
+               AND_REG(&cc->min_res_mask,
+                       ~(PMURES_BIT(RES4319_HT_AVAIL)));
+               AND_REG(&cc->max_res_mask,
+                       ~(PMURES_BIT(RES4319_HT_AVAIL)));
+
+               udelay(100);
+               AND_REG(&cc->min_res_mask,
+                       ~(PMURES_BIT(RES4319_BBPLL_PWRSW_PU)));
+               AND_REG(&cc->max_res_mask,
+                       ~(PMURES_BIT(RES4319_BBPLL_PWRSW_PU)));
+
+               udelay(100);
+               SPINWAIT(R_REG(&cc->clk_ctl_st) & CCS_HTAVAIL,
+                        PMU_MAX_TRANSITION_DLY);
+               W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL4);
+               tmp = 0x200005c0;
+               W_REG(&cc->pllcontrol_data, tmp);
                break;
-       case BCM4319_CHIP_ID:
+
        case BCM4336_CHIP_ID:
-       case BCM4330_CHIP_ID:
-               clock = si_pmu1_cpuclk0(sih, cc);
-               break;
-       case BCM4313_CHIP_ID:
-               /* 80MHz backplane clock */
-               clock = 80000 * 1000;
-               break;
-       case BCM43235_CHIP_ID:
-       case BCM43236_CHIP_ID:
-       case BCM43238_CHIP_ID:
-               clock =
-                   (cc->chipstatus & CST43236_BP_CLK) ? (120000 *
-                                                         1000) : (96000 *
-                                                                  1000);
-               break;
-       case BCM5356_CHIP_ID:
-               clock =
-                   si_pmu5_clock(sih, cc, PMU5356_MAINPLL_PLL0,
-                                 PMU5_MAINPLL_SI);
+               AND_REG(&cc->min_res_mask,
+                       ~(PMURES_BIT(RES4336_HT_AVAIL) |
+                         PMURES_BIT(RES4336_MACPHY_CLKAVAIL)));
+               AND_REG(&cc->max_res_mask,
+                       ~(PMURES_BIT(RES4336_HT_AVAIL) |
+                         PMURES_BIT(RES4336_MACPHY_CLKAVAIL)));
+               udelay(100);
+               SPINWAIT(R_REG(&cc->clk_ctl_st) & CCS_HTAVAIL,
+                        PMU_MAX_TRANSITION_DLY);
                break;
-       case BCM5357_CHIP_ID:
-               clock =
-                   si_pmu5_clock(sih, cc, PMU5357_MAINPLL_PLL0,
-                                 PMU5_MAINPLL_SI);
+
+       case BCM4330_CHIP_ID:
+               AND_REG(&cc->min_res_mask,
+                       ~(PMURES_BIT(RES4330_HT_AVAIL) |
+                         PMURES_BIT(RES4330_MACPHY_CLKAVAIL)));
+               AND_REG(&cc->max_res_mask,
+                       ~(PMURES_BIT(RES4330_HT_AVAIL) |
+                         PMURES_BIT(RES4330_MACPHY_CLKAVAIL)));
+               udelay(100);
+               SPINWAIT(R_REG(&cc->clk_ctl_st) & CCS_HTAVAIL,
+                        PMU_MAX_TRANSITION_DLY);
                break;
+
        default:
-               PMU_MSG(("No backplane clock specified "
-                        "for chip %s rev %d pmurev %d, using default %d Hz\n",
-                        bcm_chipname(sih->chip, chn, 8), sih->chiprev,
-                        sih->pmurev, clock));
                break;
        }
 
-       /* Return to original core */
-       si_setcoreidx(sih, origidx);
-       return clock;
-}
-
-/* query CPU clock frequency */
-u32 si_pmu_cpu_clock(si_t *sih)
-{
-       chipcregs_t *cc;
-       uint origidx;
-       u32 clock;
-
-       ASSERT(sih->cccaps & CC_CAP_PMU);
-
-       if ((sih->pmurev >= 5) &&
-           !((sih->chip == BCM4329_CHIP_ID) ||
-             (sih->chip == BCM4319_CHIP_ID) ||
-             (sih->chip == BCM43236_CHIP_ID) ||
-             (sih->chip == BCM4336_CHIP_ID) ||
-             (sih->chip == BCM4330_CHIP_ID))) {
-               uint pll;
-
-               switch (sih->chip) {
-               case BCM5356_CHIP_ID:
-                       pll = PMU5356_MAINPLL_PLL0;
-                       break;
-               case BCM5357_CHIP_ID:
-                       pll = PMU5357_MAINPLL_PLL0;
-                       break;
-               default:
-                       pll = PMU4716_MAINPLL_PLL0;
-                       break;
-               }
-
-               /* Remember original core before switch to chipc */
-               origidx = si_coreidx(sih);
-               cc = si_setcoreidx(sih, SI_CC_IDX);
-               ASSERT(cc != NULL);
+       /* Write p1div and p2div to pllcontrol[0] */
+       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0);
+       tmp = R_REG(&cc->pllcontrol_data) &
+           ~(PMU1_PLL0_PC0_P1DIV_MASK | PMU1_PLL0_PC0_P2DIV_MASK);
+       tmp |=
+           ((xt->
+             p1div << PMU1_PLL0_PC0_P1DIV_SHIFT) & PMU1_PLL0_PC0_P1DIV_MASK) |
+           ((xt->
+             p2div << PMU1_PLL0_PC0_P2DIV_SHIFT) & PMU1_PLL0_PC0_P2DIV_MASK);
+       W_REG(&cc->pllcontrol_data, tmp);
 
-               clock = si_pmu5_clock(sih, cc, pll, PMU5_MAINPLL_CPU);
+       if ((sih->chip == BCM4330_CHIP_ID))
+               si_pmu_set_4330_plldivs(sih);
 
-               /* Return to original core */
-               si_setcoreidx(sih, origidx);
-       } else
-               clock = si_pmu_si_clock(sih);
+       if ((sih->chip == BCM4329_CHIP_ID)
+           && (sih->chiprev == 0)) {
 
-       return clock;
-}
+               W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL1);
+               tmp = R_REG(&cc->pllcontrol_data);
+               tmp = tmp & (~DOT11MAC_880MHZ_CLK_DIVISOR_MASK);
+               tmp = tmp | DOT11MAC_880MHZ_CLK_DIVISOR_VAL;
+               W_REG(&cc->pllcontrol_data, tmp);
+       }
+       if ((sih->chip == BCM4319_CHIP_ID) ||
+           (sih->chip == BCM4336_CHIP_ID) ||
+           (sih->chip == BCM4330_CHIP_ID))
+               ndiv_mode = PMU1_PLL0_PC2_NDIV_MODE_MFB;
+       else
+               ndiv_mode = PMU1_PLL0_PC2_NDIV_MODE_MASH;
 
-/* query memory clock frequency */
-u32 si_pmu_mem_clock(si_t *sih)
-{
-       chipcregs_t *cc;
-       uint origidx;
-       u32 clock;
+       /* Write ndiv_int and ndiv_mode to pllcontrol[2] */
+       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2);
+       tmp = R_REG(&cc->pllcontrol_data) &
+           ~(PMU1_PLL0_PC2_NDIV_INT_MASK | PMU1_PLL0_PC2_NDIV_MODE_MASK);
+       tmp |=
+           ((xt->
+             ndiv_int << PMU1_PLL0_PC2_NDIV_INT_SHIFT) &
+            PMU1_PLL0_PC2_NDIV_INT_MASK) | ((ndiv_mode <<
+                                             PMU1_PLL0_PC2_NDIV_MODE_SHIFT) &
+                                            PMU1_PLL0_PC2_NDIV_MODE_MASK);
+       W_REG(&cc->pllcontrol_data, tmp);
 
-       ASSERT(sih->cccaps & CC_CAP_PMU);
+       /* Write ndiv_frac to pllcontrol[3] */
+       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL3);
+       tmp = R_REG(&cc->pllcontrol_data) & ~PMU1_PLL0_PC3_NDIV_FRAC_MASK;
+       tmp |= ((xt->ndiv_frac << PMU1_PLL0_PC3_NDIV_FRAC_SHIFT) &
+               PMU1_PLL0_PC3_NDIV_FRAC_MASK);
+       W_REG(&cc->pllcontrol_data, tmp);
 
-       if ((sih->pmurev >= 5) &&
-           !((sih->chip == BCM4329_CHIP_ID) ||
-             (sih->chip == BCM4319_CHIP_ID) ||
-             (sih->chip == BCM4330_CHIP_ID) ||
-             (sih->chip == BCM4336_CHIP_ID) ||
-             (sih->chip == BCM43236_CHIP_ID))) {
-               uint pll;
+       /* Write clock driving strength to pllcontrol[5] */
+       if (buf_strength) {
+               W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL5);
+               tmp =
+                   R_REG(&cc->pllcontrol_data) & ~PMU1_PLL0_PC5_CLK_DRV_MASK;
+               tmp |= (buf_strength << PMU1_PLL0_PC5_CLK_DRV_SHIFT);
+               W_REG(&cc->pllcontrol_data, tmp);
+       }
 
-               switch (sih->chip) {
-               case BCM5356_CHIP_ID:
-                       pll = PMU5356_MAINPLL_PLL0;
-                       break;
-               case BCM5357_CHIP_ID:
-                       pll = PMU5357_MAINPLL_PLL0;
-                       break;
-               default:
-                       pll = PMU4716_MAINPLL_PLL0;
-                       break;
+       /* to operate the 4319 usb in 24MHz/48MHz; chipcontrol[2][84:83] needs
+        * to be updated.
+        */
+       if ((sih->chip == BCM4319_CHIP_ID)
+           && (xt->fref != XTAL_FREQ_30000MHZ)) {
+               W_REG(&cc->chipcontrol_addr, PMU1_PLL0_CHIPCTL2);
+               tmp =
+                   R_REG(&cc->chipcontrol_data) & ~CCTL_4319USB_XTAL_SEL_MASK;
+               if (xt->fref == XTAL_FREQ_24000MHZ) {
+                       tmp |=
+                           (CCTL_4319USB_24MHZ_PLL_SEL <<
+                            CCTL_4319USB_XTAL_SEL_SHIFT);
+               } else if (xt->fref == XTAL_FREQ_48000MHZ) {
+                       tmp |=
+                           (CCTL_4319USB_48MHZ_PLL_SEL <<
+                            CCTL_4319USB_XTAL_SEL_SHIFT);
                }
+               W_REG(&cc->chipcontrol_data, tmp);
+       }
 
-               /* Remember original core before switch to chipc */
-               origidx = si_coreidx(sih);
-               cc = si_setcoreidx(sih, SI_CC_IDX);
-               ASSERT(cc != NULL);
+       /* Flush deferred pll control registers writes */
+       if (sih->pmurev >= 2)
+               OR_REG(&cc->pmucontrol, PCTL_PLL_PLLCTL_UPD);
 
-               clock = si_pmu5_clock(sih, cc, pll, PMU5_MAINPLL_MEM);
+       /* Write XtalFreq. Set the divisor also. */
+       tmp = R_REG(&cc->pmucontrol) &
+           ~(PCTL_ILP_DIV_MASK | PCTL_XTALFREQ_MASK);
+       tmp |= (((((xt->fref + 127) / 128) - 1) << PCTL_ILP_DIV_SHIFT) &
+               PCTL_ILP_DIV_MASK) |
+           ((xt->xf << PCTL_XTALFREQ_SHIFT) & PCTL_XTALFREQ_MASK);
 
-               /* Return to original core */
-               si_setcoreidx(sih, origidx);
-       } else {
-               clock = si_pmu_si_clock(sih);
+       if ((sih->chip == BCM4329_CHIP_ID)
+           && sih->chiprev == 0) {
+               /* clear the htstretch before clearing HTReqEn */
+               AND_REG(&cc->clkstretch, ~CSTRETCH_HT);
+               tmp &= ~PCTL_HT_REQ_EN;
        }
 
-       return clock;
+       W_REG(&cc->pmucontrol, tmp);
 }
 
-/* Measure ILP clock frequency */
-#define ILP_CALC_DUR   10      /* ms, make sure 1000 can be divided by it. */
-
-static u32 ilpcycles_per_sec;
-
 u32 si_pmu_ilp_clock(si_t *sih)
 {
-       if (ISSIM_ENAB(sih))
+       static u32 ilpcycles_per_sec;
+
+       if (ISSIM_ENAB(sih) || !PMUCTL_ENAB(sih))
                return ILP_CLOCK;
 
        if (ilpcycles_per_sec == 0) {
                u32 start, end, delta;
-               u32 origidx = si_coreidx(sih);
-               chipcregs_t *cc = si_setcoreidx(sih, SI_CC_IDX);
-               ASSERT(cc != NULL);
+               u32 origidx = ai_coreidx(sih);
+               chipcregs_t *cc = ai_setcoreidx(sih, SI_CC_IDX);
                start = R_REG(&cc->pmutimer);
                mdelay(ILP_CALC_DUR);
                end = R_REG(&cc->pmutimer);
                delta = end - start;
                ilpcycles_per_sec = delta * (1000 / ILP_CALC_DUR);
-               si_setcoreidx(sih, origidx);
+               ai_setcoreidx(sih, origidx);
        }
 
        return ilpcycles_per_sec;
 }
 
-/* SDIO Pad drive strength to select value mappings */
-typedef struct {
-       u8 strength;            /* Pad Drive Strength in mA */
-       u8 sel;         /* Chip-specific select value */
-} sdiod_drive_str_t;
-
-/* SDIO Drive Strength to sel value table for PMU Rev 1 */
-static const sdiod_drive_str_t sdiod_drive_strength_tab1[] = {
-       {
-       4, 0x2}, {
-       2, 0x3}, {
-       1, 0x0}, {
-       0, 0x0}
-       };
-
-/* SDIO Drive Strength to sel value table for PMU Rev 2, 3 */
-static const sdiod_drive_str_t sdiod_drive_strength_tab2[] = {
-       {
-       12, 0x7}, {
-       10, 0x6}, {
-       8, 0x5}, {
-       6, 0x4}, {
-       4, 0x2}, {
-       2, 0x1}, {
-       0, 0x0}
-       };
-
-/* SDIO Drive Strength to sel value table for PMU Rev 8 (1.8V) */
-static const sdiod_drive_str_t sdiod_drive_strength_tab3[] = {
-       {
-       32, 0x7}, {
-       26, 0x6}, {
-       22, 0x5}, {
-       16, 0x4}, {
-       12, 0x3}, {
-       8, 0x2}, {
-       4, 0x1}, {
-       0, 0x0}
-       };
-
-#define SDIOD_DRVSTR_KEY(chip, pmu)    (((chip) << 16) | (pmu))
-
-void
-si_sdiod_drive_strength_init(si_t *sih, u32 drivestrength) {
-       chipcregs_t *cc;
-       uint origidx, intr_val = 0;
-       sdiod_drive_str_t *str_tab = NULL;
-       u32 str_mask = 0;
-       u32 str_shift = 0;
-#ifdef BCMDBG
-       char chn[8];
-#endif
-
-       if (!(sih->cccaps & CC_CAP_PMU)) {
-               return;
-       }
-
-       /* Remember original core before switch to chipc */
-       cc = (chipcregs_t *) si_switch_core(sih, CC_CORE_ID, &origidx,
-                                           &intr_val);
-
-       switch (SDIOD_DRVSTR_KEY(sih->chip, sih->pmurev)) {
-       case SDIOD_DRVSTR_KEY(BCM4325_CHIP_ID, 1):
-               str_tab = (sdiod_drive_str_t *)&sdiod_drive_strength_tab1;
-               str_mask = 0x30000000;
-               str_shift = 28;
-               break;
-       case SDIOD_DRVSTR_KEY(BCM4325_CHIP_ID, 2):
-       case SDIOD_DRVSTR_KEY(BCM4325_CHIP_ID, 3):
-               str_tab = (sdiod_drive_str_t *)&sdiod_drive_strength_tab2;
-               str_mask = 0x00003800;
-               str_shift = 11;
-               break;
-       case SDIOD_DRVSTR_KEY(BCM4336_CHIP_ID, 8):
-               str_tab = (sdiod_drive_str_t *) &sdiod_drive_strength_tab3;
-               str_mask = 0x00003800;
-               str_shift = 11;
-               break;
-
-       default:
-               PMU_MSG(("No SDIO Drive strength init done for chip %s rev %d pmurev %d\n", bcm_chipname(sih->chip, chn, 8), sih->chiprev, sih->pmurev));
-
-               break;
-       }
-
-       if (str_tab != NULL) {
-               u32 drivestrength_sel = 0;
-               u32 cc_data_temp;
-               int i;
-
-               for (i = 0; str_tab[i].strength != 0; i++) {
-                       if (drivestrength >= str_tab[i].strength) {
-                               drivestrength_sel = str_tab[i].sel;
-                               break;
-                       }
-               }
-
-               W_REG(&cc->chipcontrol_addr, 1);
-               cc_data_temp = R_REG(&cc->chipcontrol_data);
-               cc_data_temp &= ~str_mask;
-               drivestrength_sel <<= str_shift;
-               cc_data_temp |= drivestrength_sel;
-               W_REG(&cc->chipcontrol_data, cc_data_temp);
-
-               PMU_MSG(("SDIO: %dmA drive strength selected, set to 0x%08x\n",
-                        drivestrength, cc_data_temp));
-       }
-
-       /* Return to original core */
-       si_restore_core(sih, origidx, intr_val);
-}
-
-/* initialize PMU */
-void si_pmu_init(si_t *sih)
+void si_pmu_set_ldo_voltage(si_t *sih, u8 ldo, u8 voltage)
 {
-       chipcregs_t *cc;
-       uint origidx;
-
-       ASSERT(sih->cccaps & CC_CAP_PMU);
-
-       /* Remember original core before switch to chipc */
-       origidx = si_coreidx(sih);
-       cc = si_setcoreidx(sih, SI_CC_IDX);
-       ASSERT(cc != NULL);
-
-       if (sih->pmurev == 1)
-               AND_REG(&cc->pmucontrol, ~PCTL_NOILP_ON_WAIT);
-       else if (sih->pmurev >= 2)
-               OR_REG(&cc->pmucontrol, PCTL_NOILP_ON_WAIT);
-
-       if ((sih->chip == BCM4329_CHIP_ID) && (sih->chiprev == 2)) {
-               /* Fix for 4329b0 bad LPOM state. */
-               W_REG(&cc->regcontrol_addr, 2);
-               OR_REG(&cc->regcontrol_data, 0x100);
-
-               W_REG(&cc->regcontrol_addr, 3);
-               OR_REG(&cc->regcontrol_data, 0x4);
-       }
-
-       /* Return to original core */
-       si_setcoreidx(sih, origidx);
-}
-
-/* Return up time in ILP cycles for the given resource. */
-static uint
-si_pmu_res_uptime(si_t *sih, chipcregs_t *cc, u8 rsrc) {
-       u32 deps;
-       uint up, i, dup, dmax;
-       u32 min_mask = 0, max_mask = 0;
-
-       /* uptime of resource 'rsrc' */
-       W_REG(&cc->res_table_sel, rsrc);
-       up = (R_REG(&cc->res_updn_timer) >> 8) & 0xff;
-
-       /* direct dependancies of resource 'rsrc' */
-       deps = si_pmu_res_deps(sih, cc, PMURES_BIT(rsrc), false);
-       for (i = 0; i <= PMURES_MAX_RESNUM; i++) {
-               if (!(deps & PMURES_BIT(i)))
-                       continue;
-               deps &= ~si_pmu_res_deps(sih, cc, PMURES_BIT(i), true);
-       }
-       si_pmu_res_masks(sih, &min_mask, &max_mask);
-       deps &= ~min_mask;
+       u8 sr_cntl_shift = 0, rc_shift = 0, shift = 0, mask = 0;
+       u8 addr = 0;
 
-       /* max uptime of direct dependancies */
-       dmax = 0;
-       for (i = 0; i <= PMURES_MAX_RESNUM; i++) {
-               if (!(deps & PMURES_BIT(i)))
-                       continue;
-               dup = si_pmu_res_uptime(sih, cc, (u8) i);
-               if (dmax < dup)
-                       dmax = dup;
+       switch (sih->chip) {
+       case BCM4336_CHIP_ID:
+               switch (ldo) {
+               case SET_LDO_VOLTAGE_CLDO_PWM:
+                       addr = 4;
+                       rc_shift = 1;
+                       mask = 0xf;
+                       break;
+               case SET_LDO_VOLTAGE_CLDO_BURST:
+                       addr = 4;
+                       rc_shift = 5;
+                       mask = 0xf;
+                       break;
+               case SET_LDO_VOLTAGE_LNLDO1:
+                       addr = 4;
+                       rc_shift = 17;
+                       mask = 0xf;
+                       break;
+               default:
+                       return;
+               }
+               break;
+       case BCM4330_CHIP_ID:
+               switch (ldo) {
+               case SET_LDO_VOLTAGE_CBUCK_PWM:
+                       addr = 3;
+                       rc_shift = 0;
+                       mask = 0x1f;
+                       break;
+               default:
+                       return;
+               }
+               break;
+       default:
+               return;
        }
 
-       PMU_MSG(("si_pmu_res_uptime: rsrc %u uptime %u(deps 0x%08x uptime %u)\n", rsrc, up, deps, dmax));
-
-       return up + dmax + PMURES_UP_TRANSITION;
-}
-
-/* Return dependancies (direct or all/indirect) for the given resources */
-static u32
-si_pmu_res_deps(si_t *sih, chipcregs_t *cc, u32 rsrcs,
-               bool all)
-{
-       u32 deps = 0;
-       u32 i;
-
-       for (i = 0; i <= PMURES_MAX_RESNUM; i++) {
-               if (!(rsrcs & PMURES_BIT(i)))
-                       continue;
-               W_REG(&cc->res_table_sel, i);
-               deps |= R_REG(&cc->res_dep_mask);
-       }
+       shift = sr_cntl_shift + rc_shift;
 
-       return !all ? deps : (deps
-                             ? (deps |
-                                si_pmu_res_deps(sih, cc, deps,
-                                                true)) : 0);
+       ai_corereg(sih, SI_CC_IDX, offsetof(chipcregs_t, regcontrol_addr),
+                  ~0, addr);
+       ai_corereg(sih, SI_CC_IDX, offsetof(chipcregs_t, regcontrol_data),
+                  mask << shift, (voltage & mask) << shift);
 }
 
-/* power up/down OTP through PMU resources */
-void si_pmu_otp_power(si_t *sih, bool on)
+u16 si_pmu_fast_pwrup_delay(si_t *sih)
 {
+       uint delay = PMU_MAX_TRANSITION_DLY;
        chipcregs_t *cc;
        uint origidx;
-       u32 rsrcs = 0;  /* rsrcs to turn on/off OTP power */
-
-       ASSERT(sih->cccaps & CC_CAP_PMU);
-
-       /* Don't do anything if OTP is disabled */
-       if (si_is_otp_disabled(sih)) {
-               PMU_MSG(("si_pmu_otp_power: OTP is disabled\n"));
-               return;
-       }
+#ifdef BCMDBG
+       char chn[8];
+       chn[0] = 0;             /* to suppress compile error */
+#endif
 
        /* Remember original core before switch to chipc */
-       origidx = si_coreidx(sih);
-       cc = si_setcoreidx(sih, SI_CC_IDX);
-       ASSERT(cc != NULL);
+       origidx = ai_coreidx(sih);
+       cc = ai_setcoreidx(sih, SI_CC_IDX);
 
        switch (sih->chip) {
+       case BCM43224_CHIP_ID:
+       case BCM43225_CHIP_ID:
+       case BCM43421_CHIP_ID:
+       case BCM43235_CHIP_ID:
+       case BCM43236_CHIP_ID:
+       case BCM43238_CHIP_ID:
+       case BCM4331_CHIP_ID:
+       case BCM6362_CHIP_ID:
+       case BCM4313_CHIP_ID:
+               delay = ISSIM_ENAB(sih) ? 70 : 3700;
+               break;
        case BCM4329_CHIP_ID:
-               rsrcs = PMURES_BIT(RES4329_OTP_PU);
+               if (ISSIM_ENAB(sih))
+                       delay = 70;
+               else {
+                       u32 ilp = si_pmu_ilp_clock(sih);
+                       delay =
+                           (si_pmu_res_uptime(sih, cc, RES4329_HT_AVAIL) +
+                            D11SCC_SLOW2FAST_TRANSITION) * ((1000000 + ilp -
+                                                             1) / ilp);
+                       delay = (11 * delay) / 10;
+               }
                break;
        case BCM4319_CHIP_ID:
-               rsrcs = PMURES_BIT(RES4319_OTP_PU);
+               delay = ISSIM_ENAB(sih) ? 70 : 3700;
                break;
        case BCM4336_CHIP_ID:
-               rsrcs = PMURES_BIT(RES4336_OTP_PU);
+               if (ISSIM_ENAB(sih))
+                       delay = 70;
+               else {
+                       u32 ilp = si_pmu_ilp_clock(sih);
+                       delay =
+                           (si_pmu_res_uptime(sih, cc, RES4336_HT_AVAIL) +
+                            D11SCC_SLOW2FAST_TRANSITION) * ((1000000 + ilp -
+                                                             1) / ilp);
+                       delay = (11 * delay) / 10;
+               }
                break;
        case BCM4330_CHIP_ID:
-               rsrcs = PMURES_BIT(RES4330_OTP_PU);
+               if (ISSIM_ENAB(sih))
+                       delay = 70;
+               else {
+                       u32 ilp = si_pmu_ilp_clock(sih);
+                       delay =
+                           (si_pmu_res_uptime(sih, cc, RES4330_HT_AVAIL) +
+                            D11SCC_SLOW2FAST_TRANSITION) * ((1000000 + ilp -
+                                                             1) / ilp);
+                       delay = (11 * delay) / 10;
+               }
                break;
        default:
                break;
        }
+       /* Return to original core */
+       ai_setcoreidx(sih, origidx);
 
-       if (rsrcs != 0) {
-               u32 otps;
+       return (u16) delay;
+}
 
-               /* Figure out the dependancies (exclude min_res_mask) */
-               u32 deps = si_pmu_res_deps(sih, cc, rsrcs, true);
-               u32 min_mask = 0, max_mask = 0;
-               si_pmu_res_masks(sih, &min_mask, &max_mask);
-               deps &= ~min_mask;
-               /* Turn on/off the power */
-               if (on) {
-                       PMU_MSG(("Adding rsrc 0x%x to min_res_mask\n",
-                                rsrcs | deps));
-                       OR_REG(&cc->min_res_mask, (rsrcs | deps));
-                       SPINWAIT(!(R_REG(&cc->res_state) & rsrcs),
-                                PMU_MAX_TRANSITION_DLY);
-                       ASSERT(R_REG(&cc->res_state) & rsrcs);
-               } else {
-                       PMU_MSG(("Removing rsrc 0x%x from min_res_mask\n",
-                                rsrcs | deps));
-                       AND_REG(&cc->min_res_mask, ~(rsrcs | deps));
-               }
+void si_pmu_sprom_enable(si_t *sih, bool enable)
+{
+       chipcregs_t *cc;
+       uint origidx;
 
-               SPINWAIT((((otps = R_REG(&cc->otpstatus)) & OTPS_READY) !=
-                         (on ? OTPS_READY : 0)), 100);
-               ASSERT((otps & OTPS_READY) == (on ? OTPS_READY : 0));
-               if ((otps & OTPS_READY) != (on ? OTPS_READY : 0))
-                       PMU_MSG(("OTP ready bit not %s after wait\n",
-                                (on ? "ON" : "OFF")));
-       }
+       /* Remember original core before switch to chipc */
+       origidx = ai_coreidx(sih);
+       cc = ai_setcoreidx(sih, SI_CC_IDX);
 
        /* Return to original core */
-       si_setcoreidx(sih, origidx);
+       ai_setcoreidx(sih, origidx);
+}
+
+/* Read/write a chipcontrol reg */
+u32 si_pmu_chipcontrol(si_t *sih, uint reg, u32 mask, u32 val)
+{
+       ai_corereg(sih, SI_CC_IDX, offsetof(chipcregs_t, chipcontrol_addr), ~0,
+                  reg);
+       return ai_corereg(sih, SI_CC_IDX,
+                         offsetof(chipcregs_t, chipcontrol_data), mask, val);
+}
+
+/* Read/write a regcontrol reg */
+u32 si_pmu_regcontrol(si_t *sih, uint reg, u32 mask, u32 val)
+{
+       ai_corereg(sih, SI_CC_IDX, offsetof(chipcregs_t, regcontrol_addr), ~0,
+                  reg);
+       return ai_corereg(sih, SI_CC_IDX,
+                         offsetof(chipcregs_t, regcontrol_data), mask, val);
+}
+
+/* Read/write a pllcontrol reg */
+u32 si_pmu_pllcontrol(si_t *sih, uint reg, u32 mask, u32 val)
+{
+       ai_corereg(sih, SI_CC_IDX, offsetof(chipcregs_t, pllcontrol_addr), ~0,
+                  reg);
+       return ai_corereg(sih, SI_CC_IDX,
+                         offsetof(chipcregs_t, pllcontrol_data), mask, val);
+}
+
+/* PMU PLL update */
+void si_pmu_pllupd(si_t *sih)
+{
+       ai_corereg(sih, SI_CC_IDX, offsetof(chipcregs_t, pmucontrol),
+                  PCTL_PLL_PLLCTL_UPD, PCTL_PLL_PLLCTL_UPD);
 }
 
-void si_pmu_rcal(si_t *sih)
+/* query alp/xtal clock frequency */
+u32 si_pmu_alp_clock(si_t *sih)
 {
        chipcregs_t *cc;
        uint origidx;
+       u32 clock = ALP_CLOCK;
 
-       ASSERT(sih->cccaps & CC_CAP_PMU);
+       /* bail out with default */
+       if (!PMUCTL_ENAB(sih))
+               return clock;
 
        /* Remember original core before switch to chipc */
-       origidx = si_coreidx(sih);
-       cc = si_setcoreidx(sih, SI_CC_IDX);
-       ASSERT(cc != NULL);
+       origidx = ai_coreidx(sih);
+       cc = ai_setcoreidx(sih, SI_CC_IDX);
 
        switch (sih->chip) {
-       case BCM4329_CHIP_ID:{
-                       u8 rcal_code;
-                       u32 val;
-
-                       /* Kick RCal */
-                       W_REG(&cc->chipcontrol_addr, 1);
-
-                       /* Power Down RCAL Block */
-                       AND_REG(&cc->chipcontrol_data, ~0x04);
-
-                       /* Power Up RCAL block */
-                       OR_REG(&cc->chipcontrol_data, 0x04);
-
-                       /* Wait for completion */
-                       SPINWAIT(0 == (R_REG(&cc->chipstatus) & 0x08),
-                                10 * 1000 * 1000);
-                       ASSERT(R_REG(&cc->chipstatus) & 0x08);
-
-                       /* Drop the LSB to convert from 5 bit code to 4 bit code */
-                       rcal_code =
-                           (u8) (R_REG(&cc->chipstatus) >> 5) & 0x0f;
-
-                       PMU_MSG(("RCal completed, status 0x%x, code 0x%x\n",
-                                R_REG(&cc->chipstatus), rcal_code));
-
-                       /* Write RCal code into pmu_vreg_ctrl[32:29] */
-                       W_REG(&cc->regcontrol_addr, 0);
-                       val =
-                           R_REG(&cc->regcontrol_data) & ~((u32) 0x07 << 29);
-                       val |= (u32) (rcal_code & 0x07) << 29;
-                       W_REG(&cc->regcontrol_data, val);
-                       W_REG(&cc->regcontrol_addr, 1);
-                       val = R_REG(&cc->regcontrol_data) & ~(u32) 0x01;
-                       val |= (u32) ((rcal_code >> 3) & 0x01);
-                       W_REG(&cc->regcontrol_data, val);
-
-                       /* Write RCal code into pmu_chip_ctrl[33:30] */
-                       W_REG(&cc->chipcontrol_addr, 0);
-                       val =
-                           R_REG(&cc->chipcontrol_data) & ~((u32) 0x03 << 30);
-                       val |= (u32) (rcal_code & 0x03) << 30;
-                       W_REG(&cc->chipcontrol_data, val);
-                       W_REG(&cc->chipcontrol_addr, 1);
-                       val =
-                           R_REG(&cc->chipcontrol_data) & ~(u32) 0x03;
-                       val |= (u32) ((rcal_code >> 2) & 0x03);
-                       W_REG(&cc->chipcontrol_data, val);
-
-                       /* Set override in pmu_chip_ctrl[29] */
-                       W_REG(&cc->chipcontrol_addr, 0);
-                       OR_REG(&cc->chipcontrol_data, (0x01 << 29));
-
-                       /* Power off RCal block */
-                       W_REG(&cc->chipcontrol_addr, 1);
-                       AND_REG(&cc->chipcontrol_data, ~0x04);
+       case BCM43224_CHIP_ID:
+       case BCM43225_CHIP_ID:
+       case BCM43421_CHIP_ID:
+       case BCM43235_CHIP_ID:
+       case BCM43236_CHIP_ID:
+       case BCM43238_CHIP_ID:
+       case BCM4331_CHIP_ID:
+       case BCM6362_CHIP_ID:
+       case BCM4716_CHIP_ID:
+       case BCM4748_CHIP_ID:
+       case BCM47162_CHIP_ID:
+       case BCM4313_CHIP_ID:
+       case BCM5357_CHIP_ID:
+               /* always 20Mhz */
+               clock = 20000 * 1000;
+               break;
+       case BCM4329_CHIP_ID:
+       case BCM4319_CHIP_ID:
+       case BCM4336_CHIP_ID:
+       case BCM4330_CHIP_ID:
 
-                       break;
-               }
+               clock = si_pmu1_alpclk0(sih, cc);
+               break;
+       case BCM5356_CHIP_ID:
+               /* always 25Mhz */
+               clock = 25000 * 1000;
+               break;
        default:
                break;
        }
 
        /* Return to original core */
-       si_setcoreidx(sih, origidx);
+       ai_setcoreidx(sih, origidx);
+       return clock;
 }
 
 void si_pmu_spuravoid(si_t *sih, u8 spuravoid)
@@ -2215,9 +1462,8 @@ void si_pmu_spuravoid(si_t *sih, u8 spuravoid)
        u32 tmp = 0;
 
        /* Remember original core before switch to chipc */
-       cc = (chipcregs_t *) si_switch_core(sih, CC_CORE_ID, &origidx,
+       cc = (chipcregs_t *) ai_switch_core(sih, CC_CORE_ID, &origidx,
                                            &intr_val);
-       ASSERT(cc != NULL);
 
        /* force the HT off  */
        if (sih->chip == BCM4336_CHIP_ID) {
@@ -2227,7 +1473,6 @@ void si_pmu_spuravoid(si_t *sih, u8 spuravoid)
                /* wait for the ht to really go away */
                SPINWAIT(((R_REG(&cc->clk_ctl_st) & CCS_HTAVAIL) == 0),
                         10000);
-               ASSERT((R_REG(&cc->clk_ctl_st) & CCS_HTAVAIL) == 0);
        }
 
        /* update the pll changes */
@@ -2241,203 +1486,340 @@ void si_pmu_spuravoid(si_t *sih, u8 spuravoid)
        }
 
        /* Return to original core */
-       si_restore_core(sih, origidx, intr_val);
+       ai_restore_core(sih, origidx, intr_val);
 }
 
-static void
-si_pmu_spuravoid_pllupdate(si_t *sih, chipcregs_t *cc, u8 spuravoid)
+/* initialize PMU */
+void si_pmu_init(si_t *sih)
 {
-       u32 tmp = 0;
-       u8 phypll_offset = 0;
-       u8 bcm5357_bcm43236_p1div[] = { 0x1, 0x5, 0x5 };
-       u8 bcm5357_bcm43236_ndiv[] = { 0x30, 0xf6, 0xfc };
+       chipcregs_t *cc;
+       uint origidx;
+
+       /* Remember original core before switch to chipc */
+       origidx = ai_coreidx(sih);
+       cc = ai_setcoreidx(sih, SI_CC_IDX);
+
+       if (sih->pmurev == 1)
+               AND_REG(&cc->pmucontrol, ~PCTL_NOILP_ON_WAIT);
+       else if (sih->pmurev >= 2)
+               OR_REG(&cc->pmucontrol, PCTL_NOILP_ON_WAIT);
+
+       if ((sih->chip == BCM4329_CHIP_ID) && (sih->chiprev == 2)) {
+               /* Fix for 4329b0 bad LPOM state. */
+               W_REG(&cc->regcontrol_addr, 2);
+               OR_REG(&cc->regcontrol_data, 0x100);
+
+               W_REG(&cc->regcontrol_addr, 3);
+               OR_REG(&cc->regcontrol_data, 0x4);
+       }
+
+       /* Return to original core */
+       ai_setcoreidx(sih, origidx);
+}
+
+/* initialize PMU chip controls and other chip level stuff */
+void si_pmu_chip_init(si_t *sih)
+{
+       uint origidx;
+
+       /* Gate off SPROM clock and chip select signals */
+       si_pmu_sprom_enable(sih, false);
+
+       /* Remember original core */
+       origidx = ai_coreidx(sih);
+
+       /* Return to original core */
+       ai_setcoreidx(sih, origidx);
+}
+
+/* initialize PMU switch/regulators */
+void si_pmu_swreg_init(si_t *sih)
+{
+       switch (sih->chip) {
+       case BCM4336_CHIP_ID:
+               /* Reduce CLDO PWM output voltage to 1.2V */
+               si_pmu_set_ldo_voltage(sih, SET_LDO_VOLTAGE_CLDO_PWM, 0xe);
+               /* Reduce CLDO BURST output voltage to 1.2V */
+               si_pmu_set_ldo_voltage(sih, SET_LDO_VOLTAGE_CLDO_BURST,
+                                      0xe);
+               /* Reduce LNLDO1 output voltage to 1.2V */
+               si_pmu_set_ldo_voltage(sih, SET_LDO_VOLTAGE_LNLDO1, 0xe);
+               if (sih->chiprev == 0)
+                       si_pmu_regcontrol(sih, 2, 0x400000, 0x400000);
+               break;
+
+       case BCM4330_CHIP_ID:
+               /* CBUCK Voltage is 1.8 by default and set that to 1.5 */
+               si_pmu_set_ldo_voltage(sih, SET_LDO_VOLTAGE_CBUCK_PWM, 0);
+               break;
+       default:
+               break;
+       }
+}
+
+/* initialize PLL */
+void si_pmu_pll_init(si_t *sih, uint xtalfreq)
+{
+       chipcregs_t *cc;
+       uint origidx;
+
+       /* Remember original core before switch to chipc */
+       origidx = ai_coreidx(sih);
+       cc = ai_setcoreidx(sih, SI_CC_IDX);
 
        switch (sih->chip) {
-       case BCM5357_CHIP_ID:
+       case BCM4329_CHIP_ID:
+               if (xtalfreq == 0)
+                       xtalfreq = 38400;
+               si_pmu1_pllinit0(sih, cc, xtalfreq);
+               break;
+       case BCM4313_CHIP_ID:
+       case BCM43224_CHIP_ID:
+       case BCM43225_CHIP_ID:
+       case BCM43421_CHIP_ID:
        case BCM43235_CHIP_ID:
        case BCM43236_CHIP_ID:
        case BCM43238_CHIP_ID:
+       case BCM4331_CHIP_ID:
+       case BCM6362_CHIP_ID:
+               /* ??? */
+               break;
+       case BCM4319_CHIP_ID:
+       case BCM4336_CHIP_ID:
+       case BCM4330_CHIP_ID:
+               si_pmu1_pllinit0(sih, cc, xtalfreq);
+               break;
+       default:
+               break;
+       }
 
-               /* BCM5357 needs to touch PLL1_PLLCTL[02], so offset PLL0_PLLCTL[02] by 6 */
-               phypll_offset = (sih->chip == BCM5357_CHIP_ID) ? 6 : 0;
+       /* Return to original core */
+       ai_setcoreidx(sih, origidx);
+}
 
-               /* RMW only the P1 divider */
-               W_REG(&cc->pllcontrol_addr,
-                     PMU1_PLL0_PLLCTL0 + phypll_offset);
-               tmp = R_REG(&cc->pllcontrol_data);
-               tmp &= (~(PMU1_PLL0_PC0_P1DIV_MASK));
-               tmp |=
-                   (bcm5357_bcm43236_p1div[spuravoid] <<
-                    PMU1_PLL0_PC0_P1DIV_SHIFT);
-               W_REG(&cc->pllcontrol_data, tmp);
+/* initialize PMU resources */
+void si_pmu_res_init(si_t *sih)
+{
+       chipcregs_t *cc;
+       uint origidx;
+       const pmu_res_updown_t *pmu_res_updown_table = NULL;
+       uint pmu_res_updown_table_sz = 0;
+       const pmu_res_depend_t *pmu_res_depend_table = NULL;
+       uint pmu_res_depend_table_sz = 0;
+       u32 min_mask = 0, max_mask = 0;
+       char name[8], *val;
+       uint i, rsrcs;
 
-               /* RMW only the int feedback divider */
-               W_REG(&cc->pllcontrol_addr,
-                     PMU1_PLL0_PLLCTL2 + phypll_offset);
-               tmp = R_REG(&cc->pllcontrol_data);
-               tmp &= ~(PMU1_PLL0_PC2_NDIV_INT_MASK);
-               tmp |=
-                   (bcm5357_bcm43236_ndiv[spuravoid]) <<
-                   PMU1_PLL0_PC2_NDIV_INT_SHIFT;
-               W_REG(&cc->pllcontrol_data, tmp);
+       /* Remember original core before switch to chipc */
+       origidx = ai_coreidx(sih);
+       cc = ai_setcoreidx(sih, SI_CC_IDX);
 
-               tmp = 1 << 10;
+       switch (sih->chip) {
+       case BCM4329_CHIP_ID:
+               /* Optimize resources up/down timers */
+               if (ISSIM_ENAB(sih)) {
+                       pmu_res_updown_table = NULL;
+                       pmu_res_updown_table_sz = 0;
+               } else {
+                       pmu_res_updown_table = bcm4329_res_updown;
+                       pmu_res_updown_table_sz =
+                               ARRAY_SIZE(bcm4329_res_updown);
+               }
+               /* Optimize resources dependencies */
+               pmu_res_depend_table = bcm4329_res_depend;
+               pmu_res_depend_table_sz = ARRAY_SIZE(bcm4329_res_depend);
                break;
 
-       case BCM4331_CHIP_ID:
-               if (spuravoid == 2) {
-                       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0);
-                       W_REG(&cc->pllcontrol_data, 0x11500014);
-                       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2);
-                       W_REG(&cc->pllcontrol_data, 0x0FC00a08);
-               } else if (spuravoid == 1) {
-                       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0);
-                       W_REG(&cc->pllcontrol_data, 0x11500014);
-                       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2);
-                       W_REG(&cc->pllcontrol_data, 0x0F600a08);
+       case BCM4319_CHIP_ID:
+               /* Optimize resources up/down timers */
+               if (ISSIM_ENAB(sih)) {
+                       pmu_res_updown_table = bcm4319a0_res_updown_qt;
+                       pmu_res_updown_table_sz =
+                           ARRAY_SIZE(bcm4319a0_res_updown_qt);
                } else {
-                       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0);
-                       W_REG(&cc->pllcontrol_data, 0x11100014);
-                       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2);
-                       W_REG(&cc->pllcontrol_data, 0x03000a08);
+                       pmu_res_updown_table = bcm4319a0_res_updown;
+                       pmu_res_updown_table_sz =
+                           ARRAY_SIZE(bcm4319a0_res_updown);
                }
-               tmp = 1 << 10;
+               /* Optimize resources dependancies masks */
+               pmu_res_depend_table = bcm4319a0_res_depend;
+               pmu_res_depend_table_sz = ARRAY_SIZE(bcm4319a0_res_depend);
                break;
 
-       case BCM43224_CHIP_ID:
-       case BCM43225_CHIP_ID:
-       case BCM43421_CHIP_ID:
-       case BCM6362_CHIP_ID:
-               if (spuravoid == 1) {
-                       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0);
-                       W_REG(&cc->pllcontrol_data, 0x11500010);
-                       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL1);
-                       W_REG(&cc->pllcontrol_data, 0x000C0C06);
-                       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2);
-                       W_REG(&cc->pllcontrol_data, 0x0F600a08);
-                       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL3);
-                       W_REG(&cc->pllcontrol_data, 0x00000000);
-                       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL4);
-                       W_REG(&cc->pllcontrol_data, 0x2001E920);
-                       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL5);
-                       W_REG(&cc->pllcontrol_data, 0x88888815);
+       case BCM4336_CHIP_ID:
+               /* Optimize resources up/down timers */
+               if (ISSIM_ENAB(sih)) {
+                       pmu_res_updown_table = bcm4336a0_res_updown_qt;
+                       pmu_res_updown_table_sz =
+                           ARRAY_SIZE(bcm4336a0_res_updown_qt);
                } else {
-                       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0);
-                       W_REG(&cc->pllcontrol_data, 0x11100010);
-                       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL1);
-                       W_REG(&cc->pllcontrol_data, 0x000c0c06);
-                       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2);
-                       W_REG(&cc->pllcontrol_data, 0x03000a08);
-                       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL3);
-                       W_REG(&cc->pllcontrol_data, 0x00000000);
-                       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL4);
-                       W_REG(&cc->pllcontrol_data, 0x200005c0);
-                       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL5);
-                       W_REG(&cc->pllcontrol_data, 0x88888815);
+                       pmu_res_updown_table = bcm4336a0_res_updown;
+                       pmu_res_updown_table_sz =
+                           ARRAY_SIZE(bcm4336a0_res_updown);
                }
-               tmp = 1 << 10;
+               /* Optimize resources dependancies masks */
+               pmu_res_depend_table = bcm4336a0_res_depend;
+               pmu_res_depend_table_sz = ARRAY_SIZE(bcm4336a0_res_depend);
                break;
 
-               W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0);
-               W_REG(&cc->pllcontrol_data, 0x11100008);
-               W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL1);
-               W_REG(&cc->pllcontrol_data, 0x0c000c06);
-               W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2);
-               W_REG(&cc->pllcontrol_data, 0x03000a08);
-               W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL3);
-               W_REG(&cc->pllcontrol_data, 0x00000000);
-               W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL4);
-               W_REG(&cc->pllcontrol_data, 0x200005c0);
-               W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL5);
-               W_REG(&cc->pllcontrol_data, 0x88888855);
+       case BCM4330_CHIP_ID:
+               /* Optimize resources up/down timers */
+               if (ISSIM_ENAB(sih)) {
+                       pmu_res_updown_table = bcm4330a0_res_updown_qt;
+                       pmu_res_updown_table_sz =
+                           ARRAY_SIZE(bcm4330a0_res_updown_qt);
+               } else {
+                       pmu_res_updown_table = bcm4330a0_res_updown;
+                       pmu_res_updown_table_sz =
+                           ARRAY_SIZE(bcm4330a0_res_updown);
+               }
+               /* Optimize resources dependancies masks */
+               pmu_res_depend_table = bcm4330a0_res_depend;
+               pmu_res_depend_table_sz = ARRAY_SIZE(bcm4330a0_res_depend);
+               break;
 
-               tmp = 1 << 10;
+       default:
                break;
+       }
 
-       case BCM4716_CHIP_ID:
-       case BCM4748_CHIP_ID:
-       case BCM47162_CHIP_ID:
-               if (spuravoid == 1) {
-                       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0);
-                       W_REG(&cc->pllcontrol_data, 0x11500060);
-                       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL1);
-                       W_REG(&cc->pllcontrol_data, 0x080C0C06);
-                       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2);
-                       W_REG(&cc->pllcontrol_data, 0x0F600000);
-                       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL3);
-                       W_REG(&cc->pllcontrol_data, 0x00000000);
-                       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL4);
-                       W_REG(&cc->pllcontrol_data, 0x2001E924);
-                       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL5);
-                       W_REG(&cc->pllcontrol_data, 0x88888815);
-               } else {
-                       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0);
-                       W_REG(&cc->pllcontrol_data, 0x11100060);
-                       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL1);
-                       W_REG(&cc->pllcontrol_data, 0x080c0c06);
-                       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2);
-                       W_REG(&cc->pllcontrol_data, 0x03000000);
-                       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL3);
-                       W_REG(&cc->pllcontrol_data, 0x00000000);
-                       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL4);
-                       W_REG(&cc->pllcontrol_data, 0x200005c0);
-                       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL5);
-                       W_REG(&cc->pllcontrol_data, 0x88888815);
+       /* # resources */
+       rsrcs = (sih->pmucaps & PCAP_RC_MASK) >> PCAP_RC_SHIFT;
+
+       /* Program up/down timers */
+       while (pmu_res_updown_table_sz--) {
+               W_REG(&cc->res_table_sel,
+                     pmu_res_updown_table[pmu_res_updown_table_sz].resnum);
+               W_REG(&cc->res_updn_timer,
+                     pmu_res_updown_table[pmu_res_updown_table_sz].updown);
+       }
+       /* Apply nvram overrides to up/down timers */
+       for (i = 0; i < rsrcs; i++) {
+               snprintf(name, sizeof(name), "r%dt", i);
+               val = getvar(NULL, name);
+               if (val == NULL)
+                       continue;
+               W_REG(&cc->res_table_sel, (u32) i);
+               W_REG(&cc->res_updn_timer,
+                     (u32) simple_strtoul(val, NULL, 0));
+       }
+
+       /* Program resource dependencies table */
+       while (pmu_res_depend_table_sz--) {
+               if (pmu_res_depend_table[pmu_res_depend_table_sz].filter != NULL
+                   && !(pmu_res_depend_table[pmu_res_depend_table_sz].
+                        filter) (sih))
+                       continue;
+               for (i = 0; i < rsrcs; i++) {
+                       if ((pmu_res_depend_table[pmu_res_depend_table_sz].
+                            res_mask & PMURES_BIT(i)) == 0)
+                               continue;
+                       W_REG(&cc->res_table_sel, i);
+                       switch (pmu_res_depend_table[pmu_res_depend_table_sz].
+                               action) {
+                       case RES_DEPEND_SET:
+                               W_REG(&cc->res_dep_mask,
+                                     pmu_res_depend_table
+                                     [pmu_res_depend_table_sz].depend_mask);
+                               break;
+                       case RES_DEPEND_ADD:
+                               OR_REG(&cc->res_dep_mask,
+                                      pmu_res_depend_table
+                                      [pmu_res_depend_table_sz].depend_mask);
+                               break;
+                       case RES_DEPEND_REMOVE:
+                               AND_REG(&cc->res_dep_mask,
+                                       ~pmu_res_depend_table
+                                       [pmu_res_depend_table_sz].depend_mask);
+                               break;
+                       default:
+                               break;
+                       }
                }
+       }
+       /* Apply nvram overrides to dependancies masks */
+       for (i = 0; i < rsrcs; i++) {
+               snprintf(name, sizeof(name), "r%dd", i);
+               val = getvar(NULL, name);
+               if (val == NULL)
+                       continue;
+               W_REG(&cc->res_table_sel, (u32) i);
+               W_REG(&cc->res_dep_mask,
+                     (u32) simple_strtoul(val, NULL, 0));
+       }
 
-               tmp = 3 << 9;
-               break;
+       /* Determine min/max rsrc masks */
+       si_pmu_res_masks(sih, &min_mask, &max_mask);
 
-       case BCM4319_CHIP_ID:
-               W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0);
-               W_REG(&cc->pllcontrol_data, 0x11100070);
-               W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL1);
-               W_REG(&cc->pllcontrol_data, 0x1014140a);
-               W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL5);
-               W_REG(&cc->pllcontrol_data, 0x88888854);
+       /* It is required to program max_mask first and then min_mask */
 
-               if (spuravoid == 1) {   /* spur_avoid ON, enable 41/82/164Mhz clock mode */
-                       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2);
-                       W_REG(&cc->pllcontrol_data, 0x05201828);
-               } else {        /* enable 40/80/160Mhz clock mode */
-                       W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2);
-                       W_REG(&cc->pllcontrol_data, 0x05001828);
-               }
-               break;
-       case BCM4336_CHIP_ID:
-               /* Looks like these are only for default xtal freq 26MHz */
-               W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0);
-               W_REG(&cc->pllcontrol_data, 0x02100020);
+       /* Program max resource mask */
 
-               W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL1);
-               W_REG(&cc->pllcontrol_data, 0x0C0C0C0C);
+       if (max_mask)
+               W_REG(&cc->max_res_mask, max_mask);
 
-               W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2);
-               W_REG(&cc->pllcontrol_data, 0x01240C0C);
+       /* Program min resource mask */
 
-               W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL4);
-               W_REG(&cc->pllcontrol_data, 0x202C2820);
+       if (min_mask)
+               W_REG(&cc->min_res_mask, min_mask);
 
-               W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL5);
-               W_REG(&cc->pllcontrol_data, 0x88888825);
+       /* Add some delay; allow resources to come up and settle. */
+       mdelay(2);
 
-               W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL3);
-               if (spuravoid == 1) {
-                       W_REG(&cc->pllcontrol_data, 0x00EC4EC4);
-               } else {
-                       W_REG(&cc->pllcontrol_data, 0x00762762);
-               }
+       /* Return to original core */
+       ai_setcoreidx(sih, origidx);
+}
 
-               tmp = PCTL_PLL_PLLCTL_UPD;
-               break;
+u32 si_pmu_measure_alpclk(si_t *sih)
+{
+       chipcregs_t *cc;
+       uint origidx;
+       u32 alp_khz;
 
-       default:
-               PMU_ERROR(("%s: unknown spuravoidance settings for chip %s, not changing PLL\n", __func__, bcm_chipname(sih->chip, chn, 8)));
-               break;
-       }
+       if (sih->pmurev < 10)
+               return 0;
 
-       tmp |= R_REG(&cc->pmucontrol);
-       W_REG(&cc->pmucontrol, tmp);
+       /* Remember original core before switch to chipc */
+       origidx = ai_coreidx(sih);
+       cc = ai_setcoreidx(sih, SI_CC_IDX);
+
+       if (R_REG(&cc->pmustatus) & PST_EXTLPOAVAIL) {
+               u32 ilp_ctr, alp_hz;
+
+               /*
+                * Enable the reg to measure the freq,
+                * in case it was disabled before
+                */
+               W_REG(&cc->pmu_xtalfreq,
+                     1U << PMU_XTALFREQ_REG_MEASURE_SHIFT);
+
+               /* Delay for well over 4 ILP clocks */
+               udelay(1000);
+
+               /* Read the latched number of ALP ticks per 4 ILP ticks */
+               ilp_ctr =
+                   R_REG(&cc->pmu_xtalfreq) & PMU_XTALFREQ_REG_ILPCTR_MASK;
+
+               /*
+                * Turn off the PMU_XTALFREQ_REG_MEASURE_SHIFT
+                * bit to save power
+                */
+               W_REG(&cc->pmu_xtalfreq, 0);
+
+               /* Calculate ALP frequency */
+               alp_hz = (ilp_ctr * EXT_ILP_HZ) / 4;
+
+               /*
+                * Round to nearest 100KHz, and at
+                * the same time convert to KHz
+                */
+               alp_khz = (alp_hz + 50000) / 100000 * 100;
+       } else
+               alp_khz = 0;
+
+       /* Return to original core */
+       ai_setcoreidx(sih, origidx);
+
+       return alp_khz;
 }
 
 bool si_pmu_is_otp_powered(si_t *sih)
@@ -2447,9 +1829,8 @@ bool si_pmu_is_otp_powered(si_t *sih)
        bool st;
 
        /* Remember original core before switch to chipc */
-       idx = si_coreidx(sih);
-       cc = si_setcoreidx(sih, SI_CC_IDX);
-       ASSERT(cc != NULL);
+       idx = ai_coreidx(sih);
+       cc = ai_setcoreidx(sih, SI_CC_IDX);
 
        switch (sih->chip) {
        case BCM4329_CHIP_ID:
@@ -2486,190 +1867,63 @@ bool si_pmu_is_otp_powered(si_t *sih)
        }
 
        /* Return to original core */
-       si_setcoreidx(sih, idx);
+       ai_setcoreidx(sih, idx);
        return st;
 }
 
-void si_pmu_sprom_enable(si_t *sih, bool enable)
+/* power up/down OTP through PMU resources */
+void si_pmu_otp_power(si_t *sih, bool on)
 {
        chipcregs_t *cc;
        uint origidx;
+       u32 rsrcs = 0;  /* rsrcs to turn on/off OTP power */
 
-       /* Remember original core before switch to chipc */
-       origidx = si_coreidx(sih);
-       cc = si_setcoreidx(sih, SI_CC_IDX);
-       ASSERT(cc != NULL);
-
-       /* Return to original core */
-       si_setcoreidx(sih, origidx);
-}
-
-/* initialize PMU chip controls and other chip level stuff */
-void si_pmu_chip_init(si_t *sih)
-{
-       uint origidx;
-
-       ASSERT(sih->cccaps & CC_CAP_PMU);
-
-#ifdef CHIPC_UART_ALWAYS_ON
-       si_corereg(sih, SI_CC_IDX, offsetof(chipcregs_t, clk_ctl_st),
-                  CCS_FORCEALP, CCS_FORCEALP);
-#endif                         /* CHIPC_UART_ALWAYS_ON */
-
-       /* Gate off SPROM clock and chip select signals */
-       si_pmu_sprom_enable(sih, false);
-
-       /* Remember original core */
-       origidx = si_coreidx(sih);
-
-       /* Return to original core */
-       si_setcoreidx(sih, origidx);
-}
+       /* Don't do anything if OTP is disabled */
+       if (ai_is_otp_disabled(sih))
+               return;
 
-/* initialize PMU switch/regulators */
-void si_pmu_swreg_init(si_t *sih)
-{
-       ASSERT(sih->cccaps & CC_CAP_PMU);
+       /* Remember original core before switch to chipc */
+       origidx = ai_coreidx(sih);
+       cc = ai_setcoreidx(sih, SI_CC_IDX);
 
        switch (sih->chip) {
+       case BCM4329_CHIP_ID:
+               rsrcs = PMURES_BIT(RES4329_OTP_PU);
+               break;
+       case BCM4319_CHIP_ID:
+               rsrcs = PMURES_BIT(RES4319_OTP_PU);
+               break;
        case BCM4336_CHIP_ID:
-               /* Reduce CLDO PWM output voltage to 1.2V */
-               si_pmu_set_ldo_voltage(sih, SET_LDO_VOLTAGE_CLDO_PWM, 0xe);
-               /* Reduce CLDO BURST output voltage to 1.2V */
-               si_pmu_set_ldo_voltage(sih, SET_LDO_VOLTAGE_CLDO_BURST,
-                                      0xe);
-               /* Reduce LNLDO1 output voltage to 1.2V */
-               si_pmu_set_ldo_voltage(sih, SET_LDO_VOLTAGE_LNLDO1, 0xe);
-               if (sih->chiprev == 0)
-                       si_pmu_regcontrol(sih, 2, 0x400000, 0x400000);
+               rsrcs = PMURES_BIT(RES4336_OTP_PU);
                break;
-
        case BCM4330_CHIP_ID:
-               /* CBUCK Voltage is 1.8 by default and set that to 1.5 */
-               si_pmu_set_ldo_voltage(sih, SET_LDO_VOLTAGE_CBUCK_PWM, 0);
+               rsrcs = PMURES_BIT(RES4330_OTP_PU);
                break;
        default:
                break;
        }
-}
-
-void si_pmu_radio_enable(si_t *sih, bool enable)
-{
-       ASSERT(sih->cccaps & CC_CAP_PMU);
-
-       switch (sih->chip) {
-       case BCM4319_CHIP_ID:
-               if (enable)
-                       si_write_wrapperreg(sih, AI_OOBSELOUTB74,
-                                           (u32) 0x868584);
-               else
-                       si_write_wrapperreg(sih, AI_OOBSELOUTB74,
-                                           (u32) 0x060584);
-               break;
-       }
-}
-
-/* Wait for a particular clock level to be on the backplane */
-u32
-si_pmu_waitforclk_on_backplane(si_t *sih, u32 clk, u32 delay)
-{
-       chipcregs_t *cc;
-       uint origidx;
-
-       ASSERT(sih->cccaps & CC_CAP_PMU);
-
-       /* Remember original core before switch to chipc */
-       origidx = si_coreidx(sih);
-       cc = si_setcoreidx(sih, SI_CC_IDX);
-       ASSERT(cc != NULL);
-
-       if (delay)
-               SPINWAIT(((R_REG(&cc->pmustatus) & clk) != clk), delay);
-
-       /* Return to original core */
-       si_setcoreidx(sih, origidx);
-
-       return R_REG(&cc->pmustatus) & clk;
-}
-
-/*
- * Measures the ALP clock frequency in KHz.  Returns 0 if not possible.
- * Possible only if PMU rev >= 10 and there is an external LPO 32768Hz crystal.
- */
-
-#define EXT_ILP_HZ 32768
-
-u32 si_pmu_measure_alpclk(si_t *sih)
-{
-       chipcregs_t *cc;
-       uint origidx;
-       u32 alp_khz;
-
-       if (sih->pmurev < 10)
-               return 0;
-
-       ASSERT(sih->cccaps & CC_CAP_PMU);
-
-       /* Remember original core before switch to chipc */
-       origidx = si_coreidx(sih);
-       cc = si_setcoreidx(sih, SI_CC_IDX);
-       ASSERT(cc != NULL);
-
-       if (R_REG(&cc->pmustatus) & PST_EXTLPOAVAIL) {
-               u32 ilp_ctr, alp_hz;
 
-               /* Enable the reg to measure the freq, in case disabled before */
-               W_REG(&cc->pmu_xtalfreq,
-                     1U << PMU_XTALFREQ_REG_MEASURE_SHIFT);
-
-               /* Delay for well over 4 ILP clocks */
-               udelay(1000);
-
-               /* Read the latched number of ALP ticks per 4 ILP ticks */
-               ilp_ctr =
-                   R_REG(&cc->pmu_xtalfreq) & PMU_XTALFREQ_REG_ILPCTR_MASK;
-
-               /* Turn off the PMU_XTALFREQ_REG_MEASURE_SHIFT bit to save power */
-               W_REG(&cc->pmu_xtalfreq, 0);
+       if (rsrcs != 0) {
+               u32 otps;
 
-               /* Calculate ALP frequency */
-               alp_hz = (ilp_ctr * EXT_ILP_HZ) / 4;
+               /* Figure out the dependancies (exclude min_res_mask) */
+               u32 deps = si_pmu_res_deps(sih, cc, rsrcs, true);
+               u32 min_mask = 0, max_mask = 0;
+               si_pmu_res_masks(sih, &min_mask, &max_mask);
+               deps &= ~min_mask;
+               /* Turn on/off the power */
+               if (on) {
+                       OR_REG(&cc->min_res_mask, (rsrcs | deps));
+                       SPINWAIT(!(R_REG(&cc->res_state) & rsrcs),
+                                PMU_MAX_TRANSITION_DLY);
+               } else {
+                       AND_REG(&cc->min_res_mask, ~(rsrcs | deps));
+               }
 
-               /* Round to nearest 100KHz, and at the same time convert to KHz */
-               alp_khz = (alp_hz + 50000) / 100000 * 100;
-       } else
-               alp_khz = 0;
+               SPINWAIT((((otps = R_REG(&cc->otpstatus)) & OTPS_READY) !=
+                         (on ? OTPS_READY : 0)), 100);
+       }
 
        /* Return to original core */
-       si_setcoreidx(sih, origidx);
-
-       return alp_khz;
-}
-
-static void si_pmu_set_4330_plldivs(si_t *sih)
-{
-       u32 FVCO = si_pmu1_pllfvco0(sih) / 1000;
-       u32 m1div, m2div, m3div, m4div, m5div, m6div;
-       u32 pllc1, pllc2;
-
-       m2div = m3div = m4div = m6div = FVCO / 80;
-       m5div = FVCO / 160;
-
-       if (CST4330_CHIPMODE_SDIOD(sih->chipst))
-               m1div = FVCO / 80;
-       else
-               m1div = FVCO / 90;
-       pllc1 =
-           (m1div << PMU1_PLL0_PC1_M1DIV_SHIFT) | (m2div <<
-                                                   PMU1_PLL0_PC1_M2DIV_SHIFT) |
-           (m3div << PMU1_PLL0_PC1_M3DIV_SHIFT) | (m4div <<
-                                                   PMU1_PLL0_PC1_M4DIV_SHIFT);
-       si_pmu_pllcontrol(sih, PMU1_PLL0_PLLCTL1, ~0, pllc1);
-
-       pllc2 = si_pmu_pllcontrol(sih, PMU1_PLL0_PLLCTL1, 0, 0);
-       pllc2 &= ~(PMU1_PLL0_PC2_M5DIV_MASK | PMU1_PLL0_PC2_M6DIV_MASK);
-       pllc2 |=
-           ((m5div << PMU1_PLL0_PC2_M5DIV_SHIFT) |
-            (m6div << PMU1_PLL0_PC2_M6DIV_SHIFT));
-       si_pmu_pllcontrol(sih, PMU1_PLL0_PLLCTL2, ~0, pllc2);
+       ai_setcoreidx(sih, origidx);
 }
similarity index 77%
rename from drivers/staging/brcm80211/include/hndpmu.h
rename to drivers/staging/brcm80211/brcmsmac/wlc_pmu.h
index 3eea1f9fbc390005743376045e0afdb53021b057..bd5b809b2e31965a116eb99edac785ae6fda1e9e 100644 (file)
  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-#ifndef _hndpmu_h_
-#define _hndpmu_h_
 
+#ifndef WLC_PMU_H_
+#define WLC_PMU_H_
+
+#include <linux/types.h>
+
+#include <aiutils.h>
+
+/*
+ * LDO selections used in si_pmu_set_ldo_voltage
+ */
 #define SET_LDO_VOLTAGE_LDO1   1
 #define SET_LDO_VOLTAGE_LDO2   2
 #define SET_LDO_VOLTAGE_LDO3   3
 #define SET_LDO_VOLTAGE_LNLDO1 9
 #define SET_LDO_VOLTAGE_LNLDO2_SEL     10
 
+extern void si_pmu_set_ldo_voltage(si_t *sih, u8 ldo, u8 voltage);
+extern u16 si_pmu_fast_pwrup_delay(si_t *sih);
+extern void si_pmu_sprom_enable(si_t *sih, bool enable);
+extern u32 si_pmu_chipcontrol(si_t *sih, uint reg, u32 mask, u32 val);
+extern u32 si_pmu_regcontrol(si_t *sih, uint reg, u32 mask, u32 val);
+extern u32 si_pmu_ilp_clock(si_t *sih);
+extern u32 si_pmu_alp_clock(si_t *sih);
+extern void si_pmu_pllupd(si_t *sih);
+extern void si_pmu_spuravoid(si_t *sih, u8 spuravoid);
+extern u32 si_pmu_pllcontrol(si_t *sih, uint reg, u32 mask, u32 val);
 extern void si_pmu_init(si_t *sih);
 extern void si_pmu_chip_init(si_t *sih);
 extern void si_pmu_pll_init(si_t *sih, u32 xtalfreq);
 extern void si_pmu_res_init(si_t *sih);
 extern void si_pmu_swreg_init(si_t *sih);
-
-extern u32 si_pmu_force_ilp(si_t *sih, bool force);
-
-extern u32 si_pmu_si_clock(si_t *sih);
-extern u32 si_pmu_cpu_clock(si_t *sih);
-extern u32 si_pmu_mem_clock(si_t *sih);
-extern u32 si_pmu_alp_clock(si_t *sih);
-extern u32 si_pmu_ilp_clock(si_t *sih);
-
-extern void si_pmu_set_switcher_voltage(si_t *sih,
-                                       u8 bb_voltage, u8 rf_voltage);
-extern void si_pmu_set_ldo_voltage(si_t *sih, u8 ldo, u8 voltage);
-extern u16 si_pmu_fast_pwrup_delay(si_t *sih);
-extern void si_pmu_rcal(si_t *sih);
-extern void si_pmu_pllupd(si_t *sih);
-extern void si_pmu_spuravoid(si_t *sih, u8 spuravoid);
-
-extern bool si_pmu_is_otp_powered(si_t *sih);
 extern u32 si_pmu_measure_alpclk(si_t *sih);
-
-extern u32 si_pmu_chipcontrol(si_t *sih, uint reg, u32 mask, u32 val);
-extern u32 si_pmu_regcontrol(si_t *sih, uint reg, u32 mask, u32 val);
-extern u32 si_pmu_pllcontrol(si_t *sih, uint reg, u32 mask, u32 val);
-extern void si_pmu_pllupd(si_t *sih);
-extern void si_pmu_sprom_enable(si_t *sih, bool enable);
-
-extern void si_pmu_radio_enable(si_t *sih, bool enable);
-extern u32 si_pmu_waitforclk_on_backplane(si_t *sih, u32 clk, u32 delay);
-
+extern bool si_pmu_is_otp_powered(si_t *sih);
 extern void si_pmu_otp_power(si_t *sih, bool on);
-extern void si_sdiod_drive_strength_init(si_t *sih, u32 drivestrength);
 
-#endif                         /* _hndpmu_h_ */
+#endif /* WLC_PMU_H_ */
index b956c23fa467e0dca5da6d959c7b0cf8754154d7..9334deacda12d42d512afa7097ac46b5fe7c63d2 100644 (file)
  */
 #define WLC_TXPWR_MAX          (127)   /* ~32 dBm = 1,500 mW */
 
+/* rate related definitions */
+#define        WLC_RATE_FLAG   0x80    /* Flag to indicate it is a basic rate */
+#define        WLC_RATE_MASK   0x7f    /* Rate value mask w/o basic rate flag */
+
 /* legacy rx Antenna diversity for SISO rates */
 #define        ANT_RX_DIV_FORCE_0              0       /* Use antenna 0 */
 #define        ANT_RX_DIV_FORCE_1              1       /* Use antenna 1 */
@@ -92,6 +96,8 @@
 #define AIDMAPSZ       (roundup(MAXSCB, NBBY)/NBBY)    /* aid bitmap size in bytes */
 #endif                         /* AIDMAPSZ */
 
+struct ieee80211_tx_queue_params;
+
 typedef struct wlc_tunables {
        int ntxd;               /* size of tx descriptor table */
        int nrxd;               /* size of rx descriptor table */
@@ -478,7 +484,7 @@ extern const u8 wme_fifo2ac[];
 #define        WLC_PROT_N_OBSS         16      /* non-HT OBSS present */
 
 /* common functions for every port */
-extern void *wlc_attach(void *wl, u16 vendor, u16 device, uint unit,
+extern void *wlc_attach(struct wl_info *wl, u16 vendor, u16 device, uint unit,
                        bool piomode, void *regsva, uint bustype, void *btparam,
                        uint *perr);
 extern uint wlc_detach(struct wlc_info *wlc);
@@ -499,8 +505,6 @@ extern void wlc_intrsrestore(struct wlc_info *wlc, u32 macintmask);
 extern bool wlc_intrsupd(struct wlc_info *wlc);
 extern bool wlc_isr(struct wlc_info *wlc, bool *wantdpc);
 extern bool wlc_dpc(struct wlc_info *wlc, bool bounded);
-extern bool wlc_send80211_raw(struct wlc_info *wlc, struct wlc_if *wlcif,
-                             void *p, uint ac);
 extern bool wlc_sendpkt_mac80211(struct wlc_info *wlc, struct sk_buff *sdu,
                                 struct ieee80211_hw *hw);
 extern int wlc_iovar_op(struct wlc_info *wlc, const char *name, void *params,
@@ -508,6 +512,8 @@ extern int wlc_iovar_op(struct wlc_info *wlc, const char *name, void *params,
                        struct wlc_if *wlcif);
 extern int wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len,
                     struct wlc_if *wlcif);
+extern bool wlc_aggregatable(struct wlc_info *wlc, u8 tid);
+
 /* helper functions */
 extern void wlc_statsupd(struct wlc_info *wlc);
 extern void wlc_protection_upd(struct wlc_info *wlc, uint idx, int val);
@@ -515,24 +521,14 @@ extern int wlc_get_header_len(void);
 extern void wlc_mac_bcn_promisc_change(struct wlc_info *wlc, bool promisc);
 extern void wlc_set_addrmatch(struct wlc_info *wlc, int match_reg_offset,
                              const u8 *addr);
-extern void wlc_wme_setparams(struct wlc_info *wlc, u16 aci, void *arg,
+extern void wlc_wme_setparams(struct wlc_info *wlc, u16 aci,
+                             const struct ieee80211_tx_queue_params *arg,
                              bool suspend);
-
 extern struct wlc_pub *wlc_pub(void *wlc);
 
 /* common functions for every port */
-extern int wlc_bmac_up_prep(struct wlc_hw_info *wlc_hw);
-extern int wlc_bmac_up_finish(struct wlc_hw_info *wlc_hw);
-extern int wlc_bmac_down_prep(struct wlc_hw_info *wlc_hw);
-extern int wlc_bmac_down_finish(struct wlc_hw_info *wlc_hw);
-
-extern u32 wlc_reg_read(struct wlc_info *wlc, void *r, uint size);
-extern void wlc_reg_write(struct wlc_info *wlc, void *r, u32 v, uint size);
-extern void wlc_corereset(struct wlc_info *wlc, u32 flags);
 extern void wlc_mhf(struct wlc_info *wlc, u8 idx, u16 mask, u16 val,
                    int bands);
-extern u16 wlc_mhf_get(struct wlc_info *wlc, u8 idx, int bands);
-extern u32 wlc_delta_txfunfl(struct wlc_info *wlc, int fifo);
 extern void wlc_rate_lookup_init(struct wlc_info *wlc, wlc_rateset_t *rateset);
 extern void wlc_default_rateset(struct wlc_info *wlc, wlc_rateset_t *rs);
 
@@ -543,11 +539,8 @@ extern void wlc_ampdu_flush(struct wlc_info *wlc, struct ieee80211_sta *sta,
 /* wlc_phy.c helper functions */
 extern void wlc_set_ps_ctrl(struct wlc_info *wlc);
 extern void wlc_mctrl(struct wlc_info *wlc, u32 mask, u32 val);
-extern void wlc_scb_ratesel_init_all(struct wlc_info *wlc);
 
 /* ioctl */
-extern int wlc_iovar_gets8(struct wlc_info *wlc, const char *name,
-                            s8 *arg);
 extern int wlc_iovar_check(struct wlc_pub *pub, const bcm_iovar_t *vi,
                           void *arg,
                           int len, bool set);
@@ -562,31 +555,12 @@ extern void wlc_enable_mac(struct wlc_info *wlc);
 extern void wlc_associate_upd(struct wlc_info *wlc, bool state);
 extern void wlc_scan_start(struct wlc_info *wlc);
 extern void wlc_scan_stop(struct wlc_info *wlc);
-
-static inline int wlc_iovar_getuint(struct wlc_info *wlc, const char *name,
-                                   uint *arg)
-{
-       return wlc_iovar_getint(wlc, name, (int *)arg);
-}
-
-static inline int wlc_iovar_getu8(struct wlc_info *wlc, const char *name,
-                                    u8 *arg)
-{
-       return wlc_iovar_gets8(wlc, name, (s8 *) arg);
-}
-
-static inline int wlc_iovar_setuint(struct wlc_info *wlc, const char *name,
-                                   uint arg)
-{
-       return wlc_iovar_setint(wlc, name, (int)arg);
-}
+extern int wlc_get_curband(struct wlc_info *wlc);
+extern void wlc_wait_for_tx_completion(struct wlc_info *wlc, bool drop);
 
 #if defined(BCMDBG)
 extern int wlc_iocregchk(struct wlc_info *wlc, uint band);
 #endif
-#if defined(BCMDBG)
-extern int wlc_iocpichk(struct wlc_info *wlc, uint phytype);
-#endif
 
 /* helper functions */
 extern bool wlc_check_radio_disabled(struct wlc_info *wlc);
index d284f1ac49cc3a654813e8b74c6763e091a1e019..87b252d6a7f5860ac71a2dd1e8fc5ce00ffb4255 100644 (file)
@@ -19,7 +19,7 @@
 #include <proto/802.11.h>
 #include <bcmdefs.h>
 #include <bcmutils.h>
-#include <siutils.h>
+#include <aiutils.h>
 #include <wlioctl.h>
 #include <sbhnddma.h>
 
@@ -304,7 +304,7 @@ wlc_rate_hwrs_filter_sort_validate(wlc_rateset_t *rs,
 
        for (i = 0; i < count; i++) {
                /* mask off "basic rate" bit, WLC_RATE_FLAG */
-               r = (int)rs->rates[i] & RATE_MASK;
+               r = (int)rs->rates[i] & WLC_RATE_MASK;
                if ((r > WLC_MAXRATE) || (rate_info[r] == 0)) {
                        continue;
                }
@@ -314,8 +314,7 @@ wlc_rate_hwrs_filter_sort_validate(wlc_rateset_t *rs,
        /* fill out the rates in order, looking at only supported rates */
        count = 0;
        for (i = 0; i < hw_rs->count; i++) {
-               r = hw_rs->rates[i] & RATE_MASK;
-               ASSERT(r <= WLC_MAXRATE);
+               r = hw_rs->rates[i] & WLC_RATE_MASK;
                if (rateset[r])
                        rs->rates[count++] = rateset[r];
        }
@@ -333,7 +332,7 @@ wlc_rate_hwrs_filter_sort_validate(wlc_rateset_t *rs,
 }
 
 /* calculate the rate of a rx'd frame and return it as a ratespec */
-ratespec_t BCMFASTPATH wlc_compute_rspec(d11rxhdr_t *rxh, u8 *plcp)
+ratespec_t wlc_compute_rspec(d11rxhdr_t *rxh, u8 *plcp)
 {
        int phy_type;
        ratespec_t rspec = PHY_TXC1_BW_20MHZ << RSPEC_BW_SHIFT;
@@ -364,8 +363,7 @@ ratespec_t BCMFASTPATH wlc_compute_rspec(d11rxhdr_t *rxh, u8 *plcp)
                case PRXS0_STDN:
                        /* fallthru */
                default:
-                       /* not supported */
-                       ASSERT(0);
+                       /* not supported, error condition */
                        break;
                }
                if (PLCP3_ISSGI(plcp[3]))
@@ -407,9 +405,9 @@ wlc_rateset_filter(wlc_rateset_t *src, wlc_rateset_t *dst, bool basic_only,
                r = src->rates[i];
                if (basic_only && !(r & WLC_RATE_FLAG))
                        continue;
-               if ((rates == WLC_RATES_CCK) && IS_OFDM((r & RATE_MASK)))
+               if ((rates == WLC_RATES_CCK) && IS_OFDM((r & WLC_RATE_MASK)))
                        continue;
-               if ((rates == WLC_RATES_OFDM) && IS_CCK((r & RATE_MASK)))
+               if ((rates == WLC_RATES_OFDM) && IS_CCK((r & WLC_RATE_MASK)))
                        continue;
                dst->rates[count++] = r & xmask;
        }
@@ -451,7 +449,7 @@ wlc_rateset_default(wlc_rateset_t *rs_tgt, const wlc_rateset_t *rs_hw,
        } else if (PHYTYPE_IS(phy_type, PHY_TYPE_G)) {
                rs_dflt = &cck_ofdm_rates;
        } else {
-               ASSERT(0);      /* should not happen */
+               /* should not happen, error condition */
                rs_dflt = &cck_rates;   /* force cck */
        }
 
@@ -468,7 +466,7 @@ wlc_rateset_default(wlc_rateset_t *rs_tgt, const wlc_rateset_t *rs_hw,
                                           mcsallow ? txstreams : 1);
 }
 
-s16 BCMFASTPATH wlc_rate_legacy_phyctl(uint rate)
+s16 wlc_rate_legacy_phyctl(uint rate)
 {
        uint i;
        for (i = 0; i < LEGACY_PHYCFG_TABLE_SIZE; i++)
index 25ba2a4236399b64095a4c6289c962f50a8c90eb..5575e83bdc694aedb1644d8af63f822f5e16b855 100644 (file)
@@ -54,11 +54,8 @@ extern const mcs_info_t mcs_table[];
        (_is40 ? mcs_table[_mcs].phy_rate_40 : mcs_table[_mcs].phy_rate_20))
 #define VALID_MCS(_mcs)        ((_mcs < MCS_TABLE_SIZE))
 
-#define        WLC_RATE_FLAG   0x80    /* Rate flag: basic or ofdm */
-
-/* Macros to use the rate_info table */
-#define        RATE_MASK       0x7f    /* Rate value mask w/o basic rate flag */
-#define        RATE_MASK_FULL  0xff    /* Rate value mask with basic rate flag */
+/* Macro to use the rate_info table */
+#define        WLC_RATE_MASK_FULL 0xff /* Rate value mask with basic rate flag */
 
 #define WLC_RATE_500K_TO_BPS(rate)     ((rate) * 500000)       /* convert 500kbps to bps */
 
@@ -115,9 +112,11 @@ typedef u32 ratespec_t;
 /* Rate info table; takes a legacy rate or ratespec_t */
 #define        IS_MCS(r)       (r & RSPEC_MIMORATE)
 #define        IS_OFDM(r)      (!IS_MCS(r) && (rate_info[(r) & RSPEC_RATE_MASK] & WLC_RATE_FLAG))
-#define        IS_CCK(r)       (!IS_MCS(r) && (((r) & RATE_MASK) == WLC_RATE_1M || \
-                        ((r) & RATE_MASK) == WLC_RATE_2M || \
-                        ((r) & RATE_MASK) == WLC_RATE_5M5 || ((r) & RATE_MASK) == WLC_RATE_11M))
+#define        IS_CCK(r)       (!IS_MCS(r) && ( \
+                        ((r) & WLC_RATE_MASK) == WLC_RATE_1M || \
+                        ((r) & WLC_RATE_MASK) == WLC_RATE_2M || \
+                        ((r) & WLC_RATE_MASK) == WLC_RATE_5M5 || \
+                        ((r) & WLC_RATE_MASK) == WLC_RATE_11M))
 #define IS_SINGLE_STREAM(mcs)  (((mcs) <= HIGHEST_SINGLE_STREAM_MCS) || ((mcs) == 32))
 #define CCK_RSPEC(cck)         ((cck) & RSPEC_RATE_MASK)
 #define OFDM_RSPEC(ofdm)       (((ofdm) & RSPEC_RATE_MASK) |\
index 73260068898f331ddce66bd09437fc768f9cc821..f07a891d5d2755ebc8a6b6cd45e075c55f0836c5 100644 (file)
@@ -17,8 +17,6 @@
 #ifndef _wlc_scb_h_
 #define _wlc_scb_h_
 
-extern bool wlc_aggregatable(struct wlc_info *wlc, u8 tid);
-
 #define AMPDU_TX_BA_MAX_WSIZE  64      /* max Tx ba window size (in pdu) */
 /* structure to store per-tid state for the ampdu initiator */
 typedef struct scb_ampdu_tid_ini {
index 098fd59ee15351dd0b83bd726e8b7526e5c72631..c4f58172182d61d724c417b17dd3e7795b5549cf 100644 (file)
 
 #include <bcmdefs.h>
 #include <bcmutils.h>
-#include <siutils.h>
+#include <aiutils.h>
 #include <wlioctl.h>
 #include <bcmwifi.h>
+#include <bcmnvram.h>
 #include <sbhnddma.h>
 
 #include "wlc_types.h"
@@ -69,9 +70,6 @@ const u8 txcore_default[5] = {
 
 static void wlc_stf_stbc_rx_ht_update(struct wlc_info *wlc, int val)
 {
-       ASSERT((val == HT_CAP_RX_STBC_NO)
-              || (val == HT_CAP_RX_STBC_ONE_STREAM));
-
        /* MIMOPHYs rev3-6 cannot receive STBC with only one rx core active */
        if (WLC_STF_SS_STBC_RX(wlc)) {
                if ((wlc->stf->rxstreams == 1) && (val != HT_CAP_RX_STBC_NO))
@@ -193,10 +191,8 @@ bool wlc_stf_stbc_rx_set(struct wlc_info *wlc, s32 int_val)
 
 static int wlc_stf_txcore_set(struct wlc_info *wlc, u8 Nsts, u8 core_mask)
 {
-       WL_TRACE("wl%d: %s: Nsts %d core_mask %x\n",
-                wlc->pub->unit, __func__, Nsts, core_mask);
-
-       ASSERT((Nsts > 0) && (Nsts <= MAX_STREAMS_SUPPORTED));
+       BCMMSG(wlc->wiphy, "wl%d: Nsts %d core_mask %x\n",
+                wlc->pub->unit, Nsts, core_mask);
 
        if (WLC_BITSCNT(core_mask) > wlc->stf->txstreams) {
                core_mask = 0;
@@ -208,8 +204,6 @@ static int wlc_stf_txcore_set(struct wlc_info *wlc, u8 Nsts, u8 core_mask)
                core_mask = wlc->stf->txchain;
        }
 
-       ASSERT(!core_mask || Nsts <= WLC_BITSCNT(core_mask));
-
        wlc->stf->txcore[Nsts] = core_mask;
        /* Nsts = 1..4, txcore index = 1..4 */
        if (Nsts == 1) {
@@ -225,7 +219,7 @@ static int wlc_stf_txcore_set(struct wlc_info *wlc, u8 Nsts, u8 core_mask)
                }
        }
 
-       return BCME_OK;
+       return 0;
 }
 
 static int wlc_stf_spatial_policy_set(struct wlc_info *wlc, int val)
@@ -233,7 +227,7 @@ static int wlc_stf_spatial_policy_set(struct wlc_info *wlc, int val)
        int i;
        u8 core_mask = 0;
 
-       WL_TRACE("wl%d: %s: val %x\n", wlc->pub->unit, __func__, val);
+       BCMMSG(wlc->wiphy, "wl%d: val %x\n", wlc->pub->unit, val);
 
        wlc->stf->spatial_policy = (s8) val;
        for (i = 1; i <= MAX_STREAMS_SUPPORTED; i++) {
@@ -241,7 +235,7 @@ static int wlc_stf_spatial_policy_set(struct wlc_info *wlc, int val)
                    wlc->stf->txchain : txcore_default[i];
                wlc_stf_txcore_set(wlc, (u8) i, core_mask);
        }
-       return BCME_OK;
+       return 0;
 }
 
 int wlc_stf_txchain_set(struct wlc_info *wlc, s32 int_val, bool force)
@@ -251,16 +245,16 @@ int wlc_stf_txchain_set(struct wlc_info *wlc, s32 int_val, bool force)
        uint i;
 
        if (wlc->stf->txchain == txchain)
-               return BCME_OK;
+               return 0;
 
        if ((txchain & ~wlc->stf->hw_txchain)
            || !(txchain & wlc->stf->hw_txchain))
-               return BCME_RANGE;
+               return -EINVAL;
 
        /* if nrate override is configured to be non-SISO STF mode, reject reducing txchain to 1 */
        txstreams = (u8) WLC_BITSCNT(txchain);
        if (txstreams > MAX_STREAMS_SUPPORTED)
-               return BCME_RANGE;
+               return -EINVAL;
 
        if (txstreams == 1) {
                for (i = 0; i < NBANDS(wlc); i++)
@@ -269,21 +263,25 @@ int wlc_stf_txchain_set(struct wlc_info *wlc, s32 int_val, bool force)
                            || (RSPEC_STF(wlc->bandstate[i]->mrspec_override) !=
                                PHY_TXC1_MODE_SISO)) {
                                if (!force)
-                                       return BCME_ERROR;
+                                       return -EBADE;
 
                                /* over-write the override rspec */
                                if (RSPEC_STF(wlc->bandstate[i]->rspec_override)
                                    != PHY_TXC1_MODE_SISO) {
                                        wlc->bandstate[i]->rspec_override = 0;
-                                       WL_ERROR("%s(): temp sense override non-SISO rspec_override\n",
-                                                __func__);
+                                       wiphy_err(wlc->wiphy, "%s(): temp "
+                                                 "sense override non-SISO "
+                                                 "rspec_override\n",
+                                                 __func__);
                                }
                                if (RSPEC_STF
                                    (wlc->bandstate[i]->mrspec_override) !=
                                    PHY_TXC1_MODE_SISO) {
                                        wlc->bandstate[i]->mrspec_override = 0;
-                                       WL_ERROR("%s(): temp sense override non-SISO mrspec_override\n",
-                                                __func__);
+                                       wiphy_err(wlc->wiphy, "%s(): temp "
+                                                 "sense override non-SISO "
+                                                 "mrspec_override\n",
+                                                 __func__);
                                }
                        }
        }
@@ -303,7 +301,7 @@ int wlc_stf_txchain_set(struct wlc_info *wlc, s32 int_val, bool force)
        for (i = 1; i <= MAX_STREAMS_SUPPORTED; i++)
                wlc_stf_txcore_set(wlc, (u8) i, txcore_default[i]);
 
-       return BCME_OK;
+       return 0;
 }
 
 /* update wlc->stf->ss_opmode which represents the operational stf_ss mode we're using */
@@ -319,9 +317,6 @@ int wlc_stf_ss_update(struct wlc_info *wlc, struct wlcband *band)
        if (WLC_STBC_CAP_PHY(wlc) &&
            wlc->stf->ss_algosel_auto
            && (wlc->stf->ss_algo_channel != (u16) -1)) {
-               ASSERT(isset(&wlc->stf->ss_algo_channel, PHY_TXC1_MODE_CDD)
-                      || isset(&wlc->stf->ss_algo_channel,
-                               PHY_TXC1_MODE_SISO));
                upd_stf_ss = (wlc->stf->no_cddstbc || (wlc->stf->txstreams == 1)
                              || isset(&wlc->stf->ss_algo_channel,
                                       PHY_TXC1_MODE_SISO)) ? PHY_TXC1_MODE_SISO
@@ -371,11 +366,11 @@ void wlc_stf_detach(struct wlc_info *wlc)
 
 int wlc_stf_ant_txant_validate(struct wlc_info *wlc, s8 val)
 {
-       int bcmerror = BCME_OK;
+       int bcmerror = 0;
 
        /* when there is only 1 tx_streams, don't allow to change the txant */
        if (WLCISNPHY(wlc->band) && (wlc->stf->txstreams == 1))
-               return ((val == wlc->stf->txant) ? bcmerror : BCME_RANGE);
+               return ((val == wlc->stf->txant) ? bcmerror : -EINVAL);
 
        switch (val) {
        case -1:
@@ -391,11 +386,11 @@ int wlc_stf_ant_txant_validate(struct wlc_info *wlc, s8 val)
                val = ANT_TX_LAST_RX;
                break;
        default:
-               bcmerror = BCME_RANGE;
+               bcmerror = -EINVAL;
                break;
        }
 
-       if (bcmerror == BCME_OK)
+       if (bcmerror == 0)
                wlc->stf->txant = (s8) val;
 
        return bcmerror;
@@ -421,9 +416,6 @@ static void _wlc_stf_phy_txant_upd(struct wlc_info *wlc)
        s8 txant;
 
        txant = (s8) wlc->stf->txant;
-       ASSERT(txant == ANT_TX_FORCE_0 || txant == ANT_TX_FORCE_1
-              || txant == ANT_TX_LAST_RX);
-
        if (WLC_PHY_11N_CAP(wlc->band)) {
                if (txant == ANT_TX_FORCE_0) {
                        wlc->stf->phytxant = PHY_TXC_ANT_0;
@@ -439,8 +431,8 @@ static void _wlc_stf_phy_txant_upd(struct wlc_info *wlc)
                        if (WLCISLCNPHY(wlc->band) || WLCISSSLPNPHY(wlc->band))
                                wlc->stf->phytxant = PHY_TXC_LCNPHY_ANT_LAST;
                        else {
-                               /* keep this assert to catch out of sync wlc->stf->txcore */
-                               ASSERT(wlc->stf->txchain > 0);
+                               /* catch out of sync wlc->stf->txcore */
+                               WARN_ON(wlc->stf->txchain <= 0);
                                wlc->stf->phytxant =
                                    wlc->stf->txchain << PHY_TXC_ANT_SHIFT;
                        }
@@ -504,7 +496,6 @@ static u16 _wlc_stf_phytxchain_sel(struct wlc_info *wlc, ratespec_t rspec)
        u16 phytxant = wlc->stf->phytxant;
 
        if (RSPEC_STF(rspec) != PHY_TXC1_MODE_SISO) {
-               ASSERT(wlc->stf->txstreams > 1);
                phytxant = wlc->stf->txchain << PHY_TXC_ANT_SHIFT;
        } else if (wlc->stf->txant == ANT_TX_DEF)
                phytxant = wlc->stf->txchain << PHY_TXC_ANT_SHIFT;
@@ -524,7 +515,6 @@ u16 wlc_stf_d11hdrs_phyctl_txant(struct wlc_info *wlc, ratespec_t rspec)
 
        /* for non-siso rates or default setting, use the available chains */
        if (WLCISNPHY(wlc->band)) {
-               ASSERT(wlc->stf->txchain != 0);
                phytxant = _wlc_stf_phytxchain_sel(wlc, rspec);
                mask = PHY_TXC_HTANT_MASK;
        }
index d33f0202cec44ea32e7d2ffbf324ec0c4b1c8c85..7e0ce8f2434827e64a66c4087b22e087b7a945d6 100644 (file)
@@ -292,7 +292,7 @@ typedef volatile struct _aidmp {
 #define        AI_OOBDINWIDTH          0x364
 #define        AI_OOBDOUTWIDTH         0x368
 
-#if    defined(IL_BIGENDIAN) && defined(BCMHND74K)
+#if    defined(__BIG_ENDIAN) && defined(BCMHND74K)
 /* Selective swapped defines for those registers we need in
  * big-endian code.
  */
@@ -303,7 +303,7 @@ typedef volatile struct _aidmp {
 #define        AI_RESETCTRL            0x804
 #define        AI_RESETSTATUS          0x800
 
-#else                          /* !IL_BIGENDIAN || !BCMHND74K */
+#else                          /* !__BIG_ENDIAN || !BCMHND74K */
 
 #define        AI_IOCTRLSET            0x400
 #define        AI_IOCTRLCLEAR          0x404
@@ -312,7 +312,7 @@ typedef volatile struct _aidmp {
 #define        AI_RESETCTRL            0x800
 #define        AI_RESETSTATUS          0x804
 
-#endif                         /* IL_BIGENDIAN && BCMHND74K */
+#endif                         /* __BIG_ENDIAN && BCMHND74K */
 
 #define        AI_IOCTRLWIDTH          0x700
 #define        AI_IOSTATUSWIDTH        0x704
index 22a389e1d511c4a8ce5fe85bc272b756a60299cd..55631f367436a4614096cc7ce4a57662a7935f2d 100644 (file)
 
 #define        AUTO    (-1)            /* Auto = -1 */
 
-#ifdef mips
-#define BCMFASTPATH            __attribute__ ((__section__(".text.fastpath")))
-#else
-#define BCMFASTPATH
-#endif
-
 /* Bus types */
 #define        SI_BUS                  0       /* SOC Interconnect */
 #define        PCI_BUS                 1       /* PCI target */
@@ -114,12 +108,6 @@ typedef struct {
 
 #define BCMEXTRAHDROOM 172
 
-#ifdef BCMDBG
-#ifndef BCMDBG_ASSERT
-#define BCMDBG_ASSERT
-#endif /* BCMDBG_ASSERT */
-#endif /* BCMDBG */
-
 /* Macros for doing definition and get/set of bitfields
  * Usage example, e.g. a three-bit field (bits 4-6):
  *    #define <NAME>_M BITFIELD_MASK(3)
index 075883a935291b58c832038e7fe400a5708edf97..26947efa83e8cd48e06979a549cb523f0361726f 100644 (file)
 #ifndef        _BCMDEVS_H
 #define        _BCMDEVS_H
 
-/* PCI vendor IDs */
-#define        VENDOR_BROADCOM         0x14e4
-
-/* DONGLE VID/PIDs */
-#define BCM_DNGL_VID           0x0a5c
-#define BCM_DNGL_BDC_PID       0x0bdc
-
 #define        BCM4325_D11DUAL_ID      0x431b
 #define        BCM4325_D11G_ID         0x431c
 #define        BCM4325_D11A_ID         0x431d
-#define BCM4329_D11N_ID                0x432e  /* 4329 802.11n dualband device */
+
 #define BCM4329_D11N2G_ID      0x432f  /* 4329 802.11n 2.4G device */
 #define BCM4329_D11N5G_ID      0x4330  /* 4329 802.11n 5G device */
 #define BCM4329_D11NDUAL_ID    0x432e
 #define BCM4319_D11N5G_ID      0x4339  /* 4319 802.11n 5G device */
 
 #define BCM43224_D11N_ID       0x4353  /* 43224 802.11n dualband device */
+
 #define BCM43225_D11N2G_ID     0x4357  /* 43225 802.11n 2.4GHz device */
 
 #define BCM43236_D11N_ID       0x4346  /* 43236 802.11n dualband device */
 #define BCM43236_D11N2G_ID     0x4347  /* 43236 802.11n 2.4GHz device */
-#define BCM43236_D11N5G_ID     0x4348  /* 43236 802.11n 5GHz device */
 
-#define BCM43421_D11N_ID       0xA99D  /* 43421 802.11n dualband device */
 #define BCM4313_D11N2G_ID      0x4727  /* 4313 802.11n 2.4G device */
-#define BCM4330_D11N_ID         0x4360 /* 4330 802.11n dualband device */
-#define BCM4330_D11N2G_ID       0x4361 /* 4330 802.11n 2.4G device */
-#define BCM4330_D11N5G_ID       0x4362 /* 4330 802.11n 5G device */
-#define BCM4336_D11N_ID                0x4343  /* 4336 802.11n 2.4GHz device */
-#define BCM6362_D11N_ID                0x435f  /* 6362 802.11n dualband device */
-#define BCM4331_D11N_ID                0x4331  /* 4331 802.11n dualband id */
-#define BCM4331_D11N2G_ID      0x4332  /* 4331 802.11n 2.4Ghz band id */
-#define BCM4331_D11N5G_ID      0x4333  /* 4331 802.11n 5Ghz band id */
 
 /* Chip IDs */
 #define BCM4313_CHIP_ID                0x4313  /* 4313 chip id */
@@ -60,7 +44,6 @@
 
 #define        BCM43224_CHIP_ID        43224   /* 43224 chipcommon chipid */
 #define        BCM43225_CHIP_ID        43225   /* 43225 chipcommon chipid */
-#define        BCM43228_CHIP_ID        43228   /* 43228 chipcommon chipid */
 #define        BCM43421_CHIP_ID        43421   /* 43421 chipcommon chipid */
 #define        BCM43235_CHIP_ID        43235   /* 43235 chipcommon chipid */
 #define        BCM43236_CHIP_ID        43236   /* 43236 chipcommon chipid */
 /* Package IDs */
 #define BCM4329_289PIN_PKG_ID  0       /* 4329 289-pin package id */
 #define BCM4329_182PIN_PKG_ID  1       /* 4329N 182-pin package id */
-#define        BCM4716_PKG_ID          8       /* 4716 package id */
 #define        BCM4717_PKG_ID          9       /* 4717 package id */
 #define        BCM4718_PKG_ID          10      /* 4718 package id */
-#define BCM5356_PKG_NONMODE    1       /* 5356 package without nmode suppport */
-#define BCM5358U_PKG_ID                8       /* 5358U package id */
-#define BCM5358_PKG_ID         9       /* 5358 package id */
-#define BCM47186_PKG_ID                10      /* 47186 package id */
-#define BCM5357_PKG_ID         11      /* 5357 package id */
-#define BCM5356U_PKG_ID                12      /* 5356U package id */
-#define HDLSIM5350_PKG_ID      1       /* HDL simulator package id for a 5350 */
 #define HDLSIM_PKG_ID          14      /* HDL simulator package id */
 #define HWSIM_PKG_ID           15      /* Hardware simulator package id */
-#define BCM43224_FAB_CSM       0x8     /* the chip is manufactured by CSM */
 #define BCM43224_FAB_SMIC      0xa     /* the chip is manufactured by SMIC */
-#define BCM4336_WLBGA_PKG_ID 0x8
 
 /* boardflags */
-#define        BFL_RESERVED1           0x00000001
 #define        BFL_PACTRL              0x00000002      /* Board has gpio 9 controlling the PA */
-#define        BFL_AIRLINEMODE         0x00000004      /* Board implements gpio 13 radio disable indication */
-#define        BFL_ADCDIV              0x00000008      /* Board has the rssi ADC divider */
-#define        BFL_ENETROBO            0x00000010      /* Board has robo switch or core */
 #define        BFL_NOPLLDOWN           0x00000020      /* Not ok to power down the chip pll and oscillator */
-#define        BFL_CCKHIPWR            0x00000040      /* Can do high-power CCK transmission */
-#define        BFL_ENETADM             0x00000080      /* Board has ADMtek switch */
-#define        BFL_ENETVLAN            0x00000100      /* Board has VLAN capability */
-#define BFL_NOPCI              0x00000400      /* Board leaves PCI floating */
 #define BFL_FEM                        0x00000800      /* Board supports the Front End Module */
 #define BFL_EXTLNA             0x00001000      /* Board has an external LNA in 2.4GHz band */
-#define BFL_HGPA               0x00002000      /* Board has a high gain PA */
-#define        BFL_RESERVED2           0x00004000
-#define        BFL_ALTIQ               0x00008000      /* Alternate I/Q settings */
 #define BFL_NOPA               0x00010000      /* Board has no PA */
-#define BFL_RSSIINV            0x00020000      /* Board's RSSI uses positive slope(not TSSI) */
-#define BFL_PAREF              0x00040000      /* Board uses the PARef LDO */
-#define BFL_3TSWITCH           0x00080000      /* Board uses a triple throw switch shared with BT */
-#define BFL_PHASESHIFT         0x00100000      /* Board can support phase shifter */
 #define BFL_BUCKBOOST          0x00200000      /* Power topology uses BUCKBOOST */
 #define BFL_FEM_BT             0x00400000      /* Board has FEM and switch to share antenna w/ BT */
 #define BFL_NOCBUCK            0x00800000      /* Power topology doesn't use CBUCK */
-#define BFL_CCKFAVOREVM                0x01000000      /* Favor CCK EVM over spectral mask */
 #define BFL_PALDO              0x02000000      /* Power topology uses PALDO */
-#define BFL_LNLDO2_2P5         0x04000000      /* Select 2.5V as LNLDO2 output voltage */
-#define BFL_FASTPWR            0x08000000
-#define BFL_UCPWRCTL_MININDX   0x08000000      /* Enforce min power index to avoid FEM damage */
 #define BFL_EXTLNA_5GHz                0x10000000      /* Board has an external LNA in 5GHz band */
-#define BFL_TRSW_1by2          0x20000000      /* Board has 2 TRSW's in 1by2 designs */
-#define BFL_LO_TRSW_R_5GHz     0x40000000      /* In 5G do not throw TRSW to T for clipLO gain */
-#define BFL_ELNA_GAINDEF       0x80000000      /* Backoff InitGain based on elna_2g/5g field
-                                                * when this flag is set
-                                                */
 
 /* boardflags2 */
 #define BFL2_RXBB_INT_REG_DIS  0x00000001      /* Board has an external rxbb regulator */
 #define BFL2_2X4_DIV           0x00000008      /* Board supports the 2X4 diversity switch */
 #define BFL2_5G_PWRGAIN                0x00000010      /* Board supports 5G band power gain */
 #define BFL2_PCIEWAR_OVR       0x00000020      /* Board overrides ASPM and Clkreq settings */
-#define BFL2_CAESERS_BRD       0x00000040      /* Board is Caesers brd (unused by sw) */
 #define BFL2_LEGACY            0x00000080
 #define BFL2_SKWRKFEM_BRD      0x00000100      /* 4321mcm93 board uses Skyworks FEM */
 #define BFL2_SPUR_WAR          0x00000200      /* Board has a WAR for clock-harmonic spurs */
 #define BFL2_GPLL_WAR          0x00000400      /* Flag to narrow G-band PLL loop b/w */
-#define BFL2_TRISTATE_LED      0x00000800      /* Tri-state the LED */
 #define BFL2_SINGLEANT_CCK     0x00001000      /* Tx CCK pkts on Ant 0 only */
 #define BFL2_2G_SPUR_WAR       0x00002000      /* WAR to reduce and avoid clock-harmonic spurs in 2G */
-#define BFL2_BPHY_ALL_TXCORES  0x00004000      /* Transmit bphy frames using all tx cores */
-#define BFL2_FCC_BANDEDGE_WAR  0x00008000      /* using 40Mhz LPF for 20Mhz bandedge channels */
 #define BFL2_GPLL_WAR2         0x00010000      /* Flag to widen G-band PLL loop b/w */
 #define BFL2_IPALVLSHIFT_3P3    0x00020000
 #define BFL2_INTERNDET_TXIQCAL  0x00040000     /* Use internal envelope detector for TX IQCAL */
                                                 */
 
 /* board specific GPIO assignment, gpio 0-3 are also customer-configurable led */
-#define        BOARD_GPIO_RESERVED1    0x010
-#define        BOARD_GPIO_RESERVED2    0x020
-#define        BOARD_GPIO_RESERVED3    0x080
-#define        BOARD_GPIO_RESERVED4    0x100
 #define        BOARD_GPIO_PACTRL       0x200   /* bit 9 controls the PA on new 4306 boards */
 #define BOARD_GPIO_12          0x1000  /* gpio 12 */
 #define BOARD_GPIO_13          0x2000  /* gpio 13 */
-#define BOARD_GPIO_RESERVED5   0x0800
-#define BOARD_GPIO_RESERVED6   0x2000
-#define BOARD_GPIO_RESERVED7   0x4000
-#define BOARD_GPIO_RESERVED8   0x8000
 
 #define        PCI_CFG_GPIO_SCS        0x10    /* PCI config space bit 4 for 4306c0 slow clock source */
-#define PCI_CFG_GPIO_HWRAD     0x20    /* PCI config space GPIO 13 for hw radio disable */
 #define PCI_CFG_GPIO_XTAL      0x40    /* PCI config space GPIO 14 for Xtal power-up */
 #define PCI_CFG_GPIO_PLL       0x80    /* PCI config space GPIO 15 for PLL power-down */
 
 /* power control defines */
 #define PLL_DELAY              150     /* us pll on delay */
 #define FREF_DELAY             200     /* us fref change delay */
-#define MIN_SLOW_CLK           32      /* us Slow clock period */
 #define        XTAL_ON_DELAY           1000    /* us crystal power-on delay */
 
-/* # of GPIO pins */
-#define GPIO_NUMPINS           16
-
 /* Reference board types */
 #define        SPI_BOARD               0x0402
 
index e194131a750ec4907b1db4f196b6fa4ef1e86dd8..12645ddf000d10bd706a58e8092684f5c04e7054 100644 (file)
@@ -29,32 +29,27 @@ struct nvram_header {
        u32 config_ncdl;        /* ncdl values for memc */
 };
 
-/*
- * Get default value for an NVRAM variable
- */
-extern char *nvram_default_get(const char *name);
-
 /*
  * Initialize NVRAM access. May be unnecessary or undefined on certain
  * platforms.
  */
-extern int nvram_init(void *sih);
+extern int nvram_init(void);
 
 /*
  * Append a chunk of nvram variables to the global list
  */
-extern int nvram_append(void *si, char *vars, uint varsz);
+extern int nvram_append(char *vars, uint varsz);
 
 /*
  * Check for reset button press for restoring factory defaults.
  */
-extern int nvram_reset(void *sih);
+extern int nvram_reset(void);
 
 /*
  * Disable NVRAM access. May be unnecessary or undefined on certain
  * platforms.
  */
-extern void nvram_exit(void *sih);
+extern void nvram_exit(void);
 
 /*
  * Get the value of an NVRAM variable. The pointer returned may be
@@ -64,12 +59,6 @@ extern void nvram_exit(void *sih);
  */
 extern char *nvram_get(const char *name);
 
-/*
- * Read the reset GPIO value from the nvram and set the GPIO
- * as input
- */
-extern int nvram_resetgpio_init(void *sih);
-
 /*
  * Get the value of an NVRAM variable.
  * @param      name    name of variable to get
@@ -139,14 +128,12 @@ extern int nvram_commit(void);
  */
 extern int nvram_getall(char *nvram_buf, int count);
 
-/*
- * returns the crc value of the nvram
- * @param      nvh     nvram header pointer
- */
-u8 nvram_calc_crc(struct nvram_header *nvh);
-
 #endif                         /* _LANGUAGE_ASSEMBLY */
 
+/* variable access */
+extern char *getvar(char *vars, const char *name);
+extern int getintvar(char *vars, const char *name);
+
 /* The NVRAM version number stored as an NVRAM variable */
 #define NVRAM_SOFTWARE_VERSION "1"
 
index 48699471fac874a36b6b1a0c47df8235380174bf..5175e67a6d28f71a1a21410cdc0a7f770ac30cd4 100644 (file)
@@ -186,7 +186,7 @@ typedef volatile struct {
  * Shared structure between dongle and the host.
  * The structure contains pointers to trap or assert information.
  */
-#define SDPCM_SHARED_VERSION       0x0001
+#define SDPCM_SHARED_VERSION       0x0002
 #define SDPCM_SHARED_VERSION_MASK  0x00FF
 #define SDPCM_SHARED_ASSERT_BUILT  0x0100
 #define SDPCM_SHARED_ASSERT        0x0200
@@ -200,6 +200,7 @@ typedef struct {
        u32 assert_line;
        u32 console_addr;       /* Address of hndrte_cons_t */
        u32 msgtrace_addr;
+       u8 tag[32];
 } sdpcm_shared_t;
 
 extern sdpcm_shared_t sdpcm_shared;
index 4768968f910a025f2b74355bca71d32d86a8efb0..4666afd883a516aaee2c97bb61f00cea3f67b574 100644 (file)
 
 /* SROM Rev 4: Reallocate the software part of the srom to accommodate
  * MIMO features. It assumes up to two PCIE functions and 440 bytes
- * of useable srom i.e. the useable storage in chips with OTP that
+ * of usable srom i.e. the usable storage in chips with OTP that
  * implements hardware redundancy.
  */
 
index fc2a2a910129cca9acc4afb1d6096cf7b58892ef..17683f2f785ff21f667b92d28cea349cf7170b1d 100644 (file)
@@ -74,7 +74,7 @@
 #define PKTQ_PREC_ITER(pq, prec)        for (prec = (pq)->num_prec - 1; prec >= 0; prec--)
 
 /* fn(pkt, arg).  return true if pkt belongs to if */
-       typedef bool(*ifpkt_cb_t) (void *, int);
+typedef bool(*ifpkt_cb_t) (struct sk_buff *, void *);
 
 /* operations on a specific precedence in packet queue */
 
 #define pktq_ppeek(pq, prec)            ((pq)->q[prec].head)
 #define pktq_ppeek_tail(pq, prec)       ((pq)->q[prec].tail)
 
-extern struct sk_buff *pktq_penq(struct pktq *pq, int prec,
+extern struct sk_buff *bcm_pktq_penq(struct pktq *pq, int prec,
                                 struct sk_buff *p);
-extern struct sk_buff *pktq_penq_head(struct pktq *pq, int prec,
+extern struct sk_buff *bcm_pktq_penq_head(struct pktq *pq, int prec,
                                      struct sk_buff *p);
-extern struct sk_buff *pktq_pdeq(struct pktq *pq, int prec);
-extern struct sk_buff *pktq_pdeq_tail(struct pktq *pq, int prec);
+extern struct sk_buff *bcm_pktq_pdeq(struct pktq *pq, int prec);
+extern struct sk_buff *bcm_pktq_pdeq_tail(struct pktq *pq, int prec);
 
 /* packet primitives */
-extern struct sk_buff *pkt_buf_get_skb(uint len);
-extern void pkt_buf_free_skb(struct sk_buff *skb);
+extern struct sk_buff *bcm_pkt_buf_get_skb(uint len);
+extern void bcm_pkt_buf_free_skb(struct sk_buff *skb);
 
 /* Empty the queue at particular precedence level */
-#ifdef BRCM_FULLMAC
-       extern void pktq_pflush(struct pktq *pq, int prec,
-               bool dir);
-#else
-       extern void pktq_pflush(struct pktq *pq, int prec,
-               bool dir, ifpkt_cb_t fn, int arg);
-#endif /* BRCM_FULLMAC */
+extern void bcm_pktq_pflush(struct pktq *pq, int prec,
+       bool dir, ifpkt_cb_t fn, void *arg);
 
 /* operations on a set of precedences in packet queue */
 
-extern int pktq_mlen(struct pktq *pq, uint prec_bmp);
-extern struct sk_buff *pktq_mdeq(struct pktq *pq, uint prec_bmp, int *prec_out);
+extern int bcm_pktq_mlen(struct pktq *pq, uint prec_bmp);
+extern struct sk_buff *bcm_pktq_mdeq(struct pktq *pq, uint prec_bmp,
+       int *prec_out);
 
 /* operations on packet queue as a whole */
 
@@ -121,46 +117,38 @@ extern struct sk_buff *pktq_mdeq(struct pktq *pq, uint prec_bmp, int *prec_out);
 #define pktq_empty(pq)                  ((pq)->len == 0)
 
 /* operations for single precedence queues */
-#define pktenq(pq, p)          pktq_penq(((struct pktq *)pq), 0, (p))
-#define pktenq_head(pq, p)     pktq_penq_head(((struct pktq *)pq), 0, (p))
-#define pktdeq(pq)             pktq_pdeq(((struct pktq *)pq), 0)
-#define pktdeq_tail(pq)                pktq_pdeq_tail(((struct pktq *)pq), 0)
-#define pktqinit(pq, len) pktq_init(((struct pktq *)pq), 1, len)
+#define pktenq(pq, p)          bcm_pktq_penq(((struct pktq *)pq), 0, (p))
+#define pktenq_head(pq, p)     bcm_pktq_penq_head(((struct pktq *)pq), 0, (p))
+#define pktdeq(pq)             bcm_pktq_pdeq(((struct pktq *)pq), 0)
+#define pktdeq_tail(pq)                bcm_pktq_pdeq_tail(((struct pktq *)pq), 0)
+#define pktqinit(pq, len)      bcm_pktq_init(((struct pktq *)pq), 1, len)
 
-       extern void pktq_init(struct pktq *pq, int num_prec, int max_len);
+extern void bcm_pktq_init(struct pktq *pq, int num_prec, int max_len);
 /* prec_out may be NULL if caller is not interested in return value */
-       extern struct sk_buff *pktq_peek_tail(struct pktq *pq, int *prec_out);
-#ifdef BRCM_FULLMAC
-       extern void pktq_flush(struct pktq *pq, bool dir);
-#else
-       extern void pktq_flush(struct pktq *pq, bool dir,
-               ifpkt_cb_t fn, int arg);
-#endif
+extern struct sk_buff *bcm_pktq_peek_tail(struct pktq *pq, int *prec_out);
+extern void bcm_pktq_flush(struct pktq *pq, bool dir,
+       ifpkt_cb_t fn, void *arg);
 
 /* externs */
 /* packet */
-       extern uint pktfrombuf(struct sk_buff *p,
-                              uint offset, int len, unsigned char *buf);
-       extern uint pkttotlen(struct sk_buff *p);
+extern uint bcm_pktfrombuf(struct sk_buff *p,
+       uint offset, int len, unsigned char *buf);
+extern uint bcm_pkttotlen(struct sk_buff *p);
 
 /* ethernet address */
-       extern int bcm_ether_atoe(char *p, u8 *ea);
+extern int bcm_ether_atoe(char *p, u8 *ea);
 
 /* ip address */
        struct ipv4_addr;
        extern char *bcm_ip_ntoa(struct ipv4_addr *ia, char *buf);
 
-/* variable access */
-       extern char *getvar(char *vars, const char *name);
-       extern int getintvar(char *vars, const char *name);
 #ifdef BCMDBG
-       extern void prpkt(const char *msg, struct sk_buff *p0);
+extern void bcm_prpkt(const char *msg, struct sk_buff *p0);
 #else
-#define prpkt(a, b)
+#define bcm_prpkt(a, b)
 #endif                         /* BCMDBG */
 
 #define bcm_perf_enable()
-#define bcmstats(fmt)
 #define        bcmlog(fmt, a1, a2)
 #define        bcmdumplog(buf, size)   (*buf = '\0')
 #define        bcmdumplogent(buf, idx) -1
@@ -241,107 +229,6 @@ extern struct sk_buff *pktq_mdeq(struct pktq *pq, uint prec_bmp, int *prec_out);
 /* ** driver/apps-shared section ** */
 
 #define BCME_STRLEN            64      /* Max string length for BCM errors */
-#define VALID_BCMERROR(e)  ((e <= 0) && (e >= BCME_LAST))
-
-/*
- * error codes could be added but the defined ones shouldn't be changed/deleted
- * these error codes are exposed to the user code
- * when ever a new error code is added to this list
- * please update errorstring table with the related error string and
- * update osl files with os specific errorcode map
-*/
-
-#define BCME_OK                                0       /* Success */
-#define BCME_ERROR                     -1      /* Error generic */
-#define BCME_BADARG                    -2      /* Bad Argument */
-#define BCME_BADOPTION                 -3      /* Bad option */
-#define BCME_NOTUP                     -4      /* Not up */
-#define BCME_NOTDOWN                   -5      /* Not down */
-#define BCME_NOTAP                     -6      /* Not AP */
-#define BCME_NOTSTA                    -7      /* Not STA  */
-#define BCME_BADKEYIDX                 -8      /* BAD Key Index */
-#define BCME_RADIOOFF                  -9      /* Radio Off */
-#define BCME_NOTBANDLOCKED             -10     /* Not  band locked */
-#define BCME_NOCLK                     -11     /* No Clock */
-#define BCME_BADRATESET                        -12     /* BAD Rate valueset */
-#define BCME_BADBAND                   -13     /* BAD Band */
-#define BCME_BUFTOOSHORT               -14     /* Buffer too short */
-#define BCME_BUFTOOLONG                        -15     /* Buffer too long */
-#define BCME_BUSY                      -16     /* Busy */
-#define BCME_NOTASSOCIATED             -17     /* Not Associated */
-#define BCME_BADSSIDLEN                        -18     /* Bad SSID len */
-#define BCME_OUTOFRANGECHAN            -19     /* Out of Range Channel */
-#define BCME_BADCHAN                   -20     /* Bad Channel */
-#define BCME_BADADDR                   -21     /* Bad Address */
-#define BCME_NORESOURCE                        -22     /* Not Enough Resources */
-#define BCME_UNSUPPORTED               -23     /* Unsupported */
-#define BCME_BADLEN                    -24     /* Bad length */
-#define BCME_NOTREADY                  -25     /* Not Ready */
-#define BCME_EPERM                     -26     /* Not Permitted */
-#define BCME_NOMEM                     -27     /* No Memory */
-#define BCME_ASSOCIATED                        -28     /* Associated */
-#define BCME_RANGE                     -29     /* Not In Range */
-#define BCME_NOTFOUND                  -30     /* Not Found */
-#define BCME_WME_NOT_ENABLED           -31     /* WME Not Enabled */
-#define BCME_TSPEC_NOTFOUND            -32     /* TSPEC Not Found */
-#define BCME_ACM_NOTSUPPORTED          -33     /* ACM Not Supported */
-#define BCME_NOT_WME_ASSOCIATION       -34     /* Not WME Association */
-#define BCME_SDIO_ERROR                        -35     /* SDIO Bus Error */
-#define BCME_DONGLE_DOWN               -36     /* Dongle Not Accessible */
-#define BCME_VERSION                   -37     /* Incorrect version */
-#define BCME_TXFAIL                    -38     /* TX failure */
-#define BCME_RXFAIL                    -39     /* RX failure */
-#define BCME_NODEVICE                  -40     /* Device not present */
-#define BCME_NMODE_DISABLED            -41     /* NMODE disabled */
-#define BCME_NONRESIDENT               -42     /* access to nonresident overlay */
-#define BCME_LAST                      BCME_NONRESIDENT
-
-/* These are collection of BCME Error strings */
-#define BCMERRSTRINGTABLE {            \
-       "OK",                           \
-       "Undefined error",              \
-       "Bad Argument",                 \
-       "Bad Option",                   \
-       "Not up",                       \
-       "Not down",                     \
-       "Not AP",                       \
-       "Not STA",                      \
-       "Bad Key Index",                \
-       "Radio Off",                    \
-       "Not band locked",              \
-       "No clock",                     \
-       "Bad Rate valueset",            \
-       "Bad Band",                     \
-       "Buffer too short",             \
-       "Buffer too long",              \
-       "Busy",                         \
-       "Not Associated",               \
-       "Bad SSID len",                 \
-       "Out of Range Channel",         \
-       "Bad Channel",                  \
-       "Bad Address",                  \
-       "Not Enough Resources",         \
-       "Unsupported",                  \
-       "Bad length",                   \
-       "Not Ready",                    \
-       "Not Permitted",                \
-       "No Memory",                    \
-       "Associated",                   \
-       "Not In Range",                 \
-       "Not Found",                    \
-       "WME Not Enabled",              \
-       "TSPEC Not Found",              \
-       "ACM Not Supported",            \
-       "Not WME Association",          \
-       "SDIO Bus Error",               \
-       "Dongle Not Accessible",        \
-       "Incorrect version",            \
-       "TX Failure",                   \
-       "RX Failure",                   \
-       "Device Not Present",           \
-       "NMODE Disabled",               \
-       "Nonresident overlay access", \
-}
 
 #ifndef ABS
 #define        ABS(a)                  (((a) < 0) ? -(a) : (a))
@@ -358,16 +245,6 @@ extern struct sk_buff *pktq_mdeq(struct pktq *pq, uint prec_bmp, int *prec_out);
 #define REG_MAP(pa, size)       (void *)(0)
 #endif
 
-extern u32 g_assert_type;
-
-#if defined(BCMDBG_ASSERT)
-#define ASSERT(exp) \
-         do { if (!(exp)) osl_assert(#exp, __FILE__, __LINE__); } while (0)
-extern void osl_assert(char *exp, char *file, int line);
-#else
-#define ASSERT(exp)    do {} while (0)
-#endif  /* defined(BCMDBG_ASSERT) */
-
 /* register access macros */
 #if defined(BCMSDIO)
 #ifdef BRCM_FULLMAC
@@ -399,7 +276,7 @@ extern void osl_assert(char *exp, char *file, int line);
 #define        bcopy(src, dst, len)    memcpy((dst), (src), (len))
 
 /* register access macros */
-#ifndef IL_BIGENDIAN
+#ifndef __BIG_ENDIAN
 #ifndef __mips__
 #define R_REG(r) (\
        SELECT_BUS_READ(sizeof(*(r)) == sizeof(u8) ? \
@@ -450,7 +327,7 @@ extern void osl_assert(char *exp, char *file, int line);
                }, \
                (OSL_WRITE_REG(r, v))); \
        } while (0)
-#else                          /* IL_BIGENDIAN */
+#else                          /* __BIG_ENDIAN */
 #define R_REG(r) (\
        SELECT_BUS_READ( \
                ({ \
@@ -487,7 +364,7 @@ extern void osl_assert(char *exp, char *file, int line);
                }, \
                (OSL_WRITE_REG(r, v))); \
        } while (0)
-#endif                         /* IL_BIGENDIAN */
+#endif                         /* __BIG_ENDIAN */
 
 #define AND_REG(r, v)  W_REG((r), R_REG(r) & (v))
 #define OR_REG(r, v)   W_REG((r), R_REG(r) | (v))
@@ -590,8 +467,7 @@ extern void osl_assert(char *exp, char *file, int line);
 
 /* externs */
 /* crc */
-       extern u8 hndcrc8(u8 *p, uint nbytes, u8 crc);
-       extern u16 hndcrc16(u8 *p, uint nbytes, u16 crc);
+extern u8 bcm_crc8(u8 *p, uint nbytes, u8 crc);
 /* format/print */
 #if defined(BCMDBG)
        extern int bcm_format_flags(const bcm_bit_desc_t *bd, u32 flags,
@@ -599,12 +475,9 @@ extern void osl_assert(char *exp, char *file, int line);
        extern int bcm_format_hex(char *str, const void *bytes, int len);
 #endif
        extern char *bcm_chipname(uint chipid, char *buf, uint len);
-       extern void prhex(const char *msg, unsigned char *buf, uint len);
 
        extern bcm_tlv_t *bcm_parse_tlvs(void *buf, int buflen,
                                                    uint key);
-/* bcmerror */
-       extern const char *bcmerrorstr(int bcmerror);
 
 /* multi-bool data type: set of bools, mbool is true if any is set */
        typedef u32 mbool;
index 4a0f976afaa489cc842a5a4e3c5a1545595a41e1..a573ebff7680ccfe6786d1b8cbd4f7e6a32e0823 100644 (file)
@@ -134,14 +134,14 @@ typedef u16 chanspec_t;
  * combination could be legal given any set of circumstances.
  * RETURNS: true is the chanspec is malformed, false if it looks good.
  */
-extern bool wf_chspec_malformed(chanspec_t chanspec);
+extern bool bcm_chspec_malformed(chanspec_t chanspec);
 
 /*
  * This function returns the channel number that control traffic is being sent on, for legacy
  * channels this is just the channel number, for 40MHZ channels it is the upper or lowre 20MHZ
  * sideband depending on the chanspec selected
  */
-extern u8 wf_chspec_ctlchan(chanspec_t chspec);
+extern u8 bcm_chspec_ctlchan(chanspec_t chspec);
 
 /*
  * Return the channel number for a given frequency and base frequency.
@@ -162,6 +162,6 @@ extern u8 wf_chspec_ctlchan(chanspec_t chspec);
  *
  * Reference 802.11 REVma, section 17.3.8.3, and 802.11B section 18.4.6.2
  */
-extern int wf_mhz2channel(uint freq, uint start_factor);
+extern int bcm_mhz2channel(uint freq, uint start_factor);
 
 #endif                         /* _bcmwifi_h_ */
index 5d079e77490ee24185f545bb4f1cc75f14720787..fbbcb9b5ae622c10f479f1f2750471d4e245a9ff 100644 (file)
@@ -204,4 +204,23 @@ extern const di_fcn_t dma64proc;
 extern uint dma_addrwidth(si_t *sih, void *dmaregs);
 void dma_walk_packets(struct hnddma_pub *dmah, void (*callback_fnc)
                      (void *pkt, void *arg_a), void *arg_a);
+
+/*
+ * DMA(Bug) on some chips seems to declare that the packet is ready, but the
+ * packet length is not updated yet (by DMA) on the expected time.
+ * Workaround is to hold processor till DMA updates the length, and stay off
+ * the bus to allow DMA update the length in buffer
+ */
+static inline void dma_spin_for_len(uint len, struct sk_buff *head)
+{
+#if defined(__mips__)
+       if (!len) {
+               while (!(len = *(u16 *) KSEG1ADDR(head->data)))
+                       udelay(1);
+
+               *(u16 *) (head->data) = cpu_to_le16((u16) len);
+       }
+#endif                         /* defined(__mips__) */
+}
+
 #endif                         /* _hnddma_h_ */
index 675554a1d34112141c437e597df2ab07c7a5f59e..d0c617a63c4ff8b2a0b3ff0a1a332a8484885224 100644 (file)
 #ifndef        _h_pcicfg_
 #define        _h_pcicfg_
 
-/* The following inside ifndef's so we don't collide with NTDDK.H */
-#ifndef PCI_MAX_BUS
-#define PCI_MAX_BUS            0x100
-#endif
-#ifndef PCI_MAX_DEVICES
-#define PCI_MAX_DEVICES                0x20
-#endif
-#ifndef PCI_MAX_FUNCTION
-#define PCI_MAX_FUNCTION       0x8
-#endif
+#include <linux/pci_regs.h>
 
-#ifndef PCI_INVALID_VENDORID
-#define PCI_INVALID_VENDORID   0xffff
-#endif
-#ifndef PCI_INVALID_DEVICEID
-#define PCI_INVALID_DEVICEID   0xffff
-#endif
-
-/* Convert between bus-slot-function-register and config addresses */
-
-#define        PCICFG_BUS_SHIFT        16      /* Bus shift */
-#define        PCICFG_SLOT_SHIFT       11      /* Slot shift */
-#define        PCICFG_FUN_SHIFT        8       /* Function shift */
-#define        PCICFG_OFF_SHIFT        0       /* Register shift */
-
-#define        PCICFG_BUS_MASK         0xff    /* Bus mask */
-#define        PCICFG_SLOT_MASK        0x1f    /* Slot mask */
-#define        PCICFG_FUN_MASK         7       /* Function mask */
-#define        PCICFG_OFF_MASK         0xff    /* Bus mask */
-
-#define        PCI_CONFIG_ADDR(b, s, f, o)                                     \
-               ((((b) & PCICFG_BUS_MASK) << PCICFG_BUS_SHIFT)          \
-                | (((s) & PCICFG_SLOT_MASK) << PCICFG_SLOT_SHIFT)      \
-                | (((f) & PCICFG_FUN_MASK) << PCICFG_FUN_SHIFT)        \
-                | (((o) & PCICFG_OFF_MASK) << PCICFG_OFF_SHIFT))
-
-#define        PCI_CONFIG_BUS(a)       (((a) >> PCICFG_BUS_SHIFT) & PCICFG_BUS_MASK)
-#define        PCI_CONFIG_SLOT(a)      (((a) >> PCICFG_SLOT_SHIFT) & PCICFG_SLOT_MASK)
-#define        PCI_CONFIG_FUN(a)       (((a) >> PCICFG_FUN_SHIFT) & PCICFG_FUN_MASK)
-#define        PCI_CONFIG_OFF(a)       (((a) >> PCICFG_OFF_SHIFT) & PCICFG_OFF_MASK)
-
-/* PCIE Config space accessing MACROS */
-
-#define        PCIECFG_BUS_SHIFT       24      /* Bus shift */
-#define        PCIECFG_SLOT_SHIFT      19      /* Slot/Device shift */
-#define        PCIECFG_FUN_SHIFT       16      /* Function shift */
-#define        PCIECFG_OFF_SHIFT       0       /* Register shift */
-
-#define        PCIECFG_BUS_MASK        0xff    /* Bus mask */
-#define        PCIECFG_SLOT_MASK       0x1f    /* Slot/Device mask */
-#define        PCIECFG_FUN_MASK        7       /* Function mask */
-#define        PCIECFG_OFF_MASK        0xfff   /* Register mask */
-
-#define        PCIE_CONFIG_ADDR(b, s, f, o)                                    \
-               ((((b) & PCIECFG_BUS_MASK) << PCIECFG_BUS_SHIFT)                \
-                | (((s) & PCIECFG_SLOT_MASK) << PCIECFG_SLOT_SHIFT)    \
-                | (((f) & PCIECFG_FUN_MASK) << PCIECFG_FUN_SHIFT)      \
-                | (((o) & PCIECFG_OFF_MASK) << PCIECFG_OFF_SHIFT))
-
-#define        PCIE_CONFIG_BUS(a)      (((a) >> PCIECFG_BUS_SHIFT) & PCIECFG_BUS_MASK)
-#define        PCIE_CONFIG_SLOT(a)     (((a) >> PCIECFG_SLOT_SHIFT) & PCIECFG_SLOT_MASK)
-#define        PCIE_CONFIG_FUN(a)      (((a) >> PCIECFG_FUN_SHIFT) & PCIECFG_FUN_MASK)
-#define        PCIE_CONFIG_OFF(a)      (((a) >> PCIECFG_OFF_SHIFT) & PCIECFG_OFF_MASK)
-
-/* The actual config space */
-
-#define        PCI_BAR_MAX             6
-
-#define        PCI_ROM_BAR             8
-
-#define        PCR_RSVDA_MAX           2
-
-/* Bits in PCI bars' flags */
-
-#define        PCIBAR_FLAGS            0xf
-#define        PCIBAR_IO               0x1
-#define        PCIBAR_MEM1M            0x2
-#define        PCIBAR_MEM64            0x4
-#define        PCIBAR_PREFETCH         0x8
-#define        PCIBAR_MEM32_MASK       0xFFFFFF80
-
-/* pci config status reg has a bit to indicate that capability ptr is present */
-
-#define PCI_CAPPTR_PRESENT     0x0010
-
-typedef struct _pci_config_regs {
-       u16 vendor;
-       u16 device;
-       u16 command;
-       u16 status;
-       u8 rev_id;
-       u8 prog_if;
-       u8 sub_class;
-       u8 base_class;
-       u8 cache_line_size;
-       u8 latency_timer;
-       u8 header_type;
-       u8 bist;
-       u32 base[PCI_BAR_MAX];
-       u32 cardbus_cis;
-       u16 subsys_vendor;
-       u16 subsys_id;
-       u32 baserom;
-       u32 rsvd_a[PCR_RSVDA_MAX];
-       u8 int_line;
-       u8 int_pin;
-       u8 min_gnt;
-       u8 max_lat;
-       u8 dev_dep[192];
-} pci_config_regs;
-
-#define        SZPCR           (sizeof (pci_config_regs))
-#define        MINSZPCR        64      /* offsetof (dev_dep[0] */
-
-/* A structure for the config registers is nice, but in most
- * systems the config space is not memory mapped, so we need
- * field offsetts. :-(
- */
-#define        PCI_CFG_VID             0
-#define        PCI_CFG_DID             2
-#define        PCI_CFG_CMD             4
-#define        PCI_CFG_STAT            6
-#define        PCI_CFG_REV             8
-#define        PCI_CFG_PROGIF          9
-#define        PCI_CFG_SUBCL           0xa
-#define        PCI_CFG_BASECL          0xb
-#define        PCI_CFG_CLSZ            0xc
-#define        PCI_CFG_LATTIM          0xd
-#define        PCI_CFG_HDR             0xe
-#define        PCI_CFG_BIST            0xf
-#define        PCI_CFG_BAR0            0x10
-#define        PCI_CFG_BAR1            0x14
-#define        PCI_CFG_BAR2            0x18
-#define        PCI_CFG_BAR3            0x1c
-#define        PCI_CFG_BAR4            0x20
-#define        PCI_CFG_BAR5            0x24
-#define        PCI_CFG_CIS             0x28
-#define        PCI_CFG_SVID            0x2c
-#define        PCI_CFG_SSID            0x2e
-#define        PCI_CFG_ROMBAR          0x30
-#define PCI_CFG_CAPPTR         0x34
-#define        PCI_CFG_INT             0x3c
-#define        PCI_CFG_PIN             0x3d
-#define        PCI_CFG_MINGNT          0x3e
-#define        PCI_CFG_MAXLAT          0x3f
-
-/* Classes and subclasses */
-
-typedef enum {
-       PCI_CLASS_OLD = 0,
-       PCI_CLASS_DASDI,
-       PCI_CLASS_NET,
-       PCI_CLASS_DISPLAY,
-       PCI_CLASS_MMEDIA,
-       PCI_CLASS_MEMORY,
-       PCI_CLASS_BRIDGE,
-       PCI_CLASS_COMM,
-       PCI_CLASS_BASE,
-       PCI_CLASS_INPUT,
-       PCI_CLASS_DOCK,
-       PCI_CLASS_CPU,
-       PCI_CLASS_SERIAL,
-       PCI_CLASS_INTELLIGENT = 0xe,
-       PCI_CLASS_SATELLITE,
-       PCI_CLASS_CRYPT,
-       PCI_CLASS_DSP,
-       PCI_CLASS_XOR = 0xfe
-} pci_classes;
-
-typedef enum {
-       PCI_DASDI_SCSI,
-       PCI_DASDI_IDE,
-       PCI_DASDI_FLOPPY,
-       PCI_DASDI_IPI,
-       PCI_DASDI_RAID,
-       PCI_DASDI_OTHER = 0x80
-} pci_dasdi_subclasses;
-
-typedef enum {
-       PCI_NET_ETHER,
-       PCI_NET_TOKEN,
-       PCI_NET_FDDI,
-       PCI_NET_ATM,
-       PCI_NET_OTHER = 0x80
-} pci_net_subclasses;
-
-typedef enum {
-       PCI_DISPLAY_VGA,
-       PCI_DISPLAY_XGA,
-       PCI_DISPLAY_3D,
-       PCI_DISPLAY_OTHER = 0x80
-} pci_display_subclasses;
-
-typedef enum {
-       PCI_MMEDIA_VIDEO,
-       PCI_MMEDIA_AUDIO,
-       PCI_MMEDIA_PHONE,
-       PCI_MEDIA_OTHER = 0x80
-} pci_mmedia_subclasses;
-
-typedef enum {
-       PCI_MEMORY_RAM,
-       PCI_MEMORY_FLASH,
-       PCI_MEMORY_OTHER = 0x80
-} pci_memory_subclasses;
-
-typedef enum {
-       PCI_BRIDGE_HOST,
-       PCI_BRIDGE_ISA,
-       PCI_BRIDGE_EISA,
-       PCI_BRIDGE_MC,
-       PCI_BRIDGE_PCI,
-       PCI_BRIDGE_PCMCIA,
-       PCI_BRIDGE_NUBUS,
-       PCI_BRIDGE_CARDBUS,
-       PCI_BRIDGE_RACEWAY,
-       PCI_BRIDGE_OTHER = 0x80
-} pci_bridge_subclasses;
-
-typedef enum {
-       PCI_COMM_UART,
-       PCI_COMM_PARALLEL,
-       PCI_COMM_MULTIUART,
-       PCI_COMM_MODEM,
-       PCI_COMM_OTHER = 0x80
-} pci_comm_subclasses;
-
-typedef enum {
-       PCI_BASE_PIC,
-       PCI_BASE_DMA,
-       PCI_BASE_TIMER,
-       PCI_BASE_RTC,
-       PCI_BASE_PCI_HOTPLUG,
-       PCI_BASE_OTHER = 0x80
-} pci_base_subclasses;
-
-typedef enum {
-       PCI_INPUT_KBD,
-       PCI_INPUT_PEN,
-       PCI_INPUT_MOUSE,
-       PCI_INPUT_SCANNER,
-       PCI_INPUT_GAMEPORT,
-       PCI_INPUT_OTHER = 0x80
-} pci_input_subclasses;
-
-typedef enum {
-       PCI_DOCK_GENERIC,
-       PCI_DOCK_OTHER = 0x80
-} pci_dock_subclasses;
-
-typedef enum {
-       PCI_CPU_386,
-       PCI_CPU_486,
-       PCI_CPU_PENTIUM,
-       PCI_CPU_ALPHA = 0x10,
-       PCI_CPU_POWERPC = 0x20,
-       PCI_CPU_MIPS = 0x30,
-       PCI_CPU_COPROC = 0x40,
-       PCI_CPU_OTHER = 0x80
-} pci_cpu_subclasses;
-
-typedef enum {
-       PCI_SERIAL_IEEE1394,
-       PCI_SERIAL_ACCESS,
-       PCI_SERIAL_SSA,
-       PCI_SERIAL_USB,
-       PCI_SERIAL_FIBER,
-       PCI_SERIAL_SMBUS,
-       PCI_SERIAL_OTHER = 0x80
-} pci_serial_subclasses;
-
-typedef enum {
-       PCI_INTELLIGENT_I2O
-} pci_intelligent_subclasses;
-
-typedef enum {
-       PCI_SATELLITE_TV,
-       PCI_SATELLITE_AUDIO,
-       PCI_SATELLITE_VOICE,
-       PCI_SATELLITE_DATA,
-       PCI_SATELLITE_OTHER = 0x80
-} pci_satellite_subclasses;
-
-typedef enum {
-       PCI_CRYPT_NETWORK,
-       PCI_CRYPT_ENTERTAINMENT,
-       PCI_CRYPT_OTHER = 0x80
-} pci_crypt_subclasses;
-
-typedef enum {
-       PCI_DSP_DPIO,
-       PCI_DSP_OTHER = 0x80
-} pci_dsp_subclasses;
-
-typedef enum {
-       PCI_XOR_QDMA,
-       PCI_XOR_OTHER = 0x80
-} pci_xor_subclasses;
-
-/* Header types */
-#define        PCI_HEADER_MULTI        0x80
-#define        PCI_HEADER_MASK         0x7f
-typedef enum {
-       PCI_HEADER_NORMAL,
-       PCI_HEADER_BRIDGE,
-       PCI_HEADER_CARDBUS
-} pci_header_types;
-
-/* Overlay for a PCI-to-PCI bridge */
-
-#define        PPB_RSVDA_MAX           2
-#define        PPB_RSVDD_MAX           8
-
-typedef struct _ppb_config_regs {
-       u16 vendor;
-       u16 device;
-       u16 command;
-       u16 status;
-       u8 rev_id;
-       u8 prog_if;
-       u8 sub_class;
-       u8 base_class;
-       u8 cache_line_size;
-       u8 latency_timer;
-       u8 header_type;
-       u8 bist;
-       u32 rsvd_a[PPB_RSVDA_MAX];
-       u8 prim_bus;
-       u8 sec_bus;
-       u8 sub_bus;
-       u8 sec_lat;
-       u8 io_base;
-       u8 io_lim;
-       u16 sec_status;
-       u16 mem_base;
-       u16 mem_lim;
-       u16 pf_mem_base;
-       u16 pf_mem_lim;
-       u32 pf_mem_base_hi;
-       u32 pf_mem_lim_hi;
-       u16 io_base_hi;
-       u16 io_lim_hi;
-       u16 subsys_vendor;
-       u16 subsys_id;
-       u32 rsvd_b;
-       u8 rsvd_c;
-       u8 int_pin;
-       u16 bridge_ctrl;
-       u8 chip_ctrl;
-       u8 diag_ctrl;
-       u16 arb_ctrl;
-       u32 rsvd_d[PPB_RSVDD_MAX];
-       u8 dev_dep[192];
-} ppb_config_regs;
-
-/* PCI CAPABILITY DEFINES */
-#define PCI_CAP_POWERMGMTCAP_ID                0x01
-#define PCI_CAP_MSICAP_ID              0x05
-#define PCI_CAP_VENDSPEC_ID            0x09
-#define PCI_CAP_PCIECAP_ID             0x10
-
-/* Data structure to define the Message Signalled Interrupt facility
- * Valid for PCI and PCIE configurations
- */
-typedef struct _pciconfig_cap_msi {
-       u8 capID;
-       u8 nextptr;
-       u16 msgctrl;
-       u32 msgaddr;
-} pciconfig_cap_msi;
-
-/* Data structure to define the Power management facility
- * Valid for PCI and PCIE configurations
- */
-typedef struct _pciconfig_cap_pwrmgmt {
-       u8 capID;
-       u8 nextptr;
-       u16 pme_cap;
-       u16 pme_sts_ctrl;
-       u8 pme_bridge_ext;
-       u8 data;
-} pciconfig_cap_pwrmgmt;
-
-#define PME_CAP_PM_STATES (0x1f << 27) /* Bits 31:27 states that can generate PME */
-#define PME_CSR_OFFSET     0x4 /* 4-bytes offset */
-#define PME_CSR_PME_EN   (1 << 8)      /* Bit 8 Enable generating of PME */
-#define PME_CSR_PME_STAT  (1 << 15)    /* Bit 15 PME got asserted */
-
-/* Data structure to define the PCIE capability */
-typedef struct _pciconfig_cap_pcie {
-       u8 capID;
-       u8 nextptr;
-       u16 pcie_cap;
-       u32 dev_cap;
-       u16 dev_ctrl;
-       u16 dev_status;
-       u32 link_cap;
-       u16 link_ctrl;
-       u16 link_status;
-       u32 slot_cap;
-       u16 slot_ctrl;
-       u16 slot_status;
-       u16 root_ctrl;
-       u16 root_cap;
-       u32 root_status;
-} pciconfig_cap_pcie;
-
-/* PCIE Enhanced CAPABILITY DEFINES */
-#define PCIE_EXTCFG_OFFSET     0x100
-#define PCIE_ADVERRREP_CAPID   0x0001
-#define PCIE_VC_CAPID          0x0002
-#define PCIE_DEVSNUM_CAPID     0x0003
-#define PCIE_PWRBUDGET_CAPID   0x0004
-
-/* PCIE Extended configuration */
-#define PCIE_ADV_CORR_ERR_MASK 0x114
-#define CORR_ERR_RE    (1 << 0)        /* Receiver  */
-#define CORR_ERR_BT    (1 << 6)        /* Bad TLP  */
-#define CORR_ERR_BD    (1 << 7)        /* Bad DLLP */
-#define CORR_ERR_RR    (1 << 8)        /* REPLAY_NUM rollover */
-#define CORR_ERR_RT    (1 << 12)       /* Reply timer timeout */
-#define ALL_CORR_ERRORS (CORR_ERR_RE | CORR_ERR_BT | CORR_ERR_BD | \
-                        CORR_ERR_RR | CORR_ERR_RT)
-
-/* PCIE Root Control Register bits (Host mode only) */
-#define        PCIE_RC_CORR_SERR_EN            0x0001
-#define        PCIE_RC_NONFATAL_SERR_EN        0x0002
-#define        PCIE_RC_FATAL_SERR_EN           0x0004
-#define        PCIE_RC_PME_INT_EN              0x0008
-#define        PCIE_RC_CRS_EN                  0x0010
-
-/* PCIE Root Capability Register bits (Host mode only) */
-#define        PCIE_RC_CRS_VISIBILITY          0x0001
-
-/* Header to define the PCIE specific capabilities in the extended config space */
-typedef struct _pcie_enhanced_caphdr {
-       u16 capID;
-       u16 cap_ver:4;
-       u16 next_ptr:12;
-} pcie_enhanced_caphdr;
+/* PCI configuration address space size */
+#define PCI_SZPCR              256
 
 /* Everything below is BRCM HND proprietary */
 
 /* Brcm PCI configuration registers */
-#define cap_list       rsvd_a[0]
-#define bar0_window    dev_dep[0x80 - 0x40]
-#define bar1_window    dev_dep[0x84 - 0x40]
-#define sprom_control  dev_dep[0x88 - 0x40]
-#define        PCI_BAR0_WIN            0x80    /* backplane address space accessed by BAR0 */
-#define        PCI_BAR1_WIN            0x84    /* backplane address space accessed by BAR1 */
-#define        PCI_SPROM_CONTROL       0x88    /* sprom property control */
-#define        PCI_BAR1_CONTROL        0x8c    /* BAR1 region burst control */
-#define        PCI_INT_STATUS          0x90    /* PCI and other cores interrupts */
-#define        PCI_INT_MASK            0x94    /* mask of PCI and other cores interrupts */
-#define PCI_TO_SB_MB           0x98    /* signal backplane interrupts */
-#define PCI_BACKPLANE_ADDR     0xa0    /* address an arbitrary location on the system backplane */
-#define PCI_BACKPLANE_DATA     0xa4    /* data at the location specified by above address */
-#define        PCI_CLK_CTL_ST          0xa8    /* pci config space clock control/status (>=rev14) */
-#define        PCI_BAR0_WIN2           0xac    /* backplane address space accessed by second 4KB of BAR0 */
-#define        PCI_GPIO_IN             0xb0    /* pci config space gpio input (>=rev3) */
-#define        PCI_GPIO_OUT            0xb4    /* pci config space gpio output (>=rev3) */
-#define        PCI_GPIO_OUTEN          0xb8    /* pci config space gpio output enable (>=rev3) */
-
-#define        PCI_BAR0_SHADOW_OFFSET  (2 * 1024)      /* bar0 + 2K accesses sprom shadow (in pci core) */
-#define        PCI_BAR0_SPROM_OFFSET   (4 * 1024)      /* bar0 + 4K accesses external sprom */
-#define        PCI_BAR0_PCIREGS_OFFSET (6 * 1024)      /* bar0 + 6K accesses pci core registers */
-#define        PCI_BAR0_PCISBR_OFFSET  (4 * 1024)      /* pci core SB registers are at the end of the
+#define PCI_BAR0_WIN           0x80    /* backplane address space accessed by BAR0 */
+#define PCI_SPROM_CONTROL      0x88    /* sprom property control */
+#define PCI_INT_MASK           0x94    /* mask of PCI and other cores interrupts */
+#define  PCI_SBIM_SHIFT                8       /* backplane core interrupt mask bits offset */
+#define PCI_BAR0_WIN2          0xac    /* backplane address space accessed by second 4KB of BAR0 */
+#define PCI_GPIO_IN            0xb0    /* pci config space gpio input (>=rev3) */
+#define PCI_GPIO_OUT           0xb4    /* pci config space gpio output (>=rev3) */
+#define PCI_GPIO_OUTEN         0xb8    /* pci config space gpio output enable (>=rev3) */
+
+#define PCI_BAR0_SPROM_OFFSET  (4 * 1024)      /* bar0 + 4K accesses external sprom */
+#define PCI_BAR0_PCIREGS_OFFSET        (6 * 1024)      /* bar0 + 6K accesses pci core registers */
+#define PCI_BAR0_PCISBR_OFFSET (4 * 1024)      /* pci core SB registers are at the end of the
                                                 * 8KB window, so their address is the "regular"
                                                 * address plus 4K
                                                 */
 #define PCI_BAR0_WINSZ         (16 * 1024)     /* bar0 window size Match with corerev 13 */
 /* On pci corerev >= 13 and all pcie, the bar0 is now 16KB and it maps: */
-#define        PCI_16KB0_PCIREGS_OFFSET (8 * 1024)     /* bar0 + 8K accesses pci/pcie core registers */
-#define        PCI_16KB0_CCREGS_OFFSET (12 * 1024)     /* bar0 + 12K accesses chipc core registers */
-#define PCI_16KBB0_WINSZ       (16 * 1024)     /* bar0 window size */
-
-/* On AI chips we have a second window to map DMP regs are mapped: */
-#define        PCI_16KB0_WIN2_OFFSET   (4 * 1024)      /* bar0 + 4K is "Window 2" */
-
-/* PCI_INT_STATUS */
-#define        PCI_SBIM_STATUS_SERR    0x4     /* backplane SBErr interrupt status */
-
-/* PCI_INT_MASK */
-#define        PCI_SBIM_SHIFT          8       /* backplane core interrupt mask bits offset */
-#define        PCI_SBIM_MASK           0xff00  /* backplane core interrupt mask */
-#define        PCI_SBIM_MASK_SERR      0x4     /* backplane SBErr interrupt mask */
+#define PCI_16KB0_PCIREGS_OFFSET (8 * 1024)    /* bar0 + 8K accesses pci/pcie core registers */
+#define PCI_16KB0_CCREGS_OFFSET        (12 * 1024)     /* bar0 + 12K accesses chipc core registers */
 
-/* PCI_SPROM_CONTROL */
-#define SPROM_SZ_MSK           0x02    /* SPROM Size Mask */
-#define SPROM_LOCKED           0x08    /* SPROM Locked */
-#define        SPROM_BLANK             0x04    /* indicating a blank SPROM */
-#define SPROM_WRITEEN          0x10    /* SPROM write enable */
-#define SPROM_BOOTROM_WE       0x20    /* external bootrom write enable */
-#define SPROM_BACKPLANE_EN     0x40    /* Enable indirect backplane access */
-#define SPROM_OTPIN_USE                0x80    /* device OTP In use */
+#define PCI_SBIM_STATUS_SERR   0x4     /* backplane SBErr interrupt status */
 
-/* Bits in PCI command and status regs */
-#define PCI_CMD_IO             0x00000001      /* I/O enable */
-#define PCI_CMD_MEMORY         0x00000002      /* Memory enable */
-#define PCI_CMD_MASTER         0x00000004      /* Master enable */
-#define PCI_CMD_SPECIAL                0x00000008      /* Special cycles enable */
-#define PCI_CMD_INVALIDATE     0x00000010      /* Invalidate? */
-#define PCI_CMD_VGA_PAL                0x00000040      /* VGA Palate */
-#define PCI_STAT_TA            0x08000000      /* target abort status */
 #endif                         /* _h_pcicfg_ */
index f608894b117cac63d33ee05ea6f17954d0f535ed..8c01c638ab8ddbd31be9a9297aeeab452dbf49e1 100644 (file)
@@ -225,7 +225,7 @@ typedef volatile struct {
 
 #endif                         /* _LANGUAGE_ASSEMBLY */
 
-#if    defined(IL_BIGENDIAN) && defined(BCMHND74K)
+#if    defined(__BIG_ENDIAN) && defined(BCMHND74K)
 /* Selective swapped defines for those registers we need in
  * big-endian code.
  */
@@ -234,14 +234,14 @@ typedef volatile struct {
 #define        CC_CHIPST               0x28
 #define        CC_EROMPTR              0xf8
 
-#else                          /* !IL_BIGENDIAN || !BCMHND74K */
+#else                          /* !__BIG_ENDIAN || !BCMHND74K */
 
 #define        CC_CHIPID               0
 #define        CC_CAPABILITIES         4
 #define        CC_CHIPST               0x2c
 #define        CC_EROMPTR              0xfc
 
-#endif                         /* IL_BIGENDIAN && BCMHND74K */
+#endif                         /* __BIG_ENDIAN && BCMHND74K */
 
 #define CC_OTPST               0x10
 #define        CC_JTAGCMD              0x30
diff --git a/drivers/staging/brcm80211/include/siutils.h b/drivers/staging/brcm80211/include/siutils.h
deleted file mode 100644 (file)
index 101e9a4..0000000
+++ /dev/null
@@ -1,361 +0,0 @@
-/*
- * Copyright (c) 2010 Broadcom Corporation
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
- * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
- * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifndef        _siutils_h_
-#define        _siutils_h_
-
-#include <hndsoc.h>
-
-/*
- * Data structure to export all chip specific common variables
- *   public (read-only) portion of siutils handle returned by si_attach()
- */
-struct si_pub {
-       uint socitype;          /* SOCI_SB, SOCI_AI */
-
-       uint bustype;           /* SI_BUS, PCI_BUS */
-       uint buscoretype;       /* PCI_CORE_ID, PCIE_CORE_ID, PCMCIA_CORE_ID */
-       uint buscorerev;        /* buscore rev */
-       uint buscoreidx;        /* buscore index */
-       int ccrev;              /* chip common core rev */
-       u32 cccaps;             /* chip common capabilities */
-       u32 cccaps_ext; /* chip common capabilities extension */
-       int pmurev;             /* pmu core rev */
-       u32 pmucaps;            /* pmu capabilities */
-       uint boardtype;         /* board type */
-       uint boardvendor;       /* board vendor */
-       uint boardflags;        /* board flags */
-       uint boardflags2;       /* board flags2 */
-       uint chip;              /* chip number */
-       uint chiprev;           /* chip revision */
-       uint chippkg;           /* chip package option */
-       u32 chipst;             /* chip status */
-       bool issim;             /* chip is in simulation or emulation */
-       uint socirev;           /* SOC interconnect rev */
-       bool pci_pr32414;
-
-};
-
-/* for HIGH_ONLY driver, the si_t must be writable to allow states sync from BMAC to HIGH driver
- * for monolithic driver, it is readonly to prevent accident change
- */
-typedef const struct si_pub si_t;
-
-/*
- * Many of the routines below take an 'sih' handle as their first arg.
- * Allocate this by calling si_attach().  Free it by calling si_detach().
- * At any one time, the sih is logically focused on one particular si core
- * (the "current core").
- * Use si_setcore() or si_setcoreidx() to change the association to another core.
- */
-
-#define        BADIDX          (SI_MAXCORES + 1)
-
-/* clkctl xtal what flags */
-#define        XTAL                    0x1     /* primary crystal oscillator (2050) */
-#define        PLL                     0x2     /* main chip pll */
-
-/* clkctl clk mode */
-#define        CLK_FAST                0       /* force fast (pll) clock */
-#define        CLK_DYNAMIC             2       /* enable dynamic clock control */
-
-/* GPIO usage priorities */
-#define GPIO_DRV_PRIORITY      0       /* Driver */
-#define GPIO_APP_PRIORITY      1       /* Application */
-#define GPIO_HI_PRIORITY       2       /* Highest priority. Ignore GPIO reservation */
-
-/* GPIO pull up/down */
-#define GPIO_PULLUP            0
-#define GPIO_PULLDN            1
-
-/* GPIO event regtype */
-#define GPIO_REGEVT            0       /* GPIO register event */
-#define GPIO_REGEVT_INTMSK     1       /* GPIO register event int mask */
-#define GPIO_REGEVT_INTPOL     2       /* GPIO register event int polarity */
-
-/* device path */
-#define SI_DEVPATH_BUFSZ       16      /* min buffer size in bytes */
-
-/* SI routine enumeration: to be used by update function with multiple hooks */
-#define        SI_DOATTACH     1
-#define SI_PCIDOWN     2
-#define SI_PCIUP       3
-
-#define        ISSIM_ENAB(sih) 0
-
-/* PMU clock/power control */
-#if defined(BCMPMUCTL)
-#define PMUCTL_ENAB(sih)       (BCMPMUCTL)
-#else
-#define PMUCTL_ENAB(sih)       ((sih)->cccaps & CC_CAP_PMU)
-#endif
-
-/* chipcommon clock/power control (exclusive with PMU's) */
-#if defined(BCMPMUCTL) && BCMPMUCTL
-#define CCCTL_ENAB(sih)                (0)
-#define CCPLL_ENAB(sih)                (0)
-#else
-#define CCCTL_ENAB(sih)                ((sih)->cccaps & CC_CAP_PWR_CTL)
-#define CCPLL_ENAB(sih)                ((sih)->cccaps & CC_CAP_PLL_MASK)
-#endif
-
-typedef void (*gpio_handler_t) (u32 stat, void *arg);
-
-/* External PA enable mask */
-#define GPIO_CTRL_EPA_EN_MASK 0x40
-
-/* === exported functions === */
-extern si_t *si_attach(uint pcidev, void *regs, uint bustype,
-                      void *sdh, char **vars, uint *varsz);
-
-extern void si_detach(si_t *sih);
-extern bool si_pci_war16165(si_t *sih);
-
-extern uint si_coreid(si_t *sih);
-extern uint si_flag(si_t *sih);
-extern uint si_coreidx(si_t *sih);
-extern uint si_corerev(si_t *sih);
-extern uint si_corereg(si_t *sih, uint coreidx, uint regoff, uint mask,
-               uint val);
-extern void si_write_wrapperreg(si_t *sih, u32 offset, u32 val);
-extern u32 si_core_cflags(si_t *sih, u32 mask, u32 val);
-extern u32 si_core_sflags(si_t *sih, u32 mask, u32 val);
-extern bool si_iscoreup(si_t *sih);
-extern uint si_findcoreidx(si_t *sih, uint coreid, uint coreunit);
-#ifndef BCMSDIO
-extern void *si_setcoreidx(si_t *sih, uint coreidx);
-#endif
-extern void *si_setcore(si_t *sih, uint coreid, uint coreunit);
-extern void *si_switch_core(si_t *sih, uint coreid, uint *origidx,
-                           uint *intr_val);
-extern void si_restore_core(si_t *sih, uint coreid, uint intr_val);
-extern void si_core_reset(si_t *sih, u32 bits, u32 resetbits);
-extern void si_core_disable(si_t *sih, u32 bits);
-extern u32 si_alp_clock(si_t *sih);
-extern u32 si_ilp_clock(si_t *sih);
-extern void si_pci_setup(si_t *sih, uint coremask);
-extern void si_setint(si_t *sih, int siflag);
-extern bool si_backplane64(si_t *sih);
-extern void si_register_intr_callback(si_t *sih, void *intrsoff_fn,
-                                     void *intrsrestore_fn,
-                                     void *intrsenabled_fn, void *intr_arg);
-extern void si_deregister_intr_callback(si_t *sih);
-extern void si_clkctl_init(si_t *sih);
-extern u16 si_clkctl_fast_pwrup_delay(si_t *sih);
-extern bool si_clkctl_cc(si_t *sih, uint mode);
-extern int si_clkctl_xtal(si_t *sih, uint what, bool on);
-extern bool si_deviceremoved(si_t *sih);
-extern u32 si_socram_size(si_t *sih);
-
-extern void si_watchdog(si_t *sih, uint ticks);
-extern u32 si_gpiocontrol(si_t *sih, u32 mask, u32 val,
-                            u8 priority);
-
-#ifdef BCMSDIO
-extern void si_sdio_init(si_t *sih);
-#endif
-
-#define si_eci(sih) 0
-#define si_eci_init(sih) (0)
-#define si_eci_notify_bt(sih, type, val)  (0)
-#define si_seci(sih) 0
-
-/* OTP status */
-extern bool si_is_otp_disabled(si_t *sih);
-extern bool si_is_otp_powered(si_t *sih);
-extern void si_otp_power(si_t *sih, bool on);
-
-/* SPROM availability */
-extern bool si_is_sprom_available(si_t *sih);
-#ifdef SI_SPROM_PROBE
-extern void si_sprom_init(si_t *sih);
-#endif                         /* SI_SPROM_PROBE */
-
-#define        SI_ERROR(args)
-
-#ifdef BCMDBG
-#define        SI_MSG(args)    printk args
-#else
-#define        SI_MSG(args)
-#endif                         /* BCMDBG */
-
-/* Define SI_VMSG to printf for verbose debugging, but don't check it in */
-#define        SI_VMSG(args)
-
-#define        IS_SIM(chippkg) ((chippkg == HDLSIM_PKG_ID) || (chippkg == HWSIM_PKG_ID))
-
-typedef u32(*si_intrsoff_t) (void *intr_arg);
-typedef void (*si_intrsrestore_t) (void *intr_arg, u32 arg);
-typedef bool(*si_intrsenabled_t) (void *intr_arg);
-
-typedef struct gpioh_item {
-       void *arg;
-       bool level;
-       gpio_handler_t handler;
-       u32 event;
-       struct gpioh_item *next;
-} gpioh_item_t;
-
-/* misc si info needed by some of the routines */
-typedef struct si_info {
-       struct si_pub pub;      /* back plane public state (must be first) */
-       void *pbus;             /* handle to bus (pci/sdio/..) */
-       uint dev_coreid;        /* the core provides driver functions */
-       void *intr_arg;         /* interrupt callback function arg */
-       si_intrsoff_t intrsoff_fn;      /* turns chip interrupts off */
-       si_intrsrestore_t intrsrestore_fn;      /* restore chip interrupts */
-       si_intrsenabled_t intrsenabled_fn;      /* check if interrupts are enabled */
-
-       void *pch;              /* PCI/E core handle */
-
-       gpioh_item_t *gpioh_head;       /* GPIO event handlers list */
-
-       bool memseg;            /* flag to toggle MEM_SEG register */
-
-       char *vars;
-       uint varsz;
-
-       void *curmap;           /* current regs va */
-       void *regs[SI_MAXCORES];        /* other regs va */
-
-       uint curidx;            /* current core index */
-       uint numcores;          /* # discovered cores */
-       uint coreid[SI_MAXCORES];       /* id of each core */
-       u32 coresba[SI_MAXCORES];       /* backplane address of each core */
-       void *regs2[SI_MAXCORES];       /* va of each core second register set (usbh20) */
-       u32 coresba2[SI_MAXCORES];      /* address of each core second register set (usbh20) */
-       u32 coresba_size[SI_MAXCORES];  /* backplane address space size */
-       u32 coresba2_size[SI_MAXCORES]; /* second address space size */
-
-       void *curwrap;          /* current wrapper va */
-       void *wrappers[SI_MAXCORES];    /* other cores wrapper va */
-       u32 wrapba[SI_MAXCORES];        /* address of controlling wrapper */
-
-       u32 cia[SI_MAXCORES];   /* erom cia entry for each core */
-       u32 cib[SI_MAXCORES];   /* erom cia entry for each core */
-       u32 oob_router; /* oob router registers for axi */
-} si_info_t;
-
-#define        SI_INFO(sih)    ((si_info_t *)(sih))
-
-#define        GOODCOREADDR(x, b) (((x) >= (b)) && ((x) < ((b) + SI_MAXCORES * SI_CORE_SIZE)) && \
-               IS_ALIGNED((x), SI_CORE_SIZE))
-#define        GOODREGS(regs)  ((regs) != NULL && IS_ALIGNED((unsigned long)(regs), SI_CORE_SIZE))
-#define BADCOREADDR    0
-#define        GOODIDX(idx)    (((uint)idx) < SI_MAXCORES)
-#define        NOREV           -1      /* Invalid rev */
-
-/* Newer chips can access PCI/PCIE and CC core without requiring to change
- * PCI BAR0 WIN
- */
-#define SI_FAST(si) (((si)->pub.buscoretype == PCIE_CORE_ID) ||        \
-                    (((si)->pub.buscoretype == PCI_CORE_ID) && (si)->pub.buscorerev >= 13))
-
-#define PCIEREGS(si) (((char *)((si)->curmap) + PCI_16KB0_PCIREGS_OFFSET))
-#define CCREGS_FAST(si) (((char *)((si)->curmap) + PCI_16KB0_CCREGS_OFFSET))
-
-/*
- * Macros to disable/restore function core(D11, ENET, ILINE20, etc) interrupts
- * before after core switching to avoid invalid register access inside ISR.
- */
-#define INTR_OFF(si, intr_val) \
-       if ((si)->intrsoff_fn && (si)->coreid[(si)->curidx] == (si)->dev_coreid) {      \
-               intr_val = (*(si)->intrsoff_fn)((si)->intr_arg); }
-#define INTR_RESTORE(si, intr_val) \
-       if ((si)->intrsrestore_fn && (si)->coreid[(si)->curidx] == (si)->dev_coreid) {  \
-               (*(si)->intrsrestore_fn)((si)->intr_arg, intr_val); }
-
-/* dynamic clock control defines */
-#define        LPOMINFREQ              25000   /* low power oscillator min */
-#define        LPOMAXFREQ              43000   /* low power oscillator max */
-#define        XTALMINFREQ             19800000        /* 20 MHz - 1% */
-#define        XTALMAXFREQ             20200000        /* 20 MHz + 1% */
-#define        PCIMINFREQ              25000000        /* 25 MHz */
-#define        PCIMAXFREQ              34000000        /* 33 MHz + fudge */
-
-#define        ILP_DIV_5MHZ            0       /* ILP = 5 MHz */
-#define        ILP_DIV_1MHZ            4       /* ILP = 1 MHz */
-
-#define PCI(si)                (((si)->pub.bustype == PCI_BUS) &&      \
-                        ((si)->pub.buscoretype == PCI_CORE_ID))
-#define PCIE(si)       (((si)->pub.bustype == PCI_BUS) &&      \
-                        ((si)->pub.buscoretype == PCIE_CORE_ID))
-#define PCI_FORCEHT(si)        \
-       (PCIE(si) && (si->pub.chip == BCM4716_CHIP_ID))
-
-/* GPIO Based LED powersave defines */
-#define DEFAULT_GPIO_ONTIME    10      /* Default: 10% on */
-#define DEFAULT_GPIO_OFFTIME   90      /* Default: 10% on */
-
-#ifndef DEFAULT_GPIOTIMERVAL
-#define DEFAULT_GPIOTIMERVAL  ((DEFAULT_GPIO_ONTIME << GPIO_ONTIME_SHIFT) | DEFAULT_GPIO_OFFTIME)
-#endif
-
-/*
- * Build device path. Path size must be >= SI_DEVPATH_BUFSZ.
- * The returned path is NULL terminated and has trailing '/'.
- * Return 0 on success, nonzero otherwise.
- */
-extern int si_devpath(si_t *sih, char *path, int size);
-/* Read variable with prepending the devpath to the name */
-extern char *si_getdevpathvar(si_t *sih, const char *name);
-extern int si_getdevpathintvar(si_t *sih, const char *name);
-
-extern void si_war42780_clkreq(si_t *sih, bool clkreq);
-extern void si_pci_sleep(si_t *sih);
-extern void si_pci_down(si_t *sih);
-extern void si_pci_up(si_t *sih);
-extern void si_pcie_extendL1timer(si_t *sih, bool extend);
-extern int si_pci_fixcfg(si_t *sih);
-
-extern void si_chipcontrl_epa4331(si_t *sih, bool on);
-/* Enable Ex-PA for 4313 */
-extern void si_epa_4313war(si_t *sih);
-
-char *si_getnvramflvar(si_t *sih, const char *name);
-
-/* AMBA Interconnect exported externs */
-extern si_t *ai_attach(uint pcidev, void *regs, uint bustype,
-                      void *sdh, char **vars, uint *varsz);
-extern si_t *ai_kattach(void);
-extern void ai_scan(si_t *sih, void *regs, uint devid);
-
-extern uint ai_flag(si_t *sih);
-extern void ai_setint(si_t *sih, int siflag);
-extern uint ai_coreidx(si_t *sih);
-extern uint ai_corevendor(si_t *sih);
-extern uint ai_corerev(si_t *sih);
-extern bool ai_iscoreup(si_t *sih);
-extern void *ai_setcoreidx(si_t *sih, uint coreidx);
-extern u32 ai_core_cflags(si_t *sih, u32 mask, u32 val);
-extern void ai_core_cflags_wo(si_t *sih, u32 mask, u32 val);
-extern u32 ai_core_sflags(si_t *sih, u32 mask, u32 val);
-extern uint ai_corereg(si_t *sih, uint coreidx, uint regoff, uint mask,
-                      uint val);
-extern void ai_core_reset(si_t *sih, u32 bits, u32 resetbits);
-extern void ai_core_disable(si_t *sih, u32 bits);
-extern int ai_numaddrspaces(si_t *sih);
-extern u32 ai_addrspace(si_t *sih, uint asidx);
-extern u32 ai_addrspacesize(si_t *sih, uint asidx);
-extern void ai_write_wrap_reg(si_t *sih, u32 offset, u32 val);
-
-#ifdef BCMSDIO
-#define si_setcoreidx(sih, idx) sb_setcoreidx(sih, idx)
-#define si_coreid(sih) sb_coreid(sih)
-#define si_corerev(sih) sb_corerev(sih)
-#endif
-
-#endif                         /* _siutils_h_ */
index 5e2b11bcfc6f04afbb5965f433945962bff490ff..2876bd9eff85144d299e4a2553bef08cbe3effa1 100644 (file)
@@ -259,6 +259,7 @@ typedef struct wl_u32_list {
 /* used for association with a specific BSSID and chanspec list */
 typedef struct wl_assoc_params {
        u8 bssid[ETH_ALEN];     /* 00:00:00:00:00:00: broadcast scan */
+       u16 bssid_cnt;
        s32 chanspec_num;       /* 0: all available channels,
                                 * otherwise count of chanspecs in chanspec_list
                                 */
@@ -585,15 +586,6 @@ struct maclist {
        u8 ea[1][ETH_ALEN];     /* variable length array of MAC addresses */
 };
 
-/* get pkt count struct passed through ioctl */
-typedef struct get_pktcnt {
-       uint rx_good_pkt;
-       uint rx_bad_pkt;
-       uint tx_good_pkt;
-       uint tx_bad_pkt;
-       uint rx_ocast_good_pkt; /* unicast packets destined for others */
-} get_pktcnt_t;
-
 #ifdef BRCM_FULLMAC
 /* Linux network driver ioctl encoding */
 typedef struct wl_ioctl {
@@ -1247,8 +1239,6 @@ typedef struct tx_inst_power {
 /* Message levels */
 #define WL_ERROR_VAL           0x00000001
 #define WL_TRACE_VAL           0x00000002
-#define WL_AMPDU_VAL           0x20000000
-#define WL_FFPLD_VAL           0x40000000
 
 /* maximum channels returned by the get valid channels iovar */
 #define WL_NUMCHANNELS         64
@@ -1260,348 +1250,11 @@ struct tsinfo_arg {
 
 #define        NFIFO                   6       /* # tx/rx fifopairs */
 
-#define        WL_CNT_T_VERSION        7       /* current version of wl_cnt_t struct */
-
-struct wl_cnt {
-       u16 version;            /* see definition of WL_CNT_T_VERSION */
-       u16 length;             /* length of entire structure */
-
-       /* transmit stat counters */
-       u32 txframe;            /* tx data frames */
-       u32 txbyte;             /* tx data bytes */
-       u32 txretrans;  /* tx mac retransmits */
-       u32 txerror;            /* tx data errors (derived: sum of others) */
-       u32 txctl;              /* tx management frames */
-       u32 txprshort;  /* tx short preamble frames */
-       u32 txserr;             /* tx status errors */
-       u32 txnobuf;            /* tx out of buffers errors */
-       u32 txnoassoc;  /* tx discard because we're not associated */
-       u32 txrunt;             /* tx runt frames */
-       u32 txchit;             /* tx header cache hit (fastpath) */
-       u32 txcmiss;            /* tx header cache miss (slowpath) */
-       u32 ieee_tx_status;     /* calls to ieee80211_tx_status */
-       u32 ieee_tx;            /* tx calls frm mac0211 */
-       u32 ieee_rx;            /* calls to ieee_rx */
-
-       /* transmit chip error counters */
-       u32 txuflo;             /* tx fifo underflows */
-       u32 txphyerr;   /* tx phy errors (indicated in tx status) */
-       u32 txphycrs;
-
-       /* receive stat counters */
-       u32 rxframe;            /* rx data frames */
-       u32 rxbyte;             /* rx data bytes */
-       u32 rxerror;            /* rx data errors (derived: sum of others) */
-       u32 rxctl;              /* rx management frames */
-       u32 rxnobuf;            /* rx out of buffers errors */
-       u32 rxnondata;  /* rx non data frames in the data channel errors */
-       u32 rxbadds;            /* rx bad DS errors */
-       u32 rxbadcm;            /* rx bad control or management frames */
-       u32 rxfragerr;  /* rx fragmentation errors */
-       u32 rxrunt;             /* rx runt frames */
-       u32 rxgiant;            /* rx giant frames */
-       u32 rxnoscb;            /* rx no scb error */
-       u32 rxbadproto; /* rx invalid frames */
-       u32 rxbadsrcmac;        /* rx frames with Invalid Src Mac */
-       u32 rxbadda;            /* rx frames tossed for invalid da */
-       u32 rxfilter;   /* rx frames filtered out */
-
-       /* receive chip error counters */
-       u32 rxoflo;             /* rx fifo overflow errors */
-       u32 rxuflo[NFIFO];      /* rx dma descriptor underflow errors */
-
-       u32 d11cnt_txrts_off;   /* d11cnt txrts value when reset d11cnt */
-       u32 d11cnt_rxcrc_off;   /* d11cnt rxcrc value when reset d11cnt */
-       u32 d11cnt_txnocts_off; /* d11cnt txnocts value when reset d11cnt */
-
-       /* misc counters */
-       u32 dmade;              /* tx/rx dma descriptor errors */
-       u32 dmada;              /* tx/rx dma data errors */
-       u32 dmape;              /* tx/rx dma descriptor protocol errors */
-       u32 reset;              /* reset count */
-       u32 tbtt;               /* cnts the TBTT int's */
-       u32 txdmawar;
-       u32 pkt_callback_reg_fail;      /* callbacks register failure */
-
-       /* MAC counters: 32-bit version of d11.h's macstat_t */
-       u32 txallfrm;   /* total number of frames sent, incl. Data, ACK, RTS, CTS,
-                                * Control Management (includes retransmissions)
-                                */
-       u32 txrtsfrm;   /* number of RTS sent out by the MAC */
-       u32 txctsfrm;   /* number of CTS sent out by the MAC */
-       u32 txackfrm;   /* number of ACK frames sent out */
-       u32 txdnlfrm;   /* Not used */
-       u32 txbcnfrm;   /* beacons transmitted */
-       u32 txfunfl[8]; /* per-fifo tx underflows */
-       u32 txtplunfl;  /* Template underflows (mac was too slow to transmit ACK/CTS
-                                * or BCN)
-                                */
-       u32 txphyerror; /* Transmit phy error, type of error is reported in tx-status for
-                                * driver enqueued frames
-                                */
-       u32 rxfrmtoolong;       /* Received frame longer than legal limit (2346 bytes) */
-       u32 rxfrmtooshrt;       /* Received frame did not contain enough bytes for its frame type */
-       u32 rxinvmachdr;        /* Either the protocol version != 0 or frame type not
-                                * data/control/management
-                                */
-       u32 rxbadfcs;   /* number of frames for which the CRC check failed in the MAC */
-       u32 rxbadplcp;  /* parity check of the PLCP header failed */
-       u32 rxcrsglitch;        /* PHY was able to correlate the preamble but not the header */
-       u32 rxstrt;             /* Number of received frames with a good PLCP
-                                * (i.e. passing parity check)
-                                */
-       u32 rxdfrmucastmbss;    /* Number of received DATA frames with good FCS and matching RA */
-       u32 rxmfrmucastmbss;    /* number of received mgmt frames with good FCS and matching RA */
-       u32 rxcfrmucast;        /* number of received CNTRL frames with good FCS and matching RA */
-       u32 rxrtsucast; /* number of unicast RTS addressed to the MAC (good FCS) */
-       u32 rxctsucast; /* number of unicast CTS addressed to the MAC (good FCS) */
-       u32 rxackucast; /* number of ucast ACKS received (good FCS) */
-       u32 rxdfrmocast;        /* number of received DATA frames (good FCS and not matching RA) */
-       u32 rxmfrmocast;        /* number of received MGMT frames (good FCS and not matching RA) */
-       u32 rxcfrmocast;        /* number of received CNTRL frame (good FCS and not matching RA) */
-       u32 rxrtsocast; /* number of received RTS not addressed to the MAC */
-       u32 rxctsocast; /* number of received CTS not addressed to the MAC */
-       u32 rxdfrmmcast;        /* number of RX Data multicast frames received by the MAC */
-       u32 rxmfrmmcast;        /* number of RX Management multicast frames received by the MAC */
-       u32 rxcfrmmcast;        /* number of RX Control multicast frames received by the MAC
-                                * (unlikely to see these)
-                                */
-       u32 rxbeaconmbss;       /* beacons received from member of BSS */
-       u32 rxdfrmucastobss;    /* number of unicast frames addressed to the MAC from
-                                * other BSS (WDS FRAME)
-                                */
-       u32 rxbeaconobss;       /* beacons received from other BSS */
-       u32 rxrsptmout; /* Number of response timeouts for transmitted frames
-                                * expecting a response
-                                */
-       u32 bcntxcancl; /* transmit beacons canceled due to receipt of beacon (IBSS) */
-       u32 rxf0ovfl;   /* Number of receive fifo 0 overflows */
-       u32 rxf1ovfl;   /* Number of receive fifo 1 overflows (obsolete) */
-       u32 rxf2ovfl;   /* Number of receive fifo 2 overflows (obsolete) */
-       u32 txsfovfl;   /* Number of transmit status fifo overflows (obsolete) */
-       u32 pmqovfl;            /* Number of PMQ overflows */
-       u32 rxcgprqfrm; /* Number of received Probe requests that made it into
-                                * the PRQ fifo
-                                */
-       u32 rxcgprsqovfl;       /* Rx Probe Request Que overflow in the AP */
-       u32 txcgprsfail;        /* Tx Probe Response Fail. AP sent probe response but did
-                                * not get ACK
-                                */
-       u32 txcgprssuc; /* Tx Probe Response Success (ACK was received) */
-       u32 prs_timeout;        /* Number of probe requests that were dropped from the PRQ
-                                * fifo because a probe response could not be sent out within
-                                * the time limit defined in M_PRS_MAXTIME
-                                */
-       u32 rxnack;
-       u32 frmscons;
-       u32 txnack;
-       u32 txglitch_nack;      /* obsolete */
-       u32 txburst;            /* obsolete */
-
-       /* 802.11 MIB counters, pp. 614 of 802.11 reaff doc. */
-       u32 txfrag;             /* dot11TransmittedFragmentCount */
-       u32 txmulti;            /* dot11MulticastTransmittedFrameCount */
-       u32 txfail;             /* dot11FailedCount */
-       u32 txretry;            /* dot11RetryCount */
-       u32 txretrie;   /* dot11MultipleRetryCount */
-       u32 rxdup;              /* dot11FrameduplicateCount */
-       u32 txrts;              /* dot11RTSSuccessCount */
-       u32 txnocts;            /* dot11RTSFailureCount */
-       u32 txnoack;            /* dot11ACKFailureCount */
-       u32 rxfrag;             /* dot11ReceivedFragmentCount */
-       u32 rxmulti;            /* dot11MulticastReceivedFrameCount */
-       u32 rxcrc;              /* dot11FCSErrorCount */
-       u32 txfrmsnt;   /* dot11TransmittedFrameCount (bogus MIB?) */
-       u32 rxundec;            /* dot11WEPUndecryptableCount */
-
-       /* WPA2 counters (see rxundec for DecryptFailureCount) */
-       u32 tkipmicfaill;       /* TKIPLocalMICFailures */
-       u32 tkipcntrmsr;        /* TKIPCounterMeasuresInvoked */
-       u32 tkipreplay; /* TKIPReplays */
-       u32 ccmpfmterr; /* CCMPFormatErrors */
-       u32 ccmpreplay; /* CCMPReplays */
-       u32 ccmpundec;  /* CCMPDecryptErrors */
-       u32 fourwayfail;        /* FourWayHandshakeFailures */
-       u32 wepundec;   /* dot11WEPUndecryptableCount */
-       u32 wepicverr;  /* dot11WEPICVErrorCount */
-       u32 decsuccess; /* DecryptSuccessCount */
-       u32 tkipicverr; /* TKIPICVErrorCount */
-       u32 wepexcluded;        /* dot11WEPExcludedCount */
-
-       u32 rxundec_mcst;       /* dot11WEPUndecryptableCount */
-
-       /* WPA2 counters (see rxundec for DecryptFailureCount) */
-       u32 tkipmicfaill_mcst;  /* TKIPLocalMICFailures */
-       u32 tkipcntrmsr_mcst;   /* TKIPCounterMeasuresInvoked */
-       u32 tkipreplay_mcst;    /* TKIPReplays */
-       u32 ccmpfmterr_mcst;    /* CCMPFormatErrors */
-       u32 ccmpreplay_mcst;    /* CCMPReplays */
-       u32 ccmpundec_mcst;     /* CCMPDecryptErrors */
-       u32 fourwayfail_mcst;   /* FourWayHandshakeFailures */
-       u32 wepundec_mcst;      /* dot11WEPUndecryptableCount */
-       u32 wepicverr_mcst;     /* dot11WEPICVErrorCount */
-       u32 decsuccess_mcst;    /* DecryptSuccessCount */
-       u32 tkipicverr_mcst;    /* TKIPICVErrorCount */
-       u32 wepexcluded_mcst;   /* dot11WEPExcludedCount */
-
-       u32 txchanrej;  /* Tx frames suppressed due to channel rejection */
-       u32 txexptime;  /* Tx frames suppressed due to timer expiration */
-       u32 psmwds;             /* Count PSM watchdogs */
-       u32 phywatchdog;        /* Count Phy watchdogs (triggered by ucode) */
-
-       /* MBSS counters, AP only */
-       u32 prq_entries_handled;        /* PRQ entries read in */
-       u32 prq_undirected_entries;     /*    which were bcast bss & ssid */
-       u32 prq_bad_entries;    /*    which could not be translated to info */
-       u32 atim_suppress_count;        /* TX suppressions on ATIM fifo */
-       u32 bcn_template_not_ready;     /* Template marked in use on send bcn ... */
-       u32 bcn_template_not_ready_done;        /* ...but "DMA done" interrupt rcvd */
-       u32 late_tbtt_dpc;      /* TBTT DPC did not happen in time */
-
-       /* per-rate receive stat counters */
-       u32 rx1mbps;            /* packets rx at 1Mbps */
-       u32 rx2mbps;            /* packets rx at 2Mbps */
-       u32 rx5mbps5;   /* packets rx at 5.5Mbps */
-       u32 rx6mbps;            /* packets rx at 6Mbps */
-       u32 rx9mbps;            /* packets rx at 9Mbps */
-       u32 rx11mbps;   /* packets rx at 11Mbps */
-       u32 rx12mbps;   /* packets rx at 12Mbps */
-       u32 rx18mbps;   /* packets rx at 18Mbps */
-       u32 rx24mbps;   /* packets rx at 24Mbps */
-       u32 rx36mbps;   /* packets rx at 36Mbps */
-       u32 rx48mbps;   /* packets rx at 48Mbps */
-       u32 rx54mbps;   /* packets rx at 54Mbps */
-       u32 rx108mbps;  /* packets rx at 108mbps */
-       u32 rx162mbps;  /* packets rx at 162mbps */
-       u32 rx216mbps;  /* packets rx at 216 mbps */
-       u32 rx270mbps;  /* packets rx at 270 mbps */
-       u32 rx324mbps;  /* packets rx at 324 mbps */
-       u32 rx378mbps;  /* packets rx at 378 mbps */
-       u32 rx432mbps;  /* packets rx at 432 mbps */
-       u32 rx486mbps;  /* packets rx at 486 mbps */
-       u32 rx540mbps;  /* packets rx at 540 mbps */
-
-       /* pkteng rx frame stats */
-       u32 pktengrxducast;     /* unicast frames rxed by the pkteng code */
-       u32 pktengrxdmcast;     /* multicast frames rxed by the pkteng code */
-
-       u32 rfdisable;  /* count of radio disables */
-       u32 bphy_rxcrsglitch;   /* PHY count of bphy glitches */
-
-       u32 txmpdu_sgi; /* count for sgi transmit */
-       u32 rxmpdu_sgi; /* count for sgi received */
-       u32 txmpdu_stbc;        /* count for stbc transmit */
-       u32 rxmpdu_stbc;        /* count for stbc received */
-};
-
-#define        WL_DELTA_STATS_T_VERSION        1       /* current version of wl_delta_stats_t struct */
-
-typedef struct {
-       u16 version;            /* see definition of WL_DELTA_STATS_T_VERSION */
-       u16 length;             /* length of entire structure */
-
-       /* transmit stat counters */
-       u32 txframe;            /* tx data frames */
-       u32 txbyte;             /* tx data bytes */
-       u32 txretrans;  /* tx mac retransmits */
-       u32 txfail;             /* tx failures */
-
-       /* receive stat counters */
-       u32 rxframe;            /* rx data frames */
-       u32 rxbyte;             /* rx data bytes */
-
-       /* per-rate receive stat counters */
-       u32 rx1mbps;            /* packets rx at 1Mbps */
-       u32 rx2mbps;            /* packets rx at 2Mbps */
-       u32 rx5mbps5;   /* packets rx at 5.5Mbps */
-       u32 rx6mbps;            /* packets rx at 6Mbps */
-       u32 rx9mbps;            /* packets rx at 9Mbps */
-       u32 rx11mbps;   /* packets rx at 11Mbps */
-       u32 rx12mbps;   /* packets rx at 12Mbps */
-       u32 rx18mbps;   /* packets rx at 18Mbps */
-       u32 rx24mbps;   /* packets rx at 24Mbps */
-       u32 rx36mbps;   /* packets rx at 36Mbps */
-       u32 rx48mbps;   /* packets rx at 48Mbps */
-       u32 rx54mbps;   /* packets rx at 54Mbps */
-       u32 rx108mbps;  /* packets rx at 108mbps */
-       u32 rx162mbps;  /* packets rx at 162mbps */
-       u32 rx216mbps;  /* packets rx at 216 mbps */
-       u32 rx270mbps;  /* packets rx at 270 mbps */
-       u32 rx324mbps;  /* packets rx at 324 mbps */
-       u32 rx378mbps;  /* packets rx at 378 mbps */
-       u32 rx432mbps;  /* packets rx at 432 mbps */
-       u32 rx486mbps;  /* packets rx at 486 mbps */
-       u32 rx540mbps;  /* packets rx at 540 mbps */
-} wl_delta_stats_t;
-
-#define WL_WME_CNT_VERSION     1       /* current version of wl_wme_cnt_t */
-
-typedef struct {
-       u32 packets;
-       u32 bytes;
-} wl_traffic_stats_t;
-
-typedef struct {
-       u16 version;            /* see definition of WL_WME_CNT_VERSION */
-       u16 length;             /* length of entire structure */
-
-       wl_traffic_stats_t tx[AC_COUNT];        /* Packets transmitted */
-       wl_traffic_stats_t tx_failed[AC_COUNT]; /* Packets dropped or failed to transmit */
-       wl_traffic_stats_t rx[AC_COUNT];        /* Packets received */
-       wl_traffic_stats_t rx_failed[AC_COUNT]; /* Packets failed to receive */
-
-       wl_traffic_stats_t forward[AC_COUNT];   /* Packets forwarded by AP */
-
-       wl_traffic_stats_t tx_expired[AC_COUNT];        /* packets dropped due to lifetime expiry */
-
-} wl_wme_cnt_t;
-
 struct wl_msglevel2 {
        u32 low;
        u32 high;
 };
 
-#ifdef WLBA
-
-#define        WLC_BA_CNT_VERSION      1       /* current version of wlc_ba_cnt_t */
-
-/* block ack related stats */
-typedef struct wlc_ba_cnt {
-       u16 version;            /* WLC_BA_CNT_VERSION */
-       u16 length;             /* length of entire structure */
-
-       /* transmit stat counters */
-       u32 txpdu;              /* pdus sent */
-       u32 txsdu;              /* sdus sent */
-       u32 txfc;               /* tx side flow controlled packets */
-       u32 txfci;              /* tx side flow control initiated */
-       u32 txretrans;  /* retransmitted pdus */
-       u32 txbatimer;  /* ba resend due to timer */
-       u32 txdrop;             /* dropped packets */
-       u32 txaddbareq; /* addba req sent */
-       u32 txaddbaresp;        /* addba resp sent */
-       u32 txdelba;            /* delba sent */
-       u32 txba;               /* ba sent */
-       u32 txbar;              /* bar sent */
-       u32 txpad[4];   /* future */
-
-       /* receive side counters */
-       u32 rxpdu;              /* pdus recd */
-       u32 rxqed;              /* pdus buffered before sending up */
-       u32 rxdup;              /* duplicate pdus */
-       u32 rxnobuf;            /* pdus discarded due to no buf */
-       u32 rxaddbareq; /* addba req recd */
-       u32 rxaddbaresp;        /* addba resp recd */
-       u32 rxdelba;            /* delba recd */
-       u32 rxba;               /* ba recd */
-       u32 rxbar;              /* bar recd */
-       u32 rxinvba;            /* invalid ba recd */
-       u32 rxbaholes;  /* ba recd with holes */
-       u32 rxunexp;            /* unexpected packets */
-       u32 rxpad[4];   /* future */
-} wlc_ba_cnt_t;
-#endif                         /* WLBA */
-
 /* structure for per-tid ampdu control */
 struct ampdu_tid_control {
        u8 tid;         /* tid */
diff --git a/drivers/staging/brcm80211/util/Makefile b/drivers/staging/brcm80211/util/Makefile
new file mode 100644 (file)
index 0000000..f9b36ca
--- /dev/null
@@ -0,0 +1,29 @@
+#
+# Makefile fragment for Broadcom 802.11n Networking Device Driver Utilities
+#
+# Copyright (c) 2011 Broadcom Corporation
+#
+# Permission to use, copy, modify, and/or distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+# SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+# OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+ccflags-y :=                           \
+       -Idrivers/staging/brcm80211/util \
+       -Idrivers/staging/brcm80211/include
+
+BRCMUTIL_OFILES := \
+       bcmutils.o \
+       bcmwifi.o
+
+MODULEPFX := brcmutil
+
+obj-$(CONFIG_BRCMUTIL) += $(MODULEPFX).o
+$(MODULEPFX)-objs      = $(BRCMUTIL_OFILES)
diff --git a/drivers/staging/brcm80211/util/aiutils.c b/drivers/staging/brcm80211/util/aiutils.c
deleted file mode 100644 (file)
index 5708690..0000000
+++ /dev/null
@@ -1,705 +0,0 @@
-/*
- * Copyright (c) 2010 Broadcom Corporation
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
- * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
- * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <linux/delay.h>
-#include <linux/kernel.h>
-#include <linux/string.h>
-#include <bcmdefs.h>
-#include <linux/module.h>
-#include <linux/pci.h>
-#include <bcmutils.h>
-#include <siutils.h>
-#include <hndsoc.h>
-#include <sbchipc.h>
-#include <pcicfg.h>
-#include <bcmdevs.h>
-
-#define BCM47162_DMP() ((sih->chip == BCM47162_CHIP_ID) && \
-               (sih->chiprev == 0) && \
-               (sii->coreid[sii->curidx] == MIPS74K_CORE_ID))
-
-/* EROM parsing */
-
-static u32
-get_erom_ent(si_t *sih, u32 **eromptr, u32 mask, u32 match)
-{
-       u32 ent;
-       uint inv = 0, nom = 0;
-
-       while (true) {
-               ent = R_REG(*eromptr);
-               (*eromptr)++;
-
-               if (mask == 0)
-                       break;
-
-               if ((ent & ER_VALID) == 0) {
-                       inv++;
-                       continue;
-               }
-
-               if (ent == (ER_END | ER_VALID))
-                       break;
-
-               if ((ent & mask) == match)
-                       break;
-
-               nom++;
-       }
-
-       SI_VMSG(("%s: Returning ent 0x%08x\n", __func__, ent));
-       if (inv + nom) {
-               SI_VMSG(("  after %d invalid and %d non-matching entries\n",
-                        inv, nom));
-       }
-       return ent;
-}
-
-static u32
-get_asd(si_t *sih, u32 **eromptr, uint sp, uint ad, uint st,
-       u32 *addrl, u32 *addrh, u32 *sizel, u32 *sizeh)
-{
-       u32 asd, sz, szd;
-
-       asd = get_erom_ent(sih, eromptr, ER_VALID, ER_VALID);
-       if (((asd & ER_TAG1) != ER_ADD) ||
-           (((asd & AD_SP_MASK) >> AD_SP_SHIFT) != sp) ||
-           ((asd & AD_ST_MASK) != st)) {
-               /* This is not what we want, "push" it back */
-               (*eromptr)--;
-               return 0;
-       }
-       *addrl = asd & AD_ADDR_MASK;
-       if (asd & AD_AG32)
-               *addrh = get_erom_ent(sih, eromptr, 0, 0);
-       else
-               *addrh = 0;
-       *sizeh = 0;
-       sz = asd & AD_SZ_MASK;
-       if (sz == AD_SZ_SZD) {
-               szd = get_erom_ent(sih, eromptr, 0, 0);
-               *sizel = szd & SD_SZ_MASK;
-               if (szd & SD_SG32)
-                       *sizeh = get_erom_ent(sih, eromptr, 0, 0);
-       } else
-               *sizel = AD_SZ_BASE << (sz >> AD_SZ_SHIFT);
-
-       SI_VMSG(("  SP %d, ad %d: st = %d, 0x%08x_0x%08x @ 0x%08x_0x%08x\n",
-                sp, ad, st, *sizeh, *sizel, *addrh, *addrl));
-
-       return asd;
-}
-
-static void ai_hwfixup(si_info_t *sii)
-{
-}
-
-/* parse the enumeration rom to identify all cores */
-void ai_scan(si_t *sih, void *regs, uint devid)
-{
-       si_info_t *sii = SI_INFO(sih);
-       chipcregs_t *cc = (chipcregs_t *) regs;
-       u32 erombase, *eromptr, *eromlim;
-
-       erombase = R_REG(&cc->eromptr);
-
-       switch (sih->bustype) {
-       case SI_BUS:
-               eromptr = (u32 *) REG_MAP(erombase, SI_CORE_SIZE);
-               break;
-
-       case PCI_BUS:
-               /* Set wrappers address */
-               sii->curwrap = (void *)((unsigned long)regs + SI_CORE_SIZE);
-
-               /* Now point the window at the erom */
-               pci_write_config_dword(sii->pbus, PCI_BAR0_WIN, erombase);
-               eromptr = regs;
-               break;
-
-       case SPI_BUS:
-       case SDIO_BUS:
-               eromptr = (u32 *)(unsigned long)erombase;
-               break;
-
-       default:
-               SI_ERROR(("Don't know how to do AXI enumertion on bus %d\n",
-                         sih->bustype));
-               ASSERT(0);
-               return;
-       }
-       eromlim = eromptr + (ER_REMAPCONTROL / sizeof(u32));
-
-       SI_VMSG(("ai_scan: regs = 0x%p, erombase = 0x%08x, eromptr = 0x%p, eromlim = 0x%p\n", regs, erombase, eromptr, eromlim));
-       while (eromptr < eromlim) {
-               u32 cia, cib, cid, mfg, crev, nmw, nsw, nmp, nsp;
-               u32 mpd, asd, addrl, addrh, sizel, sizeh;
-               u32 *base;
-               uint i, j, idx;
-               bool br;
-
-               br = false;
-
-               /* Grok a component */
-               cia = get_erom_ent(sih, &eromptr, ER_TAG, ER_CI);
-               if (cia == (ER_END | ER_VALID)) {
-                       SI_VMSG(("Found END of erom after %d cores\n",
-                                sii->numcores));
-                       ai_hwfixup(sii);
-                       return;
-               }
-               base = eromptr - 1;
-               cib = get_erom_ent(sih, &eromptr, 0, 0);
-
-               if ((cib & ER_TAG) != ER_CI) {
-                       SI_ERROR(("CIA not followed by CIB\n"));
-                       goto error;
-               }
-
-               cid = (cia & CIA_CID_MASK) >> CIA_CID_SHIFT;
-               mfg = (cia & CIA_MFG_MASK) >> CIA_MFG_SHIFT;
-               crev = (cib & CIB_REV_MASK) >> CIB_REV_SHIFT;
-               nmw = (cib & CIB_NMW_MASK) >> CIB_NMW_SHIFT;
-               nsw = (cib & CIB_NSW_MASK) >> CIB_NSW_SHIFT;
-               nmp = (cib & CIB_NMP_MASK) >> CIB_NMP_SHIFT;
-               nsp = (cib & CIB_NSP_MASK) >> CIB_NSP_SHIFT;
-
-               SI_VMSG(("Found component 0x%04x/0x%04x rev %d at erom addr 0x%p, with nmw = %d, " "nsw = %d, nmp = %d & nsp = %d\n", mfg, cid, crev, base, nmw, nsw, nmp, nsp));
-
-               if (((mfg == MFGID_ARM) && (cid == DEF_AI_COMP)) || (nsp == 0))
-                       continue;
-               if ((nmw + nsw == 0)) {
-                       /* A component which is not a core */
-                       if (cid == OOB_ROUTER_CORE_ID) {
-                               asd = get_asd(sih, &eromptr, 0, 0, AD_ST_SLAVE,
-                                             &addrl, &addrh, &sizel, &sizeh);
-                               if (asd != 0) {
-                                       sii->oob_router = addrl;
-                               }
-                       }
-                       continue;
-               }
-
-               idx = sii->numcores;
-/*             sii->eromptr[idx] = base; */
-               sii->cia[idx] = cia;
-               sii->cib[idx] = cib;
-               sii->coreid[idx] = cid;
-
-               for (i = 0; i < nmp; i++) {
-                       mpd = get_erom_ent(sih, &eromptr, ER_VALID, ER_VALID);
-                       if ((mpd & ER_TAG) != ER_MP) {
-                               SI_ERROR(("Not enough MP entries for component 0x%x\n", cid));
-                               goto error;
-                       }
-                       SI_VMSG(("  Master port %d, mp: %d id: %d\n", i,
-                                (mpd & MPD_MP_MASK) >> MPD_MP_SHIFT,
-                                (mpd & MPD_MUI_MASK) >> MPD_MUI_SHIFT));
-               }
-
-               /* First Slave Address Descriptor should be port 0:
-                * the main register space for the core
-                */
-               asd =
-                   get_asd(sih, &eromptr, 0, 0, AD_ST_SLAVE, &addrl, &addrh,
-                           &sizel, &sizeh);
-               if (asd == 0) {
-                       /* Try again to see if it is a bridge */
-                       asd =
-                           get_asd(sih, &eromptr, 0, 0, AD_ST_BRIDGE, &addrl,
-                                   &addrh, &sizel, &sizeh);
-                       if (asd != 0)
-                               br = true;
-                       else if ((addrh != 0) || (sizeh != 0)
-                                || (sizel != SI_CORE_SIZE)) {
-                               SI_ERROR(("First Slave ASD for core 0x%04x malformed " "(0x%08x)\n", cid, asd));
-                               goto error;
-                       }
-               }
-               sii->coresba[idx] = addrl;
-               sii->coresba_size[idx] = sizel;
-               /* Get any more ASDs in port 0 */
-               j = 1;
-               do {
-                       asd =
-                           get_asd(sih, &eromptr, 0, j, AD_ST_SLAVE, &addrl,
-                                   &addrh, &sizel, &sizeh);
-                       if ((asd != 0) && (j == 1) && (sizel == SI_CORE_SIZE)) {
-                               sii->coresba2[idx] = addrl;
-                               sii->coresba2_size[idx] = sizel;
-                       }
-                       j++;
-               } while (asd != 0);
-
-               /* Go through the ASDs for other slave ports */
-               for (i = 1; i < nsp; i++) {
-                       j = 0;
-                       do {
-                               asd =
-                                   get_asd(sih, &eromptr, i, j++, AD_ST_SLAVE,
-                                           &addrl, &addrh, &sizel, &sizeh);
-                       } while (asd != 0);
-                       if (j == 0) {
-                               SI_ERROR((" SP %d has no address descriptors\n",
-                                         i));
-                               goto error;
-                       }
-               }
-
-               /* Now get master wrappers */
-               for (i = 0; i < nmw; i++) {
-                       asd =
-                           get_asd(sih, &eromptr, i, 0, AD_ST_MWRAP, &addrl,
-                                   &addrh, &sizel, &sizeh);
-                       if (asd == 0) {
-                               SI_ERROR(("Missing descriptor for MW %d\n", i));
-                               goto error;
-                       }
-                       if ((sizeh != 0) || (sizel != SI_CORE_SIZE)) {
-                               SI_ERROR(("Master wrapper %d is not 4KB\n", i));
-                               goto error;
-                       }
-                       if (i == 0)
-                               sii->wrapba[idx] = addrl;
-               }
-
-               /* And finally slave wrappers */
-               for (i = 0; i < nsw; i++) {
-                       uint fwp = (nsp == 1) ? 0 : 1;
-                       asd =
-                           get_asd(sih, &eromptr, fwp + i, 0, AD_ST_SWRAP,
-                                   &addrl, &addrh, &sizel, &sizeh);
-                       if (asd == 0) {
-                               SI_ERROR(("Missing descriptor for SW %d\n", i));
-                               goto error;
-                       }
-                       if ((sizeh != 0) || (sizel != SI_CORE_SIZE)) {
-                               SI_ERROR(("Slave wrapper %d is not 4KB\n", i));
-                               goto error;
-                       }
-                       if ((nmw == 0) && (i == 0))
-                               sii->wrapba[idx] = addrl;
-               }
-
-               /* Don't record bridges */
-               if (br)
-                       continue;
-
-               /* Done with core */
-               sii->numcores++;
-       }
-
-       SI_ERROR(("Reached end of erom without finding END"));
-
- error:
-       sii->numcores = 0;
-       return;
-}
-
-/* This function changes the logical "focus" to the indicated core.
- * Return the current core's virtual address.
- */
-void *ai_setcoreidx(si_t *sih, uint coreidx)
-{
-       si_info_t *sii = SI_INFO(sih);
-       u32 addr = sii->coresba[coreidx];
-       u32 wrap = sii->wrapba[coreidx];
-       void *regs;
-
-       if (coreidx >= sii->numcores)
-               return NULL;
-
-       /*
-        * If the user has provided an interrupt mask enabled function,
-        * then assert interrupts are disabled before switching the core.
-        */
-       ASSERT((sii->intrsenabled_fn == NULL)
-              || !(*(sii)->intrsenabled_fn) ((sii)->intr_arg));
-
-       switch (sih->bustype) {
-       case SI_BUS:
-               /* map new one */
-               if (!sii->regs[coreidx]) {
-                       sii->regs[coreidx] = REG_MAP(addr, SI_CORE_SIZE);
-                       ASSERT(GOODREGS(sii->regs[coreidx]));
-               }
-               sii->curmap = regs = sii->regs[coreidx];
-               if (!sii->wrappers[coreidx]) {
-                       sii->wrappers[coreidx] = REG_MAP(wrap, SI_CORE_SIZE);
-                       ASSERT(GOODREGS(sii->wrappers[coreidx]));
-               }
-               sii->curwrap = sii->wrappers[coreidx];
-               break;
-
-       case PCI_BUS:
-               /* point bar0 window */
-               pci_write_config_dword(sii->pbus, PCI_BAR0_WIN, addr);
-               regs = sii->curmap;
-               /* point bar0 2nd 4KB window */
-               pci_write_config_dword(sii->pbus, PCI_BAR0_WIN2, wrap);
-               break;
-
-       case SPI_BUS:
-       case SDIO_BUS:
-               sii->curmap = regs = (void *)(unsigned long)addr;
-               sii->curwrap = (void *)(unsigned long)wrap;
-               break;
-
-       default:
-               ASSERT(0);
-               regs = NULL;
-               break;
-       }
-
-       sii->curmap = regs;
-       sii->curidx = coreidx;
-
-       return regs;
-}
-
-/* Return the number of address spaces in current core */
-int ai_numaddrspaces(si_t *sih)
-{
-       return 2;
-}
-
-/* Return the address of the nth address space in the current core */
-u32 ai_addrspace(si_t *sih, uint asidx)
-{
-       si_info_t *sii;
-       uint cidx;
-
-       sii = SI_INFO(sih);
-       cidx = sii->curidx;
-
-       if (asidx == 0)
-               return sii->coresba[cidx];
-       else if (asidx == 1)
-               return sii->coresba2[cidx];
-       else {
-               SI_ERROR(("%s: Need to parse the erom again to find addr space %d\n", __func__, asidx));
-               return 0;
-       }
-}
-
-/* Return the size of the nth address space in the current core */
-u32 ai_addrspacesize(si_t *sih, uint asidx)
-{
-       si_info_t *sii;
-       uint cidx;
-
-       sii = SI_INFO(sih);
-       cidx = sii->curidx;
-
-       if (asidx == 0)
-               return sii->coresba_size[cidx];
-       else if (asidx == 1)
-               return sii->coresba2_size[cidx];
-       else {
-               SI_ERROR(("%s: Need to parse the erom again to find addr space %d\n", __func__, asidx));
-               return 0;
-       }
-}
-
-uint ai_flag(si_t *sih)
-{
-       si_info_t *sii;
-       aidmp_t *ai;
-
-       sii = SI_INFO(sih);
-       if (BCM47162_DMP()) {
-               SI_ERROR(("%s: Attempting to read MIPS DMP registers on 47162a0", __func__));
-               return sii->curidx;
-       }
-       ai = sii->curwrap;
-
-       return R_REG(&ai->oobselouta30) & 0x1f;
-}
-
-void ai_setint(si_t *sih, int siflag)
-{
-}
-
-void ai_write_wrap_reg(si_t *sih, u32 offset, u32 val)
-{
-       si_info_t *sii = SI_INFO(sih);
-       u32 *w = (u32 *) sii->curwrap;
-       W_REG(w + (offset / 4), val);
-       return;
-}
-
-uint ai_corevendor(si_t *sih)
-{
-       si_info_t *sii;
-       u32 cia;
-
-       sii = SI_INFO(sih);
-       cia = sii->cia[sii->curidx];
-       return (cia & CIA_MFG_MASK) >> CIA_MFG_SHIFT;
-}
-
-uint ai_corerev(si_t *sih)
-{
-       si_info_t *sii;
-       u32 cib;
-
-       sii = SI_INFO(sih);
-       cib = sii->cib[sii->curidx];
-       return (cib & CIB_REV_MASK) >> CIB_REV_SHIFT;
-}
-
-bool ai_iscoreup(si_t *sih)
-{
-       si_info_t *sii;
-       aidmp_t *ai;
-
-       sii = SI_INFO(sih);
-       ai = sii->curwrap;
-
-       return (((R_REG(&ai->ioctrl) & (SICF_FGC | SICF_CLOCK_EN)) ==
-                SICF_CLOCK_EN)
-               && ((R_REG(&ai->resetctrl) & AIRC_RESET) == 0));
-}
-
-/*
- * Switch to 'coreidx', issue a single arbitrary 32bit register mask&set operation,
- * switch back to the original core, and return the new value.
- *
- * When using the silicon backplane, no fiddling with interrupts or core switches is needed.
- *
- * Also, when using pci/pcie, we can optimize away the core switching for pci registers
- * and (on newer pci cores) chipcommon registers.
- */
-uint ai_corereg(si_t *sih, uint coreidx, uint regoff, uint mask, uint val)
-{
-       uint origidx = 0;
-       u32 *r = NULL;
-       uint w;
-       uint intr_val = 0;
-       bool fast = false;
-       si_info_t *sii;
-
-       sii = SI_INFO(sih);
-
-       ASSERT(GOODIDX(coreidx));
-       ASSERT(regoff < SI_CORE_SIZE);
-       ASSERT((val & ~mask) == 0);
-
-       if (coreidx >= SI_MAXCORES)
-               return 0;
-
-       if (sih->bustype == SI_BUS) {
-               /* If internal bus, we can always get at everything */
-               fast = true;
-               /* map if does not exist */
-               if (!sii->regs[coreidx]) {
-                       sii->regs[coreidx] = REG_MAP(sii->coresba[coreidx],
-                                                    SI_CORE_SIZE);
-                       ASSERT(GOODREGS(sii->regs[coreidx]));
-               }
-               r = (u32 *) ((unsigned char *) sii->regs[coreidx] + regoff);
-       } else if (sih->bustype == PCI_BUS) {
-               /* If pci/pcie, we can get at pci/pcie regs and on newer cores to chipc */
-
-               if ((sii->coreid[coreidx] == CC_CORE_ID) && SI_FAST(sii)) {
-                       /* Chipc registers are mapped at 12KB */
-
-                       fast = true;
-                       r = (u32 *) ((char *)sii->curmap +
-                                       PCI_16KB0_CCREGS_OFFSET + regoff);
-               } else if (sii->pub.buscoreidx == coreidx) {
-                       /* pci registers are at either in the last 2KB of an 8KB window
-                        * or, in pcie and pci rev 13 at 8KB
-                        */
-                       fast = true;
-                       if (SI_FAST(sii))
-                               r = (u32 *) ((char *)sii->curmap +
-                                               PCI_16KB0_PCIREGS_OFFSET +
-                                               regoff);
-                       else
-                               r = (u32 *) ((char *)sii->curmap +
-                                               ((regoff >= SBCONFIGOFF) ?
-                                                PCI_BAR0_PCISBR_OFFSET :
-                                                PCI_BAR0_PCIREGS_OFFSET) +
-                                               regoff);
-               }
-       }
-
-       if (!fast) {
-               INTR_OFF(sii, intr_val);
-
-               /* save current core index */
-               origidx = si_coreidx(&sii->pub);
-
-               /* switch core */
-               r = (u32 *) ((unsigned char *) ai_setcoreidx(&sii->pub, coreidx) +
-                               regoff);
-       }
-       ASSERT(r != NULL);
-
-       /* mask and set */
-       if (mask || val) {
-               w = (R_REG(r) & ~mask) | val;
-               W_REG(r, w);
-       }
-
-       /* readback */
-       w = R_REG(r);
-
-       if (!fast) {
-               /* restore core index */
-               if (origidx != coreidx)
-                       ai_setcoreidx(&sii->pub, origidx);
-
-               INTR_RESTORE(sii, intr_val);
-       }
-
-       return w;
-}
-
-void ai_core_disable(si_t *sih, u32 bits)
-{
-       si_info_t *sii;
-       volatile u32 dummy;
-       aidmp_t *ai;
-
-       sii = SI_INFO(sih);
-
-       ASSERT(GOODREGS(sii->curwrap));
-       ai = sii->curwrap;
-
-       /* if core is already in reset, just return */
-       if (R_REG(&ai->resetctrl) & AIRC_RESET)
-               return;
-
-       W_REG(&ai->ioctrl, bits);
-       dummy = R_REG(&ai->ioctrl);
-       udelay(10);
-
-       W_REG(&ai->resetctrl, AIRC_RESET);
-       udelay(1);
-}
-
-/* reset and re-enable a core
- * inputs:
- * bits - core specific bits that are set during and after reset sequence
- * resetbits - core specific bits that are set only during reset sequence
- */
-void ai_core_reset(si_t *sih, u32 bits, u32 resetbits)
-{
-       si_info_t *sii;
-       aidmp_t *ai;
-       volatile u32 dummy;
-
-       sii = SI_INFO(sih);
-       ASSERT(GOODREGS(sii->curwrap));
-       ai = sii->curwrap;
-
-       /*
-        * Must do the disable sequence first to work for arbitrary current core state.
-        */
-       ai_core_disable(sih, (bits | resetbits));
-
-       /*
-        * Now do the initialization sequence.
-        */
-       W_REG(&ai->ioctrl, (bits | SICF_FGC | SICF_CLOCK_EN));
-       dummy = R_REG(&ai->ioctrl);
-       W_REG(&ai->resetctrl, 0);
-       udelay(1);
-
-       W_REG(&ai->ioctrl, (bits | SICF_CLOCK_EN));
-       dummy = R_REG(&ai->ioctrl);
-       udelay(1);
-}
-
-void ai_core_cflags_wo(si_t *sih, u32 mask, u32 val)
-{
-       si_info_t *sii;
-       aidmp_t *ai;
-       u32 w;
-
-       sii = SI_INFO(sih);
-
-       if (BCM47162_DMP()) {
-               SI_ERROR(("%s: Accessing MIPS DMP register (ioctrl) on 47162a0",
-                         __func__));
-               return;
-       }
-
-       ASSERT(GOODREGS(sii->curwrap));
-       ai = sii->curwrap;
-
-       ASSERT((val & ~mask) == 0);
-
-       if (mask || val) {
-               w = ((R_REG(&ai->ioctrl) & ~mask) | val);
-               W_REG(&ai->ioctrl, w);
-       }
-}
-
-u32 ai_core_cflags(si_t *sih, u32 mask, u32 val)
-{
-       si_info_t *sii;
-       aidmp_t *ai;
-       u32 w;
-
-       sii = SI_INFO(sih);
-       if (BCM47162_DMP()) {
-               SI_ERROR(("%s: Accessing MIPS DMP register (ioctrl) on 47162a0",
-                         __func__));
-               return 0;
-       }
-
-       ASSERT(GOODREGS(sii->curwrap));
-       ai = sii->curwrap;
-
-       ASSERT((val & ~mask) == 0);
-
-       if (mask || val) {
-               w = ((R_REG(&ai->ioctrl) & ~mask) | val);
-               W_REG(&ai->ioctrl, w);
-       }
-
-       return R_REG(&ai->ioctrl);
-}
-
-u32 ai_core_sflags(si_t *sih, u32 mask, u32 val)
-{
-       si_info_t *sii;
-       aidmp_t *ai;
-       u32 w;
-
-       sii = SI_INFO(sih);
-       if (BCM47162_DMP()) {
-               SI_ERROR(("%s: Accessing MIPS DMP register (iostatus) on 47162a0", __func__));
-               return 0;
-       }
-
-       ASSERT(GOODREGS(sii->curwrap));
-       ai = sii->curwrap;
-
-       ASSERT((val & ~mask) == 0);
-       ASSERT((mask & ~SISF_CORE_BITS) == 0);
-
-       if (mask || val) {
-               w = ((R_REG(&ai->iostatus) & ~mask) | val);
-               W_REG(&ai->iostatus, w);
-       }
-
-       return R_REG(&ai->iostatus);
-}
-
diff --git a/drivers/staging/brcm80211/util/bcmsrom.c b/drivers/staging/brcm80211/util/bcmsrom.c
deleted file mode 100644 (file)
index 850bfa6..0000000
+++ /dev/null
@@ -1,2088 +0,0 @@
-/*
- * Copyright (c) 2010 Broadcom Corporation
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
- * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
- * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-#include <linux/kernel.h>
-#include <linux/string.h>
-#include <linux/etherdevice.h>
-#include <bcmdefs.h>
-#include <linux/module.h>
-#include <linux/pci.h>
-#include <stdarg.h>
-#include <bcmutils.h>
-#include <hndsoc.h>
-#include <sbchipc.h>
-#include <bcmdevs.h>
-#include <pcicfg.h>
-#include <siutils.h>
-#include <bcmsrom.h>
-#include <bcmsrom_tbl.h>
-#ifdef BCMSDIO
-#include <bcmsdh.h>
-#include <sdio.h>
-#endif
-
-#include <bcmnvram.h>
-#include <bcmotp.h>
-
-#if defined(BCMSDIO)
-#include <sbsdio.h>
-#include <sbhnddma.h>
-#include <sbsdpcmdev.h>
-#endif
-
-#include <linux/if_ether.h>
-
-#define        BS_ERROR(args)
-
-#define SROM_OFFSET(sih) ((sih->ccrev > 31) ? \
-       (((sih->cccaps & CC_CAP_SROM) == 0) ? NULL : \
-        ((u8 *)curmap + PCI_16KB0_CCREGS_OFFSET + CC_SROM_OTP)) : \
-       ((u8 *)curmap + PCI_BAR0_SPROM_OFFSET))
-
-#if defined(BCMDBG)
-#define WRITE_ENABLE_DELAY     500     /* 500 ms after write enable/disable toggle */
-#define WRITE_WORD_DELAY       20      /* 20 ms between each word write */
-#endif
-
-typedef struct varbuf {
-       char *base;             /* pointer to buffer base */
-       char *buf;              /* pointer to current position */
-       unsigned int size;      /* current (residual) size in bytes */
-} varbuf_t;
-extern char *_vars;
-extern uint _varsz;
-
-#define SROM_CIS_SINGLE        1
-
-static int initvars_srom_si(si_t *sih, void *curmap, char **vars, uint *count);
-static void _initvars_srom_pci(u8 sromrev, u16 *srom, uint off, varbuf_t *b);
-static int initvars_srom_pci(si_t *sih, void *curmap, char **vars, uint *count);
-static int initvars_flash_si(si_t *sih, char **vars, uint *count);
-#ifdef BCMSDIO
-static int initvars_cis_sdio(char **vars, uint *count);
-static int sprom_cmd_sdio(u8 cmd);
-static int sprom_read_sdio(u16 addr, u16 *data);
-#endif                         /* BCMSDIO */
-static int sprom_read_pci(si_t *sih, u16 *sprom,
-                         uint wordoff, u16 *buf, uint nwords, bool check_crc);
-#if defined(BCMNVRAMR)
-static int otp_read_pci(si_t *sih, u16 *buf, uint bufsz);
-#endif
-static u16 srom_cc_cmd(si_t *sih, void *ccregs, u32 cmd,
-                         uint wordoff, u16 data);
-
-static int initvars_table(char *start, char *end,
-                         char **vars, uint *count);
-static int initvars_flash(si_t *sih, char **vp,
-                         uint len);
-
-/* Initialization of varbuf structure */
-static void varbuf_init(varbuf_t *b, char *buf, uint size)
-{
-       b->size = size;
-       b->base = b->buf = buf;
-}
-
-/* append a null terminated var=value string */
-static int varbuf_append(varbuf_t *b, const char *fmt, ...)
-{
-       va_list ap;
-       int r;
-       size_t len;
-       char *s;
-
-       if (b->size < 2)
-               return 0;
-
-       va_start(ap, fmt);
-       r = vsnprintf(b->buf, b->size, fmt, ap);
-       va_end(ap);
-
-       /* C99 snprintf behavior returns r >= size on overflow,
-        * others return -1 on overflow.
-        * All return -1 on format error.
-        * We need to leave room for 2 null terminations, one for the current var
-        * string, and one for final null of the var table. So check that the
-        * strlen written, r, leaves room for 2 chars.
-        */
-       if ((r == -1) || (r > (int)(b->size - 2))) {
-               b->size = 0;
-               return 0;
-       }
-
-       /* Remove any earlier occurrence of the same variable */
-       s = strchr(b->buf, '=');
-       if (s != NULL) {
-               len = (size_t) (s - b->buf);
-               for (s = b->base; s < b->buf;) {
-                       if ((memcmp(s, b->buf, len) == 0) && s[len] == '=') {
-                               len = strlen(s) + 1;
-                               memmove(s, (s + len),
-                                       ((b->buf + r + 1) - (s + len)));
-                               b->buf -= len;
-                               b->size += (unsigned int)len;
-                               break;
-                       }
-
-                       while (*s++)
-                               ;
-               }
-       }
-
-       /* skip over this string's null termination */
-       r++;
-       b->size -= r;
-       b->buf += r;
-
-       return r;
-}
-
-/*
- * Initialize local vars from the right source for this platform.
- * Return 0 on success, nonzero on error.
- */
-int srom_var_init(si_t *sih, uint bustype, void *curmap,
-                 char **vars, uint *count)
-{
-       uint len;
-
-       len = 0;
-
-       ASSERT(bustype == bustype);
-       if (vars == NULL || count == NULL)
-               return 0;
-
-       *vars = NULL;
-       *count = 0;
-
-       switch (bustype) {
-       case SI_BUS:
-       case JTAG_BUS:
-               return initvars_srom_si(sih, curmap, vars, count);
-
-       case PCI_BUS:
-               ASSERT(curmap != NULL);
-               if (curmap == NULL)
-                       return -1;
-
-               return initvars_srom_pci(sih, curmap, vars, count);
-
-#ifdef BCMSDIO
-       case SDIO_BUS:
-               return initvars_cis_sdio(vars, count);
-#endif                         /* BCMSDIO */
-
-       default:
-               ASSERT(0);
-       }
-       return -1;
-}
-
-/* support only 16-bit word read from srom */
-int
-srom_read(si_t *sih, uint bustype, void *curmap,
-         uint byteoff, uint nbytes, u16 *buf, bool check_crc)
-{
-       uint off, nw;
-#ifdef BCMSDIO
-       uint i;
-#endif                         /* BCMSDIO */
-
-       ASSERT(bustype == bustype);
-
-       /* check input - 16-bit access only */
-       if (byteoff & 1 || nbytes & 1 || (byteoff + nbytes) > SROM_MAX)
-               return 1;
-
-       off = byteoff / 2;
-       nw = nbytes / 2;
-
-       if (bustype == PCI_BUS) {
-               if (!curmap)
-                       return 1;
-
-               if (si_is_sprom_available(sih)) {
-                       u16 *srom;
-
-                       srom = (u16 *) SROM_OFFSET(sih);
-                       if (srom == NULL)
-                               return 1;
-
-                       if (sprom_read_pci
-                           (sih, srom, off, buf, nw, check_crc))
-                               return 1;
-               }
-#if defined(BCMNVRAMR)
-               else {
-                       if (otp_read_pci(sih, buf, SROM_MAX))
-                               return 1;
-               }
-#endif
-#ifdef BCMSDIO
-       } else if (bustype == SDIO_BUS) {
-               off = byteoff / 2;
-               nw = nbytes / 2;
-               for (i = 0; i < nw; i++) {
-                       if (sprom_read_sdio
-                           ((u16) (off + i), (u16 *) (buf + i)))
-                               return 1;
-               }
-#endif                         /* BCMSDIO */
-       } else if (bustype == SI_BUS) {
-               return 1;
-       } else {
-               return 1;
-       }
-
-       return 0;
-}
-
-static const char vstr_manf[] = "manf=%s";
-static const char vstr_productname[] = "productname=%s";
-static const char vstr_manfid[] = "manfid=0x%x";
-static const char vstr_prodid[] = "prodid=0x%x";
-#ifdef BCMSDIO
-static const char vstr_sdmaxspeed[] = "sdmaxspeed=%d";
-static const char vstr_sdmaxblk[][13] = {
-"sdmaxblk0=%d", "sdmaxblk1=%d", "sdmaxblk2=%d"};
-#endif
-static const char vstr_regwindowsz[] = "regwindowsz=%d";
-static const char vstr_sromrev[] = "sromrev=%d";
-static const char vstr_chiprev[] = "chiprev=%d";
-static const char vstr_subvendid[] = "subvendid=0x%x";
-static const char vstr_subdevid[] = "subdevid=0x%x";
-static const char vstr_boardrev[] = "boardrev=0x%x";
-static const char vstr_aa2g[] = "aa2g=0x%x";
-static const char vstr_aa5g[] = "aa5g=0x%x";
-static const char vstr_ag[] = "ag%d=0x%x";
-static const char vstr_cc[] = "cc=%d";
-static const char vstr_opo[] = "opo=%d";
-static const char vstr_pa0b[][9] = {
-"pa0b0=%d", "pa0b1=%d", "pa0b2=%d"};
-
-static const char vstr_pa0itssit[] = "pa0itssit=%d";
-static const char vstr_pa0maxpwr[] = "pa0maxpwr=%d";
-static const char vstr_pa1b[][9] = {
-"pa1b0=%d", "pa1b1=%d", "pa1b2=%d"};
-
-static const char vstr_pa1lob[][11] = {
-"pa1lob0=%d", "pa1lob1=%d", "pa1lob2=%d"};
-
-static const char vstr_pa1hib[][11] = {
-"pa1hib0=%d", "pa1hib1=%d", "pa1hib2=%d"};
-
-static const char vstr_pa1itssit[] = "pa1itssit=%d";
-static const char vstr_pa1maxpwr[] = "pa1maxpwr=%d";
-static const char vstr_pa1lomaxpwr[] = "pa1lomaxpwr=%d";
-static const char vstr_pa1himaxpwr[] = "pa1himaxpwr=%d";
-static const char vstr_oem[] =
-    "oem=%02x%02x%02x%02x%02x%02x%02x%02x";
-static const char vstr_boardflags[] = "boardflags=0x%x";
-static const char vstr_boardflags2[] = "boardflags2=0x%x";
-static const char vstr_ledbh[] = "ledbh%d=0x%x";
-static const char vstr_noccode[] = "ccode=0x0";
-static const char vstr_ccode[] = "ccode=%c%c";
-static const char vstr_cctl[] = "cctl=0x%x";
-static const char vstr_cckpo[] = "cckpo=0x%x";
-static const char vstr_ofdmpo[] = "ofdmpo=0x%x";
-static const char vstr_rdlid[] = "rdlid=0x%x";
-static const char vstr_rdlrndis[] = "rdlrndis=%d";
-static const char vstr_rdlrwu[] = "rdlrwu=%d";
-static const char vstr_usbfs[] = "usbfs=%d";
-static const char vstr_wpsgpio[] = "wpsgpio=%d";
-static const char vstr_wpsled[] = "wpsled=%d";
-static const char vstr_rdlsn[] = "rdlsn=%d";
-static const char vstr_rssismf2g[] = "rssismf2g=%d";
-static const char vstr_rssismc2g[] = "rssismc2g=%d";
-static const char vstr_rssisav2g[] = "rssisav2g=%d";
-static const char vstr_bxa2g[] = "bxa2g=%d";
-static const char vstr_rssismf5g[] = "rssismf5g=%d";
-static const char vstr_rssismc5g[] = "rssismc5g=%d";
-static const char vstr_rssisav5g[] = "rssisav5g=%d";
-static const char vstr_bxa5g[] = "bxa5g=%d";
-static const char vstr_tri2g[] = "tri2g=%d";
-static const char vstr_tri5gl[] = "tri5gl=%d";
-static const char vstr_tri5g[] = "tri5g=%d";
-static const char vstr_tri5gh[] = "tri5gh=%d";
-static const char vstr_rxpo2g[] = "rxpo2g=%d";
-static const char vstr_rxpo5g[] = "rxpo5g=%d";
-static const char vstr_boardtype[] = "boardtype=0x%x";
-static const char vstr_leddc[] = "leddc=0x%04x";
-static const char vstr_vendid[] = "vendid=0x%x";
-static const char vstr_devid[] = "devid=0x%x";
-static const char vstr_xtalfreq[] = "xtalfreq=%d";
-static const char vstr_txchain[] = "txchain=0x%x";
-static const char vstr_rxchain[] = "rxchain=0x%x";
-static const char vstr_antswitch[] = "antswitch=0x%x";
-static const char vstr_regrev[] = "regrev=0x%x";
-static const char vstr_antswctl2g[] = "antswctl2g=0x%x";
-static const char vstr_triso2g[] = "triso2g=0x%x";
-static const char vstr_pdetrange2g[] = "pdetrange2g=0x%x";
-static const char vstr_extpagain2g[] = "extpagain2g=0x%x";
-static const char vstr_tssipos2g[] = "tssipos2g=0x%x";
-static const char vstr_antswctl5g[] = "antswctl5g=0x%x";
-static const char vstr_triso5g[] = "triso5g=0x%x";
-static const char vstr_pdetrange5g[] = "pdetrange5g=0x%x";
-static const char vstr_extpagain5g[] = "extpagain5g=0x%x";
-static const char vstr_tssipos5g[] = "tssipos5g=0x%x";
-static const char vstr_maxp2ga0[] = "maxp2ga0=0x%x";
-static const char vstr_itt2ga0[] = "itt2ga0=0x%x";
-static const char vstr_pa[] = "pa%dgw%da%d=0x%x";
-static const char vstr_pahl[] = "pa%dg%cw%da%d=0x%x";
-static const char vstr_maxp5ga0[] = "maxp5ga0=0x%x";
-static const char vstr_itt5ga0[] = "itt5ga0=0x%x";
-static const char vstr_maxp5gha0[] = "maxp5gha0=0x%x";
-static const char vstr_maxp5gla0[] = "maxp5gla0=0x%x";
-static const char vstr_maxp2ga1[] = "maxp2ga1=0x%x";
-static const char vstr_itt2ga1[] = "itt2ga1=0x%x";
-static const char vstr_maxp5ga1[] = "maxp5ga1=0x%x";
-static const char vstr_itt5ga1[] = "itt5ga1=0x%x";
-static const char vstr_maxp5gha1[] = "maxp5gha1=0x%x";
-static const char vstr_maxp5gla1[] = "maxp5gla1=0x%x";
-static const char vstr_cck2gpo[] = "cck2gpo=0x%x";
-static const char vstr_ofdm2gpo[] = "ofdm2gpo=0x%x";
-static const char vstr_ofdm5gpo[] = "ofdm5gpo=0x%x";
-static const char vstr_ofdm5glpo[] = "ofdm5glpo=0x%x";
-static const char vstr_ofdm5ghpo[] = "ofdm5ghpo=0x%x";
-static const char vstr_cddpo[] = "cddpo=0x%x";
-static const char vstr_stbcpo[] = "stbcpo=0x%x";
-static const char vstr_bw40po[] = "bw40po=0x%x";
-static const char vstr_bwduppo[] = "bwduppo=0x%x";
-static const char vstr_mcspo[] = "mcs%dgpo%d=0x%x";
-static const char vstr_mcspohl[] = "mcs%dg%cpo%d=0x%x";
-static const char vstr_custom[] = "customvar%d=0x%x";
-static const char vstr_cckdigfilttype[] = "cckdigfilttype=%d";
-static const char vstr_boardnum[] = "boardnum=%d";
-static const char vstr_macaddr[] = "macaddr=%s";
-static const char vstr_usbepnum[] = "usbepnum=0x%x";
-static const char vstr_end[] = "END\0";
-
-u8 patch_pair;
-
-/* For dongle HW, accept partial calibration parameters */
-#define BCMDONGLECASE(n)
-
-int srom_parsecis(u8 *pcis[], uint ciscnt, char **vars,
-                 uint *count)
-{
-       char eabuf[32];
-       char *base;
-       varbuf_t b;
-       u8 *cis, tup, tlen, sromrev = 1;
-       int i, j;
-       bool ag_init = false;
-       u32 w32;
-       uint funcid;
-       uint cisnum;
-       s32 boardnum;
-       int err;
-       bool standard_cis;
-
-       ASSERT(vars != NULL);
-       ASSERT(count != NULL);
-
-       boardnum = -1;
-
-       base = kmalloc(MAXSZ_NVRAM_VARS, GFP_ATOMIC);
-       ASSERT(base != NULL);
-       if (!base)
-               return -2;
-
-       varbuf_init(&b, base, MAXSZ_NVRAM_VARS);
-       memset(base, 0, MAXSZ_NVRAM_VARS);
-       eabuf[0] = '\0';
-       for (cisnum = 0; cisnum < ciscnt; cisnum++) {
-               cis = *pcis++;
-               i = 0;
-               funcid = 0;
-               standard_cis = true;
-               do {
-                       if (standard_cis) {
-                               tup = cis[i++];
-                               if (tup == CISTPL_NULL || tup == CISTPL_END)
-                                       tlen = 0;
-                               else
-                                       tlen = cis[i++];
-                       } else {
-                               if (cis[i] == CISTPL_NULL
-                                   || cis[i] == CISTPL_END) {
-                                       tlen = 0;
-                                       tup = cis[i];
-                               } else {
-                                       tlen = cis[i];
-                                       tup = CISTPL_BRCM_HNBU;
-                               }
-                               ++i;
-                       }
-                       if ((i + tlen) >= CIS_SIZE)
-                               break;
-
-                       switch (tup) {
-                       case CISTPL_VERS_1:
-                               /* assume the strings are good if the version field checks out */
-                               if (((cis[i + 1] << 8) + cis[i]) >= 0x0008) {
-                                       varbuf_append(&b, vstr_manf,
-                                                     &cis[i + 2]);
-                                       varbuf_append(&b, vstr_productname,
-                                                     &cis[i + 3 +
-                                                          strlen((char *)
-                                                                 &cis[i +
-                                                                      2])]);
-                                       break;
-                               }
-
-                       case CISTPL_MANFID:
-                               varbuf_append(&b, vstr_manfid,
-                                             (cis[i + 1] << 8) + cis[i]);
-                               varbuf_append(&b, vstr_prodid,
-                                             (cis[i + 3] << 8) + cis[i + 2]);
-                               break;
-
-                       case CISTPL_FUNCID:
-                               funcid = cis[i];
-                               break;
-
-                       case CISTPL_FUNCE:
-                               switch (funcid) {
-                               case CISTPL_FID_SDIO:
-#ifdef BCMSDIO
-                                       if (cis[i] == 0) {
-                                               u8 spd = cis[i + 3];
-                                               static int base[] = {
-                                                       -1, 10, 12, 13, 15, 20,
-                                                           25, 30,
-                                                       35, 40, 45, 50, 55, 60,
-                                                           70, 80
-                                               };
-                                               static int mult[] = {
-                                                       10, 100, 1000, 10000,
-                                                       -1, -1, -1, -1
-                                               };
-                                               ASSERT((mult[spd & 0x7] != -1)
-                                                      &&
-                                                      (base
-                                                       [(spd >> 3) & 0x0f]));
-                                               varbuf_append(&b,
-                                                             vstr_sdmaxblk[0],
-                                                             (cis[i + 2] << 8)
-                                                             + cis[i + 1]);
-                                               varbuf_append(&b,
-                                                             vstr_sdmaxspeed,
-                                                             (mult[spd & 0x7] *
-                                                              base[(spd >> 3) &
-                                                                   0x0f]));
-                                       } else if (cis[i] == 1) {
-                                               varbuf_append(&b,
-                                                             vstr_sdmaxblk
-                                                             [cisnum],
-                                                             (cis[i + 13] << 8)
-                                                             | cis[i + 12]);
-                                       }
-#endif                         /* BCMSDIO */
-                                       funcid = 0;
-                                       break;
-                               default:
-                                       /* set macaddr if HNBU_MACADDR not seen yet */
-                                       if (eabuf[0] == '\0' &&
-                                           cis[i] == LAN_NID &&
-                                           !is_zero_ether_addr(&cis[i + 2]) &&
-                                           !is_multicast_ether_addr(&cis[i + 2])) {
-                                               ASSERT(cis[i + 1] ==
-                                                      ETH_ALEN);
-                                               snprintf(eabuf, sizeof(eabuf),
-                                                       "%pM", &cis[i + 2]);
-
-                                               /* set boardnum if HNBU_BOARDNUM not seen yet */
-                                               if (boardnum == -1)
-                                                       boardnum =
-                                                           (cis[i + 6] << 8) +
-                                                           cis[i + 7];
-                                       }
-                                       break;
-                               }
-                               break;
-
-                       case CISTPL_CFTABLE:
-                               varbuf_append(&b, vstr_regwindowsz,
-                                             (cis[i + 7] << 8) | cis[i + 6]);
-                               break;
-
-                       case CISTPL_BRCM_HNBU:
-                               switch (cis[i]) {
-                               case HNBU_SROMREV:
-                                       sromrev = cis[i + 1];
-                                       varbuf_append(&b, vstr_sromrev,
-                                                     sromrev);
-                                       break;
-
-                               case HNBU_XTALFREQ:
-                                       varbuf_append(&b, vstr_xtalfreq,
-                                                     (cis[i + 4] << 24) |
-                                                     (cis[i + 3] << 16) |
-                                                     (cis[i + 2] << 8) |
-                                                     cis[i + 1]);
-                                       break;
-
-                               case HNBU_CHIPID:
-                                       varbuf_append(&b, vstr_vendid,
-                                                     (cis[i + 2] << 8) +
-                                                     cis[i + 1]);
-                                       varbuf_append(&b, vstr_devid,
-                                                     (cis[i + 4] << 8) +
-                                                     cis[i + 3]);
-                                       if (tlen >= 7) {
-                                               varbuf_append(&b, vstr_chiprev,
-                                                             (cis[i + 6] << 8)
-                                                             + cis[i + 5]);
-                                       }
-                                       if (tlen >= 9) {
-                                               varbuf_append(&b,
-                                                             vstr_subvendid,
-                                                             (cis[i + 8] << 8)
-                                                             + cis[i + 7]);
-                                       }
-                                       if (tlen >= 11) {
-                                               varbuf_append(&b, vstr_subdevid,
-                                                             (cis[i + 10] << 8)
-                                                             + cis[i + 9]);
-                                               /* subdevid doubles for boardtype */
-                                               varbuf_append(&b,
-                                                             vstr_boardtype,
-                                                             (cis[i + 10] << 8)
-                                                             + cis[i + 9]);
-                                       }
-                                       break;
-
-                               case HNBU_BOARDNUM:
-                                       boardnum =
-                                           (cis[i + 2] << 8) + cis[i + 1];
-                                       break;
-
-                               case HNBU_PATCH:
-                                       {
-                                               char vstr_paddr[16];
-                                               char vstr_pdata[16];
-
-                                               /* retrieve the patch pairs
-                                                * from tlen/6; where 6 is
-                                                * sizeof(patch addr(2)) +
-                                                * sizeof(patch data(4)).
-                                                */
-                                               patch_pair = tlen / 6;
-
-                                               for (j = 0; j < patch_pair; j++) {
-                                                       snprintf(vstr_paddr,
-                                                                sizeof
-                                                                (vstr_paddr),
-                                                                "pa%d=0x%%x",
-                                                                j);
-                                                       snprintf(vstr_pdata,
-                                                                sizeof
-                                                                (vstr_pdata),
-                                                                "pd%d=0x%%x",
-                                                                j);
-
-                                                       varbuf_append(&b,
-                                                                     vstr_paddr,
-                                                                     (cis
-                                                                      [i +
-                                                                       (j *
-                                                                        6) +
-                                                                       2] << 8)
-                                                                     | cis[i +
-                                                                           (j *
-                                                                            6)
-                                                                           +
-                                                                           1]);
-
-                                                       varbuf_append(&b,
-                                                                     vstr_pdata,
-                                                                     (cis
-                                                                      [i +
-                                                                       (j *
-                                                                        6) +
-                                                                       6] <<
-                                                                      24) |
-                                                                     (cis
-                                                                      [i +
-                                                                       (j *
-                                                                        6) +
-                                                                       5] <<
-                                                                      16) |
-                                                                     (cis
-                                                                      [i +
-                                                                       (j *
-                                                                        6) +
-                                                                       4] << 8)
-                                                                     | cis[i +
-                                                                           (j *
-                                                                            6)
-                                                                           +
-                                                                           3]);
-                                               }
-                                       }
-                                       break;
-
-                               case HNBU_BOARDREV:
-                                       if (tlen == 2)
-                                               varbuf_append(&b, vstr_boardrev,
-                                                             cis[i + 1]);
-                                       else
-                                               varbuf_append(&b, vstr_boardrev,
-                                                             (cis[i + 2] << 8)
-                                                             + cis[i + 1]);
-                                       break;
-
-                               case HNBU_BOARDFLAGS:
-                                       w32 = (cis[i + 2] << 8) + cis[i + 1];
-                                       if (tlen >= 5)
-                                               w32 |=
-                                                   ((cis[i + 4] << 24) +
-                                                    (cis[i + 3] << 16));
-                                       varbuf_append(&b, vstr_boardflags, w32);
-
-                                       if (tlen >= 7) {
-                                               w32 =
-                                                   (cis[i + 6] << 8) + cis[i +
-                                                                           5];
-                                               if (tlen >= 9)
-                                                       w32 |=
-                                                           ((cis[i + 8] << 24)
-                                                            +
-                                                            (cis[i + 7] <<
-                                                             16));
-                                               varbuf_append(&b,
-                                                             vstr_boardflags2,
-                                                             w32);
-                                       }
-                                       break;
-
-                               case HNBU_USBFS:
-                                       varbuf_append(&b, vstr_usbfs,
-                                                     cis[i + 1]);
-                                       break;
-
-                               case HNBU_BOARDTYPE:
-                                       varbuf_append(&b, vstr_boardtype,
-                                                     (cis[i + 2] << 8) +
-                                                     cis[i + 1]);
-                                       break;
-
-                               case HNBU_HNBUCIS:
-                                       /*
-                                        * what follows is a nonstandard HNBU CIS
-                                        * that lacks CISTPL_BRCM_HNBU tags
-                                        *
-                                        * skip 0xff (end of standard CIS)
-                                        * after this tuple
-                                        */
-                                       tlen++;
-                                       standard_cis = false;
-                                       break;
-
-                               case HNBU_USBEPNUM:
-                                       varbuf_append(&b, vstr_usbepnum,
-                                                     (cis[i + 2] << 8) | cis[i
-                                                                             +
-                                                                             1]);
-                                       break;
-
-                               case HNBU_AA:
-                                       varbuf_append(&b, vstr_aa2g,
-                                                     cis[i + 1]);
-                                       if (tlen >= 3)
-                                               varbuf_append(&b, vstr_aa5g,
-                                                             cis[i + 2]);
-                                       break;
-
-                               case HNBU_AG:
-                                       varbuf_append(&b, vstr_ag, 0,
-                                                     cis[i + 1]);
-                                       if (tlen >= 3)
-                                               varbuf_append(&b, vstr_ag, 1,
-                                                             cis[i + 2]);
-                                       if (tlen >= 4)
-                                               varbuf_append(&b, vstr_ag, 2,
-                                                             cis[i + 3]);
-                                       if (tlen >= 5)
-                                               varbuf_append(&b, vstr_ag, 3,
-                                                             cis[i + 4]);
-                                       ag_init = true;
-                                       break;
-
-                               case HNBU_ANT5G:
-                                       varbuf_append(&b, vstr_aa5g,
-                                                     cis[i + 1]);
-                                       varbuf_append(&b, vstr_ag, 1,
-                                                     cis[i + 2]);
-                                       break;
-
-                               case HNBU_CC:
-                                       ASSERT(sromrev == 1);
-                                       varbuf_append(&b, vstr_cc, cis[i + 1]);
-                                       break;
-
-                               case HNBU_PAPARMS:
-                                       switch (tlen) {
-                                       case 2:
-                                               ASSERT(sromrev == 1);
-                                               varbuf_append(&b,
-                                                             vstr_pa0maxpwr,
-                                                             cis[i + 1]);
-                                               break;
-                                       case 10:
-                                               ASSERT(sromrev >= 2);
-                                               varbuf_append(&b, vstr_opo,
-                                                             cis[i + 9]);
-                                               /* FALLTHROUGH */
-                                       case 9:
-                                               varbuf_append(&b,
-                                                             vstr_pa0maxpwr,
-                                                             cis[i + 8]);
-                                               /* FALLTHROUGH */
-                                               BCMDONGLECASE(8)
-                                                   varbuf_append(&b,
-                                                                 vstr_pa0itssit,
-                                                                 cis[i + 7]);
-                                               /* FALLTHROUGH */
-                                               BCMDONGLECASE(7)
-                                                   for (j = 0; j < 3; j++) {
-                                                       varbuf_append(&b,
-                                                                     vstr_pa0b
-                                                                     [j],
-                                                                     (cis
-                                                                      [i +
-                                                                       (j *
-                                                                        2) +
-                                                                       2] << 8)
-                                                                     + cis[i +
-                                                                           (j *
-                                                                            2)
-                                                                           +
-                                                                           1]);
-                                               }
-                                               break;
-                                       default:
-                                               ASSERT((tlen == 2)
-                                                      || (tlen == 9)
-                                                      || (tlen == 10));
-                                               break;
-                                       }
-                                       break;
-
-                               case HNBU_PAPARMS5G:
-                                       ASSERT((sromrev == 2)
-                                              || (sromrev == 3));
-                                       switch (tlen) {
-                                       case 23:
-                                               varbuf_append(&b,
-                                                             vstr_pa1himaxpwr,
-                                                             cis[i + 22]);
-                                               varbuf_append(&b,
-                                                             vstr_pa1lomaxpwr,
-                                                             cis[i + 21]);
-                                               varbuf_append(&b,
-                                                             vstr_pa1maxpwr,
-                                                             cis[i + 20]);
-                                               /* FALLTHROUGH */
-                                       case 20:
-                                               varbuf_append(&b,
-                                                             vstr_pa1itssit,
-                                                             cis[i + 19]);
-                                               /* FALLTHROUGH */
-                                       case 19:
-                                               for (j = 0; j < 3; j++) {
-                                                       varbuf_append(&b,
-                                                                     vstr_pa1b
-                                                                     [j],
-                                                                     (cis
-                                                                      [i +
-                                                                       (j *
-                                                                        2) +
-                                                                       2] << 8)
-                                                                     + cis[i +
-                                                                           (j *
-                                                                            2)
-                                                                           +
-                                                                           1]);
-                                               }
-                                               for (j = 3; j < 6; j++) {
-                                                       varbuf_append(&b,
-                                                                     vstr_pa1lob
-                                                                     [j - 3],
-                                                                     (cis
-                                                                      [i +
-                                                                       (j *
-                                                                        2) +
-                                                                       2] << 8)
-                                                                     + cis[i +
-                                                                           (j *
-                                                                            2)
-                                                                           +
-                                                                           1]);
-                                               }
-                                               for (j = 6; j < 9; j++) {
-                                                       varbuf_append(&b,
-                                                                     vstr_pa1hib
-                                                                     [j - 6],
-                                                                     (cis
-                                                                      [i +
-                                                                       (j *
-                                                                        2) +
-                                                                       2] << 8)
-                                                                     + cis[i +
-                                                                           (j *
-                                                                            2)
-                                                                           +
-                                                                           1]);
-                                               }
-                                               break;
-                                       default:
-                                               ASSERT((tlen == 19) ||
-                                                      (tlen == 20)
-                                                      || (tlen == 23));
-                                               break;
-                                       }
-                                       break;
-
-                               case HNBU_OEM:
-                                       ASSERT(sromrev == 1);
-                                       varbuf_append(&b, vstr_oem,
-                                                     cis[i + 1], cis[i + 2],
-                                                     cis[i + 3], cis[i + 4],
-                                                     cis[i + 5], cis[i + 6],
-                                                     cis[i + 7], cis[i + 8]);
-                                       break;
-
-                               case HNBU_LEDS:
-                                       for (j = 1; j <= 4; j++) {
-                                               if (cis[i + j] != 0xff) {
-                                                       varbuf_append(&b,
-                                                                     vstr_ledbh,
-                                                                     j - 1,
-                                                                     cis[i +
-                                                                         j]);
-                                               }
-                                       }
-                                       break;
-
-                               case HNBU_CCODE:
-                                       ASSERT(sromrev > 1);
-                                       if ((cis[i + 1] == 0)
-                                           || (cis[i + 2] == 0))
-                                               varbuf_append(&b, vstr_noccode);
-                                       else
-                                               varbuf_append(&b, vstr_ccode,
-                                                             cis[i + 1],
-                                                             cis[i + 2]);
-                                       varbuf_append(&b, vstr_cctl,
-                                                     cis[i + 3]);
-                                       break;
-
-                               case HNBU_CCKPO:
-                                       ASSERT(sromrev > 2);
-                                       varbuf_append(&b, vstr_cckpo,
-                                                     (cis[i + 2] << 8) | cis[i
-                                                                             +
-                                                                             1]);
-                                       break;
-
-                               case HNBU_OFDMPO:
-                                       ASSERT(sromrev > 2);
-                                       varbuf_append(&b, vstr_ofdmpo,
-                                                     (cis[i + 4] << 24) |
-                                                     (cis[i + 3] << 16) |
-                                                     (cis[i + 2] << 8) |
-                                                     cis[i + 1]);
-                                       break;
-
-                               case HNBU_WPS:
-                                       varbuf_append(&b, vstr_wpsgpio,
-                                                     cis[i + 1]);
-                                       if (tlen >= 3)
-                                               varbuf_append(&b, vstr_wpsled,
-                                                             cis[i + 2]);
-                                       break;
-
-                               case HNBU_RSSISMBXA2G:
-                                       ASSERT(sromrev == 3);
-                                       varbuf_append(&b, vstr_rssismf2g,
-                                                     cis[i + 1] & 0xf);
-                                       varbuf_append(&b, vstr_rssismc2g,
-                                                     (cis[i + 1] >> 4) & 0xf);
-                                       varbuf_append(&b, vstr_rssisav2g,
-                                                     cis[i + 2] & 0x7);
-                                       varbuf_append(&b, vstr_bxa2g,
-                                                     (cis[i + 2] >> 3) & 0x3);
-                                       break;
-
-                               case HNBU_RSSISMBXA5G:
-                                       ASSERT(sromrev == 3);
-                                       varbuf_append(&b, vstr_rssismf5g,
-                                                     cis[i + 1] & 0xf);
-                                       varbuf_append(&b, vstr_rssismc5g,
-                                                     (cis[i + 1] >> 4) & 0xf);
-                                       varbuf_append(&b, vstr_rssisav5g,
-                                                     cis[i + 2] & 0x7);
-                                       varbuf_append(&b, vstr_bxa5g,
-                                                     (cis[i + 2] >> 3) & 0x3);
-                                       break;
-
-                               case HNBU_TRI2G:
-                                       ASSERT(sromrev == 3);
-                                       varbuf_append(&b, vstr_tri2g,
-                                                     cis[i + 1]);
-                                       break;
-
-                               case HNBU_TRI5G:
-                                       ASSERT(sromrev == 3);
-                                       varbuf_append(&b, vstr_tri5gl,
-                                                     cis[i + 1]);
-                                       varbuf_append(&b, vstr_tri5g,
-                                                     cis[i + 2]);
-                                       varbuf_append(&b, vstr_tri5gh,
-                                                     cis[i + 3]);
-                                       break;
-
-                               case HNBU_RXPO2G:
-                                       ASSERT(sromrev == 3);
-                                       varbuf_append(&b, vstr_rxpo2g,
-                                                     cis[i + 1]);
-                                       break;
-
-                               case HNBU_RXPO5G:
-                                       ASSERT(sromrev == 3);
-                                       varbuf_append(&b, vstr_rxpo5g,
-                                                     cis[i + 1]);
-                                       break;
-
-                               case HNBU_MACADDR:
-                                       if (!is_zero_ether_addr(&cis[i + 1]) &&
-                                           !is_multicast_ether_addr(&cis[i + 1])) {
-                                               snprintf(eabuf, sizeof(eabuf),
-                                                       "%pM", &cis[i + 1]);
-
-                                               /* set boardnum if HNBU_BOARDNUM not seen yet */
-                                               if (boardnum == -1)
-                                                       boardnum =
-                                                           (cis[i + 5] << 8) +
-                                                           cis[i + 6];
-                                       }
-                                       break;
-
-                               case HNBU_LEDDC:
-                                       /* CIS leddc only has 16bits, convert it to 32bits */
-                                       w32 = ((cis[i + 2] << 24) |     /* oncount */
-                                              (cis[i + 1] << 8));      /* offcount */
-                                       varbuf_append(&b, vstr_leddc, w32);
-                                       break;
-
-                               case HNBU_CHAINSWITCH:
-                                       varbuf_append(&b, vstr_txchain,
-                                                     cis[i + 1]);
-                                       varbuf_append(&b, vstr_rxchain,
-                                                     cis[i + 2]);
-                                       varbuf_append(&b, vstr_antswitch,
-                                                     (cis[i + 4] << 8) +
-                                                     cis[i + 3]);
-                                       break;
-
-                               case HNBU_REGREV:
-                                       varbuf_append(&b, vstr_regrev,
-                                                     cis[i + 1]);
-                                       break;
-
-                               case HNBU_FEM:{
-                                               u16 fem =
-                                                   (cis[i + 2] << 8) + cis[i +
-                                                                           1];
-                                               varbuf_append(&b,
-                                                             vstr_antswctl2g,
-                                                             (fem &
-                                                              SROM8_FEM_ANTSWLUT_MASK)
-                                                             >>
-                                                             SROM8_FEM_ANTSWLUT_SHIFT);
-                                               varbuf_append(&b, vstr_triso2g,
-                                                             (fem &
-                                                              SROM8_FEM_TR_ISO_MASK)
-                                                             >>
-                                                             SROM8_FEM_TR_ISO_SHIFT);
-                                               varbuf_append(&b,
-                                                             vstr_pdetrange2g,
-                                                             (fem &
-                                                              SROM8_FEM_PDET_RANGE_MASK)
-                                                             >>
-                                                             SROM8_FEM_PDET_RANGE_SHIFT);
-                                               varbuf_append(&b,
-                                                             vstr_extpagain2g,
-                                                             (fem &
-                                                              SROM8_FEM_EXTPA_GAIN_MASK)
-                                                             >>
-                                                             SROM8_FEM_EXTPA_GAIN_SHIFT);
-                                               varbuf_append(&b,
-                                                             vstr_tssipos2g,
-                                                             (fem &
-                                                              SROM8_FEM_TSSIPOS_MASK)
-                                                             >>
-                                                             SROM8_FEM_TSSIPOS_SHIFT);
-                                               if (tlen < 5)
-                                                       break;
-
-                                               fem =
-                                                   (cis[i + 4] << 8) + cis[i +
-                                                                           3];
-                                               varbuf_append(&b,
-                                                             vstr_antswctl5g,
-                                                             (fem &
-                                                              SROM8_FEM_ANTSWLUT_MASK)
-                                                             >>
-                                                             SROM8_FEM_ANTSWLUT_SHIFT);
-                                               varbuf_append(&b, vstr_triso5g,
-                                                             (fem &
-                                                              SROM8_FEM_TR_ISO_MASK)
-                                                             >>
-                                                             SROM8_FEM_TR_ISO_SHIFT);
-                                               varbuf_append(&b,
-                                                             vstr_pdetrange5g,
-                                                             (fem &
-                                                              SROM8_FEM_PDET_RANGE_MASK)
-                                                             >>
-                                                             SROM8_FEM_PDET_RANGE_SHIFT);
-                                               varbuf_append(&b,
-                                                             vstr_extpagain5g,
-                                                             (fem &
-                                                              SROM8_FEM_EXTPA_GAIN_MASK)
-                                                             >>
-                                                             SROM8_FEM_EXTPA_GAIN_SHIFT);
-                                               varbuf_append(&b,
-                                                             vstr_tssipos5g,
-                                                             (fem &
-                                                              SROM8_FEM_TSSIPOS_MASK)
-                                                             >>
-                                                             SROM8_FEM_TSSIPOS_SHIFT);
-                                               break;
-                                       }
-
-                               case HNBU_PAPARMS_C0:
-                                       varbuf_append(&b, vstr_maxp2ga0,
-                                                     cis[i + 1]);
-                                       varbuf_append(&b, vstr_itt2ga0,
-                                                     cis[i + 2]);
-                                       varbuf_append(&b, vstr_pa, 2, 0, 0,
-                                                     (cis[i + 4] << 8) +
-                                                     cis[i + 3]);
-                                       varbuf_append(&b, vstr_pa, 2, 1, 0,
-                                                     (cis[i + 6] << 8) +
-                                                     cis[i + 5]);
-                                       varbuf_append(&b, vstr_pa, 2, 2, 0,
-                                                     (cis[i + 8] << 8) +
-                                                     cis[i + 7]);
-                                       if (tlen < 31)
-                                               break;
-
-                                       varbuf_append(&b, vstr_maxp5ga0,
-                                                     cis[i + 9]);
-                                       varbuf_append(&b, vstr_itt5ga0,
-                                                     cis[i + 10]);
-                                       varbuf_append(&b, vstr_maxp5gha0,
-                                                     cis[i + 11]);
-                                       varbuf_append(&b, vstr_maxp5gla0,
-                                                     cis[i + 12]);
-                                       varbuf_append(&b, vstr_pa, 5, 0, 0,
-                                                     (cis[i + 14] << 8) +
-                                                     cis[i + 13]);
-                                       varbuf_append(&b, vstr_pa, 5, 1, 0,
-                                                     (cis[i + 16] << 8) +
-                                                     cis[i + 15]);
-                                       varbuf_append(&b, vstr_pa, 5, 2, 0,
-                                                     (cis[i + 18] << 8) +
-                                                     cis[i + 17]);
-                                       varbuf_append(&b, vstr_pahl, 5, 'l', 0,
-                                                     0,
-                                                     (cis[i + 20] << 8) +
-                                                     cis[i + 19]);
-                                       varbuf_append(&b, vstr_pahl, 5, 'l', 1,
-                                                     0,
-                                                     (cis[i + 22] << 8) +
-                                                     cis[i + 21]);
-                                       varbuf_append(&b, vstr_pahl, 5, 'l', 2,
-                                                     0,
-                                                     (cis[i + 24] << 8) +
-                                                     cis[i + 23]);
-                                       varbuf_append(&b, vstr_pahl, 5, 'h', 0,
-                                                     0,
-                                                     (cis[i + 26] << 8) +
-                                                     cis[i + 25]);
-                                       varbuf_append(&b, vstr_pahl, 5, 'h', 1,
-                                                     0,
-                                                     (cis[i + 28] << 8) +
-                                                     cis[i + 27]);
-                                       varbuf_append(&b, vstr_pahl, 5, 'h', 2,
-                                                     0,
-                                                     (cis[i + 30] << 8) +
-                                                     cis[i + 29]);
-                                       break;
-
-                               case HNBU_PAPARMS_C1:
-                                       varbuf_append(&b, vstr_maxp2ga1,
-                                                     cis[i + 1]);
-                                       varbuf_append(&b, vstr_itt2ga1,
-                                                     cis[i + 2]);
-                                       varbuf_append(&b, vstr_pa, 2, 0, 1,
-                                                     (cis[i + 4] << 8) +
-                                                     cis[i + 3]);
-                                       varbuf_append(&b, vstr_pa, 2, 1, 1,
-                                                     (cis[i + 6] << 8) +
-                                                     cis[i + 5]);
-                                       varbuf_append(&b, vstr_pa, 2, 2, 1,
-                                                     (cis[i + 8] << 8) +
-                                                     cis[i + 7]);
-                                       if (tlen < 31)
-                                               break;
-
-                                       varbuf_append(&b, vstr_maxp5ga1,
-                                                     cis[i + 9]);
-                                       varbuf_append(&b, vstr_itt5ga1,
-                                                     cis[i + 10]);
-                                       varbuf_append(&b, vstr_maxp5gha1,
-                                                     cis[i + 11]);
-                                       varbuf_append(&b, vstr_maxp5gla1,
-                                                     cis[i + 12]);
-                                       varbuf_append(&b, vstr_pa, 5, 0, 1,
-                                                     (cis[i + 14] << 8) +
-                                                     cis[i + 13]);
-                                       varbuf_append(&b, vstr_pa, 5, 1, 1,
-                                                     (cis[i + 16] << 8) +
-                                                     cis[i + 15]);
-                                       varbuf_append(&b, vstr_pa, 5, 2, 1,
-                                                     (cis[i + 18] << 8) +
-                                                     cis[i + 17]);
-                                       varbuf_append(&b, vstr_pahl, 5, 'l', 0,
-                                                     1,
-                                                     (cis[i + 20] << 8) +
-                                                     cis[i + 19]);
-                                       varbuf_append(&b, vstr_pahl, 5, 'l', 1,
-                                                     1,
-                                                     (cis[i + 22] << 8) +
-                                                     cis[i + 21]);
-                                       varbuf_append(&b, vstr_pahl, 5, 'l', 2,
-                                                     1,
-                                                     (cis[i + 24] << 8) +
-                                                     cis[i + 23]);
-                                       varbuf_append(&b, vstr_pahl, 5, 'h', 0,
-                                                     1,
-                                                     (cis[i + 26] << 8) +
-                                                     cis[i + 25]);
-                                       varbuf_append(&b, vstr_pahl, 5, 'h', 1,
-                                                     1,
-                                                     (cis[i + 28] << 8) +
-                                                     cis[i + 27]);
-                                       varbuf_append(&b, vstr_pahl, 5, 'h', 2,
-                                                     1,
-                                                     (cis[i + 30] << 8) +
-                                                     cis[i + 29]);
-                                       break;
-
-                               case HNBU_PO_CCKOFDM:
-                                       varbuf_append(&b, vstr_cck2gpo,
-                                                     (cis[i + 2] << 8) +
-                                                     cis[i + 1]);
-                                       varbuf_append(&b, vstr_ofdm2gpo,
-                                                     (cis[i + 6] << 24) +
-                                                     (cis[i + 5] << 16) +
-                                                     (cis[i + 4] << 8) +
-                                                     cis[i + 3]);
-                                       if (tlen < 19)
-                                               break;
-
-                                       varbuf_append(&b, vstr_ofdm5gpo,
-                                                     (cis[i + 10] << 24) +
-                                                     (cis[i + 9] << 16) +
-                                                     (cis[i + 8] << 8) +
-                                                     cis[i + 7]);
-                                       varbuf_append(&b, vstr_ofdm5glpo,
-                                                     (cis[i + 14] << 24) +
-                                                     (cis[i + 13] << 16) +
-                                                     (cis[i + 12] << 8) +
-                                                     cis[i + 11]);
-                                       varbuf_append(&b, vstr_ofdm5ghpo,
-                                                     (cis[i + 18] << 24) +
-                                                     (cis[i + 17] << 16) +
-                                                     (cis[i + 16] << 8) +
-                                                     cis[i + 15]);
-                                       break;
-
-                               case HNBU_PO_MCS2G:
-                                       for (j = 0; j <= (tlen / 2); j++) {
-                                               varbuf_append(&b, vstr_mcspo, 2,
-                                                             j,
-                                                             (cis
-                                                              [i + 2 +
-                                                               2 * j] << 8) +
-                                                             cis[i + 1 +
-                                                                 2 * j]);
-                                       }
-                                       break;
-
-                               case HNBU_PO_MCS5GM:
-                                       for (j = 0; j <= (tlen / 2); j++) {
-                                               varbuf_append(&b, vstr_mcspo, 5,
-                                                             j,
-                                                             (cis
-                                                              [i + 2 +
-                                                               2 * j] << 8) +
-                                                             cis[i + 1 +
-                                                                 2 * j]);
-                                       }
-                                       break;
-
-                               case HNBU_PO_MCS5GLH:
-                                       for (j = 0; j <= (tlen / 4); j++) {
-                                               varbuf_append(&b, vstr_mcspohl,
-                                                             5, 'l', j,
-                                                             (cis
-                                                              [i + 2 +
-                                                               2 * j] << 8) +
-                                                             cis[i + 1 +
-                                                                 2 * j]);
-                                       }
-
-                                       for (j = 0; j <= (tlen / 4); j++) {
-                                               varbuf_append(&b, vstr_mcspohl,
-                                                             5, 'h', j,
-                                                             (cis
-                                                              [i +
-                                                               ((tlen / 2) +
-                                                                2) +
-                                                               2 * j] << 8) +
-                                                             cis[i +
-                                                                 ((tlen / 2) +
-                                                                  1) + 2 * j]);
-                                       }
-
-                                       break;
-
-                               case HNBU_PO_CDD:
-                                       varbuf_append(&b, vstr_cddpo,
-                                                     (cis[i + 2] << 8) +
-                                                     cis[i + 1]);
-                                       break;
-
-                               case HNBU_PO_STBC:
-                                       varbuf_append(&b, vstr_stbcpo,
-                                                     (cis[i + 2] << 8) +
-                                                     cis[i + 1]);
-                                       break;
-
-                               case HNBU_PO_40M:
-                                       varbuf_append(&b, vstr_bw40po,
-                                                     (cis[i + 2] << 8) +
-                                                     cis[i + 1]);
-                                       break;
-
-                               case HNBU_PO_40MDUP:
-                                       varbuf_append(&b, vstr_bwduppo,
-                                                     (cis[i + 2] << 8) +
-                                                     cis[i + 1]);
-                                       break;
-
-                               case HNBU_OFDMPO5G:
-                                       varbuf_append(&b, vstr_ofdm5gpo,
-                                                     (cis[i + 4] << 24) +
-                                                     (cis[i + 3] << 16) +
-                                                     (cis[i + 2] << 8) +
-                                                     cis[i + 1]);
-                                       varbuf_append(&b, vstr_ofdm5glpo,
-                                                     (cis[i + 8] << 24) +
-                                                     (cis[i + 7] << 16) +
-                                                     (cis[i + 6] << 8) +
-                                                     cis[i + 5]);
-                                       varbuf_append(&b, vstr_ofdm5ghpo,
-                                                     (cis[i + 12] << 24) +
-                                                     (cis[i + 11] << 16) +
-                                                     (cis[i + 10] << 8) +
-                                                     cis[i + 9]);
-                                       break;
-
-                               case HNBU_CUSTOM1:
-                                       varbuf_append(&b, vstr_custom, 1,
-                                                     ((cis[i + 4] << 24) +
-                                                      (cis[i + 3] << 16) +
-                                                      (cis[i + 2] << 8) +
-                                                      cis[i + 1]));
-                                       break;
-
-#if defined(BCMSDIO)
-                               case HNBU_SROM3SWRGN:
-                                       if (tlen >= 73) {
-                                               u16 srom[35];
-                                               u8 srev = cis[i + 1 + 70];
-                                               ASSERT(srev == 3);
-                                               /* make tuple value 16-bit aligned and parse it */
-                                               memcpy(srom, &cis[i + 1],
-                                                      sizeof(srom));
-                                               _initvars_srom_pci(srev, srom,
-                                                                  SROM3_SWRGN_OFF,
-                                                                  &b);
-                                               /* 2.4G antenna gain is included in SROM */
-                                               ag_init = true;
-                                               /* Ethernet MAC address is included in SROM */
-                                               eabuf[0] = 0;
-                                               boardnum = -1;
-                                       }
-                                       /* create extra variables */
-                                       if (tlen >= 75)
-                                               varbuf_append(&b, vstr_vendid,
-                                                             (cis[i + 1 + 73]
-                                                              << 8) + cis[i +
-                                                                          1 +
-                                                                          72]);
-                                       if (tlen >= 77)
-                                               varbuf_append(&b, vstr_devid,
-                                                             (cis[i + 1 + 75]
-                                                              << 8) + cis[i +
-                                                                          1 +
-                                                                          74]);
-                                       if (tlen >= 79)
-                                               varbuf_append(&b, vstr_xtalfreq,
-                                                             (cis[i + 1 + 77]
-                                                              << 8) + cis[i +
-                                                                          1 +
-                                                                          76]);
-                                       break;
-#endif                         /* defined(BCMSDIO) */
-
-                               case HNBU_CCKFILTTYPE:
-                                       varbuf_append(&b, vstr_cckdigfilttype,
-                                                     (cis[i + 1]));
-                                       break;
-                               }
-
-                               break;
-                       }
-                       i += tlen;
-               } while (tup != CISTPL_END);
-       }
-
-       if (boardnum != -1) {
-               varbuf_append(&b, vstr_boardnum, boardnum);
-       }
-
-       if (eabuf[0]) {
-               varbuf_append(&b, vstr_macaddr, eabuf);
-       }
-
-       /* if there is no antenna gain field, set default */
-       if (getvar(NULL, "ag0") == NULL && ag_init == false) {
-               varbuf_append(&b, vstr_ag, 0, 0xff);
-       }
-
-       /* final nullbyte terminator */
-       ASSERT(b.size >= 1);
-       *b.buf++ = '\0';
-
-       ASSERT(b.buf - base <= MAXSZ_NVRAM_VARS);
-       err = initvars_table(base, b.buf, vars, count);
-
-       kfree(base);
-       return err;
-}
-
-/* In chips with chipcommon rev 32 and later, the srom is in chipcommon,
- * not in the bus cores.
- */
-static u16
-srom_cc_cmd(si_t *sih, void *ccregs, u32 cmd,
-           uint wordoff, u16 data)
-{
-       chipcregs_t *cc = (chipcregs_t *) ccregs;
-       uint wait_cnt = 1000;
-
-       if ((cmd == SRC_OP_READ) || (cmd == SRC_OP_WRITE)) {
-               W_REG(&cc->sromaddress, wordoff * 2);
-               if (cmd == SRC_OP_WRITE)
-                       W_REG(&cc->sromdata, data);
-       }
-
-       W_REG(&cc->sromcontrol, SRC_START | cmd);
-
-       while (wait_cnt--) {
-               if ((R_REG(&cc->sromcontrol) & SRC_BUSY) == 0)
-                       break;
-       }
-
-       if (!wait_cnt) {
-               BS_ERROR(("%s: Command 0x%x timed out\n", __func__, cmd));
-               return 0xffff;
-       }
-       if (cmd == SRC_OP_READ)
-               return (u16) R_REG(&cc->sromdata);
-       else
-               return 0xffff;
-}
-
-static inline void ltoh16_buf(u16 *buf, unsigned int size)
-{
-       for (size /= 2; size; size--)
-               *(buf + size) = le16_to_cpu(*(buf + size));
-}
-
-static inline void htol16_buf(u16 *buf, unsigned int size)
-{
-       for (size /= 2; size; size--)
-               *(buf + size) = cpu_to_le16(*(buf + size));
-}
-
-/*
- * Read in and validate sprom.
- * Return 0 on success, nonzero on error.
- */
-static int
-sprom_read_pci(si_t *sih, u16 *sprom, uint wordoff,
-              u16 *buf, uint nwords, bool check_crc)
-{
-       int err = 0;
-       uint i;
-       void *ccregs = NULL;
-
-       /* read the sprom */
-       for (i = 0; i < nwords; i++) {
-
-               if (sih->ccrev > 31 && ISSIM_ENAB(sih)) {
-                       /* use indirect since direct is too slow on QT */
-                       if ((sih->cccaps & CC_CAP_SROM) == 0)
-                               return 1;
-
-                       ccregs = (void *)((u8 *) sprom - CC_SROM_OTP);
-                       buf[i] =
-                           srom_cc_cmd(sih, ccregs, SRC_OP_READ,
-                                       wordoff + i, 0);
-
-               } else {
-                       if (ISSIM_ENAB(sih))
-                               buf[i] = R_REG(&sprom[wordoff + i]);
-
-                       buf[i] = R_REG(&sprom[wordoff + i]);
-               }
-
-       }
-
-       /* bypass crc checking for simulation to allow srom hack */
-       if (ISSIM_ENAB(sih))
-               return err;
-
-       if (check_crc) {
-
-               if (buf[0] == 0xffff) {
-                       /* The hardware thinks that an srom that starts with 0xffff
-                        * is blank, regardless of the rest of the content, so declare
-                        * it bad.
-                        */
-                       BS_ERROR(("%s: buf[0] = 0x%x, returning bad-crc\n",
-                                 __func__, buf[0]));
-                       return 1;
-               }
-
-               /* fixup the endianness so crc8 will pass */
-               htol16_buf(buf, nwords * 2);
-               if (hndcrc8((u8 *) buf, nwords * 2, CRC8_INIT_VALUE) !=
-                   CRC8_GOOD_VALUE) {
-                       /* DBG only pci always read srom4 first, then srom8/9 */
-                       /* BS_ERROR(("%s: bad crc\n", __func__)); */
-                       err = 1;
-               }
-               /* now correct the endianness of the byte array */
-               ltoh16_buf(buf, nwords * 2);
-       }
-       return err;
-}
-
-#if defined(BCMNVRAMR)
-static int otp_read_pci(si_t *sih, u16 *buf, uint bufsz)
-{
-       u8 *otp;
-       uint sz = OTP_SZ_MAX / 2;       /* size in words */
-       int err = 0;
-
-       ASSERT(bufsz <= OTP_SZ_MAX);
-
-       otp = kzalloc(OTP_SZ_MAX, GFP_ATOMIC);
-       if (otp == NULL) {
-               return BCME_ERROR;
-       }
-
-       err = otp_read_region(sih, OTP_HW_RGN, (u16 *) otp, &sz);
-
-       memcpy(buf, otp, bufsz);
-
-       kfree(otp);
-
-       /* Check CRC */
-       if (buf[0] == 0xffff) {
-               /* The hardware thinks that an srom that starts with 0xffff
-                * is blank, regardless of the rest of the content, so declare
-                * it bad.
-                */
-               BS_ERROR(("%s: buf[0] = 0x%x, returning bad-crc\n", __func__,
-                         buf[0]));
-               return 1;
-       }
-
-       /* fixup the endianness so crc8 will pass */
-       htol16_buf(buf, bufsz);
-       if (hndcrc8((u8 *) buf, SROM4_WORDS * 2, CRC8_INIT_VALUE) !=
-           CRC8_GOOD_VALUE) {
-               BS_ERROR(("%s: bad crc\n", __func__));
-               err = 1;
-       }
-       /* now correct the endianness of the byte array */
-       ltoh16_buf(buf, bufsz);
-
-       return err;
-}
-#endif                         /* defined(BCMNVRAMR) */
-/*
-* Create variable table from memory.
-* Return 0 on success, nonzero on error.
-*/
-static int initvars_table(char *start, char *end,
-                         char **vars, uint *count)
-{
-       int c = (int)(end - start);
-
-       /* do it only when there is more than just the null string */
-       if (c > 1) {
-               char *vp = kmalloc(c, GFP_ATOMIC);
-               ASSERT(vp != NULL);
-               if (!vp)
-                       return BCME_NOMEM;
-               memcpy(vp, start, c);
-               *vars = vp;
-               *count = c;
-       } else {
-               *vars = NULL;
-               *count = 0;
-       }
-
-       return 0;
-}
-
-/*
- * Find variables with <devpath> from flash. 'base' points to the beginning
- * of the table upon enter and to the end of the table upon exit when success.
- * Return 0 on success, nonzero on error.
- */
-static int initvars_flash(si_t *sih, char **base, uint len)
-{
-       char *vp = *base;
-       char *flash;
-       int err;
-       char *s;
-       uint l, dl, copy_len;
-       char devpath[SI_DEVPATH_BUFSZ];
-
-       /* allocate memory and read in flash */
-       flash = kmalloc(NVRAM_SPACE, GFP_ATOMIC);
-       if (!flash)
-               return BCME_NOMEM;
-       err = nvram_getall(flash, NVRAM_SPACE);
-       if (err)
-               goto exit;
-
-       si_devpath(sih, devpath, sizeof(devpath));
-
-       /* grab vars with the <devpath> prefix in name */
-       dl = strlen(devpath);
-       for (s = flash; s && *s; s += l + 1) {
-               l = strlen(s);
-
-               /* skip non-matching variable */
-               if (strncmp(s, devpath, dl))
-                       continue;
-
-               /* is there enough room to copy? */
-               copy_len = l - dl + 1;
-               if (len < copy_len) {
-                       err = BCME_BUFTOOSHORT;
-                       goto exit;
-               }
-
-               /* no prefix, just the name=value */
-               strncpy(vp, &s[dl], copy_len);
-               vp += copy_len;
-               len -= copy_len;
-       }
-
-       /* add null string as terminator */
-       if (len < 1) {
-               err = BCME_BUFTOOSHORT;
-               goto exit;
-       }
-       *vp++ = '\0';
-
-       *base = vp;
-
- exit: kfree(flash);
-       return err;
-}
-
-/*
- * Initialize nonvolatile variable table from flash.
- * Return 0 on success, nonzero on error.
- */
-static int initvars_flash_si(si_t *sih, char **vars, uint *count)
-{
-       char *vp, *base;
-       int err;
-
-       ASSERT(vars != NULL);
-       ASSERT(count != NULL);
-
-       base = vp = kmalloc(MAXSZ_NVRAM_VARS, GFP_ATOMIC);
-       ASSERT(vp != NULL);
-       if (!vp)
-               return BCME_NOMEM;
-
-       err = initvars_flash(sih, &vp, MAXSZ_NVRAM_VARS);
-       if (err == 0)
-               err = initvars_table(base, vp, vars, count);
-
-       kfree(base);
-
-       return err;
-}
-
-/* Parse SROM and create name=value pairs. 'srom' points to
- * the SROM word array. 'off' specifies the offset of the
- * first word 'srom' points to, which should be either 0 or
- * SROM3_SWRG_OFF (full SROM or software region).
- */
-
-static uint mask_shift(u16 mask)
-{
-       uint i;
-       for (i = 0; i < (sizeof(mask) << 3); i++) {
-               if (mask & (1 << i))
-                       return i;
-       }
-       ASSERT(mask);
-       return 0;
-}
-
-static uint mask_width(u16 mask)
-{
-       int i;
-       for (i = (sizeof(mask) << 3) - 1; i >= 0; i--) {
-               if (mask & (1 << i))
-                       return (uint) (i - mask_shift(mask) + 1);
-       }
-       ASSERT(mask);
-       return 0;
-}
-
-#if defined(BCMDBG)
-static bool mask_valid(u16 mask)
-{
-       uint shift = mask_shift(mask);
-       uint width = mask_width(mask);
-       return mask == ((~0 << shift) & ~(~0 << (shift + width)));
-}
-#endif                         /* BCMDBG */
-
-static void _initvars_srom_pci(u8 sromrev, u16 *srom, uint off, varbuf_t *b)
-{
-       u16 w;
-       u32 val;
-       const sromvar_t *srv;
-       uint width;
-       uint flags;
-       u32 sr = (1 << sromrev);
-
-       varbuf_append(b, "sromrev=%d", sromrev);
-
-       for (srv = pci_sromvars; srv->name != NULL; srv++) {
-               const char *name;
-
-               if ((srv->revmask & sr) == 0)
-                       continue;
-
-               if (srv->off < off)
-                       continue;
-
-               flags = srv->flags;
-               name = srv->name;
-
-               /* This entry is for mfgc only. Don't generate param for it, */
-               if (flags & SRFL_NOVAR)
-                       continue;
-
-               if (flags & SRFL_ETHADDR) {
-                       u8 ea[ETH_ALEN];
-
-                       ea[0] = (srom[srv->off - off] >> 8) & 0xff;
-                       ea[1] = srom[srv->off - off] & 0xff;
-                       ea[2] = (srom[srv->off + 1 - off] >> 8) & 0xff;
-                       ea[3] = srom[srv->off + 1 - off] & 0xff;
-                       ea[4] = (srom[srv->off + 2 - off] >> 8) & 0xff;
-                       ea[5] = srom[srv->off + 2 - off] & 0xff;
-
-                       varbuf_append(b, "%s=%pM", name, ea);
-               } else {
-                       ASSERT(mask_valid(srv->mask));
-                       ASSERT(mask_width(srv->mask));
-
-                       w = srom[srv->off - off];
-                       val = (w & srv->mask) >> mask_shift(srv->mask);
-                       width = mask_width(srv->mask);
-
-                       while (srv->flags & SRFL_MORE) {
-                               srv++;
-                               ASSERT(srv->name != NULL);
-
-                               if (srv->off == 0 || srv->off < off)
-                                       continue;
-
-                               ASSERT(mask_valid(srv->mask));
-                               ASSERT(mask_width(srv->mask));
-
-                               w = srom[srv->off - off];
-                               val +=
-                                   ((w & srv->mask) >> mask_shift(srv->
-                                                                  mask)) <<
-                                   width;
-                               width += mask_width(srv->mask);
-                       }
-
-                       if ((flags & SRFL_NOFFS)
-                           && ((int)val == (1 << width) - 1))
-                               continue;
-
-                       if (flags & SRFL_CCODE) {
-                               if (val == 0)
-                                       varbuf_append(b, "ccode=");
-                               else
-                                       varbuf_append(b, "ccode=%c%c",
-                                                     (val >> 8), (val & 0xff));
-                       }
-                       /* LED Powersave duty cycle has to be scaled:
-                        *(oncount >> 24) (offcount >> 8)
-                        */
-                       else if (flags & SRFL_LEDDC) {
-                               u32 w32 = (((val >> 8) & 0xff) << 24) | /* oncount */
-                                   (((val & 0xff)) << 8);      /* offcount */
-                               varbuf_append(b, "leddc=%d", w32);
-                       } else if (flags & SRFL_PRHEX)
-                               varbuf_append(b, "%s=0x%x", name, val);
-                       else if ((flags & SRFL_PRSIGN)
-                                && (val & (1 << (width - 1))))
-                               varbuf_append(b, "%s=%d", name,
-                                             (int)(val | (~0 << width)));
-                       else
-                               varbuf_append(b, "%s=%u", name, val);
-               }
-       }
-
-       if (sromrev >= 4) {
-               /* Do per-path variables */
-               uint p, pb, psz;
-
-               if (sromrev >= 8) {
-                       pb = SROM8_PATH0;
-                       psz = SROM8_PATH1 - SROM8_PATH0;
-               } else {
-                       pb = SROM4_PATH0;
-                       psz = SROM4_PATH1 - SROM4_PATH0;
-               }
-
-               for (p = 0; p < MAX_PATH_SROM; p++) {
-                       for (srv = perpath_pci_sromvars; srv->name != NULL;
-                            srv++) {
-                               if ((srv->revmask & sr) == 0)
-                                       continue;
-
-                               if (pb + srv->off < off)
-                                       continue;
-
-                               /* This entry is for mfgc only. Don't generate param for it, */
-                               if (srv->flags & SRFL_NOVAR)
-                                       continue;
-
-                               w = srom[pb + srv->off - off];
-
-                               ASSERT(mask_valid(srv->mask));
-                               val = (w & srv->mask) >> mask_shift(srv->mask);
-                               width = mask_width(srv->mask);
-
-                               /* Cheating: no per-path var is more than 1 word */
-
-                               if ((srv->flags & SRFL_NOFFS)
-                                   && ((int)val == (1 << width) - 1))
-                                       continue;
-
-                               if (srv->flags & SRFL_PRHEX)
-                                       varbuf_append(b, "%s%d=0x%x", srv->name,
-                                                     p, val);
-                               else
-                                       varbuf_append(b, "%s%d=%d", srv->name,
-                                                     p, val);
-                       }
-                       pb += psz;
-               }
-       }
-}
-
-/*
- * Initialize nonvolatile variable table from sprom.
- * Return 0 on success, nonzero on error.
- */
-static int initvars_srom_pci(si_t *sih, void *curmap, char **vars, uint *count)
-{
-       u16 *srom, *sromwindow;
-       u8 sromrev = 0;
-       u32 sr;
-       varbuf_t b;
-       char *vp, *base = NULL;
-       bool flash = false;
-       int err = 0;
-
-       /*
-        * Apply CRC over SROM content regardless SROM is present or not,
-        * and use variable <devpath>sromrev's existence in flash to decide
-        * if we should return an error when CRC fails or read SROM variables
-        * from flash.
-        */
-       srom = kmalloc(SROM_MAX, GFP_ATOMIC);
-       ASSERT(srom != NULL);
-       if (!srom)
-               return -2;
-
-       sromwindow = (u16 *) SROM_OFFSET(sih);
-       if (si_is_sprom_available(sih)) {
-               err =
-                   sprom_read_pci(sih, sromwindow, 0, srom, SROM_WORDS,
-                                  true);
-
-               if ((srom[SROM4_SIGN] == SROM4_SIGNATURE) ||
-                   (((sih->buscoretype == PCIE_CORE_ID)
-                     && (sih->buscorerev >= 6))
-                    || ((sih->buscoretype == PCI_CORE_ID)
-                        && (sih->buscorerev >= 0xe)))) {
-                       /* sromrev >= 4, read more */
-                       err =
-                           sprom_read_pci(sih, sromwindow, 0, srom,
-                                          SROM4_WORDS, true);
-                       sromrev = srom[SROM4_CRCREV] & 0xff;
-                       if (err)
-                               BS_ERROR(("%s: srom %d, bad crc\n", __func__,
-                                         sromrev));
-
-               } else if (err == 0) {
-                       /* srom is good and is rev < 4 */
-                       /* top word of sprom contains version and crc8 */
-                       sromrev = srom[SROM_CRCREV] & 0xff;
-                       /* bcm4401 sroms misprogrammed */
-                       if (sromrev == 0x10)
-                               sromrev = 1;
-               }
-       }
-#if defined(BCMNVRAMR)
-       /* Use OTP if SPROM not available */
-       else {
-               err = otp_read_pci(sih, srom, SROM_MAX);
-               if (err == 0)
-                       /* OTP only contain SROM rev8/rev9 for now */
-                       sromrev = srom[SROM4_CRCREV] & 0xff;
-               else
-                       err = 1;
-       }
-#else
-       else
-               err = 1;
-#endif
-
-       /*
-        * We want internal/wltest driver to come up with default
-        * sromvars so we can program a blank SPROM/OTP.
-        */
-       if (err) {
-               char *value;
-               u32 val;
-               val = 0;
-
-               BS_ERROR(("Neither SPROM nor OTP has valid image\n"));
-               value = si_getdevpathvar(sih, "sromrev");
-               if (value) {
-                       sromrev = (u8) simple_strtoul(value, NULL, 0);
-                       flash = true;
-                       goto varscont;
-               }
-
-               BS_ERROR(("%s, SROM CRC Error\n", __func__));
-
-               value = si_getnvramflvar(sih, "sromrev");
-               if (value) {
-                       err = 0;
-                       goto errout;
-               }
-
-               {
-                       err = -1;
-                       goto errout;
-               }
-       }
-
- varscont:
-       /* Bitmask for the sromrev */
-       sr = 1 << sromrev;
-
-       /* srom version check: Current valid versions: 1, 2, 3, 4, 5, 8, 9 */
-       if ((sr & 0x33e) == 0) {
-               err = -2;
-               goto errout;
-       }
-
-       ASSERT(vars != NULL);
-       ASSERT(count != NULL);
-
-       base = vp = kmalloc(MAXSZ_NVRAM_VARS, GFP_ATOMIC);
-       ASSERT(vp != NULL);
-       if (!vp) {
-               err = -2;
-               goto errout;
-       }
-
-       /* read variables from flash */
-       if (flash) {
-               err = initvars_flash(sih, &vp, MAXSZ_NVRAM_VARS);
-               if (err)
-                       goto errout;
-               goto varsdone;
-       }
-
-       varbuf_init(&b, base, MAXSZ_NVRAM_VARS);
-
-       /* parse SROM into name=value pairs. */
-       _initvars_srom_pci(sromrev, srom, 0, &b);
-
-       /* final nullbyte terminator */
-       ASSERT(b.size >= 1);
-       vp = b.buf;
-       *vp++ = '\0';
-
-       ASSERT((vp - base) <= MAXSZ_NVRAM_VARS);
-
- varsdone:
-       err = initvars_table(base, vp, vars, count);
-
- errout:
-       if (base)
-               kfree(base);
-
-       kfree(srom);
-       return err;
-}
-
-#ifdef BCMSDIO
-/*
- * Read the SDIO cis and call parsecis to initialize the vars.
- * Return 0 on success, nonzero on error.
- */
-static int initvars_cis_sdio(char **vars, uint *count)
-{
-       u8 *cis[SBSDIO_NUM_FUNCTION + 1];
-       uint fn, numfn;
-       int rc = 0;
-
-       numfn = bcmsdh_query_iofnum(NULL);
-       ASSERT(numfn <= SDIOD_MAX_IOFUNCS);
-
-       for (fn = 0; fn <= numfn; fn++) {
-               cis[fn] = kzalloc(SBSDIO_CIS_SIZE_LIMIT, GFP_ATOMIC);
-               if (cis[fn] == NULL) {
-                       rc = -1;
-                       break;
-               }
-
-               if (bcmsdh_cis_read(NULL, fn, cis[fn], SBSDIO_CIS_SIZE_LIMIT) !=
-                   0) {
-                       kfree(cis[fn]);
-                       rc = -2;
-                       break;
-               }
-       }
-
-       if (!rc)
-               rc = srom_parsecis(cis, fn, vars, count);
-
-       while (fn-- > 0)
-               kfree(cis[fn]);
-
-       return rc;
-}
-
-/* set SDIO sprom command register */
-static int sprom_cmd_sdio(u8 cmd)
-{
-       u8 status = 0;
-       uint wait_cnt = 1000;
-
-       /* write sprom command register */
-       bcmsdh_cfg_write(NULL, SDIO_FUNC_1, SBSDIO_SPROM_CS, cmd, NULL);
-
-       /* wait status */
-       while (wait_cnt--) {
-               status =
-                   bcmsdh_cfg_read(NULL, SDIO_FUNC_1, SBSDIO_SPROM_CS, NULL);
-               if (status & SBSDIO_SPROM_DONE)
-                       return 0;
-       }
-
-       return 1;
-}
-
-/* read a word from the SDIO srom */
-static int sprom_read_sdio(u16 addr, u16 *data)
-{
-       u8 addr_l, addr_h, data_l, data_h;
-
-       addr_l = (u8) ((addr * 2) & 0xff);
-       addr_h = (u8) (((addr * 2) >> 8) & 0xff);
-
-       /* set address */
-       bcmsdh_cfg_write(NULL, SDIO_FUNC_1, SBSDIO_SPROM_ADDR_HIGH, addr_h,
-                        NULL);
-       bcmsdh_cfg_write(NULL, SDIO_FUNC_1, SBSDIO_SPROM_ADDR_LOW, addr_l,
-                        NULL);
-
-       /* do read */
-       if (sprom_cmd_sdio(SBSDIO_SPROM_READ))
-               return 1;
-
-       /* read data */
-       data_h =
-           bcmsdh_cfg_read(NULL, SDIO_FUNC_1, SBSDIO_SPROM_DATA_HIGH, NULL);
-       data_l =
-           bcmsdh_cfg_read(NULL, SDIO_FUNC_1, SBSDIO_SPROM_DATA_LOW, NULL);
-
-       *data = (data_h << 8) | data_l;
-       return 0;
-}
-#endif                         /* BCMSDIO */
-
-static int initvars_srom_si(si_t *sih, void *curmap, char **vars, uint *varsz)
-{
-       /* Search flash nvram section for srom variables */
-       return initvars_flash_si(sih, vars, varsz);
-}
index fb0bcccfda44cbd35d77cff465a3c8a038ae4c14..43e5bb3aec02a7f2ca2c8af4b1716950389a73a6 100644 (file)
 #include <linux/pci.h>
 #include <linux/netdevice.h>
 #include <linux/sched.h>
+#include <linux/printk.h>
 #include <bcmdefs.h>
 #include <stdarg.h>
 #include <bcmutils.h>
-#include <siutils.h>
 #include <bcmnvram.h>
 #include <bcmdevs.h>
 #include <proto/802.11.h>
 
-/* Global ASSERT type flag */
-u32 g_assert_type;
+MODULE_AUTHOR("Broadcom Corporation");
+MODULE_DESCRIPTION("Broadcom 802.11n wireless LAN driver utilities.");
+MODULE_SUPPORTED_DEVICE("Broadcom 802.11n WLAN cards");
+MODULE_LICENSE("Dual BSD/GPL");
 
-struct sk_buff *BCMFASTPATH pkt_buf_get_skb(uint len)
+struct sk_buff *bcm_pkt_buf_get_skb(uint len)
 {
        struct sk_buff *skb;
 
@@ -44,15 +46,14 @@ struct sk_buff *BCMFASTPATH pkt_buf_get_skb(uint len)
 
        return skb;
 }
+EXPORT_SYMBOL(bcm_pkt_buf_get_skb);
 
 /* Free the driver packet. Free the tag if present */
-void BCMFASTPATH pkt_buf_free_skb(struct sk_buff *skb)
+void bcm_pkt_buf_free_skb(struct sk_buff *skb)
 {
        struct sk_buff *nskb;
        int nest = 0;
 
-       ASSERT(skb);
-
        /* perversion: we use skb->next to chain multi-skb packets */
        while (skb) {
                nskb = skb->next;
@@ -73,9 +74,11 @@ void BCMFASTPATH pkt_buf_free_skb(struct sk_buff *skb)
                skb = nskb;
        }
 }
+EXPORT_SYMBOL(bcm_pkt_buf_free_skb);
+
 
 /* copy a buffer into a pkt buffer chain */
-uint pktfrombuf(struct sk_buff *p, uint offset, int len,
+uint bcm_pktfrombuf(struct sk_buff *p, uint offset, int len,
                unsigned char *buf)
 {
        uint n, ret = 0;
@@ -102,8 +105,10 @@ uint pktfrombuf(struct sk_buff *p, uint offset, int len,
 
        return ret;
 }
+EXPORT_SYMBOL(bcm_pktfrombuf);
+
 /* return total length of buffer chain */
-uint BCMFASTPATH pkttotlen(struct sk_buff *p)
+uint bcm_pkttotlen(struct sk_buff *p)
 {
        uint total;
 
@@ -112,21 +117,19 @@ uint BCMFASTPATH pkttotlen(struct sk_buff *p)
                total += p->len;
        return total;
 }
+EXPORT_SYMBOL(bcm_pkttotlen);
 
 /*
  * osl multiple-precedence packet queue
  * hi_prec is always >= the number of the highest non-empty precedence
  */
-struct sk_buff *BCMFASTPATH pktq_penq(struct pktq *pq, int prec,
+struct sk_buff *bcm_pktq_penq(struct pktq *pq, int prec,
                                      struct sk_buff *p)
 {
        struct pktq_prec *q;
 
-       ASSERT(prec >= 0 && prec < pq->num_prec);
-       ASSERT(p->prev == NULL);        /* queueing chains not allowed */
-
-       ASSERT(!pktq_full(pq));
-       ASSERT(!pktq_pfull(pq, prec));
+       if (pktq_full(pq) || pktq_pfull(pq, prec))
+               return NULL;
 
        q = &pq->q[prec];
 
@@ -145,17 +148,15 @@ struct sk_buff *BCMFASTPATH pktq_penq(struct pktq *pq, int prec,
 
        return p;
 }
+EXPORT_SYMBOL(bcm_pktq_penq);
 
-struct sk_buff *BCMFASTPATH pktq_penq_head(struct pktq *pq, int prec,
+struct sk_buff *bcm_pktq_penq_head(struct pktq *pq, int prec,
                                           struct sk_buff *p)
 {
        struct pktq_prec *q;
 
-       ASSERT(prec >= 0 && prec < pq->num_prec);
-       ASSERT(p->prev == NULL);        /* queueing chains not allowed */
-
-       ASSERT(!pktq_full(pq));
-       ASSERT(!pktq_pfull(pq, prec));
+       if (pktq_full(pq) || pktq_pfull(pq, prec))
+               return NULL;
 
        q = &pq->q[prec];
 
@@ -173,14 +174,13 @@ struct sk_buff *BCMFASTPATH pktq_penq_head(struct pktq *pq, int prec,
 
        return p;
 }
+EXPORT_SYMBOL(bcm_pktq_penq_head);
 
-struct sk_buff *BCMFASTPATH pktq_pdeq(struct pktq *pq, int prec)
+struct sk_buff *bcm_pktq_pdeq(struct pktq *pq, int prec)
 {
        struct pktq_prec *q;
        struct sk_buff *p;
 
-       ASSERT(prec >= 0 && prec < pq->num_prec);
-
        q = &pq->q[prec];
 
        p = q->head;
@@ -199,14 +199,13 @@ struct sk_buff *BCMFASTPATH pktq_pdeq(struct pktq *pq, int prec)
 
        return p;
 }
+EXPORT_SYMBOL(bcm_pktq_pdeq);
 
-struct sk_buff *BCMFASTPATH pktq_pdeq_tail(struct pktq *pq, int prec)
+struct sk_buff *bcm_pktq_pdeq_tail(struct pktq *pq, int prec)
 {
        struct pktq_prec *q;
        struct sk_buff *p, *prev;
 
-       ASSERT(prec >= 0 && prec < pq->num_prec);
-
        q = &pq->q[prec];
 
        p = q->head;
@@ -228,38 +227,11 @@ struct sk_buff *BCMFASTPATH pktq_pdeq_tail(struct pktq *pq, int prec)
 
        return p;
 }
+EXPORT_SYMBOL(bcm_pktq_pdeq_tail);
 
-#ifdef BRCM_FULLMAC
-void pktq_pflush(struct pktq *pq, int prec, bool dir)
-{
-       struct pktq_prec *q;
-       struct sk_buff *p;
-
-       q = &pq->q[prec];
-       p = q->head;
-       while (p) {
-               q->head = p->prev;
-               p->prev = NULL;
-               pkt_buf_free_skb(p);
-               q->len--;
-               pq->len--;
-               p = q->head;
-       }
-       ASSERT(q->len == 0);
-       q->tail = NULL;
-}
-
-void pktq_flush(struct pktq *pq, bool dir)
-{
-       int prec;
-       for (prec = 0; prec < pq->num_prec; prec++)
-               pktq_pflush(pq, prec, dir);
-       ASSERT(pq->len == 0);
-}
-#else /* !BRCM_FULLMAC */
 void
-pktq_pflush(struct pktq *pq, int prec, bool dir,
-           ifpkt_cb_t fn, int arg)
+bcm_pktq_pflush(struct pktq *pq, int prec, bool dir,
+           ifpkt_cb_t fn, void *arg)
 {
        struct pktq_prec *q;
        struct sk_buff *p, *prev = NULL;
@@ -274,7 +246,7 @@ pktq_pflush(struct pktq *pq, int prec, bool dir,
                        else
                                prev->prev = p->prev;
                        p->prev = NULL;
-                       pkt_buf_free_skb(p);
+                       bcm_pkt_buf_free_skb(p);
                        q->len--;
                        pq->len--;
                        p = (head ? q->head : prev->prev);
@@ -285,28 +257,24 @@ pktq_pflush(struct pktq *pq, int prec, bool dir,
        }
 
        if (q->head == NULL) {
-               ASSERT(q->len == 0);
                q->tail = NULL;
        }
 }
+EXPORT_SYMBOL(bcm_pktq_pflush);
 
-void pktq_flush(struct pktq *pq, bool dir,
-               ifpkt_cb_t fn, int arg)
+void bcm_pktq_flush(struct pktq *pq, bool dir,
+               ifpkt_cb_t fn, void *arg)
 {
        int prec;
        for (prec = 0; prec < pq->num_prec; prec++)
-               pktq_pflush(pq, prec, dir, fn, arg);
-       if (fn == NULL)
-               ASSERT(pq->len == 0);
+               bcm_pktq_pflush(pq, prec, dir, fn, arg);
 }
-#endif /* BRCM_FULLMAC */
+EXPORT_SYMBOL(bcm_pktq_flush);
 
-void pktq_init(struct pktq *pq, int num_prec, int max_len)
+void bcm_pktq_init(struct pktq *pq, int num_prec, int max_len)
 {
        int prec;
 
-       ASSERT(num_prec > 0 && num_prec <= PKTQ_MAX_PREC);
-
        /* pq is variable size; only zero out what's requested */
        memset(pq, 0,
              offsetof(struct pktq, q) + (sizeof(struct pktq_prec) * num_prec));
@@ -318,8 +286,9 @@ void pktq_init(struct pktq *pq, int num_prec, int max_len)
        for (prec = 0; prec < num_prec; prec++)
                pq->q[prec].max = pq->max;
 }
+EXPORT_SYMBOL(bcm_pktq_init);
 
-struct sk_buff *pktq_peek_tail(struct pktq *pq, int *prec_out)
+struct sk_buff *bcm_pktq_peek_tail(struct pktq *pq, int *prec_out)
 {
        int prec;
 
@@ -335,9 +304,10 @@ struct sk_buff *pktq_peek_tail(struct pktq *pq, int *prec_out)
 
        return pq->q[prec].tail;
 }
+EXPORT_SYMBOL(bcm_pktq_peek_tail);
 
 /* Return sum of lengths of a specific set of precedences */
-int pktq_mlen(struct pktq *pq, uint prec_bmp)
+int bcm_pktq_mlen(struct pktq *pq, uint prec_bmp)
 {
        int prec, len;
 
@@ -349,8 +319,10 @@ int pktq_mlen(struct pktq *pq, uint prec_bmp)
 
        return len;
 }
+EXPORT_SYMBOL(bcm_pktq_mlen);
+
 /* Priority dequeue from a specific set of precedences */
-struct sk_buff *BCMFASTPATH pktq_mdeq(struct pktq *pq, uint prec_bmp,
+struct sk_buff *bcm_pktq_mdeq(struct pktq *pq, uint prec_bmp,
                                      int *prec_out)
 {
        struct pktq_prec *q;
@@ -388,6 +360,7 @@ struct sk_buff *BCMFASTPATH pktq_mdeq(struct pktq *pq, uint prec_bmp,
 
        return p;
 }
+EXPORT_SYMBOL(bcm_pktq_mdeq);
 
 /* parse a xx:xx:xx:xx:xx:xx format ethernet address */
 int bcm_ether_atoe(char *p, u8 *ea)
@@ -402,57 +375,11 @@ int bcm_ether_atoe(char *p, u8 *ea)
 
        return i == 6;
 }
-
-/*
- * Search the name=value vars for a specific one and return its value.
- * Returns NULL if not found.
- */
-char *getvar(char *vars, const char *name)
-{
-       char *s;
-       int len;
-
-       if (!name)
-               return NULL;
-
-       len = strlen(name);
-       if (len == 0)
-               return NULL;
-
-       /* first look in vars[] */
-       for (s = vars; s && *s;) {
-               if ((memcmp(s, name, len) == 0) && (s[len] == '='))
-                       return &s[len + 1];
-
-               while (*s++)
-                       ;
-       }
-#ifdef BRCM_FULLMAC
-       return NULL;
-#else
-       /* then query nvram */
-       return nvram_get(name);
-#endif
-}
-
-/*
- * Search the vars for a specific one and return its value as
- * an integer. Returns 0 if not found.
- */
-int getintvar(char *vars, const char *name)
-{
-       char *val;
-
-       val = getvar(vars, name);
-       if (val == NULL)
-               return 0;
-
-       return simple_strtoul(val, NULL, 0);
-}
+EXPORT_SYMBOL(bcm_ether_atoe);
 
 #if defined(BCMDBG)
 /* pretty hex print a pkt buffer chain */
-void prpkt(const char *msg, struct sk_buff *p0)
+void bcm_prpkt(const char *msg, struct sk_buff *p0)
 {
        struct sk_buff *p;
 
@@ -460,32 +387,11 @@ void prpkt(const char *msg, struct sk_buff *p0)
                printk(KERN_DEBUG "%s:\n", msg);
 
        for (p = p0; p; p = p->next)
-               prhex(NULL, p->data, p->len);
+               print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, p->data, p->len);
 }
+EXPORT_SYMBOL(bcm_prpkt);
 #endif                         /* defined(BCMDBG) */
 
-static char bcm_undeferrstr[BCME_STRLEN];
-
-static const char *bcmerrorstrtable[] = BCMERRSTRINGTABLE;
-
-/* Convert the error codes into related error strings  */
-const char *bcmerrorstr(int bcmerror)
-{
-       /* check if someone added a bcmerror code but
-                forgot to add errorstring */
-       ASSERT(ABS(BCME_LAST) == (ARRAY_SIZE(bcmerrorstrtable) - 1));
-
-       if (bcmerror > 0 || bcmerror < BCME_LAST) {
-               snprintf(bcm_undeferrstr, BCME_STRLEN, "Undefined error %d",
-                        bcmerror);
-               return bcm_undeferrstr;
-       }
-
-       ASSERT(strlen(bcmerrorstrtable[-bcmerror]) < BCME_STRLEN);
-
-       return bcmerrorstrtable[-bcmerror];
-}
-
 /* iovar table lookup */
 const bcm_iovar_t *bcm_iovar_lookup(const bcm_iovar_t *table, const char *name)
 {
@@ -499,8 +405,6 @@ const bcm_iovar_t *bcm_iovar_lookup(const bcm_iovar_t *table, const char *name)
        else
                lookup_name = name;
 
-       ASSERT(table != NULL);
-
        for (vi = table; vi->name; vi++) {
                if (!strcmp(vi->name, lookup_name))
                        return vi;
@@ -509,6 +413,7 @@ const bcm_iovar_t *bcm_iovar_lookup(const bcm_iovar_t *table, const char *name)
 
        return NULL;            /* var name not found */
 }
+EXPORT_SYMBOL(bcm_iovar_lookup);
 
 int bcm_iovar_lencheck(const bcm_iovar_t *vi, void *arg, int len, bool set)
 {
@@ -525,35 +430,35 @@ int bcm_iovar_lencheck(const bcm_iovar_t *vi, void *arg, int len, bool set)
        case IOVT_UINT32:
                /* all integers are s32 sized args at the ioctl interface */
                if (len < (int)sizeof(int)) {
-                       bcmerror = BCME_BUFTOOSHORT;
+                       bcmerror = -EOVERFLOW;
                }
                break;
 
        case IOVT_BUFFER:
                /* buffer must meet minimum length requirement */
                if (len < vi->minlen) {
-                       bcmerror = BCME_BUFTOOSHORT;
+                       bcmerror = -EOVERFLOW;
                }
                break;
 
        case IOVT_VOID:
                if (!set) {
                        /* Cannot return nil... */
-                       bcmerror = BCME_UNSUPPORTED;
+                       bcmerror = -ENOTSUPP;
                } else if (len) {
                        /* Set is an action w/o parameters */
-                       bcmerror = BCME_BUFTOOLONG;
+                       bcmerror = -ENOBUFS;
                }
                break;
 
        default:
                /* unknown type for length check in iovar info */
-               ASSERT(0);
-               bcmerror = BCME_UNSUPPORTED;
+               bcmerror = -ENOTSUPP;
        }
 
        return bcmerror;
 }
+EXPORT_SYMBOL(bcm_iovar_lencheck);
 
 /*******************************************************************************
  * crc8
@@ -612,195 +517,18 @@ static const u8 crc8_table[256] = {
        0xF4, 0x03, 0x4D, 0xBA, 0xD1, 0x26, 0x68, 0x9F
 };
 
-#define CRC_INNER_LOOP(n, c, x) \
-       ((c) = ((c) >> 8) ^ crc##n##_table[((c) ^ (x)) & 0xff])
-
-u8 hndcrc8(u8 *pdata,  /* pointer to array of data to process */
+u8 bcm_crc8(u8 *pdata, /* pointer to array of data to process */
                         uint nbytes,   /* number of input data bytes to process */
                         u8 crc /* either CRC8_INIT_VALUE or previous return value */
     ) {
-       /* hard code the crc loop instead of using CRC_INNER_LOOP macro
-        * to avoid the undefined and unnecessary (u8 >> 8) operation.
-        */
+       /* loop over the buffer data */
        while (nbytes-- > 0)
                crc = crc8_table[(crc ^ *pdata++) & 0xff];
 
        return crc;
 }
+EXPORT_SYMBOL(bcm_crc8);
 
-/*******************************************************************************
- * crc16
- *
- * Computes a crc16 over the input data using the polynomial:
- *
- *       x^16 + x^12 +x^5 + 1
- *
- * The caller provides the initial value (either CRC16_INIT_VALUE
- * or the previous returned value) to allow for processing of
- * discontiguous blocks of data.  When generating the CRC the
- * caller is responsible for complementing the final return value
- * and inserting it into the byte stream.  When checking, a final
- * return value of CRC16_GOOD_VALUE indicates a valid CRC.
- *
- * Reference: Dallas Semiconductor Application Note 27
- *   Williams, Ross N., "A Painless Guide to CRC Error Detection Algorithms",
- *     ver 3, Aug 1993, ross@guest.adelaide.edu.au, Rocksoft Pty Ltd.,
- *     ftp://ftp.rocksoft.com/clients/rocksoft/papers/crc_v3.txt
- *
- * ****************************************************************************
- */
-
-static const u16 crc16_table[256] = {
-       0x0000, 0x1189, 0x2312, 0x329B, 0x4624, 0x57AD, 0x6536, 0x74BF,
-       0x8C48, 0x9DC1, 0xAF5A, 0xBED3, 0xCA6C, 0xDBE5, 0xE97E, 0xF8F7,
-       0x1081, 0x0108, 0x3393, 0x221A, 0x56A5, 0x472C, 0x75B7, 0x643E,
-       0x9CC9, 0x8D40, 0xBFDB, 0xAE52, 0xDAED, 0xCB64, 0xF9FF, 0xE876,
-       0x2102, 0x308B, 0x0210, 0x1399, 0x6726, 0x76AF, 0x4434, 0x55BD,
-       0xAD4A, 0xBCC3, 0x8E58, 0x9FD1, 0xEB6E, 0xFAE7, 0xC87C, 0xD9F5,
-       0x3183, 0x200A, 0x1291, 0x0318, 0x77A7, 0x662E, 0x54B5, 0x453C,
-       0xBDCB, 0xAC42, 0x9ED9, 0x8F50, 0xFBEF, 0xEA66, 0xD8FD, 0xC974,
-       0x4204, 0x538D, 0x6116, 0x709F, 0x0420, 0x15A9, 0x2732, 0x36BB,
-       0xCE4C, 0xDFC5, 0xED5E, 0xFCD7, 0x8868, 0x99E1, 0xAB7A, 0xBAF3,
-       0x5285, 0x430C, 0x7197, 0x601E, 0x14A1, 0x0528, 0x37B3, 0x263A,
-       0xDECD, 0xCF44, 0xFDDF, 0xEC56, 0x98E9, 0x8960, 0xBBFB, 0xAA72,
-       0x6306, 0x728F, 0x4014, 0x519D, 0x2522, 0x34AB, 0x0630, 0x17B9,
-       0xEF4E, 0xFEC7, 0xCC5C, 0xDDD5, 0xA96A, 0xB8E3, 0x8A78, 0x9BF1,
-       0x7387, 0x620E, 0x5095, 0x411C, 0x35A3, 0x242A, 0x16B1, 0x0738,
-       0xFFCF, 0xEE46, 0xDCDD, 0xCD54, 0xB9EB, 0xA862, 0x9AF9, 0x8B70,
-       0x8408, 0x9581, 0xA71A, 0xB693, 0xC22C, 0xD3A5, 0xE13E, 0xF0B7,
-       0x0840, 0x19C9, 0x2B52, 0x3ADB, 0x4E64, 0x5FED, 0x6D76, 0x7CFF,
-       0x9489, 0x8500, 0xB79B, 0xA612, 0xD2AD, 0xC324, 0xF1BF, 0xE036,
-       0x18C1, 0x0948, 0x3BD3, 0x2A5A, 0x5EE5, 0x4F6C, 0x7DF7, 0x6C7E,
-       0xA50A, 0xB483, 0x8618, 0x9791, 0xE32E, 0xF2A7, 0xC03C, 0xD1B5,
-       0x2942, 0x38CB, 0x0A50, 0x1BD9, 0x6F66, 0x7EEF, 0x4C74, 0x5DFD,
-       0xB58B, 0xA402, 0x9699, 0x8710, 0xF3AF, 0xE226, 0xD0BD, 0xC134,
-       0x39C3, 0x284A, 0x1AD1, 0x0B58, 0x7FE7, 0x6E6E, 0x5CF5, 0x4D7C,
-       0xC60C, 0xD785, 0xE51E, 0xF497, 0x8028, 0x91A1, 0xA33A, 0xB2B3,
-       0x4A44, 0x5BCD, 0x6956, 0x78DF, 0x0C60, 0x1DE9, 0x2F72, 0x3EFB,
-       0xD68D, 0xC704, 0xF59F, 0xE416, 0x90A9, 0x8120, 0xB3BB, 0xA232,
-       0x5AC5, 0x4B4C, 0x79D7, 0x685E, 0x1CE1, 0x0D68, 0x3FF3, 0x2E7A,
-       0xE70E, 0xF687, 0xC41C, 0xD595, 0xA12A, 0xB0A3, 0x8238, 0x93B1,
-       0x6B46, 0x7ACF, 0x4854, 0x59DD, 0x2D62, 0x3CEB, 0x0E70, 0x1FF9,
-       0xF78F, 0xE606, 0xD49D, 0xC514, 0xB1AB, 0xA022, 0x92B9, 0x8330,
-       0x7BC7, 0x6A4E, 0x58D5, 0x495C, 0x3DE3, 0x2C6A, 0x1EF1, 0x0F78
-};
-
-u16 hndcrc16(u8 *pdata,        /* pointer to array of data to process */
-       uint nbytes,    /* number of input data bytes to process */
-       u16 crc /* either CRC16_INIT_VALUE or previous return value */
-    ) {
-       while (nbytes-- > 0)
-               CRC_INNER_LOOP(16, crc, *pdata++);
-       return crc;
-}
-
-static const u32 crc32_table[256] = {
-       0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA,
-       0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3,
-       0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988,
-       0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91,
-       0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE,
-       0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7,
-       0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC,
-       0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5,
-       0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172,
-       0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B,
-       0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940,
-       0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59,
-       0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116,
-       0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F,
-       0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924,
-       0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D,
-       0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A,
-       0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433,
-       0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818,
-       0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01,
-       0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E,
-       0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457,
-       0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C,
-       0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65,
-       0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2,
-       0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB,
-       0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0,
-       0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9,
-       0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086,
-       0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F,
-       0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4,
-       0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD,
-       0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A,
-       0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683,
-       0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8,
-       0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1,
-       0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE,
-       0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7,
-       0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC,
-       0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5,
-       0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252,
-       0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B,
-       0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60,
-       0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79,
-       0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236,
-       0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F,
-       0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04,
-       0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D,
-       0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A,
-       0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713,
-       0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38,
-       0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21,
-       0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E,
-       0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777,
-       0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C,
-       0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45,
-       0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2,
-       0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB,
-       0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0,
-       0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9,
-       0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6,
-       0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF,
-       0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94,
-       0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D
-};
-
-u32 hndcrc32(u8 *pdata,        /* pointer to array of data to process */
-               uint nbytes,    /* number of input data bytes to process */
-               u32 crc /* either CRC32_INIT_VALUE or previous
-                                        return value */
-)
-{
-       u8 *pend;
-#ifdef __mips__
-       u8 tmp[4];
-       unsigned long *tptr = (unsigned long *) tmp;
-
-       /* in case the beginning of the buffer isn't aligned */
-       pend = (u8 *) ((uint) (pdata + 3) & 0xfffffffc);
-       nbytes -= (pend - pdata);
-       while (pdata < pend)
-               CRC_INNER_LOOP(32, crc, *pdata++);
-
-       /* handle bulk of data as 32-bit words */
-       pend = pdata + (nbytes & 0xfffffffc);
-       while (pdata < pend) {
-               *tptr = *(unsigned long *) pdata;
-               pdata += sizeof(unsigned long *);
-               CRC_INNER_LOOP(32, crc, tmp[0]);
-               CRC_INNER_LOOP(32, crc, tmp[1]);
-               CRC_INNER_LOOP(32, crc, tmp[2]);
-               CRC_INNER_LOOP(32, crc, tmp[3]);
-       }
-
-       /* 1-3 bytes at end of buffer */
-       pend = pdata + (nbytes & 0x03);
-       while (pdata < pend)
-               CRC_INNER_LOOP(32, crc, *pdata++);
-#else
-       pend = pdata + nbytes;
-       while (pdata < pend)
-               CRC_INNER_LOOP(32, crc, *pdata++);
-#endif                         /* __mips__ */
-
-       return crc;
-}
 /*
  * Traverse a string of 1-byte tag/1-byte length/variable-length value
  * triples, returning a pointer to the substring whose first element
@@ -828,6 +556,7 @@ bcm_tlv_t *bcm_parse_tlvs(void *buf, int buflen, uint key)
 
        return NULL;
 }
+EXPORT_SYMBOL(bcm_parse_tlvs);
 
 
 #if defined(BCMDBG)
@@ -883,6 +612,7 @@ bcm_format_flags(const bcm_bit_desc_t *bd, u32 flags, char *buf, int len)
 
        return (int)(p - buf);
 }
+EXPORT_SYMBOL(bcm_format_flags);
 
 /* print bytes formatted as hex to a string. return the resulting string length */
 int bcm_format_hex(char *str, const void *bytes, int len)
@@ -897,44 +627,9 @@ int bcm_format_hex(char *str, const void *bytes, int len)
        }
        return (int)(p - str);
 }
+EXPORT_SYMBOL(bcm_format_hex);
 #endif                         /* defined(BCMDBG) */
 
-/* pretty hex print a contiguous buffer */
-void prhex(const char *msg, unsigned char *buf, uint nbytes)
-{
-       char line[128], *p;
-       int len = sizeof(line);
-       int nchar;
-       uint i;
-
-       if (msg && (msg[0] != '\0'))
-               printk(KERN_DEBUG "%s:\n", msg);
-
-       p = line;
-       for (i = 0; i < nbytes; i++) {
-               if (i % 16 == 0) {
-                       nchar = snprintf(p, len, "  %04d: ", i);        /* line prefix */
-                       p += nchar;
-                       len -= nchar;
-               }
-               if (len > 0) {
-                       nchar = snprintf(p, len, "%02x ", buf[i]);
-                       p += nchar;
-                       len -= nchar;
-               }
-
-               if (i % 16 == 15) {
-                       printk(KERN_DEBUG "%s\n", line);        /* flush line */
-                       p = line;
-                       len = sizeof(line);
-               }
-       }
-
-       /* flush last partial line */
-       if (p != line)
-               printk(KERN_DEBUG "%s\n", line);
-}
-
 char *bcm_chipname(uint chipid, char *buf, uint len)
 {
        const char *fmt;
@@ -943,6 +638,7 @@ char *bcm_chipname(uint chipid, char *buf, uint len)
        snprintf(buf, len, fmt, chipid);
        return buf;
 }
+EXPORT_SYMBOL(bcm_chipname);
 
 uint bcm_mkiovar(char *name, char *data, uint datalen, char *buf, uint buflen)
 {
@@ -961,6 +657,7 @@ uint bcm_mkiovar(char *name, char *data, uint datalen, char *buf, uint buflen)
 
        return len;
 }
+EXPORT_SYMBOL(bcm_mkiovar);
 
 /* Quarter dBm units to mW
  * Table starts at QDBM_OFFSET, so the first entry is mW for qdBm=153
@@ -1015,6 +712,8 @@ u16 bcm_qdbm_to_mw(u8 qdbm)
         */
        return (nqdBm_to_mW_map[idx] + factor / 2) / factor;
 }
+EXPORT_SYMBOL(bcm_qdbm_to_mw);
+
 u8 bcm_mw_to_qdbm(u16 mw)
 {
        u8 qdbm;
@@ -1045,6 +744,8 @@ u8 bcm_mw_to_qdbm(u16 mw)
 
        return qdbm;
 }
+EXPORT_SYMBOL(bcm_mw_to_qdbm);
+
 uint bcm_bitcount(u8 *bitmap, uint length)
 {
        uint bitcount = 0, i;
@@ -1058,12 +759,15 @@ uint bcm_bitcount(u8 *bitmap, uint length)
        }
        return bitcount;
 }
+EXPORT_SYMBOL(bcm_bitcount);
+
 /* Initialization of bcmstrbuf structure */
 void bcm_binit(struct bcmstrbuf *b, char *buf, uint size)
 {
        b->origsize = b->size = size;
        b->origbuf = b->buf = buf;
 }
+EXPORT_SYMBOL(bcm_binit);
 
 /* Buffer sprintf wrapper to guard against buffer overflow */
 int bcm_bprintf(struct bcmstrbuf *b, const char *fmt, ...)
@@ -1089,50 +793,4 @@ int bcm_bprintf(struct bcmstrbuf *b, const char *fmt, ...)
 
        return r;
 }
-
-#if defined(BCMDBG_ASSERT)
-void osl_assert(char *exp, char *file, int line)
-{
-       char tempbuf[256];
-       char *basename;
-
-       basename = strrchr(file, '/');
-       /* skip the '/' */
-       if (basename)
-               basename++;
-
-       if (!basename)
-               basename = file;
-
-       snprintf(tempbuf, 256,
-                "assertion \"%s\" failed: file \"%s\", line %d\n", exp,
-                basename, line);
-
-       /*
-        * Print assert message and give it time to
-        * be written to /var/log/messages
-        */
-       if (!in_interrupt()) {
-               const int delay = 3;
-               printk(KERN_ERR "%s", tempbuf);
-               printk(KERN_ERR "panic in %d seconds\n", delay);
-               set_current_state(TASK_INTERRUPTIBLE);
-               schedule_timeout(delay * HZ);
-       }
-
-       switch (g_assert_type) {
-       case 0:
-               panic(KERN_ERR "%s", tempbuf);
-               break;
-       case 1:
-               printk(KERN_ERR "%s", tempbuf);
-               BUG();
-               break;
-       case 2:
-               printk(KERN_ERR "%s", tempbuf);
-               break;
-       default:
-               break;
-       }
-}
-#endif                         /* defined(BCMDBG_ASSERT) */
+EXPORT_SYMBOL(bcm_bprintf);
index d82c2b29816d3373f045be2f53d279d5641b17b5..955a3ab1a827553e0a0f2482219aae1e29e6b220 100644 (file)
@@ -15,6 +15,7 @@
  */
 #include <linux/ctype.h>
 #include <linux/kernel.h>
+#include <linux/module.h>
 #include <bcmdefs.h>
 #include <bcmutils.h>
 #include <bcmwifi.h>
@@ -25,7 +26,7 @@
  * combination could be legal given any set of circumstances.
  * RETURNS: true is the chanspec is malformed, false if it looks good.
  */
-bool wf_chspec_malformed(chanspec_t chanspec)
+bool bcm_chspec_malformed(chanspec_t chanspec)
 {
        /* must be 2G or 5G band */
        if (!CHSPEC_IS5G(chanspec) && !CHSPEC_IS2G(chanspec))
@@ -45,13 +46,14 @@ bool wf_chspec_malformed(chanspec_t chanspec)
 
        return false;
 }
+EXPORT_SYMBOL(bcm_chspec_malformed);
 
 /*
  * This function returns the channel number that control traffic is being sent on, for legacy
  * channels this is just the channel number, for 40MHZ channels it is the upper or lowre 20MHZ
  * sideband depending on the chanspec selected
  */
-u8 wf_chspec_ctlchan(chanspec_t chspec)
+u8 bcm_chspec_ctlchan(chanspec_t chspec)
 {
        u8 ctl_chan;
 
@@ -60,7 +62,6 @@ u8 wf_chspec_ctlchan(chanspec_t chspec)
                return CHSPEC_CHANNEL(chspec);
        } else {
                /* we only support 40MHZ with sidebands */
-               ASSERT(CHSPEC_BW(chspec) == WL_CHANSPEC_BW_40);
                /* chanspec channel holds the centre frequency, use that and the
                 * side band information to reconstruct the control channel number
                 */
@@ -68,8 +69,6 @@ u8 wf_chspec_ctlchan(chanspec_t chspec)
                        /* control chan is the upper 20 MHZ SB of the 40MHZ channel */
                        ctl_chan = UPPER_20_SB(CHSPEC_CHANNEL(chspec));
                } else {
-                       ASSERT(CHSPEC_CTL_SB(chspec) ==
-                              WL_CHANSPEC_CTL_SB_LOWER);
                        /* control chan is the lower 20 MHZ SB of the 40MHZ channel */
                        ctl_chan = LOWER_20_SB(CHSPEC_CHANNEL(chspec));
                }
@@ -77,6 +76,7 @@ u8 wf_chspec_ctlchan(chanspec_t chspec)
 
        return ctl_chan;
 }
+EXPORT_SYMBOL(bcm_chspec_ctlchan);
 
 /*
  * Return the channel number for a given frequency and base frequency.
@@ -97,7 +97,7 @@ u8 wf_chspec_ctlchan(chanspec_t chspec)
  *
  * Reference 802.11 REVma, section 17.3.8.3, and 802.11B section 18.4.6.2
  */
-int wf_mhz2channel(uint freq, uint start_factor)
+int bcm_mhz2channel(uint freq, uint start_factor)
 {
        int ch = -1;
        uint base;
@@ -133,4 +133,5 @@ int wf_mhz2channel(uint freq, uint start_factor)
 
        return ch;
 }
+EXPORT_SYMBOL(bcm_mhz2channel);
 
diff --git a/drivers/staging/brcm80211/util/qmath.c b/drivers/staging/brcm80211/util/qmath.c
deleted file mode 100644 (file)
index 40c9929..0000000
+++ /dev/null
@@ -1,681 +0,0 @@
-/*
- * Copyright (c) 2010 Broadcom Corporation
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
- * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
- * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <linux/types.h>
-#include "qmath.h"
-
-/*
-Description: This function saturate input 32 bit number into a 16 bit number.
-If input number is greater than 0x7fff then output is saturated to 0x7fff.
-else if input number is less than 0xffff8000 then output is saturated to 0xffff8000
-else output is same as input.
-*/
-s16 qm_sat32(s32 op)
-{
-       s16 result;
-       if (op > (s32) 0x7fff) {
-               result = 0x7fff;
-       } else if (op < (s32) 0xffff8000) {
-               result = (s16) (0x8000);
-       } else {
-               result = (s16) op;
-       }
-       return result;
-}
-
-/*
-Description: This function multiply two input 16 bit numbers and return the 32 bit result.
-This multiplication is similar to compiler multiplication. This operation is defined if
-16 bit multiplication on the processor platform is cheaper than 32 bit multiplication (as
-the most of qmath functions can be replaced with processor intrinsic instructions).
-*/
-s32 qm_mul321616(s16 op1, s16 op2)
-{
-       return (s32) (op1) * (s32) (op2);
-}
-
-/*
-Description: This function make 16 bit multiplication and return the result in 16 bits.
-To fit the result into 16 bits the 32 bit multiplication result is right
-shifted by 16 bits.
-*/
-s16 qm_mul16(s16 op1, s16 op2)
-{
-       s32 result;
-       result = ((s32) (op1) * (s32) (op2));
-       return (s16) (result >> 16);
-}
-
-/*
-Description: This function multiply two 16 bit numbers and return the result in 32 bits.
-This function remove the extra sign bit created by the multiplication by leftshifting the
-32 bit multiplication result by 1 bit before returning the result. So the output is
-twice that of compiler multiplication. (i.e. qm_muls321616(2,3)=12).
-When both input 16 bit numbers are 0x8000, then the result is saturated to 0x7fffffff.
-*/
-s32 qm_muls321616(s16 op1, s16 op2)
-{
-       s32 result;
-       if (op1 == (s16) (0x8000) && op2 == (s16) (0x8000)) {
-               result = 0x7fffffff;
-       } else {
-               result = ((s32) (op1) * (s32) (op2));
-               result = result << 1;
-       }
-       return result;
-}
-
-/*
-Description: This function make 16 bit unsigned multiplication. To fit the output into
-16 bits the 32 bit multiplication result is right shifted by 16 bits.
-*/
-u16 qm_mulu16(u16 op1, u16 op2)
-{
-       return (u16) (((u32) op1 * (u32) op2) >> 16);
-}
-
-/*
-Description: This function make 16 bit multiplication and return the result in 16 bits.
-To fit the multiplication result into 16 bits the multiplication result is right shifted by
-15 bits. Right shifting 15 bits instead of 16 bits is done to remove the extra sign bit formed
-due to the multiplication.
-When both the 16bit inputs are 0x8000 then the output is saturated to 0x7fffffff.
-*/
-s16 qm_muls16(s16 op1, s16 op2)
-{
-       s32 result;
-       if (op1 == (s16) 0x8000 && op2 == (s16) 0x8000) {
-               result = 0x7fffffff;
-       } else {
-               result = ((s32) (op1) * (s32) (op2));
-       }
-       return (s16) (result >> 15);
-}
-
-/*
-Description: This function add two 32 bit numbers and return the 32bit result.
-If the result overflow 32 bits, the output will be saturated to 32bits.
-*/
-s32 qm_add32(s32 op1, s32 op2)
-{
-       s32 result;
-       result = op1 + op2;
-       if (op1 < 0 && op2 < 0 && result > 0) {
-               result = 0x80000000;
-       } else if (op1 > 0 && op2 > 0 && result < 0) {
-               result = 0x7fffffff;
-       }
-       return result;
-}
-
-/*
-Description: This function add two 16 bit numbers and return the 16bit result.
-If the result overflow 16 bits, the output will be saturated to 16bits.
-*/
-s16 qm_add16(s16 op1, s16 op2)
-{
-       s16 result;
-       s32 temp = (s32) op1 + (s32) op2;
-       if (temp > (s32) 0x7fff) {
-               result = (s16) 0x7fff;
-       } else if (temp < (s32) 0xffff8000) {
-               result = (s16) 0xffff8000;
-       } else {
-               result = (s16) temp;
-       }
-       return result;
-}
-
-/*
-Description: This function make 16 bit subtraction and return the 16bit result.
-If the result overflow 16 bits, the output will be saturated to 16bits.
-*/
-s16 qm_sub16(s16 op1, s16 op2)
-{
-       s16 result;
-       s32 temp = (s32) op1 - (s32) op2;
-       if (temp > (s32) 0x7fff) {
-               result = (s16) 0x7fff;
-       } else if (temp < (s32) 0xffff8000) {
-               result = (s16) 0xffff8000;
-       } else {
-               result = (s16) temp;
-       }
-       return result;
-}
-
-/*
-Description: This function make 32 bit subtraction and return the 32bit result.
-If the result overflow 32 bits, the output will be saturated to 32bits.
-*/
-s32 qm_sub32(s32 op1, s32 op2)
-{
-       s32 result;
-       result = op1 - op2;
-       if (op1 >= 0 && op2 < 0 && result < 0) {
-               result = 0x7fffffff;
-       } else if (op1 < 0 && op2 > 0 && result > 0) {
-               result = 0x80000000;
-       }
-       return result;
-}
-
-/*
-Description: This function multiply input 16 bit numbers and accumulate the result
-into the input 32 bit number and return the 32 bit accumulated result.
-If the accumulation result in overflow, then the output will be saturated.
-*/
-s32 qm_mac321616(s32 acc, s16 op1, s16 op2)
-{
-       s32 result;
-       result = qm_add32(acc, qm_mul321616(op1, op2));
-       return result;
-}
-
-/*
-Description: This function make a 32 bit saturated left shift when the specified shift
-is +ve. This function will make a 32 bit right shift when the specified shift is -ve.
-This function return the result after shifting operation.
-*/
-s32 qm_shl32(s32 op, int shift)
-{
-       int i;
-       s32 result;
-       result = op;
-       if (shift > 31)
-               shift = 31;
-       else if (shift < -31)
-               shift = -31;
-       if (shift >= 0) {
-               for (i = 0; i < shift; i++) {
-                       result = qm_add32(result, result);
-               }
-       } else {
-               result = result >> (-shift);
-       }
-       return result;
-}
-
-/*
-Description: This function make a 32 bit right shift when shift is +ve.
-This function make a 32 bit saturated left shift when shift is -ve. This function
-return the result of the shift operation.
-*/
-s32 qm_shr32(s32 op, int shift)
-{
-       return qm_shl32(op, -shift);
-}
-
-/*
-Description: This function make a 16 bit saturated left shift when the specified shift
-is +ve. This function will make a 16 bit right shift when the specified shift is -ve.
-This function return the result after shifting operation.
-*/
-s16 qm_shl16(s16 op, int shift)
-{
-       int i;
-       s16 result;
-       result = op;
-       if (shift > 15)
-               shift = 15;
-       else if (shift < -15)
-               shift = -15;
-       if (shift > 0) {
-               for (i = 0; i < shift; i++) {
-                       result = qm_add16(result, result);
-               }
-       } else {
-               result = result >> (-shift);
-       }
-       return result;
-}
-
-/*
-Description: This function make a 16 bit right shift when shift is +ve.
-This function make a 16 bit saturated left shift when shift is -ve. This function
-return the result of the shift operation.
-*/
-s16 qm_shr16(s16 op, int shift)
-{
-       return qm_shl16(op, -shift);
-}
-
-/*
-Description: This function return the number of redundant sign bits in a 16 bit number.
-Example: qm_norm16(0x0080) = 7.
-*/
-s16 qm_norm16(s16 op)
-{
-       u16 u16extraSignBits;
-       if (op == 0) {
-               return 15;
-       } else {
-               u16extraSignBits = 0;
-               while ((op >> 15) == (op >> 14)) {
-                       u16extraSignBits++;
-                       op = op << 1;
-               }
-       }
-       return u16extraSignBits;
-}
-
-/*
-Description: This function return the number of redundant sign bits in a 32 bit number.
-Example: qm_norm32(0x00000080) = 23
-*/
-s16 qm_norm32(s32 op)
-{
-       u16 u16extraSignBits;
-       if (op == 0) {
-               return 31;
-       } else {
-               u16extraSignBits = 0;
-               while ((op >> 31) == (op >> 30)) {
-                       u16extraSignBits++;
-                       op = op << 1;
-               }
-       }
-       return u16extraSignBits;
-}
-
-/*
-Description: This function divide two 16 bit unsigned numbers.
-The numerator should be less than denominator. So the quotient is always less than 1.
-This function return the quotient in q.15 format.
-*/
-s16 qm_div_s(s16 num, s16 denom)
-{
-       s16 var_out;
-       s16 iteration;
-       s32 L_num;
-       s32 L_denom;
-       L_num = (num) << 15;
-       L_denom = (denom) << 15;
-       for (iteration = 0; iteration < 15; iteration++) {
-               L_num <<= 1;
-               if (L_num >= L_denom) {
-                       L_num = qm_sub32(L_num, L_denom);
-                       L_num = qm_add32(L_num, 1);
-               }
-       }
-       var_out = (s16) (L_num & 0x7fff);
-       return var_out;
-}
-
-/*
-Description: This function compute the absolute value of a 16 bit number.
-*/
-s16 qm_abs16(s16 op)
-{
-       if (op < 0) {
-               if (op == (s16) 0xffff8000) {
-                       return 0x7fff;
-               } else {
-                       return -op;
-               }
-       } else {
-               return op;
-       }
-}
-
-/*
-Description: This function divide two 16 bit numbers.
-The quotient is returned through return value.
-The qformat of the quotient is returned through the pointer (qQuotient) passed
-to this function. The qformat of quotient is adjusted appropriately such that
-the quotient occupies all 16 bits.
-*/
-s16 qm_div16(s16 num, s16 denom, s16 *qQuotient)
-{
-       s16 sign;
-       s16 nNum, nDenom;
-       sign = num ^ denom;
-       num = qm_abs16(num);
-       denom = qm_abs16(denom);
-       nNum = qm_norm16(num);
-       nDenom = qm_norm16(denom);
-       num = qm_shl16(num, nNum - 1);
-       denom = qm_shl16(denom, nDenom);
-       *qQuotient = nNum - 1 - nDenom + 15;
-       if (sign >= 0) {
-               return qm_div_s(num, denom);
-       } else {
-               return -qm_div_s(num, denom);
-       }
-}
-
-/*
-Description: This function compute absolute value of a 32 bit number.
-*/
-s32 qm_abs32(s32 op)
-{
-       if (op < 0) {
-               if (op == (s32) 0x80000000) {
-                       return 0x7fffffff;
-               } else {
-                       return -op;
-               }
-       } else {
-               return op;
-       }
-}
-
-/*
-Description: This function divide two 32 bit numbers. The division is performed
-by considering only important 16 bits in 32 bit numbers.
-The quotient is returned through return value.
-The qformat of the quotient is returned through the pointer (qquotient) passed
-to this function. The qformat of quotient is adjusted appropriately such that
-the quotient occupies all 16 bits.
-*/
-s16 qm_div163232(s32 num, s32 denom, s16 *qquotient)
-{
-       s32 sign;
-       s16 nNum, nDenom;
-       sign = num ^ denom;
-       num = qm_abs32(num);
-       denom = qm_abs32(denom);
-       nNum = qm_norm32(num);
-       nDenom = qm_norm32(denom);
-       num = qm_shl32(num, nNum - 1);
-       denom = qm_shl32(denom, nDenom);
-       *qquotient = nNum - 1 - nDenom + 15;
-       if (sign >= 0) {
-               return qm_div_s((s16) (num >> 16), (s16) (denom >> 16));
-       } else {
-               return -qm_div_s((s16) (num >> 16), (s16) (denom >> 16));
-       }
-}
-
-/*
-Description: This function multiply a 32 bit number with a 16 bit number.
-The multiplicaton result is right shifted by 16 bits to fit the result
-into 32 bit output.
-*/
-s32 qm_mul323216(s32 op1, s16 op2)
-{
-       s16 hi;
-       u16 lo;
-       s32 result;
-       hi = op1 >> 16;
-       lo = (s16) (op1 & 0xffff);
-       result = qm_mul321616(hi, op2);
-       result = result + (qm_mulsu321616(op2, lo) >> 16);
-       return result;
-}
-
-/*
-Description: This function multiply signed 16 bit number with unsigned 16 bit number and return
-the result in 32 bits.
-*/
-s32 qm_mulsu321616(s16 op1, u16 op2)
-{
-       return (s32) (op1) * op2;
-}
-
-/*
-Description: This function multiply 32 bit number with 16 bit number. The multiplication result is
-right shifted by 15 bits to fit the result into 32 bits. Right shifting by only 15 bits instead of
-16 bits is done to remove the extra sign bit formed by multiplication from the return value.
-When the input numbers are 0x80000000, 0x8000 the return value is saturated to 0x7fffffff.
-*/
-s32 qm_muls323216(s32 op1, s16 op2)
-{
-       s16 hi;
-       u16 lo;
-       s32 result;
-       hi = op1 >> 16;
-       lo = (s16) (op1 & 0xffff);
-       result = qm_muls321616(hi, op2);
-       result = qm_add32(result, (qm_mulsu321616(op2, lo) >> 15));
-       return result;
-}
-
-/*
-Description: This function multiply two 32 bit numbers. The multiplication result is right
-shifted by 32 bits to fit the multiplication result into 32 bits. The right shifted
-multiplication result is returned as output.
-*/
-s32 qm_mul32(s32 a, s32 b)
-{
-       s16 hi1, hi2;
-       u16 lo1, lo2;
-       s32 result;
-       hi1 = a >> 16;
-       hi2 = b >> 16;
-       lo1 = (u16) (a & 0xffff);
-       lo2 = (u16) (b & 0xffff);
-       result = qm_mul321616(hi1, hi2);
-       result = result + (qm_mulsu321616(hi1, lo2) >> 16);
-       result = result + (qm_mulsu321616(hi2, lo1) >> 16);
-       return result;
-}
-
-/*
-Description: This function multiply two 32 bit numbers. The multiplication result is
-right shifted by 31 bits to fit the multiplication result into 32 bits. The right
-shifted multiplication result is returned as output. Right shifting by only 31 bits
-instead of 32 bits is done to remove the extra sign bit formed by multiplication.
-When the input numbers are 0x80000000, 0x80000000 the return value is saturated to
-0x7fffffff.
-*/
-s32 qm_muls32(s32 a, s32 b)
-{
-       s16 hi1, hi2;
-       u16 lo1, lo2;
-       s32 result;
-       hi1 = a >> 16;
-       hi2 = b >> 16;
-       lo1 = (u16) (a & 0xffff);
-       lo2 = (u16) (b & 0xffff);
-       result = qm_muls321616(hi1, hi2);
-       result = qm_add32(result, (qm_mulsu321616(hi1, lo2) >> 15));
-       result = qm_add32(result, (qm_mulsu321616(hi2, lo1) >> 15));
-       result = qm_add32(result, (qm_mulu16(lo1, lo2) >> 15));
-       return result;
-}
-
-/* This table is log2(1+(i/32)) where i=[0:1:31], in q.15 format */
-static const s16 log_table[] = {
-       0,
-       1455,
-       2866,
-       4236,
-       5568,
-       6863,
-       8124,
-       9352,
-       10549,
-       11716,
-       12855,
-       13968,
-       15055,
-       16117,
-       17156,
-       18173,
-       19168,
-       20143,
-       21098,
-       22034,
-       22952,
-       23852,
-       24736,
-       25604,
-       26455,
-       27292,
-       28114,
-       28922,
-       29717,
-       30498,
-       31267,
-       32024
-};
-
-#define LOG_TABLE_SIZE 32      /* log_table size */
-#define LOG2_LOG_TABLE_SIZE 5  /* log2(log_table size) */
-#define Q_LOG_TABLE 15         /* qformat of log_table */
-#define LOG10_2                19728   /* log10(2) in q.16 */
-
-/*
-Description:
-This routine takes the input number N and its q format qN and compute
-the log10(N). This routine first normalizes the input no N.    Then N is in mag*(2^x) format.
-mag is any number in the range 2^30-(2^31 - 1). Then log2(mag * 2^x) = log2(mag) + x is computed.
-From that log10(mag * 2^x) = log2(mag * 2^x) * log10(2) is computed.
-This routine looks the log2 value in the table considering LOG2_LOG_TABLE_SIZE+1 MSBs.
-As the MSB is always 1, only next LOG2_OF_LOG_TABLE_SIZE MSBs are used for table lookup.
-Next 16 MSBs are used for interpolation.
-Inputs:
-N - number to which log10 has to be found.
-qN - q format of N
-log10N - address where log10(N) will be written.
-qLog10N - address where log10N qformat will be written.
-Note/Problem:
-For accurate results input should be in normalized or near normalized form.
-*/
-void qm_log10(s32 N, s16 qN, s16 *log10N, s16 *qLog10N)
-{
-       s16 s16norm, s16tableIndex, s16errorApproximation;
-       u16 u16offset;
-       s32 s32log;
-
-       /* Logerithm of negative values is undefined.
-        * assert N is greater than 0.
-        */
-       /* ASSERT(N > 0); */
-
-       /* normalize the N. */
-       s16norm = qm_norm32(N);
-       N = N << s16norm;
-
-       /* The qformat of N after normalization.
-        * -30 is added to treat the no as between 1.0 to 2.0
-        * i.e. after adding the -30 to the qformat the decimal point will be
-        * just rigtht of the MSB. (i.e. after sign bit and 1st MSB). i.e.
-        * at the right side of 30th bit.
-        */
-       qN = qN + s16norm - 30;
-
-       /* take the table index as the LOG2_OF_LOG_TABLE_SIZE bits right of the MSB */
-       s16tableIndex = (s16) (N >> (32 - (2 + LOG2_LOG_TABLE_SIZE)));
-
-       /* remove the MSB. the MSB is always 1 after normalization. */
-       s16tableIndex =
-           s16tableIndex & (s16) ((1 << LOG2_LOG_TABLE_SIZE) - 1);
-
-       /* remove the (1+LOG2_OF_LOG_TABLE_SIZE) MSBs in the N. */
-       N = N & ((1 << (32 - (2 + LOG2_LOG_TABLE_SIZE))) - 1);
-
-       /* take the offset as the 16 MSBS after table index.
-        */
-       u16offset = (u16) (N >> (32 - (2 + LOG2_LOG_TABLE_SIZE + 16)));
-
-       /* look the log value in the table. */
-       s32log = log_table[s16tableIndex];      /* q.15 format */
-
-       /* interpolate using the offset. */
-       s16errorApproximation = (s16) qm_mulu16(u16offset, (u16) (log_table[s16tableIndex + 1] - log_table[s16tableIndex]));    /* q.15 */
-
-       s32log = qm_add16((s16) s32log, s16errorApproximation); /* q.15 format */
-
-       /* adjust for the qformat of the N as
-        * log2(mag * 2^x) = log2(mag) + x
-        */
-       s32log = qm_add32(s32log, ((s32) -qN) << 15);   /* q.15 format */
-
-       /* normalize the result. */
-       s16norm = qm_norm32(s32log);
-
-       /* bring all the important bits into lower 16 bits */
-       s32log = qm_shl32(s32log, s16norm - 16);        /* q.15+s16norm-16 format */
-
-       /* compute the log10(N) by multiplying log2(N) with log10(2).
-        * as log10(mag * 2^x) = log2(mag * 2^x) * log10(2)
-        * log10N in q.15+s16norm-16+1 (LOG10_2 is in q.16)
-        */
-       *log10N = qm_muls16((s16) s32log, (s16) LOG10_2);
-
-       /* write the q format of the result. */
-       *qLog10N = 15 + s16norm - 16 + 1;
-
-       return;
-}
-
-/*
-Description:
-This routine compute 1/N.
-This routine reformates the given no N as N * 2^qN where N is in between 0.5 and 1.0
-in q.15 format in 16 bits. So the problem now boils down to finding the inverse of a
-q.15 no in 16 bits which is in the range of 0.5 to 1.0. The output is always between
-2.0 to 1. So the output is 2.0 to 1.0 in q.30 format. Once the final output format is found
-by taking the qN into account. Inverse is found with newton rapson method. Initially
-inverse (x) is guessed as 1/0.75 (with appropriate sign). The new guess is calculated
-using the formula x' = 2*x - N*x*x. After 4 or 5 iterations the inverse is very close to
-inverse of N.
-Inputs:
-N - number to which 1/N has to be found.
-qn - q format of N.
-sqrtN - address where 1/N has to be written.
-qsqrtN - address where q format of 1/N has to be written.
-*/
-#define qx 29
-void qm_1byN(s32 N, s16 qN, s32 *result, s16 *qResult)
-{
-       s16 normN;
-       s32 s32firstTerm, s32secondTerm, x;
-       int i;
-
-       normN = qm_norm32(N);
-
-       /* limit N to least significant 16 bits. 15th bit is the sign bit. */
-       N = qm_shl32(N, normN - 16);
-       qN = qN + normN - 16 - 15;
-       /* -15 is added to treat N as 16 bit q.15 number in the range from 0.5 to 1 */
-
-       /* Take the initial guess as 1/0.75 in qx format with appropriate sign. */
-       if (N >= 0) {
-               x = (s32) ((1 / 0.75) * (1 << qx));
-               /* input no is in the range 0.5 to 1. So 1/0.75 is taken as initial guess. */
-       } else {
-               x = (s32) ((1 / -0.75) * (1 << qx));
-               /* input no is in the range -0.5 to -1. So 1/-0.75 is taken as initial guess. */
-       }
-
-       /* iterate the equation x = 2*x - N*x*x for 4 times. */
-       for (i = 0; i < 4; i++) {
-               s32firstTerm = qm_shl32(x, 1);  /* s32firstTerm = 2*x in q.29 */
-               s32secondTerm =
-                   qm_muls321616((s16) (s32firstTerm >> 16),
-                                 (s16) (s32firstTerm >> 16));
-               /* s32secondTerm = x*x in q.(29+1-16)*2+1 */
-               s32secondTerm =
-                   qm_muls321616((s16) (s32secondTerm >> 16), (s16) N);
-               /* s32secondTerm = N*x*x in q.((29+1-16)*2+1)-16+15+1 i.e. in q.29 */
-               x = qm_sub32(s32firstTerm, s32secondTerm);
-               /* can be added directly as both are in q.29 */
-       }
-
-       /* Bring the x to q.30 format. */
-       *result = qm_shl32(x, 1);
-       /* giving the output in q.30 format for q.15 input in 16 bits. */
-
-       /* compute the final q format of the result. */
-       *qResult = -qN + 30;    /* adjusting the q format of actual output */
-
-       return;
-}
-
-#undef qx
diff --git a/drivers/staging/brcm80211/util/sbpcmcia.h b/drivers/staging/brcm80211/util/sbpcmcia.h
deleted file mode 100644 (file)
index d4c1565..0000000
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
- * Copyright (c) 2010 Broadcom Corporation
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
- * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
- * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifndef        _SBPCMCIA_H
-#define        _SBPCMCIA_H
-
-/* All the addresses that are offsets in attribute space are divided
- * by two to account for the fact that odd bytes are invalid in
- * attribute space and our read/write routines make the space appear
- * as if they didn't exist. Still we want to show the original numbers
- * as documented in the hnd_pcmcia core manual.
- */
-
-/* PCMCIA Function Configuration Registers */
-#define        PCMCIA_FCR              (0x700 / 2)
-
-#define        FCR0_OFF                0
-#define        FCR1_OFF                (0x40 / 2)
-#define        FCR2_OFF                (0x80 / 2)
-#define        FCR3_OFF                (0xc0 / 2)
-
-#define        PCMCIA_FCR0             (0x700 / 2)
-#define        PCMCIA_FCR1             (0x740 / 2)
-#define        PCMCIA_FCR2             (0x780 / 2)
-#define        PCMCIA_FCR3             (0x7c0 / 2)
-
-/* Standard PCMCIA FCR registers */
-
-#define        PCMCIA_COR              0
-
-#define        COR_RST                 0x80
-#define        COR_LEV                 0x40
-#define        COR_IRQEN               0x04
-#define        COR_BLREN               0x01
-#define        COR_FUNEN               0x01
-
-#define        PCICIA_FCSR             (2 / 2)
-#define        PCICIA_PRR              (4 / 2)
-#define        PCICIA_SCR              (6 / 2)
-#define        PCICIA_ESR              (8 / 2)
-
-#define PCM_MEMOFF             0x0000
-#define F0_MEMOFF              0x1000
-#define F1_MEMOFF              0x2000
-#define F2_MEMOFF              0x3000
-#define F3_MEMOFF              0x4000
-
-/* Memory base in the function fcr's */
-#define MEM_ADDR0              (0x728 / 2)
-#define MEM_ADDR1              (0x72a / 2)
-#define MEM_ADDR2              (0x72c / 2)
-
-/* PCMCIA base plus Srom access in fcr0: */
-#define PCMCIA_ADDR0           (0x072e / 2)
-#define PCMCIA_ADDR1           (0x0730 / 2)
-#define PCMCIA_ADDR2           (0x0732 / 2)
-
-#define MEM_SEG                        (0x0734 / 2)
-#define SROM_CS                        (0x0736 / 2)
-#define SROM_DATAL             (0x0738 / 2)
-#define SROM_DATAH             (0x073a / 2)
-#define SROM_ADDRL             (0x073c / 2)
-#define SROM_ADDRH             (0x073e / 2)
-#define        SROM_INFO2              (0x0772 / 2)    /* Corerev >= 2 && <= 5 */
-#define        SROM_INFO               (0x07be / 2)    /* Corerev >= 6 */
-
-/*  Values for srom_cs: */
-#define SROM_IDLE              0
-#define SROM_WRITE             1
-#define SROM_READ              2
-#define SROM_WEN               4
-#define SROM_WDS               7
-#define SROM_DONE              8
-
-/* Fields in srom_info: */
-#define        SRI_SZ_MASK             0x03
-#define        SRI_BLANK               0x04
-#define        SRI_OTP                 0x80
-
-#if !defined(ESTA_POSTMOGRIFY_REMOVAL)
-/* CIS stuff */
-
-/* The CIS stops where the FCRs start */
-#define        CIS_SIZE                PCMCIA_FCR
-
-/* CIS tuple length field max */
-#define CIS_TUPLE_LEN_MAX      0xff
-
-/* Standard tuples we know about */
-
-#define CISTPL_NULL                    0x00
-#define        CISTPL_VERS_1           0x15    /* CIS ver, manf, dev & ver strings */
-#define        CISTPL_MANFID           0x20    /* Manufacturer and device id */
-#define CISTPL_FUNCID          0x21    /* Function identification */
-#define        CISTPL_FUNCE            0x22    /* Function extensions */
-#define        CISTPL_CFTABLE          0x1b    /* Config table entry */
-#define        CISTPL_END              0xff    /* End of the CIS tuple chain */
-
-/* Function identifier provides context for the function extensions tuple */
-#define CISTPL_FID_SDIO                0x0c    /* Extensions defined by SDIO spec */
-
-/* Function extensions for LANs (assumed for extensions other than SDIO) */
-#define        LAN_TECH                1       /* Technology type */
-#define        LAN_SPEED               2       /* Raw bit rate */
-#define        LAN_MEDIA               3       /* Transmission media */
-#define        LAN_NID                 4       /* Node identification (aka MAC addr) */
-#define        LAN_CONN                5       /* Connector standard */
-
-/* CFTable */
-#define CFTABLE_REGWIN_2K      0x08    /* 2k reg windows size */
-#define CFTABLE_REGWIN_4K      0x10    /* 4k reg windows size */
-#define CFTABLE_REGWIN_8K      0x20    /* 8k reg windows size */
-
-/* Vendor unique tuples are 0x80-0x8f. Within Broadcom we'll
- * take one for HNBU, and use "extensions" (a la FUNCE) within it.
- */
-
-#define        CISTPL_BRCM_HNBU        0x80
-
-/* Subtypes of BRCM_HNBU: */
-
-#define HNBU_SROMREV           0x00    /* A byte with sromrev, 1 if not present */
-#define HNBU_CHIPID            0x01    /* Two 16bit values: PCI vendor & device id */
-#define HNBU_BOARDREV          0x02    /* One byte board revision */
-#define HNBU_PAPARMS           0x03    /* PA parameters: 8 (sromrev == 1)
-                                        * or 9 (sromrev > 1) bytes
-                                        */
-#define HNBU_OEM               0x04    /* Eight bytes OEM data (sromrev == 1) */
-#define HNBU_CC                        0x05    /* Default country code (sromrev == 1) */
-#define        HNBU_AA                 0x06    /* Antennas available */
-#define        HNBU_AG                 0x07    /* Antenna gain */
-#define HNBU_BOARDFLAGS                0x08    /* board flags (2 or 4 bytes) */
-#define HNBU_LEDS              0x09    /* LED set */
-#define HNBU_CCODE             0x0a    /* Country code (2 bytes ascii + 1 byte cctl)
-                                        * in rev 2
-                                        */
-#define HNBU_CCKPO             0x0b    /* 2 byte cck power offsets in rev 3 */
-#define HNBU_OFDMPO            0x0c    /* 4 byte 11g ofdm power offsets in rev 3 */
-#define HNBU_GPIOTIMER         0x0d    /* 2 bytes with on/off values in rev 3 */
-#define HNBU_PAPARMS5G         0x0e    /* 5G PA params */
-#define HNBU_ANT5G             0x0f    /* 4328 5G antennas available/gain */
-#define HNBU_RDLID             0x10    /* 2 byte USB remote downloader (RDL) product Id */
-#define HNBU_RSSISMBXA2G       0x11    /* 4328 2G RSSI mid pt sel & board switch arch,
-                                        * 2 bytes, rev 3.
-                                        */
-#define HNBU_RSSISMBXA5G       0x12    /* 4328 5G RSSI mid pt sel & board switch arch,
-                                        * 2 bytes, rev 3.
-                                        */
-#define HNBU_XTALFREQ          0x13    /* 4 byte Crystal frequency in kilohertz */
-#define HNBU_TRI2G             0x14    /* 4328 2G TR isolation, 1 byte */
-#define HNBU_TRI5G             0x15    /* 4328 5G TR isolation, 3 bytes */
-#define HNBU_RXPO2G            0x16    /* 4328 2G RX power offset, 1 byte */
-#define HNBU_RXPO5G            0x17    /* 4328 5G RX power offset, 1 byte */
-#define HNBU_BOARDNUM          0x18    /* board serial number, independent of mac addr */
-#define HNBU_MACADDR           0x19    /* mac addr override for the standard CIS LAN_NID */
-#define HNBU_RDLSN             0x1a    /* 2 bytes; serial # advertised in USB descriptor */
-#define HNBU_BOARDTYPE         0x1b    /* 2 bytes; boardtype */
-#define HNBU_LEDDC             0x1c    /* 2 bytes; LED duty cycle */
-#define HNBU_HNBUCIS           0x1d    /* what follows is proprietary HNBU CIS format */
-#define HNBU_PAPARMS_SSLPNPHY  0x1e    /* SSLPNPHY PA params */
-#define HNBU_RSSISMBXA2G_SSLPNPHY 0x1f /* SSLPNPHY RSSI mid pt sel & board switch arch */
-#define HNBU_RDLRNDIS          0x20    /* 1 byte; 1 = RDL advertises RNDIS config */
-#define HNBU_CHAINSWITCH       0x21    /* 2 byte; txchain, rxchain */
-#define HNBU_REGREV            0x22    /* 1 byte; */
-#define HNBU_FEM               0x23    /* 2 or 4 byte: 11n frontend specification */
-#define HNBU_PAPARMS_C0                0x24    /* 8 or 30 bytes: 11n pa paramater for chain 0 */
-#define HNBU_PAPARMS_C1                0x25    /* 8 or 30 bytes: 11n pa paramater for chain 1 */
-#define HNBU_PAPARMS_C2                0x26    /* 8 or 30 bytes: 11n pa paramater for chain 2 */
-#define HNBU_PAPARMS_C3                0x27    /* 8 or 30 bytes: 11n pa paramater for chain 3 */
-#define HNBU_PO_CCKOFDM                0x28    /* 6 or 18 bytes: cck2g/ofdm2g/ofdm5g power offset */
-#define HNBU_PO_MCS2G          0x29    /* 8 bytes: mcs2g power offset */
-#define HNBU_PO_MCS5GM         0x2a    /* 8 bytes: mcs5g mid band power offset */
-#define HNBU_PO_MCS5GLH                0x2b    /* 16 bytes: mcs5g low-high band power offset */
-#define HNBU_PO_CDD            0x2c    /* 2 bytes: cdd2g/5g power offset */
-#define HNBU_PO_STBC           0x2d    /* 2 bytes: stbc2g/5g power offset */
-#define HNBU_PO_40M            0x2e    /* 2 bytes: 40Mhz channel 2g/5g power offset */
-#define HNBU_PO_40MDUP         0x2f    /* 2 bytes: 40Mhz channel dup 2g/5g power offset */
-
-#define HNBU_RDLRWU            0x30    /* 1 byte; 1 = RDL advertises Remote Wake-up */
-#define HNBU_WPS               0x31    /* 1 byte; GPIO pin for WPS button */
-#define HNBU_USBFS             0x32    /* 1 byte; 1 = USB advertises FS mode only */
-#define HNBU_BRMIN             0x33    /* 4 byte bootloader min resource mask */
-#define HNBU_BRMAX             0x34    /* 4 byte bootloader max resource mask */
-#define HNBU_PATCH             0x35    /* bootloader patch addr(2b) & data(4b) pair */
-#define HNBU_CCKFILTTYPE       0x36    /* CCK digital filter selection options */
-#define HNBU_OFDMPO5G          0x37    /* 4 * 3 = 12 byte 11a ofdm power offsets in rev 3 */
-
-#define HNBU_USBEPNUM          0x40    /* USB endpoint numbers */
-#define HNBU_SROM3SWRGN                0x80    /* 78 bytes; srom rev 3 s/w region without crc8
-                                        * plus extra info appended.
-                                        */
-#define HNBU_RESERVED          0x81    /* Reserved for non-BRCM post-mfg additions */
-#define HNBU_CUSTOM1           0x82    /* 4 byte; For non-BRCM post-mfg additions */
-#define HNBU_CUSTOM2           0x83    /* Reserved; For non-BRCM post-mfg additions */
-#endif                         /* !defined(ESTA_POSTMOGRIFY_REMOVAL) */
-
-/* sbtmstatelow */
-#define SBTML_INT_ACK          0x40000 /* ack the sb interrupt */
-#define SBTML_INT_EN           0x20000 /* enable sb interrupt */
-
-/* sbtmstatehigh */
-#define SBTMH_INT_STATUS       0x40000 /* sb interrupt status */
-
-#endif                         /* _SBPCMCIA_H */
diff --git a/drivers/staging/brcm80211/util/sbsocram.h b/drivers/staging/brcm80211/util/sbsocram.h
deleted file mode 100644 (file)
index 0cfe985..0000000
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * Copyright (c) 2010 Broadcom Corporation
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
- * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
- * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifndef        _SBSOCRAM_H
-#define        _SBSOCRAM_H
-
-#ifndef _LANGUAGE_ASSEMBLY
-
-/* cpp contortions to concatenate w/arg prescan */
-#ifndef PAD
-#define        _PADLINE(line)  pad ## line
-#define        _XSTR(line)     _PADLINE(line)
-#define        PAD             _XSTR(__LINE__)
-#endif                         /* PAD */
-
-/* Memcsocram core registers */
-typedef volatile struct sbsocramregs {
-       u32 coreinfo;
-       u32 bwalloc;
-       u32 extracoreinfo;
-       u32 biststat;
-       u32 bankidx;
-       u32 standbyctrl;
-
-       u32 errlogstatus;       /* rev 6 */
-       u32 errlogaddr; /* rev 6 */
-       /* used for patching rev 3 & 5 */
-       u32 cambankidx;
-       u32 cambankstandbyctrl;
-       u32 cambankpatchctrl;
-       u32 cambankpatchtblbaseaddr;
-       u32 cambankcmdreg;
-       u32 cambankdatareg;
-       u32 cambankmaskreg;
-       u32 PAD[1];
-       u32 bankinfo;   /* corev 8 */
-       u32 PAD[15];
-       u32 extmemconfig;
-       u32 extmemparitycsr;
-       u32 extmemparityerrdata;
-       u32 extmemparityerrcnt;
-       u32 extmemwrctrlandsize;
-       u32 PAD[84];
-       u32 workaround;
-       u32 pwrctl;             /* corerev >= 2 */
-} sbsocramregs_t;
-
-#endif                         /* _LANGUAGE_ASSEMBLY */
-
-/* Register offsets */
-#define        SR_COREINFO             0x00
-#define        SR_BWALLOC              0x04
-#define        SR_BISTSTAT             0x0c
-#define        SR_BANKINDEX            0x10
-#define        SR_BANKSTBYCTL          0x14
-#define SR_PWRCTL              0x1e8
-
-/* Coreinfo register */
-#define        SRCI_PT_MASK            0x00070000      /* corerev >= 6; port type[18:16] */
-#define        SRCI_PT_SHIFT           16
-/* port types : SRCI_PT_<processorPT>_<backplanePT> */
-#define SRCI_PT_OCP_OCP                0
-#define SRCI_PT_AXI_OCP                1
-#define SRCI_PT_ARM7AHB_OCP    2
-#define SRCI_PT_CM3AHB_OCP     3
-#define SRCI_PT_AXI_AXI                4
-#define SRCI_PT_AHB_AXI                5
-/* corerev >= 3 */
-#define SRCI_LSS_MASK          0x00f00000
-#define SRCI_LSS_SHIFT         20
-#define SRCI_LRS_MASK          0x0f000000
-#define SRCI_LRS_SHIFT         24
-
-/* In corerev 0, the memory size is 2 to the power of the
- * base plus 16 plus to the contents of the memsize field plus 1.
- */
-#define        SRCI_MS0_MASK           0xf
-#define SR_MS0_BASE            16
-
-/*
- * In corerev 1 the bank size is 2 ^ the bank size field plus 14,
- * the memory size is number of banks times bank size.
- * The same applies to rom size.
- */
-#define        SRCI_ROMNB_MASK         0xf000
-#define        SRCI_ROMNB_SHIFT        12
-#define        SRCI_ROMBSZ_MASK        0xf00
-#define        SRCI_ROMBSZ_SHIFT       8
-#define        SRCI_SRNB_MASK          0xf0
-#define        SRCI_SRNB_SHIFT         4
-#define        SRCI_SRBSZ_MASK         0xf
-#define        SRCI_SRBSZ_SHIFT        0
-
-#define SR_BSZ_BASE            14
-
-/* Standby control register */
-#define        SRSC_SBYOVR_MASK        0x80000000
-#define        SRSC_SBYOVR_SHIFT       31
-#define        SRSC_SBYOVRVAL_MASK     0x60000000
-#define        SRSC_SBYOVRVAL_SHIFT    29
-#define        SRSC_SBYEN_MASK         0x01000000      /* rev >= 3 */
-#define        SRSC_SBYEN_SHIFT        24
-
-/* Power control register */
-#define SRPC_PMU_STBYDIS_MASK  0x00000010      /* rev >= 3 */
-#define SRPC_PMU_STBYDIS_SHIFT 4
-#define SRPC_STBYOVRVAL_MASK   0x00000008
-#define SRPC_STBYOVRVAL_SHIFT  3
-#define SRPC_STBYOVR_MASK      0x00000007
-#define SRPC_STBYOVR_SHIFT     0
-
-/* Extra core capability register */
-#define SRECC_NUM_BANKS_MASK   0x000000F0
-#define SRECC_NUM_BANKS_SHIFT  4
-#define SRECC_BANKSIZE_MASK    0x0000000F
-#define SRECC_BANKSIZE_SHIFT   0
-
-#define SRECC_BANKSIZE(value)   (1 << (value))
-
-/* CAM bank patch control */
-#define SRCBPC_PATCHENABLE 0x80000000
-
-#define SRP_ADDRESS   0x0001FFFC
-#define SRP_VALID     0x8000
-
-/* CAM bank command reg */
-#define SRCMD_WRITE  0x00020000
-#define SRCMD_READ   0x00010000
-#define SRCMD_DONE   0x80000000
-
-#define SRCMD_DONE_DLY 1000
-
-/* bankidx and bankinfo reg defines corerev >= 8 */
-#define SOCRAM_BANKINFO_SZMASK         0x3f
-#define SOCRAM_BANKIDX_ROM_MASK                0x100
-
-#define SOCRAM_BANKIDX_MEMTYPE_SHIFT   8
-/* socram bankinfo memtype */
-#define SOCRAM_MEMTYPE_RAM             0
-#define SOCRAM_MEMTYPE_R0M             1
-#define SOCRAM_MEMTYPE_DEVRAM          2
-
-#define        SOCRAM_BANKINFO_REG             0x40
-#define        SOCRAM_BANKIDX_REG              0x10
-#define        SOCRAM_BANKINFO_STDBY_MASK      0x400
-#define        SOCRAM_BANKINFO_STDBY_TIMER     0x800
-
-/* bankinfo rev >= 10 */
-#define SOCRAM_BANKINFO_DEVRAMSEL_SHIFT        13
-#define SOCRAM_BANKINFO_DEVRAMSEL_MASK 0x2000
-#define SOCRAM_BANKINFO_DEVRAMPRO_SHIFT        14
-#define SOCRAM_BANKINFO_DEVRAMPRO_MASK 0x4000
-
-/* extracoreinfo register */
-#define SOCRAM_DEVRAMBANK_MASK         0xF000
-#define SOCRAM_DEVRAMBANK_SHIFT                12
-
-/* bank info to calculate bank size */
-#define        SOCRAM_BANKINFO_SZBASE          8192
-#define SOCRAM_BANKSIZE_SHIFT          13      /* SOCRAM_BANKINFO_SZBASE */
-
-#endif                         /* _SBSOCRAM_H */
diff --git a/drivers/staging/brcm80211/util/sbutils.c b/drivers/staging/brcm80211/util/sbutils.c
deleted file mode 100644 (file)
index 21dde8e..0000000
+++ /dev/null
@@ -1,476 +0,0 @@
-/*
- * Copyright (c) 2010 Broadcom Corporation
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
- * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
- * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <linux/types.h>
-#include <bcmdefs.h>
-#ifdef BRCM_FULLMAC
-#include <linux/netdevice.h>
-#endif
-#include <bcmutils.h>
-#include <siutils.h>
-#include <bcmdevs.h>
-#include <hndsoc.h>
-#include <sbchipc.h>
-#include <pci_core.h>
-#include <pcicfg.h>
-#include <sbpcmcia.h>
-#include "siutils_priv.h"
-
-/* local prototypes */
-static uint _sb_coreidx(si_info_t *sii, u32 sba);
-static uint _sb_scan(si_info_t *sii, u32 sba, void *regs, uint bus,
-                    u32 sbba, uint ncores);
-static u32 _sb_coresba(si_info_t *sii);
-static void *_sb_setcoreidx(si_info_t *sii, uint coreidx);
-
-#define        SET_SBREG(sii, r, mask, val)    \
-               W_SBREG((sii), (r), ((R_SBREG((sii), (r)) & ~(mask)) | (val)))
-#define        REGS2SB(va)     (sbconfig_t *) ((s8 *)(va) + SBCONFIGOFF)
-
-/* sonicsrev */
-#define        SONICS_2_2      (SBIDL_RV_2_2 >> SBIDL_RV_SHIFT)
-#define        SONICS_2_3      (SBIDL_RV_2_3 >> SBIDL_RV_SHIFT)
-
-#define        R_SBREG(sii, sbr)       sb_read_sbreg((sii), (sbr))
-#define        W_SBREG(sii, sbr, v)    sb_write_sbreg((sii), (sbr), (v))
-#define        AND_SBREG(sii, sbr, v)  \
-       W_SBREG((sii), (sbr), (R_SBREG((sii), (sbr)) & (v)))
-#define        OR_SBREG(sii, sbr, v)   \
-       W_SBREG((sii), (sbr), (R_SBREG((sii), (sbr)) | (v)))
-
-static u32 sb_read_sbreg(si_info_t *sii, volatile u32 *sbr)
-{
-       return R_REG(sbr);
-}
-
-static void sb_write_sbreg(si_info_t *sii, volatile u32 *sbr, u32 v)
-{
-       W_REG(sbr, v);
-}
-
-uint sb_coreid(si_t *sih)
-{
-       si_info_t *sii;
-       sbconfig_t *sb;
-
-       sii = SI_INFO(sih);
-       sb = REGS2SB(sii->curmap);
-
-       return (R_SBREG(sii, &sb->sbidhigh) & SBIDH_CC_MASK) >>
-               SBIDH_CC_SHIFT;
-}
-
-/* return core index of the core with address 'sba' */
-static uint _sb_coreidx(si_info_t *sii, u32 sba)
-{
-       uint i;
-
-       for (i = 0; i < sii->numcores; i++)
-               if (sba == sii->coresba[i])
-                       return i;
-       return BADIDX;
-}
-
-/* return core address of the current core */
-static u32 _sb_coresba(si_info_t *sii)
-{
-       u32 sbaddr = 0;
-
-       switch (sii->pub.bustype) {
-       case SPI_BUS:
-       case SDIO_BUS:
-               sbaddr = (u32)(unsigned long)sii->curmap;
-               break;
-       default:
-               ASSERT(0);
-               break;
-       }
-
-       return sbaddr;
-}
-
-uint sb_corerev(si_t *sih)
-{
-       si_info_t *sii;
-       sbconfig_t *sb;
-       uint sbidh;
-
-       sii = SI_INFO(sih);
-       sb = REGS2SB(sii->curmap);
-       sbidh = R_SBREG(sii, &sb->sbidhigh);
-
-       return SBCOREREV(sbidh);
-}
-
-bool sb_iscoreup(si_t *sih)
-{
-       si_info_t *sii;
-       sbconfig_t *sb;
-
-       sii = SI_INFO(sih);
-       sb = REGS2SB(sii->curmap);
-
-       return (R_SBREG(sii, &sb->sbtmstatelow) &
-                (SBTML_RESET | SBTML_REJ_MASK |
-                 (SICF_CLOCK_EN << SBTML_SICF_SHIFT))) ==
-               (SICF_CLOCK_EN << SBTML_SICF_SHIFT);
-}
-
-/*
- * Switch to 'coreidx', issue a single arbitrary 32bit
- * register mask&set operation,
- * switch back to the original core, and return the new value.
- *
- * When using the silicon backplane, no fidleing with interrupts
- * or core switches are needed.
- *
- * Also, when using pci/pcie, we can optimize away the core switching
- * for pci registers
- * and (on newer pci cores) chipcommon registers.
- */
-uint sb_corereg(si_t *sih, uint coreidx, uint regoff, uint mask, uint val)
-{
-       uint origidx = 0;
-       u32 *r = NULL;
-       uint w;
-       uint intr_val = 0;
-       bool fast = false;
-       si_info_t *sii;
-
-       sii = SI_INFO(sih);
-
-       ASSERT(GOODIDX(coreidx));
-       ASSERT(regoff < SI_CORE_SIZE);
-       ASSERT((val & ~mask) == 0);
-
-       if (coreidx >= SI_MAXCORES)
-               return 0;
-
-       if (!fast) {
-               INTR_OFF(sii, intr_val);
-
-               /* save current core index */
-               origidx = si_coreidx(&sii->pub);
-
-               /* switch core */
-               r = (u32 *) ((unsigned char *) sb_setcoreidx(&sii->pub, coreidx) +
-                               regoff);
-       }
-       ASSERT(r != NULL);
-
-       /* mask and set */
-       if (mask || val) {
-               if (regoff >= SBCONFIGOFF) {
-                       w = (R_SBREG(sii, r) & ~mask) | val;
-                       W_SBREG(sii, r, w);
-               } else {
-                       w = (R_REG(r) & ~mask) | val;
-                       W_REG(r, w);
-               }
-       }
-
-       /* readback */
-       if (regoff >= SBCONFIGOFF)
-               w = R_SBREG(sii, r);
-       else
-               w = R_REG(r);
-
-       if (!fast) {
-               /* restore core index */
-               if (origidx != coreidx)
-                       sb_setcoreidx(&sii->pub, origidx);
-
-               INTR_RESTORE(sii, intr_val);
-       }
-
-       return w;
-}
-
-/* Scan the enumeration space to find all cores starting from the given
- * bus 'sbba'. Append coreid and other info to the lists in 'si'. 'sba'
- * is the default core address at chip POR time and 'regs' is the virtual
- * address that the default core is mapped at. 'ncores' is the number of
- * cores expected on bus 'sbba'. It returns the total number of cores
- * starting from bus 'sbba', inclusive.
- */
-#define SB_MAXBUSES    2
-static uint _sb_scan(si_info_t *sii, u32 sba, void *regs, uint bus, u32 sbba,
-                    uint numcores)
-{
-       uint next;
-       uint ncc = 0;
-       uint i;
-
-       if (bus >= SB_MAXBUSES) {
-               SI_ERROR(("_sb_scan: bus 0x%08x at level %d is too deep to "
-                       "scan\n", sbba, bus));
-               return 0;
-       }
-       SI_MSG(("_sb_scan: scan bus 0x%08x assume %u cores\n",
-               sbba, numcores));
-
-       /* Scan all cores on the bus starting from core 0.
-        * Core addresses must be contiguous on each bus.
-        */
-       for (i = 0, next = sii->numcores;
-            i < numcores && next < SB_BUS_MAXCORES; i++, next++) {
-               sii->coresba[next] = sbba + (i * SI_CORE_SIZE);
-
-               /* change core to 'next' and read its coreid */
-               sii->curmap = _sb_setcoreidx(sii, next);
-               sii->curidx = next;
-
-               sii->coreid[next] = sb_coreid(&sii->pub);
-
-               /* core specific processing... */
-               /* chipc provides # cores */
-               if (sii->coreid[next] == CC_CORE_ID) {
-                       chipcregs_t *cc = (chipcregs_t *) sii->curmap;
-                       u32 ccrev = sb_corerev(&sii->pub);
-
-                       /* determine numcores - this is the
-                                total # cores in the chip */
-                       if (((ccrev == 4) || (ccrev >= 6)))
-                               numcores =
-                                   (R_REG(&cc->chipid) & CID_CC_MASK)
-                                   >> CID_CC_SHIFT;
-                       else {
-                               /* Older chips */
-                               SI_ERROR(("sb_chip2numcores: unsupported chip "
-                                                 "0x%x\n", sii->pub.chip));
-                               ASSERT(0);
-                               numcores = 1;
-                       }
-
-                       SI_VMSG(("_sb_scan: %u cores in the chip %s\n",
-                       numcores, sii->pub.issim ? "QT" : ""));
-               }
-               /* scan bridged SB(s) and add results to the end of the list */
-               else if (sii->coreid[next] == OCP_CORE_ID) {
-                       sbconfig_t *sb = REGS2SB(sii->curmap);
-                       u32 nsbba = R_SBREG(sii, &sb->sbadmatch1);
-                       uint nsbcc;
-
-                       sii->numcores = next + 1;
-
-                       if ((nsbba & 0xfff00000) != SI_ENUM_BASE)
-                               continue;
-                       nsbba &= 0xfffff000;
-                       if (_sb_coreidx(sii, nsbba) != BADIDX)
-                               continue;
-
-                       nsbcc =
-                           (R_SBREG(sii, &sb->sbtmstatehigh) & 0x000f0000) >>
-                           16;
-                       nsbcc = _sb_scan(sii, sba, regs, bus + 1, nsbba, nsbcc);
-                       if (sbba == SI_ENUM_BASE)
-                               numcores -= nsbcc;
-                       ncc += nsbcc;
-               }
-       }
-
-       SI_MSG(("_sb_scan: found %u cores on bus 0x%08x\n", i, sbba));
-
-       sii->numcores = i + ncc;
-       return sii->numcores;
-}
-
-/* scan the sb enumerated space to identify all cores */
-void sb_scan(si_t *sih, void *regs, uint devid)
-{
-       si_info_t *sii;
-       u32 origsba;
-       sbconfig_t *sb;
-
-       sii = SI_INFO(sih);
-       sb = REGS2SB(sii->curmap);
-
-       sii->pub.socirev =
-           (R_SBREG(sii, &sb->sbidlow) & SBIDL_RV_MASK) >> SBIDL_RV_SHIFT;
-
-       /* Save the current core info and validate it later till we know
-        * for sure what is good and what is bad.
-        */
-       origsba = _sb_coresba(sii);
-
-       /* scan all SB(s) starting from SI_ENUM_BASE */
-       sii->numcores = _sb_scan(sii, origsba, regs, 0, SI_ENUM_BASE, 1);
-}
-
-/*
- * This function changes logical "focus" to the indicated core;
- * must be called with interrupts off.
- * Moreover, callers should keep interrupts off during switching out of
- * and back to d11 core
- */
-void *sb_setcoreidx(si_t *sih, uint coreidx)
-{
-       si_info_t *sii;
-
-       sii = SI_INFO(sih);
-
-       if (coreidx >= sii->numcores)
-               return NULL;
-
-       /*
-        * If the user has provided an interrupt mask enabled function,
-        * then assert interrupts are disabled before switching the core.
-        */
-       ASSERT((sii->intrsenabled_fn == NULL)
-              || !(*(sii)->intrsenabled_fn) ((sii)->intr_arg));
-
-       sii->curmap = _sb_setcoreidx(sii, coreidx);
-       sii->curidx = coreidx;
-
-       return sii->curmap;
-}
-
-/* This function changes the logical "focus" to the indicated core.
- * Return the current core's virtual address.
- */
-static void *_sb_setcoreidx(si_info_t *sii, uint coreidx)
-{
-       u32 sbaddr = sii->coresba[coreidx];
-       void *regs;
-
-       switch (sii->pub.bustype) {
-#ifdef BCMSDIO
-       case SPI_BUS:
-       case SDIO_BUS:
-               /* map new one */
-               if (!sii->regs[coreidx]) {
-                       sii->regs[coreidx] = (void *)sbaddr;
-                       ASSERT(GOODREGS(sii->regs[coreidx]));
-               }
-               regs = sii->regs[coreidx];
-               break;
-#endif                         /* BCMSDIO */
-       default:
-               ASSERT(0);
-               regs = NULL;
-               break;
-       }
-
-       return regs;
-}
-
-void sb_core_disable(si_t *sih, u32 bits)
-{
-       si_info_t *sii;
-       volatile u32 dummy;
-       sbconfig_t *sb;
-
-       sii = SI_INFO(sih);
-
-       ASSERT(GOODREGS(sii->curmap));
-       sb = REGS2SB(sii->curmap);
-
-       /* if core is already in reset, just return */
-       if (R_SBREG(sii, &sb->sbtmstatelow) & SBTML_RESET)
-               return;
-
-       /* if clocks are not enabled, put into reset and return */
-       if ((R_SBREG(sii, &sb->sbtmstatelow) &
-            (SICF_CLOCK_EN << SBTML_SICF_SHIFT)) == 0)
-               goto disable;
-
-       /* set target reject and spin until busy is clear
-          (preserve core-specific bits) */
-       OR_SBREG(sii, &sb->sbtmstatelow, SBTML_REJ);
-       dummy = R_SBREG(sii, &sb->sbtmstatelow);
-       udelay(1);
-       SPINWAIT((R_SBREG(sii, &sb->sbtmstatehigh) & SBTMH_BUSY), 100000);
-       if (R_SBREG(sii, &sb->sbtmstatehigh) & SBTMH_BUSY)
-               SI_ERROR(("%s: target state still busy\n", __func__));
-
-       if (R_SBREG(sii, &sb->sbidlow) & SBIDL_INIT) {
-               OR_SBREG(sii, &sb->sbimstate, SBIM_RJ);
-               dummy = R_SBREG(sii, &sb->sbimstate);
-               udelay(1);
-               SPINWAIT((R_SBREG(sii, &sb->sbimstate) & SBIM_BY), 100000);
-       }
-
-       /* set reset and reject while enabling the clocks */
-       W_SBREG(sii, &sb->sbtmstatelow,
-               (((bits | SICF_FGC | SICF_CLOCK_EN) << SBTML_SICF_SHIFT) |
-                SBTML_REJ | SBTML_RESET));
-       dummy = R_SBREG(sii, &sb->sbtmstatelow);
-       udelay(10);
-
-       /* don't forget to clear the initiator reject bit */
-       if (R_SBREG(sii, &sb->sbidlow) & SBIDL_INIT)
-               AND_SBREG(sii, &sb->sbimstate, ~SBIM_RJ);
-
-disable:
-       /* leave reset and reject asserted */
-       W_SBREG(sii, &sb->sbtmstatelow,
-               ((bits << SBTML_SICF_SHIFT) | SBTML_REJ | SBTML_RESET));
-       udelay(1);
-}
-
-/* reset and re-enable a core
- * inputs:
- * bits - core specific bits that are set during and after reset sequence
- * resetbits - core specific bits that are set only during reset sequence
- */
-void sb_core_reset(si_t *sih, u32 bits, u32 resetbits)
-{
-       si_info_t *sii;
-       sbconfig_t *sb;
-       volatile u32 dummy;
-
-       sii = SI_INFO(sih);
-       ASSERT(GOODREGS(sii->curmap));
-       sb = REGS2SB(sii->curmap);
-
-       /*
-        * Must do the disable sequence first to work for
-        * arbitrary current core state.
-        */
-       sb_core_disable(sih, (bits | resetbits));
-
-       /*
-        * Now do the initialization sequence.
-        */
-
-       /* set reset while enabling the clock and
-                forcing them on throughout the core */
-       W_SBREG(sii, &sb->sbtmstatelow,
-               (((bits | resetbits | SICF_FGC | SICF_CLOCK_EN) <<
-                 SBTML_SICF_SHIFT) | SBTML_RESET));
-       dummy = R_SBREG(sii, &sb->sbtmstatelow);
-       udelay(1);
-
-       if (R_SBREG(sii, &sb->sbtmstatehigh) & SBTMH_SERR)
-               W_SBREG(sii, &sb->sbtmstatehigh, 0);
-
-       dummy = R_SBREG(sii, &sb->sbimstate);
-       if (dummy & (SBIM_IBE | SBIM_TO))
-               AND_SBREG(sii, &sb->sbimstate, ~(SBIM_IBE | SBIM_TO));
-
-       /* clear reset and allow it to propagate throughout the core */
-       W_SBREG(sii, &sb->sbtmstatelow,
-               ((bits | resetbits | SICF_FGC | SICF_CLOCK_EN) <<
-                SBTML_SICF_SHIFT));
-       dummy = R_SBREG(sii, &sb->sbtmstatelow);
-       udelay(1);
-
-       /* leave clock enabled */
-       W_SBREG(sii, &sb->sbtmstatelow,
-               ((bits | SICF_CLOCK_EN) << SBTML_SICF_SHIFT));
-       dummy = R_SBREG(sii, &sb->sbtmstatelow);
-       udelay(1);
-}
index 0c890a969bb14370218d35b4233be5cfbdca4c21..c13b00274923bf55ea09a4c52fe63a1a7e30f09d 100644 (file)
@@ -35,22 +35,8 @@ You should also find the complete GPL in the COPYING file accompanying this sour
   | Project manager: Eric Stolz   | Date     :  02/12/2002                |
   +-----------------------------------------------------------------------+
   | Description :   APCI-1710 SSI counter module                          |
-  |                                                                       |
-  |                                                                       |
   +-----------------------------------------------------------------------+
-  |                             UPDATES                                   |
-  +-----------------------------------------------------------------------+
-  |   Date   |   Author  |          Description of updates                |
-  +----------+-----------+------------------------------------------------+
-  | 13/05/98 | S. Weber  | SSI digital input / output implementation      |
-  |----------|-----------|------------------------------------------------|
-  | 22/03/00 | C.Guinot  | 0100/0226 -> 0200/0227                         |
-  |          |           | Änderung in InitSSI Funktion                   |
-  |          |           | b_SSIProfile >= 2 anstatt b_SSIProfile > 2     |
-  |          |           |                                                |
-  +-----------------------------------------------------------------------+
-  | 08/05/00 | Guinot C  | - 0400/0228 All Function in RING 0             |
-  |          |           |   available                                    |
+  | several changes done by S. Weber in 1998 and C. Guinot in 2000        |
   +-----------------------------------------------------------------------+
 */
 
index 76f2483871a780b6b60140020d686d09218d1980..6cf19ed683a8883f8d19b3bac1ccf0c805832063 100644 (file)
@@ -77,7 +77,7 @@ You should also find the complete GPL in the COPYING file accompanying this sour
 /* Update-0.7.57->0.7.68MODULE_LICENSE("GPL"); */
 
 #define devpriv ((struct addi_private *)dev->private)
-#define this_board ((struct addi_board *)dev->board_ptr)
+#define this_board ((const struct addi_board *)dev->board_ptr)
 
 #if defined(CONFIG_APCI_1710) || defined(CONFIG_APCI_3200) || defined(CONFIG_APCI_3300)
 /* BYTE b_SaveFPUReg [94]; */
@@ -2666,13 +2666,11 @@ static int i_ADDI_Attach(struct comedi_device *dev, struct comedi_devconfig *it)
                devpriv->i_IobaseAmcc = (int) iobase_a; /* AMCC base address... */
                devpriv->i_IobaseAddon = (int) iobase_addon;    /* ADD ON base address.... */
                devpriv->i_IobaseReserved = (int) iobase_reserved;
-               devpriv->ps_BoardInfo = this_board;
        } else {
                dev->board_name = this_board->pc_DriverName;
                dev->iobase = (unsigned long)io_addr[2];
                devpriv->amcc = card;
                devpriv->iobase = (int) io_addr[2];
-               devpriv->ps_BoardInfo = this_board;
                devpriv->i_IobaseReserved = (int) io_addr[3];
                printk("\nioremap begin");
                devpriv->dw_AiBase = ioremap(io_addr[3],
@@ -2680,6 +2678,21 @@ static int i_ADDI_Attach(struct comedi_device *dev, struct comedi_devconfig *it)
                printk("\nioremap end");
        }
 
+       /* Initialize parameters that can be overridden in EEPROM */
+       devpriv->s_EeParameters.i_NbrAiChannel = this_board->i_NbrAiChannel;
+       devpriv->s_EeParameters.i_NbrAoChannel = this_board->i_NbrAoChannel;
+       devpriv->s_EeParameters.i_AiMaxdata = this_board->i_AiMaxdata;
+       devpriv->s_EeParameters.i_AoMaxdata = this_board->i_AoMaxdata;
+       devpriv->s_EeParameters.i_NbrDiChannel = this_board->i_NbrDiChannel;
+       devpriv->s_EeParameters.i_NbrDoChannel = this_board->i_NbrDoChannel;
+       devpriv->s_EeParameters.i_DoMaxdata = this_board->i_DoMaxdata;
+       devpriv->s_EeParameters.i_Dma = this_board->i_Dma;
+       devpriv->s_EeParameters.i_Timer = this_board->i_Timer;
+       devpriv->s_EeParameters.ui_MinAcquisitiontimeNs =
+               this_board->ui_MinAcquisitiontimeNs;
+       devpriv->s_EeParameters.ui_MinDelaytimeNs =
+               this_board->ui_MinDelaytimeNs;
+
        /* ## */
 
        if (irq > 0) {
@@ -2728,7 +2741,7 @@ static int i_ADDI_Attach(struct comedi_device *dev, struct comedi_devconfig *it)
                devpriv->us_UseDma = ADDI_ENABLE;
        }
 
-       if (this_board->i_Dma) {
+       if (devpriv->s_EeParameters.i_Dma) {
                printk("\nDMA used");
                if (devpriv->us_UseDma == ADDI_ENABLE) {
                        /*  alloc DMA buffers */
@@ -2787,21 +2800,22 @@ static int i_ADDI_Attach(struct comedi_device *dev, struct comedi_devconfig *it)
 
                /*  Allocate and Initialise AI Subdevice Structures */
                s = dev->subdevices + 0;
-               if ((this_board->i_NbrAiChannel)
+               if ((devpriv->s_EeParameters.i_NbrAiChannel)
                        || (this_board->i_NbrAiChannelDiff)) {
                        dev->read_subdev = s;
                        s->type = COMEDI_SUBD_AI;
                        s->subdev_flags =
                                SDF_READABLE | SDF_COMMON | SDF_GROUND
                                | SDF_DIFF;
-                       if (this_board->i_NbrAiChannel) {
-                               s->n_chan = this_board->i_NbrAiChannel;
+                       if (devpriv->s_EeParameters.i_NbrAiChannel) {
+                               s->n_chan =
+                                       devpriv->s_EeParameters.i_NbrAiChannel;
                                devpriv->b_SingelDiff = 0;
                        } else {
                                s->n_chan = this_board->i_NbrAiChannelDiff;
                                devpriv->b_SingelDiff = 1;
                        }
-                       s->maxdata = this_board->i_AiMaxdata;
+                       s->maxdata = devpriv->s_EeParameters.i_AiMaxdata;
                        s->len_chanlist = this_board->i_AiChannelList;
                        s->range_table = this_board->pr_AiRangelist;
 
@@ -2825,12 +2839,13 @@ static int i_ADDI_Attach(struct comedi_device *dev, struct comedi_devconfig *it)
 
                /*  Allocate and Initialise AO Subdevice Structures */
                s = dev->subdevices + 1;
-               if (this_board->i_NbrAoChannel) {
+               if (devpriv->s_EeParameters.i_NbrAoChannel) {
                        s->type = COMEDI_SUBD_AO;
                        s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON;
-                       s->n_chan = this_board->i_NbrAoChannel;
-                       s->maxdata = this_board->i_AoMaxdata;
-                       s->len_chanlist = this_board->i_NbrAoChannel;
+                       s->n_chan = devpriv->s_EeParameters.i_NbrAoChannel;
+                       s->maxdata = devpriv->s_EeParameters.i_AoMaxdata;
+                       s->len_chanlist =
+                               devpriv->s_EeParameters.i_NbrAoChannel;
                        s->range_table = this_board->pr_AoRangelist;
                        s->insn_config =
                                this_board->i_hwdrv_InsnConfigAnalogOutput;
@@ -2841,12 +2856,13 @@ static int i_ADDI_Attach(struct comedi_device *dev, struct comedi_devconfig *it)
                }
                /*  Allocate and Initialise DI Subdevice Structures */
                s = dev->subdevices + 2;
-               if (this_board->i_NbrDiChannel) {
+               if (devpriv->s_EeParameters.i_NbrDiChannel) {
                        s->type = COMEDI_SUBD_DI;
                        s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_COMMON;
-                       s->n_chan = this_board->i_NbrDiChannel;
+                       s->n_chan = devpriv->s_EeParameters.i_NbrDiChannel;
                        s->maxdata = 1;
-                       s->len_chanlist = this_board->i_NbrDiChannel;
+                       s->len_chanlist =
+                               devpriv->s_EeParameters.i_NbrDiChannel;
                        s->range_table = &range_digital;
                        s->io_bits = 0; /* all bits input */
                        s->insn_config =
@@ -2860,13 +2876,14 @@ static int i_ADDI_Attach(struct comedi_device *dev, struct comedi_devconfig *it)
                }
                /*  Allocate and Initialise DO Subdevice Structures */
                s = dev->subdevices + 3;
-               if (this_board->i_NbrDoChannel) {
+               if (devpriv->s_EeParameters.i_NbrDoChannel) {
                        s->type = COMEDI_SUBD_DO;
                        s->subdev_flags =
                                SDF_READABLE | SDF_WRITEABLE | SDF_GROUND | SDF_COMMON;
-                       s->n_chan = this_board->i_NbrDoChannel;
-                       s->maxdata = this_board->i_DoMaxdata;
-                       s->len_chanlist = this_board->i_NbrDoChannel;
+                       s->n_chan = devpriv->s_EeParameters.i_NbrDoChannel;
+                       s->maxdata = devpriv->s_EeParameters.i_DoMaxdata;
+                       s->len_chanlist =
+                               devpriv->s_EeParameters.i_NbrDoChannel;
                        s->range_table = &range_digital;
                        s->io_bits = 0xf;       /* all bits output */
 
@@ -2883,7 +2900,7 @@ static int i_ADDI_Attach(struct comedi_device *dev, struct comedi_devconfig *it)
 
                /*  Allocate and Initialise Timer Subdevice Structures */
                s = dev->subdevices + 4;
-               if (this_board->i_Timer) {
+               if (devpriv->s_EeParameters.i_Timer) {
                        s->type = COMEDI_SUBD_TIMER;
                        s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON;
                        s->n_chan = 1;
@@ -2968,8 +2985,8 @@ static int i_ADDI_Detach(struct comedi_device *dev)
                        free_irq(dev->irq, dev);
                }
 
-               if ((devpriv->ps_BoardInfo->pc_EepromChip == NULL)
-                       || (strcmp(devpriv->ps_BoardInfo->pc_EepromChip,
+               if ((this_board->pc_EepromChip == NULL)
+                       || (strcmp(this_board->pc_EepromChip,
                                        ADDIDATA_9054) != 0)) {
                        if (devpriv->allocated) {
                                i_pci_card_free(devpriv->amcc);
index 13621d47037b85e6adcf61f5d89d806e1b8ace93..c6980b7dfea01fd327e72bb625e65bd5be2a2682 100644 (file)
@@ -406,7 +406,6 @@ struct addi_private {
 
        /* Pointer to the current process */
        struct task_struct *tsk_Current;
-       struct addi_board *ps_BoardInfo;
 
        /* Hardware board infos for 1710 */
        struct {
@@ -434,6 +433,22 @@ struct addi_private {
        union str_ModuleInfo s_ModuleInfo[4];
        unsigned int ul_TTLPortConfiguration[10];
 
+       /* Parameters read from EEPROM overriding static board info */
+       struct {
+               int i_NbrAiChannel;     /*  num of A/D chans */
+               int i_NbrAoChannel;     /*  num of D/A chans */
+               int i_AiMaxdata;        /*  resolution of A/D */
+               int i_AoMaxdata;        /*  resolution of D/A */
+               int i_NbrDiChannel;     /*  Number of DI channels */
+               int i_NbrDoChannel;     /*  Number of DO channels */
+               int i_DoMaxdata;        /*  data to set all channels high */
+               int i_Dma;              /*  dma present or not */
+               int i_Timer;            /*  timer subdevice present or not */
+               unsigned int ui_MinAcquisitiontimeNs;
+                                       /*  Minimum Acquisition in Nano secs */
+               unsigned int ui_MinDelaytimeNs;
+                                       /*  Minimum Delay in Nano secs */
+       } s_EeParameters;
 };
 
 static unsigned short pci_list_builded;        /* set to 1 when list of card is known */
index 0aa11a0a6e91c05e59220f5546ab5925e4a1feb9..3a9339b926101fc83f4fffaf6bf15438c3327594 100644 (file)
@@ -847,7 +847,7 @@ int i_EepromReadMainHeader(unsigned short w_PCIBoardEepromAddress,
                                pc_PCIChipInformation,
                                s_MainHeader.s_Functions[i].w_Address,
                                &s_DigitalInputHeader);
-                       this_board->i_NbrDiChannel =
+                       devpriv->s_EeParameters.i_NbrDiChannel =
                                s_DigitalInputHeader.w_Nchannel;
                        break;
 
@@ -856,11 +856,12 @@ int i_EepromReadMainHeader(unsigned short w_PCIBoardEepromAddress,
                                pc_PCIChipInformation,
                                s_MainHeader.s_Functions[i].w_Address,
                                &s_DigitalOutputHeader);
-                       this_board->i_NbrDoChannel =
+                       devpriv->s_EeParameters.i_NbrDoChannel =
                                s_DigitalOutputHeader.w_Nchannel;
                        ui_Temp = 0xffffffff;
-                       this_board->i_DoMaxdata =
-                               ui_Temp >> (32 - this_board->i_NbrDoChannel);
+                       devpriv->s_EeParameters.i_DoMaxdata =
+                               ui_Temp >> (32 -
+                                       devpriv->s_EeParameters.i_NbrDoChannel);
                        break;
 
                case EEPROM_ANALOGINPUT:
@@ -869,20 +870,21 @@ int i_EepromReadMainHeader(unsigned short w_PCIBoardEepromAddress,
                                s_MainHeader.s_Functions[i].w_Address,
                                &s_AnalogInputHeader);
                        if (!(strcmp(this_board->pc_DriverName, "apci3200")))
-                               this_board->i_NbrAiChannel =
+                               devpriv->s_EeParameters.i_NbrAiChannel =
                                        s_AnalogInputHeader.w_Nchannel * 4;
                        else
-                               this_board->i_NbrAiChannel =
+                               devpriv->s_EeParameters.i_NbrAiChannel =
                                        s_AnalogInputHeader.w_Nchannel;
-                       this_board->i_Dma = s_AnalogInputHeader.b_HasDma;
-                       this_board->ui_MinAcquisitiontimeNs =
+                       devpriv->s_EeParameters.i_Dma =
+                               s_AnalogInputHeader.b_HasDma;
+                       devpriv->s_EeParameters.ui_MinAcquisitiontimeNs =
                                (unsigned int) s_AnalogInputHeader.w_MinConvertTiming *
                                1000;
-                       this_board->ui_MinDelaytimeNs =
+                       devpriv->s_EeParameters.ui_MinDelaytimeNs =
                                (unsigned int) s_AnalogInputHeader.w_MinDelayTiming *
                                1000;
                        ui_Temp = 0xffff;
-                       this_board->i_AiMaxdata =
+                       devpriv->s_EeParameters.i_AiMaxdata =
                                ui_Temp >> (16 -
                                s_AnalogInputHeader.b_Resolution);
                        break;
@@ -892,24 +894,28 @@ int i_EepromReadMainHeader(unsigned short w_PCIBoardEepromAddress,
                                pc_PCIChipInformation,
                                s_MainHeader.s_Functions[i].w_Address,
                                &s_AnalogOutputHeader);
-                       this_board->i_NbrAoChannel =
+                       devpriv->s_EeParameters.i_NbrAoChannel =
                                s_AnalogOutputHeader.w_Nchannel;
                        ui_Temp = 0xffff;
-                       this_board->i_AoMaxdata =
+                       devpriv->s_EeParameters.i_AoMaxdata =
                                ui_Temp >> (16 -
                                s_AnalogOutputHeader.b_Resolution);
                        break;
 
                case EEPROM_TIMER:
-                       this_board->i_Timer = 1;        /* Timer subdevice present */
+                       /* Timer subdevice present */
+                       devpriv->s_EeParameters.i_Timer = 1;
                        break;
 
                case EEPROM_WATCHDOG:
-                       this_board->i_Timer = 1;        /* Timer subdevice present */
+                       /* Timer subdevice present */
+                       devpriv->s_EeParameters.i_Timer = 1;
                        break;
 
                case EEPROM_TIMER_WATCHDOG_COUNTER:
-                       this_board->i_Timer = 1;        /* Timer subdevice present */
+                       /* Timer subdevice present */
+                       devpriv->s_EeParameters.i_Timer = 1;
+                       break;
                }
        }
 
index 8ebb2544df480e139ef186bbe4eef3adda0e145d..00a088f820a737ec7c58972b67676bb15a744d38 100644 (file)
@@ -97,7 +97,7 @@ int i_APCI16XX_InsnConfigInitTTLIO(struct comedi_device *dev,
        unsigned char b_Command = 0;
        unsigned char b_Cpt = 0;
        unsigned char b_NumberOfPort =
-               (unsigned char) (devpriv->ps_BoardInfo->i_NbrTTLChannel / 8);
+               (unsigned char) (this_board->i_NbrTTLChannel / 8);
 
        /************************/
        /* Test the buffer size */
@@ -289,7 +289,7 @@ int i_APCI16XX_InsnBitsReadTTLIO(struct comedi_device *dev,
        int i_ReturnValue = insn->n;
        unsigned char b_Command = 0;
        unsigned char b_NumberOfPort =
-               (unsigned char) (devpriv->ps_BoardInfo->i_NbrTTLChannel / 8);
+               (unsigned char) (this_board->i_NbrTTLChannel / 8);
        unsigned char b_SelectedPort = CR_RANGE(insn->chanspec);
        unsigned char b_InputChannel = CR_CHAN(insn->chanspec);
        unsigned char *pb_Status;
@@ -450,9 +450,9 @@ int i_APCI16XX_InsnReadTTLIOAllPortValue(struct comedi_device *dev,
           /**********************************/
 
                b_NumberOfPort =
-                       (unsigned char) (devpriv->ps_BoardInfo->i_NbrTTLChannel / 32);
+                       (unsigned char) (this_board->i_NbrTTLChannel / 32);
                if ((b_NumberOfPort * 32) <
-                       devpriv->ps_BoardInfo->i_NbrTTLChannel) {
+                       this_board->i_NbrTTLChannel) {
                        b_NumberOfPort = b_NumberOfPort + 1;
                }
 
@@ -576,7 +576,7 @@ int i_APCI16XX_InsnBitsWriteTTLIO(struct comedi_device *dev,
        int i_ReturnValue = insn->n;
        unsigned char b_Command = 0;
        unsigned char b_NumberOfPort =
-               (unsigned char) (devpriv->ps_BoardInfo->i_NbrTTLChannel / 8);
+               (unsigned char) (this_board->i_NbrTTLChannel / 8);
        unsigned char b_SelectedPort = CR_RANGE(insn->chanspec);
        unsigned char b_OutputChannel = CR_CHAN(insn->chanspec);
        unsigned int dw_Status = 0;
index fc61214151b700a4feed81088e438d387a6fa14b..e886ced4978f84a0ed2d1f10983388a64a41fe3d 100644 (file)
@@ -90,7 +90,8 @@ int i_APCI3120_InsnConfigAnalogInput(struct comedi_device *dev, struct comedi_su
                /* Test the number of the channel */
                for (i = 0; i < data[3]; i++) {
 
-                       if (CR_CHAN(data[4 + i]) >= this_board->i_NbrAiChannel) {
+                       if (CR_CHAN(data[4 + i]) >=
+                               devpriv->s_EeParameters.i_NbrAiChannel) {
                                printk("bad channel list\n");
                                return -2;
                        }
@@ -541,8 +542,10 @@ int i_APCI3120_CommandTestAnalogInput(struct comedi_device *dev, struct comedi_s
        }
 
        if (cmd->scan_begin_src == TRIG_TIMER) {        /*  Test Delay timing */
-               if (cmd->scan_begin_arg < this_board->ui_MinDelaytimeNs) {
-                       cmd->scan_begin_arg = this_board->ui_MinDelaytimeNs;
+               if (cmd->scan_begin_arg <
+                               devpriv->s_EeParameters.ui_MinDelaytimeNs) {
+                       cmd->scan_begin_arg =
+                               devpriv->s_EeParameters.ui_MinDelaytimeNs;
                        err++;
                }
        }
@@ -551,16 +554,18 @@ int i_APCI3120_CommandTestAnalogInput(struct comedi_device *dev, struct comedi_s
                if (cmd->scan_begin_src == TRIG_TIMER) {
                        if ((cmd->convert_arg)
                                && (cmd->convert_arg <
-                                       this_board->ui_MinAcquisitiontimeNs)) {
-                               cmd->convert_arg =
-                                       this_board->ui_MinAcquisitiontimeNs;
+                                       devpriv->s_EeParameters.
+                                               ui_MinAcquisitiontimeNs)) {
+                               cmd->convert_arg = devpriv->s_EeParameters.
+                                       ui_MinAcquisitiontimeNs;
                                err++;
                        }
                } else {
                        if (cmd->convert_arg <
-                               this_board->ui_MinAcquisitiontimeNs) {
-                               cmd->convert_arg =
-                                       this_board->ui_MinAcquisitiontimeNs;
+                               devpriv->s_EeParameters.ui_MinAcquisitiontimeNs
+                               ) {
+                               cmd->convert_arg = devpriv->s_EeParameters.
+                                       ui_MinAcquisitiontimeNs;
                                err++;
 
                        }
@@ -2452,7 +2457,7 @@ int i_APCI3120_InsnBitsDigitalOutput(struct comedi_device *dev,
                                     struct comedi_insn *insn,
                                     unsigned int *data)
 {
-       if ((data[0] > this_board->i_DoMaxdata) || (data[0] < 0)) {
+       if ((data[0] > devpriv->s_EeParameters.i_DoMaxdata) || (data[0] < 0)) {
 
                comedi_error(dev, "Data is not valid !!! \n");
                return -EINVAL;
@@ -2515,7 +2520,7 @@ int i_APCI3120_InsnWriteDigitalOutput(struct comedi_device *dev,
                        "Not a valid Data !!! ,Data should be 1 or 0\n");
                return -EINVAL;
        }
-       if (ui_NoOfChannel > this_board->i_NbrDoChannel - 1) {
+       if (ui_NoOfChannel > devpriv->s_EeParameters.i_NbrDoChannel - 1) {
                comedi_error(dev,
                        "This board doesn't have specified channel !!! \n");
                return -EINVAL;
index d3c5963a79e7dbac86fd65cbb8db977bbaa7207c..fff99df51e927f7519cd68909351901fcb2dc533 100644 (file)
@@ -141,8 +141,7 @@ static int i_APCI3XXX_AnalogInputConfigOperatingMode(struct comedi_device *dev,
                /* Test the time base */
           /**********************/
 
-               if ((devpriv->ps_BoardInfo->
-                               b_AvailableConvertUnit & (1 << b_TimeBase)) !=
+               if ((this_board->b_AvailableConvertUnit & (1 << b_TimeBase)) !=
                        0) {
              /*******************************/
                        /* Test the convert time value */
@@ -165,12 +164,16 @@ static int i_APCI3XXX_AnalogInputConfigOperatingMode(struct comedi_device *dev,
                 /*******************************/
 
                                if (dw_TestReloadValue >=
-                                       devpriv->ps_BoardInfo->
+                                       devpriv->s_EeParameters.
                                        ui_MinAcquisitiontimeNs) {
                                        if ((b_SingleDiff == APCI3XXX_SINGLE)
                                                || (b_SingleDiff ==
                                                        APCI3XXX_DIFF)) {
-                                               if (((b_SingleDiff == APCI3XXX_SINGLE) && (devpriv->ps_BoardInfo->i_NbrAiChannel == 0)) || ((b_SingleDiff == APCI3XXX_DIFF) && (devpriv->ps_BoardInfo->i_NbrAiChannelDiff == 0))) {
+                                               if (((b_SingleDiff == APCI3XXX_SINGLE)
+                                                       && (devpriv->s_EeParameters.i_NbrAiChannel == 0))
+                                                   || ((b_SingleDiff == APCI3XXX_DIFF)
+                                                       && (this_board->i_NbrAiChannelDiff == 0))
+                                                   ) {
                           /*******************************/
                                                        /* Single/Diff selection error */
                           /*******************************/
@@ -372,10 +375,9 @@ static int i_APCI3XXX_InsnReadAnalogInput(struct comedi_device *dev,
                /* Test the channel number */
           /***************************/
 
-               if (((b_Channel < devpriv->ps_BoardInfo->i_NbrAiChannel)
+               if (((b_Channel < devpriv->s_EeParameters.i_NbrAiChannel)
                                && (devpriv->b_SingelDiff == APCI3XXX_SINGLE))
-                       || ((b_Channel < devpriv->ps_BoardInfo->
-                                       i_NbrAiChannelDiff)
+                       || ((b_Channel < this_board->i_NbrAiChannelDiff)
                                && (devpriv->b_SingelDiff == APCI3XXX_DIFF))) {
              /**********************************/
                        /* Test the channel configuration */
@@ -663,7 +665,7 @@ static int i_APCI3XXX_InsnWriteAnalogOutput(struct comedi_device *dev,
                /* Test the channel number */
           /***************************/
 
-               if (b_Channel < devpriv->ps_BoardInfo->i_NbrAoChannel) {
+               if (b_Channel < devpriv->s_EeParameters.i_NbrAoChannel) {
              /**********************************/
                        /* Test the channel configuration */
              /**********************************/
@@ -1273,7 +1275,7 @@ static int i_APCI3XXX_InsnReadDigitalInput(struct comedi_device *dev,
        /* Test the channel number */
        /***************************/
 
-       if (b_Channel <= devpriv->ps_BoardInfo->i_NbrDiChannel) {
+       if (b_Channel <= devpriv->s_EeParameters.i_NbrDiChannel) {
           /************************/
                /* Test the buffer size */
           /************************/
@@ -1492,7 +1494,7 @@ static int i_APCI3XXX_InsnWriteDigitalOutput(struct comedi_device *dev,
                /* Test the channel number */
           /***************************/
 
-               if (b_Channel < devpriv->ps_BoardInfo->i_NbrDoChannel) {
+               if (b_Channel < devpriv->s_EeParameters.i_NbrDoChannel) {
              /*******************/
                        /* Get the command */
              /*******************/
@@ -1568,7 +1570,7 @@ static int i_APCI3XXX_InsnReadDigitalOutput(struct comedi_device *dev,
                /* Test the channel number */
           /***************************/
 
-               if (b_Channel < devpriv->ps_BoardInfo->i_NbrDoChannel) {
+               if (b_Channel < devpriv->s_EeParameters.i_NbrDoChannel) {
              /********************************/
                        /* Read the digital output port */
              /********************************/
index 632d5d0721cd495a458c3a80f611af427491799b..08b71d9974b686dbc102bd05f111cda9a8e54cb0 100644 (file)
@@ -1417,7 +1417,7 @@ static int pci9118_ai_docmd_sampl(struct comedi_device *dev,
                comedi_error(dev,
                             "pci9118_ai_docmd_sampl() mode number bug!\n");
                return -EIO;
-       };
+       }
 
        devpriv->int_ai_func = interrupt_pci9118_ai_onesample;
                                                /* transfer function */
@@ -1496,7 +1496,7 @@ static int pci9118_ai_docmd_dma(struct comedi_device *dev,
        default:
                comedi_error(dev, "pci9118_ai_docmd_dma() mode number bug!\n");
                return -EIO;
-       };
+       }
 
        if (devpriv->ai12_startstop) {
                pci9118_exttrg_add(dev, EXTTRG_AI);
index 9102667ab40e250d321e1407d459c056395e3675..d23799be7ce25d49d0b6d8c11748da3d01121156 100644 (file)
@@ -117,6 +117,7 @@ enum hw_io_access {
 
 /*  Advantech PCI-1751/3/3E */
 #define PCI1751_DIO       0    /* R/W: begin of 8255 registers block */
+#define PCI1751_CNT      24    /* R/W: begin of 8254 registers block */
 #define PCI1751_ICR      32    /* W:   Interrupt control register */
 #define PCI1751_ISR      32    /* R:   Interrupt status register */
 #define PCI1753_DIO       0    /* R/W: begin of 8255 registers block */
@@ -329,7 +330,7 @@ static const struct dio_boardtype boardtypes[] = {
         { {0, 0, 0, 0}, {0, 0, 0, 0} },
         { {48, PCI1751_DIO, 2, 0}, {0, 0, 0, 0} },
         {0, 0, 0, 0},
-        { {0, 0, 0, 0} },
+        { {3, PCI1751_CNT, 1, 0} },
         IO_8b},
        {"pci1752", PCI_VENDOR_ID_ADVANTECH, 0x1752, PCIDIO_MAINREG,
         TYPE_PCI1752,
index 6383fc93b83dc45f46c54f41784e518ec1ef770e..49102b3a6c4adfd8ff384532f3c992a557da8186 100644 (file)
@@ -650,7 +650,7 @@ static int cb_pcidda_ao_winsn(struct comedi_device *dev,
        case 5:
                command |= UNIP | RANGE2V5;
                break;
-       };
+       }
 
        /* output channel specification */
        command |= channel << 2;
index 3d53df000cf11ee4f77601b8b0695dc28dd4afcf..b1b832b65bc101f7b7c0f45a9590faf44978160d 100644 (file)
@@ -264,7 +264,7 @@ found:
        default:
                printk("THIS CARD IS UNSUPPORTED.\n"
                       "PLEASE REPORT USAGE TO <mocelet@sucs.org>\n");
-       };
+       }
 
        if (comedi_pci_enable(pcidev, "cb_pcimdas")) {
                printk(" Failed to enable PCI device and request regions\n");
index 5c6c7274416724930f8758b5a0cab6c42442b975..8d98cf412709da6524aeddc36bad5e8ee7046a9d 100644 (file)
@@ -193,9 +193,8 @@ static void set_transforms(volatile struct jr3_channel *channel,
                set_s16(&channel->transforms[num].link[i].link_amount,
                        transf.link[i].link_amount);
                udelay(1);
-               if (transf.link[i].link_type == end_x_form) {
+               if (transf.link[i].link_type == end_x_form)
                        break;
-               }
        }
 }
 
@@ -460,9 +459,8 @@ static int jr3_download_firmware(struct comedi_device *dev, const u8 * data,
                                unsigned int count, addr;
                                more = more
                                    && read_idm_word(data, size, &pos, &count);
-                               if (more && count == 0xffff) {
+                               if (more && count == 0xffff)
                                        break;
-                               }
                                more = more
                                    && read_idm_word(data, size, &pos, &addr);
                                printk("Loading#%d %4.4x bytes at %4.4x\n", i,
@@ -793,9 +791,8 @@ static int jr3_pci_attach(struct comedi_device *dev,
        }
 
        result = alloc_private(dev, sizeof(struct jr3_pci_dev_private));
-       if (result < 0) {
+       if (result < 0)
                return -ENOMEM;
-       }
        card = NULL;
        devpriv = dev->private;
        init_timer(&devpriv->timer);
@@ -851,9 +848,8 @@ static int jr3_pci_attach(struct comedi_device *dev,
        }
 
        result = comedi_pci_enable(card, "jr3_pci");
-       if (result < 0) {
+       if (result < 0)
                return -EIO;
-       }
 
        devpriv->pci_enabled = 1;
        devpriv->iobase = ioremap(pci_resource_start(card, 0),
@@ -922,9 +918,8 @@ static int jr3_pci_attach(struct comedi_device *dev,
        result = comedi_load_firmware(dev, "jr3pci.idm", jr3_download_firmware);
        printk("Firmare load %d\n", result);
 
-       if (result < 0) {
+       if (result < 0)
                goto out;
-       }
 /*
  * TODO: use firmware to load preferred offset tables. Suggested
  * format:
@@ -973,21 +968,17 @@ static int jr3_pci_detach(struct comedi_device *dev)
                del_timer_sync(&devpriv->timer);
 
                if (dev->subdevices) {
-                       for (i = 0; i < devpriv->n_channels; i++) {
+                       for (i = 0; i < devpriv->n_channels; i++)
                                kfree(dev->subdevices[i].private);
-                       }
                }
 
-               if (devpriv->iobase) {
+               if (devpriv->iobase)
                        iounmap((void *)devpriv->iobase);
-               }
-               if (devpriv->pci_enabled) {
+               if (devpriv->pci_enabled)
                        comedi_pci_disable(devpriv->pci_dev);
-               }
 
-               if (devpriv->pci_dev) {
+               if (devpriv->pci_dev)
                        pci_dev_put(devpriv->pci_dev);
-               }
        }
        return 0;
 }
index ca2aeaa9449cfaac27348a9442a02031b2bb2242..35f3a47498256d85a407c0a4b01534365c66aa93 100644 (file)
@@ -1418,7 +1418,7 @@ static int ni_660x_dio_insn_config(struct comedi_device *dev,
        default:
                return -EINVAL;
                break;
-       };
+       }
        return 0;
 }
 
index 986ef671298965fecf04f42303002524cddb1a83..fd232bc5f87349f2f0238f31c4f3fe982a563ba7 100644 (file)
@@ -1627,7 +1627,7 @@ static int ni_ai_setup_MITE_dma(struct comedi_device *dev)
        default:
                mite_prep_dma(devpriv->ai_mite_chan, 16, 16);
                break;
-       };
+       }
        /*start the MITE */
        mite_dma_arm(devpriv->ai_mite_chan);
        spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
@@ -2156,7 +2156,7 @@ static unsigned ni_min_ai_scan_period_ns(struct comedi_device *dev,
        default:
                /*  multiplexed inputs */
                break;
-       };
+       }
        return boardtype.ai_speed * num_channels;
 }
 
@@ -5173,7 +5173,7 @@ static void GPCT_Reset(struct comedi_device *dev, int chan)
                devpriv->stc_writew(dev, devpriv->an_trig_etc_reg,
                                    Analog_Trigger_Etc_Register);
                break;
-       };
+       }
 
        devpriv->gpct_mode[chan] = 0;
        devpriv->gpct_input_select[chan] = 0;
index a9bb6b13dfc46d9deebe35298a7e5dc0a627d873..98f87897e2a823b31085b92cf03adf865015f449 100644 (file)
@@ -1181,7 +1181,7 @@ static int ni_660x_set_second_gate(struct ni_gpct *counter,
                        break;
                return -EINVAL;
                break;
-       };
+       }
        counter_dev->regs[second_gate_reg] |= Gi_Second_Gate_Mode_Bit;
        counter_dev->regs[second_gate_reg] &= ~Gi_Second_Gate_Select_Mask;
        counter_dev->regs[second_gate_reg] |=
@@ -1209,7 +1209,7 @@ static int ni_m_series_set_second_gate(struct ni_gpct *counter,
                ni_m_series_second_gate_select =
                    selected_second_gate & selected_second_gate_mask;
                break;
-       };
+       }
        counter_dev->regs[second_gate_reg] |= Gi_Second_Gate_Mode_Bit;
        counter_dev->regs[second_gate_reg] &= ~Gi_Second_Gate_Select_Mask;
        counter_dev->regs[second_gate_reg] |=
@@ -1674,7 +1674,7 @@ int ni_tio_rinsn(struct ni_gpct *counter, struct comedi_insn *insn,
                    counter_dev->
                    regs[NITIO_Gi_LoadB_Reg(counter->counter_index)];
                break;
-       };
+       }
        return 0;
 }
 EXPORT_SYMBOL_GPL(ni_tio_rinsn);
index 396a058bb67dc242721408498dd2734370e145a6..61b075db66ef425e65b99456c427429b783bdc5e 100644 (file)
@@ -209,7 +209,7 @@ static int pcl724_attach(struct comedi_device *dev, struct comedi_devconfig *it)
                                         subdev_8255_cb,
                                         (unsigned long)(dev->iobase +
                                                         SIZE_8255 * i));
-       };
+       }
 
        return 0;
 }
index e3eea09ae1fb5cb865523a2a2c2058a73d093589..8933e5089bd337e6bd44ecf3bb2e14fba35649b8 100644 (file)
@@ -1662,7 +1662,7 @@ static void rtc_dropped_irq(unsigned long data)
                tmp = (CMOS_READ(RTC_INTR_FLAGS) & 0xF0);       /* restart */
                restore_flags(flags);
                break;
-       };
+       }
 }
 
 /*
index 7fb3c27e5979ce1b42eaf7e1a166aa95ed4b0a48..f5c0bd17684c4d16092af720f75f8883efa96583 100644 (file)
@@ -301,7 +301,7 @@ static int pcm3724_attach(struct comedi_device *dev,
                subdev_8255_init(dev, dev->subdevices + i, subdev_8255_cb,
                                 (unsigned long)(dev->iobase + SIZE_8255 * i));
                ((dev->subdevices) + i)->insn_config = subdev_3724_insn_config;
-       };
+       }
        return 0;
 }
 
index e543e6c2b1bbee6381d8cd9b366fbddffdbaca49..1d09bfa2edf5ca0b17046291b57bff03833f34d3 100644 (file)
@@ -1530,7 +1530,7 @@ static int usbdux_ao_cmdtest(struct comedi_device *dev,
        /* we always output at 1kHz just now all channels at once */
        if (0) {                /* (this_usbduxsub->high_speed) */
                /*
-                * in usb-2.0 only one conversion it tranmitted but with 8kHz/n
+                * in usb-2.0 only one conversion it transmitted but with 8kHz/n
                 */
                cmd->convert_src &= TRIG_TIMER;
        } else {
index 6479c38d027876c98aeff47f561538fa73fd7fb2..3d13ca6e16705053b26fce5a0426ef3e29b4f42b 100644 (file)
@@ -64,6 +64,8 @@ Changelog:
 
 #include "../comedidev.h"
 
+#define BOARDNAME "vmk80xx"
+
 MODULE_AUTHOR("Manuel Gebele <forensixs@gmx.de>");
 MODULE_DESCRIPTION("Velleman USB Board Low-Level Driver");
 MODULE_SUPPORTED_DEVICE("K8055/K8061 aka VM110/VM140");
@@ -305,8 +307,10 @@ exit:
 
 static int vmk80xx_check_data_link(struct vmk80xx_usb *dev)
 {
-       unsigned int tx_pipe, rx_pipe;
-       unsigned char tx[1], rx[2];
+       unsigned int tx_pipe;
+       unsigned int rx_pipe;
+       unsigned char tx[1];
+       unsigned char rx[2];
 
        dbgvm("vmk80xx: %s\n", __func__);
 
@@ -315,9 +319,11 @@ static int vmk80xx_check_data_link(struct vmk80xx_usb *dev)
 
        tx[0] = VMK8061_CMD_RD_PWR_STAT;
 
-       /* Check that IC6 (PIC16F871) is powered and
+       /*
+        * Check that IC6 (PIC16F871) is powered and
         * running and the data link between IC3 and
-        * IC6 is working properly */
+        * IC6 is working properly
+        */
        usb_bulk_msg(dev->udev, tx_pipe, tx, 1, NULL, dev->ep_tx->bInterval);
        usb_bulk_msg(dev->udev, rx_pipe, rx, 2, NULL, HZ * 10);
 
@@ -326,8 +332,10 @@ static int vmk80xx_check_data_link(struct vmk80xx_usb *dev)
 
 static void vmk80xx_read_eeprom(struct vmk80xx_usb *dev, int flag)
 {
-       unsigned int tx_pipe, rx_pipe;
-       unsigned char tx[1], rx[64];
+       unsigned int tx_pipe;
+       unsigned int rx_pipe;
+       unsigned char tx[1];
+       unsigned char rx[64];
        int cnt;
 
        dbgvm("vmk80xx: %s\n", __func__);
@@ -337,8 +345,10 @@ static void vmk80xx_read_eeprom(struct vmk80xx_usb *dev, int flag)
 
        tx[0] = VMK8061_CMD_RD_VERSION;
 
-       /* Read the firmware version info of IC3 and
-        * IC6 from the internal EEPROM of the IC */
+       /*
+        * Read the firmware version info of IC3 and
+        * IC6 from the internal EEPROM of the IC
+        */
        usb_bulk_msg(dev->udev, tx_pipe, tx, 1, NULL, dev->ep_tx->bInterval);
        usb_bulk_msg(dev->udev, rx_pipe, rx, 64, &cnt, HZ * 10);
 
@@ -388,7 +398,8 @@ static int vmk80xx_reset_device(struct vmk80xx_usb *dev)
 static void vmk80xx_build_int_urb(struct urb *urb, int flag)
 {
        struct vmk80xx_usb *dev = urb->context;
-       __u8 rx_addr, tx_addr;
+       __u8 rx_addr;
+       __u8 tx_addr;
        unsigned int pipe;
        unsigned char *buf;
        size_t size;
@@ -418,8 +429,10 @@ static void vmk80xx_build_int_urb(struct urb *urb, int flag)
 
 static void vmk80xx_do_bulk_msg(struct vmk80xx_usb *dev)
 {
-       __u8 tx_addr, rx_addr;
-       unsigned int tx_pipe, rx_pipe;
+       __u8 tx_addr;
+       __u8 rx_addr;
+       unsigned int tx_pipe;
+       unsigned int rx_pipe;
        size_t size;
 
        dbgvm("vmk80xx: %s\n", __func__);
@@ -432,8 +445,10 @@ static void vmk80xx_do_bulk_msg(struct vmk80xx_usb *dev)
        tx_pipe = usb_sndbulkpipe(dev->udev, tx_addr);
        rx_pipe = usb_rcvbulkpipe(dev->udev, rx_addr);
 
-       /* The max packet size attributes of the K8061
-        * input/output endpoints are identical */
+       /*
+        * The max packet size attributes of the K8061
+        * input/output endpoints are identical
+        */
        size = le16_to_cpu(dev->ep_tx->wMaxPacketSize);
 
        usb_bulk_msg(dev->udev, tx_pipe, dev->usb_tx_buf,
@@ -544,34 +559,40 @@ exit:
 #define DIR_IN  1
 #define DIR_OUT 2
 
-#define rudimentary_check(dir)                             \
-do {                                                       \
-       if (!dev)                                          \
-               return -EFAULT;                            \
-       if (!dev->probed)                                  \
-               return -ENODEV;                            \
-       if (!dev->attached)                                \
-               return -ENODEV;                            \
-       if ((dir) & DIR_IN) {                              \
-               if (test_bit(TRANS_IN_BUSY, &dev->flags))  \
-                       return -EBUSY;                     \
-       } else {  /* DIR_OUT */                            \
-               if (test_bit(TRANS_OUT_BUSY, &dev->flags)) \
-                       return -EBUSY;                     \
-       }                                                  \
-} while (0)
+static int rudimentary_check(struct vmk80xx_usb *dev, int dir)
+{
+       if (!dev)
+               return -EFAULT;
+       if (!dev->probed)
+               return -ENODEV;
+       if (!dev->attached)
+               return -ENODEV;
+       if (dir & DIR_IN) {
+               if (test_bit(TRANS_IN_BUSY, &dev->flags))
+                       return -EBUSY;
+       }
+       if (dir & DIR_OUT) {
+               if (test_bit(TRANS_OUT_BUSY, &dev->flags))
+                       return -EBUSY;
+       }
+
+       return 0;
+}
 
 static int vmk80xx_ai_rinsn(struct comedi_device *cdev,
                            struct comedi_subdevice *s,
                            struct comedi_insn *insn, unsigned int *data)
 {
        struct vmk80xx_usb *dev = cdev->private;
-       int chan, reg[2];
+       int chan;
+       int reg[2];
        int n;
 
        dbgvm("vmk80xx: %s\n", __func__);
 
-       rudimentary_check(DIR_IN);
+       n = rudimentary_check(dev, DIR_IN);
+       if (n)
+               return n;
 
        down(&dev->limit_sem);
        chan = CR_CHAN(insn->chanspec);
@@ -615,12 +636,16 @@ static int vmk80xx_ao_winsn(struct comedi_device *cdev,
                            struct comedi_insn *insn, unsigned int *data)
 {
        struct vmk80xx_usb *dev = cdev->private;
-       int chan, cmd, reg;
+       int chan;
+       int cmd;
+       int reg;
        int n;
 
        dbgvm("vmk80xx: %s\n", __func__);
 
-       rudimentary_check(DIR_OUT);
+       n = rudimentary_check(dev, DIR_OUT);
+       if (n)
+               return n;
 
        down(&dev->limit_sem);
        chan = CR_CHAN(insn->chanspec);
@@ -657,12 +682,15 @@ static int vmk80xx_ao_rinsn(struct comedi_device *cdev,
                            struct comedi_insn *insn, unsigned int *data)
 {
        struct vmk80xx_usb *dev = cdev->private;
-       int chan, reg;
+       int chan;
+       int reg;
        int n;
 
        dbgvm("vmk80xx: %s\n", __func__);
 
-       rudimentary_check(DIR_IN);
+       n = rudimentary_check(dev, DIR_IN);
+       if (n)
+               return n;
 
        down(&dev->limit_sem);
        chan = CR_CHAN(insn->chanspec);
@@ -683,6 +711,50 @@ static int vmk80xx_ao_rinsn(struct comedi_device *cdev,
        return n;
 }
 
+static int vmk80xx_di_bits(struct comedi_device *cdev,
+                          struct comedi_subdevice *s,
+                          struct comedi_insn *insn, unsigned int *data)
+{
+       struct vmk80xx_usb *dev = cdev->private;
+       unsigned char *rx_buf;
+       int reg;
+       int retval;
+
+       dbgvm("vmk80xx: %s\n", __func__);
+
+       retval = rudimentary_check(dev, DIR_IN);
+       if (retval)
+               return retval;
+
+       down(&dev->limit_sem);
+
+       rx_buf = dev->usb_rx_buf;
+
+       if (dev->board.model == VMK8061_MODEL) {
+               reg = VMK8061_DI_REG;
+               dev->usb_tx_buf[0] = VMK8061_CMD_RD_DI;
+       } else {
+               reg = VMK8055_DI_REG;
+       }
+
+       retval = vmk80xx_read_packet(dev);
+
+       if (!retval) {
+               if (dev->board.model == VMK8055_MODEL)
+                       data[1] = (((rx_buf[reg] >> 4) & 0x03) |
+                                 ((rx_buf[reg] << 2) & 0x04) |
+                                 ((rx_buf[reg] >> 3) & 0x18));
+               else
+                       data[1] = rx_buf[reg];
+
+               retval = 2;
+       }
+
+       up(&dev->limit_sem);
+
+       return retval;
+}
+
 static int vmk80xx_di_rinsn(struct comedi_device *cdev,
                            struct comedi_subdevice *s,
                            struct comedi_insn *insn, unsigned int *data)
@@ -690,12 +762,15 @@ static int vmk80xx_di_rinsn(struct comedi_device *cdev,
        struct vmk80xx_usb *dev = cdev->private;
        int chan;
        unsigned char *rx_buf;
-       int reg, inp;
+       int reg;
+       int inp;
        int n;
 
        dbgvm("vmk80xx: %s\n", __func__);
 
-       rudimentary_check(DIR_IN);
+       n = rudimentary_check(dev, DIR_IN);
+       if (n)
+               return n;
 
        down(&dev->limit_sem);
        chan = CR_CHAN(insn->chanspec);
@@ -705,9 +780,9 @@ static int vmk80xx_di_rinsn(struct comedi_device *cdev,
        if (dev->board.model == VMK8061_MODEL) {
                reg = VMK8061_DI_REG;
                dev->usb_tx_buf[0] = VMK8061_CMD_RD_DI;
-       } else
+       } else {
                reg = VMK8055_DI_REG;
-
+       }
        for (n = 0; n < insn->n; n++) {
                if (vmk80xx_read_packet(dev))
                        break;
@@ -719,7 +794,7 @@ static int vmk80xx_di_rinsn(struct comedi_device *cdev,
                else
                        inp = rx_buf[reg];
 
-               data[n] = ((inp & (1 << chan)) > 0);
+               data[n] = (inp >> chan) & 1;
        }
 
        up(&dev->limit_sem);
@@ -731,16 +806,18 @@ static int vmk80xx_do_winsn(struct comedi_device *cdev,
                            struct comedi_subdevice *s,
                            struct comedi_insn *insn, unsigned int *data)
 {
-
        struct vmk80xx_usb *dev = cdev->private;
        int chan;
        unsigned char *tx_buf;
-       int reg, cmd;
+       int reg;
+       int cmd;
        int n;
 
        dbgvm("vmk80xx: %s\n", __func__);
 
-       rudimentary_check(DIR_OUT);
+       n = rudimentary_check(dev, DIR_OUT);
+       if (n)
+               return n;
 
        down(&dev->limit_sem);
        chan = CR_CHAN(insn->chanspec);
@@ -755,21 +832,17 @@ static int vmk80xx_do_winsn(struct comedi_device *cdev,
                                tx_buf[reg] |= (1 << chan);
                        else
                                tx_buf[reg] ^= (1 << chan);
-
-                       goto write_packet;
-               }
-
-               /* VMK8061_MODEL */
-               reg = VMK8061_DO_REG;
-               if (data[n] == 1) {
-                       cmd = VMK8061_CMD_SET_DO;
-                       tx_buf[reg] = 1 << chan;
-               } else {
-                       cmd = VMK8061_CMD_CLR_DO;
-                       tx_buf[reg] = 0xff - (1 << chan);
+               } else { /* VMK8061_MODEL */
+                       reg = VMK8061_DO_REG;
+                       if (data[n] == 1) {
+                               cmd = VMK8061_CMD_SET_DO;
+                               tx_buf[reg] = 1 << chan;
+                       } else {
+                               cmd = VMK8061_CMD_CLR_DO;
+                               tx_buf[reg] = 0xff - (1 << chan);
+                       }
                }
 
-write_packet:
                if (vmk80xx_write_packet(dev, cmd))
                        break;
        }
@@ -784,18 +857,20 @@ static int vmk80xx_do_rinsn(struct comedi_device *cdev,
                            struct comedi_insn *insn, unsigned int *data)
 {
        struct vmk80xx_usb *dev = cdev->private;
-       int chan, reg, mask;
+       int chan;
+       int reg;
        int n;
 
        dbgvm("vmk80xx: %s\n", __func__);
 
-       rudimentary_check(DIR_IN);
+       n = rudimentary_check(dev, DIR_IN);
+       if (n)
+               return n;
 
        down(&dev->limit_sem);
        chan = CR_CHAN(insn->chanspec);
 
        reg = VMK8061_DO_REG;
-       mask = 1 << chan;
 
        dev->usb_tx_buf[0] = VMK8061_CMD_RD_DO;
 
@@ -803,7 +878,7 @@ static int vmk80xx_do_rinsn(struct comedi_device *cdev,
                if (vmk80xx_read_packet(dev))
                        break;
 
-               data[n] = (dev->usb_rx_buf[reg] & mask) >> chan;
+               data[n] = (dev->usb_rx_buf[reg] >> chan) & 1;
        }
 
        up(&dev->limit_sem);
@@ -811,17 +886,87 @@ static int vmk80xx_do_rinsn(struct comedi_device *cdev,
        return n;
 }
 
+static int vmk80xx_do_bits(struct comedi_device *cdev,
+                          struct comedi_subdevice *s,
+                          struct comedi_insn *insn, unsigned int *data)
+{
+       struct vmk80xx_usb *dev = cdev->private;
+       unsigned char *rx_buf, *tx_buf;
+       int dir, reg, cmd;
+       int retval;
+
+       dbgvm("vmk80xx: %s\n", __func__);
+
+       dir = 0;
+
+       if (data[0])
+               dir |= DIR_OUT;
+
+       if (dev->board.model == VMK8061_MODEL)
+               dir |= DIR_IN;
+
+       retval = rudimentary_check(dev, dir);
+       if (retval)
+               return retval;
+
+       down(&dev->limit_sem);
+
+       rx_buf = dev->usb_rx_buf;
+       tx_buf = dev->usb_tx_buf;
+
+       if (data[0]) {
+               if (dev->board.model == VMK8055_MODEL) {
+                       reg = VMK8055_DO_REG;
+                       cmd = VMK8055_CMD_WRT_AD;
+               } else { /* VMK8061_MODEL */
+                       reg = VMK8061_DO_REG;
+                       cmd = VMK8061_CMD_DO;
+               }
+
+               tx_buf[reg] &= ~data[0];
+               tx_buf[reg] |= (data[0] & data[1]);
+
+               retval = vmk80xx_write_packet(dev, cmd);
+
+               if (retval)
+                       goto out;
+       }
+
+       if (dev->board.model == VMK8061_MODEL) {
+               reg = VMK8061_DO_REG;
+               tx_buf[0] = VMK8061_CMD_RD_DO;
+
+               retval = vmk80xx_read_packet(dev);
+
+               if (!retval) {
+                       data[1] = rx_buf[reg];
+                       retval = 2;
+               }
+       } else {
+               data[1] = tx_buf[reg];
+               retval = 2;
+       }
+
+out:
+       up(&dev->limit_sem);
+
+       return retval;
+}
+
 static int vmk80xx_cnt_rinsn(struct comedi_device *cdev,
                             struct comedi_subdevice *s,
                             struct comedi_insn *insn, unsigned int *data)
 {
        struct vmk80xx_usb *dev = cdev->private;
-       int chan, reg[2];
+       int chan;
+       int reg[2];
        int n;
 
        dbgvm("vmk80xx: %s\n", __func__);
 
-       rudimentary_check(DIR_IN);
+       n = rudimentary_check(dev, DIR_IN);
+       if (n)
+               return n;
 
        down(&dev->limit_sem);
        chan = CR_CHAN(insn->chanspec);
@@ -844,14 +989,11 @@ static int vmk80xx_cnt_rinsn(struct comedi_device *cdev,
                if (vmk80xx_read_packet(dev))
                        break;
 
-               if (dev->board.model == VMK8055_MODEL) {
+               if (dev->board.model == VMK8055_MODEL)
                        data[n] = dev->usb_rx_buf[reg[0]];
-                       continue;
-               }
-
-               /* VMK8061_MODEL */
-               data[n] = dev->usb_rx_buf[reg[0] * (chan + 1) + 1]
-                   + 256 * dev->usb_rx_buf[reg[1] * 2 + 2];
+               else /* VMK8061_MODEL */
+                       data[n] = dev->usb_rx_buf[reg[0] * (chan + 1) + 1]
+                           + 256 * dev->usb_rx_buf[reg[1] * 2 + 2];
        }
 
        up(&dev->limit_sem);
@@ -865,12 +1007,16 @@ static int vmk80xx_cnt_cinsn(struct comedi_device *cdev,
 {
        struct vmk80xx_usb *dev = cdev->private;
        unsigned int insn_cmd;
-       int chan, cmd, reg;
+       int chan;
+       int cmd;
+       int reg;
        int n;
 
        dbgvm("vmk80xx: %s\n", __func__);
 
-       rudimentary_check(DIR_OUT);
+       n = rudimentary_check(dev, DIR_OUT);
+       if (n)
+               return n;
 
        down(&dev->limit_sem);
 
@@ -890,8 +1036,9 @@ static int vmk80xx_cnt_cinsn(struct comedi_device *cdev,
                }
 
                dev->usb_tx_buf[reg] = 0x00;
-       } else
+       } else {
                cmd = VMK8061_CMD_RST_CNT;
+       }
 
        for (n = 0; n < insn->n; n++)
                if (vmk80xx_write_packet(dev, cmd))
@@ -907,13 +1054,17 @@ static int vmk80xx_cnt_winsn(struct comedi_device *cdev,
                             struct comedi_insn *insn, unsigned int *data)
 {
        struct vmk80xx_usb *dev = cdev->private;
-       unsigned long debtime, val;
-       int chan, cmd;
+       unsigned long debtime;
+       unsigned long val;
+       int chan;
+       int cmd;
        int n;
 
        dbgvm("vmk80xx: %s\n", __func__);
 
-       rudimentary_check(DIR_OUT);
+       n = rudimentary_check(dev, DIR_OUT);
+       if (n)
+               return n;
 
        down(&dev->limit_sem);
        chan = CR_CHAN(insn->chanspec);
@@ -957,7 +1108,9 @@ static int vmk80xx_pwm_rinsn(struct comedi_device *cdev,
 
        dbgvm("vmk80xx: %s\n", __func__);
 
-       rudimentary_check(DIR_IN);
+       n = rudimentary_check(dev, DIR_IN);
+       if (n)
+               return n;
 
        down(&dev->limit_sem);
 
@@ -984,12 +1137,15 @@ static int vmk80xx_pwm_winsn(struct comedi_device *cdev,
 {
        struct vmk80xx_usb *dev = cdev->private;
        unsigned char *tx_buf;
-       int reg[2], cmd;
+       int reg[2];
+       int cmd;
        int n;
 
        dbgvm("vmk80xx: %s\n", __func__);
 
-       rudimentary_check(DIR_OUT);
+       n = rudimentary_check(dev, DIR_OUT);
+       if (n)
+               return n;
 
        down(&dev->limit_sem);
 
@@ -1026,8 +1182,8 @@ static int vmk80xx_pwm_winsn(struct comedi_device *cdev,
        return n;
 }
 
-static int
-vmk80xx_attach(struct comedi_device *cdev, struct comedi_devconfig *it)
+static int vmk80xx_attach(struct comedi_device *cdev,
+                         struct comedi_devconfig *it)
 {
        int i;
        struct vmk80xx_usb *dev;
@@ -1094,16 +1250,18 @@ vmk80xx_attach(struct comedi_device *cdev, struct comedi_devconfig *it)
        s->type = COMEDI_SUBD_DI;
        s->subdev_flags = SDF_READABLE | SDF_GROUND;
        s->n_chan = dev->board.di_chans;
-       s->maxdata = (1 << dev->board.di_bits) - 1;
+       s->maxdata = 1;
        s->insn_read = vmk80xx_di_rinsn;
+       s->insn_bits = vmk80xx_di_bits;
 
        /* Digital output subdevice */
        s = cdev->subdevices + VMK80XX_SUBD_DO;
        s->type = COMEDI_SUBD_DO;
        s->subdev_flags = SDF_WRITEABLE | SDF_GROUND;
        s->n_chan = dev->board.do_chans;
-       s->maxdata = (1 << dev->board.do_bits) - 1;
+       s->maxdata = 1;
        s->insn_write = vmk80xx_do_winsn;
+       s->insn_bits = vmk80xx_do_bits;
 
        if (dev->board.model == VMK8061_MODEL) {
                s->subdev_flags |= SDF_READABLE;
@@ -1179,8 +1337,8 @@ static int vmk80xx_detach(struct comedi_device *cdev)
        return 0;
 }
 
-static int
-vmk80xx_probe(struct usb_interface *intf, const struct usb_device_id *id)
+static int vmk80xx_probe(struct usb_interface *intf,
+                        const struct usb_device_id *id)
 {
        int i;
        struct vmk80xx_usb *dev;
@@ -1309,8 +1467,9 @@ vmk80xx_probe(struct usb_interface *intf, const struct usb_device_id *id)
                        vmk80xx_read_eeprom(dev, IC6_VERSION);
                        printk(KERN_INFO "comedi#: vmk80xx: %s\n",
                               dev->fw.ic6_vers);
-               } else
+               } else {
                        dbgcm("comedi#: vmk80xx: no conn. to CPU\n");
+               }
        }
 
        if (dev->board.model == VMK8055_MODEL)
@@ -1323,6 +1482,8 @@ vmk80xx_probe(struct usb_interface *intf, const struct usb_device_id *id)
 
        mutex_unlock(&glb_mutex);
 
+       comedi_usb_auto_config(dev->udev, BOARDNAME);
+
        return 0;
 error:
        mutex_unlock(&glb_mutex);
@@ -1339,6 +1500,8 @@ static void vmk80xx_disconnect(struct usb_interface *intf)
        if (!dev)
                return;
 
+       comedi_usb_auto_unconfig(dev->udev);
+
        mutex_lock(&glb_mutex);
        down(&dev->limit_sem);
 
@@ -1376,10 +1539,16 @@ static struct comedi_driver driver_vmk80xx = {
 
 static int __init vmk80xx_init(void)
 {
+       int retval;
+
        printk(KERN_INFO "vmk80xx: version 0.8.01 "
               "Manuel Gebele <forensixs@gmx.de>\n");
-       usb_register(&vmk80xx_driver);
-       return comedi_driver_register(&driver_vmk80xx);
+
+       retval = comedi_driver_register(&driver_vmk80xx);
+       if (retval < 0)
+               return retval;
+
+       return usb_register(&vmk80xx_driver);
 }
 
 static void __exit vmk80xx_exit(void)
index 0fe713e72e9d4d620e346e214c8feaeebbef1003..5456f82c30660d72259b02226c30ca61b09fb983 100644 (file)
@@ -462,8 +462,8 @@ static int cp_tm1217_probe(struct i2c_client *client,
                if (input_dev == NULL) {
                        dev_err(ts->dev,
                                "cp_tm1217:Input Device Struct alloc failed\n");
-                       kfree(ts);
-                       return -ENOMEM;
+                       retval = -ENOMEM;
+                       goto fail;
                }
                input_info = &ts->cp_input_info[i];
                snprintf(input_info->name, sizeof(input_info->name),
@@ -486,6 +486,7 @@ static int cp_tm1217_probe(struct i2c_client *client,
                        dev_err(ts->dev,
                                "Input dev registration failed for %s\n",
                                        input_dev->name);
+                       input_free_device(input_dev);
                        goto fail;
                }
                input_info->input = input_dev;
index 6fd8089415d622ff3efed3c3bf8edfbd83f7fbe0..d2131e7fe2fbdf212a8128e80220bd69d7c279ca 100644 (file)
@@ -65,7 +65,6 @@ typedef unsigned char *PUCHAR;
 #else
 
 /* For Kernel usage.. */
-typedef bool   bc_bool_t;
 #endif
 
 #else
index 2c5138e4e1b59ab42950c70df925b30a193fbd4f..5fa0c6e10ce265c0356023ea5bd22da2eefe6ac1 100644 (file)
@@ -311,7 +311,7 @@ enum BC_STATUS crystalhd_pci_cfg_rd(struct crystalhd_adp *adp, uint32_t off,
                rc = -EINVAL;
                sts = BC_STS_INV_ARG;
                BCMLOG_ERR("Invalid len:%d\n", len);
-       };
+       }
 
        if (rc && (sts == BC_STS_SUCCESS))
                sts = BC_STS_ERROR;
@@ -356,7 +356,7 @@ enum BC_STATUS crystalhd_pci_cfg_wr(struct crystalhd_adp *adp, uint32_t off,
                rc = -EINVAL;
                sts = BC_STS_INV_ARG;
                BCMLOG_ERR("Invalid len:%d\n", len);
-       };
+       }
 
        if (rc && (sts == BC_STS_SUCCESS))
                sts = BC_STS_ERROR;
index ab05392386e86e2f19b9214c94d57532759bcca7..7a0304a857358557a869b23e279ee7d48c06220c 100644 (file)
@@ -832,6 +832,7 @@ static int video_open(struct file *file)
 
        if (NULL == dev) {
                mutex_unlock(&cx25821_devlist_mutex);
+               kfree(fh);
                return -ENODEV;
        }
 
@@ -1573,7 +1574,7 @@ int cx25821_set_control(struct cx25821_dev *dev,
                break;
        default:
                /* nothing */ ;
-       };
+       }
 
        switch (ctl->id) {
        case V4L2_CID_BRIGHTNESS:
index cee3252ea2d9386b86927ed577acb810fc2ceb0b..62e07f6a026c86461c42e7ee88b803557c0d9a2c 100644 (file)
@@ -201,9 +201,9 @@ static int easycap_open(struct inode *inode, struct file *file)
 static int reset(struct easycap *peasycap)
 {
        struct easycap_standard const *peasycap_standard;
-       int i, rc, input, rate;
+       int fmtidx, input, rate;
        bool ntsc, other;
-       int fmtidx;
+       int rc;
 
        if (!peasycap) {
                SAY("ERROR: peasycap is NULL\n");
@@ -226,33 +226,27 @@ static int reset(struct easycap *peasycap)
        JOM(8, "peasycap->ntsc=%d\n", peasycap->ntsc);
 
        rate = ready_saa(peasycap->pusb_device);
-       if (0 > rate) {
-               JOM(8, "not ready to capture after %i ms ...\n", PATIENCE);
-               if (peasycap->ntsc) {
-                       JOM(8, "... trying PAL ...\n");  ntsc = false;
-               } else {
-                       JOM(8, "... trying NTSC ...\n"); ntsc = true;
-       }
-       rc = setup_stk(peasycap->pusb_device, ntsc);
-       if (0 == rc)
-               JOM(4, "setup_stk() OK\n");
-       else {
-               SAM("ERROR: setup_stk() rc = %i\n", rc);
-               return -EFAULT;
-       }
-       rc = setup_saa(peasycap->pusb_device, ntsc);
-       if (0 == rc)
-               JOM(4, "setup_saa() OK\n");
-       else {
-               SAM("ERROR: setup_saa() rc = %i\n", rc);
-               return -EFAULT;
-       }
-       rate = ready_saa(peasycap->pusb_device);
-       if (0 > rate) {
+       if (rate < 0) {
                JOM(8, "not ready to capture after %i ms ...\n", PATIENCE);
-               JOM(8, "... saa register 0x1F has 0x%02X\n",
+               ntsc = !peasycap->ntsc;
+               JOM(8, "... trying  %s ..\n", ntsc ? "NTSC" : "PAL");
+               rc = setup_stk(peasycap->pusb_device, ntsc);
+               if (rc) {
+                       SAM("ERROR: setup_stk() rc = %i\n", rc);
+                       return -EFAULT;
+               }
+               rc = setup_saa(peasycap->pusb_device, ntsc);
+               if (rc) {
+                       SAM("ERROR: setup_saa() rc = %i\n", rc);
+                       return -EFAULT;
+               }
+
+               rate = ready_saa(peasycap->pusb_device);
+               if (rate < 0) {
+                       JOM(8, "not ready to capture after %i ms\n", PATIENCE);
+                       JOM(8, "... saa register 0x1F has 0x%02X\n",
                                        read_saa(peasycap->pusb_device, 0x1F));
-               ntsc = peasycap->ntsc;
+                       ntsc = peasycap->ntsc;
                } else {
                        JOM(8, "... success at second try:  %i=rate\n", rate);
                        ntsc = (0 < (rate/2)) ? true : false ;
@@ -266,22 +260,17 @@ static int reset(struct easycap *peasycap)
 /*---------------------------------------------------------------------------*/
 
        rc = setup_stk(peasycap->pusb_device, ntsc);
-       if (0 == rc)
-               JOM(4, "setup_stk() OK\n");
-       else {
+       if (rc) {
                SAM("ERROR: setup_stk() rc = %i\n", rc);
                return -EFAULT;
        }
        rc = setup_saa(peasycap->pusb_device, ntsc);
-       if (0 == rc)
-               JOM(4, "setup_saa() OK\n");
-       else {
+       if (rc) {
                SAM("ERROR: setup_saa() rc = %i\n", rc);
                return -EFAULT;
        }
 
-       for (i = 0; i < 180; i++)
-               peasycap->merit[i] = 0;
+       memset(peasycap->merit, 0, sizeof(peasycap->merit));
 
        peasycap->video_eof = 0;
        peasycap->audio_eof = 0;
@@ -2986,26 +2975,18 @@ static const struct v4l2_file_operations v4l2_fops = {
  *  TIMES, ONCE FOR EACH OF THE THREE INTERFACES.  BEWARE.
  */
 /*---------------------------------------------------------------------------*/
-static int easycap_usb_probe(struct usb_interface *pusb_interface,
-                           const struct usb_device_id *pusb_device_id)
+static int easycap_usb_probe(struct usb_interface *intf,
+                           const struct usb_device_id *id)
 {
-       struct usb_device *pusb_device;
-       struct usb_host_interface *pusb_host_interface;
-       struct usb_endpoint_descriptor *pepd;
-       struct usb_interface_descriptor *pusb_interface_descriptor;
+       struct usb_device *usbdev;
+       struct usb_host_interface *alt;
+       struct usb_endpoint_descriptor *ep;
+       struct usb_interface_descriptor *interface;
        struct urb *purb;
        struct easycap *peasycap;
        int ndong;
        struct data_urb *pdata_urb;
-       size_t wMaxPacketSize;
-       int ISOCwMaxPacketSize;
-       int BULKwMaxPacketSize;
-       int INTwMaxPacketSize;
-       int CTRLwMaxPacketSize;
-       u8 bEndpointAddress;
-       u8 ISOCbEndpointAddress;
-       u8 INTbEndpointAddress;
-       int isin, i, j, k, m, rc;
+       int i, j, k, m, rc;
        u8 bInterfaceNumber;
        u8 bInterfaceClass;
        u8 bInterfaceSubClass;
@@ -3021,23 +3002,17 @@ static int easycap_usb_probe(struct usb_interface *pusb_interface,
        struct inputset *inputset;
        struct v4l2_device *pv4l2_device;
 
-/*---------------------------------------------------------------------------*/
-/*
- *  GET POINTER TO STRUCTURE usb_device
- */
-/*---------------------------------------------------------------------------*/
-       pusb_device = interface_to_usbdev(pusb_interface);
+       usbdev = interface_to_usbdev(intf);
 
-       JOT(4, "bNumConfigurations=%i\n", pusb_device->descriptor.bNumConfigurations);
 /*---------------------------------------------------------------------------*/
-       pusb_host_interface = pusb_interface->cur_altsetting;
-       if (!pusb_host_interface) {
-               SAY("ERROR: pusb_host_interface is NULL\n");
+       alt = usb_altnum_to_altsetting(intf, 0);
+       if (!alt) {
+               SAY("ERROR: usb_host_interface not found\n");
                return -EFAULT;
        }
-       pusb_interface_descriptor = &(pusb_host_interface->desc);
-       if (!pusb_interface_descriptor) {
-               SAY("ERROR: pusb_interface_descriptor is NULL\n");
+       interface = &alt->desc;
+       if (!interface) {
+               SAY("ERROR: intf_descriptor is NULL\n");
                return -EFAULT;
        }
 /*---------------------------------------------------------------------------*/
@@ -3045,16 +3020,15 @@ static int easycap_usb_probe(struct usb_interface *pusb_interface,
  *  GET PROPERTIES OF PROBED INTERFACE
  */
 /*---------------------------------------------------------------------------*/
-       bInterfaceNumber = pusb_interface_descriptor->bInterfaceNumber;
-       bInterfaceClass = pusb_interface_descriptor->bInterfaceClass;
-       bInterfaceSubClass = pusb_interface_descriptor->bInterfaceSubClass;
+       bInterfaceNumber = interface->bInterfaceNumber;
+       bInterfaceClass = interface->bInterfaceClass;
+       bInterfaceSubClass = interface->bInterfaceSubClass;
 
        JOT(4, "intf[%i]: num_altsetting=%i\n",
-                       bInterfaceNumber, pusb_interface->num_altsetting);
+                       bInterfaceNumber, intf->num_altsetting);
        JOT(4, "intf[%i]: cur_altsetting - altsetting=%li\n",
                bInterfaceNumber,
-               (long int)(pusb_interface->cur_altsetting -
-                               pusb_interface->altsetting));
+               (long int)(intf->cur_altsetting - intf->altsetting));
        JOT(4, "intf[%i]: bInterfaceClass=0x%02X bInterfaceSubClass=0x%02X\n",
                        bInterfaceNumber, bInterfaceClass, bInterfaceSubClass);
 /*---------------------------------------------------------------------------*/
@@ -3140,8 +3114,8 @@ static int easycap_usb_probe(struct usb_interface *pusb_interface,
  *  ... AND FURTHER INITIALIZE THE STRUCTURE
 */
 /*---------------------------------------------------------------------------*/
-               peasycap->pusb_device = pusb_device;
-               peasycap->pusb_interface = pusb_interface;
+               peasycap->pusb_device = usbdev;
+               peasycap->pusb_interface = intf;
 
                peasycap->ilk = 0;
                peasycap->microphone = false;
@@ -3275,7 +3249,7 @@ static int easycap_usb_probe(struct usb_interface *pusb_interface,
  */
 /*---------------------------------------------------------------------------*/
                for (ndong = 0; ndong < DONGLE_MANY; ndong++) {
-                       if (pusb_device == easycapdc60_dongle[ndong].peasycap->
+                       if (usbdev == easycapdc60_dongle[ndong].peasycap->
                                                                        pusb_device) {
                                peasycap = easycapdc60_dongle[ndong].peasycap;
                                JOT(8, "intf[%i]: dongle[%i].peasycap\n",
@@ -3302,7 +3276,7 @@ static int easycap_usb_probe(struct usb_interface *pusb_interface,
 */
 /*---------------------------------------------------------------------------*/
                if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) {
-                       pv4l2_device = usb_get_intfdata(pusb_interface);
+                       pv4l2_device = usb_get_intfdata(intf);
                        if (!pv4l2_device) {
                                SAY("ERROR: pv4l2_device is NULL\n");
                                return -ENODEV;
@@ -3351,220 +3325,155 @@ static int easycap_usb_probe(struct usb_interface *pusb_interface,
 /*---------------------------------------------------------------------------*/
        isokalt = 0;
 
-       for (i = 0; i < pusb_interface->num_altsetting; i++) {
-               pusb_host_interface = &(pusb_interface->altsetting[i]);
-               if (!pusb_host_interface) {
-                       SAM("ERROR: pusb_host_interface is NULL\n");
+       for (i = 0; i < intf->num_altsetting; i++) {
+               alt = usb_altnum_to_altsetting(intf, i);
+               if (!alt) {
+                       SAM("ERROR: alt is NULL\n");
                        return -EFAULT;
                }
-               pusb_interface_descriptor = &(pusb_host_interface->desc);
-               if (!pusb_interface_descriptor) {
-                       SAM("ERROR: pusb_interface_descriptor is NULL\n");
+               interface = &alt->desc;
+               if (!interface) {
+                       SAM("ERROR: intf_descriptor is NULL\n");
                        return -EFAULT;
                }
 
-               JOM(4, "intf[%i]alt[%i]: desc.bDescriptorType=0x%02X\n",
-               bInterfaceNumber, i, pusb_interface_descriptor->bDescriptorType);
-               JOM(4, "intf[%i]alt[%i]: desc.bInterfaceNumber=0x%02X\n",
-               bInterfaceNumber, i, pusb_interface_descriptor->bInterfaceNumber);
-               JOM(4, "intf[%i]alt[%i]: desc.bAlternateSetting=0x%02X\n",
-               bInterfaceNumber, i, pusb_interface_descriptor->bAlternateSetting);
-               JOM(4, "intf[%i]alt[%i]: desc.bNumEndpoints=0x%02X\n",
-               bInterfaceNumber, i, pusb_interface_descriptor->bNumEndpoints);
-               JOM(4, "intf[%i]alt[%i]: desc.bInterfaceClass=0x%02X\n",
-               bInterfaceNumber, i, pusb_interface_descriptor->bInterfaceClass);
-               JOM(4, "intf[%i]alt[%i]: desc.bInterfaceSubClass=0x%02X\n",
-               bInterfaceNumber, i, pusb_interface_descriptor->bInterfaceSubClass);
-               JOM(4, "intf[%i]alt[%i]: desc.bInterfaceProtocol=0x%02X\n",
-               bInterfaceNumber, i, pusb_interface_descriptor->bInterfaceProtocol);
-               JOM(4, "intf[%i]alt[%i]: desc.iInterface=0x%02X\n",
-               bInterfaceNumber, i, pusb_interface_descriptor->iInterface);
-
-               ISOCwMaxPacketSize = -1;
-               BULKwMaxPacketSize = -1;
-               INTwMaxPacketSize = -1;
-               CTRLwMaxPacketSize = -1;
-               ISOCbEndpointAddress = 0;
-               INTbEndpointAddress = 0;
-
-               if (0 == pusb_interface_descriptor->bNumEndpoints)
+               if (0 == interface->bNumEndpoints)
                        JOM(4, "intf[%i]alt[%i] has no endpoints\n",
                                                bInterfaceNumber, i);
 /*---------------------------------------------------------------------------*/
-               for (j = 0; j < pusb_interface_descriptor->bNumEndpoints; j++) {
-                       pepd = &(pusb_host_interface->endpoint[j].desc);
-                       if (!pepd) {
-                               SAM("ERROR:  pepd is NULL.\n");
+               for (j = 0; j < interface->bNumEndpoints; j++) {
+                       ep = &alt->endpoint[j].desc;
+                       if (!ep) {
+                               SAM("ERROR:  ep is NULL.\n");
                                SAM("...... skipping\n");
                                continue;
                        }
-                       wMaxPacketSize = le16_to_cpu(pepd->wMaxPacketSize);
-                       bEndpointAddress = pepd->bEndpointAddress;
-
-                       JOM(4, "intf[%i]alt[%i]end[%i]: bEndpointAddress=0x%X\n",
-                                       bInterfaceNumber, i, j,
-                                       pepd->bEndpointAddress);
-                       JOM(4, "intf[%i]alt[%i]end[%i]: bmAttributes=0x%X\n",
-                                       bInterfaceNumber, i, j,
-                                       pepd->bmAttributes);
-                       JOM(4, "intf[%i]alt[%i]end[%i]: wMaxPacketSize=%i\n",
-                                       bInterfaceNumber, i, j,
-                                       pepd->wMaxPacketSize);
-                       JOM(4, "intf[%i]alt[%i]end[%i]: bInterval=%i\n",
-                                       bInterfaceNumber, i, j,
-                                       pepd->bInterval);
-
-                       if (pepd->bEndpointAddress & USB_DIR_IN) {
-                               JOM(4, "intf[%i]alt[%i]end[%i] is an  IN  endpoint\n",
-                                                       bInterfaceNumber, i, j);
-                               isin = 1;
-                       } else {
-                               JOM(4, "intf[%i]alt[%i]end[%i] is an  OUT endpoint\n",
-                                                       bInterfaceNumber, i, j);
-                               SAM("ERROR: OUT endpoint unexpected\n");
-                               SAM("...... continuing\n");
-                               isin = 0;
+
+                       if (!usb_endpoint_is_isoc_in(ep)) {
+                               JOM(4, "intf[%i]alt[%i]end[%i] is a %d endpoint\n",
+                                               bInterfaceNumber,
+                                               i, j, ep->bmAttributes);
+                               if (usb_endpoint_dir_out(ep)) {
+                                       SAM("ERROR: OUT endpoint unexpected\n");
+                                       SAM("...... continuing\n");
+                               }
+                               continue;
                        }
-                       if ((pepd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
-                                               USB_ENDPOINT_XFER_ISOC) {
-                               JOM(4, "intf[%i]alt[%i]end[%i] is an ISOC endpoint\n",
-                                                       bInterfaceNumber, i, j);
-                               if (isin) {
-                                       switch (bInterfaceClass) {
-                                       case USB_CLASS_VIDEO:
-                                       case USB_CLASS_VENDOR_SPEC: {
-                                               if (!peasycap) {
-                                                       SAM("MISTAKE: "
-                                                               "peasycap is NULL\n");
-                                                       return -EFAULT;
-                                               }
-                                               if (pepd->wMaxPacketSize) {
-                                                       if (8 > isokalt) {
-                                                               okalt[isokalt] = i;
-                                                               JOM(4,
-                                                               "%i=okalt[%i]\n",
-                                                               okalt[isokalt],
-                                                               isokalt);
-                                                               okepn[isokalt] =
-                                                               pepd->
-                                                               bEndpointAddress &
-                                                               0x0F;
-                                                               JOM(4,
-                                                               "%i=okepn[%i]\n",
-                                                               okepn[isokalt],
-                                                               isokalt);
-                                                               okmps[isokalt] =
-                                                               le16_to_cpu(pepd->
-                                                               wMaxPacketSize);
-                                                               JOM(4,
-                                                               "%i=okmps[%i]\n",
-                                                               okmps[isokalt],
-                                                               isokalt);
-                                                               isokalt++;
-                                                       }
-                                               } else {
-                                                       if (-1 == peasycap->
-                                                               video_altsetting_off) {
-                                                               peasycap->
-                                                               video_altsetting_off =
-                                                                                i;
-                                                               JOM(4, "%i=video_"
-                                                               "altsetting_off "
-                                                                       "<====\n",
-                                                               peasycap->
-                                                               video_altsetting_off);
-                                                       } else {
-                                                               SAM("ERROR: peasycap"
-                                                               "->video_altsetting_"
-                                                               "off already set\n");
-                                                               SAM("...... "
-                                                               "continuing with "
-                                                               "%i=peasycap->video_"
-                                                               "altsetting_off\n",
-                                                               peasycap->
-                                                               video_altsetting_off);
-                                                       }
-                                               }
-                                               break;
+                       switch (bInterfaceClass) {
+                       case USB_CLASS_VIDEO:
+                       case USB_CLASS_VENDOR_SPEC: {
+                               if (ep->wMaxPacketSize) {
+                                       if (8 > isokalt) {
+                                               okalt[isokalt] = i;
+                                               JOM(4,
+                                               "%i=okalt[%i]\n",
+                                               okalt[isokalt],
+                                               isokalt);
+                                               okepn[isokalt] =
+                                               ep->
+                                               bEndpointAddress &
+                                               0x0F;
+                                               JOM(4,
+                                               "%i=okepn[%i]\n",
+                                               okepn[isokalt],
+                                               isokalt);
+                                               okmps[isokalt] =
+                                               le16_to_cpu(ep->
+                                               wMaxPacketSize);
+                                               JOM(4,
+                                               "%i=okmps[%i]\n",
+                                               okmps[isokalt],
+                                               isokalt);
+                                               isokalt++;
                                        }
-                                       case USB_CLASS_AUDIO: {
-                                               if (bInterfaceSubClass !=
-                                                   USB_SUBCLASS_AUDIOSTREAMING)
-                                                       break;
-                                               if (!peasycap) {
-                                                       SAM("MISTAKE: "
-                                                       "peasycap is NULL\n");
-                                                       return -EFAULT;
-                                               }
-                                               if (pepd->wMaxPacketSize) {
-                                                       if (8 > isokalt) {
-                                                               okalt[isokalt] = i ;
-                                                               JOM(4,
-                                                               "%i=okalt[%i]\n",
-                                                               okalt[isokalt],
-                                                               isokalt);
-                                                               okepn[isokalt] =
-                                                               pepd->
-                                                               bEndpointAddress &
-                                                               0x0F;
-                                                               JOM(4,
-                                                               "%i=okepn[%i]\n",
-                                                               okepn[isokalt],
-                                                               isokalt);
-                                                               okmps[isokalt] =
-                                                               le16_to_cpu(pepd->
-                                                               wMaxPacketSize);
-                                                               JOM(4,
-                                                               "%i=okmps[%i]\n",
-                                                               okmps[isokalt],
-                                                               isokalt);
-                                                               isokalt++;
-                                                       }
-                                               } else {
-                                                       if (-1 == peasycap->
-                                                               audio_altsetting_off) {
-                                                               peasycap->
-                                                               audio_altsetting_off =
-                                                                                i;
-                                                               JOM(4, "%i=audio_"
-                                                               "altsetting_off "
-                                                               "<====\n",
-                                                               peasycap->
-                                                               audio_altsetting_off);
-                                                       } else {
-                                                               SAM("ERROR: peasycap"
-                                                               "->audio_altsetting_"
-                                                               "off already set\n");
-                                                               SAM("...... "
-                                                               "continuing with "
-                                                               "%i=peasycap->"
-                                                               "audio_altsetting_"
-                                                               "off\n",
-                                                               peasycap->
-                                                               audio_altsetting_off);
-                                                       }
-                                               }
+                               } else {
+                                       if (-1 == peasycap->
+                                               video_altsetting_off) {
+                                               peasycap->
+                                               video_altsetting_off =
+                                                                i;
+                                               JOM(4, "%i=video_"
+                                               "altsetting_off "
+                                                       "<====\n",
+                                               peasycap->
+                                               video_altsetting_off);
+                                       } else {
+                                               SAM("ERROR: peasycap"
+                                               "->video_altsetting_"
+                                               "off already set\n");
+                                               SAM("...... "
+                                               "continuing with "
+                                               "%i=peasycap->video_"
+                                               "altsetting_off\n",
+                                               peasycap->
+                                               video_altsetting_off);
+                                       }
+                               }
+                               break;
+                       }
+                       case USB_CLASS_AUDIO: {
+                               if (bInterfaceSubClass !=
+                                   USB_SUBCLASS_AUDIOSTREAMING)
                                        break;
+                               if (!peasycap) {
+                                       SAM("MISTAKE: "
+                                       "peasycap is NULL\n");
+                                       return -EFAULT;
+                               }
+                               if (ep->wMaxPacketSize) {
+                                       if (8 > isokalt) {
+                                               okalt[isokalt] = i ;
+                                               JOM(4,
+                                               "%i=okalt[%i]\n",
+                                               okalt[isokalt],
+                                               isokalt);
+                                               okepn[isokalt] =
+                                               ep->
+                                               bEndpointAddress &
+                                               0x0F;
+                                               JOM(4,
+                                               "%i=okepn[%i]\n",
+                                               okepn[isokalt],
+                                               isokalt);
+                                               okmps[isokalt] =
+                                               le16_to_cpu(ep->
+                                               wMaxPacketSize);
+                                               JOM(4,
+                                               "%i=okmps[%i]\n",
+                                               okmps[isokalt],
+                                               isokalt);
+                                               isokalt++;
                                        }
-                                       default:
-                                               break;
+                               } else {
+                                       if (-1 == peasycap->
+                                               audio_altsetting_off) {
+                                               peasycap->
+                                               audio_altsetting_off =
+                                                                i;
+                                               JOM(4, "%i=audio_"
+                                               "altsetting_off "
+                                               "<====\n",
+                                               peasycap->
+                                               audio_altsetting_off);
+                                       } else {
+                                               SAM("ERROR: peasycap"
+                                               "->audio_altsetting_"
+                                               "off already set\n");
+                                               SAM("...... "
+                                               "continuing with "
+                                               "%i=peasycap->"
+                                               "audio_altsetting_"
+                                               "off\n",
+                                               peasycap->
+                                               audio_altsetting_off);
                                        }
                                }
-                       } else if ((pepd->bmAttributes &
-                                                       USB_ENDPOINT_XFERTYPE_MASK) ==
-                                                       USB_ENDPOINT_XFER_BULK) {
-                               JOM(4, "intf[%i]alt[%i]end[%i] is a  BULK endpoint\n",
-                                                       bInterfaceNumber, i, j);
-                       } else if ((pepd->bmAttributes &
-                                                       USB_ENDPOINT_XFERTYPE_MASK) ==
-                                                       USB_ENDPOINT_XFER_INT) {
-                               JOM(4, "intf[%i]alt[%i]end[%i] is an  INT endpoint\n",
-                                                       bInterfaceNumber, i, j);
-                       } else {
-                               JOM(4, "intf[%i]alt[%i]end[%i] is a  CTRL endpoint\n",
-                                                       bInterfaceNumber, i, j);
+                       break;
+                       }
+                       default:
+                               break;
                        }
-                       if (0 == pepd->wMaxPacketSize) {
+                       if (0 == ep->wMaxPacketSize) {
                                JOM(4, "intf[%i]alt[%i]end[%i] "
                                                        "has zero packet size\n",
                                                        bInterfaceNumber, i, j);
@@ -3577,7 +3486,7 @@ static int easycap_usb_probe(struct usb_interface *pusb_interface,
  */
 /*---------------------------------------------------------------------------*/
        JOM(4, "initialization begins for interface %i\n",
-               pusb_interface_descriptor->bInterfaceNumber);
+               interface->bInterfaceNumber);
        switch (bInterfaceNumber) {
 /*---------------------------------------------------------------------------*/
 /*
@@ -3844,7 +3753,7 @@ static int easycap_usb_probe(struct usb_interface *pusb_interface,
  *  SAVE POINTER peasycap IN THIS INTERFACE.
  */
 /*--------------------------------------------------------------------------*/
-               usb_set_intfdata(pusb_interface, peasycap);
+               usb_set_intfdata(intf, peasycap);
 /*---------------------------------------------------------------------------*/
 /*
  *  IT IS ESSENTIAL TO INITIALIZE THE HARDWARE BEFORE, RATHER THAN AFTER,
@@ -3866,7 +3775,7 @@ static int easycap_usb_probe(struct usb_interface *pusb_interface,
  *  THE VIDEO DEVICE CAN BE REGISTERED NOW, AS IT IS READY.
  */
 /*--------------------------------------------------------------------------*/
-               if (0 != (v4l2_device_register(&(pusb_interface->dev),
+               if (0 != (v4l2_device_register(&(intf->dev),
                                                        &(peasycap->v4l2_device)))) {
                        SAM("v4l2_device_register() failed\n");
                        return -ENODEV;
@@ -3924,9 +3833,9 @@ static int easycap_usb_probe(struct usb_interface *pusb_interface,
  *  SAVE POINTER peasycap IN INTERFACE 1
  */
 /*--------------------------------------------------------------------------*/
-               usb_set_intfdata(pusb_interface, peasycap);
+               usb_set_intfdata(intf, peasycap);
                JOM(4, "no initialization required for interface %i\n",
-                                       pusb_interface_descriptor->bInterfaceNumber);
+                                       interface->bInterfaceNumber);
                break;
        }
 /*--------------------------------------------------------------------------*/
@@ -4188,7 +4097,7 @@ static int easycap_usb_probe(struct usb_interface *pusb_interface,
  *  SAVE POINTER peasycap IN THIS INTERFACE.
  */
 /*---------------------------------------------------------------------------*/
-               usb_set_intfdata(pusb_interface, peasycap);
+               usb_set_intfdata(intf, peasycap);
 /*---------------------------------------------------------------------------*/
 /*
  *  THE AUDIO DEVICE CAN BE REGISTERED NOW, AS IT IS READY.
@@ -4201,28 +4110,22 @@ static int easycap_usb_probe(struct usb_interface *pusb_interface,
                if (rc) {
                        err("easycap_alsa_probe() rc = %i\n", rc);
                        return -ENODEV;
-               } else {
-                       JOM(8, "kref_get() with %i=kref.refcount.counter\n",
-                                       peasycap->kref.refcount.counter);
-                       kref_get(&peasycap->kref);
-                       peasycap->registered_audio++;
                }
 
 #else /* CONFIG_EASYCAP_OSS */
-               rc = usb_register_dev(pusb_interface, &easyoss_class);
+               rc = usb_register_dev(intf, &easyoss_class);
                if (rc) {
                        SAY("ERROR: usb_register_dev() failed\n");
-                       usb_set_intfdata(pusb_interface, NULL);
+                       usb_set_intfdata(intf, NULL);
                        return -ENODEV;
-               } else {
-                       JOM(8, "kref_get() with %i=kref.refcount.counter\n",
-                                       peasycap->kref.refcount.counter);
-                       kref_get(&peasycap->kref);
-                       peasycap->registered_audio++;
                }
-               SAM("easyoss attached to minor #%d\n", pusb_interface->minor);
+               SAM("easyoss attached to minor #%d\n", intf->minor);
 #endif /* CONFIG_EASYCAP_OSS */
 
+               JOM(8, "kref_get() with %i=kref.refcount.counter\n",
+                               peasycap->kref.refcount.counter);
+               kref_get(&peasycap->kref);
+               peasycap->registered_audio++;
                break;
        }
 /*---------------------------------------------------------------------------*/
index 3c188d5f1d9f9b7d632118dbc6ba1d2f0af17114..c0adae1bf6d38ea35c77a691332e7a76900c8b90 100644 (file)
 #define DTD_HANGOVER                   600     /* 600 samples, or 75ms     */
 #define DC_LOG2BETA                    3       /* log2() of DC filter Beta */
 
-
 /* adapting coeffs using the traditional stochastic descent (N)LMS algorithm */
 
 #ifdef __bfin__
-static inline void lms_adapt_bg(struct oslec_state *ec, int clean,
-                                   int shift)
+static inline void lms_adapt_bg(struct oslec_state *ec, int clean, int shift)
 {
        int i, j;
        int offset1;
@@ -189,8 +187,7 @@ static inline void lms_adapt_bg(struct oslec_state *ec, int clean,
 */
 
 #else
-static inline void lms_adapt_bg(struct oslec_state *ec, int clean,
-                                   int shift)
+static inline void lms_adapt_bg(struct oslec_state *ec, int clean, int shift)
 {
        int i;
 
@@ -225,7 +222,7 @@ static inline int top_bit(unsigned int bits)
        if (bits == 0)
                return -1;
        else
-               return (int)fls((int32_t)bits)-1;
+               return (int)fls((int32_t) bits) - 1;
 }
 
 struct oslec_state *oslec_create(int len, int adaption_mode)
@@ -279,6 +276,7 @@ error_oom:
        kfree(ec);
        return NULL;
 }
+
 EXPORT_SYMBOL_GPL(oslec_create);
 
 void oslec_free(struct oslec_state *ec)
@@ -292,12 +290,14 @@ void oslec_free(struct oslec_state *ec)
        kfree(ec->snapshot);
        kfree(ec);
 }
+
 EXPORT_SYMBOL_GPL(oslec_free);
 
 void oslec_adaption_mode(struct oslec_state *ec, int adaption_mode)
 {
        ec->adaption_mode = adaption_mode;
 }
+
 EXPORT_SYMBOL_GPL(oslec_adaption_mode);
 
 void oslec_flush(struct oslec_state *ec)
@@ -324,12 +324,14 @@ void oslec_flush(struct oslec_state *ec)
        ec->curr_pos = ec->taps - 1;
        ec->Pstates = 0;
 }
+
 EXPORT_SYMBOL_GPL(oslec_flush);
 
 void oslec_snapshot(struct oslec_state *ec)
 {
        memcpy(ec->snapshot, ec->fir_taps16[0], ec->taps * sizeof(int16_t));
 }
+
 EXPORT_SYMBOL_GPL(oslec_snapshot);
 
 /* Dual Path Echo Canceller */
@@ -404,11 +406,11 @@ int16_t oslec_update(struct oslec_state *ec, int16_t tx, int16_t rx)
                /* efficient "out with the old and in with the new" algorithm so
                   we don't have to recalculate over the whole block of
                   samples. */
-               new = (int)tx * (int)tx;
+               new = (int)tx *(int)tx;
                old = (int)ec->fir_state.history[ec->fir_state.curr_pos] *
                    (int)ec->fir_state.history[ec->fir_state.curr_pos];
                ec->Pstates +=
-                   ((new - old) + (1 << (ec->log2taps-1))) >> ec->log2taps;
+                   ((new - old) + (1 << (ec->log2taps - 1))) >> ec->log2taps;
                if (ec->Pstates < 0)
                        ec->Pstates = 0;
        }
@@ -466,7 +468,7 @@ int16_t oslec_update(struct oslec_state *ec, int16_t tx, int16_t rx)
 
                   factor      = (2^30) * (2^-2) * clean_bg_rx/P
 
-                                               (30 - 2 - log2(P))
+                  (30 - 2 - log2(P))
                   factor      = clean_bg_rx 2                     ----- (3)
 
                   To avoid a divide we approximate log2(P) as top_bit(P),
@@ -514,7 +516,7 @@ int16_t oslec_update(struct oslec_state *ec, int16_t tx, int16_t rx)
                         */
                        ec->adapt = 1;
                        memcpy(ec->fir_taps16[0], ec->fir_taps16[1],
-                               ec->taps * sizeof(int16_t));
+                              ec->taps * sizeof(int16_t));
                } else
                        ec->cond_met++;
        } else
@@ -601,6 +603,7 @@ int16_t oslec_update(struct oslec_state *ec, int16_t tx, int16_t rx)
 
        return (int16_t) ec->clean_nlp << 1;
 }
+
 EXPORT_SYMBOL_GPL(oslec_update);
 
 /* This function is separated from the echo canceller is it is usually called
@@ -625,7 +628,7 @@ EXPORT_SYMBOL_GPL(oslec_update);
    giving very clean DC removal.
 */
 
-int16_t oslec_hpf_tx(struct oslec_state *ec, int16_t tx)
+int16_t oslec_hpf_tx(struct oslec_state * ec, int16_t tx)
 {
        int tmp, tmp1;
 
@@ -654,6 +657,7 @@ int16_t oslec_hpf_tx(struct oslec_state *ec, int16_t tx)
 
        return tx;
 }
+
 EXPORT_SYMBOL_GPL(oslec_hpf_tx);
 
 MODULE_LICENSE("GPL");
index 684e69eacb71e58f823e2bf67c2f90d532ba0cf8..b0a4211f43a1d51cb882ca3e611d87198422757f 100644 (file)
@@ -6,8 +6,6 @@
 //
 // $Id:
 //====================================================
-// 20090926; aelias; removed compiler warnings & errors; ubuntu 9.04; 2.6.28-15-generic
-
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
@@ -38,8 +36,6 @@ static int ft1000_open (struct net_device *dev);
 static struct net_device_stats *ft1000_netdev_stats(struct net_device *dev);
 static int ft1000_chkcard (struct ft1000_device *dev);
 
-//Jim
-
 static u8 tempbuffer[1600];
 
 #define MAX_RCV_LOOP   100
@@ -492,8 +488,6 @@ void card_send_command(struct ft1000_device *ft1000dev, void *ptempbuffer,
        commandbuf = (unsigned char *)kmalloc(size + 2, GFP_KERNEL);
        memcpy((void *)commandbuf + 2, (void *)ptempbuffer, size);
 
-       //DEBUG("card_send_command: Command Send\n");
-
        ft1000_read_register(ft1000dev, &temp, FT1000_REG_DOORBELL);
 
        if (temp & 0x0100)
@@ -506,16 +500,14 @@ void card_send_command(struct ft1000_device *ft1000dev, void *ptempbuffer,
        if (size % 4)
                size += 4 - (size % 4);
 
-       //DEBUG("card_send_command: write dpram ... size=%d\n", size);
        ft1000_write_dpram32(ft1000dev, 0, commandbuf, size);
        msleep(1);
-       //DEBUG("card_send_command: write into doorbell ...\n");
        ft1000_write_register(ft1000dev, FT1000_DB_DPRAM_TX,
                              FT1000_REG_DOORBELL);
        msleep(1);
 
        ft1000_read_register(ft1000dev, &temp, FT1000_REG_DOORBELL);
-       //DEBUG("card_send_command: read doorbell ...temp=%x\n", temp);
+
        if ((temp & 0x0100) == 0) {
                //DEBUG("card_send_command: Message sent\n");
        }
@@ -601,8 +593,6 @@ static void ft1000_reset_asic(struct net_device *dev)
 
        DEBUG("ft1000_hw:ft1000_reset_asic called\n");
 
-       info->ASICResetNum++;
-
        /* Let's use the register provided by the Magnemite ASIC to reset the
         * ASIC and DSP.
         */
@@ -660,8 +650,6 @@ static int ft1000_reset_card(struct net_device *dev)
        DEBUG("ft1000_hw:ft1000_reset_card: reset asic\n");
        ft1000_reset_asic(dev);
 
-       info->DSPResetNum++;
-
        DEBUG("ft1000_hw:ft1000_reset_card: call dsp_reload\n");
        dsp_reload(ft1000dev);
 
@@ -683,8 +671,6 @@ static int ft1000_reset_card(struct net_device *dev)
        return TRUE;
 }
 
-
-//mbelian
 #ifdef HAVE_NET_DEVICE_OPS
 static const struct net_device_ops ftnet_ops =
 {
@@ -758,14 +744,11 @@ int init_ft1000_netdev(struct ft1000_device *ft1000dev)
        spin_lock_init(&pInfo->dpram_lock);
        pInfo->pFt1000Dev = ft1000dev;
        pInfo->DrvErrNum = 0;
-       pInfo->ASICResetNum = 0;
        pInfo->registered = 1;
        pInfo->ft1000_reset = ft1000_reset;
        pInfo->mediastate = 0;
        pInfo->fifo_cnt = 0;
        pInfo->DeviceCreated = FALSE;
-       pInfo->CurrentInterruptEnableMask = ISR_DEFAULT_MASK;
-       pInfo->InterruptsEnabled = FALSE;
        pInfo->CardReady = 0;
        pInfo->DSP_TIME[0] = 0;
        pInfo->DSP_TIME[1] = 0;
@@ -904,14 +887,10 @@ static void ft1000_usb_transmit_complete(struct urb *urb)
 
        struct ft1000_device *ft1000dev = urb->context;
 
-    //DEBUG("ft1000_usb_transmit_complete entered\n");
-
        if (urb->status)
                pr_err("%s: TX status %d\n", ft1000dev->net->name, urb->status);
 
        netif_wake_queue(ft1000dev->net);
-
-    //DEBUG("Return from ft1000_usb_transmit_complete\n");
 }
 
 //---------------------------------------------------------------------------
@@ -943,8 +922,6 @@ static int ft1000_copy_down_pkt(struct net_device *netdev, u8 * packet, u16 len)
                return -ENODEV;
        }
 
-       //DEBUG("ft1000_copy_down_pkt() entered, len = %d\n", len);
-
        count = sizeof(struct pseudo_hdr) + len;
        if (count > MAX_BUF_SIZE) {
                DEBUG("Error:ft1000_copy_down_pkt:Message Size Overflow!\n");
@@ -973,8 +950,6 @@ static int ft1000_copy_down_pkt(struct net_device *netdev, u8 * packet, u16 len)
 
        netif_stop_queue(netdev);
 
-       //DEBUG ("ft1000_copy_down_pkt: count = %d\n", count);
-
        usb_fill_bulk_urb(pFt1000Dev->tx_urb,
                          pFt1000Dev->dev,
                          usb_sndbulkpipe(pFt1000Dev->dev,
@@ -983,11 +958,6 @@ static int ft1000_copy_down_pkt(struct net_device *netdev, u8 * packet, u16 len)
                          ft1000_usb_transmit_complete, (void *)pFt1000Dev);
 
        t = (u8 *) pFt1000Dev->tx_urb->transfer_buffer;
-       //DEBUG("transfer_length=%d\n", pFt1000Dev->tx_urb->transfer_buffer_length);
-       /*for (i=0; i<count; i++ )
-          {
-          DEBUG("%x    ", *t++ );
-          } */
 
        ret = usb_submit_urb(pFt1000Dev->tx_urb, GFP_ATOMIC);
 
@@ -999,8 +969,6 @@ static int ft1000_copy_down_pkt(struct net_device *netdev, u8 * packet, u16 len)
                pInfo->stats.tx_bytes += (len + 14);
        }
 
-       //DEBUG("ft1000_copy_down_pkt() exit\n");
-
        return 0;
 }
 
@@ -1026,8 +994,6 @@ static int ft1000_start_xmit(struct sk_buff *skb, struct net_device *dev)
        u8 *pdata;
        int maxlen, pipe;
 
-       //DEBUG(" ft1000_start_xmit() entered\n");
-
        if (skb == NULL) {
                DEBUG("ft1000_hw: ft1000_start_xmit:skb == NULL!!!\n");
                return NETDEV_TX_OK;
@@ -1037,17 +1003,12 @@ static int ft1000_start_xmit(struct sk_buff *skb, struct net_device *dev)
                DEBUG("network driver is closed, return\n");
                goto err;
        }
-       //DEBUG("ft1000_start_xmit 1:length of packet = %d\n", skb->len);
+
        pipe =
            usb_sndbulkpipe(pFt1000Dev->dev, pFt1000Dev->bulk_out_endpointAddr);
        maxlen = usb_maxpacket(pFt1000Dev->dev, pipe, usb_pipeout(pipe));
-       //DEBUG("ft1000_start_xmit 2: pipe=%d dev->maxpacket  = %d\n", pipe, maxlen);
 
        pdata = (u8 *) skb->data;
-       /*for (i=0; i<skb->len; i++)
-          DEBUG("skb->data[%d]=%x    ", i, *(skb->data+i));
-
-          DEBUG("\n"); */
 
        if (pInfo->mediastate == 0) {
                /* Drop packet is mediastate is down */
@@ -1060,13 +1021,12 @@ static int ft1000_start_xmit(struct sk_buff *skb, struct net_device *dev)
                DEBUG("ft1000_hw:ft1000_start_xmit:invalid ethernet length\n");
                goto err;
        }
-//mbelian
+
        ft1000_copy_down_pkt(dev, (pdata + ENET_HEADER_SIZE - 2),
                             skb->len - ENET_HEADER_SIZE + 2);
 
 err:
        dev_kfree_skb(skb);
-       //DEBUG(" ft1000_start_xmit() exit\n");
 
        return NETDEV_TX_OK;
 }
@@ -1093,24 +1053,20 @@ static int ft1000_copy_up_pkt(struct urb *urb)
 
        u16 tempword;
        u16 len;
-       u16 lena;               //mbelian
+       u16 lena;
        struct sk_buff *skb;
        u16 i;
        u8 *pbuffer = NULL;
        u8 *ptemp = NULL;
        u16 *chksum;
 
-       //DEBUG("ft1000_copy_up_pkt entered\n");
-
        if (ft1000dev->status & FT1000_STATUS_CLOSING) {
                DEBUG("network driver is closed, return\n");
                return STATUS_SUCCESS;
        }
        // Read length
        len = urb->transfer_buffer_length;
-       lena = urb->actual_length;      //mbelian
-       //DEBUG("ft1000_copy_up_pkt: transfer_buffer_length=%d, actual_buffer_len=%d\n",
-       //       urb->transfer_buffer_length, urb->actual_length);
+       lena = urb->actual_length;
 
        chksum = (u16 *) ft1000dev->rx_buf;
 
@@ -1124,8 +1080,6 @@ static int ft1000_copy_up_pkt(struct urb *urb)
                return STATUS_FAILURE;
        }
 
-       //DEBUG("ft1000_copy_up_pkt: checksum is correct %x\n", *chksum);
-
        skb = dev_alloc_skb(len + 12 + 2);
 
        if (skb == NULL) {
@@ -1157,12 +1111,6 @@ static int ft1000_copy_up_pkt(struct urb *urb)
        memcpy(pbuffer, ft1000dev->rx_buf + sizeof(struct pseudo_hdr),
               len - sizeof(struct pseudo_hdr));
 
-       //DEBUG("ft1000_copy_up_pkt: Data passed to Protocol layer\n");
-       /*for (i=0; i<len+12; i++)
-          {
-          DEBUG("ft1000_copy_up_pkt: Protocol Data: 0x%x\n ", *ptemp++);
-          } */
-
        skb->dev = net;
 
        skb->protocol = eth_type_trans(skb, net);
@@ -1171,10 +1119,10 @@ static int ft1000_copy_up_pkt(struct urb *urb)
 
        info->stats.rx_packets++;
        /* Add on 12 bytes for MAC address which was removed */
-       info->stats.rx_bytes += (lena + 12);    //mbelian
+       info->stats.rx_bytes += (lena + 12);
 
        ft1000_submit_rx_urb(info);
-       //DEBUG("ft1000_copy_up_pkt exited\n");
+
        return SUCCESS;
 }
 
@@ -1197,10 +1145,8 @@ static int ft1000_submit_rx_urb(struct ft1000_info *info)
        int result;
        struct ft1000_device *pFt1000Dev = info->pFt1000Dev;
 
-       //DEBUG ("ft1000_submit_rx_urb entered: sizeof rx_urb is %d\n", sizeof(*pFt1000Dev->rx_urb));
        if (pFt1000Dev->status & FT1000_STATUS_CLOSING) {
                DEBUG("network driver is closed, return\n");
-               //usb_kill_urb(pFt1000Dev->rx_urb); //mbelian
                return -ENODEV;
        }
 
@@ -1218,7 +1164,6 @@ static int ft1000_submit_rx_urb(struct ft1000_info *info)
                       result);
                return result;
        }
-       //DEBUG("ft1000_submit_rx_urb exit: result=%d\n", result);
 
        return 0;
 }
@@ -1241,23 +1186,22 @@ static int ft1000_submit_rx_urb(struct ft1000_info *info)
 static int ft1000_open(struct net_device *dev)
 {
        struct ft1000_info *pInfo = netdev_priv(dev);
-       struct timeval tv;      //mbelian
+       struct timeval tv;
        int ret;
 
        DEBUG("ft1000_open is called for card %d\n", pInfo->CardNumber);
-       //DEBUG("ft1000_open: dev->addr=%x, dev->addr_len=%d\n", dev->addr, dev->addr_len);
 
-       pInfo->stats.rx_bytes = 0;      //mbelian
-       pInfo->stats.tx_bytes = 0;      //mbelian
-       pInfo->stats.rx_packets = 0;    //mbelian
-       pInfo->stats.tx_packets = 0;    //mbelian
+       pInfo->stats.rx_bytes = 0;
+       pInfo->stats.tx_bytes = 0;
+       pInfo->stats.rx_packets = 0;
+       pInfo->stats.tx_packets = 0;
        do_gettimeofday(&tv);
        pInfo->ConTm = tv.tv_sec;
-       pInfo->ProgConStat = 0; //mbelian
+       pInfo->ProgConStat = 0;
 
        netif_start_queue(dev);
 
-       netif_carrier_on(dev);  //mbelian
+       netif_carrier_on(dev);
 
        ret = ft1000_submit_rx_urb(pInfo);
 
@@ -1283,19 +1227,14 @@ int ft1000_close(struct net_device *net)
        struct ft1000_info *pInfo = netdev_priv(net);
        struct ft1000_device *ft1000dev = pInfo->pFt1000Dev;
 
-       //DEBUG ("ft1000_close: netdev->refcnt=%d\n", net->refcnt);
-
        ft1000dev->status |= FT1000_STATUS_CLOSING;
 
-       //DEBUG("ft1000_close: calling usb_kill_urb \n");
-
        DEBUG("ft1000_close: pInfo=%p, ft1000dev=%p\n", pInfo, ft1000dev);
-       netif_carrier_off(net); //mbelian
+       netif_carrier_off(net);
        netif_stop_queue(net);
-       //DEBUG("ft1000_close: netif_stop_queue called\n");
        ft1000dev->status &= ~FT1000_STATUS_CLOSING;
 
-       pInfo->ProgConStat = 0xff;      //mbelian
+       pInfo->ProgConStat = 0xff;
 
        return 0;
 }
@@ -1304,15 +1243,10 @@ static struct net_device_stats *ft1000_netdev_stats(struct net_device *dev)
 {
        struct ft1000_info *info = netdev_priv(dev);
 
-       return &(info->stats); //mbelian
+       return &(info->stats);
 }
 
 
-/*********************************************************************************
-Jim
-*/
-
-
 //---------------------------------------------------------------------------
 //
 // Function:   ft1000_chkcard
@@ -1340,7 +1274,6 @@ static int ft1000_chkcard(struct ft1000_device *dev)
         * set to zero.
         */
        status = ft1000_read_register(dev, &tempword, FT1000_REG_SUP_IMASK);
-       //DEBUG("ft1000_hw:ft1000_chkcard: read FT1000_REG_SUP_IMASK = %x\n", tempword);
        if (tempword == 0) {
                DEBUG
                    ("ft1000_hw:ft1000_chkcard: IMASK = 0 Card not detected\n");
@@ -1350,9 +1283,8 @@ static int ft1000_chkcard(struct ft1000_device *dev)
         * if the device is not present.
         */
        status = ft1000_read_register(dev, &tempword, FT1000_REG_ASIC_ID);
-       //DEBUG("ft1000_hw:ft1000_chkcard: read FT1000_REG_ASIC_ID = %x\n", tempword);
        if (tempword != 0x1b01) {
-               dev->status |= FT1000_STATUS_CLOSING;   //mbelian
+               dev->status |= FT1000_STATUS_CLOSING;
                DEBUG
                    ("ft1000_hw:ft1000_chkcard: Version = 0xffff Card not detected\n");
                return FALSE;
@@ -1395,7 +1327,6 @@ static bool ft1000_receive_cmd(struct ft1000_device *dev, u16 *pbuffer,
                                      FT1000_REG_DPRAM_ADDR);
                ret =
                    ft1000_read_register(dev, pbuffer, FT1000_REG_MAG_DPDATAH);
-               //DEBUG("ft1000_hw:received data = 0x%x\n", *pbuffer);
                pbuffer++;
                ft1000_write_register(dev, FT1000_DPRAM_MAG_RX_BASE + 1,
                                      FT1000_REG_DPRAM_ADDR);
@@ -1412,11 +1343,11 @@ static bool ft1000_receive_cmd(struct ft1000_device *dev, u16 *pbuffer,
                /* copy odd aligned word */
                ret =
                    ft1000_read_register(dev, pbuffer, FT1000_REG_MAG_DPDATAL);
-               //DEBUG("ft1000_hw:received data = 0x%x\n", *pbuffer);
+
                pbuffer++;
                ret =
                    ft1000_read_register(dev, pbuffer, FT1000_REG_MAG_DPDATAH);
-               //DEBUG("ft1000_hw:received data = 0x%x\n", *pbuffer);
+
                pbuffer++;
                if (size & 0x0001) {
                        /* copy odd byte from fifo */
@@ -1495,10 +1426,8 @@ static int ft1000_dsp_prov(void *arg)
                        ppseudo_hdr->portsrc = 0;
                        /* Calculate new checksum */
                        ppseudo_hdr->checksum = *pmsg++;
-                       //DEBUG("checksum = 0x%x\n", ppseudo_hdr->checksum);
                        for (i = 1; i < 7; i++) {
                                ppseudo_hdr->checksum ^= *pmsg++;
-                               //DEBUG("checksum = 0x%x\n", ppseudo_hdr->checksum);
                        }
 
                        TempShortBuf[0] = 0;
@@ -1582,21 +1511,16 @@ static int ft1000_proc_drvmsg(struct ft1000_device *dev, u16 size)
                                        DEBUG("Media is up\n");
                                        if (info->mediastate == 0) {
                                                if (info->NetDevRegDone) {
-                                                       //netif_carrier_on(dev->net);//mbelian
                                                        netif_wake_queue(dev->
                                                                         net);
                                                }
                                                info->mediastate = 1;
-                                               /*do_gettimeofday(&tv);
-                                                  info->ConTm = tv.tv_sec; *///mbelian
                                        }
                                } else {
                                        DEBUG("Media is down\n");
                                        if (info->mediastate == 1) {
                                                info->mediastate = 0;
                                                if (info->NetDevRegDone) {
-                                                       //netif_carrier_off(dev->net); mbelian
-                                                       //netif_stop_queue(dev->net);
                                                }
                                                info->ConTm = 0;
                                        }
@@ -1605,10 +1529,6 @@ static int ft1000_proc_drvmsg(struct ft1000_device *dev, u16 size)
                                DEBUG("Media is down\n");
                                if (info->mediastate == 1) {
                                        info->mediastate = 0;
-                                       if (info->NetDevRegDone) {
-                                               //netif_carrier_off(dev->net); //mbelian
-                                               //netif_stop_queue(dev->net);
-                                       }
                                        info->ConTm = 0;
                                }
                        }
@@ -1860,31 +1780,26 @@ int ft1000_poll(void* dev_id) {
        struct pseudo_hdr *ppseudo_hdr;
     unsigned long flags;
 
-    //DEBUG("Enter ft1000_poll...\n");
     if (ft1000_chkcard(dev) == FALSE) {
         DEBUG("ft1000_poll::ft1000_chkcard: failed\n");
         return STATUS_FAILURE;
     }
 
     status = ft1000_read_register (dev, &tempword, FT1000_REG_DOORBELL);
-   // DEBUG("ft1000_poll: read FT1000_REG_DOORBELL message 0x%x\n", tempword);
 
     if ( !status )
     {
 
         if (tempword & FT1000_DB_DPRAM_RX) {
-            //DEBUG("ft1000_poll: FT1000_REG_DOORBELL message type:  FT1000_DB_DPRAM_RX\n");
 
             status = ft1000_read_dpram16(dev, 0x200, (u8 *)&data, 0);
-            //DEBUG("ft1000_poll:FT1000_DB_DPRAM_RX:ft1000_read_dpram16:size = 0x%x\n", data);
-            size = ntohs(data) + 16 + 2; //wai
+            size = ntohs(data) + 16 + 2;
             if (size % 4) {
                 modulo = 4 - (size % 4);
                 size = size + modulo;
             }
             status = ft1000_read_dpram16(dev, 0x201, (u8 *)&portid, 1);
             portid &= 0xff;
-            //DEBUG("ft1000_poll: FT1000_REG_DOORBELL message type: FT1000_DB_DPRAM_RX : portid 0x%x\n", portid);
 
             if (size < MAX_CMD_SQSIZE) {
                 switch (portid)
@@ -1899,13 +1814,11 @@ int ft1000_poll(void* dev_id) {
                     case DSPBCMSGID:
                         // This is a dsp broadcast message
                         // Check which application has registered for dsp broadcast messages
-                        //DEBUG("ft1000_poll: FT1000_REG_DOORBELL message type: FT1000_DB_DPRAM_RX : portid DSPBCMSGID\n");
 
                        for (i=0; i<MAX_NUM_APP; i++) {
                           if ( (info->app_info[i].DspBCMsgFlag) && (info->app_info[i].fileobject) &&
                                          (info->app_info[i].NumOfMsg < MAX_MSG_LIMIT)  )
                           {
-                              //DEBUG("Dsp broadcast message detected for app id %d\n", i);
                               nxtph = FT1000_DPRAM_RX_BASE + 2;
                               pdpram_blk = ft1000_get_buffer (&freercvpool);
                               if (pdpram_blk != NULL) {
@@ -1929,15 +1842,13 @@ int ft1000_poll(void* dev_id) {
                                else {
                                    DEBUG("Out of memory in free receive command pool\n");
                                    info->app_info[i].nRxMsgMiss++;
-                               }//endof if (pdpram_blk != NULL)
-                           }//endof if
-                          //else
-                          //    DEBUG("app_info mismatch\n");
-                       }// endof for
+                               }
+                           }
+                       }
                         break;
                     default:
                         pdpram_blk = ft1000_get_buffer (&freercvpool);
-                        //DEBUG("Memory allocated = 0x%8x\n", (u32)pdpram_blk);
+
                         if (pdpram_blk != NULL) {
                            if ( ft1000_receive_cmd(dev, pdpram_blk->pbuffer, MAX_CMD_SQSIZE, &nxtph) ) {
                                ppseudo_hdr = (struct pseudo_hdr *)pdpram_blk->pbuffer;
@@ -1961,11 +1872,8 @@ int ft1000_poll(void* dev_id) {
                                    else {
                                        info->app_info[i].nRxMsg++;
                                        // Put message into the appropriate application block
-                                       //pxu spin_lock_irqsave(&free_buff_lock, flags);
                                        list_add_tail(&pdpram_blk->list, &info->app_info[i].app_sqlist);
                                       info->app_info[i].NumOfMsg++;
-                                       //pxu spin_unlock_irqrestore(&free_buff_lock, flags);
-                                       //pxu wake_up_interruptible(&info->app_info[i].wait_dpram_msg);
                                    }
                                }
                            }
@@ -1978,15 +1886,14 @@ int ft1000_poll(void* dev_id) {
                             DEBUG("Out of memory in free receive command pool\n");
                         }
                         break;
-                } //end of switch
-            } //endof if (size < MAX_CMD_SQSIZE)
+                }
+            }
             else {
                 DEBUG("FT1000:dpc:Invalid total length for SlowQ = %d\n", size);
             }
             status = ft1000_write_register (dev, FT1000_DB_DPRAM_RX, FT1000_REG_DOORBELL);
         }
         else if (tempword & FT1000_DSP_ASIC_RESET) {
-            //DEBUG("ft1000_poll: FT1000_REG_DOORBELL message type:  FT1000_DSP_ASIC_RESET\n");
 
             // Let's reset the ASIC from the Host side as well
             status = ft1000_write_register (dev, ASIC_RESET_BIT, FT1000_REG_RESET);
@@ -2025,10 +1932,8 @@ int ft1000_poll(void* dev_id) {
         }
         else if (tempword & FT1000_DB_COND_RESET) {
             DEBUG("ft1000_poll: FT1000_REG_DOORBELL message type:  FT1000_DB_COND_RESET\n");
-//By Jim
-// Reset ASIC and DSP
-//MAG
-            if (info->fAppMsgPend == 0) {
+
+           if (info->fAppMsgPend == 0) {
                // Reset ASIC and DSP
 
                 status    = ft1000_read_dpram16(dev, FT1000_MAG_DSP_TIMER0, (u8 *)&(info->DSP_TIME[0]), FT1000_MAG_DSP_TIMER0_INDX);
@@ -2048,11 +1953,8 @@ int ft1000_poll(void* dev_id) {
             ft1000_write_register(dev, FT1000_DB_COND_RESET, FT1000_REG_DOORBELL);
         }
 
-    }//endof if ( !status )
+    }
 
-    //DEBUG("return from ft1000_poll.\n");
     return STATUS_SUCCESS;
 
 }
-
-/*end of Jim*/
index f2ecb3eae9cdf5eb044330ecc1bce6388924e957..0b30020c7548d465d6472ba923708870460cbf10 100644 (file)
@@ -494,21 +494,9 @@ struct ft1000_info {
     bool fProvComplete;
     bool fCondResetPend;
     bool fAppMsgPend;
-    char *pfwimg;
-    int fwimgsz;
     u16 DrvErrNum;
-    u8  *pTestImage;
     u16 AsicID;
-    unsigned long TestImageIndx;
-    unsigned long TestImageSz;
-    u8  TestImageEnable;
-    u8  TestImageReady;
-    int ASICResetNum;
     int DspAsicReset;
-    int PktIntfErr;
-    int DSPResetNum;
-    int NumIOCTLBufs;
-    int IOCTLBufLvl;
     int DeviceCreated;
     int CardReady;
     int NetDevRegDone;
@@ -517,13 +505,9 @@ struct ft1000_info {
     struct ft1000_debug_dirs nodes;
     int registered;
     int mediastate;
-    int dhcpflg;
-    u16 packetseqnum;
     u8 squeseqnum;                 // sequence number on slow queue
     spinlock_t dpram_lock;
     spinlock_t fifo_lock;
-    u16 CurrentInterruptEnableMask;
-    int InterruptsEnabled;
     u16 fifo_cnt;
     u8 DspVer[DSPVERSZ];        // DSP version number
     u8 HwSerNum[HWSERNUMSZ];    // Hardware Serial Number
@@ -534,7 +518,6 @@ struct ft1000_info {
     u8 RfCalVer[CALVERSZ];
     u8 RfCalDate[CALDATESZ];
     u16 DSP_TIME[4];
-    u16 ProgSnr;
     u16 LedStat;       //mbelian
     u16 ConStat;       //mbelian
     u16 ProgConStat;
@@ -586,8 +569,6 @@ extern void card_send_command(struct ft1000_device *ft1000dev, void *ptempbuffer
 struct dpram_blk *ft1000_get_buffer(struct list_head *bufflist);
 void ft1000_free_buffer(struct dpram_blk *pdpram_blk, struct list_head *plist);
 
-char *getfw (char *fn, size_t *pimgsz);
-
 int dsp_reload(struct ft1000_device *ft1000dev);
 int init_ft1000_netdev(struct ft1000_device *ft1000dev);
 struct usb_interface;
index a52ba48be518d59ba2572ffe0ebf2f130631513c..db73ec6d81281f55f2704ee898648dd1696aaa63 100644 (file)
@@ -5,6 +5,7 @@ ccflags-y += -Iinclude/drm
 
 psb_gfx-y += psb_bl.o \
          psb_drv.o \
+         psb_gem.o \
          psb_fb.o \
          psb_2d.o \
          psb_gtt.o \
@@ -15,17 +16,11 @@ psb_gfx-y += psb_bl.o \
          psb_intel_lvds.o \
          psb_intel_modes.o \
          psb_intel_sdvo.o \
-         psb_reset.o \
-         psb_sgx.o \
-         psb_pvr_glue.o \
-         psb_buffer.o \
-         psb_fence.o \
+         psb_lid.o \
          psb_mmu.o \
-         psb_ttm_glue.o \
-         psb_ttm_fence.o \
-         psb_ttm_fence_user.o \
-         psb_ttm_placement_user.o \
          psb_powermgmt.o \
-         psb_irq.o
+         psb_irq.o \
+         mrst_crtc.o \
+         mrst_lvds.o
 
 obj-$(CONFIG_DRM_PSB) += psb_gfx.o
diff --git a/drivers/staging/gma500/mrst.h b/drivers/staging/gma500/mrst.h
new file mode 100644 (file)
index 0000000..5e4aaeb
--- /dev/null
@@ -0,0 +1,217 @@
+/**************************************************************************
+ * Copyright (c) 2007-2011, Intel Corporation.
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ **************************************************************************/
+
+/* MID device specific descriptors */
+
+struct mrst_vbt {
+       s8 signature[4];        /*4 bytes,"$GCT" */
+       u8 revision;
+       u8 size;
+       u8 checksum;
+       void *mrst_gct;
+} __attribute__ ((packed));
+
+struct mrst_timing_info {
+       u16 pixel_clock;
+       u8 hactive_lo;
+       u8 hblank_lo;
+       u8 hblank_hi:4;
+       u8 hactive_hi:4;
+       u8 vactive_lo;
+       u8 vblank_lo;
+       u8 vblank_hi:4;
+       u8 vactive_hi:4;
+       u8 hsync_offset_lo;
+       u8 hsync_pulse_width_lo;
+       u8 vsync_pulse_width_lo:4;
+       u8 vsync_offset_lo:4;
+       u8 vsync_pulse_width_hi:2;
+       u8 vsync_offset_hi:2;
+       u8 hsync_pulse_width_hi:2;
+       u8 hsync_offset_hi:2;
+       u8 width_mm_lo;
+       u8 height_mm_lo;
+       u8 height_mm_hi:4;
+       u8 width_mm_hi:4;
+       u8 hborder;
+       u8 vborder;
+       u8 unknown0:1;
+       u8 hsync_positive:1;
+       u8 vsync_positive:1;
+       u8 separate_sync:2;
+       u8 stereo:1;
+       u8 unknown6:1;
+       u8 interlaced:1;
+} __attribute__((packed));
+
+struct gct_r10_timing_info {
+       u16 pixel_clock;
+       u32 hactive_lo:8;
+       u32 hactive_hi:4;
+       u32 hblank_lo:8;
+       u32 hblank_hi:4;
+       u32 hsync_offset_lo:8;
+       u16 hsync_offset_hi:2;
+       u16 hsync_pulse_width_lo:8;
+       u16 hsync_pulse_width_hi:2;
+       u16 hsync_positive:1;
+       u16 rsvd_1:3;
+       u8  vactive_lo:8;
+       u16 vactive_hi:4;
+       u16 vblank_lo:8;
+       u16 vblank_hi:4;
+       u16 vsync_offset_lo:4;
+       u16 vsync_offset_hi:2;
+       u16 vsync_pulse_width_lo:4;
+       u16 vsync_pulse_width_hi:2;
+       u16 vsync_positive:1;
+       u16 rsvd_2:3;
+} __attribute__((packed));
+
+struct mrst_panel_descriptor_v1 {
+       u32 Panel_Port_Control; /* 1 dword, Register 0x61180 if LVDS */
+                               /* 0x61190 if MIPI */
+       u32 Panel_Power_On_Sequencing;/*1 dword,Register 0x61208,*/
+       u32 Panel_Power_Off_Sequencing;/*1 dword,Register 0x6120C,*/
+       u32 Panel_Power_Cycle_Delay_and_Reference_Divisor;/* 1 dword */
+                                               /* Register 0x61210 */
+       struct mrst_timing_info DTD;/*18 bytes, Standard definition */
+       u16 Panel_Backlight_Inverter_Descriptor;/* 16 bits, as follows */
+                               /* Bit 0, Frequency, 15 bits,0 - 32767Hz */
+                       /* Bit 15, Polarity, 1 bit, 0: Normal, 1: Inverted */
+       u16 Panel_MIPI_Display_Descriptor;
+                       /*16 bits, Defined as follows: */
+                       /* if MIPI, 0x0000 if LVDS */
+                       /* Bit 0, Type, 2 bits, */
+                       /* 0: Type-1, */
+                       /* 1: Type-2, */
+                       /* 2: Type-3, */
+                       /* 3: Type-4 */
+                       /* Bit 2, Pixel Format, 4 bits */
+                       /* Bit0: 16bpp (not supported in LNC), */
+                       /* Bit1: 18bpp loosely packed, */
+                       /* Bit2: 18bpp packed, */
+                       /* Bit3: 24bpp */
+                       /* Bit 6, Reserved, 2 bits, 00b */
+                       /* Bit 8, Minimum Supported Frame Rate, 6 bits, 0 - 63Hz */
+                       /* Bit 14, Reserved, 2 bits, 00b */
+} __attribute__ ((packed));
+
+struct mrst_panel_descriptor_v2 {
+       u32 Panel_Port_Control; /* 1 dword, Register 0x61180 if LVDS */
+                               /* 0x61190 if MIPI */
+       u32 Panel_Power_On_Sequencing;/*1 dword,Register 0x61208,*/
+       u32 Panel_Power_Off_Sequencing;/*1 dword,Register 0x6120C,*/
+       u8 Panel_Power_Cycle_Delay_and_Reference_Divisor;/* 1 byte */
+                                               /* Register 0x61210 */
+       struct mrst_timing_info DTD;/*18 bytes, Standard definition */
+       u16 Panel_Backlight_Inverter_Descriptor;/*16 bits, as follows*/
+                               /*Bit 0, Frequency, 16 bits, 0 - 32767Hz*/
+       u8 Panel_Initial_Brightness;/* [7:0] 0 - 100% */
+                       /*Bit 7, Polarity, 1 bit,0: Normal, 1: Inverted*/
+       u16 Panel_MIPI_Display_Descriptor;
+                       /*16 bits, Defined as follows: */
+                       /* if MIPI, 0x0000 if LVDS */
+                       /* Bit 0, Type, 2 bits, */
+                       /* 0: Type-1, */
+                       /* 1: Type-2, */
+                       /* 2: Type-3, */
+                       /* 3: Type-4 */
+                       /* Bit 2, Pixel Format, 4 bits */
+                       /* Bit0: 16bpp (not supported in LNC), */
+                       /* Bit1: 18bpp loosely packed, */
+                       /* Bit2: 18bpp packed, */
+                       /* Bit3: 24bpp */
+                       /* Bit 6, Reserved, 2 bits, 00b */
+                       /* Bit 8, Minimum Supported Frame Rate, 6 bits, 0 - 63Hz */
+                       /* Bit 14, Reserved, 2 bits, 00b */
+} __attribute__ ((packed));
+
+union mrst_panel_rx {
+       struct{
+               u16 NumberOfLanes:2; /*Num of Lanes, 2 bits,0 = 1 lane,*/
+                       /* 1 = 2 lanes, 2 = 3 lanes, 3 = 4 lanes. */
+               u16 MaxLaneFreq:3; /* 0: 100MHz, 1: 200MHz, 2: 300MHz, */
+               /*3: 400MHz, 4: 500MHz, 5: 600MHz, 6: 700MHz, 7: 800MHz.*/
+               u16 SupportedVideoTransferMode:2; /*0: Non-burst only */
+                                       /* 1: Burst and non-burst */
+                                       /* 2/3: Reserved */
+               u16 HSClkBehavior:1; /*0: Continuous, 1: Non-continuous*/
+               u16 DuoDisplaySupport:1; /*1 bit,0: No, 1: Yes*/
+               u16 ECC_ChecksumCapabilities:1;/*1 bit,0: No, 1: Yes*/
+               u16 BidirectionalCommunication:1;/*1 bit,0: No, 1: Yes */
+               u16 Rsvd:5;/*5 bits,00000b */
+       } panelrx;
+       u16 panel_receiver;
+} __attribute__ ((packed));
+
+struct mrst_gct_v1 {
+       union{ /*8 bits,Defined as follows: */
+               struct {
+                       u8 PanelType:4; /*4 bits, Bit field for panels*/
+                                       /* 0 - 3: 0 = LVDS, 1 = MIPI*/
+                                       /*2 bits,Specifies which of the*/
+                       u8 BootPanelIndex:2;
+                                       /* 4 panels to use by default*/
+                       u8 BootMIPI_DSI_RxIndex:2;/*Specifies which of*/
+                                       /* the 4 MIPI DSI receivers to use*/
+               } PD;
+               u8 PanelDescriptor;
+       };
+       struct mrst_panel_descriptor_v1 panel[4];/*panel descrs,38 bytes each*/
+       union mrst_panel_rx panelrx[4]; /* panel receivers*/
+} __attribute__ ((packed));
+
+struct mrst_gct_v2 {
+       union{ /*8 bits,Defined as follows: */
+               struct {
+                       u8 PanelType:4; /*4 bits, Bit field for panels*/
+                                       /* 0 - 3: 0 = LVDS, 1 = MIPI*/
+                                       /*2 bits,Specifies which of the*/
+                       u8 BootPanelIndex:2;
+                                       /* 4 panels to use by default*/
+                       u8 BootMIPI_DSI_RxIndex:2;/*Specifies which of*/
+                                       /* the 4 MIPI DSI receivers to use*/
+               } PD;
+               u8 PanelDescriptor;
+       };
+       struct mrst_panel_descriptor_v2 panel[4];/*panel descrs,38 bytes each*/
+       union mrst_panel_rx panelrx[4]; /* panel receivers*/
+} __attribute__ ((packed));
+
+struct mrst_gct_data {
+       u8 bpi; /* boot panel index, number of panel used during boot */
+       u8 pt; /* panel type, 4 bit field, 0=lvds, 1=mipi */
+       struct mrst_timing_info DTD; /* timing info for the selected panel */
+       u32 Panel_Port_Control;
+       u32 PP_On_Sequencing;/*1 dword,Register 0x61208,*/
+       u32 PP_Off_Sequencing;/*1 dword,Register 0x6120C,*/
+       u32 PP_Cycle_Delay;
+       u16 Panel_Backlight_Inverter_Descriptor;
+       u16 Panel_MIPI_Display_Descriptor;
+} __attribute__ ((packed));
+
+#define MODE_SETTING_IN_CRTC   0x1
+#define MODE_SETTING_IN_ENCODER 0x2
+#define MODE_SETTING_ON_GOING  0x3
+#define MODE_SETTING_IN_DSR    0x4
+#define MODE_SETTING_ENCODER_DONE 0x8
+#define GCT_R10_HEADER_SIZE    16
+#define GCT_R10_DISPLAY_DESC_SIZE      28
+
diff --git a/drivers/staging/gma500/mrst_crtc.c b/drivers/staging/gma500/mrst_crtc.c
new file mode 100644 (file)
index 0000000..e4a0c03
--- /dev/null
@@ -0,0 +1,619 @@
+/*
+ * Copyright © 2009 Intel Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <linux/i2c.h>
+#include <linux/pm_runtime.h>
+
+#include <drm/drmP.h>
+#include "psb_fb.h"
+#include "psb_drv.h"
+#include "psb_intel_drv.h"
+#include "psb_intel_reg.h"
+#include "psb_intel_display.h"
+#include "psb_powermgmt.h"
+
+struct psb_intel_range_t {
+       int min, max;
+};
+
+struct mrst_limit_t {
+       struct psb_intel_range_t dot, m, p1;
+};
+
+struct mrst_clock_t {
+       /* derived values */
+       int dot;
+       int m;
+       int p1;
+};
+
+#define MRST_LIMIT_LVDS_100L       0
+#define MRST_LIMIT_LVDS_83         1
+#define MRST_LIMIT_LVDS_100        2
+
+#define MRST_DOT_MIN             19750
+#define MRST_DOT_MAX             120000
+#define MRST_M_MIN_100L                    20
+#define MRST_M_MIN_100             10
+#define MRST_M_MIN_83              12
+#define MRST_M_MAX_100L                    34
+#define MRST_M_MAX_100             17
+#define MRST_M_MAX_83              20
+#define MRST_P1_MIN                2
+#define MRST_P1_MAX_0              7
+#define MRST_P1_MAX_1              8
+
+static const struct mrst_limit_t mrst_limits[] = {
+       {                       /* MRST_LIMIT_LVDS_100L */
+        .dot = {.min = MRST_DOT_MIN, .max = MRST_DOT_MAX},
+        .m = {.min = MRST_M_MIN_100L, .max = MRST_M_MAX_100L},
+        .p1 = {.min = MRST_P1_MIN, .max = MRST_P1_MAX_1},
+        },
+       {                       /* MRST_LIMIT_LVDS_83L */
+        .dot = {.min = MRST_DOT_MIN, .max = MRST_DOT_MAX},
+        .m = {.min = MRST_M_MIN_83, .max = MRST_M_MAX_83},
+        .p1 = {.min = MRST_P1_MIN, .max = MRST_P1_MAX_0},
+        },
+       {                       /* MRST_LIMIT_LVDS_100 */
+        .dot = {.min = MRST_DOT_MIN, .max = MRST_DOT_MAX},
+        .m = {.min = MRST_M_MIN_100, .max = MRST_M_MAX_100},
+        .p1 = {.min = MRST_P1_MIN, .max = MRST_P1_MAX_1},
+        },
+};
+
+#define MRST_M_MIN         10
+static const u32 mrst_m_converts[] = {
+       0x2B, 0x15, 0x2A, 0x35, 0x1A, 0x0D, 0x26, 0x33, 0x19, 0x2C,
+       0x36, 0x3B, 0x1D, 0x2E, 0x37, 0x1B, 0x2D, 0x16, 0x0B, 0x25,
+       0x12, 0x09, 0x24, 0x32, 0x39, 0x1c,
+};
+
+static const struct mrst_limit_t *mrst_limit(struct drm_crtc *crtc)
+{
+       const struct mrst_limit_t *limit = NULL;
+       struct drm_device *dev = crtc->dev;
+       DRM_DRIVER_PRIVATE_T *dev_priv = dev->dev_private;
+
+       if (psb_intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS)
+           || psb_intel_pipe_has_type(crtc, INTEL_OUTPUT_MIPI)) {
+               switch (dev_priv->core_freq) {
+               case 100:
+                       limit = &mrst_limits[MRST_LIMIT_LVDS_100L];
+                       break;
+               case 166:
+                       limit = &mrst_limits[MRST_LIMIT_LVDS_83];
+                       break;
+               case 200:
+                       limit = &mrst_limits[MRST_LIMIT_LVDS_100];
+                       break;
+               }
+       } else {
+               limit = NULL;
+               PSB_DEBUG_ENTRY("mrst_limit Wrong display type.\n");
+       }
+
+       return limit;
+}
+
+/** Derive the pixel clock for the given refclk and divisors for 8xx chips. */
+static void mrst_clock(int refclk, struct mrst_clock_t *clock)
+{
+       clock->dot = (refclk * clock->m) / (14 * clock->p1);
+}
+
+void mrstPrintPll(char *prefix, struct mrst_clock_t *clock)
+{
+       PSB_DEBUG_ENTRY("%s: dotclock = %d,  m = %d, p1 = %d.\n",
+            prefix, clock->dot, clock->m, clock->p1);
+}
+
+/**
+ * Returns a set of divisors for the desired target clock with the given refclk,
+ * or FALSE.  Divisor values are the actual divisors for
+ */
+static bool
+mrstFindBestPLL(struct drm_crtc *crtc, int target, int refclk,
+               struct mrst_clock_t *best_clock)
+{
+       struct mrst_clock_t clock;
+       const struct mrst_limit_t *limit = mrst_limit(crtc);
+       int err = target;
+
+       memset(best_clock, 0, sizeof(*best_clock));
+
+       for (clock.m = limit->m.min; clock.m <= limit->m.max; clock.m++) {
+               for (clock.p1 = limit->p1.min; clock.p1 <= limit->p1.max;
+                    clock.p1++) {
+                       int this_err;
+
+                       mrst_clock(refclk, &clock);
+
+                       this_err = abs(clock.dot - target);
+                       if (this_err < err) {
+                               *best_clock = clock;
+                               err = this_err;
+                       }
+               }
+       }
+       DRM_DEBUG("mrstFindBestPLL err = %d.\n", err);
+
+       return err != target;
+}
+
+/**
+ * Sets the power management mode of the pipe and plane.
+ *
+ * This code should probably grow support for turning the cursor off and back
+ * on appropriately at the same time as we're turning the pipe off/on.
+ */
+static void mrst_crtc_dpms(struct drm_crtc *crtc, int mode)
+{
+       struct drm_device *dev = crtc->dev;
+       struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc);
+       int pipe = psb_intel_crtc->pipe;
+       int dpll_reg = (pipe == 0) ? MRST_DPLL_A : DPLL_B;
+       int dspcntr_reg = (pipe == 0) ? DSPACNTR : DSPBCNTR;
+       int dspbase_reg = (pipe == 0) ? MRST_DSPABASE : DSPBBASE;
+       int pipeconf_reg = (pipe == 0) ? PIPEACONF : PIPEBCONF;
+       u32 temp;
+       bool enabled;
+
+       PSB_DEBUG_ENTRY("mode = %d, pipe = %d\n", mode, pipe);
+
+       if (!gma_power_begin(dev, true))
+               return;
+
+       /* XXX: When our outputs are all unaware of DPMS modes other than off
+        * and on, we should map those modes to DRM_MODE_DPMS_OFF in the CRTC.
+        */
+       switch (mode) {
+       case DRM_MODE_DPMS_ON:
+       case DRM_MODE_DPMS_STANDBY:
+       case DRM_MODE_DPMS_SUSPEND:
+               /* Enable the DPLL */
+               temp = REG_READ(dpll_reg);
+               if ((temp & DPLL_VCO_ENABLE) == 0) {
+                       REG_WRITE(dpll_reg, temp);
+                       REG_READ(dpll_reg);
+                       /* Wait for the clocks to stabilize. */
+                       udelay(150);
+                       REG_WRITE(dpll_reg, temp | DPLL_VCO_ENABLE);
+                       REG_READ(dpll_reg);
+                       /* Wait for the clocks to stabilize. */
+                       udelay(150);
+                       REG_WRITE(dpll_reg, temp | DPLL_VCO_ENABLE);
+                       REG_READ(dpll_reg);
+                       /* Wait for the clocks to stabilize. */
+                       udelay(150);
+               }
+               /* Enable the pipe */
+               temp = REG_READ(pipeconf_reg);
+               if ((temp & PIPEACONF_ENABLE) == 0)
+                       REG_WRITE(pipeconf_reg, temp | PIPEACONF_ENABLE);
+               /* Enable the plane */
+               temp = REG_READ(dspcntr_reg);
+               if ((temp & DISPLAY_PLANE_ENABLE) == 0) {
+                       REG_WRITE(dspcntr_reg,
+                                 temp | DISPLAY_PLANE_ENABLE);
+                       /* Flush the plane changes */
+                       REG_WRITE(dspbase_reg, REG_READ(dspbase_reg));
+               }
+
+               psb_intel_crtc_load_lut(crtc);
+
+               /* Give the overlay scaler a chance to enable
+                  if it's on this pipe */
+               /* psb_intel_crtc_dpms_video(crtc, true); TODO */
+               break;
+       case DRM_MODE_DPMS_OFF:
+               /* Give the overlay scaler a chance to disable
+                * if it's on this pipe */
+               /* psb_intel_crtc_dpms_video(crtc, FALSE); TODO */
+
+               /* Disable the VGA plane that we never use */
+               REG_WRITE(VGACNTRL, VGA_DISP_DISABLE);
+               /* Disable display plane */
+               temp = REG_READ(dspcntr_reg);
+               if ((temp & DISPLAY_PLANE_ENABLE) != 0) {
+                       REG_WRITE(dspcntr_reg,
+                                 temp & ~DISPLAY_PLANE_ENABLE);
+                       /* Flush the plane changes */
+                       REG_WRITE(dspbase_reg, REG_READ(dspbase_reg));
+                       REG_READ(dspbase_reg);
+               }
+
+               /* Next, disable display pipes */
+               temp = REG_READ(pipeconf_reg);
+               if ((temp & PIPEACONF_ENABLE) != 0) {
+                       REG_WRITE(pipeconf_reg, temp & ~PIPEACONF_ENABLE);
+                       REG_READ(pipeconf_reg);
+               }
+               /* Wait for for the pipe disable to take effect. */
+               psb_intel_wait_for_vblank(dev);
+
+               temp = REG_READ(dpll_reg);
+               if ((temp & DPLL_VCO_ENABLE) != 0) {
+                       REG_WRITE(dpll_reg, temp & ~DPLL_VCO_ENABLE);
+                       REG_READ(dpll_reg);
+               }
+
+               /* Wait for the clocks to turn off. */
+               udelay(150);
+               break;
+       }
+
+       enabled = crtc->enabled && mode != DRM_MODE_DPMS_OFF;
+
+       /*Set FIFO Watermarks*/
+       REG_WRITE(DSPARB, 0x3FFF);
+       REG_WRITE(DSPFW1, 0x3F88080A);
+       REG_WRITE(DSPFW2, 0x0b060808);
+       REG_WRITE(DSPFW3, 0x0);
+       REG_WRITE(DSPFW4, 0x08030404);
+       REG_WRITE(DSPFW5, 0x04040404);
+       REG_WRITE(DSPFW6, 0x78);
+       REG_WRITE(0x70400, REG_READ(0x70400) | 0x4000);
+       /* Must write Bit 14 of the Chicken Bit Register */
+
+       gma_power_end(dev);
+}
+
+/**
+ * Return the pipe currently connected to the panel fitter,
+ * or -1 if the panel fitter is not present or not in use
+ */
+static int mrst_panel_fitter_pipe(struct drm_device *dev)
+{
+       u32 pfit_control;
+
+       pfit_control = REG_READ(PFIT_CONTROL);
+
+       /* See if the panel fitter is in use */
+       if ((pfit_control & PFIT_ENABLE) == 0)
+               return -1;
+       return (pfit_control >> 29) & 3;
+}
+
+static int mrst_crtc_mode_set(struct drm_crtc *crtc,
+                             struct drm_display_mode *mode,
+                             struct drm_display_mode *adjusted_mode,
+                             int x, int y,
+                             struct drm_framebuffer *old_fb)
+{
+       struct drm_device *dev = crtc->dev;
+       struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc);
+       DRM_DRIVER_PRIVATE_T *dev_priv = dev->dev_private;
+       int pipe = psb_intel_crtc->pipe;
+       int fp_reg = (pipe == 0) ? MRST_FPA0 : FPB0;
+       int dpll_reg = (pipe == 0) ? MRST_DPLL_A : DPLL_B;
+       int dspcntr_reg = (pipe == 0) ? DSPACNTR : DSPBCNTR;
+       int pipeconf_reg = (pipe == 0) ? PIPEACONF : PIPEBCONF;
+       int htot_reg = (pipe == 0) ? HTOTAL_A : HTOTAL_B;
+       int hblank_reg = (pipe == 0) ? HBLANK_A : HBLANK_B;
+       int hsync_reg = (pipe == 0) ? HSYNC_A : HSYNC_B;
+       int vtot_reg = (pipe == 0) ? VTOTAL_A : VTOTAL_B;
+       int vblank_reg = (pipe == 0) ? VBLANK_A : VBLANK_B;
+       int vsync_reg = (pipe == 0) ? VSYNC_A : VSYNC_B;
+       int pipesrc_reg = (pipe == 0) ? PIPEASRC : PIPEBSRC;
+       int refclk = 0;
+       struct mrst_clock_t clock;
+       u32 dpll = 0, fp = 0, dspcntr, pipeconf;
+       bool ok, is_sdvo = false;
+       bool is_crt = false, is_lvds = false, is_tv = false;
+       bool is_mipi = false;
+       struct drm_mode_config *mode_config = &dev->mode_config;
+       struct psb_intel_output *psb_intel_output = NULL;
+       uint64_t scalingType = DRM_MODE_SCALE_FULLSCREEN;
+       struct drm_encoder *encoder;
+
+       PSB_DEBUG_ENTRY("pipe = 0x%x\n", pipe);
+
+       if (!gma_power_begin(dev, true))
+               return 0;
+
+       memcpy(&psb_intel_crtc->saved_mode,
+               mode,
+               sizeof(struct drm_display_mode));
+       memcpy(&psb_intel_crtc->saved_adjusted_mode,
+               adjusted_mode,
+               sizeof(struct drm_display_mode));
+
+       list_for_each_entry(encoder, &mode_config->encoder_list, head) {
+
+               if (encoder->crtc != crtc)
+                       continue;
+
+               psb_intel_output = enc_to_psb_intel_output(encoder);
+               switch (psb_intel_output->type) {
+               case INTEL_OUTPUT_LVDS:
+                       is_lvds = true;
+                       break;
+               case INTEL_OUTPUT_SDVO:
+                       is_sdvo = true;
+                       break;
+               case INTEL_OUTPUT_TVOUT:
+                       is_tv = true;
+                       break;
+               case INTEL_OUTPUT_ANALOG:
+                       is_crt = true;
+                       break;
+               case INTEL_OUTPUT_MIPI:
+                       is_mipi = true;
+                       break;
+               }
+       }
+
+       /* Disable the VGA plane that we never use */
+       REG_WRITE(VGACNTRL, VGA_DISP_DISABLE);
+
+       /* Disable the panel fitter if it was on our pipe */
+       if (mrst_panel_fitter_pipe(dev) == pipe)
+               REG_WRITE(PFIT_CONTROL, 0);
+
+       REG_WRITE(pipesrc_reg,
+                 ((mode->crtc_hdisplay - 1) << 16) |
+                 (mode->crtc_vdisplay - 1));
+
+       if (psb_intel_output)
+               drm_connector_property_get_value(&psb_intel_output->base,
+                       dev->mode_config.scaling_mode_property, &scalingType);
+
+       if (scalingType == DRM_MODE_SCALE_NO_SCALE) {
+               /* Moorestown doesn't have register support for centering so
+                * we need to mess with the h/vblank and h/vsync start and
+                * ends to get centering */
+               int offsetX = 0, offsetY = 0;
+
+               offsetX = (adjusted_mode->crtc_hdisplay -
+                          mode->crtc_hdisplay) / 2;
+               offsetY = (adjusted_mode->crtc_vdisplay -
+                          mode->crtc_vdisplay) / 2;
+
+               REG_WRITE(htot_reg, (mode->crtc_hdisplay - 1) |
+                       ((adjusted_mode->crtc_htotal - 1) << 16));
+               REG_WRITE(vtot_reg, (mode->crtc_vdisplay - 1) |
+                       ((adjusted_mode->crtc_vtotal - 1) << 16));
+               REG_WRITE(hblank_reg,
+                       (adjusted_mode->crtc_hblank_start - offsetX - 1) |
+                       ((adjusted_mode->crtc_hblank_end - offsetX - 1) << 16));
+               REG_WRITE(hsync_reg,
+                       (adjusted_mode->crtc_hsync_start - offsetX - 1) |
+                       ((adjusted_mode->crtc_hsync_end - offsetX - 1) << 16));
+               REG_WRITE(vblank_reg,
+                       (adjusted_mode->crtc_vblank_start - offsetY - 1) |
+                       ((adjusted_mode->crtc_vblank_end - offsetY - 1) << 16));
+               REG_WRITE(vsync_reg,
+                       (adjusted_mode->crtc_vsync_start - offsetY - 1) |
+                       ((adjusted_mode->crtc_vsync_end - offsetY - 1) << 16));
+       } else {
+               REG_WRITE(htot_reg, (adjusted_mode->crtc_hdisplay - 1) |
+                       ((adjusted_mode->crtc_htotal - 1) << 16));
+               REG_WRITE(vtot_reg, (adjusted_mode->crtc_vdisplay - 1) |
+                       ((adjusted_mode->crtc_vtotal - 1) << 16));
+               REG_WRITE(hblank_reg, (adjusted_mode->crtc_hblank_start - 1) |
+                       ((adjusted_mode->crtc_hblank_end - 1) << 16));
+               REG_WRITE(hsync_reg, (adjusted_mode->crtc_hsync_start - 1) |
+                       ((adjusted_mode->crtc_hsync_end - 1) << 16));
+               REG_WRITE(vblank_reg, (adjusted_mode->crtc_vblank_start - 1) |
+                       ((adjusted_mode->crtc_vblank_end - 1) << 16));
+               REG_WRITE(vsync_reg, (adjusted_mode->crtc_vsync_start - 1) |
+                       ((adjusted_mode->crtc_vsync_end - 1) << 16));
+       }
+
+       /* Flush the plane changes */
+       {
+               struct drm_crtc_helper_funcs *crtc_funcs =
+                   crtc->helper_private;
+               crtc_funcs->mode_set_base(crtc, x, y, old_fb);
+       }
+
+       /* setup pipeconf */
+       pipeconf = REG_READ(pipeconf_reg);
+
+       /* Set up the display plane register */
+       dspcntr = REG_READ(dspcntr_reg);
+       dspcntr |= DISPPLANE_GAMMA_ENABLE;
+
+       if (pipe == 0)
+               dspcntr |= DISPPLANE_SEL_PIPE_A;
+       else
+               dspcntr |= DISPPLANE_SEL_PIPE_B;
+
+       dev_priv->dspcntr = dspcntr |= DISPLAY_PLANE_ENABLE;
+       dev_priv->pipeconf = pipeconf |= PIPEACONF_ENABLE;
+
+       if (is_mipi)
+               goto mrst_crtc_mode_set_exit;
+
+       refclk = dev_priv->core_freq * 1000;
+
+       dpll = 0;               /*BIT16 = 0 for 100MHz reference */
+
+       ok = mrstFindBestPLL(crtc, adjusted_mode->clock, refclk, &clock);
+
+       if (!ok) {
+               PSB_DEBUG_ENTRY(
+                       "mrstFindBestPLL fail in mrst_crtc_mode_set.\n");
+       } else {
+               PSB_DEBUG_ENTRY("mrst_crtc_mode_set pixel clock = %d,"
+                        "m = %x, p1 = %x.\n", clock.dot, clock.m,
+                        clock.p1);
+       }
+
+       fp = mrst_m_converts[(clock.m - MRST_M_MIN)] << 8;
+
+       dpll |= DPLL_VGA_MODE_DIS;
+
+
+       dpll |= DPLL_VCO_ENABLE;
+
+       if (is_lvds)
+               dpll |= DPLLA_MODE_LVDS;
+       else
+               dpll |= DPLLB_MODE_DAC_SERIAL;
+
+       if (is_sdvo) {
+               int sdvo_pixel_multiply =
+                   adjusted_mode->clock / mode->clock;
+
+               dpll |= DPLL_DVO_HIGH_SPEED;
+               dpll |=
+                   (sdvo_pixel_multiply -
+                    1) << SDVO_MULTIPLIER_SHIFT_HIRES;
+       }
+
+
+       /* compute bitmask from p1 value */
+       dpll |= (1 << (clock.p1 - 2)) << 17;
+
+       dpll |= DPLL_VCO_ENABLE;
+
+       mrstPrintPll("chosen", &clock);
+
+       if (dpll & DPLL_VCO_ENABLE) {
+               REG_WRITE(fp_reg, fp);
+               REG_WRITE(dpll_reg, dpll & ~DPLL_VCO_ENABLE);
+               REG_READ(dpll_reg);
+               /* Check the DPLLA lock bit PIPEACONF[29] */
+               udelay(150);
+       }
+
+       REG_WRITE(fp_reg, fp);
+       REG_WRITE(dpll_reg, dpll);
+       REG_READ(dpll_reg);
+       /* Wait for the clocks to stabilize. */
+       udelay(150);
+
+       /* write it again -- the BIOS does, after all */
+       REG_WRITE(dpll_reg, dpll);
+       REG_READ(dpll_reg);
+       /* Wait for the clocks to stabilize. */
+       udelay(150);
+
+       REG_WRITE(pipeconf_reg, pipeconf);
+       REG_READ(pipeconf_reg);
+       psb_intel_wait_for_vblank(dev);
+
+       REG_WRITE(dspcntr_reg, dspcntr);
+       psb_intel_wait_for_vblank(dev);
+
+mrst_crtc_mode_set_exit:
+       gma_power_end(dev);
+       return 0;
+}
+
+static bool mrst_crtc_mode_fixup(struct drm_crtc *crtc,
+                                 struct drm_display_mode *mode,
+                                 struct drm_display_mode *adjusted_mode)
+{
+       return true;
+}
+
+int mrst_pipe_set_base(struct drm_crtc *crtc,
+                           int x, int y, struct drm_framebuffer *old_fb)
+{
+       struct drm_device *dev = crtc->dev;
+       /* struct drm_i915_master_private *master_priv; */
+       struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc);
+       struct psb_framebuffer *psbfb = to_psb_fb(crtc->fb);
+       int pipe = psb_intel_crtc->pipe;
+       unsigned long start, offset;
+       /* FIXME: check if we need this surely MRST is pipe 0 only */
+       int dspbase = (pipe == 0 ? DSPALINOFF : DSPBBASE);
+       int dspsurf = (pipe == 0 ? DSPASURF : DSPBSURF);
+       int dspstride = (pipe == 0) ? DSPASTRIDE : DSPBSTRIDE;
+       int dspcntr_reg = (pipe == 0) ? DSPACNTR : DSPBCNTR;
+       u32 dspcntr;
+       int ret = 0;
+
+       PSB_DEBUG_ENTRY("\n");
+
+       /* no fb bound */
+       if (!crtc->fb) {
+               DRM_DEBUG("No FB bound\n");
+               return 0;
+       }
+
+       if (!gma_power_begin(dev, true))
+               return 0;
+
+       start = psbfb->gtt->offset;
+       offset = y * crtc->fb->pitch + x * (crtc->fb->bits_per_pixel / 8);
+
+       REG_WRITE(dspstride, crtc->fb->pitch);
+
+       dspcntr = REG_READ(dspcntr_reg);
+       dspcntr &= ~DISPPLANE_PIXFORMAT_MASK;
+
+       switch (crtc->fb->bits_per_pixel) {
+       case 8:
+               dspcntr |= DISPPLANE_8BPP;
+               break;
+       case 16:
+               if (crtc->fb->depth == 15)
+                       dspcntr |= DISPPLANE_15_16BPP;
+               else
+                       dspcntr |= DISPPLANE_16BPP;
+               break;
+       case 24:
+       case 32:
+               dspcntr |= DISPPLANE_32BPP_NO_ALPHA;
+               break;
+       default:
+               DRM_ERROR("Unknown color depth\n");
+               ret = -EINVAL;
+               goto pipe_set_base_exit;
+       }
+       REG_WRITE(dspcntr_reg, dspcntr);
+
+       DRM_DEBUG("Writing base %08lX %08lX %d %d\n", start, offset, x, y);
+       if (0 /* FIXMEAC - check what PSB needs */) {
+               REG_WRITE(dspbase, offset);
+               REG_READ(dspbase);
+               REG_WRITE(dspsurf, start);
+               REG_READ(dspsurf);
+       } else {
+               REG_WRITE(dspbase, start + offset);
+               REG_READ(dspbase);
+       }
+
+pipe_set_base_exit:
+       gma_power_end(dev);
+       return ret;
+}
+
+static void mrst_crtc_prepare(struct drm_crtc *crtc)
+{
+       struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private;
+       crtc_funcs->dpms(crtc, DRM_MODE_DPMS_OFF);
+}
+
+static void mrst_crtc_commit(struct drm_crtc *crtc)
+{
+       struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private;
+       crtc_funcs->dpms(crtc, DRM_MODE_DPMS_ON);
+}
+
+const struct drm_crtc_helper_funcs mrst_helper_funcs = {
+       .dpms = mrst_crtc_dpms,
+       .mode_fixup = mrst_crtc_mode_fixup,
+       .mode_set = mrst_crtc_mode_set,
+       .mode_set_base = mrst_pipe_set_base,
+       .prepare = mrst_crtc_prepare,
+       .commit = mrst_crtc_commit,
+};
+
diff --git a/drivers/staging/gma500/mrst_lvds.c b/drivers/staging/gma500/mrst_lvds.c
new file mode 100644 (file)
index 0000000..4a08b74
--- /dev/null
@@ -0,0 +1,371 @@
+/*
+ * Copyright © 2006-2009 Intel Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Authors:
+ *     Eric Anholt <eric@anholt.net>
+ *     Dave Airlie <airlied@linux.ie>
+ *     Jesse Barnes <jesse.barnes@intel.com>
+ */
+
+#include <linux/i2c.h>
+#include <drm/drmP.h>
+#include <asm/mrst.h>
+
+#include "psb_intel_bios.h"
+#include "psb_drv.h"
+#include "psb_intel_drv.h"
+#include "psb_intel_reg.h"
+#include "psb_powermgmt.h"
+#include <linux/pm_runtime.h>
+
+/* The max/min PWM frequency in BPCR[31:17] - */
+/* The smallest number is 1 (not 0) that can fit in the
+ * 15-bit field of the and then*/
+/* shifts to the left by one bit to get the actual 16-bit
+ * value that the 15-bits correspond to.*/
+#define MRST_BLC_MAX_PWM_REG_FREQ          0xFFFF
+#define BRIGHTNESS_MAX_LEVEL 100
+
+/**
+ * Sets the power state for the panel.
+ */
+static void mrst_lvds_set_power(struct drm_device *dev,
+                               struct psb_intel_output *output, bool on)
+{
+       u32 pp_status;
+       DRM_DRIVER_PRIVATE_T *dev_priv = dev->dev_private;
+       PSB_DEBUG_ENTRY("\n");
+
+       if (!gma_power_begin(dev, true))
+               return;
+
+       if (on) {
+               REG_WRITE(PP_CONTROL, REG_READ(PP_CONTROL) |
+                         POWER_TARGET_ON);
+               do {
+                       pp_status = REG_READ(PP_STATUS);
+               } while ((pp_status & (PP_ON | PP_READY)) == PP_READY);
+               dev_priv->is_lvds_on = true;
+       } else {
+               REG_WRITE(PP_CONTROL, REG_READ(PP_CONTROL) &
+                         ~POWER_TARGET_ON);
+               do {
+                       pp_status = REG_READ(PP_STATUS);
+               } while (pp_status & PP_ON);
+               dev_priv->is_lvds_on = false;
+               pm_request_idle(&dev->pdev->dev);
+       }
+
+       gma_power_end(dev);
+}
+
+static void mrst_lvds_dpms(struct drm_encoder *encoder, int mode)
+{
+       struct drm_device *dev = encoder->dev;
+       struct psb_intel_output *output = enc_to_psb_intel_output(encoder);
+
+       PSB_DEBUG_ENTRY("\n");
+
+       if (mode == DRM_MODE_DPMS_ON)
+               mrst_lvds_set_power(dev, output, true);
+       else
+               mrst_lvds_set_power(dev, output, false);
+
+       /* XXX: We never power down the LVDS pairs. */
+}
+
+static void mrst_lvds_mode_set(struct drm_encoder *encoder,
+                              struct drm_display_mode *mode,
+                              struct drm_display_mode *adjusted_mode)
+{
+       struct psb_intel_mode_device *mode_dev =
+                               enc_to_psb_intel_output(encoder)->mode_dev;
+       struct drm_device *dev = encoder->dev;
+       u32 lvds_port;
+       uint64_t v = DRM_MODE_SCALE_FULLSCREEN;
+
+       PSB_DEBUG_ENTRY("\n");
+
+       if (!gma_power_begin(dev, true))
+               return;
+
+       /*
+        * The LVDS pin pair will already have been turned on in the
+        * psb_intel_crtc_mode_set since it has a large impact on the DPLL
+        * settings.
+        */
+       lvds_port = (REG_READ(LVDS) &
+                   (~LVDS_PIPEB_SELECT)) |
+                   LVDS_PORT_EN |
+                   LVDS_BORDER_EN;
+
+       if (mode_dev->panel_wants_dither)
+               lvds_port |= MRST_PANEL_8TO6_DITHER_ENABLE;
+
+       REG_WRITE(LVDS, lvds_port);
+
+       drm_connector_property_get_value(
+               &enc_to_psb_intel_output(encoder)->base,
+               dev->mode_config.scaling_mode_property,
+               &v);
+
+       if (v == DRM_MODE_SCALE_NO_SCALE)
+               REG_WRITE(PFIT_CONTROL, 0);
+       else if (v == DRM_MODE_SCALE_ASPECT) {
+               if ((mode->vdisplay != adjusted_mode->crtc_vdisplay) ||
+                   (mode->hdisplay != adjusted_mode->crtc_hdisplay)) {
+                       if ((adjusted_mode->crtc_hdisplay * mode->vdisplay) ==
+                           (mode->hdisplay * adjusted_mode->crtc_vdisplay))
+                               REG_WRITE(PFIT_CONTROL, PFIT_ENABLE);
+                       else if ((adjusted_mode->crtc_hdisplay *
+                               mode->vdisplay) > (mode->hdisplay *
+                               adjusted_mode->crtc_vdisplay))
+                               REG_WRITE(PFIT_CONTROL, PFIT_ENABLE |
+                                         PFIT_SCALING_MODE_PILLARBOX);
+                       else
+                               REG_WRITE(PFIT_CONTROL, PFIT_ENABLE |
+                                         PFIT_SCALING_MODE_LETTERBOX);
+               } else
+                       REG_WRITE(PFIT_CONTROL, PFIT_ENABLE);
+       } else /*(v == DRM_MODE_SCALE_FULLSCREEN)*/
+               REG_WRITE(PFIT_CONTROL, PFIT_ENABLE);
+
+       gma_power_end(dev);
+}
+
+
+static const struct drm_encoder_helper_funcs mrst_lvds_helper_funcs = {
+       .dpms = mrst_lvds_dpms,
+       .mode_fixup = psb_intel_lvds_mode_fixup,
+       .prepare = psb_intel_lvds_prepare,
+       .mode_set = mrst_lvds_mode_set,
+       .commit = psb_intel_lvds_commit,
+};
+
+static struct drm_display_mode lvds_configuration_modes[] = {
+       /* hard coded fixed mode for TPO LTPS LPJ040K001A */
+       { DRM_MODE("800x480",  DRM_MODE_TYPE_DRIVER, 33264, 800, 836,
+                  846, 1056, 0, 480, 489, 491, 525, 0, 0) },
+       /* hard coded fixed mode for LVDS 800x480 */
+       { DRM_MODE("800x480",  DRM_MODE_TYPE_DRIVER, 30994, 800, 801,
+                  802, 1024, 0, 480, 481, 482, 525, 0, 0) },
+       /* hard coded fixed mode for Samsung 480wsvga LVDS 1024x600@75 */
+       { DRM_MODE("1024x600", DRM_MODE_TYPE_DRIVER, 53990, 1024, 1072,
+                  1104, 1184, 0, 600, 603, 604, 608, 0, 0) },
+       /* hard coded fixed mode for Samsung 480wsvga LVDS 1024x600@75 */
+       { DRM_MODE("1024x600", DRM_MODE_TYPE_DRIVER, 53990, 1024, 1104,
+                  1136, 1184, 0, 600, 603, 604, 608, 0, 0) },
+       /* hard coded fixed mode for Sharp wsvga LVDS 1024x600 */
+       { DRM_MODE("1024x600", DRM_MODE_TYPE_DRIVER, 48885, 1024, 1124,
+                  1204, 1312, 0, 600, 607, 610, 621, 0, 0) },
+       /* hard coded fixed mode for LVDS 1024x768 */
+       { DRM_MODE("1024x768", DRM_MODE_TYPE_DRIVER, 65000, 1024, 1048,
+                  1184, 1344, 0, 768, 771, 777, 806, 0, 0) },
+       /* hard coded fixed mode for LVDS 1366x768 */
+       { DRM_MODE("1366x768", DRM_MODE_TYPE_DRIVER, 77500, 1366, 1430,
+                  1558, 1664, 0, 768, 769, 770, 776, 0, 0) },
+};
+
+/* Returns the panel fixed mode from configuration. */
+
+static struct drm_display_mode *
+mrst_lvds_get_configuration_mode(struct drm_device *dev)
+{
+       struct drm_display_mode *mode = NULL;
+       struct drm_psb_private *dev_priv = dev->dev_private;
+       struct mrst_timing_info *ti = &dev_priv->gct_data.DTD;
+
+       if (dev_priv->vbt_data.size != 0x00) { /*if non-zero, then use vbt*/
+               mode = kzalloc(sizeof(*mode), GFP_KERNEL);
+               if (!mode)
+                       return NULL;
+
+               mode->hdisplay = (ti->hactive_hi << 8) | ti->hactive_lo;
+               mode->vdisplay = (ti->vactive_hi << 8) | ti->vactive_lo;
+               mode->hsync_start = mode->hdisplay + \
+                               ((ti->hsync_offset_hi << 8) | \
+                               ti->hsync_offset_lo);
+               mode->hsync_end = mode->hsync_start + \
+                               ((ti->hsync_pulse_width_hi << 8) | \
+                               ti->hsync_pulse_width_lo);
+               mode->htotal = mode->hdisplay + ((ti->hblank_hi << 8) | \
+                                                       ti->hblank_lo);
+               mode->vsync_start = \
+                       mode->vdisplay + ((ti->vsync_offset_hi << 4) | \
+                                               ti->vsync_offset_lo);
+               mode->vsync_end = \
+                       mode->vsync_start + ((ti->vsync_pulse_width_hi << 4) | \
+                                               ti->vsync_pulse_width_lo);
+               mode->vtotal = mode->vdisplay + \
+                               ((ti->vblank_hi << 8) | ti->vblank_lo);
+               mode->clock = ti->pixel_clock * 10;
+#if 0
+               printk(KERN_INFO "hdisplay is %d\n", mode->hdisplay);
+               printk(KERN_INFO "vdisplay is %d\n", mode->vdisplay);
+               printk(KERN_INFO "HSS is %d\n", mode->hsync_start);
+               printk(KERN_INFO "HSE is %d\n", mode->hsync_end);
+               printk(KERN_INFO "htotal is %d\n", mode->htotal);
+               printk(KERN_INFO "VSS is %d\n", mode->vsync_start);
+               printk(KERN_INFO "VSE is %d\n", mode->vsync_end);
+               printk(KERN_INFO "vtotal is %d\n", mode->vtotal);
+               printk(KERN_INFO "clock is %d\n", mode->clock);
+#endif
+       } else
+               mode = drm_mode_duplicate(dev, &lvds_configuration_modes[2]);
+
+       drm_mode_set_name(mode);
+       drm_mode_set_crtcinfo(mode, 0);
+
+       return mode;
+}
+
+/**
+ * mrst_lvds_init - setup LVDS connectors on this device
+ * @dev: drm device
+ *
+ * Create the connector, register the LVDS DDC bus, and try to figure out what
+ * modes we can display on the LVDS panel (if present).
+ */
+void mrst_lvds_init(struct drm_device *dev,
+                   struct psb_intel_mode_device *mode_dev)
+{
+       struct psb_intel_output *psb_intel_output;
+       struct drm_connector *connector;
+       struct drm_encoder *encoder;
+       struct drm_psb_private *dev_priv =
+                               (struct drm_psb_private *) dev->dev_private;
+       struct edid *edid;
+       int ret = 0;
+       struct i2c_adapter *i2c_adap;
+       struct drm_display_mode *scan;  /* *modes, *bios_mode; */
+
+       PSB_DEBUG_ENTRY("\n");
+
+       psb_intel_output = kzalloc(sizeof(struct psb_intel_output), GFP_KERNEL);
+       if (!psb_intel_output)
+               return;
+
+       psb_intel_output->mode_dev = mode_dev;
+       connector = &psb_intel_output->base;
+       encoder = &psb_intel_output->enc;
+       dev_priv->is_lvds_on = true;
+       drm_connector_init(dev, &psb_intel_output->base,
+                          &psb_intel_lvds_connector_funcs,
+                          DRM_MODE_CONNECTOR_LVDS);
+
+       drm_encoder_init(dev, &psb_intel_output->enc, &psb_intel_lvds_enc_funcs,
+                        DRM_MODE_ENCODER_LVDS);
+
+       drm_mode_connector_attach_encoder(&psb_intel_output->base,
+                                         &psb_intel_output->enc);
+       psb_intel_output->type = INTEL_OUTPUT_LVDS;
+
+       drm_encoder_helper_add(encoder, &mrst_lvds_helper_funcs);
+       drm_connector_helper_add(connector,
+                                &psb_intel_lvds_connector_helper_funcs);
+       connector->display_info.subpixel_order = SubPixelHorizontalRGB;
+       connector->interlace_allowed = false;
+       connector->doublescan_allowed = false;
+
+       drm_connector_attach_property(connector,
+                                       dev->mode_config.scaling_mode_property,
+                                       DRM_MODE_SCALE_FULLSCREEN);
+       drm_connector_attach_property(connector,
+                                       dev_priv->backlight_property,
+                                       BRIGHTNESS_MAX_LEVEL);
+
+       mode_dev->panel_wants_dither = false;
+       if (dev_priv->vbt_data.size != 0x00)
+               mode_dev->panel_wants_dither = (dev_priv->gct_data.
+                       Panel_Port_Control & MRST_PANEL_8TO6_DITHER_ENABLE);
+
+       /*
+        * LVDS discovery:
+        * 1) check for EDID on DDC
+        * 2) check for VBT data
+        * 3) check to see if LVDS is already on
+        *    if none of the above, no panel
+        * 4) make sure lid is open
+        *    if closed, act like it's not there for now
+        */
+
+        /* This ifdef can go once the cpu ident stuff is cleaned up in arch */
+#if defined(CONFIG_X86_MRST)
+       if (mrst_identify_cpu())
+               i2c_adap = i2c_get_adapter(2);
+        else   /* Oaktrail uses I2C 1 */
+#endif        
+               i2c_adap = i2c_get_adapter(1);
+
+       if (i2c_adap == NULL)
+               printk(KERN_ALERT "No ddc adapter available!\n");
+       /*
+        * Attempt to get the fixed panel mode from DDC.  Assume that the
+        * preferred mode is the right one.
+        */
+       if (i2c_adap) {
+               edid = drm_get_edid(connector, i2c_adap);
+               if (edid) {
+                       drm_mode_connector_update_edid_property(connector,
+                                                                       edid);
+                       ret = drm_add_edid_modes(connector, edid);
+                       kfree(edid);
+               }
+
+               list_for_each_entry(scan, &connector->probed_modes, head) {
+                       if (scan->type & DRM_MODE_TYPE_PREFERRED) {
+                               mode_dev->panel_fixed_mode =
+                                   drm_mode_duplicate(dev, scan);
+                               goto out;       /* FIXME: check for quirks */
+                       }
+               }
+       }
+
+       /*
+        * If we didn't get EDID, try geting panel timing
+        * from configuration data
+        */
+       mode_dev->panel_fixed_mode = mrst_lvds_get_configuration_mode(dev);
+
+       if (mode_dev->panel_fixed_mode) {
+               mode_dev->panel_fixed_mode->type |=
+                   DRM_MODE_TYPE_PREFERRED;
+               goto out;       /* FIXME: check for quirks */
+       }
+
+       /* If we still don't have a mode after all that, give up. */
+       if (!mode_dev->panel_fixed_mode) {
+               DRM_DEBUG
+                   ("Found no modes on the lvds, ignoring the LVDS\n");
+               goto failed_find;
+       }
+
+out:
+       drm_sysfs_connector_add(connector);
+       return;
+
+failed_find:
+       DRM_DEBUG("No LVDS modes found, disabling.\n");
+       if (psb_intel_output->ddc_bus)
+               psb_intel_i2c_destroy(psb_intel_output->ddc_bus);
+
+/* failed_ddc: */
+
+       drm_encoder_cleanup(encoder);
+       drm_connector_cleanup(connector);
+       kfree(connector);
+}
+
index e4cae5d77d01d8f2d474c1db8f69edbfc0174607..0bd834c982d3b909fad8d7a463ad1e0b47130902 100644 (file)
@@ -40,7 +40,6 @@
 #include "psb_reg.h"
 #include "psb_drv.h"
 #include "psb_fb.h"
-#include "psb_sgx.h"
 
 void psb_spank(struct drm_psb_private *dev_priv)
 {
@@ -85,7 +84,7 @@ static int psb_2d_wait_available(struct drm_psb_private *dev_priv,
 /* FIXME: Remember if we expose the 2D engine to the DRM we need to serialize
    it with console use */
 
-static int psbfb_2d_submit(struct drm_psb_private *dev_priv, uint32_t *cmdbuf,
+int psbfb_2d_submit(struct drm_psb_private *dev_priv, uint32_t *cmdbuf,
                           unsigned size)
 {
        int ret = 0;
@@ -161,7 +160,7 @@ static void psbfb_fillrect_accel(struct fb_info *info,
        if (!fb)
                return;
 
-       offset = psbfb->offset;
+       offset = psbfb->gtt->offset;
        stride = fb->pitch;
 
        switch (fb->depth) {
@@ -304,7 +303,7 @@ static void psbfb_copyarea_accel(struct fb_info *info,
        if (!fb)
                return;
 
-       offset = psbfb->offset;
+       offset = psbfb->gtt->offset;
        stride = fb->pitch;
 
        switch (fb->depth) {
@@ -344,7 +343,7 @@ void psbfb_copyarea(struct fb_info *info,
        if (unlikely(info->state != FBINFO_STATE_RUNNING))
                return;
 
-       if (1 || (info->flags & FBINFO_HWACCEL_DISABLED))
+       if (info->flags & FBINFO_HWACCEL_DISABLED)
                return cfb_copyarea(info, region);
 
        /* psb_check_power_state(dev, PSB_DEVICE_SGX); */
index 70c17b352f9f3d9ff2946f621986b9c5107096a4..5dffc71c5125616b45170d3d14c0d08ceda44489 100644 (file)
@@ -33,7 +33,6 @@
 #define BLC_PWM_FREQ_CALC_CONSTANT 32
 #define MHz 1000000
 #define BRIGHTNESS_MIN_LEVEL 1
-#define BRIGHTNESS_MAX_LEVEL 100
 #define BRIGHTNESS_MASK        0xFF
 #define BLC_POLARITY_NORMAL 0
 #define BLC_POLARITY_INVERSE 1
@@ -59,15 +58,57 @@ int psb_set_brightness(struct backlight_device *bd)
 
        DRM_DEBUG_DRIVER("backlight level set to %d\n", level);
 
-       /* Perform value bounds checking */
-       if (level < BRIGHTNESS_MIN_LEVEL)
-               level = BRIGHTNESS_MIN_LEVEL;
+       /* Percentage 1-100% being valid */
+       if (level < 1)
+               level = 1;
 
        psb_intel_lvds_set_brightness(dev, level);
        psb_brightness = level;
        return 0;
 }
 
+int mrst_set_brightness(struct backlight_device *bd)
+{
+       struct drm_device *dev = bl_get_data(psb_backlight_device);
+       struct drm_psb_private *dev_priv = dev->dev_private;
+       int level = bd->props.brightness;
+       u32 blc_pwm_ctl;
+       u32 max_pwm_blc;
+
+       DRM_DEBUG_DRIVER("backlight level set to %d\n", level);
+
+       /* Percentage 1-100% being valid */
+       if (level < 1)
+               level = 1;
+
+       if (gma_power_begin(dev, 0)) {
+               /* Calculate and set the brightness value */
+               max_pwm_blc = REG_READ(BLC_PWM_CTL) >> 16;
+               blc_pwm_ctl = level * max_pwm_blc / 100;
+
+               /* Adjust the backlight level with the percent in
+                * dev_priv->blc_adj1;
+                */
+               blc_pwm_ctl = blc_pwm_ctl * dev_priv->blc_adj1;
+               blc_pwm_ctl = blc_pwm_ctl / 100;
+
+               /* Adjust the backlight level with the percent in
+                * dev_priv->blc_adj2;
+                */
+               blc_pwm_ctl = blc_pwm_ctl * dev_priv->blc_adj2;
+               blc_pwm_ctl = blc_pwm_ctl / 100;
+
+               if (blc_pol == BLC_POLARITY_INVERSE)
+                       blc_pwm_ctl = max_pwm_blc - blc_pwm_ctl;
+               /* force PWM bit on */
+               REG_WRITE(BLC_PWM_CTL2, (0x80000000 | REG_READ(BLC_PWM_CTL2)));
+               REG_WRITE(BLC_PWM_CTL, (max_pwm_blc << 16) | blc_pwm_ctl);
+               gma_power_end(dev);
+       }
+       psb_brightness = level;
+       return 0;
+}
+
 int psb_get_brightness(struct backlight_device *bd)
 {
        DRM_DEBUG_DRIVER("brightness = 0x%x\n", psb_brightness);
@@ -85,24 +126,33 @@ static const struct backlight_ops psb_ops = {
 
 static int device_backlight_init(struct drm_device *dev)
 {
+       struct drm_psb_private *dev_priv = dev->dev_private;
        unsigned long core_clock;
        /* u32 bl_max_freq; */
        /* unsigned long value; */
        u16 bl_max_freq;
        uint32_t value;
        uint32_t blc_pwm_precision_factor;
-       struct drm_psb_private *dev_priv = dev->dev_private;
 
-       /* get bl_max_freq and pol from dev_priv*/
-       if (!dev_priv->lvds_bl) {
-               DRM_ERROR("Has no valid LVDS backlight info\n");
-               return 1;
+       if (IS_MRST(dev)) {
+               dev_priv->blc_adj1 = BLC_ADJUSTMENT_MAX;
+               dev_priv->blc_adj2 = BLC_ADJUSTMENT_MAX;
+               bl_max_freq = 256;
+               /* this needs to be set elsewhere */
+               blc_pol = BLC_POLARITY_NORMAL;
+               blc_pwm_precision_factor = BLC_PWM_PRECISION_FACTOR;
+       } else {
+               /* get bl_max_freq and pol from dev_priv*/
+               if (!dev_priv->lvds_bl) {
+                       DRM_ERROR("Has no valid LVDS backlight info\n");
+                       return 1;
+               }
+               bl_max_freq = dev_priv->lvds_bl->freq;
+               blc_pol = dev_priv->lvds_bl->pol;
+               blc_pwm_precision_factor = PSB_BLC_PWM_PRECISION_FACTOR;
+               blc_brightnesscmd = dev_priv->lvds_bl->brightnesscmd;
+               blc_type = dev_priv->lvds_bl->type;
        }
-       bl_max_freq = dev_priv->lvds_bl->freq;
-       blc_pol = dev_priv->lvds_bl->pol;
-       blc_pwm_precision_factor = PSB_BLC_PWM_PRECISION_FACTOR;
-       blc_brightnesscmd = dev_priv->lvds_bl->brightnesscmd;
-       blc_type = dev_priv->lvds_bl->type;
 
        core_clock = dev_priv->core_freq;
 
@@ -111,20 +161,27 @@ static int device_backlight_init(struct drm_device *dev)
        value /= bl_max_freq;
        value /= blc_pwm_precision_factor;
 
-       if (ospm_power_using_hw_begin(OSPM_DISPLAY_ISLAND,
-                                               OSPM_UHB_ONLY_IF_ON)) {
-               /* Check: may be MFLD only */
-               if (
-                value > (unsigned long long)PSB_BLC_MAX_PWM_REG_FREQ ||
-                value < (unsigned long long)PSB_BLC_MIN_PWM_REG_FREQ)
-                       return 2;
-               else {
-                       value &= PSB_BACKLIGHT_PWM_POLARITY_BIT_CLEAR;
-                       REG_WRITE(BLC_PWM_CTL,
-                               (value << PSB_BACKLIGHT_PWM_CTL_SHIFT) |
-                               (value));
+       if (gma_power_begin(dev, false)) {
+               if (IS_MRST(dev)) {
+                       if (value > (unsigned long long)MRST_BLC_MAX_PWM_REG_FREQ)
+                               return 2;
+                       else {
+                               REG_WRITE(BLC_PWM_CTL2,
+                                       (0x80000000 | REG_READ(BLC_PWM_CTL2)));
+                               REG_WRITE(BLC_PWM_CTL, value | (value << 16));
+                       }
+               } else {
+                       if (value > (unsigned long long)PSB_BLC_MAX_PWM_REG_FREQ ||
+                        value < (unsigned long long)PSB_BLC_MIN_PWM_REG_FREQ)
+                               return 2;
+                       else {
+                               value &= PSB_BACKLIGHT_PWM_POLARITY_BIT_CLEAR;
+                               REG_WRITE(BLC_PWM_CTL,
+                                       (value << PSB_BACKLIGHT_PWM_CTL_SHIFT) |
+                                       (value));
+                       }
                }
-               ospm_power_using_hw_end(OSPM_DISPLAY_ISLAND);
+               gma_power_end(dev);
        }
        return 0;
 }
@@ -136,7 +193,8 @@ int psb_backlight_init(struct drm_device *dev)
 
        struct backlight_properties props;
        memset(&props, 0, sizeof(struct backlight_properties));
-       props.max_brightness = BRIGHTNESS_MAX_LEVEL;
+       props.max_brightness = 100;
+       props.type = BACKLIGHT_PLATFORM;
 
        psb_backlight_device = backlight_device_register("psb-bl", NULL,
                                                (void *)dev, &psb_ops, &props);
@@ -147,8 +205,8 @@ int psb_backlight_init(struct drm_device *dev)
        if (ret < 0)
                return ret;
 
-       psb_backlight_device->props.brightness = BRIGHTNESS_MAX_LEVEL;
-       psb_backlight_device->props.max_brightness = BRIGHTNESS_MAX_LEVEL;
+       psb_backlight_device->props.brightness = 100;
+       psb_backlight_device->props.max_brightness = 100;
        backlight_update_status(psb_backlight_device);
 #endif
        return 0;
diff --git a/drivers/staging/gma500/psb_buffer.c b/drivers/staging/gma500/psb_buffer.c
deleted file mode 100644 (file)
index 3077f6a..0000000
+++ /dev/null
@@ -1,450 +0,0 @@
-/**************************************************************************
- * Copyright (c) 2007, Intel Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
- *
- **************************************************************************/
-/*
- * Authors: Thomas Hellstrom <thomas-at-tungstengraphics.com>
- */
-#include "ttm/ttm_placement.h"
-#include "ttm/ttm_execbuf_util.h"
-#include "psb_ttm_fence_api.h"
-#include <drm/drmP.h>
-#include "psb_drv.h"
-
-#define DRM_MEM_TTM       26
-
-struct drm_psb_ttm_backend {
-       struct ttm_backend base;
-       struct page **pages;
-       unsigned int desired_tile_stride;
-       unsigned int hw_tile_stride;
-       int mem_type;
-       unsigned long offset;
-       unsigned long num_pages;
-};
-
-/*
- * MSVDX/TOPAZ GPU virtual space looks like this
- * (We currently use only one MMU context).
- * PSB_MEM_MMU_START: from 0x00000000~0xe000000, for generic buffers
- * TTM_PL_CI: from 0xe0000000+half GTT space, for camear/video buffer sharing
- * TTM_PL_RAR: from TTM_PL_CI+CI size, for RAR/video buffer sharing
- * TTM_PL_TT: from TTM_PL_RAR+RAR size, for buffers need to mapping into GTT
- */
-static int psb_init_mem_type(struct ttm_bo_device *bdev, uint32_t type,
-                            struct ttm_mem_type_manager *man)
-{
-
-       struct drm_psb_private *dev_priv =
-           container_of(bdev, struct drm_psb_private, bdev);
-       struct psb_gtt *pg = dev_priv->pg;
-
-       switch (type) {
-       case TTM_PL_SYSTEM:
-               man->flags = TTM_MEMTYPE_FLAG_MAPPABLE;
-               man->available_caching = TTM_PL_FLAG_CACHED |
-                   TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC;
-               man->default_caching = TTM_PL_FLAG_CACHED;
-               break;
-       case DRM_PSB_MEM_MMU:
-               man->func = &ttm_bo_manager_func;
-               man->flags = TTM_MEMTYPE_FLAG_MAPPABLE |
-                   TTM_MEMTYPE_FLAG_CMA;
-               man->gpu_offset = PSB_MEM_MMU_START;
-               man->available_caching = TTM_PL_FLAG_CACHED |
-                   TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC;
-               man->default_caching = TTM_PL_FLAG_WC;
-               break;
-       case TTM_PL_CI:
-               man->func = &ttm_bo_manager_func;
-               man->flags = TTM_MEMTYPE_FLAG_MAPPABLE |
-                       TTM_MEMTYPE_FLAG_FIXED;
-               man->gpu_offset = pg->mmu_gatt_start + (pg->ci_start);
-               man->available_caching = TTM_PL_FLAG_UNCACHED;
-               man->default_caching = TTM_PL_FLAG_UNCACHED;
-               break;
-       case TTM_PL_RAR:        /* Unmappable RAR memory */
-               man->func = &ttm_bo_manager_func;
-               man->flags = TTM_MEMTYPE_FLAG_MAPPABLE |
-                       TTM_MEMTYPE_FLAG_FIXED;
-               man->available_caching = TTM_PL_FLAG_UNCACHED;
-               man->default_caching = TTM_PL_FLAG_UNCACHED;
-               man->gpu_offset = pg->mmu_gatt_start + (pg->rar_start);
-               break;
-       case TTM_PL_TT: /* Mappable GATT memory */
-               man->func = &ttm_bo_manager_func;
-#ifdef PSB_WORKING_HOST_MMU_ACCESS
-               man->flags = TTM_MEMTYPE_FLAG_MAPPABLE;
-#else
-               man->flags = TTM_MEMTYPE_FLAG_MAPPABLE |
-                   TTM_MEMTYPE_FLAG_CMA;
-#endif
-               man->available_caching = TTM_PL_FLAG_CACHED |
-                   TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC;
-               man->default_caching = TTM_PL_FLAG_WC;
-               man->gpu_offset = pg->mmu_gatt_start +
-                               (pg->rar_start + dev_priv->rar_region_size);
-               break;
-       default:
-               DRM_ERROR("Unsupported memory type %u\n", (unsigned) type);
-               return -EINVAL;
-       }
-       return 0;
-}
-
-
-static void psb_evict_mask(struct ttm_buffer_object *bo,
-                                       struct ttm_placement *placement)
-{
-       static uint32_t cur_placement;
-
-       cur_placement = bo->mem.placement & ~TTM_PL_MASK_MEM;
-       cur_placement |= TTM_PL_FLAG_SYSTEM;
-
-       placement->fpfn = 0;
-       placement->lpfn = 0;
-       placement->num_placement = 1;
-       placement->placement = &cur_placement;
-       placement->num_busy_placement = 0;
-       placement->busy_placement = NULL;
-
-       /* all buffers evicted to system memory */
-       /* return cur_placement | TTM_PL_FLAG_SYSTEM; */
-}
-
-static int psb_invalidate_caches(struct ttm_bo_device *bdev,
-                                uint32_t placement)
-{
-       return 0;
-}
-
-static int psb_move_blit(struct ttm_buffer_object *bo,
-                        bool evict, bool no_wait,
-                        struct ttm_mem_reg *new_mem)
-{
-       BUG();
-       return 0;
-}
-
-/*
- * Flip destination ttm into GATT,
- * then blit and subsequently move out again.
- */
-
-static int psb_move_flip(struct ttm_buffer_object *bo,
-                        bool evict, bool interruptible, bool no_wait,
-                        struct ttm_mem_reg *new_mem)
-{
-       /*struct ttm_bo_device *bdev = bo->bdev;*/
-       struct ttm_mem_reg tmp_mem;
-       int ret;
-       struct ttm_placement placement;
-       uint32_t flags = TTM_PL_FLAG_TT;
-
-       tmp_mem = *new_mem;
-       tmp_mem.mm_node = NULL;
-
-       placement.fpfn = 0;
-       placement.lpfn = 0;
-       placement.num_placement = 1;
-       placement.placement = &flags;
-       placement.num_busy_placement = 0; /* FIXME */
-       placement.busy_placement = NULL;
-
-       ret = ttm_bo_mem_space(bo, &placement, &tmp_mem, interruptible,
-                                                       false, no_wait);
-       if (ret)
-               return ret;
-       ret = ttm_tt_bind(bo->ttm, &tmp_mem);
-       if (ret)
-               goto out_cleanup;
-       ret = psb_move_blit(bo, true, no_wait, &tmp_mem);
-       if (ret)
-               goto out_cleanup;
-
-       ret = ttm_bo_move_ttm(bo, evict, false, no_wait, new_mem);
-out_cleanup:
-       if (tmp_mem.mm_node) {
-               drm_mm_put_block(tmp_mem.mm_node);
-               tmp_mem.mm_node = NULL;
-       }
-       return ret;
-}
-
-static int psb_move(struct ttm_buffer_object *bo,
-                   bool evict, bool interruptible, bool no_wait_reserve,
-                   bool no_wait, struct ttm_mem_reg *new_mem)
-{
-       struct ttm_mem_reg *old_mem = &bo->mem;
-
-       if ((old_mem->mem_type == TTM_PL_RAR) ||
-           (new_mem->mem_type == TTM_PL_RAR)) {
-               if (old_mem->mm_node) {
-                       spin_lock(&bo->glob->lru_lock);
-                       drm_mm_put_block(old_mem->mm_node);
-                       spin_unlock(&bo->glob->lru_lock);
-               }
-               old_mem->mm_node = NULL;
-               *old_mem = *new_mem;
-       } else if (old_mem->mem_type == TTM_PL_SYSTEM) {
-               return ttm_bo_move_memcpy(bo, evict, false, no_wait, new_mem);
-       } else if (new_mem->mem_type == TTM_PL_SYSTEM) {
-               int ret = psb_move_flip(bo, evict, interruptible,
-                                       no_wait, new_mem);
-               if (unlikely(ret != 0)) {
-                       if (ret == -ERESTART)
-                               return ret;
-                       else
-                               return ttm_bo_move_memcpy(bo, evict, false,
-                                               no_wait, new_mem);
-               }
-       } else {
-               if (psb_move_blit(bo, evict, no_wait, new_mem))
-                       return ttm_bo_move_memcpy(bo, evict, false, no_wait,
-                                                 new_mem);
-       }
-       return 0;
-}
-
-static int drm_psb_tbe_populate(struct ttm_backend *backend,
-                               unsigned long num_pages,
-                               struct page **pages,
-                               struct page *dummy_read_page,
-                               dma_addr_t *dma_addrs)
-{
-       struct drm_psb_ttm_backend *psb_be =
-           container_of(backend, struct drm_psb_ttm_backend, base);
-
-       psb_be->pages = pages;
-       return 0;
-}
-
-static int drm_psb_tbe_unbind(struct ttm_backend *backend)
-{
-       struct ttm_bo_device *bdev = backend->bdev;
-       struct drm_psb_private *dev_priv =
-           container_of(bdev, struct drm_psb_private, bdev);
-       struct drm_psb_ttm_backend *psb_be =
-           container_of(backend, struct drm_psb_ttm_backend, base);
-       struct psb_mmu_pd *pd = psb_mmu_get_default_pd(dev_priv->mmu);
-       /* struct ttm_mem_type_manager *man = &bdev->man[psb_be->mem_type]; */
-
-       if (psb_be->mem_type == TTM_PL_TT) {
-               uint32_t gatt_p_offset =
-                       (psb_be->offset - dev_priv->pg->mmu_gatt_start)
-                                                               >> PAGE_SHIFT;
-
-               (void) psb_gtt_remove_pages(dev_priv->pg, gatt_p_offset,
-                                           psb_be->num_pages,
-                                           psb_be->desired_tile_stride,
-                                           psb_be->hw_tile_stride, 0);
-       }
-
-       psb_mmu_remove_pages(pd, psb_be->offset,
-                            psb_be->num_pages,
-                            psb_be->desired_tile_stride,
-                            psb_be->hw_tile_stride);
-
-       return 0;
-}
-
-static int drm_psb_tbe_bind(struct ttm_backend *backend,
-                           struct ttm_mem_reg *bo_mem)
-{
-       struct ttm_bo_device *bdev = backend->bdev;
-       struct drm_psb_private *dev_priv =
-           container_of(bdev, struct drm_psb_private, bdev);
-       struct drm_psb_ttm_backend *psb_be =
-           container_of(backend, struct drm_psb_ttm_backend, base);
-       struct psb_mmu_pd *pd = psb_mmu_get_default_pd(dev_priv->mmu);
-       struct ttm_mem_type_manager *man = &bdev->man[bo_mem->mem_type];
-       struct drm_mm_node *mm_node = bo_mem->mm_node;
-       int type;
-       int ret = 0;
-
-       psb_be->mem_type = bo_mem->mem_type;
-       psb_be->num_pages = bo_mem->num_pages;
-       psb_be->desired_tile_stride = 0;
-       psb_be->hw_tile_stride = 0;
-       psb_be->offset = (mm_node->start << PAGE_SHIFT) +
-           man->gpu_offset;
-
-       type =
-           (bo_mem->
-            placement & TTM_PL_FLAG_CACHED) ? PSB_MMU_CACHED_MEMORY : 0;
-
-       if (psb_be->mem_type == TTM_PL_TT) {
-               uint32_t gatt_p_offset =
-                               (psb_be->offset - dev_priv->pg->mmu_gatt_start)
-                                                               >> PAGE_SHIFT;
-
-               ret = psb_gtt_insert_pages(dev_priv->pg, psb_be->pages,
-                                          gatt_p_offset,
-                                          psb_be->num_pages,
-                                          psb_be->desired_tile_stride,
-                                          psb_be->hw_tile_stride, type);
-       }
-
-       ret = psb_mmu_insert_pages(pd, psb_be->pages,
-                                  psb_be->offset, psb_be->num_pages,
-                                  psb_be->desired_tile_stride,
-                                  psb_be->hw_tile_stride, type);
-       if (ret)
-               goto out_err;
-
-       return 0;
-out_err:
-       drm_psb_tbe_unbind(backend);
-       return ret;
-
-}
-
-static void drm_psb_tbe_clear(struct ttm_backend *backend)
-{
-       struct drm_psb_ttm_backend *psb_be =
-           container_of(backend, struct drm_psb_ttm_backend, base);
-
-       psb_be->pages = NULL;
-       return;
-}
-
-static void drm_psb_tbe_destroy(struct ttm_backend *backend)
-{
-       struct drm_psb_ttm_backend *psb_be =
-           container_of(backend, struct drm_psb_ttm_backend, base);
-
-       if (backend)
-               kfree(psb_be);
-}
-
-static struct ttm_backend_func psb_ttm_backend = {
-       .populate = drm_psb_tbe_populate,
-       .clear = drm_psb_tbe_clear,
-       .bind = drm_psb_tbe_bind,
-       .unbind = drm_psb_tbe_unbind,
-       .destroy = drm_psb_tbe_destroy,
-};
-
-static struct ttm_backend *drm_psb_tbe_init(struct ttm_bo_device *bdev)
-{
-       struct drm_psb_ttm_backend *psb_be;
-
-       psb_be = kzalloc(sizeof(*psb_be), GFP_KERNEL);
-       if (!psb_be)
-               return NULL;
-       psb_be->pages = NULL;
-       psb_be->base.func = &psb_ttm_backend;
-       psb_be->base.bdev = bdev;
-       return &psb_be->base;
-}
-
-static int psb_ttm_io_mem_reserve(struct ttm_bo_device *bdev,
-                                               struct ttm_mem_reg *mem)
-{
-       struct ttm_mem_type_manager *man = &bdev->man[mem->mem_type];
-       struct drm_psb_private *dev_priv =
-           container_of(bdev, struct drm_psb_private, bdev);
-       struct psb_gtt *pg = dev_priv->pg;
-       struct drm_mm_node *mm_node = mem->mm_node;
-
-       mem->bus.addr = NULL;
-       mem->bus.offset = 0;
-       mem->bus.size = mem->num_pages << PAGE_SHIFT;
-       mem->bus.base = 0;
-       mem->bus.is_iomem = false;
-       if (!(man->flags & TTM_MEMTYPE_FLAG_MAPPABLE))
-               return -EINVAL;
-       switch (mem->mem_type) {
-       case TTM_PL_SYSTEM:
-               /* system memory */
-               return 0;
-       case TTM_PL_TT:
-               mem->bus.offset = mm_node->start << PAGE_SHIFT;
-               mem->bus.base = pg->gatt_start;
-               mem->bus.is_iomem = false;
-               /* Don't know whether it is IO_MEM, this flag
-                                               used in vm_fault handle */
-               break;
-       case DRM_PSB_MEM_MMU:
-               mem->bus.offset = mm_node->start << PAGE_SHIFT;
-               mem->bus.base = 0x00000000;
-               break;
-       case TTM_PL_CI:
-               mem->bus.offset = mm_node->start << PAGE_SHIFT;
-               mem->bus.base = dev_priv->ci_region_start;;
-               mem->bus.is_iomem = true;
-               break;
-       case TTM_PL_RAR:
-               mem->bus.offset = mm_node->start << PAGE_SHIFT;
-               mem->bus.base = dev_priv->rar_region_start;;
-               mem->bus.is_iomem = true;
-               break;
-       default:
-               return -EINVAL;
-       }
-       return 0;
-}
-
-static void psb_ttm_io_mem_free(struct ttm_bo_device *bdev,
-                                               struct ttm_mem_reg *mem)
-{
-}
-
-/*
- * Use this memory type priority if no eviction is needed.
- */
-/*
-static uint32_t psb_mem_prios[] = {
-       TTM_PL_CI,
-       TTM_PL_RAR,
-       TTM_PL_TT,
-       DRM_PSB_MEM_MMU,
-       TTM_PL_SYSTEM
-};
-*/
-/*
- * Use this memory type priority if need to evict.
- */
-/*
-static uint32_t psb_busy_prios[] = {
-       TTM_PL_TT,
-       TTM_PL_CI,
-       TTM_PL_RAR,
-       DRM_PSB_MEM_MMU,
-       TTM_PL_SYSTEM
-};
-*/
-struct ttm_bo_driver psb_ttm_bo_driver = {
-/*
-       .mem_type_prio = psb_mem_prios,
-       .mem_busy_prio = psb_busy_prios,
-       .num_mem_type_prio = ARRAY_SIZE(psb_mem_prios),
-       .num_mem_busy_prio = ARRAY_SIZE(psb_busy_prios),
-*/
-       .create_ttm_backend_entry = &drm_psb_tbe_init,
-       .invalidate_caches = &psb_invalidate_caches,
-       .init_mem_type = &psb_init_mem_type,
-       .evict_flags = &psb_evict_mask,
-       .move = &psb_move,
-       .verify_access = &psb_verify_access,
-       .sync_obj_signaled = &ttm_fence_sync_obj_signaled,
-       .sync_obj_wait = &ttm_fence_sync_obj_wait,
-       .sync_obj_flush = &ttm_fence_sync_obj_flush,
-       .sync_obj_unref = &ttm_fence_sync_obj_unref,
-       .sync_obj_ref = &ttm_fence_sync_obj_ref,
-       .io_mem_reserve = &psb_ttm_io_mem_reserve,
-       .io_mem_free = &psb_ttm_io_mem_free
-};
index a339406052efc4da1242773bae04a136ab3a10e8..49ffdd5b90e29531c2e17352fe24e14c7a9edf72 100644 (file)
@@ -28,9 +28,6 @@
 #include "drm_mode.h"
 #endif
 
-#include "psb_ttm_fence_user.h"
-#include "psb_ttm_placement_user.h"
-
 #define DRM_PSB_SAREA_MAJOR 0
 #define DRM_PSB_SAREA_MINOR 2
 #define PSB_FIXED_SHIFT 16
  * Public memory types.
  */
 
-#define DRM_PSB_MEM_MMU        TTM_PL_PRIV1
-#define DRM_PSB_FLAG_MEM_MMU   TTM_PL_FLAG_PRIV1
-
-#define TTM_PL_CI               TTM_PL_PRIV0
-#define TTM_PL_FLAG_CI          TTM_PL_FLAG_PRIV0
-
-#define TTM_PL_RAR              TTM_PL_PRIV2
-#define TTM_PL_FLAG_RAR         TTM_PL_FLAG_PRIV2
-
 typedef s32 psb_fixed;
 typedef u32 psb_ufixed;
 
@@ -112,111 +100,12 @@ struct drm_psb_sarea {
        u32 num_active_scanouts;
 };
 
-#define PSB_RELOC_MAGIC         0x67676767
-#define PSB_RELOC_SHIFT_MASK    0x0000FFFF
-#define PSB_RELOC_SHIFT_SHIFT   0
-#define PSB_RELOC_ALSHIFT_MASK  0xFFFF0000
-#define PSB_RELOC_ALSHIFT_SHIFT 16
-
-#define PSB_RELOC_OP_OFFSET     0      /* Offset of the indicated
-                                        * buffer
-                                        */
-
-struct drm_psb_reloc {
-       u32 reloc_op;
-       u32 where;              /* offset in destination buffer */
-       u32 buffer;     /* Buffer reloc applies to */
-       u32 mask;               /* Destination format: */
-       u32 shift;              /* Destination format: */
-       u32 pre_add;    /* Destination format: */
-       u32 background; /* Destination add */
-       u32 dst_buffer; /* Destination buffer. Index into buffer_list */
-       u32 arg0;               /* Reloc-op dependent */
-       u32 arg1;
-};
-
-
 #define PSB_GPU_ACCESS_READ         (1ULL << 32)
 #define PSB_GPU_ACCESS_WRITE        (1ULL << 33)
 #define PSB_GPU_ACCESS_MASK         (PSB_GPU_ACCESS_READ | PSB_GPU_ACCESS_WRITE)
 
 #define PSB_BO_FLAG_COMMAND         (1ULL << 52)
 
-#define PSB_ENGINE_2D 0
-#define PSB_ENGINE_VIDEO 1
-#define LNC_ENGINE_ENCODE 5
-
-/*
- * For this fence class we have a couple of
- * fence types.
- */
-
-#define _PSB_FENCE_EXE_SHIFT           0
-#define _PSB_FENCE_FEEDBACK_SHIFT      4
-
-#define _PSB_FENCE_TYPE_EXE         (1 << _PSB_FENCE_EXE_SHIFT)
-#define _PSB_FENCE_TYPE_FEEDBACK    (1 << _PSB_FENCE_FEEDBACK_SHIFT)
-
-#define PSB_NUM_ENGINES 6
-
-
-#define PSB_FEEDBACK_OP_VISTEST (1 << 0)
-
-struct drm_psb_extension_rep {
-       s32 exists;
-       u32 driver_ioctl_offset;
-       u32 sarea_offset;
-       u32 major;
-       u32 minor;
-       u32 pl;
-};
-
-#define DRM_PSB_EXT_NAME_LEN 128
-
-union drm_psb_extension_arg {
-       char extension[DRM_PSB_EXT_NAME_LEN];
-       struct drm_psb_extension_rep rep;
-};
-
-struct psb_validate_req {
-       u64 set_flags;
-       u64 clear_flags;
-       u64 next;
-       u64 presumed_gpu_offset;
-       u32 buffer_handle;
-       u32 presumed_flags;
-       u32 group;
-       u32 pad64;
-};
-
-struct psb_validate_rep {
-       u64 gpu_offset;
-       u32 placement;
-       u32 fence_type_mask;
-};
-
-#define PSB_USE_PRESUMED     (1 << 0)
-
-struct psb_validate_arg {
-       int handled;
-       int ret;
-       union {
-               struct psb_validate_req req;
-               struct psb_validate_rep rep;
-       } d;
-};
-
-
-#define DRM_PSB_FENCE_NO_USER        (1 << 0)
-
-struct psb_ttm_fence_rep {
-       u32 handle;
-       u32 fence_class;
-       u32 fence_type;
-       u32 signaled_types;
-       u32 error;
-};
-
 /*
  * Feedback components:
  */
@@ -330,17 +219,6 @@ struct drm_psb_register_rw_arg {
        u32 subpicture_disable_mask;
 };
 
-struct psb_gtt_mapping_arg {
-       void *hKernelMemInfo;
-       u32 offset_pages;
-};
-
-struct drm_psb_getpageaddrs_arg {
-       u32 handle;
-       unsigned long *page_addrs;
-       unsigned long gtt_offset;
-};
-
 /* Controlling the kernel modesetting buffers */
 
 #define DRM_PSB_KMS_OFF                0x00
index d01d45e7a14d427c8fbc5460c71c9747c81440f6..1c45c11a774eaa60921f4ca0d69cec7e7481f8ea 100644 (file)
 int drm_psb_debug;
 static int drm_psb_trap_pagefaults;
 
-int drm_psb_disable_vsync = 1;
 int drm_psb_no_fb;
-int gfxrtdelay = 2 * 1000;
 
 static int psb_probe(struct pci_dev *pdev, const struct pci_device_id *ent);
 
 MODULE_PARM_DESC(debug, "Enable debug output");
 MODULE_PARM_DESC(no_fb, "Disable FBdev");
 MODULE_PARM_DESC(trap_pagefaults, "Error and reset on MMU pagefaults");
-MODULE_PARM_DESC(disable_vsync, "Disable vsync interrupts");
-MODULE_PARM_DESC(force_pipeb, "Forces PIPEB to become primary fb");
-MODULE_PARM_DESC(ta_mem_size, "TA memory size in kiB");
-MODULE_PARM_DESC(ospm, "switch for ospm support");
-MODULE_PARM_DESC(rtpm, "Specifies Runtime PM delay for GFX");
-MODULE_PARM_DESC(hdmi_edid, "EDID info for HDMI monitor");
 module_param_named(debug, drm_psb_debug, int, 0600);
 module_param_named(no_fb, drm_psb_no_fb, int, 0600);
 module_param_named(trap_pagefaults, drm_psb_trap_pagefaults, int, 0600);
-module_param_named(rtpm, gfxrtdelay, int, 0600);
 
 
 static struct pci_device_id pciidlist[] = {
        { 0x8086, 0x8108, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PSB_8108 },
        { 0x8086, 0x8109, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PSB_8109 },
+       { 0x8086, 0x4100, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_MRST_4100},
+       { 0x8086, 0x4101, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_MRST_4100},
+       { 0x8086, 0x4102, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_MRST_4100},
+       { 0x8086, 0x4103, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_MRST_4100},
+       { 0x8086, 0x4104, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_MRST_4100},
+       { 0x8086, 0x4105, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_MRST_4100},
+       { 0x8086, 0x4106, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_MRST_4100},
+       { 0x8086, 0x4107, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_MRST_4100},
        { 0, 0, 0}
 };
 MODULE_DEVICE_TABLE(pci, pciidlist);
@@ -74,10 +73,6 @@ MODULE_DEVICE_TABLE(pci, pciidlist);
                DRM_IO(DRM_PSB_KMS_OFF + DRM_COMMAND_BASE)
 #define DRM_IOCTL_PSB_KMS_ON   \
                DRM_IO(DRM_PSB_KMS_ON + DRM_COMMAND_BASE)
-#define DRM_IOCTL_PSB_VT_LEAVE \
-               DRM_IO(DRM_PSB_VT_LEAVE + DRM_COMMAND_BASE)
-#define DRM_IOCTL_PSB_VT_ENTER \
-               DRM_IO(DRM_PSB_VT_ENTER + DRM_COMMAND_BASE)
 #define DRM_IOCTL_PSB_SIZES    \
                DRM_IOR(DRM_PSB_SIZES + DRM_COMMAND_BASE, \
                        struct drm_psb_sizes_arg)
@@ -97,18 +92,6 @@ MODULE_DEVICE_TABLE(pci, pciidlist);
 #define DRM_IOCTL_PSB_REGISTER_RW      \
                DRM_IOWR(DRM_PSB_REGISTER_RW + DRM_COMMAND_BASE, \
                         struct drm_psb_register_rw_arg)
-#define DRM_IOCTL_PSB_GTT_MAP  \
-               DRM_IOWR(DRM_PSB_GTT_MAP + DRM_COMMAND_BASE, \
-                        struct psb_gtt_mapping_arg)
-#define DRM_IOCTL_PSB_GTT_UNMAP        \
-               DRM_IOW(DRM_PSB_GTT_UNMAP + DRM_COMMAND_BASE, \
-                       struct psb_gtt_mapping_arg)
-#define DRM_IOCTL_PSB_GETPAGEADDRS     \
-               DRM_IOWR(DRM_COMMAND_BASE + DRM_PSB_GETPAGEADDRS,\
-                        struct drm_psb_getpageaddrs_arg)
-#define DRM_IOCTL_PSB_UPDATE_GUARD     \
-               DRM_IOWR(DRM_PSB_UPDATE_GUARD + DRM_COMMAND_BASE, \
-                        uint32_t)
 #define DRM_IOCTL_PSB_DPST     \
                DRM_IOWR(DRM_PSB_DPST + DRM_COMMAND_BASE, \
                         uint32_t)
@@ -122,74 +105,6 @@ MODULE_DEVICE_TABLE(pci, pciidlist);
                DRM_IOWR(DRM_PSB_GET_PIPE_FROM_CRTC_ID + DRM_COMMAND_BASE, \
                         struct drm_psb_get_pipe_from_crtc_id_arg)
 
-/*
- * TTM execbuf extension.
- */
-
-#define DRM_PSB_CMDBUF           0x23
-#define DRM_PSB_SCENE_UNREF      0x24
-#define DRM_IOCTL_PSB_KMS_OFF    DRM_IO(DRM_PSB_KMS_OFF + DRM_COMMAND_BASE)
-#define DRM_IOCTL_PSB_KMS_ON     DRM_IO(DRM_PSB_KMS_ON + DRM_COMMAND_BASE)
-/*
- * TTM placement user extension.
- */
-
-#define DRM_PSB_PLACEMENT_OFFSET   (DRM_PSB_SCENE_UNREF + 1)
-
-#define DRM_PSB_TTM_PL_CREATE   (TTM_PL_CREATE + DRM_PSB_PLACEMENT_OFFSET)
-#define DRM_PSB_TTM_PL_REFERENCE (TTM_PL_REFERENCE + DRM_PSB_PLACEMENT_OFFSET)
-#define DRM_PSB_TTM_PL_UNREF    (TTM_PL_UNREF + DRM_PSB_PLACEMENT_OFFSET)
-#define DRM_PSB_TTM_PL_SYNCCPU  (TTM_PL_SYNCCPU + DRM_PSB_PLACEMENT_OFFSET)
-#define DRM_PSB_TTM_PL_WAITIDLE  (TTM_PL_WAITIDLE + DRM_PSB_PLACEMENT_OFFSET)
-#define DRM_PSB_TTM_PL_SETSTATUS (TTM_PL_SETSTATUS + DRM_PSB_PLACEMENT_OFFSET)
-#define DRM_PSB_TTM_PL_CREATE_UB (TTM_PL_CREATE_UB + DRM_PSB_PLACEMENT_OFFSET)
-
-/*
- * TTM fence extension.
- */
-
-#define DRM_PSB_FENCE_OFFSET      (DRM_PSB_TTM_PL_CREATE_UB + 1)
-#define DRM_PSB_TTM_FENCE_SIGNALED (TTM_FENCE_SIGNALED + DRM_PSB_FENCE_OFFSET)
-#define DRM_PSB_TTM_FENCE_FINISH   (TTM_FENCE_FINISH + DRM_PSB_FENCE_OFFSET)
-#define DRM_PSB_TTM_FENCE_UNREF    (TTM_FENCE_UNREF + DRM_PSB_FENCE_OFFSET)
-
-#define DRM_PSB_FLIP      (DRM_PSB_TTM_FENCE_UNREF + 1)        /*20*/
-
-#define DRM_IOCTL_PSB_TTM_PL_CREATE    \
-       DRM_IOWR(DRM_COMMAND_BASE + DRM_PSB_TTM_PL_CREATE,\
-                union ttm_pl_create_arg)
-#define DRM_IOCTL_PSB_TTM_PL_REFERENCE \
-       DRM_IOWR(DRM_COMMAND_BASE + DRM_PSB_TTM_PL_REFERENCE,\
-                union ttm_pl_reference_arg)
-#define DRM_IOCTL_PSB_TTM_PL_UNREF    \
-       DRM_IOW(DRM_COMMAND_BASE + DRM_PSB_TTM_PL_UNREF,\
-               struct ttm_pl_reference_req)
-#define DRM_IOCTL_PSB_TTM_PL_SYNCCPU   \
-       DRM_IOW(DRM_COMMAND_BASE + DRM_PSB_TTM_PL_SYNCCPU,\
-               struct ttm_pl_synccpu_arg)
-#define DRM_IOCTL_PSB_TTM_PL_WAITIDLE   \
-       DRM_IOW(DRM_COMMAND_BASE + DRM_PSB_TTM_PL_WAITIDLE,\
-               struct ttm_pl_waitidle_arg)
-#define DRM_IOCTL_PSB_TTM_PL_SETSTATUS \
-       DRM_IOWR(DRM_COMMAND_BASE + DRM_PSB_TTM_PL_SETSTATUS,\
-                union ttm_pl_setstatus_arg)
-#define DRM_IOCTL_PSB_TTM_PL_CREATE_UB    \
-       DRM_IOWR(DRM_COMMAND_BASE + DRM_PSB_TTM_PL_CREATE_UB,\
-                union ttm_pl_create_ub_arg)
-#define DRM_IOCTL_PSB_TTM_FENCE_SIGNALED \
-       DRM_IOWR(DRM_COMMAND_BASE + DRM_PSB_TTM_FENCE_SIGNALED, \
-                 union ttm_fence_signaled_arg)
-#define DRM_IOCTL_PSB_TTM_FENCE_FINISH \
-       DRM_IOWR(DRM_COMMAND_BASE + DRM_PSB_TTM_FENCE_FINISH,   \
-                union ttm_fence_finish_arg)
-#define DRM_IOCTL_PSB_TTM_FENCE_UNREF \
-       DRM_IOW(DRM_COMMAND_BASE + DRM_PSB_TTM_FENCE_UNREF,     \
-                struct ttm_fence_unref_arg)
-
-static int psb_vt_leave_ioctl(struct drm_device *dev, void *data,
-                             struct drm_file *file_priv);
-static int psb_vt_enter_ioctl(struct drm_device *dev, void *data,
-                             struct drm_file *file_priv);
 static int psb_sizes_ioctl(struct drm_device *dev, void *data,
                           struct drm_file *file_priv);
 static int psb_dc_state_ioctl(struct drm_device *dev, void * data,
@@ -218,11 +133,6 @@ static struct drm_ioctl_desc psb_ioctls[] = {
        PSB_IOCTL_DEF(DRM_IOCTL_PSB_KMS_ON,
                        psbfb_kms_on_ioctl,
                        DRM_ROOT_ONLY),
-       PSB_IOCTL_DEF(DRM_IOCTL_PSB_VT_LEAVE, psb_vt_leave_ioctl,
-                     DRM_ROOT_ONLY),
-       PSB_IOCTL_DEF(DRM_IOCTL_PSB_VT_ENTER,
-                       psb_vt_enter_ioctl,
-                       DRM_ROOT_ONLY),
        PSB_IOCTL_DEF(DRM_IOCTL_PSB_SIZES, psb_sizes_ioctl, DRM_AUTH),
        PSB_IOCTL_DEF(DRM_IOCTL_PSB_DC_STATE, psb_dc_state_ioctl, DRM_AUTH),
        PSB_IOCTL_DEF(DRM_IOCTL_PSB_ADB, psb_adb_ioctl, DRM_AUTH),
@@ -232,92 +142,226 @@ static struct drm_ioctl_desc psb_ioctls[] = {
                      DRM_AUTH),
        PSB_IOCTL_DEF(DRM_IOCTL_PSB_REGISTER_RW, psb_register_rw_ioctl,
                      DRM_AUTH),
-       PSB_IOCTL_DEF(DRM_IOCTL_PSB_GTT_MAP,
-                       psb_gtt_map_meminfo_ioctl,
-                       DRM_AUTH),
-       PSB_IOCTL_DEF(DRM_IOCTL_PSB_GTT_UNMAP,
-                       psb_gtt_unmap_meminfo_ioctl,
-                       DRM_AUTH),
-       PSB_IOCTL_DEF(DRM_IOCTL_PSB_GETPAGEADDRS,
-                       psb_getpageaddrs_ioctl,
-                       DRM_AUTH),
        PSB_IOCTL_DEF(DRM_IOCTL_PSB_DPST, psb_dpst_ioctl, DRM_AUTH),
        PSB_IOCTL_DEF(DRM_IOCTL_PSB_GAMMA, psb_gamma_ioctl, DRM_AUTH),
        PSB_IOCTL_DEF(DRM_IOCTL_PSB_DPST_BL, psb_dpst_bl_ioctl, DRM_AUTH),
        PSB_IOCTL_DEF(DRM_IOCTL_PSB_GET_PIPE_FROM_CRTC_ID,
                                        psb_intel_get_pipe_from_crtc_id, 0),
 
-       PSB_IOCTL_DEF(DRM_IOCTL_PSB_TTM_PL_CREATE, psb_pl_create_ioctl,
-                     DRM_AUTH),
-       PSB_IOCTL_DEF(DRM_IOCTL_PSB_TTM_PL_REFERENCE, psb_pl_reference_ioctl,
-                     DRM_AUTH),
-       PSB_IOCTL_DEF(DRM_IOCTL_PSB_TTM_PL_UNREF, psb_pl_unref_ioctl,
-                     DRM_AUTH),
-       PSB_IOCTL_DEF(DRM_IOCTL_PSB_TTM_PL_SYNCCPU, psb_pl_synccpu_ioctl,
-                     DRM_AUTH),
-       PSB_IOCTL_DEF(DRM_IOCTL_PSB_TTM_PL_WAITIDLE, psb_pl_waitidle_ioctl,
-                     DRM_AUTH),
-       PSB_IOCTL_DEF(DRM_IOCTL_PSB_TTM_PL_SETSTATUS, psb_pl_setstatus_ioctl,
-                     DRM_AUTH),
-       PSB_IOCTL_DEF(DRM_IOCTL_PSB_TTM_PL_CREATE_UB, psb_pl_ub_create_ioctl,
-                     DRM_AUTH),
-       PSB_IOCTL_DEF(DRM_IOCTL_PSB_TTM_FENCE_SIGNALED,
-                     psb_fence_signaled_ioctl, DRM_AUTH),
-       PSB_IOCTL_DEF(DRM_IOCTL_PSB_TTM_FENCE_FINISH, psb_fence_finish_ioctl,
-                     DRM_AUTH),
-       PSB_IOCTL_DEF(DRM_IOCTL_PSB_TTM_FENCE_UNREF, psb_fence_unref_ioctl,
-                     DRM_AUTH),
 };
 
-static void psb_set_uopt(struct drm_psb_uopt *uopt)
+static void psb_lastclose(struct drm_device *dev)
 {
        return;
 }
 
-static void psb_lastclose(struct drm_device *dev)
+static void psb_do_takedown(struct drm_device *dev)
 {
-       struct drm_psb_private *dev_priv =
-           (struct drm_psb_private *) dev->dev_private;
+       /* FIXME: do we need to clean up the gtt here ? */
+}
 
-       return;
+void mrst_get_fuse_settings(struct drm_device *dev)
+{
+       struct drm_psb_private *dev_priv = dev->dev_private;
+       struct pci_dev *pci_root = pci_get_bus_and_slot(0, 0);
+       uint32_t fuse_value = 0;
+       uint32_t fuse_value_tmp = 0;
 
-       if (!dev->dev_private)
-               return;
+#define FB_REG06 0xD0810600
+#define FB_MIPI_DISABLE  (1 << 11)
+#define FB_REG09 0xD0810900
+#define FB_REG09 0xD0810900
+#define FB_SKU_MASK  0x7000
+#define FB_SKU_SHIFT 12
+#define FB_SKU_100 0
+#define FB_SKU_100L 1
+#define FB_SKU_83 2
+       pci_write_config_dword(pci_root, 0xD0, FB_REG06);
+       pci_read_config_dword(pci_root, 0xD4, &fuse_value);
+
+       dev_priv->iLVDS_enable = fuse_value & FB_MIPI_DISABLE;
+
+       DRM_INFO("internal display is %s\n",
+                dev_priv->iLVDS_enable ? "LVDS display" : "MIPI display");
+
+        /*prevent Runtime suspend at start*/
+        if (dev_priv->iLVDS_enable) {
+               dev_priv->is_lvds_on = true;
+               dev_priv->is_mipi_on = false;
+       }
+       else {
+               dev_priv->is_mipi_on = true;
+               dev_priv->is_lvds_on = false;
+       }
+
+       dev_priv->video_device_fuse = fuse_value;
+
+       pci_write_config_dword(pci_root, 0xD0, FB_REG09);
+       pci_read_config_dword(pci_root, 0xD4, &fuse_value);
 
-       mutex_lock(&dev_priv->cmdbuf_mutex);
-       if (dev_priv->context.buffers) {
-               vfree(dev_priv->context.buffers);
-               dev_priv->context.buffers = NULL;
+       DRM_INFO("SKU values is 0x%x. \n", fuse_value);
+       fuse_value_tmp = (fuse_value & FB_SKU_MASK) >> FB_SKU_SHIFT;
+
+       dev_priv->fuse_reg_value = fuse_value;
+
+       switch (fuse_value_tmp) {
+       case FB_SKU_100:
+               dev_priv->core_freq = 200;
+               break;
+       case FB_SKU_100L:
+               dev_priv->core_freq = 100;
+               break;
+       case FB_SKU_83:
+               dev_priv->core_freq = 166;
+               break;
+       default:
+               DRM_ERROR("Invalid SKU values, SKU value = 0x%08x\n", fuse_value_tmp);
+               dev_priv->core_freq = 0;
        }
-       mutex_unlock(&dev_priv->cmdbuf_mutex);
+       DRM_INFO("LNC core clk is %dMHz.\n", dev_priv->core_freq);
+       pci_dev_put(pci_root);
 }
 
-static void psb_do_takedown(struct drm_device *dev)
+void mid_get_pci_revID (struct drm_psb_private *dev_priv)
 {
-       struct drm_psb_private *dev_priv =
-           (struct drm_psb_private *) dev->dev_private;
-       struct ttm_bo_device *bdev = &dev_priv->bdev;
+       uint32_t platform_rev_id = 0;
+       struct pci_dev *pci_gfx_root = pci_get_bus_and_slot(0, PCI_DEVFN(2, 0));
 
+       /*get the revison ID, B0:D2:F0;0x08 */
+       pci_read_config_dword(pci_gfx_root, 0x08, &platform_rev_id);
+       dev_priv->platform_rev_id = (uint8_t) platform_rev_id;
+       pci_dev_put(pci_gfx_root);
+       PSB_DEBUG_ENTRY("platform_rev_id is %x\n",      dev_priv->platform_rev_id);
+}
 
-       if (dev_priv->have_mem_mmu) {
-               ttm_bo_clean_mm(bdev, DRM_PSB_MEM_MMU);
-               dev_priv->have_mem_mmu = 0;
-       }
+void mrst_get_vbt_data(struct drm_psb_private *dev_priv)
+{
+       struct mrst_vbt *vbt = &dev_priv->vbt_data;
+       u32 platform_config_address;
+       u16 new_size;
+       u8 *vbt_virtual;
+       u8 bpi;
+       u8 number_desc = 0;
+       struct mrst_timing_info *dp_ti = &dev_priv->gct_data.DTD;
+       struct gct_r10_timing_info ti;
+       void *pGCT;
+       struct pci_dev *pci_gfx_root = pci_get_bus_and_slot(0, PCI_DEVFN(2, 0));
 
-       if (dev_priv->have_tt) {
-               ttm_bo_clean_mm(bdev, TTM_PL_TT);
-               dev_priv->have_tt = 0;
-       }
+       /*get the address of the platform config vbt, B0:D2:F0;0xFC */
+       pci_read_config_dword(pci_gfx_root, 0xFC, &platform_config_address);
+       pci_dev_put(pci_gfx_root);
+       DRM_INFO("drm platform config address is %x\n",
+                       platform_config_address);
 
-       if (dev_priv->have_camera) {
-               ttm_bo_clean_mm(bdev, TTM_PL_CI);
-               dev_priv->have_camera = 0;
-       }
-       if (dev_priv->have_rar) {
-               ttm_bo_clean_mm(bdev, TTM_PL_RAR);
-               dev_priv->have_rar = 0;
+       /* check for platform config address == 0. */
+       /* this means fw doesn't support vbt */
+
+       if (platform_config_address == 0) {
+               vbt->size = 0;
+               return;
        }
 
+       /* get the virtual address of the vbt */
+       vbt_virtual = ioremap(platform_config_address, sizeof(*vbt));
+
+       memcpy(vbt, vbt_virtual, sizeof(*vbt));
+       iounmap(vbt_virtual); /* Free virtual address space */
+
+       printk(KERN_ALERT "GCT revision is %x\n", vbt->revision);
+
+       switch (vbt->revision) {
+       case 0:
+               vbt->mrst_gct = NULL;
+               vbt->mrst_gct = \
+                       ioremap(platform_config_address + sizeof(*vbt) - 4,
+                                       vbt->size - sizeof(*vbt) + 4);
+               pGCT = vbt->mrst_gct;
+               bpi = ((struct mrst_gct_v1 *)pGCT)->PD.BootPanelIndex;
+               dev_priv->gct_data.bpi = bpi;
+               dev_priv->gct_data.pt =
+                       ((struct mrst_gct_v1 *)pGCT)->PD.PanelType;
+               memcpy(&dev_priv->gct_data.DTD,
+                       &((struct mrst_gct_v1 *)pGCT)->panel[bpi].DTD,
+                               sizeof(struct mrst_timing_info));
+               dev_priv->gct_data.Panel_Port_Control =
+                 ((struct mrst_gct_v1 *)pGCT)->panel[bpi].Panel_Port_Control;
+               dev_priv->gct_data.Panel_MIPI_Display_Descriptor =
+                 ((struct mrst_gct_v1 *)pGCT)->panel[bpi].Panel_MIPI_Display_Descriptor;
+               break;
+       case 1:
+               vbt->mrst_gct = NULL;
+               vbt->mrst_gct = \
+                       ioremap(platform_config_address + sizeof(*vbt) - 4,
+                                       vbt->size - sizeof(*vbt) + 4);
+               pGCT = vbt->mrst_gct;
+               bpi = ((struct mrst_gct_v2 *)pGCT)->PD.BootPanelIndex;
+               dev_priv->gct_data.bpi = bpi;
+               dev_priv->gct_data.pt =
+                       ((struct mrst_gct_v2 *)pGCT)->PD.PanelType;
+               memcpy(&dev_priv->gct_data.DTD,
+                       &((struct mrst_gct_v2 *)pGCT)->panel[bpi].DTD,
+                               sizeof(struct mrst_timing_info));
+               dev_priv->gct_data.Panel_Port_Control =
+                 ((struct mrst_gct_v2 *)pGCT)->panel[bpi].Panel_Port_Control;
+               dev_priv->gct_data.Panel_MIPI_Display_Descriptor =
+                 ((struct mrst_gct_v2 *)pGCT)->panel[bpi].Panel_MIPI_Display_Descriptor;
+               break;
+       case 0x10:
+               /*header definition changed from rev 01 (v2) to rev 10h. */
+               /*so, some values have changed location*/
+               new_size = vbt->checksum; /*checksum contains lo size byte*/
+               /*LSB of mrst_gct contains hi size byte*/
+               new_size |= ((0xff & (unsigned int)vbt->mrst_gct)) << 8;
+
+               vbt->checksum = vbt->size; /*size contains the checksum*/
+               if (new_size > 0xff)
+                       vbt->size = 0xff; /*restrict size to 255*/
+               else
+                       vbt->size = new_size;
+
+               /* number of descriptors defined in the GCT */
+               number_desc = ((0xff00 & (unsigned int)vbt->mrst_gct)) >> 8;
+               bpi = ((0xff0000 & (unsigned int)vbt->mrst_gct)) >> 16;
+               vbt->mrst_gct = NULL;
+               vbt->mrst_gct = \
+                       ioremap(platform_config_address + GCT_R10_HEADER_SIZE,
+                               GCT_R10_DISPLAY_DESC_SIZE * number_desc);
+               pGCT = vbt->mrst_gct;
+               pGCT = (u8 *)pGCT + (bpi*GCT_R10_DISPLAY_DESC_SIZE);
+               dev_priv->gct_data.bpi = bpi; /*save boot panel id*/
+
+               /*copy the GCT display timings into a temp structure*/
+               memcpy(&ti, pGCT, sizeof(struct gct_r10_timing_info));
+
+               /*now copy the temp struct into the dev_priv->gct_data*/
+               dp_ti->pixel_clock = ti.pixel_clock;
+               dp_ti->hactive_hi = ti.hactive_hi;
+               dp_ti->hactive_lo = ti.hactive_lo;
+               dp_ti->hblank_hi = ti.hblank_hi;
+               dp_ti->hblank_lo = ti.hblank_lo;
+               dp_ti->hsync_offset_hi = ti.hsync_offset_hi;
+               dp_ti->hsync_offset_lo = ti.hsync_offset_lo;
+               dp_ti->hsync_pulse_width_hi = ti.hsync_pulse_width_hi;
+               dp_ti->hsync_pulse_width_lo = ti.hsync_pulse_width_lo;
+               dp_ti->vactive_hi = ti.vactive_hi;
+               dp_ti->vactive_lo = ti.vactive_lo;
+               dp_ti->vblank_hi = ti.vblank_hi;
+               dp_ti->vblank_lo = ti.vblank_lo;
+               dp_ti->vsync_offset_hi = ti.vsync_offset_hi;
+               dp_ti->vsync_offset_lo = ti.vsync_offset_lo;
+               dp_ti->vsync_pulse_width_hi = ti.vsync_pulse_width_hi;
+               dp_ti->vsync_pulse_width_lo = ti.vsync_pulse_width_lo;
+
+               /*mov the MIPI_Display_Descriptor data from GCT to dev priv*/
+               dev_priv->gct_data.Panel_MIPI_Display_Descriptor =
+                                                       *((u8 *)pGCT + 0x0d);
+               dev_priv->gct_data.Panel_MIPI_Display_Descriptor |=
+                                               (*((u8 *)pGCT + 0x0e)) << 8;
+               break;
+       default:
+               printk(KERN_ERR "Unknown revision of GCT!\n");
+               vbt->size = 0;
+       }
 }
 
 static void psb_get_core_freq(struct drm_device *dev)
@@ -358,36 +402,10 @@ static void psb_get_core_freq(struct drm_device *dev)
        }
 }
 
-#define FB_REG06 0xD0810600
-#define FB_TOPAZ_DISABLE BIT0
-#define FB_MIPI_DISABLE  BIT11
-#define FB_REG09 0xD0810900
-#define FB_SKU_MASK  (BIT12|BIT13|BIT14)
-#define FB_SKU_SHIFT 12
-#define FB_SKU_100 0
-#define FB_SKU_100L 1
-#define FB_SKU_83 2
-
-bool mid_get_pci_revID(struct drm_psb_private *dev_priv)
-{
-       uint32_t platform_rev_id = 0;
-       struct pci_dev *pci_gfx_root = pci_get_bus_and_slot(0, PCI_DEVFN(2, 0));
-
-       /*get the revison ID, B0:D2:F0;0x08 */
-       pci_read_config_dword(pci_gfx_root, 0x08, &platform_rev_id);
-       dev_priv->platform_rev_id = (uint8_t) platform_rev_id;
-       pci_dev_put(pci_gfx_root);
-       PSB_DEBUG_ENTRY("platform_rev_id is %x\n",
-                                       dev_priv->platform_rev_id);
-
-       return true;
-}
-
 static int psb_do_init(struct drm_device *dev)
 {
        struct drm_psb_private *dev_priv =
            (struct drm_psb_private *) dev->dev_private;
-       struct ttm_bo_device *bdev = &dev_priv->bdev;
        struct psb_gtt *pg = dev_priv->pg;
 
        uint32_t stolen_gtt;
@@ -396,16 +414,6 @@ static int psb_do_init(struct drm_device *dev)
 
        int ret = -ENOMEM;
 
-
-       /*
-        * Initialize sequence numbers for the different command
-        * submission mechanisms.
-        */
-
-       dev_priv->sequence[PSB_ENGINE_2D] = 0;
-       dev_priv->sequence[PSB_ENGINE_VIDEO] = 0;
-       dev_priv->sequence[LNC_ENGINE_ENCODE] = 0;
-
        if (pg->mmu_gatt_start & 0x0FFFFFFF) {
                DRM_ERROR("Gatt must be 256M aligned. This is a bug.\n");
                ret = -EINVAL;
@@ -445,6 +453,7 @@ static int psb_do_init(struct drm_device *dev)
            pg->gatt_pages : PSB_TT_PRIV0_PLIMIT;
        tt_start = dev_priv->gatt_free_offset - pg->mmu_gatt_start;
        tt_pages -= tt_start >> PAGE_SHIFT;
+       /* FIXME: can we kill ta_mem_size ? */
        dev_priv->sizes.ta_mem_size = 0;
 
        PSB_WSGX32(0x00000000, PSB_CR_BIF_BANK0);
@@ -453,30 +462,10 @@ static int psb_do_init(struct drm_device *dev)
         PSB_WSGX32(PSB_RSGX32(PSB_CR_BIF_CTRL) | _PSB_MMU_ER_MASK,
                                                        PSB_CR_BIF_CTRL);
        psb_spank(dev_priv);
-       
-       PSB_WSGX32(pg->mmu_gatt_start, PSB_CR_BIF_TWOD_REQ_BASE);
-
-       /* TT region managed by TTM. */
-       if (!ttm_bo_init_mm(bdev, TTM_PL_TT,
-                       pg->gatt_pages -
-                       (pg->ci_start >> PAGE_SHIFT) -
-                       ((dev_priv->ci_region_size + dev_priv->rar_region_size)
-                        >> PAGE_SHIFT))) {
-
-               dev_priv->have_tt = 1;
-               dev_priv->sizes.tt_size =
-                       (tt_pages << PAGE_SHIFT) / (1024 * 1024) / 2;
-       }
 
-       if (!ttm_bo_init_mm(bdev,
-                       DRM_PSB_MEM_MMU,
-                       PSB_MEM_TT_START >> PAGE_SHIFT)) {
-               dev_priv->have_mem_mmu = 1;
-               dev_priv->sizes.mmu_size =
-                       PSB_MEM_TT_START / (1024*1024);
-       }
+       /* mmu_gatt ?? */
+       PSB_WSGX32(pg->gatt_start, PSB_CR_BIF_TWOD_REQ_BASE);
 
-       PSB_DEBUG_INIT("Init MSVDX\n");
        return 0;
 out_err:
        psb_do_takedown(dev);
@@ -510,39 +499,19 @@ static int psb_driver_unload(struct drm_device *dev)
 
                        down_read(&pg->sem);
                        psb_mmu_remove_pfn_sequence(
-                                       psb_mmu_get_default_pd
-                                       (dev_priv->mmu),
-                                       pg->mmu_gatt_start,
-                                       pg->vram_stolen_size >> PAGE_SHIFT);
-                       if (pg->ci_stolen_size != 0)
-                               psb_mmu_remove_pfn_sequence(
-                                       psb_mmu_get_default_pd
-                                       (dev_priv->mmu),
-                                       pg->ci_start,
-                                       pg->ci_stolen_size >> PAGE_SHIFT);
-                       if (pg->rar_stolen_size != 0)
-                               psb_mmu_remove_pfn_sequence(
-                                       psb_mmu_get_default_pd
-                                       (dev_priv->mmu),
-                                       pg->rar_start,
-                                       pg->rar_stolen_size >> PAGE_SHIFT);
+                               psb_mmu_get_default_pd
+                               (dev_priv->mmu),
+                               pg->mmu_gatt_start,
+                               dev_priv->vram_stolen_size >> PAGE_SHIFT);
                        up_read(&pg->sem);
                        psb_mmu_driver_takedown(dev_priv->mmu);
                        dev_priv->mmu = NULL;
                }
-               psb_gtt_takedown(dev_priv->pg, 1);
+               psb_gtt_takedown(dev);
                if (dev_priv->scratch_page) {
                        __free_page(dev_priv->scratch_page);
                        dev_priv->scratch_page = NULL;
                }
-               if (dev_priv->has_bo_device) {
-                       ttm_bo_device_release(&dev_priv->bdev);
-                       dev_priv->has_bo_device = 0;
-               }
-               if (dev_priv->has_fence_device) {
-                       ttm_fence_device_release(&dev_priv->fdev);
-                       dev_priv->has_fence_device = 0;
-               }
                if (dev_priv->vdc_reg) {
                        iounmap(dev_priv->vdc_reg);
                        dev_priv->vdc_reg = NULL;
@@ -552,12 +521,6 @@ static int psb_driver_unload(struct drm_device *dev)
                        dev_priv->sgx_reg = NULL;
                }
 
-               if (dev_priv->tdev)
-                       ttm_object_device_release(&dev_priv->tdev);
-
-               if (dev_priv->has_global)
-                       psb_ttm_global_release(dev_priv);
-
                kfree(dev_priv);
                dev->dev_private = NULL;
 
@@ -565,7 +528,7 @@ static int psb_driver_unload(struct drm_device *dev)
                psb_intel_destroy_bios(dev);
        }
 
-       ospm_power_uninit();
+       gma_power_uninit(dev);
 
        return 0;
 }
@@ -574,7 +537,6 @@ static int psb_driver_unload(struct drm_device *dev)
 static int psb_driver_load(struct drm_device *dev, unsigned long chipset)
 {
        struct drm_psb_private *dev_priv;
-       struct ttm_bo_device *bdev;
        unsigned long resource_start;
        struct psb_gtt *pg;
        unsigned long irqflags;
@@ -584,39 +546,16 @@ static int psb_driver_load(struct drm_device *dev, unsigned long chipset)
        dev_priv = kzalloc(sizeof(*dev_priv), GFP_KERNEL);
        if (dev_priv == NULL)
                return -ENOMEM;
-       INIT_LIST_HEAD(&dev_priv->video_ctx);
-
-       dev_priv->num_pipe = 2;
 
+       if (IS_MRST(dev))
+               dev_priv->num_pipe = 1;
+       else
+               dev_priv->num_pipe = 2;
 
        dev_priv->dev = dev;
-       bdev = &dev_priv->bdev;
-
-       ret = psb_ttm_global_init(dev_priv);
-       if (unlikely(ret != 0))
-               goto out_err;
-       dev_priv->has_global = 1;
-
-       dev_priv->tdev = ttm_object_device_init
-               (dev_priv->mem_global_ref.object, PSB_OBJECT_HASH_ORDER);
-       if (unlikely(dev_priv->tdev == NULL))
-               goto out_err;
-
-       mutex_init(&dev_priv->temp_mem);
-       mutex_init(&dev_priv->cmdbuf_mutex);
-       mutex_init(&dev_priv->reset_mutex);
-       INIT_LIST_HEAD(&dev_priv->context.validate_list);
-       INIT_LIST_HEAD(&dev_priv->context.kern_validate_list);
-
-/*     mutex_init(&dev_priv->dsr_mutex); */
-
-       spin_lock_init(&dev_priv->reloc_lock);
-
-       DRM_INIT_WAITQUEUE(&dev_priv->rel_mapped_queue);
 
        dev->dev_private = (void *) dev_priv;
        dev_priv->chipset = chipset;
-       psb_set_uopt(&dev_priv->uopt);
 
        PSB_DEBUG_INIT("Mapping MMIO\n");
        resource_start = pci_resource_start(dev->pdev, PSB_MMIO_RESOURCE);
@@ -626,34 +565,28 @@ static int psb_driver_load(struct drm_device *dev, unsigned long chipset)
        if (!dev_priv->vdc_reg)
                goto out_err;
 
-       dev_priv->sgx_reg = ioremap(resource_start + PSB_SGX_OFFSET,
+       if (IS_MRST(dev))
+               dev_priv->sgx_reg = ioremap(resource_start + MRST_SGX_OFFSET,
+                                                       PSB_SGX_SIZE);
+       else
+               dev_priv->sgx_reg = ioremap(resource_start + PSB_SGX_OFFSET,
                                                        PSB_SGX_SIZE);
 
        if (!dev_priv->sgx_reg)
                goto out_err;
 
-       psb_get_core_freq(dev);
-       psb_intel_opregion_init(dev);
-       psb_intel_init_bios(dev);
-
-       PSB_DEBUG_INIT("Init TTM fence and BO driver\n");
+       if (IS_MRST(dev)) {
+               mrst_get_fuse_settings(dev);
+               mrst_get_vbt_data(dev_priv);
+               mid_get_pci_revID(dev_priv);
+       } else {
+               psb_get_core_freq(dev);
+               psb_intel_opregion_init(dev);
+               psb_intel_init_bios(dev);
+       }
 
        /* Init OSPM support */
-       ospm_power_init(dev);
-
-       ret = psb_ttm_fence_device_init(&dev_priv->fdev);
-       if (unlikely(ret != 0))
-               goto out_err;
-
-       dev_priv->has_fence_device = 1;
-       ret = ttm_bo_device_init(bdev,
-                                dev_priv->bo_global_ref.ref.object,
-                                &psb_ttm_bo_driver,
-                                DRM_PSB_FILE_PAGE_OFFSET, false);
-       if (unlikely(ret != 0))
-               goto out_err;
-       dev_priv->has_bo_device = 1;
-       ttm_lock_init(&dev_priv->ttm_lock);
+       gma_power_init(dev);
 
        ret = -ENOMEM;
 
@@ -663,15 +596,7 @@ static int psb_driver_load(struct drm_device *dev, unsigned long chipset)
 
        set_pages_uc(dev_priv->scratch_page, 1);
 
-       dev_priv->pg = psb_gtt_alloc(dev);
-       if (!dev_priv->pg)
-               goto out_err;
-
-       ret = psb_gtt_init(dev_priv->pg, 0);
-       if (ret)
-               goto out_err;
-
-       ret = psb_gtt_mm_init(dev_priv->pg);
+       ret = psb_gtt_init(dev, 0);
        if (ret)
                goto out_err;
 
@@ -686,40 +611,6 @@ static int psb_driver_load(struct drm_device *dev, unsigned long chipset)
        tt_pages = (pg->gatt_pages < PSB_TT_PRIV0_PLIMIT) ?
                (pg->gatt_pages) : PSB_TT_PRIV0_PLIMIT;
 
-       /* CI/RAR use the lower half of TT. */
-       pg->ci_start = (tt_pages / 2) << PAGE_SHIFT;
-       pg->rar_start = pg->ci_start + pg->ci_stolen_size;
-
-
-       /*
-        * Make MSVDX/TOPAZ MMU aware of the CI stolen memory area.
-        */
-       if (dev_priv->pg->ci_stolen_size != 0) {
-               down_read(&pg->sem);
-               ret = psb_mmu_insert_pfn_sequence(psb_mmu_get_default_pd
-                               (dev_priv->mmu),
-                               dev_priv->ci_region_start >> PAGE_SHIFT,
-                               pg->mmu_gatt_start + pg->ci_start,
-                               pg->ci_stolen_size >> PAGE_SHIFT, 0);
-               up_read(&pg->sem);
-               if (ret)
-                       goto out_err;
-       }
-
-       /*
-        * Make MSVDX/TOPAZ MMU aware of the rar stolen memory area.
-        */
-       if (dev_priv->pg->rar_stolen_size != 0) {
-               down_read(&pg->sem);
-               ret = psb_mmu_insert_pfn_sequence(
-                               psb_mmu_get_default_pd(dev_priv->mmu),
-                               dev_priv->rar_region_start >> PAGE_SHIFT,
-                               pg->mmu_gatt_start + pg->rar_start,
-                               pg->rar_stolen_size >> PAGE_SHIFT, 0);
-               up_read(&pg->sem);
-               if (ret)
-                       goto out_err;
-       }
 
        dev_priv->pf_pd = psb_mmu_alloc_pd(dev_priv->mmu, 1, 0);
        if (!dev_priv->pf_pd)
@@ -728,14 +619,13 @@ static int psb_driver_load(struct drm_device *dev, unsigned long chipset)
        psb_mmu_set_pd_context(psb_mmu_get_default_pd(dev_priv->mmu), 0);
        psb_mmu_set_pd_context(dev_priv->pf_pd, 1);
 
-       spin_lock_init(&dev_priv->sequence_lock);
-
-       PSB_DEBUG_INIT("Begin to init MSVDX/Topaz\n");
-
        ret = psb_do_init(dev);
        if (ret)
                return ret;
 
+       PSB_WSGX32(0x20000000, PSB_CR_PDS_EXEC_BASE);
+       PSB_WSGX32(0x30000000, PSB_CR_BIF_3D_REQ_BASE);
+
 /*     igd_opregion_init(&dev_priv->opregion_dev); */
        acpi_video_register();
        if (dev_priv->lid_state)
@@ -783,11 +673,6 @@ static int psb_driver_load(struct drm_device *dev, unsigned long chipset)
 #endif
        /*Intel drm driver load is done, continue doing pvr load*/
        DRM_DEBUG("Pvr driver load\n");
-
-/*     if (PVRCore_Init() < 0)
-               goto out_err; */
-/*     if (MRSTLFBInit(dev) < 0)
-               goto out_err;*/
        return 0;
 out_err:
        psb_driver_unload(dev);
@@ -800,45 +685,6 @@ int psb_driver_device_is_agp(struct drm_device *dev)
 }
 
 
-static int psb_vt_leave_ioctl(struct drm_device *dev, void *data,
-                             struct drm_file *file_priv)
-{
-       struct drm_psb_private *dev_priv = psb_priv(dev);
-       struct ttm_bo_device *bdev = &dev_priv->bdev;
-       struct ttm_mem_type_manager *man;
-       int ret;
-
-       ret = ttm_vt_lock(&dev_priv->ttm_lock, 1,
-                            psb_fpriv(file_priv)->tfile);
-       if (unlikely(ret != 0))
-               return ret;
-
-       ret = ttm_bo_evict_mm(&dev_priv->bdev, TTM_PL_TT);
-       if (unlikely(ret != 0))
-               goto out_unlock;
-
-       man = &bdev->man[TTM_PL_TT];
-
-#if 0          /* What to do with this ? */
-       if (unlikely(!drm_mm_clean(&man->manager)))
-               DRM_INFO("Warning: GATT was not clean after VT switch.\n");
-#endif
-
-       ttm_bo_swapout_all(&dev_priv->bdev);
-
-       return 0;
-out_unlock:
-       (void) ttm_vt_unlock(&dev_priv->ttm_lock);
-       return ret;
-}
-
-static int psb_vt_enter_ioctl(struct drm_device *dev, void *data,
-                             struct drm_file *file_priv)
-{
-       struct drm_psb_private *dev_priv = psb_priv(dev);
-       return ttm_vt_unlock(&dev_priv->ttm_lock);
-}
-
 static int psb_sizes_ioctl(struct drm_device *dev, void *data,
                           struct drm_file *file_priv)
 {
@@ -945,13 +791,12 @@ static int psb_dpst_ioctl(struct drm_device *dev, void *data,
        uint32_t y;
        uint32_t reg;
 
-       if (!ospm_power_using_hw_begin(OSPM_DISPLAY_ISLAND,
-                                                       OSPM_UHB_ONLY_IF_ON))
-               return 0;
+       if (!gma_power_begin(dev, 0))
+               return -EIO;
 
        reg = PSB_RVDC32(PIPEASRC);
 
-       ospm_power_using_hw_end(OSPM_DISPLAY_ISLAND);
+       gma_power_end(dev);
 
        /* horizontal is the left 16 bits */
        x = reg >> 16;
@@ -1028,13 +873,12 @@ static int psb_mode_operation_ioctl(struct drm_device *dev, void *data,
                drm_fb = obj_to_fb(obj);
                psb_fb = to_psb_fb(drm_fb);
 
-               if (ospm_power_using_hw_begin(OSPM_DISPLAY_ISLAND,
-                                             OSPM_UHB_ONLY_IF_ON)) {
-                       REG_WRITE(DSPASURF, psb_fb->offset);
+               if (gma_power_begin(dev, 0)) {
+                       REG_WRITE(DSPASURF, psb_fb->gtt->offset);
                        REG_READ(DSPASURF);
-                       ospm_power_using_hw_end(OSPM_DISPLAY_ISLAND);
+                       gma_power_end(dev);
                } else {
-                       dev_priv->saveDSPASURF = psb_fb->offset;
+                       dev_priv->saveDSPASURF = psb_fb->gtt->offset;
                }
 
                return 0;
@@ -1107,8 +951,8 @@ static int psb_stolen_memory_ioctl(struct drm_device *dev, void *data,
        struct drm_psb_private *dev_priv = psb_priv(dev);
        struct drm_psb_stolen_memory_arg *arg = data;
 
-       arg->base = dev_priv->pg->stolen_base;
-       arg->size = dev_priv->pg->vram_stolen_size;
+       arg->base = dev_priv->stolen_base;
+       arg->size = dev_priv->vram_stolen_size;
 
        return 0;
 }
@@ -1118,11 +962,10 @@ static int psb_register_rw_ioctl(struct drm_device *dev, void *data,
 {
        struct drm_psb_private *dev_priv = psb_priv(dev);
        struct drm_psb_register_rw_arg *arg = data;
-       UHBUsage usage =
-         arg->b_force_hw_on ? OSPM_UHB_FORCE_POWER_ON : OSPM_UHB_ONLY_IF_ON;
+       bool usage = arg->b_force_hw_on ? true : false;
 
        if (arg->display_write_mask != 0) {
-               if (ospm_power_using_hw_begin(OSPM_DISPLAY_ISLAND, usage)) {
+               if (gma_power_begin(dev, usage)) {
                        if (arg->display_write_mask & REGRWBITS_PFIT_CONTROLS)
                                PSB_WVDC32(arg->display.pfit_controls,
                                           PFIT_CONTROL);
@@ -1147,7 +990,7 @@ static int psb_register_rw_ioctl(struct drm_device *dev, void *data,
                        if (arg->display_write_mask & REGRWBITS_VTOTAL_B)
                                PSB_WVDC32(arg->display.vtotal_b,
                                           VTOTAL_B);
-                       ospm_power_using_hw_end(OSPM_DISPLAY_ISLAND);
+                       gma_power_end(dev);
                } else {
                        if (arg->display_write_mask & REGRWBITS_PFIT_CONTROLS)
                                dev_priv->savePFIT_CONTROL =
@@ -1172,7 +1015,7 @@ static int psb_register_rw_ioctl(struct drm_device *dev, void *data,
        }
 
        if (arg->display_read_mask != 0) {
-               if (ospm_power_using_hw_begin(OSPM_DISPLAY_ISLAND, usage)) {
+               if (gma_power_begin(dev, usage)) {
                        if (arg->display_read_mask &
                            REGRWBITS_PFIT_CONTROLS)
                                arg->display.pfit_controls =
@@ -1193,7 +1036,7 @@ static int psb_register_rw_ioctl(struct drm_device *dev, void *data,
                                arg->display.vtotal_a = PSB_RVDC32(VTOTAL_A);
                        if (arg->display_read_mask & REGRWBITS_VTOTAL_B)
                                arg->display.vtotal_b = PSB_RVDC32(VTOTAL_B);
-                       ospm_power_using_hw_end(OSPM_DISPLAY_ISLAND);
+                       gma_power_end(dev);
                } else {
                        if (arg->display_read_mask &
                            REGRWBITS_PFIT_CONTROLS)
@@ -1219,7 +1062,7 @@ static int psb_register_rw_ioctl(struct drm_device *dev, void *data,
        }
 
        if (arg->overlay_write_mask != 0) {
-               if (ospm_power_using_hw_begin(OSPM_DISPLAY_ISLAND, usage)) {
+               if (gma_power_begin(dev, usage)) {
                        if (arg->overlay_write_mask & OV_REGRWBITS_OGAM_ALL) {
                                PSB_WVDC32(arg->overlay.OGAMC5, OV_OGAMC5);
                                PSB_WVDC32(arg->overlay.OGAMC4, OV_OGAMC4);
@@ -1270,7 +1113,7 @@ static int psb_register_rw_ioctl(struct drm_device *dev, void *data,
                                        }
                                }
                        }
-                       ospm_power_using_hw_end(OSPM_DISPLAY_ISLAND);
+                       gma_power_end(dev);
                } else {
                        if (arg->overlay_write_mask & OV_REGRWBITS_OGAM_ALL) {
                                dev_priv->saveOV_OGAMC5 = arg->overlay.OGAMC5;
@@ -1296,7 +1139,7 @@ static int psb_register_rw_ioctl(struct drm_device *dev, void *data,
        }
 
        if (arg->overlay_read_mask != 0) {
-               if (ospm_power_using_hw_begin(OSPM_DISPLAY_ISLAND, usage)) {
+               if (gma_power_begin(dev, usage)) {
                        if (arg->overlay_read_mask & OV_REGRWBITS_OGAM_ALL) {
                                arg->overlay.OGAMC5 = PSB_RVDC32(OV_OGAMC5);
                                arg->overlay.OGAMC4 = PSB_RVDC32(OV_OGAMC4);
@@ -1317,7 +1160,7 @@ static int psb_register_rw_ioctl(struct drm_device *dev, void *data,
                                arg->overlay.OVADD = PSB_RVDC32(OV_OVADD);
                        if (arg->overlay_read_mask & OVC_REGRWBITS_OVADD)
                                arg->overlay.OVADD = PSB_RVDC32(OVC_OVADD);
-                       ospm_power_using_hw_end(OSPM_DISPLAY_ISLAND);
+                       gma_power_end(dev);
                } else {
                        if (arg->overlay_read_mask & OV_REGRWBITS_OGAM_ALL) {
                                arg->overlay.OGAMC5 = dev_priv->saveOV_OGAMC5;
@@ -1343,7 +1186,7 @@ static int psb_register_rw_ioctl(struct drm_device *dev, void *data,
        }
 
        if (arg->sprite_enable_mask != 0) {
-               if (ospm_power_using_hw_begin(OSPM_DISPLAY_ISLAND, usage)) {
+               if (gma_power_begin(dev, usage)) {
                        PSB_WVDC32(0x1F3E, DSPARB);
                        PSB_WVDC32(arg->sprite.dspa_control
                                        | PSB_RVDC32(DSPACNTR), DSPACNTR);
@@ -1358,22 +1201,22 @@ static int psb_register_rw_ioctl(struct drm_device *dev, void *data,
                        PSB_WVDC32(arg->sprite.dspc_size, DSPCSIZE);
                        PSB_WVDC32(arg->sprite.dspc_surface, DSPCSURF);
                        PSB_RVDC32(DSPCSURF);
-                       ospm_power_using_hw_end(OSPM_DISPLAY_ISLAND);
+                       gma_power_end(dev);
                }
        }
 
        if (arg->sprite_disable_mask != 0) {
-               if (ospm_power_using_hw_begin(OSPM_DISPLAY_ISLAND, usage)) {
+               if (gma_power_begin(dev, usage)) {
                        PSB_WVDC32(0x3F3E, DSPARB);
                        PSB_WVDC32(0x0, DSPCCNTR);
                        PSB_WVDC32(arg->sprite.dspc_surface, DSPCSURF);
                        PSB_RVDC32(DSPCSURF);
-                       ospm_power_using_hw_end(OSPM_DISPLAY_ISLAND);
+                       gma_power_end(dev);
                }
        }
 
        if (arg->subpicture_enable_mask != 0) {
-               if (ospm_power_using_hw_begin(OSPM_DISPLAY_ISLAND, usage)) {
+               if (gma_power_begin(dev, usage)) {
                        uint32_t temp;
                        if (arg->subpicture_enable_mask & REGRWBITS_DSPACNTR) {
                                temp =  PSB_RVDC32(DSPACNTR);
@@ -1417,12 +1260,12 @@ static int psb_register_rw_ioctl(struct drm_device *dev, void *data,
                                PSB_WVDC32(temp, DSPCSURF);
                                PSB_RVDC32(DSPCSURF);
                        }
-                       ospm_power_using_hw_end(OSPM_DISPLAY_ISLAND);
+                       gma_power_end(dev);
                }
        }
 
        if (arg->subpicture_disable_mask != 0) {
-               if (ospm_power_using_hw_begin(OSPM_DISPLAY_ISLAND, usage)) {
+               if (gma_power_begin(dev, usage)) {
                        uint32_t temp;
                        if (arg->subpicture_disable_mask & REGRWBITS_DSPACNTR) {
                                temp =  PSB_RVDC32(DSPACNTR);
@@ -1463,42 +1306,20 @@ static int psb_register_rw_ioctl(struct drm_device *dev, void *data,
                                PSB_WVDC32(temp, DSPCSURF);
                                PSB_RVDC32(DSPCSURF);
                        }
-                       ospm_power_using_hw_end(OSPM_DISPLAY_ISLAND);
+                       gma_power_end(dev);
                }
        }
 
        return 0;
 }
 
-/* always available as we are SIGIO'd */
-static unsigned int psb_poll(struct file *filp,
-                            struct poll_table_struct *wait)
-{
-       return POLLIN | POLLRDNORM;
-}
-
-/* Not sure what we will need yet - in the PVR driver this disappears into
-   a tangle of abstracted handlers and per process crap */
-
-struct psb_priv {
-       int dummy;
-};
-
 static int psb_driver_open(struct drm_device *dev, struct drm_file *priv)
 {
-       struct psb_priv *psb = kzalloc(sizeof(struct psb_priv), GFP_KERNEL);
-       if (psb == NULL)
-               return -ENOMEM;
-       priv->driver_priv = psb;
-       DRM_DEBUG("\n");
-       /*return PVRSRVOpen(dev, priv);*/
        return 0;
 }
 
 static void psb_driver_close(struct drm_device *dev, struct drm_file *priv)
 {
-       kfree(priv->driver_priv);
-       priv->driver_priv = NULL;
 }
 
 static long psb_unlocked_ioctl(struct file *filp, unsigned int cmd,
@@ -1517,30 +1338,9 @@ static long psb_unlocked_ioctl(struct file *filp, unsigned int cmd,
                pm_runtime_allow(&dev->pdev->dev);
                dev_priv->rpm_enabled = 1;
        }
-       /*
-        * The driver private ioctls and TTM ioctls should be
-        * thread-safe.
-        */
-
-       if ((nr >= DRM_COMMAND_BASE) && (nr < DRM_COMMAND_END)
-            && (nr < DRM_COMMAND_BASE + dev->driver->num_ioctls)) {
-               struct drm_ioctl_desc *ioctl =
-                                       &psb_ioctls[nr - DRM_COMMAND_BASE];
-
-               if (unlikely(ioctl->cmd != cmd)) {
-                       DRM_ERROR(
-                               "Invalid drm cmnd %d ioctl->cmd %x, cmd %x\n",
-                               nr - DRM_COMMAND_BASE, ioctl->cmd, cmd);
-                       return -EINVAL;
-               }
-
-               return drm_ioctl(filp, cmd, arg);
-       }
-       /*
-        * Not all old drm ioctls are thread-safe.
-        */
-
        return drm_ioctl(filp, cmd, arg);
+       
+       /* FIXME: do we need to wrap the other side of this */
 }
 
 
@@ -1557,16 +1357,21 @@ static void psb_remove(struct pci_dev *pdev)
        drm_put_dev(dev);
 }
 
-
 static const struct dev_pm_ops psb_pm_ops = {
        .runtime_suspend = psb_runtime_suspend,
        .runtime_resume = psb_runtime_resume,
        .runtime_idle = psb_runtime_idle,
 };
 
+static struct vm_operations_struct psb_gem_vm_ops = {
+       .fault = psb_gem_fault,
+       .open = drm_gem_vm_open,
+       .close = drm_gem_vm_close,
+};
+
 static struct drm_driver driver = {
        .driver_features = DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED | \
-                          DRIVER_IRQ_VBL | DRIVER_MODESET,
+                          DRIVER_IRQ_VBL | DRIVER_MODESET| DRIVER_GEM ,
        .load = psb_driver_load,
        .unload = psb_driver_unload,
 
@@ -1580,27 +1385,29 @@ static struct drm_driver driver = {
        .enable_vblank = psb_enable_vblank,
        .disable_vblank = psb_disable_vblank,
        .get_vblank_counter = psb_get_vblank_counter,
-       .firstopen = NULL,
        .lastclose = psb_lastclose,
        .open = psb_driver_open,
-       .postclose = psb_driver_close,
-#if 0  /* ACFIXME */
-       .get_map_ofs = drm_core_get_map_ofs,
-       .get_reg_ofs = drm_core_get_reg_ofs,
-       .proc_init = psb_proc_init,
-       .proc_cleanup = psb_proc_cleanup,
-#endif
        .preclose = psb_driver_preclose,
+       .postclose = psb_driver_close,
+       .reclaim_buffers = drm_core_reclaim_buffers,
+
+       .gem_init_object = psb_gem_init_object,
+       .gem_free_object = psb_gem_free_object,
+       .gem_vm_ops = &psb_gem_vm_ops,
+       .dumb_create = psb_gem_dumb_create,
+       .dumb_map_offset = psb_gem_dumb_map_gtt,
+       .dumb_destroy = psb_gem_dumb_destroy,
+
        .fops = {
                 .owner = THIS_MODULE,
-                .open = psb_open,
-                .release = psb_release,
+                .open = drm_open,
+                .release = drm_release,
                 .unlocked_ioctl = psb_unlocked_ioctl,
-                .mmap = psb_mmap,
-                .poll = psb_poll,
+                .mmap = drm_gem_mmap,
+                .poll = drm_poll,
                 .fasync = drm_fasync,
                 .read = drm_read,
-                },
+        },
        .name = DRIVER_NAME,
        .desc = DRIVER_DESC,
        .date = PSB_DRM_DRIVER_DATE,
@@ -1612,8 +1419,8 @@ static struct drm_driver driver = {
 static struct pci_driver psb_pci_driver = {
        .name = DRIVER_NAME,
        .id_table = pciidlist,
-       .resume = ospm_power_resume,
-       .suspend = ospm_power_suspend,
+       .resume = gma_power_resume,
+       .suspend = gma_power_suspend,
        .probe = psb_probe,
        .remove = psb_remove,
 #ifdef CONFIG_PM
index 29a36056d66409f2fb860446fdc3edd76e0f66fa..e19a454787573bbd3de6a6e95058ad357c811ac8 100644 (file)
@@ -21,6 +21,7 @@
 #define _PSB_DRV_H_
 
 #include <linux/version.h>
+#include <linux/kref.h>
 
 #include <drm/drmP.h>
 #include "drm_global.h"
 #include "psb_intel_drv.h"
 #include "psb_gtt.h"
 #include "psb_powermgmt.h"
-#include "ttm/ttm_object.h"
-#include "psb_ttm_fence_driver.h"
-#include "psb_ttm_userobj_api.h"
-#include "ttm/ttm_bo_driver.h"
-#include "ttm/ttm_lock.h"
+#include "mrst.h"
 
 /*Append new drm mode definition here, align with libdrm definition*/
 #define DRM_MODE_SCALE_NO_SCALE   2
 
-extern struct ttm_bo_driver psb_ttm_bo_driver;
-
 enum {
        CHIP_PSB_8108 = 0,
        CHIP_PSB_8109 = 1,
+       CHIP_MRST_4100 = 2,
 };
 
+#define IS_MRST(dev) (((dev)->pci_device & 0xfffc) == 0x4100)
+
 /*
  *Hardware bugfixes
  */
@@ -52,10 +50,6 @@ enum {
 #define DRIVER_NAME "pvrsrvkm"
 #define DRIVER_DESC "drm driver for the Intel GMA500"
 #define DRIVER_AUTHOR "Intel Corporation"
-#define OSPM_PROC_ENTRY "ospm"
-#define RTPM_PROC_ENTRY "rtpm"
-#define BLC_PROC_ENTRY "mrst_blc"
-#define DISPLAY_PROC_ENTRY "display_status"
 
 #define PSB_DRM_DRIVER_DATE "2009-03-10"
 #define PSB_DRM_DRIVER_MAJOR 8
@@ -92,26 +86,10 @@ enum {
 #define PSB_TT_PRIV0_PLIMIT     (PSB_TT_PRIV0_LIMIT >> PAGE_SHIFT)
 #define PSB_NUM_VALIDATE_BUFFERS 2048
 
-#define PSB_MEM_MMU_START       0x00000000
-#define PSB_MEM_TT_START        0xE0000000
-
-#define PSB_GL3_CACHE_CTL      0x2100
-#define PSB_GL3_CACHE_STAT     0x2108
-
 /*
  *Flags for external memory type field.
  */
 
-#define MRST_MSVDX_OFFSET      0x90000 /*MSVDX Base offset */
-#define PSB_MSVDX_OFFSET       0x50000 /*MSVDX Base offset */
-/* MSVDX MMIO region is 0x50000 - 0x57fff ==> 32KB */
-#define PSB_MSVDX_SIZE         0x10000
-
-#define LNC_TOPAZ_OFFSET       0xA0000
-#define PNW_TOPAZ_OFFSET       0xC0000
-#define PNW_GL3_OFFSET         0xB0000
-#define LNC_TOPAZ_SIZE         0x10000
-#define PNW_TOPAZ_SIZE         0x30000 /* PNW VXE285 has two cores */
 #define PSB_MMU_CACHED_MEMORY    0x0001        /* Bind to MMU only */
 #define PSB_MMU_RO_MEMORY        0x0002        /* MMU RO memory */
 #define PSB_MMU_WO_MEMORY        0x0004        /* MMU WO memory */
@@ -223,20 +201,6 @@ enum {
 #define MDFLD_PNW_B0 0x04
 #define MDFLD_PNW_C0 0x08
 
-#define MDFLD_DSR_2D_3D_0 BIT0
-#define MDFLD_DSR_2D_3D_2 BIT1
-#define MDFLD_DSR_CURSOR_0 BIT2
-#define MDFLD_DSR_CURSOR_2 BIT3
-#define MDFLD_DSR_OVERLAY_0 BIT4
-#define MDFLD_DSR_OVERLAY_2 BIT5
-#define MDFLD_DSR_MIPI_CONTROL BIT6
-#define MDFLD_DSR_2D_3D        (MDFLD_DSR_2D_3D_0 | MDFLD_DSR_2D_3D_2)
-
-#define MDFLD_DSR_RR 45
-#define MDFLD_DPU_ENABLE BIT31
-#define MDFLD_DSR_FULLSCREEN BIT30
-#define MDFLD_DSR_DELAY (DRM_HZ / MDFLD_DSR_RR)
-
 #define PSB_PWR_STATE_ON               1
 #define PSB_PWR_STATE_OFF              2
 
@@ -250,9 +214,6 @@ enum {
 #define PSB_PCIx_MSI_ADDR_LOC          0x94
 #define PSB_PCIx_MSI_DATA_LOC          0x98
 
-#define MDFLD_PLANE_MAX_WIDTH          2048
-#define MDFLD_PLANE_MAX_HEIGHT         2048
-
 struct opregion_header;
 struct opregion_acpi;
 struct opregion_swsci;
@@ -266,142 +227,55 @@ struct psb_intel_opregion {
        int enabled;
 };
 
-/*
- *User options.
- */
-
-struct drm_psb_uopt {
-       int pad; /*keep it here in case we use it in future*/
-};
-
-/**
- *struct psb_context
- *
- *@buffers:     array of pre-allocated validate buffers.
- *@used_buffers: number of buffers in @buffers array currently in use.
- *@validate_buffer: buffers validated from user-space.
- *@kern_validate_buffers : buffers validated from kernel-space.
- *@fence_flags : Fence flags to be used for fence creation.
- *
- *This structure is used during execbuf validation.
- */
-
-struct psb_context {
-       struct psb_validate_buffer *buffers;
-       uint32_t used_buffers;
-       struct list_head validate_list;
-       struct list_head kern_validate_list;
-       uint32_t fence_types;
-       uint32_t val_seq;
-};
-
-struct psb_validate_buffer;
-
-/* Currently defined profiles */
-enum VAProfile {
-       VAProfileMPEG2Simple            = 0,
-       VAProfileMPEG2Main              = 1,
-       VAProfileMPEG4Simple            = 2,
-       VAProfileMPEG4AdvancedSimple    = 3,
-       VAProfileMPEG4Main              = 4,
-       VAProfileH264Baseline           = 5,
-       VAProfileH264Main               = 6,
-       VAProfileH264High               = 7,
-       VAProfileVC1Simple              = 8,
-       VAProfileVC1Main                = 9,
-       VAProfileVC1Advanced            = 10,
-       VAProfileH263Baseline           = 11,
-       VAProfileJPEGBaseline           = 12,
-       VAProfileH264ConstrainedBaseline = 13
-};
-
-/* Currently defined entrypoints */
-enum VAEntrypoint {
-       VAEntrypointVLD         = 1,
-       VAEntrypointIZZ         = 2,
-       VAEntrypointIDCT        = 3,
-       VAEntrypointMoComp      = 4,
-       VAEntrypointDeblocking  = 5,
-       VAEntrypointEncSlice    = 6,    /* slice level encode */
-       VAEntrypointEncPicture  = 7     /* pictuer encode, JPEG, etc */
-};
-
-
-struct psb_video_ctx {
-       struct list_head head;
-       struct file *filp; /* DRM device file pointer */
-       int ctx_type; /* profile<<8|entrypoint */
-       /* todo: more context specific data for multi-context support */
-};
-
-#define MODE_SETTING_IN_CRTC   0x1
-#define MODE_SETTING_IN_ENCODER 0x2
-#define MODE_SETTING_ON_GOING  0x3
-#define MODE_SETTING_IN_DSR    0x4
-#define MODE_SETTING_ENCODER_DONE 0x8
-#define GCT_R10_HEADER_SIZE    16
-#define GCT_R10_DISPLAY_DESC_SIZE      28
 
 struct drm_psb_private {
-       /*
-        * DSI info.
-        */
-       void * dbi_dsr_info;
-       void * dsi_configs[2];
-
-       /*
-        *TTM Glue.
-        */
-
-       struct drm_global_reference mem_global_ref;
-       struct ttm_bo_global_ref bo_global_ref;
-       int has_global;
-
        struct drm_device *dev;
-       struct ttm_object_device *tdev;
-       struct ttm_fence_device fdev;
-       struct ttm_bo_device bdev;
-       struct ttm_lock ttm_lock;
-       struct vm_operations_struct *ttm_vm_ops;
-       int has_fence_device;
-       int has_bo_device;
 
        unsigned long chipset;
 
-       struct drm_psb_uopt uopt;
-
        struct psb_gtt *pg;
 
-       /*GTT Memory manager*/
+       /* GTT Memory manager */
        struct psb_gtt_mm *gtt_mm;
-
        struct page *scratch_page;
-       uint32_t sequence[PSB_NUM_ENGINES];
-       uint32_t last_sequence[PSB_NUM_ENGINES];
-       uint32_t last_submitted_seq[PSB_NUM_ENGINES];
+       u32 *gtt_map;
+       uint32_t stolen_base;
+       void *vram_addr;
+       unsigned long vram_stolen_size;
+       int gtt_initialized;
+       u16 gmch_ctrl;          /* Saved GTT setup */
+       u32 pge_ctl;
+
+       struct mutex gtt_mutex;
+       struct resource *gtt_mem;       /* Our PCI resource */
 
        struct psb_mmu_driver *mmu;
        struct psb_mmu_pd *pf_pd;
 
+       /*
+        * Register base
+        */
+
        uint8_t *sgx_reg;
        uint8_t *vdc_reg;
        uint32_t gatt_free_offset;
 
-       /* IMG video context */
-       struct list_head video_ctx;
-
-
-
        /*
-        *Fencing / irq.
+        * Fencing / irq.
         */
 
        uint32_t vdc_irq_mask;
        uint32_t pipestat[PSB_NUM_PIPE];
-       bool vblanksEnabledForFlips;
 
        spinlock_t irqmask_lock;
-       spinlock_t sequence_lock;
+
+       /*
+        * Power
+         */
+
+       bool suspended;
+       bool display_power;
+       int display_count;
 
        /*
         *Modesetting
@@ -412,41 +286,10 @@ struct drm_psb_private {
        struct drm_crtc *pipe_to_crtc_mapping[PSB_NUM_PIPE];
        uint32_t num_pipe;
 
-       /*
-        * CI share buffer
-        */
-       unsigned int ci_region_start;
-       unsigned int ci_region_size;
-
-       /*
-        * RAR share buffer;
-        */
-       unsigned int rar_region_start;
-       unsigned int rar_region_size;
-
        /*
         *Memory managers
         */
 
-       int have_camera;
-       int have_rar;
-       int have_tt;
-       int have_mem_mmu;
-       struct mutex temp_mem;
-
-       /*
-        *Relocation buffer mapping.
-        */
-
-       spinlock_t reloc_lock;
-       unsigned int rel_mapped_pages;
-       wait_queue_head_t rel_mapped_queue;
-
-       /*
-        *SAREA
-        */
-       struct drm_psb_sarea *sarea_priv;
-
        /*
        *OSPM info
        */
@@ -458,7 +301,8 @@ struct drm_psb_private {
 
        struct drm_psb_sizes_arg sizes;
 
-       uint32_t fuse_reg_value;
+       u32 fuse_reg_value;
+       u32 video_device_fuse;
 
        /* pci revision id for B0:D2:F0 */
        uint8_t platform_rev_id;
@@ -483,6 +327,7 @@ struct drm_psb_private {
        unsigned int lvds_use_ssc:1;
        int lvds_ssc_freq;
        bool is_lvds_on;
+       bool is_mipi_on;
 
        unsigned int core_freq;
        uint32_t iLVDS_enable;
@@ -490,6 +335,20 @@ struct drm_psb_private {
        /*runtime PM state*/
        int rpm_enabled;
 
+       /* Moorestown specific */
+       struct mrst_vbt vbt_data;
+       struct mrst_gct_data gct_data;
+
+       /* Moorestown pipe config register value cache */
+       uint32_t pipeconf;
+       uint32_t pipeconf1;
+       uint32_t pipeconf2;
+
+       /* Moorestown plane control register value cache */
+       uint32_t dspcntr;
+       uint32_t dspcntr1;
+       uint32_t dspcntr2;
+
        /*
         *Register state
         */
@@ -595,97 +454,10 @@ struct drm_psb_private {
        uint32_t saveOVC_OGAMC4;
        uint32_t saveOVC_OGAMC5;
 
-       /*
-        * extra MDFLD Register state
-        */
-       uint32_t saveHDMIPHYMISCCTL;
-       uint32_t saveHDMIB_CONTROL;
-       uint32_t saveDSPCCNTR;
-       uint32_t savePIPECCONF;
-       uint32_t savePIPECSRC;
-       uint32_t saveHTOTAL_C;
-       uint32_t saveHBLANK_C;
-       uint32_t saveHSYNC_C;
-       uint32_t saveVTOTAL_C;
-       uint32_t saveVBLANK_C;
-       uint32_t saveVSYNC_C;
-       uint32_t saveDSPCSTRIDE;
-       uint32_t saveDSPCSIZE;
-       uint32_t saveDSPCPOS;
-       uint32_t saveDSPCSURF;
-       uint32_t saveDSPCLINOFF;
-       uint32_t saveDSPCTILEOFF;
-       uint32_t saveDSPCCURSOR_CTRL;
-       uint32_t saveDSPCCURSOR_BASE;
-       uint32_t saveDSPCCURSOR_POS;
-       uint32_t save_palette_c[256];
-       uint32_t saveOV_OVADD_C;
-       uint32_t saveOV_OGAMC0_C;
-       uint32_t saveOV_OGAMC1_C;
-       uint32_t saveOV_OGAMC2_C;
-       uint32_t saveOV_OGAMC3_C;
-       uint32_t saveOV_OGAMC4_C;
-       uint32_t saveOV_OGAMC5_C;
-
-       /* DSI reg save */
-       uint32_t saveDEVICE_READY_REG;
-       uint32_t saveINTR_EN_REG;
-       uint32_t saveDSI_FUNC_PRG_REG;
-       uint32_t saveHS_TX_TIMEOUT_REG;
-       uint32_t saveLP_RX_TIMEOUT_REG;
-       uint32_t saveTURN_AROUND_TIMEOUT_REG;
-       uint32_t saveDEVICE_RESET_REG;
-       uint32_t saveDPI_RESOLUTION_REG;
-       uint32_t saveHORIZ_SYNC_PAD_COUNT_REG;
-       uint32_t saveHORIZ_BACK_PORCH_COUNT_REG;
-       uint32_t saveHORIZ_FRONT_PORCH_COUNT_REG;
-       uint32_t saveHORIZ_ACTIVE_AREA_COUNT_REG;
-       uint32_t saveVERT_SYNC_PAD_COUNT_REG;
-       uint32_t saveVERT_BACK_PORCH_COUNT_REG;
-       uint32_t saveVERT_FRONT_PORCH_COUNT_REG;
-       uint32_t saveHIGH_LOW_SWITCH_COUNT_REG;
-       uint32_t saveINIT_COUNT_REG;
-       uint32_t saveMAX_RET_PAK_REG;
-       uint32_t saveVIDEO_FMT_REG;
-       uint32_t saveEOT_DISABLE_REG;
-       uint32_t saveLP_BYTECLK_REG;
-       uint32_t saveHS_LS_DBI_ENABLE_REG;
-       uint32_t saveTXCLKESC_REG;
-       uint32_t saveDPHY_PARAM_REG;
-       uint32_t saveMIPI_CONTROL_REG;
-       uint32_t saveMIPI;
-       uint32_t saveMIPI_C;
-       void (*init_drvIC)(struct drm_device *dev);
-       void (*dsi_prePowerState)(struct drm_device *dev);
-       void (*dsi_postPowerState)(struct drm_device *dev);
-
-       /* DPST Register Save */
-       uint32_t saveHISTOGRAM_INT_CONTROL_REG;
-       uint32_t saveHISTOGRAM_LOGIC_CONTROL_REG;
-       uint32_t savePWM_CONTROL_LOGIC;
-
        /* MSI reg save */
-
        uint32_t msi_addr;
        uint32_t msi_data;
 
-       /*
-        *Scheduling.
-        */
-
-       struct mutex reset_mutex;
-       struct mutex cmdbuf_mutex;
-       /*uint32_t ta_mem_pages;
-       struct psb_ta_mem *ta_mem;
-       int force_ta_mem_load;*/
-       atomic_t val_seq;
-
-       /*
-        *TODO: change this to be per drm-context.
-        */
-
-       struct psb_context context;
-
        /*
         * LID-Switch
         */
@@ -699,8 +471,6 @@ struct drm_psb_private {
         *Watchdog
         */
 
-       int timer_available;
-
        uint32_t apm_reg;
        uint16_t apm_base;
 
@@ -716,72 +486,16 @@ struct drm_psb_private {
 };
 
 
-struct psb_file_data { /* TODO: Audit this, remove the indirection and set
-                          it up properly in open/postclose  ACFIXME */
-       void *priv;
-};
-
-struct psb_fpriv {
-       struct ttm_object_file *tfile;
-};
-
 struct psb_mmu_driver;
 
 extern int drm_crtc_probe_output_modes(struct drm_device *dev, int, int);
 extern int drm_pick_crtcs(struct drm_device *dev);
 
-static inline struct psb_fpriv *psb_fpriv(struct drm_file *file_priv)
-{
-       struct psb_file_data *pvr_file_priv
-                       = (struct psb_file_data *)file_priv->driver_priv;
-       return (struct psb_fpriv *) pvr_file_priv->priv;
-}
-
 static inline struct drm_psb_private *psb_priv(struct drm_device *dev)
 {
        return (struct drm_psb_private *) dev->dev_private;
 }
 
-/*
- *TTM glue. psb_ttm_glue.c
- */
-
-extern int psb_open(struct inode *inode, struct file *filp);
-extern int psb_release(struct inode *inode, struct file *filp);
-extern int psb_mmap(struct file *filp, struct vm_area_struct *vma);
-
-extern int psb_fence_signaled_ioctl(struct drm_device *dev, void *data,
-                                   struct drm_file *file_priv);
-extern int psb_verify_access(struct ttm_buffer_object *bo,
-                            struct file *filp);
-extern ssize_t psb_ttm_read(struct file *filp, char __user *buf,
-                           size_t count, loff_t *f_pos);
-extern ssize_t psb_ttm_write(struct file *filp, const char __user *buf,
-                           size_t count, loff_t *f_pos);
-extern int psb_fence_finish_ioctl(struct drm_device *dev, void *data,
-                                 struct drm_file *file_priv);
-extern int psb_fence_unref_ioctl(struct drm_device *dev, void *data,
-                                struct drm_file *file_priv);
-extern int psb_pl_waitidle_ioctl(struct drm_device *dev, void *data,
-                                struct drm_file *file_priv);
-extern int psb_pl_setstatus_ioctl(struct drm_device *dev, void *data,
-                                 struct drm_file *file_priv);
-extern int psb_pl_synccpu_ioctl(struct drm_device *dev, void *data,
-                               struct drm_file *file_priv);
-extern int psb_pl_unref_ioctl(struct drm_device *dev, void *data,
-                             struct drm_file *file_priv);
-extern int psb_pl_reference_ioctl(struct drm_device *dev, void *data,
-                                 struct drm_file *file_priv);
-extern int psb_pl_create_ioctl(struct drm_device *dev, void *data,
-                              struct drm_file *file_priv);
-extern int psb_pl_ub_create_ioctl(struct drm_device *dev, void *data,
-                              struct drm_file *file_priv);
-extern int psb_extension_ioctl(struct drm_device *dev, void *data,
-                              struct drm_file *file_priv);
-extern int psb_ttm_global_init(struct drm_psb_private *dev_priv);
-extern void psb_ttm_global_release(struct drm_psb_private *dev_priv);
-extern int psb_getpageaddrs_ioctl(struct drm_device *dev, void *data,
-                               struct drm_file *file_priv);
 /*
  *MMU stuff.
  */
@@ -824,31 +538,6 @@ extern void psb_mmu_remove_pages(struct psb_mmu_pd *pd,
                                 unsigned long address, uint32_t num_pages,
                                 uint32_t desired_tile_stride,
                                 uint32_t hw_tile_stride);
-/*
- *psb_sgx.c
- */
-
-
-
-extern int psb_cmdbuf_ioctl(struct drm_device *dev, void *data,
-                           struct drm_file *file_priv);
-extern int psb_reg_submit(struct drm_psb_private *dev_priv,
-                         uint32_t *regs, unsigned int cmds);
-
-
-extern void psb_fence_or_sync(struct drm_file *file_priv,
-                             uint32_t engine,
-                             uint32_t fence_types,
-                             uint32_t fence_flags,
-                             struct list_head *list,
-                             struct psb_ttm_fence_rep *fence_arg,
-                             struct ttm_fence_object **fence_p);
-extern int psb_validate_kernel_buffer(struct psb_context *context,
-                                     struct ttm_buffer_object *bo,
-                                     uint32_t fence_class,
-                                     uint64_t set_flags,
-                                     uint64_t clr_flags);
-
 /*
  *psb_irq.c
  */
@@ -859,8 +548,6 @@ extern int psb_irq_disable_dpst(struct drm_device *dev);
 extern void psb_irq_preinstall(struct drm_device *dev);
 extern int psb_irq_postinstall(struct drm_device *dev);
 extern void psb_irq_uninstall(struct drm_device *dev);
-extern void psb_irq_preinstall_islands(struct drm_device *dev, int hw_islands);
-extern int psb_irq_postinstall_islands(struct drm_device *dev, int hw_islands);
 extern void psb_irq_turn_on_dpst(struct drm_device *dev);
 extern void psb_irq_turn_off_dpst(struct drm_device *dev);
 
@@ -877,29 +564,6 @@ psb_disable_pipestat(struct drm_psb_private *dev_priv, int pipe, u32 mask);
 
 extern u32 psb_get_vblank_counter(struct drm_device *dev, int crtc);
 
-/*
- *psb_fence.c
- */
-
-extern void psb_fence_handler(struct drm_device *dev, uint32_t class);
-
-extern int psb_fence_emit_sequence(struct ttm_fence_device *fdev,
-                                  uint32_t fence_class,
-                                  uint32_t flags, uint32_t *sequence,
-                                  unsigned long *timeout_jiffies);
-extern void psb_fence_error(struct drm_device *dev,
-                           uint32_t class,
-                           uint32_t sequence, uint32_t type, int error);
-extern int psb_ttm_fence_device_init(struct ttm_fence_device *fdev);
-
-/* MSVDX/Topaz stuff */
-extern int psb_remove_videoctx(struct drm_psb_private *dev_priv, struct file *filp);
-
-extern int lnc_video_frameskip(struct drm_device *dev,
-                              uint64_t user_pointer);
-extern int lnc_video_getparam(struct drm_device *dev, void *data,
-                             struct drm_file *file_priv);
-
 /*
  * psb_opregion.c
  */
@@ -930,6 +594,9 @@ extern int psbfb_sync(struct fb_info *info);
 
 extern void psb_spank(struct drm_psb_private *dev_priv);
 
+extern int psbfb_2d_submit(struct drm_psb_private *dev_priv, uint32_t *cmdbuf,
+                          unsigned size);
+
 /*
  *psb_reset.c
  */
@@ -950,8 +617,36 @@ int psb_set_brightness(struct backlight_device *bd);
 int psb_get_brightness(struct backlight_device *bd);
 struct backlight_device * psb_get_backlight_device(void);
 
+/* mrst_crtc.c */
+extern const struct drm_crtc_helper_funcs mrst_helper_funcs;
+
+/* mrst_lvds.c */
+extern void mrst_lvds_init(struct drm_device *dev,
+                   struct psb_intel_mode_device *mode_dev);
+
+/* psb_intel_lvds.c */
+extern void psb_intel_lvds_prepare(struct drm_encoder *encoder);
+extern void psb_intel_lvds_commit(struct drm_encoder *encoder);
+extern const struct drm_connector_helper_funcs
+                                       psb_intel_lvds_connector_helper_funcs;
+extern const struct drm_connector_funcs psb_intel_lvds_connector_funcs;
+
+/* psb_gem.c */
+extern int psb_gem_init_object(struct drm_gem_object *obj);
+extern void psb_gem_free_object(struct drm_gem_object *obj);
+extern int psb_gem_get_aperture(struct drm_device *dev, void *data,
+                               struct drm_file *file);
+extern int psb_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
+                       struct drm_mode_create_dumb *args);
+extern int psb_gem_dumb_destroy(struct drm_file *file, struct drm_device *dev,
+                       uint32_t handle);
+extern int psb_gem_dumb_map_gtt(struct drm_file *file, struct drm_device *dev,
+                        uint32_t handle, uint64_t *offset);
+extern int psb_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf);
+
+
 /*
- *Debug print bits setting
+ * Debug print bits setting
  */
 #define PSB_D_GENERAL (1 << 0)
 #define PSB_D_INIT    (1 << 1)
@@ -975,7 +670,6 @@ struct backlight_device * psb_get_backlight_device(void);
 
 extern int drm_psb_debug;
 extern int drm_psb_no_fb;
-extern int drm_psb_disable_vsync;
 extern int drm_idle_check_interval;
 
 #define PSB_DEBUG_GENERAL(_fmt, _arg...) \
index f67f53b12937c74e522586ecde12d0d699a6d736..99c03a2e06bdb32e8a20f579be0f4c975314805c 100644 (file)
 #include "psb_drv.h"
 #include "psb_intel_reg.h"
 #include "psb_intel_drv.h"
-#include "psb_ttm_userobj_api.h"
 #include "psb_fb.h"
-#include "psb_sgx.h"
-#include "psb_pvr_glue.h"
 
 static void psb_user_framebuffer_destroy(struct drm_framebuffer *fb);
 static int psb_user_framebuffer_create_handle(struct drm_framebuffer *fb,
@@ -193,8 +190,7 @@ static int psbfb_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
        struct psb_framebuffer *psbfb = vma->vm_private_data;
        struct drm_device *dev = psbfb->base.dev;
        struct drm_psb_private *dev_priv = dev->dev_private;
-       struct psb_gtt *pg = dev_priv->pg;
-       unsigned long phys_addr = (unsigned long)pg->stolen_base;;
+       unsigned long phys_addr = (unsigned long)dev_priv->stolen_base;
 
        page_num = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT;
 
@@ -243,7 +239,6 @@ static int psbfb_mmap(struct fb_info *info, struct vm_area_struct *vma)
        char *fb_screen_base = NULL;
        struct drm_device *dev = psbfb->base.dev;
        struct drm_psb_private *dev_priv = dev->dev_private;
-       struct psb_gtt *pg = dev_priv->pg;
 
        if (vma->vm_pgoff != 0)
                return -EINVAL;
@@ -256,22 +251,48 @@ static int psbfb_mmap(struct fb_info *info, struct vm_area_struct *vma)
        fb_screen_base = (char *)info->screen_base;
 
        DRM_DEBUG("vm_pgoff 0x%lx, screen base %p vram_addr %p\n",
-                               vma->vm_pgoff, fb_screen_base, pg->vram_addr);
+                               vma->vm_pgoff, fb_screen_base,
+                                dev_priv->vram_addr);
 
-       /*if using stolen memory, */
-       if (fb_screen_base == pg->vram_addr) {
+        /* FIXME: ultimately this needs to become 'if entirely stolen memory' */
+       if (1 || fb_screen_base == dev_priv->vram_addr) {
                vma->vm_ops = &psbfb_vm_ops;
                vma->vm_private_data = (void *)psbfb;
                vma->vm_flags |= VM_RESERVED | VM_IO |
                                                VM_MIXEDMAP | VM_DONTEXPAND;
        } else {
-       /*using IMG meminfo, can I use pvrmmap to map it?*/
-
+               /* GTT memory backed by kernel/user pages, needs a different
+                  approach ? - GEM ? */
        }
 
        return 0;
 }
 
+static int psbfb_ioctl(struct fb_info *info, unsigned int cmd, unsigned long arg)
+{
+       struct psb_fbdev *fbdev = info->par;
+       struct psb_framebuffer *psbfb = fbdev->pfb;
+       struct drm_device *dev = psbfb->base.dev;
+       struct drm_psb_private *dev_priv = dev->dev_private;
+       u32 __user *p = (u32 __user *)arg;
+       u32 l;
+       u32 buf[32];
+       switch (cmd) {
+       case 0x12345678:
+               if (!capable(CAP_SYS_RAWIO))
+                       return -EPERM;
+               if (get_user(l, p))
+                       return -EFAULT;
+               if (l > 32)
+                       return -EMSGSIZE;
+               if (copy_from_user(buf, p + 1, l * sizeof(u32)))
+                       return -EFAULT;
+               psbfb_2d_submit(dev_priv, buf, l);
+               return 0;
+       default:
+               return -ENOTTY;
+       }
+}
 
 static struct fb_ops psbfb_ops = {
        .owner = THIS_MODULE,
@@ -284,11 +305,12 @@ static struct fb_ops psbfb_ops = {
        .fb_imageblit = psbfb_imageblit,
        .fb_mmap = psbfb_mmap,
        .fb_sync = psbfb_sync,
+       .fb_ioctl = psbfb_ioctl,
 };
 
 static struct drm_framebuffer *psb_framebuffer_create
                        (struct drm_device *dev, struct drm_mode_fb_cmd *r,
-                        void *mm_private)
+                        struct gtt_range *gt)
 {
        struct psb_framebuffer *fb;
        int ret;
@@ -304,7 +326,7 @@ static struct drm_framebuffer *psb_framebuffer_create
 
        drm_helper_mode_fill_fb_struct(&fb->base, r);
 
-       fb->bo = mm_private;
+       fb->gtt = gt;
 
        return &fb->base;
 
@@ -313,136 +335,58 @@ err:
        return NULL;
 }
 
-static struct drm_framebuffer *psb_user_framebuffer_create
-                       (struct drm_device *dev, struct drm_file *filp,
-                        struct drm_mode_fb_cmd *r)
-{
-       struct ttm_buffer_object *bo = NULL;
-       uint64_t size;
-
-       bo = ttm_buffer_object_lookup(psb_fpriv(filp)->tfile, r->handle);
-       if (!bo)
-               return NULL;
-
-       /* JB: TODO not drop, make smarter */
-       size = ((uint64_t) bo->num_pages) << PAGE_SHIFT;
-       if (size < r->width * r->height * 4)
-               return NULL;
-
-       /* JB: TODO not drop, refcount buffer */
-       return psb_framebuffer_create(dev, r, bo);
-
-#if 0
-       struct psb_framebuffer *psbfb;
-       struct drm_framebuffer *fb;
-       struct fb_info *info;
-       void *psKernelMemInfo = NULL;
-       void * hKernelMemInfo = (void *)r->handle;
-       struct drm_psb_private *dev_priv
-               = (struct drm_psb_private *)dev->dev_private;
-       struct psb_fbdev *fbdev = dev_priv->fbdev;
-       struct psb_gtt *pg = dev_priv->pg;
-       int ret;
-       uint32_t offset;
-       uint64_t size;
-
-       ret = psb_get_meminfo_by_handle(hKernelMemInfo, &psKernelMemInfo);
-       if (ret) {
-               DRM_ERROR("Cannot get meminfo for handle 0x%x\n",
-                                               (u32)hKernelMemInfo);
-               return NULL;
-       }
-
-       DRM_DEBUG("Got Kernel MemInfo for handle %lx\n",
-                 (u32)hKernelMemInfo);
-
-       /* JB: TODO not drop, make smarter */
-       size = psKernelMemInfo->ui32AllocSize;
-       if (size < r->height * r->pitch)
+/**
+ *     psbfb_alloc             -       allocate frame buffer memory
+ *     @dev: the DRM device
+ *     @aligned_size: space needed
+ *
+ *     Allocate the frame buffer. In the usual case we get a GTT range that
+ *     is stolen memory backed and life is simple. If there isn't sufficient
+ *     stolen memory or the system has no stolen memory we allocate a range
+ *     and back it with a GEM object.
+ *
+ *     In this case the GEM object has no handle. 
+ */
+static struct gtt_range *psbfb_alloc(struct drm_device *dev, int aligned_size)
+{
+       struct gtt_range *backing;
+       /* Begin by trying to use stolen memory backing */
+       backing = psb_gtt_alloc_range(dev, aligned_size, "fb", 1);
+       if (backing)
+               return backing;
+       /* Next try using GEM host memory */
+       backing = psb_gtt_alloc_range(dev, aligned_size, "fb(gem)", 0);
+       if (backing == NULL)
                return NULL;
 
-       /* JB: TODO not drop, refcount buffer */
-       /* return psb_framebuffer_create(dev, r, bo); */
-
-       fb = psb_framebuffer_create(dev, r, (void *)psKernelMemInfo);
-       if (!fb) {
-               DRM_ERROR("failed to allocate fb.\n");
+       /* Now back it with an object */
+       if (drm_gem_object_init(dev, &backing->gem, aligned_size) != 0) {
+               psb_gtt_free_range(dev, backing);
                return NULL;
        }
-
-       psbfb = to_psb_fb(fb);
-       psbfb->size = size;
-       psbfb->hKernelMemInfo = hKernelMemInfo;
-
-       DRM_DEBUG("Mapping to gtt..., KernelMemInfo %p\n", psKernelMemInfo);
-
-       /*if not VRAM, map it into tt aperture*/
-       if (psKernelMemInfo->pvLinAddrKM != pg->vram_addr) {
-               ret = psb_gtt_map_meminfo(dev, hKernelMemInfo, &offset);
-               if (ret) {
-                       DRM_ERROR("map meminfo for 0x%x failed\n",
-                                 (u32)hKernelMemInfo);
-                       return NULL;
-               }
-               psbfb->offset = (offset << PAGE_SHIFT);
-       } else {
-               psbfb->offset = 0;
-       }
-       info = framebuffer_alloc(0, &dev->pdev->dev);
-       if (!info)
-               return NULL;
-
-       strcpy(info->fix.id, "psbfb");
-
-       info->flags = FBINFO_DEFAULT;
-       info->fix.accel = FB_ACCEL_I830;        /*FIXMEAC*/
-       info->fbops = &psbfb_ops;
-
-       info->fix.smem_start = dev->mode_config.fb_base;
-       info->fix.smem_len = size;
-
-       info->screen_base = psKernelMemInfo->pvLinAddrKM;
-       info->screen_size = size;
-
-       drm_fb_helper_fill_fix(info, fb->pitch, fb->depth);
-       drm_fb_helper_fill_var(info, &fbdev->psb_fb_helper,
-                                                       fb->width, fb->height);
-
-       info->fix.mmio_start = pci_resource_start(dev->pdev, 0);
-       info->fix.mmio_len = pci_resource_len(dev->pdev, 0);
-
-       info->pixmap.size = 64 * 1024;
-       info->pixmap.buf_align = 8;
-       info->pixmap.access_align = 32;
-       info->pixmap.flags = FB_PIXMAP_SYSTEM;
-       info->pixmap.scan_align = 1;
-
-       psbfb->fbdev = info;
-       fbdev->pfb = psbfb;
-
-       fbdev->psb_fb_helper.fb = fb;
-       fbdev->psb_fb_helper.fbdev = info;
-       MRSTLFBHandleChangeFB(dev, psbfb);
-
-       return fb;
-#endif
+       return backing;
 }
-
+       
+/**
+ *     psbfb_create            -       create a framebuffer
+ *     @fbdev: the framebuffer device
+ *     @sizes: specification of the layout
+ *
+ *     Create a framebuffer to the specifications provided
+ */
 static int psbfb_create(struct psb_fbdev *fbdev,
                                struct drm_fb_helper_surface_size *sizes)
 {
        struct drm_device *dev = fbdev->psb_fb_helper.dev;
        struct drm_psb_private *dev_priv = dev->dev_private;
-       struct psb_gtt *pg = dev_priv->pg;
        struct fb_info *info;
        struct drm_framebuffer *fb;
        struct psb_framebuffer *psbfb;
        struct drm_mode_fb_cmd mode_cmd;
        struct device *device = &dev->pdev->dev;
-
-       struct ttm_buffer_object *fbo = NULL;
        int size, aligned_size;
        int ret;
+       struct gtt_range *backing;
 
        mode_cmd.width = sizes->surface_width;
        mode_cmd.height = sizes->surface_height;
@@ -455,15 +399,19 @@ static int psbfb_create(struct psb_fbdev *fbdev,
        size = mode_cmd.pitch * mode_cmd.height;
        aligned_size = ALIGN(size, PAGE_SIZE);
 
+       /* Allocate the framebuffer in the GTT with stolen page backing */
+       backing = psbfb_alloc(dev, aligned_size);
+       if (backing == NULL)
+               return -ENOMEM;
+
        mutex_lock(&dev->struct_mutex);
-       fb = psb_framebuffer_create(dev, &mode_cmd, fbo);
+       fb = psb_framebuffer_create(dev, &mode_cmd, backing);
        if (!fb) {
                DRM_ERROR("failed to allocate fb.\n");
                ret = -ENOMEM;
                goto out_err1;
        }
        psbfb = to_psb_fb(fb);
-       psbfb->size = size;
 
        info = framebuffer_alloc(sizeof(struct psb_fbdev), device);
        if (!info) {
@@ -485,7 +433,11 @@ static int psbfb_create(struct psb_fbdev *fbdev,
        info->fbops = &psbfb_ops;
        info->fix.smem_start = dev->mode_config.fb_base;
        info->fix.smem_len = size;
-       info->screen_base = (char *)pg->vram_addr;
+
+       /* Accessed via stolen memory directly, This only works for stolem
+          memory however. Need to address this once we start using gtt
+          pages we allocate */
+       info->screen_base = (char *)dev_priv->vram_addr + backing->offset;
        info->screen_size = size;
        memset(info->screen_base, 0, size);
 
@@ -515,9 +467,51 @@ out_err0:
        fb->funcs->destroy(fb);
 out_err1:
        mutex_unlock(&dev->struct_mutex);
+       psb_gtt_free_range(dev, backing);
        return ret;
 }
 
+/**
+ *     psb_user_framebuffer_create     -       create framebuffer
+ *     @dev: our DRM device
+ *     @filp: client file
+ *     @cmd: mode request
+ *
+ *     Create a new framebuffer backed by a userspace GEM object
+ */
+static struct drm_framebuffer *psb_user_framebuffer_create
+                       (struct drm_device *dev, struct drm_file *filp,
+                        struct drm_mode_fb_cmd *cmd)
+{
+        struct gtt_range *r;
+        struct drm_gem_object *obj;
+        struct psb_framebuffer *psbfb;
+
+        /* Find the GEM object and thus the gtt range object that is
+           to back this space */
+       obj = drm_gem_object_lookup(dev, filp, cmd->handle);
+       if (obj == NULL)
+               return ERR_PTR(-ENOENT);
+
+        /* Allocate a framebuffer */
+        psbfb = kzalloc(sizeof(*psbfb), GFP_KERNEL);
+        if (psbfb == NULL) {
+                drm_gem_object_unreference_unlocked(obj);
+                return ERR_PTR(-ENOMEM);
+        }
+        
+        /* Let the core code do all the work */
+        r = container_of(obj, struct gtt_range, gem);
+       if (psb_framebuffer_create(dev, cmd, r) == NULL) {
+                drm_gem_object_unreference_unlocked(obj);
+                kfree(psbfb);
+                return ERR_PTR(-EINVAL);
+        }
+        /* Return the drm_framebuffer contained within the psb fbdev which
+           has been initialized by the framebuffer creation */
+        return &psbfb->base;
+}
+
 static void psbfb_gamma_set(struct drm_crtc *crtc, u16 red, u16 green,
                                                        u16 blue, int regno)
 {
@@ -561,15 +555,20 @@ int psb_fbdev_destroy(struct drm_device *dev, struct psb_fbdev *fbdev)
 
        if (fbdev->psb_fb_helper.fbdev) {
                info = fbdev->psb_fb_helper.fbdev;
+               /* FIXME: this is a bit more inside knowledge than I'd like
+                  but I don't see how to make a fake GEM object of the
+                  stolen space nicely */
+               if (psbfb->gtt->stolen)
+                       psb_gtt_free_range(dev, psbfb->gtt);
+               else
+                       drm_gem_object_unreference(&psbfb->gtt->gem);
                unregister_framebuffer(info);
                iounmap(info->screen_base);
                framebuffer_release(info);
        }
 
        drm_fb_helper_fini(&fbdev->psb_fb_helper);
-
        drm_framebuffer_cleanup(&psbfb->base);
-
        return 0;
 }
 
@@ -610,7 +609,6 @@ void psb_fbdev_fini(struct drm_device *dev)
        dev_priv->fbdev = NULL;
 }
 
-
 static void psbfb_output_poll_changed(struct drm_device *dev)
 {
        struct drm_psb_private *dev_priv = dev->dev_private;
@@ -627,7 +625,6 @@ int psbfb_remove(struct drm_device *dev, struct drm_framebuffer *fb)
                return 0;
 
        info = psbfb->fbdev;
-       psbfb->pvrBO = NULL;
 
        if (info)
                framebuffer_release(info);
@@ -635,28 +632,48 @@ int psbfb_remove(struct drm_device *dev, struct drm_framebuffer *fb)
 }
 /*EXPORT_SYMBOL(psbfb_remove); */
 
+/**
+ *     psb_user_framebuffer_create_handle - add hamdle to a framebuffer
+ *     @fb: framebuffer
+ *     @file_priv: our DRM file
+ *     @handle: returned handle
+ *
+ *     Our framebuffer object is a GTT range which also contains a GEM
+ *     object. We need to turn it into a handle for userspace. GEM will do
+ *     the work for us
+ */
 static int psb_user_framebuffer_create_handle(struct drm_framebuffer *fb,
                                              struct drm_file *file_priv,
                                              unsigned int *handle)
 {
-       /* JB: TODO currently we can't go from a bo to a handle with ttm */
-       (void) file_priv;
-       *handle = 0;
-       return 0;
+        struct psb_framebuffer *psbfb = to_psb_fb(fb);
+        struct gtt_range *r = psbfb->gtt;
+        if (r->stolen)
+                return -EOPNOTSUPP;
+        return drm_gem_handle_create(file_priv, &r->gem, handle);
 }
 
+/**
+ *     psb_user_framebuffer_destroy    -       destruct user created fb
+ *     @fb: framebuffer
+ *
+ *     User framebuffers are backed by GEM objects so all we have to do is
+ *     clean up a bit and drop the reference, GEM will handle the fallout
+ */
 static void psb_user_framebuffer_destroy(struct drm_framebuffer *fb)
 {
        struct drm_device *dev = fb->dev;
        struct psb_framebuffer *psbfb = to_psb_fb(fb);
+       struct gtt_range *r = psbfb->gtt;
 
-       /*ummap gtt pages*/
-       psb_gtt_unmap_meminfo(dev, psbfb->hKernelMemInfo);
        if (psbfb->fbdev)
                psbfb_remove(dev, fb);
 
-       /* JB: TODO not drop, refcount buffer */
+        /* Let DRM do its clean up */
        drm_framebuffer_cleanup(fb);
+       /*  We are no longer using the resource in GEM */
+       drm_gem_object_unreference_unlocked(&r->gem);
+
        kfree(fb);
 }
 
@@ -698,8 +715,15 @@ static void psb_setup_outputs(struct drm_device *dev)
 
        psb_create_backlight_property(dev);
 
-       psb_intel_lvds_init(dev, &dev_priv->mode_dev);
-       /* psb_intel_sdvo_init(dev, SDVOB); */
+       if (IS_MRST(dev)) {
+               if (dev_priv->iLVDS_enable)
+                       mrst_lvds_init(dev, &dev_priv->mode_dev);
+               else
+                       DRM_ERROR("DSI is not supported\n");
+       } else {
+               psb_intel_lvds_init(dev, &dev_priv->mode_dev);
+               psb_intel_sdvo_init(dev, SDVOB);
+       }
 
        list_for_each_entry(connector, &dev->mode_config.connector_list,
                            head) {
@@ -716,7 +740,10 @@ static void psb_setup_outputs(struct drm_device *dev)
                        break;
                case INTEL_OUTPUT_LVDS:
                        PSB_DEBUG_ENTRY("LVDS.\n");
-                       crtc_mask = (1 << 1);
+                       if (IS_MRST(dev))
+                               crtc_mask = (1 << 0);
+                       else
+                               crtc_mask = (1 << 1);
                        clone_mask = (1 << INTEL_OUTPUT_LVDS);
                        break;
                case INTEL_OUTPUT_MIPI:
@@ -743,52 +770,6 @@ static void psb_setup_outputs(struct drm_device *dev)
        }
 }
 
-static void *psb_bo_from_handle(struct drm_device *dev,
-                               struct drm_file *file_priv,
-                               unsigned int handle)
-{
-       void *psKernelMemInfo = NULL;
-       void * hKernelMemInfo = (void *)handle;
-       int ret;
-
-       ret = psb_get_meminfo_by_handle(hKernelMemInfo, &psKernelMemInfo);
-       if (ret) {
-               DRM_ERROR("Cannot get meminfo for handle 0x%x\n",
-                         (u32)hKernelMemInfo);
-               return NULL;
-       }
-
-       return (void *)psKernelMemInfo;
-}
-
-static size_t psb_bo_size(struct drm_device *dev, void *bof)
-{
-#if 0
-       void *psKernelMemInfo   = (void *)bof;
-       return (size_t)psKernelMemInfo->ui32AllocSize;
-#else
-       return 0;
-#endif
-}
-
-static size_t psb_bo_offset(struct drm_device *dev, void *bof)
-{
-       struct psb_framebuffer *psbfb
-               = (struct psb_framebuffer *)bof;
-
-       return (size_t)psbfb->offset;
-}
-
-static int psb_bo_pin_for_scanout(struct drm_device *dev, void *bo)
-{
-        return 0;
-}
-
-static int psb_bo_unpin_for_scanout(struct drm_device *dev, void *bo)
-{
-       return 0;
-}
-
 void psb_modeset_init(struct drm_device *dev)
 {
        struct drm_psb_private *dev_priv =
@@ -797,12 +778,6 @@ void psb_modeset_init(struct drm_device *dev)
        int i;
 
        PSB_DEBUG_ENTRY("\n");
-       /* Init mm functions */
-       mode_dev->bo_from_handle = psb_bo_from_handle;
-       mode_dev->bo_size = psb_bo_size;
-       mode_dev->bo_offset = psb_bo_offset;
-       mode_dev->bo_pin_for_scanout = psb_bo_pin_for_scanout;
-       mode_dev->bo_unpin_for_scanout = psb_bo_unpin_for_scanout;
 
        drm_mode_config_init(dev);
 
index b4fab9262db5df16685b263e96ff84a52ac8b00c..c8ec0d6febb1c15b3323727ac53f26b80fd54397 100644 (file)
 
 #include "psb_drv.h"
 
-/*IMG Headers*/
-/*#include "servicesint.h"*/
-
 struct psb_framebuffer {
        struct drm_framebuffer base;
        struct address_space *addr_space;
-       struct ttm_buffer_object *bo;
-       struct fb_info * fbdev;
-       /* struct ttm_bo_kmap_obj kmap; */
-       void *pvrBO;    /* FIXME: sort this out */
-       void * hKernelMemInfo;
-       uint32_t size;
-       uint32_t offset;
+       struct fb_info *fbdev;
+       struct gtt_range *gtt;
 };
 
 struct psb_fbdev {
        struct drm_fb_helper psb_fb_helper;
-       struct psb_framebuffer * pfb;
+       struct psb_framebuffer *pfb;
 };
 
 
 #define to_psb_fb(x) container_of(x, struct psb_framebuffer, base)
 
-
 extern int psb_intel_connector_clones(struct drm_device *dev, int type_mask);
 
-
 #endif
 
diff --git a/drivers/staging/gma500/psb_fence.c b/drivers/staging/gma500/psb_fence.c
deleted file mode 100644 (file)
index a70aa64..0000000
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright (c) 2007, Intel Corporation.
- * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
- *
- *
- * Authors: Thomas Hellstrom <thomas-at-tungstengraphics-dot-com>
- */
-
-#include <drm/drmP.h>
-#include "psb_drv.h"
-
-
-static void psb_fence_poll(struct ttm_fence_device *fdev,
-                          uint32_t fence_class, uint32_t waiting_types)
-{
-       struct drm_psb_private *dev_priv =
-           container_of(fdev, struct drm_psb_private, fdev);
-
-
-       if (unlikely(!dev_priv))
-               return;
-
-       if (waiting_types == 0)
-               return;
-
-       /* DRM_ERROR("Polling fence sequence, got 0x%08x\n", sequence); */
-       ttm_fence_handler(fdev, fence_class, 0 /* Sequence */,
-                       _PSB_FENCE_TYPE_EXE, 0);
-}
-
-void psb_fence_error(struct drm_device *dev,
-                    uint32_t fence_class,
-                    uint32_t sequence, uint32_t type, int error)
-{
-       struct drm_psb_private *dev_priv = psb_priv(dev);
-       struct ttm_fence_device *fdev = &dev_priv->fdev;
-       unsigned long irq_flags;
-       struct ttm_fence_class_manager *fc =
-           &fdev->fence_class[fence_class];
-
-       BUG_ON(fence_class >= PSB_NUM_ENGINES);
-       write_lock_irqsave(&fc->lock, irq_flags);
-       ttm_fence_handler(fdev, fence_class, sequence, type, error);
-       write_unlock_irqrestore(&fc->lock, irq_flags);
-}
-
-int psb_fence_emit_sequence(struct ttm_fence_device *fdev,
-                           uint32_t fence_class,
-                           uint32_t flags, uint32_t *sequence,
-                           unsigned long *timeout_jiffies)
-{
-       struct drm_psb_private *dev_priv =
-           container_of(fdev, struct drm_psb_private, fdev);
-
-       if (!dev_priv)
-               return -EINVAL;
-
-       if (fence_class >= PSB_NUM_ENGINES)
-               return -EINVAL;
-
-       DRM_ERROR("Unexpected fence class\n");
-       return -EINVAL;
-}
-
-static void psb_fence_lockup(struct ttm_fence_object *fence,
-                            uint32_t fence_types)
-{
-       DRM_ERROR("Unsupported fence class\n");
-}
-
-void psb_fence_handler(struct drm_device *dev, uint32_t fence_class)
-{
-       struct drm_psb_private *dev_priv = psb_priv(dev);
-       struct ttm_fence_device *fdev = &dev_priv->fdev;
-       struct ttm_fence_class_manager *fc =
-           &fdev->fence_class[fence_class];
-       unsigned long irq_flags;
-
-       write_lock_irqsave(&fc->lock, irq_flags);
-       psb_fence_poll(fdev, fence_class, fc->waiting_types);
-       write_unlock_irqrestore(&fc->lock, irq_flags);
-}
-
-
-static struct ttm_fence_driver psb_ttm_fence_driver = {
-       .has_irq = NULL,
-       .emit = psb_fence_emit_sequence,
-       .flush = NULL,
-       .poll = psb_fence_poll,
-       .needed_flush = NULL,
-       .wait = NULL,
-       .signaled = NULL,
-       .lockup = psb_fence_lockup,
-};
-
-int psb_ttm_fence_device_init(struct ttm_fence_device *fdev)
-{
-       struct drm_psb_private *dev_priv =
-               container_of(fdev, struct drm_psb_private, fdev);
-       struct ttm_fence_class_init fci = {.wrap_diff = (1 << 30),
-               .flush_diff = (1 << 29),
-               .sequence_mask = 0xFFFFFFFF
-       };
-
-       return ttm_fence_device_init(PSB_NUM_ENGINES,
-                                    dev_priv->mem_global_ref.object,
-                                    fdev, &fci, 1,
-                                    &psb_ttm_fence_driver);
-}
diff --git a/drivers/staging/gma500/psb_gem.c b/drivers/staging/gma500/psb_gem.c
new file mode 100644 (file)
index 0000000..76ff7ba
--- /dev/null
@@ -0,0 +1,320 @@
+/*
+ *  psb GEM interface
+ *
+ * Copyright (c) 2011, Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Authors: Alan Cox
+ *
+ * TODO:
+ *     -       we don't actually put GEM objects into the GART yet
+ *     -       we need to work out if the MMU is relevant as well (eg for
+ *             accelerated operations on a GEM object)
+ *     -       cache coherency
+ *
+ * ie this is just an initial framework to get us going.
+ */
+
+#include <drm/drmP.h>
+#include <drm/drm.h>
+#include "psb_drm.h"
+#include "psb_drv.h"
+
+int psb_gem_init_object(struct drm_gem_object *obj)
+{
+       return -EINVAL;
+}
+
+void psb_gem_free_object(struct drm_gem_object *obj)
+{
+       struct gtt_range *gtt = container_of(obj, struct gtt_range, gem);
+       psb_gtt_free_range(obj->dev, gtt);
+       if (obj->map_list.map) {
+               /* Do things GEM should do for us */
+               struct drm_gem_mm *mm = obj->dev->mm_private;
+               struct drm_map_list *list = &obj->map_list;
+               drm_ht_remove_item(&mm->offset_hash, &list->hash);
+               drm_mm_put_block(list->file_offset_node);
+               kfree(list->map);
+               list->map = NULL;
+       }
+       drm_gem_object_release(obj);
+}
+
+int psb_gem_get_aperture(struct drm_device *dev, void *data,
+                               struct drm_file *file)
+{
+       return -EINVAL;
+}
+
+/**
+ *     psb_gem_create_mmap_offset      -       invent an mmap offset
+ *     @obj: our object
+ *
+ *     This is basically doing by hand a pile of ugly crap which should
+ *     be done automatically by the GEM library code but isn't
+ */
+static int psb_gem_create_mmap_offset(struct drm_gem_object *obj)
+{
+       struct drm_device *dev = obj->dev;
+       struct drm_gem_mm *mm = dev->mm_private;
+       struct drm_map_list *list;
+       struct drm_local_map *map;
+       int ret;
+
+       list = &obj->map_list;
+       list->map = kzalloc(sizeof(struct drm_map_list), GFP_KERNEL);
+       if (list->map == NULL)
+               return -ENOMEM;
+       map = list->map;
+       map->type = _DRM_GEM;
+       map->size = obj->size;
+       map->handle =obj;
+
+       list->file_offset_node = drm_mm_search_free(&mm->offset_manager,
+                                       obj->size / PAGE_SIZE, 0, 0);
+       if (!list->file_offset_node) {
+               DRM_ERROR("failed to allocate offset for bo %d\n", obj->name);
+               ret = -ENOSPC;
+               goto free_it;
+       }
+       list->file_offset_node = drm_mm_get_block(list->file_offset_node,
+                                       obj->size / PAGE_SIZE, 0);
+       if (!list->file_offset_node) {
+               ret = -ENOMEM;
+               goto free_it;
+       }
+       list->hash.key = list->file_offset_node->start;
+       ret = drm_ht_insert_item(&mm->offset_hash, &list->hash);
+       if (ret) {
+               DRM_ERROR("failed to add to map hash\n");
+               goto free_mm;
+       }
+       return 0;
+
+free_mm:
+       drm_mm_put_block(list->file_offset_node);
+free_it:
+       kfree(list->map);
+       list->map = NULL;
+       return ret;
+}
+
+/**
+ *     psb_gem_dumb_map_gtt    -       buffer mapping for dumb interface
+ *     @file: our drm client file
+ *     @dev: drm device
+ *     @handle: GEM handle to the object (from dumb_create)
+ *
+ *     Do the necessary setup to allow the mapping of the frame buffer
+ *     into user memory. We don't have to do much here at the moment.
+ */
+int psb_gem_dumb_map_gtt(struct drm_file *file, struct drm_device *dev,
+                        uint32_t handle, uint64_t *offset)
+{
+       int ret = 0;
+       struct drm_gem_object *obj;
+
+       if (!(dev->driver->driver_features & DRIVER_GEM))
+               return -ENODEV;
+               
+       mutex_lock(&dev->struct_mutex);
+
+       /* GEM does all our handle to object mapping */
+       obj = drm_gem_object_lookup(dev, file, handle);
+       if (obj == NULL) {
+               ret = -ENOENT;
+               goto unlock;
+       }
+       /* What validation is needed here ? */
+       
+       /* Make it mmapable */
+       if (!obj->map_list.map) {
+               ret = psb_gem_create_mmap_offset(obj);
+               if (ret)
+                       goto out;
+       }
+       /* GEM should really work out the hash offsets for us */
+       *offset = (u64)obj->map_list.hash.key << PAGE_SHIFT;
+out:
+       drm_gem_object_unreference(obj);
+unlock:
+       mutex_unlock(&dev->struct_mutex);
+       return ret;
+}
+
+/**
+ *     psb_gem_create          -       create a mappable object
+ *     @file: the DRM file of the client
+ *     @dev: our device
+ *     @size: the size requested
+ *     @handlep: returned handle (opaque number)
+ *
+ *     Create a GEM object, fill in the boilerplate and attach a handle to
+ *     it so that userspace can speak about it. This does the core work
+ *     for the various methods that do/will create GEM objects for things
+ */
+static int psb_gem_create(struct drm_file *file,
+       struct drm_device *dev, uint64_t size, uint32_t *handlep)
+{
+       struct gtt_range *r;
+       int ret;
+       u32 handle;
+
+       size = roundup(size, PAGE_SIZE);
+
+       /* Allocate our object - for now a direct gtt range which is not 
+          stolen memory backed */
+       r = psb_gtt_alloc_range(dev, size, "gem", 0);
+       if (r == NULL)
+               return -ENOSPC;
+       /* Initialize the extra goodies GEM needs to do all the hard work */
+       if (drm_gem_object_init(dev, &r->gem, size) != 0) {
+               psb_gtt_free_range(dev, r);
+               /* GEM doesn't give an error code and we don't have an
+                  EGEMSUCKS so make something up for now - FIXME */
+               return -ENOMEM;
+       }
+       /* Give the object a handle so we can carry it more easily */
+       ret = drm_gem_handle_create(file, &r->gem, &handle);
+       if (ret) {
+               drm_gem_object_release(&r->gem);
+               psb_gtt_free_range(dev, r);
+               return ret;
+       }
+       /* We have the initial and handle reference but need only one now */
+       drm_gem_object_unreference(&r->gem);
+       *handlep = handle;
+       return 0;
+}
+
+/**
+ *     psb_gem_dumb_create     -       create a dumb buffer
+ *     @drm_file: our client file
+ *     @dev: our device
+ *     @args: the requested arguments copied from userspace
+ *
+ *     Allocate a buffer suitable for use for a frame buffer of the
+ *     form described by user space. Give userspace a handle by which
+ *     to reference it.
+ */
+int psb_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
+                       struct drm_mode_create_dumb *args)
+{
+       args->pitch = ALIGN(args->width * ((args->bpp + 7) / 8), 64);
+       args->size = args->pitch * args->height;
+       return psb_gem_create(file, dev, args->size, &args->handle);
+}
+
+/**
+ *     psb_gem_dumb_destroy    -       destroy a dumb buffer
+ *     @file: client file
+ *     @dev: our DRM device
+ *     @handle: the object handle
+ *
+ *     Destroy a handle that was created via psb_gem_dumb_create, at least
+ *     we hope it was created that way. i915 seems to assume the caller
+ *     does the checking but that might be worth review ! FIXME
+ */
+int psb_gem_dumb_destroy(struct drm_file *file, struct drm_device *dev,
+                       uint32_t handle)
+{
+       /* No special work needed, drop the reference and see what falls out */
+       return drm_gem_handle_delete(file, handle);
+}
+
+/**
+ *     psb_gem_fault           -       pagefault handler for GEM objects
+ *     @vma: the VMA of the GEM object
+ *     @vmf: fault detail
+ *
+ *     Invoked when a fault occurs on an mmap of a GEM managed area. GEM
+ *     does most of the work for us including the actual map/unmap calls
+ *     but we need to do the actual page work.
+ *
+ *     This code eventually needs to handle faulting objects in and out
+ *     of the GART and repacking it when we run out of space. We can put
+ *     that off for now and for our simple uses
+ *
+ *     The VMA was set up by GEM. In doing so it also ensured that the
+ *     vma->vm_private_data points to the GEM object that is backing this
+ *     mapping.
+ *
+ *     To avoid aliasing and cache funnies we want to map the object
+ *     through the GART. For the moment this is slightly hackish. It would
+ *     be nicer if GEM provided mmap opened/closed hooks for us giving
+ *     the object so that we could track things nicely. That needs changes
+ *     to the core GEM code so must be tackled post staging
+ *
+ *     FIXME
+ */
+int psb_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
+{
+       struct drm_gem_object *obj;
+       struct gtt_range *r;
+       int ret;
+       unsigned long pfn;
+       pgoff_t page_offset;
+       struct drm_device *dev;
+
+       obj = vma->vm_private_data;     /* GEM object */
+       dev = obj->dev;
+
+       r = container_of(obj, struct gtt_range, gem);   /* Get the gtt range */
+
+       /* Make sure we don't parallel update on a fault, nor move or remove
+          something from beneath our feet */
+       mutex_lock(&dev->struct_mutex);
+
+       /* For now the mmap pins the object and it stays pinned. As things
+          stand that will do us no harm */
+       if (r->mmapping == 0) {
+               ret = psb_gtt_pin(r);
+               if (ret < 0) {
+                       DRM_ERROR("gma500: pin failed: %d\n", ret);
+                       goto fail;
+                }
+               r->mmapping = 1;
+       }
+
+       /* FIXME: Locking. We may also need to repack the GART sometimes */
+
+       /* Page relative to the VMA start */
+       page_offset = ((unsigned long) vmf->virtual_address - vma->vm_start)
+                               >> PAGE_SHIFT;
+
+       /* Bus address of the page is gart + object offset + page offset */
+       /* Assumes gtt allocations are page aligned */
+       pfn = (r->resource.start >> PAGE_SHIFT) + page_offset;
+
+       pr_debug("Object GTT base at %p\n", (void *)(r->resource.start));
+       pr_debug("Inserting %p pfn %lx, pa %lx\n", vmf->virtual_address,
+               pfn, pfn << PAGE_SHIFT);
+
+       ret = vm_insert_pfn(vma, (unsigned long)vmf->virtual_address, pfn);
+
+fail:
+        mutex_unlock(&dev->struct_mutex);
+       switch (ret) {
+       case 0:
+       case -ERESTARTSYS:
+       case -EINTR:
+               return VM_FAULT_NOPAGE;
+       case -ENOMEM:
+               return VM_FAULT_OOM;
+       default:
+               return VM_FAULT_SIGBUS;
+       }
+}
index 53c1e1ed3bd21cd4f31929f95e330410d6af9589..74c5a6569d08674bba05a49888d131a459b74f9a 100644 (file)
  * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
  *
  * Authors: Thomas Hellstrom <thomas-at-tungstengraphics.com>
+ *         Alan Cox <alan@linux.intel.com>
  */
 
 #include <drm/drmP.h>
 #include "psb_drv.h"
-#include "psb_pvr_glue.h"
 
+
+/*
+ *     GTT resource allocator - manage page mappings in GTT space
+ */
+
+/**
+ *     psb_gtt_mask_pte        -       generate GART pte entry
+ *     @pfn: page number to encode
+ *     @type: type of memory in the GART
+ *
+ *     Set the GART entry for the appropriate memory type.
+ */
 static inline uint32_t psb_gtt_mask_pte(uint32_t pfn, int type)
 {
        uint32_t mask = PSB_PTE_VALID;
@@ -36,6 +48,327 @@ static inline uint32_t psb_gtt_mask_pte(uint32_t pfn, int type)
        return (pfn << PAGE_SHIFT) | mask;
 }
 
+/**
+ *     psb_gtt_entry           -       find the GART entries for a gtt_range
+ *     @dev: our DRM device
+ *     @r: our GTT range
+ * 
+ *     Given a gtt_range object return the GART offset of the page table
+ *     entries for this gtt_range
+ */
+u32 *psb_gtt_entry(struct drm_device *dev, struct gtt_range *r)
+{
+        struct drm_psb_private *dev_priv = dev->dev_private;
+       unsigned long offset;
+
+       offset = r->resource.start - dev_priv->gtt_mem->start;
+
+       return dev_priv->gtt_map + (offset >> PAGE_SHIFT);
+}
+
+/**
+ *     psb_gtt_insert  -       put an object into the GART
+ *     @dev: our DRM device
+ *     @r: our GTT range
+ *
+ *     Take our preallocated GTT range and insert the GEM object into
+ *     the GART.
+ *
+ *     FIXME: gtt lock ?
+ */
+static int psb_gtt_insert(struct drm_device *dev, struct gtt_range *r)
+{
+        struct drm_psb_private *dev_priv = dev->dev_private;
+       u32 *gtt_slot, pte;
+       int numpages = (r->resource.end + 1 - r->resource.start) >> PAGE_SHIFT;
+       struct page **pages;
+       int i;
+
+       if (r->pages == NULL) {
+               WARN_ON(1);
+               return -EINVAL;
+       }
+
+       WARN_ON(r->stolen);     /* refcount these maybe ? */
+
+       gtt_slot = psb_gtt_entry(dev, r);
+       pages = r->pages;
+
+       /* Make sure we have no alias present */
+       wbinvd();
+
+       /* Write our page entries into the GART itself */
+       for (i = 0; i < numpages; i++) {
+               pte = psb_gtt_mask_pte(page_to_pfn(*pages++), 0/*type*/);
+               iowrite32(pte, gtt_slot++);
+       }
+       /* Make sure all the entries are set before we return */
+       ioread32(gtt_slot - 1);
+       
+       return 0;
+}
+
+/**
+ *     psb_gtt_remove  -       remove an object from the GART
+ *     @dev: our DRM device
+ *     @r: our GTT range
+ *
+ *     Remove a preallocated GTT range from the GART. Overwrite all the
+ *     page table entries with the dummy page
+ */
+
+static void psb_gtt_remove(struct drm_device *dev, struct gtt_range *r)
+{
+       struct drm_psb_private *dev_priv = dev->dev_private;
+       u32 *gtt_slot, pte;
+       int numpages = (r->resource.end + 1 - r->resource.start) >> PAGE_SHIFT;
+       int i;
+
+       WARN_ON(r->stolen);
+
+       gtt_slot = psb_gtt_entry(dev, r);
+       pte = psb_gtt_mask_pte(page_to_pfn(dev_priv->scratch_page), 0);;
+
+       for (i = 0; i < numpages; i++)
+               iowrite32(pte, gtt_slot++);
+       ioread32(gtt_slot - 1);
+}
+
+/**
+ *     psb_gtt_attach_pages    -       attach and pin GEM pages
+ *     @gt: the gtt range
+ *
+ *     Pin and build an in kernel list of the pages that back our GEM object.
+ *     While we hold this the pages cannot be swapped out
+ *
+ *     FIXME: Do we need to cache flush when we update the GTT
+ */
+static int psb_gtt_attach_pages(struct gtt_range *gt)
+{
+       struct inode *inode;
+       struct address_space *mapping;
+       int i;
+       struct page *p;
+       int pages = (gt->resource.end + 1 - gt->resource.start) >> PAGE_SHIFT;
+
+       WARN_ON(gt->pages);
+
+       /* This is the shared memory object that backs the GEM resource */
+       inode = gt->gem.filp->f_path.dentry->d_inode;
+       mapping = inode->i_mapping;
+
+       gt->pages = kmalloc(pages * sizeof(struct page *), GFP_KERNEL);
+       if (gt->pages == NULL)
+               return -ENOMEM;
+       for (i = 0; i < pages; i++) {
+               /* FIXME: review flags later */
+               p = read_cache_page_gfp(mapping, i,
+                                       __GFP_COLD | GFP_KERNEL);
+               if (IS_ERR(p))
+                       goto err;
+               gt->pages[i] = p;
+       }
+       return 0;
+
+err:
+       while (i--)
+               page_cache_release(gt->pages[i]);
+       kfree(gt->pages);
+       gt->pages = NULL;
+       return PTR_ERR(p);
+}
+
+/**
+ *     psb_gtt_detach_pages    -       attach and pin GEM pages
+ *     @gt: the gtt range
+ *
+ *     Undo the effect of psb_gtt_attach_pages. At this point the pages
+ *     must have been removed from the GART as they could now be paged out
+ *     and move bus address.
+ *
+ *     FIXME: Do we need to cache flush when we update the GTT
+ */
+static void psb_gtt_detach_pages(struct gtt_range *gt)
+{
+       int i;
+       int pages = (gt->resource.end + 1 - gt->resource.start) >> PAGE_SHIFT;
+
+       for (i = 0; i < pages; i++) {
+               /* FIXME: do we need to force dirty */
+               set_page_dirty(gt->pages[i]);
+               /* Undo the reference we took when populating the table */
+               page_cache_release(gt->pages[i]);
+       }
+       kfree(gt->pages);
+       gt->pages = NULL;
+}
+
+/**
+ *     psb_gtt_pin             -       pin pages into the GTT
+ *     @gt: range to pin
+ *
+ *     Pin a set of pages into the GTT. The pins are refcounted so that
+ *     multiple pins need multiple unpins to undo.
+ *
+ *     Non GEM backed objects treat this as a no-op as they are always GTT
+ *     backed objects.
+ */
+int psb_gtt_pin(struct gtt_range *gt)
+{
+       int ret;
+       struct drm_device *dev = gt->gem.dev;
+       struct drm_psb_private *dev_priv = dev->dev_private;
+
+       mutex_lock(&dev_priv->gtt_mutex);
+
+       if (gt->in_gart == 0 && gt->stolen == 0) {
+               ret = psb_gtt_attach_pages(gt);
+               if (ret < 0)
+                       goto out;
+               ret = psb_gtt_insert(dev, gt);
+               if (ret < 0) {
+                       psb_gtt_detach_pages(gt);
+                       goto out;
+               }
+       }
+       gt->in_gart++;
+out:
+       mutex_unlock(&dev_priv->gtt_mutex);
+       return ret;
+}
+
+/**
+ *     psb_gtt_unpin           -       Drop a GTT pin requirement
+ *     @gt: range to pin
+ *
+ *     Undoes the effect of psb_gtt_pin. On the last drop the GEM object
+ *     will be removed from the GTT which will also drop the page references
+ *     and allow the VM to clean up or page stuff.
+ *
+ *     Non GEM backed objects treat this as a no-op as they are always GTT
+ *     backed objects.
+ */
+void psb_gtt_unpin(struct gtt_range *gt)
+{
+       struct drm_device *dev = gt->gem.dev;
+       struct drm_psb_private *dev_priv = dev->dev_private;
+
+       mutex_lock(&dev_priv->gtt_mutex);
+
+       WARN_ON(!gt->in_gart);
+
+       gt->in_gart--;
+       if (gt->in_gart == 0 && gt->stolen == 0) {
+               psb_gtt_remove(dev, gt);
+               psb_gtt_detach_pages(gt);
+       }
+       mutex_unlock(&dev_priv->gtt_mutex);
+}
+       
+/*
+ *     GTT resource allocator - allocate and manage GTT address space
+ */
+
+/**
+ *     psb_gtt_alloc_range     -       allocate GTT address space
+ *     @dev: Our DRM device
+ *     @len: length (bytes) of address space required
+ *     @name: resource name
+ *     @backed: resource should be backed by stolen pages
+ *
+ *     Ask the kernel core to find us a suitable range of addresses
+ *     to use for a GTT mapping.
+ *
+ *     Returns a gtt_range structure describing the object, or NULL on
+ *     error. On successful return the resource is both allocated and marked
+ *     as in use.
+ */
+struct gtt_range *psb_gtt_alloc_range(struct drm_device *dev, int len,
+                                               const char *name, int backed)
+{
+       struct drm_psb_private *dev_priv = dev->dev_private;
+       struct gtt_range *gt;
+       struct resource *r = dev_priv->gtt_mem;
+       int ret;
+       unsigned long start, end;
+       
+       if (backed) {
+               /* The start of the GTT is the stolen pages */
+               start = r->start;
+               end = r->start + dev_priv->pg->stolen_size - 1;
+        } else {
+                /* The rest we will use for GEM backed objects */
+                start = r->start + dev_priv->pg->stolen_size;
+                end = r->end;
+        }
+
+       gt = kzalloc(sizeof(struct gtt_range), GFP_KERNEL);
+       if (gt == NULL)
+               return NULL;
+        gt->resource.name = name;
+        gt->stolen = backed;
+        gt->in_gart = backed;
+        /* Ensure this is set for non GEM objects */
+        gt->gem.dev = dev;
+       kref_init(&gt->kref);
+
+       ret = allocate_resource(dev_priv->gtt_mem, &gt->resource,
+                               len, start, end, PAGE_SIZE, NULL, NULL);
+       if (ret == 0) {
+               gt->offset = gt->resource.start - r->start;
+               return gt;
+        }
+       kfree(gt);
+       return NULL;
+}
+
+/**
+ *     psb_gtt_destroy         -       final free up of a gtt
+ *     @kref: the kref of the gtt
+ *
+ *     Called from the kernel kref put when the final reference to our
+ *     GTT object is dropped. At that point we can free up the resources.
+ *
+ *     For now we handle mmap clean up here to work around limits in GEM
+ */
+static void psb_gtt_destroy(struct kref *kref)
+{
+       struct gtt_range *gt = container_of(kref, struct gtt_range, kref);
+
+       /* Undo the mmap pin if we are destroying the object */
+       if (gt->mmapping) {
+               psb_gtt_unpin(gt);
+               gt->mmapping = 0;
+       }
+       WARN_ON(gt->in_gart && !gt->stolen);
+       release_resource(&gt->resource);
+       kfree(gt);
+}
+
+/**
+ *     psb_gtt_kref_put        -       drop reference to a GTT object
+ *     @gt: the GT being dropped
+ *
+ *     Drop a reference to a psb gtt
+ */
+void psb_gtt_kref_put(struct gtt_range *gt)
+{
+       kref_put(&gt->kref, psb_gtt_destroy);
+}
+
+/**
+ *     psb_gtt_free_range      -       release GTT address space
+ *     @dev: our DRM device
+ *     @gt: a mapping created with psb_gtt_alloc_range
+ *
+ *     Release a resource that was allocated with psb_gtt_alloc_range
+ */
+void psb_gtt_free_range(struct drm_device *dev, struct gtt_range *gt)
+{
+       psb_gtt_kref_put(gt);
+}
+
+
 struct psb_gtt *psb_gtt_alloc(struct drm_device *dev)
 {
        struct psb_gtt *tmp = kzalloc(sizeof(*tmp), GFP_KERNEL);
@@ -49,98 +382,89 @@ struct psb_gtt *psb_gtt_alloc(struct drm_device *dev)
        return tmp;
 }
 
-void psb_gtt_takedown(struct psb_gtt *pg, int free)
+void psb_gtt_takedown(struct drm_device *dev)
 {
-       struct drm_psb_private *dev_priv = pg->dev->dev_private;
-
-       if (!pg)
-               return;
+       struct drm_psb_private *dev_priv = dev->dev_private;
 
-       if (pg->gtt_map) {
-               iounmap(pg->gtt_map);
-               pg->gtt_map = NULL;
+       /* FIXME: iounmap dev_priv->vram_addr etc */
+       if (dev_priv->gtt_map) {
+               iounmap(dev_priv->gtt_map);
+               dev_priv->gtt_map = NULL;
        }
-       if (pg->initialized) {
-               pci_write_config_word(pg->dev->pdev, PSB_GMCH_CTRL,
-                                     pg->gmch_ctrl);
-               PSB_WVDC32(pg->pge_ctl, PSB_PGETBL_CTL);
+       if (dev_priv->gtt_initialized) {
+               pci_write_config_word(dev->pdev, PSB_GMCH_CTRL,
+                                     dev_priv->gmch_ctrl);
+               PSB_WVDC32(dev_priv->pge_ctl, PSB_PGETBL_CTL);
                (void) PSB_RVDC32(PSB_PGETBL_CTL);
        }
-       if (free)
-               kfree(pg);
+       kfree(dev_priv->pg);
+       dev_priv->pg = NULL;
 }
 
-int psb_gtt_init(struct psb_gtt *pg, int resume)
+int psb_gtt_init(struct drm_device *dev, int resume)
 {
-       struct drm_device *dev = pg->dev;
        struct drm_psb_private *dev_priv = dev->dev_private;
        unsigned gtt_pages;
-       unsigned long stolen_size, vram_stolen_size, ci_stolen_size;
-       unsigned long rar_stolen_size;
+       unsigned long stolen_size, vram_stolen_size;
        unsigned i, num_pages;
        unsigned pfn_base;
-       uint32_t ci_pages, vram_pages;
+       uint32_t vram_pages;
        uint32_t tt_pages;
        uint32_t *ttm_gtt_map;
        uint32_t dvmt_mode = 0;
+       struct psb_gtt *pg;
 
        int ret = 0;
        uint32_t pte;
 
-       pci_read_config_word(dev->pdev, PSB_GMCH_CTRL, &pg->gmch_ctrl);
+       mutex_init(&dev_priv->gtt_mutex);
+
+       dev_priv->pg = pg = psb_gtt_alloc(dev);
+       if (pg == NULL)
+               return -ENOMEM;
+
+       pci_read_config_word(dev->pdev, PSB_GMCH_CTRL, &dev_priv->gmch_ctrl);
        pci_write_config_word(dev->pdev, PSB_GMCH_CTRL,
-                             pg->gmch_ctrl | _PSB_GMCH_ENABLED);
+                             dev_priv->gmch_ctrl | _PSB_GMCH_ENABLED);
 
-       pg->pge_ctl = PSB_RVDC32(PSB_PGETBL_CTL);
-       PSB_WVDC32(pg->pge_ctl | _PSB_PGETBL_ENABLED, PSB_PGETBL_CTL);
+       dev_priv->pge_ctl = PSB_RVDC32(PSB_PGETBL_CTL);
+       PSB_WVDC32(dev_priv->pge_ctl | _PSB_PGETBL_ENABLED, PSB_PGETBL_CTL);
        (void) PSB_RVDC32(PSB_PGETBL_CTL);
 
-       pg->initialized = 1;
+       /* The root resource we allocate address space from */
+       dev_priv->gtt_mem = &dev->pdev->resource[PSB_GATT_RESOURCE];
 
-       pg->gtt_phys_start = pg->pge_ctl & PAGE_MASK;
+       dev_priv->gtt_initialized = 1;
+
+       pg->gtt_phys_start = dev_priv->pge_ctl & PAGE_MASK;
 
        pg->gatt_start = pci_resource_start(dev->pdev, PSB_GATT_RESOURCE);
        /* fix me: video mmu has hw bug to access 0x0D0000000,
         * then make gatt start at 0x0e000,0000 */
-       pg->mmu_gatt_start = PSB_MEM_TT_START;
+       pg->mmu_gatt_start = 0xE0000000;
        pg->gtt_start = pci_resource_start(dev->pdev, PSB_GTT_RESOURCE);
        gtt_pages =
            pci_resource_len(dev->pdev, PSB_GTT_RESOURCE) >> PAGE_SHIFT;
        pg->gatt_pages = pci_resource_len(dev->pdev, PSB_GATT_RESOURCE)
            >> PAGE_SHIFT;
 
-       pci_read_config_dword(dev->pdev, PSB_BSM, &pg->stolen_base);
-       vram_stolen_size = pg->gtt_phys_start - pg->stolen_base - PAGE_SIZE;
+       pci_read_config_dword(dev->pdev, PSB_BSM, &dev_priv->stolen_base);
+       vram_stolen_size = pg->gtt_phys_start - dev_priv->stolen_base - PAGE_SIZE;
 
-       /* CI is not included in the stolen size since the TOPAZ MMU bug */
-       ci_stolen_size = dev_priv->ci_region_size;
-       /* Don't add CI & RAR share buffer space
-        * managed by TTM to stolen_size */
        stolen_size = vram_stolen_size;
 
-       rar_stolen_size = dev_priv->rar_region_size;
-
        printk(KERN_INFO"GMMADR(region 0) start: 0x%08x (%dM).\n",
                pg->gatt_start, pg->gatt_pages/256);
        printk(KERN_INFO"GTTADR(region 3) start: 0x%08x (can map %dM RAM), and actual RAM base 0x%08x.\n",
                pg->gtt_start, gtt_pages * 4, pg->gtt_phys_start);
-       printk(KERN_INFO "Stole memory information\n");
-       printk(KERN_INFO "      base in RAM: 0x%x\n", pg->stolen_base);
-       printk(KERN_INFO "      size: %luK, calculated by (GTT RAM base) - (Stolen base), seems wrong\n",
+       printk(KERN_INFO "Stolen memory information\n");
+       printk(KERN_INFO "       base in RAM: 0x%x\n", dev_priv->stolen_base);
+       printk(KERN_INFO "       size: %luK, calculated by (GTT RAM base) - (Stolen base), seems wrong\n",
                vram_stolen_size/1024);
-       dvmt_mode = (pg->gmch_ctrl >> 4) & 0x7;
+       dvmt_mode = (dev_priv->gmch_ctrl >> 4) & 0x7;
        printk(KERN_INFO "      the correct size should be: %dM(dvmt mode=%d)\n",
                (dvmt_mode == 1) ? 1 : (2 << (dvmt_mode - 1)), dvmt_mode);
 
-       if (ci_stolen_size > 0)
-               printk(KERN_INFO"CI Stole memory: RAM base = 0x%08x, size = %lu M\n",
-                               dev_priv->ci_region_start,
-                               ci_stolen_size / 1024 / 1024);
-       if (rar_stolen_size > 0)
-               printk(KERN_INFO "RAR Stole memory: RAM base = 0x%08x, size = %lu M\n",
-                       dev_priv->rar_region_start,
-                       rar_stolen_size / 1024 / 1024);
-
        if (resume && (gtt_pages != pg->gtt_pages) &&
            (stolen_size != pg->stolen_size)) {
                DRM_ERROR("GTT resume error.\n");
@@ -150,42 +474,40 @@ int psb_gtt_init(struct psb_gtt *pg, int resume)
 
        pg->gtt_pages = gtt_pages;
        pg->stolen_size = stolen_size;
-       pg->vram_stolen_size = vram_stolen_size;
-       pg->ci_stolen_size = ci_stolen_size;
-       pg->rar_stolen_size = rar_stolen_size;
-       pg->gtt_map =
+       dev_priv->vram_stolen_size = vram_stolen_size;
+       dev_priv->gtt_map =
            ioremap_nocache(pg->gtt_phys_start, gtt_pages << PAGE_SHIFT);
-       if (!pg->gtt_map) {
+       if (!dev_priv->gtt_map) {
                DRM_ERROR("Failure to map gtt.\n");
                ret = -ENOMEM;
                goto out_err;
        }
 
-       pg->vram_addr = ioremap_wc(pg->stolen_base, stolen_size);
-       if (!pg->vram_addr) {
+       dev_priv->vram_addr = ioremap_wc(dev_priv->stolen_base, stolen_size);
+       if (!dev_priv->vram_addr) {
                DRM_ERROR("Failure to map stolen base.\n");
                ret = -ENOMEM;
                goto out_err;
        }
 
-       DRM_DEBUG("%s: vram kernel virtual address %p\n", pg->vram_addr);
+       DRM_DEBUG("%s: vram kernel virtual address %p\n", dev_priv->vram_addr);
 
        tt_pages = (pg->gatt_pages < PSB_TT_PRIV0_PLIMIT) ?
                (pg->gatt_pages) : PSB_TT_PRIV0_PLIMIT;
 
-       ttm_gtt_map = pg->gtt_map + tt_pages / 2;
+       ttm_gtt_map = dev_priv->gtt_map + tt_pages / 2;
 
        /*
         * insert vram stolen pages.
         */
 
-       pfn_base = pg->stolen_base >> PAGE_SHIFT;
+       pfn_base = dev_priv->stolen_base >> PAGE_SHIFT;
        vram_pages = num_pages = vram_stolen_size >> PAGE_SHIFT;
        printk(KERN_INFO"Set up %d stolen pages starting at 0x%08x, GTT offset %dK\n",
                num_pages, pfn_base, 0);
        for (i = 0; i < num_pages; ++i) {
                pte = psb_gtt_mask_pte(pfn_base + i, 0);
-               iowrite32(pte, pg->gtt_map + i);
+               iowrite32(pte, dev_priv->gtt_map + i);
        }
 
        /*
@@ -194,35 +516,8 @@ int psb_gtt_init(struct psb_gtt *pg, int resume)
        pfn_base = page_to_pfn(dev_priv->scratch_page);
        pte = psb_gtt_mask_pte(pfn_base, 0);
        for (; i < tt_pages / 2 - 1; ++i)
-               iowrite32(pte, pg->gtt_map + i);
-
-       /*
-        * insert CI stolen pages
-        */
-
-       pfn_base = dev_priv->ci_region_start >> PAGE_SHIFT;
-       ci_pages = num_pages = ci_stolen_size >> PAGE_SHIFT;
-       printk(KERN_INFO"Set up %d CI stolen pages starting at 0x%08x, GTT offset %dK\n",
-              num_pages, pfn_base, (ttm_gtt_map - pg->gtt_map) * 4);
-       for (i = 0; i < num_pages; ++i) {
-               pte = psb_gtt_mask_pte(pfn_base + i, 0);
-               iowrite32(pte, ttm_gtt_map + i);
-       }
+               iowrite32(pte, dev_priv->gtt_map + i);
 
-       /*
-        * insert RAR stolen pages
-        */
-       if (rar_stolen_size != 0) {
-               pfn_base = dev_priv->rar_region_start >> PAGE_SHIFT;
-               num_pages = rar_stolen_size >> PAGE_SHIFT;
-               printk(KERN_INFO"Set up %d RAR stolen pages starting at 0x%08x, GTT offset %dK\n",
-                       num_pages, pfn_base,
-                       (ttm_gtt_map - pg->gtt_map + i) * 4);
-               for (; i < num_pages + ci_pages; ++i) {
-                       pte = psb_gtt_mask_pte(pfn_base + i - ci_pages, 0);
-                       iowrite32(pte, ttm_gtt_map + i);
-               }
-       }
        /*
         * Init rest of gtt managed by TTM.
         */
@@ -234,801 +529,11 @@ int psb_gtt_init(struct psb_gtt *pg, int resume)
 
        for (; i < pg->gatt_pages - tt_pages / 2; ++i)
                iowrite32(pte, ttm_gtt_map + i);
-       (void) ioread32(pg->gtt_map + i - 1);
+       (void) ioread32(dev_priv->gtt_map + i - 1);
 
        return 0;
 
 out_err:
-       psb_gtt_takedown(pg, 0);
-       return ret;
-}
-
-int psb_gtt_insert_pages(struct psb_gtt *pg, struct page **pages,
-                        unsigned offset_pages, unsigned num_pages,
-                        unsigned desired_tile_stride,
-                        unsigned hw_tile_stride, int type)
-{
-       unsigned rows = 1;
-       unsigned add;
-       unsigned row_add;
-       unsigned i;
-       unsigned j;
-       uint32_t *cur_page = NULL;
-       uint32_t pte;
-
-       if (hw_tile_stride)
-               rows = num_pages / desired_tile_stride;
-       else
-               desired_tile_stride = num_pages;
-
-       add = desired_tile_stride;
-       row_add = hw_tile_stride;
-
-       down_read(&pg->sem);
-       for (i = 0; i < rows; ++i) {
-               cur_page = pg->gtt_map + offset_pages;
-               for (j = 0; j < desired_tile_stride; ++j) {
-                       pte =
-                           psb_gtt_mask_pte(page_to_pfn(*pages++), type);
-                       iowrite32(pte, cur_page++);
-               }
-               offset_pages += add;
-       }
-       (void) ioread32(cur_page - 1);
-       up_read(&pg->sem);
-
-       return 0;
-}
-
-int psb_gtt_insert_phys_addresses(struct psb_gtt *pg, dma_addr_t *pPhysFrames,
-                       unsigned offset_pages, unsigned num_pages, int type)
-{
-       unsigned j;
-       uint32_t *cur_page = NULL;
-       uint32_t pte;
-       u32 ba;
-
-       down_read(&pg->sem);
-       cur_page = pg->gtt_map + offset_pages;
-       for (j = 0; j < num_pages; ++j) {
-               ba = *pPhysFrames++;
-               pte =  psb_gtt_mask_pte(ba >> PAGE_SHIFT, type);
-               iowrite32(pte, cur_page++);
-       }
-       (void) ioread32(cur_page - 1);
-       up_read(&pg->sem);
-       return 0;
-}
-
-int psb_gtt_remove_pages(struct psb_gtt *pg, unsigned offset_pages,
-                        unsigned num_pages, unsigned desired_tile_stride,
-                        unsigned hw_tile_stride, int rc_prot)
-{
-       struct drm_psb_private *dev_priv = pg->dev->dev_private;
-       unsigned rows = 1;
-       unsigned add;
-       unsigned row_add;
-       unsigned i;
-       unsigned j;
-       uint32_t *cur_page = NULL;
-       unsigned pfn_base = page_to_pfn(dev_priv->scratch_page);
-       uint32_t pte = psb_gtt_mask_pte(pfn_base, 0);
-
-       if (hw_tile_stride)
-               rows = num_pages / desired_tile_stride;
-       else
-               desired_tile_stride = num_pages;
-
-       add = desired_tile_stride;
-       row_add = hw_tile_stride;
-
-       if (rc_prot)
-               down_read(&pg->sem);
-       for (i = 0; i < rows; ++i) {
-               cur_page = pg->gtt_map + offset_pages;
-               for (j = 0; j < desired_tile_stride; ++j)
-                       iowrite32(pte, cur_page++);
-
-               offset_pages += add;
-       }
-       (void) ioread32(cur_page - 1);
-       if (rc_prot)
-               up_read(&pg->sem);
-
-       return 0;
-}
-
-int psb_gtt_mm_init(struct psb_gtt *pg)
-{
-       struct psb_gtt_mm *gtt_mm;
-       struct drm_psb_private *dev_priv = pg->dev->dev_private;
-       struct drm_open_hash *ht;
-       struct drm_mm *mm;
-       int ret;
-       uint32_t tt_start;
-       uint32_t tt_size;
-
-       if (!pg || !pg->initialized) {
-               DRM_DEBUG("Invalid gtt struct\n");
-               return -EINVAL;
-       }
-
-       gtt_mm =  kzalloc(sizeof(struct psb_gtt_mm), GFP_KERNEL);
-       if (!gtt_mm)
-               return -ENOMEM;
-
-       spin_lock_init(&gtt_mm->lock);
-
-       ht = &gtt_mm->hash;
-       ret = drm_ht_create(ht, 20);
-       if (ret) {
-               DRM_DEBUG("Create hash table failed(%d)\n", ret);
-               goto err_free;
-       }
-
-       tt_start = (pg->stolen_size + PAGE_SIZE - 1) >> PAGE_SHIFT;
-       tt_start = (tt_start < pg->gatt_pages) ? tt_start : pg->gatt_pages;
-       tt_size = (pg->gatt_pages < PSB_TT_PRIV0_PLIMIT) ?
-                       (pg->gatt_pages) : PSB_TT_PRIV0_PLIMIT;
-
-       mm = &gtt_mm->base;
-
-       /*will use tt_start ~ 128M for IMG TT buffers*/
-       ret = drm_mm_init(mm, tt_start, ((tt_size / 2) - tt_start));
-       if (ret) {
-               DRM_DEBUG("drm_mm_int error(%d)\n", ret);
-               goto err_mm_init;
-       }
-
-       gtt_mm->count = 0;
-
-       dev_priv->gtt_mm = gtt_mm;
-
-       DRM_INFO("PSB GTT mem manager ready, tt_start %ld, tt_size %ld pages\n",
-               (unsigned long)tt_start,
-               (unsigned long)((tt_size / 2) - tt_start));
-       return 0;
-err_mm_init:
-       drm_ht_remove(ht);
-
-err_free:
-       kfree(gtt_mm);
+       psb_gtt_takedown(dev);
        return ret;
 }
-
-/**
- * Delete all hash entries;
- */
-void psb_gtt_mm_takedown(void)
-{
-       return;
-}
-
-static int psb_gtt_mm_get_ht_by_pid_locked(struct psb_gtt_mm *mm,
-                                   u32 tgid,
-                                   struct psb_gtt_hash_entry **hentry)
-{
-       struct drm_hash_item *entry;
-       struct psb_gtt_hash_entry *psb_entry;
-       int ret;
-
-       ret = drm_ht_find_item(&mm->hash, tgid, &entry);
-       if (ret) {
-               DRM_DEBUG("Cannot find entry pid=%ld\n", tgid);
-               return ret;
-       }
-
-       psb_entry = container_of(entry, struct psb_gtt_hash_entry, item);
-       if (!psb_entry) {
-               DRM_DEBUG("Invalid entry");
-               return -EINVAL;
-       }
-
-       *hentry = psb_entry;
-       return 0;
-}
-
-
-static int psb_gtt_mm_insert_ht_locked(struct psb_gtt_mm *mm,
-                                      u32 tgid,
-                                      struct psb_gtt_hash_entry *hentry)
-{
-       struct drm_hash_item *item;
-       int ret;
-
-       if (!hentry) {
-               DRM_DEBUG("Invalid parameters\n");
-               return -EINVAL;
-       }
-
-       item = &hentry->item;
-       item->key = tgid;
-
-       /**
-        * NOTE: drm_ht_insert_item will perform such a check
-       ret = psb_gtt_mm_get_ht_by_pid(mm, tgid, &tmp);
-       if (!ret) {
-               DRM_DEBUG("Entry already exists for pid %ld\n", tgid);
-               return -EAGAIN;
-       }
-       */
-
-       /*Insert the given entry*/
-       ret = drm_ht_insert_item(&mm->hash, item);
-       if (ret) {
-               DRM_DEBUG("Insert failure\n");
-               return ret;
-       }
-
-       mm->count++;
-
-       return 0;
-}
-
-static int psb_gtt_mm_alloc_insert_ht(struct psb_gtt_mm *mm,
-                                     u32 tgid,
-                                     struct psb_gtt_hash_entry **entry)
-{
-       struct psb_gtt_hash_entry *hentry;
-       int ret;
-
-       /*if the hentry for this tgid exists, just get it and return*/
-       spin_lock(&mm->lock);
-       ret = psb_gtt_mm_get_ht_by_pid_locked(mm, tgid, &hentry);
-       if (!ret) {
-               DRM_DEBUG("Entry for tgid %ld exist, hentry %p\n",
-                         tgid, hentry);
-               *entry = hentry;
-               spin_unlock(&mm->lock);
-               return 0;
-       }
-       spin_unlock(&mm->lock);
-
-       DRM_DEBUG("Entry for tgid %ld doesn't exist, will create it\n", tgid);
-
-       hentry = kzalloc(sizeof(struct psb_gtt_hash_entry), GFP_KERNEL);
-       if (!hentry) {
-               DRM_DEBUG("Kmalloc failled\n");
-               return -ENOMEM;
-       }
-
-       ret = drm_ht_create(&hentry->ht, 20);
-       if (ret) {
-               DRM_DEBUG("Create hash table failed\n");
-               return ret;
-       }
-
-       spin_lock(&mm->lock);
-       ret = psb_gtt_mm_insert_ht_locked(mm, tgid, hentry);
-       spin_unlock(&mm->lock);
-
-       if (!ret)
-               *entry = hentry;
-
-       return ret;
-}
-
-static struct psb_gtt_hash_entry *
-psb_gtt_mm_remove_ht_locked(struct psb_gtt_mm *mm, u32 tgid)
-{
-       struct psb_gtt_hash_entry *tmp;
-       int ret;
-
-       ret = psb_gtt_mm_get_ht_by_pid_locked(mm, tgid, &tmp);
-       if (ret) {
-               DRM_DEBUG("Cannot find entry pid %ld\n", tgid);
-               return NULL;
-       }
-
-       /*remove it from ht*/
-       drm_ht_remove_item(&mm->hash, &tmp->item);
-
-       mm->count--;
-
-       return tmp;
-}
-
-static int psb_gtt_mm_remove_free_ht_locked(struct psb_gtt_mm *mm, u32 tgid)
-{
-       struct psb_gtt_hash_entry *entry;
-
-       entry = psb_gtt_mm_remove_ht_locked(mm, tgid);
-
-       if (!entry) {
-               DRM_DEBUG("Invalid entry");
-               return -EINVAL;
-       }
-
-       /*delete ht*/
-       drm_ht_remove(&entry->ht);
-
-       /*free this entry*/
-       kfree(entry);
-       return 0;
-}
-
-static int
-psb_gtt_mm_get_mem_mapping_locked(struct drm_open_hash *ht,
-                          u32 key,
-                          struct psb_gtt_mem_mapping **hentry)
-{
-       struct drm_hash_item *entry;
-       struct psb_gtt_mem_mapping *mapping;
-       int ret;
-
-       ret = drm_ht_find_item(ht, key, &entry);
-       if (ret) {
-               DRM_DEBUG("Cannot find key %ld\n", key);
-               return ret;
-       }
-
-       mapping =  container_of(entry, struct psb_gtt_mem_mapping, item);
-       if (!mapping) {
-               DRM_DEBUG("Invalid entry\n");
-               return -EINVAL;
-       }
-
-       *hentry = mapping;
-       return 0;
-}
-
-static int
-psb_gtt_mm_insert_mem_mapping_locked(struct drm_open_hash *ht,
-                             u32 key,
-                             struct psb_gtt_mem_mapping *hentry)
-{
-       struct drm_hash_item *item;
-       struct psb_gtt_hash_entry *entry;
-       int ret;
-
-       if (!hentry) {
-               DRM_DEBUG("hentry is NULL\n");
-               return -EINVAL;
-       }
-
-       item = &hentry->item;
-       item->key = key;
-
-       ret = drm_ht_insert_item(ht, item);
-       if (ret) {
-               DRM_DEBUG("insert_item failed\n");
-               return ret;
-       }
-
-       entry = container_of(ht, struct psb_gtt_hash_entry, ht);
-       if (entry)
-               entry->count++;
-
-       return 0;
-}
-
-static int
-psb_gtt_mm_alloc_insert_mem_mapping(struct psb_gtt_mm *mm,
-                                   struct drm_open_hash *ht,
-                                   u32 key,
-                                   struct drm_mm_node *node,
-                                   struct psb_gtt_mem_mapping **entry)
-{
-       struct psb_gtt_mem_mapping *mapping;
-       int ret;
-
-       if (!node || !ht) {
-               DRM_DEBUG("parameter error\n");
-               return -EINVAL;
-       }
-
-       /*try to get this mem_map */
-       spin_lock(&mm->lock);
-       ret = psb_gtt_mm_get_mem_mapping_locked(ht, key, &mapping);
-       if (!ret) {
-               DRM_DEBUG("mapping entry for key %ld exists, entry %p\n",
-                         key, mapping);
-               *entry = mapping;
-               spin_unlock(&mm->lock);
-               return 0;
-       }
-       spin_unlock(&mm->lock);
-
-       DRM_DEBUG("Mapping entry for key %ld doesn't exist, will create it\n",
-                 key);
-
-       mapping = kzalloc(sizeof(struct psb_gtt_mem_mapping), GFP_KERNEL);
-       if (!mapping) {
-               DRM_DEBUG("kmalloc failed\n");
-               return -ENOMEM;
-       }
-
-       mapping->node = node;
-
-       spin_lock(&mm->lock);
-       ret = psb_gtt_mm_insert_mem_mapping_locked(ht, key, mapping);
-       spin_unlock(&mm->lock);
-
-       if (!ret)
-               *entry = mapping;
-
-       return ret;
-}
-
-static struct psb_gtt_mem_mapping *
-psb_gtt_mm_remove_mem_mapping_locked(struct drm_open_hash *ht, u32 key)
-{
-       struct psb_gtt_mem_mapping *tmp;
-       struct psb_gtt_hash_entry *entry;
-       int ret;
-
-       ret = psb_gtt_mm_get_mem_mapping_locked(ht, key, &tmp);
-       if (ret) {
-               DRM_DEBUG("Cannot find key %ld\n", key);
-               return NULL;
-       }
-
-       drm_ht_remove_item(ht, &tmp->item);
-
-       entry = container_of(ht, struct psb_gtt_hash_entry, ht);
-       if (entry)
-               entry->count--;
-
-       return tmp;
-}
-
-static int psb_gtt_mm_remove_free_mem_mapping_locked(struct drm_open_hash *ht,
-                                             u32 key,
-                                             struct drm_mm_node **node)
-{
-       struct psb_gtt_mem_mapping *entry;
-
-       entry = psb_gtt_mm_remove_mem_mapping_locked(ht, key);
-       if (!entry) {
-               DRM_DEBUG("entry is NULL\n");
-               return -EINVAL;
-       }
-
-       *node = entry->node;
-
-       kfree(entry);
-       return 0;
-}
-
-static int psb_gtt_add_node(struct psb_gtt_mm *mm,
-                           u32 tgid,
-                           u32 key,
-                           struct drm_mm_node *node,
-                           struct psb_gtt_mem_mapping **entry)
-{
-       struct psb_gtt_hash_entry *hentry;
-       struct psb_gtt_mem_mapping *mapping;
-       int ret;
-
-       ret = psb_gtt_mm_alloc_insert_ht(mm, tgid, &hentry);
-       if (ret) {
-               DRM_DEBUG("alloc_insert failed\n");
-               return ret;
-       }
-
-       ret = psb_gtt_mm_alloc_insert_mem_mapping(mm,
-                                                 &hentry->ht,
-                                                 key,
-                                                 node,
-                                                 &mapping);
-       if (ret) {
-               DRM_DEBUG("mapping alloc_insert failed\n");
-               return ret;
-       }
-
-       *entry = mapping;
-
-       return 0;
-}
-
-static int psb_gtt_remove_node(struct psb_gtt_mm *mm,
-                              u32 tgid,
-                              u32 key,
-                              struct drm_mm_node **node)
-{
-       struct psb_gtt_hash_entry *hentry;
-       struct drm_mm_node *tmp;
-       int ret;
-
-       spin_lock(&mm->lock);
-       ret = psb_gtt_mm_get_ht_by_pid_locked(mm, tgid, &hentry);
-       if (ret) {
-               DRM_DEBUG("Cannot find entry for pid %ld\n", tgid);
-               spin_unlock(&mm->lock);
-               return ret;
-       }
-       spin_unlock(&mm->lock);
-
-       /*remove mapping entry*/
-       spin_lock(&mm->lock);
-       ret = psb_gtt_mm_remove_free_mem_mapping_locked(&hentry->ht,
-                                                       key,
-                                                       &tmp);
-       if (ret) {
-               DRM_DEBUG("remove_free failed\n");
-               spin_unlock(&mm->lock);
-               return ret;
-       }
-
-       *node = tmp;
-
-       /*check the count of mapping entry*/
-       if (!hentry->count) {
-               DRM_DEBUG("count of mapping entry is zero, tgid=%ld\n", tgid);
-               psb_gtt_mm_remove_free_ht_locked(mm, tgid);
-       }
-
-       spin_unlock(&mm->lock);
-
-       return 0;
-}
-
-static int psb_gtt_mm_alloc_mem(struct psb_gtt_mm *mm,
-                               uint32_t pages,
-                               uint32_t align,
-                               struct drm_mm_node **node)
-{
-       struct drm_mm_node *tmp_node;
-       int ret;
-
-       do {
-               ret = drm_mm_pre_get(&mm->base);
-               if (unlikely(ret)) {
-                       DRM_DEBUG("drm_mm_pre_get error\n");
-                       return ret;
-               }
-
-               spin_lock(&mm->lock);
-               tmp_node = drm_mm_search_free(&mm->base, pages, align, 1);
-               if (unlikely(!tmp_node)) {
-                       DRM_DEBUG("No free node found\n");
-                       spin_unlock(&mm->lock);
-                       break;
-               }
-
-               tmp_node = drm_mm_get_block_atomic(tmp_node, pages, align);
-               spin_unlock(&mm->lock);
-       } while (!tmp_node);
-
-       if (!tmp_node) {
-               DRM_DEBUG("Node allocation failed\n");
-               return -ENOMEM;
-       }
-
-       *node = tmp_node;
-       return 0;
-}
-
-static void psb_gtt_mm_free_mem(struct psb_gtt_mm *mm, struct drm_mm_node *node)
-{
-       spin_lock(&mm->lock);
-       drm_mm_put_block(node);
-       spin_unlock(&mm->lock);
-}
-
-int psb_gtt_map_meminfo(struct drm_device *dev,
-                       void *hKernelMemInfo,
-                       uint32_t *offset)
-{
-       return -EINVAL;
-       /* FIXMEAC */
-#if 0
-       struct drm_psb_private *dev_priv
-              = (struct drm_psb_private *)dev->dev_private;
-       void *psKernelMemInfo;
-       struct psb_gtt_mm *mm = dev_priv->gtt_mm;
-       struct psb_gtt *pg = dev_priv->pg;
-       uint32_t size, pages, offset_pages;
-       void *kmem;
-       struct drm_mm_node *node;
-       struct page **page_list;
-       struct psb_gtt_mem_mapping *mapping = NULL;
-       int ret;
-
-       ret = psb_get_meminfo_by_handle(hKernelMemInfo, &psKernelMemInfo);
-       if (ret) {
-               DRM_DEBUG("Cannot find kernelMemInfo handle %ld\n",
-                         hKernelMemInfo);
-               return -EINVAL;
-       }
-
-       DRM_DEBUG("Got psKernelMemInfo %p for handle %lx\n",
-                 psKernelMemInfo, (u32)hKernelMemInfo);
-       size = psKernelMemInfo->ui32AllocSize;
-       kmem = psKernelMemInfo->pvLinAddrKM;
-       pages = (size + PAGE_SIZE - 1) >> PAGE_SHIFT;
-
-       DRM_DEBUG("KerMemInfo size %ld, cpuVadr %lx, pages %ld, osMemHdl %lx\n",
-                 size, kmem, pages, psKernelMemInfo->sMemBlk.hOSMemHandle);
-
-       if (!kmem)
-               DRM_DEBUG("kmem is NULL");
-
-       /*get pages*/
-       ret = psb_get_pages_by_mem_handle(psKernelMemInfo->sMemBlk.hOSMemHandle,
-                                         &page_list);
-       if (ret) {
-               DRM_DEBUG("get pages error\n");
-               return ret;
-       }
-
-       DRM_DEBUG("get %ld pages\n", pages);
-
-       /*alloc memory in TT apeture*/
-       ret = psb_gtt_mm_alloc_mem(mm, pages, 0, &node);
-       if (ret) {
-               DRM_DEBUG("alloc TT memory error\n");
-               goto failed_pages_alloc;
-       }
-
-       /*update psb_gtt_mm*/
-       ret = psb_gtt_add_node(mm,
-                              task_tgid_nr(current),
-                              (u32)hKernelMemInfo,
-                              node,
-                              &mapping);
-       if (ret) {
-               DRM_DEBUG("add_node failed");
-               goto failed_add_node;
-       }
-
-       node = mapping->node;
-       offset_pages = node->start;
-
-       DRM_DEBUG("get free node for %ld pages, offset %ld pages",
-                 pages, offset_pages);
-
-       /*update gtt*/
-       psb_gtt_insert_pages(pg, page_list,
-                            (unsigned)offset_pages,
-                            (unsigned)pages,
-                            0,
-                            0,
-                            0);
-
-       *offset = offset_pages;
-       return 0;
-
-failed_add_node:
-       psb_gtt_mm_free_mem(mm, node);
-failed_pages_alloc:
-       kfree(page_list);
-       return ret;
-#endif
-}
-
-int psb_gtt_unmap_meminfo(struct drm_device *dev, void * hKernelMemInfo)
-{
-       struct drm_psb_private *dev_priv
-              = (struct drm_psb_private *)dev->dev_private;
-       struct psb_gtt_mm *mm = dev_priv->gtt_mm;
-       struct psb_gtt *pg = dev_priv->pg;
-       uint32_t pages, offset_pages;
-       struct drm_mm_node *node;
-       int ret;
-
-       ret = psb_gtt_remove_node(mm,
-                       task_tgid_nr(current),
-                       (u32)hKernelMemInfo,
-                       &node);
-       if (ret) {
-               DRM_DEBUG("remove node failed\n");
-               return ret;
-       }
-
-       /*remove gtt entries*/
-       offset_pages = node->start;
-       pages = node->size;
-
-       psb_gtt_remove_pages(pg, offset_pages, pages, 0, 0, 1);
-
-
-       /*free tt node*/
-
-       psb_gtt_mm_free_mem(mm, node);
-       return 0;
-}
-
-int psb_gtt_map_meminfo_ioctl(struct drm_device *dev, void *data,
-                              struct drm_file *file_priv)
-{
-       struct psb_gtt_mapping_arg *arg
-              = (struct psb_gtt_mapping_arg *)data;
-       uint32_t *offset_pages = &arg->offset_pages;
-
-       DRM_DEBUG("\n");
-
-       return psb_gtt_map_meminfo(dev, arg->hKernelMemInfo, offset_pages);
-}
-
-int psb_gtt_unmap_meminfo_ioctl(struct drm_device *dev, void *data,
-                               struct drm_file *file_priv)
-{
-
-       struct psb_gtt_mapping_arg *arg
-              = (struct psb_gtt_mapping_arg *)data;
-
-       DRM_DEBUG("\n");
-
-       return psb_gtt_unmap_meminfo(dev, arg->hKernelMemInfo);
-}
-
-int psb_gtt_map_pvr_memory(struct drm_device *dev,  unsigned int hHandle,
-                       unsigned int ui32TaskId, dma_addr_t *pPages,
-                       unsigned int ui32PagesNum, unsigned int *ui32Offset)
-{
-       struct drm_psb_private *dev_priv = dev->dev_private;
-       struct psb_gtt_mm *mm = dev_priv->gtt_mm;
-       struct psb_gtt *pg = dev_priv->pg;
-       uint32_t size, pages, offset_pages;
-       struct drm_mm_node *node = NULL;
-       struct psb_gtt_mem_mapping *mapping = NULL;
-       int ret;
-
-       size = ui32PagesNum * PAGE_SIZE;
-       pages = 0;
-
-       /*alloc memory in TT apeture*/
-       ret = psb_gtt_mm_alloc_mem(mm, ui32PagesNum, 0, &node);
-       if (ret) {
-               DRM_DEBUG("alloc TT memory error\n");
-               goto failed_pages_alloc;
-       }
-
-   /*update psb_gtt_mm*/
-       ret = psb_gtt_add_node(mm,
-                                                  (u32)ui32TaskId,
-                                                  (u32)hHandle,
-                                                  node,
-                                                  &mapping);
-       if (ret) {
-               DRM_DEBUG("add_node failed");
-               goto failed_add_node;
-       }
-
-       node = mapping->node;
-       offset_pages = node->start;
-
-       DRM_DEBUG("get free node for %ld pages, offset %ld pages",
-                                                       pages, offset_pages);
-
-       /*update gtt*/
-       psb_gtt_insert_phys_addresses(pg, pPages, (unsigned)offset_pages,
-                                               (unsigned)ui32PagesNum, 0);
-
-       *ui32Offset = offset_pages;
-       return 0;
-
-failed_add_node:
-       psb_gtt_mm_free_mem(mm, node);
-failed_pages_alloc:
-       return ret;
-}
-
-
-int psb_gtt_unmap_pvr_memory(struct drm_device *dev, unsigned int hHandle,
-                                               unsigned int ui32TaskId)
-{
-       struct drm_psb_private *dev_priv = dev->dev_private;
-       struct psb_gtt_mm *mm = dev_priv->gtt_mm;
-       struct psb_gtt *pg = dev_priv->pg;
-       uint32_t pages, offset_pages;
-       struct drm_mm_node *node;
-       int ret;
-
-       ret = psb_gtt_remove_node(mm, (u32)ui32TaskId, (u32)hHandle, &node);
-       if (ret) {
-               printk(KERN_ERR "remove node failed\n");
-               return ret;
-       }
-
-       /*remove gtt entries*/
-       offset_pages = node->start;
-       pages = node->size;
-
-       psb_gtt_remove_pages(pg, offset_pages, pages, 0, 0, 1);
-
-       /*free tt node*/
-       psb_gtt_mm_free_mem(mm, node);
-       return 0;
-}
index 0272f83b461ebb783fadda40eb0ce40d35c94e4a..535ae00f2ab96f3b1288ef6e1c19bc6f2505fd14 100644 (file)
 
 #include <drm/drmP.h>
 
-/*#include "img_types.h"*/
-
 struct psb_gtt {
        struct drm_device *dev;
-       int initialized;
        uint32_t gatt_start;
        uint32_t mmu_gatt_start;
-       uint32_t ci_start;
-       uint32_t rar_start;
        uint32_t gtt_start;
        uint32_t gtt_phys_start;
        unsigned gtt_pages;
        unsigned gatt_pages;
-       uint32_t stolen_base;
-       void *vram_addr;
-       uint32_t pge_ctl;
-       u16 gmch_ctrl;
        unsigned long stolen_size;
        unsigned long vram_stolen_size;
-       unsigned long ci_stolen_size;
-       unsigned long rar_stolen_size;
-       uint32_t *gtt_map;
        struct rw_semaphore sem;
 };
 
-struct psb_gtt_mm {
-       struct drm_mm base;
-       struct drm_open_hash hash;
-       uint32_t count;
-       spinlock_t lock;
-};
-
-struct psb_gtt_hash_entry {
-       struct drm_open_hash ht;
-       uint32_t count;
-       struct drm_hash_item item;
-};
-
-struct psb_gtt_mem_mapping {
-       struct drm_mm_node *node;
-       struct drm_hash_item item;
-};
-
 /*Exported functions*/
-extern int psb_gtt_init(struct psb_gtt *pg, int resume);
-extern int psb_gtt_insert_pages(struct psb_gtt *pg, struct page **pages,
-                               unsigned offset_pages, unsigned num_pages,
-                               unsigned desired_tile_stride,
-                               unsigned hw_tile_stride, int type);
-extern int psb_gtt_remove_pages(struct psb_gtt *pg, unsigned offset_pages,
-                               unsigned num_pages,
-                               unsigned desired_tile_stride,
-                               unsigned hw_tile_stride,
-                               int rc_prot);
-
-extern struct psb_gtt *psb_gtt_alloc(struct drm_device *dev);
-extern void psb_gtt_takedown(struct psb_gtt *pg, int free);
-extern int psb_gtt_map_meminfo(struct drm_device *dev,
-                               void * hKernelMemInfo,
-                               uint32_t *offset);
-extern int psb_gtt_unmap_meminfo(struct drm_device *dev,
-                                void * hKernelMemInfo);
-extern int psb_gtt_map_meminfo_ioctl(struct drm_device *dev, void *data,
-                                    struct drm_file *file_priv);
-extern int psb_gtt_unmap_meminfo_ioctl(struct drm_device *dev, void *data,
-                                      struct drm_file *file_priv);
-extern int psb_gtt_mm_init(struct psb_gtt *pg);
-extern void psb_gtt_mm_takedown(void);
-
-extern int psb_gtt_map_pvr_memory(struct drm_device *dev,
-                                                                  unsigned int hHandle,
-                                                                  unsigned int ui32TaskId,
-                                                                  dma_addr_t *pPages,
-                                                                  unsigned int ui32PagesNum,
-                                                                  unsigned int *ui32Offset);
+extern int psb_gtt_init(struct drm_device *dev, int resume);
+extern void psb_gtt_takedown(struct drm_device *dev);
+
+/* Each gtt_range describes an allocation in the GTT area */
+struct gtt_range {
+       struct resource resource;
+       u32 offset;
+       struct kref kref;
+       struct drm_gem_object gem;      /* GEM high level stuff */
+       int in_gart;                    /* Currently in the GART (ref ct) */
+        bool stolen;                   /* Backed from stolen RAM */
+        bool mmapping;                 /* Is mmappable */
+       struct page **pages;            /* Backing pages if present */
+};
 
-extern int psb_gtt_unmap_pvr_memory(struct drm_device *dev,
-                                                                        unsigned int hHandle,
-                                                                        unsigned int ui32TaskId);
+extern struct gtt_range *psb_gtt_alloc_range(struct drm_device *dev, int len,
+                                               const char *name, int backed);
+extern void psb_gtt_kref_put(struct gtt_range *gt);
+extern void psb_gtt_free_range(struct drm_device *dev, struct gtt_range *gt);
+extern int psb_gtt_pin(struct gtt_range *gt);
+extern void psb_gtt_unpin(struct gtt_range *gt);
 
 #endif
index 80b37f4ca10a01b3ef4f30ebf6f953f31afe7207..4f47d09d65de73121d438f90a058b886692a5043 100644 (file)
@@ -341,9 +341,8 @@ int psb_intel_pipe_set_base(struct drm_crtc *crtc,
        /* struct drm_i915_master_private *master_priv; */
        struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc);
        struct psb_framebuffer *psbfb = to_psb_fb(crtc->fb);
-       struct psb_intel_mode_device *mode_dev = psb_intel_crtc->mode_dev;
        int pipe = psb_intel_crtc->pipe;
-       unsigned long Start, Offset;
+       unsigned long start, offset;
        int dspbase = (pipe == 0 ? DSPABASE : DSPBBASE);
        int dspsurf = (pipe == 0 ? DSPASURF : DSPBSURF);
        int dspstride = (pipe == 0) ? DSPASTRIDE : DSPBSTRIDE;
@@ -359,12 +358,17 @@ int psb_intel_pipe_set_base(struct drm_crtc *crtc,
                return 0;
        }
 
-       if (!ospm_power_using_hw_begin(OSPM_DISPLAY_ISLAND,
-                                      OSPM_UHB_FORCE_POWER_ON))
+       if (!gma_power_begin(dev, true))
                return 0;
 
-       Start = mode_dev->bo_offset(dev, psbfb);
-       Offset = y * crtc->fb->pitch + x * (crtc->fb->bits_per_pixel / 8);
+       /* We are displaying this buffer, make sure it is actually loaded
+          into the GTT */
+       ret = psb_gtt_pin(psbfb->gtt);
+       if (ret < 0)
+               goto psb_intel_pipe_set_base_exit;
+       start = psbfb->gtt->offset;
+
+       offset = y * crtc->fb->pitch + x * (crtc->fb->bits_per_pixel / 8);
 
        REG_WRITE(dspstride, crtc->fb->pitch);
 
@@ -388,25 +392,29 @@ int psb_intel_pipe_set_base(struct drm_crtc *crtc,
        default:
                DRM_ERROR("Unknown color depth\n");
                ret = -EINVAL;
+               psb_gtt_unpin(psbfb->gtt);
                goto psb_intel_pipe_set_base_exit;
        }
        REG_WRITE(dspcntr_reg, dspcntr);
 
-       DRM_DEBUG("Writing base %08lX %08lX %d %d\n", Start, Offset, x, y);
+
+       DRM_DEBUG("Writing base %08lX %08lX %d %d\n", start, offset, x, y);
        if (0 /* FIXMEAC - check what PSB needs */) {
-               REG_WRITE(dspbase, Offset);
+               REG_WRITE(dspbase, offset);
                REG_READ(dspbase);
-               REG_WRITE(dspsurf, Start);
+               REG_WRITE(dspsurf, start);
                REG_READ(dspsurf);
        } else {
-               REG_WRITE(dspbase, Start + Offset);
+               REG_WRITE(dspbase, start + offset);
                REG_READ(dspbase);
        }
 
-psb_intel_pipe_set_base_exit:
-
-       ospm_power_using_hw_end(OSPM_DISPLAY_ISLAND);
+       /* If there was a previous display we can now unpin it */
+       if (old_fb)
+               psb_gtt_unpin(to_psb_fb(old_fb)->gtt);
 
+psb_intel_pipe_set_base_exit:
+       gma_power_end(dev);
        return ret;
 }
 
@@ -816,8 +824,7 @@ void psb_intel_crtc_load_lut(struct drm_crtc *crtc)
                return;
        }
 
-       if (ospm_power_using_hw_begin(OSPM_DISPLAY_ISLAND,
-                                     OSPM_UHB_ONLY_IF_ON)) {
+       if (gma_power_begin(dev, false)) {
                for (i = 0; i < 256; i++) {
                        REG_WRITE(palreg + 4 * i,
                                  ((psb_intel_crtc->lut_r[i] +
@@ -827,7 +834,7 @@ void psb_intel_crtc_load_lut(struct drm_crtc *crtc)
                                  (psb_intel_crtc->lut_b[i] +
                                  psb_intel_crtc->lut_adj[i]));
                }
-               ospm_power_using_hw_end(OSPM_DISPLAY_ISLAND);
+               gma_power_end(dev);
        } else {
                for (i = 0; i < 256; i++) {
                        dev_priv->save_palette_a[i] =
@@ -1022,19 +1029,14 @@ static int psb_intel_crtc_cursor_set(struct drm_crtc *crtc,
                                 uint32_t width, uint32_t height)
 {
        struct drm_device *dev = crtc->dev;
-       struct drm_psb_private *dev_priv =
-                               (struct drm_psb_private *)dev->dev_private;
-       struct psb_gtt *pg = dev_priv->pg;
        struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc);
-       struct psb_intel_mode_device *mode_dev = psb_intel_crtc->mode_dev;
        int pipe = psb_intel_crtc->pipe;
        uint32_t control = (pipe == 0) ? CURACNTR : CURBCNTR;
        uint32_t base = (pipe == 0) ? CURABASE : CURBBASE;
        uint32_t temp;
        size_t addr = 0;
-       uint32_t page_offset;
-       size_t size;
-       void *bo;
+       struct gtt_range *gt;
+       struct drm_gem_object *obj;
        int ret;
 
        DRM_DEBUG("\n");
@@ -1043,22 +1045,21 @@ static int psb_intel_crtc_cursor_set(struct drm_crtc *crtc,
        if (!handle) {
                DRM_DEBUG("cursor off\n");
                /* turn off the cursor */
-               temp = 0;
-               temp |= CURSOR_MODE_DISABLE;
+               temp = CURSOR_MODE_DISABLE;
 
-               if (ospm_power_using_hw_begin(OSPM_DISPLAY_ISLAND,
-                                             OSPM_UHB_ONLY_IF_ON)) {
+               if (gma_power_begin(dev, false)) {
                        REG_WRITE(control, temp);
                        REG_WRITE(base, 0);
-                       ospm_power_using_hw_end(OSPM_DISPLAY_ISLAND);
+                       gma_power_end(dev);
                }
 
-               /* unpin the old bo */
-               if (psb_intel_crtc->cursor_bo) {
-                       mode_dev->bo_unpin_for_scanout(dev,
-                                                      psb_intel_crtc->
-                                                      cursor_bo);
-                       psb_intel_crtc->cursor_bo = NULL;
+               /* Unpin the old GEM object */
+               if (psb_intel_crtc->cursor_obj) {
+                       gt = container_of(psb_intel_crtc->cursor_obj,
+                                                       struct gtt_range, gem);
+                       psb_gtt_unpin(gt);
+                       drm_gem_object_unreference(psb_intel_crtc->cursor_obj);
+                       psb_intel_crtc->cursor_obj = NULL;
                }
 
                return 0;
@@ -1070,32 +1071,26 @@ static int psb_intel_crtc_cursor_set(struct drm_crtc *crtc,
                return -EINVAL;
        }
 
-       bo = mode_dev->bo_from_handle(dev, file_priv, handle);
-       if (!bo)
+       obj = drm_gem_object_lookup(dev, file_priv, handle);
+       if (!obj)
                return -ENOENT;
 
-       ret = mode_dev->bo_pin_for_scanout(dev, bo);
-       if (ret)
-               return ret;
-       size = mode_dev->bo_size(dev, bo);
-       if (size < width * height * 4) {
+       if (obj->size < width * height * 4) {
                DRM_ERROR("buffer is to small\n");
                return -ENOMEM;
        }
 
-       /*insert this bo into gtt*/
-       DRM_DEBUG("%s: map meminfo for hw cursor. handle %x\n",
-                                               __func__, handle);
+       gt = container_of(obj, struct gtt_range, gem);
 
-       ret = psb_gtt_map_meminfo(dev, (void *)handle, &page_offset);
+       /* Pin the memory into the GTT */
+       ret = psb_gtt_pin(gt);
        if (ret) {
-               DRM_ERROR("Can not map meminfo to GTT. handle 0x%x\n", handle);
+               DRM_ERROR("Can not pin down handle 0x%x\n", handle);
                return ret;
        }
 
-       addr = page_offset << PAGE_SHIFT;
 
-       addr += pg->stolen_base;
+       addr = gt->offset;      /* Or resource.start ??? */
 
        psb_intel_crtc->cursor_addr = addr;
 
@@ -1104,17 +1099,19 @@ static int psb_intel_crtc_cursor_set(struct drm_crtc *crtc,
        temp |= (pipe << 28);
        temp |= CURSOR_MODE_64_ARGB_AX | MCURSOR_GAMMA_ENABLE;
 
-       if (ospm_power_using_hw_begin(OSPM_DISPLAY_ISLAND,
-                                     OSPM_UHB_ONLY_IF_ON)) {
+       if (gma_power_begin(dev, false)) {
                REG_WRITE(control, temp);
                REG_WRITE(base, addr);
-               ospm_power_using_hw_end(OSPM_DISPLAY_ISLAND);
+               gma_power_end(dev);
        }
 
        /* unpin the old bo */
-       if (psb_intel_crtc->cursor_bo && psb_intel_crtc->cursor_bo != bo) {
-               mode_dev->bo_unpin_for_scanout(dev, psb_intel_crtc->cursor_bo);
-               psb_intel_crtc->cursor_bo = bo;
+       if (psb_intel_crtc->cursor_obj && psb_intel_crtc->cursor_obj != obj) {
+               gt = container_of(psb_intel_crtc->cursor_obj,
+                                                       struct gtt_range, gem);
+               psb_gtt_unpin(gt);
+               drm_gem_object_unreference(psb_intel_crtc->cursor_obj);
+               psb_intel_crtc->cursor_obj = obj;
        }
 
        return 0;
@@ -1126,7 +1123,7 @@ static int psb_intel_crtc_cursor_move(struct drm_crtc *crtc, int x, int y)
        struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc);
        int pipe = psb_intel_crtc->pipe;
        uint32_t temp = 0;
-       uint32_t adder;
+       uint32_t addr;
 
 
        if (x < 0) {
@@ -1141,13 +1138,12 @@ static int psb_intel_crtc_cursor_move(struct drm_crtc *crtc, int x, int y)
        temp |= ((x & CURSOR_POS_MASK) << CURSOR_X_SHIFT);
        temp |= ((y & CURSOR_POS_MASK) << CURSOR_Y_SHIFT);
 
-       adder = psb_intel_crtc->cursor_addr;
+       addr = psb_intel_crtc->cursor_addr;
 
-       if (ospm_power_using_hw_begin(OSPM_DISPLAY_ISLAND,
-                                     OSPM_UHB_ONLY_IF_ON)) {
+       if (gma_power_begin(dev, false)) {
                REG_WRITE((pipe == 0) ? CURAPOS : CURBPOS, temp);
-               REG_WRITE((pipe == 0) ? CURABASE : CURBBASE, adder);
-               ospm_power_using_hw_end(OSPM_DISPLAY_ISLAND);
+               REG_WRITE((pipe == 0) ? CURABASE : CURBBASE, addr);
+               gma_power_end(dev);
        }
        return 0;
 }
@@ -1197,15 +1193,14 @@ static int psb_intel_crtc_clock_get(struct drm_device *dev,
        bool is_lvds;
        struct drm_psb_private *dev_priv = dev->dev_private;
 
-       if (ospm_power_using_hw_begin(OSPM_DISPLAY_ISLAND,
-                                     OSPM_UHB_ONLY_IF_ON)) {
+       if (gma_power_begin(dev, false)) {
                dpll = REG_READ((pipe == 0) ? DPLL_A : DPLL_B);
                if ((dpll & DISPLAY_RATE_SELECT_FPA1) == 0)
                        fp = REG_READ((pipe == 0) ? FPA0 : FPB0);
                else
                        fp = REG_READ((pipe == 0) ? FPA1 : FPB1);
                is_lvds = (pipe == 1) && (REG_READ(LVDS) & LVDS_PORT_EN);
-               ospm_power_using_hw_end(OSPM_DISPLAY_ISLAND);
+               gma_power_end(dev);
        } else {
                dpll = (pipe == 0) ?
                        dev_priv->saveDPLL_A : dev_priv->saveDPLL_B;
@@ -1277,13 +1272,12 @@ struct drm_display_mode *psb_intel_crtc_mode_get(struct drm_device *dev,
        int vsync;
        struct drm_psb_private *dev_priv = dev->dev_private;
 
-       if (ospm_power_using_hw_begin(OSPM_DISPLAY_ISLAND,
-                                     OSPM_UHB_ONLY_IF_ON)) {
+       if (gma_power_begin(dev, false)) {
                htot = REG_READ((pipe == 0) ? HTOTAL_A : HTOTAL_B);
                hsync = REG_READ((pipe == 0) ? HSYNC_A : HSYNC_B);
                vtot = REG_READ((pipe == 0) ? VTOTAL_A : VTOTAL_B);
                vsync = REG_READ((pipe == 0) ? VSYNC_A : VSYNC_B);
-               ospm_power_using_hw_end(OSPM_DISPLAY_ISLAND);
+               gma_power_end(dev);
        } else {
                htot = (pipe == 0) ?
                        dev_priv->saveHTOTAL_A : dev_priv->saveHTOTAL_B;
@@ -1318,7 +1312,16 @@ struct drm_display_mode *psb_intel_crtc_mode_get(struct drm_device *dev,
 static void psb_intel_crtc_destroy(struct drm_crtc *crtc)
 {
        struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc);
-
+       struct gtt_range *gt;
+
+       /* Unpin the old GEM object */
+       if (psb_intel_crtc->cursor_obj) {
+               gt = container_of(psb_intel_crtc->cursor_obj,
+                                               struct gtt_range, gem);
+               psb_gtt_unpin(gt);
+               drm_gem_object_unreference(psb_intel_crtc->cursor_obj);
+               psb_intel_crtc->cursor_obj = NULL;
+       }
        kfree(psb_intel_crtc->crtc_state);
        drm_crtc_cleanup(crtc);
        kfree(psb_intel_crtc);
@@ -1333,10 +1336,6 @@ static const struct drm_crtc_helper_funcs psb_intel_helper_funcs = {
        .commit = psb_intel_crtc_commit,
 };
 
-static const struct drm_crtc_helper_funcs mrst_helper_funcs;
-static const struct drm_crtc_helper_funcs mdfld_helper_funcs;
-const struct drm_crtc_funcs mdfld_intel_crtc_funcs;
-
 const struct drm_crtc_funcs psb_intel_crtc_funcs = {
        .save = psb_intel_crtc_save,
        .restore = psb_intel_crtc_restore,
@@ -1397,7 +1396,11 @@ void psb_intel_crtc_init(struct drm_device *dev, int pipe,
        psb_intel_crtc->mode_dev = mode_dev;
        psb_intel_crtc->cursor_addr = 0;
 
-       drm_crtc_helper_add(&psb_intel_crtc->base,
+       if (IS_MRST(dev))
+               drm_crtc_helper_add(&psb_intel_crtc->base,
+                                   &mrst_helper_funcs);
+       else
+               drm_crtc_helper_add(&psb_intel_crtc->base,
                                    &psb_intel_helper_funcs);
 
        /* Setup the array of drm_connector pointer array */
index f6229c56de40011452be6dc433f8892db53ee527..6006ddd993f2f113855a73ed390c4e845743921d 100644 (file)
@@ -76,13 +76,7 @@ struct psb_intel_mode_device {
        /*
         * Abstracted memory manager operations
         */
-       void *(*bo_from_handle) (struct drm_device *dev,
-                                struct drm_file *file_priv,
-                                unsigned int handle);
-        size_t(*bo_size) (struct drm_device *dev, void *bo);
         size_t(*bo_offset) (struct drm_device *dev, void *bo);
-       int (*bo_pin_for_scanout) (struct drm_device *dev, void *bo);
-       int (*bo_unpin_for_scanout) (struct drm_device *dev, void *bo);
 
        /*
         * Cursor
@@ -156,11 +150,8 @@ struct psb_intel_crtc {
        /* a mode_set for fbdev users on this crtc */
        struct drm_mode_set mode_set;
 
-       /* current bo we scanout from */
-       void *scanout_bo;
-
-       /* current bo we cursor from */
-       void *cursor_bo;
+       /* GEM object that holds our cursor */
+       struct drm_gem_object *cursor_obj;
 
        struct drm_display_mode saved_mode;
        struct drm_display_mode saved_adjusted_mode;
index d3d210a1026ab10ba60664682ac37db9d3d4df39..b0a225b9f562c4b59641a49bf4d45e487aa63a36 100644 (file)
 #include "psb_powermgmt.h"
 #include <linux/pm_runtime.h>
 
-/* MRST defines start */
-uint8_t blc_freq;
-uint8_t blc_minbrightness;
-uint8_t blc_i2caddr;
-uint8_t blc_brightnesscmd;
-int lvds_backlight;            /* restore backlight to this value */
-
 u32 CoreClock;
 u32 PWMControlRegFreq;
 
@@ -83,13 +76,12 @@ static u32 psb_intel_lvds_get_max_backlight(struct drm_device *dev)
        struct drm_psb_private *dev_priv = dev->dev_private;
        u32 retVal;
 
-       if (ospm_power_using_hw_begin(OSPM_DISPLAY_ISLAND,
-                                       OSPM_UHB_ONLY_IF_ON)) {
+       if (gma_power_begin(dev, false)) {
                retVal = ((REG_READ(BLC_PWM_CTL) &
                          BACKLIGHT_MODULATION_FREQ_MASK) >>
                          BACKLIGHT_MODULATION_FREQ_SHIFT) * 2;
 
-               ospm_power_using_hw_end(OSPM_DISPLAY_ISLAND);
+               gma_power_end(dev);
        } else
                retVal = ((dev_priv->saveBLC_PWM_CTL &
                          BACKLIGHT_MODULATION_FREQ_MASK) >>
@@ -98,8 +90,11 @@ static u32 psb_intel_lvds_get_max_backlight(struct drm_device *dev)
        return retVal;
 }
 
-/**
+/*
  * Set LVDS backlight level by I2C command
+ *
+ * FIXME: at some point we need to both track this for PM and also
+ * disable runtime pm on MRST if the brightness is nil (ie blanked)
  */
 static int psb_lvds_i2c_set_brightness(struct drm_device *dev,
                                        unsigned int level)
@@ -132,7 +127,7 @@ static int psb_lvds_i2c_set_brightness(struct drm_device *dev,
 
        if (i2c_transfer(&lvds_i2c_bus->adapter, msgs, 1) == 1) {
                DRM_DEBUG("I2C set brightness.(command, value) (%d, %d)\n",
-                       blc_brightnesscmd,
+                       dev_priv->lvds_bl->brightnesscmd,
                        blc_i2c_brightness);
                return 0;
        }
@@ -200,14 +195,13 @@ static void psb_intel_lvds_set_backlight(struct drm_device *dev, int level)
        struct drm_psb_private *dev_priv = dev->dev_private;
        u32 blc_pwm_ctl;
 
-       if (ospm_power_using_hw_begin(OSPM_DISPLAY_ISLAND,
-                                       OSPM_UHB_ONLY_IF_ON)) {
+       if (gma_power_begin(dev, false)) {
                blc_pwm_ctl =
                        REG_READ(BLC_PWM_CTL) & ~BACKLIGHT_DUTY_CYCLE_MASK;
                REG_WRITE(BLC_PWM_CTL,
                                (blc_pwm_ctl |
                                (level << BACKLIGHT_DUTY_CYCLE_SHIFT)));
-               ospm_power_using_hw_end(OSPM_DISPLAY_ISLAND);
+               gma_power_end(dev);
        } else {
                blc_pwm_ctl = dev_priv->saveBLC_PWM_CTL &
                                ~BACKLIGHT_DUTY_CYCLE_MASK;
@@ -224,8 +218,7 @@ static void psb_intel_lvds_set_power(struct drm_device *dev,
 {
        u32 pp_status;
 
-       if (!ospm_power_using_hw_begin(OSPM_DISPLAY_ISLAND,
-                                       OSPM_UHB_FORCE_POWER_ON))
+       if (!gma_power_begin(dev, true))
                return;
 
        if (on) {
@@ -248,7 +241,7 @@ static void psb_intel_lvds_set_power(struct drm_device *dev,
                } while (pp_status & PP_ON);
        }
 
-       ospm_power_using_hw_end(OSPM_DISPLAY_ISLAND);
+       gma_power_end(dev);
 }
 
 static void psb_intel_lvds_encoder_dpms(struct drm_encoder *encoder, int mode)
@@ -400,11 +393,15 @@ bool psb_intel_lvds_mode_fixup(struct drm_encoder *encoder,
        if (psb_intel_output->type == INTEL_OUTPUT_MIPI2)
                panel_fixed_mode = mode_dev->panel_fixed_mode2;
 
-       /* PSB doesn't appear to be GEN4 */
-       if (psb_intel_crtc->pipe == 0) {
+       /* PSB requires the LVDS is on pipe B, MRST has only one pipe anyway */
+       if (!IS_MRST(dev) && psb_intel_crtc->pipe == 0) {
                printk(KERN_ERR "Can't support LVDS on pipe A\n");
                return false;
        }
+       if (IS_MRST(dev) && psb_intel_crtc->pipe != 0) {
+               printk(KERN_ERR "Must use PIPE A\n");
+               return false;
+       }
        /* Should never happen!! */
        list_for_each_entry(tmp_encoder, &dev->mode_config.encoder_list,
                            head) {
@@ -445,7 +442,7 @@ bool psb_intel_lvds_mode_fixup(struct drm_encoder *encoder,
        return true;
 }
 
-static void psb_intel_lvds_prepare(struct drm_encoder *encoder)
+void psb_intel_lvds_prepare(struct drm_encoder *encoder)
 {
        struct drm_device *dev = encoder->dev;
        struct psb_intel_output *output = enc_to_psb_intel_output(encoder);
@@ -453,8 +450,7 @@ static void psb_intel_lvds_prepare(struct drm_encoder *encoder)
 
        PSB_DEBUG_ENTRY("\n");
 
-       if (!ospm_power_using_hw_begin(OSPM_DISPLAY_ISLAND,
-                                       OSPM_UHB_FORCE_POWER_ON))
+       if (!gma_power_begin(dev, true))
                return;
 
        mode_dev->saveBLC_PWM_CTL = REG_READ(BLC_PWM_CTL);
@@ -463,10 +459,10 @@ static void psb_intel_lvds_prepare(struct drm_encoder *encoder)
 
        psb_intel_lvds_set_power(dev, output, false);
 
-       ospm_power_using_hw_end(OSPM_DISPLAY_ISLAND);
+       gma_power_end(dev);
 }
 
-static void psb_intel_lvds_commit(struct drm_encoder *encoder)
+void psb_intel_lvds_commit(struct drm_encoder *encoder)
 {
        struct drm_device *dev = encoder->dev;
        struct psb_intel_output *output = enc_to_psb_intel_output(encoder);
@@ -669,14 +665,14 @@ static const struct drm_encoder_helper_funcs psb_intel_lvds_helper_funcs = {
        .commit = psb_intel_lvds_commit,
 };
 
-static const struct drm_connector_helper_funcs
+const struct drm_connector_helper_funcs
                                psb_intel_lvds_connector_helper_funcs = {
        .get_modes = psb_intel_lvds_get_modes,
        .mode_valid = psb_intel_lvds_mode_valid,
        .best_encoder = psb_intel_best_encoder,
 };
 
-static const struct drm_connector_funcs psb_intel_lvds_connector_funcs = {
+const struct drm_connector_funcs psb_intel_lvds_connector_funcs = {
        .dpms = drm_helper_connector_dpms,
        .save = psb_intel_lvds_save,
        .restore = psb_intel_lvds_restore,
index 1d2bb021c0a53649c4ae3823ec24354d1b7309e8..df1c006ecfaabac799301ada83e689b2e64e7635 100644 (file)
@@ -204,7 +204,7 @@ static void psb_intel_sdvo_write_cmd(struct psb_intel_output *psb_intel_output,
        struct psb_intel_sdvo_priv *sdvo_priv = psb_intel_output->dev_priv;
        int i;
 
-       if (1) {
+       if (0) {
                DRM_DEBUG("%s: W: %02X ", SDVO_NAME(sdvo_priv), cmd);
                for (i = 0; i < args_len; i++)
                        printk(KERN_INFO"%02X ", ((u8 *) args)[i]);
@@ -266,7 +266,7 @@ static u8 psb_intel_sdvo_read_response(
                                         SDVO_I2C_CMD_STATUS,
                                         &status);
 
-               if (1) {
+               if (0) {
                        DRM_DEBUG("%s: R: ", SDVO_NAME(sdvo_priv));
                        for (i = 0; i < response_len; i++)
                                printk(KERN_INFO"%02X ", ((u8 *) response)[i]);
index 4597c88247218d0a496cac4d4beca6ac7700f5c5..9ea37e5888740771f71c705cc551b30496abe68e 100644 (file)
@@ -88,13 +88,12 @@ psb_enable_pipestat(struct drm_psb_private *dev_priv, int pipe, u32 mask)
                u32 reg = psb_pipestat(pipe);
                dev_priv->pipestat[pipe] |= mask;
                /* Enable the interrupt, clear any pending status */
-               if (ospm_power_using_hw_begin(OSPM_DISPLAY_ISLAND,
-                                                       OSPM_UHB_ONLY_IF_ON)) {
+               if (gma_power_begin(dev_priv->dev, false)) {
                        u32 writeVal = PSB_RVDC32(reg);
                        writeVal |= (mask | (mask >> 16));
                        PSB_WVDC32(writeVal, reg);
                        (void) PSB_RVDC32(reg);
-                       ospm_power_using_hw_end(OSPM_DISPLAY_ISLAND);
+                       gma_power_end(dev_priv->dev);
                }
        }
 }
@@ -105,39 +104,36 @@ psb_disable_pipestat(struct drm_psb_private *dev_priv, int pipe, u32 mask)
        if ((dev_priv->pipestat[pipe] & mask) != 0) {
                u32 reg = psb_pipestat(pipe);
                dev_priv->pipestat[pipe] &= ~mask;
-               if (ospm_power_using_hw_begin(OSPM_DISPLAY_ISLAND,
-                                                       OSPM_UHB_ONLY_IF_ON)) {
+               if (gma_power_begin(dev_priv->dev, false)) {
                        u32 writeVal = PSB_RVDC32(reg);
                        writeVal &= ~mask;
                        PSB_WVDC32(writeVal, reg);
                        (void) PSB_RVDC32(reg);
-                       ospm_power_using_hw_end(OSPM_DISPLAY_ISLAND);
+                       gma_power_end(dev_priv->dev);
                }
        }
 }
 
 void mid_enable_pipe_event(struct drm_psb_private *dev_priv, int pipe)
 {
-       if (ospm_power_using_hw_begin(OSPM_DISPLAY_ISLAND,
-                                                       OSPM_UHB_ONLY_IF_ON)) {
+       if (gma_power_begin(dev_priv->dev, false)) {
                u32 pipe_event = mid_pipe_event(pipe);
                dev_priv->vdc_irq_mask |= pipe_event;
                PSB_WVDC32(~dev_priv->vdc_irq_mask, PSB_INT_MASK_R);
                PSB_WVDC32(dev_priv->vdc_irq_mask, PSB_INT_ENABLE_R);
-               ospm_power_using_hw_end(OSPM_DISPLAY_ISLAND);
+               gma_power_end(dev_priv->dev);
        }
 }
 
 void mid_disable_pipe_event(struct drm_psb_private *dev_priv, int pipe)
 {
        if (dev_priv->pipestat[pipe] == 0) {
-               if (ospm_power_using_hw_begin(OSPM_DISPLAY_ISLAND,
-                                                       OSPM_UHB_ONLY_IF_ON)) {
+               if (gma_power_begin(dev_priv->dev, false)) {
                        u32 pipe_event = mid_pipe_event(pipe);
                        dev_priv->vdc_irq_mask &= ~pipe_event;
                        PSB_WVDC32(~dev_priv->vdc_irq_mask, PSB_INT_MASK_R);
                        PSB_WVDC32(dev_priv->vdc_irq_mask, PSB_INT_ENABLE_R);
-                       ospm_power_using_hw_end(OSPM_DISPLAY_ISLAND);
+                       gma_power_end(dev_priv->dev);
                }
        }
 }
@@ -242,7 +238,7 @@ irqreturn_t psb_irq_handler(DRM_IRQ_ARGS)
        vdc_stat &= dev_priv->vdc_irq_mask;
        spin_unlock(&dev_priv->irqmask_lock);
 
-       if (dsp_int && ospm_power_is_hw_on(OSPM_DISPLAY_ISLAND)) {
+       if (dsp_int && gma_power_is_on(dev)) {
                psb_vdc_interrupt(dev, vdc_stat);
                handled = 1;
        }
@@ -270,55 +266,29 @@ irqreturn_t psb_irq_handler(DRM_IRQ_ARGS)
 }
 
 void psb_irq_preinstall(struct drm_device *dev)
-{
-       psb_irq_preinstall_islands(dev, OSPM_ALL_ISLANDS);
-}
-
-/**
- * FIXME: should I remove display irq enable here??
- */
-void psb_irq_preinstall_islands(struct drm_device *dev, int hw_islands)
 {
        struct drm_psb_private *dev_priv =
            (struct drm_psb_private *) dev->dev_private;
        unsigned long irqflags;
 
-       PSB_DEBUG_ENTRY("\n");
-
        spin_lock_irqsave(&dev_priv->irqmask_lock, irqflags);
 
-       if (hw_islands & OSPM_DISPLAY_ISLAND) {
-               if (ospm_power_is_hw_on(OSPM_DISPLAY_ISLAND)) {
-                       PSB_WVDC32(0xFFFFFFFF, PSB_HWSTAM);
-                       if (dev->vblank_enabled[0])
-                               dev_priv->vdc_irq_mask |=
-                                               _PSB_PIPEA_EVENT_FLAG;
-                       if (dev->vblank_enabled[1])
-                               dev_priv->vdc_irq_mask |=
-                                               _MDFLD_PIPEB_EVENT_FLAG;
-                       if (dev->vblank_enabled[2])
-                               dev_priv->vdc_irq_mask |=
-                                               _MDFLD_PIPEC_EVENT_FLAG;
-               }
-       }
-/* NO I DONT WANT ANY IRQS GRRR FIXMEAC */
-       if (hw_islands & OSPM_GRAPHICS_ISLAND)
-               dev_priv->vdc_irq_mask |= _PSB_IRQ_SGX_FLAG;
-/* */
+       if (gma_power_is_on(dev))
+               PSB_WVDC32(0xFFFFFFFF, PSB_HWSTAM);
+       if (dev->vblank_enabled[0])
+               dev_priv->vdc_irq_mask |= _PSB_PIPEA_EVENT_FLAG;
+       if (dev->vblank_enabled[1])
+               dev_priv->vdc_irq_mask |= _MDFLD_PIPEB_EVENT_FLAG;
+       if (dev->vblank_enabled[2])
+               dev_priv->vdc_irq_mask |= _MDFLD_PIPEC_EVENT_FLAG;
+
        /*This register is safe even if display island is off*/
        PSB_WVDC32(~dev_priv->vdc_irq_mask, PSB_INT_MASK_R);
-
        spin_unlock_irqrestore(&dev_priv->irqmask_lock, irqflags);
 }
 
 int psb_irq_postinstall(struct drm_device *dev)
 {
-       return psb_irq_postinstall_islands(dev, OSPM_ALL_ISLANDS);
-}
-
-int psb_irq_postinstall_islands(struct drm_device *dev, int hw_islands)
-{
-
        struct drm_psb_private *dev_priv =
            (struct drm_psb_private *) dev->dev_private;
        unsigned long irqflags;
@@ -327,47 +297,30 @@ int psb_irq_postinstall_islands(struct drm_device *dev, int hw_islands)
 
        spin_lock_irqsave(&dev_priv->irqmask_lock, irqflags);
 
-       /*This register is safe even if display island is off*/
+       /* This register is safe even if display island is off */
        PSB_WVDC32(dev_priv->vdc_irq_mask, PSB_INT_ENABLE_R);
+       PSB_WVDC32(0xFFFFFFFF, PSB_HWSTAM);
 
-       if (hw_islands & OSPM_DISPLAY_ISLAND) {
-               if (true/*powermgmt_is_hw_on(dev->pdev, PSB_DISPLAY_ISLAND)*/) {
-                       PSB_WVDC32(0xFFFFFFFF, PSB_HWSTAM);
-
-                       if (dev->vblank_enabled[0])
-                               psb_enable_pipestat(dev_priv, 0,
-                                   PIPE_VBLANK_INTERRUPT_ENABLE);
-                       else
-                               psb_disable_pipestat(dev_priv, 0,
-                                   PIPE_VBLANK_INTERRUPT_ENABLE);
-
-                       if (dev->vblank_enabled[1])
-                                       psb_enable_pipestat(dev_priv, 1,
-                                           PIPE_VBLANK_INTERRUPT_ENABLE);
-                       else
-                               psb_disable_pipestat(dev_priv, 1,
-                                   PIPE_VBLANK_INTERRUPT_ENABLE);
-
-                       if (dev->vblank_enabled[2])
-                               psb_enable_pipestat(dev_priv, 2,
-                                   PIPE_VBLANK_INTERRUPT_ENABLE);
-                       else
-                               psb_disable_pipestat(dev_priv, 2,
-                                   PIPE_VBLANK_INTERRUPT_ENABLE);
-               }
-       }
+       if (dev->vblank_enabled[0])
+               psb_enable_pipestat(dev_priv, 0, PIPE_VBLANK_INTERRUPT_ENABLE);
+       else
+               psb_disable_pipestat(dev_priv, 0, PIPE_VBLANK_INTERRUPT_ENABLE);
 
-       spin_unlock_irqrestore(&dev_priv->irqmask_lock, irqflags);
+       if (dev->vblank_enabled[1])
+               psb_enable_pipestat(dev_priv, 1, PIPE_VBLANK_INTERRUPT_ENABLE);
+       else
+               psb_disable_pipestat(dev_priv, 1, PIPE_VBLANK_INTERRUPT_ENABLE);
 
+       if (dev->vblank_enabled[2])
+               psb_enable_pipestat(dev_priv, 2, PIPE_VBLANK_INTERRUPT_ENABLE);
+       else
+               psb_disable_pipestat(dev_priv, 2, PIPE_VBLANK_INTERRUPT_ENABLE);
+
+       spin_unlock_irqrestore(&dev_priv->irqmask_lock, irqflags);
        return 0;
 }
 
 void psb_irq_uninstall(struct drm_device *dev)
-{
-       psb_irq_uninstall_islands(dev, OSPM_ALL_ISLANDS);
-}
-
-void psb_irq_uninstall_islands(struct drm_device *dev, int hw_islands)
 {
        struct drm_psb_private *dev_priv =
            (struct drm_psb_private *) dev->dev_private;
@@ -377,39 +330,29 @@ void psb_irq_uninstall_islands(struct drm_device *dev, int hw_islands)
 
        spin_lock_irqsave(&dev_priv->irqmask_lock, irqflags);
 
-       if (hw_islands & OSPM_DISPLAY_ISLAND) {
-               if (true/*powermgmt_is_hw_on(dev->pdev, PSB_DISPLAY_ISLAND)*/) {
-                       PSB_WVDC32(0xFFFFFFFF, PSB_HWSTAM);
+       PSB_WVDC32(0xFFFFFFFF, PSB_HWSTAM);
 
-                       if (dev->vblank_enabled[0])
-                               psb_disable_pipestat(dev_priv, 0,
-                                   PIPE_VBLANK_INTERRUPT_ENABLE);
+       if (dev->vblank_enabled[0])
+               psb_disable_pipestat(dev_priv, 0, PIPE_VBLANK_INTERRUPT_ENABLE);
 
-                       if (dev->vblank_enabled[1])
-                               psb_disable_pipestat(dev_priv, 1,
-                                   PIPE_VBLANK_INTERRUPT_ENABLE);
+       if (dev->vblank_enabled[1])
+               psb_disable_pipestat(dev_priv, 1, PIPE_VBLANK_INTERRUPT_ENABLE);
 
-                       if (dev->vblank_enabled[2])
-                               psb_disable_pipestat(dev_priv, 2,
-                                   PIPE_VBLANK_INTERRUPT_ENABLE);
-               }
-               dev_priv->vdc_irq_mask &= _PSB_IRQ_SGX_FLAG |
-                                         _PSB_IRQ_MSVDX_FLAG |
-                                         _LNC_IRQ_TOPAZ_FLAG;
-       }
-       /*TODO: remove following code*/
-       if (hw_islands & OSPM_GRAPHICS_ISLAND)
-               dev_priv->vdc_irq_mask &= ~_PSB_IRQ_SGX_FLAG;
+       if (dev->vblank_enabled[2])
+               psb_disable_pipestat(dev_priv, 2, PIPE_VBLANK_INTERRUPT_ENABLE);
+
+       dev_priv->vdc_irq_mask &= _PSB_IRQ_SGX_FLAG |
+                                 _PSB_IRQ_MSVDX_FLAG |
+                                 _LNC_IRQ_TOPAZ_FLAG;
 
-       /*These two registers are safe even if display island is off*/
+       /* These two registers are safe even if display island is off */
        PSB_WVDC32(~dev_priv->vdc_irq_mask, PSB_INT_MASK_R);
        PSB_WVDC32(dev_priv->vdc_irq_mask, PSB_INT_ENABLE_R);
 
        wmb();
 
-       /*This register is safe even if display island is off*/
+       /* This register is safe even if display island is off */
        PSB_WVDC32(PSB_RVDC32(PSB_INT_IDENTITY_R), PSB_INT_IDENTITY_R);
-
        spin_unlock_irqrestore(&dev_priv->irqmask_lock, irqflags);
 }
 
@@ -420,8 +363,7 @@ void psb_irq_turn_on_dpst(struct drm_device *dev)
        u32 hist_reg;
        u32 pwm_reg;
 
-       if (ospm_power_using_hw_begin(OSPM_DISPLAY_ISLAND,
-                                                       OSPM_UHB_ONLY_IF_ON)) {
+       if (gma_power_begin(dev, false)) {
                PSB_WVDC32(1 << 31, HISTOGRAM_LOGIC_CONTROL);
                hist_reg = PSB_RVDC32(HISTOGRAM_LOGIC_CONTROL);
                PSB_WVDC32(1 << 31, HISTOGRAM_INT_CONTROL);
@@ -443,7 +385,7 @@ void psb_irq_turn_on_dpst(struct drm_device *dev)
                PSB_WVDC32(pwm_reg | 0x80010100 | PWM_PHASEIN_ENABLE,
                                                        PWM_CONTROL_LOGIC);
 
-               ospm_power_using_hw_end(OSPM_DISPLAY_ISLAND);
+               gma_power_end(dev);
        }
 }
 
@@ -472,8 +414,7 @@ void psb_irq_turn_off_dpst(struct drm_device *dev)
        u32 hist_reg;
        u32 pwm_reg;
 
-       if (ospm_power_using_hw_begin(OSPM_DISPLAY_ISLAND,
-                                                       OSPM_UHB_ONLY_IF_ON)) {
+       if (gma_power_begin(dev, false)) {
                PSB_WVDC32(0x00000000, HISTOGRAM_INT_CONTROL);
                hist_reg = PSB_RVDC32(HISTOGRAM_INT_CONTROL);
 
@@ -484,7 +425,7 @@ void psb_irq_turn_off_dpst(struct drm_device *dev)
                                                        PWM_CONTROL_LOGIC);
                pwm_reg = PSB_RVDC32(PWM_CONTROL_LOGIC);
 
-               ospm_power_using_hw_end(OSPM_DISPLAY_ISLAND);
+               gma_power_end(dev);
        }
 }
 
@@ -526,18 +467,16 @@ static int psb_vblank_do_wait(struct drm_device *dev,
  */
 int psb_enable_vblank(struct drm_device *dev, int pipe)
 {
-       struct drm_psb_private *dev_priv =
-           (struct drm_psb_private *) dev->dev_private;
+       struct drm_psb_private *dev_priv = dev->dev_private;
        unsigned long irqflags;
        uint32_t reg_val = 0;
        uint32_t pipeconf_reg = mid_pipeconf(pipe);
 
        PSB_DEBUG_ENTRY("\n");
 
-       if (ospm_power_using_hw_begin(OSPM_DISPLAY_ISLAND,
-                                                       OSPM_UHB_ONLY_IF_ON)) {
+       if (gma_power_begin(dev, false)) {
                reg_val = REG_READ(pipeconf_reg);
-               ospm_power_using_hw_end(OSPM_DISPLAY_ISLAND);
+               gma_power_end(dev);
        }
 
        if (!(reg_val & PIPEACONF_ENABLE))
@@ -545,7 +484,6 @@ int psb_enable_vblank(struct drm_device *dev, int pipe)
 
        spin_lock_irqsave(&dev_priv->irqmask_lock, irqflags);
 
-       drm_psb_disable_vsync = 0;
        mid_enable_pipe_event(dev_priv, pipe);
        psb_enable_pipestat(dev_priv, pipe, PIPE_VBLANK_INTERRUPT_ENABLE);
 
@@ -559,15 +497,13 @@ int psb_enable_vblank(struct drm_device *dev, int pipe)
  */
 void psb_disable_vblank(struct drm_device *dev, int pipe)
 {
-       struct drm_psb_private *dev_priv =
-           (struct drm_psb_private *) dev->dev_private;
+       struct drm_psb_private *dev_priv = dev->dev_private;
        unsigned long irqflags;
 
        PSB_DEBUG_ENTRY("\n");
 
        spin_lock_irqsave(&dev_priv->irqmask_lock, irqflags);
 
-       drm_psb_disable_vsync = 1;
        mid_disable_pipe_event(dev_priv, pipe);
        psb_disable_pipestat(dev_priv, pipe, PIPE_VBLANK_INTERRUPT_ENABLE);
 
@@ -603,7 +539,7 @@ u32 psb_get_vblank_counter(struct drm_device *dev, int pipe)
                return 0;
        }
 
-       if (!ospm_power_using_hw_begin(OSPM_DISPLAY_ISLAND, false))
+       if (!gma_power_begin(dev, false))
                return 0;
 
        reg_val = REG_READ(pipeconf_reg);
@@ -632,7 +568,7 @@ u32 psb_get_vblank_counter(struct drm_device *dev, int pipe)
 
 psb_get_vblank_counter_exit:
 
-       ospm_power_using_hw_end(OSPM_DISPLAY_ISLAND);
+       gma_power_end(dev);
 
        return count;
 }
index edd0d4923e0f993f6c02d525d650eeccf56b4c86..c904d73b1de3f99e9d391ccc0fd6a81d4635f104 100644 (file)
@@ -444,67 +444,6 @@ static inline void psb_mmu_invalidate_pte(struct psb_mmu_pt *pt,
        pt->v[psb_mmu_pt_index(addr)] = pt->pd->invalid_pte;
 }
 
-#if 0
-static uint32_t psb_mmu_check_pte_locked(struct psb_mmu_pd *pd,
-                                        uint32_t mmu_offset)
-{
-       uint32_t *v;
-       uint32_t pfn;
-
-       v = kmap_atomic(pd->p, KM_USER0);
-       if (!v) {
-               printk(KERN_INFO "Could not kmap pde page.\n");
-               return 0;
-       }
-       pfn = v[psb_mmu_pd_index(mmu_offset)];
-       /*      printk(KERN_INFO "pde is 0x%08x\n",pfn); */
-       kunmap_atomic(v, KM_USER0);
-       if (((pfn & 0x0F) != PSB_PTE_VALID)) {
-               printk(KERN_INFO "Strange pde at 0x%08x: 0x%08x.\n",
-                      mmu_offset, pfn);
-       }
-       v = ioremap(pfn & 0xFFFFF000, 4096);
-       if (!v) {
-               printk(KERN_INFO "Could not kmap pte page.\n");
-               return 0;
-       }
-       pfn = v[psb_mmu_pt_index(mmu_offset)];
-       /* printk(KERN_INFO "pte is 0x%08x\n",pfn); */
-       iounmap(v);
-       if (((pfn & 0x0F) != PSB_PTE_VALID)) {
-               printk(KERN_INFO "Strange pte at 0x%08x: 0x%08x.\n",
-                      mmu_offset, pfn);
-       }
-       return pfn >> PAGE_SHIFT;
-}
-
-static void psb_mmu_check_mirrored_gtt(struct psb_mmu_pd *pd,
-                                      uint32_t mmu_offset,
-                                      uint32_t gtt_pages)
-{
-       uint32_t start;
-       uint32_t next;
-
-       printk(KERN_INFO "Checking mirrored gtt 0x%08x %d\n",
-              mmu_offset, gtt_pages);
-       down_read(&pd->driver->sem);
-       start = psb_mmu_check_pte_locked(pd, mmu_offset);
-       mmu_offset += PAGE_SIZE;
-       gtt_pages -= 1;
-       while (gtt_pages--) {
-               next = psb_mmu_check_pte_locked(pd, mmu_offset);
-               if (next != start + 1) {
-                       printk(KERN_INFO
-                              "Ptes out of order: 0x%08x, 0x%08x.\n",
-                              start, next);
-               }
-               start = next;
-               mmu_offset += PAGE_SIZE;
-       }
-       up_read(&pd->driver->sem);
-}
-
-#endif
 
 void psb_mmu_mirror_gtt(struct psb_mmu_pd *pd,
                        uint32_t mmu_offset, uint32_t gtt_start,
index 7deb1ba8254583a3187f72bd1511e19c32452034..1495415be6c7db6feb221b39a6bb8df061241ab8 100644 (file)
  * Authors:
  *    Benjamin Defnet <benjamin.r.defnet@intel.com>
  *    Rajesh Poornachandran <rajesh.poornachandran@intel.com>
- *
+ * Massively reworked
+ *    Alan Cox <alan@linux.intel.com>
  */
 #include "psb_powermgmt.h"
 #include "psb_drv.h"
+#include "psb_reg.h"
 #include "psb_intel_reg.h"
 #include <linux/mutex.h>
 #include <linux/pm_runtime.h>
 
-#undef OSPM_GFX_DPK
-
-extern u32 gui32SGXDeviceID;
-extern u32 gui32MRSTDisplayDeviceID;
-extern u32 gui32MRSTMSVDXDeviceID;
-extern u32 gui32MRSTTOPAZDeviceID;
-
-struct drm_device *gpDrmDevice = NULL;
 static struct mutex power_mutex;
-static bool gbSuspendInProgress = false;
-static bool gbResumeInProgress = false;
-static int g_hw_power_status_mask;
-static atomic_t g_display_access_count;
-static atomic_t g_graphics_access_count;
-static atomic_t g_videoenc_access_count;
-static atomic_t g_videodec_access_count;
-int allow_runtime_pm = 0;
-
-void ospm_power_island_up(int hw_islands);
-void ospm_power_island_down(int hw_islands);
-static bool gbSuspended = false;
-bool gbgfxsuspended = false;
 
-/*
- * ospm_power_init
+/**
+ *     gma_power_init          -       initialise power manager
+ *     @dev: our device
  *
- * Description: Initialize this ospm power management module
+ *     Set up for power management tracking of our hardware.
  */
-void ospm_power_init(struct drm_device *dev)
+void gma_power_init(struct drm_device *dev)
 {
-       struct drm_psb_private *dev_priv = (struct drm_psb_private *)dev->dev_private;
-
-       gpDrmDevice = dev;
+       struct drm_psb_private *dev_priv = dev->dev_private;
 
        dev_priv->apm_base = dev_priv->apm_reg & 0xffff;
        dev_priv->ospm_base &= 0xffff;
 
+       dev_priv->display_power = true; /* We start active */
+       dev_priv->display_count = 0;    /* Currently no users */
+       dev_priv->suspended = false;    /* And not suspended */
        mutex_init(&power_mutex);
-       g_hw_power_status_mask = OSPM_ALL_ISLANDS;
-       atomic_set(&g_display_access_count, 0);
-       atomic_set(&g_graphics_access_count, 0);
-       atomic_set(&g_videoenc_access_count, 0);
-       atomic_set(&g_videodec_access_count, 0);
+
+       if (!IS_MRST(dev)) {
+               /* FIXME: wants further review */
+               u32 gating = PSB_RSGX32(PSB_CR_CLKGATECTL);
+               /* Disable 2D clock gating */
+               gating &= ~3;
+               gating |= 1;
+               PSB_WSGX32(gating, PSB_CR_CLKGATECTL);
+               PSB_RSGX32(PSB_CR_CLKGATECTL);
+       }
 }
 
-/*
- * ospm_power_uninit
+/**
+ *     gma_power_uninit        -       end power manager
+ *     @dev: device to end for
  *
- * Description: Uninitialize this ospm power management module
+ *     Undo the effects of gma_power_init
  */
-void ospm_power_uninit(void)
+void gma_power_uninit(struct drm_device *dev)
 {
        mutex_destroy(&power_mutex);
-       pm_runtime_disable(&gpDrmDevice->pdev->dev);
-       pm_runtime_set_suspended(&gpDrmDevice->pdev->dev);
+       pm_runtime_disable(&dev->pdev->dev);
+       pm_runtime_set_suspended(&dev->pdev->dev);
 }
 
 
-/*
- * save_display_registers
+/**
+ *     save_display_registers  -       save registers lost on suspend
+ *     @dev: our DRM device
  *
- * Description: We are going to suspend so save current display
- * register state.
+ *     Save the state we need in order to be able to restore the interface
+ *     upon resume from suspend
  */
 static int save_display_registers(struct drm_device *dev)
 {
        struct drm_psb_private *dev_priv = dev->dev_private;
-       struct drm_crtc * crtc;
-       struct drm_connector * connector;
+       struct drm_crtc *crtc;
+       struct drm_connector *connector;
 
        /* Display arbitration control + watermarks */
        dev_priv->saveDSPARB = PSB_RVDC32(DSPARB);
@@ -112,37 +102,31 @@ static int save_display_registers(struct drm_device *dev)
        dev_priv->saveDSPFW6 = PSB_RVDC32(DSPFW6);
        dev_priv->saveCHICKENBIT = PSB_RVDC32(DSPCHICKENBIT);
 
-       /*save crtc and output state*/
+       /* Save crtc and output state */
        mutex_lock(&dev->mode_config.mutex);
        list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
-               if(drm_helper_crtc_in_use(crtc)) {
+               if (drm_helper_crtc_in_use(crtc))
                        crtc->funcs->save(crtc);
-               }
        }
 
-       list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
+       list_for_each_entry(connector, &dev->mode_config.connector_list, head)
                connector->funcs->save(connector);
-       }
-       mutex_unlock(&dev->mode_config.mutex);
-
-       /* Interrupt state */
-       /*
-        * Handled in psb_irq.c
-        */
 
+       mutex_unlock(&dev->mode_config.mutex);
        return 0;
 }
 
-/*
- * restore_display_registers
+/**
+ *     restore_display_registers       -       restore lost register state
+ *     @dev: our DRM device
  *
- * Description: We are going to resume so restore display register state.
+ *     Restore register state that was lost during suspend and resume.
  */
 static int restore_display_registers(struct drm_device *dev)
 {
        struct drm_psb_private *dev_priv = dev->dev_private;
-       struct drm_crtc * crtc;
-       struct drm_connector * connector;
+       struct drm_crtc *crtc;
+       struct drm_connector *connector;
 
        /* Display arbitration + watermarks */
        PSB_WVDC32(dev_priv->saveDSPARB, DSPARB);
@@ -158,39 +142,57 @@ static int restore_display_registers(struct drm_device *dev)
        PSB_WVDC32(0x80000000, VGACNTRL);
 
        mutex_lock(&dev->mode_config.mutex);
-       list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
-               if(drm_helper_crtc_in_use(crtc))
+       list_for_each_entry(crtc, &dev->mode_config.crtc_list, head)
+               if (drm_helper_crtc_in_use(crtc))
                        crtc->funcs->restore(crtc);
-       }
-       list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
-               connector->funcs->restore(connector);
-       }
-       mutex_unlock(&dev->mode_config.mutex);
 
-       /*Interrupt state*/
-       /*
-        * Handled in psb_irq.c
-        */
+       list_for_each_entry(connector, &dev->mode_config.connector_list, head)
+               connector->funcs->restore(connector);
 
+       mutex_unlock(&dev->mode_config.mutex);
        return 0;
 }
-/*
- * powermgmt_suspend_display
+
+/**
+ *     power_down      -       power down the display island
+ *     @dev: our DRM device
  *
- * Description: Suspend the display hardware saving state and disabling
- * as necessary.
+ *     Power down the display interface of our device
  */
-void ospm_suspend_display(struct drm_device *dev)
+static void power_down(struct drm_device *dev)
 {
        struct drm_psb_private *dev_priv = dev->dev_private;
-       int pp_stat, ret=0;
+       u32 pwr_mask ;
+       u32 pwr_sts;
 
-       printk(KERN_ALERT "%s \n", __func__);
+       if (IS_MRST(dev)) {
+               pwr_mask = PSB_PWRGT_DISPLAY_MASK;
+               outl(pwr_mask, dev_priv->ospm_base + PSB_PM_SSC);
 
-#ifdef OSPM_GFX_DPK
-       printk(KERN_ALERT "%s \n", __func__);
-#endif
-       if (!(g_hw_power_status_mask & OSPM_DISPLAY_ISLAND))
+               while (true) {
+                       pwr_sts = inl(dev_priv->ospm_base + PSB_PM_SSS);
+                       if ((pwr_sts & pwr_mask) == pwr_mask)
+                               break;
+                       else
+                               udelay(10);
+               }
+               dev_priv->display_power = false;
+       }
+}
+
+
+/**
+ *     gma_suspend_display     -       suspend the display logic
+ *     @dev: our DRM device
+ *
+ *     Suspend the display logic of the graphics interface
+ */
+static void gma_suspend_display(struct drm_device *dev)
+{
+       struct drm_psb_private *dev_priv = dev->dev_private;
+       int pp_stat;
+
+       if (dev_priv->suspended)
                return;
 
        save_display_registers(dev);
@@ -225,37 +227,58 @@ void ospm_suspend_display(struct drm_device *dev)
                        != DPI_FIFO_EMPTY);
                PSB_WVDC32(0, DEVICE_READY_REG);
                        /* turn off panel power */
-               ret = 0;
        }
-       ospm_power_island_down(OSPM_DISPLAY_ISLAND);
+       power_down(dev);
 }
 
 /*
- * ospm_resume_display
+ * power_up
  *
- * Description: Resume the display hardware restoring state and enabling
- * as necessary.
+ * Description: Restore power to the specified island(s) (powergating)
  */
-void ospm_resume_display(struct pci_dev *pdev)
+static void power_up(struct drm_device *dev)
 {
-       struct drm_device *dev = pci_get_drvdata(pdev);
        struct drm_psb_private *dev_priv = dev->dev_private;
-       struct psb_gtt *pg = dev_priv->pg;
+       u32 pwr_mask = PSB_PWRGT_DISPLAY_MASK;
+       u32 pwr_sts, pwr_cnt;
 
-       printk(KERN_ALERT "%s \n", __func__);
+       if (IS_MRST(dev)) {
+               pwr_cnt = inl(dev_priv->ospm_base + PSB_PM_SSC);
+               pwr_cnt &= ~pwr_mask;
+               outl(pwr_cnt, (dev_priv->ospm_base + PSB_PM_SSC));
 
-#ifdef OSPM_GFX_DPK
-       printk(KERN_ALERT "%s \n", __func__);
-#endif
-       if (g_hw_power_status_mask & OSPM_DISPLAY_ISLAND)
+               while (true) {
+                       pwr_sts = inl(dev_priv->ospm_base + PSB_PM_SSS);
+                       if ((pwr_sts & pwr_mask) == 0)
+                               break;
+                       else
+                               udelay(10);
+               }
+       }
+       dev_priv->suspended = false;
+       dev_priv->display_power = true;
+}
+
+/**
+ *     gma_resume_display      -       resume display side logic
+ *
+ *     Resume the display hardware restoring state and enabling
+ *     as necessary.
+ */
+static void gma_resume_display(struct pci_dev *pdev)
+{
+       struct drm_device *dev = pci_get_drvdata(pdev);
+       struct drm_psb_private *dev_priv = dev->dev_private;
+
+       if (dev_priv->suspended == false)
                return;
 
        /* turn on the display power island */
-       ospm_power_island_up(OSPM_DISPLAY_ISLAND);
+       power_up(dev);
 
-       PSB_WVDC32(pg->pge_ctl | _PSB_PGETBL_ENABLED, PSB_PGETBL_CTL);
+       PSB_WVDC32(dev_priv->pge_ctl | _PSB_PGETBL_ENABLED, PSB_PGETBL_CTL);
        pci_write_config_word(pdev, PSB_GMCH_CTRL,
-                       pg->gmch_ctrl | _PSB_GMCH_ENABLED);
+                       dev_priv->gmch_ctrl | _PSB_GMCH_ENABLED);
 
        /* Don't reinitialize the GTT as it is unnecessary.  The gtt is
         * stored in memory so it will automatically be restored.  All
@@ -267,26 +290,21 @@ void ospm_resume_display(struct pci_dev *pdev)
        restore_display_registers(dev);
 }
 
-#if 1
-/*
- * ospm_suspend_pci
+/**
+ *     gma_suspend_pci         -       suspend PCI side
+ *     @pdev: PCI device
  *
- * Description: Suspend the pci device saving state and disabling
- * as necessary.
+ *     Perform the suspend processing on our PCI device state
  */
-static void ospm_suspend_pci(struct pci_dev *pdev)
+static void gma_suspend_pci(struct pci_dev *pdev)
 {
        struct drm_device *dev = pci_get_drvdata(pdev);
        struct drm_psb_private *dev_priv = dev->dev_private;
        int bsm, vbt;
 
-       if (gbSuspended)
+       if (dev_priv->suspended)
                return;
 
-#ifdef OSPM_GFX_DPK
-       printk(KERN_ALERT "ospm_suspend_pci\n");
-#endif
-
        pci_save_state(pdev);
        pci_read_config_dword(pdev, 0x5C, &bsm);
        dev_priv->saveBSM = bsm;
@@ -298,29 +316,25 @@ static void ospm_suspend_pci(struct pci_dev *pdev)
        pci_disable_device(pdev);
        pci_set_power_state(pdev, PCI_D3hot);
 
-       gbSuspended = true;
-       gbgfxsuspended = true;
+       dev_priv->suspended = true;
 }
 
-/*
- * ospm_resume_pci
+/**
+ *     gma_resume_pci          -       resume helper
+ *     @dev: our PCI device
  *
- * Description: Resume the pci device restoring state and enabling
- * as necessary.
+ *     Perform the resume processing on our PCI device state - rewrite
+ *     register state and re-enable the PCI device
  */
-static bool ospm_resume_pci(struct pci_dev *pdev)
+static bool gma_resume_pci(struct pci_dev *pdev)
 {
        struct drm_device *dev = pci_get_drvdata(pdev);
        struct drm_psb_private *dev_priv = dev->dev_private;
-       int ret = 0;
+       int ret;
 
-       if (!gbSuspended)
+       if (!dev_priv->suspended)
                return true;
 
-#ifdef OSPM_GFX_DPK
-       printk(KERN_ALERT "ospm_resume_pci\n");
-#endif
-
        pci_set_power_state(pdev, PCI_D0);
        pci_restore_state(pdev);
        pci_write_config_dword(pdev, 0x5c, dev_priv->saveBSM);
@@ -331,448 +345,131 @@ static bool ospm_resume_pci(struct pci_dev *pdev)
        ret = pci_enable_device(pdev);
 
        if (ret != 0)
-               printk(KERN_ALERT "ospm_resume_pci: pci_enable_device failed: %d\n", ret);
+               dev_err(&pdev->dev, "pci_enable failed: %d\n", ret);
        else
-               gbSuspended = false;
-
-       return !gbSuspended;
-}
-#endif
-/*
- * ospm_power_suspend
- *
- * Description: OSPM is telling our driver to suspend so save state
- * and power down all hardware.
- */
-int ospm_power_suspend(struct pci_dev *pdev, pm_message_t state)
-{
-        int ret = 0;
-        int graphics_access_count;
-        int videoenc_access_count;
-        int videodec_access_count;
-        int display_access_count;
-       bool suspend_pci = true;
-
-       if(gbSuspendInProgress || gbResumeInProgress)
-        {
-#ifdef OSPM_GFX_DPK
-                printk(KERN_ALERT "OSPM_GFX_DPK: %s system BUSY \n", __func__);
-#endif
-                return  -EBUSY;
-        }
-
-        mutex_lock(&power_mutex);
-
-        if (!gbSuspended) {
-                graphics_access_count = atomic_read(&g_graphics_access_count);
-                videoenc_access_count = atomic_read(&g_videoenc_access_count);
-                videodec_access_count = atomic_read(&g_videodec_access_count);
-                display_access_count = atomic_read(&g_display_access_count);
-
-                if (graphics_access_count ||
-                       videoenc_access_count ||
-                       videodec_access_count ||
-                       display_access_count)
-                        ret = -EBUSY;
-
-                if (!ret) {
-                        gbSuspendInProgress = true;
-
-                        psb_irq_uninstall_islands(gpDrmDevice, OSPM_DISPLAY_ISLAND);
-                        ospm_suspend_display(gpDrmDevice);
-                        if (suspend_pci == true) {
-                               ospm_suspend_pci(pdev);
-                        }
-                        gbSuspendInProgress = false;
-                } else {
-                        printk(KERN_ALERT "ospm_power_suspend: device busy: graphics %d videoenc %d videodec %d display %d\n", graphics_access_count, videoenc_access_count, videodec_access_count, display_access_count);
-                }
-        }
-
-
-        mutex_unlock(&power_mutex);
-        return ret;
+               dev_priv->suspended = false;
+       return !dev_priv->suspended;
 }
 
-/*
- * ospm_power_island_up
+/**
+ *     gma_power_suspend               -       bus callback for suspend
+ *     @pdev: our PCI device
+ *     @state: suspend type
  *
- * Description: Restore power to the specified island(s) (powergating)
+ *     Called back by the PCI layer during a suspend of the system. We
+ *     perform the necessary shut down steps and save enough state that
+ *     we can undo this when resume is called.
  */
-void ospm_power_island_up(int hw_islands)
+int gma_power_suspend(struct pci_dev *pdev, pm_message_t state)
 {
-       u32 pwr_cnt = 0;
-       u32 pwr_sts = 0;
-       u32 pwr_mask = 0;
-
-       struct drm_psb_private *dev_priv =
-               (struct drm_psb_private *) gpDrmDevice->dev_private;
-
-
-       if (hw_islands & OSPM_DISPLAY_ISLAND) {
-               pwr_mask = PSB_PWRGT_DISPLAY_MASK;
-
-               pwr_cnt = inl(dev_priv->ospm_base + PSB_PM_SSC);
-               pwr_cnt &= ~pwr_mask;
-               outl(pwr_cnt, (dev_priv->ospm_base + PSB_PM_SSC));
+       struct drm_device *dev = pci_get_drvdata(pdev);
+       struct drm_psb_private *dev_priv = dev->dev_private;
 
-               while (true) {
-                       pwr_sts = inl(dev_priv->ospm_base + PSB_PM_SSS);
-                       if ((pwr_sts & pwr_mask) == 0)
-                               break;
-                       else
-                               udelay(10);
+       mutex_lock(&power_mutex);
+       if (!dev_priv->suspended) {
+               if (dev_priv->display_count) {
+                       mutex_unlock(&power_mutex);
+                       return -EBUSY;
                }
+               psb_irq_uninstall(dev);
+               gma_suspend_display(dev);
+               gma_suspend_pci(pdev);
        }
-
-       g_hw_power_status_mask |= hw_islands;
-}
-
-/*
- * ospm_power_resume
- */
-int ospm_power_resume(struct pci_dev *pdev)
-{
-       if(gbSuspendInProgress || gbResumeInProgress)
-        {
-#ifdef OSPM_GFX_DPK
-                printk(KERN_ALERT "OSPM_GFX_DPK: %s hw_island: Suspend || gbResumeInProgress!!!! \n", __func__);
-#endif
-                return 0;
-        }
-
-        mutex_lock(&power_mutex);
-
-#ifdef OSPM_GFX_DPK
-       printk(KERN_ALERT "OSPM_GFX_DPK: ospm_power_resume \n");
-#endif
-
-       gbResumeInProgress = true;
-
-        ospm_resume_pci(pdev);
-
-       ospm_resume_display(gpDrmDevice->pdev);
-        psb_irq_preinstall_islands(gpDrmDevice, OSPM_DISPLAY_ISLAND);
-        psb_irq_postinstall_islands(gpDrmDevice, OSPM_DISPLAY_ISLAND);
-
-       gbResumeInProgress = false;
-
-        mutex_unlock(&power_mutex);
-
+       mutex_unlock(&power_mutex);
        return 0;
 }
 
 
-/*
- * ospm_power_island_down
+/**
+ *     gma_power_resume                -       resume power
+ *     @pdev: PCI device
  *
- * Description: Cut power to the specified island(s) (powergating)
+ *     Resume the PCI side of the graphics and then the displays
  */
-void ospm_power_island_down(int islands)
+int gma_power_resume(struct pci_dev *pdev)
 {
-#if 0
-       u32 pwr_cnt = 0;
-       u32 pwr_mask = 0;
-       u32 pwr_sts = 0;
-
-       struct drm_psb_private *dev_priv =
-               (struct drm_psb_private *) gpDrmDevice->dev_private;
-
-       g_hw_power_status_mask &= ~islands;
-
-       if (islands & OSPM_GRAPHICS_ISLAND) {
-               pwr_cnt |= PSB_PWRGT_GFX_MASK;
-               pwr_mask |= PSB_PWRGT_GFX_MASK;
-               if (dev_priv->graphics_state == PSB_PWR_STATE_ON) {
-                       dev_priv->gfx_on_time += (jiffies - dev_priv->gfx_last_mode_change) * 1000 / HZ;
-                       dev_priv->gfx_last_mode_change = jiffies;
-                       dev_priv->graphics_state = PSB_PWR_STATE_OFF;
-                       dev_priv->gfx_off_cnt++;
-               }
-       }
-       if (islands & OSPM_VIDEO_ENC_ISLAND) {
-               pwr_cnt |= PSB_PWRGT_VID_ENC_MASK;
-               pwr_mask |= PSB_PWRGT_VID_ENC_MASK;
-       }
-       if (islands & OSPM_VIDEO_DEC_ISLAND) {
-               pwr_cnt |= PSB_PWRGT_VID_DEC_MASK;
-               pwr_mask |= PSB_PWRGT_VID_DEC_MASK;
-       }
-       if (pwr_cnt) {
-               pwr_cnt |= inl(dev_priv->apm_base);
-               outl(pwr_cnt, dev_priv->apm_base  + PSB_APM_CMD);
-               while (true) {
-                       pwr_sts = inl(dev_priv->apm_base + PSB_APM_STS);
-
-                       if ((pwr_sts & pwr_mask) == pwr_mask)
-                               break;
-                       else
-                               udelay(10);
-               }
-       }
-
-       if (islands & OSPM_DISPLAY_ISLAND) {
-               pwr_mask = PSB_PWRGT_DISPLAY_MASK;
-
-               outl(pwr_mask, (dev_priv->ospm_base + PSB_PM_SSC));
+       struct drm_device *dev = pci_get_drvdata(pdev);
 
-               while (true) {
-                       pwr_sts = inl(dev_priv->ospm_base + PSB_PM_SSS);
-                       if ((pwr_sts & pwr_mask) == pwr_mask)
-                               break;
-                       else
-                               udelay(10);
-               }
-       }
-#endif
+       mutex_lock(&power_mutex);
+       gma_resume_pci(pdev);
+       gma_resume_display(pdev);
+       psb_irq_preinstall(dev);
+       psb_irq_postinstall(dev);
+       mutex_unlock(&power_mutex);
+       return 0;
 }
 
 
-/*
- * ospm_power_is_hw_on
+
+/**
+ *     gma_power_is_on         -       returne true if power is on
+ *     @dev: our DRM device
  *
- * Description: do an instantaneous check for if the specified islands
- * are on.  Only use this in cases where you know the g_state_change_mutex
- * is already held such as in irq install/uninstall.  Otherwise, use
- * ospm_power_using_hw_begin().
+ *     Returns true if the display island power is on at this moment
  */
-bool ospm_power_is_hw_on(int hw_islands)
+bool gma_power_is_on(struct drm_device *dev)
 {
-       return ((g_hw_power_status_mask & hw_islands) == hw_islands) ? true:false;
+       struct drm_psb_private *dev_priv = dev->dev_private;
+       return dev_priv->display_power;
 }
 
-/*
- * ospm_power_using_hw_begin
+
+/**
+ *     gma_power_begin         -       begin requiring power
+ *     @dev: our DRM device
+ *     @force_on: true to force power on
  *
- * Description: Notify PowerMgmt module that you will be accessing the
- * specified island's hw so don't power it off.  If force_on is true,
- * this will power on the specified island if it is off.
- * Otherwise, this will return false and the caller is expected to not
- * access the hw.
+ *     Begin an action that requires the display power island is enabled.
+ *     We refcount the islands.
  *
- * NOTE *** If this is called from and interrupt handler or other atomic
- * context, then it will return false if we are in the middle of a
- * power state transition and the caller will be expected to handle that
- * even if force_on is set to true.
+ *     FIXME: locking
  */
-bool ospm_power_using_hw_begin(int hw_island, UHBUsage usage)
+bool gma_power_begin(struct drm_device *dev, bool force_on)
 {
-        return 1;      /*FIXMEAC */
-#if 0
-       bool ret = true;
-       bool island_is_off = false;
-       bool b_atomic = (in_interrupt() || in_atomic());
-       bool locked = true;
-       struct pci_dev *pdev = gpDrmDevice->pdev;
-       u32 deviceID = 0;
-       bool force_on = usage ? true: false;
-       /*quick path, not 100% race safe, but should be enough comapre to current other code in this file */
-       if (!force_on) {
-               if (hw_island & (OSPM_ALL_ISLANDS & ~g_hw_power_status_mask))
-                       return false;
-               else {
-                       locked = false;
-#ifdef CONFIG_PM_RUNTIME
-                       /* increment pm_runtime_refcount */
-                       pm_runtime_get(&pdev->dev);
-#endif
-                       goto increase_count;
-               }
-       }
-
-
-       if (!b_atomic)
-               mutex_lock(&power_mutex);
-
-       island_is_off = hw_island & (OSPM_ALL_ISLANDS & ~g_hw_power_status_mask);
-
-       if (b_atomic && (gbSuspendInProgress || gbResumeInProgress || gbSuspended) && force_on && island_is_off)
-               ret = false;
-
-       if (ret && island_is_off && !force_on)
-               ret = false;
-
-       if (ret && island_is_off && force_on) {
-               gbResumeInProgress = true;
-
-               ret = ospm_resume_pci(pdev);
-
-               if (ret) {
-                       switch(hw_island)
-                       {
-                       case OSPM_DISPLAY_ISLAND:
-                               deviceID = gui32MRSTDisplayDeviceID;
-                               ospm_resume_display(pdev);
-                               psb_irq_preinstall_islands(gpDrmDevice, OSPM_DISPLAY_ISLAND);
-                               psb_irq_postinstall_islands(gpDrmDevice, OSPM_DISPLAY_ISLAND);
-                               break;
-                       case OSPM_GRAPHICS_ISLAND:
-                               deviceID = gui32SGXDeviceID;
-                               ospm_power_island_up(OSPM_GRAPHICS_ISLAND);
-                               psb_irq_preinstall_islands(gpDrmDevice, OSPM_GRAPHICS_ISLAND);
-                               psb_irq_postinstall_islands(gpDrmDevice, OSPM_GRAPHICS_ISLAND);
-                               break;
-#if 1
-                       case OSPM_VIDEO_DEC_ISLAND:
-                               if(!ospm_power_is_hw_on(OSPM_DISPLAY_ISLAND)) {
-                                       //printk(KERN_ALERT "%s power on display for video decode use\n", __func__);
-                                       deviceID = gui32MRSTDisplayDeviceID;
-                                       ospm_resume_display(pdev);
-                                       psb_irq_preinstall_islands(gpDrmDevice, OSPM_DISPLAY_ISLAND);
-                                       psb_irq_postinstall_islands(gpDrmDevice, OSPM_DISPLAY_ISLAND);
-                               }
-                               else{
-                                       //printk(KERN_ALERT "%s display is already on for video decode use\n", __func__);
-                               }
-
-                               if(!ospm_power_is_hw_on(OSPM_VIDEO_DEC_ISLAND)) {
-                                       //printk(KERN_ALERT "%s power on video decode\n", __func__);
-                                       deviceID = gui32MRSTMSVDXDeviceID;
-                                       ospm_power_island_up(OSPM_VIDEO_DEC_ISLAND);
-                                       psb_irq_preinstall_islands(gpDrmDevice, OSPM_VIDEO_DEC_ISLAND);
-                                       psb_irq_postinstall_islands(gpDrmDevice, OSPM_VIDEO_DEC_ISLAND);
-                               }
-                               else{
-                                       //printk(KERN_ALERT "%s video decode is already on\n", __func__);
-                               }
-
-                               break;
-                       case OSPM_VIDEO_ENC_ISLAND:
-                               if(!ospm_power_is_hw_on(OSPM_DISPLAY_ISLAND)) {
-                                       //printk(KERN_ALERT "%s power on display for video encode\n", __func__);
-                                       deviceID = gui32MRSTDisplayDeviceID;
-                                       ospm_resume_display(pdev);
-                                       psb_irq_preinstall_islands(gpDrmDevice, OSPM_DISPLAY_ISLAND);
-                                       psb_irq_postinstall_islands(gpDrmDevice, OSPM_DISPLAY_ISLAND);
-                               }
-                               else{
-                                       //printk(KERN_ALERT "%s display is already on for video encode use\n", __func__);
-                               }
-
-                               if(!ospm_power_is_hw_on(OSPM_VIDEO_ENC_ISLAND)) {
-                                       //printk(KERN_ALERT "%s power on video encode\n", __func__);
-                                       deviceID = gui32MRSTTOPAZDeviceID;
-                                       ospm_power_island_up(OSPM_VIDEO_ENC_ISLAND);
-                                       psb_irq_preinstall_islands(gpDrmDevice, OSPM_VIDEO_ENC_ISLAND);
-                                       psb_irq_postinstall_islands(gpDrmDevice, OSPM_VIDEO_ENC_ISLAND);
-                               }
-                               else{
-                                       //printk(KERN_ALERT "%s video decode is already on\n", __func__);
-                               }
-#endif
-                               break;
-
-                       default:
-                               printk(KERN_ALERT "%s unknown island !!!! \n", __func__);
-                               break;
-                       }
-
-               }
-
-               if (!ret)
-                       printk(KERN_ALERT "ospm_power_using_hw_begin: forcing on %d failed\n", hw_island);
+       struct drm_psb_private *dev_priv = dev->dev_private;
+       int ret;
 
-               gbResumeInProgress = false;
+       /* Power already on ? */
+       if (dev_priv->display_power) {
+               dev_priv->display_count++;
+               pm_runtime_get(&dev->pdev->dev);
+               return true;
        }
-increase_count:
-       if (ret) {
-               switch(hw_island)
-               {
-               case OSPM_GRAPHICS_ISLAND:
-                       atomic_inc(&g_graphics_access_count);
-                       break;
-               case OSPM_VIDEO_ENC_ISLAND:
-                       atomic_inc(&g_videoenc_access_count);
-                       break;
-               case OSPM_VIDEO_DEC_ISLAND:
-                       atomic_inc(&g_videodec_access_count);
-                       break;
-               case OSPM_DISPLAY_ISLAND:
-                       atomic_inc(&g_display_access_count);
-                       break;
-               }
+       if (force_on == false)
+               return false;
+
+       /* Ok power up needed */
+       ret = gma_resume_pci(dev->pdev);
+       if (ret == 0) {
+               psb_irq_preinstall(dev);
+               psb_irq_postinstall(dev);
+               pm_runtime_get(&dev->pdev->dev);
+               dev_priv->display_count++;
+               return true;
        }
-
-       if (!b_atomic && locked)
-               mutex_unlock(&power_mutex);
-
-       return ret;
-#endif
+       return false;
 }
 
 
-/*
- * ospm_power_using_hw_end
+/**
+ *     gma_power_end           -       end use of power
+ *     @dev: Our DRM device
  *
- * Description: Notify PowerMgmt module that you are done accessing the
- * specified island's hw so feel free to power it off.  Note that this
- * function doesn't actually power off the islands.
+ *     Indicate that one of our gma_power_begin() requested periods when
+ *     the diplay island power is needed has completed.
  */
-void ospm_power_using_hw_end(int hw_island)
-{
-#if 0 /* FIXMEAC */
-       switch(hw_island)
-       {
-       case OSPM_GRAPHICS_ISLAND:
-               atomic_dec(&g_graphics_access_count);
-               break;
-       case OSPM_VIDEO_ENC_ISLAND:
-               atomic_dec(&g_videoenc_access_count);
-               break;
-       case OSPM_VIDEO_DEC_ISLAND:
-               atomic_dec(&g_videodec_access_count);
-               break;
-       case OSPM_DISPLAY_ISLAND:
-               atomic_dec(&g_display_access_count);
-               break;
-       }
-
-       //decrement runtime pm ref count
-       pm_runtime_put(&gpDrmDevice->pdev->dev);
-
-       WARN_ON(atomic_read(&g_graphics_access_count) < 0);
-       WARN_ON(atomic_read(&g_videoenc_access_count) < 0);
-       WARN_ON(atomic_read(&g_videodec_access_count) < 0);
-       WARN_ON(atomic_read(&g_display_access_count) < 0);
-#endif
-}
-
-int ospm_runtime_pm_allow(struct drm_device * dev)
+void gma_power_end(struct drm_device *dev)
 {
-       return 0;
-}
-
-void ospm_runtime_pm_forbid(struct drm_device * dev)
-{
-       struct drm_psb_private * dev_priv = dev->dev_private;
-
-       DRM_INFO("%s\n", __FUNCTION__);
-
-       pm_runtime_forbid(&dev->pdev->dev);
-       dev_priv->rpm_enabled = 0;
+       struct drm_psb_private *dev_priv = dev->dev_private;
+       dev_priv->display_count--;
+       WARN_ON(dev_priv->display_count < 0);
+       pm_runtime_put(&dev->pdev->dev);
 }
 
 int psb_runtime_suspend(struct device *dev)
 {
-       pm_message_t state;
-       int ret = 0;
-       state.event = 0;
-
-#ifdef OSPM_GFX_DPK
-       printk(KERN_ALERT "OSPM_GFX_DPK: %s \n", __func__);
-#endif
-        if (atomic_read(&g_graphics_access_count) || atomic_read(&g_videoenc_access_count)
-               || atomic_read(&g_videodec_access_count) || atomic_read(&g_display_access_count)){
-#ifdef OSPM_GFX_DPK
-                printk(KERN_ALERT "OSPM_GFX_DPK: GFX: %d VEC: %d VED: %d DC: %d DSR: %d \n", atomic_read(&g_graphics_access_count),
-                       atomic_read(&g_videoenc_access_count), atomic_read(&g_videodec_access_count), atomic_read(&g_display_access_count));
-#endif
-                return -EBUSY;
-        }
-        else
-               ret = ospm_power_suspend(gpDrmDevice->pdev, state);
-
-       return ret;
+       static pm_message_t dummy;
+       return gma_power_suspend(to_pci_dev(dev), dummy);
 }
 
 int psb_runtime_resume(struct device *dev)
@@ -782,11 +479,11 @@ int psb_runtime_resume(struct device *dev)
 
 int psb_runtime_idle(struct device *dev)
 {
-       /*printk (KERN_ALERT "lvds:%d,mipi:%d\n", dev_priv->is_lvds_on, dev_priv->is_mipi_on);*/
-       if (atomic_read(&g_graphics_access_count) || atomic_read(&g_videoenc_access_count)
-               || atomic_read(&g_videodec_access_count) || atomic_read(&g_display_access_count))
-               return 1;
-       else
+       struct drm_device *drmdev = pci_get_drvdata(to_pci_dev(dev));
+       struct drm_psb_private *dev_priv = drmdev->dev_private;
+       if (dev_priv->display_count)
                return 0;
+       else
+               return 1;
 }
 
index bf6f27af03a821a437531b877fb895a2f71f30d5..e005229af7988e9ee149e6b5de807fb6f2a74653 100644 (file)
@@ -24,7 +24,8 @@
  * Authors:
  *    Benjamin Defnet <benjamin.r.defnet@intel.com>
  *    Rajesh Poornachandran <rajesh.poornachandran@intel.com>
- *
+ * Massively reworked
+ *    Alan Cox <alan@linux.intel.com>
  */
 #ifndef _PSB_POWERMGMT_H_
 #define _PSB_POWERMGMT_H_
 #include <linux/pci.h>
 #include <drm/drmP.h>
 
-#define OSPM_GRAPHICS_ISLAND   0x1
-#define OSPM_VIDEO_ENC_ISLAND  0x2
-#define OSPM_VIDEO_DEC_ISLAND  0x4
-#define OSPM_DISPLAY_ISLAND    0x8
-#define OSPM_GL3_CACHE_ISLAND  0x10
-#define OSPM_ALL_ISLANDS       0x1f
-
-/* IPC message and command defines used to enable/disable mipi panel voltages */
-#define IPC_MSG_PANEL_ON_OFF    0xE9
-#define IPC_CMD_PANEL_ON        1
-#define IPC_CMD_PANEL_OFF       0
-
-typedef enum _UHBUsage
-{
-    OSPM_UHB_ONLY_IF_ON = 0,
-    OSPM_UHB_FORCE_POWER_ON,
-} UHBUsage;
-
-/* Use these functions to power down video HW for D0i3 purpose  */
-
-void ospm_power_init(struct drm_device *dev);
-void ospm_power_uninit(void);
-
+void gma_power_init(struct drm_device *dev);
+void gma_power_uninit(struct drm_device *dev);
 
 /*
- * OSPM will call these functions
+ * The kernel bus power management  will call these functions
  */
-int ospm_power_suspend(struct pci_dev *pdev, pm_message_t state);
-int ospm_power_resume(struct pci_dev *pdev);
+int gma_power_suspend(struct pci_dev *pdev, pm_message_t state);
+int gma_power_resume(struct pci_dev *pdev);
 
 /*
  * These are the functions the driver should use to wrap all hw access
  * (i.e. register reads and writes)
  */
-bool ospm_power_using_hw_begin(int hw_island, UHBUsage usage);
-void ospm_power_using_hw_end(int hw_island);
+bool gma_power_begin(struct drm_device *dev, bool force);
+void gma_power_end(struct drm_device *dev);
 
 /*
  * Use this function to do an instantaneous check for if the hw is on.
- * Only use this in cases where you know the g_state_change_mutex
- * is already held such as in irq install/uninstall and you need to
- * prevent a deadlock situation.  Otherwise use ospm_power_using_hw_begin().
+ * Only use this in cases where you know the mutex is already held such
+ * as in irq install/uninstall and you need to
+ * prevent a deadlock situation.  Otherwise use gma_power_begin().
  */
-bool ospm_power_is_hw_on(int hw_islands);
+bool gma_power_is_on(struct drm_device *dev);
 
-/*
- * Power up/down different hw component rails/islands
- */
-void ospm_power_island_down(int hw_islands);
-void ospm_power_island_up(int hw_islands);
-void ospm_suspend_graphics(void);
 /*
  * GFX-Runtime PM callbacks
  */
 int psb_runtime_suspend(struct device *dev);
 int psb_runtime_resume(struct device *dev);
 int psb_runtime_idle(struct device *dev);
-int ospm_runtime_pm_allow(struct drm_device * dev);
-void ospm_runtime_pm_forbid(struct drm_device * dev);
-
 
 #endif /*_PSB_POWERMGMT_H_*/
diff --git a/drivers/staging/gma500/psb_pvr_glue.c b/drivers/staging/gma500/psb_pvr_glue.c
deleted file mode 100644 (file)
index da78946..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (c) 2009, Intel Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
- *
- */
-
-#include "psb_pvr_glue.h"
-
-/**
- * FIXME: should NOT use these file under env/linux directly
- */
-
-int psb_get_meminfo_by_handle(void *hKernelMemInfo,
-                               void **ppsKernelMemInfo)
-{
-       return -EINVAL;
-#if 0
-       void *psKernelMemInfo = IMG_NULL;
-       PVRSRV_PER_PROCESS_DATA *psPerProc = IMG_NULL;
-       PVRSRV_ERROR eError;
-
-       psPerProc = PVRSRVPerProcessData(task_tgid_nr(current));
-       eError = PVRSRVLookupHandle(psPerProc->psHandleBase,
-                                   (IMG_VOID *)&psKernelMemInfo,
-                                   hKernelMemInfo,
-                                   PVRSRV_HANDLE_TYPE_MEM_INFO);
-       if (eError != PVRSRV_OK) {
-               DRM_ERROR("Cannot find kernel meminfo for handle 0x%x\n",
-                         (u32)hKernelMemInfo);
-               return -EINVAL;
-       }
-
-       *ppsKernelMemInfo = psKernelMemInfo;
-
-       DRM_DEBUG("Got Kernel MemInfo for handle %lx\n",
-                 (u32)hKernelMemInfo);
-       return 0;
-#endif
-}
-
-int psb_get_pages_by_mem_handle(void *hOSMemHandle, struct page ***pages)
-{
-       return -EINVAL;
-#if 0
-       LinuxMemArea *psLinuxMemArea = (LinuxMemArea *)hOSMemHandle;
-       struct page **page_list;
-       if (psLinuxMemArea->eAreaType != LINUX_MEM_AREA_ALLOC_PAGES) {
-               DRM_ERROR("MemArea type is not LINUX_MEM_AREA_ALLOC_PAGES\n");
-               return -EINVAL;
-       }
-
-       page_list = psLinuxMemArea->uData.sPageList.pvPageList;
-       if (!page_list) {
-               DRM_DEBUG("Page List is NULL\n");
-               return -ENOMEM;
-       }
-
-       *pages = page_list;
-       return 0;
-#endif
-}
diff --git a/drivers/staging/gma500/psb_pvr_glue.h b/drivers/staging/gma500/psb_pvr_glue.h
deleted file mode 100644 (file)
index dee8cb2..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright (c) 2009, Intel Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
- *
- */
-
-#include "psb_drv.h"
-
-extern int psb_get_meminfo_by_handle(void * hKernelMemInfo,
-                               void **ppsKernelMemInfo);
-extern u32 psb_get_tgid(void);
-extern int psb_get_pages_by_mem_handle(void * hOSMemHandle,
-                                       struct page ***pages);
diff --git a/drivers/staging/gma500/psb_sgx.c b/drivers/staging/gma500/psb_sgx.c
deleted file mode 100644 (file)
index 973134b..0000000
+++ /dev/null
@@ -1,238 +0,0 @@
-/**************************************************************************
- * Copyright (c) 2007, Intel Corporation.
- * All Rights Reserved.
- * Copyright (c) 2008, Tungsten Graphics, Inc. Cedar Park, TX. USA.
- * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
- *
- **************************************************************************/
-
-#include <drm/drmP.h>
-#include "psb_drv.h"
-#include "psb_drm.h"
-#include "psb_reg.h"
-#include "ttm/ttm_bo_api.h"
-#include "ttm/ttm_execbuf_util.h"
-#include "psb_ttm_userobj_api.h"
-#include "ttm/ttm_placement.h"
-#include "psb_sgx.h"
-#include "psb_intel_reg.h"
-#include "psb_powermgmt.h"
-
-
-static inline int psb_same_page(unsigned long offset,
-                               unsigned long offset2)
-{
-       return (offset & PAGE_MASK) == (offset2 & PAGE_MASK);
-}
-
-static inline unsigned long psb_offset_end(unsigned long offset,
-                                             unsigned long end)
-{
-       offset = (offset + PAGE_SIZE) & PAGE_MASK;
-       return (end < offset) ? end : offset;
-}
-
-struct psb_dstbuf_cache {
-       unsigned int dst;
-       struct ttm_buffer_object *dst_buf;
-       unsigned long dst_offset;
-       uint32_t *dst_page;
-       unsigned int dst_page_offset;
-       struct ttm_bo_kmap_obj dst_kmap;
-       bool dst_is_iomem;
-};
-
-struct psb_validate_buffer {
-       struct ttm_validate_buffer base;
-       struct psb_validate_req req;
-       int ret;
-       struct psb_validate_arg __user *user_val_arg;
-       uint32_t flags;
-       uint32_t offset;
-       int po_correct;
-};
-static int
-psb_placement_fence_type(struct ttm_buffer_object *bo,
-                        uint64_t set_val_flags,
-                        uint64_t clr_val_flags,
-                        uint32_t new_fence_class,
-                        uint32_t *new_fence_type)
-{
-       int ret;
-       uint32_t n_fence_type;
-       /*
-       uint32_t set_flags = set_val_flags & 0xFFFFFFFF;
-       uint32_t clr_flags = clr_val_flags & 0xFFFFFFFF;
-       */
-       struct ttm_fence_object *old_fence;
-       uint32_t old_fence_type;
-       struct ttm_placement placement;
-
-       if (unlikely
-           (!(set_val_flags &
-              (PSB_GPU_ACCESS_READ | PSB_GPU_ACCESS_WRITE)))) {
-               DRM_ERROR
-                   ("GPU access type (read / write) is not indicated.\n");
-               return -EINVAL;
-       }
-
-       /* User space driver doesn't set any TTM placement flags in
-                                       set_val_flags or clr_val_flags */
-       placement.num_placement = 0;/* FIXME  */
-       placement.num_busy_placement = 0;
-       placement.fpfn = 0;
-       placement.lpfn = 0;
-       ret = psb_ttm_bo_check_placement(bo, &placement);
-       if (unlikely(ret != 0))
-               return ret;
-
-       switch (new_fence_class) {
-       default:
-               n_fence_type = _PSB_FENCE_TYPE_EXE;
-       }
-
-       *new_fence_type = n_fence_type;
-       old_fence = (struct ttm_fence_object *) bo->sync_obj;
-       old_fence_type = (uint32_t) (unsigned long) bo->sync_obj_arg;
-
-       if (old_fence && ((new_fence_class != old_fence->fence_class) ||
-                         ((n_fence_type ^ old_fence_type) &
-                          old_fence_type))) {
-               ret = ttm_bo_wait(bo, 0, 1, 0);
-               if (unlikely(ret != 0))
-                       return ret;
-       }
-       /*
-       bo->proposed_flags = (bo->proposed_flags | set_flags)
-               & ~clr_flags & TTM_PL_MASK_MEMTYPE;
-       */
-       return 0;
-}
-
-int psb_validate_kernel_buffer(struct psb_context *context,
-                              struct ttm_buffer_object *bo,
-                              uint32_t fence_class,
-                              uint64_t set_flags, uint64_t clr_flags)
-{
-       struct psb_validate_buffer *item;
-       uint32_t cur_fence_type;
-       int ret;
-
-       if (unlikely(context->used_buffers >= PSB_NUM_VALIDATE_BUFFERS)) {
-               DRM_ERROR("Out of free validation buffer entries for "
-                         "kernel buffer validation.\n");
-               return -ENOMEM;
-       }
-
-       item = &context->buffers[context->used_buffers];
-       item->user_val_arg = NULL;
-       item->base.reserved = 0;
-
-       ret = ttm_bo_reserve(bo, 1, 0, 1, context->val_seq);
-       if (unlikely(ret != 0))
-               return ret;
-
-       ret = psb_placement_fence_type(bo, set_flags, clr_flags, fence_class,
-                                      &cur_fence_type);
-       if (unlikely(ret != 0)) {
-               ttm_bo_unreserve(bo);
-               return ret;
-       }
-
-       item->base.bo = ttm_bo_reference(bo);
-       item->base.new_sync_obj_arg = (void *) (unsigned long) cur_fence_type;
-       item->base.reserved = 1;
-
-       /* Internal locking ??? FIXMEAC */
-       list_add_tail(&item->base.head, &context->kern_validate_list);
-       context->used_buffers++;
-       /*
-       ret = ttm_bo_validate(bo, 1, 0, 0);
-       if (unlikely(ret != 0))
-               goto out_unlock;
-       */
-       item->offset = bo->offset;
-       item->flags = bo->mem.placement;
-       context->fence_types |= cur_fence_type;
-
-       return ret;
-}
-
-void psb_fence_or_sync(struct drm_file *file_priv,
-                      uint32_t engine,
-                      uint32_t fence_types,
-                      uint32_t fence_flags,
-                      struct list_head *list,
-                      struct psb_ttm_fence_rep *fence_arg,
-                      struct ttm_fence_object **fence_p)
-{
-       struct drm_device *dev = file_priv->minor->dev;
-       struct drm_psb_private *dev_priv = psb_priv(dev);
-       struct ttm_fence_device *fdev = &dev_priv->fdev;
-       int ret;
-       struct ttm_fence_object *fence;
-       struct ttm_object_file *tfile = psb_fpriv(file_priv)->tfile;
-       uint32_t handle;
-
-       ret = ttm_fence_user_create(fdev, tfile,
-                                   engine, fence_types,
-                                   TTM_FENCE_FLAG_EMIT, &fence, &handle);
-       if (ret) {
-
-               /*
-                * Fence creation failed.
-                * Fall back to synchronous operation and idle the engine.
-                */
-
-               if (!(fence_flags & DRM_PSB_FENCE_NO_USER)) {
-
-                       /*
-                        * Communicate to user-space that
-                        * fence creation has failed and that
-                        * the engine is idle.
-                        */
-
-                       fence_arg->handle = ~0;
-                       fence_arg->error = ret;
-               }
-
-               ttm_eu_backoff_reservation(list);
-               if (fence_p)
-                       *fence_p = NULL;
-               return;
-       }
-
-       ttm_eu_fence_buffer_objects(list, fence);
-       if (!(fence_flags & DRM_PSB_FENCE_NO_USER)) {
-               struct ttm_fence_info info = ttm_fence_get_info(fence);
-               fence_arg->handle = handle;
-               fence_arg->fence_class = ttm_fence_class(fence);
-               fence_arg->fence_type = ttm_fence_types(fence);
-               fence_arg->signaled_types = info.signaled_types;
-               fence_arg->error = 0;
-       } else {
-               ret =
-                   ttm_ref_object_base_unref(tfile, handle,
-                                             ttm_fence_type);
-               BUG_ON(ret);
-       }
-
-       if (fence_p)
-               *fence_p = fence;
-       else if (fence)
-               ttm_fence_object_unref(&fence);
-}
-
diff --git a/drivers/staging/gma500/psb_sgx.h b/drivers/staging/gma500/psb_sgx.h
deleted file mode 100644 (file)
index 9300e2d..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (c) 2008, Intel Corporation
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Authors:
- *    Eric Anholt <eric@anholt.net>
- *
- **/
-#ifndef _PSB_SGX_H_
-#define _PSB_SGX_H_
-
-extern int psb_submit_video_cmdbuf(struct drm_device *dev,
-                              struct ttm_buffer_object *cmd_buffer,
-                              unsigned long cmd_offset,
-                              unsigned long cmd_size,
-                              struct ttm_fence_object *fence);
-
-extern int drm_idle_check_interval;
-
-#endif
diff --git a/drivers/staging/gma500/psb_ttm_fence.c b/drivers/staging/gma500/psb_ttm_fence.c
deleted file mode 100644 (file)
index d1c3590..0000000
+++ /dev/null
@@ -1,605 +0,0 @@
-/**************************************************************************
- *
- * Copyright (c) 2006-2008 Tungsten Graphics, Inc., Cedar Park, TX., USA
- * All Rights Reserved.
- * Copyright (c) 2009 VMware, Inc., Palo Alto, CA., USA
- * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
- *
- **************************************************************************/
-/*
- * Authors: Thomas Hellstrom <thomas-at-tungstengraphics-dot-com>
- */
-
-#include "psb_ttm_fence_api.h"
-#include "psb_ttm_fence_driver.h"
-#include <linux/wait.h>
-#include <linux/sched.h>
-
-#include <drm/drmP.h>
-
-/*
- * Simple implementation for now.
- */
-
-static void ttm_fence_lockup(struct ttm_fence_object *fence, uint32_t mask)
-{
-       struct ttm_fence_class_manager *fc = ttm_fence_fc(fence);
-
-       printk(KERN_ERR "GPU lockup dectected on engine %u "
-              "fence type 0x%08x\n",
-              (unsigned int)fence->fence_class, (unsigned int)mask);
-       /*
-        * Give engines some time to idle?
-        */
-
-       write_lock(&fc->lock);
-       ttm_fence_handler(fence->fdev, fence->fence_class,
-                         fence->sequence, mask, -EBUSY);
-       write_unlock(&fc->lock);
-}
-
-/*
- * Convenience function to be called by fence::wait methods that
- * need polling.
- */
-
-int ttm_fence_wait_polling(struct ttm_fence_object *fence, bool lazy,
-                          bool interruptible, uint32_t mask)
-{
-       struct ttm_fence_class_manager *fc = ttm_fence_fc(fence);
-       const struct ttm_fence_driver *driver = ttm_fence_driver(fence);
-       uint32_t count = 0;
-       int ret;
-       unsigned long end_jiffies = fence->timeout_jiffies;
-
-       DECLARE_WAITQUEUE(entry, current);
-       add_wait_queue(&fc->fence_queue, &entry);
-
-       ret = 0;
-
-       for (;;) {
-               __set_current_state((interruptible) ?
-                                   TASK_INTERRUPTIBLE : TASK_UNINTERRUPTIBLE);
-               if (ttm_fence_object_signaled(fence, mask))
-                       break;
-               if (time_after_eq(jiffies, end_jiffies)) {
-                       if (driver->lockup)
-                               driver->lockup(fence, mask);
-                       else
-                               ttm_fence_lockup(fence, mask);
-                       continue;
-               }
-               if (lazy)
-                       schedule_timeout(1);
-               else if ((++count & 0x0F) == 0) {
-                       __set_current_state(TASK_RUNNING);
-                       schedule();
-                       __set_current_state((interruptible) ?
-                                           TASK_INTERRUPTIBLE :
-                                           TASK_UNINTERRUPTIBLE);
-               }
-               if (interruptible && signal_pending(current)) {
-                       ret = -ERESTART;
-                       break;
-               }
-       }
-       __set_current_state(TASK_RUNNING);
-       remove_wait_queue(&fc->fence_queue, &entry);
-       return ret;
-}
-
-/*
- * Typically called by the IRQ handler.
- */
-
-void ttm_fence_handler(struct ttm_fence_device *fdev, uint32_t fence_class,
-                      uint32_t sequence, uint32_t type, uint32_t error)
-{
-       int wake = 0;
-       uint32_t diff;
-       uint32_t relevant_type;
-       uint32_t new_type;
-       struct ttm_fence_class_manager *fc = &fdev->fence_class[fence_class];
-       const struct ttm_fence_driver *driver = ttm_fence_driver_from_dev(fdev);
-       struct list_head *head;
-       struct ttm_fence_object *fence, *next;
-       bool found = false;
-
-       if (list_empty(&fc->ring))
-               return;
-
-       list_for_each_entry(fence, &fc->ring, ring) {
-               diff = (sequence - fence->sequence) & fc->sequence_mask;
-               if (diff > fc->wrap_diff) {
-                       found = true;
-                       break;
-               }
-       }
-
-       fc->waiting_types &= ~type;
-       head = (found) ? &fence->ring : &fc->ring;
-
-       list_for_each_entry_safe_reverse(fence, next, head, ring) {
-               if (&fence->ring == &fc->ring)
-                       break;
-
-               DRM_DEBUG("Fence 0x%08lx, sequence 0x%08x, type 0x%08x\n",
-                         (unsigned long)fence, fence->sequence,
-                         fence->fence_type);
-
-               if (error) {
-                       fence->info.error = error;
-                       fence->info.signaled_types = fence->fence_type;
-                       list_del_init(&fence->ring);
-                       wake = 1;
-                       break;
-               }
-
-               relevant_type = type & fence->fence_type;
-               new_type = (fence->info.signaled_types | relevant_type) ^
-                   fence->info.signaled_types;
-
-               if (new_type) {
-                       fence->info.signaled_types |= new_type;
-                       DRM_DEBUG("Fence 0x%08lx signaled 0x%08x\n",
-                                 (unsigned long)fence,
-                                 fence->info.signaled_types);
-
-                       if (unlikely(driver->signaled))
-                               driver->signaled(fence);
-
-                       if (driver->needed_flush)
-                               fc->pending_flush |=
-                                   driver->needed_flush(fence);
-
-                       if (new_type & fence->waiting_types)
-                               wake = 1;
-               }
-
-               fc->waiting_types |=
-                   fence->waiting_types & ~fence->info.signaled_types;
-
-               if (!(fence->fence_type & ~fence->info.signaled_types)) {
-                       DRM_DEBUG("Fence completely signaled 0x%08lx\n",
-                                 (unsigned long)fence);
-                       list_del_init(&fence->ring);
-               }
-       }
-
-       /*
-        * Reinstate lost waiting types.
-        */
-
-       if ((fc->waiting_types & type) != type) {
-               head = head->prev;
-               list_for_each_entry(fence, head, ring) {
-                       if (&fence->ring == &fc->ring)
-                               break;
-                       diff =
-                           (fc->highest_waiting_sequence -
-                            fence->sequence) & fc->sequence_mask;
-                       if (diff > fc->wrap_diff)
-                               break;
-
-                       fc->waiting_types |=
-                           fence->waiting_types & ~fence->info.signaled_types;
-               }
-       }
-
-       if (wake)
-               wake_up_all(&fc->fence_queue);
-}
-
-static void ttm_fence_unring(struct ttm_fence_object *fence)
-{
-       struct ttm_fence_class_manager *fc = ttm_fence_fc(fence);
-       unsigned long irq_flags;
-
-       write_lock_irqsave(&fc->lock, irq_flags);
-       list_del_init(&fence->ring);
-       write_unlock_irqrestore(&fc->lock, irq_flags);
-}
-
-bool ttm_fence_object_signaled(struct ttm_fence_object *fence, uint32_t mask)
-{
-       unsigned long flags;
-       bool signaled;
-       const struct ttm_fence_driver *driver = ttm_fence_driver(fence);
-       struct ttm_fence_class_manager *fc = ttm_fence_fc(fence);
-
-       mask &= fence->fence_type;
-       read_lock_irqsave(&fc->lock, flags);
-       signaled = (mask & fence->info.signaled_types) == mask;
-       read_unlock_irqrestore(&fc->lock, flags);
-       if (!signaled && driver->poll) {
-               write_lock_irqsave(&fc->lock, flags);
-               driver->poll(fence->fdev, fence->fence_class, mask);
-               signaled = (mask & fence->info.signaled_types) == mask;
-               write_unlock_irqrestore(&fc->lock, flags);
-       }
-       return signaled;
-}
-
-int ttm_fence_object_flush(struct ttm_fence_object *fence, uint32_t type)
-{
-       const struct ttm_fence_driver *driver = ttm_fence_driver(fence);
-       struct ttm_fence_class_manager *fc = ttm_fence_fc(fence);
-       unsigned long irq_flags;
-       uint32_t saved_pending_flush;
-       uint32_t diff;
-       bool call_flush;
-
-       if (type & ~fence->fence_type) {
-               DRM_ERROR("Flush trying to extend fence type, "
-                         "0x%x, 0x%x\n", type, fence->fence_type);
-               return -EINVAL;
-       }
-
-       write_lock_irqsave(&fc->lock, irq_flags);
-       fence->waiting_types |= type;
-       fc->waiting_types |= fence->waiting_types;
-       diff = (fence->sequence - fc->highest_waiting_sequence) &
-           fc->sequence_mask;
-
-       if (diff < fc->wrap_diff)
-               fc->highest_waiting_sequence = fence->sequence;
-
-       /*
-        * fence->waiting_types has changed. Determine whether
-        * we need to initiate some kind of flush as a result of this.
-        */
-
-       saved_pending_flush = fc->pending_flush;
-       if (driver->needed_flush)
-               fc->pending_flush |= driver->needed_flush(fence);
-
-       if (driver->poll)
-               driver->poll(fence->fdev, fence->fence_class,
-                            fence->waiting_types);
-
-       call_flush = (fc->pending_flush != 0);
-       write_unlock_irqrestore(&fc->lock, irq_flags);
-
-       if (call_flush && driver->flush)
-               driver->flush(fence->fdev, fence->fence_class);
-
-       return 0;
-}
-
-/*
- * Make sure old fence objects are signaled before their fence sequences are
- * wrapped around and reused.
- */
-
-void ttm_fence_flush_old(struct ttm_fence_device *fdev,
-                        uint32_t fence_class, uint32_t sequence)
-{
-       struct ttm_fence_class_manager *fc = &fdev->fence_class[fence_class];
-       struct ttm_fence_object *fence;
-       unsigned long irq_flags;
-       const struct ttm_fence_driver *driver = fdev->driver;
-       bool call_flush;
-
-       uint32_t diff;
-
-       write_lock_irqsave(&fc->lock, irq_flags);
-
-       list_for_each_entry_reverse(fence, &fc->ring, ring) {
-               diff = (sequence - fence->sequence) & fc->sequence_mask;
-               if (diff <= fc->flush_diff)
-                       break;
-
-               fence->waiting_types = fence->fence_type;
-               fc->waiting_types |= fence->fence_type;
-
-               if (driver->needed_flush)
-                       fc->pending_flush |= driver->needed_flush(fence);
-       }
-
-       if (driver->poll)
-               driver->poll(fdev, fence_class, fc->waiting_types);
-
-       call_flush = (fc->pending_flush != 0);
-       write_unlock_irqrestore(&fc->lock, irq_flags);
-
-       if (call_flush && driver->flush)
-               driver->flush(fdev, fence->fence_class);
-
-       /*
-        * FIXME: Shold we implement a wait here for really old fences?
-        */
-
-}
-
-int ttm_fence_object_wait(struct ttm_fence_object *fence,
-                         bool lazy, bool interruptible, uint32_t mask)
-{
-       const struct ttm_fence_driver *driver = ttm_fence_driver(fence);
-       struct ttm_fence_class_manager *fc = ttm_fence_fc(fence);
-       int ret = 0;
-       unsigned long timeout;
-       unsigned long cur_jiffies;
-       unsigned long to_jiffies;
-
-       if (mask & ~fence->fence_type) {
-               DRM_ERROR("Wait trying to extend fence type"
-                         " 0x%08x 0x%08x\n", mask, fence->fence_type);
-               BUG();
-               return -EINVAL;
-       }
-
-       if (driver->wait)
-               return driver->wait(fence, lazy, interruptible, mask);
-
-       ttm_fence_object_flush(fence, mask);
-retry:
-       if (!driver->has_irq ||
-           driver->has_irq(fence->fdev, fence->fence_class, mask)) {
-
-               cur_jiffies = jiffies;
-               to_jiffies = fence->timeout_jiffies;
-
-               timeout = (time_after(to_jiffies, cur_jiffies)) ?
-                   to_jiffies - cur_jiffies : 1;
-
-               if (interruptible)
-                       ret = wait_event_interruptible_timeout
-                           (fc->fence_queue,
-                            ttm_fence_object_signaled(fence, mask), timeout);
-               else
-                       ret = wait_event_timeout
-                           (fc->fence_queue,
-                            ttm_fence_object_signaled(fence, mask), timeout);
-
-               if (unlikely(ret == -ERESTARTSYS))
-                       return -ERESTART;
-
-               if (unlikely(ret == 0)) {
-                       if (driver->lockup)
-                               driver->lockup(fence, mask);
-                       else
-                               ttm_fence_lockup(fence, mask);
-                       goto retry;
-               }
-
-               return 0;
-       }
-
-       return ttm_fence_wait_polling(fence, lazy, interruptible, mask);
-}
-
-int ttm_fence_object_emit(struct ttm_fence_object *fence, uint32_t fence_flags,
-                         uint32_t fence_class, uint32_t type)
-{
-       const struct ttm_fence_driver *driver = ttm_fence_driver(fence);
-       struct ttm_fence_class_manager *fc = ttm_fence_fc(fence);
-       unsigned long flags;
-       uint32_t sequence;
-       unsigned long timeout;
-       int ret;
-
-       ttm_fence_unring(fence);
-       ret = driver->emit(fence->fdev,
-                          fence_class, fence_flags, &sequence, &timeout);
-       if (ret)
-               return ret;
-
-       write_lock_irqsave(&fc->lock, flags);
-       fence->fence_class = fence_class;
-       fence->fence_type = type;
-       fence->waiting_types = 0;
-       fence->info.signaled_types = 0;
-       fence->info.error = 0;
-       fence->sequence = sequence;
-       fence->timeout_jiffies = timeout;
-       if (list_empty(&fc->ring))
-               fc->highest_waiting_sequence = sequence - 1;
-       list_add_tail(&fence->ring, &fc->ring);
-       fc->latest_queued_sequence = sequence;
-       write_unlock_irqrestore(&fc->lock, flags);
-       return 0;
-}
-
-int ttm_fence_object_init(struct ttm_fence_device *fdev,
-                         uint32_t fence_class,
-                         uint32_t type,
-                         uint32_t create_flags,
-                         void (*destroy) (struct ttm_fence_object *),
-                         struct ttm_fence_object *fence)
-{
-       int ret = 0;
-
-       kref_init(&fence->kref);
-       fence->fence_class = fence_class;
-       fence->fence_type = type;
-       fence->info.signaled_types = 0;
-       fence->waiting_types = 0;
-       fence->sequence = 0;
-       fence->info.error = 0;
-       fence->fdev = fdev;
-       fence->destroy = destroy;
-       INIT_LIST_HEAD(&fence->ring);
-       atomic_inc(&fdev->count);
-
-       if (create_flags & TTM_FENCE_FLAG_EMIT) {
-               ret = ttm_fence_object_emit(fence, create_flags,
-                                           fence->fence_class, type);
-       }
-
-       return ret;
-}
-
-int ttm_fence_object_create(struct ttm_fence_device *fdev,
-                           uint32_t fence_class,
-                           uint32_t type,
-                           uint32_t create_flags,
-                           struct ttm_fence_object **c_fence)
-{
-       struct ttm_fence_object *fence;
-       int ret;
-
-       ret = ttm_mem_global_alloc(fdev->mem_glob,
-                                  sizeof(*fence),
-                                  false,
-                                  false);
-       if (unlikely(ret != 0)) {
-               printk(KERN_ERR "Out of memory creating fence object\n");
-               return ret;
-       }
-
-       fence = kmalloc(sizeof(*fence), GFP_KERNEL);
-       if (!fence) {
-               printk(KERN_ERR "Out of memory creating fence object\n");
-               ttm_mem_global_free(fdev->mem_glob, sizeof(*fence));
-               return -ENOMEM;
-       }
-
-       ret = ttm_fence_object_init(fdev, fence_class, type,
-                                   create_flags, NULL, fence);
-       if (ret) {
-               ttm_fence_object_unref(&fence);
-               return ret;
-       }
-       *c_fence = fence;
-
-       return 0;
-}
-
-static void ttm_fence_object_destroy(struct kref *kref)
-{
-       struct ttm_fence_object *fence =
-           container_of(kref, struct ttm_fence_object, kref);
-       struct ttm_fence_class_manager *fc = ttm_fence_fc(fence);
-       unsigned long irq_flags;
-
-       write_lock_irqsave(&fc->lock, irq_flags);
-       list_del_init(&fence->ring);
-       write_unlock_irqrestore(&fc->lock, irq_flags);
-
-       atomic_dec(&fence->fdev->count);
-       if (fence->destroy)
-               fence->destroy(fence);
-       else {
-               ttm_mem_global_free(fence->fdev->mem_glob,
-                                   sizeof(*fence));
-               kfree(fence);
-       }
-}
-
-void ttm_fence_device_release(struct ttm_fence_device *fdev)
-{
-       kfree(fdev->fence_class);
-}
-
-int
-ttm_fence_device_init(int num_classes,
-                     struct ttm_mem_global *mem_glob,
-                     struct ttm_fence_device *fdev,
-                     const struct ttm_fence_class_init *init,
-                     bool replicate_init,
-                     const struct ttm_fence_driver *driver)
-{
-       struct ttm_fence_class_manager *fc;
-       const struct ttm_fence_class_init *fci;
-       int i;
-
-       fdev->mem_glob = mem_glob;
-       fdev->fence_class = kzalloc(num_classes *
-                                   sizeof(*fdev->fence_class), GFP_KERNEL);
-
-       if (unlikely(!fdev->fence_class))
-               return -ENOMEM;
-
-       fdev->num_classes = num_classes;
-       atomic_set(&fdev->count, 0);
-       fdev->driver = driver;
-
-       for (i = 0; i < fdev->num_classes; ++i) {
-               fc = &fdev->fence_class[i];
-               fci = &init[(replicate_init) ? 0 : i];
-
-               fc->wrap_diff = fci->wrap_diff;
-               fc->flush_diff = fci->flush_diff;
-               fc->sequence_mask = fci->sequence_mask;
-
-               rwlock_init(&fc->lock);
-               INIT_LIST_HEAD(&fc->ring);
-               init_waitqueue_head(&fc->fence_queue);
-       }
-
-       return 0;
-}
-
-struct ttm_fence_info ttm_fence_get_info(struct ttm_fence_object *fence)
-{
-       struct ttm_fence_class_manager *fc = ttm_fence_fc(fence);
-       struct ttm_fence_info tmp;
-       unsigned long irq_flags;
-
-       read_lock_irqsave(&fc->lock, irq_flags);
-       tmp = fence->info;
-       read_unlock_irqrestore(&fc->lock, irq_flags);
-
-       return tmp;
-}
-
-void ttm_fence_object_unref(struct ttm_fence_object **p_fence)
-{
-       struct ttm_fence_object *fence = *p_fence;
-
-       *p_fence = NULL;
-       (void)kref_put(&fence->kref, &ttm_fence_object_destroy);
-}
-
-/*
- * Placement / BO sync object glue.
- */
-
-bool ttm_fence_sync_obj_signaled(void *sync_obj, void *sync_arg)
-{
-       struct ttm_fence_object *fence = (struct ttm_fence_object *)sync_obj;
-       uint32_t fence_types = (uint32_t) (unsigned long)sync_arg;
-
-       return ttm_fence_object_signaled(fence, fence_types);
-}
-
-int ttm_fence_sync_obj_wait(void *sync_obj, void *sync_arg,
-                           bool lazy, bool interruptible)
-{
-       struct ttm_fence_object *fence = (struct ttm_fence_object *)sync_obj;
-       uint32_t fence_types = (uint32_t) (unsigned long)sync_arg;
-
-       return ttm_fence_object_wait(fence, lazy, interruptible, fence_types);
-}
-
-int ttm_fence_sync_obj_flush(void *sync_obj, void *sync_arg)
-{
-       struct ttm_fence_object *fence = (struct ttm_fence_object *)sync_obj;
-       uint32_t fence_types = (uint32_t) (unsigned long)sync_arg;
-
-       return ttm_fence_object_flush(fence, fence_types);
-}
-
-void ttm_fence_sync_obj_unref(void **sync_obj)
-{
-       ttm_fence_object_unref((struct ttm_fence_object **)sync_obj);
-}
-
-void *ttm_fence_sync_obj_ref(void *sync_obj)
-{
-       return (void *)
-           ttm_fence_object_ref((struct ttm_fence_object *)sync_obj);
-}
diff --git a/drivers/staging/gma500/psb_ttm_fence_api.h b/drivers/staging/gma500/psb_ttm_fence_api.h
deleted file mode 100644 (file)
index b14a427..0000000
+++ /dev/null
@@ -1,272 +0,0 @@
-/**************************************************************************
- *
- * Copyright (c) 2006-2008 Tungsten Graphics, Inc., Cedar Park, TX., USA
- * All Rights Reserved.
- * Copyright (c) 2009 VMware, Inc., Palo Alto, CA., USA
- * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
- *
- **************************************************************************/
-/*
- * Authors: Thomas Hellstrom <thomas-at-tungstengraphics-dot-com>
- */
-#ifndef _TTM_FENCE_API_H_
-#define _TTM_FENCE_API_H_
-
-#include <linux/list.h>
-#include <linux/kref.h>
-
-#define TTM_FENCE_FLAG_EMIT (1 << 0)
-#define TTM_FENCE_TYPE_EXE  (1 << 0)
-
-struct ttm_fence_device;
-
-/**
- * struct ttm_fence_info
- *
- * @fence_class:    The fence class.
- * @fence_type:     Bitfield indicating types for this fence.
- * @signaled_types: Bitfield indicating which types are signaled.
- * @error:          Last error reported from the device.
- *
- * Used as output from the ttm_fence_get_info
- */
-
-struct ttm_fence_info {
-       uint32_t signaled_types;
-       uint32_t error;
-};
-
-/**
- * struct ttm_fence_object
- *
- * @fdev:            Pointer to the fence device struct.
- * @kref:            Holds the reference count of this fence object.
- * @ring:            List head used for the circular list of not-completely
- *                   signaled fences.
- * @info:            Data for fast retrieval using the ttm_fence_get_info()
- * function.
- * @timeout_jiffies: Absolute jiffies value indicating when this fence
- *                   object times out and, if waited on, calls ttm_fence_lockup
- *                   to check for and resolve a GPU lockup.
- * @sequence:        Fence sequence number.
- * @waiting_types:   Types currently waited on.
- * @destroy:         Called to free the fence object, when its refcount has
- *                   reached zero. If NULL, kfree is used.
- *
- * This struct is provided in the driver interface so that drivers can
- * derive from it and create their own fence implementation. All members
- * are private to the fence implementation and the fence driver callbacks.
- * Otherwise a driver may access the derived object using container_of().
- */
-
-struct ttm_fence_object {
-       struct ttm_fence_device *fdev;
-       struct kref kref;
-       uint32_t fence_class;
-       uint32_t fence_type;
-
-       /*
-        * The below fields are protected by the fence class
-        * manager spinlock.
-        */
-
-       struct list_head ring;
-       struct ttm_fence_info info;
-       unsigned long timeout_jiffies;
-       uint32_t sequence;
-       uint32_t waiting_types;
-       void (*destroy) (struct ttm_fence_object *);
-};
-
-/**
- * ttm_fence_object_init
- *
- * @fdev: Pointer to a struct ttm_fence_device.
- * @fence_class: Fence class for this fence.
- * @type: Fence type for this fence.
- * @create_flags: Flags indicating varios actions at init time. At this point
- * there's only TTM_FENCE_FLAG_EMIT, which triggers a sequence emission to
- * the command stream.
- * @destroy: Destroy function. If NULL, kfree() is used.
- * @fence: The struct ttm_fence_object to initialize.
- *
- * Initialize a pre-allocated fence object. This function, together with the
- * destroy function makes it possible to derive driver-specific fence objects.
- */
-
-extern int
-ttm_fence_object_init(struct ttm_fence_device *fdev,
-                     uint32_t fence_class,
-                     uint32_t type,
-                     uint32_t create_flags,
-                     void (*destroy) (struct ttm_fence_object *fence),
-                     struct ttm_fence_object *fence);
-
-/**
- * ttm_fence_object_create
- *
- * @fdev: Pointer to a struct ttm_fence_device.
- * @fence_class: Fence class for this fence.
- * @type: Fence type for this fence.
- * @create_flags: Flags indicating varios actions at init time. At this point
- * there's only TTM_FENCE_FLAG_EMIT, which triggers a sequence emission to
- * the command stream.
- * @c_fence: On successful termination, *(@c_fence) will point to the created
- * fence object.
- *
- * Create and initialize a struct ttm_fence_object. The destroy function will
- * be set to kfree().
- */
-
-extern int
-ttm_fence_object_create(struct ttm_fence_device *fdev,
-                       uint32_t fence_class,
-                       uint32_t type,
-                       uint32_t create_flags,
-                       struct ttm_fence_object **c_fence);
-
-/**
- * ttm_fence_object_wait
- *
- * @fence: The fence object to wait on.
- * @lazy: Allow sleeps to reduce the cpu-usage if polling.
- * @interruptible: Sleep interruptible when waiting.
- * @type_mask: Wait for the given type_mask to signal.
- *
- * Wait for a fence to signal the given type_mask. The function will
- * perform a fence_flush using type_mask. (See ttm_fence_object_flush).
- *
- * Returns
- * -ERESTART if interrupted by a signal.
- * May return driver-specific error codes if timed-out.
- */
-
-extern int
-ttm_fence_object_wait(struct ttm_fence_object *fence,
-                     bool lazy, bool interruptible, uint32_t type_mask);
-
-/**
- * ttm_fence_object_flush
- *
- * @fence: The fence object to flush.
- * @flush_mask: Fence types to flush.
- *
- * Make sure that the given fence eventually signals the
- * types indicated by @flush_mask. Note that this may or may not
- * map to a CPU or GPU flush.
- */
-
-extern int
-ttm_fence_object_flush(struct ttm_fence_object *fence, uint32_t flush_mask);
-
-/**
- * ttm_fence_get_info
- *
- * @fence: The fence object.
- *
- * Copy the info block from the fence while holding relevant locks.
- */
-
-struct ttm_fence_info ttm_fence_get_info(struct ttm_fence_object *fence);
-
-/**
- * ttm_fence_object_ref
- *
- * @fence: The fence object.
- *
- * Return a ref-counted pointer to the fence object indicated by @fence.
- */
-
-static inline struct ttm_fence_object *ttm_fence_object_ref(struct
-                                                           ttm_fence_object
-                                                           *fence)
-{
-       kref_get(&fence->kref);
-       return fence;
-}
-
-/**
- * ttm_fence_object_unref
- *
- * @p_fence: Pointer to a ref-counted pinter to a struct ttm_fence_object.
- *
- * Unreference the fence object pointed to by *(@p_fence), clearing
- * *(p_fence).
- */
-
-extern void ttm_fence_object_unref(struct ttm_fence_object **p_fence);
-
-/**
- * ttm_fence_object_signaled
- *
- * @fence: Pointer to the struct ttm_fence_object.
- * @mask: Type mask to check whether signaled.
- *
- * This function checks (without waiting) whether the fence object
- * pointed to by @fence has signaled the types indicated by @mask,
- * and returns 1 if true, 0 if false. This function does NOT perform
- * an implicit fence flush.
- */
-
-extern bool
-ttm_fence_object_signaled(struct ttm_fence_object *fence, uint32_t mask);
-
-/**
- * ttm_fence_class
- *
- * @fence: Pointer to the struct ttm_fence_object.
- *
- * Convenience function that returns the fence class of a
- * struct ttm_fence_object.
- */
-
-static inline uint32_t ttm_fence_class(const struct ttm_fence_object *fence)
-{
-       return fence->fence_class;
-}
-
-/**
- * ttm_fence_types
- *
- * @fence: Pointer to the struct ttm_fence_object.
- *
- * Convenience function that returns the fence types of a
- * struct ttm_fence_object.
- */
-
-static inline uint32_t ttm_fence_types(const struct ttm_fence_object *fence)
-{
-       return fence->fence_type;
-}
-
-/*
- * The functions below are wrappers to the above functions, with
- * similar names but with sync_obj omitted. These wrappers are intended
- * to be plugged directly into the buffer object driver's sync object
- * API, if the driver chooses to use ttm_fence_objects as buffer object
- * sync objects. In the prototypes below, a sync_obj is cast to a
- * struct ttm_fence_object, whereas a sync_arg is cast to an
- * uint32_t representing a fence_type argument.
- */
-
-extern bool ttm_fence_sync_obj_signaled(void *sync_obj, void *sync_arg);
-extern int ttm_fence_sync_obj_wait(void *sync_obj, void *sync_arg,
-                                  bool lazy, bool interruptible);
-extern int ttm_fence_sync_obj_flush(void *sync_obj, void *sync_arg);
-extern void ttm_fence_sync_obj_unref(void **sync_obj);
-extern void *ttm_fence_sync_obj_ref(void *sync_obj);
-
-#endif
diff --git a/drivers/staging/gma500/psb_ttm_fence_driver.h b/drivers/staging/gma500/psb_ttm_fence_driver.h
deleted file mode 100644 (file)
index c35c569..0000000
+++ /dev/null
@@ -1,302 +0,0 @@
-/**************************************************************************
- *
- * Copyright (c) 2006-2008 Tungsten Graphics, Inc., Cedar Park, TX., USA
- * All Rights Reserved.
- * Copyright (c) 2009 VMware, Inc., Palo Alto, CA., USA
- * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
- *
- **************************************************************************/
-/*
- * Authors: Thomas Hellstrom <thomas-at-tungstengraphics-dot-com>
- */
-#ifndef _TTM_FENCE_DRIVER_H_
-#define _TTM_FENCE_DRIVER_H_
-
-#include <linux/kref.h>
-#include <linux/spinlock.h>
-#include <linux/wait.h>
-#include "psb_ttm_fence_api.h"
-#include "ttm/ttm_memory.h"
-
-/** @file ttm_fence_driver.h
- *
- * Definitions needed for a driver implementing the
- * ttm_fence subsystem.
- */
-
-/**
- * struct ttm_fence_class_manager:
- *
- * @wrap_diff: Sequence difference to catch 32-bit wrapping.
- * if (seqa - seqb) > @wrap_diff, then seqa < seqb.
- * @flush_diff: Sequence difference to trigger fence flush.
- * if (cur_seq - seqa) > @flush_diff, then consider fence object with
- * seqa as old an needing a flush.
- * @sequence_mask: Mask of valid bits in a fence sequence.
- * @lock: Lock protecting this struct as well as fence objects
- * associated with this struct.
- * @ring: Circular sequence-ordered list of fence objects.
- * @pending_flush: Fence types currently needing a flush.
- * @waiting_types: Fence types that are currently waited for.
- * @fence_queue: Queue of waiters on fences belonging to this fence class.
- * @highest_waiting_sequence: Sequence number of the fence with highest
- * sequence number and that is waited for.
- * @latest_queued_sequence: Sequence number of the fence latest queued
- * on the ring.
- */
-
-struct ttm_fence_class_manager {
-
-       /*
-        * Unprotected constant members.
-        */
-
-       uint32_t wrap_diff;
-       uint32_t flush_diff;
-       uint32_t sequence_mask;
-
-       /*
-        * The rwlock protects this structure as well as
-        * the data in all fence objects belonging to this
-        * class. This should be OK as most fence objects are
-        * only read from once they're created.
-        */
-
-       rwlock_t lock;
-       struct list_head ring;
-       uint32_t pending_flush;
-       uint32_t waiting_types;
-       wait_queue_head_t fence_queue;
-       uint32_t highest_waiting_sequence;
-       uint32_t latest_queued_sequence;
-};
-
-/**
- * struct ttm_fence_device
- *
- * @fence_class:  Array of fence class managers.
- * @num_classes:  Array dimension of @fence_class.
- * @count:        Current number of fence objects for statistics.
- * @driver:       Driver struct.
- *
- * Provided in the driver interface so that the driver can derive
- * from this struct for its driver_private, and accordingly
- * access the driver_private from the fence driver callbacks.
- *
- * All members except "count" are initialized at creation and
- * never touched after that. No protection needed.
- *
- * This struct is private to the fence implementation and to the fence
- * driver callbacks, and may otherwise be used by drivers only to
- * obtain the derived device_private object using container_of().
- */
-
-struct ttm_fence_device {
-       struct ttm_mem_global *mem_glob;
-       struct ttm_fence_class_manager *fence_class;
-       uint32_t num_classes;
-       atomic_t count;
-       const struct ttm_fence_driver *driver;
-};
-
-/**
- * struct ttm_fence_class_init
- *
- * @wrap_diff:    Fence sequence number wrap indicator. If
- * (sequence1 - sequence2) > @wrap_diff, then sequence1 is
- * considered to be older than sequence2.
- * @flush_diff:   Fence sequence number flush indicator.
- * If a non-completely-signaled fence has a fence sequence number
- * sequence1 and (sequence1 - current_emit_sequence) > @flush_diff,
- * the fence is considered too old and it will be flushed upon the
- * next call of ttm_fence_flush_old(), to make sure no fences with
- * stale sequence numbers remains unsignaled. @flush_diff should
- * be sufficiently less than @wrap_diff.
- * @sequence_mask: Mask with valid bits of the fence sequence
- * number set to 1.
- *
- * This struct is used as input to ttm_fence_device_init.
- */
-
-struct ttm_fence_class_init {
-       uint32_t wrap_diff;
-       uint32_t flush_diff;
-       uint32_t sequence_mask;
-};
-
-/**
- * struct ttm_fence_driver
- *
- * @has_irq: Called by a potential waiter. Should return 1 if a
- * fence object with indicated parameters is expected to signal
- * automatically, and 0 if the fence implementation needs to
- * repeatedly call @poll to make it signal.
- * @emit:    Make sure a fence with the given parameters is
- * present in the indicated command stream. Return its sequence number
- * in "breadcrumb".
- * @poll:    Check and report sequences of the given "fence_class"
- *           that have signaled "types"
- * @flush:   Make sure that the types indicated by the bitfield
- *           ttm_fence_class_manager::pending_flush will eventually
- *           signal. These bits have been put together using the
- *           result from the needed_flush function described below.
- * @needed_flush: Given the fence_class and fence_types indicated by
- *           "fence", and the last received fence sequence of this
- *           fence class, indicate what types need a fence flush to
- *           signal. Return as a bitfield.
- * @wait:    Set to non-NULL if the driver wants to override the fence
- *           wait implementation. Return 0 on success, -EBUSY on failure,
- *           and -ERESTART if interruptible and a signal is pending.
- * @signaled:  Driver callback that is called whenever a
- *           ttm_fence_object::signaled_types has changed status.
- *           This function is called from atomic context,
- *           with the ttm_fence_class_manager::lock held in write mode.
- * @lockup:  Driver callback that is called whenever a wait has exceeded
- *           the lifetime of a fence object.
- *           If there is a GPU lockup,
- *           this function should, if possible, reset the GPU,
- *           call the ttm_fence_handler with an error status, and
- *           return. If no lockup was detected, simply extend the
- *           fence timeout_jiffies and return. The driver might
- *           want to protect the lockup check with a mutex and cache a
- *           non-locked-up status for a while to avoid an excessive
- *           amount of lockup checks from every waiting thread.
- */
-
-struct ttm_fence_driver {
-       bool (*has_irq) (struct ttm_fence_device *fdev,
-                       uint32_t fence_class, uint32_t flags);
-       int (*emit) (struct ttm_fence_device *fdev,
-                    uint32_t fence_class,
-                    uint32_t flags,
-                    uint32_t *breadcrumb, unsigned long *timeout_jiffies);
-       void (*flush) (struct ttm_fence_device *fdev, uint32_t fence_class);
-       void (*poll) (struct ttm_fence_device *fdev,
-                     uint32_t fence_class, uint32_t types);
-        uint32_t(*needed_flush)
-        (struct ttm_fence_object *fence);
-       int (*wait) (struct ttm_fence_object *fence, bool lazy,
-                    bool interruptible, uint32_t mask);
-       void (*signaled) (struct ttm_fence_object *fence);
-       void (*lockup) (struct ttm_fence_object *fence, uint32_t fence_types);
-};
-
-/**
- * function ttm_fence_device_init
- *
- * @num_classes:      Number of fence classes for this fence implementation.
- * @mem_global:       Pointer to the global memory accounting info.
- * @fdev:             Pointer to an uninitialised struct ttm_fence_device.
- * @init:             Array of initialization info for each fence class.
- * @replicate_init:   Use the first @init initialization info for all classes.
- * @driver:           Driver callbacks.
- *
- * Initialize a struct ttm_fence_driver structure. Returns -ENOMEM if
- * out-of-memory. Otherwise returns 0.
- */
-extern int
-ttm_fence_device_init(int num_classes,
-                     struct ttm_mem_global *mem_glob,
-                     struct ttm_fence_device *fdev,
-                     const struct ttm_fence_class_init *init,
-                     bool replicate_init,
-                     const struct ttm_fence_driver *driver);
-
-/**
- * function ttm_fence_device_release
- *
- * @fdev:             Pointer to the fence device.
- *
- * Release all resources held by a fence device. Note that before
- * this function is called, the caller must have made sure all fence
- * objects belonging to this fence device are completely signaled.
- */
-
-extern void ttm_fence_device_release(struct ttm_fence_device *fdev);
-
-/**
- * ttm_fence_handler - the fence handler.
- *
- * @fdev:        Pointer to the fence device.
- * @fence_class: Fence class that signals.
- * @sequence:    Signaled sequence.
- * @type:        Types that signal.
- * @error:       Error from the engine.
- *
- * This function signals all fences with a sequence previous to the
- * @sequence argument, and belonging to @fence_class. The signaled fence
- * types are provided in @type. If error is non-zero, the error member
- * of the fence with sequence = @sequence is set to @error. This value
- * may be reported back to user-space, indicating, for example an illegal
- * 3D command or illegal mpeg data.
- *
- * This function is typically called from the driver::poll method when the
- * command sequence preceding the fence marker has executed. It should be
- * called with the ttm_fence_class_manager::lock held in write mode and
- * may be called from interrupt context.
- */
-
-extern void
-ttm_fence_handler(struct ttm_fence_device *fdev,
-                 uint32_t fence_class,
-                 uint32_t sequence, uint32_t type, uint32_t error);
-
-/**
- * ttm_fence_driver_from_dev
- *
- * @fdev:        The ttm fence device.
- *
- * Returns a pointer to the fence driver struct.
- */
-
-static inline const struct ttm_fence_driver *ttm_fence_driver_from_dev(
-                                               struct ttm_fence_device *fdev)
-{
-       return fdev->driver;
-}
-
-/**
- * ttm_fence_driver
- *
- * @fence:        Pointer to a ttm fence object.
- *
- * Returns a pointer to the fence driver struct.
- */
-
-static inline const struct ttm_fence_driver *ttm_fence_driver(struct
-                                                             ttm_fence_object
-                                                             *fence)
-{
-       return ttm_fence_driver_from_dev(fence->fdev);
-}
-
-/**
- * ttm_fence_fc
- *
- * @fence:        Pointer to a ttm fence object.
- *
- * Returns a pointer to the struct ttm_fence_class_manager for the
- * fence class of @fence.
- */
-
-static inline struct ttm_fence_class_manager *ttm_fence_fc(struct
-                                                          ttm_fence_object
-                                                          *fence)
-{
-       return &fence->fdev->fence_class[fence->fence_class];
-}
-
-#endif
diff --git a/drivers/staging/gma500/psb_ttm_fence_user.c b/drivers/staging/gma500/psb_ttm_fence_user.c
deleted file mode 100644 (file)
index 36f974f..0000000
+++ /dev/null
@@ -1,237 +0,0 @@
-/**************************************************************************
- *
- * Copyright (c) 2006-2008 Tungsten Graphics, Inc., Cedar Park, TX., USA
- * All Rights Reserved.
- * Copyright (c) 2009 VMware, Inc., Palo Alto, CA., USA
- * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
- *
- **************************************************************************/
-/*
- * Authors: Thomas Hellstrom <thomas-at-tungstengraphics-dot-com>
- */
-
-#include <drm/drmP.h>
-#include "psb_ttm_fence_user.h"
-#include "ttm/ttm_object.h"
-#include "psb_ttm_fence_driver.h"
-#include "psb_ttm_userobj_api.h"
-
-/**
- * struct ttm_fence_user_object
- *
- * @base:    The base object used for user-space visibility and refcounting.
- *
- * @fence:   The fence object itself.
- *
- */
-
-struct ttm_fence_user_object {
-       struct ttm_base_object base;
-       struct ttm_fence_object fence;
-};
-
-static struct ttm_fence_user_object *ttm_fence_user_object_lookup(
-                                       struct ttm_object_file *tfile,
-                                       uint32_t handle)
-{
-       struct ttm_base_object *base;
-
-       base = ttm_base_object_lookup(tfile, handle);
-       if (unlikely(base == NULL)) {
-               printk(KERN_ERR "Invalid fence handle 0x%08lx\n",
-                      (unsigned long)handle);
-               return NULL;
-       }
-
-       if (unlikely(base->object_type != ttm_fence_type)) {
-               ttm_base_object_unref(&base);
-               printk(KERN_ERR "Invalid fence handle 0x%08lx\n",
-                      (unsigned long)handle);
-               return NULL;
-       }
-
-       return container_of(base, struct ttm_fence_user_object, base);
-}
-
-/*
- * The fence object destructor.
- */
-
-static void ttm_fence_user_destroy(struct ttm_fence_object *fence)
-{
-       struct ttm_fence_user_object *ufence =
-           container_of(fence, struct ttm_fence_user_object, fence);
-
-       ttm_mem_global_free(fence->fdev->mem_glob, sizeof(*ufence));
-       kfree(ufence);
-}
-
-/*
- * The base object destructor. We basically unly unreference the
- * attached fence object.
- */
-
-static void ttm_fence_user_release(struct ttm_base_object **p_base)
-{
-       struct ttm_fence_user_object *ufence;
-       struct ttm_base_object *base = *p_base;
-       struct ttm_fence_object *fence;
-
-       *p_base = NULL;
-
-       if (unlikely(base == NULL))
-               return;
-
-       ufence = container_of(base, struct ttm_fence_user_object, base);
-       fence = &ufence->fence;
-       ttm_fence_object_unref(&fence);
-}
-
-int
-ttm_fence_user_create(struct ttm_fence_device *fdev,
-                     struct ttm_object_file *tfile,
-                     uint32_t fence_class,
-                     uint32_t fence_types,
-                     uint32_t create_flags,
-                     struct ttm_fence_object **fence,
-                     uint32_t *user_handle)
-{
-       int ret;
-       struct ttm_fence_object *tmp;
-       struct ttm_fence_user_object *ufence;
-
-       ret = ttm_mem_global_alloc(fdev->mem_glob,
-                                  sizeof(*ufence),
-                                  false,
-                                  false);
-       if (unlikely(ret != 0))
-               return -ENOMEM;
-
-       ufence = kmalloc(sizeof(*ufence), GFP_KERNEL);
-       if (unlikely(ufence == NULL)) {
-               ttm_mem_global_free(fdev->mem_glob, sizeof(*ufence));
-               return -ENOMEM;
-       }
-
-       ret = ttm_fence_object_init(fdev,
-                                   fence_class,
-                                   fence_types, create_flags,
-                                   &ttm_fence_user_destroy, &ufence->fence);
-
-       if (unlikely(ret != 0))
-               goto out_err0;
-
-       /*
-        * One fence ref is held by the fence ptr we return.
-        * The other one by the base object. Need to up the
-        * fence refcount before we publish this object to
-        * user-space.
-        */
-
-       tmp = ttm_fence_object_ref(&ufence->fence);
-       ret = ttm_base_object_init(tfile, &ufence->base,
-                                  false, ttm_fence_type,
-                                  &ttm_fence_user_release, NULL);
-
-       if (unlikely(ret != 0))
-               goto out_err1;
-
-       *fence = &ufence->fence;
-       *user_handle = ufence->base.hash.key;
-
-       return 0;
-out_err1:
-       ttm_fence_object_unref(&tmp);
-       tmp = &ufence->fence;
-       ttm_fence_object_unref(&tmp);
-       return ret;
-out_err0:
-       ttm_mem_global_free(fdev->mem_glob, sizeof(*ufence));
-       kfree(ufence);
-       return ret;
-}
-
-int ttm_fence_signaled_ioctl(struct ttm_object_file *tfile, void *data)
-{
-       int ret;
-       union ttm_fence_signaled_arg *arg = data;
-       struct ttm_fence_object *fence;
-       struct ttm_fence_info info;
-       struct ttm_fence_user_object *ufence;
-       struct ttm_base_object *base;
-       ret = 0;
-
-       ufence = ttm_fence_user_object_lookup(tfile, arg->req.handle);
-       if (unlikely(ufence == NULL))
-               return -EINVAL;
-
-       fence = &ufence->fence;
-
-       if (arg->req.flush) {
-               ret = ttm_fence_object_flush(fence, arg->req.fence_type);
-               if (unlikely(ret != 0))
-                       goto out;
-       }
-
-       info = ttm_fence_get_info(fence);
-       arg->rep.signaled_types = info.signaled_types;
-       arg->rep.fence_error = info.error;
-
-out:
-       base = &ufence->base;
-       ttm_base_object_unref(&base);
-       return ret;
-}
-
-int ttm_fence_finish_ioctl(struct ttm_object_file *tfile, void *data)
-{
-       int ret;
-       union ttm_fence_finish_arg *arg = data;
-       struct ttm_fence_user_object *ufence;
-       struct ttm_base_object *base;
-       struct ttm_fence_object *fence;
-       ret = 0;
-
-       ufence = ttm_fence_user_object_lookup(tfile, arg->req.handle);
-       if (unlikely(ufence == NULL))
-               return -EINVAL;
-
-       fence = &ufence->fence;
-
-       ret = ttm_fence_object_wait(fence,
-                                   arg->req.mode & TTM_FENCE_FINISH_MODE_LAZY,
-                                   true, arg->req.fence_type);
-       if (likely(ret == 0)) {
-               struct ttm_fence_info info = ttm_fence_get_info(fence);
-
-               arg->rep.signaled_types = info.signaled_types;
-               arg->rep.fence_error = info.error;
-       }
-
-       base = &ufence->base;
-       ttm_base_object_unref(&base);
-
-       return ret;
-}
-
-int ttm_fence_unref_ioctl(struct ttm_object_file *tfile, void *data)
-{
-       struct ttm_fence_unref_arg *arg = data;
-       int ret = 0;
-
-       ret = ttm_ref_object_base_unref(tfile, arg->handle, ttm_fence_type);
-       return ret;
-}
diff --git a/drivers/staging/gma500/psb_ttm_fence_user.h b/drivers/staging/gma500/psb_ttm_fence_user.h
deleted file mode 100644 (file)
index 762a057..0000000
+++ /dev/null
@@ -1,140 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2006-2008 Tungsten Graphics, Inc., Cedar Park, TX., USA
- * All Rights Reserved.
- * Copyright (c) 2009 VMware, Inc., Palo Alto, CA., USA
- * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
- *
- **************************************************************************/
-/*
- * Authors
- * Thomas Hellström <thomas-at-tungstengraphics-dot-com>
- */
-
-#ifndef TTM_FENCE_USER_H
-#define TTM_FENCE_USER_H
-
-#if !defined(__KERNEL__) && !defined(_KERNEL)
-#include <stdint.h>
-#endif
-
-#define TTM_FENCE_MAJOR 0
-#define TTM_FENCE_MINOR 1
-#define TTM_FENCE_PL    0
-#define TTM_FENCE_DATE  "080819"
-
-/**
- * struct ttm_fence_signaled_req
- *
- * @handle: Handle to the fence object. Input.
- *
- * @fence_type: Fence types we want to flush. Input.
- *
- * @flush: Boolean. Flush the indicated fence_types. Input.
- *
- * Argument to the TTM_FENCE_SIGNALED ioctl.
- */
-
-struct ttm_fence_signaled_req {
-       uint32_t handle;
-       uint32_t fence_type;
-       int32_t flush;
-       uint32_t pad64;
-};
-
-/**
- * struct ttm_fence_rep
- *
- * @signaled_types: Fence type that has signaled.
- *
- * @fence_error: Command execution error.
- * Hardware errors that are consequences of the execution
- * of the command stream preceding the fence are reported
- * here.
- *
- * Output argument to the TTM_FENCE_SIGNALED and
- * TTM_FENCE_FINISH ioctls.
- */
-
-struct ttm_fence_rep {
-       uint32_t signaled_types;
-       uint32_t fence_error;
-};
-
-union ttm_fence_signaled_arg {
-       struct ttm_fence_signaled_req req;
-       struct ttm_fence_rep rep;
-};
-
-/*
- * Waiting mode flags for the TTM_FENCE_FINISH ioctl.
- *
- * TTM_FENCE_FINISH_MODE_LAZY: Allow for sleeps during polling
- * wait.
- *
- * TTM_FENCE_FINISH_MODE_NO_BLOCK: Don't block waiting for GPU,
- * but return -EBUSY if the buffer is busy.
- */
-
-#define TTM_FENCE_FINISH_MODE_LAZY     (1 << 0)
-#define TTM_FENCE_FINISH_MODE_NO_BLOCK (1 << 1)
-
-/**
- * struct ttm_fence_finish_req
- *
- * @handle: Handle to the fence object. Input.
- *
- * @fence_type: Fence types we want to finish.
- *
- * @mode: Wait mode.
- *
- * Input to the TTM_FENCE_FINISH ioctl.
- */
-
-struct ttm_fence_finish_req {
-       uint32_t handle;
-       uint32_t fence_type;
-       uint32_t mode;
-       uint32_t pad64;
-};
-
-union ttm_fence_finish_arg {
-       struct ttm_fence_finish_req req;
-       struct ttm_fence_rep rep;
-};
-
-/**
- * struct ttm_fence_unref_arg
- *
- * @handle: Handle to the fence object.
- *
- * Argument to the TTM_FENCE_UNREF ioctl.
- */
-
-struct ttm_fence_unref_arg {
-       uint32_t handle;
-       uint32_t pad64;
-};
-
-/*
- * Ioctl offsets from extenstion start.
- */
-
-#define TTM_FENCE_SIGNALED 0x01
-#define TTM_FENCE_FINISH   0x02
-#define TTM_FENCE_UNREF    0x03
-
-#endif
diff --git a/drivers/staging/gma500/psb_ttm_glue.c b/drivers/staging/gma500/psb_ttm_glue.c
deleted file mode 100644 (file)
index d1d965e..0000000
+++ /dev/null
@@ -1,349 +0,0 @@
-/**************************************************************************
- * Copyright (c) 2008, Intel Corporation.
- * All Rights Reserved.
- * Copyright (c) 2008, Tungsten Graphics Inc.  Cedar Park, TX., USA.
- * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
- *
- **************************************************************************/
-
-
-#include <drm/drmP.h>
-#include "psb_drv.h"
-#include "psb_ttm_userobj_api.h"
-#include <linux/io.h>
-
-
-static struct vm_operations_struct psb_ttm_vm_ops;
-
-/**
- * NOTE: driver_private of drm_file is now a struct psb_file_data struct
- * pPriv in struct psb_file_data contains the original psb_fpriv;
- */
-int psb_open(struct inode *inode, struct file *filp)
-{
-       struct drm_file *file_priv;
-       struct drm_psb_private *dev_priv;
-       struct psb_fpriv *psb_fp;
-       struct psb_file_data *pvr_file_priv;
-       int ret;
-
-       DRM_DEBUG("\n");
-
-       ret = drm_open(inode, filp);
-       if (unlikely(ret))
-               return ret;
-
-       psb_fp = kzalloc(sizeof(*psb_fp), GFP_KERNEL);
-
-       if (unlikely(psb_fp == NULL))
-               goto out_err0;
-
-       file_priv = (struct drm_file *) filp->private_data;
-       dev_priv = psb_priv(file_priv->minor->dev);
-
-       DRM_DEBUG("is_master %d\n", file_priv->is_master ? 1 : 0);
-
-       psb_fp->tfile = ttm_object_file_init(dev_priv->tdev,
-                                            PSB_FILE_OBJECT_HASH_ORDER);
-       if (unlikely(psb_fp->tfile == NULL))
-               goto out_err1;
-
-       pvr_file_priv = (struct psb_file_data *)file_priv->driver_priv;
-       if (!pvr_file_priv) {
-               DRM_ERROR("drm file private is NULL\n");
-               goto out_err1;
-       }
-
-       pvr_file_priv->priv = psb_fp;
-       if (unlikely(dev_priv->bdev.dev_mapping == NULL))
-               dev_priv->bdev.dev_mapping = dev_priv->dev->dev_mapping;
-
-       return 0;
-
-out_err1:
-       kfree(psb_fp);
-out_err0:
-       (void) drm_release(inode, filp);
-       return ret;
-}
-
-int psb_release(struct inode *inode, struct file *filp)
-{
-       struct drm_file *file_priv;
-       struct psb_fpriv *psb_fp;
-       struct drm_psb_private *dev_priv;
-       int ret;
-       file_priv = (struct drm_file *) filp->private_data;
-       psb_fp = psb_fpriv(file_priv);
-       dev_priv = psb_priv(file_priv->minor->dev);
-
-       ttm_object_file_release(&psb_fp->tfile);
-       kfree(psb_fp);
-
-       ret = drm_release(inode, filp);
-
-       return ret;
-}
-
-int psb_fence_signaled_ioctl(struct drm_device *dev, void *data,
-                            struct drm_file *file_priv)
-{
-
-       return ttm_fence_signaled_ioctl(psb_fpriv(file_priv)->tfile, data);
-}
-
-int psb_fence_finish_ioctl(struct drm_device *dev, void *data,
-                          struct drm_file *file_priv)
-{
-       return ttm_fence_finish_ioctl(psb_fpriv(file_priv)->tfile, data);
-}
-
-int psb_fence_unref_ioctl(struct drm_device *dev, void *data,
-                         struct drm_file *file_priv)
-{
-       return ttm_fence_unref_ioctl(psb_fpriv(file_priv)->tfile, data);
-}
-
-int psb_pl_waitidle_ioctl(struct drm_device *dev, void *data,
-                         struct drm_file *file_priv)
-{
-       return ttm_pl_waitidle_ioctl(psb_fpriv(file_priv)->tfile, data);
-}
-
-int psb_pl_setstatus_ioctl(struct drm_device *dev, void *data,
-                          struct drm_file *file_priv)
-{
-       return ttm_pl_setstatus_ioctl(psb_fpriv(file_priv)->tfile,
-                                     &psb_priv(dev)->ttm_lock, data);
-
-}
-
-int psb_pl_synccpu_ioctl(struct drm_device *dev, void *data,
-                        struct drm_file *file_priv)
-{
-       return ttm_pl_synccpu_ioctl(psb_fpriv(file_priv)->tfile, data);
-}
-
-int psb_pl_unref_ioctl(struct drm_device *dev, void *data,
-                      struct drm_file *file_priv)
-{
-       return ttm_pl_unref_ioctl(psb_fpriv(file_priv)->tfile, data);
-
-}
-
-int psb_pl_reference_ioctl(struct drm_device *dev, void *data,
-                          struct drm_file *file_priv)
-{
-       return  ttm_pl_reference_ioctl(psb_fpriv(file_priv)->tfile, data);
-
-}
-
-int psb_pl_create_ioctl(struct drm_device *dev, void *data,
-                       struct drm_file *file_priv)
-{
-       struct drm_psb_private *dev_priv = psb_priv(dev);
-
-       return ttm_pl_create_ioctl(psb_fpriv(file_priv)->tfile,
-                                  &dev_priv->bdev, &dev_priv->ttm_lock, data);
-
-}
-
-int psb_pl_ub_create_ioctl(struct drm_device *dev, void *data,
-                       struct drm_file *file_priv)
-{
-       struct drm_psb_private *dev_priv = psb_priv(dev);
-
-       return ttm_pl_ub_create_ioctl(psb_fpriv(file_priv)->tfile,
-                                  &dev_priv->bdev, &dev_priv->ttm_lock, data);
-
-}
-/**
- * psb_ttm_fault - Wrapper around the ttm fault method.
- *
- * @vma: The struct vm_area_struct as in the vm fault() method.
- * @vmf: The struct vm_fault as in the vm fault() method.
- *
- * Since ttm_fault() will reserve buffers while faulting,
- * we need to take the ttm read lock around it, as this driver
- * relies on the ttm_lock in write mode to exclude all threads from
- * reserving and thus validating buffers in aperture- and memory shortage
- * situations.
- */
-
-static int psb_ttm_fault(struct vm_area_struct *vma,
-                        struct vm_fault *vmf)
-{
-       struct ttm_buffer_object *bo = (struct ttm_buffer_object *)
-               vma->vm_private_data;
-       struct drm_psb_private *dev_priv =
-               container_of(bo->bdev, struct drm_psb_private, bdev);
-       int ret;
-
-       ret = ttm_read_lock(&dev_priv->ttm_lock, true);
-       if (unlikely(ret != 0))
-               return VM_FAULT_NOPAGE;
-
-       ret = dev_priv->ttm_vm_ops->fault(vma, vmf);
-
-       ttm_read_unlock(&dev_priv->ttm_lock);
-       return ret;
-}
-
-/**
- * if vm_pgoff < DRM_PSB_FILE_PAGE_OFFSET call directly to
- * PVRMMap
- */
-int psb_mmap(struct file *filp, struct vm_area_struct *vma)
-{
-       struct drm_file *file_priv;
-       struct drm_psb_private *dev_priv;
-       int ret;
-
-       if (vma->vm_pgoff < DRM_PSB_FILE_PAGE_OFFSET ||
-           vma->vm_pgoff > 2 * DRM_PSB_FILE_PAGE_OFFSET)
-#if 0          /* FIXMEAC */
-               return PVRMMap(filp, vma);
-#else
-               return -EINVAL;
-#endif
-
-       file_priv = (struct drm_file *) filp->private_data;
-       dev_priv = psb_priv(file_priv->minor->dev);
-
-       ret = ttm_bo_mmap(filp, vma, &dev_priv->bdev);
-       if (unlikely(ret != 0))
-               return ret;
-
-       if (unlikely(dev_priv->ttm_vm_ops == NULL)) {
-               dev_priv->ttm_vm_ops = (struct vm_operations_struct *)
-                                                               vma->vm_ops;
-               psb_ttm_vm_ops = *vma->vm_ops;
-               psb_ttm_vm_ops.fault = &psb_ttm_fault;
-       }
-
-       vma->vm_ops = &psb_ttm_vm_ops;
-
-       return 0;
-}
-/*
-ssize_t psb_ttm_write(struct file *filp, const char __user *buf,
-                     size_t count, loff_t *f_pos)
-{
-       struct drm_file *file_priv = (struct drm_file *)filp->private_data;
-       struct drm_psb_private *dev_priv = psb_priv(file_priv->minor->dev);
-
-       return ttm_bo_io(&dev_priv->bdev, filp, buf, NULL, count, f_pos, 1);
-}
-
-ssize_t psb_ttm_read(struct file *filp, char __user *buf,
-                    size_t count, loff_t *f_pos)
-{
-       struct drm_file *file_priv = (struct drm_file *)filp->private_data;
-       struct drm_psb_private *dev_priv = psb_priv(file_priv->minor->dev);
-
-       return ttm_bo_io(&dev_priv->bdev, filp, NULL, buf, count, f_pos, 1);
-}
-*/
-int psb_verify_access(struct ttm_buffer_object *bo,
-                     struct file *filp)
-{
-       struct drm_file *file_priv = (struct drm_file *)filp->private_data;
-
-       if (capable(CAP_SYS_ADMIN))
-               return 0;
-
-       if (unlikely(!file_priv->authenticated))
-               return -EPERM;
-
-       return ttm_pl_verify_access(bo, psb_fpriv(file_priv)->tfile);
-}
-
-static int psb_ttm_mem_global_init(struct drm_global_reference *ref)
-{
-       return ttm_mem_global_init(ref->object);
-}
-
-static void psb_ttm_mem_global_release(struct drm_global_reference *ref)
-{
-       ttm_mem_global_release(ref->object);
-}
-
-int psb_ttm_global_init(struct drm_psb_private *dev_priv)
-{
-       struct drm_global_reference *global_ref;
-       int ret;
-
-       global_ref = &dev_priv->mem_global_ref;
-       global_ref->global_type = DRM_GLOBAL_TTM_MEM;
-       global_ref->size = sizeof(struct ttm_mem_global);
-       global_ref->init = &psb_ttm_mem_global_init;
-       global_ref->release = &psb_ttm_mem_global_release;
-
-       ret = drm_global_item_ref(global_ref);
-       if (unlikely(ret != 0)) {
-               DRM_ERROR("Failed referencing a global TTM memory object.\n");
-               return ret;
-       }
-
-       dev_priv->bo_global_ref.mem_glob = dev_priv->mem_global_ref.object;
-       global_ref = &dev_priv->bo_global_ref.ref;
-       global_ref->global_type = DRM_GLOBAL_TTM_BO;
-       global_ref->size = sizeof(struct ttm_bo_global);
-       global_ref->init = &ttm_bo_global_init;
-       global_ref->release = &ttm_bo_global_release;
-       ret = drm_global_item_ref(global_ref);
-       if (ret != 0) {
-               DRM_ERROR("Failed setting up TTM BO subsystem.\n");
-               drm_global_item_unref(global_ref);
-               return ret;
-       }
-       return 0;
-}
-
-void psb_ttm_global_release(struct drm_psb_private *dev_priv)
-{
-       drm_global_item_unref(&dev_priv->mem_global_ref);
-}
-
-int psb_getpageaddrs_ioctl(struct drm_device *dev, void *data,
-               struct drm_file *file_priv)
-{
-       struct drm_psb_getpageaddrs_arg *arg = data;
-       struct ttm_buffer_object *bo;
-       struct ttm_tt *ttm;
-       struct page **tt_pages;
-       unsigned long i, num_pages;
-       unsigned long *p = arg->page_addrs;
-       int ret = 0;
-
-       bo = ttm_buffer_object_lookup(psb_fpriv(file_priv)->tfile,
-                                       arg->handle);
-       if (unlikely(bo == NULL)) {
-               printk(KERN_ERR
-                       "Could not find buffer object for getpageaddrs.\n");
-               return -EINVAL;
-       }
-
-       arg->gtt_offset = bo->offset;
-       ttm = bo->ttm;
-       num_pages = ttm->num_pages;
-       tt_pages = ttm->pages;
-
-       for (i = 0; i < num_pages; i++)
-               p[i] = (unsigned long)page_to_phys(tt_pages[i]);
-
-       return ret;
-}
diff --git a/drivers/staging/gma500/psb_ttm_placement_user.c b/drivers/staging/gma500/psb_ttm_placement_user.c
deleted file mode 100644 (file)
index 272b397..0000000
+++ /dev/null
@@ -1,628 +0,0 @@
-/**************************************************************************
- *
- * Copyright (c) 2006-2008 Tungsten Graphics, Inc., Cedar Park, TX., USA
- * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
- *
- **************************************************************************/
-/*
- * Authors: Thomas Hellstrom <thomas-at-tungstengraphics-dot-com>
- */
-
-#include "psb_ttm_placement_user.h"
-#include "ttm/ttm_bo_driver.h"
-#include "ttm/ttm_object.h"
-#include "psb_ttm_userobj_api.h"
-#include "ttm/ttm_lock.h"
-#include <linux/slab.h>
-#include <linux/sched.h>
-
-struct ttm_bo_user_object {
-       struct ttm_base_object base;
-       struct ttm_buffer_object bo;
-};
-
-static size_t pl_bo_size;
-
-static uint32_t psb_busy_prios[] = {
-       TTM_PL_TT,
-       TTM_PL_PRIV0, /* CI */
-       TTM_PL_PRIV2, /* RAR */
-       TTM_PL_PRIV1, /* DRM_PSB_MEM_MMU */
-       TTM_PL_SYSTEM
-};
-
-static const struct ttm_placement default_placement = {
-                               0, 0, 0, NULL, 5, psb_busy_prios
-};
-
-static size_t ttm_pl_size(struct ttm_bo_device *bdev, unsigned long num_pages)
-{
-       size_t page_array_size =
-           (num_pages * sizeof(void *) + PAGE_SIZE - 1) & PAGE_MASK;
-
-       if (unlikely(pl_bo_size == 0)) {
-               pl_bo_size = bdev->glob->ttm_bo_extra_size +
-                   ttm_round_pot(sizeof(struct ttm_bo_user_object));
-       }
-
-       return bdev->glob->ttm_bo_size + 2 * page_array_size;
-}
-
-static struct ttm_bo_user_object *ttm_bo_user_lookup(struct ttm_object_file
-                                                    *tfile, uint32_t handle)
-{
-       struct ttm_base_object *base;
-
-       base = ttm_base_object_lookup(tfile, handle);
-       if (unlikely(base == NULL)) {
-               printk(KERN_ERR "Invalid buffer object handle 0x%08lx.\n",
-                      (unsigned long)handle);
-               return NULL;
-       }
-
-       if (unlikely(base->object_type != ttm_buffer_type)) {
-               ttm_base_object_unref(&base);
-               printk(KERN_ERR "Invalid buffer object handle 0x%08lx.\n",
-                      (unsigned long)handle);
-               return NULL;
-       }
-
-       return container_of(base, struct ttm_bo_user_object, base);
-}
-
-struct ttm_buffer_object *ttm_buffer_object_lookup(struct ttm_object_file
-                                                  *tfile, uint32_t handle)
-{
-       struct ttm_bo_user_object *user_bo;
-       struct ttm_base_object *base;
-
-       user_bo = ttm_bo_user_lookup(tfile, handle);
-       if (unlikely(user_bo == NULL))
-               return NULL;
-
-       (void)ttm_bo_reference(&user_bo->bo);
-       base = &user_bo->base;
-       ttm_base_object_unref(&base);
-       return &user_bo->bo;
-}
-
-static void ttm_bo_user_destroy(struct ttm_buffer_object *bo)
-{
-       struct ttm_bo_user_object *user_bo =
-           container_of(bo, struct ttm_bo_user_object, bo);
-
-       ttm_mem_global_free(bo->glob->mem_glob, bo->acc_size);
-       kfree(user_bo);
-}
-
-static void ttm_bo_user_release(struct ttm_base_object **p_base)
-{
-       struct ttm_bo_user_object *user_bo;
-       struct ttm_base_object *base = *p_base;
-       struct ttm_buffer_object *bo;
-
-       *p_base = NULL;
-
-       if (unlikely(base == NULL))
-               return;
-
-       user_bo = container_of(base, struct ttm_bo_user_object, base);
-       bo = &user_bo->bo;
-       ttm_bo_unref(&bo);
-}
-
-static void ttm_bo_user_ref_release(struct ttm_base_object *base,
-                                   enum ttm_ref_type ref_type)
-{
-       struct ttm_bo_user_object *user_bo =
-           container_of(base, struct ttm_bo_user_object, base);
-       struct ttm_buffer_object *bo = &user_bo->bo;
-
-       switch (ref_type) {
-       case TTM_REF_SYNCCPU_WRITE:
-               ttm_bo_synccpu_write_release(bo);
-               break;
-       default:
-               BUG();
-       }
-}
-
-static void ttm_pl_fill_rep(struct ttm_buffer_object *bo,
-                           struct ttm_pl_rep *rep)
-{
-       struct ttm_bo_user_object *user_bo =
-           container_of(bo, struct ttm_bo_user_object, bo);
-
-       rep->gpu_offset = bo->offset;
-       rep->bo_size = bo->num_pages << PAGE_SHIFT;
-       rep->map_handle = bo->addr_space_offset;
-       rep->placement = bo->mem.placement;
-       rep->handle = user_bo->base.hash.key;
-       rep->sync_object_arg = (uint32_t) (unsigned long)bo->sync_obj_arg;
-}
-
-/* FIXME Copy from upstream TTM */
-static inline size_t ttm_bo_size(struct ttm_bo_global *glob,
-                                unsigned long num_pages)
-{
-       size_t page_array_size = (num_pages * sizeof(void *) + PAGE_SIZE - 1) &
-           PAGE_MASK;
-
-       return glob->ttm_bo_size + 2 * page_array_size;
-}
-
-/* FIXME Copy from upstream TTM "ttm_bo_create", upstream TTM does not
-   export this, so copy it here */
-static int ttm_bo_create_private(struct ttm_bo_device *bdev,
-                       unsigned long size,
-                       enum ttm_bo_type type,
-                       struct ttm_placement *placement,
-                       uint32_t page_alignment,
-                       unsigned long buffer_start,
-                       bool interruptible,
-                       struct file *persistant_swap_storage,
-                       struct ttm_buffer_object **p_bo)
-{
-       struct ttm_buffer_object *bo;
-       struct ttm_mem_global *mem_glob = bdev->glob->mem_glob;
-       int ret;
-
-       size_t acc_size =
-           ttm_bo_size(bdev->glob, (size + PAGE_SIZE - 1) >> PAGE_SHIFT);
-       ret = ttm_mem_global_alloc(mem_glob, acc_size, false, false);
-       if (unlikely(ret != 0))
-               return ret;
-
-       bo = kzalloc(sizeof(*bo), GFP_KERNEL);
-
-       if (unlikely(bo == NULL)) {
-               ttm_mem_global_free(mem_glob, acc_size);
-               return -ENOMEM;
-       }
-
-       ret = ttm_bo_init(bdev, bo, size, type, placement, page_alignment,
-                               buffer_start, interruptible,
-                               persistant_swap_storage, acc_size, NULL);
-       if (likely(ret == 0))
-               *p_bo = bo;
-
-       return ret;
-}
-
-int psb_ttm_bo_check_placement(struct ttm_buffer_object *bo,
-                               struct ttm_placement *placement)
-{
-       int i;
-
-       for (i = 0; i < placement->num_placement; i++) {
-               if (!capable(CAP_SYS_ADMIN)) {
-                       if (placement->placement[i] & TTM_PL_FLAG_NO_EVICT) {
-                               printk(KERN_ERR TTM_PFX "Need to be root to "
-                                       "modify NO_EVICT status.\n");
-                               return -EINVAL;
-                       }
-               }
-       }
-       for (i = 0; i < placement->num_busy_placement; i++) {
-               if (!capable(CAP_SYS_ADMIN)) {
-                       if (placement->busy_placement[i]
-                                               & TTM_PL_FLAG_NO_EVICT) {
-                               printk(KERN_ERR TTM_PFX "Need to be root to modify NO_EVICT status.\n");
-                               return -EINVAL;
-                       }
-               }
-       }
-       return 0;
-}
-
-int ttm_buffer_object_create(struct ttm_bo_device *bdev,
-                       unsigned long size,
-                       enum ttm_bo_type type,
-                       uint32_t flags,
-                       uint32_t page_alignment,
-                       unsigned long buffer_start,
-                       bool interruptible,
-                       struct file *persistant_swap_storage,
-                       struct ttm_buffer_object **p_bo)
-{
-       struct ttm_placement placement = default_placement;
-       int ret;
-
-       if ((flags & TTM_PL_MASK_CACHING) == 0)
-               flags |= TTM_PL_FLAG_WC | TTM_PL_FLAG_UNCACHED;
-
-       placement.num_placement = 1;
-       placement.placement = &flags;
-
-       ret = ttm_bo_create_private(bdev,
-                       size,
-                       type,
-                       &placement,
-                       page_alignment,
-                       buffer_start,
-                       interruptible,
-                       persistant_swap_storage,
-                       p_bo);
-
-       return ret;
-}
-
-
-int ttm_pl_create_ioctl(struct ttm_object_file *tfile,
-                       struct ttm_bo_device *bdev,
-                       struct ttm_lock *lock, void *data)
-{
-       union ttm_pl_create_arg *arg = data;
-       struct ttm_pl_create_req *req = &arg->req;
-       struct ttm_pl_rep *rep = &arg->rep;
-       struct ttm_buffer_object *bo;
-       struct ttm_buffer_object *tmp;
-       struct ttm_bo_user_object *user_bo;
-       uint32_t flags;
-       int ret = 0;
-       struct ttm_mem_global *mem_glob = bdev->glob->mem_glob;
-       struct ttm_placement placement = default_placement;
-       size_t acc_size =
-           ttm_pl_size(bdev, (req->size + PAGE_SIZE - 1) >> PAGE_SHIFT);
-       ret = ttm_mem_global_alloc(mem_glob, acc_size, false, false);
-       if (unlikely(ret != 0))
-               return ret;
-
-       flags = req->placement;
-       user_bo = kzalloc(sizeof(*user_bo), GFP_KERNEL);
-       if (unlikely(user_bo == NULL)) {
-               ttm_mem_global_free(mem_glob, acc_size);
-               return -ENOMEM;
-       }
-
-       bo = &user_bo->bo;
-       ret = ttm_read_lock(lock, true);
-       if (unlikely(ret != 0)) {
-               ttm_mem_global_free(mem_glob, acc_size);
-               kfree(user_bo);
-               return ret;
-       }
-
-       placement.num_placement = 1;
-       placement.placement = &flags;
-
-       if ((flags & TTM_PL_MASK_CACHING) == 0)
-               flags |=  TTM_PL_FLAG_WC | TTM_PL_FLAG_UNCACHED;
-
-       ret = ttm_bo_init(bdev, bo, req->size,
-                                    ttm_bo_type_device, &placement,
-                                    req->page_alignment, 0, true,
-                                    NULL, acc_size, &ttm_bo_user_destroy);
-       ttm_read_unlock(lock);
-
-       /*
-        * Note that the ttm_buffer_object_init function
-        * would've called the destroy function on failure!!
-        */
-
-       if (unlikely(ret != 0))
-               goto out;
-
-       tmp = ttm_bo_reference(bo);
-       ret = ttm_base_object_init(tfile, &user_bo->base,
-                                  flags & TTM_PL_FLAG_SHARED,
-                                  ttm_buffer_type,
-                                  &ttm_bo_user_release,
-                                  &ttm_bo_user_ref_release);
-       if (unlikely(ret != 0))
-               goto out_err;
-
-       ttm_pl_fill_rep(bo, rep);
-       ttm_bo_unref(&bo);
-out:
-       return 0;
-out_err:
-       ttm_bo_unref(&tmp);
-       ttm_bo_unref(&bo);
-       return ret;
-}
-
-int ttm_pl_ub_create_ioctl(struct ttm_object_file *tfile,
-                          struct ttm_bo_device *bdev,
-                          struct ttm_lock *lock, void *data)
-{
-       union ttm_pl_create_ub_arg *arg = data;
-       struct ttm_pl_create_ub_req *req = &arg->req;
-       struct ttm_pl_rep *rep = &arg->rep;
-       struct ttm_buffer_object *bo;
-       struct ttm_buffer_object *tmp;
-       struct ttm_bo_user_object *user_bo;
-       uint32_t flags;
-       int ret = 0;
-       struct ttm_mem_global *mem_glob = bdev->glob->mem_glob;
-       struct ttm_placement placement = default_placement;
-       size_t acc_size =
-           ttm_pl_size(bdev, (req->size + PAGE_SIZE - 1) >> PAGE_SHIFT);
-       ret = ttm_mem_global_alloc(mem_glob, acc_size, false, false);
-       if (unlikely(ret != 0))
-               return ret;
-
-       flags = req->placement;
-       user_bo = kzalloc(sizeof(*user_bo), GFP_KERNEL);
-       if (unlikely(user_bo == NULL)) {
-               ttm_mem_global_free(mem_glob, acc_size);
-               return -ENOMEM;
-       }
-       ret = ttm_read_lock(lock, true);
-       if (unlikely(ret != 0)) {
-               ttm_mem_global_free(mem_glob, acc_size);
-               kfree(user_bo);
-               return ret;
-       }
-       bo = &user_bo->bo;
-
-       placement.num_placement = 1;
-       placement.placement = &flags;
-
-       ret = ttm_bo_init(bdev,
-                                       bo,
-                                       req->size,
-                                       ttm_bo_type_user,
-                                       &placement,
-                                       req->page_alignment,
-                                       req->user_address,
-                                       true,
-                                       NULL,
-                                       acc_size,
-                                       &ttm_bo_user_destroy);
-
-       /*
-        * Note that the ttm_buffer_object_init function
-        * would've called the destroy function on failure!!
-        */
-       ttm_read_unlock(lock);
-       if (unlikely(ret != 0))
-               goto out;
-
-       tmp = ttm_bo_reference(bo);
-       ret = ttm_base_object_init(tfile, &user_bo->base,
-                                  flags & TTM_PL_FLAG_SHARED,
-                                  ttm_buffer_type,
-                                  &ttm_bo_user_release,
-                                  &ttm_bo_user_ref_release);
-       if (unlikely(ret != 0))
-               goto out_err;
-
-       ttm_pl_fill_rep(bo, rep);
-       ttm_bo_unref(&bo);
-out:
-       return 0;
-out_err:
-       ttm_bo_unref(&tmp);
-       ttm_bo_unref(&bo);
-       return ret;
-}
-
-int ttm_pl_reference_ioctl(struct ttm_object_file *tfile, void *data)
-{
-       union ttm_pl_reference_arg *arg = data;
-       struct ttm_pl_rep *rep = &arg->rep;
-       struct ttm_bo_user_object *user_bo;
-       struct ttm_buffer_object *bo;
-       struct ttm_base_object *base;
-       int ret;
-
-       user_bo = ttm_bo_user_lookup(tfile, arg->req.handle);
-       if (unlikely(user_bo == NULL)) {
-               printk(KERN_ERR "Could not reference buffer object.\n");
-               return -EINVAL;
-       }
-
-       bo = &user_bo->bo;
-       ret = ttm_ref_object_add(tfile, &user_bo->base, TTM_REF_USAGE, NULL);
-       if (unlikely(ret != 0)) {
-               printk(KERN_ERR
-                      "Could not add a reference to buffer object.\n");
-               goto out;
-       }
-
-       ttm_pl_fill_rep(bo, rep);
-
-out:
-       base = &user_bo->base;
-       ttm_base_object_unref(&base);
-       return ret;
-}
-
-int ttm_pl_unref_ioctl(struct ttm_object_file *tfile, void *data)
-{
-       struct ttm_pl_reference_req *arg = data;
-
-       return ttm_ref_object_base_unref(tfile, arg->handle, TTM_REF_USAGE);
-}
-
-int ttm_pl_synccpu_ioctl(struct ttm_object_file *tfile, void *data)
-{
-       struct ttm_pl_synccpu_arg *arg = data;
-       struct ttm_bo_user_object *user_bo;
-       struct ttm_buffer_object *bo;
-       struct ttm_base_object *base;
-       bool existed;
-       int ret;
-
-       switch (arg->op) {
-       case TTM_PL_SYNCCPU_OP_GRAB:
-               user_bo = ttm_bo_user_lookup(tfile, arg->handle);
-               if (unlikely(user_bo == NULL)) {
-                       printk(KERN_ERR
-                              "Could not find buffer object for synccpu.\n");
-                       return -EINVAL;
-               }
-               bo = &user_bo->bo;
-               base = &user_bo->base;
-               ret = ttm_bo_synccpu_write_grab(bo,
-                                               arg->access_mode &
-                                               TTM_PL_SYNCCPU_MODE_NO_BLOCK);
-               if (unlikely(ret != 0)) {
-                       ttm_base_object_unref(&base);
-                       goto out;
-               }
-               ret = ttm_ref_object_add(tfile, &user_bo->base,
-                                        TTM_REF_SYNCCPU_WRITE, &existed);
-               if (existed || ret != 0)
-                       ttm_bo_synccpu_write_release(bo);
-               ttm_base_object_unref(&base);
-               break;
-       case TTM_PL_SYNCCPU_OP_RELEASE:
-               ret = ttm_ref_object_base_unref(tfile, arg->handle,
-                                               TTM_REF_SYNCCPU_WRITE);
-               break;
-       default:
-               ret = -EINVAL;
-               break;
-       }
-out:
-       return ret;
-}
-
-int ttm_pl_setstatus_ioctl(struct ttm_object_file *tfile,
-                          struct ttm_lock *lock, void *data)
-{
-       union ttm_pl_setstatus_arg *arg = data;
-       struct ttm_pl_setstatus_req *req = &arg->req;
-       struct ttm_pl_rep *rep = &arg->rep;
-       struct ttm_buffer_object *bo;
-       struct ttm_bo_device *bdev;
-       struct ttm_placement placement = default_placement;
-       uint32_t flags[2];
-       int ret;
-
-       bo = ttm_buffer_object_lookup(tfile, req->handle);
-       if (unlikely(bo == NULL)) {
-               printk(KERN_ERR
-                      "Could not find buffer object for setstatus.\n");
-               return -EINVAL;
-       }
-
-       bdev = bo->bdev;
-
-       ret = ttm_read_lock(lock, true);
-       if (unlikely(ret != 0))
-               goto out_err0;
-
-       ret = ttm_bo_reserve(bo, true, false, false, 0);
-       if (unlikely(ret != 0))
-               goto out_err1;
-
-       ret = ttm_bo_wait_cpu(bo, false);
-       if (unlikely(ret != 0))
-               goto out_err2;
-
-       flags[0] = req->set_placement;
-       flags[1] = req->clr_placement;
-
-       placement.num_placement = 2;
-       placement.placement = flags;
-
-       /* Review internal locking ? FIXMEAC */
-       ret = psb_ttm_bo_check_placement(bo, &placement);
-       if (unlikely(ret != 0))
-               goto out_err2;
-
-       placement.num_placement = 1;
-       flags[0] = (req->set_placement | bo->mem.placement)
-                                               & ~req->clr_placement;
-
-       ret = ttm_bo_validate(bo, &placement, true, false, false);
-       if (unlikely(ret != 0))
-               goto out_err2;
-
-       ttm_pl_fill_rep(bo, rep);
-out_err2:
-       ttm_bo_unreserve(bo);
-out_err1:
-       ttm_read_unlock(lock);
-out_err0:
-       ttm_bo_unref(&bo);
-       return ret;
-}
-
-static int psb_ttm_bo_block_reservation(struct ttm_buffer_object *bo,
-                               bool interruptible, bool no_wait)
-{
-       int ret;
-
-       while (unlikely(atomic_cmpxchg(&bo->reserved, 0, 1) != 0)) {
-               if (no_wait)
-                       return -EBUSY;
-               else if (interruptible) {
-                       ret = wait_event_interruptible(bo->event_queue,
-                                       atomic_read(&bo->reserved) == 0);
-                       if (unlikely(ret != 0))
-                               return -ERESTART;
-               } else {
-                       wait_event(bo->event_queue,
-                               atomic_read(&bo->reserved) == 0);
-               }
-       }
-       return 0;
-}
-
-static void psb_ttm_bo_unblock_reservation(struct ttm_buffer_object *bo)
-{
-       atomic_set(&bo->reserved, 0);
-       wake_up_all(&bo->event_queue);
-}
-
-int ttm_pl_waitidle_ioctl(struct ttm_object_file *tfile, void *data)
-{
-       struct ttm_pl_waitidle_arg *arg = data;
-       struct ttm_buffer_object *bo;
-       int ret;
-
-       bo = ttm_buffer_object_lookup(tfile, arg->handle);
-       if (unlikely(bo == NULL)) {
-               printk(KERN_ERR "Could not find buffer object for waitidle.\n");
-               return -EINVAL;
-       }
-
-       ret =
-           psb_ttm_bo_block_reservation(bo, true,
-                                    arg->mode & TTM_PL_WAITIDLE_MODE_NO_BLOCK);
-       if (unlikely(ret != 0))
-               goto out;
-       ret = ttm_bo_wait(bo,
-                         arg->mode & TTM_PL_WAITIDLE_MODE_LAZY,
-                         true, arg->mode & TTM_PL_WAITIDLE_MODE_NO_BLOCK);
-       psb_ttm_bo_unblock_reservation(bo);
-out:
-       ttm_bo_unref(&bo);
-       return ret;
-}
-
-int ttm_pl_verify_access(struct ttm_buffer_object *bo,
-                        struct ttm_object_file *tfile)
-{
-       struct ttm_bo_user_object *ubo;
-
-       /*
-        * Check bo subclass.
-        */
-
-       if (unlikely(bo->destroy != &ttm_bo_user_destroy))
-               return -EPERM;
-
-       ubo = container_of(bo, struct ttm_bo_user_object, bo);
-       if (likely(ubo->base.shareable || ubo->base.tfile == tfile))
-               return 0;
-
-       return -EPERM;
-}
diff --git a/drivers/staging/gma500/psb_ttm_placement_user.h b/drivers/staging/gma500/psb_ttm_placement_user.h
deleted file mode 100644 (file)
index 8b7068b..0000000
+++ /dev/null
@@ -1,252 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2006-2008 Tungsten Graphics, Inc., Cedar Park, TX., USA
- * All Rights Reserved.
- * Copyright (c) 2009 VMware, Inc., Palo Alto, CA., USA
- * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
- *
- **************************************************************************/
-/*
- * Authors
- * Thomas Hellström <thomas-at-tungstengraphics-dot-com>
- */
-
-#ifndef _TTM_PLACEMENT_USER_H_
-#define _TTM_PLACEMENT_USER_H_
-
-#if !defined(__KERNEL__) && !defined(_KERNEL)
-#include <stdint.h>
-#else
-#include <linux/kernel.h>
-#endif
-
-#include "ttm/ttm_placement.h"
-
-#define TTM_PLACEMENT_MAJOR 0
-#define TTM_PLACEMENT_MINOR 1
-#define TTM_PLACEMENT_PL    0
-#define TTM_PLACEMENT_DATE  "080819"
-
-/**
- * struct ttm_pl_create_req
- *
- * @size: The buffer object size.
- * @placement: Flags that indicate initial acceptable
- *  placement.
- * @page_alignment: Required alignment in pages.
- *
- * Input to the TTM_BO_CREATE ioctl.
- */
-
-struct ttm_pl_create_req {
-       uint64_t size;
-       uint32_t placement;
-       uint32_t page_alignment;
-};
-
-/**
- * struct ttm_pl_create_ub_req
- *
- * @size: The buffer object size.
- * @user_address: User-space address of the memory area that
- * should be used to back the buffer object cast to 64-bit.
- * @placement: Flags that indicate initial acceptable
- *  placement.
- * @page_alignment: Required alignment in pages.
- *
- * Input to the TTM_BO_CREATE_UB ioctl.
- */
-
-struct ttm_pl_create_ub_req {
-       uint64_t size;
-       uint64_t user_address;
-       uint32_t placement;
-       uint32_t page_alignment;
-};
-
-/**
- * struct ttm_pl_rep
- *
- * @gpu_offset: The current offset into the memory region used.
- * This can be used directly by the GPU if there are no
- * additional GPU mapping procedures used by the driver.
- *
- * @bo_size: Actual buffer object size.
- *
- * @map_handle: Offset into the device address space.
- * Used for map, seek, read, write. This will never change
- * during the lifetime of an object.
- *
- * @placement: Flag indicating the placement status of
- * the buffer object using the TTM_PL flags above.
- *
- * @sync_object_arg: Used for user-space synchronization and
- * depends on the synchronization model used. If fences are
- * used, this is the buffer_object::fence_type_mask
- *
- * Output from the TTM_PL_CREATE and TTM_PL_REFERENCE, and
- * TTM_PL_SETSTATUS ioctls.
- */
-
-struct ttm_pl_rep {
-       uint64_t gpu_offset;
-       uint64_t bo_size;
-       uint64_t map_handle;
-       uint32_t placement;
-       uint32_t handle;
-       uint32_t sync_object_arg;
-       uint32_t pad64;
-};
-
-/**
- * struct ttm_pl_setstatus_req
- *
- * @set_placement: Placement flags to set.
- *
- * @clr_placement: Placement flags to clear.
- *
- * @handle: The object handle
- *
- * Input to the TTM_PL_SETSTATUS ioctl.
- */
-
-struct ttm_pl_setstatus_req {
-       uint32_t set_placement;
-       uint32_t clr_placement;
-       uint32_t handle;
-       uint32_t pad64;
-};
-
-/**
- * struct ttm_pl_reference_req
- *
- * @handle: The object to put a reference on.
- *
- * Input to the TTM_PL_REFERENCE and the TTM_PL_UNREFERENCE ioctls.
- */
-
-struct ttm_pl_reference_req {
-       uint32_t handle;
-       uint32_t pad64;
-};
-
-/*
- * ACCESS mode flags for SYNCCPU.
- *
- * TTM_SYNCCPU_MODE_READ will guarantee that the GPU is not
- * writing to the buffer.
- *
- * TTM_SYNCCPU_MODE_WRITE will guarantee that the GPU is not
- * accessing the buffer.
- *
- * TTM_SYNCCPU_MODE_NO_BLOCK makes sure the call does not wait
- * for GPU accesses to finish but return -EBUSY.
- *
- * TTM_SYNCCPU_MODE_TRYCACHED Try to place the buffer in cacheable
- * memory while synchronized for CPU.
- */
-
-#define TTM_PL_SYNCCPU_MODE_READ      TTM_ACCESS_READ
-#define TTM_PL_SYNCCPU_MODE_WRITE     TTM_ACCESS_WRITE
-#define TTM_PL_SYNCCPU_MODE_NO_BLOCK  (1 << 2)
-#define TTM_PL_SYNCCPU_MODE_TRYCACHED (1 << 3)
-
-/**
- * struct ttm_pl_synccpu_arg
- *
- * @handle: The object to synchronize.
- *
- * @access_mode: access mode indicated by the
- * TTM_SYNCCPU_MODE flags.
- *
- * @op: indicates whether to grab or release the
- * buffer for cpu usage.
- *
- * Input to the TTM_PL_SYNCCPU ioctl.
- */
-
-struct ttm_pl_synccpu_arg {
-       uint32_t handle;
-       uint32_t access_mode;
-       enum {
-               TTM_PL_SYNCCPU_OP_GRAB,
-               TTM_PL_SYNCCPU_OP_RELEASE
-       } op;
-       uint32_t pad64;
-};
-
-/*
- * Waiting mode flags for the TTM_BO_WAITIDLE ioctl.
- *
- * TTM_WAITIDLE_MODE_LAZY: Allow for sleeps during polling
- * wait.
- *
- * TTM_WAITIDLE_MODE_NO_BLOCK: Don't block waiting for GPU,
- * but return -EBUSY if the buffer is busy.
- */
-
-#define TTM_PL_WAITIDLE_MODE_LAZY     (1 << 0)
-#define TTM_PL_WAITIDLE_MODE_NO_BLOCK (1 << 1)
-
-/**
- * struct ttm_waitidle_arg
- *
- * @handle: The object to synchronize.
- *
- * @mode: wait mode indicated by the
- * TTM_SYNCCPU_MODE flags.
- *
- * Argument to the TTM_BO_WAITIDLE ioctl.
- */
-
-struct ttm_pl_waitidle_arg {
-       uint32_t handle;
-       uint32_t mode;
-};
-
-union ttm_pl_create_arg {
-       struct ttm_pl_create_req req;
-       struct ttm_pl_rep rep;
-};
-
-union ttm_pl_reference_arg {
-       struct ttm_pl_reference_req req;
-       struct ttm_pl_rep rep;
-};
-
-union ttm_pl_setstatus_arg {
-       struct ttm_pl_setstatus_req req;
-       struct ttm_pl_rep rep;
-};
-
-union ttm_pl_create_ub_arg {
-       struct ttm_pl_create_ub_req req;
-       struct ttm_pl_rep rep;
-};
-
-/*
- * Ioctl offsets.
- */
-
-#define TTM_PL_CREATE      0x00
-#define TTM_PL_REFERENCE   0x01
-#define TTM_PL_UNREF       0x02
-#define TTM_PL_SYNCCPU     0x03
-#define TTM_PL_WAITIDLE    0x04
-#define TTM_PL_SETSTATUS   0x05
-#define TTM_PL_CREATE_UB   0x06
-
-#endif
diff --git a/drivers/staging/gma500/psb_ttm_userobj_api.h b/drivers/staging/gma500/psb_ttm_userobj_api.h
deleted file mode 100644 (file)
index 6a8f7c4..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-/**************************************************************************
- *
- * Copyright (c) 2006-2008 Tungsten Graphics, Inc., Cedar Park, TX., USA
- * All Rights Reserved.
- * Copyright (c) 2009 VMware, Inc., Palo Alto, CA., USA
- * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
- *
- **************************************************************************/
-/*
- * Authors: Thomas Hellstrom <thomas-at-tungstengraphics-dot-com>
- */
-
-#ifndef _TTM_USEROBJ_API_H_
-#define _TTM_USEROBJ_API_H_
-
-#include "psb_ttm_placement_user.h"
-#include "psb_ttm_fence_user.h"
-#include "ttm/ttm_object.h"
-#include "psb_ttm_fence_api.h"
-#include "ttm/ttm_bo_api.h"
-
-struct ttm_lock;
-
-/*
- * User ioctls.
- */
-
-extern int ttm_pl_create_ioctl(struct ttm_object_file *tfile,
-                              struct ttm_bo_device *bdev,
-                              struct ttm_lock *lock, void *data);
-extern int ttm_pl_ub_create_ioctl(struct ttm_object_file *tfile,
-                                 struct ttm_bo_device *bdev,
-                                 struct ttm_lock *lock, void *data);
-extern int ttm_pl_reference_ioctl(struct ttm_object_file *tfile, void *data);
-extern int ttm_pl_unref_ioctl(struct ttm_object_file *tfile, void *data);
-extern int ttm_pl_synccpu_ioctl(struct ttm_object_file *tfile, void *data);
-extern int ttm_pl_setstatus_ioctl(struct ttm_object_file *tfile,
-                                 struct ttm_lock *lock, void *data);
-extern int ttm_pl_waitidle_ioctl(struct ttm_object_file *tfile, void *data);
-extern int ttm_fence_signaled_ioctl(struct ttm_object_file *tfile, void *data);
-extern int ttm_fence_finish_ioctl(struct ttm_object_file *tfile, void *data);
-extern int ttm_fence_unref_ioctl(struct ttm_object_file *tfile, void *data);
-
-extern int
-ttm_fence_user_create(struct ttm_fence_device *fdev,
-                     struct ttm_object_file *tfile,
-                     uint32_t fence_class,
-                     uint32_t fence_types,
-                     uint32_t create_flags,
-                     struct ttm_fence_object **fence, uint32_t * user_handle);
-
-extern struct ttm_buffer_object *ttm_buffer_object_lookup(struct ttm_object_file
-                                                         *tfile,
-                                                         uint32_t handle);
-
-extern int
-ttm_pl_verify_access(struct ttm_buffer_object *bo,
-                    struct ttm_object_file *tfile);
-
-extern int ttm_buffer_object_create(struct ttm_bo_device *bdev,
-                       unsigned long size,
-                       enum ttm_bo_type type,
-                       uint32_t flags,
-                       uint32_t page_alignment,
-                       unsigned long buffer_start,
-                       bool interruptible,
-                       struct file *persistant_swap_storage,
-                       struct ttm_buffer_object **p_bo);
-
-extern int psb_ttm_bo_check_placement(struct ttm_buffer_object *bo,
-                               struct ttm_placement *placement);
-#endif
index d41f380d188f985fbea159555a94702cb7a226f4..5e0c9f6c74578525040314d74490fc9648140832 100644 (file)
@@ -1,6 +1,6 @@
 config HYPERV
        tristate "Microsoft Hyper-V client drivers"
-       depends on X86 && m
+       depends on X86 && ACPI && PCI && m
        default n
        help
          Select this option to run Linux as a Hyper-V client operating
@@ -31,7 +31,7 @@ config HYPERV_NET
 
 config HYPERV_UTILS
        tristate "Microsoft Hyper-V Utilities driver"
-       depends on CONNECTOR
+       depends on CONNECTOR && NLS
        default HYPERV
        help
          Select this option to enable the Hyper-V Utilities.
index abeb2f7ef4e24144fd8743dff41762c7e7373367..30046743a0b4418f8813037998dd206f0e08c21f 100644 (file)
@@ -9,6 +9,6 @@ hv_vmbus-y := vmbus_drv.o \
                 hv.o connection.o channel.o \
                 channel_mgmt.o ring_buffer.o
 hv_storvsc-y := storvsc_drv.o storvsc.o
-hv_blkvsc-y := blkvsc_drv.o blkvsc.o
+hv_blkvsc-y := blkvsc_drv.o  storvsc.o
 hv_netvsc-y := netvsc_drv.o netvsc.o rndis_filter.o
 hv_utils-y := hv_util.o hv_kvp.o
diff --git a/drivers/staging/hv/blkvsc.c b/drivers/staging/hv/blkvsc.c
deleted file mode 100644 (file)
index 7c8729b..0000000
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- *
- * Copyright (c) 2009, Microsoft Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place - Suite 330, Boston, MA 02111-1307 USA.
- *
- * Authors:
- *   Haiyang Zhang <haiyangz@microsoft.com>
- *   Hank Janssen  <hjanssen@microsoft.com>
- *
- */
-#include <linux/kernel.h>
-#include <linux/mm.h>
-#include "hv_api.h"
-#include "storvsc.c"
-
-static const char *g_blk_driver_name = "blkvsc";
-
-/* {32412632-86cb-44a2-9b5c-50d1417354f5} */
-static const struct hv_guid g_blk_device_type = {
-       .data = {
-               0x32, 0x26, 0x41, 0x32, 0xcb, 0x86, 0xa2, 0x44,
-               0x9b, 0x5c, 0x50, 0xd1, 0x41, 0x73, 0x54, 0xf5
-       }
-};
-
-static int blk_vsc_on_device_add(struct hv_device *device, void *additional_info)
-{
-       struct storvsc_device_info *device_info;
-       int ret = 0;
-
-       device_info = (struct storvsc_device_info *)additional_info;
-
-       ret = stor_vsc_on_device_add(device, additional_info);
-       if (ret != 0)
-               return ret;
-
-       /*
-        * We need to use the device instance guid to set the path and target
-        * id. For IDE devices, the device instance id is formatted as
-        * <bus id> * - <device id> - 8899 - 000000000000.
-        */
-       device_info->path_id = device->dev_instance.data[3] << 24 |
-                            device->dev_instance.data[2] << 16 |
-                            device->dev_instance.data[1] << 8  |
-                            device->dev_instance.data[0];
-
-       device_info->target_id = device->dev_instance.data[5] << 8 |
-                              device->dev_instance.data[4];
-
-       return ret;
-}
-
-int blk_vsc_initialize(struct hv_driver *driver)
-{
-       struct storvsc_driver_object *stor_driver;
-       int ret = 0;
-
-       stor_driver = (struct storvsc_driver_object *)driver;
-
-       /* Make sure we are at least 2 pages since 1 page is used for control */
-       /* ASSERT(stor_driver->RingBufferSize >= (PAGE_SIZE << 1)); */
-
-       driver->name = g_blk_driver_name;
-       memcpy(&driver->dev_type, &g_blk_device_type, sizeof(struct hv_guid));
-
-       stor_driver->request_ext_size = sizeof(struct storvsc_request_extension);
-
-       /*
-        * Divide the ring buffer data size (which is 1 page less than the ring
-        * buffer size since that page is reserved for the ring buffer indices)
-        * by the max request size (which is
-        * vmbus_channel_packet_multipage_buffer + struct vstor_packet + u64)
-        */
-       stor_driver->max_outstanding_req_per_channel =
-               ((stor_driver->ring_buffer_size - PAGE_SIZE) /
-                 ALIGN(MAX_MULTIPAGE_BUFFER_PACKET +
-                          sizeof(struct vstor_packet) + sizeof(u64),
-                          sizeof(u64)));
-
-       DPRINT_INFO(BLKVSC, "max io outstd %u",
-                   stor_driver->max_outstanding_req_per_channel);
-
-       /* Setup the dispatch table */
-       stor_driver->base.dev_add = blk_vsc_on_device_add;
-       stor_driver->base.dev_rm = stor_vsc_on_device_remove;
-       stor_driver->base.cleanup = stor_vsc_on_cleanup;
-       stor_driver->on_io_request = stor_vsc_on_io_request;
-
-       return ret;
-}
index 68ad17d670980d4894f0835f88925a1f63d84662..46daade7a9e2c40935fc04ee0774d1cee66d3dc4 100644 (file)
@@ -17,6 +17,7 @@
  * Authors:
  *   Haiyang Zhang <haiyangz@microsoft.com>
  *   Hank Janssen  <hjanssen@microsoft.com>
+ *   K. Y. Srinivasan <kys@microsoft.com>
  */
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/major.h>
 #include <linux/delay.h>
 #include <linux/hdreg.h>
-#include <linux/mutex.h>
 #include <linux/slab.h>
 #include <scsi/scsi.h>
 #include <scsi/scsi_cmnd.h>
 #include <scsi/scsi_eh.h>
 #include <scsi/scsi_dbg.h>
-#include "hv_api.h"
-#include "logging.h"
-#include "version_info.h"
-#include "vmbus.h"
-#include "storvsc_api.h"
+
+#include "hyperv.h"
+#include "hyperv_storage.h"
 
 
 #define BLKVSC_MINORS  64
@@ -46,6 +44,12 @@ enum blkvsc_device_type {
        DVD_TYPE,
 };
 
+enum blkvsc_op_type {
+       DO_INQUIRY,
+       DO_CAPACITY,
+       DO_FLUSH,
+};
+
 /*
  * This request ties the struct request and struct
  * blkvsc_request/hv_storvsc_request together A struct request may be
@@ -72,9 +76,6 @@ struct blkvsc_request {
        /* The group this request is part of. Maybe null */
        struct blkvsc_request_group *group;
 
-       wait_queue_head_t wevent;
-       int cond;
-
        int write;
        sector_t sector_start;
        unsigned long sector_count;
@@ -84,12 +85,6 @@ struct blkvsc_request {
        unsigned char cmnd[MAX_COMMAND_SIZE];
 
        struct hv_storvsc_request request;
-       /*
-        * !!!DO NOT ADD ANYTHING BELOW HERE!!! Otherwise, memory can overlap,
-        * because - The extension buffer falls right here and is pointed to by
-        * request.Extension;
-        * Which sounds like a horrible idea, who designed this?
-        */
 };
 
 /* Per device structure */
@@ -106,7 +101,6 @@ struct block_device_context {
        unsigned int device_id_len;
        int num_outstanding_reqs;
        int shutting_down;
-       int media_not_present;
        unsigned int sector_size;
        sector_t capacity;
        unsigned int port;
@@ -115,437 +109,314 @@ struct block_device_context {
        int users;
 };
 
+static const char *drv_name = "blkvsc";
 
-/* Static decl */
-static DEFINE_MUTEX(blkvsc_mutex);
-static int blkvsc_probe(struct device *dev);
-static int blkvsc_remove(struct device *device);
-static void blkvsc_shutdown(struct device *device);
+/* {32412632-86cb-44a2-9b5c-50d1417354f5} */
+static const struct hv_guid dev_type = {
+       .data = {
+               0x32, 0x26, 0x41, 0x32, 0xcb, 0x86, 0xa2, 0x44,
+               0x9b, 0x5c, 0x50, 0xd1, 0x41, 0x73, 0x54, 0xf5
+       }
+};
 
-static int blkvsc_open(struct block_device *bdev,  fmode_t mode);
-static int blkvsc_release(struct gendisk *disk, fmode_t mode);
-static unsigned int blkvsc_check_events(struct gendisk *gd,
-                                       unsigned int clearing);
-static int blkvsc_revalidate_disk(struct gendisk *gd);
-static int blkvsc_getgeo(struct block_device *bd, struct hd_geometry *hg);
-static int blkvsc_ioctl(struct block_device *bd, fmode_t mode,
-                       unsigned cmd, unsigned long argument);
-static void blkvsc_request(struct request_queue *queue);
+/*
+ * There is a circular dependency involving blkvsc_request_completion()
+ * and blkvsc_do_request().
+ */
 static void blkvsc_request_completion(struct hv_storvsc_request *request);
-static int blkvsc_do_request(struct block_device_context *blkdev,
-                            struct request *req);
-static int blkvsc_submit_request(struct blkvsc_request *blkvsc_req,
-               void (*request_completion)(struct hv_storvsc_request *));
-static void blkvsc_init_rw(struct blkvsc_request *blkvsc_req);
-static void blkvsc_cmd_completion(struct hv_storvsc_request *request);
-static int blkvsc_do_inquiry(struct block_device_context *blkdev);
-static int blkvsc_do_read_capacity(struct block_device_context *blkdev);
-static int blkvsc_do_read_capacity16(struct block_device_context *blkdev);
-static int blkvsc_do_flush(struct block_device_context *blkdev);
-static int blkvsc_cancel_pending_reqs(struct block_device_context *blkdev);
-static int blkvsc_do_pending_reqs(struct block_device_context *blkdev);
 
 static int blkvsc_ringbuffer_size = BLKVSC_RING_BUFFER_SIZE;
+
 module_param(blkvsc_ringbuffer_size, int, S_IRUGO);
 MODULE_PARM_DESC(ring_size, "Ring buffer size (in bytes)");
 
-/* The one and only one */
-static  struct storvsc_driver_object g_blkvsc_drv;
-
-static const struct block_device_operations block_ops = {
-       .owner = THIS_MODULE,
-       .open = blkvsc_open,
-       .release = blkvsc_release,
-       .check_events = blkvsc_check_events,
-       .revalidate_disk = blkvsc_revalidate_disk,
-       .getgeo = blkvsc_getgeo,
-       .ioctl  = blkvsc_ioctl,
-};
-
 /*
- * blkvsc_drv_init -  BlkVsc driver initialization.
+ * There is a circular dependency involving blkvsc_probe()
+ * and block_ops.
  */
-static int blkvsc_drv_init(int (*drv_init)(struct hv_driver *drv))
-{
-       struct storvsc_driver_object *storvsc_drv_obj = &g_blkvsc_drv;
-       struct hv_driver *drv = &g_blkvsc_drv.base;
-       int ret;
+static int blkvsc_probe(struct hv_device *dev);
 
-       storvsc_drv_obj->ring_buffer_size = blkvsc_ringbuffer_size;
+static int blkvsc_device_add(struct hv_device *device,
+                               void *additional_info)
+{
+       struct storvsc_device_info *device_info;
+       int ret = 0;
 
-       drv->priv = storvsc_drv_obj;
+       device_info = (struct storvsc_device_info *)additional_info;
 
-       /* Callback to client driver to complete the initialization */
-       drv_init(&storvsc_drv_obj->base);
+       device_info->ring_buffer_size = blkvsc_ringbuffer_size;
 
-       drv->driver.name = storvsc_drv_obj->base.name;
+       ret = storvsc_dev_add(device, additional_info);
+       if (ret != 0)
+               return ret;
 
-       drv->driver.probe = blkvsc_probe;
-       drv->driver.remove = blkvsc_remove;
-       drv->driver.shutdown = blkvsc_shutdown;
+       /*
+        * We need to use the device instance guid to set the path and target
+        * id. For IDE devices, the device instance id is formatted as
+        * <bus id> * - <device id> - 8899 - 000000000000.
+        */
+       device_info->path_id = device->dev_instance.data[3] << 24 |
+                            device->dev_instance.data[2] << 16 |
+                            device->dev_instance.data[1] << 8  |
+                            device->dev_instance.data[0];
 
-       /* The driver belongs to vmbus */
-       ret = vmbus_child_driver_register(&drv->driver);
+       device_info->target_id = device->dev_instance.data[5] << 8 |
+                              device->dev_instance.data[4];
 
        return ret;
 }
 
-static int blkvsc_drv_exit_cb(struct device *dev, void *data)
-{
-       struct device **curr = (struct device **)data;
-       *curr = dev;
-       return 1; /* stop iterating */
-}
-
-static void blkvsc_drv_exit(void)
+static int blkvsc_submit_request(struct blkvsc_request *blkvsc_req,
+                       void (*request_completion)(struct hv_storvsc_request *))
 {
-       struct storvsc_driver_object *storvsc_drv_obj = &g_blkvsc_drv;
-       struct hv_driver *drv = &g_blkvsc_drv.base;
-       struct device *current_dev;
+       struct block_device_context *blkdev = blkvsc_req->dev;
+       struct hv_storvsc_request *storvsc_req;
+       struct vmscsi_request *vm_srb;
        int ret;
 
-       while (1) {
-               current_dev = NULL;
-
-               /* Get the device */
-               ret = driver_for_each_device(&drv->driver, NULL,
-                                            (void *) &current_dev,
-                                            blkvsc_drv_exit_cb);
-
-               if (ret)
-                       DPRINT_WARN(BLKVSC_DRV,
-                                   "driver_for_each_device returned %d", ret);
-
-
-               if (current_dev == NULL)
-                       break;
-
-               /* Initiate removal from the top-down */
-               device_unregister(current_dev);
-       }
-
-       if (storvsc_drv_obj->base.cleanup)
-               storvsc_drv_obj->base.cleanup(&storvsc_drv_obj->base);
-
-       vmbus_child_driver_unregister(&drv->driver);
-
-       return;
-}
 
-/*
- * blkvsc_probe - Add a new device for this driver
- */
-static int blkvsc_probe(struct device *device)
-{
-       struct hv_driver *drv =
-                               drv_to_hv_drv(device->driver);
-       struct storvsc_driver_object *storvsc_drv_obj =
-                               drv->priv;
-       struct hv_device *device_obj = device_to_hv_device(device);
+       storvsc_req = &blkvsc_req->request;
+       vm_srb = &storvsc_req->vstor_packet.vm_srb;
 
-       struct block_device_context *blkdev = NULL;
-       struct storvsc_device_info device_info;
-       int major = 0;
-       int devnum = 0;
-       int ret = 0;
-       static int ide0_registered;
-       static int ide1_registered;
+       vm_srb->data_in = blkvsc_req->write ? WRITE_TYPE : READ_TYPE;
 
-       DPRINT_DBG(BLKVSC_DRV, "blkvsc_probe - enter");
+       storvsc_req->on_io_completion = request_completion;
+       storvsc_req->context = blkvsc_req;
 
-       if (!storvsc_drv_obj->base.dev_add) {
-               DPRINT_ERR(BLKVSC_DRV, "OnDeviceAdd() not set");
-               ret = -1;
-               goto Cleanup;
-       }
+       vm_srb->port_number = blkdev->port;
+       vm_srb->path_id = blkdev->path;
+       vm_srb->target_id = blkdev->target;
+       vm_srb->lun = 0;         /* this is not really used at all */
 
-       blkdev = kzalloc(sizeof(struct block_device_context), GFP_KERNEL);
-       if (!blkdev) {
-               ret = -ENOMEM;
-               goto Cleanup;
-       }
+       vm_srb->cdb_length = blkvsc_req->cmd_len;
 
-       INIT_LIST_HEAD(&blkdev->pending_list);
+       memcpy(vm_srb->cdb, blkvsc_req->cmnd, vm_srb->cdb_length);
 
-       /* Initialize what we can here */
-       spin_lock_init(&blkdev->lock);
+       storvsc_req->sense_buffer = blkvsc_req->sense_buffer;
 
-       /* ASSERT(sizeof(struct blkvsc_request_group) <= */
-       /*      sizeof(struct blkvsc_request)); */
+       ret =  storvsc_do_io(blkdev->device_ctx,
+                                          &blkvsc_req->request);
+       if (ret == 0)
+               blkdev->num_outstanding_reqs++;
 
-       blkdev->request_pool = kmem_cache_create(dev_name(&device_obj->device),
-                                       sizeof(struct blkvsc_request) +
-                                       storvsc_drv_obj->request_ext_size, 0,
-                                       SLAB_HWCACHE_ALIGN, NULL);
-       if (!blkdev->request_pool) {
-               ret = -ENOMEM;
-               goto Cleanup;
-       }
+       return ret;
+}
 
 
-       /* Call to the vsc driver to add the device */
-       ret = storvsc_drv_obj->base.dev_add(device_obj, &device_info);
-       if (ret != 0) {
-               DPRINT_ERR(BLKVSC_DRV, "unable to add blkvsc device");
-               goto Cleanup;
-       }
+static int blkvsc_open(struct block_device *bdev, fmode_t mode)
+{
+       struct block_device_context *blkdev = bdev->bd_disk->private_data;
+       unsigned long flags;
 
-       blkdev->device_ctx = device_obj;
-       /* this identified the device 0 or 1 */
-       blkdev->target = device_info.target_id;
-       /* this identified the ide ctrl 0 or 1 */
-       blkdev->path = device_info.path_id;
+       spin_lock_irqsave(&blkdev->lock, flags);
 
-       dev_set_drvdata(device, blkdev);
+       blkdev->users++;
 
-       /* Calculate the major and device num */
-       if (blkdev->path == 0) {
-               major = IDE0_MAJOR;
-               devnum = blkdev->path + blkdev->target;         /* 0 or 1 */
+       spin_unlock_irqrestore(&blkdev->lock, flags);
 
-               if (!ide0_registered) {
-                       ret = register_blkdev(major, "ide");
-                       if (ret != 0) {
-                               DPRINT_ERR(BLKVSC_DRV,
-                                          "register_blkdev() failed! ret %d",
-                                          ret);
-                               goto Remove;
-                       }
+       return 0;
+}
 
-                       ide0_registered = 1;
-               }
-       } else if (blkdev->path == 1) {
-               major = IDE1_MAJOR;
-               devnum = blkdev->path + blkdev->target + 1; /* 2 or 3 */
-
-               if (!ide1_registered) {
-                       ret = register_blkdev(major, "ide");
-                       if (ret != 0) {
-                               DPRINT_ERR(BLKVSC_DRV,
-                                          "register_blkdev() failed! ret %d",
-                                          ret);
-                               goto Remove;
-                       }
 
-                       ide1_registered = 1;
-               }
-       } else {
-               DPRINT_ERR(BLKVSC_DRV, "invalid pathid");
-               ret = -1;
-               goto Cleanup;
-       }
+static int blkvsc_getgeo(struct block_device *bd, struct hd_geometry *hg)
+{
+       sector_t nsect = get_capacity(bd->bd_disk);
+       sector_t cylinders = nsect;
 
-       DPRINT_INFO(BLKVSC_DRV, "blkvsc registered for major %d!!", major);
+       /*
+        * We are making up these values; let us keep it simple.
+        */
+       hg->heads = 0xff;
+       hg->sectors = 0x3f;
+       sector_div(cylinders, hg->heads * hg->sectors);
+       hg->cylinders = cylinders;
+       if ((sector_t)(hg->cylinders + 1) * hg->heads * hg->sectors < nsect)
+               hg->cylinders = 0xffff;
+       return 0;
 
-       blkdev->gd = alloc_disk(BLKVSC_MINORS);
-       if (!blkdev->gd) {
-               DPRINT_ERR(BLKVSC_DRV, "register_blkdev() failed! ret %d", ret);
-               ret = -1;
-               goto Cleanup;
-       }
+}
 
-       blkdev->gd->queue = blk_init_queue(blkvsc_request, &blkdev->lock);
 
-       blk_queue_max_segment_size(blkdev->gd->queue, PAGE_SIZE);
-       blk_queue_max_segments(blkdev->gd->queue, MAX_MULTIPAGE_BUFFER_COUNT);
-       blk_queue_segment_boundary(blkdev->gd->queue, PAGE_SIZE-1);
-       blk_queue_bounce_limit(blkdev->gd->queue, BLK_BOUNCE_ANY);
-       blk_queue_dma_alignment(blkdev->gd->queue, 511);
+static void blkvsc_init_rw(struct blkvsc_request *blkvsc_req)
+{
 
-       blkdev->gd->major = major;
-       if (devnum == 1 || devnum == 3)
-               blkdev->gd->first_minor = BLKVSC_MINORS;
-       else
-               blkdev->gd->first_minor = 0;
-       blkdev->gd->fops = &block_ops;
-       blkdev->gd->events = DISK_EVENT_MEDIA_CHANGE;
-       blkdev->gd->private_data = blkdev;
-       blkdev->gd->driverfs_dev = &(blkdev->device_ctx->device);
-       sprintf(blkdev->gd->disk_name, "hd%c", 'a' + devnum);
+       blkvsc_req->cmd_len = 16;
 
-       blkvsc_do_inquiry(blkdev);
-       if (blkdev->device_type == DVD_TYPE) {
-               set_disk_ro(blkdev->gd, 1);
-               blkdev->gd->flags |= GENHD_FL_REMOVABLE;
-               blkvsc_do_read_capacity(blkdev);
+       if (rq_data_dir(blkvsc_req->req)) {
+               blkvsc_req->write = 1;
+               blkvsc_req->cmnd[0] = WRITE_16;
        } else {
-               blkvsc_do_read_capacity16(blkdev);
+               blkvsc_req->write = 0;
+               blkvsc_req->cmnd[0] = READ_16;
        }
 
-       set_capacity(blkdev->gd, blkdev->capacity * (blkdev->sector_size/512));
-       blk_queue_logical_block_size(blkdev->gd->queue, blkdev->sector_size);
-       /* go! */
-       add_disk(blkdev->gd);
+       blkvsc_req->cmnd[1] |=
+       (blkvsc_req->req->cmd_flags & REQ_FUA) ? 0x8 : 0;
 
-       DPRINT_INFO(BLKVSC_DRV, "%s added!! capacity %lu sector_size %d",
-                   blkdev->gd->disk_name, (unsigned long)blkdev->capacity,
-                   blkdev->sector_size);
+       *(unsigned long long *)&blkvsc_req->cmnd[2] =
+       cpu_to_be64(blkvsc_req->sector_start);
+       *(unsigned int *)&blkvsc_req->cmnd[10] =
+       cpu_to_be32(blkvsc_req->sector_count);
+}
 
-       return ret;
 
-Remove:
-       storvsc_drv_obj->base.dev_rm(device_obj);
+static int blkvsc_ioctl(struct block_device *bd, fmode_t mode,
+                       unsigned cmd, unsigned long arg)
+{
+       struct block_device_context *blkdev = bd->bd_disk->private_data;
+       int ret = 0;
 
-Cleanup:
-       if (blkdev) {
-               if (blkdev->request_pool) {
-                       kmem_cache_destroy(blkdev->request_pool);
-                       blkdev->request_pool = NULL;
-               }
-               kfree(blkdev);
-               blkdev = NULL;
+       switch (cmd) {
+       case HDIO_GET_IDENTITY:
+               if (copy_to_user((void __user *)arg, blkdev->device_id,
+                                blkdev->device_id_len))
+                       ret = -EFAULT;
+               break;
+       default:
+               ret = -EINVAL;
+               break;
        }
 
        return ret;
 }
 
-static void blkvsc_shutdown(struct device *device)
+static void blkvsc_cmd_completion(struct hv_storvsc_request *request)
 {
-       struct block_device_context *blkdev = dev_get_drvdata(device);
+       struct blkvsc_request *blkvsc_req =
+                       (struct blkvsc_request *)request->context;
+       struct block_device_context *blkdev =
+                       (struct block_device_context *)blkvsc_req->dev;
+       struct scsi_sense_hdr sense_hdr;
+       struct vmscsi_request *vm_srb;
        unsigned long flags;
 
-       if (!blkdev)
-               return;
 
-       DPRINT_DBG(BLKVSC_DRV, "blkvsc_shutdown - users %d disk %s\n",
-                  blkdev->users, blkdev->gd->disk_name);
+       vm_srb = &blkvsc_req->request.vstor_packet.vm_srb;
 
        spin_lock_irqsave(&blkdev->lock, flags);
-
-       blkdev->shutting_down = 1;
-
-       blk_stop_queue(blkdev->gd->queue);
-
+       blkdev->num_outstanding_reqs--;
        spin_unlock_irqrestore(&blkdev->lock, flags);
 
-       while (blkdev->num_outstanding_reqs) {
-               DPRINT_INFO(STORVSC, "waiting for %d requests to complete...",
-                           blkdev->num_outstanding_reqs);
-               udelay(100);
-       }
-
-       blkvsc_do_flush(blkdev);
-
-       spin_lock_irqsave(&blkdev->lock, flags);
-
-       blkvsc_cancel_pending_reqs(blkdev);
+       if (vm_srb->scsi_status)
+               if (scsi_normalize_sense(blkvsc_req->sense_buffer,
+                                        SCSI_SENSE_BUFFERSIZE, &sense_hdr))
+                       scsi_print_sense_hdr("blkvsc", &sense_hdr);
 
-       spin_unlock_irqrestore(&blkdev->lock, flags);
+       complete(&blkvsc_req->request.wait_event);
 }
 
-static int blkvsc_do_flush(struct block_device_context *blkdev)
-{
-       struct blkvsc_request *blkvsc_req;
-
-       DPRINT_DBG(BLKVSC_DRV, "blkvsc_do_flush()\n");
-
-       if (blkdev->device_type != HARDDISK_TYPE)
-               return 0;
-
-       blkvsc_req = kmem_cache_alloc(blkdev->request_pool, GFP_KERNEL);
-       if (!blkvsc_req)
-               return -ENOMEM;
-
-       memset(blkvsc_req, 0, sizeof(struct blkvsc_request));
-       init_waitqueue_head(&blkvsc_req->wevent);
-       blkvsc_req->dev = blkdev;
-       blkvsc_req->req = NULL;
-       blkvsc_req->write = 0;
-
-       blkvsc_req->request.data_buffer.pfn_array[0] = 0;
-       blkvsc_req->request.data_buffer.offset = 0;
-       blkvsc_req->request.data_buffer.len = 0;
-
-       blkvsc_req->cmnd[0] = SYNCHRONIZE_CACHE;
-       blkvsc_req->cmd_len = 10;
-
-       /*
-        * Set this here since the completion routine may be invoked and
-        * completed before we return
-        */
-       blkvsc_req->cond = 0;
-       blkvsc_submit_request(blkvsc_req, blkvsc_cmd_completion);
-
-       wait_event_interruptible(blkvsc_req->wevent, blkvsc_req->cond);
-
-       kmem_cache_free(blkvsc_req->dev->request_pool, blkvsc_req);
-
-       return 0;
-}
 
-/* Do a scsi INQUIRY cmd here to get the device type (ie disk or dvd) */
-static int blkvsc_do_inquiry(struct block_device_context *blkdev)
+static int blkvsc_do_operation(struct block_device_context *blkdev,
+                               enum blkvsc_op_type op)
 {
        struct blkvsc_request *blkvsc_req;
        struct page *page_buf;
        unsigned char *buf;
        unsigned char device_type;
+       struct scsi_sense_hdr sense_hdr;
+       struct vmscsi_request *vm_srb;
+       unsigned long flags;
 
-       DPRINT_DBG(BLKVSC_DRV, "blkvsc_do_inquiry()\n");
+       int ret = 0;
 
-       blkvsc_req = kmem_cache_alloc(blkdev->request_pool, GFP_KERNEL);
+       blkvsc_req = kmem_cache_zalloc(blkdev->request_pool, GFP_KERNEL);
        if (!blkvsc_req)
                return -ENOMEM;
 
-       memset(blkvsc_req, 0, sizeof(struct blkvsc_request));
        page_buf = alloc_page(GFP_KERNEL);
        if (!page_buf) {
                kmem_cache_free(blkvsc_req->dev->request_pool, blkvsc_req);
                return -ENOMEM;
        }
 
-       init_waitqueue_head(&blkvsc_req->wevent);
+       vm_srb = &blkvsc_req->request.vstor_packet.vm_srb;
+       init_completion(&blkvsc_req->request.wait_event);
        blkvsc_req->dev = blkdev;
        blkvsc_req->req = NULL;
        blkvsc_req->write = 0;
 
-       blkvsc_req->request.data_buffer.pfn_array[0] = page_to_pfn(page_buf);
+       blkvsc_req->request.data_buffer.pfn_array[0] =
+       page_to_pfn(page_buf);
        blkvsc_req->request.data_buffer.offset = 0;
-       blkvsc_req->request.data_buffer.len = 64;
 
-       blkvsc_req->cmnd[0] = INQUIRY;
-       blkvsc_req->cmnd[1] = 0x1;              /* Get product data */
-       blkvsc_req->cmnd[2] = 0x83;             /* mode page 83 */
-       blkvsc_req->cmnd[4] = 64;
-       blkvsc_req->cmd_len = 6;
+       switch (op) {
+       case DO_INQUIRY:
+               blkvsc_req->cmnd[0] = INQUIRY;
+               blkvsc_req->cmnd[1] = 0x1;              /* Get product data */
+               blkvsc_req->cmnd[2] = 0x83;             /* mode page 83 */
+               blkvsc_req->cmnd[4] = 64;
+               blkvsc_req->cmd_len = 6;
+               blkvsc_req->request.data_buffer.len = 64;
+               break;
 
-       /*
-        * Set this here since the completion routine may be invoked and
-        * completed before we return
-        */
-       blkvsc_req->cond = 0;
+       case DO_CAPACITY:
+               blkdev->sector_size = 0;
+               blkdev->capacity = 0;
+
+               blkvsc_req->cmnd[0] = READ_CAPACITY;
+               blkvsc_req->cmd_len = 16;
+               blkvsc_req->request.data_buffer.len = 8;
+               break;
+
+       case DO_FLUSH:
+               blkvsc_req->cmnd[0] = SYNCHRONIZE_CACHE;
+               blkvsc_req->cmd_len = 10;
+               blkvsc_req->request.data_buffer.pfn_array[0] = 0;
+               blkvsc_req->request.data_buffer.len = 0;
+               break;
+       default:
+               ret = -EINVAL;
+               goto cleanup;
+       }
 
+       spin_lock_irqsave(&blkdev->lock, flags);
        blkvsc_submit_request(blkvsc_req, blkvsc_cmd_completion);
+       spin_unlock_irqrestore(&blkdev->lock, flags);
+
+       wait_for_completion_interruptible(&blkvsc_req->request.wait_event);
 
-       DPRINT_DBG(BLKVSC_DRV, "waiting %p to complete - cond %d\n",
-                  blkvsc_req, blkvsc_req->cond);
+       /* check error */
+       if (vm_srb->scsi_status) {
+               scsi_normalize_sense(blkvsc_req->sense_buffer,
+                                    SCSI_SENSE_BUFFERSIZE, &sense_hdr);
 
-       wait_event_interruptible(blkvsc_req->wevent, blkvsc_req->cond);
+               return 0;
+       }
 
        buf = kmap(page_buf);
 
-       /* print_hex_dump_bytes("", DUMP_PREFIX_NONE, buf, 64); */
-       /* be to le */
-       device_type = buf[0] & 0x1F;
+       switch (op) {
+       case DO_INQUIRY:
+               device_type = buf[0] & 0x1F;
 
-       if (device_type == 0x0) {
-               blkdev->device_type = HARDDISK_TYPE;
-       } else if (device_type == 0x5) {
-               blkdev->device_type = DVD_TYPE;
-       } else {
-               /* TODO: this is currently unsupported device type */
-               blkdev->device_type = UNKNOWN_DEV_TYPE;
-       }
+               if (device_type == 0x0)
+                       blkdev->device_type = HARDDISK_TYPE;
+                else
+                       blkdev->device_type = UNKNOWN_DEV_TYPE;
+
+               blkdev->device_id_len = buf[7];
+               if (blkdev->device_id_len > 64)
+                       blkdev->device_id_len = 64;
+
+               memcpy(blkdev->device_id, &buf[8], blkdev->device_id_len);
+               break;
 
-       DPRINT_DBG(BLKVSC_DRV, "device type %d\n", device_type);
+       case DO_CAPACITY:
+               /* be to le */
+               blkdev->capacity =
+               ((buf[0] << 24) | (buf[1] << 16) |
+               (buf[2] << 8) | buf[3]) + 1;
 
-       blkdev->device_id_len = buf[7];
-       if (blkdev->device_id_len > 64)
-               blkdev->device_id_len = 64;
+               blkdev->sector_size =
+               (buf[4] << 24) | (buf[5] << 16) |
+               (buf[6] << 8) | buf[7];
+               break;
+       default:
+               break;
+
+       }
 
-       memcpy(blkdev->device_id, &buf[8], blkdev->device_id_len);
-       /* printk_hex_dump_bytes("", DUMP_PREFIX_NONE, blkdev->device_id,
-        * blkdev->device_id_len); */
+cleanup:
 
        kunmap(page_buf);
 
@@ -553,197 +424,86 @@ static int blkvsc_do_inquiry(struct block_device_context *blkdev)
 
        kmem_cache_free(blkvsc_req->dev->request_pool, blkvsc_req);
 
-       return 0;
+       return ret;
 }
 
-/* Do a scsi READ_CAPACITY cmd here to get the size of the disk */
-static int blkvsc_do_read_capacity(struct block_device_context *blkdev)
-{
-       struct blkvsc_request *blkvsc_req;
-       struct page *page_buf;
-       unsigned char *buf;
-       struct scsi_sense_hdr sense_hdr;
 
-       DPRINT_DBG(BLKVSC_DRV, "blkvsc_do_read_capacity()\n");
+static int blkvsc_cancel_pending_reqs(struct block_device_context *blkdev)
+{
+       struct blkvsc_request *pend_req, *tmp;
+       struct blkvsc_request *comp_req, *tmp2;
+       struct vmscsi_request *vm_srb;
 
-       blkdev->sector_size = 0;
-       blkdev->capacity = 0;
-       blkdev->media_not_present = 0; /* assume a disk is present */
+       int ret = 0;
 
-       blkvsc_req = kmem_cache_alloc(blkdev->request_pool, GFP_KERNEL);
-       if (!blkvsc_req)
-               return -ENOMEM;
 
-       memset(blkvsc_req, 0, sizeof(struct blkvsc_request));
-       page_buf = alloc_page(GFP_KERNEL);
-       if (!page_buf) {
-               kmem_cache_free(blkvsc_req->dev->request_pool, blkvsc_req);
-               return -ENOMEM;
-       }
-
-       init_waitqueue_head(&blkvsc_req->wevent);
-       blkvsc_req->dev = blkdev;
-       blkvsc_req->req = NULL;
-       blkvsc_req->write = 0;
-
-       blkvsc_req->request.data_buffer.pfn_array[0] = page_to_pfn(page_buf);
-       blkvsc_req->request.data_buffer.offset = 0;
-       blkvsc_req->request.data_buffer.len = 8;
-
-       blkvsc_req->cmnd[0] = READ_CAPACITY;
-       blkvsc_req->cmd_len = 16;
-
-       /*
-        * Set this here since the completion routine may be invoked
-        * and completed before we return
-        */
-       blkvsc_req->cond = 0;
+       /* Flush the pending list first */
+       list_for_each_entry_safe(pend_req, tmp, &blkdev->pending_list,
+                                pend_entry) {
+               /*
+                * The pend_req could be part of a partially completed
+                * request. If so, complete those req first until we
+                * hit the pend_req
+                */
+               list_for_each_entry_safe(comp_req, tmp2,
+                                        &pend_req->group->blkvsc_req_list,
+                                        req_entry) {
 
-       blkvsc_submit_request(blkvsc_req, blkvsc_cmd_completion);
+                       if (comp_req == pend_req)
+                               break;
 
-       DPRINT_DBG(BLKVSC_DRV, "waiting %p to complete - cond %d\n",
-                  blkvsc_req, blkvsc_req->cond);
+                       list_del(&comp_req->req_entry);
 
-       wait_event_interruptible(blkvsc_req->wevent, blkvsc_req->cond);
+                       if (comp_req->req) {
+                               vm_srb =
+                               &comp_req->request.vstor_packet.
+                               vm_srb;
+                               ret = __blk_end_request(comp_req->req,
+                                       (!vm_srb->scsi_status ? 0 : -EIO),
+                                       comp_req->sector_count *
+                                       blkdev->sector_size);
 
-       /* check error */
-       if (blkvsc_req->request.status) {
-               scsi_normalize_sense(blkvsc_req->sense_buffer,
-                                    SCSI_SENSE_BUFFERSIZE, &sense_hdr);
+                               /* FIXME: shouldn't this do more than return? */
+                               if (ret)
+                                       goto out;
+                       }
 
-               if (sense_hdr.asc == 0x3A) {
-                       /* Medium not present */
-                       blkdev->media_not_present = 1;
+                       kmem_cache_free(blkdev->request_pool, comp_req);
                }
-               return 0;
-       }
-       buf = kmap(page_buf);
-
-       /* be to le */
-       blkdev->capacity = ((buf[0] << 24) | (buf[1] << 16) |
-                           (buf[2] << 8) | buf[3]) + 1;
-       blkdev->sector_size = (buf[4] << 24) | (buf[5] << 16) |
-                             (buf[6] << 8) | buf[7];
-
-       kunmap(page_buf);
-
-       __free_page(page_buf);
-
-       kmem_cache_free(blkvsc_req->dev->request_pool, blkvsc_req);
-
-       return 0;
-}
-
-static int blkvsc_do_read_capacity16(struct block_device_context *blkdev)
-{
-       struct blkvsc_request *blkvsc_req;
-       struct page *page_buf;
-       unsigned char *buf;
-       struct scsi_sense_hdr sense_hdr;
-
-       DPRINT_DBG(BLKVSC_DRV, "blkvsc_do_read_capacity16()\n");
-
-       blkdev->sector_size = 0;
-       blkdev->capacity = 0;
-       blkdev->media_not_present = 0; /* assume a disk is present */
-
-       blkvsc_req = kmem_cache_alloc(blkdev->request_pool, GFP_KERNEL);
-       if (!blkvsc_req)
-               return -ENOMEM;
 
-       memset(blkvsc_req, 0, sizeof(struct blkvsc_request));
-       page_buf = alloc_page(GFP_KERNEL);
-       if (!page_buf) {
-               kmem_cache_free(blkvsc_req->dev->request_pool, blkvsc_req);
-               return -ENOMEM;
-       }
-
-       init_waitqueue_head(&blkvsc_req->wevent);
-       blkvsc_req->dev = blkdev;
-       blkvsc_req->req = NULL;
-       blkvsc_req->write = 0;
-
-       blkvsc_req->request.data_buffer.pfn_array[0] = page_to_pfn(page_buf);
-       blkvsc_req->request.data_buffer.offset = 0;
-       blkvsc_req->request.data_buffer.len = 12;
-
-       blkvsc_req->cmnd[0] = 0x9E; /* READ_CAPACITY16; */
-       blkvsc_req->cmd_len = 16;
-
-       /*
-        * Set this here since the completion routine may be invoked
-        * and completed before we return
-        */
-       blkvsc_req->cond = 0;
-
-       blkvsc_submit_request(blkvsc_req, blkvsc_cmd_completion);
-
-       DPRINT_DBG(BLKVSC_DRV, "waiting %p to complete - cond %d\n",
-                  blkvsc_req, blkvsc_req->cond);
+               list_del(&pend_req->pend_entry);
 
-       wait_event_interruptible(blkvsc_req->wevent, blkvsc_req->cond);
+               list_del(&pend_req->req_entry);
 
-       /* check error */
-       if (blkvsc_req->request.status) {
-               scsi_normalize_sense(blkvsc_req->sense_buffer,
-                                    SCSI_SENSE_BUFFERSIZE, &sense_hdr);
-               if (sense_hdr.asc == 0x3A) {
-                       /* Medium not present */
-                       blkdev->media_not_present = 1;
+               if (comp_req->req) {
+                       if (!__blk_end_request(pend_req->req, -EIO,
+                                              pend_req->sector_count *
+                                              blkdev->sector_size)) {
+                               /*
+                                * All the sectors have been xferred ie the
+                                * request is done
+                                */
+                               kmem_cache_free(blkdev->request_pool,
+                                               pend_req->group);
+                       }
                }
-               return 0;
-       }
-       buf = kmap(page_buf);
-
-       /* be to le */
-       blkdev->capacity = be64_to_cpu(*(unsigned long long *) &buf[0]) + 1;
-       blkdev->sector_size = be32_to_cpu(*(unsigned int *)&buf[8]);
 
-#if 0
-       blkdev->capacity = ((buf[0] << 24) | (buf[1] << 16) |
-                           (buf[2] << 8) | buf[3]) + 1;
-       blkdev->sector_size = (buf[4] << 24) | (buf[5] << 16) |
-                             (buf[6] << 8) | buf[7];
-#endif
-
-       kunmap(page_buf);
-
-       __free_page(page_buf);
-
-       kmem_cache_free(blkvsc_req->dev->request_pool, blkvsc_req);
+               kmem_cache_free(blkdev->request_pool, pend_req);
+       }
 
-       return 0;
+out:
+       return ret;
 }
 
+
 /*
  * blkvsc_remove() - Callback when our device is removed
  */
-static int blkvsc_remove(struct device *device)
+static int blkvsc_remove(struct hv_device *dev)
 {
-       struct hv_driver *drv =
-                               drv_to_hv_drv(device->driver);
-       struct storvsc_driver_object *storvsc_drv_obj =
-                               drv->priv;
-       struct hv_device *device_obj = device_to_hv_device(device);
-       struct block_device_context *blkdev = dev_get_drvdata(device);
+       struct block_device_context *blkdev = dev_get_drvdata(&dev->device);
        unsigned long flags;
-       int ret;
 
-       DPRINT_DBG(BLKVSC_DRV, "blkvsc_remove()\n");
-
-       if (!storvsc_drv_obj->base.dev_rm)
-               return -1;
-
-       /*
-        * Call to the vsc driver to let it know that the device is being
-        * removed
-        */
-       ret = storvsc_drv_obj->base.dev_rm(device_obj);
-       if (ret != 0) {
-               /* TODO: */
-               DPRINT_ERR(BLKVSC_DRV,
-                          "unable to remove blkvsc device (ret %d)", ret);
-       }
 
        /* Get to a known state */
        spin_lock_irqsave(&blkdev->lock, flags);
@@ -752,149 +512,77 @@ static int blkvsc_remove(struct device *device)
 
        blk_stop_queue(blkdev->gd->queue);
 
-       spin_unlock_irqrestore(&blkdev->lock, flags);
-
-       while (blkdev->num_outstanding_reqs) {
-               DPRINT_INFO(STORVSC, "waiting for %d requests to complete...",
-                           blkdev->num_outstanding_reqs);
-               udelay(100);
-       }
-
-       blkvsc_do_flush(blkdev);
-
-       spin_lock_irqsave(&blkdev->lock, flags);
-
        blkvsc_cancel_pending_reqs(blkdev);
 
        spin_unlock_irqrestore(&blkdev->lock, flags);
 
+       blkvsc_do_operation(blkdev, DO_FLUSH);
+
        blk_cleanup_queue(blkdev->gd->queue);
 
+       /*
+        * Call to the vsc driver to let it know that the device is being
+        * removed
+        */
+       storvsc_dev_remove(dev);
+
        del_gendisk(blkdev->gd);
 
        kmem_cache_destroy(blkdev->request_pool);
 
        kfree(blkdev);
 
-       return ret;
+       return 0;
+
 }
 
-static void blkvsc_init_rw(struct blkvsc_request *blkvsc_req)
+static void blkvsc_shutdown(struct hv_device *dev)
 {
-       /* ASSERT(blkvsc_req->req); */
-       /* ASSERT(blkvsc_req->sector_count <= (MAX_MULTIPAGE_BUFFER_COUNT*8)); */
-
-       blkvsc_req->cmd_len = 16;
-
-       if (blkvsc_req->sector_start > 0xffffffff) {
-               if (rq_data_dir(blkvsc_req->req)) {
-                       blkvsc_req->write = 1;
-                       blkvsc_req->cmnd[0] = WRITE_16;
-               } else {
-                       blkvsc_req->write = 0;
-                       blkvsc_req->cmnd[0] = READ_16;
-               }
-
-               blkvsc_req->cmnd[1] |=
-                       (blkvsc_req->req->cmd_flags & REQ_FUA) ? 0x8 : 0;
-
-               *(unsigned long long *)&blkvsc_req->cmnd[2] =
-                               cpu_to_be64(blkvsc_req->sector_start);
-               *(unsigned int *)&blkvsc_req->cmnd[10] =
-                               cpu_to_be32(blkvsc_req->sector_count);
-       } else if ((blkvsc_req->sector_count > 0xff) ||
-                  (blkvsc_req->sector_start > 0x1fffff)) {
-               if (rq_data_dir(blkvsc_req->req)) {
-                       blkvsc_req->write = 1;
-                       blkvsc_req->cmnd[0] = WRITE_10;
-               } else {
-                       blkvsc_req->write = 0;
-                       blkvsc_req->cmnd[0] = READ_10;
-               }
+       struct block_device_context *blkdev = dev_get_drvdata(&dev->device);
+       unsigned long flags;
 
-               blkvsc_req->cmnd[1] |=
-                       (blkvsc_req->req->cmd_flags & REQ_FUA) ? 0x8 : 0;
+       if (!blkdev)
+               return;
 
-               *(unsigned int *)&blkvsc_req->cmnd[2] =
-                               cpu_to_be32(blkvsc_req->sector_start);
-               *(unsigned short *)&blkvsc_req->cmnd[7] =
-                               cpu_to_be16(blkvsc_req->sector_count);
-       } else {
-               if (rq_data_dir(blkvsc_req->req)) {
-                       blkvsc_req->write = 1;
-                       blkvsc_req->cmnd[0] = WRITE_6;
-               } else {
-                       blkvsc_req->write = 0;
-                       blkvsc_req->cmnd[0] = READ_6;
-               }
+       spin_lock_irqsave(&blkdev->lock, flags);
 
-               *(unsigned int *)&blkvsc_req->cmnd[1] =
-                               cpu_to_be32(blkvsc_req->sector_start) >> 8;
-               blkvsc_req->cmnd[1] &= 0x1f;
-               blkvsc_req->cmnd[4] = (unsigned char)blkvsc_req->sector_count;
-       }
-}
+       blkdev->shutting_down = 1;
 
-static int blkvsc_submit_request(struct blkvsc_request *blkvsc_req,
-                       void (*request_completion)(struct hv_storvsc_request *))
-{
-       struct block_device_context *blkdev = blkvsc_req->dev;
-       struct hv_device *device_ctx = blkdev->device_ctx;
-       struct hv_driver *drv =
-                       drv_to_hv_drv(device_ctx->device.driver);
-       struct storvsc_driver_object *storvsc_drv_obj =
-                       drv->priv;
-       struct hv_storvsc_request *storvsc_req;
-       int ret;
+       blk_stop_queue(blkdev->gd->queue);
 
-       DPRINT_DBG(BLKVSC_DRV, "blkvsc_submit_request() - "
-                  "req %p type %s start_sector %lu count %ld offset %d "
-                  "len %d\n", blkvsc_req,
-                  (blkvsc_req->write) ? "WRITE" : "READ",
-                  (unsigned long) blkvsc_req->sector_start,
-                  blkvsc_req->sector_count,
-                  blkvsc_req->request.data_buffer.offset,
-                  blkvsc_req->request.data_buffer.len);
-#if 0
-       for (i = 0; i < (blkvsc_req->request.data_buffer.len >> 12); i++) {
-               DPRINT_DBG(BLKVSC_DRV, "blkvsc_submit_request() - "
-                          "req %p pfn[%d] %llx\n",
-                          blkvsc_req, i,
-                          blkvsc_req->request.data_buffer.pfn_array[i]);
-       }
-#endif
+       blkvsc_cancel_pending_reqs(blkdev);
 
-       storvsc_req = &blkvsc_req->request;
-       storvsc_req->extension = (void *)((unsigned long)blkvsc_req +
-                                         sizeof(struct blkvsc_request));
+       spin_unlock_irqrestore(&blkdev->lock, flags);
 
-       storvsc_req->type = blkvsc_req->write ? WRITE_TYPE : READ_TYPE;
+       blkvsc_do_operation(blkdev, DO_FLUSH);
 
-       storvsc_req->on_io_completion = request_completion;
-       storvsc_req->context = blkvsc_req;
+       /*
+        * Now wait for all outgoing I/O to be drained.
+        */
+       storvsc_wait_to_drain((struct storvsc_device *)dev->ext);
 
-       storvsc_req->host = blkdev->port;
-       storvsc_req->bus = blkdev->path;
-       storvsc_req->target_id = blkdev->target;
-       storvsc_req->lun_id = 0;         /* this is not really used at all */
+}
 
-       storvsc_req->cdb_len = blkvsc_req->cmd_len;
-       storvsc_req->cdb = blkvsc_req->cmnd;
+static int blkvsc_release(struct gendisk *disk, fmode_t mode)
+{
+       struct block_device_context *blkdev = disk->private_data;
+       unsigned long flags;
 
-       storvsc_req->sense_buffer = blkvsc_req->sense_buffer;
-       storvsc_req->sense_buffer_size = SCSI_SENSE_BUFFERSIZE;
+       if (blkdev->users == 1) {
+               blkvsc_do_operation(blkdev, DO_FLUSH);
+       }
 
-       ret = storvsc_drv_obj->on_io_request(blkdev->device_ctx,
-                                          &blkvsc_req->request);
-       if (ret == 0)
-               blkdev->num_outstanding_reqs++;
+       spin_lock_irqsave(&blkdev->lock, flags);
+       blkdev->users--;
+       spin_unlock_irqrestore(&blkdev->lock, flags);
 
-       return ret;
+       return 0;
 }
 
+
 /*
  * We break the request into 1 or more blkvsc_requests and submit
- * them.  If we can't submit them all, we put them on the
+ * them.  If we cant submit them all, we put them on the
  * pending_list. The blkvsc_request() will work on the pending_list.
  */
 static int blkvsc_do_request(struct block_device_context *blkdev,
@@ -913,11 +601,8 @@ static int blkvsc_do_request(struct block_device_context *blkdev,
        int pending = 0;
        struct blkvsc_request_group *group = NULL;
 
-       DPRINT_DBG(BLKVSC_DRV, "blkdev %p req %p sect %lu\n", blkdev, req,
-                 (unsigned long)blk_rq_pos(req));
-
        /* Create a group to tie req to list of blkvsc_reqs */
-       group = kmem_cache_alloc(blkdev->request_pool, GFP_ATOMIC);
+       group = kmem_cache_zalloc(blkdev->request_pool, GFP_ATOMIC);
        if (!group)
                return -ENOMEM;
 
@@ -933,11 +618,6 @@ static int blkvsc_do_request(struct block_device_context *blkdev,
                         * Map this bio into an existing or new storvsc request
                         */
                        bio_for_each_segment(bvec, bio, seg_idx) {
-                               DPRINT_DBG(BLKVSC_DRV, "bio_for_each_segment() "
-                                          "- req %p bio %p bvec %p seg_idx %d "
-                                          "databuf_idx %d\n", req, bio, bvec,
-                                          seg_idx, databuf_idx);
-
                                /* Get a new storvsc request */
                                /* 1st-time */
                                if ((!blkvsc_req) ||
@@ -949,10 +629,15 @@ static int blkvsc_do_request(struct block_device_context *blkdev,
                                     (prev_bvec->bv_len != PAGE_SIZE))) {
                                        /* submit the prev one */
                                        if (blkvsc_req) {
-                                               blkvsc_req->sector_start = start_sector;
-                                               sector_div(blkvsc_req->sector_start, (blkdev->sector_size >> 9));
-
-                                               blkvsc_req->sector_count = num_sectors / (blkdev->sector_size >> 9);
+                                               blkvsc_req->sector_start =
+                                               start_sector;
+                                               sector_div(
+                                               blkvsc_req->sector_start,
+                                               (blkdev->sector_size >> 9));
+
+                                               blkvsc_req->sector_count =
+                                               num_sectors /
+                                               (blkdev->sector_size >> 9);
                                                blkvsc_init_rw(blkvsc_req);
                                        }
 
@@ -960,18 +645,24 @@ static int blkvsc_do_request(struct block_device_context *blkdev,
                                         * Create new blkvsc_req to represent
                                         * the current bvec
                                         */
-                                       blkvsc_req = kmem_cache_alloc(blkdev->request_pool, GFP_ATOMIC);
+                                       blkvsc_req =
+                                       kmem_cache_zalloc(
+                                       blkdev->request_pool, GFP_ATOMIC);
                                        if (!blkvsc_req) {
                                                /* free up everything */
                                                list_for_each_entry_safe(
                                                        blkvsc_req, tmp,
                                                        &group->blkvsc_req_list,
                                                        req_entry) {
-                                                       list_del(&blkvsc_req->req_entry);
-                                                       kmem_cache_free(blkdev->request_pool, blkvsc_req);
+                                                       list_del(
+                                                       &blkvsc_req->req_entry);
+                                                       kmem_cache_free(
+                                                       blkdev->request_pool,
+                                                       blkvsc_req);
                                                }
 
-                                               kmem_cache_free(blkdev->request_pool, group);
+                                               kmem_cache_free(
+                                               blkdev->request_pool, group);
                                                return -ENOMEM;
                                        }
 
@@ -980,23 +671,27 @@ static int blkvsc_do_request(struct block_device_context *blkdev,
 
                                        blkvsc_req->dev = blkdev;
                                        blkvsc_req->req = req;
-                                       blkvsc_req->request.data_buffer.offset
-                                               = bvec->bv_offset;
-                                       blkvsc_req->request.data_buffer.len
-                                               = 0;
+                                       blkvsc_req->request.
+                                       data_buffer.offset
+                                       = bvec->bv_offset;
+                                       blkvsc_req->request.
+                                       data_buffer.len = 0;
 
                                        /* Add to the group */
                                        blkvsc_req->group = group;
                                        blkvsc_req->group->outstanding++;
                                        list_add_tail(&blkvsc_req->req_entry,
-                                               &blkvsc_req->group->blkvsc_req_list);
+                                       &blkvsc_req->group->blkvsc_req_list);
 
                                        start_sector += num_sectors;
                                        num_sectors = 0;
                                        databuf_idx = 0;
                                }
 
-                               /* Add the curr bvec/segment to the curr blkvsc_req */
+                               /*
+                                * Add the curr bvec/segment to the curr
+                                * blkvsc_req
+                                */
                                blkvsc_req->request.data_buffer.
                                        pfn_array[databuf_idx]
                                                = page_to_pfn(bvec->bv_page);
@@ -1015,10 +710,6 @@ static int blkvsc_do_request(struct block_device_context *blkdev,
 
        /* Handle the last one */
        if (blkvsc_req) {
-               DPRINT_DBG(BLKVSC_DRV, "blkdev %p req %p group %p count %d\n",
-                          blkdev, req, blkvsc_req->group,
-                          blkvsc_req->group->outstanding);
-
                blkvsc_req->sector_start = start_sector;
                sector_div(blkvsc_req->sector_start,
                           (blkdev->sector_size >> 9));
@@ -1031,13 +722,6 @@ static int blkvsc_do_request(struct block_device_context *blkdev,
 
        list_for_each_entry(blkvsc_req, &group->blkvsc_req_list, req_entry) {
                if (pending) {
-                       DPRINT_DBG(BLKVSC_DRV, "adding blkvsc_req to "
-                                  "pending_list - blkvsc_req %p start_sect %lu"
-                                  " sect_count %ld (%lu %ld)\n", blkvsc_req,
-                                  (unsigned long)blkvsc_req->sector_start,
-                                  blkvsc_req->sector_count,
-                                  (unsigned long)start_sector,
-                                  (unsigned long)num_sectors);
 
                        list_add_tail(&blkvsc_req->pend_entry,
                                      &blkdev->pending_list);
@@ -1050,186 +734,12 @@ static int blkvsc_do_request(struct block_device_context *blkdev,
                                              &blkdev->pending_list);
                        }
 
-                       DPRINT_DBG(BLKVSC_DRV, "submitted blkvsc_req %p "
-                                  "start_sect %lu sect_count %ld (%lu %ld) "
-                                  "ret %d\n", blkvsc_req,
-                                  (unsigned long)blkvsc_req->sector_start,
-                                  blkvsc_req->sector_count,
-                                  (unsigned long)start_sector,
-                                  num_sectors, ret);
                }
        }
 
        return pending;
 }
 
-static void blkvsc_cmd_completion(struct hv_storvsc_request *request)
-{
-       struct blkvsc_request *blkvsc_req =
-                       (struct blkvsc_request *)request->context;
-       struct block_device_context *blkdev =
-                       (struct block_device_context *)blkvsc_req->dev;
-       struct scsi_sense_hdr sense_hdr;
-
-       DPRINT_DBG(BLKVSC_DRV, "blkvsc_cmd_completion() - req %p\n",
-                  blkvsc_req);
-
-       blkdev->num_outstanding_reqs--;
-
-       if (blkvsc_req->request.status)
-               if (scsi_normalize_sense(blkvsc_req->sense_buffer,
-                                        SCSI_SENSE_BUFFERSIZE, &sense_hdr))
-                       scsi_print_sense_hdr("blkvsc", &sense_hdr);
-
-       blkvsc_req->cond = 1;
-       wake_up_interruptible(&blkvsc_req->wevent);
-}
-
-static void blkvsc_request_completion(struct hv_storvsc_request *request)
-{
-       struct blkvsc_request *blkvsc_req =
-                       (struct blkvsc_request *)request->context;
-       struct block_device_context *blkdev =
-                       (struct block_device_context *)blkvsc_req->dev;
-       unsigned long flags;
-       struct blkvsc_request *comp_req, *tmp;
-
-       /* ASSERT(blkvsc_req->group); */
-
-       DPRINT_DBG(BLKVSC_DRV, "blkdev %p blkvsc_req %p group %p type %s "
-                  "sect_start %lu sect_count %ld len %d group outstd %d "
-                  "total outstd %d\n",
-                  blkdev, blkvsc_req, blkvsc_req->group,
-                  (blkvsc_req->write) ? "WRITE" : "READ",
-                  (unsigned long)blkvsc_req->sector_start,
-                  blkvsc_req->sector_count,
-                  blkvsc_req->request.data_buffer.len,
-                  blkvsc_req->group->outstanding,
-                  blkdev->num_outstanding_reqs);
-
-       spin_lock_irqsave(&blkdev->lock, flags);
-
-       blkdev->num_outstanding_reqs--;
-       blkvsc_req->group->outstanding--;
-
-       /*
-        * Only start processing when all the blkvsc_reqs are
-        * completed. This guarantees no out-of-order blkvsc_req
-        * completion when calling end_that_request_first()
-        */
-       if (blkvsc_req->group->outstanding == 0) {
-               list_for_each_entry_safe(comp_req, tmp,
-                                        &blkvsc_req->group->blkvsc_req_list,
-                                        req_entry) {
-                       DPRINT_DBG(BLKVSC_DRV, "completing blkvsc_req %p "
-                                  "sect_start %lu sect_count %ld\n",
-                                  comp_req,
-                                  (unsigned long)comp_req->sector_start,
-                                  comp_req->sector_count);
-
-                       list_del(&comp_req->req_entry);
-
-                       if (!__blk_end_request(comp_req->req,
-                               (!comp_req->request.status ? 0 : -EIO),
-                               comp_req->sector_count * blkdev->sector_size)) {
-                               /*
-                                * All the sectors have been xferred ie the
-                                * request is done
-                                */
-                               DPRINT_DBG(BLKVSC_DRV, "req %p COMPLETED\n",
-                                          comp_req->req);
-                               kmem_cache_free(blkdev->request_pool,
-                                               comp_req->group);
-                       }
-
-                       kmem_cache_free(blkdev->request_pool, comp_req);
-               }
-
-               if (!blkdev->shutting_down) {
-                       blkvsc_do_pending_reqs(blkdev);
-                       blk_start_queue(blkdev->gd->queue);
-                       blkvsc_request(blkdev->gd->queue);
-               }
-       }
-
-       spin_unlock_irqrestore(&blkdev->lock, flags);
-}
-
-static int blkvsc_cancel_pending_reqs(struct block_device_context *blkdev)
-{
-       struct blkvsc_request *pend_req, *tmp;
-       struct blkvsc_request *comp_req, *tmp2;
-
-       int ret = 0;
-
-       DPRINT_DBG(BLKVSC_DRV, "blkvsc_cancel_pending_reqs()");
-
-       /* Flush the pending list first */
-       list_for_each_entry_safe(pend_req, tmp, &blkdev->pending_list,
-                                pend_entry) {
-               /*
-                * The pend_req could be part of a partially completed
-                * request. If so, complete those req first until we
-                * hit the pend_req
-                */
-               list_for_each_entry_safe(comp_req, tmp2,
-                                        &pend_req->group->blkvsc_req_list,
-                                        req_entry) {
-                       DPRINT_DBG(BLKVSC_DRV, "completing blkvsc_req %p "
-                                  "sect_start %lu sect_count %ld\n",
-                                  comp_req,
-                                  (unsigned long) comp_req->sector_start,
-                                  comp_req->sector_count);
-
-                       if (comp_req == pend_req)
-                               break;
-
-                       list_del(&comp_req->req_entry);
-
-                       if (comp_req->req) {
-                               ret = __blk_end_request(comp_req->req,
-                                       (!comp_req->request.status ? 0 : -EIO),
-                                       comp_req->sector_count *
-                                       blkdev->sector_size);
-
-                               /* FIXME: shouldn't this do more than return? */
-                               if (ret)
-                                       goto out;
-                       }
-
-                       kmem_cache_free(blkdev->request_pool, comp_req);
-               }
-
-               DPRINT_DBG(BLKVSC_DRV, "cancelling pending request - %p\n",
-                          pend_req);
-
-               list_del(&pend_req->pend_entry);
-
-               list_del(&pend_req->req_entry);
-
-               if (comp_req->req) {
-                       if (!__blk_end_request(pend_req->req, -EIO,
-                                              pend_req->sector_count *
-                                              blkdev->sector_size)) {
-                               /*
-                                * All the sectors have been xferred ie the
-                                * request is done
-                                */
-                               DPRINT_DBG(BLKVSC_DRV,
-                                          "blkvsc_cancel_pending_reqs() - "
-                                          "req %p COMPLETED\n", pend_req->req);
-                               kmem_cache_free(blkdev->request_pool,
-                                               pend_req->group);
-                       }
-               }
-
-               kmem_cache_free(blkdev->request_pool, pend_req);
-       }
-
-out:
-       return ret;
-}
-
 static int blkvsc_do_pending_reqs(struct block_device_context *blkdev)
 {
        struct blkvsc_request *pend_req, *tmp;
@@ -1238,8 +748,6 @@ static int blkvsc_do_pending_reqs(struct block_device_context *blkdev)
        /* Flush the pending list first */
        list_for_each_entry_safe(pend_req, tmp, &blkdev->pending_list,
                                 pend_entry) {
-               DPRINT_DBG(BLKVSC_DRV, "working off pending_list - %p\n",
-                          pend_req);
 
                ret = blkvsc_submit_request(pend_req,
                                            blkvsc_request_completion);
@@ -1252,19 +760,17 @@ static int blkvsc_do_pending_reqs(struct block_device_context *blkdev)
        return ret;
 }
 
+
 static void blkvsc_request(struct request_queue *queue)
 {
        struct block_device_context *blkdev = NULL;
        struct request *req;
        int ret = 0;
 
-       DPRINT_DBG(BLKVSC_DRV, "- enter\n");
        while ((req = blk_peek_request(queue)) != NULL) {
-               DPRINT_DBG(BLKVSC_DRV, "- req %p\n", req);
 
                blkdev = req->rq_disk->private_data;
-               if (blkdev->shutting_down || req->cmd_type != REQ_TYPE_FS ||
-                   blkdev->media_not_present) {
+               if (blkdev->shutting_down || req->cmd_type != REQ_TYPE_FS) {
                        __blk_end_request_cur(req, 0);
                        continue;
                }
@@ -1272,8 +778,6 @@ static void blkvsc_request(struct request_queue *queue)
                ret = blkvsc_do_pending_reqs(blkdev);
 
                if (ret != 0) {
-                       DPRINT_DBG(BLKVSC_DRV,
-                                  "- stop queue - pending_list not empty\n");
                        blk_stop_queue(queue);
                        break;
                }
@@ -1282,11 +786,9 @@ static void blkvsc_request(struct request_queue *queue)
 
                ret = blkvsc_do_request(blkdev, req);
                if (ret > 0) {
-                       DPRINT_DBG(BLKVSC_DRV, "- stop queue - no room\n");
                        blk_stop_queue(queue);
                        break;
                } else if (ret < 0) {
-                       DPRINT_DBG(BLKVSC_DRV, "- stop queue - no mem\n");
                        blk_requeue_request(queue, req);
                        blk_stop_queue(queue);
                        break;
@@ -1294,191 +796,218 @@ static void blkvsc_request(struct request_queue *queue)
        }
 }
 
-static int blkvsc_open(struct block_device *bdev, fmode_t mode)
-{
-       struct block_device_context *blkdev = bdev->bd_disk->private_data;
-
-       DPRINT_DBG(BLKVSC_DRV, "- users %d disk %s\n", blkdev->users,
-                  blkdev->gd->disk_name);
 
-       mutex_lock(&blkvsc_mutex);
-       spin_lock(&blkdev->lock);
 
-       if (!blkdev->users && blkdev->device_type == DVD_TYPE) {
-               spin_unlock(&blkdev->lock);
-               check_disk_change(bdev);
-               spin_lock(&blkdev->lock);
-       }
-
-       blkdev->users++;
+/* The one and only one */
+static  struct hv_driver blkvsc_drv = {
+       .probe =  blkvsc_probe,
+       .remove =  blkvsc_remove,
+       .shutdown = blkvsc_shutdown,
+};
 
-       spin_unlock(&blkdev->lock);
-       mutex_unlock(&blkvsc_mutex);
-       return 0;
-}
+static const struct block_device_operations block_ops = {
+       .owner = THIS_MODULE,
+       .open = blkvsc_open,
+       .release = blkvsc_release,
+       .getgeo = blkvsc_getgeo,
+       .ioctl  = blkvsc_ioctl,
+};
 
-static int blkvsc_release(struct gendisk *disk, fmode_t mode)
+/*
+ * blkvsc_drv_init -  BlkVsc driver initialization.
+ */
+static int blkvsc_drv_init(void)
 {
-       struct block_device_context *blkdev = disk->private_data;
+       struct hv_driver *drv = &blkvsc_drv;
+       int ret;
 
-       DPRINT_DBG(BLKVSC_DRV, "- users %d disk %s\n", blkdev->users,
-                  blkdev->gd->disk_name);
+       BUILD_BUG_ON(sizeof(sector_t) != 8);
 
-       mutex_lock(&blkvsc_mutex);
-       spin_lock(&blkdev->lock);
-       if (blkdev->users == 1) {
-               spin_unlock(&blkdev->lock);
-               blkvsc_do_flush(blkdev);
-               spin_lock(&blkdev->lock);
-       }
+       memcpy(&drv->dev_type, &dev_type, sizeof(struct hv_guid));
+       drv->name = drv_name;
+       drv->driver.name = drv_name;
 
-       blkdev->users--;
+       /* The driver belongs to vmbus */
+       ret = vmbus_child_driver_register(&drv->driver);
 
-       spin_unlock(&blkdev->lock);
-       mutex_unlock(&blkvsc_mutex);
-       return 0;
+       return ret;
 }
 
-static unsigned int blkvsc_check_events(struct gendisk *gd,
-                                       unsigned int clearing)
+
+static void blkvsc_drv_exit(void)
 {
-       DPRINT_DBG(BLKVSC_DRV, "- enter\n");
-       return DISK_EVENT_MEDIA_CHANGE;
+
+       vmbus_child_driver_unregister(&blkvsc_drv.driver);
 }
 
-static int blkvsc_revalidate_disk(struct gendisk *gd)
+/*
+ * blkvsc_probe - Add a new device for this driver
+ */
+static int blkvsc_probe(struct hv_device *dev)
 {
-       struct block_device_context *blkdev = gd->private_data;
-
-       DPRINT_DBG(BLKVSC_DRV, "- enter\n");
+       struct block_device_context *blkdev = NULL;
+       struct storvsc_device_info device_info;
+       struct storvsc_major_info major_info;
+       int ret = 0;
 
-       if (blkdev->device_type == DVD_TYPE) {
-               blkvsc_do_read_capacity(blkdev);
-               set_capacity(blkdev->gd, blkdev->capacity *
-                           (blkdev->sector_size/512));
-               blk_queue_logical_block_size(gd->queue, blkdev->sector_size);
+       blkdev = kzalloc(sizeof(struct block_device_context), GFP_KERNEL);
+       if (!blkdev) {
+               ret = -ENOMEM;
+               goto cleanup;
        }
-       return 0;
-}
 
-static int blkvsc_getgeo(struct block_device *bd, struct hd_geometry *hg)
-{
-       sector_t total_sectors = get_capacity(bd->bd_disk);
-       sector_t cylinder_times_heads = 0;
-       sector_t temp = 0;
+       INIT_LIST_HEAD(&blkdev->pending_list);
 
-       int sectors_per_track = 0;
-       int heads = 0;
-       int cylinders = 0;
-       int rem = 0;
+       /* Initialize what we can here */
+       spin_lock_init(&blkdev->lock);
 
-       if (total_sectors > (65535 * 16 * 255))
-               total_sectors = (65535 * 16 * 255);
 
-       if (total_sectors >= (65535 * 16 * 63)) {
-               sectors_per_track = 255;
-               heads = 16;
+       blkdev->request_pool = kmem_cache_create(dev_name(&dev->device),
+                                       sizeof(struct blkvsc_request), 0,
+                                       SLAB_HWCACHE_ALIGN, NULL);
+       if (!blkdev->request_pool) {
+               ret = -ENOMEM;
+               goto cleanup;
+       }
 
-               cylinder_times_heads = total_sectors;
-               /* sector_div stores the quotient in cylinder_times_heads */
-               rem = sector_div(cylinder_times_heads, sectors_per_track);
-       } else {
-               sectors_per_track = 17;
 
-               cylinder_times_heads = total_sectors;
-               /* sector_div stores the quotient in cylinder_times_heads */
-               rem = sector_div(cylinder_times_heads, sectors_per_track);
+       ret = blkvsc_device_add(dev, &device_info);
+       if (ret != 0)
+               goto cleanup;
 
-               temp = cylinder_times_heads + 1023;
-               /* sector_div stores the quotient in temp */
-               rem = sector_div(temp, 1024);
+       blkdev->device_ctx = dev;
+       /* this identified the device 0 or 1 */
+       blkdev->target = device_info.target_id;
+       /* this identified the ide ctrl 0 or 1 */
+       blkdev->path = device_info.path_id;
 
-               heads = temp;
+       dev_set_drvdata(&dev->device, blkdev);
 
-               if (heads < 4)
-                       heads = 4;
+       ret = storvsc_get_major_info(&device_info, &major_info);
 
+       if (ret)
+               goto cleanup;
 
-               if (cylinder_times_heads >= (heads * 1024) || (heads > 16)) {
-                       sectors_per_track = 31;
-                       heads = 16;
+       if (major_info.do_register) {
+               ret = register_blkdev(major_info.major, major_info.devname);
 
-                       cylinder_times_heads = total_sectors;
-                       /*
-                        * sector_div stores the quotient in
-                        * cylinder_times_heads
-                        */
-                       rem = sector_div(cylinder_times_heads,
-                                        sectors_per_track);
+               if (ret != 0) {
+                       DPRINT_ERR(BLKVSC_DRV,
+                                  "register_blkdev() failed! ret %d", ret);
+                       goto remove;
                }
+       }
 
-               if (cylinder_times_heads >= (heads * 1024)) {
-                       sectors_per_track = 63;
-                       heads = 16;
+       DPRINT_INFO(BLKVSC_DRV, "blkvsc registered for major %d!!",
+                       major_info.major);
 
-                       cylinder_times_heads = total_sectors;
-                       /*
-                        * sector_div stores the quotient in
-                        * cylinder_times_heads
-                        */
-                       rem = sector_div(cylinder_times_heads,
-                                        sectors_per_track);
-               }
+       blkdev->gd = alloc_disk(BLKVSC_MINORS);
+       if (!blkdev->gd) {
+               ret = -1;
+               goto cleanup;
        }
 
-       temp = cylinder_times_heads;
-       /* sector_div stores the quotient in temp */
-       rem = sector_div(temp, heads);
-       cylinders = temp;
+       blkdev->gd->queue = blk_init_queue(blkvsc_request, &blkdev->lock);
 
-       hg->heads = heads;
-       hg->sectors = sectors_per_track;
-       hg->cylinders = cylinders;
+       blk_queue_max_segment_size(blkdev->gd->queue, PAGE_SIZE);
+       blk_queue_max_segments(blkdev->gd->queue, MAX_MULTIPAGE_BUFFER_COUNT);
+       blk_queue_segment_boundary(blkdev->gd->queue, PAGE_SIZE-1);
+       blk_queue_bounce_limit(blkdev->gd->queue, BLK_BOUNCE_ANY);
+       blk_queue_dma_alignment(blkdev->gd->queue, 511);
 
-       DPRINT_INFO(BLKVSC_DRV, "CHS (%d, %d, %d)", cylinders, heads,
-                   sectors_per_track);
+       blkdev->gd->major = major_info.major;
+       if (major_info.index == 1 || major_info.index == 3)
+               blkdev->gd->first_minor = BLKVSC_MINORS;
+       else
+               blkdev->gd->first_minor = 0;
+       blkdev->gd->fops = &block_ops;
+       blkdev->gd->events = DISK_EVENT_MEDIA_CHANGE;
+       blkdev->gd->private_data = blkdev;
+       blkdev->gd->driverfs_dev = &(blkdev->device_ctx->device);
+       sprintf(blkdev->gd->disk_name, "hd%c", 'a' + major_info.index);
 
-    return 0;
-}
+       blkvsc_do_operation(blkdev, DO_INQUIRY);
+       blkvsc_do_operation(blkdev, DO_CAPACITY);
 
-static int blkvsc_ioctl(struct block_device *bd, fmode_t mode,
-                       unsigned cmd, unsigned long argument)
-{
-/*     struct block_device_context *blkdev = bd->bd_disk->private_data; */
-       int ret;
+       set_capacity(blkdev->gd, blkdev->capacity * (blkdev->sector_size/512));
+       blk_queue_logical_block_size(blkdev->gd->queue, blkdev->sector_size);
+       /* go! */
+       add_disk(blkdev->gd);
 
-       switch (cmd) {
-       /*
-        * TODO: I think there is certain format for HDIO_GET_IDENTITY rather
-        * than just a GUID. Commented it out for now.
-        */
-#if 0
-       case HDIO_GET_IDENTITY:
-               DPRINT_INFO(BLKVSC_DRV, "HDIO_GET_IDENTITY\n");
-               if (copy_to_user((void __user *)arg, blkdev->device_id,
-                                blkdev->device_id_len))
-                       ret = -EFAULT;
-               break;
-#endif
-       default:
-               ret = -EINVAL;
-               break;
+       DPRINT_INFO(BLKVSC_DRV, "%s added!! capacity %lu sector_size %d",
+                   blkdev->gd->disk_name, (unsigned long)blkdev->capacity,
+                   blkdev->sector_size);
+
+       return ret;
+
+remove:
+       storvsc_dev_remove(dev);
+
+cleanup:
+       if (blkdev) {
+               if (blkdev->request_pool) {
+                       kmem_cache_destroy(blkdev->request_pool);
+                       blkdev->request_pool = NULL;
+               }
+               kfree(blkdev);
+               blkdev = NULL;
        }
 
        return ret;
 }
 
-static int __init blkvsc_init(void)
+static void blkvsc_request_completion(struct hv_storvsc_request *request)
 {
-       int ret;
+       struct blkvsc_request *blkvsc_req =
+                       (struct blkvsc_request *)request->context;
+       struct block_device_context *blkdev =
+                       (struct block_device_context *)blkvsc_req->dev;
+       unsigned long flags;
+       struct blkvsc_request *comp_req, *tmp;
+       struct vmscsi_request *vm_srb;
 
-       BUILD_BUG_ON(sizeof(sector_t) != 8);
 
-       DPRINT_INFO(BLKVSC_DRV, "Blkvsc initializing....");
+       spin_lock_irqsave(&blkdev->lock, flags);
 
-       ret = blkvsc_drv_init(blk_vsc_initialize);
+       blkdev->num_outstanding_reqs--;
+       blkvsc_req->group->outstanding--;
 
-       return ret;
+       /*
+        * Only start processing when all the blkvsc_reqs are
+        * completed. This guarantees no out-of-order blkvsc_req
+        * completion when calling end_that_request_first()
+        */
+       if (blkvsc_req->group->outstanding == 0) {
+               list_for_each_entry_safe(comp_req, tmp,
+                                        &blkvsc_req->group->blkvsc_req_list,
+                                        req_entry) {
+
+                       list_del(&comp_req->req_entry);
+
+                       vm_srb =
+                       &comp_req->request.vstor_packet.vm_srb;
+                       if (!__blk_end_request(comp_req->req,
+                               (!vm_srb->scsi_status ? 0 : -EIO),
+                               comp_req->sector_count * blkdev->sector_size)) {
+                               /*
+                                * All the sectors have been xferred ie the
+                                * request is done
+                                */
+                               kmem_cache_free(blkdev->request_pool,
+                                               comp_req->group);
+                       }
+
+                       kmem_cache_free(blkdev->request_pool, comp_req);
+               }
+
+               if (!blkdev->shutting_down) {
+                       blkvsc_do_pending_reqs(blkdev);
+                       blk_start_queue(blkdev->gd->queue);
+                       blkvsc_request(blkdev->gd->queue);
+               }
+       }
+
+       spin_unlock_irqrestore(&blkdev->lock, flags);
 }
 
 static void __exit blkvsc_exit(void)
@@ -1489,5 +1018,5 @@ static void __exit blkvsc_exit(void)
 MODULE_LICENSE("GPL");
 MODULE_VERSION(HV_DRV_VERSION);
 MODULE_DESCRIPTION("Microsoft Hyper-V virtual block driver");
-module_init(blkvsc_init);
+module_init(blkvsc_drv_init);
 module_exit(blkvsc_exit);
index f7ce7d2494b38c7e7fbf80c489864e6d86f98a56..f655e59a9a8fb3c6cba0515dded3c609687166c8 100644 (file)
  *   Haiyang Zhang <haiyangz@microsoft.com>
  *   Hank Janssen  <hjanssen@microsoft.com>
  */
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/kernel.h>
 #include <linux/sched.h>
 #include <linux/wait.h>
 #include <linux/mm.h>
 #include <linux/slab.h>
 #include <linux/module.h>
-#include "hv_api.h"
-#include "logging.h"
-#include "vmbus_private.h"
+
+#include "hyperv.h"
+#include "hyperv_vmbus.h"
 
 #define NUM_PAGES_SPANNED(addr, len) \
 ((PAGE_ALIGN(addr + len) >> PAGE_SHIFT) - (addr >> PAGE_SHIFT))
@@ -40,37 +42,6 @@ static int create_gpadl_header(
 static void dump_vmbus_channel(struct vmbus_channel *channel);
 static void vmbus_setevent(struct vmbus_channel *channel);
 
-
-#if 0
-static void DumpMonitorPage(struct hv_monitor_page *MonitorPage)
-{
-       int i = 0;
-       int j = 0;
-
-       DPRINT_DBG(VMBUS, "monitorPage - %p, trigger state - %d",
-                  MonitorPage, MonitorPage->trigger_state);
-
-       for (i = 0; i < 4; i++)
-               DPRINT_DBG(VMBUS, "trigger group (%d) - %llx", i,
-                          MonitorPage->trigger_group[i].as_uint64);
-
-       for (i = 0; i < 4; i++) {
-               for (j = 0; j < 32; j++) {
-                       DPRINT_DBG(VMBUS, "latency (%d)(%d) - %llx", i, j,
-                                  MonitorPage->latency[i][j]);
-               }
-       }
-       for (i = 0; i < 4; i++) {
-               for (j = 0; j < 32; j++) {
-                       DPRINT_DBG(VMBUS, "param-conn id (%d)(%d) - %d", i, j,
-                              MonitorPage->parameter[i][j].connectionid.asu32);
-                       DPRINT_DBG(VMBUS, "param-flag (%d)(%d) - %d", i, j,
-                               MonitorPage->parameter[i][j].flag_number);
-               }
-       }
-}
-#endif
-
 /*
  * vmbus_setevent- Trigger an event notification on the specified
  * channel.
@@ -97,28 +68,6 @@ static void vmbus_setevent(struct vmbus_channel *channel)
        }
 }
 
-#if 0
-static void VmbusChannelClearEvent(struct vmbus_channel *channel)
-{
-       struct hv_monitor_page *monitorPage;
-
-       if (Channel->offermsg.monitor_allocated) {
-               /* Each u32 represents 32 channels */
-               sync_clear_bit(Channel->offermsg.child_relid & 31,
-                         (unsigned long *)vmbus_connection.send_int_page +
-                         (Channel->offermsg.child_relid >> 5));
-
-               monitorPage = (struct hv_monitor_page *)
-                       vmbus_connection.monitor_pages;
-               monitorPage++; /* Get the child to parent monitor page */
-
-               sync_clear_bit(Channel->monitor_bit,
-                         (unsigned long *)&monitorPage->trigger_group
-                                       [Channel->monitor_grp].Pending);
-       }
-}
-
-#endif
 /*
  * vmbus_get_debug_info -Retrieve various channel debug info
  */
@@ -160,8 +109,8 @@ void vmbus_get_debug_info(struct vmbus_channel *channel,
                        monitorpage->parameter[monitor_group]
                                        [monitor_offset].connectionid.u.id;
 
-       ringbuffer_get_debuginfo(&channel->inbound, &debuginfo->inbound);
-       ringbuffer_get_debuginfo(&channel->outbound, &debuginfo->outbound);
+       hv_ringbuffer_get_debuginfo(&channel->inbound, &debuginfo->inbound);
+       hv_ringbuffer_get_debuginfo(&channel->outbound, &debuginfo->outbound);
 }
 
 /*
@@ -175,11 +124,7 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
        struct vmbus_channel_msginfo *openInfo = NULL;
        void *in, *out;
        unsigned long flags;
-       int ret, err = 0;
-
-       /* Aligned to page size */
-       /* ASSERT(!(SendRingBufferSize & (PAGE_SIZE - 1))); */
-       /* ASSERT(!(RecvRingBufferSize & (PAGE_SIZE - 1))); */
+       int ret, t, err = 0;
 
        newchannel->onchannel_callback = onchannelcallback;
        newchannel->channel_callback_context = context;
@@ -191,7 +136,6 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
        if (!out)
                return -ENOMEM;
 
-       /* ASSERT(((unsigned long)out & (PAGE_SIZE-1)) == 0); */
 
        in = (void *)((unsigned long)out + send_ringbuffer_size);
 
@@ -199,13 +143,16 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
        newchannel->ringbuffer_pagecount = (send_ringbuffer_size +
                                           recv_ringbuffer_size) >> PAGE_SHIFT;
 
-       ret = ringbuffer_init(&newchannel->outbound, out, send_ringbuffer_size);
+       ret = hv_ringbuffer_init(
+               &newchannel->outbound, out, send_ringbuffer_size);
+
        if (ret != 0) {
                err = ret;
                goto errorout;
        }
 
-       ret = ringbuffer_init(&newchannel->inbound, in, recv_ringbuffer_size);
+       ret = hv_ringbuffer_init(
+               &newchannel->inbound, in, recv_ringbuffer_size);
        if (ret != 0) {
                err = ret;
                goto errorout;
@@ -213,9 +160,6 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
 
 
        /* Establish the gpadl for the ring buffer */
-       DPRINT_DBG(VMBUS, "Establishing ring buffer's gpadl for channel %p...",
-                  newchannel);
-
        newchannel->ringbuffer_gpadlhandle = 0;
 
        ret = vmbus_establish_gpadl(newchannel,
@@ -229,16 +173,6 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
                goto errorout;
        }
 
-       DPRINT_DBG(VMBUS, "channel %p <relid %d gpadl 0x%x send ring %p "
-                  "size %d recv ring %p size %d, downstreamoffset %d>",
-                  newchannel, newchannel->offermsg.child_relid,
-                  newchannel->ringbuffer_gpadlhandle,
-                  newchannel->outbound.ring_buffer,
-                  newchannel->outbound.ring_size,
-                  newchannel->inbound.ring_buffer,
-                  newchannel->inbound.ring_size,
-                  send_ringbuffer_size);
-
        /* Create and init the channel open message */
        openInfo = kmalloc(sizeof(*openInfo) +
                           sizeof(struct vmbus_channel_open_channel),
@@ -248,7 +182,7 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
                goto errorout;
        }
 
-       init_waitqueue_head(&openInfo->waitevent);
+       init_completion(&openInfo->waitevent);
 
        openMsg = (struct vmbus_channel_open_channel *)openInfo->msg;
        openMsg->header.msgtype = CHANNELMSG_OPENCHANNEL;
@@ -272,30 +206,21 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
                      &vmbus_connection.chn_msg_list);
        spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
 
-       DPRINT_DBG(VMBUS, "Sending channel open msg...");
-
        ret = vmbus_post_msg(openMsg,
                               sizeof(struct vmbus_channel_open_channel));
-       if (ret != 0) {
-               DPRINT_ERR(VMBUS, "unable to open channel - %d", ret);
+
+       if (ret != 0)
                goto Cleanup;
-       }
 
-       openInfo->wait_condition = 0;
-       wait_event_timeout(openInfo->waitevent,
-                       openInfo->wait_condition,
-                       msecs_to_jiffies(1000));
-       if (openInfo->wait_condition == 0) {
+       t = wait_for_completion_timeout(&openInfo->waitevent, HZ);
+       if (t == 0) {
                err = -ETIMEDOUT;
                goto errorout;
        }
 
 
-       if (openInfo->response.open_result.status == 0)
-               DPRINT_INFO(VMBUS, "channel <%p> open success!!", newchannel);
-       else
-               DPRINT_INFO(VMBUS, "channel <%p> open failed - %d!!",
-                           newchannel, openInfo->response.open_result.status);
+       if (openInfo->response.open_result.status)
+               err = openInfo->response.open_result.status;
 
 Cleanup:
        spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags);
@@ -303,11 +228,11 @@ Cleanup:
        spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
 
        kfree(openInfo);
-       return 0;
+       return err;
 
 errorout:
-       ringbuffer_cleanup(&newchannel->outbound);
-       ringbuffer_cleanup(&newchannel->inbound);
+       hv_ringbuffer_cleanup(&newchannel->outbound);
+       hv_ringbuffer_cleanup(&newchannel->inbound);
        free_pages((unsigned long)out,
                get_order(send_ringbuffer_size + recv_ringbuffer_size));
        kfree(openInfo);
@@ -326,6 +251,7 @@ static void dump_gpadl_body(struct vmbus_channel_gpadl_body *gpadl, u32 len)
 
        pfncount = (len - sizeof(struct vmbus_channel_gpadl_body)) /
                   sizeof(u64);
+
        DPRINT_DBG(VMBUS, "gpadl body - len %d pfn count %d", len, pfncount);
 
        for (i = 0; i < pfncount; i++)
@@ -377,9 +303,6 @@ static int create_gpadl_header(void *kbuffer, u32 size,
 
        int pfnsum, pfncount, pfnleft, pfncurr, pfnsize;
 
-       /* ASSERT((kbuffer & (PAGE_SIZE-1)) == 0); */
-       /* ASSERT((Size & (PAGE_SIZE-1)) == 0); */
-
        pagecount = size >> PAGE_SHIFT;
        pfn = virt_to_phys(kbuffer) >> PAGE_SHIFT;
 
@@ -508,6 +431,7 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
        u32 next_gpadl_handle;
        unsigned long flags;
        int ret = 0;
+       int t;
 
        next_gpadl_handle = atomic_read(&vmbus_connection.next_gpadl_handle);
        atomic_inc(&vmbus_connection.next_gpadl_handle);
@@ -516,7 +440,7 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
        if (ret)
                return ret;
 
-       init_waitqueue_head(&msginfo->waitevent);
+       init_completion(&msginfo->waitevent);
 
        gpadlmsg = (struct vmbus_channel_gpadl_header *)msginfo->msg;
        gpadlmsg->header.msgtype = CHANNELMSG_GPADL_HEADER;
@@ -530,19 +454,11 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
                      &vmbus_connection.chn_msg_list);
 
        spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
-       DPRINT_DBG(VMBUS, "buffer %p, size %d msg cnt %d",
-                  kbuffer, size, msgcount);
 
-       DPRINT_DBG(VMBUS, "Sending GPADL Header - len %zd",
-                  msginfo->msgsize - sizeof(*msginfo));
-
-       msginfo->wait_condition = 0;
        ret = vmbus_post_msg(gpadlmsg, msginfo->msgsize -
                               sizeof(*msginfo));
-       if (ret != 0) {
-               DPRINT_ERR(VMBUS, "Unable to open channel - %d", ret);
+       if (ret != 0)
                goto Cleanup;
-       }
 
        if (msgcount > 1) {
                list_for_each(curr, &msginfo->submsglist) {
@@ -556,10 +472,6 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
                                CHANNELMSG_GPADL_BODY;
                        gpadl_body->gpadl = next_gpadl_handle;
 
-                       DPRINT_DBG(VMBUS, "Sending GPADL Body - len %zd",
-                                  submsginfo->msgsize -
-                                  sizeof(*submsginfo));
-
                        dump_gpadl_body(gpadl_body, submsginfo->msgsize -
                                      sizeof(*submsginfo));
                        ret = vmbus_post_msg(gpadl_body,
@@ -570,19 +482,11 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
 
                }
        }
-       wait_event_timeout(msginfo->waitevent,
-                               msginfo->wait_condition,
-                               msecs_to_jiffies(1000));
-       BUG_ON(msginfo->wait_condition == 0);
+       t = wait_for_completion_timeout(&msginfo->waitevent, HZ);
+       BUG_ON(t == 0);
 
 
        /* At this point, we received the gpadl created msg */
-       DPRINT_DBG(VMBUS, "Received GPADL created "
-                  "(relid %d, status %d handle %x)",
-                  channel->offermsg.child_relid,
-                  msginfo->response.gpadl_created.creation_status,
-                  gpadlmsg->gpadl);
-
        *gpadl_handle = gpadlmsg->gpadl;
 
 Cleanup:
@@ -603,7 +507,7 @@ int vmbus_teardown_gpadl(struct vmbus_channel *channel, u32 gpadl_handle)
        struct vmbus_channel_gpadl_teardown *msg;
        struct vmbus_channel_msginfo *info;
        unsigned long flags;
-       int ret;
+       int ret, t;
 
        /* ASSERT(gpadl_handle != 0); */
 
@@ -612,7 +516,7 @@ int vmbus_teardown_gpadl(struct vmbus_channel *channel, u32 gpadl_handle)
        if (!info)
                return -ENOMEM;
 
-       init_waitqueue_head(&info->waitevent);
+       init_completion(&info->waitevent);
 
        msg = (struct vmbus_channel_gpadl_teardown *)info->msg;
 
@@ -624,14 +528,12 @@ int vmbus_teardown_gpadl(struct vmbus_channel *channel, u32 gpadl_handle)
        list_add_tail(&info->msglistentry,
                      &vmbus_connection.chn_msg_list);
        spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
-       info->wait_condition = 0;
        ret = vmbus_post_msg(msg,
                               sizeof(struct vmbus_channel_gpadl_teardown));
 
        BUG_ON(ret != 0);
-       wait_event_timeout(info->waitevent,
-                       info->wait_condition, msecs_to_jiffies(1000));
-       BUG_ON(info->wait_condition == 0);
+       t = wait_for_completion_timeout(&info->waitevent, HZ);
+       BUG_ON(t == 0);
 
        /* Received a torndown response */
        spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags);
@@ -681,8 +583,8 @@ void vmbus_close(struct vmbus_channel *channel)
        /* TODO: Send a msg to release the childRelId */
 
        /* Cleanup the ring buffers for this channel */
-       ringbuffer_cleanup(&channel->outbound);
-       ringbuffer_cleanup(&channel->inbound);
+       hv_ringbuffer_cleanup(&channel->outbound);
+       hv_ringbuffer_cleanup(&channel->inbound);
 
        free_pages((unsigned long)channel->ringbuffer_pages,
                get_order(channel->ringbuffer_pagecount * PAGE_SIZE));
@@ -730,13 +632,8 @@ int vmbus_sendpacket(struct vmbus_channel *channel, const void *buffer,
        u64 aligned_data = 0;
        int ret;
 
-       DPRINT_DBG(VMBUS, "channel %p buffer %p len %d",
-                  channel, buffer, bufferlen);
-
        dump_vmbus_channel(channel);
 
-       /* ASSERT((packetLenAligned - packetLen) < sizeof(u64)); */
-
        /* Setup the descriptor */
        desc.type = type; /* VmbusPacketTypeDataInBand; */
        desc.flags = flags; /* VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED; */
@@ -751,10 +648,10 @@ int vmbus_sendpacket(struct vmbus_channel *channel, const void *buffer,
        sg_set_buf(&bufferlist[2], &aligned_data,
                   packetlen_aligned - packetlen);
 
-       ret = ringbuffer_write(&channel->outbound, bufferlist, 3);
+       ret = hv_ringbuffer_write(&channel->outbound, bufferlist, 3);
 
        /* TODO: We should determine if this is optional */
-       if (ret == 0 && !get_ringbuffer_interrupt_mask(&channel->outbound))
+       if (ret == 0 && !hv_get_ringbuffer_interrupt_mask(&channel->outbound))
                vmbus_setevent(channel);
 
        return ret;
@@ -794,8 +691,6 @@ int vmbus_sendpacket_pagebuffer(struct vmbus_channel *channel,
        packetlen = descsize + bufferlen;
        packetlen_aligned = ALIGN(packetlen, sizeof(u64));
 
-       /* ASSERT((packetLenAligned - packetLen) < sizeof(u64)); */
-
        /* Setup the descriptor */
        desc.type = VM_PKT_DATA_USING_GPA_DIRECT;
        desc.flags = VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED;
@@ -816,10 +711,10 @@ int vmbus_sendpacket_pagebuffer(struct vmbus_channel *channel,
        sg_set_buf(&bufferlist[2], &aligned_data,
                packetlen_aligned - packetlen);
 
-       ret = ringbuffer_write(&channel->outbound, bufferlist, 3);
+       ret = hv_ringbuffer_write(&channel->outbound, bufferlist, 3);
 
        /* TODO: We should determine if this is optional */
-       if (ret == 0 && !get_ringbuffer_interrupt_mask(&channel->outbound))
+       if (ret == 0 && !hv_get_ringbuffer_interrupt_mask(&channel->outbound))
                vmbus_setevent(channel);
 
        return ret;
@@ -846,10 +741,6 @@ int vmbus_sendpacket_multipagebuffer(struct vmbus_channel *channel,
 
        dump_vmbus_channel(channel);
 
-       DPRINT_DBG(VMBUS, "data buffer - offset %u len %u pfn count %u",
-               multi_pagebuffer->offset,
-               multi_pagebuffer->len, pfncount);
-
        if ((pfncount < 0) || (pfncount > MAX_MULTIPAGE_BUFFER_COUNT))
                return -EINVAL;
 
@@ -863,7 +754,6 @@ int vmbus_sendpacket_multipagebuffer(struct vmbus_channel *channel,
        packetlen = descsize + bufferlen;
        packetlen_aligned = ALIGN(packetlen, sizeof(u64));
 
-       /* ASSERT((packetLenAligned - packetLen) < sizeof(u64)); */
 
        /* Setup the descriptor */
        desc.type = VM_PKT_DATA_USING_GPA_DIRECT;
@@ -885,10 +775,10 @@ int vmbus_sendpacket_multipagebuffer(struct vmbus_channel *channel,
        sg_set_buf(&bufferlist[2], &aligned_data,
                packetlen_aligned - packetlen);
 
-       ret = ringbuffer_write(&channel->outbound, bufferlist, 3);
+       ret = hv_ringbuffer_write(&channel->outbound, bufferlist, 3);
 
        /* TODO: We should determine if this is optional */
-       if (ret == 0 && !get_ringbuffer_interrupt_mask(&channel->outbound))
+       if (ret == 0 && !hv_get_ringbuffer_interrupt_mask(&channel->outbound))
                vmbus_setevent(channel);
 
        return ret;
@@ -922,32 +812,22 @@ int vmbus_recvpacket(struct vmbus_channel *channel, void *buffer,
 
        spin_lock_irqsave(&channel->inbound_lock, flags);
 
-       ret = ringbuffer_peek(&channel->inbound, &desc,
+       ret = hv_ringbuffer_peek(&channel->inbound, &desc,
                             sizeof(struct vmpacket_descriptor));
        if (ret != 0) {
                spin_unlock_irqrestore(&channel->inbound_lock, flags);
-
-               /* DPRINT_DBG(VMBUS, "nothing to read!!"); */
                return 0;
        }
 
-       /* VmbusChannelClearEvent(Channel); */
-
        packetlen = desc.len8 << 3;
        userlen = packetlen - (desc.offset8 << 3);
-       /* ASSERT(userLen > 0); */
-
-       DPRINT_DBG(VMBUS, "packet received on channel %p relid %d <type %d "
-                  "flag %d tid %llx pktlen %d datalen %d> ",
-                  channel, channel->offermsg.child_relid, desc.type,
-                  desc.flags, desc.trans_id, packetlen, userlen);
 
        *buffer_actual_len = userlen;
 
        if (userlen > bufferlen) {
                spin_unlock_irqrestore(&channel->inbound_lock, flags);
 
-               DPRINT_ERR(VMBUS, "buffer too small - got %d needs %d",
+               pr_err("Buffer too small - got %d needs %d\n",
                           bufferlen, userlen);
                return -1;
        }
@@ -955,7 +835,7 @@ int vmbus_recvpacket(struct vmbus_channel *channel, void *buffer,
        *requestid = desc.trans_id;
 
        /* Copy over the packet to the user buffer */
-       ret = ringbuffer_read(&channel->inbound, buffer, userlen,
+       ret = hv_ringbuffer_read(&channel->inbound, buffer, userlen,
                             (desc.offset8 << 3));
 
        spin_unlock_irqrestore(&channel->inbound_lock, flags);
@@ -982,39 +862,32 @@ int vmbus_recvpacket_raw(struct vmbus_channel *channel, void *buffer,
 
        spin_lock_irqsave(&channel->inbound_lock, flags);
 
-       ret = ringbuffer_peek(&channel->inbound, &desc,
+       ret = hv_ringbuffer_peek(&channel->inbound, &desc,
                             sizeof(struct vmpacket_descriptor));
        if (ret != 0) {
                spin_unlock_irqrestore(&channel->inbound_lock, flags);
-
-               /* DPRINT_DBG(VMBUS, "nothing to read!!"); */
                return 0;
        }
 
-       /* VmbusChannelClearEvent(Channel); */
 
        packetlen = desc.len8 << 3;
        userlen = packetlen - (desc.offset8 << 3);
 
-       DPRINT_DBG(VMBUS, "packet received on channel %p relid %d <type %d "
-                  "flag %d tid %llx pktlen %d datalen %d> ",
-                  channel, channel->offermsg.child_relid, desc.type,
-                  desc.flags, desc.trans_id, packetlen, userlen);
-
        *buffer_actual_len = packetlen;
 
        if (packetlen > bufferlen) {
                spin_unlock_irqrestore(&channel->inbound_lock, flags);
 
-               DPRINT_ERR(VMBUS, "buffer too small - needed %d bytes but "
-                          "got space for only %d bytes", packetlen, bufferlen);
+               pr_err("Buffer too small - needed %d bytes but "
+                       "got space for only %d bytes\n",
+                       packetlen, bufferlen);
                return -2;
        }
 
        *requestid = desc.trans_id;
 
        /* Copy over the entire packet to the user buffer */
-       ret = ringbuffer_read(&channel->inbound, buffer, packetlen, 0);
+       ret = hv_ringbuffer_read(&channel->inbound, buffer, packetlen, 0);
 
        spin_unlock_irqrestore(&channel->inbound_lock, flags);
        return 0;
@@ -1027,7 +900,6 @@ EXPORT_SYMBOL_GPL(vmbus_recvpacket_raw);
 void vmbus_onchannel_event(struct vmbus_channel *channel)
 {
        dump_vmbus_channel(channel);
-       /* ASSERT(Channel->OnChannelCallback); */
 
        channel->onchannel_callback(channel->channel_callback_context);
 
@@ -1051,6 +923,6 @@ void vmbus_ontimer(unsigned long data)
 static void dump_vmbus_channel(struct vmbus_channel *channel)
 {
        DPRINT_DBG(VMBUS, "Channel (%d)", channel->offermsg.child_relid);
-       dump_ring_info(&channel->outbound, "Outbound ");
-       dump_ring_info(&channel->inbound, "Inbound ");
+       hv_dump_ring_info(&channel->outbound, "Outbound ");
+       hv_dump_ring_info(&channel->inbound, "Inbound ");
 }
diff --git a/drivers/staging/hv/channel.h b/drivers/staging/hv/channel.h
deleted file mode 100644 (file)
index de4f867..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- *
- * Copyright (c) 2009, Microsoft Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place - Suite 330, Boston, MA 02111-1307 USA.
- *
- * Authors:
- *   Haiyang Zhang <haiyangz@microsoft.com>
- *   Hank Janssen  <hjanssen@microsoft.com>
- *
- */
-
-
-#ifndef _CHANNEL_H_
-#define _CHANNEL_H_
-
-#include "channel_mgmt.h"
-
-/* The format must be the same as struct vmdata_gpa_direct */
-struct vmbus_channel_packet_page_buffer {
-       u16 type;
-       u16 dataoffset8;
-       u16 length8;
-       u16 flags;
-       u64 transactionid;
-       u32 reserved;
-       u32 rangecount;
-       struct hv_page_buffer range[MAX_PAGE_BUFFER_COUNT];
-} __packed;
-
-/* The format must be the same as struct vmdata_gpa_direct */
-struct vmbus_channel_packet_multipage_buffer {
-       u16 type;
-       u16 dataoffset8;
-       u16 length8;
-       u16 flags;
-       u64 transactionid;
-       u32 reserved;
-       u32 rangecount;         /* Always 1 in this case */
-       struct hv_multipage_buffer range;
-} __packed;
-
-
-extern int vmbus_open(struct vmbus_channel *channel,
-                           u32 send_ringbuffersize,
-                           u32 recv_ringbuffersize,
-                           void *userdata,
-                           u32 userdatalen,
-                           void(*onchannel_callback)(void *context),
-                           void *context);
-
-extern void vmbus_close(struct vmbus_channel *channel);
-
-extern int vmbus_sendpacket(struct vmbus_channel *channel,
-                                 const void *buffer,
-                                 u32 bufferLen,
-                                 u64 requestid,
-                                 enum vmbus_packet_type type,
-                                 u32 flags);
-
-extern int vmbus_sendpacket_pagebuffer(struct vmbus_channel *channel,
-                                           struct hv_page_buffer pagebuffers[],
-                                           u32 pagecount,
-                                           void *buffer,
-                                           u32 bufferlen,
-                                           u64 requestid);
-
-extern int vmbus_sendpacket_multipagebuffer(struct vmbus_channel *channel,
-                                       struct hv_multipage_buffer *mpb,
-                                       void *buffer,
-                                       u32 bufferlen,
-                                       u64 requestid);
-
-extern int vmbus_establish_gpadl(struct vmbus_channel *channel,
-                                     void *kbuffer,
-                                     u32 size,
-                                     u32 *gpadl_handle);
-
-extern int vmbus_teardown_gpadl(struct vmbus_channel *channel,
-                                    u32 gpadl_handle);
-
-extern int vmbus_recvpacket(struct vmbus_channel *channel,
-                                 void *buffer,
-                                 u32 bufferlen,
-                                 u32 *buffer_actual_len,
-                                 u64 *requestid);
-
-extern int vmbus_recvpacket_raw(struct vmbus_channel *channel,
-                                    void *buffer,
-                                    u32 bufferlen,
-                                    u32 *buffer_actual_len,
-                                    u64 *requestid);
-
-extern void vmbus_onchannel_event(struct vmbus_channel *channel);
-
-extern void vmbus_get_debug_info(struct vmbus_channel *channel,
-                                    struct vmbus_channel_debug_info *debug);
-
-extern void vmbus_ontimer(unsigned long data);
-
-#endif /* _CHANNEL_H_ */
index 06b573227e8dd9dfb72a28ff7bfdac3dd8ed0cfe..957d61ee4cebe2f2f9b02edd84c077fe1491b738 100644 (file)
@@ -18,6 +18,8 @@
  *   Haiyang Zhang <haiyangz@microsoft.com>
  *   Hank Janssen  <hjanssen@microsoft.com>
  */
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/kernel.h>
 #include <linux/sched.h>
 #include <linux/wait.h>
 #include <linux/list.h>
 #include <linux/module.h>
 #include <linux/completion.h>
-#include "hv_api.h"
-#include "logging.h"
-#include "vmbus_private.h"
-#include "utils.h"
+
+#include "hyperv.h"
+#include "hyperv_vmbus.h"
 
 struct vmbus_channel_message_table_entry {
-       enum vmbus_channel_message_type messageType;
-       void (*messageHandler)(struct vmbus_channel_message_header *msg);
+       enum vmbus_channel_message_type message_type;
+       void (*message_handler)(struct vmbus_channel_message_header *msg);
 };
 
 #define MAX_MSG_TYPES                    4
 #define MAX_NUM_DEVICE_CLASSES_SUPPORTED 8
 
 static const struct hv_guid
-       gSupportedDeviceClasses[MAX_NUM_DEVICE_CLASSES_SUPPORTED] = {
+       supported_device_classes[MAX_NUM_DEVICE_CLASSES_SUPPORTED] = {
        /* {ba6163d9-04a1-4d29-b605-72e2ffb1dc7f} */
        /* Storage - SCSI */
        {
@@ -180,6 +181,24 @@ void chn_cb_negotiate(void *context)
        struct icmsg_hdr *icmsghdrp;
        struct icmsg_negotiate *negop = NULL;
 
+       if (channel->util_index >= 0) {
+               /*
+                * This is a properly initialized util channel.
+                * Route this callback appropriately and setup state
+                * so that we don't need to reroute again.
+                */
+               if (hv_cb_utils[channel->util_index].callback != NULL) {
+                       /*
+                        * The util driver has established a handler for
+                        * this service; do the magic.
+                        */
+                       channel->onchannel_callback =
+                       hv_cb_utils[channel->util_index].callback;
+                       (hv_cb_utils[channel->util_index].callback)(channel);
+                       return;
+               }
+       }
+
        buflen = PAGE_SIZE;
        buf = kmalloc(buflen, GFP_ATOMIC);
 
@@ -216,7 +235,6 @@ struct hyperv_service_callback hv_cb_utils[MAX_MSG_TYPES] = {
                        0x31, 0x60, 0x0B, 0X0E, 0x13, 0x52, 0x34, 0x49,
                        0x81, 0x8B, 0x38, 0XD9, 0x0C, 0xED, 0x39, 0xDB
                },
-               .callback = chn_cb_negotiate,
                .log_msg = "Shutdown channel functionality initialized"
        },
 
@@ -228,7 +246,6 @@ struct hyperv_service_callback hv_cb_utils[MAX_MSG_TYPES] = {
                        0x30, 0xe6, 0x27, 0x95, 0xae, 0xd0, 0x7b, 0x49,
                        0xad, 0xce, 0xe8, 0x0a, 0xb0, 0x17, 0x5c, 0xaf
                },
-               .callback = chn_cb_negotiate,
                .log_msg = "Timesync channel functionality initialized"
        },
        /* {57164f39-9115-4e78-ab55-382f3bd5422d} */
@@ -239,7 +256,6 @@ struct hyperv_service_callback hv_cb_utils[MAX_MSG_TYPES] = {
                        0x39, 0x4f, 0x16, 0x57, 0x15, 0x91, 0x78, 0x4e,
                        0xab, 0x55, 0x38, 0x2f, 0x3b, 0xd5, 0x42, 0x2d
                },
-               .callback = chn_cb_negotiate,
                .log_msg = "Heartbeat channel functionality initialized"
        },
        /* {A9A0F4E7-5A45-4d96-B827-8A841E8C03E6} */
@@ -249,7 +265,6 @@ struct hyperv_service_callback hv_cb_utils[MAX_MSG_TYPES] = {
                        0xe7, 0xf4, 0xa0, 0xa9, 0x45, 0x5a, 0x96, 0x4d,
                        0xb8, 0x27, 0x8a, 0x84, 0x1e, 0x8c, 0x3,  0xe6
                },
-               .callback = chn_cb_negotiate,
                .log_msg = "KVP channel functionality initialized"
        },
 };
@@ -290,9 +305,7 @@ static void release_channel(struct work_struct *work)
                                                     struct vmbus_channel,
                                                     work);
 
-       DPRINT_DBG(VMBUS, "releasing channel (%p)", channel);
        destroy_workqueue(channel->controlwq);
-       DPRINT_DBG(VMBUS, "channel released (%p)", channel);
 
        kfree(channel);
 }
@@ -314,22 +327,6 @@ void free_channel(struct vmbus_channel *channel)
 }
 
 
-DECLARE_COMPLETION(hv_channel_ready);
-
-/*
- * Count initialized channels, and ensure all channels are ready when hv_vmbus
- * module loading completes.
- */
-static void count_hv_channel(void)
-{
-       static int counter;
-       unsigned long flags;
-
-       spin_lock_irqsave(&vmbus_connection.channel_lock, flags);
-       if (++counter == MAX_MSG_TYPES)
-               complete(&hv_channel_ready);
-       spin_unlock_irqrestore(&vmbus_connection.channel_lock, flags);
-}
 
 /*
  * vmbus_process_rescind_offer -
@@ -384,8 +381,6 @@ static void vmbus_process_offer(struct work_struct *work)
        spin_unlock_irqrestore(&vmbus_connection.channel_lock, flags);
 
        if (!fnew) {
-               DPRINT_DBG(VMBUS, "Ignoring duplicate offer for relid (%d)",
-                          newchannel->offermsg.child_relid);
                free_channel(newchannel);
                return;
        }
@@ -400,9 +395,6 @@ static void vmbus_process_offer(struct work_struct *work)
                &newchannel->offermsg.offer.if_instance,
                newchannel);
 
-       DPRINT_DBG(VMBUS, "child device object allocated - %p",
-                  newchannel->device_obj);
-
        /*
         * Add the new device to the bus. This will kick off device-driver
         * binding which eventually invokes the device driver's AddDevice()
@@ -410,8 +402,7 @@ static void vmbus_process_offer(struct work_struct *work)
         */
        ret = vmbus_child_device_register(newchannel->device_obj);
        if (ret != 0) {
-               DPRINT_ERR(VMBUS,
-                          "unable to add child device object (relid %d)",
+               pr_err("unable to add child device object (relid %d)\n",
                           newchannel->offermsg.child_relid);
 
                spin_lock_irqsave(&vmbus_connection.channel_lock, flags);
@@ -426,6 +417,7 @@ static void vmbus_process_offer(struct work_struct *work)
                 * can cleanup properly
                 */
                newchannel->state = CHANNEL_OPEN_STATE;
+               newchannel->util_index = -1; /* Invalid index */
 
                /* Open IC channels */
                for (cnt = 0; cnt < MAX_MSG_TYPES; cnt++) {
@@ -434,12 +426,13 @@ static void vmbus_process_offer(struct work_struct *work)
                                   sizeof(struct hv_guid)) == 0 &&
                                vmbus_open(newchannel, 2 * PAGE_SIZE,
                                                 2 * PAGE_SIZE, NULL, 0,
-                                                hv_cb_utils[cnt].callback,
+                                                chn_cb_negotiate,
                                                 newchannel) == 0) {
                                hv_cb_utils[cnt].channel = newchannel;
-                               DPRINT_INFO(VMBUS, "%s",
-                                               hv_cb_utils[cnt].log_msg);
-                               count_hv_channel();
+                               newchannel->util_index = cnt;
+
+                               pr_info("%s\n", hv_cb_utils[cnt].log_msg);
+
                        }
                }
        }
@@ -464,55 +457,26 @@ static void vmbus_onoffer(struct vmbus_channel_message_header *hdr)
        offer = (struct vmbus_channel_offer_channel *)hdr;
        for (i = 0; i < MAX_NUM_DEVICE_CLASSES_SUPPORTED; i++) {
                if (memcmp(&offer->offer.if_type,
-                   &gSupportedDeviceClasses[i], sizeof(struct hv_guid)) == 0) {
+                       &supported_device_classes[i],
+                       sizeof(struct hv_guid)) == 0) {
                        fsupported = 1;
                        break;
                }
        }
 
-       if (!fsupported) {
-               DPRINT_DBG(VMBUS, "Ignoring channel offer notification for "
-                          "child relid %d", offer->child_relid);
+       if (!fsupported)
                return;
-       }
 
        guidtype = &offer->offer.if_type;
        guidinstance = &offer->offer.if_instance;
 
-       DPRINT_INFO(VMBUS, "Channel offer notification - "
-                   "child relid %d monitor id %d allocated %d, "
-                   "type {%02x%02x%02x%02x-%02x%02x-%02x%02x-"
-                   "%02x%02x%02x%02x%02x%02x%02x%02x} "
-                   "instance {%02x%02x%02x%02x-%02x%02x-%02x%02x-"
-                   "%02x%02x%02x%02x%02x%02x%02x%02x}",
-                   offer->child_relid, offer->monitorid,
-                   offer->monitor_allocated,
-                   guidtype->data[3], guidtype->data[2],
-                   guidtype->data[1], guidtype->data[0],
-                   guidtype->data[5], guidtype->data[4],
-                   guidtype->data[7], guidtype->data[6],
-                   guidtype->data[8], guidtype->data[9],
-                   guidtype->data[10], guidtype->data[11],
-                   guidtype->data[12], guidtype->data[13],
-                   guidtype->data[14], guidtype->data[15],
-                   guidinstance->data[3], guidinstance->data[2],
-                   guidinstance->data[1], guidinstance->data[0],
-                   guidinstance->data[5], guidinstance->data[4],
-                   guidinstance->data[7], guidinstance->data[6],
-                   guidinstance->data[8], guidinstance->data[9],
-                   guidinstance->data[10], guidinstance->data[11],
-                   guidinstance->data[12], guidinstance->data[13],
-                   guidinstance->data[14], guidinstance->data[15]);
-
        /* Allocate the channel object and save this offer. */
        newchannel = alloc_channel();
        if (!newchannel) {
-               DPRINT_ERR(VMBUS, "unable to allocate channel object");
+               pr_err("Unable to allocate channel object\n");
                return;
        }
 
-       DPRINT_DBG(VMBUS, "channel object allocated - %p", newchannel);
-
        memcpy(&newchannel->offermsg, offer,
               sizeof(struct vmbus_channel_offer_channel));
        newchannel->monitor_grp = (u8)offer->monitorid / 32;
@@ -535,11 +499,10 @@ static void vmbus_onoffer_rescind(struct vmbus_channel_message_header *hdr)
 
        rescind = (struct vmbus_channel_rescind_offer *)hdr;
        channel = relid2channel(rescind->child_relid);
-       if (channel == NULL) {
-               DPRINT_DBG(VMBUS, "channel not found for relId %d",
-                          rescind->child_relid);
+
+       if (channel == NULL)
+               /* Just return here, no channel found */
                return;
-       }
 
        /* work is initialized for vmbus_process_rescind_offer() from
         * vmbus_process_offer() where the channel got created */
@@ -573,7 +536,6 @@ static void vmbus_onopen_result(struct vmbus_channel_message_header *hdr)
        unsigned long flags;
 
        result = (struct vmbus_channel_open_result *)hdr;
-       DPRINT_DBG(VMBUS, "vmbus open result - %d", result->status);
 
        /*
         * Find the open msg, copy the result and signal/unblock the wait event
@@ -592,9 +554,9 @@ static void vmbus_onopen_result(struct vmbus_channel_message_header *hdr)
                            openmsg->openid == result->openid) {
                                memcpy(&msginfo->response.open_result,
                                       result,
-                                      sizeof(struct vmbus_channel_open_result));
-                               msginfo->wait_condition = 1;
-                               wake_up(&msginfo->waitevent);
+                                      sizeof(
+                                       struct vmbus_channel_open_result));
+                               complete(&msginfo->waitevent);
                                break;
                        }
                }
@@ -618,8 +580,6 @@ static void vmbus_ongpadl_created(struct vmbus_channel_message_header *hdr)
        unsigned long flags;
 
        gpadlcreated = (struct vmbus_channel_gpadl_created *)hdr;
-       DPRINT_DBG(VMBUS, "vmbus gpadl created result - %d",
-                  gpadlcreated->creation_status);
 
        /*
         * Find the establish msg, copy the result and signal/unblock the wait
@@ -641,9 +601,9 @@ static void vmbus_ongpadl_created(struct vmbus_channel_message_header *hdr)
                            (gpadlcreated->gpadl == gpadlheader->gpadl)) {
                                memcpy(&msginfo->response.gpadl_created,
                                       gpadlcreated,
-                                      sizeof(struct vmbus_channel_gpadl_created));
-                               msginfo->wait_condition = 1;
-                               wake_up(&msginfo->waitevent);
+                                      sizeof(
+                                       struct vmbus_channel_gpadl_created));
+                               complete(&msginfo->waitevent);
                                break;
                        }
                }
@@ -686,9 +646,9 @@ static void vmbus_ongpadl_torndown(
                        if (gpadl_torndown->gpadl == gpadl_teardown->gpadl) {
                                memcpy(&msginfo->response.gpadl_torndown,
                                       gpadl_torndown,
-                                      sizeof(struct vmbus_channel_gpadl_torndown));
-                               msginfo->wait_condition = 1;
-                               wake_up(&msginfo->waitevent);
+                                      sizeof(
+                                       struct vmbus_channel_gpadl_torndown));
+                               complete(&msginfo->waitevent);
                                break;
                        }
                }
@@ -727,8 +687,7 @@ static void vmbus_onversion_response(
                        memcpy(&msginfo->response.version_response,
                              version_response,
                              sizeof(struct vmbus_channel_version_response));
-                       msginfo->wait_condition = 1;
-                       wake_up(&msginfo->waitevent);
+                       complete(&msginfo->waitevent);
                }
        }
        spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
@@ -736,7 +695,7 @@ static void vmbus_onversion_response(
 
 /* Channel message dispatch table */
 static struct vmbus_channel_message_table_entry
-       gChannelMessageTable[CHANNELMSG_COUNT] = {
+       channel_message_table[CHANNELMSG_COUNT] = {
        {CHANNELMSG_INVALID,                    NULL},
        {CHANNELMSG_OFFERCHANNEL,               vmbus_onoffer},
        {CHANNELMSG_RESCIND_CHANNELOFFER,       vmbus_onoffer_rescind},
@@ -770,22 +729,18 @@ void vmbus_onmessage(void *context)
        hdr = (struct vmbus_channel_message_header *)msg->u.payload;
        size = msg->header.payload_size;
 
-       DPRINT_DBG(VMBUS, "message type %d size %d", hdr->msgtype, size);
-
        if (hdr->msgtype >= CHANNELMSG_COUNT) {
-               DPRINT_ERR(VMBUS,
-                          "Received invalid channel message type %d size %d",
+               pr_err("Received invalid channel message type %d size %d\n",
                           hdr->msgtype, size);
                print_hex_dump_bytes("", DUMP_PREFIX_NONE,
                                     (unsigned char *)msg->u.payload, size);
                return;
        }
 
-       if (gChannelMessageTable[hdr->msgtype].messageHandler)
-               gChannelMessageTable[hdr->msgtype].messageHandler(hdr);
+       if (channel_message_table[hdr->msgtype].message_handler)
+               channel_message_table[hdr->msgtype].message_handler(hdr);
        else
-               DPRINT_ERR(VMBUS, "Unhandled channel message type %d",
-                          hdr->msgtype);
+               pr_err("Unhandled channel message type %d\n", hdr->msgtype);
 }
 
 /*
@@ -795,7 +750,7 @@ int vmbus_request_offers(void)
 {
        struct vmbus_channel_message_header *msg;
        struct vmbus_channel_msginfo *msginfo;
-       int ret;
+       int ret, t;
 
        msginfo = kmalloc(sizeof(*msginfo) +
                          sizeof(struct vmbus_channel_message_header),
@@ -803,7 +758,7 @@ int vmbus_request_offers(void)
        if (!msginfo)
                return -ENOMEM;
 
-       init_waitqueue_head(&msginfo->waitevent);
+       init_completion(&msginfo->waitevent);
 
        msg = (struct vmbus_channel_message_header *)msginfo->msg;
 
@@ -813,15 +768,13 @@ int vmbus_request_offers(void)
        ret = vmbus_post_msg(msg,
                               sizeof(struct vmbus_channel_message_header));
        if (ret != 0) {
-               DPRINT_ERR(VMBUS, "Unable to request offers - %d", ret);
+               pr_err("Unable to request offers - %d\n", ret);
 
                goto cleanup;
        }
 
-       msginfo->wait_condition = 0;
-       wait_event_timeout(msginfo->waitevent, msginfo->wait_condition,
-                       msecs_to_jiffies(1000));
-       if (msginfo->wait_condition == 0) {
+       t = wait_for_completion_timeout(&msginfo->waitevent, HZ);
+       if (t == 0) {
                ret = -ETIMEDOUT;
                goto cleanup;
        }
@@ -834,38 +787,4 @@ cleanup:
        return ret;
 }
 
-/*
- * vmbus_release_unattached_channels - Release channels that are
- * unattached/unconnected ie (no drivers associated)
- */
-void vmbus_release_unattached_channels(void)
-{
-       struct vmbus_channel *channel, *pos;
-       struct vmbus_channel *start = NULL;
-       unsigned long flags;
-
-       spin_lock_irqsave(&vmbus_connection.channel_lock, flags);
-
-       list_for_each_entry_safe(channel, pos, &vmbus_connection.chn_list,
-                                listentry) {
-               if (channel == start)
-                       break;
-
-               if (!channel->device_obj->drv) {
-                       list_del(&channel->listentry);
-                       DPRINT_INFO(VMBUS,
-                                   "Releasing unattached device object %p",
-                                   channel->device_obj);
-
-                       vmbus_child_device_unregister(channel->device_obj);
-                       free_channel(channel);
-               } else {
-                       if (!start)
-                               start = channel;
-               }
-       }
-
-       spin_unlock_irqrestore(&vmbus_connection.channel_lock, flags);
-}
-
 /* eof */
diff --git a/drivers/staging/hv/channel_mgmt.h b/drivers/staging/hv/channel_mgmt.h
deleted file mode 100644 (file)
index 96f74e2..0000000
+++ /dev/null
@@ -1,320 +0,0 @@
-/*
- *
- * Copyright (c) 2009, Microsoft Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place - Suite 330, Boston, MA 02111-1307 USA.
- *
- * Authors:
- *   Haiyang Zhang <haiyangz@microsoft.com>
- *   Hank Janssen  <hjanssen@microsoft.com>
- *
- */
-
-
-#ifndef _CHANNEL_MGMT_H_
-#define _CHANNEL_MGMT_H_
-
-#include <linux/list.h>
-#include <linux/timer.h>
-#include <linux/workqueue.h>
-#include "ring_buffer.h"
-#include "vmbus_channel_interface.h"
-#include "vmbus_packet_format.h"
-
-/* Version 1 messages */
-enum vmbus_channel_message_type {
-       CHANNELMSG_INVALID                      =  0,
-       CHANNELMSG_OFFERCHANNEL         =  1,
-       CHANNELMSG_RESCIND_CHANNELOFFER =  2,
-       CHANNELMSG_REQUESTOFFERS                =  3,
-       CHANNELMSG_ALLOFFERS_DELIVERED  =  4,
-       CHANNELMSG_OPENCHANNEL          =  5,
-       CHANNELMSG_OPENCHANNEL_RESULT           =  6,
-       CHANNELMSG_CLOSECHANNEL         =  7,
-       CHANNELMSG_GPADL_HEADER         =  8,
-       CHANNELMSG_GPADL_BODY                   =  9,
-       CHANNELMSG_GPADL_CREATED                = 10,
-       CHANNELMSG_GPADL_TEARDOWN               = 11,
-       CHANNELMSG_GPADL_TORNDOWN               = 12,
-       CHANNELMSG_RELID_RELEASED               = 13,
-       CHANNELMSG_INITIATE_CONTACT             = 14,
-       CHANNELMSG_VERSION_RESPONSE             = 15,
-       CHANNELMSG_UNLOAD                       = 16,
-#ifdef VMBUS_FEATURE_PARENT_OR_PEER_MEMORY_MAPPED_INTO_A_CHILD
-       CHANNELMSG_VIEWRANGE_ADD                = 17,
-       CHANNELMSG_VIEWRANGE_REMOVE             = 18,
-#endif
-       CHANNELMSG_COUNT
-};
-
-struct vmbus_channel_message_header {
-       enum vmbus_channel_message_type msgtype;
-       u32 padding;
-} __packed;
-
-/* Query VMBus Version parameters */
-struct vmbus_channel_query_vmbus_version {
-       struct vmbus_channel_message_header header;
-       u32 version;
-} __packed;
-
-/* VMBus Version Supported parameters */
-struct vmbus_channel_version_supported {
-       struct vmbus_channel_message_header header;
-       bool version_supported;
-} __packed;
-
-/* Offer Channel parameters */
-struct vmbus_channel_offer_channel {
-       struct vmbus_channel_message_header header;
-       struct vmbus_channel_offer offer;
-       u32 child_relid;
-       u8 monitorid;
-       bool monitor_allocated;
-} __packed;
-
-/* Rescind Offer parameters */
-struct vmbus_channel_rescind_offer {
-       struct vmbus_channel_message_header header;
-       u32 child_relid;
-} __packed;
-
-/*
- * Request Offer -- no parameters, SynIC message contains the partition ID
- * Set Snoop -- no parameters, SynIC message contains the partition ID
- * Clear Snoop -- no parameters, SynIC message contains the partition ID
- * All Offers Delivered -- no parameters, SynIC message contains the partition
- *                        ID
- * Flush Client -- no parameters, SynIC message contains the partition ID
- */
-
-/* Open Channel parameters */
-struct vmbus_channel_open_channel {
-       struct vmbus_channel_message_header header;
-
-       /* Identifies the specific VMBus channel that is being opened. */
-       u32 child_relid;
-
-       /* ID making a particular open request at a channel offer unique. */
-       u32 openid;
-
-       /* GPADL for the channel's ring buffer. */
-       u32 ringbuffer_gpadlhandle;
-
-       /* GPADL for the channel's server context save area. */
-       u32 server_contextarea_gpadlhandle;
-
-       /*
-       * The upstream ring buffer begins at offset zero in the memory
-       * described by RingBufferGpadlHandle. The downstream ring buffer
-       * follows it at this offset (in pages).
-       */
-       u32 downstream_ringbuffer_pageoffset;
-
-       /* User-specific data to be passed along to the server endpoint. */
-       unsigned char userdata[MAX_USER_DEFINED_BYTES];
-} __packed;
-
-/* Open Channel Result parameters */
-struct vmbus_channel_open_result {
-       struct vmbus_channel_message_header header;
-       u32 child_relid;
-       u32 openid;
-       u32 status;
-} __packed;
-
-/* Close channel parameters; */
-struct vmbus_channel_close_channel {
-       struct vmbus_channel_message_header header;
-       u32 child_relid;
-} __packed;
-
-/* Channel Message GPADL */
-#define GPADL_TYPE_RING_BUFFER         1
-#define GPADL_TYPE_SERVER_SAVE_AREA    2
-#define GPADL_TYPE_TRANSACTION         8
-
-/*
- * The number of PFNs in a GPADL message is defined by the number of
- * pages that would be spanned by ByteCount and ByteOffset.  If the
- * implied number of PFNs won't fit in this packet, there will be a
- * follow-up packet that contains more.
- */
-struct vmbus_channel_gpadl_header {
-       struct vmbus_channel_message_header header;
-       u32 child_relid;
-       u32 gpadl;
-       u16 range_buflen;
-       u16 rangecount;
-       struct gpa_range range[0];
-} __packed;
-
-/* This is the followup packet that contains more PFNs. */
-struct vmbus_channel_gpadl_body {
-       struct vmbus_channel_message_header header;
-       u32 msgnumber;
-       u32 gpadl;
-       u64 pfn[0];
-} __packed;
-
-struct vmbus_channel_gpadl_created {
-       struct vmbus_channel_message_header header;
-       u32 child_relid;
-       u32 gpadl;
-       u32 creation_status;
-} __packed;
-
-struct vmbus_channel_gpadl_teardown {
-       struct vmbus_channel_message_header header;
-       u32 child_relid;
-       u32 gpadl;
-} __packed;
-
-struct vmbus_channel_gpadl_torndown {
-       struct vmbus_channel_message_header header;
-       u32 gpadl;
-} __packed;
-
-#ifdef VMBUS_FEATURE_PARENT_OR_PEER_MEMORY_MAPPED_INTO_A_CHILD
-struct vmbus_channel_view_range_add {
-       struct vmbus_channel_message_header header;
-       PHYSICAL_ADDRESS viewrange_base;
-       u64 viewrange_length;
-       u32 child_relid;
-} __packed;
-
-struct vmbus_channel_view_range_remove {
-       struct vmbus_channel_message_header header;
-       PHYSICAL_ADDRESS viewrange_base;
-       u32 child_relid;
-} __packed;
-#endif
-
-struct vmbus_channel_relid_released {
-       struct vmbus_channel_message_header header;
-       u32 child_relid;
-} __packed;
-
-struct vmbus_channel_initiate_contact {
-       struct vmbus_channel_message_header header;
-       u32 vmbus_version_requested;
-       u32 padding2;
-       u64 interrupt_page;
-       u64 monitor_page1;
-       u64 monitor_page2;
-} __packed;
-
-struct vmbus_channel_version_response {
-       struct vmbus_channel_message_header header;
-       bool version_supported;
-} __packed;
-
-enum vmbus_channel_state {
-       CHANNEL_OFFER_STATE,
-       CHANNEL_OPENING_STATE,
-       CHANNEL_OPEN_STATE,
-};
-
-struct vmbus_channel {
-       struct list_head listentry;
-
-       struct hv_device *device_obj;
-
-       struct timer_list poll_timer; /* SA-111 workaround */
-       struct work_struct work;
-
-       enum vmbus_channel_state state;
-
-       struct vmbus_channel_offer_channel offermsg;
-       /*
-        * These are based on the OfferMsg.MonitorId.
-        * Save it here for easy access.
-        */
-       u8 monitor_grp;
-       u8 monitor_bit;
-
-       u32 ringbuffer_gpadlhandle;
-
-       /* Allocated memory for ring buffer */
-       void *ringbuffer_pages;
-       u32 ringbuffer_pagecount;
-       struct hv_ring_buffer_info outbound;    /* send to parent */
-       struct hv_ring_buffer_info inbound;     /* receive from parent */
-       spinlock_t inbound_lock;
-       struct workqueue_struct *controlwq;
-
-       /* Channel callback are invoked in this workqueue context */
-       /* HANDLE dataWorkQueue; */
-
-       void (*onchannel_callback)(void *context);
-       void *channel_callback_context;
-};
-
-struct vmbus_channel_debug_info {
-       u32 relid;
-       enum vmbus_channel_state state;
-       struct hv_guid interfacetype;
-       struct hv_guid interface_instance;
-       u32 monitorid;
-       u32 servermonitor_pending;
-       u32 servermonitor_latency;
-       u32 servermonitor_connectionid;
-       u32 clientmonitor_pending;
-       u32 clientmonitor_latency;
-       u32 clientmonitor_connectionid;
-
-       struct hv_ring_buffer_debug_info inbound;
-       struct hv_ring_buffer_debug_info outbound;
-};
-
-/*
- * Represents each channel msg on the vmbus connection This is a
- * variable-size data structure depending on the msg type itself
- */
-struct vmbus_channel_msginfo {
-       /* Bookkeeping stuff */
-       struct list_head msglistentry;
-
-       /* So far, this is only used to handle gpadl body message */
-       struct list_head submsglist;
-
-       /* Synchronize the request/response if needed */
-       int wait_condition;
-       wait_queue_head_t waitevent;
-       union {
-               struct vmbus_channel_version_supported version_supported;
-               struct vmbus_channel_open_result open_result;
-               struct vmbus_channel_gpadl_torndown gpadl_torndown;
-               struct vmbus_channel_gpadl_created gpadl_created;
-               struct vmbus_channel_version_response version_response;
-       } response;
-
-       u32 msgsize;
-       /*
-        * The channel message that goes out on the "wire".
-        * It will contain at minimum the VMBUS_CHANNEL_MESSAGE_HEADER header
-        */
-       unsigned char msg[0];
-};
-
-
-void free_channel(struct vmbus_channel *channel);
-
-void vmbus_onmessage(void *context);
-
-int vmbus_request_offers(void);
-
-void vmbus_release_unattached_channels(void);
-
-#endif /* _CHANNEL_MGMT_H_ */
index afc8116e7aa490bfb5b9e68e0abc2b607e830568..37bbf770ef117714d320a8e18e368b2835263e3b 100644 (file)
  *   Hank Janssen  <hjanssen@microsoft.com>
  *
  */
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/kernel.h>
 #include <linux/sched.h>
 #include <linux/wait.h>
 #include <linux/mm.h>
 #include <linux/slab.h>
 #include <linux/vmalloc.h>
-#include "hv_api.h"
-#include "logging.h"
-#include "vmbus_private.h"
+
+#include "hyperv.h"
+#include "hyperv_vmbus.h"
 
 
 struct vmbus_connection vmbus_connection = {
@@ -42,6 +44,7 @@ struct vmbus_connection vmbus_connection = {
 int vmbus_connect(void)
 {
        int ret = 0;
+       int t;
        struct vmbus_channel_msginfo *msginfo = NULL;
        struct vmbus_channel_initiate_contact *msg;
        unsigned long flags;
@@ -55,7 +58,7 @@ int vmbus_connect(void)
        vmbus_connection.work_queue = create_workqueue("hv_vmbus_con");
        if (!vmbus_connection.work_queue) {
                ret = -1;
-               goto Cleanup;
+               goto cleanup;
        }
 
        INIT_LIST_HEAD(&vmbus_connection.chn_msg_list);
@@ -72,7 +75,7 @@ int vmbus_connect(void)
        (void *)__get_free_pages(GFP_KERNEL|__GFP_ZERO, 0);
        if (vmbus_connection.int_page == NULL) {
                ret = -1;
-               goto Cleanup;
+               goto cleanup;
        }
 
        vmbus_connection.recv_int_page = vmbus_connection.int_page;
@@ -88,7 +91,7 @@ int vmbus_connect(void)
        (void *)__get_free_pages((GFP_KERNEL|__GFP_ZERO), 1);
        if (vmbus_connection.monitor_pages == NULL) {
                ret = -1;
-               goto Cleanup;
+               goto cleanup;
        }
 
        msginfo = kzalloc(sizeof(*msginfo) +
@@ -96,10 +99,10 @@ int vmbus_connect(void)
                          GFP_KERNEL);
        if (msginfo == NULL) {
                ret = -ENOMEM;
-               goto Cleanup;
+               goto cleanup;
        }
 
-       init_waitqueue_head(&msginfo->waitevent);
+       init_completion(&msginfo->waitevent);
 
        msg = (struct vmbus_channel_initiate_contact *)msginfo->msg;
 
@@ -121,11 +124,6 @@ int vmbus_connect(void)
 
        spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
 
-       DPRINT_DBG(VMBUS, "Vmbus connection - interrupt pfn %llx, "
-                  "monitor1 pfn %llx,, monitor2 pfn %llx",
-                  msg->interrupt_page, msg->monitor_page1, msg->monitor_page2);
-
-       DPRINT_DBG(VMBUS, "Sending channel initiate msg...");
        ret = vmbus_post_msg(msg,
                               sizeof(struct vmbus_channel_initiate_contact));
        if (ret != 0) {
@@ -133,21 +131,19 @@ int vmbus_connect(void)
                list_del(&msginfo->msglistentry);
                spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock,
                                        flags);
-               goto Cleanup;
+               goto cleanup;
        }
 
        /* Wait for the connection response */
-       msginfo->wait_condition = 0;
-       wait_event_timeout(msginfo->waitevent, msginfo->wait_condition,
-                       msecs_to_jiffies(1000));
-       if (msginfo->wait_condition == 0) {
+       t =  wait_for_completion_timeout(&msginfo->waitevent, HZ);
+       if (t == 0) {
                spin_lock_irqsave(&vmbus_connection.channelmsg_lock,
                                flags);
                list_del(&msginfo->msglistentry);
                spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock,
                                        flags);
                ret = -ETIMEDOUT;
-               goto Cleanup;
+               goto cleanup;
        }
 
        spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags);
@@ -156,21 +152,19 @@ int vmbus_connect(void)
 
        /* Check if successful */
        if (msginfo->response.version_response.version_supported) {
-               DPRINT_INFO(VMBUS, "Vmbus connected!!");
                vmbus_connection.conn_state = CONNECTED;
-
        } else {
-               DPRINT_ERR(VMBUS, "Vmbus connection failed!!..."
-                          "current version (%d) not supported",
-                          VMBUS_REVISION_NUMBER);
+               pr_err("Unable to connect, "
+                       "Version %d not supported by Hyper-V\n",
+                       VMBUS_REVISION_NUMBER);
                ret = -1;
-               goto Cleanup;
+               goto cleanup;
        }
 
        kfree(msginfo);
        return 0;
 
-Cleanup:
+cleanup:
        vmbus_connection.conn_state = DISCONNECTED;
 
        if (vmbus_connection.work_queue)
@@ -213,7 +207,7 @@ int vmbus_disconnect(void)
        ret = vmbus_post_msg(msg,
                               sizeof(struct vmbus_channel_message_header));
        if (ret != 0)
-               goto Cleanup;
+               goto cleanup;
 
        free_pages((unsigned long)vmbus_connection.int_page, 0);
        free_pages((unsigned long)vmbus_connection.monitor_pages, 1);
@@ -223,9 +217,9 @@ int vmbus_disconnect(void)
 
        vmbus_connection.conn_state = DISCONNECTED;
 
-       DPRINT_INFO(VMBUS, "Vmbus disconnected!!");
+       pr_info("hv_vmbus disconnected\n");
 
-Cleanup:
+cleanup:
        kfree(msg);
        return ret;
 }
@@ -255,10 +249,9 @@ struct vmbus_channel *relid2channel(u32 relid)
 /*
  * process_chn_event - Process a channel event notification
  */
-static void process_chn_event(void *context)
+static void process_chn_event(u32 relid)
 {
        struct vmbus_channel *channel;
-       u32 relid = (u32)(unsigned long)context;
 
        /* ASSERT(relId > 0); */
 
@@ -270,13 +263,8 @@ static void process_chn_event(void *context)
 
        if (channel) {
                vmbus_onchannel_event(channel);
-               /*
-                * WorkQueueQueueWorkItem(channel->dataWorkQueue,
-                *                        vmbus_onchannel_event,
-                *                        (void*)channel);
-                */
        } else {
-               DPRINT_ERR(VMBUS, "channel not found for relid - %d.", relid);
+               pr_err("channel not found for relid - %u\n", relid);
        }
 }
 
@@ -285,39 +273,33 @@ static void process_chn_event(void *context)
  */
 void vmbus_on_event(unsigned long data)
 {
-       int dword;
-       int maxdword = MAX_NUM_CHANNELS_SUPPORTED >> 5;
+       u32 dword;
+       u32 maxdword = MAX_NUM_CHANNELS_SUPPORTED >> 5;
        int bit;
-       int relid;
+       u32 relid;
        u32 *recv_int_page = vmbus_connection.recv_int_page;
 
        /* Check events */
-       if (recv_int_page) {
-               for (dword = 0; dword < maxdword; dword++) {
-                       if (recv_int_page[dword]) {
-                               for (bit = 0; bit < 32; bit++) {
-                                       if (sync_test_and_clear_bit(bit,
-                                               (unsigned long *)
-                                               &recv_int_page[dword])) {
-                                               relid = (dword << 5) + bit;
-                                               DPRINT_DBG(VMBUS, "event detected for relid - %d", relid);
-
-                                               if (relid == 0) {
-                                                       /* special case - vmbus channel protocol msg */
-                                                       DPRINT_DBG(VMBUS, "invalid relid - %d", relid);
-                                                       continue;
-                                               } else {
-                                                       /* QueueWorkItem(VmbusProcessEvent, (void*)relid); */
-                                                       /* ret = WorkQueueQueueWorkItem(gVmbusConnection.workQueue, VmbusProcessChannelEvent, (void*)relid); */
-                                               process_chn_event((void *)
-                                               (unsigned long)relid);
-                                               }
-                                       }
+       if (!recv_int_page)
+               return;
+       for (dword = 0; dword < maxdword; dword++) {
+               if (!recv_int_page[dword])
+                       continue;
+               for (bit = 0; bit < 32; bit++) {
+                       if (sync_test_and_clear_bit(bit, (unsigned long *)&recv_int_page[dword])) {
+                               relid = (dword << 5) + bit;
+
+                               if (relid == 0) {
+                                       /*
+                                        * Special case - vmbus
+                                        * channel protocol msg
+                                        */
+                                       continue;
                                }
+                               process_chn_event(relid);
                        }
-                }
+               }
        }
-       return;
 }
 
 /*
index 0b06f4fe5838eaa549ec54207501e9e730751c16..a2cc0911de58e22b82a1c058497c901a1a19d8a3 100644 (file)
  *   Hank Janssen  <hjanssen@microsoft.com>
  *
  */
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/kernel.h>
 #include <linux/mm.h>
 #include <linux/slab.h>
 #include <linux/vmalloc.h>
-#include "hv_api.h"
-#include "logging.h"
-#include "vmbus_private.h"
+
+#include "hyperv.h"
+#include "hyperv_vmbus.h"
 
 /* The one and only */
 struct hv_context hv_context = {
@@ -80,33 +82,7 @@ static int query_hypervisor_info(void)
        op = HVCPUID_VENDOR_MAXFUNCTION;
        cpuid(op, &eax, &ebx, &ecx, &edx);
 
-       DPRINT_INFO(VMBUS, "Vendor ID: %c%c%c%c%c%c%c%c%c%c%c%c",
-                   (ebx & 0xFF),
-                   ((ebx >> 8) & 0xFF),
-                   ((ebx >> 16) & 0xFF),
-                   ((ebx >> 24) & 0xFF),
-                   (ecx & 0xFF),
-                   ((ecx >> 8) & 0xFF),
-                   ((ecx >> 16) & 0xFF),
-                   ((ecx >> 24) & 0xFF),
-                   (edx & 0xFF),
-                   ((edx >> 8) & 0xFF),
-                   ((edx >> 16) & 0xFF),
-                   ((edx >> 24) & 0xFF));
-
        max_leaf = eax;
-       eax = 0;
-       ebx = 0;
-       ecx = 0;
-       edx = 0;
-       op = HVCPUID_INTERFACE;
-       cpuid(op, &eax, &ebx, &ecx, &edx);
-
-       DPRINT_INFO(VMBUS, "Interface ID: %c%c%c%c",
-                   (eax & 0xFF),
-                   ((eax >> 8) & 0xFF),
-                   ((eax >> 16) & 0xFF),
-                   ((eax >> 24) & 0xFF));
 
        if (max_leaf >= HVCPUID_VERSION) {
                eax = 0;
@@ -115,7 +91,7 @@ static int query_hypervisor_info(void)
                edx = 0;
                op = HVCPUID_VERSION;
                cpuid(op, &eax, &ebx, &ecx, &edx);
-               DPRINT_INFO(VMBUS, "OS Build:%d-%d.%d-%d-%d.%d",\
+               pr_info("Hyper-V Host OS Build:%d-%d.%d-%d-%d.%d\n",
                            eax,
                            ebx >> 16,
                            ebx & 0xFFFF,
@@ -137,18 +113,11 @@ static u64 do_hypercall(u64 control, void *input, void *output)
        u64 output_address = (output) ? virt_to_phys(output) : 0;
        volatile void *hypercall_page = hv_context.hypercall_page;
 
-       DPRINT_DBG(VMBUS, "Hypercall <control %llx input phys %llx virt %p "
-                  "output phys %llx virt %p hypercall %p>",
-                  control, input_address, input,
-                  output_address, output, hypercall_page);
-
        __asm__ __volatile__("mov %0, %%r8" : : "r" (output_address) : "r8");
        __asm__ __volatile__("call *%3" : "=a" (hv_status) :
                             "c" (control), "d" (input_address),
                             "m" (hypercall_page));
 
-       DPRINT_DBG(VMBUS, "Hypercall <return %llx>",  hv_status);
-
        return hv_status;
 
 #else
@@ -165,18 +134,12 @@ static u64 do_hypercall(u64 control, void *input, void *output)
        u32 output_address_lo = output_address & 0xFFFFFFFF;
        volatile void *hypercall_page = hv_context.hypercall_page;
 
-       DPRINT_DBG(VMBUS, "Hypercall <control %llx input %p output %p>",
-                  control, input, output);
-
        __asm__ __volatile__ ("call *%8" : "=d"(hv_status_hi),
                              "=a"(hv_status_lo) : "d" (control_hi),
                              "a" (control_lo), "b" (input_address_hi),
                              "c" (input_address_lo), "D"(output_address_hi),
                              "S"(output_address_lo), "m" (hypercall_page));
 
-       DPRINT_DBG(VMBUS, "Hypercall <return %llx>",
-                  hv_status_lo | ((u64)hv_status_hi << 32));
-
        return hv_status_lo | ((u64)hv_status_hi << 32);
 #endif /* !x86_64 */
 }
@@ -197,13 +160,8 @@ int hv_init(void)
        memset(hv_context.synic_message_page, 0,
               sizeof(void *) * MAX_NUM_CPUS);
 
-       if (!query_hypervisor_presence()) {
-               DPRINT_ERR(VMBUS, "No Windows hypervisor detected!!");
-               goto Cleanup;
-       }
-
-       DPRINT_INFO(VMBUS,
-                   "Windows hypervisor detected! Retrieving more info...");
+       if (!query_hypervisor_presence())
+               goto cleanup;
 
        max_leaf = query_hypervisor_info();
        /* HvQueryHypervisorFeatures(maxLeaf); */
@@ -213,11 +171,8 @@ int hv_init(void)
         */
        rdmsrl(HV_X64_MSR_GUEST_OS_ID, hv_context.guestid);
 
-       if (hv_context.guestid != 0) {
-               DPRINT_ERR(VMBUS, "Unknown guest id (0x%llx)!!",
-                               hv_context.guestid);
-               goto Cleanup;
-       }
+       if (hv_context.guestid != 0)
+               goto cleanup;
 
        /* Write our OS info */
        wrmsrl(HV_X64_MSR_GUEST_OS_ID, HV_LINUX_GUEST_ID);
@@ -232,11 +187,8 @@ int hv_init(void)
        */
        virtaddr = __vmalloc(PAGE_SIZE, GFP_KERNEL, PAGE_KERNEL_EXEC);
 
-       if (!virtaddr) {
-               DPRINT_ERR(VMBUS,
-                          "unable to allocate hypercall page!!");
-               goto Cleanup;
-       }
+       if (!virtaddr)
+               goto cleanup;
 
        hypercall_msr.enable = 1;
 
@@ -247,23 +199,17 @@ int hv_init(void)
        hypercall_msr.as_uint64 = 0;
        rdmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
 
-       if (!hypercall_msr.enable) {
-               DPRINT_ERR(VMBUS, "unable to set hypercall page!!");
-               goto Cleanup;
-       }
+       if (!hypercall_msr.enable)
+               goto cleanup;
 
        hv_context.hypercall_page = virtaddr;
 
-       DPRINT_INFO(VMBUS, "Hypercall page VA=%p, PA=0x%0llx",
-                   hv_context.hypercall_page,
-                   (u64)hypercall_msr.guest_physical_address << PAGE_SHIFT);
-
        /* Setup the global signal event param for the signal event hypercall */
        hv_context.signal_event_buffer =
                        kmalloc(sizeof(struct hv_input_signal_event_buffer),
                                GFP_KERNEL);
        if (!hv_context.signal_event_buffer)
-               goto Cleanup;
+               goto cleanup;
 
        hv_context.signal_event_param =
                (struct hv_input_signal_event *)
@@ -278,7 +224,7 @@ int hv_init(void)
 
        return ret;
 
-Cleanup:
+cleanup:
        if (virtaddr) {
                if (hypercall_msr.enable) {
                        hypercall_msr.as_uint64 = 0;
@@ -394,24 +340,20 @@ void hv_synic_init(void *irqarg)
        /* Check the version */
        rdmsrl(HV_X64_MSR_SVERSION, version);
 
-       DPRINT_INFO(VMBUS, "SynIC version: %llx", version);
-
        hv_context.synic_message_page[cpu] =
                (void *)get_zeroed_page(GFP_ATOMIC);
 
        if (hv_context.synic_message_page[cpu] == NULL) {
-               DPRINT_ERR(VMBUS,
-                          "unable to allocate SYNIC message page!!");
-               goto Cleanup;
+               pr_err("Unable to allocate SYNIC message page\n");
+               goto cleanup;
        }
 
        hv_context.synic_event_page[cpu] =
                (void *)get_zeroed_page(GFP_ATOMIC);
 
        if (hv_context.synic_event_page[cpu] == NULL) {
-               DPRINT_ERR(VMBUS,
-                          "unable to allocate SYNIC event page!!");
-               goto Cleanup;
+               pr_err("Unable to allocate SYNIC event page\n");
+               goto cleanup;
        }
 
        /* Setup the Synic's message page */
@@ -420,8 +362,6 @@ void hv_synic_init(void *irqarg)
        simp.base_simp_gpa = virt_to_phys(hv_context.synic_message_page[cpu])
                >> PAGE_SHIFT;
 
-       DPRINT_DBG(VMBUS, "HV_X64_MSR_SIMP msr set to: %llx", simp.as_uint64);
-
        wrmsrl(HV_X64_MSR_SIMP, simp.as_uint64);
 
        /* Setup the Synic's event page */
@@ -430,14 +370,8 @@ void hv_synic_init(void *irqarg)
        siefp.base_siefp_gpa = virt_to_phys(hv_context.synic_event_page[cpu])
                >> PAGE_SHIFT;
 
-       DPRINT_DBG(VMBUS, "HV_X64_MSR_SIEFP msr set to: %llx", siefp.as_uint64);
-
        wrmsrl(HV_X64_MSR_SIEFP, siefp.as_uint64);
 
-       /* Setup the interception SINT. */
-       /* wrmsrl((HV_X64_MSR_SINT0 + HV_SYNIC_INTERCEPTION_SINT_INDEX), */
-       /*        interceptionSint.as_uint64); */
-
        /* Setup the shared SINT. */
        rdmsrl(HV_X64_MSR_SINT0 + VMBUS_MESSAGE_SINT, shared_sint.as_uint64);
 
@@ -446,9 +380,6 @@ void hv_synic_init(void *irqarg)
        shared_sint.masked = false;
        shared_sint.auto_eoi = true;
 
-       DPRINT_DBG(VMBUS, "HV_X64_MSR_SINT1 msr set to: %llx",
-                  shared_sint.as_uint64);
-
        wrmsrl(HV_X64_MSR_SINT0 + VMBUS_MESSAGE_SINT, shared_sint.as_uint64);
 
        /* Enable the global synic bit */
@@ -460,7 +391,7 @@ void hv_synic_init(void *irqarg)
        hv_context.synic_initialized = true;
        return;
 
-Cleanup:
+cleanup:
        if (hv_context.synic_event_page[cpu])
                free_page((unsigned long)hv_context.synic_event_page[cpu]);
 
diff --git a/drivers/staging/hv/hv.h b/drivers/staging/hv/hv.h
deleted file mode 100644 (file)
index 829aff8..0000000
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- *
- * Copyright (c) 2009, Microsoft Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place - Suite 330, Boston, MA 02111-1307 USA.
- *
- * Authors:
- *   Haiyang Zhang <haiyangz@microsoft.com>
- *   Hank Janssen  <hjanssen@microsoft.com>
- *
- */
-
-
-#ifndef __HV_H__
-#define __HV_H__
-
-#include "hv_api.h"
-
-enum {
-       VMBUS_MESSAGE_CONNECTION_ID     = 1,
-       VMBUS_MESSAGE_PORT_ID           = 1,
-       VMBUS_EVENT_CONNECTION_ID       = 2,
-       VMBUS_EVENT_PORT_ID             = 2,
-       VMBUS_MONITOR_CONNECTION_ID     = 3,
-       VMBUS_MONITOR_PORT_ID           = 3,
-       VMBUS_MESSAGE_SINT              = 2,
-};
-
-/* #defines */
-
-#define HV_PRESENT_BIT                 0x80000000
-
-#define HV_LINUX_GUEST_ID_LO           0x00000000
-#define HV_LINUX_GUEST_ID_HI           0xB16B00B5
-#define HV_LINUX_GUEST_ID              (((u64)HV_LINUX_GUEST_ID_HI << 32) | \
-                                          HV_LINUX_GUEST_ID_LO)
-
-#define HV_CPU_POWER_MANAGEMENT                (1 << 0)
-#define HV_RECOMMENDATIONS_MAX         4
-
-#define HV_X64_MAX                     5
-#define HV_CAPS_MAX                    8
-
-
-#define HV_HYPERCALL_PARAM_ALIGN       sizeof(u64)
-
-
-/* Service definitions */
-
-#define HV_SERVICE_PARENT_PORT                         (0)
-#define HV_SERVICE_PARENT_CONNECTION                   (0)
-
-#define HV_SERVICE_CONNECT_RESPONSE_SUCCESS            (0)
-#define HV_SERVICE_CONNECT_RESPONSE_INVALID_PARAMETER  (1)
-#define HV_SERVICE_CONNECT_RESPONSE_UNKNOWN_SERVICE    (2)
-#define HV_SERVICE_CONNECT_RESPONSE_CONNECTION_REJECTED        (3)
-
-#define HV_SERVICE_CONNECT_REQUEST_MESSAGE_ID          (1)
-#define HV_SERVICE_CONNECT_RESPONSE_MESSAGE_ID         (2)
-#define HV_SERVICE_DISCONNECT_REQUEST_MESSAGE_ID       (3)
-#define HV_SERVICE_DISCONNECT_RESPONSE_MESSAGE_ID      (4)
-#define HV_SERVICE_MAX_MESSAGE_ID                              (4)
-
-#define HV_SERVICE_PROTOCOL_VERSION (0x0010)
-#define HV_CONNECT_PAYLOAD_BYTE_COUNT 64
-
-/* #define VMBUS_REVISION_NUMBER       6 */
-
-/* Our local vmbus's port and connection id. Anything >0 is fine */
-/* #define VMBUS_PORT_ID               11 */
-
-/* 628180B8-308D-4c5e-B7DB-1BEB62E62EF4 */
-static const struct hv_guid VMBUS_SERVICE_ID = {
-       .data = {
-               0xb8, 0x80, 0x81, 0x62, 0x8d, 0x30, 0x5e, 0x4c,
-               0xb7, 0xdb, 0x1b, 0xeb, 0x62, 0xe6, 0x2e, 0xf4
-       },
-};
-
-#define MAX_NUM_CPUS   32
-
-
-struct hv_input_signal_event_buffer {
-       u64 align8;
-       struct hv_input_signal_event event;
-};
-
-struct hv_context {
-       /* We only support running on top of Hyper-V
-       * So at this point this really can only contain the Hyper-V ID
-       */
-       u64 guestid;
-
-       void *hypercall_page;
-
-       bool synic_initialized;
-
-       /*
-        * This is used as an input param to HvCallSignalEvent hypercall. The
-        * input param is immutable in our usage and must be dynamic mem (vs
-        * stack or global). */
-       struct hv_input_signal_event_buffer *signal_event_buffer;
-       /* 8-bytes aligned of the buffer above */
-       struct hv_input_signal_event *signal_event_param;
-
-       void *synic_message_page[MAX_NUM_CPUS];
-       void *synic_event_page[MAX_NUM_CPUS];
-};
-
-extern struct hv_context hv_context;
-
-
-/* Hv Interface */
-
-extern int hv_init(void);
-
-extern void hv_cleanup(void);
-
-extern u16 hv_post_message(union hv_connection_id connection_id,
-                        enum hv_message_type message_type,
-                        void *payload, size_t payload_size);
-
-extern u16 hv_signal_event(void);
-
-extern void hv_synic_init(void *irqarg);
-
-extern void hv_synic_cleanup(void *arg);
-
-#endif /* __HV_H__ */
diff --git a/drivers/staging/hv/hv_api.h b/drivers/staging/hv/hv_api.h
deleted file mode 100644 (file)
index 43a7228..0000000
+++ /dev/null
@@ -1,910 +0,0 @@
-/*
- *
- * Copyright (c) 2009, Microsoft Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place - Suite 330, Boston, MA 02111-1307 USA.
- *
- * Authors:
- *   Haiyang Zhang <haiyangz@microsoft.com>
- *   Hank Janssen  <hjanssen@microsoft.com>
- *
- */
-#ifndef __HV_API_H
-#define __HV_API_H
-
-struct hv_guid {
-       unsigned char data[16];
-};
-
-
-
-/* Status codes for hypervisor operations. */
-
-/*
- * HV_STATUS_SUCCESS
- * The specified hypercall succeeded
- */
-#define HV_STATUS_SUCCESS                              ((u16)0x0000)
-
-/*
- * HV_STATUS_INVALID_HYPERCALL_CODE
- * The hypervisor does not support the operation because the specified
- * hypercall code is not supported.
- */
-#define HV_STATUS_INVALID_HYPERCALL_CODE               ((u16)0x0002)
-
-/*
- * HV_STATUS_INVALID_HYPERCALL_INPUT
- * The hypervisor does not support the operation because the encoding for the
- * hypercall input register is not supported.
- */
-#define HV_STATUS_INVALID_HYPERCALL_INPUT              ((u16)0x0003)
-
-/*
- * HV_STATUS_INVALID_ALIGNMENT
- * The hypervisor could not perform the operation because a parameter has an
- * invalid alignment.
- */
-#define HV_STATUS_INVALID_ALIGNMENT                    ((u16)0x0004)
-
-/*
- * HV_STATUS_INVALID_PARAMETER
- * The hypervisor could not perform the operation because an invalid parameter
- * was specified.
- */
-#define HV_STATUS_INVALID_PARAMETER                    ((u16)0x0005)
-
-/*
- * HV_STATUS_ACCESS_DENIED
- * Access to the specified object was denied.
- */
-#define HV_STATUS_ACCESS_DENIED                                ((u16)0x0006)
-
-/*
- * HV_STATUS_INVALID_PARTITION_STATE
- * The hypervisor could not perform the operation because the partition is
- * entering or in an invalid state.
- */
-#define HV_STATUS_INVALID_PARTITION_STATE              ((u16)0x0007)
-
-/*
- * HV_STATUS_OPERATION_DENIED
- * The operation is not allowed in the current state.
- */
-#define HV_STATUS_OPERATION_DENIED                     ((u16)0x0008)
-
-/*
- * HV_STATUS_UNKNOWN_PROPERTY
- * The hypervisor does not recognize the specified partition property.
- */
-#define HV_STATUS_UNKNOWN_PROPERTY                     ((u16)0x0009)
-
-/*
- * HV_STATUS_PROPERTY_VALUE_OUT_OF_RANGE
- * The specified value of a partition property is out of range or violates an
- * invariant.
- */
-#define HV_STATUS_PROPERTY_VALUE_OUT_OF_RANGE          ((u16)0x000A)
-
-/*
- * HV_STATUS_INSUFFICIENT_MEMORY
- * There is not enough memory in the hypervisor pool to complete the operation.
- */
-#define HV_STATUS_INSUFFICIENT_MEMORY                  ((u16)0x000B)
-
-/*
- * HV_STATUS_PARTITION_TOO_DEEP
- * The maximum partition depth has been exceeded for the partition hierarchy.
- */
-#define HV_STATUS_PARTITION_TOO_DEEP                   ((u16)0x000C)
-
-/*
- * HV_STATUS_INVALID_PARTITION_ID
- * A partition with the specified partition Id does not exist.
- */
-#define HV_STATUS_INVALID_PARTITION_ID                 ((u16)0x000D)
-
-/*
- * HV_STATUS_INVALID_VP_INDEX
- * The hypervisor could not perform the operation because the specified VP
- * index is invalid.
- */
-#define HV_STATUS_INVALID_VP_INDEX                     ((u16)0x000E)
-
-/*
- * HV_STATUS_NOT_FOUND
- * The iteration is complete; no addition items in the iteration could be
- * found.
- */
-#define HV_STATUS_NOT_FOUND                            ((u16)0x0010)
-
-/*
- * HV_STATUS_INVALID_PORT_ID
- * The hypervisor could not perform the operation because the specified port
- * identifier is invalid.
- */
-#define HV_STATUS_INVALID_PORT_ID                      ((u16)0x0011)
-
-/*
- * HV_STATUS_INVALID_CONNECTION_ID
- * The hypervisor could not perform the operation because the specified
- * connection identifier is invalid.
- */
-#define HV_STATUS_INVALID_CONNECTION_ID                        ((u16)0x0012)
-
-/*
- * HV_STATUS_INSUFFICIENT_BUFFERS
- * You did not supply enough message buffers to send a message.
- */
-#define HV_STATUS_INSUFFICIENT_BUFFERS                 ((u16)0x0013)
-
-/*
- * HV_STATUS_NOT_ACKNOWLEDGED
- * The previous virtual interrupt has not been acknowledged.
- */
-#define HV_STATUS_NOT_ACKNOWLEDGED                     ((u16)0x0014)
-
-/*
- * HV_STATUS_INVALID_VP_STATE
- * A virtual processor is not in the correct state for the performance of the
- * indicated operation.
- */
-#define HV_STATUS_INVALID_VP_STATE                     ((u16)0x0015)
-
-/*
- * HV_STATUS_ACKNOWLEDGED
- * The previous virtual interrupt has already been acknowledged.
- */
-#define HV_STATUS_ACKNOWLEDGED                         ((u16)0x0016)
-
-/*
- * HV_STATUS_INVALID_SAVE_RESTORE_STATE
- * The indicated partition is not in a valid state for saving or restoring.
- */
-#define HV_STATUS_INVALID_SAVE_RESTORE_STATE           ((u16)0x0017)
-
-/*
- * HV_STATUS_INVALID_SYNIC_STATE
- * The hypervisor could not complete the operation because a required feature
- * of the synthetic interrupt controller (SynIC) was disabled.
- */
-#define HV_STATUS_INVALID_SYNIC_STATE                  ((u16)0x0018)
-
-/*
- * HV_STATUS_OBJECT_IN_USE
- * The hypervisor could not perform the operation because the object or value
- * was either already in use or being used for a purpose that would not permit
- * completing the operation.
- */
-#define HV_STATUS_OBJECT_IN_USE                                ((u16)0x0019)
-
-/*
- * HV_STATUS_INVALID_PROXIMITY_DOMAIN_INFO
- * The proximity domain information is invalid.
- */
-#define HV_STATUS_INVALID_PROXIMITY_DOMAIN_INFO                ((u16)0x001A)
-
-/*
- * HV_STATUS_NO_DATA
- * An attempt to retrieve debugging data failed because none was available.
- */
-#define HV_STATUS_NO_DATA                              ((u16)0x001B)
-
-/*
- * HV_STATUS_INACTIVE
- * The physical connection being used for debuggging has not recorded any
- * receive activity since the last operation.
- */
-#define HV_STATUS_INACTIVE                             ((u16)0x001C)
-
-/*
- * HV_STATUS_NO_RESOURCES
- * There are not enough resources to complete the operation.
- */
-#define HV_STATUS_NO_RESOURCES                         ((u16)0x001D)
-
-/*
- * HV_STATUS_FEATURE_UNAVAILABLE
- * A hypervisor feature is not available to the user.
- */
-#define HV_STATUS_FEATURE_UNAVAILABLE                  ((u16)0x001E)
-
-/*
- * HV_STATUS_UNSUCCESSFUL
- * {Operation Failed} The requested operation was unsuccessful.
- */
-#define HV_STATUS_UNSUCCESSFUL                         ((u16)0x1001)
-
-/*
- * HV_STATUS_INSUFFICIENT_BUFFER
- * The specified buffer was too small to contain all of the requested data.
- */
-#define HV_STATUS_INSUFFICIENT_BUFFER                  ((u16)0x1002)
-
-/*
- * HV_STATUS_GPA_NOT_PRESENT
- * The guest physical address is not currently associated with a system
- * physical address.
- */
-#define HV_STATUS_GPA_NOT_PRESENT                      ((u16)0x1003)
-
-/*
- * HV_STATUS_GUEST_PAGE_FAULT
- * The operation would have resulted in a page fault in the guest.
- */
-#define HV_STATUS_GUEST_PAGE_FAULT                     ((u16)0x1004)
-
-/*
- * HV_STATUS_RUNDOWN_DISABLED
- * The operation cannot proceed as the rundown object was marked disabled.
- */
-#define HV_STATUS_RUNDOWN_DISABLED                     ((u16)0x1005)
-
-/*
- * HV_STATUS_KEY_ALREADY_EXISTS
- * The entry cannot be added as another entry with the same key already exists.
- */
-#define HV_STATUS_KEY_ALREADY_EXISTS                   ((u16)0x1006)
-
-/*
- * HV_STATUS_GPA_INTERCEPT
- * The operation resulted an intercept on a region of guest physical memory.
- */
-#define HV_STATUS_GPA_INTERCEPT                                ((u16)0x1007)
-
-/*
- * HV_STATUS_GUEST_GENERAL_PROTECTION_FAULT
- * The operation would have resulted in a general protection fault in the
- * guest.
- */
-#define HV_STATUS_GUEST_GENERAL_PROTECTION_FAULT       ((u16)0x1008)
-
-/*
- * HV_STATUS_GUEST_STACK_FAULT
- * The operation would have resulted in a stack fault in the guest.
- */
-#define HV_STATUS_GUEST_STACK_FAULT                    ((u16)0x1009)
-
-/*
- * HV_STATUS_GUEST_INVALID_OPCODE_FAULT
- * The operation would have resulted in an invalid opcode fault in the guest.
- */
-#define HV_STATUS_GUEST_INVALID_OPCODE_FAULT           ((u16)0x100A)
-
-/*
- * HV_STATUS_FINALIZE_INCOMPLETE
- * The partition is not completely finalized.
- */
-#define HV_STATUS_FINALIZE_INCOMPLETE                  ((u16)0x100B)
-
-/*
- * HV_STATUS_GUEST_MACHINE_CHECK_ABORT
- * The operation would have resulted in an machine check abort in the guest.
- */
-#define HV_STATUS_GUEST_MACHINE_CHECK_ABORT            ((u16)0x100C)
-
-/*
- * HV_STATUS_ILLEGAL_OVERLAY_ACCESS
- * An illegal access was attempted to an overlay page.
- */
-#define HV_STATUS_ILLEGAL_OVERLAY_ACCESS               ((u16)0x100D)
-
-/*
- * HV_STATUS_INSUFFICIENT_SYSTEM_VA
- * There is not enough system VA space available to satisfy the request,
- */
-#define HV_STATUS_INSUFFICIENT_SYSTEM_VA               ((u16)0x100E)
-
-/*
- * HV_STATUS_VIRTUAL_ADDRESS_NOT_MAPPED
- * The passed virtual address was not mapped in the hypervisor address space.
- */
-#define HV_STATUS_VIRTUAL_ADDRESS_NOT_MAPPED           ((u16)0x100F)
-
-/*
- * HV_STATUS_NOT_IMPLEMENTED
- * The requested operation is not implemented in this version of the
- * hypervisor.
- */
-#define HV_STATUS_NOT_IMPLEMENTED                      ((u16)0x1010)
-
-/*
- * HV_STATUS_VMX_INSTRUCTION_FAILED
- * The requested VMX instruction failed to complete successfully.
- */
-#define HV_STATUS_VMX_INSTRUCTION_FAILED               ((u16)0x1011)
-
-/*
- * HV_STATUS_VMX_INSTRUCTION_FAILED_WITH_STATUS
- * The requested VMX instruction failed to complete successfully indicating
- * status.
- */
-#define HV_STATUS_VMX_INSTRUCTION_FAILED_WITH_STATUS   ((u16)0x1012)
-
-/*
- * HV_STATUS_MSR_ACCESS_FAILED
- * The requested access to the model specific register failed.
- */
-#define HV_STATUS_MSR_ACCESS_FAILED            ((u16)0x1013)
-
-/*
- * HV_STATUS_CR_ACCESS_FAILED
- * The requested access to the control register failed.
- */
-#define HV_STATUS_CR_ACCESS_FAILED             ((u16)0x1014)
-
-/*
- * HV_STATUS_TIMEOUT
- * The specified timeout expired before the operation completed.
- */
-#define HV_STATUS_TIMEOUT                      ((u16)0x1016)
-
-/*
- * HV_STATUS_MSR_INTERCEPT
- * The requested access to the model specific register generated an intercept.
- */
-#define HV_STATUS_MSR_INTERCEPT                        ((u16)0x1017)
-
-/*
- * HV_STATUS_CPUID_INTERCEPT
- * The CPUID instruction generated an intercept.
- */
-#define HV_STATUS_CPUID_INTERCEPT              ((u16)0x1018)
-
-/*
- * HV_STATUS_REPEAT_INSTRUCTION
- * The current instruction should be repeated and the instruction pointer not
- * advanced.
- */
-#define HV_STATUS_REPEAT_INSTRUCTION           ((u16)0x1019)
-
-/*
- * HV_STATUS_PAGE_PROTECTION_VIOLATION
- * The current instruction should be repeated and the instruction pointer not
- * advanced.
- */
-#define HV_STATUS_PAGE_PROTECTION_VIOLATION    ((u16)0x101A)
-
-/*
- * HV_STATUS_PAGE_TABLE_INVALID
- * The current instruction should be repeated and the instruction pointer not
- * advanced.
- */
-#define HV_STATUS_PAGE_TABLE_INVALID           ((u16)0x101B)
-
-/*
- * HV_STATUS_PAGE_NOT_PRESENT
- * The current instruction should be repeated and the instruction pointer not
- * advanced.
- */
-#define HV_STATUS_PAGE_NOT_PRESENT             ((u16)0x101C)
-
-/*
- * HV_STATUS_IO_INTERCEPT
- * The requested access to the I/O port generated an intercept.
- */
-#define HV_STATUS_IO_INTERCEPT                         ((u16)0x101D)
-
-/*
- * HV_STATUS_NOTHING_TO_DO
- * There is nothing to do.
- */
-#define HV_STATUS_NOTHING_TO_DO                                ((u16)0x101E)
-
-/*
- * HV_STATUS_THREAD_TERMINATING
- * The requested thread is terminating.
- */
-#define HV_STATUS_THREAD_TERMINATING                   ((u16)0x101F)
-
-/*
- * HV_STATUS_SECTION_ALREADY_CONSTRUCTED
- * The specified section was already constructed.
- */
-#define HV_STATUS_SECTION_ALREADY_CONSTRUCTED          ((u16)0x1020)
-
-/* HV_STATUS_SECTION_NOT_ALREADY_CONSTRUCTED
- * The specified section was not already constructed.
- */
-#define HV_STATUS_SECTION_NOT_ALREADY_CONSTRUCTED      ((u16)0x1021)
-
-/*
- * HV_STATUS_PAGE_ALREADY_COMMITTED
- * The specified virtual address was already backed by physical memory.
- */
-#define HV_STATUS_PAGE_ALREADY_COMMITTED               ((u16)0x1022)
-
-/*
- * HV_STATUS_PAGE_NOT_ALREADY_COMMITTED
- * The specified virtual address was not already backed by physical memory.
- */
-#define HV_STATUS_PAGE_NOT_ALREADY_COMMITTED           ((u16)0x1023)
-
-/*
- * HV_STATUS_COMMITTED_PAGES_REMAIN
- * Committed pages remain in the section.
- */
-#define HV_STATUS_COMMITTED_PAGES_REMAIN               ((u16)0x1024)
-
-/*
- * HV_STATUS_NO_REMAINING_COMMITTED_PAGES
- * No additional committed pages beyond the specified page exist in the
- * section.
- */
-#define HV_STATUS_NO_REMAINING_COMMITTED_PAGES         ((u16)0x1025)
-
-/*
- * HV_STATUS_INSUFFICIENT_COMPARTMENT_VA
- * The VA space of the compartment is exhausted.
- */
-#define HV_STATUS_INSUFFICIENT_COMPARTMENT_VA          ((u16)0x1026)
-
-/*
- * HV_STATUS_DEREF_SPA_LIST_FULL
- * The SPA dereference list is full, and there are additional entries to be
- * added to it.
- */
-#define HV_STATUS_DEREF_SPA_LIST_FULL                  ((u16)0x1027)
-
-/*
- * HV_STATUS_GPA_OUT_OF_RANGE
- * The supplied GPA is out of range.
- */
-#define HV_STATUS_GPA_OUT_OF_RANGE                     ((u16)0x1027)
-
-/*
- * HV_STATUS_NONVOLATILE_XMM_STALE
- * The XMM register that was being accessed is stale.
- */
-#define HV_STATUS_NONVOLATILE_XMM_STALE                        ((u16)0x1028)
-
-/* HV_STATUS_UNSUPPORTED_PROCESSOR
- * The hypervisor does not support the processors in this system.
- */
-#define HV_STATUS_UNSUPPORTED_PROCESSOR                        ((u16)0x1029)
-
-/*
- * HV_STATUS_INSUFFICIENT_CROM_SPACE
- * Insufficient space existed for copying over the CROM contents.
- */
-#define HV_STATUS_INSUFFICIENT_CROM_SPACE              ((u16)0x2000)
-
-/*
- * HV_STATUS_BAD_CROM_FORMAT
- * The contents of the CROM failed validation attempts.
- */
-#define HV_STATUS_BAD_CROM_FORMAT                      ((u16)0x2001)
-
-/*
- * HV_STATUS_UNSUPPORTED_CROM_FORMAT
- * The contents of the CROM contain contents the parser doesn't support.
- */
-#define HV_STATUS_UNSUPPORTED_CROM_FORMAT              ((u16)0x2002)
-
-/*
- * HV_STATUS_UNSUPPORTED_CONTROLLER
- * The register format of the OHCI controller specified for debugging is not
- * supported.
- */
-#define HV_STATUS_UNSUPPORTED_CONTROLLER               ((u16)0x2003)
-
-/*
- * HV_STATUS_CROM_TOO_LARGE
- * The CROM contents were to large to copy over.
- */
-#define HV_STATUS_CROM_TOO_LARGE                       ((u16)0x2004)
-
-/*
- * HV_STATUS_CONTROLLER_IN_USE
- * The OHCI controller specified for debugging cannot be used as it is already
- * in use.
- */
-#define HV_STATUS_CONTROLLER_IN_USE                    ((u16)0x2005)
-
-
-/*
- * The below CPUID leaves are present if VersionAndFeatures.HypervisorPresent
- * is set by CPUID(HVCPUID_VERSION_FEATURES).
- */
-enum hv_cpuid_function {
-       HVCPUID_VERSION_FEATURES                = 0x00000001,
-       HVCPUID_VENDOR_MAXFUNCTION              = 0x40000000,
-       HVCPUID_INTERFACE                       = 0x40000001,
-
-       /*
-        * The remaining functions depend on the value of
-        * HVCPUID_INTERFACE
-        */
-       HVCPUID_VERSION                 = 0x40000002,
-       HVCPUID_FEATURES                        = 0x40000003,
-       HVCPUID_ENLIGHTENMENT_INFO      = 0x40000004,
-       HVCPUID_IMPLEMENTATION_LIMITS           = 0x40000005,
-};
-
-/* Define the virtual APIC registers */
-#define HV_X64_MSR_EOI                 (0x40000070)
-#define HV_X64_MSR_ICR                 (0x40000071)
-#define HV_X64_MSR_TPR                 (0x40000072)
-#define HV_X64_MSR_APIC_ASSIST_PAGE    (0x40000073)
-
-/* Define version of the synthetic interrupt controller. */
-#define HV_SYNIC_VERSION               (1)
-
-/* Define synthetic interrupt controller model specific registers. */
-#define HV_X64_MSR_SCONTROL            (0x40000080)
-#define HV_X64_MSR_SVERSION            (0x40000081)
-#define HV_X64_MSR_SIEFP               (0x40000082)
-#define HV_X64_MSR_SIMP                        (0x40000083)
-#define HV_X64_MSR_EOM                 (0x40000084)
-#define HV_X64_MSR_SINT0               (0x40000090)
-#define HV_X64_MSR_SINT1               (0x40000091)
-#define HV_X64_MSR_SINT2               (0x40000092)
-#define HV_X64_MSR_SINT3               (0x40000093)
-#define HV_X64_MSR_SINT4               (0x40000094)
-#define HV_X64_MSR_SINT5               (0x40000095)
-#define HV_X64_MSR_SINT6               (0x40000096)
-#define HV_X64_MSR_SINT7               (0x40000097)
-#define HV_X64_MSR_SINT8               (0x40000098)
-#define HV_X64_MSR_SINT9               (0x40000099)
-#define HV_X64_MSR_SINT10              (0x4000009A)
-#define HV_X64_MSR_SINT11              (0x4000009B)
-#define HV_X64_MSR_SINT12              (0x4000009C)
-#define HV_X64_MSR_SINT13              (0x4000009D)
-#define HV_X64_MSR_SINT14              (0x4000009E)
-#define HV_X64_MSR_SINT15              (0x4000009F)
-
-/* Define the expected SynIC version. */
-#define HV_SYNIC_VERSION_1             (0x1)
-
-/* Define synthetic interrupt controller message constants. */
-#define HV_MESSAGE_SIZE                        (256)
-#define HV_MESSAGE_PAYLOAD_BYTE_COUNT  (240)
-#define HV_MESSAGE_PAYLOAD_QWORD_COUNT (30)
-#define HV_ANY_VP                      (0xFFFFFFFF)
-
-/* Define synthetic interrupt controller flag constants. */
-#define HV_EVENT_FLAGS_COUNT           (256 * 8)
-#define HV_EVENT_FLAGS_BYTE_COUNT      (256)
-#define HV_EVENT_FLAGS_DWORD_COUNT     (256 / sizeof(u32))
-
-/* Define hypervisor message types. */
-enum hv_message_type {
-       HVMSG_NONE                      = 0x00000000,
-
-       /* Memory access messages. */
-       HVMSG_UNMAPPED_GPA              = 0x80000000,
-       HVMSG_GPA_INTERCEPT             = 0x80000001,
-
-       /* Timer notification messages. */
-       HVMSG_TIMER_EXPIRED                     = 0x80000010,
-
-       /* Error messages. */
-       HVMSG_INVALID_VP_REGISTER_VALUE = 0x80000020,
-       HVMSG_UNRECOVERABLE_EXCEPTION   = 0x80000021,
-       HVMSG_UNSUPPORTED_FEATURE               = 0x80000022,
-
-       /* Trace buffer complete messages. */
-       HVMSG_EVENTLOG_BUFFERCOMPLETE   = 0x80000040,
-
-       /* Platform-specific processor intercept messages. */
-       HVMSG_X64_IOPORT_INTERCEPT              = 0x80010000,
-       HVMSG_X64_MSR_INTERCEPT         = 0x80010001,
-       HVMSG_X64_CPUID_INTERCEPT               = 0x80010002,
-       HVMSG_X64_EXCEPTION_INTERCEPT   = 0x80010003,
-       HVMSG_X64_APIC_EOI                      = 0x80010004,
-       HVMSG_X64_LEGACY_FP_ERROR               = 0x80010005
-};
-
-/* Define the number of synthetic interrupt sources. */
-#define HV_SYNIC_SINT_COUNT            (16)
-#define HV_SYNIC_STIMER_COUNT          (4)
-
-/* Define invalid partition identifier. */
-#define HV_PARTITION_ID_INVALID                ((u64)0x0)
-
-/* Define connection identifier type. */
-union hv_connection_id {
-       u32 asu32;
-       struct {
-               u32 id:24;
-               u32 reserved:8;
-       } u;
-};
-
-/* Define port identifier type. */
-union hv_port_id {
-       u32 asu32;
-       struct {
-               u32 id:24;
-               u32 reserved:8;
-       } u ;
-};
-
-/* Define port type. */
-enum hv_port_type {
-       HVPORT_MSG      = 1,
-       HVPORT_EVENT            = 2,
-       HVPORT_MONITOR  = 3
-};
-
-/* Define port information structure. */
-struct hv_port_info {
-       enum hv_port_type port_type;
-       u32 padding;
-       union {
-               struct {
-                       u32 target_sint;
-                       u32 target_vp;
-                       u64 rsvdz;
-               } message_port_info;
-               struct {
-                       u32 target_sint;
-                       u32 target_vp;
-                       u16 base_flag_bumber;
-                       u16 flag_count;
-                       u32 rsvdz;
-               } event_port_info;
-               struct {
-                       u64 monitor_address;
-                       u64 rsvdz;
-               } monitor_port_info;
-       };
-};
-
-struct hv_connection_info {
-       enum hv_port_type port_type;
-       u32 padding;
-       union {
-               struct {
-                       u64 rsvdz;
-               } message_connection_info;
-               struct {
-                       u64 rsvdz;
-               } event_connection_info;
-               struct {
-                       u64 monitor_address;
-               } monitor_connection_info;
-       };
-};
-
-/* Define synthetic interrupt controller message flags. */
-union hv_message_flags {
-       u8 asu8;
-       struct {
-               u8 msg_pending:1;
-               u8 reserved:7;
-       };
-};
-
-/* Define synthetic interrupt controller message header. */
-struct hv_message_header {
-       enum hv_message_type message_type;
-       u8 payload_size;
-       union hv_message_flags message_flags;
-       u8 reserved[2];
-       union {
-               u64 sender;
-               union hv_port_id port;
-       };
-};
-
-/* Define timer message payload structure. */
-struct hv_timer_message_payload {
-       u32 timer_index;
-       u32 reserved;
-       u64 expiration_time;    /* When the timer expired */
-       u64 delivery_time;      /* When the message was delivered */
-};
-
-/* Define synthetic interrupt controller message format. */
-struct hv_message {
-       struct hv_message_header header;
-       union {
-               u64 payload[HV_MESSAGE_PAYLOAD_QWORD_COUNT];
-       } u ;
-};
-
-/* Define the number of message buffers associated with each port. */
-#define HV_PORT_MESSAGE_BUFFER_COUNT   (16)
-
-/* Define the synthetic interrupt message page layout. */
-struct hv_message_page {
-       struct hv_message sint_message[HV_SYNIC_SINT_COUNT];
-};
-
-/* Define the synthetic interrupt controller event flags format. */
-union hv_synic_event_flags {
-       u8 flags8[HV_EVENT_FLAGS_BYTE_COUNT];
-       u32 flags32[HV_EVENT_FLAGS_DWORD_COUNT];
-};
-
-/* Define the synthetic interrupt flags page layout. */
-struct hv_synic_event_flags_page {
-       union hv_synic_event_flags sintevent_flags[HV_SYNIC_SINT_COUNT];
-};
-
-/* Define SynIC control register. */
-union hv_synic_scontrol {
-       u64 as_uint64;
-       struct {
-               u64 enable:1;
-               u64 reserved:63;
-       };
-};
-
-/* Define synthetic interrupt source. */
-union hv_synic_sint {
-       u64 as_uint64;
-       struct {
-               u64 vector:8;
-               u64 reserved1:8;
-               u64 masked:1;
-               u64 auto_eoi:1;
-               u64 reserved2:46;
-       };
-};
-
-/* Define the format of the SIMP register */
-union hv_synic_simp {
-       u64 as_uint64;
-       struct {
-               u64 simp_enabled:1;
-               u64 preserved:11;
-               u64 base_simp_gpa:52;
-       };
-};
-
-/* Define the format of the SIEFP register */
-union hv_synic_siefp {
-       u64 as_uint64;
-       struct {
-               u64 siefp_enabled:1;
-               u64 preserved:11;
-               u64 base_siefp_gpa:52;
-       };
-};
-
-/* Definitions for the monitored notification facility */
-union hv_monitor_trigger_group {
-       u64 as_uint64;
-       struct {
-               u32 pending;
-               u32 armed;
-       };
-};
-
-struct hv_monitor_parameter {
-       union hv_connection_id connectionid;
-       u16 flagnumber;
-       u16 rsvdz;
-};
-
-union hv_monitor_trigger_state {
-       u32 asu32;
-
-       struct {
-               u32 group_enable:4;
-               u32 rsvdz:28;
-       };
-};
-
-/* struct hv_monitor_page Layout */
-/* ------------------------------------------------------ */
-/* | 0   | TriggerState (4 bytes) | Rsvd1 (4 bytes)     | */
-/* | 8   | TriggerGroup[0]                              | */
-/* | 10  | TriggerGroup[1]                              | */
-/* | 18  | TriggerGroup[2]                              | */
-/* | 20  | TriggerGroup[3]                              | */
-/* | 28  | Rsvd2[0]                                     | */
-/* | 30  | Rsvd2[1]                                     | */
-/* | 38  | Rsvd2[2]                                     | */
-/* | 40  | NextCheckTime[0][0]    | NextCheckTime[0][1] | */
-/* | ...                                                | */
-/* | 240 | Latency[0][0..3]                             | */
-/* | 340 | Rsvz3[0]                                     | */
-/* | 440 | Parameter[0][0]                              | */
-/* | 448 | Parameter[0][1]                              | */
-/* | ...                                                | */
-/* | 840 | Rsvd4[0]                                     | */
-/* ------------------------------------------------------ */
-struct hv_monitor_page {
-       union hv_monitor_trigger_state trigger_state;
-       u32 rsvdz1;
-
-       union hv_monitor_trigger_group trigger_group[4];
-       u64 rsvdz2[3];
-
-       s32 next_checktime[4][32];
-
-       u16 latency[4][32];
-       u64 rsvdz3[32];
-
-       struct hv_monitor_parameter parameter[4][32];
-
-       u8 rsvdz4[1984];
-};
-
-/* Declare the various hypercall operations. */
-enum hv_call_code {
-       HVCALL_POST_MESSAGE     = 0x005c,
-       HVCALL_SIGNAL_EVENT     = 0x005d,
-};
-
-/* Definition of the hv_post_message hypercall input structure. */
-struct hv_input_post_message {
-       union hv_connection_id connectionid;
-       u32 reserved;
-       enum hv_message_type message_type;
-       u32 payload_size;
-       u64 payload[HV_MESSAGE_PAYLOAD_QWORD_COUNT];
-};
-
-/* Definition of the hv_signal_event hypercall input structure. */
-struct hv_input_signal_event {
-       union hv_connection_id connectionid;
-       u16 flag_number;
-       u16 rsvdz;
-};
-
-/*
- * Versioning definitions used for guests reporting themselves to the
- * hypervisor, and visa versa.
- */
-
-/* Version info reported by guest OS's */
-enum hv_guest_os_vendor {
-       HVGUESTOS_VENDOR_MICROSOFT      = 0x0001
-};
-
-enum hv_guest_os_microsoft_ids {
-       HVGUESTOS_MICROSOFT_UNDEFINED   = 0x00,
-       HVGUESTOS_MICROSOFT_MSDOS               = 0x01,
-       HVGUESTOS_MICROSOFT_WINDOWS3X   = 0x02,
-       HVGUESTOS_MICROSOFT_WINDOWS9X   = 0x03,
-       HVGUESTOS_MICROSOFT_WINDOWSNT   = 0x04,
-       HVGUESTOS_MICROSOFT_WINDOWSCE   = 0x05
-};
-
-/*
- * Declare the MSR used to identify the guest OS.
- */
-#define HV_X64_MSR_GUEST_OS_ID 0x40000000
-
-union hv_x64_msr_guest_os_id_contents {
-       u64 as_uint64;
-       struct {
-               u64 build_number:16;
-               u64 service_version:8; /* Service Pack, etc. */
-               u64 minor_version:8;
-               u64 major_version:8;
-               u64 os_id:8; /* enum hv_guest_os_microsoft_ids (if Vendor=MS) */
-               u64 vendor_id:16; /* enum hv_guest_os_vendor */
-       };
-};
-
-/*
- * Declare the MSR used to setup pages used to communicate with the hypervisor.
- */
-#define HV_X64_MSR_HYPERCALL   0x40000001
-
-union hv_x64_msr_hypercall_contents {
-       u64 as_uint64;
-       struct {
-               u64 enable:1;
-               u64 reserved:11;
-               u64 guest_physical_address:52;
-       };
-};
-
-#endif
index faf692e4126e93ca54fd9c384dea964e21800d6b..13b0ecf7d5d61ca9405bec1693a616181c584d00 100644 (file)
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  *
  */
-
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
 #include <linux/net.h>
 #include <linux/nls.h>
 #include <linux/connector.h>
 #include <linux/workqueue.h>
 
-#include "logging.h"
-#include "hv_api.h"
-#include "vmbus.h"
-#include "vmbus_packet_format.h"
-#include "vmbus_channel_interface.h"
-#include "version_info.h"
-#include "channel.h"
-#include "vmbus_private.h"
-#include "vmbus_api.h"
-#include "utils.h"
+#include "hyperv.h"
 #include "hv_kvp.h"
 
 
@@ -114,7 +105,7 @@ kvp_cn_callback(struct cn_msg *msg, struct netlink_skb_parms *nsp)
 
        message = (struct hv_ku_msg *)msg->data;
        if (msg->seq == KVP_REGISTER) {
-               printk(KERN_INFO "KVP: user-mode registering done.\n");
+               pr_info("KVP: user-mode registering done.\n");
                kvp_register();
        }
 
@@ -174,7 +165,7 @@ kvp_respond_to_host(char *key, char *value, int error)
                /*
                 * This is a spurious call!
                 */
-               printk(KERN_WARNING "KVP: Transaction not active\n");
+               pr_warn("KVP: Transaction not active\n");
                return;
        }
        /*
@@ -259,9 +250,6 @@ void hv_kvp_onchannelcallback(void *context)
        vmbus_recvpacket(channel, recv_buffer, PAGE_SIZE, &recvlen, &requestid);
 
        if (recvlen > 0) {
-               DPRINT_DBG(VMBUS, "KVP packet: len=%d, requestid=%lld",
-                          recvlen, requestid);
-
                icmsghdrp = (struct icmsg_hdr *)&recv_buffer[
                        sizeof(struct vmbuspipe_hdr)];
 
index 118c7be22562437e44a61b49d0fee98116af47a6..359e73741c484ea5da31b0e41531f1701526d420 100644 (file)
 #include <linux/dmi.h>
 #include <linux/delay.h>
 
-#include "hv_api.h"
-#include "logging.h"
-#include "version_info.h"
-#include "vmbus.h"
-#include "vmbus_api.h"
-#include "channel.h"
-#include "vmbus_packet_format.h"
+#include "hyperv.h"
 
 
 /*
@@ -45,13 +39,6 @@ struct hv_input_dev_info {
        char name[128];
 };
 
-/* Represents the input vsc driver */
-/* FIXME - can be removed entirely */
-struct mousevsc_drv_obj {
-       struct hv_driver Base;
-};
-
-
 /* The maximum size of a synthetic input message. */
 #define SYNTHHID_MAX_INPUT_REPORT_SIZE 16
 
@@ -169,23 +156,23 @@ struct  mousevsc_prt_msg {
  * Represents an mousevsc device
  */
 struct mousevsc_dev {
-       struct hv_device        *Device;
+       struct hv_device        *device;
        /* 0 indicates the device is being destroyed */
-       atomic_t                RefCount;
-       int                     NumOutstandingRequests;
-       unsigned char           bInitializeComplete;
-       struct mousevsc_prt_msg ProtocolReq;
-       struct mousevsc_prt_msg ProtocolResp;
+       atomic_t                ref_count;
+       int                     num_outstanding_req;
+       unsigned char           init_complete;
+       struct mousevsc_prt_msg protocol_req;
+       struct mousevsc_prt_msg protocol_resp;
        /* Synchronize the request/response if needed */
-       wait_queue_head_t       ProtocolWaitEvent;
-       wait_queue_head_t       DeviceInfoWaitEvent;
+       wait_queue_head_t       protocol_wait_event;
+       wait_queue_head_t       dev_info_wait_event;
        int                     protocol_wait_condition;
        int                     device_wait_condition;
-       int                     DeviceInfoStatus;
+       int                     dev_info_status;
 
-       struct hid_descriptor   *HidDesc;
-       unsigned char           *ReportDesc;
-       u32                     ReportDescSize;
+       struct hid_descriptor   *hid_desc;
+       unsigned char           *report_desc;
+       u32                     report_desc_size;
        struct hv_input_dev_info hid_dev_info;
 };
 
@@ -202,41 +189,41 @@ static void deviceinfo_callback(struct hv_device *dev, struct hv_input_dev_info
 static void inputreport_callback(struct hv_device *dev, void *packet, u32 len);
 static void reportdesc_callback(struct hv_device *dev, void *packet, u32 len);
 
-static struct mousevsc_dev *AllocInputDevice(struct hv_device *Device)
+static struct mousevsc_dev *alloc_input_device(struct hv_device *device)
 {
-       struct mousevsc_dev *inputDevice;
+       struct mousevsc_dev *input_dev;
 
-       inputDevice = kzalloc(sizeof(struct mousevsc_dev), GFP_KERNEL);
+       input_dev = kzalloc(sizeof(struct mousevsc_dev), GFP_KERNEL);
 
-       if (!inputDevice)
+       if (!input_dev)
                return NULL;
 
        /*
         * Set to 2 to allow both inbound and outbound traffics
-        * (ie GetInputDevice() and MustGetInputDevice()) to proceed.
+        * (ie get_input_device() and must_get_input_device()) to proceed.
         */
-       atomic_cmpxchg(&inputDevice->RefCount, 0, 2);
+       atomic_cmpxchg(&input_dev->ref_count, 0, 2);
 
-       inputDevice->Device = Device;
-       Device->ext = inputDevice;
+       input_dev->device = device;
+       device->ext = input_dev;
 
-       return inputDevice;
+       return input_dev;
 }
 
-static void FreeInputDevice(struct mousevsc_dev *Device)
+static void free_input_device(struct mousevsc_dev *device)
 {
-       WARN_ON(atomic_read(&Device->RefCount) == 0);
-       kfree(Device);
+       WARN_ON(atomic_read(&device->ref_count) == 0);
+       kfree(device);
 }
 
 /*
  * Get the inputdevice object if exists and its refcount > 1
  */
-static struct mousevsc_dev *GetInputDevice(struct hv_device *Device)
+static struct mousevsc_dev *get_input_device(struct hv_device *device)
 {
-       struct mousevsc_dev *inputDevice;
+       struct mousevsc_dev *input_dev;
 
-       inputDevice = (struct mousevsc_dev *)Device->ext;
+       input_dev = (struct mousevsc_dev *)device->ext;
 
 /*
  *     FIXME
@@ -244,134 +231,137 @@ static struct mousevsc_dev *GetInputDevice(struct hv_device *Device)
  *     what the intention is...
  *
  *     printk(KERN_ERR "-------------------------> REFCOUNT = %d",
- *            inputDevice->RefCount);
+ *            input_dev->ref_count);
  */
 
-       if (inputDevice && atomic_read(&inputDevice->RefCount) > 1)
-               atomic_inc(&inputDevice->RefCount);
+       if (input_dev && atomic_read(&input_dev->ref_count) > 1)
+               atomic_inc(&input_dev->ref_count);
        else
-               inputDevice = NULL;
+               input_dev = NULL;
 
-       return inputDevice;
+       return input_dev;
 }
 
 /*
  * Get the inputdevice object iff exists and its refcount > 0
  */
-static struct mousevsc_dev *MustGetInputDevice(struct hv_device *Device)
+static struct mousevsc_dev *must_get_input_device(struct hv_device *device)
 {
-       struct mousevsc_dev *inputDevice;
+       struct mousevsc_dev *input_dev;
 
-       inputDevice = (struct mousevsc_dev *)Device->ext;
+       input_dev = (struct mousevsc_dev *)device->ext;
 
-       if (inputDevice && atomic_read(&inputDevice->RefCount))
-               atomic_inc(&inputDevice->RefCount);
+       if (input_dev && atomic_read(&input_dev->ref_count))
+               atomic_inc(&input_dev->ref_count);
        else
-               inputDevice = NULL;
+               input_dev = NULL;
 
-       return inputDevice;
+       return input_dev;
 }
 
-static void PutInputDevice(struct hv_device *Device)
+static void put_input_device(struct hv_device *device)
 {
-       struct mousevsc_dev *inputDevice;
+       struct mousevsc_dev *input_dev;
 
-       inputDevice = (struct mousevsc_dev *)Device->ext;
+       input_dev = (struct mousevsc_dev *)device->ext;
 
-       atomic_dec(&inputDevice->RefCount);
+       atomic_dec(&input_dev->ref_count);
 }
 
 /*
- * Drop ref count to 1 to effectively disable GetInputDevice()
+ * Drop ref count to 1 to effectively disable get_input_device()
  */
-static struct mousevsc_dev *ReleaseInputDevice(struct hv_device *Device)
+static struct mousevsc_dev *release_input_device(struct hv_device *device)
 {
-       struct mousevsc_dev *inputDevice;
+       struct mousevsc_dev *input_dev;
 
-       inputDevice = (struct mousevsc_dev *)Device->ext;
+       input_dev = (struct mousevsc_dev *)device->ext;
 
        /* Busy wait until the ref drop to 2, then set it to 1  */
-       while (atomic_cmpxchg(&inputDevice->RefCount, 2, 1) != 2)
+       while (atomic_cmpxchg(&input_dev->ref_count, 2, 1) != 2)
                udelay(100);
 
-       return inputDevice;
+       return input_dev;
 }
 
 /*
- * Drop ref count to 0. No one can use InputDevice object.
+ * Drop ref count to 0. No one can use input_device object.
  */
-static struct mousevsc_dev *FinalReleaseInputDevice(struct hv_device *Device)
+static struct mousevsc_dev *final_release_input_device(struct hv_device *device)
 {
-       struct mousevsc_dev *inputDevice;
+       struct mousevsc_dev *input_dev;
 
-       inputDevice = (struct mousevsc_dev *)Device->ext;
+       input_dev = (struct mousevsc_dev *)device->ext;
 
        /* Busy wait until the ref drop to 1, then set it to 0  */
-       while (atomic_cmpxchg(&inputDevice->RefCount, 1, 0) != 1)
+       while (atomic_cmpxchg(&input_dev->ref_count, 1, 0) != 1)
                udelay(100);
 
-       Device->ext = NULL;
-       return inputDevice;
+       device->ext = NULL;
+       return input_dev;
 }
 
-static void MousevscOnSendCompletion(struct hv_device *Device, struct vmpacket_descriptor *Packet)
+static void mousevsc_on_send_completion(struct hv_device *device,
+                                       struct vmpacket_descriptor *packet)
 {
-       struct mousevsc_dev *inputDevice;
+       struct mousevsc_dev *input_dev;
        void *request;
 
-       inputDevice = MustGetInputDevice(Device);
-       if (!inputDevice) {
+       input_dev = must_get_input_device(device);
+       if (!input_dev) {
                pr_err("unable to get input device...device being destroyed?");
                return;
        }
 
-       request = (void *)(unsigned long)Packet->trans_id;
+       request = (void *)(unsigned long)packet->trans_id;
 
-       if (request == &inputDevice->ProtocolReq) {
+       if (request == &input_dev->protocol_req) {
                /* FIXME */
                /* Shouldn't we be doing something here? */
        }
 
-       PutInputDevice(Device);
+       put_input_device(device);
 }
 
-static void MousevscOnReceiveDeviceInfo(struct mousevsc_dev *InputDevice, struct synthhid_device_info *DeviceInfo)
+static void mousevsc_on_receive_device_info(struct mousevsc_dev *input_device,
+                               struct synthhid_device_info *device_info)
 {
        int ret = 0;
        struct hid_descriptor *desc;
        struct mousevsc_prt_msg ack;
 
        /* Assume success for now */
-       InputDevice->DeviceInfoStatus = 0;
+       input_device->dev_info_status = 0;
 
        /* Save the device attr */
-       memcpy(&InputDevice->hid_dev_info, &DeviceInfo->hid_dev_info, sizeof(struct hv_input_dev_info));
+       memcpy(&input_device->hid_dev_info, &device_info->hid_dev_info,
+               sizeof(struct hv_input_dev_info));
 
        /* Save the hid desc */
-       desc = &DeviceInfo->hid_descriptor;
+       desc = &device_info->hid_descriptor;
        WARN_ON(desc->bLength > 0);
 
-       InputDevice->HidDesc = kzalloc(desc->bLength, GFP_KERNEL);
+       input_device->hid_desc = kzalloc(desc->bLength, GFP_KERNEL);
 
-       if (!InputDevice->HidDesc) {
+       if (!input_device->hid_desc) {
                pr_err("unable to allocate hid descriptor - size %d", desc->bLength);
                goto Cleanup;
        }
 
-       memcpy(InputDevice->HidDesc, desc, desc->bLength);
+       memcpy(input_device->hid_desc, desc, desc->bLength);
 
        /* Save the report desc */
-       InputDevice->ReportDescSize = desc->desc[0].wDescriptorLength;
-       InputDevice->ReportDesc = kzalloc(InputDevice->ReportDescSize,
+       input_device->report_desc_size = desc->desc[0].wDescriptorLength;
+       input_device->report_desc = kzalloc(input_device->report_desc_size,
                                          GFP_KERNEL);
 
-       if (!InputDevice->ReportDesc) {
+       if (!input_device->report_desc) {
                pr_err("unable to allocate report descriptor - size %d",
-                          InputDevice->ReportDescSize);
+                          input_device->report_desc_size);
                goto Cleanup;
        }
 
-       memcpy(InputDevice->ReportDesc,
+       memcpy(input_device->report_desc,
               ((unsigned char *)desc) + desc->bLength,
               desc->desc[0].wDescriptorLength);
 
@@ -385,7 +375,7 @@ static void MousevscOnReceiveDeviceInfo(struct mousevsc_dev *InputDevice, struct
        ack.ack.header.size = 1;
        ack.ack.reserved = 0;
 
-       ret = vmbus_sendpacket(InputDevice->Device->channel,
+       ret = vmbus_sendpacket(input_device->device->channel,
                        &ack,
                        sizeof(struct pipe_prt_msg) - sizeof(unsigned char) +
                        sizeof(struct synthhid_device_info_ack),
@@ -398,138 +388,143 @@ static void MousevscOnReceiveDeviceInfo(struct mousevsc_dev *InputDevice, struct
                goto Cleanup;
        }
 
-       InputDevice->device_wait_condition = 1;
-       wake_up(&InputDevice->DeviceInfoWaitEvent);
+       input_device->device_wait_condition = 1;
+       wake_up(&input_device->dev_info_wait_event);
 
        return;
 
 Cleanup:
-       kfree(InputDevice->HidDesc);
-       InputDevice->HidDesc = NULL;
+       kfree(input_device->hid_desc);
+       input_device->hid_desc = NULL;
 
-       kfree(InputDevice->ReportDesc);
-       InputDevice->ReportDesc = NULL;
+       kfree(input_device->report_desc);
+       input_device->report_desc = NULL;
 
-       InputDevice->DeviceInfoStatus = -1;
-       InputDevice->device_wait_condition = 1;
-       wake_up(&InputDevice->DeviceInfoWaitEvent);
+       input_device->dev_info_status = -1;
+       input_device->device_wait_condition = 1;
+       wake_up(&input_device->dev_info_wait_event);
 }
 
-static void MousevscOnReceiveInputReport(struct mousevsc_dev *InputDevice, struct synthhid_input_report *InputReport)
+static void mousevsc_on_receive_input_report(struct mousevsc_dev *input_device,
+                               struct synthhid_input_report *input_report)
 {
-       struct mousevsc_drv_obj *inputDriver;
+       struct hv_driver *input_drv;
 
-       if (!InputDevice->bInitializeComplete) {
-               pr_info("Initialization incomplete...ignoring InputReport msg");
+       if (!input_device->init_complete) {
+               pr_info("Initialization incomplete...ignoring input_report msg");
                return;
        }
 
-       inputDriver = (struct mousevsc_drv_obj *)InputDevice->Device->drv;
+       input_drv = drv_to_hv_drv(input_device->device->device.driver);
 
-       inputreport_callback(InputDevice->Device,
-                            InputReport->buffer,
-                            InputReport->header.size);
+       inputreport_callback(input_device->device,
+                            input_report->buffer,
+                            input_report->header.size);
 }
 
-static void MousevscOnReceive(struct hv_device *Device, struct vmpacket_descriptor *Packet)
+static void mousevsc_on_receive(struct hv_device *device,
+                               struct vmpacket_descriptor *packet)
 {
-       struct pipe_prt_msg *pipeMsg;
-       struct synthhid_msg *hidMsg;
-       struct mousevsc_dev *inputDevice;
+       struct pipe_prt_msg *pipe_msg;
+       struct synthhid_msg *hid_msg;
+       struct mousevsc_dev *input_dev;
 
-       inputDevice = MustGetInputDevice(Device);
-       if (!inputDevice) {
+       input_dev = must_get_input_device(device);
+       if (!input_dev) {
                pr_err("unable to get input device...device being destroyed?");
                return;
        }
 
-       pipeMsg = (struct pipe_prt_msg *)((unsigned long)Packet + (Packet->offset8 << 3));
+       pipe_msg = (struct pipe_prt_msg *)((unsigned long)packet +
+                                               (packet->offset8 << 3));
 
-       if (pipeMsg->type != PipeMessageData) {
+       if (pipe_msg->type != PipeMessageData) {
                pr_err("unknown pipe msg type - type %d len %d",
-                          pipeMsg->type, pipeMsg->size);
-               PutInputDevice(Device);
+                          pipe_msg->type, pipe_msg->size);
+               put_input_device(device);
                return ;
        }
 
-       hidMsg = (struct synthhid_msg *)&pipeMsg->data[0];
+       hid_msg = (struct synthhid_msg *)&pipe_msg->data[0];
 
-       switch (hidMsg->header.type) {
+       switch (hid_msg->header.type) {
        case SynthHidProtocolResponse:
-               memcpy(&inputDevice->ProtocolResp, pipeMsg,
-                      pipeMsg->size + sizeof(struct pipe_prt_msg) -
+               memcpy(&input_dev->protocol_resp, pipe_msg,
+                      pipe_msg->size + sizeof(struct pipe_prt_msg) -
                       sizeof(unsigned char));
-               inputDevice->protocol_wait_condition = 1;
-               wake_up(&inputDevice->ProtocolWaitEvent);
+               input_dev->protocol_wait_condition = 1;
+               wake_up(&input_dev->protocol_wait_event);
                break;
 
        case SynthHidInitialDeviceInfo:
-               WARN_ON(pipeMsg->size >= sizeof(struct hv_input_dev_info));
+               WARN_ON(pipe_msg->size >= sizeof(struct hv_input_dev_info));
 
                /*
                 * Parse out the device info into device attr,
                 * hid desc and report desc
                 */
-               MousevscOnReceiveDeviceInfo(inputDevice,
-                                           (struct synthhid_device_info *)&pipeMsg->data[0]);
+               mousevsc_on_receive_device_info(input_dev,
+                       (struct synthhid_device_info *)&pipe_msg->data[0]);
                break;
        case SynthHidInputReport:
-               MousevscOnReceiveInputReport(inputDevice,
-                                            (struct synthhid_input_report *)&pipeMsg->data[0]);
+               mousevsc_on_receive_input_report(input_dev,
+                       (struct synthhid_input_report *)&pipe_msg->data[0]);
 
                break;
        default:
                pr_err("unsupported hid msg type - type %d len %d",
-                      hidMsg->header.type, hidMsg->header.size);
+                      hid_msg->header.type, hid_msg->header.size);
                break;
        }
 
-       PutInputDevice(Device);
+       put_input_device(device);
 }
 
-static void MousevscOnChannelCallback(void *Context)
+static void mousevsc_on_channel_callback(void *context)
 {
        const int packetSize = 0x100;
        int ret = 0;
-       struct hv_device *device = (struct hv_device *)Context;
-       struct mousevsc_dev *inputDevice;
+       struct hv_device *device = (struct hv_device *)context;
+       struct mousevsc_dev *input_dev;
 
-       u32 bytesRecvd;
-       u64 requestId;
-       unsigned char packet[packetSize];
+       u32 bytes_recvd;
+       u64 req_id;
+       unsigned char packet[0x100];
        struct vmpacket_descriptor *desc;
        unsigned char   *buffer = packet;
        int     bufferlen = packetSize;
 
-       inputDevice = MustGetInputDevice(device);
+       input_dev = must_get_input_device(device);
 
-       if (!inputDevice) {
+       if (!input_dev) {
                pr_err("unable to get input device...device being destroyed?");
                return;
        }
 
        do {
-               ret = vmbus_recvpacket_raw(device->channel, buffer, bufferlen, &bytesRecvd, &requestId);
+               ret = vmbus_recvpacket_raw(device->channel, buffer,
+                                       bufferlen, &bytes_recvd, &req_id);
 
                if (ret == 0) {
-                       if (bytesRecvd > 0) {
+                       if (bytes_recvd > 0) {
                                desc = (struct vmpacket_descriptor *)buffer;
 
                                switch (desc->type) {
                                        case VM_PKT_COMP:
-                                               MousevscOnSendCompletion(device,
-                                                                        desc);
+                                               mousevsc_on_send_completion(
+                                                       device, desc);
                                                break;
 
                                        case VM_PKT_DATA_INBAND:
-                                               MousevscOnReceive(device, desc);
+                                               mousevsc_on_receive(
+                                                       device, desc);
                                                break;
 
                                        default:
                                                pr_err("unhandled packet type %d, tid %llx len %d\n",
                                                           desc->type,
-                                                          requestId,
-                                                          bytesRecvd);
+                                                          req_id,
+                                                          bytes_recvd);
                                                break;
                                }
 
@@ -555,8 +550,8 @@ static void MousevscOnChannelCallback(void *Context)
                        }
                } else if (ret == -2) {
                        /* Handle large packet */
-                       bufferlen = bytesRecvd;
-                       buffer = kzalloc(bytesRecvd, GFP_KERNEL);
+                       bufferlen = bytes_recvd;
+                       buffer = kzalloc(bytes_recvd, GFP_KERNEL);
 
                        if (buffer == NULL) {
                                buffer = packet;
@@ -564,35 +559,35 @@ static void MousevscOnChannelCallback(void *Context)
 
                                /* Try again next time around */
                                pr_err("unable to allocate buffer of size %d!",
-                                      bytesRecvd);
+                                      bytes_recvd);
                                break;
                        }
                }
        } while (1);
 
-       PutInputDevice(device);
+       put_input_device(device);
 
        return;
 }
 
-static int MousevscConnectToVsp(struct hv_device *Device)
+static int mousevsc_connect_to_vsp(struct hv_device *device)
 {
        int ret = 0;
-       struct mousevsc_dev *inputDevice;
+       struct mousevsc_dev *input_dev;
        struct mousevsc_prt_msg *request;
        struct mousevsc_prt_msg *response;
 
-       inputDevice = GetInputDevice(Device);
+       input_dev = get_input_device(device);
 
-       if (!inputDevice) {
+       if (!input_dev) {
                pr_err("unable to get input device...device being destroyed?");
                return -1;
        }
 
-       init_waitqueue_head(&inputDevice->ProtocolWaitEvent);
-       init_waitqueue_head(&inputDevice->DeviceInfoWaitEvent);
+       init_waitqueue_head(&input_dev->protocol_wait_event);
+       init_waitqueue_head(&input_dev->dev_info_wait_event);
 
-       request = &inputDevice->ProtocolReq;
+       request = &input_dev->protocol_req;
 
        /*
         * Now, initiate the vsc/vsp initialization protocol on the open channel
@@ -608,7 +603,7 @@ static int MousevscConnectToVsp(struct hv_device *Device)
 
        pr_info("synthhid protocol request...");
 
-       ret = vmbus_sendpacket(Device->channel, request,
+       ret = vmbus_sendpacket(device->channel, request,
                                        sizeof(struct pipe_prt_msg) -
                                        sizeof(unsigned char) +
                                        sizeof(struct synthhid_protocol_request),
@@ -620,14 +615,15 @@ static int MousevscConnectToVsp(struct hv_device *Device)
                goto Cleanup;
        }
 
-       inputDevice->protocol_wait_condition = 0;
-       wait_event_timeout(inputDevice->ProtocolWaitEvent, inputDevice->protocol_wait_condition, msecs_to_jiffies(1000));
-       if (inputDevice->protocol_wait_condition == 0) {
+       input_dev->protocol_wait_condition = 0;
+       wait_event_timeout(input_dev->protocol_wait_event,
+               input_dev->protocol_wait_condition, msecs_to_jiffies(1000));
+       if (input_dev->protocol_wait_condition == 0) {
                ret = -ETIMEDOUT;
                goto Cleanup;
        }
 
-       response = &inputDevice->ProtocolResp;
+       response = &input_dev->protocol_resp;
 
        if (!response->response.approved) {
                pr_err("synthhid protocol request failed (version %d)",
@@ -636,9 +632,10 @@ static int MousevscConnectToVsp(struct hv_device *Device)
                goto Cleanup;
        }
 
-       inputDevice->device_wait_condition = 0;
-       wait_event_timeout(inputDevice->DeviceInfoWaitEvent, inputDevice->device_wait_condition, msecs_to_jiffies(1000));
-       if (inputDevice->device_wait_condition == 0) {
+       input_dev->device_wait_condition = 0;
+       wait_event_timeout(input_dev->dev_info_wait_event,
+               input_dev->device_wait_condition, msecs_to_jiffies(1000));
+       if (input_dev->device_wait_condition == 0) {
                ret = -ETIMEDOUT;
                goto Cleanup;
        }
@@ -647,94 +644,95 @@ static int MousevscConnectToVsp(struct hv_device *Device)
         * We should have gotten the device attr, hid desc and report
         * desc at this point
         */
-       if (!inputDevice->DeviceInfoStatus)
+       if (!input_dev->dev_info_status)
                pr_info("**** input channel up and running!! ****");
        else
                ret = -1;
 
 Cleanup:
-       PutInputDevice(Device);
+       put_input_device(device);
 
        return ret;
 }
 
-static int MousevscOnDeviceAdd(struct hv_device *Device, void *AdditionalInfo)
+static int mousevsc_on_device_add(struct hv_device *device,
+                                       void *additional_info)
 {
        int ret = 0;
-       struct mousevsc_dev *inputDevice;
-       struct mousevsc_drv_obj *inputDriver;
+       struct mousevsc_dev *input_dev;
+       struct hv_driver *input_drv;
        struct hv_input_dev_info dev_info;
 
-       inputDevice = AllocInputDevice(Device);
+       input_dev = alloc_input_device(device);
 
-       if (!inputDevice) {
+       if (!input_dev) {
                ret = -1;
                goto Cleanup;
        }
 
-       inputDevice->bInitializeComplete = false;
+       input_dev->init_complete = false;
 
        /* Open the channel */
-       ret = vmbus_open(Device->channel,
+       ret = vmbus_open(device->channel,
                INPUTVSC_SEND_RING_BUFFER_SIZE,
                INPUTVSC_RECV_RING_BUFFER_SIZE,
                NULL,
                0,
-               MousevscOnChannelCallback,
-               Device
+               mousevsc_on_channel_callback,
+               device
                );
 
        if (ret != 0) {
                pr_err("unable to open channel: %d", ret);
-               FreeInputDevice(inputDevice);
+               free_input_device(input_dev);
                return -1;
        }
 
        pr_info("InputVsc channel open: %d", ret);
 
-       ret = MousevscConnectToVsp(Device);
+       ret = mousevsc_connect_to_vsp(device);
 
        if (ret != 0) {
                pr_err("unable to connect channel: %d", ret);
 
-               vmbus_close(Device->channel);
-               FreeInputDevice(inputDevice);
+               vmbus_close(device->channel);
+               free_input_device(input_dev);
                return ret;
        }
 
-       inputDriver = (struct mousevsc_drv_obj *)inputDevice->Device->drv;
+       input_drv = drv_to_hv_drv(input_dev->device->device.driver);
 
-       dev_info.vendor = inputDevice->hid_dev_info.vendor;
-       dev_info.product = inputDevice->hid_dev_info.product;
-       dev_info.version = inputDevice->hid_dev_info.version;
+       dev_info.vendor = input_dev->hid_dev_info.vendor;
+       dev_info.product = input_dev->hid_dev_info.product;
+       dev_info.version = input_dev->hid_dev_info.version;
        strcpy(dev_info.name, "Microsoft Vmbus HID-compliant Mouse");
 
        /* Send the device info back up */
-       deviceinfo_callback(Device, &dev_info);
+       deviceinfo_callback(device, &dev_info);
 
        /* Send the report desc back up */
        /* workaround SA-167 */
-       if (inputDevice->ReportDesc[14] == 0x25)
-               inputDevice->ReportDesc[14] = 0x29;
+       if (input_dev->report_desc[14] == 0x25)
+               input_dev->report_desc[14] = 0x29;
 
-       reportdesc_callback(Device, inputDevice->ReportDesc,
-                           inputDevice->ReportDescSize);
+       reportdesc_callback(device, input_dev->report_desc,
+                           input_dev->report_desc_size);
 
-       inputDevice->bInitializeComplete = true;
+       input_dev->init_complete = true;
 
 Cleanup:
        return ret;
 }
 
-static int MousevscOnDeviceRemove(struct hv_device *Device)
+static int mousevsc_on_device_remove(struct hv_device *device)
 {
-       struct mousevsc_dev *inputDevice;
+       struct mousevsc_dev *input_dev;
        int ret = 0;
 
        pr_info("disabling input device (%p)...",
-                   Device->ext);
+                   device->ext);
 
-       inputDevice = ReleaseInputDevice(Device);
+       input_dev = release_input_device(device);
 
 
        /*
@@ -743,29 +741,27 @@ static int MousevscOnDeviceRemove(struct hv_device *Device)
         *
         * so that outstanding requests can be completed.
         */
-       while (inputDevice->NumOutstandingRequests) {
-               pr_info("waiting for %d requests to complete...", inputDevice->NumOutstandingRequests);
+       while (input_dev->num_outstanding_req) {
+               pr_info("waiting for %d requests to complete...",
+                       input_dev->num_outstanding_req);
 
                udelay(100);
        }
 
-       pr_info("removing input device (%p)...", Device->ext);
+       pr_info("removing input device (%p)...", device->ext);
 
-       inputDevice = FinalReleaseInputDevice(Device);
+       input_dev = final_release_input_device(device);
 
-       pr_info("input device (%p) safe to remove", inputDevice);
+       pr_info("input device (%p) safe to remove", input_dev);
 
        /* Close the channel */
-       vmbus_close(Device->channel);
+       vmbus_close(device->channel);
 
-       FreeInputDevice(inputDevice);
+       free_input_device(input_dev);
 
        return ret;
 }
 
-static void MousevscOnCleanup(struct hv_driver *drv)
-{
-}
 
 /*
  * Data types
@@ -778,8 +774,6 @@ struct input_device_context {
 };
 
 
-static struct  mousevsc_drv_obj g_mousevsc_drv;
-
 static void deviceinfo_callback(struct hv_device *dev, struct hv_input_dev_info *info)
 {
        struct input_device_context *input_device_ctx =
@@ -813,24 +807,19 @@ static void mousevsc_hid_close(struct hid_device *hid)
 {
 }
 
-static int mousevsc_probe(struct device *device)
+static int mousevsc_probe(struct hv_device *dev)
 {
        int ret = 0;
 
-       struct hv_driver *drv =
-               drv_to_hv_drv(device->driver);
-       struct mousevsc_drv_obj *mousevsc_drv_obj = drv->priv;
-
-       struct hv_device *device_obj = device_to_hv_device(device);
        struct input_device_context *input_dev_ctx;
 
        input_dev_ctx = kmalloc(sizeof(struct input_device_context),
                                GFP_KERNEL);
 
-       dev_set_drvdata(device, input_dev_ctx);
+       dev_set_drvdata(&dev->device, input_dev_ctx);
 
        /* Call to the vsc driver to add the device */
-       ret = mousevsc_drv_obj->Base.dev_add(device_obj, NULL);
+       ret = mousevsc_on_device_add(dev, NULL);
 
        if (ret != 0) {
                DPRINT_ERR(INPUTVSC_DRV, "unable to add input vsc device");
@@ -841,35 +830,27 @@ static int mousevsc_probe(struct device *device)
        return 0;
 }
 
-static int mousevsc_remove(struct device *device)
+static int mousevsc_remove(struct hv_device *dev)
 {
        int ret = 0;
 
-       struct hv_driver *drv =
-               drv_to_hv_drv(device->driver);
-       struct mousevsc_drv_obj *mousevsc_drv_obj = drv->priv;
-
-       struct hv_device *device_obj = device_to_hv_device(device);
        struct input_device_context *input_dev_ctx;
 
        input_dev_ctx = kmalloc(sizeof(struct input_device_context),
                                GFP_KERNEL);
 
-       dev_set_drvdata(device, input_dev_ctx);
+       dev_set_drvdata(&dev->device, input_dev_ctx);
 
        if (input_dev_ctx->connected) {
                hidinput_disconnect(input_dev_ctx->hid_device);
                input_dev_ctx->connected = 0;
        }
 
-       if (!mousevsc_drv_obj->Base.dev_rm)
-               return -1;
-
        /*
         * Call to the vsc driver to let it know that the device
         * is being removed
         */
-       ret = mousevsc_drv_obj->Base.dev_rm(device_obj);
+       ret = mousevsc_on_device_remove(dev);
 
        if (ret != 0) {
                DPRINT_ERR(INPUTVSC_DRV,
@@ -934,81 +915,28 @@ static void reportdesc_callback(struct hv_device *dev, void *packet, u32 len)
        kfree(hid_dev);
 }
 
-static int mousevsc_drv_exit_cb(struct device *dev, void *data)
-{
-       struct device **curr = (struct device **)data;
-       *curr = dev;
 
-       return 1;
-}
+static struct  hv_driver mousevsc_drv = {
+       .probe = mousevsc_probe,
+       .remove = mousevsc_remove,
+};
 
 static void mousevsc_drv_exit(void)
 {
-       struct mousevsc_drv_obj *mousevsc_drv_obj = &g_mousevsc_drv;
-       struct hv_driver *drv = &g_mousevsc_drv.Base;
-       int ret;
-
-       struct device *current_dev = NULL;
-
-       while (1) {
-               current_dev = NULL;
-
-               /* Get the device */
-               ret = driver_for_each_device(&drv->driver, NULL,
-                                            (void *)&current_dev,
-                                            mousevsc_drv_exit_cb);
-               if (ret)
-                       printk(KERN_ERR "Can't find mouse device!\n");
-
-               if (current_dev == NULL)
-                       break;
-
-               /* Initiate removal from the top-down */
-               device_unregister(current_dev);
-       }
-
-       if (mousevsc_drv_obj->Base.cleanup)
-               mousevsc_drv_obj->Base.cleanup(&mousevsc_drv_obj->Base);
-
-       vmbus_child_driver_unregister(&drv->driver);
-
-       return;
+       vmbus_child_driver_unregister(&mousevsc_drv.driver);
 }
 
-static int mouse_vsc_initialize(struct hv_driver *Driver)
-{
-       struct mousevsc_drv_obj *inputDriver =
-               (struct mousevsc_drv_obj *)Driver;
-       int ret = 0;
-
-       Driver->name = driver_name;
-       memcpy(&Driver->dev_type, &mouse_guid,
-              sizeof(struct hv_guid));
-
-       /* Setup the dispatch table */
-       inputDriver->Base.dev_add = MousevscOnDeviceAdd;
-       inputDriver->Base.dev_rm = MousevscOnDeviceRemove;
-       inputDriver->Base.cleanup = MousevscOnCleanup;
-
-       return ret;
-}
-
-
 static int __init mousevsc_init(void)
 {
-       struct mousevsc_drv_obj *input_drv_obj = &g_mousevsc_drv;
-       struct hv_driver *drv = &g_mousevsc_drv.Base;
+       struct hv_driver *drv = &mousevsc_drv;
 
        DPRINT_INFO(INPUTVSC_DRV, "Hyper-V Mouse driver initializing.");
 
-       /* Callback to client driver to complete the initialization */
-       mouse_vsc_initialize(&input_drv_obj->Base);
-
-       drv->driver.name = input_drv_obj->Base.name;
-       drv->priv = input_drv_obj;
+       memcpy(&drv->dev_type, &mouse_guid,
+              sizeof(struct hv_guid));
 
-       drv->driver.probe = mousevsc_probe;
-       drv->driver.remove = mousevsc_remove;
+       drv->driver.name = driver_name;
+       drv->name = driver_name;
 
        /* The driver belongs to vmbus */
        vmbus_child_driver_register(&drv->driver);
index a7ee533303b4f97dba9c2b2e78c2d81e148726c4..0efb04915255dfb7a9d8544154922b2ce8704199 100644 (file)
@@ -20,6 +20,7 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  *
  */
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
 #include <linux/version.h>
 #include <linux/clocksource.h>
@@ -91,7 +92,7 @@ static int __init init_hv_clocksource(void)
        if (!dmi_check_system(hv_timesource_dmi_table))
                return -ENODEV;
 
-       printk(KERN_INFO "Registering HyperV clock source\n");
+       pr_info("Registering HyperV clock source\n");
        return clocksource_register(&hyperv_cs);
 }
 
index 2df15683f8fafa674afb653bc23bcaf4ce1be2d4..c164b54b4cd774ee37b562315a91026088f62ff5 100644 (file)
@@ -18,6 +18,8 @@
  *   Haiyang Zhang <haiyangz@microsoft.com>
  *   Hank Janssen  <hjanssen@microsoft.com>
  */
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/dmi.h>
 #include <linux/pci.h>
 
-#include "logging.h"
-#include "hv_api.h"
-#include "vmbus.h"
-#include "vmbus_packet_format.h"
-#include "vmbus_channel_interface.h"
-#include "version_info.h"
-#include "channel.h"
-#include "vmbus_private.h"
-#include "vmbus_api.h"
-#include "utils.h"
+#include "hyperv.h"
 #include "hv_kvp.h"
 
 static u8 *shut_txf_buf;
@@ -59,9 +52,6 @@ static void shutdown_onchannelcallback(void *context)
                         PAGE_SIZE, &recvlen, &requestid);
 
        if (recvlen > 0) {
-               DPRINT_DBG(VMBUS, "shutdown packet: len=%d, requestid=%lld",
-                          recvlen, requestid);
-
                icmsghdrp = (struct icmsg_hdr *)&shut_txf_buf[
                        sizeof(struct vmbuspipe_hdr)];
 
@@ -79,17 +69,17 @@ static void shutdown_onchannelcallback(void *context)
                                icmsghdrp->status = HV_S_OK;
                                execute_shutdown = true;
 
-                               DPRINT_INFO(VMBUS, "Shutdown request received -"
-                                           " graceful shutdown initiated");
+                               pr_info("Shutdown request received -"
+                                           " graceful shutdown initiated\n");
                                break;
                        default:
                                icmsghdrp->status = HV_E_FAIL;
                                execute_shutdown = false;
 
-                               DPRINT_INFO(VMBUS, "Shutdown request received -"
-                                           " Invalid request");
+                               pr_info("Shutdown request received -"
+                                           " Invalid request\n");
                                break;
-                       };
+                       }
                }
 
                icmsghdrp->icflags = ICMSGHDRFLAG_TRANSACTION
@@ -159,9 +149,6 @@ static void timesync_onchannelcallback(void *context)
                         PAGE_SIZE, &recvlen, &requestid);
 
        if (recvlen > 0) {
-               DPRINT_DBG(VMBUS, "timesync packet: recvlen=%d, requestid=%lld",
-                       recvlen, requestid);
-
                icmsghdrp = (struct icmsg_hdr *)&time_txf_buf[
                                sizeof(struct vmbuspipe_hdr)];
 
@@ -200,9 +187,6 @@ static void heartbeat_onchannelcallback(void *context)
                         PAGE_SIZE, &recvlen, &requestid);
 
        if (recvlen > 0) {
-               DPRINT_DBG(VMBUS, "heartbeat packet: len=%d, requestid=%lld",
-                          recvlen, requestid);
-
                icmsghdrp = (struct icmsg_hdr *)&hbeat_txf_buf[
                                sizeof(struct vmbuspipe_hdr)];
 
@@ -214,9 +198,6 @@ static void heartbeat_onchannelcallback(void *context)
                                        sizeof(struct vmbuspipe_hdr) +
                                        sizeof(struct icmsg_hdr)];
 
-                       DPRINT_DBG(VMBUS, "heartbeat seq = %lld",
-                                  heartbeat_msg->seq_num);
-
                        heartbeat_msg->seq_num += 1;
                }
 
@@ -254,7 +235,7 @@ MODULE_DEVICE_TABLE(dmi, hv_utils_dmi_table);
 
 static int __init init_hyperv_utils(void)
 {
-       printk(KERN_INFO "Registering HyperV Utility Driver\n");
+       pr_info("Registering HyperV Utility Driver\n");
 
        if (hv_kvp_init())
                return -ENODEV;
@@ -268,52 +249,48 @@ static int __init init_hyperv_utils(void)
        hbeat_txf_buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
 
        if (!shut_txf_buf || !time_txf_buf || !hbeat_txf_buf) {
-               printk(KERN_INFO
-                      "Unable to allocate memory for receive buffer\n");
+               pr_info("Unable to allocate memory for receive buffer\n");
                kfree(shut_txf_buf);
                kfree(time_txf_buf);
                kfree(hbeat_txf_buf);
                return -ENOMEM;
        }
 
-       hv_cb_utils[HV_SHUTDOWN_MSG].channel->onchannel_callback =
-               &shutdown_onchannelcallback;
        hv_cb_utils[HV_SHUTDOWN_MSG].callback = &shutdown_onchannelcallback;
 
-       hv_cb_utils[HV_TIMESYNC_MSG].channel->onchannel_callback =
-               &timesync_onchannelcallback;
        hv_cb_utils[HV_TIMESYNC_MSG].callback = &timesync_onchannelcallback;
 
-       hv_cb_utils[HV_HEARTBEAT_MSG].channel->onchannel_callback =
-               &heartbeat_onchannelcallback;
        hv_cb_utils[HV_HEARTBEAT_MSG].callback = &heartbeat_onchannelcallback;
 
-       hv_cb_utils[HV_KVP_MSG].channel->onchannel_callback =
-               &hv_kvp_onchannelcallback;
-
-
+       hv_cb_utils[HV_KVP_MSG].callback = &hv_kvp_onchannelcallback;
 
        return 0;
 }
 
 static void exit_hyperv_utils(void)
 {
-       printk(KERN_INFO "De-Registered HyperV Utility Driver\n");
+       pr_info("De-Registered HyperV Utility Driver\n");
+
+       if (hv_cb_utils[HV_SHUTDOWN_MSG].channel != NULL)
+               hv_cb_utils[HV_SHUTDOWN_MSG].channel->onchannel_callback =
+                       &chn_cb_negotiate;
+       hv_cb_utils[HV_SHUTDOWN_MSG].callback = NULL;
 
-       hv_cb_utils[HV_SHUTDOWN_MSG].channel->onchannel_callback =
-               &chn_cb_negotiate;
-       hv_cb_utils[HV_SHUTDOWN_MSG].callback = &chn_cb_negotiate;
+       if (hv_cb_utils[HV_TIMESYNC_MSG].channel != NULL)
+               hv_cb_utils[HV_TIMESYNC_MSG].channel->onchannel_callback =
+                       &chn_cb_negotiate;
+       hv_cb_utils[HV_TIMESYNC_MSG].callback = NULL;
 
-       hv_cb_utils[HV_TIMESYNC_MSG].channel->onchannel_callback =
-               &chn_cb_negotiate;
-       hv_cb_utils[HV_TIMESYNC_MSG].callback = &chn_cb_negotiate;
+       if (hv_cb_utils[HV_HEARTBEAT_MSG].channel != NULL)
+               hv_cb_utils[HV_HEARTBEAT_MSG].channel->onchannel_callback =
+                       &chn_cb_negotiate;
+       hv_cb_utils[HV_HEARTBEAT_MSG].callback = NULL;
 
-       hv_cb_utils[HV_HEARTBEAT_MSG].channel->onchannel_callback =
-               &chn_cb_negotiate;
-       hv_cb_utils[HV_HEARTBEAT_MSG].callback = &chn_cb_negotiate;
+       if (hv_cb_utils[HV_KVP_MSG].channel != NULL)
+               hv_cb_utils[HV_KVP_MSG].channel->onchannel_callback =
+                       &chn_cb_negotiate;
+       hv_cb_utils[HV_KVP_MSG].callback = NULL;
 
-       hv_cb_utils[HV_KVP_MSG].channel->onchannel_callback =
-               &chn_cb_negotiate;
        hv_kvp_deinit();
 
        kfree(shut_txf_buf);
diff --git a/drivers/staging/hv/hyperv.h b/drivers/staging/hv/hyperv.h
new file mode 100644 (file)
index 0000000..3310e9b
--- /dev/null
@@ -0,0 +1,944 @@
+/*
+ *
+ * Copyright (c) 2011, Microsoft Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place - Suite 330, Boston, MA 02111-1307 USA.
+ *
+ * Authors:
+ *   Haiyang Zhang <haiyangz@microsoft.com>
+ *   Hank Janssen  <hjanssen@microsoft.com>
+ *   K. Y. Srinivasan <kys@microsoft.com>
+ *
+ */
+
+#ifndef _HYPERV_H
+#define _HYPERV_H
+
+#include <linux/scatterlist.h>
+#include <linux/list.h>
+#include <linux/timer.h>
+#include <linux/workqueue.h>
+#include <linux/completion.h>
+#include <linux/device.h>
+
+
+#include <asm/hyperv.h>
+
+struct hv_guid {
+       unsigned char data[16];
+};
+
+#define MAX_PAGE_BUFFER_COUNT                          16
+#define MAX_MULTIPAGE_BUFFER_COUNT                     32 /* 128K */
+
+#pragma pack(push, 1)
+
+/* Single-page buffer */
+struct hv_page_buffer {
+       u32 len;
+       u32 offset;
+       u64 pfn;
+};
+
+/* Multiple-page buffer */
+struct hv_multipage_buffer {
+       /* Length and Offset determines the # of pfns in the array */
+       u32 len;
+       u32 offset;
+       u64 pfn_array[MAX_MULTIPAGE_BUFFER_COUNT];
+};
+
+/* 0x18 includes the proprietary packet header */
+#define MAX_PAGE_BUFFER_PACKET         (0x18 +                 \
+                                       (sizeof(struct hv_page_buffer) * \
+                                        MAX_PAGE_BUFFER_COUNT))
+#define MAX_MULTIPAGE_BUFFER_PACKET    (0x18 +                 \
+                                        sizeof(struct hv_multipage_buffer))
+
+
+#pragma pack(pop)
+
+struct hv_ring_buffer {
+       /* Offset in bytes from the start of ring data below */
+       u32 write_index;
+
+       /* Offset in bytes from the start of ring data below */
+       u32 read_index;
+
+       u32 interrupt_mask;
+
+       /* Pad it to PAGE_SIZE so that data starts on page boundary */
+       u8      reserved[4084];
+
+       /* NOTE:
+        * The interrupt_mask field is used only for channels but since our
+        * vmbus connection also uses this data structure and its data starts
+        * here, we commented out this field.
+        */
+
+       /*
+        * Ring data starts here + RingDataStartOffset
+        * !!! DO NOT place any fields below this !!!
+        */
+       u8 buffer[0];
+} __packed;
+
+struct hv_ring_buffer_info {
+       struct hv_ring_buffer *ring_buffer;
+       u32 ring_size;                  /* Include the shared header */
+       spinlock_t ring_lock;
+
+       u32 ring_datasize;              /* < ring_size */
+       u32 ring_data_startoffset;
+};
+
+struct hv_ring_buffer_debug_info {
+       u32 current_interrupt_mask;
+       u32 current_read_index;
+       u32 current_write_index;
+       u32 bytes_avail_toread;
+       u32 bytes_avail_towrite;
+};
+
+/*
+ * We use the same version numbering for all Hyper-V modules.
+ *
+ * Definition of versioning is as follows;
+ *
+ *     Major Number    Changes for these scenarios;
+ *                     1.      When a new version of Windows Hyper-V
+ *                             is released.
+ *                     2.      A Major change has occurred in the
+ *                             Linux IC's.
+ *                     (For example the merge for the first time
+ *                     into the kernel) Every time the Major Number
+ *                     changes, the Revision number is reset to 0.
+ *     Minor Number    Changes when new functionality is added
+ *                     to the Linux IC's that is not a bug fix.
+ *
+ * 3.1 - Added completed hv_utils driver. Shutdown/Heartbeat/Timesync
+ */
+#define HV_DRV_VERSION           "3.1"
+
+
+/*
+ * A revision number of vmbus that is used for ensuring both ends on a
+ * partition are using compatible versions.
+ */
+#define VMBUS_REVISION_NUMBER          13
+
+/* Make maximum size of pipe payload of 16K */
+#define MAX_PIPE_DATA_PAYLOAD          (sizeof(u8) * 16384)
+
+/* Define PipeMode values. */
+#define VMBUS_PIPE_TYPE_BYTE           0x00000000
+#define VMBUS_PIPE_TYPE_MESSAGE                0x00000004
+
+/* The size of the user defined data buffer for non-pipe offers. */
+#define MAX_USER_DEFINED_BYTES         120
+
+/* The size of the user defined data buffer for pipe offers. */
+#define MAX_PIPE_USER_DEFINED_BYTES    116
+
+/*
+ * At the center of the Channel Management library is the Channel Offer. This
+ * struct contains the fundamental information about an offer.
+ */
+struct vmbus_channel_offer {
+       struct hv_guid if_type;
+       struct hv_guid if_instance;
+       u64 int_latency; /* in 100ns units */
+       u32 if_revision;
+       u32 server_ctx_size;    /* in bytes */
+       u16 chn_flags;
+       u16 mmio_megabytes;             /* in bytes * 1024 * 1024 */
+
+       union {
+               /* Non-pipes: The user has MAX_USER_DEFINED_BYTES bytes. */
+               struct {
+                       unsigned char user_def[MAX_USER_DEFINED_BYTES];
+               } std;
+
+               /*
+                * Pipes:
+                * The following sructure is an integrated pipe protocol, which
+                * is implemented on top of standard user-defined data. Pipe
+                * clients have MAX_PIPE_USER_DEFINED_BYTES left for their own
+                * use.
+                */
+               struct {
+                       u32  pipe_mode;
+                       unsigned char user_def[MAX_PIPE_USER_DEFINED_BYTES];
+               } pipe;
+       } u;
+       u32 padding;
+} __packed;
+
+/* Server Flags */
+#define VMBUS_CHANNEL_ENUMERATE_DEVICE_INTERFACE       1
+#define VMBUS_CHANNEL_SERVER_SUPPORTS_TRANSFER_PAGES   2
+#define VMBUS_CHANNEL_SERVER_SUPPORTS_GPADLS           4
+#define VMBUS_CHANNEL_NAMED_PIPE_MODE                  0x10
+#define VMBUS_CHANNEL_LOOPBACK_OFFER                   0x100
+#define VMBUS_CHANNEL_PARENT_OFFER                     0x200
+#define VMBUS_CHANNEL_REQUEST_MONITORED_NOTIFICATION   0x400
+
+struct vmpacket_descriptor {
+       u16 type;
+       u16 offset8;
+       u16 len8;
+       u16 flags;
+       u64 trans_id;
+} __packed;
+
+struct vmpacket_header {
+       u32 prev_pkt_start_offset;
+       struct vmpacket_descriptor descriptor;
+} __packed;
+
+struct vmtransfer_page_range {
+       u32 byte_count;
+       u32 byte_offset;
+} __packed;
+
+struct vmtransfer_page_packet_header {
+       struct vmpacket_descriptor d;
+       u16 xfer_pageset_id;
+       bool sender_owns_set;
+       u8 reserved;
+       u32 range_cnt;
+       struct vmtransfer_page_range ranges[1];
+} __packed;
+
+struct vmgpadl_packet_header {
+       struct vmpacket_descriptor d;
+       u32 gpadl;
+       u32 reserved;
+} __packed;
+
+struct vmadd_remove_transfer_page_set {
+       struct vmpacket_descriptor d;
+       u32 gpadl;
+       u16 xfer_pageset_id;
+       u16 reserved;
+} __packed;
+
+/*
+ * This structure defines a range in guest physical space that can be made to
+ * look virtually contiguous.
+ */
+struct gpa_range {
+       u32 byte_count;
+       u32 byte_offset;
+       u64 pfn_array[0];
+};
+
+/*
+ * This is the format for an Establish Gpadl packet, which contains a handle by
+ * which this GPADL will be known and a set of GPA ranges associated with it.
+ * This can be converted to a MDL by the guest OS.  If there are multiple GPA
+ * ranges, then the resulting MDL will be "chained," representing multiple VA
+ * ranges.
+ */
+struct vmestablish_gpadl {
+       struct vmpacket_descriptor d;
+       u32 gpadl;
+       u32 range_cnt;
+       struct gpa_range range[1];
+} __packed;
+
+/*
+ * This is the format for a Teardown Gpadl packet, which indicates that the
+ * GPADL handle in the Establish Gpadl packet will never be referenced again.
+ */
+struct vmteardown_gpadl {
+       struct vmpacket_descriptor d;
+       u32 gpadl;
+       u32 reserved;   /* for alignment to a 8-byte boundary */
+} __packed;
+
+/*
+ * This is the format for a GPA-Direct packet, which contains a set of GPA
+ * ranges, in addition to commands and/or data.
+ */
+struct vmdata_gpa_direct {
+       struct vmpacket_descriptor d;
+       u32 reserved;
+       u32 range_cnt;
+       struct gpa_range range[1];
+} __packed;
+
+/* This is the format for a Additional Data Packet. */
+struct vmadditional_data {
+       struct vmpacket_descriptor d;
+       u64 total_bytes;
+       u32 offset;
+       u32 byte_cnt;
+       unsigned char data[1];
+} __packed;
+
+union vmpacket_largest_possible_header {
+       struct vmpacket_descriptor simple_hdr;
+       struct vmtransfer_page_packet_header xfer_page_hdr;
+       struct vmgpadl_packet_header gpadl_hdr;
+       struct vmadd_remove_transfer_page_set add_rm_xfer_page_hdr;
+       struct vmestablish_gpadl establish_gpadl_hdr;
+       struct vmteardown_gpadl teardown_gpadl_hdr;
+       struct vmdata_gpa_direct data_gpa_direct_hdr;
+};
+
+#define VMPACKET_DATA_START_ADDRESS(__packet)  \
+       (void *)(((unsigned char *)__packet) +  \
+        ((struct vmpacket_descriptor)__packet)->offset8 * 8)
+
+#define VMPACKET_DATA_LENGTH(__packet)         \
+       ((((struct vmpacket_descriptor)__packet)->len8 -        \
+         ((struct vmpacket_descriptor)__packet)->offset8) * 8)
+
+#define VMPACKET_TRANSFER_MODE(__packet)       \
+       (((struct IMPACT)__packet)->type)
+
+enum vmbus_packet_type {
+       VM_PKT_INVALID                          = 0x0,
+       VM_PKT_SYNCH                            = 0x1,
+       VM_PKT_ADD_XFER_PAGESET                 = 0x2,
+       VM_PKT_RM_XFER_PAGESET                  = 0x3,
+       VM_PKT_ESTABLISH_GPADL                  = 0x4,
+       VM_PKT_TEARDOWN_GPADL                   = 0x5,
+       VM_PKT_DATA_INBAND                      = 0x6,
+       VM_PKT_DATA_USING_XFER_PAGES            = 0x7,
+       VM_PKT_DATA_USING_GPADL                 = 0x8,
+       VM_PKT_DATA_USING_GPA_DIRECT            = 0x9,
+       VM_PKT_CANCEL_REQUEST                   = 0xa,
+       VM_PKT_COMP                             = 0xb,
+       VM_PKT_DATA_USING_ADDITIONAL_PKT        = 0xc,
+       VM_PKT_ADDITIONAL_DATA                  = 0xd
+};
+
+#define VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED    1
+
+
+/* Version 1 messages */
+enum vmbus_channel_message_type {
+       CHANNELMSG_INVALID                      =  0,
+       CHANNELMSG_OFFERCHANNEL         =  1,
+       CHANNELMSG_RESCIND_CHANNELOFFER =  2,
+       CHANNELMSG_REQUESTOFFERS                =  3,
+       CHANNELMSG_ALLOFFERS_DELIVERED  =  4,
+       CHANNELMSG_OPENCHANNEL          =  5,
+       CHANNELMSG_OPENCHANNEL_RESULT           =  6,
+       CHANNELMSG_CLOSECHANNEL         =  7,
+       CHANNELMSG_GPADL_HEADER         =  8,
+       CHANNELMSG_GPADL_BODY                   =  9,
+       CHANNELMSG_GPADL_CREATED                = 10,
+       CHANNELMSG_GPADL_TEARDOWN               = 11,
+       CHANNELMSG_GPADL_TORNDOWN               = 12,
+       CHANNELMSG_RELID_RELEASED               = 13,
+       CHANNELMSG_INITIATE_CONTACT             = 14,
+       CHANNELMSG_VERSION_RESPONSE             = 15,
+       CHANNELMSG_UNLOAD                       = 16,
+#ifdef VMBUS_FEATURE_PARENT_OR_PEER_MEMORY_MAPPED_INTO_A_CHILD
+       CHANNELMSG_VIEWRANGE_ADD                = 17,
+       CHANNELMSG_VIEWRANGE_REMOVE             = 18,
+#endif
+       CHANNELMSG_COUNT
+};
+
+struct vmbus_channel_message_header {
+       enum vmbus_channel_message_type msgtype;
+       u32 padding;
+} __packed;
+
+/* Query VMBus Version parameters */
+struct vmbus_channel_query_vmbus_version {
+       struct vmbus_channel_message_header header;
+       u32 version;
+} __packed;
+
+/* VMBus Version Supported parameters */
+struct vmbus_channel_version_supported {
+       struct vmbus_channel_message_header header;
+       bool version_supported;
+} __packed;
+
+/* Offer Channel parameters */
+struct vmbus_channel_offer_channel {
+       struct vmbus_channel_message_header header;
+       struct vmbus_channel_offer offer;
+       u32 child_relid;
+       u8 monitorid;
+       bool monitor_allocated;
+} __packed;
+
+/* Rescind Offer parameters */
+struct vmbus_channel_rescind_offer {
+       struct vmbus_channel_message_header header;
+       u32 child_relid;
+} __packed;
+
+/*
+ * Request Offer -- no parameters, SynIC message contains the partition ID
+ * Set Snoop -- no parameters, SynIC message contains the partition ID
+ * Clear Snoop -- no parameters, SynIC message contains the partition ID
+ * All Offers Delivered -- no parameters, SynIC message contains the partition
+ *                        ID
+ * Flush Client -- no parameters, SynIC message contains the partition ID
+ */
+
+/* Open Channel parameters */
+struct vmbus_channel_open_channel {
+       struct vmbus_channel_message_header header;
+
+       /* Identifies the specific VMBus channel that is being opened. */
+       u32 child_relid;
+
+       /* ID making a particular open request at a channel offer unique. */
+       u32 openid;
+
+       /* GPADL for the channel's ring buffer. */
+       u32 ringbuffer_gpadlhandle;
+
+       /* GPADL for the channel's server context save area. */
+       u32 server_contextarea_gpadlhandle;
+
+       /*
+       * The upstream ring buffer begins at offset zero in the memory
+       * described by RingBufferGpadlHandle. The downstream ring buffer
+       * follows it at this offset (in pages).
+       */
+       u32 downstream_ringbuffer_pageoffset;
+
+       /* User-specific data to be passed along to the server endpoint. */
+       unsigned char userdata[MAX_USER_DEFINED_BYTES];
+} __packed;
+
+/* Open Channel Result parameters */
+struct vmbus_channel_open_result {
+       struct vmbus_channel_message_header header;
+       u32 child_relid;
+       u32 openid;
+       u32 status;
+} __packed;
+
+/* Close channel parameters; */
+struct vmbus_channel_close_channel {
+       struct vmbus_channel_message_header header;
+       u32 child_relid;
+} __packed;
+
+/* Channel Message GPADL */
+#define GPADL_TYPE_RING_BUFFER         1
+#define GPADL_TYPE_SERVER_SAVE_AREA    2
+#define GPADL_TYPE_TRANSACTION         8
+
+/*
+ * The number of PFNs in a GPADL message is defined by the number of
+ * pages that would be spanned by ByteCount and ByteOffset.  If the
+ * implied number of PFNs won't fit in this packet, there will be a
+ * follow-up packet that contains more.
+ */
+struct vmbus_channel_gpadl_header {
+       struct vmbus_channel_message_header header;
+       u32 child_relid;
+       u32 gpadl;
+       u16 range_buflen;
+       u16 rangecount;
+       struct gpa_range range[0];
+} __packed;
+
+/* This is the followup packet that contains more PFNs. */
+struct vmbus_channel_gpadl_body {
+       struct vmbus_channel_message_header header;
+       u32 msgnumber;
+       u32 gpadl;
+       u64 pfn[0];
+} __packed;
+
+struct vmbus_channel_gpadl_created {
+       struct vmbus_channel_message_header header;
+       u32 child_relid;
+       u32 gpadl;
+       u32 creation_status;
+} __packed;
+
+struct vmbus_channel_gpadl_teardown {
+       struct vmbus_channel_message_header header;
+       u32 child_relid;
+       u32 gpadl;
+} __packed;
+
+struct vmbus_channel_gpadl_torndown {
+       struct vmbus_channel_message_header header;
+       u32 gpadl;
+} __packed;
+
+#ifdef VMBUS_FEATURE_PARENT_OR_PEER_MEMORY_MAPPED_INTO_A_CHILD
+struct vmbus_channel_view_range_add {
+       struct vmbus_channel_message_header header;
+       PHYSICAL_ADDRESS viewrange_base;
+       u64 viewrange_length;
+       u32 child_relid;
+} __packed;
+
+struct vmbus_channel_view_range_remove {
+       struct vmbus_channel_message_header header;
+       PHYSICAL_ADDRESS viewrange_base;
+       u32 child_relid;
+} __packed;
+#endif
+
+struct vmbus_channel_relid_released {
+       struct vmbus_channel_message_header header;
+       u32 child_relid;
+} __packed;
+
+struct vmbus_channel_initiate_contact {
+       struct vmbus_channel_message_header header;
+       u32 vmbus_version_requested;
+       u32 padding2;
+       u64 interrupt_page;
+       u64 monitor_page1;
+       u64 monitor_page2;
+} __packed;
+
+struct vmbus_channel_version_response {
+       struct vmbus_channel_message_header header;
+       bool version_supported;
+} __packed;
+
+enum vmbus_channel_state {
+       CHANNEL_OFFER_STATE,
+       CHANNEL_OPENING_STATE,
+       CHANNEL_OPEN_STATE,
+};
+
+struct vmbus_channel {
+       struct list_head listentry;
+
+       struct hv_device *device_obj;
+
+       struct timer_list poll_timer; /* SA-111 workaround */
+       struct work_struct work;
+
+       enum vmbus_channel_state state;
+       /*
+        * For util channels, stash the
+        * the service index for easy access.
+        */
+       s8 util_index;
+
+       struct vmbus_channel_offer_channel offermsg;
+       /*
+        * These are based on the OfferMsg.MonitorId.
+        * Save it here for easy access.
+        */
+       u8 monitor_grp;
+       u8 monitor_bit;
+
+       u32 ringbuffer_gpadlhandle;
+
+       /* Allocated memory for ring buffer */
+       void *ringbuffer_pages;
+       u32 ringbuffer_pagecount;
+       struct hv_ring_buffer_info outbound;    /* send to parent */
+       struct hv_ring_buffer_info inbound;     /* receive from parent */
+       spinlock_t inbound_lock;
+       struct workqueue_struct *controlwq;
+
+       /* Channel callback are invoked in this workqueue context */
+       /* HANDLE dataWorkQueue; */
+
+       void (*onchannel_callback)(void *context);
+       void *channel_callback_context;
+};
+
+struct vmbus_channel_debug_info {
+       u32 relid;
+       enum vmbus_channel_state state;
+       struct hv_guid interfacetype;
+       struct hv_guid interface_instance;
+       u32 monitorid;
+       u32 servermonitor_pending;
+       u32 servermonitor_latency;
+       u32 servermonitor_connectionid;
+       u32 clientmonitor_pending;
+       u32 clientmonitor_latency;
+       u32 clientmonitor_connectionid;
+
+       struct hv_ring_buffer_debug_info inbound;
+       struct hv_ring_buffer_debug_info outbound;
+};
+
+/*
+ * Represents each channel msg on the vmbus connection This is a
+ * variable-size data structure depending on the msg type itself
+ */
+struct vmbus_channel_msginfo {
+       /* Bookkeeping stuff */
+       struct list_head msglistentry;
+
+       /* So far, this is only used to handle gpadl body message */
+       struct list_head submsglist;
+
+       /* Synchronize the request/response if needed */
+       struct completion  waitevent;
+       union {
+               struct vmbus_channel_version_supported version_supported;
+               struct vmbus_channel_open_result open_result;
+               struct vmbus_channel_gpadl_torndown gpadl_torndown;
+               struct vmbus_channel_gpadl_created gpadl_created;
+               struct vmbus_channel_version_response version_response;
+       } response;
+
+       u32 msgsize;
+       /*
+        * The channel message that goes out on the "wire".
+        * It will contain at minimum the VMBUS_CHANNEL_MESSAGE_HEADER header
+        */
+       unsigned char msg[0];
+};
+
+
+void free_channel(struct vmbus_channel *channel);
+
+void vmbus_onmessage(void *context);
+
+int vmbus_request_offers(void);
+
+/* The format must be the same as struct vmdata_gpa_direct */
+struct vmbus_channel_packet_page_buffer {
+       u16 type;
+       u16 dataoffset8;
+       u16 length8;
+       u16 flags;
+       u64 transactionid;
+       u32 reserved;
+       u32 rangecount;
+       struct hv_page_buffer range[MAX_PAGE_BUFFER_COUNT];
+} __packed;
+
+/* The format must be the same as struct vmdata_gpa_direct */
+struct vmbus_channel_packet_multipage_buffer {
+       u16 type;
+       u16 dataoffset8;
+       u16 length8;
+       u16 flags;
+       u64 transactionid;
+       u32 reserved;
+       u32 rangecount;         /* Always 1 in this case */
+       struct hv_multipage_buffer range;
+} __packed;
+
+
+extern int vmbus_open(struct vmbus_channel *channel,
+                           u32 send_ringbuffersize,
+                           u32 recv_ringbuffersize,
+                           void *userdata,
+                           u32 userdatalen,
+                           void(*onchannel_callback)(void *context),
+                           void *context);
+
+extern void vmbus_close(struct vmbus_channel *channel);
+
+extern int vmbus_sendpacket(struct vmbus_channel *channel,
+                                 const void *buffer,
+                                 u32 bufferLen,
+                                 u64 requestid,
+                                 enum vmbus_packet_type type,
+                                 u32 flags);
+
+extern int vmbus_sendpacket_pagebuffer(struct vmbus_channel *channel,
+                                           struct hv_page_buffer pagebuffers[],
+                                           u32 pagecount,
+                                           void *buffer,
+                                           u32 bufferlen,
+                                           u64 requestid);
+
+extern int vmbus_sendpacket_multipagebuffer(struct vmbus_channel *channel,
+                                       struct hv_multipage_buffer *mpb,
+                                       void *buffer,
+                                       u32 bufferlen,
+                                       u64 requestid);
+
+extern int vmbus_establish_gpadl(struct vmbus_channel *channel,
+                                     void *kbuffer,
+                                     u32 size,
+                                     u32 *gpadl_handle);
+
+extern int vmbus_teardown_gpadl(struct vmbus_channel *channel,
+                                    u32 gpadl_handle);
+
+extern int vmbus_recvpacket(struct vmbus_channel *channel,
+                                 void *buffer,
+                                 u32 bufferlen,
+                                 u32 *buffer_actual_len,
+                                 u64 *requestid);
+
+extern int vmbus_recvpacket_raw(struct vmbus_channel *channel,
+                                    void *buffer,
+                                    u32 bufferlen,
+                                    u32 *buffer_actual_len,
+                                    u64 *requestid);
+
+extern void vmbus_onchannel_event(struct vmbus_channel *channel);
+
+extern void vmbus_get_debug_info(struct vmbus_channel *channel,
+                                    struct vmbus_channel_debug_info *debug);
+
+extern void vmbus_ontimer(unsigned long data);
+
+
+#define LOWORD(dw) ((unsigned short)(dw))
+#define HIWORD(dw) ((unsigned short)(((unsigned int) (dw) >> 16) & 0xFFFF))
+
+
+#define VMBUS                          0x0001
+#define STORVSC                                0x0002
+#define NETVSC                         0x0004
+#define INPUTVSC                       0x0008
+#define BLKVSC                         0x0010
+#define VMBUS_DRV                      0x0100
+#define STORVSC_DRV                    0x0200
+#define NETVSC_DRV                     0x0400
+#define INPUTVSC_DRV           0x0800
+#define BLKVSC_DRV                     0x1000
+
+#define ALL_MODULES                    (VMBUS          |\
+                                                       STORVSC         |\
+                                                       NETVSC          |\
+                                                       INPUTVSC        |\
+                                                       BLKVSC          |\
+                                                       VMBUS_DRV       |\
+                                                       STORVSC_DRV     |\
+                                                       NETVSC_DRV      |\
+                                                       INPUTVSC_DRV|\
+                                                       BLKVSC_DRV)
+
+/* Logging Level */
+#define ERROR_LVL                              3
+#define WARNING_LVL                            4
+#define INFO_LVL                               6
+#define DEBUG_LVL                              7
+#define DEBUG_LVL_ENTEREXIT                    8
+#define DEBUG_RING_LVL                         9
+
+extern unsigned int vmbus_loglevel;
+
+#define DPRINT(mod, lvl, fmt, args...) do {\
+       if ((mod & (HIWORD(vmbus_loglevel))) && \
+           (lvl <= LOWORD(vmbus_loglevel)))    \
+               printk(KERN_DEBUG #mod": %s() " fmt "\n", __func__, ## args);\
+       } while (0)
+
+#define DPRINT_DBG(mod, fmt, args...) do {\
+       if ((mod & (HIWORD(vmbus_loglevel))) &&         \
+           (DEBUG_LVL <= LOWORD(vmbus_loglevel)))      \
+               printk(KERN_DEBUG #mod": %s() " fmt "\n", __func__, ## args);\
+       } while (0)
+
+#define DPRINT_INFO(mod, fmt, args...) do {\
+       if ((mod & (HIWORD(vmbus_loglevel))) &&         \
+           (INFO_LVL <= LOWORD(vmbus_loglevel)))       \
+               printk(KERN_INFO #mod": " fmt "\n", ## args);\
+       } while (0)
+
+#define DPRINT_WARN(mod, fmt, args...) do {\
+       if ((mod & (HIWORD(vmbus_loglevel))) &&         \
+           (WARNING_LVL <= LOWORD(vmbus_loglevel)))    \
+               printk(KERN_WARNING #mod": WARNING! " fmt "\n", ## args);\
+       } while (0)
+
+#define DPRINT_ERR(mod, fmt, args...) do {\
+       if ((mod & (HIWORD(vmbus_loglevel))) &&         \
+           (ERROR_LVL <= LOWORD(vmbus_loglevel)))      \
+               printk(KERN_ERR #mod": %s() ERROR!! " fmt "\n", \
+                      __func__, ## args);\
+       } while (0)
+
+
+
+struct hv_driver;
+struct hv_device;
+
+struct hv_dev_port_info {
+       u32 int_mask;
+       u32 read_idx;
+       u32 write_idx;
+       u32 bytes_avail_toread;
+       u32 bytes_avail_towrite;
+};
+
+struct hv_device_info {
+       u32 chn_id;
+       u32 chn_state;
+       struct hv_guid chn_type;
+       struct hv_guid chn_instance;
+
+       u32 monitor_id;
+       u32 server_monitor_pending;
+       u32 server_monitor_latency;
+       u32 server_monitor_conn_id;
+       u32 client_monitor_pending;
+       u32 client_monitor_latency;
+       u32 client_monitor_conn_id;
+
+       struct hv_dev_port_info inbound;
+       struct hv_dev_port_info outbound;
+};
+
+/* Base driver object */
+struct hv_driver {
+       const char *name;
+
+       /* the device type supported by this driver */
+       struct hv_guid dev_type;
+
+       struct device_driver driver;
+
+       int (*probe)(struct hv_device *);
+       int (*remove)(struct hv_device *);
+       void (*shutdown)(struct hv_device *);
+
+};
+
+/* Base device object */
+struct hv_device {
+       /* the device type id of this device */
+       struct hv_guid dev_type;
+
+       /* the device instance id of this device */
+       struct hv_guid dev_instance;
+
+       struct device device;
+
+       struct vmbus_channel *channel;
+
+       /* Device extension; */
+       void *ext;
+};
+
+
+static inline struct hv_device *device_to_hv_device(struct device *d)
+{
+       return container_of(d, struct hv_device, device);
+}
+
+static inline struct hv_driver *drv_to_hv_drv(struct device_driver *d)
+{
+       return container_of(d, struct hv_driver, driver);
+}
+
+
+/* Vmbus interface */
+int vmbus_child_driver_register(struct device_driver *drv);
+void vmbus_child_driver_unregister(struct device_driver *drv);
+
+/*
+ * Common header for Hyper-V ICs
+ */
+
+#define ICMSGTYPE_NEGOTIATE            0
+#define ICMSGTYPE_HEARTBEAT            1
+#define ICMSGTYPE_KVPEXCHANGE          2
+#define ICMSGTYPE_SHUTDOWN             3
+#define ICMSGTYPE_TIMESYNC             4
+#define ICMSGTYPE_VSS                  5
+
+#define ICMSGHDRFLAG_TRANSACTION       1
+#define ICMSGHDRFLAG_REQUEST           2
+#define ICMSGHDRFLAG_RESPONSE          4
+
+#define HV_S_OK                                0x00000000
+#define HV_E_FAIL                      0x80004005
+#define HV_ERROR_NOT_SUPPORTED         0x80070032
+#define HV_ERROR_MACHINE_LOCKED                0x800704F7
+
+struct vmbuspipe_hdr {
+       u32 flags;
+       u32 msgsize;
+} __packed;
+
+struct ic_version {
+       u16 major;
+       u16 minor;
+} __packed;
+
+struct icmsg_hdr {
+       struct ic_version icverframe;
+       u16 icmsgtype;
+       struct ic_version icvermsg;
+       u16 icmsgsize;
+       u32 status;
+       u8 ictransaction_id;
+       u8 icflags;
+       u8 reserved[2];
+} __packed;
+
+struct icmsg_negotiate {
+       u16 icframe_vercnt;
+       u16 icmsg_vercnt;
+       u32 reserved;
+       struct ic_version icversion_data[1]; /* any size array */
+} __packed;
+
+struct shutdown_msg_data {
+       u32 reason_code;
+       u32 timeout_seconds;
+       u32 flags;
+       u8  display_message[2048];
+} __packed;
+
+struct heartbeat_msg_data {
+       u64 seq_num;
+       u32 reserved[8];
+} __packed;
+
+/* Time Sync IC defs */
+#define ICTIMESYNCFLAG_PROBE   0
+#define ICTIMESYNCFLAG_SYNC    1
+#define ICTIMESYNCFLAG_SAMPLE  2
+
+#ifdef __x86_64__
+#define WLTIMEDELTA    116444736000000000L     /* in 100ns unit */
+#else
+#define WLTIMEDELTA    116444736000000000LL
+#endif
+
+struct ictimesync_data {
+       u64 parenttime;
+       u64 childtime;
+       u64 roundtriptime;
+       u8 flags;
+} __packed;
+
+/* Index for each IC struct in array hv_cb_utils[] */
+#define HV_SHUTDOWN_MSG                0
+#define HV_TIMESYNC_MSG                1
+#define HV_HEARTBEAT_MSG       2
+#define HV_KVP_MSG             3
+
+struct hyperv_service_callback {
+       u8 msg_type;
+       char *log_msg;
+       unsigned char data[16];
+       struct vmbus_channel *channel;
+       void (*callback) (void *context);
+};
+
+extern void prep_negotiate_resp(struct icmsg_hdr *,
+                               struct icmsg_negotiate *, u8 *);
+extern void chn_cb_negotiate(void *);
+extern struct hyperv_service_callback hv_cb_utils[];
+
+#endif /* _HYPERV_H */
similarity index 65%
rename from drivers/staging/hv/rndis.h
rename to drivers/staging/hv/hyperv_net.h
index 014de047b86dd6f7204fcd29b21eb6adba1a29c4..315097df799adcb1a36121928637076fb2adc31b 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *
- * Copyright (c) 2009, Microsoft Corporation.
+ * Copyright (c) 2011, Microsoft Corporation.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms and conditions of the GNU General Public License,
  * Authors:
  *   Haiyang Zhang <haiyangz@microsoft.com>
  *   Hank Janssen  <hjanssen@microsoft.com>
+ *   K. Y. Srinivasan <kys@microsoft.com>
  *
  */
 
-#ifndef _RNDIS_H_
-#define _RNDIS_H_
+#ifndef _HYPERV_NET_H
+#define _HYPERV_NET_H
+
+#include <linux/list.h>
+#include "hyperv.h"
+
+/* Fwd declaration */
+struct hv_netvsc_packet;
+
+/* Represent the xfer page packet which contains 1 or more netvsc packet */
+struct xferpage_packet {
+       struct list_head list_ent;
+
+       /* # of netvsc packets this xfer packet contains */
+       u32 count;
+};
+
+/* The number of pages which are enough to cover jumbo frame buffer. */
+#define NETVSC_PACKET_MAXPAGE          4
+
+/*
+ * Represent netvsc packet which contains 1 RNDIS and 1 ethernet frame
+ * within the RNDIS
+ */
+struct hv_netvsc_packet {
+       /* Bookkeeping stuff */
+       struct list_head list_ent;
+
+       struct hv_device *device;
+       bool is_data_pkt;
+
+       /*
+        * Valid only for receives when we break a xfer page packet
+        * into multiple netvsc packets
+        */
+       struct xferpage_packet *xfer_page_pkt;
+
+       union {
+               struct {
+                       u64 recv_completion_tid;
+                       void *recv_completion_ctx;
+                       void (*recv_completion)(void *context);
+               } recv;
+               struct {
+                       u64 send_completion_tid;
+                       void *send_completion_ctx;
+                       void (*send_completion)(void *context);
+               } send;
+       } completion;
+
+       /* This points to the memory after page_buf */
+       void *extension;
+
+       u32 total_data_buflen;
+       /* Points to the send/receive buffer where the ethernet frame is */
+       u32 page_buf_cnt;
+       struct hv_page_buffer page_buf[NETVSC_PACKET_MAXPAGE];
+};
+
+struct netvsc_device_info {
+       unsigned char mac_adr[6];
+       bool link_state;        /* 0 - link up, 1 - link down */
+       int  ring_size;
+};
+
+/* Interface */
+int netvsc_device_add(struct hv_device *device, void *additional_info);
+int netvsc_device_remove(struct hv_device *device);
+int netvsc_send(struct hv_device *device,
+               struct hv_netvsc_packet *packet);
+void netvsc_linkstatus_callback(struct hv_device *device_obj,
+                               unsigned int status);
+int netvsc_recv_callback(struct hv_device *device_obj,
+                       struct hv_netvsc_packet *packet);
+int netvsc_initialize(struct hv_driver *drv);
+int rndis_filter_open(struct hv_device *dev);
+int rndis_filter_close(struct hv_device *dev);
+int rndis_filte_device_add(struct hv_device *dev,
+                       void *additional_info);
+int rndis_filter_device_remove(struct hv_device *dev);
+int rndis_filter_receive(struct hv_device *dev,
+                       struct hv_netvsc_packet *pkt);
+
+
+
+int rndis_filter_send(struct hv_device *dev,
+                       struct hv_netvsc_packet *pkt);
+
+#define NVSP_INVALID_PROTOCOL_VERSION  ((u32)0xFFFFFFFF)
+
+#define NVSP_PROTOCOL_VERSION_1                2
+#define NVSP_MIN_PROTOCOL_VERSION      NVSP_PROTOCOL_VERSION_1
+#define NVSP_MAX_PROTOCOL_VERSION      NVSP_PROTOCOL_VERSION_1
+
+enum {
+       NVSP_MSG_TYPE_NONE = 0,
+
+       /* Init Messages */
+       NVSP_MSG_TYPE_INIT                      = 1,
+       NVSP_MSG_TYPE_INIT_COMPLETE             = 2,
+
+       NVSP_VERSION_MSG_START                  = 100,
+
+       /* Version 1 Messages */
+       NVSP_MSG1_TYPE_SEND_NDIS_VER            = NVSP_VERSION_MSG_START,
+
+       NVSP_MSG1_TYPE_SEND_RECV_BUF,
+       NVSP_MSG1_TYPE_SEND_RECV_BUF_COMPLETE,
+       NVSP_MSG1_TYPE_REVOKE_RECV_BUF,
+
+       NVSP_MSG1_TYPE_SEND_SEND_BUF,
+       NVSP_MSG1_TYPE_SEND_SEND_BUF_COMPLETE,
+       NVSP_MSG1_TYPE_REVOKE_SEND_BUF,
+
+       NVSP_MSG1_TYPE_SEND_RNDIS_PKT,
+       NVSP_MSG1_TYPE_SEND_RNDIS_PKT_COMPLETE,
+
+       /*
+        * This should be set to the number of messages for the version with
+        * the maximum number of messages.
+        */
+       NVSP_NUM_MSG_PER_VERSION                = 9,
+};
+
+enum {
+       NVSP_STAT_NONE = 0,
+       NVSP_STAT_SUCCESS,
+       NVSP_STAT_FAIL,
+       NVSP_STAT_PROTOCOL_TOO_NEW,
+       NVSP_STAT_PROTOCOL_TOO_OLD,
+       NVSP_STAT_INVALID_RNDIS_PKT,
+       NVSP_STAT_BUSY,
+       NVSP_STAT_MAX,
+};
+
+struct nvsp_message_header {
+       u32 msg_type;
+};
+
+/* Init Messages */
+
+/*
+ * This message is used by the VSC to initialize the channel after the channels
+ * has been opened. This message should never include anything other then
+ * versioning (i.e. this message will be the same for ever).
+ */
+struct nvsp_message_init {
+       u32 min_protocol_ver;
+       u32 max_protocol_ver;
+} __packed;
+
+/*
+ * This message is used by the VSP to complete the initialization of the
+ * channel. This message should never include anything other then versioning
+ * (i.e. this message will be the same for ever).
+ */
+struct nvsp_message_init_complete {
+       u32 negotiated_protocol_ver;
+       u32 max_mdl_chain_len;
+       u32 status;
+} __packed;
+
+union nvsp_message_init_uber {
+       struct nvsp_message_init init;
+       struct nvsp_message_init_complete init_complete;
+} __packed;
+
+/* Version 1 Messages */
+
+/*
+ * This message is used by the VSC to send the NDIS version to the VSP. The VSP
+ * can use this information when handling OIDs sent by the VSC.
+ */
+struct nvsp_1_message_send_ndis_version {
+       u32 ndis_major_ver;
+       u32 ndis_minor_ver;
+} __packed;
+
+/*
+ * This message is used by the VSC to send a receive buffer to the VSP. The VSP
+ * can then use the receive buffer to send data to the VSC.
+ */
+struct nvsp_1_message_send_receive_buffer {
+       u32 gpadl_handle;
+       u16 id;
+} __packed;
+
+struct nvsp_1_receive_buffer_section {
+       u32 offset;
+       u32 sub_alloc_size;
+       u32 num_sub_allocs;
+       u32 end_offset;
+} __packed;
+
+/*
+ * This message is used by the VSP to acknowledge a receive buffer send by the
+ * VSC. This message must be sent by the VSP before the VSP uses the receive
+ * buffer.
+ */
+struct nvsp_1_message_send_receive_buffer_complete {
+       u32 status;
+       u32 num_sections;
+
+       /*
+        * The receive buffer is split into two parts, a large suballocation
+        * section and a small suballocation section. These sections are then
+        * suballocated by a certain size.
+        */
+
+       /*
+        * For example, the following break up of the receive buffer has 6
+        * large suballocations and 10 small suballocations.
+        */
+
+       /*
+        * |            Large Section          |  |   Small Section   |
+        * ------------------------------------------------------------
+        * |     |     |     |     |     |     |  | | | | | | | | | | |
+        * |                                      |
+        *  LargeOffset                            SmallOffset
+        */
+
+       struct nvsp_1_receive_buffer_section sections[1];
+} __packed;
+
+/*
+ * This message is sent by the VSC to revoke the receive buffer.  After the VSP
+ * completes this transaction, the vsp should never use the receive buffer
+ * again.
+ */
+struct nvsp_1_message_revoke_receive_buffer {
+       u16 id;
+};
+
+/*
+ * This message is used by the VSC to send a send buffer to the VSP. The VSC
+ * can then use the send buffer to send data to the VSP.
+ */
+struct nvsp_1_message_send_send_buffer {
+       u32 gpadl_handle;
+       u16 id;
+} __packed;
+
+/*
+ * This message is used by the VSP to acknowledge a send buffer sent by the
+ * VSC. This message must be sent by the VSP before the VSP uses the sent
+ * buffer.
+ */
+struct nvsp_1_message_send_send_buffer_complete {
+       u32 status;
+
+       /*
+        * The VSC gets to choose the size of the send buffer and the VSP gets
+        * to choose the sections size of the buffer.  This was done to enable
+        * dynamic reconfigurations when the cost of GPA-direct buffers
+        * decreases.
+        */
+       u32 section_size;
+} __packed;
+
+/*
+ * This message is sent by the VSC to revoke the send buffer.  After the VSP
+ * completes this transaction, the vsp should never use the send buffer again.
+ */
+struct nvsp_1_message_revoke_send_buffer {
+       u16 id;
+};
+
+/*
+ * This message is used by both the VSP and the VSC to send a RNDIS message to
+ * the opposite channel endpoint.
+ */
+struct nvsp_1_message_send_rndis_packet {
+       /*
+        * This field is specified by RNIDS. They assume there's two different
+        * channels of communication. However, the Network VSP only has one.
+        * Therefore, the channel travels with the RNDIS packet.
+        */
+       u32 channel_type;
+
+       /*
+        * This field is used to send part or all of the data through a send
+        * buffer. This values specifies an index into the send buffer. If the
+        * index is 0xFFFFFFFF, then the send buffer is not being used and all
+        * of the data was sent through other VMBus mechanisms.
+        */
+       u32 send_buf_section_index;
+       u32 send_buf_section_size;
+} __packed;
+
+/*
+ * This message is used by both the VSP and the VSC to complete a RNDIS message
+ * to the opposite channel endpoint. At this point, the initiator of this
+ * message cannot use any resources associated with the original RNDIS packet.
+ */
+struct nvsp_1_message_send_rndis_packet_complete {
+       u32 status;
+};
+
+union nvsp_1_message_uber {
+       struct nvsp_1_message_send_ndis_version send_ndis_ver;
+
+       struct nvsp_1_message_send_receive_buffer send_recv_buf;
+       struct nvsp_1_message_send_receive_buffer_complete
+                                               send_recv_buf_complete;
+       struct nvsp_1_message_revoke_receive_buffer revoke_recv_buf;
+
+       struct nvsp_1_message_send_send_buffer send_send_buf;
+       struct nvsp_1_message_send_send_buffer_complete send_send_buf_complete;
+       struct nvsp_1_message_revoke_send_buffer revoke_send_buf;
+
+       struct nvsp_1_message_send_rndis_packet send_rndis_pkt;
+       struct nvsp_1_message_send_rndis_packet_complete
+                                               send_rndis_pkt_complete;
+} __packed;
+
+union nvsp_all_messages {
+       union nvsp_message_init_uber init_msg;
+       union nvsp_1_message_uber v1_msg;
+} __packed;
+
+/* ALL Messages */
+struct nvsp_message {
+       struct nvsp_message_header hdr;
+       union nvsp_all_messages msg;
+} __packed;
+
+
+
+
+/* #define NVSC_MIN_PROTOCOL_VERSION           1 */
+/* #define NVSC_MAX_PROTOCOL_VERSION           1 */
+
+#define NETVSC_SEND_BUFFER_SIZE                        (64*1024)       /* 64K */
+#define NETVSC_SEND_BUFFER_ID                  0xface
+
+
+#define NETVSC_RECEIVE_BUFFER_SIZE             (1024*1024)     /* 1MB */
+
+#define NETVSC_RECEIVE_BUFFER_ID               0xcafe
+
+#define NETVSC_RECEIVE_SG_COUNT                        1
+
+/* Preallocated receive packets */
+#define NETVSC_RECEIVE_PACKETLIST_COUNT                256
+
+#define NETVSC_PACKET_SIZE                      2048
+
+/* Per netvsc channel-specific */
+struct netvsc_device {
+       struct hv_device *dev;
+
+       atomic_t refcnt;
+       atomic_t num_outstanding_sends;
+       /*
+        * List of free preallocated hv_netvsc_packet to represent receive
+        * packet
+        */
+       struct list_head recv_pkt_list;
+       spinlock_t recv_pkt_list_lock;
+
+       /* Send buffer allocated by us but manages by NetVSP */
+       void *send_buf;
+       u32 send_buf_size;
+       u32 send_buf_gpadl_handle;
+       u32 send_section_size;
+
+       /* Receive buffer allocated by us but manages by NetVSP */
+       void *recv_buf;
+       u32 recv_buf_size;
+       u32 recv_buf_gpadl_handle;
+       u32 recv_section_cnt;
+       struct nvsp_1_receive_buffer_section *recv_section;
+
+       /* Used for NetVSP initialization protocol */
+       struct completion channel_init_wait;
+       struct nvsp_message channel_init_pkt;
+
+       struct nvsp_message revoke_packet;
+       /* unsigned char HwMacAddr[HW_MACADDR_LEN]; */
+
+       /* Holds rndis device info */
+       void *extension;
+};
+
 
 /*  Status codes */
 
@@ -618,6 +1002,13 @@ struct rndis_message {
        union rndis_message_container msg;
 };
 
+
+struct rndis_filter_packet {
+       void *completion_ctx;
+       void (*completion)(void *context);
+       struct rndis_message msg;
+};
+
 /* Handy macros */
 
 /* get the size of an RNDIS message. Pass in the message type, */
@@ -650,4 +1041,27 @@ struct rndis_message {
 #define RNDIS_MESSAGE_RAW_PTR_TO_MESSAGE_PTR(rndis_msg)        \
        ((void *) rndis_msg)
 
-#endif /* _RNDIS_H_ */
+
+#define __struct_bcount(x)
+
+
+
+#define RNDIS_HEADER_SIZE      (sizeof(struct rndis_message) - \
+                                sizeof(union rndis_message_container))
+
+#define NDIS_PACKET_TYPE_DIRECTED      0x00000001
+#define NDIS_PACKET_TYPE_MULTICAST     0x00000002
+#define NDIS_PACKET_TYPE_ALL_MULTICAST 0x00000004
+#define NDIS_PACKET_TYPE_BROADCAST     0x00000008
+#define NDIS_PACKET_TYPE_SOURCE_ROUTING        0x00000010
+#define NDIS_PACKET_TYPE_PROMISCUOUS   0x00000020
+#define NDIS_PACKET_TYPE_SMT           0x00000040
+#define NDIS_PACKET_TYPE_ALL_LOCAL     0x00000080
+#define NDIS_PACKET_TYPE_GROUP         0x00000100
+#define NDIS_PACKET_TYPE_ALL_FUNCTIONAL        0x00000200
+#define NDIS_PACKET_TYPE_FUNCTIONAL    0x00000400
+#define NDIS_PACKET_TYPE_MAC_FRAME     0x00000800
+
+
+
+#endif /* _HYPERV_NET_H */
similarity index 63%
rename from drivers/staging/hv/vstorage.h
rename to drivers/staging/hv/hyperv_storage.h
index ebb4d671c424206da9583b9513bb0b65c4c3a459..a01f9a07c988961c0389eb60ffb794a0ce87743f 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *
- * Copyright (c) 2009, Microsoft Corporation.
+ * Copyright (c) 2011, Microsoft Corporation.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms and conditions of the GNU General Public License,
  * Authors:
  *   Haiyang Zhang <haiyangz@microsoft.com>
  *   Hank Janssen  <hjanssen@microsoft.com>
+ *   K. Y. Srinivasan <kys@microsoft.com>
  *
  */
 
+#ifndef _HYPERV_STORAGE_H
+#define _HYPERV_STORAGE_H
+
+
 /* vstorage.w revision number.  This is used in the case of a version match, */
 /* to alert the user that structure sizes may be mismatched even though the */
 /* protocol versions match. */
 
+
 #define REVISION_STRING(REVISION_) #REVISION_
 #define FILL_VMSTOR_REVISION(RESULT_LVALUE_)                           \
        do {                                                            \
@@ -190,3 +196,139 @@ struct vstor_packet {
 
 /*  This is the set of flags that the vsc can set in any packets it sends */
 #define VSC_LEGAL_FLAGS                (REQUEST_COMPLETION_FLAG)
+
+
+#include <linux/kernel.h>
+#include <linux/wait.h>
+#include "hyperv_storage.h"
+#include "hyperv.h"
+
+/* Defines */
+#define STORVSC_RING_BUFFER_SIZE                       (20*PAGE_SIZE)
+#define BLKVSC_RING_BUFFER_SIZE                                (20*PAGE_SIZE)
+
+#define STORVSC_MAX_IO_REQUESTS                                128
+
+/*
+ * In Hyper-V, each port/path/target maps to 1 scsi host adapter.  In
+ * reality, the path/target is not used (ie always set to 0) so our
+ * scsi host adapter essentially has 1 bus with 1 target that contains
+ * up to 256 luns.
+ */
+#define STORVSC_MAX_LUNS_PER_TARGET                    64
+#define STORVSC_MAX_TARGETS                            1
+#define STORVSC_MAX_CHANNELS                           1
+
+struct hv_storvsc_request;
+
+/* Matches Windows-end */
+enum storvsc_request_type {
+       WRITE_TYPE,
+       READ_TYPE,
+       UNKNOWN_TYPE,
+};
+
+
+struct hv_storvsc_request {
+       struct hv_storvsc_request *request;
+       struct hv_device *device;
+
+       /* Synchronize the request/response if needed */
+       struct completion wait_event;
+
+       unsigned char *sense_buffer;
+       void *context;
+       void (*on_io_completion)(struct hv_storvsc_request *request);
+       struct hv_multipage_buffer data_buffer;
+
+       struct vstor_packet vstor_packet;
+};
+
+
+struct storvsc_device_info {
+       u32 ring_buffer_size;
+       unsigned int port_number;
+       unsigned char path_id;
+       unsigned char target_id;
+};
+
+struct storvsc_major_info {
+       int major;
+       int index;
+       bool do_register;
+       char *devname;
+       char *diskname;
+};
+
+/* A storvsc device is a device object that contains a vmbus channel */
+struct storvsc_device {
+       struct hv_device *device;
+
+       /* 0 indicates the device is being destroyed */
+       atomic_t ref_count;
+
+       bool     drain_notify;
+       atomic_t num_outstanding_req;
+
+       wait_queue_head_t waiting_to_drain;
+
+       /*
+        * Each unique Port/Path/Target represents 1 channel ie scsi
+        * controller. In reality, the pathid, targetid is always 0
+        * and the port is set by us
+        */
+       unsigned int port_number;
+       unsigned char path_id;
+       unsigned char target_id;
+
+       /* Used for vsc/vsp channel reset process */
+       struct hv_storvsc_request init_request;
+       struct hv_storvsc_request reset_request;
+};
+
+
+/* Get the stordevice object iff exists and its refcount > 1 */
+static inline struct storvsc_device *get_stor_device(struct hv_device *device)
+{
+       struct storvsc_device *stor_device;
+
+       stor_device = (struct storvsc_device *)device->ext;
+       if (stor_device && atomic_read(&stor_device->ref_count) > 1)
+               atomic_inc(&stor_device->ref_count);
+       else
+               stor_device = NULL;
+
+       return stor_device;
+}
+
+
+static inline void put_stor_device(struct hv_device *device)
+{
+       struct storvsc_device *stor_device;
+
+       stor_device = (struct storvsc_device *)device->ext;
+
+       atomic_dec(&stor_device->ref_count);
+}
+
+static inline void storvsc_wait_to_drain(struct storvsc_device *dev)
+{
+       dev->drain_notify = true;
+       wait_event(dev->waiting_to_drain,
+                  atomic_read(&dev->num_outstanding_req) == 0);
+       dev->drain_notify = false;
+}
+
+/* Interface */
+
+int storvsc_dev_add(struct hv_device *device,
+                               void *additional_info);
+int storvsc_dev_remove(struct hv_device *device);
+
+int storvsc_do_io(struct hv_device *device,
+                               struct hv_storvsc_request *request);
+
+int storvsc_get_major_info(struct storvsc_device_info *device_info,
+                               struct storvsc_major_info *major_info);
+
+#endif /* _HYPERV_STORAGE_H */
diff --git a/drivers/staging/hv/hyperv_vmbus.h b/drivers/staging/hv/hyperv_vmbus.h
new file mode 100644 (file)
index 0000000..bf30a42
--- /dev/null
@@ -0,0 +1,631 @@
+/*
+ *
+ * Copyright (c) 2011, Microsoft Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place - Suite 330, Boston, MA 02111-1307 USA.
+ *
+ * Authors:
+ *   Haiyang Zhang <haiyangz@microsoft.com>
+ *   Hank Janssen  <hjanssen@microsoft.com>
+ *   K. Y. Srinivasan <kys@microsoft.com>
+ *
+ */
+
+#ifndef _HYPERV_VMBUS_H
+#define _HYPERV_VMBUS_H
+
+#include <linux/list.h>
+#include <asm/sync_bitops.h>
+#include <linux/atomic.h>
+
+#include "hyperv.h"
+
+/*
+ * The below CPUID leaves are present if VersionAndFeatures.HypervisorPresent
+ * is set by CPUID(HVCPUID_VERSION_FEATURES).
+ */
+enum hv_cpuid_function {
+       HVCPUID_VERSION_FEATURES                = 0x00000001,
+       HVCPUID_VENDOR_MAXFUNCTION              = 0x40000000,
+       HVCPUID_INTERFACE                       = 0x40000001,
+
+       /*
+        * The remaining functions depend on the value of
+        * HVCPUID_INTERFACE
+        */
+       HVCPUID_VERSION                 = 0x40000002,
+       HVCPUID_FEATURES                        = 0x40000003,
+       HVCPUID_ENLIGHTENMENT_INFO      = 0x40000004,
+       HVCPUID_IMPLEMENTATION_LIMITS           = 0x40000005,
+};
+
+/* Define version of the synthetic interrupt controller. */
+#define HV_SYNIC_VERSION               (1)
+
+/* Define the expected SynIC version. */
+#define HV_SYNIC_VERSION_1             (0x1)
+
+/* Define synthetic interrupt controller message constants. */
+#define HV_MESSAGE_SIZE                        (256)
+#define HV_MESSAGE_PAYLOAD_BYTE_COUNT  (240)
+#define HV_MESSAGE_PAYLOAD_QWORD_COUNT (30)
+#define HV_ANY_VP                      (0xFFFFFFFF)
+
+/* Define synthetic interrupt controller flag constants. */
+#define HV_EVENT_FLAGS_COUNT           (256 * 8)
+#define HV_EVENT_FLAGS_BYTE_COUNT      (256)
+#define HV_EVENT_FLAGS_DWORD_COUNT     (256 / sizeof(u32))
+
+/* Define hypervisor message types. */
+enum hv_message_type {
+       HVMSG_NONE                      = 0x00000000,
+
+       /* Memory access messages. */
+       HVMSG_UNMAPPED_GPA              = 0x80000000,
+       HVMSG_GPA_INTERCEPT             = 0x80000001,
+
+       /* Timer notification messages. */
+       HVMSG_TIMER_EXPIRED                     = 0x80000010,
+
+       /* Error messages. */
+       HVMSG_INVALID_VP_REGISTER_VALUE = 0x80000020,
+       HVMSG_UNRECOVERABLE_EXCEPTION   = 0x80000021,
+       HVMSG_UNSUPPORTED_FEATURE               = 0x80000022,
+
+       /* Trace buffer complete messages. */
+       HVMSG_EVENTLOG_BUFFERCOMPLETE   = 0x80000040,
+
+       /* Platform-specific processor intercept messages. */
+       HVMSG_X64_IOPORT_INTERCEPT              = 0x80010000,
+       HVMSG_X64_MSR_INTERCEPT         = 0x80010001,
+       HVMSG_X64_CPUID_INTERCEPT               = 0x80010002,
+       HVMSG_X64_EXCEPTION_INTERCEPT   = 0x80010003,
+       HVMSG_X64_APIC_EOI                      = 0x80010004,
+       HVMSG_X64_LEGACY_FP_ERROR               = 0x80010005
+};
+
+/* Define the number of synthetic interrupt sources. */
+#define HV_SYNIC_SINT_COUNT            (16)
+#define HV_SYNIC_STIMER_COUNT          (4)
+
+/* Define invalid partition identifier. */
+#define HV_PARTITION_ID_INVALID                ((u64)0x0)
+
+/* Define connection identifier type. */
+union hv_connection_id {
+       u32 asu32;
+       struct {
+               u32 id:24;
+               u32 reserved:8;
+       } u;
+};
+
+/* Define port identifier type. */
+union hv_port_id {
+       u32 asu32;
+       struct {
+               u32 id:24;
+               u32 reserved:8;
+       } u ;
+};
+
+/* Define port type. */
+enum hv_port_type {
+       HVPORT_MSG      = 1,
+       HVPORT_EVENT            = 2,
+       HVPORT_MONITOR  = 3
+};
+
+/* Define port information structure. */
+struct hv_port_info {
+       enum hv_port_type port_type;
+       u32 padding;
+       union {
+               struct {
+                       u32 target_sint;
+                       u32 target_vp;
+                       u64 rsvdz;
+               } message_port_info;
+               struct {
+                       u32 target_sint;
+                       u32 target_vp;
+                       u16 base_flag_bumber;
+                       u16 flag_count;
+                       u32 rsvdz;
+               } event_port_info;
+               struct {
+                       u64 monitor_address;
+                       u64 rsvdz;
+               } monitor_port_info;
+       };
+};
+
+struct hv_connection_info {
+       enum hv_port_type port_type;
+       u32 padding;
+       union {
+               struct {
+                       u64 rsvdz;
+               } message_connection_info;
+               struct {
+                       u64 rsvdz;
+               } event_connection_info;
+               struct {
+                       u64 monitor_address;
+               } monitor_connection_info;
+       };
+};
+
+/* Define synthetic interrupt controller message flags. */
+union hv_message_flags {
+       u8 asu8;
+       struct {
+               u8 msg_pending:1;
+               u8 reserved:7;
+       };
+};
+
+/* Define synthetic interrupt controller message header. */
+struct hv_message_header {
+       enum hv_message_type message_type;
+       u8 payload_size;
+       union hv_message_flags message_flags;
+       u8 reserved[2];
+       union {
+               u64 sender;
+               union hv_port_id port;
+       };
+};
+
+/* Define timer message payload structure. */
+struct hv_timer_message_payload {
+       u32 timer_index;
+       u32 reserved;
+       u64 expiration_time;    /* When the timer expired */
+       u64 delivery_time;      /* When the message was delivered */
+};
+
+/* Define synthetic interrupt controller message format. */
+struct hv_message {
+       struct hv_message_header header;
+       union {
+               u64 payload[HV_MESSAGE_PAYLOAD_QWORD_COUNT];
+       } u ;
+};
+
+/* Define the number of message buffers associated with each port. */
+#define HV_PORT_MESSAGE_BUFFER_COUNT   (16)
+
+/* Define the synthetic interrupt message page layout. */
+struct hv_message_page {
+       struct hv_message sint_message[HV_SYNIC_SINT_COUNT];
+};
+
+/* Define the synthetic interrupt controller event flags format. */
+union hv_synic_event_flags {
+       u8 flags8[HV_EVENT_FLAGS_BYTE_COUNT];
+       u32 flags32[HV_EVENT_FLAGS_DWORD_COUNT];
+};
+
+/* Define the synthetic interrupt flags page layout. */
+struct hv_synic_event_flags_page {
+       union hv_synic_event_flags sintevent_flags[HV_SYNIC_SINT_COUNT];
+};
+
+/* Define SynIC control register. */
+union hv_synic_scontrol {
+       u64 as_uint64;
+       struct {
+               u64 enable:1;
+               u64 reserved:63;
+       };
+};
+
+/* Define synthetic interrupt source. */
+union hv_synic_sint {
+       u64 as_uint64;
+       struct {
+               u64 vector:8;
+               u64 reserved1:8;
+               u64 masked:1;
+               u64 auto_eoi:1;
+               u64 reserved2:46;
+       };
+};
+
+/* Define the format of the SIMP register */
+union hv_synic_simp {
+       u64 as_uint64;
+       struct {
+               u64 simp_enabled:1;
+               u64 preserved:11;
+               u64 base_simp_gpa:52;
+       };
+};
+
+/* Define the format of the SIEFP register */
+union hv_synic_siefp {
+       u64 as_uint64;
+       struct {
+               u64 siefp_enabled:1;
+               u64 preserved:11;
+               u64 base_siefp_gpa:52;
+       };
+};
+
+/* Definitions for the monitored notification facility */
+union hv_monitor_trigger_group {
+       u64 as_uint64;
+       struct {
+               u32 pending;
+               u32 armed;
+       };
+};
+
+struct hv_monitor_parameter {
+       union hv_connection_id connectionid;
+       u16 flagnumber;
+       u16 rsvdz;
+};
+
+union hv_monitor_trigger_state {
+       u32 asu32;
+
+       struct {
+               u32 group_enable:4;
+               u32 rsvdz:28;
+       };
+};
+
+/* struct hv_monitor_page Layout */
+/* ------------------------------------------------------ */
+/* | 0   | TriggerState (4 bytes) | Rsvd1 (4 bytes)     | */
+/* | 8   | TriggerGroup[0]                              | */
+/* | 10  | TriggerGroup[1]                              | */
+/* | 18  | TriggerGroup[2]                              | */
+/* | 20  | TriggerGroup[3]                              | */
+/* | 28  | Rsvd2[0]                                     | */
+/* | 30  | Rsvd2[1]                                     | */
+/* | 38  | Rsvd2[2]                                     | */
+/* | 40  | NextCheckTime[0][0]    | NextCheckTime[0][1] | */
+/* | ...                                                | */
+/* | 240 | Latency[0][0..3]                             | */
+/* | 340 | Rsvz3[0]                                     | */
+/* | 440 | Parameter[0][0]                              | */
+/* | 448 | Parameter[0][1]                              | */
+/* | ...                                                | */
+/* | 840 | Rsvd4[0]                                     | */
+/* ------------------------------------------------------ */
+struct hv_monitor_page {
+       union hv_monitor_trigger_state trigger_state;
+       u32 rsvdz1;
+
+       union hv_monitor_trigger_group trigger_group[4];
+       u64 rsvdz2[3];
+
+       s32 next_checktime[4][32];
+
+       u16 latency[4][32];
+       u64 rsvdz3[32];
+
+       struct hv_monitor_parameter parameter[4][32];
+
+       u8 rsvdz4[1984];
+};
+
+/* Declare the various hypercall operations. */
+enum hv_call_code {
+       HVCALL_POST_MESSAGE     = 0x005c,
+       HVCALL_SIGNAL_EVENT     = 0x005d,
+};
+
+/* Definition of the hv_post_message hypercall input structure. */
+struct hv_input_post_message {
+       union hv_connection_id connectionid;
+       u32 reserved;
+       enum hv_message_type message_type;
+       u32 payload_size;
+       u64 payload[HV_MESSAGE_PAYLOAD_QWORD_COUNT];
+};
+
+/* Definition of the hv_signal_event hypercall input structure. */
+struct hv_input_signal_event {
+       union hv_connection_id connectionid;
+       u16 flag_number;
+       u16 rsvdz;
+};
+
+/*
+ * Versioning definitions used for guests reporting themselves to the
+ * hypervisor, and visa versa.
+ */
+
+/* Version info reported by guest OS's */
+enum hv_guest_os_vendor {
+       HVGUESTOS_VENDOR_MICROSOFT      = 0x0001
+};
+
+enum hv_guest_os_microsoft_ids {
+       HVGUESTOS_MICROSOFT_UNDEFINED   = 0x00,
+       HVGUESTOS_MICROSOFT_MSDOS               = 0x01,
+       HVGUESTOS_MICROSOFT_WINDOWS3X   = 0x02,
+       HVGUESTOS_MICROSOFT_WINDOWS9X   = 0x03,
+       HVGUESTOS_MICROSOFT_WINDOWSNT   = 0x04,
+       HVGUESTOS_MICROSOFT_WINDOWSCE   = 0x05
+};
+
+/*
+ * Declare the MSR used to identify the guest OS.
+ */
+#define HV_X64_MSR_GUEST_OS_ID 0x40000000
+
+union hv_x64_msr_guest_os_id_contents {
+       u64 as_uint64;
+       struct {
+               u64 build_number:16;
+               u64 service_version:8; /* Service Pack, etc. */
+               u64 minor_version:8;
+               u64 major_version:8;
+               u64 os_id:8; /* enum hv_guest_os_microsoft_ids (if Vendor=MS) */
+               u64 vendor_id:16; /* enum hv_guest_os_vendor */
+       };
+};
+
+/*
+ * Declare the MSR used to setup pages used to communicate with the hypervisor.
+ */
+#define HV_X64_MSR_HYPERCALL   0x40000001
+
+union hv_x64_msr_hypercall_contents {
+       u64 as_uint64;
+       struct {
+               u64 enable:1;
+               u64 reserved:11;
+               u64 guest_physical_address:52;
+       };
+};
+
+
+enum {
+       VMBUS_MESSAGE_CONNECTION_ID     = 1,
+       VMBUS_MESSAGE_PORT_ID           = 1,
+       VMBUS_EVENT_CONNECTION_ID       = 2,
+       VMBUS_EVENT_PORT_ID             = 2,
+       VMBUS_MONITOR_CONNECTION_ID     = 3,
+       VMBUS_MONITOR_PORT_ID           = 3,
+       VMBUS_MESSAGE_SINT              = 2,
+};
+
+/* #defines */
+
+#define HV_PRESENT_BIT                 0x80000000
+
+#define HV_LINUX_GUEST_ID_LO           0x00000000
+#define HV_LINUX_GUEST_ID_HI           0xB16B00B5
+#define HV_LINUX_GUEST_ID              (((u64)HV_LINUX_GUEST_ID_HI << 32) | \
+                                          HV_LINUX_GUEST_ID_LO)
+
+#define HV_CPU_POWER_MANAGEMENT                (1 << 0)
+#define HV_RECOMMENDATIONS_MAX         4
+
+#define HV_X64_MAX                     5
+#define HV_CAPS_MAX                    8
+
+
+#define HV_HYPERCALL_PARAM_ALIGN       sizeof(u64)
+
+
+/* Service definitions */
+
+#define HV_SERVICE_PARENT_PORT                         (0)
+#define HV_SERVICE_PARENT_CONNECTION                   (0)
+
+#define HV_SERVICE_CONNECT_RESPONSE_SUCCESS            (0)
+#define HV_SERVICE_CONNECT_RESPONSE_INVALID_PARAMETER  (1)
+#define HV_SERVICE_CONNECT_RESPONSE_UNKNOWN_SERVICE    (2)
+#define HV_SERVICE_CONNECT_RESPONSE_CONNECTION_REJECTED        (3)
+
+#define HV_SERVICE_CONNECT_REQUEST_MESSAGE_ID          (1)
+#define HV_SERVICE_CONNECT_RESPONSE_MESSAGE_ID         (2)
+#define HV_SERVICE_DISCONNECT_REQUEST_MESSAGE_ID       (3)
+#define HV_SERVICE_DISCONNECT_RESPONSE_MESSAGE_ID      (4)
+#define HV_SERVICE_MAX_MESSAGE_ID                              (4)
+
+#define HV_SERVICE_PROTOCOL_VERSION (0x0010)
+#define HV_CONNECT_PAYLOAD_BYTE_COUNT 64
+
+/* #define VMBUS_REVISION_NUMBER       6 */
+
+/* Our local vmbus's port and connection id. Anything >0 is fine */
+/* #define VMBUS_PORT_ID               11 */
+
+/* 628180B8-308D-4c5e-B7DB-1BEB62E62EF4 */
+static const struct hv_guid VMBUS_SERVICE_ID = {
+       .data = {
+               0xb8, 0x80, 0x81, 0x62, 0x8d, 0x30, 0x5e, 0x4c,
+               0xb7, 0xdb, 0x1b, 0xeb, 0x62, 0xe6, 0x2e, 0xf4
+       },
+};
+
+#define MAX_NUM_CPUS   32
+
+
+struct hv_input_signal_event_buffer {
+       u64 align8;
+       struct hv_input_signal_event event;
+};
+
+struct hv_context {
+       /* We only support running on top of Hyper-V
+       * So at this point this really can only contain the Hyper-V ID
+       */
+       u64 guestid;
+
+       void *hypercall_page;
+
+       bool synic_initialized;
+
+       /*
+        * This is used as an input param to HvCallSignalEvent hypercall. The
+        * input param is immutable in our usage and must be dynamic mem (vs
+        * stack or global). */
+       struct hv_input_signal_event_buffer *signal_event_buffer;
+       /* 8-bytes aligned of the buffer above */
+       struct hv_input_signal_event *signal_event_param;
+
+       void *synic_message_page[MAX_NUM_CPUS];
+       void *synic_event_page[MAX_NUM_CPUS];
+};
+
+extern struct hv_context hv_context;
+
+
+/* Hv Interface */
+
+extern int hv_init(void);
+
+extern void hv_cleanup(void);
+
+extern u16 hv_post_message(union hv_connection_id connection_id,
+                        enum hv_message_type message_type,
+                        void *payload, size_t payload_size);
+
+extern u16 hv_signal_event(void);
+
+extern void hv_synic_init(void *irqarg);
+
+extern void hv_synic_cleanup(void *arg);
+
+
+/* Interface */
+
+
+int hv_ringbuffer_init(struct hv_ring_buffer_info *ring_info, void *buffer,
+                  u32 buflen);
+
+void hv_ringbuffer_cleanup(struct hv_ring_buffer_info *ring_info);
+
+int hv_ringbuffer_write(struct hv_ring_buffer_info *ring_info,
+                   struct scatterlist *sglist,
+                   u32 sgcount);
+
+int hv_ringbuffer_peek(struct hv_ring_buffer_info *ring_info, void *buffer,
+                  u32 buflen);
+
+int hv_ringbuffer_read(struct hv_ring_buffer_info *ring_info,
+                  void *buffer,
+                  u32 buflen,
+                  u32 offset);
+
+u32 hv_get_ringbuffer_interrupt_mask(struct hv_ring_buffer_info *ring_info);
+
+void hv_dump_ring_info(struct hv_ring_buffer_info *ring_info, char *prefix);
+
+void hv_ringbuffer_get_debuginfo(struct hv_ring_buffer_info *ring_info,
+                           struct hv_ring_buffer_debug_info *debug_info);
+
+/*
+ * Maximum channels is determined by the size of the interrupt page
+ * which is PAGE_SIZE. 1/2 of PAGE_SIZE is for send endpoint interrupt
+ * and the other is receive endpoint interrupt
+ */
+#define MAX_NUM_CHANNELS       ((PAGE_SIZE >> 1) << 3) /* 16348 channels */
+
+/* The value here must be in multiple of 32 */
+/* TODO: Need to make this configurable */
+#define MAX_NUM_CHANNELS_SUPPORTED     256
+
+
+enum vmbus_connect_state {
+       DISCONNECTED,
+       CONNECTING,
+       CONNECTED,
+       DISCONNECTING
+};
+
+#define MAX_SIZE_CHANNEL_MESSAGE       HV_MESSAGE_PAYLOAD_BYTE_COUNT
+
+struct vmbus_connection {
+       enum vmbus_connect_state conn_state;
+
+       atomic_t next_gpadl_handle;
+
+       /*
+        * Represents channel interrupts. Each bit position represents a
+        * channel.  When a channel sends an interrupt via VMBUS, it finds its
+        * bit in the sendInterruptPage, set it and calls Hv to generate a port
+        * event. The other end receives the port event and parse the
+        * recvInterruptPage to see which bit is set
+        */
+       void *int_page;
+       void *send_int_page;
+       void *recv_int_page;
+
+       /*
+        * 2 pages - 1st page for parent->child notification and 2nd
+        * is child->parent notification
+        */
+       void *monitor_pages;
+       struct list_head chn_msg_list;
+       spinlock_t channelmsg_lock;
+
+       /* List of channels */
+       struct list_head chn_list;
+       spinlock_t channel_lock;
+
+       struct workqueue_struct *work_queue;
+};
+
+
+struct vmbus_msginfo {
+       /* Bookkeeping stuff */
+       struct list_head msglist_entry;
+
+       /* The message itself */
+       unsigned char msg[0];
+};
+
+
+extern struct vmbus_connection vmbus_connection;
+
+/* General vmbus interface */
+
+struct hv_device *vmbus_child_device_create(struct hv_guid *type,
+                                        struct hv_guid *instance,
+                                        struct vmbus_channel *channel);
+
+int vmbus_child_device_register(struct hv_device *child_device_obj);
+void vmbus_child_device_unregister(struct hv_device *device_obj);
+
+/* static void */
+/* VmbusChildDeviceDestroy( */
+/* struct hv_device *); */
+
+struct vmbus_channel *relid2channel(u32 relid);
+
+
+/* Connection interface */
+
+int vmbus_connect(void);
+
+int vmbus_disconnect(void);
+
+int vmbus_post_msg(void *buffer, size_t buflen);
+
+int vmbus_set_event(u32 child_relid);
+
+void vmbus_on_event(unsigned long data);
+
+
+#endif /* _HYPERV_VMBUS_H */
diff --git a/drivers/staging/hv/logging.h b/drivers/staging/hv/logging.h
deleted file mode 100644 (file)
index 1799951..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- *
- * Copyright (c) 2009, Microsoft Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place - Suite 330, Boston, MA 02111-1307 USA.
- *
- * Authors:
- *   Haiyang Zhang <haiyangz@microsoft.com>
- *   Hank Janssen  <hjanssen@microsoft.com>
- *
- */
-
-
-#ifndef _LOGGING_H_
-#define _LOGGING_H_
-
-#define LOWORD(dw) ((unsigned short)(dw))
-#define HIWORD(dw) ((unsigned short)(((unsigned int) (dw) >> 16) & 0xFFFF))
-
-/* #include <linux/init.h> */
-/* #include <linux/module.h> */
-
-
-#define VMBUS                          0x0001
-#define STORVSC                                0x0002
-#define NETVSC                         0x0004
-#define INPUTVSC                       0x0008
-#define BLKVSC                         0x0010
-#define VMBUS_DRV                      0x0100
-#define STORVSC_DRV                    0x0200
-#define NETVSC_DRV                     0x0400
-#define INPUTVSC_DRV           0x0800
-#define BLKVSC_DRV                     0x1000
-
-#define ALL_MODULES                    (VMBUS          |\
-                                                       STORVSC         |\
-                                                       NETVSC          |\
-                                                       INPUTVSC        |\
-                                                       BLKVSC          |\
-                                                       VMBUS_DRV       |\
-                                                       STORVSC_DRV     |\
-                                                       NETVSC_DRV      |\
-                                                       INPUTVSC_DRV|\
-                                                       BLKVSC_DRV)
-
-/* Logging Level */
-#define ERROR_LVL                              3
-#define WARNING_LVL                            4
-#define INFO_LVL                               6
-#define DEBUG_LVL                              7
-#define DEBUG_LVL_ENTEREXIT                    8
-#define DEBUG_RING_LVL                         9
-
-extern unsigned int vmbus_loglevel;
-
-#define DPRINT(mod, lvl, fmt, args...) do {\
-       if ((mod & (HIWORD(vmbus_loglevel))) && \
-           (lvl <= LOWORD(vmbus_loglevel)))    \
-               printk(KERN_DEBUG #mod": %s() " fmt "\n", __func__, ## args);\
-       } while (0)
-
-#define DPRINT_DBG(mod, fmt, args...) do {\
-       if ((mod & (HIWORD(vmbus_loglevel))) &&         \
-           (DEBUG_LVL <= LOWORD(vmbus_loglevel)))      \
-               printk(KERN_DEBUG #mod": %s() " fmt "\n", __func__, ## args);\
-       } while (0)
-
-#define DPRINT_INFO(mod, fmt, args...) do {\
-       if ((mod & (HIWORD(vmbus_loglevel))) &&         \
-           (INFO_LVL <= LOWORD(vmbus_loglevel)))       \
-               printk(KERN_INFO #mod": " fmt "\n", ## args);\
-       } while (0)
-
-#define DPRINT_WARN(mod, fmt, args...) do {\
-       if ((mod & (HIWORD(vmbus_loglevel))) &&         \
-           (WARNING_LVL <= LOWORD(vmbus_loglevel)))    \
-               printk(KERN_WARNING #mod": WARNING! " fmt "\n", ## args);\
-       } while (0)
-
-#define DPRINT_ERR(mod, fmt, args...) do {\
-       if ((mod & (HIWORD(vmbus_loglevel))) &&         \
-           (ERROR_LVL <= LOWORD(vmbus_loglevel)))      \
-               printk(KERN_ERR #mod": %s() ERROR!! " fmt "\n", \
-                      __func__, ## args);\
-       } while (0)
-
-#endif /* _LOGGING_H_ */
index 20b159775e88a5accd9d33fb0456ca348e584a6c..41cbb26eccbf8c978d5cbc877d15ceebbd4d0f97 100644 (file)
@@ -18,6 +18,8 @@
  *   Haiyang Zhang <haiyangz@microsoft.com>
  *   Hank Janssen  <hjanssen@microsoft.com>
  */
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/kernel.h>
 #include <linux/sched.h>
 #include <linux/wait.h>
 #include <linux/delay.h>
 #include <linux/io.h>
 #include <linux/slab.h>
-#include "hv_api.h"
-#include "logging.h"
-#include "netvsc.h"
-#include "rndis_filter.h"
-#include "channel.h"
+
+#include "hyperv.h"
+#include "hyperv_net.h"
 
 
 /* Globals */
@@ -43,38 +43,6 @@ static const struct hv_guid netvsc_device_type = {
        }
 };
 
-static int netvsc_device_add(struct hv_device *device, void *additional_info);
-
-static int netvsc_device_remove(struct hv_device *device);
-
-static void netvsc_cleanup(struct hv_driver *driver);
-
-static void netvsc_channel_cb(void *context);
-
-static int netvsc_init_send_buf(struct hv_device *device);
-
-static int netvsc_init_recv_buf(struct hv_device *device);
-
-static int netvsc_destroy_send_buf(struct netvsc_device *net_device);
-
-static int netvsc_destroy_recv_buf(struct netvsc_device *net_device);
-
-static int netvsc_connect_vsp(struct hv_device *device);
-
-static void netvsc_send_completion(struct hv_device *device,
-                                  struct vmpacket_descriptor *packet);
-
-static int netvsc_send(struct hv_device *device,
-                       struct hv_netvsc_packet *packet);
-
-static void netvsc_receive(struct hv_device *device,
-                           struct vmpacket_descriptor *packet);
-
-static void netvsc_receive_completion(void *context);
-
-static void netvsc_send_recv_completion(struct hv_device *device,
-                                       u64 transaction_id);
-
 
 static struct netvsc_device *alloc_net_device(struct hv_device *device)
 {
@@ -171,43 +139,85 @@ static struct netvsc_device *release_inbound_net_device(
        return net_device;
 }
 
-/*
- * netvsc_initialize - Main entry point
- */
-int netvsc_initialize(struct hv_driver *drv)
+static int netvsc_destroy_recv_buf(struct netvsc_device *net_device)
 {
-       struct netvsc_driver *driver = (struct netvsc_driver *)drv;
+       struct nvsp_message *revoke_packet;
+       int ret = 0;
 
-       DPRINT_DBG(NETVSC, "sizeof(struct hv_netvsc_packet)=%zd, "
-                  "sizeof(struct nvsp_message)=%zd, "
-                  "sizeof(struct vmtransfer_page_packet_header)=%zd",
-                  sizeof(struct hv_netvsc_packet),
-                  sizeof(struct nvsp_message),
-                  sizeof(struct vmtransfer_page_packet_header));
+       /*
+        * If we got a section count, it means we received a
+        * SendReceiveBufferComplete msg (ie sent
+        * NvspMessage1TypeSendReceiveBuffer msg) therefore, we need
+        * to send a revoke msg here
+        */
+       if (net_device->recv_section_cnt) {
+               /* Send the revoke receive buffer */
+               revoke_packet = &net_device->revoke_packet;
+               memset(revoke_packet, 0, sizeof(struct nvsp_message));
 
-       drv->name = driver_name;
-       memcpy(&drv->dev_type, &netvsc_device_type, sizeof(struct hv_guid));
+               revoke_packet->hdr.msg_type =
+                       NVSP_MSG1_TYPE_REVOKE_RECV_BUF;
+               revoke_packet->msg.v1_msg.
+               revoke_recv_buf.id = NETVSC_RECEIVE_BUFFER_ID;
 
-       /* Setup the dispatch table */
-       driver->base.dev_add    = netvsc_device_add;
-       driver->base.dev_rm     = netvsc_device_remove;
-       driver->base.cleanup            = netvsc_cleanup;
+               ret = vmbus_sendpacket(net_device->dev->channel,
+                                      revoke_packet,
+                                      sizeof(struct nvsp_message),
+                                      (unsigned long)revoke_packet,
+                                      VM_PKT_DATA_INBAND, 0);
+               /*
+                * If we failed here, we might as well return and
+                * have a leak rather than continue and a bugchk
+                */
+               if (ret != 0) {
+                       dev_err(&net_device->dev->device, "unable to send "
+                               "revoke receive buffer to netvsp");
+                       return -1;
+               }
+       }
 
-       driver->send                    = netvsc_send;
+       /* Teardown the gpadl on the vsp end */
+       if (net_device->recv_buf_gpadl_handle) {
+               ret = vmbus_teardown_gpadl(net_device->dev->channel,
+                          net_device->recv_buf_gpadl_handle);
 
-       rndis_filter_init(driver);
-       return 0;
+               /* If we failed here, we might as well return and have a leak
+                * rather than continue and a bugchk
+                */
+               if (ret != 0) {
+                       dev_err(&net_device->dev->device,
+                                  "unable to teardown receive buffer's gpadl");
+                       return -1;
+               }
+               net_device->recv_buf_gpadl_handle = 0;
+       }
+
+       if (net_device->recv_buf) {
+               /* Free up the receive buffer */
+               free_pages((unsigned long)net_device->recv_buf,
+                       get_order(net_device->recv_buf_size));
+               net_device->recv_buf = NULL;
+       }
+
+       if (net_device->recv_section) {
+               net_device->recv_section_cnt = 0;
+               kfree(net_device->recv_section);
+               net_device->recv_section = NULL;
+       }
+
+       return ret;
 }
 
 static int netvsc_init_recv_buf(struct hv_device *device)
 {
        int ret = 0;
+       int t;
        struct netvsc_device *net_device;
        struct nvsp_message *init_packet;
 
        net_device = get_outbound_net_device(device);
        if (!net_device) {
-               DPRINT_ERR(NETVSC, "unable to get net device..."
+               dev_err(&device->device, "unable to get net device..."
                           "device being destroyed?");
                return -1;
        }
@@ -216,15 +226,12 @@ static int netvsc_init_recv_buf(struct hv_device *device)
                (void *)__get_free_pages(GFP_KERNEL|__GFP_ZERO,
                                get_order(net_device->recv_buf_size));
        if (!net_device->recv_buf) {
-               DPRINT_ERR(NETVSC,
-                          "unable to allocate receive buffer of size %d",
-                          net_device->recv_buf_size);
+               dev_err(&device->device, "unable to allocate receive "
+                       "buffer of size %d", net_device->recv_buf_size);
                ret = -1;
                goto cleanup;
        }
 
-       DPRINT_INFO(NETVSC, "Establishing receive buffer's GPADL...");
-
        /*
         * Establish the gpadl handle for this buffer on this
         * channel.  Note: This call uses the vmbus connection rather
@@ -234,15 +241,13 @@ static int netvsc_init_recv_buf(struct hv_device *device)
                                    net_device->recv_buf_size,
                                    &net_device->recv_buf_gpadl_handle);
        if (ret != 0) {
-               DPRINT_ERR(NETVSC,
-                          "unable to establish receive buffer's gpadl");
+               dev_err(&device->device,
+                       "unable to establish receive buffer's gpadl");
                goto cleanup;
        }
 
 
        /* Notify the NetVsp of the gpadl handle */
-       DPRINT_INFO(NETVSC, "Sending NvspMessage1TypeSendReceiveBuffer...");
-
        init_packet = &net_device->channel_init_pkt;
 
        memset(init_packet, 0, sizeof(struct nvsp_message));
@@ -254,28 +259,25 @@ static int netvsc_init_recv_buf(struct hv_device *device)
                send_recv_buf.id = NETVSC_RECEIVE_BUFFER_ID;
 
        /* Send the gpadl notification request */
-       net_device->wait_condition = 0;
        ret = vmbus_sendpacket(device->channel, init_packet,
                               sizeof(struct nvsp_message),
                               (unsigned long)init_packet,
                               VM_PKT_DATA_INBAND,
                               VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
        if (ret != 0) {
-               DPRINT_ERR(NETVSC,
-                          "unable to send receive buffer's gpadl to netvsp");
+               dev_err(&device->device,
+                       "unable to send receive buffer's gpadl to netvsp");
                goto cleanup;
        }
 
-       wait_event_timeout(net_device->channel_init_wait,
-                       net_device->wait_condition,
-                       msecs_to_jiffies(1000));
-       BUG_ON(net_device->wait_condition == 0);
+       t = wait_for_completion_timeout(&net_device->channel_init_wait, HZ);
+       BUG_ON(t == 0);
 
 
        /* Check the response */
        if (init_packet->msg.v1_msg.
            send_recv_buf_complete.status != NVSP_STAT_SUCCESS) {
-               DPRINT_ERR(NETVSC, "Unable to complete receive buffer "
+               dev_err(&device->device, "Unable to complete receive buffer "
                           "initialzation with NetVsp - status %d",
                           init_packet->msg.v1_msg.
                           send_recv_buf_complete.status);
@@ -301,14 +303,6 @@ static int netvsc_init_recv_buf(struct hv_device *device)
                net_device->recv_section_cnt *
               sizeof(struct nvsp_1_receive_buffer_section));
 
-       DPRINT_INFO(NETVSC, "Receive sections info (count %d, offset %d, "
-                   "endoffset %d, suballoc size %d, num suballocs %d)",
-                   net_device->recv_section_cnt,
-                   net_device->recv_section[0].offset,
-                   net_device->recv_section[0].end_offset,
-                   net_device->recv_section[0].sub_alloc_size,
-                   net_device->recv_section[0].num_sub_allocs);
-
        /*
         * For 1st release, there should only be 1 section that represents the
         * entire receive buffer
@@ -329,15 +323,80 @@ exit:
        return ret;
 }
 
+static int netvsc_destroy_send_buf(struct netvsc_device *net_device)
+{
+       struct nvsp_message *revoke_packet;
+       int ret = 0;
+
+       /*
+        * If we got a section count, it means we received a
+        *  SendReceiveBufferComplete msg (ie sent
+        *  NvspMessage1TypeSendReceiveBuffer msg) therefore, we need
+        *  to send a revoke msg here
+        */
+       if (net_device->send_section_size) {
+               /* Send the revoke send buffer */
+               revoke_packet = &net_device->revoke_packet;
+               memset(revoke_packet, 0, sizeof(struct nvsp_message));
+
+               revoke_packet->hdr.msg_type =
+                       NVSP_MSG1_TYPE_REVOKE_SEND_BUF;
+               revoke_packet->msg.v1_msg.
+                       revoke_send_buf.id = NETVSC_SEND_BUFFER_ID;
+
+               ret = vmbus_sendpacket(net_device->dev->channel,
+                                      revoke_packet,
+                                      sizeof(struct nvsp_message),
+                                      (unsigned long)revoke_packet,
+                                      VM_PKT_DATA_INBAND, 0);
+               /*
+                * If we failed here, we might as well return and have a leak
+                * rather than continue and a bugchk
+                */
+               if (ret != 0) {
+                       dev_err(&net_device->dev->device, "unable to send "
+                               "revoke send buffer to netvsp");
+                       return -1;
+               }
+       }
+
+       /* Teardown the gpadl on the vsp end */
+       if (net_device->send_buf_gpadl_handle) {
+               ret = vmbus_teardown_gpadl(net_device->dev->channel,
+                                          net_device->send_buf_gpadl_handle);
+
+               /*
+                * If we failed here, we might as well return and have a leak
+                * rather than continue and a bugchk
+                */
+               if (ret != 0) {
+                       dev_err(&net_device->dev->device,
+                               "unable to teardown send buffer's gpadl");
+                       return -1;
+               }
+               net_device->send_buf_gpadl_handle = 0;
+       }
+
+       if (net_device->send_buf) {
+               /* Free up the receive buffer */
+               free_pages((unsigned long)net_device->send_buf,
+                               get_order(net_device->send_buf_size));
+               net_device->send_buf = NULL;
+       }
+
+       return ret;
+}
+
 static int netvsc_init_send_buf(struct hv_device *device)
 {
        int ret = 0;
+       int t;
        struct netvsc_device *net_device;
        struct nvsp_message *init_packet;
 
        net_device = get_outbound_net_device(device);
        if (!net_device) {
-               DPRINT_ERR(NETVSC, "unable to get net device..."
+               dev_err(&device->device, "unable to get net device..."
                           "device being destroyed?");
                return -1;
        }
@@ -350,14 +409,12 @@ static int netvsc_init_send_buf(struct hv_device *device)
                (void *)__get_free_pages(GFP_KERNEL|__GFP_ZERO,
                                get_order(net_device->send_buf_size));
        if (!net_device->send_buf) {
-               DPRINT_ERR(NETVSC, "unable to allocate send buffer of size %d",
-                          net_device->send_buf_size);
+               dev_err(&device->device, "unable to allocate send "
+                       "buffer of size %d", net_device->send_buf_size);
                ret = -1;
                goto cleanup;
        }
 
-       DPRINT_INFO(NETVSC, "Establishing send buffer's GPADL...");
-
        /*
         * Establish the gpadl handle for this buffer on this
         * channel.  Note: This call uses the vmbus connection rather
@@ -367,13 +424,11 @@ static int netvsc_init_send_buf(struct hv_device *device)
                                    net_device->send_buf_size,
                                    &net_device->send_buf_gpadl_handle);
        if (ret != 0) {
-               DPRINT_ERR(NETVSC, "unable to establish send buffer's gpadl");
+               dev_err(&device->device, "unable to establish send buffer's gpadl");
                goto cleanup;
        }
 
        /* Notify the NetVsp of the gpadl handle */
-       DPRINT_INFO(NETVSC, "Sending NvspMessage1TypeSendSendBuffer...");
-
        init_packet = &net_device->channel_init_pkt;
 
        memset(init_packet, 0, sizeof(struct nvsp_message));
@@ -385,27 +440,25 @@ static int netvsc_init_send_buf(struct hv_device *device)
                NETVSC_SEND_BUFFER_ID;
 
        /* Send the gpadl notification request */
-       net_device->wait_condition = 0;
        ret = vmbus_sendpacket(device->channel, init_packet,
                               sizeof(struct nvsp_message),
                               (unsigned long)init_packet,
                               VM_PKT_DATA_INBAND,
                               VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
        if (ret != 0) {
-               DPRINT_ERR(NETVSC,
+               dev_err(&device->device,
                           "unable to send receive buffer's gpadl to netvsp");
                goto cleanup;
        }
 
-       wait_event_timeout(net_device->channel_init_wait,
-                       net_device->wait_condition,
-                       msecs_to_jiffies(1000));
-       BUG_ON(net_device->wait_condition == 0);
+       t = wait_for_completion_timeout(&net_device->channel_init_wait, HZ);
+
+       BUG_ON(t == 0);
 
        /* Check the response */
        if (init_packet->msg.v1_msg.
            send_send_buf_complete.status != NVSP_STAT_SUCCESS) {
-               DPRINT_ERR(NETVSC, "Unable to complete send buffer "
+               dev_err(&device->device, "Unable to complete send buffer "
                           "initialzation with NetVsp - status %d",
                           init_packet->msg.v1_msg.
                           send_send_buf_complete.status);
@@ -426,234 +479,70 @@ exit:
        return ret;
 }
 
-static int netvsc_destroy_recv_buf(struct netvsc_device *net_device)
+
+static int netvsc_connect_vsp(struct hv_device *device)
 {
-       struct nvsp_message *revoke_packet;
-       int ret = 0;
+       int ret, t;
+       struct netvsc_device *net_device;
+       struct nvsp_message *init_packet;
+       int ndis_version;
 
-       /*
-        * If we got a section count, it means we received a
-        * SendReceiveBufferComplete msg (ie sent
-        * NvspMessage1TypeSendReceiveBuffer msg) therefore, we need
-        * to send a revoke msg here
-        */
-       if (net_device->recv_section_cnt) {
-               DPRINT_INFO(NETVSC,
-                           "Sending NvspMessage1TypeRevokeReceiveBuffer...");
+       net_device = get_outbound_net_device(device);
+       if (!net_device) {
+               dev_err(&device->device, "unable to get net device..."
+                          "device being destroyed?");
+               return -1;
+       }
 
-               /* Send the revoke receive buffer */
-               revoke_packet = &net_device->revoke_packet;
-               memset(revoke_packet, 0, sizeof(struct nvsp_message));
+       init_packet = &net_device->channel_init_pkt;
 
-               revoke_packet->hdr.msg_type =
-                       NVSP_MSG1_TYPE_REVOKE_RECV_BUF;
-               revoke_packet->msg.v1_msg.
-               revoke_recv_buf.id = NETVSC_RECEIVE_BUFFER_ID;
+       memset(init_packet, 0, sizeof(struct nvsp_message));
+       init_packet->hdr.msg_type = NVSP_MSG_TYPE_INIT;
+       init_packet->msg.init_msg.init.min_protocol_ver =
+               NVSP_MIN_PROTOCOL_VERSION;
+       init_packet->msg.init_msg.init.max_protocol_ver =
+               NVSP_MAX_PROTOCOL_VERSION;
 
-               ret = vmbus_sendpacket(net_device->dev->channel,
-                                      revoke_packet,
-                                      sizeof(struct nvsp_message),
-                                      (unsigned long)revoke_packet,
-                                      VM_PKT_DATA_INBAND, 0);
-               /*
-                * If we failed here, we might as well return and
-                * have a leak rather than continue and a bugchk
-                */
-               if (ret != 0) {
-                       DPRINT_ERR(NETVSC, "unable to send revoke receive "
-                                  "buffer to netvsp");
-                       return -1;
-               }
-       }
+       /* Send the init request */
+       ret = vmbus_sendpacket(device->channel, init_packet,
+                              sizeof(struct nvsp_message),
+                              (unsigned long)init_packet,
+                              VM_PKT_DATA_INBAND,
+                              VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
 
-       /* Teardown the gpadl on the vsp end */
-       if (net_device->recv_buf_gpadl_handle) {
-               DPRINT_INFO(NETVSC, "Tearing down receive buffer's GPADL...");
+       if (ret != 0)
+               goto cleanup;
 
-               ret = vmbus_teardown_gpadl(net_device->dev->channel,
-                          net_device->recv_buf_gpadl_handle);
+       t = wait_for_completion_timeout(&net_device->channel_init_wait, HZ);
 
-               /* If we failed here, we might as well return and have a leak rather than continue and a bugchk */
-               if (ret != 0) {
-                       DPRINT_ERR(NETVSC,
-                                  "unable to teardown receive buffer's gpadl");
-                       return -1;
-               }
-               net_device->recv_buf_gpadl_handle = 0;
+       if (t == 0) {
+               ret = -ETIMEDOUT;
+               goto cleanup;
        }
 
-       if (net_device->recv_buf) {
-               DPRINT_INFO(NETVSC, "Freeing up receive buffer...");
-
-               /* Free up the receive buffer */
-               free_pages((unsigned long)net_device->recv_buf,
-                       get_order(net_device->recv_buf_size));
-               net_device->recv_buf = NULL;
+       if (init_packet->msg.init_msg.init_complete.status !=
+           NVSP_STAT_SUCCESS) {
+               ret = -1;
+               goto cleanup;
        }
 
-       if (net_device->recv_section) {
-               net_device->recv_section_cnt = 0;
-               kfree(net_device->recv_section);
-               net_device->recv_section = NULL;
+       if (init_packet->msg.init_msg.init_complete.
+           negotiated_protocol_ver != NVSP_PROTOCOL_VERSION_1) {
+               ret = -1;
+               goto cleanup;
        }
+       /* Send the ndis version */
+       memset(init_packet, 0, sizeof(struct nvsp_message));
 
-       return ret;
-}
+       ndis_version = 0x00050000;
 
-static int netvsc_destroy_send_buf(struct netvsc_device *net_device)
-{
-       struct nvsp_message *revoke_packet;
-       int ret = 0;
-
-       /*
-        * If we got a section count, it means we received a
-        *  SendReceiveBufferComplete msg (ie sent
-        *  NvspMessage1TypeSendReceiveBuffer msg) therefore, we need
-        *  to send a revoke msg here
-        */
-       if (net_device->send_section_size) {
-               DPRINT_INFO(NETVSC,
-                           "Sending NvspMessage1TypeRevokeSendBuffer...");
-
-               /* Send the revoke send buffer */
-               revoke_packet = &net_device->revoke_packet;
-               memset(revoke_packet, 0, sizeof(struct nvsp_message));
-
-               revoke_packet->hdr.msg_type =
-                       NVSP_MSG1_TYPE_REVOKE_SEND_BUF;
-               revoke_packet->msg.v1_msg.
-                       revoke_send_buf.id = NETVSC_SEND_BUFFER_ID;
-
-               ret = vmbus_sendpacket(net_device->dev->channel,
-                                      revoke_packet,
-                                      sizeof(struct nvsp_message),
-                                      (unsigned long)revoke_packet,
-                                      VM_PKT_DATA_INBAND, 0);
-               /*
-                * If we failed here, we might as well return and have a leak
-                * rather than continue and a bugchk
-                */
-               if (ret != 0) {
-                       DPRINT_ERR(NETVSC, "unable to send revoke send buffer "
-                                  "to netvsp");
-                       return -1;
-               }
-       }
-
-       /* Teardown the gpadl on the vsp end */
-       if (net_device->send_buf_gpadl_handle) {
-               DPRINT_INFO(NETVSC, "Tearing down send buffer's GPADL...");
-               ret = vmbus_teardown_gpadl(net_device->dev->channel,
-                                          net_device->send_buf_gpadl_handle);
-
-               /*
-                * If we failed here, we might as well return and have a leak
-                * rather than continue and a bugchk
-                */
-               if (ret != 0) {
-                       DPRINT_ERR(NETVSC, "unable to teardown send buffer's "
-                                  "gpadl");
-                       return -1;
-               }
-               net_device->send_buf_gpadl_handle = 0;
-       }
-
-       if (net_device->send_buf) {
-               DPRINT_INFO(NETVSC, "Freeing up send buffer...");
-
-               /* Free up the receive buffer */
-               free_pages((unsigned long)net_device->send_buf,
-                               get_order(net_device->send_buf_size));
-               net_device->send_buf = NULL;
-       }
-
-       return ret;
-}
-
-
-static int netvsc_connect_vsp(struct hv_device *device)
-{
-       int ret;
-       struct netvsc_device *net_device;
-       struct nvsp_message *init_packet;
-       int ndis_version;
-
-       net_device = get_outbound_net_device(device);
-       if (!net_device) {
-               DPRINT_ERR(NETVSC, "unable to get net device..."
-                          "device being destroyed?");
-               return -1;
-       }
-
-       init_packet = &net_device->channel_init_pkt;
-
-       memset(init_packet, 0, sizeof(struct nvsp_message));
-       init_packet->hdr.msg_type = NVSP_MSG_TYPE_INIT;
-       init_packet->msg.init_msg.init.min_protocol_ver =
-               NVSP_MIN_PROTOCOL_VERSION;
-       init_packet->msg.init_msg.init.max_protocol_ver =
-               NVSP_MAX_PROTOCOL_VERSION;
-
-       DPRINT_INFO(NETVSC, "Sending NvspMessageTypeInit...");
-
-       /* Send the init request */
-       net_device->wait_condition = 0;
-       ret = vmbus_sendpacket(device->channel, init_packet,
-                              sizeof(struct nvsp_message),
-                              (unsigned long)init_packet,
-                              VM_PKT_DATA_INBAND,
-                              VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
-
-       if (ret != 0) {
-               DPRINT_ERR(NETVSC, "unable to send NvspMessageTypeInit");
-               goto cleanup;
-       }
-
-       wait_event_timeout(net_device->channel_init_wait,
-                       net_device->wait_condition,
-                       msecs_to_jiffies(1000));
-       if (net_device->wait_condition == 0) {
-               ret = -ETIMEDOUT;
-               goto cleanup;
-       }
-
-       DPRINT_INFO(NETVSC, "NvspMessageTypeInit status(%d) max mdl chain (%d)",
-               init_packet->msg.init_msg.init_complete.status,
-               init_packet->msg.init_msg.
-                   init_complete.max_mdl_chain_len);
-
-       if (init_packet->msg.init_msg.init_complete.status !=
-           NVSP_STAT_SUCCESS) {
-               DPRINT_ERR(NETVSC,
-                       "unable to initialize with netvsp (status 0x%x)",
-                       init_packet->msg.init_msg.init_complete.status);
-               ret = -1;
-               goto cleanup;
-       }
-
-       if (init_packet->msg.init_msg.init_complete.
-           negotiated_protocol_ver != NVSP_PROTOCOL_VERSION_1) {
-               DPRINT_ERR(NETVSC, "unable to initialize with netvsp "
-                          "(version expected 1 got %d)",
-                          init_packet->msg.init_msg.
-                          init_complete.negotiated_protocol_ver);
-               ret = -1;
-               goto cleanup;
-       }
-       DPRINT_INFO(NETVSC, "Sending NvspMessage1TypeSendNdisVersion...");
-
-       /* Send the ndis version */
-       memset(init_packet, 0, sizeof(struct nvsp_message));
-
-       ndis_version = 0x00050000;
-
-       init_packet->hdr.msg_type = NVSP_MSG1_TYPE_SEND_NDIS_VER;
-       init_packet->msg.v1_msg.
-               send_ndis_ver.ndis_major_ver =
-                               (ndis_version & 0xFFFF0000) >> 16;
-       init_packet->msg.v1_msg.
-               send_ndis_ver.ndis_minor_ver =
-                               ndis_version & 0xFFFF;
+       init_packet->hdr.msg_type = NVSP_MSG1_TYPE_SEND_NDIS_VER;
+       init_packet->msg.v1_msg.
+               send_ndis_ver.ndis_major_ver =
+                               (ndis_version & 0xFFFF0000) >> 16;
+       init_packet->msg.v1_msg.
+               send_ndis_ver.ndis_minor_ver =
+                               ndis_version & 0xFFFF;
 
        /* Send the init request */
        ret = vmbus_sendpacket(device->channel, init_packet,
@@ -661,8 +550,6 @@ static int netvsc_connect_vsp(struct hv_device *device)
                                (unsigned long)init_packet,
                                VM_PKT_DATA_INBAND, 0);
        if (ret != 0) {
-               DPRINT_ERR(NETVSC,
-                          "unable to send NvspMessage1TypeSendNdisVersion");
                ret = -1;
                goto cleanup;
        }
@@ -677,143 +564,42 @@ cleanup:
        return ret;
 }
 
-static void NetVscDisconnectFromVsp(struct netvsc_device *net_device)
+static void netvsc_disconnect_vsp(struct netvsc_device *net_device)
 {
        netvsc_destroy_recv_buf(net_device);
        netvsc_destroy_send_buf(net_device);
 }
 
-/*
- * netvsc_device_add - Callback when the device belonging to this
- * driver is added
- */
-static int netvsc_device_add(struct hv_device *device, void *additional_info)
-{
-       int ret = 0;
-       int i;
-       struct netvsc_device *net_device;
-       struct hv_netvsc_packet *packet, *pos;
-       struct netvsc_driver *net_driver =
-                               (struct netvsc_driver *)device->drv;
-
-       net_device = alloc_net_device(device);
-       if (!net_device) {
-               ret = -1;
-               goto cleanup;
-       }
-
-       DPRINT_DBG(NETVSC, "netvsc channel object allocated - %p", net_device);
-
-       /* Initialize the NetVSC channel extension */
-       net_device->recv_buf_size = NETVSC_RECEIVE_BUFFER_SIZE;
-       spin_lock_init(&net_device->recv_pkt_list_lock);
-
-       net_device->send_buf_size = NETVSC_SEND_BUFFER_SIZE;
-
-       INIT_LIST_HEAD(&net_device->recv_pkt_list);
-
-       for (i = 0; i < NETVSC_RECEIVE_PACKETLIST_COUNT; i++) {
-               packet = kzalloc(sizeof(struct hv_netvsc_packet) +
-                                (NETVSC_RECEIVE_SG_COUNT *
-                                 sizeof(struct hv_page_buffer)), GFP_KERNEL);
-               if (!packet) {
-                       DPRINT_DBG(NETVSC, "unable to allocate netvsc pkts "
-                                  "for receive pool (wanted %d got %d)",
-                                  NETVSC_RECEIVE_PACKETLIST_COUNT, i);
-                       break;
-               }
-               list_add_tail(&packet->list_ent,
-                             &net_device->recv_pkt_list);
-       }
-       init_waitqueue_head(&net_device->channel_init_wait);
-
-       /* Open the channel */
-       ret = vmbus_open(device->channel, net_driver->ring_buf_size,
-                        net_driver->ring_buf_size, NULL, 0,
-                        netvsc_channel_cb, device);
-
-       if (ret != 0) {
-               DPRINT_ERR(NETVSC, "unable to open channel: %d", ret);
-               ret = -1;
-               goto cleanup;
-       }
-
-       /* Channel is opened */
-       DPRINT_INFO(NETVSC, "*** NetVSC channel opened successfully! ***");
-
-       /* Connect with the NetVsp */
-       ret = netvsc_connect_vsp(device);
-       if (ret != 0) {
-               DPRINT_ERR(NETVSC, "unable to connect to NetVSP - %d", ret);
-               ret = -1;
-               goto close;
-       }
-
-       DPRINT_INFO(NETVSC, "*** NetVSC channel handshake result - %d ***",
-                   ret);
-
-       return ret;
-
-close:
-       /* Now, we can close the channel safely */
-       vmbus_close(device->channel);
-
-cleanup:
-
-       if (net_device) {
-               list_for_each_entry_safe(packet, pos,
-                                        &net_device->recv_pkt_list,
-                                        list_ent) {
-                       list_del(&packet->list_ent);
-                       kfree(packet);
-               }
-
-               release_outbound_net_device(device);
-               release_inbound_net_device(device);
-
-               free_net_device(net_device);
-       }
-
-       return ret;
-}
-
 /*
  * netvsc_device_remove - Callback when the root bus device is removed
  */
-static int netvsc_device_remove(struct hv_device *device)
+int netvsc_device_remove(struct hv_device *device)
 {
        struct netvsc_device *net_device;
        struct hv_netvsc_packet *netvsc_packet, *pos;
 
-       DPRINT_INFO(NETVSC, "Disabling outbound traffic on net device (%p)...",
-                   device->ext);
-
        /* Stop outbound traffic ie sends and receives completions */
        net_device = release_outbound_net_device(device);
        if (!net_device) {
-               DPRINT_ERR(NETVSC, "No net device present!!");
+               dev_err(&device->device, "No net device present!!");
                return -1;
        }
 
        /* Wait for all send completions */
        while (atomic_read(&net_device->num_outstanding_sends)) {
-               DPRINT_INFO(NETVSC, "waiting for %d requests to complete...",
-                           atomic_read(&net_device->num_outstanding_sends));
+               dev_err(&device->device,
+                       "waiting for %d requests to complete...",
+                       atomic_read(&net_device->num_outstanding_sends));
                udelay(100);
        }
 
-       DPRINT_INFO(NETVSC, "Disconnecting from netvsp...");
-
-       NetVscDisconnectFromVsp(net_device);
-
-       DPRINT_INFO(NETVSC, "Disabling inbound traffic on net device (%p)...",
-                   device->ext);
+       netvsc_disconnect_vsp(net_device);
 
        /* Stop inbound traffic ie receives and sends completions */
        net_device = release_inbound_net_device(device);
 
        /* At this point, no one should be accessing netDevice except in here */
-       DPRINT_INFO(NETVSC, "net device (%p) safe to remove", net_device);
+       dev_notice(&device->device, "net device safe to remove");
 
        /* Now, we can close the channel safely */
        vmbus_close(device->channel);
@@ -829,13 +615,6 @@ static int netvsc_device_remove(struct hv_device *device)
        return 0;
 }
 
-/*
- * netvsc_cleanup - Perform any cleanup when the driver is removed
- */
-static void netvsc_cleanup(struct hv_driver *drv)
-{
-}
-
 static void netvsc_send_completion(struct hv_device *device,
                                   struct vmpacket_descriptor *packet)
 {
@@ -845,7 +624,7 @@ static void netvsc_send_completion(struct hv_device *device,
 
        net_device = get_inbound_net_device(device);
        if (!net_device) {
-               DPRINT_ERR(NETVSC, "unable to get net device..."
+               dev_err(&device->device, "unable to get net device..."
                           "device being destroyed?");
                return;
        }
@@ -853,9 +632,6 @@ static void netvsc_send_completion(struct hv_device *device,
        nvsp_packet = (struct nvsp_message *)((unsigned long)packet +
                        (packet->offset8 << 3));
 
-       DPRINT_DBG(NETVSC, "send completion packet - type %d",
-                  nvsp_packet->hdr.msg_type);
-
        if ((nvsp_packet->hdr.msg_type == NVSP_MSG_TYPE_INIT_COMPLETE) ||
            (nvsp_packet->hdr.msg_type ==
             NVSP_MSG1_TYPE_SEND_RECV_BUF_COMPLETE) ||
@@ -864,8 +640,7 @@ static void netvsc_send_completion(struct hv_device *device,
                /* Copy the response back */
                memcpy(&net_device->channel_init_pkt, nvsp_packet,
                       sizeof(struct nvsp_message));
-               net_device->wait_condition = 1;
-               wake_up(&net_device->channel_init_wait);
+               complete(&net_device->channel_init_wait);
        } else if (nvsp_packet->hdr.msg_type ==
                   NVSP_MSG1_TYPE_SEND_RNDIS_PKT_COMPLETE) {
                /* Get the send context */
@@ -878,14 +653,14 @@ static void netvsc_send_completion(struct hv_device *device,
 
                atomic_dec(&net_device->num_outstanding_sends);
        } else {
-               DPRINT_ERR(NETVSC, "Unknown send completion packet type - "
+               dev_err(&device->device, "Unknown send completion packet type- "
                           "%d received!!", nvsp_packet->hdr.msg_type);
        }
 
        put_net_device(device);
 }
 
-static int netvsc_send(struct hv_device *device,
+int netvsc_send(struct hv_device *device,
                        struct hv_netvsc_packet *packet)
 {
        struct netvsc_device *net_device;
@@ -895,7 +670,7 @@ static int netvsc_send(struct hv_device *device,
 
        net_device = get_outbound_net_device(device);
        if (!net_device) {
-               DPRINT_ERR(NETVSC, "net device (%p) shutting down..."
+               dev_err(&device->device, "net device (%p) shutting down..."
                           "ignoring outbound packets", net_device);
                return -2;
        }
@@ -931,7 +706,7 @@ static int netvsc_send(struct hv_device *device,
        }
 
        if (ret != 0)
-               DPRINT_ERR(NETVSC, "Unable to send packet %p ret %d",
+               dev_err(&device->device, "Unable to send packet %p ret %d",
                           packet, ret);
 
        atomic_inc(&net_device->num_outstanding_sends);
@@ -939,6 +714,98 @@ static int netvsc_send(struct hv_device *device,
        return ret;
 }
 
+static void netvsc_send_recv_completion(struct hv_device *device,
+                                       u64 transaction_id)
+{
+       struct nvsp_message recvcompMessage;
+       int retries = 0;
+       int ret;
+
+       recvcompMessage.hdr.msg_type =
+                               NVSP_MSG1_TYPE_SEND_RNDIS_PKT_COMPLETE;
+
+       /* FIXME: Pass in the status */
+       recvcompMessage.msg.v1_msg.send_rndis_pkt_complete.status =
+               NVSP_STAT_SUCCESS;
+
+retry_send_cmplt:
+       /* Send the completion */
+       ret = vmbus_sendpacket(device->channel, &recvcompMessage,
+                              sizeof(struct nvsp_message), transaction_id,
+                              VM_PKT_COMP, 0);
+       if (ret == 0) {
+               /* success */
+               /* no-op */
+       } else if (ret == -1) {
+               /* no more room...wait a bit and attempt to retry 3 times */
+               retries++;
+               dev_err(&device->device, "unable to send receive completion pkt"
+                       " (tid %llx)...retrying %d", transaction_id, retries);
+
+               if (retries < 4) {
+                       udelay(100);
+                       goto retry_send_cmplt;
+               } else {
+                       dev_err(&device->device, "unable to send receive "
+                               "completion pkt (tid %llx)...give up retrying",
+                               transaction_id);
+               }
+       } else {
+               dev_err(&device->device, "unable to send receive "
+                       "completion pkt - %llx", transaction_id);
+       }
+}
+
+/* Send a receive completion packet to RNDIS device (ie NetVsp) */
+static void netvsc_receive_completion(void *context)
+{
+       struct hv_netvsc_packet *packet = context;
+       struct hv_device *device = (struct hv_device *)packet->device;
+       struct netvsc_device *net_device;
+       u64 transaction_id = 0;
+       bool fsend_receive_comp = false;
+       unsigned long flags;
+
+       /*
+        * Even though it seems logical to do a GetOutboundNetDevice() here to
+        * send out receive completion, we are using GetInboundNetDevice()
+        * since we may have disable outbound traffic already.
+        */
+       net_device = get_inbound_net_device(device);
+       if (!net_device) {
+               dev_err(&device->device, "unable to get net device..."
+                          "device being destroyed?");
+               return;
+       }
+
+       /* Overloading use of the lock. */
+       spin_lock_irqsave(&net_device->recv_pkt_list_lock, flags);
+
+       packet->xfer_page_pkt->count--;
+
+       /*
+        * Last one in the line that represent 1 xfer page packet.
+        * Return the xfer page packet itself to the freelist
+        */
+       if (packet->xfer_page_pkt->count == 0) {
+               fsend_receive_comp = true;
+               transaction_id = packet->completion.recv.recv_completion_tid;
+               list_add_tail(&packet->xfer_page_pkt->list_ent,
+                             &net_device->recv_pkt_list);
+
+       }
+
+       /* Put the packet back */
+       list_add_tail(&packet->list_ent, &net_device->recv_pkt_list);
+       spin_unlock_irqrestore(&net_device->recv_pkt_list_lock, flags);
+
+       /* Send a receive completion for the xfer page packet */
+       if (fsend_receive_comp)
+               netvsc_send_recv_completion(device, transaction_id);
+
+       put_net_device(device);
+}
+
 static void netvsc_receive(struct hv_device *device,
                            struct vmpacket_descriptor *packet)
 {
@@ -953,11 +820,12 @@ static void netvsc_receive(struct hv_device *device,
        int i, j;
        int count = 0, bytes_remain = 0;
        unsigned long flags;
+
        LIST_HEAD(listHead);
 
        net_device = get_inbound_net_device(device);
        if (!net_device) {
-               DPRINT_ERR(NETVSC, "unable to get net device..."
+               dev_err(&device->device, "unable to get net device..."
                           "device being destroyed?");
                return;
        }
@@ -967,7 +835,7 @@ static void netvsc_receive(struct hv_device *device,
         * packet
         */
        if (packet->type != VM_PKT_DATA_USING_XFER_PAGES) {
-               DPRINT_ERR(NETVSC, "Unknown packet type received - %d",
+               dev_err(&device->device, "Unknown packet type received - %d",
                           packet->type);
                put_net_device(device);
                return;
@@ -979,28 +847,22 @@ static void netvsc_receive(struct hv_device *device,
        /* Make sure this is a valid nvsp packet */
        if (nvsp_packet->hdr.msg_type !=
            NVSP_MSG1_TYPE_SEND_RNDIS_PKT) {
-               DPRINT_ERR(NETVSC, "Unknown nvsp packet type received - %d",
-                          nvsp_packet->hdr.msg_type);
+               dev_err(&device->device, "Unknown nvsp packet type received-"
+                       " %d", nvsp_packet->hdr.msg_type);
                put_net_device(device);
                return;
        }
 
-       DPRINT_DBG(NETVSC, "NVSP packet received - type %d",
-                  nvsp_packet->hdr.msg_type);
-
        vmxferpage_packet = (struct vmtransfer_page_packet_header *)packet;
 
        if (vmxferpage_packet->xfer_pageset_id != NETVSC_RECEIVE_BUFFER_ID) {
-               DPRINT_ERR(NETVSC, "Invalid xfer page set id - "
+               dev_err(&device->device, "Invalid xfer page set id - "
                           "expecting %x got %x", NETVSC_RECEIVE_BUFFER_ID,
                           vmxferpage_packet->xfer_pageset_id);
                put_net_device(device);
                return;
        }
 
-       DPRINT_DBG(NETVSC, "xfer page - range count %d",
-                  vmxferpage_packet->range_cnt);
-
        /*
         * Grab free packets (range count + 1) to represent this xfer
         * page packet. +1 to represent the xfer page packet itself.
@@ -1021,9 +883,9 @@ static void netvsc_receive(struct hv_device *device,
         * some of the xfer page packet ranges...
         */
        if (count < 2) {
-               DPRINT_ERR(NETVSC, "Got only %d netvsc pkt...needed %d pkts. "
-                          "Dropping this xfer page packet completely!",
-                          count, vmxferpage_packet->range_cnt + 1);
+               dev_err(&device->device, "Got only %d netvsc pkt...needed "
+                       "%d pkts. Dropping this xfer page packet completely!",
+                       count, vmxferpage_packet->range_cnt + 1);
 
                /* Return it to the freelist */
                spin_lock_irqsave(&net_device->recv_pkt_list_lock, flags);
@@ -1049,9 +911,9 @@ static void netvsc_receive(struct hv_device *device,
        xferpage_packet->count = count - 1;
 
        if (xferpage_packet->count != vmxferpage_packet->range_cnt) {
-               DPRINT_INFO(NETVSC, "Needed %d netvsc pkts to satisy this xfer "
-                           "page...got %d", vmxferpage_packet->range_cnt,
-                           xferpage_packet->count);
+               dev_err(&device->device, "Needed %d netvsc pkts to satisy "
+                       "this xfer page...got %d",
+                       vmxferpage_packet->range_cnt, xferpage_packet->count);
        }
 
        /* Each range represents 1 RNDIS pkt that contains 1 ethernet frame */
@@ -1117,17 +979,9 @@ static void netvsc_receive(struct hv_device *device,
                                        break;
                        }
                }
-               DPRINT_DBG(NETVSC, "[%d] - (abs offset %u len %u) => "
-                          "(pfn %llx, offset %u, len %u)", i,
-                          vmxferpage_packet->ranges[i].byte_offset,
-                          vmxferpage_packet->ranges[i].byte_count,
-                          netvsc_packet->page_buf[0].pfn,
-                          netvsc_packet->page_buf[0].offset,
-                          netvsc_packet->page_buf[0].len);
 
                /* Pass it to the upper layer */
-               ((struct netvsc_driver *)device->drv)->
-                       recv_cb(device, netvsc_packet);
+               rndis_filter_receive(device, netvsc_packet);
 
                netvsc_receive_completion(netvsc_packet->
                                completion.recv.recv_completion_ctx);
@@ -1136,101 +990,6 @@ static void netvsc_receive(struct hv_device *device,
        put_net_device(device);
 }
 
-static void netvsc_send_recv_completion(struct hv_device *device,
-                                       u64 transaction_id)
-{
-       struct nvsp_message recvcompMessage;
-       int retries = 0;
-       int ret;
-
-       DPRINT_DBG(NETVSC, "Sending receive completion pkt - %llx",
-                  transaction_id);
-
-       recvcompMessage.hdr.msg_type =
-                               NVSP_MSG1_TYPE_SEND_RNDIS_PKT_COMPLETE;
-
-       /* FIXME: Pass in the status */
-       recvcompMessage.msg.v1_msg.send_rndis_pkt_complete.status =
-               NVSP_STAT_SUCCESS;
-
-retry_send_cmplt:
-       /* Send the completion */
-       ret = vmbus_sendpacket(device->channel, &recvcompMessage,
-                              sizeof(struct nvsp_message), transaction_id,
-                              VM_PKT_COMP, 0);
-       if (ret == 0) {
-               /* success */
-               /* no-op */
-       } else if (ret == -1) {
-               /* no more room...wait a bit and attempt to retry 3 times */
-               retries++;
-               DPRINT_ERR(NETVSC, "unable to send receive completion pkt "
-                          "(tid %llx)...retrying %d", transaction_id, retries);
-
-               if (retries < 4) {
-                       udelay(100);
-                       goto retry_send_cmplt;
-               } else {
-                       DPRINT_ERR(NETVSC, "unable to send receive completion "
-                                 "pkt (tid %llx)...give up retrying",
-                                 transaction_id);
-               }
-       } else {
-               DPRINT_ERR(NETVSC, "unable to send receive completion pkt - "
-                          "%llx", transaction_id);
-       }
-}
-
-/* Send a receive completion packet to RNDIS device (ie NetVsp) */
-static void netvsc_receive_completion(void *context)
-{
-       struct hv_netvsc_packet *packet = context;
-       struct hv_device *device = (struct hv_device *)packet->device;
-       struct netvsc_device *net_device;
-       u64 transaction_id = 0;
-       bool fsend_receive_comp = false;
-       unsigned long flags;
-
-       /*
-        * Even though it seems logical to do a GetOutboundNetDevice() here to
-        * send out receive completion, we are using GetInboundNetDevice()
-        * since we may have disable outbound traffic already.
-        */
-       net_device = get_inbound_net_device(device);
-       if (!net_device) {
-               DPRINT_ERR(NETVSC, "unable to get net device..."
-                          "device being destroyed?");
-               return;
-       }
-
-       /* Overloading use of the lock. */
-       spin_lock_irqsave(&net_device->recv_pkt_list_lock, flags);
-
-       packet->xfer_page_pkt->count--;
-
-       /*
-        * Last one in the line that represent 1 xfer page packet.
-        * Return the xfer page packet itself to the freelist
-        */
-       if (packet->xfer_page_pkt->count == 0) {
-               fsend_receive_comp = true;
-               transaction_id = packet->completion.recv.recv_completion_tid;
-               list_add_tail(&packet->xfer_page_pkt->list_ent,
-                             &net_device->recv_pkt_list);
-
-       }
-
-       /* Put the packet back */
-       list_add_tail(&packet->list_ent, &net_device->recv_pkt_list);
-       spin_unlock_irqrestore(&net_device->recv_pkt_list_lock, flags);
-
-       /* Send a receive completion for the xfer page packet */
-       if (fsend_receive_comp)
-               netvsc_send_recv_completion(device, transaction_id);
-
-       put_net_device(device);
-}
-
 static void netvsc_channel_cb(void *context)
 {
        int ret;
@@ -1251,7 +1010,7 @@ static void netvsc_channel_cb(void *context)
 
        net_device = get_inbound_net_device(device);
        if (!net_device) {
-               DPRINT_ERR(NETVSC, "net device (%p) shutting down..."
+               dev_err(&device->device, "net device (%p) shutting down..."
                           "ignoring inbound packets", net_device);
                goto out;
        }
@@ -1261,9 +1020,6 @@ static void netvsc_channel_cb(void *context)
                                           &bytes_recvd, &request_id);
                if (ret == 0) {
                        if (bytes_recvd > 0) {
-                               DPRINT_DBG(NETVSC, "receive %d bytes, tid %llx",
-                                          bytes_recvd, request_id);
-
                                desc = (struct vmpacket_descriptor *)buffer;
                                switch (desc->type) {
                                case VM_PKT_COMP:
@@ -1275,7 +1031,7 @@ static void netvsc_channel_cb(void *context)
                                        break;
 
                                default:
-                                       DPRINT_ERR(NETVSC,
+                                       dev_err(&device->device,
                                                   "unhandled packet type %d, "
                                                   "tid %llx len %d\n",
                                                   desc->type, request_id,
@@ -1304,7 +1060,7 @@ static void netvsc_channel_cb(void *context)
                        buffer = kmalloc(bytes_recvd, GFP_ATOMIC);
                        if (buffer == NULL) {
                                /* Try again next time around */
-                               DPRINT_ERR(NETVSC,
+                               dev_err(&device->device,
                                           "unable to allocate buffer of size "
                                           "(%d)!!", bytes_recvd);
                                break;
@@ -1319,3 +1075,102 @@ out:
        kfree(buffer);
        return;
 }
+
+/*
+ * netvsc_device_add - Callback when the device belonging to this
+ * driver is added
+ */
+int netvsc_device_add(struct hv_device *device, void *additional_info)
+{
+       int ret = 0;
+       int i;
+       int ring_size =
+       ((struct netvsc_device_info *)additional_info)->ring_size;
+       struct netvsc_device *net_device;
+       struct hv_netvsc_packet *packet, *pos;
+
+       net_device = alloc_net_device(device);
+       if (!net_device) {
+               ret = -1;
+               goto cleanup;
+       }
+
+       /* Initialize the NetVSC channel extension */
+       net_device->recv_buf_size = NETVSC_RECEIVE_BUFFER_SIZE;
+       spin_lock_init(&net_device->recv_pkt_list_lock);
+
+       net_device->send_buf_size = NETVSC_SEND_BUFFER_SIZE;
+
+       INIT_LIST_HEAD(&net_device->recv_pkt_list);
+
+       for (i = 0; i < NETVSC_RECEIVE_PACKETLIST_COUNT; i++) {
+               packet = kzalloc(sizeof(struct hv_netvsc_packet) +
+                                (NETVSC_RECEIVE_SG_COUNT *
+                                 sizeof(struct hv_page_buffer)), GFP_KERNEL);
+               if (!packet)
+                       break;
+
+               list_add_tail(&packet->list_ent,
+                             &net_device->recv_pkt_list);
+       }
+       init_completion(&net_device->channel_init_wait);
+
+       /* Open the channel */
+       ret = vmbus_open(device->channel, ring_size * PAGE_SIZE,
+                        ring_size * PAGE_SIZE, NULL, 0,
+                        netvsc_channel_cb, device);
+
+       if (ret != 0) {
+               dev_err(&device->device, "unable to open channel: %d", ret);
+               ret = -1;
+               goto cleanup;
+       }
+
+       /* Channel is opened */
+       pr_info("hv_netvsc channel opened successfully");
+
+       /* Connect with the NetVsp */
+       ret = netvsc_connect_vsp(device);
+       if (ret != 0) {
+               dev_err(&device->device,
+                       "unable to connect to NetVSP - %d", ret);
+               ret = -1;
+               goto close;
+       }
+
+       return ret;
+
+close:
+       /* Now, we can close the channel safely */
+       vmbus_close(device->channel);
+
+cleanup:
+
+       if (net_device) {
+               list_for_each_entry_safe(packet, pos,
+                                        &net_device->recv_pkt_list,
+                                        list_ent) {
+                       list_del(&packet->list_ent);
+                       kfree(packet);
+               }
+
+               release_outbound_net_device(device);
+               release_inbound_net_device(device);
+
+               free_net_device(net_device);
+       }
+
+       return ret;
+}
+
+/*
+ * netvsc_initialize - Main entry point
+ */
+int netvsc_initialize(struct hv_driver *drv)
+{
+
+       drv->name = driver_name;
+       memcpy(&drv->dev_type, &netvsc_device_type, sizeof(struct hv_guid));
+
+       return 0;
+}
diff --git a/drivers/staging/hv/netvsc.h b/drivers/staging/hv/netvsc.h
deleted file mode 100644 (file)
index 45d24b9..0000000
+++ /dev/null
@@ -1,332 +0,0 @@
-/*
- *
- * Copyright (c) 2009, Microsoft Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place - Suite 330, Boston, MA 02111-1307 USA.
- *
- * Authors:
- *   Haiyang Zhang <haiyangz@microsoft.com>
- *   Hank Janssen  <hjanssen@microsoft.com>
- *
- */
-
-
-#ifndef _NETVSC_H_
-#define _NETVSC_H_
-
-#include <linux/list.h>
-#include "vmbus_packet_format.h"
-#include "vmbus_channel_interface.h"
-#include "netvsc_api.h"
-
-
-#define NVSP_INVALID_PROTOCOL_VERSION  ((u32)0xFFFFFFFF)
-
-#define NVSP_PROTOCOL_VERSION_1                2
-#define NVSP_MIN_PROTOCOL_VERSION      NVSP_PROTOCOL_VERSION_1
-#define NVSP_MAX_PROTOCOL_VERSION      NVSP_PROTOCOL_VERSION_1
-
-enum {
-       NVSP_MSG_TYPE_NONE = 0,
-
-       /* Init Messages */
-       NVSP_MSG_TYPE_INIT                      = 1,
-       NVSP_MSG_TYPE_INIT_COMPLETE             = 2,
-
-       NVSP_VERSION_MSG_START                  = 100,
-
-       /* Version 1 Messages */
-       NVSP_MSG1_TYPE_SEND_NDIS_VER            = NVSP_VERSION_MSG_START,
-
-       NVSP_MSG1_TYPE_SEND_RECV_BUF,
-       NVSP_MSG1_TYPE_SEND_RECV_BUF_COMPLETE,
-       NVSP_MSG1_TYPE_REVOKE_RECV_BUF,
-
-       NVSP_MSG1_TYPE_SEND_SEND_BUF,
-       NVSP_MSG1_TYPE_SEND_SEND_BUF_COMPLETE,
-       NVSP_MSG1_TYPE_REVOKE_SEND_BUF,
-
-       NVSP_MSG1_TYPE_SEND_RNDIS_PKT,
-       NVSP_MSG1_TYPE_SEND_RNDIS_PKT_COMPLETE,
-
-       /*
-        * This should be set to the number of messages for the version with
-        * the maximum number of messages.
-        */
-       NVSP_NUM_MSG_PER_VERSION                = 9,
-};
-
-enum {
-       NVSP_STAT_NONE = 0,
-       NVSP_STAT_SUCCESS,
-       NVSP_STAT_FAIL,
-       NVSP_STAT_PROTOCOL_TOO_NEW,
-       NVSP_STAT_PROTOCOL_TOO_OLD,
-       NVSP_STAT_INVALID_RNDIS_PKT,
-       NVSP_STAT_BUSY,
-       NVSP_STAT_MAX,
-};
-
-struct nvsp_message_header {
-       u32 msg_type;
-};
-
-/* Init Messages */
-
-/*
- * This message is used by the VSC to initialize the channel after the channels
- * has been opened. This message should never include anything other then
- * versioning (i.e. this message will be the same for ever).
- */
-struct nvsp_message_init {
-       u32 min_protocol_ver;
-       u32 max_protocol_ver;
-} __packed;
-
-/*
- * This message is used by the VSP to complete the initialization of the
- * channel. This message should never include anything other then versioning
- * (i.e. this message will be the same for ever).
- */
-struct nvsp_message_init_complete {
-       u32 negotiated_protocol_ver;
-       u32 max_mdl_chain_len;
-       u32 status;
-} __packed;
-
-union nvsp_message_init_uber {
-       struct nvsp_message_init init;
-       struct nvsp_message_init_complete init_complete;
-} __packed;
-
-/* Version 1 Messages */
-
-/*
- * This message is used by the VSC to send the NDIS version to the VSP. The VSP
- * can use this information when handling OIDs sent by the VSC.
- */
-struct nvsp_1_message_send_ndis_version {
-       u32 ndis_major_ver;
-       u32 ndis_minor_ver;
-} __packed;
-
-/*
- * This message is used by the VSC to send a receive buffer to the VSP. The VSP
- * can then use the receive buffer to send data to the VSC.
- */
-struct nvsp_1_message_send_receive_buffer {
-       u32 gpadl_handle;
-       u16 id;
-} __packed;
-
-struct nvsp_1_receive_buffer_section {
-       u32 offset;
-       u32 sub_alloc_size;
-       u32 num_sub_allocs;
-       u32 end_offset;
-} __packed;
-
-/*
- * This message is used by the VSP to acknowledge a receive buffer send by the
- * VSC. This message must be sent by the VSP before the VSP uses the receive
- * buffer.
- */
-struct nvsp_1_message_send_receive_buffer_complete {
-       u32 status;
-       u32 num_sections;
-
-       /*
-        * The receive buffer is split into two parts, a large suballocation
-        * section and a small suballocation section. These sections are then
-        * suballocated by a certain size.
-        */
-
-       /*
-        * For example, the following break up of the receive buffer has 6
-        * large suballocations and 10 small suballocations.
-        */
-
-       /*
-        * |            Large Section          |  |   Small Section   |
-        * ------------------------------------------------------------
-        * |     |     |     |     |     |     |  | | | | | | | | | | |
-        * |                                      |
-        *  LargeOffset                            SmallOffset
-        */
-
-       struct nvsp_1_receive_buffer_section sections[1];
-} __packed;
-
-/*
- * This message is sent by the VSC to revoke the receive buffer.  After the VSP
- * completes this transaction, the vsp should never use the receive buffer
- * again.
- */
-struct nvsp_1_message_revoke_receive_buffer {
-       u16 id;
-};
-
-/*
- * This message is used by the VSC to send a send buffer to the VSP. The VSC
- * can then use the send buffer to send data to the VSP.
- */
-struct nvsp_1_message_send_send_buffer {
-       u32 gpadl_handle;
-       u16 id;
-} __packed;
-
-/*
- * This message is used by the VSP to acknowledge a send buffer sent by the
- * VSC. This message must be sent by the VSP before the VSP uses the sent
- * buffer.
- */
-struct nvsp_1_message_send_send_buffer_complete {
-       u32 status;
-
-       /*
-        * The VSC gets to choose the size of the send buffer and the VSP gets
-        * to choose the sections size of the buffer.  This was done to enable
-        * dynamic reconfigurations when the cost of GPA-direct buffers
-        * decreases.
-        */
-       u32 section_size;
-} __packed;
-
-/*
- * This message is sent by the VSC to revoke the send buffer.  After the VSP
- * completes this transaction, the vsp should never use the send buffer again.
- */
-struct nvsp_1_message_revoke_send_buffer {
-       u16 id;
-};
-
-/*
- * This message is used by both the VSP and the VSC to send a RNDIS message to
- * the opposite channel endpoint.
- */
-struct nvsp_1_message_send_rndis_packet {
-       /*
-        * This field is specified by RNIDS. They assume there's two different
-        * channels of communication. However, the Network VSP only has one.
-        * Therefore, the channel travels with the RNDIS packet.
-        */
-       u32 channel_type;
-
-       /*
-        * This field is used to send part or all of the data through a send
-        * buffer. This values specifies an index into the send buffer. If the
-        * index is 0xFFFFFFFF, then the send buffer is not being used and all
-        * of the data was sent through other VMBus mechanisms.
-        */
-       u32 send_buf_section_index;
-       u32 send_buf_section_size;
-} __packed;
-
-/*
- * This message is used by both the VSP and the VSC to complete a RNDIS message
- * to the opposite channel endpoint. At this point, the initiator of this
- * message cannot use any resources associated with the original RNDIS packet.
- */
-struct nvsp_1_message_send_rndis_packet_complete {
-       u32 status;
-};
-
-union nvsp_1_message_uber {
-       struct nvsp_1_message_send_ndis_version send_ndis_ver;
-
-       struct nvsp_1_message_send_receive_buffer send_recv_buf;
-       struct nvsp_1_message_send_receive_buffer_complete
-                                               send_recv_buf_complete;
-       struct nvsp_1_message_revoke_receive_buffer revoke_recv_buf;
-
-       struct nvsp_1_message_send_send_buffer send_send_buf;
-       struct nvsp_1_message_send_send_buffer_complete send_send_buf_complete;
-       struct nvsp_1_message_revoke_send_buffer revoke_send_buf;
-
-       struct nvsp_1_message_send_rndis_packet send_rndis_pkt;
-       struct nvsp_1_message_send_rndis_packet_complete
-                                               send_rndis_pkt_complete;
-} __packed;
-
-union nvsp_all_messages {
-       union nvsp_message_init_uber init_msg;
-       union nvsp_1_message_uber v1_msg;
-} __packed;
-
-/* ALL Messages */
-struct nvsp_message {
-       struct nvsp_message_header hdr;
-       union nvsp_all_messages msg;
-} __packed;
-
-
-
-
-/* #define NVSC_MIN_PROTOCOL_VERSION           1 */
-/* #define NVSC_MAX_PROTOCOL_VERSION           1 */
-
-#define NETVSC_SEND_BUFFER_SIZE                        (64*1024)       /* 64K */
-#define NETVSC_SEND_BUFFER_ID                  0xface
-
-
-#define NETVSC_RECEIVE_BUFFER_SIZE             (1024*1024)     /* 1MB */
-
-#define NETVSC_RECEIVE_BUFFER_ID               0xcafe
-
-#define NETVSC_RECEIVE_SG_COUNT                        1
-
-/* Preallocated receive packets */
-#define NETVSC_RECEIVE_PACKETLIST_COUNT                256
-
-#define NETVSC_PACKET_SIZE                      2048
-
-/* Per netvsc channel-specific */
-struct netvsc_device {
-       struct hv_device *dev;
-
-       atomic_t refcnt;
-       atomic_t num_outstanding_sends;
-       /*
-        * List of free preallocated hv_netvsc_packet to represent receive
-        * packet
-        */
-       struct list_head recv_pkt_list;
-       spinlock_t recv_pkt_list_lock;
-
-       /* Send buffer allocated by us but manages by NetVSP */
-       void *send_buf;
-       u32 send_buf_size;
-       u32 send_buf_gpadl_handle;
-       u32 send_section_size;
-
-       /* Receive buffer allocated by us but manages by NetVSP */
-       void *recv_buf;
-       u32 recv_buf_size;
-       u32 recv_buf_gpadl_handle;
-       u32 recv_section_cnt;
-       struct nvsp_1_receive_buffer_section *recv_section;
-
-       /* Used for NetVSP initialization protocol */
-       int wait_condition;
-       wait_queue_head_t channel_init_wait;
-       struct nvsp_message channel_init_pkt;
-
-       struct nvsp_message revoke_packet;
-       /* unsigned char HwMacAddr[HW_MACADDR_LEN]; */
-
-       /* Holds rndis device info */
-       void *extension;
-};
-
-#endif /* _NETVSC_H_ */
diff --git a/drivers/staging/hv/netvsc_api.h b/drivers/staging/hv/netvsc_api.h
deleted file mode 100644 (file)
index b4bed36..0000000
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- *
- * Copyright (c) 2009, Microsoft Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place - Suite 330, Boston, MA 02111-1307 USA.
- *
- * Authors:
- *   Haiyang Zhang <haiyangz@microsoft.com>
- *   Hank Janssen  <hjanssen@microsoft.com>
- *
- */
-
-
-#ifndef _NETVSC_API_H_
-#define _NETVSC_API_H_
-
-#include "vmbus_api.h"
-
-/* Fwd declaration */
-struct hv_netvsc_packet;
-
-/* Represent the xfer page packet which contains 1 or more netvsc packet */
-struct xferpage_packet {
-       struct list_head list_ent;
-
-       /* # of netvsc packets this xfer packet contains */
-       u32 count;
-};
-
-/* The number of pages which are enough to cover jumbo frame buffer. */
-#define NETVSC_PACKET_MAXPAGE          4
-
-/*
- * Represent netvsc packet which contains 1 RNDIS and 1 ethernet frame
- * within the RNDIS
- */
-struct hv_netvsc_packet {
-       /* Bookkeeping stuff */
-       struct list_head list_ent;
-
-       struct hv_device *device;
-       bool is_data_pkt;
-
-       /*
-        * Valid only for receives when we break a xfer page packet
-        * into multiple netvsc packets
-        */
-       struct xferpage_packet *xfer_page_pkt;
-
-       union {
-               struct{
-                       u64 recv_completion_tid;
-                       void *recv_completion_ctx;
-                       void (*recv_completion)(void *context);
-               } recv;
-               struct{
-                       u64 send_completion_tid;
-                       void *send_completion_ctx;
-                       void (*send_completion)(void *context);
-               } send;
-       } completion;
-
-       /* This points to the memory after page_buf */
-       void *extension;
-
-       u32 total_data_buflen;
-       /* Points to the send/receive buffer where the ethernet frame is */
-       u32 page_buf_cnt;
-       struct hv_page_buffer page_buf[NETVSC_PACKET_MAXPAGE];
-};
-
-/* Represents the net vsc driver */
-struct netvsc_driver {
-       /* Must be the first field */
-       /* Which is a bug FIXME! */
-       struct hv_driver base;
-
-       u32 ring_buf_size;
-       u32 req_ext_size;
-
-       /*
-        * This is set by the caller to allow us to callback when we
-        * receive a packet from the "wire"
-        */
-       int (*recv_cb)(struct hv_device *dev,
-                                struct hv_netvsc_packet *packet);
-       void (*link_status_change)(struct hv_device *dev, u32 status);
-
-       /* Specific to this driver */
-       int (*send)(struct hv_device *dev, struct hv_netvsc_packet *packet);
-
-       void *ctx;
-};
-
-struct netvsc_device_info {
-       unsigned char mac_adr[6];
-       bool link_state;        /* 0 - link up, 1 - link down */
-};
-
-/* Interface */
-int netvsc_initialize(struct hv_driver *drv);
-int rndis_filter_open(struct hv_device *dev);
-int rndis_filter_close(struct hv_device *dev);
-
-#endif /* _NETVSC_API_H_ */
index aaa81883f0ada8bdee48388a1af0ae50c02be0e3..7b9c229f7295a0a6b50a16d78d7ba19a818557e8 100644 (file)
@@ -18,6 +18,8 @@
  *   Haiyang Zhang <haiyangz@microsoft.com>
  *   Hank Janssen  <hjanssen@microsoft.com>
  */
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/highmem.h>
 #include <net/route.h>
 #include <net/sock.h>
 #include <net/pkt_sched.h>
-#include "hv_api.h"
-#include "logging.h"
-#include "version_info.h"
-#include "vmbus.h"
-#include "netvsc_api.h"
+
+#include "hyperv.h"
+#include "hyperv_net.h"
 
 struct net_device_context {
        /* point back to our device context */
@@ -58,9 +58,6 @@ static int ring_size = 128;
 module_param(ring_size, int, S_IRUGO);
 MODULE_PARM_DESC(ring_size, "Ring buffer size (# of pages)");
 
-/* The one and only one */
-static struct  netvsc_driver g_netvsc_drv;
-
 /* no-op so the netdev core doesn't return -EINVAL when modifying the the
  * multicast address list in SIOCADDMULTI. hv is setup to get all multicast
  * when it calls RndisFilterOnOpen() */
@@ -78,14 +75,14 @@ static int netvsc_open(struct net_device *net)
                /* Open up the device */
                ret = rndis_filter_open(device_obj);
                if (ret != 0) {
-                       DPRINT_ERR(NETVSC_DRV,
-                                  "unable to open device (ret %d).", ret);
+                       netdev_err(net, "unable to open device (ret %d).\n",
+                                  ret);
                        return ret;
                }
 
                netif_start_queue(net);
        } else {
-               DPRINT_ERR(NETVSC_DRV, "unable to open device...link is down.");
+               netdev_err(net, "unable to open device...link is down.\n");
        }
 
        return ret;
@@ -101,7 +98,7 @@ static int netvsc_close(struct net_device *net)
 
        ret = rndis_filter_close(device_obj);
        if (ret != 0)
-               DPRINT_ERR(NETVSC_DRV, "unable to close device (ret %d).", ret);
+               netdev_err(net, "unable to close device (ret %d).\n", ret);
 
        return ret;
 }
@@ -130,16 +127,10 @@ static void netvsc_xmit_completion(void *context)
 static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net)
 {
        struct net_device_context *net_device_ctx = netdev_priv(net);
-       struct hv_driver *drv =
-           drv_to_hv_drv(net_device_ctx->device_ctx->device.driver);
-       struct netvsc_driver *net_drv_obj = drv->priv;
        struct hv_netvsc_packet *packet;
        int ret;
        unsigned int i, num_pages;
 
-       DPRINT_DBG(NETVSC_DRV, "xmit packet - len %d data_len %d",
-                  skb->len, skb->data_len);
-
        /* Add 1 for skb->data and additional one for RNDIS */
        num_pages = skb_shinfo(skb)->nr_frags + 1 + 1;
        if (num_pages > net_device_ctx->avail)
@@ -148,10 +139,10 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net)
        /* Allocate a netvsc packet based on # of frags. */
        packet = kzalloc(sizeof(struct hv_netvsc_packet) +
                         (num_pages * sizeof(struct hv_page_buffer)) +
-                        net_drv_obj->req_ext_size, GFP_ATOMIC);
+                        sizeof(struct rndis_filter_packet), GFP_ATOMIC);
        if (!packet) {
                /* out of memory, silently drop packet */
-               DPRINT_ERR(NETVSC_DRV, "unable to allocate hv_netvsc_packet");
+               netdev_err(net, "unable to allocate hv_netvsc_packet\n");
 
                dev_kfree_skb(skb);
                net->stats.tx_dropped++;
@@ -191,16 +182,12 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net)
        packet->completion.send.send_completion_ctx = packet;
        packet->completion.send.send_completion_tid = (unsigned long)skb;
 
-       ret = net_drv_obj->send(net_device_ctx->device_ctx,
+       ret = rndis_filter_send(net_device_ctx->device_ctx,
                                  packet);
        if (ret == 0) {
                net->stats.tx_bytes += skb->len;
                net->stats.tx_packets++;
 
-               DPRINT_DBG(NETVSC_DRV, "# of xmits %lu total size %lu",
-                          net->stats.tx_packets,
-                          net->stats.tx_bytes);
-
                net_device_ctx->avail -= num_pages;
                if (net_device_ctx->avail < PACKET_PAGES_LOWATER)
                        netif_stop_queue(net);
@@ -216,15 +203,15 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net)
 /*
  * netvsc_linkstatus_callback - Link up/down notification
  */
-static void netvsc_linkstatus_callback(struct hv_device *device_obj,
+void netvsc_linkstatus_callback(struct hv_device *device_obj,
                                       unsigned int status)
 {
        struct net_device *net = dev_get_drvdata(&device_obj->device);
        struct net_device_context *ndev_ctx;
 
        if (!net) {
-               DPRINT_ERR(NETVSC_DRV, "got link status but net device "
-                               "not initialized yet");
+               netdev_err(net, "got link status but net device "
+                               "not initialized yet\n");
                return;
        }
 
@@ -244,7 +231,7 @@ static void netvsc_linkstatus_callback(struct hv_device *device_obj,
  * netvsc_recv_callback -  Callback when we receive a packet from the
  * "wire" on the specified device.
  */
-static int netvsc_recv_callback(struct hv_device *device_obj,
+int netvsc_recv_callback(struct hv_device *device_obj,
                                struct hv_netvsc_packet *packet)
 {
        struct net_device *net = dev_get_drvdata(&device_obj->device);
@@ -254,8 +241,8 @@ static int netvsc_recv_callback(struct hv_device *device_obj,
        unsigned long flags;
 
        if (!net) {
-               DPRINT_ERR(NETVSC_DRV, "got receive callback but net device "
-                               "not initialized yet");
+               netdev_err(net, "got receive callback but net device"
+                       " not initialized yet\n");
                return 0;
        }
 
@@ -301,9 +288,6 @@ static int netvsc_recv_callback(struct hv_device *device_obj,
         */
        netif_rx(skb);
 
-       DPRINT_DBG(NETVSC_DRV, "# of recvs %lu total size %lu",
-                  net->stats.rx_packets, net->stats.rx_bytes);
-
        return 0;
 }
 
@@ -349,20 +333,13 @@ static void netvsc_send_garp(struct work_struct *w)
 }
 
 
-static int netvsc_probe(struct device *device)
+static int netvsc_probe(struct hv_device *dev)
 {
-       struct hv_driver *drv =
-               drv_to_hv_drv(device->driver);
-       struct netvsc_driver *net_drv_obj = drv->priv;
-       struct hv_device *device_obj = device_to_hv_device(device);
        struct net_device *net = NULL;
        struct net_device_context *net_device_ctx;
        struct netvsc_device_info device_info;
        int ret;
 
-       if (!net_drv_obj->base.dev_add)
-               return -1;
-
        net = alloc_etherdev(sizeof(struct net_device_context));
        if (!net)
                return -1;
@@ -371,19 +348,19 @@ static int netvsc_probe(struct device *device)
        netif_carrier_off(net);
 
        net_device_ctx = netdev_priv(net);
-       net_device_ctx->device_ctx = device_obj;
+       net_device_ctx->device_ctx = dev;
        net_device_ctx->avail = ring_size;
-       dev_set_drvdata(device, net);
+       dev_set_drvdata(&dev->device, net);
        INIT_WORK(&net_device_ctx->work, netvsc_send_garp);
 
        /* Notify the netvsc driver of the new device */
-       ret = net_drv_obj->base.dev_add(device_obj, &device_info);
+       device_info.ring_size = ring_size;
+       ret = rndis_filte_device_add(dev, &device_info);
        if (ret != 0) {
                free_netdev(net);
-               dev_set_drvdata(device, NULL);
+               dev_set_drvdata(&dev->device, NULL);
 
-               DPRINT_ERR(NETVSC_DRV, "unable to add netvsc device (ret %d)",
-                          ret);
+               netdev_err(net, "unable to add netvsc device (ret %d)\n", ret);
                return ret;
        }
 
@@ -408,35 +385,28 @@ static int netvsc_probe(struct device *device)
        net->features = NETIF_F_SG;
 
        SET_ETHTOOL_OPS(net, &ethtool_ops);
-       SET_NETDEV_DEV(net, device);
+       SET_NETDEV_DEV(net, &dev->device);
 
        ret = register_netdev(net);
        if (ret != 0) {
                /* Remove the device and release the resource */
-               net_drv_obj->base.dev_rm(device_obj);
+               rndis_filter_device_remove(dev);
                free_netdev(net);
        }
 
        return ret;
 }
 
-static int netvsc_remove(struct device *device)
+static int netvsc_remove(struct hv_device *dev)
 {
-       struct hv_driver *drv =
-               drv_to_hv_drv(device->driver);
-       struct netvsc_driver *net_drv_obj = drv->priv;
-       struct hv_device *device_obj = device_to_hv_device(device);
-       struct net_device *net = dev_get_drvdata(&device_obj->device);
+       struct net_device *net = dev_get_drvdata(&dev->device);
        int ret;
 
        if (net == NULL) {
-               DPRINT_INFO(NETVSC, "no net device to remove");
+               dev_err(&dev->device, "No net device to remove\n");
                return 0;
        }
 
-       if (!net_drv_obj->base.dev_rm)
-               return -1;
-
        /* Stop outbound asap */
        netif_stop_queue(net);
        /* netif_carrier_off(net); */
@@ -447,84 +417,27 @@ static int netvsc_remove(struct device *device)
         * Call to the vsc driver to let it know that the device is being
         * removed
         */
-       ret = net_drv_obj->base.dev_rm(device_obj);
+       ret = rndis_filter_device_remove(dev);
        if (ret != 0) {
                /* TODO: */
-               DPRINT_ERR(NETVSC, "unable to remove vsc device (ret %d)", ret);
+               netdev_err(net, "unable to remove vsc device (ret %d)\n", ret);
        }
 
        free_netdev(net);
        return ret;
 }
 
-static int netvsc_drv_exit_cb(struct device *dev, void *data)
-{
-       struct device **curr = (struct device **)data;
-
-       *curr = dev;
-       /* stop iterating */
-       return 1;
-}
+/* The one and only one */
+static struct  hv_driver netvsc_drv = {
+       .probe = netvsc_probe,
+       .remove = netvsc_remove,
+};
 
-static void netvsc_drv_exit(void)
+static void __exit netvsc_drv_exit(void)
 {
-       struct netvsc_driver *netvsc_drv_obj = &g_netvsc_drv;
-       struct hv_driver *drv = &g_netvsc_drv.base;
-       struct device *current_dev;
-       int ret;
-
-       while (1) {
-               current_dev = NULL;
-
-               /* Get the device */
-               ret = driver_for_each_device(&drv->driver, NULL,
-                                            &current_dev, netvsc_drv_exit_cb);
-               if (ret)
-                       DPRINT_WARN(NETVSC_DRV,
-                                   "driver_for_each_device returned %d", ret);
-
-               if (current_dev == NULL)
-                       break;
-
-               /* Initiate removal from the top-down */
-               DPRINT_INFO(NETVSC_DRV, "unregistering device (%p)...",
-                           current_dev);
-
-               device_unregister(current_dev);
-       }
-
-       if (netvsc_drv_obj->base.cleanup)
-               netvsc_drv_obj->base.cleanup(&netvsc_drv_obj->base);
-
-       vmbus_child_driver_unregister(&drv->driver);
-
-       return;
+       vmbus_child_driver_unregister(&netvsc_drv.driver);
 }
 
-static int netvsc_drv_init(int (*drv_init)(struct hv_driver *drv))
-{
-       struct netvsc_driver *net_drv_obj = &g_netvsc_drv;
-       struct hv_driver *drv = &g_netvsc_drv.base;
-       int ret;
-
-       net_drv_obj->ring_buf_size = ring_size * PAGE_SIZE;
-       net_drv_obj->recv_cb = netvsc_recv_callback;
-       net_drv_obj->link_status_change = netvsc_linkstatus_callback;
-       drv->priv = net_drv_obj;
-
-       /* Callback to client driver to complete the initialization */
-       drv_init(&net_drv_obj->base);
-
-       drv->driver.name = net_drv_obj->base.name;
-
-       drv->driver.probe = netvsc_probe;
-       drv->driver.remove = netvsc_remove;
-
-       /* The driver belongs to vmbus */
-       ret = vmbus_child_driver_register(&drv->driver);
-
-       return ret;
-}
 
 static const struct dmi_system_id __initconst
 hv_netvsc_dmi_table[] __maybe_unused  = {
@@ -540,19 +453,26 @@ hv_netvsc_dmi_table[] __maybe_unused  = {
 };
 MODULE_DEVICE_TABLE(dmi, hv_netvsc_dmi_table);
 
-static int __init netvsc_init(void)
+static int __init netvsc_drv_init(void)
 {
-       DPRINT_INFO(NETVSC_DRV, "Netvsc initializing....");
+       struct hv_driver *drv = &netvsc_drv;
+       int ret;
+
+       pr_info("initializing....");
 
        if (!dmi_check_system(hv_netvsc_dmi_table))
                return -ENODEV;
 
-       return netvsc_drv_init(netvsc_initialize);
-}
 
-static void __exit netvsc_exit(void)
-{
-       netvsc_drv_exit();
+       /* Callback to client driver to complete the initialization */
+       netvsc_initialize(drv);
+
+       drv->driver.name = drv->name;
+
+       /* The driver belongs to vmbus */
+       ret = vmbus_child_driver_register(&drv->driver);
+
+       return ret;
 }
 
 static const struct pci_device_id __initconst
@@ -566,5 +486,5 @@ MODULE_LICENSE("GPL");
 MODULE_VERSION(HV_DRV_VERSION);
 MODULE_DESCRIPTION("Microsoft Hyper-V network driver");
 
-module_init(netvsc_init);
-module_exit(netvsc_exit);
+module_init(netvsc_drv_init);
+module_exit(netvsc_drv_exit);
index 66688fb69741b4165cadaa9fdd0652e9b142cee2..3da333018b5a62869882ba236e38dc49b9bd5677 100644 (file)
  * Authors:
  *   Haiyang Zhang <haiyangz@microsoft.com>
  *   Hank Janssen  <hjanssen@microsoft.com>
+ *   K. Y. Srinivasan <kys@microsoft.com>
  *
  */
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
 #include <linux/kernel.h>
 #include <linux/mm.h>
-#include "logging.h"
-#include "ring_buffer.h"
+
+#include "hyperv.h"
+#include "hyperv_vmbus.h"
 
 
 /* #defines */
 #define BYTES_AVAIL_TO_WRITE(r, w, z) ((w) >= (r)) ? ((z) - ((w) - (r))) : ((r) - (w))
 
 
-/*++
-
-Name:
-       get_ringbuffer_availbytes()
-
-Description:
-       Get number of bytes available to read and to write to
-       for the specified ring buffer
-
---*/
+/*
+ *
+ * hv_get_ringbuffer_availbytes()
+ *
+ * Get number of bytes available to read and to write to
+ * for the specified ring buffer
+ */
 static inline void
-get_ringbuffer_availbytes(struct hv_ring_buffer_info *rbi,
+hv_get_ringbuffer_availbytes(struct hv_ring_buffer_info *rbi,
                          u32 *read, u32 *write)
 {
        u32 read_loc, write_loc;
@@ -58,162 +58,131 @@ get_ringbuffer_availbytes(struct hv_ring_buffer_info *rbi,
        *read = rbi->ring_datasize - *write;
 }
 
-/*++
-
-Name:
-       get_next_write_location()
-
-Description:
-       Get the next write location for the specified ring buffer
-
---*/
+/*
+ * hv_get_next_write_location()
+ *
+ * Get the next write location for the specified ring buffer
+ *
+ */
 static inline u32
-get_next_write_location(struct hv_ring_buffer_info *ring_info)
+hv_get_next_write_location(struct hv_ring_buffer_info *ring_info)
 {
        u32 next = ring_info->ring_buffer->write_index;
 
-       /* ASSERT(next < ring_info->RingDataSize); */
-
        return next;
 }
 
-/*++
-
-Name:
-       set_next_write_location()
-
-Description:
-       Set the next write location for the specified ring buffer
-
---*/
+/*
+ * hv_set_next_write_location()
+ *
+ * Set the next write location for the specified ring buffer
+ *
+ */
 static inline void
-set_next_write_location(struct hv_ring_buffer_info *ring_info,
+hv_set_next_write_location(struct hv_ring_buffer_info *ring_info,
                     u32 next_write_location)
 {
        ring_info->ring_buffer->write_index = next_write_location;
 }
 
-/*++
-
-Name:
-       get_next_read_location()
-
-Description:
-       Get the next read location for the specified ring buffer
-
---*/
+/*
+ * hv_get_next_read_location()
+ *
+ * Get the next read location for the specified ring buffer
+ */
 static inline u32
-get_next_read_location(struct hv_ring_buffer_info *ring_info)
+hv_get_next_read_location(struct hv_ring_buffer_info *ring_info)
 {
        u32 next = ring_info->ring_buffer->read_index;
 
-       /* ASSERT(next < ring_info->RingDataSize); */
-
        return next;
 }
 
-/*++
-
-Name:
-       get_next_readlocation_withoffset()
-
-Description:
-       Get the next read location + offset for the specified ring buffer.
-       This allows the caller to skip
-
---*/
+/*
+ * hv_get_next_readlocation_withoffset()
+ *
+ * Get the next read location + offset for the specified ring buffer.
+ * This allows the caller to skip
+ */
 static inline u32
-get_next_readlocation_withoffset(struct hv_ring_buffer_info *ring_info,
+hv_get_next_readlocation_withoffset(struct hv_ring_buffer_info *ring_info,
                                 u32 offset)
 {
        u32 next = ring_info->ring_buffer->read_index;
 
-       /* ASSERT(next < ring_info->RingDataSize); */
        next += offset;
        next %= ring_info->ring_datasize;
 
        return next;
 }
 
-/*++
-
-Name:
-       set_next_read_location()
-
-Description:
-       Set the next read location for the specified ring buffer
-
---*/
+/*
+ *
+ * hv_set_next_read_location()
+ *
+ * Set the next read location for the specified ring buffer
+ *
+ */
 static inline void
-set_next_read_location(struct hv_ring_buffer_info *ring_info,
+hv_set_next_read_location(struct hv_ring_buffer_info *ring_info,
                    u32 next_read_location)
 {
        ring_info->ring_buffer->read_index = next_read_location;
 }
 
 
-/*++
-
-Name:
-       get_ring_buffer()
-
-Description:
-       Get the start of the ring buffer
-
---*/
+/*
+ *
+ * hv_get_ring_buffer()
+ *
+ * Get the start of the ring buffer
+ */
 static inline void *
-get_ring_buffer(struct hv_ring_buffer_info *ring_info)
+hv_get_ring_buffer(struct hv_ring_buffer_info *ring_info)
 {
        return (void *)ring_info->ring_buffer->buffer;
 }
 
 
-/*++
-
-Name:
-       get_ring_buffersize()
-
-Description:
-       Get the size of the ring buffer
-
---*/
+/*
+ *
+ * hv_get_ring_buffersize()
+ *
+ * Get the size of the ring buffer
+ */
 static inline u32
-get_ring_buffersize(struct hv_ring_buffer_info *ring_info)
+hv_get_ring_buffersize(struct hv_ring_buffer_info *ring_info)
 {
        return ring_info->ring_datasize;
 }
 
-/*++
-
-Name:
-       get_ring_bufferindices()
-
-Description:
-       Get the read and write indices as u64 of the specified ring buffer
-
---*/
+/*
+ *
+ * hv_get_ring_bufferindices()
+ *
+ * Get the read and write indices as u64 of the specified ring buffer
+ *
+ */
 static inline u64
-get_ring_bufferindices(struct hv_ring_buffer_info *ring_info)
+hv_get_ring_bufferindices(struct hv_ring_buffer_info *ring_info)
 {
        return (u64)ring_info->ring_buffer->write_index << 32;
 }
 
 
-/*++
-
-Name:
-       dump_ring_info()
-
-Description:
-       Dump out to console the ring buffer info
-
---*/
-void dump_ring_info(struct hv_ring_buffer_info *ring_info, char *prefix)
+/*
+ *
+ * hv_dump_ring_info()
+ *
+ * Dump out to console the ring buffer info
+ *
+ */
+void hv_dump_ring_info(struct hv_ring_buffer_info *ring_info, char *prefix)
 {
        u32 bytes_avail_towrite;
        u32 bytes_avail_toread;
 
-       get_ringbuffer_availbytes(ring_info,
+       hv_get_ringbuffer_availbytes(ring_info,
        &bytes_avail_toread,
        &bytes_avail_towrite);
 
@@ -231,41 +200,90 @@ void dump_ring_info(struct hv_ring_buffer_info *ring_info, char *prefix)
 }
 
 
-/* Internal routines */
-
-static u32
-copyto_ringbuffer(
-       struct hv_ring_buffer_info      *ring_info,
-       u32                             start_write_offset,
-       void                            *src,
-       u32                             srclen);
-
-static u32
-copyfrom_ringbuffer(
+/*
+ *
+ * hv_copyfrom_ringbuffer()
+ *
+ * Helper routine to copy to source from ring buffer.
+ * Assume there is enough room. Handles wrap-around in src case only!!
+ *
+ */
+static u32 hv_copyfrom_ringbuffer(
        struct hv_ring_buffer_info      *ring_info,
        void                            *dest,
        u32                             destlen,
-       u32                             start_read_offset);
+       u32                             start_read_offset)
+{
+       void *ring_buffer = hv_get_ring_buffer(ring_info);
+       u32 ring_buffer_size = hv_get_ring_buffersize(ring_info);
 
+       u32 frag_len;
 
+       /* wrap-around detected at the src */
+       if (destlen > ring_buffer_size - start_read_offset) {
+               frag_len = ring_buffer_size - start_read_offset;
 
-/*++
+               memcpy(dest, ring_buffer + start_read_offset, frag_len);
+               memcpy(dest + frag_len, ring_buffer, destlen - frag_len);
+       } else
+
+               memcpy(dest, ring_buffer + start_read_offset, destlen);
+
+
+       start_read_offset += destlen;
+       start_read_offset %= ring_buffer_size;
+
+       return start_read_offset;
+}
+
+
+/*
+ *
+ * hv_copyto_ringbuffer()
+ *
+ * Helper routine to copy from source to ring buffer.
+ * Assume there is enough room. Handles wrap-around in dest case only!!
+ *
+ */
+static u32 hv_copyto_ringbuffer(
+       struct hv_ring_buffer_info      *ring_info,
+       u32                             start_write_offset,
+       void                            *src,
+       u32                             srclen)
+{
+       void *ring_buffer = hv_get_ring_buffer(ring_info);
+       u32 ring_buffer_size = hv_get_ring_buffersize(ring_info);
+       u32 frag_len;
+
+       /* wrap-around detected! */
+       if (srclen > ring_buffer_size - start_write_offset) {
+               frag_len = ring_buffer_size - start_write_offset;
+               memcpy(ring_buffer + start_write_offset, src, frag_len);
+               memcpy(ring_buffer, src + frag_len, srclen - frag_len);
+       } else
+               memcpy(ring_buffer + start_write_offset, src, srclen);
 
-Name:
-       ringbuffer_get_debuginfo()
+       start_write_offset += srclen;
+       start_write_offset %= ring_buffer_size;
 
-Description:
-       Get various debug metrics for the specified ring buffer
+       return start_write_offset;
+}
 
---*/
-void ringbuffer_get_debuginfo(struct hv_ring_buffer_info *ring_info,
+/*
+ *
+ * hv_ringbuffer_get_debuginfo()
+ *
+ * Get various debug metrics for the specified ring buffer
+ *
+ */
+void hv_ringbuffer_get_debuginfo(struct hv_ring_buffer_info *ring_info,
                            struct hv_ring_buffer_debug_info *debug_info)
 {
        u32 bytes_avail_towrite;
        u32 bytes_avail_toread;
 
        if (ring_info->ring_buffer) {
-               get_ringbuffer_availbytes(ring_info,
+               hv_get_ringbuffer_availbytes(ring_info,
                                        &bytes_avail_toread,
                                        &bytes_avail_towrite);
 
@@ -281,30 +299,26 @@ void ringbuffer_get_debuginfo(struct hv_ring_buffer_info *ring_info,
 }
 
 
-/*++
-
-Name:
-       get_ringbuffer_interrupt_mask()
-
-Description:
-       Get the interrupt mask for the specified ring buffer
-
---*/
-u32 get_ringbuffer_interrupt_mask(struct hv_ring_buffer_info *rbi)
+/*
+ *
+ * hv_get_ringbuffer_interrupt_mask()
+ *
+ * Get the interrupt mask for the specified ring buffer
+ *
+ */
+u32 hv_get_ringbuffer_interrupt_mask(struct hv_ring_buffer_info *rbi)
 {
        return rbi->ring_buffer->interrupt_mask;
 }
 
-/*++
-
-Name:
-       ringbuffer_init()
-
-Description:
-       Initialize the ring buffer
-
---*/
-int ringbuffer_init(struct hv_ring_buffer_info *ring_info,
+/*
+ *
+ * hv_ringbuffer_init()
+ *
+ *Initialize the ring buffer
+ *
+ */
+int hv_ringbuffer_init(struct hv_ring_buffer_info *ring_info,
                   void *buffer, u32 buflen)
 {
        if (sizeof(struct hv_ring_buffer) != PAGE_SIZE)
@@ -324,29 +338,25 @@ int ringbuffer_init(struct hv_ring_buffer_info *ring_info,
        return 0;
 }
 
-/*++
-
-Name:
-       ringbuffer_cleanup()
-
-Description:
-       Cleanup the ring buffer
-
---*/
-void ringbuffer_cleanup(struct hv_ring_buffer_info *ring_info)
+/*
+ *
+ * hv_ringbuffer_cleanup()
+ *
+ * Cleanup the ring buffer
+ *
+ */
+void hv_ringbuffer_cleanup(struct hv_ring_buffer_info *ring_info)
 {
 }
 
-/*++
-
-Name:
-       ringbuffer_write()
-
-Description:
-       Write to the ring buffer
-
---*/
-int ringbuffer_write(struct hv_ring_buffer_info *outring_info,
+/*
+ *
+ * hv_ringbuffer_write()
+ *
+ * Write to the ring buffer
+ *
+ */
+int hv_ringbuffer_write(struct hv_ring_buffer_info *outring_info,
                    struct scatterlist *sglist, u32 sgcount)
 {
        int i = 0;
@@ -355,7 +365,7 @@ int ringbuffer_write(struct hv_ring_buffer_info *outring_info,
        u32 totalbytes_towrite = 0;
 
        struct scatterlist *sg;
-       volatile u32 next_write_location;
+       u32 next_write_location;
        u64 prev_indices = 0;
        unsigned long flags;
 
@@ -368,43 +378,34 @@ int ringbuffer_write(struct hv_ring_buffer_info *outring_info,
 
        spin_lock_irqsave(&outring_info->ring_lock, flags);
 
-       get_ringbuffer_availbytes(outring_info,
+       hv_get_ringbuffer_availbytes(outring_info,
                                &bytes_avail_toread,
                                &bytes_avail_towrite);
 
-       DPRINT_DBG(VMBUS, "Writing %u bytes...", totalbytes_towrite);
-
-       /* Dumpring_info(Outring_info, "BEFORE "); */
 
        /* If there is only room for the packet, assume it is full. */
        /* Otherwise, the next time around, we think the ring buffer */
        /* is empty since the read index == write index */
        if (bytes_avail_towrite <= totalbytes_towrite) {
-               DPRINT_DBG(VMBUS,
-                       "No more space left on outbound ring buffer "
-                       "(needed %u, avail %u)",
-                       totalbytes_towrite,
-                       bytes_avail_towrite);
-
                spin_unlock_irqrestore(&outring_info->ring_lock, flags);
                return -1;
        }
 
        /* Write to the ring buffer */
-       next_write_location = get_next_write_location(outring_info);
+       next_write_location = hv_get_next_write_location(outring_info);
 
        for_each_sg(sglist, sg, sgcount, i)
        {
-               next_write_location = copyto_ringbuffer(outring_info,
+               next_write_location = hv_copyto_ringbuffer(outring_info,
                                                     next_write_location,
                                                     sg_virt(sg),
                                                     sg->length);
        }
 
        /* Set previous packet start */
-       prev_indices = get_ring_bufferindices(outring_info);
+       prev_indices = hv_get_ring_bufferindices(outring_info);
 
-       next_write_location = copyto_ringbuffer(outring_info,
+       next_write_location = hv_copyto_ringbuffer(outring_info,
                                             next_write_location,
                                             &prev_indices,
                                             sizeof(u64));
@@ -413,25 +414,22 @@ int ringbuffer_write(struct hv_ring_buffer_info *outring_info,
        mb();
 
        /* Now, update the write location */
-       set_next_write_location(outring_info, next_write_location);
+       hv_set_next_write_location(outring_info, next_write_location);
 
-       /* Dumpring_info(Outring_info, "AFTER "); */
 
        spin_unlock_irqrestore(&outring_info->ring_lock, flags);
        return 0;
 }
 
 
-/*++
-
-Name:
-       ringbuffer_peek()
-
-Description:
-       Read without advancing the read index
-
---*/
-int ringbuffer_peek(struct hv_ring_buffer_info *Inring_info,
+/*
+ *
+ * hv_ringbuffer_peek()
+ *
+ * Read without advancing the read index
+ *
+ */
+int hv_ringbuffer_peek(struct hv_ring_buffer_info *Inring_info,
                   void *Buffer, u32 buflen)
 {
        u32 bytes_avail_towrite;
@@ -441,17 +439,12 @@ int ringbuffer_peek(struct hv_ring_buffer_info *Inring_info,
 
        spin_lock_irqsave(&Inring_info->ring_lock, flags);
 
-       get_ringbuffer_availbytes(Inring_info,
+       hv_get_ringbuffer_availbytes(Inring_info,
                                &bytes_avail_toread,
                                &bytes_avail_towrite);
 
        /* Make sure there is something to read */
        if (bytes_avail_toread < buflen) {
-               /* DPRINT_DBG(VMBUS,
-                       "got callback but not enough to read "
-                       "<avail to read %d read size %d>!!",
-                       bytes_avail_toread,
-                       BufferLen); */
 
                spin_unlock_irqrestore(&Inring_info->ring_lock, flags);
 
@@ -459,9 +452,9 @@ int ringbuffer_peek(struct hv_ring_buffer_info *Inring_info,
        }
 
        /* Convert to byte offset */
-       next_read_location = get_next_read_location(Inring_info);
+       next_read_location = hv_get_next_read_location(Inring_info);
 
-       next_read_location = copyfrom_ringbuffer(Inring_info,
+       next_read_location = hv_copyfrom_ringbuffer(Inring_info,
                                                Buffer,
                                                buflen,
                                                next_read_location);
@@ -472,16 +465,14 @@ int ringbuffer_peek(struct hv_ring_buffer_info *Inring_info,
 }
 
 
-/*++
-
-Name:
-       ringbuffer_read()
-
-Description:
-       Read and advance the read index
-
---*/
-int ringbuffer_read(struct hv_ring_buffer_info *inring_info, void *buffer,
+/*
+ *
+ * hv_ringbuffer_read()
+ *
+ * Read and advance the read index
+ *
+ */
+int hv_ringbuffer_read(struct hv_ring_buffer_info *inring_info, void *buffer,
                   u32 buflen, u32 offset)
 {
        u32 bytes_avail_towrite;
@@ -495,36 +486,26 @@ int ringbuffer_read(struct hv_ring_buffer_info *inring_info, void *buffer,
 
        spin_lock_irqsave(&inring_info->ring_lock, flags);
 
-       get_ringbuffer_availbytes(inring_info,
+       hv_get_ringbuffer_availbytes(inring_info,
                                &bytes_avail_toread,
                                &bytes_avail_towrite);
 
-       DPRINT_DBG(VMBUS, "Reading %u bytes...", buflen);
-
-       /* Dumpring_info(Inring_info, "BEFORE "); */
-
        /* Make sure there is something to read */
        if (bytes_avail_toread < buflen) {
-               DPRINT_DBG(VMBUS,
-                       "got callback but not enough to read "
-                       "<avail to read %d read size %d>!!",
-                       bytes_avail_toread,
-                       buflen);
-
                spin_unlock_irqrestore(&inring_info->ring_lock, flags);
 
                return -1;
        }
 
        next_read_location =
-               get_next_readlocation_withoffset(inring_info, offset);
+               hv_get_next_readlocation_withoffset(inring_info, offset);
 
-       next_read_location = copyfrom_ringbuffer(inring_info,
+       next_read_location = hv_copyfrom_ringbuffer(inring_info,
                                                buffer,
                                                buflen,
                                                next_read_location);
 
-       next_read_location = copyfrom_ringbuffer(inring_info,
+       next_read_location = hv_copyfrom_ringbuffer(inring_info,
                                                &prev_indices,
                                                sizeof(u64),
                                                next_read_location);
@@ -535,94 +516,9 @@ int ringbuffer_read(struct hv_ring_buffer_info *inring_info, void *buffer,
        mb();
 
        /* Update the read index */
-       set_next_read_location(inring_info, next_read_location);
-
-       /* Dumpring_info(Inring_info, "AFTER "); */
+       hv_set_next_read_location(inring_info, next_read_location);
 
        spin_unlock_irqrestore(&inring_info->ring_lock, flags);
 
        return 0;
 }
-
-
-/*++
-
-Name:
-       copyto_ringbuffer()
-
-Description:
-       Helper routine to copy from source to ring buffer.
-       Assume there is enough room. Handles wrap-around in dest case only!!
-
---*/
-static u32
-copyto_ringbuffer(
-       struct hv_ring_buffer_info      *ring_info,
-       u32                             start_write_offset,
-       void                            *src,
-       u32                             srclen)
-{
-       void *ring_buffer = get_ring_buffer(ring_info);
-       u32 ring_buffer_size = get_ring_buffersize(ring_info);
-       u32 frag_len;
-
-       /* wrap-around detected! */
-       if (srclen > ring_buffer_size - start_write_offset) {
-               DPRINT_DBG(VMBUS, "wrap-around detected!");
-
-               frag_len = ring_buffer_size - start_write_offset;
-               memcpy(ring_buffer + start_write_offset, src, frag_len);
-               memcpy(ring_buffer, src + frag_len, srclen - frag_len);
-       } else
-               memcpy(ring_buffer + start_write_offset, src, srclen);
-
-       start_write_offset += srclen;
-       start_write_offset %= ring_buffer_size;
-
-       return start_write_offset;
-}
-
-
-/*++
-
-Name:
-       copyfrom_ringbuffer()
-
-Description:
-       Helper routine to copy to source from ring buffer.
-       Assume there is enough room. Handles wrap-around in src case only!!
-
---*/
-static u32
-copyfrom_ringbuffer(
-       struct hv_ring_buffer_info      *ring_info,
-       void                            *dest,
-       u32                             destlen,
-       u32                             start_read_offset)
-{
-       void *ring_buffer = get_ring_buffer(ring_info);
-       u32 ring_buffer_size = get_ring_buffersize(ring_info);
-
-       u32 frag_len;
-
-       /* wrap-around detected at the src */
-       if (destlen > ring_buffer_size - start_read_offset) {
-               DPRINT_DBG(VMBUS, "src wrap-around detected!");
-
-               frag_len = ring_buffer_size - start_read_offset;
-
-               memcpy(dest, ring_buffer + start_read_offset, frag_len);
-               memcpy(dest + frag_len, ring_buffer, destlen - frag_len);
-       } else
-
-               memcpy(dest, ring_buffer + start_read_offset, destlen);
-
-
-       start_read_offset += destlen;
-       start_read_offset %= ring_buffer_size;
-
-       return start_read_offset;
-}
-
-
-/* eof */
diff --git a/drivers/staging/hv/ring_buffer.h b/drivers/staging/hv/ring_buffer.h
deleted file mode 100644 (file)
index 7bf20d6..0000000
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- *
- * Copyright (c) 2009, Microsoft Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place - Suite 330, Boston, MA 02111-1307 USA.
- *
- * Authors:
- *   Haiyang Zhang <haiyangz@microsoft.com>
- *   Hank Janssen  <hjanssen@microsoft.com>
- *
- */
-
-
-#ifndef _RING_BUFFER_H_
-#define _RING_BUFFER_H_
-
-#include <linux/scatterlist.h>
-
-struct hv_ring_buffer {
-       /* Offset in bytes from the start of ring data below */
-       volatile u32 write_index;
-
-       /* Offset in bytes from the start of ring data below */
-       volatile u32 read_index;
-
-       volatile u32 interrupt_mask;
-
-       /* Pad it to PAGE_SIZE so that data starts on page boundary */
-       u8      reserved[4084];
-
-       /* NOTE:
-        * The interrupt_mask field is used only for channels but since our
-        * vmbus connection also uses this data structure and its data starts
-        * here, we commented out this field.
-        */
-       /* volatile u32 InterruptMask; */
-
-       /*
-        * Ring data starts here + RingDataStartOffset
-        * !!! DO NOT place any fields below this !!!
-        */
-       u8 buffer[0];
-} __packed;
-
-struct hv_ring_buffer_info {
-       struct hv_ring_buffer *ring_buffer;
-       u32 ring_size;                  /* Include the shared header */
-       spinlock_t ring_lock;
-
-       u32 ring_datasize;              /* < ring_size */
-       u32 ring_data_startoffset;
-};
-
-struct hv_ring_buffer_debug_info {
-       u32 current_interrupt_mask;
-       u32 current_read_index;
-       u32 current_write_index;
-       u32 bytes_avail_toread;
-       u32 bytes_avail_towrite;
-};
-
-
-
-/* Interface */
-
-
-int ringbuffer_init(struct hv_ring_buffer_info *ring_info, void *buffer,
-                  u32 buflen);
-
-void ringbuffer_cleanup(struct hv_ring_buffer_info *ring_info);
-
-int ringbuffer_write(struct hv_ring_buffer_info *ring_info,
-                   struct scatterlist *sglist,
-                   u32 sgcount);
-
-int ringbuffer_peek(struct hv_ring_buffer_info *ring_info, void *buffer,
-                  u32 buflen);
-
-int ringbuffer_read(struct hv_ring_buffer_info *ring_info,
-                  void *buffer,
-                  u32 buflen,
-                  u32 offset);
-
-u32 get_ringbuffer_interrupt_mask(struct hv_ring_buffer_info *ring_info);
-
-void dump_ring_info(struct hv_ring_buffer_info *ring_info, char *prefix);
-
-void ringbuffer_get_debuginfo(struct hv_ring_buffer_info *ring_info,
-                           struct hv_ring_buffer_debug_info *debug_info);
-
-#endif /* _RING_BUFFER_H_ */
index 048376b2b676bb2479417c4e6db7e0034b99e2ab..60ebdb1b6082b33f1a993b1b6928da599df4c1fc 100644 (file)
 #include <linux/slab.h>
 #include <linux/io.h>
 #include <linux/if_ether.h>
+#include <linux/netdevice.h>
 
-#include "logging.h"
-#include "hv_api.h"
-#include "netvsc_api.h"
-#include "rndis_filter.h"
+#include "hyperv.h"
+#include "hyperv_net.h"
 
-/* Data types */
-struct rndis_filter_driver_object {
-       /* The original driver */
-       struct netvsc_driver inner_drv;
-};
 
 enum rndis_device_state {
        RNDIS_DEV_UNINITIALIZED = 0,
@@ -59,8 +53,7 @@ struct rndis_device {
 
 struct rndis_request {
        struct list_head list_ent;
-       int wait_condition;
-       wait_queue_head_t wait_event;
+       struct completion  wait_event;
 
        /*
         * FIXME: We assumed a fixed size response here. If we do ever need to
@@ -76,31 +69,11 @@ struct rndis_request {
        struct rndis_message request_msg;
 };
 
-
-struct rndis_filter_packet {
-       void *completion_ctx;
-       void (*completion)(void *context);
-       struct rndis_message msg;
-};
-
-
-static int rndis_filte_device_add(struct hv_device *dev,
-                                 void *additional_info);
-
-static int rndis_filter_device_remove(struct hv_device *dev);
-
-static void rndis_filter_cleanup(struct hv_driver *drv);
-
-static int rndis_filter_send(struct hv_device *dev,
-                            struct hv_netvsc_packet *pkt);
-
 static void rndis_filter_send_completion(void *ctx);
 
 static void rndis_filter_send_request_completion(void *ctx);
 
 
-/* The one and only */
-static struct rndis_filter_driver_object rndis_filter;
 
 static struct rndis_device *get_rndis_device(void)
 {
@@ -132,7 +105,7 @@ static struct rndis_request *get_rndis_request(struct rndis_device *dev,
        if (!request)
                return NULL;
 
-       init_waitqueue_head(&request->wait_event);
+       init_completion(&request->wait_event);
 
        rndis_msg = &request->request_msg;
        rndis_msg->ndis_msg_type = msg_type;
@@ -264,7 +237,7 @@ static int rndis_filter_send_request(struct rndis_device *dev,
                rndis_filter_send_request_completion;
        packet->completion.send.send_completion_tid = (unsigned long)dev;
 
-       ret = rndis_filter.inner_drv.send(dev->net_dev->dev, packet);
+       ret = netvsc_send(dev->net_dev->dev, packet);
        return ret;
 }
 
@@ -283,14 +256,6 @@ static void rndis_filter_receive_response(struct rndis_device *dev,
                 */
                if (request->request_msg.msg.init_req.req_id
                    == resp->msg.init_complete.req_id) {
-                       DPRINT_DBG(NETVSC, "found rndis request for "
-                               "this response (id 0x%x req type 0x%x res "
-                               "type 0x%x)",
-                               request->request_msg.msg.
-                                  init_req.req_id,
-                               request->request_msg.ndis_msg_type,
-                               resp->ndis_msg_type);
-
                        found = true;
                        break;
                }
@@ -302,10 +267,11 @@ static void rndis_filter_receive_response(struct rndis_device *dev,
                        memcpy(&request->response_msg, resp,
                               resp->msg_len);
                } else {
-                       DPRINT_ERR(NETVSC, "rndis response buffer overflow "
-                                 "detected (size %u max %zu)",
-                                 resp->msg_len,
-                                 sizeof(struct rndis_filter_packet));
+                       dev_err(&dev->net_dev->dev->device,
+                               "rndis response buffer overflow "
+                               "detected (size %u max %zu)\n",
+                               resp->msg_len,
+                               sizeof(struct rndis_filter_packet));
 
                        if (resp->ndis_msg_type ==
                            REMOTE_NDIS_RESET_CMPLT) {
@@ -319,13 +285,13 @@ static void rndis_filter_receive_response(struct rndis_device *dev,
                        }
                }
 
-               request->wait_condition = 1;
-               wake_up(&request->wait_event);
+               complete(&request->wait_event);
        } else {
-               DPRINT_ERR(NETVSC, "no rndis request found for this response "
-                          "(id 0x%x res type 0x%x)",
-                          resp->msg.init_complete.req_id,
-                          resp->ndis_msg_type);
+               dev_err(&dev->net_dev->dev->device,
+                       "no rndis request found for this response "
+                       "(id 0x%x res type 0x%x)\n",
+                       resp->msg.init_complete.req_id,
+                       resp->ndis_msg_type);
        }
 }
 
@@ -336,10 +302,10 @@ static void rndis_filter_receive_indicate_status(struct rndis_device *dev,
                        &resp->msg.indicate_status;
 
        if (indicate->status == RNDIS_STATUS_MEDIA_CONNECT) {
-               rndis_filter.inner_drv.link_status_change(
+               netvsc_linkstatus_callback(
                        dev->net_dev->dev, 1);
        } else if (indicate->status == RNDIS_STATUS_MEDIA_DISCONNECT) {
-               rndis_filter.inner_drv.link_status_change(
+               netvsc_linkstatus_callback(
                        dev->net_dev->dev, 0);
        } else {
                /*
@@ -371,11 +337,10 @@ static void rndis_filter_receive_data(struct rndis_device *dev,
 
        pkt->is_data_pkt = true;
 
-       rndis_filter.inner_drv.recv_cb(dev->net_dev->dev,
-                                                  pkt);
+       netvsc_recv_callback(dev->net_dev->dev, pkt);
 }
 
-static int rndis_filter_receive(struct hv_device *dev,
+int rndis_filter_receive(struct hv_device *dev,
                                struct hv_netvsc_packet *pkt)
 {
        struct netvsc_device *net_dev = dev->ext;
@@ -388,15 +353,15 @@ static int rndis_filter_receive(struct hv_device *dev,
 
        /* Make sure the rndis device state is initialized */
        if (!net_dev->extension) {
-               DPRINT_ERR(NETVSC, "got rndis message but no rndis device..."
-                         "dropping this message!");
+               dev_err(&dev->device, "got rndis message but no rndis device - "
+                         "dropping this message!\n");
                return -1;
        }
 
        rndis_dev = (struct rndis_device *)net_dev->extension;
        if (rndis_dev->state == RNDIS_DEV_UNINITIALIZED) {
-               DPRINT_ERR(NETVSC, "got rndis message but rndis device "
-                          "uninitialized...dropping this message!");
+               dev_err(&dev->device, "got rndis message but rndis device "
+                          "uninitialized...dropping this message!\n");
                return -1;
        }
 
@@ -417,8 +382,8 @@ static int rndis_filter_receive(struct hv_device *dev,
                kunmap_atomic(rndis_hdr - pkt->page_buf[0].offset,
                              KM_IRQ0);
 
-               DPRINT_ERR(NETVSC, "invalid rndis message? (expected %u "
-                          "bytes got %u)...dropping this message!",
+               dev_err(&dev->device, "invalid rndis message? (expected %u "
+                          "bytes got %u)...dropping this message!\n",
                           rndis_hdr->msg_len,
                           pkt->total_data_buflen);
                return -1;
@@ -427,8 +392,8 @@ static int rndis_filter_receive(struct hv_device *dev,
 
        if ((rndis_hdr->ndis_msg_type != REMOTE_NDIS_PACKET_MSG) &&
            (rndis_hdr->msg_len > sizeof(struct rndis_message))) {
-               DPRINT_ERR(NETVSC, "incoming rndis message buffer overflow "
-                          "detected (got %u, max %zu)...marking it an error!",
+               dev_err(&dev->device, "incoming rndis message buffer overflow "
+                          "detected (got %u, max %zu)..marking it an error!\n",
                           rndis_hdr->msg_len,
                           sizeof(struct rndis_message));
        }
@@ -460,7 +425,8 @@ static int rndis_filter_receive(struct hv_device *dev,
                rndis_filter_receive_indicate_status(rndis_dev, &rndis_msg);
                break;
        default:
-               DPRINT_ERR(NETVSC, "unhandled rndis message (type %u len %u)",
+               dev_err(&dev->device,
+                       "unhandled rndis message (type %u len %u)\n",
                           rndis_msg.ndis_msg_type,
                           rndis_msg.msg_len);
                break;
@@ -477,6 +443,7 @@ static int rndis_filter_query_device(struct rndis_device *dev, u32 oid,
        struct rndis_query_request *query;
        struct rndis_query_complete *query_complete;
        int ret = 0;
+       int t;
 
        if (!result)
                return -EINVAL;
@@ -496,14 +463,12 @@ static int rndis_filter_query_device(struct rndis_device *dev, u32 oid,
        query->info_buflen = 0;
        query->dev_vc_handle = 0;
 
-       request->wait_condition = 0;
        ret = rndis_filter_send_request(dev, request);
        if (ret != 0)
                goto Cleanup;
 
-       wait_event_timeout(request->wait_event, request->wait_condition,
-                               msecs_to_jiffies(1000));
-       if (request->wait_condition == 0) {
+       t = wait_for_completion_timeout(&request->wait_event, HZ);
+       if (t == 0) {
                ret = -ETIMEDOUT;
                goto Cleanup;
        }
@@ -555,7 +520,7 @@ static int rndis_filter_set_packet_filter(struct rndis_device *dev,
        struct rndis_set_request *set;
        struct rndis_set_complete *set_complete;
        u32 status;
-       int ret;
+       int ret, t;
 
        request = get_rndis_request(dev, REMOTE_NDIS_SET_MSG,
                        RNDIS_MESSAGE_SIZE(struct rndis_set_request) +
@@ -574,16 +539,16 @@ static int rndis_filter_set_packet_filter(struct rndis_device *dev,
        memcpy((void *)(unsigned long)set + sizeof(struct rndis_set_request),
               &new_filter, sizeof(u32));
 
-       request->wait_condition = 0;
        ret = rndis_filter_send_request(dev, request);
        if (ret != 0)
                goto Cleanup;
 
-       wait_event_timeout(request->wait_event, request->wait_condition,
-               msecs_to_jiffies(2000));
-       if (request->wait_condition == 0) {
+       t = wait_for_completion_timeout(&request->wait_event, HZ);
+
+       if (t == 0) {
                ret = -1;
-               DPRINT_ERR(NETVSC, "timeout before we got a set response...");
+               dev_err(&dev->net_dev->dev->device,
+                       "timeout before we got a set response...\n");
                /*
                 * We can't deallocate the request since we may still receive a
                 * send completion for it.
@@ -603,42 +568,6 @@ Exit:
        return ret;
 }
 
-int rndis_filter_init(struct netvsc_driver *drv)
-{
-       DPRINT_DBG(NETVSC, "sizeof(struct rndis_filter_packet) == %zd",
-                  sizeof(struct rndis_filter_packet));
-
-       drv->req_ext_size = sizeof(struct rndis_filter_packet);
-
-       /* Driver->Context = rndisDriver; */
-
-       memset(&rndis_filter, 0, sizeof(struct rndis_filter_driver_object));
-
-       /*rndisDriver->Driver = Driver;
-
-       ASSERT(Driver->OnLinkStatusChanged);
-       rndisDriver->OnLinkStatusChanged = Driver->OnLinkStatusChanged;*/
-
-       /* Save the original dispatch handlers before we override it */
-       rndis_filter.inner_drv.base.dev_add = drv->base.dev_add;
-       rndis_filter.inner_drv.base.dev_rm =
-                                       drv->base.dev_rm;
-       rndis_filter.inner_drv.base.cleanup = drv->base.cleanup;
-
-       rndis_filter.inner_drv.send = drv->send;
-       rndis_filter.inner_drv.recv_cb = drv->recv_cb;
-       rndis_filter.inner_drv.link_status_change =
-                                       drv->link_status_change;
-
-       /* Override */
-       drv->base.dev_add = rndis_filte_device_add;
-       drv->base.dev_rm = rndis_filter_device_remove;
-       drv->base.cleanup = rndis_filter_cleanup;
-       drv->send = rndis_filter_send;
-       drv->recv_cb = rndis_filter_receive;
-
-       return 0;
-}
 
 static int rndis_filter_init_device(struct rndis_device *dev)
 {
@@ -646,7 +575,7 @@ static int rndis_filter_init_device(struct rndis_device *dev)
        struct rndis_initialize_request *init;
        struct rndis_initialize_complete *init_complete;
        u32 status;
-       int ret;
+       int ret, t;
 
        request = get_rndis_request(dev, REMOTE_NDIS_INITIALIZE_MSG,
                        RNDIS_MESSAGE_SIZE(struct rndis_initialize_request));
@@ -664,7 +593,6 @@ static int rndis_filter_init_device(struct rndis_device *dev)
 
        dev->state = RNDIS_DEV_INITIALIZING;
 
-       request->wait_condition = 0;
        ret = rndis_filter_send_request(dev, request);
        if (ret != 0) {
                dev->state = RNDIS_DEV_UNINITIALIZED;
@@ -672,9 +600,9 @@ static int rndis_filter_init_device(struct rndis_device *dev)
        }
 
 
-       wait_event_timeout(request->wait_event, request->wait_condition,
-               msecs_to_jiffies(1000));
-       if (request->wait_condition == 0) {
+       t = wait_for_completion_timeout(&request->wait_event, HZ);
+
+       if (t == 0) {
                ret = -ETIMEDOUT;
                goto Cleanup;
        }
@@ -753,7 +681,7 @@ static int rndis_filter_close_device(struct rndis_device *dev)
        return ret;
 }
 
-static int rndis_filte_device_add(struct hv_device *dev,
+int rndis_filte_device_add(struct hv_device *dev,
                                  void *additional_info)
 {
        int ret;
@@ -765,14 +693,12 @@ static int rndis_filte_device_add(struct hv_device *dev,
        if (!rndisDevice)
                return -1;
 
-       DPRINT_DBG(NETVSC, "rndis device object allocated - %p", rndisDevice);
-
        /*
         * Let the inner driver handle this first to create the netvsc channel
         * NOTE! Once the channel is created, we may get a receive callback
         * (RndisFilterOnReceive()) before this call is completed
         */
-       ret = rndis_filter.inner_drv.base.dev_add(dev, additional_info);
+       ret = netvsc_device_add(dev, additional_info);
        if (ret != 0) {
                kfree(rndisDevice);
                return ret;
@@ -802,21 +728,20 @@ static int rndis_filte_device_add(struct hv_device *dev,
                 */
        }
 
-       DPRINT_INFO(NETVSC, "Device 0x%p mac addr %pM",
-                   rndisDevice, rndisDevice->hw_mac_adr);
-
        memcpy(deviceInfo->mac_adr, rndisDevice->hw_mac_adr, ETH_ALEN);
 
        rndis_filter_query_device_link_status(rndisDevice);
 
        deviceInfo->link_state = rndisDevice->link_stat;
-       DPRINT_INFO(NETVSC, "Device 0x%p link state %s", rndisDevice,
-                   ((deviceInfo->link_state) ? ("down") : ("up")));
+
+       dev_info(&dev->device, "Device MAC %pM link state %s",
+                rndisDevice->hw_mac_adr,
+                ((deviceInfo->link_state) ? ("down\n") : ("up\n")));
 
        return ret;
 }
 
-static int rndis_filter_device_remove(struct hv_device *dev)
+int rndis_filter_device_remove(struct hv_device *dev)
 {
        struct netvsc_device *net_dev = dev->ext;
        struct rndis_device *rndis_dev = net_dev->extension;
@@ -827,15 +752,11 @@ static int rndis_filter_device_remove(struct hv_device *dev)
        kfree(rndis_dev);
        net_dev->extension = NULL;
 
-       /* Pass control to inner driver to remove the device */
-       rndis_filter.inner_drv.base.dev_rm(dev);
+       netvsc_device_remove(dev);
 
        return 0;
 }
 
-static void rndis_filter_cleanup(struct hv_driver *drv)
-{
-}
 
 int rndis_filter_open(struct hv_device *dev)
 {
@@ -857,7 +778,7 @@ int rndis_filter_close(struct hv_device *dev)
        return rndis_filter_close_device(netDevice->extension);
 }
 
-static int rndis_filter_send(struct hv_device *dev,
+int rndis_filter_send(struct hv_device *dev,
                             struct hv_netvsc_packet *pkt)
 {
        int ret;
@@ -897,7 +818,7 @@ static int rndis_filter_send(struct hv_device *dev,
        pkt->completion.send.send_completion = rndis_filter_send_completion;
        pkt->completion.send.send_completion_ctx = filterPacket;
 
-       ret = rndis_filter.inner_drv.send(dev, pkt);
+       ret = netvsc_send(dev, pkt);
        if (ret != 0) {
                /*
                 * Reset the completion to originals to allow retries from
diff --git a/drivers/staging/hv/rndis_filter.h b/drivers/staging/hv/rndis_filter.h
deleted file mode 100644 (file)
index 4da18f3..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- *
- * Copyright (c) 2009, Microsoft Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place - Suite 330, Boston, MA 02111-1307 USA.
- *
- * Authors:
- *   Haiyang Zhang <haiyangz@microsoft.com>
- *   Hank Janssen  <hjanssen@microsoft.com>
- *
- */
-
-
-#ifndef _RNDISFILTER_H_
-#define _RNDISFILTER_H_
-
-#define __struct_bcount(x)
-
-#include "netvsc.h"
-
-#include "rndis.h"
-
-#define RNDIS_HEADER_SIZE      (sizeof(struct rndis_message) - \
-                                sizeof(union rndis_message_container))
-
-#define NDIS_PACKET_TYPE_DIRECTED      0x00000001
-#define NDIS_PACKET_TYPE_MULTICAST     0x00000002
-#define NDIS_PACKET_TYPE_ALL_MULTICAST 0x00000004
-#define NDIS_PACKET_TYPE_BROADCAST     0x00000008
-#define NDIS_PACKET_TYPE_SOURCE_ROUTING        0x00000010
-#define NDIS_PACKET_TYPE_PROMISCUOUS   0x00000020
-#define NDIS_PACKET_TYPE_SMT           0x00000040
-#define NDIS_PACKET_TYPE_ALL_LOCAL     0x00000080
-#define NDIS_PACKET_TYPE_GROUP         0x00000100
-#define NDIS_PACKET_TYPE_ALL_FUNCTIONAL        0x00000200
-#define NDIS_PACKET_TYPE_FUNCTIONAL    0x00000400
-#define NDIS_PACKET_TYPE_MAC_FRAME     0x00000800
-
-
-/* Interface */
-
-extern int rndis_filter_init(struct netvsc_driver *driver);
-
-#endif /* _RNDISFILTER_H_ */
index e2ad729241841be352abf874cad0ea0326965ab9..06cd3276813c55e9a6fc328fdee72fc109f1eee0 100644 (file)
  * Authors:
  *   Haiyang Zhang <haiyangz@microsoft.com>
  *   Hank Janssen  <hjanssen@microsoft.com>
+ *   K. Y. Srinivasan <kys@microsoft.com>
+ *
  */
 #include <linux/kernel.h>
 #include <linux/sched.h>
-#include <linux/wait.h>
+#include <linux/completion.h>
 #include <linux/string.h>
 #include <linux/slab.h>
 #include <linux/mm.h>
 #include <linux/delay.h>
-#include "hv_api.h"
-#include "logging.h"
-#include "storvsc_api.h"
-#include "vmbus_packet_format.h"
-#include "vstorage.h"
-#include "channel.h"
-
-
-struct storvsc_request_extension {
-       /* LIST_ENTRY ListEntry; */
-
-       struct hv_storvsc_request *request;
-       struct hv_device *device;
-
-       /* Synchronize the request/response if needed */
-       int wait_condition;
-       wait_queue_head_t wait_event;
-
-       struct vstor_packet vstor_packet;
-};
-
-/* A storvsc device is a device object that contains a vmbus channel */
-struct storvsc_device {
-       struct hv_device *device;
-
-       /* 0 indicates the device is being destroyed */
-       atomic_t ref_count;
 
-       atomic_t num_outstanding_req;
-
-       /*
-        * Each unique Port/Path/Target represents 1 channel ie scsi
-        * controller. In reality, the pathid, targetid is always 0
-        * and the port is set by us
-        */
-       unsigned int port_number;
-       unsigned char path_id;
-       unsigned char target_id;
-
-       /* LIST_ENTRY OutstandingRequestList; */
-       /* HANDLE OutstandingRequestLock; */
-
-       /* Used for vsc/vsp channel reset process */
-       struct storvsc_request_extension init_request;
-       struct storvsc_request_extension reset_request;
-};
-
-
-static const char *g_driver_name = "storvsc";
-
-/* {ba6163d9-04a1-4d29-b605-72e2ffb1dc7f} */
-static const struct hv_guid gStorVscDeviceType = {
-       .data = {
-               0xd9, 0x63, 0x61, 0xba, 0xa1, 0x04, 0x29, 0x4d,
-               0xb6, 0x05, 0x72, 0xe2, 0xff, 0xb1, 0xdc, 0x7f
-       }
-};
+#include "hyperv.h"
+#include "hyperv_storage.h"
 
 
 static inline struct storvsc_device *alloc_stor_device(struct hv_device *device)
@@ -96,6 +44,7 @@ static inline struct storvsc_device *alloc_stor_device(struct hv_device *device)
        /* (ie get_stor_device() and must_get_stor_device()) to proceed. */
        atomic_cmpxchg(&stor_device->ref_count, 0, 2);
 
+       init_waitqueue_head(&stor_device->waiting_to_drain);
        stor_device->device = device;
        device->ext = stor_device;
 
@@ -104,24 +53,9 @@ static inline struct storvsc_device *alloc_stor_device(struct hv_device *device)
 
 static inline void free_stor_device(struct storvsc_device *device)
 {
-       /* ASSERT(atomic_read(&device->ref_count) == 0); */
        kfree(device);
 }
 
-/* Get the stordevice object iff exists and its refcount > 1 */
-static inline struct storvsc_device *get_stor_device(struct hv_device *device)
-{
-       struct storvsc_device *stor_device;
-
-       stor_device = (struct storvsc_device *)device->ext;
-       if (stor_device && atomic_read(&stor_device->ref_count) > 1)
-               atomic_inc(&stor_device->ref_count);
-       else
-               stor_device = NULL;
-
-       return stor_device;
-}
-
 /* Get the stordevice object iff exists and its refcount > 0 */
 static inline struct storvsc_device *must_get_stor_device(
                                        struct hv_device *device)
@@ -137,17 +71,6 @@ static inline struct storvsc_device *must_get_stor_device(
        return stor_device;
 }
 
-static inline void put_stor_device(struct hv_device *device)
-{
-       struct storvsc_device *stor_device;
-
-       stor_device = (struct storvsc_device *)device->ext;
-       /* ASSERT(stor_device); */
-
-       atomic_dec(&stor_device->ref_count);
-       /* ASSERT(atomic_read(&stor_device->ref_count)); */
-}
-
 /* Drop ref count to 1 to effectively disable get_stor_device() */
 static inline struct storvsc_device *release_stor_device(
                                        struct hv_device *device)
@@ -155,7 +78,6 @@ static inline struct storvsc_device *release_stor_device(
        struct storvsc_device *stor_device;
 
        stor_device = (struct storvsc_device *)device->ext;
-       /* ASSERT(stor_device); */
 
        /* Busy wait until the ref drop to 2, then set it to 1 */
        while (atomic_cmpxchg(&stor_device->ref_count, 2, 1) != 2)
@@ -171,7 +93,6 @@ static inline struct storvsc_device *final_release_stor_device(
        struct storvsc_device *stor_device;
 
        stor_device = (struct storvsc_device *)device->ext;
-       /* ASSERT(stor_device); */
 
        /* Busy wait until the ref drop to 1, then set it to 0 */
        while (atomic_cmpxchg(&stor_device->ref_count, 1, 0) != 1)
@@ -181,19 +102,16 @@ static inline struct storvsc_device *final_release_stor_device(
        return stor_device;
 }
 
-static int stor_vsc_channel_init(struct hv_device *device)
+static int storvsc_channel_init(struct hv_device *device)
 {
        struct storvsc_device *stor_device;
-       struct storvsc_request_extension *request;
+       struct hv_storvsc_request *request;
        struct vstor_packet *vstor_packet;
-       int ret;
+       int ret, t;
 
        stor_device = get_stor_device(device);
-       if (!stor_device) {
-               DPRINT_ERR(STORVSC, "unable to get stor device..."
-                          "device being destroyed?");
+       if (!stor_device)
                return -1;
-       }
 
        request = &stor_device->init_request;
        vstor_packet = &request->vstor_packet;
@@ -202,40 +120,30 @@ static int stor_vsc_channel_init(struct hv_device *device)
         * Now, initiate the vsc/vsp initialization protocol on the open
         * channel
         */
-       memset(request, 0, sizeof(struct storvsc_request_extension));
-       init_waitqueue_head(&request->wait_event);
+       memset(request, 0, sizeof(struct hv_storvsc_request));
+       init_completion(&request->wait_event);
        vstor_packet->operation = VSTOR_OPERATION_BEGIN_INITIALIZATION;
        vstor_packet->flags = REQUEST_COMPLETION_FLAG;
 
        DPRINT_INFO(STORVSC, "BEGIN_INITIALIZATION_OPERATION...");
 
-       request->wait_condition = 0;
        ret = vmbus_sendpacket(device->channel, vstor_packet,
                               sizeof(struct vstor_packet),
                               (unsigned long)request,
                               VM_PKT_DATA_INBAND,
                               VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
-       if (ret != 0) {
-               DPRINT_ERR(STORVSC,
-                          "unable to send BEGIN_INITIALIZATION_OPERATION");
+       if (ret != 0)
                goto cleanup;
-       }
 
-       wait_event_timeout(request->wait_event, request->wait_condition,
-                       msecs_to_jiffies(1000));
-       if (request->wait_condition == 0) {
+       t = wait_for_completion_timeout(&request->wait_event, HZ);
+       if (t == 0) {
                ret = -ETIMEDOUT;
                goto cleanup;
        }
 
-
        if (vstor_packet->operation != VSTOR_OPERATION_COMPLETE_IO ||
-           vstor_packet->status != 0) {
-               DPRINT_ERR(STORVSC, "BEGIN_INITIALIZATION_OPERATION failed "
-                          "(op %d status 0x%x)",
-                          vstor_packet->operation, vstor_packet->status);
+           vstor_packet->status != 0)
                goto cleanup;
-       }
 
        DPRINT_INFO(STORVSC, "QUERY_PROTOCOL_VERSION_OPERATION...");
 
@@ -247,33 +155,24 @@ static int stor_vsc_channel_init(struct hv_device *device)
        vstor_packet->version.major_minor = VMSTOR_PROTOCOL_VERSION_CURRENT;
        FILL_VMSTOR_REVISION(vstor_packet->version.revision);
 
-       request->wait_condition = 0;
        ret = vmbus_sendpacket(device->channel, vstor_packet,
                               sizeof(struct vstor_packet),
                               (unsigned long)request,
                               VM_PKT_DATA_INBAND,
                               VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
-       if (ret != 0) {
-               DPRINT_ERR(STORVSC,
-                          "unable to send BEGIN_INITIALIZATION_OPERATION");
+       if (ret != 0)
                goto cleanup;
-       }
 
-       wait_event_timeout(request->wait_event, request->wait_condition,
-                       msecs_to_jiffies(1000));
-       if (request->wait_condition == 0) {
+       t = wait_for_completion_timeout(&request->wait_event, HZ);
+       if (t == 0) {
                ret = -ETIMEDOUT;
                goto cleanup;
        }
 
        /* TODO: Check returned version */
        if (vstor_packet->operation != VSTOR_OPERATION_COMPLETE_IO ||
-           vstor_packet->status != 0) {
-               DPRINT_ERR(STORVSC, "QUERY_PROTOCOL_VERSION_OPERATION failed "
-                          "(op %d status 0x%x)",
-                          vstor_packet->operation, vstor_packet->status);
+           vstor_packet->status != 0)
                goto cleanup;
-       }
 
        /* Query channel properties */
        DPRINT_INFO(STORVSC, "QUERY_PROPERTIES_OPERATION...");
@@ -284,76 +183,54 @@ static int stor_vsc_channel_init(struct hv_device *device)
        vstor_packet->storage_channel_properties.port_number =
                                        stor_device->port_number;
 
-       request->wait_condition = 0;
        ret = vmbus_sendpacket(device->channel, vstor_packet,
                               sizeof(struct vstor_packet),
                               (unsigned long)request,
                               VM_PKT_DATA_INBAND,
                               VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
 
-       if (ret != 0) {
-               DPRINT_ERR(STORVSC,
-                          "unable to send QUERY_PROPERTIES_OPERATION");
+       if (ret != 0)
                goto cleanup;
-       }
 
-       wait_event_timeout(request->wait_event, request->wait_condition,
-                       msecs_to_jiffies(1000));
-       if (request->wait_condition == 0) {
+       t = wait_for_completion_timeout(&request->wait_event, HZ);
+       if (t == 0) {
                ret = -ETIMEDOUT;
                goto cleanup;
        }
 
        /* TODO: Check returned version */
        if (vstor_packet->operation != VSTOR_OPERATION_COMPLETE_IO ||
-           vstor_packet->status != 0) {
-               DPRINT_ERR(STORVSC, "QUERY_PROPERTIES_OPERATION failed "
-                          "(op %d status 0x%x)",
-                          vstor_packet->operation, vstor_packet->status);
+           vstor_packet->status != 0)
                goto cleanup;
-       }
 
        stor_device->path_id = vstor_packet->storage_channel_properties.path_id;
        stor_device->target_id
                = vstor_packet->storage_channel_properties.target_id;
 
-       DPRINT_DBG(STORVSC, "channel flag 0x%x, max xfer len 0x%x",
-                  vstor_packet->storage_channel_properties.flags,
-                  vstor_packet->storage_channel_properties.max_transfer_bytes);
-
        DPRINT_INFO(STORVSC, "END_INITIALIZATION_OPERATION...");
 
        memset(vstor_packet, 0, sizeof(struct vstor_packet));
        vstor_packet->operation = VSTOR_OPERATION_END_INITIALIZATION;
        vstor_packet->flags = REQUEST_COMPLETION_FLAG;
 
-       request->wait_condition = 0;
        ret = vmbus_sendpacket(device->channel, vstor_packet,
                               sizeof(struct vstor_packet),
                               (unsigned long)request,
                               VM_PKT_DATA_INBAND,
                               VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
 
-       if (ret != 0) {
-               DPRINT_ERR(STORVSC,
-                          "unable to send END_INITIALIZATION_OPERATION");
+       if (ret != 0)
                goto cleanup;
-       }
 
-       wait_event_timeout(request->wait_event, request->wait_condition,
-                       msecs_to_jiffies(1000));
-       if (request->wait_condition == 0) {
+       t = wait_for_completion_timeout(&request->wait_event, HZ);
+       if (t == 0) {
                ret = -ETIMEDOUT;
                goto cleanup;
        }
 
        if (vstor_packet->operation != VSTOR_OPERATION_COMPLETE_IO ||
-           vstor_packet->status != 0) {
-               DPRINT_ERR(STORVSC, "END_INITIALIZATION_OPERATION failed "
-                          "(op %d status 0x%x)",
-                          vstor_packet->operation, vstor_packet->status);
+           vstor_packet->status != 0)
                goto cleanup;
-       }
 
        DPRINT_INFO(STORVSC, "**** storage channel up and running!! ****");
 
@@ -362,78 +239,70 @@ cleanup:
        return ret;
 }
 
-static void stor_vsc_on_io_completion(struct hv_device *device,
+static void storvsc_on_io_completion(struct hv_device *device,
                                  struct vstor_packet *vstor_packet,
-                                 struct storvsc_request_extension *request_ext)
+                                 struct hv_storvsc_request *request)
 {
-       struct hv_storvsc_request *request;
        struct storvsc_device *stor_device;
+       struct vstor_packet *stor_pkt;
 
        stor_device = must_get_stor_device(device);
-       if (!stor_device) {
-               DPRINT_ERR(STORVSC, "unable to get stor device..."
-                          "device being destroyed?");
+       if (!stor_device)
                return;
-       }
-
-       DPRINT_DBG(STORVSC, "IO_COMPLETE_OPERATION - request extension %p "
-                  "completed bytes xfer %u", request_ext,
-                  vstor_packet->vm_srb.data_transfer_length);
 
-       /* ASSERT(request_ext != NULL); */
-       /* ASSERT(request_ext->request != NULL); */
+       stor_pkt = &request->vstor_packet;
 
-       request = request_ext->request;
-
-       /* ASSERT(request->OnIOCompletion != NULL); */
 
        /* Copy over the status...etc */
-       request->status = vstor_packet->vm_srb.scsi_status;
+       stor_pkt->vm_srb.scsi_status = vstor_packet->vm_srb.scsi_status;
+       stor_pkt->vm_srb.srb_status = vstor_packet->vm_srb.srb_status;
+       stor_pkt->vm_srb.sense_info_length =
+       vstor_packet->vm_srb.sense_info_length;
 
-       if (request->status != 0 || vstor_packet->vm_srb.srb_status != 1) {
+       if (vstor_packet->vm_srb.scsi_status != 0 ||
+               vstor_packet->vm_srb.srb_status != 1){
                DPRINT_WARN(STORVSC,
                            "cmd 0x%x scsi status 0x%x srb status 0x%x\n",
-                           request->cdb[0], vstor_packet->vm_srb.scsi_status,
+                           stor_pkt->vm_srb.cdb[0],
+                           vstor_packet->vm_srb.scsi_status,
                            vstor_packet->vm_srb.srb_status);
        }
 
-       if ((request->status & 0xFF) == 0x02) {
+       if ((vstor_packet->vm_srb.scsi_status & 0xFF) == 0x02) {
                /* CHECK_CONDITION */
                if (vstor_packet->vm_srb.srb_status & 0x80) {
                        /* autosense data available */
                        DPRINT_WARN(STORVSC, "storvsc pkt %p autosense data "
-                                   "valid - len %d\n", request_ext,
+                                   "valid - len %d\n", request,
                                    vstor_packet->vm_srb.sense_info_length);
 
-                       /* ASSERT(vstor_packet->vm_srb.sense_info_length <= */
-                       /*      request->SenseBufferSize); */
                        memcpy(request->sense_buffer,
                               vstor_packet->vm_srb.sense_data,
                               vstor_packet->vm_srb.sense_info_length);
 
-                       request->sense_buffer_size =
-                                       vstor_packet->vm_srb.sense_info_length;
                }
        }
 
-       /* TODO: */
-       request->bytes_xfer = vstor_packet->vm_srb.data_transfer_length;
+       stor_pkt->vm_srb.data_transfer_length =
+       vstor_packet->vm_srb.data_transfer_length;
 
        request->on_io_completion(request);
 
-       atomic_dec(&stor_device->num_outstanding_req);
+       if (atomic_dec_and_test(&stor_device->num_outstanding_req) &&
+               stor_device->drain_notify)
+               wake_up(&stor_device->waiting_to_drain);
+
 
        put_stor_device(device);
 }
 
-static void stor_vsc_on_receive(struct hv_device *device,
+static void storvsc_on_receive(struct hv_device *device,
                             struct vstor_packet *vstor_packet,
-                            struct storvsc_request_extension *request_ext)
+                            struct hv_storvsc_request *request)
 {
        switch (vstor_packet->operation) {
        case VSTOR_OPERATION_COMPLETE_IO:
-               DPRINT_DBG(STORVSC, "IO_COMPLETE_OPERATION");
-               stor_vsc_on_io_completion(device, vstor_packet, request_ext);
+               storvsc_on_io_completion(device, vstor_packet, request);
                break;
        case VSTOR_OPERATION_REMOVE_DEVICE:
                DPRINT_INFO(STORVSC, "REMOVE_DEVICE_OPERATION");
@@ -447,60 +316,42 @@ static void stor_vsc_on_receive(struct hv_device *device,
        }
 }
 
-static void stor_vsc_on_channel_callback(void *context)
+static void storvsc_on_channel_callback(void *context)
 {
        struct hv_device *device = (struct hv_device *)context;
        struct storvsc_device *stor_device;
        u32 bytes_recvd;
        u64 request_id;
        unsigned char packet[ALIGN(sizeof(struct vstor_packet), 8)];
-       struct storvsc_request_extension *request;
+       struct hv_storvsc_request *request;
        int ret;
 
-       /* ASSERT(device); */
 
        stor_device = must_get_stor_device(device);
-       if (!stor_device) {
-               DPRINT_ERR(STORVSC, "unable to get stor device..."
-                          "device being destroyed?");
+       if (!stor_device)
                return;
-       }
 
        do {
                ret = vmbus_recvpacket(device->channel, packet,
                                       ALIGN(sizeof(struct vstor_packet), 8),
                                       &bytes_recvd, &request_id);
                if (ret == 0 && bytes_recvd > 0) {
-                       DPRINT_DBG(STORVSC, "receive %d bytes - tid %llx",
-                                  bytes_recvd, request_id);
 
-                       /* ASSERT(bytes_recvd ==
-                                       sizeof(struct vstor_packet)); */
-
-                       request = (struct storvsc_request_extension *)
+                       request = (struct hv_storvsc_request *)
                                        (unsigned long)request_id;
-                       /* ASSERT(request);c */
 
-                       /* if (vstor_packet.Flags & SYNTHETIC_FLAG) */
                        if ((request == &stor_device->init_request) ||
                            (request == &stor_device->reset_request)) {
-                               /* DPRINT_INFO(STORVSC,
-                                *             "reset completion - operation "
-                                *             "%u status %u",
-                                *             vstor_packet.Operation,
-                                *             vstor_packet.Status); */
 
                                memcpy(&request->vstor_packet, packet,
                                       sizeof(struct vstor_packet));
-                               request->wait_condition = 1;
-                               wake_up(&request->wait_event);
+                               complete(&request->wait_event);
                        } else {
-                               stor_vsc_on_receive(device,
+                               storvsc_on_receive(device,
                                                (struct vstor_packet *)packet,
                                                request);
                        }
                } else {
-                       /* DPRINT_DBG(STORVSC, "nothing else to read..."); */
                        break;
                }
        } while (1);
@@ -509,45 +360,33 @@ static void stor_vsc_on_channel_callback(void *context)
        return;
 }
 
-static int stor_vsc_connect_to_vsp(struct hv_device *device)
+static int storvsc_connect_to_vsp(struct hv_device *device, u32 ring_size)
 {
        struct vmstorage_channel_properties props;
-       struct storvsc_driver_object *stor_driver;
        int ret;
 
-       stor_driver = (struct storvsc_driver_object *)device->drv;
        memset(&props, 0, sizeof(struct vmstorage_channel_properties));
 
        /* Open the channel */
        ret = vmbus_open(device->channel,
-                        stor_driver->ring_buffer_size,
-                        stor_driver->ring_buffer_size,
+                        ring_size,
+                        ring_size,
                         (void *)&props,
                         sizeof(struct vmstorage_channel_properties),
-                        stor_vsc_on_channel_callback, device);
-
-       DPRINT_DBG(STORVSC, "storage props: path id %d, tgt id %d, max xfer %d",
-                  props.path_id, props.target_id, props.max_transfer_bytes);
+                        storvsc_on_channel_callback, device);
 
-       if (ret != 0) {
-               DPRINT_ERR(STORVSC, "unable to open channel: %d", ret);
+       if (ret != 0)
                return -1;
-       }
 
-       ret = stor_vsc_channel_init(device);
+       ret = storvsc_channel_init(device);
 
        return ret;
 }
 
-/*
- * stor_vsc_on_device_add - Callback when the device belonging to this driver
- * is added
- */
-static int stor_vsc_on_device_add(struct hv_device *device,
+int storvsc_dev_add(struct hv_device *device,
                                        void *additional_info)
 {
        struct storvsc_device *stor_device;
-       /* struct vmstorage_channel_properties *props; */
        struct storvsc_device_info *device_info;
        int ret = 0;
 
@@ -559,8 +398,6 @@ static int stor_vsc_on_device_add(struct hv_device *device,
        }
 
        /* Save the channel properties to our storvsc channel */
-       /* props = (struct vmstorage_channel_properties *)
-        *              channel->offerMsg.Offer.u.Standard.UserDefined; */
 
        /* FIXME: */
        /*
@@ -569,30 +406,18 @@ static int stor_vsc_on_device_add(struct hv_device *device,
         * scsi channel prior to the bus scan
         */
 
-       /* storChannel->PortNumber = 0;
-       storChannel->PathId = props->PathId;
-       storChannel->TargetId = props->TargetId; */
-
        stor_device->port_number = device_info->port_number;
        /* Send it back up */
-       ret = stor_vsc_connect_to_vsp(device);
+       ret = storvsc_connect_to_vsp(device, device_info->ring_buffer_size);
 
-       /* device_info->PortNumber = stor_device->PortNumber; */
        device_info->path_id = stor_device->path_id;
        device_info->target_id = stor_device->target_id;
 
-       DPRINT_DBG(STORVSC, "assigned port %u, path %u target %u\n",
-                  stor_device->port_number, stor_device->path_id,
-                  stor_device->target_id);
-
 cleanup:
        return ret;
 }
 
-/*
- * stor_vsc_on_device_remove - Callback when the our device is being removed
- */
-static int stor_vsc_on_device_remove(struct hv_device *device)
+int storvsc_dev_remove(struct hv_device *device)
 {
        struct storvsc_device *stor_device;
 
@@ -606,19 +431,11 @@ static int stor_vsc_on_device_remove(struct hv_device *device)
         * only allow inbound traffic (responses) to proceed so that
         * outstanding requests can be completed.
         */
-       while (atomic_read(&stor_device->num_outstanding_req)) {
-               DPRINT_INFO(STORVSC, "waiting for %d requests to complete...",
-                           atomic_read(&stor_device->num_outstanding_req));
-               udelay(100);
-       }
 
-       DPRINT_INFO(STORVSC, "removing storage device (%p)...",
-                   device->ext);
+       storvsc_wait_to_drain(stor_device);
 
        stor_device = final_release_stor_device(device);
 
-       DPRINT_INFO(STORVSC, "storage device (%p) safe to remove", stor_device);
-
        /* Close the channel */
        vmbus_close(device->channel);
 
@@ -626,148 +443,52 @@ static int stor_vsc_on_device_remove(struct hv_device *device)
        return 0;
 }
 
-int stor_vsc_on_host_reset(struct hv_device *device)
-{
-       struct storvsc_device *stor_device;
-       struct storvsc_request_extension *request;
-       struct vstor_packet *vstor_packet;
-       int ret;
-
-       DPRINT_INFO(STORVSC, "resetting host adapter...");
-
-       stor_device = get_stor_device(device);
-       if (!stor_device) {
-               DPRINT_ERR(STORVSC, "unable to get stor device..."
-                          "device being destroyed?");
-               return -1;
-       }
-
-       request = &stor_device->reset_request;
-       vstor_packet = &request->vstor_packet;
-
-       init_waitqueue_head(&request->wait_event);
-
-       vstor_packet->operation = VSTOR_OPERATION_RESET_BUS;
-       vstor_packet->flags = REQUEST_COMPLETION_FLAG;
-       vstor_packet->vm_srb.path_id = stor_device->path_id;
-
-       request->wait_condition = 0;
-       ret = vmbus_sendpacket(device->channel, vstor_packet,
-                              sizeof(struct vstor_packet),
-                              (unsigned long)&stor_device->reset_request,
-                              VM_PKT_DATA_INBAND,
-                              VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
-       if (ret != 0) {
-               DPRINT_ERR(STORVSC, "Unable to send reset packet %p ret %d",
-                          vstor_packet, ret);
-               goto cleanup;
-       }
-
-       wait_event_timeout(request->wait_event, request->wait_condition,
-                       msecs_to_jiffies(1000));
-       if (request->wait_condition == 0) {
-               ret = -ETIMEDOUT;
-               goto cleanup;
-       }
-
-       DPRINT_INFO(STORVSC, "host adapter reset completed");
-
-       /*
-        * At this point, all outstanding requests in the adapter
-        * should have been flushed out and return to us
-        */
-
-cleanup:
-       put_stor_device(device);
-       return ret;
-}
-
-/*
- * stor_vsc_on_io_request - Callback to initiate an I/O request
- */
-static int stor_vsc_on_io_request(struct hv_device *device,
+int storvsc_do_io(struct hv_device *device,
                              struct hv_storvsc_request *request)
 {
        struct storvsc_device *stor_device;
-       struct storvsc_request_extension *request_extension;
        struct vstor_packet *vstor_packet;
        int ret = 0;
 
-       request_extension =
-               (struct storvsc_request_extension *)request->extension;
-       vstor_packet = &request_extension->vstor_packet;
+       vstor_packet = &request->vstor_packet;
        stor_device = get_stor_device(device);
 
-       DPRINT_DBG(STORVSC, "enter - Device %p, DeviceExt %p, Request %p, "
-                  "Extension %p", device, stor_device, request,
-                  request_extension);
-
-       DPRINT_DBG(STORVSC, "req %p len %d bus %d, target %d, lun %d cdblen %d",
-                  request, request->data_buffer.len, request->bus,
-                  request->target_id, request->lun_id, request->cdb_len);
-
-       if (!stor_device) {
-               DPRINT_ERR(STORVSC, "unable to get stor device..."
-                          "device being destroyed?");
+       if (!stor_device)
                return -2;
-       }
 
-       /* print_hex_dump_bytes("", DUMP_PREFIX_NONE, request->Cdb,
-        *                      request->CdbLen); */
 
-       request_extension->request = request;
-       request_extension->device  = device;
+       request->device  = device;
 
-       memset(vstor_packet, 0 , sizeof(struct vstor_packet));
 
        vstor_packet->flags |= REQUEST_COMPLETION_FLAG;
 
        vstor_packet->vm_srb.length = sizeof(struct vmscsi_request);
 
-       vstor_packet->vm_srb.port_number = request->host;
-       vstor_packet->vm_srb.path_id = request->bus;
-       vstor_packet->vm_srb.target_id = request->target_id;
-       vstor_packet->vm_srb.lun = request->lun_id;
 
        vstor_packet->vm_srb.sense_info_length = SENSE_BUFFER_SIZE;
 
-       /* Copy over the scsi command descriptor block */
-       vstor_packet->vm_srb.cdb_length = request->cdb_len;
-       memcpy(&vstor_packet->vm_srb.cdb, request->cdb, request->cdb_len);
 
-       vstor_packet->vm_srb.data_in = request->type;
-       vstor_packet->vm_srb.data_transfer_length = request->data_buffer.len;
+       vstor_packet->vm_srb.data_transfer_length =
+       request->data_buffer.len;
 
        vstor_packet->operation = VSTOR_OPERATION_EXECUTE_SRB;
 
-       DPRINT_DBG(STORVSC, "srb - len %d port %d, path %d, target %d, "
-                  "lun %d senselen %d cdblen %d",
-                  vstor_packet->vm_srb.length,
-                  vstor_packet->vm_srb.port_number,
-                  vstor_packet->vm_srb.path_id,
-                  vstor_packet->vm_srb.target_id,
-                  vstor_packet->vm_srb.lun,
-                  vstor_packet->vm_srb.sense_info_length,
-                  vstor_packet->vm_srb.cdb_length);
-
-       if (request_extension->request->data_buffer.len) {
+       if (request->data_buffer.len) {
                ret = vmbus_sendpacket_multipagebuffer(device->channel,
-                               &request_extension->request->data_buffer,
+                               &request->data_buffer,
                                vstor_packet,
                                sizeof(struct vstor_packet),
-                               (unsigned long)request_extension);
+                               (unsigned long)request);
        } else {
                ret = vmbus_sendpacket(device->channel, vstor_packet,
                                       sizeof(struct vstor_packet),
-                                      (unsigned long)request_extension,
+                                      (unsigned long)request,
                                       VM_PKT_DATA_INBAND,
                                       VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
        }
 
-       if (ret != 0) {
-               DPRINT_DBG(STORVSC, "Unable to send packet %p ret %d",
-                          vstor_packet, ret);
-       }
+       if (ret != 0)
+               return ret;
 
        atomic_inc(&stor_device->num_outstanding_req);
 
@@ -776,62 +497,68 @@ static int stor_vsc_on_io_request(struct hv_device *device,
 }
 
 /*
- * stor_vsc_on_cleanup - Perform any cleanup when the driver is removed
+ * The channel properties uniquely specify how the device is to be
+ * presented to the guest. Map this information for use by the block
+ * driver. For Linux guests on Hyper-V, we emulate a scsi HBA in the guest
+ * (storvsc_drv) and so scsi devices in the guest  are handled by
+ * native upper level Linux drivers. Consequently, Hyper-V
+ * block driver, while being a generic block driver, presently does not
+ * deal with anything other than devices that would need to be presented
+ * to the guest as an IDE disk.
+ *
+ * This function maps the channel properties as embedded in the input
+ * parameter device_info onto information necessary to register the
+ * corresponding block device.
+ *
+ * Currently, there is no way to stop the emulation of the block device
+ * on the host side. And so, to prevent the native IDE drivers in Linux
+ * from taking over these devices (to be managedby Hyper-V block
+ * driver), we will take over if need be the major of the IDE controllers.
+ *
  */
-static void stor_vsc_on_cleanup(struct hv_driver *driver)
-{
-}
 
-/*
- * stor_vsc_initialize - Main entry point
- */
-int stor_vsc_initialize(struct hv_driver *driver)
+int storvsc_get_major_info(struct storvsc_device_info *device_info,
+                           struct storvsc_major_info *major_info)
 {
-       struct storvsc_driver_object *stor_driver;
-
-       stor_driver = (struct storvsc_driver_object *)driver;
-
-       DPRINT_DBG(STORVSC, "sizeof(STORVSC_REQUEST)=%zd "
-                  "sizeof(struct storvsc_request_extension)=%zd "
-                  "sizeof(struct vstor_packet)=%zd, "
-                  "sizeof(struct vmscsi_request)=%zd",
-                  sizeof(struct hv_storvsc_request),
-                  sizeof(struct storvsc_request_extension),
-                  sizeof(struct vstor_packet),
-                  sizeof(struct vmscsi_request));
-
-       /* Make sure we are at least 2 pages since 1 page is used for control */
-       /* ASSERT(stor_driver->RingBufferSize >= (PAGE_SIZE << 1)); */
-
-       driver->name = g_driver_name;
-       memcpy(&driver->dev_type, &gStorVscDeviceType,
-              sizeof(struct hv_guid));
-
-       stor_driver->request_ext_size =
-                       sizeof(struct storvsc_request_extension);
+       static bool ide0_registered;
+       static bool ide1_registered;
 
        /*
-        * Divide the ring buffer data size (which is 1 page less
-        * than the ring buffer size since that page is reserved for
-        * the ring buffer indices) by the max request size (which is
-        * vmbus_channel_packet_multipage_buffer + struct vstor_packet + u64)
+        * For now we only support IDE disks.
         */
-       stor_driver->max_outstanding_req_per_channel =
-               ((stor_driver->ring_buffer_size - PAGE_SIZE) /
-                 ALIGN(MAX_MULTIPAGE_BUFFER_PACKET +
-                          sizeof(struct vstor_packet) + sizeof(u64),
-                          sizeof(u64)));
-
-       DPRINT_INFO(STORVSC, "max io %u, currently %u\n",
-                   stor_driver->max_outstanding_req_per_channel,
-                   STORVSC_MAX_IO_REQUESTS);
-
-       /* Setup the dispatch table */
-       stor_driver->base.dev_add       = stor_vsc_on_device_add;
-       stor_driver->base.dev_rm        = stor_vsc_on_device_remove;
-       stor_driver->base.cleanup       = stor_vsc_on_cleanup;
-
-       stor_driver->on_io_request      = stor_vsc_on_io_request;
+       major_info->devname = "ide";
+       major_info->diskname = "hd";
+
+       if (device_info->path_id) {
+               major_info->major = 22;
+               if (!ide1_registered) {
+                       major_info->do_register = true;
+                       ide1_registered = true;
+               } else
+                       major_info->do_register = false;
+
+               if (device_info->target_id)
+                       major_info->index = 3;
+               else
+                       major_info->index = 2;
+
+               return 0;
+       } else {
+               major_info->major = 3;
+               if (!ide0_registered) {
+                       major_info->do_register = true;
+                       ide0_registered = true;
+               } else
+                       major_info->do_register = false;
+
+               if (device_info->target_id)
+                       major_info->index = 1;
+               else
+                       major_info->index = 0;
+
+               return 0;
+       }
 
-       return 0;
+       return -ENODEV;
 }
+
diff --git a/drivers/staging/hv/storvsc_api.h b/drivers/staging/hv/storvsc_api.h
deleted file mode 100644 (file)
index fbf5755..0000000
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- *
- * Copyright (c) 2009, Microsoft Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place - Suite 330, Boston, MA 02111-1307 USA.
- *
- * Authors:
- *   Haiyang Zhang <haiyangz@microsoft.com>
- *   Hank Janssen  <hjanssen@microsoft.com>
- *
- */
-
-
-#ifndef _STORVSC_API_H_
-#define _STORVSC_API_H_
-
-#include "vmbus_api.h"
-
-/* Defines */
-#define STORVSC_RING_BUFFER_SIZE                       (20*PAGE_SIZE)
-#define BLKVSC_RING_BUFFER_SIZE                                (20*PAGE_SIZE)
-
-#define STORVSC_MAX_IO_REQUESTS                                128
-
-/*
- * In Hyper-V, each port/path/target maps to 1 scsi host adapter.  In
- * reality, the path/target is not used (ie always set to 0) so our
- * scsi host adapter essentially has 1 bus with 1 target that contains
- * up to 256 luns.
- */
-#define STORVSC_MAX_LUNS_PER_TARGET                    64
-#define STORVSC_MAX_TARGETS                            1
-#define STORVSC_MAX_CHANNELS                           1
-
-struct hv_storvsc_request;
-
-/* Matches Windows-end */
-enum storvsc_request_type{
-       WRITE_TYPE,
-       READ_TYPE,
-       UNKNOWN_TYPE,
-};
-
-struct hv_storvsc_request {
-       enum storvsc_request_type type;
-       u32 host;
-       u32 bus;
-       u32 target_id;
-       u32 lun_id;
-       u8 *cdb;
-       u32 cdb_len;
-       u32 status;
-       u32 bytes_xfer;
-
-       unsigned char *sense_buffer;
-       u32 sense_buffer_size;
-
-       void *context;
-
-       void (*on_io_completion)(struct hv_storvsc_request *request);
-
-       /* This points to the memory after DataBuffer */
-       void *extension;
-
-       struct hv_multipage_buffer data_buffer;
-};
-
-/* Represents the block vsc driver */
-struct storvsc_driver_object {
-       /* Must be the first field */
-       /* Which is a bug FIXME! */
-       struct hv_driver base;
-
-       /* Set by caller (in bytes) */
-       u32 ring_buffer_size;
-
-       /* Allocate this much private extension for each I/O request */
-       u32 request_ext_size;
-
-       /* Maximum # of requests in flight per channel/device */
-       u32 max_outstanding_req_per_channel;
-
-       /* Specific to this driver */
-       int (*on_io_request)(struct hv_device *device,
-                          struct hv_storvsc_request *request);
-};
-
-struct storvsc_device_info {
-       unsigned int port_number;
-       unsigned char path_id;
-       unsigned char target_id;
-};
-
-/* Interface */
-int stor_vsc_initialize(struct hv_driver *driver);
-int stor_vsc_on_host_reset(struct hv_device *device);
-int blk_vsc_initialize(struct hv_driver *driver);
-
-#endif /* _STORVSC_API_H_ */
index e6462a2fe9abfdb9082a2ab2e2464d85cecd7557..942cc5f98db19694673c21c6b35ac4099b541fb8 100644 (file)
@@ -17,6 +17,7 @@
  * Authors:
  *   Haiyang Zhang <haiyangz@microsoft.com>
  *   Hank Janssen  <hjanssen@microsoft.com>
+ *   K. Y. Srinivasan <kys@microsoft.com>
  */
 #include <linux/init.h>
 #include <linux/slab.h>
 #include <scsi/scsi_eh.h>
 #include <scsi/scsi_devinfo.h>
 #include <scsi/scsi_dbg.h>
-#include "hv_api.h"
-#include "logging.h"
-#include "version_info.h"
-#include "vmbus.h"
-#include "storvsc_api.h"
-
-
-struct host_device_context {
-       /* must be 1st field
-        * FIXME this is a bug */
-       /* point back to our device context */
-       struct hv_device *device_ctx;
+
+#include "hyperv.h"
+#include "hyperv_storage.h"
+
+static int storvsc_ringbuffer_size = STORVSC_RING_BUFFER_SIZE;
+
+module_param(storvsc_ringbuffer_size, int, S_IRUGO);
+MODULE_PARM_DESC(storvsc_ringbuffer_size, "Ring buffer size (bytes)");
+
+static const char *driver_name = "storvsc";
+
+/* {ba6163d9-04a1-4d29-b605-72e2ffb1dc7f} */
+static const struct hv_guid gStorVscDeviceType = {
+       .data = {
+               0xd9, 0x63, 0x61, 0xba, 0xa1, 0x04, 0x29, 0x4d,
+               0xb6, 0x05, 0x72, 0xe2, 0xff, 0xb1, 0xdc, 0x7f
+       }
+};
+
+struct hv_host_device {
+       struct hv_device *dev;
        struct kmem_cache *request_pool;
        unsigned int port;
        unsigned char path;
@@ -57,331 +67,57 @@ struct storvsc_cmd_request {
        struct scatterlist *bounce_sgl;
 
        struct hv_storvsc_request request;
-       /* !!!DO NOT ADD ANYTHING BELOW HERE!!! */
-       /* The extension buffer falls right here and is pointed to by
-        * request.Extension;
-        * Which sounds like a very bad design... */
 };
 
 
-/* Static decl */
-static int storvsc_probe(struct device *dev);
-static int storvsc_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *scmnd);
-static int storvsc_device_alloc(struct scsi_device *);
-static int storvsc_device_configure(struct scsi_device *);
-static int storvsc_host_reset_handler(struct scsi_cmnd *scmnd);
-static int storvsc_remove(struct device *dev);
-
-static struct scatterlist *create_bounce_buffer(struct scatterlist *sgl,
-                                               unsigned int sg_count,
-                                               unsigned int len);
-static void destroy_bounce_buffer(struct scatterlist *sgl,
-                                 unsigned int sg_count);
-static int do_bounce_buffer(struct scatterlist *sgl, unsigned int sg_count);
-static unsigned int copy_from_bounce_buffer(struct scatterlist *orig_sgl,
-                                           struct scatterlist *bounce_sgl,
-                                           unsigned int orig_sgl_count);
-static unsigned int copy_to_bounce_buffer(struct scatterlist *orig_sgl,
-                                         struct scatterlist *bounce_sgl,
-                                         unsigned int orig_sgl_count);
-
-static int storvsc_get_chs(struct scsi_device *sdev, struct block_device *bdev,
-                          sector_t capacity, int *info);
-
-
-static int storvsc_ringbuffer_size = STORVSC_RING_BUFFER_SIZE;
-module_param(storvsc_ringbuffer_size, int, S_IRUGO);
-MODULE_PARM_DESC(storvsc_ringbuffer_size, "Ring buffer size (bytes)");
-
-/* The one and only one */
-static struct storvsc_driver_object g_storvsc_drv;
-
-/* Scsi driver */
-static struct scsi_host_template scsi_driver = {
-       .module =               THIS_MODULE,
-       .name =                 "storvsc_host_t",
-       .bios_param =           storvsc_get_chs,
-       .queuecommand =         storvsc_queuecommand,
-       .eh_host_reset_handler =        storvsc_host_reset_handler,
-       .slave_alloc =          storvsc_device_alloc,
-       .slave_configure =      storvsc_device_configure,
-       .cmd_per_lun =          1,
-       /* 64 max_queue * 1 target */
-       .can_queue =            STORVSC_MAX_IO_REQUESTS*STORVSC_MAX_TARGETS,
-       .this_id =              -1,
-       /* no use setting to 0 since ll_blk_rw reset it to 1 */
-       /* currently 32 */
-       .sg_tablesize =         MAX_MULTIPAGE_BUFFER_COUNT,
+static int storvsc_device_alloc(struct scsi_device *sdevice)
+{
        /*
-        * ENABLE_CLUSTERING allows mutiple physically contig bio_vecs to merge
-        * into 1 sg element. If set, we must limit the max_segment_size to
-        * PAGE_SIZE, otherwise we may get 1 sg element that represents
-        * multiple
+        * This enables luns to be located sparsely. Otherwise, we may not
+        * discovered them.
         */
-       /* physically contig pfns (ie sg[x].length > PAGE_SIZE). */
-       .use_clustering =       ENABLE_CLUSTERING,
-       /* Make sure we dont get a sg segment crosses a page boundary */
-       .dma_boundary =         PAGE_SIZE-1,
-};
-
-
-/*
- * storvsc_drv_init - StorVsc driver initialization.
- */
-static int storvsc_drv_init(int (*drv_init)(struct hv_driver *drv))
-{
-       int ret;
-       struct storvsc_driver_object *storvsc_drv_obj = &g_storvsc_drv;
-       struct hv_driver *drv = &g_storvsc_drv.base;
-
-       storvsc_drv_obj->ring_buffer_size = storvsc_ringbuffer_size;
-
-       /* Callback to client driver to complete the initialization */
-       drv_init(&storvsc_drv_obj->base);
-
-       drv->priv = storvsc_drv_obj;
-
-       DPRINT_INFO(STORVSC_DRV,
-                   "request extension size %u, max outstanding reqs %u",
-                   storvsc_drv_obj->request_ext_size,
-                   storvsc_drv_obj->max_outstanding_req_per_channel);
-
-       if (storvsc_drv_obj->max_outstanding_req_per_channel <
-           STORVSC_MAX_IO_REQUESTS) {
-               DPRINT_ERR(STORVSC_DRV,
-                          "The number of outstanding io requests (%d) "
-                          "is larger than that supported (%d) internally.",
-                          STORVSC_MAX_IO_REQUESTS,
-                          storvsc_drv_obj->max_outstanding_req_per_channel);
-               return -1;
-       }
-
-       drv->driver.name = storvsc_drv_obj->base.name;
-
-       drv->driver.probe = storvsc_probe;
-       drv->driver.remove = storvsc_remove;
-
-       /* The driver belongs to vmbus */
-       ret = vmbus_child_driver_register(&drv->driver);
-
-       return ret;
-}
-
-static int storvsc_drv_exit_cb(struct device *dev, void *data)
-{
-       struct device **curr = (struct device **)data;
-       *curr = dev;
-       return 1; /* stop iterating */
-}
-
-static void storvsc_drv_exit(void)
-{
-       struct storvsc_driver_object *storvsc_drv_obj = &g_storvsc_drv;
-       struct hv_driver *drv = &g_storvsc_drv.base;
-       struct device *current_dev = NULL;
-       int ret;
-
-       while (1) {
-               current_dev = NULL;
-
-               /* Get the device */
-               ret = driver_for_each_device(&drv->driver, NULL,
-                                            (void *) &current_dev,
-                                            storvsc_drv_exit_cb);
-
-               if (ret)
-                       DPRINT_WARN(STORVSC_DRV,
-                                   "driver_for_each_device returned %d", ret);
-
-               if (current_dev == NULL)
-                       break;
-
-               /* Initiate removal from the top-down */
-               device_unregister(current_dev);
-       }
-
-       if (storvsc_drv_obj->base.cleanup)
-               storvsc_drv_obj->base.cleanup(&storvsc_drv_obj->base);
-
-       vmbus_child_driver_unregister(&drv->driver);
-       return;
+       sdevice->sdev_bflags |= BLIST_SPARSELUN | BLIST_LARGELUN;
+       return 0;
 }
 
-/*
- * storvsc_probe - Add a new device for this driver
- */
-static int storvsc_probe(struct device *device)
+static int storvsc_merge_bvec(struct request_queue *q,
+                             struct bvec_merge_data *bmd, struct bio_vec *bvec)
 {
-       int ret;
-       struct hv_driver *drv =
-                               drv_to_hv_drv(device->driver);
-       struct storvsc_driver_object *storvsc_drv_obj = drv->priv;
-       struct hv_device *device_obj = device_to_hv_device(device);
-       struct Scsi_Host *host;
-       struct host_device_context *host_device_ctx;
-       struct storvsc_device_info device_info;
-
-       if (!storvsc_drv_obj->base.dev_add)
-               return -1;
-
-       host = scsi_host_alloc(&scsi_driver,
-                              sizeof(struct host_device_context));
-       if (!host) {
-               DPRINT_ERR(STORVSC_DRV, "unable to allocate scsi host object");
-               return -ENOMEM;
-       }
-
-       dev_set_drvdata(device, host);
-
-       host_device_ctx = (struct host_device_context *)host->hostdata;
-       memset(host_device_ctx, 0, sizeof(struct host_device_context));
-
-       host_device_ctx->port = host->host_no;
-       host_device_ctx->device_ctx = device_obj;
-
-       host_device_ctx->request_pool =
-                               kmem_cache_create(dev_name(&device_obj->device),
-                                       sizeof(struct storvsc_cmd_request) +
-                                       storvsc_drv_obj->request_ext_size, 0,
-                                       SLAB_HWCACHE_ALIGN, NULL);
-
-       if (!host_device_ctx->request_pool) {
-               scsi_host_put(host);
-               return -ENOMEM;
-       }
-
-       device_info.port_number = host->host_no;
-       /* Call to the vsc driver to add the device */
-       ret = storvsc_drv_obj->base.dev_add(device_obj,
-                                               (void *)&device_info);
-       if (ret != 0) {
-               DPRINT_ERR(STORVSC_DRV, "unable to add scsi vsc device");
-               kmem_cache_destroy(host_device_ctx->request_pool);
-               scsi_host_put(host);
-               return -1;
-       }
-
-       /* host_device_ctx->port = device_info.PortNumber; */
-       host_device_ctx->path = device_info.path_id;
-       host_device_ctx->target = device_info.target_id;
-
-       /* max # of devices per target */
-       host->max_lun = STORVSC_MAX_LUNS_PER_TARGET;
-       /* max # of targets per channel */
-       host->max_id = STORVSC_MAX_TARGETS;
-       /* max # of channels */
-       host->max_channel = STORVSC_MAX_CHANNELS - 1;
-
-       /* Register the HBA and start the scsi bus scan */
-       ret = scsi_add_host(host, device);
-       if (ret != 0) {
-               DPRINT_ERR(STORVSC_DRV, "unable to add scsi host device");
-
-               storvsc_drv_obj->base.dev_rm(device_obj);
-
-               kmem_cache_destroy(host_device_ctx->request_pool);
-               scsi_host_put(host);
-               return -1;
-       }
-
-       scsi_scan_host(host);
-       return ret;
+       /* checking done by caller. */
+       return bvec->bv_len;
 }
 
-/*
- * storvsc_remove - Callback when our device is removed
- */
-static int storvsc_remove(struct device *device)
+static int storvsc_device_configure(struct scsi_device *sdevice)
 {
-       int ret;
-       struct hv_driver *drv =
-                       drv_to_hv_drv(device->driver);
-       struct storvsc_driver_object *storvsc_drv_obj = drv->priv;
-       struct hv_device *device_obj = device_to_hv_device(device);
-       struct Scsi_Host *host = dev_get_drvdata(device);
-       struct host_device_context *host_device_ctx =
-                       (struct host_device_context *)host->hostdata;
-
-
-       if (!storvsc_drv_obj->base.dev_rm)
-               return -1;
+       scsi_adjust_queue_depth(sdevice, MSG_SIMPLE_TAG,
+                               STORVSC_MAX_IO_REQUESTS);
 
-       /*
-        * Call to the vsc driver to let it know that the device is being
-        * removed
-        */
-       ret = storvsc_drv_obj->base.dev_rm(device_obj);
-       if (ret != 0) {
-               /* TODO: */
-               DPRINT_ERR(STORVSC, "unable to remove vsc device (ret %d)",
-                          ret);
-       }
+       DPRINT_INFO(STORVSC_DRV, "sdev (%p) - setting max segment size to %ld",
+                   sdevice, PAGE_SIZE);
+       blk_queue_max_segment_size(sdevice->request_queue, PAGE_SIZE);
 
-       if (host_device_ctx->request_pool) {
-               kmem_cache_destroy(host_device_ctx->request_pool);
-               host_device_ctx->request_pool = NULL;
-       }
+       DPRINT_INFO(STORVSC_DRV, "sdev (%p) - adding merge bio vec routine",
+                   sdevice);
+       blk_queue_merge_bvec(sdevice->request_queue, storvsc_merge_bvec);
 
-       DPRINT_INFO(STORVSC, "removing host adapter (%p)...", host);
-       scsi_remove_host(host);
+       blk_queue_bounce_limit(sdevice->request_queue, BLK_BOUNCE_ANY);
 
-       DPRINT_INFO(STORVSC, "releasing host adapter (%p)...", host);
-       scsi_host_put(host);
-       return ret;
+       return 0;
 }
 
-/*
- * storvsc_commmand_completion - Command completion processing
- */
-static void storvsc_commmand_completion(struct hv_storvsc_request *request)
+static void destroy_bounce_buffer(struct scatterlist *sgl,
+                                 unsigned int sg_count)
 {
-       struct storvsc_cmd_request *cmd_request =
-               (struct storvsc_cmd_request *)request->context;
-       struct scsi_cmnd *scmnd = cmd_request->cmd;
-       struct host_device_context *host_device_ctx =
-               (struct host_device_context *)scmnd->device->host->hostdata;
-       void (*scsi_done_fn)(struct scsi_cmnd *);
-       struct scsi_sense_hdr sense_hdr;
-
-       /* ASSERT(request == &cmd_request->request); */
-       /* ASSERT(scmnd); */
-       /* ASSERT((unsigned long)scmnd->host_scribble == */
-       /*        (unsigned long)cmd_request); */
-       /* ASSERT(scmnd->scsi_done); */
-
-       if (cmd_request->bounce_sgl_count) {
-               /* using bounce buffer */
-               /* printk("copy_from_bounce_buffer\n"); */
-
-               /* FIXME: We can optimize on writes by just skipping this */
-               copy_from_bounce_buffer(scsi_sglist(scmnd),
-                                       cmd_request->bounce_sgl,
-                                       scsi_sg_count(scmnd));
-               destroy_bounce_buffer(cmd_request->bounce_sgl,
-                                     cmd_request->bounce_sgl_count);
-       }
-
-       scmnd->result = request->status;
+       int i;
+       struct page *page_buf;
 
-       if (scmnd->result) {
-               if (scsi_normalize_sense(scmnd->sense_buffer,
-                               request->sense_buffer_size, &sense_hdr))
-                       scsi_print_sense_hdr("storvsc", &sense_hdr);
+       for (i = 0; i < sg_count; i++) {
+               page_buf = sg_page((&sgl[i]));
+               if (page_buf != NULL)
+                       __free_page(page_buf);
        }
 
-       /* ASSERT(request->BytesXfer <= request->data_buffer.Length); */
-       scsi_set_resid(scmnd,
-               request->data_buffer.len - request->bytes_xfer);
-
-       scsi_done_fn = scmnd->scsi_done;
-
-       scmnd->host_scribble = NULL;
-       scmnd->scsi_done = NULL;
-
-       /* !!DO NOT MODIFY the scmnd after this call */
-       scsi_done_fn(scmnd);
-
-       kmem_cache_free(host_device_ctx->request_pool, cmd_request);
+       kfree(sgl);
 }
 
 static int do_bounce_buffer(struct scatterlist *sgl, unsigned int sg_count)
@@ -440,21 +176,72 @@ cleanup:
        return NULL;
 }
 
-static void destroy_bounce_buffer(struct scatterlist *sgl,
-                                 unsigned int sg_count)
+
+/* Assume the original sgl has enough room */
+static unsigned int copy_from_bounce_buffer(struct scatterlist *orig_sgl,
+                                           struct scatterlist *bounce_sgl,
+                                           unsigned int orig_sgl_count)
 {
        int i;
-       struct page *page_buf;
+       int j = 0;
+       unsigned long src, dest;
+       unsigned int srclen, destlen, copylen;
+       unsigned int total_copied = 0;
+       unsigned long bounce_addr = 0;
+       unsigned long dest_addr = 0;
+       unsigned long flags;
 
-       for (i = 0; i < sg_count; i++) {
-               page_buf = sg_page((&sgl[i]));
-               if (page_buf != NULL)
-                       __free_page(page_buf);
+       local_irq_save(flags);
+
+       for (i = 0; i < orig_sgl_count; i++) {
+               dest_addr = (unsigned long)kmap_atomic(sg_page((&orig_sgl[i])),
+                                       KM_IRQ0) + orig_sgl[i].offset;
+               dest = dest_addr;
+               destlen = orig_sgl[i].length;
+
+               if (bounce_addr == 0)
+                       bounce_addr =
+                       (unsigned long)kmap_atomic(sg_page((&bounce_sgl[j])),
+                                                       KM_IRQ0);
+
+               while (destlen) {
+                       src = bounce_addr + bounce_sgl[j].offset;
+                       srclen = bounce_sgl[j].length - bounce_sgl[j].offset;
+
+                       copylen = min(srclen, destlen);
+                       memcpy((void *)dest, (void *)src, copylen);
+
+                       total_copied += copylen;
+                       bounce_sgl[j].offset += copylen;
+                       destlen -= copylen;
+                       dest += copylen;
+
+                       if (bounce_sgl[j].offset == bounce_sgl[j].length) {
+                               /* full */
+                               kunmap_atomic((void *)bounce_addr, KM_IRQ0);
+                               j++;
+
+                               /* if we need to use another bounce buffer */
+                               if (destlen || i != orig_sgl_count - 1)
+                                       bounce_addr =
+                                       (unsigned long)kmap_atomic(
+                                       sg_page((&bounce_sgl[j])), KM_IRQ0);
+                       } else if (destlen == 0 && i == orig_sgl_count - 1) {
+                               /* unmap the last bounce that is < PAGE_SIZE */
+                               kunmap_atomic((void *)bounce_addr, KM_IRQ0);
+                       }
+               }
+
+               kunmap_atomic((void *)(dest_addr - orig_sgl[i].offset),
+                             KM_IRQ0);
        }
 
-       kfree(sgl);
+       local_irq_restore(flags);
+
+       return total_copied;
 }
 
+
 /* Assume the bounce_sgl has enough room ie using the create_bounce_buffer() */
 static unsigned int copy_to_bounce_buffer(struct scatterlist *orig_sgl,
                                          struct scatterlist *bounce_sgl,
@@ -477,107 +264,228 @@ static unsigned int copy_to_bounce_buffer(struct scatterlist *orig_sgl,
                src = src_addr;
                srclen = orig_sgl[i].length;
 
-               /* ASSERT(orig_sgl[i].offset + orig_sgl[i].length <= PAGE_SIZE); */
+               if (bounce_addr == 0)
+                       bounce_addr =
+                       (unsigned long)kmap_atomic(sg_page((&bounce_sgl[j])),
+                                               KM_IRQ0);
+
+               while (srclen) {
+                       /* assume bounce offset always == 0 */
+                       dest = bounce_addr + bounce_sgl[j].length;
+                       destlen = PAGE_SIZE - bounce_sgl[j].length;
+
+                       copylen = min(srclen, destlen);
+                       memcpy((void *)dest, (void *)src, copylen);
+
+                       total_copied += copylen;
+                       bounce_sgl[j].length += copylen;
+                       srclen -= copylen;
+                       src += copylen;
+
+                       if (bounce_sgl[j].length == PAGE_SIZE) {
+                               /* full..move to next entry */
+                               kunmap_atomic((void *)bounce_addr, KM_IRQ0);
+                               j++;
+
+                               /* if we need to use another bounce buffer */
+                               if (srclen || i != orig_sgl_count - 1)
+                                       bounce_addr =
+                                       (unsigned long)kmap_atomic(
+                                       sg_page((&bounce_sgl[j])), KM_IRQ0);
+
+                       } else if (srclen == 0 && i == orig_sgl_count - 1) {
+                               /* unmap the last bounce that is < PAGE_SIZE */
+                               kunmap_atomic((void *)bounce_addr, KM_IRQ0);
+                       }
+               }
+
+               kunmap_atomic((void *)(src_addr - orig_sgl[i].offset), KM_IRQ0);
+       }
+
+       local_irq_restore(flags);
+
+       return total_copied;
+}
+
+
+/*
+ * storvsc_remove - Callback when our device is removed
+ */
+static int storvsc_remove(struct hv_device *dev)
+{
+       struct Scsi_Host *host = dev_get_drvdata(&dev->device);
+       struct hv_host_device *host_dev =
+                       (struct hv_host_device *)host->hostdata;
+
+       /*
+        * Call to the vsc driver to let it know that the device is being
+        * removed
+        */
+       storvsc_dev_remove(dev);
+
+       if (host_dev->request_pool) {
+               kmem_cache_destroy(host_dev->request_pool);
+               host_dev->request_pool = NULL;
+       }
+
+       DPRINT_INFO(STORVSC, "removing host adapter (%p)...", host);
+       scsi_remove_host(host);
+
+       DPRINT_INFO(STORVSC, "releasing host adapter (%p)...", host);
+       scsi_host_put(host);
+       return 0;
+}
+
+
+static int storvsc_get_chs(struct scsi_device *sdev, struct block_device * bdev,
+                          sector_t capacity, int *info)
+{
+       sector_t nsect = capacity;
+       sector_t cylinders = nsect;
+       int heads, sectors_pt;
+
+       /*
+        * We are making up these values; let us keep it simple.
+        */
+       heads = 0xff;
+       sectors_pt = 0x3f;      /* Sectors per track */
+       sector_div(cylinders, heads * sectors_pt);
+       if ((sector_t)(cylinders + 1) * heads * sectors_pt < nsect)
+               cylinders = 0xffff;
+
+       info[0] = heads;
+       info[1] = sectors_pt;
+       info[2] = (int)cylinders;
+
+       DPRINT_INFO(STORVSC_DRV, "CHS (%d, %d, %d)", (int)cylinders, heads,
+                       sectors_pt);
+
+       return 0;
+}
+
+static int storvsc_host_reset(struct hv_device *device)
+{
+       struct storvsc_device *stor_device;
+       struct hv_storvsc_request *request;
+       struct vstor_packet *vstor_packet;
+       int ret, t;
 
-               if (bounce_addr == 0)
-                       bounce_addr = (unsigned long)kmap_atomic(sg_page((&bounce_sgl[j])), KM_IRQ0);
+       DPRINT_INFO(STORVSC, "resetting host adapter...");
 
-               while (srclen) {
-                       /* assume bounce offset always == 0 */
-                       dest = bounce_addr + bounce_sgl[j].length;
-                       destlen = PAGE_SIZE - bounce_sgl[j].length;
+       stor_device = get_stor_device(device);
+       if (!stor_device)
+               return -1;
 
-                       copylen = min(srclen, destlen);
-                       memcpy((void *)dest, (void *)src, copylen);
+       request = &stor_device->reset_request;
+       vstor_packet = &request->vstor_packet;
 
-                       total_copied += copylen;
-                       bounce_sgl[j].length += copylen;
-                       srclen -= copylen;
-                       src += copylen;
+       init_completion(&request->wait_event);
 
-                       if (bounce_sgl[j].length == PAGE_SIZE) {
-                               /* full..move to next entry */
-                               kunmap_atomic((void *)bounce_addr, KM_IRQ0);
-                               j++;
+       vstor_packet->operation = VSTOR_OPERATION_RESET_BUS;
+       vstor_packet->flags = REQUEST_COMPLETION_FLAG;
+       vstor_packet->vm_srb.path_id = stor_device->path_id;
 
-                               /* if we need to use another bounce buffer */
-                               if (srclen || i != orig_sgl_count - 1)
-                                       bounce_addr = (unsigned long)kmap_atomic(sg_page((&bounce_sgl[j])), KM_IRQ0);
-                       } else if (srclen == 0 && i == orig_sgl_count - 1) {
-                               /* unmap the last bounce that is < PAGE_SIZE */
-                               kunmap_atomic((void *)bounce_addr, KM_IRQ0);
-                       }
-               }
+       ret = vmbus_sendpacket(device->channel, vstor_packet,
+                              sizeof(struct vstor_packet),
+                              (unsigned long)&stor_device->reset_request,
+                              VM_PKT_DATA_INBAND,
+                              VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
+       if (ret != 0)
+               goto cleanup;
 
-               kunmap_atomic((void *)(src_addr - orig_sgl[i].offset), KM_IRQ0);
+       t = wait_for_completion_timeout(&request->wait_event, HZ);
+       if (t == 0) {
+               ret = -ETIMEDOUT;
+               goto cleanup;
        }
 
-       local_irq_restore(flags);
+       DPRINT_INFO(STORVSC, "host adapter reset completed");
 
-       return total_copied;
+       /*
+        * At this point, all outstanding requests in the adapter
+        * should have been flushed out and return to us
+        */
+
+cleanup:
+       put_stor_device(device);
+       return ret;
 }
 
-/* Assume the original sgl has enough room */
-static unsigned int copy_from_bounce_buffer(struct scatterlist *orig_sgl,
-                                           struct scatterlist *bounce_sgl,
-                                           unsigned int orig_sgl_count)
+
+/*
+ * storvsc_host_reset_handler - Reset the scsi HBA
+ */
+static int storvsc_host_reset_handler(struct scsi_cmnd *scmnd)
 {
-       int i;
-       int j = 0;
-       unsigned long src, dest;
-       unsigned int srclen, destlen, copylen;
-       unsigned int total_copied = 0;
-       unsigned long bounce_addr = 0;
-       unsigned long dest_addr = 0;
-       unsigned long flags;
+       int ret;
+       struct hv_host_device *host_dev =
+               (struct hv_host_device *)scmnd->device->host->hostdata;
+       struct hv_device *dev = host_dev->dev;
 
-       local_irq_save(flags);
+       DPRINT_INFO(STORVSC_DRV, "sdev (%p) dev obj (%p) - host resetting...",
+                   scmnd->device, dev);
 
-       for (i = 0; i < orig_sgl_count; i++) {
-               dest_addr = (unsigned long)kmap_atomic(sg_page((&orig_sgl[i])),
-                                       KM_IRQ0) + orig_sgl[i].offset;
-               dest = dest_addr;
-               destlen = orig_sgl[i].length;
-               /* ASSERT(orig_sgl[i].offset + orig_sgl[i].length <= PAGE_SIZE); */
+       /* Invokes the vsc to reset the host/bus */
+       ret = storvsc_host_reset(dev);
+       if (ret != 0)
+               return ret;
 
-               if (bounce_addr == 0)
-                       bounce_addr = (unsigned long)kmap_atomic(sg_page((&bounce_sgl[j])), KM_IRQ0);
+       DPRINT_INFO(STORVSC_DRV, "sdev (%p) dev obj (%p) - host reseted",
+                   scmnd->device, dev);
 
-               while (destlen) {
-                       src = bounce_addr + bounce_sgl[j].offset;
-                       srclen = bounce_sgl[j].length - bounce_sgl[j].offset;
+       return ret;
+}
 
-                       copylen = min(srclen, destlen);
-                       memcpy((void *)dest, (void *)src, copylen);
 
-                       total_copied += copylen;
-                       bounce_sgl[j].offset += copylen;
-                       destlen -= copylen;
-                       dest += copylen;
+/*
+ * storvsc_commmand_completion - Command completion processing
+ */
+static void storvsc_commmand_completion(struct hv_storvsc_request *request)
+{
+       struct storvsc_cmd_request *cmd_request =
+               (struct storvsc_cmd_request *)request->context;
+       struct scsi_cmnd *scmnd = cmd_request->cmd;
+       struct hv_host_device *host_dev =
+               (struct hv_host_device *)scmnd->device->host->hostdata;
+       void (*scsi_done_fn)(struct scsi_cmnd *);
+       struct scsi_sense_hdr sense_hdr;
+       struct vmscsi_request *vm_srb;
 
-                       if (bounce_sgl[j].offset == bounce_sgl[j].length) {
-                               /* full */
-                               kunmap_atomic((void *)bounce_addr, KM_IRQ0);
-                               j++;
+       if (cmd_request->bounce_sgl_count) {
 
-                               /* if we need to use another bounce buffer */
-                               if (destlen || i != orig_sgl_count - 1)
-                                       bounce_addr = (unsigned long)kmap_atomic(sg_page((&bounce_sgl[j])), KM_IRQ0);
-                       } else if (destlen == 0 && i == orig_sgl_count - 1) {
-                               /* unmap the last bounce that is < PAGE_SIZE */
-                               kunmap_atomic((void *)bounce_addr, KM_IRQ0);
-                       }
-               }
+               /* FIXME: We can optimize on writes by just skipping this */
+               copy_from_bounce_buffer(scsi_sglist(scmnd),
+                                       cmd_request->bounce_sgl,
+                                       scsi_sg_count(scmnd));
+               destroy_bounce_buffer(cmd_request->bounce_sgl,
+                                     cmd_request->bounce_sgl_count);
+       }
 
-               kunmap_atomic((void *)(dest_addr - orig_sgl[i].offset),
-                             KM_IRQ0);
+       vm_srb = &request->vstor_packet.vm_srb;
+       scmnd->result = vm_srb->scsi_status;
+
+       if (scmnd->result) {
+               if (scsi_normalize_sense(scmnd->sense_buffer,
+                               SCSI_SENSE_BUFFERSIZE, &sense_hdr))
+                       scsi_print_sense_hdr("storvsc", &sense_hdr);
        }
 
-       local_irq_restore(flags);
+       scsi_set_resid(scmnd,
+               request->data_buffer.len -
+               vm_srb->data_transfer_length);
 
-       return total_copied;
+       scsi_done_fn = scmnd->scsi_done;
+
+       scmnd->host_scribble = NULL;
+       scmnd->scsi_done = NULL;
+
+       /* !!DO NOT MODIFY the scmnd after this call */
+       scsi_done_fn(scmnd);
+
+       kmem_cache_free(host_dev->request_pool, cmd_request);
 }
 
+
 /*
  * storvsc_queuecommand - Initiate command processing
  */
@@ -585,28 +493,20 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd,
                                void (*done)(struct scsi_cmnd *))
 {
        int ret;
-       struct host_device_context *host_device_ctx =
-               (struct host_device_context *)scmnd->device->host->hostdata;
-       struct hv_device *device_ctx = host_device_ctx->device_ctx;
-       struct hv_driver *drv =
-               drv_to_hv_drv(device_ctx->device.driver);
-       struct storvsc_driver_object *storvsc_drv_obj = drv->priv;
+       struct hv_host_device *host_dev =
+               (struct hv_host_device *)scmnd->device->host->hostdata;
+       struct hv_device *dev = host_dev->dev;
        struct hv_storvsc_request *request;
        struct storvsc_cmd_request *cmd_request;
        unsigned int request_size = 0;
        int i;
        struct scatterlist *sgl;
        unsigned int sg_count = 0;
+       struct vmscsi_request *vm_srb;
 
-       DPRINT_DBG(STORVSC_DRV, "scmnd %p dir %d, use_sg %d buf %p len %d "
-                  "queue depth %d tagged %d", scmnd, scmnd->sc_data_direction,
-                  scsi_sg_count(scmnd), scsi_sglist(scmnd),
-                  scsi_bufflen(scmnd), scmnd->device->queue_depth,
-                  scmnd->device->tagged_supported);
 
        /* If retrying, no need to prep the cmd */
        if (scmnd->host_scribble) {
-               /* ASSERT(scmnd->scsi_done != NULL); */
 
                cmd_request =
                        (struct storvsc_cmd_request *)scmnd->host_scribble;
@@ -616,18 +516,13 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd,
                goto retry_request;
        }
 
-       /* ASSERT(scmnd->scsi_done == NULL); */
-       /* ASSERT(scmnd->host_scribble == NULL); */
-
        scmnd->scsi_done = done;
 
        request_size = sizeof(struct storvsc_cmd_request);
 
-       cmd_request = kmem_cache_alloc(host_device_ctx->request_pool,
+       cmd_request = kmem_cache_zalloc(host_dev->request_pool,
                                       GFP_ATOMIC);
        if (!cmd_request) {
-               DPRINT_ERR(STORVSC_DRV, "scmnd (%p) - unable to allocate "
-                          "storvsc_cmd_request...marking queue busy", scmnd);
                scmnd->scsi_done = NULL;
                return SCSI_MLQUEUE_DEVICE_BUSY;
        }
@@ -640,40 +535,35 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd,
        scmnd->host_scribble = (unsigned char *)cmd_request;
 
        request = &cmd_request->request;
+       vm_srb = &request->vstor_packet.vm_srb;
 
-       request->extension =
-               (void *)((unsigned long)cmd_request + request_size);
-       DPRINT_DBG(STORVSC_DRV, "req %p size %d ext %d", request, request_size,
-                  storvsc_drv_obj->request_ext_size);
 
        /* Build the SRB */
        switch (scmnd->sc_data_direction) {
        case DMA_TO_DEVICE:
-               request->type = WRITE_TYPE;
+               vm_srb->data_in = WRITE_TYPE;
                break;
        case DMA_FROM_DEVICE:
-               request->type = READ_TYPE;
+               vm_srb->data_in = READ_TYPE;
                break;
        default:
-               request->type = UNKNOWN_TYPE;
+               vm_srb->data_in = UNKNOWN_TYPE;
                break;
        }
 
        request->on_io_completion = storvsc_commmand_completion;
        request->context = cmd_request;/* scmnd; */
 
-       /* request->PortId = scmnd->device->channel; */
-       request->host = host_device_ctx->port;
-       request->bus = scmnd->device->channel;
-       request->target_id = scmnd->device->id;
-       request->lun_id = scmnd->device->lun;
+       vm_srb->port_number = host_dev->port;
+       vm_srb->path_id = scmnd->device->channel;
+       vm_srb->target_id = scmnd->device->id;
+       vm_srb->lun = scmnd->device->lun;
+
+       vm_srb->cdb_length = scmnd->cmd_len;
 
-       /* ASSERT(scmnd->cmd_len <= 16); */
-       request->cdb_len = scmnd->cmd_len;
-       request->cdb = scmnd->cmnd;
+       memcpy(vm_srb->cdb, scmnd->cmnd, vm_srb->cdb_length);
 
        request->sense_buffer = scmnd->sense_buffer;
-       request->sense_buffer_size = SCSI_SENSE_BUFFERSIZE;
 
 
        request->data_buffer.len = scsi_bufflen(scmnd);
@@ -683,20 +573,13 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd,
 
                /* check if we need to bounce the sgl */
                if (do_bounce_buffer(sgl, scsi_sg_count(scmnd)) != -1) {
-                       DPRINT_INFO(STORVSC_DRV,
-                                   "need to bounce buffer for this scmnd %p",
-                                   scmnd);
                        cmd_request->bounce_sgl =
                                create_bounce_buffer(sgl, scsi_sg_count(scmnd),
                                                     scsi_bufflen(scmnd));
                        if (!cmd_request->bounce_sgl) {
-                               DPRINT_ERR(STORVSC_DRV,
-                                          "unable to create bounce buffer for "
-                                          "this scmnd %p", scmnd);
-
                                scmnd->scsi_done = NULL;
                                scmnd->host_scribble = NULL;
-                               kmem_cache_free(host_device_ctx->request_pool,
+                               kmem_cache_free(host_dev->request_pool,
                                                cmd_request);
 
                                return SCSI_MLQUEUE_HOST_BUSY;
@@ -719,14 +602,11 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd,
 
                request->data_buffer.offset = sgl[0].offset;
 
-               for (i = 0; i < sg_count; i++) {
-                       DPRINT_DBG(STORVSC_DRV, "sgl[%d] len %d offset %d\n",
-                                  i, sgl[i].length, sgl[i].offset);
+               for (i = 0; i < sg_count; i++)
                        request->data_buffer.pfn_array[i] =
                                page_to_pfn(sg_page((&sgl[i])));
-               }
+
        } else if (scsi_sglist(scmnd)) {
-               /* ASSERT(scsi_bufflen(scmnd) <= PAGE_SIZE); */
                request->data_buffer.offset =
                        virt_to_phys(scsi_sglist(scmnd)) & (PAGE_SIZE-1);
                request->data_buffer.pfn_array[0] =
@@ -735,13 +615,10 @@ static int storvsc_queuecommand_lck(struct scsi_cmnd *scmnd,
 
 retry_request:
        /* Invokes the vsc to start an IO */
-       ret = storvsc_drv_obj->on_io_request(device_ctx,
-                                          &cmd_request->request);
+       ret = storvsc_do_io(dev, &cmd_request->request);
+
        if (ret == -1) {
                /* no more space */
-               DPRINT_ERR(STORVSC_DRV,
-                          "scmnd (%p) - queue FULL...marking queue busy",
-                          scmnd);
 
                if (cmd_request->bounce_sgl_count) {
                        /*
@@ -755,7 +632,7 @@ retry_request:
                                              cmd_request->bounce_sgl_count);
                }
 
-               kmem_cache_free(host_device_ctx->request_pool, cmd_request);
+               kmem_cache_free(host_dev->request_pool, cmd_request);
 
                scmnd->scsi_done = NULL;
                scmnd->host_scribble = NULL;
@@ -768,154 +645,156 @@ retry_request:
 
 static DEF_SCSI_QCMD(storvsc_queuecommand)
 
-static int storvsc_merge_bvec(struct request_queue *q,
-                             struct bvec_merge_data *bmd, struct bio_vec *bvec)
-{
-       /* checking done by caller. */
-       return bvec->bv_len;
-}
 
-/*
- * storvsc_device_configure - Configure the specified scsi device
- */
-static int storvsc_device_alloc(struct scsi_device *sdevice)
-{
-       DPRINT_DBG(STORVSC_DRV, "sdev (%p) - setting device flag to %d",
-                  sdevice, BLIST_SPARSELUN);
+/* Scsi driver */
+static struct scsi_host_template scsi_driver = {
+       .module =               THIS_MODULE,
+       .name =                 "storvsc_host_t",
+       .bios_param =           storvsc_get_chs,
+       .queuecommand =         storvsc_queuecommand,
+       .eh_host_reset_handler =        storvsc_host_reset_handler,
+       .slave_alloc =          storvsc_device_alloc,
+       .slave_configure =      storvsc_device_configure,
+       .cmd_per_lun =          1,
+       /* 64 max_queue * 1 target */
+       .can_queue =            STORVSC_MAX_IO_REQUESTS*STORVSC_MAX_TARGETS,
+       .this_id =              -1,
+       /* no use setting to 0 since ll_blk_rw reset it to 1 */
+       /* currently 32 */
+       .sg_tablesize =         MAX_MULTIPAGE_BUFFER_COUNT,
        /*
-        * This enables luns to be located sparsely. Otherwise, we may not
-        * discovered them.
+        * ENABLE_CLUSTERING allows mutiple physically contig bio_vecs to merge
+        * into 1 sg element. If set, we must limit the max_segment_size to
+        * PAGE_SIZE, otherwise we may get 1 sg element that represents
+        * multiple
         */
-       sdevice->sdev_bflags |= BLIST_SPARSELUN | BLIST_LARGELUN;
-       return 0;
-}
+       /* physically contig pfns (ie sg[x].length > PAGE_SIZE). */
+       .use_clustering =       ENABLE_CLUSTERING,
+       /* Make sure we dont get a sg segment crosses a page boundary */
+       .dma_boundary =         PAGE_SIZE-1,
+};
 
-static int storvsc_device_configure(struct scsi_device *sdevice)
+
+/*
+ * storvsc_probe - Add a new device for this driver
+ */
+
+static int storvsc_probe(struct hv_device *device)
 {
-       DPRINT_INFO(STORVSC_DRV, "sdev (%p) - curr queue depth %d", sdevice,
-                   sdevice->queue_depth);
+       int ret;
+       struct Scsi_Host *host;
+       struct hv_host_device *host_dev;
+       struct storvsc_device_info device_info;
 
-       DPRINT_INFO(STORVSC_DRV, "sdev (%p) - setting queue depth to %d",
-                   sdevice, STORVSC_MAX_IO_REQUESTS);
-       scsi_adjust_queue_depth(sdevice, MSG_SIMPLE_TAG,
-                               STORVSC_MAX_IO_REQUESTS);
+       host = scsi_host_alloc(&scsi_driver,
+                              sizeof(struct hv_host_device));
+       if (!host)
+               return -ENOMEM;
 
-       DPRINT_INFO(STORVSC_DRV, "sdev (%p) - setting max segment size to %ld",
-                   sdevice, PAGE_SIZE);
-       blk_queue_max_segment_size(sdevice->request_queue, PAGE_SIZE);
+       dev_set_drvdata(&device->device, host);
 
-       DPRINT_INFO(STORVSC_DRV, "sdev (%p) - adding merge bio vec routine",
-                   sdevice);
-       blk_queue_merge_bvec(sdevice->request_queue, storvsc_merge_bvec);
+       host_dev = (struct hv_host_device *)host->hostdata;
+       memset(host_dev, 0, sizeof(struct hv_host_device));
 
-       blk_queue_bounce_limit(sdevice->request_queue, BLK_BOUNCE_ANY);
-       /* sdevice->timeout = (2000 * HZ);//(75 * HZ); */
+       host_dev->port = host->host_no;
+       host_dev->dev = device;
 
-       return 0;
-}
+       host_dev->request_pool =
+                               kmem_cache_create(dev_name(&device->device),
+                                       sizeof(struct storvsc_cmd_request), 0,
+                                       SLAB_HWCACHE_ALIGN, NULL);
 
-/*
- * storvsc_host_reset_handler - Reset the scsi HBA
- */
-static int storvsc_host_reset_handler(struct scsi_cmnd *scmnd)
-{
-       int ret;
-       struct host_device_context *host_device_ctx =
-               (struct host_device_context *)scmnd->device->host->hostdata;
-       struct hv_device *device_ctx = host_device_ctx->device_ctx;
+       if (!host_dev->request_pool) {
+               scsi_host_put(host);
+               return -ENOMEM;
+       }
 
-       DPRINT_INFO(STORVSC_DRV, "sdev (%p) dev obj (%p) - host resetting...",
-                   scmnd->device, device_ctx);
+       device_info.port_number = host->host_no;
+       device_info.ring_buffer_size  = storvsc_ringbuffer_size;
+       /* Call to the vsc driver to add the device */
+       ret = storvsc_dev_add(device, (void *)&device_info);
 
-       /* Invokes the vsc to reset the host/bus */
-       ret = stor_vsc_on_host_reset(device_ctx);
-       if (ret != 0)
-               return ret;
+       if (ret != 0) {
+               kmem_cache_destroy(host_dev->request_pool);
+               scsi_host_put(host);
+               return -1;
+       }
 
-       DPRINT_INFO(STORVSC_DRV, "sdev (%p) dev obj (%p) - host reseted",
-                   scmnd->device, device_ctx);
+       host_dev->path = device_info.path_id;
+       host_dev->target = device_info.target_id;
 
-       return ret;
-}
+       /* max # of devices per target */
+       host->max_lun = STORVSC_MAX_LUNS_PER_TARGET;
+       /* max # of targets per channel */
+       host->max_id = STORVSC_MAX_TARGETS;
+       /* max # of channels */
+       host->max_channel = STORVSC_MAX_CHANNELS - 1;
 
-static int storvsc_get_chs(struct scsi_device *sdev, struct block_device * bdev,
-                          sector_t capacity, int *info)
-{
-       sector_t total_sectors = capacity;
-       sector_t cylinder_times_heads = 0;
-       sector_t temp = 0;
+       /* Register the HBA and start the scsi bus scan */
+       ret = scsi_add_host(host, &device->device);
+       if (ret != 0) {
 
-       int sectors_per_track = 0;
-       int heads = 0;
-       int cylinders = 0;
-       int rem = 0;
+               storvsc_dev_remove(device);
 
-       if (total_sectors > (65535 * 16 * 255))
-               total_sectors = (65535 * 16 * 255);
+               kmem_cache_destroy(host_dev->request_pool);
+               scsi_host_put(host);
+               return -1;
+       }
 
-       if (total_sectors >= (65535 * 16 * 63)) {
-               sectors_per_track = 255;
-               heads = 16;
+       scsi_scan_host(host);
+       return ret;
+}
 
-               cylinder_times_heads = total_sectors;
-               /* sector_div stores the quotient in cylinder_times_heads */
-               rem = sector_div(cylinder_times_heads, sectors_per_track);
-       } else {
-               sectors_per_track = 17;
+/* The one and only one */
 
-               cylinder_times_heads = total_sectors;
-               /* sector_div stores the quotient in cylinder_times_heads */
-               rem = sector_div(cylinder_times_heads, sectors_per_track);
+static struct hv_driver storvsc_drv = {
+       .probe = storvsc_probe,
+       .remove = storvsc_remove,
+};
 
-               temp = cylinder_times_heads + 1023;
-               /* sector_div stores the quotient in temp */
-               rem = sector_div(temp, 1024);
 
-               heads = temp;
+/*
+ * storvsc_drv_init - StorVsc driver initialization.
+ */
+static int storvsc_drv_init(void)
+{
+       int ret;
+       struct hv_driver *drv = &storvsc_drv;
+       u32 max_outstanding_req_per_channel;
 
-               if (heads < 4)
-                       heads = 4;
+       /*
+        * Divide the ring buffer data size (which is 1 page less
+        * than the ring buffer size since that page is reserved for
+        * the ring buffer indices) by the max request size (which is
+        * vmbus_channel_packet_multipage_buffer + struct vstor_packet + u64)
+        */
 
-               if (cylinder_times_heads >= (heads * 1024) || (heads > 16)) {
-                       sectors_per_track = 31;
-                       heads = 16;
+       max_outstanding_req_per_channel =
+       ((storvsc_ringbuffer_size - PAGE_SIZE) /
+       ALIGN(MAX_MULTIPAGE_BUFFER_PACKET +
+       sizeof(struct vstor_packet) + sizeof(u64),
+       sizeof(u64)));
 
-                       cylinder_times_heads = total_sectors;
-                       /*
-                        * sector_div stores the quotient in
-                        * cylinder_times_heads
-                        */
-                       rem = sector_div(cylinder_times_heads,
-                                        sectors_per_track);
-               }
+       memcpy(&drv->dev_type, &gStorVscDeviceType,
+              sizeof(struct hv_guid));
 
-               if (cylinder_times_heads >= (heads * 1024)) {
-                       sectors_per_track = 63;
-                       heads = 16;
+       if (max_outstanding_req_per_channel <
+           STORVSC_MAX_IO_REQUESTS)
+               return -1;
 
-                       cylinder_times_heads = total_sectors;
-                       /*
-                        * sector_div stores the quotient in
-                        * cylinder_times_heads
-                        */
-                       rem = sector_div(cylinder_times_heads,
-                                        sectors_per_track);
-               }
-       }
+       drv->name = driver_name;
+       drv->driver.name = driver_name;
 
-       temp = cylinder_times_heads;
-       /* sector_div stores the quotient in temp */
-       rem = sector_div(temp, heads);
-       cylinders = temp;
 
-       info[0] = heads;
-       info[1] = sectors_per_track;
-       info[2] = cylinders;
+       /* The driver belongs to vmbus */
+       ret = vmbus_child_driver_register(&drv->driver);
 
-       DPRINT_INFO(STORVSC_DRV, "CHS (%d, %d, %d)", cylinders, heads,
-                   sectors_per_track);
+       return ret;
+}
 
-    return 0;
+static void storvsc_drv_exit(void)
+{
+       vmbus_child_driver_unregister(&storvsc_drv.driver);
 }
 
 static int __init storvsc_init(void)
@@ -923,7 +802,7 @@ static int __init storvsc_init(void)
        int ret;
 
        DPRINT_INFO(STORVSC_DRV, "Storvsc initializing....");
-       ret = storvsc_drv_init(stor_vsc_initialize);
+       ret = storvsc_drv_init();
        return ret;
 }
 
diff --git a/drivers/staging/hv/utils.h b/drivers/staging/hv/utils.h
deleted file mode 100644 (file)
index acebbbf..0000000
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright (c) 2009, Microsoft Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place - Suite 330, Boston, MA 02111-1307 USA.
- *
- * Authors:
- *   Haiyang Zhang <haiyangz@microsoft.com>
- *   Hank Janssen  <hjanssen@microsoft.com>
- */
-#ifndef __HV_UTILS_H_
-#define __HV_UTILS_H_
-
-/*
- * Common header for Hyper-V ICs
- */
-#define ICMSGTYPE_NEGOTIATE            0
-#define ICMSGTYPE_HEARTBEAT            1
-#define ICMSGTYPE_KVPEXCHANGE          2
-#define ICMSGTYPE_SHUTDOWN             3
-#define ICMSGTYPE_TIMESYNC             4
-#define ICMSGTYPE_VSS                  5
-
-#define ICMSGHDRFLAG_TRANSACTION       1
-#define ICMSGHDRFLAG_REQUEST           2
-#define ICMSGHDRFLAG_RESPONSE          4
-
-#define HV_S_OK                                0x00000000
-#define HV_E_FAIL                      0x80004005
-#define HV_ERROR_NOT_SUPPORTED         0x80070032
-#define HV_ERROR_MACHINE_LOCKED                0x800704F7
-
-struct vmbuspipe_hdr {
-       u32 flags;
-       u32 msgsize;
-} __packed;
-
-struct ic_version {
-       u16 major;
-       u16 minor;
-} __packed;
-
-struct icmsg_hdr {
-       struct ic_version icverframe;
-       u16 icmsgtype;
-       struct ic_version icvermsg;
-       u16 icmsgsize;
-       u32 status;
-       u8 ictransaction_id;
-       u8 icflags;
-       u8 reserved[2];
-} __packed;
-
-struct icmsg_negotiate {
-       u16 icframe_vercnt;
-       u16 icmsg_vercnt;
-       u32 reserved;
-       struct ic_version icversion_data[1]; /* any size array */
-} __packed;
-
-struct shutdown_msg_data {
-       u32 reason_code;
-       u32 timeout_seconds;
-       u32 flags;
-       u8  display_message[2048];
-} __packed;
-
-struct heartbeat_msg_data {
-       u64 seq_num;
-       u32 reserved[8];
-} __packed;
-
-/* Time Sync IC defs */
-#define ICTIMESYNCFLAG_PROBE   0
-#define ICTIMESYNCFLAG_SYNC    1
-#define ICTIMESYNCFLAG_SAMPLE  2
-
-#ifdef __x86_64__
-#define WLTIMEDELTA    116444736000000000L     /* in 100ns unit */
-#else
-#define WLTIMEDELTA    116444736000000000LL
-#endif
-
-struct ictimesync_data{
-       u64 parenttime;
-       u64 childtime;
-       u64 roundtriptime;
-       u8 flags;
-} __packed;
-
-/* Index for each IC struct in array hv_cb_utils[] */
-#define HV_SHUTDOWN_MSG                0
-#define HV_TIMESYNC_MSG                1
-#define HV_HEARTBEAT_MSG       2
-#define HV_KVP_MSG             3
-
-struct hyperv_service_callback {
-       u8 msg_type;
-       char *log_msg;
-       unsigned char data[16];
-       struct vmbus_channel *channel;
-       void (*callback) (void *context);
-};
-
-extern void prep_negotiate_resp(struct icmsg_hdr *,
-                               struct icmsg_negotiate *, u8 *);
-extern void chn_cb_negotiate(void *);
-extern struct hyperv_service_callback hv_cb_utils[];
-
-#endif /* __HV_UTILS_H_ */
diff --git a/drivers/staging/hv/version_info.h b/drivers/staging/hv/version_info.h
deleted file mode 100644 (file)
index 35178f2..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- *
- * Copyright (c) 2009, Microsoft Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place - Suite 330, Boston, MA 02111-1307 USA.
- *
- * Authors:
- *   Haiyang Zhang <haiyangz@microsoft.com>
- *   Hank Janssen  <hjanssen@microsoft.com>
- *
- */
-
-#ifndef __HV_VERSION_INFO
-#define __HV_VERSION_INFO
-
-/*
- * We use the same version numbering for all Hyper-V modules.
- *
- * Definition of versioning is as follows;
- *
- *     Major Number    Changes for these scenarios;
- *                     1.      When a new version of Windows Hyper-V
- *                             is released.
- *                     2.      A Major change has occurred in the
- *                             Linux IC's.
- *                     (For example the merge for the first time
- *                     into the kernel) Every time the Major Number
- *                     changes, the Revision number is reset to 0.
- *     Minor Number    Changes when new functionality is added
- *                     to the Linux IC's that is not a bug fix.
- *
- * 3.1 - Added completed hv_utils driver. Shutdown/Heartbeat/Timesync
- */
-#define HV_DRV_VERSION           "3.1"
-
-
-#endif
diff --git a/drivers/staging/hv/vmbus.h b/drivers/staging/hv/vmbus.h
deleted file mode 100644 (file)
index 73087f2..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- *
- * Copyright (c) 2009, Microsoft Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place - Suite 330, Boston, MA 02111-1307 USA.
- *
- * Authors:
- *   Haiyang Zhang <haiyangz@microsoft.com>
- *   Hank Janssen  <hjanssen@microsoft.com>
- *
- */
-
-
-#ifndef _VMBUS_H_
-#define _VMBUS_H_
-
-#include <linux/device.h>
-#include "vmbus_api.h"
-
-
-
-
-static inline struct hv_device *device_to_hv_device(struct device *d)
-{
-       return container_of(d, struct hv_device, device);
-}
-
-static inline struct hv_driver *drv_to_hv_drv(struct device_driver *d)
-{
-       return container_of(d, struct hv_driver, driver);
-}
-
-
-/* Vmbus interface */
-int vmbus_child_driver_register(struct device_driver *drv);
-void vmbus_child_driver_unregister(struct device_driver *drv);
-
-extern struct completion hv_channel_ready;
-
-#endif /* _VMBUS_H_ */
diff --git a/drivers/staging/hv/vmbus_api.h b/drivers/staging/hv/vmbus_api.h
deleted file mode 100644 (file)
index f0d96eb..0000000
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- *
- * Copyright (c) 2009, Microsoft Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place - Suite 330, Boston, MA 02111-1307 USA.
- *
- * Authors:
- *   Haiyang Zhang <haiyangz@microsoft.com>
- *   Hank Janssen  <hjanssen@microsoft.com>
- *
- */
-
-
-#ifndef _VMBUS_API_H_
-#define _VMBUS_API_H_
-
-#include <linux/device.h>
-#include <linux/workqueue.h>
-
-#define MAX_PAGE_BUFFER_COUNT                          16
-#define MAX_MULTIPAGE_BUFFER_COUNT                     32 /* 128K */
-
-#pragma pack(push, 1)
-
-/* Single-page buffer */
-struct hv_page_buffer {
-       u32 len;
-       u32 offset;
-       u64 pfn;
-};
-
-/* Multiple-page buffer */
-struct hv_multipage_buffer {
-       /* Length and Offset determines the # of pfns in the array */
-       u32 len;
-       u32 offset;
-       u64 pfn_array[MAX_MULTIPAGE_BUFFER_COUNT];
-};
-
-/* 0x18 includes the proprietary packet header */
-#define MAX_PAGE_BUFFER_PACKET         (0x18 +                 \
-                                       (sizeof(struct hv_page_buffer) * \
-                                        MAX_PAGE_BUFFER_COUNT))
-#define MAX_MULTIPAGE_BUFFER_PACKET    (0x18 +                 \
-                                        sizeof(struct hv_multipage_buffer))
-
-
-#pragma pack(pop)
-
-struct hv_driver;
-struct hv_device;
-
-struct hv_dev_port_info {
-       u32 int_mask;
-       u32 read_idx;
-       u32 write_idx;
-       u32 bytes_avail_toread;
-       u32 bytes_avail_towrite;
-};
-
-struct hv_device_info {
-       u32 chn_id;
-       u32 chn_state;
-       struct hv_guid chn_type;
-       struct hv_guid chn_instance;
-
-       u32 monitor_id;
-       u32 server_monitor_pending;
-       u32 server_monitor_latency;
-       u32 server_monitor_conn_id;
-       u32 client_monitor_pending;
-       u32 client_monitor_latency;
-       u32 client_monitor_conn_id;
-
-       struct hv_dev_port_info inbound;
-       struct hv_dev_port_info outbound;
-};
-
-/* Base driver object */
-struct hv_driver {
-       const char *name;
-
-       /* the device type supported by this driver */
-       struct hv_guid dev_type;
-
-       /*
-        * Device type specific drivers (net, blk etc.)
-        * need a mechanism to get a pointer to
-        * device type specific driver structure given
-        * a pointer to the base hyperv driver structure.
-        * The current code solves this problem using
-        * a hack. Support this need explicitly
-        */
-       void *priv;
-
-       struct device_driver driver;
-
-       int (*dev_add)(struct hv_device *device, void *data);
-       int (*dev_rm)(struct hv_device *device);
-       void (*cleanup)(struct hv_driver *driver);
-};
-
-/* Base device object */
-struct hv_device {
-       /* the driver for this device */
-       struct hv_driver *drv;
-
-       char name[64];
-
-       struct work_struct probe_failed_work_item;
-
-       int probe_error;
-
-       /* the device type id of this device */
-       struct hv_guid dev_type;
-
-       /* the device instance id of this device */
-       struct hv_guid dev_instance;
-
-       struct device device;
-
-       struct vmbus_channel *channel;
-
-       /* Device extension; */
-       void *ext;
-};
-
-#endif /* _VMBUS_API_H_ */
diff --git a/drivers/staging/hv/vmbus_channel_interface.h b/drivers/staging/hv/vmbus_channel_interface.h
deleted file mode 100644 (file)
index 20ae258..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- *
- * Copyright (c) 2009, Microsoft Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place - Suite 330, Boston, MA 02111-1307 USA.
- *
- * Authors:
- *   Haiyang Zhang <haiyangz@microsoft.com>
- *   Hank Janssen  <hjanssen@microsoft.com>
- *
- */
-
-#ifndef __VMBUSCHANNELINTERFACE_H
-#define __VMBUSCHANNELINTERFACE_H
-
-/*
- * A revision number of vmbus that is used for ensuring both ends on a
- * partition are using compatible versions.
- */
-#define VMBUS_REVISION_NUMBER          13
-
-/* Make maximum size of pipe payload of 16K */
-#define MAX_PIPE_DATA_PAYLOAD          (sizeof(u8) * 16384)
-
-/* Define PipeMode values. */
-#define VMBUS_PIPE_TYPE_BYTE           0x00000000
-#define VMBUS_PIPE_TYPE_MESSAGE                0x00000004
-
-/* The size of the user defined data buffer for non-pipe offers. */
-#define MAX_USER_DEFINED_BYTES         120
-
-/* The size of the user defined data buffer for pipe offers. */
-#define MAX_PIPE_USER_DEFINED_BYTES    116
-
-/*
- * At the center of the Channel Management library is the Channel Offer. This
- * struct contains the fundamental information about an offer.
- */
-struct vmbus_channel_offer {
-       struct hv_guid if_type;
-       struct hv_guid if_instance;
-       u64 int_latency; /* in 100ns units */
-       u32 if_revision;
-       u32 server_ctx_size;    /* in bytes */
-       u16 chn_flags;
-       u16 mmio_megabytes;             /* in bytes * 1024 * 1024 */
-
-       union {
-               /* Non-pipes: The user has MAX_USER_DEFINED_BYTES bytes. */
-               struct {
-                       unsigned char user_def[MAX_USER_DEFINED_BYTES];
-               } std;
-
-               /*
-                * Pipes:
-                * The following sructure is an integrated pipe protocol, which
-                * is implemented on top of standard user-defined data. Pipe
-                * clients have MAX_PIPE_USER_DEFINED_BYTES left for their own
-                * use.
-                */
-               struct {
-                       u32  pipe_mode;
-                       unsigned char user_def[MAX_PIPE_USER_DEFINED_BYTES];
-               } pipe;
-       } u;
-       u32 padding;
-} __packed;
-
-/* Server Flags */
-#define VMBUS_CHANNEL_ENUMERATE_DEVICE_INTERFACE       1
-#define VMBUS_CHANNEL_SERVER_SUPPORTS_TRANSFER_PAGES   2
-#define VMBUS_CHANNEL_SERVER_SUPPORTS_GPADLS           4
-#define VMBUS_CHANNEL_NAMED_PIPE_MODE                  0x10
-#define VMBUS_CHANNEL_LOOPBACK_OFFER                   0x100
-#define VMBUS_CHANNEL_PARENT_OFFER                     0x200
-#define VMBUS_CHANNEL_REQUEST_MONITORED_NOTIFICATION   0x400
-
-#endif
index 79089f85d903a1ca4caa170346b00ac607eacdea..ec1d38cd481c74a8eec2e9df608762d4417b33bb 100644 (file)
  * Authors:
  *   Haiyang Zhang <haiyangz@microsoft.com>
  *   Hank Janssen  <hjanssen@microsoft.com>
+ *   K. Y. Srinivasan <kys@microsoft.com>
+ *
  */
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/device.h>
 #include <linux/pci.h>
 #include <linux/dmi.h>
 #include <linux/slab.h>
+#include <linux/acpi.h>
+#include <acpi/acpi_bus.h>
 #include <linux/completion.h>
-#include "version_info.h"
-#include "hv_api.h"
-#include "logging.h"
-#include "vmbus.h"
-#include "channel.h"
-#include "vmbus_private.h"
-
-
-/* FIXME! We need to do this dynamically for PIC and APIC system */
-#define VMBUS_IRQ              0x5
-#define VMBUS_IRQ_VECTOR       IRQ5_VECTOR
-
-/* Main vmbus driver data structure */
-struct vmbus_driver_context {
-
-       struct bus_type bus;
-       struct tasklet_struct msg_dpc;
-       struct tasklet_struct event_dpc;
-
-       /* The bus root device */
-       struct hv_device device_ctx;
-};
-
-static int vmbus_match(struct device *device, struct device_driver *driver);
-static int vmbus_probe(struct device *device);
-static int vmbus_remove(struct device *device);
-static void vmbus_shutdown(struct device *device);
-static int vmbus_uevent(struct device *device, struct kobj_uevent_env *env);
 
-static irqreturn_t vmbus_isr(int irq, void *dev_id);
+#include "hyperv.h"
+#include "hyperv_vmbus.h"
 
-static void vmbus_device_release(struct device *device);
-static void vmbus_bus_release(struct device *device);
 
-static ssize_t vmbus_show_device_attr(struct device *dev,
-                                     struct device_attribute *dev_attr,
-                                     char *buf);
+static struct pci_dev *hv_pci_dev;
 
+static struct tasklet_struct msg_dpc;
+static struct tasklet_struct event_dpc;
 
 unsigned int vmbus_loglevel = (ALL_MODULES << 16 | INFO_LVL);
 EXPORT_SYMBOL(vmbus_loglevel);
        /* (ALL_MODULES << 16 | DEBUG_LVL_ENTEREXIT); */
        /* (((VMBUS | VMBUS_DRV)<<16) | DEBUG_LVL_ENTEREXIT); */
 
-static int vmbus_irq = VMBUS_IRQ;
-
-/* Set up per device attributes in /sys/bus/vmbus/devices/<bus device> */
-static struct device_attribute vmbus_device_attrs[] = {
-       __ATTR(id, S_IRUGO, vmbus_show_device_attr, NULL),
-       __ATTR(state, S_IRUGO, vmbus_show_device_attr, NULL),
-       __ATTR(class_id, S_IRUGO, vmbus_show_device_attr, NULL),
-       __ATTR(device_id, S_IRUGO, vmbus_show_device_attr, NULL),
-       __ATTR(monitor_id, S_IRUGO, vmbus_show_device_attr, NULL),
-
-       __ATTR(server_monitor_pending, S_IRUGO, vmbus_show_device_attr, NULL),
-       __ATTR(server_monitor_latency, S_IRUGO, vmbus_show_device_attr, NULL),
-       __ATTR(server_monitor_conn_id, S_IRUGO, vmbus_show_device_attr, NULL),
-
-       __ATTR(client_monitor_pending, S_IRUGO, vmbus_show_device_attr, NULL),
-       __ATTR(client_monitor_latency, S_IRUGO, vmbus_show_device_attr, NULL),
-       __ATTR(client_monitor_conn_id, S_IRUGO, vmbus_show_device_attr, NULL),
-
-       __ATTR(out_intr_mask, S_IRUGO, vmbus_show_device_attr, NULL),
-       __ATTR(out_read_index, S_IRUGO, vmbus_show_device_attr, NULL),
-       __ATTR(out_write_index, S_IRUGO, vmbus_show_device_attr, NULL),
-       __ATTR(out_read_bytes_avail, S_IRUGO, vmbus_show_device_attr, NULL),
-       __ATTR(out_write_bytes_avail, S_IRUGO, vmbus_show_device_attr, NULL),
-
-       __ATTR(in_intr_mask, S_IRUGO, vmbus_show_device_attr, NULL),
-       __ATTR(in_read_index, S_IRUGO, vmbus_show_device_attr, NULL),
-       __ATTR(in_write_index, S_IRUGO, vmbus_show_device_attr, NULL),
-       __ATTR(in_read_bytes_avail, S_IRUGO, vmbus_show_device_attr, NULL),
-       __ATTR(in_write_bytes_avail, S_IRUGO, vmbus_show_device_attr, NULL),
-       __ATTR_NULL
-};
-
-/* The one and only one */
-static struct vmbus_driver_context vmbus_drv = {
-       .bus.name =             "vmbus",
-       .bus.match =            vmbus_match,
-       .bus.shutdown =         vmbus_shutdown,
-       .bus.remove =           vmbus_remove,
-       .bus.probe =            vmbus_probe,
-       .bus.uevent =           vmbus_uevent,
-       .bus.dev_attrs =        vmbus_device_attrs,
-};
-
-static const char *driver_name = "hyperv";
-
-/*
- * Windows vmbus does not defined this.
- * We defined this to be consistent with other devices
- */
-/* {c5295816-f63a-4d5f-8d1a-4daf999ca185} */
-static const struct hv_guid device_type = {
-       .data = {
-               0x16, 0x58, 0x29, 0xc5, 0x3a, 0xf6, 0x5f, 0x4d,
-               0x8d, 0x1a, 0x4d, 0xaf, 0x99, 0x9c, 0xa1, 0x85
-       }
-};
-
-/* {ac3760fc-9adf-40aa-9427-a70ed6de95c5} */
-static const struct hv_guid device_id = {
-       .data = {
-               0xfc, 0x60, 0x37, 0xac, 0xdf, 0x9a, 0xaa, 0x40,
-               0x94, 0x27, 0xa7, 0x0e, 0xd6, 0xde, 0x95, 0xc5
-       }
-};
-
-static struct hv_device *vmbus_device; /* vmbus root device */
-
-
-/*
- * vmbus_dev_add - Callback when the root bus device is added
- */
-static int vmbus_dev_add(struct hv_device *dev, void *info)
-{
-       u32 *irqvector = info;
-       int ret;
-
-       vmbus_device = dev;
-
-       memcpy(&vmbus_device->dev_type, &device_type, sizeof(struct hv_guid));
-       memcpy(&vmbus_device->dev_instance, &device_id,
-              sizeof(struct hv_guid));
-
-       /* strcpy(dev->name, "vmbus"); */
-       /* SynIC setup... */
-       on_each_cpu(hv_synic_init, (void *)irqvector, 1);
-
-       /* Connect to VMBus in the root partition */
-       ret = vmbus_connect();
-
-       /* VmbusSendEvent(device->localPortId+1); */
-       return ret;
-}
-
-
-struct onmessage_work_context {
-       struct work_struct work;
-       struct hv_message msg;
-};
-
-static void vmbus_onmessage_work(struct work_struct *work)
-{
-       struct onmessage_work_context *ctx;
-
-       ctx = container_of(work, struct onmessage_work_context,
-                          work);
-       vmbus_onmessage(&ctx->msg);
-       kfree(ctx);
-}
-
-/*
- * vmbus_on_msg_dpc - DPC routine to handle messages from the hypervisior
- */
-static void vmbus_on_msg_dpc(unsigned long data)
-{
-       int cpu = smp_processor_id();
-       void *page_addr = hv_context.synic_message_page[cpu];
-       struct hv_message *msg = (struct hv_message *)page_addr +
-                                 VMBUS_MESSAGE_SINT;
-       struct onmessage_work_context *ctx;
-
-       while (1) {
-               if (msg->header.message_type == HVMSG_NONE) {
-                       /* no msg */
-                       break;
-               } else {
-                       ctx = kmalloc(sizeof(*ctx), GFP_ATOMIC);
-                       if (ctx == NULL)
-                               continue;
-                       INIT_WORK(&ctx->work, vmbus_onmessage_work);
-                       memcpy(&ctx->msg, msg, sizeof(*msg));
-                       queue_work(vmbus_connection.work_queue, &ctx->work);
-               }
-
-               msg->header.message_type = HVMSG_NONE;
-
-               /*
-                * Make sure the write to MessageType (ie set to
-                * HVMSG_NONE) happens before we read the
-                * MessagePending and EOMing. Otherwise, the EOMing
-                * will not deliver any more messages since there is
-                * no empty slot
-                */
-               mb();
-
-               if (msg->header.message_flags.msg_pending) {
-                       /*
-                        * This will cause message queue rescan to
-                        * possibly deliver another msg from the
-                        * hypervisor
-                        */
-                       wrmsrl(HV_X64_MSR_EOM, 0);
-               }
-       }
-}
-
-/*
- * vmbus_on_isr - ISR routine
- */
-static int vmbus_on_isr(void)
-{
-       int ret = 0;
-       int cpu = smp_processor_id();
-       void *page_addr;
-       struct hv_message *msg;
-       union hv_synic_event_flags *event;
-
-       page_addr = hv_context.synic_message_page[cpu];
-       msg = (struct hv_message *)page_addr + VMBUS_MESSAGE_SINT;
-
-       /* Check if there are actual msgs to be process */
-       if (msg->header.message_type != HVMSG_NONE) {
-               DPRINT_DBG(VMBUS, "received msg type %d size %d",
-                               msg->header.message_type,
-                               msg->header.payload_size);
-               ret |= 0x1;
-       }
-
-       /* TODO: Check if there are events to be process */
-       page_addr = hv_context.synic_event_page[cpu];
-       event = (union hv_synic_event_flags *)page_addr + VMBUS_MESSAGE_SINT;
-
-       /* Since we are a child, we only need to check bit 0 */
-       if (sync_test_and_clear_bit(0, (unsigned long *) &event->flags32[0])) {
-               DPRINT_DBG(VMBUS, "received event %d", event->flags32[0]);
-               ret |= 0x2;
-       }
-
-       return ret;
-}
+static int pci_probe_error;
+static struct completion probe_event;
+static int irq;
 
 static void get_channel_info(struct hv_device *device,
                             struct hv_device_info *info)
@@ -407,7 +198,324 @@ static ssize_t vmbus_show_device_attr(struct device *dev,
                return sprintf(buf, "%d\n",
                               device_info.client_monitor_conn_id);
        } else {
-               return 0;
+               return 0;
+       }
+}
+
+/* Set up per device attributes in /sys/bus/vmbus/devices/<bus device> */
+static struct device_attribute vmbus_device_attrs[] = {
+       __ATTR(id, S_IRUGO, vmbus_show_device_attr, NULL),
+       __ATTR(state, S_IRUGO, vmbus_show_device_attr, NULL),
+       __ATTR(class_id, S_IRUGO, vmbus_show_device_attr, NULL),
+       __ATTR(device_id, S_IRUGO, vmbus_show_device_attr, NULL),
+       __ATTR(monitor_id, S_IRUGO, vmbus_show_device_attr, NULL),
+
+       __ATTR(server_monitor_pending, S_IRUGO, vmbus_show_device_attr, NULL),
+       __ATTR(server_monitor_latency, S_IRUGO, vmbus_show_device_attr, NULL),
+       __ATTR(server_monitor_conn_id, S_IRUGO, vmbus_show_device_attr, NULL),
+
+       __ATTR(client_monitor_pending, S_IRUGO, vmbus_show_device_attr, NULL),
+       __ATTR(client_monitor_latency, S_IRUGO, vmbus_show_device_attr, NULL),
+       __ATTR(client_monitor_conn_id, S_IRUGO, vmbus_show_device_attr, NULL),
+
+       __ATTR(out_intr_mask, S_IRUGO, vmbus_show_device_attr, NULL),
+       __ATTR(out_read_index, S_IRUGO, vmbus_show_device_attr, NULL),
+       __ATTR(out_write_index, S_IRUGO, vmbus_show_device_attr, NULL),
+       __ATTR(out_read_bytes_avail, S_IRUGO, vmbus_show_device_attr, NULL),
+       __ATTR(out_write_bytes_avail, S_IRUGO, vmbus_show_device_attr, NULL),
+
+       __ATTR(in_intr_mask, S_IRUGO, vmbus_show_device_attr, NULL),
+       __ATTR(in_read_index, S_IRUGO, vmbus_show_device_attr, NULL),
+       __ATTR(in_write_index, S_IRUGO, vmbus_show_device_attr, NULL),
+       __ATTR(in_read_bytes_avail, S_IRUGO, vmbus_show_device_attr, NULL),
+       __ATTR(in_write_bytes_avail, S_IRUGO, vmbus_show_device_attr, NULL),
+       __ATTR_NULL
+};
+
+
+/*
+ * vmbus_uevent - add uevent for our device
+ *
+ * This routine is invoked when a device is added or removed on the vmbus to
+ * generate a uevent to udev in the userspace. The udev will then look at its
+ * rule and the uevent generated here to load the appropriate driver
+ */
+static int vmbus_uevent(struct device *device, struct kobj_uevent_env *env)
+{
+       struct hv_device *dev = device_to_hv_device(device);
+       int ret;
+
+       ret = add_uevent_var(env, "VMBUS_DEVICE_CLASS_GUID={"
+                            "%02x%02x%02x%02x-%02x%02x-%02x%02x-"
+                            "%02x%02x%02x%02x%02x%02x%02x%02x}",
+                            dev->dev_type.data[3],
+                            dev->dev_type.data[2],
+                            dev->dev_type.data[1],
+                            dev->dev_type.data[0],
+                            dev->dev_type.data[5],
+                            dev->dev_type.data[4],
+                            dev->dev_type.data[7],
+                            dev->dev_type.data[6],
+                            dev->dev_type.data[8],
+                            dev->dev_type.data[9],
+                            dev->dev_type.data[10],
+                            dev->dev_type.data[11],
+                            dev->dev_type.data[12],
+                            dev->dev_type.data[13],
+                            dev->dev_type.data[14],
+                            dev->dev_type.data[15]);
+
+       if (ret)
+               return ret;
+
+       ret = add_uevent_var(env, "VMBUS_DEVICE_DEVICE_GUID={"
+                            "%02x%02x%02x%02x-%02x%02x-%02x%02x-"
+                            "%02x%02x%02x%02x%02x%02x%02x%02x}",
+                            dev->dev_instance.data[3],
+                            dev->dev_instance.data[2],
+                            dev->dev_instance.data[1],
+                            dev->dev_instance.data[0],
+                            dev->dev_instance.data[5],
+                            dev->dev_instance.data[4],
+                            dev->dev_instance.data[7],
+                            dev->dev_instance.data[6],
+                            dev->dev_instance.data[8],
+                            dev->dev_instance.data[9],
+                            dev->dev_instance.data[10],
+                            dev->dev_instance.data[11],
+                            dev->dev_instance.data[12],
+                            dev->dev_instance.data[13],
+                            dev->dev_instance.data[14],
+                            dev->dev_instance.data[15]);
+       if (ret)
+               return ret;
+
+       return 0;
+}
+
+
+/*
+ * vmbus_match - Attempt to match the specified device to the specified driver
+ */
+static int vmbus_match(struct device *device, struct device_driver *driver)
+{
+       int match = 0;
+       struct hv_driver *drv = drv_to_hv_drv(driver);
+       struct hv_device *device_ctx = device_to_hv_device(device);
+
+       /* We found our driver ? */
+       if (memcmp(&device_ctx->dev_type, &drv->dev_type,
+                  sizeof(struct hv_guid)) == 0)
+               match = 1;
+
+       return match;
+}
+
+/*
+ * vmbus_probe - Add the new vmbus's child device
+ */
+static int vmbus_probe(struct device *child_device)
+{
+       int ret = 0;
+       struct hv_driver *drv =
+                       drv_to_hv_drv(child_device->driver);
+       struct hv_device *dev = device_to_hv_device(child_device);
+
+       if (drv->probe) {
+               ret = drv->probe(dev);
+               if (ret != 0)
+                       pr_err("probe failed for device %s (%d)\n",
+                              dev_name(child_device), ret);
+
+       } else {
+               pr_err("probe not set for driver %s\n",
+                      dev_name(child_device));
+               ret = -1;
+       }
+       return ret;
+}
+
+/*
+ * vmbus_remove - Remove a vmbus device
+ */
+static int vmbus_remove(struct device *child_device)
+{
+       int ret;
+       struct hv_driver *drv;
+
+       struct hv_device *dev = device_to_hv_device(child_device);
+
+       if (child_device->driver) {
+               drv = drv_to_hv_drv(child_device->driver);
+
+               if (drv->remove) {
+                       ret = drv->remove(dev);
+               } else {
+                       pr_err("remove not set for driver %s\n",
+                               dev_name(child_device));
+                       ret = -1;
+               }
+       }
+
+       return 0;
+}
+
+
+/*
+ * vmbus_shutdown - Shutdown a vmbus device
+ */
+static void vmbus_shutdown(struct device *child_device)
+{
+       struct hv_driver *drv;
+       struct hv_device *dev = device_to_hv_device(child_device);
+
+
+       /* The device may not be attached yet */
+       if (!child_device->driver)
+               return;
+
+       drv = drv_to_hv_drv(child_device->driver);
+
+       if (drv->shutdown)
+               drv->shutdown(dev);
+
+       return;
+}
+
+
+/*
+ * vmbus_device_release - Final callback release of the vmbus child device
+ */
+static void vmbus_device_release(struct device *device)
+{
+       struct hv_device *device_ctx = device_to_hv_device(device);
+
+       kfree(device_ctx);
+
+}
+
+/* The one and only one */
+static struct bus_type  hv_bus = {
+       .name =         "vmbus",
+       .match =                vmbus_match,
+       .shutdown =             vmbus_shutdown,
+       .remove =               vmbus_remove,
+       .probe =                vmbus_probe,
+       .uevent =               vmbus_uevent,
+       .dev_attrs =    vmbus_device_attrs,
+};
+
+static const char *driver_name = "hyperv";
+
+
+struct onmessage_work_context {
+       struct work_struct work;
+       struct hv_message msg;
+};
+
+static void vmbus_onmessage_work(struct work_struct *work)
+{
+       struct onmessage_work_context *ctx;
+
+       ctx = container_of(work, struct onmessage_work_context,
+                          work);
+       vmbus_onmessage(&ctx->msg);
+       kfree(ctx);
+}
+
+/*
+ * vmbus_on_msg_dpc - DPC routine to handle messages from the hypervisior
+ */
+static void vmbus_on_msg_dpc(unsigned long data)
+{
+       int cpu = smp_processor_id();
+       void *page_addr = hv_context.synic_message_page[cpu];
+       struct hv_message *msg = (struct hv_message *)page_addr +
+                                 VMBUS_MESSAGE_SINT;
+       struct onmessage_work_context *ctx;
+
+       while (1) {
+               if (msg->header.message_type == HVMSG_NONE) {
+                       /* no msg */
+                       break;
+               } else {
+                       ctx = kmalloc(sizeof(*ctx), GFP_ATOMIC);
+                       if (ctx == NULL)
+                               continue;
+                       INIT_WORK(&ctx->work, vmbus_onmessage_work);
+                       memcpy(&ctx->msg, msg, sizeof(*msg));
+                       queue_work(vmbus_connection.work_queue, &ctx->work);
+               }
+
+               msg->header.message_type = HVMSG_NONE;
+
+               /*
+                * Make sure the write to MessageType (ie set to
+                * HVMSG_NONE) happens before we read the
+                * MessagePending and EOMing. Otherwise, the EOMing
+                * will not deliver any more messages since there is
+                * no empty slot
+                */
+               mb();
+
+               if (msg->header.message_flags.msg_pending) {
+                       /*
+                        * This will cause message queue rescan to
+                        * possibly deliver another msg from the
+                        * hypervisor
+                        */
+                       wrmsrl(HV_X64_MSR_EOM, 0);
+               }
+       }
+}
+
+/*
+ * vmbus_on_isr - ISR routine
+ */
+static int vmbus_on_isr(void)
+{
+       int ret = 0;
+       int cpu = smp_processor_id();
+       void *page_addr;
+       struct hv_message *msg;
+       union hv_synic_event_flags *event;
+
+       page_addr = hv_context.synic_message_page[cpu];
+       msg = (struct hv_message *)page_addr + VMBUS_MESSAGE_SINT;
+
+       /* Check if there are actual msgs to be process */
+       if (msg->header.message_type != HVMSG_NONE)
+               ret |= 0x1;
+
+       /* TODO: Check if there are events to be process */
+       page_addr = hv_context.synic_event_page[cpu];
+       event = (union hv_synic_event_flags *)page_addr + VMBUS_MESSAGE_SINT;
+
+       /* Since we are a child, we only need to check bit 0 */
+       if (sync_test_and_clear_bit(0, (unsigned long *) &event->flags32[0]))
+               ret |= 0x2;
+
+       return ret;
+}
+
+
+static irqreturn_t vmbus_isr(int irq, void *dev_id)
+{
+       int ret;
+
+       ret = vmbus_on_isr();
+
+       /* Schedules a dpc if necessary */
+       if (ret > 0) {
+               if (test_bit(0, (unsigned long *)&ret))
+                       tasklet_schedule(&msg_dpc);
+
+               if (test_bit(1, (unsigned long *)&ret))
+                       tasklet_schedule(&event_dpc);
+
+               return IRQ_HANDLED;
+       } else {
+               return IRQ_NONE;
        }
 }
 
@@ -416,148 +524,69 @@ static ssize_t vmbus_show_device_attr(struct device *dev,
  *
  * Here, we
  *     - initialize the vmbus driver context
- *     - setup various driver entry points
  *     - invoke the vmbus hv main init routine
  *     - get the irq resource
- *     - invoke the vmbus to add the vmbus root device
- *     - setup the vmbus root device
  *     - retrieve the channel offers
  */
-static int vmbus_bus_init(void)
+static int vmbus_bus_init(struct pci_dev *pdev)
 {
-       struct vmbus_driver_context *vmbus_drv_ctx = &vmbus_drv;
-       struct hv_device *dev_ctx = &vmbus_drv.device_ctx;
        int ret;
        unsigned int vector;
 
-       DPRINT_INFO(VMBUS, "+++++++ HV Driver version = %s +++++++",
-                   HV_DRV_VERSION);
-       DPRINT_INFO(VMBUS, "+++++++ Vmbus supported version = %d +++++++",
-                       VMBUS_REVISION_NUMBER);
-       DPRINT_INFO(VMBUS, "+++++++ Vmbus using SINT %d +++++++",
-                       VMBUS_MESSAGE_SINT);
-       DPRINT_DBG(VMBUS, "sizeof(vmbus_channel_packet_page_buffer)=%zd, "
-                       "sizeof(VMBUS_CHANNEL_PACKET_MULITPAGE_BUFFER)=%zd",
-                       sizeof(struct vmbus_channel_packet_page_buffer),
-                       sizeof(struct vmbus_channel_packet_multipage_buffer));
-
-
        /* Hypervisor initialization...setup hypercall page..etc */
        ret = hv_init();
        if (ret != 0) {
-               DPRINT_ERR(VMBUS, "Unable to initialize the hypervisor - 0x%x",
-                               ret);
+               pr_err("Unable to initialize the hypervisor - 0x%x\n", ret);
                goto cleanup;
        }
 
-
-       vmbus_drv_ctx->bus.name = driver_name;
-
        /* Initialize the bus context */
-       tasklet_init(&vmbus_drv_ctx->msg_dpc, vmbus_on_msg_dpc,
-                    (unsigned long)NULL);
-       tasklet_init(&vmbus_drv_ctx->event_dpc, vmbus_on_event,
-                    (unsigned long)NULL);
+       tasklet_init(&msg_dpc, vmbus_on_msg_dpc, 0);
+       tasklet_init(&event_dpc, vmbus_on_event, 0);
 
        /* Now, register the bus  with LDM */
-       ret = bus_register(&vmbus_drv_ctx->bus);
+       ret = bus_register(&hv_bus);
        if (ret) {
                ret = -1;
                goto cleanup;
        }
 
        /* Get the interrupt resource */
-       ret = request_irq(vmbus_irq, vmbus_isr, IRQF_SAMPLE_RANDOM,
-                         driver_name, NULL);
-
-       if (ret != 0) {
-               DPRINT_ERR(VMBUS_DRV, "ERROR - Unable to request IRQ %d",
-                          vmbus_irq);
-
-               bus_unregister(&vmbus_drv_ctx->bus);
-
-               ret = -1;
-               goto cleanup;
-       }
-       vector = VMBUS_IRQ_VECTOR;
-
-       DPRINT_INFO(VMBUS_DRV, "irq 0x%x vector 0x%x", vmbus_irq, vector);
-
-       /* Add the root device */
-       memset(dev_ctx, 0, sizeof(struct hv_device));
+       ret = request_irq(pdev->irq, vmbus_isr,
+                         IRQF_SHARED | IRQF_SAMPLE_RANDOM,
+                         driver_name, pdev);
 
-       ret = vmbus_dev_add(dev_ctx, &vector);
        if (ret != 0) {
-               DPRINT_ERR(VMBUS_DRV,
-                          "ERROR - Unable to add vmbus root device");
+               pr_err("Unable to request IRQ %d\n",
+                          pdev->irq);
 
-               free_irq(vmbus_irq, NULL);
-
-               bus_unregister(&vmbus_drv_ctx->bus);
+               bus_unregister(&hv_bus);
 
                ret = -1;
                goto cleanup;
        }
-       /* strcpy(dev_ctx->device.bus_id, dev_ctx->device_obj.name); */
-       dev_set_name(&dev_ctx->device, "vmbus_0_0");
-
-       /* No need to bind a driver to the root device. */
-       dev_ctx->device.parent = NULL;
-       /* NULL; vmbus_remove() does not get invoked */
-       dev_ctx->device.bus = &vmbus_drv_ctx->bus;
 
-       /* Setup the device dispatch table */
-       dev_ctx->device.release = vmbus_bus_release;
+       vector = IRQ0_VECTOR + pdev->irq;
 
-       /* register the  root device */
-       ret = device_register(&dev_ctx->device);
+       /*
+        * Notify the hypervisor of our irq and
+        * connect to the host.
+        */
+       on_each_cpu(hv_synic_init, (void *)&vector, 1);
+       ret = vmbus_connect();
        if (ret) {
-               DPRINT_ERR(VMBUS_DRV,
-                          "ERROR - Unable to register vmbus root device");
-
-               free_irq(vmbus_irq, NULL);
-               bus_unregister(&vmbus_drv_ctx->bus);
-
-               ret = -1;
+               free_irq(pdev->irq, pdev);
+               bus_unregister(&hv_bus);
                goto cleanup;
        }
 
+
        vmbus_request_offers();
-       wait_for_completion(&hv_channel_ready);
 
 cleanup:
        return ret;
 }
 
-/*
- * vmbus_bus_exit - Terminate the vmbus driver.
- *
- * This routine is opposite of vmbus_bus_init()
- */
-static void vmbus_bus_exit(void)
-{
-       struct vmbus_driver_context *vmbus_drv_ctx = &vmbus_drv;
-
-       struct hv_device *dev_ctx = &vmbus_drv.device_ctx;
-
-       vmbus_release_unattached_channels();
-       vmbus_disconnect();
-       on_each_cpu(hv_synic_cleanup, NULL, 1);
-
-       hv_cleanup();
-
-       /* Unregister the root bus device */
-       device_unregister(&dev_ctx->device);
-
-       bus_unregister(&vmbus_drv_ctx->bus);
-
-       free_irq(vmbus_irq, NULL);
-
-       tasklet_kill(&vmbus_drv_ctx->msg_dpc);
-       tasklet_kill(&vmbus_drv_ctx->event_dpc);
-}
-
-
 /**
  * vmbus_child_driver_register() - Register a vmbus's child driver
  * @drv:        Pointer to driver structure you want to register
@@ -573,11 +602,10 @@ int vmbus_child_driver_register(struct device_driver *drv)
 {
        int ret;
 
-       DPRINT_INFO(VMBUS_DRV, "child driver (%p) registering - name %s",
-                   drv, drv->name);
+       pr_info("child driver registering - name %s\n", drv->name);
 
        /* The child driver on this vmbus */
-       drv->bus = &vmbus_drv.bus;
+       drv->bus = &hv_bus;
 
        ret = driver_register(drv);
 
@@ -599,8 +627,7 @@ EXPORT_SYMBOL(vmbus_child_driver_register);
  */
 void vmbus_child_driver_unregister(struct device_driver *drv)
 {
-       DPRINT_INFO(VMBUS_DRV, "child driver (%p) unregistering - name %s",
-                   drv, drv->name);
+       pr_info("child driver unregistering - name %s\n", drv->name);
 
        driver_unregister(drv);
 
@@ -621,30 +648,10 @@ struct hv_device *vmbus_child_device_create(struct hv_guid *type,
        /* Allocate the new child device */
        child_device_obj = kzalloc(sizeof(struct hv_device), GFP_KERNEL);
        if (!child_device_obj) {
-               DPRINT_ERR(VMBUS_DRV,
-                       "unable to allocate device_context for child device");
+               pr_err("Unable to allocate device object for child device\n");
                return NULL;
        }
 
-       DPRINT_DBG(VMBUS_DRV, "child device (%p) allocated - "
-               "type {%02x%02x%02x%02x-%02x%02x-%02x%02x-"
-               "%02x%02x%02x%02x%02x%02x%02x%02x},"
-               "id {%02x%02x%02x%02x-%02x%02x-%02x%02x-"
-               "%02x%02x%02x%02x%02x%02x%02x%02x}",
-               &child_device_obj->device,
-               type->data[3], type->data[2], type->data[1], type->data[0],
-               type->data[5], type->data[4], type->data[7], type->data[6],
-               type->data[8], type->data[9], type->data[10], type->data[11],
-               type->data[12], type->data[13], type->data[14], type->data[15],
-               instance->data[3], instance->data[2],
-               instance->data[1], instance->data[0],
-               instance->data[5], instance->data[4],
-               instance->data[7], instance->data[6],
-               instance->data[8], instance->data[9],
-               instance->data[10], instance->data[11],
-               instance->data[12], instance->data[13],
-               instance->data[14], instance->data[15]);
-
        child_device_obj->channel = channel;
        memcpy(&child_device_obj->dev_type, type, sizeof(struct hv_guid));
        memcpy(&child_device_obj->dev_instance, instance,
@@ -663,16 +670,13 @@ int vmbus_child_device_register(struct hv_device *child_device_obj)
 
        static atomic_t device_num = ATOMIC_INIT(0);
 
-       DPRINT_DBG(VMBUS_DRV, "child device (%p) registering",
-                  child_device_obj);
-
        /* Set the device name. Otherwise, device_register() will fail. */
        dev_set_name(&child_device_obj->device, "vmbus_0_%d",
                     atomic_inc_return(&device_num));
 
        /* The new device belongs to this bus */
-       child_device_obj->device.bus = &vmbus_drv.bus; /* device->dev.bus; */
-       child_device_obj->device.parent = &vmbus_device->device;
+       child_device_obj->device.bus = &hv_bus; /* device->dev.bus; */
+       child_device_obj->device.parent = &hv_pci_dev->dev;
        child_device_obj->device.release = vmbus_device_release;
 
        /*
@@ -681,15 +685,11 @@ int vmbus_child_device_register(struct hv_device *child_device_obj)
         */
        ret = device_register(&child_device_obj->device);
 
-       /* vmbus_probe() error does not get propergate to device_register(). */
-       ret = child_device_obj->probe_error;
-
        if (ret)
-               DPRINT_ERR(VMBUS_DRV, "unable to register child device (%p)",
-                          &child_device_obj->device);
+               pr_err("Unable to register child device\n");
        else
-               DPRINT_INFO(VMBUS_DRV, "child device (%p) registered",
-                           &child_device_obj->device);
+               pr_info("child device %s registered\n",
+                       dev_name(&child_device_obj->device));
 
        return ret;
 }
@@ -700,313 +700,110 @@ int vmbus_child_device_register(struct hv_device *child_device_obj)
  */
 void vmbus_child_device_unregister(struct hv_device *device_obj)
 {
-
-       DPRINT_INFO(VMBUS_DRV, "unregistering child device (%p)",
-                   &device_obj->device);
-
        /*
         * Kick off the process of unregistering the device.
         * This will call vmbus_remove() and eventually vmbus_device_release()
         */
        device_unregister(&device_obj->device);
 
-       DPRINT_INFO(VMBUS_DRV, "child device (%p) unregistered",
-                   &device_obj->device);
+       pr_info("child device %s unregistered\n",
+               dev_name(&device_obj->device));
 }
 
-/*
- * vmbus_uevent - add uevent for our device
- *
- * This routine is invoked when a device is added or removed on the vmbus to
- * generate a uevent to udev in the userspace. The udev will then look at its
- * rule and the uevent generated here to load the appropriate driver
- */
-static int vmbus_uevent(struct device *device, struct kobj_uevent_env *env)
-{
-       struct hv_device *dev = device_to_hv_device(device);
-       int ret;
-
-       DPRINT_INFO(VMBUS_DRV, "generating uevent - VMBUS_DEVICE_CLASS_GUID={"
-                   "%02x%02x%02x%02x-%02x%02x-%02x%02x-"
-                   "%02x%02x%02x%02x%02x%02x%02x%02x}",
-                   dev->dev_type.data[3], dev->dev_type.data[2],
-                   dev->dev_type.data[1], dev->dev_type.data[0],
-                   dev->dev_type.data[5], dev->dev_type.data[4],
-                   dev->dev_type.data[7], dev->dev_type.data[6],
-                   dev->dev_type.data[8], dev->dev_type.data[9],
-                   dev->dev_type.data[10],
-                   dev->dev_type.data[11],
-                   dev->dev_type.data[12],
-                   dev->dev_type.data[13],
-                   dev->dev_type.data[14],
-                   dev->dev_type.data[15]);
-
-       ret = add_uevent_var(env, "VMBUS_DEVICE_CLASS_GUID={"
-                            "%02x%02x%02x%02x-%02x%02x-%02x%02x-"
-                            "%02x%02x%02x%02x%02x%02x%02x%02x}",
-                            dev->dev_type.data[3],
-                            dev->dev_type.data[2],
-                            dev->dev_type.data[1],
-                            dev->dev_type.data[0],
-                            dev->dev_type.data[5],
-                            dev->dev_type.data[4],
-                            dev->dev_type.data[7],
-                            dev->dev_type.data[6],
-                            dev->dev_type.data[8],
-                            dev->dev_type.data[9],
-                            dev->dev_type.data[10],
-                            dev->dev_type.data[11],
-                            dev->dev_type.data[12],
-                            dev->dev_type.data[13],
-                            dev->dev_type.data[14],
-                            dev->dev_type.data[15]);
-
-       if (ret)
-               return ret;
-
-       ret = add_uevent_var(env, "VMBUS_DEVICE_DEVICE_GUID={"
-                            "%02x%02x%02x%02x-%02x%02x-%02x%02x-"
-                            "%02x%02x%02x%02x%02x%02x%02x%02x}",
-                            dev->dev_instance.data[3],
-                            dev->dev_instance.data[2],
-                            dev->dev_instance.data[1],
-                            dev->dev_instance.data[0],
-                            dev->dev_instance.data[5],
-                            dev->dev_instance.data[4],
-                            dev->dev_instance.data[7],
-                            dev->dev_instance.data[6],
-                            dev->dev_instance.data[8],
-                            dev->dev_instance.data[9],
-                            dev->dev_instance.data[10],
-                            dev->dev_instance.data[11],
-                            dev->dev_instance.data[12],
-                            dev->dev_instance.data[13],
-                            dev->dev_instance.data[14],
-                            dev->dev_instance.data[15]);
-       if (ret)
-               return ret;
-
-       return 0;
-}
 
 /*
- * vmbus_match - Attempt to match the specified device to the specified driver
+ * VMBUS is an acpi enumerated device. Get the the IRQ information
+ * from DSDT.
  */
-static int vmbus_match(struct device *device, struct device_driver *driver)
-{
-       int match = 0;
-       struct hv_driver *drv = drv_to_hv_drv(driver);
-       struct hv_device *device_ctx = device_to_hv_device(device);
-
-       /* We found our driver ? */
-       if (memcmp(&device_ctx->dev_type, &drv->dev_type,
-                  sizeof(struct hv_guid)) == 0) {
-
-               device_ctx->drv = drv->priv;
-               DPRINT_INFO(VMBUS_DRV,
-                           "device object (%p) set to driver object (%p)",
-                           &device_ctx,
-                           device_ctx->drv);
-
-               match = 1;
-       }
-       return match;
-}
 
-/*
- * vmbus_probe_failed_cb - Callback when a driver probe failed in vmbus_probe()
- *
- * We need a callback because we cannot invoked device_unregister() inside
- * vmbus_probe() since vmbus_probe() may be invoked inside device_register()
- * i.e. we cannot call device_unregister() inside device_register()
- */
-static void vmbus_probe_failed_cb(struct work_struct *context)
+static acpi_status vmbus_walk_resources(struct acpi_resource *res, void *irq)
 {
-       struct hv_device *device_ctx = (struct hv_device *)context;
-
-       /*
-        * Kick off the process of unregistering the device.
-        * This will call vmbus_remove() and eventually vmbus_device_release()
-        */
-       device_unregister(&device_ctx->device);
-
-       /* put_device(&device_ctx->device); */
-}
 
-/*
- * vmbus_probe - Add the new vmbus's child device
- */
-static int vmbus_probe(struct device *child_device)
-{
-       int ret = 0;
-       struct hv_driver *drv =
-                       drv_to_hv_drv(child_device->driver);
-       struct hv_device *dev = device_to_hv_device(child_device);
+       if (res->type == ACPI_RESOURCE_TYPE_IRQ) {
+               struct acpi_resource_irq *irqp;
+               irqp = &res->data.irq;
 
-       /* Let the specific open-source driver handles the probe if it can */
-       if (drv->driver.probe) {
-               ret = dev->probe_error =
-               drv->driver.probe(child_device);
-               if (ret != 0) {
-                       DPRINT_ERR(VMBUS_DRV, "probe() failed for device %s "
-                                  "(%p) on driver %s (%d)...",
-                                  dev_name(child_device), child_device,
-                                  child_device->driver->name, ret);
-
-                       INIT_WORK(&dev->probe_failed_work_item,
-                                 vmbus_probe_failed_cb);
-                       schedule_work(&dev->probe_failed_work_item);
-               }
-       } else {
-               DPRINT_ERR(VMBUS_DRV, "probe() method not set for driver - %s",
-                          child_device->driver->name);
-               ret = -1;
+               *((unsigned int *)irq) = irqp->interrupts[0];
        }
-       return ret;
+
+       return AE_OK;
 }
 
-/*
- * vmbus_remove - Remove a vmbus device
- */
-static int vmbus_remove(struct device *child_device)
+static int vmbus_acpi_add(struct acpi_device *device)
 {
-       int ret;
-       struct hv_driver *drv;
-
-       /* Special case root bus device */
-       if (child_device->parent == NULL) {
-               /*
-                * No-op since it is statically defined and handle in
-                * vmbus_bus_exit()
-                */
-               return 0;
-       }
+       acpi_status result;
 
-       if (child_device->driver) {
-               drv = drv_to_hv_drv(child_device->driver);
+       result =
+       acpi_walk_resources(device->handle, METHOD_NAME__CRS,
+                       vmbus_walk_resources, &irq);
 
-               /*
-                * Let the specific open-source driver handles the removal if
-                * it can
-                */
-               if (drv->driver.remove) {
-                       ret = drv->driver.remove(child_device);
-               } else {
-                       DPRINT_ERR(VMBUS_DRV,
-                                  "remove() method not set for driver - %s",
-                                  child_device->driver->name);
-                       ret = -1;
-               }
+       if (ACPI_FAILURE(result)) {
+               complete(&probe_event);
+               return -ENODEV;
        }
-
+       complete(&probe_event);
        return 0;
 }
 
-/*
- * vmbus_shutdown - Shutdown a vmbus device
- */
-static void vmbus_shutdown(struct device *child_device)
-{
-       struct hv_driver *drv;
-
-       /* Special case root bus device */
-       if (child_device->parent == NULL) {
-               /*
-                * No-op since it is statically defined and handle in
-                * vmbus_bus_exit()
-                */
-               return;
-       }
+static const struct acpi_device_id vmbus_acpi_device_ids[] = {
+       {"VMBUS", 0},
+       {"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, vmbus_acpi_device_ids);
 
-       /* The device may not be attached yet */
-       if (!child_device->driver)
-               return;
+static struct acpi_driver vmbus_acpi_driver = {
+       .name = "vmbus",
+       .ids = vmbus_acpi_device_ids,
+       .ops = {
+               .add = vmbus_acpi_add,
+       },
+};
 
-       drv = drv_to_hv_drv(child_device->driver);
+static int vmbus_acpi_init(void)
+{
+       int result;
 
-       /* Let the specific open-source driver handles the removal if it can */
-       if (drv->driver.shutdown)
-               drv->driver.shutdown(child_device);
 
-       return;
-}
+       result = acpi_bus_register_driver(&vmbus_acpi_driver);
+       if (result < 0)
+               return result;
 
-/*
- * vmbus_bus_release - Final callback release of the vmbus root device
- */
-static void vmbus_bus_release(struct device *device)
-{
-       /* FIXME */
-       /* Empty release functions are a bug, or a major sign
-        * of a problem design, this MUST BE FIXED! */
-       dev_err(device, "%s needs to be fixed!\n", __func__);
-       WARN_ON(1);
+       return 0;
 }
 
-/*
- * vmbus_device_release - Final callback release of the vmbus child device
- */
-static void vmbus_device_release(struct device *device)
+static void vmbus_acpi_exit(void)
 {
-       struct hv_device *device_ctx = device_to_hv_device(device);
-
-       kfree(device_ctx);
+       acpi_bus_unregister_driver(&vmbus_acpi_driver);
 
-       /* !!DO NOT REFERENCE device_ctx anymore at this point!! */
+       return;
 }
 
 
-
-static irqreturn_t vmbus_isr(int irq, void *dev_id)
+static int __devinit hv_pci_probe(struct pci_dev *pdev,
+                               const struct pci_device_id *ent)
 {
-       int ret;
-
-       ret = vmbus_on_isr();
-
-       /* Schedules a dpc if necessary */
-       if (ret > 0) {
-               if (test_bit(0, (unsigned long *)&ret))
-                       tasklet_schedule(&vmbus_drv.msg_dpc);
-
-               if (test_bit(1, (unsigned long *)&ret))
-                       tasklet_schedule(&vmbus_drv.event_dpc);
+       hv_pci_dev = pdev;
 
-               return IRQ_HANDLED;
-       } else {
-               return IRQ_NONE;
-       }
-}
+       pci_probe_error = pci_enable_device(pdev);
+       if (pci_probe_error)
+               goto probe_cleanup;
 
-static struct dmi_system_id __initdata microsoft_hv_dmi_table[] = {
-       {
-               .ident = "Hyper-V",
-               .matches = {
-                       DMI_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
-                       DMI_MATCH(DMI_PRODUCT_NAME, "Virtual Machine"),
-                       DMI_MATCH(DMI_BOARD_NAME, "Virtual Machine"),
-               },
-       },
-       { },
-};
-MODULE_DEVICE_TABLE(dmi, microsoft_hv_dmi_table);
+       /*
+        * If the PCI sub-sytem did not assign us an
+        * irq, use the bios provided one.
+        */
 
-static int __init vmbus_init(void)
-{
-       DPRINT_INFO(VMBUS_DRV,
-               "Vmbus initializing.... current log level 0x%x (%x,%x)",
-               vmbus_loglevel, HIWORD(vmbus_loglevel), LOWORD(vmbus_loglevel));
-       /* Todo: it is used for loglevel, to be ported to new kernel. */
+       if (pdev->irq == 0)
+               pdev->irq = irq;
 
-       if (!dmi_check_system(microsoft_hv_dmi_table))
-               return -ENODEV;
+       pci_probe_error = vmbus_bus_init(pdev);
 
-       return vmbus_bus_init();
-}
+       if (pci_probe_error)
+               pci_disable_device(pdev);
 
-static void __exit vmbus_exit(void)
-{
-       vmbus_bus_exit();
-       /* Todo: it is used for loglevel, to be ported to new kernel. */
+probe_cleanup:
+       complete(&probe_event);
+       return pci_probe_error;
 }
 
 /*
@@ -1021,10 +818,53 @@ static const struct pci_device_id microsoft_hv_pci_table[] = {
 };
 MODULE_DEVICE_TABLE(pci, microsoft_hv_pci_table);
 
+static struct pci_driver hv_bus_driver = {
+       .name =           "hv_bus",
+       .probe =          hv_pci_probe,
+       .id_table =       microsoft_hv_pci_table,
+};
+
+static int __init hv_pci_init(void)
+{
+       int ret;
+
+       init_completion(&probe_event);
+
+       /*
+        * Get irq resources first.
+        */
+
+       ret = vmbus_acpi_init();
+       if (ret)
+               return ret;
+
+       wait_for_completion(&probe_event);
+
+       if (irq <= 0) {
+               vmbus_acpi_exit();
+               return -ENODEV;
+       }
+
+       vmbus_acpi_exit();
+       init_completion(&probe_event);
+       ret = pci_register_driver(&hv_bus_driver);
+       if (ret)
+               return ret;
+       /*
+        * All the vmbus initialization occurs within the
+        * hv_pci_probe() function. Wait for hv_pci_probe()
+        * to complete.
+        */
+       wait_for_completion(&probe_event);
+
+       if (pci_probe_error)
+               pci_unregister_driver(&hv_bus_driver);
+       return pci_probe_error;
+}
+
+
 MODULE_LICENSE("GPL");
 MODULE_VERSION(HV_DRV_VERSION);
-module_param(vmbus_irq, int, S_IRUGO);
-module_param(vmbus_loglevel, int, S_IRUGO);
+module_param(vmbus_loglevel, int, S_IRUGO|S_IWUSR);
 
-module_init(vmbus_init);
-module_exit(vmbus_exit);
+module_init(hv_pci_init);
diff --git a/drivers/staging/hv/vmbus_packet_format.h b/drivers/staging/hv/vmbus_packet_format.h
deleted file mode 100644 (file)
index c0b2c2b..0000000
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- *
- * Copyright (c) 2009, Microsoft Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place - Suite 330, Boston, MA 02111-1307 USA.
- *
- * Authors:
- *   Haiyang Zhang <haiyangz@microsoft.com>
- *   Hank Janssen  <hjanssen@microsoft.com>
- *
- */
-
-#ifndef _VMBUSPACKETFORMAT_H_
-#define _VMBUSPACKETFORMAT_H_
-
-struct vmpacket_descriptor {
-       u16 type;
-       u16 offset8;
-       u16 len8;
-       u16 flags;
-       u64 trans_id;
-} __packed;
-
-struct vmpacket_header {
-       u32 prev_pkt_start_offset;
-       struct vmpacket_descriptor descriptor;
-} __packed;
-
-struct vmtransfer_page_range {
-       u32 byte_count;
-       u32 byte_offset;
-} __packed;
-
-struct vmtransfer_page_packet_header {
-       struct vmpacket_descriptor d;
-       u16 xfer_pageset_id;
-       bool sender_owns_set;
-       u8 reserved;
-       u32 range_cnt;
-       struct vmtransfer_page_range ranges[1];
-} __packed;
-
-struct vmgpadl_packet_header {
-       struct vmpacket_descriptor d;
-       u32 gpadl;
-       u32 reserved;
-} __packed;
-
-struct vmadd_remove_transfer_page_set {
-       struct vmpacket_descriptor d;
-       u32 gpadl;
-       u16 xfer_pageset_id;
-       u16 reserved;
-} __packed;
-
-/*
- * This structure defines a range in guest physical space that can be made to
- * look virtually contiguous.
- */
-struct gpa_range {
-       u32 byte_count;
-       u32 byte_offset;
-       u64 pfn_array[0];
-};
-
-/*
- * This is the format for an Establish Gpadl packet, which contains a handle by
- * which this GPADL will be known and a set of GPA ranges associated with it.
- * This can be converted to a MDL by the guest OS.  If there are multiple GPA
- * ranges, then the resulting MDL will be "chained," representing multiple VA
- * ranges.
- */
-struct vmestablish_gpadl {
-       struct vmpacket_descriptor d;
-       u32 gpadl;
-       u32 range_cnt;
-       struct gpa_range range[1];
-} __packed;
-
-/*
- * This is the format for a Teardown Gpadl packet, which indicates that the
- * GPADL handle in the Establish Gpadl packet will never be referenced again.
- */
-struct vmteardown_gpadl {
-       struct vmpacket_descriptor d;
-       u32 gpadl;
-       u32 reserved;   /* for alignment to a 8-byte boundary */
-} __packed;
-
-/*
- * This is the format for a GPA-Direct packet, which contains a set of GPA
- * ranges, in addition to commands and/or data.
- */
-struct vmdata_gpa_direct {
-       struct vmpacket_descriptor d;
-       u32 reserved;
-       u32 range_cnt;
-       struct gpa_range range[1];
-} __packed;
-
-/* This is the format for a Additional Data Packet. */
-struct vmadditional_data {
-       struct vmpacket_descriptor d;
-       u64 total_bytes;
-       u32 offset;
-       u32 byte_cnt;
-       unsigned char data[1];
-} __packed;
-
-union vmpacket_largest_possible_header {
-       struct vmpacket_descriptor simple_hdr;
-       struct vmtransfer_page_packet_header xfer_page_hdr;
-       struct vmgpadl_packet_header gpadl_hdr;
-       struct vmadd_remove_transfer_page_set add_rm_xfer_page_hdr;
-       struct vmestablish_gpadl establish_gpadl_hdr;
-       struct vmteardown_gpadl teardown_gpadl_hdr;
-       struct vmdata_gpa_direct data_gpa_direct_hdr;
-};
-
-#define VMPACKET_DATA_START_ADDRESS(__packet)  \
-       (void *)(((unsigned char *)__packet) +  \
-        ((struct vmpacket_descriptor)__packet)->offset8 * 8)
-
-#define VMPACKET_DATA_LENGTH(__packet)         \
-       ((((struct vmpacket_descriptor)__packet)->len8 -        \
-         ((struct vmpacket_descriptor)__packet)->offset8) * 8)
-
-#define VMPACKET_TRANSFER_MODE(__packet)       \
-       (((struct IMPACT)__packet)->type)
-
-enum vmbus_packet_type {
-       VM_PKT_INVALID                          = 0x0,
-       VM_PKT_SYNCH                            = 0x1,
-       VM_PKT_ADD_XFER_PAGESET                 = 0x2,
-       VM_PKT_RM_XFER_PAGESET                  = 0x3,
-       VM_PKT_ESTABLISH_GPADL                  = 0x4,
-       VM_PKT_TEARDOWN_GPADL                   = 0x5,
-       VM_PKT_DATA_INBAND                      = 0x6,
-       VM_PKT_DATA_USING_XFER_PAGES            = 0x7,
-       VM_PKT_DATA_USING_GPADL                 = 0x8,
-       VM_PKT_DATA_USING_GPA_DIRECT            = 0x9,
-       VM_PKT_CANCEL_REQUEST                   = 0xa,
-       VM_PKT_COMP                             = 0xb,
-       VM_PKT_DATA_USING_ADDITIONAL_PKT        = 0xc,
-       VM_PKT_ADDITIONAL_DATA                  = 0xd
-};
-
-#define VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED    1
-
-#endif
diff --git a/drivers/staging/hv/vmbus_private.h b/drivers/staging/hv/vmbus_private.h
deleted file mode 100644 (file)
index 6f0d8df..0000000
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- *
- * Copyright (c) 2009, Microsoft Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place - Suite 330, Boston, MA 02111-1307 USA.
- *
- * Authors:
- *   Haiyang Zhang <haiyangz@microsoft.com>
- *   Hank Janssen  <hjanssen@microsoft.com>
- *
- */
-
-
-#ifndef _VMBUS_PRIVATE_H_
-#define _VMBUS_PRIVATE_H_
-
-#include "hv.h"
-#include "vmbus_api.h"
-#include "channel.h"
-#include "channel_mgmt.h"
-#include "ring_buffer.h"
-#include <linux/list.h>
-#include <asm/sync_bitops.h>
-
-
-/*
- * Maximum channels is determined by the size of the interrupt page
- * which is PAGE_SIZE. 1/2 of PAGE_SIZE is for send endpoint interrupt
- * and the other is receive endpoint interrupt
- */
-#define MAX_NUM_CHANNELS       ((PAGE_SIZE >> 1) << 3) /* 16348 channels */
-
-/* The value here must be in multiple of 32 */
-/* TODO: Need to make this configurable */
-#define MAX_NUM_CHANNELS_SUPPORTED     256
-
-
-enum vmbus_connect_state {
-       DISCONNECTED,
-       CONNECTING,
-       CONNECTED,
-       DISCONNECTING
-};
-
-#define MAX_SIZE_CHANNEL_MESSAGE       HV_MESSAGE_PAYLOAD_BYTE_COUNT
-
-struct vmbus_connection {
-       enum vmbus_connect_state conn_state;
-
-       atomic_t next_gpadl_handle;
-
-       /*
-        * Represents channel interrupts. Each bit position represents a
-        * channel.  When a channel sends an interrupt via VMBUS, it finds its
-        * bit in the sendInterruptPage, set it and calls Hv to generate a port
-        * event. The other end receives the port event and parse the
-        * recvInterruptPage to see which bit is set
-        */
-       void *int_page;
-       void *send_int_page;
-       void *recv_int_page;
-
-       /*
-        * 2 pages - 1st page for parent->child notification and 2nd
-        * is child->parent notification
-        */
-       void *monitor_pages;
-       struct list_head chn_msg_list;
-       spinlock_t channelmsg_lock;
-
-       /* List of channels */
-       struct list_head chn_list;
-       spinlock_t channel_lock;
-
-       struct workqueue_struct *work_queue;
-};
-
-
-struct vmbus_msginfo {
-       /* Bookkeeping stuff */
-       struct list_head msglist_entry;
-
-       /* Synchronize the request/response if needed */
-       int wait_condition;
-       wait_queue_head_t  wait_event;
-
-       /* The message itself */
-       unsigned char msg[0];
-};
-
-
-extern struct vmbus_connection vmbus_connection;
-
-/* General vmbus interface */
-
-struct hv_device *vmbus_child_device_create(struct hv_guid *type,
-                                        struct hv_guid *instance,
-                                        struct vmbus_channel *channel);
-
-int vmbus_child_device_register(struct hv_device *child_device_obj);
-void vmbus_child_device_unregister(struct hv_device *device_obj);
-
-/* static void */
-/* VmbusChildDeviceDestroy( */
-/* struct hv_device *); */
-
-struct vmbus_channel *relid2channel(u32 relid);
-
-
-/* Connection interface */
-
-int vmbus_connect(void);
-
-int vmbus_disconnect(void);
-
-int vmbus_post_msg(void *buffer, size_t buflen);
-
-int vmbus_set_event(u32 child_relid);
-
-void vmbus_on_event(unsigned long data);
-
-
-#endif /* _VMBUS_PRIVATE_H_ */
index 69d9570f29fca10eb33702af17f88bfb6ae0c351..1abb80cb884ecc5d69c9e8792458dd4f70b8a9ba 100644 (file)
@@ -8,34 +8,66 @@ The crucial structure for device drivers in iio is iio_dev.
 
 First allocate one using:
 
-struct iio_dev *indio_dev = iio_allocate_device();
+struct iio_dev *indio_dev = iio_allocate_device(sizeof(struct chip_state));
+where chip_state is a structure of local state data for this instance of
+the chip.
 
-Then fill in the following:
-
-indio_dev->dev.parent
-  the struct device associated with the underlying hardware.
-
-indio_dev->num_interrupt_lines
-   number of event triggering hardware lines the device has.
+That data can be accessed using iio_priv(struct iio_dev *)
 
-indio_dev->event_attrs
-   attributes used to enable / disable hardware events - note the
-   attributes are embedded in iio_event_attr structures with an
-   associated iio_event_handler which may or may note be shared.
-   If num_interrupt_lines = 0, then no need to fill this in.
-
-indio_dev->attrs
-   general attributes such as polled access to device channels.
+Then fill in the following:
 
-indio_dev->dev_data
-   private device specific data.
+- indio_dev->dev.parent
+       Struct device associated with the underlying hardware.
+- indio_dev->name
+       Name of the device being driven - made available as the name
+       attribute in sysfs.
 
-indio_dev->driver_module
-   typically set to THIS_MODULE. Used to specify ownership of some
-   iio created resources.
+- indio_dev->info
+       pointer to a structure with elements that tend to be fixed for
+       large sets of different parts supported by a given driver.
+       This contains:
+       * info->driver_module:
+               Set to THIS_MODULE. Used to ensure correct ownership
+               of various resources allocate by the core.
+       * info->num_interrupt_lines:
+               Number of event triggering hardware lines the device has.
+       * info->event_attrs:
+               Attributes used to enable / disable hardware events.
+       * info->attrs:
+               General device attributes. Typically used for the weird
+               and the wonderful bits not covered by the channel specification.
+       * info->read_raw:
+               Raw data reading function. Used for both raw channel access
+               and for associate parameters such as offsets and scales.
+       * info->write_raw:
+               Raw value writing function. Used for writable device values such
+               as DAC values and caliboffset.
+       * info->read_event_config:
+               Typically only set if there are some interrupt lines.  This
+               is used to read if an on sensor event detector is enabled.
+       * info->write_event_config:
+               Enable / disable an on sensor event detector.
+       * info->read_event_value:
+               Read value associated with on sensor event detectors. Note that
+               the meaning of the returned value is dependent on the event
+               type.
+       * info->write_event_value:
+               Write the value associated with on sensor event detectors. E.g.
+               a threshold above which an interrupt occurs.  Note that the
+               meaning of the value to be set is event type dependant.
 
-indio_dev->modes
-   whether direct access and / or ring buffer access is supported.
+- indio_dev->modes:
+       Specify whether direct access and / or ring buffer access is supported.
+- indio_dev->ring:
+       An optional associated buffer.
+- indio_dev->pollfunc:
+       Poll function related elements. This controls what occurs when a trigger
+       to which this device is attached sends and event.
+- indio_dev->channels:
+       Specification of device channels. Most attributes etc are built
+       form this spec.
+- indio_dev->num_channels:
+       How many channels are there?
 
 Once these are set up, a call to iio_device_register(indio_dev),
 will register the device with the iio core.
index 3cc18ab4ebfd357f347d9e4d48c62c229e002475..f82894f42d27f96c196fc8d964d8fa7634360b96 100644 (file)
@@ -27,6 +27,7 @@
 #include <sys/dir.h>
 #include <linux/types.h>
 #include <string.h>
+#include <poll.h>
 #include "iio_utils.h"
 
 /**
@@ -53,6 +54,24 @@ int size_from_channelarray(struct iio_channel_info *channels, int num_channels)
        return bytes;
 }
 
+void print2byte(int input, struct iio_channel_info *info)
+{
+       /* shift before conversion to avoid sign extension
+          of left aligned data */
+       input = input >> info->shift;
+       if (info->is_signed) {
+               int16_t val = input;
+               val &= (1 << info->bits_used) - 1;
+               val = (int16_t)(val << (16 - info->bits_used)) >>
+                       (16 - info->bits_used);
+               printf("%05f  ", val,
+                      (float)(val + info->offset)*info->scale);
+       } else {
+               uint16_t val = input;
+               val &= (1 << info->bits_used) - 1;
+               printf("%05f ", ((float)val + info->offset)*info->scale);
+       }
+}
 /**
  * process_scan() - print out the values in SI units
  * @data:              pointer to the start of the scan
@@ -70,25 +89,8 @@ void process_scan(char *data,
                switch (infoarray[k].bytes) {
                        /* only a few cases implemented so far */
                case 2:
-                       if (infoarray[k].is_signed) {
-                               int16_t val = *(int16_t *)
-                                       (data
-                                        + infoarray[k].location);
-                               if ((val >> infoarray[k].bits_used) & 1)
-                                       val = (val & infoarray[k].mask) |
-                                               ~infoarray[k].mask;
-                               printf("%05f ", ((float)val +
-                                                infoarray[k].offset)*
-                                      infoarray[k].scale);
-                       } else {
-                               uint16_t val = *(uint16_t *)
-                                       (data +
-                                        infoarray[k].location);
-                               val = (val & infoarray[k].mask);
-                               printf("%05f ", ((float)val +
-                                                infoarray[k].offset)*
-                                      infoarray[k].scale);
-                       }
+                       print2byte(*(uint16_t *)(data + infoarray[k].location),
+                                  &infoarray[k]);
                        break;
                case 8:
                        if (infoarray[k].is_signed) {
@@ -132,10 +134,9 @@ int main(int argc, char **argv)
 
        int datardytrigger = 1;
        char *data;
-       size_t read_size;
-       struct iio_event_data dat;
+       ssize_t read_size;
        int dev_num, trig_num;
-       char *buffer_access, *buffer_event;
+       char *buffer_access;
        int scan_size;
        int noevents = 0;
        char *dummy;
@@ -210,7 +211,7 @@ int main(int argc, char **argv)
         */
        ret = build_channel_array(dev_dir_name, &infoarray, &num_channels);
        if (ret) {
-               printf("Problem reading scan element information \n");
+               printf("Problem reading scan element information\n");
                goto error_free_triggername;
        }
 
@@ -251,54 +252,32 @@ int main(int argc, char **argv)
        }
 
        ret = asprintf(&buffer_access,
-                      "/dev/device%d:buffer0:access0",
+                      "/dev/device%d:buffer0",
                       dev_num);
        if (ret < 0) {
                ret = -ENOMEM;
                goto error_free_data;
        }
 
-       ret = asprintf(&buffer_event, "/dev/device%d:buffer0:event0", dev_num);
-       if (ret < 0) {
-               ret = -ENOMEM;
-               goto error_free_buffer_access;
-       }
        /* Attempt to open non blocking the access dev */
        fp = open(buffer_access, O_RDONLY | O_NONBLOCK);
        if (fp == -1) { /*If it isn't there make the node */
                printf("Failed to open %s\n", buffer_access);
                ret = -errno;
-               goto error_free_buffer_event;
-       }
-       /* Attempt to open the event access dev (blocking this time) */
-       fp_ev = fopen(buffer_event, "rb");
-       if (fp_ev == NULL) {
-               printf("Failed to open %s\n", buffer_event);
-               ret = -errno;
-               goto error_close_buffer_access;
+               goto error_free_buffer_access;
        }
 
        /* Wait for events 10 times */
        for (j = 0; j < num_loops; j++) {
                if (!noevents) {
-                       read_size = fread(&dat,
-                                       1,
-                                       sizeof(struct iio_event_data),
-                                       fp_ev);
-                       switch (dat.id) {
-                       case IIO_EVENT_CODE_RING_100_FULL:
-                               toread = buf_len;
-                               break;
-                       case IIO_EVENT_CODE_RING_75_FULL:
-                               toread = buf_len*3/4;
-                               break;
-                       case IIO_EVENT_CODE_RING_50_FULL:
-                               toread = buf_len/2;
-                               break;
-                       default:
-                               printf("Unexpecteded event code\n");
-                               continue;
-                       }
+                       struct pollfd pfd = {
+                               .fd = fp,
+                               .events = POLLIN,
+                       };
+
+                       poll(&pfd, 1, -1);
+                       toread = buf_len;
+
                } else {
                        usleep(timedelay);
                        toread = 64;
@@ -320,22 +299,18 @@ int main(int argc, char **argv)
        /* Stop the ring buffer */
        ret = write_sysfs_int("enable", buf_dir_name, 0);
        if (ret < 0)
-               goto error_close_buffer_event;
+               goto error_close_buffer_access;
 
        /* Disconnect from the trigger - just write a dummy name.*/
        write_sysfs_string("trigger/current_trigger",
                        dev_dir_name, "NULL");
 
-error_close_buffer_event:
-       fclose(fp_ev);
 error_close_buffer_access:
        close(fp);
 error_free_data:
        free(data);
 error_free_buffer_access:
        free(buffer_access);
-error_free_buffer_event:
-       free(buffer_event);
 error_free_buf_dir_name:
        free(buf_dir_name);
 error_free_triggername:
index fd78e4ff99ae36abcc6fd476441304eba45b528d..150f44073631314b49628ca9cc21532bee70d8ee 100644 (file)
 
 #define IIO_MAX_NAME_LENGTH 30
 
-#define IIO_EV_CLASS_BUFFER            0
-#define IIO_BUFFER_EVENT_CODE(code)            \
-       (IIO_EV_CLASS_BUFFER | (code << 8))
-
-#define IIO_EVENT_CODE_RING_50_FULL    IIO_BUFFER_EVENT_CODE(0)
-#define IIO_EVENT_CODE_RING_75_FULL    IIO_BUFFER_EVENT_CODE(1)
-#define IIO_EVENT_CODE_RING_100_FULL   IIO_BUFFER_EVENT_CODE(2)
-
-
 #define FORMAT_SCAN_ELEMENTS_DIR "%s:buffer0/scan_elements"
 #define FORMAT_TYPE_FILE "%s_type"
 
 const char *iio_dir = "/sys/bus/iio/devices/";
 
-struct iio_event_data {
-       int id;
-       __s64 timestamp;
-};
-
 /**
  * iioutils_break_up_name() - extract generic name from full channel name
  * @full_name: the full channel name
@@ -85,6 +71,7 @@ struct iio_channel_info {
        unsigned index;
        unsigned bytes;
        unsigned bits_used;
+       unsigned shift;
        uint64_t mask;
        unsigned is_signed;
        unsigned enabled;
@@ -103,6 +90,7 @@ struct iio_channel_info {
 inline int iioutils_get_type(unsigned *is_signed,
                             unsigned *bytes,
                             unsigned *bits_used,
+                            unsigned *shift,
                             uint64_t *mask,
                             const char *device_dir,
                             const char *name,
@@ -157,7 +145,8 @@ inline int iioutils_get_type(unsigned *is_signed,
                                goto error_free_filename;
                        }
                        fscanf(sysfsfp,
-                              "%c%u/%u", &signchar, bits_used, &padint);
+                              "%c%u/%u>>%u", &signchar, bits_used,
+                              &padint, shift);
                        *bytes = padint / 8;
                        if (*bits_used == 64)
                                *mask = ~0;
@@ -395,6 +384,7 @@ inline int build_channel_array(const char *device_dir,
                        ret = iioutils_get_type(&current->is_signed,
                                                &current->bytes,
                                                &current->bits_used,
+                                               &current->shift,
                                                &current->mask,
                                                device_dir,
                                                current->name,
index d97106cb2b96212699db3a7d812ef4ceeaf0b150..afc39ecde9cadbaf027e146f77dbf8fca6dadfc7 100644 (file)
@@ -3,8 +3,7 @@ Overview of IIO
 The Industrial I/O subsystem is intended to provide support for devices
 that in some sense are analog to digital converters (ADCs). As many
 actual devices combine some ADCs with digital to analog converters
-(DACs) the intention is to add that functionality at a future date
-(hence the name).
+(DACs) that functionality is also supported.
 
 The aim is to fill the gap between the somewhat similar hwmon and
 input subsystems.  Hwmon is very much directed at low sample rate
@@ -31,32 +30,28 @@ event must be accessed via polling.
 Note: A given device may have one or more event channel.  These events are
 turned on or off (if possible) via sysfs interfaces.
 
-* Hardware ring buffer support.  Some recent sensors have included
+* Hardware buffer support.  Some recent sensors have included
 fifo / ring buffers on the sensor chip.  These greatly reduce the load
 on the host CPU by buffering relatively large numbers of data samples
 based on an internal sampling clock. Examples include VTI SCA3000
-series and Analog Device ADXL345 accelerometers.  Each ring buffer
-typically has an event chrdev (similar to the more general ones above)
-to pass on events such as buffer 50% full and an access chrdev via
-which the raw data it self may be read back.
+series and Analog Device ADXL345 accelerometers.  Each buffer supports
+polling to establish when data is available.
 
-* Trigger and software ring buffer support. In many data analysis
+* Trigger and software buffer support. In many data analysis
 applications it it useful to be able to capture data based on some
 external signal (trigger).  These triggers might be a data ready
 signal, a gpio line connected to some external system or an on
 processor periodic interrupt.  A single trigger may initialize data
 capture or reading from a number of sensors.  These triggers are
-used in IIO to fill software ring buffers acting in a very similar
+used in IIO to fill software buffers acting in a very similar
 fashion to the hardware buffers described above.
 
 Other documentation:
 
-userspace.txt - overview of ring buffer reading from userspace.
-
 device.txt - elements of a typical device driver.
 
 trigger.txt - elements of a typical trigger driver.
 
-ring.txt - additional elements required for ring buffer support.
+ring.txt - additional elements required for buffer support.
 
 sysfs-bus-iio - abi documentation file.
index 3696c364e644bd16679f1be24bea14de1fd7955d..7e99ef2b7bc01b667813edf1f3b1414ce3d00681 100644 (file)
@@ -1,57 +1,55 @@
-Ring buffer support within IIO
+Buffer support within IIO
 
 This document is intended as a general overview of the functionality
-a ring buffer may supply and how it is specified within IIO.  For more
-specific information on a given ring buffer implementation, see the
-comments in the source code.  Note that the intention is to allow
-some drivers to specify ring buffers choice at probe or runtime, but
-for now the selection is hard coded within a given driver.
+a buffer may supply and how it is specified within IIO.  For more
+specific information on a given buffer implementation, see the
+comments in the source code.  Note that some drivers allow buffer
+implementation to be selected at compile time via Kconfig options.
 
-A given ring buffer implementation typically embedded a struct
+A given buffer implementation typically embeds a struct
 iio_ring_buffer and it is a pointer to this that is provided to the
 IIO core. Access to the embedding structure is typically done via
 container_of functions.
 
-struct iio_ring_buffer contains 4 function pointers
-(preenable, postenable, predisable, postdisable).
-These are used to perform implementation specific steps on either side
-of the core changing it's current mode to indicate that the ring buffer
+struct iio_ring_buffer contains a struct iio_ring_setup_ops *setup_ops
+which in turn contains the 4 function pointers
+(preenable, postenable, predisable and postdisable).
+These are used to perform device specific steps on either side
+of the core changing it's current mode to indicate that the buffer
 is enabled or disabled (along with enabling triggering etc as appropriate).
 
 Also in struct iio_ring_buffer is a struct iio_ring_access_funcs.
 The function pointers within here are used to allow the core to handle
-as much ring buffer functionality as possible. Note almost all of these
+as much buffer functionality as possible. Note almost all of these
 are optional.
 
 mark_in_use, unmark_in_use
-  Basically indicate that not changes should be made to the ring
-  buffer state that will effect the form of the data being captures
-  (e.g. scan elements or length)
+  Basically indicate that not changes should be made to the buffer state that
+  will effect the form of the data being captures (e.g. scan elements or length)
 
 store_to
-  If possible, push data to ring buffer.
+  If possible, push data to the buffer.
 
 read_last
-  If possible get the most recent entry from the buffer (without removal).
+  If possible, get the most recent scan from the buffer (without removal).
   This provides polling like functionality whilst the ring buffering is in
   use without a separate read from the device.
 
-rip_lots
-  The primary ring buffer reading function. Note that it may well not return
-  as much data as requested.  The deadoffset is used to indicate that some
-  initial data in the data array is not guaranteed to be valid.
+rip_first_n
+  The primary buffer reading function. Note that it may well not return
+  as much data as requested.
 
 mark_param_changed
   Used to indicate that something has changed. Used in conjunction with
 request_update
   If parameters have changed that require reinitialization or configuration of
-  the ring buffer this will trigger it.
+  the buffer this will trigger it.
 
 get_bytes_per_datum, set_bytes_per_datum
   Get/set the number of bytes for a complete scan. (All samples + timestamp)
 
 get_length / set_length
-  Get/set the number of sample sets that may be held by the buffer.
+  Get/set the number of complete scans that may be held by the buffer.
 
 is_enabled
   Query if ring buffer is in use
index 4915aee14d881769f2fb3d5ce6bfadb218e2f52f..467c49a472580abd765620de41ca6ecc272d4fd0 100644 (file)
@@ -6,6 +6,12 @@ Description:
                Corresponds to a grouping of sensor channels. X is the IIO
                index of the device.
 
+What:          /sys/bus/iio/devices/device[n]/power_state
+KernelVersion: 2.6.37
+Contact:       linux-iio@vger.kernel.org
+Description:
+               This property gets/sets the device power state.
+
 What:          /sys/bus/iio/devices/triggerX
 KernelVersion: 2.6.35
 Contact:       linux-iio@vger.kernel.org
@@ -698,3 +704,10 @@ Description:
                with all _en attributes to establish which channels are present,
                and the relevant _type attributes to establish the data storage
                format.
+
+What:          /sys/bus/iio/devices/deviceX/gyro_z_quadrature_correction_raw
+KernelVersion: 2.6.38
+Contact:       linux-iio@xxxxxxxxxxxxxxx
+Description:
+               This attribute is used to read the amount of quadrature error
+               present in the device at a given time.
index 5d84856dc14a231cfd09705522f195d0f64b3b69..21d277405816611bef263019a6d61c9bf1d24c62 100644 (file)
@@ -62,3 +62,16 @@ Description:
                sensing mode. This value should be the output from a reading
                and if expressed in SI units, should include _input. If this
                value is not in SI units, then it should include _raw.
+
+What:          /sys/bus/iio/devices/device[n]/illuminance0_target
+KernelVersion: 2.6.37
+Contact:       linux-iio@vger.kernel.org
+Description:
+               This property gets/sets the last known external
+               lux measurement used in/for calibration.
+
+What:          /sys/bus/iio/devices/device[n]/illuminance0_integration_time
+KernelVersion: 2.6.37
+Contact:       linux-iio@vger.kernel.org
+Description:
+               This property gets/sets the sensors ADC analog integration time.
diff --git a/drivers/staging/iio/Documentation/sysfs-bus-iio-light-tsl2583 b/drivers/staging/iio/Documentation/sysfs-bus-iio-light-tsl2583
new file mode 100644 (file)
index 0000000..660781d
--- /dev/null
@@ -0,0 +1,20 @@
+What:          /sys/bus/iio/devices/device[n]/lux_table
+KernelVersion: 2.6.37
+Contact:       linux-iio@vger.kernel.org
+Description:
+               This property gets/sets the table of coefficients
+               used in calculating illuminance in lux.
+
+What:          /sys/bus/iio/devices/device[n]/illuminance0_calibrate
+KernelVersion: 2.6.37
+Contact:       linux-iio@vger.kernel.org
+Description:
+               This property causes an internal calibration of the als gain trim
+               value which is later used in calculating illuminance in lux.
+
+What:          /sys/bus/iio/devices/device[n]/illuminance0_input_target
+KernelVersion: 2.6.37
+Contact:       linux-iio@vger.kernel.org
+Description:
+               This property is the known externally illuminance (in lux).
+               It is used in the process of calibrating the device accuracy.
index 650157f5c9debbd21854b9e1b1c7b8147a8ad25b..fc2012ebc100a533af42f1e05095d601adeb2703 100644 (file)
@@ -5,14 +5,11 @@ an IIO device.  Whilst this can create device specific complexities
 such triggers are registered with the core in the same way as
 stand-alone triggers.
 
-struct iio_trig *trig = iio_allocate_trigger();
+struct iio_trig *trig = iio_allocate_trigger("<trigger format string>", ...);
 
 allocates a trigger structure.  The key elements to then fill in within
 a driver are:
 
-trig->control_attrs
-       Any sysfs attributes needed to control parameters of the trigger
-
 trig->private_data
        Device specific private data.
 
@@ -20,8 +17,12 @@ trig->owner
        Typically set to THIS_MODULE. Used to ensure correct
        ownership of core allocated resources.
 
-trig->name
-       A unique name for the trigger.
+trig->set_trigger_state:
+       Function that enables / disables the underlying source of the trigger.
+
+There is also a
+trig->alloc_list which is useful for drivers that allocate multiple
+triggers to keep track of what they have created.
 
 When these have been set call:
 
@@ -30,9 +31,8 @@ iio_trigger_register(trig);
 to register the trigger with the core, making it available to trigger
 consumers.
 
-
 Trigger Consumers
 
-Currently triggers are only used for the filling of software ring
+Currently triggers are only used for the filling of software
 buffers and as such any device supporting INDIO_RING_TRIGGERED has the
 consumer interface automatically created.
diff --git a/drivers/staging/iio/Documentation/userspace.txt b/drivers/staging/iio/Documentation/userspace.txt
deleted file mode 100644 (file)
index ff06e5d..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-Userspace access to IIO
-
-The sysfs attributes are documented in sysfs-bus-iio.
-
-Udev will create the following entries under /dev by default:
-
-device0:buffer0:access0 - ring access chrdev
-device0:buffer0:event0 - ring event chrdev
-device0:event0 - general event chrdev.
-
-The files, lis3l02dqbuffersimple.c and iio_utils.h in this directory provide an example
-of how to use the ring buffer and event interfaces.
index 6775bf90e2f139f4c8b51dce135f93f15354c4af..f96d5b5d5141cabe75c79a722b6811135ed9b90e 100644 (file)
@@ -5,17 +5,17 @@
 menuconfig IIO
        tristate "Industrial I/O support"
        depends on !S390
-       ---help---
+       help
          The industrial I/O subsystem provides a unified framework for
          drivers for many different types of embedded sensors using a
          number of different physical interfaces (i2c, spi, etc). See
-         Documentation/industrialio for more information.
+         drivers/staging/iio/Documentation for more information.
 if IIO
 
 config IIO_RING_BUFFER
-       bool "Enable ring buffer support within IIO"
+       bool "Enable buffer support within IIO"
        help
-         Provide core support for various ring buffer based data
+         Provide core support for various buffer based data
          acquisition methods.
 
 if IIO_RING_BUFFER
@@ -48,6 +48,13 @@ config IIO_TRIGGER
          ring buffers.  The triggers are effectively a 'capture
          data now' interrupt.
 
+config IIO_CONSUMERS_PER_TRIGGER
+       int "Maximum number of consumers per trigger"
+       depends on IIO_TRIGGER
+       default "2"
+       help
+       This value controls the maximum number of consumers that a
+       given trigger may handle. Default is 2.
 
 source "drivers/staging/iio/accel/Kconfig"
 source "drivers/staging/iio/adc/Kconfig"
index 23fe54d09d1250b8702c1b7ddadb2e6596874cc2..0b9b85424dfaa1fdbe7b931e6fcf98f68ef9c9bf 100644 (file)
@@ -64,9 +64,6 @@
 /**
  * struct adis16201_state - device instance specific data
  * @us:                        actual spi_device
- * @work_trigger_to_ring: bh for triggered event handling
- * @inter:             used to check if new interrupt has been triggered
- * @last_timestamp:    passing timestamp from th to bh of interrupt handler
  * @indio_dev:         industrial I/O device structure
  * @trig:              data ready trigger registered with iio
  * @tx:                        transmit buffer
@@ -75,8 +72,6 @@
  **/
 struct adis16201_state {
        struct spi_device               *us;
-       struct work_struct              work_trigger_to_ring;
-       s64                             last_timestamp;
        struct iio_dev                  *indio_dev;
        struct iio_trigger              *trig;
        u8                              *tx;
@@ -84,7 +79,7 @@ struct adis16201_state {
        struct mutex                    buf_lock;
 };
 
-int adis16201_set_irq(struct device *dev, bool enable);
+int adis16201_set_irq(struct iio_dev *indio_dev, bool enable);
 
 #ifdef CONFIG_IIO_RING_BUFFER
 enum adis16201_scan {
@@ -107,8 +102,6 @@ ssize_t adis16201_read_data_from_ring(struct device *dev,
 int adis16201_configure_ring(struct iio_dev *indio_dev);
 void adis16201_unconfigure_ring(struct iio_dev *indio_dev);
 
-int adis16201_initialize_ring(struct iio_ring_buffer *ring);
-void adis16201_uninitialize_ring(struct iio_ring_buffer *ring);
 #else /* CONFIG_IIO_RING_BUFFER */
 
 static inline void adis16201_remove_trigger(struct iio_dev *indio_dev)
index 79b785a0013af4e490ff6f64126ca2b2d124b844..e4c49f00d1321470190ddf3e7319ae29c1211585 100644 (file)
@@ -6,9 +6,6 @@
  * Licensed under the GPL-2 or later.
  */
 
-#include <linux/interrupt.h>
-#include <linux/irq.h>
-#include <linux/gpio.h>
 #include <linux/delay.h>
 #include <linux/mutex.h>
 #include <linux/device.h>
 #include <linux/spi/spi.h>
 #include <linux/slab.h>
 #include <linux/sysfs.h>
-#include <linux/list.h>
 
 #include "../iio.h"
 #include "../sysfs.h"
+#include "../ring_generic.h"
+
 #include "accel.h"
 #include "inclinometer.h"
-#include "../gyro/gyro.h"
 #include "../adc/adc.h"
 
 #include "adis16201.h"
 
 #define DRIVER_NAME            "adis16201"
 
-static int adis16201_check_status(struct device *dev);
+enum adis16201_chan {
+       in_supply,
+       temp,
+       accel_x,
+       accel_y,
+       incli_x,
+       incli_y,
+       in_aux,
+};
 
 /**
  * adis16201_spi_write_reg_8() - write single byte to a register
@@ -57,18 +62,17 @@ static int adis16201_spi_write_reg_8(struct device *dev,
 
 /**
  * adis16201_spi_write_reg_16() - write 2 bytes to a pair of registers
- * @dev: device associated with child of actual device (iio_dev or iio_trig)
+ * @indio_dev: iio device associated with child of actual device
  * @reg_address: the address of the lower of the two registers. Second register
  *               is assumed to have address one greater.
  * @val: value to be written
  **/
-static int adis16201_spi_write_reg_16(struct device *dev,
-               u8 lower_reg_address,
-               u16 value)
+static int adis16201_spi_write_reg_16(struct iio_dev *indio_dev,
+                                     u8 lower_reg_address,
+                                     u16 value)
 {
        int ret;
        struct spi_message msg;
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
        struct adis16201_state *st = iio_dev_get_devdata(indio_dev);
        struct spi_transfer xfers[] = {
                {
@@ -80,7 +84,6 @@ static int adis16201_spi_write_reg_16(struct device *dev,
                        .tx_buf = st->tx + 2,
                        .bits_per_word = 8,
                        .len = 2,
-                       .cs_change = 1,
                },
        };
 
@@ -101,17 +104,16 @@ static int adis16201_spi_write_reg_16(struct device *dev,
 
 /**
  * adis16201_spi_read_reg_16() - read 2 bytes from a 16-bit register
- * @dev: device associated with child of actual device (iio_dev or iio_trig)
+ * @indio_dev: iio device associated with child of actual device
  * @reg_address: the address of the lower of the two registers. Second register
  *               is assumed to have address one greater.
  * @val: somewhere to pass back the value read
  **/
-static int adis16201_spi_read_reg_16(struct device *dev,
+static int adis16201_spi_read_reg_16(struct iio_dev *indio_dev,
                u8 lower_reg_address,
                u16 *val)
 {
        struct spi_message msg;
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
        struct adis16201_state *st = iio_dev_get_devdata(indio_dev);
        int ret;
        struct spi_transfer xfers[] = {
@@ -125,7 +127,6 @@ static int adis16201_spi_read_reg_16(struct device *dev,
                        .rx_buf = st->rx,
                        .bits_per_word = 8,
                        .len = 2,
-                       .cs_change = 1,
                        .delay_usecs = 20,
                },
        };
@@ -150,160 +151,6 @@ error_ret:
        return ret;
 }
 
-static ssize_t adis16201_read_12bit_unsigned(struct device *dev,
-               struct device_attribute *attr,
-               char *buf)
-{
-       int ret;
-       u16 val = 0;
-       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-
-       ret = adis16201_spi_read_reg_16(dev, this_attr->address, &val);
-       if (ret)
-               return ret;
-
-       if (val & ADIS16201_ERROR_ACTIVE) {
-               ret = adis16201_check_status(dev);
-               if (ret)
-                       return ret;
-       }
-
-       return sprintf(buf, "%u\n", val & 0x0FFF);
-}
-
-static ssize_t adis16201_read_temp(struct device *dev,
-               struct device_attribute *attr,
-               char *buf)
-{
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
-       ssize_t ret;
-       u16 val;
-
-       /* Take the iio_dev status lock */
-       mutex_lock(&indio_dev->mlock);
-
-       ret = adis16201_spi_read_reg_16(dev, ADIS16201_TEMP_OUT, (u16 *)&val);
-       if (ret)
-               goto error_ret;
-
-       if (val & ADIS16201_ERROR_ACTIVE) {
-               ret = adis16201_check_status(dev);
-               if (ret)
-                       goto error_ret;
-       }
-
-       val &= 0xFFF;
-       ret = sprintf(buf, "%d\n", val);
-
-error_ret:
-       mutex_unlock(&indio_dev->mlock);
-       return ret;
-}
-
-static ssize_t adis16201_read_9bit_signed(struct device *dev,
-               struct device_attribute *attr,
-               char *buf)
-{
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
-       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-       s16 val = 0;
-       ssize_t ret;
-
-       mutex_lock(&indio_dev->mlock);
-
-       ret = adis16201_spi_read_reg_16(dev, this_attr->address, (u16 *)&val);
-       if (!ret) {
-               if (val & ADIS16201_ERROR_ACTIVE) {
-                       ret = adis16201_check_status(dev);
-                       if (ret)
-                               goto error_ret;
-               }
-               val = ((s16)(val << 7) >> 7);
-               ret = sprintf(buf, "%d\n", val);
-       }
-
-error_ret:
-       mutex_unlock(&indio_dev->mlock);
-
-       return ret;
-}
-
-static ssize_t adis16201_read_12bit_signed(struct device *dev,
-               struct device_attribute *attr,
-               char *buf)
-{
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
-       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-       s16 val = 0;
-       ssize_t ret;
-
-       mutex_lock(&indio_dev->mlock);
-
-       ret = adis16201_spi_read_reg_16(dev, this_attr->address, (u16 *)&val);
-       if (!ret) {
-               if (val & ADIS16201_ERROR_ACTIVE) {
-                       ret = adis16201_check_status(dev);
-                       if (ret)
-                               goto error_ret;
-               }
-
-               val = ((s16)(val << 4) >> 4);
-               ret = sprintf(buf, "%d\n", val);
-       }
-
-error_ret:
-       mutex_unlock(&indio_dev->mlock);
-
-       return ret;
-}
-
-static ssize_t adis16201_read_14bit_signed(struct device *dev,
-               struct device_attribute *attr,
-               char *buf)
-{
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
-       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-       s16 val = 0;
-       ssize_t ret;
-
-       mutex_lock(&indio_dev->mlock);
-
-       ret = adis16201_spi_read_reg_16(dev, this_attr->address, (u16 *)&val);
-       if (!ret) {
-               if (val & ADIS16201_ERROR_ACTIVE) {
-                       ret = adis16201_check_status(dev);
-                       if (ret)
-                               goto error_ret;
-               }
-
-               val = ((s16)(val << 2) >> 2);
-               ret = sprintf(buf, "%d\n", val);
-       }
-
-error_ret:
-       mutex_unlock(&indio_dev->mlock);
-
-       return ret;
-}
-
-static ssize_t adis16201_write_16bit(struct device *dev,
-               struct device_attribute *attr,
-               const char *buf,
-               size_t len)
-{
-       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-       int ret;
-       long val;
-
-       ret = strict_strtol(buf, 10, &val);
-       if (ret)
-               goto error_ret;
-       ret = adis16201_spi_write_reg_16(dev, this_attr->address, val);
-
-error_ret:
-       return ret ? ret : len;
-}
-
 static int adis16201_reset(struct device *dev)
 {
        int ret;
@@ -331,12 +178,12 @@ static ssize_t adis16201_write_reset(struct device *dev,
        return -EINVAL;
 }
 
-int adis16201_set_irq(struct device *dev, bool enable)
+int adis16201_set_irq(struct iio_dev *indio_dev, bool enable)
 {
        int ret = 0;
        u16 msc;
 
-       ret = adis16201_spi_read_reg_16(dev, ADIS16201_MSC_CTRL, &msc);
+       ret = adis16201_spi_read_reg_16(indio_dev, ADIS16201_MSC_CTRL, &msc);
        if (ret)
                goto error_ret;
 
@@ -347,20 +194,21 @@ int adis16201_set_irq(struct device *dev, bool enable)
        else
                msc &= ~ADIS16201_MSC_CTRL_DATA_RDY_EN;
 
-       ret = adis16201_spi_write_reg_16(dev, ADIS16201_MSC_CTRL, msc);
+       ret = adis16201_spi_write_reg_16(indio_dev, ADIS16201_MSC_CTRL, msc);
 
 error_ret:
        return ret;
 }
 
-static int adis16201_check_status(struct device *dev)
+static int adis16201_check_status(struct iio_dev *indio_dev)
 {
        u16 status;
        int ret;
 
-       ret = adis16201_spi_read_reg_16(dev, ADIS16201_DIAG_STAT, &status);
+       ret = adis16201_spi_read_reg_16(indio_dev,
+                                       ADIS16201_DIAG_STAT, &status);
        if (ret < 0) {
-               dev_err(dev, "Reading status failed\n");
+               dev_err(&indio_dev->dev, "Reading status failed\n");
                goto error_ret;
        }
        ret = status & 0xF;
@@ -368,30 +216,30 @@ static int adis16201_check_status(struct device *dev)
                ret = -EFAULT;
 
        if (status & ADIS16201_DIAG_STAT_SPI_FAIL)
-               dev_err(dev, "SPI failure\n");
+               dev_err(&indio_dev->dev, "SPI failure\n");
        if (status & ADIS16201_DIAG_STAT_FLASH_UPT)
-               dev_err(dev, "Flash update failed\n");
+               dev_err(&indio_dev->dev, "Flash update failed\n");
        if (status & ADIS16201_DIAG_STAT_POWER_HIGH)
-               dev_err(dev, "Power supply above 3.625V\n");
+               dev_err(&indio_dev->dev, "Power supply above 3.625V\n");
        if (status & ADIS16201_DIAG_STAT_POWER_LOW)
-               dev_err(dev, "Power supply below 3.15V\n");
+               dev_err(&indio_dev->dev, "Power supply below 3.15V\n");
 
 error_ret:
        return ret;
 }
 
-static int adis16201_self_test(struct device *dev)
+static int adis16201_self_test(struct iio_dev *indio_dev)
 {
        int ret;
-       ret = adis16201_spi_write_reg_16(dev,
+       ret = adis16201_spi_write_reg_16(indio_dev,
                        ADIS16201_MSC_CTRL,
                        ADIS16201_MSC_CTRL_SELF_TEST_EN);
        if (ret) {
-               dev_err(dev, "problem starting self test");
+               dev_err(&indio_dev->dev, "problem starting self test");
                goto err_ret;
        }
 
-       ret = adis16201_check_status(dev);
+       ret = adis16201_check_status(indio_dev);
 
 err_ret:
        return ret;
@@ -403,26 +251,26 @@ static int adis16201_initial_setup(struct adis16201_state *st)
        struct device *dev = &st->indio_dev->dev;
 
        /* Disable IRQ */
-       ret = adis16201_set_irq(dev, false);
+       ret = adis16201_set_irq(st->indio_dev, false);
        if (ret) {
                dev_err(dev, "disable irq failed");
                goto err_ret;
        }
 
        /* Do self test */
-       ret = adis16201_self_test(dev);
+       ret = adis16201_self_test(st->indio_dev);
        if (ret) {
                dev_err(dev, "self test failure");
                goto err_ret;
        }
 
        /* Read status register to check the result */
-       ret = adis16201_check_status(dev);
+       ret = adis16201_check_status(st->indio_dev);
        if (ret) {
                adis16201_reset(dev);
                dev_err(dev, "device not playing ball -> reset");
                msleep(ADIS16201_STARTUP_DELAY);
-               ret = adis16201_check_status(dev);
+               ret = adis16201_check_status(st->indio_dev);
                if (ret) {
                        dev_err(dev, "giving up");
                        goto err_ret;
@@ -436,77 +284,172 @@ err_ret:
        return ret;
 }
 
-static IIO_DEV_ATTR_IN_NAMED_RAW(0, supply, adis16201_read_12bit_unsigned,
-               ADIS16201_SUPPLY_OUT);
-static IIO_CONST_ATTR(in0_supply_scale, "0.00122");
-static IIO_DEV_ATTR_IN_RAW(1, adis16201_read_12bit_unsigned,
-               ADIS16201_AUX_ADC);
-static IIO_CONST_ATTR(in1_scale, "0.00061");
-
-static IIO_DEV_ATTR_ACCEL_X(adis16201_read_14bit_signed,
-               ADIS16201_XACCL_OUT);
-static IIO_DEV_ATTR_ACCEL_Y(adis16201_read_14bit_signed,
-               ADIS16201_YACCL_OUT);
-static IIO_DEV_ATTR_ACCEL_X_OFFSET(S_IWUSR | S_IRUGO,
-               adis16201_read_12bit_signed,
-               adis16201_write_16bit,
-               ADIS16201_XACCL_OFFS);
-static IIO_DEV_ATTR_ACCEL_Y_OFFSET(S_IWUSR | S_IRUGO,
-               adis16201_read_12bit_signed,
-               adis16201_write_16bit,
-               ADIS16201_YACCL_OFFS);
-static IIO_CONST_ATTR(accel_scale, "0.4625");
-
-static IIO_DEV_ATTR_INCLI_X(adis16201_read_14bit_signed,
-               ADIS16201_XINCL_OUT);
-static IIO_DEV_ATTR_INCLI_Y(adis16201_read_14bit_signed,
-               ADIS16201_YINCL_OUT);
-static IIO_DEV_ATTR_INCLI_X_OFFSET(S_IWUSR | S_IRUGO,
-               adis16201_read_9bit_signed,
-               adis16201_write_16bit,
-               ADIS16201_XACCL_OFFS);
-static IIO_DEV_ATTR_INCLI_Y_OFFSET(S_IWUSR | S_IRUGO,
-               adis16201_read_9bit_signed,
-               adis16201_write_16bit,
-               ADIS16201_YACCL_OFFS);
-static IIO_CONST_ATTR(incli_scale, "0.1");
-
-static IIO_DEV_ATTR_TEMP_RAW(adis16201_read_temp);
-static IIO_CONST_ATTR(temp_offset, "25");
-static IIO_CONST_ATTR(temp_scale, "-0.47");
+static u8 adis16201_addresses[7][2] = {
+       [in_supply] = { ADIS16201_SUPPLY_OUT, },
+       [temp] = { ADIS16201_TEMP_OUT },
+       [accel_x] = { ADIS16201_XACCL_OUT, ADIS16201_XACCL_OFFS },
+       [accel_y] = { ADIS16201_YACCL_OUT, ADIS16201_YACCL_OFFS },
+       [in_aux] = { ADIS16201_AUX_ADC },
+       [incli_x] = { ADIS16201_XINCL_OUT },
+       [incli_y] = { ADIS16201_YINCL_OUT },
+};
 
-static IIO_DEVICE_ATTR(reset, S_IWUSR, NULL, adis16201_write_reset, 0);
+static int adis16201_read_raw(struct iio_dev *indio_dev,
+                             struct iio_chan_spec const *chan,
+                             int *val, int *val2,
+                             long mask)
+{
+       int ret;
+       int bits;
+       u8 addr;
+       s16 val16;
+
+       switch (mask) {
+       case 0:
+               mutex_lock(&indio_dev->mlock);
+               addr = adis16201_addresses[chan->address][0];
+               ret = adis16201_spi_read_reg_16(indio_dev, addr, &val16);
+               if (ret)
+                       return ret;
 
-static IIO_CONST_ATTR(name, "adis16201");
+               if (val16 & ADIS16201_ERROR_ACTIVE) {
+                       ret = adis16201_check_status(indio_dev);
+                       if (ret)
+                               return ret;
+               }
+               val16 = val16 & ((1 << chan->scan_type.realbits) - 1);
+               if (chan->scan_type.sign == 's')
+                       val16 = (s16)(val16 <<
+                                     (16 - chan->scan_type.realbits)) >>
+                               (16 - chan->scan_type.realbits);
+               *val = val16;
+               mutex_unlock(&indio_dev->mlock);
+               return IIO_VAL_INT;
+       case (1 << IIO_CHAN_INFO_SCALE_SEPARATE):
+       case (1 << IIO_CHAN_INFO_SCALE_SHARED):
+               switch (chan->type) {
+               case IIO_IN:
+                       *val = 0;
+                       if (chan->channel == 0)
+                               *val2 = 1220;
+                       else
+                               *val2 = 610;
+                       return IIO_VAL_INT_PLUS_MICRO;
+               case IIO_TEMP:
+                       *val = 0;
+                       *val2 = -470000;
+                       return IIO_VAL_INT_PLUS_MICRO;
+               case IIO_ACCEL:
+                       *val = 0;
+                       *val2 = 462500;
+                       return IIO_VAL_INT_PLUS_MICRO;
+               case IIO_INCLI:
+                       *val = 0;
+                       *val2 = 100000;
+                       return IIO_VAL_INT_PLUS_MICRO;
+               default:
+                       return -EINVAL;
+               }
+               break;
+       case (1 << IIO_CHAN_INFO_OFFSET_SEPARATE):
+               *val = 25;
+               return IIO_VAL_INT;
+       case (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE):
+               switch (chan->type) {
+               case IIO_ACCEL:
+                       bits = 12;
+                       break;
+               case IIO_INCLI:
+                       bits = 9;
+                       break;
+               default:
+                       return -EINVAL;
+               };
+               mutex_lock(&indio_dev->mlock);
+               addr = adis16201_addresses[chan->address][1];
+               ret = adis16201_spi_read_reg_16(indio_dev, addr, &val16);
+               if (ret) {
+                       mutex_unlock(&indio_dev->mlock);
+                       return ret;
+               }
+               val16 &= (1 << bits) - 1;
+               val16 = (s16)(val16 << (16 - bits)) >> (16 - bits);
+               *val = val16;
+               mutex_unlock(&indio_dev->mlock);
+               return IIO_VAL_INT;
+       }
+       return -EINVAL;
+}
 
-static struct attribute *adis16201_event_attributes[] = {
-       NULL
-};
+static int adis16201_write_raw(struct iio_dev *indio_dev,
+                              struct iio_chan_spec const *chan,
+                              int val,
+                              int val2,
+                              long mask)
+{
+       int bits;
+       s16 val16;
+       u8 addr;
+       switch (mask) {
+       case (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE):
+               switch (chan->type) {
+               case IIO_ACCEL:
+                       bits = 12;
+                       break;
+               case IIO_INCLI:
+                       bits = 9;
+                       break;
+               default:
+                       return -EINVAL;
+               };
+               val16 = val & ((1 << bits) - 1);
+               addr = adis16201_addresses[chan->address][1];
+               return adis16201_spi_write_reg_16(indio_dev, addr, val16);
+       }
+       return -EINVAL;
+}
 
-static struct attribute_group adis16201_event_attribute_group = {
-       .attrs = adis16201_event_attributes,
+static struct iio_chan_spec adis16201_channels[] = {
+       IIO_CHAN(IIO_IN, 0, 1, 0, "supply", 0, 0,
+                (1 << IIO_CHAN_INFO_SCALE_SEPARATE),
+                in_supply, ADIS16201_SCAN_SUPPLY,
+                IIO_ST('u', 12, 16, 0), 0),
+       IIO_CHAN(IIO_TEMP, 0, 1, 0, NULL, 0, 0,
+                (1 << IIO_CHAN_INFO_SCALE_SEPARATE) |
+                (1 << IIO_CHAN_INFO_OFFSET_SEPARATE),
+                temp, ADIS16201_SCAN_TEMP,
+                IIO_ST('u', 12, 16, 0), 0),
+       IIO_CHAN(IIO_ACCEL, 1, 0, 0, NULL, 0, IIO_MOD_X,
+                (1 << IIO_CHAN_INFO_SCALE_SHARED) |
+                (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE),
+                accel_x, ADIS16201_SCAN_ACC_X,
+                IIO_ST('s', 14, 16, 0), 0),
+       IIO_CHAN(IIO_ACCEL, 1, 0, 0, NULL, 0, IIO_MOD_Y,
+                (1 << IIO_CHAN_INFO_SCALE_SHARED) |
+                (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE),
+                accel_y, ADIS16201_SCAN_ACC_Y,
+                IIO_ST('s', 14, 16, 0), 0),
+       IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 1, 0,
+                (1 << IIO_CHAN_INFO_SCALE_SEPARATE),
+                in_aux, ADIS16201_SCAN_AUX_ADC,
+                IIO_ST('u', 12, 16, 0), 0),
+       IIO_CHAN(IIO_INCLI, 1, 0, 0, NULL, 0, IIO_MOD_X,
+                (1 << IIO_CHAN_INFO_SCALE_SHARED) |
+                (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE),
+                incli_x, ADIS16201_SCAN_INCLI_X,
+                IIO_ST('s', 14, 16, 0), 0),
+       IIO_CHAN(IIO_INCLI, 1, 0, 0, NULL, 0, IIO_MOD_Y,
+                (1 << IIO_CHAN_INFO_SCALE_SHARED) |
+                (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE),
+                incli_y, ADIS16201_SCAN_INCLI_Y,
+                IIO_ST('s', 14, 16, 0), 0),
+       IIO_CHAN_SOFT_TIMESTAMP(7)
 };
 
+static IIO_DEVICE_ATTR(reset, S_IWUSR, NULL, adis16201_write_reset, 0);
+
 static struct attribute *adis16201_attributes[] = {
-       &iio_dev_attr_in0_supply_raw.dev_attr.attr,
-       &iio_const_attr_in0_supply_scale.dev_attr.attr,
-       &iio_dev_attr_temp_raw.dev_attr.attr,
-       &iio_const_attr_temp_offset.dev_attr.attr,
-       &iio_const_attr_temp_scale.dev_attr.attr,
        &iio_dev_attr_reset.dev_attr.attr,
-       &iio_const_attr_name.dev_attr.attr,
-       &iio_dev_attr_in1_raw.dev_attr.attr,
-       &iio_const_attr_in1_scale.dev_attr.attr,
-       &iio_dev_attr_accel_x_raw.dev_attr.attr,
-       &iio_dev_attr_accel_y_raw.dev_attr.attr,
-       &iio_dev_attr_accel_x_offset.dev_attr.attr,
-       &iio_dev_attr_accel_y_offset.dev_attr.attr,
-       &iio_const_attr_accel_scale.dev_attr.attr,
-       &iio_dev_attr_incli_x_raw.dev_attr.attr,
-       &iio_dev_attr_incli_y_raw.dev_attr.attr,
-       &iio_dev_attr_incli_x_offset.dev_attr.attr,
-       &iio_dev_attr_incli_y_offset.dev_attr.attr,
-       &iio_const_attr_incli_scale.dev_attr.attr,
        NULL
 };
 
@@ -514,6 +457,13 @@ static const struct attribute_group adis16201_attribute_group = {
        .attrs = adis16201_attributes,
 };
 
+static const struct iio_info adis16201_info = {
+       .attrs = &adis16201_attribute_group,
+       .read_raw = &adis16201_read_raw,
+       .write_raw = &adis16201_write_raw,
+       .driver_module = THIS_MODULE,
+};
+
 static int __devinit adis16201_probe(struct spi_device *spi)
 {
        int ret, regdone = 0;
@@ -539,18 +489,19 @@ static int __devinit adis16201_probe(struct spi_device *spi)
        st->us = spi;
        mutex_init(&st->buf_lock);
        /* setup the industrialio driver allocated elements */
-       st->indio_dev = iio_allocate_device();
+       st->indio_dev = iio_allocate_device(0);
        if (st->indio_dev == NULL) {
                ret = -ENOMEM;
                goto error_free_tx;
        }
 
+       st->indio_dev->name = spi->dev.driver->name;
        st->indio_dev->dev.parent = &spi->dev;
-       st->indio_dev->num_interrupt_lines = 1;
-       st->indio_dev->event_attrs = &adis16201_event_attribute_group;
-       st->indio_dev->attrs = &adis16201_attribute_group;
+       st->indio_dev->info = &adis16201_info;
+
+       st->indio_dev->channels = adis16201_channels;
+       st->indio_dev->num_channels = ARRAY_SIZE(adis16201_channels);
        st->indio_dev->dev_data = (void *)(st);
-       st->indio_dev->driver_module = THIS_MODULE;
        st->indio_dev->modes = INDIO_DIRECT_MODE;
 
        ret = adis16201_configure_ring(st->indio_dev);
@@ -562,24 +513,18 @@ static int __devinit adis16201_probe(struct spi_device *spi)
                goto error_unreg_ring_funcs;
        regdone = 1;
 
-       ret = adis16201_initialize_ring(st->indio_dev->ring);
+       ret = iio_ring_buffer_register_ex(st->indio_dev->ring, 0,
+                                         adis16201_channels,
+                                         ARRAY_SIZE(adis16201_channels));
        if (ret) {
                printk(KERN_ERR "failed to initialize the ring\n");
                goto error_unreg_ring_funcs;
        }
 
        if (spi->irq) {
-               ret = iio_register_interrupt_line(spi->irq,
-                               st->indio_dev,
-                               0,
-                               IRQF_TRIGGER_RISING,
-                               "adis16201");
-               if (ret)
-                       goto error_uninitialize_ring;
-
                ret = adis16201_probe_trigger(st->indio_dev);
                if (ret)
-                       goto error_unregister_line;
+                       goto error_uninitialize_ring;
        }
 
        /* Get the device into a sane initial state */
@@ -590,11 +535,8 @@ static int __devinit adis16201_probe(struct spi_device *spi)
 
 error_remove_trigger:
        adis16201_remove_trigger(st->indio_dev);
-error_unregister_line:
-       if (spi->irq)
-               iio_unregister_interrupt_line(st->indio_dev, 0);
 error_uninitialize_ring:
-       adis16201_uninitialize_ring(st->indio_dev->ring);
+       iio_ring_buffer_unregister(st->indio_dev->ring);
 error_unreg_ring_funcs:
        adis16201_unconfigure_ring(st->indio_dev);
 error_free_dev:
@@ -617,13 +559,8 @@ static int adis16201_remove(struct spi_device *spi)
        struct adis16201_state *st = spi_get_drvdata(spi);
        struct iio_dev *indio_dev = st->indio_dev;
 
-       flush_scheduled_work();
-
        adis16201_remove_trigger(indio_dev);
-       if (spi->irq)
-               iio_unregister_interrupt_line(indio_dev, 0);
-
-       adis16201_uninitialize_ring(indio_dev->ring);
+       iio_ring_buffer_unregister(indio_dev->ring);
        iio_device_unregister(indio_dev);
        adis16201_unconfigure_ring(indio_dev);
        kfree(st->tx);
index e6870a2721f121efe05441b76185b5b49c230cd3..c61f981255ca0fcad61e85b0995f016c866528ab 100644 (file)
@@ -1,14 +1,11 @@
 #include <linux/interrupt.h>
 #include <linux/irq.h>
-#include <linux/gpio.h>
-#include <linux/workqueue.h>
 #include <linux/mutex.h>
 #include <linux/device.h>
 #include <linux/kernel.h>
 #include <linux/spi/spi.h>
 #include <linux/slab.h>
 #include <linux/sysfs.h>
-#include <linux/list.h>
 
 #include "../iio.h"
 #include "../sysfs.h"
 #include "../trigger.h"
 #include "adis16201.h"
 
-static IIO_SCAN_EL_C(in_supply, ADIS16201_SCAN_SUPPLY, ADIS16201_SUPPLY_OUT, NULL);
-static IIO_CONST_ATTR_SCAN_EL_TYPE(in_supply, u, 12, 16);
-static IIO_SCAN_EL_C(accel_x, ADIS16201_SCAN_ACC_X, ADIS16201_XACCL_OUT, NULL);
-static IIO_SCAN_EL_C(accel_y, ADIS16201_SCAN_ACC_Y, ADIS16201_YACCL_OUT, NULL);
-static IIO_CONST_ATTR_SCAN_EL_TYPE(accel, s, 14, 16);
-static IIO_SCAN_EL_C(in0, ADIS16201_SCAN_AUX_ADC, ADIS16201_AUX_ADC, NULL);
-static IIO_CONST_ATTR_SCAN_EL_TYPE(in0, u, 12, 16);
-static IIO_SCAN_EL_C(temp, ADIS16201_SCAN_TEMP, ADIS16201_TEMP_OUT, NULL);
-static IIO_CONST_ATTR_SCAN_EL_TYPE(temp, u, 12, 16);
-static IIO_SCAN_EL_C(incli_x, ADIS16201_SCAN_INCLI_X,
-                    ADIS16201_XINCL_OUT, NULL);
-static IIO_SCAN_EL_C(incli_y, ADIS16201_SCAN_INCLI_Y,
-                    ADIS16201_YINCL_OUT, NULL);
-static IIO_CONST_ATTR_SCAN_EL_TYPE(incli, s, 14, 16);
-static IIO_SCAN_EL_TIMESTAMP(7);
-static IIO_CONST_ATTR_SCAN_EL_TYPE(timestamp, s, 64, 64);
-
-static struct attribute *adis16201_scan_el_attrs[] = {
-       &iio_scan_el_in_supply.dev_attr.attr,
-       &iio_const_attr_in_supply_index.dev_attr.attr,
-       &iio_const_attr_in_supply_type.dev_attr.attr,
-       &iio_scan_el_accel_x.dev_attr.attr,
-       &iio_const_attr_accel_x_index.dev_attr.attr,
-       &iio_scan_el_accel_y.dev_attr.attr,
-       &iio_const_attr_accel_y_index.dev_attr.attr,
-       &iio_const_attr_accel_type.dev_attr.attr,
-       &iio_scan_el_in0.dev_attr.attr,
-       &iio_const_attr_in0_index.dev_attr.attr,
-       &iio_const_attr_in0_type.dev_attr.attr,
-       &iio_scan_el_temp.dev_attr.attr,
-       &iio_const_attr_temp_index.dev_attr.attr,
-       &iio_const_attr_temp_type.dev_attr.attr,
-       &iio_scan_el_incli_x.dev_attr.attr,
-       &iio_const_attr_incli_x_index.dev_attr.attr,
-       &iio_scan_el_incli_y.dev_attr.attr,
-       &iio_const_attr_incli_y_index.dev_attr.attr,
-       &iio_const_attr_incli_type.dev_attr.attr,
-       &iio_scan_el_timestamp.dev_attr.attr,
-       &iio_const_attr_timestamp_index.dev_attr.attr,
-       &iio_const_attr_timestamp_type.dev_attr.attr,
-       NULL,
-};
-
-static struct attribute_group adis16201_scan_el_group = {
-       .attrs = adis16201_scan_el_attrs,
-       .name = "scan_elements",
-};
-
-/**
- * adis16201_poll_func_th() top half interrupt handler called by trigger
- * @private_data:      iio_dev
- **/
-static void adis16201_poll_func_th(struct iio_dev *indio_dev, s64 time)
-{
-       struct adis16201_state *st = iio_dev_get_devdata(indio_dev);
-       st->last_timestamp = time;
-       schedule_work(&st->work_trigger_to_ring);
-}
 
 /**
  * adis16201_read_ring_data() read data registers which will be placed into ring
  * @dev: device associated with child of actual device (iio_dev or iio_trig)
  * @rx: somewhere to pass back the value read
  **/
-static int adis16201_read_ring_data(struct device *dev, u8 *rx)
+static int adis16201_read_ring_data(struct iio_dev *indio_dev, u8 *rx)
 {
        struct spi_message msg;
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
        struct adis16201_state *st = iio_dev_get_devdata(indio_dev);
        struct spi_transfer xfers[ADIS16201_OUTPUTS + 1];
        int ret;
@@ -101,7 +39,8 @@ static int adis16201_read_ring_data(struct device *dev, u8 *rx)
                xfers[i].len = 2;
                xfers[i].delay_usecs = 20;
                xfers[i].tx_buf = st->tx + 2 * i;
-               st->tx[2 * i] = ADIS16201_READ_REG(ADIS16201_SUPPLY_OUT + 2 * i);
+               st->tx[2 * i] = ADIS16201_READ_REG(ADIS16201_SUPPLY_OUT +
+                                                  2 * i);
                st->tx[2 * i + 1] = 0;
                if (i >= 1)
                        xfers[i].rx_buf = rx + 2 * (i - 1);
@@ -120,55 +59,57 @@ static int adis16201_read_ring_data(struct device *dev, u8 *rx)
 /* Whilst this makes a lot of calls to iio_sw_ring functions - it is to device
  * specific to be rolled into the core.
  */
-static void adis16201_trigger_bh_to_ring(struct work_struct *work_s)
+static irqreturn_t adis16201_trigger_handler(int irq, void *p)
 {
-       struct adis16201_state *st
-               = container_of(work_s, struct adis16201_state,
-                              work_trigger_to_ring);
-       struct iio_ring_buffer *ring = st->indio_dev->ring;
+       struct iio_poll_func *pf = p;
+       struct iio_dev *indio_dev = pf->private_data;
+       struct adis16201_state *st = iio_dev_get_devdata(indio_dev);
+       struct iio_ring_buffer *ring = indio_dev->ring;
 
        int i = 0;
        s16 *data;
-       size_t datasize = ring->access.get_bytes_per_datum(ring);
+       size_t datasize = ring->access->get_bytes_per_datum(ring);
 
        data = kmalloc(datasize, GFP_KERNEL);
        if (data == NULL) {
                dev_err(&st->us->dev, "memory alloc failed in ring bh");
-               return;
+               return -ENOMEM;
        }
 
        if (ring->scan_count)
-               if (adis16201_read_ring_data(&st->indio_dev->dev, st->rx) >= 0)
+               if (adis16201_read_ring_data(st->indio_dev, st->rx) >= 0)
                        for (; i < ring->scan_count; i++)
                                data[i] = be16_to_cpup(
                                        (__be16 *)&(st->rx[i*2]));
 
        /* Guaranteed to be aligned with 8 byte boundary */
        if (ring->scan_timestamp)
-               *((s64 *)(data + ((i + 3)/4)*4)) = st->last_timestamp;
+               *((s64 *)(data + ((i + 3)/4)*4)) = pf->timestamp;
 
-       ring->access.store_to(ring,
-                             (u8 *)data,
-                             st->last_timestamp);
+       ring->access->store_to(ring, (u8 *)data, pf->timestamp);
 
        iio_trigger_notify_done(st->indio_dev->trig);
        kfree(data);
 
-       return;
+       return IRQ_HANDLED;
 }
 
 void adis16201_unconfigure_ring(struct iio_dev *indio_dev)
 {
-       kfree(indio_dev->pollfunc);
+       iio_dealloc_pollfunc(indio_dev->pollfunc);
        iio_sw_rb_free(indio_dev->ring);
 }
 
+static const struct iio_ring_setup_ops adis16201_ring_setup_ops = {
+       .preenable = &iio_sw_ring_preenable,
+       .postenable = &iio_triggered_ring_postenable,
+       .predisable = &iio_triggered_ring_predisable,
+};
+
 int adis16201_configure_ring(struct iio_dev *indio_dev)
 {
        int ret = 0;
-       struct adis16201_state *st = indio_dev->dev_data;
        struct iio_ring_buffer *ring;
-       INIT_WORK(&st->work_trigger_to_ring, adis16201_trigger_bh_to_ring);
 
        ring = iio_sw_rb_allocate(indio_dev);
        if (!ring) {
@@ -177,42 +118,35 @@ int adis16201_configure_ring(struct iio_dev *indio_dev)
        }
        indio_dev->ring = ring;
        /* Effectively select the ring buffer implementation */
-       iio_ring_sw_register_funcs(&ring->access);
        ring->bpe = 2;
-       ring->scan_el_attrs = &adis16201_scan_el_group;
        ring->scan_timestamp = true;
-       ring->preenable = &iio_sw_ring_preenable;
-       ring->postenable = &iio_triggered_ring_postenable;
-       ring->predisable = &iio_triggered_ring_predisable;
+       ring->access = &ring_sw_access_funcs;
+       ring->setup_ops = &adis16201_ring_setup_ops;
        ring->owner = THIS_MODULE;
 
        /* Set default scan mode */
-       iio_scan_mask_set(ring, iio_scan_el_in_supply.number);
-       iio_scan_mask_set(ring, iio_scan_el_accel_x.number);
-       iio_scan_mask_set(ring, iio_scan_el_accel_y.number);
-       iio_scan_mask_set(ring, iio_scan_el_temp.number);
-       iio_scan_mask_set(ring, iio_scan_el_in0.number);
-       iio_scan_mask_set(ring, iio_scan_el_incli_x.number);
-       iio_scan_mask_set(ring, iio_scan_el_incli_y.number);
-
-       ret = iio_alloc_pollfunc(indio_dev, NULL, &adis16201_poll_func_th);
-       if (ret)
+       iio_scan_mask_set(ring, ADIS16201_SCAN_SUPPLY);
+       iio_scan_mask_set(ring, ADIS16201_SCAN_ACC_X);
+       iio_scan_mask_set(ring, ADIS16201_SCAN_ACC_Y);
+       iio_scan_mask_set(ring, ADIS16201_SCAN_AUX_ADC);
+       iio_scan_mask_set(ring, ADIS16201_SCAN_TEMP);
+       iio_scan_mask_set(ring, ADIS16201_SCAN_INCLI_X);
+       iio_scan_mask_set(ring, ADIS16201_SCAN_INCLI_Y);
+
+       indio_dev->pollfunc = iio_alloc_pollfunc(&iio_pollfunc_store_time,
+                                                &adis16201_trigger_handler,
+                                                IRQF_ONESHOT,
+                                                indio_dev,
+                                                "adis16201_consumer%d",
+                                                indio_dev->id);
+       if (indio_dev->pollfunc == NULL) {
+               ret = -ENOMEM;
                goto error_iio_sw_rb_free;
+       }
 
        indio_dev->modes |= INDIO_RING_TRIGGERED;
        return 0;
-
 error_iio_sw_rb_free:
        iio_sw_rb_free(indio_dev->ring);
        return ret;
 }
-
-int adis16201_initialize_ring(struct iio_ring_buffer *ring)
-{
-       return iio_ring_buffer_register(ring, 0);
-}
-
-void adis16201_uninitialize_ring(struct iio_ring_buffer *ring)
-{
-       iio_ring_buffer_unregister(ring);
-}
index 8a9cea1986e7298e26f51d771df93f486c867259..bea917e03b425673bab594655d9af03a38e571bc 100644 (file)
@@ -4,7 +4,6 @@
 #include <linux/device.h>
 #include <linux/kernel.h>
 #include <linux/sysfs.h>
-#include <linux/list.h>
 #include <linux/spi/spi.h>
 
 #include "../iio.h"
 #include "../trigger.h"
 #include "adis16201.h"
 
-/**
- * adis16201_data_rdy_trig_poll() the event handler for the data rdy trig
- **/
-static int adis16201_data_rdy_trig_poll(struct iio_dev *dev_info,
-                                      int index,
-                                      s64 timestamp,
-                                      int no_test)
-{
-       struct adis16201_state *st = iio_dev_get_devdata(dev_info);
-       struct iio_trigger *trig = st->trig;
-
-       iio_trigger_poll(trig, timestamp);
-
-       return IRQ_HANDLED;
-}
-
-IIO_EVENT_SH(data_rdy_trig, &adis16201_data_rdy_trig_poll);
-
-static DEVICE_ATTR(name, S_IRUGO, iio_trigger_read_name, NULL);
-
-static struct attribute *adis16201_trigger_attrs[] = {
-       &dev_attr_name.attr,
-       NULL,
-};
-
-static const struct attribute_group adis16201_trigger_attr_group = {
-       .attrs = adis16201_trigger_attrs,
-};
-
 /**
  * adis16201_data_rdy_trigger_set_state() set datardy interrupt state
  **/
@@ -49,31 +19,9 @@ static int adis16201_data_rdy_trigger_set_state(struct iio_trigger *trig,
 {
        struct adis16201_state *st = trig->private_data;
        struct iio_dev *indio_dev = st->indio_dev;
-       int ret = 0;
 
        dev_dbg(&indio_dev->dev, "%s (%d)\n", __func__, state);
-       ret = adis16201_set_irq(&st->indio_dev->dev, state);
-       if (state == false) {
-               iio_remove_event_from_list(&iio_event_data_rdy_trig,
-                                          &indio_dev->interrupts[0]
-                                          ->ev_list);
-               flush_scheduled_work();
-       } else {
-               iio_add_event_to_list(&iio_event_data_rdy_trig,
-                                     &indio_dev->interrupts[0]->ev_list);
-       }
-       return ret;
-}
-
-/**
- * adis16201_trig_try_reen() try renabling irq for data rdy trigger
- * @trig:      the datardy trigger
- **/
-static int adis16201_trig_try_reen(struct iio_trigger *trig)
-{
-       struct adis16201_state *st = trig->private_data;
-       enable_irq(st->us->irq);
-       return 0;
+       return adis16201_set_irq(st->indio_dev, state);
 }
 
 int adis16201_probe_trigger(struct iio_dev *indio_dev)
@@ -81,34 +29,36 @@ int adis16201_probe_trigger(struct iio_dev *indio_dev)
        int ret;
        struct adis16201_state *st = indio_dev->dev_data;
 
-       st->trig = iio_allocate_trigger();
-       st->trig->name = kasprintf(GFP_KERNEL,
-                               "adis16201-dev%d",
-                               indio_dev->id);
-       if (!st->trig->name) {
+       st->trig = iio_allocate_trigger("adis16201-dev%d", indio_dev->id);
+       if (st->trig == NULL) {
                ret = -ENOMEM;
-               goto error_free_trig;
+               goto error_ret;
        }
+       ret = request_irq(st->us->irq,
+                         &iio_trigger_generic_data_rdy_poll,
+                         IRQF_TRIGGER_RISING,
+                         "adis16201",
+                         st->trig);
+       if (ret)
+               goto error_free_trig;
        st->trig->dev.parent = &st->us->dev;
        st->trig->owner = THIS_MODULE;
        st->trig->private_data = st;
        st->trig->set_trigger_state = &adis16201_data_rdy_trigger_set_state;
-       st->trig->try_reenable = &adis16201_trig_try_reen;
-       st->trig->control_attrs = &adis16201_trigger_attr_group;
        ret = iio_trigger_register(st->trig);
 
        /* select default trigger */
        indio_dev->trig = st->trig;
        if (ret)
-               goto error_free_trig_name;
+               goto error_free_irq;
 
        return 0;
 
-error_free_trig_name:
-       kfree(st->trig->name);
+error_free_irq:
+       free_irq(st->us->irq, st->trig);
 error_free_trig:
        iio_free_trigger(st->trig);
-
+error_ret:
        return ret;
 }
 
@@ -117,6 +67,6 @@ void adis16201_remove_trigger(struct iio_dev *indio_dev)
        struct adis16201_state *state = indio_dev->dev_data;
 
        iio_trigger_unregister(state->trig);
-       kfree(state->trig->name);
+       free_irq(state->us->irq, state->trig);
        iio_free_trigger(state->trig);
 }
index b88688128d61a79e9c83fd85442886061da752ac..8bb8ce50c2483d339f584a2c83ad82c771ee2108 100644 (file)
@@ -59,9 +59,6 @@
 /**
  * struct adis16203_state - device instance specific data
  * @us:                        actual spi_device
- * @work_trigger_to_ring: bh for triggered event handling
- * @inter:             used to check if new interrupt has been triggered
- * @last_timestamp:    passing timestamp from th to bh of interrupt handler
  * @indio_dev:         industrial I/O device structure
  * @trig:              data ready trigger registered with iio
  * @tx:                        transmit buffer
@@ -70,8 +67,6 @@
  **/
 struct adis16203_state {
        struct spi_device               *us;
-       struct work_struct              work_trigger_to_ring;
-       s64                             last_timestamp;
        struct iio_dev                  *indio_dev;
        struct iio_trigger              *trig;
        u8                              *tx;
@@ -79,7 +74,7 @@ struct adis16203_state {
        struct mutex                    buf_lock;
 };
 
-int adis16203_set_irq(struct device *dev, bool enable);
+int adis16203_set_irq(struct iio_dev *indio_dev, bool enable);
 
 #ifdef CONFIG_IIO_RING_BUFFER
 enum adis16203_scan {
@@ -100,8 +95,6 @@ ssize_t adis16203_read_data_from_ring(struct device *dev,
 int adis16203_configure_ring(struct iio_dev *indio_dev);
 void adis16203_unconfigure_ring(struct iio_dev *indio_dev);
 
-int adis16203_initialize_ring(struct iio_ring_buffer *ring);
-void adis16203_uninitialize_ring(struct iio_ring_buffer *ring);
 #else /* CONFIG_IIO_RING_BUFFER */
 
 static inline void adis16203_remove_trigger(struct iio_dev *indio_dev)
@@ -130,14 +123,5 @@ static inline void adis16203_unconfigure_ring(struct iio_dev *indio_dev)
 {
 }
 
-static inline int adis16203_initialize_ring(struct iio_ring_buffer *ring)
-{
-       return 0;
-}
-
-static inline void adis16203_uninitialize_ring(struct iio_ring_buffer *ring)
-{
-}
-
 #endif /* CONFIG_IIO_RING_BUFFER */
 #endif /* SPI_ADIS16203_H_ */
index b57f19087a93193e712b265ae48e2bd3a3155eb9..36be4d5dc6147be310d87a3f2d5a13ac19930809 100644 (file)
@@ -6,9 +6,6 @@
  * Licensed under the GPL-2 or later.
  */
 
-#include <linux/interrupt.h>
-#include <linux/irq.h>
-#include <linux/gpio.h>
 #include <linux/delay.h>
 #include <linux/mutex.h>
 #include <linux/device.h>
 #include <linux/spi/spi.h>
 #include <linux/slab.h>
 #include <linux/sysfs.h>
-#include <linux/list.h>
 
 #include "../iio.h"
 #include "../sysfs.h"
 #include "accel.h"
 #include "inclinometer.h"
-#include "../gyro/gyro.h"
+#include "../ring_generic.h"
 #include "../adc/adc.h"
 
 #include "adis16203.h"
 
 #define DRIVER_NAME            "adis16203"
 
-static int adis16203_check_status(struct device *dev);
-
 /**
  * adis16203_spi_write_reg_8() - write single byte to a register
- * @dev: device associated with child of actual device (iio_dev or iio_trig)
+ * @indio_dev: iio device associated with child of actual device
  * @reg_address: the address of the register to be written
  * @val: the value to write
  **/
-static int adis16203_spi_write_reg_8(struct device *dev,
-               u8 reg_address,
-               u8 val)
+static int adis16203_spi_write_reg_8(struct iio_dev *indio_dev,
+                                    u8 reg_address,
+                                    u8 val)
 {
        int ret;
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
        struct adis16203_state *st = iio_dev_get_devdata(indio_dev);
 
        mutex_lock(&st->buf_lock);
@@ -57,18 +50,17 @@ static int adis16203_spi_write_reg_8(struct device *dev,
 
 /**
  * adis16203_spi_write_reg_16() - write 2 bytes to a pair of registers
- * @dev: device associated with child of actual device (iio_dev or iio_trig)
+ * @indio_dev: iio device associated with child of actual device
  * @reg_address: the address of the lower of the two registers. Second register
  *               is assumed to have address one greater.
  * @val: value to be written
  **/
-static int adis16203_spi_write_reg_16(struct device *dev,
-               u8 lower_reg_address,
-               u16 value)
+static int adis16203_spi_write_reg_16(struct iio_dev *indio_dev,
+                                     u8 lower_reg_address,
+                                     u16 value)
 {
        int ret;
        struct spi_message msg;
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
        struct adis16203_state *st = iio_dev_get_devdata(indio_dev);
        struct spi_transfer xfers[] = {
                {
@@ -80,7 +72,6 @@ static int adis16203_spi_write_reg_16(struct device *dev,
                        .tx_buf = st->tx + 2,
                        .bits_per_word = 8,
                        .len = 2,
-                       .cs_change = 1,
                },
        };
 
@@ -101,17 +92,16 @@ static int adis16203_spi_write_reg_16(struct device *dev,
 
 /**
  * adis16203_spi_read_reg_16() - read 2 bytes from a 16-bit register
- * @dev: device associated with child of actual device (iio_dev or iio_trig)
+ * @indio_dev: iio device associated with child of actual device
  * @reg_address: the address of the lower of the two registers. Second register
  *               is assumed to have address one greater.
  * @val: somewhere to pass back the value read
  **/
-static int adis16203_spi_read_reg_16(struct device *dev,
+static int adis16203_spi_read_reg_16(struct iio_dev *indio_dev,
                u8 lower_reg_address,
                u16 *val)
 {
        struct spi_message msg;
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
        struct adis16203_state *st = iio_dev_get_devdata(indio_dev);
        int ret;
        struct spi_transfer xfers[] = {
@@ -125,7 +115,6 @@ static int adis16203_spi_read_reg_16(struct device *dev,
                        .rx_buf = st->rx,
                        .bits_per_word = 8,
                        .len = 2,
-                       .cs_change = 1,
                        .delay_usecs = 20,
                },
        };
@@ -150,101 +139,43 @@ error_ret:
        return ret;
 }
 
-static ssize_t adis16203_read_12bit_unsigned(struct device *dev,
-               struct device_attribute *attr,
-               char *buf)
+static int adis16203_check_status(struct iio_dev *indio_dev)
 {
+       u16 status;
        int ret;
-       u16 val = 0;
-       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-
-       ret = adis16203_spi_read_reg_16(dev, this_attr->address, &val);
-       if (ret)
-               return ret;
-
-       if (val & ADIS16203_ERROR_ACTIVE)
-               adis16203_check_status(dev);
-
-       return sprintf(buf, "%u\n", val & 0x0FFF);
-}
 
-static ssize_t adis16203_read_temp(struct device *dev,
-               struct device_attribute *attr,
-               char *buf)
-{
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
-       ssize_t ret;
-       u16 val;
-
-       /* Take the iio_dev status lock */
-       mutex_lock(&indio_dev->mlock);
-
-       ret = adis16203_spi_read_reg_16(dev, ADIS16203_TEMP_OUT, (u16 *)&val);
-       if (ret)
+       ret = adis16203_spi_read_reg_16(indio_dev,
+                                       ADIS16203_DIAG_STAT,
+                                       &status);
+       if (ret < 0) {
+               dev_err(&indio_dev->dev, "Reading status failed\n");
                goto error_ret;
-
-       if (val & ADIS16203_ERROR_ACTIVE)
-               adis16203_check_status(dev);
-
-       val &= 0xFFF;
-       ret = sprintf(buf, "%d\n", val);
-
-error_ret:
-       mutex_unlock(&indio_dev->mlock);
-       return ret;
-}
-
-static ssize_t adis16203_read_14bit_signed(struct device *dev,
-               struct device_attribute *attr,
-               char *buf)
-{
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
-       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-       s16 val = 0;
-       ssize_t ret;
-
-       mutex_lock(&indio_dev->mlock);
-
-       ret = adis16203_spi_read_reg_16(dev, this_attr->address, (u16 *)&val);
-       if (!ret) {
-               if (val & ADIS16203_ERROR_ACTIVE)
-                       adis16203_check_status(dev);
-
-               val = ((s16)(val << 2) >> 2);
-               ret = sprintf(buf, "%d\n", val);
        }
+       ret = status & 0x1F;
 
-       mutex_unlock(&indio_dev->mlock);
-
-       return ret;
-}
-
-static ssize_t adis16203_write_16bit(struct device *dev,
-               struct device_attribute *attr,
-               const char *buf,
-               size_t len)
-{
-       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-       int ret;
-       long val;
-
-       ret = strict_strtol(buf, 10, &val);
-       if (ret)
-               goto error_ret;
-       ret = adis16203_spi_write_reg_16(dev, this_attr->address, val);
+       if (status & ADIS16203_DIAG_STAT_SELFTEST_FAIL)
+               dev_err(&indio_dev->dev, "Self test failure\n");
+       if (status & ADIS16203_DIAG_STAT_SPI_FAIL)
+               dev_err(&indio_dev->dev, "SPI failure\n");
+       if (status & ADIS16203_DIAG_STAT_FLASH_UPT)
+               dev_err(&indio_dev->dev, "Flash update failed\n");
+       if (status & ADIS16203_DIAG_STAT_POWER_HIGH)
+               dev_err(&indio_dev->dev, "Power supply above 3.625V\n");
+       if (status & ADIS16203_DIAG_STAT_POWER_LOW)
+               dev_err(&indio_dev->dev, "Power supply below 3.15V\n");
 
 error_ret:
-       return ret ? ret : len;
+       return ret;
 }
 
-static int adis16203_reset(struct device *dev)
+static int adis16203_reset(struct iio_dev *indio_dev)
 {
        int ret;
-       ret = adis16203_spi_write_reg_8(dev,
+       ret = adis16203_spi_write_reg_8(indio_dev,
                        ADIS16203_GLOB_CMD,
                        ADIS16203_GLOB_CMD_SW_RESET);
        if (ret)
-               dev_err(dev, "problem resetting device");
+               dev_err(&indio_dev->dev, "problem resetting device");
 
        return ret;
 }
@@ -253,23 +184,24 @@ static ssize_t adis16203_write_reset(struct device *dev,
                struct device_attribute *attr,
                const char *buf, size_t len)
 {
+       struct iio_dev *indio_dev = dev_get_drvdata(dev);
        if (len < 1)
                return -EINVAL;
        switch (buf[0]) {
        case '1':
        case 'y':
        case 'Y':
-               return adis16203_reset(dev);
+               return adis16203_reset(indio_dev);
        }
        return -EINVAL;
 }
 
-int adis16203_set_irq(struct device *dev, bool enable)
+int adis16203_set_irq(struct iio_dev *indio_dev, bool enable)
 {
        int ret = 0;
        u16 msc;
 
-       ret = adis16203_spi_read_reg_16(dev, ADIS16203_MSC_CTRL, &msc);
+       ret = adis16203_spi_read_reg_16(indio_dev, ADIS16203_MSC_CTRL, &msc);
        if (ret)
                goto error_ret;
 
@@ -280,142 +212,195 @@ int adis16203_set_irq(struct device *dev, bool enable)
        else
                msc &= ~ADIS16203_MSC_CTRL_DATA_RDY_EN;
 
-       ret = adis16203_spi_write_reg_16(dev, ADIS16203_MSC_CTRL, msc);
+       ret = adis16203_spi_write_reg_16(indio_dev, ADIS16203_MSC_CTRL, msc);
 
 error_ret:
        return ret;
 }
 
-static int adis16203_check_status(struct device *dev)
+static int adis16203_self_test(struct iio_dev *indio_dev)
 {
-       u16 status;
        int ret;
-
-       ret = adis16203_spi_read_reg_16(dev, ADIS16203_DIAG_STAT, &status);
-       if (ret < 0) {
-               dev_err(dev, "Reading status failed\n");
-               goto error_ret;
-       }
-       ret = status & 0x1F;
-
-       if (status & ADIS16203_DIAG_STAT_SELFTEST_FAIL)
-               dev_err(dev, "Self test failure\n");
-       if (status & ADIS16203_DIAG_STAT_SPI_FAIL)
-               dev_err(dev, "SPI failure\n");
-       if (status & ADIS16203_DIAG_STAT_FLASH_UPT)
-               dev_err(dev, "Flash update failed\n");
-       if (status & ADIS16203_DIAG_STAT_POWER_HIGH)
-               dev_err(dev, "Power supply above 3.625V\n");
-       if (status & ADIS16203_DIAG_STAT_POWER_LOW)
-               dev_err(dev, "Power supply below 3.15V\n");
-
-error_ret:
-       return ret;
-}
-
-static int adis16203_self_test(struct device *dev)
-{
-       int ret;
-       ret = adis16203_spi_write_reg_16(dev,
+       ret = adis16203_spi_write_reg_16(indio_dev,
                        ADIS16203_MSC_CTRL,
                        ADIS16203_MSC_CTRL_SELF_TEST_EN);
        if (ret) {
-               dev_err(dev, "problem starting self test");
+               dev_err(&indio_dev->dev, "problem starting self test");
                goto err_ret;
        }
 
-       adis16203_check_status(dev);
+       adis16203_check_status(indio_dev);
 
 err_ret:
        return ret;
 }
 
-static int adis16203_initial_setup(struct adis16203_state *st)
+static int adis16203_initial_setup(struct iio_dev *indio_dev)
 {
        int ret;
-       struct device *dev = &st->indio_dev->dev;
 
        /* Disable IRQ */
-       ret = adis16203_set_irq(dev, false);
+       ret = adis16203_set_irq(indio_dev, false);
        if (ret) {
-               dev_err(dev, "disable irq failed");
+               dev_err(&indio_dev->dev, "disable irq failed");
                goto err_ret;
        }
 
        /* Do self test */
-       ret = adis16203_self_test(dev);
+       ret = adis16203_self_test(indio_dev);
        if (ret) {
-               dev_err(dev, "self test failure");
+               dev_err(&indio_dev->dev, "self test failure");
                goto err_ret;
        }
 
        /* Read status register to check the result */
-       ret = adis16203_check_status(dev);
+       ret = adis16203_check_status(indio_dev);
        if (ret) {
-               adis16203_reset(dev);
-               dev_err(dev, "device not playing ball -> reset");
+               adis16203_reset(indio_dev);
+               dev_err(&indio_dev->dev, "device not playing ball -> reset");
                msleep(ADIS16203_STARTUP_DELAY);
-               ret = adis16203_check_status(dev);
+               ret = adis16203_check_status(indio_dev);
                if (ret) {
-                       dev_err(dev, "giving up");
+                       dev_err(&indio_dev->dev, "giving up");
                        goto err_ret;
                }
        }
 
-       printk(KERN_INFO DRIVER_NAME ": at CS%d (irq %d)\n",
-                       st->us->chip_select, st->us->irq);
-
 err_ret:
        return ret;
 }
 
-static IIO_DEV_ATTR_IN_NAMED_RAW(0, supply, adis16203_read_12bit_unsigned,
-               ADIS16203_SUPPLY_OUT);
-static IIO_CONST_ATTR(in0_supply_scale, "0.00122");
-static IIO_DEV_ATTR_IN_RAW(1, adis16203_read_12bit_unsigned,
-               ADIS16203_AUX_ADC);
-static IIO_CONST_ATTR(in1_scale, "0.00061");
-
-static IIO_DEV_ATTR_INCLI_X(adis16203_read_14bit_signed,
-               ADIS16203_XINCL_OUT);
-static IIO_DEV_ATTR_INCLI_Y(adis16203_read_14bit_signed,
-               ADIS16203_YINCL_OUT);
-static IIO_DEV_ATTR_INCLI_X_OFFSET(S_IWUSR | S_IRUGO,
-               adis16203_read_14bit_signed,
-               adis16203_write_16bit,
-               ADIS16203_INCL_NULL);
-static IIO_CONST_ATTR(incli_scale, "0.025");
-
-static IIO_DEV_ATTR_TEMP_RAW(adis16203_read_temp);
-static IIO_CONST_ATTR(temp_offset, "25");
-static IIO_CONST_ATTR(temp_scale, "-0.47");
+enum adis16203_chan {
+       in_supply,
+       in_aux,
+       incli_x,
+       incli_y,
+       temp,
+};
+
+static u8 adis16203_addresses[5][2] = {
+       [in_supply] = { ADIS16203_SUPPLY_OUT },
+       [in_aux] = { ADIS16203_AUX_ADC },
+       [incli_x] = { ADIS16203_XINCL_OUT, ADIS16203_INCL_NULL},
+       [incli_y] = { ADIS16203_YINCL_OUT },
+       [temp] = { ADIS16203_TEMP_OUT }
+};
 
-static IIO_DEVICE_ATTR(reset, S_IWUSR, NULL, adis16203_write_reset, 0);
+static int adis16203_write_raw(struct iio_dev *indio_dev,
+                              struct iio_chan_spec const *chan,
+                              int val,
+                              int val2,
+                              long mask)
+{
+       /* currently only one writable parameter which keeps this simple */
+       u8 addr = adis16203_addresses[chan->address][1];
+       return adis16203_spi_write_reg_16(indio_dev, addr, val & 0x3FFF);
+}
 
-static IIO_CONST_ATTR(name, "adis16203");
+static int adis16203_read_raw(struct iio_dev *indio_dev,
+                             struct iio_chan_spec const *chan,
+                             int *val, int *val2,
+                             long mask)
+{
+       int ret;
+       int bits;
+       u8 addr;
+       s16 val16;
+       switch (mask) {
+       case 0:
+               mutex_lock(&indio_dev->mlock);
+               addr = adis16203_addresses[chan->address][0];
+               ret = adis16203_spi_read_reg_16(indio_dev, addr, &val16);
+               if (ret)
+                       return ret;
 
-static struct attribute *adis16203_event_attributes[] = {
-       NULL
-};
+               if (val16 & ADIS16203_ERROR_ACTIVE) {
+                       ret = adis16203_check_status(indio_dev);
+                       if (ret)
+                               return ret;
+               }
+               val16 = val16 & ((1 << chan->scan_type.realbits) - 1);
+               if (chan->scan_type.sign == 's')
+                       val16 = (s16)(val16 <<
+                                     (16 - chan->scan_type.realbits)) >>
+                               (16 - chan->scan_type.realbits);
+               *val = val16;
+               mutex_unlock(&indio_dev->mlock);
+               return IIO_VAL_INT;
+       case (1 << IIO_CHAN_INFO_SCALE_SEPARATE):
+       case (1 << IIO_CHAN_INFO_SCALE_SHARED):
+               switch (chan->type) {
+               case IIO_IN:
+                       *val = 0;
+                       if (chan->channel == 0)
+                               *val2 = 1220;
+                       else
+                               *val2 = 610;
+                       return IIO_VAL_INT_PLUS_MICRO;
+               case IIO_TEMP:
+                       *val = 0;
+                       *val2 = -470000;
+                       return IIO_VAL_INT_PLUS_MICRO;
+               case IIO_INCLI:
+                       *val = 0;
+                       *val2 = 25000;
+                       return IIO_VAL_INT_PLUS_MICRO;
+               default:
+                       return -EINVAL;
+               }
+       case (1 << IIO_CHAN_INFO_OFFSET_SEPARATE):
+               *val = 25;
+               return IIO_VAL_INT;
+       case (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE):
+               bits = 14;
+               mutex_lock(&indio_dev->mlock);
+               addr = adis16203_addresses[chan->address][1];
+               ret = adis16203_spi_read_reg_16(indio_dev, addr, &val16);
+               if (ret) {
+                       mutex_unlock(&indio_dev->mlock);
+                       return ret;
+               }
+               val16 &= (1 << bits) - 1;
+               val16 = (s16)(val16 << (16 - bits)) >> (16 - bits);
+               *val = val16;
+               mutex_unlock(&indio_dev->mlock);
+               return IIO_VAL_INT;
+       default:
+               return -EINVAL;
+       }
+}
 
-static struct attribute_group adis16203_event_attribute_group = {
-       .attrs = adis16203_event_attributes,
+static struct iio_chan_spec adis16203_channels[] = {
+       IIO_CHAN(IIO_IN, 0, 1, 0, "supply", 0, 0,
+                (1 << IIO_CHAN_INFO_SCALE_SEPARATE),
+                in_supply, ADIS16203_SCAN_SUPPLY,
+                IIO_ST('u', 12, 16, 0), 0),
+       IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 1, 0,
+                (1 << IIO_CHAN_INFO_SCALE_SEPARATE),
+                in_aux, ADIS16203_SCAN_AUX_ADC,
+                IIO_ST('u', 12, 16, 0), 0),
+       IIO_CHAN(IIO_INCLI, 1, 0, 0, NULL, 0, IIO_MOD_X,
+                (1 << IIO_CHAN_INFO_SCALE_SHARED) |
+                (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE),
+                incli_x, ADIS16203_SCAN_INCLI_X,
+                IIO_ST('s', 14, 16, 0), 0),
+       /* Fixme: Not what it appears to be - see data sheet */
+       IIO_CHAN(IIO_INCLI, 1, 0, 0, NULL, 0, IIO_MOD_Y,
+                (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                incli_y, ADIS16203_SCAN_INCLI_Y,
+                IIO_ST('s', 14, 16, 0), 0),
+       IIO_CHAN(IIO_TEMP, 0, 1, 0, NULL, 0, 0,
+                (1 << IIO_CHAN_INFO_SCALE_SEPARATE) |
+                (1 << IIO_CHAN_INFO_OFFSET_SEPARATE),
+                temp, ADIS16203_SCAN_TEMP,
+                IIO_ST('u', 12, 16, 0), 0),
+       IIO_CHAN_SOFT_TIMESTAMP(5),
 };
 
+static IIO_DEVICE_ATTR(reset, S_IWUSR, NULL, adis16203_write_reset, 0);
+
 static struct attribute *adis16203_attributes[] = {
-       &iio_dev_attr_in0_supply_raw.dev_attr.attr,
-       &iio_const_attr_in0_supply_scale.dev_attr.attr,
-       &iio_dev_attr_temp_raw.dev_attr.attr,
-       &iio_const_attr_temp_offset.dev_attr.attr,
-       &iio_const_attr_temp_scale.dev_attr.attr,
        &iio_dev_attr_reset.dev_attr.attr,
-       &iio_const_attr_name.dev_attr.attr,
-       &iio_dev_attr_in1_raw.dev_attr.attr,
-       &iio_const_attr_in1_scale.dev_attr.attr,
-       &iio_dev_attr_incli_x_raw.dev_attr.attr,
-       &iio_dev_attr_incli_y_raw.dev_attr.attr,
-       &iio_dev_attr_incli_x_offset.dev_attr.attr,
-       &iio_const_attr_incli_scale.dev_attr.attr,
        NULL
 };
 
@@ -423,6 +408,13 @@ static const struct attribute_group adis16203_attribute_group = {
        .attrs = adis16203_attributes,
 };
 
+static const struct iio_info adis16203_info = {
+       .attrs = &adis16203_attribute_group,
+       .read_raw = &adis16203_read_raw,
+       .write_raw = &adis16203_write_raw,
+       .driver_module = THIS_MODULE,
+};
+
 static int __devinit adis16203_probe(struct spi_device *spi)
 {
        int ret, regdone = 0;
@@ -448,18 +440,17 @@ static int __devinit adis16203_probe(struct spi_device *spi)
        st->us = spi;
        mutex_init(&st->buf_lock);
        /* setup the industrialio driver allocated elements */
-       st->indio_dev = iio_allocate_device();
+       st->indio_dev = iio_allocate_device(0);
        if (st->indio_dev == NULL) {
                ret = -ENOMEM;
                goto error_free_tx;
        }
-
+       st->indio_dev->name = spi->dev.driver->name;
        st->indio_dev->dev.parent = &spi->dev;
-       st->indio_dev->num_interrupt_lines = 1;
-       st->indio_dev->event_attrs = &adis16203_event_attribute_group;
-       st->indio_dev->attrs = &adis16203_attribute_group;
+       st->indio_dev->channels = adis16203_channels;
+       st->indio_dev->num_channels = ARRAY_SIZE(adis16203_channels);
+       st->indio_dev->info = &adis16203_info;
        st->indio_dev->dev_data = (void *)(st);
-       st->indio_dev->driver_module = THIS_MODULE;
        st->indio_dev->modes = INDIO_DIRECT_MODE;
 
        ret = adis16203_configure_ring(st->indio_dev);
@@ -471,39 +462,30 @@ static int __devinit adis16203_probe(struct spi_device *spi)
                goto error_unreg_ring_funcs;
        regdone = 1;
 
-       ret = adis16203_initialize_ring(st->indio_dev->ring);
+       ret = iio_ring_buffer_register_ex(st->indio_dev->ring, 0,
+                                         adis16203_channels,
+                                         ARRAY_SIZE(adis16203_channels));
        if (ret) {
                printk(KERN_ERR "failed to initialize the ring\n");
                goto error_unreg_ring_funcs;
        }
 
        if (spi->irq) {
-               ret = iio_register_interrupt_line(spi->irq,
-                               st->indio_dev,
-                               0,
-                               IRQF_TRIGGER_RISING,
-                               "adis16203");
-               if (ret)
-                       goto error_uninitialize_ring;
-
                ret = adis16203_probe_trigger(st->indio_dev);
                if (ret)
-                       goto error_unregister_line;
+                       goto error_uninitialize_ring;
        }
 
        /* Get the device into a sane initial state */
-       ret = adis16203_initial_setup(st);
+       ret = adis16203_initial_setup(st->indio_dev);
        if (ret)
                goto error_remove_trigger;
        return 0;
 
 error_remove_trigger:
        adis16203_remove_trigger(st->indio_dev);
-error_unregister_line:
-       if (spi->irq)
-               iio_unregister_interrupt_line(st->indio_dev, 0);
 error_uninitialize_ring:
-       adis16203_uninitialize_ring(st->indio_dev->ring);
+       iio_ring_buffer_unregister(st->indio_dev->ring);
 error_unreg_ring_funcs:
        adis16203_unconfigure_ring(st->indio_dev);
 error_free_dev:
@@ -526,13 +508,8 @@ static int adis16203_remove(struct spi_device *spi)
        struct adis16203_state *st = spi_get_drvdata(spi);
        struct iio_dev *indio_dev = st->indio_dev;
 
-       flush_scheduled_work();
-
        adis16203_remove_trigger(indio_dev);
-       if (spi->irq)
-               iio_unregister_interrupt_line(indio_dev, 0);
-
-       adis16203_uninitialize_ring(indio_dev->ring);
+       iio_ring_buffer_unregister(indio_dev->ring);
        iio_device_unregister(indio_dev);
        adis16203_unconfigure_ring(indio_dev);
        kfree(st->tx);
index 3d774f7efa25125ac69946c63406cb663462dba3..a9a789d79c090e7922ce6f515999c0b489f2e97f 100644 (file)
 #include "../trigger.h"
 #include "adis16203.h"
 
-static IIO_SCAN_EL_C(in_supply, ADIS16203_SCAN_SUPPLY, ADIS16203_SUPPLY_OUT, NULL);
-static IIO_CONST_ATTR_SCAN_EL_TYPE(in_supply, u, 12, 16);
-static IIO_SCAN_EL_C(in0, ADIS16203_SCAN_AUX_ADC, ADIS16203_AUX_ADC, NULL);
-static IIO_CONST_ATTR_SCAN_EL_TYPE(in0, u, 12, 16);
-static IIO_SCAN_EL_C(temp, ADIS16203_SCAN_TEMP, ADIS16203_TEMP_OUT, NULL);
-static IIO_CONST_ATTR_SCAN_EL_TYPE(temp, u, 12, 16);
-static IIO_SCAN_EL_C(incli_x, ADIS16203_SCAN_INCLI_X,
-                    ADIS16203_XINCL_OUT, NULL);
-static IIO_SCAN_EL_C(incli_y, ADIS16203_SCAN_INCLI_Y,
-                    ADIS16203_YINCL_OUT, NULL);
-static IIO_CONST_ATTR_SCAN_EL_TYPE(incli, s, 14, 16);
-static IIO_SCAN_EL_TIMESTAMP(5);
-static IIO_CONST_ATTR_SCAN_EL_TYPE(timestamp, s, 64, 64);
-
-static struct attribute *adis16203_scan_el_attrs[] = {
-       &iio_scan_el_in_supply.dev_attr.attr,
-       &iio_const_attr_in_supply_index.dev_attr.attr,
-       &iio_const_attr_in_supply_type.dev_attr.attr,
-       &iio_scan_el_in0.dev_attr.attr,
-       &iio_const_attr_in0_index.dev_attr.attr,
-       &iio_const_attr_in0_type.dev_attr.attr,
-       &iio_scan_el_temp.dev_attr.attr,
-       &iio_const_attr_temp_index.dev_attr.attr,
-       &iio_const_attr_temp_type.dev_attr.attr,
-       &iio_scan_el_incli_x.dev_attr.attr,
-       &iio_const_attr_incli_x_index.dev_attr.attr,
-       &iio_scan_el_incli_y.dev_attr.attr,
-       &iio_const_attr_incli_y_index.dev_attr.attr,
-       &iio_const_attr_incli_type.dev_attr.attr,
-       &iio_scan_el_timestamp.dev_attr.attr,
-       &iio_const_attr_timestamp_index.dev_attr.attr,
-       &iio_const_attr_timestamp_type.dev_attr.attr,
-       NULL,
-};
-
-static struct attribute_group adis16203_scan_el_group = {
-       .attrs = adis16203_scan_el_attrs,
-       .name = "scan_elements",
-};
-
-/**
- * adis16203_poll_func_th() top half interrupt handler called by trigger
- * @private_data:      iio_dev
- **/
-static void adis16203_poll_func_th(struct iio_dev *indio_dev, s64 timestamp)
-{
-       struct adis16203_state *st = iio_dev_get_devdata(indio_dev);
-       st->last_timestamp = timestamp;
-       schedule_work(&st->work_trigger_to_ring);
-}
-
 /**
  * adis16203_read_ring_data() read data registers which will be placed into ring
  * @dev: device associated with child of actual device (iio_dev or iio_trig)
@@ -115,21 +64,21 @@ static int adis16203_read_ring_data(struct device *dev, u8 *rx)
 /* Whilst this makes a lot of calls to iio_sw_ring functions - it is to device
  * specific to be rolled into the core.
  */
-static void adis16203_trigger_bh_to_ring(struct work_struct *work_s)
+static irqreturn_t adis16203_trigger_handler(int irq, void *p)
 {
-       struct adis16203_state *st
-               = container_of(work_s, struct adis16203_state,
-                              work_trigger_to_ring);
-       struct iio_ring_buffer *ring = st->indio_dev->ring;
+       struct iio_poll_func *pf = p;
+       struct iio_dev *indio_dev = pf->private_data;
+       struct adis16203_state *st = iio_dev_get_devdata(indio_dev);
+       struct iio_ring_buffer *ring = indio_dev->ring;
 
        int i = 0;
        s16 *data;
-       size_t datasize = ring->access.get_bytes_per_datum(ring);
+       size_t datasize = ring->access->get_bytes_per_datum(ring);
 
        data = kmalloc(datasize, GFP_KERNEL);
        if (data == NULL) {
                dev_err(&st->us->dev, "memory alloc failed in ring bh");
-               return;
+               return -ENOMEM;
        }
 
        if (ring->scan_count)
@@ -140,30 +89,34 @@ static void adis16203_trigger_bh_to_ring(struct work_struct *work_s)
 
        /* Guaranteed to be aligned with 8 byte boundary */
        if (ring->scan_timestamp)
-               *((s64 *)(data + ((i + 3)/4)*4)) = st->last_timestamp;
+               *((s64 *)(data + ((i + 3)/4)*4)) = pf->timestamp;
 
-       ring->access.store_to(ring,
+       ring->access->store_to(ring,
                              (u8 *)data,
-                             st->last_timestamp);
+                             pf->timestamp);
 
        iio_trigger_notify_done(st->indio_dev->trig);
        kfree(data);
 
-       return;
+       return IRQ_HANDLED;
 }
 
 void adis16203_unconfigure_ring(struct iio_dev *indio_dev)
 {
-       kfree(indio_dev->pollfunc);
+       iio_dealloc_pollfunc(indio_dev->pollfunc);
        iio_sw_rb_free(indio_dev->ring);
 }
 
+static const struct iio_ring_setup_ops adis16203_ring_setup_ops = {
+       .preenable = &iio_sw_ring_preenable,
+       .postenable = &iio_triggered_ring_postenable,
+       .predisable = &iio_triggered_ring_predisable,
+};
+
 int adis16203_configure_ring(struct iio_dev *indio_dev)
 {
        int ret = 0;
-       struct adis16203_state *st = indio_dev->dev_data;
        struct iio_ring_buffer *ring;
-       INIT_WORK(&st->work_trigger_to_ring, adis16203_trigger_bh_to_ring);
 
        ring = iio_sw_rb_allocate(indio_dev);
        if (!ring) {
@@ -172,25 +125,29 @@ int adis16203_configure_ring(struct iio_dev *indio_dev)
        }
        indio_dev->ring = ring;
        /* Effectively select the ring buffer implementation */
-       iio_ring_sw_register_funcs(&ring->access);
        ring->bpe = 2;
-       ring->scan_el_attrs = &adis16203_scan_el_group;
        ring->scan_timestamp = true;
-       ring->preenable = &iio_sw_ring_preenable;
-       ring->postenable = &iio_triggered_ring_postenable;
-       ring->predisable = &iio_triggered_ring_predisable;
+       ring->access = &ring_sw_access_funcs;
+       ring->setup_ops = &adis16203_ring_setup_ops;
        ring->owner = THIS_MODULE;
 
        /* Set default scan mode */
-       iio_scan_mask_set(ring, iio_scan_el_in_supply.number);
-       iio_scan_mask_set(ring, iio_scan_el_temp.number);
-       iio_scan_mask_set(ring, iio_scan_el_in0.number);
-       iio_scan_mask_set(ring, iio_scan_el_incli_x.number);
-       iio_scan_mask_set(ring, iio_scan_el_incli_y.number);
-
-       ret = iio_alloc_pollfunc(indio_dev, NULL, &adis16203_poll_func_th);
-       if (ret)
+       iio_scan_mask_set(ring, ADIS16203_SCAN_SUPPLY);
+       iio_scan_mask_set(ring, ADIS16203_SCAN_TEMP);
+       iio_scan_mask_set(ring, ADIS16203_SCAN_AUX_ADC);
+       iio_scan_mask_set(ring, ADIS16203_SCAN_INCLI_X);
+       iio_scan_mask_set(ring, ADIS16203_SCAN_INCLI_Y);
+
+       indio_dev->pollfunc = iio_alloc_pollfunc(&iio_pollfunc_store_time,
+                                                &adis16203_trigger_handler,
+                                                IRQF_ONESHOT,
+                                                indio_dev,
+                                                "adis16203_consumer%d",
+                                                indio_dev->id);
+       if (indio_dev->pollfunc == NULL) {
+               ret = -ENOMEM;
                goto error_iio_sw_rb_free;
+       }
 
        indio_dev->modes |= INDIO_RING_TRIGGERED;
        return 0;
@@ -199,13 +156,3 @@ error_iio_sw_rb_free:
        iio_sw_rb_free(indio_dev->ring);
        return ret;
 }
-
-int adis16203_initialize_ring(struct iio_ring_buffer *ring)
-{
-       return iio_ring_buffer_register(ring, 0);
-}
-
-void adis16203_uninitialize_ring(struct iio_ring_buffer *ring)
-{
-       iio_ring_buffer_unregister(ring);
-}
index 50be51c25dc22ece5c0e9a6ab7d6ee47566e17ef..ca5db17319889b21e606088950d355632c08344b 100644 (file)
 #include "../trigger.h"
 #include "adis16203.h"
 
-/**
- * adis16203_data_rdy_trig_poll() the event handler for the data rdy trig
- **/
-static int adis16203_data_rdy_trig_poll(struct iio_dev *dev_info,
-                                      int index,
-                                      s64 timestamp,
-                                      int no_test)
-{
-       struct adis16203_state *st = iio_dev_get_devdata(dev_info);
-       struct iio_trigger *trig = st->trig;
-
-       iio_trigger_poll(trig, timestamp);
-
-       return IRQ_HANDLED;
-}
-
-IIO_EVENT_SH(data_rdy_trig, &adis16203_data_rdy_trig_poll);
-
-static DEVICE_ATTR(name, S_IRUGO, iio_trigger_read_name, NULL);
-
-static struct attribute *adis16203_trigger_attrs[] = {
-       &dev_attr_name.attr,
-       NULL,
-};
-
-static const struct attribute_group adis16203_trigger_attr_group = {
-       .attrs = adis16203_trigger_attrs,
-};
-
 /**
  * adis16203_data_rdy_trigger_set_state() set datardy interrupt state
  **/
@@ -49,31 +20,9 @@ static int adis16203_data_rdy_trigger_set_state(struct iio_trigger *trig,
 {
        struct adis16203_state *st = trig->private_data;
        struct iio_dev *indio_dev = st->indio_dev;
-       int ret = 0;
 
        dev_dbg(&indio_dev->dev, "%s (%d)\n", __func__, state);
-       ret = adis16203_set_irq(&st->indio_dev->dev, state);
-       if (state == false) {
-               iio_remove_event_from_list(&iio_event_data_rdy_trig,
-                                          &indio_dev->interrupts[0]
-                                          ->ev_list);
-               flush_scheduled_work();
-       } else {
-               iio_add_event_to_list(&iio_event_data_rdy_trig,
-                                     &indio_dev->interrupts[0]->ev_list);
-       }
-       return ret;
-}
-
-/**
- * adis16203_trig_try_reen() try renabling irq for data rdy trigger
- * @trig:      the datardy trigger
- **/
-static int adis16203_trig_try_reen(struct iio_trigger *trig)
-{
-       struct adis16203_state *st = trig->private_data;
-       enable_irq(st->us->irq);
-       return 0;
+       return adis16203_set_irq(st->indio_dev, state);
 }
 
 int adis16203_probe_trigger(struct iio_dev *indio_dev)
@@ -81,34 +30,38 @@ int adis16203_probe_trigger(struct iio_dev *indio_dev)
        int ret;
        struct adis16203_state *st = indio_dev->dev_data;
 
-       st->trig = iio_allocate_trigger();
-       st->trig->name = kasprintf(GFP_KERNEL,
-                               "adis16203-dev%d",
-                               indio_dev->id);
-       if (!st->trig->name) {
+       st->trig = iio_allocate_trigger("adis16203-dev%d", indio_dev->id);
+       if (st->trig == NULL) {
                ret = -ENOMEM;
-               goto error_free_trig;
+               goto error_ret;
        }
+
+       ret = request_irq(st->us->irq,
+                         &iio_trigger_generic_data_rdy_poll,
+                         IRQF_TRIGGER_RISING,
+                         "adis16203",
+                         st->trig);
+       if (ret)
+               goto error_free_trig;
+
        st->trig->dev.parent = &st->us->dev;
        st->trig->owner = THIS_MODULE;
        st->trig->private_data = st;
        st->trig->set_trigger_state = &adis16203_data_rdy_trigger_set_state;
-       st->trig->try_reenable = &adis16203_trig_try_reen;
-       st->trig->control_attrs = &adis16203_trigger_attr_group;
        ret = iio_trigger_register(st->trig);
 
        /* select default trigger */
        indio_dev->trig = st->trig;
        if (ret)
-               goto error_free_trig_name;
+               goto error_free_irq;
 
        return 0;
 
-error_free_trig_name:
-       kfree(st->trig->name);
+error_free_irq:
+       free_irq(st->us->irq, st->trig);
 error_free_trig:
        iio_free_trigger(st->trig);
-
+error_ret:
        return ret;
 }
 
@@ -117,6 +70,6 @@ void adis16203_remove_trigger(struct iio_dev *indio_dev)
        struct adis16203_state *state = indio_dev->dev_data;
 
        iio_trigger_unregister(state->trig);
-       kfree(state->trig->name);
+       free_irq(state->us->irq, state->trig);
        iio_free_trigger(state->trig);
 }
index e61844684f9905b7f0f27d829aeefdaa6616ad26..5310a4297688ba93bfa2a350024e9e8f8457fb4c 100644 (file)
@@ -67,9 +67,6 @@
 /**
  * struct adis16204_state - device instance specific data
  * @us:                        actual spi_device
- * @work_trigger_to_ring: bh for triggered event handling
- * @inter:             used to check if new interrupt has been triggered
- * @last_timestamp:    passing timestamp from th to bh of interrupt handler
  * @indio_dev:         industrial I/O device structure
  * @trig:              data ready trigger registered with iio
  * @tx:                        transmit buffer
@@ -78,8 +75,6 @@
  **/
 struct adis16204_state {
        struct spi_device               *us;
-       struct work_struct              work_trigger_to_ring;
-       s64                             last_timestamp;
        struct iio_dev                  *indio_dev;
        struct iio_trigger              *trig;
        u8                              *tx;
@@ -87,7 +82,7 @@ struct adis16204_state {
        struct mutex                    buf_lock;
 };
 
-int adis16204_set_irq(struct device *dev, bool enable);
+int adis16204_set_irq(struct iio_dev *indio_dev, bool enable);
 
 #ifdef CONFIG_IIO_RING_BUFFER
 enum adis16204_scan {
@@ -108,8 +103,6 @@ ssize_t adis16204_read_data_from_ring(struct device *dev,
 int adis16204_configure_ring(struct iio_dev *indio_dev);
 void adis16204_unconfigure_ring(struct iio_dev *indio_dev);
 
-int adis16204_initialize_ring(struct iio_ring_buffer *ring);
-void adis16204_uninitialize_ring(struct iio_ring_buffer *ring);
 #else /* CONFIG_IIO_RING_BUFFER */
 
 static inline void adis16204_remove_trigger(struct iio_dev *indio_dev)
@@ -138,14 +131,5 @@ static inline void adis16204_unconfigure_ring(struct iio_dev *indio_dev)
 {
 }
 
-static inline int adis16204_initialize_ring(struct iio_ring_buffer *ring)
-{
-       return 0;
-}
-
-static inline void adis16204_uninitialize_ring(struct iio_ring_buffer *ring)
-{
-}
-
 #endif /* CONFIG_IIO_RING_BUFFER */
 #endif /* SPI_ADIS16204_H_ */
index cc15e40726fc57c033f079757e61665358e2c209..16806704bf4863825f04477932918aae150b00c5 100644 (file)
 
 #include "../iio.h"
 #include "../sysfs.h"
+#include "../ring_generic.h"
 #include "accel.h"
-#include "../gyro/gyro.h"
 #include "../adc/adc.h"
 
 #include "adis16204.h"
 
 #define DRIVER_NAME            "adis16204"
 
-static int adis16204_check_status(struct device *dev);
-
 /**
  * adis16204_spi_write_reg_8() - write single byte to a register
  * @dev: device associated with child of actual device (iio_dev or iio_trig)
  * @reg_address: the address of the register to be written
  * @val: the value to write
  **/
-static int adis16204_spi_write_reg_8(struct device *dev,
+static int adis16204_spi_write_reg_8(struct iio_dev *indio_dev,
                u8 reg_address,
                u8 val)
 {
        int ret;
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
        struct adis16204_state *st = iio_dev_get_devdata(indio_dev);
 
        mutex_lock(&st->buf_lock);
@@ -56,18 +53,17 @@ static int adis16204_spi_write_reg_8(struct device *dev,
 
 /**
  * adis16204_spi_write_reg_16() - write 2 bytes to a pair of registers
- * @dev: device associated with child of actual device (iio_dev or iio_trig)
+ * @indio_dev: iio device associated with child of actual device
  * @reg_address: the address of the lower of the two registers. Second register
  *               is assumed to have address one greater.
  * @val: value to be written
  **/
-static int adis16204_spi_write_reg_16(struct device *dev,
+static int adis16204_spi_write_reg_16(struct iio_dev *indio_dev,
                u8 lower_reg_address,
                u16 value)
 {
        int ret;
        struct spi_message msg;
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
        struct adis16204_state *st = iio_dev_get_devdata(indio_dev);
        struct spi_transfer xfers[] = {
                {
@@ -100,17 +96,16 @@ static int adis16204_spi_write_reg_16(struct device *dev,
 
 /**
  * adis16204_spi_read_reg_16() - read 2 bytes from a 16-bit register
- * @dev: device associated with child of actual device (iio_dev or iio_trig)
+ * @indio_dev: iio device associated with child of actual device
  * @reg_address: the address of the lower of the two registers. Second register
  *               is assumed to have address one greater.
  * @val: somewhere to pass back the value read
  **/
-static int adis16204_spi_read_reg_16(struct device *dev,
-               u8 lower_reg_address,
-               u16 *val)
+static int adis16204_spi_read_reg_16(struct iio_dev *indio_dev,
+                                    u8 lower_reg_address,
+                                    u16 *val)
 {
        struct spi_message msg;
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
        struct adis16204_state *st = iio_dev_get_devdata(indio_dev);
        int ret;
        struct spi_transfer xfers[] = {
@@ -124,7 +119,6 @@ static int adis16204_spi_read_reg_16(struct device *dev,
                        .rx_buf = st->rx,
                        .bits_per_word = 8,
                        .len = 2,
-                       .cs_change = 1,
                        .delay_usecs = 20,
                },
        };
@@ -149,72 +143,31 @@ error_ret:
        return ret;
 }
 
-static ssize_t adis16204_read_12bit_unsigned(struct device *dev,
-               struct device_attribute *attr,
-               char *buf)
+static int adis16204_check_status(struct iio_dev *indio_dev)
 {
+       u16 status;
        int ret;
-       u16 val = 0;
-       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-
-       ret = adis16204_spi_read_reg_16(dev, this_attr->address, &val);
-       if (ret)
-               return ret;
-
-       if (val & ADIS16204_ERROR_ACTIVE)
-               adis16204_check_status(dev);
 
-       return sprintf(buf, "%u\n", val & 0x0FFF);
-}
-
-static ssize_t adis16204_read_temp(struct device *dev,
-               struct device_attribute *attr,
-               char *buf)
-{
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
-       ssize_t ret;
-       u16 val;
-
-       /* Take the iio_dev status lock */
-       mutex_lock(&indio_dev->mlock);
-
-       ret = adis16204_spi_read_reg_16(dev, ADIS16204_TEMP_OUT, (u16 *)&val);
-       if (ret)
+       ret = adis16204_spi_read_reg_16(indio_dev,
+                                       ADIS16204_DIAG_STAT, &status);
+       if (ret < 0) {
+               dev_err(&indio_dev->dev, "Reading status failed\n");
                goto error_ret;
-
-       if (val & ADIS16204_ERROR_ACTIVE)
-               adis16204_check_status(dev);
-
-       val &= 0xFFF;
-       ret = sprintf(buf, "%d\n", val);
-
-error_ret:
-       mutex_unlock(&indio_dev->mlock);
-       return ret;
-}
-
-static ssize_t adis16204_read_12bit_signed(struct device *dev,
-               struct device_attribute *attr,
-               char *buf)
-{
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
-       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-       s16 val = 0;
-       ssize_t ret;
-
-       mutex_lock(&indio_dev->mlock);
-
-       ret = adis16204_spi_read_reg_16(dev, this_attr->address, (u16 *)&val);
-       if (!ret) {
-               if (val & ADIS16204_ERROR_ACTIVE)
-                       adis16204_check_status(dev);
-
-               val = ((s16)(val << 4) >> 4);
-               ret = sprintf(buf, "%d\n", val);
        }
+       ret = status & 0x1F;
 
-       mutex_unlock(&indio_dev->mlock);
+       if (status & ADIS16204_DIAG_STAT_SELFTEST_FAIL)
+               dev_err(&indio_dev->dev, "Self test failure\n");
+       if (status & ADIS16204_DIAG_STAT_SPI_FAIL)
+               dev_err(&indio_dev->dev, "SPI failure\n");
+       if (status & ADIS16204_DIAG_STAT_FLASH_UPT)
+               dev_err(&indio_dev->dev, "Flash update failed\n");
+       if (status & ADIS16204_DIAG_STAT_POWER_HIGH)
+               dev_err(&indio_dev->dev, "Power supply above 3.625V\n");
+       if (status & ADIS16204_DIAG_STAT_POWER_LOW)
+               dev_err(&indio_dev->dev, "Power supply below 2.975V\n");
 
+error_ret:
        return ret;
 }
 
@@ -229,10 +182,11 @@ static ssize_t adis16204_read_14bit_signed(struct device *dev,
 
        mutex_lock(&indio_dev->mlock);
 
-       ret = adis16204_spi_read_reg_16(dev, this_attr->address, (u16 *)&val);
+       ret = adis16204_spi_read_reg_16(indio_dev,
+                                       this_attr->address, (u16 *)&val);
        if (!ret) {
                if (val & ADIS16204_ERROR_ACTIVE)
-                       adis16204_check_status(dev);
+                       adis16204_check_status(indio_dev);
 
                val = ((s16)(val << 2) >> 2);
                ret = sprintf(buf, "%d\n", val);
@@ -243,32 +197,14 @@ static ssize_t adis16204_read_14bit_signed(struct device *dev,
        return ret;
 }
 
-static ssize_t adis16204_write_16bit(struct device *dev,
-               struct device_attribute *attr,
-               const char *buf,
-               size_t len)
+static int adis16204_reset(struct iio_dev *indio_dev)
 {
-       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
        int ret;
-       long val;
-
-       ret = strict_strtol(buf, 10, &val);
-       if (ret)
-               goto error_ret;
-       ret = adis16204_spi_write_reg_16(dev, this_attr->address, val);
-
-error_ret:
-       return ret ? ret : len;
-}
-
-static int adis16204_reset(struct device *dev)
-{
-       int ret;
-       ret = adis16204_spi_write_reg_8(dev,
+       ret = adis16204_spi_write_reg_8(indio_dev,
                        ADIS16204_GLOB_CMD,
                        ADIS16204_GLOB_CMD_SW_RESET);
        if (ret)
-               dev_err(dev, "problem resetting device");
+               dev_err(&indio_dev->dev, "problem resetting device");
 
        return ret;
 }
@@ -277,23 +213,25 @@ static ssize_t adis16204_write_reset(struct device *dev,
                struct device_attribute *attr,
                const char *buf, size_t len)
 {
+       struct iio_dev *indio_dev = dev_get_drvdata(dev);
+
        if (len < 1)
                return -EINVAL;
        switch (buf[0]) {
        case '1':
        case 'y':
        case 'Y':
-               return adis16204_reset(dev);
+               return adis16204_reset(indio_dev);
        }
        return -EINVAL;
 }
 
-int adis16204_set_irq(struct device *dev, bool enable)
+int adis16204_set_irq(struct iio_dev *indio_dev, bool enable)
 {
        int ret = 0;
        u16 msc;
 
-       ret = adis16204_spi_read_reg_16(dev, ADIS16204_MSC_CTRL, &msc);
+       ret = adis16204_spi_read_reg_16(indio_dev, ADIS16204_MSC_CTRL, &msc);
        if (ret)
                goto error_ret;
 
@@ -304,106 +242,63 @@ int adis16204_set_irq(struct device *dev, bool enable)
        else
                msc &= ~ADIS16204_MSC_CTRL_DATA_RDY_EN;
 
-       ret = adis16204_spi_write_reg_16(dev, ADIS16204_MSC_CTRL, msc);
-
-error_ret:
-       return ret;
-}
-
-static int adis16204_check_status(struct device *dev)
-{
-       u16 status;
-       int ret;
-
-       ret = adis16204_spi_read_reg_16(dev, ADIS16204_DIAG_STAT, &status);
-       if (ret < 0) {
-               dev_err(dev, "Reading status failed\n");
-               goto error_ret;
-       }
-       ret = status & 0x1F;
-
-       if (status & ADIS16204_DIAG_STAT_SELFTEST_FAIL)
-               dev_err(dev, "Self test failure\n");
-       if (status & ADIS16204_DIAG_STAT_SPI_FAIL)
-               dev_err(dev, "SPI failure\n");
-       if (status & ADIS16204_DIAG_STAT_FLASH_UPT)
-               dev_err(dev, "Flash update failed\n");
-       if (status & ADIS16204_DIAG_STAT_POWER_HIGH)
-               dev_err(dev, "Power supply above 3.625V\n");
-       if (status & ADIS16204_DIAG_STAT_POWER_LOW)
-               dev_err(dev, "Power supply below 2.975V\n");
+       ret = adis16204_spi_write_reg_16(indio_dev, ADIS16204_MSC_CTRL, msc);
 
 error_ret:
        return ret;
 }
 
-static int adis16204_self_test(struct device *dev)
+static int adis16204_self_test(struct iio_dev *indio_dev)
 {
        int ret;
-       ret = adis16204_spi_write_reg_16(dev,
+       ret = adis16204_spi_write_reg_16(indio_dev,
                        ADIS16204_MSC_CTRL,
                        ADIS16204_MSC_CTRL_SELF_TEST_EN);
        if (ret) {
-               dev_err(dev, "problem starting self test");
+               dev_err(&indio_dev->dev, "problem starting self test");
                goto err_ret;
        }
 
-       adis16204_check_status(dev);
+       adis16204_check_status(indio_dev);
 
 err_ret:
        return ret;
 }
 
-static int adis16204_initial_setup(struct adis16204_state *st)
+static int adis16204_initial_setup(struct iio_dev *indio_dev)
 {
        int ret;
-       struct device *dev = &st->indio_dev->dev;
 
        /* Disable IRQ */
-       ret = adis16204_set_irq(dev, false);
+       ret = adis16204_set_irq(indio_dev, false);
        if (ret) {
-               dev_err(dev, "disable irq failed");
+               dev_err(&indio_dev->dev, "disable irq failed");
                goto err_ret;
        }
 
        /* Do self test */
-       ret = adis16204_self_test(dev);
+       ret = adis16204_self_test(indio_dev);
        if (ret) {
-               dev_err(dev, "self test failure");
+               dev_err(&indio_dev->dev, "self test failure");
                goto err_ret;
        }
 
        /* Read status register to check the result */
-       ret = adis16204_check_status(dev);
+       ret = adis16204_check_status(indio_dev);
        if (ret) {
-               adis16204_reset(dev);
-               dev_err(dev, "device not playing ball -> reset");
+               adis16204_reset(indio_dev);
+               dev_err(&indio_dev->dev, "device not playing ball -> reset");
                msleep(ADIS16204_STARTUP_DELAY);
-               ret = adis16204_check_status(dev);
+               ret = adis16204_check_status(indio_dev);
                if (ret) {
-                       dev_err(dev, "giving up");
+                       dev_err(&indio_dev->dev, "giving up");
                        goto err_ret;
                }
        }
 
-       printk(KERN_INFO DRIVER_NAME ": at CS%d (irq %d)\n",
-                       st->us->chip_select, st->us->irq);
-
 err_ret:
        return ret;
 }
-
-static IIO_DEV_ATTR_IN_NAMED_RAW(0, supply, adis16204_read_12bit_unsigned,
-               ADIS16204_SUPPLY_OUT);
-static IIO_CONST_ATTR(in0_supply_scale, "0.00122");
-static IIO_DEV_ATTR_IN_RAW(1, adis16204_read_12bit_unsigned,
-               ADIS16204_AUX_ADC);
-static IIO_CONST_ATTR(in1_scale, "0.00061");
-
-static IIO_DEV_ATTR_ACCEL_X(adis16204_read_14bit_signed,
-               ADIS16204_XACCL_OUT);
-static IIO_DEV_ATTR_ACCEL_Y(adis16204_read_14bit_signed,
-               ADIS16204_YACCL_OUT);
 static IIO_DEV_ATTR_ACCEL_XY(adis16204_read_14bit_signed,
                ADIS16204_XY_RSS_OUT);
 static IIO_DEV_ATTR_ACCEL_XPEAK(adis16204_read_14bit_signed,
@@ -412,54 +307,164 @@ static IIO_DEV_ATTR_ACCEL_YPEAK(adis16204_read_14bit_signed,
                ADIS16204_Y_PEAK_OUT);
 static IIO_DEV_ATTR_ACCEL_XYPEAK(adis16204_read_14bit_signed,
                ADIS16204_XY_PEAK_OUT);
-static IIO_DEV_ATTR_ACCEL_X_OFFSET(S_IWUSR | S_IRUGO,
-               adis16204_read_12bit_signed,
-               adis16204_write_16bit,
-               ADIS16204_XACCL_NULL);
-static IIO_DEV_ATTR_ACCEL_Y_OFFSET(S_IWUSR | S_IRUGO,
-               adis16204_read_12bit_signed,
-               adis16204_write_16bit,
-               ADIS16204_YACCL_NULL);
-static IIO_CONST_ATTR(accel_x_scale, "0.017125");
-static IIO_CONST_ATTR(accel_y_scale, "0.008407");
 static IIO_CONST_ATTR(accel_xy_scale, "0.017125");
 
-static IIO_DEV_ATTR_TEMP_RAW(adis16204_read_temp);
-static IIO_CONST_ATTR(temp_offset, "25");
-static IIO_CONST_ATTR(temp_scale, "-0.47");
-
 static IIO_DEVICE_ATTR(reset, S_IWUSR, NULL, adis16204_write_reset, 0);
 
-static IIO_CONST_ATTR(name, "adis16204");
-
-static struct attribute *adis16204_event_attributes[] = {
-       NULL
+enum adis16204_channel {
+       in_supply,
+       in_aux,
+       temp,
+       accel_x,
+       accel_y,
 };
 
-static struct attribute_group adis16204_event_attribute_group = {
-       .attrs = adis16204_event_attributes,
+static u8 adis16204_addresses[5][2] = {
+       [in_supply] = { ADIS16204_SUPPLY_OUT },
+       [in_aux] = { ADIS16204_AUX_ADC },
+       [temp] = { ADIS16204_TEMP_OUT },
+       [accel_x] = { ADIS16204_XACCL_OUT, ADIS16204_XACCL_NULL },
+       [accel_y] = { ADIS16204_XACCL_OUT, ADIS16204_YACCL_NULL },
 };
+static int adis16204_read_raw(struct iio_dev *indio_dev,
+                             struct iio_chan_spec const *chan,
+                             int *val, int *val2,
+                             long mask)
+{
+       int ret;
+       int bits;
+       u8 addr;
+       s16 val16;
+
+       switch (mask) {
+       case 0:
+               mutex_lock(&indio_dev->mlock);
+               addr = adis16204_addresses[chan->address][0];
+               ret = adis16204_spi_read_reg_16(indio_dev, addr, &val16);
+               if (ret)
+                       return ret;
+
+               if (val16 & ADIS16204_ERROR_ACTIVE) {
+                       ret = adis16204_check_status(indio_dev);
+                       if (ret)
+                               return ret;
+               }
+               val16 = val16 & ((1 << chan->scan_type.realbits) - 1);
+               if (chan->scan_type.sign == 's')
+                       val16 = (s16)(val16 <<
+                                     (16 - chan->scan_type.realbits)) >>
+                               (16 - chan->scan_type.realbits);
+               *val = val16;
+               mutex_unlock(&indio_dev->mlock);
+               return IIO_VAL_INT;
+       case (1 << IIO_CHAN_INFO_SCALE_SEPARATE):
+               switch (chan->type) {
+               case IIO_IN:
+                       *val = 0;
+                       if (chan->channel == 0)
+                               *val2 = 1220;
+                       else
+                               *val2 = 610;
+                       return IIO_VAL_INT_PLUS_MICRO;
+               case IIO_TEMP:
+                       *val = 0;
+                       *val2 = -470000;
+                       return IIO_VAL_INT_PLUS_MICRO;
+               case IIO_ACCEL:
+                       *val = 0;
+                       if (chan->channel == 'x')
+                               *val2 = 17125;
+                       else
+                               *val2 = 8407;
+                       return IIO_VAL_INT_PLUS_MICRO;
+               default:
+                       return -EINVAL;
+               }
+               break;
+       case (1 << IIO_CHAN_INFO_OFFSET_SEPARATE):
+               *val = 25;
+               return IIO_VAL_INT;
+       case (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE):
+               switch (chan->type) {
+               case IIO_ACCEL:
+                       bits = 12;
+                       break;
+               default:
+                       return -EINVAL;
+               };
+               mutex_lock(&indio_dev->mlock);
+               addr = adis16204_addresses[chan->address][1];
+               ret = adis16204_spi_read_reg_16(indio_dev, addr, &val16);
+               if (ret) {
+                       mutex_unlock(&indio_dev->mlock);
+                       return ret;
+               }
+               val16 &= (1 << bits) - 1;
+               val16 = (s16)(val16 << (16 - bits)) >> (16 - bits);
+               *val = val16;
+               mutex_unlock(&indio_dev->mlock);
+               return IIO_VAL_INT;
+       }
+       return -EINVAL;
+}
 
+static int adis16204_write_raw(struct iio_dev *indio_dev,
+                              struct iio_chan_spec const *chan,
+                              int val,
+                              int val2,
+                              long mask)
+{
+       int bits;
+       s16 val16;
+       u8 addr;
+       switch (mask) {
+       case (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE):
+               switch (chan->type) {
+               case IIO_ACCEL:
+                       bits = 12;
+                       break;
+               default:
+                       return -EINVAL;
+               };
+               val16 = val & ((1 << bits) - 1);
+               addr = adis16204_addresses[chan->address][1];
+               return adis16204_spi_write_reg_16(indio_dev, addr, val16);
+       }
+       return -EINVAL;
+}
+
+static struct iio_chan_spec adis16204_channels[] = {
+       IIO_CHAN(IIO_IN, 0, 0, 0, "supply", 0, 0,
+                (1 << IIO_CHAN_INFO_SCALE_SEPARATE),
+                in_supply, ADIS16204_SCAN_SUPPLY,
+                IIO_ST('u', 12, 16, 0), 0),
+       IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 1, 0,
+                (1 << IIO_CHAN_INFO_SCALE_SEPARATE),
+                in_aux, ADIS16204_SCAN_AUX_ADC,
+                IIO_ST('u', 12, 16, 0), 0),
+       IIO_CHAN(IIO_TEMP, 0, 1, 0, NULL, 0, 0,
+                (1 << IIO_CHAN_INFO_SCALE_SEPARATE) |
+                (1 << IIO_CHAN_INFO_OFFSET_SEPARATE),
+                temp, ADIS16204_SCAN_TEMP,
+                IIO_ST('u', 12, 16, 0), 0),
+       IIO_CHAN(IIO_ACCEL, 1, 0, 0, NULL, 0, IIO_MOD_X,
+                (1 << IIO_CHAN_INFO_SCALE_SEPARATE) |
+                (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE),
+                accel_x, ADIS16204_SCAN_ACC_X,
+                IIO_ST('s', 14, 16, 0), 0),
+       IIO_CHAN(IIO_ACCEL, 1, 0, 0, NULL, 0, IIO_MOD_Y,
+                (1 << IIO_CHAN_INFO_SCALE_SEPARATE) |
+                (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE),
+                accel_y, ADIS16204_SCAN_ACC_Y,
+                IIO_ST('s', 14, 16, 0), 0),
+       IIO_CHAN_SOFT_TIMESTAMP(5),
+};
 static struct attribute *adis16204_attributes[] = {
-       &iio_dev_attr_in0_supply_raw.dev_attr.attr,
-       &iio_const_attr_in0_supply_scale.dev_attr.attr,
-       &iio_dev_attr_temp_raw.dev_attr.attr,
-       &iio_const_attr_temp_offset.dev_attr.attr,
-       &iio_const_attr_temp_scale.dev_attr.attr,
        &iio_dev_attr_reset.dev_attr.attr,
-       &iio_const_attr_name.dev_attr.attr,
-       &iio_dev_attr_in1_raw.dev_attr.attr,
-       &iio_const_attr_in1_scale.dev_attr.attr,
-       &iio_dev_attr_accel_x_raw.dev_attr.attr,
-       &iio_dev_attr_accel_y_raw.dev_attr.attr,
        &iio_dev_attr_accel_xy.dev_attr.attr,
        &iio_dev_attr_accel_xpeak.dev_attr.attr,
        &iio_dev_attr_accel_ypeak.dev_attr.attr,
        &iio_dev_attr_accel_xypeak.dev_attr.attr,
-       &iio_dev_attr_accel_x_offset.dev_attr.attr,
-       &iio_dev_attr_accel_y_offset.dev_attr.attr,
-       &iio_const_attr_accel_x_scale.dev_attr.attr,
-       &iio_const_attr_accel_y_scale.dev_attr.attr,
        &iio_const_attr_accel_xy_scale.dev_attr.attr,
        NULL
 };
@@ -468,6 +473,13 @@ static const struct attribute_group adis16204_attribute_group = {
        .attrs = adis16204_attributes,
 };
 
+static const struct iio_info adis16204_info = {
+       .attrs = &adis16204_attribute_group,
+       .read_raw = &adis16204_read_raw,
+       .write_raw = &adis16204_write_raw,
+       .driver_module = THIS_MODULE,
+};
+
 static int __devinit adis16204_probe(struct spi_device *spi)
 {
        int ret, regdone = 0;
@@ -493,18 +505,18 @@ static int __devinit adis16204_probe(struct spi_device *spi)
        st->us = spi;
        mutex_init(&st->buf_lock);
        /* setup the industrialio driver allocated elements */
-       st->indio_dev = iio_allocate_device();
+       st->indio_dev = iio_allocate_device(0);
        if (st->indio_dev == NULL) {
                ret = -ENOMEM;
                goto error_free_tx;
        }
 
+       st->indio_dev->name = spi->dev.driver->name;
        st->indio_dev->dev.parent = &spi->dev;
-       st->indio_dev->num_interrupt_lines = 1;
-       st->indio_dev->event_attrs = &adis16204_event_attribute_group;
-       st->indio_dev->attrs = &adis16204_attribute_group;
+       st->indio_dev->info = &adis16204_info;
+       st->indio_dev->channels = adis16204_channels;
+       st->indio_dev->num_channels = ARRAY_SIZE(adis16204_channels);
        st->indio_dev->dev_data = (void *)(st);
-       st->indio_dev->driver_module = THIS_MODULE;
        st->indio_dev->modes = INDIO_DIRECT_MODE;
 
        ret = adis16204_configure_ring(st->indio_dev);
@@ -516,39 +528,30 @@ static int __devinit adis16204_probe(struct spi_device *spi)
                goto error_unreg_ring_funcs;
        regdone = 1;
 
-       ret = adis16204_initialize_ring(st->indio_dev->ring);
+       ret = iio_ring_buffer_register_ex(st->indio_dev->ring, 0,
+                                         adis16204_channels,
+                                         ARRAY_SIZE(adis16204_channels));
        if (ret) {
                printk(KERN_ERR "failed to initialize the ring\n");
                goto error_unreg_ring_funcs;
        }
 
        if (spi->irq) {
-               ret = iio_register_interrupt_line(spi->irq,
-                               st->indio_dev,
-                               0,
-                               IRQF_TRIGGER_RISING,
-                               "adis16204");
-               if (ret)
-                       goto error_uninitialize_ring;
-
                ret = adis16204_probe_trigger(st->indio_dev);
                if (ret)
-                       goto error_unregister_line;
+                       goto error_uninitialize_ring;
        }
 
        /* Get the device into a sane initial state */
-       ret = adis16204_initial_setup(st);
+       ret = adis16204_initial_setup(st->indio_dev);
        if (ret)
                goto error_remove_trigger;
        return 0;
 
 error_remove_trigger:
        adis16204_remove_trigger(st->indio_dev);
-error_unregister_line:
-       if (spi->irq)
-               iio_unregister_interrupt_line(st->indio_dev, 0);
 error_uninitialize_ring:
-       adis16204_uninitialize_ring(st->indio_dev->ring);
+       iio_ring_buffer_unregister(st->indio_dev->ring);
 error_unreg_ring_funcs:
        adis16204_unconfigure_ring(st->indio_dev);
 error_free_dev:
@@ -571,13 +574,8 @@ static int adis16204_remove(struct spi_device *spi)
        struct adis16204_state *st = spi_get_drvdata(spi);
        struct iio_dev *indio_dev = st->indio_dev;
 
-       flush_scheduled_work();
-
        adis16204_remove_trigger(indio_dev);
-       if (spi->irq)
-               iio_unregister_interrupt_line(indio_dev, 0);
-
-       adis16204_uninitialize_ring(indio_dev->ring);
+       iio_ring_buffer_unregister(st->indio_dev->ring);
        iio_device_unregister(indio_dev);
        adis16204_unconfigure_ring(indio_dev);
        kfree(st->tx);
@@ -609,5 +607,5 @@ static __exit void adis16204_exit(void)
 module_exit(adis16204_exit);
 
 MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>");
-MODULE_DESCRIPTION("Analog Devices ADIS16204 Programmable High-g Digital Impact Sensor and Recorder");
+MODULE_DESCRIPTION("ADIS16204 High-g Digital Impact Sensor and Recorder");
 MODULE_LICENSE("GPL v2");
index 420b160fe3abca9e86e6e3ae9a6ab57fae3d0542..a2d36fb822e57ee136ebc68a161af721a29f8032 100644 (file)
 #include "../trigger.h"
 #include "adis16204.h"
 
-static IIO_SCAN_EL_C(in_supply, ADIS16204_SCAN_SUPPLY, ADIS16204_SUPPLY_OUT, NULL);
-static IIO_CONST_ATTR_SCAN_EL_TYPE(in_supply, u, 12, 16);
-static IIO_SCAN_EL_C(accel_x, ADIS16204_SCAN_ACC_X, ADIS16204_XACCL_OUT, NULL);
-static IIO_SCAN_EL_C(accel_y, ADIS16204_SCAN_ACC_Y, ADIS16204_YACCL_OUT, NULL);
-static IIO_CONST_ATTR_SCAN_EL_TYPE(accel, s, 14, 16);
-static IIO_SCAN_EL_C(in0, ADIS16204_SCAN_AUX_ADC, ADIS16204_AUX_ADC, NULL);
-static IIO_CONST_ATTR_SCAN_EL_TYPE(in0, u, 12, 16);
-static IIO_SCAN_EL_C(temp, ADIS16204_SCAN_TEMP, ADIS16204_TEMP_OUT, NULL);
-static IIO_CONST_ATTR_SCAN_EL_TYPE(temp, u, 12, 16);
-static IIO_SCAN_EL_TIMESTAMP(5);
-static IIO_CONST_ATTR_SCAN_EL_TYPE(timestamp, s, 64, 64);
-
-static struct attribute *adis16204_scan_el_attrs[] = {
-       &iio_scan_el_in_supply.dev_attr.attr,
-       &iio_const_attr_in_supply_index.dev_attr.attr,
-       &iio_const_attr_in_supply_type.dev_attr.attr,
-       &iio_scan_el_accel_x.dev_attr.attr,
-       &iio_const_attr_accel_x_index.dev_attr.attr,
-       &iio_scan_el_accel_y.dev_attr.attr,
-       &iio_const_attr_accel_y_index.dev_attr.attr,
-       &iio_const_attr_accel_type.dev_attr.attr,
-       &iio_scan_el_in0.dev_attr.attr,
-       &iio_const_attr_in0_index.dev_attr.attr,
-       &iio_const_attr_in0_type.dev_attr.attr,
-       &iio_scan_el_temp.dev_attr.attr,
-       &iio_const_attr_temp_index.dev_attr.attr,
-       &iio_const_attr_temp_type.dev_attr.attr,
-       &iio_scan_el_timestamp.dev_attr.attr,
-       &iio_const_attr_timestamp_index.dev_attr.attr,
-       &iio_const_attr_timestamp_type.dev_attr.attr,
-       NULL,
-};
-
-static struct attribute_group adis16204_scan_el_group = {
-       .attrs = adis16204_scan_el_attrs,
-       .name = "scan_elements",
-};
-
-/**
- * adis16204_poll_func_th() top half interrupt handler called by trigger
- * @private_data:      iio_dev
- **/
-static void adis16204_poll_func_th(struct iio_dev *indio_dev, s64 timestamp)
-{
-       struct adis16204_state *st = iio_dev_get_devdata(indio_dev);
-       st->last_timestamp = timestamp;
-       schedule_work(&st->work_trigger_to_ring);
-}
-
 /**
  * adis16204_read_ring_data() read data registers which will be placed into ring
  * @dev: device associated with child of actual device (iio_dev or iio_trig)
@@ -91,7 +42,8 @@ static int adis16204_read_ring_data(struct device *dev, u8 *rx)
                xfers[i].len = 2;
                xfers[i].delay_usecs = 20;
                xfers[i].tx_buf = st->tx + 2 * i;
-               st->tx[2 * i] = ADIS16204_READ_REG(ADIS16204_SUPPLY_OUT + 2 * i);
+               st->tx[2 * i]
+                       = ADIS16204_READ_REG(ADIS16204_SUPPLY_OUT + 2 * i);
                st->tx[2 * i + 1] = 0;
                if (i >= 1)
                        xfers[i].rx_buf = rx + 2 * (i - 1);
@@ -110,21 +62,20 @@ static int adis16204_read_ring_data(struct device *dev, u8 *rx)
 /* Whilst this makes a lot of calls to iio_sw_ring functions - it is to device
  * specific to be rolled into the core.
  */
-static void adis16204_trigger_bh_to_ring(struct work_struct *work_s)
+static irqreturn_t adis16204_trigger_handler(int irq, void *p)
 {
-       struct adis16204_state *st
-               = container_of(work_s, struct adis16204_state,
-                              work_trigger_to_ring);
-       struct iio_ring_buffer *ring = st->indio_dev->ring;
-
+       struct iio_poll_func *pf = p;
+       struct iio_dev *indio_dev = pf->private_data;
+       struct adis16204_state *st = iio_dev_get_devdata(indio_dev);
+       struct iio_ring_buffer *ring = indio_dev->ring;
        int i = 0;
        s16 *data;
-       size_t datasize = ring->access.get_bytes_per_datum(ring);
+       size_t datasize = ring->access->get_bytes_per_datum(ring);
 
        data = kmalloc(datasize, GFP_KERNEL);
        if (data == NULL) {
                dev_err(&st->us->dev, "memory alloc failed in ring bh");
-               return;
+               return -ENOMEM;
        }
 
        if (ring->scan_count)
@@ -135,30 +86,32 @@ static void adis16204_trigger_bh_to_ring(struct work_struct *work_s)
 
        /* Guaranteed to be aligned with 8 byte boundary */
        if (ring->scan_timestamp)
-               *((s64 *)(data + ((i + 3)/4)*4)) = st->last_timestamp;
+               *((s64 *)(data + ((i + 3)/4)*4)) = pf->timestamp;
 
-       ring->access.store_to(ring,
-                             (u8 *)data,
-                             st->last_timestamp);
+       ring->access->store_to(ring, (u8 *)data, pf->timestamp);
 
        iio_trigger_notify_done(st->indio_dev->trig);
        kfree(data);
 
-       return;
+       return IRQ_HANDLED;
 }
 
 void adis16204_unconfigure_ring(struct iio_dev *indio_dev)
 {
-       kfree(indio_dev->pollfunc);
+       iio_dealloc_pollfunc(indio_dev->pollfunc);
        iio_sw_rb_free(indio_dev->ring);
 }
 
+static const struct iio_ring_setup_ops adis16204_ring_setup_ops = {
+       .preenable = &iio_sw_ring_preenable,
+       .postenable = &iio_triggered_ring_postenable,
+       .predisable = &iio_triggered_ring_predisable,
+};
+
 int adis16204_configure_ring(struct iio_dev *indio_dev)
 {
        int ret = 0;
-       struct adis16204_state *st = indio_dev->dev_data;
        struct iio_ring_buffer *ring;
-       INIT_WORK(&st->work_trigger_to_ring, adis16204_trigger_bh_to_ring);
 
        ring = iio_sw_rb_allocate(indio_dev);
        if (!ring) {
@@ -167,25 +120,30 @@ int adis16204_configure_ring(struct iio_dev *indio_dev)
        }
        indio_dev->ring = ring;
        /* Effectively select the ring buffer implementation */
-       iio_ring_sw_register_funcs(&ring->access);
+       ring->access = &ring_sw_access_funcs;
        ring->bpe = 2;
-       ring->scan_el_attrs = &adis16204_scan_el_group;
        ring->scan_timestamp = true;
-       ring->preenable = &iio_sw_ring_preenable;
-       ring->postenable = &iio_triggered_ring_postenable;
-       ring->predisable = &iio_triggered_ring_predisable;
+       ring->setup_ops = &adis16204_ring_setup_ops;
        ring->owner = THIS_MODULE;
 
        /* Set default scan mode */
-       iio_scan_mask_set(ring, iio_scan_el_in_supply.number);
-       iio_scan_mask_set(ring, iio_scan_el_accel_x.number);
-       iio_scan_mask_set(ring, iio_scan_el_accel_y.number);
-       iio_scan_mask_set(ring, iio_scan_el_temp.number);
-       iio_scan_mask_set(ring, iio_scan_el_in0.number);
-
-       ret = iio_alloc_pollfunc(indio_dev, NULL, &adis16204_poll_func_th);
-       if (ret)
+       iio_scan_mask_set(ring, ADIS16204_SCAN_SUPPLY);
+       iio_scan_mask_set(ring, ADIS16204_SCAN_ACC_X);
+       iio_scan_mask_set(ring, ADIS16204_SCAN_ACC_Y);
+       iio_scan_mask_set(ring, ADIS16204_SCAN_AUX_ADC);
+       iio_scan_mask_set(ring, ADIS16204_SCAN_TEMP);
+
+       indio_dev->pollfunc = iio_alloc_pollfunc(&iio_pollfunc_store_time,
+                                                &adis16204_trigger_handler,
+                                                IRQF_ONESHOT,
+                                                indio_dev,
+                                                "%s_consumer%d",
+                                                indio_dev->name,
+                                                indio_dev->id);
+       if (indio_dev->pollfunc == NULL) {
+               ret = -ENOMEM;
                goto error_iio_sw_rb_free;
+       }
 
        indio_dev->modes |= INDIO_RING_TRIGGERED;
        return 0;
@@ -194,13 +152,3 @@ error_iio_sw_rb_free:
        iio_sw_rb_free(indio_dev->ring);
        return ret;
 }
-
-int adis16204_initialize_ring(struct iio_ring_buffer *ring)
-{
-       return iio_ring_buffer_register(ring, 0);
-}
-
-void adis16204_uninitialize_ring(struct iio_ring_buffer *ring)
-{
-       iio_ring_buffer_unregister(ring);
-}
index 8e9db90e51eb3f9f2528e4955d516d6047a71ad9..5e1f9ae9d5c182e09085a852d6c2c0ef6acebf15 100644 (file)
 #include "../trigger.h"
 #include "adis16204.h"
 
-/**
- * adis16204_data_rdy_trig_poll() the event handler for the data rdy trig
- **/
-static int adis16204_data_rdy_trig_poll(struct iio_dev *dev_info,
-                                      int index,
-                                      s64 timestamp,
-                                      int no_test)
-{
-       struct adis16204_state *st = iio_dev_get_devdata(dev_info);
-       struct iio_trigger *trig = st->trig;
-
-       iio_trigger_poll(trig, timestamp);
-
-       return IRQ_HANDLED;
-}
-
-IIO_EVENT_SH(data_rdy_trig, &adis16204_data_rdy_trig_poll);
-
-static DEVICE_ATTR(name, S_IRUGO, iio_trigger_read_name, NULL);
-
-static struct attribute *adis16204_trigger_attrs[] = {
-       &dev_attr_name.attr,
-       NULL,
-};
-
-static const struct attribute_group adis16204_trigger_attr_group = {
-       .attrs = adis16204_trigger_attrs,
-};
-
 /**
  * adis16204_data_rdy_trigger_set_state() set datardy interrupt state
  **/
@@ -49,31 +20,9 @@ static int adis16204_data_rdy_trigger_set_state(struct iio_trigger *trig,
 {
        struct adis16204_state *st = trig->private_data;
        struct iio_dev *indio_dev = st->indio_dev;
-       int ret = 0;
 
        dev_dbg(&indio_dev->dev, "%s (%d)\n", __func__, state);
-       ret = adis16204_set_irq(&st->indio_dev->dev, state);
-       if (state == false) {
-               iio_remove_event_from_list(&iio_event_data_rdy_trig,
-                                          &indio_dev->interrupts[0]
-                                          ->ev_list);
-               flush_scheduled_work();
-       } else {
-               iio_add_event_to_list(&iio_event_data_rdy_trig,
-                                     &indio_dev->interrupts[0]->ev_list);
-       }
-       return ret;
-}
-
-/**
- * adis16204_trig_try_reen() try renabling irq for data rdy trigger
- * @trig:      the datardy trigger
- **/
-static int adis16204_trig_try_reen(struct iio_trigger *trig)
-{
-       struct adis16204_state *st = trig->private_data;
-       enable_irq(st->us->irq);
-       return 0;
+       return adis16204_set_irq(st->indio_dev, state);
 }
 
 int adis16204_probe_trigger(struct iio_dev *indio_dev)
@@ -81,34 +30,38 @@ int adis16204_probe_trigger(struct iio_dev *indio_dev)
        int ret;
        struct adis16204_state *st = indio_dev->dev_data;
 
-       st->trig = iio_allocate_trigger();
-       st->trig->name = kasprintf(GFP_KERNEL,
-                               "adis16204-dev%d",
-                               indio_dev->id);
-       if (!st->trig->name) {
+       st->trig = iio_allocate_trigger("adis16204-dev%d", indio_dev->id);
+       if (st->trig == NULL) {
                ret = -ENOMEM;
-               goto error_free_trig;
+               goto error_ret;
        }
+
+       ret = request_irq(st->us->irq,
+                         &iio_trigger_generic_data_rdy_poll,
+                         IRQF_TRIGGER_RISING,
+                         "adis16204",
+                         st->trig);
+       if (ret)
+               goto error_free_trig;
+
        st->trig->dev.parent = &st->us->dev;
        st->trig->owner = THIS_MODULE;
        st->trig->private_data = st;
        st->trig->set_trigger_state = &adis16204_data_rdy_trigger_set_state;
-       st->trig->try_reenable = &adis16204_trig_try_reen;
-       st->trig->control_attrs = &adis16204_trigger_attr_group;
        ret = iio_trigger_register(st->trig);
 
        /* select default trigger */
        indio_dev->trig = st->trig;
        if (ret)
-               goto error_free_trig_name;
+               goto error_free_irq;
 
        return 0;
 
-error_free_trig_name:
-       kfree(st->trig->name);
+error_free_irq:
+       free_irq(st->us->irq, st->trig);
 error_free_trig:
        iio_free_trigger(st->trig);
-
+error_ret:
        return ret;
 }
 
@@ -117,6 +70,6 @@ void adis16204_remove_trigger(struct iio_dev *indio_dev)
        struct adis16204_state *state = indio_dev->dev_data;
 
        iio_trigger_unregister(state->trig);
-       kfree(state->trig->name);
+       free_irq(state->us->irq, state->trig);
        iio_free_trigger(state->trig);
 }
index 8b0da1349555c9db611632a30307587341890a08..58d08db6f9b50488526dc651923ec6958e6950bc 100644 (file)
 /**
  * struct adis16209_state - device instance specific data
  * @us:                        actual spi_device
- * @work_trigger_to_ring: bh for triggered event handling
- * @last_timestamp:    passing timestamp from th to bh of interrupt handler
  * @indio_dev:         industrial I/O device structure
  * @trig:              data ready trigger registered with iio
  * @tx:                        transmit buffer
  **/
 struct adis16209_state {
        struct spi_device               *us;
-       struct work_struct              work_trigger_to_ring;
-       s64                             last_timestamp;
        struct iio_dev                  *indio_dev;
        struct iio_trigger              *trig;
        u8                              *tx;
@@ -123,7 +119,7 @@ struct adis16209_state {
        struct mutex                    buf_lock;
 };
 
-int adis16209_set_irq(struct device *dev, bool enable);
+int adis16209_set_irq(struct iio_dev *indio_dev, bool enable);
 
 #ifdef CONFIG_IIO_RING_BUFFER
 
index e4ac956208a6df33c95fd2c4bbee46bd18a902cf..c423cc960254858a1bd11360fd7cc758bf31d280 100644 (file)
@@ -6,9 +6,6 @@
  * Licensed under the GPL-2 or later.
  */
 
-#include <linux/interrupt.h>
-#include <linux/irq.h>
-#include <linux/gpio.h>
 #include <linux/delay.h>
 #include <linux/mutex.h>
 #include <linux/device.h>
 #include "../ring_generic.h"
 #include "accel.h"
 #include "inclinometer.h"
-#include "../gyro/gyro.h"
 #include "../adc/adc.h"
 
 #include "adis16209.h"
 
 #define DRIVER_NAME            "adis16209"
 
-static int adis16209_check_status(struct device *dev);
-
 /**
  * adis16209_spi_write_reg_8() - write single byte to a register
- * @dev: device associated with child of actual device (iio_dev or iio_trig)
+ * @indio_dev: iio device associated with actual device
  * @reg_address: the address of the register to be written
  * @val: the value to write
  **/
-static int adis16209_spi_write_reg_8(struct device *dev,
-               u8 reg_address,
-               u8 val)
+static int adis16209_spi_write_reg_8(struct iio_dev *indio_dev,
+                                    u8 reg_address,
+                                    u8 val)
 {
        int ret;
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
        struct adis16209_state *st = iio_dev_get_devdata(indio_dev);
 
        mutex_lock(&st->buf_lock);
@@ -58,18 +51,17 @@ static int adis16209_spi_write_reg_8(struct device *dev,
 
 /**
  * adis16209_spi_write_reg_16() - write 2 bytes to a pair of registers
- * @dev: device associated with child of actual device (iio_dev or iio_trig)
+ * @indio_dev: iio device associated actual device
  * @reg_address: the address of the lower of the two registers. Second register
  *               is assumed to have address one greater.
  * @val: value to be written
  **/
-static int adis16209_spi_write_reg_16(struct device *dev,
-               u8 lower_reg_address,
-               u16 value)
+static int adis16209_spi_write_reg_16(struct iio_dev *indio_dev,
+                                     u8 lower_reg_address,
+                                     u16 value)
 {
        int ret;
        struct spi_message msg;
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
        struct adis16209_state *st = iio_dev_get_devdata(indio_dev);
        struct spi_transfer xfers[] = {
                {
@@ -82,7 +74,6 @@ static int adis16209_spi_write_reg_16(struct device *dev,
                        .tx_buf = st->tx + 2,
                        .bits_per_word = 8,
                        .len = 2,
-                       .cs_change = 1,
                        .delay_usecs = 30,
                },
        };
@@ -104,17 +95,16 @@ static int adis16209_spi_write_reg_16(struct device *dev,
 
 /**
  * adis16209_spi_read_reg_16() - read 2 bytes from a 16-bit register
- * @dev: device associated with child of actual device (iio_dev or iio_trig)
+ * @indio_dev: iio device associated with device
  * @reg_address: the address of the lower of the two registers. Second register
  *               is assumed to have address one greater.
  * @val: somewhere to pass back the value read
  **/
-static int adis16209_spi_read_reg_16(struct device *dev,
-               u8 lower_reg_address,
-               u16 *val)
+static int adis16209_spi_read_reg_16(struct iio_dev *indio_dev,
+                                    u8 lower_reg_address,
+                                    u16 *val)
 {
        struct spi_message msg;
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
        struct adis16209_state *st = iio_dev_get_devdata(indio_dev);
        int ret;
        struct spi_transfer xfers[] = {
@@ -128,7 +118,6 @@ static int adis16209_spi_read_reg_16(struct device *dev,
                        .rx_buf = st->rx,
                        .bits_per_word = 8,
                        .len = 2,
-                       .cs_change = 1,
                        .delay_usecs = 30,
                },
        };
@@ -154,119 +143,14 @@ error_ret:
        return ret;
 }
 
-static ssize_t adis16209_read_12bit_unsigned(struct device *dev,
-               struct device_attribute *attr,
-               char *buf)
-{
-       int ret;
-       u16 val = 0;
-       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-
-       ret = adis16209_spi_read_reg_16(dev, this_attr->address, &val);
-       if (ret)
-               return ret;
-
-       if (val & ADIS16209_ERROR_ACTIVE)
-               adis16209_check_status(dev);
-
-       return sprintf(buf, "%u\n", val & 0x0FFF);
-}
-
-static ssize_t adis16209_read_14bit_unsigned(struct device *dev,
-               struct device_attribute *attr,
-               char *buf)
-{
-       int ret;
-       u16 val = 0;
-       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-
-       ret = adis16209_spi_read_reg_16(dev, this_attr->address, &val);
-       if (ret)
-               return ret;
-
-       if (val & ADIS16209_ERROR_ACTIVE)
-               adis16209_check_status(dev);
-
-       return sprintf(buf, "%u\n", val & 0x3FFF);
-}
-
-static ssize_t adis16209_read_temp(struct device *dev,
-               struct device_attribute *attr,
-               char *buf)
-{
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
-       ssize_t ret;
-       u16 val;
-
-       /* Take the iio_dev status lock */
-       mutex_lock(&indio_dev->mlock);
-
-       ret = adis16209_spi_read_reg_16(dev, ADIS16209_TEMP_OUT, (u16 *)&val);
-       if (ret)
-               goto error_ret;
-
-       if (val & ADIS16209_ERROR_ACTIVE)
-               adis16209_check_status(dev);
-
-       val &= 0xFFF;
-       ret = sprintf(buf, "%d\n", val);
-
-error_ret:
-       mutex_unlock(&indio_dev->mlock);
-       return ret;
-}
-
-static ssize_t adis16209_read_14bit_signed(struct device *dev,
-               struct device_attribute *attr,
-               char *buf)
-{
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
-       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-       s16 val = 0;
-       ssize_t ret;
-
-       mutex_lock(&indio_dev->mlock);
-
-       ret = adis16209_spi_read_reg_16(dev, this_attr->address, (u16 *)&val);
-       if (!ret) {
-               if (val & ADIS16209_ERROR_ACTIVE)
-                       adis16209_check_status(dev);
-
-               val = ((s16)(val << 2) >> 2);
-               ret = sprintf(buf, "%d\n", val);
-       }
-
-       mutex_unlock(&indio_dev->mlock);
-
-       return ret;
-}
-
-static ssize_t adis16209_write_16bit(struct device *dev,
-               struct device_attribute *attr,
-               const char *buf,
-               size_t len)
+static int adis16209_reset(struct iio_dev *indio_dev)
 {
-       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
        int ret;
-       long val;
-
-       ret = strict_strtol(buf, 10, &val);
-       if (ret)
-               goto error_ret;
-       ret = adis16209_spi_write_reg_16(dev, this_attr->address, val);
-
-error_ret:
-       return ret ? ret : len;
-}
-
-static int adis16209_reset(struct device *dev)
-{
-       int ret;
-       ret = adis16209_spi_write_reg_8(dev,
+       ret = adis16209_spi_write_reg_8(indio_dev,
                        ADIS16209_GLOB_CMD,
                        ADIS16209_GLOB_CMD_SW_RESET);
        if (ret)
-               dev_err(dev, "problem resetting device");
+               dev_err(&indio_dev->dev, "problem resetting device");
 
        return ret;
 }
@@ -275,23 +159,25 @@ static ssize_t adis16209_write_reset(struct device *dev,
                struct device_attribute *attr,
                const char *buf, size_t len)
 {
+       struct iio_dev *indio_dev = dev_get_drvdata(dev);
+
        if (len < 1)
                return -EINVAL;
        switch (buf[0]) {
        case '1':
        case 'y':
        case 'Y':
-               return adis16209_reset(dev);
+               return adis16209_reset(indio_dev);
        }
        return -EINVAL;
 }
 
-int adis16209_set_irq(struct device *dev, bool enable)
+int adis16209_set_irq(struct iio_dev *indio_dev, bool enable)
 {
        int ret = 0;
        u16 msc;
 
-       ret = adis16209_spi_read_reg_16(dev, ADIS16209_MSC_CTRL, &msc);
+       ret = adis16209_spi_read_reg_16(indio_dev, ADIS16209_MSC_CTRL, &msc);
        if (ret)
                goto error_ret;
 
@@ -302,160 +188,267 @@ int adis16209_set_irq(struct device *dev, bool enable)
        else
                msc &= ~ADIS16209_MSC_CTRL_DATA_RDY_EN;
 
-       ret = adis16209_spi_write_reg_16(dev, ADIS16209_MSC_CTRL, msc);
+       ret = adis16209_spi_write_reg_16(indio_dev, ADIS16209_MSC_CTRL, msc);
 
 error_ret:
        return ret;
 }
 
-static int adis16209_check_status(struct device *dev)
+static int adis16209_check_status(struct iio_dev *indio_dev)
 {
        u16 status;
        int ret;
 
-       ret = adis16209_spi_read_reg_16(dev, ADIS16209_DIAG_STAT, &status);
+       ret = adis16209_spi_read_reg_16(indio_dev,
+                                       ADIS16209_DIAG_STAT, &status);
        if (ret < 0) {
-               dev_err(dev, "Reading status failed\n");
+               dev_err(&indio_dev->dev, "Reading status failed\n");
                goto error_ret;
        }
        ret = status & 0x1F;
 
        if (status & ADIS16209_DIAG_STAT_SELFTEST_FAIL)
-               dev_err(dev, "Self test failure\n");
+               dev_err(&indio_dev->dev, "Self test failure\n");
        if (status & ADIS16209_DIAG_STAT_SPI_FAIL)
-               dev_err(dev, "SPI failure\n");
+               dev_err(&indio_dev->dev, "SPI failure\n");
        if (status & ADIS16209_DIAG_STAT_FLASH_UPT)
-               dev_err(dev, "Flash update failed\n");
+               dev_err(&indio_dev->dev, "Flash update failed\n");
        if (status & ADIS16209_DIAG_STAT_POWER_HIGH)
-               dev_err(dev, "Power supply above 3.625V\n");
+               dev_err(&indio_dev->dev, "Power supply above 3.625V\n");
        if (status & ADIS16209_DIAG_STAT_POWER_LOW)
-               dev_err(dev, "Power supply below 3.15V\n");
+               dev_err(&indio_dev->dev, "Power supply below 3.15V\n");
 
 error_ret:
        return ret;
 }
 
-static int adis16209_self_test(struct device *dev)
+static int adis16209_self_test(struct iio_dev *indio_dev)
 {
        int ret;
-       ret = adis16209_spi_write_reg_16(dev,
+       ret = adis16209_spi_write_reg_16(indio_dev,
                        ADIS16209_MSC_CTRL,
                        ADIS16209_MSC_CTRL_SELF_TEST_EN);
        if (ret) {
-               dev_err(dev, "problem starting self test");
+               dev_err(&indio_dev->dev, "problem starting self test");
                goto err_ret;
        }
 
-       adis16209_check_status(dev);
+       adis16209_check_status(indio_dev);
 
 err_ret:
        return ret;
 }
 
-static int adis16209_initial_setup(struct adis16209_state *st)
+static int adis16209_initial_setup(struct iio_dev *indio_dev)
 {
        int ret;
-       struct device *dev = &st->indio_dev->dev;
 
        /* Disable IRQ */
-       ret = adis16209_set_irq(dev, false);
+       ret = adis16209_set_irq(indio_dev, false);
        if (ret) {
-               dev_err(dev, "disable irq failed");
+               dev_err(&indio_dev->dev, "disable irq failed");
                goto err_ret;
        }
 
        /* Do self test */
-       ret = adis16209_self_test(dev);
+       ret = adis16209_self_test(indio_dev);
        if (ret) {
-               dev_err(dev, "self test failure");
+               dev_err(&indio_dev->dev, "self test failure");
                goto err_ret;
        }
 
        /* Read status register to check the result */
-       ret = adis16209_check_status(dev);
+       ret = adis16209_check_status(indio_dev);
        if (ret) {
-               adis16209_reset(dev);
-               dev_err(dev, "device not playing ball -> reset");
+               adis16209_reset(indio_dev);
+               dev_err(&indio_dev->dev, "device not playing ball -> reset");
                msleep(ADIS16209_STARTUP_DELAY);
-               ret = adis16209_check_status(dev);
+               ret = adis16209_check_status(indio_dev);
                if (ret) {
-                       dev_err(dev, "giving up");
+                       dev_err(&indio_dev->dev, "giving up");
                        goto err_ret;
                }
        }
 
-       printk(KERN_INFO DRIVER_NAME ": at CS%d (irq %d)\n",
-                       st->us->chip_select, st->us->irq);
-
 err_ret:
        return ret;
 }
 
-static IIO_DEV_ATTR_IN_NAMED_RAW(0, supply, adis16209_read_14bit_unsigned,
-               ADIS16209_SUPPLY_OUT);
-static IIO_CONST_ATTR_IN_NAMED_SCALE(0, supply, "0.30518");
-static IIO_DEV_ATTR_IN_RAW(1, adis16209_read_12bit_unsigned,
-               ADIS16209_AUX_ADC);
-static IIO_CONST_ATTR(in1_scale, "0.6105");
-
-static IIO_DEV_ATTR_ACCEL_X(adis16209_read_14bit_signed,
-               ADIS16209_XACCL_OUT);
-static IIO_DEV_ATTR_ACCEL_Y(adis16209_read_14bit_signed,
-               ADIS16209_YACCL_OUT);
-static IIO_DEV_ATTR_ACCEL_X_CALIBBIAS(S_IWUSR | S_IRUGO,
-               adis16209_read_14bit_signed,
-               adis16209_write_16bit,
-               ADIS16209_XACCL_NULL);
-static IIO_DEV_ATTR_ACCEL_Y_CALIBBIAS(S_IWUSR | S_IRUGO,
-               adis16209_read_14bit_signed,
-               adis16209_write_16bit,
-               ADIS16209_YACCL_NULL);
-static IIO_CONST_ATTR_ACCEL_SCALE("0.002394195531");
-
-static IIO_DEV_ATTR_INCLI_X(adis16209_read_14bit_signed,
-               ADIS16209_XINCL_OUT);
-static IIO_DEV_ATTR_INCLI_Y(adis16209_read_14bit_signed,
-               ADIS16209_YINCL_OUT);
-static IIO_CONST_ATTR(incli_scale, "0.00043633231");
-
-static IIO_DEVICE_ATTR(rot_raw, S_IRUGO, adis16209_read_14bit_signed,
-                      NULL, ADIS16209_ROT_OUT);
-
-static IIO_DEV_ATTR_TEMP_RAW(adis16209_read_temp);
-static IIO_CONST_ATTR_TEMP_OFFSET("25");
-static IIO_CONST_ATTR_TEMP_SCALE("-0.47");
+enum adis16209_chan {
+       in_supply,
+       temp,
+       accel_x,
+       accel_y,
+       incli_x,
+       incli_y,
+       in_aux,
+       rot,
+};
 
-static IIO_DEVICE_ATTR(reset, S_IWUSR, NULL, adis16209_write_reset, 0);
+static const u8 adis16209_addresses[8][2] = {
+       [in_supply] = { ADIS16209_SUPPLY_OUT },
+       [in_aux] = { ADIS16209_AUX_ADC },
+       [accel_x] = { ADIS16209_XACCL_OUT, ADIS16209_XACCL_NULL },
+       [accel_y] = { ADIS16209_YACCL_OUT, ADIS16209_YACCL_NULL },
+       [incli_x] = { ADIS16209_XINCL_OUT, ADIS16209_XINCL_NULL },
+       [incli_y] = { ADIS16209_YINCL_OUT, ADIS16209_YINCL_NULL },
+       [rot] = { ADIS16209_ROT_OUT },
+       [temp] = { ADIS16209_TEMP_OUT },
+};
+
+static int adis16209_write_raw(struct iio_dev *indio_dev,
+                              struct iio_chan_spec const *chan,
+                              int val,
+                              int val2,
+                              long mask)
+{
+       int bits;
+       s16 val16;
+       u8 addr;
+       switch (mask) {
+       case (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE):
+               switch (chan->type) {
+               case IIO_ACCEL:
+               case IIO_INCLI:
+                       bits = 14;
+                       break;
+               default:
+                       return -EINVAL;
+               };
+               val16 = val & ((1 << bits) - 1);
+               addr = adis16209_addresses[chan->address][1];
+               return adis16209_spi_write_reg_16(indio_dev, addr, val16);
+       }
+       return -EINVAL;
+}
 
-static IIO_CONST_ATTR_NAME("adis16209");
+static int adis16209_read_raw(struct iio_dev *indio_dev,
+                             struct iio_chan_spec const *chan,
+                             int *val, int *val2,
+                             long mask)
+{
+       int ret;
+       int bits;
+       u8 addr;
+       s16 val16;
+
+       switch (mask) {
+       case 0:
+               mutex_lock(&indio_dev->mlock);
+               addr = adis16209_addresses[chan->address][0];
+               ret = adis16209_spi_read_reg_16(indio_dev, addr, &val16);
+               if (ret)
+                       return ret;
 
-static struct attribute *adis16209_event_attributes[] = {
-       NULL
-};
+               if (val16 & ADIS16209_ERROR_ACTIVE) {
+                       ret = adis16209_check_status(indio_dev);
+                       if (ret)
+                               return ret;
+               }
+               val16 = val16 & ((1 << chan->scan_type.realbits) - 1);
+               if (chan->scan_type.sign == 's')
+                       val16 = (s16)(val16 <<
+                                     (16 - chan->scan_type.realbits)) >>
+                               (16 - chan->scan_type.realbits);
+               *val = val16;
+               mutex_unlock(&indio_dev->mlock);
+               return IIO_VAL_INT;
+       case (1 << IIO_CHAN_INFO_SCALE_SEPARATE):
+       case (1 << IIO_CHAN_INFO_SCALE_SHARED):
+               switch (chan->type) {
+               case IIO_IN:
+                       *val = 0;
+                       if (chan->channel == 0)
+                               *val2 = 305180;
+                       else
+                               *val2 = 610500;
+                       return IIO_VAL_INT_PLUS_MICRO;
+               case IIO_TEMP:
+                       *val = 0;
+                       *val2 = -470000;
+                       return IIO_VAL_INT_PLUS_MICRO;
+               case IIO_ACCEL:
+                       *val = 0;
+                       *val2 = 2394;
+                       return IIO_VAL_INT_PLUS_MICRO;
+               case IIO_INCLI:
+                       *val = 0;
+                       *val2 = 436;
+                       return IIO_VAL_INT_PLUS_MICRO;
+               default:
+                       return -EINVAL;
+               }
+               break;
+       case (1 << IIO_CHAN_INFO_OFFSET_SEPARATE):
+               *val = 25;
+               return IIO_VAL_INT;
+       case (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE):
+               switch (chan->type) {
+               case IIO_ACCEL:
+                       bits = 14;
+                       break;
+               default:
+                       return -EINVAL;
+               };
+               mutex_lock(&indio_dev->mlock);
+               addr = adis16209_addresses[chan->address][1];
+               ret = adis16209_spi_read_reg_16(indio_dev, addr, &val16);
+               if (ret) {
+                       mutex_unlock(&indio_dev->mlock);
+                       return ret;
+               }
+               val16 &= (1 << bits) - 1;
+               val16 = (s16)(val16 << (16 - bits)) >> (16 - bits);
+               *val = val16;
+               mutex_unlock(&indio_dev->mlock);
+               return IIO_VAL_INT;
+       }
+       return -EINVAL;
+}
 
-static struct attribute_group adis16209_event_attribute_group = {
-       .attrs = adis16209_event_attributes,
+static struct iio_chan_spec adis16209_channels[] = {
+       IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 0, 0,
+                (1 << IIO_CHAN_INFO_SCALE_SEPARATE),
+                in_supply, ADIS16209_SCAN_SUPPLY,
+                IIO_ST('u', 14, 16, 0), 0),
+       IIO_CHAN(IIO_TEMP, 0, 1, 0, NULL, 0, 0,
+                (1 << IIO_CHAN_INFO_SCALE_SEPARATE) |
+                (1 << IIO_CHAN_INFO_OFFSET_SEPARATE),
+                temp, ADIS16209_SCAN_TEMP,
+                IIO_ST('u', 12, 16, 0), 0),
+       IIO_CHAN(IIO_ACCEL, 1, 0, 0, NULL, 0, IIO_MOD_X,
+                (1 << IIO_CHAN_INFO_SCALE_SHARED) |
+                (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE),
+                accel_x, ADIS16209_SCAN_ACC_X,
+                IIO_ST('s', 14, 16, 0), 0),
+       IIO_CHAN(IIO_ACCEL, 1, 0, 0, NULL, 0, IIO_MOD_Y,
+                (1 << IIO_CHAN_INFO_SCALE_SHARED) |
+                (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE),
+                accel_y, ADIS16209_SCAN_ACC_Y,
+                IIO_ST('s', 14, 16, 0), 0),
+       IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 1, 0,
+                (1 << IIO_CHAN_INFO_SCALE_SEPARATE),
+                in_aux, ADIS16209_SCAN_AUX_ADC,
+                IIO_ST('u', 12, 16, 0), 0),
+       IIO_CHAN(IIO_INCLI, 0, 1, 0, NULL, 0, IIO_MOD_X,
+                (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                incli_x, ADIS16209_SCAN_INCLI_X,
+                IIO_ST('s', 14, 16, 0), 0),
+       IIO_CHAN(IIO_INCLI, 0, 1, 0, NULL, 0, IIO_MOD_Y,
+                (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                incli_y, ADIS16209_SCAN_INCLI_Y,
+                IIO_ST('s', 14, 16, 0), 0),
+       IIO_CHAN(IIO_ROT, 0, 1, 0, NULL, 0, IIO_MOD_X,
+                   0,
+                   rot, ADIS16209_SCAN_ROT,
+                   IIO_ST('s', 14, 16, 0), 0),
+       IIO_CHAN_SOFT_TIMESTAMP(8)
 };
 
+static IIO_DEVICE_ATTR(reset, S_IWUSR, NULL, adis16209_write_reset, 0);
+
 static struct attribute *adis16209_attributes[] = {
-       &iio_dev_attr_in0_supply_raw.dev_attr.attr,
-       &iio_const_attr_in0_supply_scale.dev_attr.attr,
-       &iio_dev_attr_temp_raw.dev_attr.attr,
-       &iio_const_attr_temp_offset.dev_attr.attr,
-       &iio_const_attr_temp_scale.dev_attr.attr,
        &iio_dev_attr_reset.dev_attr.attr,
-       &iio_const_attr_name.dev_attr.attr,
-       &iio_dev_attr_in1_raw.dev_attr.attr,
-       &iio_const_attr_in1_scale.dev_attr.attr,
-       &iio_dev_attr_accel_x_raw.dev_attr.attr,
-       &iio_dev_attr_accel_y_raw.dev_attr.attr,
-       &iio_dev_attr_accel_x_calibbias.dev_attr.attr,
-       &iio_dev_attr_accel_y_calibbias.dev_attr.attr,
-       &iio_const_attr_accel_scale.dev_attr.attr,
-       &iio_dev_attr_incli_x_raw.dev_attr.attr,
-       &iio_dev_attr_incli_y_raw.dev_attr.attr,
-       &iio_const_attr_incli_scale.dev_attr.attr,
-       &iio_dev_attr_rot_raw.dev_attr.attr,
        NULL
 };
 
@@ -463,6 +456,13 @@ static const struct attribute_group adis16209_attribute_group = {
        .attrs = adis16209_attributes,
 };
 
+static const struct iio_info adis16209_info = {
+       .attrs = &adis16209_attribute_group,
+       .read_raw = &adis16209_read_raw,
+       .write_raw = &adis16209_write_raw,
+       .driver_module = THIS_MODULE,
+};
+
 static int __devinit adis16209_probe(struct spi_device *spi)
 {
        int ret, regdone = 0;
@@ -488,18 +488,18 @@ static int __devinit adis16209_probe(struct spi_device *spi)
        st->us = spi;
        mutex_init(&st->buf_lock);
        /* setup the industrialio driver allocated elements */
-       st->indio_dev = iio_allocate_device();
+       st->indio_dev = iio_allocate_device(0);
        if (st->indio_dev == NULL) {
                ret = -ENOMEM;
                goto error_free_tx;
        }
 
+       st->indio_dev->name = spi->dev.driver->name;
        st->indio_dev->dev.parent = &spi->dev;
-       st->indio_dev->num_interrupt_lines = 1;
-       st->indio_dev->event_attrs = &adis16209_event_attribute_group;
-       st->indio_dev->attrs = &adis16209_attribute_group;
+       st->indio_dev->info = &adis16209_info;
+       st->indio_dev->channels = adis16209_channels;
+       st->indio_dev->num_channels = ARRAY_SIZE(adis16209_channels);
        st->indio_dev->dev_data = (void *)(st);
-       st->indio_dev->driver_module = THIS_MODULE;
        st->indio_dev->modes = INDIO_DIRECT_MODE;
 
        ret = adis16209_configure_ring(st->indio_dev);
@@ -511,37 +511,28 @@ static int __devinit adis16209_probe(struct spi_device *spi)
                goto error_unreg_ring_funcs;
        regdone = 1;
 
-       ret = iio_ring_buffer_register(st->indio_dev->ring, 0);
+       ret = iio_ring_buffer_register_ex(st->indio_dev->ring, 0,
+                                         adis16209_channels,
+                                         ARRAY_SIZE(adis16209_channels));
        if (ret) {
                printk(KERN_ERR "failed to initialize the ring\n");
                goto error_unreg_ring_funcs;
        }
 
        if (spi->irq) {
-               ret = iio_register_interrupt_line(spi->irq,
-                               st->indio_dev,
-                               0,
-                               IRQF_TRIGGER_RISING,
-                               "adis16209");
-               if (ret)
-                       goto error_uninitialize_ring;
-
                ret = adis16209_probe_trigger(st->indio_dev);
                if (ret)
-                       goto error_unregister_line;
+                       goto error_uninitialize_ring;
        }
 
        /* Get the device into a sane initial state */
-       ret = adis16209_initial_setup(st);
+       ret = adis16209_initial_setup(st->indio_dev);
        if (ret)
                goto error_remove_trigger;
        return 0;
 
 error_remove_trigger:
        adis16209_remove_trigger(st->indio_dev);
-error_unregister_line:
-       if (spi->irq)
-               iio_unregister_interrupt_line(st->indio_dev, 0);
 error_uninitialize_ring:
        iio_ring_buffer_unregister(st->indio_dev->ring);
 error_unreg_ring_funcs:
@@ -569,9 +560,6 @@ static int adis16209_remove(struct spi_device *spi)
        flush_scheduled_work();
 
        adis16209_remove_trigger(indio_dev);
-       if (spi->irq)
-               iio_unregister_interrupt_line(indio_dev, 0);
-
        iio_ring_buffer_unregister(indio_dev->ring);
        iio_device_unregister(indio_dev);
        adis16209_unconfigure_ring(indio_dev);
index 8eba0af98ed5ef0f2cd27ca3cce9586144bdcc98..390908b3f02f583070d7da605e305d733b45c95b 100644 (file)
 #include "../trigger.h"
 #include "adis16209.h"
 
-static IIO_SCAN_EL_C(in_supply, ADIS16209_SCAN_SUPPLY,
-                    ADIS16209_SUPPLY_OUT, NULL);
-static IIO_CONST_ATTR_SCAN_EL_TYPE(in_supply, u, 14, 16)
-static IIO_SCAN_EL_C(accel_x, ADIS16209_SCAN_ACC_X, ADIS16209_XACCL_OUT, NULL);
-static IIO_SCAN_EL_C(accel_y, ADIS16209_SCAN_ACC_Y, ADIS16209_YACCL_OUT, NULL);
-static IIO_CONST_ATTR_SCAN_EL_TYPE(accel, s, 14, 16);
-static IIO_SCAN_EL_C(in0, ADIS16209_SCAN_AUX_ADC, ADIS16209_AUX_ADC, NULL);
-static IIO_CONST_ATTR_SCAN_EL_TYPE(in0, u, 12, 16);
-static IIO_SCAN_EL_C(temp, ADIS16209_SCAN_TEMP, ADIS16209_TEMP_OUT, NULL);
-static IIO_CONST_ATTR_SCAN_EL_TYPE(temp, u, 12, 16);
-static IIO_SCAN_EL_C(incli_x, ADIS16209_SCAN_INCLI_X,
-                    ADIS16209_XINCL_OUT, NULL);
-static IIO_SCAN_EL_C(incli_y, ADIS16209_SCAN_INCLI_Y,
-                    ADIS16209_YINCL_OUT, NULL);
-static IIO_CONST_ATTR_SCAN_EL_TYPE(incli, s, 14, 16);
-static IIO_SCAN_EL_C(rot, ADIS16209_SCAN_ROT, ADIS16209_ROT_OUT, NULL);
-static IIO_CONST_ATTR_SCAN_EL_TYPE(rot, s, 14, 16);
-static IIO_SCAN_EL_TIMESTAMP(8);
-static IIO_CONST_ATTR_SCAN_EL_TYPE(timestamp, s, 64, 64);
-
-static struct attribute *adis16209_scan_el_attrs[] = {
-       &iio_scan_el_in_supply.dev_attr.attr,
-       &iio_const_attr_in_supply_index.dev_attr.attr,
-       &iio_const_attr_in_supply_type.dev_attr.attr,
-       &iio_scan_el_accel_x.dev_attr.attr,
-       &iio_const_attr_accel_x_index.dev_attr.attr,
-       &iio_scan_el_accel_y.dev_attr.attr,
-       &iio_const_attr_accel_y_index.dev_attr.attr,
-       &iio_const_attr_accel_type.dev_attr.attr,
-       &iio_scan_el_in0.dev_attr.attr,
-       &iio_const_attr_in0_index.dev_attr.attr,
-       &iio_const_attr_in0_type.dev_attr.attr,
-       &iio_scan_el_temp.dev_attr.attr,
-       &iio_const_attr_temp_index.dev_attr.attr,
-       &iio_const_attr_temp_type.dev_attr.attr,
-       &iio_scan_el_incli_x.dev_attr.attr,
-       &iio_const_attr_incli_x_index.dev_attr.attr,
-       &iio_scan_el_incli_y.dev_attr.attr,
-       &iio_const_attr_incli_y_index.dev_attr.attr,
-       &iio_const_attr_incli_type.dev_attr.attr,
-       &iio_scan_el_rot.dev_attr.attr,
-       &iio_const_attr_rot_index.dev_attr.attr,
-       &iio_const_attr_rot_type.dev_attr.attr,
-       &iio_scan_el_timestamp.dev_attr.attr,
-       &iio_const_attr_timestamp_index.dev_attr.attr,
-       &iio_const_attr_timestamp_type.dev_attr.attr,
-       NULL,
-};
-
-static struct attribute_group adis16209_scan_el_group = {
-       .attrs = adis16209_scan_el_attrs,
-       .name = "scan_elements",
-};
-
-/**
- * adis16209_poll_func_th() top half interrupt handler called by trigger
- * @private_data:      iio_dev
- **/
-static void adis16209_poll_func_th(struct iio_dev *indio_dev, s64 time)
-{
-       struct adis16209_state *st = iio_dev_get_devdata(indio_dev);
-       st->last_timestamp = time;
-       schedule_work(&st->work_trigger_to_ring);
-}
-
 /**
  * adis16209_read_ring_data() read data registers which will be placed into ring
  * @dev: device associated with child of actual device (iio_dev or iio_trig)
@@ -127,55 +62,56 @@ static int adis16209_read_ring_data(struct device *dev, u8 *rx)
 /* Whilst this makes a lot of calls to iio_sw_ring functions - it is to device
  * specific to be rolled into the core.
  */
-static void adis16209_trigger_bh_to_ring(struct work_struct *work_s)
+static irqreturn_t adis16209_trigger_handler(int irq, void *p)
 {
-       struct adis16209_state *st
-               = container_of(work_s, struct adis16209_state,
-                              work_trigger_to_ring);
-       struct iio_ring_buffer *ring = st->indio_dev->ring;
+       struct iio_poll_func *pf = p;
+       struct iio_dev *indio_dev = pf->private_data;
+       struct adis16209_state *st = iio_dev_get_devdata(indio_dev);
+       struct iio_ring_buffer *ring = indio_dev->ring;
 
        int i = 0;
        s16 *data;
-       size_t datasize = ring->access.get_bytes_per_datum(ring);
+       size_t datasize = ring->access->get_bytes_per_datum(ring);
 
        data = kmalloc(datasize , GFP_KERNEL);
        if (data == NULL) {
                dev_err(&st->us->dev, "memory alloc failed in ring bh");
-               return;
+               return -ENOMEM;
        }
 
-       if (ring->scan_count)
-               if (adis16209_read_ring_data(&st->indio_dev->dev, st->rx) >= 0)
-                       for (; i < ring->scan_count; i++)
-                               data[i] = be16_to_cpup(
-                                       (__be16 *)&(st->rx[i*2]));
+       if (ring->scan_count &&
+           adis16209_read_ring_data(&st->indio_dev->dev, st->rx) >= 0)
+               for (; i < ring->scan_count; i++)
+                       data[i] = be16_to_cpup((__be16 *)&(st->rx[i*2]));
 
        /* Guaranteed to be aligned with 8 byte boundary */
        if (ring->scan_timestamp)
-               *((s64 *)(data + ((i + 3)/4)*4)) = st->last_timestamp;
+               *((s64 *)(data + ((i + 3)/4)*4)) = pf->timestamp;
 
-       ring->access.store_to(ring,
-                             (u8 *)data,
-                             st->last_timestamp);
+       ring->access->store_to(ring, (u8 *)data, pf->timestamp);
 
        iio_trigger_notify_done(st->indio_dev->trig);
        kfree(data);
 
-       return;
+       return IRQ_HANDLED;
 }
 
 void adis16209_unconfigure_ring(struct iio_dev *indio_dev)
 {
-       kfree(indio_dev->pollfunc);
+       iio_dealloc_pollfunc(indio_dev->pollfunc);
        iio_sw_rb_free(indio_dev->ring);
 }
 
+static const struct iio_ring_setup_ops adis16209_ring_setup_ops = {
+       .preenable = &iio_sw_ring_preenable,
+       .postenable = &iio_triggered_ring_postenable,
+       .predisable = &iio_triggered_ring_predisable,
+};
+
 int adis16209_configure_ring(struct iio_dev *indio_dev)
 {
        int ret = 0;
-       struct adis16209_state *st = indio_dev->dev_data;
        struct iio_ring_buffer *ring;
-       INIT_WORK(&st->work_trigger_to_ring, adis16209_trigger_bh_to_ring);
 
        ring = iio_sw_rb_allocate(indio_dev);
        if (!ring) {
@@ -184,28 +120,33 @@ int adis16209_configure_ring(struct iio_dev *indio_dev)
        }
        indio_dev->ring = ring;
        /* Effectively select the ring buffer implementation */
-       iio_ring_sw_register_funcs(&ring->access);
+       ring->access = &ring_sw_access_funcs;
        ring->bpe = 2;
-       ring->scan_el_attrs = &adis16209_scan_el_group;
        ring->scan_timestamp = true;
-       ring->preenable = &iio_sw_ring_preenable;
-       ring->postenable = &iio_triggered_ring_postenable;
-       ring->predisable = &iio_triggered_ring_predisable;
+       ring->setup_ops = &adis16209_ring_setup_ops;
        ring->owner = THIS_MODULE;
 
        /* Set default scan mode */
-       iio_scan_mask_set(ring, iio_scan_el_in_supply.number);
-       iio_scan_mask_set(ring, iio_scan_el_rot.number);
-       iio_scan_mask_set(ring, iio_scan_el_accel_x.number);
-       iio_scan_mask_set(ring, iio_scan_el_accel_y.number);
-       iio_scan_mask_set(ring, iio_scan_el_temp.number);
-       iio_scan_mask_set(ring, iio_scan_el_in0.number);
-       iio_scan_mask_set(ring, iio_scan_el_incli_x.number);
-       iio_scan_mask_set(ring, iio_scan_el_incli_y.number);
-
-       ret = iio_alloc_pollfunc(indio_dev, NULL, &adis16209_poll_func_th);
-       if (ret)
+       iio_scan_mask_set(ring, ADIS16209_SCAN_SUPPLY);
+       iio_scan_mask_set(ring, ADIS16209_SCAN_ACC_X);
+       iio_scan_mask_set(ring, ADIS16209_SCAN_ACC_Y);
+       iio_scan_mask_set(ring, ADIS16209_SCAN_AUX_ADC);
+       iio_scan_mask_set(ring, ADIS16209_SCAN_TEMP);
+       iio_scan_mask_set(ring, ADIS16209_SCAN_INCLI_X);
+       iio_scan_mask_set(ring, ADIS16209_SCAN_INCLI_Y);
+       iio_scan_mask_set(ring, ADIS16209_SCAN_ROT);
+
+       indio_dev->pollfunc = iio_alloc_pollfunc(&iio_pollfunc_store_time,
+                                                &adis16209_trigger_handler,
+                                                IRQF_ONESHOT,
+                                                indio_dev,
+                                                "%s_consumer%d",
+                                                indio_dev->name,
+                                                indio_dev->id);
+       if (indio_dev->pollfunc == NULL) {
+               ret = -ENOMEM;
                goto error_iio_sw_rb_free;
+       }
 
        indio_dev->modes |= INDIO_RING_TRIGGERED;
        return 0;
index d2980dc74440ce995cf32f756becfdfd908bccdd..211ee70456977bdd653948a5d20ae045bdf77c0f 100644 (file)
 /**
  * adis16209_data_rdy_trig_poll() the event handler for the data rdy trig
  **/
-static int adis16209_data_rdy_trig_poll(struct iio_dev *dev_info,
-                                      int index,
-                                      s64 timestamp,
-                                      int no_test)
+static irqreturn_t adis16209_data_rdy_trig_poll(int irq, void *trig)
 {
-       struct adis16209_state *st = iio_dev_get_devdata(dev_info);
-       struct iio_trigger *trig = st->trig;
-
-       iio_trigger_poll(trig, timestamp);
-
+       iio_trigger_poll(trig, iio_get_time_ns());
        return IRQ_HANDLED;
 }
 
-IIO_EVENT_SH(data_rdy_trig, &adis16209_data_rdy_trig_poll);
-
-static IIO_TRIGGER_NAME_ATTR;
-
-static struct attribute *adis16209_trigger_attrs[] = {
-       &dev_attr_name.attr,
-       NULL,
-};
-
-static const struct attribute_group adis16209_trigger_attr_group = {
-       .attrs = adis16209_trigger_attrs,
-};
-
 /**
  * adis16209_data_rdy_trigger_set_state() set datardy interrupt state
  **/
@@ -49,31 +29,9 @@ static int adis16209_data_rdy_trigger_set_state(struct iio_trigger *trig,
 {
        struct adis16209_state *st = trig->private_data;
        struct iio_dev *indio_dev = st->indio_dev;
-       int ret = 0;
 
        dev_dbg(&indio_dev->dev, "%s (%d)\n", __func__, state);
-       ret = adis16209_set_irq(&st->indio_dev->dev, state);
-       if (state == false) {
-               iio_remove_event_from_list(&iio_event_data_rdy_trig,
-                                          &indio_dev->interrupts[0]
-                                          ->ev_list);
-               flush_scheduled_work();
-       } else {
-               iio_add_event_to_list(&iio_event_data_rdy_trig,
-                                     &indio_dev->interrupts[0]->ev_list);
-       }
-       return ret;
-}
-
-/**
- * adis16209_trig_try_reen() try renabling irq for data rdy trigger
- * @trig:      the datardy trigger
- **/
-static int adis16209_trig_try_reen(struct iio_trigger *trig)
-{
-       struct adis16209_state *st = trig->private_data;
-       enable_irq(st->us->irq);
-       return 0;
+       return adis16209_set_irq(st->indio_dev, state);
 }
 
 int adis16209_probe_trigger(struct iio_dev *indio_dev)
@@ -81,34 +39,37 @@ int adis16209_probe_trigger(struct iio_dev *indio_dev)
        int ret;
        struct adis16209_state *st = indio_dev->dev_data;
 
-       st->trig = iio_allocate_trigger();
-       st->trig->name = kasprintf(GFP_KERNEL,
-                                  "adis16209-dev%d",
-                                  indio_dev->id);
-       if (!st->trig->name) {
+       st->trig = iio_allocate_trigger("adis16209-dev%d", indio_dev->id);
+       if (st->trig == NULL) {
                ret = -ENOMEM;
-               goto error_free_trig;
+               goto error_ret;
        }
+
+       ret = request_irq(st->us->irq,
+                         adis16209_data_rdy_trig_poll,
+                         IRQF_TRIGGER_RISING,
+                         "adis16209",
+                         st->trig);
+       if (ret)
+               goto error_free_trig;
        st->trig->dev.parent = &st->us->dev;
        st->trig->owner = THIS_MODULE;
        st->trig->private_data = st;
        st->trig->set_trigger_state = &adis16209_data_rdy_trigger_set_state;
-       st->trig->try_reenable = &adis16209_trig_try_reen;
-       st->trig->control_attrs = &adis16209_trigger_attr_group;
        ret = iio_trigger_register(st->trig);
 
        /* select default trigger */
        indio_dev->trig = st->trig;
        if (ret)
-               goto error_free_trig_name;
+               goto error_free_irq;
 
        return 0;
 
-error_free_trig_name:
-       kfree(st->trig->name);
+error_free_irq:
+       free_irq(st->us->irq, st->trig);
 error_free_trig:
        iio_free_trigger(st->trig);
-
+error_ret:
        return ret;
 }
 
@@ -117,6 +78,6 @@ void adis16209_remove_trigger(struct iio_dev *indio_dev)
        struct adis16209_state *state = indio_dev->dev_data;
 
        iio_trigger_unregister(state->trig);
-       kfree(state->trig->name);
+       free_irq(state->us->irq, state->trig);
        iio_free_trigger(state->trig);
 }
index 1c1e98aee2d9fdd78aeabeab1d604f344a092367..605a75ea39967554af85208305b3b34dba908f4c 100644 (file)
@@ -521,8 +521,6 @@ static IIO_DEV_ATTR_CAPTURE_COUNT(S_IWUSR | S_IRUGO,
 
 static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("100200");
 
-static IIO_CONST_ATTR_NAME("adis16220");
-
 static struct attribute *adis16220_attributes[] = {
        &iio_dev_attr_in0_supply_raw.dev_attr.attr,
        &iio_const_attr_in0_supply_scale.dev_attr.attr,
@@ -539,7 +537,6 @@ static struct attribute *adis16220_attributes[] = {
        &iio_dev_attr_reset.dev_attr.attr,
        &iio_dev_attr_capture.dev_attr.attr,
        &iio_dev_attr_capture_count.dev_attr.attr,
-       &iio_const_attr_name.dev_attr.attr,
        NULL
 };
 
@@ -547,6 +544,10 @@ static const struct attribute_group adis16220_attribute_group = {
        .attrs = adis16220_attributes,
 };
 
+static const struct iio_info adis16220_info = {
+       .attrs = &adis16220_attribute_group,
+       .driver_module = THIS_MODULE,
+};
 static int __devinit adis16220_probe(struct spi_device *spi)
 {
        int ret, regdone = 0;
@@ -572,16 +573,16 @@ static int __devinit adis16220_probe(struct spi_device *spi)
        st->us = spi;
        mutex_init(&st->buf_lock);
        /* setup the industrialio driver allocated elements */
-       st->indio_dev = iio_allocate_device();
+       st->indio_dev = iio_allocate_device(0);
        if (st->indio_dev == NULL) {
                ret = -ENOMEM;
                goto error_free_tx;
        }
 
+       st->indio_dev->name = spi->dev.driver->name;
        st->indio_dev->dev.parent = &spi->dev;
-       st->indio_dev->attrs = &adis16220_attribute_group;
+       st->indio_dev->info = &adis16220_info;
        st->indio_dev->dev_data = (void *)(st);
-       st->indio_dev->driver_module = THIS_MODULE;
        st->indio_dev->modes = INDIO_DIRECT_MODE;
 
        ret = iio_device_register(st->indio_dev);
index 76a45797b9dd375fb45e01a97229d4391e6895c7..162b1f468a1acad06f4aaf3ced7259925515d521 100644 (file)
 /**
  * struct adis16240_state - device instance specific data
  * @us:                        actual spi_device
- * @work_trigger_to_ring: bh for triggered event handling
- * @inter:             used to check if new interrupt has been triggered
- * @last_timestamp:    passing timestamp from th to bh of interrupt handler
  * @indio_dev:         industrial I/O device structure
  * @trig:              data ready trigger registered with iio
  * @tx:                        transmit buffer
  **/
 struct adis16240_state {
        struct spi_device               *us;
-       struct work_struct              work_trigger_to_ring;
-       s64                             last_timestamp;
        struct iio_dev                  *indio_dev;
        struct iio_trigger              *trig;
        u8                              *tx;
@@ -146,7 +141,7 @@ struct adis16240_state {
        struct mutex                    buf_lock;
 };
 
-int adis16240_set_irq(struct device *dev, bool enable);
+int adis16240_set_irq(struct iio_dev *indio_dev, bool enable);
 
 #ifdef CONFIG_IIO_RING_BUFFER
 /* At the moment triggers are only used for ring buffer
index d11d164207eee3b222500c3ae05f3e1e6fb4ec3f..ac6038557b0d448a5931482f5cba22472a3f3d1f 100644 (file)
 
 #define DRIVER_NAME            "adis16240"
 
-static int adis16240_check_status(struct device *dev);
+static int adis16240_check_status(struct iio_dev *indio_dev);
 
 /**
  * adis16240_spi_write_reg_8() - write single byte to a register
- * @dev: device associated with child of actual device (iio_dev or iio_trig)
+ * @indio_dev: iio_dev associated with device
  * @reg_address: the address of the register to be written
  * @val: the value to write
  **/
-static int adis16240_spi_write_reg_8(struct device *dev,
-               u8 reg_address,
-               u8 val)
+static int adis16240_spi_write_reg_8(struct iio_dev *indio_dev,
+                                    u8 reg_address,
+                                    u8 val)
 {
        int ret;
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
        struct adis16240_state *st = iio_dev_get_devdata(indio_dev);
 
        mutex_lock(&st->buf_lock);
@@ -56,18 +55,17 @@ static int adis16240_spi_write_reg_8(struct device *dev,
 
 /**
  * adis16240_spi_write_reg_16() - write 2 bytes to a pair of registers
- * @dev: device associated with child of actual device (iio_dev or iio_trig)
+ * @indio_dev: iio_dev for this device
  * @reg_address: the address of the lower of the two registers. Second register
  *               is assumed to have address one greater.
  * @val: value to be written
  **/
-static int adis16240_spi_write_reg_16(struct device *dev,
-               u8 lower_reg_address,
-               u16 value)
+static int adis16240_spi_write_reg_16(struct iio_dev *indio_dev,
+                                     u8 lower_reg_address,
+                                     u16 value)
 {
        int ret;
        struct spi_message msg;
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
        struct adis16240_state *st = iio_dev_get_devdata(indio_dev);
        struct spi_transfer xfers[] = {
                {
@@ -80,7 +78,6 @@ static int adis16240_spi_write_reg_16(struct device *dev,
                        .tx_buf = st->tx + 2,
                        .bits_per_word = 8,
                        .len = 2,
-                       .cs_change = 1,
                        .delay_usecs = 35,
                },
        };
@@ -102,17 +99,16 @@ static int adis16240_spi_write_reg_16(struct device *dev,
 
 /**
  * adis16240_spi_read_reg_16() - read 2 bytes from a 16-bit register
- * @dev: device associated with child of actual device (iio_dev or iio_trig)
+ * @indio_dev: iio_dev for this device
  * @reg_address: the address of the lower of the two registers. Second register
  *               is assumed to have address one greater.
  * @val: somewhere to pass back the value read
  **/
-static int adis16240_spi_read_reg_16(struct device *dev,
+static int adis16240_spi_read_reg_16(struct iio_dev *indio_dev,
                u8 lower_reg_address,
                u16 *val)
 {
        struct spi_message msg;
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
        struct adis16240_state *st = iio_dev_get_devdata(indio_dev);
        int ret;
        struct spi_transfer xfers[] = {
@@ -159,61 +155,30 @@ static ssize_t adis16240_spi_read_signed(struct device *dev,
                char *buf,
                unsigned bits)
 {
+       struct iio_dev *indio_dev = dev_get_drvdata(dev);
        int ret;
        s16 val = 0;
        unsigned shift = 16 - bits;
        struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
 
-       ret = adis16240_spi_read_reg_16(dev, this_attr->address, (u16 *)&val);
+       ret = adis16240_spi_read_reg_16(indio_dev,
+                                       this_attr->address, (u16 *)&val);
        if (ret)
                return ret;
 
        if (val & ADIS16240_ERROR_ACTIVE)
-               adis16240_check_status(dev);
+               adis16240_check_status(indio_dev);
 
        val = ((s16)(val << shift) >> shift);
        return sprintf(buf, "%d\n", val);
 }
 
-static ssize_t adis16240_read_10bit_unsigned(struct device *dev,
-               struct device_attribute *attr,
-               char *buf)
-{
-       int ret;
-       u16 val = 0;
-       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-
-       ret = adis16240_spi_read_reg_16(dev, this_attr->address, &val);
-       if (ret)
-               return ret;
-
-       if (val & ADIS16240_ERROR_ACTIVE)
-               adis16240_check_status(dev);
-
-       return sprintf(buf, "%u\n", val & 0x03FF);
-}
-
-static ssize_t adis16240_read_10bit_signed(struct device *dev,
-               struct device_attribute *attr,
-               char *buf)
-{
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
-       ssize_t ret;
-
-       /* Take the iio_dev status lock */
-       mutex_lock(&indio_dev->mlock);
-       ret =  adis16240_spi_read_signed(dev, attr, buf, 10);
-       mutex_unlock(&indio_dev->mlock);
-
-       return ret;
-}
-
 static ssize_t adis16240_read_12bit_signed(struct device *dev,
                struct device_attribute *attr,
                char *buf)
 {
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
        ssize_t ret;
+       struct iio_dev *indio_dev = dev_get_drvdata(dev);
 
        /* Take the iio_dev status lock */
        mutex_lock(&indio_dev->mlock);
@@ -223,32 +188,14 @@ static ssize_t adis16240_read_12bit_signed(struct device *dev,
        return ret;
 }
 
-static ssize_t adis16240_write_16bit(struct device *dev,
-               struct device_attribute *attr,
-               const char *buf,
-               size_t len)
+static int adis16240_reset(struct iio_dev *indio_dev)
 {
-       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
        int ret;
-       long val;
-
-       ret = strict_strtol(buf, 10, &val);
-       if (ret)
-               goto error_ret;
-       ret = adis16240_spi_write_reg_16(dev, this_attr->address, val);
-
-error_ret:
-       return ret ? ret : len;
-}
-
-static int adis16240_reset(struct device *dev)
-{
-       int ret;
-       ret = adis16240_spi_write_reg_8(dev,
+       ret = adis16240_spi_write_reg_8(indio_dev,
                        ADIS16240_GLOB_CMD,
                        ADIS16240_GLOB_CMD_SW_RESET);
        if (ret)
-               dev_err(dev, "problem resetting device");
+               dev_err(&indio_dev->dev, "problem resetting device");
 
        return ret;
 }
@@ -257,23 +204,26 @@ static ssize_t adis16240_write_reset(struct device *dev,
                struct device_attribute *attr,
                const char *buf, size_t len)
 {
+       struct iio_dev *indio_dev = dev_get_drvdata(dev);
+
        if (len < 1)
                return -EINVAL;
        switch (buf[0]) {
        case '1':
        case 'y':
        case 'Y':
-               return adis16240_reset(dev);
+               return adis16240_reset(indio_dev);
        }
        return -EINVAL;
 }
 
-int adis16240_set_irq(struct device *dev, bool enable)
+int adis16240_set_irq(struct iio_dev *indio_dev, bool enable)
 {
        int ret = 0;
        u16 msc;
 
-       ret = adis16240_spi_read_reg_16(dev, ADIS16240_MSC_CTRL, &msc);
+       ret = adis16240_spi_read_reg_16(indio_dev,
+                                       ADIS16240_MSC_CTRL, &msc);
        if (ret)
                goto error_ret;
 
@@ -284,37 +234,40 @@ int adis16240_set_irq(struct device *dev, bool enable)
        else
                msc &= ~ADIS16240_MSC_CTRL_DATA_RDY_EN;
 
-       ret = adis16240_spi_write_reg_16(dev, ADIS16240_MSC_CTRL, msc);
+       ret = adis16240_spi_write_reg_16(indio_dev,
+                                        ADIS16240_MSC_CTRL, msc);
 
 error_ret:
        return ret;
 }
 
-static int adis16240_self_test(struct device *dev)
+static int adis16240_self_test(struct iio_dev *indio_dev)
 {
        int ret;
-       ret = adis16240_spi_write_reg_16(dev,
+       ret = adis16240_spi_write_reg_16(indio_dev,
                        ADIS16240_MSC_CTRL,
                        ADIS16240_MSC_CTRL_SELF_TEST_EN);
        if (ret) {
-               dev_err(dev, "problem starting self test");
+               dev_err(&indio_dev->dev, "problem starting self test");
                goto err_ret;
        }
 
        msleep(ADIS16240_STARTUP_DELAY);
 
-       adis16240_check_status(dev);
+       adis16240_check_status(indio_dev);
 
 err_ret:
        return ret;
 }
 
-static int adis16240_check_status(struct device *dev)
+static int adis16240_check_status(struct iio_dev *indio_dev)
 {
        u16 status;
        int ret;
+       struct device *dev = &indio_dev->dev;
 
-       ret = adis16240_spi_read_reg_16(dev, ADIS16240_DIAG_STAT, &status);
+       ret = adis16240_spi_read_reg_16(indio_dev,
+                                       ADIS16240_DIAG_STAT, &status);
 
        if (ret < 0) {
                dev_err(dev, "Reading status failed\n");
@@ -337,122 +290,216 @@ error_ret:
        return ret;
 }
 
-static int adis16240_initial_setup(struct adis16240_state *st)
+static int adis16240_initial_setup(struct iio_dev *indio_dev)
 {
        int ret;
-       struct device *dev = &st->indio_dev->dev;
+       struct device *dev = &indio_dev->dev;
 
        /* Disable IRQ */
-       ret = adis16240_set_irq(dev, false);
+       ret = adis16240_set_irq(indio_dev, false);
        if (ret) {
                dev_err(dev, "disable irq failed");
                goto err_ret;
        }
 
        /* Do self test */
-       ret = adis16240_self_test(dev);
+       ret = adis16240_self_test(indio_dev);
        if (ret) {
                dev_err(dev, "self test failure");
                goto err_ret;
        }
 
        /* Read status register to check the result */
-       ret = adis16240_check_status(dev);
+       ret = adis16240_check_status(indio_dev);
        if (ret) {
-               adis16240_reset(dev);
+               adis16240_reset(indio_dev);
                dev_err(dev, "device not playing ball -> reset");
                msleep(ADIS16240_STARTUP_DELAY);
-               ret = adis16240_check_status(dev);
+               ret = adis16240_check_status(indio_dev);
                if (ret) {
                        dev_err(dev, "giving up");
                        goto err_ret;
                }
        }
 
-       printk(KERN_INFO DRIVER_NAME ": at CS%d (irq %d)\n",
-                       st->us->chip_select, st->us->irq);
-
 err_ret:
        return ret;
 }
 
-static IIO_DEV_ATTR_IN_NAMED_RAW(0, supply, adis16240_read_10bit_unsigned,
-               ADIS16240_SUPPLY_OUT);
-static IIO_DEV_ATTR_IN_RAW(1, adis16240_read_10bit_signed,
-               ADIS16240_AUX_ADC);
-static IIO_CONST_ATTR_IN_NAMED_SCALE(0, supply, "0.00488");
-
-static IIO_CONST_ATTR_ACCEL_SCALE("0.50406181");
-static IIO_CONST_ATTR(accel_peak_scale, "6.6292954");
-static IIO_DEV_ATTR_ACCEL_X(adis16240_read_10bit_signed,
-               ADIS16240_XACCL_OUT);
-static IIO_DEVICE_ATTR(accel_x_peak_raw, S_IRUGO,
-                      adis16240_read_10bit_signed, NULL,
-                      ADIS16240_XPEAK_OUT);
-static IIO_DEV_ATTR_ACCEL_Y(adis16240_read_10bit_signed,
-               ADIS16240_YACCL_OUT);
-static IIO_DEVICE_ATTR(accel_y_peak_raw, S_IRUGO,
-                      adis16240_read_10bit_signed, NULL,
-                      ADIS16240_YPEAK_OUT);
-static IIO_DEV_ATTR_ACCEL_Z(adis16240_read_10bit_signed,
-               ADIS16240_ZACCL_OUT);
-static IIO_DEVICE_ATTR(accel_z_peak_raw, S_IRUGO,
-                      adis16240_read_10bit_signed, NULL,
-                      ADIS16240_ZPEAK_OUT);
-
 static IIO_DEVICE_ATTR(accel_xyz_squared_peak_raw, S_IRUGO,
                       adis16240_read_12bit_signed, NULL,
                       ADIS16240_XYZPEAK_OUT);
-static IIO_DEV_ATTR_ACCEL_X_CALIBBIAS(S_IWUSR | S_IRUGO,
-               adis16240_read_10bit_signed,
-               adis16240_write_16bit,
-               ADIS16240_XACCL_OFF);
-static IIO_DEV_ATTR_ACCEL_Y_CALIBBIAS(S_IWUSR | S_IRUGO,
-               adis16240_read_10bit_signed,
-               adis16240_write_16bit,
-               ADIS16240_YACCL_OFF);
-static IIO_DEV_ATTR_ACCEL_Z_CALIBBIAS(S_IWUSR | S_IRUGO,
-               adis16240_read_10bit_signed,
-               adis16240_write_16bit,
-               ADIS16240_ZACCL_OFF);
-static IIO_DEV_ATTR_TEMP_RAW(adis16240_read_10bit_unsigned);
-static IIO_CONST_ATTR_TEMP_SCALE("0.244");
 
 static IIO_DEVICE_ATTR(reset, S_IWUSR, NULL, adis16240_write_reset, 0);
 
 static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("4096");
 
-static IIO_CONST_ATTR_NAME("adis16240");
+enum adis16240_chan {
+       in_supply,
+       in_aux,
+       accel_x,
+       accel_y,
+       accel_z,
+       temp,
+};
 
-static struct attribute *adis16240_event_attributes[] = {
-       NULL
+static const u8 adis16240_addresses[6][3] = {
+       [in_supply] = { ADIS16240_SUPPLY_OUT },
+       [in_aux] = { ADIS16240_AUX_ADC },
+       [accel_x] = { ADIS16240_XACCL_OUT, ADIS16240_XACCL_OFF,
+                     ADIS16240_XPEAK_OUT },
+       [accel_y] = { ADIS16240_YACCL_OUT, ADIS16240_YACCL_OFF,
+                     ADIS16240_YPEAK_OUT },
+       [accel_z] = { ADIS16240_ZACCL_OUT, ADIS16240_ZACCL_OFF,
+                     ADIS16240_ZPEAK_OUT },
+       [temp] = { ADIS16240_TEMP_OUT },
 };
 
-static struct attribute_group adis16240_event_attribute_group = {
-       .attrs = adis16240_event_attributes,
+static int adis16240_read_raw(struct iio_dev *indio_dev,
+                             struct iio_chan_spec const *chan,
+                             int *val, int *val2,
+                             long mask)
+{
+       int ret;
+       int bits;
+       u8 addr;
+       s16 val16;
+
+       switch (mask) {
+       case 0:
+               mutex_lock(&indio_dev->mlock);
+               addr = adis16240_addresses[chan->address][0];
+               ret = adis16240_spi_read_reg_16(indio_dev, addr, &val16);
+               if (ret)
+                       return ret;
+
+               if (val16 & ADIS16240_ERROR_ACTIVE) {
+                       ret = adis16240_check_status(indio_dev);
+                       if (ret)
+                               return ret;
+               }
+               val16 = val16 & ((1 << chan->scan_type.realbits) - 1);
+               if (chan->scan_type.sign == 's')
+                       val16 = (s16)(val16 <<
+                                     (16 - chan->scan_type.realbits)) >>
+                               (16 - chan->scan_type.realbits);
+               *val = val16;
+               mutex_unlock(&indio_dev->mlock);
+               return IIO_VAL_INT;
+       case (1 << IIO_CHAN_INFO_SCALE_SEPARATE):
+       case (1 << IIO_CHAN_INFO_SCALE_SHARED):
+               switch (chan->type) {
+               case IIO_IN:
+                       *val = 0;
+                       if (chan->channel == 0)
+                               *val2 = 4880;
+                       else
+                               return -EINVAL;
+                       return IIO_VAL_INT_PLUS_MICRO;
+               case IIO_TEMP:
+                       *val = 0;
+                       *val2 = 244000;
+                       return IIO_VAL_INT_PLUS_MICRO;
+               case IIO_ACCEL:
+                       *val = 0;
+                       *val2 = 504062;
+                       return IIO_VAL_INT_PLUS_MICRO;
+               default:
+                       return -EINVAL;
+               }
+               break;
+       case (1 << IIO_CHAN_INFO_PEAK_SCALE_SHARED):
+               *val = 6;
+               *val2 = 629295;
+               return IIO_VAL_INT_PLUS_MICRO;
+       case (1 << IIO_CHAN_INFO_OFFSET_SEPARATE):
+               *val = 25;
+               return IIO_VAL_INT;
+       case (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE):
+               bits = 10;
+               mutex_lock(&indio_dev->mlock);
+               addr = adis16240_addresses[chan->address][1];
+               ret = adis16240_spi_read_reg_16(indio_dev, addr, &val16);
+               if (ret) {
+                       mutex_unlock(&indio_dev->mlock);
+                       return ret;
+               }
+               val16 &= (1 << bits) - 1;
+               val16 = (s16)(val16 << (16 - bits)) >> (16 - bits);
+               *val = val16;
+               mutex_unlock(&indio_dev->mlock);
+               return IIO_VAL_INT;
+       case (1 << IIO_CHAN_INFO_PEAK_SEPARATE):
+               bits = 10;
+               mutex_lock(&indio_dev->mlock);
+               addr = adis16240_addresses[chan->address][2];
+               ret = adis16240_spi_read_reg_16(indio_dev, addr, &val16);
+               if (ret) {
+                       mutex_unlock(&indio_dev->mlock);
+                       return ret;
+               }
+               val16 &= (1 << bits) - 1;
+               val16 = (s16)(val16 << (16 - bits)) >> (16 - bits);
+               *val = val16;
+               mutex_unlock(&indio_dev->mlock);
+               return IIO_VAL_INT;
+       }
+       return -EINVAL;
+}
+
+static int adis16240_write_raw(struct iio_dev *indio_dev,
+                              struct iio_chan_spec const *chan,
+                              int val,
+                              int val2,
+                              long mask)
+{
+       int bits = 10;
+       s16 val16;
+       u8 addr;
+       switch (mask) {
+       case (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE):
+               val16 = val & ((1 << bits) - 1);
+               addr = adis16240_addresses[chan->address][1];
+               return adis16240_spi_write_reg_16(indio_dev, addr, val16);
+       }
+       return -EINVAL;
+}
+
+static struct iio_chan_spec adis16240_channels[] = {
+       IIO_CHAN(IIO_IN, 0, 1, 0, "supply", 0, 0,
+                (1 << IIO_CHAN_INFO_SCALE_SEPARATE),
+                in_supply, ADIS16240_SCAN_SUPPLY,
+                IIO_ST('u', 10, 16, 0), 0),
+       IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 1, 0,
+                0,
+                in_aux, ADIS16240_SCAN_AUX_ADC,
+                IIO_ST('u', 10, 16, 0), 0),
+       IIO_CHAN(IIO_ACCEL, 1, 0, 0, NULL, 0, IIO_MOD_X,
+                (1 << IIO_CHAN_INFO_SCALE_SHARED) |
+                (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE),
+                accel_x, ADIS16240_SCAN_ACC_X,
+                IIO_ST('s', 10, 16, 0), 0),
+       IIO_CHAN(IIO_ACCEL, 1, 0, 0, NULL, 0, IIO_MOD_Y,
+                (1 << IIO_CHAN_INFO_SCALE_SHARED) |
+                (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE),
+                accel_y, ADIS16240_SCAN_ACC_Y,
+                IIO_ST('s', 10, 16, 0), 0),
+       IIO_CHAN(IIO_ACCEL, 1, 0, 0, NULL, 0, IIO_MOD_Z,
+                (1 << IIO_CHAN_INFO_SCALE_SHARED) |
+                (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE),
+                accel_z, ADIS16240_SCAN_ACC_Z,
+                IIO_ST('s', 10, 16, 0), 0),
+       IIO_CHAN(IIO_TEMP, 0, 1, 0, NULL, 0, 0,
+                (1 << IIO_CHAN_INFO_SCALE_SEPARATE),
+                temp, ADIS16240_SCAN_TEMP,
+                IIO_ST('u', 10, 16, 0), 0),
+       IIO_CHAN_SOFT_TIMESTAMP(6)
 };
 
 static struct attribute *adis16240_attributes[] = {
-       &iio_dev_attr_in0_supply_raw.dev_attr.attr,
-       &iio_const_attr_in0_supply_scale.dev_attr.attr,
-       &iio_dev_attr_in1_raw.dev_attr.attr,
-       &iio_const_attr_accel_scale.dev_attr.attr,
-       &iio_const_attr_accel_peak_scale.dev_attr.attr,
-       &iio_dev_attr_accel_x_raw.dev_attr.attr,
-       &iio_dev_attr_accel_x_calibbias.dev_attr.attr,
-       &iio_dev_attr_accel_x_peak_raw.dev_attr.attr,
-       &iio_dev_attr_accel_y_raw.dev_attr.attr,
-       &iio_dev_attr_accel_y_calibbias.dev_attr.attr,
-       &iio_dev_attr_accel_y_peak_raw.dev_attr.attr,
-       &iio_dev_attr_accel_z_raw.dev_attr.attr,
-       &iio_dev_attr_accel_z_calibbias.dev_attr.attr,
-       &iio_dev_attr_accel_z_peak_raw.dev_attr.attr,
        &iio_dev_attr_accel_xyz_squared_peak_raw.dev_attr.attr,
-       &iio_dev_attr_temp_raw.dev_attr.attr,
-       &iio_const_attr_temp_scale.dev_attr.attr,
        &iio_const_attr_sampling_frequency_available.dev_attr.attr,
        &iio_dev_attr_reset.dev_attr.attr,
-       &iio_const_attr_name.dev_attr.attr,
        NULL
 };
 
@@ -460,6 +507,13 @@ static const struct attribute_group adis16240_attribute_group = {
        .attrs = adis16240_attributes,
 };
 
+static const struct iio_info adis16240_info = {
+       .attrs = &adis16240_attribute_group,
+       .read_raw = &adis16240_read_raw,
+       .write_raw = &adis16240_write_raw,
+       .driver_module = THIS_MODULE,
+};
+
 static int __devinit adis16240_probe(struct spi_device *spi)
 {
        int ret, regdone = 0;
@@ -485,18 +539,18 @@ static int __devinit adis16240_probe(struct spi_device *spi)
        st->us = spi;
        mutex_init(&st->buf_lock);
        /* setup the industrialio driver allocated elements */
-       st->indio_dev = iio_allocate_device();
+       st->indio_dev = iio_allocate_device(0);
        if (st->indio_dev == NULL) {
                ret = -ENOMEM;
                goto error_free_tx;
        }
 
+       st->indio_dev->name = spi->dev.driver->name;
        st->indio_dev->dev.parent = &spi->dev;
-       st->indio_dev->num_interrupt_lines = 1;
-       st->indio_dev->event_attrs = &adis16240_event_attribute_group;
-       st->indio_dev->attrs = &adis16240_attribute_group;
+       st->indio_dev->info = &adis16240_info;
+       st->indio_dev->channels = adis16240_channels;
+       st->indio_dev->num_channels = ARRAY_SIZE(adis16240_channels);
        st->indio_dev->dev_data = (void *)(st);
-       st->indio_dev->driver_module = THIS_MODULE;
        st->indio_dev->modes = INDIO_DIRECT_MODE;
 
        ret = adis16240_configure_ring(st->indio_dev);
@@ -508,37 +562,28 @@ static int __devinit adis16240_probe(struct spi_device *spi)
                goto error_unreg_ring_funcs;
        regdone = 1;
 
-       ret = iio_ring_buffer_register(st->indio_dev->ring, 0);
+       ret = iio_ring_buffer_register_ex(st->indio_dev->ring, 0,
+                                         adis16240_channels,
+                                         ARRAY_SIZE(adis16240_channels));
        if (ret) {
                printk(KERN_ERR "failed to initialize the ring\n");
                goto error_unreg_ring_funcs;
        }
 
        if (spi->irq) {
-               ret = iio_register_interrupt_line(spi->irq,
-                               st->indio_dev,
-                               0,
-                               IRQF_TRIGGER_RISING,
-                               "adis16240");
-               if (ret)
-                       goto error_uninitialize_ring;
-
                ret = adis16240_probe_trigger(st->indio_dev);
                if (ret)
-                       goto error_unregister_line;
+                       goto error_uninitialize_ring;
        }
 
        /* Get the device into a sane initial state */
-       ret = adis16240_initial_setup(st);
+       ret = adis16240_initial_setup(st->indio_dev);
        if (ret)
                goto error_remove_trigger;
        return 0;
 
 error_remove_trigger:
        adis16240_remove_trigger(st->indio_dev);
-error_unregister_line:
-       if (spi->irq)
-               iio_unregister_interrupt_line(st->indio_dev, 0);
 error_uninitialize_ring:
        iio_ring_buffer_unregister(st->indio_dev->ring);
 error_unreg_ring_funcs:
@@ -566,9 +611,6 @@ static int adis16240_remove(struct spi_device *spi)
        flush_scheduled_work();
 
        adis16240_remove_trigger(indio_dev);
-       if (spi->irq)
-               iio_unregister_interrupt_line(indio_dev, 0);
-
        iio_ring_buffer_unregister(indio_dev->ring);
        iio_device_unregister(indio_dev);
        adis16240_unconfigure_ring(indio_dev);
index f882e9c150e23196415d55fd12b2e3437adc378c..0c6d781d94c6761a5238e9546f94fa3b233c04f7 100644 (file)
 #include "../trigger.h"
 #include "adis16240.h"
 
-static IIO_SCAN_EL_C(in_supply, ADIS16240_SCAN_SUPPLY,
-               ADIS16240_SUPPLY_OUT, NULL);
-static IIO_CONST_ATTR_SCAN_EL_TYPE(in_supply, u, 10, 16);
-static IIO_SCAN_EL_C(accel_x, ADIS16240_SCAN_ACC_X, ADIS16240_XACCL_OUT, NULL);
-static IIO_SCAN_EL_C(accel_y, ADIS16240_SCAN_ACC_Y, ADIS16240_YACCL_OUT, NULL);
-static IIO_SCAN_EL_C(accel_z, ADIS16240_SCAN_ACC_Z, ADIS16240_ZACCL_OUT, NULL);
-static IIO_CONST_ATTR_SCAN_EL_TYPE(accel, s, 10, 16);
-static IIO_SCAN_EL_C(in0, ADIS16240_SCAN_AUX_ADC, ADIS16240_AUX_ADC, NULL);
-static IIO_CONST_ATTR_SCAN_EL_TYPE(in0, u, 10, 16);
-static IIO_SCAN_EL_C(temp, ADIS16240_SCAN_TEMP, ADIS16240_TEMP_OUT, NULL);
-static IIO_CONST_ATTR_SCAN_EL_TYPE(temp, u, 10, 16);
-static IIO_SCAN_EL_TIMESTAMP(6);
-static IIO_CONST_ATTR_SCAN_EL_TYPE(timestamp, s, 64, 64);
-
-static struct attribute *adis16240_scan_el_attrs[] = {
-       &iio_scan_el_in_supply.dev_attr.attr,
-       &iio_const_attr_in_supply_index.dev_attr.attr,
-       &iio_const_attr_in_supply_type.dev_attr.attr,
-       &iio_scan_el_accel_x.dev_attr.attr,
-       &iio_const_attr_accel_x_index.dev_attr.attr,
-       &iio_scan_el_accel_y.dev_attr.attr,
-       &iio_const_attr_accel_y_index.dev_attr.attr,
-       &iio_scan_el_accel_z.dev_attr.attr,
-       &iio_const_attr_accel_z_index.dev_attr.attr,
-       &iio_const_attr_accel_type.dev_attr.attr,
-       &iio_scan_el_in0.dev_attr.attr,
-       &iio_const_attr_in0_index.dev_attr.attr,
-       &iio_const_attr_in0_type.dev_attr.attr,
-       &iio_scan_el_temp.dev_attr.attr,
-       &iio_const_attr_temp_index.dev_attr.attr,
-       &iio_const_attr_temp_type.dev_attr.attr,
-       &iio_scan_el_timestamp.dev_attr.attr,
-       &iio_const_attr_timestamp_index.dev_attr.attr,
-       &iio_const_attr_timestamp_type.dev_attr.attr,
-       NULL,
-};
-
-static struct attribute_group adis16240_scan_el_group = {
-       .attrs = adis16240_scan_el_attrs,
-       .name = "scan_elements",
-};
-
-/**
- * adis16240_poll_func_th() top half interrupt handler called by trigger
- * @private_data:      iio_dev
- **/
-static void adis16240_poll_func_th(struct iio_dev *indio_dev, s64 time)
-{
-       struct adis16240_state *st = iio_dev_get_devdata(indio_dev);
-       st->last_timestamp = time;
-       schedule_work(&st->work_trigger_to_ring);
-}
-
 /**
  * adis16240_read_ring_data() read data registers which will be placed into ring
  * @dev: device associated with child of actual device (iio_dev or iio_trig)
@@ -112,56 +59,56 @@ static int adis16240_read_ring_data(struct device *dev, u8 *rx)
        return ret;
 }
 
-
-static void adis16240_trigger_bh_to_ring(struct work_struct *work_s)
+static irqreturn_t adis16240_trigger_handler(int irq, void *p)
 {
-       struct adis16240_state *st
-               = container_of(work_s, struct adis16240_state,
-                               work_trigger_to_ring);
-       struct iio_ring_buffer *ring = st->indio_dev->ring;
+       struct iio_poll_func *pf = p;
+       struct iio_dev *indio_dev = pf->private_data;
+       struct adis16240_state *st = iio_dev_get_devdata(indio_dev);
+       struct iio_ring_buffer *ring = indio_dev->ring;
 
        int i = 0;
        s16 *data;
-       size_t datasize = ring->access.get_bytes_per_datum(ring);
+       size_t datasize = ring->access->get_bytes_per_datum(ring);
 
-       data = kmalloc(datasize , GFP_KERNEL);
+       data = kmalloc(datasize, GFP_KERNEL);
        if (data == NULL) {
                dev_err(&st->us->dev, "memory alloc failed in ring bh");
-               return;
+               return -ENOMEM;
        }
 
-       if (ring->scan_count)
-               if (adis16240_read_ring_data(&st->indio_dev->dev, st->rx) >= 0)
-                       for (; i < ring->scan_count; i++)
-                               data[i] = be16_to_cpup(
-                                       (__be16 *)&(st->rx[i*2]));
+       if (ring->scan_count &&
+           adis16240_read_ring_data(&st->indio_dev->dev, st->rx) >= 0)
+               for (; i < ring->scan_count; i++)
+                       data[i] = be16_to_cpup((__be16 *)&(st->rx[i*2]));
 
        /* Guaranteed to be aligned with 8 byte boundary */
        if (ring->scan_timestamp)
-               *((s64 *)(data + ((i + 3)/4)*4)) = st->last_timestamp;
+               *((s64 *)(data + ((i + 3)/4)*4)) = pf->timestamp;
 
-       ring->access.store_to(ring,
-                       (u8 *)data,
-                       st->last_timestamp);
+       ring->access->store_to(ring, (u8 *)data, pf->timestamp);
 
        iio_trigger_notify_done(st->indio_dev->trig);
        kfree(data);
 
-       return;
+       return IRQ_HANDLED;
 }
 
 void adis16240_unconfigure_ring(struct iio_dev *indio_dev)
 {
-       kfree(indio_dev->pollfunc);
+       iio_dealloc_pollfunc(indio_dev->pollfunc);
        iio_sw_rb_free(indio_dev->ring);
 }
 
+static const struct iio_ring_setup_ops adis16240_ring_setup_ops = {
+       .preenable = &iio_sw_ring_preenable,
+       .postenable = &iio_triggered_ring_postenable,
+       .predisable = &iio_triggered_ring_predisable,
+};
+
 int adis16240_configure_ring(struct iio_dev *indio_dev)
 {
        int ret = 0;
-       struct adis16240_state *st = indio_dev->dev_data;
        struct iio_ring_buffer *ring;
-       INIT_WORK(&st->work_trigger_to_ring, adis16240_trigger_bh_to_ring);
 
        ring = iio_sw_rb_allocate(indio_dev);
        if (!ring) {
@@ -170,26 +117,31 @@ int adis16240_configure_ring(struct iio_dev *indio_dev)
        }
        indio_dev->ring = ring;
        /* Effectively select the ring buffer implementation */
-       iio_ring_sw_register_funcs(&ring->access);
+       ring->access = &ring_sw_access_funcs;
        ring->bpe = 2;
-       ring->scan_el_attrs = &adis16240_scan_el_group;
        ring->scan_timestamp = true;
-       ring->preenable = &iio_sw_ring_preenable;
-       ring->postenable = &iio_triggered_ring_postenable;
-       ring->predisable = &iio_triggered_ring_predisable;
+       ring->setup_ops = &adis16240_ring_setup_ops;
        ring->owner = THIS_MODULE;
 
        /* Set default scan mode */
-       iio_scan_mask_set(ring, iio_scan_el_in_supply.number);
-       iio_scan_mask_set(ring, iio_scan_el_accel_x.number);
-       iio_scan_mask_set(ring, iio_scan_el_accel_y.number);
-       iio_scan_mask_set(ring, iio_scan_el_accel_z.number);
-       iio_scan_mask_set(ring, iio_scan_el_temp.number);
-       iio_scan_mask_set(ring, iio_scan_el_in0.number);
-
-       ret = iio_alloc_pollfunc(indio_dev, NULL, &adis16240_poll_func_th);
-       if (ret)
+       iio_scan_mask_set(ring, ADIS16240_SCAN_SUPPLY);
+       iio_scan_mask_set(ring, ADIS16240_SCAN_ACC_X);
+       iio_scan_mask_set(ring, ADIS16240_SCAN_ACC_Y);
+       iio_scan_mask_set(ring, ADIS16240_SCAN_ACC_Z);
+       iio_scan_mask_set(ring, ADIS16240_SCAN_AUX_ADC);
+       iio_scan_mask_set(ring, ADIS16240_SCAN_TEMP);
+
+       indio_dev->pollfunc = iio_alloc_pollfunc(&iio_pollfunc_store_time,
+                                                &adis16240_trigger_handler,
+                                                IRQF_ONESHOT,
+                                                indio_dev,
+                                                "%s_consumer%d",
+                                                indio_dev->name,
+                                                indio_dev->id);
+       if (indio_dev->pollfunc == NULL) {
+               ret = -ENOMEM;
                goto error_iio_sw_rb_free;
+       }
 
        indio_dev->modes |= INDIO_RING_TRIGGERED;
        return 0;
@@ -198,4 +150,3 @@ error_iio_sw_rb_free:
        iio_sw_rb_free(indio_dev->ring);
        return ret;
 }
-
index 6cb8681f2853fa0415588d5b404e466e952fff7d..ece3ca8fb7eb2ea5823f75beae8c89d82c3f0a7f 100644 (file)
 /**
  * adis16240_data_rdy_trig_poll() the event handler for the data rdy trig
  **/
-static int adis16240_data_rdy_trig_poll(struct iio_dev *dev_info,
-                                      int index,
-                                      s64 timestamp,
-                                      int no_test)
+static irqreturn_t adis16240_data_rdy_trig_poll(int irq, void *trig)
 {
-       struct adis16240_state *st = iio_dev_get_devdata(dev_info);
-       struct iio_trigger *trig = st->trig;
-
-       iio_trigger_poll(trig, timestamp);
-
+       iio_trigger_poll(trig, iio_get_time_ns());
        return IRQ_HANDLED;
 }
 
-IIO_EVENT_SH(data_rdy_trig, &adis16240_data_rdy_trig_poll);
-
-static IIO_TRIGGER_NAME_ATTR;
-
-static struct attribute *adis16240_trigger_attrs[] = {
-       &dev_attr_name.attr,
-       NULL,
-};
-
-static const struct attribute_group adis16240_trigger_attr_group = {
-       .attrs = adis16240_trigger_attrs,
-};
-
 /**
  * adis16240_data_rdy_trigger_set_state() set datardy interrupt state
  **/
@@ -49,31 +29,9 @@ static int adis16240_data_rdy_trigger_set_state(struct iio_trigger *trig,
 {
        struct adis16240_state *st = trig->private_data;
        struct iio_dev *indio_dev = st->indio_dev;
-       int ret = 0;
 
        dev_dbg(&indio_dev->dev, "%s (%d)\n", __func__, state);
-       ret = adis16240_set_irq(&st->indio_dev->dev, state);
-       if (state == false) {
-               iio_remove_event_from_list(&iio_event_data_rdy_trig,
-                                          &indio_dev->interrupts[0]
-                                          ->ev_list);
-               flush_scheduled_work();
-       } else {
-               iio_add_event_to_list(&iio_event_data_rdy_trig,
-                                     &indio_dev->interrupts[0]->ev_list);
-       }
-       return ret;
-}
-
-/**
- * adis16240_trig_try_reen() try renabling irq for data rdy trigger
- * @trig:      the datardy trigger
- **/
-static int adis16240_trig_try_reen(struct iio_trigger *trig)
-{
-       struct adis16240_state *st = trig->private_data;
-       enable_irq(st->us->irq);
-       return 0;
+       return adis16240_set_irq(st->indio_dev, state);
 }
 
 int adis16240_probe_trigger(struct iio_dev *indio_dev)
@@ -81,34 +39,38 @@ int adis16240_probe_trigger(struct iio_dev *indio_dev)
        int ret;
        struct adis16240_state *st = indio_dev->dev_data;
 
-       st->trig = iio_allocate_trigger();
-       st->trig->name = kasprintf(GFP_KERNEL,
-                                  "adis16240-dev%d",
-                                  indio_dev->id);
-       if (!st->trig->name) {
+       st->trig = iio_allocate_trigger("adis16240-dev%d", indio_dev->id);
+       if (st->trig == NULL) {
                ret = -ENOMEM;
-               goto error_free_trig;
+               goto error_ret;
        }
+
+       ret = request_irq(st->us->irq,
+                         adis16240_data_rdy_trig_poll,
+                         IRQF_TRIGGER_RISING,
+                         "adis16240",
+                         st->trig);
+       if (ret)
+               goto error_free_trig;
+
        st->trig->dev.parent = &st->us->dev;
        st->trig->owner = THIS_MODULE;
        st->trig->private_data = st;
        st->trig->set_trigger_state = &adis16240_data_rdy_trigger_set_state;
-       st->trig->try_reenable = &adis16240_trig_try_reen;
-       st->trig->control_attrs = &adis16240_trigger_attr_group;
        ret = iio_trigger_register(st->trig);
 
        /* select default trigger */
        indio_dev->trig = st->trig;
        if (ret)
-               goto error_free_trig_name;
+               goto error_free_irq;
 
        return 0;
 
-error_free_trig_name:
-       kfree(st->trig->name);
+error_free_irq:
+       free_irq(st->us->irq, st->trig);
 error_free_trig:
        iio_free_trigger(st->trig);
-
+error_ret:
        return ret;
 }
 
@@ -117,6 +79,6 @@ void adis16240_remove_trigger(struct iio_dev *indio_dev)
        struct adis16240_state *state = indio_dev->dev_data;
 
        iio_trigger_unregister(state->trig);
-       kfree(state->trig->name);
+       free_irq(state->us->irq, state->trig);
        iio_free_trigger(state->trig);
 }
index 79f57950ebeb00c2613c11370ddbf5856729d4d7..973156e75773e3d8f8110c95cda1c3386394702c 100644 (file)
@@ -301,6 +301,11 @@ error_ret:
 
 };
 
+static const struct iio_info kxsd9_info = {
+       .attrs = &kxsd9_attribute_group,
+       .driver_module = THIS_MODULE,
+};
+
 static int __devinit kxsd9_probe(struct spi_device *spi)
 {
 
@@ -329,19 +334,14 @@ static int __devinit kxsd9_probe(struct spi_device *spi)
 
        st->us = spi;
        mutex_init(&st->buf_lock);
-       st->indio_dev = iio_allocate_device();
+       st->indio_dev = iio_allocate_device(0);
        if (st->indio_dev == NULL) {
                ret = -ENOMEM;
                goto error_free_tx;
        }
        st->indio_dev->dev.parent = &spi->dev;
-       /* for now */
-       st->indio_dev->num_interrupt_lines = 0;
-       st->indio_dev->event_attrs = NULL;
-
-       st->indio_dev->attrs = &kxsd9_attribute_group;
+       st->indio_dev->info = &kxsd9_info;
        st->indio_dev->dev_data = (void *)(st);
-       st->indio_dev->driver_module = THIS_MODULE;
        st->indio_dev->modes = INDIO_DIRECT_MODE;
 
        ret = iio_device_register(st->indio_dev);
index 11402187f9ae6288de4a07b323f543a896dc0616..18b23acfb6f45abf606394dac86fc99931284fbc 100644 (file)
@@ -148,38 +148,31 @@ Form of high byte dependent on justification set in ctrl reg */
 #define LIS3L02DQ_MAX_RX 12
 /**
  * struct lis3l02dq_state - device instance specific data
- * @helper:            data and func pointer allowing generic functions
  * @us:                        actual spi_device
- * @work_thresh:       bh for threshold events
- * @thresh_timestamp:  timestamp for threshold interrupts.
- * @inter:             used to check if new interrupt has been triggered
  * @trig:              data ready trigger registered with iio
  * @tx:                        transmit buffer
  * @rx:                        receive buffer
  * @buf_lock:          mutex to protect tx and rx
  **/
 struct lis3l02dq_state {
-       struct iio_sw_ring_helper_state help;
        struct spi_device               *us;
-       struct work_struct              work_thresh;
-       s64                             thresh_timestamp;
-       bool                            inter;
        struct iio_trigger              *trig;
-       u8                              *tx;
-       u8                              *rx;
        struct mutex                    buf_lock;
-};
+       bool                            trigger_on;
 
-#define lis3l02dq_h_to_s(_h)                           \
-       container_of(_h, struct lis3l02dq_state, help)
+       u8      tx[LIS3L02DQ_MAX_RX] ____cacheline_aligned;
+       u8      rx[LIS3L02DQ_MAX_RX] ____cacheline_aligned;
+};
 
-int lis3l02dq_spi_read_reg_8(struct device *dev,
+int lis3l02dq_spi_read_reg_8(struct iio_dev *indio_dev,
                             u8 reg_address,
                             u8 *val);
 
-int lis3l02dq_spi_write_reg_8(struct device *dev,
+int lis3l02dq_spi_write_reg_8(struct iio_dev *indio_dev,
                              u8 reg_address,
-                             u8 *val);
+                             u8 val);
+
+int lis3l02dq_disable_all_events(struct iio_dev *indio_dev);
 
 #ifdef CONFIG_IIO_RING_BUFFER
 /* At the moment triggers are only used for ring buffer
@@ -188,9 +181,9 @@ int lis3l02dq_spi_write_reg_8(struct device *dev,
 void lis3l02dq_remove_trigger(struct iio_dev *indio_dev);
 int lis3l02dq_probe_trigger(struct iio_dev *indio_dev);
 
-ssize_t lis3l02dq_read_accel_from_ring(struct device *dev,
-                                      struct device_attribute *attr,
-                                      char *buf);
+ssize_t lis3l02dq_read_accel_from_ring(struct iio_ring_buffer *ring,
+                                      int index,
+                                      int *val);
 
 
 int lis3l02dq_configure_ring(struct iio_dev *indio_dev);
@@ -199,14 +192,18 @@ void lis3l02dq_unconfigure_ring(struct iio_dev *indio_dev);
 #ifdef CONFIG_LIS3L02DQ_BUF_RING_SW
 #define lis3l02dq_free_buf iio_sw_rb_free
 #define lis3l02dq_alloc_buf iio_sw_rb_allocate
-#define lis3l02dq_register_buf_funcs iio_ring_sw_register_funcs
+#define lis3l02dq_access_funcs ring_sw_access_funcs
 #endif
 #ifdef CONFIG_LIS3L02DQ_BUF_KFIFO
 #define lis3l02dq_free_buf iio_kfifo_free
 #define lis3l02dq_alloc_buf iio_kfifo_allocate
-#define lis3l02dq_register_buf_funcs iio_kfifo_register_funcs
+#define lis3l02dq_access_funcs kfifo_access_funcs
 #endif
+irqreturn_t lis3l02dq_data_rdy_trig_poll(int irq, void *private);
+#define lis3l02dq_th lis3l02dq_data_rdy_trig_poll
+
 #else /* CONFIG_IIO_RING_BUFFER */
+#define lis3l02dq_th lis3l02dq_noring
 
 static inline void lis3l02dq_remove_trigger(struct iio_dev *indio_dev)
 {
@@ -215,11 +212,10 @@ static inline int lis3l02dq_probe_trigger(struct iio_dev *indio_dev)
 {
        return 0;
 }
-
 static inline ssize_t
-lis3l02dq_read_accel_from_ring(struct device *dev,
-                              struct device_attribute *attr,
-                              char *buf)
+lis3l02dq_read_accel_from_ring(struct iio_ring_buffer *ring,
+                              int index,
+                              int *val)
 {
        return 0;
 }
index 3067f9662d20e98908a31424697a108afaea98eb..ba5bc679204f5cd023031545ed286e8f3786f260 100644 (file)
 #include <linux/interrupt.h>
 #include <linux/irq.h>
 #include <linux/gpio.h>
-#include <linux/workqueue.h>
 #include <linux/mutex.h>
 #include <linux/device.h>
 #include <linux/kernel.h>
 #include <linux/spi/spi.h>
 #include <linux/slab.h>
-
 #include <linux/sysfs.h>
-#include <linux/list.h>
 
 #include "../iio.h"
 #include "../sysfs.h"
 #include "../ring_generic.h"
-#include "../ring_sw.h"
 
 #include "accel.h"
 
  * It's in the likely to be added comment at the top of spi.h.
  * This means that use cannot be made of spi_write etc.
  */
+/* direct copy of the irq_default_primary_handler */
+#ifndef CONFIG_IIO_RING_BUFFER
+static irqreturn_t lis3l02dq_noring(int irq, void *private)
+{
+       return IRQ_WAKE_THREAD;
+}
+#endif
 
 /**
  * lis3l02dq_spi_read_reg_8() - read single byte from a single register
- * @dev: device asosciated with child of actual device (iio_dev or iio_trig)
+ * @indio_dev: iio_dev for this actual device
  * @reg_address: the address of the register to be read
  * @val: pass back the resulting value
  **/
-int lis3l02dq_spi_read_reg_8(struct device *dev, u8 reg_address, u8 *val)
+int lis3l02dq_spi_read_reg_8(struct iio_dev *indio_dev,
+                            u8 reg_address, u8 *val)
 {
-       int ret;
+       struct lis3l02dq_state *st = iio_priv(indio_dev);
        struct spi_message msg;
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
-       struct iio_sw_ring_helper_state *h = iio_dev_get_devdata(indio_dev);
-       struct lis3l02dq_state *st = lis3l02dq_h_to_s(h);
-
+       int ret;
        struct spi_transfer xfer = {
                .tx_buf = st->tx,
                .rx_buf = st->rx,
                .bits_per_word = 8,
                .len = 2,
-               .cs_change = 1,
        };
 
        mutex_lock(&st->buf_lock);
@@ -76,34 +76,21 @@ int lis3l02dq_spi_read_reg_8(struct device *dev, u8 reg_address, u8 *val)
 
 /**
  * lis3l02dq_spi_write_reg_8() - write single byte to a register
- * @dev: device associated with child of actual device (iio_dev or iio_trig)
+ * @indio_dev: iio_dev for this device
  * @reg_address: the address of the register to be written
  * @val: the value to write
  **/
-int lis3l02dq_spi_write_reg_8(struct device *dev,
+int lis3l02dq_spi_write_reg_8(struct iio_dev *indio_dev,
                              u8 reg_address,
-                             u8 *val)
+                             u8 val)
 {
        int ret;
-       struct spi_message msg;
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
-       struct iio_sw_ring_helper_state *h
-               = iio_dev_get_devdata(indio_dev);
-       struct lis3l02dq_state *st = lis3l02dq_h_to_s(h);
-       struct spi_transfer xfer = {
-               .tx_buf = st->tx,
-               .bits_per_word = 8,
-               .len = 2,
-               .cs_change = 1,
-       };
+       struct lis3l02dq_state *st = iio_priv(indio_dev);
 
        mutex_lock(&st->buf_lock);
        st->tx[0] = LIS3L02DQ_WRITE_REG(reg_address);
-       st->tx[1] = *val;
-
-       spi_message_init(&msg);
-       spi_message_add_tail(&xfer, &msg);
-       ret = spi_sync(st->us, &msg);
+       st->tx[1] = val;
+       ret = spi_write(st->us, st->tx, 2);
        mutex_unlock(&st->buf_lock);
 
        return ret;
@@ -111,21 +98,18 @@ int lis3l02dq_spi_write_reg_8(struct device *dev,
 
 /**
  * lisl302dq_spi_write_reg_s16() - write 2 bytes to a pair of registers
- * @dev: device associated with child of actual device (iio_dev or iio_trig)
- * @reg_address: the address of the lower of the two registers. Second register
- *               is assumed to have address one greater.
- * @val: value to be written
+ * @indio_dev: iio_dev for this device
+ * @lower_reg_address: the address of the lower of the two registers.
+ *               Second register is assumed to have address one greater.
+ * @value: value to be written
  **/
-static int lis3l02dq_spi_write_reg_s16(struct device *dev,
+static int lis3l02dq_spi_write_reg_s16(struct iio_dev *indio_dev,
                                       u8 lower_reg_address,
                                       s16 value)
 {
        int ret;
        struct spi_message msg;
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
-       struct iio_sw_ring_helper_state *h
-               = iio_dev_get_devdata(indio_dev);
-       struct lis3l02dq_state *st = lis3l02dq_h_to_s(h);
+       struct lis3l02dq_state *st = iio_priv(indio_dev);
        struct spi_transfer xfers[] = { {
                        .tx_buf = st->tx,
                        .bits_per_word = 8,
@@ -135,7 +119,6 @@ static int lis3l02dq_spi_write_reg_s16(struct device *dev,
                        .tx_buf = st->tx + 2,
                        .bits_per_word = 8,
                        .len = 2,
-                       .cs_change = 1,
                },
        };
 
@@ -154,23 +137,15 @@ static int lis3l02dq_spi_write_reg_s16(struct device *dev,
        return ret;
 }
 
-/**
- * lisl302dq_spi_read_reg_s16() - write 2 bytes to a pair of registers
- * @dev: device associated with child of actual device (iio_dev or iio_trig)
- * @reg_address: the address of the lower of the two registers. Second register
- *               is assumed to have address one greater.
- * @val: somewhere to pass back the value read
- **/
-static int lis3l02dq_spi_read_reg_s16(struct device *dev,
-                                     u8 lower_reg_address,
-                                     s16 *val)
+static int lis3l02dq_read_reg_s16(struct iio_dev *indio_dev,
+                                 u8 lower_reg_address,
+                                 int *val)
 {
+       struct lis3l02dq_state *st = iio_priv(indio_dev);
+
        struct spi_message msg;
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
-       struct iio_sw_ring_helper_state *h
-               = iio_dev_get_devdata(indio_dev);
-       struct lis3l02dq_state *st = lis3l02dq_h_to_s(h);
        int ret;
+       s16 tempval;
        struct spi_transfer xfers[] = { {
                        .tx_buf = st->tx,
                        .rx_buf = st->rx,
@@ -182,15 +157,13 @@ static int lis3l02dq_spi_read_reg_s16(struct device *dev,
                        .rx_buf = st->rx + 2,
                        .bits_per_word = 8,
                        .len = 2,
-                       .cs_change = 1,
-
                },
        };
 
        mutex_lock(&st->buf_lock);
        st->tx[0] = LIS3L02DQ_READ_REG(lower_reg_address);
        st->tx[1] = 0;
-       st->tx[2] = LIS3L02DQ_READ_REG(lower_reg_address+1);
+       st->tx[2] = LIS3L02DQ_READ_REG(lower_reg_address + 1);
        st->tx[3] = 0;
 
        spi_message_init(&msg);
@@ -201,144 +174,135 @@ static int lis3l02dq_spi_read_reg_s16(struct device *dev,
                dev_err(&st->us->dev, "problem when reading 16 bit register");
                goto error_ret;
        }
-       *val = (s16)(st->rx[1]) | ((s16)(st->rx[3]) << 8);
+       tempval = (s16)(st->rx[1]) | ((s16)(st->rx[3]) << 8);
 
+       *val = tempval;
 error_ret:
        mutex_unlock(&st->buf_lock);
        return ret;
 }
 
-/**
- * lis3l02dq_read_signed() - attribute function used for 8 bit signed values
- * @dev: the child device associated with the iio_dev or iio_trigger
- * @attr: the attribute being processed
- * @buf: buffer into which put the output string
- **/
-static ssize_t lis3l02dq_read_signed(struct device *dev,
-                                    struct device_attribute *attr,
-                                    char *buf)
-{
-       int ret;
-       s8 val;
-       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-
-       ret = lis3l02dq_spi_read_reg_8(dev, this_attr->address, (u8 *)&val);
-
-       return ret ? ret : sprintf(buf, "%d\n", val);
-}
-
-static ssize_t lis3l02dq_read_unsigned(struct device *dev,
-                                      struct device_attribute *attr,
-                                      char *buf)
-{
-       int ret;
-       u8 val;
-       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-
-       ret = lis3l02dq_spi_read_reg_8(dev, this_attr->address, &val);
-
-       return ret ? ret : sprintf(buf, "%d\n", val);
-}
-
-static ssize_t lis3l02dq_write_signed(struct device *dev,
-                                     struct device_attribute *attr,
-                                     const char *buf,
-                                     size_t len)
-{
-       long valin;
-       s8 val;
-       int ret;
-       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-
-       ret = strict_strtol(buf, 10, &valin);
-       if (ret)
-               goto error_ret;
-       val = valin;
-       ret = lis3l02dq_spi_write_reg_8(dev, this_attr->address, (u8 *)&val);
+enum lis3l02dq_rm_ind {
+       LIS3L02DQ_ACCEL,
+       LIS3L02DQ_GAIN,
+       LIS3L02DQ_BIAS,
+};
 
-error_ret:
-       return ret ? ret : len;
-}
+static u8 lis3l02dq_axis_map[3][3] = {
+       [LIS3L02DQ_ACCEL] = { LIS3L02DQ_REG_OUT_X_L_ADDR,
+                             LIS3L02DQ_REG_OUT_Y_L_ADDR,
+                             LIS3L02DQ_REG_OUT_Z_L_ADDR },
+       [LIS3L02DQ_GAIN] = { LIS3L02DQ_REG_GAIN_X_ADDR,
+                            LIS3L02DQ_REG_GAIN_Y_ADDR,
+                            LIS3L02DQ_REG_GAIN_Z_ADDR },
+       [LIS3L02DQ_BIAS] = { LIS3L02DQ_REG_OFFSET_X_ADDR,
+                            LIS3L02DQ_REG_OFFSET_Y_ADDR,
+                            LIS3L02DQ_REG_OFFSET_Z_ADDR }
+};
 
-static ssize_t lis3l02dq_write_unsigned(struct device *dev,
-                                       struct device_attribute *attr,
-                                       const char *buf,
-                                       size_t len)
+static int lis3l02dq_read_thresh(struct iio_dev *indio_dev,
+                                int e,
+                                int *val)
 {
-       int ret;
-       ulong valin;
-       u8 val;
-       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-
-       ret = strict_strtoul(buf, 10, &valin);
-       if (ret)
-               goto err_ret;
-       val = valin;
-       ret = lis3l02dq_spi_write_reg_8(dev, this_attr->address, &val);
-
-err_ret:
-       return ret ? ret : len;
+       return lis3l02dq_read_reg_s16(indio_dev, LIS3L02DQ_REG_THS_L_ADDR, val);
 }
 
-static ssize_t lis3l02dq_read_16bit_signed(struct device *dev,
-                                          struct device_attribute *attr,
-                                          char *buf)
+static int lis3l02dq_write_thresh(struct iio_dev *indio_dev,
+                                 int event_code,
+                                 int val)
 {
-       int ret;
-       s16 val = 0;
-       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-
-       ret = lis3l02dq_spi_read_reg_s16(dev, this_attr->address, &val);
-
-       if (ret)
-               return ret;
-
-       return sprintf(buf, "%d\n", val);
+       u16 value = val;
+       return lis3l02dq_spi_write_reg_s16(indio_dev,
+                                          LIS3L02DQ_REG_THS_L_ADDR,
+                                          value);
 }
 
-static ssize_t lis3l02dq_read_accel(struct device *dev,
-                                   struct device_attribute *attr,
-                                   char *buf)
+static int lis3l02dq_write_raw(struct iio_dev *indio_dev,
+                              struct iio_chan_spec const *chan,
+                              int val,
+                              int val2,
+                              long mask)
 {
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
-       ssize_t ret;
-
-       /* Take the iio_dev status lock */
-       mutex_lock(&indio_dev->mlock);
-       if (indio_dev->currentmode == INDIO_RING_TRIGGERED)
-               ret = lis3l02dq_read_accel_from_ring(dev, attr, buf);
-       else
-               ret =  lis3l02dq_read_16bit_signed(dev, attr, buf);
-       mutex_unlock(&indio_dev->mlock);
-
+       int ret = -EINVAL, reg;
+       u8 uval;
+       s8 sval;
+       switch (mask) {
+       case (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE):
+               if (val > 255 || val < -256)
+                       return -EINVAL;
+               sval = val;
+               reg = lis3l02dq_axis_map[LIS3L02DQ_BIAS][chan->address];
+               ret = lis3l02dq_spi_write_reg_8(indio_dev, reg, sval);
+               break;
+       case (1 << IIO_CHAN_INFO_CALIBSCALE_SEPARATE):
+               if (val & ~0xFF)
+                       return -EINVAL;
+               uval = val;
+               reg = lis3l02dq_axis_map[LIS3L02DQ_GAIN][chan->address];
+               ret = lis3l02dq_spi_write_reg_8(indio_dev, reg, uval);
+               break;
+       }
        return ret;
 }
 
-static ssize_t lis3l02dq_write_16bit_signed(struct device *dev,
-                                           struct device_attribute *attr,
-                                           const char *buf,
-                                           size_t len)
+static int lis3l02dq_read_raw(struct iio_dev *indio_dev,
+                             struct iio_chan_spec const *chan,
+                             int *val,
+                             int *val2,
+                             long mask)
 {
-       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-       int ret;
-       long val;
-
-       ret = strict_strtol(buf, 10, &val);
-       if (ret)
-               goto error_ret;
-       ret = lis3l02dq_spi_write_reg_s16(dev, this_attr->address, val);
-
+       u8 utemp;
+       s8 stemp;
+       ssize_t ret = 0;
+       u8 reg;
+
+       switch (mask) {
+       case 0:
+               /* Take the iio_dev status lock */
+               mutex_lock(&indio_dev->mlock);
+               if (indio_dev->currentmode == INDIO_RING_TRIGGERED)
+                       ret = lis3l02dq_read_accel_from_ring(indio_dev->ring,
+                                                            chan->scan_index,
+                                                            val);
+               else {
+                       reg = lis3l02dq_axis_map
+                               [LIS3L02DQ_ACCEL][chan->address];
+                       ret = lis3l02dq_read_reg_s16(indio_dev, reg, val);
+               }
+               mutex_unlock(&indio_dev->mlock);
+               return IIO_VAL_INT;
+       case (1 << IIO_CHAN_INFO_SCALE_SHARED):
+               *val = 0;
+               *val2 = 9580;
+               return IIO_VAL_INT_PLUS_MICRO;
+       case (1 << IIO_CHAN_INFO_CALIBSCALE_SEPARATE):
+               reg = lis3l02dq_axis_map[LIS3L02DQ_GAIN][chan->address];
+               ret = lis3l02dq_spi_read_reg_8(indio_dev, reg, &utemp);
+               if (ret)
+                       goto error_ret;
+               /* to match with what previous code does */
+               *val = utemp;
+               return IIO_VAL_INT;
+
+       case (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE):
+               reg = lis3l02dq_axis_map[LIS3L02DQ_BIAS][chan->address];
+               ret = lis3l02dq_spi_read_reg_8(indio_dev, reg, (u8 *)&stemp);
+               /* to match with what previous code does */
+               *val = stemp;
+               return IIO_VAL_INT;
+       }
 error_ret:
-       return ret ? ret : len;
+       return ret;
 }
 
 static ssize_t lis3l02dq_read_frequency(struct device *dev,
                                        struct device_attribute *attr,
                                        char *buf)
 {
+       struct iio_dev *indio_dev = dev_get_drvdata(dev);
        int ret, len = 0;
        s8 t;
-       ret = lis3l02dq_spi_read_reg_8(dev,
+       ret = lis3l02dq_spi_read_reg_8(indio_dev,
                                       LIS3L02DQ_REG_CTRL_1_ADDR,
                                       (u8 *)&t);
        if (ret)
@@ -376,7 +340,7 @@ static ssize_t lis3l02dq_write_frequency(struct device *dev,
                return ret;
 
        mutex_lock(&indio_dev->mlock);
-       ret = lis3l02dq_spi_read_reg_8(dev,
+       ret = lis3l02dq_spi_read_reg_8(indio_dev,
                                       LIS3L02DQ_REG_CTRL_1_ADDR,
                                       &t);
        if (ret)
@@ -399,11 +363,11 @@ static ssize_t lis3l02dq_write_frequency(struct device *dev,
        default:
                ret = -EINVAL;
                goto error_ret_mutex;
-       };
+       }
 
-       ret = lis3l02dq_spi_write_reg_8(dev,
+       ret = lis3l02dq_spi_write_reg_8(indio_dev,
                                        LIS3L02DQ_REG_CTRL_1_ADDR,
-                                       &t);
+                                       t);
 
 error_ret_mutex:
        mutex_unlock(&indio_dev->mlock);
@@ -411,8 +375,9 @@ error_ret_mutex:
        return ret ? ret : len;
 }
 
-static int lis3l02dq_initial_setup(struct lis3l02dq_state *st)
+static int lis3l02dq_initial_setup(struct iio_dev *indio_dev)
 {
+       struct lis3l02dq_state *st = iio_priv(indio_dev);
        int ret;
        u8 val, valtest;
 
@@ -422,17 +387,17 @@ static int lis3l02dq_initial_setup(struct lis3l02dq_state *st)
 
        val = LIS3L02DQ_DEFAULT_CTRL1;
        /* Write suitable defaults to ctrl1 */
-       ret = lis3l02dq_spi_write_reg_8(&st->help.indio_dev->dev,
+       ret = lis3l02dq_spi_write_reg_8(indio_dev,
                                        LIS3L02DQ_REG_CTRL_1_ADDR,
-                                       &val);
+                                       val);
        if (ret) {
                dev_err(&st->us->dev, "problem with setup control register 1");
                goto err_ret;
        }
        /* Repeat as sometimes doesn't work first time?*/
-       ret = lis3l02dq_spi_write_reg_8(&st->help.indio_dev->dev,
+       ret = lis3l02dq_spi_write_reg_8(indio_dev,
                                        LIS3L02DQ_REG_CTRL_1_ADDR,
-                                       &val);
+                                       val);
        if (ret) {
                dev_err(&st->us->dev, "problem with setup control register 1");
                goto err_ret;
@@ -440,28 +405,29 @@ static int lis3l02dq_initial_setup(struct lis3l02dq_state *st)
 
        /* Read back to check this has worked acts as loose test of correct
         * chip */
-       ret = lis3l02dq_spi_read_reg_8(&st->help.indio_dev->dev,
+       ret = lis3l02dq_spi_read_reg_8(indio_dev,
                                       LIS3L02DQ_REG_CTRL_1_ADDR,
                                       &valtest);
        if (ret || (valtest != val)) {
-               dev_err(&st->help.indio_dev->dev, "device not playing ball");
+               dev_err(&indio_dev->dev,
+                       "device not playing ball %d %d\n", valtest, val);
                ret = -EINVAL;
                goto err_ret;
        }
 
        val = LIS3L02DQ_DEFAULT_CTRL2;
-       ret = lis3l02dq_spi_write_reg_8(&st->help.indio_dev->dev,
+       ret = lis3l02dq_spi_write_reg_8(indio_dev,
                                        LIS3L02DQ_REG_CTRL_2_ADDR,
-                                       &val);
+                                       val);
        if (ret) {
                dev_err(&st->us->dev, "problem with setup control register 2");
                goto err_ret;
        }
 
        val = LIS3L02DQ_REG_WAKE_UP_CFG_LATCH_SRC;
-       ret = lis3l02dq_spi_write_reg_8(&st->help.indio_dev->dev,
+       ret = lis3l02dq_spi_write_reg_8(indio_dev,
                                        LIS3L02DQ_REG_WAKE_UP_CFG_ADDR,
-                                       &val);
+                                       val);
        if (ret)
                dev_err(&st->us->dev, "problem with interrupt cfg register");
 err_ret:
@@ -469,309 +435,215 @@ err_ret:
        return ret;
 }
 
-#define LIS3L02DQ_SIGNED_ATTR(name, reg)       \
-       IIO_DEVICE_ATTR(name,                   \
-                       S_IWUSR | S_IRUGO,      \
-                       lis3l02dq_read_signed,  \
-                       lis3l02dq_write_signed, \
-                       reg);
-
-#define LIS3L02DQ_UNSIGNED_ATTR(name, reg)             \
-       IIO_DEVICE_ATTR(name,                           \
-                       S_IWUSR | S_IRUGO,              \
-                       lis3l02dq_read_unsigned,        \
-                       lis3l02dq_write_unsigned,       \
-                       reg);
-
-static LIS3L02DQ_SIGNED_ATTR(accel_x_calibbias,
-                            LIS3L02DQ_REG_OFFSET_X_ADDR);
-static LIS3L02DQ_SIGNED_ATTR(accel_y_calibbias,
-                            LIS3L02DQ_REG_OFFSET_Y_ADDR);
-static LIS3L02DQ_SIGNED_ATTR(accel_z_calibbias,
-                            LIS3L02DQ_REG_OFFSET_Z_ADDR);
-
-static LIS3L02DQ_UNSIGNED_ATTR(accel_x_calibscale,
-                              LIS3L02DQ_REG_GAIN_X_ADDR);
-static LIS3L02DQ_UNSIGNED_ATTR(accel_y_calibscale,
-                              LIS3L02DQ_REG_GAIN_Y_ADDR);
-static LIS3L02DQ_UNSIGNED_ATTR(accel_z_calibscale,
-                              LIS3L02DQ_REG_GAIN_Z_ADDR);
-
-static IIO_DEVICE_ATTR(accel_raw_mag_value,
-                      S_IWUSR | S_IRUGO,
-                      lis3l02dq_read_16bit_signed,
-                      lis3l02dq_write_16bit_signed,
-                      LIS3L02DQ_REG_THS_L_ADDR);
-/* RFC The reading method for these will change depending on whether
- * ring buffer capture is in use. Is it worth making these take two
- * functions and let the core handle which to call, or leave as in this
- * driver where it is the drivers problem to manage this?
- */
-
-static IIO_DEV_ATTR_ACCEL_X(lis3l02dq_read_accel,
-                           LIS3L02DQ_REG_OUT_X_L_ADDR);
-
-static IIO_DEV_ATTR_ACCEL_Y(lis3l02dq_read_accel,
-                           LIS3L02DQ_REG_OUT_Y_L_ADDR);
-
-static IIO_DEV_ATTR_ACCEL_Z(lis3l02dq_read_accel,
-                           LIS3L02DQ_REG_OUT_Z_L_ADDR);
-
 static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO,
                              lis3l02dq_read_frequency,
                              lis3l02dq_write_frequency);
 
 static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("280 560 1120 4480");
 
-static ssize_t lis3l02dq_read_interrupt_config(struct device *dev,
-                                              struct device_attribute *attr,
-                                              char *buf)
-{
-       int ret;
-       s8 val;
-       struct iio_event_attr *this_attr = to_iio_event_attr(attr);
-
-       ret = lis3l02dq_spi_read_reg_8(dev->parent,
-                                      LIS3L02DQ_REG_WAKE_UP_CFG_ADDR,
-                                      (u8 *)&val);
-
-       return ret ? ret : sprintf(buf, "%d\n", !!(val & this_attr->mask));
-}
-
-static ssize_t lis3l02dq_write_interrupt_config(struct device *dev,
-                                               struct device_attribute *attr,
-                                               const char *buf,
-                                               size_t len)
-{
-       struct iio_event_attr *this_attr = to_iio_event_attr(attr);
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
-       int ret, currentlyset, changed = 0;
-       u8 valold, controlold;
-       bool val;
-
-       val = !(buf[0] == '0');
-
-       mutex_lock(&indio_dev->mlock);
-       /* read current value */
-       ret = lis3l02dq_spi_read_reg_8(dev->parent,
-                                      LIS3L02DQ_REG_WAKE_UP_CFG_ADDR,
-                                      &valold);
-       if (ret)
-               goto error_mutex_unlock;
-
-       /* read current control */
-       ret = lis3l02dq_spi_read_reg_8(dev,
-                                      LIS3L02DQ_REG_CTRL_2_ADDR,
-                                      &controlold);
-       if (ret)
-               goto error_mutex_unlock;
-       currentlyset = !!(valold & this_attr->mask);
-       if (val == false && currentlyset) {
-               valold &= ~this_attr->mask;
-               changed = 1;
-               iio_remove_event_from_list(this_attr->listel,
-                                                &indio_dev->interrupts[0]
-                                                ->ev_list);
-       } else if (val == true && !currentlyset) {
-               changed = 1;
-               valold |= this_attr->mask;
-               iio_add_event_to_list(this_attr->listel,
-                                           &indio_dev->interrupts[0]->ev_list);
-       }
-
-       if (changed) {
-               ret = lis3l02dq_spi_write_reg_8(dev,
-                                               LIS3L02DQ_REG_WAKE_UP_CFG_ADDR,
-                                               &valold);
-               if (ret)
-                       goto error_mutex_unlock;
-               /* This always enables the interrupt, even if we've remove the
-                * last thing using it. For this device we can use the reference
-                * count on the handler to tell us if anyone wants the interrupt
-                */
-               controlold = this_attr->listel->refcount ?
-                       (controlold | LIS3L02DQ_REG_CTRL_2_ENABLE_INTERRUPT) :
-                       (controlold & ~LIS3L02DQ_REG_CTRL_2_ENABLE_INTERRUPT);
-               ret = lis3l02dq_spi_write_reg_8(dev,
-                                               LIS3L02DQ_REG_CTRL_2_ADDR,
-                                               &controlold);
-               if (ret)
-                       goto error_mutex_unlock;
-       }
-error_mutex_unlock:
-       mutex_unlock(&indio_dev->mlock);
-
-       return ret ? ret : len;
-}
-
-
-static int lis3l02dq_thresh_handler_th(struct iio_dev *indio_dev,
-                                      int index,
-                                      s64 timestamp,
-                                      int no_test)
-{
-       struct iio_sw_ring_helper_state *h
-               = iio_dev_get_devdata(indio_dev);
-       struct lis3l02dq_state *st = lis3l02dq_h_to_s(h);
-
-       /* Stash the timestamp somewhere convenient for the bh */
-       st->thresh_timestamp = timestamp;
-       schedule_work(&st->work_thresh);
-
-       return 0;
-}
-
-
-/* Unforunately it appears the interrupt won't clear unless you read from the
- * src register.
- */
-static void lis3l02dq_thresh_handler_bh_no_check(struct work_struct *work_s)
+static irqreturn_t lis3l02dq_event_handler(int irq, void *private)
 {
-       struct lis3l02dq_state *st
-              = container_of(work_s,
-                      struct lis3l02dq_state, work_thresh);
-
+       struct iio_dev *indio_dev = private;
        u8 t;
 
-       lis3l02dq_spi_read_reg_8(&st->help.indio_dev->dev,
+       s64 timestamp = iio_get_time_ns();
+
+       lis3l02dq_spi_read_reg_8(indio_dev,
                                 LIS3L02DQ_REG_WAKE_UP_SRC_ADDR,
                                 &t);
 
        if (t & LIS3L02DQ_REG_WAKE_UP_SRC_INTERRUPT_Z_HIGH)
-               iio_push_event(st->help.indio_dev, 0,
+               iio_push_event(indio_dev, 0,
                               IIO_MOD_EVENT_CODE(IIO_EV_CLASS_ACCEL,
                                                  0,
                                                  IIO_EV_MOD_Z,
                                                  IIO_EV_TYPE_THRESH,
                                                  IIO_EV_DIR_RISING),
-                              st->thresh_timestamp);
+                              timestamp);
 
        if (t & LIS3L02DQ_REG_WAKE_UP_SRC_INTERRUPT_Z_LOW)
-               iio_push_event(st->help.indio_dev, 0,
+               iio_push_event(indio_dev, 0,
                               IIO_MOD_EVENT_CODE(IIO_EV_CLASS_ACCEL,
                                                  0,
                                                  IIO_EV_MOD_Z,
                                                  IIO_EV_TYPE_THRESH,
                                                  IIO_EV_DIR_FALLING),
-                              st->thresh_timestamp);
+                              timestamp);
 
        if (t & LIS3L02DQ_REG_WAKE_UP_SRC_INTERRUPT_Y_HIGH)
-               iio_push_event(st->help.indio_dev, 0,
+               iio_push_event(indio_dev, 0,
                               IIO_MOD_EVENT_CODE(IIO_EV_CLASS_ACCEL,
                                                  0,
                                                  IIO_EV_MOD_Y,
                                                  IIO_EV_TYPE_THRESH,
                                                  IIO_EV_DIR_RISING),
-                              st->thresh_timestamp);
+                              timestamp);
 
        if (t & LIS3L02DQ_REG_WAKE_UP_SRC_INTERRUPT_Y_LOW)
-               iio_push_event(st->help.indio_dev, 0,
+               iio_push_event(indio_dev, 0,
                               IIO_MOD_EVENT_CODE(IIO_EV_CLASS_ACCEL,
                                                  0,
                                                  IIO_EV_MOD_Y,
                                                  IIO_EV_TYPE_THRESH,
                                                  IIO_EV_DIR_FALLING),
-                              st->thresh_timestamp);
+                              timestamp);
 
        if (t & LIS3L02DQ_REG_WAKE_UP_SRC_INTERRUPT_X_HIGH)
-               iio_push_event(st->help.indio_dev, 0,
+               iio_push_event(indio_dev, 0,
                               IIO_MOD_EVENT_CODE(IIO_EV_CLASS_ACCEL,
                                                  0,
                                                  IIO_EV_MOD_X,
                                                  IIO_EV_TYPE_THRESH,
                                                  IIO_EV_DIR_RISING),
-                              st->thresh_timestamp);
+                              timestamp);
 
        if (t & LIS3L02DQ_REG_WAKE_UP_SRC_INTERRUPT_X_LOW)
-               iio_push_event(st->help.indio_dev, 0,
+               iio_push_event(indio_dev, 0,
                               IIO_MOD_EVENT_CODE(IIO_EV_CLASS_ACCEL,
                                                  0,
                                                  IIO_EV_MOD_X,
                                                  IIO_EV_TYPE_THRESH,
                                                  IIO_EV_DIR_FALLING),
-                              st->thresh_timestamp);
-       /* reenable the irq */
-       enable_irq(st->us->irq);
+                              timestamp);
+
        /* Ack and allow for new interrupts */
-       lis3l02dq_spi_read_reg_8(&st->help.indio_dev->dev,
+       lis3l02dq_spi_read_reg_8(indio_dev,
                                 LIS3L02DQ_REG_WAKE_UP_ACK_ADDR,
                                 &t);
 
-       return;
+       return IRQ_HANDLED;
 }
 
-/* A shared handler for a number of threshold types */
-IIO_EVENT_SH(threshold, &lis3l02dq_thresh_handler_th);
-
-IIO_EVENT_ATTR_SH(accel_x_thresh_rising_en,
-                 iio_event_threshold,
-                 lis3l02dq_read_interrupt_config,
-                 lis3l02dq_write_interrupt_config,
-                 LIS3L02DQ_REG_WAKE_UP_CFG_INTERRUPT_X_HIGH);
-
-IIO_EVENT_ATTR_SH(accel_y_thresh_rising_en,
-                 iio_event_threshold,
-                 lis3l02dq_read_interrupt_config,
-                 lis3l02dq_write_interrupt_config,
-                 LIS3L02DQ_REG_WAKE_UP_CFG_INTERRUPT_Y_HIGH);
-
-IIO_EVENT_ATTR_SH(accel_z_thresh_rising_en,
-                 iio_event_threshold,
-                 lis3l02dq_read_interrupt_config,
-                 lis3l02dq_write_interrupt_config,
-                 LIS3L02DQ_REG_WAKE_UP_CFG_INTERRUPT_Z_HIGH);
-
-IIO_EVENT_ATTR_SH(accel_x_thresh_falling_en,
-                 iio_event_threshold,
-                 lis3l02dq_read_interrupt_config,
-                 lis3l02dq_write_interrupt_config,
-                 LIS3L02DQ_REG_WAKE_UP_CFG_INTERRUPT_X_LOW);
-
-IIO_EVENT_ATTR_SH(accel_y_thresh_falling_en,
-                 iio_event_threshold,
-                 lis3l02dq_read_interrupt_config,
-                 lis3l02dq_write_interrupt_config,
-                 LIS3L02DQ_REG_WAKE_UP_CFG_INTERRUPT_Y_LOW);
-
-IIO_EVENT_ATTR_SH(accel_z_thresh_falling_en,
-                 iio_event_threshold,
-                 lis3l02dq_read_interrupt_config,
-                 lis3l02dq_write_interrupt_config,
-                 LIS3L02DQ_REG_WAKE_UP_CFG_INTERRUPT_Z_LOW);
-
-
-static struct attribute *lis3l02dq_event_attributes[] = {
-       &iio_event_attr_accel_x_thresh_rising_en.dev_attr.attr,
-       &iio_event_attr_accel_y_thresh_rising_en.dev_attr.attr,
-       &iio_event_attr_accel_z_thresh_rising_en.dev_attr.attr,
-       &iio_event_attr_accel_x_thresh_falling_en.dev_attr.attr,
-       &iio_event_attr_accel_y_thresh_falling_en.dev_attr.attr,
-       &iio_event_attr_accel_z_thresh_falling_en.dev_attr.attr,
-       &iio_dev_attr_accel_raw_mag_value.dev_attr.attr,
-       NULL
+#define LIS3L02DQ_INFO_MASK                            \
+       ((1 << IIO_CHAN_INFO_SCALE_SHARED) |            \
+        (1 << IIO_CHAN_INFO_CALIBSCALE_SEPARATE) |     \
+        (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE))
+
+#define LIS3L02DQ_EVENT_MASK                                   \
+       (IIO_EV_BIT(IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING) |    \
+        IIO_EV_BIT(IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING))
+
+static struct iio_chan_spec lis3l02dq_channels[] = {
+       IIO_CHAN(IIO_ACCEL, 1, 0, 0, NULL, 0, IIO_MOD_X, LIS3L02DQ_INFO_MASK,
+                0, 0, IIO_ST('s', 12, 16, 0), LIS3L02DQ_EVENT_MASK),
+       IIO_CHAN(IIO_ACCEL, 1, 0, 0, NULL, 0, IIO_MOD_Y, LIS3L02DQ_INFO_MASK,
+                1, 1, IIO_ST('s', 12, 16, 0), LIS3L02DQ_EVENT_MASK),
+       IIO_CHAN(IIO_ACCEL, 1, 0, 0, NULL, 0, IIO_MOD_Z, LIS3L02DQ_INFO_MASK,
+                2, 2, IIO_ST('s', 12, 16, 0), LIS3L02DQ_EVENT_MASK),
+       IIO_CHAN_SOFT_TIMESTAMP(3)
 };
 
-static struct attribute_group lis3l02dq_event_attribute_group = {
-       .attrs = lis3l02dq_event_attributes,
-};
 
-static IIO_CONST_ATTR_NAME("lis3l02dq");
-static IIO_CONST_ATTR(accel_scale, "0.00958");
+static ssize_t lis3l02dq_read_event_config(struct iio_dev *indio_dev,
+                                          int event_code)
+{
+
+       u8 val;
+       int ret;
+       u8 mask = (1 << (IIO_EVENT_CODE_EXTRACT_MODIFIER(event_code)*2 +
+                        (IIO_EVENT_CODE_EXTRACT_DIR(event_code) ==
+                         IIO_EV_DIR_RISING)));
+       ret = lis3l02dq_spi_read_reg_8(indio_dev,
+                                      LIS3L02DQ_REG_WAKE_UP_CFG_ADDR,
+                                      &val);
+       if (ret < 0)
+               return ret;
+
+       return !!(val & mask);
+}
+
+int lis3l02dq_disable_all_events(struct iio_dev *indio_dev)
+{
+       int ret;
+       u8 control, val;
+
+       ret = lis3l02dq_spi_read_reg_8(indio_dev,
+                                      LIS3L02DQ_REG_CTRL_2_ADDR,
+                                      &control);
+
+       control &= ~LIS3L02DQ_REG_CTRL_2_ENABLE_INTERRUPT;
+       ret = lis3l02dq_spi_write_reg_8(indio_dev,
+                                       LIS3L02DQ_REG_CTRL_2_ADDR,
+                                       control);
+       if (ret)
+               goto error_ret;
+       /* Also for consistency clear the mask */
+       ret = lis3l02dq_spi_read_reg_8(indio_dev,
+                                      LIS3L02DQ_REG_WAKE_UP_CFG_ADDR,
+                                      &val);
+       if (ret)
+               goto error_ret;
+       val &= ~0x3f;
+
+       ret = lis3l02dq_spi_write_reg_8(indio_dev,
+                                       LIS3L02DQ_REG_WAKE_UP_CFG_ADDR,
+                                       val);
+       if (ret)
+               goto error_ret;
+
+       ret = control;
+error_ret:
+       return ret;
+}
+
+static int lis3l02dq_write_event_config(struct iio_dev *indio_dev,
+                                       int event_code,
+                                       int state)
+{
+       int ret = 0;
+       u8 val, control;
+       u8 currentlyset;
+       bool changed = false;
+       u8 mask = (1 << (IIO_EVENT_CODE_EXTRACT_MODIFIER(event_code)*2 +
+                        (IIO_EVENT_CODE_EXTRACT_DIR(event_code) ==
+                         IIO_EV_DIR_RISING)));
+
+       mutex_lock(&indio_dev->mlock);
+       /* read current control */
+       ret = lis3l02dq_spi_read_reg_8(indio_dev,
+                                      LIS3L02DQ_REG_CTRL_2_ADDR,
+                                      &control);
+       if (ret)
+               goto error_ret;
+       ret = lis3l02dq_spi_read_reg_8(indio_dev,
+                                      LIS3L02DQ_REG_WAKE_UP_CFG_ADDR,
+                                      &val);
+       if (ret < 0)
+               goto error_ret;
+       currentlyset = val & mask;
+
+       if (!currentlyset && state) {
+               changed = true;
+               val |= mask;
+       } else if (currentlyset && !state) {
+               changed = true;
+               val &= ~mask;
+       }
+
+       if (changed) {
+               ret = lis3l02dq_spi_write_reg_8(indio_dev,
+                                               LIS3L02DQ_REG_WAKE_UP_CFG_ADDR,
+                                               val);
+               if (ret)
+                       goto error_ret;
+               control = val & 0x3f ?
+                       (control | LIS3L02DQ_REG_CTRL_2_ENABLE_INTERRUPT) :
+                       (control & ~LIS3L02DQ_REG_CTRL_2_ENABLE_INTERRUPT);
+               ret = lis3l02dq_spi_write_reg_8(indio_dev,
+                                              LIS3L02DQ_REG_CTRL_2_ADDR,
+                                              control);
+               if (ret)
+                       goto error_ret;
+       }
+
+error_ret:
+       mutex_unlock(&indio_dev->mlock);
+       return ret;
+}
 
 static struct attribute *lis3l02dq_attributes[] = {
-       &iio_dev_attr_accel_x_calibbias.dev_attr.attr,
-       &iio_dev_attr_accel_y_calibbias.dev_attr.attr,
-       &iio_dev_attr_accel_z_calibbias.dev_attr.attr,
-       &iio_dev_attr_accel_x_calibscale.dev_attr.attr,
-       &iio_dev_attr_accel_y_calibscale.dev_attr.attr,
-       &iio_dev_attr_accel_z_calibscale.dev_attr.attr,
-       &iio_const_attr_accel_scale.dev_attr.attr,
-       &iio_dev_attr_accel_x_raw.dev_attr.attr,
-       &iio_dev_attr_accel_y_raw.dev_attr.attr,
-       &iio_dev_attr_accel_z_raw.dev_attr.attr,
        &iio_dev_attr_sampling_frequency.dev_attr.attr,
        &iio_const_attr_sampling_frequency_available.dev_attr.attr,
-       &iio_const_attr_name.dev_attr.attr,
        NULL
 };
 
@@ -779,103 +651,96 @@ static const struct attribute_group lis3l02dq_attribute_group = {
        .attrs = lis3l02dq_attributes,
 };
 
+static const struct iio_info lis3l02dq_info = {
+       .num_interrupt_lines = 1,
+       .read_raw = &lis3l02dq_read_raw,
+       .write_raw = &lis3l02dq_write_raw,
+       .read_event_value = &lis3l02dq_read_thresh,
+       .write_event_value = &lis3l02dq_write_thresh,
+       .write_event_config = &lis3l02dq_write_event_config,
+       .read_event_config = &lis3l02dq_read_event_config,
+       .driver_module = THIS_MODULE,
+       .attrs = &lis3l02dq_attribute_group,
+};
+
 static int __devinit lis3l02dq_probe(struct spi_device *spi)
 {
        int ret, regdone = 0;
-       struct lis3l02dq_state *st = kzalloc(sizeof *st, GFP_KERNEL);
-       if (!st) {
-               ret =  -ENOMEM;
+       struct lis3l02dq_state *st;
+       struct iio_dev *indio_dev;
+
+       indio_dev = iio_allocate_device(sizeof *st);
+       if (indio_dev == NULL) {
+               ret = -ENOMEM;
                goto error_ret;
        }
-       INIT_WORK(&st->work_thresh, lis3l02dq_thresh_handler_bh_no_check);
+       st = iio_priv(indio_dev);
        /* this is only used tor removal purposes */
        spi_set_drvdata(spi, st);
 
-       /* Allocate the comms buffers */
-       st->rx = kzalloc(sizeof(*st->rx)*LIS3L02DQ_MAX_RX, GFP_KERNEL);
-       if (st->rx == NULL) {
-               ret = -ENOMEM;
-               goto error_free_st;
-       }
-       st->tx = kzalloc(sizeof(*st->tx)*LIS3L02DQ_MAX_TX, GFP_KERNEL);
-       if (st->tx == NULL) {
-               ret = -ENOMEM;
-               goto error_free_rx;
-       }
        st->us = spi;
        mutex_init(&st->buf_lock);
-       /* setup the industrialio driver allocated elements */
-       st->help.indio_dev = iio_allocate_device();
-       if (st->help.indio_dev == NULL) {
-               ret = -ENOMEM;
-               goto error_free_tx;
-       }
+       indio_dev->name = spi->dev.driver->name;
+       indio_dev->dev.parent = &spi->dev;
+       indio_dev->info = &lis3l02dq_info;
+       indio_dev->channels = lis3l02dq_channels;
+       indio_dev->num_channels = ARRAY_SIZE(lis3l02dq_channels);
 
-       st->help.indio_dev->dev.parent = &spi->dev;
-       st->help.indio_dev->num_interrupt_lines = 1;
-       st->help.indio_dev->event_attrs = &lis3l02dq_event_attribute_group;
-       st->help.indio_dev->attrs = &lis3l02dq_attribute_group;
-       st->help.indio_dev->dev_data = (void *)(&st->help);
-       st->help.indio_dev->driver_module = THIS_MODULE;
-       st->help.indio_dev->modes = INDIO_DIRECT_MODE;
+       indio_dev->modes = INDIO_DIRECT_MODE;
 
-       ret = lis3l02dq_configure_ring(st->help.indio_dev);
+       ret = lis3l02dq_configure_ring(indio_dev);
        if (ret)
                goto error_free_dev;
 
-       ret = iio_device_register(st->help.indio_dev);
+       ret = iio_device_register(indio_dev);
        if (ret)
                goto error_unreg_ring_funcs;
        regdone = 1;
 
-       ret = iio_ring_buffer_register(st->help.indio_dev->ring, 0);
+       ret = iio_ring_buffer_register_ex(indio_dev->ring, 0,
+                                         lis3l02dq_channels,
+                                         ARRAY_SIZE(lis3l02dq_channels));
        if (ret) {
                printk(KERN_ERR "failed to initialize the ring\n");
                goto error_unreg_ring_funcs;
        }
 
        if (spi->irq && gpio_is_valid(irq_to_gpio(spi->irq)) > 0) {
-               st->inter = 0;
-               ret = iio_register_interrupt_line(spi->irq,
-                                                 st->help.indio_dev,
-                                                 0,
-                                                 IRQF_TRIGGER_RISING,
-                                                 "lis3l02dq");
+               ret = request_threaded_irq(st->us->irq,
+                                          &lis3l02dq_th,
+                                          &lis3l02dq_event_handler,
+                                          IRQF_TRIGGER_RISING,
+                                          "lis3l02dq",
+                                          indio_dev);
                if (ret)
                        goto error_uninitialize_ring;
 
-               ret = lis3l02dq_probe_trigger(st->help.indio_dev);
+               ret = lis3l02dq_probe_trigger(indio_dev);
                if (ret)
-                       goto error_unregister_line;
+                       goto error_free_interrupt;
        }
 
        /* Get the device into a sane initial state */
-       ret = lis3l02dq_initial_setup(st);
+       ret = lis3l02dq_initial_setup(indio_dev);
        if (ret)
                goto error_remove_trigger;
        return 0;
 
 error_remove_trigger:
-       if (st->help.indio_dev->modes & INDIO_RING_TRIGGERED)
-               lis3l02dq_remove_trigger(st->help.indio_dev);
-error_unregister_line:
-       if (st->help.indio_dev->modes & INDIO_RING_TRIGGERED)
-               iio_unregister_interrupt_line(st->help.indio_dev, 0);
+       if (indio_dev->modes & INDIO_RING_TRIGGERED)
+               lis3l02dq_remove_trigger(indio_dev);
+error_free_interrupt:
+       if (spi->irq && gpio_is_valid(irq_to_gpio(spi->irq)) > 0)
+               free_irq(st->us->irq, indio_dev);
 error_uninitialize_ring:
-       iio_ring_buffer_unregister(st->help.indio_dev->ring);
+       iio_ring_buffer_unregister(indio_dev->ring);
 error_unreg_ring_funcs:
-       lis3l02dq_unconfigure_ring(st->help.indio_dev);
+       lis3l02dq_unconfigure_ring(indio_dev);
 error_free_dev:
        if (regdone)
-               iio_device_unregister(st->help.indio_dev);
+               iio_device_unregister(indio_dev);
        else
-               iio_free_device(st->help.indio_dev);
-error_free_tx:
-       kfree(st->tx);
-error_free_rx:
-       kfree(st->rx);
-error_free_st:
-       kfree(st);
+               iio_free_device(indio_dev);
 error_ret:
        return ret;
 }
@@ -884,23 +749,21 @@ error_ret:
 static int lis3l02dq_stop_device(struct iio_dev *indio_dev)
 {
        int ret;
-       struct iio_sw_ring_helper_state *h
-               = iio_dev_get_devdata(indio_dev);
-       struct lis3l02dq_state *st = lis3l02dq_h_to_s(h);
+       struct lis3l02dq_state *st = iio_priv(indio_dev);
        u8 val = 0;
 
        mutex_lock(&indio_dev->mlock);
-       ret = lis3l02dq_spi_write_reg_8(&indio_dev->dev,
+       ret = lis3l02dq_spi_write_reg_8(indio_dev,
                                        LIS3L02DQ_REG_CTRL_1_ADDR,
-                                       &val);
+                                       val);
        if (ret) {
                dev_err(&st->us->dev, "problem with turning device off: ctrl1");
                goto err_ret;
        }
 
-       ret = lis3l02dq_spi_write_reg_8(&indio_dev->dev,
+       ret = lis3l02dq_spi_write_reg_8(indio_dev,
                                        LIS3L02DQ_REG_CTRL_2_ADDR,
-                                       &val);
+                                       val);
        if (ret)
                dev_err(&st->us->dev, "problem with turning device off: ctrl2");
 err_ret:
@@ -912,25 +775,24 @@ err_ret:
 static int lis3l02dq_remove(struct spi_device *spi)
 {
        int ret;
-       struct lis3l02dq_state *st = spi_get_drvdata(spi);
-       struct iio_dev *indio_dev = st->help.indio_dev;
+       struct iio_dev *indio_dev = spi_get_drvdata(spi);
+       struct lis3l02dq_state *st = iio_priv(indio_dev);
 
-       ret = lis3l02dq_stop_device(indio_dev);
+       ret = lis3l02dq_disable_all_events(indio_dev);
        if (ret)
                goto err_ret;
 
-       flush_scheduled_work();
+       ret = lis3l02dq_stop_device(indio_dev);
+       if (ret)
+               goto err_ret;
 
-       lis3l02dq_remove_trigger(indio_dev);
        if (spi->irq && gpio_is_valid(irq_to_gpio(spi->irq)) > 0)
-               iio_unregister_interrupt_line(indio_dev, 0);
+               free_irq(st->us->irq, indio_dev);
 
+       lis3l02dq_remove_trigger(indio_dev);
        iio_ring_buffer_unregister(indio_dev->ring);
        lis3l02dq_unconfigure_ring(indio_dev);
        iio_device_unregister(indio_dev);
-       kfree(st->tx);
-       kfree(st->rx);
-       kfree(st);
 
        return 0;
 
index 529a3cc6d0c748bcd902ff897a380f24b82a3595..8d5c8ac7db5197f8b0334ccc11a8be128605376c 100644 (file)
@@ -1,13 +1,11 @@
 #include <linux/interrupt.h>
 #include <linux/irq.h>
 #include <linux/gpio.h>
-#include <linux/workqueue.h>
 #include <linux/mutex.h>
 #include <linux/device.h>
 #include <linux/kernel.h>
 #include <linux/spi/spi.h>
 #include <linux/sysfs.h>
-#include <linux/list.h>
 #include <linux/slab.h>
 
 #include "../iio.h"
@@ -29,180 +27,49 @@ static inline u16 combine_8_to_16(u8 lower, u8 upper)
 }
 
 /**
- * lis3l02dq_scan_el_set_state() set whether a scan contains a given channel
- * @scan_el:   associtate iio scan element attribute
- * @indio_dev: the device structure
- * @bool:      desired state
- *
- * mlock already held when this is called.
- **/
-static int lis3l02dq_scan_el_set_state(struct iio_scan_el *scan_el,
-                                      struct iio_dev *indio_dev,
-                                      bool state)
-{
-       u8 t, mask;
-       int ret;
-
-       ret = lis3l02dq_spi_read_reg_8(&indio_dev->dev,
-                                      LIS3L02DQ_REG_CTRL_1_ADDR,
-                                      &t);
-       if (ret)
-               goto error_ret;
-       switch (scan_el->label) {
-       case LIS3L02DQ_REG_OUT_X_L_ADDR:
-               mask = LIS3L02DQ_REG_CTRL_1_AXES_X_ENABLE;
-               break;
-       case LIS3L02DQ_REG_OUT_Y_L_ADDR:
-               mask = LIS3L02DQ_REG_CTRL_1_AXES_Y_ENABLE;
-               break;
-       case LIS3L02DQ_REG_OUT_Z_L_ADDR:
-               mask = LIS3L02DQ_REG_CTRL_1_AXES_Z_ENABLE;
-               break;
-       default:
-               ret = -EINVAL;
-               goto error_ret;
-       }
-
-       if (!(mask & t) == state) {
-               if (state)
-                       t |= mask;
-               else
-                       t &= ~mask;
-               ret = lis3l02dq_spi_write_reg_8(&indio_dev->dev,
-                                               LIS3L02DQ_REG_CTRL_1_ADDR,
-                                               &t);
-       }
-error_ret:
-       return ret;
-
-}
-static IIO_SCAN_EL_C(accel_x, 0,
-                    LIS3L02DQ_REG_OUT_X_L_ADDR,
-                    &lis3l02dq_scan_el_set_state);
-static IIO_SCAN_EL_C(accel_y, 1,
-                    LIS3L02DQ_REG_OUT_Y_L_ADDR,
-                    &lis3l02dq_scan_el_set_state);
-static IIO_SCAN_EL_C(accel_z, 2,
-                    LIS3L02DQ_REG_OUT_Z_L_ADDR,
-                    &lis3l02dq_scan_el_set_state);
-static IIO_CONST_ATTR_SCAN_EL_TYPE(accel, s, 12, 16);
-static IIO_SCAN_EL_TIMESTAMP(3);
-static IIO_CONST_ATTR_SCAN_EL_TYPE(timestamp, s, 64, 64);
-
-static struct attribute *lis3l02dq_scan_el_attrs[] = {
-       &iio_scan_el_accel_x.dev_attr.attr,
-       &iio_const_attr_accel_x_index.dev_attr.attr,
-       &iio_scan_el_accel_y.dev_attr.attr,
-       &iio_const_attr_accel_y_index.dev_attr.attr,
-       &iio_scan_el_accel_z.dev_attr.attr,
-       &iio_const_attr_accel_z_index.dev_attr.attr,
-       &iio_const_attr_accel_type.dev_attr.attr,
-       &iio_scan_el_timestamp.dev_attr.attr,
-       &iio_const_attr_timestamp_index.dev_attr.attr,
-       &iio_const_attr_timestamp_type.dev_attr.attr,
-       NULL,
-};
-
-static struct attribute_group lis3l02dq_scan_el_group = {
-       .attrs = lis3l02dq_scan_el_attrs,
-       .name = "scan_elements",
-};
-
-/**
- * lis3l02dq_poll_func_th() top half interrupt handler called by trigger
- * @private_data:      iio_dev
+ * lis3l02dq_data_rdy_trig_poll() the event handler for the data rdy trig
  **/
-static void lis3l02dq_poll_func_th(struct iio_dev *indio_dev, s64 time)
+irqreturn_t lis3l02dq_data_rdy_trig_poll(int irq, void *private)
 {
-       struct iio_sw_ring_helper_state *h
-               = iio_dev_get_devdata(indio_dev);
-       struct lis3l02dq_state *st = lis3l02dq_h_to_s(h);
-       /* in this case we need to slightly extend the helper function */
-       iio_sw_poll_func_th(indio_dev, time);
-
-       /* Indicate that this interrupt is being handled */
-       /* Technically this is trigger related, but without this
-        * handler running there is currently now way for the interrupt
-        * to clear.
-        */
-       st->inter = 1;
+       struct iio_dev *indio_dev = private;
+       struct lis3l02dq_state *st = iio_priv(indio_dev);
+
+       if (st->trigger_on) {
+               iio_trigger_poll(st->trig, iio_get_time_ns());
+               return IRQ_HANDLED;
+       } else
+               return IRQ_WAKE_THREAD;
 }
 
 /**
- * lis3l02dq_data_rdy_trig_poll() the event handler for the data rdy trig
+ * lis3l02dq_read_accel_from_ring() individual acceleration read from ring
  **/
-static int lis3l02dq_data_rdy_trig_poll(struct iio_dev *indio_dev,
+ssize_t lis3l02dq_read_accel_from_ring(struct iio_ring_buffer *ring,
                                       int index,
-                                      s64 timestamp,
-                                      int no_test)
+                                      int *val)
 {
-       struct iio_sw_ring_helper_state *h
-               = iio_dev_get_devdata(indio_dev);
-       struct lis3l02dq_state *st = lis3l02dq_h_to_s(h);
-
-       iio_trigger_poll(st->trig, timestamp);
+       int ret;
+       s16 *data;
 
-       return IRQ_HANDLED;
-}
+       if (!iio_scan_mask_query(ring, index))
+               return -EINVAL;
 
-/* This is an event as it is a response to a physical interrupt */
-IIO_EVENT_SH(data_rdy_trig, &lis3l02dq_data_rdy_trig_poll);
+       if (!ring->access->read_last)
+               return -EBUSY;
 
-/**
- * lis3l02dq_read_accel_from_ring() individual acceleration read from ring
- **/
-ssize_t lis3l02dq_read_accel_from_ring(struct device *dev,
-                                      struct device_attribute *attr,
-                                      char *buf)
-{
-       struct iio_scan_el *el = NULL;
-       int ret, len = 0, i = 0;
-       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-       struct iio_dev *dev_info = dev_get_drvdata(dev);
-       struct iio_ring_buffer *ring = dev_info->ring;
-       struct attribute_group *scan_el_attrs = ring->scan_el_attrs;
-       s16 *data;
+       data = kmalloc(ring->access->get_bytes_per_datum(ring),
+                      GFP_KERNEL);
+       if (data == NULL)
+               return -ENOMEM;
 
-       while (scan_el_attrs->attrs[i]) {
-               el = to_iio_scan_el((struct device_attribute *)
-                                   (scan_el_attrs->attrs[i]));
-               /* label is in fact the address */
-               if (el->label == this_attr->address)
-                       break;
-               i++;
-       }
-       if (!scan_el_attrs->attrs[i]) {
-               ret = -EINVAL;
-               goto error_ret;
-       }
-       /* If this element is in the scan mask */
-       ret = iio_scan_mask_query(ring, el->number);
-       if (ret < 0)
-               goto error_ret;
-       if (ret) {
-               data = kmalloc(ring->access.get_bytes_per_datum(ring),
-                              GFP_KERNEL);
-               if (data == NULL)
-                       return -ENOMEM;
-               ret = ring->access.read_last(ring,
-                                       (u8 *)data);
-               if (ret)
-                       goto error_free_data;
-       } else {
-               ret = -EINVAL;
-               goto error_ret;
-       }
-       len = iio_scan_mask_count_to_right(ring, el->number);
-       if (len < 0) {
-               ret = len;
+       ret = ring->access->read_last(ring, (u8 *)data);
+       if (ret)
                goto error_free_data;
-       }
-       len = sprintf(buf, "ring %d\n", data[len]);
+       *val = data[bitmap_weight(&ring->scan_mask, index)];
 error_free_data:
        kfree(data);
-error_ret:
-       return ret ? ret : len;
 
+       return ret;
 }
 
 static const u8 read_all_tx_array[] = {
@@ -220,9 +87,10 @@ static const u8 read_all_tx_array[] = {
  * @rx_array:  (dma capable) receive array, must be at least
  *             4*number of channels
  **/
-static int lis3l02dq_read_all(struct lis3l02dq_state *st, u8 *rx_array)
+static int lis3l02dq_read_all(struct iio_dev *indio_dev, u8 *rx_array)
 {
-       struct iio_ring_buffer *ring = st->help.indio_dev->ring;
+       struct iio_ring_buffer *ring = indio_dev->ring;
+       struct lis3l02dq_state *st = iio_priv(indio_dev);
        struct spi_transfer *xfers;
        struct spi_message msg;
        int ret, i, j = 0;
@@ -234,7 +102,7 @@ static int lis3l02dq_read_all(struct lis3l02dq_state *st, u8 *rx_array)
 
        mutex_lock(&st->buf_lock);
 
-       for (i = 0; i < ARRAY_SIZE(read_all_tx_array)/4; i++) {
+       for (i = 0; i < ARRAY_SIZE(read_all_tx_array)/4; i++)
                if (ring->scan_mask & (1 << i)) {
                        /* lower byte */
                        xfers[j].tx_buf = st->tx + 2*j;
@@ -258,7 +126,7 @@ static int lis3l02dq_read_all(struct lis3l02dq_state *st, u8 *rx_array)
                        xfers[j].cs_change = 1;
                        j++;
                }
-       }
+
        /* After these are transmitted, the rx_buff should have
         * values in alternate bytes
         */
@@ -273,31 +141,20 @@ static int lis3l02dq_read_all(struct lis3l02dq_state *st, u8 *rx_array)
        return ret;
 }
 
-static void lis3l02dq_trigger_bh_to_ring(struct work_struct *work_s)
-{
-       struct iio_sw_ring_helper_state *h
-               = container_of(work_s, struct iio_sw_ring_helper_state,
-                       work_trigger_to_ring);
-       struct lis3l02dq_state *st = lis3l02dq_h_to_s(h);
-
-       st->inter = 0;
-       iio_sw_trigger_bh_to_ring(work_s);
-}
-
-static int lis3l02dq_get_ring_element(struct iio_sw_ring_helper_state *h,
+static int lis3l02dq_get_ring_element(struct iio_dev *indio_dev,
                                u8 *buf)
 {
        int ret, i;
        u8 *rx_array ;
        s16 *data = (s16 *)buf;
 
-       rx_array = kzalloc(4 * (h->indio_dev->ring->scan_count), GFP_KERNEL);
+       rx_array = kzalloc(4 * (indio_dev->ring->scan_count), GFP_KERNEL);
        if (rx_array == NULL)
                return -ENOMEM;
-       ret = lis3l02dq_read_all(lis3l02dq_h_to_s(h), rx_array);
+       ret = lis3l02dq_read_all(indio_dev, rx_array);
        if (ret < 0)
                return ret;
-       for (i = 0; i < h->indio_dev->ring->scan_count; i++)
+       for (i = 0; i < indio_dev->ring->scan_count; i++)
                data[i] = combine_8_to_16(rx_array[i*4+1],
                                        rx_array[i*4+3]);
        kfree(rx_array);
@@ -305,19 +162,48 @@ static int lis3l02dq_get_ring_element(struct iio_sw_ring_helper_state *h,
        return i*sizeof(data[0]);
 }
 
+static irqreturn_t lis3l02dq_trigger_handler(int irq, void *p)
+{
+       struct iio_poll_func *pf = p;
+       struct iio_dev *indio_dev = pf->private_data;
+       struct iio_ring_buffer *ring = indio_dev->ring;
+       int len = 0;
+       size_t datasize = ring->access->get_bytes_per_datum(ring);
+       char *data = kmalloc(datasize, GFP_KERNEL);
+
+       if (data == NULL) {
+               dev_err(indio_dev->dev.parent,
+                       "memory alloc failed in ring bh");
+               return -ENOMEM;
+       }
+
+       if (ring->scan_count)
+               len = lis3l02dq_get_ring_element(indio_dev, data);
+
+         /* Guaranteed to be aligned with 8 byte boundary */
+       if (ring->scan_timestamp)
+               *(s64 *)(((phys_addr_t)data + len
+                               + sizeof(s64) - 1) & ~(sizeof(s64) - 1))
+                       = pf->timestamp;
+       ring->access->store_to(ring, (u8 *)data, pf->timestamp);
+
+       iio_trigger_notify_done(indio_dev->trig);
+       kfree(data);
+       return IRQ_HANDLED;
+}
+
 /* Caller responsible for locking as necessary. */
 static int
-__lis3l02dq_write_data_ready_config(struct device *dev,
-                                   struct iio_event_handler_list *list,
-                                   bool state)
+__lis3l02dq_write_data_ready_config(struct device *dev, bool state)
 {
        int ret;
        u8 valold;
        bool currentlyset;
        struct iio_dev *indio_dev = dev_get_drvdata(dev);
+       struct lis3l02dq_state *st = iio_priv(indio_dev);
 
 /* Get the current event mask register */
-       ret = lis3l02dq_spi_read_reg_8(dev,
+       ret = lis3l02dq_spi_read_reg_8(indio_dev,
                                       LIS3L02DQ_REG_CTRL_2_ADDR,
                                       &valold);
        if (ret)
@@ -328,32 +214,36 @@ __lis3l02dq_write_data_ready_config(struct device *dev,
 
 /* Disable requested */
        if (!state && currentlyset) {
-
+               /* disable the data ready signal */
                valold &= ~LIS3L02DQ_REG_CTRL_2_ENABLE_DATA_READY_GENERATION;
+
                /* The double write is to overcome a hardware bug?*/
-               ret = lis3l02dq_spi_write_reg_8(dev,
+               ret = lis3l02dq_spi_write_reg_8(indio_dev,
                                                LIS3L02DQ_REG_CTRL_2_ADDR,
-                                               &valold);
+                                               valold);
                if (ret)
                        goto error_ret;
-               ret = lis3l02dq_spi_write_reg_8(dev,
+               ret = lis3l02dq_spi_write_reg_8(indio_dev,
                                                LIS3L02DQ_REG_CTRL_2_ADDR,
-                                               &valold);
+                                               valold);
                if (ret)
                        goto error_ret;
-
-               iio_remove_event_from_list(list,
-                                          &indio_dev->interrupts[0]
-                                          ->ev_list);
-
+               st->trigger_on = false;
 /* Enable requested */
        } else if (state && !currentlyset) {
                /* if not set, enable requested */
-               valold |= LIS3L02DQ_REG_CTRL_2_ENABLE_DATA_READY_GENERATION;
-               iio_add_event_to_list(list, &indio_dev->interrupts[0]->ev_list);
-               ret = lis3l02dq_spi_write_reg_8(dev,
+               /* first disable all events */
+               ret = lis3l02dq_disable_all_events(indio_dev);
+               if (ret < 0)
+                       goto error_ret;
+
+               valold = ret |
+                       LIS3L02DQ_REG_CTRL_2_ENABLE_DATA_READY_GENERATION;
+
+               st->trigger_on = true;
+               ret = lis3l02dq_spi_write_reg_8(indio_dev,
                                                LIS3L02DQ_REG_CTRL_2_ADDR,
-                                               &valold);
+                                               valold);
                if (ret)
                        goto error_ret;
        }
@@ -373,65 +263,45 @@ error_ret:
 static int lis3l02dq_data_rdy_trigger_set_state(struct iio_trigger *trig,
                                                bool state)
 {
-       struct lis3l02dq_state *st = trig->private_data;
+       struct iio_dev *indio_dev = trig->private_data;
        int ret = 0;
        u8 t;
-       __lis3l02dq_write_data_ready_config(&st->help.indio_dev->dev,
-                                           &iio_event_data_rdy_trig,
-                                           state);
+
+       __lis3l02dq_write_data_ready_config(&indio_dev->dev, state);
        if (state == false) {
-               /* possible quirk with handler currently worked around
-                  by ensuring the work queue is empty */
-               flush_scheduled_work();
-               /* Clear any outstanding ready events */
-               ret = lis3l02dq_read_all(st, NULL);
+               /*
+                * A possible quirk with teh handler is currently worked around
+                *  by ensuring outstanding read events are cleared.
+                */
+               ret = lis3l02dq_read_all(indio_dev, NULL);
        }
-       lis3l02dq_spi_read_reg_8(&st->help.indio_dev->dev,
+       lis3l02dq_spi_read_reg_8(indio_dev,
                                 LIS3L02DQ_REG_WAKE_UP_SRC_ADDR,
                                 &t);
        return ret;
 }
 
-static IIO_TRIGGER_NAME_ATTR;
-
-static struct attribute *lis3l02dq_trigger_attrs[] = {
-       &dev_attr_name.attr,
-       NULL,
-};
-
-static const struct attribute_group lis3l02dq_trigger_attr_group = {
-       .attrs = lis3l02dq_trigger_attrs,
-};
-
 /**
  * lis3l02dq_trig_try_reen() try renabling irq for data rdy trigger
  * @trig:      the datardy trigger
- *
- * As the trigger may occur on any data element being updated it is
- * really rather likely to occur during the read from the previous
- * trigger event.  The only way to discover if this has occurred on
- * boards not supporting level interrupts is to take a look at the line.
- * If it is indicating another interrupt and we don't seem to have a
- * handler looking at it, then we need to notify the core that we need
- * to tell the triggering core to try reading all these again.
- **/
+ */
 static int lis3l02dq_trig_try_reen(struct iio_trigger *trig)
 {
-       struct lis3l02dq_state *st = trig->private_data;
-       enable_irq(st->us->irq);
+       struct iio_dev *indio_dev = trig->private_data;
+       struct lis3l02dq_state *st = iio_priv(indio_dev);
+       int i;
+
        /* If gpio still high (or high again) */
-       if (gpio_get_value(irq_to_gpio(st->us->irq)))
-               if (st->inter == 0) {
-                       /* already interrupt handler dealing with it */
-                       disable_irq_nosync(st->us->irq);
-                       if (st->inter == 1) {
-                               /* interrupt handler snuck in between test
-                                * and disable */
-                               enable_irq(st->us->irq);
-                               return 0;
-                       }
-                       return -EAGAIN;
-               }
+       /* In theory possible we will need to do this several times */
+       for (i = 0; i < 5; i++)
+               if (gpio_get_value(irq_to_gpio(st->us->irq)))
+                       lis3l02dq_read_all(indio_dev, NULL);
+               else
+                       break;
+       if (i == 5)
+               printk(KERN_INFO
+                      "Failed to clear the interrupt for lis3l02dq\n");
+
        /* irq reenabled so success! */
        return 0;
 }
@@ -439,62 +309,124 @@ static int lis3l02dq_trig_try_reen(struct iio_trigger *trig)
 int lis3l02dq_probe_trigger(struct iio_dev *indio_dev)
 {
        int ret;
-       struct lis3l02dq_state *state = indio_dev->dev_data;
+       struct lis3l02dq_state *st = iio_priv(indio_dev);
 
-       state->trig = iio_allocate_trigger();
-       if (!state->trig)
-               return -ENOMEM;
-
-       state->trig->name = kasprintf(GFP_KERNEL,
-                                     "lis3l02dq-dev%d",
-                                     indio_dev->id);
-       if (!state->trig->name) {
+       st->trig = iio_allocate_trigger("lis3l02dq-dev%d", indio_dev->id);
+       if (!st->trig) {
                ret = -ENOMEM;
-               goto error_free_trig;
+               goto error_ret;
        }
 
-       state->trig->dev.parent = &state->us->dev;
-       state->trig->owner = THIS_MODULE;
-       state->trig->private_data = state;
-       state->trig->set_trigger_state = &lis3l02dq_data_rdy_trigger_set_state;
-       state->trig->try_reenable = &lis3l02dq_trig_try_reen;
-       state->trig->control_attrs = &lis3l02dq_trigger_attr_group;
-       ret = iio_trigger_register(state->trig);
+       st->trig->dev.parent = &st->us->dev;
+       st->trig->owner = THIS_MODULE;
+       st->trig->private_data = indio_dev;
+       st->trig->set_trigger_state = &lis3l02dq_data_rdy_trigger_set_state;
+       st->trig->try_reenable = &lis3l02dq_trig_try_reen;
+       ret = iio_trigger_register(st->trig);
        if (ret)
-               goto error_free_trig_name;
+               goto error_free_trig;
 
        return 0;
 
-error_free_trig_name:
-       kfree(state->trig->name);
 error_free_trig:
-       iio_free_trigger(state->trig);
-
+       iio_free_trigger(st->trig);
+error_ret:
        return ret;
 }
 
 void lis3l02dq_remove_trigger(struct iio_dev *indio_dev)
 {
-       struct lis3l02dq_state *state = indio_dev->dev_data;
+       struct lis3l02dq_state *st = iio_priv(indio_dev);
 
-       iio_trigger_unregister(state->trig);
-       kfree(state->trig->name);
-       iio_free_trigger(state->trig);
+       iio_trigger_unregister(st->trig);
+       iio_free_trigger(st->trig);
 }
 
 void lis3l02dq_unconfigure_ring(struct iio_dev *indio_dev)
 {
-       kfree(indio_dev->pollfunc);
+       iio_dealloc_pollfunc(indio_dev->pollfunc);
        lis3l02dq_free_buf(indio_dev->ring);
 }
 
+static int lis3l02dq_ring_postenable(struct iio_dev *indio_dev)
+{
+       /* Disable unwanted channels otherwise the interrupt will not clear */
+       u8 t;
+       int ret;
+       bool oneenabled = false;
+
+       ret = lis3l02dq_spi_read_reg_8(indio_dev,
+                                      LIS3L02DQ_REG_CTRL_1_ADDR,
+                                      &t);
+       if (ret)
+               goto error_ret;
+
+       if (iio_scan_mask_query(indio_dev->ring, 0)) {
+               t |= LIS3L02DQ_REG_CTRL_1_AXES_X_ENABLE;
+               oneenabled = true;
+       } else
+               t &= ~LIS3L02DQ_REG_CTRL_1_AXES_X_ENABLE;
+       if (iio_scan_mask_query(indio_dev->ring, 1)) {
+               t |= LIS3L02DQ_REG_CTRL_1_AXES_Y_ENABLE;
+               oneenabled = true;
+       } else
+               t &= ~LIS3L02DQ_REG_CTRL_1_AXES_Y_ENABLE;
+       if (iio_scan_mask_query(indio_dev->ring, 2)) {
+               t |= LIS3L02DQ_REG_CTRL_1_AXES_Z_ENABLE;
+               oneenabled = true;
+       } else
+               t &= ~LIS3L02DQ_REG_CTRL_1_AXES_Z_ENABLE;
+
+       if (!oneenabled) /* what happens in this case is unknown */
+               return -EINVAL;
+       ret = lis3l02dq_spi_write_reg_8(indio_dev,
+                                       LIS3L02DQ_REG_CTRL_1_ADDR,
+                                       t);
+       if (ret)
+               goto error_ret;
+
+       return iio_triggered_ring_postenable(indio_dev);
+error_ret:
+       return ret;
+}
+
+/* Turn all channels on again */
+static int lis3l02dq_ring_predisable(struct iio_dev *indio_dev)
+{
+       u8 t;
+       int ret;
+
+       ret = iio_triggered_ring_predisable(indio_dev);
+       if (ret)
+               goto error_ret;
+
+       ret = lis3l02dq_spi_read_reg_8(indio_dev,
+                                      LIS3L02DQ_REG_CTRL_1_ADDR,
+                                      &t);
+       if (ret)
+               goto error_ret;
+       t |= LIS3L02DQ_REG_CTRL_1_AXES_X_ENABLE |
+               LIS3L02DQ_REG_CTRL_1_AXES_Y_ENABLE |
+               LIS3L02DQ_REG_CTRL_1_AXES_Z_ENABLE;
+
+       ret = lis3l02dq_spi_write_reg_8(indio_dev,
+                                       LIS3L02DQ_REG_CTRL_1_ADDR,
+                                       t);
+
+error_ret:
+       return ret;
+}
+
+static const struct iio_ring_setup_ops lis3l02dq_ring_setup_ops = {
+       .preenable = &iio_sw_ring_preenable,
+       .postenable = &lis3l02dq_ring_postenable,
+       .predisable = &lis3l02dq_ring_predisable,
+};
+
 int lis3l02dq_configure_ring(struct iio_dev *indio_dev)
 {
        int ret;
-       struct iio_sw_ring_helper_state *h = iio_dev_get_devdata(indio_dev);
        struct iio_ring_buffer *ring;
-       INIT_WORK(&h->work_trigger_to_ring, lis3l02dq_trigger_bh_to_ring);
-       h->get_ring_element = &lis3l02dq_get_ring_element;
 
        ring = lis3l02dq_alloc_buf(indio_dev);
        if (!ring)
@@ -502,23 +434,31 @@ int lis3l02dq_configure_ring(struct iio_dev *indio_dev)
 
        indio_dev->ring = ring;
        /* Effectively select the ring buffer implementation */
-       lis3l02dq_register_buf_funcs(&ring->access);
+       indio_dev->ring->access = &lis3l02dq_access_funcs;
        ring->bpe = 2;
-       ring->scan_el_attrs = &lis3l02dq_scan_el_group;
+
        ring->scan_timestamp = true;
-       ring->preenable = &iio_sw_ring_preenable;
-       ring->postenable = &iio_triggered_ring_postenable;
-       ring->predisable = &iio_triggered_ring_predisable;
+       ring->setup_ops = &lis3l02dq_ring_setup_ops;
        ring->owner = THIS_MODULE;
 
        /* Set default scan mode */
-       iio_scan_mask_set(ring, iio_scan_el_accel_x.number);
-       iio_scan_mask_set(ring, iio_scan_el_accel_y.number);
-       iio_scan_mask_set(ring, iio_scan_el_accel_z.number);
-
-       ret = iio_alloc_pollfunc(indio_dev, NULL, &lis3l02dq_poll_func_th);
-       if (ret)
+       iio_scan_mask_set(ring, 0);
+       iio_scan_mask_set(ring, 1);
+       iio_scan_mask_set(ring, 2);
+
+       /* Functions are NULL as we set handler below */
+       indio_dev->pollfunc = iio_alloc_pollfunc(&iio_pollfunc_store_time,
+                                                &lis3l02dq_trigger_handler,
+                                                0,
+                                                indio_dev,
+                                                "lis3l02dq_consumer%d",
+                                                indio_dev->id);
+
+       if (indio_dev->pollfunc == NULL) {
+               ret = -ENOMEM;
                goto error_iio_sw_rb_free;
+       }
+
        indio_dev->modes |= INDIO_RING_TRIGGERED;
        return 0;
 
index db710334b99b5787cbcddc6df258c60c41aaa856..cf0751d917a950855cf33b64cba4559a58ddd808 100644 (file)
 
 /**
  * struct sca3000_state - device instance state information
- * @us:                        the associated spi device
- * @info:                      chip variant information
- * @indio_dev:                         device information used by the IIO core
- * @interrupt_handler_ws:      event interrupt handler for all events
- * @last_timestamp:            the timestamp of the last event
- * @mo_det_use_count:          reference counter for the motion detection unit
- * @lock:                      lock used to protect elements of sca3000_state
- *                             and the underlying device state.
- * @bpse:                      number of bits per scan element
- * @tx:                        dma-able transmit buffer
- * @rx:                        dma-able receive buffer
+ * @us:                        the associated spi device
+ * @info:                      chip variant information
+ * @indio_dev:                 device information used by the IIO core
+ * @interrupt_handler_ws:      event interrupt handler for all events
+ * @last_timestamp:            the timestamp of the last event
+ * @mo_det_use_count:          reference counter for the motion detection unit
+ * @lock:                      lock used to protect elements of sca3000_state
+ *                             and the underlying device state.
+ * @bpse:                      number of bits per scan element
+ * @tx:                        dma-able transmit buffer
+ * @rx:                        dma-able receive buffer
  **/
 struct sca3000_state {
        struct spi_device               *us;
@@ -179,15 +179,14 @@ struct sca3000_state {
        int                             mo_det_use_count;
        struct mutex                    lock;
        int                             bpse;
-       u8                              *tx;
-       /* not used during a ring buffer read */
-       u8                              *rx;
+       /* Can these share a cacheline ? */
+       u8                              rx[2] ____cacheline_aligned;
+       u8                              tx[6] ____cacheline_aligned;
 };
 
 /**
  * struct sca3000_chip_info - model dependent parameters
- * @name:                      model identification
- * @scale:                     string containing floating point scale factor
+ * @scale:                     scale * 10^-6
  * @temp_output:               some devices have temperature sensors.
  * @measurement_mode_freq:     normal mode sampling frequency
  * @option_mode_1:             first optional mode. Not all models have one
@@ -199,30 +198,20 @@ struct sca3000_state {
  * sca3000 variant.
  **/
 struct sca3000_chip_info {
-       const char              *name;
-       const char              *scale;
+       unsigned int            scale;
        bool                    temp_output;
        int                     measurement_mode_freq;
        int                     option_mode_1;
        int                     option_mode_1_freq;
        int                     option_mode_2;
        int                     option_mode_2_freq;
+       int                     mot_det_mult_xz[6];
+       int                     mot_det_mult_y[7];
 };
 
-/**
- * sca3000_read_data() read a series of values from the device
- * @dev:               device
- * @reg_address_high:  start address (decremented read)
- * @rx:                        pointer where received data is placed. Callee
- *                     responsible for freeing this.
- * @len:               number of bytes to read
- *
- * The main lock must be held.
- **/
-int sca3000_read_data(struct sca3000_state *st,
-                     u8 reg_address_high,
-                     u8 **rx_p,
-                     int len);
+int sca3000_read_data_short(struct sca3000_state *st,
+                           u8 reg_address_high,
+                           int len);
 
 /**
  * sca3000_write_reg() write a single register
@@ -233,29 +222,6 @@ int sca3000_read_data(struct sca3000_state *st,
  **/
 int sca3000_write_reg(struct sca3000_state *st, u8 address, u8 val);
 
-/* Conversion function for use with the ring buffer when in 11bit mode */
-static inline int sca3000_11bit_convert(uint8_t msb, uint8_t lsb)
-{
-       int16_t val;
-
-       val = ((lsb >> 3) & 0x1C) | (msb << 5);
-       val |= (val & (1 << 12)) ? 0xE000 : 0;
-
-       return val;
-}
-
-static inline int sca3000_13bit_convert(uint8_t msb, uint8_t lsb)
-{
-       s16 val;
-
-       val = ((lsb >> 3) & 0x1F) | (msb << 5);
-       /* sign fill */
-       val |= (val & (1 << 12)) ? 0xE000 : 0;
-
-       return val;
-}
-
-
 #ifdef CONFIG_IIO_RING_BUFFER
 /**
  * sca3000_register_ring_funcs() setup the ring state change functions
index 5b06dea6af25679b446bfb466325211ffbc9c300..f213b8698eb262d5409ec17a3b55e53e1c1fcb1d 100644 (file)
@@ -40,95 +40,74 @@ enum sca3000_variant {
  * do not actually appear to be available.
  */
 static const struct sca3000_chip_info sca3000_spi_chip_info_tbl[] = {
-       {
-               .name = "sca3000-d01",
-               .scale = " 0.0073575",
+       [d01] = {
+               .scale = 7357,
                .temp_output = true,
                .measurement_mode_freq = 250,
                .option_mode_1 = SCA3000_OP_MODE_BYPASS,
                .option_mode_1_freq = 250,
-       }, {
-               .name = "sca3000-e02",
-               .scale = "0.00981",
+               .mot_det_mult_xz = {50, 100, 200, 350, 650, 1300},
+               .mot_det_mult_y = {50, 100, 150, 250, 450, 850, 1750},
+       },
+       [e02] = {
+               .scale = 9810,
                .measurement_mode_freq = 125,
                .option_mode_1 = SCA3000_OP_MODE_NARROW,
                .option_mode_1_freq = 63,
-       }, {
-               .name = "sca3000-e04",
-               .scale = "0.01962",
+               .mot_det_mult_xz = {100, 150, 300, 550, 1050, 2050},
+               .mot_det_mult_y = {50, 100, 200, 350, 700, 1350, 2700},
+       },
+       [e04] = {
+               .scale = 19620,
                .measurement_mode_freq = 100,
                .option_mode_1 = SCA3000_OP_MODE_NARROW,
                .option_mode_1_freq = 50,
                .option_mode_2 = SCA3000_OP_MODE_WIDE,
                .option_mode_2_freq = 400,
-       }, {
-               .name = "sca3000-e05",
-               .scale = "0.0613125",
+               .mot_det_mult_xz = {200, 300, 600, 1100, 2100, 4100},
+               .mot_det_mult_y = {100, 200, 400, 7000, 1400, 2700, 54000},
+       },
+       [e05] = {
+               .scale = 61313,
                .measurement_mode_freq = 200,
                .option_mode_1 = SCA3000_OP_MODE_NARROW,
                .option_mode_1_freq = 50,
                .option_mode_2 = SCA3000_OP_MODE_WIDE,
                .option_mode_2_freq = 400,
+               .mot_det_mult_xz = {600, 900, 1700, 3200, 6100, 11900},
+               .mot_det_mult_y = {300, 600, 1200, 2000, 4100, 7800, 15600},
        },
 };
 
-
 int sca3000_write_reg(struct sca3000_state *st, u8 address, u8 val)
 {
-       struct spi_transfer xfer = {
-               .bits_per_word = 8,
-               .len = 2,
-               .cs_change = 1,
-               .tx_buf = st->tx,
-       };
-       struct spi_message msg;
-
        st->tx[0] = SCA3000_WRITE_REG(address);
        st->tx[1] = val;
-       spi_message_init(&msg);
-       spi_message_add_tail(&xfer, &msg);
-
-       return spi_sync(st->us, &msg);
+       return spi_write(st->us, st->tx, 2);
 }
 
-int sca3000_read_data(struct sca3000_state *st,
-                     uint8_t reg_address_high,
-                     u8 **rx_p,
-                     int len)
+int sca3000_read_data_short(struct sca3000_state *st,
+                           uint8_t reg_address_high,
+                           int len)
 {
-       int ret;
        struct spi_message msg;
-       struct spi_transfer xfer = {
-               .bits_per_word = 8,
-               .len = len + 1,
-               .cs_change = 1,
-               .tx_buf = st->tx,
+       struct spi_transfer xfer[2] = {
+               {
+                       .len = 1,
+                       .tx_buf = st->tx,
+               }, {
+                       .len = len,
+                       .rx_buf = st->rx,
+               }
        };
-
-       *rx_p = kmalloc(len + 1, GFP_KERNEL);
-       if (*rx_p == NULL) {
-               ret = -ENOMEM;
-               goto error_ret;
-       }
-       xfer.rx_buf = *rx_p;
        st->tx[0] = SCA3000_READ_REG(reg_address_high);
        spi_message_init(&msg);
-       spi_message_add_tail(&xfer, &msg);
-
-       ret = spi_sync(st->us, &msg);
-
-       if (ret) {
-               dev_err(get_device(&st->us->dev), "problem reading register");
-               goto error_free_rx;
-       }
-
-       return 0;
-error_free_rx:
-       kfree(*rx_p);
-error_ret:
-       return ret;
+       spi_message_add_tail(&xfer[0], &msg);
+       spi_message_add_tail(&xfer[1], &msg);
 
+       return spi_sync(st->us, &msg);
 }
+
 /**
  * sca3000_reg_lock_on() test if the ctrl register lock is on
  *
@@ -136,17 +115,13 @@ error_ret:
  **/
 static int sca3000_reg_lock_on(struct sca3000_state *st)
 {
-       u8 *rx;
        int ret;
 
-       ret = sca3000_read_data(st, SCA3000_REG_ADDR_STATUS, &rx, 1);
-
+       ret = sca3000_read_data_short(st, SCA3000_REG_ADDR_STATUS, 1);
        if (ret < 0)
                return ret;
-       ret = !(rx[1] & SCA3000_LOCKED);
-       kfree(rx);
 
-       return ret;
+       return !(st->rx[0] & SCA3000_LOCKED);
 }
 
 /**
@@ -161,19 +136,15 @@ static int __sca3000_unlock_reg_lock(struct sca3000_state *st)
        struct spi_message msg;
        struct spi_transfer xfer[3] = {
                {
-                       .bits_per_word = 8,
                        .len = 2,
                        .cs_change = 1,
                        .tx_buf = st->tx,
                }, {
-                       .bits_per_word = 8,
                        .len = 2,
                        .cs_change = 1,
                        .tx_buf = st->tx + 2,
                }, {
-                       .bits_per_word = 8,
                        .len = 2,
-                       .cs_change = 1,
                        .tx_buf = st->tx + 4,
                },
        };
@@ -236,8 +207,7 @@ error_ret:
  * Lock must be held.
  **/
 static int sca3000_read_ctrl_reg(struct sca3000_state *st,
-                                u8 ctrl_reg,
-                                u8 **rx_p)
+                                u8 ctrl_reg)
 {
        int ret;
 
@@ -253,8 +223,11 @@ static int sca3000_read_ctrl_reg(struct sca3000_state *st,
        ret = sca3000_write_reg(st, SCA3000_REG_ADDR_CTRL_SEL, ctrl_reg);
        if (ret)
                goto error_ret;
-       ret = sca3000_read_data(st, SCA3000_REG_ADDR_CTRL_DATA, rx_p, 1);
-
+       ret = sca3000_read_data_short(st, SCA3000_REG_ADDR_CTRL_DATA, 1);
+       if (ret)
+               goto error_ret;
+       else
+               return st->rx[0];
 error_ret:
        return ret;
 }
@@ -267,20 +240,18 @@ error_ret:
  **/
 static int sca3000_check_status(struct device *dev)
 {
-       u8 *rx;
        int ret;
        struct iio_dev *indio_dev = dev_get_drvdata(dev);
        struct sca3000_state *st = indio_dev->dev_data;
 
        mutex_lock(&st->lock);
-       ret = sca3000_read_data(st, SCA3000_REG_ADDR_STATUS, &rx, 1);
+       ret = sca3000_read_data_short(st, SCA3000_REG_ADDR_STATUS, 1);
        if (ret < 0)
                goto error_ret;
-       if (rx[1] & SCA3000_EEPROM_CS_ERROR)
+       if (st->rx[0] & SCA3000_EEPROM_CS_ERROR)
                dev_err(dev, "eeprom error\n");
-       if (rx[1] & SCA3000_SPI_FRAME_ERROR)
+       if (st->rx[0] & SCA3000_SPI_FRAME_ERROR)
                dev_err(dev, "Previous SPI Frame was corrupt\n");
-       kfree(rx);
 
 error_ret:
        mutex_unlock(&st->lock);
@@ -288,53 +259,7 @@ error_ret:
 }
 #endif /* SCA3000_DEBUG */
 
-/**
- * sca3000_read_13bit_signed() sysfs interface to read 13 bit signed registers
- *
- * These are described as signed 12 bit on the data sheet, which appears
- * to be a conventional 2's complement 13 bit.
- **/
-static ssize_t sca3000_read_13bit_signed(struct device *dev,
-                                        struct device_attribute *attr,
-                                        char *buf)
-{
-       int len = 0, ret;
-       int val;
-       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-       u8 *rx;
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
-       struct sca3000_state *st = indio_dev->dev_data;
-
-       mutex_lock(&st->lock);
-       ret = sca3000_read_data(st, this_attr->address, &rx, 2);
-       if (ret < 0)
-               goto error_ret;
-       val = sca3000_13bit_convert(rx[1], rx[2]);
-       len += sprintf(buf + len, "%d\n", val);
-       kfree(rx);
-error_ret:
-       mutex_unlock(&st->lock);
-
-       return ret ? ret : len;
-}
 
-static ssize_t sca3000_show_scale(struct device *dev,
-                                 struct device_attribute *attr,
-                                 char *buf)
-{
-       struct iio_dev *dev_info = dev_get_drvdata(dev);
-       struct sca3000_state *st = dev_info->dev_data;
-       return sprintf(buf, "%s\n", st->info->scale);
-}
-
-static ssize_t sca3000_show_name(struct device *dev,
-                                struct device_attribute *attr,
-                                char *buf)
-{
-       struct iio_dev *dev_info = dev_get_drvdata(dev);
-       struct sca3000_state *st = dev_info->dev_data;
-       return sprintf(buf, "%s\n", st->info->name);
-}
 /**
  * sca3000_show_reg() - sysfs interface to read the chip revision number
  **/
@@ -346,18 +271,14 @@ static ssize_t sca3000_show_rev(struct device *dev,
        struct iio_dev *dev_info = dev_get_drvdata(dev);
        struct sca3000_state *st = dev_info->dev_data;
 
-       u8 *rx;
-
        mutex_lock(&st->lock);
-       ret = sca3000_read_data(st, SCA3000_REG_ADDR_REVID, &rx, 1);
+       ret = sca3000_read_data_short(st, SCA3000_REG_ADDR_REVID, 1);
        if (ret < 0)
                goto error_ret;
        len += sprintf(buf + len,
                       "major=%d, minor=%d\n",
-                      rx[1] & SCA3000_REVID_MAJOR_MASK,
-                      rx[1] & SCA3000_REVID_MINOR_MASK);
-       kfree(rx);
-
+                      st->rx[0] & SCA3000_REVID_MAJOR_MASK,
+                      st->rx[0] & SCA3000_REVID_MINOR_MASK);
 error_ret:
        mutex_unlock(&st->lock);
 
@@ -410,15 +331,14 @@ sca3000_show_measurement_mode(struct device *dev,
        struct iio_dev *dev_info = dev_get_drvdata(dev);
        struct sca3000_state *st = dev_info->dev_data;
        int len = 0, ret;
-       u8 *rx;
 
        mutex_lock(&st->lock);
-       ret = sca3000_read_data(st, SCA3000_REG_ADDR_MODE, &rx, 1);
+       ret = sca3000_read_data_short(st, SCA3000_REG_ADDR_MODE, 1);
        if (ret)
                goto error_ret;
        /* mask bottom 2 bits - only ones that are relevant */
-       rx[1] &= 0x03;
-       switch (rx[1]) {
+       st->rx[0] &= 0x03;
+       switch (st->rx[0]) {
        case SCA3000_MEAS_MODE_NORMAL:
                len += sprintf(buf + len, "0 - normal mode\n");
                break;
@@ -462,7 +382,6 @@ sca3000_store_measurement_mode(struct device *dev,
        struct iio_dev *dev_info = dev_get_drvdata(dev);
        struct sca3000_state *st = dev_info->dev_data;
        int ret;
-       u8 *rx;
        int mask = 0x03;
        long val;
 
@@ -470,20 +389,18 @@ sca3000_store_measurement_mode(struct device *dev,
        ret = strict_strtol(buf, 10, &val);
        if (ret)
                goto error_ret;
-       ret = sca3000_read_data(st, SCA3000_REG_ADDR_MODE, &rx, 1);
+       ret = sca3000_read_data_short(st, SCA3000_REG_ADDR_MODE, 1);
        if (ret)
                goto error_ret;
-       rx[1] &= ~mask;
-       rx[1] |= (val & mask);
-       ret = sca3000_write_reg(st, SCA3000_REG_ADDR_MODE, rx[1]);
+       st->rx[0] &= ~mask;
+       st->rx[0] |= (val & mask);
+       ret = sca3000_write_reg(st, SCA3000_REG_ADDR_MODE, st->rx[0]);
        if (ret)
-               goto error_free_rx;
+               goto error_ret;
        mutex_unlock(&st->lock);
 
        return len;
 
-error_free_rx:
-       kfree(rx);
 error_ret:
        mutex_unlock(&st->lock);
 
@@ -505,18 +422,70 @@ static IIO_DEVICE_ATTR(measurement_mode, S_IRUGO | S_IWUSR,
 
 /* More standard attributes */
 
-static IIO_DEV_ATTR_NAME(sca3000_show_name);
 static IIO_DEV_ATTR_REV(sca3000_show_rev);
-static IIO_DEVICE_ATTR(accel_scale, S_IRUGO, sca3000_show_scale,
-                      NULL, 0);
 
-static IIO_DEV_ATTR_ACCEL_X(sca3000_read_13bit_signed,
-                           SCA3000_REG_ADDR_X_MSB);
-static IIO_DEV_ATTR_ACCEL_Y(sca3000_read_13bit_signed,
-                           SCA3000_REG_ADDR_Y_MSB);
-static IIO_DEV_ATTR_ACCEL_Z(sca3000_read_13bit_signed,
-                           SCA3000_REG_ADDR_Z_MSB);
+#define SCA3000_INFO_MASK                      \
+       (1 << IIO_CHAN_INFO_SCALE_SHARED)
+#define SCA3000_EVENT_MASK                                     \
+       (IIO_EV_BIT(IIO_EV_TYPE_MAG, IIO_EV_DIR_RISING))
+
+static struct iio_chan_spec sca3000_channels[] = {
+       IIO_CHAN(IIO_ACCEL, 1, 0, 0, NULL, 0, IIO_MOD_X, SCA3000_INFO_MASK,
+                0, 0, IIO_ST('s', 11, 16, 5), SCA3000_EVENT_MASK),
+       IIO_CHAN(IIO_ACCEL, 1, 0, 0, NULL, 0, IIO_MOD_Y, SCA3000_INFO_MASK,
+                1, 1, IIO_ST('s', 11, 16, 5), SCA3000_EVENT_MASK),
+       IIO_CHAN(IIO_ACCEL, 1, 0, 0, NULL, 0, IIO_MOD_Z, SCA3000_INFO_MASK,
+                2, 2, IIO_ST('s', 11, 16, 5), SCA3000_EVENT_MASK),
+};
+
+static u8 sca3000_addresses[3][3] = {
+       [0] = {SCA3000_REG_ADDR_X_MSB, SCA3000_REG_CTRL_SEL_MD_X_TH,
+              SCA3000_MD_CTRL_OR_X},
+       [1] = {SCA3000_REG_ADDR_Y_MSB, SCA3000_REG_CTRL_SEL_MD_Y_TH,
+              SCA3000_MD_CTRL_OR_Y},
+       [2] = {SCA3000_REG_ADDR_Z_MSB, SCA3000_REG_CTRL_SEL_MD_Z_TH,
+              SCA3000_MD_CTRL_OR_Z},
+};
 
+static int sca3000_read_raw(struct iio_dev *indio_dev,
+                           struct iio_chan_spec const *chan,
+                           int *val,
+                           int *val2,
+                           long mask)
+{
+       struct sca3000_state *st = indio_dev->dev_data;
+       int ret;
+       u8 address;
+
+       switch (mask) {
+       case 0:
+               mutex_lock(&st->lock);
+               if (st->mo_det_use_count) {
+                       mutex_unlock(&st->lock);
+                       return -EBUSY;
+               }
+               address = sca3000_addresses[chan->address][0];
+               ret = sca3000_read_data_short(st, address, 2);
+               if (ret < 0) {
+                       mutex_unlock(&st->lock);
+                       return ret;
+               }
+               *val = (be16_to_cpup((__be16 *)st->rx) >> 3) & 0x1FFF;
+               *val = ((*val) << (sizeof(*val)*8 - 13)) >>
+                       (sizeof(*val)*8 - 13);
+               mutex_unlock(&st->lock);
+               return IIO_VAL_INT;
+       case (1 << IIO_CHAN_INFO_SCALE_SHARED):
+               *val = 0;
+               if (chan->type == IIO_ACCEL)
+                       *val2 = st->info->scale;
+               else /* temperature */
+                       *val2 = 555556;
+               return IIO_VAL_INT_PLUS_MICRO;
+       default:
+               return -EINVAL;
+       }
+}
 
 /**
  * sca3000_read_av_freq() sysfs function to get available frequencies
@@ -532,15 +501,16 @@ static ssize_t sca3000_read_av_freq(struct device *dev,
 {
        struct iio_dev *indio_dev = dev_get_drvdata(dev);
        struct sca3000_state *st = indio_dev->dev_data;
-       int len = 0, ret;
-       u8 *rx;
+       int len = 0, ret, val;
+
        mutex_lock(&st->lock);
-       ret = sca3000_read_data(st, SCA3000_REG_ADDR_MODE, &rx, 1);
+       ret = sca3000_read_data_short(st, SCA3000_REG_ADDR_MODE, 1);
+       val = st->rx[0];
        mutex_unlock(&st->lock);
        if (ret)
                goto error_ret;
-       rx[1] &= 0x03;
-       switch (rx[1]) {
+
+       switch (val & 0x03) {
        case SCA3000_MEAS_MODE_NORMAL:
                len += sprintf(buf + len, "%d %d %d\n",
                               st->info->measurement_mode_freq,
@@ -560,7 +530,6 @@ static ssize_t sca3000_read_av_freq(struct device *dev,
                               st->info->option_mode_2_freq/4);
                break;
        }
-       kfree(rx);
        return len;
 error_ret:
        return ret;
@@ -575,12 +544,11 @@ static inline int __sca3000_get_base_freq(struct sca3000_state *st,
                                          int *base_freq)
 {
        int ret;
-       u8 *rx;
 
-       ret = sca3000_read_data(st, SCA3000_REG_ADDR_MODE, &rx, 1);
+       ret = sca3000_read_data_short(st, SCA3000_REG_ADDR_MODE, 1);
        if (ret)
                goto error_ret;
-       switch (0x03 & rx[1]) {
+       switch (0x03 & st->rx[0]) {
        case SCA3000_MEAS_MODE_NORMAL:
                *base_freq = info->measurement_mode_freq;
                break;
@@ -591,7 +559,6 @@ static inline int __sca3000_get_base_freq(struct sca3000_state *st,
                *base_freq = info->option_mode_2_freq;
                break;
        }
-       kfree(rx);
 error_ret:
        return ret;
 }
@@ -605,18 +572,19 @@ static ssize_t sca3000_read_frequency(struct device *dev,
 {
        struct iio_dev *indio_dev = dev_get_drvdata(dev);
        struct sca3000_state *st = indio_dev->dev_data;
-       int ret, len = 0, base_freq = 0;
-       u8 *rx;
+       int ret, len = 0, base_freq = 0, val;
+
        mutex_lock(&st->lock);
        ret = __sca3000_get_base_freq(st, st->info, &base_freq);
        if (ret)
                goto error_ret_mut;
-       ret = sca3000_read_ctrl_reg(st, SCA3000_REG_CTRL_SEL_OUT_CTRL, &rx);
+       ret = sca3000_read_ctrl_reg(st, SCA3000_REG_CTRL_SEL_OUT_CTRL);
        mutex_unlock(&st->lock);
        if (ret)
                goto error_ret;
+       val = ret;
        if (base_freq > 0)
-               switch (rx[1]&0x03) {
+               switch (val & 0x03) {
                case 0x00:
                case 0x03:
                        len = sprintf(buf, "%d\n", base_freq);
@@ -628,7 +596,7 @@ static ssize_t sca3000_read_frequency(struct device *dev,
                        len = sprintf(buf, "%d\n", base_freq/4);
                        break;
        }
-       kfree(rx);
+
        return len;
 error_ret_mut:
        mutex_unlock(&st->lock);
@@ -647,7 +615,7 @@ static ssize_t sca3000_set_frequency(struct device *dev,
        struct iio_dev *indio_dev = dev_get_drvdata(dev);
        struct sca3000_state *st = indio_dev->dev_data;
        int ret, base_freq = 0;
-       u8 *rx;
+       int ctrlval;
        long val;
 
        ret = strict_strtol(buf, 10, &val);
@@ -660,21 +628,23 @@ static ssize_t sca3000_set_frequency(struct device *dev,
        if (ret)
                goto error_free_lock;
 
-       ret = sca3000_read_ctrl_reg(st, SCA3000_REG_CTRL_SEL_OUT_CTRL, &rx);
-       if (ret)
+       ret = sca3000_read_ctrl_reg(st, SCA3000_REG_CTRL_SEL_OUT_CTRL);
+       if (ret < 0)
                goto error_free_lock;
+       ctrlval = ret;
        /* clear the bits */
-       rx[1] &= ~0x03;
+       ctrlval &= ~0x03;
 
        if (val == base_freq/2) {
-               rx[1] |= SCA3000_OUT_CTRL_BUF_DIV_2;
+               ctrlval |= SCA3000_OUT_CTRL_BUF_DIV_2;
        } else if (val == base_freq/4) {
-               rx[1] |= SCA3000_OUT_CTRL_BUF_DIV_4;
+               ctrlval |= SCA3000_OUT_CTRL_BUF_DIV_4;
        } else if (val != base_freq) {
                ret = -EINVAL;
                goto error_free_lock;
        }
-       ret = sca3000_write_ctrl_reg(st, SCA3000_REG_CTRL_SEL_OUT_CTRL, rx[1]);
+       ret = sca3000_write_ctrl_reg(st, SCA3000_REG_CTRL_SEL_OUT_CTRL,
+                                    ctrlval);
 error_free_lock:
        mutex_unlock(&st->lock);
 
@@ -704,17 +674,14 @@ static ssize_t sca3000_read_temp(struct device *dev,
 {
        struct iio_dev *indio_dev = dev_get_drvdata(dev);
        struct sca3000_state *st = indio_dev->dev_data;
-       int len = 0, ret;
+       int ret;
        int val;
-       u8 *rx;
-       ret = sca3000_read_data(st, SCA3000_REG_ADDR_TEMP_MSB, &rx, 2);
+       ret = sca3000_read_data_short(st, SCA3000_REG_ADDR_TEMP_MSB, 2);
        if (ret < 0)
                goto error_ret;
-       val = ((rx[1]&0x3F) << 3) | ((rx[2] & 0xE0) >> 5);
-       len += sprintf(buf + len, "%d\n", val);
-       kfree(rx);
+       val = ((st->rx[0] & 0x3F) << 3) | ((st->rx[1] & 0xE0) >> 5);
 
-       return len;
+       return sprintf(buf, "%d\n", val);
 
 error_ret:
        return ret;
@@ -725,80 +692,71 @@ static IIO_CONST_ATTR_TEMP_SCALE("0.555556");
 static IIO_CONST_ATTR_TEMP_OFFSET("-214.6");
 
 /**
- * sca3000_show_thresh() sysfs query of a threshold
+ * sca3000_read_thresh() - query of a threshold
  **/
-static ssize_t sca3000_show_thresh(struct device *dev,
-                                  struct device_attribute *attr,
-                                  char *buf)
+static int sca3000_read_thresh(struct iio_dev *indio_dev,
+                              int e,
+                              int *val)
 {
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
+       int ret, i;
        struct sca3000_state *st = indio_dev->dev_data;
-       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-       int len = 0, ret;
-       u8 *rx;
-
+       int num = IIO_EVENT_CODE_EXTRACT_MODIFIER(e);
        mutex_lock(&st->lock);
-       ret = sca3000_read_ctrl_reg(st,
-                                   this_attr->address,
-                                   &rx);
+       ret = sca3000_read_ctrl_reg(st, sca3000_addresses[num][1]);
        mutex_unlock(&st->lock);
-       if (ret)
+       if (ret < 0)
                return ret;
-       len += sprintf(buf + len, "%d\n", rx[1]);
-       kfree(rx);
+       *val = 0;
+       if (num == 1)
+               for_each_set_bit(i, (unsigned long *)&ret,
+                                ARRAY_SIZE(st->info->mot_det_mult_y))
+                       *val += st->info->mot_det_mult_y[i];
+       else
+               for_each_set_bit(i, (unsigned long *)&ret,
+                                ARRAY_SIZE(st->info->mot_det_mult_xz))
+                       *val += st->info->mot_det_mult_xz[i];
 
-       return len;
+       return 0;
 }
 
 /**
- * sca3000_write_thresh() sysfs control of threshold
+ * sca3000_write_thresh() control of threshold
  **/
-static ssize_t sca3000_write_thresh(struct device *dev,
-                                   struct device_attribute *attr,
-                                   const char *buf,
-                                   size_t len)
+static int sca3000_write_thresh(struct iio_dev *indio_dev,
+                                   int e,
+                                   int val)
 {
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
        struct sca3000_state *st = indio_dev->dev_data;
-       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
+       int num = IIO_EVENT_CODE_EXTRACT_MODIFIER(e);
        int ret;
-       long val;
+       int i;
+       u8 nonlinear = 0;
+
+       if (num == 1) {
+               i = ARRAY_SIZE(st->info->mot_det_mult_y);
+               while (i > 0)
+                       if (val >= st->info->mot_det_mult_y[--i]) {
+                               nonlinear |= (1 << i);
+                               val -= st->info->mot_det_mult_y[i];
+                       }
+       } else {
+               i = ARRAY_SIZE(st->info->mot_det_mult_xz);
+               while (i > 0)
+                       if (val >= st->info->mot_det_mult_xz[--i]) {
+                               nonlinear |= (1 << i);
+                               val -= st->info->mot_det_mult_xz[i];
+                       }
+       }
 
-       ret = strict_strtol(buf, 10, &val);
-       if (ret)
-               return ret;
        mutex_lock(&st->lock);
-       ret = sca3000_write_ctrl_reg(st, this_attr->address, val);
+       ret = sca3000_write_ctrl_reg(st, sca3000_addresses[num][1], nonlinear);
        mutex_unlock(&st->lock);
 
-       return ret ? ret : len;
+       return ret;
 }
 
-static IIO_DEVICE_ATTR(accel_x_raw_mag_rising_value,
-               S_IRUGO | S_IWUSR,
-               sca3000_show_thresh,
-               sca3000_write_thresh,
-               SCA3000_REG_CTRL_SEL_MD_X_TH);
-
-static IIO_DEVICE_ATTR(accel_y_raw_mag_rising_value,
-               S_IRUGO | S_IWUSR,
-               sca3000_show_thresh,
-               sca3000_write_thresh,
-               SCA3000_REG_CTRL_SEL_MD_Y_TH);
-
-static IIO_DEVICE_ATTR(accel_z_raw_mag_rising_value,
-               S_IRUGO | S_IWUSR,
-               sca3000_show_thresh,
-               sca3000_write_thresh,
-               SCA3000_REG_CTRL_SEL_MD_Z_TH);
-
 static struct attribute *sca3000_attributes[] = {
-       &iio_dev_attr_name.dev_attr.attr,
        &iio_dev_attr_revision.dev_attr.attr,
-       &iio_dev_attr_accel_scale.dev_attr.attr,
-       &iio_dev_attr_accel_x_raw.dev_attr.attr,
-       &iio_dev_attr_accel_y_raw.dev_attr.attr,
-       &iio_dev_attr_accel_z_raw.dev_attr.attr,
        &iio_dev_attr_measurement_mode_available.dev_attr.attr,
        &iio_dev_attr_measurement_mode.dev_attr.attr,
        &iio_dev_attr_sampling_frequency_available.dev_attr.attr,
@@ -807,12 +765,7 @@ static struct attribute *sca3000_attributes[] = {
 };
 
 static struct attribute *sca3000_attributes_with_temp[] = {
-       &iio_dev_attr_name.dev_attr.attr,
        &iio_dev_attr_revision.dev_attr.attr,
-       &iio_dev_attr_accel_scale.dev_attr.attr,
-       &iio_dev_attr_accel_x_raw.dev_attr.attr,
-       &iio_dev_attr_accel_y_raw.dev_attr.attr,
-       &iio_dev_attr_accel_z_raw.dev_attr.attr,
        &iio_dev_attr_measurement_mode_available.dev_attr.attr,
        &iio_dev_attr_measurement_mode.dev_attr.attr,
        &iio_dev_attr_sampling_frequency_available.dev_attr.attr,
@@ -836,134 +789,102 @@ static const struct attribute_group sca3000_attribute_group_with_temp = {
 /* depending on event, push to the ring buffer event chrdev or the event one */
 
 /**
- * sca3000_interrupt_handler_bh() - handling ring and non ring events
+ * sca3000_event_handler() - handling ring and non ring events
  *
  * This function is complicated by the fact that the devices can signify ring
  * and non ring events via the same interrupt line and they can only
  * be distinguished via a read of the relevant status register.
  **/
-static void sca3000_interrupt_handler_bh(struct work_struct *work_s)
+static irqreturn_t sca3000_event_handler(int irq, void *private)
 {
-       struct sca3000_state *st
-               = container_of(work_s, struct sca3000_state,
-                              interrupt_handler_ws);
-       u8 *rx;
-       int ret;
+       struct iio_dev *indio_dev = private;
+       struct sca3000_state *st;
+       int ret, val;
+       s64 last_timestamp = iio_get_time_ns();
 
+       st = indio_dev->dev_data;
        /* Could lead if badly timed to an extra read of status reg,
         * but ensures no interrupt is missed.
         */
-       enable_irq(st->us->irq);
        mutex_lock(&st->lock);
-       ret = sca3000_read_data(st, SCA3000_REG_ADDR_INT_STATUS,
-                               &rx, 1);
+       ret = sca3000_read_data_short(st, SCA3000_REG_ADDR_INT_STATUS, 1);
+       val = st->rx[0];
        mutex_unlock(&st->lock);
        if (ret)
                goto done;
 
-       sca3000_ring_int_process(rx[1], st->indio_dev->ring);
+       sca3000_ring_int_process(val, st->indio_dev->ring);
 
-       if (rx[1] & SCA3000_INT_STATUS_FREE_FALL)
+       if (val & SCA3000_INT_STATUS_FREE_FALL)
                iio_push_event(st->indio_dev, 0,
                               IIO_MOD_EVENT_CODE(IIO_EV_CLASS_ACCEL,
                                                  0,
                                                  IIO_EV_MOD_X_AND_Y_AND_Z,
                                                  IIO_EV_TYPE_MAG,
                                                  IIO_EV_DIR_FALLING),
-                              st->last_timestamp);
+                              last_timestamp);
 
-       if (rx[1] & SCA3000_INT_STATUS_Y_TRIGGER)
+       if (val & SCA3000_INT_STATUS_Y_TRIGGER)
                iio_push_event(st->indio_dev, 0,
                               IIO_MOD_EVENT_CODE(IIO_EV_CLASS_ACCEL,
                                                  0,
                                                  IIO_EV_MOD_Y,
                                                  IIO_EV_TYPE_MAG,
                                                  IIO_EV_DIR_RISING),
-                              st->last_timestamp);
+                              last_timestamp);
 
-       if (rx[1] & SCA3000_INT_STATUS_X_TRIGGER)
+       if (val & SCA3000_INT_STATUS_X_TRIGGER)
                iio_push_event(st->indio_dev, 0,
                               IIO_MOD_EVENT_CODE(IIO_EV_CLASS_ACCEL,
                                                  0,
                                                  IIO_EV_MOD_X,
                                                  IIO_EV_TYPE_MAG,
                                                  IIO_EV_DIR_RISING),
-                              st->last_timestamp);
+                              last_timestamp);
 
-       if (rx[1] & SCA3000_INT_STATUS_Z_TRIGGER)
+       if (val & SCA3000_INT_STATUS_Z_TRIGGER)
                iio_push_event(st->indio_dev, 0,
                               IIO_MOD_EVENT_CODE(IIO_EV_CLASS_ACCEL,
                                                  0,
                                                  IIO_EV_MOD_Z,
                                                  IIO_EV_TYPE_MAG,
                                                  IIO_EV_DIR_RISING),
-                              st->last_timestamp);
+                              last_timestamp);
 
 done:
-       kfree(rx);
-       return;
+       return IRQ_HANDLED;
 }
 
 /**
- * sca3000_handler_th() handles all interrupt events from device
- *
- * These devices deploy unified interrupt status registers meaning
- * all interrupts must be handled together
- **/
-static int sca3000_handler_th(struct iio_dev *dev_info,
-                             int index,
-                             s64 timestamp,
-                             int no_test)
-{
-       struct sca3000_state *st = dev_info->dev_data;
-
-       st->last_timestamp = timestamp;
-       schedule_work(&st->interrupt_handler_ws);
-
-       return 0;
-}
-
-/**
- * sca3000_query_mo_det() is motion detection enabled for this axis
- *
- * First queries if motion detection is enabled and then if this axis is
- * on.
+ * sca3000_read_event_config() what events are enabled
  **/
-static ssize_t sca3000_query_mo_det(struct device *dev,
-                                   struct device_attribute *attr,
-                                   char *buf)
+static int sca3000_read_event_config(struct iio_dev *indio_dev,
+                                    int e)
 {
-       struct iio_dev *indio_dev = dev_get_drvdata(dev->parent);
        struct sca3000_state *st = indio_dev->dev_data;
-       struct iio_event_attr *this_attr = to_iio_event_attr(attr);
-       int ret, len = 0;
-       u8 *rx;
+       int ret;
        u8 protect_mask = 0x03;
+       int num = IIO_EVENT_CODE_EXTRACT_MODIFIER(e);
 
        /* read current value of mode register */
        mutex_lock(&st->lock);
-       ret = sca3000_read_data(st, SCA3000_REG_ADDR_MODE, &rx, 1);
+       ret = sca3000_read_data_short(st, SCA3000_REG_ADDR_MODE, 1);
        if (ret)
                goto error_ret;
 
-       if ((rx[1]&protect_mask) != SCA3000_MEAS_MODE_MOT_DET)
-               len += sprintf(buf + len, "0\n");
+       if ((st->rx[0] & protect_mask) != SCA3000_MEAS_MODE_MOT_DET)
+               ret = 0;
        else {
-               kfree(rx);
-               ret = sca3000_read_ctrl_reg(st,
-                                           SCA3000_REG_CTRL_SEL_MD_CTRL,
-                                           &rx);
-               if (ret)
+               ret = sca3000_read_ctrl_reg(st, SCA3000_REG_CTRL_SEL_MD_CTRL);
+               if (ret < 0)
                        goto error_ret;
                /* only supporting logical or's for now */
-               len += sprintf(buf + len, "%d\n",
-                              (rx[1] & this_attr->mask) ? 1 : 0);
+               ret = !!(ret & sca3000_addresses[num][2]);
        }
-       kfree(rx);
 error_ret:
        mutex_unlock(&st->lock);
 
-       return ret ? ret : len;
+       return ret;
 }
 /**
  * sca3000_query_free_fall_mode() is free fall mode enabled
@@ -973,80 +894,20 @@ static ssize_t sca3000_query_free_fall_mode(struct device *dev,
                                            char *buf)
 {
        int ret, len;
-       u8 *rx;
        struct iio_dev *indio_dev = dev_get_drvdata(dev);
        struct sca3000_state *st = indio_dev->dev_data;
+       int val;
 
        mutex_lock(&st->lock);
-       ret = sca3000_read_data(st, SCA3000_REG_ADDR_MODE, &rx, 1);
+       ret = sca3000_read_data_short(st, SCA3000_REG_ADDR_MODE, 1);
+       val = st->rx[0];
        mutex_unlock(&st->lock);
-       if (ret)
+       if (ret < 0)
                return ret;
        len = sprintf(buf, "%d\n",
-                     !!(rx[1] & SCA3000_FREE_FALL_DETECT));
-       kfree(rx);
-
-       return len;
-}
-/**
- * sca3000_query_ring_int() is the hardware ring status interrupt enabled
- **/
-static ssize_t sca3000_query_ring_int(struct device *dev,
-                                     struct device_attribute *attr,
-                                     char *buf)
-{
-       struct iio_event_attr *this_attr = to_iio_event_attr(attr);
-       int ret, len;
-       u8 *rx;
-       struct iio_dev *indio_dev = dev_get_drvdata(dev->parent);
-       struct sca3000_state *st = indio_dev->dev_data;
-       mutex_lock(&st->lock);
-       ret = sca3000_read_data(st, SCA3000_REG_ADDR_INT_MASK, &rx, 1);
-       mutex_unlock(&st->lock);
-       if (ret)
-               return ret;
-       len = sprintf(buf, "%d\n", (rx[1] & this_attr->mask) ? 1 : 0);
-       kfree(rx);
-
+                     !!(val & SCA3000_FREE_FALL_DETECT));
        return len;
 }
-/**
- * sca3000_set_ring_int() set state of ring status interrupt
- **/
-static ssize_t sca3000_set_ring_int(struct device *dev,
-                                     struct device_attribute *attr,
-                                     const char *buf,
-                                     size_t len)
-{
-       struct iio_dev *indio_dev = dev_get_drvdata(dev->parent);
-       struct sca3000_state *st = indio_dev->dev_data;
-       struct iio_event_attr *this_attr = to_iio_event_attr(attr);
-
-       long val;
-       int ret;
-       u8 *rx;
-
-       mutex_lock(&st->lock);
-       ret = strict_strtol(buf, 10, &val);
-       if (ret)
-               goto error_ret;
-       ret = sca3000_read_data(st, SCA3000_REG_ADDR_INT_MASK, &rx, 1);
-       if (ret)
-               goto error_ret;
-       if (val)
-               ret = sca3000_write_reg(st,
-                                       SCA3000_REG_ADDR_INT_MASK,
-                                       rx[1] | this_attr->mask);
-       else
-               ret = sca3000_write_reg(st,
-                                       SCA3000_REG_ADDR_INT_MASK,
-                                       rx[1] & ~this_attr->mask);
-       kfree(rx);
-error_ret:
-       mutex_unlock(&st->lock);
-
-       return ret ? ret : len;
-}
 
 /**
  * sca3000_set_free_fall_mode() simple on off control for free fall int
@@ -1065,7 +926,6 @@ static ssize_t sca3000_set_free_fall_mode(struct device *dev,
        struct sca3000_state *st = indio_dev->dev_data;
        long val;
        int ret;
-       u8 *rx;
        u8 protect_mask = SCA3000_FREE_FALL_DETECT;
 
        mutex_lock(&st->lock);
@@ -1074,20 +934,18 @@ static ssize_t sca3000_set_free_fall_mode(struct device *dev,
                goto error_ret;
 
        /* read current value of mode register */
-       ret = sca3000_read_data(st, SCA3000_REG_ADDR_MODE, &rx, 1);
+       ret = sca3000_read_data_short(st, SCA3000_REG_ADDR_MODE, 1);
        if (ret)
                goto error_ret;
 
        /*if off and should be on*/
-       if (val && !(rx[1] & protect_mask))
+       if (val && !(st->rx[0] & protect_mask))
                ret = sca3000_write_reg(st, SCA3000_REG_ADDR_MODE,
-                                       (rx[1] | SCA3000_FREE_FALL_DETECT));
+                                       (st->rx[0] | SCA3000_FREE_FALL_DETECT));
        /* if on and should be off */
-       else if (!val && (rx[1]&protect_mask))
+       else if (!val && (st->rx[0] & protect_mask))
                ret = sca3000_write_reg(st, SCA3000_REG_ADDR_MODE,
-                                       (rx[1] & ~protect_mask));
-
-       kfree(rx);
+                                       (st->rx[0] & ~protect_mask));
 error_ret:
        mutex_unlock(&st->lock);
 
@@ -1103,127 +961,77 @@ error_ret:
  * There is a complexity in knowing which mode to return to when
  * this mode is disabled.  Currently normal mode is assumed.
  **/
-static ssize_t sca3000_set_mo_det(struct device *dev,
-                                 struct device_attribute *attr,
-                                 const char *buf,
-                                 size_t len)
+static int sca3000_write_event_config(struct iio_dev *indio_dev,
+                                     int e,
+                                     int state)
 {
-       struct iio_dev *indio_dev = dev_get_drvdata(dev->parent);
        struct sca3000_state *st = indio_dev->dev_data;
-       struct iio_event_attr *this_attr = to_iio_event_attr(attr);
-       long val;
-       int ret;
-       u8 *rx;
+       int ret, ctrlval;
        u8 protect_mask = 0x03;
-       ret = strict_strtol(buf, 10, &val);
-       if (ret)
-               return ret;
+       int num = IIO_EVENT_CODE_EXTRACT_MODIFIER(e);
 
        mutex_lock(&st->lock);
        /* First read the motion detector config to find out if
         * this axis is on*/
-       ret = sca3000_read_ctrl_reg(st,
-                                   SCA3000_REG_CTRL_SEL_MD_CTRL,
-                                   &rx);
-       if (ret)
+       ret = sca3000_read_ctrl_reg(st, SCA3000_REG_CTRL_SEL_MD_CTRL);
+       if (ret < 0)
                goto exit_point;
+       ctrlval = ret;
        /* Off and should be on */
-       if (val && !(rx[1] & this_attr->mask)) {
+       if (state && !(ctrlval & sca3000_addresses[num][2])) {
                ret = sca3000_write_ctrl_reg(st,
                                             SCA3000_REG_CTRL_SEL_MD_CTRL,
-                                            rx[1] | this_attr->mask);
+                                            ctrlval |
+                                            sca3000_addresses[num][2]);
                if (ret)
-                       goto exit_point_free_rx;
+                       goto exit_point;
                st->mo_det_use_count++;
-       } else if (!val && (rx[1]&this_attr->mask)) {
+       } else if (!state && (ctrlval & sca3000_addresses[num][2])) {
                ret = sca3000_write_ctrl_reg(st,
                                             SCA3000_REG_CTRL_SEL_MD_CTRL,
-                                            rx[1] & ~(this_attr->mask));
+                                            ctrlval &
+                                            ~(sca3000_addresses[num][2]));
                if (ret)
-                       goto exit_point_free_rx;
+                       goto exit_point;
                st->mo_det_use_count--;
-       } else /* relies on clean state for device on boot */
-               goto exit_point_free_rx;
-       kfree(rx);
+       }
+
        /* read current value of mode register */
-       ret = sca3000_read_data(st, SCA3000_REG_ADDR_MODE, &rx, 1);
+       ret = sca3000_read_data_short(st, SCA3000_REG_ADDR_MODE, 1);
        if (ret)
                goto exit_point;
        /*if off and should be on*/
        if ((st->mo_det_use_count)
-           && ((rx[1]&protect_mask) != SCA3000_MEAS_MODE_MOT_DET))
+           && ((st->rx[0] & protect_mask) != SCA3000_MEAS_MODE_MOT_DET))
                ret = sca3000_write_reg(st, SCA3000_REG_ADDR_MODE,
-                                       (rx[1] & ~protect_mask)
+                                       (st->rx[0] & ~protect_mask)
                                        | SCA3000_MEAS_MODE_MOT_DET);
        /* if on and should be off */
        else if (!(st->mo_det_use_count)
-                && ((rx[1]&protect_mask) == SCA3000_MEAS_MODE_MOT_DET))
+                && ((st->rx[0] & protect_mask) == SCA3000_MEAS_MODE_MOT_DET))
                ret = sca3000_write_reg(st, SCA3000_REG_ADDR_MODE,
-                                       (rx[1] & ~protect_mask));
-exit_point_free_rx:
-       kfree(rx);
+                                       (st->rx[0] & ~protect_mask));
 exit_point:
        mutex_unlock(&st->lock);
 
-       return ret ? ret : len;
+       return ret;
 }
 
-/* Shared event handler for all events as single event status register */
-IIO_EVENT_SH(all, &sca3000_handler_th);
-
 /* Free fall detector related event attribute */
-IIO_EVENT_ATTR_NAMED_SH(accel_xayaz_mag_falling_en,
-                       accel_x&y&z_mag_falling_en,
-                       iio_event_all,
-                       sca3000_query_free_fall_mode,
-                       sca3000_set_free_fall_mode,
-                       0);
-
-IIO_CONST_ATTR_NAMED(accel_xayaz_mag_falling_period,
-                    accel_x&y&z_mag_falling_period,
-                    "0.226");
-
-/* Motion detector related event attributes */
-IIO_EVENT_ATTR_SH(accel_x_mag_rising_en,
-                 iio_event_all,
-                 sca3000_query_mo_det,
-                 sca3000_set_mo_det,
-                 SCA3000_MD_CTRL_OR_X);
-
-IIO_EVENT_ATTR_SH(accel_y_mag_rising_en,
-                 iio_event_all,
-                 sca3000_query_mo_det,
-                 sca3000_set_mo_det,
-                 SCA3000_MD_CTRL_OR_Y);
-
-IIO_EVENT_ATTR_SH(accel_z_mag_rising_en,
-                 iio_event_all,
-                 sca3000_query_mo_det,
-                 sca3000_set_mo_det,
-                 SCA3000_MD_CTRL_OR_Z);
-
-/* Hardware ring buffer related event attributes */
-IIO_EVENT_ATTR_RING_50_FULL_SH(iio_event_all,
-                              sca3000_query_ring_int,
-                              sca3000_set_ring_int,
-                              SCA3000_INT_MASK_RING_HALF);
-
-IIO_EVENT_ATTR_RING_75_FULL_SH(iio_event_all,
-                              sca3000_query_ring_int,
-                              sca3000_set_ring_int,
-                              SCA3000_INT_MASK_RING_THREE_QUARTER);
+static IIO_DEVICE_ATTR_NAMED(accel_xayaz_mag_falling_en,
+                            accel_x&y&z_mag_falling_en,
+                            S_IRUGO | S_IWUSR,
+                            sca3000_query_free_fall_mode,
+                            sca3000_set_free_fall_mode,
+                            0);
+
+static IIO_CONST_ATTR_NAMED(accel_xayaz_mag_falling_period,
+                           accel_x&y&z_mag_falling_period,
+                           "0.226");
 
 static struct attribute *sca3000_event_attributes[] = {
-       &iio_event_attr_accel_xayaz_mag_falling_en.dev_attr.attr,
+       &iio_dev_attr_accel_xayaz_mag_falling_en.dev_attr.attr,
        &iio_const_attr_accel_xayaz_mag_falling_period.dev_attr.attr,
-       &iio_event_attr_accel_x_mag_rising_en.dev_attr.attr,
-       &iio_dev_attr_accel_x_raw_mag_rising_value.dev_attr.attr,
-       &iio_event_attr_accel_y_mag_rising_en.dev_attr.attr,
-       &iio_dev_attr_accel_y_raw_mag_rising_value.dev_attr.attr,
-       &iio_event_attr_accel_z_mag_rising_en.dev_attr.attr,
-       &iio_dev_attr_accel_z_raw_mag_rising_value.dev_attr.attr,
-       &iio_event_attr_ring_50_full.dev_attr.attr,
-       &iio_event_attr_ring_75_full.dev_attr.attr,
        NULL,
 };
 
@@ -1241,70 +1049,50 @@ static struct attribute_group sca3000_event_attribute_group = {
 static int sca3000_clean_setup(struct sca3000_state *st)
 {
        int ret;
-       u8 *rx;
 
        mutex_lock(&st->lock);
        /* Ensure all interrupts have been acknowledged */
-       ret = sca3000_read_data(st, SCA3000_REG_ADDR_INT_STATUS, &rx, 1);
+       ret = sca3000_read_data_short(st, SCA3000_REG_ADDR_INT_STATUS, 1);
        if (ret)
                goto error_ret;
-       kfree(rx);
 
        /* Turn off all motion detection channels */
-       ret = sca3000_read_ctrl_reg(st,
-                                   SCA3000_REG_CTRL_SEL_MD_CTRL,
-                                   &rx);
-       if (ret)
+       ret = sca3000_read_ctrl_reg(st, SCA3000_REG_CTRL_SEL_MD_CTRL);
+       if (ret < 0)
                goto error_ret;
-       ret = sca3000_write_ctrl_reg(st,
-                                    SCA3000_REG_CTRL_SEL_MD_CTRL,
-                                    rx[1] & SCA3000_MD_CTRL_PROT_MASK);
-       kfree(rx);
+       ret = sca3000_write_ctrl_reg(st, SCA3000_REG_CTRL_SEL_MD_CTRL,
+                                    ret & SCA3000_MD_CTRL_PROT_MASK);
        if (ret)
                goto error_ret;
 
        /* Disable ring buffer */
-       sca3000_read_ctrl_reg(st,
-                             SCA3000_REG_CTRL_SEL_OUT_CTRL,
-                             &rx);
-       /* Frequency of ring buffer sampling deliberately restricted to make
-        * debugging easier - add control of this later */
-       ret = sca3000_write_ctrl_reg(st,
-                                    SCA3000_REG_CTRL_SEL_OUT_CTRL,
-                                    (rx[1] & SCA3000_OUT_CTRL_PROT_MASK)
+       ret = sca3000_read_ctrl_reg(st, SCA3000_REG_CTRL_SEL_OUT_CTRL);
+       ret = sca3000_write_ctrl_reg(st, SCA3000_REG_CTRL_SEL_OUT_CTRL,
+                                    (ret & SCA3000_OUT_CTRL_PROT_MASK)
                                     | SCA3000_OUT_CTRL_BUF_X_EN
                                     | SCA3000_OUT_CTRL_BUF_Y_EN
                                     | SCA3000_OUT_CTRL_BUF_Z_EN
                                     | SCA3000_OUT_CTRL_BUF_DIV_4);
-       kfree(rx);
-
        if (ret)
                goto error_ret;
        /* Enable interrupts, relevant to mode and set up as active low */
-       ret = sca3000_read_data(st,
-                         SCA3000_REG_ADDR_INT_MASK,
-                         &rx, 1);
+       ret = sca3000_read_data_short(st, SCA3000_REG_ADDR_INT_MASK, 1);
        if (ret)
                goto error_ret;
        ret = sca3000_write_reg(st,
                                SCA3000_REG_ADDR_INT_MASK,
-                               (rx[1] & SCA3000_INT_MASK_PROT_MASK)
+                               (ret & SCA3000_INT_MASK_PROT_MASK)
                                | SCA3000_INT_MASK_ACTIVE_LOW);
-       kfree(rx);
        if (ret)
                goto error_ret;
        /* Select normal measurement mode, free fall off, ring off */
        /* Ring in 12 bit mode - it is fine to overwrite reserved bits 3,5
         * as that occurs in one of the example on the datasheet */
-       ret = sca3000_read_data(st,
-                         SCA3000_REG_ADDR_MODE,
-                         &rx, 1);
+       ret = sca3000_read_data_short(st, SCA3000_REG_ADDR_MODE, 1);
        if (ret)
                goto error_ret;
-       ret = sca3000_write_reg(st,
-                               SCA3000_REG_ADDR_MODE,
-                               (rx[1] & SCA3000_MODE_PROT_MASK));
-       kfree(rx);
+       ret = sca3000_write_reg(st, SCA3000_REG_ADDR_MODE,
+                               (st->rx[0] & SCA3000_MODE_PROT_MASK));
        st->bpse = 11;
 
 error_ret:
@@ -1312,8 +1100,29 @@ error_ret:
        return ret;
 }
 
-static int __devinit __sca3000_probe(struct spi_device *spi,
-                                    enum sca3000_variant variant)
+static const struct iio_info sca3000_info = {
+       .attrs = &sca3000_attribute_group,
+       .read_raw = &sca3000_read_raw,
+       .num_interrupt_lines = 1,
+       .event_attrs = &sca3000_event_attribute_group,
+       .read_event_value = &sca3000_read_thresh,
+       .write_event_value = &sca3000_write_thresh,
+       .read_event_config = &sca3000_read_event_config,
+       .write_event_config = &sca3000_write_event_config,
+       .driver_module = THIS_MODULE,
+};
+
+static const struct iio_info sca3000_info_with_temp = {
+       .attrs = &sca3000_attribute_group_with_temp,
+       .read_raw = &sca3000_read_raw,
+       .read_event_value = &sca3000_read_thresh,
+       .write_event_value = &sca3000_write_thresh,
+       .read_event_config = &sca3000_read_event_config,
+       .write_event_config = &sca3000_write_event_config,
+       .driver_module = THIS_MODULE,
+};
+
+static int __devinit sca3000_probe(struct spi_device *spi)
 {
        int ret, regdone = 0;
        struct sca3000_state *st;
@@ -1325,75 +1134,57 @@ static int __devinit __sca3000_probe(struct spi_device *spi,
        }
        spi_set_drvdata(spi, st);
 
-       st->tx = kmalloc(sizeof(*st->tx)*6, GFP_KERNEL);
-       if (st->tx == NULL) {
-               ret = -ENOMEM;
-               goto error_clear_st;
-       }
-       st->rx = kmalloc(sizeof(*st->rx)*3, GFP_KERNEL);
-       if (st->rx == NULL) {
-               ret = -ENOMEM;
-               goto error_free_tx;
-       }
        st->us = spi;
        mutex_init(&st->lock);
-       st->info = &sca3000_spi_chip_info_tbl[variant];
+       st->info = &sca3000_spi_chip_info_tbl[spi_get_device_id(spi)
+                                             ->driver_data];
 
-       st->indio_dev = iio_allocate_device();
+       st->indio_dev = iio_allocate_device(0);
        if (st->indio_dev == NULL) {
                ret = -ENOMEM;
-               goto error_free_rx;
+               goto error_clear_st;
        }
-
        st->indio_dev->dev.parent = &spi->dev;
-       st->indio_dev->num_interrupt_lines = 1;
-       st->indio_dev->event_attrs = &sca3000_event_attribute_group;
+       st->indio_dev->name = spi_get_device_id(spi)->name;
        if (st->info->temp_output)
-               st->indio_dev->attrs = &sca3000_attribute_group_with_temp;
-       else
-               st->indio_dev->attrs = &sca3000_attribute_group;
+               st->indio_dev->info = &sca3000_info_with_temp;
+       else {
+               st->indio_dev->info = &sca3000_info;
+               st->indio_dev->channels = sca3000_channels;
+               st->indio_dev->num_channels = ARRAY_SIZE(sca3000_channels);
+       }
        st->indio_dev->dev_data = (void *)(st);
        st->indio_dev->modes = INDIO_DIRECT_MODE;
 
        sca3000_configure_ring(st->indio_dev);
-
        ret = iio_device_register(st->indio_dev);
        if (ret < 0)
                goto error_free_dev;
        regdone = 1;
-       ret = iio_ring_buffer_register(st->indio_dev->ring, 0);
+       ret = iio_ring_buffer_register_ex(st->indio_dev->ring, 0,
+                                         sca3000_channels,
+                                         ARRAY_SIZE(sca3000_channels));
        if (ret < 0)
                goto error_unregister_dev;
        if (spi->irq && gpio_is_valid(irq_to_gpio(spi->irq)) > 0) {
-               INIT_WORK(&st->interrupt_handler_ws,
-                         sca3000_interrupt_handler_bh);
-               ret = iio_register_interrupt_line(spi->irq,
-                                                 st->indio_dev,
-                                                 0,
-                                                 IRQF_TRIGGER_FALLING,
-                                                 "sca3000");
+               ret = request_threaded_irq(spi->irq,
+                                          NULL,
+                                          &sca3000_event_handler,
+                                          IRQF_TRIGGER_FALLING,
+                                          "sca3000",
+                                          st->indio_dev);
                if (ret)
                        goto error_unregister_ring;
-               /* RFC
-                * Probably a common situation.  All interrupts need an ack
-                * and there is only one handler so the complicated list system
-                * is overkill.  At very least a simpler registration method
-                * might be worthwhile.
-                */
-               iio_add_event_to_list(
-                       iio_event_attr_accel_z_mag_rising_en.listel,
-                       &st->indio_dev
-                       ->interrupts[0]->ev_list);
        }
        sca3000_register_ring_funcs(st->indio_dev);
        ret = sca3000_clean_setup(st);
        if (ret)
-               goto error_unregister_interrupt_line;
+               goto error_free_irq;
        return 0;
 
-error_unregister_interrupt_line:
+error_free_irq:
        if (spi->irq && gpio_is_valid(irq_to_gpio(spi->irq)) > 0)
-               iio_unregister_interrupt_line(st->indio_dev, 0);
+               free_irq(spi->irq, st->indio_dev);
 error_unregister_ring:
        iio_ring_buffer_unregister(st->indio_dev->ring);
 error_unregister_dev:
@@ -1402,10 +1193,6 @@ error_free_dev:
                iio_device_unregister(st->indio_dev);
        else
                iio_free_device(st->indio_dev);
-error_free_rx:
-       kfree(st->rx);
-error_free_tx:
-       kfree(st->tx);
 error_clear_st:
        kfree(st);
 error_ret:
@@ -1415,20 +1202,19 @@ error_ret:
 static int sca3000_stop_all_interrupts(struct sca3000_state *st)
 {
        int ret;
-       u8 *rx;
 
        mutex_lock(&st->lock);
-       ret = sca3000_read_data(st, SCA3000_REG_ADDR_INT_MASK, &rx, 1);
+       ret = sca3000_read_data_short(st, SCA3000_REG_ADDR_INT_MASK, 1);
        if (ret)
                goto error_ret;
        ret = sca3000_write_reg(st, SCA3000_REG_ADDR_INT_MASK,
-                               (rx[1] & ~(SCA3000_INT_MASK_RING_THREE_QUARTER
-                                          | SCA3000_INT_MASK_RING_HALF
-                                          | SCA3000_INT_MASK_ALL_INTS)));
+                               (st->rx[0] &
+                                ~(SCA3000_INT_MASK_RING_THREE_QUARTER |
+                                  SCA3000_INT_MASK_RING_HALF |
+                                  SCA3000_INT_MASK_ALL_INTS)));
 error_ret:
-       kfree(rx);
+       mutex_unlock(&st->lock);
        return ret;
-
 }
 
 static int sca3000_remove(struct spi_device *spi)
@@ -1441,87 +1227,44 @@ static int sca3000_remove(struct spi_device *spi)
        if (ret)
                return ret;
        if (spi->irq && gpio_is_valid(irq_to_gpio(spi->irq)) > 0)
-               iio_unregister_interrupt_line(indio_dev, 0);
+               free_irq(spi->irq, indio_dev);
        iio_ring_buffer_unregister(indio_dev->ring);
        sca3000_unconfigure_ring(indio_dev);
        iio_device_unregister(indio_dev);
 
-       kfree(st->tx);
-       kfree(st->rx);
        kfree(st);
 
        return 0;
 }
 
-/* These macros save on an awful lot of repeated code */
-#define SCA3000_VARIANT_PROBE(_name)                           \
-       static int __devinit                                    \
-       sca3000_##_name##_probe(struct spi_device *spi)         \
-       {                                                       \
-               return __sca3000_probe(spi, _name);             \
-       }
-
-#define SCA3000_VARIANT_SPI_DRIVER(_name)                      \
-       struct spi_driver sca3000_##_name##_driver = {          \
-               .driver = {                                     \
-                       .name = "sca3000_" #_name,              \
-                       .owner = THIS_MODULE,                   \
-               },                                              \
-               .probe = sca3000_##_name##_probe,               \
-               .remove = __devexit_p(sca3000_remove),          \
-       }
-
-SCA3000_VARIANT_PROBE(d01);
-static SCA3000_VARIANT_SPI_DRIVER(d01);
-
-SCA3000_VARIANT_PROBE(e02);
-static SCA3000_VARIANT_SPI_DRIVER(e02);
-
-SCA3000_VARIANT_PROBE(e04);
-static SCA3000_VARIANT_SPI_DRIVER(e04);
+static const struct spi_device_id sca3000_id[] = {
+       {"sca3000_d01", d01},
+       {"sca3000_e02", e02},
+       {"sca3000_e04", e04},
+       {"sca3000_e05", e05},
+       {}
+};
 
-SCA3000_VARIANT_PROBE(e05);
-static SCA3000_VARIANT_SPI_DRIVER(e05);
+static struct spi_driver sca3000_driver = {
+       .driver = {
+               .name = "sca3000",
+               .owner = THIS_MODULE,
+       },
+       .probe = sca3000_probe,
+       .remove = __devexit_p(sca3000_remove),
+       .id_table = sca3000_id,
+};
 
 static __init int sca3000_init(void)
 {
-       int ret;
-
-       ret = spi_register_driver(&sca3000_d01_driver);
-       if (ret)
-               goto error_ret;
-       ret = spi_register_driver(&sca3000_e02_driver);
-       if (ret)
-               goto error_unreg_d01;
-       ret = spi_register_driver(&sca3000_e04_driver);
-       if (ret)
-               goto error_unreg_e02;
-       ret = spi_register_driver(&sca3000_e05_driver);
-       if (ret)
-               goto error_unreg_e04;
-
-       return 0;
-
-error_unreg_e04:
-       spi_unregister_driver(&sca3000_e04_driver);
-error_unreg_e02:
-       spi_unregister_driver(&sca3000_e02_driver);
-error_unreg_d01:
-       spi_unregister_driver(&sca3000_d01_driver);
-error_ret:
-
-       return ret;
+       return spi_register_driver(&sca3000_driver);
 }
+module_init(sca3000_init);
 
 static __exit void sca3000_exit(void)
 {
-       spi_unregister_driver(&sca3000_e05_driver);
-       spi_unregister_driver(&sca3000_e04_driver);
-       spi_unregister_driver(&sca3000_e02_driver);
-       spi_unregister_driver(&sca3000_d01_driver);
+       spi_unregister_driver(&sca3000_driver);
 }
-
-module_init(sca3000_init);
 module_exit(sca3000_exit);
 
 MODULE_AUTHOR("Jonathan Cameron <jic23@cam.ac.uk>");
index a730a7638de18de9e669f7bc7783291db190419c..7c4ff0b1df041b1142ffb14c13f1c9b246efb86b 100644 (file)
@@ -17,6 +17,8 @@
 #include <linux/kernel.h>
 #include <linux/spi/spi.h>
 #include <linux/sysfs.h>
+#include <linux/sched.h>
+#include <linux/poll.h>
 
 #include "../iio.h"
 #include "../sysfs.h"
  * Currently scan elements aren't configured so it doesn't matter.
  */
 
+static int sca3000_read_data(struct sca3000_state *st,
+                           uint8_t reg_address_high,
+                           u8 **rx_p,
+                           int len)
+{
+       int ret;
+       struct spi_message msg;
+       struct spi_transfer xfer[2] = {
+               {
+                       .len = 1,
+                       .tx_buf = st->tx,
+               }, {
+                       .len = len,
+               }
+       };
+       *rx_p = kmalloc(len, GFP_KERNEL);
+       if (*rx_p == NULL) {
+               ret = -ENOMEM;
+               goto error_ret;
+       }
+       xfer[1].rx_buf = *rx_p;
+       st->tx[0] = SCA3000_READ_REG(reg_address_high);
+       spi_message_init(&msg);
+       spi_message_add_tail(&xfer[0], &msg);
+       spi_message_add_tail(&xfer[1], &msg);
+       ret = spi_sync(st->us, &msg);
+       if (ret) {
+               dev_err(get_device(&st->us->dev), "problem reading register");
+               goto error_free_rx;
+       }
+
+       return 0;
+error_free_rx:
+       kfree(*rx_p);
+error_ret:
+       return ret;
+}
+
 /**
- * sca3000_rip_hw_rb() - main ring access function, pulls data from ring
+ * sca3000_read_first_n_hw_rb() - main ring access, pulls data from ring
  * @r:                 the ring
  * @count:             number of samples to try and pull
  * @data:              output the actual samples pulled from the hw ring
- * @dead_offset:       cheating a bit here: Set to 1 so as to allow for the
- *                     leading byte used in bus comms.
  *
  * Currently does not provide timestamps.  As the hardware doesn't add them they
  * can only be inferred approximately from ring buffer events such as 50% full
  * and knowledge of when buffer was last emptied.  This is left to userspace.
  **/
-static int sca3000_rip_hw_rb(struct iio_ring_buffer *r,
-                            size_t count, u8 **data, int *dead_offset)
+static int sca3000_read_first_n_hw_rb(struct iio_ring_buffer *r,
+                                     size_t count, char __user *buf)
 {
        struct iio_hw_ring_buffer *hw_ring = iio_to_hw_ring_buf(r);
        struct iio_dev *indio_dev = hw_ring->private;
        struct sca3000_state *st = indio_dev->dev_data;
        u8 *rx;
-       s16 *samples;
        int ret, i, num_available, num_read = 0;
        int bytes_per_sample = 1;
 
@@ -61,44 +98,38 @@ static int sca3000_rip_hw_rb(struct iio_ring_buffer *r,
                bytes_per_sample = 2;
 
        mutex_lock(&st->lock);
-       /* Check how much data is available:
-        * RFC: Implement an ioctl to not bother checking whether there
-        * is enough data in the ring?  Afterall, if we are responding
-        * to an interrupt we have a minimum content guaranteed so it
-        * seems slight silly to waste time checking it is there.
-        */
-       ret = sca3000_read_data(st,
-                               SCA3000_REG_ADDR_BUF_COUNT,
-                               &rx, 1);
+       if (count % bytes_per_sample) {
+               ret = -EINVAL;
+               goto error_ret;
+       }
+
+       ret = sca3000_read_data_short(st, SCA3000_REG_ADDR_BUF_COUNT, 1);
        if (ret)
                goto error_ret;
        else
-               num_available = rx[1];
-       /* num_available is the total number of samples available
+               num_available = st->rx[0];
+       /*
+        * num_available is the total number of samples available
         * i.e. number of time points * number of channels.
         */
-       kfree(rx);
        if (count > num_available * bytes_per_sample)
                num_read = num_available*bytes_per_sample;
        else
-               num_read = count - (count % (bytes_per_sample));
+               num_read = count;
 
-       /* Avoid the read request byte */
-       *dead_offset = 1;
        ret = sca3000_read_data(st,
                                SCA3000_REG_ADDR_RING_OUT,
-                               data, num_read);
-
-       /* Convert byte order and shift to default resolution */
-       if (st->bpse == 11) {
-               samples = (s16*)(*data+1);
-               for (i = 0; i < (num_read/2); i++) {
-                       samples[i] = be16_to_cpup(
-                                       (__be16 *)&(samples[i]));
-                       samples[i] >>= 3;
-               }
-       }
+                               &rx, num_read);
+       if (ret)
+               goto error_ret;
 
+       for (i = 0; i < num_read; i++)
+               *(((u16 *)rx) + i) = be16_to_cpup((u16 *)rx + i);
+
+       if (copy_to_user(buf, rx, num_read))
+               ret = -EFAULT;
+       kfree(rx);
+       r->stufftoread = 0;
 error_ret:
        mutex_unlock(&st->lock);
 
@@ -126,6 +157,76 @@ static IIO_RING_ENABLE_ATTR;
 static IIO_RING_BYTES_PER_DATUM_ATTR;
 static IIO_RING_LENGTH_ATTR;
 
+/**
+ * sca3000_query_ring_int() is the hardware ring status interrupt enabled
+ **/
+static ssize_t sca3000_query_ring_int(struct device *dev,
+                                     struct device_attribute *attr,
+                                     char *buf)
+{
+       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
+       int ret, val;
+       struct iio_ring_buffer *ring = dev_get_drvdata(dev);
+       struct iio_dev *indio_dev = ring->indio_dev;
+       struct sca3000_state *st = indio_dev->dev_data;
+
+       mutex_lock(&st->lock);
+       ret = sca3000_read_data_short(st, SCA3000_REG_ADDR_INT_MASK, 1);
+       val = st->rx[0];
+       mutex_unlock(&st->lock);
+       if (ret)
+               return ret;
+
+       return sprintf(buf, "%d\n", !!(val & this_attr->address));
+}
+
+/**
+ * sca3000_set_ring_int() set state of ring status interrupt
+ **/
+static ssize_t sca3000_set_ring_int(struct device *dev,
+                                     struct device_attribute *attr,
+                                     const char *buf,
+                                     size_t len)
+{
+       struct iio_ring_buffer *ring = dev_get_drvdata(dev);
+       struct iio_dev *indio_dev = ring->indio_dev;
+       struct sca3000_state *st = indio_dev->dev_data;
+       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
+       long val;
+       int ret;
+
+       mutex_lock(&st->lock);
+       ret = strict_strtol(buf, 10, &val);
+       if (ret)
+               goto error_ret;
+       ret = sca3000_read_data_short(st, SCA3000_REG_ADDR_INT_MASK, 1);
+       if (ret)
+               goto error_ret;
+       if (val)
+               ret = sca3000_write_reg(st,
+                                       SCA3000_REG_ADDR_INT_MASK,
+                                       st->rx[0] | this_attr->address);
+       else
+               ret = sca3000_write_reg(st,
+                                       SCA3000_REG_ADDR_INT_MASK,
+                                       st->rx[0] & ~this_attr->address);
+error_ret:
+       mutex_unlock(&st->lock);
+
+       return ret ? ret : len;
+}
+
+static IIO_DEVICE_ATTR(50_percent, S_IRUGO | S_IWUSR,
+                      sca3000_query_ring_int,
+                      sca3000_set_ring_int,
+                      SCA3000_INT_MASK_RING_HALF);
+
+static IIO_DEVICE_ATTR(75_percent, S_IRUGO | S_IWUSR,
+                      sca3000_query_ring_int,
+                      sca3000_set_ring_int,
+                      SCA3000_INT_MASK_RING_THREE_QUARTER);
+
+
 /**
  * sca3000_show_ring_bpse() -sysfs function to query bits per sample from ring
  * @dev: ring buffer device
@@ -137,20 +238,18 @@ static ssize_t sca3000_show_ring_bpse(struct device *dev,
                                      char *buf)
 {
        int len = 0, ret;
-       u8 *rx;
        struct iio_ring_buffer *ring = dev_get_drvdata(dev);
        struct iio_dev *indio_dev = ring->indio_dev;
        struct sca3000_state *st = indio_dev->dev_data;
 
        mutex_lock(&st->lock);
-       ret = sca3000_read_data(st, SCA3000_REG_ADDR_MODE, &rx, 1);
+       ret = sca3000_read_data_short(st, SCA3000_REG_ADDR_MODE, 1);
        if (ret)
                goto error_ret;
-       if (rx[1] & SCA3000_RING_BUF_8BIT)
+       if (st->rx[0] & SCA3000_RING_BUF_8BIT)
                len = sprintf(buf, "s8/8\n");
        else
                len = sprintf(buf, "s11/16\n");
-       kfree(rx);
 error_ret:
        mutex_unlock(&st->lock);
 
@@ -173,20 +272,19 @@ static ssize_t sca3000_store_ring_bpse(struct device *dev,
        struct iio_dev *indio_dev = ring->indio_dev;
        struct sca3000_state *st = indio_dev->dev_data;
        int ret;
-       u8 *rx;
 
        mutex_lock(&st->lock);
 
-       ret = sca3000_read_data(st, SCA3000_REG_ADDR_MODE, &rx, 1);
+       ret = sca3000_read_data_short(st, SCA3000_REG_ADDR_MODE, 1);
        if (ret)
                goto error_ret;
-       if (strncmp(buf, "s8/8", 4) == 0) {
+       if (sysfs_streq(buf, "s8/8")) {
                ret = sca3000_write_reg(st, SCA3000_REG_ADDR_MODE,
-                                       rx[1] | SCA3000_RING_BUF_8BIT);
+                                       st->rx[0] | SCA3000_RING_BUF_8BIT);
                st->bpse = 8;
-       } else if (strncmp(buf, "s11/16", 5) == 0) {
+       } else if (sysfs_streq(buf, "s11/16")) {
                ret = sca3000_write_reg(st, SCA3000_REG_ADDR_MODE,
-                                       rx[1] & ~SCA3000_RING_BUF_8BIT);
+                                       st->rx[0] & ~SCA3000_RING_BUF_8BIT);
                st->bpse = 11;
        } else
                ret = -EINVAL;
@@ -196,32 +294,22 @@ error_ret:
        return ret ? ret : len;
 }
 
-static IIO_SCAN_EL_C(accel_x, 0, 0, NULL);
-static IIO_SCAN_EL_C(accel_y, 1, 0, NULL);
-static IIO_SCAN_EL_C(accel_z, 2, 0, NULL);
-static IIO_CONST_ATTR(accel_type_available, "s8/8 s11/16");
-static IIO_DEVICE_ATTR(accel_type,
-                      S_IRUGO | S_IWUSR,
-                      sca3000_show_ring_bpse,
-                      sca3000_store_ring_bpse,
-                      0);
+static ssize_t sca3000_show_buffer_scale(struct device *dev,
+                                        struct device_attribute *attr,
+                                        char *buf)
+{
+       struct iio_ring_buffer *ring = dev_get_drvdata(dev);
+       struct iio_dev *indio_dev = ring->indio_dev;
+       struct sca3000_state *st = indio_dev->dev_data;
 
-static struct attribute *sca3000_scan_el_attrs[] = {
-       &iio_scan_el_accel_x.dev_attr.attr,
-       &iio_const_attr_accel_x_index.dev_attr.attr,
-       &iio_scan_el_accel_y.dev_attr.attr,
-       &iio_const_attr_accel_y_index.dev_attr.attr,
-       &iio_scan_el_accel_z.dev_attr.attr,
-       &iio_const_attr_accel_z_index.dev_attr.attr,
-       &iio_const_attr_accel_type_available.dev_attr.attr,
-       &iio_dev_attr_accel_type.dev_attr.attr,
-       NULL
-};
+       return sprintf(buf, "0.%06d\n", 4*st->info->scale);
+}
 
-static struct attribute_group sca3000_scan_el_group = {
-       .attrs = sca3000_scan_el_attrs,
-       .name = "scan_elements",
-};
+static IIO_DEVICE_ATTR(accel_scale,
+                      S_IRUGO,
+                      sca3000_show_buffer_scale,
+                      NULL,
+                      0);
 
 /*
  * Ring buffer attributes
@@ -233,6 +321,9 @@ static struct attribute *sca3000_ring_attributes[] = {
        &dev_attr_length.attr,
        &dev_attr_bytes_per_datum.attr,
        &dev_attr_enable.attr,
+       &iio_dev_attr_50_percent.dev_attr.attr,
+       &iio_dev_attr_75_percent.dev_attr.attr,
+       &iio_dev_attr_accel_scale.dev_attr.attr,
        NULL,
 };
 
@@ -258,11 +349,12 @@ static struct iio_ring_buffer *sca3000_rb_allocate(struct iio_dev *indio_dev)
        ring = kzalloc(sizeof *ring, GFP_KERNEL);
        if (!ring)
                return NULL;
+
        ring->private = indio_dev;
        buf = &ring->buf;
+       buf->stufftoread = 0;
        iio_ring_buffer_init(buf, indio_dev);
        buf->dev.type = &sca3000_ring_type;
-       device_initialize(&buf->dev);
        buf->dev.parent = &indio_dev->dev;
        dev_set_drvdata(&buf->dev, (void *)buf);
 
@@ -275,6 +367,12 @@ static inline void sca3000_rb_free(struct iio_ring_buffer *r)
                iio_put_ring_buffer(r);
 }
 
+static const struct iio_ring_access_funcs sca3000_ring_access_funcs = {
+       .read_first_n = &sca3000_read_first_n_hw_rb,
+       .get_length = &sca3000_ring_get_length,
+       .get_bytes_per_datum = &sca3000_ring_get_bytes_per_datum,
+};
+
 int sca3000_configure_ring(struct iio_dev *indio_dev)
 {
        indio_dev->ring = sca3000_rb_allocate(indio_dev);
@@ -282,10 +380,11 @@ int sca3000_configure_ring(struct iio_dev *indio_dev)
                return -ENOMEM;
        indio_dev->modes |= INDIO_RING_HARDWARE_BUFFER;
 
-       indio_dev->ring->scan_el_attrs = &sca3000_scan_el_group;
-       indio_dev->ring->access.rip_lots = &sca3000_rip_hw_rb;
-       indio_dev->ring->access.get_length = &sca3000_ring_get_length;
-       indio_dev->ring->access.get_bytes_per_datum = &sca3000_ring_get_bytes_per_datum;
+       indio_dev->ring->access = &sca3000_ring_access_funcs;
+
+       iio_scan_mask_set(indio_dev->ring, 0);
+       iio_scan_mask_set(indio_dev->ring, 1);
+       iio_scan_mask_set(indio_dev->ring, 2);
 
        return 0;
 }
@@ -300,22 +399,20 @@ int __sca3000_hw_ring_state_set(struct iio_dev *indio_dev, bool state)
 {
        struct sca3000_state *st = indio_dev->dev_data;
        int ret;
-       u8 *rx;
 
        mutex_lock(&st->lock);
-       ret = sca3000_read_data(st, SCA3000_REG_ADDR_MODE, &rx, 1);
+       ret = sca3000_read_data_short(st, SCA3000_REG_ADDR_MODE, 1);
        if (ret)
                goto error_ret;
        if (state) {
                printk(KERN_INFO "supposedly enabling ring buffer\n");
                ret = sca3000_write_reg(st,
                                        SCA3000_REG_ADDR_MODE,
-                                       (rx[1] | SCA3000_RING_BUF_ENABLE));
+                                       (st->rx[0] | SCA3000_RING_BUF_ENABLE));
        } else
                ret = sca3000_write_reg(st,
                                        SCA3000_REG_ADDR_MODE,
-                                       (rx[1] & ~SCA3000_RING_BUF_ENABLE));
-       kfree(rx);
+                                       (st->rx[0] & ~SCA3000_RING_BUF_ENABLE));
 error_ret:
        mutex_unlock(&st->lock);
 
@@ -338,10 +435,14 @@ static int sca3000_hw_ring_postdisable(struct iio_dev *indio_dev)
        return __sca3000_hw_ring_state_set(indio_dev, 0);
 }
 
+static const struct iio_ring_setup_ops sca3000_ring_setup_ops = {
+       .preenable = &sca3000_hw_ring_preenable,
+       .postdisable = &sca3000_hw_ring_postdisable,
+};
+
 void sca3000_register_ring_funcs(struct iio_dev *indio_dev)
 {
-       indio_dev->ring->preenable = &sca3000_hw_ring_preenable;
-       indio_dev->ring->postdisable = &sca3000_hw_ring_postdisable;
+       indio_dev->ring->setup_ops = &sca3000_ring_setup_ops;
 }
 
 /**
@@ -352,11 +453,9 @@ void sca3000_register_ring_funcs(struct iio_dev *indio_dev)
  **/
 void sca3000_ring_int_process(u8 val, struct iio_ring_buffer *ring)
 {
-       if (val & SCA3000_INT_STATUS_THREE_QUARTERS)
-               iio_push_or_escallate_ring_event(ring,
-                                                IIO_EVENT_CODE_RING_75_FULL,
-                                                0);
-       else if (val & SCA3000_INT_STATUS_HALF)
-               iio_push_ring_event(ring,
-                                   IIO_EVENT_CODE_RING_50_FULL, 0);
+       if (val & (SCA3000_INT_STATUS_THREE_QUARTERS |
+                  SCA3000_INT_STATUS_HALF)) {
+               ring->stufftoread = true;
+               wake_up_interruptible(&ring->pollq);
+       }
 }
index 6692a3d87f2399ad417131ad3d7efc99a5ef2e77..8c751c46ddd7e080a1424c873fe29f4545aa7fde 100644 (file)
@@ -3,30 +3,6 @@
 #
 comment "Analog to digital convertors"
 
-config MAX1363
-       tristate "MAXIM max1363 ADC driver"
-       depends on I2C
-       select IIO_TRIGGER if IIO_RING_BUFFER
-       select MAX1363_RING_BUFFER
-       help
-         Say yes here to build support for many MAXIM i2c analog to digital
-         convertors (ADC). (max1361, max1362, max1363, max1364, max1036,
-         max1037, max1038, max1039, max1136, max1136, max1137, max1138,
-         max1139, max1236, max1237, max11238, max1239, max11600, max11601,
-         max11602, max11603, max11604, max11605, max11606, max11607,
-         max11608, max11609, max11610, max11611, max11612, max11613,
-         max11614, max11615, max11616, max11617) Provides direct access
-         via sysfs.
-
-config MAX1363_RING_BUFFER
-       bool "MAXIM max1363: use ring buffer"
-       depends on MAX1363
-       select IIO_RING_BUFFER
-       select IIO_SW_RING
-       help
-         Say yes here to include ring buffer support in the MAX1363
-         ADC driver.
-
 config AD7150
        tristate "Analog Devices ad7150/1/6 capacitive sensor driver"
        depends on I2C
@@ -142,6 +118,18 @@ config AD7887
          To compile this driver as a module, choose M here: the
          module will be called ad7887.
 
+config AD7780
+       tristate "Analog Devices AD7780 AD7781 ADC driver"
+       depends on SPI
+       depends on GPIOLIB
+       help
+         Say yes here to build support for Analog Devices
+         AD7780 and AD7781 SPI analog to digital convertors (ADC).
+         If unsure, say N (but it's safe to say "Y").
+
+         To compile this driver as a module, choose M here: the
+         module will be called ad7780.
+
 config AD7745
        tristate "Analog Devices AD7745, AD7746 AD7747 capacitive sensor driver"
        depends on I2C
@@ -179,3 +167,27 @@ config ADT7410
        help
          Say yes here to build support for Analog Devices ADT7410
          temperature sensors.
+
+config MAX1363
+       tristate "Maxim max1363 ADC driver"
+       depends on I2C
+       select IIO_TRIGGER if IIO_RING_BUFFER
+       select MAX1363_RING_BUFFER
+       help
+         Say yes here to build support for many Maxim i2c analog to digital
+         convertors (ADC). (max1361, max1362, max1363, max1364, max1036,
+         max1037, max1038, max1039, max1136, max1136, max1137, max1138,
+         max1139, max1236, max1237, max11238, max1239, max11600, max11601,
+         max11602, max11603, max11604, max11605, max11606, max11607,
+         max11608, max11609, max11610, max11611, max11612, max11613,
+         max11614, max11615, max11616, max11617, max11644, max11645,
+         max11646, max11647) Provides direct access via sysfs.
+
+config MAX1363_RING_BUFFER
+       bool "Maxim max1363: use ring buffer"
+       depends on MAX1363
+       select IIO_RING_BUFFER
+       select IIO_SW_RING
+       help
+         Say yes here to include ring buffer support in the MAX1363
+         ADC driver.
index 31067defd79b8be3e507aafd95a64a59a4ca2af4..1d9b3f582eab7761a7143ad9982615e160bc5952 100644 (file)
@@ -34,6 +34,7 @@ obj-$(CONFIG_AD7152) += ad7152.o
 obj-$(CONFIG_AD7291) += ad7291.o
 obj-$(CONFIG_AD7314) += ad7314.o
 obj-$(CONFIG_AD7745) += ad7745.o
+obj-$(CONFIG_AD7780) += ad7780.o
 obj-$(CONFIG_AD7816) += ad7816.o
 obj-$(CONFIG_ADT75) += adt75.o
 obj-$(CONFIG_ADT7310) += adt7310.o
index 8555766109d894e1623aaf0177e43fac75b04324..ca32b6778a9e95488f68a4c8668202b21046a280 100644 (file)
@@ -7,15 +7,10 @@
  */
 
 #include <linux/interrupt.h>
-#include <linux/gpio.h>
-#include <linux/workqueue.h>
 #include <linux/device.h>
 #include <linux/kernel.h>
 #include <linux/slab.h>
-#include <linux/sysfs.h>
-#include <linux/list.h>
 #include <linux/i2c.h>
-#include <linux/rtc.h>
 
 #include "../iio.h"
 #include "../sysfs.h"
  */
 
 struct ad7150_chip_info {
-       const char *name;
        struct i2c_client *client;
        struct iio_dev *indio_dev;
-       struct work_struct thresh_work;
        bool inter;
-       s64 last_timestamp;
        u16 ch1_threshold;     /* Ch1 Threshold (in fixed threshold mode) */
        u8  ch1_sensitivity;   /* Ch1 Sensitivity (in adaptive threshold mode) */
        u8  ch1_timeout;       /* Ch1 Timeout (in adaptive threshold mode) */
@@ -88,7 +80,8 @@ struct ad7150_conversion_mode {
        u8 reg_cfg;
 };
 
-struct ad7150_conversion_mode ad7150_conv_mode_table[AD7150_MAX_CONV_MODE] = {
+static struct ad7150_conversion_mode
+ad7150_conv_mode_table[AD7150_MAX_CONV_MODE] = {
        { "idle", 0 },
        { "continuous-conversion", 1 },
        { "single-conversion", 2 },
@@ -590,17 +583,6 @@ static IIO_DEV_ATTR_CH2_SETUP(S_IRUGO | S_IWUSR,
                ad7150_show_ch2_setup,
                ad7150_store_ch2_setup);
 
-static ssize_t ad7150_show_name(struct device *dev,
-               struct device_attribute *attr,
-               char *buf)
-{
-       struct iio_dev *dev_info = dev_get_drvdata(dev);
-       struct ad7150_chip_info *chip = dev_info->dev_data;
-       return sprintf(buf, "%s\n", chip->name);
-}
-
-static IIO_DEVICE_ATTR(name, S_IRUGO, ad7150_show_name, NULL, 0);
-
 static ssize_t ad7150_show_powerdown_timer(struct device *dev,
                struct device_attribute *attr,
                char *buf)
@@ -649,7 +631,6 @@ static struct attribute *ad7150_attributes[] = {
        &iio_dev_attr_powerdown_timer.dev_attr.attr,
        &iio_dev_attr_ch1_value.dev_attr.attr,
        &iio_dev_attr_ch2_value.dev_attr.attr,
-       &iio_dev_attr_name.dev_attr.attr,
        NULL,
 };
 
@@ -661,96 +642,57 @@ static const struct attribute_group ad7150_attribute_group = {
  * threshold events
  */
 
-#define IIO_EVENT_CODE_CH1_HIGH    IIO_BUFFER_EVENT_CODE(0)
-#define IIO_EVENT_CODE_CH1_LOW     IIO_BUFFER_EVENT_CODE(1)
-#define IIO_EVENT_CODE_CH2_HIGH    IIO_BUFFER_EVENT_CODE(2)
-#define IIO_EVENT_CODE_CH2_LOW     IIO_BUFFER_EVENT_CODE(3)
-
-#define IIO_EVENT_ATTR_CH1_HIGH_SH(_evlist, _show, _store, _mask)      \
-       IIO_EVENT_ATTR_SH(ch1_high, _evlist, _show, _store, _mask)
-
-#define IIO_EVENT_ATTR_CH2_HIGH_SH(_evlist, _show, _store, _mask)      \
-       IIO_EVENT_ATTR_SH(ch2_high, _evlist, _show, _store, _mask)
-
-#define IIO_EVENT_ATTR_CH1_LOW_SH(_evlist, _show, _store, _mask)       \
-       IIO_EVENT_ATTR_SH(ch1_low, _evlist, _show, _store, _mask)
-
-#define IIO_EVENT_ATTR_CH2_LOW_SH(_evlist, _show, _store, _mask)       \
-       IIO_EVENT_ATTR_SH(ch2_low, _evlist, _show, _store, _mask)
-
-static void ad7150_interrupt_handler_bh(struct work_struct *work_s)
+static irqreturn_t ad7150_event_handler(int irq, void *private)
 {
-       struct ad7150_chip_info *chip =
-               container_of(work_s, struct ad7150_chip_info, thresh_work);
+       struct iio_dev *indio_dev = private;
+       struct ad7150_chip_info *chip = iio_dev_get_devdata(indio_dev);
        u8 int_status;
-
-       enable_irq(chip->client->irq);
+       s64 timestamp = iio_get_time_ns();
 
        ad7150_i2c_read(chip, AD7150_STATUS, &int_status, 1);
 
        if ((int_status & AD7150_STATUS_OUT1) && !(chip->old_state & AD7150_STATUS_OUT1))
-               iio_push_event(chip->indio_dev, 0,
-                               IIO_EVENT_CODE_CH1_HIGH,
-                               chip->last_timestamp);
+               iio_push_event(indio_dev, 0,
+                              IIO_UNMOD_EVENT_CODE(IIO_EV_CLASS_IN,
+                                                   0,
+                                                   IIO_EV_TYPE_THRESH,
+                                                   IIO_EV_DIR_RISING),
+                               timestamp);
        else if ((!(int_status & AD7150_STATUS_OUT1)) && (chip->old_state & AD7150_STATUS_OUT1))
-               iio_push_event(chip->indio_dev, 0,
-                               IIO_EVENT_CODE_CH1_LOW,
-                               chip->last_timestamp);
+               iio_push_event(indio_dev, 0,
+                              IIO_UNMOD_EVENT_CODE(IIO_EV_CLASS_IN,
+                                                   0,
+                                                   IIO_EV_TYPE_THRESH,
+                                                   IIO_EV_DIR_FALLING),
+                              timestamp);
 
        if ((int_status & AD7150_STATUS_OUT2) && !(chip->old_state & AD7150_STATUS_OUT2))
-               iio_push_event(chip->indio_dev, 0,
-                               IIO_EVENT_CODE_CH2_HIGH,
-                               chip->last_timestamp);
+               iio_push_event(indio_dev, 0,
+                              IIO_UNMOD_EVENT_CODE(IIO_EV_CLASS_IN,
+                                                   1,
+                                                   IIO_EV_TYPE_THRESH,
+                                                   IIO_EV_DIR_RISING),
+                              timestamp);
        else if ((!(int_status & AD7150_STATUS_OUT2)) && (chip->old_state & AD7150_STATUS_OUT2))
-               iio_push_event(chip->indio_dev, 0,
-                               IIO_EVENT_CODE_CH2_LOW,
-                               chip->last_timestamp);
+               iio_push_event(indio_dev, 0,
+                              IIO_UNMOD_EVENT_CODE(IIO_EV_CLASS_IN,
+                                                   1,
+                                                   IIO_EV_TYPE_THRESH,
+                                                   IIO_EV_DIR_FALLING),
+                              timestamp);
+       return IRQ_HANDLED;
 }
 
-static int ad7150_interrupt_handler_th(struct iio_dev *dev_info,
-               int index,
-               s64 timestamp,
-               int no_test)
-{
-       struct ad7150_chip_info *chip = dev_info->dev_data;
-
-       chip->last_timestamp = timestamp;
-       schedule_work(&chip->thresh_work);
-
-       return 0;
-}
-
-IIO_EVENT_SH(threshold, &ad7150_interrupt_handler_th);
-
-static ssize_t ad7150_query_out_mode(struct device *dev,
-               struct device_attribute *attr,
-               char *buf)
-{
-       /*
-        * AD7150 provides two logic output channels, which can be used as interrupt
-        * but the pins are not configurable
-        */
-       return sprintf(buf, "1\n");
-}
-
-static ssize_t ad7150_set_out_mode(struct device *dev,
-               struct device_attribute *attr,
-               const char *buf,
-               size_t len)
-{
-       return len;
-}
-
-IIO_EVENT_ATTR_CH1_HIGH_SH(iio_event_threshold, ad7150_query_out_mode, ad7150_set_out_mode, 0);
-IIO_EVENT_ATTR_CH2_HIGH_SH(iio_event_threshold, ad7150_query_out_mode, ad7150_set_out_mode, 0);
-IIO_EVENT_ATTR_CH1_LOW_SH(iio_event_threshold, ad7150_query_out_mode, ad7150_set_out_mode, 0);
-IIO_EVENT_ATTR_CH2_LOW_SH(iio_event_threshold, ad7150_query_out_mode, ad7150_set_out_mode, 0);
+static IIO_CONST_ATTR(ch1_high_en, "1");
+static IIO_CONST_ATTR(ch2_high_en, "1");
+static IIO_CONST_ATTR(ch1_low_en, "1");
+static IIO_CONST_ATTR(ch2_low_en, "1");
 
 static struct attribute *ad7150_event_attributes[] = {
-       &iio_event_attr_ch1_high.dev_attr.attr,
-       &iio_event_attr_ch2_high.dev_attr.attr,
-       &iio_event_attr_ch1_low.dev_attr.attr,
-       &iio_event_attr_ch2_low.dev_attr.attr,
+       &iio_const_attr_ch1_high_en.dev_attr.attr,
+       &iio_const_attr_ch2_high_en.dev_attr.attr,
+       &iio_const_attr_ch1_low_en.dev_attr.attr,
+       &iio_const_attr_ch2_low_en.dev_attr.attr,
        NULL,
 };
 
@@ -758,6 +700,12 @@ static struct attribute_group ad7150_event_attribute_group = {
        .attrs = ad7150_event_attributes,
 };
 
+static const struct iio_info ad7150_info = {
+       .attrs = &ad7150_attribute_group,
+       .num_interrupt_lines = 1,
+       .event_attrs = &ad7150_event_attribute_group,
+       .driver_module = THIS_MODULE,
+};
 /*
  * device probe and remove
  */
@@ -776,21 +724,20 @@ static int __devinit ad7150_probe(struct i2c_client *client,
        i2c_set_clientdata(client, chip);
 
        chip->client = client;
-       chip->name = id->name;
 
-       chip->indio_dev = iio_allocate_device();
+       chip->indio_dev = iio_allocate_device(0);
        if (chip->indio_dev == NULL) {
                ret = -ENOMEM;
                goto error_free_chip;
        }
 
-       /* Echipabilish that the iio_dev is a child of the i2c device */
+       /* Establish that the iio_dev is a child of the i2c device */
+       chip->indio_dev->name = id->name;
        chip->indio_dev->dev.parent = &client->dev;
-       chip->indio_dev->attrs = &ad7150_attribute_group;
-       chip->indio_dev->event_attrs = &ad7150_event_attribute_group;
+
+       chip->indio_dev->info = &ad7150_info;
        chip->indio_dev->dev_data = (void *)(chip);
-       chip->indio_dev->driver_module = THIS_MODULE;
-       chip->indio_dev->num_interrupt_lines = 1;
+
        chip->indio_dev->modes = INDIO_DIRECT_MODE;
 
        ret = iio_device_register(chip->indio_dev);
@@ -798,19 +745,16 @@ static int __devinit ad7150_probe(struct i2c_client *client,
                goto error_free_dev;
        regdone = 1;
 
-       if (client->irq && gpio_is_valid(irq_to_gpio(client->irq)) > 0) {
-               ret = iio_register_interrupt_line(client->irq,
-                               chip->indio_dev,
-                               0,
-                               IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
-                               "ad7150");
+       if (client->irq) {
+               ret = request_threaded_irq(client->irq,
+                                          NULL,
+                                          &ad7150_event_handler,
+                                          IRQF_TRIGGER_RISING |
+                                          IRQF_TRIGGER_FALLING,
+                                          "ad7150",
+                                          chip->indio_dev);
                if (ret)
                        goto error_free_dev;
-
-               iio_add_event_to_list(iio_event_attr_ch2_low.listel,
-                               &chip->indio_dev->interrupts[0]->ev_list);
-
-               INIT_WORK(&chip->thresh_work, ad7150_interrupt_handler_bh);
        }
 
        dev_err(&client->dev, "%s capacitive sensor registered, irq: %d\n", id->name, client->irq);
@@ -833,8 +777,8 @@ static int __devexit ad7150_remove(struct i2c_client *client)
        struct ad7150_chip_info *chip = i2c_get_clientdata(client);
        struct iio_dev *indio_dev = chip->indio_dev;
 
-       if (client->irq && gpio_is_valid(irq_to_gpio(client->irq)) > 0)
-               iio_unregister_interrupt_line(indio_dev, 0);
+       if (client->irq)
+               free_irq(client->irq, indio_dev);
        iio_device_unregister(indio_dev);
        kfree(chip);
 
index fa7f840623070fb68dab597de791f37e4ed3ef29..7a38bcbbe1af9e96e6c3e2d1ece85346405199c9 100644 (file)
@@ -7,15 +7,11 @@
  */
 
 #include <linux/interrupt.h>
-#include <linux/gpio.h>
-#include <linux/workqueue.h>
 #include <linux/device.h>
 #include <linux/kernel.h>
 #include <linux/slab.h>
 #include <linux/sysfs.h>
-#include <linux/list.h>
 #include <linux/i2c.h>
-#include <linux/rtc.h>
 
 #include "../iio.h"
 #include "../sysfs.h"
@@ -54,7 +50,6 @@
  */
 
 struct ad7152_chip_info {
-       const char *name;
        struct i2c_client *client;
        struct iio_dev *indio_dev;
        u16 ch1_offset;     /* Channel 1 offset calibration coefficient */
@@ -72,7 +67,8 @@ struct ad7152_conversion_mode {
        u8 reg_cfg;
 };
 
-struct ad7152_conversion_mode ad7152_conv_mode_table[AD7152_MAX_CONV_MODE] = {
+static struct ad7152_conversion_mode
+ad7152_conv_mode_table[AD7152_MAX_CONV_MODE] = {
        { "idle", 0 },
        { "continuous-conversion", 1 },
        { "single-conversion", 2 },
@@ -482,17 +478,6 @@ static IIO_DEV_ATTR_FILTER_RATE_SETUP(S_IRUGO | S_IWUSR,
                ad7152_show_filter_rate_setup,
                ad7152_store_filter_rate_setup);
 
-static ssize_t ad7152_show_name(struct device *dev,
-               struct device_attribute *attr,
-               char *buf)
-{
-       struct iio_dev *dev_info = dev_get_drvdata(dev);
-       struct ad7152_chip_info *chip = dev_info->dev_data;
-       return sprintf(buf, "%s\n", chip->name);
-}
-
-static IIO_DEVICE_ATTR(name, S_IRUGO, ad7152_show_name, NULL, 0);
-
 static struct attribute *ad7152_attributes[] = {
        &iio_dev_attr_available_conversion_modes.dev_attr.attr,
        &iio_dev_attr_conversion_mode.dev_attr.attr,
@@ -505,7 +490,6 @@ static struct attribute *ad7152_attributes[] = {
        &iio_dev_attr_ch1_setup.dev_attr.attr,
        &iio_dev_attr_ch2_setup.dev_attr.attr,
        &iio_dev_attr_filter_rate_setup.dev_attr.attr,
-       &iio_dev_attr_name.dev_attr.attr,
        NULL,
 };
 
@@ -513,6 +497,10 @@ static const struct attribute_group ad7152_attribute_group = {
        .attrs = ad7152_attributes,
 };
 
+static const struct iio_info ad7152_info = {
+       .attrs = &ad7152_attribute_group,
+       .driver_module = THIS_MODULE,
+};
 /*
  * device probe and remove
  */
@@ -531,19 +519,18 @@ static int __devinit ad7152_probe(struct i2c_client *client,
        i2c_set_clientdata(client, chip);
 
        chip->client = client;
-       chip->name = id->name;
 
-       chip->indio_dev = iio_allocate_device();
+       chip->indio_dev = iio_allocate_device(0);
        if (chip->indio_dev == NULL) {
                ret = -ENOMEM;
                goto error_free_chip;
        }
 
        /* Echipabilish that the iio_dev is a child of the i2c device */
+       chip->indio_dev->name = id->name;
        chip->indio_dev->dev.parent = &client->dev;
-       chip->indio_dev->attrs = &ad7152_attribute_group;
+       chip->indio_dev->info = &ad7152_info;
        chip->indio_dev->dev_data = (void *)(chip);
-       chip->indio_dev->driver_module = THIS_MODULE;
        chip->indio_dev->modes = INDIO_DIRECT_MODE;
 
        ret = iio_device_register(chip->indio_dev);
@@ -567,8 +554,6 @@ static int __devexit ad7152_remove(struct i2c_client *client)
        struct ad7152_chip_info *chip = i2c_get_clientdata(client);
        struct iio_dev *indio_dev = chip->indio_dev;
 
-       if (client->irq && gpio_is_valid(irq_to_gpio(client->irq)) > 0)
-               iio_unregister_interrupt_line(indio_dev, 0);
        iio_device_unregister(indio_dev);
        kfree(chip);
 
index 34041a72aa529d564f958ff1e524fd1d956c8fb8..1be3453479b75e333343efbaafc2ba90377669ae 100644 (file)
@@ -8,14 +8,12 @@
 
 #include <linux/interrupt.h>
 #include <linux/gpio.h>
-#include <linux/workqueue.h>
 #include <linux/device.h>
 #include <linux/kernel.h>
 #include <linux/slab.h>
 #include <linux/sysfs.h>
 #include <linux/list.h>
 #include <linux/i2c.h>
-#include <linux/rtc.h>
 
 #include "../iio.h"
 #include "../sysfs.h"
  */
 
 struct ad7291_chip_info {
-       const char *name;
        struct i2c_client *client;
        struct iio_dev *indio_dev;
-       struct work_struct thresh_work;
-       s64 last_timestamp;
        u16 command;
        u8  channels;   /* Active voltage channels */
 };
@@ -438,17 +433,6 @@ static IIO_DEVICE_ATTR(channel_mask, S_IRUGO | S_IWUSR,
                ad7291_store_channel_mask,
                0);
 
-static ssize_t ad7291_show_name(struct device *dev,
-               struct device_attribute *attr,
-               char *buf)
-{
-       struct iio_dev *dev_info = dev_get_drvdata(dev);
-       struct ad7291_chip_info *chip = dev_info->dev_data;
-       return sprintf(buf, "%s\n", chip->name);
-}
-
-static IIO_DEVICE_ATTR(name, S_IRUGO, ad7291_show_name, NULL, 0);
-
 static struct attribute *ad7291_attributes[] = {
        &iio_dev_attr_available_modes.dev_attr.attr,
        &iio_dev_attr_mode.dev_attr.attr,
@@ -459,7 +443,6 @@ static struct attribute *ad7291_attributes[] = {
        &iio_dev_attr_t_average.dev_attr.attr,
        &iio_dev_attr_voltage.dev_attr.attr,
        &iio_dev_attr_channel_mask.dev_attr.attr,
-       &iio_dev_attr_name.dev_attr.attr,
        NULL,
 };
 
@@ -471,28 +454,23 @@ static const struct attribute_group ad7291_attribute_group = {
  * temperature bound events
  */
 
-#define IIO_EVENT_CODE_AD7291_T_SENSE_HIGH  IIO_BUFFER_EVENT_CODE(0)
-#define IIO_EVENT_CODE_AD7291_T_SENSE_LOW   IIO_BUFFER_EVENT_CODE(1)
-#define IIO_EVENT_CODE_AD7291_T_AVG_HIGH    IIO_BUFFER_EVENT_CODE(2)
-#define IIO_EVENT_CODE_AD7291_T_AVG_LOW     IIO_BUFFER_EVENT_CODE(3)
-#define IIO_EVENT_CODE_AD7291_VOLTAGE_BASE  IIO_BUFFER_EVENT_CODE(4)
-
-static void ad7291_interrupt_bh(struct work_struct *work_s)
+static irqreturn_t ad7291_event_handler(int irq, void *private)
 {
-       struct ad7291_chip_info *chip =
-               container_of(work_s, struct ad7291_chip_info, thresh_work);
+       struct iio_dev *indio_dev = private;
+       struct ad7291_chip_info *chip = iio_dev_get_devdata(private);
        u16 t_status, v_status;
        u16 command;
        int i;
+       s64 timestamp = iio_get_time_ns();
 
        if (ad7291_i2c_read(chip, AD7291_T_ALERT_STATUS, &t_status))
-               return;
+               return IRQ_HANDLED;
 
        if (ad7291_i2c_read(chip, AD7291_VOLTAGE_ALERT_STATUS, &v_status))
-               return;
+               return IRQ_HANDLED;
 
        if (!(t_status || v_status))
-               return;
+               return IRQ_HANDLED;
 
        command = chip->command | AD7291_ALART_CLEAR;
        ad7291_i2c_write(chip, AD7291_COMMAND, command);
@@ -500,50 +478,67 @@ static void ad7291_interrupt_bh(struct work_struct *work_s)
        command = chip->command & ~AD7291_ALART_CLEAR;
        ad7291_i2c_write(chip, AD7291_COMMAND, command);
 
-       enable_irq(chip->client->irq);
-
-       for (i = 0; i < 4; i++) {
-               if (t_status & (1 << i))
-                       iio_push_event(chip->indio_dev, 0,
-                               IIO_EVENT_CODE_AD7291_T_SENSE_HIGH + i,
-                               chip->last_timestamp);
-       }
-
-       for (i = 0; i < AD7291_VOLTAGE_LIMIT_COUNT*2; i++) {
+       if (t_status & (1 << 0))
+               iio_push_event(indio_dev, 0,
+                              IIO_UNMOD_EVENT_CODE(IIO_TEMP,
+                                                   0,
+                                                   IIO_EV_TYPE_THRESH,
+                                                   IIO_EV_DIR_FALLING),
+                              timestamp);
+       if (t_status & (1 << 1))
+               iio_push_event(indio_dev, 0,
+                              IIO_UNMOD_EVENT_CODE(IIO_TEMP,
+                                                   0,
+                                                   IIO_EV_TYPE_THRESH,
+                                                   IIO_EV_DIR_RISING),
+                              timestamp);
+       if (t_status & (1 << 2))
+               iio_push_event(indio_dev, 0,
+                              IIO_UNMOD_EVENT_CODE(IIO_TEMP,
+                                                   0,
+                                                   IIO_EV_TYPE_THRESH,
+                                                   IIO_EV_DIR_FALLING),
+                              timestamp);
+       if (t_status & (1 << 3))
+               iio_push_event(indio_dev, 0,
+                              IIO_UNMOD_EVENT_CODE(IIO_TEMP,
+                                                   0,
+                                                   IIO_EV_TYPE_THRESH,
+                                                   IIO_EV_DIR_RISING),
+                              timestamp);
+
+       for (i = 0; i < AD7291_VOLTAGE_LIMIT_COUNT*2; i += 2) {
                if (v_status & (1 << i))
-                       iio_push_event(chip->indio_dev, 0,
-                               IIO_EVENT_CODE_AD7291_VOLTAGE_BASE + i,
-                               chip->last_timestamp);
+                       iio_push_event(indio_dev, 0,
+                                      IIO_UNMOD_EVENT_CODE(IIO_IN,
+                                                           i/2,
+                                                           IIO_EV_TYPE_THRESH,
+                                                           IIO_EV_DIR_FALLING),
+                                      timestamp);
+               if (v_status & (1 << (i + 1)))
+                       iio_push_event(indio_dev, 0,
+                                      IIO_UNMOD_EVENT_CODE(IIO_IN,
+                                                           i/2,
+                                                           IIO_EV_TYPE_THRESH,
+                                                           IIO_EV_DIR_RISING),
+                                      timestamp);
        }
-}
-
-static int ad7291_interrupt(struct iio_dev *dev_info,
-               int index,
-               s64 timestamp,
-               int no_test)
-{
-       struct ad7291_chip_info *chip = dev_info->dev_data;
-
-       chip->last_timestamp = timestamp;
-       schedule_work(&chip->thresh_work);
 
-       return 0;
+       return IRQ_HANDLED;
 }
 
-IIO_EVENT_SH(ad7291, &ad7291_interrupt);
-
 static inline ssize_t ad7291_show_t_bound(struct device *dev,
                struct device_attribute *attr,
-               u8 bound_reg,
                char *buf)
 {
        struct iio_dev *dev_info = dev_get_drvdata(dev);
        struct ad7291_chip_info *chip = dev_info->dev_data;
+       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
        u16 data;
        char sign = ' ';
        int ret;
 
-       ret = ad7291_i2c_read(chip, bound_reg, &data);
+       ret = ad7291_i2c_read(chip, this_attr->address, &data);
        if (ret)
                return -EIO;
 
@@ -561,12 +556,12 @@ static inline ssize_t ad7291_show_t_bound(struct device *dev,
 
 static inline ssize_t ad7291_set_t_bound(struct device *dev,
                struct device_attribute *attr,
-               u8 bound_reg,
                const char *buf,
                size_t len)
 {
        struct iio_dev *dev_info = dev_get_drvdata(dev);
        struct ad7291_chip_info *chip = dev_info->dev_data;
+       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
        long tmp1, tmp2;
        u16 data;
        char *pos;
@@ -600,64 +595,13 @@ static inline ssize_t ad7291_set_t_bound(struct device *dev,
                /* convert positive value to supplyment */
                data = (AD7291_T_VALUE_SIGN << 1) - data;
 
-       ret = ad7291_i2c_write(chip, bound_reg, data);
+       ret = ad7291_i2c_write(chip, this_attr->address, data);
        if (ret)
                return -EIO;
 
        return ret;
 }
 
-static ssize_t ad7291_show_t_sense_high(struct device *dev,
-               struct device_attribute *attr,
-               char *buf)
-{
-       return ad7291_show_t_bound(dev, attr,
-                       AD7291_T_SENSE_HIGH, buf);
-}
-
-static inline ssize_t ad7291_set_t_sense_high(struct device *dev,
-               struct device_attribute *attr,
-               const char *buf,
-               size_t len)
-{
-       return ad7291_set_t_bound(dev, attr,
-                       AD7291_T_SENSE_HIGH, buf, len);
-}
-
-static ssize_t ad7291_show_t_sense_low(struct device *dev,
-               struct device_attribute *attr,
-               char *buf)
-{
-       return ad7291_show_t_bound(dev, attr,
-                       AD7291_T_SENSE_LOW, buf);
-}
-
-static inline ssize_t ad7291_set_t_sense_low(struct device *dev,
-               struct device_attribute *attr,
-               const char *buf,
-               size_t len)
-{
-       return ad7291_set_t_bound(dev, attr,
-                       AD7291_T_SENSE_LOW, buf, len);
-}
-
-static ssize_t ad7291_show_t_sense_hyst(struct device *dev,
-               struct device_attribute *attr,
-               char *buf)
-{
-       return ad7291_show_t_bound(dev, attr,
-                       AD7291_T_SENSE_HYST, buf);
-}
-
-static inline ssize_t ad7291_set_t_sense_hyst(struct device *dev,
-               struct device_attribute *attr,
-               const char *buf,
-               size_t len)
-{
-       return ad7291_set_t_bound(dev, attr,
-                       AD7291_T_SENSE_HYST, buf, len);
-}
-
 static inline ssize_t ad7291_show_v_bound(struct device *dev,
                struct device_attribute *attr,
                u8 bound_reg,
@@ -712,191 +656,121 @@ static inline ssize_t ad7291_set_v_bound(struct device *dev,
        return ret;
 }
 
-static int ad7291_get_voltage_limit_regs(const char *channel)
-{
-       int index;
-
-       if (strlen(channel) < 3 && channel[0] != 'v')
-               return -EINVAL;
-
-       index = channel[1] - '0';
-       if (index >= AD7291_VOLTAGE_LIMIT_COUNT)
-               return -EINVAL;
-
-       return index;
-}
-
-static ssize_t ad7291_show_voltage_high(struct device *dev,
-               struct device_attribute *attr,
-               char *buf)
-{
-       int regs;
-
-       regs = ad7291_get_voltage_limit_regs(attr->attr.name);
-
-       if (regs < 0)
-               return regs;
-
-       return ad7291_show_t_bound(dev, attr, regs, buf);
-}
-
-static inline ssize_t ad7291_set_voltage_high(struct device *dev,
-               struct device_attribute *attr,
-               const char *buf,
-               size_t len)
-{
-       int regs;
-
-       regs = ad7291_get_voltage_limit_regs(attr->attr.name);
-
-       if (regs < 0)
-               return regs;
-
-       return ad7291_set_t_bound(dev, attr, regs, buf, len);
-}
-
-static ssize_t ad7291_show_voltage_low(struct device *dev,
-               struct device_attribute *attr,
-               char *buf)
-{
-       int regs;
-
-       regs = ad7291_get_voltage_limit_regs(attr->attr.name);
-
-       if (regs < 0)
-               return regs;
-
-       return ad7291_show_t_bound(dev, attr, regs+1, buf);
-}
-
-static inline ssize_t ad7291_set_voltage_low(struct device *dev,
-               struct device_attribute *attr,
-               const char *buf,
-               size_t len)
-{
-       int regs;
-
-       regs = ad7291_get_voltage_limit_regs(attr->attr.name);
-
-       if (regs < 0)
-               return regs;
-
-       return ad7291_set_t_bound(dev, attr, regs+1, buf, len);
-}
-
-static ssize_t ad7291_show_voltage_hyst(struct device *dev,
-               struct device_attribute *attr,
-               char *buf)
-{
-       int regs;
-
-       regs = ad7291_get_voltage_limit_regs(attr->attr.name);
-
-       if (regs < 0)
-               return regs;
-
-       return ad7291_show_t_bound(dev, attr, regs+2, buf);
-}
-
-static inline ssize_t ad7291_set_voltage_hyst(struct device *dev,
-               struct device_attribute *attr,
-               const char *buf,
-               size_t len)
-{
-       int regs;
-
-       regs = ad7291_get_voltage_limit_regs(attr->attr.name);
-
-       if (regs < 0)
-               return regs;
-
-       return ad7291_set_t_bound(dev, attr, regs+2, buf, len);
-}
-
-IIO_EVENT_ATTR_SH(t_sense_high, iio_event_ad7291,
-               ad7291_show_t_sense_high, ad7291_set_t_sense_high, 0);
-IIO_EVENT_ATTR_SH(t_sense_low, iio_event_ad7291,
-               ad7291_show_t_sense_low, ad7291_set_t_sense_low, 0);
-IIO_EVENT_ATTR_SH(t_sense_hyst, iio_event_ad7291,
-               ad7291_show_t_sense_hyst, ad7291_set_t_sense_hyst, 0);
-
-IIO_EVENT_ATTR_SH(v0_high, iio_event_ad7291,
-               ad7291_show_voltage_high, ad7291_set_voltage_high, 0);
-IIO_EVENT_ATTR_SH(v0_low, iio_event_ad7291,
-               ad7291_show_voltage_low, ad7291_set_voltage_low, 0);
-IIO_EVENT_ATTR_SH(v0_hyst, iio_event_ad7291,
-               ad7291_show_voltage_hyst, ad7291_set_voltage_hyst, 0);
-IIO_EVENT_ATTR_SH(v1_high, iio_event_ad7291,
-               ad7291_show_voltage_high, ad7291_set_voltage_high, 0);
-IIO_EVENT_ATTR_SH(v1_low, iio_event_ad7291,
-               ad7291_show_voltage_low, ad7291_set_voltage_low, 0);
-IIO_EVENT_ATTR_SH(v1_hyst, iio_event_ad7291,
-               ad7291_show_voltage_hyst, ad7291_set_voltage_hyst, 0);
-IIO_EVENT_ATTR_SH(v2_high, iio_event_ad7291,
-               ad7291_show_voltage_high, ad7291_set_voltage_high, 0);
-IIO_EVENT_ATTR_SH(v2_low, iio_event_ad7291,
-               ad7291_show_voltage_low, ad7291_set_voltage_low, 0);
-IIO_EVENT_ATTR_SH(v2_hyst, iio_event_ad7291,
-               ad7291_show_voltage_hyst, ad7291_set_voltage_hyst, 0);
-IIO_EVENT_ATTR_SH(v3_high, iio_event_ad7291,
-               ad7291_show_voltage_high, ad7291_set_voltage_high, 0);
-IIO_EVENT_ATTR_SH(v3_low, iio_event_ad7291,
-               ad7291_show_voltage_low, ad7291_set_voltage_low, 0);
-IIO_EVENT_ATTR_SH(v3_hyst, iio_event_ad7291,
-               ad7291_show_voltage_hyst, ad7291_set_voltage_hyst, 0);
-IIO_EVENT_ATTR_SH(v4_high, iio_event_ad7291,
-               ad7291_show_voltage_high, ad7291_set_voltage_high, 0);
-IIO_EVENT_ATTR_SH(v4_low, iio_event_ad7291,
-               ad7291_show_voltage_low, ad7291_set_voltage_low, 0);
-IIO_EVENT_ATTR_SH(v4_hyst, iio_event_ad7291,
-               ad7291_show_voltage_hyst, ad7291_set_voltage_hyst, 0);
-IIO_EVENT_ATTR_SH(v5_high, iio_event_ad7291,
-               ad7291_show_voltage_high, ad7291_set_voltage_high, 0);
-IIO_EVENT_ATTR_SH(v5_low, iio_event_ad7291,
-               ad7291_show_voltage_low, ad7291_set_voltage_low, 0);
-IIO_EVENT_ATTR_SH(v5_hyst, iio_event_ad7291,
-               ad7291_show_voltage_hyst, ad7291_set_voltage_hyst, 0);
-IIO_EVENT_ATTR_SH(v6_high, iio_event_ad7291,
-               ad7291_show_voltage_high, ad7291_set_voltage_high, 0);
-IIO_EVENT_ATTR_SH(v6_low, iio_event_ad7291,
-               ad7291_show_voltage_low, ad7291_set_voltage_low, 0);
-IIO_EVENT_ATTR_SH(v6_hyst, iio_event_ad7291,
-               ad7291_show_voltage_hyst, ad7291_set_voltage_hyst, 0);
-IIO_EVENT_ATTR_SH(v7_high, iio_event_ad7291,
-               ad7291_show_voltage_high, ad7291_set_voltage_high, 0);
-IIO_EVENT_ATTR_SH(v7_low, iio_event_ad7291,
-               ad7291_show_voltage_low, ad7291_set_voltage_low, 0);
-IIO_EVENT_ATTR_SH(v7_hyst, iio_event_ad7291,
-               ad7291_show_voltage_hyst, ad7291_set_voltage_hyst, 0);
+static IIO_DEVICE_ATTR(t_sense_high_value,
+                      S_IRUGO | S_IWUSR,
+                      ad7291_show_t_bound, ad7291_set_t_bound,
+                      AD7291_T_SENSE_HIGH);
+static IIO_DEVICE_ATTR(t_sense_low_value,
+                      S_IRUGO | S_IWUSR,
+                      ad7291_show_t_bound, ad7291_set_t_bound,
+                      AD7291_T_SENSE_LOW);
+static IIO_DEVICE_ATTR(t_sense_hyst_value,
+                      S_IRUGO | S_IWUSR,
+                      ad7291_show_t_bound, ad7291_set_t_bound,
+                      AD7291_T_SENSE_HYST);
+static IIO_DEVICE_ATTR(v0_high,
+                      S_IRUGO | S_IWUSR,
+                      ad7291_show_t_bound, ad7291_set_t_bound, 0x04);
+static IIO_DEVICE_ATTR(v0_low,
+                      S_IRUGO | S_IWUSR,
+                      ad7291_show_t_bound, ad7291_set_t_bound, 0x05);
+static IIO_DEVICE_ATTR(v0_hyst,
+                      S_IRUGO | S_IWUSR,
+                      ad7291_show_t_bound, ad7291_set_t_bound, 0x06);
+static IIO_DEVICE_ATTR(v1_high,
+                      S_IRUGO | S_IWUSR,
+                      ad7291_show_t_bound, ad7291_set_t_bound, 0x07);
+static IIO_DEVICE_ATTR(v1_low,
+                      S_IRUGO | S_IWUSR,
+                      ad7291_show_t_bound, ad7291_set_t_bound, 0x08);
+static IIO_DEVICE_ATTR(v1_hyst,
+                      S_IRUGO | S_IWUSR,
+                      ad7291_show_t_bound, ad7291_set_t_bound, 0x09);
+static IIO_DEVICE_ATTR(v2_high,
+                      S_IRUGO | S_IWUSR,
+                      ad7291_show_t_bound, ad7291_set_t_bound, 0x0A);
+static IIO_DEVICE_ATTR(v2_low,
+                      S_IRUGO | S_IWUSR,
+                      ad7291_show_t_bound, ad7291_set_t_bound, 0x0B);
+static IIO_DEVICE_ATTR(v2_hyst,
+                      S_IRUGO | S_IWUSR,
+                      ad7291_show_t_bound, ad7291_set_t_bound, 0x0C);
+static IIO_DEVICE_ATTR(v3_high,
+                      S_IRUGO | S_IWUSR,
+                      /* Datasheet suggests this one and this one only
+                         has the registers in different order */
+                      ad7291_show_t_bound, ad7291_set_t_bound, 0x0E);
+static IIO_DEVICE_ATTR(v3_low,
+                      S_IRUGO | S_IWUSR,
+                      ad7291_show_t_bound, ad7291_set_t_bound, 0x0D);
+static IIO_DEVICE_ATTR(v3_hyst,
+                      S_IRUGO | S_IWUSR,
+                      ad7291_show_t_bound, ad7291_set_t_bound, 0x0F);
+static IIO_DEVICE_ATTR(v4_high,
+                      S_IRUGO | S_IWUSR,
+                      ad7291_show_t_bound, ad7291_set_t_bound, 0x10);
+static IIO_DEVICE_ATTR(v4_low,
+                      S_IRUGO | S_IWUSR,
+                      ad7291_show_t_bound, ad7291_set_t_bound, 0x11);
+static IIO_DEVICE_ATTR(v4_hyst,
+                      S_IRUGO | S_IWUSR,
+                      ad7291_show_t_bound, ad7291_set_t_bound, 0x12);
+static IIO_DEVICE_ATTR(v5_high,
+                      S_IRUGO | S_IWUSR,
+                      ad7291_show_t_bound, ad7291_set_t_bound, 0x13);
+static IIO_DEVICE_ATTR(v5_low,
+                      S_IRUGO | S_IWUSR,
+                      ad7291_show_t_bound, ad7291_set_t_bound, 0x14);
+static IIO_DEVICE_ATTR(v5_hyst,
+                      S_IRUGO | S_IWUSR,
+                      ad7291_show_t_bound, ad7291_set_t_bound, 0x15);
+static IIO_DEVICE_ATTR(v6_high,
+                      S_IRUGO | S_IWUSR,
+                      ad7291_show_t_bound, ad7291_set_t_bound, 0x16);
+static IIO_DEVICE_ATTR(v6_low,
+                      S_IRUGO | S_IWUSR,
+                      ad7291_show_t_bound, ad7291_set_t_bound, 0x17);
+static IIO_DEVICE_ATTR(v6_hyst,
+                      S_IRUGO | S_IWUSR,
+                      ad7291_show_t_bound, ad7291_set_t_bound, 0x18);
+static IIO_DEVICE_ATTR(v7_high,
+                      S_IRUGO | S_IWUSR,
+                      ad7291_show_t_bound, ad7291_set_t_bound, 0x19);
+static IIO_DEVICE_ATTR(v7_low,
+                      S_IRUGO | S_IWUSR,
+                      ad7291_show_t_bound, ad7291_set_t_bound, 0x1A);
+static IIO_DEVICE_ATTR(v7_hyst,
+                      S_IRUGO | S_IWUSR,
+                      ad7291_show_t_bound, ad7291_set_t_bound, 0x1B);
 
 static struct attribute *ad7291_event_attributes[] = {
-       &iio_event_attr_t_sense_high.dev_attr.attr,
-       &iio_event_attr_t_sense_low.dev_attr.attr,
-       &iio_event_attr_t_sense_hyst.dev_attr.attr,
-       &iio_event_attr_v0_high.dev_attr.attr,
-       &iio_event_attr_v0_low.dev_attr.attr,
-       &iio_event_attr_v0_hyst.dev_attr.attr,
-       &iio_event_attr_v1_high.dev_attr.attr,
-       &iio_event_attr_v1_low.dev_attr.attr,
-       &iio_event_attr_v1_hyst.dev_attr.attr,
-       &iio_event_attr_v2_high.dev_attr.attr,
-       &iio_event_attr_v2_low.dev_attr.attr,
-       &iio_event_attr_v2_hyst.dev_attr.attr,
-       &iio_event_attr_v3_high.dev_attr.attr,
-       &iio_event_attr_v3_low.dev_attr.attr,
-       &iio_event_attr_v3_hyst.dev_attr.attr,
-       &iio_event_attr_v4_high.dev_attr.attr,
-       &iio_event_attr_v4_low.dev_attr.attr,
-       &iio_event_attr_v4_hyst.dev_attr.attr,
-       &iio_event_attr_v5_high.dev_attr.attr,
-       &iio_event_attr_v5_low.dev_attr.attr,
-       &iio_event_attr_v5_hyst.dev_attr.attr,
-       &iio_event_attr_v6_high.dev_attr.attr,
-       &iio_event_attr_v6_low.dev_attr.attr,
-       &iio_event_attr_v6_hyst.dev_attr.attr,
-       &iio_event_attr_v7_high.dev_attr.attr,
-       &iio_event_attr_v7_low.dev_attr.attr,
-       &iio_event_attr_v7_hyst.dev_attr.attr,
+       &iio_dev_attr_t_sense_high_value.dev_attr.attr,
+       &iio_dev_attr_t_sense_low_value.dev_attr.attr,
+       &iio_dev_attr_t_sense_hyst_value.dev_attr.attr,
+       &iio_dev_attr_v0_high.dev_attr.attr,
+       &iio_dev_attr_v0_low.dev_attr.attr,
+       &iio_dev_attr_v0_hyst.dev_attr.attr,
+       &iio_dev_attr_v1_high.dev_attr.attr,
+       &iio_dev_attr_v1_low.dev_attr.attr,
+       &iio_dev_attr_v1_hyst.dev_attr.attr,
+       &iio_dev_attr_v2_high.dev_attr.attr,
+       &iio_dev_attr_v2_low.dev_attr.attr,
+       &iio_dev_attr_v2_hyst.dev_attr.attr,
+       &iio_dev_attr_v3_high.dev_attr.attr,
+       &iio_dev_attr_v3_low.dev_attr.attr,
+       &iio_dev_attr_v3_hyst.dev_attr.attr,
+       &iio_dev_attr_v4_high.dev_attr.attr,
+       &iio_dev_attr_v4_low.dev_attr.attr,
+       &iio_dev_attr_v4_hyst.dev_attr.attr,
+       &iio_dev_attr_v5_high.dev_attr.attr,
+       &iio_dev_attr_v5_low.dev_attr.attr,
+       &iio_dev_attr_v5_hyst.dev_attr.attr,
+       &iio_dev_attr_v6_high.dev_attr.attr,
+       &iio_dev_attr_v6_low.dev_attr.attr,
+       &iio_dev_attr_v6_hyst.dev_attr.attr,
+       &iio_dev_attr_v7_high.dev_attr.attr,
+       &iio_dev_attr_v7_low.dev_attr.attr,
+       &iio_dev_attr_v7_hyst.dev_attr.attr,
        NULL,
 };
 
@@ -904,6 +778,12 @@ static struct attribute_group ad7291_event_attribute_group = {
        .attrs = ad7291_event_attributes,
 };
 
+static const struct iio_info ad7291_info = {
+       .attrs = &ad7291_attribute_group,
+       .num_interrupt_lines = 1,
+       .event_attrs = &ad7291_event_attribute_group,
+};
+
 /*
  * device probe and remove
  */
@@ -923,21 +803,18 @@ static int __devinit ad7291_probe(struct i2c_client *client,
        i2c_set_clientdata(client, chip);
 
        chip->client = client;
-       chip->name = id->name;
        chip->command = AD7291_NOISE_DELAY | AD7291_T_SENSE_MASK;
 
-       chip->indio_dev = iio_allocate_device();
+       chip->indio_dev = iio_allocate_device(0);
        if (chip->indio_dev == NULL) {
                ret = -ENOMEM;
                goto error_free_chip;
        }
 
+       chip->indio_dev->name = id->name;
        chip->indio_dev->dev.parent = &client->dev;
-       chip->indio_dev->attrs = &ad7291_attribute_group;
-       chip->indio_dev->event_attrs = &ad7291_event_attribute_group;
+       chip->indio_dev->info = &ad7291_info;
        chip->indio_dev->dev_data = (void *)chip;
-       chip->indio_dev->driver_module = THIS_MODULE;
-       chip->indio_dev->num_interrupt_lines = 1;
        chip->indio_dev->modes = INDIO_DIRECT_MODE;
 
        ret = iio_device_register(chip->indio_dev);
@@ -945,24 +822,15 @@ static int __devinit ad7291_probe(struct i2c_client *client,
                goto error_free_dev;
 
        if (client->irq > 0) {
-               ret = iio_register_interrupt_line(client->irq,
-                               chip->indio_dev,
-                               0,
-                               IRQF_TRIGGER_LOW,
-                               chip->name);
+               ret = request_threaded_irq(client->irq,
+                                          NULL,
+                                          &ad7291_event_handler,
+                                          IRQF_TRIGGER_LOW | IRQF_ONESHOT,
+                                          id->name,
+                                          chip->indio_dev);
                if (ret)
                        goto error_unreg_dev;
 
-               /*
-                * The event handler list element refer to iio_event_ad7291.
-                * All event attributes bind to the same event handler.
-                * So, only register event handler once.
-                */
-               iio_add_event_to_list(&iio_event_ad7291,
-                               &chip->indio_dev->interrupts[0]->ev_list);
-
-               INIT_WORK(&chip->thresh_work, ad7291_interrupt_bh);
-
                /* set irq polarity low level */
                chip->command |= AD7291_ALART_POLARITY;
        }
@@ -979,7 +847,7 @@ static int __devinit ad7291_probe(struct i2c_client *client,
        return 0;
 
 error_unreg_irq:
-       iio_unregister_interrupt_line(chip->indio_dev, 0);
+       free_irq(client->irq, chip->indio_dev);
 error_unreg_dev:
        iio_device_unregister(chip->indio_dev);
 error_free_dev:
@@ -996,7 +864,7 @@ static int __devexit ad7291_remove(struct i2c_client *client)
        struct iio_dev *indio_dev = chip->indio_dev;
 
        if (client->irq)
-               iio_unregister_interrupt_line(indio_dev, 0);
+               free_irq(client->irq, chip->indio_dev);
        iio_device_unregister(indio_dev);
        iio_free_device(chip->indio_dev);
        kfree(chip);
index fe7ed77d638fd9312c5be3f9fede99f53b1f3c79..628f5adcf0c9a82b269aec2088d2eaaf52f53e87 100644 (file)
 #define AD7298_TAVG    (1 << 1) /* temperature sensor averaging enable */
 #define AD7298_PDD     (1 << 0) /* partial power down enable */
 
-#define AD7298_CH_MASK (AD7298_CH0 | AD7298_CH1 | AD7298_CH2 | AD7298_CH3 | \
-                       AD7298_CH4 | AD7298_CH5 | AD7298_CH6 | AD7298_CH7)
-
 #define AD7298_MAX_CHAN                8
 #define AD7298_BITS            12
 #define AD7298_STORAGE_BITS    16
 #define AD7298_INTREF_mV       2500
 
+#define AD7298_CH_TEMP         9
+
 #define RES_MASK(bits) ((1 << (bits)) - 1)
 
 /*
@@ -37,11 +36,8 @@ struct ad7298_platform_data {
 };
 
 struct ad7298_state {
-       struct iio_dev                  *indio_dev;
        struct spi_device               *spi;
        struct regulator                *reg;
-       struct work_struct              poll_work;
-       atomic_t                        protect_ring;
        size_t                          d_size;
        u16                             int_vref_mv;
        unsigned                        ext_ref;
@@ -58,11 +54,11 @@ struct ad7298_state {
 };
 
 #ifdef CONFIG_IIO_RING_BUFFER
-int ad7298_scan_from_ring(struct ad7298_state *st, long ch);
+int ad7298_scan_from_ring(struct iio_dev *indio_dev, long ch);
 int ad7298_register_ring_funcs_and_init(struct iio_dev *indio_dev);
 void ad7298_ring_cleanup(struct iio_dev *indio_dev);
 #else /* CONFIG_IIO_RING_BUFFER */
-static inline int ad7298_scan_from_ring(struct ad7298_state *st, long ch)
+static inline int ad7298_scan_from_ring(struct iio_dev *indio_dev, long ch)
 {
        return 0;
 }
index 2e9154e7d8873c5ee399e2494c89e61bed4be088..b8e4ae29b0b5cfca99236a425ce444fecb95791a 100644 (file)
@@ -6,7 +6,6 @@
  * Licensed under the GPL-2.
  */
 
-#include <linux/workqueue.h>
 #include <linux/device.h>
 #include <linux/kernel.h>
 #include <linux/slab.h>
 
 #include "ad7298.h"
 
+static struct iio_chan_spec ad7298_channels[] = {
+       IIO_CHAN(IIO_TEMP, 0, 1, 0, NULL, 0, 0,
+                (1 << IIO_CHAN_INFO_SCALE_SEPARATE),
+                9, AD7298_CH_TEMP, IIO_ST('s', 32, 32, 0), 0),
+       IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 0, 0,
+                (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                0, 0, IIO_ST('u', 12, 16, 0), 0),
+       IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 1, 0,
+                (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                1, 1, IIO_ST('u', 12, 16, 0), 0),
+       IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 2, 0,
+                (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                2, 2, IIO_ST('u', 12, 16, 0), 0),
+       IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 3, 0,
+                (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                3, 3, IIO_ST('u', 12, 16, 0), 0),
+       IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 4, 0,
+                (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                4, 4, IIO_ST('u', 12, 16, 0), 0),
+       IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 5, 0,
+                (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                5, 5, IIO_ST('u', 12, 16, 0), 0),
+       IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 6, 0,
+                (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                6, 6, IIO_ST('u', 12, 16, 0), 0),
+       IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 7, 0,
+                (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                7, 7, IIO_ST('u', 12, 16, 0), 0),
+       IIO_CHAN_SOFT_TIMESTAMP(8),
+};
+
 static int ad7298_scan_direct(struct ad7298_state *st, unsigned ch)
 {
        int ret;
@@ -36,55 +66,28 @@ static int ad7298_scan_direct(struct ad7298_state *st, unsigned ch)
        return be16_to_cpu(st->rx_buf[0]);
 }
 
-static ssize_t ad7298_scan(struct device *dev,
-                           struct device_attribute *attr,
-                           char *buf)
+static int ad7298_scan_temp(struct ad7298_state *st, int *val)
 {
-       struct iio_dev *dev_info = dev_get_drvdata(dev);
-       struct ad7298_state *st = dev_info->dev_data;
-       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-       int ret;
+       int tmp, ret;
 
-       mutex_lock(&dev_info->mlock);
-       if (iio_ring_enabled(dev_info))
-               ret = ad7298_scan_from_ring(st, this_attr->address);
-       else
-               ret = ad7298_scan_direct(st, this_attr->address);
-       mutex_unlock(&dev_info->mlock);
+       tmp = cpu_to_be16(AD7298_WRITE | AD7298_TSENSE |
+                         AD7298_TAVG | st->ext_ref);
 
-       if (ret < 0)
+       ret = spi_write(st->spi, (u8 *)&tmp, 2);
+       if (ret)
                return ret;
 
-       return sprintf(buf, "%d\n", ret & RES_MASK(AD7298_BITS));
-}
-
-static IIO_DEV_ATTR_IN_RAW(0, ad7298_scan, 0);
-static IIO_DEV_ATTR_IN_RAW(1, ad7298_scan, 1);
-static IIO_DEV_ATTR_IN_RAW(2, ad7298_scan, 2);
-static IIO_DEV_ATTR_IN_RAW(3, ad7298_scan, 3);
-static IIO_DEV_ATTR_IN_RAW(4, ad7298_scan, 4);
-static IIO_DEV_ATTR_IN_RAW(5, ad7298_scan, 5);
-static IIO_DEV_ATTR_IN_RAW(6, ad7298_scan, 6);
-static IIO_DEV_ATTR_IN_RAW(7, ad7298_scan, 7);
-
-static ssize_t ad7298_show_temp(struct device *dev,
-                               struct device_attribute *attr,
-                               char *buf)
-{
-       struct iio_dev *dev_info = dev_get_drvdata(dev);
-       struct ad7298_state *st = iio_dev_get_devdata(dev_info);
-       int tmp;
+       tmp = 0;
 
-       tmp = cpu_to_be16(AD7298_WRITE | AD7298_TSENSE |
-                         AD7298_TAVG | st->ext_ref);
+       ret = spi_write(st->spi, (u8 *)&tmp, 2);
+       if (ret)
+               return ret;
 
-       mutex_lock(&dev_info->mlock);
-       spi_write(st->spi, (u8 *)&tmp, 2);
-       tmp = 0;
-       spi_write(st->spi, (u8 *)&tmp, 2);
        usleep_range(101, 1000); /* sleep > 100us */
-       spi_read(st->spi, (u8 *)&tmp, 2);
-       mutex_unlock(&dev_info->mlock);
+
+       ret = spi_read(st->spi, (u8 *)&tmp, 2);
+       if (ret)
+               return ret;
 
        tmp = be16_to_cpu(tmp) & RES_MASK(AD7298_BITS);
 
@@ -101,65 +104,74 @@ static ssize_t ad7298_show_temp(struct device *dev,
                tmp *= 250; /* temperature in milli degrees Celsius */
        }
 
-       return sprintf(buf, "%d\n", tmp);
-}
+       *val = tmp;
 
-static IIO_DEVICE_ATTR(temp0_input, S_IRUGO, ad7298_show_temp, NULL, 0);
-
-static ssize_t ad7298_show_scale(struct device *dev,
-                               struct device_attribute *attr,
-                               char *buf)
-{
-       struct iio_dev *dev_info = dev_get_drvdata(dev);
-       struct ad7298_state *st = iio_dev_get_devdata(dev_info);
-       /* Corresponds to Vref / 2^(bits) */
-       unsigned int scale_uv = (st->int_vref_mv * 1000) >> AD7298_BITS;
-
-       return sprintf(buf, "%d.%03d\n", scale_uv / 1000, scale_uv % 1000);
+       return 0;
 }
-static IIO_DEVICE_ATTR(in_scale, S_IRUGO, ad7298_show_scale, NULL, 0);
 
-static ssize_t ad7298_show_name(struct device *dev,
-                                struct device_attribute *attr,
-                                char *buf)
+static int ad7298_read_raw(struct iio_dev *dev_info,
+                          struct iio_chan_spec const *chan,
+                          int *val,
+                          int *val2,
+                          long m)
 {
-       struct iio_dev *dev_info = dev_get_drvdata(dev);
-       struct ad7298_state *st = iio_dev_get_devdata(dev_info);
-
-       return sprintf(buf, "%s\n", spi_get_device_id(st->spi)->name);
+       int ret;
+       struct ad7298_state *st = iio_priv(dev_info);
+       unsigned int scale_uv;
+
+       switch (m) {
+       case 0:
+               mutex_lock(&dev_info->mlock);
+               if (iio_ring_enabled(dev_info)) {
+                       if (chan->address == AD7298_CH_TEMP)
+                               ret = -ENODEV;
+                       else
+                               ret = ad7298_scan_from_ring(dev_info,
+                                                           chan->address);
+               } else {
+                       if (chan->address == AD7298_CH_TEMP)
+                               ret = ad7298_scan_temp(st, val);
+                       else
+                               ret = ad7298_scan_direct(st, chan->address);
+               }
+               mutex_unlock(&dev_info->mlock);
+
+               if (ret < 0)
+                       return ret;
+
+               if (chan->address != AD7298_CH_TEMP)
+                       *val = ret & RES_MASK(AD7298_BITS);
+
+               return IIO_VAL_INT;
+       case (1 << IIO_CHAN_INFO_SCALE_SHARED):
+               scale_uv = (st->int_vref_mv * 1000) >> AD7298_BITS;
+               *val =  scale_uv / 1000;
+               *val2 = (scale_uv % 1000) * 1000;
+               return IIO_VAL_INT_PLUS_MICRO;
+       case (1 << IIO_CHAN_INFO_SCALE_SEPARATE):
+               *val =  1;
+               *val2 = 0;
+               return IIO_VAL_INT_PLUS_MICRO;
+       }
+       return -EINVAL;
 }
-static IIO_DEVICE_ATTR(name, S_IRUGO, ad7298_show_name, NULL, 0);
-
-static struct attribute *ad7298_attributes[] = {
-       &iio_dev_attr_in0_raw.dev_attr.attr,
-       &iio_dev_attr_in1_raw.dev_attr.attr,
-       &iio_dev_attr_in2_raw.dev_attr.attr,
-       &iio_dev_attr_in3_raw.dev_attr.attr,
-       &iio_dev_attr_in4_raw.dev_attr.attr,
-       &iio_dev_attr_in5_raw.dev_attr.attr,
-       &iio_dev_attr_in6_raw.dev_attr.attr,
-       &iio_dev_attr_in7_raw.dev_attr.attr,
-       &iio_dev_attr_in_scale.dev_attr.attr,
-       &iio_dev_attr_temp0_input.dev_attr.attr,
-       &iio_dev_attr_name.dev_attr.attr,
-       NULL,
-};
 
-static const struct attribute_group ad7298_attribute_group = {
-       .attrs = ad7298_attributes,
+static const struct iio_info ad7298_info = {
+       .read_raw = &ad7298_read_raw,
+       .driver_module = THIS_MODULE,
 };
 
 static int __devinit ad7298_probe(struct spi_device *spi)
 {
        struct ad7298_platform_data *pdata = spi->dev.platform_data;
        struct ad7298_state *st;
-       int ret;
+       int ret, regdone = 0;
+       struct iio_dev *indio_dev = iio_allocate_device(sizeof(*st));
 
-       st = kzalloc(sizeof(*st), GFP_KERNEL);
-       if (st == NULL) {
-               ret = -ENOMEM;
-               goto error_ret;
-       }
+       if (indio_dev == NULL)
+               return -ENOMEM;
+
+       st = iio_priv(indio_dev);
 
        st->reg = regulator_get(&spi->dev, "vcc");
        if (!IS_ERR(st->reg)) {
@@ -168,22 +180,16 @@ static int __devinit ad7298_probe(struct spi_device *spi)
                        goto error_put_reg;
        }
 
-       spi_set_drvdata(spi, st);
+       spi_set_drvdata(spi, indio_dev);
 
-       atomic_set(&st->protect_ring, 0);
        st->spi = spi;
 
-       st->indio_dev = iio_allocate_device();
-       if (st->indio_dev == NULL) {
-               ret = -ENOMEM;
-               goto error_disable_reg;
-       }
-
-       st->indio_dev->dev.parent = &spi->dev;
-       st->indio_dev->attrs = &ad7298_attribute_group;
-       st->indio_dev->dev_data = (void *)(st);
-       st->indio_dev->driver_module = THIS_MODULE;
-       st->indio_dev->modes = INDIO_DIRECT_MODE;
+       indio_dev->name = spi_get_device_id(spi)->name;
+       indio_dev->dev.parent = &spi->dev;
+       indio_dev->modes = INDIO_DIRECT_MODE;
+       indio_dev->channels = ad7298_channels;
+       indio_dev->num_channels = ARRAY_SIZE(ad7298_channels);
+       indio_dev->info = &ad7298_info;
 
        /* Setup default message */
 
@@ -208,39 +214,44 @@ static int __devinit ad7298_probe(struct spi_device *spi)
                st->int_vref_mv = AD7298_INTREF_mV;
        }
 
-       ret = ad7298_register_ring_funcs_and_init(st->indio_dev);
+       ret = ad7298_register_ring_funcs_and_init(indio_dev);
        if (ret)
-               goto error_free_device;
+               goto error_disable_reg;
 
-       ret = iio_device_register(st->indio_dev);
+       ret = iio_device_register(indio_dev);
        if (ret)
-               goto error_free_device;
+               goto error_disable_reg;
+       regdone = 1;
 
-       ret = iio_ring_buffer_register(st->indio_dev->ring, 0);
+       ret = iio_ring_buffer_register_ex(indio_dev->ring, 0,
+                                         &ad7298_channels[1], /* skip temp0 */
+                                         ARRAY_SIZE(ad7298_channels) - 1);
        if (ret)
                goto error_cleanup_ring;
+
        return 0;
 
 error_cleanup_ring:
-       ad7298_ring_cleanup(st->indio_dev);
-       iio_device_unregister(st->indio_dev);
-error_free_device:
-       iio_free_device(st->indio_dev);
+       ad7298_ring_cleanup(indio_dev);
 error_disable_reg:
        if (!IS_ERR(st->reg))
                regulator_disable(st->reg);
 error_put_reg:
        if (!IS_ERR(st->reg))
                regulator_put(st->reg);
-       kfree(st);
-error_ret:
+
+       if (regdone)
+               iio_device_unregister(indio_dev);
+       else
+               iio_free_device(indio_dev);
+
        return ret;
 }
 
 static int __devexit ad7298_remove(struct spi_device *spi)
 {
-       struct ad7298_state *st = spi_get_drvdata(spi);
-       struct iio_dev *indio_dev = st->indio_dev;
+       struct iio_dev *indio_dev = spi_get_drvdata(spi);
+       struct ad7298_state *st = iio_priv(indio_dev);
 
        iio_ring_buffer_unregister(indio_dev->ring);
        ad7298_ring_cleanup(indio_dev);
@@ -249,7 +260,8 @@ static int __devexit ad7298_remove(struct spi_device *spi)
                regulator_disable(st->reg);
                regulator_put(st->reg);
        }
-       kfree(st);
+       iio_device_unregister(indio_dev);
+
        return 0;
 }
 
index 9068d7f54d155625d48d4d7fcb1c251bfc509087..a04c033526242ad7ca17697e3117aeba480b568c 100644 (file)
@@ -7,7 +7,6 @@
  */
 
 #include <linux/interrupt.h>
-#include <linux/workqueue.h>
 #include <linux/device.h>
 #include <linux/kernel.h>
 #include <linux/slab.h>
 
 #include "ad7298.h"
 
-static IIO_SCAN_EL_C(in0, 0, 0, NULL);
-static IIO_SCAN_EL_C(in1, 1, 0, NULL);
-static IIO_SCAN_EL_C(in2, 2, 0, NULL);
-static IIO_SCAN_EL_C(in3, 3, 0, NULL);
-static IIO_SCAN_EL_C(in4, 4, 0, NULL);
-static IIO_SCAN_EL_C(in5, 5, 0, NULL);
-static IIO_SCAN_EL_C(in6, 6, 0, NULL);
-static IIO_SCAN_EL_C(in7, 7, 0, NULL);
-
-static IIO_SCAN_EL_TIMESTAMP(8);
-static IIO_CONST_ATTR_SCAN_EL_TYPE(timestamp, s, 64, 64);
-
-static IIO_CONST_ATTR(in_type, "u12/16") ;
-
-static struct attribute *ad7298_scan_el_attrs[] = {
-       &iio_scan_el_in0.dev_attr.attr,
-       &iio_const_attr_in0_index.dev_attr.attr,
-       &iio_scan_el_in1.dev_attr.attr,
-       &iio_const_attr_in1_index.dev_attr.attr,
-       &iio_scan_el_in2.dev_attr.attr,
-       &iio_const_attr_in2_index.dev_attr.attr,
-       &iio_scan_el_in3.dev_attr.attr,
-       &iio_const_attr_in3_index.dev_attr.attr,
-       &iio_scan_el_in4.dev_attr.attr,
-       &iio_const_attr_in4_index.dev_attr.attr,
-       &iio_scan_el_in5.dev_attr.attr,
-       &iio_const_attr_in5_index.dev_attr.attr,
-       &iio_scan_el_in6.dev_attr.attr,
-       &iio_const_attr_in6_index.dev_attr.attr,
-       &iio_scan_el_in7.dev_attr.attr,
-       &iio_const_attr_in7_index.dev_attr.attr,
-       &iio_const_attr_timestamp_index.dev_attr.attr,
-       &iio_scan_el_timestamp.dev_attr.attr,
-       &iio_const_attr_timestamp_type.dev_attr.attr,
-       &iio_const_attr_in_type.dev_attr.attr,
-       NULL,
-};
-
-static struct attribute_group ad7298_scan_el_group = {
-       .name = "scan_elements",
-       .attrs = ad7298_scan_el_attrs,
-};
-
-int ad7298_scan_from_ring(struct ad7298_state *st, long ch)
+int ad7298_scan_from_ring(struct iio_dev *dev_info, long ch)
 {
-       struct iio_ring_buffer *ring = st->indio_dev->ring;
+       struct iio_ring_buffer *ring = dev_info->ring;
        int ret;
        u16 *ring_data;
 
@@ -76,12 +32,13 @@ int ad7298_scan_from_ring(struct ad7298_state *st, long ch)
                goto error_ret;
        }
 
-       ring_data = kmalloc(ring->access.get_bytes_per_datum(ring), GFP_KERNEL);
+       ring_data = kmalloc(ring->access->get_bytes_per_datum(ring),
+                           GFP_KERNEL);
        if (ring_data == NULL) {
                ret = -ENOMEM;
                goto error_ret;
        }
-       ret = ring->access.read_last(ring, (u8 *) ring_data);
+       ret = ring->access->read_last(ring, (u8 *) ring_data);
        if (ret)
                goto error_free_ring_data;
 
@@ -102,7 +59,7 @@ error_ret:
  **/
 static int ad7298_ring_preenable(struct iio_dev *indio_dev)
 {
-       struct ad7298_state *st = indio_dev->dev_data;
+       struct ad7298_state *st = iio_priv(indio_dev);
        struct iio_ring_buffer *ring = indio_dev->ring;
        size_t d_size;
        int i, m;
@@ -117,8 +74,8 @@ static int ad7298_ring_preenable(struct iio_dev *indio_dev)
                        d_size += sizeof(s64) - (d_size % sizeof(s64));
        }
 
-       if (ring->access.set_bytes_per_datum)
-               ring->access.set_bytes_per_datum(ring, d_size);
+       if (ring->access->set_bytes_per_datum)
+               ring->access->set_bytes_per_datum(ring, d_size);
 
        st->d_size = d_size;
 
@@ -155,47 +112,24 @@ static int ad7298_ring_preenable(struct iio_dev *indio_dev)
 }
 
 /**
- * ad7298_poll_func_th() th of trigger launched polling to ring buffer
- *
- * As sampling only occurs on spi comms occurring, leave timestamping until
- * then.  Some triggers will generate their own time stamp.  Currently
- * there is no way of notifying them when no one cares.
- **/
-static void ad7298_poll_func_th(struct iio_dev *indio_dev, s64 time)
-{
-       struct ad7298_state *st = indio_dev->dev_data;
-
-       schedule_work(&st->poll_work);
-       return;
-}
-
-/**
- * ad7298_poll_bh_to_ring() bh of trigger launched polling to ring buffer
- * @work_s:    the work struct through which this was scheduled
+ * ad7298_trigger_handler() bh of trigger launched polling to ring buffer
  *
  * Currently there is no option in this driver to disable the saving of
  * timestamps within the ring.
- * I think the one copy of this at a time was to avoid problems if the
- * trigger was set far too high and the reads then locked up the computer.
  **/
-static void ad7298_poll_bh_to_ring(struct work_struct *work_s)
+static irqreturn_t ad7298_trigger_handler(int irq, void *p)
 {
-       struct ad7298_state *st = container_of(work_s, struct ad7298_state,
-                                                 poll_work);
-       struct iio_dev *indio_dev = st->indio_dev;
-       struct iio_sw_ring_buffer *sw_ring = iio_to_sw_ring(indio_dev->ring);
+       struct iio_poll_func *pf = p;
+       struct iio_dev *indio_dev = pf->private_data;
+       struct ad7298_state *st = iio_priv(indio_dev);
        struct iio_ring_buffer *ring = indio_dev->ring;
        s64 time_ns;
        __u16 buf[16];
        int b_sent, i;
 
-       /* Ensure only one copy of this function running at a time */
-       if (atomic_inc_return(&st->protect_ring) > 1)
-               return;
-
        b_sent = spi_sync(st->spi, &st->ring_msg);
        if (b_sent)
-               goto done;
+               return b_sent;
 
        if (ring->scan_timestamp) {
                time_ns = iio_get_time_ns();
@@ -206,14 +140,20 @@ static void ad7298_poll_bh_to_ring(struct work_struct *work_s)
        for (i = 0; i < ring->scan_count; i++)
                buf[i] = be16_to_cpu(st->rx_buf[i]);
 
-       indio_dev->ring->access.store_to(&sw_ring->buf, (u8 *)buf, time_ns);
-done:
-       atomic_dec(&st->protect_ring);
+       indio_dev->ring->access->store_to(ring, (u8 *)buf, time_ns);
+       iio_trigger_notify_done(indio_dev->trig);
+
+       return IRQ_HANDLED;
 }
 
+static const struct iio_ring_setup_ops ad7298_ring_setup_ops = {
+       .preenable = &ad7298_ring_preenable,
+       .postenable = &iio_triggered_ring_postenable,
+       .predisable = &iio_triggered_ring_predisable,
+};
+
 int ad7298_register_ring_funcs_and_init(struct iio_dev *indio_dev)
 {
-       struct ad7298_state *st = indio_dev->dev_data;
        int ret;
 
        indio_dev->ring = iio_sw_rb_allocate(indio_dev);
@@ -222,24 +162,28 @@ int ad7298_register_ring_funcs_and_init(struct iio_dev *indio_dev)
                goto error_ret;
        }
        /* Effectively select the ring buffer implementation */
-       iio_ring_sw_register_funcs(&indio_dev->ring->access);
-       ret = iio_alloc_pollfunc(indio_dev, NULL, &ad7298_poll_func_th);
-       if (ret)
+       indio_dev->ring->access = &ring_sw_access_funcs;
+
+       indio_dev->pollfunc = iio_alloc_pollfunc(NULL,
+                                                &ad7298_trigger_handler,
+                                                IRQF_ONESHOT,
+                                                indio_dev,
+                                                "ad7298_consumer%d",
+                                                indio_dev->id);
+
+       if (indio_dev->pollfunc == NULL) {
+               ret = -ENOMEM;
                goto error_deallocate_sw_rb;
+       }
 
        /* Ring buffer functions - here trigger setup related */
-
-       indio_dev->ring->preenable = &ad7298_ring_preenable;
-       indio_dev->ring->postenable = &iio_triggered_ring_postenable;
-       indio_dev->ring->predisable = &iio_triggered_ring_predisable;
-       indio_dev->ring->scan_el_attrs = &ad7298_scan_el_group;
+       indio_dev->ring->setup_ops = &ad7298_ring_setup_ops;
        indio_dev->ring->scan_timestamp = true;
 
-       INIT_WORK(&st->poll_work, &ad7298_poll_bh_to_ring);
-
        /* Flag that polled ring buffering is possible */
        indio_dev->modes |= INDIO_RING_TRIGGERED;
        return 0;
+
 error_deallocate_sw_rb:
        iio_sw_rb_free(indio_dev->ring);
 error_ret:
@@ -253,6 +197,6 @@ void ad7298_ring_cleanup(struct iio_dev *indio_dev)
                iio_trigger_dettach_poll_func(indio_dev->trig,
                                              indio_dev->pollfunc);
        }
-       kfree(indio_dev->pollfunc);
+       iio_dealloc_pollfunc(indio_dev->pollfunc);
        iio_sw_rb_free(indio_dev->ring);
 }
index 8c17b1fe90261b595396832fbdaf674ed8006180..98bb16fcff266fe8f4bbb35c6086d38da127f897 100644 (file)
@@ -6,16 +6,11 @@
  * Licensed under the GPL-2 or later.
  */
 
-#include <linux/interrupt.h>
-#include <linux/gpio.h>
-#include <linux/workqueue.h>
 #include <linux/device.h>
 #include <linux/kernel.h>
 #include <linux/slab.h>
 #include <linux/sysfs.h>
-#include <linux/list.h>
 #include <linux/spi/spi.h>
-#include <linux/rtc.h>
 
 #include "../iio.h"
 #include "../sysfs.h"
@@ -47,7 +42,6 @@
  */
 
 struct ad7314_chip_info {
-       const char *name;
        struct spi_device *spi_dev;
        struct iio_dev *indio_dev;
        s64 last_timestamp;
@@ -160,7 +154,7 @@ static ssize_t ad7314_show_temperature(struct device *dev,
        if (chip->mode)
                ad7314_spi_write(chip, chip->mode);
 
-       if (strcmp(chip->name, "ad7314")) {
+       if (strcmp(dev_info->name, "ad7314")) {
                data = (data & AD7314_TEMP_MASK) >>
                        AD7314_TEMP_OFFSET;
                if (data & AD7314_TEMP_SIGN) {
@@ -186,22 +180,10 @@ static ssize_t ad7314_show_temperature(struct device *dev,
 
 static IIO_DEVICE_ATTR(temperature, S_IRUGO, ad7314_show_temperature, NULL, 0);
 
-static ssize_t ad7314_show_name(struct device *dev,
-               struct device_attribute *attr,
-               char *buf)
-{
-       struct iio_dev *dev_info = dev_get_drvdata(dev);
-       struct ad7314_chip_info *chip = dev_info->dev_data;
-       return sprintf(buf, "%s\n", chip->name);
-}
-
-static IIO_DEVICE_ATTR(name, S_IRUGO, ad7314_show_name, NULL, 0);
-
 static struct attribute *ad7314_attributes[] = {
        &iio_dev_attr_available_modes.dev_attr.attr,
        &iio_dev_attr_mode.dev_attr.attr,
        &iio_dev_attr_temperature.dev_attr.attr,
-       &iio_dev_attr_name.dev_attr.attr,
        NULL,
 };
 
@@ -209,6 +191,10 @@ static const struct attribute_group ad7314_attribute_group = {
        .attrs = ad7314_attributes,
 };
 
+static const struct iio_info ad7314_info = {
+       .attrs = &ad7314_attribute_group,
+       .driver_module = THIS_MODULE,
+};
 /*
  * device probe and remove
  */
@@ -227,25 +213,24 @@ static int __devinit ad7314_probe(struct spi_device *spi_dev)
        dev_set_drvdata(&spi_dev->dev, chip);
 
        chip->spi_dev = spi_dev;
-       chip->name = spi_dev->modalias;
 
-       chip->indio_dev = iio_allocate_device();
+       chip->indio_dev = iio_allocate_device(0);
        if (chip->indio_dev == NULL) {
                ret = -ENOMEM;
                goto error_free_chip;
        }
 
+       chip->indio_dev->name = spi_get_device_id(spi_dev)->name;
        chip->indio_dev->dev.parent = &spi_dev->dev;
-       chip->indio_dev->attrs = &ad7314_attribute_group;
+       chip->indio_dev->info = &ad7314_info;
        chip->indio_dev->dev_data = (void *)chip;
-       chip->indio_dev->driver_module = THIS_MODULE;
 
        ret = iio_device_register(chip->indio_dev);
        if (ret)
                goto error_free_dev;
 
        dev_info(&spi_dev->dev, "%s temperature sensor registered.\n",
-                        chip->name);
+                        chip->indio_dev->name);
 
        return 0;
 error_free_dev:
@@ -262,8 +247,6 @@ static int __devexit ad7314_remove(struct spi_device *spi_dev)
        struct iio_dev *indio_dev = chip->indio_dev;
 
        dev_set_drvdata(&spi_dev->dev, NULL);
-       if (spi_dev->irq)
-               iio_unregister_interrupt_line(indio_dev, 0);
        iio_device_unregister(indio_dev);
        iio_free_device(chip->indio_dev);
        kfree(chip);
index f917e9c3d54f64c3c9099f39b7826cb7b1717ac0..01a70211f4ff4f6082bec8fa73a7b0741d70fdea 100644 (file)
@@ -19,11 +19,8 @@ struct ad7476_platform_data {
 };
 
 struct ad7476_chip_info {
-       u8                              bits;
-       u8                              storagebits;
-       u8                              res_shift;
-       char                            sign;
        u16                             int_vref_mv;
+       struct iio_chan_spec            channel[2];
 };
 
 struct ad7476_state {
@@ -31,8 +28,6 @@ struct ad7476_state {
        struct spi_device               *spi;
        const struct ad7476_chip_info   *chip_info;
        struct regulator                *reg;
-       struct work_struct              poll_work;
-       atomic_t                        protect_ring;
        size_t                          d_size;
        u16                             int_vref_mv;
        struct spi_transfer             xfer;
index d263904b3d1dcb8bd38569512868eda8705eb91b..50cedb42283978f98a70b09edd74f7706edd9d80 100644 (file)
@@ -6,13 +6,10 @@
  * Licensed under the GPL-2 or later.
  */
 
-#include <linux/interrupt.h>
-#include <linux/workqueue.h>
 #include <linux/device.h>
 #include <linux/kernel.h>
 #include <linux/slab.h>
 #include <linux/sysfs.h>
-#include <linux/list.h>
 #include <linux/spi/spi.h>
 #include <linux/regulator/consumer.h>
 #include <linux/err.h>
@@ -35,117 +32,97 @@ static int ad7476_scan_direct(struct ad7476_state *st)
        return (st->data[0] << 8) | st->data[1];
 }
 
-static ssize_t ad7476_scan(struct device *dev,
-                           struct device_attribute *attr,
-                           char *buf)
+static int ad7476_read_raw(struct iio_dev *dev_info,
+                          struct iio_chan_spec const *chan,
+                          int *val,
+                          int *val2,
+                          long m)
 {
-       struct iio_dev *dev_info = dev_get_drvdata(dev);
-       struct ad7476_state *st = dev_info->dev_data;
        int ret;
-
-       mutex_lock(&dev_info->mlock);
-       if (iio_ring_enabled(dev_info))
-               ret = ad7476_scan_from_ring(st);
-       else
-               ret = ad7476_scan_direct(st);
-       mutex_unlock(&dev_info->mlock);
-
-       if (ret < 0)
-               return ret;
-
-       return sprintf(buf, "%d\n", (ret >> st->chip_info->res_shift) &
-                      RES_MASK(st->chip_info->bits));
-}
-static IIO_DEV_ATTR_IN_RAW(0, ad7476_scan, 0);
-
-static ssize_t ad7476_show_scale(struct device *dev,
-                               struct device_attribute *attr,
-                               char *buf)
-{
-       /* Driver currently only support internal vref */
-       struct iio_dev *dev_info = dev_get_drvdata(dev);
-       struct ad7476_state *st = iio_dev_get_devdata(dev_info);
-       /* Corresponds to Vref / 2^(bits) */
-       unsigned int scale_uv = (st->int_vref_mv * 1000) >> st->chip_info->bits;
-
-       return sprintf(buf, "%d.%03d\n", scale_uv / 1000, scale_uv % 1000);
-}
-static IIO_DEVICE_ATTR(in_scale, S_IRUGO, ad7476_show_scale, NULL, 0);
-
-static ssize_t ad7476_show_name(struct device *dev,
-                                struct device_attribute *attr,
-                                char *buf)
-{
-       struct iio_dev *dev_info = dev_get_drvdata(dev);
-       struct ad7476_state *st = iio_dev_get_devdata(dev_info);
-
-       return sprintf(buf, "%s\n", spi_get_device_id(st->spi)->name);
+       struct ad7476_state *st = dev_info->dev_data;
+       unsigned int scale_uv;
+
+       switch (m) {
+       case 0:
+               mutex_lock(&dev_info->mlock);
+               if (iio_ring_enabled(dev_info))
+                       ret = ad7476_scan_from_ring(st);
+               else
+                       ret = ad7476_scan_direct(st);
+               mutex_unlock(&dev_info->mlock);
+
+               if (ret < 0)
+                       return ret;
+               *val = (ret >> st->chip_info->channel[0].scan_type.shift) &
+                       RES_MASK(st->chip_info->channel[0].scan_type.realbits);
+               return IIO_VAL_INT;
+       case (1 << IIO_CHAN_INFO_SCALE_SHARED):
+               scale_uv = (st->int_vref_mv * 1000)
+                       >> st->chip_info->channel[0].scan_type.realbits;
+               *val =  scale_uv/1000;
+               *val2 = (scale_uv%1000)*1000;
+               return IIO_VAL_INT_PLUS_MICRO;
+       }
+       return -EINVAL;
 }
-static IIO_DEVICE_ATTR(name, S_IRUGO, ad7476_show_name, NULL, 0);
-
-static struct attribute *ad7476_attributes[] = {
-       &iio_dev_attr_in0_raw.dev_attr.attr,
-       &iio_dev_attr_in_scale.dev_attr.attr,
-       &iio_dev_attr_name.dev_attr.attr,
-       NULL,
-};
-
-static const struct attribute_group ad7476_attribute_group = {
-       .attrs = ad7476_attributes,
-};
 
 static const struct ad7476_chip_info ad7476_chip_info_tbl[] = {
        [ID_AD7466] = {
-               .bits = 12,
-               .storagebits = 16,
-               .res_shift = 0,
-               .sign = IIO_SCAN_EL_TYPE_UNSIGNED,
+               .channel[0] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 0, 0,
+                                      (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                                      0, 0, IIO_ST('u', 12, 16, 0), 0),
+               .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
        },
        [ID_AD7467] = {
-               .bits = 10,
-               .storagebits = 16,
-               .res_shift = 2,
-               .sign = IIO_SCAN_EL_TYPE_UNSIGNED,
+               .channel[0] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 0, 0,
+                                      (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                                      0, 0, IIO_ST('u', 10, 16, 2), 0),
+               .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
        },
        [ID_AD7468] = {
-               .bits = 8,
-               .storagebits = 16,
-               .res_shift = 4,
-               .sign = IIO_SCAN_EL_TYPE_UNSIGNED,
+               .channel[0] = IIO_CHAN(IIO_IN, 0, 1 , 0, NULL, 0, 0,
+                                      (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                                      0, 0, IIO_ST('u', 8, 16, 4), 0),
+               .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
        },
        [ID_AD7475] = {
-               .bits = 12,
-               .storagebits = 16,
-               .res_shift = 0,
-               .sign = IIO_SCAN_EL_TYPE_UNSIGNED,
+               .channel[0] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 0, 0,
+                                      (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                                      0, 0, IIO_ST('u', 12, 16, 0), 0),
+               .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
        },
        [ID_AD7476] = {
-               .bits = 12,
-               .storagebits = 16,
-               .res_shift = 0,
-               .sign = IIO_SCAN_EL_TYPE_UNSIGNED,
+               .channel[0] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 0, 0,
+                                      (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                                      0, 0, IIO_ST('u', 12, 16, 0), 0),
+               .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
        },
        [ID_AD7477] = {
-               .bits = 10,
-               .storagebits = 16,
-               .res_shift = 2,
-               .sign = IIO_SCAN_EL_TYPE_UNSIGNED,
+               .channel[0] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 0, 0,
+                                      (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                                      0, 0, IIO_ST('u', 10, 16, 2), 0),
+               .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
        },
        [ID_AD7478] = {
-               .bits = 8,
-               .storagebits = 16,
-               .res_shift = 4,
-               .sign = IIO_SCAN_EL_TYPE_UNSIGNED,
+               .channel[0] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 0, 0,
+                                      (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                                      0, 0, IIO_ST('u', 8, 16, 4), 0),
+               .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
        },
        [ID_AD7495] = {
-               .bits = 12,
-               .storagebits = 16,
-               .res_shift = 0,
+               .channel[0] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 0, 0,
+                                      (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                                      0, 0, IIO_ST('u', 12, 16, 0), 0),
+               .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
                .int_vref_mv = 2500,
-               .sign = IIO_SCAN_EL_TYPE_UNSIGNED,
        },
 };
 
+static const struct iio_info ad7476_info = {
+       .driver_module = THIS_MODULE,
+       .read_raw = &ad7476_read_raw,
+};
+
 static int __devinit ad7476_probe(struct spi_device *spi)
 {
        struct ad7476_platform_data *pdata = spi->dev.platform_data;
@@ -181,10 +158,9 @@ static int __devinit ad7476_probe(struct spi_device *spi)
 
        spi_set_drvdata(spi, st);
 
-       atomic_set(&st->protect_ring, 0);
        st->spi = spi;
 
-       st->indio_dev = iio_allocate_device();
+       st->indio_dev = iio_allocate_device(0);
        if (st->indio_dev == NULL) {
                ret = -ENOMEM;
                goto error_disable_reg;
@@ -192,15 +168,16 @@ static int __devinit ad7476_probe(struct spi_device *spi)
 
        /* Establish that the iio_dev is a child of the spi device */
        st->indio_dev->dev.parent = &spi->dev;
-       st->indio_dev->attrs = &ad7476_attribute_group;
+       st->indio_dev->name = spi_get_device_id(spi)->name;
        st->indio_dev->dev_data = (void *)(st);
-       st->indio_dev->driver_module = THIS_MODULE;
        st->indio_dev->modes = INDIO_DIRECT_MODE;
-
+       st->indio_dev->channels = st->chip_info->channel;
+       st->indio_dev->num_channels = 2;
+       st->indio_dev->info = &ad7476_info;
        /* Setup default message */
 
        st->xfer.rx_buf = &st->data;
-       st->xfer.len = st->chip_info->storagebits / 8;
+       st->xfer.len = st->chip_info->channel[0].scan_type.storagebits / 8;
 
        spi_message_init(&st->msg);
        spi_message_add_tail(&st->xfer, &st->msg);
@@ -213,7 +190,9 @@ static int __devinit ad7476_probe(struct spi_device *spi)
        if (ret)
                goto error_free_device;
 
-       ret = iio_ring_buffer_register(st->indio_dev->ring, 0);
+       ret = iio_ring_buffer_register_ex(st->indio_dev->ring, 0,
+                                         st->chip_info->channel,
+                                         ARRAY_SIZE(st->chip_info->channel));
        if (ret)
                goto error_cleanup_ring;
        return 0;
index 92d93787d5b829f0f51aa70c1280723bead45bf2..b1b2ee2c56b00cc5ae4068d3064405ee4a37fe0d 100644 (file)
@@ -8,13 +8,10 @@
  */
 
 #include <linux/interrupt.h>
-#include <linux/gpio.h>
-#include <linux/workqueue.h>
 #include <linux/device.h>
 #include <linux/kernel.h>
 #include <linux/slab.h>
 #include <linux/sysfs.h>
-#include <linux/list.h>
 #include <linux/spi/spi.h>
 
 #include "../iio.h"
 
 #include "ad7476.h"
 
-static IIO_SCAN_EL_C(in0, 0, 0, NULL);
-static IIO_SCAN_EL_TIMESTAMP(1);
-static IIO_CONST_ATTR_SCAN_EL_TYPE(timestamp, s, 64, 64);
-
-static ssize_t ad7476_show_type(struct device *dev,
-                               struct device_attribute *attr,
-                               char *buf)
-{
-       struct iio_ring_buffer *ring = dev_get_drvdata(dev);
-       struct iio_dev *indio_dev = ring->indio_dev;
-       struct ad7476_state *st = indio_dev->dev_data;
-
-       return sprintf(buf, "%c%d/%d>>%d\n", st->chip_info->sign,
-                      st->chip_info->bits, st->chip_info->storagebits,
-                      st->chip_info->res_shift);
-}
-static IIO_DEVICE_ATTR(in_type, S_IRUGO, ad7476_show_type, NULL, 0);
-
-static struct attribute *ad7476_scan_el_attrs[] = {
-       &iio_scan_el_in0.dev_attr.attr,
-       &iio_const_attr_in0_index.dev_attr.attr,
-       &iio_const_attr_timestamp_index.dev_attr.attr,
-       &iio_scan_el_timestamp.dev_attr.attr,
-       &iio_const_attr_timestamp_type.dev_attr.attr,
-       &iio_dev_attr_in_type.dev_attr.attr,
-       NULL,
-};
-
-static struct attribute_group ad7476_scan_el_group = {
-       .name = "scan_elements",
-       .attrs = ad7476_scan_el_attrs,
-};
-
 int ad7476_scan_from_ring(struct ad7476_state *st)
 {
        struct iio_ring_buffer *ring = st->indio_dev->ring;
        int ret;
        u8 *ring_data;
 
-       ring_data = kmalloc(ring->access.get_bytes_per_datum(ring), GFP_KERNEL);
+       ring_data = kmalloc(ring->access->get_bytes_per_datum(ring),
+                           GFP_KERNEL);
        if (ring_data == NULL) {
                ret = -ENOMEM;
                goto error_ret;
        }
-       ret = ring->access.read_last(ring, ring_data);
+       ret = ring->access->read_last(ring, ring_data);
        if (ret)
                goto error_free_ring_data;
 
@@ -93,7 +58,8 @@ static int ad7476_ring_preenable(struct iio_dev *indio_dev)
        struct ad7476_state *st = indio_dev->dev_data;
        struct iio_ring_buffer *ring = indio_dev->ring;
 
-       st->d_size = ring->scan_count * st->chip_info->storagebits / 8;
+       st->d_size = ring->scan_count *
+               st->chip_info->channel[0].scan_type.storagebits / 8;
 
        if (ring->scan_timestamp) {
                st->d_size += sizeof(s64);
@@ -102,55 +68,28 @@ static int ad7476_ring_preenable(struct iio_dev *indio_dev)
                        st->d_size += sizeof(s64) - (st->d_size % sizeof(s64));
        }
 
-       if (indio_dev->ring->access.set_bytes_per_datum)
-               indio_dev->ring->access.set_bytes_per_datum(indio_dev->ring,
+       if (indio_dev->ring->access->set_bytes_per_datum)
+               indio_dev->ring->access->set_bytes_per_datum(indio_dev->ring,
                                                            st->d_size);
 
        return 0;
 }
 
-/**
- * ad7476_poll_func_th() th of trigger launched polling to ring buffer
- *
- * As sampling only occurs on i2c comms occurring, leave timestamping until
- * then.  Some triggers will generate their own time stamp.  Currently
- * there is no way of notifying them when no one cares.
- **/
-static void ad7476_poll_func_th(struct iio_dev *indio_dev, s64 time)
+static irqreturn_t ad7476_trigger_handler(int irq, void  *p)
 {
-       struct ad7476_state *st = indio_dev->dev_data;
-
-       schedule_work(&st->poll_work);
-       return;
-}
-/**
- * ad7476_poll_bh_to_ring() bh of trigger launched polling to ring buffer
- * @work_s:    the work struct through which this was scheduled
- *
- * Currently there is no option in this driver to disable the saving of
- * timestamps within the ring.
- * I think the one copy of this at a time was to avoid problems if the
- * trigger was set far too high and the reads then locked up the computer.
- **/
-static void ad7476_poll_bh_to_ring(struct work_struct *work_s)
-{
-       struct ad7476_state *st = container_of(work_s, struct ad7476_state,
-                                                 poll_work);
-       struct iio_dev *indio_dev = st->indio_dev;
-       struct iio_sw_ring_buffer *sw_ring = iio_to_sw_ring(indio_dev->ring);
+       struct iio_poll_func *pf = p;
+       struct iio_dev *indio_dev = pf->private_data;
+       struct ad7476_state *st = iio_dev_get_devdata(indio_dev);
        s64 time_ns;
        __u8 *rxbuf;
        int b_sent;
 
-       /* Ensure only one copy of this function running at a time */
-       if (atomic_inc_return(&st->protect_ring) > 1)
-               return;
-
        rxbuf = kzalloc(st->d_size, GFP_KERNEL);
        if (rxbuf == NULL)
-               return;
+               return -ENOMEM;
 
-       b_sent = spi_read(st->spi, rxbuf, st->chip_info->storagebits / 8);
+       b_sent = spi_read(st->spi, rxbuf,
+                         st->chip_info->channel[0].scan_type.storagebits / 8);
        if (b_sent < 0)
                goto done;
 
@@ -160,12 +99,20 @@ static void ad7476_poll_bh_to_ring(struct work_struct *work_s)
                memcpy(rxbuf + st->d_size - sizeof(s64),
                        &time_ns, sizeof(time_ns));
 
-       indio_dev->ring->access.store_to(&sw_ring->buf, rxbuf, time_ns);
+       indio_dev->ring->access->store_to(indio_dev->ring, rxbuf, time_ns);
 done:
+       iio_trigger_notify_done(indio_dev->trig);
        kfree(rxbuf);
-       atomic_dec(&st->protect_ring);
+
+       return IRQ_HANDLED;
 }
 
+static const struct iio_ring_setup_ops ad7476_ring_setup_ops = {
+       .preenable = &ad7476_ring_preenable,
+       .postenable = &iio_triggered_ring_postenable,
+       .predisable = &iio_triggered_ring_predisable,
+};
+
 int ad7476_register_ring_funcs_and_init(struct iio_dev *indio_dev)
 {
        struct ad7476_state *st = indio_dev->dev_data;
@@ -177,24 +124,28 @@ int ad7476_register_ring_funcs_and_init(struct iio_dev *indio_dev)
                goto error_ret;
        }
        /* Effectively select the ring buffer implementation */
-       iio_ring_sw_register_funcs(&indio_dev->ring->access);
-       ret = iio_alloc_pollfunc(indio_dev, NULL, &ad7476_poll_func_th);
-       if (ret)
+       indio_dev->ring->access = &ring_sw_access_funcs;
+       indio_dev->pollfunc
+               = iio_alloc_pollfunc(NULL,
+                                    &ad7476_trigger_handler,
+                                    IRQF_ONESHOT,
+                                    indio_dev,
+                                    "%s_consumer%d",
+                                    spi_get_device_id(st->spi)->name,
+                                    indio_dev->id);
+       if (indio_dev->pollfunc == NULL) {
+               ret = -ENOMEM;
                goto error_deallocate_sw_rb;
+       }
 
        /* Ring buffer functions - here trigger setup related */
-
-       indio_dev->ring->preenable = &ad7476_ring_preenable;
-       indio_dev->ring->postenable = &iio_triggered_ring_postenable;
-       indio_dev->ring->predisable = &iio_triggered_ring_predisable;
-       indio_dev->ring->scan_el_attrs = &ad7476_scan_el_group;
+       indio_dev->ring->setup_ops = &ad7476_ring_setup_ops;
        indio_dev->ring->scan_timestamp = true;
 
-       INIT_WORK(&st->poll_work, &ad7476_poll_bh_to_ring);
-
        /* Flag that polled ring buffering is possible */
        indio_dev->modes |= INDIO_RING_TRIGGERED;
        return 0;
+
 error_deallocate_sw_rb:
        iio_sw_rb_free(indio_dev->ring);
 error_ret:
@@ -209,6 +160,6 @@ void ad7476_ring_cleanup(struct iio_dev *indio_dev)
                iio_trigger_dettach_poll_func(indio_dev->trig,
                                              indio_dev->pollfunc);
        }
-       kfree(indio_dev->pollfunc);
+       iio_dealloc_pollfunc(indio_dev->pollfunc);
        iio_sw_rb_free(indio_dev->ring);
 }
index 338bade801a7b633c5b53dec1fe9f09385f468d7..b8b3d8ef1ff29c609cf45e280b10e4198dc4a367 100644 (file)
@@ -43,17 +43,17 @@ struct ad7606_platform_data {
 /**
  * struct ad7606_chip_info - chip specifc information
  * @name:              indentification string for chip
- * @bits:              accuracy of the adc in bits
- * @bits:              output coding [s]igned or [u]nsigned
  * @int_vref_mv:       the internal reference voltage
- * @num_channels:      number of physical inputs on chip
+ * @channels:          channel specification
+ * @num_channels:      number of channels
  */
 
 struct ad7606_chip_info {
-       char                            name[10];
+       const char                      *name;
        u8                              bits;
        char                            sign;
        u16                             int_vref_mv;
+       struct iio_chan_spec            *channels;
        unsigned                        num_channels;
 };
 
@@ -62,14 +62,12 @@ struct ad7606_chip_info {
  */
 
 struct ad7606_state {
-       struct iio_dev                  *indio_dev;
        struct device                   *dev;
        const struct ad7606_chip_info   *chip_info;
        struct ad7606_platform_data     *pdata;
        struct regulator                *reg;
        struct work_struct              poll_work;
        wait_queue_head_t               wq_data_avail;
-       atomic_t                        protect_ring;
        size_t                          d_size;
        const struct ad7606_bus_ops     *bops;
        int                             irq;
@@ -97,12 +95,12 @@ struct ad7606_bus_ops {
        int (*read_block)(struct device *, int, void *);
 };
 
-void ad7606_suspend(struct ad7606_state *st);
-void ad7606_resume(struct ad7606_state *st);
-struct ad7606_state *ad7606_probe(struct device *dev, int irq,
+void ad7606_suspend(struct iio_dev *indio_dev);
+void ad7606_resume(struct iio_dev *indio_dev);
+struct iio_dev *ad7606_probe(struct device *dev, int irq,
                              void __iomem *base_address, unsigned id,
                              const struct ad7606_bus_ops *bops);
-int ad7606_remove(struct ad7606_state *st);
+int ad7606_remove(struct iio_dev *indio_dev);
 int ad7606_reset(struct ad7606_state *st);
 
 enum ad7606_supported_device_ids {
@@ -111,7 +109,7 @@ enum ad7606_supported_device_ids {
        ID_AD7606_4
 };
 
-int ad7606_scan_from_ring(struct ad7606_state *st, unsigned ch);
+int ad7606_scan_from_ring(struct iio_dev *indio_dev, unsigned ch);
 int ad7606_register_ring_funcs_and_init(struct iio_dev *indio_dev);
 void ad7606_ring_cleanup(struct iio_dev *indio_dev);
 #endif /* IIO_ADC_AD7606_H_ */
index 4c700f07fb8304f48625e4a61bbca895fa34d44a..459371ae4dccd10de976f9b2aa5b7a7b60877553 100644 (file)
@@ -7,12 +7,10 @@
  */
 
 #include <linux/interrupt.h>
-#include <linux/workqueue.h>
 #include <linux/device.h>
 #include <linux/kernel.h>
 #include <linux/slab.h>
 #include <linux/sysfs.h>
-#include <linux/list.h>
 #include <linux/regulator/consumer.h>
 #include <linux/err.h>
 #include <linux/gpio.h>
@@ -38,8 +36,9 @@ int ad7606_reset(struct ad7606_state *st)
        return -ENODEV;
 }
 
-static int ad7606_scan_direct(struct ad7606_state *st, unsigned ch)
+static int ad7606_scan_direct(struct iio_dev *indio_dev, unsigned ch)
 {
+       struct ad7606_state *st = iio_priv(indio_dev);
        int ret;
 
        st->done = false;
@@ -78,67 +77,44 @@ error_ret:
        return ret;
 }
 
-static ssize_t ad7606_scan(struct device *dev,
-                           struct device_attribute *attr,
-                           char *buf)
+static int ad7606_read_raw(struct iio_dev *indio_dev,
+                          struct iio_chan_spec const *chan,
+                          int *val,
+                          int *val2,
+                          long m)
 {
-       struct iio_dev *dev_info = dev_get_drvdata(dev);
-       struct ad7606_state *st = dev_info->dev_data;
-       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
        int ret;
-
-       mutex_lock(&dev_info->mlock);
-       if (iio_ring_enabled(dev_info))
-               ret = ad7606_scan_from_ring(st, this_attr->address);
-       else
-               ret = ad7606_scan_direct(st, this_attr->address);
-       mutex_unlock(&dev_info->mlock);
-
-       if (ret < 0)
-               return ret;
-
-       return sprintf(buf, "%d\n", (short) ret);
-}
-
-static IIO_DEV_ATTR_IN_RAW(0, ad7606_scan, 0);
-static IIO_DEV_ATTR_IN_RAW(1, ad7606_scan, 1);
-static IIO_DEV_ATTR_IN_RAW(2, ad7606_scan, 2);
-static IIO_DEV_ATTR_IN_RAW(3, ad7606_scan, 3);
-static IIO_DEV_ATTR_IN_RAW(4, ad7606_scan, 4);
-static IIO_DEV_ATTR_IN_RAW(5, ad7606_scan, 5);
-static IIO_DEV_ATTR_IN_RAW(6, ad7606_scan, 6);
-static IIO_DEV_ATTR_IN_RAW(7, ad7606_scan, 7);
-
-static ssize_t ad7606_show_scale(struct device *dev,
-                               struct device_attribute *attr,
-                               char *buf)
-{
-       /* Driver currently only support internal vref */
-       struct iio_dev *dev_info = dev_get_drvdata(dev);
-       struct ad7606_state *st = iio_dev_get_devdata(dev_info);
-       unsigned int scale_uv = (st->range * 1000 * 2) >> st->chip_info->bits;
-
-       return sprintf(buf, "%d.%03d\n", scale_uv / 1000, scale_uv % 1000);
-}
-static IIO_DEVICE_ATTR(in_scale, S_IRUGO, ad7606_show_scale, NULL, 0);
-
-static ssize_t ad7606_show_name(struct device *dev,
-                                struct device_attribute *attr,
-                                char *buf)
-{
-       struct iio_dev *dev_info = dev_get_drvdata(dev);
-       struct ad7606_state *st = iio_dev_get_devdata(dev_info);
-
-       return sprintf(buf, "%s\n", st->chip_info->name);
+       struct ad7606_state *st = iio_priv(indio_dev);
+       unsigned int scale_uv;
+
+       switch (m) {
+       case 0:
+               mutex_lock(&indio_dev->mlock);
+               if (iio_ring_enabled(indio_dev))
+                       ret = ad7606_scan_from_ring(indio_dev, chan->address);
+               else
+                       ret = ad7606_scan_direct(indio_dev, chan->address);
+               mutex_unlock(&indio_dev->mlock);
+
+               if (ret < 0)
+                       return ret;
+               *val = (short) ret;
+               return IIO_VAL_INT;
+       case (1 << IIO_CHAN_INFO_SCALE_SHARED):
+               scale_uv = (st->range * 1000 * 2)
+                       >> st->chip_info->channels[0].scan_type.realbits;
+               *val =  scale_uv / 1000;
+               *val2 = (scale_uv % 1000) * 1000;
+               return IIO_VAL_INT_PLUS_MICRO;
+       }
+       return -EINVAL;
 }
 
-static IIO_DEVICE_ATTR(name, S_IRUGO, ad7606_show_name, NULL, 0);
-
 static ssize_t ad7606_show_range(struct device *dev,
                        struct device_attribute *attr, char *buf)
 {
-       struct iio_dev *dev_info = dev_get_drvdata(dev);
-       struct ad7606_state *st = iio_dev_get_devdata(dev_info);
+       struct iio_dev *indio_dev = dev_get_drvdata(dev);
+       struct ad7606_state *st = iio_priv(indio_dev);
 
        return sprintf(buf, "%u\n", st->range);
 }
@@ -146,8 +122,8 @@ static ssize_t ad7606_show_range(struct device *dev,
 static ssize_t ad7606_store_range(struct device *dev,
                struct device_attribute *attr, const char *buf, size_t count)
 {
-       struct iio_dev *dev_info = dev_get_drvdata(dev);
-       struct ad7606_state *st = iio_dev_get_devdata(dev_info);
+       struct iio_dev *indio_dev = dev_get_drvdata(dev);
+       struct ad7606_state *st = iio_priv(indio_dev);
        unsigned long lval;
 
        if (strict_strtoul(buf, 10, &lval))
@@ -156,10 +132,10 @@ static ssize_t ad7606_store_range(struct device *dev,
                dev_err(dev, "range is not supported\n");
                return -EINVAL;
        }
-       mutex_lock(&dev_info->mlock);
+       mutex_lock(&indio_dev->mlock);
        gpio_set_value(st->pdata->gpio_range, lval == 10000);
        st->range = lval;
-       mutex_unlock(&dev_info->mlock);
+       mutex_unlock(&indio_dev->mlock);
 
        return count;
 }
@@ -171,8 +147,8 @@ static IIO_CONST_ATTR(range_available, "5000 10000");
 static ssize_t ad7606_show_oversampling_ratio(struct device *dev,
                        struct device_attribute *attr, char *buf)
 {
-       struct iio_dev *dev_info = dev_get_drvdata(dev);
-       struct ad7606_state *st = iio_dev_get_devdata(dev_info);
+       struct iio_dev *indio_dev = dev_get_drvdata(dev);
+       struct ad7606_state *st = iio_priv(indio_dev);
 
        return sprintf(buf, "%u\n", st->oversampling);
 }
@@ -192,8 +168,8 @@ static int ad7606_oversampling_get_index(unsigned val)
 static ssize_t ad7606_store_oversampling_ratio(struct device *dev,
                struct device_attribute *attr, const char *buf, size_t count)
 {
-       struct iio_dev *dev_info = dev_get_drvdata(dev);
-       struct ad7606_state *st = iio_dev_get_devdata(dev_info);
+       struct iio_dev *indio_dev = dev_get_drvdata(dev);
+       struct ad7606_state *st = iio_priv(indio_dev);
        unsigned long lval;
        int ret;
 
@@ -206,12 +182,12 @@ static ssize_t ad7606_store_oversampling_ratio(struct device *dev,
                return ret;
        }
 
-       mutex_lock(&dev_info->mlock);
+       mutex_lock(&indio_dev->mlock);
        gpio_set_value(st->pdata->gpio_os0, (ret >> 0) & 1);
        gpio_set_value(st->pdata->gpio_os1, (ret >> 1) & 1);
        gpio_set_value(st->pdata->gpio_os1, (ret >> 2) & 1);
        st->oversampling = lval;
-       mutex_unlock(&dev_info->mlock);
+       mutex_unlock(&indio_dev->mlock);
 
        return count;
 }
@@ -222,16 +198,6 @@ static IIO_DEVICE_ATTR(oversampling_ratio, S_IRUGO | S_IWUSR,
 static IIO_CONST_ATTR(oversampling_ratio_available, "0 2 4 8 16 32 64");
 
 static struct attribute *ad7606_attributes[] = {
-       &iio_dev_attr_in0_raw.dev_attr.attr,
-       &iio_dev_attr_in1_raw.dev_attr.attr,
-       &iio_dev_attr_in2_raw.dev_attr.attr,
-       &iio_dev_attr_in3_raw.dev_attr.attr,
-       &iio_dev_attr_in4_raw.dev_attr.attr,
-       &iio_dev_attr_in5_raw.dev_attr.attr,
-       &iio_dev_attr_in6_raw.dev_attr.attr,
-       &iio_dev_attr_in7_raw.dev_attr.attr,
-       &iio_dev_attr_in_scale.dev_attr.attr,
-       &iio_dev_attr_name.dev_attr.attr,
        &iio_dev_attr_range.dev_attr.attr,
        &iio_const_attr_range_available.dev_attr.attr,
        &iio_dev_attr_oversampling_ratio.dev_attr.attr,
@@ -243,20 +209,12 @@ static mode_t ad7606_attr_is_visible(struct kobject *kobj,
                                     struct attribute *attr, int n)
 {
        struct device *dev = container_of(kobj, struct device, kobj);
-       struct iio_dev *dev_info = dev_get_drvdata(dev);
-       struct ad7606_state *st = iio_dev_get_devdata(dev_info);
+       struct iio_dev *indio_dev = dev_get_drvdata(dev);
+       struct ad7606_state *st = iio_priv(indio_dev);
 
        mode_t mode = attr->mode;
 
-       if (st->chip_info->num_channels <= 6 &&
-               (attr == &iio_dev_attr_in7_raw.dev_attr.attr ||
-               attr == &iio_dev_attr_in6_raw.dev_attr.attr))
-               mode = 0;
-       else if (st->chip_info->num_channels <= 4 &&
-               (attr == &iio_dev_attr_in5_raw.dev_attr.attr ||
-               attr == &iio_dev_attr_in4_raw.dev_attr.attr))
-               mode = 0;
-       else if (!st->have_os &&
+       if (!st->have_os &&
                (attr == &iio_dev_attr_oversampling_ratio.dev_attr.attr ||
                attr ==
                &iio_const_attr_oversampling_ratio_available.dev_attr.attr))
@@ -274,29 +232,92 @@ static const struct attribute_group ad7606_attribute_group = {
        .is_visible = ad7606_attr_is_visible,
 };
 
+static struct iio_chan_spec ad7606_8_channels[] = {
+       IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 0, 0,
+                (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                0, 0, IIO_ST('s', 16, 16, 0), 0),
+       IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 1, 0,
+                (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                1, 1, IIO_ST('s', 16, 16, 0), 0),
+       IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 2, 0,
+                (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                2, 2, IIO_ST('s', 16, 16, 0), 0),
+       IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 3, 0,
+                (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                3, 3, IIO_ST('s', 16, 16, 0), 0),
+       IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 4, 0,
+                (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                4, 4, IIO_ST('s', 16, 16, 0), 0),
+       IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 5, 0,
+                (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                5, 5, IIO_ST('s', 16, 16, 0), 0),
+       IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 6, 0,
+                (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                6, 6, IIO_ST('s', 16, 16, 0), 0),
+       IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 7, 0,
+                (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                7, 7, IIO_ST('s', 16, 16, 0), 0),
+       IIO_CHAN_SOFT_TIMESTAMP(8),
+};
+
+static struct iio_chan_spec ad7606_6_channels[] = {
+       IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 0, 0,
+                (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                0, 0, IIO_ST('s', 16, 16, 0), 0),
+       IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 1, 0,
+                (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                1, 1, IIO_ST('s', 16, 16, 0), 0),
+       IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 2, 0,
+                (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                2, 2, IIO_ST('s', 16, 16, 0), 0),
+       IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 3, 0,
+                (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                3, 3, IIO_ST('s', 16, 16, 0), 0),
+       IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 4, 0,
+                (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                4, 4, IIO_ST('s', 16, 16, 0), 0),
+       IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 5, 0,
+                (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                5, 5, IIO_ST('s', 16, 16, 0), 0),
+       IIO_CHAN_SOFT_TIMESTAMP(6),
+};
+
+static struct iio_chan_spec ad7606_4_channels[] = {
+       IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 0, 0,
+                (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                0, 0, IIO_ST('s', 16, 16, 0), 0),
+       IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 1, 0,
+                (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                1, 1, IIO_ST('s', 16, 16, 0), 0),
+       IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 2, 0,
+                (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                2, 2, IIO_ST('s', 16, 16, 0), 0),
+       IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 3, 0,
+                (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                3, 3, IIO_ST('s', 16, 16, 0), 0),
+       IIO_CHAN_SOFT_TIMESTAMP(4),
+};
+
 static const struct ad7606_chip_info ad7606_chip_info_tbl[] = {
        /*
         * More devices added in future
         */
        [ID_AD7606_8] = {
                .name = "ad7606",
-               .bits = 16,
-               .sign = IIO_SCAN_EL_TYPE_SIGNED,
                .int_vref_mv = 2500,
+               .channels = ad7606_8_channels,
                .num_channels = 8,
        },
        [ID_AD7606_6] = {
                .name = "ad7606-6",
-               .bits = 16,
-               .sign = IIO_SCAN_EL_TYPE_SIGNED,
                .int_vref_mv = 2500,
+               .channels = ad7606_6_channels,
                .num_channels = 6,
        },
        [ID_AD7606_4] = {
                .name = "ad7606-4",
-               .bits = 16,
-               .sign = IIO_SCAN_EL_TYPE_SIGNED,
                .int_vref_mv = 2500,
+               .channels = ad7606_4_channels,
                .num_channels = 4,
        },
 };
@@ -343,8 +364,8 @@ static int ad7606_request_gpios(struct ad7606_state *st)
                st->have_reset = true;
 
        ret = gpio_request_one(st->pdata->gpio_range, GPIOF_DIR_OUT |
-                              ((st->range == 10000) ? GPIOF_INIT_HIGH :
-                               GPIOF_INIT_LOW), "AD7606_RANGE");
+                               ((st->range == 10000) ? GPIOF_INIT_HIGH :
+                               GPIOF_INIT_LOW), "AD7606_RANGE");
        if (!ret)
                st->have_range = true;
 
@@ -391,9 +412,10 @@ static void ad7606_free_gpios(struct ad7606_state *st)
  */
 static irqreturn_t ad7606_interrupt(int irq, void *dev_id)
 {
-       struct ad7606_state *st = dev_id;
+       struct iio_dev *indio_dev = dev_id;
+       struct ad7606_state *st = iio_priv(indio_dev);
 
-       if (iio_ring_enabled(st->indio_dev)) {
+       if (iio_ring_enabled(indio_dev)) {
                if (!work_pending(&st->poll_work))
                        schedule_work(&st->poll_work);
        } else {
@@ -404,21 +426,29 @@ static irqreturn_t ad7606_interrupt(int irq, void *dev_id)
        return IRQ_HANDLED;
 };
 
-struct ad7606_state *ad7606_probe(struct device *dev, int irq,
+static const struct iio_info ad7606_info = {
+       .driver_module = THIS_MODULE,
+       .read_raw = &ad7606_read_raw,
+       .attrs = &ad7606_attribute_group,
+};
+
+struct iio_dev *ad7606_probe(struct device *dev, int irq,
                              void __iomem *base_address,
                              unsigned id,
                              const struct ad7606_bus_ops *bops)
 {
        struct ad7606_platform_data *pdata = dev->platform_data;
        struct ad7606_state *st;
-       int ret;
+       int ret, regdone = 0;
+       struct iio_dev *indio_dev = iio_allocate_device(sizeof(*st));
 
-       st = kzalloc(sizeof(*st), GFP_KERNEL);
-       if (st == NULL) {
+       if (indio_dev == NULL) {
                ret = -ENOMEM;
                goto error_ret;
        }
 
+       st = iio_priv(indio_dev);
+
        st->dev = dev;
        st->id = id;
        st->irq = irq;
@@ -445,93 +475,91 @@ struct ad7606_state *ad7606_probe(struct device *dev, int irq,
        st->pdata = pdata;
        st->chip_info = &ad7606_chip_info_tbl[id];
 
-       atomic_set(&st->protect_ring, 0);
-
-       st->indio_dev = iio_allocate_device();
-       if (st->indio_dev == NULL) {
-               ret = -ENOMEM;
-               goto error_disable_reg;
-       }
-
-       st->indio_dev->dev.parent = dev;
-       st->indio_dev->attrs = &ad7606_attribute_group;
-       st->indio_dev->dev_data = (void *)(st);
-       st->indio_dev->driver_module = THIS_MODULE;
-       st->indio_dev->modes = INDIO_DIRECT_MODE;
+       indio_dev->dev.parent = dev;
+       indio_dev->info = &ad7606_info;
+       indio_dev->modes = INDIO_DIRECT_MODE;
+       indio_dev->name = st->chip_info->name;
+       indio_dev->channels = st->chip_info->channels;
+       indio_dev->num_channels = st->chip_info->num_channels;
 
        init_waitqueue_head(&st->wq_data_avail);
 
        ret = ad7606_request_gpios(st);
        if (ret)
-               goto error_free_device;
+               goto error_disable_reg;
 
        ret = ad7606_reset(st);
        if (ret)
                dev_warn(st->dev, "failed to RESET: no RESET GPIO specified\n");
 
        ret = request_irq(st->irq, ad7606_interrupt,
-               IRQF_TRIGGER_FALLING, st->chip_info->name, st);
+               IRQF_TRIGGER_FALLING, st->chip_info->name, indio_dev);
        if (ret)
                goto error_free_gpios;
 
-       ret = ad7606_register_ring_funcs_and_init(st->indio_dev);
+       ret = ad7606_register_ring_funcs_and_init(indio_dev);
        if (ret)
                goto error_free_irq;
 
-       ret = iio_device_register(st->indio_dev);
+       ret = iio_device_register(indio_dev);
        if (ret)
                goto error_free_irq;
+       regdone = 1;
 
-       ret = iio_ring_buffer_register(st->indio_dev->ring, 0);
+       ret = iio_ring_buffer_register_ex(indio_dev->ring, 0,
+                                         indio_dev->channels,
+                                         indio_dev->num_channels);
        if (ret)
                goto error_cleanup_ring;
 
-       return st;
+       return indio_dev;
 
 error_cleanup_ring:
-       ad7606_ring_cleanup(st->indio_dev);
-       iio_device_unregister(st->indio_dev);
+       ad7606_ring_cleanup(indio_dev);
 
 error_free_irq:
-       free_irq(st->irq, st);
+       free_irq(st->irq, indio_dev);
 
 error_free_gpios:
        ad7606_free_gpios(st);
 
-error_free_device:
-       iio_free_device(st->indio_dev);
-
 error_disable_reg:
        if (!IS_ERR(st->reg))
                regulator_disable(st->reg);
 error_put_reg:
        if (!IS_ERR(st->reg))
                regulator_put(st->reg);
-       kfree(st);
+       if (regdone)
+               iio_device_unregister(indio_dev);
+       else
+               iio_free_device(indio_dev);
 error_ret:
        return ERR_PTR(ret);
 }
 
-int ad7606_remove(struct ad7606_state *st)
+int ad7606_remove(struct iio_dev *indio_dev)
 {
-       struct iio_dev *indio_dev = st->indio_dev;
+       struct ad7606_state *st = iio_priv(indio_dev);
+
        iio_ring_buffer_unregister(indio_dev->ring);
        ad7606_ring_cleanup(indio_dev);
-       iio_device_unregister(indio_dev);
-       free_irq(st->irq, st);
+
+       free_irq(st->irq, indio_dev);
        if (!IS_ERR(st->reg)) {
                regulator_disable(st->reg);
                regulator_put(st->reg);
        }
 
        ad7606_free_gpios(st);
+       iio_device_unregister(indio_dev);
 
-       kfree(st);
        return 0;
 }
 
-void ad7606_suspend(struct ad7606_state *st)
+void ad7606_suspend(struct iio_dev *indio_dev)
 {
+       struct ad7606_state *st = iio_priv(indio_dev);
+
        if (st->have_stby) {
                if (st->have_range)
                        gpio_set_value(st->pdata->gpio_range, 1);
@@ -539,8 +567,10 @@ void ad7606_suspend(struct ad7606_state *st)
        }
 }
 
-void ad7606_resume(struct ad7606_state *st)
+void ad7606_resume(struct iio_dev *indio_dev)
 {
+       struct ad7606_state *st = iio_priv(indio_dev);
+
        if (st->have_stby) {
                if (st->have_range)
                        gpio_set_value(st->pdata->gpio_range,
index 43a554ce753da23a0cb1e15202210d4282b4858c..d21218da923f9e9bfe357aef817e60fb2ccd76a7 100644 (file)
 #include <linux/err.h>
 #include <linux/io.h>
 
+#include "../iio.h"
 #include "ad7606.h"
 
 static int ad7606_par16_read_block(struct device *dev,
                                 int count, void *buf)
 {
        struct platform_device *pdev = to_platform_device(dev);
-       struct ad7606_state *st = platform_get_drvdata(pdev);
+       struct iio_dev *indio_dev = platform_get_drvdata(pdev);
+       struct ad7606_state *st = iio_priv(indio_dev);
 
        insw((unsigned long) st->base_address, buf, count);
 
@@ -33,7 +35,8 @@ static int ad7606_par8_read_block(struct device *dev,
                                 int count, void *buf)
 {
        struct platform_device *pdev = to_platform_device(dev);
-       struct ad7606_state *st = platform_get_drvdata(pdev);
+       struct iio_dev *indio_dev = platform_get_drvdata(pdev);
+       struct ad7606_state *st = iio_priv(indio_dev);
 
        insb((unsigned long) st->base_address, buf, count * 2);
 
@@ -47,7 +50,7 @@ static const struct ad7606_bus_ops ad7606_par8_bops = {
 static int __devinit ad7606_par_probe(struct platform_device *pdev)
 {
        struct resource *res;
-       struct ad7606_state *st;
+       struct iio_dev *indio_dev;
        void __iomem *addr;
        resource_size_t remap_size;
        int ret, irq;
@@ -75,17 +78,17 @@ static int __devinit ad7606_par_probe(struct platform_device *pdev)
                goto out1;
        }
 
-       st = ad7606_probe(&pdev->dev, irq, addr,
+       indio_dev = ad7606_probe(&pdev->dev, irq, addr,
                          platform_get_device_id(pdev)->driver_data,
                          remap_size > 1 ? &ad7606_par16_bops :
                          &ad7606_par8_bops);
 
-       if (IS_ERR(st))  {
-               ret = PTR_ERR(st);
+       if (IS_ERR(indio_dev))  {
+               ret = PTR_ERR(indio_dev);
                goto out2;
        }
 
-       platform_set_drvdata(pdev, st);
+       platform_set_drvdata(pdev, indio_dev);
 
        return 0;
 
@@ -99,10 +102,11 @@ out1:
 
 static int __devexit ad7606_par_remove(struct platform_device *pdev)
 {
-       struct ad7606_state *st = platform_get_drvdata(pdev);
+       struct iio_dev *indio_dev = platform_get_drvdata(pdev);
        struct resource *res;
+       struct ad7606_state *st = iio_priv(indio_dev);
 
-       ad7606_remove(st);
+       ad7606_remove(indio_dev);
 
        iounmap(st->base_address);
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -116,18 +120,18 @@ static int __devexit ad7606_par_remove(struct platform_device *pdev)
 #ifdef CONFIG_PM
 static int ad7606_par_suspend(struct device *dev)
 {
-       struct ad7606_state *st = dev_get_drvdata(dev);
+       struct iio_dev *indio_dev = dev_get_drvdata(dev);
 
-       ad7606_suspend(st);
+       ad7606_suspend(indio_dev);
 
        return 0;
 }
 
 static int ad7606_par_resume(struct device *dev)
 {
-       struct ad7606_state *st = dev_get_drvdata(dev);
+       struct iio_dev *indio_dev = dev_get_drvdata(dev);
 
-       ad7606_resume(st);
+       ad7606_resume(indio_dev);
 
        return 0;
 }
index b32cb0dea6d82052a4e650b4b0b3721d30973983..a199bf48396c5a4e3691dab597545cc37839c670 100644 (file)
@@ -7,7 +7,6 @@
 
 #include <linux/interrupt.h>
 #include <linux/gpio.h>
-#include <linux/workqueue.h>
 #include <linux/device.h>
 #include <linux/kernel.h>
 #include <linux/slab.h>
 
 #include "ad7606.h"
 
-static IIO_SCAN_EL_C(in0, 0, 0, NULL);
-static IIO_SCAN_EL_C(in1, 1, 0, NULL);
-static IIO_SCAN_EL_C(in2, 2, 0, NULL);
-static IIO_SCAN_EL_C(in3, 3, 0, NULL);
-static IIO_SCAN_EL_C(in4, 4, 0, NULL);
-static IIO_SCAN_EL_C(in5, 5, 0, NULL);
-static IIO_SCAN_EL_C(in6, 6, 0, NULL);
-static IIO_SCAN_EL_C(in7, 7, 0, NULL);
-
-static IIO_SCAN_EL_TIMESTAMP(8);
-static IIO_CONST_ATTR_SCAN_EL_TYPE(timestamp, s, 64, 64);
-
-static ssize_t ad7606_show_type(struct device *dev,
-                               struct device_attribute *attr,
-                               char *buf)
+int ad7606_scan_from_ring(struct iio_dev *indio_dev, unsigned ch)
 {
-       struct iio_ring_buffer *ring = dev_get_drvdata(dev);
-       struct iio_dev *indio_dev = ring->indio_dev;
-       struct ad7606_state *st = indio_dev->dev_data;
-
-       return sprintf(buf, "%c%d/%d\n", st->chip_info->sign,
-                      st->chip_info->bits, st->chip_info->bits);
-}
-static IIO_DEVICE_ATTR(in_type, S_IRUGO, ad7606_show_type, NULL, 0);
-
-static struct attribute *ad7606_scan_el_attrs[] = {
-       &iio_scan_el_in0.dev_attr.attr,
-       &iio_const_attr_in0_index.dev_attr.attr,
-       &iio_scan_el_in1.dev_attr.attr,
-       &iio_const_attr_in1_index.dev_attr.attr,
-       &iio_scan_el_in2.dev_attr.attr,
-       &iio_const_attr_in2_index.dev_attr.attr,
-       &iio_scan_el_in3.dev_attr.attr,
-       &iio_const_attr_in3_index.dev_attr.attr,
-       &iio_scan_el_in4.dev_attr.attr,
-       &iio_const_attr_in4_index.dev_attr.attr,
-       &iio_scan_el_in5.dev_attr.attr,
-       &iio_const_attr_in5_index.dev_attr.attr,
-       &iio_scan_el_in6.dev_attr.attr,
-       &iio_const_attr_in6_index.dev_attr.attr,
-       &iio_scan_el_in7.dev_attr.attr,
-       &iio_const_attr_in7_index.dev_attr.attr,
-       &iio_const_attr_timestamp_index.dev_attr.attr,
-       &iio_scan_el_timestamp.dev_attr.attr,
-       &iio_const_attr_timestamp_type.dev_attr.attr,
-       &iio_dev_attr_in_type.dev_attr.attr,
-       NULL,
-};
-
-static mode_t ad7606_scan_el_attr_is_visible(struct kobject *kobj,
-                                    struct attribute *attr, int n)
-{
-       struct device *dev = container_of(kobj, struct device, kobj);
-       struct iio_ring_buffer *ring = dev_get_drvdata(dev);
-       struct iio_dev *indio_dev = ring->indio_dev;
-       struct ad7606_state *st = indio_dev->dev_data;
-
-       mode_t mode = attr->mode;
-
-       if (st->chip_info->num_channels <= 6 &&
-               (attr == &iio_scan_el_in7.dev_attr.attr ||
-               attr == &iio_const_attr_in7_index.dev_attr.attr ||
-               attr == &iio_scan_el_in6.dev_attr.attr ||
-               attr == &iio_const_attr_in6_index.dev_attr.attr))
-               mode = 0;
-       else if (st->chip_info->num_channels <= 4 &&
-               (attr == &iio_scan_el_in5.dev_attr.attr ||
-               attr == &iio_const_attr_in5_index.dev_attr.attr ||
-               attr == &iio_scan_el_in4.dev_attr.attr ||
-               attr == &iio_const_attr_in4_index.dev_attr.attr))
-               mode = 0;
-
-       return mode;
-}
-
-static struct attribute_group ad7606_scan_el_group = {
-       .name = "scan_elements",
-       .attrs = ad7606_scan_el_attrs,
-       .is_visible = ad7606_scan_el_attr_is_visible,
-};
-
-int ad7606_scan_from_ring(struct ad7606_state *st, unsigned ch)
-{
-       struct iio_ring_buffer *ring = st->indio_dev->ring;
+       struct iio_ring_buffer *ring = indio_dev->ring;
        int ret;
        u16 *ring_data;
 
-       ring_data = kmalloc(ring->access.get_bytes_per_datum(ring), GFP_KERNEL);
+       ring_data = kmalloc(ring->access->get_bytes_per_datum(ring),
+                           GFP_KERNEL);
        if (ring_data == NULL) {
                ret = -ENOMEM;
                goto error_ret;
        }
-       ret = ring->access.read_last(ring, (u8 *) ring_data);
+       ret = ring->access->read_last(ring, (u8 *) ring_data);
        if (ret)
                goto error_free_ring_data;
 
@@ -134,12 +53,12 @@ error_ret:
  **/
 static int ad7606_ring_preenable(struct iio_dev *indio_dev)
 {
-       struct ad7606_state *st = indio_dev->dev_data;
+       struct ad7606_state *st = iio_priv(indio_dev);
        struct iio_ring_buffer *ring = indio_dev->ring;
        size_t d_size;
 
        d_size = st->chip_info->num_channels *
-                st->chip_info->bits / 8;
+                st->chip_info->channels[0].scan_type.storagebits / 8;
 
        if (ring->scan_timestamp) {
                d_size += sizeof(s64);
@@ -148,8 +67,8 @@ static int ad7606_ring_preenable(struct iio_dev *indio_dev)
                        d_size += sizeof(s64) - (d_size % sizeof(s64));
        }
 
-       if (ring->access.set_bytes_per_datum)
-               ring->access.set_bytes_per_datum(ring, d_size);
+       if (ring->access->set_bytes_per_datum)
+               ring->access->set_bytes_per_datum(ring, d_size);
 
        st->d_size = d_size;
 
@@ -157,16 +76,20 @@ static int ad7606_ring_preenable(struct iio_dev *indio_dev)
 }
 
 /**
- * ad7606_poll_func_th() th of trigger launched polling to ring buffer
+ * ad7606_trigger_handler_th() th/bh of trigger launched polling to ring buffer
  *
  **/
-static void ad7606_poll_func_th(struct iio_dev *indio_dev, s64 time)
+static irqreturn_t ad7606_trigger_handler_th_bh(int irq, void *p)
 {
-       struct ad7606_state *st = indio_dev->dev_data;
+       struct iio_poll_func *pf = p;
+       struct iio_dev *indio_dev = pf->private_data;
+       struct ad7606_state *st = iio_priv(indio_dev);
+
        gpio_set_value(st->pdata->gpio_convst, 1);
 
-       return;
+       return IRQ_HANDLED;
 }
+
 /**
  * ad7606_poll_bh_to_ring() bh of trigger launched polling to ring buffer
  * @work_s:    the work struct through which this was scheduled
@@ -180,17 +103,12 @@ static void ad7606_poll_bh_to_ring(struct work_struct *work_s)
 {
        struct ad7606_state *st = container_of(work_s, struct ad7606_state,
                                                poll_work);
-       struct iio_dev *indio_dev = st->indio_dev;
-       struct iio_sw_ring_buffer *sw_ring = iio_to_sw_ring(indio_dev->ring);
+       struct iio_dev *indio_dev = iio_priv_to_dev(st);
        struct iio_ring_buffer *ring = indio_dev->ring;
        s64 time_ns;
        __u8 *buf;
        int ret;
 
-       /* Ensure only one copy of this function running at a time */
-       if (atomic_inc_return(&st->protect_ring) > 1)
-               return;
-
        buf = kzalloc(st->d_size, GFP_KERNEL);
        if (buf == NULL)
                return;
@@ -225,16 +143,22 @@ static void ad7606_poll_bh_to_ring(struct work_struct *work_s)
                memcpy(buf + st->d_size - sizeof(s64),
                        &time_ns, sizeof(time_ns));
 
-       ring->access.store_to(&sw_ring->buf, buf, time_ns);
+       ring->access->store_to(indio_dev->ring, buf, time_ns);
 done:
        gpio_set_value(st->pdata->gpio_convst, 0);
+       iio_trigger_notify_done(indio_dev->trig);
        kfree(buf);
-       atomic_dec(&st->protect_ring);
 }
 
+static const struct iio_ring_setup_ops ad7606_ring_setup_ops = {
+       .preenable = &ad7606_ring_preenable,
+       .postenable = &iio_triggered_ring_postenable,
+       .predisable = &iio_triggered_ring_predisable,
+};
+
 int ad7606_register_ring_funcs_and_init(struct iio_dev *indio_dev)
 {
-       struct ad7606_state *st = indio_dev->dev_data;
+       struct ad7606_state *st = iio_priv(indio_dev);
        int ret;
 
        indio_dev->ring = iio_sw_rb_allocate(indio_dev);
@@ -244,17 +168,22 @@ int ad7606_register_ring_funcs_and_init(struct iio_dev *indio_dev)
        }
 
        /* Effectively select the ring buffer implementation */
-       iio_ring_sw_register_funcs(&indio_dev->ring->access);
-       ret = iio_alloc_pollfunc(indio_dev, NULL, &ad7606_poll_func_th);
-       if (ret)
+       indio_dev->ring->access = &ring_sw_access_funcs;
+       indio_dev->pollfunc = iio_alloc_pollfunc(&ad7606_trigger_handler_th_bh,
+                                                &ad7606_trigger_handler_th_bh,
+                                                0,
+                                                indio_dev,
+                                                "%s_consumer%d",
+                                                indio_dev->name,
+                                                indio_dev->id);
+       if (indio_dev->pollfunc == NULL) {
+               ret = -ENOMEM;
                goto error_deallocate_sw_rb;
+       }
 
        /* Ring buffer functions - here trigger setup related */
 
-       indio_dev->ring->preenable = &ad7606_ring_preenable;
-       indio_dev->ring->postenable = &iio_triggered_ring_postenable;
-       indio_dev->ring->predisable = &iio_triggered_ring_predisable;
-       indio_dev->ring->scan_el_attrs = &ad7606_scan_el_group;
+       indio_dev->ring->setup_ops = &ad7606_ring_setup_ops;
        indio_dev->ring->scan_timestamp = true ;
 
        INIT_WORK(&st->poll_work, &ad7606_poll_bh_to_ring);
@@ -262,6 +191,7 @@ int ad7606_register_ring_funcs_and_init(struct iio_dev *indio_dev)
        /* Flag that polled ring buffering is possible */
        indio_dev->modes |= INDIO_RING_TRIGGERED;
        return 0;
+
 error_deallocate_sw_rb:
        iio_sw_rb_free(indio_dev->ring);
 error_ret:
@@ -275,6 +205,6 @@ void ad7606_ring_cleanup(struct iio_dev *indio_dev)
                iio_trigger_dettach_poll_func(indio_dev->trig,
                                              indio_dev->pollfunc);
        }
-       kfree(indio_dev->pollfunc);
+       iio_dealloc_pollfunc(indio_dev->pollfunc);
        iio_sw_rb_free(indio_dev->ring);
 }
index d738491222f210c87d19783c737ff414902b1da6..0769c807d95f39e735ce30900433e37aca4e3801 100644 (file)
@@ -10,6 +10,8 @@
 #include <linux/spi/spi.h>
 #include <linux/types.h>
 #include <linux/err.h>
+
+#include "../iio.h"
 #include "ad7606.h"
 
 #define MAX_SPI_FREQ_HZ                23500000        /* VDRIVE above 4.75 V */
@@ -39,42 +41,42 @@ static const struct ad7606_bus_ops ad7606_spi_bops = {
 
 static int __devinit ad7606_spi_probe(struct spi_device *spi)
 {
-       struct ad7606_state *st;
+       struct iio_dev *indio_dev;
 
-       st = ad7606_probe(&spi->dev, spi->irq, NULL,
+       indio_dev = ad7606_probe(&spi->dev, spi->irq, NULL,
                           spi_get_device_id(spi)->driver_data,
                           &ad7606_spi_bops);
 
-       if (IS_ERR(st))
-               return PTR_ERR(st);
+       if (IS_ERR(indio_dev))
+               return PTR_ERR(indio_dev);
 
-       spi_set_drvdata(spi, st);
+       spi_set_drvdata(spi, indio_dev);
 
        return 0;
 }
 
 static int __devexit ad7606_spi_remove(struct spi_device *spi)
 {
-       struct ad7606_state *st = dev_get_drvdata(&spi->dev);
+       struct iio_dev *indio_dev = dev_get_drvdata(&spi->dev);
 
-       return ad7606_remove(st);
+       return ad7606_remove(indio_dev);
 }
 
 #ifdef CONFIG_PM
 static int ad7606_spi_suspend(struct device *dev)
 {
-       struct ad7606_state *st = dev_get_drvdata(dev);
+       struct iio_dev *indio_dev = dev_get_drvdata(dev);
 
-       ad7606_suspend(st);
+       ad7606_suspend(indio_dev);
 
        return 0;
 }
 
 static int ad7606_spi_resume(struct device *dev)
 {
-       struct ad7606_state *st = dev_get_drvdata(dev);
+       struct iio_dev *indio_dev = dev_get_drvdata(dev);
 
-       ad7606_resume(st);
+       ad7606_resume(indio_dev);
 
        return 0;
 }
index ab7ef8450ae2104bd1187dbadbcf68a01d4eddf8..1944223ef163824da530cc7ab42e3d0a618c3330 100644 (file)
@@ -8,14 +8,12 @@
 
 #include <linux/interrupt.h>
 #include <linux/gpio.h>
-#include <linux/workqueue.h>
 #include <linux/device.h>
 #include <linux/kernel.h>
 #include <linux/slab.h>
 #include <linux/sysfs.h>
 #include <linux/list.h>
 #include <linux/i2c.h>
-#include <linux/rtc.h>
 
 #include "../iio.h"
 #include "../sysfs.h"
  */
 
 struct ad774x_chip_info {
-       const char *name;
        struct i2c_client *client;
        struct iio_dev *indio_dev;
-       struct work_struct thresh_work;
        bool inter;
-       s64 last_timestamp;
        u16 cap_offs;                   /* Capacitive offset */
        u16 cap_gain;                   /* Capacitive gain calibration */
        u16 volt_gain;                  /* Voltage gain calibration */
@@ -76,7 +71,8 @@ struct ad774x_conversion_mode {
        u8 reg_cfg;
 };
 
-struct ad774x_conversion_mode ad774x_conv_mode_table[AD774X_MAX_CONV_MODE] = {
+static struct ad774x_conversion_mode
+ad774x_conv_mode_table[AD774X_MAX_CONV_MODE] = {
        { "idle", 0 },
        { "continuous-conversion", 1 },
        { "single-conversion", 2 },
@@ -502,17 +498,6 @@ static IIO_DEV_ATTR_CAP_GAIN(S_IRUGO | S_IWUSR,
                ad774x_show_cap_gain,
                ad774x_store_cap_gain);
 
-static ssize_t ad774x_show_name(struct device *dev,
-               struct device_attribute *attr,
-               char *buf)
-{
-       struct iio_dev *dev_info = dev_get_drvdata(dev);
-       struct ad774x_chip_info *chip = dev_info->dev_data;
-       return sprintf(buf, "%s\n", chip->name);
-}
-
-static IIO_DEVICE_ATTR(name, S_IRUGO, ad774x_show_name, NULL, 0);
-
 static struct attribute *ad774x_attributes[] = {
        &iio_dev_attr_available_conversion_modes.dev_attr.attr,
        &iio_dev_attr_conversion_mode.dev_attr.attr,
@@ -526,7 +511,6 @@ static struct attribute *ad774x_attributes[] = {
        &iio_dev_attr_cap0_raw.dev_attr.attr,
        &iio_dev_attr_capdac0_raw.dev_attr.attr,
        &iio_dev_attr_capdac1_raw.dev_attr.attr,
-       &iio_dev_attr_name.dev_attr.attr,
        NULL,
 };
 
@@ -538,8 +522,8 @@ static const struct attribute_group ad774x_attribute_group = {
  * data ready events
  */
 
-#define IIO_EVENT_CODE_CAP_RDY     IIO_BUFFER_EVENT_CODE(0)
-#define IIO_EVENT_CODE_VT_RDY      IIO_BUFFER_EVENT_CODE(1)
+#define IIO_EVENT_CODE_CAP_RDY     0
+#define IIO_EVENT_CODE_VT_RDY      1
 
 #define IIO_EVENT_ATTR_CAP_RDY_SH(_evlist, _show, _store, _mask)       \
        IIO_EVENT_ATTR_SH(cap_rdy, _evlist, _show, _store, _mask)
@@ -547,67 +531,33 @@ static const struct attribute_group ad774x_attribute_group = {
 #define IIO_EVENT_ATTR_VT_RDY_SH(_evlist, _show, _store, _mask)        \
        IIO_EVENT_ATTR_SH(vt_rdy, _evlist, _show, _store, _mask)
 
-static void ad774x_interrupt_handler_bh(struct work_struct *work_s)
+static irqreturn_t ad774x_event_handler(int irq, void *private)
 {
-       struct ad774x_chip_info *chip =
-               container_of(work_s, struct ad774x_chip_info, thresh_work);
+       struct iio_dev *indio_dev = private;
+       struct ad774x_chip_info *chip = iio_dev_get_devdata(indio_dev);
        u8 int_status;
 
-       enable_irq(chip->client->irq);
-
        ad774x_i2c_read(chip, AD774X_STATUS, &int_status, 1);
 
        if (int_status & AD774X_STATUS_RDYCAP)
-               iio_push_event(chip->indio_dev, 0,
-                               IIO_EVENT_CODE_CAP_RDY,
-                               chip->last_timestamp);
+               iio_push_event(indio_dev, 0,
+                              IIO_EVENT_CODE_CAP_RDY,
+                              iio_get_time_ns());
 
        if (int_status & AD774X_STATUS_RDYVT)
-               iio_push_event(chip->indio_dev, 0,
-                               IIO_EVENT_CODE_VT_RDY,
-                               chip->last_timestamp);
-}
-
-static int ad774x_interrupt_handler_th(struct iio_dev *dev_info,
-               int index,
-               s64 timestamp,
-               int no_test)
-{
-       struct ad774x_chip_info *chip = dev_info->dev_data;
-
-       chip->last_timestamp = timestamp;
-       schedule_work(&chip->thresh_work);
+               iio_push_event(indio_dev, 0,
+                              IIO_EVENT_CODE_VT_RDY,
+                              iio_get_time_ns());
 
-       return 0;
+       return IRQ_HANDLED;
 }
 
-IIO_EVENT_SH(data_rdy, &ad774x_interrupt_handler_th);
-
-static ssize_t ad774x_query_out_mode(struct device *dev,
-               struct device_attribute *attr,
-               char *buf)
-{
-       /*
-        * AD774X provides one /RDY pin, which can be used as interrupt
-        * but the pin is not configurable
-        */
-       return sprintf(buf, "1\n");
-}
-
-static ssize_t ad774x_set_out_mode(struct device *dev,
-               struct device_attribute *attr,
-               const char *buf,
-               size_t len)
-{
-       return len;
-}
-
-IIO_EVENT_ATTR_CAP_RDY_SH(iio_event_data_rdy, ad774x_query_out_mode, ad774x_set_out_mode, 0);
-IIO_EVENT_ATTR_VT_RDY_SH(iio_event_data_rdy, ad774x_query_out_mode, ad774x_set_out_mode, 0);
+static IIO_CONST_ATTR(cap_rdy_en, "1");
+static IIO_CONST_ATTR(vt_rdy_en, "1");
 
 static struct attribute *ad774x_event_attributes[] = {
-       &iio_event_attr_cap_rdy.dev_attr.attr,
-       &iio_event_attr_vt_rdy.dev_attr.attr,
+       &iio_const_attr_cap_rdy_en.dev_attr.attr,
+       &iio_const_attr_vt_rdy_en.dev_attr.attr,
        NULL,
 };
 
@@ -615,6 +565,12 @@ static struct attribute_group ad774x_event_attribute_group = {
        .attrs = ad774x_event_attributes,
 };
 
+static const struct iio_info ad774x_info = {
+       .attrs = &ad774x_event_attribute_group,
+       .event_attrs = &ad774x_event_attribute_group,
+       .num_interrupt_lines = 1,
+       .driver_module = THIS_MODULE,
+};
 /*
  * device probe and remove
  */
@@ -633,21 +589,18 @@ static int __devinit ad774x_probe(struct i2c_client *client,
        i2c_set_clientdata(client, chip);
 
        chip->client = client;
-       chip->name = id->name;
 
-       chip->indio_dev = iio_allocate_device();
+       chip->indio_dev = iio_allocate_device(0);
        if (chip->indio_dev == NULL) {
                ret = -ENOMEM;
                goto error_free_chip;
        }
 
        /* Establish that the iio_dev is a child of the i2c device */
+       chip->indio_dev->name = id->name;
        chip->indio_dev->dev.parent = &client->dev;
-       chip->indio_dev->attrs = &ad774x_attribute_group;
-       chip->indio_dev->event_attrs = &ad774x_event_attribute_group;
+       chip->indio_dev->info = &ad774x_info;
        chip->indio_dev->dev_data = (void *)(chip);
-       chip->indio_dev->driver_module = THIS_MODULE;
-       chip->indio_dev->num_interrupt_lines = 1;
        chip->indio_dev->modes = INDIO_DIRECT_MODE;
 
        ret = iio_device_register(chip->indio_dev);
@@ -656,18 +609,14 @@ static int __devinit ad774x_probe(struct i2c_client *client,
        regdone = 1;
 
        if (client->irq) {
-               ret = iio_register_interrupt_line(client->irq,
-                               chip->indio_dev,
-                               0,
-                               IRQF_TRIGGER_FALLING,
-                               "ad774x");
+               ret = request_threaded_irq(client->irq,
+                                          NULL,
+                                          &ad774x_event_handler,
+                                          IRQF_TRIGGER_FALLING,
+                                          "ad774x",
+                                          chip->indio_dev);
                if (ret)
                        goto error_free_dev;
-
-               iio_add_event_to_list(iio_event_attr_cap_rdy.listel,
-                               &chip->indio_dev->interrupts[0]->ev_list);
-
-               INIT_WORK(&chip->thresh_work, ad774x_interrupt_handler_bh);
        }
 
        dev_err(&client->dev, "%s capacitive sensor registered, irq: %d\n", id->name, client->irq);
@@ -676,7 +625,7 @@ static int __devinit ad774x_probe(struct i2c_client *client,
 
 error_free_dev:
        if (regdone)
-               iio_device_unregister(chip->indio_dev);
+               free_irq(client->irq, chip->indio_dev);
        else
                iio_free_device(chip->indio_dev);
 error_free_chip:
@@ -691,7 +640,7 @@ static int __devexit ad774x_remove(struct i2c_client *client)
        struct iio_dev *indio_dev = chip->indio_dev;
 
        if (client->irq)
-               iio_unregister_interrupt_line(indio_dev, 0);
+               free_irq(client->irq, indio_dev);
        iio_device_unregister(indio_dev);
        kfree(chip);
 
diff --git a/drivers/staging/iio/adc/ad7780.c b/drivers/staging/iio/adc/ad7780.c
new file mode 100644 (file)
index 0000000..e0c7b6c
--- /dev/null
@@ -0,0 +1,301 @@
+/*
+ * AD7780/AD7781 SPI ADC driver
+ *
+ * Copyright 2011 Analog Devices Inc.
+ *
+ * Licensed under the GPL-2.
+ */
+
+#include <linux/interrupt.h>
+#include <linux/device.h>
+#include <linux/kernel.h>
+#include <linux/slab.h>
+#include <linux/sysfs.h>
+#include <linux/spi/spi.h>
+#include <linux/regulator/consumer.h>
+#include <linux/err.h>
+#include <linux/sched.h>
+#include <linux/gpio.h>
+
+#include "../iio.h"
+#include "../sysfs.h"
+#include "../ring_generic.h"
+#include "adc.h"
+
+#include "ad7780.h"
+
+#define AD7780_RDY     (1 << 7)
+#define AD7780_FILTER  (1 << 6)
+#define AD7780_ERR     (1 << 5)
+#define AD7780_ID1     (1 << 4)
+#define AD7780_ID0     (1 << 3)
+#define AD7780_GAIN    (1 << 2)
+#define AD7780_PAT1    (1 << 1)
+#define AD7780_PAT0    (1 << 0)
+
+struct ad7780_chip_info {
+       struct iio_chan_spec            channel;
+};
+
+struct ad7780_state {
+       struct spi_device               *spi;
+       const struct ad7780_chip_info   *chip_info;
+       struct regulator                *reg;
+       struct ad7780_platform_data     *pdata;
+       wait_queue_head_t               wq_data_avail;
+       bool                            done;
+       u16                             int_vref_mv;
+       struct spi_transfer             xfer;
+       struct spi_message              msg;
+       /*
+        * DMA (thus cache coherency maintenance) requires the
+        * transfer buffers to live in their own cache lines.
+        */
+       unsigned int                    data ____cacheline_aligned;
+};
+
+enum ad7780_supported_device_ids {
+       ID_AD7780,
+       ID_AD7781,
+};
+
+static int ad7780_read(struct ad7780_state *st, int *val)
+{
+       int ret;
+
+       spi_bus_lock(st->spi->master);
+
+       enable_irq(st->spi->irq);
+       st->done = false;
+       gpio_set_value(st->pdata->gpio_pdrst, 1);
+
+       ret = wait_event_interruptible(st->wq_data_avail, st->done);
+       disable_irq_nosync(st->spi->irq);
+       if (ret)
+               goto out;
+
+       ret = spi_sync_locked(st->spi, &st->msg);
+       *val = be32_to_cpu(st->data);
+out:
+       gpio_set_value(st->pdata->gpio_pdrst, 0);
+       spi_bus_unlock(st->spi->master);
+
+       return ret;
+}
+
+static int ad7780_read_raw(struct iio_dev *indio_dev,
+                          struct iio_chan_spec const *chan,
+                          int *val,
+                          int *val2,
+                          long m)
+{
+       struct ad7780_state *st = iio_priv(indio_dev);
+       struct iio_chan_spec channel = st->chip_info->channel;
+       int ret, smpl = 0;
+       unsigned long scale_uv;
+
+       switch (m) {
+       case 0:
+               mutex_lock(&indio_dev->mlock);
+               ret = ad7780_read(st, &smpl);
+               mutex_unlock(&indio_dev->mlock);
+
+               if (ret < 0)
+                       return ret;
+
+               if ((smpl & AD7780_ERR) ||
+                       !((smpl & AD7780_PAT0) && !(smpl & AD7780_PAT1)))
+                       return -EIO;
+
+               *val = (smpl >> channel.scan_type.shift) &
+                       ((1 << (channel.scan_type.realbits)) - 1);
+               *val -= (1 << (channel.scan_type.realbits - 1));
+
+               if (!(smpl & AD7780_GAIN))
+                       *val *= 128;
+
+               return IIO_VAL_INT;
+       case (1 << IIO_CHAN_INFO_SCALE_SHARED):
+               scale_uv = (st->int_vref_mv * 100000)
+                       >> (channel.scan_type.realbits - 1);
+               *val =  scale_uv / 100000;
+               *val2 = (scale_uv % 100000) * 10;
+               return IIO_VAL_INT_PLUS_MICRO;
+       }
+       return -EINVAL;
+}
+
+static const struct ad7780_chip_info ad7780_chip_info_tbl[] = {
+       [ID_AD7780] = {
+               .channel = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 0, 0,
+                                   (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                                   0, 0, IIO_ST('s', 24, 32, 8), 0),
+       },
+       [ID_AD7781] = {
+               .channel = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 0, 0,
+                                   (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                                   0, 0, IIO_ST('s', 20, 32, 12), 0),
+       },
+};
+
+/**
+ *  Interrupt handler
+ */
+static irqreturn_t ad7780_interrupt(int irq, void *dev_id)
+{
+       struct ad7780_state *st = dev_id;
+
+       st->done = true;
+       wake_up_interruptible(&st->wq_data_avail);
+
+       return IRQ_HANDLED;
+};
+
+static const struct iio_info ad7780_info = {
+       .read_raw = &ad7780_read_raw,
+       .driver_module = THIS_MODULE,
+};
+
+static int __devinit ad7780_probe(struct spi_device *spi)
+{
+       struct ad7780_platform_data *pdata = spi->dev.platform_data;
+       struct ad7780_state *st;
+       struct iio_dev *indio_dev;
+       int ret, voltage_uv = 0;
+
+       if (!pdata) {
+               dev_dbg(&spi->dev, "no platform data?\n");
+               return -ENODEV;
+       }
+
+       indio_dev = iio_allocate_device(sizeof(*st));
+       if (indio_dev == NULL)
+               return -ENOMEM;
+
+       st = iio_priv(indio_dev);
+
+       st->reg = regulator_get(&spi->dev, "vcc");
+       if (!IS_ERR(st->reg)) {
+               ret = regulator_enable(st->reg);
+               if (ret)
+                       goto error_put_reg;
+
+               voltage_uv = regulator_get_voltage(st->reg);
+       }
+
+       st->chip_info =
+               &ad7780_chip_info_tbl[spi_get_device_id(spi)->driver_data];
+
+       st->pdata = pdata;
+
+       if (pdata && pdata->vref_mv)
+               st->int_vref_mv = pdata->vref_mv;
+       else if (voltage_uv)
+               st->int_vref_mv = voltage_uv / 1000;
+       else
+               dev_warn(&spi->dev, "reference voltage unspecified\n");
+
+       spi_set_drvdata(spi, indio_dev);
+       st->spi = spi;
+
+       indio_dev->dev.parent = &spi->dev;
+       indio_dev->name = spi_get_device_id(spi)->name;
+       indio_dev->modes = INDIO_DIRECT_MODE;
+       indio_dev->channels = &st->chip_info->channel;
+       indio_dev->num_channels = 1;
+       indio_dev->info = &ad7780_info;
+
+       init_waitqueue_head(&st->wq_data_avail);
+
+       /* Setup default message */
+
+       st->xfer.rx_buf = &st->data;
+       st->xfer.len = st->chip_info->channel.scan_type.storagebits / 8;
+
+       spi_message_init(&st->msg);
+       spi_message_add_tail(&st->xfer, &st->msg);
+
+       ret = gpio_request_one(st->pdata->gpio_pdrst, GPIOF_OUT_INIT_LOW,
+                              "AD7780 /PDRST");
+       if (ret) {
+               dev_err(&spi->dev, "failed to request GPIO PDRST\n");
+               goto error_disable_reg;
+       }
+
+       ret = request_irq(spi->irq, ad7780_interrupt,
+               IRQF_TRIGGER_FALLING, spi_get_device_id(spi)->name, st);
+       if (ret)
+               goto error_free_gpio;
+
+       disable_irq(spi->irq);
+
+       ret = iio_device_register(indio_dev);
+       if (ret)
+               goto error_free_irq;
+
+       return 0;
+
+error_free_irq:
+       free_irq(spi->irq, st);
+error_free_gpio:
+       gpio_free(st->pdata->gpio_pdrst);
+error_disable_reg:
+       if (!IS_ERR(st->reg))
+               regulator_disable(st->reg);
+error_put_reg:
+       if (!IS_ERR(st->reg))
+               regulator_put(st->reg);
+
+       iio_free_device(indio_dev);
+
+       return ret;
+}
+
+static int ad7780_remove(struct spi_device *spi)
+{
+       struct iio_dev *indio_dev = spi_get_drvdata(spi);
+       struct ad7780_state *st = iio_priv(indio_dev);
+
+       free_irq(spi->irq, st);
+       gpio_free(st->pdata->gpio_pdrst);
+       if (!IS_ERR(st->reg)) {
+               regulator_disable(st->reg);
+               regulator_put(st->reg);
+       }
+       iio_device_unregister(indio_dev);
+
+       return 0;
+}
+
+static const struct spi_device_id ad7780_id[] = {
+       {"ad7780", ID_AD7780},
+       {"ad7781", ID_AD7781},
+       {}
+};
+
+static struct spi_driver ad7780_driver = {
+       .driver = {
+               .name   = "ad7780",
+               .bus    = &spi_bus_type,
+               .owner  = THIS_MODULE,
+       },
+       .probe          = ad7780_probe,
+       .remove         = __devexit_p(ad7780_remove),
+       .id_table       = ad7780_id,
+};
+
+static int __init ad7780_init(void)
+{
+       return spi_register_driver(&ad7780_driver);
+}
+module_init(ad7780_init);
+
+static void __exit ad7780_exit(void)
+{
+       spi_unregister_driver(&ad7780_driver);
+}
+module_exit(ad7780_exit);
+
+MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>");
+MODULE_DESCRIPTION("Analog Devices AD7780/1 ADC");
+MODULE_LICENSE("GPL v2");
diff --git a/drivers/staging/iio/adc/ad7780.h b/drivers/staging/iio/adc/ad7780.h
new file mode 100644 (file)
index 0000000..67e511c
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * AD7780/AD7781 SPI ADC driver
+ *
+ * Copyright 2011 Analog Devices Inc.
+ *
+ * Licensed under the GPL-2.
+ */
+#ifndef IIO_ADC_AD7780_H_
+#define IIO_ADC_AD7780_H_
+
+/*
+ * TODO: struct ad7780_platform_data needs to go into include/linux/iio
+ */
+
+/* NOTE:
+ * The AD7780 doesn't feature a dedicated SPI chip select, in addition it
+ * features a dual use data out ready DOUT/RDY output.
+ * In order to avoid contentions on the SPI bus, it's therefore necessary
+ * to use spi bus locking combined with a dedicated GPIO to control the
+ * power down reset signal of the AD7780.
+ *
+ * The DOUT/RDY output must also be wired to an interrupt capable GPIO.
+ */
+
+struct ad7780_platform_data {
+       u16                             vref_mv;
+       int                             gpio_pdrst;
+};
+
+#endif /* IIO_ADC_AD7780_H_ */
index ad7415a6b8d9f160fbd06e95d80b9549e3ccdbe8..11379e469b0787809300955b2ee3ccad50335860 100644 (file)
@@ -8,14 +8,12 @@
 
 #include <linux/interrupt.h>
 #include <linux/gpio.h>
-#include <linux/workqueue.h>
 #include <linux/device.h>
 #include <linux/kernel.h>
 #include <linux/slab.h>
 #include <linux/sysfs.h>
 #include <linux/list.h>
 #include <linux/spi/spi.h>
-#include <linux/rtc.h>
 
 #include "../iio.h"
 #include "../sysfs.h"
  */
 
 struct ad7816_chip_info {
-       const char *name;
        struct spi_device *spi_dev;
        struct iio_dev *indio_dev;
-       struct work_struct thresh_work;
-       s64 last_timestamp;
        u16 rdwr_pin;
        u16 convert_pin;
        u16 busy_pin;
@@ -185,13 +180,13 @@ static ssize_t ad7816_store_channel(struct device *dev,
 
        if (data > AD7816_CS_MAX && data != AD7816_CS_MASK) {
                dev_err(&chip->spi_dev->dev, "Invalid channel id %lu for %s.\n",
-                       data, chip->name);
+                       data, dev_info->name);
                return -EINVAL;
-       } else if (strcmp(chip->name, "ad7818") == 0 && data > 1) {
+       } else if (strcmp(dev_info->name, "ad7818") == 0 && data > 1) {
                dev_err(&chip->spi_dev->dev,
                        "Invalid channel id %lu for ad7818.\n", data);
                return -EINVAL;
-       } else if (strcmp(chip->name, "ad7816") == 0 && data > 0) {
+       } else if (strcmp(dev_info->name, "ad7816") == 0 && data > 0) {
                dev_err(&chip->spi_dev->dev,
                        "Invalid channel id %lu for ad7816.\n", data);
                return -EINVAL;
@@ -236,23 +231,11 @@ static ssize_t ad7816_show_value(struct device *dev,
 
 static IIO_DEVICE_ATTR(value, S_IRUGO, ad7816_show_value, NULL, 0);
 
-static ssize_t ad7816_show_name(struct device *dev,
-               struct device_attribute *attr,
-               char *buf)
-{
-       struct iio_dev *dev_info = dev_get_drvdata(dev);
-       struct ad7816_chip_info *chip = dev_info->dev_data;
-       return sprintf(buf, "%s\n", chip->name);
-}
-
-static IIO_DEVICE_ATTR(name, S_IRUGO, ad7816_show_name, NULL, 0);
-
 static struct attribute *ad7816_attributes[] = {
        &iio_dev_attr_available_modes.dev_attr.attr,
        &iio_dev_attr_mode.dev_attr.attr,
        &iio_dev_attr_channel.dev_attr.attr,
        &iio_dev_attr_value.dev_attr.attr,
-       &iio_dev_attr_name.dev_attr.attr,
        NULL,
 };
 
@@ -264,35 +247,19 @@ static const struct attribute_group ad7816_attribute_group = {
  * temperature bound events
  */
 
-#define IIO_EVENT_CODE_AD7816_OTI    IIO_BUFFER_EVENT_CODE(0)
+#define IIO_EVENT_CODE_AD7816_OTI IIO_UNMOD_EVENT_CODE(IIO_EV_CLASS_TEMP, \
+                                                      0,               \
+                                                      IIO_EV_TYPE_THRESH, \
+                                                      IIO_EV_DIR_FALLING)
 
-static void ad7816_interrupt_bh(struct work_struct *work_s)
+static irqreturn_t ad7816_event_handler(int irq, void *private)
 {
-       struct ad7816_chip_info *chip =
-               container_of(work_s, struct ad7816_chip_info, thresh_work);
-
-       enable_irq(chip->spi_dev->irq);
-
-       iio_push_event(chip->indio_dev, 0,
-                       IIO_EVENT_CODE_AD7816_OTI,
-                       chip->last_timestamp);
+       iio_push_event(private, 0,
+                      IIO_EVENT_CODE_AD7816_OTI,
+                      iio_get_time_ns());
+       return IRQ_HANDLED;
 }
 
-static int ad7816_interrupt(struct iio_dev *dev_info,
-               int index,
-               s64 timestamp,
-               int no_test)
-{
-       struct ad7816_chip_info *chip = dev_info->dev_data;
-
-       chip->last_timestamp = timestamp;
-       schedule_work(&chip->thresh_work);
-
-       return 0;
-}
-
-IIO_EVENT_SH(ad7816, &ad7816_interrupt);
-
 static ssize_t ad7816_show_oti(struct device *dev,
                struct device_attribute *attr,
                char *buf)
@@ -352,11 +319,11 @@ static inline ssize_t ad7816_set_oti(struct device *dev,
        return len;
 }
 
-IIO_EVENT_ATTR_SH(oti, iio_event_ad7816,
-               ad7816_show_oti, ad7816_set_oti, 0);
+static IIO_DEVICE_ATTR(oti, S_IRUGO | S_IWUSR,
+                      ad7816_show_oti, ad7816_set_oti, 0);
 
 static struct attribute *ad7816_event_attributes[] = {
-       &iio_event_attr_oti.dev_attr.attr,
+       &iio_dev_attr_oti.dev_attr.attr,
        NULL,
 };
 
@@ -364,6 +331,13 @@ static struct attribute_group ad7816_event_attribute_group = {
        .attrs = ad7816_event_attributes,
 };
 
+static const struct iio_info ad7816_info = {
+       .attrs = &ad7816_attribute_group,
+       .num_interrupt_lines = 1,
+       .event_attrs = &ad7816_event_attribute_group,
+       .driver_module = THIS_MODULE,
+};
+
 /*
  * device probe and remove
  */
@@ -389,28 +363,27 @@ static int __devinit ad7816_probe(struct spi_device *spi_dev)
        dev_set_drvdata(&spi_dev->dev, chip);
 
        chip->spi_dev = spi_dev;
-       chip->name = spi_dev->modalias;
        for (i = 0; i <= AD7816_CS_MAX; i++)
                chip->oti_data[i] = 203;
        chip->rdwr_pin = pins[0];
        chip->convert_pin = pins[1];
        chip->busy_pin = pins[2];
 
-       ret = gpio_request(chip->rdwr_pin, chip->name);
+       ret = gpio_request(chip->rdwr_pin, spi_get_device_id(spi_dev)->name);
        if (ret) {
                dev_err(&spi_dev->dev, "Fail to request rdwr gpio PIN %d.\n",
                        chip->rdwr_pin);
                goto error_free_chip;
        }
        gpio_direction_input(chip->rdwr_pin);
-       ret = gpio_request(chip->convert_pin, chip->name);
+       ret = gpio_request(chip->convert_pin, spi_get_device_id(spi_dev)->name);
        if (ret) {
                dev_err(&spi_dev->dev, "Fail to request convert gpio PIN %d.\n",
                        chip->convert_pin);
                goto error_free_gpio_rdwr;
        }
        gpio_direction_input(chip->convert_pin);
-       ret = gpio_request(chip->busy_pin, chip->name);
+       ret = gpio_request(chip->busy_pin, spi_get_device_id(spi_dev)->name);
        if (ret) {
                dev_err(&spi_dev->dev, "Fail to request busy gpio PIN %d.\n",
                        chip->busy_pin);
@@ -418,18 +391,15 @@ static int __devinit ad7816_probe(struct spi_device *spi_dev)
        }
        gpio_direction_input(chip->busy_pin);
 
-       chip->indio_dev = iio_allocate_device();
+       chip->indio_dev = iio_allocate_device(0);
        if (chip->indio_dev == NULL) {
                ret = -ENOMEM;
                goto error_free_gpio;
        }
-
+       chip->indio_dev->name = spi_get_device_id(spi_dev)->name;
        chip->indio_dev->dev.parent = &spi_dev->dev;
-       chip->indio_dev->attrs = &ad7816_attribute_group;
-       chip->indio_dev->event_attrs = &ad7816_event_attribute_group;
+       chip->indio_dev->info = &ad7816_info;
        chip->indio_dev->dev_data = (void *)chip;
-       chip->indio_dev->driver_module = THIS_MODULE;
-       chip->indio_dev->num_interrupt_lines = 1;
        chip->indio_dev->modes = INDIO_DIRECT_MODE;
 
        ret = iio_device_register(chip->indio_dev);
@@ -438,27 +408,18 @@ static int __devinit ad7816_probe(struct spi_device *spi_dev)
 
        if (spi_dev->irq) {
                /* Only low trigger is supported in ad7816/7/8 */
-               ret = iio_register_interrupt_line(spi_dev->irq,
-                               chip->indio_dev,
-                               0,
-                               IRQF_TRIGGER_LOW,
-                               chip->name);
+               ret = request_threaded_irq(spi_dev->irq,
+                                          NULL,
+                                          &ad7816_event_handler,
+                                          IRQF_TRIGGER_LOW,
+                                          chip->indio_dev->name,
+                                          chip->indio_dev);
                if (ret)
                        goto error_unreg_dev;
-
-               /*
-                * The event handler list element refer to iio_event_ad7816.
-                * All event attributes bind to the same event handler.
-                * So, only register event handler once.
-                */
-               iio_add_event_to_list(&iio_event_ad7816,
-                               &chip->indio_dev->interrupts[0]->ev_list);
-
-               INIT_WORK(&chip->thresh_work, ad7816_interrupt_bh);
        }
 
        dev_info(&spi_dev->dev, "%s temperature sensor and ADC registered.\n",
-                        chip->name);
+                        chip->indio_dev->name);
 
        return 0;
 
@@ -485,7 +446,7 @@ static int __devexit ad7816_remove(struct spi_device *spi_dev)
 
        dev_set_drvdata(&spi_dev->dev, NULL);
        if (spi_dev->irq)
-               iio_unregister_interrupt_line(indio_dev, 0);
+               free_irq(spi_dev->irq, indio_dev);
        iio_device_unregister(indio_dev);
        iio_free_device(chip->indio_dev);
        gpio_free(chip->busy_pin);
index 439c802b38f226e2b811e86295d2f80a841348bd..837046c7b894f54db1e11c963db45dd487af2c73 100644 (file)
@@ -48,24 +48,23 @@ struct ad7887_platform_data {
        bool                            use_onchip_ref;
 };
 
+/**
+ * struct ad7887_chip_info - chip specifc information
+ * @int_vref_mv:       the internal reference voltage
+ * @channel:           channel specification
+ */
+
 struct ad7887_chip_info {
-       u8                              bits;           /* number of ADC bits */
-       u8                              storagebits;    /* number of bits read from the ADC */
-       u8                              left_shift;     /* number of bits the sample must be shifted */
-       char                            sign;           /* [s]igned or [u]nsigned */
-       u16                             int_vref_mv;    /* internal reference voltage */
+       u16                             int_vref_mv;
+       struct iio_chan_spec            channel[3];
 };
 
 struct ad7887_state {
-       struct iio_dev                  *indio_dev;
        struct spi_device               *spi;
        const struct ad7887_chip_info   *chip_info;
        struct regulator                *reg;
-       struct work_struct              poll_work;
-       atomic_t                        protect_ring;
        size_t                          d_size;
        u16                             int_vref_mv;
-       bool                            en_dual;
        struct spi_transfer             xfer[4];
        struct spi_message              msg[3];
        struct spi_message              *ring_msg;
index 5d85efab658cfbac69fb8b3d055f89e7ec88740a..de14b174cef7166a9dc5883985e176ebd78521b7 100644 (file)
@@ -1,18 +1,15 @@
 /*
  * AD7887 SPI ADC driver
  *
- * Copyright 2010 Analog Devices Inc.
+ * Copyright 2010-2011 Analog Devices Inc.
  *
- * Licensed under the GPL-2 or later.
+ * Licensed under the GPL-2.
  */
 
-#include <linux/interrupt.h>
-#include <linux/workqueue.h>
 #include <linux/device.h>
 #include <linux/kernel.h>
 #include <linux/slab.h>
 #include <linux/sysfs.h>
-#include <linux/list.h>
 #include <linux/spi/spi.h>
 #include <linux/regulator/consumer.h>
 #include <linux/err.h>
@@ -33,108 +30,75 @@ static int ad7887_scan_direct(struct ad7887_state *st, unsigned ch)
        return (st->data[(ch * 2)] << 8) | st->data[(ch * 2) + 1];
 }
 
-static ssize_t ad7887_scan(struct device *dev,
-                           struct device_attribute *attr,
-                           char *buf)
+static int ad7887_read_raw(struct iio_dev *dev_info,
+                          struct iio_chan_spec const *chan,
+                          int *val,
+                          int *val2,
+                          long m)
 {
-       struct iio_dev *dev_info = dev_get_drvdata(dev);
-       struct ad7887_state *st = dev_info->dev_data;
-       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
        int ret;
+       struct ad7887_state *st = dev_info->dev_data;
+       unsigned int scale_uv;
 
-       mutex_lock(&dev_info->mlock);
-       if (iio_ring_enabled(dev_info))
-               ret = ad7887_scan_from_ring(st, 1 << this_attr->address);
-       else
-               ret = ad7887_scan_direct(st, this_attr->address);
-       mutex_unlock(&dev_info->mlock);
-
-       if (ret < 0)
-               return ret;
-
-       return sprintf(buf, "%d\n", (ret >> st->chip_info->left_shift) &
-                      RES_MASK(st->chip_info->bits));
-}
-static IIO_DEV_ATTR_IN_RAW(0, ad7887_scan, 0);
-static IIO_DEV_ATTR_IN_RAW(1, ad7887_scan, 1);
-
-static ssize_t ad7887_show_scale(struct device *dev,
-                               struct device_attribute *attr,
-                               char *buf)
-{
-       /* Driver currently only support internal vref */
-       struct iio_dev *dev_info = dev_get_drvdata(dev);
-       struct ad7887_state *st = iio_dev_get_devdata(dev_info);
-       /* Corresponds to Vref / 2^(bits) */
-       unsigned int scale_uv = (st->int_vref_mv * 1000) >> st->chip_info->bits;
-
-       return sprintf(buf, "%d.%03d\n", scale_uv / 1000, scale_uv % 1000);
-}
-static IIO_DEVICE_ATTR(in_scale, S_IRUGO, ad7887_show_scale, NULL, 0);
-
-static ssize_t ad7887_show_name(struct device *dev,
-                                struct device_attribute *attr,
-                                char *buf)
-{
-       struct iio_dev *dev_info = dev_get_drvdata(dev);
-       struct ad7887_state *st = iio_dev_get_devdata(dev_info);
-
-       return sprintf(buf, "%s\n", spi_get_device_id(st->spi)->name);
-}
-static IIO_DEVICE_ATTR(name, S_IRUGO, ad7887_show_name, NULL, 0);
-
-static struct attribute *ad7887_attributes[] = {
-       &iio_dev_attr_in0_raw.dev_attr.attr,
-       &iio_dev_attr_in1_raw.dev_attr.attr,
-       &iio_dev_attr_in_scale.dev_attr.attr,
-       &iio_dev_attr_name.dev_attr.attr,
-       NULL,
-};
-
-static mode_t ad7887_attr_is_visible(struct kobject *kobj,
-                                    struct attribute *attr, int n)
-{
-       struct device *dev = container_of(kobj, struct device, kobj);
-       struct iio_dev *dev_info = dev_get_drvdata(dev);
-       struct ad7887_state *st = iio_dev_get_devdata(dev_info);
-
-       mode_t mode = attr->mode;
-
-       if ((attr == &iio_dev_attr_in1_raw.dev_attr.attr) && !st->en_dual)
-                       mode = 0;
-
-       return mode;
+       switch (m) {
+       case 0:
+               mutex_lock(&dev_info->mlock);
+               if (iio_ring_enabled(dev_info))
+                       ret = ad7887_scan_from_ring(st, 1 << chan->address);
+               else
+                       ret = ad7887_scan_direct(st, chan->address);
+               mutex_unlock(&dev_info->mlock);
+
+               if (ret < 0)
+                       return ret;
+               *val = (ret >> st->chip_info->channel[0].scan_type.shift) &
+                       RES_MASK(st->chip_info->channel[0].scan_type.realbits);
+               return IIO_VAL_INT;
+       case (1 << IIO_CHAN_INFO_SCALE_SHARED):
+               scale_uv = (st->int_vref_mv * 1000)
+                       >> st->chip_info->channel[0].scan_type.realbits;
+               *val =  scale_uv/1000;
+               *val2 = (scale_uv%1000)*1000;
+               return IIO_VAL_INT_PLUS_MICRO;
+       }
+       return -EINVAL;
 }
 
-static const struct attribute_group ad7887_attribute_group = {
-       .attrs = ad7887_attributes,
-       .is_visible = ad7887_attr_is_visible,
-};
 
 static const struct ad7887_chip_info ad7887_chip_info_tbl[] = {
        /*
         * More devices added in future
         */
        [ID_AD7887] = {
-               .bits = 12,
-               .storagebits = 16,
-               .left_shift = 0,
-               .sign = IIO_SCAN_EL_TYPE_UNSIGNED,
+               .channel[0] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 1, 0,
+                                      (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                                      1, 1, IIO_ST('u', 12, 16, 0), 0),
+
+               .channel[1] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 0, 0,
+                                      (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                                      0, 0, IIO_ST('u', 12, 16, 0), 0),
+
+               .channel[2] = IIO_CHAN_SOFT_TIMESTAMP(2),
                .int_vref_mv = 2500,
        },
 };
 
+static const struct iio_info ad7887_info = {
+       .read_raw = &ad7887_read_raw,
+       .driver_module = THIS_MODULE,
+};
+
 static int __devinit ad7887_probe(struct spi_device *spi)
 {
        struct ad7887_platform_data *pdata = spi->dev.platform_data;
        struct ad7887_state *st;
-       int ret, voltage_uv = 0;
+       int ret, voltage_uv = 0, regdone = 0;
+       struct iio_dev *indio_dev = iio_allocate_device(sizeof(*st));
 
-       st = kzalloc(sizeof(*st), GFP_KERNEL);
-       if (st == NULL) {
-               ret = -ENOMEM;
-               goto error_ret;
-       }
+       if (indio_dev == NULL)
+               return -ENOMEM;
+
+       st = iio_priv(indio_dev);
 
        st->reg = regulator_get(&spi->dev, "vcc");
        if (!IS_ERR(st->reg)) {
@@ -148,23 +112,15 @@ static int __devinit ad7887_probe(struct spi_device *spi)
        st->chip_info =
                &ad7887_chip_info_tbl[spi_get_device_id(spi)->driver_data];
 
-       spi_set_drvdata(spi, st);
-
-       atomic_set(&st->protect_ring, 0);
+       spi_set_drvdata(spi, indio_dev);
        st->spi = spi;
 
-       st->indio_dev = iio_allocate_device();
-       if (st->indio_dev == NULL) {
-               ret = -ENOMEM;
-               goto error_disable_reg;
-       }
-
        /* Estabilish that the iio_dev is a child of the spi device */
-       st->indio_dev->dev.parent = &spi->dev;
-       st->indio_dev->attrs = &ad7887_attribute_group;
-       st->indio_dev->dev_data = (void *)(st);
-       st->indio_dev->driver_module = THIS_MODULE;
-       st->indio_dev->modes = INDIO_DIRECT_MODE;
+       indio_dev->dev.parent = &spi->dev;
+       indio_dev->name = spi_get_device_id(spi)->name;
+       indio_dev->dev_data = (void *)(st);
+       indio_dev->info = &ad7887_info;
+       indio_dev->modes = INDIO_DIRECT_MODE;
 
        /* Setup default message */
 
@@ -208,8 +164,6 @@ static int __devinit ad7887_probe(struct spi_device *spi)
                spi_message_init(&st->msg[AD7887_CH1]);
                spi_message_add_tail(&st->xfer[3], &st->msg[AD7887_CH1]);
 
-               st->en_dual = true;
-
                if (pdata && pdata->vref_mv)
                        st->int_vref_mv = pdata->vref_mv;
                else if (voltage_uv)
@@ -217,6 +171,8 @@ static int __devinit ad7887_probe(struct spi_device *spi)
                else
                        dev_warn(&spi->dev, "reference voltage unspecified\n");
 
+               indio_dev->channels = st->chip_info->channel;
+               indio_dev->num_channels = 3;
        } else {
                if (pdata && pdata->vref_mv)
                        st->int_vref_mv = pdata->vref_mv;
@@ -224,50 +180,56 @@ static int __devinit ad7887_probe(struct spi_device *spi)
                        st->int_vref_mv = st->chip_info->int_vref_mv;
                else
                        dev_warn(&spi->dev, "reference voltage unspecified\n");
-       }
 
+               indio_dev->channels = &st->chip_info->channel[1];
+               indio_dev->num_channels = 2;
+       }
 
-       ret = ad7887_register_ring_funcs_and_init(st->indio_dev);
+       ret = ad7887_register_ring_funcs_and_init(indio_dev);
        if (ret)
-               goto error_free_device;
+               goto error_disable_reg;
 
-       ret = iio_device_register(st->indio_dev);
+       ret = iio_device_register(indio_dev);
        if (ret)
-               goto error_free_device;
+               goto error_disable_reg;
+       regdone = 1;
 
-       ret = iio_ring_buffer_register(st->indio_dev->ring, 0);
+       ret = iio_ring_buffer_register_ex(indio_dev->ring, 0,
+                                         indio_dev->channels,
+                                         indio_dev->num_channels);
        if (ret)
                goto error_cleanup_ring;
        return 0;
 
 error_cleanup_ring:
-       ad7887_ring_cleanup(st->indio_dev);
-       iio_device_unregister(st->indio_dev);
-error_free_device:
-       iio_free_device(st->indio_dev);
+       ad7887_ring_cleanup(indio_dev);
 error_disable_reg:
        if (!IS_ERR(st->reg))
                regulator_disable(st->reg);
 error_put_reg:
        if (!IS_ERR(st->reg))
                regulator_put(st->reg);
-       kfree(st);
-error_ret:
+       if (regdone)
+               iio_device_unregister(indio_dev);
+       else
+               iio_free_device(indio_dev);
+
        return ret;
 }
 
 static int ad7887_remove(struct spi_device *spi)
 {
-       struct ad7887_state *st = spi_get_drvdata(spi);
-       struct iio_dev *indio_dev = st->indio_dev;
+       struct iio_dev *indio_dev = spi_get_drvdata(spi);
+       struct ad7887_state *st = iio_priv(indio_dev);
+
        iio_ring_buffer_unregister(indio_dev->ring);
        ad7887_ring_cleanup(indio_dev);
-       iio_device_unregister(indio_dev);
        if (!IS_ERR(st->reg)) {
                regulator_disable(st->reg);
                regulator_put(st->reg);
        }
-       kfree(st);
+       iio_device_unregister(indio_dev);
+
        return 0;
 }
 
index da77f266c16b8051f513a89d5aa02005701ea0fc..0e4a5f4fd8921fe19c95a34fc64cb8b7ca191997 100644 (file)
@@ -1,20 +1,17 @@
 /*
- * Copyright 2010 Analog Devices Inc.
+ * Copyright 2010-2011 Analog Devices Inc.
  * Copyright (C) 2008 Jonathan Cameron
  *
- * Licensed under the GPL-2 or later.
+ * Licensed under the GPL-2.
  *
  * ad7887_ring.c
  */
 
 #include <linux/interrupt.h>
-#include <linux/gpio.h>
-#include <linux/workqueue.h>
 #include <linux/device.h>
 #include <linux/kernel.h>
 #include <linux/slab.h>
 #include <linux/sysfs.h>
-#include <linux/list.h>
 #include <linux/spi/spi.h>
 
 #include "../iio.h"
 
 #include "ad7887.h"
 
-static IIO_SCAN_EL_C(in0, 0, 0, NULL);
-static IIO_SCAN_EL_C(in1, 1, 0, NULL);
-static IIO_SCAN_EL_TIMESTAMP(2);
-static IIO_CONST_ATTR_SCAN_EL_TYPE(timestamp, s, 64, 64);
-
-static ssize_t ad7887_show_type(struct device *dev,
-                               struct device_attribute *attr,
-                               char *buf)
-{
-       struct iio_ring_buffer *ring = dev_get_drvdata(dev);
-       struct iio_dev *indio_dev = ring->indio_dev;
-       struct ad7887_state *st = indio_dev->dev_data;
-
-       return sprintf(buf, "%c%d/%d>>%d\n", st->chip_info->sign,
-                      st->chip_info->bits, st->chip_info->storagebits,
-                      st->chip_info->left_shift);
-}
-static IIO_DEVICE_ATTR(in_type, S_IRUGO, ad7887_show_type, NULL, 0);
-
-static struct attribute *ad7887_scan_el_attrs[] = {
-       &iio_scan_el_in0.dev_attr.attr,
-       &iio_const_attr_in0_index.dev_attr.attr,
-       &iio_scan_el_in1.dev_attr.attr,
-       &iio_const_attr_in1_index.dev_attr.attr,
-       &iio_const_attr_timestamp_index.dev_attr.attr,
-       &iio_scan_el_timestamp.dev_attr.attr,
-       &iio_const_attr_timestamp_type.dev_attr.attr,
-       &iio_dev_attr_in_type.dev_attr.attr,
-       NULL,
-};
-
-static mode_t ad7887_scan_el_attr_is_visible(struct kobject *kobj,
-                                    struct attribute *attr, int n)
-{
-       struct device *dev = container_of(kobj, struct device, kobj);
-       struct iio_ring_buffer *ring = dev_get_drvdata(dev);
-       struct iio_dev *indio_dev = ring->indio_dev;
-       struct ad7887_state *st = indio_dev->dev_data;
-
-       mode_t mode = attr->mode;
-
-       if ((attr == &iio_scan_el_in1.dev_attr.attr) ||
-               (attr == &iio_const_attr_in1_index.dev_attr.attr))
-               if (!st->en_dual)
-                       mode = 0;
-
-       return mode;
-}
-
-static struct attribute_group ad7887_scan_el_group = {
-       .name = "scan_elements",
-       .attrs = ad7887_scan_el_attrs,
-       .is_visible = ad7887_scan_el_attr_is_visible,
-};
-
 int ad7887_scan_from_ring(struct ad7887_state *st, long mask)
 {
-       struct iio_ring_buffer *ring = st->indio_dev->ring;
+       struct iio_ring_buffer *ring = iio_priv_to_dev(st)->ring;
        int count = 0, ret;
        u16 *ring_data;
 
@@ -91,12 +33,13 @@ int ad7887_scan_from_ring(struct ad7887_state *st, long mask)
                goto error_ret;
        }
 
-       ring_data = kmalloc(ring->access.get_bytes_per_datum(ring), GFP_KERNEL);
+       ring_data = kmalloc(ring->access->get_bytes_per_datum(ring),
+                           GFP_KERNEL);
        if (ring_data == NULL) {
                ret = -ENOMEM;
                goto error_ret;
        }
-       ret = ring->access.read_last(ring, (u8 *) ring_data);
+       ret = ring->access->read_last(ring, (u8 *) ring_data);
        if (ret)
                goto error_free_ring_data;
 
@@ -124,7 +67,8 @@ static int ad7887_ring_preenable(struct iio_dev *indio_dev)
        struct ad7887_state *st = indio_dev->dev_data;
        struct iio_ring_buffer *ring = indio_dev->ring;
 
-       st->d_size = ring->scan_count * st->chip_info->storagebits / 8;
+       st->d_size = ring->scan_count *
+               st->chip_info->channel[0].scan_type.storagebits / 8;
 
        if (ring->scan_timestamp) {
                st->d_size += sizeof(s64);
@@ -133,8 +77,8 @@ static int ad7887_ring_preenable(struct iio_dev *indio_dev)
                        st->d_size += sizeof(s64) - (st->d_size % sizeof(s64));
        }
 
-       if (indio_dev->ring->access.set_bytes_per_datum)
-               indio_dev->ring->access.set_bytes_per_datum(indio_dev->ring,
+       if (indio_dev->ring->access->set_bytes_per_datum)
+               indio_dev->ring->access->set_bytes_per_datum(indio_dev->ring,
                                                            st->d_size);
 
        switch (ring->scan_mask) {
@@ -163,48 +107,27 @@ static int ad7887_ring_postdisable(struct iio_dev *indio_dev)
 }
 
 /**
- * ad7887_poll_func_th() th of trigger launched polling to ring buffer
- *
- * As sampling only occurs on spi comms occurring, leave timestamping until
- * then.  Some triggers will generate their own time stamp.  Currently
- * there is no way of notifying them when no one cares.
- **/
-static void ad7887_poll_func_th(struct iio_dev *indio_dev, s64 time)
-{
-       struct ad7887_state *st = indio_dev->dev_data;
-
-       schedule_work(&st->poll_work);
-       return;
-}
-/**
- * ad7887_poll_bh_to_ring() bh of trigger launched polling to ring buffer
- * @work_s:    the work struct through which this was scheduled
+ * ad7887_trigger_handler() bh of trigger launched polling to ring buffer
  *
  * Currently there is no option in this driver to disable the saving of
  * timestamps within the ring.
- * I think the one copy of this at a time was to avoid problems if the
- * trigger was set far too high and the reads then locked up the computer.
  **/
-static void ad7887_poll_bh_to_ring(struct work_struct *work_s)
+static irqreturn_t ad7887_trigger_handler(int irq, void *p)
 {
-       struct ad7887_state *st = container_of(work_s, struct ad7887_state,
-                                                 poll_work);
-       struct iio_dev *indio_dev = st->indio_dev;
-       struct iio_sw_ring_buffer *sw_ring = iio_to_sw_ring(indio_dev->ring);
+       struct iio_poll_func *pf = p;
+       struct iio_dev *indio_dev = pf->private_data;
+       struct ad7887_state *st = iio_dev_get_devdata(indio_dev);
        struct iio_ring_buffer *ring = indio_dev->ring;
        s64 time_ns;
        __u8 *buf;
        int b_sent;
 
-       unsigned int bytes = ring->scan_count * st->chip_info->storagebits / 8;
-
-       /* Ensure only one copy of this function running at a time */
-       if (atomic_inc_return(&st->protect_ring) > 1)
-               return;
+       unsigned int bytes = ring->scan_count *
+               st->chip_info->channel[0].scan_type.storagebits / 8;
 
        buf = kzalloc(st->d_size, GFP_KERNEL);
        if (buf == NULL)
-               return;
+               return -ENOMEM;
 
        b_sent = spi_sync(st->spi, st->ring_msg);
        if (b_sent)
@@ -215,17 +138,25 @@ static void ad7887_poll_bh_to_ring(struct work_struct *work_s)
        memcpy(buf, st->data, bytes);
        if (ring->scan_timestamp)
                memcpy(buf + st->d_size - sizeof(s64),
-                       &time_ns, sizeof(time_ns));
+                      &time_ns, sizeof(time_ns));
 
-       indio_dev->ring->access.store_to(&sw_ring->buf, buf, time_ns);
+       indio_dev->ring->access->store_to(indio_dev->ring, buf, time_ns);
 done:
        kfree(buf);
-       atomic_dec(&st->protect_ring);
+       iio_trigger_notify_done(indio_dev->trig);
+
+       return IRQ_HANDLED;
 }
 
+static const struct iio_ring_setup_ops ad7887_ring_setup_ops = {
+       .preenable = &ad7887_ring_preenable,
+       .postenable = &iio_triggered_ring_postenable,
+       .predisable = &iio_triggered_ring_predisable,
+       .postdisable = &ad7887_ring_postdisable,
+};
+
 int ad7887_register_ring_funcs_and_init(struct iio_dev *indio_dev)
 {
-       struct ad7887_state *st = indio_dev->dev_data;
        int ret;
 
        indio_dev->ring = iio_sw_rb_allocate(indio_dev);
@@ -234,25 +165,24 @@ int ad7887_register_ring_funcs_and_init(struct iio_dev *indio_dev)
                goto error_ret;
        }
        /* Effectively select the ring buffer implementation */
-       iio_ring_sw_register_funcs(&indio_dev->ring->access);
-       ret = iio_alloc_pollfunc(indio_dev, NULL, &ad7887_poll_func_th);
-       if (ret)
+       indio_dev->ring->access = &ring_sw_access_funcs;
+       indio_dev->pollfunc = iio_alloc_pollfunc(&iio_pollfunc_store_time,
+                                                &ad7887_trigger_handler,
+                                                IRQF_ONESHOT,
+                                                indio_dev,
+                                                "ad7887_consumer%d",
+                                                indio_dev->id);
+       if (indio_dev->pollfunc == NULL) {
+               ret = -ENOMEM;
                goto error_deallocate_sw_rb;
-
+       }
        /* Ring buffer functions - here trigger setup related */
-
-       indio_dev->ring->preenable = &ad7887_ring_preenable;
-       indio_dev->ring->postenable = &iio_triggered_ring_postenable;
-       indio_dev->ring->predisable = &iio_triggered_ring_predisable;
-       indio_dev->ring->postdisable = &ad7887_ring_postdisable;
-       indio_dev->ring->scan_el_attrs = &ad7887_scan_el_group;
-       indio_dev->ring->scan_timestamp = true;
-
-       INIT_WORK(&st->poll_work, &ad7887_poll_bh_to_ring);
+       indio_dev->ring->setup_ops = &ad7887_ring_setup_ops;
 
        /* Flag that polled ring buffering is possible */
        indio_dev->modes |= INDIO_RING_TRIGGERED;
        return 0;
+
 error_deallocate_sw_rb:
        iio_sw_rb_free(indio_dev->ring);
 error_ret:
@@ -267,6 +197,6 @@ void ad7887_ring_cleanup(struct iio_dev *indio_dev)
                iio_trigger_dettach_poll_func(indio_dev->trig,
                                              indio_dev->pollfunc);
        }
-       kfree(indio_dev->pollfunc);
+       iio_dealloc_pollfunc(indio_dev->pollfunc);
        iio_sw_rb_free(indio_dev->ring);
 }
index a421362c77f95ad27d72db0cdf43e6818d9ce272..0dc9b4c73a33af36ac2ede6e19f7ded3d71111ab 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010 Michael Hennerich, Analog Devices Inc.
+ * Copyright (C) 2010-2011 Michael Hennerich, Analog Devices Inc.
  * Copyright (C) 2008-2010 Jonathan Cameron
  *
  * This program is free software; you can redistribute it and/or modify
@@ -67,6 +67,8 @@
 
 #define AD7997_8_READ_SINGLE                   0x80
 #define AD7997_8_READ_SEQUENCE                 0x70
+/* TODO: move this into a common header */
+#define RES_MASK(bits) ((1 << (bits)) - 1)
 
 enum {
        ad7991,
@@ -83,43 +85,28 @@ struct ad799x_state;
 
 /**
  * struct ad799x_chip_info - chip specifc information
- * @num_inputs:                number of physical inputs on chip
- * @bits:              accuracy of the adc in bits
+ * @channel:           channel specification
+ * @num_channels:      number of channels
  * @int_vref_mv:       the internal reference voltage
  * @monitor_mode:      whether the chip supports monitor interrupts
  * @default_config:    device default configuration
- * @dev_attrs:         pointer to the device attribute group
- * @scan_attrs:                pointer to the scan element attribute group
  * @event_attrs:       pointer to the monitor event attribute group
- * @ad799x_set_scan_mode: function pointer to the device specific mode function
-
  */
+
 struct ad799x_chip_info {
-       u8                              num_inputs;
-       u8                              bits;
-       u8                              storagebits;
-       char                            sign;
+       struct iio_chan_spec            channel[9];
+       int                             num_channels;
        u16                             int_vref_mv;
-       bool                            monitor_mode;
        u16                             default_config;
-       struct attribute_group          *dev_attrs;
-       struct attribute_group          *scan_attrs;
-       struct attribute_group          *event_attrs;
-       int (*ad799x_set_scan_mode)     (struct ad799x_state *st,
-                                       unsigned mask);
+       const struct iio_info           *info;
 };
 
 struct ad799x_state {
-       struct iio_dev                  *indio_dev;
        struct i2c_client               *client;
        const struct ad799x_chip_info   *chip_info;
-       struct work_struct              poll_work;
-       struct work_struct              work_thresh;
-       atomic_t                        protect_ring;
        size_t                          d_size;
        struct iio_trigger              *trig;
        struct regulator                *reg;
-       s64                             last_timestamp;
        u16                             int_vref_mv;
        unsigned                        id;
        char                            *name;
@@ -134,7 +121,7 @@ struct ad799x_platform_data {
        u16                             vref_mv;
 };
 
-int ad799x_set_scan_mode(struct ad799x_state *st, unsigned mask);
+int ad7997_8_set_scan_mode(struct ad799x_state *st, unsigned mask);
 
 #ifdef CONFIG_AD799X_RING_BUFFER
 int ad799x_single_channel_from_ring(struct ad799x_state *st, long mask);
index f04e642e72723329803bb109bdc4731fbdff6643..29bfbcf820649aa068d0244def9dfcde0c79ca04 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * iio/adc/ad799x.c
- * Copyright (C) 2010 Michael Hennerich, Analog Devices Inc.
+ * Copyright (C) 2010-1011 Michael Hennerich, Analog Devices Inc.
  *
  * based on iio/adc/max1363
  * Copyright (C) 2008-2010 Jonathan Cameron
  */
 
 #include <linux/interrupt.h>
-#include <linux/workqueue.h>
 #include <linux/device.h>
 #include <linux/kernel.h>
 #include <linux/sysfs.h>
-#include <linux/list.h>
 #include <linux/i2c.h>
 #include <linux/regulator/consumer.h>
 #include <linux/slab.h>
@@ -100,130 +98,77 @@ static int ad799x_i2c_write8(struct ad799x_state *st, u8 reg, u8 data)
        return ret;
 }
 
-static int ad799x_scan_el_set_state(struct iio_scan_el *scan_el,
-                                      struct iio_dev *indio_dev,
-                                      bool state)
-{
-       struct ad799x_state *st = indio_dev->dev_data;
-       return ad799x_set_scan_mode(st, st->indio_dev->ring->scan_mask);
-}
-
-/* Here we claim all are 16 bits. This currently does no harm and saves
- * us a lot of scan element listings */
-
-#define AD799X_SCAN_EL(number)                                         \
-       IIO_SCAN_EL_C(in##number, number, 0, ad799x_scan_el_set_state);
-
-static AD799X_SCAN_EL(0);
-static AD799X_SCAN_EL(1);
-static AD799X_SCAN_EL(2);
-static AD799X_SCAN_EL(3);
-static AD799X_SCAN_EL(4);
-static AD799X_SCAN_EL(5);
-static AD799X_SCAN_EL(6);
-static AD799X_SCAN_EL(7);
-
-static IIO_SCAN_EL_TIMESTAMP(8);
-static IIO_CONST_ATTR_SCAN_EL_TYPE(timestamp, s, 64, 64)
-
-static ssize_t ad799x_show_type(struct device *dev,
-                               struct device_attribute *attr,
-                               char *buf)
-{
-       struct iio_ring_buffer *ring = dev_get_drvdata(dev);
-       struct iio_dev *indio_dev = ring->indio_dev;
-       struct ad799x_state *st = indio_dev->dev_data;
-
-       return sprintf(buf, "%c%d/%d\n", st->chip_info->sign,
-                      st->chip_info->bits, AD799X_STORAGEBITS);
-}
-static IIO_DEVICE_ATTR(in_type, S_IRUGO, ad799x_show_type, NULL, 0);
-
-static int ad7991_5_9_set_scan_mode(struct ad799x_state *st, unsigned mask)
-{
-       return i2c_smbus_write_byte(st->client,
-               st->config | (mask << AD799X_CHANNEL_SHIFT));
-}
-
-static int ad7992_3_4_set_scan_mode(struct ad799x_state *st, unsigned mask)
-{
-       return ad799x_i2c_write8(st, AD7998_CONF_REG,
-               st->config | (mask << AD799X_CHANNEL_SHIFT));
-}
-
-static int ad7997_8_set_scan_mode(struct ad799x_state *st, unsigned mask)
+int ad7997_8_set_scan_mode(struct ad799x_state *st, unsigned mask)
 {
        return ad799x_i2c_write16(st, AD7998_CONF_REG,
                st->config | (mask << AD799X_CHANNEL_SHIFT));
 }
 
-int ad799x_set_scan_mode(struct ad799x_state *st, unsigned mask)
+static int ad799x_scan_direct(struct ad799x_state *st, unsigned ch)
 {
+       u16 rxbuf;
+       u8 cmd;
        int ret;
 
-       if (st->chip_info->ad799x_set_scan_mode != NULL) {
-               ret = st->chip_info->ad799x_set_scan_mode(st, mask);
-               return (ret > 0) ? 0 : ret;
+       switch (st->id) {
+       case ad7991:
+       case ad7995:
+       case ad7999:
+               cmd = st->config | ((1 << ch) << AD799X_CHANNEL_SHIFT);
+               break;
+       case ad7992:
+       case ad7993:
+       case ad7994:
+               cmd = (1 << ch) << AD799X_CHANNEL_SHIFT;
+               break;
+       case ad7997:
+       case ad7998:
+               cmd = (ch << AD799X_CHANNEL_SHIFT) | AD7997_8_READ_SINGLE;
+               break;
+       default:
+               return -EINVAL;
        }
 
-       return 0;
+       ret = ad799x_i2c_read16(st, cmd, &rxbuf);
+       if (ret < 0)
+               return ret;
+
+       return rxbuf;
 }
 
-static ssize_t ad799x_read_single_channel(struct device *dev,
-                                  struct device_attribute *attr,
-                                  char *buf)
+static int ad799x_read_raw(struct iio_dev *dev_info,
+                          struct iio_chan_spec const *chan,
+                          int *val,
+                          int *val2,
+                          long m)
 {
-       struct iio_dev *dev_info = dev_get_drvdata(dev);
-       struct ad799x_state *st = iio_dev_get_devdata(dev_info);
-       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-       int ret = 0, len = 0;
-       u32 data ;
-       u16 rxbuf[1];
-       u8 cmd;
-       long mask;
+       int ret;
+       struct ad799x_state *st = dev_info->dev_data;
+       unsigned int scale_uv;
+
+       switch (m) {
+       case 0:
+               mutex_lock(&dev_info->mlock);
+               if (iio_ring_enabled(dev_info))
+                       ret = ad799x_single_channel_from_ring(st,
+                               1 << chan->address);
+               else
+                       ret = ad799x_scan_direct(st, chan->address);
+               mutex_unlock(&dev_info->mlock);
 
-       mutex_lock(&dev_info->mlock);
-       mask = 1 << this_attr->address;
-       /* If ring buffer capture is occurring, query the buffer */
-       if (iio_ring_enabled(dev_info)) {
-               data = ret = ad799x_single_channel_from_ring(st, mask);
                if (ret < 0)
-                       goto error_ret;
-               ret = 0;
-       } else {
-               switch (st->id) {
-               case ad7991:
-               case ad7995:
-               case ad7999:
-                       cmd = st->config | (mask << AD799X_CHANNEL_SHIFT);
-                       break;
-               case ad7992:
-               case ad7993:
-               case ad7994:
-                       cmd = mask << AD799X_CHANNEL_SHIFT;
-                       break;
-               case ad7997:
-               case ad7998:
-                       cmd = (this_attr->address <<
-                               AD799X_CHANNEL_SHIFT) | AD7997_8_READ_SINGLE;
-                       break;
-               default:
-                       cmd = 0;
-
-               }
-               ret = ad799x_i2c_read16(st, cmd, rxbuf);
-               if (ret < 0)
-                       goto error_ret;
-
-               data = rxbuf[0];
+                       return ret;
+               *val = (ret >> st->chip_info->channel[0].scan_type.shift) &
+                       RES_MASK(st->chip_info->channel[0].scan_type.realbits);
+               return IIO_VAL_INT;
+       case (1 << IIO_CHAN_INFO_SCALE_SHARED):
+               scale_uv = (st->int_vref_mv * 1000)
+                       >> st->chip_info->channel[0].scan_type.realbits;
+               *val =  scale_uv / 1000;
+               *val2 = (scale_uv % 1000) * 1000;
+               return IIO_VAL_INT_PLUS_MICRO;
        }
-
-       /* Pretty print the result */
-       len = sprintf(buf, "%u\n", data & ((1 << (st->chip_info->bits)) - 1));
-
-error_ret:
-       mutex_unlock(&dev_info->mlock);
-       return ret ? ret : len;
+       return -EINVAL;
 }
 
 static ssize_t ad799x_read_frequency(struct device *dev,
@@ -331,18 +276,17 @@ error_ret_mutex:
        return ret ? ret : len;
 }
 
-
 static ssize_t ad799x_read_channel_config(struct device *dev,
                                        struct device_attribute *attr,
                                        char *buf)
 {
        struct iio_dev *dev_info = dev_get_drvdata(dev);
        struct ad799x_state *st = iio_dev_get_devdata(dev_info);
-       struct iio_event_attr *this_attr = to_iio_event_attr(attr);
+       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
 
        int ret;
        u16 val;
-       ret = ad799x_i2c_read16(st, this_attr->mask, &val);
+       ret = ad799x_i2c_read16(st, this_attr->address, &val);
        if (ret)
                return ret;
 
@@ -356,7 +300,7 @@ static ssize_t ad799x_write_channel_config(struct device *dev,
 {
        struct iio_dev *dev_info = dev_get_drvdata(dev);
        struct ad799x_state *st = iio_dev_get_devdata(dev_info);
-       struct iio_event_attr *this_attr = to_iio_event_attr(attr);
+       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
 
        long val;
        int ret;
@@ -366,273 +310,111 @@ static ssize_t ad799x_write_channel_config(struct device *dev,
                return ret;
 
        mutex_lock(&dev_info->mlock);
-       ret = ad799x_i2c_write16(st, this_attr->mask, val);
+       ret = ad799x_i2c_write16(st, this_attr->address, val);
        mutex_unlock(&dev_info->mlock);
 
        return ret ? ret : len;
 }
 
-static void ad799x_interrupt_bh(struct work_struct *work_s)
+static irqreturn_t ad799x_event_handler(int irq, void *private)
 {
-       struct ad799x_state *st = container_of(work_s,
-               struct ad799x_state, work_thresh);
+       struct iio_dev *indio_dev = private;
+       struct ad799x_state *st = iio_dev_get_devdata(private);
        u8 status;
-       int i;
+       int i, ret;
 
-       if (ad799x_i2c_read8(st, AD7998_ALERT_STAT_REG, &status))
-               goto err_out;
+       ret = ad799x_i2c_read8(st, AD7998_ALERT_STAT_REG, &status);
+       if (ret)
+               return ret;
 
        if (!status)
-               goto err_out;
+               return -EIO;
 
        ad799x_i2c_write8(st, AD7998_ALERT_STAT_REG, AD7998_ALERT_STAT_CLEAR);
 
        for (i = 0; i < 8; i++) {
                if (status & (1 << i))
-                       iio_push_event(st->indio_dev, 0,
-                               i & 0x1 ?
-                               IIO_EVENT_CODE_IN_HIGH_THRESH(i >> 1) :
-                               IIO_EVENT_CODE_IN_LOW_THRESH(i >> 1),
-                               st->last_timestamp);
+                       iio_push_event(indio_dev, 0,
+                                      i & 0x1 ?
+                                      IIO_EVENT_CODE_IN_HIGH_THRESH(i >> 1) :
+                                      IIO_EVENT_CODE_IN_LOW_THRESH(i >> 1),
+                                      iio_get_time_ns());
        }
 
-err_out:
-       enable_irq(st->client->irq);
-}
-
-static int ad799x_interrupt(struct iio_dev *dev_info,
-               int index,
-               s64 timestamp,
-               int no_test)
-{
-       struct ad799x_state *st = dev_info->dev_data;
-
-       st->last_timestamp = timestamp;
-       schedule_work(&st->work_thresh);
-       return 0;
-}
-
-IIO_EVENT_SH(ad799x, &ad799x_interrupt);
-
-/* Direct read attribtues */
-static IIO_DEV_ATTR_IN_RAW(0, ad799x_read_single_channel, 0);
-static IIO_DEV_ATTR_IN_RAW(1, ad799x_read_single_channel, 1);
-static IIO_DEV_ATTR_IN_RAW(2, ad799x_read_single_channel, 2);
-static IIO_DEV_ATTR_IN_RAW(3, ad799x_read_single_channel, 3);
-static IIO_DEV_ATTR_IN_RAW(4, ad799x_read_single_channel, 4);
-static IIO_DEV_ATTR_IN_RAW(5, ad799x_read_single_channel, 5);
-static IIO_DEV_ATTR_IN_RAW(6, ad799x_read_single_channel, 6);
-static IIO_DEV_ATTR_IN_RAW(7, ad799x_read_single_channel, 7);
-
-static ssize_t ad799x_show_scale(struct device *dev,
-                               struct device_attribute *attr,
-                               char *buf)
-{
-       /* Driver currently only support internal vref */
-       struct iio_dev *dev_info = dev_get_drvdata(dev);
-       struct ad799x_state *st = iio_dev_get_devdata(dev_info);
-
-       /* Corresponds to Vref / 2^(bits) */
-       unsigned int scale_uv = (st->int_vref_mv * 1000) >> st->chip_info->bits;
-
-       return sprintf(buf, "%d.%03d\n", scale_uv / 1000, scale_uv % 1000);
-}
-
-static IIO_DEVICE_ATTR(in_scale, S_IRUGO, ad799x_show_scale, NULL, 0);
-
-static ssize_t ad799x_show_name(struct device *dev,
-                                struct device_attribute *attr,
-                                char *buf)
-{
-       struct iio_dev *dev_info = dev_get_drvdata(dev);
-       struct ad799x_state *st = iio_dev_get_devdata(dev_info);
-       return sprintf(buf, "%s\n", st->client->name);
+       return IRQ_HANDLED;
 }
 
-static IIO_DEVICE_ATTR(name, S_IRUGO, ad799x_show_name, NULL, 0);
-
-static struct attribute *ad7991_5_9_3_4_device_attrs[] = {
-       &iio_dev_attr_in0_raw.dev_attr.attr,
-       &iio_dev_attr_in1_raw.dev_attr.attr,
-       &iio_dev_attr_in2_raw.dev_attr.attr,
-       &iio_dev_attr_in3_raw.dev_attr.attr,
-       &iio_dev_attr_name.dev_attr.attr,
-       &iio_dev_attr_in_scale.dev_attr.attr,
-       NULL
-};
-
-static struct attribute_group ad7991_5_9_3_4_dev_attr_group = {
-       .attrs = ad7991_5_9_3_4_device_attrs,
-};
-
-static struct attribute *ad7991_5_9_3_4_scan_el_attrs[] = {
-       &iio_scan_el_in0.dev_attr.attr,
-       &iio_const_attr_in0_index.dev_attr.attr,
-       &iio_scan_el_in1.dev_attr.attr,
-       &iio_const_attr_in1_index.dev_attr.attr,
-       &iio_scan_el_in2.dev_attr.attr,
-       &iio_const_attr_in2_index.dev_attr.attr,
-       &iio_scan_el_in3.dev_attr.attr,
-       &iio_const_attr_in3_index.dev_attr.attr,
-       &iio_const_attr_timestamp_index.dev_attr.attr,
-       &iio_scan_el_timestamp.dev_attr.attr,
-       &iio_const_attr_timestamp_type.dev_attr.attr,
-       &iio_dev_attr_in_type.dev_attr.attr,
-       NULL,
-};
-
-static struct attribute_group ad7991_5_9_3_4_scan_el_group = {
-       .name = "scan_elements",
-       .attrs = ad7991_5_9_3_4_scan_el_attrs,
-};
-
-static struct attribute *ad7992_device_attrs[] = {
-       &iio_dev_attr_in0_raw.dev_attr.attr,
-       &iio_dev_attr_in1_raw.dev_attr.attr,
-       &iio_dev_attr_name.dev_attr.attr,
-       &iio_dev_attr_in_scale.dev_attr.attr,
-       NULL
-};
-
-static struct attribute_group ad7992_dev_attr_group = {
-       .attrs = ad7992_device_attrs,
-};
-
-static struct attribute *ad7992_scan_el_attrs[] = {
-       &iio_scan_el_in0.dev_attr.attr,
-       &iio_const_attr_in0_index.dev_attr.attr,
-       &iio_scan_el_in1.dev_attr.attr,
-       &iio_const_attr_in1_index.dev_attr.attr,
-       &iio_const_attr_timestamp_index.dev_attr.attr,
-       &iio_scan_el_timestamp.dev_attr.attr,
-       &iio_const_attr_timestamp_type.dev_attr.attr,
-       &iio_dev_attr_in_type.dev_attr.attr,
-       NULL,
-};
-
-static struct attribute_group ad7992_scan_el_group = {
-       .name = "scan_elements",
-       .attrs = ad7992_scan_el_attrs,
-};
-
-static struct attribute *ad7997_8_device_attrs[] = {
-       &iio_dev_attr_in0_raw.dev_attr.attr,
-       &iio_dev_attr_in1_raw.dev_attr.attr,
-       &iio_dev_attr_in2_raw.dev_attr.attr,
-       &iio_dev_attr_in3_raw.dev_attr.attr,
-       &iio_dev_attr_in4_raw.dev_attr.attr,
-       &iio_dev_attr_in5_raw.dev_attr.attr,
-       &iio_dev_attr_in6_raw.dev_attr.attr,
-       &iio_dev_attr_in7_raw.dev_attr.attr,
-       &iio_dev_attr_name.dev_attr.attr,
-       &iio_dev_attr_in_scale.dev_attr.attr,
-       NULL
-};
-
-static struct attribute_group ad7997_8_dev_attr_group = {
-       .attrs = ad7997_8_device_attrs,
-};
-
-static struct attribute *ad7997_8_scan_el_attrs[] = {
-       &iio_scan_el_in0.dev_attr.attr,
-       &iio_const_attr_in0_index.dev_attr.attr,
-       &iio_scan_el_in1.dev_attr.attr,
-       &iio_const_attr_in1_index.dev_attr.attr,
-       &iio_scan_el_in2.dev_attr.attr,
-       &iio_const_attr_in2_index.dev_attr.attr,
-       &iio_scan_el_in3.dev_attr.attr,
-       &iio_const_attr_in3_index.dev_attr.attr,
-       &iio_scan_el_in4.dev_attr.attr,
-       &iio_const_attr_in4_index.dev_attr.attr,
-       &iio_scan_el_in5.dev_attr.attr,
-       &iio_const_attr_in5_index.dev_attr.attr,
-       &iio_scan_el_in6.dev_attr.attr,
-       &iio_const_attr_in6_index.dev_attr.attr,
-       &iio_scan_el_in7.dev_attr.attr,
-       &iio_const_attr_in7_index.dev_attr.attr,
-       &iio_const_attr_timestamp_index.dev_attr.attr,
-       &iio_scan_el_timestamp.dev_attr.attr,
-       &iio_const_attr_timestamp_type.dev_attr.attr,
-       &iio_dev_attr_in_type.dev_attr.attr,
-       NULL,
-};
-
-static struct attribute_group ad7997_8_scan_el_group = {
-       .name = "scan_elements",
-       .attrs = ad7997_8_scan_el_attrs,
-};
-
-IIO_EVENT_ATTR_SH(in0_thresh_low_value,
-                 iio_event_ad799x,
-                 ad799x_read_channel_config,
-                 ad799x_write_channel_config,
-                 AD7998_DATALOW_CH1_REG);
-
-IIO_EVENT_ATTR_SH(in0_thresh_high_value,
-                 iio_event_ad799x,
-                 ad799x_read_channel_config,
-                 ad799x_write_channel_config,
-                 AD7998_DATAHIGH_CH1_REG);
-
-IIO_EVENT_ATTR_SH(in0_thresh_both_hyst_raw,
-                 iio_event_ad799x,
-                 ad799x_read_channel_config,
-                 ad799x_write_channel_config,
-                 AD7998_HYST_CH1_REG);
-
-IIO_EVENT_ATTR_SH(in1_thresh_low_value,
-                 iio_event_ad799x,
-                 ad799x_read_channel_config,
-                 ad799x_write_channel_config,
-                 AD7998_DATALOW_CH2_REG);
-
-IIO_EVENT_ATTR_SH(in1_thresh_high_value,
-                 iio_event_ad799x,
-                 ad799x_read_channel_config,
-                 ad799x_write_channel_config,
-                 AD7998_DATAHIGH_CH2_REG);
-
-IIO_EVENT_ATTR_SH(in1_thresh_both_hyst_raw,
-                 iio_event_ad799x,
-                 ad799x_read_channel_config,
-                 ad799x_write_channel_config,
-                 AD7998_HYST_CH2_REG);
-
-IIO_EVENT_ATTR_SH(in2_thresh_low_value,
-                 iio_event_ad799x,
-                 ad799x_read_channel_config,
-                 ad799x_write_channel_config,
-                 AD7998_DATALOW_CH3_REG);
-
-IIO_EVENT_ATTR_SH(in2_thresh_high_value,
-                 iio_event_ad799x,
-                 ad799x_read_channel_config,
-                 ad799x_write_channel_config,
-                 AD7998_DATAHIGH_CH3_REG);
-
-IIO_EVENT_ATTR_SH(in2_thresh_both_hyst_raw,
-                 iio_event_ad799x,
-                 ad799x_read_channel_config,
-                 ad799x_write_channel_config,
-                 AD7998_HYST_CH3_REG);
-
-IIO_EVENT_ATTR_SH(in3_thresh_low_value,
-                 iio_event_ad799x,
-                 ad799x_read_channel_config,
-                 ad799x_write_channel_config,
-                 AD7998_DATALOW_CH4_REG);
-
-IIO_EVENT_ATTR_SH(in3_thresh_high_value,
-                 iio_event_ad799x,
-                 ad799x_read_channel_config,
-                 ad799x_write_channel_config,
-                 AD7998_DATAHIGH_CH4_REG);
-
-IIO_EVENT_ATTR_SH(in3_thresh_both_hyst_raw,
-                 iio_event_ad799x,
-                 ad799x_read_channel_config,
-                 ad799x_write_channel_config,
-                 AD7998_HYST_CH4_REG);
+static IIO_DEVICE_ATTR(in0_thresh_low_value,
+                      S_IRUGO | S_IWUSR,
+                      ad799x_read_channel_config,
+                      ad799x_write_channel_config,
+                      AD7998_DATALOW_CH1_REG);
+
+static IIO_DEVICE_ATTR(in0_thresh_high_value,
+                      S_IRUGO | S_IWUSR,
+                      ad799x_read_channel_config,
+                      ad799x_write_channel_config,
+                      AD7998_DATAHIGH_CH1_REG);
+
+static IIO_DEVICE_ATTR(in0_thresh_both_hyst_raw,
+                      S_IRUGO | S_IWUSR,
+                      ad799x_read_channel_config,
+                      ad799x_write_channel_config,
+                      AD7998_HYST_CH1_REG);
+
+static IIO_DEVICE_ATTR(in1_thresh_low_value,
+                      S_IRUGO | S_IWUSR,
+                      ad799x_read_channel_config,
+                      ad799x_write_channel_config,
+                      AD7998_DATALOW_CH2_REG);
+
+static IIO_DEVICE_ATTR(in1_thresh_high_value,
+                      S_IRUGO | S_IWUSR,
+                      ad799x_read_channel_config,
+                      ad799x_write_channel_config,
+                      AD7998_DATAHIGH_CH2_REG);
+
+static IIO_DEVICE_ATTR(in1_thresh_both_hyst_raw,
+                      S_IRUGO | S_IWUSR,
+                      ad799x_read_channel_config,
+                      ad799x_write_channel_config,
+                      AD7998_HYST_CH2_REG);
+
+static IIO_DEVICE_ATTR(in2_thresh_low_value,
+                      S_IRUGO | S_IWUSR,
+                      ad799x_read_channel_config,
+                      ad799x_write_channel_config,
+                      AD7998_DATALOW_CH3_REG);
+
+static IIO_DEVICE_ATTR(in2_thresh_high_value,
+                      S_IRUGO | S_IWUSR,
+                      ad799x_read_channel_config,
+                      ad799x_write_channel_config,
+                      AD7998_DATAHIGH_CH3_REG);
+
+static IIO_DEVICE_ATTR(in2_thresh_both_hyst_raw,
+                      S_IRUGO | S_IWUSR,
+                      ad799x_read_channel_config,
+                      ad799x_write_channel_config,
+                      AD7998_HYST_CH3_REG);
+
+static IIO_DEVICE_ATTR(in3_thresh_low_value,
+                      S_IRUGO | S_IWUSR,
+                      ad799x_read_channel_config,
+                      ad799x_write_channel_config,
+                      AD7998_DATALOW_CH4_REG);
+
+static IIO_DEVICE_ATTR(in3_thresh_high_value,
+                      S_IRUGO | S_IWUSR,
+                      ad799x_read_channel_config,
+                      ad799x_write_channel_config,
+                      AD7998_DATAHIGH_CH4_REG);
+
+static IIO_DEVICE_ATTR(in3_thresh_both_hyst_raw,
+                      S_IRUGO | S_IWUSR,
+                      ad799x_read_channel_config,
+                      ad799x_write_channel_config,
+                      AD7998_HYST_CH4_REG);
 
 static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO,
                              ad799x_read_frequency,
@@ -640,18 +422,18 @@ static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO,
 static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("15625 7812 3906 1953 976 488 244 0");
 
 static struct attribute *ad7993_4_7_8_event_attributes[] = {
-       &iio_event_attr_in0_thresh_low_value.dev_attr.attr,
-       &iio_event_attr_in0_thresh_high_value.dev_attr.attr,
-       &iio_event_attr_in0_thresh_both_hyst_raw.dev_attr.attr,
-       &iio_event_attr_in1_thresh_low_value.dev_attr.attr,
-       &iio_event_attr_in1_thresh_high_value.dev_attr.attr,
-       &iio_event_attr_in1_thresh_both_hyst_raw.dev_attr.attr,
-       &iio_event_attr_in2_thresh_low_value.dev_attr.attr,
-       &iio_event_attr_in2_thresh_high_value.dev_attr.attr,
-       &iio_event_attr_in2_thresh_both_hyst_raw.dev_attr.attr,
-       &iio_event_attr_in3_thresh_low_value.dev_attr.attr,
-       &iio_event_attr_in3_thresh_high_value.dev_attr.attr,
-       &iio_event_attr_in3_thresh_both_hyst_raw.dev_attr.attr,
+       &iio_dev_attr_in0_thresh_low_value.dev_attr.attr,
+       &iio_dev_attr_in0_thresh_high_value.dev_attr.attr,
+       &iio_dev_attr_in0_thresh_both_hyst_raw.dev_attr.attr,
+       &iio_dev_attr_in1_thresh_low_value.dev_attr.attr,
+       &iio_dev_attr_in1_thresh_high_value.dev_attr.attr,
+       &iio_dev_attr_in1_thresh_both_hyst_raw.dev_attr.attr,
+       &iio_dev_attr_in2_thresh_low_value.dev_attr.attr,
+       &iio_dev_attr_in2_thresh_high_value.dev_attr.attr,
+       &iio_dev_attr_in2_thresh_both_hyst_raw.dev_attr.attr,
+       &iio_dev_attr_in3_thresh_low_value.dev_attr.attr,
+       &iio_dev_attr_in3_thresh_high_value.dev_attr.attr,
+       &iio_dev_attr_in3_thresh_both_hyst_raw.dev_attr.attr,
        &iio_dev_attr_sampling_frequency.dev_attr.attr,
        &iio_const_attr_sampling_frequency_available.dev_attr.attr,
        NULL,
@@ -662,12 +444,12 @@ static struct attribute_group ad7993_4_7_8_event_attrs_group = {
 };
 
 static struct attribute *ad7992_event_attributes[] = {
-       &iio_event_attr_in0_thresh_low_value.dev_attr.attr,
-       &iio_event_attr_in0_thresh_high_value.dev_attr.attr,
-       &iio_event_attr_in0_thresh_both_hyst_raw.dev_attr.attr,
-       &iio_event_attr_in1_thresh_low_value.dev_attr.attr,
-       &iio_event_attr_in1_thresh_high_value.dev_attr.attr,
-       &iio_event_attr_in1_thresh_both_hyst_raw.dev_attr.attr,
+       &iio_dev_attr_in0_thresh_low_value.dev_attr.attr,
+       &iio_dev_attr_in0_thresh_high_value.dev_attr.attr,
+       &iio_dev_attr_in0_thresh_both_hyst_raw.dev_attr.attr,
+       &iio_dev_attr_in1_thresh_low_value.dev_attr.attr,
+       &iio_dev_attr_in1_thresh_high_value.dev_attr.attr,
+       &iio_dev_attr_in1_thresh_both_hyst_raw.dev_attr.attr,
        &iio_dev_attr_sampling_frequency.dev_attr.attr,
        &iio_const_attr_sampling_frequency_available.dev_attr.attr,
        NULL,
@@ -677,93 +459,192 @@ static struct attribute_group ad7992_event_attrs_group = {
        .attrs = ad7992_event_attributes,
 };
 
+static const struct iio_info ad7991_info = {
+       .read_raw = &ad799x_read_raw,
+       .driver_module = THIS_MODULE,
+};
+
+static const struct iio_info ad7992_info = {
+       .read_raw = &ad799x_read_raw,
+       .num_interrupt_lines = 1,
+       .event_attrs = &ad7992_event_attrs_group,
+       .driver_module = THIS_MODULE,
+};
+
+static const struct iio_info ad7993_4_7_8_info = {
+       .read_raw = &ad799x_read_raw,
+       .num_interrupt_lines = 1,
+       .event_attrs = &ad7993_4_7_8_event_attrs_group,
+       .driver_module = THIS_MODULE,
+};
+
 static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
        [ad7991] = {
-               .num_inputs = 4,
-               .bits = 12,
-               .sign = IIO_SCAN_EL_TYPE_UNSIGNED,
+               .channel[0] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 0, 0,
+                                      (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                                      0, 0, IIO_ST('u', 12, 16, 0), 0),
+               .channel[1] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 1, 0,
+                                      (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                                      1, 1, IIO_ST('u', 12, 16, 0), 0),
+               .channel[2] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 2, 0,
+                                      (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                                      2, 2, IIO_ST('u', 12, 16, 0), 0),
+               .channel[3] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 3, 0,
+                                      (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                                      3, 3, IIO_ST('u', 12, 16, 0), 0),
+               .channel[4] = IIO_CHAN_SOFT_TIMESTAMP(4),
+               .num_channels = 5,
                .int_vref_mv = 4096,
-               .dev_attrs = &ad7991_5_9_3_4_dev_attr_group,
-               .scan_attrs = &ad7991_5_9_3_4_scan_el_group,
-               .ad799x_set_scan_mode = ad7991_5_9_set_scan_mode,
+               .info = &ad7991_info,
        },
        [ad7995] = {
-               .num_inputs = 4,
-               .bits = 10,
-               .sign = IIO_SCAN_EL_TYPE_UNSIGNED,
+               .channel[0] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 0, 0,
+                                      (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                                      0, 0, IIO_ST('u', 10, 16, 0), 0),
+               .channel[1] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 1, 0,
+                                      (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                                      1, 1, IIO_ST('u', 10, 16, 0), 0),
+               .channel[2] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 2, 0,
+                                      (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                                      2, 2, IIO_ST('u', 10, 16, 0), 0),
+               .channel[3] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 3, 0,
+                                      (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                                      3, 3, IIO_ST('u', 10, 16, 0), 0),
+               .channel[4] = IIO_CHAN_SOFT_TIMESTAMP(4),
+               .num_channels = 5,
                .int_vref_mv = 1024,
-               .dev_attrs = &ad7991_5_9_3_4_dev_attr_group,
-               .scan_attrs = &ad7991_5_9_3_4_scan_el_group,
-               .ad799x_set_scan_mode = ad7991_5_9_set_scan_mode,
+               .info = &ad7991_info,
        },
        [ad7999] = {
-               .num_inputs = 4,
-               .bits = 10,
-               .sign = IIO_SCAN_EL_TYPE_UNSIGNED,
+               .channel[0] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 0, 0,
+                                      (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                                      0, 0, IIO_ST('u', 10, 16, 0), 0),
+               .channel[1] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 1, 0,
+                                      (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                                      1, 1, IIO_ST('u', 10, 16, 0), 0),
+               .channel[2] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 2, 0,
+                                      (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                                      2, 2, IIO_ST('u', 10, 16, 0), 0),
+               .channel[3] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 3, 0,
+                                      (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                                      3, 3, IIO_ST('u', 10, 16, 0), 0),
+               .channel[4] = IIO_CHAN_SOFT_TIMESTAMP(4),
+               .num_channels = 5,
                .int_vref_mv = 1024,
-               .dev_attrs = &ad7991_5_9_3_4_dev_attr_group,
-               .scan_attrs = &ad7991_5_9_3_4_scan_el_group,
-               .ad799x_set_scan_mode = ad7991_5_9_set_scan_mode,
+               .info = &ad7991_info,
        },
        [ad7992] = {
-               .num_inputs = 2,
-               .bits = 12,
-               .sign = IIO_SCAN_EL_TYPE_UNSIGNED,
+               .channel[0] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 0, 0,
+                                      (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                                      0, 0, IIO_ST('u', 12, 16, 0), 0),
+               .channel[1] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 1, 0,
+                                      (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                                      1, 1, IIO_ST('u', 12, 16, 0), 0),
+               .channel[2] = IIO_CHAN_SOFT_TIMESTAMP(2),
+               .num_channels = 3,
                .int_vref_mv = 4096,
-               .monitor_mode = true,
                .default_config = AD7998_ALERT_EN,
-               .dev_attrs = &ad7992_dev_attr_group,
-               .scan_attrs = &ad7992_scan_el_group,
-               .event_attrs = &ad7992_event_attrs_group,
-               .ad799x_set_scan_mode = ad7992_3_4_set_scan_mode,
+               .info = &ad7992_info,
        },
        [ad7993] = {
-               .num_inputs = 4,
-               .bits = 10,
-               .sign = IIO_SCAN_EL_TYPE_UNSIGNED,
+               .channel[0] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 0, 0,
+                                      (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                                      0, 0, IIO_ST('u', 10, 16, 0), 0),
+               .channel[1] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 1, 0,
+                                      (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                                      1, 1, IIO_ST('u', 10, 16, 0), 0),
+               .channel[2] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 2, 0,
+                                      (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                                      2, 2, IIO_ST('u', 10, 16, 0), 0),
+               .channel[3] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 3, 0,
+                                      (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                                      3, 3, IIO_ST('u', 10, 16, 0), 0),
+               .channel[4] = IIO_CHAN_SOFT_TIMESTAMP(4),
+               .num_channels = 5,
                .int_vref_mv = 1024,
-               .monitor_mode = true,
                .default_config = AD7998_ALERT_EN,
-               .dev_attrs = &ad7991_5_9_3_4_dev_attr_group,
-               .scan_attrs = &ad7991_5_9_3_4_scan_el_group,
-               .event_attrs = &ad7993_4_7_8_event_attrs_group,
-               .ad799x_set_scan_mode = ad7992_3_4_set_scan_mode,
+               .info = &ad7993_4_7_8_info,
        },
        [ad7994] = {
-               .num_inputs = 4,
-               .bits = 12,
-               .sign = IIO_SCAN_EL_TYPE_UNSIGNED,
+               .channel[0] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 0, 0,
+                                      (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                                      0, 0, IIO_ST('u', 12, 16, 0), 0),
+               .channel[1] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 1, 0,
+                                      (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                                      1, 1, IIO_ST('u', 12, 16, 0), 0),
+               .channel[2] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 2, 0,
+                                      (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                                      2, 2, IIO_ST('u', 12, 16, 0), 0),
+               .channel[3] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 3, 0,
+                                      (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                                      3, 3, IIO_ST('u', 12, 16, 0), 0),
+               .channel[4] = IIO_CHAN_SOFT_TIMESTAMP(4),
+               .num_channels = 5,
                .int_vref_mv = 4096,
-               .monitor_mode = true,
                .default_config = AD7998_ALERT_EN,
-               .dev_attrs = &ad7991_5_9_3_4_dev_attr_group,
-               .scan_attrs = &ad7991_5_9_3_4_scan_el_group,
-               .event_attrs = &ad7993_4_7_8_event_attrs_group,
-               .ad799x_set_scan_mode = ad7992_3_4_set_scan_mode,
+               .info = &ad7993_4_7_8_info,
        },
        [ad7997] = {
-               .num_inputs = 8,
-               .bits = 10,
-               .sign = IIO_SCAN_EL_TYPE_UNSIGNED,
+               .channel[0] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 0, 0,
+                                         (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                                         0, 0, IIO_ST('u', 10, 16, 0), 0),
+               .channel[1] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 1, 0,
+                                         (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                                         1, 1, IIO_ST('u', 10, 16, 0), 0),
+               .channel[2] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 2, 0,
+                                         (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                                         2, 2, IIO_ST('u', 10, 16, 0), 0),
+               .channel[3] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 3, 0,
+                                         (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                                         3, 3, IIO_ST('u', 10, 16, 0), 0),
+               .channel[4] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 4, 0,
+                                         (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                                         4, 4, IIO_ST('u', 10, 16, 0), 0),
+               .channel[5] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 5, 0,
+                                         (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                                         5, 5, IIO_ST('u', 10, 16, 0), 0),
+               .channel[6] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 6, 0,
+                                         (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                                         6, 6, IIO_ST('u', 10, 16, 0), 0),
+               .channel[7] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 7, 0,
+                                         (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                                         7, 7, IIO_ST('u', 10, 16, 0), 0),
+               .channel[8] = IIO_CHAN_SOFT_TIMESTAMP(8),
+               .num_channels = 9,
                .int_vref_mv = 1024,
-               .monitor_mode = true,
                .default_config = AD7998_ALERT_EN,
-               .dev_attrs = &ad7997_8_dev_attr_group,
-               .scan_attrs = &ad7997_8_scan_el_group,
-               .event_attrs = &ad7993_4_7_8_event_attrs_group,
-               .ad799x_set_scan_mode = ad7997_8_set_scan_mode,
+               .info = &ad7993_4_7_8_info,
        },
        [ad7998] = {
-               .num_inputs = 8,
-               .bits = 12,
-               .sign = IIO_SCAN_EL_TYPE_UNSIGNED,
+               .channel[0] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 0, 0,
+                                      (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                                      0, 0, IIO_ST('u', 12, 16, 0), 0),
+               .channel[1] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 1, 0,
+                                      (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                                      1, 1, IIO_ST('u', 12, 16, 0), 0),
+               .channel[2] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 2, 0,
+                                      (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                                      2, 2, IIO_ST('u', 12, 16, 0), 0),
+               .channel[3] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 3, 0,
+                                      (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                                      3, 3, IIO_ST('u', 12, 16, 0), 0),
+               .channel[4] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 4, 0,
+                                      (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                                      4, 4, IIO_ST('u', 12, 16, 0), 0),
+               .channel[5] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 5, 0,
+                                      (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                                      5, 5, IIO_ST('u', 12, 16, 0), 0),
+               .channel[6] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 6, 0,
+                                      (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                                      6, 6, IIO_ST('u', 12, 16, 0), 0),
+               .channel[7] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 7, 0,
+                                         (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                                         7, 7, IIO_ST('u', 12, 16, 0), 0),
+               .channel[8] = IIO_CHAN_SOFT_TIMESTAMP(8),
+               .num_channels = 9,
                .int_vref_mv = 4096,
-               .monitor_mode = true,
                .default_config = AD7998_ALERT_EN,
-               .dev_attrs = &ad7997_8_dev_attr_group,
-               .scan_attrs = &ad7997_8_scan_el_group,
-               .event_attrs = &ad7993_4_7_8_event_attrs_group,
-               .ad799x_set_scan_mode = ad7997_8_set_scan_mode,
+               .info = &ad7993_4_7_8_info,
        },
 };
 
@@ -772,16 +653,16 @@ static int __devinit ad799x_probe(struct i2c_client *client,
 {
        int ret, regdone = 0;
        struct ad799x_platform_data *pdata = client->dev.platform_data;
-       struct ad799x_state *st = kzalloc(sizeof(*st), GFP_KERNEL);
-       if (st == NULL) {
-               ret = -ENOMEM;
-               goto error_ret;
-       }
+       struct ad799x_state *st;
+       struct iio_dev *indio_dev = iio_allocate_device(sizeof(*st));
+
+       if (indio_dev == NULL)
+               return -ENOMEM;
 
+       st = iio_priv(indio_dev);
        /* this is only used for device removal purposes */
-       i2c_set_clientdata(client, st);
+       i2c_set_clientdata(client, indio_dev);
 
-       atomic_set(&st->protect_ring, 0);
        st->id = id->driver_data;
        st->chip_info = &ad799x_chip_info_tbl[st->id];
        st->config = st->chip_info->default_config;
@@ -801,94 +682,76 @@ static int __devinit ad799x_probe(struct i2c_client *client,
        }
        st->client = client;
 
-       st->indio_dev = iio_allocate_device();
-       if (st->indio_dev == NULL) {
-               ret = -ENOMEM;
-               goto error_disable_reg;
-       }
-
-       /* Estabilish that the iio_dev is a child of the i2c device */
-       st->indio_dev->dev.parent = &client->dev;
-       st->indio_dev->attrs = st->chip_info->dev_attrs;
-       st->indio_dev->event_attrs = st->chip_info->event_attrs;
+       indio_dev->dev.parent = &client->dev;
+       indio_dev->name = id->name;
+       indio_dev->info = st->chip_info->info;
+       indio_dev->name = id->name;
+       indio_dev->dev_data = (void *)(st);
 
-       st->indio_dev->dev_data = (void *)(st);
-       st->indio_dev->driver_module = THIS_MODULE;
-       st->indio_dev->modes = INDIO_DIRECT_MODE;
-       st->indio_dev->num_interrupt_lines = 1;
-
-       ret = ad799x_set_scan_mode(st, 0);
-       if (ret)
-               goto error_free_device;
+       indio_dev->modes = INDIO_DIRECT_MODE;
+       indio_dev->channels = st->chip_info->channel;
+       indio_dev->num_channels = st->chip_info->num_channels;
 
-       ret = ad799x_register_ring_funcs_and_init(st->indio_dev);
+       ret = ad799x_register_ring_funcs_and_init(indio_dev);
        if (ret)
-               goto error_free_device;
+               goto error_disable_reg;
 
-       ret = iio_device_register(st->indio_dev);
+       ret = iio_device_register(indio_dev);
        if (ret)
                goto error_cleanup_ring;
        regdone = 1;
 
-       ret = iio_ring_buffer_register(st->indio_dev->ring, 0);
+       ret = iio_ring_buffer_register_ex(indio_dev->ring, 0,
+                                         indio_dev->channels,
+                                         indio_dev->num_channels);
        if (ret)
                goto error_cleanup_ring;
 
-       if (client->irq > 0 && st->chip_info->monitor_mode) {
-               INIT_WORK(&st->work_thresh, ad799x_interrupt_bh);
-
-               ret = iio_register_interrupt_line(client->irq,
-                               st->indio_dev,
-                               0,
-                               IRQF_TRIGGER_FALLING,
-                               client->name);
+       if (client->irq > 0) {
+               ret = request_threaded_irq(client->irq,
+                                          NULL,
+                                          ad799x_event_handler,
+                                          IRQF_TRIGGER_FALLING |
+                                          IRQF_ONESHOT,
+                                          client->name,
+                                          indio_dev);
                if (ret)
                        goto error_cleanup_ring;
-
-               /*
-                * The event handler list element refer to iio_event_ad799x.
-                * All event attributes bind to the same event handler.
-                * So, only register event handler once.
-                */
-               iio_add_event_to_list(&iio_event_ad799x,
-                               &st->indio_dev->interrupts[0]->ev_list);
        }
 
        return 0;
+
 error_cleanup_ring:
-       ad799x_ring_cleanup(st->indio_dev);
-error_free_device:
-       if (!regdone)
-               iio_free_device(st->indio_dev);
-       else
-               iio_device_unregister(st->indio_dev);
+       ad799x_ring_cleanup(indio_dev);
 error_disable_reg:
        if (!IS_ERR(st->reg))
                regulator_disable(st->reg);
 error_put_reg:
        if (!IS_ERR(st->reg))
                regulator_put(st->reg);
-       kfree(st);
-error_ret:
+       if (regdone)
+               iio_device_unregister(indio_dev);
+       else
+               iio_free_device(indio_dev);
+
        return ret;
 }
 
 static __devexit int ad799x_remove(struct i2c_client *client)
 {
-       struct ad799x_state *st = i2c_get_clientdata(client);
-       struct iio_dev *indio_dev = st->indio_dev;
+       struct iio_dev *indio_dev = i2c_get_clientdata(client);
+       struct ad799x_state *st = iio_priv(indio_dev);
 
-       if (client->irq > 0 && st->chip_info->monitor_mode)
-               iio_unregister_interrupt_line(indio_dev, 0);
+       if (client->irq > 0)
+               free_irq(client->irq, indio_dev);
 
        iio_ring_buffer_unregister(indio_dev->ring);
        ad799x_ring_cleanup(indio_dev);
-       iio_device_unregister(indio_dev);
        if (!IS_ERR(st->reg)) {
                regulator_disable(st->reg);
                regulator_put(st->reg);
        }
-       kfree(st);
+       iio_device_unregister(indio_dev);
 
        return 0;
 }
index 0875a7ef67a54374c5fcd5a3754d9b35f1c234c1..1ae8857b3d25515750b971d17028ef9fb31236f9 100644 (file)
@@ -10,7 +10,6 @@
  */
 
 #include <linux/interrupt.h>
-#include <linux/workqueue.h>
 #include <linux/device.h>
 #include <linux/slab.h>
 #include <linux/kernel.h>
@@ -29,7 +28,7 @@
 
 int ad799x_single_channel_from_ring(struct ad799x_state *st, long mask)
 {
-       struct iio_ring_buffer *ring = st->indio_dev->ring;
+       struct iio_ring_buffer *ring = iio_priv_to_dev(st)->ring;
        int count = 0, ret;
        u16 *ring_data;
 
@@ -38,12 +37,13 @@ int ad799x_single_channel_from_ring(struct ad799x_state *st, long mask)
                goto error_ret;
        }
 
-       ring_data = kmalloc(ring->access.get_bytes_per_datum(ring), GFP_KERNEL);
+       ring_data = kmalloc(ring->access->get_bytes_per_datum(ring),
+                           GFP_KERNEL);
        if (ring_data == NULL) {
                ret = -ENOMEM;
                goto error_ret;
        }
-       ret = ring->access.read_last(ring, (u8 *) ring_data);
+       ret = ring->access->read_last(ring, (u8 *) ring_data);
        if (ret)
                goto error_free_ring_data;
        /* Need a count of channels prior to this one */
@@ -72,7 +72,7 @@ error_ret:
 static int ad799x_ring_preenable(struct iio_dev *indio_dev)
 {
        struct iio_ring_buffer *ring = indio_dev->ring;
-       struct ad799x_state *st = indio_dev->dev_data;
+       struct ad799x_state *st = iio_dev_get_devdata(indio_dev);
 
        /*
         * Need to figure out the current mode based upon the requested
@@ -80,7 +80,7 @@ static int ad799x_ring_preenable(struct iio_dev *indio_dev)
         */
 
        if (st->id == ad7997 || st->id == ad7998)
-               ad799x_set_scan_mode(st, ring->scan_mask);
+               ad7997_8_set_scan_mode(st, ring->scan_mask);
 
        st->d_size = ring->scan_count * 2;
 
@@ -91,56 +91,34 @@ static int ad799x_ring_preenable(struct iio_dev *indio_dev)
                        st->d_size += sizeof(s64) - (st->d_size % sizeof(s64));
        }
 
-       if (indio_dev->ring->access.set_bytes_per_datum)
-               indio_dev->ring->access.set_bytes_per_datum(indio_dev->ring,
+       if (indio_dev->ring->access->set_bytes_per_datum)
+               indio_dev->ring->access->set_bytes_per_datum(indio_dev->ring,
                                                            st->d_size);
 
        return 0;
 }
 
 /**
- * ad799x_poll_func_th() th of trigger launched polling to ring buffer
- *
- * As sampling only occurs on i2c comms occurring, leave timestamping until
- * then.  Some triggers will generate their own time stamp.  Currently
- * there is no way of notifying them when no one cares.
- **/
-static void ad799x_poll_func_th(struct iio_dev *indio_dev, s64 time)
-{
-       struct ad799x_state *st = indio_dev->dev_data;
-
-       schedule_work(&st->poll_work);
-
-       return;
-}
-/**
- * ad799x_poll_bh_to_ring() bh of trigger launched polling to ring buffer
- * @work_s:    the work struct through which this was scheduled
+ * ad799x_trigger_handler() bh of trigger launched polling to ring buffer
  *
  * Currently there is no option in this driver to disable the saving of
  * timestamps within the ring.
- * I think the one copy of this at a time was to avoid problems if the
- * trigger was set far too high and the reads then locked up the computer.
  **/
-static void ad799x_poll_bh_to_ring(struct work_struct *work_s)
+
+static irqreturn_t ad799x_trigger_handler(int irq, void *p)
 {
-       struct ad799x_state *st = container_of(work_s, struct ad799x_state,
-                                                 poll_work);
-       struct iio_dev *indio_dev = st->indio_dev;
+       struct iio_poll_func *pf = p;
+       struct iio_dev *indio_dev = pf->private_data;
+       struct ad799x_state *st = iio_dev_get_devdata(indio_dev);
        struct iio_ring_buffer *ring = indio_dev->ring;
-       struct iio_sw_ring_buffer *ring_sw = iio_to_sw_ring(indio_dev->ring);
        s64 time_ns;
        __u8 *rxbuf;
        int b_sent;
        u8 cmd;
 
-       /* Ensure only one copy of this function running at a time */
-       if (atomic_inc_return(&st->protect_ring) > 1)
-               return;
-
        rxbuf = kmalloc(st->d_size, GFP_KERNEL);
        if (rxbuf == NULL)
-               return;
+               goto out;
 
        switch (st->id) {
        case ad7991:
@@ -173,16 +151,25 @@ static void ad799x_poll_bh_to_ring(struct work_struct *work_s)
                memcpy(rxbuf + st->d_size - sizeof(s64),
                        &time_ns, sizeof(time_ns));
 
-       ring->access.store_to(&ring_sw->buf, rxbuf, time_ns);
+       ring->access->store_to(indio_dev->ring, rxbuf, time_ns);
 done:
        kfree(rxbuf);
-       atomic_dec(&st->protect_ring);
+       if (b_sent < 0)
+               return b_sent;
+out:
+       iio_trigger_notify_done(indio_dev->trig);
+
+       return IRQ_HANDLED;
 }
 
+static const struct iio_ring_setup_ops ad799x_buf_setup_ops = {
+       .preenable = &ad799x_ring_preenable,
+       .postenable = &iio_triggered_ring_postenable,
+       .predisable = &iio_triggered_ring_predisable,
+};
 
 int ad799x_register_ring_funcs_and_init(struct iio_dev *indio_dev)
 {
-       struct ad799x_state *st = indio_dev->dev_data;
        int ret = 0;
 
        indio_dev->ring = iio_sw_rb_allocate(indio_dev);
@@ -191,25 +178,27 @@ int ad799x_register_ring_funcs_and_init(struct iio_dev *indio_dev)
                goto error_ret;
        }
        /* Effectively select the ring buffer implementation */
-       iio_ring_sw_register_funcs(&st->indio_dev->ring->access);
-       ret = iio_alloc_pollfunc(indio_dev, NULL, &ad799x_poll_func_th);
-       if (ret)
+       indio_dev->ring->access = &ring_sw_access_funcs;
+       indio_dev->pollfunc = iio_alloc_pollfunc(NULL,
+                                                &ad799x_trigger_handler,
+                                                IRQF_ONESHOT,
+                                                indio_dev,
+                                                "%s_consumer%d",
+                                                indio_dev->name,
+                                                indio_dev->id);
+       if (indio_dev->pollfunc == NULL) {
+               ret = -ENOMEM;
                goto error_deallocate_sw_rb;
+       }
 
        /* Ring buffer functions - here trigger setup related */
-
-       indio_dev->ring->preenable = &ad799x_ring_preenable;
-       indio_dev->ring->postenable = &iio_triggered_ring_postenable;
-       indio_dev->ring->predisable = &iio_triggered_ring_predisable;
+       indio_dev->ring->setup_ops = &ad799x_buf_setup_ops;
        indio_dev->ring->scan_timestamp = true;
 
-       INIT_WORK(&st->poll_work, &ad799x_poll_bh_to_ring);
-
-       indio_dev->ring->scan_el_attrs = st->chip_info->scan_attrs;
-
        /* Flag that polled ring buffering is possible */
        indio_dev->modes |= INDIO_RING_TRIGGERED;
        return 0;
+
 error_deallocate_sw_rb:
        iio_sw_rb_free(indio_dev->ring);
 error_ret:
@@ -224,6 +213,6 @@ void ad799x_ring_cleanup(struct iio_dev *indio_dev)
                iio_trigger_dettach_poll_func(indio_dev->trig,
                                              indio_dev->pollfunc);
        }
-       kfree(indio_dev->pollfunc);
+       iio_dealloc_pollfunc(indio_dev->pollfunc);
        iio_sw_rb_free(indio_dev->ring);
 }
index 771a409ee94c71771c5dd2e18277f3363385667f..68eca0b99ac01d2eb0a183a7dfe8f5bb136accd7 100644 (file)
@@ -7,15 +7,12 @@
  */
 
 #include <linux/interrupt.h>
-#include <linux/gpio.h>
-#include <linux/workqueue.h>
 #include <linux/device.h>
 #include <linux/kernel.h>
 #include <linux/slab.h>
 #include <linux/sysfs.h>
 #include <linux/list.h>
 #include <linux/spi/spi.h>
-#include <linux/rtc.h>
 
 #include "../iio.h"
 #include "../sysfs.h"
  */
 
 struct adt7310_chip_info {
-       const char *name;
        struct spi_device *spi_dev;
        struct iio_dev *indio_dev;
-       struct work_struct thresh_work;
-       s64 last_timestamp;
        u8  config;
 };
 
@@ -380,24 +374,12 @@ static ssize_t adt7310_show_value(struct device *dev,
 
 static IIO_DEVICE_ATTR(value, S_IRUGO, adt7310_show_value, NULL, 0);
 
-static ssize_t adt7310_show_name(struct device *dev,
-               struct device_attribute *attr,
-               char *buf)
-{
-       struct iio_dev *dev_info = dev_get_drvdata(dev);
-       struct adt7310_chip_info *chip = dev_info->dev_data;
-       return sprintf(buf, "%s\n", chip->name);
-}
-
-static IIO_DEVICE_ATTR(name, S_IRUGO, adt7310_show_name, NULL, 0);
-
 static struct attribute *adt7310_attributes[] = {
        &iio_dev_attr_available_modes.dev_attr.attr,
        &iio_dev_attr_mode.dev_attr.attr,
        &iio_dev_attr_resolution.dev_attr.attr,
        &iio_dev_attr_id.dev_attr.attr,
        &iio_dev_attr_value.dev_attr.attr,
-       &iio_dev_attr_name.dev_attr.attr,
        NULL,
 };
 
@@ -405,53 +387,39 @@ static const struct attribute_group adt7310_attribute_group = {
        .attrs = adt7310_attributes,
 };
 
-/*
- * temperature bound events
- */
-
-#define IIO_EVENT_CODE_ADT7310_ABOVE_ALARM    IIO_BUFFER_EVENT_CODE(0)
-#define IIO_EVENT_CODE_ADT7310_BELLOW_ALARM   IIO_BUFFER_EVENT_CODE(1)
-#define IIO_EVENT_CODE_ADT7310_ABOVE_CRIT     IIO_BUFFER_EVENT_CODE(2)
-
-static void adt7310_interrupt_bh(struct work_struct *work_s)
+static irqreturn_t adt7310_event_handler(int irq, void *private)
 {
-       struct adt7310_chip_info *chip =
-               container_of(work_s, struct adt7310_chip_info, thresh_work);
+       struct iio_dev *indio_dev = private;
+       struct adt7310_chip_info *chip = iio_dev_get_devdata(indio_dev);
+       s64 timestamp = iio_get_time_ns();
        u8 status;
+       int ret;
 
-       if (adt7310_spi_read_byte(chip, ADT7310_STATUS, &status))
-               return;
+       ret = adt7310_spi_read_byte(chip, ADT7310_STATUS, &status);
+       if (ret)
+               return ret;
 
        if (status & ADT7310_STAT_T_HIGH)
-               iio_push_event(chip->indio_dev, 0,
-                       IIO_EVENT_CODE_ADT7310_ABOVE_ALARM,
-                       chip->last_timestamp);
+               iio_push_event(indio_dev, 0,
+                              IIO_UNMOD_EVENT_CODE(IIO_TEMP, 0,
+                                                   IIO_EV_TYPE_THRESH,
+                                                   IIO_EV_DIR_RISING),
+                              timestamp);
        if (status & ADT7310_STAT_T_LOW)
-               iio_push_event(chip->indio_dev, 0,
-                       IIO_EVENT_CODE_ADT7310_BELLOW_ALARM,
-                       chip->last_timestamp);
+               iio_push_event(indio_dev, 0,
+                              IIO_UNMOD_EVENT_CODE(IIO_TEMP, 0,
+                                                   IIO_EV_TYPE_THRESH,
+                                                   IIO_EV_DIR_FALLING),
+                              timestamp);
        if (status & ADT7310_STAT_T_CRIT)
-               iio_push_event(chip->indio_dev, 0,
-                       IIO_EVENT_CODE_ADT7310_ABOVE_CRIT,
-                       chip->last_timestamp);
+               iio_push_event(indio_dev, 0,
+                              IIO_UNMOD_EVENT_CODE(IIO_TEMP, 0,
+                                                   IIO_EV_TYPE_THRESH,
+                                                   IIO_EV_DIR_RISING),
+                       timestamp);
+       return IRQ_HANDLED;
 }
 
-static int adt7310_interrupt(struct iio_dev *dev_info,
-               int index,
-               s64 timestamp,
-               int no_test)
-{
-       struct adt7310_chip_info *chip = dev_info->dev_data;
-
-       chip->last_timestamp = timestamp;
-       schedule_work(&chip->thresh_work);
-
-       return 0;
-}
-
-IIO_EVENT_SH(adt7310, &adt7310_interrupt);
-IIO_EVENT_SH(adt7310_ct, &adt7310_interrupt);
-
 static ssize_t adt7310_show_event_mode(struct device *dev,
                struct device_attribute *attr,
                char *buf)
@@ -729,49 +697,62 @@ static inline ssize_t adt7310_set_t_hyst(struct device *dev,
        return len;
 }
 
-IIO_EVENT_ATTR_SH(event_mode, iio_event_adt7310,
-               adt7310_show_event_mode, adt7310_set_event_mode, 0);
-IIO_EVENT_ATTR_SH(available_event_modes, iio_event_adt7310,
-               adt7310_show_available_event_modes, NULL, 0);
-IIO_EVENT_ATTR_SH(fault_queue, iio_event_adt7310,
-               adt7310_show_fault_queue, adt7310_set_fault_queue, 0);
-IIO_EVENT_ATTR_SH(t_alarm_high, iio_event_adt7310,
-               adt7310_show_t_alarm_high, adt7310_set_t_alarm_high, 0);
-IIO_EVENT_ATTR_SH(t_alarm_low, iio_event_adt7310,
-               adt7310_show_t_alarm_low, adt7310_set_t_alarm_low, 0);
-IIO_EVENT_ATTR_SH(t_crit, iio_event_adt7310_ct,
-               adt7310_show_t_crit, adt7310_set_t_crit, 0);
-IIO_EVENT_ATTR_SH(t_hyst, iio_event_adt7310,
-               adt7310_show_t_hyst, adt7310_set_t_hyst, 0);
+static IIO_DEVICE_ATTR(event_mode,
+                      S_IRUGO | S_IWUSR,
+                      adt7310_show_event_mode, adt7310_set_event_mode, 0);
+static IIO_DEVICE_ATTR(available_event_modes,
+                      S_IRUGO | S_IWUSR,
+                      adt7310_show_available_event_modes, NULL, 0);
+static IIO_DEVICE_ATTR(fault_queue,
+                      S_IRUGO | S_IWUSR,
+                      adt7310_show_fault_queue, adt7310_set_fault_queue, 0);
+static IIO_DEVICE_ATTR(t_alarm_high,
+                      S_IRUGO | S_IWUSR,
+                      adt7310_show_t_alarm_high, adt7310_set_t_alarm_high, 0);
+static IIO_DEVICE_ATTR(t_alarm_low,
+                      S_IRUGO | S_IWUSR,
+                      adt7310_show_t_alarm_low, adt7310_set_t_alarm_low, 0);
+static IIO_DEVICE_ATTR(t_crit,
+                      S_IRUGO | S_IWUSR,
+                      adt7310_show_t_crit, adt7310_set_t_crit, 0);
+static IIO_DEVICE_ATTR(t_hyst,
+                      S_IRUGO | S_IWUSR,
+                      adt7310_show_t_hyst, adt7310_set_t_hyst, 0);
 
 static struct attribute *adt7310_event_int_attributes[] = {
-       &iio_event_attr_event_mode.dev_attr.attr,
-       &iio_event_attr_available_event_modes.dev_attr.attr,
-       &iio_event_attr_fault_queue.dev_attr.attr,
-       &iio_event_attr_t_alarm_high.dev_attr.attr,
-       &iio_event_attr_t_alarm_low.dev_attr.attr,
-       &iio_event_attr_t_hyst.dev_attr.attr,
+       &iio_dev_attr_event_mode.dev_attr.attr,
+       &iio_dev_attr_available_event_modes.dev_attr.attr,
+       &iio_dev_attr_fault_queue.dev_attr.attr,
+       &iio_dev_attr_t_alarm_high.dev_attr.attr,
+       &iio_dev_attr_t_alarm_low.dev_attr.attr,
+       &iio_dev_attr_t_hyst.dev_attr.attr,
        NULL,
 };
 
 static struct attribute *adt7310_event_ct_attributes[] = {
-       &iio_event_attr_event_mode.dev_attr.attr,
-       &iio_event_attr_available_event_modes.dev_attr.attr,
-       &iio_event_attr_fault_queue.dev_attr.attr,
-       &iio_event_attr_t_crit.dev_attr.attr,
-       &iio_event_attr_t_hyst.dev_attr.attr,
+       &iio_dev_attr_event_mode.dev_attr.attr,
+       &iio_dev_attr_available_event_modes.dev_attr.attr,
+       &iio_dev_attr_fault_queue.dev_attr.attr,
+       &iio_dev_attr_t_crit.dev_attr.attr,
+       &iio_dev_attr_t_hyst.dev_attr.attr,
        NULL,
 };
 
 static struct attribute_group adt7310_event_attribute_group[ADT7310_IRQS] = {
        {
                .attrs = adt7310_event_int_attributes,
-       },
-       {
+       }, {
                .attrs = adt7310_event_ct_attributes,
        }
 };
 
+static const struct iio_info adt7310_info = {
+       .attrs = &adt7310_attribute_group,
+       .num_interrupt_lines = ADT7310_IRQS,
+       .event_attrs = adt7310_event_attribute_group,
+       .driver_module = THIS_MODULE,
+};
+
 /*
  * device probe and remove
  */
@@ -792,20 +773,17 @@ static int __devinit adt7310_probe(struct spi_device *spi_dev)
        dev_set_drvdata(&spi_dev->dev, chip);
 
        chip->spi_dev = spi_dev;
-       chip->name = spi_dev->modalias;
 
-       chip->indio_dev = iio_allocate_device();
+       chip->indio_dev = iio_allocate_device(0);
        if (chip->indio_dev == NULL) {
                ret = -ENOMEM;
                goto error_free_chip;
        }
 
        chip->indio_dev->dev.parent = &spi_dev->dev;
-       chip->indio_dev->attrs = &adt7310_attribute_group;
-       chip->indio_dev->event_attrs = adt7310_event_attribute_group;
+       chip->indio_dev->name = spi_get_device_id(spi_dev)->name;
+       chip->indio_dev->info = &adt7310_info;
        chip->indio_dev->dev_data = (void *)chip;
-       chip->indio_dev->driver_module = THIS_MODULE;
-       chip->indio_dev->num_interrupt_lines = ADT7310_IRQS;
        chip->indio_dev->modes = INDIO_DIRECT_MODE;
 
        ret = iio_device_register(chip->indio_dev);
@@ -818,45 +796,29 @@ static int __devinit adt7310_probe(struct spi_device *spi_dev)
                        irq_flags = adt7310_platform_data[2];
                else
                        irq_flags = IRQF_TRIGGER_LOW;
-               ret = iio_register_interrupt_line(spi_dev->irq,
-                               chip->indio_dev,
-                               0,
-                               irq_flags,
-                               chip->name);
+               ret = request_threaded_irq(spi_dev->irq,
+                                          NULL,
+                                          &adt7310_event_handler,
+                                          irq_flags,
+                                          chip->indio_dev->name,
+                                          chip->indio_dev);
                if (ret)
                        goto error_unreg_dev;
-
-               /*
-                * The event handler list element refer to iio_event_adt7310.
-                * All event attributes bind to the same event handler.
-                * One event handler can only be added to one event list.
-                */
-               iio_add_event_to_list(&iio_event_adt7310,
-                               &chip->indio_dev->interrupts[0]->ev_list);
        }
 
        /* INT bound temperature alarm event. line 1 */
        if (adt7310_platform_data[0]) {
-               ret = iio_register_interrupt_line(adt7310_platform_data[0],
-                               chip->indio_dev,
-                               1,
-                               adt7310_platform_data[1],
-                               chip->name);
+               ret = request_threaded_irq(adt7310_platform_data[0],
+                                          NULL,
+                                          &adt7310_event_handler,
+                                          adt7310_platform_data[1],
+                                          chip->indio_dev->name,
+                                          chip->indio_dev);
                if (ret)
                        goto error_unreg_ct_irq;
-
-               /*
-                * The event handler list element refer to iio_event_adt7310.
-                * All event attributes bind to the same event handler.
-                * One event handler can only be added to one event list.
-                */
-               iio_add_event_to_list(&iio_event_adt7310_ct,
-                               &chip->indio_dev->interrupts[1]->ev_list);
        }
 
        if (spi_dev->irq && adt7310_platform_data[0]) {
-               INIT_WORK(&chip->thresh_work, adt7310_interrupt_bh);
-
                ret = adt7310_spi_read_byte(chip, ADT7310_CONFIG, &chip->config);
                if (ret) {
                        ret = -EIO;
@@ -879,14 +841,14 @@ static int __devinit adt7310_probe(struct spi_device *spi_dev)
        }
 
        dev_info(&spi_dev->dev, "%s temperature sensor registered.\n",
-                       chip->name);
+                       chip->indio_dev->name);
 
        return 0;
 
 error_unreg_int_irq:
-       iio_unregister_interrupt_line(chip->indio_dev, 1);
+       free_irq(adt7310_platform_data[0], chip->indio_dev);
 error_unreg_ct_irq:
-       iio_unregister_interrupt_line(chip->indio_dev, 0);
+       free_irq(spi_dev->irq, chip->indio_dev);
 error_unreg_dev:
        iio_device_unregister(chip->indio_dev);
 error_free_dev:
@@ -905,9 +867,9 @@ static int __devexit adt7310_remove(struct spi_device *spi_dev)
 
        dev_set_drvdata(&spi_dev->dev, NULL);
        if (adt7310_platform_data[0])
-               iio_unregister_interrupt_line(indio_dev, 1);
+               free_irq(adt7310_platform_data[0], chip->indio_dev);
        if (spi_dev->irq)
-               iio_unregister_interrupt_line(indio_dev, 0);
+               free_irq(spi_dev->irq, chip->indio_dev);
        iio_device_unregister(indio_dev);
        iio_free_device(chip->indio_dev);
        kfree(chip);
index c345f27ec7fc651f47cc09a837dabc92fe4c31f6..c40a84f9c2fff972d620cc7878c3576a3685afdf 100644 (file)
@@ -7,15 +7,12 @@
  */
 
 #include <linux/interrupt.h>
-#include <linux/gpio.h>
-#include <linux/workqueue.h>
 #include <linux/device.h>
 #include <linux/kernel.h>
 #include <linux/slab.h>
 #include <linux/sysfs.h>
 #include <linux/list.h>
 #include <linux/i2c.h>
-#include <linux/rtc.h>
 
 #include "../iio.h"
 #include "../sysfs.h"
  */
 
 struct adt7410_chip_info {
-       const char *name;
        struct i2c_client *client;
        struct iio_dev *indio_dev;
-       struct work_struct thresh_work;
-       s64 last_timestamp;
        u8  config;
 };
 
@@ -348,24 +342,12 @@ static ssize_t adt7410_show_value(struct device *dev,
 
 static IIO_DEVICE_ATTR(value, S_IRUGO, adt7410_show_value, NULL, 0);
 
-static ssize_t adt7410_show_name(struct device *dev,
-               struct device_attribute *attr,
-               char *buf)
-{
-       struct iio_dev *dev_info = dev_get_drvdata(dev);
-       struct adt7410_chip_info *chip = dev_info->dev_data;
-       return sprintf(buf, "%s\n", chip->name);
-}
-
-static IIO_DEVICE_ATTR(name, S_IRUGO, adt7410_show_name, NULL, 0);
-
 static struct attribute *adt7410_attributes[] = {
        &iio_dev_attr_available_modes.dev_attr.attr,
        &iio_dev_attr_mode.dev_attr.attr,
        &iio_dev_attr_resolution.dev_attr.attr,
        &iio_dev_attr_id.dev_attr.attr,
        &iio_dev_attr_value.dev_attr.attr,
-       &iio_dev_attr_name.dev_attr.attr,
        NULL,
 };
 
@@ -373,55 +355,38 @@ static const struct attribute_group adt7410_attribute_group = {
        .attrs = adt7410_attributes,
 };
 
-/*
- * temperature bound events
- */
-
-#define IIO_EVENT_CODE_ADT7410_ABOVE_ALARM    IIO_BUFFER_EVENT_CODE(0)
-#define IIO_EVENT_CODE_ADT7410_BELLOW_ALARM   IIO_BUFFER_EVENT_CODE(1)
-#define IIO_EVENT_CODE_ADT7410_ABOVE_CRIT     IIO_BUFFER_EVENT_CODE(2)
-
-static void adt7410_interrupt_bh(struct work_struct *work_s)
+static irqreturn_t adt7410_event_handler(int irq, void *private)
 {
-       struct adt7410_chip_info *chip =
-               container_of(work_s, struct adt7410_chip_info, thresh_work);
+       struct iio_dev *indio_dev = private;
+       struct adt7410_chip_info *chip = iio_dev_get_devdata(indio_dev);
+       s64 timestamp = iio_get_time_ns();
        u8 status;
 
        if (adt7410_i2c_read_byte(chip, ADT7410_STATUS, &status))
-               return;
-
-       enable_irq(chip->client->irq);
+               return IRQ_HANDLED;
 
        if (status & ADT7410_STAT_T_HIGH)
-               iio_push_event(chip->indio_dev, 0,
-                       IIO_EVENT_CODE_ADT7410_ABOVE_ALARM,
-                       chip->last_timestamp);
+               iio_push_event(indio_dev, 0,
+                              IIO_UNMOD_EVENT_CODE(IIO_TEMP, 0,
+                                                   IIO_EV_TYPE_THRESH,
+                                                   IIO_EV_DIR_RISING),
+                              timestamp);
        if (status & ADT7410_STAT_T_LOW)
-               iio_push_event(chip->indio_dev, 0,
-                       IIO_EVENT_CODE_ADT7410_BELLOW_ALARM,
-                       chip->last_timestamp);
+               iio_push_event(indio_dev, 0,
+                              IIO_UNMOD_EVENT_CODE(IIO_TEMP, 0,
+                                                   IIO_EV_TYPE_THRESH,
+                                                   IIO_EV_DIR_FALLING),
+                              timestamp);
        if (status & ADT7410_STAT_T_CRIT)
-               iio_push_event(chip->indio_dev, 0,
-                       IIO_EVENT_CODE_ADT7410_ABOVE_CRIT,
-                       chip->last_timestamp);
-}
+               iio_push_event(indio_dev, 0,
+                              IIO_UNMOD_EVENT_CODE(IIO_TEMP, 0,
+                                                   IIO_EV_TYPE_THRESH,
+                                                   IIO_EV_DIR_RISING),
+                              timestamp);
 
-static int adt7410_interrupt(struct iio_dev *dev_info,
-               int index,
-               s64 timestamp,
-               int no_test)
-{
-       struct adt7410_chip_info *chip = dev_info->dev_data;
-
-       chip->last_timestamp = timestamp;
-       schedule_work(&chip->thresh_work);
-
-       return 0;
+       return IRQ_HANDLED;
 }
 
-IIO_EVENT_SH(adt7410, &adt7410_interrupt);
-IIO_EVENT_SH(adt7410_ct, &adt7410_interrupt);
-
 static ssize_t adt7410_show_event_mode(struct device *dev,
                struct device_attribute *attr,
                char *buf)
@@ -699,49 +664,62 @@ static inline ssize_t adt7410_set_t_hyst(struct device *dev,
        return ret;
 }
 
-IIO_EVENT_ATTR_SH(event_mode, iio_event_adt7410,
-               adt7410_show_event_mode, adt7410_set_event_mode, 0);
-IIO_EVENT_ATTR_SH(available_event_modes, iio_event_adt7410,
-               adt7410_show_available_event_modes, NULL, 0);
-IIO_EVENT_ATTR_SH(fault_queue, iio_event_adt7410,
-               adt7410_show_fault_queue, adt7410_set_fault_queue, 0);
-IIO_EVENT_ATTR_SH(t_alarm_high, iio_event_adt7410,
-               adt7410_show_t_alarm_high, adt7410_set_t_alarm_high, 0);
-IIO_EVENT_ATTR_SH(t_alarm_low, iio_event_adt7410,
-               adt7410_show_t_alarm_low, adt7410_set_t_alarm_low, 0);
-IIO_EVENT_ATTR_SH(t_crit, iio_event_adt7410_ct,
-               adt7410_show_t_crit, adt7410_set_t_crit, 0);
-IIO_EVENT_ATTR_SH(t_hyst, iio_event_adt7410,
-               adt7410_show_t_hyst, adt7410_set_t_hyst, 0);
+static IIO_DEVICE_ATTR(event_mode,
+                      S_IRUGO | S_IWUSR,
+                      adt7410_show_event_mode, adt7410_set_event_mode, 0);
+static IIO_DEVICE_ATTR(available_event_modes,
+                      S_IRUGO,
+                      adt7410_show_available_event_modes, NULL, 0);
+static IIO_DEVICE_ATTR(fault_queue,
+                      S_IRUGO | S_IWUSR,
+                      adt7410_show_fault_queue, adt7410_set_fault_queue, 0);
+static IIO_DEVICE_ATTR(t_alarm_high,
+                      S_IRUGO | S_IWUSR,
+                      adt7410_show_t_alarm_high, adt7410_set_t_alarm_high, 0);
+static IIO_DEVICE_ATTR(t_alarm_low,
+                      S_IRUGO | S_IWUSR,
+                      adt7410_show_t_alarm_low, adt7410_set_t_alarm_low, 0);
+static IIO_DEVICE_ATTR(t_crit,
+                      S_IRUGO | S_IWUSR,
+                      adt7410_show_t_crit, adt7410_set_t_crit, 0);
+static IIO_DEVICE_ATTR(t_hyst,
+                      S_IRUGO | S_IWUSR,
+                      adt7410_show_t_hyst, adt7410_set_t_hyst, 0);
 
 static struct attribute *adt7410_event_int_attributes[] = {
-       &iio_event_attr_event_mode.dev_attr.attr,
-       &iio_event_attr_available_event_modes.dev_attr.attr,
-       &iio_event_attr_fault_queue.dev_attr.attr,
-       &iio_event_attr_t_alarm_high.dev_attr.attr,
-       &iio_event_attr_t_alarm_low.dev_attr.attr,
-       &iio_event_attr_t_hyst.dev_attr.attr,
+       &iio_dev_attr_event_mode.dev_attr.attr,
+       &iio_dev_attr_available_event_modes.dev_attr.attr,
+       &iio_dev_attr_fault_queue.dev_attr.attr,
+       &iio_dev_attr_t_alarm_high.dev_attr.attr,
+       &iio_dev_attr_t_alarm_low.dev_attr.attr,
+       &iio_dev_attr_t_hyst.dev_attr.attr,
        NULL,
 };
 
 static struct attribute *adt7410_event_ct_attributes[] = {
-       &iio_event_attr_event_mode.dev_attr.attr,
-       &iio_event_attr_available_event_modes.dev_attr.attr,
-       &iio_event_attr_fault_queue.dev_attr.attr,
-       &iio_event_attr_t_crit.dev_attr.attr,
-       &iio_event_attr_t_hyst.dev_attr.attr,
+       &iio_dev_attr_event_mode.dev_attr.attr,
+       &iio_dev_attr_available_event_modes.dev_attr.attr,
+       &iio_dev_attr_fault_queue.dev_attr.attr,
+       &iio_dev_attr_t_crit.dev_attr.attr,
+       &iio_dev_attr_t_hyst.dev_attr.attr,
        NULL,
 };
 
 static struct attribute_group adt7410_event_attribute_group[ADT7410_IRQS] = {
        {
                .attrs = adt7410_event_int_attributes,
-       },
-       {
+       }, {
                .attrs = adt7410_event_ct_attributes,
        }
 };
 
+static const struct iio_info adt7410_info = {
+       .attrs = &adt7410_attribute_group,
+       .num_interrupt_lines = ADT7410_IRQS,
+       .event_attrs = adt7410_event_attribute_group,
+       .driver_module = THIS_MODULE,
+};
+
 /*
  * device probe and remove
  */
@@ -762,20 +740,16 @@ static int __devinit adt7410_probe(struct i2c_client *client,
        i2c_set_clientdata(client, chip);
 
        chip->client = client;
-       chip->name = id->name;
 
-       chip->indio_dev = iio_allocate_device();
+       chip->indio_dev = iio_allocate_device(0);
        if (chip->indio_dev == NULL) {
                ret = -ENOMEM;
                goto error_free_chip;
        }
-
+       chip->indio_dev->name = id->name;
        chip->indio_dev->dev.parent = &client->dev;
-       chip->indio_dev->attrs = &adt7410_attribute_group;
-       chip->indio_dev->event_attrs = adt7410_event_attribute_group;
+       chip->indio_dev->info = &adt7410_info;
        chip->indio_dev->dev_data = (void *)chip;
-       chip->indio_dev->driver_module = THIS_MODULE;
-       chip->indio_dev->num_interrupt_lines = ADT7410_IRQS;
        chip->indio_dev->modes = INDIO_DIRECT_MODE;
 
        ret = iio_device_register(chip->indio_dev);
@@ -784,44 +758,29 @@ static int __devinit adt7410_probe(struct i2c_client *client,
 
        /* CT critcal temperature event. line 0 */
        if (client->irq) {
-               ret = iio_register_interrupt_line(client->irq,
-                               chip->indio_dev,
-                               0,
-                               IRQF_TRIGGER_LOW,
-                               chip->name);
+               ret = request_threaded_irq(client->irq,
+                                          NULL,
+                                          &adt7410_event_handler,
+                                          IRQF_TRIGGER_LOW,
+                                          id->name,
+                                          chip->indio_dev);
                if (ret)
                        goto error_unreg_dev;
-
-               /*
-                * The event handler list element refer to iio_event_adt7410.
-                * All event attributes bind to the same event handler.
-                * One event handler can only be added to one event list.
-                */
-               iio_add_event_to_list(&iio_event_adt7410,
-                               &chip->indio_dev->interrupts[0]->ev_list);
        }
 
        /* INT bound temperature alarm event. line 1 */
        if (adt7410_platform_data[0]) {
-               ret = iio_register_interrupt_line(adt7410_platform_data[0],
-                               chip->indio_dev,
-                               1,
-                               adt7410_platform_data[1],
-                               chip->name);
+               ret = request_threaded_irq(adt7410_platform_data[0],
+                                          NULL,
+                                          &adt7410_event_handler,
+                                          adt7410_platform_data[1],
+                                          id->name,
+                                          chip->indio_dev);
                if (ret)
                        goto error_unreg_ct_irq;
-
-               /*
-                * The event handler list element refer to iio_event_adt7410.
-                * All event attributes bind to the same event handler.
-                * One event handler can only be added to one event list.
-                */
-               iio_add_event_to_list(&iio_event_adt7410_ct,
-                               &chip->indio_dev->interrupts[1]->ev_list);
        }
 
        if (client->irq && adt7410_platform_data[0]) {
-               INIT_WORK(&chip->thresh_work, adt7410_interrupt_bh);
 
                ret = adt7410_i2c_read_byte(chip, ADT7410_CONFIG, &chip->config);
                if (ret) {
@@ -850,9 +809,9 @@ static int __devinit adt7410_probe(struct i2c_client *client,
        return 0;
 
 error_unreg_int_irq:
-       iio_unregister_interrupt_line(chip->indio_dev, 1);
+       free_irq(adt7410_platform_data[0], chip->indio_dev);
 error_unreg_ct_irq:
-       iio_unregister_interrupt_line(chip->indio_dev, 0);
+       free_irq(client->irq, chip->indio_dev);
 error_unreg_dev:
        iio_device_unregister(chip->indio_dev);
 error_free_dev:
@@ -870,9 +829,9 @@ static int __devexit adt7410_remove(struct i2c_client *client)
        unsigned long *adt7410_platform_data = client->dev.platform_data;
 
        if (adt7410_platform_data[0])
-               iio_unregister_interrupt_line(indio_dev, 1);
+               free_irq(adt7410_platform_data[0], chip->indio_dev);
        if (client->irq)
-               iio_unregister_interrupt_line(indio_dev, 0);
+               free_irq(client->irq, chip->indio_dev);
        iio_device_unregister(indio_dev);
        iio_free_device(chip->indio_dev);
        kfree(chip);
index aff4d31eb89c688dc9e70ce161d259f28367bb74..1171fb9c178f265fb135e5dbb377b79410261423 100644 (file)
@@ -7,15 +7,11 @@
  */
 
 #include <linux/interrupt.h>
-#include <linux/gpio.h>
-#include <linux/workqueue.h>
 #include <linux/device.h>
 #include <linux/kernel.h>
 #include <linux/slab.h>
 #include <linux/sysfs.h>
-#include <linux/list.h>
 #include <linux/i2c.h>
-#include <linux/rtc.h>
 
 #include "../iio.h"
 #include "../sysfs.h"
  */
 
 struct adt75_chip_info {
-       const char *name;
        struct i2c_client *client;
        struct iio_dev *indio_dev;
-       struct work_struct thresh_work;
-       s64 last_timestamp;
        u8  config;
 };
 
@@ -249,23 +242,11 @@ static ssize_t adt75_show_value(struct device *dev,
 
 static IIO_DEVICE_ATTR(value, S_IRUGO, adt75_show_value, NULL, 0);
 
-static ssize_t adt75_show_name(struct device *dev,
-               struct device_attribute *attr,
-               char *buf)
-{
-       struct iio_dev *dev_info = dev_get_drvdata(dev);
-       struct adt75_chip_info *chip = dev_info->dev_data;
-       return sprintf(buf, "%s\n", chip->name);
-}
-
-static IIO_DEVICE_ATTR(name, S_IRUGO, adt75_show_name, NULL, 0);
-
 static struct attribute *adt75_attributes[] = {
        &iio_dev_attr_available_modes.dev_attr.attr,
        &iio_dev_attr_mode.dev_attr.attr,
        &iio_dev_attr_oneshot.dev_attr.attr,
        &iio_dev_attr_value.dev_attr.attr,
-       &iio_dev_attr_name.dev_attr.attr,
        NULL,
 };
 
@@ -277,35 +258,20 @@ static const struct attribute_group adt75_attribute_group = {
  * temperature bound events
  */
 
-#define IIO_EVENT_CODE_ADT75_OTI    IIO_BUFFER_EVENT_CODE(0)
+#define IIO_EVENT_CODE_ADT75_OTI IIO_UNMOD_EVENT_CODE(IIO_EV_CLASS_TEMP, \
+                                                     0,                \
+                                                     IIO_EV_TYPE_THRESH, \
+                                                     IIO_EV_DIR_FALLING)
 
-static void adt75_interrupt_bh(struct work_struct *work_s)
+static irqreturn_t adt75_event_handler(int irq, void *private)
 {
-       struct adt75_chip_info *chip =
-               container_of(work_s, struct adt75_chip_info, thresh_work);
-
-       enable_irq(chip->client->irq);
+       iio_push_event(private, 0,
+                      IIO_EVENT_CODE_ADT75_OTI,
+                      iio_get_time_ns());
 
-       iio_push_event(chip->indio_dev, 0,
-                       IIO_EVENT_CODE_ADT75_OTI,
-                       chip->last_timestamp);
+       return IRQ_HANDLED;
 }
 
-static int adt75_interrupt(struct iio_dev *dev_info,
-               int index,
-               s64 timestamp,
-               int no_test)
-{
-       struct adt75_chip_info *chip = dev_info->dev_data;
-
-       chip->last_timestamp = timestamp;
-       schedule_work(&chip->thresh_work);
-
-       return 0;
-}
-
-IIO_EVENT_SH(adt75, &adt75_interrupt);
-
 static ssize_t adt75_show_oti_mode(struct device *dev,
                struct device_attribute *attr,
                char *buf)
@@ -458,16 +424,16 @@ static ssize_t adt75_set_fault_queue(struct device *dev,
 }
 static inline ssize_t adt75_show_t_bound(struct device *dev,
                struct device_attribute *attr,
-               u8 bound_reg,
                char *buf)
 {
+       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
        struct iio_dev *dev_info = dev_get_drvdata(dev);
        struct adt75_chip_info *chip = dev_info->dev_data;
        u16 data;
        char sign = ' ';
        int ret;
 
-       ret = adt75_i2c_read(chip, bound_reg, (u8 *)&data);
+       ret = adt75_i2c_read(chip, this_attr->address, (u8 *)&data);
        if (ret)
                return -EIO;
 
@@ -485,10 +451,10 @@ static inline ssize_t adt75_show_t_bound(struct device *dev,
 
 static inline ssize_t adt75_set_t_bound(struct device *dev,
                struct device_attribute *attr,
-               u8 bound_reg,
                const char *buf,
                size_t len)
 {
+       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
        struct iio_dev *dev_info = dev_get_drvdata(dev);
        struct adt75_chip_info *chip = dev_info->dev_data;
        long tmp1, tmp2;
@@ -525,67 +491,42 @@ static inline ssize_t adt75_set_t_bound(struct device *dev,
        data <<= ADT75_VALUE_OFFSET;
        data = swab16(data);
 
-       ret = adt75_i2c_write(chip, bound_reg, (u8)data);
+       ret = adt75_i2c_write(chip, this_attr->address, (u8)data);
        if (ret)
                return -EIO;
 
        return ret;
 }
 
-static ssize_t adt75_show_t_os(struct device *dev,
-               struct device_attribute *attr,
-               char *buf)
-{
-       return adt75_show_t_bound(dev, attr,
-                       ADT75_T_OS, buf);
-}
-
-static inline ssize_t adt75_set_t_os(struct device *dev,
-               struct device_attribute *attr,
-               const char *buf,
-               size_t len)
-{
-       return adt75_set_t_bound(dev, attr,
-                       ADT75_T_OS, buf, len);
-}
 
-static ssize_t adt75_show_t_hyst(struct device *dev,
-               struct device_attribute *attr,
-               char *buf)
-{
-       return adt75_show_t_bound(dev, attr,
-                       ADT75_T_HYST, buf);
-}
-
-static inline ssize_t adt75_set_t_hyst(struct device *dev,
-               struct device_attribute *attr,
-               const char *buf,
-               size_t len)
-{
-       return adt75_set_t_bound(dev, attr,
-                       ADT75_T_HYST, buf, len);
-}
-
-IIO_EVENT_ATTR_SH(oti_mode, iio_event_adt75,
-               adt75_show_oti_mode, adt75_set_oti_mode, 0);
-IIO_EVENT_ATTR_SH(available_oti_modes, iio_event_adt75,
-               adt75_show_available_oti_modes, NULL, 0);
-IIO_EVENT_ATTR_SH(smbus_alart, iio_event_adt75,
-               adt75_show_smbus_alart, adt75_set_smbus_alart, 0);
-IIO_EVENT_ATTR_SH(fault_queue, iio_event_adt75,
-               adt75_show_fault_queue, adt75_set_fault_queue, 0);
-IIO_EVENT_ATTR_SH(t_os, iio_event_adt75,
-               adt75_show_t_os, adt75_set_t_os, 0);
-IIO_EVENT_ATTR_SH(t_hyst, iio_event_adt75,
-               adt75_show_t_hyst, adt75_set_t_hyst, 0);
+static IIO_DEVICE_ATTR(oti_mode,
+                      S_IRUGO | S_IWUSR,
+                      adt75_show_oti_mode, adt75_set_oti_mode, 0);
+static IIO_DEVICE_ATTR(available_oti_modes,
+                      S_IRUGO,
+                      adt75_show_available_oti_modes, NULL, 0);
+static IIO_DEVICE_ATTR(smbus_alart,
+                      S_IRUGO | S_IWUSR,
+                      adt75_show_smbus_alart, adt75_set_smbus_alart, 0);
+static IIO_DEVICE_ATTR(fault_queue,
+                      S_IRUGO | S_IWUSR,
+                      adt75_show_fault_queue, adt75_set_fault_queue, 0);
+static IIO_DEVICE_ATTR(t_os_value,
+                      S_IRUGO | S_IWUSR,
+                      adt75_show_t_bound, adt75_set_t_bound,
+                      ADT75_T_OS);
+static IIO_DEVICE_ATTR(t_hyst_value,
+                      S_IRUGO | S_IWUSR,
+                      adt75_show_t_bound, adt75_set_t_bound,
+                      ADT75_T_HYST);
 
 static struct attribute *adt75_event_attributes[] = {
-       &iio_event_attr_oti_mode.dev_attr.attr,
-       &iio_event_attr_available_oti_modes.dev_attr.attr,
-       &iio_event_attr_smbus_alart.dev_attr.attr,
-       &iio_event_attr_fault_queue.dev_attr.attr,
-       &iio_event_attr_t_os.dev_attr.attr,
-       &iio_event_attr_t_hyst.dev_attr.attr,
+       &iio_dev_attr_oti_mode.dev_attr.attr,
+       &iio_dev_attr_available_oti_modes.dev_attr.attr,
+       &iio_dev_attr_smbus_alart.dev_attr.attr,
+       &iio_dev_attr_fault_queue.dev_attr.attr,
+       &iio_dev_attr_t_os_value.dev_attr.attr,
+       &iio_dev_attr_t_hyst_value.dev_attr.attr,
        NULL,
 };
 
@@ -593,6 +534,13 @@ static struct attribute_group adt75_event_attribute_group = {
        .attrs = adt75_event_attributes,
 };
 
+static const struct iio_info adt75_info = {
+       .attrs = &adt75_attribute_group,
+       .num_interrupt_lines = 1,
+       .event_attrs = &adt75_event_attribute_group,
+       .driver_module = THIS_MODULE,
+};
+
 /*
  * device probe and remove
  */
@@ -612,20 +560,17 @@ static int __devinit adt75_probe(struct i2c_client *client,
        i2c_set_clientdata(client, chip);
 
        chip->client = client;
-       chip->name = id->name;
 
-       chip->indio_dev = iio_allocate_device();
+       chip->indio_dev = iio_allocate_device(0);
        if (chip->indio_dev == NULL) {
                ret = -ENOMEM;
                goto error_free_chip;
        }
 
+       chip->indio_dev->name = id->name;
        chip->indio_dev->dev.parent = &client->dev;
-       chip->indio_dev->attrs = &adt75_attribute_group;
-       chip->indio_dev->event_attrs = &adt75_event_attribute_group;
+       chip->indio_dev->info = &adt75_info;
        chip->indio_dev->dev_data = (void *)chip;
-       chip->indio_dev->driver_module = THIS_MODULE;
-       chip->indio_dev->num_interrupt_lines = 1;
        chip->indio_dev->modes = INDIO_DIRECT_MODE;
 
        ret = iio_device_register(chip->indio_dev);
@@ -633,24 +578,15 @@ static int __devinit adt75_probe(struct i2c_client *client,
                goto error_free_dev;
 
        if (client->irq > 0) {
-               ret = iio_register_interrupt_line(client->irq,
-                               chip->indio_dev,
-                               0,
-                               IRQF_TRIGGER_LOW,
-                               chip->name);
+               ret = request_threaded_irq(client->irq,
+                                          NULL,
+                                          &adt75_event_handler,
+                                          IRQF_TRIGGER_LOW,
+                                          chip->indio_dev->name,
+                                          chip->indio_dev);
                if (ret)
                        goto error_unreg_dev;
 
-               /*
-                * The event handler list element refer to iio_event_adt75.
-                * All event attributes bind to the same event handler.
-                * So, only register event handler once.
-                */
-               iio_add_event_to_list(&iio_event_adt75,
-                               &chip->indio_dev->interrupts[0]->ev_list);
-
-               INIT_WORK(&chip->thresh_work, adt75_interrupt_bh);
-
                ret = adt75_i2c_read(chip, ADT75_CONFIG, &chip->config);
                if (ret) {
                        ret = -EIO;
@@ -668,11 +604,11 @@ static int __devinit adt75_probe(struct i2c_client *client,
        }
 
        dev_info(&client->dev, "%s temperature sensor registered.\n",
-                        id->name);
+                        chip->indio_dev->name);
 
        return 0;
 error_unreg_irq:
-       iio_unregister_interrupt_line(chip->indio_dev, 0);
+       free_irq(client->irq, chip->indio_dev);
 error_unreg_dev:
        iio_device_unregister(chip->indio_dev);
 error_free_dev:
@@ -689,7 +625,7 @@ static int __devexit adt75_remove(struct i2c_client *client)
        struct iio_dev *indio_dev = chip->indio_dev;
 
        if (client->irq)
-               iio_unregister_interrupt_line(indio_dev, 0);
+               free_irq(client->irq, chip->indio_dev);
        iio_device_unregister(indio_dev);
        iio_free_device(chip->indio_dev);
        kfree(chip);
index 8f0fe1ced2ced7618fa61b11a880ad79ffe18430..360bfc5398fc7d7c6d6d3192bf9621769af34f66 100644 (file)
@@ -67,70 +67,6 @@ struct max1363_mode {
        long            modemask;
 };
 
-#define MAX1363_MODE_SINGLE(_num, _mask) {                             \
-               .conf = MAX1363_CHANNEL_SEL(_num)                       \
-                       | MAX1363_CONFIG_SCAN_SINGLE_1                  \
-                       | MAX1363_CONFIG_SE,                            \
-                       .modemask = _mask,                              \
-                       }
-
-#define MAX1363_MODE_SCAN_TO_CHANNEL(_num, _mask) {                    \
-               .conf = MAX1363_CHANNEL_SEL(_num)                       \
-                       | MAX1363_CONFIG_SCAN_TO_CS                     \
-                       | MAX1363_CONFIG_SE,                            \
-                       .modemask = _mask,                              \
-                       }
-
-
-/* note not available for max1363 hence naming */
-#define MAX1236_MODE_SCAN_MID_TO_CHANNEL(_mid, _num, _mask) {          \
-               .conf = MAX1363_CHANNEL_SEL(_num)                       \
-                       | MAX1236_SCAN_MID_TO_CHANNEL                   \
-                       | MAX1363_CONFIG_SE,                            \
-                       .modemask = _mask                               \
-}
-
-#define MAX1363_MODE_DIFF_SINGLE(_nump, _numm, _mask) {                        \
-               .conf = MAX1363_CHANNEL_SEL(_nump)                      \
-                       | MAX1363_CONFIG_SCAN_SINGLE_1                  \
-                       | MAX1363_CONFIG_DE,                            \
-                       .modemask = _mask                               \
-                       }
-
-/* Can't think how to automate naming so specify for now */
-#define MAX1363_MODE_DIFF_SCAN_TO_CHANNEL(_num, _numvals, _mask) { \
-               .conf = MAX1363_CHANNEL_SEL(_num)                       \
-                       | MAX1363_CONFIG_SCAN_TO_CS                     \
-                       | MAX1363_CONFIG_DE,                            \
-                       .modemask = _mask                               \
-                       }
-
-/* note only available for max1363 hence naming */
-#define MAX1236_MODE_DIFF_SCAN_MID_TO_CHANNEL(_num, _numvals, _mask) { \
-               .conf = MAX1363_CHANNEL_SEL(_num)                       \
-                       | MAX1236_SCAN_MID_TO_CHANNEL                   \
-                       | MAX1363_CONFIG_SE,                            \
-                       .modemask = _mask                               \
-}
-
-/* This may seem an overly long winded way to do this, but at least it makes
- * clear what all the various options actually do. Alternative suggestions
- * that don't require user to have intimate knowledge of the chip welcomed.
- */
-enum max1363_channels {
-       max1363_in0, max1363_in1, max1363_in2, max1363_in3,
-       max1363_in4, max1363_in5, max1363_in6, max1363_in7,
-       max1363_in8, max1363_in9, max1363_in10, max1363_in11,
-
-       max1363_in0min1, max1363_in2min3,
-       max1363_in4min5, max1363_in6min7,
-       max1363_in8min9, max1363_in10min11,
-
-       max1363_in1min0, max1363_in3min2,
-       max1363_in5min4, max1363_in7min6,
-       max1363_in9min8, max1363_in11min10,
-};
-
 /* This must be maintained along side the max1363_mode_table in max1363_core */
 enum max1363_modes {
        /* Single read of a single channel */
@@ -152,37 +88,34 @@ enum max1363_modes {
 /**
  * struct max1363_chip_info - chip specifc information
  * @name:              indentification string for chip
- * @num_inputs:                number of physical inputs on chip
  * @bits:              accuracy of the adc in bits
  * @int_vref_mv:       the internal reference voltage
- * @monitor_mode:      whether the chip supports monitor interrupts
+ * @info:              iio core function callbacks structure
  * @mode_list:         array of available scan modes
  * @num_modes:         the number of scan modes available
  * @default_mode:      the scan mode in which the chip starts up
+ * @channel:           channel specification
+ * @num_channels:      number of channels
  */
 struct max1363_chip_info {
-       u8                              num_inputs;
-       u8                              bits;
-       u16                             int_vref_mv;
-       bool                            monitor_mode;
+       const struct iio_info           *info;
+       struct iio_chan_spec *channels;
+       int num_channels;
        const enum max1363_modes        *mode_list;
-       int                             num_modes;
        enum max1363_modes              default_mode;
-       struct attribute_group          *dev_attrs;
-       struct attribute_group          *scan_attrs;
+       u16                             int_vref_mv;
+       u8                              num_modes;
+       u8                              bits;
 };
 
 /**
  * struct max1363_state - driver instance specific data
- * @indio_dev:         the industrial I/O device
  * @client:            i2c_client
  * @setupbyte:         cache of current device setup byte
  * @configbyte:                cache of current device config byte
  * @chip_info:         chip model specific constants, available modes etc
  * @current_mode:      the scan mode of this chip
  * @requestedmask:     a valid requested set of channels
- * @poll_work:         bottom half of polling interrupt handler
- * @protect_ring:      used to ensure only one polling bh running at a time
  * @reg:               supply regulator
  * @monitor_on:                whether monitor mode is enabled
  * @monitor_speed:     parameter corresponding to device monitor speed setting
@@ -190,20 +123,14 @@ struct max1363_chip_info {
  * @mask_low:          bitmask for enabled low thresholds
  * @thresh_high:       high threshold values
  * @thresh_low:                low threshold values
- * @last_timestamp:    timestamp of last event interrupt
- * @thresh_work:       bh work structure for event handling
  */
 struct max1363_state {
-       struct iio_dev                  *indio_dev;
        struct i2c_client               *client;
        u8                              setupbyte;
        u8                              configbyte;
        const struct max1363_chip_info  *chip_info;
        const struct max1363_mode       *current_mode;
        u32                             requestedmask;
-       struct work_struct              poll_work;
-       atomic_t                        protect_ring;
-       struct iio_trigger              *trig;
        struct regulator                *reg;
 
        /* Using monitor modes and buffer at the same time is
@@ -215,8 +142,6 @@ struct max1363_state {
        /* 4x unipolar first then the fours bipolar ones */
        s16                             thresh_high[8];
        s16                             thresh_low[8];
-       s64                             last_timestamp;
-       struct work_struct              thresh_work;
 };
 
 const struct max1363_mode
index de83c3b37a2d39001fe844ce5d63033c4724888e..98cebd26310f0f05321d2df5a4c8c49690b4fc4e 100644 (file)
@@ -22,7 +22,6 @@
   */
 
 #include <linux/interrupt.h>
-#include <linux/workqueue.h>
 #include <linux/device.h>
 #include <linux/kernel.h>
 #include <linux/sysfs.h>
 #include "adc.h"
 #include "max1363.h"
 
-/* Here we claim all are 16 bits. This currently does no harm and saves
- * us a lot of scan element listings */
-
-#define MAX1363_SCAN_EL(number)                                \
-       IIO_SCAN_EL_C(in##number, number, 0, NULL);
-#define MAX1363_SCAN_EL_D(p, n, number)                                        \
-       IIO_SCAN_NAMED_EL_C(in##p##m##in##n, in##p-in##n, number, 0, NULL);
-
-static MAX1363_SCAN_EL(0);
-static MAX1363_SCAN_EL(1);
-static MAX1363_SCAN_EL(2);
-static MAX1363_SCAN_EL(3);
-static MAX1363_SCAN_EL(4);
-static MAX1363_SCAN_EL(5);
-static MAX1363_SCAN_EL(6);
-static MAX1363_SCAN_EL(7);
-static MAX1363_SCAN_EL(8);
-static MAX1363_SCAN_EL(9);
-static MAX1363_SCAN_EL(10);
-static MAX1363_SCAN_EL(11);
-static MAX1363_SCAN_EL_D(0, 1, 12);
-static MAX1363_SCAN_EL_D(2, 3, 13);
-static MAX1363_SCAN_EL_D(4, 5, 14);
-static MAX1363_SCAN_EL_D(6, 7, 15);
-static MAX1363_SCAN_EL_D(8, 9, 16);
-static MAX1363_SCAN_EL_D(10, 11, 17);
-static MAX1363_SCAN_EL_D(1, 0, 18);
-static MAX1363_SCAN_EL_D(3, 2, 19);
-static MAX1363_SCAN_EL_D(5, 4, 20);
-static MAX1363_SCAN_EL_D(7, 6, 21);
-static MAX1363_SCAN_EL_D(9, 8, 22);
-static MAX1363_SCAN_EL_D(11, 10, 23);
+#define MAX1363_MODE_SINGLE(_num, _mask) {                             \
+               .conf = MAX1363_CHANNEL_SEL(_num)                       \
+                       | MAX1363_CONFIG_SCAN_SINGLE_1                  \
+                       | MAX1363_CONFIG_SE,                            \
+                       .modemask = _mask,                              \
+                       }
+
+#define MAX1363_MODE_SCAN_TO_CHANNEL(_num, _mask) {                    \
+               .conf = MAX1363_CHANNEL_SEL(_num)                       \
+                       | MAX1363_CONFIG_SCAN_TO_CS                     \
+                       | MAX1363_CONFIG_SE,                            \
+                       .modemask = _mask,                              \
+                       }
+
+/* note not available for max1363 hence naming */
+#define MAX1236_MODE_SCAN_MID_TO_CHANNEL(_mid, _num, _mask) {          \
+               .conf = MAX1363_CHANNEL_SEL(_num)                       \
+                       | MAX1236_SCAN_MID_TO_CHANNEL                   \
+                       | MAX1363_CONFIG_SE,                            \
+                       .modemask = _mask                               \
+}
+
+#define MAX1363_MODE_DIFF_SINGLE(_nump, _numm, _mask) {                        \
+               .conf = MAX1363_CHANNEL_SEL(_nump)                      \
+                       | MAX1363_CONFIG_SCAN_SINGLE_1                  \
+                       | MAX1363_CONFIG_DE,                            \
+                       .modemask = _mask                               \
+                       }
+
+/* Can't think how to automate naming so specify for now */
+#define MAX1363_MODE_DIFF_SCAN_TO_CHANNEL(_num, _numvals, _mask) {     \
+               .conf = MAX1363_CHANNEL_SEL(_num)                       \
+                       | MAX1363_CONFIG_SCAN_TO_CS                     \
+                       | MAX1363_CONFIG_DE,                            \
+                       .modemask = _mask                               \
+                       }
+
+/* note only available for max1363 hence naming */
+#define MAX1236_MODE_DIFF_SCAN_MID_TO_CHANNEL(_num, _numvals, _mask) { \
+               .conf = MAX1363_CHANNEL_SEL(_num)                       \
+                       | MAX1236_SCAN_MID_TO_CHANNEL                   \
+                       | MAX1363_CONFIG_SE,                            \
+                       .modemask = _mask                               \
+}
 
 static const struct max1363_mode max1363_mode_table[] = {
        /* All of the single channel options first */
@@ -147,76 +158,13 @@ const struct max1363_mode
        return NULL;
 }
 
-static ssize_t max1363_show_precision_u(struct device *dev,
-                               struct device_attribute *attr,
-                               char *buf)
-{
-       struct iio_ring_buffer *ring = dev_get_drvdata(dev);
-       struct iio_dev *dev_info = ring->indio_dev;
-       struct max1363_state *st = iio_dev_get_devdata(dev_info);
-       return sprintf(buf, "u%d/16\n", st->chip_info->bits);
-}
-
-static ssize_t max1363_show_precision_s(struct device *dev,
-                               struct device_attribute *attr,
-                               char *buf)
-{
-       struct iio_ring_buffer *ring = dev_get_drvdata(dev);
-       struct iio_dev *dev_info = ring->indio_dev;
-       struct max1363_state *st = iio_dev_get_devdata(dev_info);
-       return sprintf(buf, "s%d/16\n", st->chip_info->bits);
-}
-
-#define MAX1363_SCAN_TYPE(n)                                           \
-       DEVICE_ATTR(in##n##_type, S_IRUGO,                              \
-                   max1363_show_precision_u, NULL);
-#define MAX1363_SCAN_TYPE_D(p, n)                                      \
-       struct device_attribute dev_attr_in##p##m##in##n##_type =       \
-               __ATTR(in##p-in##n##_type, S_IRUGO,                     \
-                      max1363_show_precision_s, NULL);
-
-static MAX1363_SCAN_TYPE(0);
-static MAX1363_SCAN_TYPE(1);
-static MAX1363_SCAN_TYPE(2);
-static MAX1363_SCAN_TYPE(3);
-static MAX1363_SCAN_TYPE(4);
-static MAX1363_SCAN_TYPE(5);
-static MAX1363_SCAN_TYPE(6);
-static MAX1363_SCAN_TYPE(7);
-static MAX1363_SCAN_TYPE(8);
-static MAX1363_SCAN_TYPE(9);
-static MAX1363_SCAN_TYPE(10);
-static MAX1363_SCAN_TYPE(11);
-
-static MAX1363_SCAN_TYPE_D(0, 1);
-static MAX1363_SCAN_TYPE_D(2, 3);
-static MAX1363_SCAN_TYPE_D(4, 5);
-static MAX1363_SCAN_TYPE_D(6, 7);
-static MAX1363_SCAN_TYPE_D(8, 9);
-static MAX1363_SCAN_TYPE_D(10, 11);
-static MAX1363_SCAN_TYPE_D(1, 0);
-static MAX1363_SCAN_TYPE_D(3, 2);
-static MAX1363_SCAN_TYPE_D(5, 4);
-static MAX1363_SCAN_TYPE_D(7, 6);
-static MAX1363_SCAN_TYPE_D(9, 8);
-static MAX1363_SCAN_TYPE_D(11, 10);
-
 static int max1363_write_basic_config(struct i2c_client *client,
                                      unsigned char d1,
                                      unsigned char d2)
 {
-       int ret;
-       u8 *tx_buf = kmalloc(2, GFP_KERNEL);
-
-       if (!tx_buf)
-               return -ENOMEM;
-       tx_buf[0] = d1;
-       tx_buf[1] = d2;
+       u8 tx_buf[2] = {d1, d2};
 
-       ret = i2c_master_send(client, tx_buf, 2);
-       kfree(tx_buf);
-
-       return (ret > 0) ? 0 : ret;
+       return i2c_master_send(client, tx_buf, 2);
 }
 
 int max1363_set_scan_mode(struct max1363_state *st)
@@ -231,20 +179,19 @@ int max1363_set_scan_mode(struct max1363_state *st)
                                          st->configbyte);
 }
 
-static ssize_t max1363_read_single_channel(struct device *dev,
-                                  struct device_attribute *attr,
-                                  char *buf)
+static int max1363_read_single_chan(struct iio_dev *indio_dev,
+                                   struct iio_chan_spec const *chan,
+                                   int *val,
+                                   long m)
 {
-       struct iio_dev *dev_info = dev_get_drvdata(dev);
-       struct max1363_state *st = iio_dev_get_devdata(dev_info);
-       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-       struct i2c_client *client = st->client;
-       int ret = 0, len = 0;
-       s32 data ;
+       int ret = 0;
+       s32 data;
        char rxbuf[2];
        long mask;
+       struct max1363_state *st = iio_priv(indio_dev);
+       struct i2c_client *client = st->client;
 
-       mutex_lock(&dev_info->mlock);
+       mutex_lock(&indio_dev->mlock);
        /*
         * If monitor mode is enabled, the method for reading a single
         * channel will have to be rather different and has not yet
@@ -256,8 +203,8 @@ static ssize_t max1363_read_single_channel(struct device *dev,
        }
 
        /* If ring buffer capture is occurring, query the buffer */
-       if (iio_ring_enabled(dev_info)) {
-               mask = max1363_mode_table[this_attr->address].modemask;
+       if (iio_ring_enabled(indio_dev)) {
+               mask = max1363_mode_table[chan->address].modemask;
                data = max1363_single_channel_from_ring(mask, st);
                if (data < 0) {
                        ret = data;
@@ -265,13 +212,11 @@ static ssize_t max1363_read_single_channel(struct device *dev,
                }
        } else {
                /* Check to see if current scan mode is correct */
-               if (st->current_mode !=
-                   &max1363_mode_table[this_attr->address]) {
+               if (st->current_mode != &max1363_mode_table[chan->address]) {
                        /* Update scan mode if needed */
-                       st->current_mode
-                               = &max1363_mode_table[this_attr->address];
+                       st->current_mode = &max1363_mode_table[chan->address];
                        ret = max1363_set_scan_mode(st);
-                       if (ret)
+                       if (ret < 0)
                                goto error_ret;
                }
                if (st->chip_info->bits != 8) {
@@ -281,7 +226,6 @@ static ssize_t max1363_read_single_channel(struct device *dev,
                                ret = data;
                                goto error_ret;
                        }
-
                        data = (s32)(rxbuf[1]) | ((s32)(rxbuf[0] & 0x0F)) << 8;
                } else {
                        /* Get reading */
@@ -293,72 +237,44 @@ static ssize_t max1363_read_single_channel(struct device *dev,
                        data = rxbuf[0];
                }
        }
-       /* Pretty print the result */
-       len = sprintf(buf, "%u\n", data);
-
+       *val = data;
 error_ret:
-       mutex_unlock(&dev_info->mlock);
-       return ret ? ret : len;
-}
+       mutex_unlock(&indio_dev->mlock);
+       return ret;
 
-/* Direct read attribtues */
-static IIO_DEV_ATTR_IN_RAW(0, max1363_read_single_channel, _s0);
-static IIO_DEV_ATTR_IN_RAW(1, max1363_read_single_channel, _s1);
-static IIO_DEV_ATTR_IN_RAW(2, max1363_read_single_channel, _s2);
-static IIO_DEV_ATTR_IN_RAW(3, max1363_read_single_channel, _s3);
-static IIO_DEV_ATTR_IN_RAW(4, max1363_read_single_channel, _s4);
-static IIO_DEV_ATTR_IN_RAW(5, max1363_read_single_channel, _s5);
-static IIO_DEV_ATTR_IN_RAW(6, max1363_read_single_channel, _s6);
-static IIO_DEV_ATTR_IN_RAW(7, max1363_read_single_channel, _s7);
-static IIO_DEV_ATTR_IN_RAW(8, max1363_read_single_channel, _s8);
-static IIO_DEV_ATTR_IN_RAW(9, max1363_read_single_channel, _s9);
-static IIO_DEV_ATTR_IN_RAW(10, max1363_read_single_channel, _s10);
-static IIO_DEV_ATTR_IN_RAW(11, max1363_read_single_channel, _s11);
-
-static IIO_DEV_ATTR_IN_DIFF_RAW(0, 1, max1363_read_single_channel, d0m1);
-static IIO_DEV_ATTR_IN_DIFF_RAW(2, 3, max1363_read_single_channel, d2m3);
-static IIO_DEV_ATTR_IN_DIFF_RAW(4, 5, max1363_read_single_channel, d4m5);
-static IIO_DEV_ATTR_IN_DIFF_RAW(6, 7, max1363_read_single_channel, d6m7);
-static IIO_DEV_ATTR_IN_DIFF_RAW(8, 9, max1363_read_single_channel, d8m9);
-static IIO_DEV_ATTR_IN_DIFF_RAW(10, 11, max1363_read_single_channel, d10m11);
-static IIO_DEV_ATTR_IN_DIFF_RAW(1, 0, max1363_read_single_channel, d1m0);
-static IIO_DEV_ATTR_IN_DIFF_RAW(3, 2, max1363_read_single_channel, d3m2);
-static IIO_DEV_ATTR_IN_DIFF_RAW(5, 4, max1363_read_single_channel, d5m4);
-static IIO_DEV_ATTR_IN_DIFF_RAW(7, 6, max1363_read_single_channel, d7m6);
-static IIO_DEV_ATTR_IN_DIFF_RAW(9, 8, max1363_read_single_channel, d9m8);
-static IIO_DEV_ATTR_IN_DIFF_RAW(11, 10, max1363_read_single_channel, d11m10);
-
-
-static ssize_t max1363_show_scale(struct device *dev,
-                               struct device_attribute *attr,
-                               char *buf)
-{
-       /* Driver currently only support internal vref */
-       struct iio_dev *dev_info = dev_get_drvdata(dev);
-       struct max1363_state *st = iio_dev_get_devdata(dev_info);
-       /* Corresponds to Vref / 2^(bits) */
-
-       if ((1 << (st->chip_info->bits + 1))
-           > st->chip_info->int_vref_mv)
-               return sprintf(buf, "0.5\n");
-       else
-               return sprintf(buf, "%d\n",
-                       st->chip_info->int_vref_mv >> st->chip_info->bits);
 }
 
-static IIO_DEVICE_ATTR(in_scale, S_IRUGO, max1363_show_scale, NULL, 0);
-
-static ssize_t max1363_show_name(struct device *dev,
-                                struct device_attribute *attr,
-                                char *buf)
+static int max1363_read_raw(struct iio_dev *indio_dev,
+                           struct iio_chan_spec const *chan,
+                           int *val,
+                           int *val2,
+                           long m)
 {
-       struct iio_dev *dev_info = dev_get_drvdata(dev);
-       struct max1363_state *st = iio_dev_get_devdata(dev_info);
-       return sprintf(buf, "%s\n", st->client->name);
+       struct max1363_state *st = iio_priv(indio_dev);
+       int ret;
+       switch (m) {
+       case 0:
+               ret = max1363_read_single_chan(indio_dev, chan, val, m);
+               if (ret)
+                       return ret;
+               return IIO_VAL_INT;
+       case (1 << IIO_CHAN_INFO_SCALE_SHARED):
+               if ((1 << (st->chip_info->bits + 1)) >
+                   st->chip_info->int_vref_mv) {
+                       *val = 0;
+                       *val2 = 500000;
+                       return IIO_VAL_INT_PLUS_MICRO;
+               } else {
+                       *val = (st->chip_info->int_vref_mv)
+                               >> st->chip_info->bits;
+                       return IIO_VAL_INT;
+               }
+       default:
+               return -EINVAL;
+       }
+       return 0;
 }
 
-static IIO_DEVICE_ATTR(name, S_IRUGO, max1363_show_name, NULL, 0);
-
 /* Applies to max1363 */
 static const enum max1363_modes max1363_mode_list[] = {
        _s0, _s1, _s2, _s3,
@@ -367,48 +283,76 @@ static const enum max1363_modes max1363_mode_list[] = {
        d0m1to2m3, d1m0to3m2,
 };
 
-static struct attribute *max1363_device_attrs[] = {
-       &iio_dev_attr_in0_raw.dev_attr.attr,
-       &iio_dev_attr_in1_raw.dev_attr.attr,
-       &iio_dev_attr_in2_raw.dev_attr.attr,
-       &iio_dev_attr_in3_raw.dev_attr.attr,
-       &iio_dev_attr_in0min1_raw.dev_attr.attr,
-       &iio_dev_attr_in2min3_raw.dev_attr.attr,
-       &iio_dev_attr_in1min0_raw.dev_attr.attr,
-       &iio_dev_attr_in3min2_raw.dev_attr.attr,
-       &iio_dev_attr_name.dev_attr.attr,
-       &iio_dev_attr_in_scale.dev_attr.attr,
-       NULL
+#define MAX1363_EV_M                                           \
+       (IIO_EV_BIT(IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING)      \
+        | IIO_EV_BIT(IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING))
+#define MAX1363_INFO_MASK (1 << IIO_CHAN_INFO_SCALE_SHARED)
+
+static struct iio_chan_spec max1363_channels[] = {
+       IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 0, 0, MAX1363_INFO_MASK,
+                _s0, 0, IIO_ST('u', 12, 16, 0), MAX1363_EV_M),
+       IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 1, 0, MAX1363_INFO_MASK,
+                _s1, 1, IIO_ST('u', 12, 16, 0), MAX1363_EV_M),
+       IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 2, 0, MAX1363_INFO_MASK,
+                _s2, 2, IIO_ST('u', 12, 16, 0), MAX1363_EV_M),
+       IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 3, 0, MAX1363_INFO_MASK,
+                _s3, 3, IIO_ST('u', 12, 16, 0), MAX1363_EV_M),
+       IIO_CHAN(IIO_IN_DIFF, 0, 1, 0, NULL, 0, 1, MAX1363_INFO_MASK,
+                d0m1, 4, IIO_ST('s', 12, 16, 0), MAX1363_EV_M),
+       IIO_CHAN(IIO_IN_DIFF, 0, 1, 0, NULL, 2, 3, MAX1363_INFO_MASK,
+                d2m3, 5, IIO_ST('s', 12, 16, 0), MAX1363_EV_M),
+       IIO_CHAN(IIO_IN_DIFF, 0, 1, 0, NULL, 1, 0, MAX1363_INFO_MASK,
+                d1m0, 6, IIO_ST('s', 12, 16, 0), MAX1363_EV_M),
+       IIO_CHAN(IIO_IN_DIFF, 0, 1, 0, NULL, 3, 2, MAX1363_INFO_MASK,
+                d3m2, 7, IIO_ST('s', 12, 16, 0), MAX1363_EV_M),
+       IIO_CHAN_SOFT_TIMESTAMP(8)
 };
 
-static struct attribute_group max1363_dev_attr_group = {
-       .attrs = max1363_device_attrs,
+static struct iio_chan_spec max1361_channels[] = {
+       IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 0, 0, MAX1363_INFO_MASK,
+                _s0, 0, IIO_ST('u', 10, 16, 0), MAX1363_EV_M),
+       IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 1, 0, MAX1363_INFO_MASK,
+                _s1, 1, IIO_ST('u', 10, 16, 0), MAX1363_EV_M),
+       IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 2, 0, MAX1363_INFO_MASK,
+                _s2, 2, IIO_ST('u', 10, 16, 0), MAX1363_EV_M),
+       IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 3, 0, MAX1363_INFO_MASK,
+                _s3, 3, IIO_ST('u', 10, 16, 0), MAX1363_EV_M),
+       IIO_CHAN(IIO_IN_DIFF, 0, 1, 0, NULL, 0, 1, MAX1363_INFO_MASK,
+                d0m1, 4, IIO_ST('s', 10, 16, 0), MAX1363_EV_M),
+       IIO_CHAN(IIO_IN_DIFF, 0, 1, 0, NULL, 2, 3, MAX1363_INFO_MASK,
+                d2m3, 5, IIO_ST('s', 10, 16, 0), MAX1363_EV_M),
+       IIO_CHAN(IIO_IN_DIFF, 0, 1, 0, NULL, 1, 0, MAX1363_INFO_MASK,
+                d1m0, 6, IIO_ST('s', 10, 16, 0), MAX1363_EV_M),
+       IIO_CHAN(IIO_IN_DIFF, 0, 1, 0, NULL, 3, 2, MAX1363_INFO_MASK,
+                d3m2, 7, IIO_ST('s', 10, 16, 0), MAX1363_EV_M),
+       IIO_CHAN_SOFT_TIMESTAMP(8)
 };
 
-static struct attribute *max1363_scan_el_attrs[] = {
-       &iio_scan_el_in0.dev_attr.attr, &dev_attr_in0_type.attr,
-       &iio_const_attr_in0_index.dev_attr.attr,
-       &iio_scan_el_in1.dev_attr.attr, &dev_attr_in1_type.attr,
-       &iio_const_attr_in1_index.dev_attr.attr,
-       &iio_scan_el_in2.dev_attr.attr, &dev_attr_in2_type.attr,
-       &iio_const_attr_in2_index.dev_attr.attr,
-       &iio_scan_el_in3.dev_attr.attr, &dev_attr_in3_type.attr,
-       &iio_const_attr_in3_index.dev_attr.attr,
-       &iio_scan_el_in0min1.dev_attr.attr,     &dev_attr_in0min1_type.attr,
-       &iio_const_attr_in0min1_index.dev_attr.attr,
-       &iio_scan_el_in2min3.dev_attr.attr,     &dev_attr_in2min3_type.attr,
-       &iio_const_attr_in2min3_index.dev_attr.attr,
-       &iio_scan_el_in1min0.dev_attr.attr,     &dev_attr_in1min0_type.attr,
-       &iio_const_attr_in1min0_index.dev_attr.attr,
-       &iio_scan_el_in3min2.dev_attr.attr,     &dev_attr_in3min2_type.attr,
-       &iio_const_attr_in3min2_index.dev_attr.attr,
-       NULL,
-};
+#define MAX1363_CHAN_U(num, address, scan_index, bits)         \
+       IIO_CHAN(IIO_IN, 0, 1, 0, NULL, num, 0, MAX1363_INFO_MASK,      \
+                address, scan_index, IIO_ST('u', bits,         \
+                                            (bits == 8) ? 8 : 16, 0), 0)
+/* bipolar channel */
+#define MAX1363_CHAN_B(num, num2, address, scan_index, bits)           \
+       IIO_CHAN(IIO_IN_DIFF, 0, 1, 0, NULL, num, num2, MAX1363_INFO_MASK,\
+                address, scan_index, IIO_ST('s', bits,         \
+                                            (bits == 8) ? 8 : 16, 0), 0)
+
+#define MAX1363_4X_CHANS(bits) {               \
+       MAX1363_CHAN_U(0, _s0, 0, bits),        \
+       MAX1363_CHAN_U(1, _s1, 1, bits),        \
+       MAX1363_CHAN_U(2, _s2, 2, bits),        \
+       MAX1363_CHAN_U(3, _s3, 3, bits),        \
+       MAX1363_CHAN_B(0, 1, d0m1, 4, bits),    \
+       MAX1363_CHAN_B(2, 3, d2m3, 5, bits),    \
+       MAX1363_CHAN_B(1, 0, d1m0, 6, bits),    \
+       MAX1363_CHAN_B(3, 2, d3m2, 7, bits),    \
+       IIO_CHAN_SOFT_TIMESTAMP(8)              \
+       }
 
-static struct attribute_group max1363_scan_el_group = {
-       .name = "scan_elements",
-       .attrs = max1363_scan_el_attrs,
-};
+static struct iio_chan_spec max1036_channels[] = MAX1363_4X_CHANS(8);
+static struct iio_chan_spec max1136_channels[] = MAX1363_4X_CHANS(10);
+static struct iio_chan_spec max1236_channels[] = MAX1363_4X_CHANS(12);
 
 /* Appies to max1236, max1237 */
 static const enum max1363_modes max1236_mode_list[] = {
@@ -432,97 +376,36 @@ static const enum max1363_modes max1238_mode_list[] = {
        d6m7to8m9, d6m7to10m11, d7m6to9m8, d7m6to11m10,
 };
 
-static struct attribute *max1238_device_attrs[] = {
-       &iio_dev_attr_in0_raw.dev_attr.attr,
-       &iio_dev_attr_in1_raw.dev_attr.attr,
-       &iio_dev_attr_in2_raw.dev_attr.attr,
-       &iio_dev_attr_in3_raw.dev_attr.attr,
-       &iio_dev_attr_in4_raw.dev_attr.attr,
-       &iio_dev_attr_in5_raw.dev_attr.attr,
-       &iio_dev_attr_in6_raw.dev_attr.attr,
-       &iio_dev_attr_in7_raw.dev_attr.attr,
-       &iio_dev_attr_in8_raw.dev_attr.attr,
-       &iio_dev_attr_in9_raw.dev_attr.attr,
-       &iio_dev_attr_in10_raw.dev_attr.attr,
-       &iio_dev_attr_in11_raw.dev_attr.attr,
-       &iio_dev_attr_in0min1_raw.dev_attr.attr,
-       &iio_dev_attr_in2min3_raw.dev_attr.attr,
-       &iio_dev_attr_in4min5_raw.dev_attr.attr,
-       &iio_dev_attr_in6min7_raw.dev_attr.attr,
-       &iio_dev_attr_in8min9_raw.dev_attr.attr,
-       &iio_dev_attr_in10min11_raw.dev_attr.attr,
-       &iio_dev_attr_in1min0_raw.dev_attr.attr,
-       &iio_dev_attr_in3min2_raw.dev_attr.attr,
-       &iio_dev_attr_in5min4_raw.dev_attr.attr,
-       &iio_dev_attr_in7min6_raw.dev_attr.attr,
-       &iio_dev_attr_in9min8_raw.dev_attr.attr,
-       &iio_dev_attr_in11min10_raw.dev_attr.attr,
-       &iio_dev_attr_name.dev_attr.attr,
-       &iio_dev_attr_in_scale.dev_attr.attr,
-       NULL
-};
-
-static struct attribute_group max1238_dev_attr_group = {
-       .attrs = max1238_device_attrs,
-};
-
-static struct attribute *max1238_scan_el_attrs[] = {
-       &iio_scan_el_in0.dev_attr.attr, &dev_attr_in0_type.attr,
-       &iio_const_attr_in0_index.dev_attr.attr,
-       &iio_scan_el_in1.dev_attr.attr, &dev_attr_in1_type.attr,
-       &iio_const_attr_in1_index.dev_attr.attr,
-       &iio_scan_el_in2.dev_attr.attr, &dev_attr_in2_type.attr,
-       &iio_const_attr_in2_index.dev_attr.attr,
-       &iio_scan_el_in3.dev_attr.attr, &dev_attr_in3_type.attr,
-       &iio_const_attr_in3_index.dev_attr.attr,
-       &iio_scan_el_in4.dev_attr.attr, &dev_attr_in4_type.attr,
-       &iio_const_attr_in4_index.dev_attr.attr,
-       &iio_scan_el_in5.dev_attr.attr, &dev_attr_in5_type.attr,
-       &iio_const_attr_in5_index.dev_attr.attr,
-       &iio_scan_el_in6.dev_attr.attr, &dev_attr_in6_type.attr,
-       &iio_const_attr_in6_index.dev_attr.attr,
-       &iio_scan_el_in7.dev_attr.attr, &dev_attr_in7_type.attr,
-       &iio_const_attr_in7_index.dev_attr.attr,
-       &iio_scan_el_in8.dev_attr.attr, &dev_attr_in8_type.attr,
-       &iio_const_attr_in8_index.dev_attr.attr,
-       &iio_scan_el_in9.dev_attr.attr, &dev_attr_in9_type.attr,
-       &iio_const_attr_in9_index.dev_attr.attr,
-       &iio_scan_el_in10.dev_attr.attr,        &dev_attr_in10_type.attr,
-       &iio_const_attr_in10_index.dev_attr.attr,
-       &iio_scan_el_in11.dev_attr.attr,        &dev_attr_in11_type.attr,
-       &iio_const_attr_in11_index.dev_attr.attr,
-       &iio_scan_el_in0min1.dev_attr.attr,     &dev_attr_in0min1_type.attr,
-       &iio_const_attr_in0min1_index.dev_attr.attr,
-       &iio_scan_el_in2min3.dev_attr.attr,     &dev_attr_in2min3_type.attr,
-       &iio_const_attr_in2min3_index.dev_attr.attr,
-       &iio_scan_el_in4min5.dev_attr.attr,     &dev_attr_in4min5_type.attr,
-       &iio_const_attr_in4min5_index.dev_attr.attr,
-       &iio_scan_el_in6min7.dev_attr.attr,     &dev_attr_in6min7_type.attr,
-       &iio_const_attr_in6min7_index.dev_attr.attr,
-       &iio_scan_el_in8min9.dev_attr.attr,     &dev_attr_in8min9_type.attr,
-       &iio_const_attr_in8min9_index.dev_attr.attr,
-       &iio_scan_el_in10min11.dev_attr.attr,   &dev_attr_in10min11_type.attr,
-       &iio_const_attr_in10min11_index.dev_attr.attr,
-       &iio_scan_el_in1min0.dev_attr.attr,     &dev_attr_in1min0_type.attr,
-       &iio_const_attr_in1min0_index.dev_attr.attr,
-       &iio_scan_el_in3min2.dev_attr.attr,     &dev_attr_in3min2_type.attr,
-       &iio_const_attr_in3min2_index.dev_attr.attr,
-       &iio_scan_el_in5min4.dev_attr.attr,     &dev_attr_in5min4_type.attr,
-       &iio_const_attr_in5min4_index.dev_attr.attr,
-       &iio_scan_el_in7min6.dev_attr.attr,     &dev_attr_in7min6_type.attr,
-       &iio_const_attr_in7min6_index.dev_attr.attr,
-       &iio_scan_el_in9min8.dev_attr.attr,     &dev_attr_in9min8_type.attr,
-       &iio_const_attr_in9min8_index.dev_attr.attr,
-       &iio_scan_el_in11min10.dev_attr.attr,   &dev_attr_in11min10_type.attr,
-       &iio_const_attr_in11min10_index.dev_attr.attr,
-       NULL,
-};
-
-static struct attribute_group max1238_scan_el_group = {
-       .name = "scan_elements",
-       .attrs = max1238_scan_el_attrs,
-};
-
+#define MAX1363_12X_CHANS(bits) {                      \
+       MAX1363_CHAN_U(0, _s0, 0, bits),                \
+       MAX1363_CHAN_U(1, _s1, 1, bits),                \
+       MAX1363_CHAN_U(2, _s2, 2, bits),                \
+       MAX1363_CHAN_U(3, _s3, 3, bits),                \
+       MAX1363_CHAN_U(4, _s4, 4, bits),                \
+       MAX1363_CHAN_U(5, _s5, 5, bits),                \
+       MAX1363_CHAN_U(6, _s6, 6, bits),                \
+       MAX1363_CHAN_U(7, _s7, 7, bits),                \
+       MAX1363_CHAN_U(8, _s8, 8, bits),                \
+       MAX1363_CHAN_U(9, _s9, 9, bits),                \
+       MAX1363_CHAN_U(10, _s10, 10, bits),             \
+       MAX1363_CHAN_U(11, _s11, 11, bits),             \
+       MAX1363_CHAN_B(0, 1, d0m1, 12, bits),           \
+       MAX1363_CHAN_B(2, 3, d2m3, 13, bits),           \
+       MAX1363_CHAN_B(4, 5, d4m5, 14, bits),           \
+       MAX1363_CHAN_B(6, 7, d6m7, 15, bits),           \
+       MAX1363_CHAN_B(8, 9, d8m9, 16, bits),           \
+       MAX1363_CHAN_B(10, 11, d10m11, 17, bits),       \
+       MAX1363_CHAN_B(1, 0, d1m0, 18, bits),           \
+       MAX1363_CHAN_B(3, 2, d3m2, 19, bits),           \
+       MAX1363_CHAN_B(5, 4, d5m4, 20, bits),           \
+       MAX1363_CHAN_B(7, 6, d7m6, 21, bits),           \
+       MAX1363_CHAN_B(9, 8, d9m8, 22, bits),           \
+       MAX1363_CHAN_B(11, 10, d11m10, 23, bits),       \
+       IIO_CHAN_SOFT_TIMESTAMP(24)                     \
+       }
+static struct iio_chan_spec max1038_channels[] = MAX1363_12X_CHANS(8);
+static struct iio_chan_spec max1138_channels[] = MAX1363_12X_CHANS(10);
+static struct iio_chan_spec max1238_channels[] = MAX1363_12X_CHANS(12);
 
 static const enum max1363_modes max11607_mode_list[] = {
        _s0, _s1, _s2, _s3,
@@ -542,72 +425,43 @@ static const enum max1363_modes max11608_mode_list[] = {
        d1m0to3m2, d1m0to5m4, d1m0to7m6,
 };
 
-static struct attribute *max11608_device_attrs[] = {
-       &iio_dev_attr_in0_raw.dev_attr.attr,
-       &iio_dev_attr_in1_raw.dev_attr.attr,
-       &iio_dev_attr_in2_raw.dev_attr.attr,
-       &iio_dev_attr_in3_raw.dev_attr.attr,
-       &iio_dev_attr_in4_raw.dev_attr.attr,
-       &iio_dev_attr_in5_raw.dev_attr.attr,
-       &iio_dev_attr_in6_raw.dev_attr.attr,
-       &iio_dev_attr_in7_raw.dev_attr.attr,
-       &iio_dev_attr_in0min1_raw.dev_attr.attr,
-       &iio_dev_attr_in2min3_raw.dev_attr.attr,
-       &iio_dev_attr_in4min5_raw.dev_attr.attr,
-       &iio_dev_attr_in6min7_raw.dev_attr.attr,
-       &iio_dev_attr_in1min0_raw.dev_attr.attr,
-       &iio_dev_attr_in3min2_raw.dev_attr.attr,
-       &iio_dev_attr_in5min4_raw.dev_attr.attr,
-       &iio_dev_attr_in7min6_raw.dev_attr.attr,
-       &iio_dev_attr_name.dev_attr.attr,
-       &iio_dev_attr_in_scale.dev_attr.attr,
-       NULL
-};
+#define MAX1363_8X_CHANS(bits) {                               \
+               MAX1363_CHAN_U(0, _s0, 0, bits),                \
+                       MAX1363_CHAN_U(1, _s1, 1, bits),        \
+                       MAX1363_CHAN_U(2, _s2, 2, bits),        \
+                       MAX1363_CHAN_U(3, _s3, 3, bits),        \
+                       MAX1363_CHAN_U(4, _s4, 4, bits),        \
+                       MAX1363_CHAN_U(5, _s5, 5, bits),        \
+                       MAX1363_CHAN_U(6, _s6, 6, bits),        \
+                       MAX1363_CHAN_U(7, _s7, 7, bits),        \
+                       MAX1363_CHAN_B(0, 1, d0m1, 8, bits),    \
+                       MAX1363_CHAN_B(2, 3, d2m3, 9, bits),    \
+                       MAX1363_CHAN_B(4, 5, d4m5, 10, bits),   \
+                       MAX1363_CHAN_B(6, 7, d6m7, 11, bits),   \
+                       MAX1363_CHAN_B(1, 0, d1m0, 12, bits),   \
+                       MAX1363_CHAN_B(3, 2, d3m2, 13, bits),   \
+                       MAX1363_CHAN_B(5, 4, d5m4, 14, bits),   \
+                       MAX1363_CHAN_B(7, 6, d7m6, 15, bits),   \
+                       IIO_CHAN_SOFT_TIMESTAMP(16)             \
+               }
+static struct iio_chan_spec max11602_channels[] = MAX1363_8X_CHANS(8);
+static struct iio_chan_spec max11608_channels[] = MAX1363_8X_CHANS(10);
+static struct iio_chan_spec max11614_channels[] = MAX1363_8X_CHANS(12);
 
-static struct attribute_group max11608_dev_attr_group = {
-       .attrs = max11608_device_attrs,
+static const enum max1363_modes max11644_mode_list[] = {
+       _s0, _s1, s0to1, d0m1, d1m0,
 };
 
-static struct attribute *max11608_scan_el_attrs[] = {
-       &iio_scan_el_in0.dev_attr.attr, &dev_attr_in0_type.attr,
-       &iio_const_attr_in0_index.dev_attr.attr,
-       &iio_scan_el_in1.dev_attr.attr, &dev_attr_in1_type.attr,
-       &iio_const_attr_in1_index.dev_attr.attr,
-       &iio_scan_el_in2.dev_attr.attr, &dev_attr_in2_type.attr,
-       &iio_const_attr_in2_index.dev_attr.attr,
-       &iio_scan_el_in3.dev_attr.attr, &dev_attr_in3_type.attr,
-       &iio_const_attr_in3_index.dev_attr.attr,
-       &iio_scan_el_in4.dev_attr.attr, &dev_attr_in4_type.attr,
-       &iio_const_attr_in4_index.dev_attr.attr,
-       &iio_scan_el_in5.dev_attr.attr, &dev_attr_in5_type.attr,
-       &iio_const_attr_in5_index.dev_attr.attr,
-       &iio_scan_el_in6.dev_attr.attr, &dev_attr_in6_type.attr,
-       &iio_const_attr_in6_index.dev_attr.attr,
-       &iio_scan_el_in7.dev_attr.attr, &dev_attr_in7_type.attr,
-       &iio_const_attr_in7_index.dev_attr.attr,
-       &iio_scan_el_in0min1.dev_attr.attr,     &dev_attr_in0min1_type.attr,
-       &iio_const_attr_in0min1_index.dev_attr.attr,
-       &iio_scan_el_in2min3.dev_attr.attr,     &dev_attr_in2min3_type.attr,
-       &iio_const_attr_in2min3_index.dev_attr.attr,
-       &iio_scan_el_in4min5.dev_attr.attr,     &dev_attr_in4min5_type.attr,
-       &iio_const_attr_in4min5_index.dev_attr.attr,
-       &iio_scan_el_in6min7.dev_attr.attr,     &dev_attr_in6min7_type.attr,
-       &iio_const_attr_in6min7_index.dev_attr.attr,
-       &iio_scan_el_in1min0.dev_attr.attr,     &dev_attr_in1min0_type.attr,
-       &iio_const_attr_in1min0_index.dev_attr.attr,
-       &iio_scan_el_in3min2.dev_attr.attr,     &dev_attr_in3min2_type.attr,
-       &iio_const_attr_in3min2_index.dev_attr.attr,
-       &iio_scan_el_in5min4.dev_attr.attr,     &dev_attr_in5min4_type.attr,
-       &iio_const_attr_in5min4_index.dev_attr.attr,
-       &iio_scan_el_in7min6.dev_attr.attr,     &dev_attr_in7min6_type.attr,
-       &iio_const_attr_in7min6_index.dev_attr.attr,
-       NULL
-};
+#define MAX1363_2X_CHANS(bits) {                       \
+       MAX1363_CHAN_U(0, _s0, 0, bits),                \
+       MAX1363_CHAN_U(1, _s1, 1, bits),                \
+       MAX1363_CHAN_B(0, 1, d0m1, 2, bits),            \
+       MAX1363_CHAN_B(1, 0, d1m0, 3, bits),            \
+       IIO_CHAN_SOFT_TIMESTAMP(4)                      \
+       }
 
-static struct attribute_group max11608_scan_el_group = {
-       .name = "scan_elements",
-       .attrs = max11608_scan_el_attrs,
-};
+static struct iio_chan_spec max11646_channels[] = MAX1363_2X_CHANS(10);
+static struct iio_chan_spec max11644_channels[] = MAX1363_2X_CHANS(12);
 
 enum { max1361,
        max1362,
@@ -643,354 +497,10 @@ enum { max1361,
        max11615,
        max11616,
        max11617,
-};
-
-/* max1363 and max1368 tested - rest from data sheet */
-static const struct max1363_chip_info max1363_chip_info_tbl[] = {
-       [max1361] = {
-               .num_inputs = 4,
-               .bits = 10,
-               .int_vref_mv = 2048,
-               .monitor_mode = 1,
-               .mode_list = max1363_mode_list,
-               .num_modes = ARRAY_SIZE(max1363_mode_list),
-               .default_mode = s0to3,
-               .dev_attrs = &max1363_dev_attr_group,
-               .scan_attrs = &max1363_scan_el_group,
-       },
-       [max1362] = {
-               .num_inputs = 4,
-               .bits = 10,
-               .int_vref_mv = 4096,
-               .monitor_mode = 1,
-               .mode_list = max1363_mode_list,
-               .num_modes = ARRAY_SIZE(max1363_mode_list),
-               .default_mode = s0to3,
-               .dev_attrs = &max1363_dev_attr_group,
-               .scan_attrs = &max1363_scan_el_group,
-       },
-       [max1363] = {
-               .num_inputs = 4,
-               .bits = 12,
-               .int_vref_mv = 2048,
-               .monitor_mode = 1,
-               .mode_list = max1363_mode_list,
-               .num_modes = ARRAY_SIZE(max1363_mode_list),
-               .default_mode = s0to3,
-               .dev_attrs = &max1363_dev_attr_group,
-               .scan_attrs = &max1363_scan_el_group,
-       },
-       [max1364] = {
-               .num_inputs = 4,
-               .bits = 12,
-               .int_vref_mv = 4096,
-               .monitor_mode = 1,
-               .mode_list = max1363_mode_list,
-               .num_modes = ARRAY_SIZE(max1363_mode_list),
-               .default_mode = s0to3,
-               .dev_attrs = &max1363_dev_attr_group,
-               .scan_attrs = &max1363_scan_el_group,
-       },
-       [max1036] = {
-               .num_inputs = 4,
-               .bits = 8,
-               .int_vref_mv = 4096,
-               .mode_list = max1236_mode_list,
-               .num_modes = ARRAY_SIZE(max1236_mode_list),
-               .default_mode = s0to3,
-               .dev_attrs = &max1363_dev_attr_group,
-               .scan_attrs = &max1363_scan_el_group,
-       },
-       [max1037] = {
-               .num_inputs = 4,
-               .bits = 8,
-               .int_vref_mv = 2048,
-               .mode_list = max1236_mode_list,
-               .num_modes = ARRAY_SIZE(max1236_mode_list),
-               .default_mode = s0to3,
-               .dev_attrs = &max1363_dev_attr_group,
-               .scan_attrs = &max1363_scan_el_group,
-       },
-       [max1038] = {
-               .num_inputs = 12,
-               .bits = 8,
-               .int_vref_mv = 4096,
-               .mode_list = max1238_mode_list,
-               .num_modes = ARRAY_SIZE(max1238_mode_list),
-               .default_mode = s0to11,
-               .dev_attrs = &max1238_dev_attr_group,
-               .scan_attrs = &max1238_scan_el_group,
-       },
-       [max1039] = {
-               .num_inputs = 12,
-               .bits = 8,
-               .int_vref_mv = 2048,
-               .mode_list = max1238_mode_list,
-               .num_modes = ARRAY_SIZE(max1238_mode_list),
-               .default_mode = s0to11,
-               .dev_attrs = &max1238_dev_attr_group,
-               .scan_attrs = &max1238_scan_el_group,
-       },
-       [max1136] = {
-               .num_inputs = 4,
-               .bits = 10,
-               .int_vref_mv = 4096,
-               .mode_list = max1236_mode_list,
-               .num_modes = ARRAY_SIZE(max1236_mode_list),
-               .default_mode = s0to3,
-               .dev_attrs = &max1363_dev_attr_group,
-               .scan_attrs = &max1363_scan_el_group,
-       },
-       [max1137] = {
-               .num_inputs = 4,
-               .bits = 10,
-               .int_vref_mv = 2048,
-               .mode_list = max1236_mode_list,
-               .num_modes = ARRAY_SIZE(max1236_mode_list),
-               .default_mode = s0to3,
-               .dev_attrs = &max1363_dev_attr_group,
-               .scan_attrs = &max1363_scan_el_group,
-       },
-       [max1138] = {
-               .num_inputs = 12,
-               .bits = 10,
-               .int_vref_mv = 4096,
-               .mode_list = max1238_mode_list,
-               .num_modes = ARRAY_SIZE(max1238_mode_list),
-               .default_mode = s0to11,
-               .dev_attrs = &max1238_dev_attr_group,
-               .scan_attrs = &max1238_scan_el_group,
-       },
-       [max1139] = {
-               .num_inputs = 12,
-               .bits = 10,
-               .int_vref_mv = 2048,
-               .mode_list = max1238_mode_list,
-               .num_modes = ARRAY_SIZE(max1238_mode_list),
-               .default_mode = s0to11,
-               .dev_attrs = &max1238_dev_attr_group,
-               .scan_attrs = &max1238_scan_el_group,
-       },
-       [max1236] = {
-               .num_inputs = 4,
-               .bits = 12,
-               .int_vref_mv = 4096,
-               .mode_list = max1236_mode_list,
-               .num_modes = ARRAY_SIZE(max1236_mode_list),
-               .default_mode = s0to3,
-               .dev_attrs = &max1363_dev_attr_group,
-               .scan_attrs = &max1363_scan_el_group,
-       },
-       [max1237] = {
-               .num_inputs = 4,
-               .bits = 12,
-               .int_vref_mv = 2048,
-               .mode_list = max1236_mode_list,
-               .num_modes = ARRAY_SIZE(max1236_mode_list),
-               .default_mode = s0to3,
-               .dev_attrs = &max1363_dev_attr_group,
-               .scan_attrs = &max1363_scan_el_group,
-       },
-       [max1238] = {
-               .num_inputs = 12,
-               .bits = 12,
-               .int_vref_mv = 4096,
-               .mode_list = max1238_mode_list,
-               .num_modes = ARRAY_SIZE(max1238_mode_list),
-               .default_mode = s0to11,
-               .dev_attrs = &max1238_dev_attr_group,
-               .scan_attrs = &max1238_scan_el_group,
-       },
-       [max1239] = {
-               .num_inputs = 12,
-               .bits = 12,
-               .int_vref_mv = 2048,
-               .mode_list = max1238_mode_list,
-               .num_modes = ARRAY_SIZE(max1238_mode_list),
-               .default_mode = s0to11,
-               .dev_attrs = &max1238_dev_attr_group,
-               .scan_attrs = &max1238_scan_el_group,
-       },
-       [max11600] = {
-               .num_inputs = 4,
-               .bits = 8,
-               .int_vref_mv = 4096,
-               .mode_list = max11607_mode_list,
-               .num_modes = ARRAY_SIZE(max11607_mode_list),
-               .default_mode = s0to3,
-               .dev_attrs = &max1363_dev_attr_group,
-               .scan_attrs = &max1363_scan_el_group,
-       },
-       [max11601] = {
-               .num_inputs = 4,
-               .bits = 8,
-               .int_vref_mv = 2048,
-               .mode_list = max11607_mode_list,
-               .num_modes = ARRAY_SIZE(max11607_mode_list),
-               .default_mode = s0to3,
-               .dev_attrs = &max1363_dev_attr_group,
-               .scan_attrs = &max1363_scan_el_group,
-       },
-       [max11602] = {
-               .num_inputs = 8,
-               .bits = 8,
-               .int_vref_mv = 4096,
-               .mode_list = max11608_mode_list,
-               .num_modes = ARRAY_SIZE(max11608_mode_list),
-               .default_mode = s0to7,
-               .dev_attrs = &max11608_dev_attr_group,
-               .scan_attrs = &max11608_scan_el_group,
-       },
-       [max11603] = {
-               .num_inputs = 8,
-               .bits = 8,
-               .int_vref_mv = 2048,
-               .mode_list = max11608_mode_list,
-               .num_modes = ARRAY_SIZE(max11608_mode_list),
-               .default_mode = s0to7,
-               .dev_attrs = &max11608_dev_attr_group,
-               .scan_attrs = &max11608_scan_el_group,
-       },
-       [max11604] = {
-               .num_inputs = 12,
-               .bits = 8,
-               .int_vref_mv = 4098,
-               .mode_list = max1238_mode_list,
-               .num_modes = ARRAY_SIZE(max1238_mode_list),
-               .default_mode = s0to11,
-               .dev_attrs = &max1238_dev_attr_group,
-               .scan_attrs = &max1238_scan_el_group,
-       },
-       [max11605] = {
-               .num_inputs = 12,
-               .bits = 8,
-               .int_vref_mv = 2048,
-               .mode_list = max1238_mode_list,
-               .num_modes = ARRAY_SIZE(max1238_mode_list),
-               .default_mode = s0to11,
-               .dev_attrs = &max1238_dev_attr_group,
-               .scan_attrs = &max1238_scan_el_group,
-       },
-       [max11606] = {
-               .num_inputs = 4,
-               .bits = 10,
-               .int_vref_mv = 4096,
-               .mode_list = max11607_mode_list,
-               .num_modes = ARRAY_SIZE(max11607_mode_list),
-               .default_mode = s0to3,
-               .dev_attrs = &max1363_dev_attr_group,
-               .scan_attrs = &max1363_scan_el_group,
-       },
-       [max11607] = {
-               .num_inputs = 4,
-               .bits = 10,
-               .int_vref_mv = 2048,
-               .mode_list = max11607_mode_list,
-               .num_modes = ARRAY_SIZE(max11607_mode_list),
-               .default_mode = s0to3,
-               .dev_attrs = &max1363_dev_attr_group,
-               .scan_attrs = &max1363_scan_el_group,
-       },
-       [max11608] = {
-               .num_inputs = 8,
-               .bits = 10,
-               .int_vref_mv = 4096,
-               .mode_list = max11608_mode_list,
-               .num_modes = ARRAY_SIZE(max11608_mode_list),
-               .default_mode = s0to7,
-               .dev_attrs = &max11608_dev_attr_group,
-               .scan_attrs = &max11608_scan_el_group,
-       },
-       [max11609] = {
-               .num_inputs = 8,
-               .bits = 10,
-               .int_vref_mv = 2048,
-               .mode_list = max11608_mode_list,
-               .num_modes = ARRAY_SIZE(max11608_mode_list),
-               .default_mode = s0to7,
-               .dev_attrs = &max11608_dev_attr_group,
-               .scan_attrs = &max11608_scan_el_group,
-       },
-       [max11610] = {
-               .num_inputs = 12,
-               .bits = 10,
-               .int_vref_mv = 4098,
-               .mode_list = max1238_mode_list,
-               .num_modes = ARRAY_SIZE(max1238_mode_list),
-               .default_mode = s0to11,
-               .dev_attrs = &max1238_dev_attr_group,
-               .scan_attrs = &max1238_scan_el_group,
-       },
-       [max11611] = {
-               .num_inputs = 12,
-               .bits = 10,
-               .int_vref_mv = 2048,
-               .mode_list = max1238_mode_list,
-               .num_modes = ARRAY_SIZE(max1238_mode_list),
-               .default_mode = s0to11,
-               .dev_attrs = &max1238_dev_attr_group,
-               .scan_attrs = &max1238_scan_el_group,
-       },
-       [max11612] = {
-               .num_inputs = 4,
-               .bits = 12,
-               .int_vref_mv = 4096,
-               .mode_list = max11607_mode_list,
-               .num_modes = ARRAY_SIZE(max11607_mode_list),
-               .default_mode = s0to3,
-               .dev_attrs = &max1363_dev_attr_group,
-               .scan_attrs = &max1363_scan_el_group,
-       },
-       [max11613] = {
-               .num_inputs = 4,
-               .bits = 12,
-               .int_vref_mv = 2048,
-               .mode_list = max11607_mode_list,
-               .num_modes = ARRAY_SIZE(max11607_mode_list),
-               .default_mode = s0to3,
-               .dev_attrs = &max1363_dev_attr_group,
-               .scan_attrs = &max1363_scan_el_group,
-       },
-       [max11614] = {
-               .num_inputs = 8,
-               .bits = 12,
-               .int_vref_mv = 4096,
-               .mode_list = max11608_mode_list,
-               .num_modes = ARRAY_SIZE(max11608_mode_list),
-               .default_mode = s0to7,
-               .dev_attrs = &max11608_dev_attr_group,
-               .scan_attrs = &max11608_scan_el_group,
-       },
-       [max11615] = {
-               .num_inputs = 8,
-               .bits = 12,
-               .int_vref_mv = 2048,
-               .mode_list = max11608_mode_list,
-               .num_modes = ARRAY_SIZE(max11608_mode_list),
-               .default_mode = s0to7,
-               .dev_attrs = &max11608_dev_attr_group,
-               .scan_attrs = &max11608_scan_el_group,
-       },
-       [max11616] = {
-               .num_inputs = 12,
-               .bits = 12,
-               .int_vref_mv = 4098,
-               .mode_list = max1238_mode_list,
-               .num_modes = ARRAY_SIZE(max1238_mode_list),
-               .default_mode = s0to11,
-               .dev_attrs = &max1238_dev_attr_group,
-               .scan_attrs = &max1238_scan_el_group,
-       },
-       [max11617] = {
-               .num_inputs = 12,
-               .bits = 12,
-               .int_vref_mv = 2048,
-               .mode_list = max1238_mode_list,
-               .num_modes = ARRAY_SIZE(max1238_mode_list),
-               .default_mode = s0to11,
-               .dev_attrs = &max1238_dev_attr_group,
-               .scan_attrs = &max1238_scan_el_group,
-       }
+       max11644,
+       max11645,
+       max11646,
+       max11647
 };
 
 static const int max1363_monitor_speeds[] = { 133000, 665000, 33300, 16600,
@@ -1000,8 +510,7 @@ static ssize_t max1363_monitor_show_freq(struct device *dev,
                                        struct device_attribute *attr,
                                        char *buf)
 {
-       struct iio_dev *dev_info = dev_get_drvdata(dev);
-       struct max1363_state *st = iio_dev_get_devdata(dev_info);
+       struct max1363_state *st = iio_priv(dev_get_drvdata(dev));
        return sprintf(buf, "%d\n", max1363_monitor_speeds[st->monitor_speed]);
 }
 
@@ -1010,8 +519,8 @@ static ssize_t max1363_monitor_store_freq(struct device *dev,
                                        const char *buf,
                                        size_t len)
 {
-       struct iio_dev *dev_info = dev_get_drvdata(dev);
-       struct max1363_state *st = iio_dev_get_devdata(dev_info);
+       struct iio_dev *indio_dev = dev_get_drvdata(dev);
+       struct max1363_state *st = iio_priv(indio_dev);
        int i, ret;
        unsigned long val;
        bool found = false;
@@ -1027,9 +536,9 @@ static ssize_t max1363_monitor_store_freq(struct device *dev,
        if (!found)
                return -EINVAL;
 
-       mutex_lock(&dev_info->mlock);
+       mutex_lock(&indio_dev->mlock);
        st->monitor_speed = i;
-       mutex_unlock(&dev_info->mlock);
+       mutex_unlock(&indio_dev->mlock);
 
        return 0;
 }
@@ -1041,52 +550,24 @@ static IIO_DEV_ATTR_SAMP_FREQ(S_IRUGO | S_IWUSR,
 static IIO_CONST_ATTR(sampling_frequency_available,
                "133000 665000 33300 16600 8300 4200 2000 1000");
 
-static ssize_t max1363_show_thresh(struct device *dev,
-                               struct device_attribute *attr,
-                               char *buf,
-                               bool high)
+static int max1363_read_thresh(struct iio_dev *indio_dev,
+                              int event_code,
+                              int *val)
 {
-       struct iio_dev *dev_info = dev_get_drvdata(dev);
-       struct max1363_state *st = iio_dev_get_devdata(dev_info);
-       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-
-       if (high)
-               return sprintf(buf, "%d\n",
-                       st->thresh_high[this_attr->address]);
+       struct max1363_state *st = iio_priv(indio_dev);
+       if (IIO_EVENT_CODE_EXTRACT_DIR(event_code) == IIO_EV_DIR_FALLING)
+               *val = st->thresh_low[IIO_EVENT_CODE_EXTRACT_NUM(event_code)];
        else
-               return sprintf(buf, "%d\n",
-                       st->thresh_low[this_attr->address & 0x7]);
-}
-
-static ssize_t max1363_show_thresh_low(struct device *dev,
-                               struct device_attribute *attr,
-                               char *buf)
-{
-       return max1363_show_thresh(dev, attr, buf, false);
-}
-
-static ssize_t max1363_show_thresh_high(struct device *dev,
-                                       struct device_attribute *attr,
-                                       char *buf)
-{
-       return max1363_show_thresh(dev, attr, buf, true);
+               *val = st->thresh_high[IIO_EVENT_CODE_EXTRACT_NUM(event_code)];
+       return 0;
 }
 
-static ssize_t max1363_store_thresh_unsigned(struct device *dev,
-                                       struct device_attribute *attr,
-                                       const char *buf,
-                                       size_t len,
-                                       bool high)
+static int max1363_write_thresh(struct iio_dev *indio_dev,
+                               int event_code,
+                               int val)
 {
-       struct iio_dev *dev_info = dev_get_drvdata(dev);
-       struct max1363_state *st = iio_dev_get_devdata(dev_info);
-       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-       unsigned long val;
-       int ret;
-
-       ret = strict_strtoul(buf, 10, &val);
-       if (ret)
-               return -EINVAL;
+       struct max1363_state *st = iio_priv(indio_dev);
+       /* make it handle signed correctly as well */
        switch (st->chip_info->bits) {
        case 10:
                if (val > 0x3FF)
@@ -1098,220 +579,60 @@ static ssize_t max1363_store_thresh_unsigned(struct device *dev,
                break;
        }
 
-       switch (high) {
-       case 1:
-               st->thresh_high[this_attr->address] = val;
+       switch (IIO_EVENT_CODE_EXTRACT_DIR(event_code)) {
+       case IIO_EV_DIR_FALLING:
+               st->thresh_low[IIO_EVENT_CODE_EXTRACT_NUM(event_code)] = val;
                break;
-       case 0:
-               st->thresh_low[this_attr->address & 0x7] = val;
+       case IIO_EV_DIR_RISING:
+               st->thresh_high[IIO_EVENT_CODE_EXTRACT_NUM(event_code)] = val;
                break;
        }
 
-       return len;
-}
-
-static ssize_t max1363_store_thresh_high_unsigned(struct device *dev,
-                                               struct device_attribute *attr,
-                                               const char *buf,
-                                               size_t len)
-{
-       return max1363_store_thresh_unsigned(dev, attr, buf, len, true);
-}
-
-static ssize_t max1363_store_thresh_low_unsigned(struct device *dev,
-                                               struct device_attribute *attr,
-                                               const char *buf,
-                                               size_t len)
-{
-       return max1363_store_thresh_unsigned(dev, attr, buf, len, false);
-}
-
-static ssize_t max1363_store_thresh_signed(struct device *dev,
-                                       struct device_attribute *attr,
-                                       const char *buf,
-                                       size_t len,
-                                       bool high)
-{
-       struct iio_dev *dev_info = dev_get_drvdata(dev);
-       struct max1363_state *st = iio_dev_get_devdata(dev_info);
-       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-       long val;
-       int ret;
-
-       ret = strict_strtol(buf, 10, &val);
-       if (ret)
-               return -EINVAL;
-       switch (st->chip_info->bits) {
-       case 10:
-               if (val < -512 || val > 511)
-                       return -EINVAL;
-               break;
-       case 12:
-               if (val < -2048 || val > 2047)
-                       return -EINVAL;
-               break;
-       }
-
-       switch (high) {
-       case 1:
-               st->thresh_high[this_attr->address] = val;
-               break;
-       case 0:
-               st->thresh_low[this_attr->address & 0x7] = val;
-               break;
-       }
-
-       return len;
-}
-
-static ssize_t max1363_store_thresh_high_signed(struct device *dev,
-                                               struct device_attribute *attr,
-                                               const char *buf,
-                                               size_t len)
-{
-       return max1363_store_thresh_signed(dev, attr, buf, len, true);
-}
-
-static ssize_t max1363_store_thresh_low_signed(struct device *dev,
-                                               struct device_attribute *attr,
-                                               const char *buf,
-                                               size_t len)
-{
-       return max1363_store_thresh_signed(dev, attr, buf, len, false);
-}
-
-static IIO_DEVICE_ATTR(in0_thresh_high_value, S_IRUGO | S_IWUSR,
-               max1363_show_thresh_high,
-               max1363_store_thresh_high_unsigned, 0);
-static IIO_DEVICE_ATTR(in0_thresh_low_value, S_IRUGO | S_IWUSR,
-               max1363_show_thresh_low,
-               max1363_store_thresh_low_unsigned, 0);
-static IIO_DEVICE_ATTR(in1_thresh_high_value, S_IRUGO | S_IWUSR,
-               max1363_show_thresh_high,
-               max1363_store_thresh_high_unsigned, 1);
-static IIO_DEVICE_ATTR(in1_thresh_low_value, S_IRUGO | S_IWUSR,
-               max1363_show_thresh_low,
-               max1363_store_thresh_low_unsigned, 1);
-static IIO_DEVICE_ATTR(in2_thresh_high_value, S_IRUGO | S_IWUSR,
-               max1363_show_thresh_high,
-               max1363_store_thresh_high_unsigned, 2);
-static IIO_DEVICE_ATTR(in2_thresh_low_value, S_IRUGO | S_IWUSR,
-               max1363_show_thresh_low,
-               max1363_store_thresh_low_unsigned, 2);
-static IIO_DEVICE_ATTR(in3_thresh_high_value, S_IRUGO | S_IWUSR,
-               max1363_show_thresh_high,
-               max1363_store_thresh_high_unsigned, 3);
-static IIO_DEVICE_ATTR(in3_thresh_low_value, S_IRUGO | S_IWUSR,
-               max1363_show_thresh_low,
-               max1363_store_thresh_low_unsigned, 3);
-
-static IIO_DEVICE_ATTR_NAMED(in0min1_thresh_high_value,
-                       in0-in1_thresh_high_value,
-                       S_IRUGO | S_IWUSR, max1363_show_thresh_high,
-                       max1363_store_thresh_high_signed, 4);
-static IIO_DEVICE_ATTR_NAMED(in0min1_thresh_low_value,
-                       in0-in1_thresh_low_value,
-                       S_IRUGO | S_IWUSR, max1363_show_thresh_low,
-                       max1363_store_thresh_low_signed, 4);
-static IIO_DEVICE_ATTR_NAMED(in2min3_thresh_high_value,
-                       in2-in3_thresh_high_value,
-                       S_IRUGO | S_IWUSR, max1363_show_thresh_high,
-                       max1363_store_thresh_high_signed, 5);
-static IIO_DEVICE_ATTR_NAMED(in2min3_thresh_low_value,
-                       in2-in3_thresh_low_value,
-                       S_IRUGO | S_IWUSR, max1363_show_thresh_low,
-                       max1363_store_thresh_low_signed, 5);
-static IIO_DEVICE_ATTR_NAMED(in1min0_thresh_high_value,
-                       in1-in0_thresh_high_value,
-                       S_IRUGO | S_IWUSR, max1363_show_thresh_high,
-                       max1363_store_thresh_high_signed, 6);
-static IIO_DEVICE_ATTR_NAMED(in1min0_thresh_low_value,
-                       in1-in0_thresh_low_value,
-                       S_IRUGO | S_IWUSR, max1363_show_thresh_low,
-                       max1363_store_thresh_low_signed, 6);
-static IIO_DEVICE_ATTR_NAMED(in3min2_thresh_high_value,
-                       in3-in2_thresh_high_value,
-                       S_IRUGO | S_IWUSR, max1363_show_thresh_high,
-                       max1363_store_thresh_high_signed, 7);
-static IIO_DEVICE_ATTR_NAMED(in3min2_thresh_low_value,
-                       in3-in2_thresh_low_value,
-                       S_IRUGO | S_IWUSR, max1363_show_thresh_low,
-                       max1363_store_thresh_low_signed, 7);
-
-static int max1363_int_th(struct iio_dev *dev_info,
-                       int index,
-                       s64 timestamp,
-                       int not_test)
-{
-       struct max1363_state *st = dev_info->dev_data;
-
-       st->last_timestamp = timestamp;
-       schedule_work(&st->thresh_work);
        return 0;
 }
 
-static void max1363_thresh_handler_bh(struct work_struct *work_s)
+static const int max1363_event_codes[] = {
+       IIO_EVENT_CODE_IN_LOW_THRESH(3), IIO_EVENT_CODE_IN_HIGH_THRESH(3),
+       IIO_EVENT_CODE_IN_LOW_THRESH(2), IIO_EVENT_CODE_IN_HIGH_THRESH(2),
+       IIO_EVENT_CODE_IN_LOW_THRESH(1), IIO_EVENT_CODE_IN_HIGH_THRESH(1),
+       IIO_EVENT_CODE_IN_LOW_THRESH(0), IIO_EVENT_CODE_IN_HIGH_THRESH(0)
+};
+
+static irqreturn_t max1363_event_handler(int irq, void *private)
 {
-       struct max1363_state *st = container_of(work_s, struct max1363_state,
-                                               thresh_work);
+       struct iio_dev *indio_dev = private;
+       struct max1363_state *st = iio_priv(indio_dev);
+       s64 timestamp = iio_get_time_ns();
+       unsigned long mask, loc;
        u8 rx;
        u8 tx[2] = { st->setupbyte,
                     MAX1363_MON_INT_ENABLE | (st->monitor_speed << 1) | 0xF0 };
 
        i2c_master_recv(st->client, &rx, 1);
-       if (rx & (1 << 0))
-               iio_push_event(st->indio_dev, 0,
-                       IIO_EVENT_CODE_IN_LOW_THRESH(3),
-                       st->last_timestamp);
-       if (rx & (1 << 1))
-               iio_push_event(st->indio_dev, 0,
-                       IIO_EVENT_CODE_IN_HIGH_THRESH(3),
-                       st->last_timestamp);
-       if (rx & (1 << 2))
-               iio_push_event(st->indio_dev, 0,
-                       IIO_EVENT_CODE_IN_LOW_THRESH(2),
-                       st->last_timestamp);
-       if (rx & (1 << 3))
-               iio_push_event(st->indio_dev, 0,
-                       IIO_EVENT_CODE_IN_HIGH_THRESH(2),
-                       st->last_timestamp);
-       if (rx & (1 << 4))
-               iio_push_event(st->indio_dev, 0,
-                       IIO_EVENT_CODE_IN_LOW_THRESH(1),
-                       st->last_timestamp);
-       if (rx & (1 << 5))
-               iio_push_event(st->indio_dev, 0,
-                       IIO_EVENT_CODE_IN_HIGH_THRESH(1),
-                       st->last_timestamp);
-       if (rx & (1 << 6))
-               iio_push_event(st->indio_dev, 0,
-                       IIO_EVENT_CODE_IN_LOW_THRESH(0),
-                       st->last_timestamp);
-       if (rx & (1 << 7))
-               iio_push_event(st->indio_dev, 0,
-                       IIO_EVENT_CODE_IN_HIGH_THRESH(0),
-                       st->last_timestamp);
-       enable_irq(st->client->irq);
+       mask = rx;
+       for_each_set_bit(loc, &mask, 8)
+               iio_push_event(indio_dev, 0, max1363_event_codes[loc],
+                              timestamp);
        i2c_master_send(st->client, tx, 2);
+
+       return IRQ_HANDLED;
 }
 
-static ssize_t max1363_read_interrupt_config(struct device *dev,
-                                       struct device_attribute *attr,
-                                       char *buf)
+static int max1363_read_event_config(struct iio_dev *indio_dev,
+                                    int event_code)
 {
-       struct iio_dev *dev_info = dev_get_drvdata(dev);
-       struct max1363_state *st = iio_dev_get_devdata(dev_info);
-       struct iio_event_attr *this_attr = to_iio_event_attr(attr);
-       int val;
+       struct max1363_state *st = iio_priv(indio_dev);
 
-       mutex_lock(&dev_info->mlock);
-       if (this_attr->mask & 0x8)
-               val = (1 << (this_attr->mask & 0x7)) & st->mask_low;
+       int val;
+       int number = IIO_EVENT_CODE_EXTRACT_NUM(event_code);
+       mutex_lock(&indio_dev->mlock);
+       if (IIO_EVENT_CODE_EXTRACT_DIR(event_code) == IIO_EV_DIR_FALLING)
+               val = (1 << number) & st->mask_low;
        else
-               val = (1 << this_attr->mask) & st->mask_high;
-       mutex_unlock(&dev_info->mlock);
+               val = (1 << number) & st->mask_high;
+       mutex_unlock(&indio_dev->mlock);
 
-       return sprintf(buf, "%d\n", !!val);
+       return val;
 }
 
 static int max1363_monitor_mode_update(struct max1363_state *st, int enabled)
@@ -1428,6 +749,7 @@ error_ret:
  * To keep this manageable we always use one of 3 scan modes.
  * Scan 0...3, 0-1,2-3 and 1-0,3-2
  */
+
 static inline int __max1363_check_event_mask(int thismask, int checkmask)
 {
        int ret = 0;
@@ -1448,206 +770,54 @@ error_ret:
        return ret;
 }
 
-static ssize_t max1363_write_interrupt_config(struct device *dev,
-                                       struct device_attribute *attr,
-                                       const char *buf,
-                                       size_t len)
+static int max1363_write_event_config(struct iio_dev *indio_dev,
+                                     int event_code,
+                                     int state)
 {
-       struct iio_dev *dev_info = dev_get_drvdata(dev);
-       struct max1363_state *st = iio_dev_get_devdata(dev_info);
-       struct iio_event_attr *this_attr = to_iio_event_attr(attr);
-       unsigned long val;
-       int ret;
+       int ret = 0;
+       struct max1363_state *st = iio_priv(indio_dev);
        u16 unifiedmask;
-       ret = strict_strtoul(buf, 10, &val);
-       if (ret)
-               return -EINVAL;
-       mutex_lock(&st->indio_dev->mlock);
+       int number = IIO_EVENT_CODE_EXTRACT_NUM(event_code);
+
+       mutex_lock(&indio_dev->mlock);
        unifiedmask = st->mask_low | st->mask_high;
-       if (this_attr->mask & 0x08) {
-               /* If we are disabling no need to test */
-               if (val == 0)
-                       st->mask_low &= ~(1 << (this_attr->mask & 0x7));
+       if (IIO_EVENT_CODE_EXTRACT_DIR(event_code) == IIO_EV_DIR_FALLING) {
+
+               if (state == 0)
+                       st->mask_low &= ~(1 << number);
                else {
-                       ret = __max1363_check_event_mask(this_attr->mask & 0x7,
-                                                       unifiedmask);
+                       ret = __max1363_check_event_mask((1 << number),
+                                                        unifiedmask);
                        if (ret)
                                goto error_ret;
-                       st->mask_low |= (1 << (this_attr->mask & 0x7));
+                       st->mask_low |= (1 << number);
                }
        } else {
-               if (val == 0)
-                       st->mask_high &= ~(1 << (this_attr->mask));
+               if (state == 0)
+                       st->mask_high &= ~(1 << number);
                else {
-                       ret = __max1363_check_event_mask(this_attr->mask,
-                                                       unifiedmask);
+                       ret = __max1363_check_event_mask((1 << number),
+                                                        unifiedmask);
                        if (ret)
                                goto error_ret;
-                       st->mask_high |= (1 << this_attr->mask);
+                       st->mask_high |= (1 << number);
                }
        }
-       if (st->monitor_on && !st->mask_high && !st->mask_low)
-               iio_remove_event_from_list(this_attr->listel,
-                                       &dev_info->interrupts[0]->ev_list);
-       if (!st->monitor_on && val)
-               iio_add_event_to_list(this_attr->listel,
-                               &dev_info->interrupts[0]->ev_list);
 
        max1363_monitor_mode_update(st, !!(st->mask_high | st->mask_low));
 error_ret:
-       mutex_unlock(&st->indio_dev->mlock);
+       mutex_unlock(&indio_dev->mlock);
 
-       return len;
+       return ret;
 }
 
-IIO_EVENT_SH(max1363_thresh, max1363_int_th);
-
-#define MAX1363_HIGH_THRESH(a) a
-#define MAX1363_LOW_THRESH(a) (a | 0x8)
-
-IIO_EVENT_ATTR_SH(in0_thresh_high_en,
-               iio_event_max1363_thresh,
-               max1363_read_interrupt_config,
-               max1363_write_interrupt_config,
-               MAX1363_HIGH_THRESH(0));
-
-IIO_EVENT_ATTR_SH(in0_thresh_low_en,
-               iio_event_max1363_thresh,
-               max1363_read_interrupt_config,
-               max1363_write_interrupt_config,
-               MAX1363_LOW_THRESH(0));
-
-IIO_EVENT_ATTR_SH(in1_thresh_high_en,
-               iio_event_max1363_thresh,
-               max1363_read_interrupt_config,
-               max1363_write_interrupt_config,
-               MAX1363_HIGH_THRESH(1));
-
-IIO_EVENT_ATTR_SH(in1_thresh_low_en,
-               iio_event_max1363_thresh,
-               max1363_read_interrupt_config,
-               max1363_write_interrupt_config,
-               MAX1363_LOW_THRESH(1));
-
-IIO_EVENT_ATTR_SH(in2_thresh_high_en,
-               iio_event_max1363_thresh,
-               max1363_read_interrupt_config,
-               max1363_write_interrupt_config,
-               MAX1363_HIGH_THRESH(2));
-
-IIO_EVENT_ATTR_SH(in2_thresh_low_en,
-               iio_event_max1363_thresh,
-               max1363_read_interrupt_config,
-               max1363_write_interrupt_config,
-               MAX1363_LOW_THRESH(2));
-
-IIO_EVENT_ATTR_SH(in3_thresh_high_en,
-               iio_event_max1363_thresh,
-               max1363_read_interrupt_config,
-               max1363_write_interrupt_config,
-               MAX1363_HIGH_THRESH(3));
-
-IIO_EVENT_ATTR_SH(in3_thresh_low_en,
-               iio_event_max1363_thresh,
-               max1363_read_interrupt_config,
-               max1363_write_interrupt_config,
-               MAX1363_LOW_THRESH(3));
-
-IIO_EVENT_ATTR_NAMED_SH(in0min1_thresh_high_en,
-                       in0-in1_thresh_high_en,
-                       iio_event_max1363_thresh,
-                       max1363_read_interrupt_config,
-                       max1363_write_interrupt_config,
-                       MAX1363_HIGH_THRESH(4));
-
-IIO_EVENT_ATTR_NAMED_SH(in0min1_thresh_low_en,
-                       in0-in1_thresh_low_en,
-                       iio_event_max1363_thresh,
-                       max1363_read_interrupt_config,
-                       max1363_write_interrupt_config,
-                       MAX1363_LOW_THRESH(4));
-
-IIO_EVENT_ATTR_NAMED_SH(in3min2_thresh_high_en,
-                       in3-in2_thresh_high_en,
-                       iio_event_max1363_thresh,
-                       max1363_read_interrupt_config,
-                       max1363_write_interrupt_config,
-                       MAX1363_HIGH_THRESH(5));
-
-IIO_EVENT_ATTR_NAMED_SH(in3min2_thresh_low_en,
-                       in3-in2_thresh_low_en,
-                       iio_event_max1363_thresh,
-                       max1363_read_interrupt_config,
-                       max1363_write_interrupt_config,
-                       MAX1363_LOW_THRESH(5));
-
-IIO_EVENT_ATTR_NAMED_SH(in1min0_thresh_high_en,
-                       in1-in0_thresh_high_en,
-                       iio_event_max1363_thresh,
-                       max1363_read_interrupt_config,
-                       max1363_write_interrupt_config,
-                       MAX1363_HIGH_THRESH(6));
-
-IIO_EVENT_ATTR_NAMED_SH(in1min0_thresh_low_en,
-                       in1-in0_thresh_low_en,
-                       iio_event_max1363_thresh,
-                       max1363_read_interrupt_config,
-                       max1363_write_interrupt_config,
-                       MAX1363_LOW_THRESH(6));
-
-IIO_EVENT_ATTR_NAMED_SH(in2min3_thresh_high_en,
-                       in2-in3_thresh_high_en,
-                       iio_event_max1363_thresh,
-                       max1363_read_interrupt_config,
-                       max1363_write_interrupt_config,
-                       MAX1363_HIGH_THRESH(7));
-
-IIO_EVENT_ATTR_NAMED_SH(in2min3_thresh_low_en,
-                       in2-in3_thresh_low_en,
-                       iio_event_max1363_thresh,
-                       max1363_read_interrupt_config,
-                       max1363_write_interrupt_config,
-                       MAX1363_LOW_THRESH(7));
-
 /*
  * As with scan_elements, only certain sets of these can
  * be combined.
  */
 static struct attribute *max1363_event_attributes[] = {
-       &iio_dev_attr_in0_thresh_high_value.dev_attr.attr,
-       &iio_dev_attr_in0_thresh_low_value.dev_attr.attr,
-       &iio_dev_attr_in1_thresh_high_value.dev_attr.attr,
-       &iio_dev_attr_in1_thresh_low_value.dev_attr.attr,
-       &iio_dev_attr_in2_thresh_high_value.dev_attr.attr,
-       &iio_dev_attr_in2_thresh_low_value.dev_attr.attr,
-       &iio_dev_attr_in3_thresh_high_value.dev_attr.attr,
-       &iio_dev_attr_in3_thresh_low_value.dev_attr.attr,
-       &iio_dev_attr_in0min1_thresh_high_value.dev_attr.attr,
-       &iio_dev_attr_in0min1_thresh_low_value.dev_attr.attr,
-       &iio_dev_attr_in2min3_thresh_high_value.dev_attr.attr,
-       &iio_dev_attr_in2min3_thresh_low_value.dev_attr.attr,
-       &iio_dev_attr_in1min0_thresh_high_value.dev_attr.attr,
-       &iio_dev_attr_in1min0_thresh_low_value.dev_attr.attr,
-       &iio_dev_attr_in3min2_thresh_high_value.dev_attr.attr,
-       &iio_dev_attr_in3min2_thresh_low_value.dev_attr.attr,
        &iio_dev_attr_sampling_frequency.dev_attr.attr,
        &iio_const_attr_sampling_frequency_available.dev_attr.attr,
-       &iio_event_attr_in0_thresh_high_en.dev_attr.attr,
-       &iio_event_attr_in0_thresh_low_en.dev_attr.attr,
-       &iio_event_attr_in1_thresh_high_en.dev_attr.attr,
-       &iio_event_attr_in1_thresh_low_en.dev_attr.attr,
-       &iio_event_attr_in2_thresh_high_en.dev_attr.attr,
-       &iio_event_attr_in2_thresh_low_en.dev_attr.attr,
-       &iio_event_attr_in3_thresh_high_en.dev_attr.attr,
-       &iio_event_attr_in3_thresh_low_en.dev_attr.attr,
-       &iio_event_attr_in0min1_thresh_high_en.dev_attr.attr,
-       &iio_event_attr_in0min1_thresh_low_en.dev_attr.attr,
-       &iio_event_attr_in3min2_thresh_high_en.dev_attr.attr,
-       &iio_event_attr_in3min2_thresh_low_en.dev_attr.attr,
-       &iio_event_attr_in1min0_thresh_high_en.dev_attr.attr,
-       &iio_event_attr_in1min0_thresh_low_en.dev_attr.attr,
-       &iio_event_attr_in2min3_thresh_high_en.dev_attr.attr,
-       &iio_event_attr_in2min3_thresh_low_en.dev_attr.attr,
        NULL,
 };
 
@@ -1655,6 +825,411 @@ static struct attribute_group max1363_event_attribute_group = {
        .attrs = max1363_event_attributes,
 };
 
+#define MAX1363_EVENT_FUNCS                                            \
+
+
+static const struct iio_info max1238_info = {
+       .read_raw = &max1363_read_raw,
+       .driver_module = THIS_MODULE,
+};
+
+static const struct iio_info max1363_info = {
+       .read_event_value = &max1363_read_thresh,
+       .write_event_value = &max1363_write_thresh,
+       .read_event_config = &max1363_read_event_config,
+       .write_event_config = &max1363_write_event_config,
+       .read_raw = &max1363_read_raw,
+       .driver_module = THIS_MODULE,
+       .num_interrupt_lines = 1,
+       .event_attrs = &max1363_event_attribute_group,
+};
+
+/* max1363 and max1368 tested - rest from data sheet */
+static const struct max1363_chip_info max1363_chip_info_tbl[] = {
+       [max1361] = {
+               .bits = 10,
+               .int_vref_mv = 2048,
+               .mode_list = max1363_mode_list,
+               .num_modes = ARRAY_SIZE(max1363_mode_list),
+               .default_mode = s0to3,
+               .channels = max1361_channels,
+               .num_channels = ARRAY_SIZE(max1361_channels),
+               .info = &max1363_info,
+       },
+       [max1362] = {
+               .bits = 10,
+               .int_vref_mv = 4096,
+               .mode_list = max1363_mode_list,
+               .num_modes = ARRAY_SIZE(max1363_mode_list),
+               .default_mode = s0to3,
+               .channels = max1361_channels,
+               .num_channels = ARRAY_SIZE(max1361_channels),
+               .info = &max1363_info,
+       },
+       [max1363] = {
+               .bits = 12,
+               .int_vref_mv = 2048,
+               .mode_list = max1363_mode_list,
+               .num_modes = ARRAY_SIZE(max1363_mode_list),
+               .default_mode = s0to3,
+               .channels = max1363_channels,
+               .num_channels = ARRAY_SIZE(max1363_channels),
+               .info = &max1363_info,
+       },
+       [max1364] = {
+               .bits = 12,
+               .int_vref_mv = 4096,
+               .mode_list = max1363_mode_list,
+               .num_modes = ARRAY_SIZE(max1363_mode_list),
+               .default_mode = s0to3,
+               .channels = max1363_channels,
+               .num_channels = ARRAY_SIZE(max1363_channels),
+               .info = &max1363_info,
+       },
+       [max1036] = {
+               .bits = 8,
+               .int_vref_mv = 4096,
+               .mode_list = max1236_mode_list,
+               .num_modes = ARRAY_SIZE(max1236_mode_list),
+               .default_mode = s0to3,
+               .info = &max1238_info,
+               .channels = max1036_channels,
+               .num_channels = ARRAY_SIZE(max1036_channels),
+       },
+       [max1037] = {
+               .bits = 8,
+               .int_vref_mv = 2048,
+               .mode_list = max1236_mode_list,
+               .num_modes = ARRAY_SIZE(max1236_mode_list),
+               .default_mode = s0to3,
+               .info = &max1238_info,
+               .channels = max1036_channels,
+               .num_channels = ARRAY_SIZE(max1036_channels),
+       },
+       [max1038] = {
+               .bits = 8,
+               .int_vref_mv = 4096,
+               .mode_list = max1238_mode_list,
+               .num_modes = ARRAY_SIZE(max1238_mode_list),
+               .default_mode = s0to11,
+               .info = &max1238_info,
+               .channels = max1038_channels,
+               .num_channels = ARRAY_SIZE(max1038_channels),
+       },
+       [max1039] = {
+               .bits = 8,
+               .int_vref_mv = 2048,
+               .mode_list = max1238_mode_list,
+               .num_modes = ARRAY_SIZE(max1238_mode_list),
+               .default_mode = s0to11,
+               .info = &max1238_info,
+               .channels = max1038_channels,
+               .num_channels = ARRAY_SIZE(max1038_channels),
+       },
+       [max1136] = {
+               .bits = 10,
+               .int_vref_mv = 4096,
+               .mode_list = max1236_mode_list,
+               .num_modes = ARRAY_SIZE(max1236_mode_list),
+               .default_mode = s0to3,
+               .info = &max1238_info,
+               .channels = max1136_channels,
+               .num_channels = ARRAY_SIZE(max1136_channels),
+       },
+       [max1137] = {
+               .bits = 10,
+               .int_vref_mv = 2048,
+               .mode_list = max1236_mode_list,
+               .num_modes = ARRAY_SIZE(max1236_mode_list),
+               .default_mode = s0to3,
+               .info = &max1238_info,
+               .channels = max1136_channels,
+               .num_channels = ARRAY_SIZE(max1136_channels),
+       },
+       [max1138] = {
+               .bits = 10,
+               .int_vref_mv = 4096,
+               .mode_list = max1238_mode_list,
+               .num_modes = ARRAY_SIZE(max1238_mode_list),
+               .default_mode = s0to11,
+               .info = &max1238_info,
+               .channels = max1138_channels,
+               .num_channels = ARRAY_SIZE(max1138_channels),
+       },
+       [max1139] = {
+               .bits = 10,
+               .int_vref_mv = 2048,
+               .mode_list = max1238_mode_list,
+               .num_modes = ARRAY_SIZE(max1238_mode_list),
+               .default_mode = s0to11,
+               .info = &max1238_info,
+               .channels = max1138_channels,
+               .num_channels = ARRAY_SIZE(max1138_channels),
+       },
+       [max1236] = {
+               .bits = 12,
+               .int_vref_mv = 4096,
+               .mode_list = max1236_mode_list,
+               .num_modes = ARRAY_SIZE(max1236_mode_list),
+               .default_mode = s0to3,
+               .info = &max1238_info,
+               .channels = max1236_channels,
+               .num_channels = ARRAY_SIZE(max1236_channels),
+       },
+       [max1237] = {
+               .bits = 12,
+               .int_vref_mv = 2048,
+               .mode_list = max1236_mode_list,
+               .num_modes = ARRAY_SIZE(max1236_mode_list),
+               .default_mode = s0to3,
+               .info = &max1238_info,
+               .channels = max1236_channels,
+               .num_channels = ARRAY_SIZE(max1236_channels),
+       },
+       [max1238] = {
+               .bits = 12,
+               .int_vref_mv = 4096,
+               .mode_list = max1238_mode_list,
+               .num_modes = ARRAY_SIZE(max1238_mode_list),
+               .default_mode = s0to11,
+               .info = &max1238_info,
+               .channels = max1238_channels,
+               .num_channels = ARRAY_SIZE(max1238_channels),
+       },
+       [max1239] = {
+               .bits = 12,
+               .int_vref_mv = 2048,
+               .mode_list = max1238_mode_list,
+               .num_modes = ARRAY_SIZE(max1238_mode_list),
+               .default_mode = s0to11,
+               .info = &max1238_info,
+               .channels = max1238_channels,
+               .num_channels = ARRAY_SIZE(max1238_channels),
+       },
+       [max11600] = {
+               .bits = 8,
+               .int_vref_mv = 4096,
+               .mode_list = max11607_mode_list,
+               .num_modes = ARRAY_SIZE(max11607_mode_list),
+               .default_mode = s0to3,
+               .info = &max1238_info,
+               .channels = max1036_channels,
+               .num_channels = ARRAY_SIZE(max1036_channels),
+       },
+       [max11601] = {
+               .bits = 8,
+               .int_vref_mv = 2048,
+               .mode_list = max11607_mode_list,
+               .num_modes = ARRAY_SIZE(max11607_mode_list),
+               .default_mode = s0to3,
+               .info = &max1238_info,
+               .channels = max1036_channels,
+               .num_channels = ARRAY_SIZE(max1036_channels),
+       },
+       [max11602] = {
+               .bits = 8,
+               .int_vref_mv = 4096,
+               .mode_list = max11608_mode_list,
+               .num_modes = ARRAY_SIZE(max11608_mode_list),
+               .default_mode = s0to7,
+               .info = &max1238_info,
+               .channels = max11602_channels,
+               .num_channels = ARRAY_SIZE(max11602_channels),
+       },
+       [max11603] = {
+               .bits = 8,
+               .int_vref_mv = 2048,
+               .mode_list = max11608_mode_list,
+               .num_modes = ARRAY_SIZE(max11608_mode_list),
+               .default_mode = s0to7,
+               .info = &max1238_info,
+               .channels = max11602_channels,
+               .num_channels = ARRAY_SIZE(max11602_channels),
+       },
+       [max11604] = {
+               .bits = 8,
+               .int_vref_mv = 4098,
+               .mode_list = max1238_mode_list,
+               .num_modes = ARRAY_SIZE(max1238_mode_list),
+               .default_mode = s0to11,
+               .info = &max1238_info,
+               .channels = max1238_channels,
+               .num_channels = ARRAY_SIZE(max1238_channels),
+       },
+       [max11605] = {
+               .bits = 8,
+               .int_vref_mv = 2048,
+               .mode_list = max1238_mode_list,
+               .num_modes = ARRAY_SIZE(max1238_mode_list),
+               .default_mode = s0to11,
+               .info = &max1238_info,
+               .channels = max1238_channels,
+               .num_channels = ARRAY_SIZE(max1238_channels),
+       },
+       [max11606] = {
+               .bits = 10,
+               .int_vref_mv = 4096,
+               .mode_list = max11607_mode_list,
+               .num_modes = ARRAY_SIZE(max11607_mode_list),
+               .default_mode = s0to3,
+               .info = &max1238_info,
+               .channels = max1136_channels,
+               .num_channels = ARRAY_SIZE(max1136_channels),
+       },
+       [max11607] = {
+               .bits = 10,
+               .int_vref_mv = 2048,
+               .mode_list = max11607_mode_list,
+               .num_modes = ARRAY_SIZE(max11607_mode_list),
+               .default_mode = s0to3,
+               .info = &max1238_info,
+               .channels = max1136_channels,
+               .num_channels = ARRAY_SIZE(max1136_channels),
+       },
+       [max11608] = {
+               .bits = 10,
+               .int_vref_mv = 4096,
+               .mode_list = max11608_mode_list,
+               .num_modes = ARRAY_SIZE(max11608_mode_list),
+               .default_mode = s0to7,
+               .info = &max1238_info,
+               .channels = max11608_channels,
+               .num_channels = ARRAY_SIZE(max11608_channels),
+       },
+       [max11609] = {
+               .bits = 10,
+               .int_vref_mv = 2048,
+               .mode_list = max11608_mode_list,
+               .num_modes = ARRAY_SIZE(max11608_mode_list),
+               .default_mode = s0to7,
+               .info = &max1238_info,
+               .channels = max11608_channels,
+               .num_channels = ARRAY_SIZE(max11608_channels),
+       },
+       [max11610] = {
+               .bits = 10,
+               .int_vref_mv = 4098,
+               .mode_list = max1238_mode_list,
+               .num_modes = ARRAY_SIZE(max1238_mode_list),
+               .default_mode = s0to11,
+               .info = &max1238_info,
+               .channels = max1238_channels,
+               .num_channels = ARRAY_SIZE(max1238_channels),
+       },
+       [max11611] = {
+               .bits = 10,
+               .int_vref_mv = 2048,
+               .mode_list = max1238_mode_list,
+               .num_modes = ARRAY_SIZE(max1238_mode_list),
+               .default_mode = s0to11,
+               .info = &max1238_info,
+               .channels = max1238_channels,
+               .num_channels = ARRAY_SIZE(max1238_channels),
+       },
+       [max11612] = {
+               .bits = 12,
+               .int_vref_mv = 4096,
+               .mode_list = max11607_mode_list,
+               .num_modes = ARRAY_SIZE(max11607_mode_list),
+               .default_mode = s0to3,
+               .info = &max1238_info,
+               .channels = max1363_channels,
+               .num_channels = ARRAY_SIZE(max1363_channels),
+       },
+       [max11613] = {
+               .bits = 12,
+               .int_vref_mv = 2048,
+               .mode_list = max11607_mode_list,
+               .num_modes = ARRAY_SIZE(max11607_mode_list),
+               .default_mode = s0to3,
+               .info = &max1238_info,
+               .channels = max1363_channels,
+               .num_channels = ARRAY_SIZE(max1363_channels),
+       },
+       [max11614] = {
+               .bits = 12,
+               .int_vref_mv = 4096,
+               .mode_list = max11608_mode_list,
+               .num_modes = ARRAY_SIZE(max11608_mode_list),
+               .default_mode = s0to7,
+               .info = &max1238_info,
+               .channels = max11614_channels,
+               .num_channels = ARRAY_SIZE(max11614_channels),
+       },
+       [max11615] = {
+               .bits = 12,
+               .int_vref_mv = 2048,
+               .mode_list = max11608_mode_list,
+               .num_modes = ARRAY_SIZE(max11608_mode_list),
+               .default_mode = s0to7,
+               .info = &max1238_info,
+               .channels = max11614_channels,
+               .num_channels = ARRAY_SIZE(max11614_channels),
+       },
+       [max11616] = {
+               .bits = 12,
+               .int_vref_mv = 4098,
+               .mode_list = max1238_mode_list,
+               .num_modes = ARRAY_SIZE(max1238_mode_list),
+               .default_mode = s0to11,
+               .info = &max1238_info,
+               .channels = max1238_channels,
+               .num_channels = ARRAY_SIZE(max1238_channels),
+       },
+       [max11617] = {
+               .bits = 12,
+               .int_vref_mv = 2048,
+               .mode_list = max1238_mode_list,
+               .num_modes = ARRAY_SIZE(max1238_mode_list),
+               .default_mode = s0to11,
+               .info = &max1238_info,
+               .channels = max1238_channels,
+               .num_channels = ARRAY_SIZE(max1238_channels),
+       },
+       [max11644] = {
+               .bits = 12,
+               .int_vref_mv = 2048,
+               .mode_list = max11644_mode_list,
+               .num_modes = ARRAY_SIZE(max11644_mode_list),
+               .default_mode = s0to1,
+               .info = &max1238_info,
+               .channels = max11644_channels,
+               .num_channels = ARRAY_SIZE(max11644_channels),
+       },
+       [max11645] = {
+               .bits = 12,
+               .int_vref_mv = 4096,
+               .mode_list = max11644_mode_list,
+               .num_modes = ARRAY_SIZE(max11644_mode_list),
+               .default_mode = s0to1,
+               .info = &max1238_info,
+               .channels = max11644_channels,
+               .num_channels = ARRAY_SIZE(max11644_channels),
+       },
+       [max11646] = {
+               .bits = 10,
+               .int_vref_mv = 2048,
+               .mode_list = max11644_mode_list,
+               .num_modes = ARRAY_SIZE(max11644_mode_list),
+               .default_mode = s0to1,
+               .info = &max1238_info,
+               .channels = max11646_channels,
+               .num_channels = ARRAY_SIZE(max11646_channels),
+       },
+       [max11647] = {
+               .bits = 10,
+               .int_vref_mv = 4096,
+               .mode_list = max11644_mode_list,
+               .num_modes = ARRAY_SIZE(max11644_mode_list),
+               .default_mode = s0to1,
+               .info = &max1238_info,
+               .channels = max11646_channels,
+               .num_channels = ARRAY_SIZE(max11646_channels),
+       },
+};
+
+
+
 static int max1363_initial_setup(struct max1363_state *st)
 {
        st->setupbyte = MAX1363_SETUP_AIN3_IS_AIN3_REF_IS_VDD
@@ -1675,126 +1250,116 @@ static int __devinit max1363_probe(struct i2c_client *client,
                                   const struct i2c_device_id *id)
 {
        int ret, i, regdone = 0;
-       struct max1363_state *st = kzalloc(sizeof(*st), GFP_KERNEL);
-       if (st == NULL) {
-               ret = -ENOMEM;
-               goto error_ret;
-       }
-
-       /* this is only used for device removal purposes */
-       i2c_set_clientdata(client, st);
-
-       atomic_set(&st->protect_ring, 0);
+       struct max1363_state *st;
+       struct iio_dev *indio_dev;
+       struct regulator *reg;
 
-       st->chip_info = &max1363_chip_info_tbl[id->driver_data];
-       st->reg = regulator_get(&client->dev, "vcc");
-       if (!IS_ERR(st->reg)) {
-               ret = regulator_enable(st->reg);
+       reg = regulator_get(&client->dev, "vcc");
+       if (!IS_ERR(reg)) {
+               ret = regulator_enable(reg);
                if (ret)
                        goto error_put_reg;
        }
-       st->client = client;
 
-       st->indio_dev = iio_allocate_device();
-       if (st->indio_dev == NULL) {
+       indio_dev = iio_allocate_device(sizeof(struct max1363_state));
+       if (indio_dev == NULL) {
                ret = -ENOMEM;
                goto error_disable_reg;
        }
+       st = iio_priv(indio_dev);
+       st->reg = reg;
+       /* this is only used for device removal purposes */
+       i2c_set_clientdata(client, indio_dev);
+
+       st->chip_info = &max1363_chip_info_tbl[id->driver_data];
+       st->client = client;
 
-       st->indio_dev->available_scan_masks
-               = kzalloc(sizeof(*st->indio_dev->available_scan_masks)*
+       indio_dev->available_scan_masks
+               = kzalloc(sizeof(*indio_dev->available_scan_masks)*
                          (st->chip_info->num_modes + 1), GFP_KERNEL);
-       if (!st->indio_dev->available_scan_masks) {
+       if (!indio_dev->available_scan_masks) {
                ret = -ENOMEM;
                goto error_free_device;
        }
 
        for (i = 0; i < st->chip_info->num_modes; i++)
-               st->indio_dev->available_scan_masks[i] =
+               indio_dev->available_scan_masks[i] =
                        max1363_mode_table[st->chip_info->mode_list[i]]
                        .modemask;
        /* Estabilish that the iio_dev is a child of the i2c device */
-       st->indio_dev->dev.parent = &client->dev;
-       st->indio_dev->attrs = st->chip_info->dev_attrs;
-
-       /* Todo: this shouldn't be here. */
-       st->indio_dev->dev_data = (void *)(st);
-       st->indio_dev->driver_module = THIS_MODULE;
-       st->indio_dev->modes = INDIO_DIRECT_MODE;
-       if (st->chip_info->monitor_mode && client->irq) {
-               st->indio_dev->num_interrupt_lines = 1;
-               st->indio_dev->event_attrs
-                       = &max1363_event_attribute_group;
-       }
+       indio_dev->dev.parent = &client->dev;
+       indio_dev->name = id->name;
 
+       indio_dev->info = st->chip_info->info;
+       indio_dev->modes = INDIO_DIRECT_MODE;
        ret = max1363_initial_setup(st);
-       if (ret)
+       if (ret < 0)
                goto error_free_available_scan_masks;
 
-       ret = max1363_register_ring_funcs_and_init(st->indio_dev);
+       ret = max1363_register_ring_funcs_and_init(indio_dev);
        if (ret)
                goto error_free_available_scan_masks;
 
-       ret = iio_device_register(st->indio_dev);
+       ret = iio_device_register(indio_dev);
        if (ret)
                goto error_cleanup_ring;
        regdone = 1;
-       ret = iio_ring_buffer_register(st->indio_dev->ring, 0);
+       ret = iio_ring_buffer_register_ex(indio_dev->ring, 0,
+                                         st->chip_info->channels,
+                                         st->chip_info->num_channels);
        if (ret)
                goto error_cleanup_ring;
 
-       if (st->chip_info->monitor_mode && client->irq) {
-               ret = iio_register_interrupt_line(client->irq,
-                                               st->indio_dev,
-                                               0,
-                                               IRQF_TRIGGER_RISING,
-                                               client->name);
+       if (client->irq) {
+               ret = request_threaded_irq(st->client->irq,
+                                          NULL,
+                                          &max1363_event_handler,
+                                          IRQF_TRIGGER_RISING | IRQF_ONESHOT,
+                                          "max1363_event",
+                                          indio_dev);
+
                if (ret)
                        goto error_uninit_ring;
-
-               INIT_WORK(&st->thresh_work, max1363_thresh_handler_bh);
        }
 
        return 0;
 error_uninit_ring:
-       iio_ring_buffer_unregister(st->indio_dev->ring);
+       iio_ring_buffer_unregister(indio_dev->ring);
 error_cleanup_ring:
-       max1363_ring_cleanup(st->indio_dev);
+       max1363_ring_cleanup(indio_dev);
 error_free_available_scan_masks:
-       kfree(st->indio_dev->available_scan_masks);
+       kfree(indio_dev->available_scan_masks);
 error_free_device:
        if (!regdone)
-               iio_free_device(st->indio_dev);
+               iio_free_device(indio_dev);
        else
-               iio_device_unregister(st->indio_dev);
+               iio_device_unregister(indio_dev);
 error_disable_reg:
        if (!IS_ERR(st->reg))
                regulator_disable(st->reg);
 error_put_reg:
        if (!IS_ERR(st->reg))
                regulator_put(st->reg);
-       kfree(st);
 
-error_ret:
        return ret;
 }
 
 static int max1363_remove(struct i2c_client *client)
 {
-       struct max1363_state *st = i2c_get_clientdata(client);
-       struct iio_dev *indio_dev = st->indio_dev;
+       struct iio_dev *indio_dev = i2c_get_clientdata(client);
+       struct max1363_state *st = iio_priv(indio_dev);
+       struct regulator *reg = st->reg;
 
-       if (st->chip_info->monitor_mode && client->irq)
-               iio_unregister_interrupt_line(st->indio_dev, 0);
+       if (client->irq)
+               free_irq(st->client->irq, indio_dev);
        iio_ring_buffer_unregister(indio_dev->ring);
        max1363_ring_cleanup(indio_dev);
-       kfree(st->indio_dev->available_scan_masks);
-       iio_device_unregister(indio_dev);
-       if (!IS_ERR(st->reg)) {
-               regulator_disable(st->reg);
-               regulator_put(st->reg);
+       kfree(indio_dev->available_scan_masks);
+       if (!IS_ERR(reg)) {
+               regulator_disable(reg);
+               regulator_put(reg);
        }
-       kfree(st);
+       iio_device_unregister(indio_dev);
 
        return 0;
 }
index d36fcc62e976dff43560ad7bbb7585e7919fa2d3..f43befd1f776baf105da7c4981e665cd53e942af 100644 (file)
@@ -9,8 +9,6 @@
  */
 
 #include <linux/interrupt.h>
-#include <linux/gpio.h>
-#include <linux/workqueue.h>
 #include <linux/device.h>
 #include <linux/slab.h>
 #include <linux/kernel.h>
 
 #include "max1363.h"
 
-/* Todo: test this */
 int max1363_single_channel_from_ring(long mask, struct max1363_state *st)
 {
-       struct iio_ring_buffer *ring = st->indio_dev->ring;
+       struct iio_ring_buffer *ring = iio_priv_to_dev(st)->ring;
        int count = 0, ret;
        u8 *ring_data;
        if (!(st->current_mode->modemask & mask)) {
@@ -38,12 +35,13 @@ int max1363_single_channel_from_ring(long mask, struct max1363_state *st)
                goto error_ret;
        }
 
-       ring_data = kmalloc(ring->access.get_bytes_per_datum(ring), GFP_KERNEL);
+       ring_data = kmalloc(ring->access->get_bytes_per_datum(ring),
+                           GFP_KERNEL);
        if (ring_data == NULL) {
                ret = -ENOMEM;
                goto error_ret;
        }
-       ret = ring->access.read_last(ring, ring_data);
+       ret = ring->access->read_last(ring, ring_data);
        if (ret)
                goto error_free_ring_data;
        /* Need a count of channels prior to this one */
@@ -65,6 +63,7 @@ error_ret:
        return ret;
 }
 
+
 /**
  * max1363_ring_preenable() - setup the parameters of the ring before enabling
  *
@@ -74,9 +73,9 @@ error_ret:
  **/
 static int max1363_ring_preenable(struct iio_dev *indio_dev)
 {
-       struct max1363_state *st = indio_dev->dev_data;
+       struct max1363_state *st = iio_priv(indio_dev);
        struct iio_ring_buffer *ring = indio_dev->ring;
-       size_t d_size;
+       size_t d_size = 0;
        unsigned long numvals;
 
        /*
@@ -91,50 +90,26 @@ static int max1363_ring_preenable(struct iio_dev *indio_dev)
        max1363_set_scan_mode(st);
 
        numvals = hweight_long(st->current_mode->modemask);
-       if (ring->access.set_bytes_per_datum) {
+       if (ring->access->set_bytes_per_datum) {
+               if (ring->scan_timestamp)
+                       d_size += sizeof(s64);
                if (st->chip_info->bits != 8)
-                       d_size = numvals*2 + sizeof(s64);
+                       d_size += numvals*2;
                else
-                       d_size = numvals + sizeof(s64);
-               if (d_size % 8)
+                       d_size += numvals;
+               if (ring->scan_timestamp && (d_size % 8))
                        d_size += 8 - (d_size % 8);
-               ring->access.set_bytes_per_datum(ring, d_size);
+               ring->access->set_bytes_per_datum(ring, d_size);
        }
 
        return 0;
 }
 
-
-/**
- * max1363_poll_func_th() - th of trigger launched polling to ring buffer
- *
- * As sampling only occurs on i2c comms occurring, leave timestamping until
- * then.  Some triggers will generate their own time stamp.  Currently
- * there is no way of notifying them when no one cares.
- **/
-static void max1363_poll_func_th(struct iio_dev *indio_dev, s64 time)
+static irqreturn_t max1363_trigger_handler(int irq, void *p)
 {
-       struct max1363_state *st = indio_dev->dev_data;
-
-       schedule_work(&st->poll_work);
-
-       return;
-}
-/**
- * max1363_poll_bh_to_ring() - bh of trigger launched polling to ring buffer
- * @work_s:    the work struct through which this was scheduled
- *
- * Currently there is no option in this driver to disable the saving of
- * timestamps within the ring.
- * I think the one copy of this at a time was to avoid problems if the
- * trigger was set far too high and the reads then locked up the computer.
- **/
-static void max1363_poll_bh_to_ring(struct work_struct *work_s)
-{
-       struct max1363_state *st = container_of(work_s, struct max1363_state,
-                                                 poll_work);
-       struct iio_dev *indio_dev = st->indio_dev;
-       struct iio_sw_ring_buffer *sw_ring = iio_to_sw_ring(indio_dev->ring);
+       struct iio_poll_func *pf = p;
+       struct iio_dev *indio_dev = pf->private_data;
+       struct max1363_state *st = iio_priv(indio_dev);
        s64 time_ns;
        __u8 *rxbuf;
        int b_sent;
@@ -149,20 +124,16 @@ static void max1363_poll_bh_to_ring(struct work_struct *work_s)
        if (d_size % sizeof(s64))
                d_size += sizeof(s64) - (d_size % sizeof(s64));
 
-       /* Ensure only one copy of this function running at a time */
-       if (atomic_inc_return(&st->protect_ring) > 1)
-               return;
-
        /* Monitor mode prevents reading. Whilst not currently implemented
         * might as well have this test in here in the meantime as it does
         * no harm.
         */
        if (numvals == 0)
-               return;
+               return IRQ_HANDLED;
 
        rxbuf = kmalloc(d_size, GFP_KERNEL);
        if (rxbuf == NULL)
-               return;
+               return -ENOMEM;
        if (st->chip_info->bits != 8)
                b_sent = i2c_master_recv(st->client, rxbuf, numvals*2);
        else
@@ -174,16 +145,23 @@ static void max1363_poll_bh_to_ring(struct work_struct *work_s)
 
        memcpy(rxbuf + d_size - sizeof(s64), &time_ns, sizeof(time_ns));
 
-       indio_dev->ring->access.store_to(&sw_ring->buf, rxbuf, time_ns);
+       indio_dev->ring->access->store_to(indio_dev->ring, rxbuf, time_ns);
 done:
+       iio_trigger_notify_done(indio_dev->trig);
        kfree(rxbuf);
-       atomic_dec(&st->protect_ring);
+
+       return IRQ_HANDLED;
 }
 
+static const struct iio_ring_setup_ops max1363_ring_setup_ops = {
+       .postenable = &iio_triggered_ring_postenable,
+       .preenable = &max1363_ring_preenable,
+       .predisable = &iio_triggered_ring_predisable,
+};
 
 int max1363_register_ring_funcs_and_init(struct iio_dev *indio_dev)
 {
-       struct max1363_state *st = indio_dev->dev_data;
+       struct max1363_state *st = iio_priv(indio_dev);
        int ret = 0;
 
        indio_dev->ring = iio_sw_rb_allocate(indio_dev);
@@ -191,22 +169,27 @@ int max1363_register_ring_funcs_and_init(struct iio_dev *indio_dev)
                ret = -ENOMEM;
                goto error_ret;
        }
-       /* Effectively select the ring buffer implementation */
-       iio_ring_sw_register_funcs(&indio_dev->ring->access);
-       ret = iio_alloc_pollfunc(indio_dev, NULL, &max1363_poll_func_th);
-       if (ret)
+       indio_dev->pollfunc = iio_alloc_pollfunc(NULL,
+                                                &max1363_trigger_handler,
+                                                IRQF_ONESHOT,
+                                                indio_dev,
+                                                "%s_consumer%d",
+                                                st->client->name,
+                                                indio_dev->id);
+       if (indio_dev->pollfunc == NULL) {
+               ret = -ENOMEM;
                goto error_deallocate_sw_rb;
-
+       }
+       /* Effectively select the ring buffer implementation */
+       indio_dev->ring->access = &ring_sw_access_funcs;
        /* Ring buffer functions - here trigger setup related */
-       indio_dev->ring->scan_el_attrs = st->chip_info->scan_attrs;
-       indio_dev->ring->postenable = &iio_triggered_ring_postenable;
-       indio_dev->ring->preenable = &max1363_ring_preenable;
-       indio_dev->ring->predisable = &iio_triggered_ring_predisable;
-       INIT_WORK(&st->poll_work, &max1363_poll_bh_to_ring);
+       indio_dev->ring->setup_ops = &max1363_ring_setup_ops;
 
        /* Flag that polled ring buffering is possible */
        indio_dev->modes |= INDIO_RING_TRIGGERED;
+
        return 0;
+
 error_deallocate_sw_rb:
        iio_sw_rb_free(indio_dev->ring);
 error_ret:
@@ -221,6 +204,6 @@ void max1363_ring_cleanup(struct iio_dev *indio_dev)
                iio_trigger_dettach_poll_func(indio_dev->trig,
                                              indio_dev->pollfunc);
        }
-       kfree(indio_dev->pollfunc);
+       iio_dealloc_pollfunc(indio_dev->pollfunc);
        iio_sw_rb_free(indio_dev->ring);
 }
index d1b5b13629d926533d59f5af3abdec98cd0093c3..7097deb0f309cb96f66d7611bba41b2e562d9f26 100644 (file)
  */
 
 struct adt7316_chip_info {
-       const char              *name;
        struct iio_dev          *indio_dev;
-       struct work_struct      thresh_work;
-       s64                     last_timestamp;
        struct adt7316_bus      bus;
        u16                     ldac_pin;
        u16                     int_mask;       /* 0x2f */
@@ -403,7 +400,7 @@ static ssize_t adt7316_show_ad_channel(struct device *dev,
                return sprintf(buf, "5 - AIN4\n");
        default:
                return sprintf(buf, "N/A\n");
-       };
+       }
 }
 
 static ssize_t adt7316_store_ad_channel(struct device *dev,
@@ -465,7 +462,7 @@ static ssize_t adt7316_show_all_ad_channels(struct device *dev,
 
        if ((chip->id & ID_FAMILY_MASK) == ID_ADT75XX)
                return sprintf(buf, "0 - VDD\n1 - Internal Temperature\n"
-                               "2 - External Temperature or AIN2\n"
+                               "2 - External Temperature or AIN1\n"
                                "3 - AIN2\n4 - AIN3\n5 - AIN4\n");
        else
                return sprintf(buf, "0 - VDD\n1 - Internal Temperature\n"
@@ -893,7 +890,7 @@ static ssize_t adt7316_show_DAC_update_mode(struct device *dev,
                        return sprintf(buf, "2 - auto at MSB DAC ABCD writing\n");
                default: /* ADT7316_DA_EN_MODE_LDAC */
                        return sprintf(buf, "3 - manual\n");
-               };
+               }
        }
 }
 
@@ -1205,7 +1202,7 @@ static ssize_t adt7316_show_ad(struct adt7316_chip_info *chip,
                        return sprintf(buf, "%d\n", data);
                else
                        break;
-       };
+       }
 
        if (data & ADT7316_T_VALUE_SIGN) {
                /* convert supplement to positive value */
@@ -1674,18 +1671,6 @@ static ssize_t adt7316_show_bus_type(struct device *dev,
 
 static IIO_DEVICE_ATTR(bus_type, S_IRUGO, adt7316_show_bus_type, NULL, 0);
 
-static ssize_t adt7316_show_name(struct device *dev,
-               struct device_attribute *attr,
-               char *buf)
-{
-       struct iio_dev *dev_info = dev_get_drvdata(dev);
-       struct adt7316_chip_info *chip = dev_info->dev_data;
-
-       return sprintf(buf, "%s\n", chip->name);
-}
-
-static IIO_DEVICE_ATTR(name, S_IRUGO, adt7316_show_name, NULL, 0);
-
 static struct attribute *adt7316_attributes[] = {
        &iio_dev_attr_all_modes.dev_attr.attr,
        &iio_dev_attr_mode.dev_attr.attr,
@@ -1722,7 +1707,6 @@ static struct attribute *adt7316_attributes[] = {
        &iio_dev_attr_manufactorer_id.dev_attr.attr,
        &iio_dev_attr_device_rev.dev_attr.attr,
        &iio_dev_attr_bus_type.dev_attr.attr,
-       &iio_dev_attr_name.dev_attr.attr,
        NULL,
 };
 
@@ -1771,7 +1755,6 @@ static struct attribute *adt7516_attributes[] = {
        &iio_dev_attr_manufactorer_id.dev_attr.attr,
        &iio_dev_attr_device_rev.dev_attr.attr,
        &iio_dev_attr_bus_type.dev_attr.attr,
-       &iio_dev_attr_name.dev_attr.attr,
        NULL,
 };
 
@@ -1779,70 +1762,77 @@ static const struct attribute_group adt7516_attribute_group = {
        .attrs = adt7516_attributes,
 };
 
-
-/*
- * temperature bound events
- */
-
-#define IIO_EVENT_CODE_ADT7316_IN_TEMP_HIGH   IIO_BUFFER_EVENT_CODE(0)
-#define IIO_EVENT_CODE_ADT7316_IN_TEMP_LOW    IIO_BUFFER_EVENT_CODE(1)
-#define IIO_EVENT_CODE_ADT7316_EX_TEMP_HIGH   IIO_BUFFER_EVENT_CODE(2)
-#define IIO_EVENT_CODE_ADT7316_EX_TEMP_LOW    IIO_BUFFER_EVENT_CODE(3)
-#define IIO_EVENT_CODE_ADT7316_EX_TEMP_FAULT  IIO_BUFFER_EVENT_CODE(4)
-#define IIO_EVENT_CODE_ADT7516_AIN1           IIO_BUFFER_EVENT_CODE(5)
-#define IIO_EVENT_CODE_ADT7516_AIN2           IIO_BUFFER_EVENT_CODE(6)
-#define IIO_EVENT_CODE_ADT7516_AIN3           IIO_BUFFER_EVENT_CODE(7)
-#define IIO_EVENT_CODE_ADT7516_AIN4           IIO_BUFFER_EVENT_CODE(8)
-#define IIO_EVENT_CODE_ADT7316_VDD            IIO_BUFFER_EVENT_CODE(9)
-
-static void adt7316_interrupt_bh(struct work_struct *work_s)
-{
-       struct adt7316_chip_info *chip =
-               container_of(work_s, struct adt7316_chip_info, thresh_work);
+static irqreturn_t adt7316_event_handler(int irq, void *private)
+{
+       struct iio_dev *indio_dev = private;
+       struct adt7316_chip_info *chip = iio_dev_get_devdata(indio_dev);
        u8 stat1, stat2;
-       int i, ret, count;
+       int ret;
+       s64 time;
 
        ret = chip->bus.read(chip->bus.client, ADT7316_INT_STAT1, &stat1);
        if (!ret) {
-               if ((chip->id & ID_FAMILY_MASK) == ID_ADT75XX)
-                       count = 8;
-               else
-                       count = 5;
+               if ((chip->id & ID_FAMILY_MASK) != ID_ADT75XX)
+                       stat1 &= 0x1F;
 
-               for (i = 0; i < count; i++) {
-                       if (stat1 & (1 << i))
-                               iio_push_event(chip->indio_dev, 0,
-                                       IIO_EVENT_CODE_ADT7316_IN_TEMP_HIGH + i,
-                                       chip->last_timestamp);
+               time = iio_get_time_ns();
+               if (stat1 & (1 << 0))
+                       iio_push_event(chip->indio_dev, 0,
+                                      IIO_UNMOD_EVENT_CODE(IIO_TEMP, 0,
+                                                           IIO_EV_TYPE_THRESH,
+                                                           IIO_EV_DIR_RISING),
+                                      time);
+               if (stat1 & (1 << 1))
+                       iio_push_event(chip->indio_dev, 0,
+                                      IIO_UNMOD_EVENT_CODE(IIO_TEMP, 0,
+                                                           IIO_EV_TYPE_THRESH,
+                                                           IIO_EV_DIR_FALLING),
+                                      time);
+               if (stat1 & (1 << 2))
+                       iio_push_event(chip->indio_dev, 0,
+                                      IIO_UNMOD_EVENT_CODE(IIO_TEMP, 1,
+                                                           IIO_EV_TYPE_THRESH,
+                                                           IIO_EV_DIR_RISING),
+                                      time);
+               if (stat1 & (1 << 3))
+                       iio_push_event(chip->indio_dev, 0,
+                                      IIO_UNMOD_EVENT_CODE(IIO_TEMP, 1,
+                                                           IIO_EV_TYPE_THRESH,
+                                                           IIO_EV_DIR_FALLING),
+                                      time);
+               if (stat1 & (1 << 5))
+                       iio_push_event(chip->indio_dev, 0,
+                                      IIO_UNMOD_EVENT_CODE(IIO_IN, 1,
+                                                           IIO_EV_TYPE_THRESH,
+                                                           IIO_EV_DIR_EITHER),
+                                      time);
+               if (stat1 & (1 << 6))
+                       iio_push_event(chip->indio_dev, 0,
+                                      IIO_UNMOD_EVENT_CODE(IIO_IN, 2,
+                                                           IIO_EV_TYPE_THRESH,
+                                                           IIO_EV_DIR_EITHER),
+                                      time);
+               if (stat1 & (1 << 7))
+                       iio_push_event(chip->indio_dev, 0,
+                                      IIO_UNMOD_EVENT_CODE(IIO_IN, 3,
+                                                           IIO_EV_TYPE_THRESH,
+                                                           IIO_EV_DIR_EITHER),
+                                      time);
                }
-       }
-
        ret = chip->bus.read(chip->bus.client, ADT7316_INT_STAT2, &stat2);
        if (!ret) {
                if (stat2 & ADT7316_INT_MASK2_VDD)
                        iio_push_event(chip->indio_dev, 0,
-                               IIO_EVENT_CODE_ADT7316_VDD,
-                               chip->last_timestamp);
+                                      IIO_UNMOD_EVENT_CODE(IIO_IN,
+                                                           0,
+                                                           IIO_EV_TYPE_THRESH,
+                                                           IIO_EV_DIR_RISING),
+                                      iio_get_time_ns());
        }
 
-       enable_irq(chip->bus.irq);
-}
-
-static int adt7316_interrupt(struct iio_dev *dev_info,
-               int index,
-               s64 timestamp,
-               int no_test)
-{
-       struct adt7316_chip_info *chip = dev_info->dev_data;
-
-       chip->last_timestamp = timestamp;
-       schedule_work(&chip->thresh_work);
-
-       return 0;
+       return IRQ_HANDLED;
 }
 
-IIO_EVENT_SH(adt7316, &adt7316_interrupt);
-
 /*
  * Show mask of enabled interrupts in Hex.
  */
@@ -1901,9 +1891,9 @@ static ssize_t adt7316_set_int_mask(struct device *dev,
 }
 static inline ssize_t adt7316_show_ad_bound(struct device *dev,
                struct device_attribute *attr,
-               u8 bound_reg,
                char *buf)
 {
+       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
        struct iio_dev *dev_info = dev_get_drvdata(dev);
        struct adt7316_chip_info *chip = dev_info->dev_data;
        u8 val;
@@ -1911,10 +1901,10 @@ static inline ssize_t adt7316_show_ad_bound(struct device *dev,
        int ret;
 
        if ((chip->id & ID_FAMILY_MASK) == ID_ADT73XX &&
-               bound_reg > ADT7316_EX_TEMP_LOW)
+               this_attr->address > ADT7316_EX_TEMP_LOW)
                return -EPERM;
 
-       ret = chip->bus.read(chip->bus.client, bound_reg, &val);
+       ret = chip->bus.read(chip->bus.client, this_attr->address, &val);
        if (ret)
                return -EIO;
 
@@ -1931,10 +1921,10 @@ static inline ssize_t adt7316_show_ad_bound(struct device *dev,
 
 static inline ssize_t adt7316_set_ad_bound(struct device *dev,
                struct device_attribute *attr,
-               u8 bound_reg,
                const char *buf,
                size_t len)
 {
+       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
        struct iio_dev *dev_info = dev_get_drvdata(dev);
        struct adt7316_chip_info *chip = dev_info->dev_data;
        long data;
@@ -1942,7 +1932,7 @@ static inline ssize_t adt7316_set_ad_bound(struct device *dev,
        int ret;
 
        if ((chip->id & ID_FAMILY_MASK) == ID_ADT73XX &&
-               bound_reg > ADT7316_EX_TEMP_LOW)
+               this_attr->address > ADT7316_EX_TEMP_LOW)
                return -EPERM;
 
        ret = strict_strtol(buf, 10, &data);
@@ -1963,183 +1953,13 @@ static inline ssize_t adt7316_set_ad_bound(struct device *dev,
 
        val = (u8)data;
 
-       ret = chip->bus.write(chip->bus.client, bound_reg, val);
+       ret = chip->bus.write(chip->bus.client, this_attr->address, val);
        if (ret)
                return -EIO;
 
        return len;
 }
 
-static ssize_t adt7316_show_in_temp_high(struct device *dev,
-               struct device_attribute *attr,
-               char *buf)
-{
-       return adt7316_show_ad_bound(dev, attr,
-                       ADT7316_IN_TEMP_HIGH, buf);
-}
-
-static inline ssize_t adt7316_set_in_temp_high(struct device *dev,
-               struct device_attribute *attr,
-               const char *buf,
-               size_t len)
-{
-       return adt7316_set_ad_bound(dev, attr,
-                       ADT7316_IN_TEMP_HIGH, buf, len);
-}
-
-static ssize_t adt7316_show_in_temp_low(struct device *dev,
-               struct device_attribute *attr,
-               char *buf)
-{
-       return adt7316_show_ad_bound(dev, attr,
-                       ADT7316_IN_TEMP_LOW, buf);
-}
-
-static inline ssize_t adt7316_set_in_temp_low(struct device *dev,
-               struct device_attribute *attr,
-               const char *buf,
-               size_t len)
-{
-       return adt7316_set_ad_bound(dev, attr,
-                       ADT7316_IN_TEMP_LOW, buf, len);
-}
-
-static ssize_t adt7316_show_ex_temp_ain1_high(struct device *dev,
-               struct device_attribute *attr,
-               char *buf)
-{
-       return adt7316_show_ad_bound(dev, attr,
-                       ADT7316_EX_TEMP_HIGH, buf);
-}
-
-static inline ssize_t adt7316_set_ex_temp_ain1_high(struct device *dev,
-               struct device_attribute *attr,
-               const char *buf,
-               size_t len)
-{
-       return adt7316_set_ad_bound(dev, attr,
-                       ADT7316_EX_TEMP_HIGH, buf, len);
-}
-
-static ssize_t adt7316_show_ex_temp_ain1_low(struct device *dev,
-               struct device_attribute *attr,
-               char *buf)
-{
-       return adt7316_show_ad_bound(dev, attr,
-                       ADT7316_EX_TEMP_LOW, buf);
-}
-
-static inline ssize_t adt7316_set_ex_temp_ain1_low(struct device *dev,
-               struct device_attribute *attr,
-               const char *buf,
-               size_t len)
-{
-       return adt7316_set_ad_bound(dev, attr,
-                       ADT7316_EX_TEMP_LOW, buf, len);
-}
-
-static ssize_t adt7316_show_ain2_high(struct device *dev,
-               struct device_attribute *attr,
-               char *buf)
-{
-       return adt7316_show_ad_bound(dev, attr,
-                       ADT7516_AIN2_HIGH, buf);
-}
-
-static inline ssize_t adt7316_set_ain2_high(struct device *dev,
-               struct device_attribute *attr,
-               const char *buf,
-               size_t len)
-{
-       return adt7316_set_ad_bound(dev, attr,
-                       ADT7516_AIN2_HIGH, buf, len);
-}
-
-static ssize_t adt7316_show_ain2_low(struct device *dev,
-               struct device_attribute *attr,
-               char *buf)
-{
-       return adt7316_show_ad_bound(dev, attr,
-                       ADT7516_AIN2_LOW, buf);
-}
-
-static inline ssize_t adt7316_set_ain2_low(struct device *dev,
-               struct device_attribute *attr,
-               const char *buf,
-               size_t len)
-{
-       return adt7316_set_ad_bound(dev, attr,
-                       ADT7516_AIN2_LOW, buf, len);
-}
-
-static ssize_t adt7316_show_ain3_high(struct device *dev,
-               struct device_attribute *attr,
-               char *buf)
-{
-       return adt7316_show_ad_bound(dev, attr,
-                       ADT7516_AIN3_HIGH, buf);
-}
-
-static inline ssize_t adt7316_set_ain3_high(struct device *dev,
-               struct device_attribute *attr,
-               const char *buf,
-               size_t len)
-{
-       return adt7316_set_ad_bound(dev, attr,
-                       ADT7516_AIN3_HIGH, buf, len);
-}
-
-static ssize_t adt7316_show_ain3_low(struct device *dev,
-               struct device_attribute *attr,
-               char *buf)
-{
-       return adt7316_show_ad_bound(dev, attr,
-                       ADT7516_AIN3_LOW, buf);
-}
-
-static inline ssize_t adt7316_set_ain3_low(struct device *dev,
-               struct device_attribute *attr,
-               const char *buf,
-               size_t len)
-{
-       return adt7316_set_ad_bound(dev, attr,
-                       ADT7516_AIN3_LOW, buf, len);
-}
-
-static ssize_t adt7316_show_ain4_high(struct device *dev,
-               struct device_attribute *attr,
-               char *buf)
-{
-       return adt7316_show_ad_bound(dev, attr,
-                       ADT7516_AIN4_HIGH, buf);
-}
-
-static inline ssize_t adt7316_set_ain4_high(struct device *dev,
-               struct device_attribute *attr,
-               const char *buf,
-               size_t len)
-{
-       return adt7316_set_ad_bound(dev, attr,
-                       ADT7516_AIN4_HIGH, buf, len);
-}
-
-static ssize_t adt7316_show_ain4_low(struct device *dev,
-               struct device_attribute *attr,
-               char *buf)
-{
-       return adt7316_show_ad_bound(dev, attr,
-                       ADT7516_AIN4_LOW, buf);
-}
-
-static inline ssize_t adt7316_set_ain4_low(struct device *dev,
-               struct device_attribute *attr,
-               const char *buf,
-               size_t len)
-{
-       return adt7316_set_ad_bound(dev, attr,
-                       ADT7516_AIN4_LOW, buf, len);
-}
-
 static ssize_t adt7316_show_int_enabled(struct device *dev,
                struct device_attribute *attr,
                char *buf)
@@ -2173,47 +1993,72 @@ static ssize_t adt7316_set_int_enabled(struct device *dev,
        return len;
 }
 
-
-IIO_EVENT_ATTR_SH(int_mask, iio_event_adt7316,
-               adt7316_show_int_mask, adt7316_set_int_mask, 0);
-IIO_EVENT_ATTR_SH(in_temp_high, iio_event_adt7316,
-               adt7316_show_in_temp_high, adt7316_set_in_temp_high, 0);
-IIO_EVENT_ATTR_SH(in_temp_low, iio_event_adt7316,
-               adt7316_show_in_temp_low, adt7316_set_in_temp_low, 0);
-IIO_EVENT_ATTR_SH(ex_temp_high, iio_event_adt7316,
-               adt7316_show_ex_temp_ain1_high,
-               adt7316_set_ex_temp_ain1_high, 0);
-IIO_EVENT_ATTR_SH(ex_temp_low, iio_event_adt7316,
-               adt7316_show_ex_temp_ain1_low,
-               adt7316_set_ex_temp_ain1_low, 0);
-IIO_EVENT_ATTR_SH(ex_temp_ain1_high, iio_event_adt7316,
-               adt7316_show_ex_temp_ain1_high,
-               adt7316_set_ex_temp_ain1_high, 0);
-IIO_EVENT_ATTR_SH(ex_temp_ain1_low, iio_event_adt7316,
-               adt7316_show_ex_temp_ain1_low,
-               adt7316_set_ex_temp_ain1_low, 0);
-IIO_EVENT_ATTR_SH(ain2_high, iio_event_adt7316,
-               adt7316_show_ain2_high, adt7316_set_ain2_high, 0);
-IIO_EVENT_ATTR_SH(ain2_low, iio_event_adt7316,
-               adt7316_show_ain2_low, adt7316_set_ain2_low, 0);
-IIO_EVENT_ATTR_SH(ain3_high, iio_event_adt7316,
-               adt7316_show_ain3_high, adt7316_set_ain3_high, 0);
-IIO_EVENT_ATTR_SH(ain3_low, iio_event_adt7316,
-               adt7316_show_ain3_low, adt7316_set_ain3_low, 0);
-IIO_EVENT_ATTR_SH(ain4_high, iio_event_adt7316,
-               adt7316_show_ain4_high, adt7316_set_ain4_high, 0);
-IIO_EVENT_ATTR_SH(ain4_low, iio_event_adt7316,
-               adt7316_show_ain4_low, adt7316_set_ain4_low, 0);
-IIO_EVENT_ATTR_SH(int_enabled, iio_event_adt7316,
-               adt7316_show_int_enabled, adt7316_set_int_enabled, 0);
+static IIO_DEVICE_ATTR(int_mask,
+                      S_IRUGO | S_IWUSR,
+                      adt7316_show_int_mask, adt7316_set_int_mask,
+                      0);
+static IIO_DEVICE_ATTR(in_temp_high_value,
+                      S_IRUGO | S_IWUSR,
+                      adt7316_show_ad_bound, adt7316_set_ad_bound,
+                      ADT7316_IN_TEMP_HIGH);
+static IIO_DEVICE_ATTR(in_temp_low_value,
+                      S_IRUGO | S_IWUSR,
+                      adt7316_show_ad_bound, adt7316_set_ad_bound,
+                      ADT7316_IN_TEMP_LOW);
+static IIO_DEVICE_ATTR(ex_temp_high_value,
+                      S_IRUGO | S_IWUSR,
+                      adt7316_show_ad_bound, adt7316_set_ad_bound,
+                      ADT7316_EX_TEMP_HIGH);
+static IIO_DEVICE_ATTR(ex_temp_low_value,
+                      S_IRUGO | S_IWUSR,
+                      adt7316_show_ad_bound, adt7316_set_ad_bound,
+                      ADT7316_EX_TEMP_LOW);
+
+/* NASTY duplication to be fixed */
+static IIO_DEVICE_ATTR(ex_temp_ain1_high_value,
+                      S_IRUGO | S_IWUSR,
+                      adt7316_show_ad_bound, adt7316_set_ad_bound,
+                      ADT7316_EX_TEMP_HIGH);
+static IIO_DEVICE_ATTR(ex_temp_ain1_low_value,
+                      S_IRUGO | S_IWUSR,
+                      adt7316_show_ad_bound, adt7316_set_ad_bound,
+                      ADT7316_EX_TEMP_LOW);
+static IIO_DEVICE_ATTR(ain2_high_value,
+                      S_IRUGO | S_IWUSR,
+                      adt7316_show_ad_bound, adt7316_set_ad_bound,
+                      ADT7516_AIN2_HIGH);
+static IIO_DEVICE_ATTR(ain2_low_value,
+                      S_IRUGO | S_IWUSR,
+                      adt7316_show_ad_bound, adt7316_set_ad_bound,
+                      ADT7516_AIN2_LOW);
+static IIO_DEVICE_ATTR(ain3_high_value,
+                      S_IRUGO | S_IWUSR,
+                      adt7316_show_ad_bound, adt7316_set_ad_bound,
+                      ADT7516_AIN3_HIGH);
+static IIO_DEVICE_ATTR(ain3_low_value,
+                      S_IRUGO | S_IWUSR,
+                      adt7316_show_ad_bound, adt7316_set_ad_bound,
+                      ADT7516_AIN3_LOW);
+static IIO_DEVICE_ATTR(ain4_high_value,
+                      S_IRUGO | S_IWUSR,
+                      adt7316_show_ad_bound, adt7316_set_ad_bound,
+                      ADT7516_AIN4_HIGH);
+static IIO_DEVICE_ATTR(ain4_low_value,
+                      S_IRUGO | S_IWUSR,
+                      adt7316_show_ad_bound, adt7316_set_ad_bound,
+                      ADT7516_AIN4_LOW);
+static IIO_DEVICE_ATTR(int_enabled,
+                      S_IRUGO | S_IWUSR,
+                      adt7316_show_int_enabled,
+                      adt7316_set_int_enabled, 0);
 
 static struct attribute *adt7316_event_attributes[] = {
-       &iio_event_attr_int_mask.dev_attr.attr,
-       &iio_event_attr_in_temp_high.dev_attr.attr,
-       &iio_event_attr_in_temp_low.dev_attr.attr,
-       &iio_event_attr_ex_temp_high.dev_attr.attr,
-       &iio_event_attr_ex_temp_low.dev_attr.attr,
-       &iio_event_attr_int_enabled.dev_attr.attr,
+       &iio_dev_attr_int_mask.dev_attr.attr,
+       &iio_dev_attr_in_temp_high_value.dev_attr.attr,
+       &iio_dev_attr_in_temp_low_value.dev_attr.attr,
+       &iio_dev_attr_ex_temp_high_value.dev_attr.attr,
+       &iio_dev_attr_ex_temp_low_value.dev_attr.attr,
+       &iio_dev_attr_int_enabled.dev_attr.attr,
        NULL,
 };
 
@@ -2222,18 +2067,18 @@ static struct attribute_group adt7316_event_attribute_group = {
 };
 
 static struct attribute *adt7516_event_attributes[] = {
-       &iio_event_attr_int_mask.dev_attr.attr,
-       &iio_event_attr_in_temp_high.dev_attr.attr,
-       &iio_event_attr_in_temp_low.dev_attr.attr,
-       &iio_event_attr_ex_temp_ain1_high.dev_attr.attr,
-       &iio_event_attr_ex_temp_ain1_low.dev_attr.attr,
-       &iio_event_attr_ain2_high.dev_attr.attr,
-       &iio_event_attr_ain2_low.dev_attr.attr,
-       &iio_event_attr_ain3_high.dev_attr.attr,
-       &iio_event_attr_ain3_low.dev_attr.attr,
-       &iio_event_attr_ain4_high.dev_attr.attr,
-       &iio_event_attr_ain4_low.dev_attr.attr,
-       &iio_event_attr_int_enabled.dev_attr.attr,
+       &iio_dev_attr_int_mask.dev_attr.attr,
+       &iio_dev_attr_in_temp_high_value.dev_attr.attr,
+       &iio_dev_attr_in_temp_low_value.dev_attr.attr,
+       &iio_dev_attr_ex_temp_ain1_high_value.dev_attr.attr,
+       &iio_dev_attr_ex_temp_ain1_low_value.dev_attr.attr,
+       &iio_dev_attr_ain2_high_value.dev_attr.attr,
+       &iio_dev_attr_ain2_low_value.dev_attr.attr,
+       &iio_dev_attr_ain3_high_value.dev_attr.attr,
+       &iio_dev_attr_ain3_low_value.dev_attr.attr,
+       &iio_dev_attr_ain4_high_value.dev_attr.attr,
+       &iio_dev_attr_ain4_low_value.dev_attr.attr,
+       &iio_dev_attr_int_enabled.dev_attr.attr,
        NULL,
 };
 
@@ -2261,6 +2106,20 @@ int adt7316_enable(struct device *dev)
 EXPORT_SYMBOL(adt7316_enable);
 #endif
 
+static const struct iio_info adt7316_info = {
+       .attrs = &adt7316_attribute_group,
+       .num_interrupt_lines = 1,
+       .event_attrs = &adt7316_event_attribute_group,
+       .driver_module = THIS_MODULE,
+};
+
+static const struct iio_info adt7516_info = {
+       .attrs = &adt7516_attribute_group,
+       .num_interrupt_lines = 1,
+       .event_attrs = &adt7516_event_attribute_group,
+       .driver_module = THIS_MODULE,
+};
+
 /*
  * device probe and remove
  */
@@ -2280,7 +2139,6 @@ int __devinit adt7316_probe(struct device *dev, struct adt7316_bus *bus,
        dev_set_drvdata(dev, chip);
 
        chip->bus = *bus;
-       chip->name = name;
 
        if (name[4] == '3')
                chip->id = ID_ADT7316 + (name[6] - '6');
@@ -2299,23 +2157,19 @@ int __devinit adt7316_probe(struct device *dev, struct adt7316_bus *bus,
        if ((chip->id & ID_FAMILY_MASK) == ID_ADT75XX)
                chip->int_mask |= ADT7516_AIN_INT_MASK;
 
-       chip->indio_dev = iio_allocate_device();
+       chip->indio_dev = iio_allocate_device(0);
        if (chip->indio_dev == NULL) {
                ret = -ENOMEM;
                goto error_free_chip;
        }
 
        chip->indio_dev->dev.parent = dev;
-       if ((chip->id & ID_FAMILY_MASK) == ID_ADT75XX) {
-               chip->indio_dev->attrs = &adt7516_attribute_group;
-               chip->indio_dev->event_attrs = &adt7516_event_attribute_group;
-       } else {
-               chip->indio_dev->attrs = &adt7316_attribute_group;
-               chip->indio_dev->event_attrs = &adt7316_event_attribute_group;
-       }
+       if ((chip->id & ID_FAMILY_MASK) == ID_ADT75XX)
+               chip->indio_dev->info = &adt7516_info;
+       else
+               chip->indio_dev->info = &adt7316_info;
+       chip->indio_dev->name = name;
        chip->indio_dev->dev_data = (void *)chip;
-       chip->indio_dev->driver_module = THIS_MODULE;
-       chip->indio_dev->num_interrupt_lines = 1;
        chip->indio_dev->modes = INDIO_DIRECT_MODE;
 
        ret = iio_device_register(chip->indio_dev);
@@ -2326,24 +2180,15 @@ int __devinit adt7316_probe(struct device *dev, struct adt7316_bus *bus,
                if (adt7316_platform_data[0])
                        chip->bus.irq_flags = adt7316_platform_data[0];
 
-               ret = iio_register_interrupt_line(chip->bus.irq,
-                               chip->indio_dev,
-                               0,
-                               chip->bus.irq_flags,
-                               chip->name);
+               ret = request_threaded_irq(chip->bus.irq,
+                                          NULL,
+                                          &adt7316_event_handler,
+                                          chip->bus.irq_flags | IRQF_ONESHOT,
+                                          chip->indio_dev->name,
+                                          chip->indio_dev);
                if (ret)
                        goto error_unreg_dev;
 
-               /*
-                * The event handler list element refer to iio_event_adt7316.
-                * All event attributes bind to the same event handler.
-                * So, only register event handler once.
-                */
-               iio_add_event_to_list(&iio_event_adt7316,
-                               &chip->indio_dev->interrupts[0]->ev_list);
-
-               INIT_WORK(&chip->thresh_work, adt7316_interrupt_bh);
-
                if (chip->bus.irq_flags & IRQF_TRIGGER_HIGH)
                        chip->config1 |= ADT7316_INT_POLARITY;
        }
@@ -2361,12 +2206,12 @@ int __devinit adt7316_probe(struct device *dev, struct adt7316_bus *bus,
        }
 
        dev_info(dev, "%s temperature sensor, ADC and DAC registered.\n",
-                       chip->name);
+                       chip->indio_dev->name);
 
        return 0;
 
 error_unreg_irq:
-       iio_unregister_interrupt_line(chip->indio_dev, 0);
+       free_irq(chip->bus.irq, chip->indio_dev);
 error_unreg_dev:
        iio_device_unregister(chip->indio_dev);
 error_free_dev:
@@ -2383,12 +2228,11 @@ int __devexit adt7316_remove(struct device *dev)
 
        struct iio_dev *dev_info = dev_get_drvdata(dev);
        struct adt7316_chip_info *chip = dev_info->dev_data;
-       struct iio_dev *indio_dev = chip->indio_dev;
 
        dev_set_drvdata(dev, NULL);
        if (chip->bus.irq)
-               iio_unregister_interrupt_line(indio_dev, 0);
-       iio_device_unregister(indio_dev);
+               free_irq(chip->bus.irq, chip->indio_dev);
+       iio_device_unregister(chip->indio_dev);
        iio_free_device(chip->indio_dev);
        kfree(chip);
 
index 4fcb99c816f91d618f18a6b331c7b2d6a91757b6..3e31ee6220edab7659371a6cd84473362c217edb 100644 (file)
@@ -45,23 +45,10 @@ struct iio_event_data {
  * struct iio_detected_event_list - list element for events that have occurred
  * @list:              linked list header
  * @ev:                        the event itself
- * @shared_pointer:    used when the event is shared - i.e. can be escallated
- *                     on demand (eg ring buffer 50%->100% full)
  */
 struct iio_detected_event_list {
        struct list_head                list;
        struct iio_event_data           ev;
-       struct iio_shared_ev_pointer    *shared_pointer;
-};
-/**
- * struct iio_shared_ev_pointer - allows shared events to identify if currently
- *                             in the detected event list
- * @ev_p:      pointer to detected event list element (null if not in list)
- * @lock:      protect this element to prevent simultaneous edit and remove
- */
-struct iio_shared_ev_pointer {
-       struct iio_detected_event_list  *ev_p;
-       spinlock_t                      lock;
 };
 
 /**
@@ -73,43 +60,16 @@ struct iio_shared_ev_pointer {
  * @det_events:                list of detected events
  * @max_events:                maximum number of events before new ones are dropped
  * @current_events:    number of events in detected list
- * @owner:             ensure the driver module owns the file, not iio
- * @private:           driver specific data
- * @_name:             used internally to store the sysfs name for minor id
- *                     attribute
- * @_attrname:         the event interface's attribute name
  */
 struct iio_event_interface {
        struct device                           dev;
        struct iio_handler                      handler;
        wait_queue_head_t                       wait;
        struct mutex                            event_list_lock;
-       struct iio_detected_event_list          det_events;
+       struct list_head                        det_events;
        int                                     max_events;
        int                                     current_events;
-       struct module                           *owner;
-       void                                    *private;
-       char                                    _name[35];
-       char                                    _attrname[20];
-};
-
-/**
- * struct iio_event_handler_list - element in list of handlers for events
- * @list:              list header
- * @refcount:          as the handler may be shared between multiple device
- *                     side events, reference counting ensures clean removal
- * @exist_lock:                prevents race conditions related to refcount usage.
- * @handler:           event handler function - called on event if this
- *                     event_handler is enabled.
- *
- * Each device has one list of these per interrupt line.
- **/
-struct iio_event_handler_list {
-       struct list_head        list;
-       int                     refcount;
-       struct mutex            exist_lock;
-       int (*handler)(struct iio_dev *dev_info, int index, s64 timestamp,
-                      int no_test);
+       struct list_head dev_attr_list;
 };
 
 #endif
index 67defcb359b126e34ac7d8613ee079f767fa0bb2..d5a5556cf985bfc1c88f5560a535ee7903afc5ba 100644 (file)
@@ -21,6 +21,27 @@ config AD5446
          To compile this driver as a module, choose M here: the
          module will be called ad5446.
 
+config AD5504
+       tristate "Analog Devices AD5504/AD5501 DAC SPI driver"
+       depends on SPI
+       help
+         Say yes here to build support for Analog Devices AD5504, AD5501,
+         High Voltage Digital to Analog Converter.
+
+         To compile this driver as a module, choose M here: the
+         module will be called ad5504.
+
+config AD5791
+       tristate "Analog Devices AD5760/AD5780/AD5781/AD5791 DAC SPI driver"
+       depends on SPI
+       help
+         Say yes here to build support for Analog Devices AD5760, AD5780,
+         AD5781, AD5791 High Resolution Voltage Output Digital to
+         Analog Converter.
+
+         To compile this driver as a module, choose M here: the
+         module will be called ad5791.
+
 config MAX517
        tristate "Maxim MAX517/518/519 DAC driver"
        depends on I2C && EXPERIMENTAL
index 1197aef54abbf2234b2c065df6437617f8bdf13e..83196de7a54c6983e723740d86af4abd60db379e 100644 (file)
@@ -3,5 +3,7 @@
 #
 
 obj-$(CONFIG_AD5624R_SPI) += ad5624r_spi.o
+obj-$(CONFIG_AD5504) += ad5504.o
 obj-$(CONFIG_AD5446) += ad5446.o
+obj-$(CONFIG_AD5791) += ad5791.o
 obj-$(CONFIG_MAX517) += max517.o
index 8623a72e046c800da70d2caaac13dd033bce87ab..86cb08ce199beb14d007c83dceddd3d4a545ce75 100644 (file)
@@ -106,17 +106,6 @@ static ssize_t ad5446_show_scale(struct device *dev,
 }
 static IIO_DEVICE_ATTR(out_scale, S_IRUGO, ad5446_show_scale, NULL, 0);
 
-static ssize_t ad5446_show_name(struct device *dev,
-                                struct device_attribute *attr,
-                                char *buf)
-{
-       struct iio_dev *dev_info = dev_get_drvdata(dev);
-       struct ad5446_state *st = iio_dev_get_devdata(dev_info);
-
-       return sprintf(buf, "%s\n", spi_get_device_id(st->spi)->name);
-}
-static IIO_DEVICE_ATTR(name, S_IRUGO, ad5446_show_name, NULL, 0);
-
 static ssize_t ad5446_write_powerdown_mode(struct device *dev,
                                       struct device_attribute *attr,
                                       const char *buf, size_t len)
@@ -204,7 +193,6 @@ static struct attribute *ad5446_attributes[] = {
        &iio_dev_attr_out0_powerdown.dev_attr.attr,
        &iio_dev_attr_out_powerdown_mode.dev_attr.attr,
        &iio_const_attr_out_powerdown_mode_available.dev_attr.attr,
-       &iio_dev_attr_name.dev_attr.attr,
        NULL,
 };
 
@@ -245,6 +233,12 @@ static const struct ad5446_chip_info ad5446_chip_info_tbl[] = {
                .left_shift = 0,
                .store_sample = ad5446_store_sample,
        },
+       [ID_AD5541A] = {
+               .bits = 16,
+               .storagebits = 16,
+               .left_shift = 0,
+               .store_sample = ad5542_store_sample,
+       },
        [ID_AD5542A] = {
                .bits = 16,
                .storagebits = 16,
@@ -340,6 +334,11 @@ static const struct ad5446_chip_info ad5446_chip_info_tbl[] = {
        },
 };
 
+static const struct iio_info ad5446_info = {
+       .attrs = &ad5446_attribute_group,
+       .driver_module = THIS_MODULE,
+};
+
 static int __devinit ad5446_probe(struct spi_device *spi)
 {
        struct ad5446_state *st;
@@ -367,7 +366,7 @@ static int __devinit ad5446_probe(struct spi_device *spi)
 
        st->spi = spi;
 
-       st->indio_dev = iio_allocate_device();
+       st->indio_dev = iio_allocate_device(0);
        if (st->indio_dev == NULL) {
                ret = -ENOMEM;
                goto error_disable_reg;
@@ -375,9 +374,9 @@ static int __devinit ad5446_probe(struct spi_device *spi)
 
        /* Estabilish that the iio_dev is a child of the spi device */
        st->indio_dev->dev.parent = &spi->dev;
-       st->indio_dev->attrs = &ad5446_attribute_group;
+       st->indio_dev->name = spi_get_device_id(spi)->name;
+       st->indio_dev->info = &ad5446_info;
        st->indio_dev->dev_data = (void *)(st);
-       st->indio_dev->driver_module = THIS_MODULE;
        st->indio_dev->modes = INDIO_DIRECT_MODE;
 
        /* Setup default message */
@@ -442,6 +441,7 @@ static const struct spi_device_id ad5446_id[] = {
        {"ad5444", ID_AD5444},
        {"ad5446", ID_AD5446},
        {"ad5512a", ID_AD5512A},
+       {"ad5541a", ID_AD5541A},
        {"ad5542a", ID_AD5542A},
        {"ad5543", ID_AD5543},
        {"ad5553", ID_AD5553},
index 7ac63ab8a11d56244cf17d9e25a2e765880f31b4..e6ffd2bb7c7d13d6149700525ee1ce4a9593d926 100644 (file)
@@ -92,6 +92,7 @@ struct ad5446_chip_info {
 enum ad5446_supported_device_ids {
        ID_AD5444,
        ID_AD5446,
+       ID_AD5541A,
        ID_AD5542A,
        ID_AD5543,
        ID_AD5512A,
diff --git a/drivers/staging/iio/dac/ad5504.c b/drivers/staging/iio/dac/ad5504.c
new file mode 100644 (file)
index 0000000..ed029cd
--- /dev/null
@@ -0,0 +1,404 @@
+/*
+ * AD5504, AD5501 High Voltage Digital to Analog Converter
+ *
+ * Copyright 2011 Analog Devices Inc.
+ *
+ * Licensed under the GPL-2.
+ */
+
+#include <linux/interrupt.h>
+#include <linux/gpio.h>
+#include <linux/fs.h>
+#include <linux/device.h>
+#include <linux/kernel.h>
+#include <linux/spi/spi.h>
+#include <linux/slab.h>
+#include <linux/sysfs.h>
+#include <linux/regulator/consumer.h>
+
+#include "../iio.h"
+#include "../sysfs.h"
+#include "dac.h"
+#include "ad5504.h"
+
+static int ad5504_spi_write(struct spi_device *spi, u8 addr, u16 val)
+{
+       u16 tmp = cpu_to_be16(AD5504_CMD_WRITE |
+                             AD5504_ADDR(addr) |
+                             (val & AD5504_RES_MASK));
+
+       return spi_write(spi, (u8 *)&tmp, 2);
+}
+
+static int ad5504_spi_read(struct spi_device *spi, u8 addr, u16 *val)
+{
+       u16 tmp = cpu_to_be16(AD5504_CMD_READ | AD5504_ADDR(addr));
+       int ret;
+       struct spi_transfer     t = {
+                       .tx_buf         = &tmp,
+                       .rx_buf         = val,
+                       .len            = 2,
+               };
+       struct spi_message      m;
+
+       spi_message_init(&m);
+       spi_message_add_tail(&t, &m);
+       ret = spi_sync(spi, &m);
+
+       *val = be16_to_cpu(*val) & AD5504_RES_MASK;
+
+       return ret;
+}
+
+static ssize_t ad5504_write_dac(struct device *dev,
+                                struct device_attribute *attr,
+                                const char *buf, size_t len)
+{
+       struct iio_dev *indio_dev = dev_get_drvdata(dev);
+       struct ad5504_state *st = iio_dev_get_devdata(indio_dev);
+       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
+       long readin;
+       int ret;
+
+       ret = strict_strtol(buf, 10, &readin);
+       if (ret)
+               return ret;
+
+       ret = ad5504_spi_write(st->spi, this_attr->address, readin);
+       return ret ? ret : len;
+}
+
+static ssize_t ad5504_read_dac(struct device *dev,
+                                          struct device_attribute *attr,
+                                          char *buf)
+{
+       struct iio_dev *indio_dev = dev_get_drvdata(dev);
+       struct ad5504_state *st = iio_dev_get_devdata(indio_dev);
+       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
+       int ret;
+       u16 val;
+
+       ret = ad5504_spi_read(st->spi, this_attr->address, &val);
+       if (ret)
+               return ret;
+
+       return sprintf(buf, "%d\n", val);
+}
+
+static ssize_t ad5504_read_powerdown_mode(struct device *dev,
+                                     struct device_attribute *attr, char *buf)
+{
+       struct iio_dev *indio_dev = dev_get_drvdata(dev);
+       struct ad5504_state *st = iio_dev_get_devdata(indio_dev);
+
+       const char mode[][14] = {"20kohm_to_gnd", "three_state"};
+
+       return sprintf(buf, "%s\n", mode[st->pwr_down_mode]);
+}
+
+static ssize_t ad5504_write_powerdown_mode(struct device *dev,
+                                      struct device_attribute *attr,
+                                      const char *buf, size_t len)
+{
+       struct iio_dev *indio_dev = dev_get_drvdata(dev);
+       struct ad5504_state *st = iio_dev_get_devdata(indio_dev);
+       int ret;
+
+       if (sysfs_streq(buf, "20kohm_to_gnd"))
+               st->pwr_down_mode = AD5504_DAC_PWRDN_20K;
+       else if (sysfs_streq(buf, "three_state"))
+               st->pwr_down_mode = AD5504_DAC_PWRDN_3STATE;
+       else
+               ret = -EINVAL;
+
+       return ret ? ret : len;
+}
+
+static ssize_t ad5504_read_dac_powerdown(struct device *dev,
+                                          struct device_attribute *attr,
+                                          char *buf)
+{
+       struct iio_dev *indio_dev = dev_get_drvdata(dev);
+       struct ad5504_state *st = iio_dev_get_devdata(indio_dev);
+       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
+
+       return sprintf(buf, "%d\n",
+                       !(st->pwr_down_mask & (1 << this_attr->address)));
+}
+
+static ssize_t ad5504_write_dac_powerdown(struct device *dev,
+                                           struct device_attribute *attr,
+                                           const char *buf, size_t len)
+{
+       long readin;
+       int ret;
+       struct iio_dev *indio_dev = dev_get_drvdata(dev);
+       struct ad5504_state *st = iio_dev_get_devdata(indio_dev);
+       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
+
+       ret = strict_strtol(buf, 10, &readin);
+       if (ret)
+               return ret;
+
+       if (readin == 0)
+               st->pwr_down_mask |= (1 << this_attr->address);
+       else if (readin == 1)
+               st->pwr_down_mask &= ~(1 << this_attr->address);
+       else
+               ret = -EINVAL;
+
+       ret = ad5504_spi_write(st->spi, AD5504_ADDR_CTRL,
+                               AD5504_DAC_PWRDWN_MODE(st->pwr_down_mode) |
+                               AD5504_DAC_PWR(st->pwr_down_mask));
+
+       /* writes to the CTRL register must be followed by a NOOP */
+       ad5504_spi_write(st->spi, AD5504_ADDR_NOOP, 0);
+
+       return ret ? ret : len;
+}
+
+static ssize_t ad5504_show_scale(struct device *dev,
+                               struct device_attribute *attr,
+                               char *buf)
+{
+       struct iio_dev *indio_dev = dev_get_drvdata(dev);
+       struct ad5504_state *st = iio_dev_get_devdata(indio_dev);
+       /* Corresponds to Vref / 2^(bits) */
+       unsigned int scale_uv = (st->vref_mv * 1000) >> AD5505_BITS;
+
+       return sprintf(buf, "%d.%03d\n", scale_uv / 1000, scale_uv % 1000);
+}
+static IIO_DEVICE_ATTR(out_scale, S_IRUGO, ad5504_show_scale, NULL, 0);
+
+#define IIO_DEV_ATTR_OUT_RW_RAW(_num, _show, _store, _addr)            \
+       IIO_DEVICE_ATTR(out##_num##_raw,                                \
+                       S_IRUGO | S_IWUSR, _show, _store, _addr)
+
+static IIO_DEV_ATTR_OUT_RW_RAW(0, ad5504_read_dac,
+       ad5504_write_dac, AD5504_ADDR_DAC0);
+static IIO_DEV_ATTR_OUT_RW_RAW(1, ad5504_read_dac,
+       ad5504_write_dac, AD5504_ADDR_DAC1);
+static IIO_DEV_ATTR_OUT_RW_RAW(2, ad5504_read_dac,
+       ad5504_write_dac, AD5504_ADDR_DAC2);
+static IIO_DEV_ATTR_OUT_RW_RAW(3, ad5504_read_dac,
+       ad5504_write_dac, AD5504_ADDR_DAC3);
+
+static IIO_DEVICE_ATTR(out_powerdown_mode, S_IRUGO |
+                       S_IWUSR, ad5504_read_powerdown_mode,
+                       ad5504_write_powerdown_mode, 0);
+
+static IIO_CONST_ATTR(out_powerdown_mode_available,
+                       "20kohm_to_gnd three_state");
+
+#define IIO_DEV_ATTR_DAC_POWERDOWN(_num, _show, _store, _addr)         \
+       IIO_DEVICE_ATTR(out##_num##_powerdown,                          \
+                       S_IRUGO | S_IWUSR, _show, _store, _addr)
+
+static IIO_DEV_ATTR_DAC_POWERDOWN(0, ad5504_read_dac_powerdown,
+                                  ad5504_write_dac_powerdown, 0);
+static IIO_DEV_ATTR_DAC_POWERDOWN(1, ad5504_read_dac_powerdown,
+                                  ad5504_write_dac_powerdown, 1);
+static IIO_DEV_ATTR_DAC_POWERDOWN(2, ad5504_read_dac_powerdown,
+                                  ad5504_write_dac_powerdown, 2);
+static IIO_DEV_ATTR_DAC_POWERDOWN(3, ad5504_read_dac_powerdown,
+                                  ad5504_write_dac_powerdown, 3);
+
+static struct attribute *ad5504_attributes[] = {
+       &iio_dev_attr_out0_raw.dev_attr.attr,
+       &iio_dev_attr_out1_raw.dev_attr.attr,
+       &iio_dev_attr_out2_raw.dev_attr.attr,
+       &iio_dev_attr_out3_raw.dev_attr.attr,
+       &iio_dev_attr_out0_powerdown.dev_attr.attr,
+       &iio_dev_attr_out1_powerdown.dev_attr.attr,
+       &iio_dev_attr_out2_powerdown.dev_attr.attr,
+       &iio_dev_attr_out3_powerdown.dev_attr.attr,
+       &iio_dev_attr_out_powerdown_mode.dev_attr.attr,
+       &iio_const_attr_out_powerdown_mode_available.dev_attr.attr,
+       &iio_dev_attr_out_scale.dev_attr.attr,
+       NULL,
+};
+
+static const struct attribute_group ad5504_attribute_group = {
+       .attrs = ad5504_attributes,
+};
+
+static struct attribute *ad5501_attributes[] = {
+       &iio_dev_attr_out0_raw.dev_attr.attr,
+       &iio_dev_attr_out0_powerdown.dev_attr.attr,
+       &iio_dev_attr_out_powerdown_mode.dev_attr.attr,
+       &iio_const_attr_out_powerdown_mode_available.dev_attr.attr,
+       &iio_dev_attr_out_scale.dev_attr.attr,
+       NULL,
+};
+
+static const struct attribute_group ad5501_attribute_group = {
+       .attrs = ad5501_attributes,
+};
+
+static IIO_CONST_ATTR(temp0_thresh_rising_value, "110000");
+static IIO_CONST_ATTR(temp0_thresh_rising_en, "1");
+
+static struct attribute *ad5504_ev_attributes[] = {
+       &iio_const_attr_temp0_thresh_rising_value.dev_attr.attr,
+       &iio_const_attr_temp0_thresh_rising_en.dev_attr.attr,
+       NULL,
+};
+
+static struct attribute_group ad5504_ev_attribute_group = {
+       .attrs = ad5504_ev_attributes,
+};
+
+static irqreturn_t ad5504_event_handler(int irq, void *private)
+{
+       iio_push_event(private, 0,
+                      IIO_UNMOD_EVENT_CODE(IIO_EV_CLASS_TEMP,
+                                           0,
+                                           IIO_EV_TYPE_THRESH,
+                                           IIO_EV_DIR_RISING),
+                      iio_get_time_ns());
+
+       return IRQ_HANDLED;
+}
+
+static const struct iio_info ad5504_info = {
+       .attrs = &ad5504_attribute_group,
+       .num_interrupt_lines = 1,
+       .event_attrs = &ad5504_ev_attribute_group,
+       .driver_module = THIS_MODULE,
+};
+
+static const struct iio_info ad5501_info = {
+       .attrs = &ad5501_attribute_group,
+       .num_interrupt_lines = 1,
+       .event_attrs = &ad5504_ev_attribute_group,
+       .driver_module = THIS_MODULE,
+};
+
+static int __devinit ad5504_probe(struct spi_device *spi)
+{
+       struct ad5504_platform_data *pdata = spi->dev.platform_data;
+       struct ad5504_state *st;
+       int ret, voltage_uv = 0;
+
+       st = kzalloc(sizeof(*st), GFP_KERNEL);
+       if (st == NULL) {
+               ret = -ENOMEM;
+               goto error_ret;
+       }
+
+       spi_set_drvdata(spi, st);
+
+       st->reg = regulator_get(&spi->dev, "vcc");
+       if (!IS_ERR(st->reg)) {
+               ret = regulator_enable(st->reg);
+               if (ret)
+                       goto error_put_reg;
+
+               voltage_uv = regulator_get_voltage(st->reg);
+       }
+
+       if (voltage_uv)
+               st->vref_mv = voltage_uv / 1000;
+       else if (pdata)
+               st->vref_mv = pdata->vref_mv;
+       else
+               dev_warn(&spi->dev, "reference voltage unspecified\n");
+
+       st->spi = spi;
+       st->indio_dev = iio_allocate_device(0);
+       if (st->indio_dev == NULL) {
+               ret = -ENOMEM;
+               goto error_disable_reg;
+       }
+       st->indio_dev->dev.parent = &spi->dev;
+       st->indio_dev->name = spi_get_device_id(st->spi)->name;
+       if (spi_get_device_id(st->spi)->driver_data == ID_AD5501)
+               st->indio_dev->info = &ad5501_info;
+       else
+               st->indio_dev->info = &ad5504_info;
+       st->indio_dev->dev_data = (void *)(st);
+       st->indio_dev->modes = INDIO_DIRECT_MODE;
+
+       ret = iio_device_register(st->indio_dev);
+       if (ret)
+               goto error_free_dev;
+
+       if (spi->irq) {
+               ret = request_threaded_irq(spi->irq,
+                                          NULL,
+                                          &ad5504_event_handler,
+                                          IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
+                                          spi_get_device_id(st->spi)->name,
+                                          st->indio_dev);
+               if (ret)
+                       goto error_unreg_iio_device;
+       }
+
+       return 0;
+
+error_unreg_iio_device:
+       iio_device_unregister(st->indio_dev);
+error_free_dev:
+       iio_free_device(st->indio_dev);
+error_disable_reg:
+       if (!IS_ERR(st->reg))
+               regulator_disable(st->reg);
+error_put_reg:
+       if (!IS_ERR(st->reg))
+               regulator_put(st->reg);
+
+       kfree(st);
+error_ret:
+       return ret;
+}
+
+static int __devexit ad5504_remove(struct spi_device *spi)
+{
+       struct ad5504_state *st = spi_get_drvdata(spi);
+
+       if (spi->irq)
+               free_irq(spi->irq, st->indio_dev);
+
+       iio_device_unregister(st->indio_dev);
+
+       if (!IS_ERR(st->reg)) {
+               regulator_disable(st->reg);
+               regulator_put(st->reg);
+       }
+
+       kfree(st);
+
+       return 0;
+}
+
+static const struct spi_device_id ad5504_id[] = {
+       {"ad5504", ID_AD5504},
+       {"ad5501", ID_AD5501},
+       {}
+};
+
+static struct spi_driver ad5504_driver = {
+       .driver = {
+                  .name = "ad5504",
+                  .owner = THIS_MODULE,
+                  },
+       .probe = ad5504_probe,
+       .remove = __devexit_p(ad5504_remove),
+       .id_table = ad5504_id,
+};
+
+static __init int ad5504_spi_init(void)
+{
+       return spi_register_driver(&ad5504_driver);
+}
+module_init(ad5504_spi_init);
+
+static __exit void ad5504_spi_exit(void)
+{
+       spi_unregister_driver(&ad5504_driver);
+}
+module_exit(ad5504_spi_exit);
+
+MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>");
+MODULE_DESCRIPTION("Analog Devices AD5501/AD5501 DAC");
+MODULE_LICENSE("GPL v2");
diff --git a/drivers/staging/iio/dac/ad5504.h b/drivers/staging/iio/dac/ad5504.h
new file mode 100644 (file)
index 0000000..13ef353
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * AD5504 SPI DAC driver
+ *
+ * Copyright 2011 Analog Devices Inc.
+ *
+ * Licensed under the GPL-2.
+ */
+
+#ifndef SPI_AD5504_H_
+#define SPI_AD5504_H_
+
+#define AD5505_BITS                    12
+#define AD5504_RES_MASK                        ((1 << (AD5505_BITS)) - 1)
+
+#define AD5504_CMD_READ                        (1 << 15)
+#define AD5504_CMD_WRITE               (0 << 15)
+#define AD5504_ADDR(addr)              ((addr) << 12)
+
+/* Registers */
+#define AD5504_ADDR_NOOP               0
+#define AD5504_ADDR_DAC0               1
+#define AD5504_ADDR_DAC1               2
+#define AD5504_ADDR_DAC2               3
+#define AD5504_ADDR_DAC3               4
+#define AD5504_ADDR_ALL_DAC            5
+#define AD5504_ADDR_CTRL               7
+
+/* Control Register */
+#define AD5504_DAC_PWR(ch)             ((ch) << 2)
+#define AD5504_DAC_PWRDWN_MODE(mode)   ((mode) << 6)
+#define AD5504_DAC_PWRDN_20K           0
+#define AD5504_DAC_PWRDN_3STATE                1
+
+/*
+ * TODO: struct ad5504_platform_data needs to go into include/linux/iio
+ */
+
+struct ad5504_platform_data {
+       u16                             vref_mv;
+};
+
+/**
+ * struct ad5446_state - driver instance specific data
+ * @indio_dev:         the industrial I/O device
+ * @us:                        spi_device
+ * @reg:               supply regulator
+ * @vref_mv:           actual reference voltage used
+ * @pwr_down_mask      power down mask
+ * @pwr_down_mode      current power down mode
+ */
+
+struct ad5504_state {
+       struct iio_dev                  *indio_dev;
+       struct spi_device               *spi;
+       struct regulator                *reg;
+       unsigned short                  vref_mv;
+       unsigned                        pwr_down_mask;
+       unsigned                        pwr_down_mode;
+};
+
+/**
+ * ad5504_supported_device_ids:
+ */
+
+enum ad5504_supported_device_ids {
+       ID_AD5504,
+       ID_AD5501,
+};
+
+#endif /* SPI_AD5504_H_ */
index a945b18ff8439997a2d27cebb55363457016c8f6..c679981f0143896fbc2841ed3fca8e671b5ae57e 100644 (file)
@@ -174,17 +174,6 @@ static ssize_t ad5624r_show_scale(struct device *dev,
 }
 static IIO_DEVICE_ATTR(out_scale, S_IRUGO, ad5624r_show_scale, NULL, 0);
 
-static ssize_t ad5624r_show_name(struct device *dev,
-                                struct device_attribute *attr,
-                                char *buf)
-{
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
-       struct ad5624r_state *st = iio_dev_get_devdata(indio_dev);
-
-       return sprintf(buf, "%s\n", spi_get_device_id(st->us)->name);
-}
-static IIO_DEVICE_ATTR(name, S_IRUGO, ad5624r_show_name, NULL, 0);
-
 static IIO_DEV_ATTR_OUT_RAW(0, ad5624r_write_dac, AD5624R_ADDR_DAC0);
 static IIO_DEV_ATTR_OUT_RAW(1, ad5624r_write_dac, AD5624R_ADDR_DAC1);
 static IIO_DEV_ATTR_OUT_RAW(2, ad5624r_write_dac, AD5624R_ADDR_DAC2);
@@ -222,7 +211,6 @@ static struct attribute *ad5624r_attributes[] = {
        &iio_dev_attr_out_powerdown_mode.dev_attr.attr,
        &iio_const_attr_out_powerdown_mode_available.dev_attr.attr,
        &iio_dev_attr_out_scale.dev_attr.attr,
-       &iio_dev_attr_name.dev_attr.attr,
        NULL,
 };
 
@@ -230,6 +218,11 @@ static const struct attribute_group ad5624r_attribute_group = {
        .attrs = ad5624r_attributes,
 };
 
+static const struct iio_info ad5624r_info = {
+       .attrs = &ad5624r_attribute_group,
+       .driver_module = THIS_MODULE,
+};
+
 static int __devinit ad5624r_probe(struct spi_device *spi)
 {
        struct ad5624r_state *st;
@@ -260,15 +253,15 @@ static int __devinit ad5624r_probe(struct spi_device *spi)
                st->vref_mv = st->chip_info->int_vref_mv;
 
        st->us = spi;
-       st->indio_dev = iio_allocate_device();
+       st->indio_dev = iio_allocate_device(0);
        if (st->indio_dev == NULL) {
                ret = -ENOMEM;
                goto error_disable_reg;
        }
        st->indio_dev->dev.parent = &spi->dev;
-       st->indio_dev->attrs = &ad5624r_attribute_group;
+       st->indio_dev->name = spi_get_device_id(spi)->name;
+       st->indio_dev->info = &ad5624r_info;
        st->indio_dev->dev_data = (void *)(st);
-       st->indio_dev->driver_module = THIS_MODULE;
        st->indio_dev->modes = INDIO_DIRECT_MODE;
 
        ret = iio_device_register(st->indio_dev);
diff --git a/drivers/staging/iio/dac/ad5791.c b/drivers/staging/iio/dac/ad5791.c
new file mode 100644 (file)
index 0000000..4eda25c
--- /dev/null
@@ -0,0 +1,444 @@
+/*
+ * AD5760, AD5780, AD5781, AD5791 Voltage Output Digital to Analog Converter
+ *
+ * Copyright 2011 Analog Devices Inc.
+ *
+ * Licensed under the GPL-2.
+ */
+
+#include <linux/interrupt.h>
+#include <linux/gpio.h>
+#include <linux/fs.h>
+#include <linux/device.h>
+#include <linux/kernel.h>
+#include <linux/spi/spi.h>
+#include <linux/slab.h>
+#include <linux/sysfs.h>
+#include <linux/regulator/consumer.h>
+
+#include "../iio.h"
+#include "../sysfs.h"
+#include "dac.h"
+#include "ad5791.h"
+
+static int ad5791_spi_write(struct spi_device *spi, u8 addr, u32 val)
+{
+       union {
+               u32 d32;
+               u8 d8[4];
+       } data;
+
+       data.d32 = cpu_to_be32(AD5791_CMD_WRITE |
+                             AD5791_ADDR(addr) |
+                             (val & AD5791_DAC_MASK));
+
+       return spi_write(spi, &data.d8[1], 3);
+}
+
+static int ad5791_spi_read(struct spi_device *spi, u8 addr, u32 *val)
+{
+       union {
+               u32 d32;
+               u8 d8[4];
+       } data[3];
+       int ret;
+       struct spi_message msg;
+       struct spi_transfer xfers[] = {
+               {
+                       .tx_buf = &data[0].d8[1],
+                       .bits_per_word = 8,
+                       .len = 3,
+                       .cs_change = 1,
+               }, {
+                       .tx_buf = &data[1].d8[1],
+                       .rx_buf = &data[2].d8[1],
+                       .bits_per_word = 8,
+                       .len = 3,
+               },
+       };
+
+       data[0].d32 = cpu_to_be32(AD5791_CMD_READ |
+                             AD5791_ADDR(addr));
+       data[1].d32 = cpu_to_be32(AD5791_ADDR(AD5791_ADDR_NOOP));
+
+       spi_message_init(&msg);
+       spi_message_add_tail(&xfers[0], &msg);
+       spi_message_add_tail(&xfers[1], &msg);
+       ret = spi_sync(spi, &msg);
+
+       *val = be32_to_cpu(data[2].d32);
+
+       return ret;
+}
+
+static ssize_t ad5791_write_dac(struct device *dev,
+                                struct device_attribute *attr,
+                                const char *buf, size_t len)
+{
+       struct iio_dev *indio_dev = dev_get_drvdata(dev);
+       struct ad5791_state *st = iio_dev_get_devdata(indio_dev);
+       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
+       long readin;
+       int ret;
+
+       ret = strict_strtol(buf, 10, &readin);
+       if (ret)
+               return ret;
+
+       readin += (1 << (st->chip_info->bits - 1));
+       readin &= AD5791_RES_MASK(st->chip_info->bits);
+       readin <<= st->chip_info->left_shift;
+
+       ret = ad5791_spi_write(st->spi, this_attr->address, readin);
+       return ret ? ret : len;
+}
+
+static ssize_t ad5791_read_dac(struct device *dev,
+                                          struct device_attribute *attr,
+                                          char *buf)
+{
+       struct iio_dev *indio_dev = dev_get_drvdata(dev);
+       struct ad5791_state *st = iio_dev_get_devdata(indio_dev);
+       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
+       int ret;
+       int val;
+
+       ret = ad5791_spi_read(st->spi, this_attr->address, &val);
+       if (ret)
+               return ret;
+
+       val &= AD5791_DAC_MASK;
+       val >>= st->chip_info->left_shift;
+       val -= (1 << (st->chip_info->bits - 1));
+
+       return sprintf(buf, "%d\n", val);
+}
+
+static ssize_t ad5791_read_powerdown_mode(struct device *dev,
+                                     struct device_attribute *attr, char *buf)
+{
+       struct iio_dev *indio_dev = dev_get_drvdata(dev);
+       struct ad5791_state *st = iio_dev_get_devdata(indio_dev);
+
+       const char mode[][14] = {"6kohm_to_gnd", "three_state"};
+
+       return sprintf(buf, "%s\n", mode[st->pwr_down_mode]);
+}
+
+static ssize_t ad5791_write_powerdown_mode(struct device *dev,
+                                      struct device_attribute *attr,
+                                      const char *buf, size_t len)
+{
+       struct iio_dev *indio_dev = dev_get_drvdata(dev);
+       struct ad5791_state *st = iio_dev_get_devdata(indio_dev);
+       int ret;
+
+       if (sysfs_streq(buf, "6kohm_to_gnd"))
+               st->pwr_down_mode = AD5791_DAC_PWRDN_6K;
+       else if (sysfs_streq(buf, "three_state"))
+               st->pwr_down_mode = AD5791_DAC_PWRDN_3STATE;
+       else
+               ret = -EINVAL;
+
+       return ret ? ret : len;
+}
+
+static ssize_t ad5791_read_dac_powerdown(struct device *dev,
+                                          struct device_attribute *attr,
+                                          char *buf)
+{
+       struct iio_dev *indio_dev = dev_get_drvdata(dev);
+       struct ad5791_state *st = iio_dev_get_devdata(indio_dev);
+
+       return sprintf(buf, "%d\n", st->pwr_down);
+}
+
+static ssize_t ad5791_write_dac_powerdown(struct device *dev,
+                                           struct device_attribute *attr,
+                                           const char *buf, size_t len)
+{
+       long readin;
+       int ret;
+       struct iio_dev *indio_dev = dev_get_drvdata(dev);
+       struct ad5791_state *st = iio_dev_get_devdata(indio_dev);
+
+       ret = strict_strtol(buf, 10, &readin);
+       if (ret)
+               return ret;
+
+       if (readin == 0) {
+               st->pwr_down = false;
+               st->ctrl &= ~(AD5791_CTRL_OPGND | AD5791_CTRL_DACTRI);
+       } else if (readin == 1) {
+               st->pwr_down = true;
+               if (st->pwr_down_mode == AD5791_DAC_PWRDN_6K)
+                       st->ctrl |= AD5791_CTRL_OPGND;
+               else if (st->pwr_down_mode == AD5791_DAC_PWRDN_3STATE)
+                       st->ctrl |= AD5791_CTRL_DACTRI;
+       } else
+               ret = -EINVAL;
+
+       ret = ad5791_spi_write(st->spi, AD5791_ADDR_CTRL, st->ctrl);
+
+       return ret ? ret : len;
+}
+
+static ssize_t ad5791_show_scale(struct device *dev,
+                               struct device_attribute *attr,
+                               char *buf)
+{
+       struct iio_dev *indio_dev = dev_get_drvdata(dev);
+       struct ad5791_state *st = iio_dev_get_devdata(indio_dev);
+       /* Corresponds to Vref / 2^(bits) */
+       unsigned int scale_uv = (st->vref_mv * 1000) >> st->chip_info->bits;
+
+       return sprintf(buf, "%d.%03d\n", scale_uv / 1000, scale_uv % 1000);
+}
+static IIO_DEVICE_ATTR(out_scale, S_IRUGO, ad5791_show_scale, NULL, 0);
+
+static ssize_t ad5791_show_name(struct device *dev,
+                                struct device_attribute *attr,
+                                char *buf)
+{
+       struct iio_dev *indio_dev = dev_get_drvdata(dev);
+       struct ad5791_state *st = iio_dev_get_devdata(indio_dev);
+
+       return sprintf(buf, "%s\n", spi_get_device_id(st->spi)->name);
+}
+static IIO_DEVICE_ATTR(name, S_IRUGO, ad5791_show_name, NULL, 0);
+
+#define IIO_DEV_ATTR_OUT_RW_RAW(_num, _show, _store, _addr)            \
+       IIO_DEVICE_ATTR(out##_num##_raw,                                \
+                       S_IRUGO | S_IWUSR, _show, _store, _addr)
+
+static IIO_DEV_ATTR_OUT_RW_RAW(0, ad5791_read_dac,
+       ad5791_write_dac, AD5791_ADDR_DAC0);
+
+static IIO_DEVICE_ATTR(out_powerdown_mode, S_IRUGO |
+                       S_IWUSR, ad5791_read_powerdown_mode,
+                       ad5791_write_powerdown_mode, 0);
+
+static IIO_CONST_ATTR(out_powerdown_mode_available,
+                       "6kohm_to_gnd three_state");
+
+#define IIO_DEV_ATTR_DAC_POWERDOWN(_num, _show, _store, _addr)         \
+       IIO_DEVICE_ATTR(out##_num##_powerdown,                          \
+                       S_IRUGO | S_IWUSR, _show, _store, _addr)
+
+static IIO_DEV_ATTR_DAC_POWERDOWN(0, ad5791_read_dac_powerdown,
+                                  ad5791_write_dac_powerdown, 0);
+
+static struct attribute *ad5791_attributes[] = {
+       &iio_dev_attr_out0_raw.dev_attr.attr,
+       &iio_dev_attr_out0_powerdown.dev_attr.attr,
+       &iio_dev_attr_out_powerdown_mode.dev_attr.attr,
+       &iio_const_attr_out_powerdown_mode_available.dev_attr.attr,
+       &iio_dev_attr_out_scale.dev_attr.attr,
+       &iio_dev_attr_name.dev_attr.attr,
+       NULL,
+};
+
+static const struct attribute_group ad5791_attribute_group = {
+       .attrs = ad5791_attributes,
+};
+
+static int ad5791_get_lin_comp(unsigned int span)
+{
+       if (span <= 10000)
+               return AD5791_LINCOMP_0_10;
+       else if (span <= 12000)
+               return AD5791_LINCOMP_10_12;
+       else if (span <= 16000)
+               return AD5791_LINCOMP_12_16;
+       else if (span <= 19000)
+               return AD5791_LINCOMP_16_19;
+       else
+               return AD5791_LINCOMP_19_20;
+}
+
+static int ad5780_get_lin_comp(unsigned int span)
+{
+       if (span <= 10000)
+               return AD5780_LINCOMP_0_10;
+       else
+               return AD5780_LINCOMP_10_20;
+}
+
+static const struct ad5791_chip_info ad5791_chip_info_tbl[] = {
+       [ID_AD5760] = {
+               .bits = 16,
+               .left_shift = 4,
+               .get_lin_comp = ad5780_get_lin_comp,
+       },
+       [ID_AD5780] = {
+               .bits = 18,
+               .left_shift = 2,
+               .get_lin_comp = ad5780_get_lin_comp,
+       },
+       [ID_AD5781] = {
+               .bits = 18,
+               .left_shift = 2,
+               .get_lin_comp = ad5791_get_lin_comp,
+       },
+       [ID_AD5791] = {
+               .bits = 20,
+               .left_shift = 0,
+               .get_lin_comp = ad5791_get_lin_comp,
+       },
+};
+
+static const struct iio_info ad5791_info = {
+       .attrs = &ad5791_attribute_group,
+       .driver_module = THIS_MODULE,
+};
+
+static int __devinit ad5791_probe(struct spi_device *spi)
+{
+       struct ad5791_platform_data *pdata = spi->dev.platform_data;
+       struct ad5791_state *st;
+       int ret, pos_voltage_uv = 0, neg_voltage_uv = 0;
+
+       st = kzalloc(sizeof(*st), GFP_KERNEL);
+       if (st == NULL) {
+               ret = -ENOMEM;
+               goto error_ret;
+       }
+
+       spi_set_drvdata(spi, st);
+
+       st->reg_vdd = regulator_get(&spi->dev, "vdd");
+       if (!IS_ERR(st->reg_vdd)) {
+               ret = regulator_enable(st->reg_vdd);
+               if (ret)
+                       goto error_put_reg_pos;
+
+               pos_voltage_uv = regulator_get_voltage(st->reg_vdd);
+       }
+
+       st->reg_vss = regulator_get(&spi->dev, "vss");
+       if (!IS_ERR(st->reg_vss)) {
+               ret = regulator_enable(st->reg_vss);
+               if (ret)
+                       goto error_put_reg_neg;
+
+               neg_voltage_uv = regulator_get_voltage(st->reg_vss);
+       }
+
+       if (!IS_ERR(st->reg_vss) && !IS_ERR(st->reg_vdd))
+               st->vref_mv = (pos_voltage_uv - neg_voltage_uv) / 1000;
+       else if (pdata)
+               st->vref_mv = pdata->vref_pos_mv - pdata->vref_neg_mv;
+       else
+               dev_warn(&spi->dev, "reference voltage unspecified\n");
+
+       ret = ad5791_spi_write(spi, AD5791_ADDR_SW_CTRL, AD5791_SWCTRL_RESET);
+       if (ret)
+               goto error_disable_reg_neg;
+
+       st->chip_info =
+               &ad5791_chip_info_tbl[spi_get_device_id(spi)->driver_data];
+
+
+       st->ctrl = AD5761_CTRL_LINCOMP(st->chip_info->get_lin_comp(st->vref_mv))
+                 | ((pdata && pdata->use_rbuf_gain2) ? 0 : AD5791_CTRL_RBUF) |
+                 AD5791_CTRL_BIN2SC;
+
+       ret = ad5791_spi_write(spi, AD5791_ADDR_CTRL, st->ctrl |
+               AD5791_CTRL_OPGND | AD5791_CTRL_DACTRI);
+       if (ret)
+               goto error_disable_reg_neg;
+
+       st->pwr_down = true;
+
+       st->spi = spi;
+       st->indio_dev = iio_allocate_device(0);
+       if (st->indio_dev == NULL) {
+               ret = -ENOMEM;
+               goto error_disable_reg_neg;
+       }
+       st->indio_dev->dev.parent = &spi->dev;
+       st->indio_dev->dev_data = (void *)(st);
+       st->indio_dev->info = &ad5791_info;
+       st->indio_dev->modes = INDIO_DIRECT_MODE;
+
+       ret = iio_device_register(st->indio_dev);
+       if (ret)
+               goto error_free_dev;
+
+       return 0;
+
+error_free_dev:
+       iio_free_device(st->indio_dev);
+
+error_disable_reg_neg:
+       if (!IS_ERR(st->reg_vss))
+               regulator_disable(st->reg_vss);
+error_put_reg_neg:
+       if (!IS_ERR(st->reg_vss))
+               regulator_put(st->reg_vss);
+
+       if (!IS_ERR(st->reg_vdd))
+               regulator_disable(st->reg_vdd);
+error_put_reg_pos:
+       if (!IS_ERR(st->reg_vdd))
+               regulator_put(st->reg_vdd);
+
+       kfree(st);
+error_ret:
+       return ret;
+}
+
+static int __devexit ad5791_remove(struct spi_device *spi)
+{
+       struct ad5791_state *st = spi_get_drvdata(spi);
+
+       iio_device_unregister(st->indio_dev);
+
+       if (!IS_ERR(st->reg_vdd)) {
+               regulator_disable(st->reg_vdd);
+               regulator_put(st->reg_vdd);
+       }
+
+       if (!IS_ERR(st->reg_vss)) {
+               regulator_disable(st->reg_vss);
+               regulator_put(st->reg_vss);
+       }
+
+       kfree(st);
+
+       return 0;
+}
+
+static const struct spi_device_id ad5791_id[] = {
+       {"ad5760", ID_AD5760},
+       {"ad5780", ID_AD5780},
+       {"ad5781", ID_AD5781},
+       {"ad5791", ID_AD5791},
+       {}
+};
+
+static struct spi_driver ad5791_driver = {
+       .driver = {
+                  .name = "ad5791",
+                  .owner = THIS_MODULE,
+                  },
+       .probe = ad5791_probe,
+       .remove = __devexit_p(ad5791_remove),
+       .id_table = ad5791_id,
+};
+
+static __init int ad5791_spi_init(void)
+{
+       return spi_register_driver(&ad5791_driver);
+}
+module_init(ad5791_spi_init);
+
+static __exit void ad5791_spi_exit(void)
+{
+       spi_unregister_driver(&ad5791_driver);
+}
+module_exit(ad5791_spi_exit);
+
+MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>");
+MODULE_DESCRIPTION("Analog Devices AD5760/AD5780/AD5781/AD5791 DAC");
+MODULE_LICENSE("GPL v2");
diff --git a/drivers/staging/iio/dac/ad5791.h b/drivers/staging/iio/dac/ad5791.h
new file mode 100644 (file)
index 0000000..f09ad9a
--- /dev/null
@@ -0,0 +1,116 @@
+/*
+ * AD5791 SPI DAC driver
+ *
+ * Copyright 2011 Analog Devices Inc.
+ *
+ * Licensed under the GPL-2.
+ */
+
+#ifndef SPI_AD5791_H_
+#define SPI_AD5791_H_
+
+#define AD5791_RES_MASK(x)             ((1 << (x)) - 1)
+#define AD5791_DAC_MASK                        AD5791_RES_MASK(20)
+#define AD5791_DAC_MSB                 (1 << 19)
+
+#define AD5791_CMD_READ                        (1 << 23)
+#define AD5791_CMD_WRITE               (0 << 23)
+#define AD5791_ADDR(addr)              ((addr) << 20)
+
+/* Registers */
+#define AD5791_ADDR_NOOP               0
+#define AD5791_ADDR_DAC0               1
+#define AD5791_ADDR_CTRL               2
+#define AD5791_ADDR_CLRCODE            3
+#define AD5791_ADDR_SW_CTRL            4
+
+/* Control Register */
+#define AD5791_CTRL_RBUF               (1 << 1)
+#define AD5791_CTRL_OPGND              (1 << 2)
+#define AD5791_CTRL_DACTRI             (1 << 3)
+#define AD5791_CTRL_BIN2SC             (1 << 4)
+#define AD5791_CTRL_SDODIS             (1 << 5)
+#define AD5761_CTRL_LINCOMP(x)         ((x) << 6)
+
+#define AD5791_LINCOMP_0_10            0
+#define AD5791_LINCOMP_10_12           1
+#define AD5791_LINCOMP_12_16           2
+#define AD5791_LINCOMP_16_19           3
+#define AD5791_LINCOMP_19_20           12
+
+#define AD5780_LINCOMP_0_10            0
+#define AD5780_LINCOMP_10_20           12
+
+/* Software Control Register */
+#define AD5791_SWCTRL_LDAC             (1 << 0)
+#define AD5791_SWCTRL_CLR              (1 << 1)
+#define AD5791_SWCTRL_RESET            (1 << 2)
+
+#define AD5791_DAC_PWRDN_6K            0
+#define AD5791_DAC_PWRDN_3STATE                1
+
+/*
+ * TODO: struct ad5791_platform_data needs to go into include/linux/iio
+ */
+
+/**
+ * struct ad5791_platform_data - platform specific information
+ * @vref_pos_mv:       Vdd Positive Analog Supply Volatge (mV)
+ * @vref_neg_mv:       Vdd Negative Analog Supply Volatge (mV)
+ * @use_rbuf_gain2:    ext. amplifier connected in gain of two configuration
+ */
+
+struct ad5791_platform_data {
+       u16                             vref_pos_mv;
+       u16                             vref_neg_mv;
+       bool                            use_rbuf_gain2;
+};
+
+/**
+ * struct ad5791_chip_info - chip specific information
+ * @bits:              accuracy of the DAC in bits
+ * @left_shift:                number of bits the datum must be shifted
+ * @get_lin_comp:      function pointer to the device specific function
+ */
+
+struct ad5791_chip_info {
+       u8                      bits;
+       u8                      left_shift;
+       int (*get_lin_comp)     (unsigned int span);
+};
+
+/**
+ * struct ad5791_state - driver instance specific data
+ * @indio_dev:         the industrial I/O device
+ * @us:                        spi_device
+ * @reg_vdd:           positive supply regulator
+ * @reg_vss:           negative supply regulator
+ * @chip_info:         chip model specific constants
+ * @vref_mv:           actual reference voltage used
+ * @pwr_down_mode      current power down mode
+ */
+
+struct ad5791_state {
+       struct iio_dev                  *indio_dev;
+       struct spi_device               *spi;
+       struct regulator                *reg_vdd;
+       struct regulator                *reg_vss;
+       const struct ad5791_chip_info   *chip_info;
+       unsigned short                  vref_mv;
+       unsigned                        ctrl;
+       unsigned                        pwr_down_mode;
+       bool                            pwr_down;
+};
+
+/**
+ * ad5791_supported_device_ids:
+ */
+
+enum ad5791_supported_device_ids {
+       ID_AD5760,
+       ID_AD5780,
+       ID_AD5781,
+       ID_AD5791,
+};
+
+#endif /* SPI_AD5791_H_ */
index 7071f713604a2ebab231f36d3aa9c9e2636580bc..881768df47a6b813a417dcffe1a3f9cce2ecf898 100644 (file)
@@ -189,6 +189,16 @@ static int max517_resume(struct i2c_client *client)
        return i2c_master_send(client, &outbuf, 1);
 }
 
+static const struct iio_info max517_info = {
+       .attrs = &max517_attribute_group,
+       .driver_module = THIS_MODULE,
+};
+
+static const struct iio_info max518_info = {
+       .attrs = &max517_attribute_group,
+       .driver_module = THIS_MODULE,
+};
+
 static int max517_probe(struct i2c_client *client,
                        const struct i2c_device_id *id)
 {
@@ -206,7 +216,7 @@ static int max517_probe(struct i2c_client *client,
 
        data->client = client;
 
-       data->indio_dev = iio_allocate_device();
+       data->indio_dev = iio_allocate_device(0);
        if (data->indio_dev == NULL) {
                err = -ENOMEM;
                goto exit_free_data;
@@ -217,11 +227,10 @@ static int max517_probe(struct i2c_client *client,
 
        /* reduced attribute set for MAX517 */
        if (id->driver_data == ID_MAX517)
-               data->indio_dev->attrs = &max517_attribute_group;
+               data->indio_dev->info = &max517_info;
        else
-               data->indio_dev->attrs = &max518_attribute_group;
+               data->indio_dev->info = &max518_info;
        data->indio_dev->dev_data = (void *)(data);
-       data->indio_dev->driver_module = THIS_MODULE;
        data->indio_dev->modes = INDIO_DIRECT_MODE;
 
        /*
index 06b6f3a8e420cf589442d47609158aeb76658dea..e07431d80093f19107e88d5ccd4f0bc6c65159e4 100644 (file)
@@ -21,11 +21,11 @@ config AD9832
          module will be called ad9832.
 
 config AD9834
-       tristate "Analog Devices ad9833/4/ driver"
+       tristate "Analog Devices AD9833/4/7/8 driver"
        depends on SPI
        help
          Say yes here to build support for Analog Devices DDS chip
-         AD9833 and AD9834, provides direct access via sysfs.
+         AD9833, AD9834, AD9837 and AD9838, provides direct access via sysfs.
 
          To compile this driver as a module, choose M here: the
          module will be called ad9834.
index f80039c5d5390292893a741e4cc09030a169b582..490c3637bc8ee9a326213a2c698b903c926fc792 100644 (file)
@@ -87,6 +87,12 @@ static const struct attribute_group ad5930_attribute_group = {
        .attrs = ad5930_attributes,
 };
 
+static const struct iio_info ad5930_info = {
+       .attrs = &ad5930_attribute_group,
+
+       .driver_module = THIS_MODULE,
+};
+
 static int __devinit ad5930_probe(struct spi_device *spi)
 {
        struct ad5930_state *st;
@@ -102,18 +108,14 @@ static int __devinit ad5930_probe(struct spi_device *spi)
        mutex_init(&st->lock);
        st->sdev = spi;
 
-       st->idev = iio_allocate_device();
+       st->idev = iio_allocate_device(0);
        if (st->idev == NULL) {
                ret = -ENOMEM;
                goto error_free_st;
        }
        st->idev->dev.parent = &spi->dev;
-       st->idev->num_interrupt_lines = 0;
-       st->idev->event_attrs = NULL;
-
-       st->idev->attrs = &ad5930_attribute_group;
        st->idev->dev_data = (void *)(st);
-       st->idev->driver_module = THIS_MODULE;
+       st->idev->info = &ad5930_info;
        st->idev->modes = INDIO_DIRECT_MODE;
 
        ret = iio_device_register(st->idev);
index 3e8491f60cfed31f43904d65b88bc57936754dc9..e8fe1426a3295965e0ce40f215112c82c1d3d0b7 100644 (file)
@@ -153,17 +153,6 @@ error_ret:
        return ret ? ret : len;
 }
 
-static ssize_t ad9832_show_name(struct device *dev,
-                                struct device_attribute *attr,
-                                char *buf)
-{
-       struct iio_dev *dev_info = dev_get_drvdata(dev);
-       struct ad9832_state *st = iio_dev_get_devdata(dev_info);
-
-       return sprintf(buf, "%s\n", spi_get_device_id(st->spi)->name);
-}
-static IIO_DEVICE_ATTR(name, S_IRUGO, ad9832_show_name, NULL, 0);
-
 /**
  * see dds.h for further information
  */
@@ -199,7 +188,6 @@ static struct attribute *ad9832_attributes[] = {
        &iio_dev_attr_dds0_freqsymbol.dev_attr.attr,
        &iio_dev_attr_dds0_phasesymbol.dev_attr.attr,
        &iio_dev_attr_dds0_out_enable.dev_attr.attr,
-       &iio_dev_attr_name.dev_attr.attr,
        NULL,
 };
 
@@ -207,6 +195,11 @@ static const struct attribute_group ad9832_attribute_group = {
        .attrs = ad9832_attributes,
 };
 
+static const struct iio_info ad9832_info = {
+       .attrs = &ad9832_attribute_group,
+       .driver_module = THIS_MODULE,
+};
+
 static int __devinit ad9832_probe(struct spi_device *spi)
 {
        struct ad9832_platform_data *pdata = spi->dev.platform_data;
@@ -236,16 +229,16 @@ static int __devinit ad9832_probe(struct spi_device *spi)
        spi_set_drvdata(spi, st);
        st->spi = spi;
 
-       st->indio_dev = iio_allocate_device();
+       st->indio_dev = iio_allocate_device(0);
        if (st->indio_dev == NULL) {
                ret = -ENOMEM;
                goto error_disable_reg;
        }
 
        st->indio_dev->dev.parent = &spi->dev;
-       st->indio_dev->attrs = &ad9832_attribute_group;
+       st->indio_dev->name = spi_get_device_id(spi)->name;
+       st->indio_dev->info = &ad9832_info;
        st->indio_dev->dev_data = (void *) st;
-       st->indio_dev->driver_module = THIS_MODULE;
        st->indio_dev->modes = INDIO_DIRECT_MODE;
 
        /* Setup default messages */
index eb1a681874f94fb994c318c7b3780ceb283246a3..0ebe8d58e92e64e2de5282561ef80ef8966782fa 100644 (file)
@@ -1,9 +1,9 @@
 /*
- * AD9834 SPI DAC driver
+ * AD9833/AD9834/AD9837/AD9838 SPI DDS driver
  *
- * Copyright 2010 Analog Devices Inc.
+ * Copyright 2010-2011 Analog Devices Inc.
  *
- * Licensed under the GPL-2 or later.
+ * Licensed under the GPL-2.
  */
 
 #include <linux/interrupt.h>
@@ -47,7 +47,7 @@ static int ad9834_write_frequency(struct ad9834_state *st,
                                       (AD9834_FREQ_BITS / 2)) &
                                       RES_MASK(AD9834_FREQ_BITS / 2)));
 
-       return spi_sync(st->spi, &st->freq_msg);;
+       return spi_sync(st->spi, &st->freq_msg);
 }
 
 static int ad9834_write_phase(struct ad9834_state *st,
@@ -148,7 +148,7 @@ static ssize_t ad9834_store_wavetype(struct device *dev,
        struct ad9834_state *st = dev_info->dev_data;
        struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
        int ret = 0;
-       bool is_ad9833 = st->devid == ID_AD9833;
+       bool is_ad9833_7 = (st->devid == ID_AD9833) || (st->devid == ID_AD9837);
 
        mutex_lock(&dev_info->mlock);
 
@@ -156,10 +156,10 @@ static ssize_t ad9834_store_wavetype(struct device *dev,
        case 0:
                if (sysfs_streq(buf, "sine")) {
                        st->control &= ~AD9834_MODE;
-                       if (is_ad9833)
+                       if (is_ad9833_7)
                                st->control &= ~AD9834_OPBITEN;
                } else if (sysfs_streq(buf, "triangle")) {
-                       if (is_ad9833) {
+                       if (is_ad9833_7) {
                                st->control &= ~AD9834_OPBITEN;
                                st->control |= AD9834_MODE;
                        } else if (st->control & AD9834_OPBITEN) {
@@ -167,7 +167,7 @@ static ssize_t ad9834_store_wavetype(struct device *dev,
                        } else {
                                st->control |= AD9834_MODE;
                        }
-               } else if (is_ad9833 && sysfs_streq(buf, "square")) {
+               } else if (is_ad9833_7 && sysfs_streq(buf, "square")) {
                        st->control &= ~AD9834_MODE;
                        st->control |= AD9834_OPBITEN;
                } else {
@@ -198,17 +198,6 @@ static ssize_t ad9834_store_wavetype(struct device *dev,
        return ret ? ret : len;
 }
 
-static ssize_t ad9834_show_name(struct device *dev,
-                                struct device_attribute *attr,
-                                char *buf)
-{
-       struct iio_dev *dev_info = dev_get_drvdata(dev);
-       struct ad9834_state *st = iio_dev_get_devdata(dev_info);
-
-       return sprintf(buf, "%s\n", spi_get_device_id(st->spi)->name);
-}
-static IIO_DEVICE_ATTR(name, S_IRUGO, ad9834_show_name, NULL, 0);
-
 static ssize_t ad9834_show_out0_wavetype_available(struct device *dev,
                                                struct device_attribute *attr,
                                                char *buf)
@@ -217,7 +206,7 @@ static ssize_t ad9834_show_out0_wavetype_available(struct device *dev,
        struct ad9834_state *st = iio_dev_get_devdata(dev_info);
        char *str;
 
-       if (st->devid == ID_AD9833)
+       if ((st->devid == ID_AD9833) || (st->devid == ID_AD9837))
                str = "sine triangle square";
        else if (st->control & AD9834_OPBITEN)
                str = "sine";
@@ -288,7 +277,6 @@ static struct attribute *ad9834_attributes[] = {
        &iio_dev_attr_dds0_out1_wavetype.dev_attr.attr,
        &iio_dev_attr_dds0_out0_wavetype_available.dev_attr.attr,
        &iio_dev_attr_dds0_out1_wavetype_available.dev_attr.attr,
-       &iio_dev_attr_name.dev_attr.attr,
        NULL,
 };
 
@@ -301,13 +289,12 @@ static mode_t ad9834_attr_is_visible(struct kobject *kobj,
 
        mode_t mode = attr->mode;
 
-       if (st->devid == ID_AD9834)
-               return mode;
-
-       if ((attr == &iio_dev_attr_dds0_out1_enable.dev_attr.attr) ||
+       if (((st->devid == ID_AD9833) || (st->devid == ID_AD9837)) &&
+               ((attr == &iio_dev_attr_dds0_out1_enable.dev_attr.attr) ||
                (attr == &iio_dev_attr_dds0_out1_wavetype.dev_attr.attr) ||
                (attr ==
-               &iio_dev_attr_dds0_out1_wavetype_available.dev_attr.attr))
+               &iio_dev_attr_dds0_out1_wavetype_available.dev_attr.attr) ||
+               (attr == &iio_dev_attr_dds0_pincontrol_en.dev_attr.attr)))
                mode = 0;
 
        return mode;
@@ -318,6 +305,11 @@ static const struct attribute_group ad9834_attribute_group = {
        .is_visible = ad9834_attr_is_visible,
 };
 
+static const struct iio_info ad9834_info = {
+       .attrs = &ad9834_attribute_group,
+       .driver_module = THIS_MODULE,
+};
+
 static int __devinit ad9834_probe(struct spi_device *spi)
 {
        struct ad9834_platform_data *pdata = spi->dev.platform_data;
@@ -349,16 +341,16 @@ static int __devinit ad9834_probe(struct spi_device *spi)
        st->spi = spi;
        st->devid = spi_get_device_id(spi)->driver_data;
 
-       st->indio_dev = iio_allocate_device();
+       st->indio_dev = iio_allocate_device(0);
        if (st->indio_dev == NULL) {
                ret = -ENOMEM;
                goto error_disable_reg;
        }
 
        st->indio_dev->dev.parent = &spi->dev;
-       st->indio_dev->attrs = &ad9834_attribute_group;
+       st->indio_dev->name = spi_get_device_id(spi)->name;
+       st->indio_dev->info = &ad9834_info;
        st->indio_dev->dev_data = (void *) st;
-       st->indio_dev->driver_module = THIS_MODULE;
        st->indio_dev->modes = INDIO_DIRECT_MODE;
 
        /* Setup default messages */
@@ -445,6 +437,8 @@ static int __devexit ad9834_remove(struct spi_device *spi)
 static const struct spi_device_id ad9834_id[] = {
        {"ad9833", ID_AD9833},
        {"ad9834", ID_AD9834},
+       {"ad9837", ID_AD9837},
+       {"ad9838", ID_AD9838},
        {}
 };
 
@@ -472,6 +466,6 @@ static void __exit ad9834_exit(void)
 module_exit(ad9834_exit);
 
 MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>");
-MODULE_DESCRIPTION("Analog Devices AD9833/AD9834 DDS");
+MODULE_DESCRIPTION("Analog Devices AD9833/AD9834/AD9837/AD9838 DDS");
 MODULE_LICENSE("GPL v2");
 MODULE_ALIAS("spi:ad9834");
index 0fc3b8859e9efe1685f9790937712c8bfe01ec18..2abd63587e0372f6d092f3c93e5c79fdb88041fb 100644 (file)
@@ -1,9 +1,9 @@
 /*
- * AD9834 SPI DDS driver
+ * AD9833/AD9834/AD9837/AD9838 SPI DDS driver
  *
- * Copyright 2010 Analog Devices Inc.
+ * Copyright 2010-2011 Analog Devices Inc.
  *
- * Licensed under the GPL-2 or later.
+ * Licensed under the GPL-2.
  */
 #ifndef IIO_DDS_AD9834_H_
 #define IIO_DDS_AD9834_H_
@@ -107,6 +107,8 @@ struct ad9834_platform_data {
 enum ad9834_supported_device_ids {
        ID_AD9833,
        ID_AD9834,
+       ID_AD9837,
+       ID_AD9838,
 };
 
 #endif /* IIO_DDS_AD9834_H_ */
index b259bfeaf5aa699ca8cbd393efc814afdbc79996..b580d852a1eeabe2ae6e5d1cbe64e9c9bd467cec 100644 (file)
@@ -73,6 +73,11 @@ static const struct attribute_group ad9850_attribute_group = {
        .attrs = ad9850_attributes,
 };
 
+static const struct iio_info ad9850_info = {
+       .attrs = &ad9850_attribute_group,
+       .driver_module = THIS_MODULE,
+};
+
 static int __devinit ad9850_probe(struct spi_device *spi)
 {
        struct ad9850_state *st;
@@ -88,18 +93,15 @@ static int __devinit ad9850_probe(struct spi_device *spi)
        mutex_init(&st->lock);
        st->sdev = spi;
 
-       st->idev = iio_allocate_device();
+       st->idev = iio_allocate_device(0);
        if (st->idev == NULL) {
                ret = -ENOMEM;
                goto error_free_st;
        }
        st->idev->dev.parent = &spi->dev;
-       st->idev->num_interrupt_lines = 0;
-       st->idev->event_attrs = NULL;
 
-       st->idev->attrs = &ad9850_attribute_group;
+       st->idev->info = &ad9850_info;
        st->idev->dev_data = (void *)(st);
-       st->idev->driver_module = THIS_MODULE;
        st->idev->modes = INDIO_DIRECT_MODE;
 
        ret = iio_device_register(st->idev);
index 594fb6a94331983afbf86b3a3a1919ee48619b6d..08020f96300a1ceceb49b9964b617fa9eb659322 100644 (file)
@@ -222,6 +222,11 @@ static const struct attribute_group ad9852_attribute_group = {
        .attrs = ad9852_attributes,
 };
 
+static const struct iio_info ad9852_info = {
+       .attrs = &ad9852_attribute_group,
+       .driver_module = THIS_MODULE,
+};
+
 static int __devinit ad9852_probe(struct spi_device *spi)
 {
        struct ad9852_state *st;
@@ -237,18 +242,15 @@ static int __devinit ad9852_probe(struct spi_device *spi)
        mutex_init(&st->lock);
        st->sdev = spi;
 
-       st->idev = iio_allocate_device();
+       st->idev = iio_allocate_device(0);
        if (st->idev == NULL) {
                ret = -ENOMEM;
                goto error_free_st;
        }
        st->idev->dev.parent = &spi->dev;
-       st->idev->num_interrupt_lines = 0;
-       st->idev->event_attrs = NULL;
 
-       st->idev->attrs = &ad9852_attribute_group;
+       st->idev->info = &ad9852_info;
        st->idev->dev_data = (void *)(st);
-       st->idev->driver_module = THIS_MODULE;
        st->idev->modes = INDIO_DIRECT_MODE;
 
        ret = iio_device_register(st->idev);
index e8fb75cb66ecce94248b6bfea4b67d81fc6e6681..97d75d755824a09864bee0715b422b7d50944a54 100644 (file)
@@ -357,6 +357,11 @@ static const struct attribute_group ad9910_attribute_group = {
        .attrs = ad9910_attributes,
 };
 
+static const struct iio_info ad9910_info = {
+       .attrs = &ad9910_attribute_group,
+       .driver_module = THIS_MODULE,
+};
+
 static int __devinit ad9910_probe(struct spi_device *spi)
 {
        struct ad9910_state *st;
@@ -372,18 +377,15 @@ static int __devinit ad9910_probe(struct spi_device *spi)
        mutex_init(&st->lock);
        st->sdev = spi;
 
-       st->idev = iio_allocate_device();
+       st->idev = iio_allocate_device(0);
        if (st->idev == NULL) {
                ret = -ENOMEM;
                goto error_free_st;
        }
        st->idev->dev.parent = &spi->dev;
-       st->idev->num_interrupt_lines = 0;
-       st->idev->event_attrs = NULL;
 
-       st->idev->attrs = &ad9910_attribute_group;
+       st->idev->info = &ad9910_info;
        st->idev->dev_data = (void *)(st);
-       st->idev->driver_module = THIS_MODULE;
        st->idev->modes = INDIO_DIRECT_MODE;
 
        ret = iio_device_register(st->idev);
index 57eddf6d47137fe720b3cec4898e95a0279a0578..d4dfcd41d5f9b4e2e36cf7186c62a1e24254c90c 100644 (file)
@@ -166,6 +166,11 @@ static const struct attribute_group ad9951_attribute_group = {
        .attrs = ad9951_attributes,
 };
 
+static const struct iio_info ad9951_info = {
+       .attrs = &ad9951_attribute_group,
+       .driver_module = THIS_MODULE,
+};
+
 static int __devinit ad9951_probe(struct spi_device *spi)
 {
        struct ad9951_state *st;
@@ -181,18 +186,15 @@ static int __devinit ad9951_probe(struct spi_device *spi)
        mutex_init(&st->lock);
        st->sdev = spi;
 
-       st->idev = iio_allocate_device();
+       st->idev = iio_allocate_device(0);
        if (st->idev == NULL) {
                ret = -ENOMEM;
                goto error_free_st;
        }
        st->idev->dev.parent = &spi->dev;
-       st->idev->num_interrupt_lines = 0;
-       st->idev->event_attrs = NULL;
 
-       st->idev->attrs = &ad9951_attribute_group;
+       st->idev->info = &ad9951_info;
        st->idev->dev_data = (void *)(st);
-       st->idev->driver_module = THIS_MODULE;
        st->idev->modes = INDIO_DIRECT_MODE;
 
        ret = iio_device_register(st->idev);
index 8b78fa0e63162a3080d0ff2d5b8357c7ddcf79f6..ae2e7d3095ae98fedea58a5bf6d763c7388eb516 100644 (file)
@@ -35,3 +35,13 @@ config ADIS16260
 
          This driver can also be built as a module.  If so, the module
          will be called adis16260.
+
+config ADXRS450
+       tristate "Analog Devices ADXRS450 Digital Output Gyroscope SPI driver"
+       depends on SPI
+       help
+         Say yes here to build support for Analog Devices ADXRS450 programmable
+         digital output gyroscope.
+
+         This driver can also be built as a module.  If so, the module
+         will be called adxrs450.
index 2764c15025a512ff07884f9a1c2f070b23286420..2212240f7de3035d9f7ba336d1ee60a6aa9e8962 100644 (file)
@@ -17,3 +17,6 @@ obj-$(CONFIG_ADIS16260) += adis16260.o
 
 adis16251-y             := adis16251_core.o
 obj-$(CONFIG_ADIS16251) += adis16251.o
+
+adxrs450-y             := adxrs450_core.o
+obj-$(CONFIG_ADXRS450) += adxrs450.o
index ae53e71d1c2f3c35b31a6d5b2779f69b96195750..edf9e3bf3efd6d7eec76c7cdf20bff7b8c344ab0 100644 (file)
@@ -133,6 +133,11 @@ static const struct attribute_group adis16060_attribute_group = {
        .attrs = adis16060_attributes,
 };
 
+static const struct iio_info adis16060_info = {
+       .attrs = &adis16060_attribute_group,
+       .driver_module = THIS_MODULE,
+};
+
 static int __devinit adis16060_r_probe(struct spi_device *spi)
 {
        int ret, regdone = 0;
@@ -147,16 +152,15 @@ static int __devinit adis16060_r_probe(struct spi_device *spi)
        st->us_r = spi;
        mutex_init(&st->buf_lock);
        /* setup the industrialio driver allocated elements */
-       st->indio_dev = iio_allocate_device();
+       st->indio_dev = iio_allocate_device(0);
        if (st->indio_dev == NULL) {
                ret = -ENOMEM;
                goto error_free_st;
        }
 
        st->indio_dev->dev.parent = &spi->dev;
-       st->indio_dev->attrs = &adis16060_attribute_group;
+       st->indio_dev->info = &adis16060_info;
        st->indio_dev->dev_data = (void *)(st);
-       st->indio_dev->driver_module = THIS_MODULE;
        st->indio_dev->modes = INDIO_DIRECT_MODE;
 
        ret = iio_device_register(st->indio_dev);
index ef9e304a226d582ce554003811f373fbf2302ea8..d42690bea066001ca060082a2721cf5244ca3c4b 100644 (file)
@@ -110,14 +110,12 @@ static IIO_DEVICE_ATTR(temp_raw, S_IRUGO, adis16080_read, NULL,
                       ADIS16080_DIN_TEMP);
 static IIO_DEV_ATTR_IN_RAW(0, adis16080_read, ADIS16080_DIN_AIN1);
 static IIO_DEV_ATTR_IN_RAW(1, adis16080_read, ADIS16080_DIN_AIN2);
-static IIO_CONST_ATTR(name, "adis16080");
 
 static struct attribute *adis16080_attributes[] = {
        &iio_dev_attr_gyro_z_raw.dev_attr.attr,
        &iio_dev_attr_temp_raw.dev_attr.attr,
        &iio_dev_attr_in0_raw.dev_attr.attr,
        &iio_dev_attr_in1_raw.dev_attr.attr,
-       &iio_const_attr_name.dev_attr.attr,
        NULL
 };
 
@@ -125,6 +123,11 @@ static const struct attribute_group adis16080_attribute_group = {
        .attrs = adis16080_attributes,
 };
 
+static const struct iio_info adis16080_info = {
+       .attrs = &adis16080_attribute_group,
+       .driver_module = THIS_MODULE,
+};
+
 static int __devinit adis16080_probe(struct spi_device *spi)
 {
        int ret, regdone = 0;
@@ -140,16 +143,16 @@ static int __devinit adis16080_probe(struct spi_device *spi)
        st->us = spi;
        mutex_init(&st->buf_lock);
        /* setup the industrialio driver allocated elements */
-       st->indio_dev = iio_allocate_device();
+       st->indio_dev = iio_allocate_device(0);
        if (st->indio_dev == NULL) {
                ret = -ENOMEM;
                goto error_free_st;
        }
 
+       st->indio_dev->name = spi->dev.driver->name;
        st->indio_dev->dev.parent = &spi->dev;
-       st->indio_dev->attrs = &adis16080_attribute_group;
+       st->indio_dev->info = &adis16080_info;
        st->indio_dev->dev_data = (void *)(st);
-       st->indio_dev->driver_module = THIS_MODULE;
        st->indio_dev->modes = INDIO_DIRECT_MODE;
 
        ret = iio_device_register(st->indio_dev);
index 70e2831f8fb84e4a776aa6bc5fdd26ab47154626..14d5a34ab441ed95ab6cd5ff8b874e21050de3cb 100644 (file)
@@ -155,8 +155,6 @@ static ssize_t adis16130_bitsmode_write(struct device *dev,
 static IIO_DEVICE_ATTR(temp_raw, S_IRUGO, adis16130_val_read, NULL,
                      ADIS16130_TEMPDATA);
 
-static IIO_CONST_ATTR(name, "adis16130");
-
 static IIO_DEV_ATTR_GYRO_Z(adis16130_val_read, ADIS16130_RATEDATA);
 
 static IIO_DEVICE_ATTR(gyro_z_type, S_IWUSR | S_IRUGO, adis16130_bitsmode_read,
@@ -167,7 +165,6 @@ static IIO_CONST_ATTR(gyro_z_type_available, "s16 s24");
 
 static struct attribute *adis16130_attributes[] = {
        &iio_dev_attr_temp_raw.dev_attr.attr,
-       &iio_const_attr_name.dev_attr.attr,
        &iio_dev_attr_gyro_z_raw.dev_attr.attr,
        &iio_dev_attr_gyro_z_type.dev_attr.attr,
        &iio_const_attr_gyro_z_type_available.dev_attr.attr,
@@ -178,6 +175,11 @@ static const struct attribute_group adis16130_attribute_group = {
        .attrs = adis16130_attributes,
 };
 
+static const struct iio_info adis16130_info = {
+       .attrs = &adis16130_attribute_group,
+       .driver_module = THIS_MODULE,
+};
+
 static int __devinit adis16130_probe(struct spi_device *spi)
 {
        int ret;
@@ -191,16 +193,16 @@ static int __devinit adis16130_probe(struct spi_device *spi)
        st->us = spi;
        mutex_init(&st->buf_lock);
        /* setup the industrialio driver allocated elements */
-       st->indio_dev = iio_allocate_device();
+       st->indio_dev = iio_allocate_device(0);
        if (st->indio_dev == NULL) {
                ret = -ENOMEM;
                goto error_free_st;
        }
 
+       st->indio_dev->name = spi->dev.driver->name;
        st->indio_dev->dev.parent = &spi->dev;
-       st->indio_dev->attrs = &adis16130_attribute_group;
+       st->indio_dev->info = &adis16130_info;
        st->indio_dev->dev_data = (void *)(st);
-       st->indio_dev->driver_module = THIS_MODULE;
        st->indio_dev->modes = INDIO_DIRECT_MODE;
        st->mode = 1;
 
index 1369501b40960ce0311370003dc669fbf807a644..702dc982f62f9e25cc351ca88688f08f3a1fbd42 100644 (file)
@@ -85,9 +85,6 @@
 /**
  * struct adis16260_state - device instance specific data
  * @us:                        actual spi_device
- * @work_trigger_to_ring: bh for triggered event handling
- * @inter:             used to check if new interrupt has been triggered
- * @last_timestamp:    passing timestamp from th to bh of interrupt handler
  * @indio_dev:         industrial I/O device structure
  * @trig:              data ready trigger registered with iio
  * @tx:                        transmit buffer
@@ -97,8 +94,6 @@
  **/
 struct adis16260_state {
        struct spi_device               *us;
-       struct work_struct              work_trigger_to_ring;
-       s64                             last_timestamp;
        struct iio_dev                  *indio_dev;
        struct iio_trigger              *trig;
        u8                              *tx;
@@ -107,7 +102,7 @@ struct adis16260_state {
        unsigned                        negate:1;
 };
 
-int adis16260_set_irq(struct device *dev, bool enable);
+int adis16260_set_irq(struct iio_dev *indio_dev, bool enable);
 
 #ifdef CONFIG_IIO_RING_BUFFER
 /* At the moment triggers are only used for ring buffer
index 69a29ec93101f5aff9075364b4780606b10848db..3dc9a272749d333850d5e2d1ae6e38bbeb82cc41 100644 (file)
 
 #define DRIVER_NAME            "adis16260"
 
-static int adis16260_check_status(struct device *dev);
+static int adis16260_check_status(struct iio_dev *indio_dev);
 
 /**
  * adis16260_spi_write_reg_8() - write single byte to a register
- * @dev: device associated with child of actual device (iio_dev or iio_trig)
+ * @indio_dev: iio_dev for the device
  * @reg_address: the address of the register to be written
  * @val: the value to write
  **/
-static int adis16260_spi_write_reg_8(struct device *dev,
+static int adis16260_spi_write_reg_8(struct iio_dev *indio_dev,
                u8 reg_address,
                u8 val)
 {
        int ret;
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
        struct adis16260_state *st = iio_dev_get_devdata(indio_dev);
 
        mutex_lock(&st->buf_lock);
@@ -56,18 +55,17 @@ static int adis16260_spi_write_reg_8(struct device *dev,
 
 /**
  * adis16260_spi_write_reg_16() - write 2 bytes to a pair of registers
- * @dev: device associated with child of actual device (iio_dev or iio_trig)
+ * @indio_dev: iio_dev for the device
  * @reg_address: the address of the lower of the two registers. Second register
  *               is assumed to have address one greater.
  * @val: value to be written
  **/
-static int adis16260_spi_write_reg_16(struct device *dev,
+static int adis16260_spi_write_reg_16(struct iio_dev *indio_dev,
                u8 lower_reg_address,
                u16 value)
 {
        int ret;
        struct spi_message msg;
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
        struct adis16260_state *st = iio_dev_get_devdata(indio_dev);
        struct spi_transfer xfers[] = {
                {
@@ -80,7 +78,6 @@ static int adis16260_spi_write_reg_16(struct device *dev,
                        .tx_buf = st->tx + 2,
                        .bits_per_word = 8,
                        .len = 2,
-                       .cs_change = 1,
                        .delay_usecs = 20,
                },
        };
@@ -102,17 +99,16 @@ static int adis16260_spi_write_reg_16(struct device *dev,
 
 /**
  * adis16260_spi_read_reg_16() - read 2 bytes from a 16-bit register
- * @dev: device associated with child of actual device (iio_dev or iio_trig)
+ * @indio_dev: iio_dev for the device
  * @reg_address: the address of the lower of the two registers. Second register
  *               is assumed to have address one greater.
  * @val: somewhere to pass back the value read
  **/
-static int adis16260_spi_read_reg_16(struct device *dev,
+static int adis16260_spi_read_reg_16(struct iio_dev *indio_dev,
                u8 lower_reg_address,
                u16 *val)
 {
        struct spi_message msg;
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
        struct adis16260_state *st = iio_dev_get_devdata(indio_dev);
        int ret;
        struct spi_transfer xfers[] = {
@@ -126,7 +122,6 @@ static int adis16260_spi_read_reg_16(struct device *dev,
                        .rx_buf = st->rx,
                        .bits_per_word = 8,
                        .len = 2,
-                       .cs_change = 1,
                        .delay_usecs = 30,
                },
        };
@@ -152,92 +147,6 @@ error_ret:
        return ret;
 }
 
-static ssize_t adis16260_spi_read_signed(struct device *dev,
-               struct device_attribute *attr,
-               char *buf,
-               unsigned bits)
-{
-       int ret;
-       s16 val = 0;
-       unsigned shift = 16 - bits;
-       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-
-       ret = adis16260_spi_read_reg_16(dev, this_attr->address, (u16 *)&val);
-       if (ret)
-               return ret;
-
-       if (val & ADIS16260_ERROR_ACTIVE)
-               adis16260_check_status(dev);
-       val = ((s16)(val << shift) >> shift);
-       return sprintf(buf, "%d\n", val);
-}
-
-static ssize_t adis16260_read_12bit_unsigned(struct device *dev,
-               struct device_attribute *attr,
-               char *buf)
-{
-       int ret;
-       u16 val = 0;
-       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-
-       ret = adis16260_spi_read_reg_16(dev, this_attr->address, &val);
-       if (ret)
-               return ret;
-
-       if (val & ADIS16260_ERROR_ACTIVE)
-               adis16260_check_status(dev);
-
-       return sprintf(buf, "%u\n", val & 0x0FFF);
-}
-
-static ssize_t adis16260_read_12bit_signed(struct device *dev,
-               struct device_attribute *attr,
-               char *buf)
-{
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
-       ssize_t ret;
-
-       /* Take the iio_dev status lock */
-       mutex_lock(&indio_dev->mlock);
-       ret =  adis16260_spi_read_signed(dev, attr, buf, 12);
-       mutex_unlock(&indio_dev->mlock);
-
-       return ret;
-}
-
-static ssize_t adis16260_read_14bit_signed(struct device *dev,
-               struct device_attribute *attr,
-               char *buf)
-{
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
-       ssize_t ret;
-
-       /* Take the iio_dev status lock */
-       mutex_lock(&indio_dev->mlock);
-       ret =  adis16260_spi_read_signed(dev, attr, buf, 14);
-       mutex_unlock(&indio_dev->mlock);
-
-       return ret;
-}
-
-static ssize_t adis16260_write_16bit(struct device *dev,
-               struct device_attribute *attr,
-               const char *buf,
-               size_t len)
-{
-       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-       int ret;
-       long val;
-
-       ret = strict_strtol(buf, 10, &val);
-       if (ret)
-               goto error_ret;
-       ret = adis16260_spi_write_reg_16(dev, this_attr->address, val);
-
-error_ret:
-       return ret ? ret : len;
-}
-
 static ssize_t adis16260_read_frequency_available(struct device *dev,
                                                  struct device_attribute *attr,
                                                  char *buf)
@@ -259,7 +168,7 @@ static ssize_t adis16260_read_frequency(struct device *dev,
        int ret, len = 0;
        u16 t;
        int sps;
-       ret = adis16260_spi_read_reg_16(dev,
+       ret = adis16260_spi_read_reg_16(indio_dev,
                        ADIS16260_SMPL_PRD,
                        &t);
        if (ret)
@@ -305,7 +214,7 @@ static ssize_t adis16260_write_frequency(struct device *dev,
                st->us->max_speed_hz = ADIS16260_SPI_SLOW;
        else
                st->us->max_speed_hz = ADIS16260_SPI_FAST;
-       ret = adis16260_spi_write_reg_8(dev,
+       ret = adis16260_spi_write_reg_8(indio_dev,
                        ADIS16260_SMPL_PRD,
                        t);
 
@@ -314,33 +223,14 @@ static ssize_t adis16260_write_frequency(struct device *dev,
        return ret ? ret : len;
 }
 
-static ssize_t adis16260_read_gyro_scale(struct device *dev,
-               struct device_attribute *attr,
-               char *buf)
-{
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
-       struct adis16260_state *st = iio_dev_get_devdata(indio_dev);
-       ssize_t ret = 0;
-
-       if (st->negate)
-               ret = sprintf(buf, "-");
-       /* Take the iio_dev status lock */
-       if (spi_get_device_id(st->us)->driver_data)
-               ret += sprintf(buf + ret, "%s\n", "0.00031974432");
-       else
-               ret += sprintf(buf + ret, "%s\n", "0.00127862821");
-
-       return ret;
-}
-
-static int adis16260_reset(struct device *dev)
+static int adis16260_reset(struct iio_dev *indio_dev)
 {
        int ret;
-       ret = adis16260_spi_write_reg_8(dev,
+       ret = adis16260_spi_write_reg_8(indio_dev,
                        ADIS16260_GLOB_CMD,
                        ADIS16260_GLOB_CMD_SW_RESET);
        if (ret)
-               dev_err(dev, "problem resetting device");
+               dev_err(&indio_dev->dev, "problem resetting device");
 
        return ret;
 }
@@ -349,22 +239,23 @@ static ssize_t adis16260_write_reset(struct device *dev,
                struct device_attribute *attr,
                const char *buf, size_t len)
 {
+       struct iio_dev *indio_dev = dev_get_drvdata(dev);
        if (len < 1)
                return -EINVAL;
        switch (buf[0]) {
        case '1':
        case 'y':
        case 'Y':
-               return adis16260_reset(dev);
+               return adis16260_reset(indio_dev);
        }
        return -EINVAL;
 }
 
-int adis16260_set_irq(struct device *dev, bool enable)
+int adis16260_set_irq(struct iio_dev *indio_dev, bool enable)
 {
        int ret;
        u16 msc;
-       ret = adis16260_spi_read_reg_16(dev, ADIS16260_MSC_CTRL, &msc);
+       ret = adis16260_spi_read_reg_16(indio_dev, ADIS16260_MSC_CTRL, &msc);
        if (ret)
                goto error_ret;
 
@@ -374,7 +265,7 @@ int adis16260_set_irq(struct device *dev, bool enable)
        else
                msc &= ~ADIS16260_MSC_CTRL_DATA_RDY_EN;
 
-       ret = adis16260_spi_write_reg_16(dev, ADIS16260_MSC_CTRL, msc);
+       ret = adis16260_spi_write_reg_16(indio_dev, ADIS16260_MSC_CTRL, msc);
        if (ret)
                goto error_ret;
 
@@ -383,41 +274,44 @@ error_ret:
 }
 
 /* Power down the device */
-static int adis16260_stop_device(struct device *dev)
+static int adis16260_stop_device(struct iio_dev *indio_dev)
 {
        int ret;
        u16 val = ADIS16260_SLP_CNT_POWER_OFF;
 
-       ret = adis16260_spi_write_reg_16(dev, ADIS16260_SLP_CNT, val);
+       ret = adis16260_spi_write_reg_16(indio_dev, ADIS16260_SLP_CNT, val);
        if (ret)
-               dev_err(dev, "problem with turning device off: SLP_CNT");
+               dev_err(&indio_dev->dev, "problem with turning device off: SLP_CNT");
 
        return ret;
 }
 
-static int adis16260_self_test(struct device *dev)
+static int adis16260_self_test(struct iio_dev *indio_dev)
 {
        int ret;
-       ret = adis16260_spi_write_reg_16(dev,
+       ret = adis16260_spi_write_reg_16(indio_dev,
                        ADIS16260_MSC_CTRL,
                        ADIS16260_MSC_CTRL_MEM_TEST);
        if (ret) {
-               dev_err(dev, "problem starting self test");
+               dev_err(&indio_dev->dev, "problem starting self test");
                goto err_ret;
        }
 
-       adis16260_check_status(dev);
+       adis16260_check_status(indio_dev);
 
 err_ret:
        return ret;
 }
 
-static int adis16260_check_status(struct device *dev)
+static int adis16260_check_status(struct iio_dev *indio_dev)
 {
        u16 status;
        int ret;
+       struct device *dev = &indio_dev->dev;
 
-       ret = adis16260_spi_read_reg_16(dev, ADIS16260_DIAG_STAT, &status);
+       ret = adis16260_spi_read_reg_16(indio_dev,
+                                       ADIS16260_DIAG_STAT,
+                                       &status);
 
        if (ret < 0) {
                dev_err(dev, "Reading status failed\n");
@@ -443,130 +337,240 @@ error_ret:
        return ret;
 }
 
-static int adis16260_initial_setup(struct adis16260_state *st)
+static int adis16260_initial_setup(struct iio_dev *indio_dev)
 {
        int ret;
-       struct device *dev = &st->indio_dev->dev;
+       struct device *dev = &indio_dev->dev;
 
        /* Disable IRQ */
-       ret = adis16260_set_irq(dev, false);
+       ret = adis16260_set_irq(indio_dev, false);
        if (ret) {
                dev_err(dev, "disable irq failed");
                goto err_ret;
        }
 
        /* Do self test */
-       ret = adis16260_self_test(dev);
+       ret = adis16260_self_test(indio_dev);
        if (ret) {
                dev_err(dev, "self test failure");
                goto err_ret;
        }
 
        /* Read status register to check the result */
-       ret = adis16260_check_status(dev);
+       ret = adis16260_check_status(indio_dev);
        if (ret) {
-               adis16260_reset(dev);
+               adis16260_reset(indio_dev);
                dev_err(dev, "device not playing ball -> reset");
                msleep(ADIS16260_STARTUP_DELAY);
-               ret = adis16260_check_status(dev);
+               ret = adis16260_check_status(indio_dev);
                if (ret) {
                        dev_err(dev, "giving up");
                        goto err_ret;
                }
        }
 
-       printk(KERN_INFO DRIVER_NAME ": at CS%d (irq %d)\n",
-                       st->us->chip_select, st->us->irq);
-
 err_ret:
        return ret;
 }
 
-static IIO_DEV_ATTR_IN_NAMED_RAW(0, supply,
-                               adis16260_read_12bit_unsigned,
-                               ADIS16260_SUPPLY_OUT);
-static IIO_CONST_ATTR_IN_NAMED_SCALE(0, supply, "0.0018315");
-
-static IIO_DEV_ATTR_TEMP_RAW(adis16260_read_12bit_unsigned);
-static IIO_CONST_ATTR_TEMP_OFFSET("25");
-static IIO_CONST_ATTR_TEMP_SCALE("0.1453");
-
-static IIO_DEV_ATTR_IN_RAW(1, adis16260_read_12bit_unsigned,
-               ADIS16260_AUX_ADC);
-static IIO_CONST_ATTR(in1_scale, "0.0006105");
-
 static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO,
                adis16260_read_frequency,
                adis16260_write_frequency);
 
 static IIO_DEVICE_ATTR(reset, S_IWUSR, NULL, adis16260_write_reset, 0);
 
-
 static IIO_DEVICE_ATTR(sampling_frequency_available,
                       S_IRUGO, adis16260_read_frequency_available, NULL, 0);
 
-static IIO_CONST_ATTR_NAME("adis16260");
+enum adis16260_channel {
+       gyro,
+       temp,
+       in_supply,
+       in_aux,
+       angle,
+};
+#define ADIS16260_GYRO_CHANNEL_SET(axis, mod)                          \
+       struct iio_chan_spec adis16260_channels_##axis[] = {            \
+               IIO_CHAN(IIO_GYRO, 1, 0, 0, NULL, 0, mod,               \
+                        (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) |      \
+                        (1 << IIO_CHAN_INFO_CALIBSCALE_SEPARATE) |     \
+                        (1 << IIO_CHAN_INFO_SCALE_SEPARATE),           \
+                        gyro, ADIS16260_SCAN_GYRO,                     \
+                        IIO_ST('s', 14, 16, 0), 0),                    \
+               IIO_CHAN(IIO_ANGL, 1, 0, 0, NULL, 0, mod,               \
+                        0,                                             \
+                        angle, ADIS16260_SCAN_ANGL,                    \
+                        IIO_ST('u', 14, 16, 0), 0),                    \
+               IIO_CHAN(IIO_TEMP, 0, 1, 0, NULL, 0, 0,                 \
+                        (1 << IIO_CHAN_INFO_OFFSET_SEPARATE) |         \
+                        (1 << IIO_CHAN_INFO_SCALE_SEPARATE),           \
+                        temp, ADIS16260_SCAN_TEMP,                     \
+                        IIO_ST('u', 12, 16, 0), 0),                    \
+               IIO_CHAN(IIO_IN, 0, 1, 0, "supply", 0, 0,               \
+                        (1 << IIO_CHAN_INFO_SCALE_SEPARATE),           \
+                        in_supply, ADIS16260_SCAN_SUPPLY,              \
+                        IIO_ST('u', 12, 16, 0), 0),                    \
+               IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 1, 0,                   \
+                        (1 << IIO_CHAN_INFO_SCALE_SEPARATE),           \
+                        in_aux, ADIS16260_SCAN_AUX_ADC,                \
+                        IIO_ST('u', 12, 16, 0), 0),                    \
+               IIO_CHAN_SOFT_TIMESTAMP(5)                              \
+       }
 
-static struct attribute *adis16260_event_attributes[] = {
-       NULL
+static const ADIS16260_GYRO_CHANNEL_SET(x, IIO_MOD_X);
+static const ADIS16260_GYRO_CHANNEL_SET(y, IIO_MOD_Y);
+static const ADIS16260_GYRO_CHANNEL_SET(z, IIO_MOD_Z);
+
+static const u8 adis16260_addresses[5][3] = {
+       [gyro] = { ADIS16260_GYRO_OUT,
+                  ADIS16260_GYRO_OFF,
+                  ADIS16260_GYRO_SCALE },
+       [angle] = { ADIS16260_ANGL_OUT },
+       [in_supply] = { ADIS16260_SUPPLY_OUT },
+       [in_aux] = { ADIS16260_AUX_ADC },
+       [temp] = { ADIS16260_TEMP_OUT },
 };
+static int adis16260_read_raw(struct iio_dev *indio_dev,
+                             struct iio_chan_spec const *chan,
+                             int *val, int *val2,
+                             long mask)
+{
+       struct adis16260_state *st = iio_dev_get_devdata(indio_dev);
+       int ret;
+       int bits;
+       u8 addr;
+       s16 val16;
+
+       switch (mask) {
+       case 0:
+               mutex_lock(&indio_dev->mlock);
+               addr = adis16260_addresses[chan->address][0];
+               ret = adis16260_spi_read_reg_16(indio_dev, addr, &val16);
+               if (ret)
+                       return ret;
 
-static struct attribute_group adis16260_event_attribute_group = {
-       .attrs = adis16260_event_attributes,
+               if (val16 & ADIS16260_ERROR_ACTIVE) {
+                       ret = adis16260_check_status(indio_dev);
+                       if (ret)
+                               return ret;
+               }
+               val16 = val16 & ((1 << chan->scan_type.realbits) - 1);
+               if (chan->scan_type.sign == 's')
+                       val16 = (s16)(val16 <<
+                                     (16 - chan->scan_type.realbits)) >>
+                               (16 - chan->scan_type.realbits);
+               *val = val16;
+               mutex_unlock(&indio_dev->mlock);
+               return IIO_VAL_INT;
+       case (1 << IIO_CHAN_INFO_SCALE_SEPARATE):
+       case (1 << IIO_CHAN_INFO_SCALE_SHARED):
+               switch (chan->type) {
+               case IIO_GYRO:
+                       *val = 0;
+                       if (spi_get_device_id(st->us)->driver_data)
+                               *val2 = 320;
+                       else
+                               *val2 = 1278;
+                       return IIO_VAL_INT_PLUS_MICRO;
+               case IIO_IN:
+                       *val = 0;
+                       if (chan->channel == 0)
+                               *val2 = 18315;
+                       else
+                               *val2 = 610500;
+                       return IIO_VAL_INT_PLUS_MICRO;
+               case IIO_TEMP:
+                       *val = 0;
+                       *val2 = 145300;
+                       return IIO_VAL_INT_PLUS_MICRO;
+               default:
+                       return -EINVAL;
+               }
+               break;
+       case (1 << IIO_CHAN_INFO_OFFSET_SEPARATE):
+               *val = 25;
+               return IIO_VAL_INT;
+       case (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE):
+               switch (chan->type) {
+               case IIO_GYRO:
+                       bits = 12;
+                       break;
+               default:
+                       return -EINVAL;
+               };
+               mutex_lock(&indio_dev->mlock);
+               addr = adis16260_addresses[chan->address][1];
+               ret = adis16260_spi_read_reg_16(indio_dev, addr, &val16);
+               if (ret) {
+                       mutex_unlock(&indio_dev->mlock);
+                       return ret;
+               }
+               val16 &= (1 << bits) - 1;
+               val16 = (s16)(val16 << (16 - bits)) >> (16 - bits);
+               *val = val16;
+               mutex_unlock(&indio_dev->mlock);
+               return IIO_VAL_INT;
+       case (1 << IIO_CHAN_INFO_CALIBSCALE_SEPARATE):
+               switch (chan->type) {
+               case IIO_GYRO:
+                       bits = 12;
+                       break;
+               default:
+                       return -EINVAL;
+               };
+               mutex_lock(&indio_dev->mlock);
+               addr = adis16260_addresses[chan->address][2];
+               ret = adis16260_spi_read_reg_16(indio_dev, addr, &val16);
+               if (ret) {
+                       mutex_unlock(&indio_dev->mlock);
+                       return ret;
+               }
+               *val = (1 << bits) - 1;
+               mutex_unlock(&indio_dev->mlock);
+               return IIO_VAL_INT;
+       }
+       return -EINVAL;
+}
+
+static int adis16260_write_raw(struct iio_dev *indio_dev,
+                              struct iio_chan_spec const *chan,
+                              int val,
+                              int val2,
+                              long mask)
+{
+       int bits = 12;
+       s16 val16;
+       u8 addr;
+       switch (mask) {
+       case (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE):
+               val16 = val & ((1 << bits) - 1);
+               addr = adis16260_addresses[chan->address][1];
+               return adis16260_spi_write_reg_16(indio_dev, addr, val16);
+       case (1 << IIO_CHAN_INFO_CALIBSCALE_SEPARATE):
+               val16 = val & ((1 << bits) - 1);
+               addr = adis16260_addresses[chan->address][2];
+               return adis16260_spi_write_reg_16(indio_dev, addr, val16);
+       }
+       return -EINVAL;
+}
+
+static struct attribute *adis16260_attributes[] = {
+       &iio_dev_attr_sampling_frequency.dev_attr.attr,
+       &iio_dev_attr_sampling_frequency_available.dev_attr.attr,
+       &iio_dev_attr_reset.dev_attr.attr,
+       NULL
 };
 
-#define ADIS16260_GYRO_ATTR_SET(axis)                                  \
-       IIO_DEV_ATTR_GYRO##axis(adis16260_read_14bit_signed,            \
-                               ADIS16260_GYRO_OUT);                    \
-       static IIO_DEV_ATTR_GYRO##axis##_SCALE(S_IRUGO,                 \
-                                       adis16260_read_gyro_scale,      \
-                                       NULL,                           \
-                                       0);                             \
-       static IIO_DEV_ATTR_GYRO##axis##_CALIBSCALE(S_IRUGO | S_IWUSR,  \
-                                       adis16260_read_12bit_unsigned,  \
-                                       adis16260_write_16bit,          \
-                                       ADIS16260_GYRO_SCALE);          \
-       static IIO_DEV_ATTR_GYRO##axis##_CALIBBIAS(S_IWUSR | S_IRUGO,   \
-                                       adis16260_read_12bit_signed,    \
-                                       adis16260_write_16bit,          \
-                                       ADIS16260_GYRO_OFF);            \
-       static IIO_DEV_ATTR_ANGL##axis(adis16260_read_14bit_signed,     \
-                                      ADIS16260_ANGL_OUT);
-
-static ADIS16260_GYRO_ATTR_SET();
-static ADIS16260_GYRO_ATTR_SET(_X);
-static ADIS16260_GYRO_ATTR_SET(_Y);
-static ADIS16260_GYRO_ATTR_SET(_Z);
-
-#define ADIS16260_ATTR_GROUP(axis)                                     \
-       struct attribute *adis16260_attributes##axis[] = {              \
-               &iio_dev_attr_in0_supply_raw.dev_attr.attr,             \
-               &iio_const_attr_in0_supply_scale.dev_attr.attr,         \
-               &iio_dev_attr_gyro##axis##_raw.dev_attr.attr,           \
-               &iio_dev_attr_gyro##axis##_scale.dev_attr.attr,         \
-               &iio_dev_attr_gyro##axis##_calibscale.dev_attr.attr,    \
-               &iio_dev_attr_gyro##axis##_calibbias.dev_attr.attr,     \
-               &iio_dev_attr_angl##axis##_raw.dev_attr.attr,           \
-               &iio_dev_attr_temp_raw.dev_attr.attr,                   \
-               &iio_const_attr_temp_offset.dev_attr.attr,              \
-               &iio_const_attr_temp_scale.dev_attr.attr,               \
-               &iio_dev_attr_in1_raw.dev_attr.attr,                    \
-               &iio_const_attr_in1_scale.dev_attr.attr,                \
-               &iio_dev_attr_sampling_frequency.dev_attr.attr,         \
-               &iio_dev_attr_sampling_frequency_available.dev_attr.attr, \
-               &iio_dev_attr_reset.dev_attr.attr,                      \
-               &iio_const_attr_name.dev_attr.attr,                     \
-               NULL                                                    \
-       };                                                              \
-       static const struct attribute_group adis16260_attribute_group##axis \
-       = {                                                             \
-               .attrs = adis16260_attributes##axis,                    \
-       };
+static const struct attribute_group adis16260_attribute_group = {
+       .attrs = adis16260_attributes,
+};
 
-static ADIS16260_ATTR_GROUP();
-static ADIS16260_ATTR_GROUP(_x);
-static ADIS16260_ATTR_GROUP(_y);
-static ADIS16260_ATTR_GROUP(_z);
+static const struct iio_info adis16260_info = {
+       .attrs = &adis16260_attribute_group,
+       .read_raw = &adis16260_read_raw,
+       .write_raw = &adis16260_write_raw,
+       .driver_module = THIS_MODULE,
+};
 
 static int __devinit adis16260_probe(struct spi_device *spi)
 {
@@ -596,35 +600,35 @@ static int __devinit adis16260_probe(struct spi_device *spi)
        st->us = spi;
        mutex_init(&st->buf_lock);
        /* setup the industrialio driver allocated elements */
-       st->indio_dev = iio_allocate_device();
+       st->indio_dev = iio_allocate_device(0);
        if (st->indio_dev == NULL) {
                ret = -ENOMEM;
                goto error_free_tx;
        }
 
+       st->indio_dev->name = spi_get_device_id(st->us)->name;
        st->indio_dev->dev.parent = &spi->dev;
-       st->indio_dev->num_interrupt_lines = 1;
-       st->indio_dev->event_attrs = &adis16260_event_attribute_group;
+       st->indio_dev->info = &adis16260_info;
+       st->indio_dev->num_channels
+               = ARRAY_SIZE(adis16260_channels_x);
        if (pd && pd->direction)
                switch (pd->direction) {
                case 'x':
-                       st->indio_dev->attrs = &adis16260_attribute_group_x;
+                       st->indio_dev->channels = adis16260_channels_x;
                        break;
                case 'y':
-                       st->indio_dev->attrs = &adis16260_attribute_group_y;
+                       st->indio_dev->channels = adis16260_channels_y;
                        break;
                case 'z':
-                       st->indio_dev->attrs = &adis16260_attribute_group_z;
+                       st->indio_dev->channels = adis16260_channels_z;
                        break;
                default:
-                       st->indio_dev->attrs = &adis16260_attribute_group;
-                       break;
+                       return -EINVAL;
                }
        else
-               st->indio_dev->attrs = &adis16260_attribute_group;
+               st->indio_dev->channels = adis16260_channels_x;
 
        st->indio_dev->dev_data = (void *)(st);
-       st->indio_dev->driver_module = THIS_MODULE;
        st->indio_dev->modes = INDIO_DIRECT_MODE;
 
        ret = adis16260_configure_ring(st->indio_dev);
@@ -635,37 +639,28 @@ static int __devinit adis16260_probe(struct spi_device *spi)
        if (ret)
                goto error_unreg_ring_funcs;
        regdone = 1;
-       ret = iio_ring_buffer_register(st->indio_dev->ring, 0);
+       ret = iio_ring_buffer_register_ex(st->indio_dev->ring, 0,
+                                         st->indio_dev->channels,
+                                         ARRAY_SIZE(adis16260_channels_x));
        if (ret) {
                printk(KERN_ERR "failed to initialize the ring\n");
                goto error_unreg_ring_funcs;
        }
 
        if (spi->irq) {
-               ret = iio_register_interrupt_line(spi->irq,
-                               st->indio_dev,
-                               0,
-                               IRQF_TRIGGER_RISING,
-                               "adis16260");
-               if (ret)
-                       goto error_uninitialize_ring;
-
                ret = adis16260_probe_trigger(st->indio_dev);
                if (ret)
-                       goto error_unregister_line;
+                       goto error_uninitialize_ring;
        }
 
        /* Get the device into a sane initial state */
-       ret = adis16260_initial_setup(st);
+       ret = adis16260_initial_setup(st->indio_dev);
        if (ret)
                goto error_remove_trigger;
        return 0;
 
 error_remove_trigger:
        adis16260_remove_trigger(st->indio_dev);
-error_unregister_line:
-       if (spi->irq)
-               iio_unregister_interrupt_line(st->indio_dev, 0);
 error_uninitialize_ring:
        iio_ring_buffer_unregister(st->indio_dev->ring);
 error_unreg_ring_funcs:
@@ -691,15 +686,13 @@ static int adis16260_remove(struct spi_device *spi)
        struct adis16260_state *st = spi_get_drvdata(spi);
        struct iio_dev *indio_dev = st->indio_dev;
 
-       ret = adis16260_stop_device(&(indio_dev->dev));
+       ret = adis16260_stop_device(indio_dev);
        if (ret)
                goto err_ret;
 
        flush_scheduled_work();
 
        adis16260_remove_trigger(indio_dev);
-       if (spi->irq)
-               iio_unregister_interrupt_line(indio_dev, 0);
 
        iio_ring_buffer_unregister(st->indio_dev->ring);
        iio_device_unregister(indio_dev);
index 23428894b1ee745f74d64bcf4f51e6db98dc381d..a0925044eaa5612282330256e1138645173277be 100644 (file)
 #include "../trigger.h"
 #include "adis16260.h"
 
-static IIO_SCAN_EL_C(in_supply, ADIS16260_SCAN_SUPPLY,
-               ADIS16260_SUPPLY_OUT, NULL);
-static IIO_CONST_ATTR_SCAN_EL_TYPE(in_supply, u, 12, 16);
-static IIO_SCAN_EL_C(gyro, ADIS16260_SCAN_GYRO, ADIS16260_GYRO_OUT, NULL);
-static IIO_CONST_ATTR_SCAN_EL_TYPE(gyro, s, 14, 16);
-static IIO_SCAN_EL_C(in0, ADIS16260_SCAN_AUX_ADC, ADIS16260_AUX_ADC, NULL);
-static IIO_CONST_ATTR_SCAN_EL_TYPE(in0, u, 12, 16);
-static IIO_SCAN_EL_C(temp, ADIS16260_SCAN_TEMP, ADIS16260_TEMP_OUT, NULL);
-static IIO_CONST_ATTR_SCAN_EL_TYPE(temp, u, 12, 16);
-static IIO_SCAN_EL_C(angl, ADIS16260_SCAN_ANGL, ADIS16260_ANGL_OUT, NULL);
-static IIO_CONST_ATTR_SCAN_EL_TYPE(angl, u, 14, 16);
-static IIO_SCAN_EL_TIMESTAMP(5);
-static IIO_CONST_ATTR_SCAN_EL_TYPE(timestamp, s, 64, 64);
-
-static struct attribute *adis16260_scan_el_attrs[] = {
-       &iio_scan_el_in_supply.dev_attr.attr,
-       &iio_const_attr_in_supply_index.dev_attr.attr,
-       &iio_const_attr_in_supply_type.dev_attr.attr,
-       &iio_scan_el_gyro.dev_attr.attr,
-       &iio_const_attr_gyro_index.dev_attr.attr,
-       &iio_const_attr_gyro_type.dev_attr.attr,
-       &iio_scan_el_in0.dev_attr.attr,
-       &iio_const_attr_in0_index.dev_attr.attr,
-       &iio_const_attr_in0_type.dev_attr.attr,
-       &iio_scan_el_temp.dev_attr.attr,
-       &iio_const_attr_temp_index.dev_attr.attr,
-       &iio_const_attr_temp_type.dev_attr.attr,
-       &iio_scan_el_angl.dev_attr.attr,
-       &iio_const_attr_angl_index.dev_attr.attr,
-       &iio_const_attr_angl_type.dev_attr.attr,
-       &iio_scan_el_timestamp.dev_attr.attr,
-       &iio_const_attr_timestamp_index.dev_attr.attr,
-       &iio_const_attr_timestamp_type.dev_attr.attr,
-       NULL,
-};
-
-static struct attribute_group adis16260_scan_el_group = {
-       .attrs = adis16260_scan_el_attrs,
-       .name = "scan_elements",
-};
-
-/**
- * adis16260_poll_func_th() top half interrupt handler called by trigger
- * @private_data:      iio_dev
- **/
-static void adis16260_poll_func_th(struct iio_dev *indio_dev, s64 time)
-{
-       struct adis16260_state *st = iio_dev_get_devdata(indio_dev);
-       st->last_timestamp = time;
-       schedule_work(&st->work_trigger_to_ring);
-}
 
 /**
  * adis16260_read_ring_data() read data registers which will be placed into ring
@@ -117,56 +66,55 @@ static int adis16260_read_ring_data(struct device *dev, u8 *rx)
        return ret;
 }
 
-
-static void adis16260_trigger_bh_to_ring(struct work_struct *work_s)
+static irqreturn_t adis16260_trigger_handler(int irq, void *p)
 {
-       struct adis16260_state *st
-               = container_of(work_s, struct adis16260_state,
-                               work_trigger_to_ring);
-       struct iio_ring_buffer *ring = st->indio_dev->ring;
-
+       struct iio_poll_func *pf = p;
+       struct iio_dev *indio_dev = pf->private_data;
+       struct adis16260_state *st = iio_dev_get_devdata(indio_dev);
+       struct iio_ring_buffer *ring = indio_dev->ring;
        int i = 0;
        s16 *data;
-       size_t datasize = ring->access.get_bytes_per_datum(ring);
+       size_t datasize = ring->access->get_bytes_per_datum(ring);
 
        data = kmalloc(datasize , GFP_KERNEL);
        if (data == NULL) {
                dev_err(&st->us->dev, "memory alloc failed in ring bh");
-               return;
+               return -ENOMEM;
        }
 
-       if (ring->scan_count)
-               if (adis16260_read_ring_data(&st->indio_dev->dev, st->rx) >= 0)
-                       for (; i < ring->scan_count; i++)
-                               data[i] = be16_to_cpup(
-                                       (__be16 *)&(st->rx[i*2]));
+       if (ring->scan_count &&
+           adis16260_read_ring_data(&st->indio_dev->dev, st->rx) >= 0)
+               for (; i < ring->scan_count; i++)
+                       data[i] = be16_to_cpup((__be16 *)&(st->rx[i*2]));
 
        /* Guaranteed to be aligned with 8 byte boundary */
        if (ring->scan_timestamp)
-               *((s64 *)(data + ((i + 3)/4)*4)) = st->last_timestamp;
+               *((s64 *)(data + ((i + 3)/4)*4)) = pf->timestamp;
 
-       ring->access.store_to(ring,
-                       (u8 *)data,
-                       st->last_timestamp);
+       ring->access->store_to(ring, (u8 *)data, pf->timestamp);
 
        iio_trigger_notify_done(st->indio_dev->trig);
        kfree(data);
 
-       return;
+       return IRQ_HANDLED;
 }
 
 void adis16260_unconfigure_ring(struct iio_dev *indio_dev)
 {
-       kfree(indio_dev->pollfunc);
+       iio_dealloc_pollfunc(indio_dev->pollfunc);
        iio_sw_rb_free(indio_dev->ring);
 }
 
+static const struct iio_ring_setup_ops adis16260_ring_setup_ops = {
+       .preenable = &iio_sw_ring_preenable,
+       .postenable = &iio_triggered_ring_postenable,
+       .predisable = &iio_triggered_ring_predisable,
+};
+
 int adis16260_configure_ring(struct iio_dev *indio_dev)
 {
        int ret = 0;
-       struct adis16260_state *st = indio_dev->dev_data;
        struct iio_ring_buffer *ring;
-       INIT_WORK(&st->work_trigger_to_ring, adis16260_trigger_bh_to_ring);
 
        ring = iio_sw_rb_allocate(indio_dev);
        if (!ring) {
@@ -175,25 +123,29 @@ int adis16260_configure_ring(struct iio_dev *indio_dev)
        }
        indio_dev->ring = ring;
        /* Effectively select the ring buffer implementation */
-       iio_ring_sw_register_funcs(&ring->access);
+       ring->access = &ring_sw_access_funcs;
        ring->bpe = 2;
-       ring->scan_el_attrs = &adis16260_scan_el_group;
        ring->scan_timestamp = true;
-       ring->preenable = &iio_sw_ring_preenable;
-       ring->postenable = &iio_triggered_ring_postenable;
-       ring->predisable = &iio_triggered_ring_predisable;
+       ring->setup_ops = &adis16260_ring_setup_ops;
        ring->owner = THIS_MODULE;
 
        /* Set default scan mode */
-       iio_scan_mask_set(ring, iio_scan_el_in_supply.number);
-       iio_scan_mask_set(ring, iio_scan_el_gyro.number);
-       iio_scan_mask_set(ring, iio_scan_el_in0.number);
-       iio_scan_mask_set(ring, iio_scan_el_temp.number);
-       iio_scan_mask_set(ring, iio_scan_el_angl.number);
-
-       ret = iio_alloc_pollfunc(indio_dev, NULL, &adis16260_poll_func_th);
-       if (ret)
+       iio_scan_mask_set(ring, ADIS16260_SCAN_SUPPLY);
+       iio_scan_mask_set(ring, ADIS16260_SCAN_GYRO);
+       iio_scan_mask_set(ring, ADIS16260_SCAN_AUX_ADC);
+       iio_scan_mask_set(ring, ADIS16260_SCAN_TEMP);
+       iio_scan_mask_set(ring, ADIS16260_SCAN_ANGL);
+
+       indio_dev->pollfunc = iio_alloc_pollfunc(&iio_pollfunc_store_time,
+                                                &adis16260_trigger_handler,
+                                                IRQF_ONESHOT,
+                                                indio_dev,
+                                                "adis16260_consumer%d",
+                                                indio_dev->id);
+       if (indio_dev->pollfunc == NULL) {
+               ret = -ENOMEM;
                goto error_iio_sw_rb_free;
+       }
 
        indio_dev->modes |= INDIO_RING_TRIGGERED;
        return 0;
index 4a744c11ca6ccf131d6d61375973cc8fb237c175..4f10fb5433560c635d1dac8b120f576ea9e8b0f2 100644 (file)
 #include "../trigger.h"
 #include "adis16260.h"
 
-/**
- * adis16260_data_rdy_trig_poll() the event handler for the data rdy trig
- **/
-static int adis16260_data_rdy_trig_poll(struct iio_dev *dev_info,
-                                      int index,
-                                      s64 timestamp,
-                                      int no_test)
-{
-       struct adis16260_state *st = iio_dev_get_devdata(dev_info);
-       struct iio_trigger *trig = st->trig;
-
-       iio_trigger_poll(trig, timestamp);
-
-       return IRQ_HANDLED;
-}
-
-IIO_EVENT_SH(data_rdy_trig, &adis16260_data_rdy_trig_poll);
-
-static IIO_TRIGGER_NAME_ATTR;
-
-static struct attribute *adis16260_trigger_attrs[] = {
-       &dev_attr_name.attr,
-       NULL,
-};
-
-static const struct attribute_group adis16260_trigger_attr_group = {
-       .attrs = adis16260_trigger_attrs,
-};
-
 /**
  * adis16260_data_rdy_trigger_set_state() set datardy interrupt state
  **/
@@ -49,31 +20,9 @@ static int adis16260_data_rdy_trigger_set_state(struct iio_trigger *trig,
 {
        struct adis16260_state *st = trig->private_data;
        struct iio_dev *indio_dev = st->indio_dev;
-       int ret = 0;
 
        dev_dbg(&indio_dev->dev, "%s (%d)\n", __func__, state);
-       ret = adis16260_set_irq(&st->indio_dev->dev, state);
-       if (state == false) {
-               iio_remove_event_from_list(&iio_event_data_rdy_trig,
-                                          &indio_dev->interrupts[0]
-                                          ->ev_list);
-               flush_scheduled_work();
-       } else {
-               iio_add_event_to_list(&iio_event_data_rdy_trig,
-                                     &indio_dev->interrupts[0]->ev_list);
-       }
-       return ret;
-}
-
-/**
- * adis16260_trig_try_reen() try renabling irq for data rdy trigger
- * @trig:      the datardy trigger
- **/
-static int adis16260_trig_try_reen(struct iio_trigger *trig)
-{
-       struct adis16260_state *st = trig->private_data;
-       enable_irq(st->us->irq);
-       return 0;
+       return adis16260_set_irq(indio_dev, state);
 }
 
 int adis16260_probe_trigger(struct iio_dev *indio_dev)
@@ -81,34 +30,40 @@ int adis16260_probe_trigger(struct iio_dev *indio_dev)
        int ret;
        struct adis16260_state *st = indio_dev->dev_data;
 
-       st->trig = iio_allocate_trigger();
-       st->trig->name = kasprintf(GFP_KERNEL,
-                                  "adis16260-dev%d",
-                                  indio_dev->id);
-       if (!st->trig->name) {
+       st->trig = iio_allocate_trigger("%s-dev%d",
+                                       spi_get_device_id(st->us)->name,
+                                       indio_dev->id);
+       if (st->trig == NULL) {
                ret = -ENOMEM;
-               goto error_free_trig;
+               goto error_ret;
        }
+
+       ret = request_irq(st->us->irq,
+                         &iio_trigger_generic_data_rdy_poll,
+                         IRQF_TRIGGER_RISING,
+                         "adis16260",
+                         st->trig);
+       if (ret)
+               goto error_free_trig;
+
        st->trig->dev.parent = &st->us->dev;
        st->trig->owner = THIS_MODULE;
        st->trig->private_data = st;
        st->trig->set_trigger_state = &adis16260_data_rdy_trigger_set_state;
-       st->trig->try_reenable = &adis16260_trig_try_reen;
-       st->trig->control_attrs = &adis16260_trigger_attr_group;
        ret = iio_trigger_register(st->trig);
 
        /* select default trigger */
        indio_dev->trig = st->trig;
        if (ret)
-               goto error_free_trig_name;
+               goto error_free_irq;
 
        return 0;
 
-error_free_trig_name:
-       kfree(st->trig->name);
+error_free_irq:
+       free_irq(st->us->irq, st->trig);
 error_free_trig:
        iio_free_trigger(st->trig);
-
+error_ret:
        return ret;
 }
 
@@ -117,6 +72,6 @@ void adis16260_remove_trigger(struct iio_dev *indio_dev)
        struct adis16260_state *state = indio_dev->dev_data;
 
        iio_trigger_unregister(state->trig);
-       kfree(state->trig->name);
+       free_irq(state->us->irq, state->trig);
        iio_free_trigger(state->trig);
 }
diff --git a/drivers/staging/iio/gyro/adxrs450.h b/drivers/staging/iio/gyro/adxrs450.h
new file mode 100644 (file)
index 0000000..c92f694
--- /dev/null
@@ -0,0 +1,58 @@
+#ifndef SPI_ADXRS450_H_
+#define SPI_ADXRS450_H_
+
+#define ADXRS450_STARTUP_DELAY 50 /* ms */
+
+/* The MSB for the spi commands */
+#define ADXRS450_SENSOR_DATA    0x20
+#define ADXRS450_WRITE_DATA    0x40
+#define ADXRS450_READ_DATA     0x80
+
+#define ADXRS450_RATE1 0x00    /* Rate Registers */
+#define ADXRS450_TEMP1 0x02    /* Temperature Registers */
+#define ADXRS450_LOCST1        0x04    /* Low CST Memory Registers */
+#define ADXRS450_HICST1        0x06    /* High CST Memory Registers */
+#define ADXRS450_QUAD1 0x08    /* Quad Memory Registers */
+#define ADXRS450_FAULT1        0x0A    /* Fault Registers */
+#define ADXRS450_PID1  0x0C    /* Part ID Register 1 */
+#define ADXRS450_SNH   0x0E    /* Serial Number Registers, 4 bytes */
+#define ADXRS450_SNL   0x10
+#define ADXRS450_DNC1  0x12    /* Dynamic Null Correction Registers */
+/* Check bits */
+#define ADXRS450_P     0x01
+#define ADXRS450_CHK   0x02
+#define ADXRS450_CST   0x04
+#define ADXRS450_PWR   0x08
+#define ADXRS450_POR   0x10
+#define ADXRS450_NVM   0x20
+#define ADXRS450_Q     0x40
+#define ADXRS450_PLL   0x80
+#define ADXRS450_UV    0x100
+#define ADXRS450_OV    0x200
+#define ADXRS450_AMP   0x400
+#define ADXRS450_FAIL  0x800
+
+#define ADXRS450_WRERR_MASK    (0x7 << 29)
+
+#define ADXRS450_MAX_RX 4
+#define ADXRS450_MAX_TX 4
+
+#define ADXRS450_GET_ST(a)     ((a >> 26) & 0x3)
+
+/**
+ * struct adxrs450_state - device instance specific data
+ * @us:                        actual spi_device
+ * @indio_dev:         industrial I/O device structure
+ * @tx:                        transmit buffer
+ * @rx:                        recieve buffer
+ * @buf_lock:          mutex to protect tx and rx
+ **/
+struct adxrs450_state {
+       struct spi_device               *us;
+       struct iio_dev                  *indio_dev;
+       u8                              *tx;
+       u8                              *rx;
+       struct mutex                    buf_lock;
+};
+
+#endif /* SPI_ADXRS450_H_ */
diff --git a/drivers/staging/iio/gyro/adxrs450_core.c b/drivers/staging/iio/gyro/adxrs450_core.c
new file mode 100644 (file)
index 0000000..3714e4a
--- /dev/null
@@ -0,0 +1,455 @@
+/*
+ * ADXRS450 Digital Output Gyroscope Driver
+ *
+ * Copyright 2011 Analog Devices Inc.
+ *
+ * Licensed under the GPL-2.
+ */
+
+#include <linux/interrupt.h>
+#include <linux/irq.h>
+#include <linux/gpio.h>
+#include <linux/delay.h>
+#include <linux/mutex.h>
+#include <linux/device.h>
+#include <linux/kernel.h>
+#include <linux/spi/spi.h>
+#include <linux/slab.h>
+#include <linux/sysfs.h>
+#include <linux/list.h>
+
+#include "../iio.h"
+#include "../sysfs.h"
+#include "gyro.h"
+#include "../adc/adc.h"
+
+#include "adxrs450.h"
+
+/**
+ * adxrs450_spi_read_reg_16() - read 2 bytes from a register pair
+ * @dev: device associated with child of actual iio_dev
+ * @reg_address: the address of the lower of the two registers,which should be an even address,
+ * Second register's address is reg_address + 1.
+ * @val: somewhere to pass back the value read
+ **/
+static int adxrs450_spi_read_reg_16(struct device *dev,
+               u8 reg_address,
+               u16 *val)
+{
+       struct spi_message msg;
+       struct iio_dev *indio_dev = dev_get_drvdata(dev);
+       struct adxrs450_state *st = iio_dev_get_devdata(indio_dev);
+       int ret;
+       struct spi_transfer xfers[] = {
+               {
+                       .tx_buf = st->tx,
+                       .bits_per_word = 8,
+                       .len = 4,
+                       .cs_change = 1,
+               }, {
+                       .rx_buf = st->rx,
+                       .bits_per_word = 8,
+                       .len = 4,
+               },
+       };
+
+       mutex_lock(&st->buf_lock);
+       st->tx[0] = ADXRS450_READ_DATA | (reg_address >> 7);
+       st->tx[1] = reg_address << 1;
+       st->tx[2] = 0;
+       st->tx[3] = 0;
+
+       if (!(hweight32(be32_to_cpu(*(u32 *)st->tx)) & 1))
+               st->tx[3]  |= ADXRS450_P;
+
+       spi_message_init(&msg);
+       spi_message_add_tail(&xfers[0], &msg);
+       spi_message_add_tail(&xfers[1], &msg);
+       ret = spi_sync(st->us, &msg);
+       if (ret) {
+               dev_err(&st->us->dev, "problem while reading 16 bit register 0x%02x\n",
+                               reg_address);
+               goto error_ret;
+       }
+
+       *val = (be32_to_cpu(*(u32 *)st->rx) >> 5) & 0xFFFF;
+
+error_ret:
+       mutex_unlock(&st->buf_lock);
+       return ret;
+}
+
+/**
+ * adxrs450_spi_write_reg_16() - write 2 bytes data to a register pair
+ * @dev: device associated with child of actual actual iio_dev
+ * @reg_address: the address of the lower of the two registers,which should be an even address,
+ * Second register's address is reg_address + 1.
+ * @val: value to be written.
+ **/
+static int adxrs450_spi_write_reg_16(struct device *dev,
+               u8 reg_address,
+               u16 val)
+{
+       struct spi_message msg;
+       struct iio_dev *indio_dev = dev_get_drvdata(dev);
+       struct adxrs450_state *st = iio_dev_get_devdata(indio_dev);
+       int ret;
+       struct spi_transfer xfers = {
+               .tx_buf = st->tx,
+               .rx_buf = st->rx,
+               .bits_per_word = 8,
+               .len = 4,
+       };
+
+       mutex_lock(&st->buf_lock);
+       st->tx[0] = ADXRS450_WRITE_DATA | reg_address >> 7;
+       st->tx[1] = reg_address << 1 | val >> 15;
+       st->tx[2] = val >> 7;
+       st->tx[3] = val << 1;
+
+       if (!(hweight32(be32_to_cpu(*(u32 *)st->tx)) & 1))
+               st->tx[3]  |= ADXRS450_P;
+
+       spi_message_init(&msg);
+       spi_message_add_tail(&xfers, &msg);
+       ret = spi_sync(st->us, &msg);
+       if (ret)
+               dev_err(&st->us->dev, "problem while writing 16 bit register 0x%02x\n",
+                               reg_address);
+       msleep(1); /* enforce sequential transfer delay 0.1ms */
+       mutex_unlock(&st->buf_lock);
+       return ret;
+}
+
+/**
+ * adxrs450_spi_sensor_data() - read 2 bytes sensor data
+ * @dev: device associated with child of actual iio_dev
+ * @val: somewhere to pass back the value read
+ **/
+static int adxrs450_spi_sensor_data(struct device *dev, s16 *val)
+{
+       struct spi_message msg;
+       struct iio_dev *indio_dev = dev_get_drvdata(dev);
+       struct adxrs450_state *st = iio_dev_get_devdata(indio_dev);
+       int ret;
+       struct spi_transfer xfers[] = {
+               {
+                       .tx_buf = st->tx,
+                       .bits_per_word = 8,
+                       .len = 4,
+                       .cs_change = 1,
+               }, {
+                       .rx_buf = st->rx,
+                       .bits_per_word = 8,
+                       .len = 4,
+               },
+       };
+
+       mutex_lock(&st->buf_lock);
+       st->tx[0] = ADXRS450_SENSOR_DATA;
+       st->tx[1] = 0;
+       st->tx[2] = 0;
+       st->tx[3] = 0;
+
+       spi_message_init(&msg);
+       spi_message_add_tail(&xfers[0], &msg);
+       spi_message_add_tail(&xfers[1], &msg);
+       ret = spi_sync(st->us, &msg);
+       if (ret) {
+               dev_err(&st->us->dev, "Problem while reading sensor data\n");
+               goto error_ret;
+       }
+
+       *val = (be32_to_cpu(*(u32 *)st->rx) >> 10) & 0xFFFF;
+
+error_ret:
+       mutex_unlock(&st->buf_lock);
+       return ret;
+}
+
+/**
+ * adxrs450_spi_initial() - use for initializing procedure.
+ * @st: device instance specific data
+ * @val: somewhere to pass back the value read
+ **/
+static int adxrs450_spi_initial(struct adxrs450_state *st,
+               u32 *val, char chk)
+{
+       struct spi_message msg;
+       int ret;
+       struct spi_transfer xfers = {
+               .tx_buf = st->tx,
+               .rx_buf = st->rx,
+               .bits_per_word = 8,
+               .len = 4,
+       };
+
+       mutex_lock(&st->buf_lock);
+       st->tx[0] = ADXRS450_SENSOR_DATA;
+       st->tx[1] = 0;
+       st->tx[2] = 0;
+       st->tx[3] = 0;
+       if (chk)
+               st->tx[3] |= (ADXRS450_CHK | ADXRS450_P);
+       spi_message_init(&msg);
+       spi_message_add_tail(&xfers, &msg);
+       ret = spi_sync(st->us, &msg);
+       if (ret) {
+               dev_err(&st->us->dev, "Problem while reading initializing data\n");
+               goto error_ret;
+       }
+
+       *val = be32_to_cpu(*(u32 *)st->rx);
+
+error_ret:
+       mutex_unlock(&st->buf_lock);
+       return ret;
+}
+
+static ssize_t adxrs450_read_temp(struct device *dev,
+               struct device_attribute *attr,
+               char *buf)
+{
+       int ret;
+       u16 t;
+       ret = adxrs450_spi_read_reg_16(dev,
+                       ADXRS450_TEMP1,
+                       &t);
+       if (ret)
+               return ret;
+       return sprintf(buf, "%d\n", t >> 7);
+}
+
+static ssize_t adxrs450_read_quad(struct device *dev,
+               struct device_attribute *attr,
+               char *buf)
+{
+       int ret;
+       s16 t;
+       ret = adxrs450_spi_read_reg_16(dev,
+                       ADXRS450_QUAD1,
+                       &t);
+       if (ret)
+               return ret;
+       return sprintf(buf, "%d\n", t);
+}
+
+static ssize_t adxrs450_write_dnc(struct device *dev,
+               struct device_attribute *attr,
+               const char *buf,
+               size_t len)
+{
+       int ret;
+       long val;
+
+       ret = strict_strtol(buf, 10, &val);
+       if (ret)
+               goto error_ret;
+       ret = adxrs450_spi_write_reg_16(dev,
+                       ADXRS450_DNC1,
+                       val & 0x3FF);
+error_ret:
+       return ret ? ret : len;
+}
+
+static ssize_t adxrs450_read_sensor_data(struct device *dev,
+               struct device_attribute *attr,
+               char *buf)
+{
+       int ret;
+       s16 t;
+
+       ret = adxrs450_spi_sensor_data(dev, &t);
+       if (ret)
+               return ret;
+
+       return sprintf(buf, "%d\n", t);
+}
+
+/* Recommended Startup Sequence by spec */
+static int adxrs450_initial_setup(struct adxrs450_state *st)
+{
+       u32 t;
+       u16 data;
+       int ret;
+       struct device *dev = &st->indio_dev->dev;
+
+       msleep(ADXRS450_STARTUP_DELAY*2);
+       ret = adxrs450_spi_initial(st, &t, 1);
+       if (ret)
+               return ret;
+       if (t != 0x01)
+               dev_warn(&st->us->dev, "The initial power on response "
+                        "is not correct! Restart without reset?\n");
+
+       msleep(ADXRS450_STARTUP_DELAY);
+       ret = adxrs450_spi_initial(st, &t, 0);
+       if (ret)
+               return ret;
+
+       msleep(ADXRS450_STARTUP_DELAY);
+       ret = adxrs450_spi_initial(st, &t, 0);
+       if (ret)
+               return ret;
+       if (((t & 0xff) | 0x01) != 0xff || ADXRS450_GET_ST(t) != 2) {
+               dev_err(&st->us->dev, "The second response is not correct!\n");
+               return -EIO;
+
+       }
+       ret = adxrs450_spi_initial(st, &t, 0);
+       if (ret)
+               return ret;
+       if (((t & 0xff) | 0x01) != 0xff || ADXRS450_GET_ST(t) != 2) {
+               dev_err(&st->us->dev, "The third response is not correct!\n");
+               return -EIO;
+
+       }
+       ret = adxrs450_spi_read_reg_16(dev, ADXRS450_FAULT1, &data);
+       if (ret)
+               return ret;
+       if (data & 0x0fff) {
+               dev_err(&st->us->dev, "The device is not in normal status!\n");
+               return -EINVAL;
+       }
+       ret = adxrs450_spi_read_reg_16(dev, ADXRS450_PID1, &data);
+       if (ret)
+               return ret;
+       dev_info(&st->us->dev, "The Part ID is 0x%x\n", data);
+
+       ret = adxrs450_spi_read_reg_16(dev, ADXRS450_SNL, &data);
+       if (ret)
+               return ret;
+       t = data;
+       ret = adxrs450_spi_read_reg_16(dev, ADXRS450_SNH, &data);
+       if (ret)
+               return ret;
+       t |= data << 16;
+       dev_info(&st->us->dev, "The Serial Number is 0x%x\n", t);
+
+       return 0;
+}
+
+static IIO_DEV_ATTR_GYRO_Z(adxrs450_read_sensor_data, 0);
+static IIO_DEV_ATTR_TEMP_RAW(adxrs450_read_temp);
+static IIO_DEV_ATTR_GYRO_Z_QUADRATURE_CORRECTION(adxrs450_read_quad, 0);
+static IIO_DEV_ATTR_GYRO_Z_CALIBBIAS(S_IWUSR,
+               NULL, adxrs450_write_dnc, 0);
+static IIO_CONST_ATTR(name, "adxrs450");
+
+static struct attribute *adxrs450_attributes[] = {
+       &iio_dev_attr_gyro_z_raw.dev_attr.attr,
+       &iio_dev_attr_temp_raw.dev_attr.attr,
+       &iio_dev_attr_gyro_z_quadrature_correction_raw.dev_attr.attr,
+       &iio_dev_attr_gyro_z_calibbias.dev_attr.attr,
+       &iio_const_attr_name.dev_attr.attr,
+       NULL
+};
+
+static const struct attribute_group adxrs450_attribute_group = {
+       .attrs = adxrs450_attributes,
+};
+
+static const struct iio_info adxrs450_info = {
+       .attrs = &adxrs450_attribute_group,
+       .driver_module = THIS_MODULE,
+};
+
+static int __devinit adxrs450_probe(struct spi_device *spi)
+{
+       int ret, regdone = 0;
+       struct adxrs450_state *st = kzalloc(sizeof *st, GFP_KERNEL);
+       if (!st) {
+               ret =  -ENOMEM;
+               goto error_ret;
+       }
+       /* This is only used for removal purposes */
+       spi_set_drvdata(spi, st);
+
+       /* Allocate the comms buffers */
+       st->rx = kzalloc(sizeof(*st->rx)*ADXRS450_MAX_RX, GFP_KERNEL);
+       if (st->rx == NULL) {
+               ret = -ENOMEM;
+               goto error_free_st;
+       }
+       st->tx = kzalloc(sizeof(*st->tx)*ADXRS450_MAX_TX, GFP_KERNEL);
+       if (st->tx == NULL) {
+               ret = -ENOMEM;
+               goto error_free_rx;
+       }
+       st->us = spi;
+       mutex_init(&st->buf_lock);
+       /* setup the industrialio driver allocated elements */
+       st->indio_dev = iio_allocate_device(0);
+       if (st->indio_dev == NULL) {
+               ret = -ENOMEM;
+               goto error_free_tx;
+       }
+
+       st->indio_dev->dev.parent = &spi->dev;
+       st->indio_dev->info = &adxrs450_info;
+       st->indio_dev->dev_data = (void *)(st);
+       st->indio_dev->modes = INDIO_DIRECT_MODE;
+
+       ret = iio_device_register(st->indio_dev);
+       if (ret)
+               goto error_free_dev;
+       regdone = 1;
+
+       /* Get the device into a sane initial state */
+       ret = adxrs450_initial_setup(st);
+       if (ret)
+               goto error_initial;
+       return 0;
+
+error_initial:
+error_free_dev:
+       if (regdone)
+               iio_device_unregister(st->indio_dev);
+       else
+               iio_free_device(st->indio_dev);
+error_free_tx:
+       kfree(st->tx);
+error_free_rx:
+       kfree(st->rx);
+error_free_st:
+       kfree(st);
+error_ret:
+       return ret;
+}
+
+static int adxrs450_remove(struct spi_device *spi)
+{
+       struct adxrs450_state *st = spi_get_drvdata(spi);
+
+       iio_device_unregister(st->indio_dev);
+       kfree(st->tx);
+       kfree(st->rx);
+       kfree(st);
+
+       return 0;
+}
+
+static struct spi_driver adxrs450_driver = {
+       .driver = {
+               .name = "adxrs450",
+               .owner = THIS_MODULE,
+       },
+       .probe = adxrs450_probe,
+       .remove = __devexit_p(adxrs450_remove),
+};
+
+static __init int adxrs450_init(void)
+{
+       return spi_register_driver(&adxrs450_driver);
+}
+module_init(adxrs450_init);
+
+static __exit void adxrs450_exit(void)
+{
+       spi_unregister_driver(&adxrs450_driver);
+}
+module_exit(adxrs450_exit);
+
+MODULE_AUTHOR("Cliff Cai <cliff.cai@xxxxxxxxxx>");
+MODULE_DESCRIPTION("Analog Devices ADXRS450 Gyroscope SPI driver");
+MODULE_LICENSE("GPL v2");
index b4ea5bf161ff021efbe0dac37e5288706b2ce926..b5495613407b06fc1532f317d39b2fb7db635bb8 100644 (file)
@@ -57,6 +57,9 @@
 #define IIO_DEV_ATTR_GYRO_Z_CALIBSCALE(_mode, _show, _store, _addr)            \
        IIO_DEVICE_ATTR(gyro_z_calibscale, _mode, _show, _store, _addr)
 
+#define IIO_DEV_ATTR_GYRO_Z_QUADRATURE_CORRECTION(_show, _addr)                \
+       IIO_DEVICE_ATTR(gyro_z_quadrature_correction_raw, S_IRUGO, _show, NULL, _addr)
+
 #define IIO_DEV_ATTR_GYRO(_show, _addr)                        \
        IIO_DEVICE_ATTR(gyro_raw, S_IRUGO, _show, NULL, _addr)
 
index 7127f26f8d267dc816d2ae717d98826aa8378d38..38f1425f46459221ade5dd42eae8e6625afd133a 100644 (file)
@@ -12,6 +12,7 @@
 
 #include <linux/device.h>
 #include <linux/cdev.h>
+#include <linux/irq.h>
 #include "sysfs.h"
 #include "chrdev.h"
 
 /* Event interface flags */
 #define IIO_BUSY_BIT_POS 1
 
-struct iio_dev;
+/* naughty temporary hack to match these against the event version
+   - need to flattern these together */
+enum iio_chan_type {
+       /* real channel types */
+       IIO_IN,
+       IIO_CURRENT,
+       IIO_POWER,
+       IIO_ACCEL,
+       IIO_IN_DIFF,
+       IIO_GYRO,
+       IIO_MAGN,
+       IIO_LIGHT,
+       IIO_INTENSITY,
+       IIO_PROXIMITY,
+       IIO_TEMP,
+       IIO_INCLI,
+       IIO_ROT,
+       IIO_ANGL,
+       IIO_TIMESTAMP,
+};
+
+#define IIO_MOD_X                      0
+#define IIO_MOD_LIGHT_BOTH             0
+#define IIO_MOD_Y                      1
+#define IIO_MOD_LIGHT_IR               1
+#define IIO_MOD_Z                      2
+#define IIO_MOD_X_AND_Y                        3
+#define IIO_MOD_X_ANX_Z                        4
+#define IIO_MOD_Y_AND_Z                        5
+#define IIO_MOD_X_AND_Y_AND_Z          6
+#define IIO_MOD_X_OR_Y                 7
+#define IIO_MOD_X_OR_Z                 8
+#define IIO_MOD_Y_OR_Z                 9
+#define IIO_MOD_X_OR_Y_OR_Z            10
+
+/* Could add the raw attributes as well - allowing buffer only devices */
+enum iio_chan_info_enum {
+       IIO_CHAN_INFO_SCALE_SHARED,
+       IIO_CHAN_INFO_SCALE_SEPARATE,
+       IIO_CHAN_INFO_OFFSET_SHARED,
+       IIO_CHAN_INFO_OFFSET_SEPARATE,
+       IIO_CHAN_INFO_CALIBSCALE_SHARED,
+       IIO_CHAN_INFO_CALIBSCALE_SEPARATE,
+       IIO_CHAN_INFO_CALIBBIAS_SHARED,
+       IIO_CHAN_INFO_CALIBBIAS_SEPARATE,
+       IIO_CHAN_INFO_PEAK_SHARED,
+       IIO_CHAN_INFO_PEAK_SEPARATE,
+       IIO_CHAN_INFO_PEAK_SCALE_SHARED,
+       IIO_CHAN_INFO_PEAK_SCALE_SEPARATE,
+};
 
+/**
+ * struct iio_chan_spec - specification of a single channel
+ * @type:              What type of measurement is the channel making.
+ * @channel:           What number or name do we wish to asign the channel.
+ * @channel2:          If there is a second number for a differential
+ *                     channel then this is it. If modified is set then the
+ *                     value here specifies the modifier.
+ * @address:           Driver specific identifier.
+ * @scan_index:        Monotonic index to give ordering in scans when read
+ *                     from a buffer.
+ * @scan_type:         Sign:           's' or 'u' to specify signed or unsigned
+ *                     realbits:       Number of valid bits of data
+ *                     storage_bits:   Realbits + padding
+ *                     shift:          Shift right by this before masking out
+ *                                     realbits.
+ * @info_mask:         What information is to be exported about this channel.
+ *                     This includes calibbias, scale etc.
+ * @event_mask:        What events can this channel produce.
+ * @extend_name:       Allows labeling of channel attributes with an
+ *                     informative name. Note this has no effect codes etc,
+ *                     unlike modifiers.
+ * @processed_val:     Flag to specify the data access attribute should be
+ *                     *_input rather than *_raw.
+ * @modified:          Does a modifier apply to this channel. What these are
+ *                     depends on the channel type.  Modifier is set in
+ *                     channel2. Examples are IIO_MOD_X for axial sensors about
+ *                     the 'x' axis.
+ * @indexed:           Specify the channel has a numerical index. If not,
+ *                     the value in channel will be suppressed for attribute
+ *                     but not for event codes. Typically set it to 0 when
+ *                     the index is false.
+ */
+struct iio_chan_spec {
+       enum iio_chan_type      type;
+       int                     channel;
+       int                     channel2;
+       unsigned long           address;
+       int                     scan_index;
+       struct {
+               char    sign;
+               u8      realbits;
+               u8      storagebits;
+               u8      shift;
+       } scan_type;
+       const long              info_mask;
+       const long              event_mask;
+       const char              *extend_name;
+       unsigned                processed_val:1;
+       unsigned                modified:1;
+       unsigned                indexed:1;
+};
+/* Meant for internal use only */
+void __iio_device_attr_deinit(struct device_attribute *dev_attr);
+int __iio_device_attr_init(struct device_attribute *dev_attr,
+                          const char *postfix,
+                          struct iio_chan_spec const *chan,
+                          ssize_t (*readfunc)(struct device *dev,
+                                              struct device_attribute *attr,
+                                              char *buf),
+                          ssize_t (*writefunc)(struct device *dev,
+                                               struct device_attribute *attr,
+                                               const char *buf,
+                                               size_t len),
+                          bool generic);
+#define IIO_ST(si, rb, sb, sh)                                         \
+       { .sign = si, .realbits = rb, .storagebits = sb, .shift = sh }
+
+#define IIO_CHAN(_type, _mod, _indexed, _proc, _name, _chan, _chan2,   \
+                _inf_mask, _address, _si, _stype, _event_mask)         \
+       { .type = _type,                                                \
+         .modified = _mod,                                             \
+         .indexed = _indexed,                                          \
+         .processed_val = _proc,                                       \
+         .extend_name = _name,                                         \
+         .channel = _chan,                                             \
+         .channel2 = _chan2,                                           \
+         .info_mask = _inf_mask,                                       \
+         .address = _address,                                          \
+         .scan_index = _si,                                            \
+         .scan_type = _stype,                                          \
+         .event_mask = _event_mask }
+
+#define IIO_CHAN_SOFT_TIMESTAMP(_si)                                   \
+       { .type = IIO_TIMESTAMP, .channel = -1,                         \
+                       .scan_index = _si, .scan_type = IIO_ST('s', 64, 64, 0) }
+
+int __iio_add_chan_devattr(const char *postfix,
+                          const char *group,
+                          struct iio_chan_spec const *chan,
+                          ssize_t (*func)(struct device *dev,
+                                          struct device_attribute *attr,
+                                          char *buf),
+                          ssize_t (*writefunc)(struct device *dev,
+                                               struct device_attribute *attr,
+                                               const char *buf,
+                                               size_t len),
+                          int mask,
+                          bool generic,
+                          struct device *dev,
+                          struct list_head *attr_list);
 /**
  * iio_get_time_ns() - utility function to get a time stamp for events etc
  **/
@@ -41,26 +191,6 @@ static inline s64 iio_get_time_ns(void)
        return timespec_to_ns(&ts);
 }
 
-/**
- * iio_add_event_to_list() - Wraps adding to event lists
- * @el:                the list element of the event to be handled.
- * @head:      the list associated with the event handler being used.
- *
- * Does reference counting to allow shared handlers.
- **/
-void iio_add_event_to_list(struct iio_event_handler_list *el,
-                          struct list_head *head);
-
-/**
- * iio_remove_event_from_list() - Wraps removing from event list
- * @el:                element to be removed
- * @head:      associate list head for the interrupt handler.
- *
- * Does reference counting to allow shared handlers.
- **/
-void iio_remove_event_from_list(struct iio_event_handler_list *el,
-                               struct list_head *head);
-
 /* Device operating modes */
 #define INDIO_DIRECT_MODE              0x01
 #define INDIO_RING_TRIGGERED           0x02
@@ -70,6 +200,62 @@ void iio_remove_event_from_list(struct iio_event_handler_list *el,
 
 /* Vast majority of this is set by the industrialio subsystem on a
  * call to iio_device_register. */
+#define IIO_VAL_INT 1
+#define IIO_VAL_INT_PLUS_MICRO 2
+
+/**
+ * struct iio_info - constant information about device
+ * @driver_module:     module structure used to ensure correct
+ *                     ownership of chrdevs etc
+ * @num_interrupt_lines:number of physical interrupt lines from device
+ * @event_attrs:       event control attributes
+ * @attrs:             general purpose device attributes
+ * @read_raw:          function to request a value from the device.
+ *                     mask specifies which value. Note 0 means a reading of
+ *                     the channel in question.  Return value will specify the
+ *                     type of value returned by the device. val and val2 will
+ *                     contain the elements making up the returned value.
+ * @write_raw:         function to write a value to the device.
+ *                     Parameters are the same as for read_raw.
+ * @read_event_config: find out if the event is enabled.
+ * @write_event_config:        set if the event is enabled.
+ * @read_event_value:  read a value associated with the event. Meaning
+ *                     is event dependant. event_code specifies which event.
+ * @write_event_value: write the value associate with the event.
+ *                     Meaning is event dependent.
+ **/
+struct iio_info {
+       struct module                   *driver_module;
+       int                             num_interrupt_lines;
+       struct attribute_group          *event_attrs;
+       const struct attribute_group    *attrs;
+
+       int (*read_raw)(struct iio_dev *indio_dev,
+                       struct iio_chan_spec const *chan,
+                       int *val,
+                       int *val2,
+                       long mask);
+
+       int (*write_raw)(struct iio_dev *indio_dev,
+                        struct iio_chan_spec const *chan,
+                        int val,
+                        int val2,
+                        long mask);
+
+       int (*read_event_config)(struct iio_dev *indio_dev,
+                                int event_code);
+
+       int (*write_event_config)(struct iio_dev *indio_dev,
+                                 int event_code,
+                                 int state);
+
+       int (*read_event_value)(struct iio_dev *indio_dev,
+                               int event_code,
+                               int *val);
+       int (*write_event_value)(struct iio_dev *indio_dev,
+                                int event_code,
+                                int val);
+};
 
 /**
  * struct iio_dev - industrial I/O device
@@ -79,13 +265,6 @@ void iio_remove_event_from_list(struct iio_event_handler_list *el,
  * @currentmode:       [DRIVER] current operating mode
  * @dev:               [DRIVER] device structure, should be assigned a parent
  *                     and owner
- * @attrs:             [DRIVER] general purpose device attributes
- * @driver_module:     [DRIVER] module structure used to ensure correct
- *                     ownership of chrdevs etc
- * @num_interrupt_lines:[DRIVER] number of physical interrupt lines from device
- * @interrupts:                [INTERN] interrupt line specific event lists etc
- * @event_attrs:       [DRIVER] event control attributes
- * @event_conf_attrs:  [DRIVER] event configuration attributes
  * @event_interfaces:  [INTERN] event chrdevs associated with interrupt lines
  * @ring:              [DRIVER] any ring buffer present
  * @mlock:             [INTERN] lock used to prevent simultaneous device state
@@ -93,6 +272,11 @@ void iio_remove_event_from_list(struct iio_event_handler_list *el,
  * @available_scan_masks: [DRIVER] optional array of allowed bitmasks
  * @trig:              [INTERN] current device trigger (ring buffer modes)
  * @pollfunc:          [DRIVER] function run on trigger being received
+ * @channels:          [DRIVER] channel specification structure table
+ * @num_channels:      [DRIVER] number of chanels specified in @channels.
+ * @channel_attr_list: [INTERN] keep track of automatically created channel
+ *                     attributes.
+ * @name:              [DRIVER] name of the device.
  **/
 struct iio_dev {
        int                             id;
@@ -100,13 +284,6 @@ struct iio_dev {
        int                             modes;
        int                             currentmode;
        struct device                   dev;
-       const struct attribute_group    *attrs;
-       struct module                   *driver_module;
-
-       int                             num_interrupt_lines;
-       struct iio_interrupt            **interrupts;
-       struct attribute_group          *event_attrs;
-       struct attribute_group          *event_conf_attrs;
 
        struct iio_event_interface      *event_interfaces;
 
@@ -116,6 +293,13 @@ struct iio_dev {
        u32                             *available_scan_masks;
        struct iio_trigger              *trig;
        struct iio_poll_func            *pollfunc;
+
+       struct iio_chan_spec const *channels;
+       int num_channels;
+
+       struct list_head channel_attr_list;
+       const char *name;
+       const struct iio_info *info;
 };
 
 /**
@@ -130,47 +314,6 @@ int iio_device_register(struct iio_dev *dev_info);
  **/
 void iio_device_unregister(struct iio_dev *dev_info);
 
-/**
- * struct iio_interrupt - wrapper used to allow easy handling of multiple
- *                     physical interrupt lines
- * @dev_info:          the iio device for which the is an interrupt line
- * @line_number:       associated line number
- * @id:                        ida allocated unique id number
- * @irq:               associate interrupt number
- * @ev_list:           event handler list for associated events
- * @ev_list_lock:      ensure only one access to list at a time
- **/
-struct iio_interrupt {
-       struct iio_dev                  *dev_info;
-       int                             line_number;
-       int                             id;
-       int                             irq;
-       struct list_head                ev_list;
-       spinlock_t                      ev_list_lock;
-};
-
-#define to_iio_interrupt(i) container_of(i, struct iio_interrupt, ev_list)
-
-/**
- * iio_register_interrupt_line() - Tell IIO about interrupt lines
- *
- * @irq:               Typically provided via platform data
- * @dev_info:          IIO device info structure for device
- * @line_number:       Which interrupt line of the device is this?
- * @type:              Interrupt type (e.g. edge triggered etc)
- * @name:              Identifying name.
- **/
-int iio_register_interrupt_line(unsigned int                   irq,
-                               struct iio_dev                  *dev_info,
-                               int                             line_number,
-                               unsigned long                   type,
-                               const char                      *name);
-
-void iio_unregister_interrupt_line(struct iio_dev *dev_info,
-                                  int line_number);
-
-
-
 /**
  * iio_push_event() - try to add event to the list for userspace reading
  * @dev_info:          IIO device structure
@@ -183,50 +326,6 @@ int iio_push_event(struct iio_dev *dev_info,
                  int ev_code,
                  s64 timestamp);
 
-/**
- * __iio_push_event() - tries to add an event to the list associated with a chrdev
- * @ev_int:            the event interface to which we are pushing the event
- * @ev_code:           the outgoing event code
- * @timestamp:         timestamp of the event
- * @shared_pointer_p:  the shared event pointer
- **/
-int __iio_push_event(struct iio_event_interface *ev_int,
-                   int ev_code,
-                   s64 timestamp,
-                   struct iio_shared_ev_pointer*
-                   shared_pointer_p);
-/**
- * __iio_change_event() - change an event code in case of event escalation
- * @ev:                        the event to be changed
- * @ev_code:           new event code
- * @timestamp:         new timestamp
- **/
-void __iio_change_event(struct iio_detected_event_list *ev,
-                       int ev_code,
-                       s64 timestamp);
-
-/**
- * iio_setup_ev_int() - configure an event interface (chrdev)
- * @name:              name used for resulting sysfs directory etc.
- * @ev_int:            interface we are configuring
- * @owner:             module that is responsible for registering this ev_int
- * @dev:               device whose ev_int this is
- **/
-int iio_setup_ev_int(struct iio_event_interface *ev_int,
-                    const char *name,
-                    struct module *owner,
-                    struct device *dev);
-
-void iio_free_ev_int(struct iio_event_interface *ev_int);
-
-/**
- * iio_allocate_chrdev() - Allocate a chrdev
- * @handler:   struct that contains relevant file handling for chrdev
- * @dev_info:  iio_dev for which chrdev is being created
- **/
-int iio_allocate_chrdev(struct iio_handler *handler, struct iio_dev *dev_info);
-void iio_deallocate_chrdev(struct iio_handler *handler);
-
 /* Used to distinguish between bipolar and unipolar scan elemenents.
  * Whilst this may seem obvious, we may well want to change the representation
  * in the future!*/
@@ -264,10 +363,25 @@ static inline void *iio_dev_get_devdata(struct iio_dev *d)
        return d->dev_data;
 }
 
+
+/* Can we make this smaller? */
+#define IIO_ALIGN L1_CACHE_BYTES
 /**
  * iio_allocate_device() - allocate an iio_dev from a driver
+ * @sizeof_priv: Space to allocate for private structure.
  **/
-struct iio_dev *iio_allocate_device(void);
+struct iio_dev *iio_allocate_device(int sizeof_priv);
+
+static inline void *iio_priv(const struct iio_dev *dev)
+{
+       return (char *)dev + ALIGN(sizeof(struct iio_dev), IIO_ALIGN);
+}
+
+static inline struct iio_dev *iio_priv_to_dev(void *priv)
+{
+       return (struct iio_dev *)((char *)priv -
+                                 ALIGN(sizeof(struct iio_dev), IIO_ALIGN));
+}
 
 /**
  * iio_free_device() - free an iio_dev from a driver
index 31a6233a2068123df6f9fce8f2bf38fc3bd8cf2e..e0e01446117e3b17201b06b4516e2c3c8bb49cb1 100644 (file)
@@ -3,29 +3,13 @@
 #
 comment "Inertial measurement units"
 
-config ADIS16300
-       tristate "Analog Devices ADIS16300 IMU SPI driver"
-       depends on SPI
-       select IIO_SW_RING if IIO_RING_BUFFER
-       select IIO_TRIGGER if IIO_RING_BUFFER
-       help
-         Say yes here to build support for Analog Devices adis16300 four degrees
-         of freedom inertial sensor.
-
-config ADIS16350
-       tristate "Analog Devices ADIS16350/54/55/60/62/64/65 IMU SPI driver"
-       depends on SPI
-       select IIO_TRIGGER if IIO_RING_BUFFER
-       select IIO_SW_RING if IIO_RING_BUFFER
-       help
-         Say yes here to build support for Analog Devices adis16350/54/55/60/62/64/65
-         high precision tri-axis inertial sensor.
-
 config ADIS16400
-       tristate "Analog Devices ADIS16400/5 IMU SPI driver"
+       tristate "Analog Devices ADIS16400 and similar IMU SPI driver"
        depends on SPI
        select IIO_SW_RING if IIO_RING_BUFFER
        select IIO_TRIGGER if IIO_RING_BUFFER
        help
-         Say yes here to build support for Analog Devices adis16400/5 triaxial
-         inertial sensor with Magnetometer.
+         Say yes here to build support for Analog Devices adis16300, adis16350,
+         adis16354, adis16355, adis16360, adis16362, adis16364, adis16365,
+         adis16400 and adis16405 triaxial inertial sensors (adis16400 series
+         also have magnetometers).
index f3b450b6611350a90909bbb48ae20c1ed79b2ec0..d46a691912ed658dbf9e7d75d4ca4723e9a46b67 100644 (file)
@@ -2,14 +2,6 @@
 # Makefile for Inertial Measurement Units
 #
 
-adis16300-y             := adis16300_core.o
-adis16300-$(CONFIG_IIO_RING_BUFFER) += adis16300_ring.o adis16300_trigger.o
-obj-$(CONFIG_ADIS16300) += adis16300.o
-
-adis16350-y             := adis16350_core.o
-adis16350-$(CONFIG_IIO_RING_BUFFER) += adis16350_ring.o adis16350_trigger.o
-obj-$(CONFIG_ADIS16350) += adis16350.o
-
 adis16400-y             := adis16400_core.o
 adis16400-$(CONFIG_IIO_RING_BUFFER) += adis16400_ring.o adis16400_trigger.o
 obj-$(CONFIG_ADIS16400) += adis16400.o
diff --git a/drivers/staging/iio/imu/adis16300.h b/drivers/staging/iio/imu/adis16300.h
deleted file mode 100644 (file)
index c095759..0000000
+++ /dev/null
@@ -1,184 +0,0 @@
-#ifndef SPI_ADIS16300_H_
-#define SPI_ADIS16300_H_
-
-#define ADIS16300_STARTUP_DELAY        220 /* ms */
-
-#define ADIS16300_READ_REG(a)    a
-#define ADIS16300_WRITE_REG(a) ((a) | 0x80)
-
-#define ADIS16300_FLASH_CNT  0x00 /* Flash memory write count */
-#define ADIS16300_SUPPLY_OUT 0x02 /* Power supply measurement */
-#define ADIS16300_XGYRO_OUT 0x04 /* X-axis gyroscope output */
-#define ADIS16300_XACCL_OUT 0x0A /* X-axis accelerometer output */
-#define ADIS16300_YACCL_OUT 0x0C /* Y-axis accelerometer output */
-#define ADIS16300_ZACCL_OUT 0x0E /* Z-axis accelerometer output */
-#define ADIS16300_TEMP_OUT  0x10 /* Temperature output */
-#define ADIS16300_XINCLI_OUT 0x12 /* X-axis inclinometer output measurement */
-#define ADIS16300_YINCLI_OUT 0x14 /* Y-axis inclinometer output measurement */
-#define ADIS16300_AUX_ADC   0x16 /* Auxiliary ADC measurement */
-
-/* Calibration parameters */
-#define ADIS16300_XGYRO_OFF 0x1A /* X-axis gyroscope bias offset factor */
-#define ADIS16300_XACCL_OFF 0x20 /* X-axis acceleration bias offset factor */
-#define ADIS16300_YACCL_OFF 0x22 /* Y-axis acceleration bias offset factor */
-#define ADIS16300_ZACCL_OFF 0x24 /* Z-axis acceleration bias offset factor */
-
-#define ADIS16300_GPIO_CTRL 0x32 /* Auxiliary digital input/output control */
-#define ADIS16300_MSC_CTRL  0x34 /* Miscellaneous control */
-#define ADIS16300_SMPL_PRD  0x36 /* Internal sample period (rate) control */
-#define ADIS16300_SENS_AVG  0x38 /* Dynamic range and digital filter control */
-#define ADIS16300_SLP_CNT   0x3A /* Sleep mode control */
-#define ADIS16300_DIAG_STAT 0x3C /* System status */
-
-/* Alarm functions */
-#define ADIS16300_GLOB_CMD  0x3E /* System command */
-#define ADIS16300_ALM_MAG1  0x26 /* Alarm 1 amplitude threshold */
-#define ADIS16300_ALM_MAG2  0x28 /* Alarm 2 amplitude threshold */
-#define ADIS16300_ALM_SMPL1 0x2A /* Alarm 1 sample size */
-#define ADIS16300_ALM_SMPL2 0x2C /* Alarm 2 sample size */
-#define ADIS16300_ALM_CTRL  0x2E /* Alarm control */
-#define ADIS16300_AUX_DAC   0x30 /* Auxiliary DAC data */
-
-#define ADIS16300_ERROR_ACTIVE                 (1<<14)
-#define ADIS16300_NEW_DATA                     (1<<15)
-
-/* MSC_CTRL */
-#define ADIS16300_MSC_CTRL_MEM_TEST            (1<<11)
-#define ADIS16300_MSC_CTRL_INT_SELF_TEST       (1<<10)
-#define ADIS16300_MSC_CTRL_NEG_SELF_TEST       (1<<9)
-#define ADIS16300_MSC_CTRL_POS_SELF_TEST       (1<<8)
-#define ADIS16300_MSC_CTRL_GYRO_BIAS           (1<<7)
-#define ADIS16300_MSC_CTRL_ACCL_ALIGN          (1<<6)
-#define ADIS16300_MSC_CTRL_DATA_RDY_EN         (1<<2)
-#define ADIS16300_MSC_CTRL_DATA_RDY_POL_HIGH   (1<<1)
-#define ADIS16300_MSC_CTRL_DATA_RDY_DIO2       (1<<0)
-
-/* SMPL_PRD */
-#define ADIS16300_SMPL_PRD_TIME_BASE   (1<<7)
-#define ADIS16300_SMPL_PRD_DIV_MASK    0x7F
-
-/* DIAG_STAT */
-#define ADIS16300_DIAG_STAT_ZACCL_FAIL (1<<15)
-#define ADIS16300_DIAG_STAT_YACCL_FAIL (1<<14)
-#define ADIS16300_DIAG_STAT_XACCL_FAIL (1<<13)
-#define ADIS16300_DIAG_STAT_XGYRO_FAIL (1<<10)
-#define ADIS16300_DIAG_STAT_ALARM2     (1<<9)
-#define ADIS16300_DIAG_STAT_ALARM1     (1<<8)
-#define ADIS16300_DIAG_STAT_FLASH_CHK  (1<<6)
-#define ADIS16300_DIAG_STAT_SELF_TEST  (1<<5)
-#define ADIS16300_DIAG_STAT_OVERFLOW   (1<<4)
-#define ADIS16300_DIAG_STAT_SPI_FAIL   (1<<3)
-#define ADIS16300_DIAG_STAT_FLASH_UPT  (1<<2)
-#define ADIS16300_DIAG_STAT_POWER_HIGH (1<<1)
-#define ADIS16300_DIAG_STAT_POWER_LOW  (1<<0)
-
-/* GLOB_CMD */
-#define ADIS16300_GLOB_CMD_SW_RESET    (1<<7)
-#define ADIS16300_GLOB_CMD_P_AUTO_NULL (1<<4)
-#define ADIS16300_GLOB_CMD_FLASH_UPD   (1<<3)
-#define ADIS16300_GLOB_CMD_DAC_LATCH   (1<<2)
-#define ADIS16300_GLOB_CMD_FAC_CALIB   (1<<1)
-#define ADIS16300_GLOB_CMD_AUTO_NULL   (1<<0)
-
-/* SLP_CNT */
-#define ADIS16300_SLP_CNT_POWER_OFF    (1<<8)
-
-#define ADIS16300_MAX_TX 18
-#define ADIS16300_MAX_RX 18
-
-#define ADIS16300_SPI_SLOW     (u32)(300 * 1000)
-#define ADIS16300_SPI_BURST    (u32)(1000 * 1000)
-#define ADIS16300_SPI_FAST     (u32)(2000 * 1000)
-
-/**
- * struct adis16300_state - device instance specific data
- * @us:                        actual spi_device
- * @work_trigger_to_ring: bh for triggered event handling
- * @inter:             used to check if new interrupt has been triggered
- * @last_timestamp:    passing timestamp from th to bh of interrupt handler
- * @indio_dev:         industrial I/O device structure
- * @trig:              data ready trigger registered with iio
- * @tx:                        transmit buffer
- * @rx:                        receive buffer
- * @buf_lock:          mutex to protect tx and rx
- **/
-struct adis16300_state {
-       struct spi_device               *us;
-       struct work_struct              work_trigger_to_ring;
-       s64                             last_timestamp;
-       struct iio_dev                  *indio_dev;
-       struct iio_trigger              *trig;
-       u8                              *tx;
-       u8                              *rx;
-       struct mutex                    buf_lock;
-};
-
-int adis16300_set_irq(struct device *dev, bool enable);
-
-#ifdef CONFIG_IIO_RING_BUFFER
-/* At the moment triggers are only used for ring buffer
- * filling. This may change!
- */
-
-#define ADIS16300_SCAN_SUPPLY  0
-#define ADIS16300_SCAN_GYRO_X  1
-#define ADIS16300_SCAN_ACC_X   2
-#define ADIS16300_SCAN_ACC_Y   3
-#define ADIS16300_SCAN_ACC_Z   4
-#define ADIS16300_SCAN_TEMP    5
-#define ADIS16300_SCAN_ADC_0   6
-#define ADIS16300_SCAN_INCLI_X 7
-#define ADIS16300_SCAN_INCLI_Y 8
-
-void adis16300_remove_trigger(struct iio_dev *indio_dev);
-int adis16300_probe_trigger(struct iio_dev *indio_dev);
-
-ssize_t adis16300_read_data_from_ring(struct device *dev,
-                                     struct device_attribute *attr,
-                                     char *buf);
-
-
-int adis16300_configure_ring(struct iio_dev *indio_dev);
-void adis16300_unconfigure_ring(struct iio_dev *indio_dev);
-
-int adis16300_initialize_ring(struct iio_ring_buffer *ring);
-void adis16300_uninitialize_ring(struct iio_ring_buffer *ring);
-#else /* CONFIG_IIO_RING_BUFFER */
-
-static inline void adis16300_remove_trigger(struct iio_dev *indio_dev)
-{
-}
-
-static inline int adis16300_probe_trigger(struct iio_dev *indio_dev)
-{
-       return 0;
-}
-
-static inline ssize_t
-adis16300_read_data_from_ring(struct device *dev,
-                             struct device_attribute *attr,
-                             char *buf)
-{
-       return 0;
-}
-
-static int adis16300_configure_ring(struct iio_dev *indio_dev)
-{
-       return 0;
-}
-
-static inline void adis16300_unconfigure_ring(struct iio_dev *indio_dev)
-{
-}
-
-static inline int adis16300_initialize_ring(struct iio_ring_buffer *ring)
-{
-       return 0;
-}
-
-static inline void adis16300_uninitialize_ring(struct iio_ring_buffer *ring)
-{
-}
-
-#endif /* CONFIG_IIO_RING_BUFFER */
-#endif /* SPI_ADIS16300_H_ */
diff --git a/drivers/staging/iio/imu/adis16300_core.c b/drivers/staging/iio/imu/adis16300_core.c
deleted file mode 100644 (file)
index 7ad13f4..0000000
+++ /dev/null
@@ -1,756 +0,0 @@
-/*
- * ADIS16300 Four Degrees of Freedom Inertial Sensor Driver
- *
- * Copyright 2010 Analog Devices Inc.
- *
- * Licensed under the GPL-2 or later.
- */
-
-#include <linux/interrupt.h>
-#include <linux/irq.h>
-#include <linux/gpio.h>
-#include <linux/delay.h>
-#include <linux/mutex.h>
-#include <linux/device.h>
-#include <linux/kernel.h>
-#include <linux/spi/spi.h>
-#include <linux/slab.h>
-#include <linux/sysfs.h>
-#include <linux/list.h>
-
-#include "../iio.h"
-#include "../sysfs.h"
-#include "../ring_generic.h"
-#include "../accel/accel.h"
-#include "../accel/inclinometer.h"
-#include "../gyro/gyro.h"
-#include "../adc/adc.h"
-
-#include "adis16300.h"
-
-#define DRIVER_NAME            "adis16300"
-
-static int adis16300_check_status(struct device *dev);
-
-/**
- * adis16300_spi_write_reg_8() - write single byte to a register
- * @dev: device associated with child of actual device (iio_dev or iio_trig)
- * @reg_address: the address of the register to be written
- * @val: the value to write
- **/
-static int adis16300_spi_write_reg_8(struct device *dev,
-               u8 reg_address,
-               u8 val)
-{
-       int ret;
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
-       struct adis16300_state *st = iio_dev_get_devdata(indio_dev);
-
-       mutex_lock(&st->buf_lock);
-       st->tx[0] = ADIS16300_WRITE_REG(reg_address);
-       st->tx[1] = val;
-
-       ret = spi_write(st->us, st->tx, 2);
-       mutex_unlock(&st->buf_lock);
-
-       return ret;
-}
-
-/**
- * adis16300_spi_write_reg_16() - write 2 bytes to a pair of registers
- * @dev: device associated with child of actual device (iio_dev or iio_trig)
- * @reg_address: the address of the lower of the two registers. Second register
- *               is assumed to have address one greater.
- * @val: value to be written
- **/
-static int adis16300_spi_write_reg_16(struct device *dev,
-               u8 lower_reg_address,
-               u16 value)
-{
-       int ret;
-       struct spi_message msg;
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
-       struct adis16300_state *st = iio_dev_get_devdata(indio_dev);
-       struct spi_transfer xfers[] = {
-               {
-                       .tx_buf = st->tx,
-                       .bits_per_word = 8,
-                       .len = 2,
-                       .cs_change = 1,
-                       .delay_usecs = 75,
-               }, {
-                       .tx_buf = st->tx + 2,
-                       .bits_per_word = 8,
-                       .len = 2,
-                       .cs_change = 1,
-                       .delay_usecs = 75,
-               },
-       };
-
-       mutex_lock(&st->buf_lock);
-       st->tx[0] = ADIS16300_WRITE_REG(lower_reg_address);
-       st->tx[1] = value & 0xFF;
-       st->tx[2] = ADIS16300_WRITE_REG(lower_reg_address + 1);
-       st->tx[3] = (value >> 8) & 0xFF;
-
-       spi_message_init(&msg);
-       spi_message_add_tail(&xfers[0], &msg);
-       spi_message_add_tail(&xfers[1], &msg);
-       ret = spi_sync(st->us, &msg);
-       mutex_unlock(&st->buf_lock);
-
-       return ret;
-}
-
-/**
- * adis16300_spi_read_reg_16() - read 2 bytes from a 16-bit register
- * @dev: device associated with child of actual device (iio_dev or iio_trig)
- * @reg_address: the address of the lower of the two registers. Second register
- *               is assumed to have address one greater.
- * @val: somewhere to pass back the value read
- **/
-static int adis16300_spi_read_reg_16(struct device *dev,
-               u8 lower_reg_address,
-               u16 *val)
-{
-       struct spi_message msg;
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
-       struct adis16300_state *st = iio_dev_get_devdata(indio_dev);
-       int ret;
-       struct spi_transfer xfers[] = {
-               {
-                       .tx_buf = st->tx,
-                       .bits_per_word = 8,
-                       .len = 2,
-                       .cs_change = 1,
-                       .delay_usecs = 75,
-               }, {
-                       .rx_buf = st->rx,
-                       .bits_per_word = 8,
-                       .len = 2,
-                       .cs_change = 1,
-                       .delay_usecs = 75,
-               },
-       };
-
-       mutex_lock(&st->buf_lock);
-       st->tx[0] = ADIS16300_READ_REG(lower_reg_address);
-       st->tx[1] = 0;
-       st->tx[2] = 0;
-       st->tx[3] = 0;
-
-       spi_message_init(&msg);
-       spi_message_add_tail(&xfers[0], &msg);
-       spi_message_add_tail(&xfers[1], &msg);
-       ret = spi_sync(st->us, &msg);
-       if (ret) {
-               dev_err(&st->us->dev,
-                       "problem when reading 16 bit register 0x%02X",
-                       lower_reg_address);
-               goto error_ret;
-       }
-       *val = (st->rx[0] << 8) | st->rx[1];
-
-error_ret:
-       mutex_unlock(&st->buf_lock);
-       return ret;
-}
-
-static ssize_t adis16300_spi_read_signed(struct device *dev,
-               struct device_attribute *attr,
-               char *buf,
-               unsigned bits)
-{
-       int ret;
-       s16 val = 0;
-       unsigned shift = 16 - bits;
-       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-
-       ret = adis16300_spi_read_reg_16(dev, this_attr->address, (u16 *)&val);
-       if (ret)
-               return ret;
-
-       if (val & ADIS16300_ERROR_ACTIVE)
-               adis16300_check_status(dev);
-       val = ((s16)(val << shift) >> shift);
-       return sprintf(buf, "%d\n", val);
-}
-
-static ssize_t adis16300_read_12bit_unsigned(struct device *dev,
-               struct device_attribute *attr,
-               char *buf)
-{
-       int ret;
-       u16 val = 0;
-       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-
-       ret = adis16300_spi_read_reg_16(dev, this_attr->address, &val);
-       if (ret)
-               return ret;
-
-       if (val & ADIS16300_ERROR_ACTIVE)
-               adis16300_check_status(dev);
-
-       return sprintf(buf, "%u\n", val & 0x0FFF);
-}
-
-static ssize_t adis16300_read_14bit_unsigned(struct device *dev,
-               struct device_attribute *attr,
-               char *buf)
-{
-       int ret;
-       u16 val = 0;
-       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-
-       ret = adis16300_spi_read_reg_16(dev, this_attr->address, &val);
-       if (ret)
-               return ret;
-
-       if (val & ADIS16300_ERROR_ACTIVE)
-               adis16300_check_status(dev);
-
-       return sprintf(buf, "%u\n", val & 0x3FFF);
-}
-
-static ssize_t adis16300_read_14bit_signed(struct device *dev,
-               struct device_attribute *attr,
-               char *buf)
-{
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
-       ssize_t ret;
-
-       /* Take the iio_dev status lock */
-       mutex_lock(&indio_dev->mlock);
-       ret =  adis16300_spi_read_signed(dev, attr, buf, 14);
-       mutex_unlock(&indio_dev->mlock);
-
-       return ret;
-}
-
-static ssize_t adis16300_read_12bit_signed(struct device *dev,
-               struct device_attribute *attr,
-               char *buf)
-{
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
-       ssize_t ret;
-
-       /* Take the iio_dev status lock */
-       mutex_lock(&indio_dev->mlock);
-       ret =  adis16300_spi_read_signed(dev, attr, buf, 12);
-       mutex_unlock(&indio_dev->mlock);
-
-       return ret;
-}
-
-static ssize_t adis16300_read_13bit_signed(struct device *dev,
-               struct device_attribute *attr,
-               char *buf)
-{
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
-       ssize_t ret;
-
-       /* Take the iio_dev status lock */
-       mutex_lock(&indio_dev->mlock);
-       ret =  adis16300_spi_read_signed(dev, attr, buf, 13);
-       mutex_unlock(&indio_dev->mlock);
-
-       return ret;
-}
-
-static ssize_t adis16300_write_16bit(struct device *dev,
-               struct device_attribute *attr,
-               const char *buf,
-               size_t len)
-{
-       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-       int ret;
-       long val;
-
-       ret = strict_strtol(buf, 10, &val);
-       if (ret)
-               goto error_ret;
-       ret = adis16300_spi_write_reg_16(dev, this_attr->address, val);
-
-error_ret:
-       return ret ? ret : len;
-}
-
-static ssize_t adis16300_read_frequency(struct device *dev,
-               struct device_attribute *attr,
-               char *buf)
-{
-       int ret, len = 0;
-       u16 t;
-       int sps;
-       ret = adis16300_spi_read_reg_16(dev,
-                       ADIS16300_SMPL_PRD,
-                       &t);
-       if (ret)
-               return ret;
-       sps =  (t & ADIS16300_SMPL_PRD_TIME_BASE) ? 53 : 1638;
-       sps /= (t & ADIS16300_SMPL_PRD_DIV_MASK) + 1;
-       len = sprintf(buf, "%d SPS\n", sps);
-       return len;
-}
-
-static ssize_t adis16300_write_frequency(struct device *dev,
-               struct device_attribute *attr,
-               const char *buf,
-               size_t len)
-{
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
-       struct adis16300_state *st = iio_dev_get_devdata(indio_dev);
-       long val;
-       int ret;
-       u8 t;
-
-       ret = strict_strtol(buf, 10, &val);
-       if (ret)
-               return ret;
-
-       mutex_lock(&indio_dev->mlock);
-
-       t = (1638 / val);
-       if (t > 0)
-               t--;
-       t &= ADIS16300_SMPL_PRD_DIV_MASK;
-       if ((t & ADIS16300_SMPL_PRD_DIV_MASK) >= 0x0A)
-               st->us->max_speed_hz = ADIS16300_SPI_SLOW;
-       else
-               st->us->max_speed_hz = ADIS16300_SPI_FAST;
-
-       ret = adis16300_spi_write_reg_8(dev,
-                       ADIS16300_SMPL_PRD,
-                       t);
-
-       mutex_unlock(&indio_dev->mlock);
-
-       return ret ? ret : len;
-}
-
-static int adis16300_reset(struct device *dev)
-{
-       int ret;
-       ret = adis16300_spi_write_reg_8(dev,
-                       ADIS16300_GLOB_CMD,
-                       ADIS16300_GLOB_CMD_SW_RESET);
-       if (ret)
-               dev_err(dev, "problem resetting device");
-
-       return ret;
-}
-
-static ssize_t adis16300_write_reset(struct device *dev,
-               struct device_attribute *attr,
-               const char *buf, size_t len)
-{
-       if (len < 1)
-               return -1;
-       switch (buf[0]) {
-       case '1':
-       case 'y':
-       case 'Y':
-               return adis16300_reset(dev);
-       }
-       return -1;
-}
-
-int adis16300_set_irq(struct device *dev, bool enable)
-{
-       int ret;
-       u16 msc;
-       ret = adis16300_spi_read_reg_16(dev, ADIS16300_MSC_CTRL, &msc);
-       if (ret)
-               goto error_ret;
-
-       msc |= ADIS16300_MSC_CTRL_DATA_RDY_POL_HIGH;
-       msc &= ~ADIS16300_MSC_CTRL_DATA_RDY_DIO2;
-       if (enable)
-               msc |= ADIS16300_MSC_CTRL_DATA_RDY_EN;
-       else
-               msc &= ~ADIS16300_MSC_CTRL_DATA_RDY_EN;
-
-       ret = adis16300_spi_write_reg_16(dev, ADIS16300_MSC_CTRL, msc);
-       if (ret)
-               goto error_ret;
-
-error_ret:
-       return ret;
-}
-
-/* Power down the device */
-static int adis16300_stop_device(struct device *dev)
-{
-       int ret;
-       u16 val = ADIS16300_SLP_CNT_POWER_OFF;
-
-       ret = adis16300_spi_write_reg_16(dev, ADIS16300_SLP_CNT, val);
-       if (ret)
-               dev_err(dev, "problem with turning device off: SLP_CNT");
-
-       return ret;
-}
-
-static int adis16300_self_test(struct device *dev)
-{
-       int ret;
-       ret = adis16300_spi_write_reg_16(dev,
-                       ADIS16300_MSC_CTRL,
-                       ADIS16300_MSC_CTRL_MEM_TEST);
-       if (ret) {
-               dev_err(dev, "problem starting self test");
-               goto err_ret;
-       }
-
-       adis16300_check_status(dev);
-
-err_ret:
-       return ret;
-}
-
-static int adis16300_check_status(struct device *dev)
-{
-       u16 status;
-       int ret;
-
-       ret = adis16300_spi_read_reg_16(dev, ADIS16300_DIAG_STAT, &status);
-
-       if (ret < 0) {
-               dev_err(dev, "Reading status failed\n");
-               goto error_ret;
-       }
-       ret = status;
-       if (status & ADIS16300_DIAG_STAT_ZACCL_FAIL)
-               dev_err(dev, "Z-axis accelerometer self-test failure\n");
-       if (status & ADIS16300_DIAG_STAT_YACCL_FAIL)
-               dev_err(dev, "Y-axis accelerometer self-test failure\n");
-       if (status & ADIS16300_DIAG_STAT_XACCL_FAIL)
-               dev_err(dev, "X-axis accelerometer self-test failure\n");
-       if (status & ADIS16300_DIAG_STAT_XGYRO_FAIL)
-               dev_err(dev, "X-axis gyroscope self-test failure\n");
-       if (status & ADIS16300_DIAG_STAT_ALARM2)
-               dev_err(dev, "Alarm 2 active\n");
-       if (status & ADIS16300_DIAG_STAT_ALARM1)
-               dev_err(dev, "Alarm 1 active\n");
-       if (status & ADIS16300_DIAG_STAT_FLASH_CHK)
-               dev_err(dev, "Flash checksum error\n");
-       if (status & ADIS16300_DIAG_STAT_SELF_TEST)
-               dev_err(dev, "Self test error\n");
-       if (status & ADIS16300_DIAG_STAT_OVERFLOW)
-               dev_err(dev, "Sensor overrange\n");
-       if (status & ADIS16300_DIAG_STAT_SPI_FAIL)
-               dev_err(dev, "SPI failure\n");
-       if (status & ADIS16300_DIAG_STAT_FLASH_UPT)
-               dev_err(dev, "Flash update failed\n");
-       if (status & ADIS16300_DIAG_STAT_POWER_HIGH)
-               dev_err(dev, "Power supply above 5.25V\n");
-       if (status & ADIS16300_DIAG_STAT_POWER_LOW)
-               dev_err(dev, "Power supply below 4.75V\n");
-
-error_ret:
-       return ret;
-}
-
-static int adis16300_initial_setup(struct adis16300_state *st)
-{
-       int ret;
-       u16 smp_prd;
-       struct device *dev = &st->indio_dev->dev;
-
-       /* use low spi speed for init */
-       st->us->max_speed_hz = ADIS16300_SPI_SLOW;
-       st->us->mode = SPI_MODE_3;
-       spi_setup(st->us);
-
-       /* Disable IRQ */
-       ret = adis16300_set_irq(dev, false);
-       if (ret) {
-               dev_err(dev, "disable irq failed");
-               goto err_ret;
-       }
-
-       /* Do self test */
-       ret = adis16300_self_test(dev);
-       if (ret) {
-               dev_err(dev, "self test failure");
-               goto err_ret;
-       }
-
-       /* Read status register to check the result */
-       ret = adis16300_check_status(dev);
-       if (ret) {
-               adis16300_reset(dev);
-               dev_err(dev, "device not playing ball -> reset");
-               msleep(ADIS16300_STARTUP_DELAY);
-               ret = adis16300_check_status(dev);
-               if (ret) {
-                       dev_err(dev, "giving up");
-                       goto err_ret;
-               }
-       }
-
-       printk(KERN_INFO DRIVER_NAME ": at CS%d (irq %d)\n",
-                       st->us->chip_select, st->us->irq);
-
-       /* use high spi speed if possible */
-       ret = adis16300_spi_read_reg_16(dev, ADIS16300_SMPL_PRD, &smp_prd);
-       if (!ret && (smp_prd & ADIS16300_SMPL_PRD_DIV_MASK) < 0x0A) {
-               st->us->max_speed_hz = ADIS16300_SPI_SLOW;
-               spi_setup(st->us);
-       }
-
-err_ret:
-       return ret;
-}
-
-static IIO_DEV_ATTR_GYRO_X_CALIBBIAS(S_IWUSR | S_IRUGO,
-               adis16300_read_12bit_signed,
-               adis16300_write_16bit,
-               ADIS16300_XGYRO_OFF);
-
-static IIO_DEV_ATTR_ACCEL_X_CALIBBIAS(S_IWUSR | S_IRUGO,
-               adis16300_read_12bit_signed,
-               adis16300_write_16bit,
-               ADIS16300_XACCL_OFF);
-
-static IIO_DEV_ATTR_ACCEL_Y_CALIBBIAS(S_IWUSR | S_IRUGO,
-               adis16300_read_12bit_signed,
-               adis16300_write_16bit,
-               ADIS16300_YACCL_OFF);
-
-static IIO_DEV_ATTR_ACCEL_Z_CALIBBIAS(S_IWUSR | S_IRUGO,
-               adis16300_read_12bit_signed,
-               adis16300_write_16bit,
-               ADIS16300_ZACCL_OFF);
-
-static IIO_DEV_ATTR_IN_NAMED_RAW(0, supply, adis16300_read_14bit_unsigned,
-                          ADIS16300_SUPPLY_OUT);
-static IIO_CONST_ATTR_IN_NAMED_SCALE(0, supply, "0.00242");
-
-static IIO_DEV_ATTR_GYRO_X(adis16300_read_14bit_signed,
-               ADIS16300_XGYRO_OUT);
-static IIO_CONST_ATTR_GYRO_SCALE("0.000872664");
-
-static IIO_DEV_ATTR_ACCEL_X(adis16300_read_14bit_signed,
-               ADIS16300_XACCL_OUT);
-static IIO_DEV_ATTR_ACCEL_Y(adis16300_read_14bit_signed,
-               ADIS16300_YACCL_OUT);
-static IIO_DEV_ATTR_ACCEL_Z(adis16300_read_14bit_signed,
-               ADIS16300_ZACCL_OUT);
-static IIO_CONST_ATTR_ACCEL_SCALE("0.00588399");
-
-static IIO_DEV_ATTR_INCLI_X(adis16300_read_13bit_signed,
-               ADIS16300_XINCLI_OUT);
-static IIO_DEV_ATTR_INCLI_Y(adis16300_read_13bit_signed,
-               ADIS16300_YINCLI_OUT);
-static IIO_CONST_ATTR_INCLI_SCALE("0.00076794487");
-
-static IIO_DEV_ATTR_TEMP_RAW(adis16300_read_12bit_unsigned);
-static IIO_CONST_ATTR_TEMP_OFFSET("198.16");
-static IIO_CONST_ATTR_TEMP_SCALE("0.14");
-
-static IIO_DEV_ATTR_IN_RAW(1, adis16300_read_12bit_unsigned,
-               ADIS16300_AUX_ADC);
-static IIO_CONST_ATTR(in1_scale, "0.000806");
-
-static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO,
-               adis16300_read_frequency,
-               adis16300_write_frequency);
-
-static IIO_DEVICE_ATTR(reset, S_IWUSR, NULL, adis16300_write_reset, 0);
-
-static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("409 546 819 1638");
-
-static IIO_CONST_ATTR_NAME("adis16300");
-
-static struct attribute *adis16300_event_attributes[] = {
-       NULL
-};
-
-static struct attribute_group adis16300_event_attribute_group = {
-       .attrs = adis16300_event_attributes,
-};
-
-static struct attribute *adis16300_attributes[] = {
-       &iio_dev_attr_gyro_x_calibbias.dev_attr.attr,
-       &iio_dev_attr_accel_x_calibbias.dev_attr.attr,
-       &iio_dev_attr_accel_y_calibbias.dev_attr.attr,
-       &iio_dev_attr_accel_z_calibbias.dev_attr.attr,
-       &iio_dev_attr_in0_supply_raw.dev_attr.attr,
-       &iio_const_attr_in0_supply_scale.dev_attr.attr,
-       &iio_dev_attr_gyro_x_raw.dev_attr.attr,
-       &iio_const_attr_gyro_scale.dev_attr.attr,
-       &iio_dev_attr_accel_x_raw.dev_attr.attr,
-       &iio_dev_attr_accel_y_raw.dev_attr.attr,
-       &iio_dev_attr_accel_z_raw.dev_attr.attr,
-       &iio_const_attr_accel_scale.dev_attr.attr,
-       &iio_dev_attr_incli_x_raw.dev_attr.attr,
-       &iio_dev_attr_incli_y_raw.dev_attr.attr,
-       &iio_const_attr_incli_scale.dev_attr.attr,
-       &iio_dev_attr_temp_raw.dev_attr.attr,
-       &iio_const_attr_temp_offset.dev_attr.attr,
-       &iio_const_attr_temp_scale.dev_attr.attr,
-       &iio_dev_attr_in1_raw.dev_attr.attr,
-       &iio_const_attr_in1_scale.dev_attr.attr,
-       &iio_dev_attr_sampling_frequency.dev_attr.attr,
-       &iio_const_attr_sampling_frequency_available.dev_attr.attr,
-       &iio_dev_attr_reset.dev_attr.attr,
-       &iio_const_attr_name.dev_attr.attr,
-       NULL
-};
-
-static const struct attribute_group adis16300_attribute_group = {
-       .attrs = adis16300_attributes,
-};
-
-static int __devinit adis16300_probe(struct spi_device *spi)
-{
-       int ret, regdone = 0;
-       struct adis16300_state *st = kzalloc(sizeof *st, GFP_KERNEL);
-       if (!st) {
-               ret =  -ENOMEM;
-               goto error_ret;
-       }
-       /* this is only used for removal purposes */
-       spi_set_drvdata(spi, st);
-
-       /* Allocate the comms buffers */
-       st->rx = kzalloc(sizeof(*st->rx)*ADIS16300_MAX_RX, GFP_KERNEL);
-       if (st->rx == NULL) {
-               ret = -ENOMEM;
-               goto error_free_st;
-       }
-       st->tx = kzalloc(sizeof(*st->tx)*ADIS16300_MAX_TX, GFP_KERNEL);
-       if (st->tx == NULL) {
-               ret = -ENOMEM;
-               goto error_free_rx;
-       }
-       st->us = spi;
-       mutex_init(&st->buf_lock);
-       /* setup the industrialio driver allocated elements */
-       st->indio_dev = iio_allocate_device();
-       if (st->indio_dev == NULL) {
-               ret = -ENOMEM;
-               goto error_free_tx;
-       }
-
-       st->indio_dev->dev.parent = &spi->dev;
-       st->indio_dev->num_interrupt_lines = 1;
-       st->indio_dev->event_attrs = &adis16300_event_attribute_group;
-       st->indio_dev->attrs = &adis16300_attribute_group;
-       st->indio_dev->dev_data = (void *)(st);
-       st->indio_dev->driver_module = THIS_MODULE;
-       st->indio_dev->modes = INDIO_DIRECT_MODE;
-
-       ret = adis16300_configure_ring(st->indio_dev);
-       if (ret)
-               goto error_free_dev;
-
-       ret = iio_device_register(st->indio_dev);
-       if (ret)
-               goto error_unreg_ring_funcs;
-       regdone = 1;
-
-       ret = iio_ring_buffer_register(st->indio_dev->ring, 0);
-       if (ret) {
-               printk(KERN_ERR "failed to initialize the ring\n");
-               goto error_unreg_ring_funcs;
-       }
-
-       if (spi->irq) {
-               ret = iio_register_interrupt_line(spi->irq,
-                               st->indio_dev,
-                               0,
-                               IRQF_TRIGGER_RISING,
-                               "adis16300");
-               if (ret)
-                       goto error_uninitialize_ring;
-
-               ret = adis16300_probe_trigger(st->indio_dev);
-               if (ret)
-                       goto error_unregister_line;
-       }
-
-       /* Get the device into a sane initial state */
-       ret = adis16300_initial_setup(st);
-       if (ret)
-               goto error_remove_trigger;
-       return 0;
-
-error_remove_trigger:
-       adis16300_remove_trigger(st->indio_dev);
-error_unregister_line:
-       if (spi->irq)
-               iio_unregister_interrupt_line(st->indio_dev, 0);
-error_uninitialize_ring:
-       iio_ring_buffer_unregister(st->indio_dev->ring);
-error_unreg_ring_funcs:
-       adis16300_unconfigure_ring(st->indio_dev);
-error_free_dev:
-       if (regdone)
-               iio_device_unregister(st->indio_dev);
-       else
-               iio_free_device(st->indio_dev);
-error_free_tx:
-       kfree(st->tx);
-error_free_rx:
-       kfree(st->rx);
-error_free_st:
-       kfree(st);
-error_ret:
-       return ret;
-}
-
-static int adis16300_remove(struct spi_device *spi)
-{
-       int ret;
-       struct adis16300_state *st = spi_get_drvdata(spi);
-       struct iio_dev *indio_dev = st->indio_dev;
-
-       ret = adis16300_stop_device(&(indio_dev->dev));
-       if (ret)
-               goto err_ret;
-
-       flush_scheduled_work();
-
-       adis16300_remove_trigger(indio_dev);
-       if (spi->irq)
-               iio_unregister_interrupt_line(indio_dev, 0);
-
-       iio_ring_buffer_unregister(indio_dev->ring);
-       iio_device_unregister(indio_dev);
-       adis16300_unconfigure_ring(indio_dev);
-       kfree(st->tx);
-       kfree(st->rx);
-       kfree(st);
-
-       return 0;
-
-err_ret:
-       return ret;
-}
-
-static struct spi_driver adis16300_driver = {
-       .driver = {
-               .name = "adis16300",
-               .owner = THIS_MODULE,
-       },
-       .probe = adis16300_probe,
-       .remove = __devexit_p(adis16300_remove),
-};
-
-static __init int adis16300_init(void)
-{
-       return spi_register_driver(&adis16300_driver);
-}
-module_init(adis16300_init);
-
-static __exit void adis16300_exit(void)
-{
-       spi_unregister_driver(&adis16300_driver);
-}
-module_exit(adis16300_exit);
-
-MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>");
-MODULE_DESCRIPTION("Analog Devices ADIS16300 IMU SPI driver");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/staging/iio/imu/adis16300_ring.c b/drivers/staging/iio/imu/adis16300_ring.c
deleted file mode 100644 (file)
index 114fdf4..0000000
+++ /dev/null
@@ -1,238 +0,0 @@
-#include <linux/interrupt.h>
-#include <linux/irq.h>
-#include <linux/gpio.h>
-#include <linux/workqueue.h>
-#include <linux/mutex.h>
-#include <linux/device.h>
-#include <linux/kernel.h>
-#include <linux/spi/spi.h>
-#include <linux/slab.h>
-#include <linux/sysfs.h>
-#include <linux/list.h>
-
-#include "../iio.h"
-#include "../sysfs.h"
-#include "../ring_sw.h"
-#include "../accel/accel.h"
-#include "../trigger.h"
-#include "adis16300.h"
-
-static IIO_SCAN_EL_C(in0_supply, ADIS16300_SCAN_SUPPLY,
-                    ADIS16300_SUPPLY_OUT, NULL);
-static IIO_CONST_ATTR_SCAN_EL_TYPE(in0_supply, u, 12, 16);
-static IIO_SCAN_EL_C(gyro_x, ADIS16300_SCAN_GYRO_X, ADIS16300_XGYRO_OUT, NULL);
-static IIO_CONST_ATTR_SCAN_EL_TYPE(gyro, s, 14, 16);
-
-static IIO_SCAN_EL_C(accel_x, ADIS16300_SCAN_ACC_X, ADIS16300_XACCL_OUT, NULL);
-static IIO_SCAN_EL_C(accel_y, ADIS16300_SCAN_ACC_Y, ADIS16300_YACCL_OUT, NULL);
-static IIO_SCAN_EL_C(accel_z, ADIS16300_SCAN_ACC_Z, ADIS16300_ZACCL_OUT, NULL);
-static IIO_CONST_ATTR_SCAN_EL_TYPE(accel, s, 14, 16);
-
-static IIO_SCAN_EL_C(temp, ADIS16300_SCAN_TEMP, ADIS16300_TEMP_OUT, NULL);
-static IIO_CONST_ATTR_SCAN_EL_TYPE(temp, s, 12, 16);
-
-static IIO_SCAN_EL_C(in1, ADIS16300_SCAN_ADC_0, ADIS16300_AUX_ADC, NULL);
-static IIO_CONST_ATTR_SCAN_EL_TYPE(in1, u, 12, 16);
-
-static IIO_SCAN_EL_C(incli_x, ADIS16300_SCAN_INCLI_X,
-                    ADIS16300_XINCLI_OUT, NULL);
-static IIO_SCAN_EL_C(incli_y, ADIS16300_SCAN_INCLI_Y,
-                    ADIS16300_YINCLI_OUT, NULL);
-static IIO_CONST_ATTR_SCAN_EL_TYPE(incli, s, 13, 16);
-
-static IIO_SCAN_EL_TIMESTAMP(9);
-static IIO_CONST_ATTR_SCAN_EL_TYPE(timestamp, s, 64, 64);
-
-static struct attribute *adis16300_scan_el_attrs[] = {
-       &iio_scan_el_in0_supply.dev_attr.attr,
-       &iio_const_attr_in0_supply_index.dev_attr.attr,
-       &iio_const_attr_in0_supply_type.dev_attr.attr,
-       &iio_scan_el_gyro_x.dev_attr.attr,
-       &iio_const_attr_gyro_x_index.dev_attr.attr,
-       &iio_const_attr_gyro_type.dev_attr.attr,
-       &iio_scan_el_temp.dev_attr.attr,
-       &iio_const_attr_temp_index.dev_attr.attr,
-       &iio_const_attr_temp_type.dev_attr.attr,
-       &iio_scan_el_accel_x.dev_attr.attr,
-       &iio_const_attr_accel_x_index.dev_attr.attr,
-       &iio_scan_el_accel_y.dev_attr.attr,
-       &iio_const_attr_accel_y_index.dev_attr.attr,
-       &iio_scan_el_accel_z.dev_attr.attr,
-       &iio_const_attr_accel_z_index.dev_attr.attr,
-       &iio_const_attr_accel_type.dev_attr.attr,
-       &iio_scan_el_incli_x.dev_attr.attr,
-       &iio_const_attr_incli_x_index.dev_attr.attr,
-       &iio_scan_el_incli_y.dev_attr.attr,
-       &iio_const_attr_incli_y_index.dev_attr.attr,
-       &iio_const_attr_incli_type.dev_attr.attr,
-       &iio_scan_el_in1.dev_attr.attr,
-       &iio_const_attr_in1_index.dev_attr.attr,
-       &iio_const_attr_in1_type.dev_attr.attr,
-       &iio_scan_el_timestamp.dev_attr.attr,
-       &iio_const_attr_timestamp_index.dev_attr.attr,
-       &iio_const_attr_timestamp_type.dev_attr.attr,
-       NULL,
-};
-
-static struct attribute_group adis16300_scan_el_group = {
-       .attrs = adis16300_scan_el_attrs,
-       .name = "scan_elements",
-};
-
-/**
- * adis16300_poll_func_th() top half interrupt handler called by trigger
- * @private_data:      iio_dev
- **/
-static void adis16300_poll_func_th(struct iio_dev *indio_dev, s64 time)
-{
-       struct adis16300_state *st = iio_dev_get_devdata(indio_dev);
-       st->last_timestamp = time;
-       schedule_work(&st->work_trigger_to_ring);
-       /* Indicate that this interrupt is being handled */
-
-       /* Technically this is trigger related, but without this
-        * handler running there is currently no way for the interrupt
-        * to clear.
-        */
-}
-
-/**
- * adis16300_spi_read_burst() - read all data registers
- * @dev: device associated with child of actual device (iio_dev or iio_trig)
- * @rx: somewhere to pass back the value read (min size is 24 bytes)
- **/
-static int adis16300_spi_read_burst(struct device *dev, u8 *rx)
-{
-       struct spi_message msg;
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
-       struct adis16300_state *st = iio_dev_get_devdata(indio_dev);
-       u32 old_speed_hz = st->us->max_speed_hz;
-       int ret;
-
-       struct spi_transfer xfers[] = {
-               {
-                       .tx_buf = st->tx,
-                       .bits_per_word = 8,
-                       .len = 2,
-                       .cs_change = 0,
-               }, {
-                       .rx_buf = rx,
-                       .bits_per_word = 8,
-                       .len = 18,
-                       .cs_change = 0,
-               },
-       };
-
-       mutex_lock(&st->buf_lock);
-       st->tx[0] = ADIS16300_READ_REG(ADIS16300_GLOB_CMD);
-       st->tx[1] = 0;
-
-       spi_message_init(&msg);
-       spi_message_add_tail(&xfers[0], &msg);
-       spi_message_add_tail(&xfers[1], &msg);
-
-       st->us->max_speed_hz = ADIS16300_SPI_BURST;
-       spi_setup(st->us);
-
-       ret = spi_sync(st->us, &msg);
-       if (ret)
-               dev_err(&st->us->dev, "problem when burst reading");
-
-       st->us->max_speed_hz = old_speed_hz;
-       spi_setup(st->us);
-       mutex_unlock(&st->buf_lock);
-       return ret;
-}
-
-/* Whilst this makes a lot of calls to iio_sw_ring functions - it is to device
- * specific to be rolled into the core.
- */
-static void adis16300_trigger_bh_to_ring(struct work_struct *work_s)
-{
-       struct adis16300_state *st
-               = container_of(work_s, struct adis16300_state,
-                              work_trigger_to_ring);
-       struct iio_ring_buffer *ring = st->indio_dev->ring;
-
-       int i = 0;
-       s16 *data;
-       size_t datasize = ring->access.get_bytes_per_datum(ring);
-
-       data = kmalloc(datasize , GFP_KERNEL);
-       if (data == NULL) {
-               dev_err(&st->us->dev, "memory alloc failed in ring bh");
-               return;
-       }
-
-       if (ring->scan_count)
-               if (adis16300_spi_read_burst(&st->indio_dev->dev, st->rx) >= 0)
-                       for (; i < ring->scan_count; i++)
-                               data[i] = be16_to_cpup(
-                                       (__be16 *)&(st->rx[i*2]));
-
-       /* Guaranteed to be aligned with 8 byte boundary */
-       if (ring->scan_timestamp)
-               *((s64 *)(data + ((i + 3)/4)*4)) = st->last_timestamp;
-
-       ring->access.store_to(ring,
-                       (u8 *)data,
-                       st->last_timestamp);
-
-       iio_trigger_notify_done(st->indio_dev->trig);
-       kfree(data);
-
-       return;
-}
-
-void adis16300_unconfigure_ring(struct iio_dev *indio_dev)
-{
-       kfree(indio_dev->pollfunc);
-       iio_sw_rb_free(indio_dev->ring);
-}
-
-int adis16300_configure_ring(struct iio_dev *indio_dev)
-{
-       int ret = 0;
-       struct adis16300_state *st = indio_dev->dev_data;
-       struct iio_ring_buffer *ring;
-       INIT_WORK(&st->work_trigger_to_ring, adis16300_trigger_bh_to_ring);
-
-       ring = iio_sw_rb_allocate(indio_dev);
-       if (!ring) {
-               ret = -ENOMEM;
-               return ret;
-       }
-       indio_dev->ring = ring;
-       /* Effectively select the ring buffer implementation */
-       iio_ring_sw_register_funcs(&ring->access);
-       ring->bpe = 2;
-       ring->scan_el_attrs = &adis16300_scan_el_group;
-       ring->scan_timestamp = true;
-       ring->preenable = &iio_sw_ring_preenable;
-       ring->postenable = &iio_triggered_ring_postenable;
-       ring->predisable = &iio_triggered_ring_predisable;
-       ring->owner = THIS_MODULE;
-
-       /* Set default scan mode */
-       iio_scan_mask_set(ring, iio_scan_el_in0_supply.number);
-       iio_scan_mask_set(ring, iio_scan_el_gyro_x.number);
-       iio_scan_mask_set(ring, iio_scan_el_accel_x.number);
-       iio_scan_mask_set(ring, iio_scan_el_accel_y.number);
-       iio_scan_mask_set(ring, iio_scan_el_accel_z.number);
-       iio_scan_mask_set(ring, iio_scan_el_temp.number);
-       iio_scan_mask_set(ring, iio_scan_el_in1.number);
-       iio_scan_mask_set(ring, iio_scan_el_incli_x.number);
-       iio_scan_mask_set(ring, iio_scan_el_incli_y.number);
-
-       ret = iio_alloc_pollfunc(indio_dev, NULL, &adis16300_poll_func_th);
-       if (ret)
-               goto error_iio_sw_rb_free;
-
-       indio_dev->modes |= INDIO_RING_TRIGGERED;
-       return 0;
-
-error_iio_sw_rb_free:
-       iio_sw_rb_free(indio_dev->ring);
-       return ret;
-}
-
diff --git a/drivers/staging/iio/imu/adis16300_trigger.c b/drivers/staging/iio/imu/adis16300_trigger.c
deleted file mode 100644 (file)
index d6677b6..0000000
+++ /dev/null
@@ -1,125 +0,0 @@
-#include <linux/interrupt.h>
-#include <linux/irq.h>
-#include <linux/mutex.h>
-#include <linux/device.h>
-#include <linux/kernel.h>
-#include <linux/sysfs.h>
-#include <linux/list.h>
-#include <linux/spi/spi.h>
-
-#include "../iio.h"
-#include "../sysfs.h"
-#include "../trigger.h"
-#include "adis16300.h"
-
-/**
- * adis16300_data_rdy_trig_poll() the event handler for the data rdy trig
- **/
-static int adis16300_data_rdy_trig_poll(struct iio_dev *dev_info,
-                                      int index,
-                                      s64 timestamp,
-                                      int no_test)
-{
-       struct adis16300_state *st = iio_dev_get_devdata(dev_info);
-       struct iio_trigger *trig = st->trig;
-
-       iio_trigger_poll(trig, timestamp);
-
-       return IRQ_HANDLED;
-}
-
-IIO_EVENT_SH(data_rdy_trig, &adis16300_data_rdy_trig_poll);
-
-static IIO_TRIGGER_NAME_ATTR;
-
-static struct attribute *adis16300_trigger_attrs[] = {
-       &dev_attr_name.attr,
-       NULL,
-};
-
-static const struct attribute_group adis16300_trigger_attr_group = {
-       .attrs = adis16300_trigger_attrs,
-};
-
-/**
- * adis16300_data_rdy_trigger_set_state() set datardy interrupt state
- **/
-static int adis16300_data_rdy_trigger_set_state(struct iio_trigger *trig,
-                                               bool state)
-{
-       struct adis16300_state *st = trig->private_data;
-       struct iio_dev *indio_dev = st->indio_dev;
-       int ret = 0;
-
-       dev_dbg(&indio_dev->dev, "%s (%d)\n", __func__, state);
-       ret = adis16300_set_irq(&st->indio_dev->dev, state);
-       if (state == false) {
-               iio_remove_event_from_list(&iio_event_data_rdy_trig,
-                                          &indio_dev->interrupts[0]
-                                          ->ev_list);
-               /* possible quirk with handler currently worked around
-                  by ensuring the work queue is empty */
-               flush_scheduled_work();
-       } else {
-               iio_add_event_to_list(&iio_event_data_rdy_trig,
-                                     &indio_dev->interrupts[0]->ev_list);
-       }
-       return ret;
-}
-
-/**
- * adis16300_trig_try_reen() try renabling irq for data rdy trigger
- * @trig:      the datardy trigger
- **/
-static int adis16300_trig_try_reen(struct iio_trigger *trig)
-{
-       struct adis16300_state *st = trig->private_data;
-       enable_irq(st->us->irq);
-       /* irq reenabled so success! */
-       return 0;
-}
-
-int adis16300_probe_trigger(struct iio_dev *indio_dev)
-{
-       int ret;
-       struct adis16300_state *st = indio_dev->dev_data;
-
-       st->trig = iio_allocate_trigger();
-       st->trig->name = kasprintf(GFP_KERNEL,
-                                  "adis16300-dev%d",
-                                  indio_dev->id);
-       if (!st->trig->name) {
-               ret = -ENOMEM;
-               goto error_free_trig;
-       }
-       st->trig->dev.parent = &st->us->dev;
-       st->trig->owner = THIS_MODULE;
-       st->trig->private_data = st;
-       st->trig->set_trigger_state = &adis16300_data_rdy_trigger_set_state;
-       st->trig->try_reenable = &adis16300_trig_try_reen;
-       st->trig->control_attrs = &adis16300_trigger_attr_group;
-       ret = iio_trigger_register(st->trig);
-
-       /* select default trigger */
-       indio_dev->trig = st->trig;
-       if (ret)
-               goto error_free_trig_name;
-
-       return 0;
-
-error_free_trig_name:
-       kfree(st->trig->name);
-error_free_trig:
-       iio_free_trigger(st->trig);
-
-       return ret;
-}
-
-void adis16300_remove_trigger(struct iio_dev *indio_dev)
-{
-       struct adis16300_state *state = indio_dev->dev_data;
-
-       iio_trigger_unregister(state->trig);
-       kfree(state->trig->name);
-       iio_free_trigger(state->trig);
-}
diff --git a/drivers/staging/iio/imu/adis16350.h b/drivers/staging/iio/imu/adis16350.h
deleted file mode 100644 (file)
index b1ad486..0000000
+++ /dev/null
@@ -1,177 +0,0 @@
-#ifndef SPI_ADIS16350_H_
-#define SPI_ADIS16350_H_
-
-#define ADIS16350_STARTUP_DELAY        220 /* ms */
-
-#define ADIS16350_READ_REG(a)    a
-#define ADIS16350_WRITE_REG(a) ((a) | 0x80)
-
-#define ADIS16350_FLASH_CNT  0x00 /* Flash memory write count */
-#define ADIS16350_SUPPLY_OUT 0x02 /* Power supply measurement */
-#define ADIS16350_XGYRO_OUT 0x04 /* X-axis gyroscope output */
-#define ADIS16350_YGYRO_OUT 0x06 /* Y-axis gyroscope output */
-#define ADIS16350_ZGYRO_OUT 0x08 /* Z-axis gyroscope output */
-#define ADIS16350_XACCL_OUT 0x0A /* X-axis accelerometer output */
-#define ADIS16350_YACCL_OUT 0x0C /* Y-axis accelerometer output */
-#define ADIS16350_ZACCL_OUT 0x0E /* Z-axis accelerometer output */
-#define ADIS16350_XTEMP_OUT 0x10 /* X-axis gyroscope temperature measurement */
-#define ADIS16350_YTEMP_OUT 0x12 /* Y-axis gyroscope temperature measurement */
-#define ADIS16350_ZTEMP_OUT 0x14 /* Z-axis gyroscope temperature measurement */
-#define ADIS16350_AUX_ADC   0x16 /* Auxiliary ADC measurement */
-
-/* Calibration parameters */
-#define ADIS16350_XGYRO_OFF 0x1A /* X-axis gyroscope bias offset factor */
-#define ADIS16350_YGYRO_OFF 0x1C /* Y-axis gyroscope bias offset factor */
-#define ADIS16350_ZGYRO_OFF 0x1E /* Z-axis gyroscope bias offset factor */
-#define ADIS16350_XACCL_OFF 0x20 /* X-axis acceleration bias offset factor */
-#define ADIS16350_YACCL_OFF 0x22 /* Y-axis acceleration bias offset factor */
-#define ADIS16350_ZACCL_OFF 0x24 /* Z-axis acceleration bias offset factor */
-
-#define ADIS16350_GPIO_CTRL 0x32 /* Auxiliary digital input/output control */
-#define ADIS16350_MSC_CTRL  0x34 /* Miscellaneous control */
-#define ADIS16350_SMPL_PRD  0x36 /* Internal sample period (rate) control */
-#define ADIS16350_SENS_AVG  0x38 /* Dynamic range and digital filter control */
-#define ADIS16350_SLP_CNT   0x3A /* Sleep mode control */
-#define ADIS16350_DIAG_STAT 0x3C /* System status */
-
-/* Alarm functions */
-#define ADIS16350_GLOB_CMD  0x3E /* System command */
-#define ADIS16350_ALM_MAG1  0x26 /* Alarm 1 amplitude threshold */
-#define ADIS16350_ALM_MAG2  0x28 /* Alarm 2 amplitude threshold */
-#define ADIS16350_ALM_SMPL1 0x2A /* Alarm 1 sample size */
-#define ADIS16350_ALM_SMPL2 0x2C /* Alarm 2 sample size */
-#define ADIS16350_ALM_CTRL  0x2E /* Alarm control */
-#define ADIS16350_AUX_DAC   0x30 /* Auxiliary DAC data */
-
-#define ADIS16350_ERROR_ACTIVE                 (1<<14)
-#define ADIS16350_NEW_DATA                     (1<<15)
-
-/* MSC_CTRL */
-#define ADIS16350_MSC_CTRL_MEM_TEST            (1<<11)
-#define ADIS16350_MSC_CTRL_INT_SELF_TEST       (1<<10)
-#define ADIS16350_MSC_CTRL_NEG_SELF_TEST       (1<<9)
-#define ADIS16350_MSC_CTRL_POS_SELF_TEST       (1<<8)
-#define ADIS16350_MSC_CTRL_GYRO_BIAS           (1<<7)
-#define ADIS16350_MSC_CTRL_ACCL_ALIGN          (1<<6)
-#define ADIS16350_MSC_CTRL_DATA_RDY_EN         (1<<2)
-#define ADIS16350_MSC_CTRL_DATA_RDY_POL_HIGH   (1<<1)
-#define ADIS16350_MSC_CTRL_DATA_RDY_DIO2       (1<<0)
-
-/* SMPL_PRD */
-#define ADIS16350_SMPL_PRD_TIME_BASE   (1<<7)
-#define ADIS16350_SMPL_PRD_DIV_MASK    0x7F
-
-/* DIAG_STAT */
-#define ADIS16350_DIAG_STAT_ZACCL_FAIL (1<<15)
-#define ADIS16350_DIAG_STAT_YACCL_FAIL (1<<14)
-#define ADIS16350_DIAG_STAT_XACCL_FAIL (1<<13)
-#define ADIS16350_DIAG_STAT_XGYRO_FAIL (1<<12)
-#define ADIS16350_DIAG_STAT_YGYRO_FAIL (1<<11)
-#define ADIS16350_DIAG_STAT_ZGYRO_FAIL (1<<10)
-#define ADIS16350_DIAG_STAT_ALARM2     (1<<9)
-#define ADIS16350_DIAG_STAT_ALARM1     (1<<8)
-#define ADIS16350_DIAG_STAT_FLASH_CHK  (1<<6)
-#define ADIS16350_DIAG_STAT_SELF_TEST  (1<<5)
-#define ADIS16350_DIAG_STAT_OVERFLOW   (1<<4)
-#define ADIS16350_DIAG_STAT_SPI_FAIL   (1<<3)
-#define ADIS16350_DIAG_STAT_FLASH_UPT  (1<<2)
-#define ADIS16350_DIAG_STAT_POWER_HIGH (1<<1)
-#define ADIS16350_DIAG_STAT_POWER_LOW  (1<<0)
-
-/* GLOB_CMD */
-#define ADIS16350_GLOB_CMD_SW_RESET    (1<<7)
-#define ADIS16350_GLOB_CMD_P_AUTO_NULL (1<<4)
-#define ADIS16350_GLOB_CMD_FLASH_UPD   (1<<3)
-#define ADIS16350_GLOB_CMD_DAC_LATCH   (1<<2)
-#define ADIS16350_GLOB_CMD_FAC_CALIB   (1<<1)
-#define ADIS16350_GLOB_CMD_AUTO_NULL   (1<<0)
-
-/* SLP_CNT */
-#define ADIS16350_SLP_CNT_POWER_OFF    (1<<8)
-
-#define ADIS16350_MAX_TX 24
-#define ADIS16350_MAX_RX 24
-
-#define ADIS16350_SPI_SLOW     (u32)(300 * 1000)
-#define ADIS16350_SPI_BURST    (u32)(1000 * 1000)
-#define ADIS16350_SPI_FAST     (u32)(2000 * 1000)
-
-/**
- * struct adis16350_state - device instance specific data
- * @us:                        actual spi_device
- * @work_trigger_to_ring: bh for triggered event handling
- * @inter:             used to check if new interrupt has been triggered
- * @last_timestamp:    passing timestamp from th to bh of interrupt handler
- * @indio_dev:         industrial I/O device structure
- * @trig:              data ready trigger registered with iio
- * @tx:                        transmit buffer
- * @rx:                        receive buffer
- * @buf_lock:          mutex to protect tx and rx
- **/
-struct adis16350_state {
-       struct spi_device               *us;
-       struct work_struct              work_trigger_to_ring;
-       s64                             last_timestamp;
-       struct iio_dev                  *indio_dev;
-       struct iio_trigger              *trig;
-       u8                              *tx;
-       u8                              *rx;
-       struct mutex                    buf_lock;
-};
-
-int adis16350_set_irq(struct device *dev, bool enable);
-
-#ifdef CONFIG_IIO_RING_BUFFER
-
-#define ADIS16350_SCAN_SUPPLY  0
-#define ADIS16350_SCAN_GYRO_X  1
-#define ADIS16350_SCAN_GYRO_Y  2
-#define ADIS16350_SCAN_GYRO_Z  3
-#define ADIS16350_SCAN_ACC_X   4
-#define ADIS16350_SCAN_ACC_Y   5
-#define ADIS16350_SCAN_ACC_Z   6
-#define ADIS16350_SCAN_TEMP_X  7
-#define ADIS16350_SCAN_TEMP_Y  8
-#define ADIS16350_SCAN_TEMP_Z  9
-#define ADIS16350_SCAN_ADC_0   10
-
-void adis16350_remove_trigger(struct iio_dev *indio_dev);
-int adis16350_probe_trigger(struct iio_dev *indio_dev);
-
-ssize_t adis16350_read_data_from_ring(struct device *dev,
-                                     struct device_attribute *attr,
-                                     char *buf);
-
-
-int adis16350_configure_ring(struct iio_dev *indio_dev);
-void adis16350_unconfigure_ring(struct iio_dev *indio_dev);
-
-#else /* CONFIG_IIO_RING_BUFFER */
-
-static inline void adis16350_remove_trigger(struct iio_dev *indio_dev)
-{
-}
-
-static inline int adis16350_probe_trigger(struct iio_dev *indio_dev)
-{
-       return 0;
-}
-
-static inline ssize_t
-adis16350_read_data_from_ring(struct device *dev,
-                             struct device_attribute *attr,
-                             char *buf)
-{
-       return 0;
-}
-
-static inline int adis16350_configure_ring(struct iio_dev *indio_dev)
-{
-       return 0;
-}
-
-static inline void adis16350_unconfigure_ring(struct iio_dev *indio_dev)
-{
-}
-#endif /* CONFIG_IIO_RING_BUFFER */
-#endif /* SPI_ADIS16350_H_ */
diff --git a/drivers/staging/iio/imu/adis16350_core.c b/drivers/staging/iio/imu/adis16350_core.c
deleted file mode 100644 (file)
index cf7176b..0000000
+++ /dev/null
@@ -1,757 +0,0 @@
-/*
- * ADIS16350/54/55/60/62/64/65 high precision tri-axis inertial sensor
- *
- * Copyright 2010 Analog Devices Inc.
- *
- * Licensed under the GPL-2 or later.
- */
-
-#include <linux/interrupt.h>
-#include <linux/irq.h>
-#include <linux/gpio.h>
-#include <linux/delay.h>
-#include <linux/mutex.h>
-#include <linux/device.h>
-#include <linux/kernel.h>
-#include <linux/spi/spi.h>
-#include <linux/slab.h>
-#include <linux/sysfs.h>
-#include <linux/list.h>
-
-#include "../iio.h"
-#include "../sysfs.h"
-#include "../ring_generic.h"
-#include "../accel/accel.h"
-#include "../adc/adc.h"
-#include "../gyro/gyro.h"
-
-#include "adis16350.h"
-
-#define DRIVER_NAME            "adis16350"
-
-static int adis16350_check_status(struct device *dev);
-
-/**
- * adis16350_spi_write_reg_8() - write single byte to a register
- * @dev: device associated with child of actual device (iio_dev or iio_trig)
- * @reg_address: the address of the register to be written
- * @val: the value to write
- **/
-static int adis16350_spi_write_reg_8(struct device *dev,
-               u8 reg_address,
-               u8 val)
-{
-       int ret;
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
-       struct adis16350_state *st = iio_dev_get_devdata(indio_dev);
-
-       mutex_lock(&st->buf_lock);
-       st->tx[0] = ADIS16350_WRITE_REG(reg_address);
-       st->tx[1] = val;
-
-       ret = spi_write(st->us, st->tx, 2);
-       mutex_unlock(&st->buf_lock);
-
-       return ret;
-}
-
-/**
- * adis16350_spi_write_reg_16() - write 2 bytes to a pair of registers
- * @dev: device associated with child of actual device (iio_dev or iio_trig)
- * @reg_address: the address of the lower of the two registers. Second register
- *               is assumed to have address one greater.
- * @val: value to be written
- **/
-static int adis16350_spi_write_reg_16(struct device *dev,
-               u8 lower_reg_address,
-               u16 value)
-{
-       int ret;
-       struct spi_message msg;
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
-       struct adis16350_state *st = iio_dev_get_devdata(indio_dev);
-       struct spi_transfer xfers[] = {
-               {
-                       .tx_buf = st->tx,
-                       .bits_per_word = 8,
-                       .len = 2,
-                       .cs_change = 1,
-                       .delay_usecs = 35,
-               }, {
-                       .tx_buf = st->tx + 2,
-                       .bits_per_word = 8,
-                       .len = 2,
-                       .cs_change = 1,
-                       .delay_usecs = 35,
-               },
-       };
-
-       mutex_lock(&st->buf_lock);
-       st->tx[0] = ADIS16350_WRITE_REG(lower_reg_address);
-       st->tx[1] = value & 0xFF;
-       st->tx[2] = ADIS16350_WRITE_REG(lower_reg_address + 1);
-       st->tx[3] = (value >> 8) & 0xFF;
-
-       spi_message_init(&msg);
-       spi_message_add_tail(&xfers[0], &msg);
-       spi_message_add_tail(&xfers[1], &msg);
-       ret = spi_sync(st->us, &msg);
-       mutex_unlock(&st->buf_lock);
-
-       return ret;
-}
-
-/**
- * adis16350_spi_read_reg_16() - read 2 bytes from a 16-bit register
- * @dev: device associated with child of actual device (iio_dev or iio_trig)
- * @reg_address: the address of the lower of the two registers. Second register
- *               is assumed to have address one greater.
- * @val: somewhere to pass back the value read
- **/
-static int adis16350_spi_read_reg_16(struct device *dev,
-               u8 lower_reg_address,
-               u16 *val)
-{
-       struct spi_message msg;
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
-       struct adis16350_state *st = iio_dev_get_devdata(indio_dev);
-       int ret;
-       struct spi_transfer xfers[] = {
-               {
-                       .tx_buf = st->tx,
-                       .bits_per_word = 8,
-                       .len = 2,
-                       .cs_change = 1,
-                       .delay_usecs = 35,
-               }, {
-                       .rx_buf = st->rx,
-                       .bits_per_word = 8,
-                       .len = 2,
-                       .cs_change = 1,
-                       .delay_usecs = 35,
-               },
-       };
-
-       mutex_lock(&st->buf_lock);
-       st->tx[0] = ADIS16350_READ_REG(lower_reg_address);
-       st->tx[1] = 0;
-       st->tx[2] = 0;
-       st->tx[3] = 0;
-
-       spi_message_init(&msg);
-       spi_message_add_tail(&xfers[0], &msg);
-       spi_message_add_tail(&xfers[1], &msg);
-       ret = spi_sync(st->us, &msg);
-       if (ret) {
-               dev_err(&st->us->dev,
-                       "problem when reading 16 bit register 0x%02X",
-                       lower_reg_address);
-               goto error_ret;
-       }
-       *val = (st->rx[0] << 8) | st->rx[1];
-
-error_ret:
-       mutex_unlock(&st->buf_lock);
-       return ret;
-}
-
-
-static ssize_t adis16350_spi_read_signed(struct device *dev,
-               struct device_attribute *attr,
-               char *buf,
-               unsigned bits)
-{
-       int ret;
-       s16 val = 0;
-       unsigned shift = 16 - bits;
-       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-
-       ret = adis16350_spi_read_reg_16(dev, this_attr->address, (u16 *)&val);
-       if (ret)
-               return ret;
-
-       if (val & ADIS16350_ERROR_ACTIVE)
-               adis16350_check_status(dev);
-       val = ((s16)(val << shift) >> shift);
-       return sprintf(buf, "%d\n", val);
-}
-
-static ssize_t adis16350_read_12bit_unsigned(struct device *dev,
-               struct device_attribute *attr,
-               char *buf)
-{
-       int ret;
-       u16 val = 0;
-       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-
-       ret = adis16350_spi_read_reg_16(dev, this_attr->address, &val);
-       if (ret)
-               return ret;
-
-       if (val & ADIS16350_ERROR_ACTIVE)
-               adis16350_check_status(dev);
-
-       return sprintf(buf, "%u\n", val & 0x0FFF);
-}
-
-static ssize_t adis16350_read_14bit_signed(struct device *dev,
-               struct device_attribute *attr,
-               char *buf)
-{
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
-       ssize_t ret;
-
-       /* Take the iio_dev status lock */
-       mutex_lock(&indio_dev->mlock);
-       ret =  adis16350_spi_read_signed(dev, attr, buf, 14);
-       mutex_unlock(&indio_dev->mlock);
-
-       return ret;
-}
-
-static ssize_t adis16350_read_12bit_signed(struct device *dev,
-               struct device_attribute *attr,
-               char *buf)
-{
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
-       ssize_t ret;
-
-       /* Take the iio_dev status lock */
-       mutex_lock(&indio_dev->mlock);
-       ret =  adis16350_spi_read_signed(dev, attr, buf, 12);
-       mutex_unlock(&indio_dev->mlock);
-
-       return ret;
-}
-
-static ssize_t adis16350_write_16bit(struct device *dev,
-               struct device_attribute *attr,
-               const char *buf,
-               size_t len)
-{
-       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-       int ret;
-       long val;
-
-       ret = strict_strtol(buf, 10, &val);
-       if (ret)
-               goto error_ret;
-       ret = adis16350_spi_write_reg_16(dev, this_attr->address, val);
-
-error_ret:
-       return ret ? ret : len;
-}
-
-static ssize_t adis16350_read_frequency(struct device *dev,
-               struct device_attribute *attr,
-               char *buf)
-{
-       int ret, len = 0;
-       u16 t;
-       int sps;
-       ret = adis16350_spi_read_reg_16(dev,
-                       ADIS16350_SMPL_PRD,
-                       &t);
-       if (ret)
-               return ret;
-       sps =  (t & ADIS16350_SMPL_PRD_TIME_BASE) ? 53 : 1638;
-       sps /= (t & ADIS16350_SMPL_PRD_DIV_MASK) + 1;
-       len = sprintf(buf, "%d SPS\n", sps);
-       return len;
-}
-
-static ssize_t adis16350_write_frequency(struct device *dev,
-               struct device_attribute *attr,
-               const char *buf,
-               size_t len)
-{
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
-       struct adis16350_state *st = iio_dev_get_devdata(indio_dev);
-       long val;
-       int ret;
-       u8 t;
-
-       ret = strict_strtol(buf, 10, &val);
-       if (ret)
-               return ret;
-
-       mutex_lock(&indio_dev->mlock);
-
-       t = (1638 / val);
-       if (t > 0)
-               t--;
-       t &= ADIS16350_SMPL_PRD_DIV_MASK;
-       if ((t & ADIS16350_SMPL_PRD_DIV_MASK) >= 0x0A)
-               st->us->max_speed_hz = ADIS16350_SPI_SLOW;
-       else
-               st->us->max_speed_hz = ADIS16350_SPI_FAST;
-
-       ret = adis16350_spi_write_reg_8(dev,
-                       ADIS16350_SMPL_PRD,
-                       t);
-
-       mutex_unlock(&indio_dev->mlock);
-
-       return ret ? ret : len;
-}
-
-static int adis16350_reset(struct device *dev)
-{
-       int ret;
-       ret = adis16350_spi_write_reg_8(dev,
-                       ADIS16350_GLOB_CMD,
-                       ADIS16350_GLOB_CMD_SW_RESET);
-       if (ret)
-               dev_err(dev, "problem resetting device");
-
-       return ret;
-}
-
-static ssize_t adis16350_write_reset(struct device *dev,
-               struct device_attribute *attr,
-               const char *buf, size_t len)
-{
-       if (len < 1)
-               return -1;
-       switch (buf[0]) {
-       case '1':
-       case 'y':
-       case 'Y':
-               return adis16350_reset(dev);
-       }
-       return -1;
-}
-
-int adis16350_set_irq(struct device *dev, bool enable)
-{
-       int ret;
-       u16 msc;
-       ret = adis16350_spi_read_reg_16(dev, ADIS16350_MSC_CTRL, &msc);
-       if (ret)
-               goto error_ret;
-
-       msc |= ADIS16350_MSC_CTRL_DATA_RDY_POL_HIGH;
-       msc &= ~ADIS16350_MSC_CTRL_DATA_RDY_DIO2;
-
-       if (enable)
-               msc |= ADIS16350_MSC_CTRL_DATA_RDY_EN;
-       else
-               msc &= ~ADIS16350_MSC_CTRL_DATA_RDY_EN;
-
-       ret = adis16350_spi_write_reg_16(dev, ADIS16350_MSC_CTRL, msc);
-       if (ret)
-               goto error_ret;
-
-error_ret:
-       return ret;
-}
-
-/* Power down the device */
-static int adis16350_stop_device(struct device *dev)
-{
-       int ret;
-       u16 val = ADIS16350_SLP_CNT_POWER_OFF;
-
-       ret = adis16350_spi_write_reg_16(dev, ADIS16350_SLP_CNT, val);
-       if (ret)
-               dev_err(dev, "problem with turning device off: SLP_CNT");
-
-       return ret;
-}
-
-static int adis16350_self_test(struct device *dev)
-{
-       int ret;
-       ret = adis16350_spi_write_reg_16(dev,
-                       ADIS16350_MSC_CTRL,
-                       ADIS16350_MSC_CTRL_MEM_TEST);
-       if (ret) {
-               dev_err(dev, "problem starting self test");
-               goto err_ret;
-       }
-
-       adis16350_check_status(dev);
-
-err_ret:
-       return ret;
-}
-
-static int adis16350_check_status(struct device *dev)
-{
-       u16 status;
-       int ret;
-
-       ret = adis16350_spi_read_reg_16(dev, ADIS16350_DIAG_STAT, &status);
-
-       if (ret < 0) {
-               dev_err(dev, "Reading status failed\n");
-               goto error_ret;
-       }
-       ret = status;
-       if (status & ADIS16350_DIAG_STAT_ZACCL_FAIL)
-               dev_err(dev, "Z-axis accelerometer self-test failure\n");
-       if (status & ADIS16350_DIAG_STAT_YACCL_FAIL)
-               dev_err(dev, "Y-axis accelerometer self-test failure\n");
-       if (status & ADIS16350_DIAG_STAT_XACCL_FAIL)
-               dev_err(dev, "X-axis accelerometer self-test failure\n");
-       if (status & ADIS16350_DIAG_STAT_XGYRO_FAIL)
-               dev_err(dev, "X-axis gyroscope self-test failure\n");
-       if (status & ADIS16350_DIAG_STAT_YGYRO_FAIL)
-               dev_err(dev, "Y-axis gyroscope self-test failure\n");
-       if (status & ADIS16350_DIAG_STAT_ZGYRO_FAIL)
-               dev_err(dev, "Z-axis gyroscope self-test failure\n");
-       if (status & ADIS16350_DIAG_STAT_ALARM2)
-               dev_err(dev, "Alarm 2 active\n");
-       if (status & ADIS16350_DIAG_STAT_ALARM1)
-               dev_err(dev, "Alarm 1 active\n");
-       if (status & ADIS16350_DIAG_STAT_FLASH_CHK)
-               dev_err(dev, "Flash checksum error\n");
-       if (status & ADIS16350_DIAG_STAT_SELF_TEST)
-               dev_err(dev, "Self test error\n");
-       if (status & ADIS16350_DIAG_STAT_OVERFLOW)
-               dev_err(dev, "Sensor overrange\n");
-       if (status & ADIS16350_DIAG_STAT_SPI_FAIL)
-               dev_err(dev, "SPI failure\n");
-       if (status & ADIS16350_DIAG_STAT_FLASH_UPT)
-               dev_err(dev, "Flash update failed\n");
-       if (status & ADIS16350_DIAG_STAT_POWER_HIGH)
-               dev_err(dev, "Power supply above 5.25V\n");
-       if (status & ADIS16350_DIAG_STAT_POWER_LOW)
-               dev_err(dev, "Power supply below 4.75V\n");
-
-error_ret:
-       return ret;
-}
-
-static int adis16350_initial_setup(struct adis16350_state *st)
-{
-       int ret;
-       u16 smp_prd;
-       struct device *dev = &st->indio_dev->dev;
-
-       /* use low spi speed for init */
-       st->us->max_speed_hz = ADIS16350_SPI_SLOW;
-       st->us->mode = SPI_MODE_3;
-       spi_setup(st->us);
-
-       /* Disable IRQ */
-       ret = adis16350_set_irq(dev, false);
-       if (ret) {
-               dev_err(dev, "disable irq failed");
-               goto err_ret;
-       }
-
-       /* Do self test */
-       ret = adis16350_self_test(dev);
-       if (ret) {
-               dev_err(dev, "self test failure");
-               goto err_ret;
-       }
-
-       /* Read status register to check the result */
-       ret = adis16350_check_status(dev);
-       if (ret) {
-               adis16350_reset(dev);
-               dev_err(dev, "device not playing ball -> reset");
-               msleep(ADIS16350_STARTUP_DELAY);
-               ret = adis16350_check_status(dev);
-               if (ret) {
-                       dev_err(dev, "giving up");
-                       goto err_ret;
-               }
-       }
-
-       printk(KERN_INFO DRIVER_NAME ": at CS%d (irq %d)\n",
-                       st->us->chip_select, st->us->irq);
-
-       /* use high spi speed if possible */
-       ret = adis16350_spi_read_reg_16(dev, ADIS16350_SMPL_PRD, &smp_prd);
-       if (!ret && (smp_prd & ADIS16350_SMPL_PRD_DIV_MASK) < 0x0A) {
-               st->us->max_speed_hz = ADIS16350_SPI_SLOW;
-               spi_setup(st->us);
-       }
-
-err_ret:
-       return ret;
-}
-
-static IIO_DEV_ATTR_GYRO_X_CALIBBIAS(S_IWUSR | S_IRUGO,
-               adis16350_read_12bit_signed,
-               adis16350_write_16bit,
-               ADIS16350_XGYRO_OFF);
-
-static IIO_DEV_ATTR_GYRO_Y_CALIBBIAS(S_IWUSR | S_IRUGO,
-               adis16350_read_12bit_signed,
-               adis16350_write_16bit,
-               ADIS16350_YGYRO_OFF);
-
-static IIO_DEV_ATTR_GYRO_Z_CALIBBIAS(S_IWUSR | S_IRUGO,
-               adis16350_read_12bit_signed,
-               adis16350_write_16bit,
-               ADIS16350_ZGYRO_OFF);
-
-static IIO_DEV_ATTR_ACCEL_X_CALIBBIAS(S_IWUSR | S_IRUGO,
-               adis16350_read_12bit_signed,
-               adis16350_write_16bit,
-               ADIS16350_XACCL_OFF);
-
-static IIO_DEV_ATTR_ACCEL_Y_CALIBBIAS(S_IWUSR | S_IRUGO,
-               adis16350_read_12bit_signed,
-               adis16350_write_16bit,
-               ADIS16350_YACCL_OFF);
-
-static IIO_DEV_ATTR_ACCEL_Z_CALIBBIAS(S_IWUSR | S_IRUGO,
-               adis16350_read_12bit_signed,
-               adis16350_write_16bit,
-               ADIS16350_ZACCL_OFF);
-
-static IIO_DEV_ATTR_IN_NAMED_RAW(0, supply, adis16350_read_12bit_unsigned,
-               ADIS16350_SUPPLY_OUT);
-static IIO_CONST_ATTR_IN_NAMED_SCALE(0, supply, "0.002418");
-
-static IIO_DEV_ATTR_GYRO_X(adis16350_read_14bit_signed,
-               ADIS16350_XGYRO_OUT);
-static IIO_DEV_ATTR_GYRO_Y(adis16350_read_14bit_signed,
-               ADIS16350_YGYRO_OUT);
-static IIO_DEV_ATTR_GYRO_Z(adis16350_read_14bit_signed,
-               ADIS16350_ZGYRO_OUT);
-static IIO_CONST_ATTR_GYRO_SCALE("0.00127862821");
-
-static IIO_DEV_ATTR_ACCEL_X(adis16350_read_14bit_signed,
-               ADIS16350_XACCL_OUT);
-static IIO_DEV_ATTR_ACCEL_Y(adis16350_read_14bit_signed,
-               ADIS16350_YACCL_OUT);
-static IIO_DEV_ATTR_ACCEL_Z(adis16350_read_14bit_signed,
-               ADIS16350_ZACCL_OUT);
-static IIO_CONST_ATTR_ACCEL_SCALE("0.0247323713");
-
-static IIO_DEVICE_ATTR(temp_x_raw, S_IRUGO, adis16350_read_12bit_signed,
-               NULL, ADIS16350_XTEMP_OUT);
-static IIO_DEVICE_ATTR(temp_y_raw, S_IRUGO, adis16350_read_12bit_signed,
-               NULL, ADIS16350_YTEMP_OUT);
-static IIO_DEVICE_ATTR(temp_z_raw, S_IRUGO, adis16350_read_12bit_signed,
-               NULL, ADIS16350_ZTEMP_OUT);
-static IIO_CONST_ATTR_TEMP_SCALE("0.14534");
-static IIO_CONST_ATTR_TEMP_OFFSET("198.16");
-
-static IIO_DEV_ATTR_IN_RAW(1, adis16350_read_12bit_unsigned,
-               ADIS16350_AUX_ADC);
-static IIO_CONST_ATTR(in1_scale, "0.000806");
-
-static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO,
-               adis16350_read_frequency,
-               adis16350_write_frequency);
-
-static IIO_DEVICE_ATTR(reset, S_IWUSR, NULL,
-               adis16350_write_reset, 0);
-
-static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("409 546 819 1638");
-
-static IIO_CONST_ATTR_NAME("adis16350");
-
-static struct attribute *adis16350_attributes[] = {
-       &iio_dev_attr_gyro_x_calibbias.dev_attr.attr,
-       &iio_dev_attr_gyro_y_calibbias.dev_attr.attr,
-       &iio_dev_attr_gyro_z_calibbias.dev_attr.attr,
-       &iio_dev_attr_accel_x_calibbias.dev_attr.attr,
-       &iio_dev_attr_accel_y_calibbias.dev_attr.attr,
-       &iio_dev_attr_accel_z_calibbias.dev_attr.attr,
-       &iio_dev_attr_in0_supply_raw.dev_attr.attr,
-       &iio_const_attr_in0_supply_scale.dev_attr.attr,
-       &iio_dev_attr_gyro_x_raw.dev_attr.attr,
-       &iio_dev_attr_gyro_y_raw.dev_attr.attr,
-       &iio_dev_attr_gyro_z_raw.dev_attr.attr,
-       &iio_const_attr_gyro_scale.dev_attr.attr,
-       &iio_dev_attr_accel_x_raw.dev_attr.attr,
-       &iio_dev_attr_accel_y_raw.dev_attr.attr,
-       &iio_dev_attr_accel_z_raw.dev_attr.attr,
-       &iio_const_attr_accel_scale.dev_attr.attr,
-       &iio_dev_attr_temp_x_raw.dev_attr.attr,
-       &iio_dev_attr_temp_y_raw.dev_attr.attr,
-       &iio_dev_attr_temp_z_raw.dev_attr.attr,
-       &iio_const_attr_temp_scale.dev_attr.attr,
-       &iio_const_attr_temp_offset.dev_attr.attr,
-       &iio_dev_attr_in1_raw.dev_attr.attr,
-       &iio_const_attr_in1_scale.dev_attr.attr,
-       &iio_dev_attr_sampling_frequency.dev_attr.attr,
-       &iio_const_attr_sampling_frequency_available.dev_attr.attr,
-       &iio_dev_attr_reset.dev_attr.attr,
-       &iio_const_attr_name.dev_attr.attr,
-       NULL
-};
-
-static const struct attribute_group adis16350_attribute_group = {
-       .attrs = adis16350_attributes,
-};
-
-static struct attribute *adis16350_event_attributes[] = {
-       NULL,
-};
-
-static struct attribute_group adis16350_event_attribute_group = {
-       .attrs = adis16350_event_attributes,
-};
-
-static int __devinit adis16350_probe(struct spi_device *spi)
-{
-       int ret, regdone = 0;
-       struct adis16350_state *st = kzalloc(sizeof *st, GFP_KERNEL);
-       if (!st) {
-               ret =  -ENOMEM;
-               goto error_ret;
-       }
-       /* this is only used for removal purposes */
-       spi_set_drvdata(spi, st);
-
-       /* Allocate the comms buffers */
-       st->rx = kzalloc(sizeof(*st->rx)*ADIS16350_MAX_RX, GFP_KERNEL);
-       if (st->rx == NULL) {
-               ret = -ENOMEM;
-               goto error_free_st;
-       }
-       st->tx = kzalloc(sizeof(*st->tx)*ADIS16350_MAX_TX, GFP_KERNEL);
-       if (st->tx == NULL) {
-               ret = -ENOMEM;
-               goto error_free_rx;
-       }
-       st->us = spi;
-       mutex_init(&st->buf_lock);
-       /* setup the industrialio driver allocated elements */
-       st->indio_dev = iio_allocate_device();
-       if (st->indio_dev == NULL) {
-               ret = -ENOMEM;
-               goto error_free_tx;
-       }
-
-       st->indio_dev->dev.parent = &spi->dev;
-       st->indio_dev->num_interrupt_lines = 1;
-       st->indio_dev->event_attrs = &adis16350_event_attribute_group;
-       st->indio_dev->attrs = &adis16350_attribute_group;
-       st->indio_dev->dev_data = (void *)(st);
-       st->indio_dev->driver_module = THIS_MODULE;
-       st->indio_dev->modes = INDIO_DIRECT_MODE;
-
-       ret = adis16350_configure_ring(st->indio_dev);
-       if (ret)
-               goto error_free_dev;
-
-       ret = iio_device_register(st->indio_dev);
-       if (ret)
-               goto error_unreg_ring_funcs;
-       regdone = 1;
-
-       ret = iio_ring_buffer_register(st->indio_dev->ring, 0);
-       if (ret) {
-               printk(KERN_ERR "failed to initialize the ring\n");
-               goto error_unreg_ring_funcs;
-       }
-
-       if (spi->irq) {
-               ret = iio_register_interrupt_line(spi->irq,
-                               st->indio_dev,
-                               0,
-                               IRQF_TRIGGER_RISING,
-                               "adis16350");
-               if (ret)
-                       goto error_uninitialize_ring;
-
-               ret = adis16350_probe_trigger(st->indio_dev);
-               if (ret)
-                       goto error_unregister_line;
-       }
-
-       /* Get the device into a sane initial state */
-       ret = adis16350_initial_setup(st);
-       if (ret)
-               goto error_remove_trigger;
-       return 0;
-
-error_remove_trigger:
-       adis16350_remove_trigger(st->indio_dev);
-error_unregister_line:
-       if (spi->irq)
-               iio_unregister_interrupt_line(st->indio_dev, 0);
-error_uninitialize_ring:
-       iio_ring_buffer_unregister(st->indio_dev->ring);
-error_unreg_ring_funcs:
-       adis16350_unconfigure_ring(st->indio_dev);
-error_free_dev:
-       if (regdone)
-               iio_device_unregister(st->indio_dev);
-       else
-               iio_free_device(st->indio_dev);
-error_free_tx:
-       kfree(st->tx);
-error_free_rx:
-       kfree(st->rx);
-error_free_st:
-       kfree(st);
-error_ret:
-       return ret;
-}
-
-static int adis16350_remove(struct spi_device *spi)
-{
-       int ret;
-       struct adis16350_state *st = spi_get_drvdata(spi);
-       struct iio_dev *indio_dev = st->indio_dev;
-
-       ret = adis16350_stop_device(&(indio_dev->dev));
-       if (ret)
-               goto err_ret;
-
-       flush_scheduled_work();
-
-       adis16350_remove_trigger(indio_dev);
-       if (spi->irq)
-               iio_unregister_interrupt_line(indio_dev, 0);
-
-       iio_ring_buffer_unregister(indio_dev->ring);
-       iio_device_unregister(indio_dev);
-       adis16350_unconfigure_ring(indio_dev);
-       kfree(st->tx);
-       kfree(st->rx);
-       kfree(st);
-
-       return 0;
-
-err_ret:
-       return ret;
-}
-
-static const struct spi_device_id adis16350_id[] = {
-       {"adis16350", 0},
-       {"adis16354", 0},
-       {"adis16355", 0},
-       {"adis16360", 0},
-       {"adis16362", 0},
-       {"adis16364", 0},
-       {"adis16365", 0},
-       {}
-};
-
-static struct spi_driver adis16350_driver = {
-       .driver = {
-               .name = "adis16350",
-               .owner = THIS_MODULE,
-       },
-       .probe = adis16350_probe,
-       .remove = __devexit_p(adis16350_remove),
-       .id_table = adis16350_id,
-};
-
-static __init int adis16350_init(void)
-{
-       return spi_register_driver(&adis16350_driver);
-}
-module_init(adis16350_init);
-
-static __exit void adis16350_exit(void)
-{
-       spi_unregister_driver(&adis16350_driver);
-}
-module_exit(adis16350_exit);
-
-MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>");
-MODULE_DESCRIPTION("Analog Devices ADIS16350/54/55/60/62/64/65 IMU SPI driver");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/staging/iio/imu/adis16350_ring.c b/drivers/staging/iio/imu/adis16350_ring.c
deleted file mode 100644 (file)
index 56b70cf..0000000
+++ /dev/null
@@ -1,236 +0,0 @@
-#include <linux/interrupt.h>
-#include <linux/irq.h>
-#include <linux/gpio.h>
-#include <linux/workqueue.h>
-#include <linux/mutex.h>
-#include <linux/device.h>
-#include <linux/kernel.h>
-#include <linux/spi/spi.h>
-#include <linux/slab.h>
-#include <linux/sysfs.h>
-#include <linux/list.h>
-
-#include "../iio.h"
-#include "../sysfs.h"
-#include "../ring_sw.h"
-#include "../accel/accel.h"
-#include "../trigger.h"
-#include "adis16350.h"
-
-static IIO_SCAN_EL_C(in0_supply, ADIS16350_SCAN_SUPPLY,
-               ADIS16350_SUPPLY_OUT, NULL);
-static IIO_CONST_ATTR_SCAN_EL_TYPE(in0_supply, u, 12, 16);
-
-static IIO_SCAN_EL_C(gyro_x, ADIS16350_SCAN_GYRO_X, ADIS16350_XGYRO_OUT, NULL);
-static IIO_SCAN_EL_C(gyro_y, ADIS16350_SCAN_GYRO_Y, ADIS16350_YGYRO_OUT, NULL);
-static IIO_SCAN_EL_C(gyro_z, ADIS16350_SCAN_GYRO_Z, ADIS16350_ZGYRO_OUT, NULL);
-static IIO_CONST_ATTR_SCAN_EL_TYPE(gyro, s, 14, 16);
-
-static IIO_SCAN_EL_C(accel_x, ADIS16350_SCAN_ACC_X, ADIS16350_XACCL_OUT, NULL);
-static IIO_SCAN_EL_C(accel_y, ADIS16350_SCAN_ACC_Y, ADIS16350_YACCL_OUT, NULL);
-static IIO_SCAN_EL_C(accel_z, ADIS16350_SCAN_ACC_Z, ADIS16350_ZACCL_OUT, NULL);
-static IIO_CONST_ATTR_SCAN_EL_TYPE(accel, s, 14, 16);
-
-static IIO_SCAN_EL_C(temp_x, ADIS16350_SCAN_TEMP_X, ADIS16350_XTEMP_OUT, NULL);
-static IIO_SCAN_EL_C(temp_y, ADIS16350_SCAN_TEMP_Y, ADIS16350_YTEMP_OUT, NULL);
-static IIO_SCAN_EL_C(temp_z, ADIS16350_SCAN_TEMP_Z, ADIS16350_ZTEMP_OUT, NULL);
-static IIO_CONST_ATTR_SCAN_EL_TYPE(temp, s, 12, 16);
-
-static IIO_SCAN_EL_C(in1, ADIS16350_SCAN_ADC_0, ADIS16350_AUX_ADC, NULL);
-static IIO_CONST_ATTR_SCAN_EL_TYPE(in1, u, 12, 16);
-
-static IIO_SCAN_EL_TIMESTAMP(11);
-static IIO_CONST_ATTR_SCAN_EL_TYPE(timestamp, s, 64, 64);
-
-static struct attribute *adis16350_scan_el_attrs[] = {
-       &iio_scan_el_in0_supply.dev_attr.attr,
-       &iio_const_attr_in0_supply_index.dev_attr.attr,
-       &iio_const_attr_in0_supply_type.dev_attr.attr,
-       &iio_scan_el_gyro_x.dev_attr.attr,
-       &iio_const_attr_gyro_x_index.dev_attr.attr,
-       &iio_scan_el_gyro_y.dev_attr.attr,
-       &iio_const_attr_gyro_y_index.dev_attr.attr,
-       &iio_scan_el_gyro_z.dev_attr.attr,
-       &iio_const_attr_gyro_z_index.dev_attr.attr,
-       &iio_const_attr_gyro_type.dev_attr.attr,
-       &iio_scan_el_accel_x.dev_attr.attr,
-       &iio_const_attr_accel_x_index.dev_attr.attr,
-       &iio_scan_el_accel_y.dev_attr.attr,
-       &iio_const_attr_accel_y_index.dev_attr.attr,
-       &iio_scan_el_accel_z.dev_attr.attr,
-       &iio_const_attr_accel_z_index.dev_attr.attr,
-       &iio_const_attr_accel_type.dev_attr.attr,
-       &iio_scan_el_temp_x.dev_attr.attr,
-       &iio_const_attr_temp_x_index.dev_attr.attr,
-       &iio_scan_el_temp_y.dev_attr.attr,
-       &iio_const_attr_temp_y_index.dev_attr.attr,
-       &iio_scan_el_temp_z.dev_attr.attr,
-       &iio_const_attr_temp_z_index.dev_attr.attr,
-       &iio_const_attr_temp_type.dev_attr.attr,
-       &iio_scan_el_in1.dev_attr.attr,
-       &iio_const_attr_in1_index.dev_attr.attr,
-       &iio_const_attr_in1_type.dev_attr.attr,
-       &iio_scan_el_timestamp.dev_attr.attr,
-       &iio_const_attr_timestamp_index.dev_attr.attr,
-       &iio_const_attr_timestamp_type.dev_attr.attr,
-       NULL,
-};
-
-static struct attribute_group adis16350_scan_el_group = {
-       .attrs = adis16350_scan_el_attrs,
-       .name = "scan_elements",
-};
-
-/**
- * adis16350_poll_func_th() top half interrupt handler called by trigger
- * @private_data:      iio_dev
- **/
-static void adis16350_poll_func_th(struct iio_dev *indio_dev, s64 time)
-{
-       struct adis16350_state *st = iio_dev_get_devdata(indio_dev);
-       st->last_timestamp = time;
-       schedule_work(&st->work_trigger_to_ring);
-}
-
-/**
- * adis16350_spi_read_burst() - read all data registers
- * @dev: device associated with child of actual device (iio_dev or iio_trig)
- * @rx: somewhere to pass back the value read (min size is 24 bytes)
- **/
-static int adis16350_spi_read_burst(struct device *dev, u8 *rx)
-{
-       struct spi_message msg;
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
-       struct adis16350_state *st = iio_dev_get_devdata(indio_dev);
-       u32 old_speed_hz = st->us->max_speed_hz;
-       int ret;
-
-       struct spi_transfer xfers[] = {
-               {
-                       .tx_buf = st->tx,
-                       .bits_per_word = 8,
-                       .len = 2,
-                       .cs_change = 0,
-               }, {
-                       .rx_buf = rx,
-                       .bits_per_word = 8,
-                       .len = 22,
-                       .cs_change = 0,
-               },
-       };
-
-       mutex_lock(&st->buf_lock);
-       st->tx[0] = ADIS16350_READ_REG(ADIS16350_GLOB_CMD);
-       st->tx[1] = 0;
-
-       spi_message_init(&msg);
-       spi_message_add_tail(&xfers[0], &msg);
-       spi_message_add_tail(&xfers[1], &msg);
-
-       st->us->max_speed_hz = ADIS16350_SPI_BURST;
-       spi_setup(st->us);
-
-       ret = spi_sync(st->us, &msg);
-       if (ret)
-               dev_err(&st->us->dev, "problem when burst reading");
-
-       st->us->max_speed_hz = old_speed_hz;
-       spi_setup(st->us);
-       mutex_unlock(&st->buf_lock);
-       return ret;
-}
-
-/* Whilst this makes a lot of calls to iio_sw_ring functions - it is to device
- * specific to be rolled into the core.
- */
-static void adis16350_trigger_bh_to_ring(struct work_struct *work_s)
-{
-       struct adis16350_state *st
-               = container_of(work_s, struct adis16350_state,
-                              work_trigger_to_ring);
-       struct iio_ring_buffer *ring = st->indio_dev->ring;
-
-       int i = 0;
-       s16 *data;
-       size_t datasize = ring->access.get_bytes_per_datum(ring);
-
-       data = kmalloc(datasize , GFP_KERNEL);
-       if (data == NULL) {
-               dev_err(&st->us->dev, "memory alloc failed in ring bh");
-               return;
-       }
-
-       if (ring->scan_count)
-               if (adis16350_spi_read_burst(&st->indio_dev->dev, st->rx) >= 0)
-                       for (; i < ring->scan_count; i++)
-                               data[i] = be16_to_cpup(
-                                       (__be16 *)&(st->rx[i*2]));
-
-       /* Guaranteed to be aligned with 8 byte boundary */
-       if (ring->scan_timestamp)
-               *((s64 *)(data + ((i + 3)/4)*4)) = st->last_timestamp;
-
-       ring->access.store_to(ring,
-                       (u8 *)data,
-                       st->last_timestamp);
-
-       iio_trigger_notify_done(st->indio_dev->trig);
-       kfree(data);
-
-       return;
-}
-
-void adis16350_unconfigure_ring(struct iio_dev *indio_dev)
-{
-       kfree(indio_dev->pollfunc);
-       iio_sw_rb_free(indio_dev->ring);
-}
-
-int adis16350_configure_ring(struct iio_dev *indio_dev)
-{
-       int ret = 0;
-       struct adis16350_state *st = indio_dev->dev_data;
-       struct iio_ring_buffer *ring;
-       INIT_WORK(&st->work_trigger_to_ring, adis16350_trigger_bh_to_ring);
-
-       ring = iio_sw_rb_allocate(indio_dev);
-       if (!ring) {
-               ret = -ENOMEM;
-               return ret;
-       }
-       indio_dev->ring = ring;
-       /* Effectively select the ring buffer implementation */
-       iio_ring_sw_register_funcs(&ring->access);
-       ring->bpe = 2;
-       ring->scan_el_attrs = &adis16350_scan_el_group;
-       ring->scan_timestamp = true;
-       ring->preenable = &iio_sw_ring_preenable;
-       ring->postenable = &iio_triggered_ring_postenable;
-       ring->predisable = &iio_triggered_ring_predisable;
-       ring->owner = THIS_MODULE;
-
-       /* Set default scan mode */
-       iio_scan_mask_set(ring, iio_scan_el_in0_supply.number);
-       iio_scan_mask_set(ring, iio_scan_el_gyro_x.number);
-       iio_scan_mask_set(ring, iio_scan_el_gyro_y.number);
-       iio_scan_mask_set(ring, iio_scan_el_gyro_z.number);
-       iio_scan_mask_set(ring, iio_scan_el_accel_x.number);
-       iio_scan_mask_set(ring, iio_scan_el_accel_y.number);
-       iio_scan_mask_set(ring, iio_scan_el_accel_z.number);
-       iio_scan_mask_set(ring, iio_scan_el_temp_x.number);
-       iio_scan_mask_set(ring, iio_scan_el_temp_y.number);
-       iio_scan_mask_set(ring, iio_scan_el_temp_z.number);
-       iio_scan_mask_set(ring, iio_scan_el_in1.number);
-
-       ret = iio_alloc_pollfunc(indio_dev, NULL, &adis16350_poll_func_th);
-       if (ret)
-               goto error_iio_sw_rb_free;
-
-       indio_dev->modes |= INDIO_RING_TRIGGERED;
-       return 0;
-
-error_iio_sw_rb_free:
-       iio_sw_rb_free(indio_dev->ring);
-       return ret;
-}
-
diff --git a/drivers/staging/iio/imu/adis16350_trigger.c b/drivers/staging/iio/imu/adis16350_trigger.c
deleted file mode 100644 (file)
index 739b7ec..0000000
+++ /dev/null
@@ -1,125 +0,0 @@
-#include <linux/interrupt.h>
-#include <linux/irq.h>
-#include <linux/mutex.h>
-#include <linux/device.h>
-#include <linux/kernel.h>
-#include <linux/sysfs.h>
-#include <linux/list.h>
-#include <linux/spi/spi.h>
-
-#include "../iio.h"
-#include "../sysfs.h"
-#include "../trigger.h"
-#include "adis16350.h"
-
-/**
- * adis16350_data_rdy_trig_poll() the event handler for the data rdy trig
- **/
-static int adis16350_data_rdy_trig_poll(struct iio_dev *dev_info,
-                                      int index,
-                                      s64 timestamp,
-                                      int no_test)
-{
-       struct adis16350_state *st = iio_dev_get_devdata(dev_info);
-       struct iio_trigger *trig = st->trig;
-
-       iio_trigger_poll(trig, timestamp);
-
-       return IRQ_HANDLED;
-}
-
-IIO_EVENT_SH(data_rdy_trig, &adis16350_data_rdy_trig_poll);
-
-static IIO_TRIGGER_NAME_ATTR;
-
-static struct attribute *adis16350_trigger_attrs[] = {
-       &dev_attr_name.attr,
-       NULL,
-};
-
-static const struct attribute_group adis16350_trigger_attr_group = {
-       .attrs = adis16350_trigger_attrs,
-};
-
-/**
- * adis16350_data_rdy_trigger_set_state() set datardy interrupt state
- **/
-static int adis16350_data_rdy_trigger_set_state(struct iio_trigger *trig,
-                                               bool state)
-{
-       struct adis16350_state *st = trig->private_data;
-       struct iio_dev *indio_dev = st->indio_dev;
-       int ret = 0;
-
-       dev_dbg(&indio_dev->dev, "%s (%d)\n", __func__, state);
-       ret = adis16350_set_irq(&st->indio_dev->dev, state);
-       if (state == false) {
-               iio_remove_event_from_list(&iio_event_data_rdy_trig,
-                                          &indio_dev->interrupts[0]
-                                          ->ev_list);
-               /* possible quirk with handler currently worked around
-                  by ensuring the work queue is empty */
-               flush_scheduled_work();
-       } else {
-               iio_add_event_to_list(&iio_event_data_rdy_trig,
-                                     &indio_dev->interrupts[0]->ev_list);
-       }
-       return ret;
-}
-
-/**
- * adis16350_trig_try_reen() try renabling irq for data rdy trigger
- * @trig:      the datardy trigger
- **/
-static int adis16350_trig_try_reen(struct iio_trigger *trig)
-{
-       struct adis16350_state *st = trig->private_data;
-       enable_irq(st->us->irq);
-       /* irq reenabled so success! */
-       return 0;
-}
-
-int adis16350_probe_trigger(struct iio_dev *indio_dev)
-{
-       int ret;
-       struct adis16350_state *st = indio_dev->dev_data;
-
-       st->trig = iio_allocate_trigger();
-       st->trig->name = kasprintf(GFP_KERNEL,
-                                  "adis16350-dev%d",
-                                  indio_dev->id);
-       if (!st->trig->name) {
-               ret = -ENOMEM;
-               goto error_free_trig;
-       }
-       st->trig->dev.parent = &st->us->dev;
-       st->trig->owner = THIS_MODULE;
-       st->trig->private_data = st;
-       st->trig->set_trigger_state = &adis16350_data_rdy_trigger_set_state;
-       st->trig->try_reenable = &adis16350_trig_try_reen;
-       st->trig->control_attrs = &adis16350_trigger_attr_group;
-       ret = iio_trigger_register(st->trig);
-
-       /* select default trigger */
-       indio_dev->trig = st->trig;
-       if (ret)
-               goto error_free_trig_name;
-
-       return 0;
-
-error_free_trig_name:
-       kfree(st->trig->name);
-error_free_trig:
-       iio_free_trigger(st->trig);
-
-       return ret;
-}
-
-void adis16350_remove_trigger(struct iio_dev *indio_dev)
-{
-       struct adis16350_state *state = indio_dev->dev_data;
-
-       iio_trigger_unregister(state->trig);
-       kfree(state->trig->name);
-       iio_free_trigger(state->trig);
-}
index e328bcc5922ffd4d6a6219589a3100c24bec161f..db184d11dfc0ff85d12ee311cdb7d829d5f9334b 100644 (file)
 #define ADIS16400_TEMP_OUT  0x16 /* Temperature output */
 #define ADIS16400_AUX_ADC   0x18 /* Auxiliary ADC measurement */
 
+#define ADIS16350_XTEMP_OUT 0x10 /* X-axis gyroscope temperature measurement */
+#define ADIS16350_YTEMP_OUT 0x12 /* Y-axis gyroscope temperature measurement */
+#define ADIS16350_ZTEMP_OUT 0x14 /* Z-axis gyroscope temperature measurement */
+
 /* Calibration parameters */
 #define ADIS16400_XGYRO_OFF 0x1A /* X-axis gyroscope bias offset factor */
 #define ADIS16400_YGYRO_OFF 0x1C /* Y-axis gyroscope bias offset factor */
@@ -68,7 +72,6 @@
 #define ADIS16400_AUX_DAC   0x4A /* Auxiliary DAC data */
 
 #define ADIS16400_PRODUCT_ID 0x56 /* Product identifier */
-#define ADIS16400_PRODUCT_ID_DEFAULT 0x4015    /* Datasheet says 0x4105, I get 0x4015 */
 
 #define ADIS16400_ERROR_ACTIVE                 (1<<14)
 #define ADIS16400_NEW_DATA                     (1<<14)
 #define ADIS16400_SPI_BURST    (u32)(1000 * 1000)
 #define ADIS16400_SPI_FAST     (u32)(2000 * 1000)
 
+#define ADIS16400_HAS_PROD_ID 1
+#define ADIS16400_NO_BURST 2
+struct adis16400_chip_info {
+       const struct iio_chan_spec *channels;
+       const int num_channels;
+       const int product_id;
+       const long flags;
+       unsigned int gyro_scale_micro;
+       unsigned int accel_scale_micro;
+       unsigned long default_scan_mask;
+};
+
 /**
  * struct adis16400_state - device instance specific data
  * @us:                        actual spi_device
- * @work_trigger_to_ring: bh for triggered event handling
- * @inter:             used to check if new interrupt has been triggered
- * @last_timestamp:    passing timestamp from th to bh of interrupt handler
- * @indio_dev:         industrial I/O device structure
  * @trig:              data ready trigger registered with iio
  * @tx:                        transmit buffer
  * @rx:                        receive buffer
  **/
 struct adis16400_state {
        struct spi_device               *us;
-       struct work_struct              work_trigger_to_ring;
-       s64                             last_timestamp;
-       struct iio_dev                  *indio_dev;
        struct iio_trigger              *trig;
-       u8                              *tx;
-       u8                              *rx;
        struct mutex                    buf_lock;
+       struct adis16400_chip_info      *variant;
+
+       u8      tx[ADIS16400_MAX_TX] ____cacheline_aligned;
+       u8      rx[ADIS16400_MAX_RX] ____cacheline_aligned;
 };
 
-int adis16400_set_irq(struct device *dev, bool enable);
+int adis16400_set_irq(struct iio_dev *indio_dev, bool enable);
 
 #ifdef CONFIG_IIO_RING_BUFFER
 /* At the moment triggers are only used for ring buffer
@@ -161,10 +171,16 @@ int adis16400_set_irq(struct device *dev, bool enable);
 #define ADIS16400_SCAN_ACC_Y   5
 #define ADIS16400_SCAN_ACC_Z   6
 #define ADIS16400_SCAN_MAGN_X  7
+#define ADIS16350_SCAN_TEMP_X  7
 #define ADIS16400_SCAN_MAGN_Y  8
+#define ADIS16350_SCAN_TEMP_Y  8
 #define ADIS16400_SCAN_MAGN_Z  9
+#define ADIS16350_SCAN_TEMP_Z  9
 #define ADIS16400_SCAN_TEMP    10
+#define ADIS16350_SCAN_ADC_0   10
 #define ADIS16400_SCAN_ADC_0   11
+#define ADIS16300_SCAN_INCLI_X 12
+#define ADIS16300_SCAN_INCLI_Y 13
 
 void adis16400_remove_trigger(struct iio_dev *indio_dev);
 int adis16400_probe_trigger(struct iio_dev *indio_dev);
index 540bde69cc3b8451c4a4805541542025e5b2759c..fe89802e3fe7b0cccd197f50d5fb2a51de7be2ce 100644 (file)
 
 #define DRIVER_NAME            "adis16400"
 
-static int adis16400_check_status(struct device *dev);
+enum adis16400_chip_variant {
+       ADIS16300,
+       ADIS16350,
+       ADIS16360,
+       ADIS16362,
+       ADIS16364,
+       ADIS16365,
+       ADIS16400,
+};
+
+static int adis16400_check_status(struct iio_dev *indio_dev);
 
 /* At the moment the spi framework doesn't allow global setting of cs_change.
  * It's in the likely to be added comment at the top of spi.h.
@@ -51,13 +61,12 @@ static int adis16400_check_status(struct device *dev);
  * @reg_address: the address of the register to be written
  * @val: the value to write
  **/
-static int adis16400_spi_write_reg_8(struct device *dev,
-               u8 reg_address,
-               u8 val)
+static int adis16400_spi_write_reg_8(struct iio_dev *indio_dev,
+                                    u8 reg_address,
+                                    u8 val)
 {
        int ret;
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
-       struct adis16400_state *st = iio_dev_get_devdata(indio_dev);
+       struct adis16400_state *st = iio_priv(indio_dev);
 
        mutex_lock(&st->buf_lock);
        st->tx[0] = ADIS16400_WRITE_REG(reg_address);
@@ -76,14 +85,13 @@ static int adis16400_spi_write_reg_8(struct device *dev,
  *               is assumed to have address one greater.
  * @val: value to be written
  **/
-static int adis16400_spi_write_reg_16(struct device *dev,
+static int adis16400_spi_write_reg_16(struct iio_dev *indio_dev,
                u8 lower_reg_address,
                u16 value)
 {
        int ret;
        struct spi_message msg;
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
-       struct adis16400_state *st = iio_dev_get_devdata(indio_dev);
+       struct adis16400_state *st = iio_priv(indio_dev);
        struct spi_transfer xfers[] = {
                {
                        .tx_buf = st->tx,
@@ -114,18 +122,17 @@ static int adis16400_spi_write_reg_16(struct device *dev,
 
 /**
  * adis16400_spi_read_reg_16() - read 2 bytes from a 16-bit register
- * @dev: device associated with child of actual device (iio_dev or iio_trig)
+ * @indio_dev: iio device
  * @reg_address: the address of the lower of the two registers. Second register
  *               is assumed to have address one greater.
  * @val: somewhere to pass back the value read
  **/
-static int adis16400_spi_read_reg_16(struct device *dev,
+static int adis16400_spi_read_reg_16(struct iio_dev *indio_dev,
                u8 lower_reg_address,
                u16 *val)
 {
        struct spi_message msg;
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
-       struct adis16400_state *st = iio_dev_get_devdata(indio_dev);
+       struct adis16400_state *st = iio_priv(indio_dev);
        int ret;
        struct spi_transfer xfers[] = {
                {
@@ -163,100 +170,15 @@ error_ret:
        return ret;
 }
 
-static ssize_t adis16400_spi_read_signed(struct device *dev,
-               struct device_attribute *attr,
-               char *buf,
-               unsigned bits)
-{
-       int ret;
-       s16 val = 0;
-       unsigned shift = 16 - bits;
-       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-
-       ret = adis16400_spi_read_reg_16(dev, this_attr->address, (u16 *)&val);
-       if (ret)
-               return ret;
-
-       if (val & ADIS16400_ERROR_ACTIVE)
-               adis16400_check_status(dev);
-       val = ((s16)(val << shift) >> shift);
-       return sprintf(buf, "%d\n", val);
-}
-
-static ssize_t adis16400_read_12bit_unsigned(struct device *dev,
-               struct device_attribute *attr,
-               char *buf)
-{
-       int ret;
-       u16 val = 0;
-       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-
-       ret = adis16400_spi_read_reg_16(dev, this_attr->address, &val);
-       if (ret)
-               return ret;
-
-       if (val & ADIS16400_ERROR_ACTIVE)
-               adis16400_check_status(dev);
-
-       return sprintf(buf, "%u\n", val & 0x0FFF);
-}
-
-static ssize_t adis16400_read_14bit_signed(struct device *dev,
-               struct device_attribute *attr,
-               char *buf)
-{
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
-       ssize_t ret;
-
-       /* Take the iio_dev status lock */
-       mutex_lock(&indio_dev->mlock);
-       ret =  adis16400_spi_read_signed(dev, attr, buf, 14);
-       mutex_unlock(&indio_dev->mlock);
-
-       return ret;
-}
-
-static ssize_t adis16400_read_12bit_signed(struct device *dev,
-               struct device_attribute *attr,
-               char *buf)
-{
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
-       ssize_t ret;
-
-       /* Take the iio_dev status lock */
-       mutex_lock(&indio_dev->mlock);
-       ret =  adis16400_spi_read_signed(dev, attr, buf, 12);
-       mutex_unlock(&indio_dev->mlock);
-
-       return ret;
-}
-
-static ssize_t adis16400_write_16bit(struct device *dev,
-               struct device_attribute *attr,
-               const char *buf,
-               size_t len)
-{
-       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-       int ret;
-       long val;
-
-       ret = strict_strtol(buf, 10, &val);
-       if (ret)
-               goto error_ret;
-       ret = adis16400_spi_write_reg_16(dev, this_attr->address, val);
-
-error_ret:
-       return ret ? ret : len;
-}
-
 static ssize_t adis16400_read_frequency(struct device *dev,
                struct device_attribute *attr,
                char *buf)
 {
+       struct iio_dev *indio_dev = dev_get_drvdata(dev);
        int ret, len = 0;
        u16 t;
        int sps;
-       ret = adis16400_spi_read_reg_16(dev,
+       ret = adis16400_spi_read_reg_16(indio_dev,
                        ADIS16400_SMPL_PRD,
                        &t);
        if (ret)
@@ -273,7 +195,7 @@ static ssize_t adis16400_write_frequency(struct device *dev,
                size_t len)
 {
        struct iio_dev *indio_dev = dev_get_drvdata(dev);
-       struct adis16400_state *st = iio_dev_get_devdata(indio_dev);
+       struct adis16400_state *st = iio_priv(indio_dev);
        long val;
        int ret;
        u8 t;
@@ -293,7 +215,7 @@ static ssize_t adis16400_write_frequency(struct device *dev,
        else
                st->us->max_speed_hz = ADIS16400_SPI_FAST;
 
-       ret = adis16400_spi_write_reg_8(dev,
+       ret = adis16400_spi_write_reg_8(indio_dev,
                        ADIS16400_SMPL_PRD,
                        t);
 
@@ -302,14 +224,14 @@ static ssize_t adis16400_write_frequency(struct device *dev,
        return ret ? ret : len;
 }
 
-static int adis16400_reset(struct device *dev)
+static int adis16400_reset(struct iio_dev *indio_dev)
 {
        int ret;
-       ret = adis16400_spi_write_reg_8(dev,
+       ret = adis16400_spi_write_reg_8(indio_dev,
                        ADIS16400_GLOB_CMD,
                        ADIS16400_GLOB_CMD_SW_RESET);
        if (ret)
-               dev_err(dev, "problem resetting device");
+               dev_err(&indio_dev->dev, "problem resetting device");
 
        return ret;
 }
@@ -318,22 +240,24 @@ static ssize_t adis16400_write_reset(struct device *dev,
                struct device_attribute *attr,
                const char *buf, size_t len)
 {
+       struct iio_dev *indio_dev = dev_get_drvdata(dev);
+
        if (len < 1)
                return -1;
        switch (buf[0]) {
        case '1':
        case 'y':
        case 'Y':
-               return adis16400_reset(dev);
+               return adis16400_reset(indio_dev);
        }
        return -1;
 }
 
-int adis16400_set_irq(struct device *dev, bool enable)
+int adis16400_set_irq(struct iio_dev *indio_dev, bool enable)
 {
        int ret;
        u16 msc;
-       ret = adis16400_spi_read_reg_16(dev, ADIS16400_MSC_CTRL, &msc);
+       ret = adis16400_spi_read_reg_16(indio_dev, ADIS16400_MSC_CTRL, &msc);
        if (ret)
                goto error_ret;
 
@@ -343,7 +267,7 @@ int adis16400_set_irq(struct device *dev, bool enable)
        else
                msc &= ~ADIS16400_MSC_CTRL_DATA_RDY_EN;
 
-       ret = adis16400_spi_write_reg_16(dev, ADIS16400_MSC_CTRL, msc);
+       ret = adis16400_spi_write_reg_16(indio_dev, ADIS16400_MSC_CTRL, msc);
        if (ret)
                goto error_ret;
 
@@ -352,41 +276,45 @@ error_ret:
 }
 
 /* Power down the device */
-static int adis16400_stop_device(struct device *dev)
+static int adis16400_stop_device(struct iio_dev *indio_dev)
 {
        int ret;
        u16 val = ADIS16400_SLP_CNT_POWER_OFF;
 
-       ret = adis16400_spi_write_reg_16(dev, ADIS16400_SLP_CNT, val);
+       ret = adis16400_spi_write_reg_16(indio_dev, ADIS16400_SLP_CNT, val);
        if (ret)
-               dev_err(dev, "problem with turning device off: SLP_CNT");
+               dev_err(&indio_dev->dev,
+                       "problem with turning device off: SLP_CNT");
 
        return ret;
 }
 
-static int adis16400_self_test(struct device *dev)
+static int adis16400_self_test(struct iio_dev *indio_dev)
 {
        int ret;
-       ret = adis16400_spi_write_reg_16(dev,
+       ret = adis16400_spi_write_reg_16(indio_dev,
                        ADIS16400_MSC_CTRL,
                        ADIS16400_MSC_CTRL_MEM_TEST);
        if (ret) {
-               dev_err(dev, "problem starting self test");
+               dev_err(&indio_dev->dev, "problem starting self test");
                goto err_ret;
        }
+
        msleep(ADIS16400_MTEST_DELAY);
-       adis16400_check_status(dev);
+       adis16400_check_status(indio_dev);
 
 err_ret:
        return ret;
 }
 
-static int adis16400_check_status(struct device *dev)
+static int adis16400_check_status(struct iio_dev *indio_dev)
 {
        u16 status;
        int ret;
+       struct device *dev = &indio_dev->dev;
 
-       ret = adis16400_spi_read_reg_16(dev, ADIS16400_DIAG_STAT, &status);
+       ret = adis16400_spi_read_reg_16(indio_dev,
+                                       ADIS16400_DIAG_STAT, &status);
 
        if (ret < 0) {
                dev_err(dev, "Reading status failed\n");
@@ -428,11 +356,12 @@ error_ret:
        return ret;
 }
 
-static int adis16400_initial_setup(struct adis16400_state *st)
+static int adis16400_initial_setup(struct iio_dev *indio_dev)
 {
        int ret;
        u16 prod_id, smp_prd;
-       struct device *dev = &st->indio_dev->dev;
+       struct device *dev = &indio_dev->dev;
+       struct adis16400_state *st = iio_priv(indio_dev);
 
        /* use low spi speed for init */
        st->us->max_speed_hz = ADIS16400_SPI_SLOW;
@@ -440,45 +369,46 @@ static int adis16400_initial_setup(struct adis16400_state *st)
        spi_setup(st->us);
 
        /* Disable IRQ */
-       ret = adis16400_set_irq(dev, false);
+       ret = adis16400_set_irq(indio_dev, false);
        if (ret) {
                dev_err(dev, "disable irq failed");
                goto err_ret;
        }
 
        /* Do self test */
-       ret = adis16400_self_test(dev);
+       ret = adis16400_self_test(indio_dev);
        if (ret) {
                dev_err(dev, "self test failure");
                goto err_ret;
        }
 
        /* Read status register to check the result */
-       ret = adis16400_check_status(dev);
+       ret = adis16400_check_status(indio_dev);
        if (ret) {
-               adis16400_reset(dev);
+               adis16400_reset(indio_dev);
                dev_err(dev, "device not playing ball -> reset");
                msleep(ADIS16400_STARTUP_DELAY);
-               ret = adis16400_check_status(dev);
+               ret = adis16400_check_status(indio_dev);
                if (ret) {
                        dev_err(dev, "giving up");
                        goto err_ret;
                }
        }
+       if (st->variant->flags & ADIS16400_HAS_PROD_ID) {
+               ret = adis16400_spi_read_reg_16(indio_dev,
+                                               ADIS16400_PRODUCT_ID, &prod_id);
+               if (ret)
+                       goto err_ret;
 
-       ret = adis16400_spi_read_reg_16(dev, ADIS16400_PRODUCT_ID, &prod_id);
-       if (ret)
-               goto err_ret;
-
-       if ((prod_id & 0xF000) != ADIS16400_PRODUCT_ID_DEFAULT)
-               dev_warn(dev, "unknown product id");
-
-
-       dev_info(dev, ": prod_id 0x%04x at CS%d (irq %d)\n",
-                       prod_id, st->us->chip_select, st->us->irq);
+               if ((prod_id & 0xF000) != st->variant->product_id)
+                       dev_warn(dev, "incorrect id");
 
+               printk(KERN_INFO DRIVER_NAME ": prod_id 0x%04x at CS%d (irq %d)\n",
+                      prod_id, st->us->chip_select, st->us->irq);
+       }
        /* use high spi speed if possible */
-       ret = adis16400_spi_read_reg_16(dev, ADIS16400_SMPL_PRD, &smp_prd);
+       ret = adis16400_spi_read_reg_16(indio_dev,
+                                       ADIS16400_SMPL_PRD, &smp_prd);
        if (!ret && (smp_prd & ADIS16400_SMPL_PRD_DIV_MASK) < 0x0A) {
                st->us->max_speed_hz = ADIS16400_SPI_SLOW;
                spi_setup(st->us);
@@ -490,58 +420,6 @@ err_ret:
        return ret;
 }
 
-#define ADIS16400_DEV_ATTR_CALIBBIAS(_channel, _reg)           \
-       IIO_DEV_ATTR_##_channel##_CALIBBIAS(S_IWUSR | S_IRUGO,  \
-                       adis16400_read_12bit_signed,            \
-                       adis16400_write_16bit,                  \
-                       _reg)
-
-static ADIS16400_DEV_ATTR_CALIBBIAS(GYRO_X, ADIS16400_XGYRO_OFF);
-static ADIS16400_DEV_ATTR_CALIBBIAS(GYRO_Y, ADIS16400_YGYRO_OFF);
-static ADIS16400_DEV_ATTR_CALIBBIAS(GYRO_Z, ADIS16400_ZGYRO_OFF);
-
-static ADIS16400_DEV_ATTR_CALIBBIAS(ACCEL_X, ADIS16400_XACCL_OFF);
-static ADIS16400_DEV_ATTR_CALIBBIAS(ACCEL_Y, ADIS16400_YACCL_OFF);
-static ADIS16400_DEV_ATTR_CALIBBIAS(ACCEL_Z, ADIS16400_ZACCL_OFF);
-
-
-static IIO_DEV_ATTR_IN_NAMED_RAW(0, supply, adis16400_read_14bit_signed,
-               ADIS16400_SUPPLY_OUT);
-static IIO_CONST_ATTR_IN_NAMED_SCALE(0, supply, "0.002418 V");
-
-static IIO_DEV_ATTR_GYRO_X(adis16400_read_14bit_signed,
-               ADIS16400_XGYRO_OUT);
-static IIO_DEV_ATTR_GYRO_Y(adis16400_read_14bit_signed,
-               ADIS16400_YGYRO_OUT);
-static IIO_DEV_ATTR_GYRO_Z(adis16400_read_14bit_signed,
-               ADIS16400_ZGYRO_OUT);
-static IIO_CONST_ATTR(gyro_scale, "0.0008726646");
-
-static IIO_DEV_ATTR_ACCEL_X(adis16400_read_14bit_signed,
-               ADIS16400_XACCL_OUT);
-static IIO_DEV_ATTR_ACCEL_Y(adis16400_read_14bit_signed,
-               ADIS16400_YACCL_OUT);
-static IIO_DEV_ATTR_ACCEL_Z(adis16400_read_14bit_signed,
-               ADIS16400_ZACCL_OUT);
-static IIO_CONST_ATTR(accel_scale, "0.0326561445");
-
-static IIO_DEV_ATTR_MAGN_X(adis16400_read_14bit_signed,
-               ADIS16400_XMAGN_OUT);
-static IIO_DEV_ATTR_MAGN_Y(adis16400_read_14bit_signed,
-               ADIS16400_YMAGN_OUT);
-static IIO_DEV_ATTR_MAGN_Z(adis16400_read_14bit_signed,
-               ADIS16400_ZMAGN_OUT);
-static IIO_CONST_ATTR(magn_scale, "0.0005 Gs");
-
-
-static IIO_DEV_ATTR_TEMP_RAW(adis16400_read_12bit_signed);
-static IIO_CONST_ATTR_TEMP_OFFSET("198.16 K");
-static IIO_CONST_ATTR_TEMP_SCALE("0.14 K");
-
-static IIO_DEV_ATTR_IN_RAW(1, adis16400_read_12bit_unsigned,
-               ADIS16400_AUX_ADC);
-static IIO_CONST_ATTR(in1_scale, "0.000806 V");
-
 static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO,
                adis16400_read_frequency,
                adis16400_write_frequency);
@@ -550,46 +428,273 @@ static IIO_DEVICE_ATTR(reset, S_IWUSR, NULL, adis16400_write_reset, 0);
 
 static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("409 546 819 1638");
 
-static IIO_CONST_ATTR_NAME("adis16400");
+enum adis16400_chan {
+       in_supply,
+       gyro_x,
+       gyro_y,
+       gyro_z,
+       accel_x,
+       accel_y,
+       accel_z,
+       magn_x,
+       magn_y,
+       magn_z,
+       temp,
+       temp0, temp1, temp2,
+       in1
+};
 
-static struct attribute *adis16400_event_attributes[] = {
-       NULL
+static u8 adis16400_addresses[16][2] = {
+       [in_supply] = { ADIS16400_SUPPLY_OUT, 0 },
+       [gyro_x] = { ADIS16400_XGYRO_OUT, ADIS16400_XGYRO_OFF },
+       [gyro_y] = { ADIS16400_YGYRO_OUT, ADIS16400_YGYRO_OFF },
+       [gyro_z] = { ADIS16400_ZGYRO_OUT, ADIS16400_ZGYRO_OFF },
+       [accel_x] = { ADIS16400_XACCL_OUT, ADIS16400_XACCL_OFF },
+       [accel_y] = { ADIS16400_YACCL_OUT, ADIS16400_YACCL_OFF },
+       [accel_z] = { ADIS16400_ZACCL_OUT, ADIS16400_ZACCL_OFF },
+       [magn_x] = { ADIS16400_XMAGN_OUT, 0 },
+       [magn_y] = { ADIS16400_YMAGN_OUT, 0 },
+       [magn_z] = { ADIS16400_ZMAGN_OUT, 0 },
+       [temp] = { ADIS16400_TEMP_OUT, 0 },
+       [temp0] = { ADIS16350_XTEMP_OUT },
+       [temp1] = { ADIS16350_YTEMP_OUT },
+       [temp2] = { ADIS16350_ZTEMP_OUT },
+       [in1] = { ADIS16400_AUX_ADC , 0 },
 };
 
-static struct attribute_group adis16400_event_attribute_group = {
-       .attrs = adis16400_event_attributes,
+static int adis16400_write_raw(struct iio_dev *indio_dev,
+                              struct iio_chan_spec const *chan,
+                              int val,
+                              int val2,
+                              long mask)
+{
+       int ret;
+       switch (mask) {
+       case (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE):
+               mutex_lock(&indio_dev->mlock);
+               ret = adis16400_spi_write_reg_16(indio_dev,
+                               adis16400_addresses[chan->address][1],
+                               val);
+               mutex_unlock(&indio_dev->mlock);
+               return ret;
+       default:
+               return -EINVAL;
+       }
+}
+
+static int adis16400_read_raw(struct iio_dev *indio_dev,
+                             struct iio_chan_spec const *chan,
+                             int *val,
+                             int *val2,
+                             long mask)
+{
+       struct adis16400_state *st = iio_priv(indio_dev);
+       int ret;
+       s16 val16;
+       int shift;
+
+       switch (mask) {
+       case 0:
+               mutex_lock(&indio_dev->mlock);
+               ret = adis16400_spi_read_reg_16(indio_dev,
+                               adis16400_addresses[chan->address][0],
+                               &val16);
+               if (ret) {
+                       mutex_unlock(&indio_dev->mlock);
+                       return ret;
+               }
+               val16 &= (1 << chan->scan_type.realbits) - 1;
+               if (chan->scan_type.sign == 's') {
+                       shift = 16 - chan->scan_type.realbits;
+                       val16 = (s16)(val16 << shift) >> shift;
+               }
+               *val = val16;
+               mutex_unlock(&indio_dev->mlock);
+               return IIO_VAL_INT;
+       case (1 << IIO_CHAN_INFO_SCALE_SHARED):
+       case (1 << IIO_CHAN_INFO_SCALE_SEPARATE):
+               switch (chan->type) {
+               case IIO_GYRO:
+                       *val = 0;
+                       *val2 = st->variant->gyro_scale_micro;
+                       return IIO_VAL_INT_PLUS_MICRO;
+               case IIO_IN:
+                       *val = 0;
+                       if (chan->channel == 0)
+                               *val2 = 2418;
+                       else
+                               *val2 = 806;
+                       return IIO_VAL_INT_PLUS_MICRO;
+               case IIO_ACCEL:
+                       *val = 0;
+                       *val2 = st->variant->accel_scale_micro;
+                       return IIO_VAL_INT_PLUS_MICRO;
+               case IIO_MAGN:
+                       *val = 0;
+                       *val2 = 500;
+                       return IIO_VAL_INT_PLUS_MICRO;
+               case IIO_TEMP:
+                       *val = 0;
+                       *val2 = 140000;
+                       return IIO_VAL_INT_PLUS_MICRO;
+               default:
+                       return -EINVAL;
+               }
+       case (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE):
+               mutex_lock(&indio_dev->mlock);
+               ret = adis16400_spi_read_reg_16(indio_dev,
+                               adis16400_addresses[chan->address][1],
+                               &val16);
+               mutex_unlock(&indio_dev->mlock);
+               if (ret)
+                       return ret;
+               val16 = ((val16 & 0xFFF) << 4) >> 4;
+               *val = val16;
+               return IIO_VAL_INT;
+       case (1 << IIO_CHAN_INFO_OFFSET_SEPARATE):
+               /* currently only temperature */
+               *val = 198;
+               *val2 = 160000;
+               return IIO_VAL_INT_PLUS_MICRO;
+       default:
+               return -EINVAL;
+       }
+}
+
+static struct iio_chan_spec adis16400_channels[] = {
+       IIO_CHAN(IIO_IN, 0, 1, 0, "supply", 0, 0,
+                (1 << IIO_CHAN_INFO_SCALE_SEPARATE),
+                in_supply, ADIS16400_SCAN_SUPPLY,
+                IIO_ST('u', 14, 16, 0), 0),
+       IIO_CHAN(IIO_GYRO, 1, 0, 0, NULL, 0, IIO_MOD_X,
+                (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) |
+                (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                gyro_x, ADIS16400_SCAN_GYRO_X, IIO_ST('s', 14, 16, 0), 0),
+       IIO_CHAN(IIO_GYRO, 1, 0, 0, NULL, 0, IIO_MOD_Y,
+                (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) |
+                (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                gyro_y, ADIS16400_SCAN_GYRO_Y, IIO_ST('s', 14, 16, 0), 0),
+       IIO_CHAN(IIO_GYRO, 1, 0, 0, NULL, 0, IIO_MOD_Z,
+                (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) |
+                (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                gyro_z, ADIS16400_SCAN_GYRO_Z, IIO_ST('s', 14, 16, 0), 0),
+       IIO_CHAN(IIO_ACCEL, 1, 0, 0, NULL, 0, IIO_MOD_X,
+                (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) |
+                (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                accel_x, ADIS16400_SCAN_ACC_X, IIO_ST('s', 14, 16, 0), 0),
+       IIO_CHAN(IIO_ACCEL, 1, 0, 0, NULL, 0, IIO_MOD_Y,
+                (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) |
+                (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                accel_y, ADIS16400_SCAN_ACC_Y, IIO_ST('s', 14, 16, 0), 0),
+       IIO_CHAN(IIO_ACCEL, 1, 0, 0, NULL, 0, IIO_MOD_Z,
+                (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) |
+                (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                accel_z, ADIS16400_SCAN_ACC_Z, IIO_ST('s', 14, 16, 0), 0),
+       IIO_CHAN(IIO_MAGN, 1, 0, 0, NULL, 0, IIO_MOD_X,
+                (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                magn_x, ADIS16400_SCAN_MAGN_X, IIO_ST('s', 14, 16, 0), 0),
+       IIO_CHAN(IIO_MAGN, 1, 0, 0, NULL, 0, IIO_MOD_Y,
+                (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                magn_y, ADIS16400_SCAN_MAGN_Y, IIO_ST('s', 14, 16, 0), 0),
+       IIO_CHAN(IIO_MAGN, 1, 0, 0, NULL, 0, IIO_MOD_Z,
+                (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                magn_z, ADIS16400_SCAN_MAGN_Z, IIO_ST('s', 14, 16, 0), 0),
+       IIO_CHAN(IIO_TEMP, 0, 1, 0, NULL, 0, 0,
+                (1 << IIO_CHAN_INFO_OFFSET_SEPARATE) |
+                (1 << IIO_CHAN_INFO_SCALE_SEPARATE),
+                temp, ADIS16400_SCAN_TEMP, IIO_ST('s', 12, 16, 0), 0),
+       IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 1, 0,
+                (1 << IIO_CHAN_INFO_SCALE_SEPARATE),
+                in1, ADIS16400_SCAN_ADC_0, IIO_ST('s', 12, 16, 0), 0),
+       IIO_CHAN_SOFT_TIMESTAMP(12)
+};
+
+static struct iio_chan_spec adis16350_channels[] = {
+       IIO_CHAN(IIO_IN, 0, 1, 0, "supply", 0, 0,
+                (1 << IIO_CHAN_INFO_SCALE_SEPARATE),
+                0, ADIS16400_SCAN_SUPPLY, IIO_ST('u', 12, 16, 0), 0),
+       IIO_CHAN(IIO_GYRO, 1, 0, 0, NULL, 0, IIO_MOD_X,
+                (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) |
+                (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                1, ADIS16400_SCAN_GYRO_X, IIO_ST('s', 14, 16, 0), 0),
+       IIO_CHAN(IIO_GYRO, 1, 0, 0, NULL, 0, IIO_MOD_Y,
+                (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) |
+                (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                2, ADIS16400_SCAN_GYRO_Y, IIO_ST('s', 14, 16, 0), 0),
+       IIO_CHAN(IIO_GYRO, 1, 0, 0, NULL, 0, IIO_MOD_Z,
+                (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) |
+                (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                3, ADIS16400_SCAN_GYRO_Z, IIO_ST('s', 14, 16, 0), 0),
+       IIO_CHAN(IIO_ACCEL, 1, 0, 0, NULL, 0, IIO_MOD_X,
+                (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) |
+                (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                4, ADIS16400_SCAN_ACC_X, IIO_ST('s', 14, 16, 0), 0),
+       IIO_CHAN(IIO_ACCEL, 1, 0, 0, NULL, 0, IIO_MOD_Y,
+                (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) |
+                (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                0, ADIS16400_SCAN_ACC_Y, IIO_ST('s', 14, 16, 0), 0),
+       IIO_CHAN(IIO_ACCEL, 1, 0, 0, NULL, 0, IIO_MOD_Z,
+                (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) |
+                (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                0, ADIS16400_SCAN_ACC_Z, IIO_ST('s', 14, 16, 0), 0),
+       IIO_CHAN(IIO_TEMP, 0, 1, 0, "x", 0, 0,
+                (1 << IIO_CHAN_INFO_OFFSET_SEPARATE) |
+                (1 << IIO_CHAN_INFO_SCALE_SEPARATE),
+                0, ADIS16350_SCAN_TEMP_X, IIO_ST('s', 12, 16, 0), 0),
+       IIO_CHAN(IIO_TEMP, 0, 1, 0, "y", 1, 0,
+                (1 << IIO_CHAN_INFO_OFFSET_SEPARATE) |
+                (1 << IIO_CHAN_INFO_SCALE_SEPARATE),
+                0, ADIS16350_SCAN_TEMP_Y, IIO_ST('s', 12, 16, 0), 0),
+       IIO_CHAN(IIO_TEMP, 0, 1, 0, "z", 2, 0,
+                (1 << IIO_CHAN_INFO_OFFSET_SEPARATE) |
+                (1 << IIO_CHAN_INFO_SCALE_SEPARATE),
+                0, ADIS16350_SCAN_TEMP_Z, IIO_ST('s', 12, 16, 0), 0),
+       IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 1, 0,
+                (1 << IIO_CHAN_INFO_SCALE_SEPARATE),
+                0, ADIS16350_SCAN_ADC_0, IIO_ST('s', 12, 16, 0), 0),
+       IIO_CHAN_SOFT_TIMESTAMP(11)
+};
+
+static struct iio_chan_spec adis16300_channels[] = {
+       IIO_CHAN(IIO_IN, 0, 1, 0, "supply", 0, 0,
+                (1 << IIO_CHAN_INFO_SCALE_SEPARATE),
+                0, ADIS16400_SCAN_SUPPLY, IIO_ST('u', 12, 16, 0), 0),
+       IIO_CHAN(IIO_GYRO, 1, 0, 0, NULL, 0, IIO_MOD_X,
+                (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) |
+                (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                1, ADIS16400_SCAN_GYRO_X, IIO_ST('s', 14, 16, 0), 0),
+       IIO_CHAN(IIO_ACCEL, 1, 0, 0, NULL, 0, IIO_MOD_X,
+                (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) |
+                (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                4, ADIS16400_SCAN_ACC_X, IIO_ST('s', 14, 16, 0), 0),
+       IIO_CHAN(IIO_ACCEL, 1, 0, 0, NULL, 0, IIO_MOD_Y,
+                (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) |
+                (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                0, ADIS16400_SCAN_ACC_Y, IIO_ST('s', 14, 16, 0), 0),
+       IIO_CHAN(IIO_ACCEL, 1, 0, 0, NULL, 0, IIO_MOD_Z,
+                (1 << IIO_CHAN_INFO_CALIBBIAS_SEPARATE) |
+                (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                0, ADIS16400_SCAN_ACC_Z, IIO_ST('s', 14, 16, 0), 0),
+       IIO_CHAN(IIO_TEMP, 0, 1, 0, NULL, 0, 0,
+                (1 << IIO_CHAN_INFO_OFFSET_SEPARATE) |
+                (1 << IIO_CHAN_INFO_SCALE_SEPARATE),
+                0, ADIS16400_SCAN_TEMP, IIO_ST('s', 12, 16, 0), 0),
+       IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 1, 0,
+                (1 << IIO_CHAN_INFO_SCALE_SEPARATE),
+                0, ADIS16350_SCAN_ADC_0, IIO_ST('s', 12, 16, 0), 0),
+       IIO_CHAN(IIO_INCLI, 1, 0, 0, NULL, 0, IIO_MOD_X,
+                (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                0, ADIS16300_SCAN_INCLI_X, IIO_ST('s', 13, 16, 0), 0),
+       IIO_CHAN(IIO_INCLI, 1, 0, 0, NULL, 0, IIO_MOD_Y,
+                (1 << IIO_CHAN_INFO_SCALE_SHARED),
+                0, ADIS16300_SCAN_INCLI_Y, IIO_ST('s', 13, 16, 0), 0),
+       IIO_CHAN_SOFT_TIMESTAMP(14)
 };
 
 static struct attribute *adis16400_attributes[] = {
-       &iio_dev_attr_gyro_x_calibbias.dev_attr.attr,
-       &iio_dev_attr_gyro_y_calibbias.dev_attr.attr,
-       &iio_dev_attr_gyro_z_calibbias.dev_attr.attr,
-       &iio_dev_attr_accel_x_calibbias.dev_attr.attr,
-       &iio_dev_attr_accel_y_calibbias.dev_attr.attr,
-       &iio_dev_attr_accel_z_calibbias.dev_attr.attr,
-       &iio_dev_attr_in0_supply_raw.dev_attr.attr,
-       &iio_const_attr_in0_supply_scale.dev_attr.attr,
-       &iio_dev_attr_gyro_x_raw.dev_attr.attr,
-       &iio_dev_attr_gyro_y_raw.dev_attr.attr,
-       &iio_dev_attr_gyro_z_raw.dev_attr.attr,
-       &iio_const_attr_gyro_scale.dev_attr.attr,
-       &iio_dev_attr_accel_x_raw.dev_attr.attr,
-       &iio_dev_attr_accel_y_raw.dev_attr.attr,
-       &iio_dev_attr_accel_z_raw.dev_attr.attr,
-       &iio_const_attr_accel_scale.dev_attr.attr,
-       &iio_dev_attr_magn_x_raw.dev_attr.attr,
-       &iio_dev_attr_magn_y_raw.dev_attr.attr,
-       &iio_dev_attr_magn_z_raw.dev_attr.attr,
-       &iio_const_attr_magn_scale.dev_attr.attr,
-       &iio_dev_attr_temp_raw.dev_attr.attr,
-       &iio_const_attr_temp_offset.dev_attr.attr,
-       &iio_const_attr_temp_scale.dev_attr.attr,
-       &iio_dev_attr_in1_raw.dev_attr.attr,
-       &iio_const_attr_in1_scale.dev_attr.attr,
        &iio_dev_attr_sampling_frequency.dev_attr.attr,
        &iio_const_attr_sampling_frequency_available.dev_attr.attr,
        &iio_dev_attr_reset.dev_attr.attr,
-       &iio_const_attr_name.dev_attr.attr,
        NULL
 };
 
@@ -597,101 +702,147 @@ static const struct attribute_group adis16400_attribute_group = {
        .attrs = adis16400_attributes,
 };
 
+static struct adis16400_chip_info adis16400_chips[] = {
+       [ADIS16300] = {
+               .channels = adis16300_channels,
+               .num_channels = ARRAY_SIZE(adis16300_channels),
+               .gyro_scale_micro = 873,
+               .accel_scale_micro = 5884,
+               .default_scan_mask = (1 << ADIS16400_SCAN_SUPPLY) |
+               (1 << ADIS16400_SCAN_GYRO_X) | (1 << ADIS16400_SCAN_ACC_X) |
+               (1 << ADIS16400_SCAN_ACC_Y) | (1 << ADIS16400_SCAN_ACC_Z) |
+               (1 << ADIS16400_SCAN_TEMP) | (1 << ADIS16400_SCAN_ADC_0) |
+               (1 << ADIS16300_SCAN_INCLI_X) | (1 << ADIS16300_SCAN_INCLI_Y) |
+               (1 << 14),
+       },
+       [ADIS16350] = {
+               .channels = adis16350_channels,
+               .num_channels = ARRAY_SIZE(adis16350_channels),
+               .gyro_scale_micro = 872664,
+               .accel_scale_micro = 24732,
+               .default_scan_mask = 0x7FF,
+               .flags = ADIS16400_NO_BURST,
+       },
+       [ADIS16360] = {
+               .channels = adis16350_channels,
+               .num_channels = ARRAY_SIZE(adis16350_channels),
+               .flags = ADIS16400_HAS_PROD_ID,
+               .product_id = 0x3FE8,
+               .gyro_scale_micro = 1279,
+               .accel_scale_micro = 24732,
+               .default_scan_mask = 0x7FF,
+       },
+       [ADIS16362] = {
+               .channels = adis16350_channels,
+               .num_channels = ARRAY_SIZE(adis16350_channels),
+               .flags = ADIS16400_HAS_PROD_ID,
+               .product_id = 0x3FEA,
+               .gyro_scale_micro = 1279,
+               .accel_scale_micro = 24732,
+               .default_scan_mask = 0x7FF,
+       },
+       [ADIS16364] = {
+               .channels = adis16350_channels,
+               .num_channels = ARRAY_SIZE(adis16350_channels),
+               .flags = ADIS16400_HAS_PROD_ID,
+               .product_id = 0x3FEC,
+               .gyro_scale_micro = 1279,
+               .accel_scale_micro = 24732,
+               .default_scan_mask = 0x7FF,
+       },
+       [ADIS16365] = {
+               .channels = adis16350_channels,
+               .num_channels = ARRAY_SIZE(adis16350_channels),
+               .flags = ADIS16400_HAS_PROD_ID,
+               .product_id = 0x3FED,
+               .gyro_scale_micro = 1279,
+               .accel_scale_micro = 24732,
+               .default_scan_mask = 0x7FF,
+       },
+       [ADIS16400] = {
+               .channels = adis16400_channels,
+               .num_channels = ARRAY_SIZE(adis16400_channels),
+               .flags = ADIS16400_HAS_PROD_ID,
+               .product_id = 0x4015,
+               .gyro_scale_micro = 873,
+               .accel_scale_micro = 32656,
+               .default_scan_mask = 0xFFF,
+       }
+};
+
+static const struct iio_info adis16400_info = {
+       .driver_module = THIS_MODULE,
+       .read_raw = &adis16400_read_raw,
+       .write_raw = &adis16400_write_raw,
+       .attrs = &adis16400_attribute_group,
+};
+
 static int __devinit adis16400_probe(struct spi_device *spi)
 {
        int ret, regdone = 0;
-       struct adis16400_state *st = kzalloc(sizeof *st, GFP_KERNEL);
-       if (!st) {
+       struct adis16400_state *st;
+       struct iio_dev *indio_dev = iio_allocate_device(sizeof(*st));
+       if (indio_dev == NULL) {
                ret =  -ENOMEM;
                goto error_ret;
        }
+       st = iio_priv(indio_dev);
        /* this is only used for removal purposes */
-       spi_set_drvdata(spi, st);
+       spi_set_drvdata(spi, indio_dev);
 
-       /* Allocate the comms buffers */
-       st->rx = kzalloc(sizeof(*st->rx)*ADIS16400_MAX_RX, GFP_KERNEL);
-       if (st->rx == NULL) {
-               ret = -ENOMEM;
-               goto error_free_st;
-       }
-       st->tx = kzalloc(sizeof(*st->tx)*ADIS16400_MAX_TX, GFP_KERNEL);
-       if (st->tx == NULL) {
-               ret = -ENOMEM;
-               goto error_free_rx;
-       }
        st->us = spi;
        mutex_init(&st->buf_lock);
-       /* setup the industrialio driver allocated elements */
-       st->indio_dev = iio_allocate_device();
-       if (st->indio_dev == NULL) {
-               ret = -ENOMEM;
-               goto error_free_tx;
-       }
 
-       st->indio_dev->dev.parent = &spi->dev;
-       st->indio_dev->num_interrupt_lines = 1;
-       st->indio_dev->event_attrs = &adis16400_event_attribute_group;
-       st->indio_dev->attrs = &adis16400_attribute_group;
-       st->indio_dev->dev_data = (void *)(st);
-       st->indio_dev->driver_module = THIS_MODULE;
-       st->indio_dev->modes = INDIO_DIRECT_MODE;
-
-       ret = adis16400_configure_ring(st->indio_dev);
+       /* setup the industrialio driver allocated elements */
+       st->variant = &adis16400_chips[spi_get_device_id(spi)->driver_data];
+       indio_dev->dev.parent = &spi->dev;
+       indio_dev->name = spi_get_device_id(spi)->name;
+       indio_dev->channels = st->variant->channels;
+       indio_dev->num_channels = st->variant->num_channels;
+       indio_dev->info = &adis16400_info;
+       indio_dev->modes = INDIO_DIRECT_MODE;
+
+       ret = adis16400_configure_ring(indio_dev);
        if (ret)
                goto error_free_dev;
 
-       ret = iio_device_register(st->indio_dev);
+       ret = iio_device_register(indio_dev);
        if (ret)
                goto error_unreg_ring_funcs;
        regdone = 1;
 
-       ret = iio_ring_buffer_register(st->indio_dev->ring, 0);
+       ret = iio_ring_buffer_register_ex(indio_dev->ring, 0,
+                                         st->variant->channels,
+                                         st->variant->num_channels);
        if (ret) {
                dev_err(&spi->dev, "failed to initialize the ring\n");
                goto error_unreg_ring_funcs;
        }
 
        if (spi->irq && gpio_is_valid(irq_to_gpio(spi->irq)) > 0) {
-               ret = iio_register_interrupt_line(spi->irq,
-                               st->indio_dev,
-                               0,
-                               IRQF_TRIGGER_RISING,
-                               "adis16400");
+               ret = adis16400_probe_trigger(indio_dev);
                if (ret)
                        goto error_uninitialize_ring;
-
-               ret = adis16400_probe_trigger(st->indio_dev);
-               if (ret)
-                       goto error_unregister_line;
        }
 
        /* Get the device into a sane initial state */
-       ret = adis16400_initial_setup(st);
+       ret = adis16400_initial_setup(indio_dev);
        if (ret)
                goto error_remove_trigger;
        return 0;
 
 error_remove_trigger:
-       if (st->indio_dev->modes & INDIO_RING_TRIGGERED)
-               adis16400_remove_trigger(st->indio_dev);
-error_unregister_line:
-       if (st->indio_dev->modes & INDIO_RING_TRIGGERED)
-               iio_unregister_interrupt_line(st->indio_dev, 0);
+       if (indio_dev->modes & INDIO_RING_TRIGGERED)
+               adis16400_remove_trigger(indio_dev);
 error_uninitialize_ring:
-       iio_ring_buffer_unregister(st->indio_dev->ring);
+       iio_ring_buffer_unregister(indio_dev->ring);
 error_unreg_ring_funcs:
-       adis16400_unconfigure_ring(st->indio_dev);
+       adis16400_unconfigure_ring(indio_dev);
 error_free_dev:
        if (regdone)
-               iio_device_unregister(st->indio_dev);
+               iio_device_unregister(indio_dev);
        else
-               iio_free_device(st->indio_dev);
-error_free_tx:
-       kfree(st->tx);
-error_free_rx:
-       kfree(st->rx);
-error_free_st:
-       kfree(st);
+               iio_free_device(indio_dev);
 error_ret:
        return ret;
 }
@@ -700,25 +851,16 @@ error_ret:
 static int adis16400_remove(struct spi_device *spi)
 {
        int ret;
-       struct adis16400_state *st = spi_get_drvdata(spi);
-       struct iio_dev *indio_dev = st->indio_dev;
+       struct iio_dev *indio_dev =  spi_get_drvdata(spi);
 
-       ret = adis16400_stop_device(&(indio_dev->dev));
+       ret = adis16400_stop_device(indio_dev);
        if (ret)
                goto err_ret;
 
-       flush_scheduled_work();
-
        adis16400_remove_trigger(indio_dev);
-       if (spi->irq && gpio_is_valid(irq_to_gpio(spi->irq)) > 0)
-               iio_unregister_interrupt_line(indio_dev, 0);
-
-       iio_ring_buffer_unregister(st->indio_dev->ring);
+       iio_ring_buffer_unregister(indio_dev->ring);
        adis16400_unconfigure_ring(indio_dev);
        iio_device_unregister(indio_dev);
-       kfree(st->tx);
-       kfree(st->rx);
-       kfree(st);
 
        return 0;
 
@@ -726,11 +868,26 @@ err_ret:
        return ret;
 }
 
+static const struct spi_device_id adis16400_id[] = {
+       {"adis16300", ADIS16300},
+       {"adis16350", ADIS16350},
+       {"adis16354", ADIS16350},
+       {"adis16355", ADIS16350},
+       {"adis16360", ADIS16360},
+       {"adis16362", ADIS16362},
+       {"adis16364", ADIS16364},
+       {"adis16365", ADIS16365},
+       {"adis16400", ADIS16400},
+       {"adis16405", ADIS16400},
+       {}
+};
+
 static struct spi_driver adis16400_driver = {
        .driver = {
                .name = "adis16400",
                .owner = THIS_MODULE,
        },
+       .id_table = adis16400_id,
        .probe = adis16400_probe,
        .remove = __devexit_p(adis16400_remove),
 };
index da28cb4288af3f104a51a791d6ab031d02244bc1..2589a7e167e4e94772fe36e8b215ea904f0873ea 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/slab.h>
 #include <linux/sysfs.h>
 #include <linux/list.h>
+#include <linux/bitops.h>
 
 #include "../iio.h"
 #include "../sysfs.h"
 #include "../trigger.h"
 #include "adis16400.h"
 
-static IIO_SCAN_EL_C(in0_supply, ADIS16400_SCAN_SUPPLY,
-                    ADIS16400_SUPPLY_OUT, NULL);
-static IIO_CONST_ATTR_SCAN_EL_TYPE(in0_supply, u, 14, 16);
-
-static IIO_SCAN_EL_C(gyro_x, ADIS16400_SCAN_GYRO_X, ADIS16400_XGYRO_OUT, NULL);
-static IIO_SCAN_EL_C(gyro_y, ADIS16400_SCAN_GYRO_Y, ADIS16400_YGYRO_OUT, NULL);
-static IIO_SCAN_EL_C(gyro_z, ADIS16400_SCAN_GYRO_Z, ADIS16400_ZGYRO_OUT, NULL);
-static IIO_CONST_ATTR_SCAN_EL_TYPE(gyro, s, 14, 16);
-
-static IIO_SCAN_EL_C(accel_x, ADIS16400_SCAN_ACC_X, ADIS16400_XACCL_OUT, NULL);
-static IIO_SCAN_EL_C(accel_y, ADIS16400_SCAN_ACC_Y, ADIS16400_YACCL_OUT, NULL);
-static IIO_SCAN_EL_C(accel_z, ADIS16400_SCAN_ACC_Z, ADIS16400_ZACCL_OUT, NULL);
-static IIO_CONST_ATTR_SCAN_EL_TYPE(accel, s, 14, 16);
-
-static IIO_SCAN_EL_C(magn_x, ADIS16400_SCAN_MAGN_X, ADIS16400_XMAGN_OUT, NULL);
-static IIO_SCAN_EL_C(magn_y, ADIS16400_SCAN_MAGN_Y, ADIS16400_YMAGN_OUT, NULL);
-static IIO_SCAN_EL_C(magn_z, ADIS16400_SCAN_MAGN_Z, ADIS16400_ZMAGN_OUT, NULL);
-static IIO_CONST_ATTR_SCAN_EL_TYPE(magn, s, 14, 16);
-
-static IIO_SCAN_EL_C(temp, ADIS16400_SCAN_TEMP, ADIS16400_TEMP_OUT, NULL);
-static IIO_CONST_ATTR_SCAN_EL_TYPE(temp, s, 12, 16);
-
-static IIO_SCAN_EL_C(in1, ADIS16400_SCAN_ADC_0, ADIS16400_AUX_ADC, NULL);
-static IIO_CONST_ATTR_SCAN_EL_TYPE(in1, u, 12, 16);
-
-static IIO_SCAN_EL_TIMESTAMP(12);
-static IIO_CONST_ATTR_SCAN_EL_TYPE(timestamp, s, 64, 64);
-
-static struct attribute *adis16400_scan_el_attrs[] = {
-       &iio_scan_el_in0_supply.dev_attr.attr,
-       &iio_const_attr_in0_supply_index.dev_attr.attr,
-       &iio_const_attr_in0_supply_type.dev_attr.attr,
-       &iio_scan_el_gyro_x.dev_attr.attr,
-       &iio_const_attr_gyro_x_index.dev_attr.attr,
-       &iio_scan_el_gyro_y.dev_attr.attr,
-       &iio_const_attr_gyro_y_index.dev_attr.attr,
-       &iio_scan_el_gyro_z.dev_attr.attr,
-       &iio_const_attr_gyro_z_index.dev_attr.attr,
-       &iio_const_attr_gyro_type.dev_attr.attr,
-       &iio_scan_el_accel_x.dev_attr.attr,
-       &iio_const_attr_accel_x_index.dev_attr.attr,
-       &iio_scan_el_accel_y.dev_attr.attr,
-       &iio_const_attr_accel_y_index.dev_attr.attr,
-       &iio_scan_el_accel_z.dev_attr.attr,
-       &iio_const_attr_accel_z_index.dev_attr.attr,
-       &iio_const_attr_accel_type.dev_attr.attr,
-       &iio_scan_el_magn_x.dev_attr.attr,
-       &iio_const_attr_magn_x_index.dev_attr.attr,
-       &iio_scan_el_magn_y.dev_attr.attr,
-       &iio_const_attr_magn_y_index.dev_attr.attr,
-       &iio_scan_el_magn_z.dev_attr.attr,
-       &iio_const_attr_magn_z_index.dev_attr.attr,
-       &iio_const_attr_magn_type.dev_attr.attr,
-       &iio_scan_el_temp.dev_attr.attr,
-       &iio_const_attr_temp_index.dev_attr.attr,
-       &iio_const_attr_temp_type.dev_attr.attr,
-       &iio_scan_el_in1.dev_attr.attr,
-       &iio_const_attr_in1_index.dev_attr.attr,
-       &iio_const_attr_in1_type.dev_attr.attr,
-       &iio_scan_el_timestamp.dev_attr.attr,
-       &iio_const_attr_timestamp_index.dev_attr.attr,
-       &iio_const_attr_timestamp_type.dev_attr.attr,
-       NULL,
-};
-
-static struct attribute_group adis16400_scan_el_group = {
-       .attrs = adis16400_scan_el_attrs,
-       .name = "scan_elements",
-};
-
-/**
- * adis16400_poll_func_th() top half interrupt handler called by trigger
- * @private_data:      iio_dev
- **/
-static void adis16400_poll_func_th(struct iio_dev *indio_dev, s64 time)
-{
-       struct adis16400_state *st = iio_dev_get_devdata(indio_dev);
-       st->last_timestamp = time;
-       schedule_work(&st->work_trigger_to_ring);
-       /* Indicate that this interrupt is being handled */
-
-       /* Technically this is trigger related, but without this
-        * handler running there is currently no way for the interrupt
-        * to clear.
-        */
-}
-
 /**
  * adis16400_spi_read_burst() - read all data registers
  * @dev: device associated with child of actual device (iio_dev or iio_trig)
@@ -113,7 +27,7 @@ static int adis16400_spi_read_burst(struct device *dev, u8 *rx)
 {
        struct spi_message msg;
        struct iio_dev *indio_dev = dev_get_drvdata(dev);
-       struct adis16400_state *st = iio_dev_get_devdata(indio_dev);
+       struct adis16400_state *st = iio_priv(indio_dev);
        u32 old_speed_hz = st->us->max_speed_hz;
        int ret;
 
@@ -150,62 +64,122 @@ static int adis16400_spi_read_burst(struct device *dev, u8 *rx)
        return ret;
 }
 
+static const u16 read_all_tx_array[] = {
+       cpu_to_be16(ADIS16400_READ_REG(ADIS16400_SUPPLY_OUT)),
+       cpu_to_be16(ADIS16400_READ_REG(ADIS16400_XGYRO_OUT)),
+       cpu_to_be16(ADIS16400_READ_REG(ADIS16400_YGYRO_OUT)),
+       cpu_to_be16(ADIS16400_READ_REG(ADIS16400_ZGYRO_OUT)),
+       cpu_to_be16(ADIS16400_READ_REG(ADIS16400_XACCL_OUT)),
+       cpu_to_be16(ADIS16400_READ_REG(ADIS16400_YACCL_OUT)),
+       cpu_to_be16(ADIS16400_READ_REG(ADIS16400_ZACCL_OUT)),
+       cpu_to_be16(ADIS16400_READ_REG(ADIS16350_XTEMP_OUT)),
+       cpu_to_be16(ADIS16400_READ_REG(ADIS16350_YTEMP_OUT)),
+       cpu_to_be16(ADIS16400_READ_REG(ADIS16350_ZTEMP_OUT)),
+       cpu_to_be16(ADIS16400_READ_REG(ADIS16400_AUX_ADC)),
+};
+
+static int adis16350_spi_read_all(struct device *dev, u8 *rx)
+{
+       struct iio_dev *indio_dev = dev_get_drvdata(dev);
+       struct adis16400_state *st = iio_priv(indio_dev);
+
+       struct spi_message msg;
+       int i, j = 0, ret;
+       struct spi_transfer *xfers;
+
+       xfers = kzalloc(sizeof(*xfers)*indio_dev->ring->scan_count + 1,
+                       GFP_KERNEL);
+       if (xfers == NULL)
+               return -ENOMEM;
+
+       for (i = 0; i < ARRAY_SIZE(read_all_tx_array); i++)
+               if (indio_dev->ring->scan_mask & (1 << i)) {
+                       xfers[j].tx_buf = &read_all_tx_array[i];
+                       xfers[j].bits_per_word = 16;
+                       xfers[j].len = 2;
+                       xfers[j + 1].rx_buf = rx + j*2;
+                       j++;
+               }
+       xfers[j].bits_per_word = 16;
+       xfers[j].len = 2;
+
+       spi_message_init(&msg);
+       for (j = 0; j < indio_dev->ring->scan_count + 1; j++)
+               spi_message_add_tail(&xfers[j], &msg);
+
+       ret = spi_sync(st->us, &msg);
+       kfree(xfers);
+
+       return ret;
+}
+
 /* Whilst this makes a lot of calls to iio_sw_ring functions - it is to device
  * specific to be rolled into the core.
  */
-static void adis16400_trigger_bh_to_ring(struct work_struct *work_s)
+static irqreturn_t adis16400_trigger_handler(int irq, void *p)
 {
-       struct adis16400_state *st
-               = container_of(work_s, struct adis16400_state,
-                              work_trigger_to_ring);
-       struct iio_ring_buffer *ring = st->indio_dev->ring;
-
-       int i = 0, j;
+       struct iio_poll_func *pf = p;
+       struct iio_dev *indio_dev = pf->private_data;
+       struct adis16400_state *st = iio_priv(indio_dev);
+       struct iio_ring_buffer *ring = indio_dev->ring;
+       int i = 0, j, ret = 0;
        s16 *data;
-       size_t datasize = ring->access.get_bytes_per_datum(ring);
+       size_t datasize = ring->access->get_bytes_per_datum(ring);
        unsigned long mask = ring->scan_mask;
 
        data = kmalloc(datasize , GFP_KERNEL);
        if (data == NULL) {
                dev_err(&st->us->dev, "memory alloc failed in ring bh");
-               return;
+               return -ENOMEM;
        }
 
-       if (ring->scan_count)
-               if (adis16400_spi_read_burst(&st->indio_dev->dev, st->rx) >= 0)
-                       for (; i < ring->scan_count; i++) {
+       if (ring->scan_count) {
+               if (st->variant->flags & ADIS16400_NO_BURST) {
+                       ret = adis16350_spi_read_all(&indio_dev->dev, st->rx);
+                       if (ret < 0)
+                               return ret;
+                       for (; i < ring->scan_count; i++)
+                               data[i] = *(s16 *)(st->rx + i*2);
+               } else {
+                       ret = adis16400_spi_read_burst(&indio_dev->dev, st->rx);
+                       if (ret < 0)
+                               return ret;
+                       for (; i < indio_dev->ring->scan_count; i++) {
                                j = __ffs(mask);
                                mask &= ~(1 << j);
-                               data[i] = be16_to_cpup(
+                               data[i] = be16_to_cpup(
                                        (__be16 *)&(st->rx[j*2]));
                        }
-
+               }
+       }
        /* Guaranteed to be aligned with 8 byte boundary */
        if (ring->scan_timestamp)
-               *((s64 *)(data + ((i + 3)/4)*4)) = st->last_timestamp;
+               *((s64 *)(data + ((i + 3)/4)*4)) = pf->timestamp;
+       ring->access->store_to(indio_dev->ring, (u8 *) data, pf->timestamp);
 
-       ring->access.store_to(ring,
-                       (u8 *) data,
-                       st->last_timestamp);
-
-       iio_trigger_notify_done(st->indio_dev->trig);
+       iio_trigger_notify_done(indio_dev->trig);
        kfree(data);
 
-       return;
+       return IRQ_HANDLED;
 }
 
 void adis16400_unconfigure_ring(struct iio_dev *indio_dev)
 {
-       kfree(indio_dev->pollfunc);
+       iio_dealloc_pollfunc(indio_dev->pollfunc);
        iio_sw_rb_free(indio_dev->ring);
 }
 
+static const struct iio_ring_setup_ops adis16400_ring_setup_ops = {
+       .preenable = &iio_sw_ring_preenable,
+       .postenable = &iio_triggered_ring_postenable,
+       .predisable = &iio_triggered_ring_predisable,
+};
+
 int adis16400_configure_ring(struct iio_dev *indio_dev)
 {
        int ret = 0;
-       struct adis16400_state *st = indio_dev->dev_data;
+       struct adis16400_state *st = iio_priv(indio_dev);
        struct iio_ring_buffer *ring;
-       INIT_WORK(&st->work_trigger_to_ring, adis16400_trigger_bh_to_ring);
 
        ring = iio_sw_rb_allocate(indio_dev);
        if (!ring) {
@@ -214,36 +188,29 @@ int adis16400_configure_ring(struct iio_dev *indio_dev)
        }
        indio_dev->ring = ring;
        /* Effectively select the ring buffer implementation */
-       iio_ring_sw_register_funcs(&ring->access);
+       ring->access = &ring_sw_access_funcs;
        ring->bpe = 2;
-       ring->scan_el_attrs = &adis16400_scan_el_group;
        ring->scan_timestamp = true;
-       ring->preenable = &iio_sw_ring_preenable;
-       ring->postenable = &iio_triggered_ring_postenable;
-       ring->predisable = &iio_triggered_ring_predisable;
+       ring->setup_ops = &adis16400_ring_setup_ops;
        ring->owner = THIS_MODULE;
-
        /* Set default scan mode */
-       iio_scan_mask_set(ring, iio_scan_el_in0_supply.number);
-       iio_scan_mask_set(ring, iio_scan_el_gyro_x.number);
-       iio_scan_mask_set(ring, iio_scan_el_gyro_y.number);
-       iio_scan_mask_set(ring, iio_scan_el_gyro_z.number);
-       iio_scan_mask_set(ring, iio_scan_el_accel_x.number);
-       iio_scan_mask_set(ring, iio_scan_el_accel_y.number);
-       iio_scan_mask_set(ring, iio_scan_el_accel_z.number);
-       iio_scan_mask_set(ring, iio_scan_el_magn_x.number);
-       iio_scan_mask_set(ring, iio_scan_el_magn_y.number);
-       iio_scan_mask_set(ring, iio_scan_el_magn_z.number);
-       iio_scan_mask_set(ring, iio_scan_el_temp.number);
-       iio_scan_mask_set(ring, iio_scan_el_in1.number);
-
-       ret = iio_alloc_pollfunc(indio_dev, NULL, &adis16400_poll_func_th);
-       if (ret)
+       ring->scan_mask = st->variant->default_scan_mask;
+       ring->scan_count = hweight_long(st->variant->default_scan_mask);
+
+       indio_dev->pollfunc = iio_alloc_pollfunc(&iio_pollfunc_store_time,
+                                                &adis16400_trigger_handler,
+                                                IRQF_ONESHOT,
+                                                indio_dev,
+                                                "%s_consumer%d",
+                                                indio_dev->name,
+                                                indio_dev->id);
+       if (indio_dev->pollfunc == NULL) {
+               ret = -ENOMEM;
                goto error_iio_sw_rb_free;
+       }
 
        indio_dev->modes |= INDIO_RING_TRIGGERED;
        return 0;
-
 error_iio_sw_rb_free:
        iio_sw_rb_free(indio_dev->ring);
        return ret;
index 36b5ff5be983d4b09a8791de6259a9083fdeb2d8..c6ec41a02a699f6754624daf60bb5bcf63770dba 100644 (file)
 #include "../trigger.h"
 #include "adis16400.h"
 
-/**
- * adis16400_data_rdy_trig_poll() the event handler for the data rdy trig
- **/
-static int adis16400_data_rdy_trig_poll(struct iio_dev *dev_info,
-                                      int index,
-                                      s64 timestamp,
-                                      int no_test)
-{
-       struct adis16400_state *st = iio_dev_get_devdata(dev_info);
-       struct iio_trigger *trig = st->trig;
-
-       iio_trigger_poll(trig, timestamp);
-
-       return IRQ_HANDLED;
-}
-
-IIO_EVENT_SH(data_rdy_trig, &adis16400_data_rdy_trig_poll);
-
-static IIO_TRIGGER_NAME_ATTR;
-
-static struct attribute *adis16400_trigger_attrs[] = {
-       &dev_attr_name.attr,
-       NULL,
-};
-
-static const struct attribute_group adis16400_trigger_attr_group = {
-       .attrs = adis16400_trigger_attrs,
-};
-
 /**
  * adis16400_data_rdy_trigger_set_state() set datardy interrupt state
  **/
 static int adis16400_data_rdy_trigger_set_state(struct iio_trigger *trig,
                                                bool state)
 {
-       struct adis16400_state *st = trig->private_data;
-       struct iio_dev *indio_dev = st->indio_dev;
-       int ret = 0;
+       struct iio_dev *indio_dev = trig->private_data;
 
        dev_dbg(&indio_dev->dev, "%s (%d)\n", __func__, state);
-       ret = adis16400_set_irq(&st->indio_dev->dev, state);
-       if (state == false) {
-               iio_remove_event_from_list(&iio_event_data_rdy_trig,
-                                          &indio_dev->interrupts[0]
-                                          ->ev_list);
-               /* possible quirk with handler currently worked around
-                  by ensuring the work queue is empty */
-               flush_scheduled_work();
-       } else {
-               iio_add_event_to_list(&iio_event_data_rdy_trig,
-                                     &indio_dev->interrupts[0]->ev_list);
-       }
-       return ret;
-}
-
-/**
- * adis16400_trig_try_reen() try renabling irq for data rdy trigger
- * @trig:      the datardy trigger
- **/
-static int adis16400_trig_try_reen(struct iio_trigger *trig)
-{
-       struct adis16400_state *st = trig->private_data;
-       enable_irq(st->us->irq);
-       /* irq reenabled so success! */
-       return 0;
+       return adis16400_set_irq(indio_dev, state);
 }
 
 int adis16400_probe_trigger(struct iio_dev *indio_dev)
 {
        int ret;
-       struct adis16400_state *st = indio_dev->dev_data;
+       struct adis16400_state *st = iio_priv(indio_dev);
 
-       st->trig = iio_allocate_trigger();
-       st->trig->name = kasprintf(GFP_KERNEL,
-                                  "adis16400-dev%d",
-                                  indio_dev->id);
-       if (!st->trig->name) {
+       st->trig = iio_allocate_trigger("%s-dev%d",
+                                       spi_get_device_id(st->us)->name,
+                                       indio_dev->id);
+       if (st->trig == NULL) {
                ret = -ENOMEM;
-               goto error_free_trig;
+               goto error_ret;
        }
+
+       ret = request_irq(st->us->irq,
+                         &iio_trigger_generic_data_rdy_poll,
+                         IRQF_TRIGGER_RISING,
+                         "adis16400",
+                         st->trig);
+       if (ret)
+               goto error_free_trig;
        st->trig->dev.parent = &st->us->dev;
        st->trig->owner = THIS_MODULE;
-       st->trig->private_data = st;
+       st->trig->private_data = indio_dev;
        st->trig->set_trigger_state = &adis16400_data_rdy_trigger_set_state;
-       st->trig->try_reenable = &adis16400_trig_try_reen;
-       st->trig->control_attrs = &adis16400_trigger_attr_group;
        ret = iio_trigger_register(st->trig);
 
        /* select default trigger */
        indio_dev->trig = st->trig;
        if (ret)
-               goto error_free_trig_name;
+               goto error_free_irq;
 
        return 0;
 
-error_free_trig_name:
-       kfree(st->trig->name);
+error_free_irq:
+       free_irq(st->us->irq, st->trig);
 error_free_trig:
        iio_free_trigger(st->trig);
-
+error_ret:
        return ret;
 }
 
 void adis16400_remove_trigger(struct iio_dev *indio_dev)
 {
-       struct adis16400_state *state = indio_dev->dev_data;
+       struct adis16400_state *st = iio_priv(indio_dev);
 
-       iio_trigger_unregister(state->trig);
-       kfree(state->trig->name);
-       iio_free_trigger(state->trig);
+       iio_trigger_unregister(st->trig);
+       free_irq(st->us->irq, st->trig);
+       iio_free_trigger(st->trig);
 }
index 1795ee1e8207377a9c987b4b4a6fc83ce0a66af1..94d3bfaa061d8e3b0ee3002f0d85ce10bfbcda95 100644 (file)
@@ -16,7 +16,6 @@
 #include <linux/err.h>
 #include <linux/device.h>
 #include <linux/fs.h>
-#include <linux/interrupt.h>
 #include <linux/poll.h>
 #include <linux/sched.h>
 #include <linux/wait.h>
@@ -44,27 +43,55 @@ struct bus_type iio_bus_type = {
 };
 EXPORT_SYMBOL(iio_bus_type);
 
-void __iio_change_event(struct iio_detected_event_list *ev,
-                       int ev_code,
-                       s64 timestamp)
-{
-       ev->ev.id = ev_code;
-       ev->ev.timestamp = timestamp;
-}
-EXPORT_SYMBOL(__iio_change_event);
+static const char * const iio_chan_type_name_spec_shared[] = {
+       [IIO_TIMESTAMP] = "timestamp",
+       [IIO_ACCEL] = "accel",
+       [IIO_IN] = "in",
+       [IIO_CURRENT] = "current",
+       [IIO_POWER] = "power",
+       [IIO_IN_DIFF] = "in-in",
+       [IIO_GYRO] = "gyro",
+       [IIO_TEMP] = "temp",
+       [IIO_MAGN] = "magn",
+       [IIO_INCLI] = "incli",
+       [IIO_ROT] = "rot",
+       [IIO_INTENSITY] = "intensity",
+       [IIO_LIGHT] = "illuminance",
+       [IIO_ANGL] = "angl",
+};
+
+static const char * const iio_chan_type_name_spec_complex[] = {
+       [IIO_IN_DIFF] = "in%d-in%d",
+};
 
-/* Used both in the interrupt line put events and the ring buffer ones */
+static const char * const iio_modifier_names_light[] = {
+       [IIO_MOD_LIGHT_BOTH] = "both",
+       [IIO_MOD_LIGHT_IR] = "ir",
+};
 
-/* Note that in it's current form someone has to be listening before events
- * are queued. Hence a client MUST open the chrdev before the ring buffer is
- * switched on.
- */
-int __iio_push_event(struct iio_event_interface *ev_int,
-                    int ev_code,
-                    s64 timestamp,
-                    struct iio_shared_ev_pointer *
-                    shared_pointer_p)
+static const char * const iio_modifier_names_axial[] = {
+       [IIO_MOD_X] = "x",
+       [IIO_MOD_Y] = "y",
+       [IIO_MOD_Z] = "z",
+};
+
+/* relies on pairs of these shared then separate */
+static const char * const iio_chan_info_postfix[] = {
+       [IIO_CHAN_INFO_SCALE_SHARED/2] = "scale",
+       [IIO_CHAN_INFO_OFFSET_SHARED/2] = "offset",
+       [IIO_CHAN_INFO_CALIBSCALE_SHARED/2] = "calibscale",
+       [IIO_CHAN_INFO_CALIBBIAS_SHARED/2] = "calibbias",
+       [IIO_CHAN_INFO_PEAK_SHARED/2] = "peak_raw",
+       [IIO_CHAN_INFO_PEAK_SCALE_SHARED/2] = "peak_scale",
+};
+
+int iio_push_event(struct iio_dev *dev_info,
+                  int ev_line,
+                  int ev_code,
+                  s64 timestamp)
 {
+       struct iio_event_interface *ev_int
+               = &dev_info->event_interfaces[ev_line];
        struct iio_detected_event_list *ev;
        int ret = 0;
 
@@ -83,11 +110,8 @@ int __iio_push_event(struct iio_event_interface *ev_int,
                }
                ev->ev.id = ev_code;
                ev->ev.timestamp = timestamp;
-               ev->shared_pointer = shared_pointer_p;
-               if (ev->shared_pointer)
-                       shared_pointer_p->ev_p = ev;
 
-               list_add_tail(&ev->list, &ev_int->det_events.list);
+               list_add_tail(&ev->list, &ev_int->det_events);
                ev_int->current_events++;
                mutex_unlock(&ev_int->event_list_lock);
                wake_up_interruptible(&ev_int->wait);
@@ -97,85 +121,8 @@ int __iio_push_event(struct iio_event_interface *ev_int,
 error_ret:
        return ret;
 }
-EXPORT_SYMBOL(__iio_push_event);
-
-int iio_push_event(struct iio_dev *dev_info,
-                  int ev_line,
-                  int ev_code,
-                  s64 timestamp)
-{
-       return __iio_push_event(&dev_info->event_interfaces[ev_line],
-                               ev_code, timestamp, NULL);
-}
 EXPORT_SYMBOL(iio_push_event);
 
-/* Generic interrupt line interrupt handler */
-static irqreturn_t iio_interrupt_handler(int irq, void *_int_info)
-{
-       struct iio_interrupt *int_info = _int_info;
-       struct iio_dev *dev_info = int_info->dev_info;
-       struct iio_event_handler_list *p;
-       s64 time_ns;
-       unsigned long flags;
-
-       spin_lock_irqsave(&int_info->ev_list_lock, flags);
-       if (list_empty(&int_info->ev_list)) {
-               spin_unlock_irqrestore(&int_info->ev_list_lock, flags);
-               return IRQ_NONE;
-       }
-
-       time_ns = iio_get_time_ns();
-       list_for_each_entry(p, &int_info->ev_list, list) {
-               disable_irq_nosync(irq);
-               p->handler(dev_info, 1, time_ns, !(p->refcount > 1));
-       }
-       spin_unlock_irqrestore(&int_info->ev_list_lock, flags);
-
-       return IRQ_HANDLED;
-}
-
-static struct iio_interrupt *iio_allocate_interrupt(void)
-{
-       struct iio_interrupt *i = kmalloc(sizeof *i, GFP_KERNEL);
-       if (i) {
-               spin_lock_init(&i->ev_list_lock);
-               INIT_LIST_HEAD(&i->ev_list);
-       }
-       return i;
-}
-
-/* Confirming the validity of supplied irq is left to drivers.*/
-int iio_register_interrupt_line(unsigned int irq,
-                               struct iio_dev *dev_info,
-                               int line_number,
-                               unsigned long type,
-                               const char *name)
-{
-       int ret;
-
-       dev_info->interrupts[line_number] = iio_allocate_interrupt();
-       if (dev_info->interrupts[line_number] == NULL) {
-               ret = -ENOMEM;
-               goto error_ret;
-       }
-       dev_info->interrupts[line_number]->line_number = line_number;
-       dev_info->interrupts[line_number]->irq = irq;
-       dev_info->interrupts[line_number]->dev_info = dev_info;
-
-       /* Possibly only request on demand?
-        * Can see this may complicate the handling of interrupts.
-        * However, with this approach we might end up handling lots of
-        * events no-one cares about.*/
-       ret = request_irq(irq,
-                         &iio_interrupt_handler,
-                         type,
-                         name,
-                         dev_info->interrupts[line_number]);
-
-error_ret:
-       return ret;
-}
-EXPORT_SYMBOL(iio_register_interrupt_line);
 
 /* This turns up an awful lot */
 ssize_t iio_read_const_attr(struct device *dev,
@@ -186,54 +133,6 @@ ssize_t iio_read_const_attr(struct device *dev,
 }
 EXPORT_SYMBOL(iio_read_const_attr);
 
-/* Before this runs the interrupt generator must have been disabled */
-void iio_unregister_interrupt_line(struct iio_dev *dev_info, int line_number)
-{
-       /* make sure the interrupt handlers are all done */
-       flush_scheduled_work();
-       free_irq(dev_info->interrupts[line_number]->irq,
-                dev_info->interrupts[line_number]);
-       kfree(dev_info->interrupts[line_number]);
-}
-EXPORT_SYMBOL(iio_unregister_interrupt_line);
-
-/* Reference counted add and remove */
-void iio_add_event_to_list(struct iio_event_handler_list *el,
-                         struct list_head *head)
-{
-       unsigned long flags;
-       struct iio_interrupt *inter = to_iio_interrupt(head);
-
-       /* take mutex to protect this element */
-       mutex_lock(&el->exist_lock);
-       if (el->refcount == 0) {
-               /* Take the event list spin lock */
-               spin_lock_irqsave(&inter->ev_list_lock, flags);
-               list_add(&el->list, head);
-               spin_unlock_irqrestore(&inter->ev_list_lock, flags);
-       }
-       el->refcount++;
-       mutex_unlock(&el->exist_lock);
-}
-EXPORT_SYMBOL(iio_add_event_to_list);
-
-void iio_remove_event_from_list(struct iio_event_handler_list *el,
-                              struct list_head *head)
-{
-       unsigned long flags;
-       struct iio_interrupt *inter = to_iio_interrupt(head);
-
-       mutex_lock(&el->exist_lock);
-       el->refcount--;
-       if (el->refcount == 0) {
-               /* Take the event list spin lock */
-               spin_lock_irqsave(&inter->ev_list_lock, flags);
-               list_del_init(&el->list);
-               spin_unlock_irqrestore(&inter->ev_list_lock, flags);
-       }
-       mutex_unlock(&el->exist_lock);
-}
-EXPORT_SYMBOL(iio_remove_event_from_list);
 
 static ssize_t iio_event_chrdev_read(struct file *filep,
                                     char __user *buf,
@@ -246,7 +145,7 @@ static ssize_t iio_event_chrdev_read(struct file *filep,
        size_t len;
 
        mutex_lock(&ev_int->event_list_lock);
-       if (list_empty(&ev_int->det_events.list)) {
+       if (list_empty(&ev_int->det_events)) {
                if (filep->f_flags & O_NONBLOCK) {
                        ret = -EAGAIN;
                        goto error_mutex_unlock;
@@ -255,14 +154,14 @@ static ssize_t iio_event_chrdev_read(struct file *filep,
                /* Blocking on device; waiting for something to be there */
                ret = wait_event_interruptible(ev_int->wait,
                                               !list_empty(&ev_int
-                                                          ->det_events.list));
+                                                          ->det_events));
                if (ret)
                        goto error_ret;
                /* Single access device so no one else can get the data */
                mutex_lock(&ev_int->event_list_lock);
        }
 
-       el = list_first_entry(&ev_int->det_events.list,
+       el = list_first_entry(&ev_int->det_events,
                              struct iio_detected_event_list,
                              list);
        len = sizeof el->ev;
@@ -273,18 +172,6 @@ static ssize_t iio_event_chrdev_read(struct file *filep,
        list_del(&el->list);
        ev_int->current_events--;
        mutex_unlock(&ev_int->event_list_lock);
-       /*
-        * Possible concurency issue if an update of this event is on its way
-        * through. May lead to new event being removed whilst the reported
-        * event was the unescalated event. In typical use case this is not a
-        * problem as userspace will say read half the buffer due to a 50%
-        * full event which would make the correct 100% full incorrect anyway.
-        */
-       if (el->shared_pointer) {
-               spin_lock(&el->shared_pointer->lock);
-               (el->shared_pointer->ev_p) = NULL;
-               spin_unlock(&el->shared_pointer->lock);
-       }
        kfree(el);
 
        return len;
@@ -309,7 +196,7 @@ static int iio_event_chrdev_release(struct inode *inode, struct file *filep)
         * clear out any awaiting events. The mask will prevent
         * any new __iio_push_event calls running.
         */
-       list_for_each_entry_safe(el, t, &ev_int->det_events.list, list) {
+       list_for_each_entry_safe(el, t, &ev_int->det_events, list) {
                list_del(&el->list);
                kfree(el);
        }
@@ -381,10 +268,11 @@ void iio_device_free_chrdev_minor(int val)
        spin_unlock(&iio_ida_lock);
 }
 
-int iio_setup_ev_int(struct iio_event_interface *ev_int,
-                    const char *name,
-                    struct module *owner,
-                    struct device *dev)
+static int iio_setup_ev_int(struct iio_event_interface *ev_int,
+                           const char *dev_name,
+                           int index,
+                           struct module *owner,
+                           struct device *dev)
 {
        int ret, minor;
 
@@ -399,7 +287,7 @@ int iio_setup_ev_int(struct iio_event_interface *ev_int,
                goto error_device_put;
        }
        ev_int->dev.devt = MKDEV(MAJOR(iio_devt), minor);
-       dev_set_name(&ev_int->dev, "%s", name);
+       dev_set_name(&ev_int->dev, "%s:event%d", dev_name, index);
 
        ret = device_add(&ev_int->dev);
        if (ret)
@@ -412,7 +300,7 @@ int iio_setup_ev_int(struct iio_event_interface *ev_int,
        /* discussion point - make this variable? */
        ev_int->max_events = 10;
        ev_int->current_events = 0;
-       INIT_LIST_HEAD(&ev_int->det_events.list);
+       INIT_LIST_HEAD(&ev_int->det_events);
        init_waitqueue_head(&ev_int->wait);
        ev_int->handler.private = ev_int;
        ev_int->handler.flags = 0;
@@ -433,7 +321,7 @@ error_device_put:
        return ret;
 }
 
-void iio_free_ev_int(struct iio_event_interface *ev_int)
+static void iio_free_ev_int(struct iio_event_interface *ev_int)
 {
        device_unregister(&ev_int->dev);
        put_device(&ev_int->dev);
@@ -488,24 +376,397 @@ static void __exit iio_exit(void)
        bus_unregister(&iio_bus_type);
 }
 
-static int iio_device_register_sysfs(struct iio_dev *dev_info)
+static ssize_t iio_read_channel_info(struct device *dev,
+                                    struct device_attribute *attr,
+                                    char *buf)
 {
-       int ret = 0;
+       struct iio_dev *indio_dev = dev_get_drvdata(dev);
+       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
+       int val, val2;
+       int ret = indio_dev->info->read_raw(indio_dev, this_attr->c,
+                                           &val, &val2, this_attr->address);
 
-       ret = sysfs_create_group(&dev_info->dev.kobj, dev_info->attrs);
-       if (ret) {
-               dev_err(dev_info->dev.parent,
-                       "Failed to register sysfs hooks\n");
+       if (ret < 0)
+               return ret;
+
+       if (ret == IIO_VAL_INT)
+               return sprintf(buf, "%d\n", val);
+       else if (ret == IIO_VAL_INT_PLUS_MICRO) {
+               if (val2 < 0)
+                       return sprintf(buf, "-%d.%06u\n", val, -val2);
+               else
+                       return sprintf(buf, "%d.%06u\n", val, val2);
+       } else
+               return 0;
+}
+
+static ssize_t iio_write_channel_info(struct device *dev,
+                                     struct device_attribute *attr,
+                                     const char *buf,
+                                     size_t len)
+{
+       struct iio_dev *indio_dev = dev_get_drvdata(dev);
+       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
+       int ret, integer = 0, micro = 0, micro_mult = 100000;
+       bool integer_part = true, negative = false;
+
+       /* Assumes decimal - precision based on number of digits */
+       if (!indio_dev->info->write_raw)
+               return -EINVAL;
+       if (buf[0] == '-') {
+               negative = true;
+               buf++;
+       }
+       while (*buf) {
+               if ('0' <= *buf && *buf <= '9') {
+                       if (integer_part)
+                               integer = integer*10 + *buf - '0';
+                       else {
+                               micro += micro_mult*(*buf - '0');
+                               if (micro_mult == 1)
+                                       break;
+                               micro_mult /= 10;
+                       }
+               } else if (*buf == '\n') {
+                       if (*(buf + 1) == '\0')
+                               break;
+                       else
+                               return -EINVAL;
+               } else if (*buf == '.') {
+                       integer_part = false;
+               } else {
+                       return -EINVAL;
+               }
+               buf++;
+       }
+       if (negative) {
+               if (integer)
+                       integer = -integer;
+               else
+                       micro = -micro;
+       }
+
+       ret = indio_dev->info->write_raw(indio_dev, this_attr->c,
+                                        integer, micro, this_attr->address);
+       if (ret)
+               return ret;
+
+       return len;
+}
+
+static int __iio_build_postfix(struct iio_chan_spec const *chan,
+                              bool generic,
+                              const char *postfix,
+                              char **result)
+{
+       char *all_post;
+       /* 3 options - generic, extend_name, modified - if generic, extend_name
+       * and modified cannot apply.*/
+
+       if (generic || (!chan->modified && !chan->extend_name)) {
+               all_post = kasprintf(GFP_KERNEL, "%s", postfix);
+       } else if (chan->modified) {
+               const char *intermediate;
+               switch (chan->type) {
+               case IIO_INTENSITY:
+                       intermediate
+                               = iio_modifier_names_light[chan->channel2];
+                       break;
+               case IIO_ACCEL:
+               case IIO_GYRO:
+               case IIO_MAGN:
+               case IIO_INCLI:
+               case IIO_ROT:
+               case IIO_ANGL:
+                       intermediate
+                               = iio_modifier_names_axial[chan->channel2];
+                       break;
+               default:
+                       return -EINVAL;
+               }
+               if (chan->extend_name)
+                       all_post = kasprintf(GFP_KERNEL, "%s_%s_%s",
+                                            intermediate,
+                                            chan->extend_name,
+                                            postfix);
+               else
+                       all_post = kasprintf(GFP_KERNEL, "%s_%s",
+                                            intermediate,
+                                            postfix);
+       } else
+               all_post = kasprintf(GFP_KERNEL, "%s_%s", chan->extend_name,
+                                    postfix);
+       if (all_post == NULL)
+               return -ENOMEM;
+       *result = all_post;
+       return 0;
+}
+
+int __iio_device_attr_init(struct device_attribute *dev_attr,
+                          const char *postfix,
+                          struct iio_chan_spec const *chan,
+                          ssize_t (*readfunc)(struct device *dev,
+                                              struct device_attribute *attr,
+                                              char *buf),
+                          ssize_t (*writefunc)(struct device *dev,
+                                               struct device_attribute *attr,
+                                               const char *buf,
+                                               size_t len),
+                          bool generic)
+{
+       int ret;
+       char *name_format, *full_postfix;
+       sysfs_attr_init(&dev_attr->attr);
+       ret = __iio_build_postfix(chan, generic, postfix, &full_postfix);
+       if (ret)
+               goto error_ret;
+
+       /* Special case for types that uses both channel numbers in naming */
+       if (chan->type == IIO_IN_DIFF && !generic)
+               name_format
+                       = kasprintf(GFP_KERNEL, "%s_%s",
+                                   iio_chan_type_name_spec_complex[chan->type],
+                                   full_postfix);
+       else if (generic || !chan->indexed)
+               name_format
+                       = kasprintf(GFP_KERNEL, "%s_%s",
+                                   iio_chan_type_name_spec_shared[chan->type],
+                                   full_postfix);
+       else
+               name_format
+                       = kasprintf(GFP_KERNEL, "%s%d_%s",
+                                   iio_chan_type_name_spec_shared[chan->type],
+                                   chan->channel,
+                                   full_postfix);
+
+       if (name_format == NULL) {
+               ret = -ENOMEM;
+               goto error_free_full_postfix;
+       }
+       dev_attr->attr.name = kasprintf(GFP_KERNEL,
+                                       name_format,
+                                       chan->channel,
+                                       chan->channel2);
+       if (dev_attr->attr.name == NULL) {
+               ret = -ENOMEM;
+               goto error_free_name_format;
+       }
+
+       if (readfunc) {
+               dev_attr->attr.mode |= S_IRUGO;
+               dev_attr->show = readfunc;
+       }
+
+       if (writefunc) {
+               dev_attr->attr.mode |= S_IWUSR;
+               dev_attr->store = writefunc;
+       }
+       kfree(name_format);
+       kfree(full_postfix);
+
+       return 0;
+
+error_free_name_format:
+       kfree(name_format);
+error_free_full_postfix:
+       kfree(full_postfix);
+error_ret:
+       return ret;
+}
+
+void __iio_device_attr_deinit(struct device_attribute *dev_attr)
+{
+       kfree(dev_attr->attr.name);
+}
+
+int __iio_add_chan_devattr(const char *postfix,
+                          const char *group,
+                          struct iio_chan_spec const *chan,
+                          ssize_t (*readfunc)(struct device *dev,
+                                              struct device_attribute *attr,
+                                              char *buf),
+                          ssize_t (*writefunc)(struct device *dev,
+                                               struct device_attribute *attr,
+                                               const char *buf,
+                                               size_t len),
+                          int mask,
+                          bool generic,
+                          struct device *dev,
+                          struct list_head *attr_list)
+{
+       int ret;
+       struct iio_dev_attr *iio_attr, *t;
+
+       iio_attr = kzalloc(sizeof *iio_attr, GFP_KERNEL);
+       if (iio_attr == NULL) {
+               ret = -ENOMEM;
+               goto error_ret;
+       }
+       ret = __iio_device_attr_init(&iio_attr->dev_attr,
+                                    postfix, chan,
+                                    readfunc, writefunc, generic);
+       if (ret)
+               goto error_iio_dev_attr_free;
+       iio_attr->c = chan;
+       iio_attr->address = mask;
+       list_for_each_entry(t, attr_list, l)
+               if (strcmp(t->dev_attr.attr.name,
+                          iio_attr->dev_attr.attr.name) == 0) {
+                       if (!generic)
+                               dev_err(dev, "tried to double register : %s\n",
+                                       t->dev_attr.attr.name);
+                       ret = -EBUSY;
+                       goto error_device_attr_deinit;
+               }
+
+       ret = sysfs_add_file_to_group(&dev->kobj,
+                                     &iio_attr->dev_attr.attr, group);
+       if (ret < 0)
+               goto error_device_attr_deinit;
+
+       list_add(&iio_attr->l, attr_list);
+
+       return 0;
+
+error_device_attr_deinit:
+       __iio_device_attr_deinit(&iio_attr->dev_attr);
+error_iio_dev_attr_free:
+       kfree(iio_attr);
+error_ret:
+       return ret;
+}
+
+static int iio_device_add_channel_sysfs(struct iio_dev *dev_info,
+                                       struct iio_chan_spec const *chan)
+{
+       int ret, i;
+
+
+       if (chan->channel < 0)
+               return 0;
+       if (chan->processed_val)
+               ret = __iio_add_chan_devattr("input", NULL, chan,
+                                            &iio_read_channel_info,
+                                            NULL,
+                                            0,
+                                            0,
+                                            &dev_info->dev,
+                                            &dev_info->channel_attr_list);
+       else
+               ret = __iio_add_chan_devattr("raw", NULL, chan,
+                                            &iio_read_channel_info,
+                                            NULL,
+                                            0,
+                                            0,
+                                            &dev_info->dev,
+                                            &dev_info->channel_attr_list);
+       if (ret)
                goto error_ret;
+
+       for_each_set_bit(i, &chan->info_mask, sizeof(long)*8) {
+               ret = __iio_add_chan_devattr(iio_chan_info_postfix[i/2],
+                                            NULL, chan,
+                                            &iio_read_channel_info,
+                                            &iio_write_channel_info,
+                                            (1 << i),
+                                            !(i%2),
+                                            &dev_info->dev,
+                                            &dev_info->channel_attr_list);
+               if (ret == -EBUSY && (i%2 == 0)) {
+                       ret = 0;
+                       continue;
+               }
+               if (ret < 0)
+                       goto error_ret;
+       }
+error_ret:
+       return ret;
+}
+
+static void iio_device_remove_and_free_read_attr(struct iio_dev *dev_info,
+                                                struct iio_dev_attr *p)
+{
+       sysfs_remove_file_from_group(&dev_info->dev.kobj,
+                                    &p->dev_attr.attr, NULL);
+       kfree(p->dev_attr.attr.name);
+       kfree(p);
+}
+
+static ssize_t iio_show_dev_name(struct device *dev,
+                                struct device_attribute *attr,
+                                char *buf)
+{
+       struct iio_dev *indio_dev = dev_get_drvdata(dev);
+       return sprintf(buf, "%s\n", indio_dev->name);
+}
+
+static DEVICE_ATTR(name, S_IRUGO, iio_show_dev_name, NULL);
+
+static int iio_device_register_sysfs(struct iio_dev *dev_info)
+{
+       int i, ret = 0;
+       struct iio_dev_attr *p, *n;
+
+       if (dev_info->info->attrs) {
+               ret = sysfs_create_group(&dev_info->dev.kobj,
+                                        dev_info->info->attrs);
+               if (ret) {
+                       dev_err(dev_info->dev.parent,
+                               "Failed to register sysfs hooks\n");
+                       goto error_ret;
+               }
+       }
+
+       /*
+        * New channel registration method - relies on the fact a group does
+        *  not need to be initialized if it is name is NULL.
+        */
+       INIT_LIST_HEAD(&dev_info->channel_attr_list);
+       if (dev_info->channels)
+               for (i = 0; i < dev_info->num_channels; i++) {
+                       ret = iio_device_add_channel_sysfs(dev_info,
+                                                          &dev_info
+                                                          ->channels[i]);
+                       if (ret < 0)
+                               goto error_clear_attrs;
+               }
+       if (dev_info->name) {
+               ret = sysfs_add_file_to_group(&dev_info->dev.kobj,
+                                             &dev_attr_name.attr,
+                                             NULL);
+               if (ret)
+                       goto error_clear_attrs;
        }
+       return 0;
 
+error_clear_attrs:
+       list_for_each_entry_safe(p, n,
+                                &dev_info->channel_attr_list, l) {
+               list_del(&p->l);
+               iio_device_remove_and_free_read_attr(dev_info, p);
+       }
+       if (dev_info->info->attrs)
+               sysfs_remove_group(&dev_info->dev.kobj, dev_info->info->attrs);
 error_ret:
        return ret;
+
 }
 
 static void iio_device_unregister_sysfs(struct iio_dev *dev_info)
 {
-       sysfs_remove_group(&dev_info->dev.kobj, dev_info->attrs);
+
+       struct iio_dev_attr *p, *n;
+       if (dev_info->name)
+               sysfs_remove_file_from_group(&dev_info->dev.kobj,
+                                            &dev_attr_name.attr,
+                                            NULL);
+       list_for_each_entry_safe(p, n, &dev_info->channel_attr_list, l) {
+               list_del(&p->l);
+               iio_device_remove_and_free_read_attr(dev_info, p);
+       }
+
+       if (dev_info->info->attrs)
+               sysfs_remove_group(&dev_info->dev.kobj, dev_info->info->attrs);
 }
 
 /* Return a negative errno on failure */
@@ -538,48 +799,209 @@ void iio_free_ida_val(struct ida *this_ida, int id)
 }
 EXPORT_SYMBOL(iio_free_ida_val);
 
-static int iio_device_register_id(struct iio_dev *dev_info,
-                                 struct ida *this_ida)
+static const char * const iio_ev_type_text[] = {
+       [IIO_EV_TYPE_THRESH] = "thresh",
+       [IIO_EV_TYPE_MAG] = "mag",
+       [IIO_EV_TYPE_ROC] = "roc"
+};
+
+static const char * const iio_ev_dir_text[] = {
+       [IIO_EV_DIR_EITHER] = "either",
+       [IIO_EV_DIR_RISING] = "rising",
+       [IIO_EV_DIR_FALLING] = "falling"
+};
+
+static ssize_t iio_ev_state_store(struct device *dev,
+                                 struct device_attribute *attr,
+                                 const char *buf,
+                                 size_t len)
 {
-       dev_info->id = iio_get_new_ida_val(&iio_ida);
-       if (dev_info->id < 0)
-               return dev_info->id;
-       return 0;
+       struct iio_dev *indio_dev = dev_get_drvdata(dev);
+       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
+       int ret;
+       bool val;
+
+       ret = strtobool(buf, &val);
+       if (ret < 0)
+               return ret;
+
+       ret = indio_dev->info->write_event_config(indio_dev,
+                                                 this_attr->address,
+                                                 val);
+       return (ret < 0) ? ret : len;
 }
 
-static void iio_device_unregister_id(struct iio_dev *dev_info)
+static ssize_t iio_ev_state_show(struct device *dev,
+                                struct device_attribute *attr,
+                                char *buf)
 {
-       iio_free_ida_val(&iio_ida, dev_info->id);
+       struct iio_dev *indio_dev = dev_get_drvdata(dev);
+       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
+       int val = indio_dev->info->read_event_config(indio_dev,
+                                                    this_attr->address);
+
+       if (val < 0)
+               return val;
+       else
+               return sprintf(buf, "%d\n", val);
+}
+
+static ssize_t iio_ev_value_show(struct device *dev,
+                                struct device_attribute *attr,
+                                char *buf)
+{
+       struct iio_dev *indio_dev = dev_get_drvdata(dev);
+       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
+       int val, ret;
+
+       ret = indio_dev->info->read_event_value(indio_dev,
+                                               this_attr->address, &val);
+       if (ret < 0)
+               return ret;
+
+       return sprintf(buf, "%d\n", val);
+}
+
+static ssize_t iio_ev_value_store(struct device *dev,
+                                 struct device_attribute *attr,
+                                 const char *buf,
+                                 size_t len)
+{
+       struct iio_dev *indio_dev = dev_get_drvdata(dev);
+       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
+       unsigned long val;
+       int ret;
+
+       ret = strict_strtoul(buf, 10, &val);
+       if (ret)
+               return ret;
+
+       ret = indio_dev->info->write_event_value(indio_dev, this_attr->address,
+                                                val);
+       if (ret < 0)
+               return ret;
+
+       return len;
+}
+
+static int iio_device_add_event_sysfs(struct iio_dev *dev_info,
+                                     struct iio_chan_spec const *chan)
+{
+
+       int ret = 0, i, mask;
+       char *postfix;
+       if (!chan->event_mask)
+               return 0;
+
+       for_each_set_bit(i, &chan->event_mask, sizeof(chan->event_mask)*8) {
+               postfix = kasprintf(GFP_KERNEL, "%s_%s_en",
+                                   iio_ev_type_text[i/IIO_EV_TYPE_MAX],
+                                   iio_ev_dir_text[i%IIO_EV_TYPE_MAX]);
+               if (postfix == NULL) {
+                       ret = -ENOMEM;
+                       goto error_ret;
+               }
+               switch (chan->type) {
+                       /* Switch this to a table at some point */
+               case IIO_IN:
+                       mask = IIO_UNMOD_EVENT_CODE(chan->type, chan->channel,
+                                                   i/IIO_EV_TYPE_MAX,
+                                                   i%IIO_EV_TYPE_MAX);
+                       break;
+               case IIO_ACCEL:
+                       mask = IIO_MOD_EVENT_CODE(chan->type, 0, chan->channel,
+                                                 i/IIO_EV_TYPE_MAX,
+                                                 i%IIO_EV_TYPE_MAX);
+                       break;
+               case IIO_IN_DIFF:
+                       mask = IIO_MOD_EVENT_CODE(chan->type, chan->channel,
+                                                 chan->channel2,
+                                                 i/IIO_EV_TYPE_MAX,
+                                                 i%IIO_EV_TYPE_MAX);
+                       break;
+               default:
+                       printk(KERN_INFO "currently unhandled type of event\n");
+               }
+               ret = __iio_add_chan_devattr(postfix,
+                                            NULL,
+                                            chan,
+                                            &iio_ev_state_show,
+                                            iio_ev_state_store,
+                                            mask,
+                                            /*HACK. - limits us to one
+                                              event interface - fix by
+                                              extending the bitmask - but
+                                              how far*/
+                                            0,
+                                            &dev_info->event_interfaces[0].dev,
+                                            &dev_info->event_interfaces[0].
+                                            dev_attr_list);
+               kfree(postfix);
+               if (ret)
+                       goto error_ret;
+
+               postfix = kasprintf(GFP_KERNEL, "%s_%s_value",
+                                   iio_ev_type_text[i/IIO_EV_TYPE_MAX],
+                                   iio_ev_dir_text[i%IIO_EV_TYPE_MAX]);
+               if (postfix == NULL) {
+                       ret = -ENOMEM;
+                       goto error_ret;
+               }
+               ret = __iio_add_chan_devattr(postfix, NULL, chan,
+                                            iio_ev_value_show,
+                                            iio_ev_value_store,
+                                            mask,
+                                            0,
+                                            &dev_info->event_interfaces[0]
+                                            .dev,
+                                            &dev_info->event_interfaces[0]
+                                            .dev_attr_list);
+               kfree(postfix);
+               if (ret)
+                       goto error_ret;
+
+       }
+
+error_ret:
+       return ret;
+}
+
+static inline void __iio_remove_all_event_sysfs(struct iio_dev *dev_info,
+                                               const char *groupname,
+                                               int num)
+{
+       struct iio_dev_attr *p, *n;
+       list_for_each_entry_safe(p, n,
+                                &dev_info->event_interfaces[num].
+                                dev_attr_list, l) {
+               sysfs_remove_file_from_group(&dev_info
+                                            ->event_interfaces[num].dev.kobj,
+                                            &p->dev_attr.attr,
+                                            groupname);
+               kfree(p->dev_attr.attr.name);
+               kfree(p);
+       }
 }
 
 static inline int __iio_add_event_config_attrs(struct iio_dev *dev_info, int i)
 {
+       int j;
        int ret;
-       /*p for adding, q for removing */
-       struct attribute **attrp, **attrq;
-
-       if (dev_info->event_conf_attrs && dev_info->event_conf_attrs[i].attrs) {
-               attrp = dev_info->event_conf_attrs[i].attrs;
-               while (*attrp) {
-                       ret =  sysfs_add_file_to_group(&dev_info->dev.kobj,
-                                                      *attrp,
-                                                      dev_info
-                                                      ->event_attrs[i].name);
+       INIT_LIST_HEAD(&dev_info->event_interfaces[0].dev_attr_list);
+       /* Dynically created from the channels array */
+       if (dev_info->channels) {
+               for (j = 0; j < dev_info->num_channels; j++) {
+                       ret = iio_device_add_event_sysfs(dev_info,
+                                                        &dev_info
+                                                        ->channels[j]);
                        if (ret)
-                               goto error_ret;
-                       attrp++;
+                               goto error_clear_attrs;
                }
        }
        return 0;
 
-error_ret:
-       attrq = dev_info->event_conf_attrs[i].attrs;
-       while (attrq != attrp) {
-                       sysfs_remove_file_from_group(&dev_info->dev.kobj,
-                                            *attrq,
-                                            dev_info->event_attrs[i].name);
-               attrq++;
-       }
+error_clear_attrs:
+       __iio_remove_all_event_sysfs(dev_info, NULL, i);
 
        return ret;
 }
@@ -587,20 +1009,7 @@ error_ret:
 static inline int __iio_remove_event_config_attrs(struct iio_dev *dev_info,
                                                  int i)
 {
-       struct attribute **attrq;
-
-       if (dev_info->event_conf_attrs
-               && dev_info->event_conf_attrs[i].attrs) {
-               attrq = dev_info->event_conf_attrs[i].attrs;
-               while (*attrq) {
-                       sysfs_remove_file_from_group(&dev_info->dev.kobj,
-                                                    *attrq,
-                                                    dev_info
-                                                    ->event_attrs[i].name);
-                       attrq++;
-               }
-       }
-
+       __iio_remove_all_event_sysfs(dev_info, NULL, i);
        return 0;
 }
 
@@ -608,39 +1017,23 @@ static int iio_device_register_eventset(struct iio_dev *dev_info)
 {
        int ret = 0, i, j;
 
-       if (dev_info->num_interrupt_lines == 0)
+       if (dev_info->info->num_interrupt_lines == 0)
                return 0;
 
        dev_info->event_interfaces =
                kzalloc(sizeof(struct iio_event_interface)
-                       *dev_info->num_interrupt_lines,
+                       *dev_info->info->num_interrupt_lines,
                        GFP_KERNEL);
        if (dev_info->event_interfaces == NULL) {
                ret = -ENOMEM;
                goto error_ret;
        }
 
-       dev_info->interrupts = kzalloc(sizeof(struct iio_interrupt *)
-                                      *dev_info->num_interrupt_lines,
-                                      GFP_KERNEL);
-       if (dev_info->interrupts == NULL) {
-               ret = -ENOMEM;
-               goto error_free_event_interfaces;
-       }
-
-       for (i = 0; i < dev_info->num_interrupt_lines; i++) {
-               dev_info->event_interfaces[i].owner = dev_info->driver_module;
-
-               snprintf(dev_info->event_interfaces[i]._name, 20,
-                        "%s:event%d",
-                        dev_name(&dev_info->dev),
-                        i);
-
+       for (i = 0; i < dev_info->info->num_interrupt_lines; i++) {
                ret = iio_setup_ev_int(&dev_info->event_interfaces[i],
-                                      (const char *)(dev_info
-                                                     ->event_interfaces[i]
-                                                     ._name),
-                                      dev_info->driver_module,
+                                      dev_name(&dev_info->dev),
+                                      i,
+                                      dev_info->info->driver_module,
                                       &dev_info->dev);
                if (ret) {
                        dev_err(&dev_info->dev,
@@ -650,10 +1043,13 @@ static int iio_device_register_eventset(struct iio_dev *dev_info)
 
                dev_set_drvdata(&dev_info->event_interfaces[i].dev,
                                (void *)dev_info);
-               ret = sysfs_create_group(&dev_info
-                                       ->event_interfaces[i]
-                                       .dev.kobj,
-                                       &dev_info->event_attrs[i]);
+
+               if (dev_info->info->event_attrs != NULL)
+                       ret = sysfs_create_group(&dev_info
+                                                ->event_interfaces[i]
+                                                .dev.kobj,
+                                                &dev_info->info
+                                                ->event_attrs[i]);
 
                if (ret) {
                        dev_err(&dev_info->dev,
@@ -662,7 +1058,7 @@ static int iio_device_register_eventset(struct iio_dev *dev_info)
                }
        }
 
-       for (i = 0; i < dev_info->num_interrupt_lines; i++) {
+       for (i = 0; i < dev_info->info->num_interrupt_lines; i++) {
                ret = __iio_add_event_config_attrs(dev_info, i);
                if (ret)
                        goto error_unregister_config_attrs;
@@ -673,17 +1069,16 @@ static int iio_device_register_eventset(struct iio_dev *dev_info)
 error_unregister_config_attrs:
        for (j = 0; j < i; j++)
                __iio_remove_event_config_attrs(dev_info, i);
-       i = dev_info->num_interrupt_lines - 1;
+       i = dev_info->info->num_interrupt_lines - 1;
 error_remove_sysfs_interfaces:
        for (j = 0; j < i; j++)
-               sysfs_remove_group(&dev_info
+               if (dev_info->info->event_attrs != NULL)
+                       sysfs_remove_group(&dev_info
                                   ->event_interfaces[j].dev.kobj,
-                                  &dev_info->event_attrs[j]);
+                                  &dev_info->info->event_attrs[j]);
 error_free_setup_ev_ints:
        for (j = 0; j < i; j++)
                iio_free_ev_int(&dev_info->event_interfaces[j]);
-       kfree(dev_info->interrupts);
-error_free_event_interfaces:
        kfree(dev_info->event_interfaces);
 error_ret:
 
@@ -694,25 +1089,25 @@ static void iio_device_unregister_eventset(struct iio_dev *dev_info)
 {
        int i;
 
-       if (dev_info->num_interrupt_lines == 0)
+       if (dev_info->info->num_interrupt_lines == 0)
                return;
-       for (i = 0; i < dev_info->num_interrupt_lines; i++)
-               sysfs_remove_group(&dev_info
-                                  ->event_interfaces[i].dev.kobj,
-                                  &dev_info->event_attrs[i]);
+       for (i = 0; i < dev_info->info->num_interrupt_lines; i++) {
+               __iio_remove_event_config_attrs(dev_info, i);
+               if (dev_info->info->event_attrs != NULL)
+                       sysfs_remove_group(&dev_info
+                                          ->event_interfaces[i].dev.kobj,
+                                          &dev_info->info->event_attrs[i]);
+       }
 
-       for (i = 0; i < dev_info->num_interrupt_lines; i++)
+       for (i = 0; i < dev_info->info->num_interrupt_lines; i++)
                iio_free_ev_int(&dev_info->event_interfaces[i]);
-       kfree(dev_info->interrupts);
        kfree(dev_info->event_interfaces);
 }
 
 static void iio_dev_release(struct device *device)
 {
-       struct iio_dev *dev = to_iio_dev(device);
-
        iio_put();
-       kfree(dev);
+       kfree(to_iio_dev(device));
 }
 
 static struct device_type iio_dev_type = {
@@ -720,9 +1115,20 @@ static struct device_type iio_dev_type = {
        .release = iio_dev_release,
 };
 
-struct iio_dev *iio_allocate_device(void)
+struct iio_dev *iio_allocate_device(int sizeof_priv)
 {
-       struct iio_dev *dev = kzalloc(sizeof *dev, GFP_KERNEL);
+       struct iio_dev *dev;
+       size_t alloc_size;
+
+       alloc_size = sizeof(struct iio_dev);
+       if (sizeof_priv) {
+               alloc_size = ALIGN(alloc_size, IIO_ALIGN);
+               alloc_size += sizeof_priv;
+       }
+       /* ensure 32-byte alignment of whole construct ? */
+       alloc_size += IIO_ALIGN - 1;
+
+       dev = kzalloc(alloc_size, GFP_KERNEL);
 
        if (dev) {
                dev->dev.type = &iio_dev_type;
@@ -748,8 +1154,9 @@ int iio_device_register(struct iio_dev *dev_info)
 {
        int ret;
 
-       ret = iio_device_register_id(dev_info, &iio_ida);
-       if (ret) {
+       dev_info->id = iio_get_new_ida_val(&iio_ida);
+       if (dev_info->id < 0) {
+               ret = dev_info->id;
                dev_err(&dev_info->dev, "Failed to get id\n");
                goto error_ret;
        }
@@ -780,7 +1187,7 @@ error_free_sysfs:
 error_del_device:
        device_del(&dev_info->dev);
 error_free_ida:
-       iio_device_unregister_id(dev_info);
+       iio_free_ida_val(&iio_ida, dev_info->id);
 error_ret:
        return ret;
 }
@@ -792,7 +1199,7 @@ void iio_device_unregister(struct iio_dev *dev_info)
                iio_device_unregister_trigger_consumer(dev_info);
        iio_device_unregister_eventset(dev_info);
        iio_device_unregister_sysfs(dev_info);
-       iio_device_unregister_id(dev_info);
+       iio_free_ida_val(&iio_ida, dev_info->id);
        device_unregister(&dev_info->dev);
 }
 EXPORT_SYMBOL(iio_device_unregister);
index bd4373ae066bd5030ee21961d9b86bd3e20b86d8..843eb82a69ba34e7601d79cc1a4dba0a4ca335eb 100644 (file)
 #include <linux/fs.h>
 #include <linux/cdev.h>
 #include <linux/slab.h>
+#include <linux/poll.h>
 
 #include "iio.h"
 #include "ring_generic.h"
 
-int iio_push_ring_event(struct iio_ring_buffer *ring_buf,
-                      int event_code,
-                      s64 timestamp)
-{
-       return __iio_push_event(&ring_buf->ev_int,
-                              event_code,
-                              timestamp,
-                              &ring_buf->shared_ev_pointer);
-}
-EXPORT_SYMBOL(iio_push_ring_event);
-
-int iio_push_or_escallate_ring_event(struct iio_ring_buffer *ring_buf,
-                                   int event_code,
-                                   s64 timestamp)
-{
-       if (ring_buf->shared_ev_pointer.ev_p)
-               __iio_change_event(ring_buf->shared_ev_pointer.ev_p,
-                                  event_code,
-                                  timestamp);
-       else
-               return iio_push_ring_event(ring_buf,
-                                         event_code,
-                                         timestamp);
-       return 0;
-}
-EXPORT_SYMBOL(iio_push_or_escallate_ring_event);
-
 /**
  * iio_ring_open() - chrdev file open for ring buffer access
  *
@@ -62,8 +36,8 @@ static int iio_ring_open(struct inode *inode, struct file *filp)
        struct iio_ring_buffer *rb = hand->private;
 
        filp->private_data = hand->private;
-       if (rb->access.mark_in_use)
-               rb->access.mark_in_use(rb);
+       if (rb->access->mark_in_use)
+               rb->access->mark_in_use(rb);
 
        return 0;
 }
@@ -81,184 +55,316 @@ static int iio_ring_release(struct inode *inode, struct file *filp)
        struct iio_ring_buffer *rb = hand->private;
 
        clear_bit(IIO_BUSY_BIT_POS, &rb->access_handler.flags);
-       if (rb->access.unmark_in_use)
-               rb->access.unmark_in_use(rb);
+       if (rb->access->unmark_in_use)
+               rb->access->unmark_in_use(rb);
 
        return 0;
 }
 
 /**
- * iio_ring_rip_outer() - chrdev read for ring buffer access
+ * iio_ring_read_first_n_outer() - chrdev read for ring buffer access
  *
  * This function relies on all ring buffer implementations having an
  * iio_ring _bufer as their first element.
  **/
-static ssize_t iio_ring_rip_outer(struct file *filp, char __user *buf,
-                                 size_t count, loff_t *f_ps)
+static ssize_t iio_ring_read_first_n_outer(struct file *filp, char __user *buf,
+                                 size_t n, loff_t *f_ps)
 {
        struct iio_ring_buffer *rb = filp->private_data;
-       int ret, dead_offset;
 
-       /* rip lots must exist. */
-       if (!rb->access.rip_lots)
+       if (!rb->access->read_first_n)
                return -EINVAL;
-       ret = rb->access.rip_lots(rb, count, buf, &dead_offset);
+       return rb->access->read_first_n(rb, n, buf);
+}
 
-       return ret;
+/**
+ * iio_ring_poll() - poll the ring to find out if it has data
+ */
+static unsigned int iio_ring_poll(struct file *filp,
+                                 struct poll_table_struct *wait)
+{
+       struct iio_ring_buffer *rb = filp->private_data;
+
+       poll_wait(filp, &rb->pollq, wait);
+       if (rb->stufftoread)
+               return POLLIN | POLLRDNORM;
+       /* need a way of knowing if there may be enough data... */
+       return 0;
 }
 
 static const struct file_operations iio_ring_fileops = {
-       .read = iio_ring_rip_outer,
+       .read = iio_ring_read_first_n_outer,
        .release = iio_ring_release,
        .open = iio_ring_open,
+       .poll = iio_ring_poll,
        .owner = THIS_MODULE,
        .llseek = noop_llseek,
 };
 
-/**
- * __iio_request_ring_buffer_event_chrdev() - allocate ring event chrdev
- * @buf:       ring buffer whose event chrdev we are allocating
- * @id:                id of this ring buffer (typically 0)
- * @owner:     the module who owns the ring buffer (for ref counting)
- * @dev:       device with which the chrdev is associated
- **/
-static inline int
-__iio_request_ring_buffer_event_chrdev(struct iio_ring_buffer *buf,
-                                      int id,
-                                      struct module *owner,
-                                      struct device *dev)
-{
-       int ret;
-
-       snprintf(buf->ev_int._name, sizeof(buf->ev_int._name),
-                "%s:event%d",
-                dev_name(&buf->dev),
-                id);
-       ret = iio_setup_ev_int(&(buf->ev_int),
-                              buf->ev_int._name,
-                              owner,
-                              dev);
-       if (ret)
-               goto error_ret;
-       return 0;
-
-error_ret:
-       return ret;
-}
-
-static inline void
-__iio_free_ring_buffer_event_chrdev(struct iio_ring_buffer *buf)
-{
-       iio_free_ev_int(&(buf->ev_int));
-}
-
-static void iio_ring_access_release(struct device *dev)
+void iio_ring_access_release(struct device *dev)
 {
        struct iio_ring_buffer *buf
-               = access_dev_to_iio_ring_buffer(dev);
+               = container_of(dev, struct iio_ring_buffer, dev);
        cdev_del(&buf->access_handler.chrdev);
        iio_device_free_chrdev_minor(MINOR(dev->devt));
 }
-
-static struct device_type iio_ring_access_type = {
-       .release = iio_ring_access_release,
-};
+EXPORT_SYMBOL(iio_ring_access_release);
 
 static inline int
-__iio_request_ring_buffer_access_chrdev(struct iio_ring_buffer *buf,
-                                       int id,
-                                       struct module *owner)
+__iio_request_ring_buffer_chrdev(struct iio_ring_buffer *buf,
+                                struct module *owner,
+                                int id)
 {
-       int ret, minor;
+       int ret;
 
        buf->access_handler.flags = 0;
+       buf->dev.bus = &iio_bus_type;
+       device_initialize(&buf->dev);
 
-       buf->access_dev.parent = &buf->dev;
-       buf->access_dev.bus = &iio_bus_type;
-       buf->access_dev.type = &iio_ring_access_type;
-       device_initialize(&buf->access_dev);
-
-       minor = iio_device_get_chrdev_minor();
-       if (minor < 0) {
-               ret = minor;
+       ret = iio_device_get_chrdev_minor();
+       if (ret < 0)
                goto error_device_put;
-       }
-       buf->access_dev.devt = MKDEV(MAJOR(iio_devt), minor);
 
-
-       buf->access_id = id;
-
-       dev_set_name(&buf->access_dev, "%s:access%d",
-                    dev_name(&buf->dev),
-                    buf->access_id);
-       ret = device_add(&buf->access_dev);
+       buf->dev.devt = MKDEV(MAJOR(iio_devt), ret);
+       dev_set_name(&buf->dev, "%s:buffer%d",
+                    dev_name(buf->dev.parent),
+                    id);
+       ret = device_add(&buf->dev);
        if (ret < 0) {
-               printk(KERN_ERR "failed to add the ring access dev\n");
+               printk(KERN_ERR "failed to add the ring dev\n");
                goto error_device_put;
        }
-
        cdev_init(&buf->access_handler.chrdev, &iio_ring_fileops);
        buf->access_handler.chrdev.owner = owner;
-
-       ret = cdev_add(&buf->access_handler.chrdev, buf->access_dev.devt, 1);
+       ret = cdev_add(&buf->access_handler.chrdev, buf->dev.devt, 1);
        if (ret) {
-               printk(KERN_ERR "failed to allocate ring access chrdev\n");
+               printk(KERN_ERR "failed to allocate ring chrdev\n");
                goto error_device_unregister;
        }
        return 0;
 
 error_device_unregister:
-       device_unregister(&buf->access_dev);
+       device_unregister(&buf->dev);
 error_device_put:
-       put_device(&buf->access_dev);
+       put_device(&buf->dev);
 
        return ret;
 }
 
-static void __iio_free_ring_buffer_access_chrdev(struct iio_ring_buffer *buf)
+static void __iio_free_ring_buffer_chrdev(struct iio_ring_buffer *buf)
 {
-       device_unregister(&buf->access_dev);
+       device_unregister(&buf->dev);
 }
 
 void iio_ring_buffer_init(struct iio_ring_buffer *ring,
                          struct iio_dev *dev_info)
 {
-       if (ring->access.mark_param_change)
-               ring->access.mark_param_change(ring);
        ring->indio_dev = dev_info;
-       ring->ev_int.private = ring;
        ring->access_handler.private = ring;
-       ring->shared_ev_pointer.ev_p = NULL;
-       spin_lock_init(&ring->shared_ev_pointer.lock);
+       init_waitqueue_head(&ring->pollq);
 }
 EXPORT_SYMBOL(iio_ring_buffer_init);
 
-int iio_ring_buffer_register(struct iio_ring_buffer *ring, int id)
+static ssize_t iio_show_scan_index(struct device *dev,
+                                  struct device_attribute *attr,
+                                  char *buf)
+{
+       return sprintf(buf, "%u\n", to_iio_dev_attr(attr)->c->scan_index);
+}
+
+static ssize_t iio_show_fixed_type(struct device *dev,
+                                  struct device_attribute *attr,
+                                  char *buf)
+{
+       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
+       return sprintf(buf, "%c%d/%d>>%u\n",
+                      this_attr->c->scan_type.sign,
+                      this_attr->c->scan_type.realbits,
+                      this_attr->c->scan_type.storagebits,
+                      this_attr->c->scan_type.shift);
+}
+
+static ssize_t iio_scan_el_show(struct device *dev,
+                               struct device_attribute *attr,
+                               char *buf)
 {
        int ret;
+       struct iio_ring_buffer *ring = dev_get_drvdata(dev);
+
+       ret = iio_scan_mask_query(ring, to_iio_dev_attr(attr)->address);
+       if (ret < 0)
+               return ret;
+       return sprintf(buf, "%d\n", ret);
+}
 
-       ring->id = id;
+static int iio_scan_mask_clear(struct iio_ring_buffer *ring, int bit)
+{
+       if (bit > IIO_MAX_SCAN_LENGTH)
+               return -EINVAL;
+       ring->scan_mask &= ~(1 << bit);
+       ring->scan_count--;
+       return 0;
+}
+
+static ssize_t iio_scan_el_store(struct device *dev,
+                                struct device_attribute *attr,
+                                const char *buf,
+                                size_t len)
+{
+       int ret = 0;
+       bool state;
+       struct iio_ring_buffer *ring = dev_get_drvdata(dev);
+       struct iio_dev *indio_dev = ring->indio_dev;
+       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
+
+       state = !(buf[0] == '0');
+       mutex_lock(&indio_dev->mlock);
+       if (indio_dev->currentmode == INDIO_RING_TRIGGERED) {
+               ret = -EBUSY;
+               goto error_ret;
+       }
+       ret = iio_scan_mask_query(ring, this_attr->address);
+       if (ret < 0)
+               goto error_ret;
+       if (!state && ret) {
+               ret = iio_scan_mask_clear(ring, this_attr->address);
+               if (ret)
+                       goto error_ret;
+       } else if (state && !ret) {
+               ret = iio_scan_mask_set(ring, this_attr->address);
+               if (ret)
+                       goto error_ret;
+       }
+
+error_ret:
+       mutex_unlock(&indio_dev->mlock);
+
+       return ret ? ret : len;
+
+}
+
+static ssize_t iio_scan_el_ts_show(struct device *dev,
+                                  struct device_attribute *attr,
+                                  char *buf)
+{
+       struct iio_ring_buffer *ring = dev_get_drvdata(dev);
+       return sprintf(buf, "%d\n", ring->scan_timestamp);
+}
+
+static ssize_t iio_scan_el_ts_store(struct device *dev,
+                                   struct device_attribute *attr,
+                                   const char *buf,
+                                   size_t len)
+{
+       int ret = 0;
+       struct iio_ring_buffer *ring = dev_get_drvdata(dev);
+       struct iio_dev *indio_dev = ring->indio_dev;
+       bool state;
+       state = !(buf[0] == '0');
+       mutex_lock(&indio_dev->mlock);
+       if (indio_dev->currentmode == INDIO_RING_TRIGGERED) {
+               ret = -EBUSY;
+               goto error_ret;
+       }
+       ring->scan_timestamp = state;
+error_ret:
+       mutex_unlock(&indio_dev->mlock);
 
-       dev_set_name(&ring->dev, "%s:buffer%d",
-                    dev_name(ring->dev.parent),
-                    ring->id);
-       ret = device_add(&ring->dev);
+       return ret ? ret : len;
+}
+
+static int iio_ring_add_channel_sysfs(struct iio_ring_buffer *ring,
+                                     const struct iio_chan_spec *chan)
+{
+       int ret;
+
+       ret = __iio_add_chan_devattr("index", "scan_elements",
+                                    chan,
+                                    &iio_show_scan_index,
+                                    NULL,
+                                    0,
+                                    0,
+                                    &ring->dev,
+                                    &ring->scan_el_dev_attr_list);
        if (ret)
                goto error_ret;
 
-       ret = __iio_request_ring_buffer_event_chrdev(ring,
-                                                    0,
-                                                    ring->owner,
-                                                    &ring->dev);
+       ret = __iio_add_chan_devattr("type", "scan_elements",
+                                    chan,
+                                    &iio_show_fixed_type,
+                                    NULL,
+                                    0,
+                                    0,
+                                    &ring->dev,
+                                    &ring->scan_el_dev_attr_list);
        if (ret)
-               goto error_remove_device;
+               goto error_ret;
+
+       if (chan->type != IIO_TIMESTAMP)
+               ret = __iio_add_chan_devattr("en", "scan_elements",
+                                            chan,
+                                            &iio_scan_el_show,
+                                            &iio_scan_el_store,
+                                            chan->scan_index,
+                                            0,
+                                            &ring->dev,
+                                            &ring->scan_el_dev_attr_list);
+       else
+               ret = __iio_add_chan_devattr("en", "scan_elements",
+                                            chan,
+                                            &iio_scan_el_ts_show,
+                                            &iio_scan_el_ts_store,
+                                            chan->scan_index,
+                                            0,
+                                            &ring->dev,
+                                            &ring->scan_el_dev_attr_list);
+error_ret:
+       return ret;
+}
+
+static void iio_ring_remove_and_free_scan_dev_attr(struct iio_ring_buffer *ring,
+                                                  struct iio_dev_attr *p)
+{
+       sysfs_remove_file_from_group(&ring->dev.kobj,
+                                    &p->dev_attr.attr, "scan_elements");
+       kfree(p->dev_attr.attr.name);
+       kfree(p);
+}
+
+static struct attribute *iio_scan_el_dummy_attrs[] = {
+       NULL
+};
+
+static struct attribute_group iio_scan_el_dummy_group = {
+       .name = "scan_elements",
+       .attrs = iio_scan_el_dummy_attrs
+};
+
+static void __iio_ring_attr_cleanup(struct iio_ring_buffer *ring)
+{
+       struct iio_dev_attr *p, *n;
+       int anydynamic = !list_empty(&ring->scan_el_dev_attr_list);
+       list_for_each_entry_safe(p, n,
+                                &ring->scan_el_dev_attr_list, l)
+               iio_ring_remove_and_free_scan_dev_attr(ring, p);
+
+       if (ring->scan_el_attrs)
+               sysfs_remove_group(&ring->dev.kobj,
+                                  ring->scan_el_attrs);
+       else if (anydynamic)
+               sysfs_remove_group(&ring->dev.kobj,
+                                  &iio_scan_el_dummy_group);
+}
 
-       ret = __iio_request_ring_buffer_access_chrdev(ring,
-                                                     0,
-                                                     ring->owner);
+int iio_ring_buffer_register_ex(struct iio_ring_buffer *ring, int id,
+                               const struct iio_chan_spec *channels,
+                               int num_channels)
+{
+       int ret, i;
 
+       ret = __iio_request_ring_buffer_chrdev(ring, ring->owner, id);
        if (ret)
-               goto error_free_ring_buffer_event_chrdev;
+               goto error_ret;
 
        if (ring->scan_el_attrs) {
                ret = sysfs_create_group(&ring->dev.kobj,
@@ -266,29 +372,39 @@ int iio_ring_buffer_register(struct iio_ring_buffer *ring, int id)
                if (ret) {
                        dev_err(&ring->dev,
                                "Failed to add sysfs scan elements\n");
-                       goto error_free_ring_buffer_event_chrdev;
+                       goto error_free_ring_buffer_chrdev;
                }
+       } else if (channels) {
+               ret = sysfs_create_group(&ring->dev.kobj,
+                                        &iio_scan_el_dummy_group);
+               if (ret)
+                       goto error_free_ring_buffer_chrdev;
        }
 
-       return ret;
-error_free_ring_buffer_event_chrdev:
-       __iio_free_ring_buffer_event_chrdev(ring);
-error_remove_device:
-       device_del(&ring->dev);
+       INIT_LIST_HEAD(&ring->scan_el_dev_attr_list);
+       if (channels) {
+               /* new magic */
+               for (i = 0; i < num_channels; i++) {
+                       ret = iio_ring_add_channel_sysfs(ring, &channels[i]);
+                       if (ret < 0)
+                               goto error_cleanup_dynamic;
+               }
+       }
+
+       return 0;
+error_cleanup_dynamic:
+       __iio_ring_attr_cleanup(ring);
+error_free_ring_buffer_chrdev:
+       __iio_free_ring_buffer_chrdev(ring);
 error_ret:
        return ret;
 }
-EXPORT_SYMBOL(iio_ring_buffer_register);
+EXPORT_SYMBOL(iio_ring_buffer_register_ex);
 
 void iio_ring_buffer_unregister(struct iio_ring_buffer *ring)
 {
-       if (ring->scan_el_attrs)
-               sysfs_remove_group(&ring->dev.kobj,
-                                  ring->scan_el_attrs);
-
-       __iio_free_ring_buffer_access_chrdev(ring);
-       __iio_free_ring_buffer_event_chrdev(ring);
-       device_del(&ring->dev);
+       __iio_ring_attr_cleanup(ring);
+       __iio_free_ring_buffer_chrdev(ring);
 }
 EXPORT_SYMBOL(iio_ring_buffer_unregister);
 
@@ -296,14 +412,13 @@ ssize_t iio_read_ring_length(struct device *dev,
                             struct device_attribute *attr,
                             char *buf)
 {
-       int len = 0;
        struct iio_ring_buffer *ring = dev_get_drvdata(dev);
 
-       if (ring->access.get_length)
-               len = sprintf(buf, "%d\n",
-                             ring->access.get_length(ring));
+       if (ring->access->get_length)
+               return sprintf(buf, "%d\n",
+                              ring->access->get_length(ring));
 
-       return len;
+       return 0;
 }
 EXPORT_SYMBOL(iio_read_ring_length);
 
@@ -315,18 +430,19 @@ ssize_t iio_write_ring_length(struct device *dev,
        int ret;
        ulong val;
        struct iio_ring_buffer *ring = dev_get_drvdata(dev);
+
        ret = strict_strtoul(buf, 10, &val);
        if (ret)
                return ret;
 
-       if (ring->access.get_length)
-               if (val == ring->access.get_length(ring))
+       if (ring->access->get_length)
+               if (val == ring->access->get_length(ring))
                        return len;
 
-       if (ring->access.set_length) {
-               ring->access.set_length(ring, val);
-               if (ring->access.mark_param_change)
-                       ring->access.mark_param_change(ring);
+       if (ring->access->set_length) {
+               ring->access->set_length(ring, val);
+               if (ring->access->mark_param_change)
+                       ring->access->mark_param_change(ring);
        }
 
        return len;
@@ -337,14 +453,13 @@ ssize_t iio_read_ring_bytes_per_datum(struct device *dev,
                          struct device_attribute *attr,
                          char *buf)
 {
-       int len = 0;
        struct iio_ring_buffer *ring = dev_get_drvdata(dev);
 
-       if (ring->access.get_bytes_per_datum)
-               len = sprintf(buf, "%d\n",
-                             ring->access.get_bytes_per_datum(ring));
+       if (ring->access->get_bytes_per_datum)
+               return sprintf(buf, "%d\n",
+                              ring->access->get_bytes_per_datum(ring));
 
-       return len;
+       return 0;
 }
 EXPORT_SYMBOL(iio_read_ring_bytes_per_datum);
 
@@ -368,8 +483,8 @@ ssize_t iio_store_ring_enable(struct device *dev,
                goto done;
        }
        if (requested_state) {
-               if (ring->preenable) {
-                       ret = ring->preenable(dev_info);
+               if (ring->setup_ops->preenable) {
+                       ret = ring->setup_ops->preenable(dev_info);
                        if (ret) {
                                printk(KERN_ERR
                                       "Buffer not started:"
@@ -377,8 +492,8 @@ ssize_t iio_store_ring_enable(struct device *dev,
                                goto error_ret;
                        }
                }
-               if (ring->access.request_update) {
-                       ret = ring->access.request_update(ring);
+               if (ring->access->request_update) {
+                       ret = ring->access->request_update(ring);
                        if (ret) {
                                printk(KERN_INFO
                                       "Buffer not started:"
@@ -386,16 +501,16 @@ ssize_t iio_store_ring_enable(struct device *dev,
                                goto error_ret;
                        }
                }
-               if (ring->access.mark_in_use)
-                       ring->access.mark_in_use(ring);
+               if (ring->access->mark_in_use)
+                       ring->access->mark_in_use(ring);
                /* Definitely possible for devices to support both of these.*/
                if (dev_info->modes & INDIO_RING_TRIGGERED) {
                        if (!dev_info->trig) {
                                printk(KERN_INFO
                                       "Buffer not started: no trigger\n");
                                ret = -EINVAL;
-                               if (ring->access.unmark_in_use)
-                                       ring->access.unmark_in_use(ring);
+                               if (ring->access->unmark_in_use)
+                                       ring->access->unmark_in_use(ring);
                                goto error_ret;
                        }
                        dev_info->currentmode = INDIO_RING_TRIGGERED;
@@ -406,32 +521,31 @@ ssize_t iio_store_ring_enable(struct device *dev,
                        goto error_ret;
                }
 
-               if (ring->postenable) {
-
-                       ret = ring->postenable(dev_info);
+               if (ring->setup_ops->postenable) {
+                       ret = ring->setup_ops->postenable(dev_info);
                        if (ret) {
                                printk(KERN_INFO
                                       "Buffer not started:"
                                       "postenable failed\n");
-                               if (ring->access.unmark_in_use)
-                                       ring->access.unmark_in_use(ring);
+                               if (ring->access->unmark_in_use)
+                                       ring->access->unmark_in_use(ring);
                                dev_info->currentmode = previous_mode;
-                               if (ring->postdisable)
-                                       ring->postdisable(dev_info);
+                               if (ring->setup_ops->postdisable)
+                                       ring->setup_ops->postdisable(dev_info);
                                goto error_ret;
                        }
                }
        } else {
-               if (ring->predisable) {
-                       ret = ring->predisable(dev_info);
+               if (ring->setup_ops->predisable) {
+                       ret = ring->setup_ops->predisable(dev_info);
                        if (ret)
                                goto error_ret;
                }
-               if (ring->access.unmark_in_use)
-                       ring->access.unmark_in_use(ring);
+               if (ring->access->unmark_in_use)
+                       ring->access->unmark_in_use(ring);
                dev_info->currentmode = INDIO_DIRECT_MODE;
-               if (ring->postdisable) {
-                       ret = ring->postdisable(dev_info);
+               if (ring->setup_ops->postdisable) {
+                       ret = ring->setup_ops->postdisable(dev_info);
                        if (ret)
                                goto error_ret;
                }
@@ -445,6 +559,7 @@ error_ret:
        return ret;
 }
 EXPORT_SYMBOL(iio_store_ring_enable);
+
 ssize_t iio_show_ring_enable(struct device *dev,
                                    struct device_attribute *attr,
                                    char *buf)
@@ -455,89 +570,27 @@ ssize_t iio_show_ring_enable(struct device *dev,
 }
 EXPORT_SYMBOL(iio_show_ring_enable);
 
-ssize_t iio_scan_el_show(struct device *dev,
-                        struct device_attribute *attr,
-                        char *buf)
-{
-       int ret;
-       struct iio_ring_buffer *ring = dev_get_drvdata(dev);
-       struct iio_scan_el *this_el = to_iio_scan_el(attr);
-
-       ret = iio_scan_mask_query(ring, this_el->number);
-       if (ret < 0)
-               return ret;
-       return sprintf(buf, "%d\n", ret);
-}
-EXPORT_SYMBOL(iio_scan_el_show);
-
-ssize_t iio_scan_el_store(struct device *dev,
-                         struct device_attribute *attr,
-                         const char *buf,
-                         size_t len)
-{
-       int ret = 0;
-       bool state;
-       struct iio_ring_buffer *ring = dev_get_drvdata(dev);
-       struct iio_dev *indio_dev = ring->indio_dev;
-       struct iio_scan_el *this_el = to_iio_scan_el(attr);
-
-       state = !(buf[0] == '0');
-       mutex_lock(&indio_dev->mlock);
-       if (indio_dev->currentmode == INDIO_RING_TRIGGERED) {
-               ret = -EBUSY;
-               goto error_ret;
-       }
-       ret = iio_scan_mask_query(ring, this_el->number);
-       if (ret < 0)
-               goto error_ret;
-       if (!state && ret) {
-               ret = iio_scan_mask_clear(ring, this_el->number);
-               if (ret)
-                       goto error_ret;
-       } else if (state && !ret) {
-               ret = iio_scan_mask_set(ring, this_el->number);
-               if (ret)
-                       goto error_ret;
-       }
-       if (this_el->set_state)
-               ret = this_el->set_state(this_el, indio_dev, state);
-error_ret:
-       mutex_unlock(&indio_dev->mlock);
-
-       return ret ? ret : len;
-
-}
-EXPORT_SYMBOL(iio_scan_el_store);
-
-ssize_t iio_scan_el_ts_show(struct device *dev,
-                           struct device_attribute *attr,
-                           char *buf)
-{
-       struct iio_ring_buffer *ring = dev_get_drvdata(dev);
-       return sprintf(buf, "%d\n", ring->scan_timestamp);
-}
-EXPORT_SYMBOL(iio_scan_el_ts_show);
-
-ssize_t iio_scan_el_ts_store(struct device *dev,
-                            struct device_attribute *attr,
-                            const char *buf,
-                            size_t len)
+int iio_sw_ring_preenable(struct iio_dev *indio_dev)
 {
-       int ret = 0;
-       struct iio_ring_buffer *ring = dev_get_drvdata(dev);
-       struct iio_dev *indio_dev = ring->indio_dev;
-       bool state;
-       state = !(buf[0] == '0');
-       mutex_lock(&indio_dev->mlock);
-       if (indio_dev->currentmode == INDIO_RING_TRIGGERED) {
-               ret = -EBUSY;
-               goto error_ret;
-       }
-       ring->scan_timestamp = state;
-error_ret:
-       mutex_unlock(&indio_dev->mlock);
+       struct iio_ring_buffer *ring = indio_dev->ring;
+       size_t size;
+       dev_dbg(&indio_dev->dev, "%s\n", __func__);
+       /* Check if there are any scan elements enabled, if not fail*/
+       if (!(ring->scan_count || ring->scan_timestamp))
+               return -EINVAL;
+       if (ring->scan_timestamp)
+               if (ring->scan_count)
+                       /* Timestamp (aligned to s64) and data */
+                       size = (((ring->scan_count * ring->bpe)
+                                       + sizeof(s64) - 1)
+                               & ~(sizeof(s64) - 1))
+                               + sizeof(s64);
+               else /* Timestamp only  */
+                       size = sizeof(s64);
+       else /* Data only */
+               size = ring->scan_count * ring->bpe;
+       ring->access->set_bytes_per_datum(ring, size);
 
-       return ret ? ret : len;
+       return 0;
 }
-EXPORT_SYMBOL(iio_scan_el_ts_store);
-
+EXPORT_SYMBOL(iio_sw_ring_preenable);
index 57dd9232cf0d91884dad5af732ab9e21fdbe150b..615902333fb0d9cb34b555c25a535362bb781042 100644 (file)
@@ -38,6 +38,19 @@ static DEFINE_SPINLOCK(iio_trigger_idr_lock);
 static LIST_HEAD(iio_trigger_list);
 static DEFINE_MUTEX(iio_trigger_list_lock);
 
+/**
+ * iio_trigger_read_name() - retrieve useful identifying name
+ **/
+static ssize_t iio_trigger_read_name(struct device *dev,
+                                    struct device_attribute *attr,
+                                    char *buf)
+{
+       struct iio_trigger *trig = dev_get_drvdata(dev);
+       return sprintf(buf, "%s\n", trig->name);
+}
+
+static DEVICE_ATTR(name, S_IRUGO, iio_trigger_read_name, NULL);
+
 /**
  * iio_trigger_register_sysfs() - create a device for this trigger
  * @trig_info: the trigger
@@ -46,20 +59,16 @@ static DEFINE_MUTEX(iio_trigger_list_lock);
  **/
 static int iio_trigger_register_sysfs(struct iio_trigger *trig_info)
 {
-       int ret = 0;
-
-       if (trig_info->control_attrs)
-               ret = sysfs_create_group(&trig_info->dev.kobj,
-                                        trig_info->control_attrs);
-
-       return ret;
+       return sysfs_add_file_to_group(&trig_info->dev.kobj,
+                                      &dev_attr_name.attr,
+                                      NULL);
 }
 
 static void iio_trigger_unregister_sysfs(struct iio_trigger *trig_info)
 {
-       if (trig_info->control_attrs)
-               sysfs_remove_group(&trig_info->dev.kobj,
-                                  trig_info->control_attrs);
+       sysfs_remove_file_from_group(&trig_info->dev.kobj,
+                                          &dev_attr_name.attr,
+                                          NULL);
 }
 
 
@@ -134,14 +143,8 @@ EXPORT_SYMBOL(iio_trigger_register);
 
 void iio_trigger_unregister(struct iio_trigger *trig_info)
 {
-       struct iio_trigger *cursor;
-
        mutex_lock(&iio_trigger_list_lock);
-       list_for_each_entry(cursor, &iio_trigger_list, list)
-               if (cursor == trig_info) {
-                       list_del(&cursor->list);
-                       break;
-               }
+       list_del(&trig_info->list);
        mutex_unlock(&iio_trigger_list_lock);
 
        iio_trigger_unregister_sysfs(trig_info);
@@ -151,47 +154,55 @@ void iio_trigger_unregister(struct iio_trigger *trig_info)
 }
 EXPORT_SYMBOL(iio_trigger_unregister);
 
-struct iio_trigger *iio_trigger_find_by_name(const char *name, size_t len)
+static struct iio_trigger *iio_trigger_find_by_name(const char *name,
+                                                   size_t len)
 {
-       struct iio_trigger *trig;
-       bool found = false;
-
-       if (len && name[len - 1] == '\n')
-               len--;
+       struct iio_trigger *trig = NULL, *iter;
 
        mutex_lock(&iio_trigger_list_lock);
-       list_for_each_entry(trig, &iio_trigger_list, list) {
-               if (strncmp(trig->name, name, len) == 0) {
-                       found = true;
+       list_for_each_entry(iter, &iio_trigger_list, list)
+               if (sysfs_streq(iter->name, name)) {
+                       trig = iter;
                        break;
                }
-       }
        mutex_unlock(&iio_trigger_list_lock);
 
-       return found ? trig : NULL;
+       return trig;
 }
-EXPORT_SYMBOL(iio_trigger_find_by_name);
 
 void iio_trigger_poll(struct iio_trigger *trig, s64 time)
 {
-       struct iio_poll_func *pf_cursor;
-
-       list_for_each_entry(pf_cursor, &trig->pollfunc_list, list) {
-               if (pf_cursor->poll_func_immediate) {
-                       pf_cursor->poll_func_immediate(pf_cursor->private_data);
-                       trig->use_count++;
-               }
-       }
-       list_for_each_entry(pf_cursor, &trig->pollfunc_list, list) {
-               if (pf_cursor->poll_func_main) {
-                       pf_cursor->poll_func_main(pf_cursor->private_data,
-                                                 time);
-                       trig->use_count++;
-               }
+       int i;
+       if (!trig->use_count) {
+               for (i = 0; i < CONFIG_IIO_CONSUMERS_PER_TRIGGER; i++)
+                       if (trig->subirqs[i].enabled) {
+                               trig->use_count++;
+                               generic_handle_irq(trig->subirq_base + i);
+                       }
        }
 }
 EXPORT_SYMBOL(iio_trigger_poll);
 
+irqreturn_t iio_trigger_generic_data_rdy_poll(int irq, void *private)
+{
+       iio_trigger_poll(private, iio_get_time_ns());
+       return IRQ_HANDLED;
+}
+EXPORT_SYMBOL(iio_trigger_generic_data_rdy_poll);
+
+void iio_trigger_poll_chained(struct iio_trigger *trig, s64 time)
+{
+       int i;
+       if (!trig->use_count) {
+               for (i = 0; i < CONFIG_IIO_CONSUMERS_PER_TRIGGER; i++)
+                       if (trig->subirqs[i].enabled) {
+                               trig->use_count++;
+                               handle_nested_irq(trig->subirq_base + i);
+                       }
+       }
+}
+EXPORT_SYMBOL(iio_trigger_poll_chained);
+
 void iio_trigger_notify_done(struct iio_trigger *trig)
 {
        trig->use_count--;
@@ -203,18 +214,6 @@ void iio_trigger_notify_done(struct iio_trigger *trig)
 }
 EXPORT_SYMBOL(iio_trigger_notify_done);
 
-/**
- * iio_trigger_read_name() - retrieve useful identifying name
- **/
-ssize_t iio_trigger_read_name(struct device *dev,
-                             struct device_attribute *attr,
-                             char *buf)
-{
-       struct iio_trigger *trig = dev_get_drvdata(dev);
-       return sprintf(buf, "%s\n", trig->name);
-}
-EXPORT_SYMBOL(iio_trigger_read_name);
-
 /* Trigger Consumer related functions */
 
 /* Complexity in here.  With certain triggers (datardy) an acknowledgement
@@ -228,18 +227,16 @@ int iio_trigger_attach_poll_func(struct iio_trigger *trig,
                                 struct iio_poll_func *pf)
 {
        int ret = 0;
-       unsigned long flags;
-
-       spin_lock_irqsave(&trig->pollfunc_list_lock, flags);
-       list_add_tail(&pf->list, &trig->pollfunc_list);
-       spin_unlock_irqrestore(&trig->pollfunc_list_lock, flags);
-
-       if (trig->set_trigger_state)
+       bool notinuse
+               = bitmap_empty(trig->pool, CONFIG_IIO_CONSUMERS_PER_TRIGGER);
+
+       pf->irq = iio_trigger_get_irq(trig);
+       ret = request_threaded_irq(pf->irq, pf->h, pf->thread,
+                                  pf->type, pf->name,
+                                  pf);
+       if (trig->set_trigger_state && notinuse)
                ret = trig->set_trigger_state(trig, true);
-       if (ret) {
-               printk(KERN_ERR "set trigger state failed\n");
-               list_del(&pf->list);
-       }
+
        return ret;
 }
 EXPORT_SYMBOL(iio_trigger_attach_poll_func);
@@ -247,41 +244,68 @@ EXPORT_SYMBOL(iio_trigger_attach_poll_func);
 int iio_trigger_dettach_poll_func(struct iio_trigger *trig,
                                  struct iio_poll_func *pf)
 {
-       struct iio_poll_func *pf_cursor;
-       unsigned long flags;
-       int ret = -EINVAL;
-
-       spin_lock_irqsave(&trig->pollfunc_list_lock, flags);
-       list_for_each_entry(pf_cursor, &trig->pollfunc_list, list)
-               if (pf_cursor == pf) {
-                       ret = 0;
-                       break;
-               }
-       if (!ret) {
-               if (list_is_singular(&trig->pollfunc_list)
-                   && trig->set_trigger_state) {
-                       spin_unlock_irqrestore(&trig->pollfunc_list_lock,
-                                              flags);
-                       /* May sleep hence cannot hold the spin lock */
-                       ret = trig->set_trigger_state(trig, false);
-                       if (ret)
-                               goto error_ret;
-                       spin_lock_irqsave(&trig->pollfunc_list_lock, flags);
-               }
-               /*
-                * Now we can delete safe in the knowledge that, if this is
-                * the last pollfunc then we have disabled the trigger anyway
-                * and so nothing should be able to call the pollfunc.
-                */
-               list_del(&pf_cursor->list);
+       int ret = 0;
+       bool no_other_users
+               = (bitmap_weight(trig->pool,
+                                CONFIG_IIO_CONSUMERS_PER_TRIGGER)
+                  == 1);
+       if (trig->set_trigger_state && no_other_users) {
+               ret = trig->set_trigger_state(trig, false);
+               if (ret)
+                       goto error_ret;
        }
-       spin_unlock_irqrestore(&trig->pollfunc_list_lock, flags);
+       iio_trigger_put_irq(trig, pf->irq);
+       free_irq(pf->irq, pf);
 
 error_ret:
        return ret;
 }
 EXPORT_SYMBOL(iio_trigger_dettach_poll_func);
 
+irqreturn_t iio_pollfunc_store_time(int irq, void *p)
+{
+       struct iio_poll_func *pf = p;
+       pf->timestamp = iio_get_time_ns();
+       return IRQ_WAKE_THREAD;
+}
+EXPORT_SYMBOL(iio_pollfunc_store_time);
+
+struct iio_poll_func
+*iio_alloc_pollfunc(irqreturn_t (*h)(int irq, void *p),
+                   irqreturn_t (*thread)(int irq, void *p),
+                   int type,
+                   void *private,
+                   const char *fmt,
+                   ...)
+{
+       va_list vargs;
+       struct iio_poll_func *pf;
+
+       pf = kmalloc(sizeof *pf, GFP_KERNEL);
+       if (pf == NULL)
+               return NULL;
+       va_start(vargs, fmt);
+       pf->name = kvasprintf(GFP_KERNEL, fmt, vargs);
+       va_end(vargs);
+       if (pf->name == NULL) {
+               kfree(pf);
+               return NULL;
+       }
+       pf->h = h;
+       pf->thread = thread;
+       pf->type = type;
+
+       return pf;
+}
+EXPORT_SYMBOL_GPL(iio_alloc_pollfunc);
+
+void iio_dealloc_pollfunc(struct iio_poll_func *pf)
+{
+       kfree(pf->name);
+       kfree(pf);
+}
+EXPORT_SYMBOL_GPL(iio_dealloc_pollfunc);
+
 /**
  * iio_trigger_read_currrent() - trigger consumer sysfs query which trigger
  *
@@ -348,6 +372,23 @@ static const struct attribute_group iio_trigger_consumer_attr_group = {
 static void iio_trig_release(struct device *device)
 {
        struct iio_trigger *trig = to_iio_trigger(device);
+       int i;
+
+       if (trig->subirq_base) {
+               for (i = 0; i < CONFIG_IIO_CONSUMERS_PER_TRIGGER; i++) {
+                       irq_modify_status(trig->subirq_base + i,
+                                         IRQ_NOAUTOEN,
+                                         IRQ_NOREQUEST | IRQ_NOPROBE);
+                       irq_set_chip(trig->subirq_base + i,
+                                    NULL);
+                       irq_set_handler(trig->subirq_base + i,
+                                       NULL);
+               }
+
+               irq_free_descs(trig->subirq_base,
+                              CONFIG_IIO_CONSUMERS_PER_TRIGGER);
+       }
+       kfree(trig->name);
        kfree(trig);
        iio_put();
 }
@@ -356,18 +397,66 @@ static struct device_type iio_trig_type = {
        .release = iio_trig_release,
 };
 
-struct iio_trigger *iio_allocate_trigger(void)
+static void iio_trig_subirqmask(struct irq_data *d)
+{
+       struct irq_chip *chip = irq_data_get_irq_chip(d);
+       struct iio_trigger *trig
+               = container_of(chip,
+                              struct iio_trigger, subirq_chip);
+       trig->subirqs[d->irq - trig->subirq_base].enabled = false;
+}
+
+static void iio_trig_subirqunmask(struct irq_data *d)
+{
+       struct irq_chip *chip = irq_data_get_irq_chip(d);
+       struct iio_trigger *trig
+               = container_of(chip,
+                              struct iio_trigger, subirq_chip);
+       trig->subirqs[d->irq - trig->subirq_base].enabled = true;
+}
+
+struct iio_trigger *iio_allocate_trigger(const char *fmt, ...)
 {
+       va_list vargs;
        struct iio_trigger *trig;
        trig = kzalloc(sizeof *trig, GFP_KERNEL);
        if (trig) {
+               int i;
                trig->dev.type = &iio_trig_type;
                trig->dev.bus = &iio_bus_type;
                device_initialize(&trig->dev);
                dev_set_drvdata(&trig->dev, (void *)trig);
-               spin_lock_init(&trig->pollfunc_list_lock);
-               INIT_LIST_HEAD(&trig->list);
-               INIT_LIST_HEAD(&trig->pollfunc_list);
+
+               mutex_init(&trig->pool_lock);
+               trig->subirq_base
+                       = irq_alloc_descs(-1, 0,
+                                         CONFIG_IIO_CONSUMERS_PER_TRIGGER,
+                                         0);
+               if (trig->subirq_base < 0) {
+                       kfree(trig);
+                       return NULL;
+               }
+               va_start(vargs, fmt);
+               trig->name = kvasprintf(GFP_KERNEL, fmt, vargs);
+               va_end(vargs);
+               if (trig->name == NULL) {
+                       irq_free_descs(trig->subirq_base,
+                                      CONFIG_IIO_CONSUMERS_PER_TRIGGER);
+                       kfree(trig);
+                       return NULL;
+               }
+               trig->subirq_chip.name = trig->name;
+               trig->subirq_chip.irq_mask = &iio_trig_subirqmask;
+               trig->subirq_chip.irq_unmask = &iio_trig_subirqunmask;
+               for (i = 0; i < CONFIG_IIO_CONSUMERS_PER_TRIGGER; i++) {
+                       irq_set_chip(trig->subirq_base + i,
+                                    &trig->subirq_chip);
+                       irq_set_handler(trig->subirq_base + i,
+                                       &handle_simple_irq);
+                       irq_modify_status(trig->subirq_base + i,
+                                         IRQ_NOREQUEST | IRQ_NOAUTOEN,
+                                         IRQ_NOPROBE);
+               }
                iio_get();
        }
        return trig;
@@ -398,20 +487,6 @@ int iio_device_unregister_trigger_consumer(struct iio_dev *dev_info)
 }
 EXPORT_SYMBOL(iio_device_unregister_trigger_consumer);
 
-int iio_alloc_pollfunc(struct iio_dev *indio_dev,
-                      void (*immediate)(struct iio_dev *indio_dev),
-                      void (*main)(struct iio_dev *private_data, s64 time))
-{
-       indio_dev->pollfunc = kzalloc(sizeof(*indio_dev->pollfunc), GFP_KERNEL);
-       if (indio_dev->pollfunc == NULL)
-               return -ENOMEM;
-       indio_dev->pollfunc->poll_func_immediate = immediate;
-       indio_dev->pollfunc->poll_func_main = main;
-       indio_dev->pollfunc->private_data = indio_dev;
-       return 0;
-}
-EXPORT_SYMBOL(iio_alloc_pollfunc);
-
 int iio_triggered_ring_postenable(struct iio_dev *indio_dev)
 {
        return indio_dev->trig
index a56c0cbba94bfdf2f4abcf834e8bcb1b37d47690..cc14b96d814c24afb29cc7b7ef8690815aa73edf 100644 (file)
@@ -8,6 +8,8 @@
 
 #include "kfifo_buf.h"
 
+#define iio_to_kfifo(r) container_of(r, struct iio_kfifo, ring)
+
 static inline int __iio_allocate_kfifo(struct iio_kfifo *buf,
                                int bytes_per_datum, int length)
 {
@@ -18,7 +20,7 @@ static inline int __iio_allocate_kfifo(struct iio_kfifo *buf,
        return kfifo_alloc(&buf->kf, bytes_per_datum*length, GFP_KERNEL);
 }
 
-int iio_request_update_kfifo(struct iio_ring_buffer *r)
+static int iio_request_update_kfifo(struct iio_ring_buffer *r)
 {
        int ret = 0;
        struct iio_kfifo *buf = iio_to_kfifo(r);
@@ -37,31 +39,27 @@ error_ret:
        mutex_unlock(&buf->use_lock);
        return ret;
 }
-EXPORT_SYMBOL(iio_request_update_kfifo);
 
-void iio_mark_kfifo_in_use(struct iio_ring_buffer *r)
+static void iio_mark_kfifo_in_use(struct iio_ring_buffer *r)
 {
        struct iio_kfifo *buf = iio_to_kfifo(r);
        mutex_lock(&buf->use_lock);
        buf->use_count++;
        mutex_unlock(&buf->use_lock);
 }
-EXPORT_SYMBOL(iio_mark_kfifo_in_use);
 
-void iio_unmark_kfifo_in_use(struct iio_ring_buffer *r)
+static void iio_unmark_kfifo_in_use(struct iio_ring_buffer *r)
 {
        struct iio_kfifo *buf = iio_to_kfifo(r);
        mutex_lock(&buf->use_lock);
        buf->use_count--;
        mutex_unlock(&buf->use_lock);
 }
-EXPORT_SYMBOL(iio_unmark_kfifo_in_use);
 
-int iio_get_length_kfifo(struct iio_ring_buffer *r)
+static int iio_get_length_kfifo(struct iio_ring_buffer *r)
 {
        return r->length;
 }
-EXPORT_SYMBOL(iio_get_length_kfifo);
 
 static inline void __iio_init_kfifo(struct iio_kfifo *kf)
 {
@@ -108,6 +106,7 @@ struct iio_ring_buffer *iio_kfifo_allocate(struct iio_dev *indio_dev)
        kf = kzalloc(sizeof *kf, GFP_KERNEL);
        if (!kf)
                return NULL;
+       kf->update_needed = true;
        iio_ring_buffer_init(&kf->ring, indio_dev);
        __iio_init_kfifo(kf);
        kf->ring.dev.type = &iio_kfifo_type;
@@ -120,41 +119,37 @@ struct iio_ring_buffer *iio_kfifo_allocate(struct iio_dev *indio_dev)
 }
 EXPORT_SYMBOL(iio_kfifo_allocate);
 
-int iio_get_bytes_per_datum_kfifo(struct iio_ring_buffer *r)
+static int iio_get_bytes_per_datum_kfifo(struct iio_ring_buffer *r)
 {
        return r->bytes_per_datum;
 }
-EXPORT_SYMBOL(iio_get_bytes_per_datum_kfifo);
 
-int iio_set_bytes_per_datum_kfifo(struct iio_ring_buffer *r, size_t bpd)
+static int iio_set_bytes_per_datum_kfifo(struct iio_ring_buffer *r, size_t bpd)
 {
        if (r->bytes_per_datum != bpd) {
                r->bytes_per_datum = bpd;
-               if (r->access.mark_param_change)
-                       r->access.mark_param_change(r);
+               if (r->access->mark_param_change)
+                       r->access->mark_param_change(r);
        }
        return 0;
 }
-EXPORT_SYMBOL(iio_set_bytes_per_datum_kfifo);
 
-int iio_mark_update_needed_kfifo(struct iio_ring_buffer *r)
+static int iio_mark_update_needed_kfifo(struct iio_ring_buffer *r)
 {
        struct iio_kfifo *kf = iio_to_kfifo(r);
        kf->update_needed = true;
        return 0;
 }
-EXPORT_SYMBOL(iio_mark_update_needed_kfifo);
 
-int iio_set_length_kfifo(struct iio_ring_buffer *r, int length)
+static int iio_set_length_kfifo(struct iio_ring_buffer *r, int length)
 {
        if (r->length != length) {
                r->length = length;
-               if (r->access.mark_param_change)
-                       r->access.mark_param_change(r);
+               if (r->access->mark_param_change)
+                       r->access->mark_param_change(r);
        }
        return 0;
 }
-EXPORT_SYMBOL(iio_set_length_kfifo);
 
 void iio_kfifo_free(struct iio_ring_buffer *r)
 {
@@ -163,7 +158,9 @@ void iio_kfifo_free(struct iio_ring_buffer *r)
 }
 EXPORT_SYMBOL(iio_kfifo_free);
 
-int iio_store_to_kfifo(struct iio_ring_buffer *r, u8 *data, s64 timestamp)
+static int iio_store_to_kfifo(struct iio_ring_buffer *r,
+                             u8 *data,
+                             s64 timestamp)
 {
        int ret;
        struct iio_kfifo *kf = iio_to_kfifo(r);
@@ -179,18 +176,30 @@ int iio_store_to_kfifo(struct iio_ring_buffer *r, u8 *data, s64 timestamp)
        kfree(datal);
        return 0;
 }
-EXPORT_SYMBOL(iio_store_to_kfifo);
 
-int iio_rip_kfifo(struct iio_ring_buffer *r,
-               size_t count, char __user *buf, int *deadoffset)
+static int iio_read_first_n_kfifo(struct iio_ring_buffer *r,
+                          size_t n, char __user *buf)
 {
        int ret, copied;
        struct iio_kfifo *kf = iio_to_kfifo(r);
 
-       *deadoffset = 0;
-       ret = kfifo_to_user(&kf->kf, buf, r->bytes_per_datum*count, &copied);
+       ret = kfifo_to_user(&kf->kf, buf, r->bytes_per_datum*n, &copied);
 
        return copied;
 }
-EXPORT_SYMBOL(iio_rip_kfifo);
+
+const struct iio_ring_access_funcs kfifo_access_funcs = {
+       .mark_in_use = &iio_mark_kfifo_in_use,
+       .unmark_in_use = &iio_unmark_kfifo_in_use,
+       .store_to = &iio_store_to_kfifo,
+       .read_first_n = &iio_read_first_n_kfifo,
+       .mark_param_change = &iio_mark_update_needed_kfifo,
+       .request_update = &iio_request_update_kfifo,
+       .get_bytes_per_datum = &iio_get_bytes_per_datum_kfifo,
+       .set_bytes_per_datum = &iio_set_bytes_per_datum_kfifo,
+       .get_length = &iio_get_length_kfifo,
+       .set_length = &iio_set_length_kfifo,
+};
+EXPORT_SYMBOL(kfifo_access_funcs);
+
 MODULE_LICENSE("GPL");
index 8064383bf7c356677bbed80f09d44541c64976f3..aac30539b2c67e4a5d408e05d5a83038429ed355 100644 (file)
@@ -11,45 +11,7 @@ struct iio_kfifo {
        struct mutex use_lock;
 };
 
-#define iio_to_kfifo(r) container_of(r, struct iio_kfifo, ring)
-
-int iio_create_kfifo(struct iio_ring_buffer **r);
-int iio_init_kfifo(struct iio_ring_buffer *r, struct iio_dev *indio_dev);
-void iio_exit_kfifo(struct iio_ring_buffer *r);
-void iio_free_kfifo(struct iio_ring_buffer *r);
-void iio_mark_kfifo_in_use(struct iio_ring_buffer *r);
-void iio_unmark_kfifo_in_use(struct iio_ring_buffer *r);
-
-int iio_store_to_kfifo(struct iio_ring_buffer *r, u8 *data, s64 timestamp);
-int iio_rip_kfifo(struct iio_ring_buffer *r,
-               size_t count,
-               char __user *buf,
-               int *dead_offset);
-
-int iio_request_update_kfifo(struct iio_ring_buffer *r);
-int iio_mark_update_needed_kfifo(struct iio_ring_buffer *r);
-
-int iio_get_bytes_per_datum_kfifo(struct iio_ring_buffer *r);
-int iio_set_bytes_per_datum_kfifo(struct iio_ring_buffer *r, size_t bpd);
-int iio_get_length_kfifo(struct iio_ring_buffer *r);
-int iio_set_length_kfifo(struct iio_ring_buffer *r, int length);
-
-static inline void iio_kfifo_register_funcs(struct iio_ring_access_funcs *ra)
-{
-       ra->mark_in_use = &iio_mark_kfifo_in_use;
-       ra->unmark_in_use = &iio_unmark_kfifo_in_use;
-
-       ra->store_to = &iio_store_to_kfifo;
-       ra->rip_lots = &iio_rip_kfifo;
-
-       ra->mark_param_change = &iio_mark_update_needed_kfifo;
-       ra->request_update = &iio_request_update_kfifo;
-
-       ra->get_bytes_per_datum = &iio_get_bytes_per_datum_kfifo;
-       ra->set_bytes_per_datum = &iio_set_bytes_per_datum_kfifo;
-       ra->get_length = &iio_get_length_kfifo;
-       ra->set_length = &iio_set_length_kfifo;
-};
+extern const struct iio_ring_access_funcs kfifo_access_funcs;
 
 struct iio_ring_buffer *iio_kfifo_allocate(struct iio_dev *indio_dev);
 void iio_kfifo_free(struct iio_ring_buffer *r);
index 36d8bbe1a9cc83fec924bcd769e10d0b1c67a52e..46d62d1b0370309b58111d0c13fd452b9cdad446 100644 (file)
@@ -1,18 +1,8 @@
-#
+\#
 # Light sensors
 #
 comment "Light sensors"
 
-config SENSORS_TSL2563
-       tristate "TAOS TSL256[0-3] ambient light sensor"
-       depends on I2C
-       help
-        If you say yes here you get support for the Taos TSL2560,
-        TSL2561, TSL2562 and TSL2563 ambient light sensors.
-
-        This driver can also be built as a module.  If so, the module
-        will be called tsl2563.
-
 config SENSORS_ISL29018
         tristate "ISL 29018 light and proximity sensor"
         depends on I2C
@@ -24,3 +14,19 @@ config SENSORS_ISL29018
          in lux, proximity infrared sensing and normal infrared sensing.
          Data from sensor is accessible via sysfs.
 
+config SENSORS_TSL2563
+       tristate "TAOS TSL2560, TSL2561, TSL2562 and TSL2563 ambient light sensors"
+       depends on I2C
+       help
+        If you say yes here you get support for the Taos TSL2560,
+        TSL2561, TSL2562 and TSL2563 ambient light sensors.
+
+        This driver can also be built as a module.  If so, the module
+        will be called tsl2563.
+
+config TSL2583
+       tristate "TAOS TSL2580, TSL2581 and TSL2583 light-to-digital converters"
+       depends on I2C
+       help
+        Provides support for the TAOS tsl2580, tsl2581 and tsl2583 devices.
+        Access ALS data via iio, sysfs.
index 9142c0e5a1b61db876a7a196b6db0609c712a2f1..3011fbfa8dc2543d6150df754759b1c4a9555ea7 100644 (file)
@@ -4,3 +4,4 @@
 
 obj-$(CONFIG_SENSORS_TSL2563)  += tsl2563.o
 obj-$(CONFIG_SENSORS_ISL29018) += isl29018.o
+obj-$(CONFIG_TSL2583)  += tsl2583.o
index f919cc1d35e1da29507892b01ea0b03293eea8c7..4794ffd5e44633c2a3bd721874284eb951be46d5 100644 (file)
@@ -402,16 +402,6 @@ static ssize_t show_proxim_ir(struct device *dev,
        return get_sensor_data(dev, buf, COMMMAND1_OPMODE_PROX_ONCE);
 }
 
-/* Read name */
-static ssize_t show_name(struct device *dev,
-               struct device_attribute *attr, char *buf)
-{
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
-       struct isl29018_chip *chip = indio_dev->dev_data;
-
-       return sprintf(buf, "%s\n", chip->client->name);
-}
-
 static IIO_DEVICE_ATTR(range, S_IRUGO | S_IWUSR, show_range, store_range, 0);
 static IIO_CONST_ATTR(range_available, "1000 4000 16000 64000");
 static IIO_CONST_ATTR(adc_resolution_available, "4 8 12 16");
@@ -424,12 +414,10 @@ static IIO_DEVICE_ATTR(proximity_on_chip_ambient_infrared_supression,
 static IIO_DEVICE_ATTR(illuminance0_input, S_IRUGO, show_lux, NULL, 0);
 static IIO_DEVICE_ATTR(intensity_infrared_raw, S_IRUGO, show_ir, NULL, 0);
 static IIO_DEVICE_ATTR(proximity_raw, S_IRUGO, show_proxim_ir, NULL, 0);
-static IIO_DEVICE_ATTR(name, S_IRUGO, show_name, NULL, 0);
 
 #define ISL29018_DEV_ATTR(name) (&iio_dev_attr_##name.dev_attr.attr)
 #define ISL29018_CONST_ATTR(name) (&iio_const_attr_##name.dev_attr.attr)
 static struct attribute *isl29018_attributes[] = {
-       ISL29018_DEV_ATTR(name),
        ISL29018_DEV_ATTR(range),
        ISL29018_CONST_ATTR(range_available),
        ISL29018_DEV_ATTR(adc_resolution),
@@ -467,6 +455,11 @@ static int isl29018_chip_init(struct i2c_client *client)
        return 0;
 }
 
+static const struct iio_info isl29108_info = {
+       .attrs = &isl29108_group,
+       .driver_module = THIS_MODULE,
+};
+
 static int __devinit isl29018_probe(struct i2c_client *client,
                         const struct i2c_device_id *id)
 {
@@ -492,15 +485,15 @@ static int __devinit isl29018_probe(struct i2c_client *client,
        if (err)
                goto exit_free;
 
-       chip->indio_dev = iio_allocate_device();
+       chip->indio_dev = iio_allocate_device(0);
        if (!chip->indio_dev) {
                dev_err(&client->dev, "iio allocation fails\n");
                goto exit_free;
        }
-       chip->indio_dev->attrs = &isl29108_group;
+       chip->indio_dev->info = &isl29108_info;
+       chip->indio_dev->name = id->name;
        chip->indio_dev->dev.parent = &client->dev;
        chip->indio_dev->dev_data = (void *)(chip);
-       chip->indio_dev->driver_module = THIS_MODULE;
        chip->indio_dev->modes = INDIO_DIRECT_MODE;
        err = iio_device_register(chip->indio_dev);
        if (err) {
index dadae7527d5c9472437dd5457c3d51b4d7bc4e5b..9cffa2ecb0ee52f2e9838493f1cc2240fed93ced 100644 (file)
@@ -92,7 +92,7 @@ struct tsl2563_gainlevel_coeff {
        u16 max;
 };
 
-static struct tsl2563_gainlevel_coeff tsl2563_gainlevel_table[] = {
+static const struct tsl2563_gainlevel_coeff tsl2563_gainlevel_table[] = {
        {
                .gaintime       = TSL2563_TIMING_400MS | TSL2563_TIMING_GAIN16,
                .min            = 0,
@@ -115,15 +115,12 @@ static struct tsl2563_gainlevel_coeff tsl2563_gainlevel_table[] = {
 struct tsl2563_chip {
        struct mutex            lock;
        struct i2c_client       *client;
-       struct iio_dev          *indio_dev;
        struct delayed_work     poweroff_work;
 
-       struct work_struct      work_thresh;
-       s64                     event_timestamp;
        /* Remember state for suspend and resume functions */
        pm_message_t            state;
 
-       struct tsl2563_gainlevel_coeff *gainlevel;
+       struct tsl2563_gainlevel_coeff const *gainlevel;
 
        u16                     low_thres;
        u16                     high_thres;
@@ -467,32 +464,6 @@ static unsigned int adc_to_lux(u32 adc0, u32 adc1)
 /*                      Sysfs interface                         */
 /*--------------------------------------------------------------*/
 
-static ssize_t tsl2563_adc_show(struct device *dev,
-                               struct device_attribute *attr, char *buf)
-{
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
-       struct tsl2563_chip *chip = indio_dev->dev_data;
-       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-       int ret;
-
-       mutex_lock(&chip->lock);
-
-       ret = tsl2563_get_adc(chip);
-       if (ret)
-               goto out;
-
-       switch (this_attr->address) {
-       case 0:
-               ret = snprintf(buf, PAGE_SIZE, "%d\n", chip->data0);
-               break;
-       case 1:
-               ret = snprintf(buf, PAGE_SIZE, "%d\n", chip->data1);
-               break;
-       }
-out:
-       mutex_unlock(&chip->lock);
-       return ret;
-}
 
 /* Apply calibration coefficient to ADC count. */
 static u32 calib_adc(u32 adc, u32 calib)
@@ -505,237 +476,165 @@ static u32 calib_adc(u32 adc, u32 calib)
        return (u32) scaled;
 }
 
-static ssize_t tsl2563_lux_show(struct device *dev,
-                               struct device_attribute *attr, char *buf)
+static int tsl2563_write_raw(struct iio_dev *indio_dev,
+                              struct iio_chan_spec const *chan,
+                              int val,
+                              int val2,
+                              long mask)
 {
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
-       struct tsl2563_chip *chip = indio_dev->dev_data;
-       u32 calib0, calib1;
-       int ret;
-
-       mutex_lock(&chip->lock);
+       struct tsl2563_chip *chip = iio_priv(indio_dev);
 
-       ret = tsl2563_get_adc(chip);
-       if (ret)
-               goto out;
-
-       calib0 = calib_adc(chip->data0, chip->calib0) * chip->cover_comp_gain;
-       calib1 = calib_adc(chip->data1, chip->calib1) * chip->cover_comp_gain;
-
-       ret = snprintf(buf, PAGE_SIZE, "%d\n", adc_to_lux(calib0, calib1));
-
-out:
-       mutex_unlock(&chip->lock);
-       return ret;
-}
+       if (chan->channel == 0)
+               chip->calib0 = calib_from_sysfs(val);
+       else
+               chip->calib1 = calib_from_sysfs(val);
 
-static ssize_t format_calib(char *buf, int len, u32 calib)
-{
-       return snprintf(buf, PAGE_SIZE, "%d\n", calib_to_sysfs(calib));
+       return 0;
 }
 
-static ssize_t tsl2563_calib_show(struct device *dev,
-                               struct device_attribute *attr, char *buf)
+static int tsl2563_read_raw(struct iio_dev *indio_dev,
+                           struct iio_chan_spec const *chan,
+                           int *val,
+                           int *val2,
+                           long m)
 {
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
-       struct tsl2563_chip *chip = indio_dev->dev_data;
-       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-       int ret;
+       int ret = -EINVAL;
+       u32 calib0, calib1;
+       struct tsl2563_chip *chip = iio_priv(indio_dev);
 
        mutex_lock(&chip->lock);
-       switch (this_attr->address) {
+       switch (m) {
        case 0:
-               ret = format_calib(buf, PAGE_SIZE, chip->calib0);
+               switch (chan->type) {
+               case IIO_LIGHT:
+                       ret = tsl2563_get_adc(chip);
+                       if (ret)
+                               goto error_ret;
+                       calib0 = calib_adc(chip->data0, chip->calib0) *
+                               chip->cover_comp_gain;
+                       calib1 = calib_adc(chip->data1, chip->calib1) *
+                               chip->cover_comp_gain;
+                       *val = adc_to_lux(calib0, calib1);
+                       ret = IIO_VAL_INT;
+                       break;
+               case IIO_INTENSITY:
+                       ret = tsl2563_get_adc(chip);
+                       if (ret)
+                               goto error_ret;
+                       if (chan->channel == 0)
+                               *val = chip->data0;
+                       else
+                               *val = chip->data1;
+                       ret = IIO_VAL_INT;
+                       break;
+               default:
+                       break;
+               }
                break;
-       case 1:
-               ret = format_calib(buf, PAGE_SIZE, chip->calib1);
+
+       case (1 << IIO_CHAN_INFO_CALIBSCALE_SEPARATE):
+               if (chan->channel == 0)
+                       *val = calib_to_sysfs(chip->calib0);
+               else
+                       *val = calib_to_sysfs(chip->calib1);
+               ret = IIO_VAL_INT;
                break;
        default:
-               ret = -ENODEV;
-       }
-       mutex_unlock(&chip->lock);
-       return ret;
-}
-
-static ssize_t tsl2563_calib_store(struct device *dev,
-                               struct device_attribute *attr,
-                               const char *buf, size_t len)
-{
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
-       struct tsl2563_chip *chip = indio_dev->dev_data;
-       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-       int value;
-       u32 calib;
-
-       if (1 != sscanf(buf, "%d", &value))
                return -EINVAL;
-
-       calib = calib_from_sysfs(value);
-
-       switch (this_attr->address) {
-       case 0:
-               chip->calib0 = calib;
-               break;
-       case 1:
-               chip->calib1 = calib;
-               break;
        }
 
-       return len;
-}
-
-static IIO_DEVICE_ATTR(intensity0_both_raw, S_IRUGO,
-               tsl2563_adc_show, NULL, 0);
-static IIO_DEVICE_ATTR(intensity1_ir_raw, S_IRUGO,
-               tsl2563_adc_show, NULL, 1);
-static DEVICE_ATTR(illuminance0_input, S_IRUGO, tsl2563_lux_show, NULL);
-static IIO_DEVICE_ATTR(intensity0_both_calibgain, S_IRUGO | S_IWUSR,
-               tsl2563_calib_show, tsl2563_calib_store, 0);
-static IIO_DEVICE_ATTR(intensity1_ir_calibgain, S_IRUGO | S_IWUSR,
-               tsl2563_calib_show, tsl2563_calib_store, 1);
-
-static ssize_t tsl2563_show_name(struct device *dev,
-                               struct device_attribute *attr,
-                               char *buf)
-{
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
-       struct tsl2563_chip *chip = indio_dev->dev_data;
-       return sprintf(buf, "%s\n", chip->client->name);
+error_ret:
+       mutex_unlock(&chip->lock);
+       return ret;
 }
 
-static DEVICE_ATTR(name, S_IRUGO, tsl2563_show_name, NULL);
-
-static struct attribute *tsl2563_attributes[] = {
-       &iio_dev_attr_intensity0_both_raw.dev_attr.attr,
-       &iio_dev_attr_intensity1_ir_raw.dev_attr.attr,
-       &dev_attr_illuminance0_input.attr,
-       &iio_dev_attr_intensity0_both_calibgain.dev_attr.attr,
-       &iio_dev_attr_intensity1_ir_calibgain.dev_attr.attr,
-       &dev_attr_name.attr,
-       NULL
+static const struct iio_chan_spec tsl2563_channels[] = {
+       IIO_CHAN(IIO_LIGHT, 0, 1, 1, NULL, 0, 0, 0, 0, 0, {}, 0),
+       IIO_CHAN(IIO_INTENSITY, 1, 1, 0, "both", 0,
+                (1 << IIO_CHAN_INFO_CALIBSCALE_SEPARATE), 0, 0, 0, {},
+                IIO_EV_BIT(IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING) |
+                IIO_EV_BIT(IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING)),
+       IIO_CHAN(IIO_INTENSITY, 1, 1, 0, "ir", 1,
+                (1 << IIO_CHAN_INFO_CALIBSCALE_SEPARATE), 0, 0, 0, {},
+                0)
 };
 
-static const struct attribute_group tsl2563_group = {
-       .attrs = tsl2563_attributes,
-};
-
-static ssize_t tsl2563_read_thresh(struct device *dev,
-                       struct device_attribute *attr,
-                       char *buf)
+static int tsl2563_read_thresh(struct iio_dev *indio_dev,
+                               int event_code,
+                               int *val)
 {
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
-       struct tsl2563_chip *chip = indio_dev->dev_data;
-       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-       u16 val = 0;
-       switch (this_attr->address) {
-       case TSL2563_REG_HIGHLOW:
-               val = chip->high_thres;
+       struct tsl2563_chip *chip = iio_priv(indio_dev);
+
+       switch (IIO_EVENT_CODE_EXTRACT_DIR(event_code)) {
+       case IIO_EV_DIR_RISING:
+               *val = chip->high_thres;
                break;
-       case TSL2563_REG_LOWLOW:
-               val = chip->low_thres;
+       case IIO_EV_DIR_FALLING:
+               *val = chip->low_thres;
                break;
+       default:
+               return -EINVAL;
        }
-       return snprintf(buf, PAGE_SIZE, "%d\n", val);
+
+       return 0;
 }
 
-static ssize_t tsl2563_write_thresh(struct device *dev,
-                               struct device_attribute *attr,
-                               const char *buf,
-                               size_t len)
+static ssize_t tsl2563_write_thresh(struct iio_dev *indio_dev,
+                                 int event_code,
+                                 int val)
 {
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
-       struct tsl2563_chip *chip = indio_dev->dev_data;
-       struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-       unsigned long val;
+       struct tsl2563_chip *chip = iio_priv(indio_dev);
        int ret;
+       u8 address;
 
-       ret = strict_strtoul(buf, 10, &val);
-       if (ret)
-               return ret;
+       if (IIO_EVENT_CODE_EXTRACT_DIR(event_code) == IIO_EV_DIR_RISING)
+               address = TSL2563_REG_HIGHLOW;
+       else
+               address = TSL2563_REG_LOWLOW;
        mutex_lock(&chip->lock);
-       ret = tsl2563_write(chip->client, this_attr->address, val & 0xFF);
+       ret = tsl2563_write(chip->client, address, val & 0xFF);
        if (ret)
                goto error_ret;
-       ret = tsl2563_write(chip->client, this_attr->address + 1,
+       ret = tsl2563_write(chip->client, address + 1,
                        (val >> 8) & 0xFF);
-       switch (this_attr->address) {
-       case TSL2563_REG_HIGHLOW:
+       if (IIO_EVENT_CODE_EXTRACT_DIR(event_code) == IIO_EV_DIR_RISING)
                chip->high_thres = val;
-               break;
-       case TSL2563_REG_LOWLOW:
+       else
                chip->low_thres = val;
-               break;
-       }
 
 error_ret:
        mutex_unlock(&chip->lock);
 
-       return ret < 0 ? ret : len;
-}
-
-static IIO_DEVICE_ATTR(intensity0_both_raw_thresh_rising_value,
-               S_IRUGO | S_IWUSR,
-               tsl2563_read_thresh,
-               tsl2563_write_thresh,
-               TSL2563_REG_HIGHLOW);
-
-static IIO_DEVICE_ATTR(intensity0_both_raw_thresh_falling_value,
-               S_IRUGO | S_IWUSR,
-               tsl2563_read_thresh,
-               tsl2563_write_thresh,
-               TSL2563_REG_LOWLOW);
-
-static int tsl2563_int_th(struct iio_dev *dev_info,
-                       int index,
-                       s64 timestamp,
-                       int not_test)
-{
-       struct tsl2563_chip *chip = dev_info->dev_data;
-
-       chip->event_timestamp = timestamp;
-       schedule_work(&chip->work_thresh);
-
-       return 0;
+       return ret;
 }
 
-static void tsl2563_int_bh(struct work_struct *work_s)
+static irqreturn_t tsl2563_event_handler(int irq, void *private)
 {
-       struct tsl2563_chip *chip
-               = container_of(work_s,
-                       struct tsl2563_chip, work_thresh);
+       struct iio_dev *dev_info = private;
+       struct tsl2563_chip *chip = iio_priv(dev_info);
        u8 cmd = TSL2563_CMD | TSL2563_CLEARINT;
 
-       iio_push_event(chip->indio_dev, 0,
+       iio_push_event(dev_info, 0,
                       IIO_UNMOD_EVENT_CODE(IIO_EV_CLASS_LIGHT,
                                            0,
                                            IIO_EV_TYPE_THRESH,
                                            IIO_EV_DIR_EITHER),
-                      chip->event_timestamp);
+                      iio_get_time_ns());
 
-       /* reenable_irq */
-       enable_irq(chip->client->irq);
        /* clear the interrupt and push the event */
        i2c_master_send(chip->client, &cmd, sizeof(cmd));
-
+       return IRQ_HANDLED;
 }
 
-static ssize_t tsl2563_write_interrupt_config(struct device *dev,
-                                       struct device_attribute *attr,
-                                       const char *buf,
-                                       size_t len)
+static int tsl2563_write_interrupt_config(struct iio_dev *indio_dev,
+                                       int event_code,
+                                       int state)
 {
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
-       struct tsl2563_chip *chip = indio_dev->dev_data;
-       struct iio_event_attr *this_attr = to_iio_event_attr(attr);
-       int input, ret = 0;
+       struct tsl2563_chip *chip = iio_priv(indio_dev);
+       int ret = 0;
 
-       ret = sscanf(buf, "%d", &input);
-       if (ret != 1)
-               return -EINVAL;
        mutex_lock(&chip->lock);
-       if (input && !(chip->intr & 0x30)) {
-               iio_add_event_to_list(this_attr->listel,
-                               &indio_dev->interrupts[0]->ev_list);
+       if (state && !(chip->intr & 0x30)) {
                chip->intr &= ~0x30;
                chip->intr |= 0x10;
                /* ensure the chip is actually on */
@@ -752,11 +651,9 @@ static ssize_t tsl2563_write_interrupt_config(struct device *dev,
                chip->int_enabled = true;
        }
 
-       if (!input && (chip->intr & 0x30)) {
+       if (!state && (chip->intr & 0x30)) {
                chip->intr |= ~0x30;
                ret = tsl2563_write(chip->client, TSL2563_REG_INT, chip->intr);
-               iio_remove_event_from_list(this_attr->listel,
-                                       &indio_dev->interrupts[0]->ev_list);
                chip->int_enabled = false;
                /* now the interrupt is not enabled, we can go to sleep */
                schedule_delayed_work(&chip->poweroff_work, 5 * HZ);
@@ -764,69 +661,64 @@ static ssize_t tsl2563_write_interrupt_config(struct device *dev,
 out:
        mutex_unlock(&chip->lock);
 
-       return (ret < 0) ? ret : len;
+       return ret;
 }
 
-static ssize_t tsl2563_read_interrupt_config(struct device *dev,
-                                       struct device_attribute *attr,
-                                       char *buf)
+static int tsl2563_read_interrupt_config(struct iio_dev *indio_dev,
+                                          int event_code)
 {
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
-       struct tsl2563_chip *chip = indio_dev->dev_data;
-       int ret;
+       struct tsl2563_chip *chip = iio_priv(indio_dev);
        u8 rxbuf;
-       ssize_t len;
+       int ret;
 
        mutex_lock(&chip->lock);
-       ret = tsl2563_read(chip->client,
-                       TSL2563_REG_INT,
-                       &rxbuf,
-                       sizeof(rxbuf));
+       ret = tsl2563_read(chip->client, TSL2563_REG_INT,
+                          &rxbuf, sizeof(rxbuf));
        mutex_unlock(&chip->lock);
        if (ret < 0)
                goto error_ret;
-       len = snprintf(buf, PAGE_SIZE, "%d\n", !!(rxbuf & 0x30));
+       ret = !!(rxbuf & 0x30);
 error_ret:
 
-       return (ret < 0) ? ret : len;
+       return ret;
 }
 
-IIO_EVENT_ATTR(intensity0_both_thresh_en,
-       tsl2563_read_interrupt_config,
-       tsl2563_write_interrupt_config,
-       0,
-       tsl2563_int_th);
-
-static struct attribute *tsl2563_event_attributes[] = {
-       &iio_event_attr_intensity0_both_thresh_en.dev_attr.attr,
-       &iio_dev_attr_intensity0_both_raw_thresh_rising_value.dev_attr.attr,
-       &iio_dev_attr_intensity0_both_raw_thresh_falling_value.dev_attr.attr,
-       NULL,
-};
-
-static struct attribute_group tsl2563_event_attribute_group = {
-       .attrs = tsl2563_event_attributes,
-};
-
 /*--------------------------------------------------------------*/
 /*                      Probe, Attach, Remove                   */
 /*--------------------------------------------------------------*/
 static struct i2c_driver tsl2563_i2c_driver;
 
+static const struct iio_info tsl2563_info_no_irq = {
+       .driver_module = THIS_MODULE,
+};
+
+static const struct iio_info tsl2563_info = {
+       .driver_module = THIS_MODULE,
+       .num_interrupt_lines = 1,
+       .read_raw = &tsl2563_read_raw,
+       .write_raw = &tsl2563_write_raw,
+       .read_event_value = &tsl2563_read_thresh,
+       .write_event_value = &tsl2563_write_thresh,
+       .read_event_config = &tsl2563_read_interrupt_config,
+       .write_event_config = &tsl2563_write_interrupt_config,
+};
+
 static int __devinit tsl2563_probe(struct i2c_client *client,
                                const struct i2c_device_id *device_id)
 {
+       struct iio_dev *indio_dev;
        struct tsl2563_chip *chip;
        struct tsl2563_platform_data *pdata = client->dev.platform_data;
        int err = 0;
        int ret;
        u8 id;
 
-       chip = kzalloc(sizeof(*chip), GFP_KERNEL);
-       if (!chip)
+       indio_dev = iio_allocate_device(sizeof(*chip));
+       if (!indio_dev)
                return -ENOMEM;
 
-       INIT_WORK(&chip->work_thresh, tsl2563_int_bh);
+       chip = iio_priv(indio_dev);
+
        i2c_set_clientdata(client, chip);
        chip->client = client;
 
@@ -856,30 +748,25 @@ static int __devinit tsl2563_probe(struct i2c_client *client,
                chip->cover_comp_gain = 1;
 
        dev_info(&client->dev, "model %d, rev. %d\n", id >> 4, id & 0x0f);
-
-       chip->indio_dev = iio_allocate_device();
-       if (!chip->indio_dev)
-               goto fail1;
-       chip->indio_dev->attrs = &tsl2563_group;
-       chip->indio_dev->dev.parent = &client->dev;
-       chip->indio_dev->dev_data = (void *)(chip);
-       chip->indio_dev->driver_module = THIS_MODULE;
-       chip->indio_dev->modes = INDIO_DIRECT_MODE;
-       if (client->irq) {
-               chip->indio_dev->num_interrupt_lines = 1;
-               chip->indio_dev->event_attrs
-                       = &tsl2563_event_attribute_group;
-       }
-       ret = iio_device_register(chip->indio_dev);
+       indio_dev->name = client->name;
+       indio_dev->channels = tsl2563_channels;
+       indio_dev->num_channels = ARRAY_SIZE(tsl2563_channels);
+       indio_dev->dev.parent = &client->dev;
+       indio_dev->modes = INDIO_DIRECT_MODE;
+       if (client->irq)
+               indio_dev->info = &tsl2563_info;
+       else
+               indio_dev->info = &tsl2563_info_no_irq;
+       ret = iio_device_register(indio_dev);
        if (ret)
                goto fail1;
-
        if (client->irq) {
-               ret = iio_register_interrupt_line(client->irq,
-                                               chip->indio_dev,
-                                               0,
-                                               IRQF_TRIGGER_RISING,
-                                               client->name);
+               ret = request_threaded_irq(client->irq,
+                                          NULL,
+                                          &tsl2563_event_handler,
+                                          IRQF_TRIGGER_RISING | IRQF_ONESHOT,
+                                          "tsl2563_event",
+                                          indio_dev);
                if (ret)
                        goto fail2;
        }
@@ -894,9 +781,9 @@ static int __devinit tsl2563_probe(struct i2c_client *client,
        return 0;
 fail3:
        if (client->irq)
-               iio_unregister_interrupt_line(chip->indio_dev, 0);
+               free_irq(client->irq, indio_dev);
 fail2:
-       iio_device_unregister(chip->indio_dev);
+       iio_device_unregister(indio_dev);
 fail1:
        kfree(chip);
        return err;
@@ -905,6 +792,7 @@ fail1:
 static int tsl2563_remove(struct i2c_client *client)
 {
        struct tsl2563_chip *chip = i2c_get_clientdata(client);
+       struct iio_dev *indio_dev = iio_priv_to_dev(chip);
        if (!chip->int_enabled)
                cancel_delayed_work(&chip->poweroff_work);
        /* Ensure that interrupts are disabled - then flush any bottom halves */
@@ -913,10 +801,9 @@ static int tsl2563_remove(struct i2c_client *client)
        flush_scheduled_work();
        tsl2563_set_power(chip, 0);
        if (client->irq)
-               iio_unregister_interrupt_line(chip->indio_dev, 0);
-       iio_device_unregister(chip->indio_dev);
+               free_irq(client->irq, indio_dev);
+       iio_device_unregister(indio_dev);
 
-       kfree(chip);
        return 0;
 }
 
diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c
new file mode 100644 (file)
index 0000000..5694610
--- /dev/null
@@ -0,0 +1,964 @@
+/*
+ * Device driver for monitoring ambient light intensity (lux)
+ * within the TAOS tsl258x family of devices (tsl2580, tsl2581).
+ *
+ * Copyright (c) 2011, TAOS Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include <linux/kernel.h>
+#include <linux/i2c.h>
+#include <linux/errno.h>
+#include <linux/delay.h>
+#include <linux/string.h>
+#include <linux/mutex.h>
+#include <linux/unistd.h>
+#include <linux/slab.h>
+#include "../iio.h"
+
+#define TSL258X_MAX_DEVICE_REGS                32
+
+/* Triton register offsets */
+#define        TSL258X_REG_MAX         8
+
+/* Device Registers and Masks */
+#define TSL258X_CNTRL                  0x00
+#define TSL258X_ALS_TIME               0X01
+#define TSL258X_INTERRUPT              0x02
+#define TSL258X_GAIN                   0x07
+#define TSL258X_REVID                  0x11
+#define TSL258X_CHIPID                 0x12
+#define TSL258X_ALS_CHAN0LO            0x14
+#define TSL258X_ALS_CHAN0HI            0x15
+#define TSL258X_ALS_CHAN1LO            0x16
+#define TSL258X_ALS_CHAN1HI            0x17
+#define TSL258X_TMR_LO                 0x18
+#define TSL258X_TMR_HI                 0x19
+
+/* tsl2583 cmd reg masks */
+#define TSL258X_CMD_REG                        0x80
+#define TSL258X_CMD_SPL_FN             0x60
+#define TSL258X_CMD_ALS_INT_CLR        0X01
+
+/* tsl2583 cntrl reg masks */
+#define TSL258X_CNTL_ADC_ENBL  0x02
+#define TSL258X_CNTL_PWR_ON            0x01
+
+/* tsl2583 status reg masks */
+#define TSL258X_STA_ADC_VALID  0x01
+#define TSL258X_STA_ADC_INTR   0x10
+
+/* Lux calculation constants */
+#define        TSL258X_LUX_CALC_OVER_FLOW              65535
+
+enum {
+       TSL258X_CHIP_UNKNOWN = 0,
+       TSL258X_CHIP_WORKING = 1,
+       TSL258X_CHIP_SUSPENDED = 2
+} TSL258X_CHIP_WORKING_STATUS;
+
+/* Per-device data */
+struct taos_als_info {
+       u16 als_ch0;
+       u16 als_ch1;
+       u16 lux;
+};
+
+struct taos_settings {
+       int als_time;
+       int als_gain;
+       int als_gain_trim;
+       int als_cal_target;
+};
+
+struct tsl2583_chip {
+       struct mutex als_mutex;
+       struct i2c_client *client;
+       struct iio_dev *iio_dev;
+       struct taos_als_info als_cur_info;
+       struct taos_settings taos_settings;
+       int als_time_scale;
+       int als_saturation;
+       int taos_chip_status;
+       u8 taos_config[8];
+};
+
+/*
+ * Initial values for device - this values can/will be changed by driver.
+ * and applications as needed.
+ * These values are dynamic.
+ */
+static const u8 taos_config[8] = {
+               0x00, 0xee, 0x00, 0x03, 0x00, 0xFF, 0xFF, 0x00
+}; /*  cntrl atime intC  Athl0 Athl1 Athh0 Athh1 gain */
+
+struct taos_lux {
+       unsigned int ratio;
+       unsigned int ch0;
+       unsigned int ch1;
+};
+
+/* This structure is intentionally large to accommodate updates via sysfs. */
+/* Sized to 11 = max 10 segments + 1 termination segment */
+/* Assumption is is one and only one type of glass used  */
+struct taos_lux taos_device_lux[11] = {
+       {  9830,  8520, 15729 },
+       { 12452, 10807, 23344 },
+       { 14746,  6383, 11705 },
+       { 17695,  4063,  6554 },
+};
+
+struct gainadj {
+       s16 ch0;
+       s16 ch1;
+};
+
+/* Index = (0 - 3) Used to validate the gain selection index */
+static const struct gainadj gainadj[] = {
+       { 1, 1 },
+       { 8, 8 },
+       { 16, 16 },
+       { 107, 115 }
+};
+
+/*
+ * Provides initial operational parameter defaults.
+ * These defaults may be changed through the device's sysfs files.
+ */
+static void taos_defaults(struct tsl2583_chip *chip)
+{
+       /* Operational parameters */
+       chip->taos_settings.als_time = 100;
+       /* must be a multiple of 50mS */
+       chip->taos_settings.als_gain = 0;
+       /* this is actually an index into the gain table */
+       /* assume clear glass as default */
+       chip->taos_settings.als_gain_trim = 1000;
+       /* default gain trim to account for aperture effects */
+       chip->taos_settings.als_cal_target = 130;
+       /* Known external ALS reading used for calibration */
+}
+
+/*
+ * Read a number of bytes starting at register (reg) location.
+ * Return 0, or i2c_smbus_write_byte ERROR code.
+ */
+static int
+taos_i2c_read(struct i2c_client *client, u8 reg, u8 *val, unsigned int len)
+{
+       int ret;
+       int i;
+
+       for (i = 0; i < len; i++) {
+               /* select register to write */
+               ret = i2c_smbus_write_byte(client, (TSL258X_CMD_REG | reg));
+               if (ret < 0) {
+                       dev_err(&client->dev, "taos_i2c_read failed to write"
+                               " register %x\n", reg);
+                       return ret;
+               }
+               /* read the data */
+               *val = i2c_smbus_read_byte(client);
+               val++;
+               reg++;
+       }
+       return 0;
+}
+
+/*
+ * Reads and calculates current lux value.
+ * The raw ch0 and ch1 values of the ambient light sensed in the last
+ * integration cycle are read from the device.
+ * Time scale factor array values are adjusted based on the integration time.
+ * The raw values are multiplied by a scale factor, and device gain is obtained
+ * using gain index. Limit checks are done next, then the ratio of a multiple
+ * of ch1 value, to the ch0 value, is calculated. The array taos_device_lux[]
+ * declared above is then scanned to find the first ratio value that is just
+ * above the ratio we just calculated. The ch0 and ch1 multiplier constants in
+ * the array are then used along with the time scale factor array values, to
+ * calculate the lux.
+ */
+static int taos_get_lux(struct i2c_client *client)
+{
+       u16 ch0, ch1; /* separated ch0/ch1 data from device */
+       u32 lux; /* raw lux calculated from device data */
+       u32 ratio;
+       u8 buf[5];
+       struct taos_lux *p;
+       struct tsl2583_chip *chip = i2c_get_clientdata(client);
+       int i, ret;
+       u32 ch0lux = 0;
+       u32 ch1lux = 0;
+
+       if (mutex_trylock(&chip->als_mutex) == 0) {
+               dev_info(&client->dev, "taos_get_lux device is busy\n");
+               return chip->als_cur_info.lux; /* busy, so return LAST VALUE */
+       }
+
+       if (chip->taos_chip_status != TSL258X_CHIP_WORKING) {
+               /* device is not enabled */
+               dev_err(&client->dev, "taos_get_lux device is not enabled\n");
+               ret = -EBUSY ;
+               goto out_unlock;
+       }
+
+       ret = taos_i2c_read(client, (TSL258X_CMD_REG), &buf[0], 1);
+       if (ret < 0) {
+               dev_err(&client->dev, "taos_get_lux failed to read CMD_REG\n");
+               goto out_unlock;
+       }
+       /* is data new & valid */
+       if (!(buf[0] & TSL258X_STA_ADC_INTR)) {
+               dev_err(&client->dev, "taos_get_lux data not valid\n");
+               ret = chip->als_cur_info.lux; /* return LAST VALUE */
+               goto out_unlock;
+       }
+
+       for (i = 0; i < 4; i++) {
+               int reg = TSL258X_CMD_REG | (TSL258X_ALS_CHAN0LO + i);
+               ret = taos_i2c_read(client, reg, &buf[i], 1);
+               if (ret < 0) {
+                       dev_err(&client->dev, "taos_get_lux failed to read"
+                               " register %x\n", reg);
+                       goto out_unlock;
+               }
+       }
+
+       /* clear status, really interrupt status (interrupts are off), but
+        * we use the bit anyway - don't forget 0x80 - this is a command*/
+       ret = i2c_smbus_write_byte(client,
+       (TSL258X_CMD_REG | TSL258X_CMD_SPL_FN | TSL258X_CMD_ALS_INT_CLR));
+
+       if (ret < 0) {
+               dev_err(&client->dev,
+                       "taos_i2c_write_command failed in taos_get_lux, err = %d\n",
+                       ret);
+               goto out_unlock; /* have no data, so return failure */
+       }
+
+       /* extract ALS/lux data */
+       ch0 = le16_to_cpup((const __le16 *)&buf[0]);
+       ch1 = le16_to_cpup((const __le16 *)&buf[2]);
+
+       chip->als_cur_info.als_ch0 = ch0;
+       chip->als_cur_info.als_ch1 = ch1;
+
+       if ((ch0 >= chip->als_saturation) || (ch1 >= chip->als_saturation))
+               goto return_max;
+
+       if (ch0 == 0) {
+               /* have no data, so return LAST VALUE */
+               ret = chip->als_cur_info.lux = 0;
+               goto out_unlock;
+       }
+       /* calculate ratio */
+       ratio = (ch1 << 15) / ch0;
+       /* convert to unscaled lux using the pointer to the table */
+       for (p = (struct taos_lux *) taos_device_lux;
+            p->ratio != 0 && p->ratio < ratio; p++)
+               ;
+
+       if (p->ratio == 0) {
+               lux = 0;
+       } else {
+               ch0lux = ((ch0 * p->ch0) +
+                         (gainadj[chip->taos_settings.als_gain].ch0 >> 1))
+                        / gainadj[chip->taos_settings.als_gain].ch0;
+               ch1lux = ((ch1 * p->ch1) +
+                         (gainadj[chip->taos_settings.als_gain].ch1 >> 1))
+                        / gainadj[chip->taos_settings.als_gain].ch1;
+               lux = ch0lux - ch1lux;
+       }
+
+       /* note: lux is 31 bit max at this point */
+       if (ch1lux > ch0lux) {
+               dev_dbg(&client->dev, "No Data - Return last value\n");
+               ret = chip->als_cur_info.lux = 0;
+               goto out_unlock;
+       }
+
+       /* adjust for active time scale */
+       if (chip->als_time_scale == 0)
+               lux = 0;
+       else
+               lux = (lux + (chip->als_time_scale >> 1)) /
+                       chip->als_time_scale;
+
+       /* adjust for active gain scale */
+       lux >>= 13; /* tables have factor of 8192 builtin for accuracy */
+       lux = (lux * chip->taos_settings.als_gain_trim + 500) / 1000;
+       if (lux > TSL258X_LUX_CALC_OVER_FLOW) { /* check for overflow */
+return_max:
+               lux = TSL258X_LUX_CALC_OVER_FLOW;
+       }
+
+       /* Update the structure with the latest VALID lux. */
+       chip->als_cur_info.lux = lux;
+       ret = lux;
+
+out_unlock:
+       mutex_unlock(&chip->als_mutex);
+       return ret;
+}
+
+/*
+ * Obtain single reading and calculate the als_gain_trim (later used
+ * to derive actual lux).
+ * Return updated gain_trim value.
+ */
+int taos_als_calibrate(struct i2c_client *client)
+{
+       struct tsl2583_chip *chip = i2c_get_clientdata(client);
+       u8 reg_val;
+       unsigned int gain_trim_val;
+       int ret;
+       int lux_val;
+
+       ret = i2c_smbus_write_byte(client, (TSL258X_CMD_REG | TSL258X_CNTRL));
+       if (ret < 0) {
+               dev_err(&client->dev,
+                       "taos_als_calibrate failed to reach the CNTRL register, ret=%d\n",
+                       ret);
+               return ret;
+       }
+
+       reg_val = i2c_smbus_read_byte(client);
+       if ((reg_val & (TSL258X_CNTL_ADC_ENBL | TSL258X_CNTL_PWR_ON))
+                       != (TSL258X_CNTL_ADC_ENBL | TSL258X_CNTL_PWR_ON)) {
+               dev_err(&client->dev,
+                       "taos_als_calibrate failed: device not powered on with ADC enabled\n");
+               return -1;
+       }
+
+       ret = i2c_smbus_write_byte(client, (TSL258X_CMD_REG | TSL258X_CNTRL));
+       if (ret < 0) {
+               dev_err(&client->dev,
+                       "taos_als_calibrate failed to reach the STATUS register, ret=%d\n",
+                       ret);
+               return ret;
+       }
+       reg_val = i2c_smbus_read_byte(client);
+
+       if ((reg_val & TSL258X_STA_ADC_VALID) != TSL258X_STA_ADC_VALID) {
+               dev_err(&client->dev,
+                       "taos_als_calibrate failed: STATUS - ADC not valid.\n");
+               return -ENODATA;
+       }
+       lux_val = taos_get_lux(client);
+       if (lux_val < 0) {
+               dev_err(&client->dev, "taos_als_calibrate failed to get lux\n");
+               return lux_val;
+       }
+       gain_trim_val = (unsigned int) (((chip->taos_settings.als_cal_target)
+                       * chip->taos_settings.als_gain_trim) / lux_val);
+
+       if ((gain_trim_val < 250) || (gain_trim_val > 4000)) {
+               dev_err(&client->dev,
+                       "taos_als_calibrate failed: trim_val of %d is out of range\n",
+                       gain_trim_val);
+               return -ENODATA;
+       }
+       chip->taos_settings.als_gain_trim = (int) gain_trim_val;
+
+       return (int) gain_trim_val;
+}
+
+/*
+ * Turn the device on.
+ * Configuration must be set before calling this function.
+ */
+static int taos_chip_on(struct i2c_client *client)
+{
+       int i;
+       int ret = 0;
+       u8 *uP;
+       u8 utmp;
+       int als_count;
+       int als_time;
+       struct tsl2583_chip *chip = i2c_get_clientdata(client);
+
+       /* and make sure we're not already on */
+       if (chip->taos_chip_status == TSL258X_CHIP_WORKING) {
+               /* if forcing a register update - turn off, then on */
+               dev_info(&client->dev, "device is already enabled\n");
+               return   -EINVAL;
+       }
+
+       /* determine als integration regster */
+       als_count = (chip->taos_settings.als_time * 100 + 135) / 270;
+       if (als_count == 0)
+               als_count = 1; /* ensure at least one cycle */
+
+       /* convert back to time (encompasses overrides) */
+       als_time = (als_count * 27 + 5) / 10;
+       chip->taos_config[TSL258X_ALS_TIME] = 256 - als_count;
+
+       /* Set the gain based on taos_settings struct */
+       chip->taos_config[TSL258X_GAIN] = chip->taos_settings.als_gain;
+
+       /* set chip struct re scaling and saturation */
+       chip->als_saturation = als_count * 922; /* 90% of full scale */
+       chip->als_time_scale = (als_time + 25) / 50;
+
+       /* TSL258x Specific power-on / adc enable sequence
+        * Power on the device 1st. */
+       utmp = TSL258X_CNTL_PWR_ON;
+       ret = i2c_smbus_write_byte_data(client,
+               TSL258X_CMD_REG | TSL258X_CNTRL, utmp);
+       if (ret < 0) {
+               dev_err(&client->dev, "taos_chip_on failed on CNTRL reg.\n");
+               return -1;
+       }
+
+       /* Use the following shadow copy for our delay before enabling ADC.
+        * Write all the registers. */
+       for (i = 0, uP = chip->taos_config; i < TSL258X_REG_MAX; i++) {
+               ret = i2c_smbus_write_byte_data(client, TSL258X_CMD_REG + i,
+                                               *uP++);
+               if (ret < 0) {
+                       dev_err(&client->dev,
+                               "taos_chip_on failed on reg %d.\n", i);
+                       return -1;
+               }
+       }
+
+       msleep(3);
+       /* NOW enable the ADC
+        * initialize the desired mode of operation */
+       utmp = TSL258X_CNTL_PWR_ON | TSL258X_CNTL_ADC_ENBL;
+       ret = i2c_smbus_write_byte_data(client, TSL258X_CMD_REG | TSL258X_CNTRL,
+                                       utmp);
+       if (ret < 0) {
+               dev_err(&client->dev, "taos_chip_on failed on 2nd CTRL reg.\n");
+               return -1;
+       }
+       chip->taos_chip_status = TSL258X_CHIP_WORKING;
+
+       return ret;
+}
+
+static int taos_chip_off(struct i2c_client *client)
+{
+       struct tsl2583_chip *chip = i2c_get_clientdata(client);
+       int ret;
+
+       /* turn device off */
+       chip->taos_chip_status = TSL258X_CHIP_SUSPENDED;
+       ret = i2c_smbus_write_byte_data(client, TSL258X_CMD_REG | TSL258X_CNTRL,
+                                       0x00);
+       return ret;
+}
+
+/* Sysfs Interface Functions */
+static ssize_t taos_device_id(struct device *dev,
+struct device_attribute *attr, char *buf)
+{
+       struct iio_dev *indio_dev = dev_get_drvdata(dev);
+       struct tsl2583_chip *chip = indio_dev->dev_data;
+
+       return sprintf(buf, "%s\n", chip->client->name);
+}
+
+static ssize_t taos_power_state_show(struct device *dev,
+       struct device_attribute *attr, char *buf)
+{
+       struct iio_dev *indio_dev = dev_get_drvdata(dev);
+       struct tsl2583_chip *chip = indio_dev->dev_data;
+
+       return sprintf(buf, "%d\n", chip->taos_chip_status);
+}
+
+static ssize_t taos_power_state_store(struct device *dev,
+       struct device_attribute *attr, const char *buf, size_t len)
+{
+       struct iio_dev *indio_dev = dev_get_drvdata(dev);
+       struct tsl2583_chip *chip = indio_dev->dev_data;
+       unsigned long value;
+
+       if (strict_strtoul(buf, 0, &value))
+               return -EINVAL;
+
+       if (value == 0)
+               taos_chip_off(chip->client);
+       else
+               taos_chip_on(chip->client);
+
+       return len;
+}
+
+static ssize_t taos_gain_show(struct device *dev,
+       struct device_attribute *attr, char *buf)
+{
+       struct iio_dev *indio_dev = dev_get_drvdata(dev);
+       struct tsl2583_chip *chip = indio_dev->dev_data;
+       char gain[4] = {0};
+
+       switch (chip->taos_settings.als_gain) {
+       case 0:
+               strcpy(gain, "001");
+               break;
+       case 1:
+               strcpy(gain, "008");
+               break;
+       case 2:
+               strcpy(gain, "016");
+               break;
+       case 3:
+               strcpy(gain, "111");
+               break;
+       }
+
+       return sprintf(buf, "%s\n", gain);
+}
+
+static ssize_t taos_gain_store(struct device *dev,
+       struct device_attribute *attr, const char *buf, size_t len)
+{
+       struct iio_dev *indio_dev = dev_get_drvdata(dev);
+       struct tsl2583_chip *chip = indio_dev->dev_data;
+       unsigned long value;
+
+       if (strict_strtoul(buf, 0, &value))
+               return -EINVAL;
+
+       switch (value) {
+       case 1:
+               chip->taos_settings.als_gain = 0;
+               break;
+       case 8:
+               chip->taos_settings.als_gain = 1;
+               break;
+       case 16:
+               chip->taos_settings.als_gain = 2;
+               break;
+       case 111:
+               chip->taos_settings.als_gain = 3;
+               break;
+       default:
+               dev_err(dev, "Invalid Gain Index (must be 1,8,16,111)\n");
+               return -1;
+       }
+
+       return len;
+}
+
+static ssize_t taos_gain_available_show(struct device *dev,
+       struct device_attribute *attr, char *buf)
+{
+       return sprintf(buf, "%s\n", "1 8 16 111");
+}
+
+static ssize_t taos_als_time_show(struct device *dev,
+       struct device_attribute *attr, char *buf)
+{
+       struct iio_dev *indio_dev = dev_get_drvdata(dev);
+       struct tsl2583_chip *chip = indio_dev->dev_data;
+
+       return sprintf(buf, "%d\n", chip->taos_settings.als_time);
+}
+
+static ssize_t taos_als_time_store(struct device *dev,
+       struct device_attribute *attr, const char *buf, size_t len)
+{
+       struct iio_dev *indio_dev = dev_get_drvdata(dev);
+       struct tsl2583_chip *chip = indio_dev->dev_data;
+       unsigned long value;
+
+       if (strict_strtoul(buf, 0, &value))
+               return -EINVAL;
+
+       if ((value < 50) || (value > 650))
+               return -EINVAL;
+
+       if (value % 50)
+               return -EINVAL;
+
+        chip->taos_settings.als_time = value;
+
+       return len;
+}
+
+static ssize_t taos_als_time_available_show(struct device *dev,
+       struct device_attribute *attr, char *buf)
+{
+       return sprintf(buf, "%s\n",
+               "50 100 150 200 250 300 350 400 450 500 550 600 650");
+}
+
+static ssize_t taos_als_trim_show(struct device *dev,
+       struct device_attribute *attr, char *buf)
+{
+       struct iio_dev *indio_dev = dev_get_drvdata(dev);
+       struct tsl2583_chip *chip = indio_dev->dev_data;
+
+       return sprintf(buf, "%d\n", chip->taos_settings.als_gain_trim);
+}
+
+static ssize_t taos_als_trim_store(struct device *dev,
+       struct device_attribute *attr, const char *buf, size_t len)
+{
+       struct iio_dev *indio_dev = dev_get_drvdata(dev);
+       struct tsl2583_chip *chip = indio_dev->dev_data;
+       unsigned long value;
+
+       if (strict_strtoul(buf, 0, &value))
+               return -EINVAL;
+
+       if (value)
+               chip->taos_settings.als_gain_trim = value;
+
+       return len;
+}
+
+static ssize_t taos_als_cal_target_show(struct device *dev,
+       struct device_attribute *attr, char *buf)
+{
+       struct iio_dev *indio_dev = dev_get_drvdata(dev);
+       struct tsl2583_chip *chip = indio_dev->dev_data;
+
+       return sprintf(buf, "%d\n", chip->taos_settings.als_cal_target);
+}
+
+static ssize_t taos_als_cal_target_store(struct device *dev,
+       struct device_attribute *attr, const char *buf, size_t len)
+{
+       struct iio_dev *indio_dev = dev_get_drvdata(dev);
+       struct tsl2583_chip *chip = indio_dev->dev_data;
+       unsigned long value;
+
+       if (strict_strtoul(buf, 0, &value))
+               return -EINVAL;
+
+       if (value)
+               chip->taos_settings.als_cal_target = value;
+
+       return len;
+}
+
+static ssize_t taos_lux_show(struct device *dev, struct device_attribute *attr,
+       char *buf)
+{
+       struct iio_dev *indio_dev = dev_get_drvdata(dev);
+       struct tsl2583_chip *chip = indio_dev->dev_data;
+       int lux;
+
+       lux = taos_get_lux(chip->client);
+
+       return sprintf(buf, "%d\n", lux);
+}
+
+static ssize_t taos_do_calibrate(struct device *dev,
+       struct device_attribute *attr, const char *buf, size_t len)
+{
+       struct iio_dev *indio_dev = dev_get_drvdata(dev);
+       struct tsl2583_chip *chip = indio_dev->dev_data;
+       unsigned long value;
+
+       if (strict_strtoul(buf, 0, &value))
+               return -EINVAL;
+
+       if (value == 1)
+               taos_als_calibrate(chip->client);
+
+       return len;
+}
+
+static ssize_t taos_luxtable_show(struct device *dev,
+       struct device_attribute *attr, char *buf)
+{
+       int i;
+       int offset = 0;
+
+       for (i = 0; i < ARRAY_SIZE(taos_device_lux); i++) {
+               offset += sprintf(buf + offset, "%d,%d,%d,",
+                                 taos_device_lux[i].ratio,
+                                 taos_device_lux[i].ch0,
+                                 taos_device_lux[i].ch1);
+               if (taos_device_lux[i].ratio == 0) {
+                       /* We just printed the first "0" entry.
+                        * Now get rid of the extra "," and break. */
+                       offset--;
+                       break;
+               }
+       }
+
+       offset += sprintf(buf + offset, "\n");
+       return offset;
+}
+
+static ssize_t taos_luxtable_store(struct device *dev,
+       struct device_attribute *attr, const char *buf, size_t len)
+{
+       struct iio_dev *indio_dev = dev_get_drvdata(dev);
+       struct tsl2583_chip *chip = indio_dev->dev_data;
+       int value[ARRAY_SIZE(taos_device_lux)];
+       int n;
+
+       get_options(buf, ARRAY_SIZE(value), value);
+
+       /* We now have an array of ints starting at value[1], and
+        * enumerated by value[0].
+        * We expect each group of three ints is one table entry,
+        * and the last table entry is all 0.
+        */
+       n = value[0];
+       if ((n % 3) || n < 6 || n > ((ARRAY_SIZE(taos_device_lux) - 1) * 3)) {
+               dev_info(dev, "LUX TABLE INPUT ERROR 1 Value[0]=%d\n", n);
+               return -EINVAL;
+       }
+       if ((value[(n - 2)] | value[(n - 1)] | value[n]) != 0) {
+               dev_info(dev, "LUX TABLE INPUT ERROR 2 Value[0]=%d\n", n);
+               return -EINVAL;
+       }
+
+       if (chip->taos_chip_status == TSL258X_CHIP_WORKING)
+               taos_chip_off(chip->client);
+
+       /* Zero out the table */
+       memset(taos_device_lux, 0, sizeof(taos_device_lux));
+       memcpy(taos_device_lux, &value[1], (value[0] * 4));
+
+       taos_chip_on(chip->client);
+
+       return len;
+}
+
+static DEVICE_ATTR(name, S_IRUGO, taos_device_id, NULL);
+static DEVICE_ATTR(power_state, S_IRUGO | S_IWUSR,
+               taos_power_state_show, taos_power_state_store);
+
+static DEVICE_ATTR(illuminance0_calibscale, S_IRUGO | S_IWUSR,
+               taos_gain_show, taos_gain_store);
+static DEVICE_ATTR(illuminance0_calibscale_available, S_IRUGO,
+               taos_gain_available_show, NULL);
+
+static DEVICE_ATTR(illuminance0_integration_time, S_IRUGO | S_IWUSR,
+               taos_als_time_show, taos_als_time_store);
+static DEVICE_ATTR(illuminance0_integration_time_available, S_IRUGO,
+               taos_als_time_available_show, NULL);
+
+static DEVICE_ATTR(illuminance0_calibbias, S_IRUGO | S_IWUSR,
+               taos_als_trim_show, taos_als_trim_store);
+
+static DEVICE_ATTR(illuminance0_input_target, S_IRUGO | S_IWUSR,
+               taos_als_cal_target_show, taos_als_cal_target_store);
+
+static DEVICE_ATTR(illuminance0_input, S_IRUGO, taos_lux_show, NULL);
+static DEVICE_ATTR(illuminance0_calibrate, S_IWUSR, NULL, taos_do_calibrate);
+static DEVICE_ATTR(illuminance0_lux_table, S_IRUGO | S_IWUSR,
+               taos_luxtable_show, taos_luxtable_store);
+
+static struct attribute *sysfs_attrs_ctrl[] = {
+       &dev_attr_name.attr,
+       &dev_attr_power_state.attr,
+       &dev_attr_illuminance0_calibscale.attr,                 /* Gain  */
+       &dev_attr_illuminance0_calibscale_available.attr,
+       &dev_attr_illuminance0_integration_time.attr,   /* I time*/
+       &dev_attr_illuminance0_integration_time_available.attr,
+       &dev_attr_illuminance0_calibbias.attr,                  /* trim  */
+       &dev_attr_illuminance0_input_target.attr,
+       &dev_attr_illuminance0_input.attr,
+       &dev_attr_illuminance0_calibrate.attr,
+       &dev_attr_illuminance0_lux_table.attr,
+       NULL
+};
+
+static struct attribute_group tsl2583_attribute_group = {
+       .attrs = sysfs_attrs_ctrl,
+};
+
+/* Use the default register values to identify the Taos device */
+static int taos_tsl258x_device(unsigned char *bufp)
+{
+       return ((bufp[TSL258X_CHIPID] & 0xf0) == 0x90);
+}
+
+static const struct iio_info tsl2583_info = {
+       .attrs = &tsl2583_attribute_group,
+       .driver_module = THIS_MODULE,
+};
+
+/*
+ * Client probe function - When a valid device is found, the driver's device
+ * data structure is updated, and initialization completes successfully.
+ */
+static int __devinit taos_probe(struct i2c_client *clientp,
+                     const struct i2c_device_id *idp)
+{
+       int i, ret = 0;
+       unsigned char buf[TSL258X_MAX_DEVICE_REGS];
+       static struct tsl2583_chip *chip;
+
+       if (!i2c_check_functionality(clientp->adapter,
+               I2C_FUNC_SMBUS_BYTE_DATA)) {
+               dev_err(&clientp->dev,
+                       "taos_probe() - i2c smbus byte data "
+                       "functions unsupported\n");
+               return -EOPNOTSUPP;
+       }
+
+       chip = kzalloc(sizeof(struct tsl2583_chip), GFP_KERNEL);
+       if (!chip)
+               return -ENOMEM;
+
+       chip->client = clientp;
+       i2c_set_clientdata(clientp, chip);
+
+       mutex_init(&chip->als_mutex);
+       chip->taos_chip_status = TSL258X_CHIP_UNKNOWN;
+       memcpy(chip->taos_config, taos_config, sizeof(chip->taos_config));
+
+       for (i = 0; i < TSL258X_MAX_DEVICE_REGS; i++) {
+               ret = i2c_smbus_write_byte(clientp,
+                               (TSL258X_CMD_REG | (TSL258X_CNTRL + i)));
+               if (ret < 0) {
+                       dev_err(&clientp->dev, "i2c_smbus_write_bytes() to cmd "
+                               "reg failed in taos_probe(), err = %d\n", ret);
+                       goto fail1;
+               }
+               ret = i2c_smbus_read_byte(clientp);
+               if (ret < 0) {
+                       dev_err(&clientp->dev, "i2c_smbus_read_byte from "
+                               "reg failed in taos_probe(), err = %d\n", ret);
+
+                       goto fail1;
+               }
+               buf[i] = ret;
+       }
+
+       if (!taos_tsl258x_device(buf)) {
+               dev_info(&clientp->dev, "i2c device found but does not match "
+                       "expected id in taos_probe()\n");
+               goto fail1;
+       }
+
+       ret = i2c_smbus_write_byte(clientp, (TSL258X_CMD_REG | TSL258X_CNTRL));
+       if (ret < 0) {
+               dev_err(&clientp->dev, "i2c_smbus_write_byte() to cmd reg "
+                       "failed in taos_probe(), err = %d\n", ret);
+               goto fail1;
+       }
+
+       chip->iio_dev = iio_allocate_device(0);
+       if (!chip->iio_dev) {
+               ret = -ENOMEM;
+               dev_err(&clientp->dev, "iio allocation failed\n");
+               goto fail1;
+       }
+
+       chip->iio_dev->info = &tsl2583_info;
+       chip->iio_dev->dev.parent = &clientp->dev;
+       chip->iio_dev->dev_data = (void *)(chip);
+       chip->iio_dev->modes = INDIO_DIRECT_MODE;
+       ret = iio_device_register(chip->iio_dev);
+       if (ret) {
+               dev_err(&clientp->dev, "iio registration failed\n");
+               goto fail1;
+       }
+
+       /* Load up the V2 defaults (these are hard coded defaults for now) */
+       taos_defaults(chip);
+
+       /* Make sure the chip is on */
+       taos_chip_on(clientp);
+
+       dev_info(&clientp->dev, "Light sensor found.\n");
+
+       return 0;
+
+fail1:
+       kfree(chip);
+
+       return ret;
+}
+
+static int taos_suspend(struct i2c_client *client, pm_message_t state)
+{
+       struct tsl2583_chip *chip = i2c_get_clientdata(client);
+       int ret = 0;
+
+       mutex_lock(&chip->als_mutex);
+
+       if (chip->taos_chip_status == TSL258X_CHIP_WORKING) {
+               ret = taos_chip_off(client);
+               chip->taos_chip_status = TSL258X_CHIP_SUSPENDED;
+       }
+
+       mutex_unlock(&chip->als_mutex);
+       return ret;
+}
+
+static int taos_resume(struct i2c_client *client)
+{
+       struct tsl2583_chip *chip = i2c_get_clientdata(client);
+       int ret = 0;
+
+       mutex_lock(&chip->als_mutex);
+
+       if (chip->taos_chip_status == TSL258X_CHIP_SUSPENDED)
+               ret = taos_chip_on(client);
+
+       mutex_unlock(&chip->als_mutex);
+       return ret;
+}
+
+
+static int __devexit taos_remove(struct i2c_client *client)
+{
+       struct tsl2583_chip *chip = i2c_get_clientdata(client);
+
+       iio_device_unregister(chip->iio_dev);
+
+       kfree(chip);
+       return 0;
+}
+
+static struct i2c_device_id taos_idtable[] = {
+       { "tsl2580", 0 },
+       { "tsl2581", 1 },
+       { "tsl2583", 2 },
+       {}
+};
+MODULE_DEVICE_TABLE(i2c, taos_idtable);
+
+/* Driver definition */
+static struct i2c_driver taos_driver = {
+       .driver = {
+               .name = "tsl2583",
+       },
+       .id_table = taos_idtable,
+       .suspend        = taos_suspend,
+       .resume         = taos_resume,
+       .probe = taos_probe,
+       .remove = __devexit_p(taos_remove),
+};
+
+static int __init taos_init(void)
+{
+       return i2c_add_driver(&taos_driver);
+}
+
+static void __exit taos_exit(void)
+{
+       i2c_del_driver(&taos_driver);
+}
+
+module_init(taos_init);
+module_exit(taos_exit);
+
+MODULE_AUTHOR("J. August Brenner<jbrenner@taosinc.com>");
+MODULE_DESCRIPTION("TAOS tsl2583 ambient light sensor driver");
+MODULE_LICENSE("GPL");
index 420f206cf517618495f0c0885f4634bd0aa77203..700f96c7027394f9c12b9960f2431886e153200f 100644 (file)
@@ -206,7 +206,7 @@ static int ak8975_setup(struct i2c_client *client)
        }
 
        /* Precalculate scale factor for each axis and
-           store in the device data. */
+          store in the device data. */
        data->raw_to_gauss[0] = ((data->asa[0] + 128) * 30) >> 8;
        data->raw_to_gauss[1] = ((data->asa[1] + 128) * 30) >> 8;
        data->raw_to_gauss[2] = ((data->asa[2] + 128) * 30) >> 8;
@@ -316,6 +316,59 @@ static ssize_t show_scale(struct device *dev, struct device_attribute *devattr,
        return sprintf(buf, "%ld\n", data->raw_to_gauss[this_attr->address]);
 }
 
+static int wait_conversion_complete_gpio(struct ak8975_data *data)
+{
+       struct i2c_client *client = data->client;
+       u8 read_status;
+       u32 timeout_ms = AK8975_MAX_CONVERSION_TIMEOUT;
+       int ret;
+
+       /* Wait for the conversion to complete. */
+       while (timeout_ms) {
+               msleep(AK8975_CONVERSION_DONE_POLL_TIME);
+               if (gpio_get_value(data->eoc_gpio))
+                       break;
+               timeout_ms -= AK8975_CONVERSION_DONE_POLL_TIME;
+       }
+       if (!timeout_ms) {
+               dev_err(&client->dev, "Conversion timeout happened\n");
+               return -EINVAL;
+       }
+
+       ret = ak8975_read_data(client, AK8975_REG_ST1, 1, &read_status);
+       if (ret < 0) {
+               dev_err(&client->dev, "Error in reading ST1\n");
+               return ret;
+       }
+       return read_status;
+}
+
+static int wait_conversion_complete_polled(struct ak8975_data *data)
+{
+       struct i2c_client *client = data->client;
+       u8 read_status;
+       u32 timeout_ms = AK8975_MAX_CONVERSION_TIMEOUT;
+       int ret;
+
+       /* Wait for the conversion to complete. */
+       while (timeout_ms) {
+               msleep(AK8975_CONVERSION_DONE_POLL_TIME);
+               ret = ak8975_read_data(client, AK8975_REG_ST1, 1, &read_status);
+               if (ret < 0) {
+                       dev_err(&client->dev, "Error in reading ST1\n");
+                       return ret;
+               }
+               if (read_status)
+                       break;
+               timeout_ms -= AK8975_CONVERSION_DONE_POLL_TIME;
+       }
+       if (!timeout_ms) {
+               dev_err(&client->dev, "Conversion timeout happened\n");
+               return -EINVAL;
+       }
+       return read_status;
+}
+
 /*
  * Emits the raw flux value for the x, y, or z axis.
  */
@@ -326,7 +379,6 @@ static ssize_t show_raw(struct device *dev, struct device_attribute *devattr,
        struct ak8975_data *data = indio_dev->dev_data;
        struct i2c_client *client = data->client;
        struct iio_dev_attr *this_attr = to_iio_dev_attr(devattr);
-       u32 timeout_ms = AK8975_MAX_CONVERSION_TIMEOUT;
        u16 meas_reg;
        s16 raw;
        u8 read_status;
@@ -352,23 +404,14 @@ static ssize_t show_raw(struct device *dev, struct device_attribute *devattr,
        }
 
        /* Wait for the conversion to complete. */
-       while (timeout_ms) {
-               msleep(AK8975_CONVERSION_DONE_POLL_TIME);
-               if (gpio_get_value(data->eoc_gpio))
-                       break;
-               timeout_ms -= AK8975_CONVERSION_DONE_POLL_TIME;
-       }
-       if (!timeout_ms) {
-               dev_err(&client->dev, "Conversion timeout happened\n");
-               ret = -EINVAL;
+       if (data->eoc_gpio)
+               ret = wait_conversion_complete_gpio(data);
+       else
+               ret = wait_conversion_complete_polled(data);
+       if (ret < 0)
                goto exit;
-       }
 
-       ret = ak8975_read_data(client, AK8975_REG_ST1, 1, &read_status);
-       if (ret < 0) {
-               dev_err(&client->dev, "Error in reading ST1\n");
-               goto exit;
-       }
+       read_status = ret;
 
        if (read_status & AK8975_REG_ST1_DRDY_MASK) {
                ret = ak8975_read_data(client, AK8975_REG_ST2, 1, &read_status);
@@ -431,6 +474,11 @@ static struct attribute_group ak8975_attr_group = {
        .attrs = ak8975_attr,
 };
 
+static const struct iio_info ak8975_info = {
+       .attrs = &ak8975_attr_group,
+       .driver_module = THIS_MODULE,
+};
+
 static int ak8975_probe(struct i2c_client *client,
                        const struct i2c_device_id *id)
 {
@@ -454,25 +502,26 @@ static int ak8975_probe(struct i2c_client *client,
        data->eoc_irq = client->irq;
        data->eoc_gpio = irq_to_gpio(client->irq);
 
-       if (!data->eoc_gpio) {
-               dev_err(&client->dev, "failed, no valid GPIO\n");
-               err = -EINVAL;
-               goto exit_free;
-       }
-
-       err = gpio_request(data->eoc_gpio, "ak_8975");
-       if (err < 0) {
-               dev_err(&client->dev, "failed to request GPIO %d, error %d\n",
-                       data->eoc_gpio, err);
-               goto exit_free;
-       }
+       /* We may not have a GPIO based IRQ to scan, that is fine, we will
+          poll if so */
+       if (data->eoc_gpio > 0) {
+               err = gpio_request(data->eoc_gpio, "ak_8975");
+               if (err < 0) {
+                       dev_err(&client->dev,
+                               "failed to request GPIO %d, error %d\n",
+                                                       data->eoc_gpio, err);
+                       goto exit_free;
+               }
 
-       err = gpio_direction_input(data->eoc_gpio);
-       if (err < 0) {
-               dev_err(&client->dev, "Failed to configure input direction for"
-                       " GPIO %d, error %d\n", data->eoc_gpio, err);
-               goto exit_gpio;
-       }
+               err = gpio_direction_input(data->eoc_gpio);
+               if (err < 0) {
+                       dev_err(&client->dev,
+                               "Failed to configure input direction for GPIO %d, error %d\n",
+                                               data->eoc_gpio, err);
+                       goto exit_gpio;
+               }
+       } else
+               data->eoc_gpio = 0;     /* No GPIO available */
 
        /* Perform some basic start-of-day setup of the device. */
        err = ak8975_setup(client);
@@ -482,16 +531,15 @@ static int ak8975_probe(struct i2c_client *client,
        }
 
        /* Register with IIO */
-       data->indio_dev = iio_allocate_device();
+       data->indio_dev = iio_allocate_device(0);
        if (data->indio_dev == NULL) {
                err = -ENOMEM;
                goto exit_gpio;
        }
 
        data->indio_dev->dev.parent = &client->dev;
-       data->indio_dev->attrs = &ak8975_attr_group;
+       data->indio_dev->info = &ak8975_info;
        data->indio_dev->dev_data = (void *)(data);
-       data->indio_dev->driver_module = THIS_MODULE;
        data->indio_dev->modes = INDIO_DIRECT_MODE;
 
        err = iio_device_register(data->indio_dev);
@@ -503,7 +551,8 @@ static int ak8975_probe(struct i2c_client *client,
 exit_free_iio:
        iio_free_device(data->indio_dev);
 exit_gpio:
-       gpio_free(data->eoc_gpio);
+       if (data->eoc_gpio)
+               gpio_free(data->eoc_gpio);
 exit_free:
        kfree(data);
 exit:
@@ -517,7 +566,8 @@ static int ak8975_remove(struct i2c_client *client)
        iio_device_unregister(data->indio_dev);
        iio_free_device(data->indio_dev);
 
-       gpio_free(data->eoc_gpio);
+       if (data->eoc_gpio)
+               gpio_free(data->eoc_gpio);
 
        kfree(data);
 
index 51689177e00e199f96af7ab97c66ca52ae2dacb2..dd9a3bb6aa0173f95f89c55e3d1316e0321fa4c5 100644 (file)
@@ -529,6 +529,11 @@ static void hmc5843_init_client(struct i2c_client *client)
        pr_info("HMC5843 initialized\n");
 }
 
+static const struct iio_info hmc5843_info = {
+       .attrs = &hmc5843_group,
+       .driver_module = THIS_MODULE,
+};
+
 static int hmc5843_probe(struct i2c_client *client,
                         const struct i2c_device_id *id)
 {
@@ -552,15 +557,14 @@ static int hmc5843_probe(struct i2c_client *client,
        /* Initialize the HMC5843 chip */
        hmc5843_init_client(client);
 
-       data->indio_dev = iio_allocate_device();
+       data->indio_dev = iio_allocate_device(0);
        if (!data->indio_dev) {
                err = -ENOMEM;
                goto exit_free1;
        }
-       data->indio_dev->attrs = &hmc5843_group;
+       data->indio_dev->info = &hmc5843_info;
        data->indio_dev->dev.parent = &client->dev;
        data->indio_dev->dev_data = (void *)(data);
-       data->indio_dev->driver_module = THIS_MODULE;
        data->indio_dev->modes = INDIO_DIRECT_MODE;
        err = iio_device_register(data->indio_dev);
        if (err)
index 8b86d82c3b32f676c4aa97554abaf3fd94611513..6c9c23fc4aed5ab1939d298ee4b38cd5197d4b8e 100644 (file)
@@ -463,8 +463,6 @@ static IIO_DEV_ATTR_RESET(ade7753_write_reset);
 
 static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("27900 14000 7000 3500");
 
-static IIO_CONST_ATTR(name, "ade7753");
-
 static struct attribute *ade7753_attributes[] = {
        &iio_dev_attr_temp_raw.dev_attr.attr,
        &iio_const_attr_temp_offset.dev_attr.attr,
@@ -472,7 +470,6 @@ static struct attribute *ade7753_attributes[] = {
        &iio_dev_attr_sampling_frequency.dev_attr.attr,
        &iio_const_attr_sampling_frequency_available.dev_attr.attr,
        &iio_dev_attr_reset.dev_attr.attr,
-       &iio_const_attr_name.dev_attr.attr,
        &iio_dev_attr_phcal.dev_attr.attr,
        &iio_dev_attr_cfden.dev_attr.attr,
        &iio_dev_attr_aenergy.dev_attr.attr,
@@ -507,6 +504,11 @@ static const struct attribute_group ade7753_attribute_group = {
        .attrs = ade7753_attributes,
 };
 
+static const struct iio_info ade7753_info = {
+       .attrs = &ade7753_attribute_group,
+       .driver_module = THIS_MODULE,
+};
+
 static int __devinit ade7753_probe(struct spi_device *spi)
 {
        int ret, regdone = 0;
@@ -532,16 +534,16 @@ static int __devinit ade7753_probe(struct spi_device *spi)
        st->us = spi;
        mutex_init(&st->buf_lock);
        /* setup the industrialio driver allocated elements */
-       st->indio_dev = iio_allocate_device();
+       st->indio_dev = iio_allocate_device(0);
        if (st->indio_dev == NULL) {
                ret = -ENOMEM;
                goto error_free_tx;
        }
 
+       st->indio_dev->name = spi->dev.driver->name;
        st->indio_dev->dev.parent = &spi->dev;
-       st->indio_dev->attrs = &ade7753_attribute_group;
+       st->indio_dev->info = &ade7753_info;
        st->indio_dev->dev_data = (void *)(st);
-       st->indio_dev->driver_module = THIS_MODULE;
        st->indio_dev->modes = INDIO_DIRECT_MODE;
 
        ret = iio_device_register(st->indio_dev);
index 4272818e7dc447e49ead46a162e759dbe422ca33..378f2c87086f078dabd14fb5a124ae9209a3a018 100644 (file)
@@ -482,8 +482,6 @@ static IIO_DEV_ATTR_RESET(ade7754_write_reset);
 
 static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("26000 13000 65000 33000");
 
-static IIO_CONST_ATTR(name, "ade7754");
-
 static struct attribute *ade7754_attributes[] = {
        &iio_dev_attr_temp_raw.dev_attr.attr,
        &iio_const_attr_temp_offset.dev_attr.attr,
@@ -491,7 +489,6 @@ static struct attribute *ade7754_attributes[] = {
        &iio_dev_attr_sampling_frequency.dev_attr.attr,
        &iio_const_attr_sampling_frequency_available.dev_attr.attr,
        &iio_dev_attr_reset.dev_attr.attr,
-       &iio_const_attr_name.dev_attr.attr,
        &iio_dev_attr_aenergy.dev_attr.attr,
        &iio_dev_attr_laenergy.dev_attr.attr,
        &iio_dev_attr_vaenergy.dev_attr.attr,
@@ -530,7 +527,10 @@ static const struct attribute_group ade7754_attribute_group = {
        .attrs = ade7754_attributes,
 };
 
-
+static const struct iio_info ade7754_info = {
+       .attrs = &ade7754_attribute_group,
+       .driver_module = THIS_MODULE,
+};
 
 static int __devinit ade7754_probe(struct spi_device *spi)
 {
@@ -557,16 +557,16 @@ static int __devinit ade7754_probe(struct spi_device *spi)
        st->us = spi;
        mutex_init(&st->buf_lock);
        /* setup the industrialio driver allocated elements */
-       st->indio_dev = iio_allocate_device();
+       st->indio_dev = iio_allocate_device(0);
        if (st->indio_dev == NULL) {
                ret = -ENOMEM;
                goto error_free_tx;
        }
 
+       st->indio_dev->name = spi->dev.driver->name;
        st->indio_dev->dev.parent = &spi->dev;
-       st->indio_dev->attrs = &ade7754_attribute_group;
+       st->indio_dev->info = &ade7754_info;
        st->indio_dev->dev_data = (void *)(st);
-       st->indio_dev->driver_module = THIS_MODULE;
        st->indio_dev->modes = INDIO_DIRECT_MODE;
 
        ret = iio_device_register(st->indio_dev);
index c6fd94f3b3eefdd74675827f398ec827830c5d02..fd74e156abf9b8bc9572c3ea2b91cbc7ef86d230 100644 (file)
@@ -1,3 +1,11 @@
+/*
+ * ADE7758 Poly Phase Multifunction Energy Metering IC driver
+ *
+ * Copyright 2010-2011 Analog Devices Inc.
+ *
+ * Licensed under the GPL-2.
+ */
+
 #ifndef _ADE7758_H
 #define _ADE7758_H
 
 #define ADE7758_MAX_RX    4
 #define ADE7758_STARTUP_DELAY 1
 
-#define ADE7758_SPI_SLOW       (u32)(300 * 1000)
-#define ADE7758_SPI_BURST      (u32)(1000 * 1000)
-#define ADE7758_SPI_FAST       (u32)(2000 * 1000)
+#define AD7758_NUM_WAVSEL      5
+#define AD7758_NUM_PHSEL       3
+#define AD7758_NUM_WAVESRC     (AD7758_NUM_WAVSEL * AD7758_NUM_PHSEL)
+
+#define AD7758_PHASE_A         0
+#define AD7758_PHASE_B         1
+#define AD7758_PHASE_C         2
+#define AD7758_CURRENT         0
+#define AD7758_VOLTAGE         1
+#define AD7758_ACT_PWR         2
+#define AD7758_REACT_PWR       3
+#define AD7758_APP_PWR         4
+#define AD7758_WT(p, w)                (((w) << 2) | (p))
 
 #define DRIVER_NAME            "ade7758"
 
+
 /**
  * struct ade7758_state - device instance specific data
  * @us:                        actual spi_device
- * @work_trigger_to_ring: bh for triggered event handling
- * @inter:             used to check if new interrupt has been triggered
- * @last_timestamp:    passing timestamp from th to bh of interrupt handler
- * @indio_dev:         industrial I/O device structure
  * @trig:              data ready trigger registered with iio
  * @tx:                        transmit buffer
  * @rx:                        receive buffer
  * @buf_lock:          mutex to protect tx and rx
  **/
 struct ade7758_state {
-       struct spi_device               *us;
-       struct work_struct              work_trigger_to_ring;
-       s64                             last_timestamp;
-       struct iio_dev                  *indio_dev;
-       struct iio_trigger              *trig;
-       u8                              *tx;
-       u8                              *rx;
-       struct mutex                    buf_lock;
+       struct spi_device       *us;
+       struct iio_trigger      *trig;
+       u8                      *tx;
+       u8                      *rx;
+       struct mutex            buf_lock;
+       u32                     available_scan_masks[AD7758_NUM_WAVESRC];
+       struct iio_chan_spec    *ade7758_ring_channels;
+       struct spi_transfer     ring_xfer[4];
+       struct spi_message      ring_msg;
+       /*
+        * DMA (thus cache coherency maintenance) requires the
+        * transfer buffers to live in their own cache lines.
+        */
+       unsigned char           rx_buf[8] ____cacheline_aligned;
+       unsigned char           tx_buf[8];
+
 };
 #ifdef CONFIG_IIO_RING_BUFFER
 /* At the moment triggers are only used for ring buffer
  * filling. This may change!
  */
 
-enum ade7758_scan {
-       ADE7758_SCAN_WFORM,
-};
-
 void ade7758_remove_trigger(struct iio_dev *indio_dev);
 int ade7758_probe_trigger(struct iio_dev *indio_dev);
 
@@ -134,6 +153,12 @@ void ade7758_unconfigure_ring(struct iio_dev *indio_dev);
 int ade7758_initialize_ring(struct iio_ring_buffer *ring);
 void ade7758_uninitialize_ring(struct iio_ring_buffer *ring);
 int ade7758_set_irq(struct device *dev, bool enable);
+
+int ade7758_spi_write_reg_8(struct device *dev,
+               u8 reg_address, u8 val);
+int ade7758_spi_read_reg_8(struct device *dev,
+               u8 reg_address, u8 *val);
+
 #else /* CONFIG_IIO_RING_BUFFER */
 
 static inline void ade7758_remove_trigger(struct iio_dev *indio_dev)
@@ -144,14 +169,6 @@ static inline int ade7758_probe_trigger(struct iio_dev *indio_dev)
        return 0;
 }
 
-static inline ssize_t
-ade7758_read_data_from_ring(struct device *dev,
-               struct device_attribute *attr,
-               char *buf)
-{
-       return 0;
-}
-
 static int ade7758_configure_ring(struct iio_dev *indio_dev)
 {
        return 0;
index b7634cb7aa4f37f34cdb8d240b12b4e90ecc6f36..299b95434e20b1de56613fc3a6bdf613682f4605 100644 (file)
@@ -1,9 +1,9 @@
 /*
- * ADE7758 Polyphase Multifunction Energy Metering IC Driver
+ * ADE7758 Poly Phase Multifunction Energy Metering IC driver
  *
- * Copyright 2010 Analog Devices Inc.
+ * Copyright 2010-2011 Analog Devices Inc.
  *
- * Licensed under the GPL-2 or later.
+ * Licensed under the GPL-2.
  */
 
 #include <linux/interrupt.h>
@@ -20,6 +20,7 @@
 
 #include "../iio.h"
 #include "../sysfs.h"
+#include "../ring_generic.h"
 #include "meter.h"
 #include "ade7758.h"
 
@@ -29,7 +30,7 @@ int ade7758_spi_write_reg_8(struct device *dev,
 {
        int ret;
        struct iio_dev *indio_dev = dev_get_drvdata(dev);
-       struct ade7758_state *st = iio_dev_get_devdata(indio_dev);
+       struct ade7758_state *st = iio_priv(indio_dev);
 
        mutex_lock(&st->buf_lock);
        st->tx[0] = ADE7758_WRITE_REG(reg_address);
@@ -48,7 +49,7 @@ static int ade7758_spi_write_reg_16(struct device *dev,
        int ret;
        struct spi_message msg;
        struct iio_dev *indio_dev = dev_get_drvdata(dev);
-       struct ade7758_state *st = iio_dev_get_devdata(indio_dev);
+       struct ade7758_state *st = iio_priv(indio_dev);
        struct spi_transfer xfers[] = {
                {
                        .tx_buf = st->tx,
@@ -77,7 +78,7 @@ static int ade7758_spi_write_reg_24(struct device *dev,
        int ret;
        struct spi_message msg;
        struct iio_dev *indio_dev = dev_get_drvdata(dev);
-       struct ade7758_state *st = iio_dev_get_devdata(indio_dev);
+       struct ade7758_state *st = iio_priv(indio_dev);
        struct spi_transfer xfers[] = {
                {
                        .tx_buf = st->tx,
@@ -100,20 +101,26 @@ static int ade7758_spi_write_reg_24(struct device *dev,
        return ret;
 }
 
-static int ade7758_spi_read_reg_8(struct device *dev,
+int ade7758_spi_read_reg_8(struct device *dev,
                u8 reg_address,
                u8 *val)
 {
        struct spi_message msg;
        struct iio_dev *indio_dev = dev_get_drvdata(dev);
-       struct ade7758_state *st = iio_dev_get_devdata(indio_dev);
+       struct ade7758_state *st = iio_priv(indio_dev);
        int ret;
        struct spi_transfer xfers[] = {
                {
                        .tx_buf = st->tx,
+                       .bits_per_word = 8,
+                       .len = 1,
+                       .delay_usecs = 4,
+               },
+               {
+                       .tx_buf = &st->tx[1],
                        .rx_buf = st->rx,
                        .bits_per_word = 8,
-                       .len = 2,
+                       .len = 1,
                },
        };
 
@@ -122,14 +129,15 @@ static int ade7758_spi_read_reg_8(struct device *dev,
        st->tx[1] = 0;
 
        spi_message_init(&msg);
-       spi_message_add_tail(xfers, &msg);
+       spi_message_add_tail(&xfers[0], &msg);
+       spi_message_add_tail(&xfers[1], &msg);
        ret = spi_sync(st->us, &msg);
        if (ret) {
                dev_err(&st->us->dev, "problem when reading 8 bit register 0x%02X",
                                reg_address);
                goto error_ret;
        }
-       *val = st->rx[1];
+       *val = st->rx[0];
 
 error_ret:
        mutex_unlock(&st->buf_lock);
@@ -142,31 +150,40 @@ static int ade7758_spi_read_reg_16(struct device *dev,
 {
        struct spi_message msg;
        struct iio_dev *indio_dev = dev_get_drvdata(dev);
-       struct ade7758_state *st = iio_dev_get_devdata(indio_dev);
+       struct ade7758_state *st = iio_priv(indio_dev);
        int ret;
        struct spi_transfer xfers[] = {
                {
                        .tx_buf = st->tx,
+                       .bits_per_word = 8,
+                       .len = 1,
+                       .delay_usecs = 4,
+               },
+               {
+                       .tx_buf = &st->tx[1],
                        .rx_buf = st->rx,
                        .bits_per_word = 8,
-                       .len = 3,
+                       .len = 2,
                },
        };
 
+
        mutex_lock(&st->buf_lock);
        st->tx[0] = ADE7758_READ_REG(reg_address);
        st->tx[1] = 0;
        st->tx[2] = 0;
 
        spi_message_init(&msg);
-       spi_message_add_tail(xfers, &msg);
+       spi_message_add_tail(&xfers[0], &msg);
+       spi_message_add_tail(&xfers[1], &msg);
        ret = spi_sync(st->us, &msg);
        if (ret) {
                dev_err(&st->us->dev, "problem when reading 16 bit register 0x%02X",
                                reg_address);
                goto error_ret;
        }
-       *val = (st->rx[1] << 8) | st->rx[2];
+
+       *val = (st->rx[0] << 8) | st->rx[1];
 
 error_ret:
        mutex_unlock(&st->buf_lock);
@@ -179,14 +196,20 @@ static int ade7758_spi_read_reg_24(struct device *dev,
 {
        struct spi_message msg;
        struct iio_dev *indio_dev = dev_get_drvdata(dev);
-       struct ade7758_state *st = iio_dev_get_devdata(indio_dev);
+       struct ade7758_state *st = iio_priv(indio_dev);
        int ret;
        struct spi_transfer xfers[] = {
                {
                        .tx_buf = st->tx,
+                       .bits_per_word = 8,
+                       .len = 1,
+                       .delay_usecs = 4,
+               },
+               {
+                       .tx_buf = &st->tx[1],
                        .rx_buf = st->rx,
                        .bits_per_word = 8,
-                       .len = 4,
+                       .len = 3,
                },
        };
 
@@ -197,14 +220,15 @@ static int ade7758_spi_read_reg_24(struct device *dev,
        st->tx[3] = 0;
 
        spi_message_init(&msg);
-       spi_message_add_tail(xfers, &msg);
+       spi_message_add_tail(&xfers[0], &msg);
+       spi_message_add_tail(&xfers[1], &msg);
        ret = spi_sync(st->us, &msg);
        if (ret) {
                dev_err(&st->us->dev, "problem when reading 24 bit register 0x%02X",
                                reg_address);
                goto error_ret;
        }
-       *val = (st->rx[1] << 16) | (st->rx[2] << 8) | st->rx[3];
+       *val = (st->rx[0] << 16) | (st->rx[1] << 8) | st->rx[2];
 
 error_ret:
        mutex_unlock(&st->buf_lock);
@@ -292,7 +316,7 @@ error_ret:
        return ret ? ret : len;
 }
 
-int ade7758_reset(struct device *dev)
+static int ade7758_reset(struct device *dev)
 {
        int ret;
        u8 val;
@@ -319,7 +343,7 @@ static ssize_t ade7758_write_reset(struct device *dev,
        case 'Y':
                return ade7758_reset(dev);
        }
-       return -1;
+       return len;
 }
 
 static IIO_DEV_ATTR_VPEAK(S_IWUSR | S_IRUGO,
@@ -461,13 +485,14 @@ static int ade7758_stop_device(struct device *dev)
        return ret;
 }
 
-static int ade7758_initial_setup(struct ade7758_state *st)
+static int ade7758_initial_setup(struct iio_dev *indio_dev)
 {
+       struct ade7758_state *st = iio_priv(indio_dev);
+       struct device *dev = &indio_dev->dev;
        int ret;
-       struct device *dev = &st->indio_dev->dev;
 
        /* use low spi speed for init */
-       st->us->mode = SPI_MODE_3;
+       st->us->mode = SPI_MODE_1;
        spi_setup(st->us);
 
        /* Disable IRQ */
@@ -510,7 +535,6 @@ static ssize_t ade7758_write_frequency(struct device *dev,
                size_t len)
 {
        struct iio_dev *indio_dev = dev_get_drvdata(dev);
-       struct ade7758_state *st = iio_dev_get_devdata(indio_dev);
        unsigned long val;
        int ret;
        u8 reg, t;
@@ -521,14 +545,23 @@ static ssize_t ade7758_write_frequency(struct device *dev,
 
        mutex_lock(&indio_dev->mlock);
 
-       t = (26040 / val);
-       if (t > 0)
-               t >>= 1;
-
-       if (t > 1)
-               st->us->max_speed_hz = ADE7758_SPI_SLOW;
-       else
-               st->us->max_speed_hz = ADE7758_SPI_FAST;
+       switch (val) {
+       case 26040:
+               t = 0;
+               break;
+       case 13020:
+               t = 1;
+               break;
+       case 6510:
+               t = 2;
+               break;
+       case 3255:
+               t = 3;
+               break;
+       default:
+               ret = -EINVAL;
+               goto out;
+       }
 
        ret = ade7758_spi_read_reg_8(dev,
                        ADE7758_WAVMODE,
@@ -549,63 +582,6 @@ out:
        return ret ? ret : len;
 }
 
-static ssize_t ade7758_read_waveform_type(struct device *dev,
-               struct device_attribute *attr,
-               char *buf)
-{
-       int ret, len = 0;
-       u8 t;
-       ret = ade7758_spi_read_reg_8(dev,
-                       ADE7758_WAVMODE,
-                       &t);
-       if (ret)
-               return ret;
-
-       t = (t >> 2) & 0x7;
-
-       len = sprintf(buf, "%d\n", t);
-
-       return len;
-}
-
-static ssize_t ade7758_write_waveform_type(struct device *dev,
-               struct device_attribute *attr,
-               const char *buf,
-               size_t len)
-{
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
-       unsigned long val;
-       int ret;
-       u8 reg;
-
-       ret = strict_strtol(buf, 10, &val);
-       if (ret)
-               return ret;
-
-       if (val > 4)
-               return -EINVAL;
-
-       mutex_lock(&indio_dev->mlock);
-
-       ret = ade7758_spi_read_reg_8(dev,
-                       ADE7758_WAVMODE,
-                       &reg);
-       if (ret)
-               goto out;
-
-       reg &= ~(7 << 2);
-       reg |= val << 2;
-
-       ret = ade7758_spi_write_reg_8(dev,
-                       ADE7758_WAVMODE,
-                       reg);
-
-out:
-       mutex_unlock(&indio_dev->mlock);
-
-       return ret ? ret : len;
-}
-
 static IIO_DEV_ATTR_TEMP_RAW(ade7758_read_8bit);
 static IIO_CONST_ATTR(temp_offset, "129 C");
 static IIO_CONST_ATTR(temp_scale, "4 C");
@@ -633,42 +609,17 @@ static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO,
                ade7758_read_frequency,
                ade7758_write_frequency);
 
-/**
- * IIO_DEV_ATTR_WAVEFORM_TYPE - set the type of waveform.
- * @_mode: sysfs file mode/permissions
- * @_show: output method for the attribute
- * @_store: input method for the attribute
- **/
-#define IIO_DEV_ATTR_WAVEFORM_TYPE(_mode, _show, _store)                       \
-       IIO_DEVICE_ATTR(waveform_type, _mode, _show, _store, 0)
-
-static IIO_DEV_ATTR_WAVEFORM_TYPE(S_IWUSR | S_IRUGO,
-               ade7758_read_waveform_type,
-               ade7758_write_waveform_type);
-
 static IIO_DEV_ATTR_RESET(ade7758_write_reset);
 
-static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("26000 13000 65000 33000");
-
-static IIO_CONST_ATTR(name, "ade7758");
-
-static struct attribute *ade7758_event_attributes[] = {
-       NULL
-};
-
-static struct attribute_group ade7758_event_attribute_group = {
-       .attrs = ade7758_event_attributes,
-};
+static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("26040 13020 6510 3255");
 
 static struct attribute *ade7758_attributes[] = {
        &iio_dev_attr_temp_raw.dev_attr.attr,
        &iio_const_attr_temp_offset.dev_attr.attr,
        &iio_const_attr_temp_scale.dev_attr.attr,
        &iio_dev_attr_sampling_frequency.dev_attr.attr,
-       &iio_dev_attr_waveform_type.dev_attr.attr,
        &iio_const_attr_sampling_frequency_available.dev_attr.attr,
        &iio_dev_attr_reset.dev_attr.attr,
-       &iio_const_attr_name.dev_attr.attr,
        &iio_dev_attr_awatthr.dev_attr.attr,
        &iio_dev_attr_bwatthr.dev_attr.attr,
        &iio_dev_attr_cwatthr.dev_attr.attr,
@@ -710,24 +661,95 @@ static const struct attribute_group ade7758_attribute_group = {
        .attrs = ade7758_attributes,
 };
 
+static struct iio_chan_spec ade7758_channels[] = {
+       IIO_CHAN(IIO_IN, 0, 1, 0, "raw", 0, 0,
+               (1 << IIO_CHAN_INFO_SCALE_SHARED),
+               AD7758_WT(AD7758_PHASE_A, AD7758_VOLTAGE),
+               0, IIO_ST('s', 24, 32, 0), 0),
+       IIO_CHAN(IIO_CURRENT, 0, 1, 0, "raw", 0, 0,
+               (1 << IIO_CHAN_INFO_SCALE_SHARED),
+               AD7758_WT(AD7758_PHASE_A, AD7758_CURRENT),
+               1, IIO_ST('s', 24, 32, 0), 0),
+       IIO_CHAN(IIO_POWER, 0, 1, 0, "apparent_raw", 0, 0,
+               (1 << IIO_CHAN_INFO_SCALE_SHARED),
+               AD7758_WT(AD7758_PHASE_A, AD7758_APP_PWR),
+               2, IIO_ST('s', 24, 32, 0), 0),
+       IIO_CHAN(IIO_POWER, 0, 1, 0, "active_raw", 0, 0,
+               (1 << IIO_CHAN_INFO_SCALE_SHARED),
+               AD7758_WT(AD7758_PHASE_A, AD7758_ACT_PWR),
+               3, IIO_ST('s', 24, 32, 0), 0),
+       IIO_CHAN(IIO_POWER, 0, 1, 0, "reactive_raw", 0, 0,
+               (1 << IIO_CHAN_INFO_SCALE_SHARED),
+               AD7758_WT(AD7758_PHASE_A, AD7758_REACT_PWR),
+               4, IIO_ST('s', 24, 32, 0), 0),
+       IIO_CHAN(IIO_IN, 0, 1, 0, "raw", 1, 0,
+               (1 << IIO_CHAN_INFO_SCALE_SHARED),
+               AD7758_WT(AD7758_PHASE_B, AD7758_VOLTAGE),
+               5, IIO_ST('s', 24, 32, 0), 0),
+       IIO_CHAN(IIO_CURRENT, 0, 1, 0, "raw", 1, 0,
+               (1 << IIO_CHAN_INFO_SCALE_SHARED),
+               AD7758_WT(AD7758_PHASE_B, AD7758_CURRENT),
+               6, IIO_ST('s', 24, 32, 0), 0),
+       IIO_CHAN(IIO_POWER, 0, 1, 0, "apparent_raw", 1, 0,
+               (1 << IIO_CHAN_INFO_SCALE_SHARED),
+               AD7758_WT(AD7758_PHASE_B, AD7758_APP_PWR),
+               7, IIO_ST('s', 24, 32, 0), 0),
+       IIO_CHAN(IIO_POWER, 0, 1, 0, "active_raw", 1, 0,
+               (1 << IIO_CHAN_INFO_SCALE_SHARED),
+               AD7758_WT(AD7758_PHASE_B, AD7758_ACT_PWR),
+               8, IIO_ST('s', 24, 32, 0), 0),
+       IIO_CHAN(IIO_POWER, 0, 1, 0, "reactive_raw", 1, 0,
+               (1 << IIO_CHAN_INFO_SCALE_SHARED),
+               AD7758_WT(AD7758_PHASE_B, AD7758_REACT_PWR),
+               9, IIO_ST('s', 24, 32, 0), 0),
+       IIO_CHAN(IIO_IN, 0, 1, 0, "raw", 2, 0,
+               (1 << IIO_CHAN_INFO_SCALE_SHARED),
+               AD7758_WT(AD7758_PHASE_C, AD7758_VOLTAGE),
+               10, IIO_ST('s', 24, 32, 0), 0),
+       IIO_CHAN(IIO_CURRENT, 0, 1, 0, "raw", 2, 0,
+               (1 << IIO_CHAN_INFO_SCALE_SHARED),
+               AD7758_WT(AD7758_PHASE_C, AD7758_CURRENT),
+               11, IIO_ST('s', 24, 32, 0), 0),
+       IIO_CHAN(IIO_POWER, 0, 1, 0, "apparent_raw", 2, 0,
+               (1 << IIO_CHAN_INFO_SCALE_SHARED),
+               AD7758_WT(AD7758_PHASE_C, AD7758_APP_PWR),
+               12, IIO_ST('s', 24, 32, 0), 0),
+       IIO_CHAN(IIO_POWER, 0, 1, 0, "active_raw", 2, 0,
+               (1 << IIO_CHAN_INFO_SCALE_SHARED),
+               AD7758_WT(AD7758_PHASE_C, AD7758_ACT_PWR),
+               13, IIO_ST('s', 24, 32, 0), 0),
+       IIO_CHAN(IIO_POWER, 0, 1, 0, "reactive_raw", 2, 0,
+               (1 << IIO_CHAN_INFO_SCALE_SHARED),
+               AD7758_WT(AD7758_PHASE_C, AD7758_REACT_PWR),
+               14, IIO_ST('s', 24, 32, 0), 0),
+       IIO_CHAN_SOFT_TIMESTAMP(15),
+};
 
+static const struct iio_info ade7758_info = {
+       .attrs = &ade7758_attribute_group,
+       .driver_module = THIS_MODULE,
+};
 
 static int __devinit ade7758_probe(struct spi_device *spi)
 {
-       int ret, regdone = 0;
-       struct ade7758_state *st = kzalloc(sizeof *st, GFP_KERNEL);
-       if (!st) {
-               ret =  -ENOMEM;
+       int i, ret, regdone = 0;
+       struct ade7758_state *st;
+       struct iio_dev *indio_dev = iio_allocate_device(sizeof(*st));
+
+       if (indio_dev == NULL) {
+               ret = -ENOMEM;
                goto error_ret;
        }
+
+       st = iio_priv(indio_dev);
        /* this is only used for removal purposes */
-       spi_set_drvdata(spi, st);
+       spi_set_drvdata(spi, indio_dev);
 
        /* Allocate the comms buffers */
        st->rx = kzalloc(sizeof(*st->rx)*ADE7758_MAX_RX, GFP_KERNEL);
        if (st->rx == NULL) {
                ret = -ENOMEM;
-               goto error_free_st;
+               goto error_free_dev;
        }
        st->tx = kzalloc(sizeof(*st->tx)*ADE7758_MAX_TX, GFP_KERNEL);
        if (st->tx == NULL) {
@@ -735,111 +757,96 @@ static int __devinit ade7758_probe(struct spi_device *spi)
                goto error_free_rx;
        }
        st->us = spi;
+       st->ade7758_ring_channels = &ade7758_channels[0];
        mutex_init(&st->buf_lock);
-       /* setup the industrialio driver allocated elements */
-       st->indio_dev = iio_allocate_device();
-       if (st->indio_dev == NULL) {
-               ret = -ENOMEM;
-               goto error_free_tx;
-       }
 
-       st->indio_dev->dev.parent = &spi->dev;
-       st->indio_dev->num_interrupt_lines = 1;
-       st->indio_dev->event_attrs = &ade7758_event_attribute_group;
-       st->indio_dev->attrs = &ade7758_attribute_group;
-       st->indio_dev->dev_data = (void *)(st);
-       st->indio_dev->driver_module = THIS_MODULE;
-       st->indio_dev->modes = INDIO_DIRECT_MODE;
+       indio_dev->name = spi->dev.driver->name;
+       indio_dev->dev.parent = &spi->dev;
+       indio_dev->info = &ade7758_info;
+       indio_dev->modes = INDIO_DIRECT_MODE;
+
+       for (i = 0; i < AD7758_NUM_WAVESRC; i++)
+               st->available_scan_masks[i] = 1 << i;
+
+       indio_dev->available_scan_masks = st->available_scan_masks;
 
-       ret = ade7758_configure_ring(st->indio_dev);
+       ret = ade7758_configure_ring(indio_dev);
        if (ret)
-               goto error_free_dev;
+               goto error_free_tx;
 
-       ret = iio_device_register(st->indio_dev);
+       ret = iio_device_register(indio_dev);
        if (ret)
                goto error_unreg_ring_funcs;
        regdone = 1;
 
-       ret = ade7758_initialize_ring(st->indio_dev->ring);
+       ret = iio_ring_buffer_register_ex(indio_dev->ring, 0,
+                                         &ade7758_channels[0],
+                                         ARRAY_SIZE(ade7758_channels));
        if (ret) {
-               printk(KERN_ERR "failed to initialize the ring\n");
+               dev_err(&spi->dev, "failed to initialize the ring\n");
                goto error_unreg_ring_funcs;
        }
 
-       if (spi->irq) {
-               ret = iio_register_interrupt_line(spi->irq,
-                               st->indio_dev,
-                               0,
-                               IRQF_TRIGGER_FALLING,
-                               "ade7758");
-               if (ret)
-                       goto error_uninitialize_ring;
+       /* Get the device into a sane initial state */
+       ret = ade7758_initial_setup(indio_dev);
+       if (ret)
+               goto error_uninitialize_ring;
 
-               ret = ade7758_probe_trigger(st->indio_dev);
+       if (spi->irq) {
+               ret = ade7758_probe_trigger(indio_dev);
                if (ret)
-                       goto error_unregister_line;
+                       goto error_remove_trigger;
        }
 
-       /* Get the device into a sane initial state */
-       ret = ade7758_initial_setup(st);
-       if (ret)
-               goto error_remove_trigger;
        return 0;
 
 error_remove_trigger:
-       if (st->indio_dev->modes & INDIO_RING_TRIGGERED)
-               ade7758_remove_trigger(st->indio_dev);
-error_unregister_line:
-       if (st->indio_dev->modes & INDIO_RING_TRIGGERED)
-               iio_unregister_interrupt_line(st->indio_dev, 0);
+       if (indio_dev->modes & INDIO_RING_TRIGGERED)
+               ade7758_remove_trigger(indio_dev);
 error_uninitialize_ring:
-       ade7758_uninitialize_ring(st->indio_dev->ring);
+       ade7758_uninitialize_ring(indio_dev->ring);
 error_unreg_ring_funcs:
-       ade7758_unconfigure_ring(st->indio_dev);
-error_free_dev:
-       if (regdone)
-               iio_device_unregister(st->indio_dev);
-       else
-               iio_free_device(st->indio_dev);
+       ade7758_unconfigure_ring(indio_dev);
 error_free_tx:
        kfree(st->tx);
 error_free_rx:
        kfree(st->rx);
-error_free_st:
-       kfree(st);
+error_free_dev:
+       if (regdone)
+               iio_device_unregister(indio_dev);
+       else
+               iio_free_device(indio_dev);
 error_ret:
        return ret;
 }
 
 static int ade7758_remove(struct spi_device *spi)
 {
+       struct iio_dev *indio_dev = spi_get_drvdata(spi);
+       struct ade7758_state *st = iio_priv(indio_dev);
        int ret;
-       struct ade7758_state *st = spi_get_drvdata(spi);
-       struct iio_dev *indio_dev = st->indio_dev;
 
-       ret = ade7758_stop_device(&(indio_dev->dev));
+       ret = ade7758_stop_device(&indio_dev->dev);
        if (ret)
                goto err_ret;
 
-       flush_scheduled_work();
-
        ade7758_remove_trigger(indio_dev);
-       if (spi->irq && gpio_is_valid(irq_to_gpio(spi->irq)) > 0)
-               iio_unregister_interrupt_line(indio_dev, 0);
-
        ade7758_uninitialize_ring(indio_dev->ring);
-       iio_device_unregister(indio_dev);
        ade7758_unconfigure_ring(indio_dev);
        kfree(st->tx);
        kfree(st->rx);
-       kfree(st);
+       iio_device_unregister(indio_dev);
 
        return 0;
-
 err_ret:
        return ret;
 }
 
+static const struct spi_device_id ade7758_id[] = {
+       {"ade7758", 0},
+       {}
+};
+
 static struct spi_driver ade7758_driver = {
        .driver = {
                .name = "ade7758",
@@ -847,6 +854,7 @@ static struct spi_driver ade7758_driver = {
        },
        .probe = ade7758_probe,
        .remove = __devexit_p(ade7758_remove),
+       .id_table = ade7758_id,
 };
 
 static __init int ade7758_init(void)
index 274b4a07808c2e97e260a2c5c0eaff8a39ff5922..b89b7f882e84106453f0dd933b80a4011551fc2f 100644 (file)
@@ -1,3 +1,10 @@
+/*
+ * ADE7758 Poly Phase Multifunction Energy Metering IC driver
+ *
+ * Copyright 2010-2011 Analog Devices Inc.
+ *
+ * Licensed under the GPL-2.
+ */
 #include <linux/interrupt.h>
 #include <linux/irq.h>
 #include <linux/gpio.h>
@@ -9,6 +16,7 @@
 #include <linux/slab.h>
 #include <linux/sysfs.h>
 #include <linux/list.h>
+#include <asm/unaligned.h>
 
 #include "../iio.h"
 #include "../sysfs.h"
 #include "ade7758.h"
 
 /**
- * combine_8_to_32() utility function to munge to u8s into u32
+ * ade7758_spi_read_burst() - read data registers
+ * @dev: device associated with child of actual device (iio_dev or iio_trig)
  **/
-static inline u32 combine_8_to_32(u8 lower, u8 mid, u8 upper)
+static int ade7758_spi_read_burst(struct device *dev)
 {
-       u32 _lower = lower;
-       u32 _mid = mid;
-       u32 _upper = upper;
-
-       return _lower | (_mid << 8) | (_upper << 16);
-}
-
-static IIO_SCAN_EL_C(wform, ADE7758_SCAN_WFORM, ADE7758_WFORM, NULL);
-static IIO_CONST_ATTR_SCAN_EL_TYPE(wform, s, 24, 32);
-static IIO_SCAN_EL_TIMESTAMP(1);
-static IIO_CONST_ATTR_SCAN_EL_TYPE(timestamp, s, 64, 64);
-
-static struct attribute *ade7758_scan_el_attrs[] = {
-       &iio_scan_el_wform.dev_attr.attr,
-       &iio_const_attr_wform_index.dev_attr.attr,
-       &iio_const_attr_wform_type.dev_attr.attr,
-       &iio_scan_el_timestamp.dev_attr.attr,
-       &iio_const_attr_timestamp_index.dev_attr.attr,
-       &iio_const_attr_timestamp_type.dev_attr.attr,
-       NULL,
-};
+       struct iio_dev *indio_dev = dev_get_drvdata(dev);
+       struct ade7758_state *st = iio_priv(indio_dev);
+       int ret;
 
-static struct attribute_group ade7758_scan_el_group = {
-       .attrs = ade7758_scan_el_attrs,
-       .name = "scan_elements",
-};
+       ret = spi_sync(st->us, &st->ring_msg);
+       if (ret)
+               dev_err(&st->us->dev, "problem when reading WFORM value\n");
 
-/**
- * ade7758_poll_func_th() top half interrupt handler called by trigger
- * @private_data:      iio_dev
- **/
-static void ade7758_poll_func_th(struct iio_dev *indio_dev, s64 time)
-{
-       struct ade7758_state *st = iio_dev_get_devdata(indio_dev);
-       st->last_timestamp = time;
-       schedule_work(&st->work_trigger_to_ring);
-       /* Indicate that this interrupt is being handled */
-
-       /* Technically this is trigger related, but without this
-        * handler running there is currently no way for the interrupt
-        * to clear.
-        */
+       return ret;
 }
 
-/**
- * ade7758_spi_read_burst() - read all data registers
- * @dev: device associated with child of actual device (iio_dev or iio_trig)
- * @rx: somewhere to pass back the value read (min size is 24 bytes)
- **/
-static int ade7758_spi_read_burst(struct device *dev, u8 *rx)
+static int ade7758_write_waveform_type(struct device *dev, unsigned type)
 {
-       struct spi_message msg;
-       struct iio_dev *indio_dev = dev_get_drvdata(dev);
-       struct ade7758_state *st = iio_dev_get_devdata(indio_dev);
        int ret;
+       u8 reg;
 
-       struct spi_transfer xfers[] = {
-               {
-                       .tx_buf = st->tx,
-                       .rx_buf = rx,
-                       .bits_per_word = 8,
-                       .len = 4,
-               }, {
-                       .tx_buf = st->tx + 4,
-                       .rx_buf = rx,
-                       .bits_per_word = 8,
-                       .len = 4,
-               },
-       };
-
-       mutex_lock(&st->buf_lock);
-       st->tx[0] = ADE7758_READ_REG(ADE7758_RSTATUS);
-       st->tx[1] = 0;
-       st->tx[2] = 0;
-       st->tx[3] = 0;
-       st->tx[4] = ADE7758_READ_REG(ADE7758_WFORM);
-       st->tx[5] = 0;
-       st->tx[6] = 0;
-       st->tx[7] = 0;
-
-       spi_message_init(&msg);
-       spi_message_add_tail(&xfers[0], &msg);
-       spi_message_add_tail(&xfers[1], &msg);
-       ret = spi_sync(st->us, &msg);
+       ret = ade7758_spi_read_reg_8(dev,
+                       ADE7758_WAVMODE,
+                       &reg);
        if (ret)
-               dev_err(&st->us->dev, "problem when reading WFORM value\n");
+               goto out;
 
-       mutex_unlock(&st->buf_lock);
+       reg &= ~0x1F;
+       reg |= type & 0x1F;
 
+       ret = ade7758_spi_write_reg_8(dev,
+                       ADE7758_WAVMODE,
+                       reg);
+out:
        return ret;
 }
 
 /* Whilst this makes a lot of calls to iio_sw_ring functions - it is to device
  * specific to be rolled into the core.
  */
-static void ade7758_trigger_bh_to_ring(struct work_struct *work_s)
+static irqreturn_t ade7758_trigger_handler(int irq, void *p)
 {
-       struct ade7758_state *st
-               = container_of(work_s, struct ade7758_state,
-                              work_trigger_to_ring);
-       struct iio_ring_buffer *ring = st->indio_dev->ring;
-
-       int i = 0;
-       s32 *data;
-       size_t datasize = ring->access.get_bytes_per_datum(ring);
-
-       data = kmalloc(datasize, GFP_KERNEL);
-       if (data == NULL) {
-               dev_err(&st->us->dev, "memory alloc failed in ring bh");
-               return;
-       }
+       struct iio_poll_func *pf = p;
+       struct iio_dev *indio_dev = pf->private_data;
+       struct iio_ring_buffer *ring = indio_dev->ring;
+       struct ade7758_state *st = iio_priv(indio_dev);
+       s64 dat64[2];
+       u32 *dat32 = (u32 *)dat64;
 
        if (ring->scan_count)
-               if (ade7758_spi_read_burst(&st->indio_dev->dev, st->rx) >= 0)
-                       for (; i < ring->scan_count; i++)
-                               data[i] = combine_8_to_32(st->rx[i*2+2],
-                                               st->rx[i*2+1],
-                                               st->rx[i*2]);
+               if (ade7758_spi_read_burst(&indio_dev->dev) >= 0)
+                       *dat32 = get_unaligned_be32(&st->rx_buf[5]) & 0xFFFFFF;
 
        /* Guaranteed to be aligned with 8 byte boundary */
        if (ring->scan_timestamp)
-               *((s64 *)
-               (((u32)data + 4 * ring->scan_count + 4) & ~0x7)) =
-                       st->last_timestamp;
+               dat64[1] = pf->timestamp;
+
+       ring->access->store_to(ring, (u8 *)dat64, pf->timestamp);
+
+       iio_trigger_notify_done(indio_dev->trig);
+
+       return IRQ_HANDLED;
+}
+
+/**
+ * ade7758_ring_preenable() setup the parameters of the ring before enabling
+ *
+ * The complex nature of the setting of the nuber of bytes per datum is due
+ * to this driver currently ensuring that the timestamp is stored at an 8
+ * byte boundary.
+ **/
+static int ade7758_ring_preenable(struct iio_dev *indio_dev)
+{
+       struct ade7758_state *st = iio_priv(indio_dev);
+       struct iio_ring_buffer *ring = indio_dev->ring;
+       size_t d_size;
+       unsigned channel;
+
+       if (!ring->scan_count)
+               return -EINVAL;
 
-       ring->access.store_to(ring,
-                             (u8 *)data,
-                             st->last_timestamp);
+       channel = __ffs(ring->scan_mask);
 
-       iio_trigger_notify_done(st->indio_dev->trig);
-       kfree(data);
+       d_size = st->ade7758_ring_channels[channel].scan_type.storagebits / 8;
 
-       return;
+       if (ring->scan_timestamp) {
+               d_size += sizeof(s64);
+
+               if (d_size % sizeof(s64))
+                       d_size += sizeof(s64) - (d_size % sizeof(s64));
+       }
+
+       if (indio_dev->ring->access->set_bytes_per_datum)
+               indio_dev->ring->access->set_bytes_per_datum(indio_dev->ring,
+                                                           d_size);
+
+       ade7758_write_waveform_type(&indio_dev->dev,
+               st->ade7758_ring_channels[channel].address);
+
+       return 0;
 }
 
+static const struct iio_ring_setup_ops ade7758_ring_setup_ops = {
+       .preenable = &ade7758_ring_preenable,
+       .postenable = &iio_triggered_ring_postenable,
+       .predisable = &iio_triggered_ring_predisable,
+};
+
 void ade7758_unconfigure_ring(struct iio_dev *indio_dev)
 {
-       kfree(indio_dev->pollfunc);
+       /* ensure that the trigger has been detached */
+       if (indio_dev->trig) {
+               iio_put_trigger(indio_dev->trig);
+               iio_trigger_dettach_poll_func(indio_dev->trig,
+                                             indio_dev->pollfunc);
+       }
+       iio_dealloc_pollfunc(indio_dev->pollfunc);
        iio_sw_rb_free(indio_dev->ring);
 }
 
 int ade7758_configure_ring(struct iio_dev *indio_dev)
 {
+       struct ade7758_state *st = iio_priv(indio_dev);
        int ret = 0;
-       struct ade7758_state *st = indio_dev->dev_data;
-       struct iio_ring_buffer *ring;
-       INIT_WORK(&st->work_trigger_to_ring, ade7758_trigger_bh_to_ring);
 
-       ring = iio_sw_rb_allocate(indio_dev);
-       if (!ring) {
+       indio_dev->ring = iio_sw_rb_allocate(indio_dev);
+       if (!indio_dev->ring) {
                ret = -ENOMEM;
                return ret;
        }
-       indio_dev->ring = ring;
+
        /* Effectively select the ring buffer implementation */
-       iio_ring_sw_register_funcs(&ring->access);
-       ring->bpe = 4;
-       ring->scan_el_attrs = &ade7758_scan_el_group;
-       ring->scan_timestamp = true;
-       ring->preenable = &iio_sw_ring_preenable;
-       ring->postenable = &iio_triggered_ring_postenable;
-       ring->predisable = &iio_triggered_ring_predisable;
-       ring->owner = THIS_MODULE;
-
-       /* Set default scan mode */
-       iio_scan_mask_set(ring, iio_scan_el_wform.number);
-
-       ret = iio_alloc_pollfunc(indio_dev, NULL, &ade7758_poll_func_th);
-       if (ret)
+       indio_dev->ring->access = &ring_sw_access_funcs;
+       indio_dev->ring->setup_ops = &ade7758_ring_setup_ops;
+       indio_dev->ring->owner = THIS_MODULE;
+
+       indio_dev->pollfunc = iio_alloc_pollfunc(&iio_pollfunc_store_time,
+                                                &ade7758_trigger_handler,
+                                                0,
+                                                indio_dev,
+                                                "ade7759_consumer%d",
+                                                indio_dev->id);
+       if (indio_dev->pollfunc == NULL) {
+               ret = -ENOMEM;
                goto error_iio_sw_rb_free;
+       }
 
        indio_dev->modes |= INDIO_RING_TRIGGERED;
+
+       st->tx_buf[0] = ADE7758_READ_REG(ADE7758_RSTATUS);
+       st->tx_buf[1] = 0;
+       st->tx_buf[2] = 0;
+       st->tx_buf[3] = 0;
+       st->tx_buf[4] = ADE7758_READ_REG(ADE7758_WFORM);
+       st->tx_buf[5] = 0;
+       st->tx_buf[6] = 0;
+       st->tx_buf[7] = 0;
+
+       /* build spi ring message */
+       st->ring_xfer[0].tx_buf = &st->tx_buf[0];
+       st->ring_xfer[0].len = 1;
+       st->ring_xfer[0].bits_per_word = 8;
+       st->ring_xfer[0].delay_usecs = 4;
+       st->ring_xfer[1].rx_buf = &st->rx_buf[1];
+       st->ring_xfer[1].len = 3;
+       st->ring_xfer[1].bits_per_word = 8;
+       st->ring_xfer[1].cs_change = 1;
+
+       st->ring_xfer[2].tx_buf = &st->tx_buf[4];
+       st->ring_xfer[2].len = 1;
+       st->ring_xfer[2].bits_per_word = 8;
+       st->ring_xfer[2].delay_usecs = 1;
+       st->ring_xfer[3].rx_buf = &st->rx_buf[5];
+       st->ring_xfer[3].len = 3;
+       st->ring_xfer[3].bits_per_word = 8;
+
+       spi_message_init(&st->ring_msg);
+       spi_message_add_tail(&st->ring_xfer[0], &st->ring_msg);
+       spi_message_add_tail(&st->ring_xfer[1], &st->ring_msg);
+       spi_message_add_tail(&st->ring_xfer[2], &st->ring_msg);
+       spi_message_add_tail(&st->ring_xfer[3], &st->ring_msg);
+
        return 0;
 
 error_iio_sw_rb_free:
@@ -201,11 +215,6 @@ error_iio_sw_rb_free:
        return ret;
 }
 
-int ade7758_initialize_ring(struct iio_ring_buffer *ring)
-{
-       return iio_ring_buffer_register(ring, 0);
-}
-
 void ade7758_uninitialize_ring(struct iio_ring_buffer *ring)
 {
        iio_ring_buffer_unregister(ring);
index 60abca0c28ffef820e73033789c65e3cf12e0ef3..a5c3248151ed6e2fafd2eaf91c53d0b6fa3d7ddb 100644 (file)
@@ -1,3 +1,11 @@
+/*
+ * ADE7758 Poly Phase Multifunction Energy Metering IC driver
+ *
+ * Copyright 2010-2011 Analog Devices Inc.
+ *
+ * Licensed under the GPL-2.
+ */
+
 #include <linux/interrupt.h>
 #include <linux/irq.h>
 #include <linux/mutex.h>
 /**
  * ade7758_data_rdy_trig_poll() the event handler for the data rdy trig
  **/
-static int ade7758_data_rdy_trig_poll(struct iio_dev *dev_info,
-                                      int index,
-                                      s64 timestamp,
-                                      int no_test)
+static irqreturn_t ade7758_data_rdy_trig_poll(int irq, void *private)
 {
-       struct ade7758_state *st = iio_dev_get_devdata(dev_info);
-       struct iio_trigger *trig = st->trig;
-
-       iio_trigger_poll(trig, timestamp);
+       disable_irq_nosync(irq);
+       iio_trigger_poll(private, iio_get_time_ns());
 
        return IRQ_HANDLED;
 }
 
-IIO_EVENT_SH(data_rdy_trig, &ade7758_data_rdy_trig_poll);
-
-static DEVICE_ATTR(name, S_IRUGO, iio_trigger_read_name, NULL);
-
-static struct attribute *ade7758_trigger_attrs[] = {
-       &dev_attr_name.attr,
-       NULL,
-};
-
-static const struct attribute_group ade7758_trigger_attr_group = {
-       .attrs = ade7758_trigger_attrs,
-};
-
 /**
  * ade7758_data_rdy_trigger_set_state() set datardy interrupt state
  **/
 static int ade7758_data_rdy_trigger_set_state(struct iio_trigger *trig,
                                                bool state)
 {
-       struct ade7758_state *st = trig->private_data;
-       struct iio_dev *indio_dev = st->indio_dev;
-       int ret = 0;
+       struct iio_dev *indio_dev = trig->private_data;
 
        dev_dbg(&indio_dev->dev, "%s (%d)\n", __func__, state);
-       ret = ade7758_set_irq(&st->indio_dev->dev, state);
-       if (state == false) {
-               iio_remove_event_from_list(&iio_event_data_rdy_trig,
-                                          &indio_dev->interrupts[0]
-                                          ->ev_list);
-               /* possible quirk with handler currently worked around
-                  by ensuring the work queue is empty */
-               flush_scheduled_work();
-       } else {
-               iio_add_event_to_list(&iio_event_data_rdy_trig,
-                                     &indio_dev->interrupts[0]->ev_list);
-       }
-       return ret;
+       return ade7758_set_irq(&indio_dev->dev, state);
 }
 
 /**
@@ -73,7 +49,9 @@ static int ade7758_data_rdy_trigger_set_state(struct iio_trigger *trig,
  **/
 static int ade7758_trig_try_reen(struct iio_trigger *trig)
 {
-       struct ade7758_state *st = trig->private_data;
+       struct iio_dev *indio_dev = trig->private_data;
+       struct ade7758_state *st = iio_priv(indio_dev);
+
        enable_irq(st->us->irq);
        /* irq reenabled so success! */
        return 0;
@@ -81,45 +59,52 @@ static int ade7758_trig_try_reen(struct iio_trigger *trig)
 
 int ade7758_probe_trigger(struct iio_dev *indio_dev)
 {
+       struct ade7758_state *st = iio_priv(indio_dev);
        int ret;
-       struct ade7758_state *st = indio_dev->dev_data;
 
-       st->trig = iio_allocate_trigger();
-       st->trig->name = kasprintf(GFP_KERNEL,
-                               "ade7758-dev%d",
-                               indio_dev->id);
-       if (!st->trig->name) {
+       st->trig = iio_allocate_trigger("%s-dev%d",
+                                       spi_get_device_id(st->us)->name,
+                                       indio_dev->id);
+       if (st->trig == NULL) {
                ret = -ENOMEM;
-               goto error_free_trig;
+               goto error_ret;
        }
+
+       ret = request_irq(st->us->irq,
+                         ade7758_data_rdy_trig_poll,
+                         IRQF_TRIGGER_LOW,
+                         spi_get_device_id(st->us)->name,
+                         st->trig);
+       if (ret)
+               goto error_free_trig;
+
        st->trig->dev.parent = &st->us->dev;
        st->trig->owner = THIS_MODULE;
-       st->trig->private_data = st;
+       st->trig->private_data = indio_dev;
        st->trig->set_trigger_state = &ade7758_data_rdy_trigger_set_state;
        st->trig->try_reenable = &ade7758_trig_try_reen;
-       st->trig->control_attrs = &ade7758_trigger_attr_group;
        ret = iio_trigger_register(st->trig);
 
        /* select default trigger */
        indio_dev->trig = st->trig;
        if (ret)
-               goto error_free_trig_name;
+               goto error_free_irq;
 
        return 0;
 
-error_free_trig_name:
-       kfree(st->trig->name);
+error_free_irq:
+       free_irq(st->us->irq, st->trig);
 error_free_trig:
        iio_free_trigger(st->trig);
-
+error_ret:
        return ret;
 }
 
 void ade7758_remove_trigger(struct iio_dev *indio_dev)
 {
-       struct ade7758_state *state = indio_dev->dev_data;
+       struct ade7758_state *st = iio_priv(indio_dev);
 
-       iio_trigger_unregister(state->trig);
-       kfree(state->trig->name);
-       iio_free_trigger(state->trig);
+       iio_trigger_unregister(st->trig);
+       free_irq(st->us->irq, st->trig);
+       iio_free_trigger(st->trig);
 }
index a9d3203b2e1c3d4a320433ad1ffb18dc40f219a3..730f6d9074a6c094e2734424e90fe8691c17ee3e 100644 (file)
@@ -422,8 +422,6 @@ static IIO_DEV_ATTR_RESET(ade7759_write_reset);
 
 static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("27900 14000 7000 3500");
 
-static IIO_CONST_ATTR(name, "ade7759");
-
 static struct attribute *ade7759_attributes[] = {
        &iio_dev_attr_temp_raw.dev_attr.attr,
        &iio_const_attr_temp_offset.dev_attr.attr,
@@ -431,7 +429,6 @@ static struct attribute *ade7759_attributes[] = {
        &iio_dev_attr_sampling_frequency.dev_attr.attr,
        &iio_const_attr_sampling_frequency_available.dev_attr.attr,
        &iio_dev_attr_reset.dev_attr.attr,
-       &iio_const_attr_name.dev_attr.attr,
        &iio_dev_attr_phcal.dev_attr.attr,
        &iio_dev_attr_cfden.dev_attr.attr,
        &iio_dev_attr_aenergy.dev_attr.attr,
@@ -453,6 +450,11 @@ static const struct attribute_group ade7759_attribute_group = {
        .attrs = ade7759_attributes,
 };
 
+static const struct iio_info ade7759_info = {
+       .attrs = &ade7759_attribute_group,
+       .driver_module = THIS_MODULE,
+};
+
 static int __devinit ade7759_probe(struct spi_device *spi)
 {
        int ret;
@@ -478,18 +480,17 @@ static int __devinit ade7759_probe(struct spi_device *spi)
        st->us = spi;
        mutex_init(&st->buf_lock);
        /* setup the industrialio driver allocated elements */
-       st->indio_dev = iio_allocate_device();
+       st->indio_dev = iio_allocate_device(0);
        if (st->indio_dev == NULL) {
                ret = -ENOMEM;
                goto error_free_tx;
        }
 
+       st->indio_dev->name = spi->dev.driver->name;
        st->indio_dev->dev.parent = &spi->dev;
-       st->indio_dev->num_interrupt_lines = 1;
 
-       st->indio_dev->attrs = &ade7759_attribute_group;
+       st->indio_dev->info = &ade7759_info;
        st->indio_dev->dev_data = (void *)(st);
-       st->indio_dev->driver_module = THIS_MODULE;
        st->indio_dev->modes = INDIO_DIRECT_MODE;
 
        ret = iio_device_register(st->indio_dev);
index 866e585451f0e7d6e62193e1c265f71bce8c6fce..44cd3ec546ae2ba58e6dc1334a1f75d5a7d2a29c 100644 (file)
@@ -551,6 +551,11 @@ static const struct attribute_group ade7854_attribute_group = {
        .attrs = ade7854_attributes,
 };
 
+static const struct iio_info ade7854_info = {
+       .attrs = &ade7854_attribute_group,
+       .driver_module = THIS_MODULE,
+};
+
 int ade7854_probe(struct ade7854_state *st, struct device *dev)
 {
        int ret;
@@ -568,16 +573,15 @@ int ade7854_probe(struct ade7854_state *st, struct device *dev)
        }
        mutex_init(&st->buf_lock);
        /* setup the industrialio driver allocated elements */
-       st->indio_dev = iio_allocate_device();
+       st->indio_dev = iio_allocate_device(0);
        if (st->indio_dev == NULL) {
                ret = -ENOMEM;
                goto error_free_tx;
        }
 
        st->indio_dev->dev.parent = dev;
-       st->indio_dev->attrs = &ade7854_attribute_group;
+       st->indio_dev->info = &ade7854_info;
        st->indio_dev->dev_data = (void *)(st);
-       st->indio_dev->driver_module = THIS_MODULE;
        st->indio_dev->modes = INDIO_DIRECT_MODE;
 
        ret = iio_device_register(st->indio_dev);
index 8f497a23976ccb3048fef908ae839e78f706ef29..f83e1422fd2905d957516438fc54e1e6cb33aac0 100644 (file)
@@ -209,10 +209,14 @@ static struct attribute *ad2s120x_attributes[] = {
 };
 
 static const struct attribute_group ad2s120x_attribute_group = {
-       .name = DRV_NAME,
        .attrs = ad2s120x_attributes,
 };
 
+static const struct iio_info ad2s120x_info = {
+       .attrs = &ad2s120x_attribute_group,
+       .driver_module = THIS_MODULE,
+};
+
 static int __devinit ad2s120x_probe(struct spi_device *spi)
 {
        struct ad2s120x_state *st;
@@ -240,18 +244,15 @@ static int __devinit ad2s120x_probe(struct spi_device *spi)
        st->sample = pins[0];
        st->rdvel = pins[1];
 
-       st->idev = iio_allocate_device();
+       st->idev = iio_allocate_device(0);
        if (st->idev == NULL) {
                ret = -ENOMEM;
                goto error_free_st;
        }
        st->idev->dev.parent = &spi->dev;
-       st->idev->num_interrupt_lines = 0;
-       st->idev->event_attrs = NULL;
 
-       st->idev->attrs = &ad2s120x_attribute_group;
+       st->idev->info = &ad2s120x_info;
        st->idev->dev_data = (void *)(st);
-       st->idev->driver_module = THIS_MODULE;
        st->idev->modes = INDIO_DIRECT_MODE;
 
        ret = iio_device_register(st->idev);
index c12f64cc40df3fbd03d11c787aa256c2b29f75df..09f4fcfda73a29afdacd34eb90983d91683b6da8 100644 (file)
@@ -755,6 +755,11 @@ error_ret:
        return ret;
 }
 
+static const struct iio_info ad2s1210_info = {
+       .attrs = &ad2s1210_attribute_group,
+       .driver_module = THIS_MODULE,
+};
+
 static int __devinit ad2s1210_probe(struct spi_device *spi)
 {
        struct ad2s1210_state *st;
@@ -800,18 +805,15 @@ static int __devinit ad2s1210_probe(struct spi_device *spi)
        st->res0 = pins[3];
        st->res1 = pins[4];
 
-       st->idev = iio_allocate_device();
+       st->idev = iio_allocate_device(0);
        if (st->idev == NULL) {
                ret = -ENOMEM;
                goto error_free_st;
        }
        st->idev->dev.parent = &spi->dev;
-       st->idev->num_interrupt_lines = 0;
-       st->idev->event_attrs = NULL;
 
-       st->idev->attrs = &ad2s1210_attribute_group;
+       st->idev->info = &ad2s1210_info;
        st->idev->dev_data = (void *)(st);
-       st->idev->driver_module = THIS_MODULE;
        st->idev->modes = INDIO_DIRECT_MODE;
 
        ret = iio_device_register(st->idev);
index 4143535242d9261e5bf45e6f6bc7ced69dc7b35a..9b72a952f2bc198a3c130a886fbfd1ebfc5a1e4d 100644 (file)
@@ -75,6 +75,11 @@ static const struct attribute_group ad2s90_attribute_group = {
        .attrs = ad2s90_attributes,
 };
 
+static const struct iio_info ad2s90_info = {
+       .attrs = &ad2s90_attribute_group,
+       .driver_module = THIS_MODULE,
+};
+
 static int __devinit ad2s90_probe(struct spi_device *spi)
 {
        struct ad2s90_state *st;
@@ -90,18 +95,15 @@ static int __devinit ad2s90_probe(struct spi_device *spi)
        mutex_init(&st->lock);
        st->sdev = spi;
 
-       st->idev = iio_allocate_device();
+       st->idev = iio_allocate_device(0);
        if (st->idev == NULL) {
                ret = -ENOMEM;
                goto error_free_st;
        }
        st->idev->dev.parent = &spi->dev;
-       st->idev->num_interrupt_lines = 0;
-       st->idev->event_attrs = NULL;
 
-       st->idev->attrs = &ad2s90_attribute_group;
+       st->idev->info = &ad2s90_info;
        st->idev->dev_data = (void *)(st);
-       st->idev->driver_module = THIS_MODULE;
        st->idev->modes = INDIO_DIRECT_MODE;
 
        ret = iio_device_register(st->idev);
index 32948e55dc81c6ae10ff1dc51f84c1b305e5aaf9..3f26f7175b6a30d09608c66f18c93930225c3c8c 100644 (file)
 
 struct iio_ring_buffer;
 
-/**
- * iio_push_ring_event() - ring buffer specific push to event chrdev
- * @ring_buf:          ring buffer that is the event source
- * @event_code:                event indentification code
- * @timestamp:         time of event
- **/
-int iio_push_ring_event(struct iio_ring_buffer *ring_buf,
-                       int event_code,
-                       s64 timestamp);
-/**
- * iio_push_or_escallate_ring_event() -        escalate or add as appropriate
- * @ring_buf:          ring buffer that is the event source
- * @event_code:                event indentification code
- * @timestamp:         time of event
- *
- * Typical usecase is to escalate a 50% ring full to 75% full if no one has yet
- * read the first event. Clearly the 50% full is no longer of interest in
- * typical use case.
- **/
-int iio_push_or_escallate_ring_event(struct iio_ring_buffer *ring_buf,
-                                    int event_code,
-                                    s64 timestamp);
-
 /**
  * struct iio_ring_access_funcs - access functions for ring buffers.
  * @mark_in_use:       reference counting, typically to prevent module removal
  * @unmark_in_use:     reduce reference count when no longer using ring buffer
  * @store_to:          actually store stuff to the ring buffer
  * @read_last:         get the last element stored
- * @rip_lots:          try to get a specified number of elements (must exist)
+ * @read_first_n:      try to get a specified number of elements (must exist)
  * @mark_param_change: notify ring that some relevant parameter has changed
  *                     Often this means the underlying storage may need to
  *                     change.
@@ -71,10 +48,9 @@ struct iio_ring_access_funcs {
 
        int (*store_to)(struct iio_ring_buffer *ring, u8 *data, s64 timestamp);
        int (*read_last)(struct iio_ring_buffer *ring, u8 *data);
-       int (*rip_lots)(struct iio_ring_buffer *ring,
-                       size_t count,
-                       char __user *buf,
-                       int *dead_offset);
+       int (*read_first_n)(struct iio_ring_buffer *ring,
+                           size_t n,
+                           char __user *buf);
 
        int (*mark_param_change)(struct iio_ring_buffer *ring);
        int (*request_update)(struct iio_ring_buffer *ring);
@@ -88,58 +64,52 @@ struct iio_ring_access_funcs {
        int (*enable)(struct iio_ring_buffer *ring);
 };
 
+struct iio_ring_setup_ops {
+       int                             (*preenable)(struct iio_dev *);
+       int                             (*postenable)(struct iio_dev *);
+       int                             (*predisable)(struct iio_dev *);
+       int                             (*postdisable)(struct iio_dev *);
+};
+
 /**
  * struct iio_ring_buffer - general ring buffer structure
  * @dev:               ring buffer device struct
- * @access_dev:                system device struct for the chrdev
  * @indio_dev:         industrial I/O device structure
  * @owner:             module that owns the ring buffer (for ref counting)
- * @id:                        unique id number
- * @access_id:         device id number
  * @length:            [DEVICE] number of datums in ring
  * @bytes_per_datum:   [DEVICE] size of individual datum including timestamp
  * @bpe:               [DEVICE] size of individual channel value
- * @loopcount:         [INTERN] number of times the ring has looped
  * @scan_el_attrs:     [DRIVER] control of scan elements if that scan mode
  *                     control method is used
  * @scan_count:        [INTERN] the number of elements in the current scan mode
  * @scan_mask:         [INTERN] bitmask used in masking scan mode elements
  * @scan_timestamp:    [INTERN] does the scan mode include a timestamp
  * @access_handler:    [INTERN] chrdev access handling
- * @ev_int:            [INTERN] chrdev interface for the event chrdev
- * @shared_ev_pointer: [INTERN] the shared event pointer to allow escalation of
- *                     events
  * @access:            [DRIVER] ring access functions associated with the
  *                     implementation.
  * @preenable:         [DRIVER] function to run prior to marking ring enabled
  * @postenable:                [DRIVER] function to run after marking ring enabled
  * @predisable:                [DRIVER] function to run prior to marking ring disabled
  * @postdisable:       [DRIVER] function to run after marking ring disabled
 **/
+ **/
 struct iio_ring_buffer {
-       struct device dev;
-       struct device access_dev;
-       struct iio_dev *indio_dev;
-       struct module *owner;
-       int                             id;
-       int                             access_id;
-       int                             length;
-       int                             bytes_per_datum;
-       int                             bpe;
-       int                             loopcount;
-       struct attribute_group          *scan_el_attrs;
-       int                             scan_count;
-       u32                             scan_mask;
-       bool                            scan_timestamp;
-       struct iio_handler              access_handler;
-       struct iio_event_interface      ev_int;
-       struct iio_shared_ev_pointer    shared_ev_pointer;
-       struct iio_ring_access_funcs    access;
-       int                             (*preenable)(struct iio_dev *);
-       int                             (*postenable)(struct iio_dev *);
-       int                             (*predisable)(struct iio_dev *);
-       int                             (*postdisable)(struct iio_dev *);
-
+       struct device                           dev;
+       struct iio_dev                          *indio_dev;
+       struct module                           *owner;
+       int                                     length;
+       int                                     bytes_per_datum;
+       int                                     bpe;
+       struct attribute_group                  *scan_el_attrs;
+       int                                     scan_count;
+       unsigned long                           scan_mask;
+       bool                                    scan_timestamp;
+       struct iio_handler                      access_handler;
+       const struct iio_ring_access_funcs      *access;
+       const struct iio_ring_setup_ops         *setup_ops;
+       struct list_head                        scan_el_dev_attr_list;
+
+       wait_queue_head_t                       pollq;
+       bool                                    stufftoread;
 };
 
 /**
@@ -161,154 +131,8 @@ static inline void __iio_update_ring_buffer(struct iio_ring_buffer *ring,
 {
        ring->bytes_per_datum = bytes_per_datum;
        ring->length = length;
-       ring->loopcount = 0;
 }
 
-/**
- * struct iio_scan_el - an individual element of a scan
- * @dev_attr:          control attribute (if directly controllable)
- * @number:            unique identifier of element (used for bit mask)
- * @label:             useful data for the scan el (often reg address)
- * @set_state:         for some devices datardy signals are generated
- *                     for any enabled lines.  This allows unwanted lines
- *                     to be disabled and hence not get in the way.
- **/
-struct iio_scan_el {
-       struct device_attribute         dev_attr;
-       unsigned int                    number;
-       unsigned int                    label;
-
-       int (*set_state)(struct iio_scan_el *scanel,
-                        struct iio_dev *dev_info,
-                        bool state);
-};
-
-#define to_iio_scan_el(_dev_attr)                              \
-       container_of(_dev_attr, struct iio_scan_el, dev_attr);
-
-/**
- * iio_scan_el_store() - sysfs scan element selection interface
- * @dev: the target device
- * @attr: the device attribute that is being processed
- * @buf: input from userspace
- * @len: length of input
- *
- * A generic function used to enable various scan elements.  In some
- * devices explicit read commands for each channel mean this is merely
- * a software switch.  In others this must actively disable the channel.
- * Complexities occur when this interacts with data ready type triggers
- * which may not reset unless every channel that is enabled is explicitly
- * read.
- **/
-ssize_t iio_scan_el_store(struct device *dev, struct device_attribute *attr,
-                         const char *buf, size_t len);
-/**
- * iio_scan_el_show() -        sysfs interface to query whether a scan element
- *                     is enabled or not
- * @dev: the target device
- * @attr: the device attribute that is being processed
- * @buf: output buffer
- **/
-ssize_t iio_scan_el_show(struct device *dev, struct device_attribute *attr,
-                        char *buf);
-
-/**
- * iio_scan_el_ts_store() - sysfs interface to set whether a timestamp is included
- *                         in the scan.
- **/
-ssize_t iio_scan_el_ts_store(struct device *dev, struct device_attribute *attr,
-                            const char *buf, size_t len);
-/**
- * iio_scan_el_ts_show() - sysfs interface to query if a timestamp is included
- *                        in the scan.
- **/
-ssize_t iio_scan_el_ts_show(struct device *dev, struct device_attribute *attr,
-                           char *buf);
-/**
- * IIO_SCAN_EL_C - declare and initialize a scan element with a control func
- *
- * @_name:     identifying name. Resulting struct is iio_scan_el_##_name,
- *             sysfs element, _name##_en.
- * @_number:   unique id number for the scan element.
- *             length devices).
- * @_label:    indentification variable used by drivers.  Often a reg address.
- * @_controlfunc: function used to notify hardware of whether state changes
- **/
-#define __IIO_SCAN_EL_C(_name, _number, _label, _controlfunc)  \
-       struct iio_scan_el iio_scan_el_##_name = {                      \
-               .dev_attr = __ATTR(_name##_en,                          \
-                                  S_IRUGO | S_IWUSR,                   \
-                                  iio_scan_el_show,                    \
-                                  iio_scan_el_store),                  \
-               .number =  _number,                                     \
-               .label = _label,                                        \
-               .set_state = _controlfunc,                              \
-       };                                                              \
-       static IIO_CONST_ATTR(_name##_index, #_number)
-
-#define IIO_SCAN_EL_C(_name, _number, _label, _controlfunc)    \
-       __IIO_SCAN_EL_C(_name, _number, _label, _controlfunc)
-
-#define __IIO_SCAN_NAMED_EL_C(_name, _string, _number, _label, _cf)    \
-       struct iio_scan_el iio_scan_el_##_name = {                      \
-               .dev_attr = __ATTR(_string##_en,                        \
-                                  S_IRUGO | S_IWUSR,                   \
-                                  iio_scan_el_show,                    \
-                                  iio_scan_el_store),                  \
-               .number =  _number,                                     \
-               .label = _label,                                        \
-               .set_state = _cf,                                       \
-       };                                                              \
-       static struct iio_const_attr iio_const_attr_##_name##_index = { \
-               .string = #_number,                                     \
-               .dev_attr = __ATTR(_string##_index,                     \
-                                  S_IRUGO, iio_read_const_attr, NULL)  \
-       }
-
-
-#define IIO_SCAN_NAMED_EL_C(_name, _string, _number, _label, _cf) \
-       __IIO_SCAN_NAMED_EL_C(_name, _string, _number, _label, _cf)
-/**
- * IIO_SCAN_EL_TIMESTAMP - declare a special scan element for timestamps
- * @number: specify where in the scan order this is stored.
- *
- * Odd one out. Handled slightly differently from other scan elements.
- **/
-#define IIO_SCAN_EL_TIMESTAMP(number)                          \
-       struct iio_scan_el iio_scan_el_timestamp = {            \
-               .dev_attr = __ATTR(timestamp_en,                \
-                                  S_IRUGO | S_IWUSR,           \
-                                  iio_scan_el_ts_show,         \
-                                  iio_scan_el_ts_store),       \
-       };                                                      \
-       static IIO_CONST_ATTR(timestamp_index, #number)
-
-/**
- * IIO_CONST_ATTR_SCAN_EL_TYPE - attr to specify the data format of a scan el
- * @name: the scan el name (may be more general and cover a set of scan elements
- * @_sign: either s or u for signed or unsigned
- * @_bits: number of actual bits occuplied by the value
- * @_storagebits: number of bits _bits is padded to when read out of buffer
- **/
-#define IIO_CONST_ATTR_SCAN_EL_TYPE(_name, _sign, _bits, _storagebits) \
-       IIO_CONST_ATTR(_name##_type, #_sign#_bits"/"#_storagebits);
-
-/**
- * IIO_CONST_ATTR_SCAN_EL_TYPE_WITH_SHIFT - attr to specify the data format of a scan el
- * @name: the scan el name (may be more general and cover a set of scan elements
- * @_sign: either s or u for signed or unsigned
- * @_bits: number of actual bits occuplied by the value
- * @_storagebits: number of bits _bits is padded to when read out of buffer
- * @_shiftbits: number of bits _shiftbits the result must be shifted
- **/
-#define IIO_CONST_ATTR_SCAN_EL_TYPE_WITH_SHIFT(_name, _sign, _bits, \
-                                              _storagebits, _shiftbits) \
-       IIO_CONST_ATTR(_name##_type, #_sign#_bits"/"#_storagebits \
-                      ">>"#_shiftbits);
-
-#define IIO_SCAN_EL_TYPE_SIGNED         's'
-#define IIO_SCAN_EL_TYPE_UNSIGNED       'u'
-
 /*
  * These are mainly provided to allow for a change of implementation if a device
  * has a large number of scan elements
@@ -374,41 +198,6 @@ static inline int iio_scan_mask_set(struct iio_ring_buffer *ring, int bit)
        return 0;
 };
 
-/**
- * iio_scan_mask_clear() - clear a particular element from the scan mask
- * @ring: the ring buffer whose scan mask we are interested in
- * @bit: the bit to clear
- **/
-static inline int iio_scan_mask_clear(struct iio_ring_buffer *ring, int bit)
-{
-       if (bit > IIO_MAX_SCAN_LENGTH)
-               return -EINVAL;
-       ring->scan_mask &= ~(1 << bit);
-       ring->scan_count--;
-       return 0;
-};
-
-/**
- * iio_scan_mask_count_to_right() - how many scan elements occur before here
- * @ring: the ring buffer whose scan mask we interested in
- * @bit: which number scan element is this
- **/
-static inline int iio_scan_mask_count_to_right(struct iio_ring_buffer *ring,
-                                               int bit)
-{
-       int count = 0;
-       int mask = (1 << bit);
-       if (bit > IIO_MAX_SCAN_LENGTH)
-               return -EINVAL;
-       while (mask) {
-               mask >>= 1;
-               if (mask & ring->scan_mask)
-                       count++;
-       }
-
-       return count;
-}
-
 /**
  * iio_put_ring_buffer() - notify done with buffer
  * @ring: the buffer we are done with.
@@ -418,17 +207,19 @@ static inline void iio_put_ring_buffer(struct iio_ring_buffer *ring)
        put_device(&ring->dev);
 };
 
-#define to_iio_ring_buffer(d)                  \
+#define to_iio_ring_buffer(d)                          \
        container_of(d, struct iio_ring_buffer, dev)
-#define access_dev_to_iio_ring_buffer(d)                       \
-       container_of(d, struct iio_ring_buffer, access_dev)
 
 /**
- * iio_ring_buffer_register() - register the buffer with IIO core
+ * iio_ring_buffer_register_ex() - register the buffer with IIO core
  * @ring: the buffer to be registered
  * @id: the id of the buffer (typically 0)
  **/
-int iio_ring_buffer_register(struct iio_ring_buffer *ring, int id);
+int iio_ring_buffer_register_ex(struct iio_ring_buffer *ring, int id,
+                               const struct iio_chan_spec *channels,
+                               int num_channels);
+
+void iio_ring_access_release(struct device *dev);
 
 /**
  * iio_ring_buffer_unregister() - unregister the buffer from IIO core
@@ -476,11 +267,19 @@ ssize_t iio_show_ring_enable(struct device *dev,
 #define IIO_RING_ENABLE_ATTR DEVICE_ATTR(enable, S_IRUGO | S_IWUSR, \
                                         iio_show_ring_enable,          \
                                         iio_store_ring_enable)
+
+int iio_sw_ring_preenable(struct iio_dev *indio_dev);
+
 #else /* CONFIG_IIO_RING_BUFFER */
-static inline int iio_ring_buffer_register(struct iio_ring_buffer *ring, int id)
+
+static inline int iio_ring_buffer_register_ex(struct iio_ring_buffer *ring,
+                                             int id,
+                                             struct iio_chan_spec *channels,
+                                             int num_channels)
 {
        return 0;
-};
+}
+
 static inline void iio_ring_buffer_unregister(struct iio_ring_buffer *ring)
 {};
 
index b71ce390064971a4905fac4531cec10bcd9a5177..feb84e27c3626ca09979d0ea39031509cf0d5c3d 100644 (file)
 #include <linux/module.h>
 #include <linux/device.h>
 #include <linux/workqueue.h>
+#include <linux/sched.h>
 #include <linux/poll.h>
 #include "ring_sw.h"
 #include "trigger.h"
 
+/**
+ * struct iio_sw_ring_buffer - software ring buffer
+ * @buf:               generic ring buffer elements
+ * @data:              the ring buffer memory
+ * @read_p:            read pointer (oldest available)
+ * @write_p:           write pointer
+ * @last_written_p:    read pointer (newest available)
+ * @half_p:            half buffer length behind write_p (event generation)
+ * @use_count:         reference count to prevent resizing when in use
+ * @update_needed:     flag to indicated change in size requested
+ * @use_lock:          lock to prevent change in size when in use
+ *
+ * Note that the first element of all ring buffers must be a
+ * struct iio_ring_buffer.
+**/
+struct iio_sw_ring_buffer {
+       struct iio_ring_buffer  buf;
+       unsigned char           *data;
+       unsigned char           *read_p;
+       unsigned char           *write_p;
+       unsigned char           *last_written_p;
+       /* used to act as a point at which to signal an event */
+       unsigned char           *half_p;
+       int                     use_count;
+       int                     update_needed;
+       spinlock_t              use_lock;
+};
+
+#define iio_to_sw_ring(r) container_of(r, struct iio_sw_ring_buffer, buf)
+
 static inline int __iio_allocate_sw_ring_buffer(struct iio_sw_ring_buffer *ring,
                                                int bytes_per_datum, int length)
 {
@@ -40,23 +71,21 @@ static inline void __iio_free_sw_ring_buffer(struct iio_sw_ring_buffer *ring)
        kfree(ring->data);
 }
 
-void iio_mark_sw_rb_in_use(struct iio_ring_buffer *r)
+static void iio_mark_sw_rb_in_use(struct iio_ring_buffer *r)
 {
        struct iio_sw_ring_buffer *ring = iio_to_sw_ring(r);
        spin_lock(&ring->use_lock);
        ring->use_count++;
        spin_unlock(&ring->use_lock);
 }
-EXPORT_SYMBOL(iio_mark_sw_rb_in_use);
 
-void iio_unmark_sw_rb_in_use(struct iio_ring_buffer *r)
+static void iio_unmark_sw_rb_in_use(struct iio_ring_buffer *r)
 {
        struct iio_sw_ring_buffer *ring = iio_to_sw_ring(r);
        spin_lock(&ring->use_lock);
        ring->use_count--;
        spin_unlock(&ring->use_lock);
 }
-EXPORT_SYMBOL(iio_unmark_sw_rb_in_use);
 
 
 /* Ring buffer related functionality */
@@ -68,7 +97,6 @@ static int iio_store_to_sw_ring(struct iio_sw_ring_buffer *ring,
                                unsigned char *data, s64 timestamp)
 {
        int ret = 0;
-       int code;
        unsigned char *temp_ptr, *change_test_ptr;
 
        /* initial store */
@@ -123,14 +151,6 @@ static int iio_store_to_sw_ring(struct iio_sw_ring_buffer *ring,
                 */
                if (change_test_ptr == ring->read_p)
                        ring->read_p = temp_ptr;
-
-               spin_lock(&ring->buf.shared_ev_pointer.lock);
-
-               ret = iio_push_or_escallate_ring_event(&ring->buf,
-                              IIO_EVENT_CODE_RING_100_FULL, timestamp);
-               spin_unlock(&ring->buf.shared_ev_pointer.lock);
-               if (ret)
-                       goto error_ret;
        }
        /* investigate if our event barrier has been passed */
        /* There are definite 'issues' with this and chances of
@@ -140,41 +160,35 @@ static int iio_store_to_sw_ring(struct iio_sw_ring_buffer *ring,
        if (ring->half_p == ring->data + ring->buf.length*ring->buf.bytes_per_datum)
                ring->half_p = ring->data;
        if (ring->half_p == ring->read_p) {
-               spin_lock(&ring->buf.shared_ev_pointer.lock);
-               code = IIO_EVENT_CODE_RING_50_FULL;
-               ret = __iio_push_event(&ring->buf.ev_int,
-                                      code,
-                                      timestamp,
-                                      &ring->buf.shared_ev_pointer);
-               spin_unlock(&ring->buf.shared_ev_pointer.lock);
+               ring->buf.stufftoread = true;
+               wake_up_interruptible(&ring->buf.pollq);
        }
-error_ret:
        return ret;
 }
 
-int iio_rip_sw_rb(struct iio_ring_buffer *r,
-                 size_t count, char __user *buf, int *dead_offset)
+static int iio_read_first_n_sw_rb(struct iio_ring_buffer *r,
+                                 size_t n, char __user *buf)
 {
        struct iio_sw_ring_buffer *ring = iio_to_sw_ring(r);
 
        u8 *initial_read_p, *initial_write_p, *current_read_p, *end_read_p;
        u8 *data;
-       int ret, max_copied;
-       int bytes_to_rip;
+       int ret, max_copied, bytes_to_rip, dead_offset;
 
        /* A userspace program has probably made an error if it tries to
         *  read something that is not a whole number of bpds.
         * Return an error.
         */
-       if (count % ring->buf.bytes_per_datum) {
+       if (n % ring->buf.bytes_per_datum) {
                ret = -EINVAL;
                printk(KERN_INFO "Ring buffer read request not whole number of"
                       "samples: Request bytes %zd, Current bytes per datum %d\n",
-                      count, ring->buf.bytes_per_datum);
+                      n, ring->buf.bytes_per_datum);
                goto error_ret;
        }
        /* Limit size to whole of ring buffer */
-       bytes_to_rip = min((size_t)(ring->buf.bytes_per_datum*ring->buf.length), count);
+       bytes_to_rip = min((size_t)(ring->buf.bytes_per_datum*ring->buf.length),
+                          n);
 
        data = kmalloc(bytes_to_rip, GFP_KERNEL);
        if (data == NULL) {
@@ -240,9 +254,9 @@ int iio_rip_sw_rb(struct iio_ring_buffer *r,
        current_read_p = ring->read_p;
 
        if (initial_read_p <= current_read_p)
-               *dead_offset = current_read_p - initial_read_p;
+               dead_offset = current_read_p - initial_read_p;
        else
-               *dead_offset = ring->buf.length*ring->buf.bytes_per_datum
+               dead_offset = ring->buf.length*ring->buf.bytes_per_datum
                        - (initial_read_p - current_read_p);
 
        /* possible issue if the initial write has been lapped or indeed
@@ -250,7 +264,7 @@ int iio_rip_sw_rb(struct iio_ring_buffer *r,
        /* No valid data read.
         * In this case the read pointer is already correct having been
         * pushed further than we would look. */
-       if (max_copied - *dead_offset < 0) {
+       if (max_copied - dead_offset < 0) {
                ret = 0;
                goto error_free_data_cpy;
        }
@@ -266,26 +280,30 @@ int iio_rip_sw_rb(struct iio_ring_buffer *r,
        while (ring->read_p != end_read_p)
                ring->read_p = end_read_p;
 
-       ret = max_copied - *dead_offset;
+       ret = max_copied - dead_offset;
 
-       if (copy_to_user(buf, data + *dead_offset, ret))  {
+       if (copy_to_user(buf, data + dead_offset, ret))  {
                ret =  -EFAULT;
                goto error_free_data_cpy;
        }
+
+       if (bytes_to_rip >= ring->buf.length*ring->buf.bytes_per_datum/2)
+               ring->buf.stufftoread = 0;
+
 error_free_data_cpy:
        kfree(data);
 error_ret:
 
        return ret;
 }
-EXPORT_SYMBOL(iio_rip_sw_rb);
 
-int iio_store_to_sw_rb(struct iio_ring_buffer *r, u8 *data, s64 timestamp)
+static int iio_store_to_sw_rb(struct iio_ring_buffer *r,
+                             u8 *data,
+                             s64 timestamp)
 {
        struct iio_sw_ring_buffer *ring = iio_to_sw_ring(r);
        return iio_store_to_sw_ring(ring, data, timestamp);
 }
-EXPORT_SYMBOL(iio_store_to_sw_rb);
 
 static int iio_read_last_from_sw_ring(struct iio_sw_ring_buffer *ring,
                                      unsigned char *data)
@@ -309,18 +327,18 @@ again:
        return 0;
 }
 
-int iio_read_last_from_sw_rb(struct iio_ring_buffer *r,
+static int iio_read_last_from_sw_rb(struct iio_ring_buffer *r,
                             unsigned char *data)
 {
        return iio_read_last_from_sw_ring(iio_to_sw_ring(r), data);
 }
-EXPORT_SYMBOL(iio_read_last_from_sw_rb);
 
-int iio_request_update_sw_rb(struct iio_ring_buffer *r)
+static int iio_request_update_sw_rb(struct iio_ring_buffer *r)
 {
        int ret = 0;
        struct iio_sw_ring_buffer *ring = iio_to_sw_ring(r);
 
+       r->stufftoread = false;
        spin_lock(&ring->use_lock);
        if (!ring->update_needed)
                goto error_ret;
@@ -335,54 +353,49 @@ error_ret:
        spin_unlock(&ring->use_lock);
        return ret;
 }
-EXPORT_SYMBOL(iio_request_update_sw_rb);
 
-int iio_get_bytes_per_datum_sw_rb(struct iio_ring_buffer *r)
+static int iio_get_bytes_per_datum_sw_rb(struct iio_ring_buffer *r)
 {
        struct iio_sw_ring_buffer *ring = iio_to_sw_ring(r);
        return ring->buf.bytes_per_datum;
 }
-EXPORT_SYMBOL(iio_get_bytes_per_datum_sw_rb);
 
-int iio_set_bytes_per_datum_sw_rb(struct iio_ring_buffer *r, size_t bpd)
+static int iio_set_bytes_per_datum_sw_rb(struct iio_ring_buffer *r, size_t bpd)
 {
        if (r->bytes_per_datum != bpd) {
                r->bytes_per_datum = bpd;
-               if (r->access.mark_param_change)
-                       r->access.mark_param_change(r);
+               if (r->access->mark_param_change)
+                       r->access->mark_param_change(r);
        }
        return 0;
 }
-EXPORT_SYMBOL(iio_set_bytes_per_datum_sw_rb);
 
-int iio_get_length_sw_rb(struct iio_ring_buffer *r)
+static int iio_get_length_sw_rb(struct iio_ring_buffer *r)
 {
        return r->length;
 }
-EXPORT_SYMBOL(iio_get_length_sw_rb);
 
-int iio_set_length_sw_rb(struct iio_ring_buffer *r, int length)
+static int iio_set_length_sw_rb(struct iio_ring_buffer *r, int length)
 {
        if (r->length != length) {
                r->length = length;
-               if (r->access.mark_param_change)
-                       r->access.mark_param_change(r);
+               if (r->access->mark_param_change)
+                       r->access->mark_param_change(r);
        }
        return 0;
 }
-EXPORT_SYMBOL(iio_set_length_sw_rb);
 
-int iio_mark_update_needed_sw_rb(struct iio_ring_buffer *r)
+static int iio_mark_update_needed_sw_rb(struct iio_ring_buffer *r)
 {
        struct iio_sw_ring_buffer *ring = iio_to_sw_ring(r);
        ring->update_needed = true;
        return 0;
 }
-EXPORT_SYMBOL(iio_mark_update_needed_sw_rb);
 
 static void iio_sw_rb_release(struct device *dev)
 {
        struct iio_ring_buffer *r = to_iio_ring_buffer(dev);
+       iio_ring_access_release(&r->dev);
        kfree(iio_to_sw_ring(r));
 }
 
@@ -420,13 +433,12 @@ struct iio_ring_buffer *iio_sw_rb_allocate(struct iio_dev *indio_dev)
        ring = kzalloc(sizeof *ring, GFP_KERNEL);
        if (!ring)
                return NULL;
+       ring->update_needed = true;
        buf = &ring->buf;
        iio_ring_buffer_init(buf, indio_dev);
        __iio_init_sw_ring_buffer(ring);
        buf->dev.type = &iio_sw_ring_type;
-       device_initialize(&buf->dev);
        buf->dev.parent = &indio_dev->dev;
-       buf->dev.bus = &iio_bus_type;
        dev_set_drvdata(&buf->dev, (void *)buf);
 
        return buf;
@@ -440,73 +452,20 @@ void iio_sw_rb_free(struct iio_ring_buffer *r)
 }
 EXPORT_SYMBOL(iio_sw_rb_free);
 
-int iio_sw_ring_preenable(struct iio_dev *indio_dev)
-{
-       struct iio_ring_buffer *ring = indio_dev->ring;
-       size_t size;
-       dev_dbg(&indio_dev->dev, "%s\n", __func__);
-       /* Check if there are any scan elements enabled, if not fail*/
-       if (!(ring->scan_count || ring->scan_timestamp))
-               return -EINVAL;
-       if (ring->scan_timestamp)
-               if (ring->scan_count)
-                       /* Timestamp (aligned to s64) and data */
-                       size = (((ring->scan_count * ring->bpe)
-                                       + sizeof(s64) - 1)
-                               & ~(sizeof(s64) - 1))
-                               + sizeof(s64);
-               else /* Timestamp only  */
-                       size = sizeof(s64);
-       else /* Data only */
-               size = ring->scan_count * ring->bpe;
-       ring->access.set_bytes_per_datum(ring, size);
-
-       return 0;
-}
-EXPORT_SYMBOL(iio_sw_ring_preenable);
-
-void iio_sw_trigger_bh_to_ring(struct work_struct *work_s)
-{
-       struct iio_sw_ring_helper_state *st
-               = container_of(work_s, struct iio_sw_ring_helper_state,
-                       work_trigger_to_ring);
-       struct iio_ring_buffer *ring = st->indio_dev->ring;
-       int len = 0;
-       size_t datasize = ring->access.get_bytes_per_datum(ring);
-       char *data = kmalloc(datasize, GFP_KERNEL);
-
-       if (data == NULL) {
-               dev_err(st->indio_dev->dev.parent,
-                       "memory alloc failed in ring bh");
-               return;
-       }
-
-       if (ring->scan_count)
-               len = st->get_ring_element(st, data);
-
-         /* Guaranteed to be aligned with 8 byte boundary */
-       if (ring->scan_timestamp)
-               *(s64 *)(((phys_addr_t)data + len
-                               + sizeof(s64) - 1) & ~(sizeof(s64) - 1))
-                       = st->last_timestamp;
-       ring->access.store_to(ring,
-                       (u8 *)data,
-                       st->last_timestamp);
-
-       iio_trigger_notify_done(st->indio_dev->trig);
-       kfree(data);
-
-       return;
-}
-EXPORT_SYMBOL(iio_sw_trigger_bh_to_ring);
-
-void iio_sw_poll_func_th(struct iio_dev *indio_dev, s64 time)
-{      struct iio_sw_ring_helper_state *h
-               = iio_dev_get_devdata(indio_dev);
-       h->last_timestamp = time;
-       schedule_work(&h->work_trigger_to_ring);
-}
-EXPORT_SYMBOL(iio_sw_poll_func_th);
+const struct iio_ring_access_funcs ring_sw_access_funcs = {
+       .mark_in_use = &iio_mark_sw_rb_in_use,
+       .unmark_in_use = &iio_unmark_sw_rb_in_use,
+       .store_to = &iio_store_to_sw_rb,
+       .read_last = &iio_read_last_from_sw_rb,
+       .read_first_n = &iio_read_first_n_sw_rb,
+       .mark_param_change = &iio_mark_update_needed_sw_rb,
+       .request_update = &iio_request_update_sw_rb,
+       .get_bytes_per_datum = &iio_get_bytes_per_datum_sw_rb,
+       .set_bytes_per_datum = &iio_set_bytes_per_datum_sw_rb,
+       .get_length = &iio_get_length_sw_rb,
+       .set_length = &iio_set_length_sw_rb,
+};
+EXPORT_SYMBOL(ring_sw_access_funcs);
 
 MODULE_DESCRIPTION("Industrialio I/O software ring buffer");
 MODULE_LICENSE("GPL");
index 13341c1e35f2d0078e9176a3a88c987927eacb27..15271639534b16eed168a7bdbbf85bba1083b84a 100644 (file)
 
 #ifndef _IIO_RING_SW_H_
 #define _IIO_RING_SW_H_
-/* NEEDS COMMENTS */
-/* The intention is that this should be a separate module from the iio core.
- * This is a bit like supporting algorithms dependent on what the device
- * driver requests - some may support multiple options */
-
-
-#include "iio.h"
 #include "ring_generic.h"
 
-#if defined CONFIG_IIO_SW_RING || defined CONFIG_IIO_SW_RING_MODULE
-
-/**
- * iio_create_sw_rb() - software ring buffer allocation
- * @r:         pointer to ring buffer pointer
- **/
-int iio_create_sw_rb(struct iio_ring_buffer **r);
-
-/**
- * iio_init_sw_rb() - initialize the software ring buffer
- * @r:         pointer to a software ring buffer created by an
- *             iio_create_sw_rb call
- * @indio_dev:         industrial I/O device structure
- **/
-int iio_init_sw_rb(struct iio_ring_buffer *r, struct iio_dev *indio_dev);
-
-/**
- * iio_exit_sw_rb() - reverse what was done in iio_init_sw_rb
- * @r:         pointer to a software ring buffer created by an
- *             iio_create_sw_rb call
- **/
-void iio_exit_sw_rb(struct iio_ring_buffer *r);
-
-/**
- * iio_free_sw_rb() - free memory occupied by the core ring buffer struct
- * @r:         pointer to a software ring buffer created by an
- *             iio_create_sw_rb call
- **/
-void iio_free_sw_rb(struct iio_ring_buffer *r);
-
-/**
- * iio_mark_sw_rb_in_use() - reference counting to prevent incorrect chances
- * @r:         pointer to a software ring buffer created by an
- *             iio_create_sw_rb call
- **/
-void iio_mark_sw_rb_in_use(struct iio_ring_buffer *r);
-
-/**
- *  iio_unmark_sw_rb_in_use() - notify the ring buffer that we don't care anymore
- * @r:         pointer to a software ring buffer created by an
- *             iio_create_sw_rb call
- **/
-void iio_unmark_sw_rb_in_use(struct iio_ring_buffer *r);
-
-/**
- * iio_read_last_from_sw_rb() - attempt to read the last stored datum from the rb
- * @r:         pointer to a software ring buffer created by an
- *             iio_create_sw_rb call
- * @data:      where to store the last datum
- **/
-int iio_read_last_from_sw_rb(struct iio_ring_buffer *r, u8 *data);
-
-/**
- * iio_store_to_sw_rb() - store a new datum to the ring buffer
- * @r:         pointer to ring buffer instance
- * @data:      the datum to be stored including timestamp if relevant
- * @timestamp: timestamp which will be attached to buffer events if relevant
- **/
-int iio_store_to_sw_rb(struct iio_ring_buffer *r, u8 *data, s64 timestamp);
-
-/**
- * iio_rip_sw_rb() - attempt to read data from the ring buffer
- * @r:                 ring buffer instance
- * @count:             number of datum's to try and read
- * @buf:               userspace buffer into which data is copied
- * @dead_offset:       how much of the stored data was possibly invalidated by
- *                     the end of the copy.
- **/
-int iio_rip_sw_rb(struct iio_ring_buffer *r,
-                 size_t count,
-                 char __user *buf,
-                 int *dead_offset);
-
-/**
- * iio_request_update_sw_rb() - update params if update needed
- * @r:         pointer to a software ring buffer created by an
- *             iio_create_sw_rb call
- **/
-int iio_request_update_sw_rb(struct iio_ring_buffer *r);
-
-/**
- * iio_mark_update_needed_sw_rb() - tell the ring buffer it needs a param update
- * @r:         pointer to a software ring buffer created by an
- *             iio_create_sw_rb call
- **/
-int iio_mark_update_needed_sw_rb(struct iio_ring_buffer *r);
-
-
-/**
- * iio_get_bytes_per_datum_sw_rb() - get the datum size in bytes
- * @r:         pointer to a software ring buffer created by an
- *             iio_create_sw_rb call
- **/
-int iio_get_bytes_per_datum_sw_rb(struct iio_ring_buffer *r);
-
-/**
- * iio_set_bytes_per_datum_sw_rb() - set the datum size in bytes
- * @r:         pointer to a software ring buffer created by an
- *             iio_create_sw_rb call
- * @bpd:       bytes per datum value
- **/
-int iio_set_bytes_per_datum_sw_rb(struct iio_ring_buffer *r, size_t bpd);
-
 /**
- * iio_get_length_sw_rb() - get how many datums the rb may contain
- * @r:         pointer to a software ring buffer created by an
- *             iio_create_sw_rb call
+ * ring_sw_access_funcs - access functions for a software ring buffer
  **/
-int iio_get_length_sw_rb(struct iio_ring_buffer *r);
-
-/**
- * iio_set_length_sw_rb() - set how many datums the rb may contain
- * @r:         pointer to a software ring buffer created by an
- *             iio_create_sw_rb call
- * @length:    max number of data items for the ring buffer
- **/
-int iio_set_length_sw_rb(struct iio_ring_buffer *r, int length);
-
-/**
- * iio_ring_sw_register_funcs() - helper function to set up rb access
- * @ra:                pointer to @iio_ring_access_funcs
- **/
-static inline void iio_ring_sw_register_funcs(struct iio_ring_access_funcs *ra)
-{
-       ra->mark_in_use = &iio_mark_sw_rb_in_use;
-       ra->unmark_in_use = &iio_unmark_sw_rb_in_use;
-
-       ra->store_to = &iio_store_to_sw_rb;
-       ra->read_last = &iio_read_last_from_sw_rb;
-       ra->rip_lots = &iio_rip_sw_rb;
-
-       ra->mark_param_change = &iio_mark_update_needed_sw_rb;
-       ra->request_update = &iio_request_update_sw_rb;
-
-       ra->get_bytes_per_datum = &iio_get_bytes_per_datum_sw_rb;
-       ra->set_bytes_per_datum = &iio_set_bytes_per_datum_sw_rb;
-
-       ra->get_length = &iio_get_length_sw_rb;
-       ra->set_length = &iio_set_length_sw_rb;
-};
-
-/**
- * struct iio_sw_ring_buffer - software ring buffer
- * @buf:               generic ring buffer elements
- * @data:              the ring buffer memory
- * @read_p:            read pointer (oldest available)
- * @write_p:           write pointer
- * @last_written_p:    read pointer (newest available)
- * @half_p:            half buffer length behind write_p (event generation)
- * @use_count:         reference count to prevent resizing when in use
- * @update_needed:     flag to indicated change in size requested
- * @use_lock:          lock to prevent change in size when in use
- *
- * Note that the first element of all ring buffers must be a
- * struct iio_ring_buffer.
-**/
-
-struct iio_sw_ring_buffer {
-       struct iio_ring_buffer  buf;
-       unsigned char           *data;
-       unsigned char           *read_p;
-       unsigned char           *write_p;
-       unsigned char           *last_written_p;
-       /* used to act as a point at which to signal an event */
-       unsigned char           *half_p;
-       int                     use_count;
-       int                     update_needed;
-       spinlock_t              use_lock;
-};
-
-#define iio_to_sw_ring(r) container_of(r, struct iio_sw_ring_buffer, buf)
+extern const struct iio_ring_access_funcs ring_sw_access_funcs;
 
 struct iio_ring_buffer *iio_sw_rb_allocate(struct iio_dev *indio_dev);
 void iio_sw_rb_free(struct iio_ring_buffer *ring);
-
-int iio_sw_ring_preenable(struct iio_dev *indio_dev);
-
-struct iio_sw_ring_helper_state {
-       struct work_struct              work_trigger_to_ring;
-       struct iio_dev                  *indio_dev;
-       int (*get_ring_element)(struct iio_sw_ring_helper_state *st, u8 *buf);
-       s64                             last_timestamp;
-};
-
-void iio_sw_poll_func_th(struct iio_dev *indio_dev, s64 time);
-void iio_sw_trigger_bh_to_ring(struct work_struct *work_s);
-
-#else /* CONFIG_IIO_RING_BUFFER*/
-struct iio_sw_ring_helper_state {
-       struct iio_dev                  *indio_dev;
-};
-#endif /* !CONFIG_IIO_RING_BUFFER */
 #endif /* _IIO_RING_SW_H_ */
index 24b74ddcd0830ffcc6bb31424b63648ee89df13d..dd79b58442123ebba25a7a337c64b25380f7ad2f 100644 (file)
 
 #include "iio.h"
 
-/**
- * struct iio_event_attr - event control attribute
- * @dev_attr:  underlying device attribute
- * @mask:      mask for the event when detecting
- * @listel:    list header to allow addition to list of event handlers
-*/
-struct iio_event_attr {
-       struct device_attribute dev_attr;
-       int mask;
-       struct iio_event_handler_list *listel;
-};
-
-#define to_iio_event_attr(_dev_attr) \
-       container_of(_dev_attr, struct iio_event_attr, dev_attr)
-
 /**
  * struct iio_dev_attr - iio specific device attribute
  * @dev_attr:  underlying device attribute
  * @address:   associated register address
  * @val2:      secondary attribute value
+ * @l:         list head for maintaining list of dynamically created attrs.
  */
 struct iio_dev_attr {
        struct device_attribute dev_attr;
        int address;
        int val2;
+       struct list_head l;
+       struct iio_chan_spec const *c;
 };
 
 #define to_iio_dev_attr(_dev_attr)                             \
@@ -100,13 +88,6 @@ struct iio_const_attr {
 #define IIO_DEV_ATTR_REV(_show)                        \
        IIO_DEVICE_ATTR(revision, S_IRUGO, _show, NULL, 0)
 
-/**
- * IIO_DEV_ATTR_NAME - chip type dependent identifier
- * @_show: output method for the attribute
- **/
-#define IIO_DEV_ATTR_NAME(_show)                               \
-       IIO_DEVICE_ATTR(name, S_IRUGO, _show, NULL, 0)
-
 /**
  * IIO_DEV_ATTR_RESET: resets the device
  **/
@@ -180,104 +161,27 @@ struct iio_const_attr {
 #define IIO_CONST_ATTR_TEMP_SCALE(_string)             \
        IIO_CONST_ATTR(temp_scale, _string)
 
-/**
- * IIO_EVENT_SH - generic shared event handler
- * @_name: event name
- * @_handler: handler function to be called
- *
- * This is used in cases where more than one event may result from a single
- * handler.  Often the case that some alarm register must be read and multiple
- * alarms may have been triggered.
- **/
-#define IIO_EVENT_SH(_name, _handler)                                  \
-       static struct iio_event_handler_list                            \
-       iio_event_##_name = {                                           \
-               .handler = _handler,                                    \
-               .refcount = 0,                                          \
-               .exist_lock = __MUTEX_INITIALIZER(iio_event_##_name     \
-                                                 .exist_lock),         \
-               .list = {                                               \
-                       .next = &iio_event_##_name.list,                \
-                       .prev = &iio_event_##_name.list,                \
-               },                                                      \
-       };
-
-/**
- * IIO_EVENT_ATTR_SH - generic shared event attribute
- * @_name: event name
- * @_ev_list: event handler list
- * @_show: output method for the attribute
- * @_store: input method for the attribute
- * @_mask: mask used when detecting the event
- *
- * An attribute with an associated IIO_EVENT_SH
- **/
-#define IIO_EVENT_ATTR_SH(_name, _ev_list, _show, _store, _mask)       \
-       static struct iio_event_attr                                    \
-       iio_event_attr_##_name                                          \
-       = { .dev_attr = __ATTR(_name, S_IRUGO | S_IWUSR,                \
-                              _show, _store),                          \
-           .mask = _mask,                                              \
-           .listel = &_ev_list };
-
-#define IIO_EVENT_ATTR_NAMED_SH(_vname, _name, _ev_list, _show, _store, _mask) \
-       static struct iio_event_attr                                    \
-       iio_event_attr_##_vname                                         \
-       = { .dev_attr = __ATTR(_name, S_IRUGO | S_IWUSR,                \
-                              _show, _store),                          \
-           .mask = _mask,                                              \
-           .listel = &_ev_list };
-
-/**
- * IIO_EVENT_ATTR - non-shared event attribute
- * @_name: event name
- * @_show: output method for the attribute
- * @_store: input method for the attribute
- * @_mask: mask used when detecting the event
- * @_handler: handler function to be called
- **/
-#define IIO_EVENT_ATTR(_name, _show, _store, _mask, _handler)          \
-       IIO_EVENT_SH(_name, _handler);                                  \
-       static struct                                                   \
-       iio_event_attr                                                  \
-       iio_event_attr_##_name                                          \
-       = { .dev_attr = __ATTR(_name, S_IRUGO | S_IWUSR,                \
-                              _show, _store),                          \
-           .mask = _mask,                                              \
-           .listel = &iio_event_##_name };                             \
-
-/**
- * IIO_EVENT_ATTR_DATA_RDY - event driven by data ready signal
- * @_show: output method for the attribute
- * @_store: input method for the attribute
- * @_mask: mask used when detecting the event
- * @_handler: handler function to be called
- *
- * Not typically implemented in devices where full triggering support
- * has been implemented.
- **/
-#define IIO_EVENT_ATTR_DATA_RDY(_show, _store, _mask, _handler) \
-       IIO_EVENT_ATTR(data_rdy, _show, _store, _mask, _handler)
-
-#define IIO_EV_CLASS_BUFFER            0
-#define IIO_EV_CLASS_IN                        1
-#define IIO_EV_CLASS_ACCEL             2
-#define IIO_EV_CLASS_GYRO              3
-#define IIO_EV_CLASS_MAGN              4
-#define IIO_EV_CLASS_LIGHT             5
-#define IIO_EV_CLASS_PROXIMITY         6
-
-#define IIO_EV_MOD_X                   0
-#define IIO_EV_MOD_Y                   1
-#define IIO_EV_MOD_Z                   2
-#define IIO_EV_MOD_X_AND_Y             3
-#define IIO_EV_MOD_X_ANX_Z             4
-#define IIO_EV_MOD_Y_AND_Z             5
-#define IIO_EV_MOD_X_AND_Y_AND_Z       6
-#define IIO_EV_MOD_X_OR_Y              7
-#define IIO_EV_MOD_X_OR_Z              8
-#define IIO_EV_MOD_Y_OR_Z              9
-#define IIO_EV_MOD_X_OR_Y_OR_Z         10
+/* must match our channel defs */
+#define IIO_EV_CLASS_IN                        IIO_IN
+#define IIO_EV_CLASS_IN_DIFF           IIO_IN_DIFF
+#define IIO_EV_CLASS_ACCEL             IIO_ACCEL
+#define IIO_EV_CLASS_GYRO              IIO_GYRO
+#define IIO_EV_CLASS_MAGN              IIO_MAGN
+#define IIO_EV_CLASS_LIGHT             IIO_LIGHT
+#define IIO_EV_CLASS_PROXIMITY         IIO_PROXIMITY
+#define IIO_EV_CLASS_TEMP              IIO_TEMP
+
+#define IIO_EV_MOD_X                   IIO_MOD_X
+#define IIO_EV_MOD_Y                   IIO_MOD_Y
+#define IIO_EV_MOD_Z                   IIO_MOD_Z
+#define IIO_EV_MOD_X_AND_Y             IIO_MOD_X_AND_Y
+#define IIO_EV_MOD_X_ANX_Z             IIO_MOD_X_AND_Z
+#define IIO_EV_MOD_Y_AND_Z             IIO_MOD_Y_AND_Z
+#define IIO_EV_MOD_X_AND_Y_AND_Z       IIO_MOD_X_AND_Y_AND_Z
+#define IIO_EV_MOD_X_OR_Y              IIO_MOD_X_OR_Y
+#define IIO_EV_MOD_X_OR_Z              IIO_MOD_X_OR_Z
+#define IIO_EV_MOD_Y_OR_Z              IIO_MOD_Y_OR_Z
+#define IIO_EV_MOD_X_OR_Y_OR_Z         IIO_MOD_X_OR_Y_OR_Z
 
 #define IIO_EV_TYPE_THRESH             0
 #define IIO_EV_TYPE_MAG                        1
@@ -287,6 +191,10 @@ struct iio_const_attr {
 #define IIO_EV_DIR_RISING              1
 #define IIO_EV_DIR_FALLING             2
 
+#define IIO_EV_TYPE_MAX 8
+#define IIO_EV_BIT(type, direction)                    \
+       (1 << (type*IIO_EV_TYPE_MAX + direction))
+
 #define IIO_EVENT_CODE(channelclass, orient_bit, number,               \
                       modifier, type, direction)                       \
        (channelclass | (orient_bit << 8) | ((number) << 9) |           \
@@ -303,38 +211,12 @@ struct iio_const_attr {
 #define IIO_BUFFER_EVENT_CODE(code)            \
        (IIO_EV_CLASS_BUFFER | (code << 8))
 
-/**
- * IIO_EVENT_ATTR_RING_50_FULL - ring buffer event to indicate 50% full
- * @_show: output method for the attribute
- * @_store: input method for the attribute
- * @_mask: mask used when detecting the event
- * @_handler: handler function to be called
- **/
-#define IIO_EVENT_ATTR_RING_50_FULL(_show, _store, _mask, _handler)    \
-       IIO_EVENT_ATTR(ring_50_full, _show, _store, _mask, _handler)
-
-/**
- * IIO_EVENT_ATTR_RING_50_FULL_SH - shared ring event to indicate 50% full
- * @_evlist: event handler list
- * @_show: output method for the attribute
- * @_store: input method for the attribute
- * @_mask: mask used when detecting the event
- **/
-#define IIO_EVENT_ATTR_RING_50_FULL_SH(_evlist, _show, _store, _mask)  \
-       IIO_EVENT_ATTR_SH(ring_50_full, _evlist, _show, _store, _mask)
+#define IIO_EVENT_CODE_EXTRACT_DIR(mask) ((mask >> 24) & 0xf)
 
-/**
- * IIO_EVENT_ATTR_RING_75_FULL_SH - shared ring event to indicate 75% full
- * @_evlist: event handler list
- * @_show: output method for the attribute
- * @_store: input method for the attribute
- * @_mask: mask used when detecting the event
- **/
-#define IIO_EVENT_ATTR_RING_75_FULL_SH(_evlist, _show, _store, _mask)  \
-       IIO_EVENT_ATTR_SH(ring_75_full, _evlist, _show, _store, _mask)
+/* Event code number extraction depends on which type of event we have.
+ * Perhaps review this function in the future*/
+#define IIO_EVENT_CODE_EXTRACT_NUM(mask) ((mask >> 9) & 0x0f)
 
-#define IIO_EVENT_CODE_RING_50_FULL    IIO_BUFFER_EVENT_CODE(0)
-#define IIO_EVENT_CODE_RING_75_FULL    IIO_BUFFER_EVENT_CODE(1)
-#define IIO_EVENT_CODE_RING_100_FULL   IIO_BUFFER_EVENT_CODE(2)
+#define IIO_EVENT_CODE_EXTRACT_MODIFIER(mask) ((mask >> 13) & 0x7)
 
 #endif /* _INDUSTRIAL_IO_SYSFS_H_ */
index 469beba3e71dd7e5294bf75d9d0386fb81cdaa02..f329fe10fa2f4251a6f88f6c995852f5d647df00 100644 (file)
@@ -6,9 +6,15 @@
  * under the terms of the GNU General Public License version 2 as published by
  * the Free Software Foundation.
  */
+#include <linux/irq.h>
+
 #ifndef _IIO_TRIGGER_H_
 #define _IIO_TRIGGER_H_
 
+struct iio_subirq {
+       bool enabled;
+};
+
 /**
  * struct iio_trigger - industrial I/O trigger device
  *
  * @private_data:      [DRIVER] device specific data
  * @list:              [INTERN] used in maintenance of global trigger list
  * @alloc_list:                [DRIVER] used for driver specific trigger list
- * @pollfunc_list_lock:        [INTERN] protection of the polling function list
- * @pollfunc_list:     [INTERN] list of functions to run on trigger.
- * @control_attrs:     [DRIVER] sysfs attributes relevant to trigger type
  * @owner:             [DRIVER] used to monitor usage count of the trigger.
  * @use_count:         use count for the trigger
  * @set_trigger_state: [DRIVER] switch on/off the trigger on demand
  * @try_reenable:      function to reenable the trigger when the
  *                     use count is zero (may be NULL)
+ * @subirq_chip:       [INTERN] associate 'virtual' irq chip.
+ * @subirq_base:       [INTERN] base number for irqs provided by trigger.
+ * @subirqs:           [INTERN] information about the 'child' irqs.
+ * @pool:              [INTERN] bitmap of irqs currently in use.
+ * @pool_lock:         [INTERN] protection of the irq pool.
  **/
 struct iio_trigger {
        int                             id;
@@ -35,14 +43,18 @@ struct iio_trigger {
        void                            *private_data;
        struct list_head                list;
        struct list_head                alloc_list;
-       spinlock_t                      pollfunc_list_lock;
-       struct list_head                pollfunc_list;
-       const struct attribute_group    *control_attrs;
        struct module                   *owner;
        int use_count;
 
        int (*set_trigger_state)(struct iio_trigger *trig, bool state);
        int (*try_reenable)(struct iio_trigger *trig);
+
+       struct irq_chip                 subirq_chip;
+       int                             subirq_base;
+
+       struct iio_subirq subirqs[CONFIG_IIO_CONSUMERS_PER_TRIGGER];
+       unsigned long pool[BITS_TO_LONGS(CONFIG_IIO_CONSUMERS_PER_TRIGGER)];
+       struct mutex                    pool_lock;
 };
 
 static inline struct iio_trigger *to_iio_trigger(struct device *d)
@@ -62,27 +74,6 @@ static inline void iio_get_trigger(struct iio_trigger *trig)
        get_device(&trig->dev);
 };
 
-/**
- * iio_trigger_read_name() - sysfs access function to get the trigger name
- * @dev: the system device
- * @attr: device attributes for the device
- * @buf: output buffer to store the trigger name
- **/
-ssize_t iio_trigger_read_name(struct device *dev,
-                             struct device_attribute *attr,
-                             char *buf);
-
-#define IIO_TRIGGER_NAME_ATTR DEVICE_ATTR(name, S_IRUGO,               \
-                                         iio_trigger_read_name,        \
-                                         NULL);
-
-/**
- * iio_trigger_find_by_name() - search global trigger list
- * @name: trigger name to search for
- * @len: trigger name string length to compare
- **/
-struct iio_trigger *iio_trigger_find_by_name(const char *name, size_t len);
-
 /**
  * iio_trigger_register() - register a trigger with the IIO core
  * @trig_info: trigger to be registered
@@ -119,36 +110,65 @@ int iio_trigger_dettach_poll_func(struct iio_trigger *trig,
  * Typically called in relevant hardware interrupt handler.
  **/
 void iio_trigger_poll(struct iio_trigger *trig, s64 time);
+void iio_trigger_poll_chained(struct iio_trigger *trig, s64 time);
 void iio_trigger_notify_done(struct iio_trigger *trig);
 
+irqreturn_t iio_trigger_generic_data_rdy_poll(int irq, void *private);
+
+static inline int iio_trigger_get_irq(struct iio_trigger *trig)
+{
+       int ret;
+       mutex_lock(&trig->pool_lock);
+       ret = bitmap_find_free_region(trig->pool,
+                                     CONFIG_IIO_CONSUMERS_PER_TRIGGER,
+                                     ilog2(1));
+       mutex_unlock(&trig->pool_lock);
+       if (ret >= 0)
+               ret += trig->subirq_base;
+
+       return ret;
+};
+
+static inline void iio_trigger_put_irq(struct iio_trigger *trig, int irq)
+{
+       mutex_lock(&trig->pool_lock);
+       clear_bit(irq - trig->subirq_base, trig->pool);
+       mutex_unlock(&trig->pool_lock);
+};
+
 /**
  * struct iio_poll_func - poll function pair
  *
- * @list:                      associate this with a triggers pollfunc_list
  * @private_data:              data specific to device (passed into poll func)
- * @poll_func_immediate:       function in here is run first. They should be
- *                             extremely lightweight.  Typically used for latch
- *                             control on sensor supporting it.
- * @poll_func_main:            function in here is run after all immediates.
- *                             Reading from sensor etc typically involves
- *                             scheduling from here.
- *
- * The two stage approach used here is only important when multiple sensors are
- * being triggered by a single trigger. This really comes into its own with
- * simultaneous sampling devices where a simple latch command can be used to
- * make the device store the values on all inputs.
+ * @h:                         the function that is actually run on trigger
+ * @thread:                    threaded interrupt part
+ * @type:                      the type of interrupt (basically if oneshot)
+ * @name:                      name used to identify the trigger consumer.
+ * @irq:                       the corresponding irq as allocated from the
+ *                             trigger pool
+ * @timestamp:                 some devices need a timestamp grabbed as soon
+ *                             as possible after the trigger - hence handler
+ *                             passes it via here.
  **/
 struct iio_poll_func {
-       struct                          list_head list;
        void                            *private_data;
-       void (*poll_func_immediate)(struct iio_dev *indio_dev);
-       void (*poll_func_main)(struct iio_dev *private_data, s64 time);
-
+       irqreturn_t (*h)(int irq, void *p);
+       irqreturn_t (*thread)(int irq, void *p);
+       int type;
+       char *name;
+       int irq;
+       s64 timestamp;
 };
 
-int iio_alloc_pollfunc(struct iio_dev *indio_dev,
-                      void (*immediate)(struct iio_dev *indio_dev),
-                      void (*main)(struct iio_dev *private_data, s64 time));
+struct iio_poll_func
+*iio_alloc_pollfunc(irqreturn_t (*h)(int irq, void *p),
+                   irqreturn_t (*thread)(int irq, void *p),
+                   int type,
+                   void *private,
+                   const char *fmt,
+                   ...);
+void iio_dealloc_pollfunc(struct iio_poll_func *pf);
+irqreturn_t iio_pollfunc_store_time(int irq, void *p);
 
 /*
  * Two functions for common case where all that happens is a pollfunc
@@ -157,8 +177,8 @@ int iio_alloc_pollfunc(struct iio_dev *indio_dev,
 int iio_triggered_ring_postenable(struct iio_dev *indio_dev);
 int iio_triggered_ring_predisable(struct iio_dev *indio_dev);
 
-struct iio_trigger *iio_allocate_trigger(void);
-
+struct iio_trigger *iio_allocate_trigger(const char *fmt, ...)
+       __attribute__((format(printf, 1, 2)));
 void iio_free_trigger(struct iio_trigger *trig);
 
 #endif /* _IIO_TRIGGER_H_ */
index c33777e0a8b3904f034a0e3ebd349bb36af6affe..b8abf5473ddc7413456dc95f1646b51a38f8c2df 100644 (file)
@@ -31,6 +31,7 @@ config IIO_SYSFS_TRIGGER
 config IIO_BFIN_TMR_TRIGGER
        tristate "Blackfin TIMER trigger"
        depends on BLACKFIN
+       select BFIN_GPTIMERS
        help
          Provides support for using a Blackfin timer as IIO triggers.
          If unsure, say N (but it's safe to say "Y").
index 583bef0936e8fb3c028d692e00fa6c1b58b3d6a4..4f1729565582f3853efade06cdf024ad5eed06da 100644 (file)
@@ -106,11 +106,9 @@ static ssize_t iio_bfin_tmr_frequency_show(struct device *dev,
 
 static DEVICE_ATTR(frequency, S_IRUGO | S_IWUSR, iio_bfin_tmr_frequency_show,
                   iio_bfin_tmr_frequency_store);
-static IIO_TRIGGER_NAME_ATTR;
 
 static struct attribute *iio_bfin_tmr_trigger_attrs[] = {
        &dev_attr_frequency.attr,
-       &dev_attr_name.attr,
        NULL,
 };
 
@@ -118,6 +116,11 @@ static const struct attribute_group iio_bfin_tmr_trigger_attr_group = {
        .attrs = iio_bfin_tmr_trigger_attrs,
 };
 
+static const struct attribute_group *iio_bfin_tmr_trigger_attr_groups[] = {
+       &iio_bfin_tmr_trigger_attr_group,
+       NULL
+};
+
 
 static irqreturn_t iio_bfin_tmr_trigger_isr(int irq, void *devid)
 {
@@ -165,24 +168,18 @@ static int __devinit iio_bfin_tmr_trigger_probe(struct platform_device *pdev)
        st->timer_num = ret;
        st->t = &iio_bfin_timer_code[st->timer_num];
 
-       st->trig = iio_allocate_trigger();
+       st->trig = iio_allocate_trigger("bfintmr%d", st->timer_num);
        if (!st->trig) {
                ret = -ENOMEM;
                goto out1;
        }
 
        st->trig->private_data = st;
-       st->trig->control_attrs = &iio_bfin_tmr_trigger_attr_group;
        st->trig->owner = THIS_MODULE;
-       st->trig->name = kasprintf(GFP_KERNEL, "bfintmr%d", st->timer_num);
-       if (st->trig->name == NULL) {
-               ret = -ENOMEM;
-               goto out2;
-       }
-
+       st->trig->dev.groups = iio_bfin_tmr_trigger_attr_groups;
        ret = iio_trigger_register(st->trig);
        if (ret)
-               goto out3;
+               goto out2;
 
        ret = request_irq(st->irq, iio_bfin_tmr_trigger_isr,
                          0, st->trig->name, st);
@@ -201,8 +198,6 @@ static int __devinit iio_bfin_tmr_trigger_probe(struct platform_device *pdev)
        return 0;
 out4:
        iio_trigger_unregister(st->trig);
-out3:
-       kfree(st->trig->name);
 out2:
        iio_put_trigger(st->trig);
 out1:
@@ -218,7 +213,6 @@ static int __devexit iio_bfin_tmr_trigger_remove(struct platform_device *pdev)
        disable_gptimers(st->t->bit);
        free_irq(st->irq, st);
        iio_trigger_unregister(st->trig);
-       kfree(st->trig->name);
        iio_put_trigger(st->trig);
        kfree(st);
 
index 2ce95e964cfdbbdfe4d4fa9fe37d820f6fe1689b..b188635c34600464b362ca2ea804a0286090925c 100644 (file)
@@ -47,17 +47,6 @@ static irqreturn_t iio_gpio_trigger_poll(int irq, void *private)
        return IRQ_HANDLED;
 }
 
-static IIO_TRIGGER_NAME_ATTR;
-
-static struct attribute *iio_gpio_trigger_attrs[] = {
-       &dev_attr_name.attr,
-       NULL,
-};
-
-static const struct attribute_group iio_gpio_trigger_attr_group = {
-       .attrs = iio_gpio_trigger_attrs,
-};
-
 static int iio_gpio_trigger_probe(struct platform_device *pdev)
 {
        struct iio_gpio_trigger_info *trig_info;
@@ -79,7 +68,7 @@ static int iio_gpio_trigger_probe(struct platform_device *pdev)
 
                for (irq = irq_res->start; irq <= irq_res->end; irq++) {
 
-                       trig = iio_allocate_trigger();
+                       trig = iio_allocate_trigger("irqtrig%d", irq);
                        if (!trig) {
                                ret = -ENOMEM;
                                goto error_free_completed_registrations;
@@ -90,21 +79,15 @@ static int iio_gpio_trigger_probe(struct platform_device *pdev)
                                ret = -ENOMEM;
                                goto error_put_trigger;
                        }
-                       trig->control_attrs = &iio_gpio_trigger_attr_group;
                        trig->private_data = trig_info;
                        trig_info->irq = irq;
                        trig->owner = THIS_MODULE;
-                       trig->name = kasprintf(GFP_KERNEL, "irqtrig%d", irq);
-                       if (trig->name == NULL) {
-                               ret = -ENOMEM;
-                               goto error_free_trig_info;
-                       }
                        ret = request_irq(irq, iio_gpio_trigger_poll,
                                          irqflags, trig->name, trig);
                        if (ret) {
                                dev_err(&pdev->dev,
                                        "request IRQ-%d failed", irq);
-                               goto error_free_name;
+                               goto error_free_trig_info;
                        }
 
                        ret = iio_trigger_register(trig);
@@ -124,8 +107,6 @@ static int iio_gpio_trigger_probe(struct platform_device *pdev)
 /* First clean up the partly allocated trigger */
 error_release_irq:
        free_irq(irq, trig);
-error_free_name:
-       kfree(trig->name);
 error_free_trig_info:
        kfree(trig_info);
 error_put_trigger:
@@ -138,7 +119,6 @@ error_free_completed_registrations:
                                 alloc_list) {
                trig_info = trig->private_data;
                free_irq(gpio_to_irq(trig_info->irq), trig);
-               kfree(trig->name);
                kfree(trig_info);
                iio_trigger_unregister(trig);
        }
@@ -159,7 +139,6 @@ static int iio_gpio_trigger_remove(struct platform_device *pdev)
                trig_info = trig->private_data;
                iio_trigger_unregister(trig);
                free_irq(trig_info->irq, trig);
-               kfree(trig->name);
                kfree(trig_info);
                iio_put_trigger(trig);
        }
index 24f174e1cda516546afafc1e326f55c6963b5a45..01cf7e20b515bf45922e306d263070aedc695444 100644 (file)
@@ -72,20 +72,24 @@ error_ret:
        return ret;
 }
 
-static IIO_TRIGGER_NAME_ATTR;
 static DEVICE_ATTR(frequency, S_IRUGO | S_IWUSR,
            iio_trig_periodic_read_freq,
            iio_trig_periodic_write_freq);
 
 static struct attribute *iio_trig_prtc_attrs[] = {
        &dev_attr_frequency.attr,
-       &dev_attr_name.attr,
        NULL,
 };
+
 static const struct attribute_group iio_trig_prtc_attr_group = {
        .attrs = iio_trig_prtc_attrs,
 };
 
+static const struct attribute_group *iio_trig_prtc_attr_groups[] = {
+       &iio_trig_prtc_attr_group,
+       NULL
+};
+
 static void iio_prtc_trigger_poll(void *private_data)
 {
        /* Timestamp is not provided currently */
@@ -103,7 +107,7 @@ static int iio_trig_periodic_rtc_probe(struct platform_device *dev)
        for (i = 0;; i++) {
                if (pdata[i] == NULL)
                        break;
-               trig = iio_allocate_trigger();
+               trig = iio_allocate_trigger("periodic%s", pdata[i]);
                if (!trig) {
                        ret = -ENOMEM;
                        goto error_free_completed_registrations;
@@ -118,25 +122,19 @@ static int iio_trig_periodic_rtc_probe(struct platform_device *dev)
                trig->private_data = trig_info;
                trig->owner = THIS_MODULE;
                trig->set_trigger_state = &iio_trig_periodic_rtc_set_state;
-               trig->name = kasprintf(GFP_KERNEL, "periodic%s", pdata[i]);
-               if (trig->name == NULL) {
-                       ret = -ENOMEM;
-                       goto error_free_trig_info;
-               }
-
                /* RTC access */
                trig_info->rtc
                        = rtc_class_open(pdata[i]);
                if (trig_info->rtc == NULL) {
                        ret = -EINVAL;
-                       goto error_free_name;
+                       goto error_free_trig_info;
                }
                trig_info->task.func = iio_prtc_trigger_poll;
                trig_info->task.private_data = trig;
                ret = rtc_irq_register(trig_info->rtc, &trig_info->task);
                if (ret)
                        goto error_close_rtc;
-               trig->control_attrs = &iio_trig_prtc_attr_group;
+               trig->dev.groups = iio_trig_prtc_attr_groups;
                ret = iio_trigger_register(trig);
                if (ret)
                        goto error_unregister_rtc_irq;
@@ -146,8 +144,6 @@ error_unregister_rtc_irq:
        rtc_irq_unregister(trig_info->rtc, &trig_info->task);
 error_close_rtc:
        rtc_class_close(trig_info->rtc);
-error_free_name:
-       kfree(trig->name);
 error_free_trig_info:
        kfree(trig_info);
 error_put_trigger_and_remove_from_list:
@@ -161,7 +157,6 @@ error_free_completed_registrations:
                trig_info = trig->private_data;
                rtc_irq_unregister(trig_info->rtc, &trig_info->task);
                rtc_class_close(trig_info->rtc);
-               kfree(trig->name);
                kfree(trig_info);
                iio_trigger_unregister(trig);
        }
@@ -180,7 +175,6 @@ static int iio_trig_periodic_rtc_remove(struct platform_device *dev)
                trig_info = trig->private_data;
                rtc_irq_unregister(trig_info->rtc, &trig_info->task);
                rtc_class_close(trig_info->rtc);
-               kfree(trig->name);
                kfree(trig_info);
                iio_trigger_unregister(trig);
        }
index 127a2a33e4db1d8694f100271db9c4f5ecafef3b..47248cd1fa0d6e91df443cf14c90acf31f710de2 100644 (file)
@@ -9,25 +9,92 @@
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/slab.h>
+#include <linux/list.h>
 
 #include "../iio.h"
 #include "../trigger.h"
 
+struct iio_sysfs_trig {
+       struct iio_trigger *trig;
+       int id;
+       struct list_head l;
+};
+
+static LIST_HEAD(iio_sysfs_trig_list);
+static DEFINE_MUTEX(iio_syfs_trig_list_mut);
+
+static int iio_sysfs_trigger_probe(int id);
+static ssize_t iio_sysfs_trig_add(struct device *dev,
+                                 struct device_attribute *attr,
+                                 const char *buf,
+                                 size_t len)
+{
+       int ret;
+       unsigned long input;
+
+       ret = strict_strtoul(buf, 10, &input);
+       if (ret)
+               return ret;
+       ret = iio_sysfs_trigger_probe(input);
+       if (ret)
+               return ret;
+       return len;
+}
+static DEVICE_ATTR(add_trigger, S_IWUSR, NULL, &iio_sysfs_trig_add);
+
+static int iio_sysfs_trigger_remove(int id);
+static ssize_t iio_sysfs_trig_remove(struct device *dev,
+                                    struct device_attribute *attr,
+                                    const char *buf,
+                                    size_t len)
+{
+       int ret;
+       unsigned long input;
+
+       ret = strict_strtoul(buf, 10, &input);
+       if (ret)
+               return ret;
+       ret = iio_sysfs_trigger_remove(input);
+       if (ret)
+               return ret;
+       return len;
+}
+
+static DEVICE_ATTR(remove_trigger, S_IWUSR, NULL, &iio_sysfs_trig_remove);
+
+static struct attribute *iio_sysfs_trig_attrs[] = {
+       &dev_attr_add_trigger.attr,
+       &dev_attr_remove_trigger.attr,
+       NULL,
+};
+
+static const struct attribute_group iio_sysfs_trig_group = {
+       .attrs = iio_sysfs_trig_attrs,
+};
+
+static const struct attribute_group *iio_sysfs_trig_groups[] = {
+       &iio_sysfs_trig_group,
+       NULL
+};
+
+static struct device iio_sysfs_trig_dev = {
+       .bus = &iio_bus_type,
+       .groups = iio_sysfs_trig_groups,
+};
+
 static ssize_t iio_sysfs_trigger_poll(struct device *dev,
                struct device_attribute *attr, const char *buf, size_t count)
 {
        struct iio_trigger *trig = dev_get_drvdata(dev);
-       iio_trigger_poll(trig, 0);
+       iio_trigger_poll_chained(trig, 0);
 
        return count;
 }
 
 static DEVICE_ATTR(trigger_now, S_IWUSR, NULL, iio_sysfs_trigger_poll);
-static IIO_TRIGGER_NAME_ATTR;
 
 static struct attribute *iio_sysfs_trigger_attrs[] = {
        &dev_attr_trigger_now.attr,
-       &dev_attr_name.attr,
        NULL,
 };
 
@@ -35,70 +102,96 @@ static const struct attribute_group iio_sysfs_trigger_attr_group = {
        .attrs = iio_sysfs_trigger_attrs,
 };
 
-static int __devinit iio_sysfs_trigger_probe(struct platform_device *pdev)
+static const struct attribute_group *iio_sysfs_trigger_attr_groups[] = {
+       &iio_sysfs_trigger_attr_group,
+       NULL
+};
+
+static int iio_sysfs_trigger_probe(int id)
 {
-       struct iio_trigger *trig;
+       struct iio_sysfs_trig *t;
        int ret;
-
-       trig = iio_allocate_trigger();
-       if (!trig) {
+       bool foundit = false;
+       mutex_lock(&iio_syfs_trig_list_mut);
+       list_for_each_entry(t, &iio_sysfs_trig_list, l)
+               if (id == t->id) {
+                       foundit = true;
+                       break;
+               }
+       if (foundit) {
+               ret = -EINVAL;
+               goto out1;
+       }
+       t = kmalloc(sizeof(*t), GFP_KERNEL);
+       if (t == NULL) {
                ret = -ENOMEM;
                goto out1;
        }
-
-       trig->control_attrs = &iio_sysfs_trigger_attr_group;
-       trig->owner = THIS_MODULE;
-       trig->name = kasprintf(GFP_KERNEL, "sysfstrig%d", pdev->id);
-       if (trig->name == NULL) {
+       t->id = id;
+       t->trig = iio_allocate_trigger("sysfstrig%d", id);
+       if (!t->trig) {
                ret = -ENOMEM;
-               goto out2;
+               goto free_t;
        }
 
-       ret = iio_trigger_register(trig);
-       if (ret)
-               goto out3;
-
-       platform_set_drvdata(pdev, trig);
+       t->trig->dev.groups = iio_sysfs_trigger_attr_groups;
+       t->trig->owner = THIS_MODULE;
+       t->trig->dev.parent = &iio_sysfs_trig_dev;
 
+       ret = iio_trigger_register(t->trig);
+       if (ret)
+               goto out2;
+       list_add(&t->l, &iio_sysfs_trig_list);
+       __module_get(THIS_MODULE);
+       mutex_unlock(&iio_syfs_trig_list_mut);
        return 0;
-out3:
-       kfree(trig->name);
+
 out2:
-       iio_put_trigger(trig);
+       iio_put_trigger(t->trig);
+free_t:
+       kfree(t);
 out1:
-
+       mutex_unlock(&iio_syfs_trig_list_mut);
        return ret;
 }
 
-static int __devexit iio_sysfs_trigger_remove(struct platform_device *pdev)
+static int iio_sysfs_trigger_remove(int id)
 {
-       struct iio_trigger *trig = platform_get_drvdata(pdev);
+       bool foundit = false;
+       struct iio_sysfs_trig *t;
+       mutex_lock(&iio_syfs_trig_list_mut);
+       list_for_each_entry(t, &iio_sysfs_trig_list, l)
+               if (id == t->id) {
+                       foundit = true;
+                       break;
+               }
+       if (!foundit) {
+               mutex_unlock(&iio_syfs_trig_list_mut);
+               return -EINVAL;
+       }
 
-       iio_trigger_unregister(trig);
-       kfree(trig->name);
-       iio_put_trigger(trig);
+       iio_trigger_unregister(t->trig);
+       iio_free_trigger(t->trig);
 
+       list_del(&t->l);
+       kfree(t);
+       module_put(THIS_MODULE);
+       mutex_unlock(&iio_syfs_trig_list_mut);
        return 0;
 }
 
-static struct platform_driver iio_sysfs_trigger_driver = {
-       .driver = {
-               .name = "iio_sysfs_trigger",
-               .owner = THIS_MODULE,
-       },
-       .probe = iio_sysfs_trigger_probe,
-       .remove = __devexit_p(iio_sysfs_trigger_remove),
-};
 
 static int __init iio_sysfs_trig_init(void)
 {
-       return platform_driver_register(&iio_sysfs_trigger_driver);
+       device_initialize(&iio_sysfs_trig_dev);
+       dev_set_name(&iio_sysfs_trig_dev, "iio_sysfs_trigger");
+       return device_add(&iio_sysfs_trig_dev);
 }
 module_init(iio_sysfs_trig_init);
 
 static void __exit iio_sysfs_trig_exit(void)
 {
-       platform_driver_unregister(&iio_sysfs_trigger_driver);
+       device_unregister(&iio_sysfs_trig_dev);
 }
 module_exit(iio_sysfs_trig_exit);
 
index 81c24d19eb9edf01ff4fbef3070c8e371dcc0dcd..c0c144a2cda10009182c8808478f057590911ab4 100644 (file)
@@ -107,6 +107,9 @@ static irqreturn_t intel_sst_interrupt(int irq, void *context)
        unsigned int size = 0, str_id;
        struct stream_info *stream ;
 
+       /* Do not handle interrupt in suspended state */
+       if (drv->sst_state == SST_SUSPENDED)
+               return IRQ_NONE;
        /* Interrupt arrived, check src */
        isr.full = sst_shim_read(drv->shim, SST_ISRX);
 
@@ -316,14 +319,30 @@ static int __devinit intel_sst_probe(struct pci_dev *pci,
        if (sst_drv_ctx->pci_id == SST_MRST_PCI_ID) {
                ret = misc_register(&lpe_dev);
                if (ret) {
-                       pr_err("couldn't register misc driver\n");
+                       pr_err("couldn't register LPE device\n");
                        goto do_free_misc;
                }
+       } else if (sst_drv_ctx->pci_id == SST_MFLD_PCI_ID) {
+               u32 csr;
+
+               /*allocate mem for fw context save during suspend*/
+               sst_drv_ctx->fw_cntx = kzalloc(FW_CONTEXT_MEM, GFP_KERNEL);
+               if (!sst_drv_ctx->fw_cntx) {
+                       ret = -ENOMEM;
+                       goto do_free_misc;
+               }
+               /*setting zero as that is valid mem to restore*/
+               sst_drv_ctx->fw_cntx_size = 0;
+
+               /*set lpe start clock and ram size*/
+               csr = sst_shim_read(sst_drv_ctx->shim, SST_CSR);
+               csr |= 0x30060; /*remove the clock ratio after fw fix*/
+               sst_shim_write(sst_drv_ctx->shim, SST_CSR, csr);
        }
        sst_drv_ctx->lpe_stalled = 0;
-       pm_runtime_set_active(&pci->dev);
-       pm_runtime_enable(&pci->dev);
+       pci_set_drvdata(pci, sst_drv_ctx);
        pm_runtime_allow(&pci->dev);
+       pm_runtime_put_noidle(&pci->dev);
        pr_debug("...successfully done!!!\n");
        return ret;
 
@@ -355,7 +374,8 @@ free_mad_wq:
        destroy_workqueue(sst_drv_ctx->mad_wq);
 do_free_drv_ctx:
        kfree(sst_drv_ctx);
-       pr_err("Probe failed with 0x%x\n", ret);
+       sst_drv_ctx = NULL;
+       pr_err("Probe failed with %d\n", ret);
        return ret;
 }
 
@@ -369,35 +389,76 @@ do_free_drv_ctx:
 */
 static void __devexit intel_sst_remove(struct pci_dev *pci)
 {
+       pm_runtime_get_noresume(&pci->dev);
+       pm_runtime_forbid(&pci->dev);
        pci_dev_put(sst_drv_ctx->pci);
        mutex_lock(&sst_drv_ctx->sst_lock);
        sst_drv_ctx->sst_state = SST_UN_INIT;
        mutex_unlock(&sst_drv_ctx->sst_lock);
        misc_deregister(&lpe_ctrl);
-       if (sst_drv_ctx->pci_id == SST_MRST_PCI_ID)
-               misc_deregister(&lpe_dev);
        free_irq(pci->irq, sst_drv_ctx);
        iounmap(sst_drv_ctx->dram);
        iounmap(sst_drv_ctx->iram);
        iounmap(sst_drv_ctx->mailbox);
        iounmap(sst_drv_ctx->shim);
        sst_drv_ctx->pmic_state = SND_MAD_UN_INIT;
-       if (sst_drv_ctx->pci_id == SST_MRST_PCI_ID)
+       if (sst_drv_ctx->pci_id == SST_MRST_PCI_ID) {
+               misc_deregister(&lpe_dev);
                kfree(sst_drv_ctx->mmap_mem);
+       } else
+               kfree(sst_drv_ctx->fw_cntx);
        flush_scheduled_work();
        destroy_workqueue(sst_drv_ctx->process_reply_wq);
        destroy_workqueue(sst_drv_ctx->process_msg_wq);
        destroy_workqueue(sst_drv_ctx->post_msg_wq);
        destroy_workqueue(sst_drv_ctx->mad_wq);
-       kfree(sst_drv_ctx);
-       pci_release_region(pci, 1);
-       pci_release_region(pci, 2);
-       pci_release_region(pci, 3);
-       pci_release_region(pci, 4);
-       pci_release_region(pci, 5);
+       kfree(pci_get_drvdata(pci));
+       sst_drv_ctx = NULL;
+       pci_release_regions(pci);
+       pci_disable_device(pci);
        pci_set_drvdata(pci, NULL);
 }
 
+void sst_save_dsp_context(void)
+{
+       struct snd_sst_ctxt_params fw_context;
+       unsigned int pvt_id, i;
+       struct ipc_post *msg = NULL;
+
+       /*check cpu type*/
+       if (sst_drv_ctx->pci_id != SST_MFLD_PCI_ID)
+               return;
+               /*not supported for rest*/
+       if (sst_drv_ctx->sst_state != SST_FW_RUNNING) {
+               pr_debug("fw not running no context save ...\n");
+               return;
+       }
+
+       /*send msg to fw*/
+       if (sst_create_large_msg(&msg))
+               return;
+       pvt_id = sst_assign_pvt_id(sst_drv_ctx);
+       i = sst_get_block_stream(sst_drv_ctx);
+       sst_drv_ctx->alloc_block[i].sst_id = pvt_id;
+       sst_fill_header(&msg->header, IPC_IA_GET_FW_CTXT, 1, pvt_id);
+       msg->header.part.data = sizeof(fw_context) + sizeof(u32);
+       fw_context.address = virt_to_phys((void *)sst_drv_ctx->fw_cntx);
+       fw_context.size = FW_CONTEXT_MEM;
+       memcpy(msg->mailbox_data, &msg->header, sizeof(u32));
+       memcpy(msg->mailbox_data + sizeof(u32),
+                               &fw_context, sizeof(fw_context));
+       spin_lock(&sst_drv_ctx->list_spin_lock);
+       list_add_tail(&msg->node, &sst_drv_ctx->ipc_dispatch_list);
+       spin_unlock(&sst_drv_ctx->list_spin_lock);
+       sst_post_message(&sst_drv_ctx->ipc_post_msg_wq);
+       /*wait for reply*/
+       if (sst_wait_timeout(sst_drv_ctx, &sst_drv_ctx->alloc_block[i]))
+               pr_debug("err fw context save timeout  ...\n");
+       sst_drv_ctx->alloc_block[i].sst_id = BLOCK_UNINIT;
+       pr_debug("fw context saved  ...\n");
+       return;
+}
+
 /* Power Management */
 /*
 * intel_sst_suspend - PCI suspend function
@@ -417,6 +478,8 @@ int intel_sst_suspend(struct pci_dev *pci, pm_message_t state)
                pr_err("active streams,not able to suspend\n");
                return -EBUSY;
        }
+       /*save fw context*/
+       sst_save_dsp_context();
        /*Assert RESET on LPE Processor*/
        csr.full = sst_shim_read(sst_drv_ctx->shim, SST_CSR);
        csr.full = csr.full | 0x2;
@@ -461,18 +524,45 @@ int intel_sst_resume(struct pci_dev *pci)
        return 0;
 }
 
+/* The runtime_suspend/resume is pretty much similar to the legacy suspend/resume with the noted exception below:
+ * The PCI core takes care of taking the system through D3hot and restoring it back to D0 and so there is
+ * no need to duplicate that here.
+ */
 static int intel_sst_runtime_suspend(struct device *dev)
 {
-       struct pci_dev *pci_dev = to_pci_dev(dev);
-       pr_debug("runtime_suspend called\n");
-       return intel_sst_suspend(pci_dev, PMSG_SUSPEND);
+       union config_status_reg csr;
+
+       pr_debug("intel_sst_runtime_suspend called\n");
+       if (sst_drv_ctx->stream_cnt) {
+               pr_err("active streams,not able to suspend\n");
+               return -EBUSY;
+       }
+       /*save fw context*/
+       sst_save_dsp_context();
+       /*Assert RESET on LPE Processor*/
+       csr.full = sst_shim_read(sst_drv_ctx->shim, SST_CSR);
+       csr.full = csr.full | 0x2;
+       /* Move the SST state to Suspended */
+       mutex_lock(&sst_drv_ctx->sst_lock);
+       sst_drv_ctx->sst_state = SST_SUSPENDED;
+       sst_shim_write(sst_drv_ctx->shim, SST_CSR, csr.full);
+       mutex_unlock(&sst_drv_ctx->sst_lock);
+       return 0;
 }
 
 static int intel_sst_runtime_resume(struct device *dev)
 {
-       struct pci_dev *pci_dev = to_pci_dev(dev);
-       pr_debug("runtime_resume called\n");
-       return intel_sst_resume(pci_dev);
+
+       pr_debug("intel_sst_runtime_resume called\n");
+       if (sst_drv_ctx->sst_state != SST_SUSPENDED) {
+               pr_err("SST is not in suspended state\n");
+               return 0;
+       }
+
+       mutex_lock(&sst_drv_ctx->sst_lock);
+       sst_drv_ctx->sst_state = SST_UN_INIT;
+       mutex_unlock(&sst_drv_ctx->sst_lock);
+       return 0;
 }
 
 static int intel_sst_runtime_idle(struct device *dev)
@@ -545,6 +635,7 @@ static void __exit intel_sst_exit(void)
        pci_unregister_driver(&driver);
 
        pr_debug("driver unloaded\n");
+       sst_drv_ctx = NULL;
        return;
 }
 
index cb03ff7d1a21451921884fdacf7b589c35beaf21..4ad2829105a7cea8016f9f0a5da31b51a09eab35 100644 (file)
  *  This file is shared between the SST and MAD drivers
  */
 #include "intel_sst_ioctl.h"
+#include <sound/jack.h>
 
 #define SST_CARD_NAMES "intel_mid_card"
 
+#define MFLD_MAX_HW_CH 4
 /* control list Pmic & Lpe */
 /* Input controls */
 enum port_status {
@@ -82,12 +84,16 @@ struct snd_pmic_ops {
        int num_channel;
        int input_dev_id;
        int mute_status;
-       int pb_on;
+       struct mutex lock;
+       int pb_on, pbhs_on;
        int cap_on;
        int output_dev_id;
+       int lineout_dev_id, line_out_names_cnt;
+       int prev_lineout_dev_id;
+       bool jack_interrupt_status;
        int (*set_input_dev) (u8 value);
        int (*set_output_dev) (u8 value);
-
+       int (*set_lineout_dev) (u8 value);
        int (*set_mute) (int dev_id, u8 value);
        int (*get_mute) (int dev_id, u8 *value);
 
@@ -103,11 +109,30 @@ struct snd_pmic_ops {
 
        int (*power_up_pmic_pb) (unsigned int port);
        int (*power_up_pmic_cp) (unsigned int port);
-       int (*power_down_pmic_pb) (void);
-       int (*power_down_pmic_cp) (void);
+       int (*power_down_pmic_pb) (unsigned int device);
+       int (*power_down_pmic_cp) (unsigned int device);
        int (*power_down_pmic) (void);
+       void (*pmic_irq_cb) (void *cb_data, u8 value);
+       void (*pmic_irq_enable)(void *data);
+       int (*pmic_jack_enable) (void);
+       int (*pmic_get_mic_bias)(void *intelmaddata);
+       int (*pmic_set_headset_state)(int state);
+
+       unsigned int hw_dmic_map[MFLD_MAX_HW_CH];
+       unsigned int available_dmics;
+       int (*set_hw_dmic_route) (u8 index);
+
+       int gpio_amp;
 };
 
+extern void sst_mad_send_jack_report(struct snd_jack *jack,
+                                    int buttonpressevent,
+                                    int status);
+
+
+int intemad_set_headset_state(int state);
+int intelmad_get_mic_bias(void);
+
 struct intel_sst_pcm_control {
        int (*open) (struct snd_sst_params *str_param);
        int (*device_control) (int cmd, void *arg);
index 1d0621260ea89a594ff840b7d45630c3c1840f6a..b8c7ddbd7cf3c0a5d83118833f7095099e7a1f10 100644 (file)
@@ -418,10 +418,6 @@ static int snd_sst_fill_kernel_list(struct stream_info *stream,
        static int sent_offset;
        static unsigned long sent_index;
 
-       stream_bufs = kzalloc(sizeof(*stream_bufs), GFP_KERNEL);
-       if (!stream_bufs)
-               return -ENOMEM;
-       stream_bufs->addr = sst_drv_ctx->mmap_mem;
 #ifdef CONFIG_MRST_RAR_HANDLER
        if (stream->ops == STREAM_OPS_PLAYBACK_DRM) {
                for (index = stream->sg_index; index < nr_segs; index++) {
@@ -448,6 +444,10 @@ static int snd_sst_fill_kernel_list(struct stream_info *stream,
                return retval;
        }
 #endif
+       stream_bufs = kzalloc(sizeof(*stream_bufs), GFP_KERNEL);
+       if (!stream_bufs)
+               return -ENOMEM;
+       stream_bufs->addr = sst_drv_ctx->mmap_mem;
        mmap_len = sst_drv_ctx->mmap_len;
        stream_bufs->addr = sst_drv_ctx->mmap_mem;
        bufp = stream->cur_ptr;
@@ -961,6 +961,34 @@ free_mem:
        return retval;
 }
 
+
+int sst_ioctl_tuning_params(unsigned long arg)
+{
+       struct snd_sst_tuning_params params;
+       struct ipc_post *msg;
+
+       if (copy_from_user(&params, (void __user *)arg, sizeof(params)))
+               return -EFAULT;
+       if (params.size > SST_MAILBOX_SIZE)
+               return -ENOMEM;
+       pr_debug("Parameter %d, Stream %d, Size %d\n", params.type,
+                       params.str_id, params.size);
+       if (sst_create_large_msg(&msg))
+               return -ENOMEM;
+
+       sst_fill_header(&msg->header, IPC_IA_TUNING_PARAMS, 1, params.str_id);
+       msg->header.part.data = sizeof(u32) + sizeof(params) + params.size;
+       memcpy(msg->mailbox_data, &msg->header.full, sizeof(u32));
+       memcpy(msg->mailbox_data + sizeof(u32), &params, sizeof(params));
+       if (copy_from_user(msg->mailbox_data + sizeof(params),
+                       (void __user *)(unsigned long)params.addr,
+                       params.size)) {
+               kfree(msg->mailbox_data);
+               kfree(msg);
+               return -EFAULT;
+       }
+       return sst_send_algo_ipc(&msg);
+}
 /**
  * intel_sst_ioctl - receives the device ioctl's
  * @file_ptr:pointer to file
@@ -1412,6 +1440,15 @@ free_iobufs:
                }
                retval = intel_sst_ioctl_dsp(cmd, arg);
                break;
+
+       case _IOC_NR(SNDRV_SST_TUNING_PARAMS):
+               if (minor != AM_MODULE) {
+                       retval = -EBADRQC;
+                       break;
+               }
+               retval = sst_ioctl_tuning_params(arg);
+               break;
+
        default:
                retval = -EINVAL;
        }
index 0a60e865b69626fe3a1c8f1628bd715eea004bd0..f8e9da6b3097822eac4fe9a8cd7eb94bed467d2b 100644 (file)
@@ -28,8 +28,8 @@
  *  Common private declarations for SST
  */
 
-#define SST_DRIVER_VERSION "1.2.09"
-#define SST_VERSION_NUM 0x1209
+#define SST_DRIVER_VERSION "1.2.17"
+#define SST_VERSION_NUM 0x1217
 
 /* driver names */
 #define SST_DRV_NAME "intel_sst_driver"
@@ -37,6 +37,7 @@
 #define SST_MFLD_PCI_ID 0x082F
 #define PCI_ID_LENGTH 4
 #define SST_SUSPEND_DELAY 2000
+#define FW_CONTEXT_MEM (64*1024)
 
 enum sst_states {
        SST_FW_LOADED = 1,
@@ -94,7 +95,7 @@ enum sst_ram_type {
 /* SST shim registers to structure mapping  */
 union config_status_reg {
        struct {
-               u32 rsvd0:1;
+               u32 mfld_strb:1;
                u32 sst_reset:1;
                u32 hw_rsvd:3;
                u32 sst_clk:2;
@@ -417,6 +418,8 @@ struct intel_sst_drv {
        unsigned int            audio_start;
        dev_t                   devt_d, devt_c;
        unsigned int            max_streams;
+       unsigned int            *fw_cntx;
+       unsigned int            fw_cntx_size;
 };
 
 extern struct intel_sst_drv *sst_drv_ctx;
index 971588ce26d3dd44ae5f726b427898e1676b3023..1021477f238db29b5c244f76f35d493aee3018d4 100644 (file)
@@ -105,21 +105,28 @@ void free_stream_context(unsigned int str_id)
        if (!sst_validate_strid(str_id)) {
                /* str_id is valid, so stream is alloacted */
                stream = &sst_drv_ctx->streams[str_id];
+               if (sst_free_stream(str_id))
+                       sst_clean_stream(&sst_drv_ctx->streams[str_id]);
                if (stream->ops == STREAM_OPS_PLAYBACK ||
                                stream->ops == STREAM_OPS_PLAYBACK_DRM) {
                        sst_drv_ctx->pb_streams--;
-                       if (sst_drv_ctx->pb_streams == 0)
-                               sst_drv_ctx->scard_ops->power_down_pmic_pb();
+                       if (sst_drv_ctx->pci_id == SST_MFLD_PCI_ID)
+                               sst_drv_ctx->scard_ops->power_down_pmic_pb(
+                                               stream->device);
+                       else {
+                               if (sst_drv_ctx->pb_streams == 0)
+                                       sst_drv_ctx->scard_ops->
+                                       power_down_pmic_pb(stream->device);
+                       }
                } else if (stream->ops == STREAM_OPS_CAPTURE) {
                        sst_drv_ctx->cp_streams--;
                        if (sst_drv_ctx->cp_streams == 0)
-                               sst_drv_ctx->scard_ops->power_down_pmic_cp();
+                               sst_drv_ctx->scard_ops->power_down_pmic_cp(
+                                               stream->device);
                }
                if (sst_drv_ctx->pb_streams == 0
                                && sst_drv_ctx->cp_streams == 0)
                        sst_drv_ctx->scard_ops->power_down_pmic();
-               if (sst_free_stream(str_id))
-                       sst_clean_stream(&sst_drv_ctx->streams[str_id]);
        }
 }
 
@@ -276,8 +283,8 @@ void sst_process_mad_ops(struct work_struct *work)
                retval = sst_resume_stream(mad_ops->stream_id);
                break;
        case SST_SND_DROP:
-/*             retval = sst_drop_stream(mad_ops->stream_id);
-*/             break;
+               retval = sst_drop_stream(mad_ops->stream_id);
+               break;
        case SST_SND_START:
                        pr_debug("SST Debug: start stream\n");
                retval = sst_start_stream(mad_ops->stream_id);
@@ -519,6 +526,9 @@ int register_sst_card(struct intel_sst_card_ops *card)
                pr_err("Repeat for registration..denied\n");
                return -EBADRQC;
        }
+       /* The ASoC code doesn't set scard_ops */
+       if (sst_drv_ctx->scard_ops)
+               sst_drv_ctx->scard_ops->card_status = SND_CARD_UN_INIT;
        return 0;
 }
 EXPORT_SYMBOL_GPL(register_sst_card);
index bffe4c6e2928065a1822b401279e8fb5746d2b36..a89e1ade847403b8ceec2353c27b9aba8cc49dd9 100644 (file)
@@ -73,7 +73,8 @@ static int intel_sst_reset_dsp_medfield(void)
        union config_status_reg csr;
 
        pr_debug("Resetting the DSP in medfield\n");
-       csr.full = 0x048303E2;
+       csr.full = sst_shim_read(sst_drv_ctx->shim, SST_CSR);
+       csr.full |= 0x382;
        sst_shim_write(sst_drv_ctx->shim, SST_CSR, csr.full);
 
        return 0;
@@ -109,11 +110,16 @@ static int sst_start_medfield(void)
 {
        union config_status_reg csr;
 
-       csr.full = 0x04830062;
+       csr.full = sst_shim_read(sst_drv_ctx->shim, SST_CSR);
+       csr.part.bypass = 0;
        sst_shim_write(sst_drv_ctx->shim, SST_CSR, csr.full);
-       csr.full = 0x04830063;
+       csr.full = sst_shim_read(sst_drv_ctx->shim, SST_CSR);
+       csr.part.mfld_strb = 1;
        sst_shim_write(sst_drv_ctx->shim, SST_CSR, csr.full);
-       csr.full = 0x04830061;
+       csr.full = sst_shim_read(sst_drv_ctx->shim, SST_CSR);
+       csr.part.run_stall = 0;
+       csr.part.sst_reset = 0;
+       pr_debug("Starting the DSP_medfld %x\n", csr.full);
        sst_shim_write(sst_drv_ctx->shim, SST_CSR, csr.full);
        pr_debug("Starting the DSP_medfld\n");
 
index 0f0c5bbc5f4bed14066ad0d49b9fbf001271f183..5d0cc56aaef9f070948a6b0a5a96a968b177a8fb 100644 (file)
@@ -56,6 +56,8 @@
 #define IPC_IA_GET_FW_VERSION 0x04
 #define IPC_IA_GET_FW_BUILD_INF 0x05
 #define IPC_IA_GET_FW_INFO 0x06
+#define IPC_IA_GET_FW_CTXT 0x07
+#define IPC_IA_SET_FW_CTXT 0x08
 
 /* I2L Codec Config/control msgs */
 #define IPC_IA_SET_CODEC_PARAMS 0x10
@@ -69,6 +71,7 @@
 #define IPC_IA_DECODE_FRAMES 0x18
 
 #define IPC_IA_ALG_PARAMS 0x1A
+#define IPC_IA_TUNING_PARAMS 0x1B
 
 /* I2L Stream config/control msgs */
 #define IPC_IA_ALLOC_STREAM 0x20 /* Allocate a stream ID */
@@ -406,4 +409,8 @@ struct ipc_post {
        char *mailbox_data;
 };
 
+struct snd_sst_ctxt_params {
+       u32 address; /* Physical Address in DDR where the context is stored */
+       u32 size; /* size of the context */
+};
 #endif /* __INTEL_SST_FW_IPC_H__ */
index bebc395a3c1f45787f98f7263b8d0d2caa1451a3..5da5ee092c69d9ee8c62059963136143e8330876 100644 (file)
@@ -400,6 +400,13 @@ struct snd_sst_dbufs  {
        struct snd_sst_buffs *obufs;
 };
 
+struct snd_sst_tuning_params {
+       __u8 type;
+       __u8 str_id;
+       __u8 size;
+       __u8 rsvd;
+       __aligned_u64 addr;
+} __attribute__ ((packed));
 /*IOCTL defined here */
 /*SST MMF IOCTLS only */
 #define SNDRV_SST_STREAM_SET_PARAMS _IOR('L', 0x00, \
@@ -428,5 +435,6 @@ struct snd_sst_dbufs  {
 /*DSP Ioctls on /dev/intel_sst_ctrl only*/
 #define SNDRV_SST_SET_ALGO     _IOW('L', 0x30,  struct snd_ppp_params *)
 #define SNDRV_SST_GET_ALGO     _IOWR('L', 0x31,  struct snd_ppp_params *)
+#define SNDRV_SST_TUNING_PARAMS        _IOW('L', 0x32,  struct snd_sst_tuning_params *)
 
 #endif /* __INTEL_SST_IOCTL_H__ */
index 0742dde2685deaca001ef10d9cb9319f4b4492b0..5c3444f6ab4146ba2f828921d9f8d0482a049cbb 100644 (file)
@@ -154,6 +154,37 @@ void sst_clear_interrupt(void)
        sst_shim_write(sst_drv_ctx->shim, SST_IMRX, imr.full);
 }
 
+void sst_restore_fw_context(void)
+{
+       struct snd_sst_ctxt_params fw_context;
+       struct ipc_post *msg = NULL;
+
+       pr_debug("restore_fw_context\n");
+       /*check cpu type*/
+       if (sst_drv_ctx->pci_id != SST_MFLD_PCI_ID)
+               return;
+               /*not supported for rest*/
+       if (!sst_drv_ctx->fw_cntx_size)
+               return;
+               /*nothing to restore*/
+       pr_debug("restoring context......\n");
+       /*send msg to fw*/
+       if (sst_create_large_msg(&msg))
+               return;
+
+       sst_fill_header(&msg->header, IPC_IA_SET_FW_CTXT, 1, 0);
+       msg->header.part.data = sizeof(fw_context) + sizeof(u32);
+       fw_context.address = virt_to_phys((void *)sst_drv_ctx->fw_cntx);
+       fw_context.size = sst_drv_ctx->fw_cntx_size;
+       memcpy(msg->mailbox_data, &msg->header, sizeof(u32));
+       memcpy(msg->mailbox_data + sizeof(u32),
+                               &fw_context, sizeof(fw_context));
+       spin_lock(&sst_drv_ctx->list_spin_lock);
+       list_add_tail(&msg->node, &sst_drv_ctx->ipc_dispatch_list);
+       spin_unlock(&sst_drv_ctx->list_spin_lock);
+       sst_post_message(&sst_drv_ctx->ipc_post_msg_wq);
+       return;
+}
 /*
  * process_fw_init - process the FW init msg
  *
@@ -184,13 +215,13 @@ int process_fw_init(struct sst_ipc_msg_wq *msg)
        sst_drv_ctx->sst_state = SST_FW_RUNNING;
        sst_drv_ctx->lpe_stalled = 0;
        mutex_unlock(&sst_drv_ctx->sst_lock);
-       pr_debug("FW Version %x.%x\n",
-                       init->fw_version.major, init->fw_version.minor);
-       pr_debug("Build No %x Type %x\n",
-                       init->fw_version.build, init->fw_version.type);
+       pr_debug("FW Version %02x.%02x.%02x\n", init->fw_version.major,
+                       init->fw_version.minor, init->fw_version.build);
+       pr_debug("Build Type %x\n", init->fw_version.type);
        pr_debug(" Build date %s Time %s\n",
                        init->build_info.date, init->build_info.time);
        sst_wake_up_alloc_block(sst_drv_ctx, FW_DWNL_ID, retval, NULL);
+       sst_restore_fw_context();
        return retval;
 }
 /**
@@ -385,6 +416,24 @@ void sst_process_reply(struct work_struct *work)
                }
                break;
        }
+
+       case IPC_IA_TUNING_PARAMS: {
+               pr_debug("sst:IPC_TUNING_PARAMS resp: %x\n", msg->header.full);
+               pr_debug("data value %x\n", msg->header.part.data);
+               if (msg->header.part.large) {
+                       pr_debug("alg set failed\n");
+                       sst_drv_ctx->ppp_params_blk.ret_code =
+                                                       -msg->header.part.data;
+               } else {
+                       pr_debug("alg set success\n");
+                       sst_drv_ctx->ppp_params_blk.ret_code = 0;
+               }
+               if (sst_drv_ctx->ppp_params_blk.on == true) {
+                       sst_drv_ctx->ppp_params_blk.condition = true;
+                       wake_up(&sst_drv_ctx->wait_queue);
+               }
+       }
+
        case IPC_IA_GET_FW_INFO: {
                struct snd_sst_fw_info *fw_info =
                        (struct snd_sst_fw_info *)msg->mailbox;
@@ -615,12 +664,18 @@ void sst_process_reply(struct work_struct *work)
                break;
 
        case IPC_IA_FREE_STREAM:
+               str_info = &sst_drv_ctx->streams[str_id];
                if (!msg->header.part.data) {
                        pr_debug("Stream %d freed\n", str_id);
                } else {
                        pr_err("Free for %d ret error %x\n",
                                       str_id, msg->header.part.data);
                }
+               if (str_info->ctrl_blk.on == true) {
+                       str_info->ctrl_blk.on = false;
+                       str_info->ctrl_blk.condition = true;
+                       wake_up(&sst_drv_ctx->wait_queue);
+               }
                break;
        case IPC_IA_ALLOC_STREAM: {
                /* map to stream, call play */
@@ -699,6 +754,17 @@ void sst_process_reply(struct work_struct *work)
        case IPC_IA_START_STREAM:
                pr_debug("reply for START STREAM %x\n", msg->header.full);
                break;
+
+       case IPC_IA_GET_FW_CTXT:
+               pr_debug("reply for get fw ctxt  %x\n", msg->header.full);
+               if (msg->header.part.data)
+                       sst_drv_ctx->fw_cntx_size = 0;
+               else
+                       sst_drv_ctx->fw_cntx_size = *sst_drv_ctx->fw_cntx;
+               pr_debug("fw copied data %x\n", sst_drv_ctx->fw_cntx_size);
+               sst_wake_up_alloc_block(
+                       sst_drv_ctx, str_id, msg->header.part.data, NULL);
+               break;
        default:
                /* Illegal case */
                pr_err("process reply:default = %x\n", msg->header.full);
index 01f8c3b1cf74f1a68bbad8b99139a742f1b12ce6..e034bea56f142580656d083906c1fe41dc6a8914 100644 (file)
@@ -203,7 +203,7 @@ int sst_create_large_msg(struct ipc_post **arg)
                kfree(msg);
                pr_err("kzalloc mailbox_data failed");
                return -ENOMEM;
-       };
+       }
        *arg = msg;
        return 0;
 }
index dd58be5b197524dd8ff0d521f963b193393e18f9..be4565e74f8c20739e8639c04f6dca305d3d106d 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/pci.h>
 #include <linux/firmware.h>
 #include <linux/sched.h>
+#include <linux/delay.h>
 #include "intel_sst_ioctl.h"
 #include "intel_sst.h"
 #include "intel_sst_fw_ipc.h"
@@ -47,7 +48,7 @@
  */
 int sst_check_device_type(u32 device, u32 num_chan, u32 *pcm_slot)
 {
-       if (device > MAX_NUM_STREAMS_MFLD) {
+       if (device >= MAX_NUM_STREAMS_MFLD) {
                pr_debug("device type invalid %d\n", device);
                return -EINVAL;
        }
@@ -72,6 +73,8 @@ int sst_check_device_type(u32 device, u32 num_chan, u32 *pcm_slot)
                        *pcm_slot = 0x07;
                else if (device == SND_SST_DEVICE_CAPTURE && num_chan == 4)
                        *pcm_slot = 0x0F;
+               else if (device == SND_SST_DEVICE_CAPTURE && num_chan > 4)
+                       *pcm_slot = 0x1F;
                else {
                        pr_debug("No condition satisfied.. ret err\n");
                        return -EINVAL;
@@ -519,10 +522,6 @@ int sst_drain_stream(int str_id)
        str_info->data_blk.on = true;
        retval = sst_wait_interruptible(sst_drv_ctx, &str_info->data_blk);
        str_info->need_draining = false;
-       if (retval == -SST_ERR_INVALID_STREAM_ID) {
-               retval = -EINVAL;
-               sst_clean_stream(str_info);
-       }
        return retval;
 }
 
@@ -563,6 +562,12 @@ int sst_free_stream(int str_id)
                        str_info->data_blk.ret_code = 0;
                        wake_up(&sst_drv_ctx->wait_queue);
                }
+               str_info->data_blk.on = true;
+               str_info->data_blk.condition = false;
+               retval = sst_wait_interruptible_timeout(sst_drv_ctx,
+                               &str_info->ctrl_blk, SST_BLOCK_TIMEOUT);
+               pr_debug("wait for free returned %d\n", retval);
+               msleep(100);
                mutex_lock(&sst_drv_ctx->stream_lock);
                sst_clean_stream(str_info);
                mutex_unlock(&sst_drv_ctx->stream_lock);
index d5f07b878828196560d8808f7e8a1b51213875ea..2be58c5cba028b07d65f90004820dee17c3f632d 100644 (file)
@@ -363,7 +363,6 @@ int sst_parse_target(struct snd_sst_slot_info *slot)
                                pr_err("SST_Activate_target_fail\n");
                        else
                                pr_err("SST_Activate_target_pass\n");
-               return retval;
        } else if (slot->action == SND_SST_PORT_PREPARE &&
                        slot->device_type == SND_SST_DEVICE_PCM) {
                                retval = sst_prepare_target(slot);
@@ -371,12 +370,11 @@ int sst_parse_target(struct snd_sst_slot_info *slot)
                                pr_err("SST_prepare_target_fail\n");
                        else
                                pr_err("SST_prepare_target_pass\n");
-                       return retval;
        } else {
                pr_err("slot_action : %d, device_type: %d\n",
                                slot->action, slot->device_type);
-               return retval;
        }
+       return retval;
 }
 
 int sst_send_target(struct snd_sst_target_device *target)
@@ -886,8 +884,7 @@ static int sst_prepare_input_buffers_rar(struct stream_info *str_info,
                        int *input_index, int *in_copied,
                        int *input_index_valid_size, int *new_entry_flag)
 {
-       int retval = 0;
-       int i;
+       int retval = 0, i;
 
        if (str_info->ops == STREAM_OPS_PLAYBACK_DRM) {
                struct RAR_buffer rar_buffers;
@@ -924,7 +921,6 @@ static int sst_prepare_input_buffers_rar(struct stream_info *str_info,
        return retval;
 }
 #endif
-
 /*This function is used to prepare the kernel input buffers with contents
 before sending for decode*/
 static int sst_prepare_input_buffers(struct stream_info *str_info,
index ebb6d03552c4b5282cb748d6ce429fd5c1f9bf3c..25656ad2802e0c02003ac1452d0ad80e4d72e7ea 100644 (file)
 #include <linux/interrupt.h>
 #include <linux/sched.h>
 #include <linux/firmware.h>
+#include <linux/input.h>
 #include <sound/control.h>
 #include <asm/mrst.h>
 #include <sound/pcm.h>
-#include "jack.h"
+#include <sound/jack.h>
 #include <sound/pcm_params.h>
 #include <sound/initval.h>
+#include <linux/gpio.h>
 #include "intel_sst.h"
 #include "intel_sst_ioctl.h"
 #include "intel_sst_fw_ipc.h"
 #include "intel_sst_common.h"
 #include "intelmid_snd_control.h"
+#include "intelmid_adc_control.h"
 #include "intelmid.h"
 
 MODULE_AUTHOR("Vinod Koul <vinod.koul@intel.com>");
@@ -65,7 +68,14 @@ MODULE_PARM_DESC(card_id, "ID string for INTELMAD soundcard.");
 
 int    sst_card_vendor_id;
 int intelmid_audio_interrupt_enable;/*checkpatch fix*/
-
+struct snd_intelmad *intelmad_drv;
+
+#define INFO(_cpu_id, _irq_cache, _size) \
+       ((kernel_ulong_t)&(struct snd_intelmad_probe_info) {    \
+               .cpu_id = (_cpu_id),                    \
+               .irq_cache = (_irq_cache),                      \
+               .size = (_size),                                \
+       })
 /* Data path functionalities */
 static struct snd_pcm_hardware snd_intelmad_stream = {
        .info = (SNDRV_PCM_INFO_INTERLEAVED |
@@ -187,7 +197,7 @@ static int snd_intelmad_pcm_prepare(struct snd_pcm_substream *substream)
                return ret_val;
        }
 
-        ret_val = snd_intelmad_alloc_stream(substream);
+       ret_val = snd_intelmad_alloc_stream(substream);
        if (ret_val < 0)
                return ret_val;
        stream->dbg_cum_bytes = 0;
@@ -326,6 +336,16 @@ static int snd_intelmad_open(struct snd_pcm_substream *substream,
        runtime = substream->runtime;
        /* set the runtime hw parameter with local snd_pcm_hardware struct */
        runtime->hw = snd_intelmad_stream;
+       if (intelmaddata->cpu_id == CPU_CHIP_LINCROFT) {
+               /*
+                * MRST firmware currently denies stereo recording requests.
+                */
+               if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
+                       runtime->hw.formats = (SNDRV_PCM_FMTBIT_S16 |
+                                              SNDRV_PCM_FMTBIT_U16);
+                       runtime->hw.channels_max = 1;
+               }
+       }
        if (intelmaddata->cpu_id == CPU_CHIP_PENWELL) {
                runtime->hw = snd_intelmad_stream;
                runtime->hw.rates = SNDRV_PCM_RATE_48000;
@@ -426,7 +446,55 @@ static struct snd_pcm_ops snd_intelmad_capture_ops = {
        .pointer = snd_intelmad_pcm_pointer,
 };
 
+int intelmad_get_mic_bias(void)
+{
+       struct snd_pmic_ops *pmic_ops;
+
+       if (!intelmad_drv || !intelmad_drv->sstdrv_ops)
+               return -ENODEV;
+       pmic_ops = intelmad_drv->sstdrv_ops->scard_ops;
+       if (pmic_ops && pmic_ops->pmic_get_mic_bias)
+               return pmic_ops->pmic_get_mic_bias(intelmad_drv);
+       else
+               return -ENODEV;
+}
+EXPORT_SYMBOL_GPL(intelmad_get_mic_bias);
+
+int intelmad_set_headset_state(int state)
+{
+       struct snd_pmic_ops *pmic_ops;
+
+       if (!intelmad_drv || !intelmad_drv->sstdrv_ops)
+               return -ENODEV;
+       pmic_ops = intelmad_drv->sstdrv_ops->scard_ops;
+       if (pmic_ops && pmic_ops->pmic_set_headset_state)
+               return pmic_ops->pmic_set_headset_state(state);
+       else
+               return -ENODEV;
+}
+EXPORT_SYMBOL_GPL(intelmad_set_headset_state);
+
+void sst_process_mad_jack_detection(struct work_struct *work)
+{
+       u8 interrupt_status;
+       struct mad_jack_msg_wq *mad_jack_detect =
+                       container_of(work, struct mad_jack_msg_wq, wq);
+
+       struct snd_intelmad *intelmaddata =
+                       mad_jack_detect->intelmaddata;
 
+       if (!intelmaddata)
+               return;
+
+       interrupt_status = mad_jack_detect->intsts;
+       if (intelmaddata->sstdrv_ops && intelmaddata->sstdrv_ops->scard_ops
+                       && intelmaddata->sstdrv_ops->scard_ops->pmic_irq_cb) {
+               intelmaddata->sstdrv_ops->scard_ops->pmic_irq_cb(
+                       (void *)intelmaddata, interrupt_status);
+               intelmaddata->sstdrv_ops->scard_ops->pmic_jack_enable();
+       }
+       kfree(mad_jack_detect);
+}
 /**
  * snd_intelmad_intr_handler- interrupt handler
  *
@@ -439,15 +507,17 @@ static irqreturn_t snd_intelmad_intr_handler(int irq, void *dev)
 {
        struct snd_intelmad *intelmaddata =
                        (struct snd_intelmad *)dev;
-       u8 intsts;
-
-       memcpy_fromio(&intsts,
+       u8 interrupt_status;
+       struct mad_jack_msg_wq  *mad_jack_msg;
+       memcpy_fromio(&interrupt_status,
                        ((void *)(intelmaddata->int_base)),
                        sizeof(u8));
-       intelmaddata->mad_jack_msg.intsts = intsts;
-       intelmaddata->mad_jack_msg.intelmaddata = intelmaddata;
 
-       queue_work(intelmaddata->mad_jack_wq, &intelmaddata->mad_jack_msg.wq);
+       mad_jack_msg = kzalloc(sizeof(*mad_jack_msg), GFP_ATOMIC);
+       mad_jack_msg->intsts = interrupt_status;
+       mad_jack_msg->intelmaddata = intelmaddata;
+       INIT_WORK(&mad_jack_msg->wq, sst_process_mad_jack_detection);
+       queue_work(intelmaddata->mad_jack_wq, &mad_jack_msg->wq);
 
        return IRQ_HANDLED;
 }
@@ -460,286 +530,22 @@ void sst_mad_send_jack_report(struct snd_jack *jack,
                pr_debug("MAD error jack empty\n");
 
        } else {
-               pr_debug("MAD send jack report for = %d!!!\n", status);
-               pr_debug("MAD send jack report %d\n", jack->type);
                snd_jack_report(jack, status);
-
-               /*button pressed and released */
+               /* button pressed and released */
                if (buttonpressevent)
                        snd_jack_report(jack, 0);
                pr_debug("MAD sending jack report Done !!!\n");
        }
-
-
-
-}
-
-void sst_mad_jackdetection_fs(u8 intsts , struct snd_intelmad *intelmaddata)
-{
-       struct snd_jack *jack = NULL;
-       unsigned int present = 0, jack_event_flag = 0, buttonpressflag = 0;
-       struct sc_reg_access sc_access[] = {
-                               {0x187, 0x00, MASK7},
-                               {0x188, 0x10, MASK4},
-                               {0x18b, 0x10, MASK4},
-       };
-
-       struct sc_reg_access sc_access_write[] = {
-                               {0x198, 0x00, 0x0},
-       };
-
-       if (intsts & 0x4) {
-
-               if (!(intelmid_audio_interrupt_enable)) {
-                       pr_debug("Audio interrupt enable\n");
-                       sst_sc_reg_access(sc_access, PMIC_READ_MODIFY, 3);
-
-                       sst_sc_reg_access(sc_access_write, PMIC_WRITE, 1);
-                       intelmid_audio_interrupt_enable = 1;
-                       intelmaddata->jack[0].jack_status = 0;
-                       intelmaddata->jack[1].jack_status = 0;
-
-               }
-               /* send headphone detect */
-               pr_debug("MAD headphone %d\n", intsts & 0x4);
-               jack = &intelmaddata->jack[0].jack;
-               present = !(intelmaddata->jack[0].jack_status);
-               intelmaddata->jack[0].jack_status = present;
-               jack_event_flag = 1;
-
-       }
-
-       if (intsts & 0x2) {
-               /* send short push */
-               pr_debug("MAD short push %d\n", intsts & 0x2);
-               jack = &intelmaddata->jack[2].jack;
-               present = 1;
-               jack_event_flag = 1;
-               buttonpressflag = 1;
-       }
-       if (intsts & 0x1) {
-               /* send long push */
-               pr_debug("MAD long push %d\n", intsts & 0x1);
-               jack = &intelmaddata->jack[3].jack;
-               present = 1;
-               jack_event_flag = 1;
-               buttonpressflag = 1;
-       }
-       if (intsts & 0x8) {
-               if (!(intelmid_audio_interrupt_enable)) {
-                       pr_debug("Audio interrupt enable\n");
-                       sst_sc_reg_access(sc_access, PMIC_READ_MODIFY, 3);
-
-                       sst_sc_reg_access(sc_access_write, PMIC_WRITE, 1);
-                       intelmid_audio_interrupt_enable = 1;
-                       intelmaddata->jack[0].jack_status = 0;
-                       intelmaddata->jack[1].jack_status = 0;
-               }
-               /* send headset detect */
-               pr_debug("MAD headset = %d\n", intsts & 0x8);
-               jack = &intelmaddata->jack[1].jack;
-               present = !(intelmaddata->jack[1].jack_status);
-               intelmaddata->jack[1].jack_status = present;
-               jack_event_flag = 1;
-       }
-
-       if (jack_event_flag)
-               sst_mad_send_jack_report(jack, buttonpressflag, present);
-}
-
-
-void sst_mad_jackdetection_mx(u8 intsts, struct snd_intelmad *intelmaddata)
-{
-       u8 value = 0, jack_prev_state = 0;
-       struct snd_jack *jack = NULL;
-       unsigned int present = 0, jack_event_flag = 0, buttonpressflag = 0;
-       time_t  timediff;
-       struct sc_reg_access sc_access_read = {0,};
-       struct snd_pmic_ops *scard_ops;
-
-       scard_ops = intelmaddata->sstdrv_ops->scard_ops;
-
-       pr_debug("previous value: %x\n", intelmaddata->jack_prev_state);
-
-       if (!(intelmid_audio_interrupt_enable)) {
-               pr_debug("Audio interrupt enable\n");
-               intelmaddata->jack_prev_state = 0xC0;
-               intelmid_audio_interrupt_enable = 1;
-       }
-
-       if (intsts & 0x2) {
-               jack_prev_state = intelmaddata->jack_prev_state;
-               if (intelmaddata->pmic_status == PMIC_INIT) {
-                       sc_access_read.reg_addr = 0x201;
-                       sst_sc_reg_access(&sc_access_read, PMIC_READ, 1);
-                       value = (sc_access_read.value);
-                       pr_debug("value returned = 0x%x\n", value);
-               }
-
-               if (jack_prev_state == 0xc0 && value == 0x40) {
-                       /*headset detected. */
-                       pr_debug("MAD headset inserted\n");
-                       jack = &intelmaddata->jack[1].jack;
-                       present = 1;
-                       jack_event_flag = 1;
-                       intelmaddata->jack[1].jack_status = 1;
-
-               }
-
-               if (jack_prev_state == 0xc0 && value == 0x00) {
-                       /* headphone  detected. */
-                       pr_debug("MAD headphone inserted\n");
-                       jack = &intelmaddata->jack[0].jack;
-                       present = 1;
-                       jack_event_flag = 1;
-
-               }
-
-               if (jack_prev_state == 0x40 && value == 0xc0) {
-                       /*headset  removed*/
-                       pr_debug("Jack headset status %d\n",
-                               intelmaddata->jack[1].jack_status);
-                       pr_debug("MAD headset removed\n");
-                       jack = &intelmaddata->jack[1].jack;
-                       present = 0;
-                       jack_event_flag = 1;
-                       intelmaddata->jack[1].jack_status = 0;
-               }
-
-               if (jack_prev_state == 0x00 && value == 0xc0) {
-                       /* headphone  detected. */
-                       pr_debug("Jack headphone status %d\n",
-                                       intelmaddata->jack[0].jack_status);
-                       pr_debug("headphone removed\n");
-                       jack = &intelmaddata->jack[0].jack;
-                       present = 0;
-                       jack_event_flag = 1;
-               }
-
-               if (jack_prev_state == 0x40 && value == 0x00) {
-                       /*button pressed*/
-                       do_gettimeofday(&intelmaddata->jack[1].buttonpressed);
-                       pr_debug("MAD button press detected\n");
-               }
-
-
-               if (jack_prev_state == 0x00 && value == 0x40) {
-                       if (intelmaddata->jack[1].jack_status) {
-                               /*button pressed*/
-                               do_gettimeofday(
-                                       &intelmaddata->jack[1].buttonreleased);
-                               /*button pressed */
-                               pr_debug("Button Released detected\n");
-                               timediff = intelmaddata->jack[1].
-                                       buttonreleased.tv_sec - intelmaddata->
-                                       jack[1].buttonpressed.tv_sec;
-                               buttonpressflag = 1;
-                               if (timediff > 1) {
-                                       pr_debug("long press detected\n");
-                                       /* send headphone detect/undetect */
-                                       jack = &intelmaddata->jack[3].jack;
-                                       present = 1;
-                                       jack_event_flag = 1;
-                               } else {
-                                       pr_debug("short press detected\n");
-                                       /* send headphone detect/undetect */
-                                       jack = &intelmaddata->jack[2].jack;
-                                       present = 1;
-                                       jack_event_flag = 1;
-                               }
-                       }
-
-               }
-               intelmaddata->jack_prev_state = value;
-       }
-       if (jack_event_flag)
-               sst_mad_send_jack_report(jack, buttonpressflag, present);
-}
-
-
-void sst_mad_jackdetection_nec(u8 intsts, struct snd_intelmad *intelmaddata)
-{
-       u8 value = 0;
-       struct snd_jack *jack = NULL;
-       unsigned int present = 0, jack_event_flag = 0, buttonpressflag = 0;
-       struct sc_reg_access sc_access_read = {0,};
-
-       if (intelmaddata->pmic_status == PMIC_INIT) {
-               sc_access_read.reg_addr = 0x132;
-               sst_sc_reg_access(&sc_access_read, PMIC_READ, 1);
-               value = (sc_access_read.value);
-               pr_debug("value returned = 0x%x\n", value);
-       }
-       if (intsts & 0x1) {
-               pr_debug("headset detected\n");
-               /* send headset detect/undetect */
-               jack = &intelmaddata->jack[1].jack;
-               present = (value == 0x1) ? 1 : 0;
-               jack_event_flag = 1;
-       }
-       if (intsts & 0x2) {
-               pr_debug("headphone detected\n");
-               /* send headphone detect/undetect */
-               jack = &intelmaddata->jack[0].jack;
-               present = (value == 0x2) ? 1 : 0;
-               jack_event_flag = 1;
-       }
-       if (intsts & 0x4) {
-               pr_debug("short push detected\n");
-               /* send short push */
-               jack = &intelmaddata->jack[2].jack;
-               present = 1;
-               jack_event_flag = 1;
-               buttonpressflag = 1;
-       }
-       if (intsts & 0x8) {
-               pr_debug("long push detected\n");
-               /* send long push */
-               jack = &intelmaddata->jack[3].jack;
-               present = 1;
-               jack_event_flag = 1;
-               buttonpressflag = 1;
-       }
-
-       if (jack_event_flag)
-               sst_mad_send_jack_report(jack, buttonpressflag, present);
-
-
-}
-
-void sst_process_mad_jack_detection(struct work_struct *work)
-{
-       u8 intsts;
-       struct mad_jack_msg_wq *mad_jack_detect =
-                       container_of(work, struct mad_jack_msg_wq, wq);
-
-       struct snd_intelmad *intelmaddata =
-                       mad_jack_detect->intelmaddata;
-
-       intsts = mad_jack_detect->intsts;
-
-       switch (intelmaddata->sstdrv_ops->vendor_id) {
-       case SND_FS:
-               sst_mad_jackdetection_fs(intsts , intelmaddata);
-               break;
-       case SND_MX:
-               sst_mad_jackdetection_mx(intsts , intelmaddata);
-               break;
-       case SND_NC:
-               sst_mad_jackdetection_nec(intsts , intelmaddata);
-               break;
-       }
 }
 
-
 static int __devinit snd_intelmad_register_irq(
-                                       struct snd_intelmad *intelmaddata)
+               struct snd_intelmad *intelmaddata, unsigned int regbase,
+               unsigned int regsize)
 {
        int ret_val;
-       u32 regbase = AUDINT_BASE, regsize = 8;
        char *drv_name;
 
-       pr_debug("irq reg done, regbase 0x%x, regsize 0x%x\n",
+       pr_debug("irq reg regbase 0x%x, regsize 0x%x\n",
                                        regbase, regsize);
        intelmaddata->int_base = ioremap_nocache(regbase, regsize);
        if (!intelmaddata->int_base)
@@ -797,6 +603,7 @@ static int __devinit snd_intelmad_sst_register(
                intelmaddata->sstdrv_ops->scard_ops->input_dev_id = DMIC;
                intelmaddata->sstdrv_ops->scard_ops->output_dev_id =
                                                        STEREO_HEADPHONE;
+               intelmaddata->sstdrv_ops->scard_ops->lineout_dev_id = NONE;
        }
 
        /* registering with SST driver to get access to SST APIs to use */
@@ -805,13 +612,15 @@ static int __devinit snd_intelmad_sst_register(
                pr_err("sst card registration failed\n");
                return ret_val;
        }
-       sst_drv_ctx->scard_ops->card_status = SND_CARD_UN_INIT;
-
        sst_card_vendor_id = intelmaddata->sstdrv_ops->vendor_id;
        intelmaddata->pmic_status = PMIC_UNINIT;
        return ret_val;
 }
 
+static void snd_intelmad_page_free(struct snd_pcm *pcm)
+{
+       snd_pcm_lib_preallocate_free_for_all(pcm);
+}
 /* Driver Init/exit functionalities */
 /**
  * snd_intelmad_pcm_new - to setup pcm for the card
@@ -863,6 +672,7 @@ static int __devinit snd_intelmad_pcm_new(struct snd_card *card,
                snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, cap_ops);
        /* setup private data which can be retrieved when required */
        pcm->private_data = intelmaddata;
+       pcm->private_free = snd_intelmad_page_free;
        pcm->info_flags = 0;
        strncpy(pcm->name, card->shortname, strlen(card->shortname));
        /* allocate dma pages for ALSA stream operations */
@@ -907,8 +717,12 @@ static int snd_intelmad_jack(struct snd_intelmad *intelmaddata)
 
        pr_debug("snd_intelmad_jack called\n");
        jack = &intelmaddata->jack[0].jack;
-       retval = snd_jack_new(intelmaddata->card, "Headphone",
-                               SND_JACK_HEADPHONE, &jack);
+       snd_jack_set_key(jack, SND_JACK_BTN_0, KEY_PHONE);
+       retval = snd_jack_new(intelmaddata->card, "Intel(R) MID Audio Jack",
+               SND_JACK_HEADPHONE | SND_JACK_HEADSET |
+               SW_JACK_PHYSICAL_INSERT | SND_JACK_BTN_0
+               | SND_JACK_BTN_1, &jack);
+       pr_debug("snd_intelmad_jack called\n");
        if (retval < 0)
                return retval;
        snd_jack_report(jack, 0);
@@ -916,40 +730,6 @@ static int snd_intelmad_jack(struct snd_intelmad *intelmaddata)
        jack->private_data = jack;
        intelmaddata->jack[0].jack = *jack;
 
-
-       jack = &intelmaddata->jack[1].jack;
-       retval = snd_jack_new(intelmaddata->card, "Headset",
-                               SND_JACK_HEADSET, &jack);
-       if (retval < 0)
-               return retval;
-
-
-
-       jack->private_data = jack;
-       intelmaddata->jack[1].jack = *jack;
-
-
-       jack = &intelmaddata->jack[2].jack;
-       retval = snd_jack_new(intelmaddata->card, "Short Press",
-                               SND_JACK_HS_SHORT_PRESS, &jack);
-       if (retval < 0)
-               return retval;
-
-
-       jack->private_data = jack;
-       intelmaddata->jack[2].jack = *jack;
-
-
-       jack = &intelmaddata->jack[3].jack;
-       retval = snd_jack_new(intelmaddata->card, "Long Press",
-                               SND_JACK_HS_LONG_PRESS, &jack);
-       if (retval < 0)
-               return retval;
-
-
-       jack->private_data = jack;
-       intelmaddata->jack[3].jack = *jack;
-
        return retval;
 }
 
@@ -1002,14 +782,14 @@ static int snd_intelmad_dev_free(struct snd_device *device)
        intelmaddata = device->device_data;
 
        pr_debug("snd_intelmad_dev_free called\n");
-       snd_card_free(intelmaddata->card);
-       /*genl_unregister_family(&audio_event_genl_family);*/
        unregister_sst_card(intelmaddata->sstdrv_ops);
 
        /* free allocated memory for internal context */
        destroy_workqueue(intelmaddata->mad_jack_wq);
+       device->device_data = NULL;
        kfree(intelmaddata->sstdrv_ops);
        kfree(intelmaddata);
+
        return 0;
 }
 
@@ -1040,9 +820,10 @@ int __devinit snd_intelmad_probe(struct platform_device *pdev)
        int ret_val;
        struct snd_intelmad *intelmaddata;
        const struct platform_device_id *id = platform_get_device_id(pdev);
-       unsigned int cpu_id = (unsigned int)id->driver_data;
+       struct snd_intelmad_probe_info *info = (void *)id->driver_data;
 
-       pr_debug("probe for %s cpu_id %d\n", pdev->name, cpu_id);
+       pr_debug("probe for %s cpu_id %d\n", pdev->name, info->cpu_id);
+       pr_debug("rq_chache %x of size %x\n", info->irq_cache, info->size);
        if (!strcmp(pdev->name, DRIVER_NAME_MRST))
                pr_debug("detected MRST\n");
        else if (!strcmp(pdev->name, DRIVER_NAME_MFLD))
@@ -1051,7 +832,8 @@ int __devinit snd_intelmad_probe(struct platform_device *pdev)
                pr_err("detected unknown device abort!!\n");
                return -EIO;
        }
-       if ((cpu_id < CPU_CHIP_LINCROFT) || (cpu_id > CPU_CHIP_PENWELL)) {
+       if ((info->cpu_id < CPU_CHIP_LINCROFT) ||
+                               (info->cpu_id > CPU_CHIP_PENWELL)) {
                pr_err("detected unknown cpu_id abort!!\n");
                return -EIO;
        }
@@ -1061,6 +843,7 @@ int __devinit snd_intelmad_probe(struct platform_device *pdev)
                pr_debug("mem alloctn fail\n");
                return -ENOMEM;
        }
+       intelmad_drv = intelmaddata;
 
        /* allocate memory for LPE API set */
        intelmaddata->sstdrv_ops = kzalloc(sizeof(struct intel_sst_card_ops),
@@ -1071,7 +854,7 @@ int __devinit snd_intelmad_probe(struct platform_device *pdev)
                return -ENOMEM;
        }
 
-       intelmaddata->cpu_id = cpu_id;
+       intelmaddata->cpu_id = info->cpu_id;
        /* create a card instance with ALSA framework */
        ret_val = snd_card_create(card_index, card_id, THIS_MODULE, 0, &card);
        if (ret_val) {
@@ -1095,7 +878,7 @@ int __devinit snd_intelmad_probe(struct platform_device *pdev)
        ret_val = snd_intelmad_sst_register(intelmaddata);
        if (ret_val) {
                pr_err("snd_intelmad_sst_register failed\n");
-               goto free_allocs;
+               goto set_null_data;
        }
 
        intelmaddata->pmic_status = PMIC_INIT;
@@ -1103,20 +886,21 @@ int __devinit snd_intelmad_probe(struct platform_device *pdev)
        ret_val = snd_intelmad_pcm(card, intelmaddata);
        if (ret_val) {
                pr_err("snd_intelmad_pcm failed\n");
-               goto free_allocs;
+               goto free_sst;
        }
 
        ret_val = snd_intelmad_mixer(intelmaddata);
        if (ret_val) {
                pr_err("snd_intelmad_mixer failed\n");
-               goto free_allocs;
+               goto free_card;
        }
 
        ret_val = snd_intelmad_jack(intelmaddata);
        if (ret_val) {
                pr_err("snd_intelmad_jack failed\n");
-               goto free_allocs;
+               goto free_card;
        }
+       intelmaddata->adc_address = mid_initialize_adc();
 
        /*create work queue for jack interrupt*/
        INIT_WORK(&intelmaddata->mad_jack_msg.wq,
@@ -1124,33 +908,48 @@ int __devinit snd_intelmad_probe(struct platform_device *pdev)
 
        intelmaddata->mad_jack_wq = create_workqueue("sst_mad_jack_wq");
        if (!intelmaddata->mad_jack_wq)
-               goto free_mad_jack_wq;
+               goto free_card;
 
-       ret_val = snd_intelmad_register_irq(intelmaddata);
+       ret_val = snd_intelmad_register_irq(intelmaddata,
+                                       info->irq_cache, info->size);
        if (ret_val) {
                pr_err("snd_intelmad_register_irq fail\n");
-               goto free_allocs;
+               goto free_mad_jack_wq;
        }
 
        /* internal function call to register device with ALSA */
        ret_val = snd_intelmad_create(intelmaddata, card);
        if (ret_val) {
                pr_err("snd_intelmad_create failed\n");
-               goto free_allocs;
+               goto set_pvt_data;
        }
        card->private_data = &intelmaddata;
        snd_card_set_dev(card, &pdev->dev);
        ret_val = snd_card_register(card);
        if (ret_val) {
                pr_err("snd_card_register failed\n");
-               goto free_allocs;
+               goto set_pvt_data;
+       }
+       if (pdev->dev.platform_data) {
+               int gpio_amp = *(int *)pdev->dev.platform_data;
+               if (gpio_request_one(gpio_amp, GPIOF_OUT_INIT_LOW, "amp power"))
+                       gpio_amp = 0;
+               intelmaddata->sstdrv_ops->scard_ops->gpio_amp = gpio_amp;
        }
 
        pr_debug("snd_intelmad_probe complete\n");
        return ret_val;
 
+set_pvt_data:
+       card->private_data = NULL;
 free_mad_jack_wq:
        destroy_workqueue(intelmaddata->mad_jack_wq);
+free_card:
+       snd_card_free(intelmaddata->card);
+free_sst:
+       unregister_sst_card(intelmaddata->sstdrv_ops);
+set_null_data:
+       platform_set_drvdata(pdev, NULL);
 free_allocs:
        pr_err("probe failed\n");
        snd_card_free(card);
@@ -1165,13 +964,13 @@ static int snd_intelmad_remove(struct platform_device *pdev)
        struct snd_intelmad *intelmaddata = platform_get_drvdata(pdev);
 
        if (intelmaddata) {
+               if (intelmaddata->sstdrv_ops->scard_ops->gpio_amp)
+                       gpio_free(intelmaddata->sstdrv_ops->scard_ops->gpio_amp);
+               free_irq(intelmaddata->irq, intelmaddata);
                snd_card_free(intelmaddata->card);
-               unregister_sst_card(intelmaddata->sstdrv_ops);
-               /* free allocated memory for internal context */
-               destroy_workqueue(intelmaddata->mad_jack_wq);
-               kfree(intelmaddata->sstdrv_ops);
-               kfree(intelmaddata);
        }
+       intelmad_drv = NULL;
+       platform_set_drvdata(pdev, NULL);
        return 0;
 }
 
@@ -1179,8 +978,8 @@ static int snd_intelmad_remove(struct platform_device *pdev)
  *             Driver initialization and exit
  *********************************************************************/
 static const struct platform_device_id snd_intelmad_ids[] = {
-       {DRIVER_NAME_MRST, CPU_CHIP_LINCROFT},
-       {DRIVER_NAME_MFLD, CPU_CHIP_PENWELL},
+       {DRIVER_NAME_MRST, INFO(CPU_CHIP_LINCROFT, AUDINT_BASE, 1)},
+       {DRIVER_NAME_MFLD, INFO(CPU_CHIP_PENWELL, 0xFFFF7FCD, 1)},
        {"", 0},
 
 };
index e77da87e1df0f52e08ec8f880b072c455f870196..14a7ba078b7c9f447b56042a3a996f33a0d7858f 100644 (file)
@@ -28,6 +28,7 @@
 #define __INTELMID_H
 
 #include <linux/time.h>
+#include <sound/jack.h>
 
 #define DRIVER_NAME_MFLD "msic_audio"
 #define DRIVER_NAME_MRST "pmic_audio"
@@ -43,7 +44,7 @@
 #define MAX_BUFFER             (800*1024) /* for PCM */
 #define MIN_BUFFER             (800*1024)
 #define MAX_PERIODS            (1024*2)
-#define MIN_PERIODS            1
+#define MIN_PERIODS            2
 #define MAX_PERIOD_BYTES MAX_BUFFER
 #define MIN_PERIOD_BYTES 32
 /*#define MIN_PERIOD_BYTES 160*/
 #define STEREO_CNTL            2
 #define MIN_CHANNEL            1
 #define MAX_CHANNEL_AMIC       2
-#define MAX_CHANNEL_DMIC       4
+#define MAX_CHANNEL_DMIC       5
 #define FIFO_SIZE              0 /* fifo not being used */
 #define INTEL_MAD              "Intel MAD"
-#define MAX_CTRL_MRST          7
-#define MAX_CTRL_MFLD          2
-#define MAX_CTRL               7
+#define MAX_CTRL_MRST          8
+#define MAX_CTRL_MFLD          7
+#define MAX_CTRL               8
 #define MAX_VENDORS            4
 /* TODO +6 db */
 #define MAX_VOL                64
 #define MIN_VOL                0
 #define PLAYBACK_COUNT  1
 #define CAPTURE_COUNT  1
+#define ADC_ONE_LSB_MULTIPLIER 2346
+
+#define MID_JACK_HS_LONG_PRESS SND_JACK_BTN_0
+#define MID_JACK_HS_SHORT_PRESS SND_JACK_BTN_1
 
 extern int     sst_card_vendor_id;
 
 struct mad_jack {
        struct snd_jack jack;
        int jack_status;
+       int jack_dev_state;
        struct timeval buttonpressed;
        struct timeval  buttonreleased;
 };
@@ -83,6 +89,12 @@ struct mad_jack_msg_wq {
 
 };
 
+struct snd_intelmad_probe_info {
+       unsigned int cpu_id;
+       unsigned int irq_cache;
+       unsigned int size;
+};
+
 /**
  * struct snd_intelmad - intelmad driver structure
  *
@@ -116,10 +128,12 @@ struct snd_intelmad {
        void __iomem *int_base;
        int output_sel;
        int input_sel;
+       int lineout_sel;
        int master_mute;
        struct mad_jack jack[4];
        int playback_cnt;
        int capture_cnt;
+       u16 adc_address;
        struct mad_jack_msg_wq  mad_jack_msg;
        struct workqueue_struct *mad_jack_wq;
        u8 jack_prev_state;
@@ -131,6 +145,8 @@ struct snd_control_val {
        int     playback_vol_min;
        int     capture_vol_max;
        int     capture_vol_min;
+       int     master_vol_max;
+       int     master_vol_min;
 };
 
 struct mad_stream_pvt {
@@ -161,8 +177,18 @@ enum _widget_ctrl {
        PLAYBACK_MUTE,
        CAPTURE_VOL,
        CAPTURE_MUTE,
+       MASTER_VOL,
        MASTER_MUTE
 };
+enum _widget_ctrl_mfld {
+       LINEOUT_SEL_MFLD = 3,
+};
+enum hw_chs {
+       HW_CH0 = 0,
+       HW_CH1,
+       HW_CH2,
+       HW_CH3
+};
 
 void period_elapsed(void *mad_substream);
 int snd_intelmad_alloc_stream(struct snd_pcm_substream *substream);
@@ -177,5 +203,7 @@ extern struct snd_control_val intelmad_ctrl_val[];
 extern struct snd_kcontrol_new snd_intelmad_controls_mrst[];
 extern struct snd_kcontrol_new snd_intelmad_controls_mfld[];
 extern struct snd_pmic_ops *intelmad_vendor_ops[];
+void sst_mad_send_jack_report(struct snd_jack *jack,
+                       int buttonpressevent , int status);
 
 #endif /* __INTELMID_H */
diff --git a/drivers/staging/intel_sst/intelmid_adc_control.h b/drivers/staging/intel_sst/intelmid_adc_control.h
new file mode 100644 (file)
index 0000000..65d5c39
--- /dev/null
@@ -0,0 +1,193 @@
+#ifndef __INTELMID_ADC_CONTROL_H__
+#define __INTELMID_ADC_CONTROL_H_
+/*
+ *  intelmid_adc_control.h - Intel SST Driver for audio engine
+ *
+ *  Copyright (C) 2008-10 Intel Corporation
+ *  Authors:   R Durgadadoss <r.durgadoss@intel.com>
+ *             Dharageswari R <dharageswari.r@intel.com>
+ *  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; version 2 of the License.
+ *
+ *  This program is distributed in the hope that it will be useful, but
+ *  WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License along
+ *  with this program; if not, write to the Free Software Foundation, Inc.,
+ *  59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ *  Common private ADC declarations for SST
+ */
+
+
+#define MSIC_ADC1CNTL1         0x1C0
+#define MSIC_ADC_ENBL          0x10
+#define MSIC_ADC_START         0x08
+
+#define MSIC_ADC1CNTL3         0x1C2
+#define MSIC_ADCTHERM_ENBL     0x04
+#define MSIC_ADCRRDATA_ENBL    0x05
+
+#define MSIC_STOPBIT_MASK      16
+#define MSIC_ADCTHERM_MASK     4
+
+#define ADC_CHANLS_MAX         15 /* Number of ADC channels */
+#define ADC_LOOP_MAX           (ADC_CHANLS_MAX - 1)
+
+/* ADC channel code values */
+#define AUDIO_DETECT_CODE      0x06
+
+/* ADC base addresses */
+#define ADC_CHNL_START_ADDR    0x1C5   /* increments by 1 */
+#define ADC_DATA_START_ADDR     0x1D4   /* increments by 2 */
+
+
+/**
+ * configure_adc - enables/disables the ADC for conversion
+ * @val: zero: disables the ADC non-zero:enables the ADC
+ *
+ * Enable/Disable the ADC depending on the argument
+ *
+ * Can sleep
+ */
+static inline int configure_adc(int val)
+{
+       int ret;
+       struct sc_reg_access sc_access = {0,};
+
+
+       sc_access.reg_addr = MSIC_ADC1CNTL1;
+       ret = sst_sc_reg_access(&sc_access, PMIC_READ, 1);
+       if (ret)
+               return ret;
+
+       if (val)
+               /* Enable and start the ADC */
+               sc_access.value |= (MSIC_ADC_ENBL | MSIC_ADC_START);
+       else
+               /* Just stop the ADC */
+               sc_access.value &= (~MSIC_ADC_START);
+       sc_access.reg_addr = MSIC_ADC1CNTL1;
+       return sst_sc_reg_access(&sc_access, PMIC_WRITE, 1);
+}
+
+/**
+ * reset_stopbit - sets the stop bit to 0 on the given channel
+ * @addr: address of the channel
+ *
+ * Can sleep
+ */
+static inline int reset_stopbit(uint16_t addr)
+{
+       int ret;
+       struct sc_reg_access sc_access = {0,};
+       sc_access.reg_addr = addr;
+       ret = sst_sc_reg_access(&sc_access, PMIC_READ, 1);
+       if (ret)
+               return ret;
+       /* Set the stop bit to zero */
+       sc_access.reg_addr = addr;
+       sc_access.value = (sc_access.value) & 0xEF;
+       return sst_sc_reg_access(&sc_access, PMIC_WRITE, 1);
+}
+
+/**
+ * find_free_channel - finds an empty channel for conversion
+ *
+ * If the ADC is not enabled then start using 0th channel
+ * itself. Otherwise find an empty channel by looking for a
+ * channel in which the stopbit is set to 1. returns the index
+ * of the first free channel if succeeds or an error code.
+ *
+ * Context: can sleep
+ *
+ */
+static inline int find_free_channel(void)
+{
+       int ret;
+       int i;
+
+       struct sc_reg_access sc_access = {0,};
+
+       /* check whether ADC is enabled */
+       sc_access.reg_addr = MSIC_ADC1CNTL1;
+       ret = sst_sc_reg_access(&sc_access, PMIC_READ, 1);
+       if (ret)
+               return ret;
+
+       if ((sc_access.value & MSIC_ADC_ENBL) == 0)
+               return 0;
+
+       /* ADC is already enabled; Looking for an empty channel */
+       for (i = 0; i < ADC_CHANLS_MAX; i++) {
+
+               sc_access.reg_addr = ADC_CHNL_START_ADDR + i;
+               ret = sst_sc_reg_access(&sc_access, PMIC_READ, 1);
+               if (ret)
+                       return ret;
+
+               if (sc_access.value & MSIC_STOPBIT_MASK) {
+                       ret = i;
+                       break;
+               }
+       }
+       return (ret > ADC_LOOP_MAX) ? (-EINVAL) : ret;
+}
+
+/**
+ * mid_initialize_adc - initializing the ADC
+ * @dev: our device structure
+ *
+ * Initialize the ADC for reading thermistor values. Can sleep.
+ */
+static inline int mid_initialize_adc(void)
+{
+       int base_addr, chnl_addr;
+       int ret;
+       static int channel_index;
+       struct sc_reg_access sc_access = {0,};
+
+       /* Index of the first channel in which the stop bit is set */
+       channel_index = find_free_channel();
+       if (channel_index < 0) {
+               pr_err("No free ADC channels");
+               return channel_index;
+       }
+
+       base_addr = ADC_CHNL_START_ADDR + channel_index;
+
+       if (!(channel_index == 0 || channel_index == ADC_LOOP_MAX)) {
+               /* Reset stop bit for channels other than 0 and 12 */
+               ret = reset_stopbit(base_addr);
+               if (ret)
+                       return ret;
+
+               /* Index of the first free channel */
+               base_addr++;
+               channel_index++;
+       }
+
+       /* Since this is the last channel, set the stop bit
+          to 1 by ORing the DIE_SENSOR_CODE with 0x10 */
+       sc_access.reg_addr = base_addr;
+       sc_access.value = AUDIO_DETECT_CODE | 0x10;
+       ret = sst_sc_reg_access(&sc_access, PMIC_WRITE, 1);
+       if (ret) {
+               pr_err("unable to enable ADC");
+               return ret;
+       }
+
+       chnl_addr = ADC_DATA_START_ADDR + 2 * channel_index;
+       pr_debug("mid_initialize : %x", chnl_addr);
+       configure_adc(1);
+       return chnl_addr;
+}
+#endif
+
index 69af0704ce946335d6f4a46ed35c786ee6000c00..19ec474b362a75d496d9dbbb0e6642d034faf603 100644 (file)
 
 #include <sound/core.h>
 #include <sound/control.h>
-#include "jack.h"
 #include "intel_sst.h"
 #include "intel_sst_ioctl.h"
 #include "intelmid_snd_control.h"
 #include "intelmid.h"
 
+#define HW_CH_BASE 4
+
+
+#define HW_CH_0        "Hw1"
+#define HW_CH_1        "Hw2"
+#define HW_CH_2        "Hw3"
+#define HW_CH_3        "Hw4"
+
+static char *router_dmics[] = {        "DMIC1",
+                               "DMIC2",
+                               "DMIC3",
+                               "DMIC4",
+                               "DMIC5",
+                               "DMIC6"
+                               };
+
 static char *out_names_mrst[] = {"Headphones",
                                "Internal speakers"};
 static char *in_names_mrst[] = {"AMIC",
                                "DMIC",
                                "HS_MIC"};
+static char *line_out_names_mfld[] = {"Headset",
+                               "IHF    ",
+                               "Vibra1 ",
+                               "Vibra2 ",
+                               "NONE   "};
 static char *out_names_mfld[] = {"Headset ",
                                "EarPiece  "};
 static char *in_names_mfld[] = {"AMIC",
@@ -60,9 +80,11 @@ struct snd_control_val intelmad_ctrl_val[MAX_VENDORS] = {
        },
        {
                .playback_vol_max = 0,
-               .playback_vol_min = -126,
+               .playback_vol_min = -31,
                .capture_vol_max = 0,
                .capture_vol_min = -31,
+               .master_vol_max = 0,
+               .master_vol_min = -126,
        },
 };
 
@@ -139,6 +161,15 @@ static int snd_intelmad_playback_volume_info(struct snd_kcontrol *kcontrol,
        return 0;
 }
 
+static int snd_intelmad_master_volume_info(struct snd_kcontrol *kcontrol,
+                                       struct snd_ctl_elem_info *uinfo)
+{
+       snd_intelmad_volume_info(uinfo, STEREO_CNTL,
+               intelmad_ctrl_val[sst_card_vendor_id].master_vol_max,
+               intelmad_ctrl_val[sst_card_vendor_id].master_vol_min);
+       return 0;
+}
+
 /**
 * snd_intelmad_device_info_mrst - provides information about the devices available
 *
@@ -179,13 +210,27 @@ static int snd_intelmad_device_info_mrst(struct snd_kcontrol *kcontrol,
 static int snd_intelmad_device_info_mfld(struct snd_kcontrol *kcontrol,
                                        struct snd_ctl_elem_info *uinfo)
 {
+       struct snd_pmic_ops *scard_ops;
+       struct snd_intelmad *intelmaddata;
+
        WARN_ON(!kcontrol);
        WARN_ON(!uinfo);
+
+       intelmaddata = kcontrol->private_data;
+
+       WARN_ON(!intelmaddata->sstdrv_ops);
+
+       scard_ops = intelmaddata->sstdrv_ops->scard_ops;
        /* setup device select as drop down controls with different values */
        if (kcontrol->id.numid == OUTPUT_SEL)
                uinfo->value.enumerated.items = ARRAY_SIZE(out_names_mfld);
-       else
+       else if (kcontrol->id.numid == INPUT_SEL)
                uinfo->value.enumerated.items = ARRAY_SIZE(in_names_mfld);
+       else if (kcontrol->id.numid == LINEOUT_SEL_MFLD) {
+               uinfo->value.enumerated.items = ARRAY_SIZE(line_out_names_mfld);
+               scard_ops->line_out_names_cnt = uinfo->value.enumerated.items;
+       } else
+               return -EINVAL;
        uinfo->count = MONO_CNTL;
        uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
 
@@ -195,10 +240,16 @@ static int snd_intelmad_device_info_mfld(struct snd_kcontrol *kcontrol,
                strncpy(uinfo->value.enumerated.name,
                        out_names_mfld[uinfo->value.enumerated.item],
                        sizeof(uinfo->value.enumerated.name)-1);
-       else
+       else if (kcontrol->id.numid == INPUT_SEL)
                strncpy(uinfo->value.enumerated.name,
                        in_names_mfld[uinfo->value.enumerated.item],
                        sizeof(uinfo->value.enumerated.name)-1);
+       else if (kcontrol->id.numid == LINEOUT_SEL_MFLD)
+               strncpy(uinfo->value.enumerated.name,
+                       line_out_names_mfld[uinfo->value.enumerated.item],
+                       sizeof(uinfo->value.enumerated.name)-1);
+       else
+               return -EINVAL;
        return 0;
 }
 
@@ -241,6 +292,11 @@ static int snd_intelmad_volume_get(struct snd_kcontrol *kcontrol,
        case CAPTURE_VOL:
                cntl_list[0] = PMIC_SND_CAPTURE_VOL;
                break;
+
+       case MASTER_VOL:
+               cntl_list[0] = PMIC_SND_RIGHT_MASTER_VOL;
+               cntl_list[1] = PMIC_SND_LEFT_MASTER_VOL;
+               break;
        default:
                return -EINVAL;
        }
@@ -251,7 +307,8 @@ static int snd_intelmad_volume_get(struct snd_kcontrol *kcontrol,
        if (ret_val)
                return ret_val;
 
-       if (kcontrol->id.numid == PLAYBACK_VOL) {
+       if (kcontrol->id.numid == PLAYBACK_VOL ||
+               kcontrol->id.numid == MASTER_VOL) {
                ret_val = scard_ops->get_vol(cntl_list[1], &value);
                uval->value.integer.value[1] = value;
        }
@@ -359,6 +416,12 @@ static int snd_intelmad_volume_set(struct snd_kcontrol *kcontrol,
        case CAPTURE_VOL:
                cntl_list[0] = PMIC_SND_CAPTURE_VOL;
                break;
+
+       case MASTER_VOL:
+               cntl_list[0] = PMIC_SND_LEFT_MASTER_VOL;
+               cntl_list[1] = PMIC_SND_RIGHT_MASTER_VOL;
+               break;
+
        default:
                return -EINVAL;
        }
@@ -368,7 +431,8 @@ static int snd_intelmad_volume_set(struct snd_kcontrol *kcontrol,
        if (ret_val)
                return ret_val;
 
-       if (kcontrol->id.numid == PLAYBACK_VOL)
+       if (kcontrol->id.numid == PLAYBACK_VOL ||
+               kcontrol->id.numid == MASTER_VOL)
                ret_val = scard_ops->set_vol(cntl_list[1],
                                uval->value.integer.value[1]);
        return ret_val;
@@ -464,14 +528,36 @@ static int snd_intelmad_device_get(struct snd_kcontrol *kcontrol,
        WARN_ON(!kcontrol);
 
        intelmaddata = kcontrol->private_data;
+       scard_ops = intelmaddata->sstdrv_ops->scard_ops;
        if (intelmaddata->cpu_id == CPU_CHIP_PENWELL) {
-               scard_ops = intelmaddata->sstdrv_ops->scard_ops;
                if (kcontrol->id.numid == OUTPUT_SEL)
                        uval->value.enumerated.item[0] =
                                        scard_ops->output_dev_id;
                else if (kcontrol->id.numid == INPUT_SEL)
                        uval->value.enumerated.item[0] =
                                        scard_ops->input_dev_id;
+               else if (kcontrol->id.numid == LINEOUT_SEL_MFLD)
+                       uval->value.enumerated.item[0] =
+                                       scard_ops->lineout_dev_id;
+               else
+                       return -EINVAL;
+       } else if (intelmaddata->cpu_id == CPU_CHIP_LINCROFT) {
+               if (kcontrol->id.numid == OUTPUT_SEL)
+                       /* There is a mismatch here.
+                        * ALSA expects 1 for internal speaker.
+                        * But internally, we may give 2 for internal speaker.
+                        */
+                       if (scard_ops->output_dev_id == MONO_EARPIECE ||
+                           scard_ops->output_dev_id == INTERNAL_SPKR)
+                               uval->value.enumerated.item[0] = MONO_EARPIECE;
+                       else if (scard_ops->output_dev_id == STEREO_HEADPHONE)
+                               uval->value.enumerated.item[0] =
+                                       STEREO_HEADPHONE;
+                       else
+                               return -EINVAL;
+               else if (kcontrol->id.numid == INPUT_SEL)
+                       uval->value.enumerated.item[0] =
+                                       scard_ops->input_dev_id;
                else
                        return -EINVAL;
        } else
@@ -534,6 +620,11 @@ static int snd_intelmad_device_set(struct snd_kcontrol *kcontrol,
                                uval->value.enumerated.item[0]);
                intelmaddata->input_sel = uval->value.enumerated.item[0];
                break;
+       case LINEOUT_SEL_MFLD:
+               ret_val = scard_ops->set_lineout_dev(
+                                       uval->value.enumerated.item[0]);
+               intelmaddata->lineout_sel = uval->value.enumerated.item[0];
+               break;
        default:
                return -EINVAL;
        }
@@ -541,6 +632,151 @@ static int snd_intelmad_device_set(struct snd_kcontrol *kcontrol,
        return ret_val;
 }
 
+static int snd_intelmad_device_dmic_get(struct snd_kcontrol *kcontrol,
+                                       struct snd_ctl_elem_value *uval)
+{
+       struct snd_intelmad *intelmaddata;
+       struct snd_pmic_ops *scard_ops;
+
+       WARN_ON(!uval);
+       WARN_ON(!kcontrol);
+
+       intelmaddata = kcontrol->private_data;
+       scard_ops = intelmaddata->sstdrv_ops->scard_ops;
+
+       if (scard_ops->input_dev_id != DMIC) {
+               pr_debug("input dev = 0x%x\n", scard_ops->input_dev_id);
+               return 0;
+       }
+
+       if (intelmaddata->cpu_id == CPU_CHIP_PENWELL)
+               uval->value.enumerated.item[0] = kcontrol->private_value;
+       else
+               pr_debug(" CPU id = 0x%xis invalid.\n",
+                       intelmaddata->cpu_id);
+       return 0;
+}
+
+void msic_set_bit(u8 index, unsigned int *available_dmics)
+{
+       *available_dmics |= (1 << index);
+}
+
+void msic_clear_bit(u8 index, unsigned int *available_dmics)
+{
+       *available_dmics &= ~(1 << index);
+}
+
+int msic_is_set_bit(u8 index, unsigned int *available_dmics)
+{
+       int ret_val;
+
+       ret_val = (*available_dmics & (1 << index));
+       return ret_val;
+}
+
+static int snd_intelmad_device_dmic_set(struct snd_kcontrol *kcontrol,
+                                       struct snd_ctl_elem_value *uval)
+{
+       struct snd_intelmad *intelmaddata;
+       struct snd_pmic_ops *scard_ops;
+       int i, dmic_index;
+       unsigned int available_dmics;
+       int jump_count;
+       int max_dmics = ARRAY_SIZE(router_dmics);
+
+       WARN_ON(!uval);
+       WARN_ON(!kcontrol);
+
+       intelmaddata = kcontrol->private_data;
+       WARN_ON(!intelmaddata->sstdrv_ops);
+
+       scard_ops = intelmaddata->sstdrv_ops->scard_ops;
+       WARN_ON(!scard_ops);
+
+       if (scard_ops->input_dev_id != DMIC) {
+               pr_debug("input dev = 0x%x\n", scard_ops->input_dev_id);
+               return 0;
+       }
+
+       available_dmics = scard_ops->available_dmics;
+
+       if (kcontrol->private_value > uval->value.enumerated.item[0]) {
+               pr_debug("jump count -1.\n");
+               jump_count = -1;
+       } else {
+               pr_debug("jump count 1.\n");
+               jump_count = 1;
+       }
+
+       dmic_index =  uval->value.enumerated.item[0];
+       pr_debug("set function. dmic_index = %d, avl_dmic = 0x%x\n",
+                        dmic_index, available_dmics);
+       for (i = 0; i < max_dmics; i++) {
+               pr_debug("set function. loop index = 0x%x.  dmic_index = 0x%x\n",
+                        i, dmic_index);
+               if (!msic_is_set_bit(dmic_index, &available_dmics)) {
+                       msic_clear_bit(kcontrol->private_value,
+                                               &available_dmics);
+                       msic_set_bit(dmic_index, &available_dmics);
+                       kcontrol->private_value = dmic_index;
+                       scard_ops->available_dmics = available_dmics;
+                       scard_ops->hw_dmic_map[kcontrol->id.numid-HW_CH_BASE] =
+                               kcontrol->private_value;
+                       scard_ops->set_hw_dmic_route
+                               (kcontrol->id.numid-HW_CH_BASE);
+                       return 0;
+               }
+
+               dmic_index += jump_count;
+
+               if (dmic_index > (max_dmics - 1) && jump_count == 1) {
+                       pr_debug("Resettingthe dmic index to 0.\n");
+                       dmic_index = 0;
+               } else if (dmic_index == -1 && jump_count == -1) {
+                       pr_debug("Resetting the dmic index to 5.\n");
+                       dmic_index = max_dmics - 1;
+               }
+       }
+
+       return -EINVAL;
+}
+
+static int snd_intelmad_device_dmic_info_mfld(struct snd_kcontrol *kcontrol,
+                                       struct snd_ctl_elem_info *uinfo)
+{
+       struct snd_intelmad *intelmaddata;
+       struct snd_pmic_ops *scard_ops;
+
+       uinfo->count                  = MONO_CNTL;
+       uinfo->type                   = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
+       uinfo->value.enumerated.items = ARRAY_SIZE(router_dmics);
+
+       intelmaddata = kcontrol->private_data;
+       WARN_ON(!intelmaddata->sstdrv_ops);
+
+       scard_ops = intelmaddata->sstdrv_ops->scard_ops;
+       WARN_ON(!scard_ops);
+
+       if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
+               uinfo->value.enumerated.item =
+                       uinfo->value.enumerated.items - 1;
+
+       strncpy(uinfo->value.enumerated.name,
+       router_dmics[uinfo->value.enumerated.item],
+       sizeof(uinfo->value.enumerated.name)-1);
+
+
+       msic_set_bit(kcontrol->private_value, &scard_ops->available_dmics);
+       pr_debug("info function. avl_dmic = 0x%x",
+               scard_ops->available_dmics);
+
+       scard_ops->hw_dmic_map[kcontrol->id.numid-HW_CH_BASE] =
+               kcontrol->private_value;
+
+       return 0;
+}
+
 struct snd_kcontrol_new snd_intelmad_controls_mrst[MAX_CTRL] __devinitdata = {
 {
        .iface          =       SNDRV_CTL_ELEM_IFACE_MIXER,
@@ -596,6 +832,15 @@ struct snd_kcontrol_new snd_intelmad_controls_mrst[MAX_CTRL] __devinitdata = {
        .put            =       snd_intelmad_mute_set,
        .private_value  =       0,
 },
+{
+       .iface          =       SNDRV_CTL_ELEM_IFACE_MIXER,
+       .name           =       "Master Playback Volume",
+       .access         =       SNDRV_CTL_ELEM_ACCESS_READWRITE,
+       .info           =       snd_intelmad_master_volume_info,
+       .get            =       snd_intelmad_volume_get,
+       .put            =       snd_intelmad_volume_set,
+       .private_value  =       0,
+},
 {
        .iface          =       SNDRV_CTL_ELEM_IFACE_MIXER,
        .name           =       "Master Playback Switch",
@@ -627,5 +872,50 @@ snd_intelmad_controls_mfld[MAX_CTRL_MFLD] __devinitdata = {
        .put            =       snd_intelmad_device_set,
        .private_value  =       0,
 },
+{
+       .iface          =       SNDRV_CTL_ELEM_IFACE_MIXER,
+       .name           =       "Line out",
+       .access         =       SNDRV_CTL_ELEM_ACCESS_READWRITE,
+       .info           =       snd_intelmad_device_info_mfld,
+       .get            =       snd_intelmad_device_get,
+       .put            =       snd_intelmad_device_set,
+       .private_value  =       0,
+},
+{
+       .iface          =       SNDRV_CTL_ELEM_IFACE_MIXER,
+       .name           =       HW_CH_0,
+       .access         =       SNDRV_CTL_ELEM_ACCESS_READWRITE,
+       .info           =       snd_intelmad_device_dmic_info_mfld,
+       .get            =       snd_intelmad_device_dmic_get,
+       .put            =       snd_intelmad_device_dmic_set,
+       .private_value  =       0
+},
+{
+       .iface          =       SNDRV_CTL_ELEM_IFACE_MIXER,
+       .name           =       HW_CH_1,
+       .access         =       SNDRV_CTL_ELEM_ACCESS_READWRITE,
+       .info           =       snd_intelmad_device_dmic_info_mfld,
+       .get            =       snd_intelmad_device_dmic_get,
+       .put            =       snd_intelmad_device_dmic_set,
+       .private_value  =       1
+},
+{
+       .iface          =       SNDRV_CTL_ELEM_IFACE_MIXER,
+       .name           =       HW_CH_2,
+       .access         =       SNDRV_CTL_ELEM_ACCESS_READWRITE,
+       .info           =       snd_intelmad_device_dmic_info_mfld,
+       .get            =       snd_intelmad_device_dmic_get,
+       .put            =       snd_intelmad_device_dmic_set,
+       .private_value  =       2
+},
+{
+       .iface          =       SNDRV_CTL_ELEM_IFACE_MIXER,
+       .name           =       HW_CH_3,
+       .access         =       SNDRV_CTL_ELEM_ACCESS_READWRITE,
+       .info           =       snd_intelmad_device_dmic_info_mfld,
+       .get            =       snd_intelmad_device_dmic_get,
+       .put            =       snd_intelmad_device_dmic_set,
+       .private_value  =       3
+}
 };
 
index da093ed0cd88c540305fc376d44ba8e6526921d8..70cdb16978153624258069e72714dd955ef052b4 100644 (file)
 
 #include <linux/pci.h>
 #include <linux/file.h>
+#include <linux/delay.h>
+#include <sound/control.h>
 #include "intel_sst.h"
-#include "intel_sst_ioctl.h"
+#include <linux/input.h>
 #include "intelmid_snd_control.h"
+#include "intelmid.h"
+
+#define AUDIOMUX12  0x24c
+#define AUDIOMUX34  0x24d
 
 static int msic_init_card(void)
 {
@@ -54,116 +60,359 @@ static int msic_init_card(void)
                /*TI vibra w/a settings*/
                {0x384, 0x80, 0},
                {0x385, 0x80, 0},
-               /*vibra settings*/
                {0x267, 0x00, 0},
-               {0x26A, 0x10, 0},
                {0x261, 0x00, 0},
-               {0x264, 0x10, 0},
                /* pcm port setting */
                {0x278, 0x00, 0},
                {0x27B, 0x01, 0},
                {0x27C, 0x0a, 0},
                /* Set vol HSLRVOLCTRL, IHFVOL */
-               {0x259, 0x04, 0},
-               {0x25A, 0x04, 0},
-               {0x25B, 0x04, 0},
-               {0x25C, 0x04, 0},
+               {0x259, 0x08, 0},
+               {0x25A, 0x08, 0},
+               {0x25B, 0x08, 0},
+               {0x25C, 0x08, 0},
                /* HSEPRXCTRL  Enable the headset left and right FIR filters  */
                {0x250, 0x30, 0},
                /* HSMIXER */
                {0x256, 0x11, 0},
                /* amic configuration */
-               {0x249, 0x09, 0x0},
-               {0x24A, 0x09, 0x0},
+               {0x249, 0x01, 0x0},
+               {0x24A, 0x01, 0x0},
                /* unmask ocaudio/accdet interrupts */
                {0x1d, 0x00, 0x00},
                {0x1e, 0x00, 0x00},
        };
        snd_msic_ops.card_status = SND_CARD_INIT_DONE;
-       sst_sc_reg_access(sc_access, PMIC_WRITE, 30);
+       sst_sc_reg_access(sc_access, PMIC_WRITE, 28);
        snd_msic_ops.pb_on = 0;
+       snd_msic_ops.pbhs_on = 0;
        snd_msic_ops.cap_on = 0;
        snd_msic_ops.input_dev_id = DMIC; /*def dev*/
        snd_msic_ops.output_dev_id = STEREO_HEADPHONE;
+       snd_msic_ops.jack_interrupt_status = false;
        pr_debug("msic init complete!!\n");
        return 0;
 }
+static int msic_line_out_restore(u8 value)
+{
+       struct sc_reg_access hs_drv_en[] = {
+               {0x25d, 0x03, 0x03},
+       };
+       struct sc_reg_access ep_drv_en[] = {
+               {0x25d, 0x40, 0x40},
+       };
+       struct sc_reg_access ihf_drv_en[] = {
+               {0x25d, 0x0c, 0x0c},
+       };
+       struct sc_reg_access vib1_drv_en[] = {
+               {0x25d, 0x10, 0x10},
+       };
+       struct sc_reg_access vib2_drv_en[] = {
+               {0x25d, 0x20, 0x20},
+       };
+       struct sc_reg_access pmode_enable[] = {
+               {0x381, 0x10, 0x10},
+       };
+       int retval = 0;
+
+       pr_debug("msic_lineout_restore_lineout_dev:%d\n", value);
+
+       switch (value) {
+       case HEADSET:
+               pr_debug("Selecting Lineout-HEADSET-restore\n");
+               if (snd_msic_ops.output_dev_id == STEREO_HEADPHONE)
+                       retval = sst_sc_reg_access(hs_drv_en,
+                                                       PMIC_READ_MODIFY, 1);
+               else
+                       retval = sst_sc_reg_access(ep_drv_en,
+                                                       PMIC_READ_MODIFY, 1);
+               break;
+       case IHF:
+               pr_debug("Selecting Lineout-IHF-restore\n");
+               retval = sst_sc_reg_access(ihf_drv_en, PMIC_READ_MODIFY, 1);
+               if (retval)
+                       return retval;
+               retval = sst_sc_reg_access(pmode_enable, PMIC_READ_MODIFY, 1);
+               break;
+       case VIBRA1:
+               pr_debug("Selecting Lineout-Vibra1-restore\n");
+               retval = sst_sc_reg_access(vib1_drv_en, PMIC_READ_MODIFY, 1);
+               break;
+       case VIBRA2:
+               pr_debug("Selecting Lineout-VIBRA2-restore\n");
+               retval = sst_sc_reg_access(vib2_drv_en, PMIC_READ_MODIFY, 1);
+               break;
+       case NONE:
+               pr_debug("Selecting Lineout-NONE-restore\n");
+               break;
+       default:
+               return -EINVAL;
+       }
+       return retval;
+}
+static int msic_get_lineout_prvstate(void)
+{
+       struct sc_reg_access hs_ihf_drv[2] = {
+               {0x257, 0x0, 0x0},
+               {0x25d, 0x0, 0x0},
+       };
+       struct sc_reg_access vib1drv[2] = {
+               {0x264, 0x0, 0x0},
+               {0x25D, 0x0, 0x0},
+       };
+       struct sc_reg_access vib2drv[2] = {
+               {0x26A, 0x0, 0x0},
+               {0x25D, 0x0, 0x0},
+       };
+       int retval = 0, drv_en, dac_en, dev_id, mask;
+       for (dev_id = 0; dev_id < snd_msic_ops.line_out_names_cnt; dev_id++) {
+               switch (dev_id) {
+               case HEADSET:
+                       pr_debug("msic_get_lineout_prvs_state: HEADSET\n");
+                       sst_sc_reg_access(hs_ihf_drv, PMIC_READ, 2);
+
+                       mask = (MASK0|MASK1);
+                       dac_en = (hs_ihf_drv[0].value) & mask;
+
+                       mask = ((MASK0|MASK1)|MASK6);
+                       drv_en = (hs_ihf_drv[1].value) & mask;
+
+                       if (dac_en && (!drv_en)) {
+                               snd_msic_ops.prev_lineout_dev_id = HEADSET;
+                               return retval;
+                       }
+                       break;
+               case IHF:
+                       pr_debug("msic_get_lineout_prvstate: IHF\n");
+                       sst_sc_reg_access(hs_ihf_drv, PMIC_READ, 2);
+
+                       mask = (MASK2 | MASK3);
+                       dac_en = (hs_ihf_drv[0].value) & mask;
+
+                       mask = (MASK2 | MASK3);
+                       drv_en = (hs_ihf_drv[1].value) & mask;
+
+                       if (dac_en && (!drv_en)) {
+                               snd_msic_ops.prev_lineout_dev_id = IHF;
+                               return retval;
+                       }
+                       break;
+               case VIBRA1:
+                       pr_debug("msic_get_lineout_prvstate: vibra1\n");
+                       sst_sc_reg_access(vib1drv, PMIC_READ, 2);
+
+                       mask = MASK1;
+                       dac_en = (vib1drv[0].value) & mask;
+
+                       mask = MASK4;
+                       drv_en = (vib1drv[1].value) & mask;
+
+                       if (dac_en && (!drv_en)) {
+                               snd_msic_ops.prev_lineout_dev_id = VIBRA1;
+                               return retval;
+                       }
+                       break;
+               case VIBRA2:
+                       pr_debug("msic_get_lineout_prvstate: vibra2\n");
+                       sst_sc_reg_access(vib2drv, PMIC_READ, 2);
+
+                       mask = MASK1;
+                       dac_en = (vib2drv[0].value) & mask;
+
+                       mask = MASK5;
+                       drv_en = ((vib2drv[1].value) & mask);
+
+                       if (dac_en && (!drv_en)) {
+                               snd_msic_ops.prev_lineout_dev_id = VIBRA2;
+                               return retval;
+                       }
+                       break;
+               case NONE:
+                       pr_debug("msic_get_lineout_prvstate: NONE\n");
+                       snd_msic_ops.prev_lineout_dev_id = NONE;
+                       return retval;
+               default:
+                       pr_debug("Invalid device id\n");
+                       snd_msic_ops.prev_lineout_dev_id = NONE;
+                       return -EINVAL;
+               }
+       }
+       return retval;
+}
+static int msic_set_selected_lineout_dev(u8 value)
+{
+       struct sc_reg_access lout_hs[] = {
+               {0x25e, 0x33, 0xFF},
+               {0x25d, 0x0, 0x43},
+       };
+       struct sc_reg_access lout_ihf[] = {
+               {0x25e, 0x55, 0xff},
+               {0x25d, 0x0, 0x0c},
+       };
+       struct sc_reg_access lout_vibra1[] = {
+
+               {0x25e, 0x61, 0xff},
+               {0x25d, 0x0, 0x10},
+       };
+       struct sc_reg_access lout_vibra2[] = {
+
+               {0x25e, 0x16, 0xff},
+               {0x25d, 0x0, 0x20},
+       };
+       struct sc_reg_access lout_def[] = {
+               {0x25e, 0x66, 0x0},
+       };
+       struct sc_reg_access pmode_disable[] = {
+               {0x381, 0x00, 0x10},
+       };
+       struct sc_reg_access pmode_enable[] = {
+               {0x381, 0x10, 0x10},
+       };
+       int retval = 0;
+
+       pr_debug("msic_set_selected_lineout_dev:%d\n", value);
+       msic_get_lineout_prvstate();
+       msic_line_out_restore(snd_msic_ops.prev_lineout_dev_id);
+       snd_msic_ops.lineout_dev_id = value;
+
+       switch (value) {
+       case HEADSET:
+               pr_debug("Selecting Lineout-HEADSET\n");
+               if (snd_msic_ops.pb_on)
+                       retval = sst_sc_reg_access(lout_hs,
+                                       PMIC_READ_MODIFY, 2);
+                       if (retval)
+                               return retval;
+                       retval = sst_sc_reg_access(pmode_disable,
+                                       PMIC_READ_MODIFY, 1);
+               break;
+       case IHF:
+               pr_debug("Selecting Lineout-IHF\n");
+               if (snd_msic_ops.pb_on)
+                       retval = sst_sc_reg_access(lout_ihf,
+                                                       PMIC_READ_MODIFY, 2);
+                       if (retval)
+                               return retval;
+                       retval = sst_sc_reg_access(pmode_enable,
+                                       PMIC_READ_MODIFY, 1);
+               break;
+       case VIBRA1:
+               pr_debug("Selecting Lineout-Vibra1\n");
+               if (snd_msic_ops.pb_on)
+                       retval = sst_sc_reg_access(lout_vibra1,
+                                                       PMIC_READ_MODIFY, 2);
+                       if (retval)
+                               return retval;
+                       retval = sst_sc_reg_access(pmode_disable,
+                                       PMIC_READ_MODIFY, 1);
+               break;
+       case VIBRA2:
+               pr_debug("Selecting Lineout-VIBRA2\n");
+               if (snd_msic_ops.pb_on)
+                       retval = sst_sc_reg_access(lout_vibra2,
+                                                       PMIC_READ_MODIFY, 2);
+                       if (retval)
+                               return retval;
+                       retval = sst_sc_reg_access(pmode_disable,
+                                       PMIC_READ_MODIFY, 1);
+               break;
+       case NONE:
+               pr_debug("Selecting Lineout-NONE\n");
+                       retval = sst_sc_reg_access(lout_def,
+                                                       PMIC_WRITE, 1);
+                       if (retval)
+                               return retval;
+                       retval = sst_sc_reg_access(pmode_disable,
+                                       PMIC_READ_MODIFY, 1);
+               break;
+       default:
+               return -EINVAL;
+       }
+       return retval;
+}
+
 
 static int msic_power_up_pb(unsigned int device)
 {
-       struct sc_reg_access sc_access1[] = {
+       struct sc_reg_access vaud[] = {
                /* turn on the audio power supplies */
-               {0x0DB, 0x05, 0},
+               {0x0DB, 0x07, 0},
+       };
+       struct sc_reg_access pll[] = {
+               /* turn on PLL */
+               {0x240, 0x20, 0},
+       };
+       struct sc_reg_access vhs[] = {
                /*  VHSP */
-               {0x0DC, 0xFF, 0},
+               {0x0DC, 0x3D, 0},
                /*  VHSN */
                {0x0DD, 0x3F, 0},
-               /* turn on PLL */
-               {0x240, 0x21, 0},
        };
-       struct sc_reg_access sc_access2[] = {
+       struct sc_reg_access hsdac[] = {
+               {0x382, 0x40, 0x40},
                /*  disable driver */
                {0x25D, 0x0, 0x43},
                /* DAC CONFIG ; both HP, LP on */
                {0x257, 0x03, 0x03},
        };
-       struct sc_reg_access sc_access3[] = {
+       struct sc_reg_access hs_filter[] = {
                /* HSEPRXCTRL  Enable the headset left and right FIR filters  */
                {0x250, 0x30, 0},
                /* HSMIXER */
                {0x256, 0x11, 0},
        };
-       struct sc_reg_access sc_access4[] = {
+       struct sc_reg_access hs_enable[] = {
                /* enable driver */
                {0x25D, 0x3, 0x3},
+               {0x26C, 0x0, 0x2},
                /* unmute the headset */
                { 0x259, 0x80, 0x80},
                { 0x25A, 0x80, 0x80},
        };
-       struct sc_reg_access sc_access_vihf[] = {
+       struct sc_reg_access vihf[] = {
                /*  VIHF ON */
-               {0x0C9, 0x2D, 0x00},
+               {0x0C9, 0x27, 0x00},
        };
-       struct sc_reg_access sc_access22[] = {
+       struct sc_reg_access ihf_filter[] = {
                /*  disable driver */
                {0x25D, 0x00, 0x0C},
                /*Filer DAC enable*/
                {0x251, 0x03, 0x03},
                {0x257, 0x0C, 0x0C},
        };
-       struct sc_reg_access sc_access32[] = {
+       struct sc_reg_access ihf_en[] = {
                /*enable drv*/
                {0x25D, 0x0C, 0x0c},
        };
-       struct sc_reg_access sc_access42[] = {
+       struct sc_reg_access ihf_unmute[] = {
                /*unmute headset*/
                {0x25B, 0x80, 0x80},
                {0x25C, 0x80, 0x80},
        };
-       struct sc_reg_access sc_access23[] = {
+       struct sc_reg_access epdac[] = {
                /*  disable driver */
                {0x25D, 0x0, 0x43},
                /* DAC CONFIG ; both HP, LP on */
                {0x257, 0x03, 0x03},
        };
-       struct sc_reg_access sc_access43[] = {
+       struct sc_reg_access ep_enable[] = {
                /* enable driver */
                {0x25D, 0x40, 0x40},
                /* unmute the headset */
                { 0x259, 0x80, 0x80},
                { 0x25A, 0x80, 0x80},
        };
-       struct sc_reg_access sc_access_vib[] = {
+       struct sc_reg_access vib1_en[] = {
                /* enable driver, ADC */
                {0x25D, 0x10, 0x10},
-               {0x264, 0x02, 0x02},
+               {0x264, 0x02, 0x82},
        };
-       struct sc_reg_access sc_access_hap[] = {
+       struct sc_reg_access vib2_en[] = {
                /* enable driver, ADC */
                {0x25D, 0x20, 0x20},
-               {0x26A, 0x02, 0x02},
+               {0x26A, 0x02, 0x82},
        };
-       struct sc_reg_access sc_access_pcm2[] = {
+       struct sc_reg_access pcm2_en[] = {
                /* enable pcm 2 */
                {0x27C, 0x1, 0x1},
        };
@@ -176,89 +425,95 @@ static int msic_power_up_pb(unsigned int device)
        }
 
        pr_debug("powering up pb.... Device %d\n", device);
-       sst_sc_reg_access(sc_access1, PMIC_WRITE, 4);
+       sst_sc_reg_access(vaud, PMIC_WRITE, 1);
+       msleep(1);
+       sst_sc_reg_access(pll, PMIC_WRITE, 1);
+       msleep(1);
        switch (device) {
        case SND_SST_DEVICE_HEADSET:
+               snd_msic_ops.pb_on = 1;
+               snd_msic_ops.pbhs_on = 1;
                if (snd_msic_ops.output_dev_id == STEREO_HEADPHONE) {
-                       sst_sc_reg_access(sc_access2, PMIC_READ_MODIFY, 2);
-                       sst_sc_reg_access(sc_access3, PMIC_WRITE, 2);
-                       sst_sc_reg_access(sc_access4, PMIC_READ_MODIFY, 3);
+                       sst_sc_reg_access(vhs, PMIC_WRITE, 2);
+                       sst_sc_reg_access(hsdac, PMIC_READ_MODIFY, 3);
+                       sst_sc_reg_access(hs_filter, PMIC_WRITE, 2);
+                       sst_sc_reg_access(hs_enable, PMIC_READ_MODIFY, 4);
                } else {
-                       sst_sc_reg_access(sc_access23, PMIC_READ_MODIFY, 2);
-                       sst_sc_reg_access(sc_access3, PMIC_WRITE, 2);
-                       sst_sc_reg_access(sc_access43, PMIC_READ_MODIFY, 3);
+                       sst_sc_reg_access(epdac, PMIC_READ_MODIFY, 2);
+                       sst_sc_reg_access(hs_filter, PMIC_WRITE, 2);
+                       sst_sc_reg_access(ep_enable, PMIC_READ_MODIFY, 3);
                }
-               snd_msic_ops.pb_on = 1;
+               if (snd_msic_ops.lineout_dev_id == HEADSET)
+                       msic_set_selected_lineout_dev(HEADSET);
                break;
-
        case SND_SST_DEVICE_IHF:
-               sst_sc_reg_access(sc_access_vihf, PMIC_WRITE, 1);
-               sst_sc_reg_access(sc_access22, PMIC_READ_MODIFY, 3);
-               sst_sc_reg_access(sc_access32, PMIC_READ_MODIFY, 1);
-               sst_sc_reg_access(sc_access42, PMIC_READ_MODIFY, 2);
+               snd_msic_ops.pb_on = 1;
+               sst_sc_reg_access(vihf, PMIC_WRITE, 1);
+               sst_sc_reg_access(ihf_filter, PMIC_READ_MODIFY, 3);
+               sst_sc_reg_access(ihf_en, PMIC_READ_MODIFY, 1);
+               sst_sc_reg_access(ihf_unmute, PMIC_READ_MODIFY, 2);
+               if (snd_msic_ops.lineout_dev_id == IHF)
+                       msic_set_selected_lineout_dev(IHF);
                break;
 
        case SND_SST_DEVICE_VIBRA:
-               sst_sc_reg_access(sc_access_vib, PMIC_READ_MODIFY, 2);
+               snd_msic_ops.pb_on = 1;
+               sst_sc_reg_access(vib1_en, PMIC_READ_MODIFY, 2);
+               if (snd_msic_ops.lineout_dev_id == VIBRA1)
+                       msic_set_selected_lineout_dev(VIBRA1);
                break;
 
        case SND_SST_DEVICE_HAPTIC:
-               sst_sc_reg_access(sc_access_hap, PMIC_READ_MODIFY, 2);
+               snd_msic_ops.pb_on = 1;
+               sst_sc_reg_access(vib2_en, PMIC_READ_MODIFY, 2);
+               if (snd_msic_ops.lineout_dev_id == VIBRA2)
+                       msic_set_selected_lineout_dev(VIBRA2);
                break;
 
        default:
                pr_warn("Wrong Device %d, selected %d\n",
                               device, snd_msic_ops.output_dev_id);
        }
-       return sst_sc_reg_access(sc_access_pcm2, PMIC_READ_MODIFY, 1);
+       return sst_sc_reg_access(pcm2_en, PMIC_READ_MODIFY, 1);
 }
 
 static int msic_power_up_cp(unsigned int device)
 {
-       struct sc_reg_access sc_access[] = {
+       struct sc_reg_access vaud[] = {
                /* turn on the audio power supplies */
-               {0x0DB, 0x05, 0},
-               /*  VHSP */
-               {0x0DC, 0xFF, 0},
-               /*  VHSN */
-               {0x0DD, 0x3F, 0},
+               {0x0DB, 0x07, 0},
+       };
+       struct sc_reg_access pll[] = {
                /* turn on PLL */
-               {0x240, 0x21, 0},
-
-               /*  Turn on DMIC supply  */
-               {0x247, 0xA0, 0x0},
-               {0x240, 0x21, 0x0},
-               {0x24C, 0x10, 0x0},
-
+               {0x240, 0x20, 0},
+       };
+       struct sc_reg_access dmic_bias[] = {
+               /*  Turn on AMIC supply  */
+               {0x247, 0xA0, 0xA0},
+       };
+       struct sc_reg_access dmic[] = {
                /* mic demux enable */
-               {0x245, 0x3F, 0x0},
-               {0x246, 0x7, 0x0},
+               {0x245, 0x3F, 0x3F},
+               {0x246, 0x07, 0x07},
 
        };
-       struct sc_reg_access sc_access_amic[] = {
-               /* turn on the audio power supplies */
-               {0x0DB, 0x05, 0},
-               /*  VHSP */
-               {0x0DC, 0xFF, 0},
-               /*  VHSN */
-               {0x0DD, 0x3F, 0},
-               /* turn on PLL */
-               {0x240, 0x21, 0},
-               /*ADC EN*/
-               {0x248, 0x05, 0x0},
-               {0x24C, 0x76, 0x0},
-               /*MIC EN*/
-               {0x249, 0x09, 0x0},
-               {0x24A, 0x09, 0x0},
+       struct sc_reg_access amic_bias[] = {
                /*  Turn on AMIC supply  */
-               {0x247, 0xFC, 0x0},
+               {0x247, 0xFC, 0xFC},
+       };
+       struct sc_reg_access amic[] = {
+               /*MIC EN*/
+               {0x249, 0x01, 0x01},
+               {0x24A, 0x01, 0x01},
+               /*ADC EN*/
+               {0x248, 0x05, 0x0F},
 
        };
-       struct sc_reg_access sc_access2[] = {
+       struct sc_reg_access pcm2[] = {
                /* enable pcm 2 */
                {0x27C, 0x1, 0x1},
        };
-       struct sc_reg_access sc_access3[] = {
+       struct sc_reg_access tx_on[] = {
                /*wait for mic to stabalize before turning on audio channels*/
                {0x24F, 0x3C, 0x0},
        };
@@ -271,42 +526,161 @@ static int msic_power_up_cp(unsigned int device)
        }
 
        pr_debug("powering up cp....%d\n", snd_msic_ops.input_dev_id);
-       sst_sc_reg_access(sc_access2, PMIC_READ_MODIFY, 1);
+       sst_sc_reg_access(vaud, PMIC_WRITE, 1);
+       msleep(500);/*FIXME need optimzed value here*/
+       sst_sc_reg_access(pll, PMIC_WRITE, 1);
+       msleep(1);
        snd_msic_ops.cap_on = 1;
-       if (snd_msic_ops.input_dev_id == AMIC)
-               sst_sc_reg_access(sc_access_amic, PMIC_WRITE, 9);
-       else
-               sst_sc_reg_access(sc_access, PMIC_WRITE, 9);
-       return sst_sc_reg_access(sc_access3, PMIC_WRITE, 1);
-
+       if (snd_msic_ops.input_dev_id == AMIC) {
+               sst_sc_reg_access(amic_bias, PMIC_READ_MODIFY, 1);
+               msleep(1);
+               sst_sc_reg_access(amic, PMIC_READ_MODIFY, 3);
+       } else {
+               sst_sc_reg_access(dmic_bias, PMIC_READ_MODIFY, 1);
+               msleep(1);
+               sst_sc_reg_access(dmic, PMIC_READ_MODIFY, 2);
+       }
+       msleep(1);
+       sst_sc_reg_access(tx_on, PMIC_WRITE, 1);
+       return sst_sc_reg_access(pcm2, PMIC_READ_MODIFY, 1);
 }
 
 static int msic_power_down(void)
 {
-       int retval = 0;
+       struct sc_reg_access power_dn[] = {
+               /*  VHSP */
+               {0x0DC, 0xC4, 0},
+               /*  VHSN */
+               {0x0DD, 0x04, 0},
+               /*  VIHF */
+               {0x0C9, 0x24, 0},
+       };
+       struct sc_reg_access pll[] = {
+               /* turn off PLL*/
+               {0x240, 0x00, 0x0},
+       };
+       struct sc_reg_access vaud[] = {
+               /* turn off VAUD*/
+               {0x0DB, 0x04, 0},
+       };
 
        pr_debug("powering dn msic\n");
+       snd_msic_ops.pbhs_on = 0;
        snd_msic_ops.pb_on = 0;
        snd_msic_ops.cap_on = 0;
-       return retval;
+       sst_sc_reg_access(power_dn, PMIC_WRITE, 3);
+       msleep(1);
+       sst_sc_reg_access(pll, PMIC_WRITE, 1);
+       msleep(1);
+       sst_sc_reg_access(vaud, PMIC_WRITE, 1);
+       return 0;
 }
 
-static int msic_power_down_pb(void)
+static int msic_power_down_pb(unsigned int device)
 {
-       int retval = 0;
+       struct sc_reg_access drv_enable[] = {
+               {0x25D, 0x00, 0x00},
+       };
+       struct sc_reg_access hs_mute[] = {
+               {0x259, 0x80, 0x80},
+               {0x25A, 0x80, 0x80},
+               {0x26C, 0x02, 0x02},
+       };
+       struct sc_reg_access hs_off[] = {
+               {0x257, 0x00, 0x03},
+               {0x250, 0x00, 0x30},
+               {0x382, 0x00, 0x40},
+       };
+       struct sc_reg_access ihf_mute[] = {
+               {0x25B, 0x80, 0x80},
+               {0x25C, 0x80, 0x80},
+       };
+       struct sc_reg_access ihf_off[] = {
+               {0x257, 0x00, 0x0C},
+               {0x251, 0x00, 0x03},
+       };
+       struct sc_reg_access vib1_off[] = {
+               {0x264, 0x00, 0x82},
+       };
+       struct sc_reg_access vib2_off[] = {
+               {0x26A, 0x00, 0x82},
+       };
+       struct sc_reg_access lout_off[] = {
+               {0x25e, 0x66, 0x00},
+       };
+       struct sc_reg_access pmode_disable[] = {
+               {0x381, 0x00, 0x10},
+       };
 
-       pr_debug("powering dn pb....\n");
-       snd_msic_ops.pb_on = 0;
-       return retval;
+
+
+       pr_debug("powering dn pb for device %d\n", device);
+       switch (device) {
+       case SND_SST_DEVICE_HEADSET:
+               snd_msic_ops.pbhs_on = 0;
+               sst_sc_reg_access(hs_mute, PMIC_READ_MODIFY, 3);
+               drv_enable[0].mask = 0x43;
+               sst_sc_reg_access(drv_enable, PMIC_READ_MODIFY, 1);
+               sst_sc_reg_access(hs_off, PMIC_READ_MODIFY, 3);
+               if (snd_msic_ops.lineout_dev_id == HEADSET)
+                       sst_sc_reg_access(lout_off, PMIC_WRITE, 1);
+               break;
+
+       case SND_SST_DEVICE_IHF:
+               sst_sc_reg_access(ihf_mute, PMIC_READ_MODIFY, 2);
+               drv_enable[0].mask = 0x0C;
+               sst_sc_reg_access(drv_enable, PMIC_READ_MODIFY, 1);
+               sst_sc_reg_access(ihf_off, PMIC_READ_MODIFY, 2);
+               if (snd_msic_ops.lineout_dev_id == IHF) {
+                       sst_sc_reg_access(lout_off, PMIC_WRITE, 1);
+                       sst_sc_reg_access(pmode_disable, PMIC_READ_MODIFY, 1);
+               }
+               break;
+
+       case SND_SST_DEVICE_VIBRA:
+               sst_sc_reg_access(vib1_off, PMIC_READ_MODIFY, 1);
+               drv_enable[0].mask = 0x10;
+               sst_sc_reg_access(drv_enable, PMIC_READ_MODIFY, 1);
+               if (snd_msic_ops.lineout_dev_id == VIBRA1)
+                       sst_sc_reg_access(lout_off, PMIC_WRITE, 1);
+               break;
+
+       case SND_SST_DEVICE_HAPTIC:
+               sst_sc_reg_access(vib2_off, PMIC_READ_MODIFY, 1);
+               drv_enable[0].mask = 0x20;
+               sst_sc_reg_access(drv_enable, PMIC_READ_MODIFY, 1);
+               if (snd_msic_ops.lineout_dev_id == VIBRA2)
+                       sst_sc_reg_access(lout_off, PMIC_WRITE, 1);
+               break;
+       }
+       return 0;
 }
 
-static int msic_power_down_cp(void)
+static int msic_power_down_cp(unsigned int device)
 {
-       int retval = 0;
+       struct sc_reg_access dmic[] = {
+               {0x247, 0x00, 0xA0},
+               {0x245, 0x00, 0x38},
+               {0x246, 0x00, 0x07},
+       };
+       struct sc_reg_access amic[] = {
+               {0x248, 0x00, 0x05},
+               {0x249, 0x00, 0x01},
+               {0x24A, 0x00, 0x01},
+               {0x247, 0x00, 0xA3},
+       };
+       struct sc_reg_access tx_off[] = {
+               {0x24F, 0x00, 0x3C},
+       };
 
        pr_debug("powering dn cp....\n");
        snd_msic_ops.cap_on = 0;
-       return retval;
+       sst_sc_reg_access(tx_off, PMIC_READ_MODIFY, 1);
+       if (snd_msic_ops.input_dev_id == DMIC)
+               sst_sc_reg_access(dmic, PMIC_READ_MODIFY, 3);
+       else
+               sst_sc_reg_access(amic, PMIC_READ_MODIFY, 4);
+       return 0;
 }
 
 static int msic_set_selected_output_dev(u8 value)
@@ -315,7 +689,7 @@ static int msic_set_selected_output_dev(u8 value)
 
        pr_debug("msic set selected output:%d\n", value);
        snd_msic_ops.output_dev_id = value;
-       if (snd_msic_ops.pb_on)
+       if (snd_msic_ops.pbhs_on)
                msic_power_up_pb(SND_SST_DEVICE_HEADSET);
        return retval;
 }
@@ -352,6 +726,57 @@ static int msic_set_selected_input_dev(u8 value)
        return retval;
 }
 
+static int msic_set_hw_dmic_route(u8 hw_ch_index)
+{
+       struct sc_reg_access sc_access_router;
+       int    retval = -EINVAL;
+
+       switch (hw_ch_index) {
+       case HW_CH0:
+               sc_access_router.reg_addr = AUDIOMUX12;
+               sc_access_router.value    = snd_msic_ops.hw_dmic_map[0];
+               sc_access_router.mask     = (MASK2 | MASK1 | MASK0);
+               pr_debug("hw_ch0.  value = 0x%x\n",
+                               sc_access_router.value);
+               retval = sst_sc_reg_access(&sc_access_router,
+                               PMIC_READ_MODIFY, 1);
+               break;
+
+       case HW_CH1:
+               sc_access_router.reg_addr = AUDIOMUX12;
+               sc_access_router.value    = (snd_msic_ops.hw_dmic_map[1]) << 4;
+               sc_access_router.mask     = (MASK6 | MASK5 | MASK4);
+               pr_debug("### hw_ch1.  value = 0x%x\n",
+                               sc_access_router.value);
+               retval = sst_sc_reg_access(&sc_access_router,
+                               PMIC_READ_MODIFY, 1);
+               break;
+
+       case HW_CH2:
+               sc_access_router.reg_addr = AUDIOMUX34;
+               sc_access_router.value    = snd_msic_ops.hw_dmic_map[2];
+               sc_access_router.mask     = (MASK2 | MASK1 | MASK0);
+               pr_debug("hw_ch2.  value = 0x%x\n",
+                               sc_access_router.value);
+               retval = sst_sc_reg_access(&sc_access_router,
+                               PMIC_READ_MODIFY, 1);
+               break;
+
+       case HW_CH3:
+               sc_access_router.reg_addr = AUDIOMUX34;
+               sc_access_router.value    = (snd_msic_ops.hw_dmic_map[3]) << 4;
+               sc_access_router.mask     = (MASK6 | MASK5 | MASK4);
+               pr_debug("hw_ch3.  value = 0x%x\n",
+                               sc_access_router.value);
+               retval = sst_sc_reg_access(&sc_access_router,
+                               PMIC_READ_MODIFY, 1);
+               break;
+       }
+
+       return retval;
+}
+
+
 static int msic_set_pcm_voice_params(void)
 {
        return 0;
@@ -392,9 +817,215 @@ static int msic_get_vol(int dev_id, int *value)
        return 0;
 }
 
+static int msic_set_headset_state(int state)
+{
+       struct sc_reg_access hs_enable[] = {
+               {0x25D, 0x03, 0x03},
+       };
+
+       if (state)
+               /*enable*/
+               sst_sc_reg_access(hs_enable, PMIC_READ_MODIFY, 1);
+       else {
+               hs_enable[0].value = 0;
+               sst_sc_reg_access(hs_enable, PMIC_READ_MODIFY, 1);
+       }
+       return 0;
+}
+
+static int msic_enable_mic_bias(void)
+{
+       struct sc_reg_access jack_interrupt_reg[] = {
+               {0x0DB, 0x07, 0x00},
+
+       };
+       struct sc_reg_access jack_bias_reg[] = {
+               {0x247, 0x0C, 0x0C},
+       };
+
+       sst_sc_reg_access(jack_interrupt_reg, PMIC_WRITE, 1);
+       sst_sc_reg_access(jack_bias_reg, PMIC_READ_MODIFY, 1);
+       return 0;
+}
+
+static int msic_disable_mic_bias(void)
+{
+       if (snd_msic_ops.jack_interrupt_status == true)
+               return 0;
+       if (!(snd_msic_ops.pb_on || snd_msic_ops.cap_on))
+               msic_power_down();
+       return 0;
+}
+
+static int msic_disable_jack_btn(void)
+{
+       struct sc_reg_access btn_disable[] = {
+               {0x26C, 0x00, 0x01}
+       };
+
+       if (!(snd_msic_ops.pb_on || snd_msic_ops.cap_on))
+               msic_power_down();
+       snd_msic_ops.jack_interrupt_status = false;
+       return sst_sc_reg_access(btn_disable, PMIC_READ_MODIFY, 1);
+}
+
+static int msic_enable_jack_btn(void)
+{
+       struct sc_reg_access btn_enable[] = {
+                       {0x26b, 0x77, 0x00},
+                       {0x26C, 0x01, 0x00},
+       };
+       return sst_sc_reg_access(btn_enable, PMIC_WRITE, 2);
+}
+static int msic_convert_adc_to_mvolt(unsigned int mic_bias)
+{
+       return (ADC_ONE_LSB_MULTIPLIER * mic_bias) / 1000;
+}
+int msic_get_headset_state(int mic_bias)
+{
+       struct sc_reg_access msic_hs_toggle[] = {
+               {0x070, 0x00, 0x01},
+       };
+       if (mic_bias >= 0 && mic_bias < 400) {
+
+               pr_debug("Detected Headphone!!!\n");
+               sst_sc_reg_access(msic_hs_toggle, PMIC_READ_MODIFY, 1);
+
+       } else if (mic_bias > 400 && mic_bias < 650) {
+
+               pr_debug("Detected American headset\n");
+               msic_hs_toggle[0].value = 0x01;
+               sst_sc_reg_access(msic_hs_toggle, PMIC_READ_MODIFY, 1);
+
+       } else if (mic_bias >= 650 && mic_bias < 2000) {
+
+               pr_debug("Detected Headset!!!\n");
+               sst_sc_reg_access(msic_hs_toggle, PMIC_READ_MODIFY, 1);
+               /*power on jack and btn*/
+               snd_msic_ops.jack_interrupt_status = true;
+               msic_enable_jack_btn();
+               msic_enable_mic_bias();
+               return SND_JACK_HEADSET;
+
+       } else
+               pr_debug("Detected Open Cable!!!\n");
+
+       return SND_JACK_HEADPHONE;
+}
+
+static int msic_get_mic_bias(void *arg)
+{
+       struct snd_intelmad *intelmad_drv = (struct snd_intelmad *)arg;
+       u16 adc_adr = intelmad_drv->adc_address;
+       u16 adc_val;
+       int ret;
+       struct sc_reg_access adc_ctrl3[2] = {
+                       {0x1C2, 0x05, 0x0},
+       };
+
+       struct sc_reg_access audio_adc_reg1 = {0,};
+       struct sc_reg_access audio_adc_reg2 = {0,};
+
+       msic_enable_mic_bias();
+       /* Enable the msic for conversion before reading */
+       ret = sst_sc_reg_access(adc_ctrl3, PMIC_WRITE, 1);
+       if (ret)
+               return ret;
+       adc_ctrl3[0].value = 0x04;
+       /* Re-toggle the RRDATARD bit */
+       ret = sst_sc_reg_access(adc_ctrl3, PMIC_WRITE, 1);
+       if (ret)
+               return ret;
+
+       audio_adc_reg1.reg_addr = adc_adr;
+       /* Read the higher bits of data */
+       msleep(1000);
+       ret = sst_sc_reg_access(&audio_adc_reg1, PMIC_READ, 1);
+       if (ret)
+               return ret;
+       pr_debug("adc read value %x", audio_adc_reg1.value);
+
+       /* Shift bits to accomodate the lower two data bits */
+       adc_val = (audio_adc_reg1.value << 2);
+       adc_adr++;
+       audio_adc_reg2. reg_addr = adc_adr;
+       ret = sst_sc_reg_access(&audio_adc_reg2, PMIC_READ, 1);
+       if (ret)
+               return ret;
+       pr_debug("adc read value %x", audio_adc_reg2.value);
+
+       /* Adding lower two bits to the higher bits */
+       audio_adc_reg2.value &= 03;
+       adc_val += audio_adc_reg2.value;
+
+       pr_debug("ADC value 0x%x", adc_val);
+       msic_disable_mic_bias();
+       return adc_val;
+}
+
+static void msic_pmic_irq_cb(void *cb_data, u8 intsts)
+{
+       struct mad_jack *mjack = NULL;
+       unsigned int present = 0, jack_event_flag = 0, buttonpressflag = 0;
+       struct snd_intelmad *intelmaddata = cb_data;
+       int retval = 0;
+
+       pr_debug("value returned = 0x%x\n", intsts);
+
+       if (snd_msic_ops.card_status == SND_CARD_UN_INIT) {
+               retval = msic_init_card();
+               if (retval)
+                       return;
+         }
+
+       mjack = &intelmaddata->jack[0];
+       if (intsts & 0x1) {
+               pr_debug("MAD short_push detected\n");
+               present = SND_JACK_BTN_0;
+               jack_event_flag = buttonpressflag = 1;
+               mjack->jack.type = SND_JACK_BTN_0;
+               mjack->jack.key[0] = BTN_0 ;
+       }
+
+       if (intsts & 0x2) {
+               pr_debug(":MAD long_push detected\n");
+               jack_event_flag = buttonpressflag = 1;
+               mjack->jack.type = present = SND_JACK_BTN_1;
+               mjack->jack.key[1] = BTN_1;
+       }
+
+       if (intsts & 0x4) {
+               unsigned int mic_bias;
+               jack_event_flag = 1;
+               buttonpressflag = 0;
+               mic_bias = msic_get_mic_bias(intelmaddata);
+               pr_debug("mic_bias = %d\n", mic_bias);
+               mic_bias = msic_convert_adc_to_mvolt(mic_bias);
+               pr_debug("mic_bias after conversion = %d mV\n", mic_bias);
+               mjack->jack_dev_state = msic_get_headset_state(mic_bias);
+               mjack->jack.type = present = mjack->jack_dev_state;
+       }
+
+       if (intsts & 0x8) {
+               mjack->jack.type = mjack->jack_dev_state;
+               present = 0;
+               jack_event_flag = 1;
+               buttonpressflag = 0;
+               msic_disable_jack_btn();
+               msic_disable_mic_bias();
+       }
+       if (jack_event_flag)
+               sst_mad_send_jack_report(&mjack->jack,
+                                       buttonpressflag, present);
+}
+
+
+
 struct snd_pmic_ops snd_msic_ops = {
        .set_input_dev  =       msic_set_selected_input_dev,
        .set_output_dev =       msic_set_selected_output_dev,
+       .set_lineout_dev =      msic_set_selected_lineout_dev,
+       .set_hw_dmic_route =    msic_set_hw_dmic_route,
        .set_mute       =       msic_set_mute,
        .get_mute       =       msic_get_mute,
        .set_vol        =       msic_set_vol,
@@ -408,5 +1039,9 @@ struct snd_pmic_ops snd_msic_ops = {
        .power_up_pmic_cp =     msic_power_up_cp,
        .power_down_pmic_pb =   msic_power_down_pb,
        .power_down_pmic_cp =   msic_power_down_cp,
-       .power_down_pmic =      msic_power_down,
+       .power_down_pmic        =       msic_power_down,
+       .pmic_irq_cb    =       msic_pmic_irq_cb,
+       .pmic_jack_enable = msic_enable_mic_bias,
+       .pmic_get_mic_bias      = msic_get_mic_bias,
+       .pmic_set_headset_state = msic_set_headset_state,
 };
index 3ba9daf675268bac500d616a0cd65940b7b490a5..90e0e64c0ab0a8baec8ecc15a80a5f17eee4d510 100644 (file)
@@ -31,7 +31,6 @@
 #include <sound/core.h>
 #include <sound/control.h>
 #include <sound/pcm.h>
-#include "jack.h"
 #include "intel_sst.h"
 #include "intel_sst_ioctl.h"
 #include "intelmid_snd_control.h"
index a4565f33a91b225ec40323d6d700de7e32b9babf..06ad3a10099cfc3ab832d8a085a1b870c4ae1b0b 100644 (file)
@@ -80,6 +80,13 @@ enum SND_INPUT_DEVICE {
        HS_MIC,
        IN_UNDEFINED
 };
+enum SND_LINE_OUT_DEVICE {
+       HEADSET,
+       IHF,
+       VIBRA1,
+       VIBRA2,
+       NONE,
+};
 
 enum SND_OUTPUT_DEVICE {
        STEREO_HEADPHONE,
@@ -104,6 +111,8 @@ enum pmic_controls {
        PMIC_SND_RIGHT_SPEAKER_MUTE =           0x0015,
        PMIC_SND_RECEIVER_VOL =                 0x0016,
        PMIC_SND_RECEIVER_MUTE =                0x0017,
+       PMIC_SND_LEFT_MASTER_VOL =              0x0018,
+       PMIC_SND_RIGHT_MASTER_VOL =             0x0019,
 /* Other controls */
        PMIC_SND_MUTE_ALL =                     0x0020,
        PMIC_MAX_CONTROLS =                     0x0020,
index 7756f8feaf851f42cfe151b150de14605da8ded8..b8dfdb9bc1aa8bba8d7515479e80a93de7b3562f 100644 (file)
 
 #include <linux/pci.h>
 #include <linux/file.h>
+#include <sound/control.h>
 #include "intel_sst.h"
 #include "intelmid_snd_control.h"
-
+#include "intelmid.h"
 
 enum _reg_v1 {
        VOICEPORT1 = 0x180,
@@ -64,6 +65,7 @@ enum _reg_v1 {
 };
 
 int rev_id = 0x20;
+static bool jack_det_enabled;
 
 /****
  * fs_init_card - initialize the sound card
@@ -157,7 +159,7 @@ static int fs_power_up_pb(unsigned int port)
        return fs_enable_audiodac(UNMUTE);
 }
 
-static int fs_power_down_pb(void)
+static int fs_power_down_pb(unsigned int device)
 {
        struct sc_reg_access sc_access[] = {
                {POWERCTRL1, 0x00, 0xC6},
@@ -195,7 +197,7 @@ static int fs_power_up_cp(unsigned int port)
        return sst_sc_reg_access(sc_access, PMIC_READ_MODIFY, 2);
 }
 
-static int fs_power_down_cp(void)
+static int fs_power_down_cp(unsigned int device)
 {
        struct sc_reg_access sc_access[] = {
                {POWERCTRL2, 0x00, 0x03},
@@ -753,6 +755,90 @@ static int fs_get_vol(int dev_id, int *value)
        return retval;
 }
 
+static void fs_pmic_irq_enable(void *data)
+{
+       struct snd_intelmad *intelmaddata = data;
+       struct sc_reg_access sc_access[] = {
+                               {0x187, 0x00, MASK7},
+                               {0x188, 0x10, MASK4},
+                               {0x18b, 0x10, MASK4},
+       };
+
+       struct sc_reg_access sc_access_write[] = {
+                               {0x198, 0x00, 0x0},
+       };
+       pr_debug("Audio interrupt enable\n");
+       sst_sc_reg_access(sc_access, PMIC_READ_MODIFY, 3);
+       sst_sc_reg_access(sc_access_write, PMIC_WRITE, 1);
+
+       intelmaddata->jack[0].jack_status = 0;
+       /*intelmaddata->jack[1].jack_status = 0;*/
+
+       jack_det_enabled = true;
+       return;
+}
+
+static void fs_pmic_irq_cb(void *cb_data, u8 value)
+{
+       struct mad_jack *mjack = NULL;
+       struct snd_intelmad *intelmaddata = cb_data;
+       unsigned int present = 0, jack_event_flag = 0, buttonpressflag = 0;
+
+       mjack = &intelmaddata->jack[0];
+
+       if (value & 0x4) {
+               if (!jack_det_enabled)
+                       fs_pmic_irq_enable(intelmaddata);
+
+               /* send headphone detect */
+               pr_debug(":MAD headphone %d\n", value & 0x4);
+               present = !(mjack->jack_status);
+               mjack->jack_status = present;
+               jack_event_flag = 1;
+               mjack->jack.type = SND_JACK_HEADPHONE;
+       }
+
+       if (value & 0x2) {
+               /* send short push */
+               pr_debug(":MAD short push %d\n", value & 0x2);
+               present = 1;
+               jack_event_flag = 1;
+               buttonpressflag = 1;
+               mjack->jack.type = MID_JACK_HS_SHORT_PRESS;
+       }
+
+       if (value & 0x1) {
+               /* send long push */
+               pr_debug(":MAD long push %d\n", value & 0x1);
+               present = 1;
+               jack_event_flag = 1;
+               buttonpressflag = 1;
+               mjack->jack.type = MID_JACK_HS_LONG_PRESS;
+       }
+
+       if (value & 0x8) {
+               if (!jack_det_enabled)
+                       fs_pmic_irq_enable(intelmaddata);
+               /* send headset detect */
+               pr_debug(":MAD headset = %d\n", value & 0x8);
+               present = !(mjack->jack_status);
+               mjack->jack_status = present;
+               jack_event_flag = 1;
+               mjack->jack.type = SND_JACK_HEADSET;
+       }
+
+
+       if (jack_event_flag)
+               sst_mad_send_jack_report(&mjack->jack,
+                                               buttonpressflag, present);
+
+       return;
+}
+static int fs_jack_enable(void)
+{
+       return 0;
+}
+
 struct snd_pmic_ops snd_pmic_ops_fs = {
        .set_input_dev = fs_set_selected_input_dev,
        .set_output_dev = fs_set_selected_output_dev,
@@ -765,9 +851,16 @@ struct snd_pmic_ops snd_pmic_ops_fs = {
        .set_pcm_voice_params = fs_set_pcm_voice_params,
        .set_voice_port = fs_set_voice_port,
        .set_audio_port = fs_set_audio_port,
-       .power_up_pmic_pb = fs_power_up_pb,
-       .power_up_pmic_cp = fs_power_up_cp,
-       .power_down_pmic_pb = fs_power_down_pb,
-       .power_down_pmic_cp = fs_power_down_cp,
-       .power_down_pmic = fs_power_down,
+       .power_up_pmic_pb =     fs_power_up_pb,
+       .power_up_pmic_cp =     fs_power_up_cp,
+       .power_down_pmic_pb =   fs_power_down_pb,
+       .power_down_pmic_cp =   fs_power_down_cp,
+       .power_down_pmic        =       fs_power_down,
+       .pmic_irq_cb    =       fs_pmic_irq_cb,
+       /*
+        * Jack detection enabling
+        * need be delayed till first IRQ happen.
+        */
+       .pmic_irq_enable =      NULL,
+       .pmic_jack_enable = fs_jack_enable,
 };
index 1ea81421805940acca598367a5fe6d3bba43d945..9d00728d8deb7e5669ca82a759c1708c977bb87f 100644 (file)
@@ -32,7 +32,6 @@
 #include <linux/file.h>
 #include <asm/mrst.h>
 #include <sound/pcm.h>
-#include "jack.h"
 #include <sound/pcm_params.h>
 #include <sound/control.h>
 #include <sound/initval.h>
@@ -212,7 +211,7 @@ static int mx_power_up_pb(unsigned int port)
        return mx_enable_audiodac(UNMUTE);
 }
 
-static int mx_power_down_pb(void)
+static int mx_power_down_pb(unsigned int device)
 {
        struct sc_reg_access sc_access[3];
        int retval = 0;
@@ -255,7 +254,7 @@ static int mx_power_up_cp(unsigned int port)
        return sst_sc_reg_access(sc_access, PMIC_READ_MODIFY, 2);
 }
 
-static int mx_power_down_cp(void)
+static int mx_power_down_cp(unsigned int device)
 {
        struct sc_reg_access sc_access[] = {
                {ENABLE_OPDEV_CTRL, 0x00, MASK1|MASK0},
@@ -832,6 +831,129 @@ static int mx_get_vol(int dev_id, int *value)
        return retval;
 }
 
+static u8 mx_get_jack_status(void)
+{
+       struct sc_reg_access sc_access_read = {0,};
+
+       sc_access_read.reg_addr = 0x201;
+       sst_sc_reg_access(&sc_access_read, PMIC_READ, 1);
+       pr_debug("value returned = 0x%x\n", sc_access_read.value);
+       return sc_access_read.value;
+}
+
+static void mx_pmic_irq_enable(void *data)
+{
+       struct snd_intelmad *intelmaddata = data;
+
+       intelmaddata->jack_prev_state = 0xc0;
+       return;
+}
+
+static void mx_pmic_irq_cb(void *cb_data, u8 intsts)
+{
+       u8 jack_cur_status, jack_prev_state = 0;
+       struct mad_jack *mjack = NULL;
+       unsigned int present = 0, jack_event_flag = 0, buttonpressflag = 0;
+       time_t  timediff;
+       struct snd_intelmad *intelmaddata = cb_data;
+
+       mjack = &intelmaddata->jack[0];
+       if (intsts & 0x2) {
+               jack_cur_status = mx_get_jack_status();
+               jack_prev_state = intelmaddata->jack_prev_state;
+               if ((jack_prev_state == 0xc0) && (jack_cur_status == 0x40)) {
+                       /*headset insert detected. */
+                       pr_debug("MAD headset inserted\n");
+                       present = 1;
+                       jack_event_flag = 1;
+                       mjack->jack_status = 1;
+                       mjack->jack.type = SND_JACK_HEADSET;
+               }
+
+               if ((jack_prev_state == 0xc0) && (jack_cur_status == 0x00)) {
+                       /* headphone insert detected. */
+                       pr_debug("MAD headphone inserted\n");
+                       present = 1;
+                       jack_event_flag = 1;
+                       mjack->jack.type = SND_JACK_HEADPHONE;
+               }
+
+               if ((jack_prev_state == 0x40) && (jack_cur_status == 0xc0)) {
+                       /* headset remove detected. */
+                       pr_debug("MAD headset removed\n");
+
+                       present = 0;
+                       jack_event_flag = 1;
+                       mjack->jack_status = 0;
+                       mjack->jack.type = SND_JACK_HEADSET;
+               }
+
+               if ((jack_prev_state == 0x00) && (jack_cur_status == 0xc0)) {
+                       /* headphone remove detected. */
+                       pr_debug("MAD headphone removed\n");
+                       present = 0;
+                       jack_event_flag = 1;
+                       mjack->jack.type = SND_JACK_HEADPHONE;
+               }
+
+               if ((jack_prev_state == 0x40) && (jack_cur_status == 0x00)) {
+                       /* button pressed */
+                       do_gettimeofday(&mjack->buttonpressed);
+                       pr_debug("MAD button press detected\n");
+               }
+
+               if ((jack_prev_state == 0x00) && (jack_cur_status == 0x40)) {
+                       if (mjack->jack_status) {
+                               /*button pressed */
+                               do_gettimeofday(
+                                       &mjack->buttonreleased);
+                               /*button pressed */
+                               pr_debug("MAD Button Released detected\n");
+                               timediff = mjack->buttonreleased.tv_sec -
+                                       mjack->buttonpressed.tv_sec;
+                               buttonpressflag = 1;
+
+                               if (timediff > 1) {
+                                       pr_debug("MAD long press dtd\n");
+                                       /* send headphone detect/undetect */
+                                       present = 1;
+                                       jack_event_flag = 1;
+                                       mjack->jack.type =
+                                                       MID_JACK_HS_LONG_PRESS;
+                               } else {
+                                       pr_debug("MAD short press dtd\n");
+                                       /* send headphone detect/undetect */
+                                       present = 1;
+                                       jack_event_flag = 1;
+                                       mjack->jack.type =
+                                               MID_JACK_HS_SHORT_PRESS;
+                               }
+                       } else {
+                               /***workaround for maxim
+                               hw issue,0x00 t 0x40 is not
+                               a valid transiton for Headset insertion */
+                               /*headset insert detected. */
+                               pr_debug("MAD headset inserted\n");
+                               present = 1;
+                               jack_event_flag = 1;
+                               mjack->jack_status = 1;
+                               mjack->jack.type = SND_JACK_HEADSET;
+                       }
+               }
+               intelmaddata->jack_prev_state  = jack_cur_status;
+               pr_debug("mx_pmic_irq_cb prv_state= 0x%x\n",
+                                       intelmaddata->jack_prev_state);
+       }
+
+       if (jack_event_flag)
+               sst_mad_send_jack_report(&mjack->jack,
+                                               buttonpressflag, present);
+}
+static int mx_jack_enable(void)
+{
+       return 0;
+}
+
 struct snd_pmic_ops snd_pmic_ops_mx = {
        .set_input_dev = mx_set_selected_input_dev,
        .set_output_dev = mx_set_selected_output_dev,
@@ -844,10 +966,13 @@ struct snd_pmic_ops snd_pmic_ops_mx = {
        .set_pcm_voice_params = mx_set_pcm_voice_params,
        .set_voice_port = mx_set_voice_port,
        .set_audio_port = mx_set_audio_port,
-       .power_up_pmic_pb = mx_power_up_pb,
-       .power_up_pmic_cp = mx_power_up_cp,
-       .power_down_pmic_pb = mx_power_down_pb,
-       .power_down_pmic_cp = mx_power_down_cp,
-       .power_down_pmic =  mx_power_down,
+       .power_up_pmic_pb =     mx_power_up_pb,
+       .power_up_pmic_cp =     mx_power_up_cp,
+       .power_down_pmic_pb =   mx_power_down_pb,
+       .power_down_pmic_cp =   mx_power_down_cp,
+       .power_down_pmic =      mx_power_down,
+       .pmic_irq_cb     =      mx_pmic_irq_cb,
+       .pmic_irq_enable =      mx_pmic_irq_enable,
+       .pmic_jack_enable =     mx_jack_enable,
 };
 
index 3c6b3abff3c3e3757fadc8b9a0f43b2895ff8bb6..000378a35c1fbb2255842d6dbd6ec9aff9408e65 100644 (file)
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
+#include <linux/gpio.h>
 #include <linux/pci.h>
 #include <linux/delay.h>
 #include <linux/file.h>
+#include <sound/control.h>
 #include "intel_sst.h"
 #include "intelmid_snd_control.h"
+#include "intelmid.h"
 
 enum reg_v3 {
        VAUDIOCNT = 0x51,
@@ -82,8 +85,15 @@ enum reg_v3 {
        HPLMIXSEL = 0x12b,
        HPRMIXSEL = 0x12c,
        LOANTIPOP = 0x12d,
+       AUXDBNC = 0x12f,
 };
 
+static void nc_set_amp_power(int power)
+{
+       if (snd_pmic_ops_nc.gpio_amp)
+               gpio_set_value(snd_pmic_ops_nc.gpio_amp, power);
+}
+
 /****
  * nc_init_card - initialize the sound card
  *
@@ -111,18 +121,20 @@ static int nc_init_card(void)
                {VOICEVOL, 0x0e, 0},
                {HPLVOL, 0x06, 0},
                {HPRVOL, 0x06, 0},
-               {MICCTRL, 0x41, 0x00},
+               {MICCTRL, 0x51, 0x00},
                {ADCSAMPLERATE, 0x8B, 0x00},
                {MICSELVOL, 0x5B, 0x00},
                {LILSEL, 0x06, 0},
                {LIRSEL, 0x46, 0},
                {LOANTIPOP, 0x00, 0},
                {DMICCTRL1, 0x40, 0},
+               {AUXDBNC, 0xff, 0},
        };
        snd_pmic_ops_nc.card_status = SND_CARD_INIT_DONE;
        snd_pmic_ops_nc.master_mute = UNMUTE;
        snd_pmic_ops_nc.mute_status = UNMUTE;
-       sst_sc_reg_access(sc_access, PMIC_WRITE, 26);
+       sst_sc_reg_access(sc_access, PMIC_WRITE, 27);
+       mutex_init(&snd_pmic_ops_nc.lock);
        pr_debug("init complete!!\n");
        return 0;
 }
@@ -169,6 +181,7 @@ static int nc_power_up_pb(unsigned int port)
                return retval;
        if (port == 0xFF)
                return 0;
+       mutex_lock(&snd_pmic_ops_nc.lock);
        nc_enable_audiodac(MUTE);
        msleep(30);
 
@@ -209,8 +222,21 @@ static int nc_power_up_pb(unsigned int port)
 
        msleep(30);
 
-       return nc_enable_audiodac(UNMUTE);
-
+       snd_pmic_ops_nc.pb_on = 1;
+
+       /*
+        * There is a mismatch between Playback Sources and the enumerated
+        * values of output sources.  This mismatch causes ALSA upper to send
+        * Item 1 for Internal Speaker, but the expected enumeration is 2!  For
+        * now, treat MONO_EARPIECE and INTERNAL_SPKR identically and power up
+        * the needed resources
+        */
+       if (snd_pmic_ops_nc.output_dev_id == MONO_EARPIECE ||
+           snd_pmic_ops_nc.output_dev_id == INTERNAL_SPKR)
+               nc_set_amp_power(1);
+       nc_enable_audiodac(UNMUTE);
+       mutex_unlock(&snd_pmic_ops_nc.lock);
+       return 0;
 }
 
 static int nc_power_up_cp(unsigned int port)
@@ -270,7 +296,6 @@ static int nc_power_down(void)
        int retval = 0;
        struct sc_reg_access sc_access[5];
 
-
        if (snd_pmic_ops_nc.card_status == SND_CARD_UN_INIT)
                retval = nc_init_card();
        if (retval)
@@ -280,6 +305,10 @@ static int nc_power_down(void)
 
        pr_debug("powering dn nc_power_down ....\n");
 
+       if (snd_pmic_ops_nc.output_dev_id == MONO_EARPIECE ||
+           snd_pmic_ops_nc.output_dev_id == INTERNAL_SPKR)
+               nc_set_amp_power(0);
+
        msleep(30);
 
        sc_access[0].reg_addr = DRVPOWERCTRL;
@@ -316,7 +345,7 @@ static int nc_power_down(void)
        return nc_enable_audiodac(UNMUTE);
 }
 
-static int nc_power_down_pb(void)
+static int nc_power_down_pb(unsigned int device)
 {
 
        int retval = 0;
@@ -328,7 +357,7 @@ static int nc_power_down_pb(void)
                return retval;
 
        pr_debug("powering dn pb....\n");
-
+       mutex_lock(&snd_pmic_ops_nc.lock);
        nc_enable_audiodac(MUTE);
 
 
@@ -355,12 +384,14 @@ static int nc_power_down_pb(void)
 
        msleep(30);
 
-       return nc_enable_audiodac(UNMUTE);
-
+       snd_pmic_ops_nc.pb_on = 0;
 
+       nc_enable_audiodac(UNMUTE);
+       mutex_unlock(&snd_pmic_ops_nc.lock);
+       return 0;
 }
 
-static int nc_power_down_cp(void)
+static int nc_power_down_cp(unsigned int device)
 {
        struct sc_reg_access sc_access[] = {
                {POWERCTRL1, 0x00, 0xBE},
@@ -498,11 +529,13 @@ static int nc_set_selected_output_dev(u8 value)
 {
        struct sc_reg_access sc_access_HP[] = {
                {LMUTE, 0x02, 0x06},
-               {RMUTE, 0x02, 0x06}
+               {RMUTE, 0x02, 0x06},
+               {DRVPOWERCTRL, 0x06, 0x06},
        };
        struct sc_reg_access sc_access_IS[] = {
                {LMUTE, 0x04, 0x06},
-               {RMUTE, 0x04, 0x06}
+               {RMUTE, 0x04, 0x06},
+               {DRVPOWERCTRL, 0x00, 0x06},
        };
        int retval = 0;
 
@@ -512,17 +545,26 @@ static int nc_set_selected_output_dev(u8 value)
        if (retval)
                return retval;
        pr_debug("nc set selected output:%d\n", value);
+       mutex_lock(&snd_pmic_ops_nc.lock);
        switch (value) {
        case STEREO_HEADPHONE:
+               if (snd_pmic_ops_nc.pb_on)
+                       sst_sc_reg_access(sc_access_HP+2, PMIC_WRITE, 1);
                retval = sst_sc_reg_access(sc_access_HP, PMIC_WRITE, 2);
+               nc_set_amp_power(0);
                break;
+       case MONO_EARPIECE:
        case INTERNAL_SPKR:
-               retval = sst_sc_reg_access(sc_access_IS, PMIC_WRITE, 2);
+               retval = sst_sc_reg_access(sc_access_IS, PMIC_WRITE, 3);
+               if (snd_pmic_ops_nc.pb_on)
+                       nc_set_amp_power(1);
                break;
        default:
                pr_err("rcvd illegal request: %d\n", value);
+               mutex_unlock(&snd_pmic_ops_nc.lock);
                return -EINVAL;
        }
+       mutex_unlock(&snd_pmic_ops_nc.lock);
        return retval;
 }
 
@@ -784,9 +826,8 @@ static int nc_set_vol(int dev_id, int value)
        case PMIC_SND_LEFT_PB_VOL:
                pr_debug("PMIC_SND_LEFT_HP_VOL %d\n", value);
                sc_access[0].value = -value;
-               sc_access[0].reg_addr  = AUDIOLVOL;
-               sc_access[0].mask =
-                       (MASK0|MASK1|MASK2|MASK3|MASK4|MASK5|MASK6);
+               sc_access[0].reg_addr  = HPLVOL;
+               sc_access[0].mask = (MASK0|MASK1|MASK2|MASK3|MASK4);
                entries = 1;
                break;
 
@@ -794,15 +835,32 @@ static int nc_set_vol(int dev_id, int value)
                pr_debug("PMIC_SND_RIGHT_HP_VOL value %d\n", value);
                if (snd_pmic_ops_nc.num_channel == 1) {
                        sc_access[0].value = 0x04;
-                   sc_access[0].reg_addr = RMUTE;
+                       sc_access[0].reg_addr = RMUTE;
                        sc_access[0].mask = MASK2;
                } else {
+                       sc_access[0].value = -value;
+                       sc_access[0].reg_addr  = HPRVOL;
+                       sc_access[0].mask = (MASK0|MASK1|MASK2|MASK3|MASK4);
+               }
+               entries = 1;
+               break;
+
+       case PMIC_SND_LEFT_MASTER_VOL:
+               pr_debug("PMIC_SND_LEFT_MASTER_VOL value %d\n", value);
+               sc_access[0].value = -value;
+               sc_access[0].reg_addr = AUDIOLVOL;
+               sc_access[0].mask =
+                       (MASK0|MASK1|MASK2|MASK3|MASK4|MASK5|MASK6);
+               entries = 1;
+               break;
+
+       case PMIC_SND_RIGHT_MASTER_VOL:
+               pr_debug("PMIC_SND_RIGHT_MASTER_VOL value %d\n", value);
                sc_access[0].value = -value;
-               sc_access[0].reg_addr  = AUDIORVOL;
+               sc_access[0].reg_addr = AUDIORVOL;
                sc_access[0].mask =
                                (MASK0|MASK1|MASK2|MASK3|MASK4|MASK5|MASK6);
                entries = 1;
-               }
                break;
 
        default:
@@ -831,7 +889,7 @@ static int nc_set_selected_input_dev(u8 value)
                pr_debug("Selecting AMIC\n");
                sc_access[0].reg_addr = 0x107;
                sc_access[0].value = 0x40;
-               sc_access[0].mask =  MASK6|MASK4|MASK3|MASK1|MASK0;
+               sc_access[0].mask =  MASK6|MASK3|MASK1|MASK0;
                sc_access[1].reg_addr = 0x10a;
                sc_access[1].value = 0x40;
                sc_access[1].mask = MASK6;
@@ -846,9 +904,9 @@ static int nc_set_selected_input_dev(u8 value)
 
        case HS_MIC:
                pr_debug("Selecting HS_MIC\n");
-               sc_access[0].reg_addr = 0x107;
-               sc_access[0].mask =  MASK6|MASK4|MASK3|MASK1|MASK0;
-               sc_access[0].value = 0x10;
+               sc_access[0].reg_addr = MICCTRL;
+               sc_access[0].mask =  MASK6|MASK3|MASK1|MASK0;
+               sc_access[0].value = 0x00;
                sc_access[1].reg_addr = 0x109;
                sc_access[1].mask = MASK6;
                sc_access[1].value = 0x40;
@@ -858,13 +916,16 @@ static int nc_set_selected_input_dev(u8 value)
                sc_access[3].reg_addr = 0x105;
                sc_access[3].value = 0x40;
                sc_access[3].mask = MASK6;
-               num_val = 4;
+               sc_access[4].reg_addr = ADCSAMPLERATE;
+               sc_access[4].mask = MASK7|MASK6|MASK5|MASK4|MASK3;
+               sc_access[4].value = 0xc8;
+               num_val = 5;
                break;
 
        case DMIC:
                pr_debug("DMIC\n");
-               sc_access[0].reg_addr = 0x107;
-               sc_access[0].mask = MASK6|MASK4|MASK3|MASK1|MASK0;
+               sc_access[0].reg_addr = MICCTRL;
+               sc_access[0].mask = MASK6|MASK3|MASK1|MASK0;
                sc_access[0].value = 0x0B;
                sc_access[1].reg_addr = 0x105;
                sc_access[1].value = 0x80;
@@ -872,12 +933,12 @@ static int nc_set_selected_input_dev(u8 value)
                sc_access[2].reg_addr = 0x10a;
                sc_access[2].value = 0x40;
                sc_access[2].mask = MASK6;
-               sc_access[3].reg_addr = 0x109;
+               sc_access[3].reg_addr = LILSEL;
                sc_access[3].mask = MASK6;
                sc_access[3].value = 0x00;
-               sc_access[4].reg_addr = 0x104;
-               sc_access[4].value = 0x3C;
-               sc_access[4].mask = 0xff;
+               sc_access[4].reg_addr = ADCSAMPLERATE;
+               sc_access[4].mask =  MASK7|MASK6|MASK5|MASK4|MASK3;
+               sc_access[4].value = 0x33;
                num_val = 5;
                break;
        default:
@@ -964,18 +1025,30 @@ static int nc_get_vol(int dev_id, int *value)
                mask = (MASK0|MASK1|MASK2|MASK3|MASK4|MASK5);
                break;
 
-       case PMIC_SND_RIGHT_PB_VOL:
-               pr_debug("GET_VOLUME_PMIC_LEFT_HP_VOL\n");
+       case PMIC_SND_LEFT_MASTER_VOL:
+               pr_debug("GET_VOLUME_PMIC_LEFT_MASTER_VOL\n");
                sc_access.reg_addr = AUDIOLVOL;
                mask = (MASK0|MASK1|MASK2|MASK3|MASK4|MASK5|MASK6);
                break;
 
-       case PMIC_SND_LEFT_PB_VOL:
-               pr_debug("GET_VOLUME_PMIC_RIGHT_HP_VOL\n");
+       case PMIC_SND_RIGHT_MASTER_VOL:
+               pr_debug("GET_VOLUME_PMIC_RIGHT_MASTER_VOL\n");
                sc_access.reg_addr = AUDIORVOL;
                mask = (MASK0|MASK1|MASK2|MASK3|MASK4|MASK5|MASK6);
                break;
 
+       case PMIC_SND_RIGHT_PB_VOL:
+               pr_debug("GET_VOLUME_PMIC_RIGHT_HP_VOL\n");
+               sc_access.reg_addr = HPRVOL;
+               mask = (MASK0|MASK1|MASK2|MASK3|MASK4);
+               break;
+
+       case PMIC_SND_LEFT_PB_VOL:
+               pr_debug("GET_VOLUME_PMIC_LEFT_HP_VOL\n");
+               sc_access.reg_addr = HPLVOL;
+               mask = (MASK0|MASK1|MASK2|MASK3|MASK4);
+               break;
+
        default:
                return -EINVAL;
 
@@ -987,7 +1060,81 @@ static int nc_get_vol(int dev_id, int *value)
        return retval;
 }
 
+static void hp_automute(enum snd_jack_types type, int present)
+{
+       u8 in = DMIC;
+       u8 out = INTERNAL_SPKR;
+       if (present) {
+               if (type == SND_JACK_HEADSET)
+                       in = HS_MIC;
+               out = STEREO_HEADPHONE;
+       }
+       nc_set_selected_input_dev(in);
+       nc_set_selected_output_dev(out);
+}
+
+static void nc_pmic_irq_cb(void *cb_data, u8 intsts)
+{
+       u8 value = 0;
+       struct mad_jack *mjack = NULL;
+       unsigned int present = 0, jack_event_flag = 0, buttonpressflag = 0;
+       struct snd_intelmad *intelmaddata = cb_data;
+       struct sc_reg_access sc_access_read = {0,};
+
+       sc_access_read.reg_addr = 0x132;
+       sst_sc_reg_access(&sc_access_read, PMIC_READ, 1);
+       value = (sc_access_read.value);
+       pr_debug("value returned = 0x%x\n", value);
+
+       mjack = &intelmaddata->jack[0];
+       if (intsts & 0x1) {
+               pr_debug("SST DBG:MAD headset detected\n");
+               /* send headset detect/undetect */
+               present = (value == 0x1) ? 1 : 0;
+               jack_event_flag = 1;
+               mjack->jack.type = SND_JACK_HEADSET;
+               hp_automute(SND_JACK_HEADSET, present);
+       }
+
+       if (intsts & 0x2) {
+               pr_debug(":MAD headphone detected\n");
+               /* send headphone detect/undetect */
+               present = (value == 0x2) ? 1 : 0;
+               jack_event_flag = 1;
+               mjack->jack.type = SND_JACK_HEADPHONE;
+               hp_automute(SND_JACK_HEADPHONE, present);
+       }
+
+       if (intsts & 0x4) {
+               pr_debug("MAD short push detected\n");
+               /* send short push */
+               present = 1;
+               jack_event_flag = 1;
+               buttonpressflag = 1;
+               mjack->jack.type = MID_JACK_HS_SHORT_PRESS;
+       }
+
+       if (intsts & 0x8) {
+               pr_debug(":MAD long push detected\n");
+               /* send long push */
+               present = 1;
+               jack_event_flag = 1;
+               buttonpressflag = 1;
+               mjack->jack.type = MID_JACK_HS_LONG_PRESS;
+       }
+
+       if (jack_event_flag)
+               sst_mad_send_jack_report(&mjack->jack,
+                                       buttonpressflag, present);
+}
+static int nc_jack_enable(void)
+{
+       return 0;
+}
+
 struct snd_pmic_ops snd_pmic_ops_nc = {
+       .input_dev_id   =       DMIC,
+       .output_dev_id  =       INTERNAL_SPKR,
        .set_input_dev  =       nc_set_selected_input_dev,
        .set_output_dev =       nc_set_selected_output_dev,
        .set_mute       =       nc_set_mute,
@@ -1003,5 +1150,7 @@ struct snd_pmic_ops snd_pmic_ops_nc = {
        .power_up_pmic_cp =     nc_power_up_cp,
        .power_down_pmic_pb =   nc_power_down_pb,
        .power_down_pmic_cp =   nc_power_down_cp,
-       .power_down_pmic =      nc_power_down,
+       .power_down_pmic        =       nc_power_down,
+       .pmic_irq_cb    =       nc_pmic_irq_cb,
+       .pmic_jack_enable =     nc_jack_enable,
 };
diff --git a/drivers/staging/intel_sst/jack.h b/drivers/staging/intel_sst/jack.h
deleted file mode 100644 (file)
index 9a6e483..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-/* Temporary staging glue */
-
-#include <sound/jack.h>
-
-/* These want adding to jack.h as enum entries once approved */
-
-#define SND_JACK_HS_SHORT_PRESS        (SND_JACK_HEADSET | 0x0020)
-#define        SND_JACK_HS_LONG_PRESS          (SND_JACK_HEADSET | 0x0040)
-
-
index b87dc7a8901d4d37960f8dabb58223edf1d11fc8..cf347ccd6a6ef5949f32aab18a0cd2a44972d22b 100644 (file)
@@ -9,5 +9,7 @@ typedef u16 *PWORD;
 typedef u32 DWORD;
 typedef u32 *PDWORD;
 
+#define BYTE_MASK      0xff
+
 #endif
 
index 8af7c84daee28d7645f6adb99ef8a1c2c0009964..b5a89375df22f5a41be617d887d79b11da3dc7d8 100644 (file)
@@ -11,9 +11,6 @@
 #include "transport.h"
 #include "init.h"
 
-BYTE IsSSFDCCompliance;
-BYTE IsXDCompliance;
-
 /*
  * ENE_InitMedia():
  */
index 953a31e9d5f0d45342ccd0c95736d8245a9c1ce6..f709055ae14669c452c38c0b09793e12ba8e2514 100644 (file)
@@ -4,7 +4,7 @@ extern DWORD MediaChange;
 extern int Check_D_MediaFmt(struct us_data *);
 
 
-BYTE MS_Init[] = {
+static BYTE MS_Init[] = {
 0x90, 0xF0, 0x15, 0xE0, 0xF5, 0x1C, 0x11, 0x2C,
 0x90, 0xFF, 0x09, 0xE0, 0x30, 0xE1, 0x06, 0x90,
 0xFF, 0x23, 0x74, 0x80, 0xF0, 0x90, 0xFF, 0x09,
@@ -262,7 +262,7 @@ BYTE MS_Init[] = {
 0x4D, 0x53, 0x2D, 0x49, 0x6E, 0x69, 0x74, 0x20,
 0x20, 0x20, 0x20, 0x31, 0x30, 0x30, 0x30, 0x30 };
 
-BYTE MSP_Rdwr[] = {
+static BYTE MSP_Rdwr[] = {
 0x90, 0xF0, 0x10, 0xE0, 0x90, 0xEA, 0x46, 0xF0,
 0xB4, 0x04, 0x03, 0x02, 0xE1, 0x1E, 0x90, 0xFF,
 0x09, 0xE0, 0x30, 0xE1, 0x06, 0x90, 0xFF, 0x23,
@@ -520,7 +520,7 @@ BYTE MSP_Rdwr[] = {
 0x4D, 0x53, 0x50, 0x2D, 0x52, 0x57, 0x20, 0x20,
 0x20, 0x20, 0x20, 0x31, 0x30, 0x30, 0x30, 0x30 };
 
-BYTE MS_Rdwr[] = {
+static BYTE MS_Rdwr[] = {
 0x90, 0xF0, 0x10, 0xE0, 0x90, 0xEA, 0x46, 0xF0,
 0xB4, 0x02, 0x02, 0x80, 0x36, 0x90, 0xF0, 0x11,
 0xE0, 0xF5, 0x17, 0x90, 0xF0, 0x12, 0xE0, 0xF5,
@@ -778,7 +778,7 @@ BYTE MS_Rdwr[] = {
 0x4D, 0x53, 0x2D, 0x52, 0x57, 0x20, 0x20, 0x20,
 0x20, 0x20, 0x20, 0x31, 0x30, 0x30, 0x30, 0x30 };
 
-BYTE SM_Init[] = {
+static BYTE SM_Init[] = {
 0x7B, 0x09, 0x7C, 0xF0, 0x7D, 0x10, 0x7E, 0xE9,
 0x7F, 0xCC, 0x12, 0x2F, 0x71, 0x90, 0xE9, 0xCC,
 0xE0, 0xB4, 0x07, 0x12, 0x90, 0xFF, 0x09, 0xE0,
@@ -1036,7 +1036,7 @@ BYTE SM_Init[] = {
 0x58, 0x44, 0x2D, 0x49, 0x6E, 0x69, 0x74, 0x20,
 0x20, 0x20, 0x20, 0x31, 0x30, 0x30, 0x30, 0x31 };
 
-BYTE SM_Rdwr[] = {
+static BYTE SM_Rdwr[] = {
 0x7B, 0x0C, 0x7C, 0xF0, 0x7D, 0x10, 0x7E, 0xE9,
 0x7F, 0xCC, 0x12, 0x2F, 0x71, 0x90, 0xE9, 0xC3,
 0xE0, 0xB4, 0x73, 0x04, 0x74, 0x40, 0x80, 0x09,
index a7137217cf869a0e183654a9a4b70fecd77ff304..087ad73ff70f18dee8564de500ef145a50a29f9d 100644 (file)
@@ -6,13 +6,17 @@
 #include "transport.h"
 #include "ms.h"
 
-//----- MS_ReaderCopyBlock() ------------------------------------------
-int MS_ReaderCopyBlock(struct us_data *us, WORD oldphy, WORD newphy, WORD PhyBlockAddr, BYTE PageNum, PBYTE buf, WORD len)
+/*
+ * MS_ReaderCopyBlock()
+ */
+int MS_ReaderCopyBlock(struct us_data *us, WORD oldphy, WORD newphy,
+                       WORD PhyBlockAddr, BYTE PageNum, PBYTE buf, WORD len)
 {
        struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
        int     result;
 
-       //printk("MS_ReaderCopyBlock --- PhyBlockAddr = %x, PageNum = %x\n", PhyBlockAddr, PageNum);
+       /* printk(KERN_INFO "MS_ReaderCopyBlock --- PhyBlockAddr = %x,
+                               PageNum = %x\n", PhyBlockAddr, PageNum); */
        result = ENE_LoadBinCode(us, MS_RW_PATTERN);
        if (result != USB_STOR_XFER_GOOD)
                return USB_STOR_TRANSPORT_ERROR;
@@ -25,10 +29,10 @@ int MS_ReaderCopyBlock(struct us_data *us, WORD oldphy, WORD newphy, WORD PhyBlo
        bcb->CDB[1]                     = 0x08;
        bcb->CDB[4]                     = (BYTE)(oldphy);
        bcb->CDB[3]                     = (BYTE)(oldphy>>8);
-       bcb->CDB[2]                     = (BYTE)(oldphy>>16);
+       bcb->CDB[2]                     = 0; /* (BYTE)(oldphy>>16) */
        bcb->CDB[7]                     = (BYTE)(newphy);
        bcb->CDB[6]                     = (BYTE)(newphy>>8);
-       bcb->CDB[5]                     = (BYTE)(newphy>>16);
+       bcb->CDB[5]                     = 0; /* (BYTE)(newphy>>16) */
        bcb->CDB[9]                     = (BYTE)(PhyBlockAddr);
        bcb->CDB[8]                     = (BYTE)(PhyBlockAddr>>8);
        bcb->CDB[10]            = PageNum;
@@ -40,21 +44,25 @@ int MS_ReaderCopyBlock(struct us_data *us, WORD oldphy, WORD newphy, WORD PhyBlo
        return USB_STOR_TRANSPORT_GOOD;
 }
 
-//----- MS_ReaderReadPage() ------------------------------------------
-int MS_ReaderReadPage(struct us_data *us, DWORD PhyBlockAddr, BYTE PageNum, PDWORD PageBuf, MS_LibTypeExtdat *ExtraDat)
+/*
+ * MS_ReaderReadPage()
+ */
+int MS_ReaderReadPage(struct us_data *us, DWORD PhyBlockAddr,
+               BYTE PageNum, PDWORD PageBuf, MS_LibTypeExtdat *ExtraDat)
 {
        struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
        int     result;
        BYTE    ExtBuf[4];
        DWORD   bn = PhyBlockAddr * 0x20 + PageNum;
 
-       //printk("MS --- MS_ReaderReadPage,  PhyBlockAddr = %x, PageNum = %x\n", PhyBlockAddr, PageNum);
+       /* printk(KERN_INFO "MS --- MS_ReaderReadPage,
+               PhyBlockAddr = %x, PageNum = %x\n", PhyBlockAddr, PageNum); */
 
        result = ENE_LoadBinCode(us, MS_RW_PATTERN);
        if (result != USB_STOR_XFER_GOOD)
                return USB_STOR_TRANSPORT_ERROR;
 
-       // Read Page Data
+       /* Read Page Data */
        memset(bcb, 0, sizeof(struct bulk_cb_wrap));
        bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
        bcb->DataTransferLength = 0x200;
@@ -65,12 +73,12 @@ int MS_ReaderReadPage(struct us_data *us, DWORD PhyBlockAddr, BYTE PageNum, PDWO
        bcb->CDB[4]                     = (BYTE)(bn>>8);
        bcb->CDB[3]                     = (BYTE)(bn>>16);
        bcb->CDB[2]                     = (BYTE)(bn>>24);
-       
+
        result = ENE_SendScsiCmd(us, FDIR_READ, PageBuf, 0);
        if (result != USB_STOR_XFER_GOOD)
                return USB_STOR_TRANSPORT_ERROR;
 
-       // Read Extra Data
+       /* Read Extra Data */
        memset(bcb, 0, sizeof(struct bulk_cb_wrap));
        bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
        bcb->DataTransferLength = 0x4;
@@ -88,9 +96,9 @@ int MS_ReaderReadPage(struct us_data *us, DWORD PhyBlockAddr, BYTE PageNum, PDWO
                return USB_STOR_TRANSPORT_ERROR;
 
        ExtraDat->reserved = 0;
-       ExtraDat->intr     = 0x80;  // Not yet, ¥ý°²³], µ¥ fireware support
-       ExtraDat->status0  = 0x10;  // Not yet, ¥ý°²³], µ¥ fireware support
-       ExtraDat->status1  = 0x00;  // Not yet, ¥ý°²³], µ¥ fireware support
+       ExtraDat->intr     = 0x80;  /* Not yet,fireware support */
+       ExtraDat->status0  = 0x10;  /* Not yet,fireware support */
+       ExtraDat->status1  = 0x00;  /* Not yet,fireware support */
        ExtraDat->ovrflg   = ExtBuf[0];
        ExtraDat->mngflg   = ExtBuf[1];
        ExtraDat->logadr   = MemStickLogAddr(ExtBuf[2], ExtBuf[3]);
@@ -98,14 +106,17 @@ int MS_ReaderReadPage(struct us_data *us, DWORD PhyBlockAddr, BYTE PageNum, PDWO
        return USB_STOR_TRANSPORT_GOOD;
 }
 
-//----- MS_ReaderEraseBlock() ----------------------------------------
+/*
+ * MS_ReaderEraseBlock()
+ */
 int MS_ReaderEraseBlock(struct us_data *us, DWORD PhyBlockAddr)
 {
        struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
        int     result;
        DWORD   bn = PhyBlockAddr;
 
-       //printk("MS --- MS_ReaderEraseBlock,  PhyBlockAddr = %x\n", PhyBlockAddr);
+       /* printk(KERN_INFO "MS --- MS_ReaderEraseBlock,
+               PhyBlockAddr = %x\n", PhyBlockAddr); */
        result = ENE_LoadBinCode(us, MS_RW_PATTERN);
        if (result != USB_STOR_XFER_GOOD)
                return USB_STOR_TRANSPORT_ERROR;
@@ -119,7 +130,7 @@ int MS_ReaderEraseBlock(struct us_data *us, DWORD PhyBlockAddr)
        bcb->CDB[4]                     = (BYTE)(bn);
        bcb->CDB[3]                     = (BYTE)(bn>>8);
        bcb->CDB[2]                     = (BYTE)(bn>>16);
-       
+
        result = ENE_SendScsiCmd(us, FDIR_READ, NULL, 0);
        if (result != USB_STOR_XFER_GOOD)
                return USB_STOR_TRANSPORT_ERROR;
@@ -127,23 +138,25 @@ int MS_ReaderEraseBlock(struct us_data *us, DWORD PhyBlockAddr)
        return USB_STOR_TRANSPORT_GOOD;
 }
 
-//----- MS_CardInit() ------------------------------------------------
+/*
+ * MS_CardInit()
+ */
 int MS_CardInit(struct us_data *us)
 {
-       DWORD                   result=0;
+       DWORD                   result = 0;
        WORD                    TmpBlock;
        PBYTE                   PageBuffer0 = NULL, PageBuffer1 = NULL;
        MS_LibTypeExtdat        extdat;
        WORD                    btBlk1st, btBlk2nd;
        DWORD                   btBlk1stErred;
 
-       printk("MS_CardInit start\n");
+       printk(KERN_INFO "MS_CardInit start\n");
 
        MS_LibFreeAllocatedArea(us);
 
-       if (((PageBuffer0 = kmalloc(MS_BYTES_PER_PAGE, GFP_KERNEL)) == NULL) ||
-           ((PageBuffer1 = kmalloc(MS_BYTES_PER_PAGE, GFP_KERNEL)) == NULL))
-       {
+       PageBuffer0 = kmalloc(MS_BYTES_PER_PAGE, GFP_KERNEL);
+       PageBuffer1 = kmalloc(MS_BYTES_PER_PAGE, GFP_KERNEL);
+       if ((PageBuffer0 == NULL) || (PageBuffer1 == NULL)) {
                result = MS_NO_MEMORY_ERROR;
                goto exit;
        }
@@ -151,16 +164,16 @@ int MS_CardInit(struct us_data *us)
        btBlk1st = btBlk2nd = MS_LB_NOT_USED;
        btBlk1stErred = 0;
 
-       for (TmpBlock=0; TmpBlock < MS_MAX_INITIAL_ERROR_BLOCKS+2; TmpBlock++)
-       {
-               switch (MS_ReaderReadPage(us, TmpBlock, 0, (DWORD *)PageBuffer0, &extdat))
-               {
-                       case MS_STATUS_SUCCESS:
+       for (TmpBlock = 0; TmpBlock < MS_MAX_INITIAL_ERROR_BLOCKS+2;
+               TmpBlock++) {
+               switch (MS_ReaderReadPage(us, TmpBlock, 0,
+                       (DWORD *)PageBuffer0, &extdat)) {
+               case MS_STATUS_SUCCESS:
                        break;
-                       case MS_STATUS_INT_ERROR:
+               case MS_STATUS_INT_ERROR:
                        break;
-                       case MS_STATUS_ERROR:
-                       default:
+               case MS_STATUS_ERROR:
+               default:
                        continue;
                }
 
@@ -173,38 +186,37 @@ int MS_CardInit(struct us_data *us)
                        (((MemStickBootBlockPage0 *)PageBuffer0)->header.bNumberOfDataEntry != MS_BOOT_BLOCK_DATA_ENTRIES))
                                continue;
 
-               if (btBlk1st != MS_LB_NOT_USED)
-               {
+               if (btBlk1st != MS_LB_NOT_USED) {
                        btBlk2nd = TmpBlock;
                        break;
                }
 
                btBlk1st = TmpBlock;
                memcpy(PageBuffer1, PageBuffer0, MS_BYTES_PER_PAGE);
-               if (extdat.status1 & (MS_REG_ST1_DTER | MS_REG_ST1_EXER | MS_REG_ST1_FGER))
+               if (extdat.status1 &
+                       (MS_REG_ST1_DTER | MS_REG_ST1_EXER | MS_REG_ST1_FGER))
                        btBlk1stErred = 1;
        }
 
-       if (btBlk1st == MS_LB_NOT_USED)
-       {
+       if (btBlk1st == MS_LB_NOT_USED) {
                result = MS_STATUS_ERROR;
                goto exit;
        }
 
-       // write protect
+       /* write protect */
        if ((extdat.status0 & MS_REG_ST0_WP) == MS_REG_ST0_WP_ON)
                MS_LibCtrlSet(us, MS_LIB_CTRL_WRPROTECT);
 
        result = MS_STATUS_ERROR;
-       // 1st Boot Block
+       /* 1st Boot Block */
        if (btBlk1stErred == 0)
-               result = MS_LibProcessBootBlock(us, btBlk1st, PageBuffer1);   // 1st
-       // 2nd Boot Block
+               result = MS_LibProcessBootBlock(us, btBlk1st, PageBuffer1);
+               /* 1st */
+       /* 2nd Boot Block */
        if (result && (btBlk2nd != MS_LB_NOT_USED))
                result = MS_LibProcessBootBlock(us, btBlk2nd, PageBuffer0);
 
-       if (result)
-       {
+       if (result) {
                result = MS_STATUS_ERROR;
                goto exit;
        }
@@ -214,8 +226,7 @@ int MS_CardInit(struct us_data *us)
 
        us->MS_Lib.Phy2LogMap[btBlk1st] = MS_LB_BOOT_BLOCK;
 
-       if (btBlk2nd != MS_LB_NOT_USED)
-       {
+       if (btBlk2nd != MS_LB_NOT_USED) {
                for (TmpBlock = btBlk1st + 1; TmpBlock < btBlk2nd; TmpBlock++)
                        us->MS_Lib.Phy2LogMap[TmpBlock] = MS_LB_INITIAL_ERROR;
                us->MS_Lib.Phy2LogMap[btBlk2nd] = MS_LB_BOOT_BLOCK;
@@ -225,18 +236,17 @@ int MS_CardInit(struct us_data *us)
        if (result)
                goto exit;
 
-       for (TmpBlock=MS_PHYSICAL_BLOCKS_PER_SEGMENT; TmpBlock<us->MS_Lib.NumberOfPhyBlock; TmpBlock+=MS_PHYSICAL_BLOCKS_PER_SEGMENT)
-       {
-               if (MS_CountFreeBlock(us, TmpBlock) == 0)
-               {
+       for (TmpBlock = MS_PHYSICAL_BLOCKS_PER_SEGMENT;
+               TmpBlock < us->MS_Lib.NumberOfPhyBlock;
+               TmpBlock += MS_PHYSICAL_BLOCKS_PER_SEGMENT) {
+               if (MS_CountFreeBlock(us, TmpBlock) == 0) {
                        MS_LibCtrlSet(us, MS_LIB_CTRL_WRPROTECT);
                        break;
                }
        }
 
-       // write
-       if (MS_LibAllocWriteBuf(us))
-       {
+       /* write */
+       if (MS_LibAllocWriteBuf(us)) {
                result = MS_NO_MEMORY_ERROR;
                goto exit;
        }
@@ -245,46 +255,48 @@ int MS_CardInit(struct us_data *us)
 
 exit:
        kfree(PageBuffer1);
-       kfree(PageBuffer0);
+       kfree(PageBuffer0);
 
-       printk("MS_CardInit end\n");
+       printk(KERN_INFO "MS_CardInit end\n");
        return result;
 }
 
-//----- MS_LibCheckDisableBlock() ------------------------------------
+/*
+ * MS_LibCheckDisableBlock()
+ */
 int MS_LibCheckDisableBlock(struct us_data *us, WORD PhyBlock)
 {
-       PWORD                   PageBuf=NULL;
-       DWORD                   result=MS_STATUS_SUCCESS;
-       DWORD                   blk, index=0;
+       PWORD                   PageBuf = NULL;
+       DWORD                   result = MS_STATUS_SUCCESS;
+       DWORD                   blk, index = 0;
        MS_LibTypeExtdat        extdat;
 
-       if (((PageBuf = kmalloc(MS_BYTES_PER_PAGE, GFP_KERNEL)) == NULL))
-       {
+       PageBuf = kmalloc(MS_BYTES_PER_PAGE, GFP_KERNEL);
+       if (PageBuf == NULL) {
                result = MS_NO_MEMORY_ERROR;
                goto exit;
        }
 
        MS_ReaderReadPage(us, PhyBlock, 1, (DWORD *)PageBuf, &extdat);
-       do
-       {
+       do {
                blk = be16_to_cpu(PageBuf[index]);
                if (blk == MS_LB_NOT_USED)
                        break;
-               if (blk == us->MS_Lib.Log2PhyMap[0])
-               {
+               if (blk == us->MS_Lib.Log2PhyMap[0]) {
                        result = MS_ERROR_FLASH_READ;
                        break;
                }
                index++;
-       } while(1);
+       } while (1);
 
 exit:
        kfree(PageBuf);
        return result;
 }
 
-//----- MS_LibFreeAllocatedArea() ------------------------------------
+/*
+ * MS_LibFreeAllocatedArea()
+ */
 void MS_LibFreeAllocatedArea(struct us_data *us)
 {
        MS_LibFreeWriteBuf(us);
@@ -302,26 +314,31 @@ void MS_LibFreeAllocatedArea(struct us_data *us)
        us->MS_Lib.NumberOfLogBlock     = 0;
 }
 
-//----- MS_LibFreeWriteBuf() -----------------------------------------
+/*
+ * MS_LibFreeWriteBuf()
+ */
 void MS_LibFreeWriteBuf(struct us_data *us)
 {
-       us->MS_Lib.wrtblk = (WORD)-1; //set to -1
-       MS_LibClearPageMap(us); // memset((fdoExt)->MS_Lib.pagemap, 0, sizeof((fdoExt)->MS_Lib.pagemap))
+       us->MS_Lib.wrtblk = (WORD)-1; /* set to -1 */
 
-       if (us->MS_Lib.blkpag)
-       {
-               kfree((BYTE *)(us->MS_Lib.blkpag));  // Arnold test ...
+       /* memset((fdoExt)->MS_Lib.pagemap, 0,
+                       sizeof((fdoExt)->MS_Lib.pagemap)) */
+       MS_LibClearPageMap(us);
+
+       if (us->MS_Lib.blkpag) {
+               kfree((BYTE *)(us->MS_Lib.blkpag));  /* Arnold test ... */
                us->MS_Lib.blkpag = NULL;
        }
 
-       if (us->MS_Lib.blkext)
-       {
-               kfree((BYTE *)(us->MS_Lib.blkext));  // Arnold test ...
+       if (us->MS_Lib.blkext) {
+               kfree((BYTE *)(us->MS_Lib.blkext));  /* Arnold test ... */
                us->MS_Lib.blkext = NULL;
        }
 }
 
-//----- MS_LibFreeLogicalMap() ---------------------------------------
+/*
+ * MS_LibFreeLogicalMap()
+ */
 int MS_LibFreeLogicalMap(struct us_data *us)
 {
        kfree(us->MS_Lib.Phy2LogMap);
@@ -330,10 +347,12 @@ int MS_LibFreeLogicalMap(struct us_data *us)
        kfree(us->MS_Lib.Log2PhyMap);
        us->MS_Lib.Log2PhyMap = NULL;
 
-    return 0;
+       return 0;
 }
 
-//----- MS_LibProcessBootBlock() -------------------------------------
+/*
+ * MS_LibProcessBootBlock()
+ */
 int MS_LibProcessBootBlock(struct us_data *us, WORD PhyBlock, BYTE *PageData)
 {
        MemStickBootBlockSysEnt  *SysEntry;
@@ -343,144 +362,165 @@ int MS_LibProcessBootBlock(struct us_data *us, WORD PhyBlock, BYTE *PageData)
        BYTE                     *PageBuffer;
        MS_LibTypeExtdat         ExtraData;
 
-       if ((PageBuffer = kmalloc(MS_BYTES_PER_PAGE, GFP_KERNEL))==NULL)
+
+       PageBuffer = kmalloc(MS_BYTES_PER_PAGE, GFP_KERNEL);
+       if (PageBuffer == NULL)
                return (DWORD)-1;
 
        result = (DWORD)-1;
 
-       SysInfo= &(((MemStickBootBlockPage0 *)PageData)->sysinf);
+       SysInfo = &(((MemStickBootBlockPage0 *)PageData)->sysinf);
 
-       if ((SysInfo->bMsClass != MS_SYSINF_MSCLASS_TYPE_1)                                   ||
-               (be16_to_cpu(SysInfo->wPageSize) != MS_SYSINF_PAGE_SIZE)                       ||
+       if ((SysInfo->bMsClass != MS_SYSINF_MSCLASS_TYPE_1) ||
+               (be16_to_cpu(SysInfo->wPageSize) != MS_SYSINF_PAGE_SIZE) ||
                ((SysInfo->bSecuritySupport & MS_SYSINF_SECURITY) == MS_SYSINF_SECURITY_SUPPORT) ||
-               (SysInfo->bReserved1 != MS_SYSINF_RESERVED1)                                     ||
-               (SysInfo->bReserved2 != MS_SYSINF_RESERVED2)                                     ||
-               (SysInfo->bFormatType!= MS_SYSINF_FORMAT_FAT)                                    ||
+               (SysInfo->bReserved1 != MS_SYSINF_RESERVED1) ||
+               (SysInfo->bReserved2 != MS_SYSINF_RESERVED2) ||
+               (SysInfo->bFormatType != MS_SYSINF_FORMAT_FAT) ||
                (SysInfo->bUsage != MS_SYSINF_USAGE_GENERAL))
                goto exit;
 
-       switch (us->MS_Lib.cardType = SysInfo->bCardType)
-       {
-               case MS_SYSINF_CARDTYPE_RDONLY:
-                       MS_LibCtrlSet(us, MS_LIB_CTRL_RDONLY);
-                       break;
-               case MS_SYSINF_CARDTYPE_RDWR:
-                       MS_LibCtrlReset(us, MS_LIB_CTRL_RDONLY);
-                       break;
-               case MS_SYSINF_CARDTYPE_HYBRID:
-               default:
-                       goto exit;
+       switch (us->MS_Lib.cardType = SysInfo->bCardType) {
+       case MS_SYSINF_CARDTYPE_RDONLY:
+               MS_LibCtrlSet(us, MS_LIB_CTRL_RDONLY);
+               break;
+       case MS_SYSINF_CARDTYPE_RDWR:
+               MS_LibCtrlReset(us, MS_LIB_CTRL_RDONLY);
+               break;
+       case MS_SYSINF_CARDTYPE_HYBRID:
+       default:
+               goto exit;
        }
 
        us->MS_Lib.blockSize        = be16_to_cpu(SysInfo->wBlockSize);
        us->MS_Lib.NumberOfPhyBlock = be16_to_cpu(SysInfo->wBlockNumber);
-       us->MS_Lib.NumberOfLogBlock = be16_to_cpu(SysInfo->wTotalBlockNumber) - 2;
-       us->MS_Lib.PagesPerBlock    = us->MS_Lib.blockSize * SIZE_OF_KIRO / MS_BYTES_PER_PAGE;
-       us->MS_Lib.NumberOfSegment  = us->MS_Lib.NumberOfPhyBlock / MS_PHYSICAL_BLOCKS_PER_SEGMENT;
+       us->MS_Lib.NumberOfLogBlock = be16_to_cpu(SysInfo->wTotalBlockNumber)
+                                                                       -2;
+       us->MS_Lib.PagesPerBlock    = us->MS_Lib.blockSize * SIZE_OF_KIRO /
+                                                       MS_BYTES_PER_PAGE;
+       us->MS_Lib.NumberOfSegment  = us->MS_Lib.NumberOfPhyBlock /
+                                       MS_PHYSICAL_BLOCKS_PER_SEGMENT;
        us->MS_Model                = be16_to_cpu(SysInfo->wMemorySize);
 
-       if (MS_LibAllocLogicalMap(us))                  //Allocate to all number of logicalblock and physicalblock
+       /*Allocate to all number of logicalblock and physicalblock */
+       if (MS_LibAllocLogicalMap(us))
                goto exit;
 
-       MS_LibSetBootBlockMark(us, PhyBlock);           //Mark the book block
+       /* Mark the book block */
+       MS_LibSetBootBlockMark(us, PhyBlock);
 
        SysEntry = &(((MemStickBootBlockPage0 *)PageData)->sysent);
 
-       for (i=0; i<MS_NUMBER_OF_SYSTEM_ENTRY; i++)
-       {
+       for (i = 0; i < MS_NUMBER_OF_SYSTEM_ENTRY; i++) {
                DWORD  EntryOffset, EntrySize;
 
-               if ((EntryOffset = be32_to_cpu(SysEntry->entry[i].dwStart)) == 0xffffff)
+               EntryOffset = be32_to_cpu(SysEntry->entry[i].dwStart);
+
+               if (EntryOffset == 0xffffff)
                        continue;
+               EntrySize = be32_to_cpu(SysEntry->entry[i].dwSize);
 
-               if ((EntrySize = be32_to_cpu(SysEntry->entry[i].dwSize)) == 0)
+               if (EntrySize == 0)
                        continue;
 
-               if (EntryOffset + MS_BYTES_PER_PAGE + EntrySize > us->MS_Lib.blockSize * (DWORD)SIZE_OF_KIRO)
+               if (EntryOffset + MS_BYTES_PER_PAGE + EntrySize >
+                       us->MS_Lib.blockSize * (DWORD)SIZE_OF_KIRO)
                        continue;
 
-               if (i == 0)
-               {
+               if (i == 0) {
                        BYTE  PrevPageNumber = 0;
                        WORD  phyblk;
 
-                       if (SysEntry->entry[i].bType != MS_SYSENT_TYPE_INVALID_BLOCK)
+                       if (SysEntry->entry[i].bType !=
+                               MS_SYSENT_TYPE_INVALID_BLOCK)
                                goto exit;
 
-                       while (EntrySize > 0)
-                       {
-                               if ((PageNumber = (BYTE)(EntryOffset / MS_BYTES_PER_PAGE + 1)) != PrevPageNumber)
-                               {
-                                       switch (MS_ReaderReadPage(us, PhyBlock, PageNumber, (DWORD *)PageBuffer, &ExtraData))
-                                       {
-                                               case MS_STATUS_SUCCESS:
-                                                       break;
-                                               case MS_STATUS_WRITE_PROTECT:
-                                               case MS_ERROR_FLASH_READ:
-                                               case MS_STATUS_ERROR:
-                                               default:
-                                                       goto exit;
+                       while (EntrySize > 0) {
+
+                               PageNumber = (BYTE)(EntryOffset /
+                                                       MS_BYTES_PER_PAGE + 1);
+                               if (PageNumber != PrevPageNumber) {
+                                       switch (MS_ReaderReadPage(us, PhyBlock,
+                                               PageNumber, (DWORD *)PageBuffer,
+                                               &ExtraData)) {
+                                       case MS_STATUS_SUCCESS:
+                                               break;
+                                       case MS_STATUS_WRITE_PROTECT:
+                                       case MS_ERROR_FLASH_READ:
+                                       case MS_STATUS_ERROR:
+                                       default:
+                                               goto exit;
                                        }
 
                                        PrevPageNumber = PageNumber;
                                }
 
-                               if ((phyblk = be16_to_cpu(*(WORD *)(PageBuffer + (EntryOffset % MS_BYTES_PER_PAGE)))) < 0x0fff)
+                               phyblk = be16_to_cpu(*(WORD *)(PageBuffer +
+                                       (EntryOffset % MS_BYTES_PER_PAGE)));
+                               if (phyblk < 0x0fff)
                                        MS_LibSetInitialErrorBlock(us, phyblk);
 
                                EntryOffset += 2;
                                EntrySize -= 2;
                        }
-               }
-               else if (i == 1)
-               {  // CIS/IDI
+               } else if (i == 1) {  /* CIS/IDI */
                        MemStickBootBlockIDI  *idi;
 
                        if (SysEntry->entry[i].bType != MS_SYSENT_TYPE_CIS_IDI)
                                goto exit;
 
-                       switch (MS_ReaderReadPage(us, PhyBlock, (BYTE)(EntryOffset / MS_BYTES_PER_PAGE + 1), (DWORD *)PageBuffer, &ExtraData))
-                       {
-                               case MS_STATUS_SUCCESS:
-                                       break;
-                               case MS_STATUS_WRITE_PROTECT:
-                               case MS_ERROR_FLASH_READ:
-                               case MS_STATUS_ERROR:
-                               default:
-                                       goto exit;
+                       switch (MS_ReaderReadPage(us, PhyBlock,
+                               (BYTE)(EntryOffset / MS_BYTES_PER_PAGE + 1),
+                               (DWORD *)PageBuffer, &ExtraData)) {
+                       case MS_STATUS_SUCCESS:
+                               break;
+                       case MS_STATUS_WRITE_PROTECT:
+                       case MS_ERROR_FLASH_READ:
+                       case MS_STATUS_ERROR:
+                       default:
+                               goto exit;
                        }
 
-                       idi = &((MemStickBootBlockCIS_IDI *)(PageBuffer + (EntryOffset % MS_BYTES_PER_PAGE)))->idi.idi;
-                       if (le16_to_cpu(idi->wIDIgeneralConfiguration) != MS_IDI_GENERAL_CONF)
+                       idi = &((MemStickBootBlockCIS_IDI *)(PageBuffer +
+                               (EntryOffset % MS_BYTES_PER_PAGE)))->idi.idi;
+                       if (le16_to_cpu(idi->wIDIgeneralConfiguration) !=
+                                                       MS_IDI_GENERAL_CONF)
                                goto exit;
 
-                       us->MS_Lib.BytesPerSector = le16_to_cpu(idi->wIDIbytesPerSector);
+                       us->MS_Lib.BytesPerSector =
+                               le16_to_cpu(idi->wIDIbytesPerSector);
                        if (us->MS_Lib.BytesPerSector != MS_BYTES_PER_PAGE)
                                goto exit;
                }
-       } // End for ..
+       } /* End for .. */
 
        result = 0;
 
 exit:
-       if (result)             MS_LibFreeLogicalMap(us);
+       if (result)
+               MS_LibFreeLogicalMap(us);
+
        kfree(PageBuffer);
 
        result = 0;
        return result;
 }
 
-//----- MS_LibAllocLogicalMap() --------------------------------------
+/*
+ * MS_LibAllocLogicalMap()
+ */
 int MS_LibAllocLogicalMap(struct us_data *us)
 {
        DWORD  i;
 
 
-       us->MS_Lib.Phy2LogMap = kmalloc(us->MS_Lib.NumberOfPhyBlock * sizeof(WORD), GFP_KERNEL);
-       us->MS_Lib.Log2PhyMap = kmalloc(us->MS_Lib.NumberOfLogBlock * sizeof(WORD), GFP_KERNEL);
+       us->MS_Lib.Phy2LogMap = kmalloc(us->MS_Lib.NumberOfPhyBlock *
+                                               sizeof(WORD), GFP_KERNEL);
+       us->MS_Lib.Log2PhyMap = kmalloc(us->MS_Lib.NumberOfLogBlock *
+                                               sizeof(WORD), GFP_KERNEL);
 
-       if ((us->MS_Lib.Phy2LogMap == NULL) || (us->MS_Lib.Log2PhyMap == NULL))
-       {
+       if ((us->MS_Lib.Phy2LogMap == NULL) ||
+               (us->MS_Lib.Log2PhyMap == NULL)) {
                MS_LibFreeLogicalMap(us);
                return (DWORD)-1;
        }
@@ -489,128 +529,142 @@ int MS_LibAllocLogicalMap(struct us_data *us)
                us->MS_Lib.Phy2LogMap[i] = MS_LB_NOT_USED;
 
        for (i = 0; i < us->MS_Lib.NumberOfLogBlock; i++)
-       us->MS_Lib.Log2PhyMap[i] = MS_LB_NOT_USED;
+               us->MS_Lib.Log2PhyMap[i] = MS_LB_NOT_USED;
 
        return 0;
 }
 
-//----- MS_LibSetBootBlockMark() -------------------------------------
+/*
+ * MS_LibSetBootBlockMark()
+ */
 int MS_LibSetBootBlockMark(struct us_data *us, WORD phyblk)
 {
-    return MS_LibSetLogicalBlockMark(us, phyblk, MS_LB_BOOT_BLOCK);
+       return MS_LibSetLogicalBlockMark(us, phyblk, MS_LB_BOOT_BLOCK);
 }
 
-//----- MS_LibSetLogicalBlockMark() ----------------------------------
+/*
+ * MS_LibSetLogicalBlockMark()
+ */
 int MS_LibSetLogicalBlockMark(struct us_data *us, WORD phyblk, WORD mark)
 {
-    if (phyblk >= us->MS_Lib.NumberOfPhyBlock)
-        return (DWORD)-1;
+       if (phyblk >= us->MS_Lib.NumberOfPhyBlock)
+               return (DWORD)-1;
 
-    us->MS_Lib.Phy2LogMap[phyblk] = mark;
+       us->MS_Lib.Phy2LogMap[phyblk] = mark;
 
-    return 0;
+       return 0;
 }
 
-//----- MS_LibSetInitialErrorBlock() ---------------------------------
+/*
+ * MS_LibSetInitialErrorBlock()
+ */
 int MS_LibSetInitialErrorBlock(struct us_data *us, WORD phyblk)
 {
-    return MS_LibSetLogicalBlockMark(us, phyblk, MS_LB_INITIAL_ERROR);
+       return MS_LibSetLogicalBlockMark(us, phyblk, MS_LB_INITIAL_ERROR);
 }
 
-//----- MS_LibScanLogicalBlockNumber() -------------------------------
+/*
+ * MS_LibScanLogicalBlockNumber()
+ */
 int MS_LibScanLogicalBlockNumber(struct us_data *us, WORD btBlk1st)
 {
        WORD                    PhyBlock, newblk, i;
        WORD                    LogStart, LogEnde;
        MS_LibTypeExtdat        extdat;
        BYTE                    buf[0x200];
-       DWORD                   count=0, index=0;
+       DWORD                   count = 0, index = 0;
 
-       for (PhyBlock = 0; PhyBlock < us->MS_Lib.NumberOfPhyBlock;)
-       {
+       for (PhyBlock = 0; PhyBlock < us->MS_Lib.NumberOfPhyBlock;) {
                MS_LibPhy2LogRange(PhyBlock, &LogStart, &LogEnde);
 
-               for (i=0; i<MS_PHYSICAL_BLOCKS_PER_SEGMENT; i++, PhyBlock++)
-               {
-                       switch (MS_LibConv2Logical(us, PhyBlock))
-                       {
-                               case MS_STATUS_ERROR:
-                                       continue;
-                               default:
-                                       break;
+               for (i = 0; i < MS_PHYSICAL_BLOCKS_PER_SEGMENT;
+                       i++, PhyBlock++) {
+                       switch (MS_LibConv2Logical(us, PhyBlock)) {
+                       case MS_STATUS_ERROR:
+                               continue;
+                       default:
+                               break;
                        }
 
-                       if (count == PhyBlock)
-                       {
-                               MS_LibReadExtraBlock(us, PhyBlock, 0, 0x80, &buf);
+                       if (count == PhyBlock) {
+                               MS_LibReadExtraBlock(us, PhyBlock,
+                                                       0, 0x80, &buf);
                                count += 0x80;
                        }
                        index = (PhyBlock % 0x80) * 4;
 
                        extdat.ovrflg = buf[index];
                        extdat.mngflg = buf[index+1];
-                       extdat.logadr = MemStickLogAddr(buf[index+2], buf[index+3]);
+                       extdat.logadr = MemStickLogAddr(buf[index+2],
+                                                       buf[index+3]);
 
-                       if ((extdat.ovrflg & MS_REG_OVR_BKST) != MS_REG_OVR_BKST_OK)
-                       {
+                       if ((extdat.ovrflg & MS_REG_OVR_BKST) !=
+                               MS_REG_OVR_BKST_OK) {
                                MS_LibSetAcquiredErrorBlock(us, PhyBlock);
                                continue;
                        }
 
-                       if ((extdat.mngflg & MS_REG_MNG_ATFLG) == MS_REG_MNG_ATFLG_ATTBL)
-                       {
+                       if ((extdat.mngflg & MS_REG_MNG_ATFLG) ==
+                               MS_REG_MNG_ATFLG_ATTBL) {
                                MS_LibErasePhyBlock(us, PhyBlock);
                                continue;
                        }
 
-                       if (extdat.logadr != MS_LB_NOT_USED)
-                       {
-                               if ((extdat.logadr < LogStart) || (LogEnde <= extdat.logadr))
-                               {
+                       if (extdat.logadr != MS_LB_NOT_USED) {
+                               if ((extdat.logadr < LogStart) ||
+                                       (LogEnde <= extdat.logadr)) {
                                        MS_LibErasePhyBlock(us, PhyBlock);
                                        continue;
                                }
 
-                               if ((newblk = MS_LibConv2Physical(us, extdat.logadr)) != MS_LB_NOT_USED)
-                               {
-                                       if (extdat.logadr==0)
-                                       {
-                                               MS_LibSetLogicalPair(us, extdat.logadr, PhyBlock);
-                                               if ( MS_LibCheckDisableBlock(us, btBlk1st) )
-                                               {
-                                                       MS_LibSetLogicalPair(us, extdat.logadr, newblk);
+                               newblk = MS_LibConv2Physical(us, extdat.logadr);
+
+                               if (newblk != MS_LB_NOT_USED) {
+                                       if (extdat.logadr == 0) {
+                                               MS_LibSetLogicalPair(us,
+                                                               extdat.logadr,
+                                                               PhyBlock);
+                                               if (MS_LibCheckDisableBlock(us,
+                                                       btBlk1st)) {
+                                                       MS_LibSetLogicalPair(us,
+                                                       extdat.logadr, newblk);
                                                        continue;
                                                }
                                        }
 
                                        MS_LibReadExtra(us, newblk, 0, &extdat);
-                                       if ((extdat.ovrflg & MS_REG_OVR_UDST) == MS_REG_OVR_UDST_UPDATING)
-                                       {
-                                               MS_LibErasePhyBlock(us, PhyBlock);
+                                       if ((extdat.ovrflg & MS_REG_OVR_UDST) ==
+                                               MS_REG_OVR_UDST_UPDATING) {
+                                               MS_LibErasePhyBlock(us,
+                                                               PhyBlock);
                                                continue;
-                                       }
-                                       else
+                                       } else {
                                                MS_LibErasePhyBlock(us, newblk);
+                                       }
                                }
 
-                               MS_LibSetLogicalPair(us, extdat.logadr, PhyBlock);
+                               MS_LibSetLogicalPair(us, extdat.logadr,
+                                                               PhyBlock);
                        }
                }
-       } //End for ...
+       } /* End for ... */
 
        return MS_STATUS_SUCCESS;
 }
 
-//----- MS_LibAllocWriteBuf() ----------------------------------------
+/*
+ * MS_LibAllocWriteBuf()
+ */
 int MS_LibAllocWriteBuf(struct us_data *us)
 {
        us->MS_Lib.wrtblk = (WORD)-1;
 
-       us->MS_Lib.blkpag = kmalloc(us->MS_Lib.PagesPerBlock * us->MS_Lib.BytesPerSector, GFP_KERNEL);
-       us->MS_Lib.blkext = kmalloc(us->MS_Lib.PagesPerBlock * sizeof(MS_LibTypeExtdat), GFP_KERNEL);
+       us->MS_Lib.blkpag = kmalloc(us->MS_Lib.PagesPerBlock *
+                                       us->MS_Lib.BytesPerSector, GFP_KERNEL);
+       us->MS_Lib.blkext = kmalloc(us->MS_Lib.PagesPerBlock *
+                                       sizeof(MS_LibTypeExtdat), GFP_KERNEL);
 
-       if ((us->MS_Lib.blkpag == NULL) || (us->MS_Lib.blkext == NULL))
-       {
+       if ((us->MS_Lib.blkpag == NULL) || (us->MS_Lib.blkext == NULL)) {
                MS_LibFreeWriteBuf(us);
                return (DWORD)-1;
        }
@@ -620,7 +674,9 @@ int MS_LibAllocWriteBuf(struct us_data *us)
        return 0;
 }
 
-//----- MS_LibClearWriteBuf() ----------------------------------------
+/*
+ * MS_LibClearWriteBuf()
+ */
 void MS_LibClearWriteBuf(struct us_data *us)
 {
        int i;
@@ -629,12 +685,11 @@ void MS_LibClearWriteBuf(struct us_data *us)
        MS_LibClearPageMap(us);
 
        if (us->MS_Lib.blkpag)
-               memset(us->MS_Lib.blkpag, 0xff, us->MS_Lib.PagesPerBlock * us->MS_Lib.BytesPerSector);
+               memset(us->MS_Lib.blkpag, 0xff,
+                       us->MS_Lib.PagesPerBlock * us->MS_Lib.BytesPerSector);
 
-       if (us->MS_Lib.blkext)
-       {
-               for (i = 0; i < us->MS_Lib.PagesPerBlock; i++)
-               {
+       if (us->MS_Lib.blkext) {
+               for (i = 0; i < us->MS_Lib.PagesPerBlock; i++) {
                        us->MS_Lib.blkext[i].status1 = MS_REG_ST1_DEFAULT;
                        us->MS_Lib.blkext[i].ovrflg = MS_REG_OVR_DEFAULT;
                        us->MS_Lib.blkext[i].mngflg = MS_REG_MNG_DEFAULT;
@@ -643,32 +698,36 @@ void MS_LibClearWriteBuf(struct us_data *us)
        }
 }
 
-//----- MS_LibPhy2LogRange() -----------------------------------------
+/*
+ * MS_LibPhy2LogRange()
+ */
 void MS_LibPhy2LogRange(WORD PhyBlock, WORD *LogStart, WORD *LogEnde)
 {
        PhyBlock /= MS_PHYSICAL_BLOCKS_PER_SEGMENT;
 
-       if (PhyBlock)
-       {
-               *LogStart = MS_LOGICAL_BLOCKS_IN_1ST_SEGMENT + (PhyBlock - 1) * MS_LOGICAL_BLOCKS_PER_SEGMENT;//496
-               *LogEnde = *LogStart + MS_LOGICAL_BLOCKS_PER_SEGMENT;//496
-       }
-       else
-       {
+       if (PhyBlock) {
+               *LogStart = MS_LOGICAL_BLOCKS_IN_1ST_SEGMENT +
+                       (PhyBlock - 1) * MS_LOGICAL_BLOCKS_PER_SEGMENT;/*496*/
+               *LogEnde = *LogStart + MS_LOGICAL_BLOCKS_PER_SEGMENT;/*496*/
+       } else {
                *LogStart = 0;
-               *LogEnde = MS_LOGICAL_BLOCKS_IN_1ST_SEGMENT;//494
+               *LogEnde = MS_LOGICAL_BLOCKS_IN_1ST_SEGMENT;/*494*/
        }
 }
 
-//----- MS_LibReadExtraBlock() --------------------------------------------
-int MS_LibReadExtraBlock(struct us_data *us, DWORD PhyBlock, BYTE PageNum, BYTE blen, void *buf)
+/*
+ * MS_LibReadExtraBlock()
+ */
+int MS_LibReadExtraBlock(struct us_data *us, DWORD PhyBlock,
+                               BYTE PageNum, BYTE blen, void *buf)
 {
        struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
        int     result;
 
-       //printk("MS_LibReadExtraBlock --- PhyBlock = %x, PageNum = %x, blen = %x\n", PhyBlock, PageNum, blen);
+       /* printk("MS_LibReadExtraBlock --- PhyBlock = %x,
+               PageNum = %x, blen = %x\n", PhyBlock, PageNum, blen); */
 
-       // Read Extra Data
+       /* Read Extra Data */
        memset(bcb, 0, sizeof(struct bulk_cb_wrap));
        bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
        bcb->DataTransferLength = 0x4 * blen;
@@ -688,14 +747,18 @@ int MS_LibReadExtraBlock(struct us_data *us, DWORD PhyBlock, BYTE PageNum, BYTE
        return USB_STOR_TRANSPORT_GOOD;
 }
 
-//----- MS_LibReadExtra() --------------------------------------------
-int MS_LibReadExtra(struct us_data *us, DWORD PhyBlock, BYTE PageNum, MS_LibTypeExtdat *ExtraDat)
+/*
+ * MS_LibReadExtra()
+ */
+int MS_LibReadExtra(struct us_data *us, DWORD PhyBlock,
+               BYTE PageNum, MS_LibTypeExtdat *ExtraDat)
 {
        struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
        int     result;
        BYTE    ExtBuf[4];
 
-       //printk("MS_LibReadExtra --- PhyBlock = %x, PageNum = %x\n", PhyBlock, PageNum);
+       /* printk("MS_LibReadExtra --- PhyBlock = %x, PageNum = %x\n"
+                                               , PhyBlock, PageNum); */
        memset(bcb, 0, sizeof(struct bulk_cb_wrap));
        bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
        bcb->DataTransferLength = 0x4;
@@ -707,23 +770,25 @@ int MS_LibReadExtra(struct us_data *us, DWORD PhyBlock, BYTE PageNum, MS_LibType
        bcb->CDB[3]                     = (BYTE)(PhyBlock>>8);
        bcb->CDB[2]                     = (BYTE)(PhyBlock>>16);
        bcb->CDB[6]                     = 0x01;
-       
+
        result = ENE_SendScsiCmd(us, FDIR_READ, &ExtBuf, 0);
        if (result != USB_STOR_XFER_GOOD)
                return USB_STOR_TRANSPORT_ERROR;
 
        ExtraDat->reserved = 0;
-       ExtraDat->intr     = 0x80;  // Not yet, waiting for fireware support
-       ExtraDat->status0  = 0x10;  // Not yet, waiting for fireware support
-       ExtraDat->status1  = 0x00;  // Not yet, waiting for fireware support
+       ExtraDat->intr     = 0x80;  /* Not yet, waiting for fireware support */
+       ExtraDat->status0  = 0x10;  /* Not yet, waiting for fireware support */
+       ExtraDat->status1  = 0x00;  /* Not yet, waiting for fireware support */
        ExtraDat->ovrflg   = ExtBuf[0];
        ExtraDat->mngflg   = ExtBuf[1];
        ExtraDat->logadr   = MemStickLogAddr(ExtBuf[2], ExtBuf[3]);
-       
+
        return USB_STOR_TRANSPORT_GOOD;
 }
 
-//----- MS_LibSetAcquiredErrorBlock() --------------------------------
+/*
+ * MS_LibSetAcquiredErrorBlock()
+ */
 int MS_LibSetAcquiredErrorBlock(struct us_data *us, WORD phyblk)
 {
        WORD log;
@@ -731,7 +796,9 @@ int MS_LibSetAcquiredErrorBlock(struct us_data *us, WORD phyblk)
        if (phyblk >= us->MS_Lib.NumberOfPhyBlock)
                return (DWORD)-1;
 
-       if ((log = us->MS_Lib.Phy2LogMap[phyblk]) < us->MS_Lib.NumberOfLogBlock)
+       log = us->MS_Lib.Phy2LogMap[phyblk];
+
+       if (log  < us->MS_Lib.NumberOfLogBlock)
                us->MS_Lib.Log2PhyMap[log] = MS_LB_NOT_USED;
 
        if (us->MS_Lib.Phy2LogMap[phyblk] != MS_LB_INITIAL_ERROR)
@@ -740,7 +807,9 @@ int MS_LibSetAcquiredErrorBlock(struct us_data *us, WORD phyblk)
        return 0;
 }
 
-//----- MS_LibErasePhyBlock() ----------------------------------------
+/*
+ * MS_LibErasePhyBlock()
+ */
 int MS_LibErasePhyBlock(struct us_data *us, WORD phyblk)
 {
        WORD  log;
@@ -748,27 +817,27 @@ int MS_LibErasePhyBlock(struct us_data *us, WORD phyblk)
        if (phyblk >= us->MS_Lib.NumberOfPhyBlock)
                return MS_STATUS_ERROR;
 
-       if ((log = us->MS_Lib.Phy2LogMap[phyblk]) < us->MS_Lib.NumberOfLogBlock)
+       log = us->MS_Lib.Phy2LogMap[phyblk];
+
+       if (log < us->MS_Lib.NumberOfLogBlock)
                us->MS_Lib.Log2PhyMap[log] = MS_LB_NOT_USED;
 
        us->MS_Lib.Phy2LogMap[phyblk] = MS_LB_NOT_USED;
 
-       if (MS_LibIsWritable(us))
-       {
-               switch (MS_ReaderEraseBlock(us, phyblk))
-               {
-                       case MS_STATUS_SUCCESS:
-                               us->MS_Lib.Phy2LogMap[phyblk] = MS_LB_NOT_USED_ERASED;
-                               return MS_STATUS_SUCCESS;
-                       case MS_ERROR_FLASH_ERASE:
-                       case MS_STATUS_INT_ERROR :
-                               MS_LibErrorPhyBlock(us, phyblk);
-                               return MS_ERROR_FLASH_ERASE;
-                       case MS_STATUS_ERROR:
-                       default:
-                               MS_LibCtrlSet(us, MS_LIB_CTRL_RDONLY);
-                               MS_LibSetAcquiredErrorBlock(us, phyblk);
-                               return MS_STATUS_ERROR;
+       if (MS_LibIsWritable(us)) {
+               switch (MS_ReaderEraseBlock(us, phyblk)) {
+               case MS_STATUS_SUCCESS:
+                       us->MS_Lib.Phy2LogMap[phyblk] = MS_LB_NOT_USED_ERASED;
+                       return MS_STATUS_SUCCESS;
+               case MS_ERROR_FLASH_ERASE:
+               case MS_STATUS_INT_ERROR:
+                       MS_LibErrorPhyBlock(us, phyblk);
+                       return MS_ERROR_FLASH_ERASE;
+               case MS_STATUS_ERROR:
+               default:
+                       MS_LibCtrlSet(us, MS_LIB_CTRL_RDONLY);
+                       MS_LibSetAcquiredErrorBlock(us, phyblk);
+                       return MS_STATUS_ERROR;
                }
        }
 
@@ -777,28 +846,35 @@ int MS_LibErasePhyBlock(struct us_data *us, WORD phyblk)
        return MS_STATUS_SUCCESS;
 }
 
-//----- MS_LibErrorPhyBlock() ----------------------------------------
+/*
+ * MS_LibErrorPhyBlock()
+ */
 int MS_LibErrorPhyBlock(struct us_data *us, WORD phyblk)
 {
-    if (phyblk >= us->MS_Lib.NumberOfPhyBlock)
-        return MS_STATUS_ERROR;
+       if (phyblk >= us->MS_Lib.NumberOfPhyBlock)
+               return MS_STATUS_ERROR;
 
-    MS_LibSetAcquiredErrorBlock(us, phyblk);
+       MS_LibSetAcquiredErrorBlock(us, phyblk);
 
-    if (MS_LibIsWritable(us))
-        return MS_LibOverwriteExtra(us, phyblk, 0, (BYTE)(~MS_REG_OVR_BKST));
+       if (MS_LibIsWritable(us))
+               return MS_LibOverwriteExtra(us, phyblk, 0,
+                               (BYTE)(~MS_REG_OVR_BKST & BYTE_MASK));
 
 
-    return MS_STATUS_SUCCESS;
+       return MS_STATUS_SUCCESS;
 }
 
-//----- MS_LibOverwriteExtra() ---------------------------------------
-int MS_LibOverwriteExtra(struct us_data *us, DWORD PhyBlockAddr, BYTE PageNum, BYTE OverwriteFlag)
+/*
+ * MS_LibOverwriteExtra()
+ */
+int MS_LibOverwriteExtra(struct us_data *us, DWORD PhyBlockAddr,
+                               BYTE PageNum, BYTE OverwriteFlag)
 {
        struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
        int     result;
 
-       //printk("MS --- MS_LibOverwriteExtra,  PhyBlockAddr = %x, PageNum = %x\n", PhyBlockAddr, PageNum);
+       /* printk("MS --- MS_LibOverwriteExtra,  \
+               PhyBlockAddr = %x, PageNum = %x\n", PhyBlockAddr, PageNum); */
        result = ENE_LoadBinCode(us, MS_RW_PATTERN);
        if (result != USB_STOR_XFER_GOOD)
                return USB_STOR_TRANSPORT_ERROR;
@@ -817,7 +893,7 @@ int MS_LibOverwriteExtra(struct us_data *us, DWORD PhyBlockAddr, BYTE PageNum, B
        bcb->CDB[7]                     = 0xFF;
        bcb->CDB[8]                     = 0xFF;
        bcb->CDB[9]                     = 0xFF;
-       
+
        result = ENE_SendScsiCmd(us, FDIR_READ, NULL, 0);
        if (result != USB_STOR_XFER_GOOD)
                return USB_STOR_TRANSPORT_ERROR;
@@ -825,13 +901,16 @@ int MS_LibOverwriteExtra(struct us_data *us, DWORD PhyBlockAddr, BYTE PageNum, B
        return USB_STOR_TRANSPORT_GOOD;
 }
 
-//----- MS_LibForceSetLogicalPair() ----------------------------------
+/*
+ * MS_LibForceSetLogicalPair()
+ */
 int MS_LibForceSetLogicalPair(struct us_data *us, WORD logblk, WORD phyblk)
 {
        if (logblk == MS_LB_NOT_USED)
                return 0;
 
-       if ((logblk >= us->MS_Lib.NumberOfLogBlock) || (phyblk >= us->MS_Lib.NumberOfPhyBlock))
+       if ((logblk >= us->MS_Lib.NumberOfLogBlock) ||
+               (phyblk >= us->MS_Lib.NumberOfPhyBlock))
                return (DWORD)-1;
 
        us->MS_Lib.Phy2LogMap[phyblk] = logblk;
@@ -840,10 +919,13 @@ int MS_LibForceSetLogicalPair(struct us_data *us, WORD logblk, WORD phyblk)
        return 0;
 }
 
-//----- MS_LibSetLogicalPair() ---------------------------------------
+/*
+ * MS_LibSetLogicalPair()
+ */
 int MS_LibSetLogicalPair(struct us_data *us, WORD logblk, WORD phyblk)
 {
-       if ((logblk >= us->MS_Lib.NumberOfLogBlock) || (phyblk >= us->MS_Lib.NumberOfPhyBlock))
+       if ((logblk >= us->MS_Lib.NumberOfLogBlock) ||
+               (phyblk >= us->MS_Lib.NumberOfPhyBlock))
                return (DWORD)-1;
 
        us->MS_Lib.Phy2LogMap[phyblk] = logblk;
@@ -852,28 +934,30 @@ int MS_LibSetLogicalPair(struct us_data *us, WORD logblk, WORD phyblk)
        return 0;
 }
 
-//----- MS_CountFreeBlock() ------------------------------------------
+/*
+ * MS_CountFreeBlock()
+ */
 int MS_CountFreeBlock(struct us_data *us, WORD PhyBlock)
 {
        DWORD Ende, Count;
 
        Ende = PhyBlock + MS_PHYSICAL_BLOCKS_PER_SEGMENT;
-       for (Count = 0; PhyBlock < Ende; PhyBlock++)
-       {
-               switch (us->MS_Lib.Phy2LogMap[PhyBlock])
-               {
-                       case MS_LB_NOT_USED:
-                       case MS_LB_NOT_USED_ERASED:
-                               Count++;
-                       default:
-                               break;
+       for (Count = 0; PhyBlock < Ende; PhyBlock++) {
+               switch (us->MS_Lib.Phy2LogMap[PhyBlock]) {
+               case MS_LB_NOT_USED:
+               case MS_LB_NOT_USED_ERASED:
+                       Count++;
+               default:
+                       break;
                }
        }
 
        return Count;
 }
 
-//----- MS_LibSearchBlockFromPhysical() ------------------------------
+/*
+ * MS_LibSearchBlockFromPhysical()
+ */
 int MS_LibSearchBlockFromPhysical(struct us_data *us, WORD phyblk)
 {
        WORD                    Newblk;
@@ -883,70 +967,68 @@ int MS_LibSearchBlockFromPhysical(struct us_data *us, WORD phyblk)
        if (phyblk >= us->MS_Lib.NumberOfPhyBlock)
                return MS_LB_ERROR;
 
-       for (blk = phyblk + 1; blk != phyblk; blk++)
-       {
+       for (blk = phyblk + 1; blk != phyblk; blk++) {
                if ((blk & MS_PHYSICAL_BLOCKS_PER_SEGMENT_MASK) == 0)
                        blk -= MS_PHYSICAL_BLOCKS_PER_SEGMENT;
 
                Newblk = us->MS_Lib.Phy2LogMap[blk];
                if (us->MS_Lib.Phy2LogMap[blk] == MS_LB_NOT_USED_ERASED)
                        return blk;
-               else if (us->MS_Lib.Phy2LogMap[blk] == MS_LB_NOT_USED)
-               {
-                       switch (MS_LibReadExtra(us, blk, 0, &extdat))
-                       {
-                               case MS_STATUS_SUCCESS :
-                               case MS_STATUS_SUCCESS_WITH_ECC:
-                                       break;
-                               case MS_NOCARD_ERROR:
-                                       return MS_NOCARD_ERROR;
-                               case MS_STATUS_INT_ERROR:
-                                       return MS_LB_ERROR;
-                               case MS_ERROR_FLASH_READ:
-                               default:
-                                       MS_LibSetAcquiredErrorBlock(us, blk);     // MS_LibErrorPhyBlock(fdoExt, blk);
-                                       continue;
-                       } // End switch
+               else if (us->MS_Lib.Phy2LogMap[blk] == MS_LB_NOT_USED) {
+                       switch (MS_LibReadExtra(us, blk, 0, &extdat)) {
+                       case MS_STATUS_SUCCESS:
+                       case MS_STATUS_SUCCESS_WITH_ECC:
+                               break;
+                       case MS_NOCARD_ERROR:
+                               return MS_NOCARD_ERROR;
+                       case MS_STATUS_INT_ERROR:
+                               return MS_LB_ERROR;
+                       case MS_ERROR_FLASH_READ:
+                       default:
+                               MS_LibSetAcquiredErrorBlock(us, blk);
+                               /* MS_LibErrorPhyBlock(fdoExt, blk); */
+                               continue;
+                       } /* End switch */
 
-                       if ((extdat.ovrflg & MS_REG_OVR_BKST) != MS_REG_OVR_BKST_OK)
-                       {
+                       if ((extdat.ovrflg & MS_REG_OVR_BKST) !=
+                                               MS_REG_OVR_BKST_OK) {
                                MS_LibSetAcquiredErrorBlock(us, blk);
                                continue;
                        }
 
-                       switch (MS_LibErasePhyBlock(us, blk))
-                       {
-                               case MS_STATUS_SUCCESS:
-                                       return blk;
-                               case MS_STATUS_ERROR:
-                                       return MS_LB_ERROR;
-                               case MS_ERROR_FLASH_ERASE:
-                               default:
-                                       MS_LibErrorPhyBlock(us, blk);
-                                       break;
+                       switch (MS_LibErasePhyBlock(us, blk)) {
+                       case MS_STATUS_SUCCESS:
+                               return blk;
+                       case MS_STATUS_ERROR:
+                               return MS_LB_ERROR;
+                       case MS_ERROR_FLASH_ERASE:
+                       default:
+                               MS_LibErrorPhyBlock(us, blk);
+                               break;
                        }
                }
-       } // End for
+       } /* End for */
 
        return MS_LB_ERROR;
 }
 
-//----- MS_LibSearchBlockFromLogical() -------------------------------
+/*
+ * MS_LibSearchBlockFromLogical()
+ */
 int MS_LibSearchBlockFromLogical(struct us_data *us, WORD logblk)
 {
        WORD phyblk;
 
-       if ((phyblk=MS_LibConv2Physical(us, logblk)) >= MS_LB_ERROR)
-       {
+       phyblk = MS_LibConv2Physical(us, logblk);
+       if (phyblk >= MS_LB_ERROR) {
                if (logblk >= us->MS_Lib.NumberOfLogBlock)
                        return MS_LB_ERROR;
 
-               phyblk = (logblk + MS_NUMBER_OF_BOOT_BLOCK) / MS_LOGICAL_BLOCKS_PER_SEGMENT;
+               phyblk = (logblk + MS_NUMBER_OF_BOOT_BLOCK) /
+                                       MS_LOGICAL_BLOCKS_PER_SEGMENT;
                phyblk *= MS_PHYSICAL_BLOCKS_PER_SEGMENT;
                phyblk += MS_PHYSICAL_BLOCKS_PER_SEGMENT - 1;
        }
 
        return MS_LibSearchBlockFromPhysical(us, phyblk);
 }
-
-
index 4509db79298a5772389b6f8f0a934b166c359130..a3da4be3f55623e523ff1516d4fb40cd63c056d0 100644 (file)
@@ -4,41 +4,41 @@
 #include <linux/blkdev.h>
 #include "common.h"
 
-// MemoryStick Register
-// Status Register 0
-#define MS_REG_ST0_MB                           0x80    // media busy
-#define MS_REG_ST0_FB0                          0x40    // flush busy 0
-#define MS_REG_ST0_BE                           0x20    // buffer empty
-#define MS_REG_ST0_BF                           0x10    // buffer full
-#define MS_REG_ST0_SL                           0x02    // sleep
-#define MS_REG_ST0_WP                           0x01    // write protected
+/* MemoryStick Register */
+/* Status Register 0 */
+#define MS_REG_ST0_MB                           0x80    /* media busy */
+#define MS_REG_ST0_FB0                          0x40    /* flush busy 0 */
+#define MS_REG_ST0_BE                           0x20    /* buffer empty */
+#define MS_REG_ST0_BF                           0x10    /* buffer full */
+#define MS_REG_ST0_SL                           0x02    /* sleep */
+#define MS_REG_ST0_WP                           0x01    /* write protected */
 #define MS_REG_ST0_WP_ON                        MS_REG_ST0_WP
 #define MS_REG_ST0_WP_OFF                       0x00
 
-// Status Register 1
-#define MS_REG_ST1_MB                           0x80    // media busy
-#define MS_REG_ST1_FB1                          0x40    // flush busy 1
-#define MS_REG_ST1_DTER                         0x20    // error on data(corrected)
-#define MS_REG_ST1_UCDT                         0x10    // unable to correct data
-#define MS_REG_ST1_EXER                         0x08    // error on extra(corrected)
-#define MS_REG_ST1_UCEX                         0x04    // unable to correct extra
-#define MS_REG_ST1_FGER                         0x02    // error on overwrite flag(corrected)
-#define MS_REG_ST1_UCFG                         0x01    // unable to correct overwrite flag
-#define MS_REG_ST1_DEFAULT                      (MS_REG_ST1_MB   | MS_REG_ST1_FB1  | \
-                                                 MS_REG_ST1_DTER | MS_REG_ST1_UCDT | \
-                                                 MS_REG_ST1_EXER | MS_REG_ST1_UCEX | \
-                                                 MS_REG_ST1_FGER | MS_REG_ST1_UCFG)
-
-// System Parameter
-#define MS_REG_SYSPAR_BAMD                      0x80                // block address mode
-#define MS_REG_SYSPAR_BAND_LINEAR               MS_REG_SYSPAR_BAMD  //   linear mode
-#define MS_REG_SYSPAR_BAND_CHIP                 0x00                //  chip mode
-#define MS_REG_SYSPAR_ATEN                      0x40                // attribute ROM enable
-#define MS_REG_SYSPAR_ATEN_ENABLE               MS_REG_SYSPAR_ATEN  //  enable
-#define MS_REG_SYSPAR_ATEN_DISABLE              0x00                //  disable
+/* Status Register 1 */
+#define MS_REG_ST1_MB          0x80    /* media busy */
+#define MS_REG_ST1_FB1         0x40    /* flush busy 1 */
+#define MS_REG_ST1_DTER                0x20    /* error on data(corrected) */
+#define MS_REG_ST1_UCDT                0x10    /* unable to correct data */
+#define MS_REG_ST1_EXER                0x08    /* error on extra(corrected) */
+#define MS_REG_ST1_UCEX                0x04    /* unable to correct extra */
+#define MS_REG_ST1_FGER                0x02    /* error on overwrite flag(corrected) */
+#define MS_REG_ST1_UCFG                0x01    /* unable to correct overwrite flag */
+#define MS_REG_ST1_DEFAULT     (MS_REG_ST1_MB   | MS_REG_ST1_FB1  | \
+                               MS_REG_ST1_DTER | MS_REG_ST1_UCDT | \
+                               MS_REG_ST1_EXER | MS_REG_ST1_UCEX | \
+                               MS_REG_ST1_FGER | MS_REG_ST1_UCFG)
+
+/* System Parameter */
+#define MS_REG_SYSPAR_BAMD             0x80    /* block address mode */
+#define MS_REG_SYSPAR_BAND_LINEAR      MS_REG_SYSPAR_BAMD  /*   linear mode */
+#define MS_REG_SYSPAR_BAND_CHIP                0x00    /*  chip mode */
+#define MS_REG_SYSPAR_ATEN             0x40    /* attribute ROM enable */
+#define MS_REG_SYSPAR_ATEN_ENABLE      MS_REG_SYSPAR_ATEN      /*  enable */
+#define MS_REG_SYSPAR_ATEN_DISABLE     0x00    /*  disable */
 #define MS_REG_SYSPAR_RESERVED                  0x2f
 
-// Command Parameter
+/* Command Parameter */
 #define MS_REG_CMDPAR_CP2                       0x80
 #define MS_REG_CMDPAR_CP1                       0x40
 #define MS_REG_CMDPAR_CP0                       0x20
 #define MS_REG_CMDPAR_OVERWRITE                 MS_REG_CMDPAR_CP2
 #define MS_REG_CMDPAR_RESERVED                  0x1f
 
-// Overwrite Area
-#define MS_REG_OVR_BKST                         0x80            // block status
-#define MS_REG_OVR_BKST_OK                      MS_REG_OVR_BKST     // OK
-#define MS_REG_OVR_BKST_NG                      0x00            // NG
-#define MS_REG_OVR_PGST0                        0x40            // page status
+/* Overwrite Area */
+#define MS_REG_OVR_BKST                0x80            /* block status */
+#define MS_REG_OVR_BKST_OK                      MS_REG_OVR_BKST     /* OK */
+#define MS_REG_OVR_BKST_NG                      0x00            /* NG */
+#define MS_REG_OVR_PGST0       0x40            /* page status */
 #define MS_REG_OVR_PGST1                        0x20
-#define MS_REG_OVR_PGST_MASK                    (MS_REG_OVR_PGST0 | MS_REG_OVR_PGST1)
-#define MS_REG_OVR_PGST_OK                      (MS_REG_OVR_PGST0 | MS_REG_OVR_PGST1) // OK
-#define MS_REG_OVR_PGST_NG                      MS_REG_OVR_PGST1                      // NG
-#define MS_REG_OVR_PGST_DATA_ERROR              0x00        // data error
-#define MS_REG_OVR_UDST                         0x10        // update status
-#define MS_REG_OVR_UDST_UPDATING                0x00        // updating
+#define MS_REG_OVR_PGST_MASK   (MS_REG_OVR_PGST0 | MS_REG_OVR_PGST1)
+#define MS_REG_OVR_PGST_OK     (MS_REG_OVR_PGST0 | MS_REG_OVR_PGST1) /* OK */
+#define MS_REG_OVR_PGST_NG     MS_REG_OVR_PGST1                      /* NG */
+#define MS_REG_OVR_PGST_DATA_ERROR              0x00        /* data error */
+#define MS_REG_OVR_UDST                         0x10        /* update status */
+#define MS_REG_OVR_UDST_UPDATING                0x00        /* updating */
 #define MS_REG_OVR_UDST_NO_UPDATE               MS_REG_OVR_UDST
 #define MS_REG_OVR_RESERVED                     0x08
 #define MS_REG_OVR_DEFAULT                      (MS_REG_OVR_BKST_OK |      \
-                                                 MS_REG_OVR_PGST_OK |      \
-                                                 MS_REG_OVR_UDST_NO_UPDATE |   \
-                                                 MS_REG_OVR_RESERVED)
-// Management Flag
-#define MS_REG_MNG_SCMS0                        0x20    // serial copy management system
+                                               MS_REG_OVR_PGST_OK |      \
+                                               MS_REG_OVR_UDST_NO_UPDATE |   \
+                                               MS_REG_OVR_RESERVED)
+/* Management Flag */
+#define MS_REG_MNG_SCMS0       0x20    /* serial copy management system */
 #define MS_REG_MNG_SCMS1                        0x10
-#define MS_REG_MNG_SCMS_MASK                    (MS_REG_MNG_SCMS0 | MS_REG_MNG_SCMS1)
-#define MS_REG_MNG_SCMS_COPY_OK                 (MS_REG_MNG_SCMS0 | MS_REG_MNG_SCMS1)
+#define MS_REG_MNG_SCMS_MASK           (MS_REG_MNG_SCMS0 | MS_REG_MNG_SCMS1)
+#define MS_REG_MNG_SCMS_COPY_OK                (MS_REG_MNG_SCMS0 | MS_REG_MNG_SCMS1)
 #define MS_REG_MNG_SCMS_ONE_COPY                MS_REG_MNG_SCMS1
 #define MS_REG_MNG_SCMS_NO_COPY                 0x00
-#define MS_REG_MNG_ATFLG                        0x08    // address transfer table flag
-#define MS_REG_MNG_ATFLG_OTHER                  MS_REG_MNG_ATFLG    // other
-#define MS_REG_MNG_ATFLG_ATTBL                  0x00    // address transfer table
-#define MS_REG_MNG_SYSFLG                       0x04    // system flag
-#define MS_REG_MNG_SYSFLG_USER                  MS_REG_MNG_SYSFLG   // user block
-#define MS_REG_MNG_SYSFLG_BOOT                  0x00            // system block
+#define MS_REG_MNG_ATFLG       0x08    /* address transfer table flag */
+#define MS_REG_MNG_ATFLG_OTHER                  MS_REG_MNG_ATFLG    /* other */
+#define MS_REG_MNG_ATFLG_ATTBL         0x00    /* address transfer table */
+#define MS_REG_MNG_SYSFLG                       0x04    /* system flag */
+#define MS_REG_MNG_SYSFLG_USER         MS_REG_MNG_SYSFLG   /* user block */
+#define MS_REG_MNG_SYSFLG_BOOT                  0x00    /* system block */
 #define MS_REG_MNG_RESERVED                     0xc3
 #define MS_REG_MNG_DEFAULT             (MS_REG_MNG_SCMS_COPY_OK |      \
                                         MS_REG_MNG_ATFLG_OTHER |       \
                                         MS_REG_MNG_SYSFLG_USER |       \
                                         MS_REG_MNG_RESERVED)
 
-// Error codes
+/* Error codes */
 #define MS_STATUS_SUCCESS                       0x0000
 #define MS_ERROR_OUT_OF_SPACE                   0x0103
 #define MS_STATUS_WRITE_PROTECT                 0x0106
 #define MS_LB_ACQUIRED_ERROR                    0xfff4
 #define MS_LB_NOT_USED_ERASED                   0xfff5
 
-#define MS_LibConv2Physical(pdx, LogBlock)      (((LogBlock) >= (pdx)->MS_Lib.NumberOfLogBlock) ? MS_STATUS_ERROR : (pdx)->MS_Lib.Log2PhyMap[LogBlock])
-#define MS_LibConv2Logical(pdx, PhyBlock)       (((PhyBlock) >= (pdx)->MS_Lib.NumberOfPhyBlock) ? MS_STATUS_ERROR : (pdx)->MS_Lib.Phy2LogMap[PhyBlock]) //¬dphy->log table
+#define MS_LibConv2Physical(pdx, LogBlock) \
+       (((LogBlock) >= (pdx)->MS_Lib.NumberOfLogBlock) ? \
+       MS_STATUS_ERROR : (pdx)->MS_Lib.Log2PhyMap[LogBlock])
+#define MS_LibConv2Logical(pdx, PhyBlock) \
+       (((PhyBlock) >= (pdx)->MS_Lib.NumberOfPhyBlock) ? \
+       MS_STATUS_ERROR : (pdx)->MS_Lib.Phy2LogMap[PhyBlock])
+       /*dphy->log table */
 
 #define MS_LIB_CTRL_RDONLY                      0
 #define MS_LIB_CTRL_WRPROTECT                   1
-#define MS_LibCtrlCheck(pdx, Flag)              ((pdx)->MS_Lib.flags & (1 << (Flag)))
+#define MS_LibCtrlCheck(pdx, Flag)     ((pdx)->MS_Lib.flags & (1 << (Flag)))
 
-#define MS_LibCtrlSet(pdx, Flag)                (pdx)->MS_Lib.flags |= (1 << (Flag))
-#define MS_LibCtrlReset(pdx, Flag)              (pdx)->MS_Lib.flags &= ~(1 << (Flag))
-#define MS_LibIsWritable(pdx)                   ((MS_LibCtrlCheck((pdx), MS_LIB_CTRL_RDONLY) == 0) && (MS_LibCtrlCheck(pdx, MS_LIB_CTRL_WRPROTECT) == 0))
+#define MS_LibCtrlSet(pdx, Flag)       ((pdx)->MS_Lib.flags |= (1 << (Flag)))
+#define MS_LibCtrlReset(pdx, Flag)     ((pdx)->MS_Lib.flags &= ~(1 << (Flag)))
+#define MS_LibIsWritable(pdx) \
+       ((MS_LibCtrlCheck((pdx), MS_LIB_CTRL_RDONLY) == 0) && \
+       (MS_LibCtrlCheck(pdx, MS_LIB_CTRL_WRPROTECT) == 0))
 
 #define MS_MAX_PAGES_PER_BLOCK                  32
 #define MS_LIB_BITS_PER_BYTE                    8
 
-#define MS_LibPageMapIdx(n)                     ((n) / MS_LIB_BITS_PER_BYTE)
-#define MS_LibPageMapBit(n)                     (1 << ((n) % MS_LIB_BITS_PER_BYTE))
-#define MS_LibCheckPageMapBit(pdx, n)           ((pdx)->MS_Lib.pagemap[MS_LibPageMapIdx(n)] & MS_LibPageMapBit(n))
-#define MS_LibSetPageMapBit(pdx, n)             ((pdx)->MS_Lib.pagemap[MS_LibPageMapIdx(n)] |= MS_LibPageMapBit(n))
-#define MS_LibResetPageMapBit(pdx, n)           ((pdx)->MS_Lib.pagemap[MS_LibPageMapIdx(n)] &= ~MS_LibPageMapBit(n))
-#define MS_LibClearPageMap(pdx)                 memset((pdx)->MS_Lib.pagemap, 0, sizeof((pdx)->MS_Lib.pagemap))
+#define MS_LibPageMapIdx(n) ((n) / MS_LIB_BITS_PER_BYTE)
+#define MS_LibPageMapBit(n) (1 << ((n) % MS_LIB_BITS_PER_BYTE))
+#define MS_LibCheckPageMapBit(pdx, n) \
+       ((pdx)->MS_Lib.pagemap[MS_LibPageMapIdx(n)] & MS_LibPageMapBit(n))
+#define MS_LibSetPageMapBit(pdx, n) \
+       ((pdx)->MS_Lib.pagemap[MS_LibPageMapIdx(n)] |= MS_LibPageMapBit(n))
+#define MS_LibResetPageMapBit(pdx, n) \
+       ((pdx)->MS_Lib.pagemap[MS_LibPageMapIdx(n)] &= ~MS_LibPageMapBit(n))
+#define MS_LibClearPageMap(pdx) \
+       memset((pdx)->MS_Lib.pagemap, 0, sizeof((pdx)->MS_Lib.pagemap))
 
 
-#define MemStickLogAddr(logadr1, logadr0)       ((((WORD)(logadr1)) << 8) | (logadr0))
+#define MemStickLogAddr(logadr1, logadr0) \
+       ((((WORD)(logadr1)) << 8) | (logadr0))
 
 #define MS_BYTES_PER_PAGE                       512
 
 #define MS_NUMBER_OF_SYSTEM_BLOCK               4
 #define MS_LOGICAL_BLOCKS_PER_SEGMENT           496
 #define MS_LOGICAL_BLOCKS_IN_1ST_SEGMENT        494
-#define MS_PHYSICAL_BLOCKS_PER_SEGMENT          0x200   // 512
+#define MS_PHYSICAL_BLOCKS_PER_SEGMENT          0x200   /* 512 */
 #define MS_PHYSICAL_BLOCKS_PER_SEGMENT_MASK     0x1ff
 
 #define MS_SECTOR_SIZE                          512
 #define MS_SYSINF_SECURITY                      0x01
 #define MS_SYSINF_SECURITY_NO_SUPPORT           MS_SYSINF_SECURITY
 #define MS_SYSINF_SECURITY_SUPPORT              0
-#define MS_SYSINF_FORMAT_MAT                    0   // ?
+#define MS_SYSINF_FORMAT_MAT                    0   /* ? */
 #define MS_SYSINF_FORMAT_FAT                    1
 #define MS_SYSINF_USAGE_GENERAL                 0
-#define MS_SYSINF_PAGE_SIZE                     MS_BYTES_PER_PAGE // fixed
+#define MS_SYSINF_PAGE_SIZE                     MS_BYTES_PER_PAGE /* fixed */
 #define MS_SYSINF_RESERVED1                     1
 #define MS_SYSINF_RESERVED2                     1
 
 #define MS_SYSENT_TYPE_INVALID_BLOCK            0x01
-#define MS_SYSENT_TYPE_CIS_IDI                  0x0a    // CIS/IDI
+#define MS_SYSENT_TYPE_CIS_IDI                  0x0a    /* CIS/IDI */
 
 #define SIZE_OF_KIRO                            1024
 
-// BOOT BLOCK
+/* BOOT BLOCK */
 #define MS_NUMBER_OF_SYSTEM_ENTRY               4
 
-//----- MemStickRegisters --------------------------------------------
-// Status registers (16 bytes)
+/*
+ * MemStickRegisters
+ */
+/* Status registers (16 bytes) */
 typedef struct {
-       BYTE Reserved0;         // 00
-       BYTE INTRegister;       // 01
-       BYTE StatusRegister0;   // 02
-       BYTE StatusRegister1;   // 03
-       BYTE Reserved1[12];     // 04-0F
+       BYTE Reserved0;         /* 00 */
+       BYTE INTRegister;       /* 01 */
+       BYTE StatusRegister0;   /* 02 */
+       BYTE StatusRegister1;   /* 03 */
+       BYTE Reserved1[12];     /* 04-0F */
 } MemStickStatusRegisters;
 
-// Parameter registers (6 bytes)
+/* Parameter registers (6 bytes) */
 typedef struct {
-       BYTE SystemParameter;   // 10
-       BYTE BlockAddress2;     // 11
-       BYTE BlockAddress1;     // 12
-       BYTE BlockAddress0;     // 13
-       BYTE CMDParameter;      // 14
-       BYTE PageAddress;       // 15
+       BYTE SystemParameter;   /* 10 */
+       BYTE BlockAddress2;     /* 11 */
+       BYTE BlockAddress1;     /* 12 */
+       BYTE BlockAddress0;     /* 13 */
+       BYTE CMDParameter;      /* 14 */
+       BYTE PageAddress;       /* 15 */
 } MemStickParameterRegisters;
 
-// Extra registers (9 bytes)
+/* Extra registers (9 bytes) */
 typedef struct {
-       BYTE OverwriteFlag;     // 16
-       BYTE ManagementFlag;    // 17
-       BYTE LogicalAddress1;   // 18
-       BYTE LogicalAddress0;   // 19
-       BYTE ReservedArea[5];   // 1A-1E
+       BYTE OverwriteFlag;     /* 16 */
+       BYTE ManagementFlag;    /* 17 */
+       BYTE LogicalAddress1;   /* 18 */
+       BYTE LogicalAddress0;   /* 19 */
+       BYTE ReservedArea[5];   /* 1A-1E */
 } MemStickExtraDataRegisters;
 
-// All registers in Memory Stick (32 bytes, includes 1 byte padding)
+/* All registers in Memory Stick (32 bytes, includes 1 byte padding) */
 typedef struct {
        MemStickStatusRegisters status;
        MemStickParameterRegisters param;
@@ -217,7 +231,9 @@ typedef struct {
        BYTE padding;
 } MemStickRegisters, *PMemStickRegisters;
 
-//----- MemStickBootBlockPage0 ---------------------------------------
+/*
+ * MemStickBootBlockPage0
+ */
 typedef struct {
        WORD wBlockID;
        WORD wFormatVersion;
@@ -238,13 +254,13 @@ typedef struct {
 } MemStickBootBlockSysEnt;
 
 typedef struct {
-       BYTE bMsClass;          // must be 1
-       BYTE bCardType;         // see below
-       WORD wBlockSize;        // n KB
-       WORD wBlockNumber;      // number of physical block
-       WORD wTotalBlockNumber; // number of logical block
-       WORD wPageSize;         // must be 0x200
-       BYTE bExtraSize;        // 0x10
+       BYTE bMsClass;          /* must be 1 */
+       BYTE bCardType;         /* see below */
+       WORD wBlockSize;        /* n KB */
+       WORD wBlockNumber;      /* number of physical block */
+       WORD wTotalBlockNumber; /* number of logical block */
+       WORD wPageSize;         /* must be 0x200 */
+       BYTE bExtraSize;        /* 0x10 */
        BYTE bSecuritySupport;
        BYTE bAssemblyDate[8];
        BYTE bFactoryArea[4];
@@ -258,10 +274,10 @@ typedef struct {
        BYTE bVCC;
        BYTE bVPP;
        WORD wControllerChipNumber;
-       WORD wControllerFunction;       // New MS
-       BYTE bReserved3[9];             // New MS
-       BYTE bParallelSupport;          // New MS
-       WORD wFormatValue;              // New MS
+       WORD wControllerFunction;       /* New MS */
+       BYTE bReserved3[9];             /* New MS */
+       BYTE bParallelSupport;          /* New MS */
+       WORD wFormatValue;              /* New MS */
        BYTE bFormatType;
        BYTE bUsage;
        BYTE bDeviceType;
@@ -277,60 +293,62 @@ typedef struct {
        MemStickBootBlockSysInf sysinf;
 } MemStickBootBlockPage0;
 
-//----- MemStickBootBlockCIS_IDI -------------------------------------
+/*
+ * MemStickBootBlockCIS_IDI
+ */
 typedef struct {
-       BYTE bCistplDEVICE[6];            // 0
-       BYTE bCistplDEVICE0C[6];          // 6
-       BYTE bCistplJEDECC[4];            // 12
-       BYTE bCistplMANFID[6];            // 16
-       BYTE bCistplVER1[32];             // 22
-       BYTE bCistplFUNCID[4];            // 54
-       BYTE bCistplFUNCE0[4];            // 58
-       BYTE bCistplFUNCE1[5];            // 62
-       BYTE bCistplCONF[7];              // 67
-       BYTE bCistplCFTBLENT0[10];        // 74
-       BYTE bCistplCFTBLENT1[8];         // 84
-       BYTE bCistplCFTBLENT2[12];        // 92
-       BYTE bCistplCFTBLENT3[8];         // 104
-       BYTE bCistplCFTBLENT4[17];        // 112
-       BYTE bCistplCFTBLENT5[8];         // 129
-       BYTE bCistplCFTBLENT6[17];        // 137
-       BYTE bCistplCFTBLENT7[8];         // 154
-       BYTE bCistplNOLINK[3];            // 162
+       BYTE bCistplDEVICE[6];            /* 0 */
+       BYTE bCistplDEVICE0C[6];          /* 6 */
+       BYTE bCistplJEDECC[4];            /* 12 */
+       BYTE bCistplMANFID[6];            /* 16 */
+       BYTE bCistplVER1[32];             /* 22 */
+       BYTE bCistplFUNCID[4];            /* 54 */
+       BYTE bCistplFUNCE0[4];            /* 58 */
+       BYTE bCistplFUNCE1[5];            /* 62 */
+       BYTE bCistplCONF[7];              /* 67 */
+       BYTE bCistplCFTBLENT0[10];        /* 74 */
+       BYTE bCistplCFTBLENT1[8];         /* 84 */
+       BYTE bCistplCFTBLENT2[12];        /* 92 */
+       BYTE bCistplCFTBLENT3[8];         /* 104 */
+       BYTE bCistplCFTBLENT4[17];        /* 112 */
+       BYTE bCistplCFTBLENT5[8];         /* 129 */
+       BYTE bCistplCFTBLENT6[17];        /* 137 */
+       BYTE bCistplCFTBLENT7[8];         /* 154 */
+       BYTE bCistplNOLINK[3];            /* 162 */
 } MemStickBootBlockCIS;
 
 typedef struct {
 #define MS_IDI_GENERAL_CONF         0x848A
-       WORD wIDIgeneralConfiguration;     // 0
-       WORD wIDInumberOfCylinder;         // 1
-       WORD wIDIreserved0;                // 2
-       WORD wIDInumberOfHead;             // 3
-       WORD wIDIbytesPerTrack;            // 4
-       WORD wIDIbytesPerSector;           // 5
-       WORD wIDIsectorsPerTrack;          // 6
-       WORD wIDItotalSectors[2];          // 7-8  high,low
-       WORD wIDIreserved1[11];            // 9-19
-       WORD wIDIbufferType;               // 20
-       WORD wIDIbufferSize;               // 21
-       WORD wIDIlongCmdECC;               // 22
-       WORD wIDIfirmVersion[4];           // 23-26
-       WORD wIDImodelName[20];            // 27-46
-       WORD wIDIreserved2;                // 47
-       WORD wIDIlongWordSupported;        // 48
-       WORD wIDIdmaSupported;             // 49
-       WORD wIDIreserved3;                // 50
-       WORD wIDIpioTiming;                // 51
-       WORD wIDIdmaTiming;                // 52
-       WORD wIDItransferParameter;        // 53
-       WORD wIDIformattedCylinder;        // 54
-       WORD wIDIformattedHead;            // 55
-       WORD wIDIformattedSectorsPerTrack; // 56
-       WORD wIDIformattedTotalSectors[2]; // 57-58
-       WORD wIDImultiSector;              // 59
-       WORD wIDIlbaSectors[2];            // 60-61
-       WORD wIDIsingleWordDMA;            // 62
-       WORD wIDImultiWordDMA;             // 63
-       WORD wIDIreserved4[192];           // 64-255
+       WORD wIDIgeneralConfiguration;     /* 0 */
+       WORD wIDInumberOfCylinder;         /* 1 */
+       WORD wIDIreserved0;                /* 2 */
+       WORD wIDInumberOfHead;             /* 3 */
+       WORD wIDIbytesPerTrack;            /* 4 */
+       WORD wIDIbytesPerSector;           /* 5 */
+       WORD wIDIsectorsPerTrack;          /* 6 */
+       WORD wIDItotalSectors[2];          /* 7-8  high,low */
+       WORD wIDIreserved1[11];            /* 9-19 */
+       WORD wIDIbufferType;               /* 20 */
+       WORD wIDIbufferSize;               /* 21 */
+       WORD wIDIlongCmdECC;               /* 22 */
+       WORD wIDIfirmVersion[4];           /* 23-26 */
+       WORD wIDImodelName[20];            /* 27-46 */
+       WORD wIDIreserved2;                /* 47 */
+       WORD wIDIlongWordSupported;        /* 48 */
+       WORD wIDIdmaSupported;             /* 49 */
+       WORD wIDIreserved3;                /* 50 */
+       WORD wIDIpioTiming;                /* 51 */
+       WORD wIDIdmaTiming;                /* 52 */
+       WORD wIDItransferParameter;        /* 53 */
+       WORD wIDIformattedCylinder;        /* 54 */
+       WORD wIDIformattedHead;            /* 55 */
+       WORD wIDIformattedSectorsPerTrack; /* 56 */
+       WORD wIDIformattedTotalSectors[2]; /* 57-58 */
+       WORD wIDImultiSector;              /* 59 */
+       WORD wIDIlbaSectors[2];            /* 60-61 */
+       WORD wIDIsingleWordDMA;            /* 62 */
+       WORD wIDImultiWordDMA;             /* 63 */
+       WORD wIDIreserved4[192];           /* 64-255 */
 } MemStickBootBlockIDI;
 
 typedef struct {
@@ -346,7 +364,9 @@ typedef struct {
 
 } MemStickBootBlockCIS_IDI;
 
-//----- MS_LibControl ------------------------------------------------
+/*
+ * MS_LibControl
+ */
 typedef struct {
        BYTE reserved;
        BYTE intr;
@@ -362,14 +382,14 @@ typedef struct {
        DWORD BytesPerSector;
        DWORD NumberOfCylinder;
        DWORD SectorsPerCylinder;
-       WORD cardType;                  // R/W, RO, Hybrid
+       WORD cardType;                  /* R/W, RO, Hybrid */
        WORD blockSize;
        WORD PagesPerBlock;
        WORD NumberOfPhyBlock;
        WORD NumberOfLogBlock;
        WORD NumberOfSegment;
-       WORD *Phy2LogMap;               // phy2log table
-       WORD *Log2PhyMap;               // log2phy table
+       WORD *Phy2LogMap;               /* phy2log table */
+       WORD *Log2PhyMap;               /* log2phy table */
        WORD wrtblk;
        BYTE pagemap[(MS_MAX_PAGES_PER_BLOCK + (MS_LIB_BITS_PER_BYTE-1)) /
                     MS_LIB_BITS_PER_BYTE];
index cb92d25acee07094ebd0653d40e07584fac79860..cb7190e0e18a18d64e5fe0076e6038137a58be4f 100644 (file)
@@ -1,3 +1,5 @@
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/sched.h>
 #include <linux/errno.h>
 #include <linux/slab.h>
 #include "scsiglue.h"
 #include "transport.h"
 
-int MS_SCSI_Test_Unit_Ready (struct us_data *us, struct scsi_cmnd *srb);
-int MS_SCSI_Inquiry         (struct us_data *us, struct scsi_cmnd *srb);
-int MS_SCSI_Mode_Sense      (struct us_data *us, struct scsi_cmnd *srb);
-int MS_SCSI_Start_Stop      (struct us_data *us, struct scsi_cmnd *srb);
-int MS_SCSI_Read_Capacity   (struct us_data *us, struct scsi_cmnd *srb);
-int MS_SCSI_Read            (struct us_data *us, struct scsi_cmnd *srb);
-int MS_SCSI_Write           (struct us_data *us, struct scsi_cmnd *srb);
-
-//----- MS_SCSIIrp() --------------------------------------------------
-int MS_SCSIIrp(struct us_data *us, struct scsi_cmnd *srb)
-{
-       int    result;
-
-       us->SrbStatus = SS_SUCCESS;
-       switch (srb->cmnd[0])
-       {
-               case TEST_UNIT_READY :  result = MS_SCSI_Test_Unit_Ready (us, srb);  break; //0x00
-               case INQUIRY         :  result = MS_SCSI_Inquiry         (us, srb);  break; //0x12
-               case MODE_SENSE      :  result = MS_SCSI_Mode_Sense      (us, srb);  break; //0x1A
-               case READ_CAPACITY   :  result = MS_SCSI_Read_Capacity   (us, srb);  break; //0x25
-               case READ_10         :  result = MS_SCSI_Read            (us, srb);  break; //0x28
-               case WRITE_10        :  result = MS_SCSI_Write           (us, srb);  break; //0x2A
-
-               default:
-                       us->SrbStatus = SS_ILLEGAL_REQUEST;
-                       result = USB_STOR_TRANSPORT_FAILED;
-                       break;
-       }
-       return result;
-}
-
-//----- MS_SCSI_Test_Unit_Ready() --------------------------------------------------
+/*
+ * MS_SCSI_Test_Unit_Ready()
+ */
 int MS_SCSI_Test_Unit_Ready(struct us_data *us, struct scsi_cmnd *srb)
 {
-       //printk("MS_SCSI_Test_Unit_Ready\n");
+       /* pr_info("MS_SCSI_Test_Unit_Ready\n"); */
        if (us->MS_Status.Insert && us->MS_Status.Ready)
                return USB_STOR_TRANSPORT_GOOD;
-       else
-       {
+       else {
                ENE_MSInit(us);
                return USB_STOR_TRANSPORT_GOOD;
        }
-               
+
        return USB_STOR_TRANSPORT_GOOD;
 }
 
-//----- MS_SCSI_Inquiry() --------------------------------------------------
+/*
+ * MS_SCSI_Inquiry()
+ */
 int MS_SCSI_Inquiry(struct us_data *us, struct scsi_cmnd *srb)
 {
-       //printk("MS_SCSI_Inquiry\n");
-       BYTE data_ptr[36] = {0x00, 0x80, 0x02, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x55, 0x53, 0x42, 0x32, 0x2E, 0x30, 0x20, 0x20, 0x43, 0x61, 0x72, 0x64, 0x52, 0x65, 0x61, 0x64, 0x65, 0x72, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x30, 0x31, 0x30, 0x30};
+       /* pr_info("MS_SCSI_Inquiry\n"); */
+       BYTE data_ptr[36] = {0x00, 0x80, 0x02, 0x00, 0x1F, 0x00,
+                               0x00, 0x00, 0x55, 0x53, 0x42, 0x32,
+                               0x2E, 0x30, 0x20, 0x20, 0x43, 0x61,
+                               0x72, 0x64, 0x52, 0x65, 0x61, 0x64,
+                               0x65, 0x72, 0x20, 0x20, 0x20, 0x20,
+                               0x20, 0x20, 0x30, 0x31, 0x30, 0x30};
 
        usb_stor_set_xfer_buf(us, data_ptr, 36, srb, TO_XFER_BUF);
        return USB_STOR_TRANSPORT_GOOD;
 }
 
-
-//----- MS_SCSI_Mode_Sense() --------------------------------------------------
+/*
+ * MS_SCSI_Mode_Sense()
+ */
 int MS_SCSI_Mode_Sense(struct us_data *us, struct scsi_cmnd *srb)
 {
-       BYTE    mediaNoWP[12] = {0x0b,0x00,0x00,0x08,0x00,0x00,0x71,0xc0,0x00,0x00,0x02,0x00};
-       BYTE    mediaWP[12]   = {0x0b,0x00,0x80,0x08,0x00,0x00,0x71,0xc0,0x00,0x00,0x02,0x00};
+       BYTE    mediaNoWP[12] = {0x0b, 0x00, 0x00, 0x08, 0x00, 0x00,
+                                       0x71, 0xc0, 0x00, 0x00, 0x02, 0x00};
+       BYTE    mediaWP[12]   = {0x0b, 0x00, 0x80, 0x08, 0x00, 0x00,
+                                       0x71, 0xc0, 0x00, 0x00, 0x02, 0x00};
 
        if (us->MS_Status.WtP)
                usb_stor_set_xfer_buf(us, mediaWP, 12, srb, TO_XFER_BUF);
@@ -82,7 +64,9 @@ int MS_SCSI_Mode_Sense(struct us_data *us, struct scsi_cmnd *srb)
        return USB_STOR_TRANSPORT_GOOD;
 }
 
-//----- MS_SCSI_Read_Capacity() --------------------------------------------------
+/*
+ * MS_SCSI_Read_Capacity()
+ */
 int MS_SCSI_Read_Capacity(struct us_data *us, struct scsi_cmnd *srb)
 {
        unsigned int offset = 0;
@@ -91,60 +75,65 @@ int MS_SCSI_Read_Capacity(struct us_data *us, struct scsi_cmnd *srb)
        WORD    bl_len;
        BYTE    buf[8];
 
-       printk("MS_SCSI_Read_Capacity\n");
+       pr_info("MS_SCSI_Read_Capacity\n");
 
        bl_len = 0x200;
-       if ( us->MS_Status.IsMSPro )
+       if (us->MS_Status.IsMSPro)
                bl_num = us->MSP_TotalBlock - 1;
        else
-               bl_num = us->MS_Lib.NumberOfLogBlock * us->MS_Lib.blockSize * 2 - 1;
+               bl_num = us->MS_Lib.NumberOfLogBlock *
+                               us->MS_Lib.blockSize * 2 - 1;
 
        us->bl_num = bl_num;
-       printk("bl_len = %x\n", bl_len);
-       printk("bl_num = %x\n", bl_num);
-
-       //srb->request_bufflen = 8;
-       buf[0] = (bl_num>>24) & 0xff;
-       buf[1] = (bl_num>>16) & 0xff;
-       buf[2] = (bl_num>> 8) & 0xff;
-       buf[3] = (bl_num>> 0) & 0xff;
-       buf[4] = (bl_len>>24) & 0xff;
-       buf[5] = (bl_len>>16) & 0xff;
-       buf[6] = (bl_len>> 8) & 0xff;
-       buf[7] = (bl_len>> 0) & 0xff;
-       
+       pr_info("bl_len = %x\n", bl_len);
+       pr_info("bl_num = %x\n", bl_num);
+
+       /* srb->request_bufflen = 8; */
+       buf[0] = (bl_num >> 24) & 0xff;
+       buf[1] = (bl_num >> 16) & 0xff;
+       buf[2] = (bl_num >> 8) & 0xff;
+       buf[3] = (bl_num >> 0) & 0xff;
+       buf[4] = (bl_len >> 24) & 0xff;
+       buf[5] = (bl_len >> 16) & 0xff;
+       buf[6] = (bl_len >> 8) & 0xff;
+       buf[7] = (bl_len >> 0) & 0xff;
+
        usb_stor_access_xfer_buf(us, buf, 8, srb, &sg, &offset, TO_XFER_BUF);
-       //usb_stor_set_xfer_buf(us, buf, srb->request_bufflen, srb, TO_XFER_BUF);
+       /* usb_stor_set_xfer_buf(us, buf, srb->request_bufflen,
+                                               srb, TO_XFER_BUF); */
 
        return USB_STOR_TRANSPORT_GOOD;
 }
 
-//----- MS_SCSI_Read() --------------------------------------------------
+/*
+ * MS_SCSI_Read()
+ */
 int MS_SCSI_Read(struct us_data *us, struct scsi_cmnd *srb)
 {
        struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
-       int result=0;
+       int result = 0;
        PBYTE   Cdb = srb->cmnd;
-       DWORD bn  =  ((Cdb[2]<<24) & 0xff000000) | ((Cdb[3]<<16) & 0x00ff0000) |
-                   ((Cdb[4]<< 8) & 0x0000ff00) | ((Cdb[5]<< 0) & 0x000000ff);
-       WORD  blen = ((Cdb[7]<< 8) & 0xff00)     | ((Cdb[8]<< 0) & 0x00ff);
+       DWORD bn  =  ((Cdb[2] << 24) & 0xff000000) |
+                       ((Cdb[3] << 16) & 0x00ff0000) |
+                       ((Cdb[4] << 8) & 0x0000ff00) |
+                       ((Cdb[5] << 0) & 0x000000ff);
+       WORD  blen = ((Cdb[7] << 8) & 0xff00) | ((Cdb[8] << 0) & 0x00ff);
        DWORD   blenByte = blen * 0x200;
 
-       //printk("SCSIOP_READ --- bn = %X, blen = %X, srb->use_sg = %X\n", bn, blen, srb->use_sg);
-       
+       /* pr_info("SCSIOP_READ --- bn = %X, blen = %X, srb->use_sg = %X\n",
+                                               bn, blen, srb->use_sg); */
+
        if (bn > us->bl_num)
                return USB_STOR_TRANSPORT_ERROR;
 
-       if (us->MS_Status.IsMSPro)
-       {
+       if (us->MS_Status.IsMSPro) {
                result = ENE_LoadBinCode(us, MSP_RW_PATTERN);
-               if (result != USB_STOR_XFER_GOOD)
-               {
-                       printk("Load MSP RW pattern Fail !!\n");
+               if (result != USB_STOR_XFER_GOOD) {
+                       pr_info("Load MSP RW pattern Fail !!\n");
                        return USB_STOR_TRANSPORT_ERROR;
                }
 
-               // set up the command wrapper
+               /*  set up the command wrapper */
                memset(bcb, 0, sizeof(struct bulk_cb_wrap));
                bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
                bcb->DataTransferLength = blenByte;
@@ -157,11 +146,9 @@ int MS_SCSI_Read(struct us_data *us, struct scsi_cmnd *srb)
                bcb->CDB[2] = (BYTE)(bn>>24);
 
                result = ENE_SendScsiCmd(us, FDIR_READ, scsi_sglist(srb), 1);
-       }
-       else
-       {
+       } else {
                void    *buf;
-               int     offset=0;
+               int     offset = 0;
                WORD    phyblk, logblk;
                BYTE    PageNum;
                WORD    len;
@@ -172,9 +159,8 @@ int MS_SCSI_Read(struct us_data *us, struct scsi_cmnd *srb)
                        return USB_STOR_TRANSPORT_ERROR;
 
                result = ENE_LoadBinCode(us, MS_RW_PATTERN);
-               if (result != USB_STOR_XFER_GOOD)
-               {
-                       printk("Load MS RW pattern Fail !!\n");
+               if (result != USB_STOR_XFER_GOOD) {
+                       pr_info("Load MS RW pattern Fail !!\n");
                        result = USB_STOR_TRANSPORT_ERROR;
                        goto exit;
                }
@@ -182,9 +168,8 @@ int MS_SCSI_Read(struct us_data *us, struct scsi_cmnd *srb)
                logblk  = (WORD)(bn / us->MS_Lib.PagesPerBlock);
                PageNum = (BYTE)(bn % us->MS_Lib.PagesPerBlock);
 
-               while(1)
-               {
-                       if (blen > (us->MS_Lib.PagesPerBlock-PageNum) )
+               while (1) {
+                       if (blen > (us->MS_Lib.PagesPerBlock-PageNum))
                                len = us->MS_Lib.PagesPerBlock-PageNum;
                        else
                                len = blen;
@@ -192,7 +177,7 @@ int MS_SCSI_Read(struct us_data *us, struct scsi_cmnd *srb)
                        phyblk = MS_LibConv2Physical(us, logblk);
                        blkno  = phyblk * 0x20 + PageNum;
 
-                       // set up the command wrapper
+                       /* set up the command wrapper */
                        memset(bcb, 0, sizeof(struct bulk_cb_wrap));
                        bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
                        bcb->DataTransferLength = 0x200 * len;
@@ -205,15 +190,15 @@ int MS_SCSI_Read(struct us_data *us, struct scsi_cmnd *srb)
                        bcb->CDB[2] = (BYTE)(blkno>>24);
 
                        result = ENE_SendScsiCmd(us, FDIR_READ, buf+offset, 0);
-                       if (result != USB_STOR_XFER_GOOD)
-                       {
-                               printk("MS_SCSI_Read --- result = %x\n", result);
+                       if (result != USB_STOR_XFER_GOOD) {
+                               pr_info("MS_SCSI_Read --- result = %x\n",
+                                                               result);
                                result =  USB_STOR_TRANSPORT_ERROR;
                                goto exit;
                        }
 
                        blen -= len;
-                       if (blen<=0)
+                       if (blen <= 0)
                                break;
                        logblk++;
                        PageNum = 0;
@@ -226,30 +211,32 @@ exit:
        return result;
 }
 
-//----- MS_SCSI_Write() --------------------------------------------------
+/*
+ * MS_SCSI_Write()
+ */
 int MS_SCSI_Write(struct us_data *us, struct scsi_cmnd *srb)
 {
        struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
-       int result=0;
+       int result = 0;
        PBYTE   Cdb = srb->cmnd;
-       DWORD bn  =  ((Cdb[2]<<24) & 0xff000000) | ((Cdb[3]<<16) & 0x00ff0000) |
-                   ((Cdb[4]<< 8) & 0x0000ff00) | ((Cdb[5]<< 0) & 0x000000ff);
-       WORD  blen = ((Cdb[7]<< 8) & 0xff00)     | ((Cdb[8]<< 0) & 0x00ff);
+       DWORD bn  = ((Cdb[2] << 24) & 0xff000000) |
+                       ((Cdb[3] << 16) & 0x00ff0000) |
+                       ((Cdb[4] << 8) & 0x0000ff00) |
+                       ((Cdb[5] << 0) & 0x000000ff);
+       WORD  blen = ((Cdb[7] << 8) & 0xff00)     | ((Cdb[8] << 0) & 0x00ff);
        DWORD   blenByte = blen * 0x200;
 
        if (bn > us->bl_num)
                return USB_STOR_TRANSPORT_ERROR;
 
-       if (us->MS_Status.IsMSPro)
-       {
+       if (us->MS_Status.IsMSPro) {
                result = ENE_LoadBinCode(us, MSP_RW_PATTERN);
-               if (result != USB_STOR_XFER_GOOD)
-               {
-                       printk("Load MSP RW pattern Fail !!\n");
+               if (result != USB_STOR_XFER_GOOD) {
+                       pr_info("Load MSP RW pattern Fail !!\n");
                        return USB_STOR_TRANSPORT_ERROR;
                }
 
-               // set up the command wrapper
+               /* set up the command wrapper */
                memset(bcb, 0, sizeof(struct bulk_cb_wrap));
                bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
                bcb->DataTransferLength = blenByte;
@@ -262,11 +249,9 @@ int MS_SCSI_Write(struct us_data *us, struct scsi_cmnd *srb)
                bcb->CDB[2] = (BYTE)(bn>>24);
 
                result = ENE_SendScsiCmd(us, FDIR_WRITE, scsi_sglist(srb), 1);
-       }
-       else
-       {
+       } else {
                void    *buf;
-               int     offset=0;
+               int     offset = 0;
                WORD    PhyBlockAddr;
                BYTE    PageNum;
                DWORD   result;
@@ -278,9 +263,8 @@ int MS_SCSI_Write(struct us_data *us, struct scsi_cmnd *srb)
                usb_stor_set_xfer_buf(us, buf, blenByte, srb, FROM_XFER_BUF);
 
                result = ENE_LoadBinCode(us, MS_RW_PATTERN);
-               if (result != USB_STOR_XFER_GOOD)
-               {
-                       printk("Load MS RW pattern Fail !!\n");
+               if (result != USB_STOR_XFER_GOOD) {
+                       pr_info("Load MS RW pattern Fail !!\n");
                        result = USB_STOR_TRANSPORT_ERROR;
                        goto exit;
                }
@@ -288,9 +272,8 @@ int MS_SCSI_Write(struct us_data *us, struct scsi_cmnd *srb)
                PhyBlockAddr = (WORD)(bn / us->MS_Lib.PagesPerBlock);
                PageNum      = (BYTE)(bn % us->MS_Lib.PagesPerBlock);
 
-               while(1)
-               {
-                       if (blen > (us->MS_Lib.PagesPerBlock-PageNum) )
+               while (1) {
+                       if (blen > (us->MS_Lib.PagesPerBlock-PageNum))
                                len = us->MS_Lib.PagesPerBlock-PageNum;
                        else
                                len = blen;
@@ -298,10 +281,12 @@ int MS_SCSI_Write(struct us_data *us, struct scsi_cmnd *srb)
                        oldphy = MS_LibConv2Physical(us, PhyBlockAddr);
                        newphy = MS_LibSearchBlockFromLogical(us, PhyBlockAddr);
 
-                       result = MS_ReaderCopyBlock(us, oldphy, newphy, PhyBlockAddr, PageNum, buf+offset, len);
-                       if (result != USB_STOR_XFER_GOOD)
-                       {
-                               printk("MS_SCSI_Write --- result = %x\n", result);
+                       result = MS_ReaderCopyBlock(us, oldphy, newphy,
+                                                       PhyBlockAddr, PageNum,
+                                                       buf+offset, len);
+                       if (result != USB_STOR_XFER_GOOD) {
+                               pr_info("MS_SCSI_Write --- result = %x\n",
+                                                               result);
                                result =  USB_STOR_TRANSPORT_ERROR;
                                goto exit;
                        }
@@ -310,7 +295,7 @@ int MS_SCSI_Write(struct us_data *us, struct scsi_cmnd *srb)
                        MS_LibForceSetLogicalPair(us, PhyBlockAddr, newphy);
 
                        blen -= len;
-                       if (blen<=0)
+                       if (blen <= 0)
                                break;
                        PhyBlockAddr++;
                        PageNum = 0;
@@ -322,3 +307,38 @@ exit:
        return result;
 }
 
+/*
+ * MS_SCSIIrp()
+ */
+int MS_SCSIIrp(struct us_data *us, struct scsi_cmnd *srb)
+{
+       int    result;
+
+       us->SrbStatus = SS_SUCCESS;
+       switch (srb->cmnd[0]) {
+       case TEST_UNIT_READY:
+               result = MS_SCSI_Test_Unit_Ready(us, srb);
+               break; /* 0x00 */
+       case INQUIRY:
+               result = MS_SCSI_Inquiry(us, srb);
+               break; /* 0x12 */
+       case MODE_SENSE:
+               result = MS_SCSI_Mode_Sense(us, srb);
+               break; /* 0x1A */
+       case READ_CAPACITY:
+               result = MS_SCSI_Read_Capacity(us, srb);
+               break; /* 0x25 */
+       case READ_10:
+               result = MS_SCSI_Read(us, srb);
+               break; /* 0x28 */
+       case WRITE_10:
+               result = MS_SCSI_Write(us, srb);
+               break;  /* 0x2A */
+       default:
+               us->SrbStatus = SS_ILLEGAL_REQUEST;
+               result = USB_STOR_TRANSPORT_FAILED;
+               break;
+       }
+       return result;
+}
+
index da4f42af3838eb209e7545128b74d0aaedcebe7b..135f7f21dfde13a4d345e0f868dbeac943a3a3a9 100644 (file)
@@ -1,3 +1,5 @@
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/mutex.h>
 #include "transport.h"
 
 /* Host functions */
-//----- host_info() ---------------------
-static const char* host_info(struct Scsi_Host *host)
+/*
+ * host_info()
+ */
+static const char *host_info(struct Scsi_Host *host)
 {
-       //printk("scsiglue --- host_info\n");
+       /* pr_info("scsiglue --- host_info\n"); */
        return "SCSI emulation for USB Mass Storage devices";
 }
 
-//----- slave_alloc() ---------------------
+/*
+ * slave_alloc()
+ */
 static int slave_alloc(struct scsi_device *sdev)
 {
        struct us_data *us = host_to_us(sdev->host);
 
-       //printk("scsiglue --- slave_alloc\n");
+       /* pr_info("scsiglue --- slave_alloc\n"); */
        sdev->inquiry_len = 36;
 
        blk_queue_update_dma_alignment(sdev->request_queue, (512 - 1));
@@ -36,14 +42,15 @@ static int slave_alloc(struct scsi_device *sdev)
        return 0;
 }
 
-//----- slave_configure() ---------------------
+/*
+ * slave_configure()
+ */
 static int slave_configure(struct scsi_device *sdev)
 {
        struct us_data *us = host_to_us(sdev->host);
 
-       //printk("scsiglue --- slave_configure\n");
-       if (us->fflags & (US_FL_MAX_SECTORS_64 | US_FL_MAX_SECTORS_MIN))
-       {
+       /* pr_info("scsiglue --- slave_configure\n"); */
+       if (us->fflags & (US_FL_MAX_SECTORS_64 | US_FL_MAX_SECTORS_MIN)) {
                unsigned int max_sectors = 64;
 
                if (us->fflags & US_FL_MAX_SECTORS_MIN)
@@ -53,9 +60,9 @@ static int slave_configure(struct scsi_device *sdev)
                                              max_sectors);
        }
 
-       if (sdev->type == TYPE_DISK)
-       {
-               if (us->subclass != USB_SC_SCSI && us->subclass != USB_SC_CYP_ATACB)
+       if (sdev->type == TYPE_DISK) {
+               if (us->subclass != USB_SC_SCSI &&
+                       us->subclass != USB_SC_CYP_ATACB)
                        sdev->use_10_for_ms = 1;
                sdev->use_192_bytes_for_3f = 1;
                if (us->fflags & US_FL_NO_WP_DETECT)
@@ -70,13 +77,12 @@ static int slave_configure(struct scsi_device *sdev)
                sdev->retry_hwerror = 1;
                sdev->allow_restart = 1;
                sdev->last_sector_bug = 1;
-       }
-       else
-       {
+       } else {
                sdev->use_10_for_ms = 1;
        }
 
-       if ((us->protocol == USB_PR_CB || us->protocol == USB_PR_CBI) && sdev->scsi_level == SCSI_UNKNOWN)
+       if ((us->protocol == USB_PR_CB || us->protocol == USB_PR_CBI) &&
+                                       sdev->scsi_level == SCSI_UNKNOWN)
                us->max_lun = 0;
 
        if (us->fflags & US_FL_NOT_LOCKABLE)
@@ -86,24 +92,26 @@ static int slave_configure(struct scsi_device *sdev)
 }
 
 /* This is always called with scsi_lock(host) held */
-//----- queuecommand() ---------------------
-static int queuecommand_lck(struct scsi_cmnd *srb, void (*done)(struct scsi_cmnd *))
+/*
+ * queuecommand()
+ */
+static int queuecommand_lck(struct scsi_cmnd *srb,
+                               void (*done)(struct scsi_cmnd *))
 {
        struct us_data *us = host_to_us(srb->device->host);
 
-       //printk("scsiglue --- queuecommand\n");
+       /* pr_info("scsiglue --- queuecommand\n"); */
 
        /* check for state-transition errors */
-       if (us->srb != NULL)
-       {
-               printk("Error in %s: us->srb = %p\n", __FUNCTION__, us->srb);
+       if (us->srb != NULL) {
+               /* pr_info("Error in %s: us->srb = %p\n"
+                                __FUNCTION__, us->srb); */
                return SCSI_MLQUEUE_HOST_BUSY;
        }
 
        /* fail the command if we are disconnecting */
-       if (test_bit(US_FLIDX_DISCONNECTING, &us->dflags))
-       {
-               printk("Fail command during disconnect\n");
+       if (test_bit(US_FLIDX_DISCONNECTING, &us->dflags)) {
+               pr_info("Fail command during disconnect\n");
                srb->result = DID_NO_CONNECT << 16;
                done(srb);
                return 0;
@@ -124,24 +132,24 @@ static DEF_SCSI_QCMD(queuecommand)
  ***********************************************************************/
 
 /* Command timeout and abort */
-//----- command_abort() ---------------------
+/*
+ * command_abort()
+ */
 static int command_abort(struct scsi_cmnd *srb)
 {
        struct us_data *us = host_to_us(srb->device->host);
 
-       //printk("scsiglue --- command_abort\n");
+       /* pr_info("scsiglue --- command_abort\n"); */
 
        scsi_lock(us_to_host(us));
-       if (us->srb != srb)
-       {
+       if (us->srb != srb) {
                scsi_unlock(us_to_host(us));
                printk ("-- nothing to abort\n");
                return FAILED;
        }
 
        set_bit(US_FLIDX_TIMED_OUT, &us->dflags);
-       if (!test_bit(US_FLIDX_RESETTING, &us->dflags))
-       {
+       if (!test_bit(US_FLIDX_RESETTING, &us->dflags)) {
                set_bit(US_FLIDX_ABORTING, &us->dflags);
                usb_stor_stop_transport(us);
        }
@@ -152,14 +160,18 @@ static int command_abort(struct scsi_cmnd *srb)
        return SUCCESS;
 }
 
-/* This invokes the transport reset mechanism to reset the state of the device */
-//----- device_reset() ---------------------
+/* This invokes the transport reset mechanism to reset the state of the
+ * device.
+ */
+/*
+ * device_reset()
+ */
 static int device_reset(struct scsi_cmnd *srb)
 {
        struct us_data *us = host_to_us(srb->device->host);
        int result;
 
-       //printk("scsiglue --- device_reset\n");
+       /* pr_info("scsiglue --- device_reset\n"); */
 
        /* lock the device pointers and do the reset */
        mutex_lock(&(us->dev_mutex));
@@ -169,38 +181,43 @@ static int device_reset(struct scsi_cmnd *srb)
        return result < 0 ? FAILED : SUCCESS;
 }
 
-//----- bus_reset() ---------------------
+/*
+ * bus_reset()
+ */
 static int bus_reset(struct scsi_cmnd *srb)
 {
        struct us_data *us = host_to_us(srb->device->host);
        int result;
 
-       //printk("scsiglue --- bus_reset\n");
+       /* pr_info("scsiglue --- bus_reset\n"); */
        result = usb_stor_port_reset(us);
        return result < 0 ? FAILED : SUCCESS;
 }
 
-//----- usb_stor_report_device_reset() ---------------------
+/*
+ * usb_stor_report_device_reset()
+ */
 void usb_stor_report_device_reset(struct us_data *us)
 {
        int i;
        struct Scsi_Host *host = us_to_host(us);
 
-       //printk("scsiglue --- usb_stor_report_device_reset\n");
+       /* pr_info("scsiglue --- usb_stor_report_device_reset\n"); */
        scsi_report_device_reset(host, 0, 0);
-       if (us->fflags & US_FL_SCM_MULT_TARG)
-       {
+       if (us->fflags & US_FL_SCM_MULT_TARG) {
                for (i = 1; i < host->max_id; ++i)
                        scsi_report_device_reset(host, 0, i);
        }
 }
 
-//----- usb_stor_report_bus_reset() ---------------------
+/*
+ * usb_stor_report_bus_reset()
+ */
 void usb_stor_report_bus_reset(struct us_data *us)
 {
        struct Scsi_Host *host = us_to_host(us);
 
-       //printk("scsiglue --- usb_stor_report_bus_reset\n");
+       /* pr_info("scsiglue --- usb_stor_report_bus_reset\n"); */
        scsi_lock(host);
        scsi_report_bus_reset(host, 0);
        scsi_unlock(host);
@@ -215,14 +232,17 @@ void usb_stor_report_bus_reset(struct us_data *us)
 #define SPRINTF(args...) \
        do { if (pos < buffer+length) pos += sprintf(pos, ## args); } while (0)
 
-//----- proc_info() ---------------------
-static int proc_info (struct Scsi_Host *host, char *buffer, char **start, off_t offset, int length, int inout)
+/*
+ * proc_info()
+ */
+static int proc_info(struct Scsi_Host *host, char *buffer, char **start,
+                                       off_t offset, int length, int inout)
 {
        struct us_data *us = host_to_us(host);
        char *pos = buffer;
        const char *string;
 
-       //printk("scsiglue --- proc_info\n");
+       /* pr_info("scsiglue --- proc_info\n"); */
        if (inout)
                return length;
 
@@ -255,8 +275,7 @@ static int proc_info (struct Scsi_Host *host, char *buffer, char **start, off_t
        SPRINTF("    Transport: %s\n", us->transport_name);
 
        /* show the device flags */
-       if (pos < buffer + length)
-       {
+       if (pos < buffer + length) {
                pos += sprintf(pos, "       Quirks:");
 
 #define US_FLAG(name, value) \
@@ -271,11 +290,11 @@ US_DO_ALL_FLAGS
        *start = buffer + offset;
 
        if ((pos - buffer) < offset)
-               return (0);
+               return 0;
        else if ((pos - buffer - offset) < length)
-               return (pos - buffer - offset);
+               return pos - buffer - offset;
        else
-               return (length);
+               return length;
 }
 
 /***********************************************************************
@@ -283,29 +302,35 @@ US_DO_ALL_FLAGS
  ***********************************************************************/
 
 /* Output routine for the sysfs max_sectors file */
-//----- show_max_sectors() ---------------------
-static ssize_t show_max_sectors(struct device *dev, struct device_attribute *attr, char *buf)
+/*
+ * show_max_sectors()
+ */
+static ssize_t show_max_sectors(struct device *dev,
+                               struct device_attribute *attr, char *buf)
 {
        struct scsi_device *sdev = to_scsi_device(dev);
 
-       //printk("scsiglue --- ssize_t show_max_sectors\n");
+       /* pr_info("scsiglue --- ssize_t show_max_sectors\n"); */
        return sprintf(buf, "%u\n", queue_max_sectors(sdev->request_queue));
 }
 
 /* Input routine for the sysfs max_sectors file */
-//----- store_max_sectors() ---------------------
-static ssize_t store_max_sectors(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
+/*
+ * store_max_sectors()
+ */
+static ssize_t store_max_sectors(struct device *dev,
+                               struct device_attribute *attr,
+                               const char *buf, size_t count)
 {
        struct scsi_device *sdev = to_scsi_device(dev);
        unsigned short ms;
 
-       //printk("scsiglue --- ssize_t store_max_sectors\n");
-       if (sscanf(buf, "%hu", &ms) > 0 && ms <= SCSI_DEFAULT_MAX_SECTORS)
-       {
+       /* pr_info("scsiglue --- ssize_t store_max_sectors\n"); */
+       if (sscanf(buf, "%hu", &ms) > 0 && ms <= SCSI_DEFAULT_MAX_SECTORS) {
                blk_queue_max_hw_sectors(sdev->request_queue, ms);
                return strlen(buf);
        }
-       return -EINVAL; 
+       return -EINVAL;
 }
 
 static DEVICE_ATTR(max_sectors, S_IRUGO | S_IWUSR, show_max_sectors, store_max_sectors);
@@ -313,7 +338,9 @@ static struct device_attribute *sysfs_device_attr_list[] = {&dev_attr_max_sector
 
 /* this defines our host template, with which we'll allocate hosts */
 
-//----- usb_stor_host_template() ---------------------
+/*
+ * usb_stor_host_template()
+ */
 struct scsi_host_template usb_stor_host_template = {
        /* basic userland interface stuff */
        .name =                         "eucr-storage",
@@ -376,42 +403,41 @@ unsigned char usb_stor_sense_invalidCDB[18] = {
  * Scatter-gather transfer buffer access routines
  ***********************************************************************/
 
-//----- usb_stor_access_xfer_buf() ---------------------
+/*
+ * usb_stor_access_xfer_buf()
+ */
 unsigned int usb_stor_access_xfer_buf(struct us_data *us, unsigned char *buffer,
        unsigned int buflen, struct scsi_cmnd *srb, struct scatterlist **sgptr,
        unsigned int *offset, enum xfer_buf_dir dir)
 {
        unsigned int cnt;
 
-       //printk("transport --- usb_stor_access_xfer_buf\n");
+       /* pr_info("transport --- usb_stor_access_xfer_buf\n"); */
        struct scatterlist *sg = *sgptr;
 
        if (!sg)
                sg = scsi_sglist(srb);
 
        cnt = 0;
-       while (cnt < buflen && sg)
-       {
-               struct page *page = sg_page(sg) + ((sg->offset + *offset) >> PAGE_SHIFT);
+       while (cnt < buflen && sg) {
+               struct page *page = sg_page(sg) +
+                                       ((sg->offset + *offset) >> PAGE_SHIFT);
                unsigned int poff = (sg->offset + *offset) & (PAGE_SIZE-1);
                unsigned int sglen = sg->length - *offset;
 
-               if (sglen > buflen - cnt)
-               {
+               if (sglen > buflen - cnt) {
                        /* Transfer ends within this s-g entry */
                        sglen = buflen - cnt;
                        *offset += sglen;
-               }
-               else
-               {
+               } else {
                        /* Transfer continues to next s-g entry */
                        *offset = 0;
                        sg = sg_next(sg);
                }
 
-               while (sglen > 0)
-               {
-                       unsigned int plen = min(sglen, (unsigned int)PAGE_SIZE - poff);
+               while (sglen > 0) {
+                       unsigned int plen = min(sglen,
+                                               (unsigned int)PAGE_SIZE - poff);
                        unsigned char *ptr = kmap(page);
 
                        if (dir == TO_XFER_BUF)
@@ -433,18 +459,24 @@ unsigned int usb_stor_access_xfer_buf(struct us_data *us, unsigned char *buffer,
        return cnt;
 }
 
-/* Store the contents of buffer into srb's transfer buffer and set the SCSI residue. */
-//----- usb_stor_set_xfer_buf() ---------------------
-void usb_stor_set_xfer_buf(struct us_data *us, unsigned char *buffer, unsigned int buflen, struct scsi_cmnd *srb,
-       unsigned int dir)
+/*
+ * Store the contents of buffer into srb's transfer
+ * buffer and set the SCSI residue.
+ */
+/*
+ * usb_stor_set_xfer_buf()
+ */
+void usb_stor_set_xfer_buf(struct us_data *us, unsigned char *buffer,
+               unsigned int buflen, struct scsi_cmnd *srb, unsigned int dir)
 {
        unsigned int offset = 0;
        struct scatterlist *sg = NULL;
 
-       //printk("transport --- usb_stor_set_xfer_buf\n");
-       // TO_XFER_BUF = 0, FROM_XFER_BUF = 1
+       /* pr_info("transport --- usb_stor_set_xfer_buf\n"); */
+       /* TO_XFER_BUF = 0, FROM_XFER_BUF = 1 */
        buflen = min(buflen, scsi_bufflen(srb));
-       buflen = usb_stor_access_xfer_buf(us, buffer, buflen, srb, &sg, &offset, dir);
+       buflen = usb_stor_access_xfer_buf(us, buffer, buflen, srb,
+                                               &sg, &offset, dir);
        if (buflen < scsi_bufflen(srb))
                scsi_set_resid(srb, scsi_bufflen(srb) - buflen);
 }
index 00064cabf4ed5841688ec1beb5271fcb060cb71f..278bdb8711294ecde52faf55efd2a330025781ec 100644 (file)
@@ -6,7 +6,7 @@
 /***************************************************************************
 Define Difinetion
 ***************************************************************************/
-#define SUCCESS             0x0000 /* SUCCESS */
+#define SMSUCCESS           0x0000 /* SUCCESS */
 #define ERROR               0xFFFF /* ERROR */
 #define CORRECT             0x0001 /* CORRECTABLE */
 
index 4226813ba588f46fb5086d7baadbb2852e1080f4..b5a8fa7c7989d40d6bc83cb83a76e86cf4523ec4 100644 (file)
@@ -44,21 +44,22 @@ Retry Counter Definition
 /***************************************************************************
 Hardware ECC Definition
 ***************************************************************************/
-#define HW_ECC_SUPPORTED    1      /* Hardware ECC Supported */  /* No difinition for Software ECC */
+#define HW_ECC_SUPPORTED    1     /* Hardware ECC Supported */
+/* No difinition for Software ECC */
 
 /***************************************************************************
 SmartMedia Command & Status Definition
 ***************************************************************************/
 /* SmartMedia Command */
 #define WRDATA        0x80
-//#define READ          0x00
+/* #define READ          0x00 */
 #define READ_REDT     0x50
-//#define WRITE         0x10
+/* #define WRITE         0x10 */
 #define RDSTATUS      0x70
 
-#define READ1         0x00 //NO
-#define READ2         0x01 //NO
-#define READ3         0x50 //NO
+#define READ1         0x00 /* NO */
+#define READ2         0x01 /* NO */
+#define READ3         0x50 /* NO */
 #define RST_CHIP      0xFF
 #define ERASE1        0x60
 #define ERASE2        0xD0
@@ -67,19 +68,19 @@ SmartMedia Command & Status Definition
 #define READ_ID_3     0x9A
 
 /* 712 SmartMedia Command */
-#define SM_CMD_RESET                0x00    // 0xFF
-#define SM_CMD_READ_ID_1            0x10    // 0x90
-#define SM_CMD_READ_ID_2            0x20    // 0x91
-#define SM_CMD_READ_STAT            0x30    // 0x70
-#define SM_CMD_RDMULTPL_STAT        0x40    // 0x71
-#define SM_CMD_READ_1               0x50    // 0x00
-#define SM_CMD_READ_2               0x60    // 0x01
-#define SM_CMD_READ_3               0x70    // 0x50
-#define SM_CMD_PAGPRGM_TRUE         0x80    // {0x80, 0x10}
-#define SM_CMD_PAGPRGM_DUMY         0x90    // {0x80, 0x11}
-#define SM_CMD_PAGPRGM_MBLK         0xA0    // {0x80, 0x15}
-#define SM_CMD_BLKERASE             0xB0    // {0x60, 0xD0}
-#define SM_CMD_BLKERASE_MULTPL      0xC0    // {0x60-0x60, 0xD0}
+#define SM_CMD_RESET                0x00    /* 0xFF */
+#define SM_CMD_READ_ID_1            0x10    /* 0x90 */
+#define SM_CMD_READ_ID_2            0x20    /* 0x91 */
+#define SM_CMD_READ_STAT            0x30    /* 0x70 */
+#define SM_CMD_RDMULTPL_STAT        0x40    /* 0x71 */
+#define SM_CMD_READ_1               0x50    /* 0x00 */
+#define SM_CMD_READ_2               0x60    /* 0x01 */
+#define SM_CMD_READ_3               0x70    /* 0x50 */
+#define SM_CMD_PAGPRGM_TRUE         0x80    /* {0x80, 0x10} */
+#define SM_CMD_PAGPRGM_DUMY         0x90    /* {0x80, 0x11} */
+#define SM_CMD_PAGPRGM_MBLK         0xA0    /* {0x80, 0x15} */
+#define SM_CMD_BLKERASE             0xB0    /* {0x60, 0xD0} */
+#define SM_CMD_BLKERASE_MULTPL      0xC0    /* {0x60-0x60, 0xD0} */
 
 #define SM_CRADDTCT_DEBNCETIMER_EN  0x02
 #define SM_CMD_START_BIT            0x01
@@ -87,27 +88,31 @@ SmartMedia Command & Status Definition
 #define SM_WaitCmdDone { while (!SM_CmdDone); }
 #define SM_WaitDmaDone { while (!SM_DmaDone); }
 
-// SmartMedia Status
-#define WR_FAIL       0x01      // 0:Pass, 1:Fail
-#define SUSPENDED     0x20      // 0:Not Suspended, 1:Suspended
-#define READY         0x40      // 0:Busy, 1:Ready
-#define WR_PRTCT      0x80      // 0:Protect, 1:Not Protect
-
-// SmartMedia Busy Time (1bit:0.1ms)
-#define BUSY_PROG     200       // tPROG   : 20ms  ----- Program Time          old : 200
-#define BUSY_ERASE    4000      // tBERASE : 400ms ----- Block Erase Time      old : 4000
-//for 712 Test
-//#define BUSY_READ     1         // tR      : 100us ----- Data transfer Time   old : 1
-//#define BUSY_READ     10         // tR      : 100us ----- Data transfer Time   old : 1
-#define BUSY_READ     200       // tR      : 20ms   ----- Data transfer Time   old : 1
-//#define BUSY_RESET    60        // tRST    : 6ms   ----- Device Resetting Time old : 60
-#define BUSY_RESET    600        // tRST    : 60ms   ----- Device Resetting Time old : 60
-
-// Hardware Timer (1bit:0.1ms)
-#define TIME_PON      3000      // 300ms ------ Power On Wait Time
-#define TIME_CDCHK    200       // 20ms  ------ Card Check Interval Timer
-#define TIME_WPCHK    50        // 5ms   ------ WP Check Interval Timer
-#define TIME_5VCHK    10        // 1ms   ------ 5V Check Interval Timer
+/* SmartMedia Status */
+#define WR_FAIL       0x01      /* 0:Pass, 1:Fail */
+#define SUSPENDED     0x20      /* 0:Not Suspended, 1:Suspended */
+#define READY         0x40      /* 0:Busy, 1:Ready */
+#define WR_PRTCT      0x80      /* 0:Protect, 1:Not Protect */
+
+/* SmartMedia Busy Time (1bit:0.1ms) */
+#define BUSY_PROG 200 /* tPROG   : 20ms  ----- Program Time old : 200 */
+#define BUSY_ERASE 4000 /* tBERASE : 400ms ----- Block Erase Time old : 4000 */
+
+/*for 712 Test */
+/* #define BUSY_READ 1 *//* tR : 100us ----- Data transfer Time   old : 1 */
+/* #define BUSY_READ 10 *//* tR : 100us ----- Data transfer Time   old : 1 */
+
+#define BUSY_READ 200 /* tR : 20ms   ----- Data transfer Time   old : 1 */
+
+/* #define BUSY_RESET 60 *//* tRST : 6ms ----- Device Resetting Time old : 60 */
+
+#define BUSY_RESET 600 /* tRST : 60ms   ----- Device Resetting Time old : 60 */
+
+/* Hardware Timer (1bit:0.1ms) */
+#define TIME_PON      3000      /* 300ms ------ Power On Wait Time */
+#define TIME_CDCHK    200       /* 20ms  ------ Card Check Interval Timer */
+#define TIME_WPCHK    50        /* 5ms   ------ WP Check Interval Timer */
+#define TIME_5VCHK    10        /* 1ms   ------ 5V Check Interval Timer */
 
 /***************************************************************************
 Redundant Data
@@ -129,32 +134,32 @@ Redundant Data
 SmartMedia Model & Attribute
 ***************************************************************************/
 /* SmartMedia Attribute */
-#define NOWP          0x00 // 0... .... No Write Protect
-#define WP            0x80 // 1... .... Write Protected
-#define MASK          0x00 // .00. .... NAND MASK ROM Model
-#define FLASH         0x20 // .01. .... NAND Flash ROM Model
-#define AD3CYC        0x00 // ...0 .... Address 3-cycle
-#define AD4CYC        0x10 // ...1 .... Address 4-cycle
-#define BS16          0x00 // .... 00.. 16page/block
-#define BS32          0x04 // .... 01.. 32page/block
-#define PS256         0x00 // .... ..00 256byte/page
-#define PS512         0x01 // .... ..01 512byte/page
-#define MWP           0x80 // WriteProtect mask
-#define MFLASH        0x60 // Flash Rom mask
-#define MADC          0x10 // Address Cycle
-#define MBS           0x0C // BlockSize mask
-#define MPS           0x03 // PageSize mask
+#define NOWP          0x00 /* 0... .... No Write Protect */
+#define WP            0x80 /* 1... .... Write Protected */
+#define MASK          0x00 /* .00. .... NAND MASK ROM Model */
+#define FLASH         0x20 /* .01. .... NAND Flash ROM Model */
+#define AD3CYC        0x00 /* ...0 .... Address 3-cycle */
+#define AD4CYC        0x10 /* ...1 .... Address 4-cycle */
+#define BS16          0x00 /* .... 00.. 16page/block */
+#define BS32          0x04 /* .... 01.. 32page/block */
+#define PS256         0x00 /* .... ..00 256byte/page */
+#define PS512         0x01 /* .... ..01 512byte/page */
+#define MWP           0x80 /* WriteProtect mask */
+#define MFLASH        0x60 /* Flash Rom mask */
+#define MADC          0x10 /* Address Cycle */
+#define MBS           0x0C /* BlockSize mask */
+#define MPS           0x03 /* PageSize mask */
 
 /* SmartMedia Model */
-#define NOSSFDC       0x00 // NO   SmartMedia
-#define SSFDC1MB      0x01 // 1MB  SmartMedia
-#define SSFDC2MB      0x02 // 2MB  SmartMedia
-#define SSFDC4MB      0x03 // 4MB  SmartMedia
-#define SSFDC8MB      0x04 // 8MB  SmartMedia
-#define SSFDC16MB     0x05 // 16MB SmartMedia
-#define SSFDC32MB     0x06 // 32MB SmartMedia
-#define SSFDC64MB     0x07 // 64MB SmartMedia
-#define SSFDC128MB    0x08 //128MB SmartMedia
+#define NOSSFDC       0x00 /* NO   SmartMedia */
+#define SSFDC1MB      0x01 /* 1MB  SmartMedia */
+#define SSFDC2MB      0x02 /* 2MB  SmartMedia */
+#define SSFDC4MB      0x03 /* 4MB  SmartMedia */
+#define SSFDC8MB      0x04 /* 8MB  SmartMedia */
+#define SSFDC16MB     0x05 /* 16MB SmartMedia */
+#define SSFDC32MB     0x06 /* 32MB SmartMedia */
+#define SSFDC64MB     0x07 /* 64MB SmartMedia */
+#define SSFDC128MB    0x08 /*128MB SmartMedia */
 #define SSFDC256MB    0x09
 #define SSFDC512MB    0x0A
 #define SSFDC1GB      0x0B
@@ -163,8 +168,7 @@ SmartMedia Model & Attribute
 /***************************************************************************
 Struct Definition
 ***************************************************************************/
-struct SSFDCTYPE
-{
+struct SSFDCTYPE {
        BYTE Model;
        BYTE Attribute;
        BYTE MaxZones;
@@ -183,8 +187,7 @@ typedef struct SSFDCTYPE_T
        WORD MaxLogBlocks;
 } *SSFDCTYPE_T;
 
-struct ADDRESS
-{
+struct ADDRESS {
        BYTE Zone;      /* Zone Number */
        BYTE Sector;    /* Sector(512byte) Number on Block */
        WORD PhyBlock;  /* Physical Block Number on Zone */
@@ -199,92 +202,112 @@ typedef struct ADDRESS_T
        WORD LogBlock;  /* Logical Block Number of Zone */
 } *ADDRESS_T;
 
-struct CIS_AREA
-{
+struct CIS_AREA {
        BYTE Sector;    /* Sector(512byte) Number on Block */
        WORD PhyBlock;  /* Physical Block Number on Zone 0 */
 };
 
 
-//----- SMILMain.c ---------------------------------------------------
-/******************************************/
-int         Init_D_SmartMedia           (void);
-int         Pwoff_D_SmartMedia          (void);
-int         Check_D_SmartMedia          (void);
-int         Check_D_Parameter           (struct us_data *,WORD *,BYTE *,BYTE *);
-int         Media_D_ReadSector          (struct us_data *,DWORD,WORD,BYTE *);
-int         Media_D_WriteSector         (struct us_data *,DWORD,WORD,BYTE *);
-int         Media_D_CopySector          (struct us_data *,DWORD,WORD,BYTE *);
-int         Media_D_EraseBlock          (struct us_data *,DWORD,WORD);
-int         Media_D_EraseAll            (struct us_data *);
-/******************************************/
-int         Media_D_OneSectWriteStart   (struct us_data *,DWORD,BYTE *);
-int         Media_D_OneSectWriteNext    (struct us_data *,BYTE *);
-int         Media_D_OneSectWriteFlush   (struct us_data *);
+extern BYTE IsSSFDCCompliance;
+extern BYTE IsXDCompliance;
 
-/******************************************/
-void        SM_EnableLED                (struct us_data *,BOOLEAN);
-void        Led_D_TernOn                (void);
-void        Led_D_TernOff               (void);
+extern DWORD   ErrXDCode;
+extern DWORD   ErrCode;
+extern WORD    ReadBlock;
+extern WORD    WriteBlock;
+extern DWORD   MediaChange;
 
-int         Media_D_EraseAllRedtData    (DWORD Index, BOOLEAN CheckBlock);
-//DWORD       Media_D_GetMediaInfo        (struct us_data * fdoExt, PIOCTL_MEDIA_INFO_IN pParamIn, PIOCTL_MEDIA_INFO_OUT pParamOut);
+extern struct SSFDCTYPE  Ssfdc;
+extern struct ADDRESS    Media;
+extern struct CIS_AREA   CisArea;
 
-//----- SMILSub.c ----------------------------------------------------
+/*
+ * SMILMain.c
+ */
 /******************************************/
-int  Check_D_DataBlank            (BYTE *);
-int  Check_D_FailBlock            (BYTE *);
-int  Check_D_DataStatus           (BYTE *);
-int  Load_D_LogBlockAddr          (BYTE *);
-void Clr_D_RedundantData          (BYTE *);
-void Set_D_LogBlockAddr           (BYTE *);
-void Set_D_FailBlock              (BYTE *);
-void Set_D_DataStaus              (BYTE *);
-
+int         Init_D_SmartMedia(void);
+int         Pwoff_D_SmartMedia(void);
+int         Check_D_SmartMedia(void);
+int         Check_D_Parameter(struct us_data *, WORD *, BYTE *, BYTE *);
+int         Media_D_ReadSector(struct us_data *, DWORD, WORD, BYTE *);
+int         Media_D_WriteSector(struct us_data *, DWORD, WORD, BYTE *);
+int         Media_D_CopySector(struct us_data *, DWORD, WORD, BYTE *);
+int         Media_D_EraseBlock(struct us_data *, DWORD, WORD);
+int         Media_D_EraseAll(struct us_data *);
 /******************************************/
-void Ssfdc_D_Reset                (struct us_data *);
-int  Ssfdc_D_ReadCisSect          (struct us_data *, BYTE *,BYTE *);
-void Ssfdc_D_WriteRedtMode        (void);
-void Ssfdc_D_ReadID               (BYTE *, BYTE);
-int  Ssfdc_D_ReadSect             (struct us_data *, BYTE *,BYTE *);
-int  Ssfdc_D_ReadBlock            (struct us_data *, WORD, BYTE *,BYTE *);
-int  Ssfdc_D_WriteSect            (struct us_data *, BYTE *,BYTE *);
-int  Ssfdc_D_WriteBlock           (struct us_data *, WORD, BYTE *,BYTE *);
-int  Ssfdc_D_CopyBlock            (struct us_data *, WORD, BYTE *,BYTE *);
-int  Ssfdc_D_WriteSectForCopy     (struct us_data *, BYTE *,BYTE *);
-int  Ssfdc_D_EraseBlock           (struct us_data *);
-int  Ssfdc_D_ReadRedtData         (struct us_data *, BYTE *);
-int  Ssfdc_D_WriteRedtData        (struct us_data *, BYTE *);
-int  Ssfdc_D_CheckStatus          (void);
-int  Set_D_SsfdcModel             (BYTE);
-void Cnt_D_Reset                  (void);
-int  Cnt_D_PowerOn                (void);
-void Cnt_D_PowerOff               (void);
-void Cnt_D_LedOn                  (void);
-void Cnt_D_LedOff                 (void);
-int  Check_D_CntPower             (void);
-int  Check_D_CardExist            (void);
-int  Check_D_CardStsChg           (void);
-int  Check_D_SsfdcWP              (void);
-int  SM_ReadBlock                 (struct us_data *, BYTE *,BYTE *);
-
-int  Ssfdc_D_ReadSect_DMA         (struct us_data *, BYTE *,BYTE *);
-int  Ssfdc_D_ReadSect_PIO         (struct us_data *, BYTE *,BYTE *);
-int  Ssfdc_D_WriteSect_DMA        (struct us_data *, BYTE *,BYTE *);
-int  Ssfdc_D_WriteSect_PIO        (struct us_data *, BYTE *,BYTE *);
+int         Media_D_OneSectWriteStart(struct us_data *, DWORD, BYTE *);
+int         Media_D_OneSectWriteNext(struct us_data *, BYTE *);
+int         Media_D_OneSectWriteFlush(struct us_data *);
 
 /******************************************/
-int  Check_D_ReadError            (BYTE *);
-int  Check_D_Correct              (BYTE *,BYTE *);
-int  Check_D_CISdata              (BYTE *,BYTE *);
-void Set_D_RightECC               (BYTE *);
-
-//----- SMILECC.c ----------------------------------------------------
-void calculate_ecc                (BYTE *, BYTE *, BYTE *, BYTE *, BYTE *);
-BYTE correct_data                 (BYTE *, BYTE *, BYTE,   BYTE,   BYTE);
-int  _Correct_D_SwECC             (BYTE *,BYTE *,BYTE *);
-void _Calculate_D_SwECC           (BYTE *,BYTE *);
+extern int     SM_FreeMem(void);       /* ENE SM function */
+void        SM_EnableLED(struct us_data *, BOOLEAN);
+void        Led_D_TernOn(void);
+void        Led_D_TernOff(void);
+
+int         Media_D_EraseAllRedtData(DWORD Index, BOOLEAN CheckBlock);
+/*DWORD Media_D_GetMediaInfo(struct us_data * fdoExt,
+       PIOCTL_MEDIA_INFO_IN pParamIn, PIOCTL_MEDIA_INFO_OUT pParamOut); */
+
+/*
+ * SMILSub.c
+ */
+/******************************************/
+int  Check_D_DataBlank(BYTE *);
+int  Check_D_FailBlock(BYTE *);
+int  Check_D_DataStatus(BYTE *);
+int  Load_D_LogBlockAddr(BYTE *);
+void Clr_D_RedundantData(BYTE *);
+void Set_D_LogBlockAddr(BYTE *);
+void Set_D_FailBlock(BYTE *);
+void Set_D_DataStaus(BYTE *);
 
-void SM_Init        (void);
+/******************************************/
+void Ssfdc_D_Reset(struct us_data *);
+int  Ssfdc_D_ReadCisSect(struct us_data *, BYTE *, BYTE *);
+void Ssfdc_D_WriteRedtMode(void);
+void Ssfdc_D_ReadID(BYTE *, BYTE);
+int  Ssfdc_D_ReadSect(struct us_data *, BYTE *, BYTE *);
+int  Ssfdc_D_ReadBlock(struct us_data *, WORD, BYTE *, BYTE *);
+int  Ssfdc_D_WriteSect(struct us_data *, BYTE *, BYTE *);
+int  Ssfdc_D_WriteBlock(struct us_data *, WORD, BYTE *, BYTE *);
+int  Ssfdc_D_CopyBlock(struct us_data *, WORD, BYTE *, BYTE *);
+int  Ssfdc_D_WriteSectForCopy(struct us_data *, BYTE *, BYTE *);
+int  Ssfdc_D_EraseBlock(struct us_data *);
+int  Ssfdc_D_ReadRedtData(struct us_data *, BYTE *);
+int  Ssfdc_D_WriteRedtData(struct us_data *, BYTE *);
+int  Ssfdc_D_CheckStatus(void);
+int  Set_D_SsfdcModel(BYTE);
+void Cnt_D_Reset(void);
+int  Cnt_D_PowerOn(void);
+void Cnt_D_PowerOff(void);
+void Cnt_D_LedOn(void);
+void Cnt_D_LedOff(void);
+int  Check_D_CntPower(void);
+int  Check_D_CardExist(void);
+int  Check_D_CardStsChg(void);
+int  Check_D_SsfdcWP(void);
+int  SM_ReadBlock(struct us_data *, BYTE *, BYTE *);
+
+int  Ssfdc_D_ReadSect_DMA(struct us_data *, BYTE *, BYTE *);
+int  Ssfdc_D_ReadSect_PIO(struct us_data *, BYTE *, BYTE *);
+int  Ssfdc_D_WriteSect_DMA(struct us_data *, BYTE *, BYTE *);
+int  Ssfdc_D_WriteSect_PIO(struct us_data *, BYTE *, BYTE *);
 
-#endif // already included
+/******************************************/
+int  Check_D_ReadError(BYTE *);
+int  Check_D_Correct(BYTE *, BYTE *);
+int  Check_D_CISdata(BYTE *, BYTE *);
+void Set_D_RightECC(BYTE *);
+
+/*
+ * SMILECC.c
+ */
+void calculate_ecc(BYTE *, BYTE *, BYTE *, BYTE *, BYTE *);
+BYTE correct_data(BYTE *, BYTE *, BYTE,   BYTE,   BYTE);
+int  _Correct_D_SwECC(BYTE *, BYTE *, BYTE *);
+void _Calculate_D_SwECC(BYTE *, BYTE *);
+
+void SM_Init(void);
+
+#endif /* already included */
index 5659dea7b701fb8c5867ac9fb1cbb6cc00cd4be3..3085f1d4a4ebe154be32040a43b183fbbe849055 100644 (file)
@@ -1,39 +1,42 @@
 #include "usb.h"
 #include "scsiglue.h"
 #include "transport.h"
-//#include "stdlib.h"
-//#include "EUCR6SK.h"
+/* #include "stdlib.h" */
+/* #include "EUCR6SK.h" */
 #include "smcommon.h"
 #include "smil.h"
 
-//#include <stdio.h>
-//#include <stdlib.h>
-//#include <string.h>
-//#include <dos.h>
-//
-//#include "EMCRIOS.h"
+/* #include <stdio.h> */
+/* #include <stdlib.h> */
+/* #include <string.h> */
+/* #include <dos.h> */
+/* #include "EMCRIOS.h" */
 
-// CP0-CP5 code table
+/* CP0-CP5 code table */
 static BYTE ecctable[256] = {
-0x00,0x55,0x56,0x03,0x59,0x0C,0x0F,0x5A,0x5A,0x0F,0x0C,0x59,0x03,0x56,0x55,0x00,
-0x65,0x30,0x33,0x66,0x3C,0x69,0x6A,0x3F,0x3F,0x6A,0x69,0x3C,0x66,0x33,0x30,0x65,
-0x66,0x33,0x30,0x65,0x3F,0x6A,0x69,0x3C,0x3C,0x69,0x6A,0x3F,0x65,0x30,0x33,0x66,
-0x03,0x56,0x55,0x00,0x5A,0x0F,0x0C,0x59,0x59,0x0C,0x0F,0x5A,0x00,0x55,0x56,0x03,
-0x69,0x3C,0x3F,0x6A,0x30,0x65,0x66,0x33,0x33,0x66,0x65,0x30,0x6A,0x3F,0x3C,0x69,
-0x0C,0x59,0x5A,0x0F,0x55,0x00,0x03,0x56,0x56,0x03,0x00,0x55,0x0F,0x5A,0x59,0x0C,
-0x0F,0x5A,0x59,0x0C,0x56,0x03,0x00,0x55,0x55,0x00,0x03,0x56,0x0C,0x59,0x5A,0x0F,
-0x6A,0x3F,0x3C,0x69,0x33,0x66,0x65,0x30,0x30,0x65,0x66,0x33,0x69,0x3C,0x3F,0x6A,
-0x6A,0x3F,0x3C,0x69,0x33,0x66,0x65,0x30,0x30,0x65,0x66,0x33,0x69,0x3C,0x3F,0x6A,
-0x0F,0x5A,0x59,0x0C,0x56,0x03,0x00,0x55,0x55,0x00,0x03,0x56,0x0C,0x59,0x5A,0x0F,
-0x0C,0x59,0x5A,0x0F,0x55,0x00,0x03,0x56,0x56,0x03,0x00,0x55,0x0F,0x5A,0x59,0x0C,
-0x69,0x3C,0x3F,0x6A,0x30,0x65,0x66,0x33,0x33,0x66,0x65,0x30,0x6A,0x3F,0x3C,0x69,
-0x03,0x56,0x55,0x00,0x5A,0x0F,0x0C,0x59,0x59,0x0C,0x0F,0x5A,0x00,0x55,0x56,0x03,
-0x66,0x33,0x30,0x65,0x3F,0x6A,0x69,0x3C,0x3C,0x69,0x6A,0x3F,0x65,0x30,0x33,0x66,
-0x65,0x30,0x33,0x66,0x3C,0x69,0x6A,0x3F,0x3F,0x6A,0x69,0x3C,0x66,0x33,0x30,0x65,
-0x00,0x55,0x56,0x03,0x59,0x0C,0x0F,0x5A,0x5A,0x0F,0x0C,0x59,0x03,0x56,0x55,0x00
+0x00, 0x55, 0x56, 0x03, 0x59, 0x0C, 0x0F, 0x5A, 0x5A, 0x0F, 0x0C, 0x59, 0x03,
+0x56, 0x55, 0x00, 0x65, 0x30, 0x33, 0x66, 0x3C, 0x69, 0x6A, 0x3F, 0x3F, 0x6A,
+0x69, 0x3C, 0x66, 0x33, 0x30, 0x65, 0x66, 0x33, 0x30, 0x65, 0x3F, 0x6A, 0x69,
+0x3C, 0x3C, 0x69, 0x6A, 0x3F, 0x65, 0x30, 0x33, 0x66, 0x03, 0x56, 0x55, 0x00,
+0x5A, 0x0F, 0x0C, 0x59, 0x59, 0x0C, 0x0F, 0x5A, 0x00, 0x55, 0x56, 0x03, 0x69,
+0x3C, 0x3F, 0x6A, 0x30, 0x65, 0x66, 0x33, 0x33, 0x66, 0x65, 0x30, 0x6A, 0x3F,
+0x3C, 0x69, 0x0C, 0x59, 0x5A, 0x0F, 0x55, 0x00, 0x03, 0x56, 0x56, 0x03, 0x00,
+0x55, 0x0F, 0x5A, 0x59, 0x0C, 0x0F, 0x5A, 0x59, 0x0C, 0x56, 0x03, 0x00, 0x55,
+0x55, 0x00, 0x03, 0x56, 0x0C, 0x59, 0x5A, 0x0F, 0x6A, 0x3F, 0x3C, 0x69, 0x33,
+0x66, 0x65, 0x30, 0x30, 0x65, 0x66, 0x33, 0x69, 0x3C, 0x3F, 0x6A, 0x6A, 0x3F,
+0x3C, 0x69, 0x33, 0x66, 0x65, 0x30, 0x30, 0x65, 0x66, 0x33, 0x69, 0x3C, 0x3F,
+0x6A, 0x0F, 0x5A, 0x59, 0x0C, 0x56, 0x03, 0x00, 0x55, 0x55, 0x00, 0x03, 0x56,
+0x0C, 0x59, 0x5A, 0x0F, 0x0C, 0x59, 0x5A, 0x0F, 0x55, 0x00, 0x03, 0x56, 0x56,
+0x03, 0x00, 0x55, 0x0F, 0x5A, 0x59, 0x0C, 0x69, 0x3C, 0x3F, 0x6A, 0x30, 0x65,
+0x66, 0x33, 0x33, 0x66, 0x65, 0x30, 0x6A, 0x3F, 0x3C, 0x69, 0x03, 0x56, 0x55,
+0x00, 0x5A, 0x0F, 0x0C, 0x59, 0x59, 0x0C, 0x0F, 0x5A, 0x00, 0x55, 0x56, 0x03,
+0x66, 0x33, 0x30, 0x65, 0x3F, 0x6A, 0x69, 0x3C, 0x3C, 0x69, 0x6A, 0x3F, 0x65,
+0x30, 0x33, 0x66, 0x65, 0x30, 0x33, 0x66, 0x3C, 0x69, 0x6A, 0x3F, 0x3F, 0x6A,
+0x69, 0x3C, 0x66, 0x33, 0x30, 0x65, 0x00, 0x55, 0x56, 0x03, 0x59, 0x0C, 0x0F,
+0x5A, 0x5A, 0x0F, 0x0C, 0x59, 0x03, 0x56, 0x55, 0x00
 };
 
-static void   trans_result  (BYTE,   BYTE,   BYTE *, BYTE *);
+static void   trans_result(BYTE,   BYTE,   BYTE *, BYTE *);
 
 #define BIT7        0x80
 #define BIT6        0x40
@@ -48,139 +51,144 @@ static void   trans_result  (BYTE,   BYTE,   BYTE *, BYTE *);
 #define MASK_CPS    0x3f
 #define CORRECTABLE 0x00555554L
 
-static void trans_result(reg2,reg3,ecc1,ecc2)
-BYTE reg2; // LP14,LP12,LP10,...
-BYTE reg3; // LP15,LP13,LP11,...
-BYTE *ecc1; // LP15,LP14,LP13,...
-BYTE *ecc2; // LP07,LP06,LP05,...
+/*
+ * reg2; * LP14,LP12,LP10,...
+ * reg3; * LP15,LP13,LP11,...
+ * *ecc1; * LP15,LP14,LP13,...
+ * *ecc2; * LP07,LP06,LP05,...
+ */
+static void trans_result(BYTE reg2, BYTE reg3, BYTE *ecc1, BYTE *ecc2)
 {
-    BYTE a; // Working for reg2,reg3
-    BYTE b; // Working for ecc1,ecc2
-    BYTE i; // For counting
-
-    a=BIT7; b=BIT7; // 80h=10000000b
-    *ecc1=*ecc2=0; // Clear ecc1,ecc2
-    for(i=0; i<4; ++i) {
-        if ((reg3&a)!=0)
-            *ecc1|=b; // LP15,13,11,9 -> ecc1
-        b=b>>1; // Right shift
-        if ((reg2&a)!=0)
-            *ecc1|=b; // LP14,12,10,8 -> ecc1
-        b=b>>1; // Right shift
-        a=a>>1; // Right shift
-    }
-
-    b=BIT7; // 80h=10000000b
-    for(i=0; i<4; ++i) {
-        if ((reg3&a)!=0)
-            *ecc2|=b; // LP7,5,3,1 -> ecc2
-        b=b>>1; // Right shift
-        if ((reg2&a)!=0)
-            *ecc2|=b; // LP6,4,2,0 -> ecc2
-        b=b>>1; // Right shift
-        a=a>>1; // Right shift
-    }
+       BYTE a; /* Working for reg2,reg3 */
+       BYTE b; /* Working for ecc1,ecc2 */
+       BYTE i; /* For counting */
+
+       a = BIT7; b = BIT7; /* 80h=10000000b */
+       *ecc1 = *ecc2 = 0; /* Clear ecc1,ecc2 */
+       for (i = 0; i < 4; ++i) {
+               if ((reg3&a) != 0)
+                       *ecc1 |= b; /* LP15,13,11,9 -> ecc1 */
+               b = b>>1; /* Right shift */
+               if ((reg2&a) != 0)
+                       *ecc1 |= b; /* LP14,12,10,8 -> ecc1 */
+               b = b>>1; /* Right shift */
+               a = a>>1; /* Right shift */
+       }
+
+       b = BIT7; /* 80h=10000000b */
+       for (i = 0; i < 4; ++i) {
+               if ((reg3&a) != 0)
+                       *ecc2 |= b; /* LP7,5,3,1 -> ecc2 */
+               b = b>>1; /* Right shift */
+               if ((reg2&a) != 0)
+                       *ecc2 |= b; /* LP6,4,2,0 -> ecc2 */
+               b = b>>1; /* Right shift */
+               a = a>>1; /* Right shift */
+       }
 }
 
-//static void calculate_ecc(table,data,ecc1,ecc2,ecc3)
-void calculate_ecc(table,data,ecc1,ecc2,ecc3)
-BYTE *table; // CP0-CP5 code table
-BYTE *data; // DATA
-BYTE *ecc1; // LP15,LP14,LP13,...
-BYTE *ecc2; // LP07,LP06,LP05,...
-BYTE *ecc3; // CP5,CP4,CP3,...,"1","1"
+/*static void calculate_ecc(table,data,ecc1,ecc2,ecc3) */
+/*
+ * *table; * CP0-CP5 code table
+ * *data; * DATA
+ * *ecc1; * LP15,LP14,LP13,...
+ * *ecc2; * LP07,LP06,LP05,...
+ * *ecc3; * CP5,CP4,CP3,...,"1","1"
+ */
+void calculate_ecc(BYTE *table, BYTE *data, BYTE *ecc1, BYTE *ecc2, BYTE *ecc3)
 {
-    DWORD  i;    // For counting
-    BYTE a;    // Working for table
-    BYTE reg1; // D-all,CP5,CP4,CP3,...
-    BYTE reg2; // LP14,LP12,L10,...
-    BYTE reg3; // LP15,LP13,L11,...
-
-    reg1=reg2=reg3=0;   // Clear parameter
-    for(i=0; i<256; ++i) {
-        a=table[data[i]]; // Get CP0-CP5 code from table
-        reg1^=(a&MASK_CPS); // XOR with a
-        if ((a&BIT6)!=0)
-        { // If D_all(all bit XOR) = 1
-            reg3^=(BYTE)i; // XOR with counter
-            reg2^=~((BYTE)i); // XOR with inv. of counter
-        }
-    }
-
-    // Trans LP14,12,10,... & LP15,13,11,... -> LP15,14,13,... & LP7,6,5,..
-    trans_result(reg2,reg3,ecc1,ecc2);
-    *ecc1=~(*ecc1); *ecc2=~(*ecc2); // Inv. ecc2 & ecc3
-    *ecc3=((~reg1)<<2)|BIT1BIT0; // Make TEL format
+       DWORD  i;    /* For counting */
+       BYTE a;    /* Working for table */
+       BYTE reg1; /* D-all,CP5,CP4,CP3,... */
+       BYTE reg2; /* LP14,LP12,L10,... */
+       BYTE reg3; /* LP15,LP13,L11,... */
+
+       reg1 = reg2 = reg3 = 0;   /* Clear parameter */
+       for (i = 0; i < 256; ++i) {
+               a = table[data[i]]; /* Get CP0-CP5 code from table */
+               reg1 ^= (a&MASK_CPS); /* XOR with a */
+               if ((a&BIT6) != 0) { /* If D_all(all bit XOR) = 1 */
+                       reg3 ^= (BYTE)i; /* XOR with counter */
+                       reg2 ^= ~((BYTE)i); /* XOR with inv. of counter */
+               }
+       }
+
+       /* Trans LP14,12,10,... & LP15,13,11,... ->
+                                               LP15,14,13,... & LP7,6,5,.. */
+       trans_result(reg2, reg3, ecc1, ecc2);
+       *ecc1 = ~(*ecc1); *ecc2 = ~(*ecc2); /* Inv. ecc2 & ecc3 */
+       *ecc3 = ((~reg1)<<2)|BIT1BIT0; /* Make TEL format */
 }
 
-BYTE correct_data(data,eccdata,ecc1,ecc2,ecc3)
-BYTE *data; // DATA
-BYTE *eccdata; // ECC DATA
-BYTE ecc1; // LP15,LP14,LP13,...
-BYTE ecc2; // LP07,LP06,LP05,...
-BYTE ecc3; // CP5,CP4,CP3,...,"1","1"
+/*
+ * *data; * DATA
+ * *eccdata; * ECC DATA
+ * ecc1; * LP15,LP14,LP13,...
+ * ecc2; * LP07,LP06,LP05,...
+ * ecc3; * CP5,CP4,CP3,...,"1","1"
+ */
+BYTE correct_data(BYTE *data, BYTE *eccdata, BYTE ecc1, BYTE ecc2, BYTE ecc3)
 {
-    DWORD l; // Working to check d
-    DWORD d; // Result of comparison
-    DWORD i; // For counting
-    BYTE d1,d2,d3; // Result of comparison
-    BYTE a; // Working for add
-    BYTE add; // Byte address of cor. DATA
-    BYTE b; // Working for bit
-    BYTE bit; // Bit address of cor. DATA
-
-    d1=ecc1^eccdata[1]; d2=ecc2^eccdata[0]; // Compare LP's
-    d3=ecc3^eccdata[2]; // Comapre CP's
-    d=((DWORD)d1<<16) // Result of comparison
-    +((DWORD)d2<<8)
-    +(DWORD)d3;
-
-    if (d==0) return(0); // If No error, return
-
-    if (((d^(d>>1))&CORRECTABLE)==CORRECTABLE)
-    { // If correctable
-        l=BIT23;
-        add=0; // Clear parameter
-        a=BIT7;
-
-        for(i=0; i<8; ++i) { // Checking 8 bit
-            if ((d&l)!=0) add|=a; // Make byte address from LP's
-            l>>=2; a>>=1; // Right Shift
-        }
-
-        bit=0; // Clear parameter
-        b=BIT2;
-        for(i=0; i<3; ++i) { // Checking 3 bit
-            if ((d&l)!=0) bit|=b; // Make bit address from CP's
-            l>>=2; b>>=1; // Right shift
-        }
-
-        b=BIT0;
-        data[add]^=(b<<bit); // Put corrected data
-        return(1);
-    }
-
-    i=0; // Clear count
-    d&=0x00ffffffL; // Masking
-
-    while(d) { // If d=0 finish counting
-        if (d&BIT0) ++i; // Count number of 1 bit
-        d>>=1; // Right shift
-    }
-
-    if (i==1)
-    { // If ECC error
-        eccdata[1]=ecc1; eccdata[0]=ecc2; // Put right ECC code
-        eccdata[2]=ecc3;
-        return(2);
-    }
-    return(3); // Uncorrectable error
+       DWORD l; /* Working to check d */
+       DWORD d; /* Result of comparison */
+       DWORD i; /* For counting */
+       BYTE d1, d2, d3; /* Result of comparison */
+       BYTE a; /* Working for add */
+       BYTE add; /* Byte address of cor. DATA */
+       BYTE b; /* Working for bit */
+       BYTE bit; /* Bit address of cor. DATA */
+
+       d1 = ecc1^eccdata[1]; d2 = ecc2^eccdata[0]; /* Compare LP's */
+       d3 = ecc3^eccdata[2]; /* Comapre CP's */
+       d = ((DWORD)d1<<16) /* Result of comparison */
+       +((DWORD)d2<<8)
+       +(DWORD)d3;
+
+       if (d == 0)
+               return 0; /* If No error, return */
+
+       if (((d^(d>>1))&CORRECTABLE) == CORRECTABLE) { /* If correctable */
+               l = BIT23;
+               add = 0; /* Clear parameter */
+               a = BIT7;
+
+               for (i = 0; i < 8; ++i) { /* Checking 8 bit */
+                       if ((d&l) != 0)
+                               add |= a; /* Make byte address from LP's */
+                       l >>= 2; a >>= 1; /* Right Shift */
+               }
+
+               bit = 0; /* Clear parameter */
+               b = BIT2;
+               for (i = 0; i < 3; ++i) { /* Checking 3 bit */
+                       if ((d&l) != 0)
+                               bit |= b; /* Make bit address from CP's */
+                       l >>= 2; b >>= 1; /* Right shift */
+               }
+
+               b = BIT0;
+               data[add] ^= (b<<bit); /* Put corrected data */
+               return 1;
+       }
+
+       i = 0; /* Clear count */
+       d &= 0x00ffffffL; /* Masking */
+
+       while (d) { /* If d=0 finish counting */
+               if (d&BIT0)
+                       ++i; /* Count number of 1 bit */
+               d >>= 1; /* Right shift */
+       }
+
+       if (i == 1) { /* If ECC error */
+               eccdata[1] = ecc1; eccdata[0] = ecc2; /* Put right ECC code */
+               eccdata[2] = ecc3;
+               return 2;
+       }
+       return 3; /* Uncorrectable error */
 }
 
-int _Correct_D_SwECC(buf,redundant_ecc,calculate_ecc)
-BYTE *buf;
-BYTE *redundant_ecc;
-BYTE *calculate_ecc;
+int _Correct_D_SwECC(BYTE *buf, BYTE *redundant_ecc, BYTE *calculate_ecc)
 {
        DWORD err;
 
@@ -195,11 +203,9 @@ BYTE *calculate_ecc;
        return -1;
 }
 
-void _Calculate_D_SwECC(buf,ecc)
-BYTE *buf;
-BYTE *ecc;
+void _Calculate_D_SwECC(BYTE *buf, BYTE *ecc)
 {
-    calculate_ecc(ecctable,buf,ecc+1,ecc+0,ecc+2);
+       calculate_ecc(ecctable, buf, ecc+1, ecc+0, ecc+2);
 }
 
 
index 95c688a5c95adfa685c6823b92367122a6291e9c..31f7813cab0d6f6093fee72dbf1726e9ff96b556 100644 (file)
@@ -48,31 +48,27 @@ int  MarkFail_D_PhyOneBlock      (struct us_data *);
 DWORD ErrXDCode;
 DWORD ErrCode;
 //BYTE  SectBuf[SECTSIZE];
-BYTE  WorkBuf[SECTSIZE];
-BYTE  Redundant[REDTSIZE];
-BYTE  WorkRedund[REDTSIZE];
+static BYTE  WorkBuf[SECTSIZE];
+static BYTE  Redundant[REDTSIZE];
+static BYTE  WorkRedund[REDTSIZE];
 //WORD  Log2Phy[MAX_ZONENUM][MAX_LOGBLOCK];
-WORD  *Log2Phy[MAX_ZONENUM];                 // 128 x 1000,   Log2Phy[MAX_ZONENUM][MAX_LOGBLOCK];
-BYTE  Assign[MAX_ZONENUM][MAX_BLOCKNUM/8];
-WORD  AssignStart[MAX_ZONENUM];
+static WORD  *Log2Phy[MAX_ZONENUM];                 // 128 x 1000,   Log2Phy[MAX_ZONENUM][MAX_LOGBLOCK];
+static BYTE  Assign[MAX_ZONENUM][MAX_BLOCKNUM/8];
+static WORD  AssignStart[MAX_ZONENUM];
 WORD  ReadBlock;
 WORD  WriteBlock;
 DWORD MediaChange;
-DWORD SectCopyMode;
-
-extern struct SSFDCTYPE  Ssfdc;
-extern struct ADDRESS    Media;
-extern struct CIS_AREA   CisArea;
+static DWORD SectCopyMode;
 
 //BIT Control Macro
-BYTE BitData[] = { 0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80 } ;
+static BYTE BitData[] = { 0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80 } ;
 #define Set_D_Bit(a,b)    (a[(BYTE)((b)/8)]|= BitData[(b)%8])
 #define Clr_D_Bit(a,b)    (a[(BYTE)((b)/8)]&=~BitData[(b)%8])
 #define Chk_D_Bit(a,b)    (a[(BYTE)((b)/8)] & BitData[(b)%8])
 
 //extern PBYTE    SMHostAddr;
-extern BYTE     IsSSFDCCompliance;
-extern BYTE     IsXDCompliance;
+BYTE     IsSSFDCCompliance;
+BYTE     IsXDCompliance;
 
 
 //
@@ -102,12 +98,12 @@ int SM_FreeMem(void)
 {
        int     i;
 
-       printk("SM_FreeMem start\n");
+       pr_info("SM_FreeMem start\n");
        for (i=0; i<MAX_ZONENUM; i++)
        {
                if (Log2Phy[i]!=NULL)
                {
-                       printk("Free Zone = %x, Addr = %p\n", i, Log2Phy[i]);
+                       pr_info("Free Zone = %x, Addr = %p\n", i, Log2Phy[i]);
                        kfree(Log2Phy[i]);
                        Log2Phy[i] = NULL;
                }
@@ -198,7 +194,7 @@ int Media_D_CopySector(struct us_data *us, DWORD start,WORD count,BYTE *buf)
        //SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc;
        //ADDRESS_T   bb = (ADDRESS_T) &Media;
 
-       //printk("Media_D_CopySector !!!\n");
+       /* pr_info("Media_D_CopySector !!!\n"); */
        if (Conv_D_MediaAddr(us, start))
                return(ErrCode);
 
@@ -256,13 +252,13 @@ int Release_D_CopySector(struct us_data *us)
        if (Media.PhyBlock==NO_ASSIGN)
        {
                Media.PhyBlock=WriteBlock;
-               return(SUCCESS);
+               return(SMSUCCESS);
        }
 
        Clr_D_Bit(Assign[Media.Zone],Media.PhyBlock);
        Media.PhyBlock=WriteBlock;
 
-       return(SUCCESS);
+       return(SMSUCCESS);
 }
 /*
 //----- Media_D_WriteSector() ------------------------------------------
@@ -572,7 +568,7 @@ int Media_D_OneSectWriteFlush(PFDO_DEVICE_EXTENSION fdoExt)
 //        default:         *c= 0;  *h= 0; *s= 0; ErrCode = ERR_NoSmartMedia;    return(ERROR);
 //    }
 //
-//    return(SUCCESS);
+//    return(SMSUCCESS);
 //}
 //
 ////Power Control & Media Exist Check Subroutine
@@ -599,7 +595,7 @@ int Media_D_OneSectWriteFlush(PFDO_DEVICE_EXTENSION fdoExt)
 //        MediaChange = ERROR;
 //    //usleep(56*1024);
 //    if ((!Check_D_CntPower())&&(!MediaChange))  // ¦³ power & Media ¨S³Q change, «h return success
-//        return(SUCCESS);
+//        return(SMSUCCESS);
 //    //usleep(56*1024);
 //
 //    if (Check_D_CardExist())                    // Check if card is not exist, return err
@@ -618,7 +614,7 @@ int Media_D_OneSectWriteFlush(PFDO_DEVICE_EXTENSION fdoExt)
 //    //usleep(56*1024);
 //    Ssfdc_D_Reset(fdoExt);
 //    //usleep(56*1024);
-//    return(SUCCESS);
+//    return(SMSUCCESS);
 //}
 //
 ////-----Check_D_MediaExist() --------------------------------------------
@@ -630,7 +626,7 @@ int Media_D_OneSectWriteFlush(PFDO_DEVICE_EXTENSION fdoExt)
 //    if (!Check_D_CardExist())
 //    {
 //        if (!MediaChange)
-//            return(SUCCESS);
+//            return(SMSUCCESS);
 //
 //        ErrCode = ERR_ChangedMedia;
 //        return(ERROR);
@@ -650,19 +646,19 @@ int Media_D_OneSectWriteFlush(PFDO_DEVICE_EXTENSION fdoExt)
 //        return(ERROR);
 //    }
 //
-//    return(SUCCESS);
+//    return(SMSUCCESS);
 //}
 */
 //SmartMedia Physical Format Test Subroutine
 //----- Check_D_MediaFmt() ---------------------------------------------
 int Check_D_MediaFmt(struct us_data *us)
 {
-       printk("Check_D_MediaFmt\n");
+       pr_info("Check_D_MediaFmt\n");
        //ULONG i,j, result=FALSE, zone,block;
 
        //usleep(56*1024);
        if (!MediaChange)
-               return(SUCCESS);
+               return(SMSUCCESS);
 
        MediaChange  = ERROR;
        SectCopyMode = COMPLETED;
@@ -682,8 +678,8 @@ int Check_D_MediaFmt(struct us_data *us)
        }
 
 
-    MediaChange = SUCCESS;
-    return(SUCCESS);
+    MediaChange = SMSUCCESS;
+    return(SMSUCCESS);
 }
 /*
 ////----- Check_D_BlockIsFull() ----------------------------------
@@ -735,7 +731,7 @@ int Check_D_MediaFmt(struct us_data *us)
 //        return(ERROR);
 //    }
 //
-//    return(SUCCESS);
+//    return(SMSUCCESS);
 //}
 */
 //SmartMedia Physical Address Control Subroutine
@@ -767,7 +763,7 @@ int Conv_D_MediaAddr(struct us_data *us, DWORD addr)
                Clr_D_RedundantData(Redundant);
                Set_D_LogBlockAddr(Redundant);
                Media.PhyBlock = Log2Phy[Media.Zone][Media.LogBlock];
-               return(SUCCESS);
+               return(SMSUCCESS);
        }
 
        ErrCode = ERR_OutOfLBA;
@@ -782,7 +778,7 @@ int Inc_D_MediaAddr(struct us_data *us)
        //ADDRESS_T   bb = (ADDRESS_T) &Media;
 
        if (++Media.Sector<Ssfdc.MaxSectors)
-               return(SUCCESS);
+               return(SMSUCCESS);
 
        if (Log2Phy[Media.Zone]==NULL)
        {
@@ -801,7 +797,7 @@ int Inc_D_MediaAddr(struct us_data *us)
                Clr_D_RedundantData(Redundant);
                Set_D_LogBlockAddr(Redundant);
                Media.PhyBlock=Log2Phy[Media.Zone][Media.LogBlock];
-               return(SUCCESS);
+               return(SMSUCCESS);
        }
 
        Media.LogBlock=0;
@@ -822,7 +818,7 @@ int Inc_D_MediaAddr(struct us_data *us)
                Clr_D_RedundantData(Redundant);
                Set_D_LogBlockAddr(Redundant);
                Media.PhyBlock=Log2Phy[Media.Zone][Media.LogBlock];
-               return(SUCCESS);
+               return(SMSUCCESS);
        }
 
        Media.Zone=0;
@@ -838,7 +834,7 @@ int Check_D_FirstSect(void)
     ADDRESS_T   bb = (ADDRESS_T) &Media;
 
     if (!Media.Sector)
-        return(SUCCESS);
+        return(SMSUCCESS);
 
     return(ERROR);
 }
@@ -852,7 +848,7 @@ int Check_D_LastSect(void)
     if (Media.Sector<(Ssfdc.MaxSectors-1))
         return(ERROR);
 
-    return(SUCCESS);
+    return(SMSUCCESS);
 }
 */
 //SmartMedia Read/Write Subroutine with Retry
@@ -862,7 +858,7 @@ int Media_D_ReadOneSect(struct us_data *us, WORD count, BYTE *buf)
        DWORD err, retry;
 
        if (!Read_D_PhyOneSect(us, count, buf))
-               return(SUCCESS);
+               return(SMSUCCESS);
        if (ErrCode==ERR_HwError)
                return(ERROR);
        if (ErrCode==ERR_DataStatus)
@@ -872,7 +868,7 @@ int Media_D_ReadOneSect(struct us_data *us, WORD count, BYTE *buf)
        if (Ssfdc.Attribute &MWP)
        {
                if (ErrCode==ERR_CorReadErr)
-                       return(SUCCESS);
+                       return(SMSUCCESS);
                return(ERROR);
        }
 
@@ -888,13 +884,13 @@ int Media_D_ReadOneSect(struct us_data *us, WORD count, BYTE *buf)
 
                ErrCode = err;
                if (ErrCode==ERR_CorReadErr)
-                       return(SUCCESS);
+                       return(SMSUCCESS);
                return(ERROR);
        }
 
        MediaChange = ERROR;
 #else
-       if (ErrCode==ERR_CorReadErr) return(SUCCESS);
+       if (ErrCode==ERR_CorReadErr) return(SMSUCCESS);
 #endif
 
        return(ERROR);
@@ -908,7 +904,7 @@ int Media_D_WriteOneSect(PFDO_DEVICE_EXTENSION fdoExt, WORD count, BYTE *buf)
     ADDRESS_T   bb = (ADDRESS_T) &Media;
 
     if (!Write_D_PhyOneSect(fdoExt, count, buf))
-        return(SUCCESS);
+        return(SMSUCCESS);
     if (ErrCode==ERR_HwError)
         return(ERROR);
 
@@ -922,7 +918,7 @@ int Media_D_WriteOneSect(PFDO_DEVICE_EXTENSION fdoExt, WORD count, BYTE *buf)
         }
 
         if (!Write_D_PhyOneSect(fdoExt, count, buf))
-            return(SUCCESS);
+            return(SMSUCCESS);
         if (ErrCode==ERR_HwError)
             return(ERROR);
     }
@@ -944,7 +940,7 @@ int Media_D_CopyBlockHead(PFDO_DEVICE_EXTENSION fdoExt)
     for(retry=0; retry<2; retry++)
     {
         if (!Copy_D_BlockHead(fdoExt))
-            return(SUCCESS);
+            return(SMSUCCESS);
         if (ErrCode==ERR_HwError)
             return(ERROR);
     }
@@ -959,7 +955,7 @@ int Media_D_CopyBlockTail(PFDO_DEVICE_EXTENSION fdoExt)
     DWORD retry;
 
     if (!Copy_D_BlockTail(fdoExt))
-        return(SUCCESS);
+        return(SMSUCCESS);
     if (ErrCode==ERR_HwError)
         return(ERROR);
 
@@ -973,7 +969,7 @@ int Media_D_CopyBlockTail(PFDO_DEVICE_EXTENSION fdoExt)
         }
 
         if (!Copy_D_BlockTail(fdoExt))
-            return(SUCCESS);
+            return(SMSUCCESS);
         if (ErrCode==ERR_HwError)
             return(ERROR);
     }
@@ -995,7 +991,7 @@ int Media_D_CopyBlockTail(PFDO_DEVICE_EXTENSION fdoExt)
 //    ADDRESS_T   bb = (ADDRESS_T) &Media;
 //
 //    if (Media.PhyBlock==NO_ASSIGN)
-//        return(SUCCESS);
+//        return(SMSUCCESS);
 //
 //    if (Log2Phy[Media.Zone]==NULL)
 //    {
@@ -1023,7 +1019,7 @@ int Media_D_CopyBlockTail(PFDO_DEVICE_EXTENSION fdoExt)
 //
 //    Clr_D_Bit(Assign[Media.Zone],Media.PhyBlock);
 //    Media.PhyBlock=NO_ASSIGN;
-//    return(SUCCESS);
+//    return(SMSUCCESS);
 //}
 //
 ////SmartMedia Erase Subroutine
@@ -1076,7 +1072,7 @@ int Media_D_CopyBlockTail(PFDO_DEVICE_EXTENSION fdoExt)
 //            }
 //
 //        }
-//    return(SUCCESS);
+//    return(SMSUCCESS);
 //}
 */
 //SmartMedia Physical Sector Data Copy Subroutine
@@ -1116,7 +1112,7 @@ int Copy_D_BlockAll(struct us_data *us, DWORD mode)
 
        Media.PhyBlock=WriteBlock;
        Media.Sector=sect;
-       return(SUCCESS);
+       return(SMSUCCESS);
 }
 /*
 //----- Copy_D_BlockHead() ---------------------------------------------
@@ -1149,7 +1145,7 @@ int Copy_D_BlockHead(PFDO_DEVICE_EXTENSION fdoExt)
 
     Media.PhyBlock=WriteBlock;
     Media.Sector=sect;
-    return(SUCCESS);
+    return(SMSUCCESS);
 }
 
 //----- Copy_D_BlockTail() ---------------------------------------------
@@ -1178,7 +1174,7 @@ int Copy_D_BlockTail(PFDO_DEVICE_EXTENSION fdoExt)
 
     Media.PhyBlock=WriteBlock;
     Media.Sector=sect;
-    return(SUCCESS);
+    return(SMSUCCESS);
 }
 
 //----- Reassign_D_BlockHead() -----------------------------------------
@@ -1226,7 +1222,7 @@ int Reassign_D_BlockHead(PFDO_DEVICE_EXTENSION fdoExt)
     ReadBlock=block;
     Media.Sector=sect;
     Media.PhyBlock=WriteBlock;
-    return(SUCCESS);
+    return(SMSUCCESS);
 }
 */
 //SmartMedia Physical Block Assign/Release Subroutine
@@ -1246,7 +1242,7 @@ int Assign_D_WriteBlock(void)
                        Media.PhyBlock=WriteBlock;
                        SectCopyMode=REQ_ERASE;
                        //ErrXDCode = NO_ERROR;
-                       return(SUCCESS);
+                       return(SMSUCCESS);
                }
        }
 
@@ -1259,7 +1255,7 @@ int Assign_D_WriteBlock(void)
                        Media.PhyBlock=WriteBlock;
                        SectCopyMode=REQ_ERASE;
                        //ErrXDCode = NO_ERROR;
-                       return(SUCCESS);
+                       return(SMSUCCESS);
                }
        }
 
@@ -1282,7 +1278,7 @@ int Release_D_ReadBlock(struct us_data *us)
        SectCopyMode=COMPLETED;
 
        if (mode==COMPLETED)
-               return(SUCCESS);
+               return(SMSUCCESS);
 
        Log2Phy[Media.Zone][Media.LogBlock]=WriteBlock;
        Media.PhyBlock=ReadBlock;
@@ -1290,7 +1286,7 @@ int Release_D_ReadBlock(struct us_data *us)
        if (Media.PhyBlock==NO_ASSIGN)
        {
                Media.PhyBlock=WriteBlock;
-               return(SUCCESS);
+               return(SMSUCCESS);
        }
 
        if (mode==REQ_ERASE)
@@ -1307,7 +1303,7 @@ int Release_D_ReadBlock(struct us_data *us)
                return(ERROR);
 
        Media.PhyBlock=WriteBlock;
-       return(SUCCESS);
+       return(SMSUCCESS);
 }
 
 //----- Release_D_WriteBlock() -----------------------------------------
@@ -1322,7 +1318,7 @@ int Release_D_WriteBlock(struct us_data *us)
                return(ERROR);
 
        Media.PhyBlock=ReadBlock;
-       return(SUCCESS);
+       return(SMSUCCESS);
 }
 
 //SmartMedia Physical Sector Data Copy Subroutine
@@ -1334,7 +1330,7 @@ int Copy_D_PhyOneSect(struct us_data *us)
        //SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc;
        //ADDRESS_T   bb = (ADDRESS_T) &Media;
 
-       //printk("Copy_D_PhyOneSect --- Secotr = %x\n", Media.Sector);
+       /* pr_info("Copy_D_PhyOneSect --- Secotr = %x\n", Media.Sector); */
        if (ReadBlock!=NO_ASSIGN)
        {
                Media.PhyBlock=ReadBlock;
@@ -1355,9 +1351,9 @@ int Copy_D_PhyOneSect(struct us_data *us)
                        if (Check_D_DataStatus(WorkRedund))
                        { err=ERROR; break; }
                        if (!Check_D_ReadError(WorkRedund))
-                       { err=SUCCESS; break; }
+                       { err=SMSUCCESS; break; }
                        if (!Check_D_Correct(WorkBuf,WorkRedund))
-                       { err=SUCCESS; break; }
+                       { err=SMSUCCESS; break; }
 
                        err=ERROR;
                        SectCopyMode=REQ_FAIL;
@@ -1365,7 +1361,7 @@ int Copy_D_PhyOneSect(struct us_data *us)
        }
        else
        {
-               err=SUCCESS;
+               err=SMSUCCESS;
                for(i=0; i<SECTSIZE; i++)
                        WorkBuf[i]=DUMMY_DATA;
                Clr_D_RedundantData(WorkRedund);
@@ -1386,7 +1382,7 @@ int Copy_D_PhyOneSect(struct us_data *us)
        { ErrCode = ERR_WriteFault; return(ERROR); }
 
        Media.PhyBlock=ReadBlock;
-       return(SUCCESS);
+       return(SMSUCCESS);
 }
 
 //SmartMedia Physical Sector Read/Write/Erase Subroutine
@@ -1402,7 +1398,7 @@ int Read_D_PhyOneSect(struct us_data *us, WORD count, BYTE *buf)
        {
                for(i=0; i<SECTSIZE; i++)
                        *buf++=DUMMY_DATA;
-               return(SUCCESS);
+               return(SMSUCCESS);
        }
 
        for(retry=0; retry<2; retry++)
@@ -1424,7 +1420,7 @@ int Read_D_PhyOneSect(struct us_data *us, WORD count, BYTE *buf)
                { ErrCode = ERR_DataStatus; return(ERROR); }
 
                if (!Check_D_ReadError(Redundant))
-                       return(SUCCESS);
+                       return(SMSUCCESS);
 
                if (!Check_D_Correct(buf,Redundant))
                { ErrCode = ERR_CorReadErr; return(ERROR); }
@@ -1446,7 +1442,7 @@ int Write_D_PhyOneSect(PFDO_DEVICE_EXTENSION fdoExt, WORD count, BYTE *buf)
     if (Ssfdc_D_CheckStatus())
     { ErrCode = ERR_WriteFault; return(ERROR); }
 
-    return(SUCCESS);
+    return(SMSUCCESS);
 }
 */
 //----- Erase_D_PhyOneBlock() ------------------------------------------
@@ -1460,7 +1456,7 @@ int Erase_D_PhyOneBlock(struct us_data *us)
        if (Ssfdc_D_CheckStatus())
        { ErrCode = ERR_WriteFault; return(ERROR); }
 
-       return(SUCCESS);
+       return(SMSUCCESS);
 }
 
 //SmartMedia Physical Format Check Local Subroutine
@@ -1544,7 +1540,7 @@ int Set_D_PhyFmtValue(struct us_data *us)
 //       }
 //    }
 
-    return(SUCCESS);
+    return(SMSUCCESS);
 }
 
 //----- Search_D_CIS() -------------------------------------------------
@@ -1600,7 +1596,7 @@ int Search_D_CIS(struct us_data *us)
                        CisArea.PhyBlock=Media.PhyBlock;
                        CisArea.Sector=Media.Sector;
                        Ssfdc_D_Reset(us);
-                       return(SUCCESS);
+                       return(SMSUCCESS);
                }
 
                Media.Sector++;
@@ -1620,7 +1616,8 @@ int Make_D_LogTable(struct us_data *us)
        if (Log2Phy[Media.Zone]==NULL)
        {
                Log2Phy[Media.Zone] = kmalloc(MAX_LOGBLOCK*sizeof(WORD), GFP_KERNEL);
-               //printk("ExAllocatePool Zone = %x, Addr = %x\n", Media.Zone, Log2Phy[Media.Zone]);
+               /* pr_info("ExAllocatePool Zone = %x, Addr = %x\n",
+                               Media.Zone, Log2Phy[Media.Zone]); */
                if (Log2Phy[Media.Zone]==NULL)
                        return(ERROR);
        }
@@ -1630,7 +1627,8 @@ int Make_D_LogTable(struct us_data *us)
        //for(Media.Zone=0; Media.Zone<MAX_ZONENUM; Media.Zone++)
        //for(Media.Zone=0; Media.Zone<Ssfdc.MaxZones; Media.Zone++)
        {
-               //printk("Make_D_LogTable --- MediaZone = 0x%x\n", Media.Zone);
+               /* pr_info("Make_D_LogTable --- MediaZone = 0x%x\n",
+                                                       Media.Zone); */
                for(Media.LogBlock=0; Media.LogBlock<Ssfdc.MaxLogBlocks; Media.LogBlock++)
                        Log2Phy[Media.Zone][Media.LogBlock]=NO_ASSIGN;
 
@@ -1735,7 +1733,7 @@ int Make_D_LogTable(struct us_data *us)
        } // End for (Media.Zone<MAX_ZONENUM)
 
        Ssfdc_D_Reset(us);
-       return(SUCCESS);
+       return(SMSUCCESS);
 }
 
 //----- MarkFail_D_PhyOneBlock() ---------------------------------------
@@ -1763,7 +1761,7 @@ int MarkFail_D_PhyOneBlock(struct us_data *us)
 
        Ssfdc_D_Reset(us);
        Media.Sector=sect;
-       return(SUCCESS);
+       return(SMSUCCESS);
 }
 /*
 //
@@ -1821,7 +1819,7 @@ int MarkFail_D_PhyOneBlock(struct us_data *us)
 //
 //    Ssfdc_D_Reset(fdoExt);
 //
-//    return(SUCCESS);
+//    return(SMSUCCESS);
 //}
 //
 ////----- Media_D_GetMediaInfo() ---------------------------------------
index 4fe47422eb7940865e1a5ce293c3fccfc5771edb..b315d5f8e197ae53ed73898a9d306f8b85279f01 100644 (file)
@@ -42,10 +42,8 @@ struct SSFDCTYPE                Ssfdc;
 struct ADDRESS                  Media;
 struct CIS_AREA                 CisArea;
 
-BYTE                            EccBuf[6];
+static BYTE                            EccBuf[6];
 extern PBYTE                    SMHostAddr;
-extern BYTE                     IsSSFDCCompliance;
-extern BYTE                     IsXDCompliance;
 extern DWORD                    ErrXDCode;
 
 extern WORD  ReadBlock;
@@ -67,7 +65,7 @@ int Check_D_DataBlank(BYTE *redundant)
                if (*redundant++!=0xFF)
                        return(ERROR);
 
-       return(SUCCESS);
+       return(SMSUCCESS);
 }
 
 //----- Check_D_FailBlock() --------------------------------------------
@@ -76,13 +74,13 @@ int Check_D_FailBlock(BYTE *redundant)
        redundant+=REDT_BLOCK;
 
        if (*redundant==0xFF)
-               return(SUCCESS);
+               return(SMSUCCESS);
        if (!*redundant)
                return(ERROR);
        if (hweight8(*redundant)<7)
                return(ERROR);
 
-       return(SUCCESS);
+       return(SMSUCCESS);
 }
 
 //----- Check_D_DataStatus() -------------------------------------------
@@ -91,7 +89,7 @@ int Check_D_DataStatus(BYTE *redundant)
        redundant+=REDT_DATA;
 
        if (*redundant==0xFF)
-               return(SUCCESS);
+               return(SMSUCCESS);
        if (!*redundant)
        {
                ErrXDCode = ERR_DataStatus;
@@ -103,7 +101,7 @@ int Check_D_DataStatus(BYTE *redundant)
        if (hweight8(*redundant)<5)
                return(ERROR);
 
-       return(SUCCESS);
+       return(SMSUCCESS);
 }
 
 //----- Load_D_LogBlockAddr() ------------------------------------------
@@ -118,17 +116,17 @@ int Load_D_LogBlockAddr(BYTE *redundant)
 
        if (addr1==addr2)
                if ((addr1 &0xF000)==0x1000)
-               { Media.LogBlock=(addr1 &0x0FFF)/2; return(SUCCESS); }
+               { Media.LogBlock=(addr1 &0x0FFF)/2; return(SMSUCCESS); }
 
        if (hweight16((WORD)(addr1^addr2))!=0x01) return(ERROR);
 
        if ((addr1 &0xF000)==0x1000)
                if (!(hweight16(addr1) &0x01))
-               { Media.LogBlock=(addr1 &0x0FFF)/2; return(SUCCESS); }
+               { Media.LogBlock=(addr1 &0x0FFF)/2; return(SMSUCCESS); }
 
        if ((addr2 &0xF000)==0x1000)
                if (!(hweight16(addr2) &0x01))
-               { Media.LogBlock=(addr2 &0x0FFF)/2; return(SUCCESS); }
+               { Media.LogBlock=(addr2 &0x0FFF)/2; return(SMSUCCESS); }
 
        return(ERROR);
 }
@@ -222,7 +220,7 @@ int Ssfdc_D_ReadCisSect(struct us_data *us, BYTE *buf,BYTE *redundant)
        }
 
        Media.Zone=zone; Media.PhyBlock=block; Media.Sector=sector;
-       return(SUCCESS);
+       return(SMSUCCESS);
 }
 /*
 ////----- Ssfdc_D_WriteRedtMode() ----------------------------------------
@@ -428,7 +426,7 @@ int Ssfdc_D_ReadBlock(struct us_data *us, WORD count, BYTE *buf,BYTE *redundant)
 //
 //    if (!_Hw_D_ChkCardIn())
 //       return(ERROR);
-//    return(SUCCESS);
+//    return(SMSUCCESS);
 //}
 //
 ////----- Ssfdc_D_ReadSect_PIO() ---------------------------------------------
@@ -451,7 +449,7 @@ int Ssfdc_D_ReadBlock(struct us_data *us, WORD count, BYTE *buf,BYTE *redundant)
 //
 //    _Calc_D_ECCdata(buf);
 //    _Set_D_SsfdcRdStandby();
-//    return(SUCCESS);
+//    return(SMSUCCESS);
 //}
 
 // 6250 CMD 3
@@ -509,7 +507,7 @@ int Ssfdc_D_WriteSect(PFDO_DEVICE_EXTENSION fdoExt, BYTE *buf,BYTE *redundant)
 //        ENE_Print("Error\n");
 //  }
 
-    return(SUCCESS);
+    return(SMSUCCESS);
 }
 */
 //----- Ssfdc_D_CopyBlock() --------------------------------------------
@@ -614,7 +612,7 @@ int Ssfdc_D_WriteBlock(PFDO_DEVICE_EXTENSION fdoExt, WORD count, BYTE *buf,BYTE
 //        ENE_Print("Error\n");
 //  }
 
-    return(SUCCESS);
+    return(SMSUCCESS);
 }
 //
 ////----- Ssfdc_D_WriteSect_DMA() --------------------------------------------
@@ -704,7 +702,7 @@ int Ssfdc_D_WriteBlock(PFDO_DEVICE_EXTENSION fdoExt, WORD count, BYTE *buf,BYTE
 //    if (!_Hw_D_ChkCardIn())
 //       return(ERROR);
 //
-//    return(SUCCESS);
+//    return(SMSUCCESS);
 //}
 //
 ////----- Ssfdc_D_WriteSect_PIO() --------------------------------------------
@@ -729,7 +727,7 @@ int Ssfdc_D_WriteBlock(PFDO_DEVICE_EXTENSION fdoExt, WORD count, BYTE *buf,BYTE
 //
 //    _Set_D_SsfdcWrStandby();
 //    _Set_D_SsfdcRdStandby();
-//    return(SUCCESS);
+//    return(SMSUCCESS);
 //}
 */
 //----- Ssfdc_D_WriteSectForCopy() -------------------------------------
@@ -893,14 +891,14 @@ int Ssfdc_D_WriteRedtData(struct us_data *us, BYTE *redundant)
 int Ssfdc_D_CheckStatus(void)
 {
     // Driver ¤£°µ
-    return(SUCCESS);
+    return(SMSUCCESS);
     //_Set_D_SsfdcRdCmd(RDSTATUS);
     //
     //if (_Check_D_SsfdcStatus())
     //{ _Set_D_SsfdcRdStandby(); return(ERROR); }
     //
     //_Set_D_SsfdcRdStandby();
-    //return(SUCCESS);
+    //return(SMSUCCESS);
 }
 /*
 ////NAND Memory (SmartMedia) Control Subroutine for Read Data
@@ -1095,7 +1093,7 @@ int Ssfdc_D_CheckStatus(void)
 //
 //    do {
 //        if (!_Hw_D_ChkBusy())
-//            return(SUCCESS);
+//            return(SMSUCCESS);
 //        EDelay(100);
 //        count++;
 //    } while (count<=time);
@@ -1109,7 +1107,7 @@ int Ssfdc_D_CheckStatus(void)
 //    if (_Hw_D_InData() & WR_FAIL)
 //        return(ERROR);
 //
-//    return(SUCCESS);
+//    return(SMSUCCESS);
 //}
 //
 //// For 712
@@ -1339,7 +1337,7 @@ int Set_D_SsfdcModel(BYTE dcode)
             return(ERROR);
     }
 
-    return(SUCCESS);
+    return(SMSUCCESS);
 }
 
 //----- _Check_D_DevCode() ---------------------------------------------
@@ -1388,7 +1386,7 @@ BYTE _Check_D_DevCode(BYTE dcode)
 //    if (_Hw_D_ChkPower())
 //    {
 //        _Hw_D_EnableOB();                       // Set SM_REG_CTRL_5 Reg. to 0x83
-//        return(SUCCESS);
+//        return(SMSUCCESS);
 //    }
 //
 //    _Hw_D_SetVccOff();
@@ -1419,7 +1417,7 @@ BYTE _Check_D_DevCode(BYTE dcode)
 //int Check_D_CntPower(void)
 //{
 //    if (_Hw_D_ChkPower())
-//        return(SUCCESS); // Power On
+//        return(SMSUCCESS); // Power On
 //
 //    return(ERROR);       // Power Off
 //}
@@ -1431,7 +1429,7 @@ BYTE _Check_D_DevCode(BYTE dcode)
 //
 //    if (!_Hw_D_ChkStatus()) // Not Status Change
 //        if (_Hw_D_ChkCardIn())
-//            return(SUCCESS); // Card exist in Slot
+//            return(SMSUCCESS); // Card exist in Slot
 //
 //    for(i=0,j=0,k=0; i<16; i++) {
 //        if (_Hw_D_ChkCardIn()) // Status Change
@@ -1444,7 +1442,7 @@ BYTE _Check_D_DevCode(BYTE dcode)
 //        }
 //
 //        if (j>3)
-//            return(SUCCESS); // Card exist in Slot
+//            return(SMSUCCESS); // Card exist in Slot
 //        if (k>3)
 //            return(ERROR); // NO Card exist in Slot
 //
@@ -1460,12 +1458,12 @@ BYTE _Check_D_DevCode(BYTE dcode)
 //    if (_Hw_D_ChkStatus())
 //        return(ERROR); // Status Change
 //
-//    return(SUCCESS);   // Not Status Change
+//    return(SMSUCCESS);   // Not Status Change
 //}
 //
 ////----- Check_D_SsfdcWP() ----------------------------------------------
 //int Check_D_SsfdcWP(void)
-//{ // ERROR: WP, SUCCESS: Not WP
+//{ // ERROR: WP, SMSUCCESS: Not WP
 //    char i;
 //
 //    for(i=0; i<8; i++) {
@@ -1474,7 +1472,7 @@ BYTE _Check_D_DevCode(BYTE dcode)
 //        _Wait_D_Timer(TIME_WPCHK);
 //    }
 //
-//    return(SUCCESS);
+//    return(SMSUCCESS);
 //}
 //
 */
@@ -1482,13 +1480,13 @@ BYTE _Check_D_DevCode(BYTE dcode)
 //----- Check_D_ReadError() ----------------------------------------------
 int Check_D_ReadError(BYTE *redundant)
 {
-       return SUCCESS;
+       return SMSUCCESS;
 }
 
 //----- Check_D_Correct() ----------------------------------------------
 int Check_D_Correct(BYTE *buf,BYTE *redundant)
 {
-       return SUCCESS;
+       return SMSUCCESS;
 }
 
 //----- Check_D_CISdata() ----------------------------------------------
@@ -1500,7 +1498,7 @@ int Check_D_CISdata(BYTE *buf, BYTE *redundant)
        int cis_len = sizeof(cis);
 
        if (!IsSSFDCCompliance && !IsXDCompliance)
-               return SUCCESS;
+               return SMSUCCESS;
 
        if (!memcmp(redundant + 0x0D, EccBuf, 3))
                return memcmp(buf, cis, cis_len);
@@ -1599,5 +1597,5 @@ int SM_ReadBlock(PFDO_DEVICE_EXTENSION fdoExt, BYTE *buf,BYTE *redundant)
     if (!NT_SUCCESS(ntStatus))
        return(ERROR);
 
-    return(SUCCESS);
+    return(SMSUCCESS);
 }*/
index 62116869b38aaa67994fbfbbb43f6eb220fa885c..a6fa77f9c48e08f29e28133234bf66f377f1e4c7 100644 (file)
@@ -20,8 +20,6 @@ int SM_SCSI_Read_Capacity   (struct us_data *us, struct scsi_cmnd *srb);
 int SM_SCSI_Read            (struct us_data *us, struct scsi_cmnd *srb);
 int SM_SCSI_Write           (struct us_data *us, struct scsi_cmnd *srb);
 
-extern struct SSFDCTYPE     Ssfdc;
-extern struct ADDRESS       Media;
 extern PBYTE                SMHostAddr;
 extern DWORD                ErrXDCode;
 
index a53402f36044e9fd06775286320499b12363eb7f..0274cb0edd01652b4be420905dbfdb91eaf70585 100644 (file)
@@ -1,3 +1,5 @@
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/sched.h>
 #include <linux/errno.h>
 #include <linux/slab.h>
 /***********************************************************************
  * Data transfer routines
  ***********************************************************************/
-//----- usb_stor_blocking_completion() ---------------------
+/*
+ * usb_stor_blocking_completion()
+ */
 static void usb_stor_blocking_completion(struct urb *urb)
 {
        struct completion *urb_done_ptr = urb->context;
 
-       //printk("transport --- usb_stor_blocking_completion\n");
+       /* pr_info("transport --- usb_stor_blocking_completion\n"); */
        complete(urb_done_ptr);
 }
 
-//----- usb_stor_msg_common() ---------------------
+/*
+ * usb_stor_msg_common()
+ */
 static int usb_stor_msg_common(struct us_data *us, int timeout)
 {
        struct completion urb_done;
        long timeleft;
        int status;
 
-       //printk("transport --- usb_stor_msg_common\n");
+       /* pr_info("transport --- usb_stor_msg_common\n"); */
        if (test_bit(US_FLIDX_ABORTING, &us->dflags))
                return -EIO;
 
@@ -52,35 +58,36 @@ static int usb_stor_msg_common(struct us_data *us, int timeout)
 
        set_bit(US_FLIDX_URB_ACTIVE, &us->dflags);
 
-       if (test_bit(US_FLIDX_ABORTING, &us->dflags))
-       {
-               if (test_and_clear_bit(US_FLIDX_URB_ACTIVE, &us->dflags))
-               {
-                       //printk("-- cancelling URB\n");
+       if (test_bit(US_FLIDX_ABORTING, &us->dflags)) {
+               if (test_and_clear_bit(US_FLIDX_URB_ACTIVE, &us->dflags)) {
+                       /* pr_info("-- cancelling URB\n"); */
                        usb_unlink_urb(us->current_urb);
                }
        }
 
-       timeleft = wait_for_completion_interruptible_timeout(&urb_done, timeout ? : MAX_SCHEDULE_TIMEOUT);
+       timeleft = wait_for_completion_interruptible_timeout(&urb_done,
+                                       timeout ? : MAX_SCHEDULE_TIMEOUT);
        clear_bit(US_FLIDX_URB_ACTIVE, &us->dflags);
 
-       if (timeleft <= 0)
-       {
-               //printk("%s -- cancelling URB\n", timeleft == 0 ? "Timeout" : "Signal");
+       if (timeleft <= 0) {
+               /* pr_info("%s -- cancelling URB\n",
+                       timeleft == 0 ? "Timeout" : "Signal"); */
                usb_kill_urb(us->current_urb);
        }
 
        return us->current_urb->status;
 }
 
-//----- usb_stor_control_msg() ---------------------
+/*
+ * usb_stor_control_msg()
+ */
 int usb_stor_control_msg(struct us_data *us, unsigned int pipe,
                 u8 request, u8 requesttype, u16 value, u16 index,
                 void *data, u16 size, int timeout)
 {
        int status;
 
-       //printk("transport --- usb_stor_control_msg\n");
+       /* pr_info("transport --- usb_stor_control_msg\n"); */
 
        /* fill in the devrequest structure */
        us->cr->bRequestType = requesttype;
@@ -91,7 +98,7 @@ int usb_stor_control_msg(struct us_data *us, unsigned int pipe,
 
        /* fill and submit the URB */
        usb_fill_control_urb(us->current_urb, us->pusb_dev, pipe,
-                        (unsigned char*) us->cr, data, size,
+                        (unsigned char *) us->cr, data, size,
                         usb_stor_blocking_completion, NULL);
        status = usb_stor_msg_common(us, timeout);
 
@@ -101,14 +108,16 @@ int usb_stor_control_msg(struct us_data *us, unsigned int pipe,
        return status;
 }
 
-//----- usb_stor_clear_halt() ---------------------
+/*
+ * usb_stor_clear_halt()
+ */
 int usb_stor_clear_halt(struct us_data *us, unsigned int pipe)
 {
        int result;
        int endp = usb_pipeendpoint(pipe);
 
-       //printk("transport --- usb_stor_clear_halt\n");
-       if (usb_pipein (pipe))
+       /* pr_info("transport --- usb_stor_clear_halt\n"); */
+       if (usb_pipein(pipe))
                endp |= USB_DIR_IN;
 
        result = usb_stor_control_msg(us, us->send_ctrl_pipe,
@@ -118,103 +127,109 @@ int usb_stor_clear_halt(struct us_data *us, unsigned int pipe)
 
        /* reset the endpoint toggle */
        if (result >= 0)
-               //usb_settoggle(us->pusb_dev, usb_pipeendpoint(pipe), usb_pipeout(pipe), 0);
-                usb_reset_endpoint(us->pusb_dev, endp);
+               /* usb_settoggle(us->pusb_dev, usb_pipeendpoint(pipe),
+                                               usb_pipeout(pipe), 0); */
+               usb_reset_endpoint(us->pusb_dev, endp);
 
        return result;
 }
 
-//----- interpret_urb_result() ---------------------
+/*
+ * interpret_urb_result()
+ */
 static int interpret_urb_result(struct us_data *us, unsigned int pipe,
                unsigned int length, int result, unsigned int partial)
 {
-       //printk("transport --- interpret_urb_result\n");
+       /* pr_info("transport --- interpret_urb_result\n"); */
        switch (result) {
        /* no error code; did we send all the data? */
        case 0:
-               if (partial != length)
-               {
-                       //printk("-- short transfer\n");
+               if (partial != length) {
+                       /* pr_info("-- short transfer\n"); */
                        return USB_STOR_XFER_SHORT;
                }
-               //printk("-- transfer complete\n");
+               /* pr_info("-- transfer complete\n"); */
                return USB_STOR_XFER_GOOD;
        case -EPIPE:
-               if (usb_pipecontrol(pipe))
-               {
-                       //printk("-- stall on control pipe\n");
+               if (usb_pipecontrol(pipe)) {
+                       /* pr_info("-- stall on control pipe\n"); */
                        return USB_STOR_XFER_STALLED;
                }
-               //printk("clearing endpoint halt for pipe 0x%x\n", pipe);
+               /* pr_info("clearing endpoint halt for pipe 0x%x\n", pipe); */
                if (usb_stor_clear_halt(us, pipe) < 0)
                        return USB_STOR_XFER_ERROR;
                return USB_STOR_XFER_STALLED;
        case -EOVERFLOW:
-               //printk("-- babble\n");
+               /* pr_info("-- babble\n"); */
                return USB_STOR_XFER_LONG;
        case -ECONNRESET:
-               //printk("-- transfer cancelled\n");
+               /* pr_info("-- transfer cancelled\n"); */
                return USB_STOR_XFER_ERROR;
        case -EREMOTEIO:
-               //printk("-- short read transfer\n");
+               /* pr_info("-- short read transfer\n"); */
                return USB_STOR_XFER_SHORT;
        case -EIO:
-               //printk("-- abort or disconnect in progress\n");
+               /* pr_info("-- abort or disconnect in progress\n"); */
                return USB_STOR_XFER_ERROR;
        default:
-               //printk("-- unknown error\n");
+               /* pr_info("-- unknown error\n"); */
                return USB_STOR_XFER_ERROR;
        }
 }
 
-//----- usb_stor_bulk_transfer_buf() ---------------------
+/*
+ * usb_stor_bulk_transfer_buf()
+ */
 int usb_stor_bulk_transfer_buf(struct us_data *us, unsigned int pipe,
        void *buf, unsigned int length, unsigned int *act_len)
 {
        int result;
 
-       //printk("transport --- usb_stor_bulk_transfer_buf\n");
+       /* pr_info("transport --- usb_stor_bulk_transfer_buf\n"); */
 
        /* fill and submit the URB */
-       usb_fill_bulk_urb(us->current_urb, us->pusb_dev, pipe, buf, length, usb_stor_blocking_completion, NULL);
+       usb_fill_bulk_urb(us->current_urb, us->pusb_dev, pipe, buf,
+                               length, usb_stor_blocking_completion, NULL);
        result = usb_stor_msg_common(us, 0);
 
        /* store the actual length of the data transferred */
        if (act_len)
                *act_len = us->current_urb->actual_length;
 
-       return interpret_urb_result(us, pipe, length, result, us->current_urb->actual_length);
+       return interpret_urb_result(us, pipe, length, result,
+                                       us->current_urb->actual_length);
 }
 
-//----- usb_stor_bulk_transfer_sglist() ---------------------
+/*
+ * usb_stor_bulk_transfer_sglist()
+ */
 static int usb_stor_bulk_transfer_sglist(struct us_data *us, unsigned int pipe,
                struct scatterlist *sg, int num_sg, unsigned int length,
                unsigned int *act_len)
 {
        int result;
 
-       //printk("transport --- usb_stor_bulk_transfer_sglist\n");
+       /* pr_info("transport --- usb_stor_bulk_transfer_sglist\n"); */
        if (test_bit(US_FLIDX_ABORTING, &us->dflags))
                return USB_STOR_XFER_ERROR;
 
        /* initialize the scatter-gather request block */
-       result = usb_sg_init(&us->current_sg, us->pusb_dev, pipe, 0, sg, num_sg, length, GFP_NOIO);
-       if (result)
-       {
-               //printk("usb_sg_init returned %d\n", result);
+       result = usb_sg_init(&us->current_sg, us->pusb_dev, pipe, 0,
+                                       sg, num_sg, length, GFP_NOIO);
+       if (result) {
+               /* pr_info("usb_sg_init returned %d\n", result); */
                return USB_STOR_XFER_ERROR;
        }
 
-       /* since the block has been initialized successfully, it's now okay to cancel it */
+       /* since the block has been initialized successfully,
+                                       it's now okay to cancel it */
        set_bit(US_FLIDX_SG_ACTIVE, &us->dflags);
 
        /* did an abort/disconnect occur during the submission? */
-       if (test_bit(US_FLIDX_ABORTING, &us->dflags))
-       {
+       if (test_bit(US_FLIDX_ABORTING, &us->dflags)) {
                /* cancel the request, if it hasn't been cancelled already */
-               if (test_and_clear_bit(US_FLIDX_SG_ACTIVE, &us->dflags))
-               {
-                       //printk("-- cancelling sg request\n");
+               if (test_and_clear_bit(US_FLIDX_SG_ACTIVE, &us->dflags)) {
+                       /* pr_info("-- cancelling sg request\n"); */
                        usb_sg_cancel(&us->current_sg);
                }
        }
@@ -227,11 +242,15 @@ static int usb_stor_bulk_transfer_sglist(struct us_data *us, unsigned int pipe,
        if (act_len)
                *act_len = us->current_sg.bytes;
 
-       return interpret_urb_result(us, pipe, length, result, us->current_sg.bytes);
+       return interpret_urb_result(us, pipe, length,
+                                       result, us->current_sg.bytes);
 }
 
-//----- usb_stor_bulk_srb() ---------------------
-int usb_stor_bulk_srb(struct us_data* us, unsigned int pipe, struct scsi_cmnd* srb)
+/*
+ * usb_stor_bulk_srb()
+ */
+int usb_stor_bulk_srb(struct us_data *us, unsigned int pipe,
+                                       struct scsi_cmnd *srb)
 {
        unsigned int partial;
        int result = usb_stor_bulk_transfer_sglist(us, pipe, scsi_sglist(srb),
@@ -242,27 +261,27 @@ int usb_stor_bulk_srb(struct us_data* us, unsigned int pipe, struct scsi_cmnd* s
        return result;
 }
 
-//----- usb_stor_bulk_transfer_sg() ---------------------
-int usb_stor_bulk_transfer_sg(struct us_data* us, unsigned int pipe,
+/*
+ * usb_stor_bulk_transfer_sg()
+ */
+int usb_stor_bulk_transfer_sg(struct us_data *us, unsigned int pipe,
                void *buf, unsigned int length_left, int use_sg, int *residual)
 {
        int result;
        unsigned int partial;
 
-       //printk("transport --- usb_stor_bulk_transfer_sg\n");
+       /* pr_info("transport --- usb_stor_bulk_transfer_sg\n"); */
        /* are we scatter-gathering? */
-       if (use_sg)
-       {
+       if (use_sg) {
                /* use the usb core scatter-gather primitives */
                result = usb_stor_bulk_transfer_sglist(us, pipe,
                                (struct scatterlist *) buf, use_sg,
                                length_left, &partial);
                length_left -= partial;
-       }
-       else
-       {
+       } else {
                /* no scatter-gather, just make the request */
-               result = usb_stor_bulk_transfer_buf(us, pipe, buf, length_left, &partial);
+               result = usb_stor_bulk_transfer_buf(us, pipe, buf,
+                                                       length_left, &partial);
                length_left -= partial;
        }
 
@@ -275,37 +294,37 @@ int usb_stor_bulk_transfer_sg(struct us_data* us, unsigned int pipe,
 /***********************************************************************
  * Transport routines
  ***********************************************************************/
-//----- usb_stor_invoke_transport() ---------------------
+/*
+ * usb_stor_invoke_transport()
+ */
 void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
 {
        int need_auto_sense;
        int result;
 
-       //printk("transport --- usb_stor_invoke_transport\n");
+       /* pr_info("transport --- usb_stor_invoke_transport\n"); */
        usb_stor_print_cmd(srb);
        /* send the command to the transport layer */
        scsi_set_resid(srb, 0);
-       result = us->transport(srb, us); //usb_stor_Bulk_transport;
-       
-       /* if the command gets aborted by the higher layers, we need to short-circuit all other processing */
-       if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags))
-       {
-               //printk("-- command was aborted\n");
+       result = us->transport(srb, us); /* usb_stor_Bulk_transport; */
+
+       /* if the command gets aborted by the higher layers,
+               we need to short-circuit all other processing */
+       if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags)) {
+               /* pr_info("-- command was aborted\n"); */
                srb->result = DID_ABORT << 16;
                goto Handle_Errors;
        }
 
        /* if there is a transport error, reset and don't auto-sense */
-       if (result == USB_STOR_TRANSPORT_ERROR)
-       {
-               //printk("-- transport indicates error, resetting\n");
+       if (result == USB_STOR_TRANSPORT_ERROR) {
+               /* pr_info("-- transport indicates error, resetting\n"); */
                srb->result = DID_ERROR << 16;
                goto Handle_Errors;
        }
 
        /* if the transport provided its own sense data, don't auto-sense */
-       if (result == USB_STOR_TRANSPORT_NO_SENSE)
-       {
+       if (result == USB_STOR_TRANSPORT_NO_SENSE) {
                srb->result = SAM_STAT_CHECK_CONDITION;
                return;
        }
@@ -315,34 +334,34 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
        /* Determine if we need to auto-sense */
        need_auto_sense = 0;
 
-       if ((us->protocol == USB_PR_CB || us->protocol == USB_PR_DPCM_USB) && srb->sc_data_direction != DMA_FROM_DEVICE)
-       {
-               //printk("-- CB transport device requiring auto-sense\n");
+       if ((us->protocol == USB_PR_CB || us->protocol == USB_PR_DPCM_USB) &&
+                               srb->sc_data_direction != DMA_FROM_DEVICE) {
+               /* pr_info("-- CB transport device requiring auto-sense\n"); */
                need_auto_sense = 1;
        }
 
-       if (result == USB_STOR_TRANSPORT_FAILED)
-       {
-               //printk("-- transport indicates command failure\n");
+       if (result == USB_STOR_TRANSPORT_FAILED) {
+               /* pr_info("-- transport indicates command failure\n"); */
                need_auto_sense = 1;
        }
 
        /* Now, if we need to do the auto-sense, let's do it */
-       if (need_auto_sense)
-       {
+       if (need_auto_sense) {
                int temp_result;
                struct scsi_eh_save ses;
 
-               printk("Issuing auto-REQUEST_SENSE\n");
+               pr_info("Issuing auto-REQUEST_SENSE\n");
 
                scsi_eh_prep_cmnd(srb, &ses, NULL, 0, US_SENSE_SIZE);
 
                /* we must do the protocol translation here */
-               if (us->subclass == USB_SC_RBC || us->subclass == USB_SC_SCSI || us->subclass == USB_SC_CYP_ATACB)
+               if (us->subclass == USB_SC_RBC ||
+                       us->subclass == USB_SC_SCSI ||
+                       us->subclass == USB_SC_CYP_ATACB) {
                        srb->cmd_len = 6;
-               else
+               } else {
                        srb->cmd_len = 12;
-
+               }
                /* issue the auto-sense command */
                scsi_set_resid(srb, 0);
                temp_result = us->transport(us->srb, us);
@@ -350,15 +369,13 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
                /* let's clean up right away */
                scsi_eh_restore_cmnd(srb, &ses);
 
-               if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags))
-               {
-                       //printk("-- auto-sense aborted\n");
+               if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags)) {
+                       /* pr_info("-- auto-sense aborted\n"); */
                        srb->result = DID_ABORT << 16;
                        goto Handle_Errors;
                }
-               if (temp_result != USB_STOR_TRANSPORT_GOOD)
-               {
-                       //printk("-- auto-sense failure\n");
+               if (temp_result != USB_STOR_TRANSPORT_GOOD) {
+                       /* pr_info("-- auto-sense failure\n"); */
                        srb->result = DID_ERROR << 16;
                        if (!(us->fflags & US_FL_SCM_MULT_TARG))
                                goto Handle_Errors;
@@ -371,16 +388,17 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
                if (result == USB_STOR_TRANSPORT_GOOD &&
                        (srb->sense_buffer[2] & 0xaf) == 0 &&
                        srb->sense_buffer[12] == 0 &&
-                       srb->sense_buffer[13] == 0)
-               {
+                       srb->sense_buffer[13] == 0) {
                        srb->result = SAM_STAT_GOOD;
                        srb->sense_buffer[0] = 0x0;
                }
        }
 
        /* Did we transfer less than the minimum amount required? */
-       if (srb->result == SAM_STAT_GOOD &&     scsi_bufflen(srb) - scsi_get_resid(srb) < srb->underflow)
-               srb->result = (DID_ERROR << 16);//v02 | (SUGGEST_RETRY << 24);
+       if (srb->result == SAM_STAT_GOOD && scsi_bufflen(srb) -
+                               scsi_get_resid(srb) < srb->underflow)
+               srb->result = (DID_ERROR << 16);
+               /* v02 | (SUGGEST_RETRY << 24); */
 
        return;
 
@@ -394,8 +412,7 @@ Handle_Errors:
        result = usb_stor_port_reset(us);
        mutex_lock(&us->dev_mutex);
 
-       if (result < 0)
-       {
+       if (result < 0) {
                scsi_lock(us_to_host(us));
                usb_stor_report_device_reset(us);
                scsi_unlock(us_to_host(us));
@@ -404,61 +421,64 @@ Handle_Errors:
        clear_bit(US_FLIDX_RESETTING, &us->dflags);
 }
 
-//----- ENE_stor_invoke_transport() ---------------------
+/*
+ * ENE_stor_invoke_transport()
+ */
 void ENE_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
 {
-       int result=0;
+       int result = 0;
 
-       //printk("transport --- ENE_stor_invoke_transport\n");
+       /* pr_info("transport --- ENE_stor_invoke_transport\n"); */
        usb_stor_print_cmd(srb);
        /* send the command to the transport layer */
        scsi_set_resid(srb, 0);
        if (!(us->MS_Status.Ready || us->SM_Status.Ready))
                result = ENE_InitMedia(us);
-       
+
        if (us->Power_IsResum == true) {
                result = ENE_InitMedia(us);
-               us->Power_IsResum = false;              
-       }       
-       
-       if (us->MS_Status.Ready)        result = MS_SCSIIrp(us, srb);
-       if (us->SM_Status.Ready)        result = SM_SCSIIrp(us, srb);
-
-       /* if the command gets aborted by the higher layers, we need to short-circuit all other processing */
-       if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags))
-       {
-               //printk("-- command was aborted\n");
+               us->Power_IsResum = false;
+       }
+
+       if (us->MS_Status.Ready)
+               result = MS_SCSIIrp(us, srb);
+       if (us->SM_Status.Ready)
+               result = SM_SCSIIrp(us, srb);
+
+       /* if the command gets aborted by the higher layers,
+               we need to short-circuit all other processing */
+       if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags)) {
+               /* pr_info("-- command was aborted\n"); */
                srb->result = DID_ABORT << 16;
                goto Handle_Errors;
        }
 
        /* if there is a transport error, reset and don't auto-sense */
-       if (result == USB_STOR_TRANSPORT_ERROR)
-       {
-               //printk("-- transport indicates error, resetting\n");
+       if (result == USB_STOR_TRANSPORT_ERROR) {
+               /* pr_info("-- transport indicates error, resetting\n"); */
                srb->result = DID_ERROR << 16;
                goto Handle_Errors;
        }
 
        /* if the transport provided its own sense data, don't auto-sense */
-       if (result == USB_STOR_TRANSPORT_NO_SENSE)
-       {
+       if (result == USB_STOR_TRANSPORT_NO_SENSE) {
                srb->result = SAM_STAT_CHECK_CONDITION;
                return;
        }
 
        srb->result = SAM_STAT_GOOD;
-       if (result == USB_STOR_TRANSPORT_FAILED)
-       {
-               //printk("-- transport indicates command failure\n");
-               //need_auto_sense = 1;
+       if (result == USB_STOR_TRANSPORT_FAILED) {
+               /* pr_info("-- transport indicates command failure\n"); */
+               /* need_auto_sense = 1; */
                BuildSenseBuffer(srb, us->SrbStatus);
                srb->result = SAM_STAT_CHECK_CONDITION;
        }
 
        /* Did we transfer less than the minimum amount required? */
-       if (srb->result == SAM_STAT_GOOD && scsi_bufflen(srb) - scsi_get_resid(srb) < srb->underflow)
-               srb->result = (DID_ERROR << 16);//v02 | (SUGGEST_RETRY << 24);
+       if (srb->result == SAM_STAT_GOOD && scsi_bufflen(srb) -
+                                       scsi_get_resid(srb) < srb->underflow)
+               srb->result = (DID_ERROR << 16);
+               /* v02 | (SUGGEST_RETRY << 24); */
 
        return;
 
@@ -472,8 +492,7 @@ Handle_Errors:
        result = usb_stor_port_reset(us);
        mutex_lock(&us->dev_mutex);
 
-       if (result < 0)
-       {
+       if (result < 0) {
                scsi_lock(us_to_host(us));
                usb_stor_report_device_reset(us);
                scsi_unlock(us_to_host(us));
@@ -482,52 +501,63 @@ Handle_Errors:
        clear_bit(US_FLIDX_RESETTING, &us->dflags);
 }
 
-//----- BuildSenseBuffer() -------------------------------------------
+/*
+ * BuildSenseBuffer()
+ */
 void BuildSenseBuffer(struct scsi_cmnd *srb, int SrbStatus)
 {
-    BYTE    *buf = srb->sense_buffer;
-    BYTE    asc;
-
-    printk("transport --- BuildSenseBuffer\n");
-    switch (SrbStatus)
-    {
-        case SS_NOT_READY:        asc = 0x3a;    break;  // sense key = 0x02
-        case SS_MEDIUM_ERR:       asc = 0x0c;    break;  // sense key = 0x03
-        case SS_ILLEGAL_REQUEST:  asc = 0x20;    break;  // sense key = 0x05
-        default:                  asc = 0x00;    break;  // ??
-    }
-
-    memset(buf, 0, 18);
-    buf[0x00] = 0xf0;
-    buf[0x02] = SrbStatus;
-    buf[0x07] = 0x0b;
-    buf[0x0c] = asc;
+       BYTE    *buf = srb->sense_buffer;
+       BYTE    asc;
+
+       pr_info("transport --- BuildSenseBuffer\n");
+       switch (SrbStatus) {
+       case SS_NOT_READY:
+               asc = 0x3a;
+               break;  /*  sense key = 0x02 */
+       case SS_MEDIUM_ERR:
+               asc = 0x0c;
+               break;  /*  sense key = 0x03 */
+       case SS_ILLEGAL_REQUEST:
+               asc = 0x20;
+               break;  /*  sense key = 0x05 */
+       default:
+               asc = 0x00;
+               break;  /*  ?? */
+       }
+
+       memset(buf, 0, 18);
+       buf[0x00] = 0xf0;
+       buf[0x02] = SrbStatus;
+       buf[0x07] = 0x0b;
+       buf[0x0c] = asc;
 }
 
-//----- usb_stor_stop_transport() ---------------------
+/*
+ * usb_stor_stop_transport()
+ */
 void usb_stor_stop_transport(struct us_data *us)
 {
-       //printk("transport --- usb_stor_stop_transport\n");
+       /* pr_info("transport --- usb_stor_stop_transport\n"); */
 
-       if (test_and_clear_bit(US_FLIDX_URB_ACTIVE, &us->dflags))
-       {
-               //printk("-- cancelling URB\n");
+       if (test_and_clear_bit(US_FLIDX_URB_ACTIVE, &us->dflags)) {
+               /* pr_info("-- cancelling URB\n"); */
                usb_unlink_urb(us->current_urb);
        }
 
-       if (test_and_clear_bit(US_FLIDX_SG_ACTIVE, &us->dflags))
-       {
-               //printk("-- cancelling sg request\n");
+       if (test_and_clear_bit(US_FLIDX_SG_ACTIVE, &us->dflags)) {
+               /* pr_info("-- cancelling sg request\n"); */
                usb_sg_cancel(&us->current_sg);
        }
 }
 
-//----- usb_stor_Bulk_max_lun() ---------------------
+/*
+ * usb_stor_Bulk_max_lun()
+ */
 int usb_stor_Bulk_max_lun(struct us_data *us)
 {
        int result;
 
-       //printk("transport --- usb_stor_Bulk_max_lun\n");
+       /* pr_info("transport --- usb_stor_Bulk_max_lun\n"); */
        /* issue the command */
        us->iobuf[0] = 0;
        result = usb_stor_control_msg(us, us->recv_ctrl_pipe,
@@ -536,7 +566,8 @@ int usb_stor_Bulk_max_lun(struct us_data *us)
                                 USB_RECIP_INTERFACE,
                                 0, us->ifnum, us->iobuf, 1, HZ);
 
-       //printk("GetMaxLUN command result is %d, data is %d\n", result, us->iobuf[0]);
+       /* pr_info("GetMaxLUN command result is %d, data is %d\n",
+                                               result, us->iobuf[0]); */
 
        /* if we have a successful request, return the result */
        if (result > 0)
@@ -545,7 +576,9 @@ int usb_stor_Bulk_max_lun(struct us_data *us)
        return 0;
 }
 
-//----- usb_stor_Bulk_transport() ---------------------
+/*
+ * usb_stor_Bulk_transport()
+ */
 int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us)
 {
        struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
@@ -557,10 +590,9 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us)
        unsigned int cswlen;
        unsigned int cbwlen = US_BULK_CB_WRAP_LEN;
 
-       //printk("transport --- usb_stor_Bulk_transport\n");
+       /* pr_info("transport --- usb_stor_Bulk_transport\n"); */
        /* Take care of BULK32 devices; set extra byte to 0 */
-       if (unlikely(us->fflags & US_FL_BULK32))
-       {
+       if (unlikely(us->fflags & US_FL_BULK32)) {
                cbwlen = 32;
                us->iobuf[31] = 0;
        }
@@ -579,27 +611,32 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us)
        memset(bcb->CDB, 0, sizeof(bcb->CDB));
        memcpy(bcb->CDB, srb->cmnd, bcb->Length);
 
-       // send command
+       /*  send command */
        /* send it to out endpoint */
-       /*printk("Bulk Command S 0x%x T 0x%x L %d F %d Trg %d LUN %d CL %d\n",
+       /* pr_info("Bulk Command S 0x%x T 0x%x L %d F %d Trg %d LUN %d CL %d\n",
                        le32_to_cpu(bcb->Signature), bcb->Tag,
                        le32_to_cpu(bcb->DataTransferLength), bcb->Flags,
                        (bcb->Lun >> 4), (bcb->Lun & 0x0F),
-                       bcb->Length);*/
-       result = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe, bcb, cbwlen, NULL);
-       //printk("Bulk command transfer result=%d\n", result);
+                       bcb->Length); */
+       result = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe,
+                                               bcb, cbwlen, NULL);
+       /* pr_info("Bulk command transfer result=%d\n", result); */
        if (result != USB_STOR_XFER_GOOD)
                return USB_STOR_TRANSPORT_ERROR;
 
        if (unlikely(us->fflags & US_FL_GO_SLOW))
                udelay(125);
 
-       // R/W data
-       if (transfer_length)
-       {
-               unsigned int pipe = srb->sc_data_direction == DMA_FROM_DEVICE ? us->recv_bulk_pipe : us->send_bulk_pipe;
+       /*  R/W data */
+       if (transfer_length) {
+               unsigned int pipe;
+               if (srb->sc_data_direction == DMA_FROM_DEVICE)
+                       pipe = us->recv_bulk_pipe;
+               else
+                       pipe = us->send_bulk_pipe;
+
                result = usb_stor_bulk_srb(us, pipe, srb);
-               //printk("Bulk data transfer result 0x%x\n", result);
+               /* pr_info("Bulk data transfer result 0x%x\n", result); */
                if (result == USB_STOR_XFER_ERROR)
                        return USB_STOR_TRANSPORT_ERROR;
 
@@ -608,55 +645,56 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us)
        }
 
        /* get CSW for device status */
-       //printk("Attempting to get CSW...\n");
-       result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, bcs, US_BULK_CS_WRAP_LEN, &cswlen);
+       /* pr_info("Attempting to get CSW...\n"); */
+       result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, bcs,
+                                               US_BULK_CS_WRAP_LEN, &cswlen);
 
-       if (result == USB_STOR_XFER_SHORT && cswlen == 0)
-       {
-               //printk("Received 0-length CSW; retrying...\n");
-               result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, bcs, US_BULK_CS_WRAP_LEN, &cswlen);
+       if (result == USB_STOR_XFER_SHORT && cswlen == 0) {
+               /* pr_info("Received 0-length CSW; retrying...\n"); */
+               result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, bcs,
+                                               US_BULK_CS_WRAP_LEN, &cswlen);
        }
 
        /* did the attempt to read the CSW fail? */
-       if (result == USB_STOR_XFER_STALLED)
-       {
+       if (result == USB_STOR_XFER_STALLED) {
                /* get the status again */
-               //printk("Attempting to get CSW (2nd try)...\n");
-               result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, bcs, US_BULK_CS_WRAP_LEN, NULL);
+               /* pr_info("Attempting to get CSW (2nd try)...\n"); */
+               result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, bcs,
+                                               US_BULK_CS_WRAP_LEN, NULL);
        }
 
        /* if we still have a failure at this point, we're in trouble */
-       //printk("Bulk status result = %d\n", result);
+       /* pr_info("Bulk status result = %d\n", result); */
        if (result != USB_STOR_XFER_GOOD)
                return USB_STOR_TRANSPORT_ERROR;
 
        /* check bulk status */
        residue = le32_to_cpu(bcs->Residue);
-       //printk("Bulk Status S 0x%x T 0x%x R %u Stat 0x%x\n", le32_to_cpu(bcs->Signature), bcs->Tag, residue, bcs->Status);
-       if (!(bcs->Tag == us->tag || (us->fflags & US_FL_BULK_IGNORE_TAG)) || bcs->Status > US_BULK_STAT_PHASE)
-       {
-               //printk("Bulk logical error\n");
+       /* pr_info("Bulk Status S 0x%x T 0x%x R %u Stat 0x%x\n",
+                               le32_to_cpu(bcs->Signature),
+                               bcs->Tag, residue, bcs->Status); */
+       if (!(bcs->Tag == us->tag ||
+               (us->fflags & US_FL_BULK_IGNORE_TAG)) ||
+               bcs->Status > US_BULK_STAT_PHASE) {
+               /* pr_info("Bulk logical error\n"); */
                return USB_STOR_TRANSPORT_ERROR;
        }
 
-       if (!us->bcs_signature)
-       {
+       if (!us->bcs_signature) {
                us->bcs_signature = bcs->Signature;
-               //if (us->bcs_signature != cpu_to_le32(US_BULK_CS_SIGN))
-               //      printk("Learnt BCS signature 0x%08X\n", le32_to_cpu(us->bcs_signature));
-       }
-       else if (bcs->Signature != us->bcs_signature)
-       {
-               /*printk("Signature mismatch: got %08X, expecting %08X\n",
+               /* if (us->bcs_signature != cpu_to_le32(US_BULK_CS_SIGN)) */
+               /* pr_info("Learnt BCS signature 0x%08X\n",
+                               le32_to_cpu(us->bcs_signature)); */
+       } else if (bcs->Signature != us->bcs_signature) {
+               /* pr_info("Signature mismatch: got %08X, expecting %08X\n",
                          le32_to_cpu(bcs->Signature),
-                         le32_to_cpu(us->bcs_signature));*/
+                         le32_to_cpu(us->bcs_signature)); */
                return USB_STOR_TRANSPORT_ERROR;
        }
 
        /* try to compute the actual residue, based on how much data
         * was really transferred and what the device tells us */
-       if (residue && !(us->fflags & US_FL_IGNORE_RESIDUE))
-       {
+       if (residue && !(us->fflags & US_FL_IGNORE_RESIDUE)) {
 
                /* Heuristically detect devices that generate bogus residues
                 * by seeing what happens with INQUIRY and READ CAPACITY
@@ -667,34 +705,31 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us)
                                        ((srb->cmnd[0] == INQUIRY &&
                                                transfer_length == 36) ||
                                        (srb->cmnd[0] == READ_CAPACITY &&
-                                               transfer_length == 8)))
-               {
+                                               transfer_length == 8))) {
                        us->fflags |= US_FL_IGNORE_RESIDUE;
 
-               }
-               else
-               {
+               } else {
                        residue = min(residue, transfer_length);
-                       scsi_set_resid(srb, max(scsi_get_resid(srb), (int) residue));
+                       scsi_set_resid(srb, max(scsi_get_resid(srb),
+                                                       (int) residue));
                }
        }
 
        /* based on the status code, we report good or bad */
-       switch (bcs->Status)
-       {
-               case US_BULK_STAT_OK:
-                       if (fake_sense)
-                       {
-                               memcpy(srb->sense_buffer, usb_stor_sense_invalidCDB, sizeof(usb_stor_sense_invalidCDB));
-                               return USB_STOR_TRANSPORT_NO_SENSE;
-                       }
-                       return USB_STOR_TRANSPORT_GOOD;
-
-               case US_BULK_STAT_FAIL:
-                       return USB_STOR_TRANSPORT_FAILED;
-
-               case US_BULK_STAT_PHASE:
-                       return USB_STOR_TRANSPORT_ERROR;
+       switch (bcs->Status) {
+       case US_BULK_STAT_OK:
+               if (fake_sense) {
+                       memcpy(srb->sense_buffer, usb_stor_sense_invalidCDB,
+                                       sizeof(usb_stor_sense_invalidCDB));
+                       return USB_STOR_TRANSPORT_NO_SENSE;
+               }
+               return USB_STOR_TRANSPORT_GOOD;
+
+       case US_BULK_STAT_FAIL:
+               return USB_STOR_TRANSPORT_FAILED;
+
+       case US_BULK_STAT_PHASE:
+               return USB_STOR_TRANSPORT_ERROR;
        }
        return USB_STOR_TRANSPORT_ERROR;
 }
@@ -702,7 +737,9 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us)
 /***********************************************************************
  * Reset routines
  ***********************************************************************/
-//----- usb_stor_reset_common() ---------------------
+/*
+ * usb_stor_reset_common()
+ */
 static int usb_stor_reset_common(struct us_data *us,
                u8 request, u8 requesttype,
                u16 value, u16 index, void *data, u16 size)
@@ -710,69 +747,75 @@ static int usb_stor_reset_common(struct us_data *us,
        int result;
        int result2;
 
-       //printk("transport --- usb_stor_reset_common\n");
-       if (test_bit(US_FLIDX_DISCONNECTING, &us->dflags))
-       {
-               //printk("No reset during disconnect\n");
+       /* pr_info("transport --- usb_stor_reset_common\n"); */
+       if (test_bit(US_FLIDX_DISCONNECTING, &us->dflags)) {
+               /* pr_info("No reset during disconnect\n"); */
                return -EIO;
        }
 
-       result = usb_stor_control_msg(us, us->send_ctrl_pipe, request, requesttype, value, index, data, size,   5*HZ);
-       if (result < 0)
-       {
-               //printk("Soft reset failed: %d\n", result);
+       result = usb_stor_control_msg(us, us->send_ctrl_pipe,
+                       request, requesttype, value, index, data, size, 5*HZ);
+
+       if (result < 0) {
+               /* pr_info("Soft reset failed: %d\n", result); */
                return result;
        }
 
-       wait_event_interruptible_timeout(us->delay_wait, test_bit(US_FLIDX_DISCONNECTING, &us->dflags), HZ*6);
-       if (test_bit(US_FLIDX_DISCONNECTING, &us->dflags))
-       {
-               //printk("Reset interrupted by disconnect\n");
+       wait_event_interruptible_timeout(us->delay_wait,
+                       test_bit(US_FLIDX_DISCONNECTING, &us->dflags),  HZ*6);
+
+       if (test_bit(US_FLIDX_DISCONNECTING, &us->dflags)) {
+               /* pr_info("Reset interrupted by disconnect\n"); */
                return -EIO;
        }
 
-       //printk("Soft reset: clearing bulk-in endpoint halt\n");
+       /* pr_info("Soft reset: clearing bulk-in endpoint halt\n"); */
        result = usb_stor_clear_halt(us, us->recv_bulk_pipe);
 
-       //printk("Soft reset: clearing bulk-out endpoint halt\n");
+       /* pr_info("Soft reset: clearing bulk-out endpoint halt\n"); */
        result2 = usb_stor_clear_halt(us, us->send_bulk_pipe);
 
        /* return a result code based on the result of the clear-halts */
        if (result >= 0)
                result = result2;
-       //if (result < 0)
-       //      printk("Soft reset failed\n");
-       //else
-       //      printk("Soft reset done\n");
+       /* if (result < 0) */
+               /* pr_info("Soft reset failed\n"); */
+       /* else */
+               /* pr_info("Soft reset done\n"); */
        return result;
 }
 
-//----- usb_stor_Bulk_reset() ---------------------
+/*
+ * usb_stor_Bulk_reset()
+ */
 int usb_stor_Bulk_reset(struct us_data *us)
 {
-       //printk("transport --- usb_stor_Bulk_reset\n");
+       /* pr_info("transport --- usb_stor_Bulk_reset\n"); */
        return usb_stor_reset_common(us, US_BULK_RESET_REQUEST,
                                 USB_TYPE_CLASS | USB_RECIP_INTERFACE,
                                 0, us->ifnum, NULL, 0);
 }
 
-//----- usb_stor_port_reset() ---------------------
+/*
+ * usb_stor_port_reset()
+ */
 int usb_stor_port_reset(struct us_data *us)
 {
        int result;
 
-       //printk("transport --- usb_stor_port_reset\n");
+       /* pr_info("transport --- usb_stor_port_reset\n"); */
        result = usb_lock_device_for_reset(us->pusb_dev, us->pusb_intf);
        if (result < 0)
-               printk("unable to lock device for reset: %d\n", result);
+               pr_info("unable to lock device for reset: %d\n", result);
        else {
                /* Were we disconnected while waiting for the lock? */
                if (test_bit(US_FLIDX_DISCONNECTING, &us->dflags)) {
                        result = -EIO;
-                       //printk("No reset during disconnect\n");
+                       /* pr_info("No reset during disconnect\n"); */
                } else {
                        result = usb_reset_device(us->pusb_dev);
-                       //printk("usb_reset_composite_device returns %d\n", result);
+                       /* pr_info("usb_reset_composite_device returns %d\n",
+                                                               result); */
                }
                usb_unlock_device(us->pusb_dev);
        }
index 565d98c98454800dacb4d4662bdfec2b1cfa7ce6..75296152af7609d1c7882e10ccb48fae1c12d244 100644 (file)
@@ -8,7 +8,7 @@
 /* command block wrapper */
 struct bulk_cb_wrap {
        __le32  Signature;                      /* contains 'USBC' */
-       __u32   Tag;                                    /* unique per command id */
+       __u32   Tag;                            /* unique per command id */
        __le32  DataTransferLength;     /* size of data */
        __u8    Flags;                          /* direction in bit 0 */
        __u8    Lun;                                    /* LUN normally 0 */
@@ -49,9 +49,9 @@ struct bulk_cs_wrap {
 
 /* Transport return codes */
 #define USB_STOR_TRANSPORT_GOOD        0       /* Transport good, command good */
-#define USB_STOR_TRANSPORT_FAILED      1       /* Transport good, command failed   */
-#define USB_STOR_TRANSPORT_NO_SENSE    2       /* Command failed, no auto-sense    */
-#define USB_STOR_TRANSPORT_ERROR       3       /* Transport bad (i.e. device dead) */
+#define USB_STOR_TRANSPORT_FAILED 1    /* Transport good, command failed */
+#define USB_STOR_TRANSPORT_NO_SENSE 2  /* Command failed, no auto-sense */
+#define USB_STOR_TRANSPORT_ERROR 3     /* Transport bad (i.e. device dead) */
 
 /*
  * We used to have USB_STOR_XFER_ABORTED and USB_STOR_TRANSPORT_ABORTED
@@ -64,11 +64,11 @@ struct bulk_cs_wrap {
 /* CBI accept device specific command */
 #define US_CBI_ADSC            0
 extern int usb_stor_Bulk_transport(struct scsi_cmnd *, struct us_data*);
-extern int usb_stor_Bulk_max_lun(struct us_data*);
-extern int usb_stor_Bulk_reset(struct us_data*);
+extern int usb_stor_Bulk_max_lun(struct us_data *);
+extern int usb_stor_Bulk_reset(struct us_data *);
 extern void usb_stor_print_cmd(struct scsi_cmnd *);
 extern void usb_stor_invoke_transport(struct scsi_cmnd *, struct us_data*);
-extern void usb_stor_stop_transport(struct us_data*);
+extern void usb_stor_stop_transport(struct us_data *);
 extern int usb_stor_control_msg(struct us_data *us, unsigned int pipe,
                u8 request, u8 requesttype, u16 value, u16 index,
                void *data, u16 size, int timeout);
@@ -77,23 +77,26 @@ extern int usb_stor_bulk_transfer_buf(struct us_data *us, unsigned int pipe,
                void *buf, unsigned int length, unsigned int *act_len);
 extern int usb_stor_bulk_transfer_sg(struct us_data *us, unsigned int pipe,
                void *buf, unsigned int length, int use_sg, int *residual);
-extern int usb_stor_bulk_srb(struct us_dataus, unsigned int pipe,
-               struct scsi_cmndsrb);
+extern int usb_stor_bulk_srb(struct us_data *us, unsigned int pipe,
+               struct scsi_cmnd *srb);
 extern int usb_stor_port_reset(struct us_data *us);
 
 /* Protocol handling routines */
 enum xfer_buf_dir      {TO_XFER_BUF, FROM_XFER_BUF};
-extern unsigned int usb_stor_access_xfer_buf(struct us_data*, unsigned char *buffer,
-       unsigned int buflen, struct scsi_cmnd *srb, struct scatterlist **,
-       unsigned int *offset, enum xfer_buf_dir dir);
-extern void usb_stor_set_xfer_buf(struct us_data*, unsigned char *buffer, unsigned int buflen, struct scsi_cmnd *srb,
+extern unsigned int usb_stor_access_xfer_buf(struct us_data*,
+       unsigned char *buffer, unsigned int buflen, struct scsi_cmnd *srb,
+       struct scatterlist **, unsigned int *offset, enum xfer_buf_dir dir);
+extern void usb_stor_set_xfer_buf(struct us_data*, unsigned char *buffer,
+       unsigned int buflen, struct scsi_cmnd *srb,
        unsigned int dir);
 
-// ENE scsi function
-extern void ENE_stor_invoke_transport(struct scsi_cmnd *, struct us_data*);
-extern int ENE_InitMedia(struct us_data*);
-extern int ENE_MSInit(struct us_data*);
-extern int ENE_SMInit(struct us_data*);
+/*
+ * ENE scsi function
+ */
+extern void ENE_stor_invoke_transport(struct scsi_cmnd *, struct us_data *);
+extern int ENE_InitMedia(struct us_data *);
+extern int ENE_MSInit(struct us_data *);
+extern int ENE_SMInit(struct us_data *);
 extern int ENE_SendScsiCmd(struct us_data*, BYTE, void*, int);
 extern int ENE_LoadBinCode(struct us_data*, BYTE);
 extern int ENE_Read_BYTE(struct us_data*, WORD index, void *buf);
@@ -101,41 +104,54 @@ extern int ENE_Read_Data(struct us_data*, void *buf, unsigned int length);
 extern int ENE_Write_Data(struct us_data*, void *buf, unsigned int length);
 extern void BuildSenseBuffer(struct scsi_cmnd *, int);
 
-// ENE scsi function
+/*
+ * ENE scsi function
+ */
 extern int MS_SCSIIrp(struct us_data *us, struct scsi_cmnd *srb);
 extern int SM_SCSIIrp(struct us_data *us, struct scsi_cmnd *srb);
 
-// ENE MS function
-extern int     MS_CardInit(struct us_data *us);
+/*
+ * ENE MS function
+ */
+extern int     MS_CardInit(struct us_data *us);
 extern void    MS_LibFreeAllocatedArea(struct us_data *us);
 extern void    MS_LibFreeWriteBuf(struct us_data *us);
 extern int     MS_LibFreeLogicalMap(struct us_data *us);
-extern int     MS_LibForceSetLogicalPair(struct us_data *us, WORD logblk, WORD phyblk);
-extern int     MS_ReaderReadPage(struct us_data *us, DWORD PhyBlockAddr, BYTE PageNum, DWORD *PageBuf, MS_LibTypeExtdat *ExtraDat);
-extern int     MS_ReaderCopyBlock(struct us_data *us, WORD oldphy, WORD newphy, WORD PhyBlockAddr, BYTE PageNum, PBYTE buf, WORD len);
+extern int     MS_LibForceSetLogicalPair(struct us_data *us, WORD logblk,
+                                                               WORD phyblk);
+extern int     MS_ReaderReadPage(struct us_data *us, DWORD PhyBlockAddr,
+                                       BYTE PageNum, DWORD *PageBuf,
+                                       MS_LibTypeExtdat *ExtraDat);
+extern int     MS_ReaderCopyBlock(struct us_data *us, WORD oldphy,
+                                       WORD newphy, WORD PhyBlockAddr,
+                                       BYTE PageNum, PBYTE buf, WORD len);
 extern int     MS_ReaderEraseBlock(struct us_data *us, DWORD PhyBlockAddr);
-extern int     MS_LibProcessBootBlock(struct us_data *us, WORD PhyBlock, BYTE *PageData);
+extern int     MS_LibProcessBootBlock(struct us_data *us, WORD PhyBlock,
+                                                       BYTE *PageData);
 extern int     MS_LibAllocLogicalMap(struct us_data *us);
 extern int     MS_LibSetBootBlockMark(struct us_data *us, WORD phyblk);
-extern int     MS_LibSetLogicalBlockMark(struct us_data *us, WORD phyblk, WORD mark);
+extern int     MS_LibSetLogicalBlockMark(struct us_data *us, WORD phyblk,
+                                                               WORD mark);
 extern int     MS_LibSetInitialErrorBlock(struct us_data *us, WORD phyblk);
 extern int     MS_LibScanLogicalBlockNumber(struct us_data *us, WORD phyblk);
 extern int     MS_LibAllocWriteBuf(struct us_data *us);
 void           MS_LibClearWriteBuf(struct us_data *us);
-void           MS_LibPhy2LogRange(WORD PhyBlock, WORD *LogStart, WORD *LogEnde);
-extern int     MS_LibReadExtra(struct us_data *us, DWORD PhyBlock, BYTE PageNum, MS_LibTypeExtdat *ExtraDat);
-extern int     MS_LibReadExtraBlock(struct us_data *us, DWORD PhyBlock, BYTE PageNum, BYTE blen, void *buf);
+void           MS_LibPhy2LogRange(WORD PhyBlock, WORD *LogStart,
+                                                       WORD *LogEnde);
+extern int     MS_LibReadExtra(struct us_data *us, DWORD PhyBlock,
+                               BYTE PageNum, MS_LibTypeExtdat *ExtraDat);
+extern int     MS_LibReadExtraBlock(struct us_data *us, DWORD PhyBlock,
+                                       BYTE PageNum, BYTE blen, void *buf);
 extern int     MS_LibSetAcquiredErrorBlock(struct us_data *us, WORD phyblk);
 extern int     MS_LibErasePhyBlock(struct us_data *us, WORD phyblk);
 extern int     MS_LibErrorPhyBlock(struct us_data *us, WORD phyblk);
-extern int     MS_LibOverwriteExtra(struct us_data *us, DWORD PhyBlockAddr, BYTE PageNum, BYTE OverwriteFlag);
-extern int     MS_LibSetLogicalPair(struct us_data *us, WORD logblk, WORD phyblk);
+extern int     MS_LibOverwriteExtra(struct us_data *us, DWORD PhyBlockAddr,
+                                       BYTE PageNum, BYTE OverwriteFlag);
+extern int     MS_LibSetLogicalPair(struct us_data *us,
+                                       WORD logblk, WORD phyblk);
 extern int     MS_LibCheckDisableBlock(struct us_data *us, WORD PhyBlock);
 extern int     MS_CountFreeBlock(struct us_data *us, WORD PhyBlock);
 extern int     MS_LibSearchBlockFromLogical(struct us_data *us, WORD logblk);
 extern int     MS_LibSearchBlockFromPhysical(struct us_data *us, WORD phyblk);
 
-// ENE SM function
-extern int     SM_FreeMem(void);
-
 #endif
index 8c2332ec4f5c20ac4c2d161338b9d641fafe9d51..d8c5c626be5ce4e3be2a28233679f35d7dd392a0 100644 (file)
@@ -14,6 +14,7 @@
 
 #include "usb.h"
 #include "scsiglue.h"
+#include "smil.h"
 #include "transport.h"
 
 /* Some informational data */
@@ -34,10 +35,10 @@ MODULE_DEVICE_TABLE (usb, eucr_usb_ids);
 
 #ifdef CONFIG_PM
 
-int eucr_suspend(struct usb_interface *iface, pm_message_t message)
+static int eucr_suspend(struct usb_interface *iface, pm_message_t message)
 {
        struct us_data *us = usb_get_intfdata(iface);
-       printk("--- eucr_suspend ---\n");
+       pr_info("--- eucr_suspend ---\n");
        /* Wait until no command is running */
        mutex_lock(&us->dev_mutex);
 
@@ -55,12 +56,12 @@ int eucr_suspend(struct usb_interface *iface, pm_message_t message)
 }
 //EXPORT_SYMBOL_GPL(eucr_suspend);
 
-int eucr_resume(struct usb_interface *iface)
+static int eucr_resume(struct usb_interface *iface)
 {
        BYTE    tmp = 0;
 
        struct us_data *us = usb_get_intfdata(iface);
-       printk("--- eucr_resume---\n");
+       pr_info("--- eucr_resume---\n");
        mutex_lock(&us->dev_mutex);
 
        //US_DEBUGP("%s\n", __func__);
@@ -80,12 +81,12 @@ int eucr_resume(struct usb_interface *iface)
        return 0;
 }
 //EXPORT_SYMBOL_GPL(eucr_resume);
-int eucr_reset_resume(struct usb_interface *iface)
+static int eucr_reset_resume(struct usb_interface *iface)
 {
        BYTE    tmp = 0;
        struct us_data *us = usb_get_intfdata(iface);
 
-       printk("--- eucr_reset_resume---\n");
+       pr_info("--- eucr_reset_resume---\n");
        //US_DEBUGP("%s\n", __func__);
 
        /* Report the reset to the SCSI core */
@@ -116,7 +117,7 @@ static int eucr_pre_reset(struct usb_interface *iface)
 {
        struct us_data *us = usb_get_intfdata(iface);
 
-      printk("usb --- eucr_pre_reset\n");
+       pr_info("usb --- eucr_pre_reset\n");
 
        /* Make sure no command runs during the reset */
        mutex_lock(&us->dev_mutex);
@@ -128,7 +129,7 @@ static int eucr_post_reset(struct usb_interface *iface)
 {
        struct us_data *us = usb_get_intfdata(iface);
 
-      printk("usb --- eucr_post_reset\n");
+       pr_info("usb --- eucr_post_reset\n");
 
        /* Report the reset to the SCSI core */
        usb_stor_report_bus_reset(us);
@@ -140,7 +141,7 @@ static int eucr_post_reset(struct usb_interface *iface)
 //----- fill_inquiry_response() ---------------------
 void fill_inquiry_response(struct us_data *us, unsigned char *data, unsigned int data_len)
 {
-      printk("usb --- fill_inquiry_response\n");
+       pr_info("usb --- fill_inquiry_response\n");
        if (data_len<36) // You lose.
                return;
 
@@ -171,7 +172,7 @@ static int usb_stor_control_thread(void * __us)
        struct us_data *us = (struct us_data *)__us;
        struct Scsi_Host *host = us_to_host(us);
 
-      printk("usb --- usb_stor_control_thread\n");
+       pr_info("usb --- usb_stor_control_thread\n");
        for(;;)
        {
                if (wait_for_completion_interruptible(&us->cmnd_ready))
@@ -242,7 +243,7 @@ static int usb_stor_control_thread(void * __us)
                else
                {
 SkipForAbort:
-                       printk("scsi command aborted\n");
+                       pr_info("scsi command aborted\n");
                }
 
                if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags))
@@ -277,7 +278,7 @@ SkipForAbort:
 //----- associate_dev() ---------------------
 static int associate_dev(struct us_data *us, struct usb_interface *intf)
 {
-      printk("usb --- associate_dev\n");
+       pr_info("usb --- associate_dev\n");
 
        /* Fill in the device-related fields */
        us->pusb_dev = interface_to_usbdev(intf);
@@ -291,21 +292,21 @@ static int associate_dev(struct us_data *us, struct usb_interface *intf)
        us->cr = usb_alloc_coherent(us->pusb_dev, sizeof(*us->cr), GFP_KERNEL, &us->cr_dma);
        if (!us->cr)
        {
-               printk("usb_ctrlrequest allocation failed\n");
+               pr_info("usb_ctrlrequest allocation failed\n");
                return -ENOMEM;
        }
 
        us->iobuf = usb_alloc_coherent(us->pusb_dev, US_IOBUF_SIZE, GFP_KERNEL, &us->iobuf_dma);
        if (!us->iobuf)
        {
-               printk("I/O buffer allocation failed\n");
+               pr_info("I/O buffer allocation failed\n");
                return -ENOMEM;
        }
 
        us->sensebuf = kmalloc(US_SENSE_SIZE, GFP_KERNEL);
        if (!us->sensebuf)
        {
-               printk("Sense buffer allocation failed\n");
+               pr_info("Sense buffer allocation failed\n");
                return -ENOMEM;
        }
        return 0;
@@ -317,7 +318,7 @@ static int get_device_info(struct us_data *us, const struct usb_device_id *id)
        struct usb_device *dev = us->pusb_dev;
        struct usb_interface_descriptor *idesc = &us->pusb_intf->cur_altsetting->desc;
 
-      printk("usb --- get_device_info\n");
+       pr_info("usb --- get_device_info\n");
 
        us->subclass = idesc->bInterfaceSubClass;
        us->protocol = idesc->bInterfaceProtocol;
@@ -326,7 +327,7 @@ static int get_device_info(struct us_data *us, const struct usb_device_id *id)
 
        if (us->fflags & US_FL_IGNORE_DEVICE)
        {
-               printk("device ignored\n");
+               pr_info("device ignored\n");
                return -ENODEV;
        }
 
@@ -339,7 +340,7 @@ static int get_device_info(struct us_data *us, const struct usb_device_id *id)
 //----- get_transport() ---------------------
 static int get_transport(struct us_data *us)
 {
-      printk("usb --- get_transport\n");
+       pr_info("usb --- get_transport\n");
        switch (us->protocol) {
        case USB_PR_BULK:
                us->transport_name = "Bulk";
@@ -350,7 +351,7 @@ static int get_transport(struct us_data *us)
        default:
                return -EIO;
        }
-       //printk("Transport: %s\n", us->transport_name);
+       /* pr_info("Transport: %s\n", us->transport_name); */
 
        /* fix for single-lun devices */
        if (us->fflags & US_FL_SINGLE_LUN)
@@ -361,9 +362,11 @@ static int get_transport(struct us_data *us)
 //----- get_protocol() ---------------------
 static int get_protocol(struct us_data *us)
 {
-      printk("usb --- get_protocol\n");
-       printk("us->pusb_dev->descriptor.idVendor = %x\n", us->pusb_dev->descriptor.idVendor);
-       printk("us->pusb_dev->descriptor.idProduct = %x\n", us->pusb_dev->descriptor.idProduct);
+       pr_info("usb --- get_protocol\n");
+       pr_info("us->pusb_dev->descriptor.idVendor = %x\n",
+                       us->pusb_dev->descriptor.idVendor);
+       pr_info("us->pusb_dev->descriptor.idProduct = %x\n",
+                       us->pusb_dev->descriptor.idProduct);
        switch (us->subclass) {
        case USB_SC_SCSI:
                us->protocol_name = "Transparent SCSI";
@@ -376,7 +379,7 @@ static int get_protocol(struct us_data *us)
        default:
                return -EIO;
        }
-       //printk("Protocol: %s\n", us->protocol_name);
+       /* pr_info("Protocol: %s\n", us->protocol_name); */
        return 0;
 }
 
@@ -390,7 +393,7 @@ static int get_pipes(struct us_data *us)
        struct usb_endpoint_descriptor *ep_out = NULL;
        struct usb_endpoint_descriptor *ep_int = NULL;
 
-      printk("usb --- get_pipes\n");
+       pr_info("usb --- get_pipes\n");
 
        for (i = 0; i < altsetting->desc.bNumEndpoints; i++)
        {
@@ -418,7 +421,7 @@ static int get_pipes(struct us_data *us)
 
        if (!ep_in || !ep_out || (us->protocol == USB_PR_CBI && !ep_int))
        {
-               printk("Endpoint sanity check failed! Rejecting dev.\n");
+               pr_info("Endpoint sanity check failed! Rejecting dev.\n");
                return -EIO;
        }
 
@@ -440,11 +443,11 @@ static int usb_stor_acquire_resources(struct us_data *us)
 {
        struct task_struct *th;
 
-      printk("usb --- usb_stor_acquire_resources\n");
+       pr_info("usb --- usb_stor_acquire_resources\n");
        us->current_urb = usb_alloc_urb(0, GFP_KERNEL);
        if (!us->current_urb)
        {
-               printk("URB allocation failed\n");
+               pr_info("URB allocation failed\n");
                return -ENOMEM;
        }
 
@@ -452,7 +455,7 @@ static int usb_stor_acquire_resources(struct us_data *us)
        th = kthread_run(usb_stor_control_thread, us, "eucr-storage");
        if (IS_ERR(th))
        {
-               printk("Unable to start control thread\n");
+               pr_info("Unable to start control thread\n");
                return PTR_ERR(th);
        }
        us->ctl_thread = th;
@@ -463,7 +466,7 @@ static int usb_stor_acquire_resources(struct us_data *us)
 //----- usb_stor_release_resources() ---------------------
 static void usb_stor_release_resources(struct us_data *us)
 {
-       printk("usb --- usb_stor_release_resources\n");
+       pr_info("usb --- usb_stor_release_resources\n");
 
        SM_FreeMem();
 
@@ -474,7 +477,7 @@ static void usb_stor_release_resources(struct us_data *us)
        /* Call the destructor routine, if it exists */
        if (us->extra_destructor)
        {
-               printk("-- calling extra_destructor()\n");
+               pr_info("-- calling extra_destructor()\n");
                us->extra_destructor(us->extra);
        }
 
@@ -486,7 +489,7 @@ static void usb_stor_release_resources(struct us_data *us)
 //----- dissociate_dev() ---------------------
 static void dissociate_dev(struct us_data *us)
 {
-      printk("usb --- dissociate_dev\n");
+       pr_info("usb --- dissociate_dev\n");
 
        kfree(us->sensebuf);
 
@@ -505,7 +508,7 @@ static void quiesce_and_remove_host(struct us_data *us)
 {
        struct Scsi_Host *host = us_to_host(us);
 
-      printk("usb --- quiesce_and_remove_host\n");
+       pr_info("usb --- quiesce_and_remove_host\n");
 
        /* If the device is really gone, cut short reset delays */
        if (us->pusb_dev->state == USB_STATE_NOTATTACHED)
@@ -535,7 +538,7 @@ static void quiesce_and_remove_host(struct us_data *us)
 //----- release_everything() ---------------------
 static void release_everything(struct us_data *us)
 {
-      printk("usb --- release_everything\n");
+       pr_info("usb --- release_everything\n");
 
        usb_stor_release_resources(us);
        dissociate_dev(us);
@@ -547,8 +550,8 @@ static int usb_stor_scan_thread(void * __us)
 {
        struct us_data *us = (struct us_data *)__us;
 
-      printk("usb --- usb_stor_scan_thread\n");
-       printk("EUCR : device found at %d\n", us->pusb_dev->devnum);
+       pr_info("usb --- usb_stor_scan_thread\n");
+       pr_info("EUCR : device found at %d\n", us->pusb_dev->devnum);
 
        set_freezable();
        /* Wait for the timeout to expire or for a disconnect */
@@ -569,7 +572,7 @@ static int usb_stor_scan_thread(void * __us)
                        mutex_unlock(&us->dev_mutex);
                }
                scsi_scan_host(us_to_host(us));
-               printk("EUCR : device scan complete\n");
+               pr_info("EUCR : device scan complete\n");
        }
        complete_and_exit(&us->scanning_done, 0);
 }
@@ -583,12 +586,12 @@ static int eucr_probe(struct usb_interface *intf, const struct usb_device_id *id
        BYTE    MiscReg03 = 0;
        struct task_struct *th;
 
-      printk("usb --- eucr_probe\n");
+       pr_info("usb --- eucr_probe\n");
 
       host = scsi_host_alloc(&usb_stor_host_template, sizeof(*us));
        if (!host)
        {
-               printk("Unable to allocate the scsi host\n");
+               pr_info("Unable to allocate the scsi host\n");
                return -ENOMEM;
        }
 
@@ -631,7 +634,7 @@ static int eucr_probe(struct usb_interface *intf, const struct usb_device_id *id
        result = scsi_add_host(host, &intf->dev);
        if (result)
        {
-               printk("Unable to add the scsi host\n");
+               pr_info("Unable to add the scsi host\n");
                goto BadDevice;
        }
 
@@ -639,7 +642,7 @@ static int eucr_probe(struct usb_interface *intf, const struct usb_device_id *id
        th = kthread_create(usb_stor_scan_thread, us, "eucr-stor-scan");
        if (IS_ERR(th))
        {
-               printk("Unable to start the device-scanning thread\n");
+               pr_info("Unable to start the device-scanning thread\n");
                complete(&us->scanning_done);
                quiesce_and_remove_host(us);
                result = PTR_ERR(th);
@@ -658,7 +661,7 @@ static int eucr_probe(struct usb_interface *intf, const struct usb_device_id *id
        if (!(MiscReg03 & 0x02)) {
                result = -ENODEV;
                quiesce_and_remove_host(us);
-               printk(KERN_NOTICE "keucr: The driver only supports SM/MS card.\
+               pr_info("keucr: The driver only supports SM/MS card.\
                        To use SD card, \
                        please build driver/usb/storage/ums-eneub6250.ko\n");
                goto BadDevice;
@@ -668,7 +671,7 @@ static int eucr_probe(struct usb_interface *intf, const struct usb_device_id *id
 
        /* We come here if there are any problems */
 BadDevice:
-      printk("usb --- eucr_probe failed\n");
+       pr_info("usb --- eucr_probe failed\n");
        release_everything(us);
        return result;
 }
@@ -678,7 +681,7 @@ static void eucr_disconnect(struct usb_interface *intf)
 {
        struct us_data *us = usb_get_intfdata(intf);
 
-      printk("usb --- eucr_disconnect\n");
+       pr_info("usb --- eucr_disconnect\n");
        quiesce_and_remove_host(us);
        release_everything(us);
 }
@@ -705,11 +708,11 @@ static struct usb_driver usb_storage_driver = {
 static int __init usb_stor_init(void)
 {
        int retval;
-      printk("usb --- usb_stor_init start\n");
+       pr_info("usb --- usb_stor_init start\n");
 
        retval = usb_register(&usb_storage_driver);
        if (retval == 0)
-            printk("ENE USB Mass Storage support registered.\n");
+               pr_info("ENE USB Mass Storage support registered.\n");
 
        return retval;
 }
@@ -717,7 +720,7 @@ static int __init usb_stor_init(void)
 //----- usb_stor_exit() ---------------------
 static void __exit usb_stor_exit(void)
 {
-      printk("usb --- usb_stor_exit\n");
+       pr_info("usb --- usb_stor_exit\n");
 
        usb_deregister(&usb_storage_driver) ;
 }
index ea9209d9ceb268ee67663c19ba455725af3133da..851b762319cf20b8b2b90c9624a1b33d51f80593 100644 (file)
@@ -1094,8 +1094,6 @@ static int line6_probe(struct usb_interface *interface,
 err_destruct:
        line6_destruct(interface);
 err_put:
-       usb_put_intf(interface);
-       usb_put_dev(usbdev);
        return ret;
 }
 
index 832522c290cbd068250ea0cbf7559a8393f3adea..50724c4e2484c23dabd649092337165d263a3007 100644 (file)
@@ -568,17 +568,17 @@ static void set_use_dec(void *data)
 }
 
 static struct lirc_driver driver = {
-       .name           = LIRC_DRIVER_NAME,
-       .minor          = -1,
-       .code_length    = 1,
-       .sample_rate    = 0,
-       .data           = NULL,
-       .add_to_buf     = NULL,
-       .set_use_inc    = set_use_inc,
-       .set_use_dec    = set_use_dec,
-       .fops           = &lirc_fops,
-       .dev            = NULL,
-       .owner          = THIS_MODULE,
+       .name           = LIRC_DRIVER_NAME,
+       .minor          = -1,
+       .code_length    = 1,
+       .sample_rate    = 0,
+       .data           = NULL,
+       .add_to_buf     = NULL,
+       .set_use_inc    = set_use_inc,
+       .set_use_dec    = set_use_dec,
+       .fops           = &lirc_fops,
+       .dev            = NULL,
+       .owner          = THIS_MODULE,
 };
 
 static struct platform_device *lirc_parallel_dev;
@@ -594,7 +594,7 @@ static int __devexit lirc_parallel_remove(struct platform_device *dev)
 }
 
 static int lirc_parallel_suspend(struct platform_device *dev,
-                                 pm_message_t state)
+                                       pm_message_t state)
 {
        return 0;
 }
@@ -647,7 +647,8 @@ static int __init lirc_parallel_init(void)
 
        result = platform_driver_register(&lirc_parallel_driver);
        if (result) {
-               printk("platform_driver_register returned %d\n", result);
+               printk(KERN_NOTICE "platform_driver_register"
+                                       " returned %d\n", result);
                return result;
        }
 
index 1c3099b388e0acefd601621dbe05a9c6b78451b7..4a3cca03224a8a114176a9ea4f09600d3f245600 100644 (file)
@@ -919,7 +919,7 @@ static int set_use_inc(void *data)
        default:
                dprintk("Interrupt %d, port %04x obtained\n", irq, io);
                break;
-       };
+       }
 
        spin_lock_irqsave(&hardware[type].lock, flags);
 
index 76be7b8c620968218822c3216204e14ffdc2250b..a7b46f24f24e242e61cf5e7c0dea2b9650bef7d8 100644 (file)
@@ -143,9 +143,9 @@ static unsigned int duty_cycle = 50;   /* duty cycle of 50% */
 #endif
 #ifndef LIRC_PORT
 /* for external dongles, default to com1 */
-#if defined(LIRC_SIR_ACTISYS_ACT200L) || \
-    defined(LIRC_SIR_ACTISYS_ACT220L) || \
-    defined(LIRC_SIR_TEKRAM)
+#if defined(LIRC_SIR_ACTISYS_ACT200L)         || \
+           defined(LIRC_SIR_ACTISYS_ACT220L) || \
+           defined(LIRC_SIR_TEKRAM)
 #define LIRC_PORT 0x3f8
 #else
 /* onboard sir ports are typically com3 */
@@ -467,7 +467,7 @@ static const struct file_operations lirc_fops = {
 
 static int set_use_inc(void *data)
 {
-       return 0;
+       return 0;
 }
 
 static void set_use_dec(void *data)
@@ -475,17 +475,17 @@ static void set_use_dec(void *data)
 }
 
 static struct lirc_driver driver = {
-       .name           = LIRC_DRIVER_NAME,
-       .minor          = -1,
-       .code_length    = 1,
-       .sample_rate    = 0,
-       .data           = NULL,
-       .add_to_buf     = NULL,
-       .set_use_inc    = set_use_inc,
-       .set_use_dec    = set_use_dec,
-       .fops           = &lirc_fops,
-       .dev            = NULL,
-       .owner          = THIS_MODULE,
+       .name           = LIRC_DRIVER_NAME,
+       .minor          = -1,
+       .code_length    = 1,
+       .sample_rate    = 0,
+       .data           = NULL,
+       .add_to_buf     = NULL,
+       .set_use_inc    = set_use_inc,
+       .set_use_dec    = set_use_dec,
+       .fops           = &lirc_fops,
+       .dev            = NULL,
+       .owner          = THIS_MODULE,
 };
 
 
diff --git a/drivers/staging/mei/Kconfig b/drivers/staging/mei/Kconfig
new file mode 100644 (file)
index 0000000..3f3f170
--- /dev/null
@@ -0,0 +1,28 @@
+config INTEL_MEI
+       tristate "Intel Management Engine Interface (Intel MEI)"
+       depends on X86 && PCI && EXPERIMENTAL
+       help
+         The Intel Management Engine (Intel ME) provides Manageability,
+         Security and Media services for system containing Intel chipsets.
+         if selected /dev/mei misc device will be created.
+
+         Supported Chipsets are:
+         7 Series Chipset Family
+         6 Series Chipset Family
+         5 Series Chipset Family
+         4 Series Chipset Family
+         Mobile 4 Series Chipset Family
+         ICH9
+         82946GZ/GL
+         82G35 Express
+         82Q963/Q965
+         82P965/G965
+         Mobile PM965/GM965
+         Mobile GME965/GLE960
+         82Q35 Express
+         82G33/G31/P35/P31 Express
+         82Q33 Express
+         82X38/X48 Express
+
+         For more information see
+         <http://software.intel.com/en-us/manageability/>
diff --git a/drivers/staging/mei/Makefile b/drivers/staging/mei/Makefile
new file mode 100644 (file)
index 0000000..57168db
--- /dev/null
@@ -0,0 +1,11 @@
+#
+# Makefile - Intel Management Engine Interface (Intel MEI) Linux driver
+# Copyright (c) 2010-2011, Intel Corporation.
+#
+obj-$(CONFIG_INTEL_MEI) += mei.o
+mei-objs := init.o
+mei-objs += interrupt.o
+mei-objs += interface.o
+mei-objs += iorw.o
+mei-objs += main.o
+mei-objs += wd.o
diff --git a/drivers/staging/mei/TODO b/drivers/staging/mei/TODO
new file mode 100644 (file)
index 0000000..3b6a667
--- /dev/null
@@ -0,0 +1,17 @@
+TODO:
+       - Create in-kernel Client API. Examples of in-kernel clients are watchdog and AMTHI.
+       - ME Watchdog Driver to expose standard Linux watchdog interface
+       - Rewrite AMTHI to use in-kernel client interface
+       - Cleanup init and probe functions
+       - Review BUG/BUG_ON usage
+       - Cleanup and reorganize header files
+       - Rewrite client data structure
+       - Make state machine more readable
+       - Add mei.txt with driver explanation and it's driver
+       - Fix Kconfig
+       - Cleanup and split the timer function
+Upon Unstaging:
+       - move mei.h to include/linux/mei.h
+       - Documentation/ioctl/ioctl-number.txt
+       - drop mei_version.h
+       - Updated MAINTAINERS
diff --git a/drivers/staging/mei/hw.h b/drivers/staging/mei/hw.h
new file mode 100644 (file)
index 0000000..9b9008c
--- /dev/null
@@ -0,0 +1,333 @@
+/*
+ *
+ * Intel Management Engine Interface (Intel MEI) Linux driver
+ * Copyright (c) 2003-2011, Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ */
+
+#ifndef _MEI_HW_TYPES_H_
+#define _MEI_HW_TYPES_H_
+
+#include <linux/uuid.h>
+
+/*
+ * Timeouts
+ */
+#define MEI_INTEROP_TIMEOUT    (HZ * 7)
+#define MEI_CONNECT_TIMEOUT            3       /* at least 2 seconds */
+
+#define CONNECT_TIMEOUT        15      /* HPS definition */
+#define INIT_CLIENTS_TIMEOUT   15      /* HPS definition */
+
+#define IAMTHIF_STALL_TIMER            12      /* seconds */
+#define IAMTHIF_READ_TIMER             10000   /* ms */
+
+/*
+ * Internal Clients Number
+ */
+#define MEI_WD_HOST_CLIENT_ID          1
+#define MEI_IAMTHIF_HOST_CLIENT_ID     2
+
+/*
+ * MEI device IDs
+ */
+#define    MEI_DEV_ID_82946GZ  0x2974  /* 82946GZ/GL */
+#define    MEI_DEV_ID_82G35    0x2984  /* 82G35 Express */
+#define    MEI_DEV_ID_82Q965   0x2994  /* 82Q963/Q965 */
+#define    MEI_DEV_ID_82G965   0x29A4  /* 82P965/G965 */
+
+#define    MEI_DEV_ID_82GM965  0x2A04  /* Mobile PM965/GM965 */
+#define    MEI_DEV_ID_82GME965 0x2A14  /* Mobile GME965/GLE960 */
+
+#define    MEI_DEV_ID_ICH9_82Q35 0x29B4  /* 82Q35 Express */
+#define    MEI_DEV_ID_ICH9_82G33 0x29C4  /* 82G33/G31/P35/P31 Express */
+#define    MEI_DEV_ID_ICH9_82Q33 0x29D4  /* 82Q33 Express */
+#define    MEI_DEV_ID_ICH9_82X38 0x29E4  /* 82X38/X48 Express */
+#define    MEI_DEV_ID_ICH9_3200  0x29F4  /* 3200/3210 Server */
+
+#define    MEI_DEV_ID_ICH9_6   0x28B4  /* Bearlake */
+#define    MEI_DEV_ID_ICH9_7   0x28C4  /* Bearlake */
+#define    MEI_DEV_ID_ICH9_8   0x28D4  /* Bearlake */
+#define    MEI_DEV_ID_ICH9_9    0x28E4  /* Bearlake */
+#define    MEI_DEV_ID_ICH9_10  0x28F4  /* Bearlake */
+
+#define    MEI_DEV_ID_ICH9M_1  0x2A44  /* Cantiga */
+#define    MEI_DEV_ID_ICH9M_2  0x2A54  /* Cantiga */
+#define    MEI_DEV_ID_ICH9M_3  0x2A64  /* Cantiga */
+#define    MEI_DEV_ID_ICH9M_4  0x2A74  /* Cantiga */
+
+#define    MEI_DEV_ID_ICH10_1  0x2E04  /* Eaglelake */
+#define    MEI_DEV_ID_ICH10_2  0x2E14  /* Eaglelake */
+#define    MEI_DEV_ID_ICH10_3  0x2E24  /* Eaglelake */
+#define    MEI_DEV_ID_ICH10_4  0x2E34  /* Eaglelake */
+
+#define    MEI_DEV_ID_IBXPK_1  0x3B64  /* Calpella */
+#define    MEI_DEV_ID_IBXPK_2  0x3B65  /* Calpella */
+
+#define    MEI_DEV_ID_CPT_1    0x1C3A    /* Cougerpoint */
+#define    MEI_DEV_ID_PBG_1    0x1D3A    /* PBG */
+
+#define    MEI_DEV_ID_PPT_1    0x1E3A    /* Pantherpoint PPT */
+#define    MEI_DEV_ID_PPT_2    0x1CBA    /* Pantherpoint PPT */
+#define    MEI_DEV_ID_PPT_3    0x1DBA    /* Pantherpoint PPT */
+
+
+/*
+ * MEI HW Section
+ */
+
+/* MEI registers */
+/* H_CB_WW - Host Circular Buffer (CB) Write Window register */
+#define H_CB_WW    0
+/* H_CSR - Host Control Status register */
+#define H_CSR      4
+/* ME_CB_RW - ME Circular Buffer Read Window register (read only) */
+#define ME_CB_RW   8
+/* ME_CSR_HA - ME Control Status Host Access register (read only) */
+#define ME_CSR_HA  0xC
+
+
+/* register bits of H_CSR (Host Control Status register) */
+/* Host Circular Buffer Depth - maximum number of 32-bit entries in CB */
+#define H_CBD             0xFF000000
+/* Host Circular Buffer Write Pointer */
+#define H_CBWP            0x00FF0000
+/* Host Circular Buffer Read Pointer */
+#define H_CBRP            0x0000FF00
+/* Host Reset */
+#define H_RST             0x00000010
+/* Host Ready */
+#define H_RDY             0x00000008
+/* Host Interrupt Generate */
+#define H_IG              0x00000004
+/* Host Interrupt Status */
+#define H_IS              0x00000002
+/* Host Interrupt Enable */
+#define H_IE              0x00000001
+
+
+/* register bits of ME_CSR_HA (ME Control Status Host Access register) */
+/* ME CB (Circular Buffer) Depth HRA (Host Read Access) - host read only
+access to ME_CBD */
+#define ME_CBD_HRA        0xFF000000
+/* ME CB Write Pointer HRA - host read only access to ME_CBWP */
+#define ME_CBWP_HRA       0x00FF0000
+/* ME CB Read Pointer HRA - host read only access to ME_CBRP */
+#define ME_CBRP_HRA       0x0000FF00
+/* ME Reset HRA - host read only access to ME_RST */
+#define ME_RST_HRA        0x00000010
+/* ME Ready HRA - host read only access to ME_RDY */
+#define ME_RDY_HRA        0x00000008
+/* ME Interrupt Generate HRA - host read only access to ME_IG */
+#define ME_IG_HRA         0x00000004
+/* ME Interrupt Status HRA - host read only access to ME_IS */
+#define ME_IS_HRA         0x00000002
+/* ME Interrupt Enable HRA - host read only access to ME_IE */
+#define ME_IE_HRA         0x00000001
+
+/*
+ * MEI Version
+ */
+#define HBM_MINOR_VERSION                   0
+#define HBM_MAJOR_VERSION                   1
+#define HBM_TIMEOUT                         1  /* 1 second */
+
+/*
+ * MEI Bus Message Command IDs
+ */
+#define HOST_START_REQ_CMD                  0x01
+#define HOST_START_RES_CMD                  0x81
+
+#define HOST_STOP_REQ_CMD                   0x02
+#define HOST_STOP_RES_CMD                   0x82
+
+#define ME_STOP_REQ_CMD                     0x03
+
+#define HOST_ENUM_REQ_CMD                   0x04
+#define HOST_ENUM_RES_CMD                   0x84
+
+#define HOST_CLIENT_PROPERTIES_REQ_CMD      0x05
+#define HOST_CLIENT_PROPERTIES_RES_CMD      0x85
+
+#define CLIENT_CONNECT_REQ_CMD              0x06
+#define CLIENT_CONNECT_RES_CMD              0x86
+
+#define CLIENT_DISCONNECT_REQ_CMD           0x07
+#define CLIENT_DISCONNECT_RES_CMD           0x87
+
+#define MEI_FLOW_CONTROL_CMD               0x08
+
+/*
+ * MEI Stop Reason
+ * used by hbm_host_stop_request.reason
+ */
+enum mei_stop_reason_types {
+       DRIVER_STOP_REQUEST = 0x00,
+       DEVICE_D1_ENTRY = 0x01,
+       DEVICE_D2_ENTRY = 0x02,
+       DEVICE_D3_ENTRY = 0x03,
+       SYSTEM_S1_ENTRY = 0x04,
+       SYSTEM_S2_ENTRY = 0x05,
+       SYSTEM_S3_ENTRY = 0x06,
+       SYSTEM_S4_ENTRY = 0x07,
+       SYSTEM_S5_ENTRY = 0x08
+};
+
+/*
+ * Client Connect Status
+ * used by hbm_client_connect_response.status
+ */
+enum client_connect_status_types {
+       CCS_SUCCESS = 0x00,
+       CCS_NOT_FOUND = 0x01,
+       CCS_ALREADY_STARTED = 0x02,
+       CCS_OUT_OF_RESOURCES = 0x03,
+       CCS_MESSAGE_SMALL = 0x04
+};
+
+/*
+ * Client Disconnect Status
+ */
+enum client_disconnect_status_types {
+       CDS_SUCCESS = 0x00
+};
+
+/*
+ *  MEI BUS Interface Section
+ */
+struct mei_msg_hdr {
+       u32 me_addr:8;
+       u32 host_addr:8;
+       u32 length:9;
+       u32 reserved:6;
+       u32 msg_complete:1;
+} __packed;
+
+
+struct hbm_cmd {
+       u8 cmd:7;
+       u8 is_response:1;
+} __packed;
+
+
+struct mei_bus_message {
+       struct hbm_cmd cmd;
+       u8 command_specific_data[];
+} __packed;
+
+struct hbm_version {
+       u8 minor_version;
+       u8 major_version;
+} __packed;
+
+struct hbm_host_version_request {
+       struct hbm_cmd cmd;
+       u8 reserved;
+       struct hbm_version host_version;
+} __packed;
+
+struct hbm_host_version_response {
+       struct hbm_cmd cmd;
+       int host_version_supported;
+       struct hbm_version me_max_version;
+} __packed;
+
+struct hbm_host_stop_request {
+       struct hbm_cmd cmd;
+       u8 reason;
+       u8 reserved[2];
+} __packed;
+
+struct hbm_host_stop_response {
+       struct hbm_cmd cmd;
+       u8 reserved[3];
+} __packed;
+
+struct hbm_me_stop_request {
+       struct hbm_cmd cmd;
+       u8 reason;
+       u8 reserved[2];
+} __packed;
+
+struct hbm_host_enum_request {
+       struct hbm_cmd cmd;
+       u8 reserved[3];
+} __packed;
+
+struct hbm_host_enum_response {
+       struct hbm_cmd cmd;
+       u8 reserved[3];
+       u8 valid_addresses[32];
+} __packed;
+
+struct mei_client_properties {
+       uuid_le protocol_name;
+       u8 protocol_version;
+       u8 max_number_of_connections;
+       u8 fixed_address;
+       u8 single_recv_buf;
+       u32 max_msg_length;
+} __packed;
+
+struct hbm_props_request {
+       struct hbm_cmd cmd;
+       u8 address;
+       u8 reserved[2];
+} __packed;
+
+
+struct hbm_props_response {
+       struct hbm_cmd cmd;
+       u8 address;
+       u8 status;
+       u8 reserved[1];
+       struct mei_client_properties client_properties;
+} __packed;
+
+struct hbm_client_connect_request {
+       struct hbm_cmd cmd;
+       u8 me_addr;
+       u8 host_addr;
+       u8 reserved;
+} __packed;
+
+struct hbm_client_connect_response {
+       struct hbm_cmd cmd;
+       u8 me_addr;
+       u8 host_addr;
+       u8 status;
+} __packed;
+
+struct hbm_client_disconnect_request {
+       struct hbm_cmd cmd;
+       u8 me_addr;
+       u8 host_addr;
+       u8 reserved[1];
+} __packed;
+
+#define MEI_FC_MESSAGE_RESERVED_LENGTH           5
+
+struct hbm_flow_control {
+       struct hbm_cmd cmd;
+       u8 me_addr;
+       u8 host_addr;
+       u8 reserved[MEI_FC_MESSAGE_RESERVED_LENGTH];
+} __packed;
+
+struct mei_me_client {
+       struct mei_client_properties props;
+       u8 client_id;
+       u8 mei_flow_ctrl_creds;
+} __packed;
+
+
+#endif
diff --git a/drivers/staging/mei/init.c b/drivers/staging/mei/init.c
new file mode 100644 (file)
index 0000000..2818851
--- /dev/null
@@ -0,0 +1,770 @@
+/*
+ *
+ * Intel Management Engine Interface (Intel MEI) Linux driver
+ * Copyright (c) 2003-2011, Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ */
+
+#include <linux/pci.h>
+#include <linux/sched.h>
+#include <linux/wait.h>
+#include <linux/delay.h>
+
+#include "mei_dev.h"
+#include "hw.h"
+#include "interface.h"
+#include "mei.h"
+
+const uuid_le mei_amthi_guid  = UUID_LE(0x12f80028, 0xb4b7, 0x4b2d, 0xac,
+                                               0xa8, 0x46, 0xe0, 0xff, 0x65,
+                                               0x81, 0x4c);
+
+/**
+ * mei_initialize_list - Sets up a queue list.
+ *
+ * @list: An instance of our list structure
+ * @dev: the device structure
+ */
+void mei_initialize_list(struct mei_io_list *list, struct mei_device *dev)
+{
+       /* initialize our queue list */
+       INIT_LIST_HEAD(&list->mei_cb.cb_list);
+       list->status = 0;
+       list->device_extension = dev;
+}
+
+/**
+ * mei_flush_queues - flushes queue lists belonging to cl.
+ *
+ * @dev: the device structure
+ * @cl: private data of the file object
+ */
+void mei_flush_queues(struct mei_device *dev, struct mei_cl *cl)
+{
+       int i;
+
+       if (!dev || !cl)
+               return;
+
+       for (i = 0; i < MEI_IO_LISTS_NUMBER; i++) {
+               dev_dbg(&dev->pdev->dev, "remove list entry belonging to cl\n");
+               mei_flush_list(dev->io_list_array[i], cl);
+       }
+}
+
+
+/**
+ * mei_flush_list - removes list entry belonging to cl.
+ *
+ * @list:  An instance of our list structure
+ * @cl: private data of the file object
+ */
+void mei_flush_list(struct mei_io_list *list, struct mei_cl *cl)
+{
+       struct mei_cl *cl_tmp;
+       struct mei_cl_cb *cb_pos = NULL;
+       struct mei_cl_cb *cb_next = NULL;
+
+       if (!list || !cl)
+               return;
+
+       if (list->status != 0)
+               return;
+
+       if (list_empty(&list->mei_cb.cb_list))
+               return;
+
+       list_for_each_entry_safe(cb_pos, cb_next,
+                                &list->mei_cb.cb_list, cb_list) {
+               if (cb_pos) {
+                       cl_tmp = (struct mei_cl *)
+                               cb_pos->file_private;
+                       if (cl_tmp &&
+                           mei_fe_same_id(cl, cl_tmp))
+                               list_del(&cb_pos->cb_list);
+               }
+       }
+}
+
+/**
+ * mei_reset_iamthif_params - initializes mei device iamthif
+ *
+ * @dev: the device structure
+ */
+static void mei_reset_iamthif_params(struct mei_device *dev)
+{
+       /* reset iamthif parameters. */
+       dev->iamthif_current_cb = NULL;
+       dev->iamthif_msg_buf_size = 0;
+       dev->iamthif_msg_buf_index = 0;
+       dev->iamthif_canceled = 0;
+       dev->iamthif_ioctl = 0;
+       dev->iamthif_state = MEI_IAMTHIF_IDLE;
+       dev->iamthif_timer = 0;
+}
+
+/**
+ * init_mei_device - allocates and initializes the mei device structure
+ *
+ * @pdev: The pci device structure
+ *
+ * returns The mei_device_device pointer on success, NULL on failure.
+ */
+struct mei_device *init_mei_device(struct pci_dev *pdev)
+{
+       int i;
+       struct mei_device *dev;
+
+       dev = kzalloc(sizeof(struct mei_device), GFP_KERNEL);
+       if (!dev)
+               return NULL;
+
+       /* setup our list array */
+       dev->io_list_array[0] = &dev->read_list;
+       dev->io_list_array[1] = &dev->write_list;
+       dev->io_list_array[2] = &dev->write_waiting_list;
+       dev->io_list_array[3] = &dev->ctrl_wr_list;
+       dev->io_list_array[4] = &dev->ctrl_rd_list;
+       dev->io_list_array[5] = &dev->amthi_cmd_list;
+       dev->io_list_array[6] = &dev->amthi_read_complete_list;
+       INIT_LIST_HEAD(&dev->file_list);
+       INIT_LIST_HEAD(&dev->wd_cl.link);
+       INIT_LIST_HEAD(&dev->iamthif_cl.link);
+       mutex_init(&dev->device_lock);
+       init_waitqueue_head(&dev->wait_recvd_msg);
+       init_waitqueue_head(&dev->wait_stop_wd);
+       dev->mei_state = MEI_INITIALIZING;
+       dev->iamthif_state = MEI_IAMTHIF_IDLE;
+       for (i = 0; i < MEI_IO_LISTS_NUMBER; i++)
+               mei_initialize_list(dev->io_list_array[i], dev);
+       dev->pdev = pdev;
+       return dev;
+}
+
+/**
+ * mei_hw_init - initializes host and fw to start work.
+ *
+ * @dev: the device structure
+ *
+ * returns 0 on success, <0 on failure.
+ */
+int mei_hw_init(struct mei_device *dev)
+{
+       int err = 0;
+       int ret;
+
+       mutex_lock(&dev->device_lock);
+
+       dev->host_hw_state = mei_hcsr_read(dev);
+       dev->me_hw_state = mei_mecsr_read(dev);
+       dev_dbg(&dev->pdev->dev, "host_hw_state = 0x%08x, mestate = 0x%08x.\n",
+           dev->host_hw_state, dev->me_hw_state);
+
+       /* acknowledge interrupt and stop interupts */
+       if ((dev->host_hw_state & H_IS) == H_IS)
+               mei_reg_write(dev, H_CSR, dev->host_hw_state);
+
+       dev->recvd_msg = 0;
+       dev_dbg(&dev->pdev->dev, "reset in start the mei device.\n");
+
+       mei_reset(dev, 1);
+
+       dev_dbg(&dev->pdev->dev, "host_hw_state = 0x%08x, me_hw_state = 0x%08x.\n",
+           dev->host_hw_state, dev->me_hw_state);
+
+       /* wait for ME to turn on ME_RDY */
+       if (!dev->recvd_msg) {
+               mutex_unlock(&dev->device_lock);
+               err = wait_event_interruptible_timeout(dev->wait_recvd_msg,
+                       dev->recvd_msg, MEI_INTEROP_TIMEOUT);
+               mutex_lock(&dev->device_lock);
+       }
+
+       if (!err && !dev->recvd_msg) {
+               dev->mei_state = MEI_DISABLED;
+               dev_dbg(&dev->pdev->dev,
+                       "wait_event_interruptible_timeout failed"
+                       "on wait for ME to turn on ME_RDY.\n");
+               ret = -ENODEV;
+               goto out;
+       }
+
+       if (!(((dev->host_hw_state & H_RDY) == H_RDY) &&
+             ((dev->me_hw_state & ME_RDY_HRA) == ME_RDY_HRA))) {
+               dev->mei_state = MEI_DISABLED;
+               dev_dbg(&dev->pdev->dev,
+                       "host_hw_state = 0x%08x, me_hw_state = 0x%08x.\n",
+                       dev->host_hw_state, dev->me_hw_state);
+
+               if (!(dev->host_hw_state & H_RDY) != H_RDY)
+                       dev_dbg(&dev->pdev->dev, "host turn off H_RDY.\n");
+
+               if (!(dev->me_hw_state & ME_RDY_HRA) != ME_RDY_HRA)
+                       dev_dbg(&dev->pdev->dev, "ME turn off ME_RDY.\n");
+
+               printk(KERN_ERR "mei: link layer initialization failed.\n");
+               ret = -ENODEV;
+               goto out;
+       }
+
+       if (dev->version.major_version != HBM_MAJOR_VERSION ||
+           dev->version.minor_version != HBM_MINOR_VERSION) {
+               dev_dbg(&dev->pdev->dev, "MEI start failed.\n");
+               ret = -ENODEV;
+               goto out;
+       }
+
+       dev->recvd_msg = 0;
+       dev_dbg(&dev->pdev->dev, "host_hw_state = 0x%08x, me_hw_state = 0x%08x.\n",
+           dev->host_hw_state, dev->me_hw_state);
+       dev_dbg(&dev->pdev->dev, "ME turn on ME_RDY and host turn on H_RDY.\n");
+       dev_dbg(&dev->pdev->dev, "link layer has been established.\n");
+       dev_dbg(&dev->pdev->dev, "MEI  start success.\n");
+       ret = 0;
+
+out:
+       mutex_unlock(&dev->device_lock);
+       return ret;
+}
+
+/**
+ * mei_hw_reset - resets fw via mei csr register.
+ *
+ * @dev: the device structure
+ * @interrupts_enabled: if interrupt should be enabled after reset.
+ */
+static void mei_hw_reset(struct mei_device *dev, int interrupts_enabled)
+{
+       dev->host_hw_state |= (H_RST | H_IG);
+
+       if (interrupts_enabled)
+               mei_enable_interrupts(dev);
+       else
+               mei_disable_interrupts(dev);
+}
+
+/**
+ * mei_reset - resets host and fw.
+ *
+ * @dev: the device structure
+ * @interrupts_enabled: if interrupt should be enabled after reset.
+ */
+void mei_reset(struct mei_device *dev, int interrupts_enabled)
+{
+       struct mei_cl *cl_pos = NULL;
+       struct mei_cl *cl_next = NULL;
+       struct mei_cl_cb *cb_pos = NULL;
+       struct mei_cl_cb *cb_next = NULL;
+       bool unexpected;
+
+       if (dev->mei_state == MEI_RECOVERING_FROM_RESET) {
+               dev->need_reset = 1;
+               return;
+       }
+
+       unexpected = (dev->mei_state != MEI_INITIALIZING &&
+                       dev->mei_state != MEI_DISABLED &&
+                       dev->mei_state != MEI_POWER_DOWN &&
+                       dev->mei_state != MEI_POWER_UP);
+
+       dev->host_hw_state = mei_hcsr_read(dev);
+
+       dev_dbg(&dev->pdev->dev, "before reset host_hw_state = 0x%08x.\n",
+           dev->host_hw_state);
+
+       mei_hw_reset(dev, interrupts_enabled);
+
+       dev->host_hw_state &= ~H_RST;
+       dev->host_hw_state |= H_IG;
+
+       mei_hcsr_set(dev);
+
+       dev_dbg(&dev->pdev->dev, "currently saved host_hw_state = 0x%08x.\n",
+           dev->host_hw_state);
+
+       dev->need_reset = 0;
+
+       if (dev->mei_state != MEI_INITIALIZING) {
+               if (dev->mei_state != MEI_DISABLED &&
+                   dev->mei_state != MEI_POWER_DOWN)
+                       dev->mei_state = MEI_RESETING;
+
+               list_for_each_entry_safe(cl_pos,
+                               cl_next, &dev->file_list, link) {
+                       cl_pos->state = MEI_FILE_DISCONNECTED;
+                       cl_pos->mei_flow_ctrl_creds = 0;
+                       cl_pos->read_cb = NULL;
+                       cl_pos->timer_count = 0;
+               }
+               /* remove entry if already in list */
+               dev_dbg(&dev->pdev->dev, "list del iamthif and wd file list.\n");
+               mei_remove_client_from_file_list(dev,
+                               dev->wd_cl.host_client_id);
+
+               mei_remove_client_from_file_list(dev,
+                               dev->iamthif_cl.host_client_id);
+
+               mei_reset_iamthif_params(dev);
+               dev->wd_due_counter = 0;
+               dev->extra_write_index = 0;
+       }
+
+       dev->num_mei_me_clients = 0;
+       dev->rd_msg_hdr = 0;
+       dev->stop = 0;
+       dev->wd_pending = 0;
+
+       /* update the state of the registers after reset */
+       dev->host_hw_state = mei_hcsr_read(dev);
+       dev->me_hw_state = mei_mecsr_read(dev);
+
+       dev_dbg(&dev->pdev->dev, "after reset host_hw_state = 0x%08x, me_hw_state = 0x%08x.\n",
+           dev->host_hw_state, dev->me_hw_state);
+
+       if (unexpected)
+               dev_warn(&dev->pdev->dev, "unexpected reset.\n");
+
+       /* Wake up all readings so they can be interrupted */
+       list_for_each_entry_safe(cl_pos, cl_next, &dev->file_list, link) {
+               if (waitqueue_active(&cl_pos->rx_wait)) {
+                       dev_dbg(&dev->pdev->dev, "Waking up client!\n");
+                       wake_up_interruptible(&cl_pos->rx_wait);
+               }
+       }
+       /* remove all waiting requests */
+       if (dev->write_list.status == 0 &&
+               !list_empty(&dev->write_list.mei_cb.cb_list)) {
+               list_for_each_entry_safe(cb_pos, cb_next,
+                               &dev->write_list.mei_cb.cb_list, cb_list) {
+                       if (cb_pos) {
+                               list_del(&cb_pos->cb_list);
+                               mei_free_cb_private(cb_pos);
+                               cb_pos = NULL;
+                       }
+               }
+       }
+}
+
+
+
+/**
+ * host_start_message - mei host sends start message.
+ *
+ * @dev: the device structure
+ *
+ * returns none.
+ */
+void host_start_message(struct mei_device *dev)
+{
+       struct mei_msg_hdr *mei_hdr;
+       struct hbm_host_version_request *host_start_req;
+
+       /* host start message */
+       mei_hdr = (struct mei_msg_hdr *) &dev->wr_msg_buf[0];
+       mei_hdr->host_addr = 0;
+       mei_hdr->me_addr = 0;
+       mei_hdr->length = sizeof(struct hbm_host_version_request);
+       mei_hdr->msg_complete = 1;
+       mei_hdr->reserved = 0;
+
+       host_start_req =
+           (struct hbm_host_version_request *) &dev->wr_msg_buf[1];
+       memset(host_start_req, 0, sizeof(struct hbm_host_version_request));
+       host_start_req->cmd.cmd = HOST_START_REQ_CMD;
+       host_start_req->host_version.major_version = HBM_MAJOR_VERSION;
+       host_start_req->host_version.minor_version = HBM_MINOR_VERSION;
+       dev->recvd_msg = 0;
+       if (!mei_write_message(dev, mei_hdr,
+                                      (unsigned char *) (host_start_req),
+                                      mei_hdr->length)) {
+               dev_dbg(&dev->pdev->dev, "write send version message to FW fail.\n");
+               dev->mei_state = MEI_RESETING;
+               mei_reset(dev, 1);
+       }
+       dev->init_clients_state = MEI_START_MESSAGE;
+       dev->init_clients_timer = INIT_CLIENTS_TIMEOUT;
+       return ;
+}
+
+/**
+ * host_enum_clients_message - host sends enumeration client request message.
+ *
+ * @dev: the device structure
+ *
+ * returns none.
+ */
+void host_enum_clients_message(struct mei_device *dev)
+{
+       struct mei_msg_hdr *mei_hdr;
+       struct hbm_host_enum_request *host_enum_req;
+       mei_hdr = (struct mei_msg_hdr *) &dev->wr_msg_buf[0];
+       /* enumerate clients */
+       mei_hdr->host_addr = 0;
+       mei_hdr->me_addr = 0;
+       mei_hdr->length = sizeof(struct hbm_host_enum_request);
+       mei_hdr->msg_complete = 1;
+       mei_hdr->reserved = 0;
+
+       host_enum_req = (struct hbm_host_enum_request *) &dev->wr_msg_buf[1];
+       memset(host_enum_req, 0, sizeof(struct hbm_host_enum_request));
+       host_enum_req->cmd.cmd = HOST_ENUM_REQ_CMD;
+       if (!mei_write_message(dev, mei_hdr,
+                              (unsigned char *) (host_enum_req),
+                               mei_hdr->length)) {
+               dev->mei_state = MEI_RESETING;
+               dev_dbg(&dev->pdev->dev, "write send enumeration request message to FW fail.\n");
+               mei_reset(dev, 1);
+       }
+       dev->init_clients_state = MEI_ENUM_CLIENTS_MESSAGE;
+       dev->init_clients_timer = INIT_CLIENTS_TIMEOUT;
+       return ;
+}
+
+
+/**
+ * allocate_me_clients_storage - allocates storage for me clients
+ *
+ * @dev: the device structure
+ *
+ * returns none.
+ */
+void allocate_me_clients_storage(struct mei_device *dev)
+{
+       struct mei_me_client *clients;
+       int b;
+
+       /* count how many ME clients we have */
+       for_each_set_bit(b, dev->me_clients_map, MEI_CLIENTS_MAX)
+               dev->num_mei_me_clients++;
+
+       if (dev->num_mei_me_clients <= 0)
+               return ;
+
+
+       if (dev->me_clients != NULL) {
+               kfree(dev->me_clients);
+               dev->me_clients = NULL;
+       }
+       dev_dbg(&dev->pdev->dev, "memory allocation for ME clients size=%zd.\n",
+               dev->num_mei_me_clients * sizeof(struct mei_me_client));
+       /* allocate storage for ME clients representation */
+       clients = kcalloc(dev->num_mei_me_clients,
+                       sizeof(struct mei_me_client), GFP_KERNEL);
+       if (!clients) {
+               dev_dbg(&dev->pdev->dev, "memory allocation for ME clients failed.\n");
+               dev->mei_state = MEI_RESETING;
+               mei_reset(dev, 1);
+               return ;
+       }
+       dev->me_clients = clients;
+       return ;
+}
+/**
+ * host_client_properties - reads properties for client
+ *
+ * @dev: the device structure
+ *
+ * returns none.
+ */
+void host_client_properties(struct mei_device *dev)
+{
+       struct mei_msg_hdr *mei_header;
+       struct hbm_props_request *host_cli_req;
+       int b;
+       u8 client_num = dev->me_client_presentation_num;
+
+       b = dev->me_client_index;
+       b = find_next_bit(dev->me_clients_map, MEI_CLIENTS_MAX, b);
+       if (b < MEI_CLIENTS_MAX) {
+               dev->me_clients[client_num].client_id = b;
+               dev->me_clients[client_num].mei_flow_ctrl_creds = 0;
+               mei_header = (struct mei_msg_hdr *)&dev->wr_msg_buf[0];
+               mei_header->host_addr = 0;
+               mei_header->me_addr = 0;
+               mei_header->length = sizeof(struct hbm_props_request);
+               mei_header->msg_complete = 1;
+               mei_header->reserved = 0;
+
+               host_cli_req = (struct hbm_props_request *)&dev->wr_msg_buf[1];
+
+               memset(host_cli_req, 0, sizeof(struct hbm_props_request));
+
+               host_cli_req->cmd.cmd = HOST_CLIENT_PROPERTIES_REQ_CMD;
+               host_cli_req->address = b;
+
+               if (!mei_write_message(dev, mei_header,
+                               (unsigned char *)host_cli_req,
+                               mei_header->length)) {
+                       dev->mei_state = MEI_RESETING;
+                       dev_dbg(&dev->pdev->dev, "write send enumeration request message to FW fail.\n");
+                       mei_reset(dev, 1);
+                       return;
+               }
+
+               dev->init_clients_timer = INIT_CLIENTS_TIMEOUT;
+               dev->me_client_index = b;
+               return;
+       }
+
+
+       /*
+        * Clear Map for indicating now ME clients
+        * with associated host client
+        */
+       bitmap_zero(dev->host_clients_map, MEI_CLIENTS_MAX);
+       dev->write_hang = -1;
+       dev->open_handle_count = 0;
+       bitmap_set(dev->host_clients_map, 0, 3);
+       dev->mei_state = MEI_ENABLED;
+
+       mei_wd_host_init(dev);
+       return;
+}
+
+/**
+ * mei_init_file_private - initializes private file structure.
+ *
+ * @priv: private file structure to be initialized
+ * @file: the file structure
+ */
+void mei_init_file_private(struct mei_cl *priv, struct mei_device *dev)
+{
+       memset(priv, 0, sizeof(struct mei_cl));
+       init_waitqueue_head(&priv->wait);
+       init_waitqueue_head(&priv->rx_wait);
+       init_waitqueue_head(&priv->tx_wait);
+       INIT_LIST_HEAD(&priv->link);
+       priv->reading_state = MEI_IDLE;
+       priv->writing_state = MEI_IDLE;
+       priv->dev = dev;
+}
+
+int mei_find_me_client_index(const struct mei_device *dev, uuid_le cuuid)
+{
+       int i, res = -1;
+
+       for (i = 0; i < dev->num_mei_me_clients; ++i)
+               if (uuid_le_cmp(cuuid,
+                               dev->me_clients[i].props.protocol_name) == 0) {
+                       res = i;
+                       break;
+               }
+
+       return res;
+}
+
+
+/**
+ * mei_find_me_client_update_filext - searches for ME client guid
+ *                       sets client_id in mei_file_private if found
+ * @dev: the device structure
+ * @priv: private file structure to set client_id in
+ * @cguid: searched guid of ME client
+ * @client_id: id of host client to be set in file private structure
+ *
+ * returns ME client index
+ */
+u8 mei_find_me_client_update_filext(struct mei_device *dev, struct mei_cl *priv,
+                               const uuid_le *cguid, u8 client_id)
+{
+       int i;
+
+       if (!dev || !priv || !cguid)
+               return 0;
+
+       /* check for valid client id */
+       i = mei_find_me_client_index(dev, *cguid);
+       if (i >= 0) {
+               priv->me_client_id = dev->me_clients[i].client_id;
+               priv->state = MEI_FILE_CONNECTING;
+               priv->host_client_id = client_id;
+
+               list_add_tail(&priv->link, &dev->file_list);
+               return (u8)i;
+       }
+
+       return 0;
+}
+
+/**
+ * host_init_iamthif - mei initialization iamthif client.
+ *
+ * @dev: the device structure
+ *
+ */
+void host_init_iamthif(struct mei_device *dev)
+{
+       u8 i;
+       unsigned char *msg_buf;
+
+       mei_init_file_private(&dev->iamthif_cl, dev);
+       dev->iamthif_cl.state = MEI_FILE_DISCONNECTED;
+
+       /* find ME amthi client */
+       i = mei_find_me_client_update_filext(dev, &dev->iamthif_cl,
+                           &mei_amthi_guid, MEI_IAMTHIF_HOST_CLIENT_ID);
+       if (dev->iamthif_cl.state != MEI_FILE_CONNECTING) {
+               dev_dbg(&dev->pdev->dev, "failed to find iamthif client.\n");
+               return;
+       }
+
+       /* Do not render the system unusable when iamthif_mtu is not equal to
+       the value received from ME.
+       Assign iamthif_mtu to the value received from ME in order to solve the
+       hardware macro incompatibility. */
+
+       dev_dbg(&dev->pdev->dev, "[DEFAULT] IAMTHIF = %d\n", dev->iamthif_mtu);
+       dev->iamthif_mtu = dev->me_clients[i].props.max_msg_length;
+       dev_dbg(&dev->pdev->dev,
+                       "IAMTHIF = %d\n",
+                       dev->me_clients[i].props.max_msg_length);
+
+       kfree(dev->iamthif_msg_buf);
+       dev->iamthif_msg_buf = NULL;
+
+       /* allocate storage for ME message buffer */
+       msg_buf = kcalloc(dev->iamthif_mtu,
+                       sizeof(unsigned char), GFP_KERNEL);
+       if (!msg_buf) {
+               dev_dbg(&dev->pdev->dev, "memory allocation for ME message buffer failed.\n");
+               return;
+       }
+
+       dev->iamthif_msg_buf = msg_buf;
+
+       if (!mei_connect(dev, &dev->iamthif_cl)) {
+               dev_dbg(&dev->pdev->dev, "Failed to connect to AMTHI client\n");
+               dev->iamthif_cl.state = MEI_FILE_DISCONNECTED;
+               dev->iamthif_cl.host_client_id = 0;
+       } else {
+               dev->iamthif_cl.timer_count = CONNECT_TIMEOUT;
+       }
+}
+
+/**
+ * mei_alloc_file_private - allocates a private file structure and sets it up.
+ * @file: the file structure
+ *
+ * returns  The allocated file or NULL on failure
+ */
+struct mei_cl *mei_alloc_file_private(struct mei_device *dev)
+{
+       struct mei_cl *priv;
+
+       priv = kmalloc(sizeof(struct mei_cl), GFP_KERNEL);
+       if (!priv)
+               return NULL;
+
+       mei_init_file_private(priv, dev);
+
+       return priv;
+}
+
+
+
+/**
+ * mei_disconnect_host_client - sends disconnect message to fw from host client.
+ *
+ * @dev: the device structure
+ * @cl: private data of the file object
+ *
+ * Locking: called under "dev->device_lock" lock
+ *
+ * returns 0 on success, <0 on failure.
+ */
+int mei_disconnect_host_client(struct mei_device *dev, struct mei_cl *cl)
+{
+       int rets, err;
+       long timeout = 15;      /* 15 seconds */
+       struct mei_cl_cb *cb;
+
+       if (!dev || !cl)
+               return -ENODEV;
+
+       if (cl->state != MEI_FILE_DISCONNECTING)
+               return 0;
+
+       cb = kzalloc(sizeof(struct mei_cl_cb), GFP_KERNEL);
+       if (!cb)
+               return -ENOMEM;
+
+       INIT_LIST_HEAD(&cb->cb_list);
+       cb->file_private = cl;
+       cb->major_file_operations = MEI_CLOSE;
+       if (dev->mei_host_buffer_is_empty) {
+               dev->mei_host_buffer_is_empty = 0;
+               if (mei_disconnect(dev, cl)) {
+                       mdelay(10); /* Wait for hardware disconnection ready */
+                       list_add_tail(&cb->cb_list,
+                               &dev->ctrl_rd_list.mei_cb.cb_list);
+               } else {
+                       rets = -ENODEV;
+                       dev_dbg(&dev->pdev->dev, "failed to call mei_disconnect.\n");
+                       goto free;
+               }
+       } else {
+               dev_dbg(&dev->pdev->dev, "add disconnect cb to control write list\n");
+               list_add_tail(&cb->cb_list,
+                               &dev->ctrl_wr_list.mei_cb.cb_list);
+       }
+       mutex_unlock(&dev->device_lock);
+
+       err = wait_event_timeout(dev->wait_recvd_msg,
+                (MEI_FILE_DISCONNECTED == cl->state),
+                timeout * HZ);
+
+       mutex_lock(&dev->device_lock);
+       if (MEI_FILE_DISCONNECTED == cl->state) {
+               rets = 0;
+               dev_dbg(&dev->pdev->dev, "successfully disconnected from FW client.\n");
+       } else {
+               rets = -ENODEV;
+               if (MEI_FILE_DISCONNECTED != cl->state)
+                       dev_dbg(&dev->pdev->dev, "wrong status client disconnect.\n");
+
+               if (err)
+                       dev_dbg(&dev->pdev->dev,
+                                       "wait failed disconnect err=%08x\n",
+                                       err);
+
+               dev_dbg(&dev->pdev->dev, "failed to disconnect from FW client.\n");
+       }
+
+       mei_flush_list(&dev->ctrl_rd_list, cl);
+       mei_flush_list(&dev->ctrl_wr_list, cl);
+free:
+       mei_free_cb_private(cb);
+       return rets;
+}
+
+/**
+ * mei_remove_client_from_file_list -
+ *     removes file private data from device file list
+ *
+ * @dev: the device structure
+ * @host_client_id: host client id to be removed
+ */
+void mei_remove_client_from_file_list(struct mei_device *dev,
+                                      u8 host_client_id)
+{
+       struct mei_cl *cl_pos = NULL;
+       struct mei_cl *cl_next = NULL;
+       list_for_each_entry_safe(cl_pos, cl_next, &dev->file_list, link) {
+               if (host_client_id == cl_pos->host_client_id) {
+                       dev_dbg(&dev->pdev->dev, "remove host client = %d, ME client = %d\n",
+                                       cl_pos->host_client_id,
+                                       cl_pos->me_client_id);
+                       list_del_init(&cl_pos->link);
+                       break;
+               }
+       }
+}
diff --git a/drivers/staging/mei/interface.c b/drivers/staging/mei/interface.c
new file mode 100644 (file)
index 0000000..4959aae
--- /dev/null
@@ -0,0 +1,447 @@
+/*
+ *
+ * Intel Management Engine Interface (Intel MEI) Linux driver
+ * Copyright (c) 2003-2011, Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ */
+
+#include <linux/pci.h>
+#include "mei_dev.h"
+#include "mei.h"
+#include "interface.h"
+
+
+
+/**
+ * mei_set_csr_register - writes H_CSR register to the mei device,
+ * and ignores the H_IS bit for it is write-one-to-zero.
+ *
+ * @dev: the device structure
+ */
+void mei_hcsr_set(struct mei_device *dev)
+{
+       if ((dev->host_hw_state & H_IS) == H_IS)
+               dev->host_hw_state &= ~H_IS;
+       mei_reg_write(dev, H_CSR, dev->host_hw_state);
+       dev->host_hw_state = mei_hcsr_read(dev);
+}
+
+/**
+ * mei_csr_enable_interrupts - enables mei device interrupts
+ *
+ * @dev: the device structure
+ */
+void mei_enable_interrupts(struct mei_device *dev)
+{
+       dev->host_hw_state |= H_IE;
+       mei_hcsr_set(dev);
+}
+
+/**
+ * mei_csr_disable_interrupts - disables mei device interrupts
+ *
+ * @dev: the device structure
+ */
+void mei_disable_interrupts(struct mei_device *dev)
+{
+       dev->host_hw_state &= ~H_IE;
+       mei_hcsr_set(dev);
+}
+
+/**
+ * _host_get_filled_slots - gets number of device filled buffer slots
+ *
+ * @device: the device structure
+ *
+ * returns number of filled slots
+ */
+static unsigned char _host_get_filled_slots(const struct mei_device *dev)
+{
+       char read_ptr, write_ptr;
+
+       read_ptr = (char) ((dev->host_hw_state & H_CBRP) >> 8);
+       write_ptr = (char) ((dev->host_hw_state & H_CBWP) >> 16);
+
+       return (unsigned char) (write_ptr - read_ptr);
+}
+
+/**
+ * mei_host_buffer_is_empty - checks if host buffer is empty.
+ *
+ * @dev: the device structure
+ *
+ * returns 1 if empty, 0 - otherwise.
+ */
+int mei_host_buffer_is_empty(struct mei_device *dev)
+{
+       unsigned char filled_slots;
+
+       dev->host_hw_state = mei_hcsr_read(dev);
+       filled_slots = _host_get_filled_slots(dev);
+
+       if (filled_slots == 0)
+               return 1;
+
+       return 0;
+}
+
+/**
+ * mei_count_empty_write_slots - counts write empty slots.
+ *
+ * @dev: the device structure
+ *
+ * returns -1(ESLOTS_OVERFLOW) if overflow, otherwise empty slots count
+ */
+int mei_count_empty_write_slots(struct mei_device *dev)
+{
+       unsigned char buffer_depth, filled_slots, empty_slots;
+
+       dev->host_hw_state = mei_hcsr_read(dev);
+       buffer_depth = (unsigned char) ((dev->host_hw_state & H_CBD) >> 24);
+       filled_slots = _host_get_filled_slots(dev);
+       empty_slots = buffer_depth - filled_slots;
+
+       /* check for overflow */
+       if (filled_slots > buffer_depth)
+               return -EOVERFLOW;
+
+       return empty_slots;
+}
+
+/**
+ * mei_write_message - writes a message to mei device.
+ *
+ * @dev: the device structure
+ * @header: header of message
+ * @write_buffer: message buffer will be written
+ * @write_length: message size will be written
+ *
+ * returns 1 if success, 0 - otherwise.
+ */
+int mei_write_message(struct mei_device *dev,
+                            struct mei_msg_hdr *header,
+                            unsigned char *write_buffer,
+                            unsigned long write_length)
+{
+       u32 temp_msg = 0;
+       unsigned long bytes_written = 0;
+       unsigned char buffer_depth, filled_slots, empty_slots;
+       unsigned long dw_to_write;
+
+       dev->host_hw_state = mei_hcsr_read(dev);
+
+       dev_dbg(&dev->pdev->dev,
+                       "host_hw_state = 0x%08x.\n",
+                       dev->host_hw_state);
+
+       dev_dbg(&dev->pdev->dev,
+                       "mei_write_message header=%08x.\n",
+                       *((u32 *) header));
+
+       buffer_depth = (unsigned char) ((dev->host_hw_state & H_CBD) >> 24);
+       filled_slots = _host_get_filled_slots(dev);
+       empty_slots = buffer_depth - filled_slots;
+       dev_dbg(&dev->pdev->dev,
+                       "filled = %hu, empty = %hu.\n",
+                       filled_slots, empty_slots);
+
+       dw_to_write = ((write_length + 3) / 4);
+
+       if (dw_to_write > empty_slots)
+               return 0;
+
+       mei_reg_write(dev, H_CB_WW, *((u32 *) header));
+
+       while (write_length >= 4) {
+               mei_reg_write(dev, H_CB_WW,
+                               *(u32 *) (write_buffer + bytes_written));
+               bytes_written += 4;
+               write_length -= 4;
+       }
+
+       if (write_length > 0) {
+               memcpy(&temp_msg, &write_buffer[bytes_written], write_length);
+               mei_reg_write(dev, H_CB_WW, temp_msg);
+       }
+
+       dev->host_hw_state |= H_IG;
+       mei_hcsr_set(dev);
+       dev->me_hw_state = mei_mecsr_read(dev);
+       if ((dev->me_hw_state & ME_RDY_HRA) != ME_RDY_HRA)
+               return 0;
+
+       dev->write_hang = 0;
+       return 1;
+}
+
+/**
+ * mei_count_full_read_slots - counts read full slots.
+ *
+ * @dev: the device structure
+ *
+ * returns -1(ESLOTS_OVERFLOW) if overflow, otherwise filled slots count
+ */
+int mei_count_full_read_slots(struct mei_device *dev)
+{
+       char read_ptr, write_ptr;
+       unsigned char buffer_depth, filled_slots;
+
+       dev->me_hw_state = mei_mecsr_read(dev);
+       buffer_depth = (unsigned char)((dev->me_hw_state & ME_CBD_HRA) >> 24);
+       read_ptr = (char) ((dev->me_hw_state & ME_CBRP_HRA) >> 8);
+       write_ptr = (char) ((dev->me_hw_state & ME_CBWP_HRA) >> 16);
+       filled_slots = (unsigned char) (write_ptr - read_ptr);
+
+       /* check for overflow */
+       if (filled_slots > buffer_depth)
+               return -EOVERFLOW;
+
+       dev_dbg(&dev->pdev->dev, "filled_slots =%08x\n", filled_slots);
+       return (int)filled_slots;
+}
+
+/**
+ * mei_read_slots - reads a message from mei device.
+ *
+ * @dev: the device structure
+ * @buffer: message buffer will be written
+ * @buffer_length: message size will be read
+ */
+void mei_read_slots(struct mei_device *dev,
+                    unsigned char *buffer, unsigned long buffer_length)
+{
+       u32 i = 0;
+       unsigned char temp_buf[sizeof(u32)];
+
+       while (buffer_length >= sizeof(u32)) {
+               ((u32 *) buffer)[i] = mei_mecbrw_read(dev);
+
+               dev_dbg(&dev->pdev->dev,
+                               "buffer[%d]= %d\n",
+                               i, ((u32 *) buffer)[i]);
+
+               i++;
+               buffer_length -= sizeof(u32);
+       }
+
+       if (buffer_length > 0) {
+               *((u32 *) &temp_buf) = mei_mecbrw_read(dev);
+               memcpy(&buffer[i * 4], temp_buf, buffer_length);
+       }
+
+       dev->host_hw_state |= H_IG;
+       mei_hcsr_set(dev);
+}
+
+/**
+ * mei_flow_ctrl_creds - checks flow_control credentials.
+ *
+ * @dev: the device structure
+ * @cl: private data of the file object
+ *
+ * returns 1 if mei_flow_ctrl_creds >0, 0 - otherwise.
+ *     -ENOENT if mei_cl is not present
+ *     -EINVAL if single_recv_buf == 0
+ */
+int mei_flow_ctrl_creds(struct mei_device *dev, struct mei_cl *cl)
+{
+       int i;
+
+       if (!dev->num_mei_me_clients)
+               return 0;
+
+       if (cl->mei_flow_ctrl_creds > 0)
+               return 1;
+
+       for (i = 0; i < dev->num_mei_me_clients; i++) {
+               struct mei_me_client  *me_cl = &dev->me_clients[i];
+               if (me_cl->client_id == cl->me_client_id) {
+                       if (me_cl->mei_flow_ctrl_creds) {
+                               if (WARN_ON(me_cl->props.single_recv_buf == 0))
+                                       return -EINVAL;
+                               return 1;
+                       } else {
+                               return 0;
+                       }
+               }
+       }
+       return -ENOENT;
+}
+
+/**
+ * mei_flow_ctrl_reduce - reduces flow_control.
+ *
+ * @dev: the device structure
+ * @cl: private data of the file object
+ * @returns
+ *     0 on success
+ *     -ENOENT when me client is not found
+ *     -EINVAL wehn ctrl credits are <= 0
+ */
+int mei_flow_ctrl_reduce(struct mei_device *dev, struct mei_cl *cl)
+{
+       int i;
+
+       if (!dev->num_mei_me_clients)
+               return -ENOENT;
+
+       for (i = 0; i < dev->num_mei_me_clients; i++) {
+               struct mei_me_client  *me_cl = &dev->me_clients[i];
+               if (me_cl->client_id == cl->me_client_id) {
+                       if (me_cl->props.single_recv_buf != 0) {
+                               if (WARN_ON(me_cl->mei_flow_ctrl_creds <= 0))
+                                       return -EINVAL;
+                               dev->me_clients[i].mei_flow_ctrl_creds--;
+                       } else {
+                               if (WARN_ON(cl->mei_flow_ctrl_creds <= 0))
+                                       return -EINVAL;
+                               cl->mei_flow_ctrl_creds--;
+                       }
+                       return 0;
+               }
+       }
+       return -ENOENT;
+}
+
+/**
+ * mei_send_flow_control - sends flow control to fw.
+ *
+ * @dev: the device structure
+ * @cl: private data of the file object
+ *
+ * returns 1 if success, 0 - otherwise.
+ */
+int mei_send_flow_control(struct mei_device *dev, struct mei_cl *cl)
+{
+       struct mei_msg_hdr *mei_hdr;
+       struct hbm_flow_control *mei_flow_control;
+
+       mei_hdr = (struct mei_msg_hdr *) &dev->wr_msg_buf[0];
+       mei_hdr->host_addr = 0;
+       mei_hdr->me_addr = 0;
+       mei_hdr->length = sizeof(struct hbm_flow_control);
+       mei_hdr->msg_complete = 1;
+       mei_hdr->reserved = 0;
+
+       mei_flow_control = (struct hbm_flow_control *) &dev->wr_msg_buf[1];
+       memset(mei_flow_control, 0, sizeof(mei_flow_control));
+       mei_flow_control->host_addr = cl->host_client_id;
+       mei_flow_control->me_addr = cl->me_client_id;
+       mei_flow_control->cmd.cmd = MEI_FLOW_CONTROL_CMD;
+       memset(mei_flow_control->reserved, 0,
+                       sizeof(mei_flow_control->reserved));
+       dev_dbg(&dev->pdev->dev, "sending flow control host client = %d, ME client = %d\n",
+           cl->host_client_id, cl->me_client_id);
+       if (!mei_write_message(dev, mei_hdr,
+                               (unsigned char *) mei_flow_control,
+                               sizeof(struct hbm_flow_control)))
+               return 0;
+
+       return 1;
+
+}
+
+/**
+ * mei_other_client_is_connecting - checks if other
+ *    client with the same client id is connected.
+ *
+ * @dev: the device structure
+ * @cl: private data of the file object
+ *
+ * returns 1 if other client is connected, 0 - otherwise.
+ */
+int mei_other_client_is_connecting(struct mei_device *dev,
+                               struct mei_cl *cl)
+{
+       struct mei_cl *cl_pos = NULL;
+       struct mei_cl *cl_next = NULL;
+
+       list_for_each_entry_safe(cl_pos, cl_next, &dev->file_list, link) {
+               if ((cl_pos->state == MEI_FILE_CONNECTING) &&
+                       (cl_pos != cl) &&
+                       cl->me_client_id == cl_pos->me_client_id)
+                       return 1;
+
+       }
+       return 0;
+}
+
+/**
+ * mei_disconnect - sends disconnect message to fw.
+ *
+ * @dev: the device structure
+ * @cl: private data of the file object
+ *
+ * returns 1 if success, 0 - otherwise.
+ */
+int mei_disconnect(struct mei_device *dev, struct mei_cl *cl)
+{
+       struct mei_msg_hdr *mei_hdr;
+       struct hbm_client_disconnect_request *mei_cli_disconnect;
+
+       mei_hdr = (struct mei_msg_hdr *) &dev->wr_msg_buf[0];
+       mei_hdr->host_addr = 0;
+       mei_hdr->me_addr = 0;
+       mei_hdr->length = sizeof(struct hbm_client_disconnect_request);
+       mei_hdr->msg_complete = 1;
+       mei_hdr->reserved = 0;
+
+       mei_cli_disconnect =
+           (struct hbm_client_disconnect_request *) &dev->wr_msg_buf[1];
+       memset(mei_cli_disconnect, 0, sizeof(mei_cli_disconnect));
+       mei_cli_disconnect->host_addr = cl->host_client_id;
+       mei_cli_disconnect->me_addr = cl->me_client_id;
+       mei_cli_disconnect->cmd.cmd = CLIENT_DISCONNECT_REQ_CMD;
+       mei_cli_disconnect->reserved[0] = 0;
+
+       if (!mei_write_message(dev, mei_hdr,
+                               (unsigned char *) mei_cli_disconnect,
+                               sizeof(struct hbm_client_disconnect_request)))
+               return 0;
+
+       return 1;
+}
+
+/**
+ * mei_connect - sends connect message to fw.
+ *
+ * @dev: the device structure
+ * @cl: private data of the file object
+ *
+ * returns 1 if success, 0 - otherwise.
+ */
+int mei_connect(struct mei_device *dev, struct mei_cl *cl)
+{
+       struct mei_msg_hdr *mei_hdr;
+       struct hbm_client_connect_request *mei_cli_connect;
+
+       mei_hdr = (struct mei_msg_hdr *) &dev->wr_msg_buf[0];
+       mei_hdr->host_addr = 0;
+       mei_hdr->me_addr = 0;
+       mei_hdr->length = sizeof(struct hbm_client_connect_request);
+       mei_hdr->msg_complete = 1;
+       mei_hdr->reserved = 0;
+
+       mei_cli_connect =
+           (struct hbm_client_connect_request *) &dev->wr_msg_buf[1];
+       mei_cli_connect->host_addr = cl->host_client_id;
+       mei_cli_connect->me_addr = cl->me_client_id;
+       mei_cli_connect->cmd.cmd = CLIENT_CONNECT_REQ_CMD;
+       mei_cli_connect->reserved = 0;
+
+       if (!mei_write_message(dev, mei_hdr,
+                               (unsigned char *) mei_cli_connect,
+                               sizeof(struct hbm_client_connect_request)))
+               return 0;
+
+       return 1;
+}
diff --git a/drivers/staging/mei/interface.h b/drivers/staging/mei/interface.h
new file mode 100644 (file)
index 0000000..d0bf5cf
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ *
+ * Intel Management Engine Interface (Intel MEI) Linux driver
+ * Copyright (c) 2003-2011, Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ */
+
+
+
+#ifndef _MEI_INTERFACE_H_
+#define _MEI_INTERFACE_H_
+
+#include "mei.h"
+#include "mei_dev.h"
+
+
+#define AMT_WD_VALUE 120       /* seconds */
+
+#define MEI_WATCHDOG_DATA_SIZE         16
+#define MEI_START_WD_DATA_SIZE         20
+#define MEI_WD_PARAMS_SIZE             4
+
+
+void mei_read_slots(struct mei_device *dev,
+                    unsigned char *buffer, unsigned long buffer_length);
+
+int mei_write_message(struct mei_device *dev,
+                            struct mei_msg_hdr *header,
+                            unsigned char *write_buffer,
+                            unsigned long write_length);
+
+int mei_host_buffer_is_empty(struct mei_device *dev);
+
+int mei_count_full_read_slots(struct mei_device *dev);
+
+int mei_count_empty_write_slots(struct mei_device *dev);
+
+int mei_flow_ctrl_creds(struct mei_device *dev, struct mei_cl *cl);
+
+int mei_wd_send(struct mei_device *dev);
+int mei_wd_stop(struct mei_device *dev, bool preserve);
+void mei_wd_host_init(struct mei_device *dev);
+void mei_wd_start_setup(struct mei_device *dev);
+
+int mei_flow_ctrl_reduce(struct mei_device *dev, struct mei_cl *cl);
+
+int mei_send_flow_control(struct mei_device *dev, struct mei_cl *cl);
+
+int mei_disconnect(struct mei_device *dev, struct mei_cl *cl);
+int mei_other_client_is_connecting(struct mei_device *dev, struct mei_cl *cl);
+int mei_connect(struct mei_device *dev, struct mei_cl *cl);
+
+#endif /* _MEI_INTERFACE_H_ */
diff --git a/drivers/staging/mei/interrupt.c b/drivers/staging/mei/interrupt.c
new file mode 100644 (file)
index 0000000..d1b9214
--- /dev/null
@@ -0,0 +1,1624 @@
+/*
+ *
+ * Intel Management Engine Interface (Intel MEI) Linux driver
+ * Copyright (c) 2003-2011, Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ */
+
+
+#include <linux/pci.h>
+#include <linux/kthread.h>
+#include <linux/interrupt.h>
+#include <linux/fs.h>
+#include <linux/jiffies.h>
+
+#include "mei_dev.h"
+#include "mei.h"
+#include "hw.h"
+#include "interface.h"
+
+
+/**
+ * mei_interrupt_quick_handler - The ISR of the MEI device
+ *
+ * @irq: The irq number
+ * @dev_id: pointer to the device structure
+ *
+ * returns irqreturn_t
+ */
+irqreturn_t mei_interrupt_quick_handler(int irq, void *dev_id)
+{
+       struct mei_device *dev = (struct mei_device *) dev_id;
+       u32 csr_reg = mei_hcsr_read(dev);
+
+       if ((csr_reg & H_IS) != H_IS)
+               return IRQ_NONE;
+
+       /* clear H_IS bit in H_CSR */
+       mei_reg_write(dev, H_CSR, csr_reg);
+
+       return IRQ_WAKE_THREAD;
+}
+
+/**
+ * _mei_cmpl - processes completed operation.
+ *
+ * @cl: private data of the file object.
+ * @cb_pos: callback block.
+ */
+static void _mei_cmpl(struct mei_cl *cl, struct mei_cl_cb *cb_pos)
+{
+       if (cb_pos->major_file_operations == MEI_WRITE) {
+               mei_free_cb_private(cb_pos);
+               cb_pos = NULL;
+               cl->writing_state = MEI_WRITE_COMPLETE;
+               if (waitqueue_active(&cl->tx_wait))
+                       wake_up_interruptible(&cl->tx_wait);
+
+       } else if (cb_pos->major_file_operations == MEI_READ &&
+                       MEI_READING == cl->reading_state) {
+               cl->reading_state = MEI_READ_COMPLETE;
+               if (waitqueue_active(&cl->rx_wait))
+                       wake_up_interruptible(&cl->rx_wait);
+
+       }
+}
+
+/**
+ * _mei_cmpl_iamthif - processes completed iamthif operation.
+ *
+ * @dev: the device structure.
+ * @cb_pos: callback block.
+ */
+static void _mei_cmpl_iamthif(struct mei_device *dev, struct mei_cl_cb *cb_pos)
+{
+       if (dev->iamthif_canceled != 1) {
+               dev->iamthif_state = MEI_IAMTHIF_READ_COMPLETE;
+               dev->iamthif_stall_timer = 0;
+               memcpy(cb_pos->response_buffer.data,
+                               dev->iamthif_msg_buf,
+                               dev->iamthif_msg_buf_index);
+               list_add_tail(&cb_pos->cb_list,
+                               &dev->amthi_read_complete_list.mei_cb.cb_list);
+               dev_dbg(&dev->pdev->dev, "amthi read completed.\n");
+               dev->iamthif_timer = jiffies;
+               dev_dbg(&dev->pdev->dev, "dev->iamthif_timer = %ld\n",
+                               dev->iamthif_timer);
+       } else {
+               run_next_iamthif_cmd(dev);
+       }
+
+       dev_dbg(&dev->pdev->dev, "completing amthi call back.\n");
+       wake_up_interruptible(&dev->iamthif_cl.wait);
+}
+
+
+/**
+ * mei_irq_thread_read_amthi_message - bottom half read routine after ISR to
+ * handle the read amthi message data processing.
+ *
+ * @complete_list: An instance of our list structure
+ * @dev: the device structure
+ * @mei_hdr: header of amthi message
+ *
+ * returns 0 on success, <0 on failure.
+ */
+static int mei_irq_thread_read_amthi_message(struct mei_io_list *complete_list,
+               struct mei_device *dev,
+               struct mei_msg_hdr *mei_hdr)
+{
+       struct mei_cl *cl;
+       struct mei_cl_cb *cb;
+       unsigned char *buffer;
+
+       BUG_ON(mei_hdr->me_addr != dev->iamthif_cl.me_client_id);
+       BUG_ON(dev->iamthif_state != MEI_IAMTHIF_READING);
+
+       buffer = (unsigned char *) (dev->iamthif_msg_buf +
+                       dev->iamthif_msg_buf_index);
+       BUG_ON(dev->iamthif_mtu < dev->iamthif_msg_buf_index + mei_hdr->length);
+
+       mei_read_slots(dev, buffer, mei_hdr->length);
+
+       dev->iamthif_msg_buf_index += mei_hdr->length;
+
+       if (!mei_hdr->msg_complete)
+               return 0;
+
+       dev_dbg(&dev->pdev->dev,
+                       "amthi_message_buffer_index =%d\n",
+                       mei_hdr->length);
+
+       dev_dbg(&dev->pdev->dev, "completed amthi read.\n ");
+       if (!dev->iamthif_current_cb)
+               return -ENODEV;
+
+       cb = dev->iamthif_current_cb;
+       dev->iamthif_current_cb = NULL;
+
+       cl = (struct mei_cl *)cb->file_private;
+       if (!cl)
+               return -ENODEV;
+
+       dev->iamthif_stall_timer = 0;
+       cb->information =       dev->iamthif_msg_buf_index;
+       cb->read_time = jiffies;
+       if (dev->iamthif_ioctl && cl == &dev->iamthif_cl) {
+               /* found the iamthif cb */
+               dev_dbg(&dev->pdev->dev, "complete the amthi read cb.\n ");
+               dev_dbg(&dev->pdev->dev, "add the amthi read cb to complete.\n ");
+               list_add_tail(&cb->cb_list,
+                                               &complete_list->mei_cb.cb_list);
+       }
+       return 0;
+}
+
+/**
+ * _mei_irq_thread_state_ok - checks if mei header matches file private data
+ *
+ * @cl: private data of the file object
+ * @mei_hdr: header of mei client message
+ *
+ * returns !=0 if matches, 0 if no match.
+ */
+static int _mei_irq_thread_state_ok(struct mei_cl *cl,
+                               struct mei_msg_hdr *mei_hdr)
+{
+       return (cl->host_client_id == mei_hdr->host_addr &&
+               cl->me_client_id == mei_hdr->me_addr &&
+               cl->state == MEI_FILE_CONNECTED &&
+               MEI_READ_COMPLETE != cl->reading_state);
+}
+
+/**
+ * mei_irq_thread_read_client_message - bottom half read routine after ISR to
+ * handle the read mei client message data processing.
+ *
+ * @complete_list: An instance of our list structure
+ * @dev: the device structure
+ * @mei_hdr: header of mei client message
+ *
+ * returns 0 on success, <0 on failure.
+ */
+static int mei_irq_thread_read_client_message(struct mei_io_list *complete_list,
+               struct mei_device *dev,
+               struct mei_msg_hdr *mei_hdr)
+{
+       struct mei_cl *cl;
+       struct mei_cl_cb *cb_pos = NULL, *cb_next = NULL;
+       unsigned char *buffer;
+
+       dev_dbg(&dev->pdev->dev, "start client msg\n");
+       if (!(dev->read_list.status == 0 &&
+             !list_empty(&dev->read_list.mei_cb.cb_list)))
+               goto quit;
+
+       list_for_each_entry_safe(cb_pos, cb_next,
+                       &dev->read_list.mei_cb.cb_list, cb_list) {
+               cl = (struct mei_cl *)cb_pos->file_private;
+               if (cl && _mei_irq_thread_state_ok(cl, mei_hdr)) {
+                       cl->reading_state = MEI_READING;
+                       buffer = (unsigned char *)
+                               (cb_pos->response_buffer.data +
+                               cb_pos->information);
+                       BUG_ON(cb_pos->response_buffer.size <
+                                       mei_hdr->length +
+                                       cb_pos->information);
+
+                       if (cb_pos->response_buffer.size <
+                                       mei_hdr->length + cb_pos->information) {
+                               dev_dbg(&dev->pdev->dev, "message overflow.\n");
+                               list_del(&cb_pos->cb_list);
+                               return -ENOMEM;
+                       }
+                       if (buffer)
+                               mei_read_slots(dev, buffer, mei_hdr->length);
+
+                       cb_pos->information += mei_hdr->length;
+                       if (mei_hdr->msg_complete) {
+                               cl->status = 0;
+                               list_del(&cb_pos->cb_list);
+                               dev_dbg(&dev->pdev->dev,
+                                       "completed read host client = %d,"
+                                       "ME client = %d, "
+                                       "data length = %lu\n",
+                                       cl->host_client_id,
+                                       cl->me_client_id,
+                                       cb_pos->information);
+
+                               *(cb_pos->response_buffer.data +
+                                       cb_pos->information) = '\0';
+                               dev_dbg(&dev->pdev->dev, "cb_pos->res_buffer - %s\n",
+                                       cb_pos->response_buffer.data);
+                               list_add_tail(&cb_pos->cb_list,
+                                       &complete_list->mei_cb.cb_list);
+                       }
+
+                       break;
+               }
+
+       }
+
+quit:
+       dev_dbg(&dev->pdev->dev, "message read\n");
+       if (!buffer) {
+               mei_read_slots(dev, (unsigned char *) dev->rd_msg_buf,
+                                               mei_hdr->length);
+               dev_dbg(&dev->pdev->dev, "discarding message, header =%08x.\n",
+                               *(u32 *) dev->rd_msg_buf);
+       }
+
+       return 0;
+}
+
+/**
+ * _mei_irq_thread_iamthif_read - prepares to read iamthif data.
+ *
+ * @dev: the device structure.
+ * @slots: free slots.
+ *
+ * returns 0, OK; otherwise, error.
+ */
+static int _mei_irq_thread_iamthif_read(struct mei_device *dev, s32 *slots)
+{
+
+       if (((*slots) * sizeof(u32)) >= (sizeof(struct mei_msg_hdr)
+                       + sizeof(struct hbm_flow_control))) {
+               *slots -= (sizeof(struct mei_msg_hdr) +
+                               sizeof(struct hbm_flow_control) + 3) / 4;
+               if (!mei_send_flow_control(dev, &dev->iamthif_cl)) {
+                       dev_dbg(&dev->pdev->dev, "iamthif flow control failed\n");
+               } else {
+                       dev_dbg(&dev->pdev->dev, "iamthif flow control success\n");
+                       dev->iamthif_state = MEI_IAMTHIF_READING;
+                       dev->iamthif_flow_control_pending = 0;
+                       dev->iamthif_msg_buf_index = 0;
+                       dev->iamthif_msg_buf_size = 0;
+                       dev->iamthif_stall_timer = IAMTHIF_STALL_TIMER;
+                       dev->mei_host_buffer_is_empty =
+                                       mei_host_buffer_is_empty(dev);
+               }
+               return 0;
+       } else {
+               return -EMSGSIZE;
+       }
+}
+
+/**
+ * _mei_irq_thread_close - processes close related operation.
+ *
+ * @dev: the device structure.
+ * @slots: free slots.
+ * @cb_pos: callback block.
+ * @cl: private data of the file object.
+ * @cmpl_list: complete list.
+ *
+ * returns 0, OK; otherwise, error.
+ */
+static int _mei_irq_thread_close(struct mei_device *dev, s32 *slots,
+                               struct mei_cl_cb *cb_pos,
+                               struct mei_cl *cl,
+                               struct mei_io_list *cmpl_list)
+{
+       if ((*slots * sizeof(u32)) >= (sizeof(struct mei_msg_hdr) +
+                       sizeof(struct hbm_client_disconnect_request))) {
+               *slots -= (sizeof(struct mei_msg_hdr) +
+                       sizeof(struct hbm_client_disconnect_request) + 3) / 4;
+
+               if (!mei_disconnect(dev, cl)) {
+                       cl->status = 0;
+                       cb_pos->information = 0;
+                       list_move_tail(&cb_pos->cb_list,
+                                       &cmpl_list->mei_cb.cb_list);
+                       return -EMSGSIZE;
+               } else {
+                       cl->state = MEI_FILE_DISCONNECTING;
+                       cl->status = 0;
+                       cb_pos->information = 0;
+                       list_move_tail(&cb_pos->cb_list,
+                                       &dev->ctrl_rd_list.mei_cb.cb_list);
+                       cl->timer_count = MEI_CONNECT_TIMEOUT;
+               }
+       } else {
+               /* return the cancel routine */
+               return -EBADMSG;
+       }
+
+       return 0;
+}
+
+/**
+ * is_treat_specially_client - checks if the message belongs
+ * to the file private data.
+ *
+ * @cl: private data of the file object
+ * @rs: connect response bus message
+ *
+ */
+static bool is_treat_specially_client(struct mei_cl *cl,
+               struct hbm_client_connect_response *rs)
+{
+
+       if (cl->host_client_id == rs->host_addr &&
+           cl->me_client_id == rs->me_addr) {
+               if (!rs->status) {
+                       cl->state = MEI_FILE_CONNECTED;
+                       cl->status = 0;
+
+               } else {
+                       cl->state = MEI_FILE_DISCONNECTED;
+                       cl->status = -ENODEV;
+               }
+               cl->timer_count = 0;
+
+               return true;
+       }
+       return false;
+}
+
+/**
+ * mei_client_connect_response - connects to response irq routine
+ *
+ * @dev: the device structure
+ * @rs: connect response bus message
+ */
+static void mei_client_connect_response(struct mei_device *dev,
+               struct hbm_client_connect_response *rs)
+{
+
+       struct mei_cl *cl;
+       struct mei_cl_cb *cb_pos = NULL, *cb_next = NULL;
+
+       dev_dbg(&dev->pdev->dev,
+                       "connect_response:\n"
+                       "ME Client = %d\n"
+                       "Host Client = %d\n"
+                       "Status = %d\n",
+                       rs->me_addr,
+                       rs->host_addr,
+                       rs->status);
+
+       /* if WD or iamthif client treat specially */
+
+       if (is_treat_specially_client(&(dev->wd_cl), rs)) {
+               dev_dbg(&dev->pdev->dev, "dev->wd_timeout =%d.\n",
+                               dev->wd_timeout);
+
+               dev->wd_due_counter = (dev->wd_timeout) ? 1 : 0;
+
+               dev_dbg(&dev->pdev->dev, "successfully connected to WD client.\n");
+               host_init_iamthif(dev);
+               return;
+       }
+
+       if (is_treat_specially_client(&(dev->iamthif_cl), rs)) {
+               dev->iamthif_state = MEI_IAMTHIF_IDLE;
+               return;
+       }
+       if (!dev->ctrl_rd_list.status &&
+           !list_empty(&dev->ctrl_rd_list.mei_cb.cb_list)) {
+               list_for_each_entry_safe(cb_pos, cb_next,
+                       &dev->ctrl_rd_list.mei_cb.cb_list, cb_list) {
+                       cl = (struct mei_cl *)cb_pos->file_private;
+                       if (!cl) {
+                               list_del(&cb_pos->cb_list);
+                               return;
+                       }
+                       if (MEI_IOCTL == cb_pos->major_file_operations) {
+                               if (is_treat_specially_client(cl, rs)) {
+                                       list_del(&cb_pos->cb_list);
+                                       cl->status = 0;
+                                       cl->timer_count = 0;
+                                       break;
+                               }
+                       }
+               }
+       }
+}
+
+/**
+ * mei_client_disconnect_response - disconnects from response irq routine
+ *
+ * @dev: the device structure
+ * @rs: disconnect response bus message
+ */
+static void mei_client_disconnect_response(struct mei_device *dev,
+                                       struct hbm_client_connect_response *rs)
+{
+       struct mei_cl *cl;
+       struct mei_cl_cb *cb_pos = NULL, *cb_next = NULL;
+
+       dev_dbg(&dev->pdev->dev,
+                       "disconnect_response:\n"
+                       "ME Client = %d\n"
+                       "Host Client = %d\n"
+                       "Status = %d\n",
+                       rs->me_addr,
+                       rs->host_addr,
+                       rs->status);
+
+       if (!dev->ctrl_rd_list.status &&
+           !list_empty(&dev->ctrl_rd_list.mei_cb.cb_list)) {
+               list_for_each_entry_safe(cb_pos, cb_next,
+                               &dev->ctrl_rd_list.mei_cb.cb_list, cb_list) {
+                       cl = (struct mei_cl *)cb_pos->file_private;
+
+                       if (!cl) {
+                               list_del(&cb_pos->cb_list);
+                               return;
+                       }
+
+                       dev_dbg(&dev->pdev->dev, "list_for_each_entry_safe in ctrl_rd_list.\n");
+                       if (cl->host_client_id == rs->host_addr &&
+                           cl->me_client_id == rs->me_addr) {
+
+                               list_del(&cb_pos->cb_list);
+                               if (!rs->status)
+                                       cl->state = MEI_FILE_DISCONNECTED;
+
+                               cl->status = 0;
+                               cl->timer_count = 0;
+                               break;
+                       }
+               }
+       }
+}
+
+/**
+ * same_flow_addr - tells if they have the same address.
+ *
+ * @file: private data of the file object.
+ * @flow: flow control.
+ *
+ * returns  !=0, same; 0,not.
+ */
+static int same_flow_addr(struct mei_cl *cl, struct hbm_flow_control *flow)
+{
+       return (cl->host_client_id == flow->host_addr &&
+               cl->me_client_id == flow->me_addr);
+}
+
+/**
+ * add_single_flow_creds - adds single buffer credentials.
+ *
+ * @file: private data ot the file object.
+ * @flow: flow control.
+ */
+static void add_single_flow_creds(struct mei_device *dev,
+                                 struct hbm_flow_control *flow)
+{
+       struct mei_me_client *client;
+       int i;
+
+       for (i = 0; i < dev->num_mei_me_clients; i++) {
+               client = &dev->me_clients[i];
+               if (client && flow->me_addr == client->client_id) {
+                       if (client->props.single_recv_buf) {
+                               client->mei_flow_ctrl_creds++;
+                               dev_dbg(&dev->pdev->dev, "recv flow ctrl msg ME %d (single).\n",
+                                   flow->me_addr);
+                               dev_dbg(&dev->pdev->dev, "flow control credentials =%d.\n",
+                                   client->mei_flow_ctrl_creds);
+                       } else {
+                               BUG();  /* error in flow control */
+                       }
+               }
+       }
+}
+
+/**
+ * mei_client_flow_control_response - flow control response irq routine
+ *
+ * @dev: the device structure
+ * @flow_control: flow control response bus message
+ */
+static void mei_client_flow_control_response(struct mei_device *dev,
+               struct hbm_flow_control *flow_control)
+{
+       struct mei_cl *cl_pos = NULL;
+       struct mei_cl *cl_next = NULL;
+
+       if (!flow_control->host_addr) {
+               /* single receive buffer */
+               add_single_flow_creds(dev, flow_control);
+       } else {
+               /* normal connection */
+               list_for_each_entry_safe(cl_pos, cl_next,
+                               &dev->file_list, link) {
+                       dev_dbg(&dev->pdev->dev, "list_for_each_entry_safe in file_list\n");
+
+                       dev_dbg(&dev->pdev->dev, "cl of host client %d ME client %d.\n",
+                           cl_pos->host_client_id,
+                           cl_pos->me_client_id);
+                       dev_dbg(&dev->pdev->dev, "flow ctrl msg for host %d ME %d.\n",
+                           flow_control->host_addr,
+                           flow_control->me_addr);
+                       if (same_flow_addr(cl_pos, flow_control)) {
+                               dev_dbg(&dev->pdev->dev, "recv ctrl msg for host  %d ME %d.\n",
+                                   flow_control->host_addr,
+                                   flow_control->me_addr);
+                               cl_pos->mei_flow_ctrl_creds++;
+                               dev_dbg(&dev->pdev->dev, "flow control credentials = %d.\n",
+                                   cl_pos->mei_flow_ctrl_creds);
+                               break;
+                       }
+               }
+       }
+}
+
+/**
+ * same_disconn_addr - tells if they have the same address
+ *
+ * @file: private data of the file object.
+ * @disconn: disconnection request.
+ *
+ * returns !=0, same; 0,not.
+ */
+static int same_disconn_addr(struct mei_cl *cl,
+                            struct hbm_client_disconnect_request *disconn)
+{
+       return (cl->host_client_id == disconn->host_addr &&
+               cl->me_client_id == disconn->me_addr);
+}
+
+/**
+ * mei_client_disconnect_request - disconnects from request irq routine
+ *
+ * @dev: the device structure.
+ * @disconnect_req: disconnect request bus message.
+ */
+static void mei_client_disconnect_request(struct mei_device *dev,
+               struct hbm_client_disconnect_request *disconnect_req)
+{
+       struct mei_msg_hdr *mei_hdr;
+       struct hbm_client_connect_response *disconnect_res;
+       struct mei_cl *cl_pos = NULL;
+       struct mei_cl *cl_next = NULL;
+
+       list_for_each_entry_safe(cl_pos, cl_next, &dev->file_list, link) {
+               if (same_disconn_addr(cl_pos, disconnect_req)) {
+                       dev_dbg(&dev->pdev->dev, "disconnect request host client %d ME client %d.\n",
+                                       disconnect_req->host_addr,
+                                       disconnect_req->me_addr);
+                       cl_pos->state = MEI_FILE_DISCONNECTED;
+                       cl_pos->timer_count = 0;
+                       if (cl_pos == &dev->wd_cl) {
+                               dev->wd_due_counter = 0;
+                               dev->wd_pending = 0;
+                       } else if (cl_pos == &dev->iamthif_cl)
+                               dev->iamthif_timer = 0;
+
+                       /* prepare disconnect response */
+                       mei_hdr =
+                               (struct mei_msg_hdr *) &dev->ext_msg_buf[0];
+                       mei_hdr->host_addr = 0;
+                       mei_hdr->me_addr = 0;
+                       mei_hdr->length =
+                               sizeof(struct hbm_client_connect_response);
+                       mei_hdr->msg_complete = 1;
+                       mei_hdr->reserved = 0;
+
+                       disconnect_res =
+                               (struct hbm_client_connect_response *)
+                               &dev->ext_msg_buf[1];
+                       disconnect_res->host_addr = cl_pos->host_client_id;
+                       disconnect_res->me_addr = cl_pos->me_client_id;
+                       *(u8 *) (&disconnect_res->cmd) =
+                               CLIENT_DISCONNECT_RES_CMD;
+                       disconnect_res->status = 0;
+                       dev->extra_write_index = 2;
+                       break;
+               }
+       }
+}
+
+
+/**
+ * mei_irq_thread_read_bus_message - bottom half read routine after ISR to
+ * handle the read bus message cmd processing.
+ *
+ * @dev: the device structure
+ * @mei_hdr: header of bus message
+ */
+static void mei_irq_thread_read_bus_message(struct mei_device *dev,
+               struct mei_msg_hdr *mei_hdr)
+{
+       struct mei_bus_message *mei_msg;
+       struct hbm_host_version_response *version_res;
+       struct hbm_client_connect_response *connect_res;
+       struct hbm_client_connect_response *disconnect_res;
+       struct hbm_flow_control *flow_control;
+       struct hbm_props_response *props_res;
+       struct hbm_host_enum_response *enum_res;
+       struct hbm_client_disconnect_request *disconnect_req;
+       struct hbm_host_stop_request *host_stop_req;
+
+       unsigned char *buffer;
+
+       /* read the message to our buffer */
+       buffer = (unsigned char *) dev->rd_msg_buf;
+       BUG_ON(mei_hdr->length >= sizeof(dev->rd_msg_buf));
+       mei_read_slots(dev, buffer, mei_hdr->length);
+       mei_msg = (struct mei_bus_message *) buffer;
+
+       switch (*(u8 *) mei_msg) {
+       case HOST_START_RES_CMD:
+               version_res = (struct hbm_host_version_response *) mei_msg;
+               if (version_res->host_version_supported) {
+                       dev->version.major_version = HBM_MAJOR_VERSION;
+                       dev->version.minor_version = HBM_MINOR_VERSION;
+                       if (dev->mei_state == MEI_INIT_CLIENTS &&
+                           dev->init_clients_state == MEI_START_MESSAGE) {
+                               dev->init_clients_timer = 0;
+                               host_enum_clients_message(dev);
+                       } else {
+                               dev->recvd_msg = 0;
+                               dev_dbg(&dev->pdev->dev, "IMEI reset due to received host start response bus message.\n");
+                               mei_reset(dev, 1);
+                               return;
+                       }
+               } else {
+                       dev->version = version_res->me_max_version;
+                       /* send stop message */
+                       mei_hdr->host_addr = 0;
+                       mei_hdr->me_addr = 0;
+                       mei_hdr->length = sizeof(struct hbm_host_stop_request);
+                       mei_hdr->msg_complete = 1;
+                       mei_hdr->reserved = 0;
+
+                       host_stop_req = (struct hbm_host_stop_request *)
+                                                       &dev->wr_msg_buf[1];
+
+                       memset(host_stop_req,
+                                       0,
+                                       sizeof(struct hbm_host_stop_request));
+                       host_stop_req->cmd.cmd = HOST_STOP_REQ_CMD;
+                       host_stop_req->reason = DRIVER_STOP_REQUEST;
+                       mei_write_message(dev, mei_hdr,
+                                          (unsigned char *) (host_stop_req),
+                                          mei_hdr->length);
+                       dev_dbg(&dev->pdev->dev, "version mismatch.\n");
+                       return;
+               }
+
+               dev->recvd_msg = 1;
+               dev_dbg(&dev->pdev->dev, "host start response message received.\n");
+               break;
+
+       case CLIENT_CONNECT_RES_CMD:
+               connect_res =
+                       (struct hbm_client_connect_response *) mei_msg;
+               mei_client_connect_response(dev, connect_res);
+               dev_dbg(&dev->pdev->dev, "client connect response message received.\n");
+               wake_up(&dev->wait_recvd_msg);
+               break;
+
+       case CLIENT_DISCONNECT_RES_CMD:
+               disconnect_res =
+                       (struct hbm_client_connect_response *) mei_msg;
+               mei_client_disconnect_response(dev,      disconnect_res);
+               dev_dbg(&dev->pdev->dev, "client disconnect response message received.\n");
+               wake_up(&dev->wait_recvd_msg);
+               break;
+
+       case MEI_FLOW_CONTROL_CMD:
+               flow_control = (struct hbm_flow_control *) mei_msg;
+               mei_client_flow_control_response(dev, flow_control);
+               dev_dbg(&dev->pdev->dev, "client flow control response message received.\n");
+               break;
+
+       case HOST_CLIENT_PROPERTIES_RES_CMD:
+               props_res = (struct hbm_props_response *)mei_msg;
+               if (props_res->status || !dev->me_clients) {
+                       dev_dbg(&dev->pdev->dev, "reset due to received host client properties response bus message wrong status.\n");
+                       mei_reset(dev, 1);
+                       return;
+               }
+              if (dev->me_clients[dev->me_client_presentation_num]
+                                       .client_id == props_res->address) {
+
+                       dev->me_clients[dev->me_client_presentation_num].props
+                                               = props_res->client_properties;
+
+                       if (dev->mei_state == MEI_INIT_CLIENTS &&
+                           dev->init_clients_state ==
+                                       MEI_CLIENT_PROPERTIES_MESSAGE) {
+                               dev->me_client_index++;
+                               dev->me_client_presentation_num++;
+                               host_client_properties(dev);
+                       } else {
+                               dev_dbg(&dev->pdev->dev, "reset due to received host client properties response bus message");
+                               mei_reset(dev, 1);
+                               return;
+                       }
+               } else {
+                       dev_dbg(&dev->pdev->dev, "reset due to received host client properties response bus message for wrong client ID\n");
+                       mei_reset(dev, 1);
+                       return;
+               }
+               break;
+
+       case HOST_ENUM_RES_CMD:
+               enum_res = (struct hbm_host_enum_response *) mei_msg;
+               memcpy(dev->me_clients_map, enum_res->valid_addresses, 32);
+               if (dev->mei_state == MEI_INIT_CLIENTS &&
+                   dev->init_clients_state == MEI_ENUM_CLIENTS_MESSAGE) {
+                               dev->init_clients_timer = 0;
+                               dev->me_client_presentation_num = 0;
+                               dev->me_client_index = 0;
+                               allocate_me_clients_storage(dev);
+                               dev->init_clients_state =
+                                       MEI_CLIENT_PROPERTIES_MESSAGE;
+                               host_client_properties(dev);
+               } else {
+                       dev_dbg(&dev->pdev->dev, "reset due to received host enumeration clients response bus message.\n");
+                       mei_reset(dev, 1);
+                       return;
+               }
+               break;
+
+       case HOST_STOP_RES_CMD:
+               dev->mei_state = MEI_DISABLED;
+               dev_dbg(&dev->pdev->dev, "resetting because of FW stop response.\n");
+               mei_reset(dev, 1);
+               break;
+
+       case CLIENT_DISCONNECT_REQ_CMD:
+               /* search for client */
+               disconnect_req =
+                       (struct hbm_client_disconnect_request *) mei_msg;
+               mei_client_disconnect_request(dev, disconnect_req);
+               break;
+
+       case ME_STOP_REQ_CMD:
+               /* prepare stop request */
+               mei_hdr = (struct mei_msg_hdr *) &dev->ext_msg_buf[0];
+               mei_hdr->host_addr = 0;
+               mei_hdr->me_addr = 0;
+               mei_hdr->length = sizeof(struct hbm_host_stop_request);
+               mei_hdr->msg_complete = 1;
+               mei_hdr->reserved = 0;
+               host_stop_req =
+                       (struct hbm_host_stop_request *) &dev->ext_msg_buf[1];
+               memset(host_stop_req, 0, sizeof(struct hbm_host_stop_request));
+               host_stop_req->cmd.cmd = HOST_STOP_REQ_CMD;
+               host_stop_req->reason = DRIVER_STOP_REQUEST;
+               host_stop_req->reserved[0] = 0;
+               host_stop_req->reserved[1] = 0;
+               dev->extra_write_index = 2;
+               break;
+
+       default:
+               BUG();
+               break;
+
+       }
+}
+
+
+/**
+ * _mei_hb_read - processes read related operation.
+ *
+ * @dev: the device structure.
+ * @slots: free slots.
+ * @cb_pos: callback block.
+ * @cl: private data of the file object.
+ * @cmpl_list: complete list.
+ *
+ * returns 0, OK; otherwise, error.
+ */
+static int _mei_irq_thread_read(struct mei_device *dev,        s32 *slots,
+                       struct mei_cl_cb *cb_pos,
+                       struct mei_cl *cl,
+                       struct mei_io_list *cmpl_list)
+{
+       if ((*slots * sizeof(u32)) >= (sizeof(struct mei_msg_hdr) +
+                       sizeof(struct hbm_flow_control))) {
+               *slots -= (sizeof(struct mei_msg_hdr) +
+                       sizeof(struct hbm_flow_control) + 3) / 4;
+               if (!mei_send_flow_control(dev, cl)) {
+                       cl->status = -ENODEV;
+                       cb_pos->information = 0;
+                       list_move_tail(&cb_pos->cb_list,
+                                       &cmpl_list->mei_cb.cb_list);
+                       return -ENODEV;
+               } else {
+                       list_move_tail(&cb_pos->cb_list,
+                                       &dev->read_list.mei_cb.cb_list);
+               }
+       } else {
+               /* return the cancel routine */
+               list_del(&cb_pos->cb_list);
+               return -EBADMSG;
+       }
+
+       return 0;
+}
+
+
+/**
+ * _mei_irq_thread_ioctl - processes ioctl related operation.
+ *
+ * @dev: the device structure.
+ * @slots: free slots.
+ * @cb_pos: callback block.
+ * @cl: private data of the file object.
+ * @cmpl_list: complete list.
+ *
+ * returns 0, OK; otherwise, error.
+ */
+static int _mei_irq_thread_ioctl(struct mei_device *dev, s32 *slots,
+                       struct mei_cl_cb *cb_pos,
+                       struct mei_cl *cl,
+                       struct mei_io_list *cmpl_list)
+{
+       if ((*slots * sizeof(u32)) >= (sizeof(struct mei_msg_hdr) +
+                       sizeof(struct hbm_client_connect_request))) {
+               cl->state = MEI_FILE_CONNECTING;
+               *slots -= (sizeof(struct mei_msg_hdr) +
+                       sizeof(struct hbm_client_connect_request) + 3) / 4;
+               if (!mei_connect(dev, cl)) {
+                       cl->status = -ENODEV;
+                       cb_pos->information = 0;
+                       list_del(&cb_pos->cb_list);
+                       return -ENODEV;
+               } else {
+                       list_move_tail(&cb_pos->cb_list,
+                               &dev->ctrl_rd_list.mei_cb.cb_list);
+                       cl->timer_count = MEI_CONNECT_TIMEOUT;
+               }
+       } else {
+               /* return the cancel routine */
+               list_del(&cb_pos->cb_list);
+               return -EBADMSG;
+       }
+
+       return 0;
+}
+
+/**
+ * _mei_irq_thread_cmpl - processes completed and no-iamthif operation.
+ *
+ * @dev: the device structure.
+ * @slots: free slots.
+ * @cb_pos: callback block.
+ * @cl: private data of the file object.
+ * @cmpl_list: complete list.
+ *
+ * returns 0, OK; otherwise, error.
+ */
+static int _mei_irq_thread_cmpl(struct mei_device *dev,        s32 *slots,
+                       struct mei_cl_cb *cb_pos,
+                       struct mei_cl *cl,
+                       struct mei_io_list *cmpl_list)
+{
+       struct mei_msg_hdr *mei_hdr;
+
+       if ((*slots * sizeof(u32)) >= (sizeof(struct mei_msg_hdr) +
+                       (cb_pos->request_buffer.size -
+                       cb_pos->information))) {
+               mei_hdr = (struct mei_msg_hdr *) &dev->wr_msg_buf[0];
+               mei_hdr->host_addr = cl->host_client_id;
+               mei_hdr->me_addr = cl->me_client_id;
+               mei_hdr->length = cb_pos->request_buffer.size -
+                                       cb_pos->information;
+               mei_hdr->msg_complete = 1;
+               mei_hdr->reserved = 0;
+               dev_dbg(&dev->pdev->dev, "cb_pos->request_buffer.size =%d"
+                       "mei_hdr->msg_complete = %d\n",
+                               cb_pos->request_buffer.size,
+                               mei_hdr->msg_complete);
+               dev_dbg(&dev->pdev->dev, "cb_pos->information  =%lu\n",
+                               cb_pos->information);
+               dev_dbg(&dev->pdev->dev, "mei_hdr->length  =%d\n",
+                               mei_hdr->length);
+               *slots -= (sizeof(struct mei_msg_hdr) +
+                               mei_hdr->length + 3) / 4;
+               if (!mei_write_message(dev, mei_hdr,
+                               (unsigned char *)
+                               (cb_pos->request_buffer.data +
+                               cb_pos->information),
+                               mei_hdr->length)) {
+                       cl->status = -ENODEV;
+                       list_move_tail(&cb_pos->cb_list,
+                               &cmpl_list->mei_cb.cb_list);
+                       return -ENODEV;
+               } else {
+                       if (mei_flow_ctrl_reduce(dev, cl))
+                               return -ENODEV;
+                       cl->status = 0;
+                       cb_pos->information += mei_hdr->length;
+                       list_move_tail(&cb_pos->cb_list,
+                               &dev->write_waiting_list.mei_cb.cb_list);
+               }
+       } else if (*slots == ((dev->host_hw_state & H_CBD) >> 24)) {
+               /* buffer is still empty */
+               mei_hdr = (struct mei_msg_hdr *) &dev->wr_msg_buf[0];
+               mei_hdr->host_addr = cl->host_client_id;
+               mei_hdr->me_addr = cl->me_client_id;
+               mei_hdr->length =
+                       (*slots * sizeof(u32)) - sizeof(struct mei_msg_hdr);
+               mei_hdr->msg_complete = 0;
+               mei_hdr->reserved = 0;
+
+               (*slots) -= (sizeof(struct mei_msg_hdr) +
+                               mei_hdr->length + 3) / 4;
+               if (!mei_write_message(dev, mei_hdr,
+                                       (unsigned char *)
+                                       (cb_pos->request_buffer.data +
+                                       cb_pos->information),
+                                       mei_hdr->length)) {
+                       cl->status = -ENODEV;
+                       list_move_tail(&cb_pos->cb_list,
+                               &cmpl_list->mei_cb.cb_list);
+                       return -ENODEV;
+               } else {
+                       cb_pos->information += mei_hdr->length;
+                       dev_dbg(&dev->pdev->dev,
+                                       "cb_pos->request_buffer.size =%d"
+                                       " mei_hdr->msg_complete = %d\n",
+                                       cb_pos->request_buffer.size,
+                                       mei_hdr->msg_complete);
+                       dev_dbg(&dev->pdev->dev, "cb_pos->information  =%lu\n",
+                                       cb_pos->information);
+                       dev_dbg(&dev->pdev->dev, "mei_hdr->length  =%d\n",
+                                       mei_hdr->length);
+               }
+               return -EMSGSIZE;
+       } else {
+               return -EBADMSG;
+       }
+
+       return 0;
+}
+
+/**
+ * _mei_irq_thread_cmpl_iamthif - processes completed iamthif operation.
+ *
+ * @dev: the device structure.
+ * @slots: free slots.
+ * @cb_pos: callback block.
+ * @cl: private data of the file object.
+ * @cmpl_list: complete list.
+ *
+ * returns 0, OK; otherwise, error.
+ */
+static int _mei_irq_thread_cmpl_iamthif(struct mei_device *dev, s32 *slots,
+                       struct mei_cl_cb *cb_pos,
+                       struct mei_cl *cl,
+                       struct mei_io_list *cmpl_list)
+{
+       struct mei_msg_hdr *mei_hdr;
+
+       if ((*slots * sizeof(u32)) >= (sizeof(struct mei_msg_hdr) +
+                       dev->iamthif_msg_buf_size -
+                       dev->iamthif_msg_buf_index)) {
+               mei_hdr = (struct mei_msg_hdr *) &dev->wr_msg_buf[0];
+               mei_hdr->host_addr = cl->host_client_id;
+               mei_hdr->me_addr = cl->me_client_id;
+               mei_hdr->length = dev->iamthif_msg_buf_size -
+                       dev->iamthif_msg_buf_index;
+               mei_hdr->msg_complete = 1;
+               mei_hdr->reserved = 0;
+
+               *slots -= (sizeof(struct mei_msg_hdr) +
+                               mei_hdr->length + 3) / 4;
+
+               if (!mei_write_message(dev, mei_hdr,
+                                       (dev->iamthif_msg_buf +
+                                       dev->iamthif_msg_buf_index),
+                                       mei_hdr->length)) {
+                       dev->iamthif_state = MEI_IAMTHIF_IDLE;
+                       cl->status = -ENODEV;
+                       list_del(&cb_pos->cb_list);
+                       return -ENODEV;
+               } else {
+                       if (mei_flow_ctrl_reduce(dev, cl))
+                               return -ENODEV;
+                       dev->iamthif_msg_buf_index += mei_hdr->length;
+                       cb_pos->information = dev->iamthif_msg_buf_index;
+                       cl->status = 0;
+                       dev->iamthif_state = MEI_IAMTHIF_FLOW_CONTROL;
+                       dev->iamthif_flow_control_pending = 1;
+                       /* save iamthif cb sent to amthi client */
+                       dev->iamthif_current_cb = cb_pos;
+                       list_move_tail(&cb_pos->cb_list,
+                               &dev->write_waiting_list.mei_cb.cb_list);
+
+               }
+       } else if (*slots == ((dev->host_hw_state & H_CBD) >> 24)) {
+                       /* buffer is still empty */
+               mei_hdr = (struct mei_msg_hdr *) &dev->wr_msg_buf[0];
+               mei_hdr->host_addr = cl->host_client_id;
+               mei_hdr->me_addr = cl->me_client_id;
+               mei_hdr->length =
+                       (*slots * sizeof(u32)) - sizeof(struct mei_msg_hdr);
+               mei_hdr->msg_complete = 0;
+               mei_hdr->reserved = 0;
+
+               *slots -= (sizeof(struct mei_msg_hdr) +
+                               mei_hdr->length + 3) / 4;
+
+               if (!mei_write_message(dev, mei_hdr,
+                                       (dev->iamthif_msg_buf +
+                                       dev->iamthif_msg_buf_index),
+                                       mei_hdr->length)) {
+                       cl->status = -ENODEV;
+                       list_del(&cb_pos->cb_list);
+               } else {
+                       dev->iamthif_msg_buf_index += mei_hdr->length;
+               }
+               return -EMSGSIZE;
+       } else {
+               return -EBADMSG;
+       }
+
+       return 0;
+}
+
+/**
+ * mei_irq_thread_read_handler - bottom half read routine after ISR to
+ * handle the read processing.
+ *
+ * @cmpl_list: An instance of our list structure
+ * @dev: the device structure
+ * @slots: slots to read.
+ *
+ * returns 0 on success, <0 on failure.
+ */
+static int mei_irq_thread_read_handler(struct mei_io_list *cmpl_list,
+               struct mei_device *dev,
+               s32 *slots)
+{
+       struct mei_msg_hdr *mei_hdr;
+       struct mei_cl *cl_pos = NULL;
+       struct mei_cl *cl_next = NULL;
+       int ret = 0;
+
+       if (!dev->rd_msg_hdr) {
+               dev->rd_msg_hdr = mei_mecbrw_read(dev);
+               dev_dbg(&dev->pdev->dev, "slots =%08x.\n", *slots);
+               (*slots)--;
+               dev_dbg(&dev->pdev->dev, "slots =%08x.\n", *slots);
+       }
+       mei_hdr = (struct mei_msg_hdr *) &dev->rd_msg_hdr;
+       dev_dbg(&dev->pdev->dev, "mei_hdr->length =%d\n", mei_hdr->length);
+
+       if (mei_hdr->reserved || !dev->rd_msg_hdr) {
+               dev_dbg(&dev->pdev->dev, "corrupted message header.\n");
+               ret = -EBADMSG;
+               goto end;
+       }
+
+       if (mei_hdr->host_addr || mei_hdr->me_addr) {
+               list_for_each_entry_safe(cl_pos, cl_next,
+                                       &dev->file_list, link) {
+                       dev_dbg(&dev->pdev->dev,
+                                       "list_for_each_entry_safe read host"
+                                       " client = %d, ME client = %d\n",
+                                       cl_pos->host_client_id,
+                                       cl_pos->me_client_id);
+                       if (cl_pos->host_client_id == mei_hdr->host_addr &&
+                           cl_pos->me_client_id == mei_hdr->me_addr)
+                               break;
+               }
+
+               if (&cl_pos->link == &dev->file_list) {
+                       dev_dbg(&dev->pdev->dev, "corrupted message header\n");
+                       ret = -EBADMSG;
+                       goto end;
+               }
+       }
+       if (((*slots) * sizeof(u32)) < mei_hdr->length) {
+               dev_dbg(&dev->pdev->dev,
+                               "we can't read the message slots =%08x.\n",
+                               *slots);
+               /* we can't read the message */
+               ret = -ERANGE;
+               goto end;
+       }
+
+       /* decide where to read the message too */
+       if (!mei_hdr->host_addr) {
+               dev_dbg(&dev->pdev->dev, "call mei_irq_thread_read_bus_message.\n");
+               mei_irq_thread_read_bus_message(dev, mei_hdr);
+               dev_dbg(&dev->pdev->dev, "end mei_irq_thread_read_bus_message.\n");
+       } else if (mei_hdr->host_addr == dev->iamthif_cl.host_client_id &&
+                  (MEI_FILE_CONNECTED == dev->iamthif_cl.state) &&
+                  (dev->iamthif_state == MEI_IAMTHIF_READING)) {
+               dev_dbg(&dev->pdev->dev, "call mei_irq_thread_read_iamthif_message.\n");
+               dev_dbg(&dev->pdev->dev, "mei_hdr->length =%d\n",
+                               mei_hdr->length);
+               ret = mei_irq_thread_read_amthi_message(cmpl_list,
+                                                       dev, mei_hdr);
+               if (ret)
+                       goto end;
+
+       } else {
+               dev_dbg(&dev->pdev->dev, "call mei_irq_thread_read_client_message.\n");
+               ret = mei_irq_thread_read_client_message(cmpl_list,
+                                                        dev, mei_hdr);
+               if (ret)
+                       goto end;
+
+       }
+
+       /* reset the number of slots and header */
+       *slots = mei_count_full_read_slots(dev);
+       dev->rd_msg_hdr = 0;
+
+       if (*slots == -EOVERFLOW) {
+               /* overflow - reset */
+               dev_dbg(&dev->pdev->dev, "resetting due to slots overflow.\n");
+               /* set the event since message has been read */
+               ret = -ERANGE;
+               goto end;
+       }
+end:
+       return ret;
+}
+
+
+/**
+ * mei_irq_thread_write_handler - bottom half write routine after
+ * ISR to handle the write processing.
+ *
+ * @cmpl_list: An instance of our list structure
+ * @dev: the device structure
+ * @slots: slots to write.
+ *
+ * returns 0 on success, <0 on failure.
+ */
+static int mei_irq_thread_write_handler(struct mei_io_list *cmpl_list,
+               struct mei_device *dev,
+               s32 *slots)
+{
+
+       struct mei_cl *cl;
+       struct mei_cl_cb *cb_pos = NULL, *cb_next = NULL;
+       struct mei_io_list *list;
+       int ret;
+
+       if (!mei_host_buffer_is_empty(dev)) {
+               dev_dbg(&dev->pdev->dev, "host buffer is not empty.\n");
+               return 0;
+       }
+       dev->write_hang = -1;
+       *slots = mei_count_empty_write_slots(dev);
+       /* complete all waiting for write CB */
+       dev_dbg(&dev->pdev->dev, "complete all waiting for write cb.\n");
+
+       list = &dev->write_waiting_list;
+       if (!list->status && !list_empty(&list->mei_cb.cb_list)) {
+               list_for_each_entry_safe(cb_pos, cb_next,
+                               &list->mei_cb.cb_list, cb_list) {
+                       cl = (struct mei_cl *)cb_pos->file_private;
+                       if (cl) {
+                               cl->status = 0;
+                               list_del(&cb_pos->cb_list);
+                               if (MEI_WRITING == cl->writing_state &&
+                                  (cb_pos->major_file_operations ==
+                                               MEI_WRITE) &&
+                                  (cl != &dev->iamthif_cl)) {
+                                       dev_dbg(&dev->pdev->dev,
+                                               "MEI WRITE COMPLETE\n");
+                                       cl->writing_state =
+                                                       MEI_WRITE_COMPLETE;
+                                       list_add_tail(&cb_pos->cb_list,
+                                               &cmpl_list->mei_cb.cb_list);
+                               }
+                               if (cl == &dev->iamthif_cl) {
+                                       dev_dbg(&dev->pdev->dev, "check iamthif flow control.\n");
+                                       if (dev->iamthif_flow_control_pending) {
+                                               ret =
+                                               _mei_irq_thread_iamthif_read(
+                                                               dev, slots);
+                                               if (ret)
+                                                       return ret;
+                                       }
+                               }
+                       }
+
+               }
+       }
+
+       if (dev->stop && !dev->wd_pending) {
+               dev->wd_stopped = 1;
+               wake_up_interruptible(&dev->wait_stop_wd);
+               return 0;
+       }
+
+       if (dev->extra_write_index) {
+               dev_dbg(&dev->pdev->dev, "extra_write_index =%d.\n",
+                               dev->extra_write_index);
+               mei_write_message(dev,
+                               (struct mei_msg_hdr *) &dev->ext_msg_buf[0],
+                               (unsigned char *) &dev->ext_msg_buf[1],
+                               (dev->extra_write_index - 1) * sizeof(u32));
+               *slots -= dev->extra_write_index;
+               dev->extra_write_index = 0;
+       }
+       if (dev->mei_state == MEI_ENABLED) {
+               if (dev->wd_pending &&
+                       mei_flow_ctrl_creds(dev, &dev->wd_cl) > 0) {
+                       if (mei_wd_send(dev))
+                               dev_dbg(&dev->pdev->dev, "wd send failed.\n");
+                       else
+                               if (mei_flow_ctrl_reduce(dev, &dev->wd_cl))
+                                       return -ENODEV;
+
+                       dev->wd_pending = 0;
+
+                       if (dev->wd_timeout) {
+                               *slots -= (sizeof(struct mei_msg_hdr) +
+                                        MEI_START_WD_DATA_SIZE + 3) / 4;
+                               dev->wd_due_counter = 2;
+                       } else {
+                               *slots -= (sizeof(struct mei_msg_hdr) +
+                                        MEI_WD_PARAMS_SIZE + 3) / 4;
+                               dev->wd_due_counter = 0;
+                       }
+
+               }
+       }
+       if (dev->stop)
+               return ~ENODEV;
+
+       /* complete control write list CB */
+       if (!dev->ctrl_wr_list.status) {
+               /* complete control write list CB */
+               dev_dbg(&dev->pdev->dev, "complete control write list cb.\n");
+               list_for_each_entry_safe(cb_pos, cb_next,
+                               &dev->ctrl_wr_list.mei_cb.cb_list, cb_list) {
+                       cl = (struct mei_cl *)
+                               cb_pos->file_private;
+                       if (!cl) {
+                               list_del(&cb_pos->cb_list);
+                               return -ENODEV;
+                       }
+                       switch (cb_pos->major_file_operations) {
+                       case MEI_CLOSE:
+                               /* send disconnect message */
+                               ret = _mei_irq_thread_close(dev, slots,
+                                                    cb_pos, cl, cmpl_list);
+                               if (ret)
+                                       return ret;
+
+                               break;
+                       case MEI_READ:
+                               /* send flow control message */
+                               ret = _mei_irq_thread_read(dev, slots,
+                                                   cb_pos, cl, cmpl_list);
+                               if (ret)
+                                       return ret;
+
+                               break;
+                       case MEI_IOCTL:
+                               /* connect message */
+                               if (!mei_other_client_is_connecting(dev,
+                                               cl))
+                                       continue;
+                               ret = _mei_irq_thread_ioctl(dev, slots,
+                                                    cb_pos, cl, cmpl_list);
+                               if (ret)
+                                       return ret;
+
+                               break;
+
+                       default:
+                               BUG();
+                       }
+
+               }
+       }
+       /* complete  write list CB */
+       if (!dev->write_list.status &&
+           !list_empty(&dev->write_list.mei_cb.cb_list)) {
+               dev_dbg(&dev->pdev->dev, "complete write list cb.\n");
+               list_for_each_entry_safe(cb_pos, cb_next,
+                               &dev->write_list.mei_cb.cb_list, cb_list) {
+                       cl = (struct mei_cl *)cb_pos->file_private;
+
+                       if (cl) {
+                               if (cl != &dev->iamthif_cl) {
+                                       if (!mei_flow_ctrl_creds(dev,
+                                               cl)) {
+                                               dev_dbg(&dev->pdev->dev,
+                                                       "No flow control"
+                                                   " credentials for client"
+                                                   " %d, not sending.\n",
+                                                   cl->host_client_id);
+                                               continue;
+                                       }
+                                       ret = _mei_irq_thread_cmpl(dev, slots,
+                                                           cb_pos,
+                                                           cl, cmpl_list);
+                                       if (ret)
+                                               return ret;
+
+                               } else if (cl == &dev->iamthif_cl) {
+                                       /* IAMTHIF IOCTL */
+                                       dev_dbg(&dev->pdev->dev, "complete amthi write cb.\n");
+                                       if (!mei_flow_ctrl_creds(dev,
+                                                       cl)) {
+                                               dev_dbg(&dev->pdev->dev,
+                                                       "No flow control"
+                                                   " credentials for amthi"
+                                                   " client %d.\n",
+                                                   cl->host_client_id);
+                                               continue;
+                                       }
+                                       ret = _mei_irq_thread_cmpl_iamthif(dev,
+                                                               slots,
+                                                               cb_pos,
+                                                               cl,
+                                                               cmpl_list);
+                                       if (ret)
+                                               return ret;
+
+                               }
+                       }
+
+               }
+       }
+       return 0;
+}
+
+
+
+/**
+ * mei_timer - timer function.
+ *
+ * @work: pointer to the work_struct structure
+ *
+ * NOTE: This function is called by timer interrupt work
+ */
+void mei_wd_timer(struct work_struct *work)
+{
+       unsigned long timeout;
+       struct mei_cl *cl_pos = NULL;
+       struct mei_cl *cl_next = NULL;
+       struct list_head *amthi_complete_list = NULL;
+       struct mei_cl_cb  *cb_pos = NULL;
+       struct mei_cl_cb  *cb_next = NULL;
+
+       struct mei_device *dev = container_of(work,
+                                       struct mei_device, wd_work.work);
+
+
+       mutex_lock(&dev->device_lock);
+       if (dev->mei_state != MEI_ENABLED) {
+               if (dev->mei_state == MEI_INIT_CLIENTS) {
+                       if (dev->init_clients_timer) {
+                               if (--dev->init_clients_timer == 0) {
+                                       dev_dbg(&dev->pdev->dev, "IMEI reset due to init clients timeout ,init clients state = %d.\n",
+                                               dev->init_clients_state);
+                                       mei_reset(dev, 1);
+                               }
+                       }
+               }
+               goto out;
+       }
+       /*** connect/disconnect timeouts ***/
+       list_for_each_entry_safe(cl_pos, cl_next, &dev->file_list, link) {
+               if (cl_pos->timer_count) {
+                       if (--cl_pos->timer_count == 0) {
+                               dev_dbg(&dev->pdev->dev, "HECI reset due to connect/disconnect timeout.\n");
+                               mei_reset(dev, 1);
+                               goto out;
+                       }
+               }
+       }
+
+       if (dev->wd_cl.state != MEI_FILE_CONNECTED)
+               goto out;
+
+       /* Watchdog */
+       if (dev->wd_due_counter && !dev->wd_bypass) {
+               if (--dev->wd_due_counter == 0) {
+                       if (dev->mei_host_buffer_is_empty &&
+                           mei_flow_ctrl_creds(dev, &dev->wd_cl) > 0) {
+                               dev->mei_host_buffer_is_empty = 0;
+                               dev_dbg(&dev->pdev->dev, "send watchdog.\n");
+
+                               if (mei_wd_send(dev))
+                                       dev_dbg(&dev->pdev->dev, "wd send failed.\n");
+                               else
+                                       if (mei_flow_ctrl_reduce(dev, &dev->wd_cl))
+                                               goto out;
+
+                               if (dev->wd_timeout)
+                                       dev->wd_due_counter = 2;
+                               else
+                                       dev->wd_due_counter = 0;
+
+                       } else
+                               dev->wd_pending = 1;
+
+               }
+       }
+       if (dev->iamthif_stall_timer) {
+               if (--dev->iamthif_stall_timer == 0) {
+                       dev_dbg(&dev->pdev->dev, "reseting because of hang to amthi.\n");
+                       mei_reset(dev, 1);
+                       dev->iamthif_msg_buf_size = 0;
+                       dev->iamthif_msg_buf_index = 0;
+                       dev->iamthif_canceled = 0;
+                       dev->iamthif_ioctl = 1;
+                       dev->iamthif_state = MEI_IAMTHIF_IDLE;
+                       dev->iamthif_timer = 0;
+
+                       if (dev->iamthif_current_cb)
+                               mei_free_cb_private(dev->iamthif_current_cb);
+
+                       dev->iamthif_file_object = NULL;
+                       dev->iamthif_current_cb = NULL;
+                       run_next_iamthif_cmd(dev);
+               }
+       }
+
+       if (dev->iamthif_timer) {
+
+               timeout = dev->iamthif_timer +
+                               msecs_to_jiffies(IAMTHIF_READ_TIMER);
+
+               dev_dbg(&dev->pdev->dev, "dev->iamthif_timer = %ld\n",
+                               dev->iamthif_timer);
+               dev_dbg(&dev->pdev->dev, "timeout = %ld\n", timeout);
+               dev_dbg(&dev->pdev->dev, "jiffies = %ld\n", jiffies);
+               if (time_after(jiffies, timeout)) {
+                       /*
+                        * User didn't read the AMTHI data on time (15sec)
+                        * freeing AMTHI for other requests
+                        */
+
+                       dev_dbg(&dev->pdev->dev, "freeing AMTHI for other requests\n");
+
+                       amthi_complete_list = &dev->amthi_read_complete_list.
+                                       mei_cb.cb_list;
+
+                       if (!list_empty(amthi_complete_list)) {
+
+                               list_for_each_entry_safe(cb_pos, cb_next,
+                                                       amthi_complete_list,
+                                                       cb_list) {
+
+                                       cl_pos = cb_pos->file_object->private_data;
+
+                                       /* Finding the AMTHI entry. */
+                                       if (cl_pos ==   &dev->iamthif_cl)
+                                               list_del(&cb_pos->cb_list);
+                               }
+                       }
+                       if (dev->iamthif_current_cb)
+                               mei_free_cb_private(dev->iamthif_current_cb);
+
+                       dev->iamthif_file_object->private_data = NULL;
+                       dev->iamthif_file_object = NULL;
+                       dev->iamthif_current_cb = NULL;
+                       dev->iamthif_timer = 0;
+                       run_next_iamthif_cmd(dev);
+
+               }
+       }
+out:
+        schedule_delayed_work(&dev->wd_work, 2 * HZ);
+        mutex_unlock(&dev->device_lock);
+}
+
+/**
+ *  mei_interrupt_thread_handler - function called after ISR to handle the interrupt
+ * processing.
+ *
+ * @irq: The irq number
+ * @dev_id: pointer to the device structure
+ *
+ * returns irqreturn_t
+ *
+ */
+irqreturn_t mei_interrupt_thread_handler(int irq, void *dev_id)
+{
+       struct mei_device *dev = (struct mei_device *) dev_id;
+       struct mei_io_list complete_list;
+       struct mei_cl_cb *cb_pos = NULL, *cb_next = NULL;
+       struct mei_cl *cl;
+       s32 slots;
+       int rets;
+       bool  bus_message_received;
+
+
+       dev_dbg(&dev->pdev->dev, "function called after ISR to handle the interrupt processing.\n");
+       /* initialize our complete list */
+       mutex_lock(&dev->device_lock);
+       mei_initialize_list(&complete_list, dev);
+       dev->host_hw_state = mei_hcsr_read(dev);
+       dev->me_hw_state = mei_mecsr_read(dev);
+
+       /* check if ME wants a reset */
+       if ((dev->me_hw_state & ME_RDY_HRA) == 0 &&
+           dev->mei_state != MEI_RESETING &&
+           dev->mei_state != MEI_INITIALIZING) {
+               dev_dbg(&dev->pdev->dev, "FW not ready.\n");
+               mei_reset(dev, 1);
+               mutex_unlock(&dev->device_lock);
+               return IRQ_HANDLED;
+       }
+
+       /*  check if we need to start the dev */
+       if ((dev->host_hw_state & H_RDY) == 0) {
+               if ((dev->me_hw_state & ME_RDY_HRA) == ME_RDY_HRA) {
+                       dev_dbg(&dev->pdev->dev, "we need to start the dev.\n");
+                       dev->host_hw_state |= (H_IE | H_IG | H_RDY);
+                       mei_hcsr_set(dev);
+                       dev->mei_state = MEI_INIT_CLIENTS;
+                       dev_dbg(&dev->pdev->dev, "link is established start sending messages.\n");
+                       /* link is established
+                        * start sending messages.
+                        */
+                       host_start_message(dev);
+                       mutex_unlock(&dev->device_lock);
+                       return IRQ_HANDLED;
+               } else {
+                       dev_dbg(&dev->pdev->dev, "FW not ready.\n");
+                       mutex_unlock(&dev->device_lock);
+                       return IRQ_HANDLED;
+               }
+       }
+       /* check slots avalable for reading */
+       slots = mei_count_full_read_slots(dev);
+       dev_dbg(&dev->pdev->dev, "slots =%08x  extra_write_index =%08x.\n",
+               slots, dev->extra_write_index);
+       while (slots > 0 && !dev->extra_write_index) {
+               dev_dbg(&dev->pdev->dev, "slots =%08x  extra_write_index =%08x.\n",
+                               slots, dev->extra_write_index);
+               dev_dbg(&dev->pdev->dev, "call mei_irq_thread_read_handler.\n");
+               rets = mei_irq_thread_read_handler(&complete_list, dev, &slots);
+               if (rets)
+                       goto end;
+       }
+       rets = mei_irq_thread_write_handler(&complete_list, dev, &slots);
+end:
+       dev_dbg(&dev->pdev->dev, "end of bottom half function.\n");
+       dev->host_hw_state = mei_hcsr_read(dev);
+       dev->mei_host_buffer_is_empty = mei_host_buffer_is_empty(dev);
+
+       bus_message_received = false;
+       if (dev->recvd_msg && waitqueue_active(&dev->wait_recvd_msg)) {
+               dev_dbg(&dev->pdev->dev, "received waiting bus message\n");
+               bus_message_received = true;
+       }
+       mutex_unlock(&dev->device_lock);
+       if (bus_message_received) {
+               dev_dbg(&dev->pdev->dev, "wake up dev->wait_recvd_msg\n");
+               wake_up_interruptible(&dev->wait_recvd_msg);
+               bus_message_received = false;
+       }
+       if (complete_list.status || list_empty(&complete_list.mei_cb.cb_list))
+               return IRQ_HANDLED;
+
+
+       list_for_each_entry_safe(cb_pos, cb_next,
+                       &complete_list.mei_cb.cb_list, cb_list) {
+               cl = (struct mei_cl *)cb_pos->file_private;
+               list_del(&cb_pos->cb_list);
+               if (cl) {
+                       if (cl != &dev->iamthif_cl) {
+                               dev_dbg(&dev->pdev->dev, "completing call back.\n");
+                               _mei_cmpl(cl, cb_pos);
+                               cb_pos = NULL;
+                       } else if (cl == &dev->iamthif_cl) {
+                               _mei_cmpl_iamthif(dev, cb_pos);
+                       }
+               }
+       }
+       return IRQ_HANDLED;
+}
diff --git a/drivers/staging/mei/iorw.c b/drivers/staging/mei/iorw.c
new file mode 100644 (file)
index 0000000..697a277
--- /dev/null
@@ -0,0 +1,604 @@
+/*
+ *
+ * Intel Management Engine Interface (Intel MEI) Linux driver
+ * Copyright (c) 2003-2011, Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ */
+
+
+#include <linux/kernel.h>
+#include <linux/fs.h>
+#include <linux/errno.h>
+#include <linux/types.h>
+#include <linux/fcntl.h>
+#include <linux/aio.h>
+#include <linux/pci.h>
+#include <linux/init.h>
+#include <linux/ioctl.h>
+#include <linux/cdev.h>
+#include <linux/list.h>
+#include <linux/delay.h>
+#include <linux/sched.h>
+#include <linux/uuid.h>
+#include <linux/jiffies.h>
+#include <linux/uaccess.h>
+
+
+#include "mei_dev.h"
+#include "hw.h"
+#include "mei.h"
+#include "interface.h"
+#include "mei_version.h"
+
+
+
+/**
+ * mei_ioctl_connect_client - the connect to fw client IOCTL function
+ *
+ * @dev: the device structure
+ * @data: IOCTL connect data, input and output parameters
+ * @file: private data of the file object
+ *
+ * Locking: called under "dev->device_lock" lock
+ *
+ * returns 0 on success, <0 on failure.
+ */
+int mei_ioctl_connect_client(struct file *file,
+                       struct mei_connect_client_data *data)
+{
+       struct mei_device *dev;
+       struct mei_cl_cb *cb;
+       struct mei_client *client;
+       struct mei_cl *cl;
+       struct mei_cl *cl_pos = NULL;
+       struct mei_cl *cl_next = NULL;
+       long timeout = CONNECT_TIMEOUT;
+       int i;
+       int err;
+       int rets;
+
+       cl = file->private_data;
+       if (WARN_ON(!cl || !cl->dev))
+               return -ENODEV;
+
+       dev = cl->dev;
+
+       dev_dbg(&dev->pdev->dev, "mei_ioctl_connect_client() Entry\n");
+
+
+       /* buffered ioctl cb */
+       cb = kzalloc(sizeof(struct mei_cl_cb), GFP_KERNEL);
+       if (!cb) {
+               rets = -ENOMEM;
+               goto end;
+       }
+       INIT_LIST_HEAD(&cb->cb_list);
+
+       cb->major_file_operations = MEI_IOCTL;
+
+       if (dev->mei_state != MEI_ENABLED) {
+               rets = -ENODEV;
+               goto end;
+       }
+       if (cl->state != MEI_FILE_INITIALIZING &&
+           cl->state != MEI_FILE_DISCONNECTED) {
+               rets = -EBUSY;
+               goto end;
+       }
+
+       /* find ME client we're trying to connect to */
+       i = mei_find_me_client_index(dev, data->in_client_uuid);
+       if (i >= 0 && !dev->me_clients[i].props.fixed_address) {
+               cl->me_client_id = dev->me_clients[i].client_id;
+               cl->state = MEI_FILE_CONNECTING;
+       }
+
+       dev_dbg(&dev->pdev->dev, "Connect to FW Client ID = %d\n",
+                       cl->me_client_id);
+       dev_dbg(&dev->pdev->dev, "FW Client - Protocol Version = %d\n",
+                       dev->me_clients[i].props.protocol_version);
+       dev_dbg(&dev->pdev->dev, "FW Client - Max Msg Len = %d\n",
+                       dev->me_clients[i].props.max_msg_length);
+
+       /* if we're connecting to amthi client so we will use the exist
+        * connection
+        */
+       if (uuid_le_cmp(data->in_client_uuid, mei_amthi_guid) == 0) {
+               dev_dbg(&dev->pdev->dev, "FW Client is amthi\n");
+               if (dev->iamthif_cl.state != MEI_FILE_CONNECTED) {
+                       rets = -ENODEV;
+                       goto end;
+               }
+               clear_bit(cl->host_client_id, dev->host_clients_map);
+               list_for_each_entry_safe(cl_pos, cl_next,
+                                        &dev->file_list, link) {
+                       if (mei_fe_same_id(cl, cl_pos)) {
+                               dev_dbg(&dev->pdev->dev,
+                                       "remove file private data node host"
+                                   " client = %d, ME client = %d.\n",
+                                   cl_pos->host_client_id,
+                                   cl_pos->me_client_id);
+                               list_del(&cl_pos->link);
+                       }
+
+               }
+               dev_dbg(&dev->pdev->dev, "free file private data memory.\n");
+               kfree(cl);
+
+               cl = NULL;
+               file->private_data = &dev->iamthif_cl;
+
+               client = &data->out_client_properties;
+               client->max_msg_length =
+                       dev->me_clients[i].props.max_msg_length;
+               client->protocol_version =
+                       dev->me_clients[i].props.protocol_version;
+               rets = dev->iamthif_cl.status;
+
+               goto end;
+       }
+
+       if (cl->state != MEI_FILE_CONNECTING) {
+               rets = -ENODEV;
+               goto end;
+       }
+
+
+       /* prepare the output buffer */
+       client = &data->out_client_properties;
+       client->max_msg_length = dev->me_clients[i].props.max_msg_length;
+       client->protocol_version = dev->me_clients[i].props.protocol_version;
+       dev_dbg(&dev->pdev->dev, "Can connect?\n");
+       if (dev->mei_host_buffer_is_empty
+           && !mei_other_client_is_connecting(dev, cl)) {
+               dev_dbg(&dev->pdev->dev, "Sending Connect Message\n");
+               dev->mei_host_buffer_is_empty = 0;
+               if (!mei_connect(dev, cl)) {
+                       dev_dbg(&dev->pdev->dev, "Sending connect message - failed\n");
+                       rets = -ENODEV;
+                       goto end;
+               } else {
+                       dev_dbg(&dev->pdev->dev, "Sending connect message - succeeded\n");
+                       cl->timer_count = MEI_CONNECT_TIMEOUT;
+                       cb->file_private = cl;
+                       list_add_tail(&cb->cb_list,
+                                     &dev->ctrl_rd_list.mei_cb.
+                                     cb_list);
+               }
+
+
+       } else {
+               dev_dbg(&dev->pdev->dev, "Queuing the connect request due to device busy\n");
+               cb->file_private = cl;
+               dev_dbg(&dev->pdev->dev, "add connect cb to control write list.\n");
+               list_add_tail(&cb->cb_list,
+                             &dev->ctrl_wr_list.mei_cb.cb_list);
+       }
+       mutex_unlock(&dev->device_lock);
+       err = wait_event_timeout(dev->wait_recvd_msg,
+                       (MEI_FILE_CONNECTED == cl->state ||
+                        MEI_FILE_DISCONNECTED == cl->state),
+                       timeout * HZ);
+
+       mutex_lock(&dev->device_lock);
+       if (MEI_FILE_CONNECTED == cl->state) {
+               dev_dbg(&dev->pdev->dev, "successfully connected to FW client.\n");
+               rets = cl->status;
+               goto end;
+       } else {
+               dev_dbg(&dev->pdev->dev, "failed to connect to FW client.cl->state = %d.\n",
+                   cl->state);
+               if (!err) {
+                       dev_dbg(&dev->pdev->dev,
+                               "wait_event_interruptible_timeout failed on client"
+                               " connect message fw response message.\n");
+               }
+               rets = -EFAULT;
+
+               mei_flush_list(&dev->ctrl_rd_list, cl);
+               mei_flush_list(&dev->ctrl_wr_list, cl);
+               goto end;
+       }
+       rets = 0;
+end:
+       dev_dbg(&dev->pdev->dev, "free connect cb memory.");
+       kfree(cb);
+       return rets;
+}
+
+/**
+ * find_amthi_read_list_entry - finds a amthilist entry for current file
+ *
+ * @dev: the device structure
+ * @file: pointer to file object
+ *
+ * returns   returned a list entry on success, NULL on failure.
+ */
+struct mei_cl_cb *find_amthi_read_list_entry(
+               struct mei_device *dev,
+               struct file *file)
+{
+       struct mei_cl *cl_temp;
+       struct mei_cl_cb *cb_pos = NULL;
+       struct mei_cl_cb *cb_next = NULL;
+
+       if (!dev->amthi_read_complete_list.status &&
+           !list_empty(&dev->amthi_read_complete_list.mei_cb.cb_list)) {
+               list_for_each_entry_safe(cb_pos, cb_next,
+                   &dev->amthi_read_complete_list.mei_cb.cb_list, cb_list) {
+                       cl_temp = (struct mei_cl *)cb_pos->file_private;
+                       if (cl_temp && cl_temp == &dev->iamthif_cl &&
+                               cb_pos->file_object == file)
+                               return cb_pos;
+               }
+       }
+       return NULL;
+}
+
+/**
+ * amthi_read - read data from AMTHI client
+ *
+ * @dev: the device structure
+ * @if_num:  minor number
+ * @file: pointer to file object
+ * @*ubuf: pointer to user data in user space
+ * @length: data length to read
+ * @offset: data read offset
+ *
+ * Locking: called under "dev->device_lock" lock
+ *
+ * returns
+ *  returned data length on success,
+ *  zero if no data to read,
+ *  negative on failure.
+ */
+int amthi_read(struct mei_device *dev, struct file *file,
+             char __user *ubuf, size_t length, loff_t *offset)
+{
+       int rets;
+       int wait_ret;
+       struct mei_cl_cb *cb = NULL;
+       struct mei_cl *cl = file->private_data;
+       unsigned long timeout;
+       int i;
+
+       /* Only Posible if we are in timeout */
+       if (!cl || cl != &dev->iamthif_cl) {
+               dev_dbg(&dev->pdev->dev, "bad file ext.\n");
+               return -ETIMEDOUT;
+       }
+
+       for (i = 0; i < dev->num_mei_me_clients; i++) {
+               if (dev->me_clients[i].client_id ==
+                   dev->iamthif_cl.me_client_id)
+                       break;
+       }
+
+       if (i == dev->num_mei_me_clients) {
+               dev_dbg(&dev->pdev->dev, "amthi client not found.\n");
+               return -ENODEV;
+       }
+       if (WARN_ON(dev->me_clients[i].client_id != cl->me_client_id))
+               return -ENODEV;
+
+       dev_dbg(&dev->pdev->dev, "checking amthi data\n");
+       cb = find_amthi_read_list_entry(dev, file);
+
+       /* Check for if we can block or not*/
+       if (cb == NULL && file->f_flags & O_NONBLOCK)
+               return -EAGAIN;
+
+
+       dev_dbg(&dev->pdev->dev, "waiting for amthi data\n");
+       while (cb == NULL) {
+               /* unlock the Mutex */
+               mutex_unlock(&dev->device_lock);
+
+               wait_ret = wait_event_interruptible(dev->iamthif_cl.wait,
+                       (cb = find_amthi_read_list_entry(dev, file)));
+
+               if (wait_ret)
+                       return -ERESTARTSYS;
+
+               dev_dbg(&dev->pdev->dev, "woke up from sleep\n");
+
+               /* Locking again the Mutex */
+               mutex_lock(&dev->device_lock);
+       }
+
+
+       dev_dbg(&dev->pdev->dev, "Got amthi data\n");
+       dev->iamthif_timer = 0;
+
+       if (cb) {
+               timeout = cb->read_time +
+                                       msecs_to_jiffies(IAMTHIF_READ_TIMER);
+               dev_dbg(&dev->pdev->dev, "amthi timeout = %lud\n",
+                               timeout);
+
+               if  (time_after(jiffies, timeout)) {
+                       dev_dbg(&dev->pdev->dev, "amthi Time out\n");
+                       /* 15 sec for the message has expired */
+                       list_del(&cb->cb_list);
+                       rets = -ETIMEDOUT;
+                       goto free;
+               }
+       }
+       /* if the whole message will fit remove it from the list */
+       if (cb->information >= *offset &&
+           length >= (cb->information - *offset))
+               list_del(&cb->cb_list);
+       else if (cb->information > 0 && cb->information <= *offset) {
+               /* end of the message has been reached */
+               list_del(&cb->cb_list);
+               rets = 0;
+               goto free;
+       }
+               /* else means that not full buffer will be read and do not
+                * remove message from deletion list
+                */
+
+       dev_dbg(&dev->pdev->dev, "amthi cb->response_buffer size - %d\n",
+           cb->response_buffer.size);
+       dev_dbg(&dev->pdev->dev, "amthi cb->information - %lu\n",
+           cb->information);
+
+       /* length is being turncated to PAGE_SIZE, however,
+        * the information may be longer */
+       length = min_t(size_t, length, (cb->information - *offset));
+
+       if (copy_to_user(ubuf,
+                        cb->response_buffer.data + *offset,
+                        length))
+               rets = -EFAULT;
+       else {
+               rets = length;
+               if ((*offset + length) < cb->information) {
+                       *offset += length;
+                       goto out;
+               }
+       }
+free:
+       dev_dbg(&dev->pdev->dev, "free amthi cb memory.\n");
+       *offset = 0;
+       mei_free_cb_private(cb);
+out:
+       return rets;
+}
+
+/**
+ * mei_start_read - the start read client message function.
+ *
+ * @dev: the device structure
+ * @if_num:  minor number
+ * @cl: private data of the file object
+ *
+ * returns 0 on success, <0 on failure.
+ */
+int mei_start_read(struct mei_device *dev, struct mei_cl *cl)
+{
+       struct mei_cl_cb *cb;
+       int rets = 0;
+       int i;
+
+       if (cl->state != MEI_FILE_CONNECTED)
+               return -ENODEV;
+
+       if (dev->mei_state != MEI_ENABLED)
+               return -ENODEV;
+
+       dev_dbg(&dev->pdev->dev, "check if read is pending.\n");
+       if (cl->read_pending || cl->read_cb) {
+               dev_dbg(&dev->pdev->dev, "read is pending.\n");
+               return -EBUSY;
+       }
+
+       cb = kzalloc(sizeof(struct mei_cl_cb), GFP_KERNEL);
+       if (!cb)
+               return -ENOMEM;
+
+       dev_dbg(&dev->pdev->dev, "allocation call back successful. host client = %d, ME client = %d\n",
+               cl->host_client_id, cl->me_client_id);
+
+       for (i = 0; i < dev->num_mei_me_clients; i++) {
+               if (dev->me_clients[i].client_id == cl->me_client_id)
+                       break;
+
+       }
+
+       if (WARN_ON(dev->me_clients[i].client_id != cl->me_client_id)) {
+               rets = -ENODEV;
+               goto unlock;
+       }
+
+       if (i == dev->num_mei_me_clients) {
+               rets = -ENODEV;
+               goto unlock;
+       }
+
+       cb->response_buffer.size = dev->me_clients[i].props.max_msg_length;
+       cb->response_buffer.data =
+           kmalloc(cb->response_buffer.size, GFP_KERNEL);
+       if (!cb->response_buffer.data) {
+               rets = -ENOMEM;
+               goto unlock;
+       }
+       dev_dbg(&dev->pdev->dev, "allocation call back data success.\n");
+       cb->major_file_operations = MEI_READ;
+       /* make sure information is zero before we start */
+       cb->information = 0;
+       cb->file_private = (void *) cl;
+       cl->read_cb = cb;
+       if (dev->mei_host_buffer_is_empty) {
+               dev->mei_host_buffer_is_empty = 0;
+               if (!mei_send_flow_control(dev, cl)) {
+                       rets = -ENODEV;
+                       goto unlock;
+               } else {
+                       list_add_tail(&cb->cb_list,
+                                     &dev->read_list.mei_cb.cb_list);
+               }
+       } else {
+               list_add_tail(&cb->cb_list,
+                             &dev->ctrl_wr_list.mei_cb.cb_list);
+       }
+       return rets;
+unlock:
+       mei_free_cb_private(cb);
+       return rets;
+}
+
+/**
+ * amthi_write - write iamthif data to amthi client
+ *
+ * @dev: the device structure
+ * @cb: mei call back struct
+ *
+ * returns 0 on success, <0 on failure.
+ */
+int amthi_write(struct mei_device *dev, struct mei_cl_cb *cb)
+{
+       struct mei_msg_hdr mei_hdr;
+       int ret;
+
+       if (!dev || !cb)
+               return -ENODEV;
+
+       dev_dbg(&dev->pdev->dev, "write data to amthi client.\n");
+
+       dev->iamthif_state = MEI_IAMTHIF_WRITING;
+       dev->iamthif_current_cb = cb;
+       dev->iamthif_file_object = cb->file_object;
+       dev->iamthif_canceled = 0;
+       dev->iamthif_ioctl = 1;
+       dev->iamthif_msg_buf_size = cb->request_buffer.size;
+       memcpy(dev->iamthif_msg_buf, cb->request_buffer.data,
+           cb->request_buffer.size);
+
+       ret = mei_flow_ctrl_creds(dev, &dev->iamthif_cl);
+       if (ret < 0)
+               return ret;
+
+       if (ret && dev->mei_host_buffer_is_empty) {
+               ret = 0;
+               dev->mei_host_buffer_is_empty = 0;
+               if (cb->request_buffer.size >
+                       (((dev->host_hw_state & H_CBD) >> 24) * sizeof(u32))
+                               -sizeof(struct mei_msg_hdr)) {
+                       mei_hdr.length =
+                           (((dev->host_hw_state & H_CBD) >> 24) *
+                           sizeof(u32)) - sizeof(struct mei_msg_hdr);
+                       mei_hdr.msg_complete = 0;
+               } else {
+                       mei_hdr.length = cb->request_buffer.size;
+                       mei_hdr.msg_complete = 1;
+               }
+
+               mei_hdr.host_addr = dev->iamthif_cl.host_client_id;
+               mei_hdr.me_addr = dev->iamthif_cl.me_client_id;
+               mei_hdr.reserved = 0;
+               dev->iamthif_msg_buf_index += mei_hdr.length;
+               if (!mei_write_message(dev, &mei_hdr,
+                                       (unsigned char *)(dev->iamthif_msg_buf),
+                                       mei_hdr.length))
+                       return -ENODEV;
+
+               if (mei_hdr.msg_complete) {
+                       if (mei_flow_ctrl_reduce(dev, &dev->iamthif_cl))
+                               return -ENODEV;
+                       dev->iamthif_flow_control_pending = 1;
+                       dev->iamthif_state = MEI_IAMTHIF_FLOW_CONTROL;
+                       dev_dbg(&dev->pdev->dev, "add amthi cb to write waiting list\n");
+                       dev->iamthif_current_cb = cb;
+                       dev->iamthif_file_object = cb->file_object;
+                       list_add_tail(&cb->cb_list,
+                                     &dev->write_waiting_list.mei_cb.cb_list);
+               } else {
+                       dev_dbg(&dev->pdev->dev, "message does not complete, "
+                                       "so add amthi cb to write list.\n");
+                       list_add_tail(&cb->cb_list,
+                                     &dev->write_list.mei_cb.cb_list);
+               }
+       } else {
+               if (!(dev->mei_host_buffer_is_empty))
+                       dev_dbg(&dev->pdev->dev, "host buffer is not empty");
+
+               dev_dbg(&dev->pdev->dev, "No flow control credentials, "
+                               "so add iamthif cb to write list.\n");
+               list_add_tail(&cb->cb_list,
+                             &dev->write_list.mei_cb.cb_list);
+       }
+       return 0;
+}
+
+/**
+ * iamthif_ioctl_send_msg - send cmd data to amthi client
+ *
+ * @dev: the device structure
+ *
+ * returns 0 on success, <0 on failure.
+ */
+void run_next_iamthif_cmd(struct mei_device *dev)
+{
+       struct mei_cl *cl_tmp;
+       struct mei_cl_cb *cb_pos = NULL;
+       struct mei_cl_cb *cb_next = NULL;
+       int status;
+
+       if (!dev)
+               return;
+
+       dev->iamthif_msg_buf_size = 0;
+       dev->iamthif_msg_buf_index = 0;
+       dev->iamthif_canceled = 0;
+       dev->iamthif_ioctl = 1;
+       dev->iamthif_state = MEI_IAMTHIF_IDLE;
+       dev->iamthif_timer = 0;
+       dev->iamthif_file_object = NULL;
+
+       if (dev->amthi_cmd_list.status == 0 &&
+           !list_empty(&dev->amthi_cmd_list.mei_cb.cb_list)) {
+               dev_dbg(&dev->pdev->dev, "complete amthi cmd_list cb.\n");
+
+               list_for_each_entry_safe(cb_pos, cb_next,
+                   &dev->amthi_cmd_list.mei_cb.cb_list, cb_list) {
+                       list_del(&cb_pos->cb_list);
+                       cl_tmp = (struct mei_cl *)cb_pos->file_private;
+
+                       if (cl_tmp && cl_tmp == &dev->iamthif_cl) {
+                               status = amthi_write(dev, cb_pos);
+                               if (status) {
+                                       dev_dbg(&dev->pdev->dev,
+                                               "amthi write failed status = %d\n",
+                                                       status);
+                                       return;
+                               }
+                               break;
+                       }
+               }
+       }
+}
+
+/**
+ * mei_free_cb_private - free mei_cb_private related memory
+ *
+ * @cb: mei callback struct
+ */
+void mei_free_cb_private(struct mei_cl_cb *cb)
+{
+       if (cb == NULL)
+               return;
+
+       kfree(cb->request_buffer.data);
+       kfree(cb->response_buffer.data);
+       kfree(cb);
+}
diff --git a/drivers/staging/mei/main.c b/drivers/staging/mei/main.c
new file mode 100644 (file)
index 0000000..bfd1b46
--- /dev/null
@@ -0,0 +1,1349 @@
+/*
+ *
+ * Intel Management Engine Interface (Intel MEI) Linux driver
+ * Copyright (c) 2003-2011, Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ */
+
+
+
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/kernel.h>
+#include <linux/device.h>
+#include <linux/fs.h>
+#include <linux/errno.h>
+#include <linux/types.h>
+#include <linux/fcntl.h>
+#include <linux/aio.h>
+#include <linux/pci.h>
+#include <linux/poll.h>
+#include <linux/init.h>
+#include <linux/ioctl.h>
+#include <linux/cdev.h>
+#include <linux/version.h>
+#include <linux/sched.h>
+#include <linux/uuid.h>
+#include <linux/compat.h>
+#include <linux/jiffies.h>
+#include <linux/interrupt.h>
+
+#include "mei_dev.h"
+#include "mei.h"
+#include "interface.h"
+#include "mei_version.h"
+
+
+#define MEI_READ_TIMEOUT 45
+#define MEI_DRIVER_NAME        "mei"
+#define MEI_DEV_NAME "mei"
+
+/*
+ *  mei driver strings
+ */
+static char mei_driver_name[] = MEI_DRIVER_NAME;
+static const char mei_driver_string[] = "Intel(R) Management Engine Interface";
+static const char mei_driver_version[] = MEI_DRIVER_VERSION;
+
+/* mei char device for registration */
+static struct cdev mei_cdev;
+
+/* major number for device */
+static int mei_major;
+/* The device pointer */
+/* Currently this driver works as long as there is only a single AMT device. */
+static struct pci_dev *mei_device;
+
+static struct class *mei_class;
+
+
+/* mei_pci_tbl - PCI Device ID Table */
+static DEFINE_PCI_DEVICE_TABLE(mei_pci_tbl) = {
+       {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_82946GZ)},
+       {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_82G35)},
+       {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_82Q965)},
+       {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_82G965)},
+       {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_82GM965)},
+       {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_82GME965)},
+       {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH9_82Q35)},
+       {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH9_82G33)},
+       {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH9_82Q33)},
+       {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH9_82X38)},
+       {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH9_3200)},
+       {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH9_6)},
+       {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH9_7)},
+       {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH9_8)},
+       {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH9_9)},
+       {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH9_10)},
+       {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH9M_1)},
+       {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH9M_2)},
+       {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH9M_3)},
+       {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH9M_4)},
+       {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH10_1)},
+       {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH10_2)},
+       {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH10_3)},
+       {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH10_4)},
+       {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_IBXPK_1)},
+       {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_IBXPK_2)},
+       {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_CPT_1)},
+       {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_PBG_1)},
+       {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_PPT_1)},
+       {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_PPT_2)},
+       {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_PPT_3)},
+
+       /* required last entry */
+       {0, }
+};
+
+MODULE_DEVICE_TABLE(pci, mei_pci_tbl);
+
+static DEFINE_MUTEX(mei_mutex);
+
+/**
+ * mei_probe - Device Initialization Routine
+ *
+ * @pdev: PCI device structure
+ * @ent: entry in kcs_pci_tbl
+ *
+ * returns 0 on success, <0 on failure.
+ */
+static int __devinit mei_probe(struct pci_dev *pdev,
+                               const struct pci_device_id *ent)
+{
+       struct mei_device *dev;
+       int err;
+
+       mutex_lock(&mei_mutex);
+       if (mei_device) {
+               err = -EEXIST;
+               goto end;
+       }
+       /* enable pci dev */
+       err = pci_enable_device(pdev);
+       if (err) {
+               printk(KERN_ERR "mei: Failed to enable pci device.\n");
+               goto end;
+       }
+       /* set PCI host mastering  */
+       pci_set_master(pdev);
+       /* pci request regions for mei driver */
+       err = pci_request_regions(pdev, mei_driver_name);
+       if (err) {
+               printk(KERN_ERR "mei: Failed to get pci regions.\n");
+               goto disable_device;
+       }
+       /* allocates and initializes the mei dev structure */
+       dev = init_mei_device(pdev);
+       if (!dev) {
+               err = -ENOMEM;
+               goto release_regions;
+       }
+       /* mapping  IO device memory */
+       dev->mem_addr = pci_iomap(pdev, 0, 0);
+       if (!dev->mem_addr) {
+               printk(KERN_ERR "mei: mapping I/O device memory failure.\n");
+               err = -ENOMEM;
+               goto free_device;
+       }
+       /* request and enable interrupt   */
+       err = request_threaded_irq(pdev->irq,
+                       mei_interrupt_quick_handler,
+                       mei_interrupt_thread_handler,
+                       IRQF_SHARED, mei_driver_name, dev);
+       if (err) {
+               printk(KERN_ERR "mei: request_threaded_irq failure. irq = %d\n",
+                      pdev->irq);
+               goto unmap_memory;
+       }
+       INIT_DELAYED_WORK(&dev->wd_work, mei_wd_timer);
+       if (mei_hw_init(dev)) {
+               printk(KERN_ERR "mei: Init hw failure.\n");
+               err = -ENODEV;
+               goto release_irq;
+       }
+       mei_device = pdev;
+       pci_set_drvdata(pdev, dev);
+       schedule_delayed_work(&dev->wd_work, HZ);
+
+       mutex_unlock(&mei_mutex);
+
+       pr_debug("mei: Driver initialization successful.\n");
+
+       return 0;
+
+release_irq:
+       /* disable interrupts */
+       dev->host_hw_state = mei_hcsr_read(dev);
+       mei_disable_interrupts(dev);
+       flush_scheduled_work();
+       free_irq(pdev->irq, dev);
+unmap_memory:
+       pci_iounmap(pdev, dev->mem_addr);
+free_device:
+       kfree(dev);
+release_regions:
+       pci_release_regions(pdev);
+disable_device:
+       pci_disable_device(pdev);
+end:
+       mutex_unlock(&mei_mutex);
+       printk(KERN_ERR "mei: Driver initialization failed.\n");
+       return err;
+}
+
+/**
+ * mei_remove - Device Removal Routine
+ *
+ * @pdev: PCI device structure
+ *
+ * mei_remove is called by the PCI subsystem to alert the driver
+ * that it should release a PCI device.
+ */
+static void __devexit mei_remove(struct pci_dev *pdev)
+{
+       struct mei_device *dev;
+
+       if (mei_device != pdev)
+               return;
+
+       dev = pci_get_drvdata(pdev);
+       if (!dev)
+               return;
+
+       mutex_lock(&dev->device_lock);
+
+       mei_wd_stop(dev, false);
+
+       mei_device = NULL;
+
+       if (dev->iamthif_cl.state == MEI_FILE_CONNECTED) {
+               dev->iamthif_cl.state = MEI_FILE_DISCONNECTING;
+               mei_disconnect_host_client(dev, &dev->iamthif_cl);
+       }
+       if (dev->wd_cl.state == MEI_FILE_CONNECTED) {
+               dev->wd_cl.state = MEI_FILE_DISCONNECTING;
+               mei_disconnect_host_client(dev, &dev->wd_cl);
+       }
+
+       /* remove entry if already in list */
+       dev_dbg(&pdev->dev, "list del iamthif and wd file list.\n");
+       mei_remove_client_from_file_list(dev, dev->wd_cl.host_client_id);
+       mei_remove_client_from_file_list(dev, dev->iamthif_cl.host_client_id);
+
+       dev->iamthif_current_cb = NULL;
+       dev->num_mei_me_clients = 0;
+
+       mutex_unlock(&dev->device_lock);
+
+       flush_scheduled_work();
+
+       /* disable interrupts */
+       mei_disable_interrupts(dev);
+
+       free_irq(pdev->irq, dev);
+       pci_set_drvdata(pdev, NULL);
+
+       if (dev->mem_addr)
+               pci_iounmap(pdev, dev->mem_addr);
+
+       kfree(dev);
+
+       pci_release_regions(pdev);
+       pci_disable_device(pdev);
+}
+
+/**
+ * mei_clear_list - removes all callbacks associated with file
+ *             from mei_cb_list
+ *
+ * @dev: device structure.
+ * @file: file structure
+ * @mei_cb_list: callbacks list
+ *
+ * mei_clear_list is called to clear resources associated with file
+ * when application calls close function or Ctrl-C was pressed
+ *
+ * returns true if callback removed from the list, false otherwise
+ */
+static bool mei_clear_list(struct mei_device *dev,
+               struct file *file, struct list_head *mei_cb_list)
+{
+       struct mei_cl_cb *cb_pos = NULL;
+       struct mei_cl_cb *cb_next = NULL;
+       struct file *file_temp;
+       bool removed = false;
+
+       /* list all list member */
+       list_for_each_entry_safe(cb_pos, cb_next, mei_cb_list, cb_list) {
+               file_temp = (struct file *)cb_pos->file_object;
+               /* check if list member associated with a file */
+               if (file_temp == file) {
+                       /* remove member from the list */
+                       list_del(&cb_pos->cb_list);
+                       /* check if cb equal to current iamthif cb */
+                       if (dev->iamthif_current_cb == cb_pos) {
+                               dev->iamthif_current_cb = NULL;
+                               /* send flow control to iamthif client */
+                               mei_send_flow_control(dev, &dev->iamthif_cl);
+                       }
+                       /* free all allocated buffers */
+                       mei_free_cb_private(cb_pos);
+                       cb_pos = NULL;
+                       removed = true;
+               }
+       }
+       return removed;
+}
+
+/**
+ * mei_clear_lists - removes all callbacks associated with file
+ *
+ * @dev: device structure
+ * @file: file structure
+ *
+ * mei_clear_lists is called to clear resources associated with file
+ * when application calls close function or Ctrl-C was pressed
+ *
+ * returns true if callback removed from the list, false otherwise
+ */
+static bool mei_clear_lists(struct mei_device *dev, struct file *file)
+{
+       bool removed = false;
+
+       /* remove callbacks associated with a file */
+       mei_clear_list(dev, file, &dev->amthi_cmd_list.mei_cb.cb_list);
+       if (mei_clear_list(dev, file,
+                           &dev->amthi_read_complete_list.mei_cb.cb_list))
+               removed = true;
+
+       mei_clear_list(dev, file, &dev->ctrl_rd_list.mei_cb.cb_list);
+
+       if (mei_clear_list(dev, file, &dev->ctrl_wr_list.mei_cb.cb_list))
+               removed = true;
+
+       if (mei_clear_list(dev, file, &dev->write_waiting_list.mei_cb.cb_list))
+               removed = true;
+
+       if (mei_clear_list(dev, file, &dev->write_list.mei_cb.cb_list))
+               removed = true;
+
+       /* check if iamthif_current_cb not NULL */
+       if (dev->iamthif_current_cb && !removed) {
+               /* check file and iamthif current cb association */
+               if (dev->iamthif_current_cb->file_object == file) {
+                       /* remove cb */
+                       mei_free_cb_private(dev->iamthif_current_cb);
+                       dev->iamthif_current_cb = NULL;
+                       removed = true;
+               }
+       }
+       return removed;
+}
+/**
+ * find_read_list_entry - find read list entry
+ *
+ * @dev: device structure
+ * @file: pointer to file structure
+ *
+ * returns cb on success, NULL on error
+ */
+static struct mei_cl_cb *find_read_list_entry(
+               struct mei_device *dev,
+               struct mei_cl *cl)
+{
+       struct mei_cl_cb *cb_pos = NULL;
+       struct mei_cl_cb *cb_next = NULL;
+       struct mei_cl *cl_list_temp;
+
+       if (!dev->read_list.status &&
+           !list_empty(&dev->read_list.mei_cb.cb_list)) {
+
+               dev_dbg(&dev->pdev->dev, "remove read_list CB\n");
+               list_for_each_entry_safe(cb_pos, cb_next,
+                               &dev->read_list.mei_cb.cb_list, cb_list) {
+
+                       cl_list_temp = (struct mei_cl *)
+                               cb_pos->file_private;
+
+                       if (cl_list_temp &&
+                           mei_fe_same_id(cl, cl_list_temp))
+                               return cb_pos;
+
+               }
+       }
+       return NULL;
+}
+
+/**
+ * mei_open - the open function
+ *
+ * @inode: pointer to inode structure
+ * @file: pointer to file structure
+ *
+ * returns 0 on success, <0 on error
+ */
+static int mei_open(struct inode *inode, struct file *file)
+{
+       struct mei_cl *cl;
+       int if_num = iminor(inode), err;
+       struct mei_device *dev;
+
+       err = -ENODEV;
+       if (!mei_device)
+               goto out;
+
+       dev = pci_get_drvdata(mei_device);
+       if (if_num != MEI_MINOR_NUMBER || !dev)
+               goto out;
+
+       mutex_lock(&dev->device_lock);
+       err = -ENOMEM;
+       cl = mei_alloc_file_private(dev);
+       if (!cl)
+               goto out;
+
+       err = -ENODEV;
+       if (dev->mei_state != MEI_ENABLED) {
+               dev_dbg(&dev->pdev->dev, "mei_state != MEI_ENABLED  mei_state= %d\n",
+                   dev->mei_state);
+               goto out_unlock;
+       }
+       err = -EMFILE;
+       if (dev->open_handle_count >= MEI_MAX_OPEN_HANDLE_COUNT)
+               goto out_unlock;
+
+       cl->host_client_id = find_first_zero_bit(dev->host_clients_map,
+                                                       MEI_CLIENTS_MAX);
+       if (cl->host_client_id > MEI_CLIENTS_MAX)
+               goto out_unlock;
+
+       dev_dbg(&dev->pdev->dev, "client_id = %d\n", cl->host_client_id);
+
+       dev->open_handle_count++;
+       list_add_tail(&cl->link, &dev->file_list);
+
+       set_bit(cl->host_client_id, dev->host_clients_map);
+       cl->state = MEI_FILE_INITIALIZING;
+       cl->sm_state = 0;
+
+       file->private_data = cl;
+       mutex_unlock(&dev->device_lock);
+
+       return 0;
+
+out_unlock:
+       mutex_unlock(&dev->device_lock);
+       kfree(cl);
+out:
+       return err;
+}
+
+/**
+ * mei_release - the release function
+ *
+ * @inode: pointer to inode structure
+ * @file: pointer to file structure
+ *
+ * returns 0 on success, <0 on error
+ */
+static int mei_release(struct inode *inode, struct file *file)
+{
+       struct mei_cl *cl = file->private_data;
+       struct mei_cl_cb *cb;
+       struct mei_device *dev;
+       int rets = 0;
+
+       if (WARN_ON(!cl || !cl->dev))
+               return -ENODEV;
+
+       dev = cl->dev;
+
+       mutex_lock(&dev->device_lock);
+       if (cl != &dev->iamthif_cl) {
+               if (cl->state == MEI_FILE_CONNECTED) {
+                       cl->state = MEI_FILE_DISCONNECTING;
+                       dev_dbg(&dev->pdev->dev,
+                               "disconnecting client host client = %d, "
+                           "ME client = %d\n",
+                           cl->host_client_id,
+                           cl->me_client_id);
+                       rets = mei_disconnect_host_client(dev, cl);
+               }
+               mei_flush_queues(dev, cl);
+               dev_dbg(&dev->pdev->dev, "remove client host client = %d, ME client = %d\n",
+                   cl->host_client_id,
+                   cl->me_client_id);
+
+               if (dev->open_handle_count > 0) {
+                       clear_bit(cl->host_client_id,
+                                 dev->host_clients_map);
+                       dev->open_handle_count--;
+               }
+               mei_remove_client_from_file_list(dev, cl->host_client_id);
+
+               /* free read cb */
+               cb = NULL;
+               if (cl->read_cb) {
+                       cb = find_read_list_entry(dev, cl);
+                       /* Remove entry from read list */
+                       if (cb)
+                               list_del(&cb->cb_list);
+
+                       cb = cl->read_cb;
+                       cl->read_cb = NULL;
+               }
+
+               file->private_data = NULL;
+
+               if (cb) {
+                       mei_free_cb_private(cb);
+                       cb = NULL;
+               }
+
+               kfree(cl);
+       } else {
+               if (dev->open_handle_count > 0)
+                       dev->open_handle_count--;
+
+               if (dev->iamthif_file_object == file &&
+                   dev->iamthif_state != MEI_IAMTHIF_IDLE) {
+
+                       dev_dbg(&dev->pdev->dev, "amthi canceled iamthif state %d\n",
+                           dev->iamthif_state);
+                       dev->iamthif_canceled = 1;
+                       if (dev->iamthif_state == MEI_IAMTHIF_READ_COMPLETE) {
+                               dev_dbg(&dev->pdev->dev, "run next amthi iamthif cb\n");
+                               run_next_iamthif_cmd(dev);
+                       }
+               }
+
+               if (mei_clear_lists(dev, file))
+                       dev->iamthif_state = MEI_IAMTHIF_IDLE;
+
+       }
+       mutex_unlock(&dev->device_lock);
+       return rets;
+}
+
+
+/**
+ * mei_read - the read function.
+ *
+ * @file: pointer to file structure
+ * @ubuf: pointer to user buffer
+ * @length: buffer length
+ * @offset: data offset in buffer
+ *
+ * returns >=0 data length on success , <0 on error
+ */
+static ssize_t mei_read(struct file *file, char __user *ubuf,
+                        size_t length, loff_t *offset)
+{
+       struct mei_cl *cl = file->private_data;
+       struct mei_cl_cb *cb_pos = NULL;
+       struct mei_cl_cb *cb = NULL;
+       struct mei_device *dev;
+       int i;
+       int rets;
+       int err;
+
+
+       if (WARN_ON(!cl || !cl->dev))
+               return -ENODEV;
+
+       dev = cl->dev;
+
+       mutex_lock(&dev->device_lock);
+       if (dev->mei_state != MEI_ENABLED) {
+               rets = -ENODEV;
+               goto out;
+       }
+
+       if ((cl->sm_state & MEI_WD_STATE_INDEPENDENCE_MSG_SENT) == 0) {
+               /* Do not allow to read watchdog client */
+               i = mei_find_me_client_index(dev, mei_wd_guid);
+               if (i >= 0) {
+                       struct mei_me_client *me_client = &dev->me_clients[i];
+
+                       if (cl->me_client_id == me_client->client_id) {
+                               rets = -EBADF;
+                               goto out;
+                       }
+               }
+       } else {
+               cl->sm_state &= ~MEI_WD_STATE_INDEPENDENCE_MSG_SENT;
+       }
+
+       if (cl == &dev->iamthif_cl) {
+               rets = amthi_read(dev, file, ubuf, length, offset);
+               goto out;
+       }
+
+       if (cl->read_cb && cl->read_cb->information > *offset) {
+               cb = cl->read_cb;
+               goto copy_buffer;
+       } else if (cl->read_cb && cl->read_cb->information > 0 &&
+                  cl->read_cb->information <= *offset) {
+               cb = cl->read_cb;
+               rets = 0;
+               goto free;
+       } else if ((!cl->read_cb || !cl->read_cb->information) &&
+                   *offset > 0) {
+               /*Offset needs to be cleaned for contingous reads*/
+               *offset = 0;
+               rets = 0;
+               goto out;
+       }
+
+       err = mei_start_read(dev, cl);
+       if (err && err != -EBUSY) {
+               dev_dbg(&dev->pdev->dev,
+                       "mei start read failure with status = %d\n", err);
+               rets = err;
+               goto out;
+       }
+
+       if (MEI_READ_COMPLETE != cl->reading_state &&
+                       !waitqueue_active(&cl->rx_wait)) {
+               if (file->f_flags & O_NONBLOCK) {
+                       rets = -EAGAIN;
+                       goto out;
+               }
+
+               mutex_unlock(&dev->device_lock);
+
+               if (wait_event_interruptible(cl->rx_wait,
+                       (MEI_READ_COMPLETE == cl->reading_state ||
+                        MEI_FILE_INITIALIZING == cl->state ||
+                        MEI_FILE_DISCONNECTED == cl->state ||
+                        MEI_FILE_DISCONNECTING == cl->state))) {
+                       if (signal_pending(current))
+                               return -EINTR;
+                       return -ERESTARTSYS;
+               }
+
+               mutex_lock(&dev->device_lock);
+               if (MEI_FILE_INITIALIZING == cl->state ||
+                   MEI_FILE_DISCONNECTED == cl->state ||
+                   MEI_FILE_DISCONNECTING == cl->state) {
+                       rets = -EBUSY;
+                       goto out;
+               }
+       }
+
+       cb = cl->read_cb;
+
+       if (!cb) {
+               rets = -ENODEV;
+               goto out;
+       }
+       if (cl->reading_state != MEI_READ_COMPLETE) {
+               rets = 0;
+               goto out;
+       }
+       /* now copy the data to user space */
+copy_buffer:
+       dev_dbg(&dev->pdev->dev, "cb->response_buffer size - %d\n",
+           cb->response_buffer.size);
+       dev_dbg(&dev->pdev->dev, "cb->information - %lu\n",
+           cb->information);
+       if (length == 0 || ubuf == NULL || *offset > cb->information) {
+               rets = -EMSGSIZE;
+               goto free;
+       }
+
+       /* length is being turncated to PAGE_SIZE, however, */
+       /* information size may be longer */
+       length = min_t(size_t, length, (cb->information - *offset));
+
+       if (copy_to_user(ubuf,
+                        cb->response_buffer.data + *offset,
+                        length)) {
+               rets = -EFAULT;
+               goto free;
+       }
+
+       rets = length;
+       *offset += length;
+       if ((unsigned long)*offset < cb->information)
+               goto out;
+
+free:
+       cb_pos = find_read_list_entry(dev, cl);
+       /* Remove entry from read list */
+       if (cb_pos)
+               list_del(&cb_pos->cb_list);
+       mei_free_cb_private(cb);
+       cl->reading_state = MEI_IDLE;
+       cl->read_cb = NULL;
+       cl->read_pending = 0;
+out:
+       dev_dbg(&dev->pdev->dev, "end mei read rets= %d\n", rets);
+       mutex_unlock(&dev->device_lock);
+       return rets;
+}
+
+/**
+ * mei_write - the write function.
+ *
+ * @file: pointer to file structure
+ * @ubuf: pointer to user buffer
+ * @length: buffer length
+ * @offset: data offset in buffer
+ *
+ * returns >=0 data length on success , <0 on error
+ */
+static ssize_t mei_write(struct file *file, const char __user *ubuf,
+                         size_t length, loff_t *offset)
+{
+       struct mei_cl *cl = file->private_data;
+       struct mei_cl_cb *write_cb = NULL;
+       struct mei_msg_hdr mei_hdr;
+       struct mei_device *dev;
+       unsigned long timeout = 0;
+       int rets;
+       int i;
+
+       if (WARN_ON(!cl || !cl->dev))
+               return -ENODEV;
+
+       dev = cl->dev;
+
+       mutex_lock(&dev->device_lock);
+
+       if (dev->mei_state != MEI_ENABLED) {
+               mutex_unlock(&dev->device_lock);
+               return -ENODEV;
+       }
+
+       if (cl == &dev->iamthif_cl) {
+               write_cb = find_amthi_read_list_entry(dev, file);
+
+               if (write_cb) {
+                       timeout = write_cb->read_time +
+                                       msecs_to_jiffies(IAMTHIF_READ_TIMER);
+
+                       if (time_after(jiffies, timeout) ||
+                                cl->reading_state == MEI_READ_COMPLETE) {
+                                       *offset = 0;
+                                       list_del(&write_cb->cb_list);
+                                       mei_free_cb_private(write_cb);
+                                       write_cb = NULL;
+                       }
+               }
+       }
+
+       /* free entry used in read */
+       if (cl->reading_state == MEI_READ_COMPLETE) {
+               *offset = 0;
+               write_cb = find_read_list_entry(dev, cl);
+               if (write_cb) {
+                       list_del(&write_cb->cb_list);
+                       mei_free_cb_private(write_cb);
+                       write_cb = NULL;
+                       cl->reading_state = MEI_IDLE;
+                       cl->read_cb = NULL;
+                       cl->read_pending = 0;
+               }
+       } else if (cl->reading_state == MEI_IDLE &&
+                  !cl->read_pending)
+               *offset = 0;
+
+
+       write_cb = kzalloc(sizeof(struct mei_cl_cb), GFP_KERNEL);
+       if (!write_cb) {
+               mutex_unlock(&dev->device_lock);
+               return -ENOMEM;
+       }
+
+       write_cb->file_object = file;
+       write_cb->file_private = cl;
+       write_cb->request_buffer.data = kmalloc(length, GFP_KERNEL);
+       rets = -ENOMEM;
+       if (!write_cb->request_buffer.data)
+               goto unlock_dev;
+
+       dev_dbg(&dev->pdev->dev, "length =%d\n", (int) length);
+
+       rets = -EFAULT;
+       if (copy_from_user(write_cb->request_buffer.data, ubuf, length))
+               goto unlock_dev;
+
+       cl->sm_state = 0;
+       if (length == 4 &&
+           ((memcmp(mei_wd_state_independence_msg[0],
+                                write_cb->request_buffer.data, 4) == 0) ||
+            (memcmp(mei_wd_state_independence_msg[1],
+                                write_cb->request_buffer.data, 4) == 0) ||
+            (memcmp(mei_wd_state_independence_msg[2],
+                                write_cb->request_buffer.data, 4) == 0)))
+               cl->sm_state |= MEI_WD_STATE_INDEPENDENCE_MSG_SENT;
+
+       INIT_LIST_HEAD(&write_cb->cb_list);
+       if (cl == &dev->iamthif_cl) {
+               write_cb->response_buffer.data =
+                   kmalloc(dev->iamthif_mtu, GFP_KERNEL);
+               if (!write_cb->response_buffer.data) {
+                       rets = -ENOMEM;
+                       goto unlock_dev;
+               }
+               if (dev->mei_state != MEI_ENABLED) {
+                       rets = -ENODEV;
+                       goto unlock_dev;
+               }
+               for (i = 0; i < dev->num_mei_me_clients; i++) {
+                       if (dev->me_clients[i].client_id ==
+                               dev->iamthif_cl.me_client_id)
+                               break;
+               }
+
+               if (WARN_ON(dev->me_clients[i].client_id != cl->me_client_id)) {
+                       rets = -ENODEV;
+                       goto unlock_dev;
+               }
+               if (i == dev->num_mei_me_clients ||
+                   (dev->me_clients[i].client_id !=
+                     dev->iamthif_cl.me_client_id)) {
+                       rets = -ENODEV;
+                       goto unlock_dev;
+               } else if (length > dev->me_clients[i].props.max_msg_length ||
+                          length <= 0) {
+                       rets = -EMSGSIZE;
+                       goto unlock_dev;
+               }
+
+               write_cb->response_buffer.size = dev->iamthif_mtu;
+               write_cb->major_file_operations = MEI_IOCTL;
+               write_cb->information = 0;
+               write_cb->request_buffer.size = length;
+               if (dev->iamthif_cl.state != MEI_FILE_CONNECTED) {
+                       rets = -ENODEV;
+                       goto unlock_dev;
+               }
+
+               if (!list_empty(&dev->amthi_cmd_list.mei_cb.cb_list) ||
+                               dev->iamthif_state != MEI_IAMTHIF_IDLE) {
+                       dev_dbg(&dev->pdev->dev, "amthi_state = %d\n",
+                                       (int) dev->iamthif_state);
+                       dev_dbg(&dev->pdev->dev, "add amthi cb to amthi cmd waiting list\n");
+                       list_add_tail(&write_cb->cb_list,
+                                       &dev->amthi_cmd_list.mei_cb.cb_list);
+                       rets = length;
+               } else {
+                       dev_dbg(&dev->pdev->dev, "call amthi write\n");
+                       rets = amthi_write(dev, write_cb);
+
+                       if (rets) {
+                               dev_dbg(&dev->pdev->dev, "amthi write failed with status = %d\n",
+                                   rets);
+                               goto unlock_dev;
+                       }
+                       rets = length;
+               }
+               mutex_unlock(&dev->device_lock);
+               return rets;
+       }
+
+       write_cb->major_file_operations = MEI_WRITE;
+       /* make sure information is zero before we start */
+
+       write_cb->information = 0;
+       write_cb->request_buffer.size = length;
+
+       dev_dbg(&dev->pdev->dev, "host client = %d, ME client = %d\n",
+           cl->host_client_id, cl->me_client_id);
+       if (cl->state != MEI_FILE_CONNECTED) {
+               rets = -ENODEV;
+               dev_dbg(&dev->pdev->dev, "host client = %d,  is not connected to ME client = %d",
+                   cl->host_client_id,
+                   cl->me_client_id);
+               goto unlock_dev;
+       }
+       for (i = 0; i < dev->num_mei_me_clients; i++) {
+               if (dev->me_clients[i].client_id ==
+                   cl->me_client_id)
+                       break;
+       }
+       if (WARN_ON(dev->me_clients[i].client_id != cl->me_client_id)) {
+               rets = -ENODEV;
+               goto unlock_dev;
+       }
+       if (i == dev->num_mei_me_clients) {
+               rets = -ENODEV;
+               goto unlock_dev;
+       }
+       if (length > dev->me_clients[i].props.max_msg_length || length <= 0) {
+               rets = -EINVAL;
+               goto unlock_dev;
+       }
+       write_cb->file_private = cl;
+
+       rets = mei_flow_ctrl_creds(dev, cl);
+       if (rets < 0)
+               goto unlock_dev;
+
+       if (rets && dev->mei_host_buffer_is_empty) {
+               rets = 0;
+               dev->mei_host_buffer_is_empty = 0;
+               if (length > ((((dev->host_hw_state & H_CBD) >> 24) *
+                       sizeof(u32)) - sizeof(struct mei_msg_hdr))) {
+
+                       mei_hdr.length =
+                               (((dev->host_hw_state & H_CBD) >> 24) *
+                               sizeof(u32)) -
+                               sizeof(struct mei_msg_hdr);
+                       mei_hdr.msg_complete = 0;
+               } else {
+                       mei_hdr.length = length;
+                       mei_hdr.msg_complete = 1;
+               }
+               mei_hdr.host_addr = cl->host_client_id;
+               mei_hdr.me_addr = cl->me_client_id;
+               mei_hdr.reserved = 0;
+               dev_dbg(&dev->pdev->dev, "call mei_write_message header=%08x.\n",
+                   *((u32 *) &mei_hdr));
+               if (!mei_write_message(dev, &mei_hdr,
+                       (unsigned char *) (write_cb->request_buffer.data),
+                       mei_hdr.length)) {
+                       rets = -ENODEV;
+                       goto unlock_dev;
+               }
+               cl->writing_state = MEI_WRITING;
+               write_cb->information = mei_hdr.length;
+               if (mei_hdr.msg_complete) {
+                       if (mei_flow_ctrl_reduce(dev, cl)) {
+                               rets = -ENODEV;
+                               goto unlock_dev;
+                       }
+                       list_add_tail(&write_cb->cb_list,
+                                     &dev->write_waiting_list.mei_cb.cb_list);
+               } else {
+                       list_add_tail(&write_cb->cb_list,
+                                     &dev->write_list.mei_cb.cb_list);
+               }
+
+       } else {
+
+               write_cb->information = 0;
+               cl->writing_state = MEI_WRITING;
+               list_add_tail(&write_cb->cb_list,
+                             &dev->write_list.mei_cb.cb_list);
+       }
+       mutex_unlock(&dev->device_lock);
+       return length;
+
+unlock_dev:
+       mutex_unlock(&dev->device_lock);
+       mei_free_cb_private(write_cb);
+       return rets;
+}
+
+
+/**
+ * mei_ioctl - the IOCTL function
+ *
+ * @file: pointer to file structure
+ * @cmd: ioctl command
+ * @data: pointer to mei message structure
+ *
+ * returns 0 on success , <0 on error
+ */
+static long mei_ioctl(struct file *file, unsigned int cmd, unsigned long data)
+{
+       struct mei_device *dev;
+       struct mei_cl *cl = file->private_data;
+       struct mei_connect_client_data *connect_data = NULL;
+       int rets;
+
+       if (cmd != IOCTL_MEI_CONNECT_CLIENT)
+               return -EINVAL;
+
+       if (WARN_ON(!cl || !cl->dev))
+               return -ENODEV;
+
+       dev = cl->dev;
+
+       dev_dbg(&dev->pdev->dev, "IOCTL cmd = 0x%x", cmd);
+
+       mutex_lock(&dev->device_lock);
+       if (dev->mei_state != MEI_ENABLED) {
+               rets = -ENODEV;
+               goto out;
+       }
+
+       dev_dbg(&dev->pdev->dev, ": IOCTL_MEI_CONNECT_CLIENT.\n");
+
+       connect_data = kzalloc(sizeof(struct mei_connect_client_data),
+                                                       GFP_KERNEL);
+       if (!connect_data) {
+               rets = -ENOMEM;
+               goto out;
+       }
+       dev_dbg(&dev->pdev->dev, "copy connect data from user\n");
+       if (copy_from_user(connect_data, (char __user *)data,
+                               sizeof(struct mei_connect_client_data))) {
+               dev_dbg(&dev->pdev->dev, "failed to copy data from userland\n");
+               rets = -EFAULT;
+               goto out;
+       }
+       rets = mei_ioctl_connect_client(file, connect_data);
+
+       /* if all is ok, copying the data back to user. */
+       if (rets)
+               goto out;
+
+       dev_dbg(&dev->pdev->dev, "copy connect data to user\n");
+       if (copy_to_user((char __user *)data, connect_data,
+                               sizeof(struct mei_connect_client_data))) {
+               dev_dbg(&dev->pdev->dev, "failed to copy data to userland\n");
+               rets = -EFAULT;
+               goto out;
+       }
+
+out:
+       kfree(connect_data);
+       mutex_unlock(&dev->device_lock);
+       return rets;
+}
+
+/**
+ * mei_compat_ioctl - the compat IOCTL function
+ *
+ * @file: pointer to file structure
+ * @cmd: ioctl command
+ * @data: pointer to mei message structure
+ *
+ * returns 0 on success , <0 on error
+ */
+#ifdef CONFIG_COMPAT
+static long mei_compat_ioctl(struct file *file,
+                     unsigned int cmd, unsigned long data)
+{
+       return mei_ioctl(file, cmd, (unsigned long)compat_ptr(data));
+}
+#endif
+
+
+/**
+ * mei_poll - the poll function
+ *
+ * @file: pointer to file structure
+ * @wait: pointer to poll_table structure
+ *
+ * returns poll mask
+ */
+static unsigned int mei_poll(struct file *file, poll_table *wait)
+{
+       struct mei_cl *cl = file->private_data;
+       struct mei_device *dev;
+       unsigned int mask = 0;
+
+       if (WARN_ON(!cl || !cl->dev))
+               return mask;
+
+       dev = cl->dev;
+
+       mutex_lock(&dev->device_lock);
+
+       if (dev->mei_state != MEI_ENABLED)
+               goto out;
+
+
+       if (cl == &dev->iamthif_cl) {
+               mutex_unlock(&dev->device_lock);
+               poll_wait(file, &dev->iamthif_cl.wait, wait);
+               mutex_lock(&dev->device_lock);
+               if (dev->iamthif_state == MEI_IAMTHIF_READ_COMPLETE &&
+                       dev->iamthif_file_object == file) {
+                       mask |= (POLLIN | POLLRDNORM);
+                       dev_dbg(&dev->pdev->dev, "run next amthi cb\n");
+                       run_next_iamthif_cmd(dev);
+               }
+               goto out;
+       }
+
+       mutex_unlock(&dev->device_lock);
+       poll_wait(file, &cl->tx_wait, wait);
+       mutex_lock(&dev->device_lock);
+       if (MEI_WRITE_COMPLETE == cl->writing_state)
+               mask |= (POLLIN | POLLRDNORM);
+
+out:
+       mutex_unlock(&dev->device_lock);
+       return mask;
+}
+
+#ifdef CONFIG_PM
+static int mei_pci_suspend(struct device *device)
+{
+       struct pci_dev *pdev = to_pci_dev(device);
+       struct mei_device *dev = pci_get_drvdata(pdev);
+       int err;
+
+       if (!dev)
+               return -ENODEV;
+       mutex_lock(&dev->device_lock);
+       /* Stop watchdog if exists */
+       err = mei_wd_stop(dev, true);
+       /* Set new mei state */
+       if (dev->mei_state == MEI_ENABLED ||
+           dev->mei_state == MEI_RECOVERING_FROM_RESET) {
+               dev->mei_state = MEI_POWER_DOWN;
+               mei_reset(dev, 0);
+       }
+       mutex_unlock(&dev->device_lock);
+
+       free_irq(pdev->irq, dev);
+
+
+       return err;
+}
+
+static int mei_pci_resume(struct device *device)
+{
+       struct pci_dev *pdev = to_pci_dev(device);
+       struct mei_device *dev;
+       int err;
+
+       dev = pci_get_drvdata(pdev);
+       if (!dev)
+               return -ENODEV;
+
+       /* request and enable interrupt   */
+       err = request_threaded_irq(pdev->irq,
+                       mei_interrupt_quick_handler,
+                       mei_interrupt_thread_handler,
+                       IRQF_SHARED, mei_driver_name, dev);
+       if (err) {
+               printk(KERN_ERR "mei: Request_irq failure. irq = %d\n",
+                      pdev->irq);
+               return err;
+       }
+
+       mutex_lock(&dev->device_lock);
+       dev->mei_state = MEI_POWER_UP;
+       mei_reset(dev, 1);
+       mutex_unlock(&dev->device_lock);
+
+       /* Start watchdog if stopped in suspend */
+       if (dev->wd_timeout) {
+               mei_wd_start_setup(dev);
+               dev->wd_due_counter = 1;
+               schedule_delayed_work(&dev->wd_work, HZ);
+       }
+       return err;
+}
+static SIMPLE_DEV_PM_OPS(mei_pm_ops, mei_pci_suspend, mei_pci_resume);
+#define MEI_PM_OPS     (&mei_pm_ops)
+#else
+#define MEI_PM_OPS     NULL
+#endif /* CONFIG_PM */
+/*
+ *  PCI driver structure
+ */
+static struct pci_driver mei_driver = {
+       .name = mei_driver_name,
+       .id_table = mei_pci_tbl,
+       .probe = mei_probe,
+       .remove = __devexit_p(mei_remove),
+       .shutdown = __devexit_p(mei_remove),
+       .driver.pm = MEI_PM_OPS,
+};
+
+/*
+ * file operations structure will be used for mei char device.
+ */
+static const struct file_operations mei_fops = {
+       .owner = THIS_MODULE,
+       .read = mei_read,
+       .unlocked_ioctl = mei_ioctl,
+#ifdef CONFIG_COMPAT
+       .compat_ioctl = mei_compat_ioctl,
+#endif
+       .open = mei_open,
+       .release = mei_release,
+       .write = mei_write,
+       .poll = mei_poll,
+};
+
+/**
+ * mei_registration_cdev - sets up the cdev structure for mei device.
+ *
+ * @dev: char device struct
+ * @hminor: minor number for registration char device
+ * @fops: file operations structure
+ *
+ * returns 0 on success, <0 on failure.
+ */
+static int mei_registration_cdev(struct cdev *dev, int hminor,
+                                 const struct file_operations *fops)
+{
+       int ret, devno = MKDEV(mei_major, hminor);
+
+       cdev_init(dev, fops);
+       dev->owner = THIS_MODULE;
+       ret = cdev_add(dev, devno, 1);
+       /* Fail gracefully if need be */
+       if (ret)
+               printk(KERN_ERR "mei: Error %d registering mei device %d\n",
+                      ret, hminor);
+       return ret;
+}
+
+/**
+ * mei_register_cdev - registers mei char device
+ *
+ * returns 0 on success, <0 on failure.
+ */
+static int mei_register_cdev(void)
+{
+       int ret;
+       dev_t dev;
+
+       /* registration of char devices */
+       ret = alloc_chrdev_region(&dev, MEI_MINORS_BASE, MEI_MINORS_COUNT,
+                                 MEI_DRIVER_NAME);
+       if (ret) {
+               printk(KERN_ERR "mei: Error allocating char device region.\n");
+               return ret;
+       }
+
+       mei_major = MAJOR(dev);
+
+       ret = mei_registration_cdev(&mei_cdev, MEI_MINOR_NUMBER,
+                                    &mei_fops);
+       if (ret)
+               unregister_chrdev_region(MKDEV(mei_major, MEI_MINORS_BASE),
+                                        MEI_MINORS_COUNT);
+
+       return ret;
+}
+
+/**
+ * mei_unregister_cdev - unregisters mei char device
+ */
+static void mei_unregister_cdev(void)
+{
+       cdev_del(&mei_cdev);
+       unregister_chrdev_region(MKDEV(mei_major, MEI_MINORS_BASE),
+                                MEI_MINORS_COUNT);
+}
+
+/**
+ * mei_sysfs_device_create - adds device entry to sysfs
+ *
+ * returns 0 on success, <0 on failure.
+ */
+static int mei_sysfs_device_create(void)
+{
+       struct class *class;
+       void *tmphdev;
+       int err;
+
+       class = class_create(THIS_MODULE, MEI_DRIVER_NAME);
+       if (IS_ERR(class)) {
+               err = PTR_ERR(class);
+               printk(KERN_ERR "mei: Error creating mei class.\n");
+               goto err_out;
+       }
+
+       tmphdev = device_create(class, NULL, mei_cdev.dev, NULL,
+                                       MEI_DEV_NAME);
+       if (IS_ERR(tmphdev)) {
+               err = PTR_ERR(tmphdev);
+               goto err_destroy;
+       }
+
+       mei_class = class;
+       return 0;
+
+err_destroy:
+       class_destroy(class);
+err_out:
+       return err;
+}
+
+/**
+ * mei_sysfs_device_remove - unregisters the device entry on sysfs
+ */
+static void mei_sysfs_device_remove(void)
+{
+       if (IS_ERR_OR_NULL(mei_class))
+               return;
+
+       device_destroy(mei_class, mei_cdev.dev);
+       class_destroy(mei_class);
+}
+
+/**
+ * mei_init_module - Driver Registration Routine
+ *
+ * mei_init_module is the first routine called when the driver is
+ * loaded. All it does is to register with the PCI subsystem.
+ *
+ * returns 0 on success, <0 on failure.
+ */
+static int __init mei_init_module(void)
+{
+       int ret;
+
+       pr_debug("mei: %s - version %s\n",
+               mei_driver_string, mei_driver_version);
+       /* init pci module */
+       ret = pci_register_driver(&mei_driver);
+       if (ret < 0) {
+               printk(KERN_ERR "mei: Error registering driver.\n");
+               goto end;
+       }
+
+       ret = mei_register_cdev();
+       if (ret)
+               goto unregister_pci;
+
+       ret = mei_sysfs_device_create();
+       if (ret)
+               goto unregister_cdev;
+
+       return ret;
+
+unregister_cdev:
+       mei_unregister_cdev();
+unregister_pci:
+       pci_unregister_driver(&mei_driver);
+end:
+       return ret;
+}
+
+module_init(mei_init_module);
+
+/**
+ * mei_exit_module - Driver Exit Cleanup Routine
+ *
+ * mei_exit_module is called just before the driver is removed
+ * from memory.
+ */
+static void __exit mei_exit_module(void)
+{
+       pci_unregister_driver(&mei_driver);
+       mei_sysfs_device_remove();
+       mei_unregister_cdev();
+
+       pr_debug("mei: Driver unloaded successfully.\n");
+}
+
+module_exit(mei_exit_module);
+
+
+MODULE_AUTHOR("Intel Corporation");
+MODULE_DESCRIPTION("Intel(R) Management Engine Interface");
+MODULE_LICENSE("GPL v2");
+MODULE_VERSION(MEI_DRIVER_VERSION);
diff --git a/drivers/staging/mei/mei.h b/drivers/staging/mei/mei.h
new file mode 100644 (file)
index 0000000..6da7c4f
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+
+  Intel Management Engine Interface (Intel MEI) Linux driver
+  Intel MEI Interface Header
+
+  This file is provided under a dual BSD/GPLv2 license.  When using or
+  redistributing this file, you may do so under either license.
+
+  GPL LICENSE SUMMARY
+
+  Copyright(c) 2003-2011 Intel Corporation. All rights reserved.
+
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of version 2 of the GNU General Public License as
+  published by the Free Software Foundation.
+
+  This program is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  General Public License for more details.
+
+  Contact Information:
+         Intel Corporation.
+         linux-mei@linux.intel.com
+         http://www.intel.com
+
+
+  BSD LICENSE
+
+  Copyright(c) 2003-2011 Intel Corporation. All rights reserved.
+  All rights reserved.
+
+  Redistribution and use in source and binary forms, with or without
+  modification, are permitted provided that the following conditions
+  are met:
+
+    * Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+    * Redistributions in binary form must reproduce the above copyright
+      notice, this list of conditions and the following disclaimer in
+      the documentation and/or other materials provided with the
+      distribution.
+    * Neither the name of Intel Corporation nor the names of its
+      contributors may be used to endorse or promote products derived
+      from this software without specific prior written permission.
+
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+*/
+
+
+#ifndef _LINUX_MEI_H
+#define _LINUX_MEI_H
+
+#include <linux/uuid.h>
+
+/*
+ * This IOCTL is used to associate the current file descriptor with a
+ * FW Client (given by UUID). This opens a communication channel
+ * between a host client and a FW client. From this point every read and write
+ * will communicate with the associated FW client.
+ * Only in close() (file_operation release()) the communication between
+ * the clients is disconnected
+ *
+ * The IOCTL argument is a struct with a union the contains
+ * the input parameter and the output parameter for this IOCTL.
+ *
+ * The input parameter is UUID of the FW Client.
+ * The output parameter is the properties of the FW client
+ * (FW protocol version and max message size).
+ *
+ */
+#define IOCTL_MEI_CONNECT_CLIENT \
+       _IOWR('H' , 0x01, struct mei_connect_client_data)
+
+/*
+ * Intel MEI client information struct
+ */
+struct mei_client {
+       __u32 max_msg_length;
+       __u8 protocol_version;
+       __u8 reserved[3];
+};
+
+/*
+ * IOCTL Connect Client Data structure
+ */
+struct mei_connect_client_data {
+       union {
+               uuid_le in_client_uuid;
+               struct mei_client out_client_properties;
+       };
+};
+
+#endif /* _LINUX_MEI_H  */
diff --git a/drivers/staging/mei/mei.txt b/drivers/staging/mei/mei.txt
new file mode 100644 (file)
index 0000000..17302ad
--- /dev/null
@@ -0,0 +1,189 @@
+Intel MEI
+=======================
+
+Introduction
+=======================
+
+The Intel Management Engine (Intel ME) is an isolated and
+protected computing resource (Coprocessor) residing inside
+Intel chipsets. The Intel ME provides support for computer/IT
+management features.
+The Feature set depends on the Intel chipset SKU.
+
+The Intel Management Engine Interface (Intel MEI, previously known
+as HECI) is the interface between the Host and Intel ME.
+This interface is exposed to the host as a PCI device.
+The Intel MEI Driver is in charge of the communication channel
+between a host application and the ME feature.
+
+Each Intel ME feature (Intel ME Client) is addressed by
+GUID/UUID and each feature defines its own protocol.
+The protocol is message-based with a header and payload up to
+512 bytes.
+
+[place holder to URL to protocol definitions]
+
+Prominent usage of the Interface is to communicate with
+Intel Active Management Technology (Intel AMT)
+implemented in firmware running on the Intel ME.
+
+Intel AMT provides the ability to manage a host remotely out-of-band (OOB)
+even when the host processor has crashed or is in a sleep state.
+
+Some examples of Intel AMT usage are:
+   - Monitoring hardware state and platform components
+   - Remote power off/on (useful for green computing or overnight IT maintenance)
+   - OS updates
+   - Storage of useful platform information such as software assets
+   - built-in hardware KVM
+   - selective network isolation of Ethernet and IP protocol flows based on
+     policies set by a remote management console
+   - IDE device redirection from remote management console
+
+Intel AMT (OOB) communication is based on SOAP (deprecated
+starting with Release 6.0) over HTTP/HTTPS or WS-Management protocol
+over HTTP and HTTPS that are received from a remote
+management console application.
+
+For more information about Intel AMT:
+http://software.intel.com/sites/manageability/AMT_Implementation_and_Reference_Guide/WordDocuments/aboutintelamt.htm
+
+
+MEI Driver
+=======================
+
+The driver exposes a character device called /dev/mei.
+
+An application maintains communication with an ME feature while
+/dev/mei is open. The binding to a specific features is performed
+by calling MEI_CONNECT_CLIENT_IOCTL, which passes the desired UUID.
+The number of instances of an ME feature that can be opened
+at the same time depends on the ME feature, but most of the
+features allow only a single instance.
+
+
+The Intel AMT Host Interface (AMTHI) feature requires multiple
+simultaneous user applications, therefore the MEI driver handles
+this internally by maintaining request queues for the applications.
+
+The driver is oblivious to data that are passed between
+
+Because some of the ME features can change the system
+configuration, the driver by default allows only privileged
+user to access it.
+
+A Code snippet for application communicating with AMTHI client:
+       struct mei_connect_client_data data;
+       fd = open(MEI_DEVICE);
+
+       data.d.in_client_uuid = AMTHI_UUID;
+
+       ioctl(fd, IOCTL_MEI_CONNECT_CLIENT, &data);
+
+       printf(“Ver=%d, MaxLen=%ld\n”,
+                       data.d.in_client_uuid.protocol_version,
+                       data.d.in_client_uuid.max_msg_length);
+
+       [...]
+
+       write(fd, amthi_req_data, amthi_req_data_len);
+
+       [...]
+
+       read(fd, &amthi_res_data, amthi_res_data_len);
+
+       [...]
+       close(fd);
+
+ME Applications:
+==============
+
+1) Intel Local Management Service (Intel LMS)
+       Applications running locally on the platform communicate with
+       Intel AMT Release 2.0 and later releases in the same way
+       that network applications do via SOAP over HTTP (deprecated
+       starting with Release 6.0) or with WS-Management over SOAP over
+       HTTP. which means that some Intel AMT feature can be access
+       from a local application using same Network interface as for
+       remote application.
+
+       When a local application sends a message addressed to the local
+       Intel AMT host name, the Local Manageability Service (LMS),
+       which listens for traffic directed to the host name, intercepts
+       the message and routes it to the Intel Management Engine Interface.
+       For more information:
+       http://software.intel.com/sites/manageability/AMT_Implementation_and_
+       Reference_Guide/WordDocuments/localaccess1.htm
+
+       The LMS opens a connection using the MEI driver to the LMS
+       FW feature using a defined UUID and then communicates with the
+       feature using a protocol
+       called Intel(R) AMT Port Forwarding Protocol (APF protocol).
+       The protocol is used to maintain multiple sessions with
+       Intel AMT from a single application.
+       See the protocol specification in
+       the Intel(R) AMT Implementation and Reference Guide
+       http://software.intel.com/sites/manageability/AMT_Implementation_and_Reference_Guide/HTMLDocuments/MPSDocuments/Intel%20AMT%20Port%20Forwarding%20Protocol%20Reference%20Manual.pdf
+
+  2) Intel AMT Remote configuration using a Local Agent:
+       A Local Agent enables IT personnel to configure Intel AMT out-of-the-box
+       without requiring installing additional data to enable setup.
+       The remote configuration process may involve an ISV-developed remote
+       configuration agent that runs on the host.
+       For more information:
+       http://software.intel.com/sites/manageability/AMT_Implementation_and_Reference_Guide/WordDocuments/remoteconfigurationwithalocalagent.htm
+
+       How the Local Agent Works (including Command structs):
+       http://software.intel.com/sites/manageability/AMT_Implementation_and_Reference_Guide/WordDocuments/howthelocalagentsampleworks.htm
+
+Intel AMT OS Health Watchdog:
+=============================
+The Intel AMT Watchdog is an OS Health (Hang/Crash) watchdog.
+Whenever the OS hangs or crashes, Intel AMT will send an event
+to whoever subscribed to this event. This mechanism means that
+IT knows when a platform crashes even when there is a hard failure
+on the host.
+The AMT Watchdog is composed of two parts:
+       1) FW Feature - that receives the heartbeats
+          and sends an event when the heartbeats stop.
+       2) MEI driver – connects to the watchdog (WD) feature,
+          configures the watchdog and sends the heartbeats.
+
+The MEI driver configures the Watchdog to expire by default
+every 120sec unless set by the user using module parameters.
+The Driver then sends heartbeats every 2sec.
+
+If WD feature does not exist (i.e. the connection failed),
+the MEI driver will disable the sending of heartbeats.
+
+Module Parameters
+=================
+watchdog_timeout - the user can use this module parameter
+to change the watchdog timeout setting.
+
+This value sets the Intel AMT watchdog timeout interval in seconds;
+the default value is 120sec.
+in order to disable the watchdog activites set the value to 0.
+Normal values should be between 120 and 65535
+
+Supported Chipsets:
+==================
+7 Series Chipset Family
+6 Series Chipset Family
+5 Series Chipset Family
+4 Series Chipset Family
+Mobile 4 Series Chipset Family
+ICH9
+82946GZ/GL
+82G35 Express
+82Q963/Q965
+82P965/G965
+Mobile PM965/GM965
+Mobile GME965/GLE960
+82Q35 Express
+82G33/G31/P35/P31 Express
+82Q33 Express
+82X38/X48 Express
+
+---
+linux-mei@linux.intel.com
diff --git a/drivers/staging/mei/mei_dev.h b/drivers/staging/mei/mei_dev.h
new file mode 100644 (file)
index 0000000..6f3ec06
--- /dev/null
@@ -0,0 +1,422 @@
+/*
+ *
+ * Intel Management Engine Interface (Intel MEI) Linux driver
+ * Copyright (c) 2003-2011, Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ */
+
+#ifndef _MEI_DEV_H_
+#define _MEI_DEV_H_
+
+#include <linux/types.h>
+#include "mei.h"
+#include "hw.h"
+
+/*
+ * MEI Char Driver Minors
+ */
+#define MEI_MINORS_BASE        1
+#define MEI_MINORS_COUNT       1
+#define MEI_MINOR_NUMBER       1
+
+/*
+ * watch dog definition
+ */
+#define MEI_WATCHDOG_DATA_SIZE         16
+#define MEI_START_WD_DATA_SIZE         20
+#define MEI_WD_PARAMS_SIZE             4
+#define MEI_WD_STATE_INDEPENDENCE_MSG_SENT       (1 << 0)
+
+/*
+ * AMTHI Client UUID
+ */
+extern const uuid_le mei_amthi_guid;
+
+/*
+ * Watchdog Client UUID
+ */
+extern const uuid_le mei_wd_guid;
+
+/*
+ * Watchdog independence state message
+ */
+extern const u8 mei_wd_state_independence_msg[3][4];
+
+/*
+ * Number of File descriptors/handles
+ * that can be opened to the driver.
+ *
+ * Limit to 253: 255 Total Clients
+ * minus internal client for AMTHI
+ * minus internal client for Watchdog
+ */
+#define  MEI_MAX_OPEN_HANDLE_COUNT     253
+
+/*
+ * Number of queue lists used by this driver
+ */
+#define MEI_IO_LISTS_NUMBER        7
+
+/*
+ * Number of Maximum MEI Clients
+ */
+#define MEI_CLIENTS_MAX 255
+
+/* File state */
+enum file_state {
+       MEI_FILE_INITIALIZING = 0,
+       MEI_FILE_CONNECTING,
+       MEI_FILE_CONNECTED,
+       MEI_FILE_DISCONNECTING,
+       MEI_FILE_DISCONNECTED
+};
+
+/* MEI device states */
+enum mei_states {
+       MEI_INITIALIZING = 0,
+       MEI_INIT_CLIENTS,
+       MEI_ENABLED,
+       MEI_RESETING,
+       MEI_DISABLED,
+       MEI_RECOVERING_FROM_RESET,
+       MEI_POWER_DOWN,
+       MEI_POWER_UP
+};
+
+/* init clients  states*/
+enum mei_init_clients_states {
+       MEI_START_MESSAGE = 0,
+       MEI_ENUM_CLIENTS_MESSAGE,
+       MEI_CLIENT_PROPERTIES_MESSAGE
+};
+
+enum iamthif_states {
+       MEI_IAMTHIF_IDLE,
+       MEI_IAMTHIF_WRITING,
+       MEI_IAMTHIF_FLOW_CONTROL,
+       MEI_IAMTHIF_READING,
+       MEI_IAMTHIF_READ_COMPLETE
+};
+
+enum mei_file_transaction_states {
+       MEI_IDLE,
+       MEI_WRITING,
+       MEI_WRITE_COMPLETE,
+       MEI_FLOW_CONTROL,
+       MEI_READING,
+       MEI_READ_COMPLETE
+};
+
+/* MEI CB */
+enum mei_cb_major_types {
+       MEI_READ = 0,
+       MEI_WRITE,
+       MEI_IOCTL,
+       MEI_OPEN,
+       MEI_CLOSE
+};
+
+/*
+ * Intel MEI message data struct
+ */
+struct mei_message_data {
+       u32 size;
+       char *data;
+} __packed;
+
+
+struct mei_cl_cb {
+       struct list_head cb_list;
+       enum mei_cb_major_types major_file_operations;
+       void *file_private;
+       struct mei_message_data request_buffer;
+       struct mei_message_data response_buffer;
+       unsigned long information;
+       unsigned long read_time;
+       struct file *file_object;
+};
+
+/* MEI client instance carried as file->pirvate_data*/
+struct mei_cl {
+       struct list_head link;
+       struct mei_device *dev;
+       enum file_state state;
+       wait_queue_head_t tx_wait;
+       wait_queue_head_t rx_wait;
+       wait_queue_head_t wait;
+       int read_pending;
+       int status;
+       /* ID of client connected */
+       u8 host_client_id;
+       u8 me_client_id;
+       u8 mei_flow_ctrl_creds;
+       u8 timer_count;
+       enum mei_file_transaction_states reading_state;
+       enum mei_file_transaction_states writing_state;
+       int sm_state;
+       struct mei_cl_cb *read_cb;
+};
+
+struct mei_io_list {
+       struct mei_cl_cb mei_cb;
+       int status;
+       struct mei_device *device_extension;
+};
+
+/* MEI private device struct */
+struct mei_device {
+       struct pci_dev *pdev;   /* pointer to pci device struct */
+       /*
+        * lists of queues
+        */
+        /* array of pointers to aio lists */
+       struct mei_io_list *io_list_array[MEI_IO_LISTS_NUMBER];
+       struct mei_io_list read_list;           /* driver read queue */
+       struct mei_io_list write_list;          /* driver write queue */
+       struct mei_io_list write_waiting_list;  /* write waiting queue */
+       struct mei_io_list ctrl_wr_list;        /* managed write IOCTL list */
+       struct mei_io_list ctrl_rd_list;        /* managed read IOCTL list */
+       struct mei_io_list amthi_cmd_list;      /* amthi list for cmd waiting */
+
+       /* driver managed amthi list for reading completed amthi cmd data */
+       struct mei_io_list amthi_read_complete_list;
+       /*
+        * list of files
+        */
+       struct list_head file_list;
+       /*
+        * memory of device
+        */
+       unsigned int mem_base;
+       unsigned int mem_length;
+       void __iomem *mem_addr;
+       /*
+        * lock for the device
+        */
+       struct mutex device_lock; /* device lock */
+       int recvd_msg;
+       struct delayed_work wd_work;    /* watch dog deleye work */
+       /*
+        * hw states of host and fw(ME)
+        */
+       u32 host_hw_state;
+       u32 me_hw_state;
+       /*
+        * waiting queue for receive message from FW
+        */
+       wait_queue_head_t wait_recvd_msg;
+       wait_queue_head_t wait_stop_wd;
+
+       /*
+        * mei device  states
+        */
+       enum mei_states mei_state;
+       enum mei_init_clients_states init_clients_state;
+       u16 init_clients_timer;
+       int stop;
+
+       u32 extra_write_index;
+       u32 rd_msg_buf[128];    /* used for control messages */
+       u32 wr_msg_buf[128];    /* used for control messages */
+       u32 ext_msg_buf[8];     /* for control responses */
+       u32 rd_msg_hdr;
+
+       struct hbm_version version;
+
+       int mei_host_buffer_is_empty;
+       struct mei_cl wd_cl;
+       struct mei_me_client *me_clients; /* Note: memory has to be allocated */
+       DECLARE_BITMAP(me_clients_map, MEI_CLIENTS_MAX);
+       DECLARE_BITMAP(host_clients_map, MEI_CLIENTS_MAX);
+       u8 num_mei_me_clients;
+       u8 me_client_presentation_num;
+       u8 me_client_index;
+
+       int wd_pending;
+       int wd_stopped;
+       u16 wd_timeout; /* seconds ((wd_data[1] << 8) + wd_data[0]) */
+       unsigned char wd_data[MEI_START_WD_DATA_SIZE];
+
+
+       u16 wd_due_counter;
+       bool wd_bypass; /* if false, don't refresh watchdog ME client */
+
+       struct file *iamthif_file_object;
+       struct mei_cl iamthif_cl;
+       int iamthif_ioctl;
+       int iamthif_canceled;
+       int iamthif_mtu;
+       unsigned long iamthif_timer;
+       u32 iamthif_stall_timer;
+       unsigned char *iamthif_msg_buf; /* Note: memory has to be allocated */
+       u32 iamthif_msg_buf_size;
+       u32 iamthif_msg_buf_index;
+       int iamthif_flow_control_pending;
+       enum iamthif_states iamthif_state;
+       struct mei_cl_cb *iamthif_current_cb;
+       u8 write_hang;
+       int need_reset;
+       long open_handle_count;
+
+};
+
+
+/*
+ * mei init function prototypes
+ */
+struct mei_device *init_mei_device(struct pci_dev *pdev);
+void mei_reset(struct mei_device *dev, int interrupts);
+int mei_hw_init(struct mei_device *dev);
+int mei_task_initialize_clients(void *data);
+int mei_initialize_clients(struct mei_device *dev);
+struct mei_cl *mei_alloc_file_private(struct mei_device *dev);
+int mei_disconnect_host_client(struct mei_device *dev, struct mei_cl *cl);
+void mei_initialize_list(struct mei_io_list *list,
+                         struct mei_device *dev);
+void mei_flush_list(struct mei_io_list *list, struct mei_cl *cl);
+void mei_flush_queues(struct mei_device *dev, struct mei_cl *cl);
+void mei_remove_client_from_file_list(struct mei_device *dev,
+                                      u8 host_client_id);
+void host_init_iamthif(struct mei_device *dev);
+void mei_init_file_private(struct mei_cl *priv, struct mei_device *dev);
+void allocate_me_clients_storage(struct mei_device *dev);
+
+void host_start_message(struct mei_device *dev);
+void host_enum_clients_message(struct mei_device *dev);
+void host_client_properties(struct mei_device *dev);
+
+u8 mei_find_me_client_update_filext(struct mei_device *dev,
+                               struct mei_cl *priv,
+                               const uuid_le *cguid, u8 client_id);
+
+/*
+ *  interrupt functions prototype
+ */
+irqreturn_t mei_interrupt_quick_handler(int irq, void *dev_id);
+irqreturn_t  mei_interrupt_thread_handler(int irq, void *dev_id);
+void mei_wd_timer(struct work_struct *work);
+
+/*
+ *  input output function prototype
+ */
+int mei_ioctl_connect_client(struct file *file,
+                       struct mei_connect_client_data *data);
+
+int mei_start_read(struct mei_device *dev, struct mei_cl *cl);
+
+int amthi_write(struct mei_device *dev, struct mei_cl_cb *priv_cb);
+
+int amthi_read(struct mei_device *dev, struct file *file,
+             char __user *ubuf, size_t length, loff_t *offset);
+
+struct mei_cl_cb *find_amthi_read_list_entry(struct mei_device *dev,
+                                               struct file *file);
+
+void run_next_iamthif_cmd(struct mei_device *dev);
+
+void mei_free_cb_private(struct mei_cl_cb *priv_cb);
+
+int mei_find_me_client_index(const struct mei_device *dev, uuid_le cuuid);
+
+/*
+ * Register Access Function
+ */
+
+/**
+ * mei_reg_read - Reads 32bit data from the mei device
+ *
+ * @dev: the device structure
+ * @offset: offset from which to read the data
+ *
+ * returns the byte read.
+ */
+static inline u32 mei_reg_read(struct mei_device *dev,
+                               unsigned long offset)
+{
+       return ioread32(dev->mem_addr + offset);
+}
+
+/**
+ * mei_reg_write - Writes 32bit data to the mei device
+ *
+ * @dev: the device structure
+ * @offset: offset from which to write the data
+ * @value: the byte to write
+ */
+static inline void mei_reg_write(struct mei_device *dev,
+                               unsigned long offset, u32 value)
+{
+       iowrite32(value, dev->mem_addr + offset);
+}
+
+/**
+ * mei_hcsr_read - Reads 32bit data from the host CSR
+ *
+ * @dev: the device structure
+ *
+ * returns the byte read.
+ */
+static inline u32 mei_hcsr_read(struct mei_device *dev)
+{
+       return mei_reg_read(dev, H_CSR);
+}
+
+/**
+ * mei_mecsr_read - Reads 32bit data from the ME CSR
+ *
+ * @dev: the device structure
+ *
+ * returns ME_CSR_HA register value (u32)
+ */
+static inline u32 mei_mecsr_read(struct mei_device *dev)
+{
+       return mei_reg_read(dev, ME_CSR_HA);
+}
+
+/**
+ * get_me_cb_rw - Reads 32bit data from the mei ME_CB_RW register
+ *
+ * @dev: the device structure
+ *
+ * returns ME_CB_RW register value (u32)
+ */
+static inline u32 mei_mecbrw_read(struct mei_device *dev)
+{
+       return mei_reg_read(dev, ME_CB_RW);
+}
+
+
+/*
+ * mei interface function prototypes
+ */
+void mei_hcsr_set(struct mei_device *dev);
+void mei_csr_clear_his(struct mei_device *dev);
+
+void mei_enable_interrupts(struct mei_device *dev);
+void mei_disable_interrupts(struct mei_device *dev);
+
+/**
+ * mei_fe_same_id - tells if file private data have same id
+ *
+ * @fe1: private data of 1. file object
+ * @fe2: private data of 2. file object
+ *
+ * returns !=0 - if ids are the same, 0 - if differ.
+ */
+static inline int mei_fe_same_id(const struct mei_cl *fe1,
+                                 const struct mei_cl *fe2)
+{
+       return ((fe1->host_client_id == fe2->host_client_id) &&
+               (fe1->me_client_id == fe2->me_client_id));
+}
+
+#endif
diff --git a/drivers/staging/mei/mei_version.h b/drivers/staging/mei/mei_version.h
new file mode 100644 (file)
index 0000000..075bad8
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ *
+ * Intel Management Engine Interface (Intel MEI) Linux driver
+ * Copyright (c) 2003-2011, Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ */
+
+
+#ifndef MEI_VERSION_H
+#define MEI_VERSION_H
+
+#define MAJOR_VERSION          7
+#define MINOR_VERSION          1
+#define QUICK_FIX_NUMBER       20
+#define VER_BUILD              1
+
+#define MEI_DRV_VER1 __stringify(MAJOR_VERSION) "." __stringify(MINOR_VERSION)
+#define MEI_DRV_VER2 __stringify(QUICK_FIX_NUMBER) "." __stringify(VER_BUILD)
+
+#define MEI_DRIVER_VERSION     MEI_DRV_VER1 "." MEI_DRV_VER2
+
+#endif
diff --git a/drivers/staging/mei/wd.c b/drivers/staging/mei/wd.c
new file mode 100644 (file)
index 0000000..2564b03
--- /dev/null
@@ -0,0 +1,183 @@
+/*
+ *
+ * Intel Management Engine Interface (Intel MEI) Linux driver
+ * Copyright (c) 2003-2011, Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ */
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/device.h>
+#include <linux/pci.h>
+#include <linux/sched.h>
+
+#include "mei_dev.h"
+#include "hw.h"
+#include "interface.h"
+#include "mei.h"
+
+/*
+ * MEI Watchdog Module Parameters
+ */
+static u16 watchdog_timeout = AMT_WD_VALUE;
+module_param(watchdog_timeout, ushort, 0);
+MODULE_PARM_DESC(watchdog_timeout,
+               "Intel(R) AMT Watchdog timeout value in seconds. (default="
+                                       __MODULE_STRING(AMT_WD_VALUE)
+                                       ", disable=0)");
+
+static const u8 mei_start_wd_params[] = { 0x02, 0x12, 0x13, 0x10 };
+static const u8 mei_stop_wd_params[] = { 0x02, 0x02, 0x14, 0x10 };
+
+const u8 mei_wd_state_independence_msg[3][4] = {
+       {0x05, 0x02, 0x51, 0x10},
+       {0x05, 0x02, 0x52, 0x10},
+       {0x07, 0x02, 0x01, 0x10}
+};
+
+/* UUIDs for AMT F/W clients */
+const uuid_le mei_wd_guid = UUID_LE(0x05B79A6F, 0x4628, 0x4D7F, 0x89,
+                                               0x9D, 0xA9, 0x15, 0x14, 0xCB,
+                                               0x32, 0xAB);
+
+
+void mei_wd_start_setup(struct mei_device *dev)
+{
+       dev_dbg(&dev->pdev->dev, "dev->wd_timeout=%d.\n", dev->wd_timeout);
+       memcpy(dev->wd_data, mei_start_wd_params, MEI_WD_PARAMS_SIZE);
+       memcpy(dev->wd_data + MEI_WD_PARAMS_SIZE,
+               &dev->wd_timeout, sizeof(u16));
+}
+
+/**
+ * host_init_wd - mei initialization wd.
+ *
+ * @dev: the device structure
+ */
+void mei_wd_host_init(struct mei_device *dev)
+{
+       mei_init_file_private(&dev->wd_cl, dev);
+
+       /* look for WD client and connect to it */
+       dev->wd_cl.state = MEI_FILE_DISCONNECTED;
+       dev->wd_timeout = watchdog_timeout;
+
+       if (dev->wd_timeout > 0) {
+               mei_wd_start_setup(dev);
+               /* find ME WD client */
+               mei_find_me_client_update_filext(dev, &dev->wd_cl,
+                                       &mei_wd_guid, MEI_WD_HOST_CLIENT_ID);
+
+               dev_dbg(&dev->pdev->dev, "check wd_cl\n");
+               if (MEI_FILE_CONNECTING == dev->wd_cl.state) {
+                       if (!mei_connect(dev, &dev->wd_cl)) {
+                               dev_dbg(&dev->pdev->dev, "Failed to connect to WD client\n");
+                               dev->wd_cl.state = MEI_FILE_DISCONNECTED;
+                               dev->wd_cl.host_client_id = 0;
+                               host_init_iamthif(dev) ;
+                       } else {
+                               dev->wd_cl.timer_count = CONNECT_TIMEOUT;
+                       }
+               } else {
+                       dev_dbg(&dev->pdev->dev, "Failed to find WD client\n");
+                       host_init_iamthif(dev) ;
+               }
+       } else {
+               dev->wd_bypass = true;
+               dev_dbg(&dev->pdev->dev, "WD requested to be disabled\n");
+               host_init_iamthif(dev) ;
+       }
+}
+
+/**
+ * mei_wd_send - sends watch dog message to fw.
+ *
+ * @dev: the device structure
+ *
+ * returns 0 if success,
+ *     -EIO when message send fails
+ *     -EINVAL when invalid message is to be sent
+ */
+int mei_wd_send(struct mei_device *dev)
+{
+       struct mei_msg_hdr *mei_hdr;
+
+       mei_hdr = (struct mei_msg_hdr *) &dev->wr_msg_buf[0];
+       mei_hdr->host_addr = dev->wd_cl.host_client_id;
+       mei_hdr->me_addr = dev->wd_cl.me_client_id;
+       mei_hdr->msg_complete = 1;
+       mei_hdr->reserved = 0;
+
+       if (!memcmp(dev->wd_data, mei_start_wd_params, MEI_WD_PARAMS_SIZE))
+               mei_hdr->length = MEI_START_WD_DATA_SIZE;
+       else if (!memcmp(dev->wd_data, mei_stop_wd_params, MEI_WD_PARAMS_SIZE))
+               mei_hdr->length = MEI_WD_PARAMS_SIZE;
+       else
+               return -EINVAL;
+
+       if (mei_write_message(dev, mei_hdr, dev->wd_data, mei_hdr->length))
+               return 0;
+       return -EIO;
+}
+
+int mei_wd_stop(struct mei_device *dev, bool preserve)
+{
+       int ret;
+       u16 wd_timeout = dev->wd_timeout;
+
+       cancel_delayed_work(&dev->wd_work);
+       if (dev->wd_cl.state != MEI_FILE_CONNECTED || !dev->wd_timeout)
+               return 0;
+
+       dev->wd_timeout = 0;
+       dev->wd_due_counter = 0;
+       memcpy(dev->wd_data, mei_stop_wd_params, MEI_WD_PARAMS_SIZE);
+       dev->stop = 1;
+
+       ret = mei_flow_ctrl_creds(dev, &dev->wd_cl);
+       if (ret < 0)
+               goto out;
+
+       if (ret && dev->mei_host_buffer_is_empty) {
+               ret = 0;
+               dev->mei_host_buffer_is_empty = 0;
+
+               if (!mei_wd_send(dev)) {
+                       ret = mei_flow_ctrl_reduce(dev, &dev->wd_cl);
+                       if (ret)
+                               goto out;
+               } else {
+                       dev_dbg(&dev->pdev->dev, "send stop WD failed\n");
+               }
+
+               dev->wd_pending = 0;
+       } else {
+               dev->wd_pending = 1;
+       }
+       dev->wd_stopped = 0;
+       mutex_unlock(&dev->device_lock);
+
+       ret = wait_event_interruptible_timeout(dev->wait_stop_wd,
+                                       dev->wd_stopped, 10 * HZ);
+       mutex_lock(&dev->device_lock);
+       if (!dev->wd_stopped)
+               dev_dbg(&dev->pdev->dev, "stop wd failed to complete.\n");
+       else
+               dev_dbg(&dev->pdev->dev, "stop wd complete.\n");
+
+       if (preserve)
+               dev->wd_timeout = wd_timeout;
+
+out:
+       return ret;
+}
+
diff --git a/drivers/staging/nvec/Kconfig b/drivers/staging/nvec/Kconfig
new file mode 100644 (file)
index 0000000..987ad48
--- /dev/null
@@ -0,0 +1,27 @@
+config MFD_NVEC
+       bool "NV Tegra Embedded Controller SMBus Interface"
+       depends on I2C && GPIOLIB && ARCH_TEGRA
+       help
+           Say Y here to enable support for a nVidia compliant embedded
+           controller.
+
+config KEYBOARD_NVEC
+       bool "Keyboard on nVidia compliant EC"
+       depends on MFD_NVEC
+       help
+         Say Y here to enable support for a keyboard connected to 
+         a nVidia compliant embedded controller.
+
+config SERIO_NVEC_PS2
+       bool "PS2 on nVidia EC"
+       depends on MFD_NVEC
+       help
+         Say Y here to enable support for a Touchpad / Mouse connected
+         to a nVidia compliant embedded controller.
+
+config NVEC_POWER
+       bool "NVEC charger and battery"
+       depends on MFD_NVEC
+       help
+         Say Y to enable support for battery and charger interface for
+         nVidia compliant embedded controllers.
diff --git a/drivers/staging/nvec/Makefile b/drivers/staging/nvec/Makefile
new file mode 100644 (file)
index 0000000..4b5fcec
--- /dev/null
@@ -0,0 +1,4 @@
+obj-$(CONFIG_SERIO_NVEC_PS2)   += nvec_ps2.o
+obj-$(CONFIG_MFD_NVEC)         += nvec.o
+obj-$(CONFIG_NVEC_POWER)       += nvec_power.o
+obj-$(CONFIG_KEYBOARD_NVEC)    += nvec_kbd.o
diff --git a/drivers/staging/nvec/README b/drivers/staging/nvec/README
new file mode 100644 (file)
index 0000000..9a320b7
--- /dev/null
@@ -0,0 +1,14 @@
+NVEC: An NVidia compliant Embedded Controller Protocol Implemenation
+
+This is an implementation of the NVEC protocol used to communicate with an
+embedded controller (EC) via I2C bus. The EC is an I2C master while the host
+processor is the I2C slave. Requests from the host processor to the EC are
+started by triggering a gpio line.
+
+There is no written documentation of the protocol available to the public,
+but the source code[1] of the published nvec reference drivers can be a guide.
+This driver is currently only used by the AC100 project[2], but it is likely,
+that other Tegra boards (not yet mainlined, if ever) also use it.
+
+[1] e.g. http://nv-tegra.nvidia.com/gitweb/?p=linux-2.6.git;a=tree;f=arch/arm/mach-tegra/nvec;hb=android-tegra-2.6.32
+[2] http://gitorious.org/ac100, http://launchpad.net/ac100
diff --git a/drivers/staging/nvec/TODO b/drivers/staging/nvec/TODO
new file mode 100644 (file)
index 0000000..77b47f7
--- /dev/null
@@ -0,0 +1,8 @@
+ToDo list (incomplete, unordered)
+       - convert mouse, keyboard, and power to platform devices
+       - add copyright / driver author / license
+       - add compile as module support
+       - move nvec devices to mfd cells?
+       - adjust to kernel style
+
+
diff --git a/drivers/staging/nvec/nvec-keytable.h b/drivers/staging/nvec/nvec-keytable.h
new file mode 100644 (file)
index 0000000..6a1c4f7
--- /dev/null
@@ -0,0 +1,266 @@
+/*
+ * drivers/input/keyboard/tegra-nvec.c
+ *
+ * Keyboard class input driver for keyboards connected to an NvEc compliant
+ * embedded controller
+ *
+ * Copyright (c) 2009, NVIDIA Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+static unsigned short code_tab_102us[] = {
+       KEY_GRAVE,      // 0x00
+       KEY_ESC,
+       KEY_1,
+       KEY_2,
+       KEY_3,
+       KEY_4,
+       KEY_5,
+       KEY_6,
+       KEY_7,
+       KEY_8,
+       KEY_9,
+       KEY_0,
+       KEY_MINUS,
+       KEY_EQUAL,
+       KEY_BACKSPACE,
+       KEY_TAB,
+       KEY_Q,          // 0x10
+       KEY_W,
+       KEY_E,
+       KEY_R,
+       KEY_T,
+       KEY_Y,
+       KEY_U,
+       KEY_I,
+       KEY_O,
+       KEY_P,
+       KEY_LEFTBRACE,
+       KEY_RIGHTBRACE,
+       KEY_ENTER,
+       KEY_LEFTCTRL,
+       KEY_A,
+       KEY_S,
+       KEY_D,          // 0x20
+       KEY_F,
+       KEY_G,
+       KEY_H,
+       KEY_J,
+       KEY_K,
+       KEY_L,
+       KEY_SEMICOLON,
+       KEY_APOSTROPHE,
+       KEY_GRAVE,
+       KEY_LEFTSHIFT,
+       KEY_BACKSLASH,
+       KEY_Z,
+       KEY_X,
+       KEY_C,
+       KEY_V,
+       KEY_B,          // 0x30
+       KEY_N,
+       KEY_M,
+       KEY_COMMA,
+       KEY_DOT,
+       KEY_SLASH,
+       KEY_RIGHTSHIFT,
+       KEY_KPASTERISK,
+       KEY_LEFTALT,
+       KEY_SPACE,
+       KEY_CAPSLOCK,
+       KEY_F1,
+       KEY_F2,
+       KEY_F3,
+       KEY_F4,
+       KEY_F5,
+       KEY_F6,         // 0x40
+       KEY_F7,
+       KEY_F8,
+       KEY_F9,
+       KEY_F10,
+       KEY_FN,
+       0,              //VK_SCROLL
+       KEY_KP7,
+       KEY_KP8,
+       KEY_KP9,
+       KEY_KPMINUS,
+       KEY_KP4,
+       KEY_KP5,
+       KEY_KP6,
+       KEY_KPPLUS,
+       KEY_KP1,
+       KEY_KP2,        // 0x50
+       KEY_KP3,
+       KEY_KP0,
+       KEY_KPDOT,
+       KEY_MENU,               //VK_SNAPSHOT
+       KEY_POWER,
+       KEY_102ND,              //VK_OEM_102   henry+ 0x2B (43) BACKSLASH have been used,change to use 0X56 (86)
+       KEY_F11,                //VK_F11
+       KEY_F12,                //VK_F12
+       0, 
+       0, 
+       0, 
+       0, 
+       0, 
+       0, 
+       0, 
+       0, // 60 
+       0,
+       0,
+       KEY_SEARCH, // add search key map 
+       0,              
+       0,
+       0,
+       0,      
+       0,              
+       0, 
+       0, 
+       0, 
+       0, 
+       0, 
+       0, 
+       0, 
+       0, // 70 
+       0,
+       0,
+       KEY_KP5,  //73 for JP keyboard '\' key, report 0x4c
+       0,              
+       0,
+       0,
+       0,      
+       0,              
+       0, 
+       0, 
+    0, 
+       0, 
+       KEY_KP9, //7d  for JP keyboard '|' key, report 0x49
+};
+
+static unsigned short extcode_tab_us102[] = {
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,              // 0xE0 0x10
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,              //VK_MEDIA_NEXT_TRACK,
+       0,
+       0,
+       0,              //VK_RETURN,
+       KEY_RIGHTCTRL,          //VK_RCONTROL,
+       0,
+       0,
+       KEY_MUTE,       // 0xE0 0x20
+       0,              //VK_LAUNCH_APP1
+       0,              //VK_MEDIA_PLAY_PAUSE
+       0,
+       0,              //VK_MEDIA_STOP
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       KEY_VOLUMEUP,   // 0xE0 0x30
+       0,
+       0,              //VK_BROWSER_HOME
+       0,
+       0,
+       KEY_KPSLASH,    //VK_DIVIDE
+       0,
+       KEY_SYSRQ,              //VK_SNAPSHOT
+       KEY_RIGHTALT,           //VK_RMENU
+       0,              //VK_OEM_NV_BACKLIGHT_UP
+       0,              //VK_OEM_NV_BACKLIGHT_DN
+       0,              //VK_OEM_NV_BACKLIGHT_AUTOTOGGLE
+       0,              //VK_OEM_NV_POWER_INFO
+       0,              //VK_OEM_NV_WIFI_TOGGLE
+       0,              //VK_OEM_NV_DISPLAY_SELECT
+       0,              //VK_OEM_NV_AIRPLANE_TOGGLE
+       0,              //0xE0 0x40
+       KEY_LEFT,               //VK_OEM_NV_RESERVED    henry+ for JP keyboard
+       0,              //VK_OEM_NV_RESERVED
+       0,              //VK_OEM_NV_RESERVED
+       0,              //VK_OEM_NV_RESERVED
+       0,              //VK_OEM_NV_RESERVED
+       KEY_CANCEL,
+       KEY_HOME,
+       KEY_UP,
+       KEY_PAGEUP,             //VK_PRIOR
+       0,
+       KEY_LEFT,
+       0,
+       KEY_RIGHT,
+       0,
+       KEY_END,
+       KEY_DOWN,       // 0xE0 0x50
+       KEY_PAGEDOWN,           //VK_NEXT
+       KEY_INSERT,
+       KEY_DELETE,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       KEY_LEFTMETA,   //VK_LWIN
+       0,              //VK_RWIN
+       KEY_ESC,        //VK_APPS
+       KEY_KPMINUS, //for power button workaround
+       0, 
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,              //VK_BROWSER_SEARCH
+       0,              //VK_BROWSER_FAVORITES
+       0,              //VK_BROWSER_REFRESH
+       0,              //VK_BROWSER_STOP
+       0,              //VK_BROWSER_FORWARD
+       0,              //VK_BROWSER_BACK
+       0,              //VK_LAUNCH_APP2
+       0,              //VK_LAUNCH_MAIL
+       0,              //VK_LAUNCH_MEDIA_SELECT
+};
+
+static unsigned short* code_tabs[] = {code_tab_102us, extcode_tab_us102 };
diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c
new file mode 100644 (file)
index 0000000..1a94364
--- /dev/null
@@ -0,0 +1,468 @@
+// #define DEBUG
+
+/* ToDo list (incomplete, unorderd)
+       - convert mouse, keyboard, and power to platform devices
+*/
+
+#include <asm/io.h>
+#include <asm/irq.h>
+#include <linux/completion.h>
+#include <linux/interrupt.h>
+#include <linux/irq.h>
+#include <linux/slab.h>
+#include <linux/gpio.h>
+#include <linux/serio.h>
+#include <linux/delay.h>
+#include <linux/input.h>
+#include <linux/workqueue.h>
+#include <linux/clk.h>
+#include <mach/iomap.h>
+#include <mach/clk.h>
+#include <linux/semaphore.h>
+#include <linux/list.h>
+#include <linux/notifier.h>
+#include <linux/workqueue.h>
+#include <linux/platform_device.h>
+#include "nvec.h"
+
+static unsigned char EC_DISABLE_EVENT_REPORTING[] =    {'\x04','\x00','\x00'};
+static unsigned char EC_ENABLE_EVENT_REPORTING[] =     {'\x04','\x00','\x01'};
+static unsigned char EC_GET_FIRMWARE_VERSION[] =       {'\x07','\x15'};
+
+static struct nvec_chip *nvec_power_handle;
+
+int nvec_register_notifier(struct nvec_chip *nvec, struct notifier_block *nb,
+                               unsigned int events)
+{
+       return atomic_notifier_chain_register(&nvec->notifier_list, nb);
+}
+EXPORT_SYMBOL_GPL(nvec_register_notifier);
+
+static int nvec_status_notifier(struct notifier_block *nb, unsigned long event_type,
+                               void *data)
+{
+       unsigned char *msg = (unsigned char *)data;
+       int i;
+
+       if(event_type != NVEC_CNTL)
+               return NOTIFY_DONE;
+
+       printk("unhandled msg type %ld, payload: ", event_type);
+       for (i = 0; i < msg[1]; i++)
+               printk("%0x ", msg[i+2]);
+       printk("\n");
+
+       return NOTIFY_OK;
+}
+
+void nvec_write_async(struct nvec_chip *nvec, unsigned char *data, short size)
+{
+       struct nvec_msg *msg = kzalloc(sizeof(struct nvec_msg), GFP_NOWAIT);
+
+       msg->data = kzalloc(size, GFP_NOWAIT);
+       msg->data[0] = size;
+       memcpy(msg->data + 1, data, size);
+       msg->size = size + 1;
+       msg->pos = 0;
+       INIT_LIST_HEAD(&msg->node);
+
+       list_add_tail(&msg->node, &nvec->tx_data);
+
+       gpio_set_value(nvec->gpio, 0);
+}
+EXPORT_SYMBOL(nvec_write_async);
+
+static void nvec_request_master(struct work_struct *work)
+{
+       struct nvec_chip *nvec = container_of(work, struct nvec_chip, tx_work);
+
+       if(!list_empty(&nvec->tx_data)) {
+               gpio_set_value(nvec->gpio, 0);
+       }
+}
+
+static int parse_msg(struct nvec_chip *nvec, struct nvec_msg *msg)
+{
+       int i;
+
+       if((msg->data[0] & 1<<7) == 0 && msg->data[3]) {
+               dev_err(nvec->dev, "ec responded %02x %02x %02x %02x\n", msg->data[0],
+                       msg->data[1], msg->data[2], msg->data[3]);
+               return -EINVAL;
+       }
+
+       if ((msg->data[0] >> 7 ) == 1 && (msg->data[0] & 0x0f) == 5)
+       {
+               dev_warn(nvec->dev, "ec system event ");
+               for (i=0; i < msg->data[1]; i++)
+                       dev_warn(nvec->dev, "%02x ", msg->data[2+i]);
+               dev_warn(nvec->dev, "\n");
+       }
+
+       atomic_notifier_call_chain(&nvec->notifier_list, msg->data[0] & 0x8f, msg->data);
+
+       return 0;
+}
+
+static struct nvec_msg *nvec_write_sync(struct nvec_chip *nvec, unsigned char *data, short size)
+{
+       down(&nvec->sync_write_mutex);
+
+       nvec->sync_write_pending = (data[1] << 8) + data[0];
+       nvec_write_async(nvec, data, size);
+
+       dev_dbg(nvec->dev, "nvec_sync_write: 0x%04x\n", nvec->sync_write_pending);
+       wait_for_completion(&nvec->sync_write);
+       dev_dbg(nvec->dev, "nvec_sync_write: pong!\n");
+
+       up(&nvec->sync_write_mutex);
+
+       return nvec->last_sync_msg;
+}
+
+/* RX worker */
+static void nvec_dispatch(struct work_struct *work)
+{
+       struct nvec_chip *nvec = container_of(work, struct nvec_chip, rx_work);
+       struct nvec_msg *msg;
+
+       while(!list_empty(&nvec->rx_data))
+       {
+               msg = list_first_entry(&nvec->rx_data, struct nvec_msg, node);
+               list_del_init(&msg->node);
+
+               if(nvec->sync_write_pending == (msg->data[2] << 8) + msg->data[0])
+               {
+                       dev_dbg(nvec->dev, "sync write completed!\n");
+                       nvec->sync_write_pending = 0;
+                       nvec->last_sync_msg = msg;
+                       complete(&nvec->sync_write);
+               } else {
+                       parse_msg(nvec, msg);
+                       if((!msg) || (!msg->data))
+                               dev_warn(nvec->dev, "attempt access zero pointer");
+                       else {
+                               kfree(msg->data);
+                               kfree(msg);
+                       }
+               }
+       }
+}
+
+static irqreturn_t i2c_interrupt(int irq, void *dev)
+{
+       unsigned long status;
+       unsigned long received;
+       unsigned char to_send;
+       struct nvec_msg *msg;
+       struct nvec_chip *nvec = (struct nvec_chip *)dev;
+       unsigned char *i2c_regs = nvec->i2c_regs;
+
+       status = readl(i2c_regs + I2C_SL_STATUS);
+
+       if(!(status & I2C_SL_IRQ))
+       {
+               dev_warn(nvec->dev, "nvec Spurious IRQ\n");
+               //Yup, handled. ahum.
+               goto handled;
+       }
+       if(status & END_TRANS && !(status & RCVD))
+       {
+               //Reenable IRQ only when even has been sent
+               //printk("Write sequence ended !\n");
+                //parse_msg(nvec);
+               nvec->state = NVEC_WAIT;
+               if(nvec->rx->size > 1)
+               {
+                       list_add_tail(&nvec->rx->node, &nvec->rx_data);
+                       schedule_work(&nvec->rx_work);
+               } else {
+                       kfree(nvec->rx->data);
+                       kfree(nvec->rx);
+               }
+               return IRQ_HANDLED;
+       } else if(status & RNW)
+       {
+               // Work around for AP20 New Slave Hw Bug. Give 1us extra.
+               // nvec/smbus/nvec_i2c_transport.c in NV`s crap for reference
+               if(status & RCVD)
+                       udelay(3);
+
+               if(status & RCVD)
+               {
+                       nvec->state = NVEC_WRITE;
+                       //Master wants something from us. New communication
+//                     dev_dbg(nvec->dev, "New read comm!\n");
+               } else {
+                       //Master wants something from us from a communication we've already started
+//                     dev_dbg(nvec->dev, "Read comm cont !\n");
+               }
+               //if(msg_pos<msg_size) {
+               if(list_empty(&nvec->tx_data))
+               {
+                       dev_err(nvec->dev, "nvec empty tx - sending no-op\n");
+                       to_send = 0x8a;
+                       nvec_write_async(nvec, "\x07\x02", 2);
+//                     to_send = 0x01;
+               } else {
+                       msg = list_first_entry(&nvec->tx_data, struct nvec_msg, node);
+                       if(msg->pos < msg->size) {
+                               to_send = msg->data[msg->pos];
+                               msg->pos++;
+                       } else {
+                               dev_err(nvec->dev, "nvec crap! %d\n", msg->size);
+                               to_send = 0x01;
+                       }
+
+                       if(msg->pos >= msg->size)
+                       {
+                               list_del_init(&msg->node);
+                               kfree(msg->data);
+                               kfree(msg);
+                               schedule_work(&nvec->tx_work);
+                               nvec->state = NVEC_WAIT;
+                       }
+               }
+               writel(to_send, i2c_regs + I2C_SL_RCVD);
+
+               gpio_set_value(nvec->gpio, 1);
+
+               dev_dbg(nvec->dev, "nvec sent %x\n", to_send);
+
+               goto handled;
+       } else {
+               received = readl(i2c_regs + I2C_SL_RCVD);
+               //Workaround?
+               if(status & RCVD) {
+                       writel(0, i2c_regs + I2C_SL_RCVD);
+                       goto handled;
+               }
+
+               if (nvec->state == NVEC_WAIT)
+               {
+                       nvec->state = NVEC_READ;
+                       msg = kzalloc(sizeof(struct nvec_msg), GFP_NOWAIT);
+                       msg->data = kzalloc(32, GFP_NOWAIT);
+                       INIT_LIST_HEAD(&msg->node);
+                       nvec->rx = msg;
+               } else
+                       msg = nvec->rx;
+
+               BUG_ON(msg->pos > 32);
+
+               msg->data[msg->pos] = received;
+               msg->pos++;
+               msg->size = msg->pos;
+               dev_dbg(nvec->dev, "Got %02lx from Master (pos: %d)!\n", received, msg->pos);
+       }
+handled:
+       return IRQ_HANDLED;
+}
+
+static int __devinit nvec_add_subdev(struct nvec_chip *nvec, struct nvec_subdev *subdev)
+{
+       struct platform_device *pdev;
+
+       pdev = platform_device_alloc(subdev->name, subdev->id);
+       pdev->dev.parent = nvec->dev;
+       pdev->dev.platform_data = subdev->platform_data;
+
+       return platform_device_add(pdev);
+}
+
+static void tegra_init_i2c_slave(struct nvec_platform_data *pdata, unsigned char *i2c_regs,
+                                       struct clk *i2c_clk)
+{
+       u32 val;
+
+       clk_enable(i2c_clk);
+       tegra_periph_reset_assert(i2c_clk);
+       udelay(2);
+       tegra_periph_reset_deassert(i2c_clk);
+
+       writel(pdata->i2c_addr>>1, i2c_regs + I2C_SL_ADDR1);
+       writel(0, i2c_regs + I2C_SL_ADDR2);
+
+       writel(0x1E, i2c_regs + I2C_SL_DELAY_COUNT);
+       val = I2C_CNFG_NEW_MASTER_SFM | I2C_CNFG_PACKET_MODE_EN |
+               (0x2 << I2C_CNFG_DEBOUNCE_CNT_SHIFT);
+       writel(val, i2c_regs + I2C_CNFG);
+       writel(I2C_SL_NEWL, i2c_regs + I2C_SL_CNFG);
+
+       clk_disable(i2c_clk);
+}
+
+static void nvec_power_off(void)
+{
+       nvec_write_async(nvec_power_handle, EC_DISABLE_EVENT_REPORTING, 3);
+       nvec_write_async(nvec_power_handle, "\x04\x01", 2);
+}
+
+static int __devinit tegra_nvec_probe(struct platform_device *pdev)
+{
+       int err, i, ret;
+       struct clk *i2c_clk;
+       struct nvec_platform_data *pdata = pdev->dev.platform_data;
+       struct nvec_chip *nvec;
+       struct nvec_msg *msg;
+       unsigned char *i2c_regs;
+
+       nvec = kzalloc(sizeof(struct nvec_chip), GFP_KERNEL);
+       if(nvec == NULL) {
+               dev_err(&pdev->dev, "failed to reserve memory\n");
+               return -ENOMEM;
+       }
+       platform_set_drvdata(pdev, nvec);
+       nvec->dev = &pdev->dev;
+       nvec->gpio = pdata->gpio;
+       nvec->irq = pdata->irq;
+
+/*
+       i2c_clk=clk_get_sys(NULL, "i2c");
+       if(IS_ERR_OR_NULL(i2c_clk))
+               printk(KERN_ERR"No such clock tegra-i2c.2\n");
+       else
+               clk_enable(i2c_clk);
+*/
+       i2c_regs = ioremap(pdata->base, pdata->size);
+       if(!i2c_regs) {
+               dev_err(nvec->dev, "failed to ioremap registers\n");
+               goto failed;
+       }
+
+       nvec->i2c_regs = i2c_regs;
+
+       i2c_clk = clk_get_sys(pdata->clock, NULL);
+       if(IS_ERR_OR_NULL(i2c_clk)) {
+               dev_err(nvec->dev, "failed to get clock tegra-i2c.2\n");
+               goto failed;
+       }
+
+       tegra_init_i2c_slave(pdata, i2c_regs, i2c_clk);
+
+       err = request_irq(nvec->irq, i2c_interrupt, IRQF_DISABLED, "nvec", nvec);
+       if(err) {
+               dev_err(nvec->dev, "couldn't request irq");
+               goto failed;
+       }
+
+       clk_enable(i2c_clk);
+       clk_set_rate(i2c_clk, 8*80000);
+
+       /* Set the gpio to low when we've got something to say */
+       err = gpio_request(nvec->gpio, "nvec gpio");
+       if(err < 0)
+               dev_err(nvec->dev, "couldn't request gpio\n");
+
+       tegra_gpio_enable(nvec->gpio);
+       gpio_direction_output(nvec->gpio, 1);
+       gpio_set_value(nvec->gpio, 1);
+
+       ATOMIC_INIT_NOTIFIER_HEAD(&nvec->notifier_list);
+
+       init_completion(&nvec->sync_write);
+       sema_init(&nvec->sync_write_mutex, 1);
+       INIT_LIST_HEAD(&nvec->tx_data);
+       INIT_LIST_HEAD(&nvec->rx_data);
+       INIT_WORK(&nvec->rx_work, nvec_dispatch);
+       INIT_WORK(&nvec->tx_work, nvec_request_master);
+
+       /* enable event reporting */
+       nvec_write_async(nvec, EC_ENABLE_EVENT_REPORTING,
+                               sizeof(EC_ENABLE_EVENT_REPORTING));
+
+       nvec_kbd_init(nvec);
+#ifdef CONFIG_SERIO_NVEC_PS2
+       nvec_ps2(nvec);
+#endif
+
+        /* setup subdevs */
+       for (i = 0; i < pdata->num_subdevs; i++) {
+               ret = nvec_add_subdev(nvec, &pdata->subdevs[i]);
+       }
+
+       nvec->nvec_status_notifier.notifier_call = nvec_status_notifier;
+       nvec_register_notifier(nvec, &nvec->nvec_status_notifier, 0);
+
+       nvec_power_handle = nvec;
+       pm_power_off = nvec_power_off;
+
+       /* Get Firmware Version */
+       msg = nvec_write_sync(nvec, EC_GET_FIRMWARE_VERSION,
+               sizeof(EC_GET_FIRMWARE_VERSION));
+
+       dev_warn(nvec->dev, "ec firmware version %02x.%02x.%02x / %02x\n",
+                       msg->data[4], msg->data[5], msg->data[6], msg->data[7]);
+
+       kfree(msg->data);
+       kfree(msg);
+
+       /* unmute speakers? */
+       nvec_write_async(nvec, "\x0d\x10\x59\x94", 4);
+
+       /* enable lid switch event */
+       nvec_write_async(nvec, "\x01\x01\x01\x00\x00\x02\x00", 7);
+
+       /* enable power button event */
+       nvec_write_async(nvec, "\x01\x01\x01\x00\x00\x80\x00", 7);
+
+       return 0;
+
+failed:
+       kfree(nvec);
+       return -ENOMEM;
+}
+
+static int __devexit tegra_nvec_remove(struct platform_device *pdev)
+{
+       // TODO: unregister
+       return 0;
+}
+
+#ifdef CONFIG_PM
+
+static int tegra_nvec_suspend(struct platform_device *pdev, pm_message_t state)
+{
+       struct nvec_chip *nvec = platform_get_drvdata(pdev);
+
+       dev_dbg(nvec->dev, "suspending\n");
+       nvec_write_async(nvec, EC_DISABLE_EVENT_REPORTING, 3);
+       nvec_write_async(nvec, "\x04\x02", 2);
+
+       return 0;
+}
+
+static int tegra_nvec_resume(struct platform_device *pdev) {
+
+       struct nvec_chip *nvec = platform_get_drvdata(pdev);
+
+       dev_dbg(nvec->dev, "resuming\n");
+       nvec_write_async(nvec, EC_ENABLE_EVENT_REPORTING, 3);
+
+       return 0;
+}
+
+#else
+#define tegra_nvec_suspend NULL
+#define tegra_nvec_resume NULL
+#endif
+
+static struct platform_driver nvec_device_driver =
+{
+       .probe = tegra_nvec_probe,
+       .remove = __devexit_p(tegra_nvec_remove),
+       .suspend = tegra_nvec_suspend,
+       .resume = tegra_nvec_resume,
+       .driver = {
+               .name = "nvec",
+               .owner = THIS_MODULE,
+       }
+};
+
+static int __init tegra_nvec_init(void)
+{
+       return platform_driver_register(&nvec_device_driver);
+}
+
+module_init(tegra_nvec_init);
+MODULE_ALIAS("platform:nvec");
diff --git a/drivers/staging/nvec/nvec.h b/drivers/staging/nvec/nvec.h
new file mode 100644 (file)
index 0000000..a2d82dc
--- /dev/null
@@ -0,0 +1,110 @@
+#ifndef __LINUX_MFD_NVEC
+#define __LINUX_MFD_NVEC
+
+#include <linux/semaphore.h>
+
+typedef enum {
+       NVEC_2BYTES,
+       NVEC_3BYTES,
+       NVEC_VAR_SIZE
+} nvec_size;
+
+typedef enum {
+       NOT_REALLY,
+       YES,
+       NOT_AT_ALL,
+} how_care;
+
+typedef enum {
+       NVEC_SYS=1,
+       NVEC_BAT,
+       NVEC_KBD = 5,
+       NVEC_PS2,
+       NVEC_CNTL,
+       NVEC_KB_EVT = 0x80,
+       NVEC_PS2_EVT
+} nvec_event;
+
+typedef enum {
+       NVEC_WAIT,
+       NVEC_READ,
+       NVEC_WRITE
+} nvec_state;
+
+struct nvec_msg {
+       unsigned char *data;
+       unsigned short size;
+       unsigned short pos;
+       struct list_head node;
+};
+
+struct nvec_subdev {
+       const char *name;
+       void *platform_data;
+       int id;
+};
+
+struct nvec_platform_data {
+       int num_subdevs;
+       int i2c_addr;
+       int gpio;
+       int irq;
+       int base;
+       int size;
+       char clock[16];
+       struct nvec_subdev *subdevs;
+};
+
+struct nvec_chip {
+       struct device *dev;
+       int gpio;
+       int irq;
+       unsigned char *i2c_regs;
+       nvec_state state;
+       struct atomic_notifier_head notifier_list;
+       struct list_head rx_data, tx_data;
+       struct notifier_block nvec_status_notifier;
+       struct work_struct rx_work, tx_work;
+       struct nvec_msg *rx, *tx;
+
+/* sync write stuff */
+       struct semaphore sync_write_mutex;
+       struct completion sync_write;
+       u16 sync_write_pending;
+       struct nvec_msg *last_sync_msg;
+};
+
+extern void nvec_write_async(struct nvec_chip *nvec, unsigned char *data, short size);
+
+extern int nvec_register_notifier(struct nvec_chip *nvec,
+                struct notifier_block *nb, unsigned int events);
+
+extern int nvec_unregister_notifier(struct device *dev,
+               struct notifier_block *nb, unsigned int events);
+
+const char *nvec_send_msg(unsigned char *src, unsigned char *dst_size, how_care care_resp, void (*rt_handler)(unsigned char *data));
+
+extern int nvec_ps2(struct nvec_chip *nvec);
+extern int nvec_kbd_init(struct nvec_chip *nvec);
+
+#define I2C_CNFG                       0x00
+#define I2C_CNFG_PACKET_MODE_EN                (1<<10)
+#define I2C_CNFG_NEW_MASTER_SFM                (1<<11)
+#define I2C_CNFG_DEBOUNCE_CNT_SHIFT    12
+
+#define I2C_SL_CNFG            0x20
+#define I2C_SL_NEWL            (1<<2)
+#define I2C_SL_NACK            (1<<1)
+#define I2C_SL_RESP            (1<<0)
+#define I2C_SL_IRQ             (1<<3)
+#define END_TRANS              (1<<4)
+#define RCVD                   (1<<2)
+#define RNW                    (1<<1)
+
+#define I2C_SL_RCVD            0x24
+#define I2C_SL_STATUS          0x28
+#define I2C_SL_ADDR1           0x2c
+#define I2C_SL_ADDR2           0x30
+#define I2C_SL_DELAY_COUNT     0x3c
+
+#endif
diff --git a/drivers/staging/nvec/nvec_kbd.c b/drivers/staging/nvec/nvec_kbd.c
new file mode 100644 (file)
index 0000000..9a98507
--- /dev/null
@@ -0,0 +1,122 @@
+#include <linux/slab.h>
+#include <linux/input.h>
+#include <linux/delay.h>
+#include "nvec-keytable.h"
+#include "nvec.h"
+
+#define ACK_KBD_EVENT {'\x05','\xed','\x01'}
+
+static unsigned char keycodes[ARRAY_SIZE(code_tab_102us)
+                       + ARRAY_SIZE(extcode_tab_us102)];
+
+struct nvec_keys {
+       struct input_dev *input;
+       struct notifier_block notifier;
+       struct nvec_chip *nvec;
+};
+
+static struct nvec_keys keys_dev;
+
+static int nvec_keys_notifier(struct notifier_block *nb,
+                               unsigned long event_type, void *data)
+{
+       int code, state;
+       unsigned char *msg = (unsigned char *)data;
+
+       if (event_type == NVEC_KB_EVT) {
+               nvec_size _size = (msg[0] & (3 << 5)) >> 5;
+
+/* power on/off button */
+               if(_size == NVEC_VAR_SIZE)
+                       return NOTIFY_STOP;
+
+               if(_size == NVEC_3BYTES)
+                       msg++;
+
+               code = msg[1] & 0x7f;
+               state = msg[1] & 0x80;
+
+               input_report_key(keys_dev.input, code_tabs[_size][code], !state);
+               input_sync(keys_dev.input);
+
+               return NOTIFY_STOP;
+       }
+
+       return NOTIFY_DONE;
+}
+
+static int nvec_kbd_event(struct input_dev *dev, unsigned int type,
+                               unsigned int code, int value)
+{
+       unsigned char buf[] = ACK_KBD_EVENT;
+       struct nvec_chip *nvec = keys_dev.nvec;
+
+       if(type==EV_REP)
+               return 0;
+
+       if(type!=EV_LED)
+               return -1;
+
+       if(code!=LED_CAPSL)
+               return -1;
+
+       buf[2] = !!value;
+       nvec_write_async(nvec, buf, sizeof(buf));
+
+       return 0;
+}
+
+int __init nvec_kbd_init(struct nvec_chip *nvec)
+{
+       int i, j, err;
+       struct input_dev *idev;
+
+       j = 0;
+
+       for(i = 0; i < ARRAY_SIZE(code_tab_102us); ++i)
+               keycodes[j++] = code_tab_102us[i];
+
+       for(i = 0; i < ARRAY_SIZE(extcode_tab_us102); ++i)
+               keycodes[j++]=extcode_tab_us102[i];
+
+       idev = input_allocate_device();
+       idev->name = "Tegra nvec keyboard";
+       idev->phys = "i2c3_slave/nvec";
+       idev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP) | BIT_MASK(EV_LED);
+       idev->ledbit[0] = BIT_MASK(LED_CAPSL);
+       idev->event = nvec_kbd_event;
+       idev->keycode = keycodes;
+       idev->keycodesize = sizeof(unsigned char);
+       idev->keycodemax = ARRAY_SIZE(keycodes);
+
+       for( i = 0; i < ARRAY_SIZE(keycodes); ++i)
+               set_bit(keycodes[i], idev->keybit);
+
+       clear_bit(0, idev->keybit);
+       err = input_register_device(idev);
+       if(err)
+               goto fail;
+
+       keys_dev.input = idev;
+       keys_dev.notifier.notifier_call = nvec_keys_notifier;
+       keys_dev.nvec = nvec;
+       nvec_register_notifier(nvec, &keys_dev.notifier, 0);
+
+       /* Enable keyboard */
+       nvec_write_async(nvec, "\x05\xf4", 2);
+
+       /* keyboard reset? */
+       nvec_write_async(nvec, "\x05\x03\x01\x01", 4);
+       nvec_write_async(nvec, "\x05\x04\x01", 3);
+       nvec_write_async(nvec, "\x06\x01\xff\x03", 4);
+/*     FIXME
+       wait until keyboard reset is finished
+       or until we have a sync write */
+       mdelay(1000);
+
+       return 0;
+
+fail:
+       input_free_device(idev);
+       return err;
+}
diff --git a/drivers/staging/nvec/nvec_power.c b/drivers/staging/nvec/nvec_power.c
new file mode 100644 (file)
index 0000000..df164ad
--- /dev/null
@@ -0,0 +1,418 @@
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/err.h>
+#include <linux/power_supply.h>
+#include <linux/slab.h>
+#include <linux/workqueue.h>
+#include <linux/delay.h>
+#include "nvec.h"
+
+struct nvec_power
+{
+       struct notifier_block notifier;
+       struct delayed_work poller;
+       struct nvec_chip *nvec;
+       int on;
+       int bat_present;
+       int bat_status;
+       int bat_voltage_now;
+       int bat_current_now;
+       int bat_current_avg;
+       int time_remain;
+       int charge_full_design;
+       int charge_last_full;
+       int critical_capacity;
+       int capacity_remain;
+       int bat_temperature;
+       int bat_cap;
+       int bat_type_enum;
+       char bat_manu[30];
+       char bat_model[30];
+       char bat_type[30];
+};
+
+enum {
+       SLOT_STATUS,
+       VOLTAGE,
+       TIME_REMAINING,
+       CURRENT,
+       AVERAGE_CURRENT,
+       AVERAGING_TIME_INTERVAL,
+       CAPACITY_REMAINING,
+       LAST_FULL_CHARGE_CAPACITY,
+       DESIGN_CAPACITY,
+       CRITICAL_CAPACITY,
+       TEMPERATURE,
+       MANUFACTURER,
+       MODEL,
+       TYPE,
+};
+
+enum {
+       AC,
+       BAT,
+};
+
+struct bat_response {
+       u8 event_type;
+       u8 length;
+       u8 sub_type;
+       u8 status;
+       union { /* payload */
+               char plc[30];
+               u16 plu;
+               s16 pls;
+       };
+};
+
+static struct power_supply nvec_bat_psy;
+static struct power_supply nvec_psy;
+
+static int nvec_power_notifier(struct notifier_block *nb,
+                                unsigned long event_type, void *data)
+{
+       struct nvec_power *power = container_of(nb, struct nvec_power, notifier);
+       struct bat_response *res = (struct bat_response *)data;
+
+       if (event_type != NVEC_SYS)
+               return NOTIFY_DONE;
+
+       if(res->sub_type == 0)
+       {
+               if (power->on != res->plu)
+               {
+                       power->on = res->plu;
+                       power_supply_changed(&nvec_psy);
+               }
+               return NOTIFY_STOP;
+       }
+       return NOTIFY_OK;
+}
+
+static const int bat_init[] =
+{
+       LAST_FULL_CHARGE_CAPACITY, DESIGN_CAPACITY, CRITICAL_CAPACITY,
+       MANUFACTURER, MODEL, TYPE,
+};
+
+static void get_bat_mfg_data(struct nvec_power *power)
+{
+       int i;
+       char buf[] = { '\x02', '\x00' };
+
+       for (i = 0; i < ARRAY_SIZE(bat_init); i++)
+       {
+               buf[1] = bat_init[i];
+               nvec_write_async(power->nvec, buf, 2);
+       }
+}
+
+static int nvec_power_bat_notifier(struct notifier_block *nb,
+                                unsigned long event_type, void *data)
+{
+       struct nvec_power *power = container_of(nb, struct nvec_power, notifier);
+       struct bat_response *res = (struct bat_response *)data;
+       int status_changed = 0;
+
+       if (event_type != NVEC_BAT)
+               return NOTIFY_DONE;
+
+       switch(res->sub_type)
+       {
+               case SLOT_STATUS:
+                       if (res->plc[0] & 1)
+                       {
+                               if (power->bat_present == 0)
+                               {
+                                       status_changed = 1;
+                                       get_bat_mfg_data(power);
+                               }
+
+                               power->bat_present = 1;
+
+                               switch ((res->plc[0] >> 1) & 3)
+                               {
+                                       case 0:
+                                               power->bat_status = POWER_SUPPLY_STATUS_NOT_CHARGING;
+                                               break;
+                                       case 1:
+                                               power->bat_status = POWER_SUPPLY_STATUS_CHARGING;
+                                               break;
+                                       case 2:
+                                               power->bat_status = POWER_SUPPLY_STATUS_DISCHARGING;
+                                               break;
+                                       default:
+                                               power->bat_status = POWER_SUPPLY_STATUS_UNKNOWN;
+                               }
+                       } else {
+                               if (power->bat_present == 1)
+                                       status_changed = 1;
+
+                               power->bat_present = 0;
+                               power->bat_status = POWER_SUPPLY_STATUS_UNKNOWN;
+                       }
+                       power->bat_cap = res->plc[1];
+                       if (status_changed)
+                               power_supply_changed(&nvec_bat_psy);
+                       break;
+               case VOLTAGE:
+                       power->bat_voltage_now = res->plu * 1000;
+                       break;
+               case TIME_REMAINING:
+                       power->time_remain = res->plu * 3600;
+                       break;
+               case CURRENT:
+                       power->bat_current_now = res->pls * 1000;
+                       break;
+               case AVERAGE_CURRENT:
+                       power->bat_current_avg = res->pls * 1000;
+                       break;
+               case CAPACITY_REMAINING:
+                       power->capacity_remain = res->plu * 1000;
+                       break;
+               case LAST_FULL_CHARGE_CAPACITY:
+                       power->charge_last_full = res->plu * 1000;
+                       break;
+               case DESIGN_CAPACITY:
+                       power->charge_full_design = res->plu * 1000;
+                       break;
+               case CRITICAL_CAPACITY:
+                       power->critical_capacity = res->plu * 1000;
+                       break;
+               case TEMPERATURE:
+                       power->bat_temperature = res->plu - 2732;
+                       break;
+               case MANUFACTURER:
+                       memcpy(power->bat_manu, &res->plc, res->length-2);
+                       power->bat_model[res->length-2] = '\0';
+                       break;
+               case MODEL:
+                       memcpy(power->bat_model, &res->plc, res->length-2);
+                       power->bat_model[res->length-2] = '\0';
+                       break;
+               case TYPE:
+                       memcpy(power->bat_type, &res->plc, res->length-2);
+                       power->bat_type[res->length-2] = '\0';
+                       /* this differs a little from the spec
+                          fill in more if you find some */
+                       if (!strncmp(power->bat_type, "Li", 30))
+                               power->bat_type_enum = POWER_SUPPLY_TECHNOLOGY_LION;
+                       else
+                               power->bat_type_enum = POWER_SUPPLY_TECHNOLOGY_UNKNOWN;
+                       break;
+               default:
+                       return NOTIFY_STOP;
+       }
+
+       return NOTIFY_STOP;
+}
+
+static int nvec_power_get_property(struct power_supply *psy,
+                               enum power_supply_property psp,
+                               union power_supply_propval *val)
+{
+       struct nvec_power *power = dev_get_drvdata(psy->dev->parent);
+       switch (psp) {
+       case POWER_SUPPLY_PROP_ONLINE:
+               val->intval = power->on;
+               break;
+       default:
+               return -EINVAL;
+       }
+       return 0;
+}
+
+static int nvec_battery_get_property(struct power_supply *psy,
+                               enum power_supply_property psp,
+                               union power_supply_propval *val)
+{
+       struct nvec_power *power = dev_get_drvdata(psy->dev->parent);
+
+       switch(psp)
+       {
+               case POWER_SUPPLY_PROP_STATUS:
+                       val->intval = power->bat_status;
+                       break;
+               case POWER_SUPPLY_PROP_CAPACITY:
+                       val->intval = power->bat_cap;
+                       break;
+               case POWER_SUPPLY_PROP_PRESENT:
+                       val->intval = power->bat_present;
+                       break;
+               case POWER_SUPPLY_PROP_VOLTAGE_NOW:
+                       val->intval = power->bat_voltage_now;
+                       break;
+               case POWER_SUPPLY_PROP_CURRENT_NOW:
+                       val->intval = power->bat_current_now;
+                       break;
+               case POWER_SUPPLY_PROP_CURRENT_AVG:
+                       val->intval = power->bat_current_avg;
+                       break;
+               case POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW:
+                       val->intval = power->time_remain;
+                       break;
+               case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN:
+                       val->intval = power->charge_full_design;
+                       break;
+               case POWER_SUPPLY_PROP_CHARGE_FULL:
+                       val->intval = power->charge_last_full;
+                       break;
+               case POWER_SUPPLY_PROP_CHARGE_EMPTY:
+                       val->intval = power->critical_capacity;
+                       break;
+               case POWER_SUPPLY_PROP_CHARGE_NOW:
+                       val->intval = power->capacity_remain;
+                       break;
+               case POWER_SUPPLY_PROP_TEMP:
+                       val->intval = power->bat_temperature;
+                       break;
+               case POWER_SUPPLY_PROP_MANUFACTURER:
+                       val->strval = power->bat_manu;
+                       break;
+               case POWER_SUPPLY_PROP_MODEL_NAME:
+                       val->strval = power->bat_model;
+                       break;
+               case POWER_SUPPLY_PROP_TECHNOLOGY:
+                       val->intval = power->bat_type_enum;
+                       break;
+               default:
+                       return -EINVAL;
+               }
+       return 0;
+}
+
+static enum power_supply_property nvec_power_props[] = {
+       POWER_SUPPLY_PROP_ONLINE,
+};
+
+static enum power_supply_property nvec_battery_props[] = {
+       POWER_SUPPLY_PROP_STATUS,
+       POWER_SUPPLY_PROP_PRESENT,
+       POWER_SUPPLY_PROP_CAPACITY,
+       POWER_SUPPLY_PROP_VOLTAGE_NOW,
+       POWER_SUPPLY_PROP_CURRENT_NOW,
+#ifdef EC_FULL_DIAG
+       POWER_SUPPLY_PROP_CURRENT_AVG,
+       POWER_SUPPLY_PROP_TEMP,
+       POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW,
+#endif
+       POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN,
+       POWER_SUPPLY_PROP_CHARGE_FULL,
+       POWER_SUPPLY_PROP_CHARGE_EMPTY,
+       POWER_SUPPLY_PROP_CHARGE_NOW,
+       POWER_SUPPLY_PROP_MANUFACTURER,
+       POWER_SUPPLY_PROP_MODEL_NAME,
+       POWER_SUPPLY_PROP_TECHNOLOGY,
+};
+
+static char *nvec_power_supplied_to[] = {
+       "battery",
+};
+
+static struct power_supply nvec_bat_psy = {
+       .name           = "battery",
+       .type           = POWER_SUPPLY_TYPE_BATTERY,
+       .properties     = nvec_battery_props,
+       .num_properties = ARRAY_SIZE(nvec_battery_props),
+       .get_property   = nvec_battery_get_property,
+};
+
+static struct power_supply nvec_psy = {
+       .name = "ac",
+       .type = POWER_SUPPLY_TYPE_MAINS,
+       .supplied_to = nvec_power_supplied_to,
+       .num_supplicants = ARRAY_SIZE(nvec_power_supplied_to),
+       .properties = nvec_power_props,
+       .num_properties = ARRAY_SIZE(nvec_power_props),
+       .get_property = nvec_power_get_property,
+};
+
+static int counter = 0;
+static int const bat_iter[] =
+{
+       SLOT_STATUS, VOLTAGE, CURRENT, CAPACITY_REMAINING,
+#ifdef EC_FULL_DIAG
+       AVERAGE_CURRENT, TEMPERATURE, TIME_REMAINING,
+#endif
+};
+
+static void nvec_power_poll(struct work_struct *work)
+{
+       char buf[] = { '\x01', '\x00' };
+       struct nvec_power *power = container_of(work, struct nvec_power,
+                poller.work);
+
+       if (counter >= ARRAY_SIZE(bat_iter))
+               counter = 0;
+
+/* AC status via sys req */
+       nvec_write_async(power->nvec, buf, 2);
+       msleep(100);
+
+/* select a battery request function via round robin
+   doing it all at once seems to overload the power supply */
+       buf[0] = '\x02'; /* battery */
+        buf[1] = bat_iter[counter++];
+       nvec_write_async(power->nvec, buf, 2);
+
+//     printk("%02x %02x\n", buf[0], buf[1]);
+
+       schedule_delayed_work(to_delayed_work(work), msecs_to_jiffies(5000));
+};
+
+static int __devinit nvec_power_probe(struct platform_device *pdev)
+{
+       struct power_supply *psy;
+       struct nvec_power *power = kzalloc(sizeof(struct nvec_power), GFP_NOWAIT);
+       struct nvec_chip *nvec = dev_get_drvdata(pdev->dev.parent);
+
+       dev_set_drvdata(&pdev->dev, power);
+       power->nvec = nvec;
+
+       switch (pdev->id) {
+       case AC:
+               psy = &nvec_psy;
+
+               power->notifier.notifier_call = nvec_power_notifier;
+
+               INIT_DELAYED_WORK(&power->poller, nvec_power_poll);
+               schedule_delayed_work(&power->poller, msecs_to_jiffies(5000));
+               break;
+       case BAT:
+               psy = &nvec_bat_psy;
+
+                power->notifier.notifier_call = nvec_power_bat_notifier;
+               break;
+       default:
+               kfree(power);
+               return -ENODEV;
+       }
+
+       nvec_register_notifier(nvec, &power->notifier, NVEC_SYS);
+
+       if (pdev->id == BAT)
+               get_bat_mfg_data(power);
+
+       return power_supply_register(&pdev->dev, psy);
+}
+
+static struct platform_driver nvec_power_driver = {
+       .probe = nvec_power_probe,
+//     .remove = __devexit_p(nvec_power_remove),
+       .driver = {
+               .name = "nvec-power",
+               .owner = THIS_MODULE,
+       }
+};
+
+static int __init nvec_power_init(void) 
+{
+       return platform_driver_register(&nvec_power_driver);
+}
+
+module_init(nvec_power_init);
+
+MODULE_AUTHOR("Ilya Petrov <ilya.muromec@gmail.com>");
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("NVEC battery and AC driver");
+MODULE_ALIAS("platform:nvec-power");
diff --git a/drivers/staging/nvec/nvec_ps2.c b/drivers/staging/nvec/nvec_ps2.c
new file mode 100644 (file)
index 0000000..6bb9430
--- /dev/null
@@ -0,0 +1,103 @@
+#include <linux/slab.h>
+#include <linux/serio.h>
+#include <linux/delay.h>
+#include "nvec.h"
+
+#define START_STREAMING        {'\x06','\x03','\x01'}
+#define STOP_STREAMING {'\x06','\x04'}
+#define SEND_COMMAND   {'\x06','\x01','\xf4','\x01'}
+
+struct nvec_ps2
+{
+       struct serio *ser_dev;
+       struct notifier_block notifier;
+       struct nvec_chip *nvec;
+};
+
+static struct nvec_ps2 ps2_dev;
+
+static int ps2_startstreaming(struct serio *ser_dev)
+{
+       unsigned char buf[] = START_STREAMING;
+       nvec_write_async(ps2_dev.nvec, buf, sizeof(buf));
+       return 0;
+}
+
+static void ps2_stopstreaming(struct serio *ser_dev)
+{
+       unsigned char buf[] = STOP_STREAMING;
+       nvec_write_async(ps2_dev.nvec, buf, sizeof(buf));
+}
+
+/* is this really needed?
+static void nvec_resp_handler(unsigned char *data) {
+       serio_interrupt(ser_dev, data[4], 0);
+}
+*/
+
+static int ps2_sendcommand(struct serio *ser_dev, unsigned char cmd)
+{
+       unsigned char buf[] = SEND_COMMAND;
+
+       buf[2] = cmd & 0xff;
+
+       dev_dbg(&ser_dev->dev, "Sending ps2 cmd %02x\n", cmd);
+       nvec_write_async(ps2_dev.nvec, buf, sizeof(buf));
+
+       return 0;
+}
+
+static int nvec_ps2_notifier(struct notifier_block *nb,
+                               unsigned long event_type, void *data)
+{
+       int i;
+       unsigned char *msg = (unsigned char *)data;
+
+       switch (event_type) {
+               case NVEC_PS2_EVT:
+                       serio_interrupt(ps2_dev.ser_dev, msg[2], 0);
+                       return NOTIFY_STOP;
+
+               case NVEC_PS2:
+                       if (msg[2] == 1)
+                               for(i = 0; i < (msg[1] - 2); i++)
+                                       serio_interrupt(ps2_dev.ser_dev, msg[i+4], 0);
+                       else if (msg[1] != 2) /* !ack */
+                       {
+                               printk("nvec_ps2: unhandled mouse event ");
+                               for(i = 0; i <= (msg[1]+1); i++)
+                                       printk("%02x ", msg[i]);
+                               printk(".\n");
+                       }
+
+                       return NOTIFY_STOP;
+       }
+
+       return NOTIFY_DONE;
+}
+
+
+int __init nvec_ps2(struct nvec_chip *nvec)
+{
+       struct serio *ser_dev = kzalloc(sizeof(struct serio), GFP_KERNEL);
+
+       ser_dev->id.type=SERIO_8042;
+       ser_dev->write=ps2_sendcommand;
+       ser_dev->open=ps2_startstreaming;
+       ser_dev->close=ps2_stopstreaming;
+
+       strlcpy(ser_dev->name, "NVEC PS2", sizeof(ser_dev->name));
+       strlcpy(ser_dev->phys, "NVEC I2C slave", sizeof(ser_dev->phys));
+
+       ps2_dev.ser_dev = ser_dev;
+       ps2_dev.notifier.notifier_call = nvec_ps2_notifier;
+       ps2_dev.nvec = nvec;
+       nvec_register_notifier(nvec, &ps2_dev.notifier, 0);
+
+       serio_register_port(ser_dev);
+
+       /* mouse reset */
+       nvec_write_async(nvec, "\x06\x01\xff\x03", 4);
+
+       return 0;
+}
index 10a82ef3021529071476d6f5cc1ddbce9f093544..8a11ffcd7de89188252cda18d3841174e6802c59 100644 (file)
@@ -91,8 +91,6 @@ const struct ethtool_ops cvm_oct_ethtool_ops = {
        .set_settings = cvm_oct_set_settings,
        .nway_reset = cvm_oct_nway_reset,
        .get_link = ethtool_op_get_link,
-       .get_sg = ethtool_op_get_sg,
-       .get_tx_csum = ethtool_op_get_tx_csum,
 };
 
 /**
index 22c04eabed4116768959b10681c4c880c0940c7c..2245213df6078559b1a564f8b451b0ac732adf4c 100644 (file)
@@ -153,7 +153,7 @@ static void dcon_wiggle_xo_1(void)
         * According to the cs5536 spec, to set GPIO14 to SMB_CLK we must
         * simultaneously set AUX1 IN/OUT to GPIO14; ditto for SMB_DATA and
         * GPIO15.
-        */
+        */
        cs5535_gpio_set(OLPC_GPIO_SMB_CLK, GPIO_OUTPUT_VAL);
        cs5535_gpio_set(OLPC_GPIO_SMB_DATA, GPIO_OUTPUT_VAL);
        cs5535_gpio_set(OLPC_GPIO_SMB_CLK, GPIO_OUTPUT_ENABLE);
index 7aa9b1a45bd6e7bd24e40cf36c95b9a68fafef57..a6a6cf2adc4d83439ccb68979a14038876aba464 100644 (file)
@@ -24,9 +24,8 @@
 #include "olpc_dcon.h"
 
 /* Hardware setup on the XO 1.5:
- *     DCONLOAD connects to
- *             VX855_GPIO1 (not SMBCK2)
- *     DCONBLANK connects to VX855_GPIO8 (not SSPICLK)  unused in driver
+ *     DCONLOAD connects to VX855_GPIO1 (not SMBCK2)
+ *     DCONBLANK connects to VX855_GPIO8 (not SSPICLK)  unused in driver
  *     DCONSTAT0 connects to VX855_GPI10 (not SSPISDI)
  *     DCONSTAT1 connects to VX855_GPI11 (not nSSPISS)
  *     DCONIRQ connects to VX855_GPIO12
@@ -34,9 +33,9 @@
  *     DCONSMBCLK connects to VX855 graphics CRTSPCLK
  */
 
-#define VX855_GENL_PURPOSE_OUTPUT 0x44c // PMIO_Rx4c-4f
-#define VX855_GPI_STATUS_CHG 0x450  // PMIO_Rx50
-#define VX855_GPI_SCI_SMI 0x452  // PMIO_Rx52
+#define VX855_GENL_PURPOSE_OUTPUT 0x44c /* PMIO_Rx4c-4f */
+#define VX855_GPI_STATUS_CHG 0x450  /* PMIO_Rx50 */
+#define VX855_GPI_SCI_SMI 0x452  /* PMIO_Rx52 */
 #define BIT_GPIO12 0x40
 
 #define PREFIX "OLPC DCON:"
@@ -63,8 +62,7 @@ static int dcon_init_xo_1_5(struct dcon_priv *dcon)
        unsigned int irq;
        u_int8_t tmp;
        struct pci_dev *pdev;
-       
-       
+
        pdev = pci_get_device(PCI_VENDOR_ID_VIA,
                              PCI_DEVICE_ID_VIA_VX855, NULL);
        if (!pdev) {
@@ -149,7 +147,7 @@ static void dcon_wiggle_xo_1_5(void)
         * state machine to reset to a (sane) initial state.  Mitch Bradley
         * did some testing and discovered that holding for 16 SMB_CLK cycles
         * worked a lot more reliably, so that's what we do here.
-        */
+        */
        set_i2c_line(1, 1);
 
        for (x = 0; x < 16; x++) {
@@ -172,13 +170,13 @@ static void dcon_set_dconload_xo_1_5(int val)
 static u8 dcon_read_status_xo_1_5(void)
 {
        u8 status;
-       
+
        if (!dcon_was_irq())
                return -1;
 
-       // i believe this is the same as "inb(0x44b) & 3"
+       /* i believe this is the same as "inb(0x44b) & 3" */
        status = gpio_get_value(VX855_GPI(10));
-       status |= gpio_get_value(VX855_GPI(11)) << 1; 
+       status |= gpio_get_value(VX855_GPI(11)) << 1;
 
        dcon_clear_irq();
 
diff --git a/drivers/staging/rt2860/Kconfig b/drivers/staging/rt2860/Kconfig
deleted file mode 100644 (file)
index f3a7e47..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-config RT2860
-       tristate "Ralink 2860/3090 wireless support"
-       depends on PCI && X86 && WLAN
-       select WIRELESS_EXT
-       select WEXT_PRIV
-       select CRC_CCITT
-       select FW_LOADER
-       ---help---
-         This is an experimental driver for the Ralink 2860 and 3090
-         wireless chips.
diff --git a/drivers/staging/rt2860/Makefile b/drivers/staging/rt2860/Makefile
deleted file mode 100644 (file)
index 6dd0aa5..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-obj-$(CONFIG_RT2860)   += rt2860sta.o
-
-# TODO: all of these should be removed
-ccflags-y := -DLINUX -DAGGREGATION_SUPPORT -DPIGGYBACK_SUPPORT -DWMM_SUPPORT
-ccflags-y += -DRTMP_MAC_PCI -DRTMP_PCI_SUPPORT -DRT2860
-ccflags-y += -DRTMP_RF_RW_SUPPORT -DRTMP_EFUSE_SUPPORT -DRT30xx -DRT3090
-ccflags-y += -DDBG
-
-rt2860sta-y := \
-       common/crypt_md5.o      \
-       common/crypt_sha2.o     \
-       common/crypt_hmac.o     \
-       common/mlme.o           \
-       common/cmm_wep.o        \
-       common/action.o         \
-       common/cmm_data.o       \
-       common/rtmp_init.o      \
-       common/cmm_tkip.o       \
-       common/cmm_aes.o        \
-       common/cmm_sync.o       \
-       common/eeprom.o         \
-       common/cmm_sanity.o     \
-       common/cmm_info.o       \
-       common/cmm_cfg.o        \
-       common/cmm_wpa.o        \
-       common/dfs.o            \
-       common/spectrum.o       \
-       common/rtmp_timer.o     \
-       common/rt_channel.o     \
-       common/cmm_asic.o       \
-       sta/assoc.o             \
-       sta/auth.o              \
-       sta/auth_rsp.o          \
-       sta/sync.o              \
-       sta/sanity.o            \
-       sta/rtmp_data.o         \
-       sta/connect.o           \
-       sta/wpa.o               \
-       rt_linux.o              \
-       rt_main_dev.o           \
-       sta_ioctl.o             \
-       common/ba_action.o      \
-       pci_main_dev.o          \
-       rt_pci_rbus.o           \
-       common/cmm_mac_pci.o    \
-       common/cmm_data_pci.o   \
-       common/ee_prom.o        \
-       common/rtmp_mcu.o       \
-       common/ee_efuse.o       \
-       chips/rt30xx.o          \
-       common/rt_rf.o          \
-       chips/rt3090.o
diff --git a/drivers/staging/rt2860/TODO b/drivers/staging/rt2860/TODO
deleted file mode 100644 (file)
index 8e2f6ee..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-I'm hesitant to add a TODO file here, as the wireless developers would
-really have people help them out on the "clean" rt2860 driver that can
-be found at the http://rt2x00.serialmonkey.com/ site.
-
-But, if you wish to clean up this driver instead, here's a short list of
-things that need to be done to get it into a more mergable shape:
-
-TODO:
-       - checkpatch.pl clean
-       - sparse clean
-       - port to in-kernel 80211 stack and common rt2x00 infrastructure
-       - review by the wireless developer community
-
-Please send any patches or complaints about this driver to Greg
-Kroah-Hartman <greg@kroah.com> and don't bother the upstream wireless
-kernel developers about it, they want nothing to do with it.
diff --git a/drivers/staging/rt2860/ap.h b/drivers/staging/rt2860/ap.h
deleted file mode 100644 (file)
index 2737c0c..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-Module Name:
-ap.h
-
-Abstract:
-Miniport generic portion header file
-
-Revision History:
-Who         When          What
---------    ----------    ----------------------------------------------
-Paul Lin    08-01-2002    created
-James Tan   09-06-2002    modified (Revise NTCRegTable)
-John Chang  12-22-2004    modified for RT2561/2661. merge with STA driver
-*/
-#ifndef __AP_H__
-#define __AP_H__
-
-/* ap_wpa.c */
-void WpaStateMachineInit(struct rt_rtmp_adapter *pAd,
-                        struct rt_state_machine *Sm,
-                        OUT STATE_MACHINE_FUNC Trans[]);
-
-#ifdef RTMP_MAC_USB
-void BeaconUpdateExec(void *SystemSpecific1,
-                     void *FunctionContext,
-                     void *SystemSpecific2, void *SystemSpecific3);
-#endif /* RTMP_MAC_USB // */
-
-void RTMPSetPiggyBack(struct rt_rtmp_adapter *pAd, IN BOOLEAN bPiggyBack);
-
-void MacTableReset(struct rt_rtmp_adapter *pAd);
-
-struct rt_mac_table_entry *MacTableInsertEntry(struct rt_rtmp_adapter *pAd,
-                                    u8 *pAddr,
-                                    u8 apidx, IN BOOLEAN CleanAll);
-
-BOOLEAN MacTableDeleteEntry(struct rt_rtmp_adapter *pAd,
-                           u16 wcid, u8 *pAddr);
-
-struct rt_mac_table_entry *MacTableLookup(struct rt_rtmp_adapter *pAd,
-                                                               u8 *pAddr);
-
-#endif /* __AP_H__ */
diff --git a/drivers/staging/rt2860/chip/mac_pci.h b/drivers/staging/rt2860/chip/mac_pci.h
deleted file mode 100644 (file)
index b8868a5..0000000
+++ /dev/null
@@ -1,355 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-    Module Name:
-       mac_pci.h
-
-    Abstract:
-
-    Revision History:
-    Who                When            What
-    Justin P. Mattock  11/07/2010      Fix some typos
-    ---------    ----------    ----------------------------------------------
- */
-
-#ifndef __MAC_PCI_H__
-#define __MAC_PCI_H__
-
-#include "../rtmp_type.h"
-#include "rtmp_mac.h"
-#include "rtmp_phy.h"
-#include "../rtmp_iface.h"
-#include "../rtmp_dot11.h"
-
-/* */
-/* Device ID & Vendor ID related definitions, */
-/* NOTE: you should not add the new VendorID/DeviceID here unless you know for sure what chip it belongs too. */
-/* */
-#define NIC_PCI_VENDOR_ID              0x1814
-#define PCIBUS_INTEL_VENDOR    0x8086
-
-#if !defined(PCI_CAP_ID_EXP)
-#define PCI_CAP_ID_EXP                     0x10
-#endif
-#if !defined(PCI_EXP_LNKCTL)
-#define PCI_EXP_LNKCTL                     0x10
-#endif
-#if !defined(PCI_CLASS_BRIDGE_PCI)
-#define PCI_CLASS_BRIDGE_PCI           0x0604
-#endif
-
-#define TXINFO_SIZE                                            0
-#define RTMP_PKT_TAIL_PADDING                  0
-#define fRTMP_ADAPTER_NEED_STOP_TX     0
-
-#define AUX_CTRL           0x10c
-
-/* */
-/* TX descriptor format, Tx     ring, Mgmt Ring */
-/* */
-struct PACKED rt_txd {
-       /* Word 0 */
-       u32 SDPtr0;
-       /* Word 1 */
-       u32 SDLen1:14;
-       u32 LastSec1:1;
-       u32 Burst:1;
-       u32 SDLen0:14;
-       u32 LastSec0:1;
-       u32 DMADONE:1;
-       /*Word2 */
-       u32 SDPtr1;
-       /*Word3 */
-       u32 rsv2:24;
-       u32 WIV:1;              /* Wireless Info Valid. 1 if Driver already fill WI,  o if DMA needs to copy WI to correct position */
-       u32 QSEL:2;             /* select on-chip FIFO ID for 2nd-stage output scheduler.0:MGMT, 1:HCCA 2:EDCA */
-       u32 rsv:2;
-       u32 TCO:1;              /* */
-       u32 UCO:1;              /* */
-       u32 ICO:1;              /* */
-};
-
-/* */
-/* Rx descriptor format, Rx Ring */
-/* */
-typedef struct PACKED rt_rxd {
-       /* Word 0 */
-       u32 SDP0;
-       /* Word 1 */
-       u32 SDL1:14;
-       u32 Rsv:2;
-       u32 SDL0:14;
-       u32 LS0:1;
-       u32 DDONE:1;
-       /* Word 2 */
-       u32 SDP1;
-       /* Word 3 */
-       u32 BA:1;
-       u32 DATA:1;
-       u32 NULLDATA:1;
-       u32 FRAG:1;
-       u32 U2M:1;              /* 1: this RX frame is unicast to me */
-       u32 Mcast:1;            /* 1: this is a multicast frame */
-       u32 Bcast:1;            /* 1: this is a broadcast frame */
-       u32 MyBss:1;            /* 1: this frame belongs to the same BSSID */
-       u32 Crc:1;              /* 1: CRC error */
-       u32 CipherErr:2;        /* 0: decryption okay, 1:ICV error, 2:MIC error, 3:KEY not valid */
-       u32 AMSDU:1;            /* rx with 802.3 header, not 802.11 header. */
-       u32 HTC:1;
-       u32 RSSI:1;
-       u32 L2PAD:1;
-       u32 AMPDU:1;
-       u32 Decrypted:1;        /* this frame is being decrypted. */
-       u32 PlcpSignal:1;       /* To be moved */
-       u32 PlcpRssil:1;        /* To be moved */
-       u32 Rsv1:13;
-} RT28XX_RXD_STRUC, *PRT28XX_RXD_STRUC;
-
-typedef union _TX_ATTENUATION_CTRL_STRUC {
-       struct {
-               unsigned long RF_ISOLATION_ENABLE:1;
-               unsigned long Reserve2:7;
-               unsigned long PCIE_PHY_TX_ATTEN_VALUE:3;
-               unsigned long PCIE_PHY_TX_ATTEN_EN:1;
-               unsigned long Reserve1:20;
-       } field;
-
-       unsigned long word;
-} TX_ATTENUATION_CTRL_STRUC, *PTX_ATTENUATION_CTRL_STRUC;
-
-/* ----------------- EEPROM Related MACRO ----------------- */
-
-/* 8051 firmware image for RT2860 - base address = 0x4000 */
-#define FIRMWARE_IMAGE_BASE     0x2000
-#define MAX_FIRMWARE_IMAGE_SIZE 0x2000 /* 8kbyte */
-
-/* ----------------- Frimware Related MACRO ----------------- */
-#define RTMP_WRITE_FIRMWARE(_pAd, _pFwImage, _FwLen)                   \
-       do {                                                            \
-               unsigned long   _i, _firm;                                      \
-               RTMP_IO_WRITE32(_pAd, PBF_SYS_CTRL, 0x10000);           \
-                                                                       \
-               for (_i = 0; _i < _FwLen; _i += 4) {                            \
-                               _firm = _pFwImage[_i] +                         \
-                          (_pFwImage[_i+3] << 24) +                    \
-                          (_pFwImage[_i+2] << 16) +                    \
-                          (_pFwImage[_i+1] << 8);                      \
-                       RTMP_IO_WRITE32(_pAd, FIRMWARE_IMAGE_BASE + _i, _firm); \
-               }                                                       \
-               RTMP_IO_WRITE32(_pAd, PBF_SYS_CTRL, 0x00000);           \
-               RTMP_IO_WRITE32(_pAd, PBF_SYS_CTRL, 0x00001);           \
-                                                                       \
-               /* initialize BBP R/W access agent */                   \
-               RTMP_IO_WRITE32(_pAd, H2M_BBP_AGENT, 0);                \
-               RTMP_IO_WRITE32(_pAd, H2M_MAILBOX_CSR, 0);              \
-       } while (0)
-
-/* ----------------- TX Related MACRO ----------------- */
-#define RTMP_START_DEQUEUE(pAd, QueIdx, irqFlags)              do {} while (0)
-#define RTMP_STOP_DEQUEUE(pAd, QueIdx, irqFlags)               do {} while (0)
-
-#define RTMP_HAS_ENOUGH_FREE_DESC(pAd, pTxBlk, freeNum, pPacket) \
-               ((freeNum) >= (unsigned long)(pTxBlk->TotalFragNum + RTMP_GET_PACKET_FRAGMENTS(pPacket) + 3))   /* rough estimate we will use 3 more descriptor. */
-#define RTMP_RELEASE_DESC_RESOURCE(pAd, QueIdx)                        do {} while (0)
-
-#define NEED_QUEUE_BACK_FOR_AGG(pAd, QueIdx, freeNum, _TxFrameType) \
-               (((freeNum != (TX_RING_SIZE-1)) && \
-               (pAd->TxSwQueue[QueIdx].Number == 0)) || (freeNum < 3))
-
-#define HAL_KickOutMgmtTx(_pAd, _QueIdx, _pPacket, _pSrcBufVA, _SrcBufLen)     \
-                       RtmpPCIMgmtKickOut(_pAd, _QueIdx, _pPacket, _pSrcBufVA, _SrcBufLen)
-
-#define HAL_WriteSubTxResource(pAd, pTxBlk, bIsLast, pFreeNumber)      \
-                               /* RtmpPCI_WriteSubTxResource(pAd, pTxBlk, bIsLast, pFreeNumber) */
-
-#define HAL_WriteTxResource(pAd, pTxBlk, bIsLast, pFreeNumber) \
-                       RtmpPCI_WriteSingleTxResource(pAd, pTxBlk, bIsLast, pFreeNumber)
-
-#define HAL_WriteFragTxResource(pAd, pTxBlk, fragNum, pFreeNumber) \
-                       RtmpPCI_WriteFragTxResource(pAd, pTxBlk, fragNum, pFreeNumber)
-
-#define HAL_WriteMultiTxResource(pAd, pTxBlk, frameNum, pFreeNumber) \
-                       RtmpPCI_WriteMultiTxResource(pAd, pTxBlk, frameNum, pFreeNumber)
-
-#define HAL_FinalWriteTxResource(_pAd, _pTxBlk, _TotalMPDUSize, _FirstTxIdx)   \
-                       RtmpPCI_FinalWriteTxResource(_pAd, _pTxBlk, _TotalMPDUSize, _FirstTxIdx)
-
-#define HAL_LastTxIdx(_pAd, _QueIdx, _LastTxIdx) \
-                               /*RtmpPCIDataLastTxIdx(_pAd, _QueIdx,_LastTxIdx) */
-
-#define HAL_KickOutTx(_pAd, _pTxBlk, _QueIdx)  \
-                       RTMP_IO_WRITE32((_pAd), TX_CTX_IDX0+((_QueIdx)*0x10), (_pAd)->TxRing[(_QueIdx)].TxCpuIdx)
-/*                     RtmpPCIDataKickOut(_pAd, _pTxBlk, _QueIdx)*/
-
-#define HAL_KickOutNullFrameTx(_pAd, _QueIdx, _pNullFrame, _frameLen)  \
-                       MiniportMMRequest(_pAd, _QueIdx, _pNullFrame, _frameLen)
-
-#define GET_TXRING_FREENO(_pAd, _QueIdx) \
-       (_pAd->TxRing[_QueIdx].TxSwFreeIdx > _pAd->TxRing[_QueIdx].TxCpuIdx)    ? \
-                       (_pAd->TxRing[_QueIdx].TxSwFreeIdx - _pAd->TxRing[_QueIdx].TxCpuIdx - 1) \
-                        :      \
-                       (_pAd->TxRing[_QueIdx].TxSwFreeIdx + TX_RING_SIZE - _pAd->TxRing[_QueIdx].TxCpuIdx - 1);
-
-#define GET_MGMTRING_FREENO(_pAd) \
-       (_pAd->MgmtRing.TxSwFreeIdx > _pAd->MgmtRing.TxCpuIdx)  ? \
-                       (_pAd->MgmtRing.TxSwFreeIdx - _pAd->MgmtRing.TxCpuIdx - 1) \
-                        :      \
-                       (_pAd->MgmtRing.TxSwFreeIdx + MGMT_RING_SIZE - _pAd->MgmtRing.TxCpuIdx - 1);
-
-/* ----------------- RX Related MACRO ----------------- */
-
-/* ----------------- ASIC Related MACRO ----------------- */
-/* reset MAC of a station entry to 0x000000000000 */
-#define RTMP_STA_ENTRY_MAC_RESET(pAd, Wcid)    \
-       AsicDelWcidTab(pAd, Wcid);
-
-/* add this entry into ASIC RX WCID search table */
-#define RTMP_STA_ENTRY_ADD(pAd, pEntry)                \
-       AsicUpdateRxWCIDTable(pAd, pEntry->Aid, pEntry->Addr);
-
-/* add by johnli, fix "in_interrupt" error when call "MacTableDeleteEntry" in Rx tasklet */
-/* Set MAC register value according operation mode */
-#define RTMP_UPDATE_PROTECT(pAd)       \
-       AsicUpdateProtect(pAd, 0, (ALLN_SETPROTECT), TRUE, 0);
-/* end johnli */
-
-/* remove Pair-wise key material from ASIC */
-#define RTMP_STA_ENTRY_KEY_DEL(pAd, BssIdx, Wcid)      \
-       AsicRemovePairwiseKeyEntry(pAd, BssIdx, (u8)Wcid);
-
-/* add Client security information into ASIC WCID table and IVEIV table */
-#define RTMP_STA_SECURITY_INFO_ADD(pAd, apidx, KeyID, pEntry)          \
-       RTMPAddWcidAttributeEntry(pAd, apidx, KeyID,                    \
-                                                       pAd->SharedKey[apidx][KeyID].CipherAlg, pEntry);
-
-#define RTMP_SECURITY_KEY_ADD(pAd, apidx, KeyID, pEntry)               \
-       {       /* update pairwise key information to ASIC Shared Key Table */  \
-               AsicAddSharedKeyEntry(pAd, apidx, KeyID,                                        \
-                                                 pAd->SharedKey[apidx][KeyID].CipherAlg,               \
-                                                 pAd->SharedKey[apidx][KeyID].Key,                             \
-                                                 pAd->SharedKey[apidx][KeyID].TxMic,                   \
-                                                 pAd->SharedKey[apidx][KeyID].RxMic);                  \
-               /* update ASIC WCID attribute table and IVEIV table */                  \
-               RTMPAddWcidAttributeEntry(pAd, apidx, KeyID,                                    \
-                                                 pAd->SharedKey[apidx][KeyID].CipherAlg,               \
-                                                 pEntry); }
-
-/* Insert the BA bitmap to ASIC for the Wcid entry */
-#define RTMP_ADD_BA_SESSION_TO_ASIC(_pAd, _Aid, _TID)  \
-               do {                                    \
-                       u32 _Value = 0, _Offset;                                        \
-                       _Offset = MAC_WCID_BASE + (_Aid) * HW_WCID_ENTRY_SIZE + 4;      \
-                       RTMP_IO_READ32((_pAd), _Offset, &_Value);\
-                       _Value |= (0x10000<<(_TID));    \
-                       RTMP_IO_WRITE32((_pAd), _Offset, _Value);\
-               } while (0)
-
-/* Remove the BA bitmap from ASIC for the Wcid entry */
-/*              bitmap field starts at 0x10000 in ASIC WCID table */
-#define RTMP_DEL_BA_SESSION_FROM_ASIC(_pAd, _Wcid, _TID)                               \
-               do {                                                            \
-                       u32 _Value = 0, _Offset;                                \
-                       _Offset = MAC_WCID_BASE + (_Wcid) * HW_WCID_ENTRY_SIZE + 4;     \
-                       RTMP_IO_READ32((_pAd), _Offset, &_Value);                       \
-                       _Value &= (~(0x10000 << (_TID)));                               \
-                       RTMP_IO_WRITE32((_pAd), _Offset, _Value);                       \
-               } while (0)
-
-/* ----------------- Interface Related MACRO ----------------- */
-
-/* */
-/* Enable & Disable NIC interrupt via writing interrupt mask register */
-/* Since it use ADAPTER structure, it have to be put after structure definition. */
-/* */
-#define RTMP_ASIC_INTERRUPT_DISABLE(_pAd)              \
-       do {                    \
-               RTMP_IO_WRITE32((_pAd), INT_MASK_CSR, 0x0);     /* 0: disable */        \
-               RTMP_CLEAR_FLAG((_pAd), fRTMP_ADAPTER_INTERRUPT_ACTIVE);                \
-       } while (0)
-
-#define RTMP_ASIC_INTERRUPT_ENABLE(_pAd)\
-       do {                            \
-               RTMP_IO_WRITE32((_pAd), INT_MASK_CSR, (_pAd)->int_enable_reg /*DELAYINTMASK*/);     /* 1:enable */      \
-               RTMP_SET_FLAG((_pAd), fRTMP_ADAPTER_INTERRUPT_ACTIVE);  \
-       } while (0)
-
-#define RTMP_IRQ_INIT(pAd)     \
-       {       pAd->int_enable_reg = ((DELAYINTMASK) |         \
-                                       (RxINT|TxDataInt|TxMgmtInt)) & ~(0x03); \
-               pAd->int_disable_mask = 0;                                              \
-               pAd->int_pending = 0; }
-
-#define RTMP_IRQ_ENABLE(pAd)                                   \
-       {       /* clear garbage ints */                        \
-               RTMP_IO_WRITE32(pAd, INT_SOURCE_CSR, 0xffffffff);\
-               RTMP_ASIC_INTERRUPT_ENABLE(pAd); }
-
-/* ----------------- MLME Related MACRO ----------------- */
-#define RTMP_MLME_HANDLER(pAd)                 MlmeHandler(pAd)
-
-#define RTMP_MLME_PRE_SANITY_CHECK(pAd)
-
-#define RTMP_MLME_STA_QUICK_RSP_WAKE_UP(pAd)   \
-               RTMPSetTimer(&pAd->StaCfg.StaQuickResponeForRateUpTimer, 100);
-
-#define RTMP_MLME_RESET_STATE_MACHINE(pAd)     \
-               MlmeRestartStateMachine(pAd)
-
-#define RTMP_HANDLE_COUNTER_MEASURE(_pAd, _pEntry)\
-               HandleCounterMeasure(_pAd, _pEntry)
-
-/* ----------------- Power Save Related MACRO ----------------- */
-#define RTMP_PS_POLL_ENQUEUE(pAd)                              EnqueuePsPoll(pAd)
-
-/* For RTMPPCIePowerLinkCtrlRestore () function */
-#define RESTORE_HALT           1
-#define RESTORE_WAKEUP         2
-#define RESTORE_CLOSE           3
-
-#define PowerSafeCID           1
-#define PowerRadioOffCID       2
-#define PowerWakeCID           3
-#define CID0MASK               0x000000ff
-#define CID1MASK               0x0000ff00
-#define CID2MASK               0x00ff0000
-#define CID3MASK               0xff000000
-
-#define RTMP_STA_FORCE_WAKEUP(pAd, bFromTx) \
-    RT28xxPciStaAsicForceWakeup(pAd, bFromTx);
-
-#define RTMP_STA_SLEEP_THEN_AUTO_WAKEUP(pAd, TbttNumToNextWakeUp) \
-    RT28xxPciStaAsicSleepThenAutoWakeup(pAd, TbttNumToNextWakeUp);
-
-#define RTMP_SET_PSM_BIT(_pAd, _val) \
-       MlmeSetPsmBit(_pAd, _val);
-
-#define RTMP_MLME_RADIO_ON(pAd) \
-    RT28xxPciMlmeRadioOn(pAd);
-
-#define RTMP_MLME_RADIO_OFF(pAd) \
-    RT28xxPciMlmeRadioOFF(pAd);
-
-#endif /*__MAC_PCI_H__ // */
diff --git a/drivers/staging/rt2860/chip/mac_usb.h b/drivers/staging/rt2860/chip/mac_usb.h
deleted file mode 100644 (file)
index e8158fb..0000000
+++ /dev/null
@@ -1,345 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-    Module Name:
-               mac_usb.h
-
-    Abstract:
-
-    Revision History:
-    Who                When            What
-    Justin P. Mattock  11/07/2010      Fix a typo
-    ---------    ----------    ----------------------------------------------
- */
-
-#ifndef __MAC_USB_H__
-#define __MAC_USB_H__
-
-#include "../rtmp_type.h"
-#include "rtmp_mac.h"
-#include "rtmp_phy.h"
-#include "../rtmp_iface.h"
-#include "../rtmp_dot11.h"
-
-#define USB_CYC_CFG                            0x02a4
-
-#define BEACON_RING_SIZE               2
-#define MGMTPIPEIDX                    0       /* EP6 is highest priority */
-
-#define RTMP_PKT_TAIL_PADDING  11      /* 3(max 4 byte padding) + 4 (last packet padding) + 4 (MaxBulkOutsize align padding) */
-
-#define fRTMP_ADAPTER_NEED_STOP_TX             \
-               (fRTMP_ADAPTER_NIC_NOT_EXIST | fRTMP_ADAPTER_HALT_IN_PROGRESS | \
-                fRTMP_ADAPTER_RESET_IN_PROGRESS | fRTMP_ADAPTER_BULKOUT_RESET | \
-                fRTMP_ADAPTER_RADIO_OFF | fRTMP_ADAPTER_REMOVE_IN_PROGRESS)
-
-/* */
-/* RXINFO appends at the end of each rx packet. */
-/* */
-#define RXINFO_SIZE                            4
-#define RT2870_RXDMALEN_FIELD_SIZE     4
-
-typedef struct PACKED rt_rxinfo {
-       u32 BA:1;
-       u32 DATA:1;
-       u32 NULLDATA:1;
-       u32 FRAG:1;
-       u32 U2M:1;              /* 1: this RX frame is unicast to me */
-       u32 Mcast:1;            /* 1: this is a multicast frame */
-       u32 Bcast:1;            /* 1: this is a broadcast frame */
-       u32 MyBss:1;            /* 1: this frame belongs to the same BSSID */
-       u32 Crc:1;              /* 1: CRC error */
-       u32 CipherErr:2;        /* 0: decryption okay, 1:ICV error, 2:MIC error, 3:KEY not valid */
-       u32 AMSDU:1;            /* rx with 802.3 header, not 802.11 header. */
-       u32 HTC:1;
-       u32 RSSI:1;
-       u32 L2PAD:1;
-       u32 AMPDU:1;            /* To be moved */
-       u32 Decrypted:1;
-       u32 PlcpRssil:1;
-       u32 CipherAlg:1;
-       u32 LastAMSDU:1;
-       u32 PlcpSignal:12;
-} RT28XX_RXD_STRUC, *PRT28XX_RXD_STRUC;
-
-/* */
-/* TXINFO */
-/* */
-#define TXINFO_SIZE                            4
-
-struct rt_txinfo {
-       /* Word 0 */
-       u32 USBDMATxPktLen:16;  /*used ONLY in USB bulk Aggregation,  Total byte counts of all sub-frame. */
-       u32 rsv:8;
-       u32 WIV:1;              /* Wireless Info Valid. 1 if Driver already fill WI,  o if DMA needs to copy WI to correct position */
-       u32 QSEL:2;             /* select on-chip FIFO ID for 2nd-stage output scheduler.0:MGMT, 1:HCCA 2:EDCA */
-       u32 SwUseLastRound:1;   /* Software use. */
-       u32 rsv2:2;             /* Software use. */
-       u32 USBDMANextVLD:1;    /*used ONLY in USB bulk Aggregation, NextValid */
-       u32 USBDMATxburst:1;    /*used ONLY in USB bulk Aggre. Force USB DMA transmit frame from current selected endpoint */
-};
-
-/* */
-/* Management ring buffer format */
-/* */
-struct rt_mgmt {
-       BOOLEAN Valid;
-       u8 *pBuffer;
-       unsigned long Length;
-};
-
-/*////////////////////////////////////////////////////////////////////////// */
-/* The struct rt_tx_buffer structure forms the transmitted USB packet to the device */
-/*////////////////////////////////////////////////////////////////////////// */
-struct rt_tx_buffer {
-       union {
-               u8 WirelessPacket[TX_BUFFER_NORMSIZE];
-               struct rt_header_802_11 NullFrame;
-               struct rt_pspoll_frame PsPollPacket;
-               struct rt_rts_frame RTSFrame;
-       } field;
-       u8 Aggregation[4];      /*Buffer for save Aggregation size. */
-};
-
-struct rt_httx_buffer {
-       union {
-               u8 WirelessPacket[MAX_TXBULK_SIZE];
-               struct rt_header_802_11 NullFrame;
-               struct rt_pspoll_frame PsPollPacket;
-               struct rt_rts_frame RTSFrame;
-       } field;
-       u8 Aggregation[4];      /*Buffer for save Aggregation size. */
-};
-
-/* used to track driver-generated write irps */
-struct rt_tx_context {
-       void *pAd;              /*Initialized in MiniportInitialize */
-       PURB pUrb;              /*Initialized in MiniportInitialize */
-       PIRP pIrp;              /*used to cancel pending bulk out. */
-       /*Initialized in MiniportInitialize */
-       struct rt_tx_buffer *TransferBuffer;    /*Initialized in MiniportInitialize */
-       unsigned long BulkOutSize;
-       u8 BulkOutPipeId;
-       u8 SelfIdx;
-       BOOLEAN InUse;
-       BOOLEAN bWaitingBulkOut;        /* at least one packet is in this TxContext, ready for making IRP anytime. */
-       BOOLEAN bFullForBulkOut;        /* all tx buffer are full , so waiting for tx bulkout. */
-       BOOLEAN IRPPending;
-       BOOLEAN LastOne;
-       BOOLEAN bAggregatible;
-       u8 Header_802_3[LENGTH_802_3];
-       u8 Rsv[2];
-       unsigned long DataOffset;
-       u32 TxRate;
-       dma_addr_t data_dma;    /* urb dma on linux */
-
-};
-
-/* used to track driver-generated write irps */
-struct rt_ht_tx_context {
-       void *pAd;              /*Initialized in MiniportInitialize */
-       PURB pUrb;              /*Initialized in MiniportInitialize */
-       PIRP pIrp;              /*used to cancel pending bulk out. */
-       /*Initialized in MiniportInitialize */
-       struct rt_httx_buffer *TransferBuffer;  /*Initialized in MiniportInitialize */
-       unsigned long BulkOutSize;      /* Indicate the total bulk-out size in bytes in one bulk-transmission */
-       u8 BulkOutPipeId;
-       BOOLEAN IRPPending;
-       BOOLEAN LastOne;
-       BOOLEAN bCurWriting;
-       BOOLEAN bRingEmpty;
-       BOOLEAN bCopySavePad;
-       u8 SavedPad[8];
-       u8 Header_802_3[LENGTH_802_3];
-       unsigned long CurWritePosition; /* Indicate the buffer offset which packet will be inserted start from. */
-       unsigned long CurWriteRealPos;  /* Indicate the buffer offset which packet now are writing to. */
-       unsigned long NextBulkOutPosition;      /* Indicate the buffer start offset of a bulk-transmission */
-       unsigned long ENextBulkOutPosition;     /* Indicate the buffer end offset of a bulk-transmission */
-       u32 TxRate;
-       dma_addr_t data_dma;    /* urb dma on linux */
-};
-
-/* */
-/* Structure to keep track of receive packets and buffers to indicate */
-/* receive data to the protocol. */
-/* */
-struct rt_rx_context {
-       u8 *TransferBuffer;
-       void *pAd;
-       PIRP pIrp;              /*used to cancel pending bulk in. */
-       PURB pUrb;
-       /*These 2 Boolean shouldn't both be 1 at the same time. */
-       unsigned long BulkInOffset;     /* number of packets waiting for reordering . */
-/*      BOOLEAN                         ReorderInUse;   // At least one packet in this buffer are in reordering buffer and wait for receive indication */
-       BOOLEAN bRxHandling;    /* Notify this packet is being process now. */
-       BOOLEAN InUse;          /* USB Hardware Occupied. Wait for USB HW to put packet. */
-       BOOLEAN Readable;       /* Receive Complete back. OK for driver to indicate receiving packet. */
-       BOOLEAN IRPPending;     /* TODO: To be removed */
-       atomic_t IrpLock;
-       spinlock_t RxContextLock;
-       dma_addr_t data_dma;    /* urb dma on linux */
-};
-
-/******************************************************************************
-
-       USB Frimware Related MACRO
-
-******************************************************************************/
-/* 8051 firmware image for usb - use last-half base address = 0x3000 */
-#define FIRMWARE_IMAGE_BASE                    0x3000
-#define MAX_FIRMWARE_IMAGE_SIZE                0x1000  /* 4kbyte */
-
-#define RTMP_WRITE_FIRMWARE(_pAd, _pFwImage, _FwLen)           \
-       RTUSBFirmwareWrite(_pAd, _pFwImage, _FwLen)
-
-/******************************************************************************
-
-       USB TX Related MACRO
-
-******************************************************************************/
-#define RTMP_START_DEQUEUE(pAd, QueIdx, irqFlags)                              \
-                       do {                                                                                                    \
-                               RTMP_IRQ_LOCK(&pAd->DeQueueLock[QueIdx], irqFlags);             \
-                               if (pAd->DeQueueRunning[QueIdx]) {                                              \
-                                       RTMP_IRQ_UNLOCK(&pAd->DeQueueLock[QueIdx], irqFlags); \
-                                       DBGPRINT(RT_DEBUG_OFF, ("DeQueueRunning[%d]= TRUE!\n", QueIdx));                \
-                                       continue;                                                                                       \
-                               } else {                                                                                                \
-                                       pAd->DeQueueRunning[QueIdx] = TRUE;                                     \
-                                       RTMP_IRQ_UNLOCK(&pAd->DeQueueLock[QueIdx], irqFlags);\
-                               }                                                                                                               \
-                       } while (0)
-
-#define RTMP_STOP_DEQUEUE(pAd, QueIdx, irqFlags)                                               \
-                       do {                                                                                                    \
-                               RTMP_IRQ_LOCK(&pAd->DeQueueLock[QueIdx], irqFlags);             \
-                               pAd->DeQueueRunning[QueIdx] = FALSE;                                    \
-                               RTMP_IRQ_UNLOCK(&pAd->DeQueueLock[QueIdx], irqFlags);   \
-                       } while (0)
-
-#define        RTMP_HAS_ENOUGH_FREE_DESC(pAd, pTxBlk, freeNum, pPacket) \
-               (RTUSBFreeDescriptorRequest(pAd, pTxBlk->QueIdx, (pTxBlk->TotalFrameLen + GET_OS_PKT_LEN(pPacket))) == NDIS_STATUS_SUCCESS)
-
-#define RTMP_RELEASE_DESC_RESOURCE(pAd, QueIdx)                        \
-               do {} while (0)
-
-#define NEED_QUEUE_BACK_FOR_AGG(_pAd, _QueIdx, _freeNum, _TxFrameType)         \
-               ((_TxFrameType == TX_RALINK_FRAME) && \
-               (RTUSBNeedQueueBackForAgg(_pAd, _QueIdx)))
-
-#define HAL_WriteSubTxResource(pAd, pTxBlk, bIsLast, pFreeNumber)      \
-               RtmpUSB_WriteSubTxResource(pAd, pTxBlk, bIsLast, pFreeNumber)
-
-#define HAL_WriteTxResource(pAd, pTxBlk, bIsLast, pFreeNumber) \
-               RtmpUSB_WriteSingleTxResource(pAd, pTxBlk, bIsLast, pFreeNumber)
-
-#define HAL_WriteFragTxResource(pAd, pTxBlk, fragNum, pFreeNumber) \
-               RtmpUSB_WriteFragTxResource(pAd, pTxBlk, fragNum, pFreeNumber)
-
-#define HAL_WriteMultiTxResource(pAd, pTxBlk, frameNum, pFreeNumber)   \
-               RtmpUSB_WriteMultiTxResource(pAd, pTxBlk, frameNum, pFreeNumber)
-
-#define HAL_FinalWriteTxResource(pAd, pTxBlk, totalMPDUSize, TxIdx)    \
-               RtmpUSB_FinalWriteTxResource(pAd, pTxBlk, totalMPDUSize, TxIdx)
-
-#define HAL_LastTxIdx(pAd, QueIdx, TxIdx) \
-                               /*RtmpUSBDataLastTxIdx(pAd, QueIdx,TxIdx) */
-
-#define HAL_KickOutTx(pAd, pTxBlk, QueIdx)     \
-                       RtmpUSBDataKickOut(pAd, pTxBlk, QueIdx)
-
-#define HAL_KickOutMgmtTx(pAd, QueIdx, pPacket, pSrcBufVA, SrcBufLen)  \
-                       RtmpUSBMgmtKickOut(pAd, QueIdx, pPacket, pSrcBufVA, SrcBufLen)
-
-#define HAL_KickOutNullFrameTx(_pAd, _QueIdx, _pNullFrame, _frameLen)  \
-                       RtmpUSBNullFrameKickOut(_pAd, _QueIdx, _pNullFrame, _frameLen)
-
-#define GET_TXRING_FREENO(_pAd, _QueIdx)       (_QueIdx)       /*(_pAd->TxRing[_QueIdx].TxSwFreeIdx) */
-#define GET_MGMTRING_FREENO(_pAd)                      (_pAd->MgmtRing.TxSwFreeIdx)
-
-/* ----------------- RX Related MACRO ----------------- */
-
-/*
-  *    Device Hardware Interface Related MACRO
-  */
-#define RTMP_IRQ_INIT(pAd)                             do {} while (0)
-#define RTMP_IRQ_ENABLE(pAd)                   do {} while (0)
-
-/*
-  *    MLME Related MACRO
-  */
-#define RTMP_MLME_HANDLER(pAd)                 RTUSBMlmeUp(pAd)
-
-#define RTMP_MLME_PRE_SANITY_CHECK(pAd)                                                                \
-       {       if ((pAd->CommonCfg.bHardwareRadio == TRUE) &&                                  \
-                       (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)) &&          \
-                       (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS))) {       \
-                       RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_CHECK_GPIO, NULL, 0); } }
-
-#define RTMP_MLME_STA_QUICK_RSP_WAKE_UP(pAd)   \
-       {       RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_QKERIODIC_EXECUT, NULL, 0);      \
-               RTUSBMlmeUp(pAd); }
-
-#define RTMP_MLME_RESET_STATE_MACHINE(pAd)     \
-       {       MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_RESET_CONF, 0, NULL);     \
-               RTUSBMlmeUp(pAd); }
-
-#define RTMP_HANDLE_COUNTER_MEASURE(_pAd, _pEntry)             \
-       {       RTUSBEnqueueInternalCmd(_pAd, CMDTHREAD_802_11_COUNTER_MEASURE, _pEntry, sizeof(struct rt_mac_table_entry));    \
-               RTUSBMlmeUp(_pAd);                                                                      \
-       }
-
-/*
-  *    Power Save Related MACRO
-  */
-#define RTMP_PS_POLL_ENQUEUE(pAd)                                              \
-       {       RTUSB_SET_BULK_FLAG(pAd, fRTUSB_BULK_OUT_PSPOLL);       \
-               RTUSBKickBulkOut(pAd); }
-
-#define RTMP_STA_FORCE_WAKEUP(_pAd, bFromTx) \
-       RT28xxUsbStaAsicForceWakeup(_pAd, bFromTx);
-
-#define RTMP_STA_SLEEP_THEN_AUTO_WAKEUP(pAd, TbttNumToNextWakeUp) \
-    RT28xxUsbStaAsicSleepThenAutoWakeup(pAd, TbttNumToNextWakeUp);
-
-#define RTMP_SET_PSM_BIT(_pAd, _val) \
-       {\
-               if ((_pAd)->StaCfg.WindowsPowerMode == Ndis802_11PowerModeFast_PSP) \
-                       MlmeSetPsmBit(_pAd, _val);\
-               else { \
-                       u16 _psm_val; \
-                       _psm_val = _val; \
-                       RTUSBEnqueueInternalCmd(_pAd, CMDTHREAD_SET_PSM_BIT, &(_psm_val), sizeof(u16)); \
-               } \
-       }
-
-#define RTMP_MLME_RADIO_ON(pAd) \
-    RT28xxUsbMlmeRadioOn(pAd);
-
-#define RTMP_MLME_RADIO_OFF(pAd) \
-    RT28xxUsbMlmeRadioOFF(pAd);
-
-#endif /*__MAC_USB_H__ // */
diff --git a/drivers/staging/rt2860/chip/rt2860.h b/drivers/staging/rt2860/chip/rt2860.h
deleted file mode 100644 (file)
index f30b808..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
- */
-
-#ifndef __RT2860_H__
-#define __RT2860_H__
-
-#include "mac_pci.h"
-
-#ifndef RTMP_PCI_SUPPORT
-#error "For RT2860, you should define the compile flag -DRTMP_PCI_SUPPORT"
-#endif
-
-#ifndef RTMP_MAC_PCI
-#error "For RT2880, you should define the compile flag -DRTMP_MAC_PCI"
-#endif
-
-/* */
-/* Device ID & Vendor ID, these values should match EEPROM value */
-/* */
-#define NIC2860_PCI_DEVICE_ID  0x0601
-#define NIC2860_PCIe_DEVICE_ID 0x0681
-#define NIC2760_PCI_DEVICE_ID  0x0701  /* 1T/2R Cardbus ??? */
-#define NIC2790_PCIe_DEVICE_ID  0x0781 /* 1T/2R miniCard */
-
-#define VEN_AWT_PCIe_DEVICE_ID 0x1059
-#define VEN_AWT_PCI_VENDOR_ID          0x1A3B
-
-#define EDIMAX_PCI_VENDOR_ID           0x1432
-
-#endif /*__RT2860_H__ // */
diff --git a/drivers/staging/rt2860/chip/rt2870.h b/drivers/staging/rt2860/chip/rt2870.h
deleted file mode 100644 (file)
index 8263f1b..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
- */
-#ifndef __RT2870_H__
-#define __RT2870_H__
-
-#ifdef RT2870
-
-#ifndef RTMP_USB_SUPPORT
-#error "For RT2870, you should define the compile flag -DRTMP_USB_SUPPORT"
-#endif
-
-#ifndef RTMP_MAC_USB
-#error "For RT2870, you should define the compile flag -DRTMP_MAC_USB"
-#endif
-
-#include "../rtmp_type.h"
-#include "mac_usb.h"
-
-/*#define RTMP_CHIP_NAME                "RT2870" */
-
-#endif /* RT2870 // */
-#endif /*__RT2870_H__ // */
diff --git a/drivers/staging/rt2860/chip/rt3070.h b/drivers/staging/rt2860/chip/rt3070.h
deleted file mode 100644 (file)
index 172ce70..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-    Module Name:
-       rt3070.h
-
-    Abstract:
-
-    Revision History:
-    Who          When          What
-    ---------    ----------    ----------------------------------------------
- */
-
-#ifndef __RT3070_H__
-#define __RT3070_H__
-
-#ifdef RT3070
-
-#ifndef RTMP_USB_SUPPORT
-#error "For RT3070, you should define the compile flag -DRTMP_USB_SUPPORT"
-#endif
-
-#ifndef RTMP_MAC_USB
-#error "For RT3070, you should define the compile flag -DRTMP_MAC_USB"
-#endif
-
-#ifndef RTMP_RF_RW_SUPPORT
-#error "For RT3070, you should define the compile flag -DRTMP_RF_RW_SUPPORT"
-#endif
-
-#ifndef RT30xx
-#error "For RT3070, you should define the compile flag -DRT30xx"
-#endif
-
-#include "mac_usb.h"
-#include "rt30xx.h"
-
-/* */
-/* Device ID & Vendor ID, these values should match EEPROM value */
-/* */
-
-#endif /* RT3070 // */
-
-#endif /*__RT3070_H__ // */
diff --git a/drivers/staging/rt2860/chip/rt3090.h b/drivers/staging/rt2860/chip/rt3090.h
deleted file mode 100644 (file)
index 102b938..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-    Module Name:
-       rt3090.h
-
-    Abstract:
-
-    Revision History:
-    Who          When          What
-    ---------    ----------    ----------------------------------------------
- */
-
-#ifndef __RT3090_H__
-#define __RT3090_H__
-
-#ifdef RT3090
-
-#ifndef RTMP_PCI_SUPPORT
-#error "For RT3090, you should define the compile flag -DRTMP_PCI_SUPPORT"
-#endif
-
-#ifndef RTMP_MAC_PCI
-#error "For RT3090, you should define the compile flag -DRTMP_MAC_PCI"
-#endif
-
-#ifndef RTMP_RF_RW_SUPPORT
-#error "For RT3090, you should define the compile flag -DRTMP_RF_RW_SUPPORT"
-#endif
-
-#ifndef RT30xx
-#error "For RT3090, you should define the compile flag -DRT30xx"
-#endif
-
-#define PCIE_PS_SUPPORT
-
-#include "mac_pci.h"
-#include "rt30xx.h"
-
-/* */
-/* Device ID & Vendor ID, these values should match EEPROM value */
-/* */
-#define NIC3090_PCIe_DEVICE_ID  0x3090 /* 1T/1R miniCard */
-#define NIC3091_PCIe_DEVICE_ID  0x3091 /* 1T/2R miniCard */
-#define NIC3092_PCIe_DEVICE_ID  0x3092 /* 2T/2R miniCard */
-
-#endif /* RT3090 // */
-
-#endif /*__RT3090_H__ // */
diff --git a/drivers/staging/rt2860/chip/rt30xx.h b/drivers/staging/rt2860/chip/rt30xx.h
deleted file mode 100644 (file)
index 02e1d72..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-    Module Name:
-       rt30xx.h
-
-    Abstract:
-
-    Revision History:
-    Who          When          What
-    ---------    ----------    ----------------------------------------------
- */
-
-#ifndef __RT30XX_H__
-#define __RT30XX_H__
-
-#ifdef RT30xx
-
-extern struct rt_reg_pair RT30xx_RFRegTable[];
-extern u8 NUM_RF_REG_PARMS;
-
-#endif /* RT30xx // */
-
-#endif /*__RT30XX_H__ // */
diff --git a/drivers/staging/rt2860/chip/rtmp_mac.h b/drivers/staging/rt2860/chip/rtmp_mac.h
deleted file mode 100644 (file)
index 3d1e491..0000000
+++ /dev/null
@@ -1,1308 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-       Module Name:
-       rtmp_mac.h
-
-       Abstract:
-       Ralink Wireless Chip MAC related definition & structures
-
-       Revision History:
-       Who                     When              What
-       Justin P. Mattock       11/07/2010        Fix a comments, and typos
-       --------        ----------        ----------------------------------------------
-*/
-
-#ifndef __RTMP_MAC_H__
-#define __RTMP_MAC_H__
-
-/* ================================================================================= */
-/* TX / RX ring descriptor format */
-/* ================================================================================= */
-
-/* the first 24-byte in TXD is called TXINFO and will be DMAed to MAC block through TXFIFO. */
-/* MAC block uses this TXINFO to control the transmission behavior of this frame. */
-#define FIFO_MGMT                 0
-#define FIFO_HCCA                 1
-#define FIFO_EDCA                 2
-
-/* */
-/* TXD Wireless Information format for Tx ring and Mgmt Ring */
-/* */
-/*txop : for txop mode */
-/* 0:txop for the MPDU frame will be handles by ASIC by register */
-/* 1/2/3:the MPDU frame is send after PIFS/backoff/SIFS */
-struct PACKED rt_txwi {
-       /* Word 0 */
-       /* ex: 00 03 00 40 means txop = 3, PHYMODE = 1 */
-       u32 FRAG:1;             /* 1 to inform TKIP engine this is a fragment. */
-       u32 MIMOps:1;   /* the remote peer is in dynamic MIMO-PS mode */
-       u32 CFACK:1;
-       u32 TS:1;
-
-       u32 AMPDU:1;
-       u32 MpduDensity:3;
-       u32 txop:2;             /*FOR "THIS" frame. 0:HT TXOP rule , 1:PIFS TX ,2:Backoff, 3:sifs only when previous frame exchange is successful. */
-       u32 rsv:6;
-
-       u32 MCS:7;
-       u32 BW:1;               /*channel bandwidth 20MHz or 40 MHz */
-       u32 ShortGI:1;
-       u32 STBC:2;             /* 1: STBC support MCS =0-7,   2,3 : RESERVE */
-       u32 Ifs:1;              /* */
-/*      u32          rsv2:2; //channel bandwidth 20MHz or 40 MHz */
-       u32 rsv2:1;
-       u32 TxBF:1;             /* 3*3 */
-       u32 PHYMODE:2;
-       /* Word1 */
-       /* ex:  1c ff 38 00 means ACK=0, BAWinSize=7, MPDUtotalByteCount = 0x38 */
-       u32 ACK:1;
-       u32 NSEQ:1;
-       u32 BAWinSize:6;
-       u32 WirelessCliID:8;
-       u32 MPDUtotalByteCount:12;
-       u32 PacketId:4;
-       /*Word2 */
-       u32 IV;
-       /*Word3 */
-       u32 EIV;
-};
-
-/* */
-/* RXWI wireless information format, in PBF. invisible in driver. */
-/* */
-struct PACKED rt_rxwi {
-       /* Word 0 */
-       u32 WirelessCliID:8;
-       u32 KeyIndex:2;
-       u32 BSSID:3;
-       u32 UDF:3;
-       u32 MPDUtotalByteCount:12;
-       u32 TID:4;
-       /* Word 1 */
-       u32 FRAG:4;
-       u32 SEQUENCE:12;
-       u32 MCS:7;
-       u32 BW:1;
-       u32 ShortGI:1;
-       u32 STBC:2;
-       u32 rsv:3;
-       u32 PHYMODE:2;  /* 1: this RX frame is unicast to me */
-       /*Word2 */
-       u32 RSSI0:8;
-       u32 RSSI1:8;
-       u32 RSSI2:8;
-       u32 rsv1:8;
-       /*Word3 */
-       u32 SNR0:8;
-       u32 SNR1:8;
-       u32 FOFFSET:8;  /* RT35xx */
-       u32 rsv2:8;
-       /*u32                rsv2:16; */
-};
-
-/* ================================================================================= */
-/* Register format */
-/* ================================================================================= */
-
-/* */
-/* SCH/DMA registers - base address 0x0200 */
-/* */
-/* INT_SOURCE_CSR: Interrupt source register. Write one to clear corresponding bit */
-/* */
-#define DMA_CSR0               0x200
-#define INT_SOURCE_CSR         0x200
-typedef union _INT_SOURCE_CSR_STRUC {
-       struct {
-               u32 RxDelayINT:1;
-               u32 TxDelayINT:1;
-               u32 RxDone:1;
-               u32 Ac0DmaDone:1;       /*4 */
-               u32 Ac1DmaDone:1;
-               u32 Ac2DmaDone:1;
-               u32 Ac3DmaDone:1;
-               u32 HccaDmaDone:1;      /* bit7 */
-               u32 MgmtDmaDone:1;
-               u32 MCUCommandINT:1;    /*bit 9 */
-               u32 RxTxCoherent:1;
-               u32 TBTTInt:1;
-               u32 PreTBTT:1;
-               u32 TXFifoStatusInt:1;  /*FIFO Statistics is full, sw should read 0x171c */
-               u32 AutoWakeup:1;       /*bit14 */
-               u32 GPTimer:1;
-               u32 RxCoherent:1;       /*bit16 */
-               u32 TxCoherent:1;
-               u32: 14;
-       } field;
-       u32 word;
-} INT_SOURCE_CSR_STRUC, *PINT_SOURCE_CSR_STRUC;
-
-/* */
-/* INT_MASK_CSR:   Interrupt MASK register.   1: the interrupt is mask OFF */
-/* */
-#define INT_MASK_CSR        0x204
-typedef union _INT_MASK_CSR_STRUC {
-       struct {
-               u32 RXDelay_INT_MSK:1;
-               u32 TxDelay:1;
-               u32 RxDone:1;
-               u32 Ac0DmaDone:1;
-               u32 Ac1DmaDone:1;
-               u32 Ac2DmaDone:1;
-               u32 Ac3DmaDone:1;
-               u32 HccaDmaDone:1;
-               u32 MgmtDmaDone:1;
-               u32 MCUCommandINT:1;
-               u32: 20;
-               u32 RxCoherent:1;
-               u32 TxCoherent:1;
-       } field;
-       u32 word;
-} INT_MASK_CSR_STRUC, *PINT_MASK_CSR_STRUC;
-
-#define WPDMA_GLO_CFG  0x208
-typedef union _WPDMA_GLO_CFG_STRUC {
-       struct {
-               u32 EnableTxDMA:1;
-               u32 TxDMABusy:1;
-               u32 EnableRxDMA:1;
-               u32 RxDMABusy:1;
-               u32 WPDMABurstSIZE:2;
-               u32 EnTXWriteBackDDONE:1;
-               u32 BigEndian:1;
-               u32 RXHdrScater:8;
-               u32 HDR_SEG_LEN:16;
-       } field;
-       u32 word;
-} WPDMA_GLO_CFG_STRUC, *PWPDMA_GLO_CFG_STRUC;
-
-#define WPDMA_RST_IDX  0x20c
-typedef union _WPDMA_RST_IDX_STRUC {
-       struct {
-               u32 RST_DTX_IDX0:1;
-               u32 RST_DTX_IDX1:1;
-               u32 RST_DTX_IDX2:1;
-               u32 RST_DTX_IDX3:1;
-               u32 RST_DTX_IDX4:1;
-               u32 RST_DTX_IDX5:1;
-               u32 rsv:10;
-               u32 RST_DRX_IDX0:1;
-               u32: 15;
-       } field;
-       u32 word;
-} WPDMA_RST_IDX_STRUC, *PWPDMA_RST_IDX_STRUC;
-#define DELAY_INT_CFG  0x0210
-typedef union _DELAY_INT_CFG_STRUC {
-       struct {
-               u32 RXMAX_PTIME:8;
-               u32 RXMAX_PINT:7;
-               u32 RXDLY_INT_EN:1;
-               u32 TXMAX_PTIME:8;
-               u32 TXMAX_PINT:7;
-               u32 TXDLY_INT_EN:1;
-       } field;
-       u32 word;
-} DELAY_INT_CFG_STRUC, *PDELAY_INT_CFG_STRUC;
-#define WMM_AIFSN_CFG   0x0214
-typedef union _AIFSN_CSR_STRUC {
-       struct {
-               u32 Aifsn0:4;   /* for AC_BE */
-               u32 Aifsn1:4;   /* for AC_BK */
-               u32 Aifsn2:4;   /* for AC_VI */
-               u32 Aifsn3:4;   /* for AC_VO */
-               u32 Rsv:16;
-       } field;
-       u32 word;
-} AIFSN_CSR_STRUC, *PAIFSN_CSR_STRUC;
-/* */
-/* CWMIN_CSR: CWmin for each EDCA AC */
-/* */
-#define WMM_CWMIN_CFG   0x0218
-typedef union _CWMIN_CSR_STRUC {
-       struct {
-               u32 Cwmin0:4;   /* for AC_BE */
-               u32 Cwmin1:4;   /* for AC_BK */
-               u32 Cwmin2:4;   /* for AC_VI */
-               u32 Cwmin3:4;   /* for AC_VO */
-               u32 Rsv:16;
-       } field;
-       u32 word;
-} CWMIN_CSR_STRUC, *PCWMIN_CSR_STRUC;
-
-/* */
-/* CWMAX_CSR: CWmin for each EDCA AC */
-/* */
-#define WMM_CWMAX_CFG   0x021c
-typedef union _CWMAX_CSR_STRUC {
-       struct {
-               u32 Cwmax0:4;   /* for AC_BE */
-               u32 Cwmax1:4;   /* for AC_BK */
-               u32 Cwmax2:4;   /* for AC_VI */
-               u32 Cwmax3:4;   /* for AC_VO */
-               u32 Rsv:16;
-       } field;
-       u32 word;
-} CWMAX_CSR_STRUC, *PCWMAX_CSR_STRUC;
-
-/* */
-/* AC_TXOP_CSR0: AC_BK/AC_BE TXOP register */
-/* */
-#define WMM_TXOP0_CFG    0x0220
-typedef union _AC_TXOP_CSR0_STRUC {
-       struct {
-               u16 Ac0Txop;    /* for AC_BK, in unit of 32us */
-               u16 Ac1Txop;    /* for AC_BE, in unit of 32us */
-       } field;
-       u32 word;
-} AC_TXOP_CSR0_STRUC, *PAC_TXOP_CSR0_STRUC;
-
-/* */
-/* AC_TXOP_CSR1: AC_VO/AC_VI TXOP register */
-/* */
-#define WMM_TXOP1_CFG    0x0224
-typedef union _AC_TXOP_CSR1_STRUC {
-       struct {
-               u16 Ac2Txop;    /* for AC_VI, in unit of 32us */
-               u16 Ac3Txop;    /* for AC_VO, in unit of 32us */
-       } field;
-       u32 word;
-} AC_TXOP_CSR1_STRUC, *PAC_TXOP_CSR1_STRUC;
-
-#define RINGREG_DIFF                   0x10
-#define GPIO_CTRL_CFG    0x0228        /*MAC_CSR13 */
-#define MCU_CMD_CFG    0x022c
-#define TX_BASE_PTR0     0x0230        /*AC_BK base address */
-#define TX_MAX_CNT0      0x0234
-#define TX_CTX_IDX0       0x0238
-#define TX_DTX_IDX0      0x023c
-#define TX_BASE_PTR1     0x0240        /*AC_BE base address */
-#define TX_MAX_CNT1      0x0244
-#define TX_CTX_IDX1       0x0248
-#define TX_DTX_IDX1      0x024c
-#define TX_BASE_PTR2     0x0250        /*AC_VI base address */
-#define TX_MAX_CNT2      0x0254
-#define TX_CTX_IDX2       0x0258
-#define TX_DTX_IDX2      0x025c
-#define TX_BASE_PTR3     0x0260        /*AC_VO base address */
-#define TX_MAX_CNT3      0x0264
-#define TX_CTX_IDX3       0x0268
-#define TX_DTX_IDX3      0x026c
-#define TX_BASE_PTR4     0x0270        /*HCCA base address */
-#define TX_MAX_CNT4      0x0274
-#define TX_CTX_IDX4       0x0278
-#define TX_DTX_IDX4      0x027c
-#define TX_BASE_PTR5     0x0280        /*MGMT base address */
-#define  TX_MAX_CNT5     0x0284
-#define TX_CTX_IDX5       0x0288
-#define TX_DTX_IDX5      0x028c
-#define TX_MGMTMAX_CNT      TX_MAX_CNT5
-#define TX_MGMTCTX_IDX       TX_CTX_IDX5
-#define TX_MGMTDTX_IDX      TX_DTX_IDX5
-#define RX_BASE_PTR     0x0290 /*RX base address */
-#define RX_MAX_CNT      0x0294
-#define RX_CRX_IDX       0x0298
-#define RX_DRX_IDX      0x029c
-
-#define USB_DMA_CFG      0x02a0
-typedef union _USB_DMA_CFG_STRUC {
-       struct {
-               u32 RxBulkAggTOut:8;    /*Rx Bulk Aggregation TimeOut  in unit of 33ns */
-               u32 RxBulkAggLmt:8;     /*Rx Bulk Aggregation Limit  in unit of 256 bytes */
-               u32 phyclear:1; /*phy watch dog enable. write 1 */
-               u32 rsv:2;
-               u32 TxClear:1;  /*Clear USB DMA TX path */
-               u32 TxopHalt:1; /*Halt TXOP count down when TX buffer is full. */
-               u32 RxBulkAggEn:1;      /*Enable Rx Bulk Aggregation */
-               u32 RxBulkEn:1; /*Enable USB DMA Rx */
-               u32 TxBulkEn:1; /*Enable USB DMA Tx */
-               u32 EpoutValid:6;       /*OUT endpoint data valid */
-               u32 RxBusy:1;   /*USB DMA RX FSM busy */
-               u32 TxBusy:1;   /*USB DMA TX FSM busy */
-       } field;
-       u32 word;
-} USB_DMA_CFG_STRUC, *PUSB_DMA_CFG_STRUC;
-
-/* */
-/*  3  PBF  registers */
-/* */
-/* */
-/* Most are for debug. Driver doesn't touch PBF register. */
-#define PBF_SYS_CTRL    0x0400
-#define PBF_CFG                 0x0408
-#define PBF_MAX_PCNT    0x040C
-#define PBF_CTRL               0x0410
-#define PBF_INT_STA     0x0414
-#define PBF_INT_ENA     0x0418
-#define TXRXQ_PCNT      0x0438
-#define PBF_DBG                         0x043c
-#define PBF_CAP_CTRL     0x0440
-
-#ifdef RT30xx
-#ifdef RTMP_EFUSE_SUPPORT
-/* eFuse registers */
-#define EFUSE_CTRL                             0x0580
-#define EFUSE_DATA0                            0x0590
-#define EFUSE_DATA1                            0x0594
-#define EFUSE_DATA2                            0x0598
-#define EFUSE_DATA3                            0x059c
-#endif /* RTMP_EFUSE_SUPPORT // */
-#endif /* RT30xx // */
-
-#define OSC_CTRL               0x5a4
-#define PCIE_PHY_TX_ATTENUATION_CTRL   0x05C8
-#define LDO_CFG0                               0x05d4
-#define GPIO_SWITCH                            0x05dc
-
-/* */
-/*  4  MAC  registers */
-/* */
-/* */
-/*  4.1 MAC SYSTEM  configuration registers (offset:0x1000) */
-/* */
-#define MAC_CSR0            0x1000
-typedef union _ASIC_VER_ID_STRUC {
-       struct {
-               u16 ASICRev;    /* reversion  : 0 */
-               u16 ASICVer;    /* version : 2860 */
-       } field;
-       u32 word;
-} ASIC_VER_ID_STRUC, *PASIC_VER_ID_STRUC;
-#define MAC_SYS_CTRL            0x1004 /*MAC_CSR1 */
-#define MAC_ADDR_DW0                           0x1008  /* MAC ADDR DW0 */
-#define MAC_ADDR_DW1                    0x100c /* MAC ADDR DW1 */
-/* */
-/* MAC_CSR2: STA MAC register 0 */
-/* */
-typedef union _MAC_DW0_STRUC {
-       struct {
-               u8 Byte0;       /* MAC address byte 0 */
-               u8 Byte1;       /* MAC address byte 1 */
-               u8 Byte2;       /* MAC address byte 2 */
-               u8 Byte3;       /* MAC address byte 3 */
-       } field;
-       u32 word;
-} MAC_DW0_STRUC, *PMAC_DW0_STRUC;
-
-/* */
-/* MAC_CSR3: STA MAC register 1 */
-/* */
-typedef union _MAC_DW1_STRUC {
-       struct {
-               u8 Byte4;       /* MAC address byte 4 */
-               u8 Byte5;       /* MAC address byte 5 */
-               u8 U2MeMask;
-               u8 Rsvd1;
-       } field;
-       u32 word;
-} MAC_DW1_STRUC, *PMAC_DW1_STRUC;
-
-#define MAC_BSSID_DW0                          0x1010  /* MAC BSSID DW0 */
-#define MAC_BSSID_DW1                          0x1014  /* MAC BSSID DW1 */
-
-/* */
-/* MAC_CSR5: BSSID register 1 */
-/* */
-typedef union _MAC_CSR5_STRUC {
-       struct {
-               u8 Byte4;       /* BSSID byte 4 */
-               u8 Byte5;       /* BSSID byte 5 */
-               u16 BssIdMask:2;        /* 0: one BSSID, 10: 4 BSSID,  01: 2 BSSID , 11: 8BSSID */
-               u16 MBssBcnNum:3;
-               u16 Rsvd:11;
-       } field;
-       u32 word;
-} MAC_CSR5_STRUC, *PMAC_CSR5_STRUC;
-
-#define MAX_LEN_CFG              0x1018        /* rt2860b max 16k bytes. bit12:13 Maximum PSDU length (power factor) 0:2^13, 1:2^14, 2:2^15, 3:2^16 */
-#define BBP_CSR_CFG                    0x101c  /* */
-/* */
-/* BBP_CSR_CFG: BBP serial control register */
-/* */
-typedef union _BBP_CSR_CFG_STRUC {
-       struct {
-               u32 Value:8;    /* Register     value to program into BBP */
-               u32 RegNum:8;   /* Selected     BBP     register */
-               u32 fRead:1;    /* 0: Write BBP, 1: Read BBP */
-               u32 Busy:1;     /* 1: ASIC is busy execute BBP programming. */
-               u32 BBP_PAR_DUR:1;      /* 0: 4 MAC clock cycles  1: 8 MAC clock cycles */
-               u32 BBP_RW_MODE:1;      /* 0: use serial mode  1:parallel */
-               u32: 12;
-       } field;
-       u32 word;
-} BBP_CSR_CFG_STRUC, *PBBP_CSR_CFG_STRUC;
-#define RF_CSR_CFG0                    0x1020
-/* */
-/* RF_CSR_CFG: RF control register */
-/* */
-typedef union _RF_CSR_CFG0_STRUC {
-       struct {
-               u32 RegIdAndContent:24; /* Register value to program into BBP */
-               u32 bitwidth:5; /* Selected BBP register */
-               u32 StandbyMode:1;      /* 0: high when stand by 1: low when standby */
-               u32 Sel:1;      /* 0:RF_LE0 activate  1:RF_LE1 activate */
-               u32 Busy:1;     /* 0: idle 1: 8busy */
-       } field;
-       u32 word;
-} RF_CSR_CFG0_STRUC, *PRF_CSR_CFG0_STRUC;
-#define RF_CSR_CFG1                    0x1024
-typedef union _RF_CSR_CFG1_STRUC {
-       struct {
-               u32 RegIdAndContent:24; /* Register value to program into BBP */
-               u32 RFGap:5;    /* Gap between BB_CONTROL_RF and RF_LE. 0: 3 system clock cycle (37.5usec) 1: 5 system clock cycle (62.5usec) */
-               u32 rsv:7;      /* 0: idle 1: 8busy */
-       } field;
-       u32 word;
-} RF_CSR_CFG1_STRUC, *PRF_CSR_CFG1_STRUC;
-#define RF_CSR_CFG2                    0x1028  /* */
-typedef union _RF_CSR_CFG2_STRUC {
-       struct {
-               u32 RegIdAndContent:24; /* Register value to program into BBP */
-               u32 rsv:8;      /* 0: idle 1: 8busy */
-       } field;
-       u32 word;
-} RF_CSR_CFG2_STRUC, *PRF_CSR_CFG2_STRUC;
-#define LED_CFG                                0x102c  /*  MAC_CSR14 */
-typedef union _LED_CFG_STRUC {
-       struct {
-               u32 OnPeriod:8; /* blinking on period unit 1ms */
-               u32 OffPeriod:8;        /* blinking off period unit 1ms */
-               u32 SlowBlinkPeriod:6;  /* slow blinking period. unit:1ms */
-               u32 rsv:2;
-               u32 RLedMode:2; /* red Led Mode 0: off1: blinking upon TX2: periodic slow blinking3: always on */
-               u32 GLedMode:2; /* green Led Mode */
-               u32 YLedMode:2; /* yellow Led Mode */
-               u32 LedPolar:1; /* Led Polarity.  0: active low1: active high */
-               u32: 1;
-       } field;
-       u32 word;
-} LED_CFG_STRUC, *PLED_CFG_STRUC;
-/* */
-/*  4.2 MAC TIMING  configuration registers (offset:0x1100) */
-/* */
-#define XIFS_TIME_CFG             0x1100       /* MAC_CSR8  MAC_CSR9 */
-typedef union _IFS_SLOT_CFG_STRUC {
-       struct {
-               u32 CckmSifsTime:8;     /*  unit 1us. Applied after CCK RX/TX */
-               u32 OfdmSifsTime:8;     /*  unit 1us. Applied after OFDM RX/TX */
-               u32 OfdmXifsTime:4;     /*OFDM SIFS. unit 1us. Applied after OFDM RX when MAC doesn't reference BBP signal BBRXEND */
-               u32 EIFS:9;     /*  unit 1us */
-               u32 BBRxendEnable:1;    /*  reference RXEND signal to begin XIFS defer */
-               u32 rsv:2;
-       } field;
-       u32 word;
-} IFS_SLOT_CFG_STRUC, *PIFS_SLOT_CFG_STRUC;
-
-#define BKOFF_SLOT_CFG             0x1104      /*  mac_csr9 last 8 bits */
-#define NAV_TIME_CFG             0x1108        /* NAV  (MAC_CSR15) */
-#define CH_TIME_CFG             0x110C /* Count as channel busy */
-#define PBF_LIFE_TIMER             0x1110      /*TX/RX MPDU timestamp timer (free run)Unit: 1us */
-#define BCN_TIME_CFG             0x1114        /* TXRX_CSR9 */
-
-#define BCN_OFFSET0                            0x042C
-#define BCN_OFFSET1                            0x0430
-
-/* */
-/* BCN_TIME_CFG : Synchronization control register */
-/* */
-typedef union _BCN_TIME_CFG_STRUC {
-       struct {
-               u32 BeaconInterval:16;  /* in unit of 1/16 TU */
-               u32 bTsfTicking:1;      /* Enable TSF auto counting */
-               u32 TsfSyncMode:2;      /* Enable TSF sync, 00: disable, 01: infra mode, 10: ad-hoc mode */
-               u32 bTBTTEnable:1;
-               u32 bBeaconGen:1;       /* Enable beacon generator */
-               u32: 3;
-               u32 TxTimestampCompensate:8;
-       } field;
-       u32 word;
-} BCN_TIME_CFG_STRUC, *PBCN_TIME_CFG_STRUC;
-#define TBTT_SYNC_CFG            0x1118        /* txrx_csr10 */
-#define TSF_TIMER_DW0             0x111C       /* Local TSF timer lsb 32 bits. Read-only */
-#define TSF_TIMER_DW1             0x1120       /* msb 32 bits. Read-only. */
-#define TBTT_TIMER             0x1124  /* TImer remains till next TBTT. Read-only.  TXRX_CSR14 */
-#define INT_TIMER_CFG                  0x1128  /* */
-#define INT_TIMER_EN                   0x112c  /*  GP-timer and pre-tbtt Int enable */
-#define CH_IDLE_STA                    0x1130  /*  channel idle time */
-#define CH_BUSY_STA                    0x1134  /*  channle busy time */
-/* */
-/*  4.2 MAC POWER  configuration registers (offset:0x1200) */
-/* */
-#define MAC_STATUS_CFG             0x1200      /* old MAC_CSR12 */
-#define PWR_PIN_CFG             0x1204 /* old MAC_CSR12 */
-#define AUTO_WAKEUP_CFG             0x1208     /* old MAC_CSR10 */
-/* */
-/* AUTO_WAKEUP_CFG: Manual power control / status register */
-/* */
-typedef union _AUTO_WAKEUP_STRUC {
-       struct {
-               u32 AutoLeadTime:8;
-               u32 NumofSleepingTbtt:7;        /* ForceWake has high privilege than PutToSleep when both set */
-               u32 EnableAutoWakeup:1; /* 0:sleep, 1:awake */
-               u32: 16;
-       } field;
-       u32 word;
-} AUTO_WAKEUP_STRUC, *PAUTO_WAKEUP_STRUC;
-/* */
-/*  4.3 MAC TX  configuration registers (offset:0x1300) */
-/* */
-
-#define EDCA_AC0_CFG   0x1300  /*AC_TXOP_CSR0 0x3474 */
-#define EDCA_AC1_CFG   0x1304
-#define EDCA_AC2_CFG   0x1308
-#define EDCA_AC3_CFG   0x130c
-typedef union _EDCA_AC_CFG_STRUC {
-       struct {
-               u32 AcTxop:8;   /*  in unit of 32us */
-               u32 Aifsn:4;    /* # of slot time */
-               u32 Cwmin:4;    /* */
-               u32 Cwmax:4;    /*unit power of 2 */
-               u32: 12;        /* */
-       } field;
-       u32 word;
-} EDCA_AC_CFG_STRUC, *PEDCA_AC_CFG_STRUC;
-
-#define EDCA_TID_AC_MAP        0x1310
-#define TX_PWR_CFG_0   0x1314
-#define TX_PWR_CFG_1   0x1318
-#define TX_PWR_CFG_2   0x131C
-#define TX_PWR_CFG_3   0x1320
-#define TX_PWR_CFG_4   0x1324
-#define TX_PIN_CFG             0x1328
-#define TX_BAND_CFG    0x132c  /* 0x1 use upper 20MHz. 0 juse lower 20MHz */
-#define TX_SW_CFG0             0x1330
-#define TX_SW_CFG1             0x1334
-#define TX_SW_CFG2             0x1338
-#define TXOP_THRES_CFG         0x133c
-#define TXOP_CTRL_CFG          0x1340
-#define TX_RTS_CFG             0x1344
-
-typedef union _TX_RTS_CFG_STRUC {
-       struct {
-               u32 AutoRtsRetryLimit:8;
-               u32 RtsThres:16;        /* unit:byte */
-               u32 RtsFbkEn:1; /* enable rts rate fallback */
-               u32 rsv:7;      /* 1: HT non-STBC control frame enable */
-       } field;
-       u32 word;
-} TX_RTS_CFG_STRUC, *PTX_RTS_CFG_STRUC;
-#define TX_TIMEOUT_CFG 0x1348
-typedef union _TX_TIMEOUT_CFG_STRUC {
-       struct {
-               u32 rsv:4;
-               u32 MpduLifeTime:4;     /*  expiration time = 2^(9+MPDU LIFE TIME)  us */
-               u32 RxAckTimeout:8;     /* unit:slot. Used for TX precedure */
-               u32 TxopTimeout:8;      /*TXOP timeout value for TXOP truncation.  It is recommended that (SLOT_TIME) > (TX_OP_TIMEOUT) > (RX_ACK_TIMEOUT) */
-               u32 rsv2:8;     /* 1: HT non-STBC control frame enable */
-       } field;
-       u32 word;
-} TX_TIMEOUT_CFG_STRUC, *PTX_TIMEOUT_CFG_STRUC;
-#define TX_RTY_CFG     0x134c
-typedef union PACKED _TX_RTY_CFG_STRUC {
-       struct {
-               u32 ShortRtyLimit:8;    /* short retry limit */
-               u32 LongRtyLimit:8;     /* long retry limit */
-               u32 LongRtyThre:12;     /* Long retry threshold */
-               u32 NonAggRtyMode:1;    /* Non-Aggregate MPDU retry mode.  0:expired by retry limit, 1: expired by mpdu life timer */
-               u32 AggRtyMode:1;       /* Aggregate MPDU retry mode.  0:expired by retry limit, 1: expired by mpdu life timer */
-               u32 TxautoFBEnable:1;   /* Tx retry PHY rate auto fallback enable */
-               u32 rsv:1;      /* 1: HT non-STBC control frame enable */
-       } field;
-       u32 word;
-} TX_RTY_CFG_STRUC, *PTX_RTY_CFG_STRUC;
-#define TX_LINK_CFG    0x1350
-typedef union PACKED _TX_LINK_CFG_STRUC {
-       struct PACKED {
-               u32 RemoteMFBLifeTime:8;        /*remote MFB life time. unit : 32us */
-               u32 MFBEnable:1;        /*  TX apply remote MFB 1:enable */
-               u32 RemoteUMFSEnable:1; /*  remote unsolicit  MFB enable.  0: not apply remote remote unsolicit (MFS=7) */
-               u32 TxMRQEn:1;  /*  MCS request TX enable */
-               u32 TxRDGEn:1;  /* RDG TX enable */
-               u32 TxCFAckEn:1;        /*   Piggyback CF-ACK enable */
-               u32 rsv:3;      /* */
-               u32 RemotMFB:8; /*  remote MCS feedback */
-               u32 RemotMFS:8; /*remote MCS feedback sequence number */
-       } field;
-       u32 word;
-} TX_LINK_CFG_STRUC, *PTX_LINK_CFG_STRUC;
-#define HT_FBK_CFG0    0x1354
-typedef union PACKED _HT_FBK_CFG0_STRUC {
-       struct {
-               u32 HTMCS0FBK:4;
-               u32 HTMCS1FBK:4;
-               u32 HTMCS2FBK:4;
-               u32 HTMCS3FBK:4;
-               u32 HTMCS4FBK:4;
-               u32 HTMCS5FBK:4;
-               u32 HTMCS6FBK:4;
-               u32 HTMCS7FBK:4;
-       } field;
-       u32 word;
-} HT_FBK_CFG0_STRUC, *PHT_FBK_CFG0_STRUC;
-#define HT_FBK_CFG1    0x1358
-typedef union _HT_FBK_CFG1_STRUC {
-       struct {
-               u32 HTMCS8FBK:4;
-               u32 HTMCS9FBK:4;
-               u32 HTMCS10FBK:4;
-               u32 HTMCS11FBK:4;
-               u32 HTMCS12FBK:4;
-               u32 HTMCS13FBK:4;
-               u32 HTMCS14FBK:4;
-               u32 HTMCS15FBK:4;
-       } field;
-       u32 word;
-} HT_FBK_CFG1_STRUC, *PHT_FBK_CFG1_STRUC;
-#define LG_FBK_CFG0    0x135c
-typedef union _LG_FBK_CFG0_STRUC {
-       struct {
-               u32 OFDMMCS0FBK:4;      /*initial value is 0 */
-               u32 OFDMMCS1FBK:4;      /*initial value is 0 */
-               u32 OFDMMCS2FBK:4;      /*initial value is 1 */
-               u32 OFDMMCS3FBK:4;      /*initial value is 2 */
-               u32 OFDMMCS4FBK:4;      /*initial value is 3 */
-               u32 OFDMMCS5FBK:4;      /*initial value is 4 */
-               u32 OFDMMCS6FBK:4;      /*initial value is 5 */
-               u32 OFDMMCS7FBK:4;      /*initial value is 6 */
-       } field;
-       u32 word;
-} LG_FBK_CFG0_STRUC, *PLG_FBK_CFG0_STRUC;
-#define LG_FBK_CFG1            0x1360
-typedef union _LG_FBK_CFG1_STRUC {
-       struct {
-               u32 CCKMCS0FBK:4;       /*initial value is 0 */
-               u32 CCKMCS1FBK:4;       /*initial value is 0 */
-               u32 CCKMCS2FBK:4;       /*initial value is 1 */
-               u32 CCKMCS3FBK:4;       /*initial value is 2 */
-               u32 rsv:16;
-       } field;
-       u32 word;
-} LG_FBK_CFG1_STRUC, *PLG_FBK_CFG1_STRUC;
-
-/*======================================================= */
-/*================ Protection Paramater================================ */
-/*======================================================= */
-#define CCK_PROT_CFG   0x1364  /*CCK Protection */
-#define ASIC_SHORTNAV          1
-#define ASIC_longNAV           2
-#define ASIC_RTS               1
-#define ASIC_CTS               2
-typedef union _PROT_CFG_STRUC {
-       struct {
-               u32 ProtectRate:16;     /*Protection control frame rate for CCK TX(RTS/CTS/CFEnd). */
-               u32 ProtectCtrl:2;      /*Protection control frame type for CCK TX. 1:RTS/CTS, 2:CTS-to-self, 0:None, 3:rsv */
-               u32 ProtectNav:2;       /*TXOP protection type for CCK TX. 0:None, 1:ShortNAVprotect,  2:LongNAVProtect, 3:rsv */
-               u32 TxopAllowCck:1;     /*CCK TXOP allowance.0:disallow. */
-               u32 TxopAllowOfdm:1;    /*CCK TXOP allowance.0:disallow. */
-               u32 TxopAllowMM20:1;    /*CCK TXOP allowance. 0:disallow. */
-               u32 TxopAllowMM40:1;    /*CCK TXOP allowance.0:disallow. */
-               u32 TxopAllowGF20:1;    /*CCK TXOP allowance.0:disallow. */
-               u32 TxopAllowGF40:1;    /*CCK TXOP allowance.0:disallow. */
-               u32 RTSThEn:1;  /*RTS threshold enable on CCK TX */
-               u32 rsv:5;
-       } field;
-       u32 word;
-} PROT_CFG_STRUC, *PPROT_CFG_STRUC;
-
-#define OFDM_PROT_CFG  0x1368  /*OFDM Protection */
-#define MM20_PROT_CFG  0x136C  /*MM20 Protection */
-#define MM40_PROT_CFG  0x1370  /*MM40 Protection */
-#define GF20_PROT_CFG  0x1374  /*GF20 Protection */
-#define GF40_PROT_CFG  0x1378  /*GR40 Protection */
-#define EXP_CTS_TIME   0x137C  /* */
-#define EXP_ACK_TIME   0x1380  /* */
-
-/* */
-/*  4.4 MAC RX configuration registers (offset:0x1400) */
-/* */
-#define RX_FILTR_CFG   0x1400  /*TXRX_CSR0 */
-#define AUTO_RSP_CFG   0x1404  /*TXRX_CSR4 */
-/* */
-/* TXRX_CSR4: Auto-Responder/ */
-/* */
-typedef union _AUTO_RSP_CFG_STRUC {
-       struct {
-               u32 AutoResponderEnable:1;
-               u32 BACAckPolicyEnable:1;       /* 0:long, 1:short preamble */
-               u32 CTS40MMode:1;       /* Response CTS 40MHz duplicate mode */
-               u32 CTS40MRef:1;        /* Response CTS 40MHz duplicate mode */
-               u32 AutoResponderPreamble:1;    /* 0:long, 1:short preamble */
-               u32 rsv:1;      /* Power bit value in conrtrol frame */
-               u32 DualCTSEn:1;        /* Power bit value in conrtrol frame */
-               u32 AckCtsPsmBit:1;     /* Power bit value in conrtrol frame */
-               u32: 24;
-       } field;
-       u32 word;
-} AUTO_RSP_CFG_STRUC, *PAUTO_RSP_CFG_STRUC;
-
-#define LEGACY_BASIC_RATE      0x1408  /*  TXRX_CSR5           0x3054 */
-#define HT_BASIC_RATE          0x140c
-#define HT_CTRL_CFG            0x1410
-#define SIFS_COST_CFG          0x1414
-#define RX_PARSER_CFG          0x1418  /*Set NAV for all received frames */
-
-/* */
-/*  4.5 MAC Security configuration (offset:0x1500) */
-/* */
-#define TX_SEC_CNT0            0x1500  /* */
-#define RX_SEC_CNT0            0x1504  /* */
-#define CCMP_FC_MUTE           0x1508  /* */
-/* */
-/*  4.6 HCCA/PSMP (offset:0x1600) */
-/* */
-#define TXOP_HLDR_ADDR0                0x1600
-#define TXOP_HLDR_ADDR1                0x1604
-#define TXOP_HLDR_ET           0x1608
-#define QOS_CFPOLL_RA_DW0              0x160c
-#define QOS_CFPOLL_A1_DW1              0x1610
-#define QOS_CFPOLL_QC          0x1614
-/* */
-/*  4.7 MAC Statistis registers (offset:0x1700) */
-/* */
-#define RX_STA_CNT0            0x1700  /* */
-#define RX_STA_CNT1            0x1704  /* */
-#define RX_STA_CNT2            0x1708  /* */
-
-/* */
-/* RX_STA_CNT0_STRUC: RX PLCP error count & RX CRC error count */
-/* */
-typedef union _RX_STA_CNT0_STRUC {
-       struct {
-               u16 CrcErr;
-               u16 PhyErr;
-       } field;
-       u32 word;
-} RX_STA_CNT0_STRUC, *PRX_STA_CNT0_STRUC;
-
-/* */
-/* RX_STA_CNT1_STRUC: RX False CCA count & RX long frame count */
-/* */
-typedef union _RX_STA_CNT1_STRUC {
-       struct {
-               u16 FalseCca;
-               u16 PlcpErr;
-       } field;
-       u32 word;
-} RX_STA_CNT1_STRUC, *PRX_STA_CNT1_STRUC;
-
-/* */
-/* RX_STA_CNT2_STRUC: */
-/* */
-typedef union _RX_STA_CNT2_STRUC {
-       struct {
-               u16 RxDupliCount;
-               u16 RxFifoOverflowCount;
-       } field;
-       u32 word;
-} RX_STA_CNT2_STRUC, *PRX_STA_CNT2_STRUC;
-#define TX_STA_CNT0            0x170C  /* */
-/* */
-/* STA_CSR3: TX Beacon count */
-/* */
-typedef union _TX_STA_CNT0_STRUC {
-       struct {
-               u16 TxFailCount;
-               u16 TxBeaconCount;
-       } field;
-       u32 word;
-} TX_STA_CNT0_STRUC, *PTX_STA_CNT0_STRUC;
-#define TX_STA_CNT1            0x1710  /* */
-/* */
-/* TX_STA_CNT1: TX tx count */
-/* */
-typedef union _TX_STA_CNT1_STRUC {
-       struct {
-               u16 TxSuccess;
-               u16 TxRetransmit;
-       } field;
-       u32 word;
-} TX_STA_CNT1_STRUC, *PTX_STA_CNT1_STRUC;
-#define TX_STA_CNT2            0x1714  /* */
-/* */
-/* TX_STA_CNT2: TX tx count */
-/* */
-typedef union _TX_STA_CNT2_STRUC {
-       struct {
-               u16 TxZeroLenCount;
-               u16 TxUnderFlowCount;
-       } field;
-       u32 word;
-} TX_STA_CNT2_STRUC, *PTX_STA_CNT2_STRUC;
-#define TX_STA_FIFO            0x1718  /* */
-/* */
-/* TX_STA_FIFO_STRUC: TX Result for specific PID status fifo register */
-/* */
-typedef union PACKED _TX_STA_FIFO_STRUC {
-       struct {
-               u32 bValid:1;   /* 1:This register contains a valid TX result */
-               u32 PidType:4;
-               u32 TxSuccess:1;        /* Tx No retry success */
-               u32 TxAggre:1;  /* Tx Retry Success */
-               u32 TxAckRequired:1;    /* Tx fail */
-               u32 wcid:8;     /*wireless client index */
-/*              u32          SuccessRate:16; //include MCS, mode ,shortGI, BW settingSame format as TXWI Word 0 Bit 31-16. */
-               u32 SuccessRate:13;     /*include MCS, mode ,shortGI, BW settingSame format as TXWI Word 0 Bit 31-16. */
-               u32 TxBF:1;
-               u32 Reserve:2;
-       } field;
-       u32 word;
-} TX_STA_FIFO_STRUC, *PTX_STA_FIFO_STRUC;
-/* Debug counter */
-#define TX_AGG_CNT     0x171c
-typedef union _TX_AGG_CNT_STRUC {
-       struct {
-               u16 NonAggTxCount;
-               u16 AggTxCount;
-       } field;
-       u32 word;
-} TX_AGG_CNT_STRUC, *PTX_AGG_CNT_STRUC;
-/* Debug counter */
-#define TX_AGG_CNT0    0x1720
-typedef union _TX_AGG_CNT0_STRUC {
-       struct {
-               u16 AggSize1Count;
-               u16 AggSize2Count;
-       } field;
-       u32 word;
-} TX_AGG_CNT0_STRUC, *PTX_AGG_CNT0_STRUC;
-/* Debug counter */
-#define TX_AGG_CNT1    0x1724
-typedef union _TX_AGG_CNT1_STRUC {
-       struct {
-               u16 AggSize3Count;
-               u16 AggSize4Count;
-       } field;
-       u32 word;
-} TX_AGG_CNT1_STRUC, *PTX_AGG_CNT1_STRUC;
-#define TX_AGG_CNT2    0x1728
-typedef union _TX_AGG_CNT2_STRUC {
-       struct {
-               u16 AggSize5Count;
-               u16 AggSize6Count;
-       } field;
-       u32 word;
-} TX_AGG_CNT2_STRUC, *PTX_AGG_CNT2_STRUC;
-/* Debug counter */
-#define TX_AGG_CNT3    0x172c
-typedef union _TX_AGG_CNT3_STRUC {
-       struct {
-               u16 AggSize7Count;
-               u16 AggSize8Count;
-       } field;
-       u32 word;
-} TX_AGG_CNT3_STRUC, *PTX_AGG_CNT3_STRUC;
-/* Debug counter */
-#define TX_AGG_CNT4    0x1730
-typedef union _TX_AGG_CNT4_STRUC {
-       struct {
-               u16 AggSize9Count;
-               u16 AggSize10Count;
-       } field;
-       u32 word;
-} TX_AGG_CNT4_STRUC, *PTX_AGG_CNT4_STRUC;
-#define TX_AGG_CNT5    0x1734
-typedef union _TX_AGG_CNT5_STRUC {
-       struct {
-               u16 AggSize11Count;
-               u16 AggSize12Count;
-       } field;
-       u32 word;
-} TX_AGG_CNT5_STRUC, *PTX_AGG_CNT5_STRUC;
-#define TX_AGG_CNT6            0x1738
-typedef union _TX_AGG_CNT6_STRUC {
-       struct {
-               u16 AggSize13Count;
-               u16 AggSize14Count;
-       } field;
-       u32 word;
-} TX_AGG_CNT6_STRUC, *PTX_AGG_CNT6_STRUC;
-#define TX_AGG_CNT7            0x173c
-typedef union _TX_AGG_CNT7_STRUC {
-       struct {
-               u16 AggSize15Count;
-               u16 AggSize16Count;
-       } field;
-       u32 word;
-} TX_AGG_CNT7_STRUC, *PTX_AGG_CNT7_STRUC;
-#define MPDU_DENSITY_CNT               0x1740
-typedef union _MPDU_DEN_CNT_STRUC {
-       struct {
-               u16 TXZeroDelCount;     /*TX zero length delimiter count */
-               u16 RXZeroDelCount;     /*RX zero length delimiter count */
-       } field;
-       u32 word;
-} MPDU_DEN_CNT_STRUC, *PMPDU_DEN_CNT_STRUC;
-/* */
-/* TXRX control registers - base address 0x3000 */
-/* */
-/* rt2860b  UNKNOWN reg use R/O Reg Addr 0x77d0 first.. */
-#define TXRX_CSR1           0x77d0
-
-/* */
-/* Security key table memory, base address = 0x1000 */
-/* */
-#define MAC_WCID_BASE          0x1800  /*8-bytes(use only 6-bytes) * 256 entry = */
-#define HW_WCID_ENTRY_SIZE   8
-#define PAIRWISE_KEY_TABLE_BASE     0x4000     /* 32-byte * 256-entry =  -byte */
-#define HW_KEY_ENTRY_SIZE           0x20
-#define PAIRWISE_IVEIV_TABLE_BASE     0x6000   /* 8-byte * 256-entry =  -byte */
-#define MAC_IVEIV_TABLE_BASE     0x6000        /* 8-byte * 256-entry =  -byte */
-#define HW_IVEIV_ENTRY_SIZE   8
-#define MAC_WCID_ATTRIBUTE_BASE     0x6800     /* 4-byte * 256-entry =  -byte */
-#define HW_WCID_ATTRI_SIZE   4
-#define WCID_RESERVED                  0x6bfc
-#define SHARED_KEY_TABLE_BASE       0x6c00     /* 32-byte * 16-entry = 512-byte */
-#define SHARED_KEY_MODE_BASE       0x7000      /* 32-byte * 16-entry = 512-byte */
-#define HW_SHARED_KEY_MODE_SIZE   4
-#define SHAREDKEYTABLE                 0
-#define PAIRWISEKEYTABLE                       1
-
-typedef union _SHAREDKEY_MODE_STRUC {
-       struct {
-               u32 Bss0Key0CipherAlg:3;
-               u32: 1;
-               u32 Bss0Key1CipherAlg:3;
-               u32: 1;
-               u32 Bss0Key2CipherAlg:3;
-               u32: 1;
-               u32 Bss0Key3CipherAlg:3;
-               u32: 1;
-               u32 Bss1Key0CipherAlg:3;
-               u32: 1;
-               u32 Bss1Key1CipherAlg:3;
-               u32: 1;
-               u32 Bss1Key2CipherAlg:3;
-               u32: 1;
-               u32 Bss1Key3CipherAlg:3;
-               u32: 1;
-       } field;
-       u32 word;
-} SHAREDKEY_MODE_STRUC, *PSHAREDKEY_MODE_STRUC;
-
-/* 8-byte per entry, 64-entry for pairwise key table */
-struct rt_hw_wcid_entry {
-       u8 Address[6];
-       u8 Rsv[2];
-};
-
-/* ================================================================================= */
-/* WCID  format */
-/* ================================================================================= */
-/*7.1   WCID  ENTRY  format  : 8bytes */
-struct rt_wcid_entry {
-       u8 RXBABitmap7; /* bit0 for TID8, bit7 for TID 15 */
-       u8 RXBABitmap0; /* bit0 for TID0, bit7 for TID 7 */
-       u8 MAC[6];              /* 0 for shared key table.  1 for pairwise key table */
-};
-
-/*8.1.1 SECURITY  KEY  format  : 8DW */
-/* 32-byte per entry, total 16-entry for shared key table, 64-entry for pairwise key table */
-struct rt_hw_key_entry {
-       u8 Key[16];
-       u8 TxMic[8];
-       u8 RxMic[8];
-};
-
-/*8.1.2 IV/EIV  format  : 2DW */
-
-/*8.1.3 RX attribute entry format  : 1DW */
-struct rt_mac_attribute {
-       u32 KeyTab:1;   /* 0 for shared key table.  1 for pairwise key table */
-       u32 PairKeyMode:3;
-       u32 BSSIDIdx:3; /*multipleBSS index for the WCID */
-       u32 RXWIUDF:3;
-       u32 rsv:22;
-};
-
-/* ================================================================================= */
-/* HOST-MCU communication data structure */
-/* ================================================================================= */
-
-/* */
-/* H2M_MAILBOX_CSR: Host-to-MCU Mailbox */
-/* */
-typedef union _H2M_MAILBOX_STRUC {
-       struct {
-               u32 LowByte:8;
-               u32 HighByte:8;
-               u32 CmdToken:8;
-               u32 Owner:8;
-       } field;
-       u32 word;
-} H2M_MAILBOX_STRUC, *PH2M_MAILBOX_STRUC;
-
-/* */
-/* M2H_CMD_DONE_CSR: MCU-to-Host command complete indication */
-/* */
-typedef union _M2H_CMD_DONE_STRUC {
-       struct {
-               u32 CmdToken0;
-               u32 CmdToken1;
-               u32 CmdToken2;
-               u32 CmdToken3;
-       } field;
-       u32 word;
-} M2H_CMD_DONE_STRUC, *PM2H_CMD_DONE_STRUC;
-
-/*NAV_TIME_CFG :NAV */
-typedef union _NAV_TIME_CFG_STRUC {
-       struct {
-               u8 Sifs;        /* in unit of 1-us */
-               u8 SlotTime;    /* in unit of 1-us */
-               u16 Eifs:9;     /* in unit of 1-us */
-               u16 ZeroSifs:1; /* Applied zero SIFS timer after OFDM RX 0: disable */
-               u16 rsv:6;
-       } field;
-       u32 word;
-} NAV_TIME_CFG_STRUC, *PNAV_TIME_CFG_STRUC;
-
-/* */
-/* RX_FILTR_CFG:  /RX configuration register */
-/* */
-typedef union _RX_FILTR_CFG_STRUC {
-       struct {
-               u32 DropCRCErr:1;       /* Drop CRC error */
-               u32 DropPhyErr:1;       /* Drop physical error */
-               u32 DropNotToMe:1;      /* Drop not to me unicast frame */
-               u32 DropNotMyBSSID:1;   /* Drop fram ToDs bit is true */
-
-               u32 DropVerErr:1;       /* Drop version error frame */
-               u32 DropMcast:1;        /* Drop multicast frames */
-               u32 DropBcast:1;        /* Drop broadcast frames */
-               u32 DropDuplicate:1;    /* Drop duplicate frame */
-
-               u32 DropCFEndAck:1;     /* Drop Ps-Poll */
-               u32 DropCFEnd:1;        /* Drop Ps-Poll */
-               u32 DropAck:1;  /* Drop Ps-Poll */
-               u32 DropCts:1;  /* Drop Ps-Poll */
-
-               u32 DropRts:1;  /* Drop Ps-Poll */
-               u32 DropPsPoll:1;       /* Drop Ps-Poll */
-               u32 DropBA:1;   /* */
-               u32 DropBAR:1;  /* */
-
-               u32 DropRsvCntlType:1;
-               u32: 15;
-       } field;
-       u32 word;
-} RX_FILTR_CFG_STRUC, *PRX_FILTR_CFG_STRUC;
-
-/* */
-/* PHY_CSR4: RF serial control register */
-/* */
-typedef union _PHY_CSR4_STRUC {
-       struct {
-               u32 RFRegValue:24;      /* Register     value (include register id)     serial out to RF/IF     chip. */
-               u32 NumberOfBits:5;     /* Number of bits used in RFRegValue (I:20,     RFMD:22) */
-               u32 IFSelect:1; /* 1: select IF to program,     0: select RF to program */
-               u32 PLL_LD:1;   /* RF PLL_LD status */
-               u32 Busy:1;     /* 1: ASIC is busy execute RF programming. */
-       } field;
-       u32 word;
-} PHY_CSR4_STRUC, *PPHY_CSR4_STRUC;
-
-/* */
-/* SEC_CSR5: shared key table security mode register */
-/* */
-typedef union _SEC_CSR5_STRUC {
-       struct {
-               u32 Bss2Key0CipherAlg:3;
-               u32: 1;
-               u32 Bss2Key1CipherAlg:3;
-               u32: 1;
-               u32 Bss2Key2CipherAlg:3;
-               u32: 1;
-               u32 Bss2Key3CipherAlg:3;
-               u32: 1;
-               u32 Bss3Key0CipherAlg:3;
-               u32: 1;
-               u32 Bss3Key1CipherAlg:3;
-               u32: 1;
-               u32 Bss3Key2CipherAlg:3;
-               u32: 1;
-               u32 Bss3Key3CipherAlg:3;
-               u32: 1;
-       } field;
-       u32 word;
-} SEC_CSR5_STRUC, *PSEC_CSR5_STRUC;
-
-/* */
-/* HOST_CMD_CSR: For HOST to interrupt embedded processor */
-/* */
-typedef union _HOST_CMD_CSR_STRUC {
-       struct {
-               u32 HostCommand:8;
-               u32 Rsv:24;
-       } field;
-       u32 word;
-} HOST_CMD_CSR_STRUC, *PHOST_CMD_CSR_STRUC;
-
-/* */
-/* AIFSN_CSR: AIFSN for each EDCA AC */
-/* */
-
-/* */
-/* E2PROM_CSR: EEPROM control register */
-/* */
-typedef union _E2PROM_CSR_STRUC {
-       struct {
-               u32 Reload:1;   /* Reload EEPROM content, write one to reload, self-cleared. */
-               u32 EepromSK:1;
-               u32 EepromCS:1;
-               u32 EepromDI:1;
-               u32 EepromDO:1;
-               u32 Type:1;     /* 1: 93C46, 0:93C66 */
-               u32 LoadStatus:1;       /* 1:loading, 0:done */
-               u32 Rsvd:25;
-       } field;
-       u32 word;
-} E2PROM_CSR_STRUC, *PE2PROM_CSR_STRUC;
-
-/* */
-/* QOS_CSR0: TXOP holder address0 register */
-/* */
-typedef union _QOS_CSR0_STRUC {
-       struct {
-               u8 Byte0;       /* MAC address byte 0 */
-               u8 Byte1;       /* MAC address byte 1 */
-               u8 Byte2;       /* MAC address byte 2 */
-               u8 Byte3;       /* MAC address byte 3 */
-       } field;
-       u32 word;
-} QOS_CSR0_STRUC, *PQOS_CSR0_STRUC;
-
-/* */
-/* QOS_CSR1: TXOP holder address1 register */
-/* */
-typedef union _QOS_CSR1_STRUC {
-       struct {
-               u8 Byte4;       /* MAC address byte 4 */
-               u8 Byte5;       /* MAC address byte 5 */
-               u8 Rsvd0;
-               u8 Rsvd1;
-       } field;
-       u32 word;
-} QOS_CSR1_STRUC, *PQOS_CSR1_STRUC;
-
-#define        RF_CSR_CFG      0x500
-typedef union _RF_CSR_CFG_STRUC {
-       struct {
-               u32 RF_CSR_DATA:8;      /* DATA */
-               u32 TESTCSR_RFACC_REGNUM:5;     /* RF register ID */
-               u32 Rsvd2:3;    /* Reserved */
-               u32 RF_CSR_WR:1;        /* 0: read  1: write */
-               u32 RF_CSR_KICK:1;      /* kick RF register read/write */
-               u32 Rsvd1:14;   /* Reserved */
-       } field;
-       u32 word;
-} RF_CSR_CFG_STRUC, *PRF_CSR_CFG_STRUC;
-
-/* */
-/* Other on-chip shared memory space, base = 0x2000 */
-/* */
-
-/* CIS space - base address = 0x2000 */
-#define HW_CIS_BASE             0x2000
-
-/* Carrier-sense CTS frame base address. It's where mac stores carrier-sense frame for carrier-sense function. */
-#define HW_CS_CTS_BASE                 0x7700
-/* DFS CTS frame base address. It's where mac stores CTS frame for DFS. */
-#define HW_DFS_CTS_BASE                        0x7780
-#define HW_CTS_FRAME_SIZE              0x80
-
-/* 2004-11-08 john - since NULL frame won't be that long (256 byte). We steal 16 tail bytes */
-/* to save debugging settings */
-#define HW_DEBUG_SETTING_BASE   0x77f0 /* 0x77f0~0x77ff total 16 bytes */
-#define HW_DEBUG_SETTING_BASE2   0x7770        /* 0x77f0~0x77ff total 16 bytes */
-
-/* In order to support maximum 8 MBSS and its maximum length is 512 for each beacon */
-/* Three section discontinue memory segments will be used. */
-/* 1. The original region for BCN 0~3 */
-/* 2. Extract memory from FCE table for BCN 4~5 */
-/* 3. Extract memory from Pair-wise key table for BCN 6~7 */
-/*        It occupied those memory of wcid 238~253 for BCN 6 */
-/*                                                    and wcid 222~237 for BCN 7 */
-#define HW_BEACON_MAX_SIZE      0x1000 /* unit: byte */
-#define HW_BEACON_BASE0         0x7800
-#define HW_BEACON_BASE1         0x7A00
-#define HW_BEACON_BASE2         0x7C00
-#define HW_BEACON_BASE3         0x7E00
-#define HW_BEACON_BASE4         0x7200
-#define HW_BEACON_BASE5         0x7400
-#define HW_BEACON_BASE6         0x5DC0
-#define HW_BEACON_BASE7         0x5BC0
-
-#define HW_BEACON_MAX_COUNT     8
-#define HW_BEACON_OFFSET               0x0200
-#define HW_BEACON_CONTENT_LEN  (HW_BEACON_OFFSET - TXWI_SIZE)
-
-/* HOST-MCU shared memory - base address = 0x2100 */
-#define HOST_CMD_CSR           0x404
-#define H2M_MAILBOX_CSR         0x7010
-#define H2M_MAILBOX_CID         0x7014
-#define H2M_MAILBOX_STATUS      0x701c
-#define H2M_INT_SRC             0x7024
-#define H2M_BBP_AGENT           0x7028
-#define M2H_CMD_DONE_CSR        0x000c
-#define MCU_TXOP_ARRAY_BASE     0x000c /* TODO: to be provided by Albert */
-#define MCU_TXOP_ENTRY_SIZE     32     /* TODO: to be provided by Albert */
-#define MAX_NUM_OF_TXOP_ENTRY   16     /* TODO: must be same with 8051 firmware */
-#define MCU_MBOX_VERSION        0x01   /* TODO: to be confirmed by Albert */
-#define MCU_MBOX_VERSION_OFFSET 5      /* TODO: to be provided by Albert */
-
-/* */
-/* Host DMA registers - base address 0x200 .  TX0-3=EDCAQid0-3, TX4=HCCA, TX5=MGMT, */
-/* */
-/* */
-/*  DMA RING DESCRIPTOR */
-/* */
-#define E2PROM_CSR          0x0004
-#define IO_CNTL_CSR         0x77d0
-
-/* ================================================================ */
-/* Tx / Rx / Mgmt ring descriptor definition */
-/* ================================================================ */
-
-/* the following PID values are used to mark outgoing frame type in TXD->PID so that */
-/* proper TX statistics can be collected based on these categories */
-/* b3-2 of PID field - */
-#define PID_MGMT                       0x05
-#define PID_BEACON                     0x0c
-#define PID_DATA_NORMALUCAST           0x02
-#define PID_DATA_AMPDU         0x04
-#define PID_DATA_NO_ACK                0x08
-#define PID_DATA_NOT_NORM_ACK          0x03
-/* value domain of pTxD->HostQId (4-bit: 0~15) */
-#define QID_AC_BK               1      /* meet ACI definition in 802.11e */
-#define QID_AC_BE               0      /* meet ACI definition in 802.11e */
-#define QID_AC_VI               2
-#define QID_AC_VO               3
-#define QID_HCCA                4
-#define NUM_OF_TX_RING          4
-#define QID_MGMT                13
-#define QID_RX                  14
-#define QID_OTHER               15
-
-#endif /* __RTMP_MAC_H__ // */
diff --git a/drivers/staging/rt2860/chip/rtmp_phy.h b/drivers/staging/rt2860/chip/rtmp_phy.h
deleted file mode 100644 (file)
index a52221f..0000000
+++ /dev/null
@@ -1,516 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-       Module Name:
-       rtmp_phy.h
-
-       Abstract:
-       Ralink Wireless Chip PHY(BBP/RF) related definition & structures
-
-       Revision History:
-       Who                     When              What
-       --------        ----------        ----------------------------------------------
-*/
-
-#ifndef __RTMP_PHY_H__
-#define __RTMP_PHY_H__
-
-/*
-       RF sections
-*/
-#define RF_R00                 0
-#define RF_R01                 1
-#define RF_R02                 2
-#define RF_R03                 3
-#define RF_R04                 4
-#define RF_R05                 5
-#define RF_R06                 6
-#define RF_R07                 7
-#define RF_R08                 8
-#define RF_R09                 9
-#define RF_R10                 10
-#define RF_R11                 11
-#define RF_R12                 12
-#define RF_R13                 13
-#define RF_R14                 14
-#define RF_R15                 15
-#define RF_R16                 16
-#define RF_R17                 17
-#define RF_R18                 18
-#define RF_R19                 19
-#define RF_R20                 20
-#define RF_R21                 21
-#define RF_R22                 22
-#define RF_R23                 23
-#define RF_R24                 24
-#define RF_R25                 25
-#define RF_R26                 26
-#define RF_R27                 27
-#define RF_R28                 28
-#define RF_R29                 29
-#define RF_R30                 30
-#define RF_R31                 31
-
-/* value domain of pAd->RfIcType */
-#define RFIC_2820                   1  /* 2.4G 2T3R */
-#define RFIC_2850                   2  /* 2.4G/5G 2T3R */
-#define RFIC_2720                   3  /* 2.4G 1T2R */
-#define RFIC_2750                   4  /* 2.4G/5G 1T2R */
-#define RFIC_3020                   5  /* 2.4G 1T1R */
-#define RFIC_2020                   6  /* 2.4G B/G */
-#define RFIC_3021                   7  /* 2.4G 1T2R */
-#define RFIC_3022                   8  /* 2.4G 2T2R */
-#define RFIC_3052                   9  /* 2.4G/5G 2T2R */
-
-/*
-       BBP sections
-*/
-#define BBP_R0                 0       /* version */
-#define BBP_R1                 1       /* TSSI */
-#define BBP_R2                 2       /* TX configure */
-#define BBP_R3                 3
-#define BBP_R4                 4
-#define BBP_R5                 5
-#define BBP_R6                 6
-#define BBP_R14                        14      /* RX configure */
-#define BBP_R16                        16
-#define BBP_R17                        17      /* RX sensibility */
-#define BBP_R18                        18
-#define BBP_R21                        21
-#define BBP_R22                        22
-#define BBP_R24                        24
-#define BBP_R25                        25
-#define BBP_R26                        26
-#define BBP_R27                        27
-#define BBP_R31                        31
-#define BBP_R49                        49      /*TSSI */
-#define BBP_R50                        50
-#define BBP_R51                        51
-#define BBP_R52                        52
-#define BBP_R55                        55
-#define BBP_R62                        62      /* Rx SQ0 Threshold HIGH */
-#define BBP_R63                        63
-#define BBP_R64                        64
-#define BBP_R65                        65
-#define BBP_R66                        66
-#define BBP_R67                        67
-#define BBP_R68                        68
-#define BBP_R69                        69
-#define BBP_R70                        70      /* Rx AGC SQ CCK Xcorr threshold */
-#define BBP_R73                        73
-#define BBP_R75                        75
-#define BBP_R77                        77
-#define BBP_R78                        78
-#define BBP_R79                        79
-#define BBP_R80                        80
-#define BBP_R81                        81
-#define BBP_R82                        82
-#define BBP_R83                        83
-#define BBP_R84                        84
-#define BBP_R86                        86
-#define BBP_R91                        91
-#define BBP_R92                        92
-#define BBP_R94                        94      /* Tx Gain Control */
-#define BBP_R103               103
-#define BBP_R105               105
-#define BBP_R106               106
-#define BBP_R113               113
-#define BBP_R114               114
-#define BBP_R115               115
-#define BBP_R116               116
-#define BBP_R117               117
-#define BBP_R118               118
-#define BBP_R119               119
-#define BBP_R120               120
-#define BBP_R121               121
-#define BBP_R122               122
-#define BBP_R123               123
-#ifdef RT30xx
-#define BBP_R138               138     /* add by johnli, RF power sequence setup, ADC dynamic on/off control */
-#endif /* RT30xx // */
-
-#define BBPR94_DEFAULT 0x06    /* Add 1 value will gain 1db */
-
-/* */
-/* BBP & RF are using indirect access. Before write any value into it. */
-/* We have to make sure there is no outstanding command pending via checking busy bit. */
-/* */
-#define MAX_BUSY_COUNT  100    /* Number of retry before failing access BBP & RF indirect register */
-
-/*#define PHY_TR_SWITCH_TIME          5  // usec */
-
-/*#define BBP_R17_LOW_SENSIBILITY     0x50 */
-/*#define BBP_R17_MID_SENSIBILITY     0x41 */
-/*#define BBP_R17_DYNAMIC_UP_BOUND    0x40 */
-
-#define RSSI_FOR_VERY_LOW_SENSIBILITY   -35
-#define RSSI_FOR_LOW_SENSIBILITY               -58
-#define RSSI_FOR_MID_LOW_SENSIBILITY   -80
-#define RSSI_FOR_MID_SENSIBILITY               -90
-
-/*****************************************************************************
-       RF register Read/Write marco definition
- *****************************************************************************/
-#ifdef RTMP_MAC_PCI
-#define RTMP_RF_IO_WRITE32(_A, _V)                  \
-{                                                                                      \
-       if ((_A)->bPCIclkOff == FALSE) {                                \
-               PHY_CSR4_STRUC  _value;                          \
-               unsigned long           _busyCnt = 0;                    \
-                                                                                       \
-               do {                                            \
-                       RTMP_IO_READ32((_A), RF_CSR_CFG0, &_value.word);  \
-                       if (_value.field.Busy == IDLE)               \
-                               break;                                  \
-                       _busyCnt++;                                  \
-               } while (_busyCnt < MAX_BUSY_COUNT);                    \
-               if (_busyCnt < MAX_BUSY_COUNT) {                        \
-                       RTMP_IO_WRITE32((_A), RF_CSR_CFG0, (_V));          \
-               }                                               \
-       }                                                               \
-}
-#endif /* RTMP_MAC_PCI // */
-#ifdef RTMP_MAC_USB
-#define RTMP_RF_IO_WRITE32(_A, _V)                 RTUSBWriteRFRegister(_A, _V)
-#endif /* RTMP_MAC_USB // */
-
-#ifdef RT30xx
-#define RTMP_RF_IO_READ8_BY_REG_ID(_A, _I, _pV)    RT30xxReadRFRegister(_A, _I, _pV)
-#define RTMP_RF_IO_WRITE8_BY_REG_ID(_A, _I, _V)    RT30xxWriteRFRegister(_A, _I, _V)
-#endif /* RT30xx // */
-
-/*****************************************************************************
-       BBP register Read/Write marco definitions.
-       we read/write the bbp value by register's ID.
-       Generate PER to test BA
- *****************************************************************************/
-#ifdef RTMP_MAC_PCI
-/*
-       basic marco for BBP read operation.
-       _pAd: the data structure pointer of struct rt_rtmp_adapter
-       _bbpID : the bbp register ID
-       _pV: data pointer used to save the value of queried bbp register.
-       _bViaMCU: if we need access the bbp via the MCU.
-*/
-#define RTMP_BBP_IO_READ8(_pAd, _bbpID, _pV, _bViaMCU)                 \
-       do {                                                            \
-               BBP_CSR_CFG_STRUC  BbpCsr;                              \
-               int   _busyCnt, _secCnt, _regID;                        \
-                                                                       \
-               _regID = ((_bViaMCU) == TRUE ? H2M_BBP_AGENT : BBP_CSR_CFG); \
-               for (_busyCnt = 0; _busyCnt < MAX_BUSY_COUNT; _busyCnt++) { \
-                       RTMP_IO_READ32(_pAd, _regID, &BbpCsr.word);     \
-                       if (BbpCsr.field.Busy == BUSY)                  \
-                               continue;                               \
-                       BbpCsr.word = 0;                                \
-                       BbpCsr.field.fRead = 1;                         \
-                       BbpCsr.field.BBP_RW_MODE = 1;                   \
-                       BbpCsr.field.Busy = 1;                          \
-                       BbpCsr.field.RegNum = _bbpID;                   \
-                       RTMP_IO_WRITE32(_pAd, _regID, BbpCsr.word);     \
-                       if ((_bViaMCU) == TRUE) {                       \
-                           AsicSendCommandToMcu(_pAd, 0x80, 0xff, 0x0, 0x0); \
-                           RTMPusecDelay(1000);        \
-                       }                                               \
-                       for (_secCnt = 0; _secCnt < MAX_BUSY_COUNT; _secCnt++) { \
-                               RTMP_IO_READ32(_pAd, _regID, &BbpCsr.word); \
-                               if (BbpCsr.field.Busy == IDLE)          \
-                                       break;                          \
-                       }                                               \
-                       if ((BbpCsr.field.Busy == IDLE) &&              \
-                               (BbpCsr.field.RegNum == _bbpID)) {      \
-                               *(_pV) = (u8)BbpCsr.field.Value;        \
-                               break;                                  \
-                       }                                               \
-               }                                                       \
-               if (BbpCsr.field.Busy == BUSY) {                        \
-                       DBGPRINT_ERR("BBP(viaMCU=%d) read R%d fail\n", (_bViaMCU), _bbpID);     \
-                       *(_pV) = (_pAd)->BbpWriteLatch[_bbpID];               \
-                       if ((_bViaMCU) == TRUE) {                       \
-                               RTMP_IO_READ32(_pAd, _regID, &BbpCsr.word);                             \
-                               BbpCsr.field.Busy = 0;                          \
-                               RTMP_IO_WRITE32(_pAd, _regID, BbpCsr.word);                             \
-                       }                               \
-               }                                                                                                       \
-       } while (0)
-
-/*
-       This marco used for the BBP read operation which didn't need via MCU.
-*/
-#define BBP_IO_READ8_BY_REG_ID(_A, _I, _pV)                    \
-       RTMP_BBP_IO_READ8((_A), (_I), (_pV), FALSE)
-
-/*
-       This marco used for the BBP read operation which need via MCU.
-       But for some chipset which didn't have mcu (e.g., RBUS based chipset), we
-       will use this function too and didn't access the bbp register via the MCU.
-*/
-/* Read BBP register by register's ID. Generate PER to test BA */
-#define RTMP_BBP_IO_READ8_BY_REG_ID(_A, _I, _pV)                                               \
-{                                                                                                                                              \
-       BBP_CSR_CFG_STRUC       BbpCsr;                                                                                 \
-       int                                     i, k;                   \
-       BOOLEAN                                 brc;                    \
-       BbpCsr.field.Busy = IDLE;                       \
-       if ((IS_RT3090((_A)) || IS_RT3572((_A)) || IS_RT3390((_A)))  \
-               && ((_A)->StaCfg.PSControl.field.rt30xxPowerMode == 3)  \
-               && ((_A)->StaCfg.PSControl.field.EnableNewPS == TRUE)   \
-               && ((_A)->bPCIclkOff == FALSE)  \
-               && ((_A)->brt30xxBanMcuCmd == FALSE)) {                 \
-               for (i = 0; i < MAX_BUSY_COUNT; i++) {                  \
-                       RTMP_IO_READ32(_A, H2M_BBP_AGENT, &BbpCsr.word); \
-                       if (BbpCsr.field.Busy == BUSY) {                \
-                               continue;                               \
-                       }                                               \
-                       BbpCsr.word = 0;                                \
-                       BbpCsr.field.fRead = 1;                         \
-                       BbpCsr.field.BBP_RW_MODE = 1;                   \
-                       BbpCsr.field.Busy = 1;                          \
-                       BbpCsr.field.RegNum = _I;                       \
-                       RTMP_IO_WRITE32(_A, H2M_BBP_AGENT, BbpCsr.word); \
-                       brc = AsicSendCommandToMcu(_A, 0x80, 0xff, 0x0, 0x0); \
-                       if (brc == TRUE) {                              \
-                               for (k = 0; k < MAX_BUSY_COUNT; k++) {  \
-                                       RTMP_IO_READ32(_A, H2M_BBP_AGENT, &BbpCsr.word); \
-                                       if (BbpCsr.field.Busy == IDLE)  \
-                                               break;                  \
-                               }                                       \
-                               if ((BbpCsr.field.Busy == IDLE) &&      \
-                                       (BbpCsr.field.RegNum == _I)) {  \
-                                       *(_pV) = (u8)BbpCsr.field.Value; \
-                                       break;                          \
-                               }                                       \
-                       } else {                                        \
-                               BbpCsr.field.Busy = 0;                                                                                  \
-                               RTMP_IO_WRITE32(_A, H2M_BBP_AGENT, BbpCsr.word);                                \
-                       }                                                                                                                               \
-               }                                                                                                                                       \
-       }       \
-       else if (!((IS_RT3090((_A)) || IS_RT3572((_A)) || IS_RT3390((_A))) && ((_A)->StaCfg.PSControl.field.rt30xxPowerMode == 3)       \
-               && ((_A)->StaCfg.PSControl.field.EnableNewPS == TRUE))  \
-               && ((_A)->bPCIclkOff == FALSE)) {                       \
-               for (i = 0; i < MAX_BUSY_COUNT; i++) {                  \
-                       RTMP_IO_READ32(_A, H2M_BBP_AGENT, &BbpCsr.word); \
-                       if (BbpCsr.field.Busy == BUSY) {                \
-                               continue;                               \
-                       }                                               \
-                       BbpCsr.word = 0;                                \
-                       BbpCsr.field.fRead = 1;                         \
-                       BbpCsr.field.BBP_RW_MODE = 1;                   \
-                       BbpCsr.field.Busy = 1;                          \
-                       BbpCsr.field.RegNum = _I;                       \
-                       RTMP_IO_WRITE32(_A, H2M_BBP_AGENT, BbpCsr.word); \
-                       AsicSendCommandToMcu(_A, 0x80, 0xff, 0x0, 0x0); \
-                       for (k = 0; k < MAX_BUSY_COUNT; k++) {          \
-                               RTMP_IO_READ32(_A, H2M_BBP_AGENT, &BbpCsr.word); \
-                               if (BbpCsr.field.Busy == IDLE)          \
-                                       break;                          \
-                       }                                               \
-                       if ((BbpCsr.field.Busy == IDLE) &&              \
-                               (BbpCsr.field.RegNum == _I)) {          \
-                               *(_pV) = (u8)BbpCsr.field.Value;        \
-                               break;                                  \
-                       }                                               \
-               }                                                       \
-       } else {                                                        \
-               DBGPRINT_ERR(" , brt30xxBanMcuCmd = %d, Read BBP %d \n", (_A)->brt30xxBanMcuCmd, (_I)); \
-               *(_pV) = (_A)->BbpWriteLatch[_I];                       \
-       }                                                               \
-       if ((BbpCsr.field.Busy == BUSY) || ((_A)->bPCIclkOff == TRUE)) { \
-               DBGPRINT_ERR("BBP read R%d=0x%x fail\n", _I, BbpCsr.word); \
-               *(_pV) = (_A)->BbpWriteLatch[_I];                       \
-       }                                                               \
-}
-
-/*
-       basic marco for BBP write operation.
-       _pAd: the data structure pointer of struct rt_rtmp_adapter
-       _bbpID : the bbp register ID
-       _pV: data used to save the value of queried bbp register.
-       _bViaMCU: if we need access the bbp via the MCU.
-*/
-#define RTMP_BBP_IO_WRITE8(_pAd, _bbpID, _pV, _bViaMCU)                        \
-       do {                                                            \
-               BBP_CSR_CFG_STRUC  BbpCsr;                             \
-               int             _busyCnt, _regID;                       \
-                                                                       \
-               _regID = ((_bViaMCU) == TRUE ? H2M_BBP_AGENT : BBP_CSR_CFG);    \
-               for (_busyCnt = 0; _busyCnt < MAX_BUSY_COUNT; _busyCnt++) { \
-                       RTMP_IO_READ32((_pAd), BBP_CSR_CFG, &BbpCsr.word);     \
-                       if (BbpCsr.field.Busy == BUSY)                  \
-                               continue;                               \
-                       BbpCsr.word = 0;                                \
-                       BbpCsr.field.fRead = 0;                         \
-                       BbpCsr.field.BBP_RW_MODE = 1;                   \
-                       BbpCsr.field.Busy = 1;                          \
-                       BbpCsr.field.Value = _pV;                       \
-                       BbpCsr.field.RegNum = _bbpID;                   \
-                       RTMP_IO_WRITE32((_pAd), BBP_CSR_CFG, BbpCsr.word); \
-                       if ((_bViaMCU) == TRUE) {                       \
-                               AsicSendCommandToMcu(_pAd, 0x80, 0xff, 0x0, 0x0); \
-                               if ((_pAd)->OpMode == OPMODE_AP)        \
-                                       RTMPusecDelay(1000);            \
-                       }                                               \
-                       (_pAd)->BbpWriteLatch[_bbpID] = _pV;            \
-                       break;                                          \
-               }                                                       \
-               if (_busyCnt == MAX_BUSY_COUNT) {                       \
-                       DBGPRINT_ERR("BBP write R%d fail\n", _bbpID);   \
-                       if ((_bViaMCU) == TRUE) {                       \
-                               RTMP_IO_READ32(_pAd, H2M_BBP_AGENT, &BbpCsr.word);      \
-                               BbpCsr.field.Busy = 0;                  \
-                               RTMP_IO_WRITE32(_pAd, H2M_BBP_AGENT, BbpCsr.word);      \
-                       }                                               \
-               }                                                       \
-       } while (0)
-
-/*
-       This marco used for the BBP write operation which didn't need via MCU.
-*/
-#define BBP_IO_WRITE8_BY_REG_ID(_A, _I, _pV)                   \
-       RTMP_BBP_IO_WRITE8((_A), (_I), (_pV), FALSE)
-
-/*
-       This marco used for the BBP write operation which need via MCU.
-       But for some chipset which didn't have mcu (e.g., RBUS based chipset), we
-       will use this function too and didn't access the bbp register via the MCU.
-*/
-/* Write BBP register by register's ID & value */
-#define RTMP_BBP_IO_WRITE8_BY_REG_ID(_A, _I, _V)                       \
-{                                                                      \
-       BBP_CSR_CFG_STRUC       BbpCsr;                                 \
-       int                                     BusyCnt = 0;            \
-       BOOLEAN                                 brc;                    \
-       if (_I < MAX_NUM_OF_BBP_LATCH) {                                \
-               if ((IS_RT3090((_A)) || IS_RT3572((_A)) || IS_RT3390((_A))) \
-                       && ((_A)->StaCfg.PSControl.field.rt30xxPowerMode == 3)  \
-                       && ((_A)->StaCfg.PSControl.field.EnableNewPS == TRUE)   \
-                       && ((_A)->bPCIclkOff == FALSE)  \
-                       && ((_A)->brt30xxBanMcuCmd == FALSE)) {         \
-                       if (_A->AccessBBPFailCount > 20) {              \
-                               AsicResetBBPAgent(_A);                  \
-                               _A->AccessBBPFailCount = 0;             \
-                       }                                               \
-                       for (BusyCnt = 0; BusyCnt < MAX_BUSY_COUNT; BusyCnt++) { \
-                               RTMP_IO_READ32(_A, H2M_BBP_AGENT, &BbpCsr.word);                                \
-                               if (BbpCsr.field.Busy == BUSY)                                                                  \
-                                       continue;                                                                                                       \
-                               BbpCsr.word = 0;                                                                                                \
-                               BbpCsr.field.fRead = 0;                                                                                 \
-                               BbpCsr.field.BBP_RW_MODE = 1;                                                                   \
-                               BbpCsr.field.Busy = 1;                                                                                  \
-                               BbpCsr.field.Value = _V;                                                                                \
-                               BbpCsr.field.RegNum = _I;                                                                               \
-                               RTMP_IO_WRITE32(_A, H2M_BBP_AGENT, BbpCsr.word);                                \
-                               brc = AsicSendCommandToMcu(_A, 0x80, 0xff, 0x0, 0x0);                                   \
-                               if (brc == TRUE) {                      \
-                                       (_A)->BbpWriteLatch[_I] = _V;                                                                   \
-                               } else {                                \
-                                       BbpCsr.field.Busy = 0;                                                                                  \
-                                       RTMP_IO_WRITE32(_A, H2M_BBP_AGENT, BbpCsr.word);                                \
-                               }                                                                                                                               \
-                               break;                                                                                                                  \
-                       }                                                                                                                                       \
-               }                                                                                                                                       \
-               else if (!((IS_RT3090((_A)) || IS_RT3572((_A)) || IS_RT3390((_A))) \
-                       && ((_A)->StaCfg.PSControl.field.rt30xxPowerMode == 3)  \
-                       && ((_A)->StaCfg.PSControl.field.EnableNewPS == TRUE))  \
-                       && ((_A)->bPCIclkOff == FALSE)) {               \
-                       if (_A->AccessBBPFailCount > 20) {              \
-                               AsicResetBBPAgent(_A);                  \
-                               _A->AccessBBPFailCount = 0;             \
-                       }                                               \
-                       for (BusyCnt = 0; BusyCnt < MAX_BUSY_COUNT; BusyCnt++) { \
-                               RTMP_IO_READ32(_A, H2M_BBP_AGENT, &BbpCsr.word);                                \
-                               if (BbpCsr.field.Busy == BUSY)                                                                  \
-                                       continue;                                                                                                       \
-                               BbpCsr.word = 0;                                                                                                \
-                               BbpCsr.field.fRead = 0;                                                                                 \
-                               BbpCsr.field.BBP_RW_MODE = 1;                                                                   \
-                               BbpCsr.field.Busy = 1;                                                                                  \
-                               BbpCsr.field.Value = _V;                                                                                \
-                               BbpCsr.field.RegNum = _I;                                                                               \
-                               RTMP_IO_WRITE32(_A, H2M_BBP_AGENT, BbpCsr.word);                                \
-                               AsicSendCommandToMcu(_A, 0x80, 0xff, 0x0, 0x0);                                 \
-                               (_A)->BbpWriteLatch[_I] = _V;                                                                   \
-                               break;                                                                                                                  \
-                       }                                                                                                                                       \
-               } else {                                                \
-                       DBGPRINT_ERR("  brt30xxBanMcuCmd = %d. Write BBP %d \n",  (_A)->brt30xxBanMcuCmd, (_I));        \
-               }                                                                                                                                       \
-               if ((BusyCnt == MAX_BUSY_COUNT) || ((_A)->bPCIclkOff == TRUE)) { \
-                       if (BusyCnt == MAX_BUSY_COUNT)                          \
-                               (_A)->AccessBBPFailCount++;                                     \
-                       DBGPRINT_ERR("BBP write R%d=0x%x fail. BusyCnt= %d.bPCIclkOff = %d. \n", _I, BbpCsr.word, BusyCnt, (_A)->bPCIclkOff);   \
-               }                                                                                                                                       \
-       } else {                                                        \
-               DBGPRINT_ERR("****** BBP_Write_Latch Buffer exceeds max boundary ****** \n");   \
-       }                                                                                                                                               \
-}
-#endif /* RTMP_MAC_PCI // */
-
-#ifdef RTMP_MAC_USB
-#define RTMP_BBP_IO_READ8_BY_REG_ID(_A, _I, _pV)   RTUSBReadBBPRegister(_A, _I, _pV)
-#define RTMP_BBP_IO_WRITE8_BY_REG_ID(_A, _I, _V)   RTUSBWriteBBPRegister(_A, _I, _V)
-
-#define BBP_IO_WRITE8_BY_REG_ID(_A, _I, _V)                    RTUSBWriteBBPRegister(_A, _I, _V)
-#define BBP_IO_READ8_BY_REG_ID(_A, _I, _pV)            RTUSBReadBBPRegister(_A, _I, _pV)
-#endif /* RTMP_MAC_USB // */
-
-#ifdef RT30xx
-#define RTMP_ASIC_MMPS_DISABLE(_pAd)                                                   \
-       do {                                                                                                                    \
-               u32 _macData; \
-               u8 _bbpData = 0; \
-               /* disable MMPS BBP control register */                                         \
-               RTMP_BBP_IO_READ8_BY_REG_ID(_pAd, BBP_R3, &_bbpData);   \
-               _bbpData &= ~(0x04);    /*bit 2*/                                                               \
-               RTMP_BBP_IO_WRITE8_BY_REG_ID(_pAd, BBP_R3, _bbpData);   \
-                                                                                                                               \
-               /* disable MMPS MAC control register */                                         \
-               RTMP_IO_READ32(_pAd, 0x1210, &_macData);                                \
-               _macData &= ~(0x09);    /*bit 0, 3*/                                                    \
-               RTMP_IO_WRITE32(_pAd, 0x1210, _macData);                                \
-       } while (0)
-
-#define RTMP_ASIC_MMPS_ENABLE(_pAd)                                                    \
-       do {                                                                                                                    \
-               u32 _macData; \
-               u8 _bbpData = 0; \
-               /* enable MMPS BBP control register */                                          \
-               RTMP_BBP_IO_READ8_BY_REG_ID(_pAd, BBP_R3, &_bbpData);   \
-               _bbpData |= (0x04);     /*bit 2*/                                                               \
-               RTMP_BBP_IO_WRITE8_BY_REG_ID(_pAd, BBP_R3, _bbpData);   \
-                                                                                                                               \
-               /* enable MMPS MAC control register */                                          \
-               RTMP_IO_READ32(_pAd, 0x1210, &_macData);                                \
-               _macData |= (0x09);     /*bit 0, 3*/                                                    \
-               RTMP_IO_WRITE32(_pAd, 0x1210, _macData);                                \
-       } while (0)
-
-#endif /* RT30xx // */
-
-#endif /* __RTMP_PHY_H__ // */
diff --git a/drivers/staging/rt2860/chips/rt3070.c b/drivers/staging/rt2860/chips/rt3070.c
deleted file mode 100644 (file)
index 3a17fd1..0000000
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-       Module Name:
-       rt3070.c
-
-       Abstract:
-       Specific funcitons and variables for RT3070
-
-       Revision History:
-       Who         When          What
-       --------    ----------    ----------------------------------------------
-*/
-
-#ifdef RT3070
-
-#include "../rt_config.h"
-
-#ifndef RTMP_RF_RW_SUPPORT
-#error "You Should Enable compile flag RTMP_RF_RW_SUPPORT for this chip"
-#endif /* RTMP_RF_RW_SUPPORT // */
-
-void NICInitRT3070RFRegisters(struct rt_rtmp_adapter *pAd)
-{
-       int i;
-       u8 RFValue;
-
-       /* Driver must read EEPROM to get RfIcType before initial RF registers */
-       /* Initialize RF register to default value */
-       if (IS_RT3070(pAd) || IS_RT3071(pAd)) {
-               /* Init RF calibration */
-               /* Driver should toggle RF R30 bit7 before init RF registers */
-               u32 RfReg = 0;
-               u32 data;
-
-               RT30xxReadRFRegister(pAd, RF_R30, (u8 *)&RfReg);
-               RfReg |= 0x80;
-               RT30xxWriteRFRegister(pAd, RF_R30, (u8)RfReg);
-               RTMPusecDelay(1000);
-               RfReg &= 0x7F;
-               RT30xxWriteRFRegister(pAd, RF_R30, (u8)RfReg);
-
-               /* Initialize RF register to default value */
-               for (i = 0; i < NUM_RF_REG_PARMS; i++) {
-                       RT30xxWriteRFRegister(pAd,
-                                             RT30xx_RFRegTable[i].Register,
-                                             RT30xx_RFRegTable[i].Value);
-               }
-
-               /* add by johnli */
-               if (IS_RT3070(pAd)) {
-                       /* */
-                       /* The DAC issue(LDO_CFG0) has been fixed in RT3070(F). */
-                       /* The voltage raising patch is no longer needed for RT3070(F) */
-                       /* */
-                       if ((pAd->MACVersion & 0xffff) < 0x0201) {
-                               /*  Update MAC 0x05D4 from 01xxxxxx to 0Dxxxxxx (voltage 1.2V to 1.35V) for RT3070 to improve yield rate */
-                               RTUSBReadMACRegister(pAd, LDO_CFG0, &data);
-                               data = ((data & 0xF0FFFFFF) | 0x0D000000);
-                               RTUSBWriteMACRegister(pAd, LDO_CFG0, data);
-                       }
-               } else if (IS_RT3071(pAd)) {
-                       /* Driver should set RF R6 bit6 on before init RF registers */
-                       RT30xxReadRFRegister(pAd, RF_R06, (u8 *)&RfReg);
-                       RfReg |= 0x40;
-                       RT30xxWriteRFRegister(pAd, RF_R06, (u8)RfReg);
-
-                       /* init R31 */
-                       RT30xxWriteRFRegister(pAd, RF_R31, 0x14);
-
-                       /* RT3071 version E has fixed this issue */
-                       if ((pAd->NicConfig2.field.DACTestBit == 1)
-                           && ((pAd->MACVersion & 0xffff) < 0x0211)) {
-                               /* patch tx EVM issue temporarily */
-                               RTUSBReadMACRegister(pAd, LDO_CFG0, &data);
-                               data = ((data & 0xE0FFFFFF) | 0x0D000000);
-                               RTUSBWriteMACRegister(pAd, LDO_CFG0, data);
-                       } else {
-                               RTMP_IO_READ32(pAd, LDO_CFG0, &data);
-                               data = ((data & 0xE0FFFFFF) | 0x01000000);
-                               RTMP_IO_WRITE32(pAd, LDO_CFG0, data);
-                       }
-
-                       /* patch LNA_PE_G1 failed issue */
-                       RTUSBReadMACRegister(pAd, GPIO_SWITCH, &data);
-                       data &= ~(0x20);
-                       RTUSBWriteMACRegister(pAd, GPIO_SWITCH, data);
-               }
-               /*For RF filter Calibration */
-               RTMPFilterCalibration(pAd);
-
-               /* Initialize RF R27 register, set RF R27 must be behind RTMPFilterCalibration() */
-               /* */
-               /* TX to RX IQ glitch(RF_R27) has been fixed in RT3070(F). */
-               /* Raising RF voltage is no longer needed for RT3070(F) */
-               /* */
-               if ((IS_RT3070(pAd)) && ((pAd->MACVersion & 0xffff) < 0x0201)) {
-                       RT30xxWriteRFRegister(pAd, RF_R27, 0x3);
-               } else if ((IS_RT3071(pAd))
-                          && ((pAd->MACVersion & 0xffff) < 0x0211)) {
-                       RT30xxWriteRFRegister(pAd, RF_R27, 0x3);
-               }
-               /* set led open drain enable */
-               RTUSBReadMACRegister(pAd, OPT_14, &data);
-               data |= 0x01;
-               RTUSBWriteMACRegister(pAd, OPT_14, data);
-
-               /* move from RT30xxLoadRFNormalModeSetup because it's needed for both RT3070 and RT3071 */
-               /* TX_LO1_en, RF R17 register Bit 3 to 0 */
-               RT30xxReadRFRegister(pAd, RF_R17, &RFValue);
-               RFValue &= (~0x08);
-               /* to fix rx long range issue */
-               if (pAd->NicConfig2.field.ExternalLNAForG == 0) {
-                       if ((IS_RT3071(pAd)
-                            && ((pAd->MACVersion & 0xffff) >= 0x0211))
-                           || IS_RT3070(pAd)) {
-                               RFValue |= 0x20;
-                       }
-               }
-               /* set RF_R17_bit[2:0] equal to EEPROM setting at 0x48h */
-               if (pAd->TxMixerGain24G >= 1) {
-                       RFValue &= (~0x7);      /* clean bit [2:0] */
-                       RFValue |= pAd->TxMixerGain24G;
-               }
-               RT30xxWriteRFRegister(pAd, RF_R17, RFValue);
-
-               if (IS_RT3071(pAd)) {
-                       /* add by johnli, RF power sequence setup, load RF normal operation-mode setup */
-                       RT30xxLoadRFNormalModeSetup(pAd);
-               } else if (IS_RT3070(pAd)) {
-                       /* add by johnli, reset RF_R27 when interface down & up to fix throughput problem */
-                       /* LDORF_VC, RF R27 register Bit 2 to 0 */
-                       RT30xxReadRFRegister(pAd, RF_R27, &RFValue);
-                       /* TX to RX IQ glitch(RF_R27) has been fixed in RT3070(F). */
-                       /* Raising RF voltage is no longer needed for RT3070(F) */
-                       if ((pAd->MACVersion & 0xffff) < 0x0201)
-                               RFValue = (RFValue & (~0x77)) | 0x3;
-                       else
-                               RFValue = (RFValue & (~0x77));
-                       RT30xxWriteRFRegister(pAd, RF_R27, RFValue);
-                       /* end johnli */
-               }
-       }
-
-}
-#endif /* RT3070 // */
diff --git a/drivers/staging/rt2860/chips/rt3090.c b/drivers/staging/rt2860/chips/rt3090.c
deleted file mode 100644 (file)
index 334720e..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-       Module Name:
-       rt3090.c
-
-       Abstract:
-       Specific functions and variables for RT3070
-
-       Revision History:
-       Who                     When            What
-       Justin P. Mattock       11/07/2010      Fix a typo
-       --------    ----------    ----------------------------------------------
-*/
-
-#ifdef RT3090
-
-#include "../rt_config.h"
-
-#ifndef RTMP_RF_RW_SUPPORT
-#error "You Should Enable compile flag RTMP_RF_RW_SUPPORT for this chip"
-#endif /* RTMP_RF_RW_SUPPORT // */
-
-void NICInitRT3090RFRegisters(struct rt_rtmp_adapter *pAd)
-{
-       int i;
-       /* Driver must read EEPROM to get RfIcType before initial RF registers */
-       /* Initialize RF register to default value */
-       if (IS_RT3090(pAd)) {
-               /* Init RF calibration */
-               /* Driver should toggle RF R30 bit7 before init RF registers */
-               u8 RfReg;
-               u32 data;
-
-               RT30xxReadRFRegister(pAd, RF_R30, (u8 *)&RfReg);
-               RfReg |= 0x80;
-               RT30xxWriteRFRegister(pAd, RF_R30, (u8)RfReg);
-               RTMPusecDelay(1000);
-               RfReg &= 0x7F;
-               RT30xxWriteRFRegister(pAd, RF_R30, (u8)RfReg);
-
-               /* init R24, R31 */
-               RT30xxWriteRFRegister(pAd, RF_R24, 0x0F);
-               RT30xxWriteRFRegister(pAd, RF_R31, 0x0F);
-
-               /* RT309x version E has fixed this issue */
-               if ((pAd->NicConfig2.field.DACTestBit == 1)
-                   && ((pAd->MACVersion & 0xffff) < 0x0211)) {
-                       /* patch tx EVM issue temporarily */
-                       RTMP_IO_READ32(pAd, LDO_CFG0, &data);
-                       data = ((data & 0xE0FFFFFF) | 0x0D000000);
-                       RTMP_IO_WRITE32(pAd, LDO_CFG0, data);
-               } else {
-                       RTMP_IO_READ32(pAd, LDO_CFG0, &data);
-                       data = ((data & 0xE0FFFFFF) | 0x01000000);
-                       RTMP_IO_WRITE32(pAd, LDO_CFG0, data);
-               }
-
-               /* patch LNA_PE_G1 failed issue */
-               RTMP_IO_READ32(pAd, GPIO_SWITCH, &data);
-               data &= ~(0x20);
-               RTMP_IO_WRITE32(pAd, GPIO_SWITCH, data);
-
-               /* Initialize RF register to default value */
-               for (i = 0; i < NUM_RF_REG_PARMS; i++) {
-                       RT30xxWriteRFRegister(pAd,
-                                             RT30xx_RFRegTable[i].Register,
-                                             RT30xx_RFRegTable[i].Value);
-               }
-
-               /* Driver should set RF R6 bit6 on before calibration */
-               RT30xxReadRFRegister(pAd, RF_R06, (u8 *)&RfReg);
-               RfReg |= 0x40;
-               RT30xxWriteRFRegister(pAd, RF_R06, (u8)RfReg);
-
-               /*For RF filter Calibration */
-               RTMPFilterCalibration(pAd);
-
-               /* Initialize RF R27 register, set RF R27 must be behind RTMPFilterCalibration() */
-               if ((pAd->MACVersion & 0xffff) < 0x0211)
-                       RT30xxWriteRFRegister(pAd, RF_R27, 0x3);
-
-               /* set led open drain enable */
-               RTMP_IO_READ32(pAd, OPT_14, &data);
-               data |= 0x01;
-               RTMP_IO_WRITE32(pAd, OPT_14, data);
-
-               /* set default antenna as main */
-               if (pAd->RfIcType == RFIC_3020)
-                       AsicSetRxAnt(pAd, pAd->RxAnt.Pair1PrimaryRxAnt);
-
-               /* add by johnli, RF power sequence setup, load RF normal operation-mode setup */
-               RT30xxLoadRFNormalModeSetup(pAd);
-       }
-
-}
-
-#endif /* RT3090 // */
diff --git a/drivers/staging/rt2860/chips/rt30xx.c b/drivers/staging/rt2860/chips/rt30xx.c
deleted file mode 100644 (file)
index 354debf..0000000
+++ /dev/null
@@ -1,516 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-       Module Name:
-       rt30xx.c
-
-       Abstract:
-       Specific functions and variables for RT30xx.
-
-       Revision History:
-       Who                     When            What
-       Justin P. Mattock       11/07/2010      Fix some typos
-       --------    ----------    ----------------------------------------------
-*/
-
-#ifdef RT30xx
-
-#ifndef RTMP_RF_RW_SUPPORT
-#error "You Should Enable compile flag RTMP_RF_RW_SUPPORT for this chip"
-#endif /* RTMP_RF_RW_SUPPORT // */
-
-#include "../rt_config.h"
-
-/* */
-/* RF register initialization set */
-/* */
-struct rt_reg_pair RT30xx_RFRegTable[] = {
-       {RF_R04, 0x40}
-       ,
-       {RF_R05, 0x03}
-       ,
-       {RF_R06, 0x02}
-       ,
-       {RF_R07, 0x60}
-       ,
-       {RF_R09, 0x0F}
-       ,
-       {RF_R10, 0x41}
-       ,
-       {RF_R11, 0x21}
-       ,
-       {RF_R12, 0x7B}
-       ,
-       {RF_R14, 0x90}
-       ,
-       {RF_R15, 0x58}
-       ,
-       {RF_R16, 0xB3}
-       ,
-       {RF_R17, 0x92}
-       ,
-       {RF_R18, 0x2C}
-       ,
-       {RF_R19, 0x02}
-       ,
-       {RF_R20, 0xBA}
-       ,
-       {RF_R21, 0xDB}
-       ,
-       {RF_R24, 0x16}
-       ,
-       {RF_R25, 0x01}
-       ,
-       {RF_R29, 0x1F}
-       ,
-};
-
-u8 NUM_RF_REG_PARMS = (sizeof(RT30xx_RFRegTable) / sizeof(struct rt_reg_pair));
-
-/* Antenna diversity use GPIO3 and EESK pin for control */
-/* Antenna and EEPROM access are both using EESK pin, */
-/* Therefor we should avoid accessing EESK at the same time */
-/* Then restore antenna after EEPROM access */
-/* The original name of this function is AsicSetRxAnt(), now change to */
-/*void AsicSetRxAnt( */
-void RT30xxSetRxAnt(struct rt_rtmp_adapter *pAd, u8 Ant)
-{
-       u32 Value;
-#ifdef RTMP_MAC_PCI
-       u32 x;
-#endif
-
-       if ((pAd->EepromAccess) ||
-           (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS)) ||
-           (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS)) ||
-           (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF)) ||
-           (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST))) {
-               return;
-       }
-       /* the antenna selection is through firmware and MAC register(GPIO3) */
-       if (Ant == 0) {
-               /* Main antenna */
-#ifdef RTMP_MAC_PCI
-               RTMP_IO_READ32(pAd, E2PROM_CSR, &x);
-               x |= (EESK);
-               RTMP_IO_WRITE32(pAd, E2PROM_CSR, x);
-#else
-               AsicSendCommandToMcu(pAd, 0x73, 0xFF, 0x1, 0x0);
-#endif /* RTMP_MAC_PCI // */
-
-               RTMP_IO_READ32(pAd, GPIO_CTRL_CFG, &Value);
-               Value &= ~(0x0808);
-               RTMP_IO_WRITE32(pAd, GPIO_CTRL_CFG, Value);
-               DBGPRINT_RAW(RT_DEBUG_TRACE,
-                            ("AsicSetRxAnt, switch to main antenna\n"));
-       } else {
-               /* Aux antenna */
-#ifdef RTMP_MAC_PCI
-               RTMP_IO_READ32(pAd, E2PROM_CSR, &x);
-               x &= ~(EESK);
-               RTMP_IO_WRITE32(pAd, E2PROM_CSR, x);
-#else
-               AsicSendCommandToMcu(pAd, 0x73, 0xFF, 0x0, 0x0);
-#endif /* RTMP_MAC_PCI // */
-               RTMP_IO_READ32(pAd, GPIO_CTRL_CFG, &Value);
-               Value &= ~(0x0808);
-               Value |= 0x08;
-               RTMP_IO_WRITE32(pAd, GPIO_CTRL_CFG, Value);
-               DBGPRINT_RAW(RT_DEBUG_TRACE,
-                            ("AsicSetRxAnt, switch to aux antenna\n"));
-       }
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               For RF filter calibration purpose
-
-       Arguments:
-               pAd                          Pointer to our adapter
-
-       Return Value:
-               None
-
-       IRQL = PASSIVE_LEVEL
-
-       ========================================================================
-*/
-void RTMPFilterCalibration(struct rt_rtmp_adapter *pAd)
-{
-       u8 R55x = 0, value, FilterTarget = 0x1E, BBPValue = 0;
-       u32 loop = 0, count = 0, loopcnt = 0, ReTry = 0;
-       u8 RF_R24_Value = 0;
-
-       /* Give bbp filter initial value */
-       pAd->Mlme.CaliBW20RfR24 = 0x1F;
-       pAd->Mlme.CaliBW40RfR24 = 0x2F; /*Bit[5] must be 1 for BW 40 */
-
-       do {
-               if (loop == 1) {        /*BandWidth = 40 MHz */
-                       /* Write 0x27 to RF_R24 to program filter */
-                       RF_R24_Value = 0x27;
-                       RT30xxWriteRFRegister(pAd, RF_R24, RF_R24_Value);
-                       if (IS_RT3090(pAd) || IS_RT3572(pAd) || IS_RT3390(pAd))
-                               FilterTarget = 0x15;
-                       else
-                               FilterTarget = 0x19;
-
-                       /* when calibrate BW40, BBP mask must set to BW40. */
-                       RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue);
-                       BBPValue &= (~0x18);
-                       BBPValue |= (0x10);
-                       RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue);
-
-                       /* set to BW40 */
-                       RT30xxReadRFRegister(pAd, RF_R31, &value);
-                       value |= 0x20;
-                       RT30xxWriteRFRegister(pAd, RF_R31, value);
-               } else {        /*BandWidth = 20 MHz */
-                       /* Write 0x07 to RF_R24 to program filter */
-                       RF_R24_Value = 0x07;
-                       RT30xxWriteRFRegister(pAd, RF_R24, RF_R24_Value);
-                       if (IS_RT3090(pAd) || IS_RT3572(pAd) || IS_RT3390(pAd))
-                               FilterTarget = 0x13;
-                       else
-                               FilterTarget = 0x16;
-
-                       /* set to BW20 */
-                       RT30xxReadRFRegister(pAd, RF_R31, &value);
-                       value &= (~0x20);
-                       RT30xxWriteRFRegister(pAd, RF_R31, value);
-               }
-
-               /* Write 0x01 to RF_R22 to enable baseband loopback mode */
-               RT30xxReadRFRegister(pAd, RF_R22, &value);
-               value |= 0x01;
-               RT30xxWriteRFRegister(pAd, RF_R22, value);
-
-               /* Write 0x00 to BBP_R24 to set power & frequency of passband test tone */
-               RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R24, 0);
-
-               do {
-                       /* Write 0x90 to BBP_R25 to transmit test tone */
-                       RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R25, 0x90);
-
-                       RTMPusecDelay(1000);
-                       /* Read BBP_R55[6:0] for received power, set R55x = BBP_R55[6:0] */
-                       RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R55, &value);
-                       R55x = value & 0xFF;
-
-               } while ((ReTry++ < 100) && (R55x == 0));
-
-               /* Write 0x06 to BBP_R24 to set power & frequency of stopband test tone */
-               RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R24, 0x06);
-
-               while (TRUE) {
-                       /* Write 0x90 to BBP_R25 to transmit test tone */
-                       RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R25, 0x90);
-
-                       /*We need to wait for calibration */
-                       RTMPusecDelay(1000);
-                       RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R55, &value);
-                       value &= 0xFF;
-                       if ((R55x - value) < FilterTarget) {
-                               RF_R24_Value++;
-                       } else if ((R55x - value) == FilterTarget) {
-                               RF_R24_Value++;
-                               count++;
-                       } else {
-                               break;
-                       }
-
-                       /* prevent infinite loop; causes driver hang. */
-                       if (loopcnt++ > 100) {
-                               DBGPRINT(RT_DEBUG_ERROR,
-                                        ("RTMPFilterCalibration - can't find a valid value, loopcnt=%d stop calibrating",
-                                         loopcnt));
-                               break;
-                       }
-                       /* Write RF_R24 to program filter */
-                       RT30xxWriteRFRegister(pAd, RF_R24, RF_R24_Value);
-               }
-
-               if (count > 0) {
-                       RF_R24_Value = RF_R24_Value - ((count) ? (1) : (0));
-               }
-               /* Store for future usage */
-               if (loopcnt < 100) {
-                       if (loop++ == 0) {
-                               /*BandWidth = 20 MHz */
-                               pAd->Mlme.CaliBW20RfR24 = (u8)RF_R24_Value;
-                       } else {
-                               /*BandWidth = 40 MHz */
-                               pAd->Mlme.CaliBW40RfR24 = (u8)RF_R24_Value;
-                               break;
-                       }
-               } else
-                       break;
-
-               RT30xxWriteRFRegister(pAd, RF_R24, RF_R24_Value);
-
-               /* reset count */
-               count = 0;
-       } while (TRUE);
-
-       /* */
-       /* Set back to initial state */
-       /* */
-       RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R24, 0);
-
-       RT30xxReadRFRegister(pAd, RF_R22, &value);
-       value &= ~(0x01);
-       RT30xxWriteRFRegister(pAd, RF_R22, value);
-
-       /* set BBP back to BW20 */
-       RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue);
-       BBPValue &= (~0x18);
-       RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue);
-
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("RTMPFilterCalibration - CaliBW20RfR24=0x%x, CaliBW40RfR24=0x%x\n",
-                 pAd->Mlme.CaliBW20RfR24, pAd->Mlme.CaliBW40RfR24));
-}
-
-/* add by johnli, RF power sequence setup */
-/*
-       ==========================================================================
-       Description:
-
-       Load RF normal operation-mode setup
-
-       ==========================================================================
- */
-void RT30xxLoadRFNormalModeSetup(struct rt_rtmp_adapter *pAd)
-{
-       u8 RFValue;
-
-       /* RX0_PD & TX0_PD, RF R1 register Bit 2 & Bit 3 to 0 and RF_BLOCK_en,RX1_PD & TX1_PD, Bit0, Bit 4 & Bit5 to 1 */
-       RT30xxReadRFRegister(pAd, RF_R01, &RFValue);
-       RFValue = (RFValue & (~0x0C)) | 0x31;
-       RT30xxWriteRFRegister(pAd, RF_R01, RFValue);
-
-       /* TX_LO2_en, RF R15 register Bit 3 to 0 */
-       RT30xxReadRFRegister(pAd, RF_R15, &RFValue);
-       RFValue &= (~0x08);
-       RT30xxWriteRFRegister(pAd, RF_R15, RFValue);
-
-       /* move to NICInitRT30xxRFRegisters
-          // TX_LO1_en, RF R17 register Bit 3 to 0
-          RT30xxReadRFRegister(pAd, RF_R17, &RFValue);
-          RFValue &= (~0x08);
-          // to fix rx long range issue
-          if (((pAd->MACVersion & 0xffff) >= 0x0211) && (pAd->NicConfig2.field.ExternalLNAForG == 0))
-          {
-          RFValue |= 0x20;
-          }
-          // set RF_R17_bit[2:0] equal to EEPROM setting at 0x48h
-          if (pAd->TxMixerGain24G >= 2)
-          {
-          RFValue &= (~0x7);  // clean bit [2:0]
-          RFValue |= pAd->TxMixerGain24G;
-          }
-          RT30xxWriteRFRegister(pAd, RF_R17, RFValue);
-        */
-
-       /* RX_LO1_en, RF R20 register Bit 3 to 0 */
-       RT30xxReadRFRegister(pAd, RF_R20, &RFValue);
-       RFValue &= (~0x08);
-       RT30xxWriteRFRegister(pAd, RF_R20, RFValue);
-
-       /* RX_LO2_en, RF R21 register Bit 3 to 0 */
-       RT30xxReadRFRegister(pAd, RF_R21, &RFValue);
-       RFValue &= (~0x08);
-       RT30xxWriteRFRegister(pAd, RF_R21, RFValue);
-
-       /* add by johnli, reset RF_R27 when interface down & up to fix throughput problem */
-       /* LDORF_VC, RF R27 register Bit 2 to 0 */
-       RT30xxReadRFRegister(pAd, RF_R27, &RFValue);
-       /* TX to RX IQ glitch(RF_R27) has been fixed in RT3070(F). */
-       /* Raising RF voltage is no longer needed for RT3070(F) */
-       if (IS_RT3090(pAd)) {   /* RT309x and RT3071/72 */
-               if ((pAd->MACVersion & 0xffff) < 0x0211)
-                       RFValue = (RFValue & (~0x77)) | 0x3;
-               else
-                       RFValue = (RFValue & (~0x77));
-               RT30xxWriteRFRegister(pAd, RF_R27, RFValue);
-       }
-       /* end johnli */
-}
-
-/*
-       ==========================================================================
-       Description:
-
-       Load RF sleep-mode setup
-
-       ==========================================================================
- */
-void RT30xxLoadRFSleepModeSetup(struct rt_rtmp_adapter *pAd)
-{
-       u8 RFValue;
-       u32 MACValue;
-
-#ifdef RTMP_MAC_USB
-       if (!IS_RT3572(pAd))
-#endif /* RTMP_MAC_USB // */
-       {
-               /* RF_BLOCK_en. RF R1 register Bit 0 to 0 */
-               RT30xxReadRFRegister(pAd, RF_R01, &RFValue);
-               RFValue &= (~0x01);
-               RT30xxWriteRFRegister(pAd, RF_R01, RFValue);
-
-               /* VCO_IC, RF R7 register Bit 4 & Bit 5 to 0 */
-               RT30xxReadRFRegister(pAd, RF_R07, &RFValue);
-               RFValue &= (~0x30);
-               RT30xxWriteRFRegister(pAd, RF_R07, RFValue);
-
-               /* Idoh, RF R9 register Bit 1, Bit 2 & Bit 3 to 0 */
-               RT30xxReadRFRegister(pAd, RF_R09, &RFValue);
-               RFValue &= (~0x0E);
-               RT30xxWriteRFRegister(pAd, RF_R09, RFValue);
-
-               /* RX_CTB_en, RF R21 register Bit 7 to 0 */
-               RT30xxReadRFRegister(pAd, RF_R21, &RFValue);
-               RFValue &= (~0x80);
-               RT30xxWriteRFRegister(pAd, RF_R21, RFValue);
-       }
-
-       if (IS_RT3090(pAd) ||   /* IS_RT3090 including RT309x and RT3071/72 */
-           IS_RT3572(pAd) ||
-           (IS_RT3070(pAd) && ((pAd->MACVersion & 0xffff) < 0x0201))) {
-#ifdef RTMP_MAC_USB
-               if (!IS_RT3572(pAd))
-#endif /* RTMP_MAC_USB // */
-               {
-                       RT30xxReadRFRegister(pAd, RF_R27, &RFValue);
-                       RFValue |= 0x77;
-                       RT30xxWriteRFRegister(pAd, RF_R27, RFValue);
-               }
-
-               RTMP_IO_READ32(pAd, LDO_CFG0, &MACValue);
-               MACValue |= 0x1D000000;
-               RTMP_IO_WRITE32(pAd, LDO_CFG0, MACValue);
-       }
-}
-
-/*
-       ==========================================================================
-       Description:
-
-       Reverse RF sleep-mode setup
-
-       ==========================================================================
- */
-void RT30xxReverseRFSleepModeSetup(struct rt_rtmp_adapter *pAd)
-{
-       u8 RFValue;
-       u32 MACValue;
-
-#ifdef RTMP_MAC_USB
-       if (!IS_RT3572(pAd))
-#endif /* RTMP_MAC_USB // */
-       {
-               /* RF_BLOCK_en, RF R1 register Bit 0 to 1 */
-               RT30xxReadRFRegister(pAd, RF_R01, &RFValue);
-               RFValue |= 0x01;
-               RT30xxWriteRFRegister(pAd, RF_R01, RFValue);
-
-               /* VCO_IC, RF R7 register Bit 4 & Bit 5 to 1 */
-               RT30xxReadRFRegister(pAd, RF_R07, &RFValue);
-               RFValue |= 0x20;
-               RT30xxWriteRFRegister(pAd, RF_R07, RFValue);
-
-               /* Idoh, RF R9 register Bit 1, Bit 2 & Bit 3 to 1 */
-               RT30xxReadRFRegister(pAd, RF_R09, &RFValue);
-               RFValue |= 0x0E;
-               RT30xxWriteRFRegister(pAd, RF_R09, RFValue);
-
-               /* RX_CTB_en, RF R21 register Bit 7 to 1 */
-               RT30xxReadRFRegister(pAd, RF_R21, &RFValue);
-               RFValue |= 0x80;
-               RT30xxWriteRFRegister(pAd, RF_R21, RFValue);
-       }
-
-       if (IS_RT3090(pAd) ||   /* IS_RT3090 including RT309x and RT3071/72 */
-           IS_RT3572(pAd) ||
-           IS_RT3390(pAd) ||
-           (IS_RT3070(pAd) && ((pAd->MACVersion & 0xffff) < 0x0201))) {
-#ifdef RTMP_MAC_USB
-               if (!IS_RT3572(pAd))
-#endif /* RTMP_MAC_USB // */
-               {
-                       RT30xxReadRFRegister(pAd, RF_R27, &RFValue);
-                       if ((pAd->MACVersion & 0xffff) < 0x0211)
-                               RFValue = (RFValue & (~0x77)) | 0x3;
-                       else
-                               RFValue = (RFValue & (~0x77));
-                       RT30xxWriteRFRegister(pAd, RF_R27, RFValue);
-               }
-               /* RT3071 version E has fixed this issue */
-               if ((pAd->NicConfig2.field.DACTestBit == 1)
-                   && ((pAd->MACVersion & 0xffff) < 0x0211)) {
-                       /* patch tx EVM issue temporarily */
-                       RTMP_IO_READ32(pAd, LDO_CFG0, &MACValue);
-                       MACValue = ((MACValue & 0xE0FFFFFF) | 0x0D000000);
-                       RTMP_IO_WRITE32(pAd, LDO_CFG0, MACValue);
-               } else {
-                       RTMP_IO_READ32(pAd, LDO_CFG0, &MACValue);
-                       MACValue = ((MACValue & 0xE0FFFFFF) | 0x01000000);
-                       RTMP_IO_WRITE32(pAd, LDO_CFG0, MACValue);
-               }
-       }
-
-       if (IS_RT3572(pAd))
-               RT30xxWriteRFRegister(pAd, RF_R08, 0x80);
-}
-
-/* end johnli */
-
-void RT30xxHaltAction(struct rt_rtmp_adapter *pAd)
-{
-       u32 TxPinCfg = 0x00050F0F;
-
-       /* */
-       /* Turn off LNA_PE or TRSW_POL */
-       /* */
-       if (IS_RT3070(pAd) || IS_RT3071(pAd) || IS_RT3572(pAd)) {
-               if ((IS_RT3071(pAd) || IS_RT3572(pAd))
-#ifdef RTMP_EFUSE_SUPPORT
-                   && (pAd->bUseEfuse)
-#endif /* RTMP_EFUSE_SUPPORT // */
-                   ) {
-                       TxPinCfg &= 0xFFFBF0F0; /* bit18 off */
-               } else {
-                       TxPinCfg &= 0xFFFFF0F0;
-               }
-
-               RTMP_IO_WRITE32(pAd, TX_PIN_CFG, TxPinCfg);
-       }
-}
-
-#endif /* RT30xx // */
diff --git a/drivers/staging/rt2860/chlist.h b/drivers/staging/rt2860/chlist.h
deleted file mode 100644 (file)
index 1231e69..0000000
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-       Module Name:
-       chlist.c
-
-       Abstract:
-
-       Revision History:
-       Who         When          What
-       --------    ----------    ----------------------------------------------
-       Fonchi Wu   2007-12-19    created
-*/
-
-#ifndef __CHLIST_H__
-#define __CHLIST_H__
-
-#include "rtmp_type.h"
-#include "rtmp_def.h"
-
-#define ODOR                   0
-#define IDOR                   1
-#define BOTH                   2
-
-#define BAND_5G         0
-#define BAND_24G        1
-#define BAND_BOTH       2
-
-struct rt_ch_desp {
-       u8 FirstChannel;
-       u8 NumOfCh;
-       char MaxTxPwr;          /* dBm */
-       u8 Geography;   /* 0:out door, 1:in door, 2:both */
-       BOOLEAN DfsReq;         /* Dfs require, 0: No, 1: yes. */
-};
-
-struct rt_ch_region {
-       u8 CountReg[3];
-       u8 DfsType;             /* 0: CE, 1: FCC, 2: JAP, 3:JAP_W53, JAP_W56 */
-       struct rt_ch_desp ChDesp[10];
-};
-
-extern struct rt_ch_region ChRegion[];
-
-struct rt_ch_freq_map {
-       u16 channel;
-       u16 freqKHz;
-};
-
-extern struct rt_ch_freq_map CH_HZ_ID_MAP[];
-extern int CH_HZ_ID_MAP_NUM;
-
-#define     MAP_CHANNEL_ID_TO_KHZ(_ch, _khz)           \
-               do {                                                    \
-                       int _chIdx;                                     \
-                       for (_chIdx = 0; _chIdx < CH_HZ_ID_MAP_NUM; _chIdx++) {\
-                               if ((_ch) == CH_HZ_ID_MAP[_chIdx].channel) { \
-                                       (_khz) = CH_HZ_ID_MAP[_chIdx].freqKHz * 1000;\
-                                       break;                          \
-                               }                                       \
-                       }                                               \
-                       if (_chIdx == CH_HZ_ID_MAP_NUM) \
-                               (_khz) = 2412000;               \
-               } while (0)
-
-#define     MAP_KHZ_TO_CHANNEL_ID(_khz, _ch)                 \
-               do {                                                    \
-                       int _chIdx;                             \
-                       for (_chIdx = 0; _chIdx < CH_HZ_ID_MAP_NUM; _chIdx++) {\
-                               if ((_khz) == CH_HZ_ID_MAP[_chIdx].freqKHz) {\
-                                       (_ch) = CH_HZ_ID_MAP[_chIdx].channel; \
-                                       break;                  \
-                               }                                       \
-                       }                                               \
-                       if (_chIdx == CH_HZ_ID_MAP_NUM)                 \
-                               (_ch) = 1;                              \
-               } while (0)
-
-void BuildChannelListEx(struct rt_rtmp_adapter *pAd);
-
-void BuildBeaconChList(struct rt_rtmp_adapter *pAd,
-                      u8 *pBuf, unsigned long *pBufLen);
-
-void N_ChannelCheck(struct rt_rtmp_adapter *pAd);
-
-void N_SetCenCh(struct rt_rtmp_adapter *pAd);
-
-u8 GetCuntryMaxTxPwr(struct rt_rtmp_adapter *pAd, u8 channel);
-
-#endif /* __CHLIST_H__ */
diff --git a/drivers/staging/rt2860/common/action.c b/drivers/staging/rt2860/common/action.c
deleted file mode 100644 (file)
index 56ad236..0000000
+++ /dev/null
@@ -1,606 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-    Module Name:
-       action.c
-
-    Abstract:
-    Handle association related requests either from WSTA or from local MLME
-
-    Revision History:
-    Who         When          What
-    --------    ----------    ----------------------------------------------
-       Jan Lee         2006            created for rt2860
- */
-
-#include "../rt_config.h"
-#include "action.h"
-
-static void ReservedAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
-
-/*
-    ==========================================================================
-    Description:
-        association state machine init, including state transition and timer init
-    Parameters:
-        S - pointer to the association state machine
-    Note:
-        The state machine looks like the following
-
-                                    ASSOC_IDLE
-        MT2_MLME_DISASSOC_REQ    mlme_disassoc_req_action
-        MT2_PEER_DISASSOC_REQ    peer_disassoc_action
-        MT2_PEER_ASSOC_REQ       drop
-        MT2_PEER_REASSOC_REQ     drop
-        MT2_CLS3ERR              cls3err_action
-    ==========================================================================
- */
-void ActionStateMachineInit(struct rt_rtmp_adapter *pAd,
-                           struct rt_state_machine *S,
-                           OUT STATE_MACHINE_FUNC Trans[])
-{
-       StateMachineInit(S, (STATE_MACHINE_FUNC *) Trans, MAX_ACT_STATE,
-                        MAX_ACT_MSG, (STATE_MACHINE_FUNC) Drop, ACT_IDLE,
-                        ACT_MACHINE_BASE);
-
-       StateMachineSetAction(S, ACT_IDLE, MT2_PEER_SPECTRUM_CATE,
-                             (STATE_MACHINE_FUNC) PeerSpectrumAction);
-       StateMachineSetAction(S, ACT_IDLE, MT2_PEER_QOS_CATE,
-                             (STATE_MACHINE_FUNC) PeerQOSAction);
-
-       StateMachineSetAction(S, ACT_IDLE, MT2_PEER_DLS_CATE,
-                             (STATE_MACHINE_FUNC) ReservedAction);
-
-       StateMachineSetAction(S, ACT_IDLE, MT2_PEER_BA_CATE,
-                             (STATE_MACHINE_FUNC) PeerBAAction);
-       StateMachineSetAction(S, ACT_IDLE, MT2_PEER_HT_CATE,
-                             (STATE_MACHINE_FUNC) PeerHTAction);
-       StateMachineSetAction(S, ACT_IDLE, MT2_MLME_ADD_BA_CATE,
-                             (STATE_MACHINE_FUNC) MlmeADDBAAction);
-       StateMachineSetAction(S, ACT_IDLE, MT2_MLME_ORI_DELBA_CATE,
-                             (STATE_MACHINE_FUNC) MlmeDELBAAction);
-       StateMachineSetAction(S, ACT_IDLE, MT2_MLME_REC_DELBA_CATE,
-                             (STATE_MACHINE_FUNC) MlmeDELBAAction);
-
-       StateMachineSetAction(S, ACT_IDLE, MT2_PEER_PUBLIC_CATE,
-                             (STATE_MACHINE_FUNC) PeerPublicAction);
-       StateMachineSetAction(S, ACT_IDLE, MT2_PEER_RM_CATE,
-                             (STATE_MACHINE_FUNC) PeerRMAction);
-
-       StateMachineSetAction(S, ACT_IDLE, MT2_MLME_QOS_CATE,
-                             (STATE_MACHINE_FUNC) MlmeQOSAction);
-       StateMachineSetAction(S, ACT_IDLE, MT2_MLME_DLS_CATE,
-                             (STATE_MACHINE_FUNC) MlmeDLSAction);
-       StateMachineSetAction(S, ACT_IDLE, MT2_ACT_INVALID,
-                             (STATE_MACHINE_FUNC) MlmeInvalidAction);
-}
-
-void MlmeADDBAAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
-{
-       struct rt_mlme_addba_req *pInfo;
-       u8 Addr[6];
-       u8 *pOutBuffer = NULL;
-       int NStatus;
-       unsigned long Idx;
-       struct rt_frame_addba_req Frame;
-       unsigned long FrameLen;
-       struct rt_ba_ori_entry *pBAEntry = NULL;
-
-       pInfo = (struct rt_mlme_addba_req *)Elem->Msg;
-       NdisZeroMemory(&Frame, sizeof(struct rt_frame_addba_req));
-
-       if (MlmeAddBAReqSanity(pAd, Elem->Msg, Elem->MsgLen, Addr)) {
-               NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); /*Get an unused nonpaged memory */
-               if (NStatus != NDIS_STATUS_SUCCESS) {
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("BA - MlmeADDBAAction() allocate memory failed \n"));
-                       return;
-               }
-               /* 1. find entry */
-               Idx =
-                   pAd->MacTab.Content[pInfo->Wcid].BAOriWcidArray[pInfo->TID];
-               if (Idx == 0) {
-                       MlmeFreeMemory(pAd, pOutBuffer);
-                       DBGPRINT(RT_DEBUG_ERROR,
-                                ("BA - MlmeADDBAAction() can't find BAOriEntry \n"));
-                       return;
-               } else {
-                       pBAEntry = &pAd->BATable.BAOriEntry[Idx];
-               }
-
-               {
-                       if (ADHOC_ON(pAd))
-                               ActHeaderInit(pAd, &Frame.Hdr, pInfo->pAddr,
-                                             pAd->CurrentAddress,
-                                             pAd->CommonCfg.Bssid);
-                       else
-                               ActHeaderInit(pAd, &Frame.Hdr,
-                                             pAd->CommonCfg.Bssid,
-                                             pAd->CurrentAddress,
-                                             pInfo->pAddr);
-               }
-
-               Frame.Category = CATEGORY_BA;
-               Frame.Action = ADDBA_REQ;
-               Frame.BaParm.AMSDUSupported = 0;
-               Frame.BaParm.BAPolicy = IMMED_BA;
-               Frame.BaParm.TID = pInfo->TID;
-               Frame.BaParm.BufSize = pInfo->BaBufSize;
-               Frame.Token = pInfo->Token;
-               Frame.TimeOutValue = pInfo->TimeOutValue;
-               Frame.BaStartSeq.field.FragNum = 0;
-               Frame.BaStartSeq.field.StartSeq =
-                   pAd->MacTab.Content[pInfo->Wcid].TxSeq[pInfo->TID];
-
-               *(u16 *) (&Frame.BaParm) =
-                   cpu2le16(*(u16 *) (&Frame.BaParm));
-               Frame.TimeOutValue = cpu2le16(Frame.TimeOutValue);
-               Frame.BaStartSeq.word = cpu2le16(Frame.BaStartSeq.word);
-
-               MakeOutgoingFrame(pOutBuffer, &FrameLen,
-                                 sizeof(struct rt_frame_addba_req), &Frame, END_OF_ARGS);
-
-               MiniportMMRequest(pAd,
-                                 (MGMT_USE_QUEUE_FLAG |
-                                  MapUserPriorityToAccessCategory[pInfo->TID]),
-                                 pOutBuffer, FrameLen);
-
-               MlmeFreeMemory(pAd, pOutBuffer);
-
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("BA - Send ADDBA request. StartSeq = %x,  FrameLen = %ld. BufSize = %d\n",
-                         Frame.BaStartSeq.field.StartSeq, FrameLen,
-                         Frame.BaParm.BufSize));
-       }
-}
-
-/*
-    ==========================================================================
-    Description:
-        send DELBA and delete BaEntry if any
-    Parametrs:
-        Elem - MLME message struct rt_mlme_delba_req
-
-       IRQL = DISPATCH_LEVEL
-
-    ==========================================================================
- */
-void MlmeDELBAAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
-{
-       struct rt_mlme_delba_req *pInfo;
-       u8 *pOutBuffer = NULL;
-       u8 *pOutBuffer2 = NULL;
-       int NStatus;
-       unsigned long Idx;
-       struct rt_frame_delba_req Frame;
-       unsigned long FrameLen;
-       struct rt_frame_bar FrameBar;
-
-       pInfo = (struct rt_mlme_delba_req *)Elem->Msg;
-       /* must send back DELBA */
-       NdisZeroMemory(&Frame, sizeof(struct rt_frame_delba_req));
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("==> MlmeDELBAAction(), Initiator(%d) \n", pInfo->Initiator));
-
-       if (MlmeDelBAReqSanity(pAd, Elem->Msg, Elem->MsgLen)) {
-               NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); /*Get an unused nonpaged memory */
-               if (NStatus != NDIS_STATUS_SUCCESS) {
-                       DBGPRINT(RT_DEBUG_ERROR,
-                                ("BA - MlmeDELBAAction() allocate memory failed 1. \n"));
-                       return;
-               }
-
-               NStatus = MlmeAllocateMemory(pAd, &pOutBuffer2);        /*Get an unused nonpaged memory */
-               if (NStatus != NDIS_STATUS_SUCCESS) {
-                       MlmeFreeMemory(pAd, pOutBuffer);
-                       DBGPRINT(RT_DEBUG_ERROR,
-                                ("BA - MlmeDELBAAction() allocate memory failed 2. \n"));
-                       return;
-               }
-               /* SEND BAR (Send BAR to refresh peer reordering buffer.) */
-               Idx =
-                   pAd->MacTab.Content[pInfo->Wcid].BAOriWcidArray[pInfo->TID];
-
-               BarHeaderInit(pAd, &FrameBar,
-                             pAd->MacTab.Content[pInfo->Wcid].Addr,
-                             pAd->CurrentAddress);
-
-               FrameBar.StartingSeq.field.FragNum = 0; /* make sure sequence not clear in DEL funciton. */
-               FrameBar.StartingSeq.field.StartSeq = pAd->MacTab.Content[pInfo->Wcid].TxSeq[pInfo->TID];       /* make sure sequence not clear in DEL funciton. */
-               FrameBar.BarControl.TID = pInfo->TID;   /* make sure sequence not clear in DEL funciton. */
-               FrameBar.BarControl.ACKPolicy = IMMED_BA;       /* make sure sequence not clear in DEL funciton. */
-               FrameBar.BarControl.Compressed = 1;     /* make sure sequence not clear in DEL funciton. */
-               FrameBar.BarControl.MTID = 0;   /* make sure sequence not clear in DEL funciton. */
-
-               MakeOutgoingFrame(pOutBuffer2, &FrameLen,
-                                 sizeof(struct rt_frame_bar), &FrameBar, END_OF_ARGS);
-               MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer2, FrameLen);
-               MlmeFreeMemory(pAd, pOutBuffer2);
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("BA - MlmeDELBAAction() . Send BAR to refresh peer reordering buffer \n"));
-
-               /* SEND DELBA FRAME */
-               FrameLen = 0;
-
-               {
-                       if (ADHOC_ON(pAd))
-                               ActHeaderInit(pAd, &Frame.Hdr,
-                                             pAd->MacTab.Content[pInfo->Wcid].
-                                             Addr, pAd->CurrentAddress,
-                                             pAd->CommonCfg.Bssid);
-                       else
-                               ActHeaderInit(pAd, &Frame.Hdr,
-                                             pAd->CommonCfg.Bssid,
-                                             pAd->CurrentAddress,
-                                             pAd->MacTab.Content[pInfo->Wcid].
-                                             Addr);
-               }
-
-               Frame.Category = CATEGORY_BA;
-               Frame.Action = DELBA;
-               Frame.DelbaParm.Initiator = pInfo->Initiator;
-               Frame.DelbaParm.TID = pInfo->TID;
-               Frame.ReasonCode = 39;  /* Time Out */
-               *(u16 *) (&Frame.DelbaParm) =
-                   cpu2le16(*(u16 *) (&Frame.DelbaParm));
-               Frame.ReasonCode = cpu2le16(Frame.ReasonCode);
-
-               MakeOutgoingFrame(pOutBuffer, &FrameLen,
-                                 sizeof(struct rt_frame_delba_req), &Frame, END_OF_ARGS);
-               MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);
-               MlmeFreeMemory(pAd, pOutBuffer);
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("BA - MlmeDELBAAction() . 3 DELBA sent. Initiator(%d)\n",
-                         pInfo->Initiator));
-       }
-}
-
-void MlmeQOSAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
-{
-}
-
-void MlmeDLSAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
-{
-}
-
-void MlmeInvalidAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
-{
-       /*u8 *                  pOutBuffer = NULL; */
-       /*Return the receiving frame except the MSB of category filed set to 1.  7.3.1.11 */
-}
-
-void PeerQOSAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
-{
-}
-
-void PeerBAAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
-{
-       u8 Action = Elem->Msg[LENGTH_802_11 + 1];
-
-       switch (Action) {
-       case ADDBA_REQ:
-               PeerAddBAReqAction(pAd, Elem);
-               break;
-       case ADDBA_RESP:
-               PeerAddBARspAction(pAd, Elem);
-               break;
-       case DELBA:
-               PeerDelBAAction(pAd, Elem);
-               break;
-       }
-}
-
-void PeerPublicAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
-{
-       if (Elem->Wcid >= MAX_LEN_OF_MAC_TABLE)
-               return;
-}
-
-static void ReservedAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
-{
-       u8 Category;
-
-       if (Elem->MsgLen <= LENGTH_802_11) {
-               return;
-       }
-
-       Category = Elem->Msg[LENGTH_802_11];
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("Rcv reserved category(%d) Action Frame\n", Category));
-       hex_dump("Reserved Action Frame", &Elem->Msg[0], Elem->MsgLen);
-}
-
-void PeerRMAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
-{
-       return;
-}
-
-static void respond_ht_information_exchange_action(struct rt_rtmp_adapter *pAd,
-                                                  struct rt_mlme_queue_elem *Elem)
-{
-       u8 *pOutBuffer = NULL;
-       int NStatus;
-       unsigned long FrameLen;
-       struct rt_frame_ht_info HTINFOframe, *pFrame;
-       u8 *pAddr;
-
-       /* 2. Always send back ADDBA Response */
-       NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); /*Get an unused nonpaged memory */
-
-       if (NStatus != NDIS_STATUS_SUCCESS) {
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("ACTION - respond_ht_information_exchange_action() allocate memory failed \n"));
-               return;
-       }
-       /* get RA */
-       pFrame = (struct rt_frame_ht_info *) & Elem->Msg[0];
-       pAddr = pFrame->Hdr.Addr2;
-
-       NdisZeroMemory(&HTINFOframe, sizeof(struct rt_frame_ht_info));
-       /* 2-1. Prepare ADDBA Response frame. */
-       {
-               if (ADHOC_ON(pAd))
-                       ActHeaderInit(pAd, &HTINFOframe.Hdr, pAddr,
-                                     pAd->CurrentAddress,
-                                     pAd->CommonCfg.Bssid);
-               else
-                       ActHeaderInit(pAd, &HTINFOframe.Hdr,
-                                     pAd->CommonCfg.Bssid, pAd->CurrentAddress,
-                                     pAddr);
-       }
-
-       HTINFOframe.Category = CATEGORY_HT;
-       HTINFOframe.Action = HT_INFO_EXCHANGE;
-       HTINFOframe.HT_Info.Request = 0;
-       HTINFOframe.HT_Info.Forty_MHz_Intolerant =
-           pAd->CommonCfg.HtCapability.HtCapInfo.Forty_Mhz_Intolerant;
-       HTINFOframe.HT_Info.STA_Channel_Width =
-           pAd->CommonCfg.AddHTInfo.AddHtInfo.RecomWidth;
-
-       MakeOutgoingFrame(pOutBuffer, &FrameLen,
-                         sizeof(struct rt_frame_ht_info), &HTINFOframe, END_OF_ARGS);
-
-       MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);
-       MlmeFreeMemory(pAd, pOutBuffer);
-}
-
-void PeerHTAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
-{
-       u8 Action = Elem->Msg[LENGTH_802_11 + 1];
-
-       if (Elem->Wcid >= MAX_LEN_OF_MAC_TABLE)
-               return;
-
-       switch (Action) {
-       case NOTIFY_BW_ACTION:
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("ACTION - HT Notify Channel bandwidth action----> \n"));
-
-               if (pAd->StaActive.SupportedPhyInfo.bHtEnable == FALSE) {
-                       /* Note, this is to patch DIR-1353 AP. When the AP set to Wep, it will use legacy mode. But AP still keeps */
-                       /* sending BW_Notify Action frame, and cause us to linkup and linkdown. */
-                       /* In legacy mode, don't need to parse HT action frame. */
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("ACTION -Ignore HT Notify Channel BW when link as legacy mode. BW = %d---> \n",
-                                 Elem->Msg[LENGTH_802_11 + 2]));
-                       break;
-               }
-
-               if (Elem->Msg[LENGTH_802_11 + 2] == 0)  /* 7.4.8.2. if value is 1, keep the same as supported channel bandwidth. */
-                       pAd->MacTab.Content[Elem->Wcid].HTPhyMode.field.BW = 0;
-
-               break;
-       case SMPS_ACTION:
-               /* 7.3.1.25 */
-               DBGPRINT(RT_DEBUG_TRACE, ("ACTION - SMPS action----> \n"));
-               if (((Elem->Msg[LENGTH_802_11 + 2] & 0x1) == 0)) {
-                       pAd->MacTab.Content[Elem->Wcid].MmpsMode = MMPS_ENABLE;
-               } else if (((Elem->Msg[LENGTH_802_11 + 2] & 0x2) == 0)) {
-                       pAd->MacTab.Content[Elem->Wcid].MmpsMode = MMPS_STATIC;
-               } else {
-                       pAd->MacTab.Content[Elem->Wcid].MmpsMode = MMPS_DYNAMIC;
-               }
-
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("Aid(%d) MIMO PS = %d\n", Elem->Wcid,
-                         pAd->MacTab.Content[Elem->Wcid].MmpsMode));
-               /* rt2860c : add something for smps change. */
-               break;
-
-       case SETPCO_ACTION:
-               break;
-       case MIMO_CHA_MEASURE_ACTION:
-               break;
-       case HT_INFO_EXCHANGE:
-               {
-                       struct rt_ht_information_octet *pHT_info;
-
-                       pHT_info =
-                           (struct rt_ht_information_octet *) & Elem->Msg[LENGTH_802_11 +
-                                                                2];
-                       /* 7.4.8.10 */
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("ACTION - HT Information Exchange action----> \n"));
-                       if (pHT_info->Request) {
-                               respond_ht_information_exchange_action(pAd,
-                                                                      Elem);
-                       }
-               }
-               break;
-       }
-}
-
-/*
-       ==========================================================================
-       Description:
-               Retry sending ADDBA Reqest.
-
-       IRQL = DISPATCH_LEVEL
-
-       Parametrs:
-       p8023Header: if this is already 802.3 format, p8023Header is NULL
-
-       Return  : TRUE if put into rx reordering buffer, shouldn't indicaterxhere.
-                               FALSE , then continue indicaterx at this moment.
-       ==========================================================================
- */
-void ORIBATimerTimeout(struct rt_rtmp_adapter *pAd)
-{
-       struct rt_mac_table_entry *pEntry;
-       int i, total;
-       u8 TID;
-
-       total = pAd->MacTab.Size * NUM_OF_TID;
-
-       for (i = 1; ((i < MAX_LEN_OF_BA_ORI_TABLE) && (total > 0)); i++) {
-               if (pAd->BATable.BAOriEntry[i].ORI_BA_Status == Originator_Done) {
-                       pEntry =
-                           &pAd->MacTab.Content[pAd->BATable.BAOriEntry[i].
-                                                Wcid];
-                       TID = pAd->BATable.BAOriEntry[i].TID;
-
-                       ASSERT(pAd->BATable.BAOriEntry[i].Wcid <
-                              MAX_LEN_OF_MAC_TABLE);
-               }
-               total--;
-       }
-}
-
-void SendRefreshBAR(struct rt_rtmp_adapter *pAd, struct rt_mac_table_entry *pEntry)
-{
-       struct rt_frame_bar FrameBar;
-       unsigned long FrameLen;
-       int NStatus;
-       u8 *pOutBuffer = NULL;
-       u16 Sequence;
-       u8 i, TID;
-       u16 idx;
-       struct rt_ba_ori_entry *pBAEntry;
-
-       for (i = 0; i < NUM_OF_TID; i++) {
-               idx = pEntry->BAOriWcidArray[i];
-               if (idx == 0) {
-                       continue;
-               }
-               pBAEntry = &pAd->BATable.BAOriEntry[idx];
-
-               if (pBAEntry->ORI_BA_Status == Originator_Done) {
-                       TID = pBAEntry->TID;
-
-                       ASSERT(pBAEntry->Wcid < MAX_LEN_OF_MAC_TABLE);
-
-                       NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); /*Get an unused nonpaged memory */
-                       if (NStatus != NDIS_STATUS_SUCCESS) {
-                               DBGPRINT(RT_DEBUG_ERROR,
-                                        ("BA - MlmeADDBAAction() allocate memory failed \n"));
-                               return;
-                       }
-
-                       Sequence = pEntry->TxSeq[TID];
-
-                       BarHeaderInit(pAd, &FrameBar, pEntry->Addr,
-                                     pAd->CurrentAddress);
-
-                       FrameBar.StartingSeq.field.FragNum = 0; /* make sure sequence not clear in DEL function. */
-                       FrameBar.StartingSeq.field.StartSeq = Sequence; /* make sure sequence not clear in DEL funciton. */
-                       FrameBar.BarControl.TID = TID;  /* make sure sequence not clear in DEL funciton. */
-
-                       MakeOutgoingFrame(pOutBuffer, &FrameLen,
-                                         sizeof(struct rt_frame_bar), &FrameBar,
-                                         END_OF_ARGS);
-                       /*if (!(CLIENT_STATUS_TEST_FLAG(pEntry, fCLIENT_STATUS_RALINK_CHIPSET))) */
-                       if (1)  /* Now we always send BAR. */
-                       {
-                               /*MiniportMMRequestUnlock(pAd, 0, pOutBuffer, FrameLen); */
-                               MiniportMMRequest(pAd,
-                                                 (MGMT_USE_QUEUE_FLAG |
-                                                  MapUserPriorityToAccessCategory
-                                                  [TID]), pOutBuffer,
-                                                 FrameLen);
-
-                       }
-                       MlmeFreeMemory(pAd, pOutBuffer);
-               }
-       }
-}
-
-void ActHeaderInit(struct rt_rtmp_adapter *pAd,
-                  struct rt_header_802_11 * pHdr80211,
-                  u8 *Addr1, u8 *Addr2, u8 *Addr3)
-{
-       NdisZeroMemory(pHdr80211, sizeof(struct rt_header_802_11));
-       pHdr80211->FC.Type = BTYPE_MGMT;
-       pHdr80211->FC.SubType = SUBTYPE_ACTION;
-
-       COPY_MAC_ADDR(pHdr80211->Addr1, Addr1);
-       COPY_MAC_ADDR(pHdr80211->Addr2, Addr2);
-       COPY_MAC_ADDR(pHdr80211->Addr3, Addr3);
-}
-
-void BarHeaderInit(struct rt_rtmp_adapter *pAd,
-                  struct rt_frame_bar * pCntlBar, u8 *pDA, u8 *pSA)
-{
-       NdisZeroMemory(pCntlBar, sizeof(struct rt_frame_bar));
-       pCntlBar->FC.Type = BTYPE_CNTL;
-       pCntlBar->FC.SubType = SUBTYPE_BLOCK_ACK_REQ;
-       pCntlBar->BarControl.MTID = 0;
-       pCntlBar->BarControl.Compressed = 1;
-       pCntlBar->BarControl.ACKPolicy = 0;
-
-       pCntlBar->Duration =
-           16 + RTMPCalcDuration(pAd, RATE_1, sizeof(struct rt_frame_ba));
-
-       COPY_MAC_ADDR(pCntlBar->Addr1, pDA);
-       COPY_MAC_ADDR(pCntlBar->Addr2, pSA);
-}
-
-/*
-       ==========================================================================
-       Description:
-               Insert Category and action code into the action frame.
-
-       Parametrs:
-               1. frame buffer pointer.
-               2. frame length.
-               3. category code of the frame.
-               4. action code of the frame.
-
-       Return  : None.
-       ==========================================================================
- */
-void InsertActField(struct rt_rtmp_adapter *pAd,
-                   u8 *pFrameBuf,
-                   unsigned long *pFrameLen, u8 Category, u8 ActCode)
-{
-       unsigned long TempLen;
-
-       MakeOutgoingFrame(pFrameBuf, &TempLen,
-                         1, &Category, 1, &ActCode, END_OF_ARGS);
-
-       *pFrameLen = *pFrameLen + TempLen;
-
-       return;
-}
diff --git a/drivers/staging/rt2860/common/action.h b/drivers/staging/rt2860/common/action.h
deleted file mode 100644 (file)
index 974f8b8..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-       Module Name:
-       aironet.h
-
-       Abstract:
-
-       Revision History:
-       Who                     When                    What
-       --------        ----------              ----------------------------------------------
-       Name            Date                    Modification logs
-       Paul Lin        04-06-15                Initial
-*/
-
-#ifndef        __ACTION_H__
-#define        __ACTION_H__
-
-struct PACKED rt_ht_information_octet {
-       u8 Request:1;
-       u8 Forty_MHz_Intolerant:1;
-       u8 STA_Channel_Width:1;
-       u8 Reserved:5;
-};
-
-struct PACKED rt_frame_ht_info {
-       struct rt_header_802_11 Hdr;
-       u8 Category;
-       u8 Action;
-       struct rt_ht_information_octet HT_Info;
-};
-
-#endif /* __ACTION_H__ */
diff --git a/drivers/staging/rt2860/common/ba_action.c b/drivers/staging/rt2860/common/ba_action.c
deleted file mode 100644 (file)
index 133bc1b..0000000
+++ /dev/null
@@ -1,1650 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
- */
-
-#include "../rt_config.h"
-#include <linux/kernel.h>
-
-#define BA_ORI_INIT_SEQ                (pEntry->TxSeq[TID])    /*1                        // initial sequence number of BA session */
-
-#define ORI_SESSION_MAX_RETRY  8
-#define ORI_BA_SESSION_TIMEOUT (2000)  /* ms */
-#define REC_BA_SESSION_IDLE_TIMEOUT    (1000)  /* ms */
-
-#define REORDERING_PACKET_TIMEOUT              ((100 * OS_HZ)/1000)    /* system ticks -- 100 ms */
-#define MAX_REORDERING_PACKET_TIMEOUT  ((3000 * OS_HZ)/1000)   /* system ticks -- 100 ms */
-
-#define RESET_RCV_SEQ          (0xFFFF)
-
-static void ba_mpdu_blk_free(struct rt_rtmp_adapter *pAd,
-                            struct reordering_mpdu *mpdu_blk);
-
-struct rt_ba_ori_entry *BATableAllocOriEntry(struct rt_rtmp_adapter *pAd, u16 * Idx);
-
-struct rt_ba_rec_entry *BATableAllocRecEntry(struct rt_rtmp_adapter *pAd, u16 * Idx);
-
-void BAOriSessionSetupTimeout(void *SystemSpecific1,
-                             void *FunctionContext,
-                             void *SystemSpecific2,
-                             void *SystemSpecific3);
-
-void BARecSessionIdleTimeout(void *SystemSpecific1,
-                            void *FunctionContext,
-                            void *SystemSpecific2,
-                            void *SystemSpecific3);
-
-BUILD_TIMER_FUNCTION(BAOriSessionSetupTimeout);
-BUILD_TIMER_FUNCTION(BARecSessionIdleTimeout);
-
-#define ANNOUNCE_REORDERING_PACKET(_pAd, _mpdu_blk)    \
-                       Announce_Reordering_Packet(_pAd, _mpdu_blk);
-
-void BA_MaxWinSizeReasign(struct rt_rtmp_adapter *pAd,
-                         struct rt_mac_table_entry *pEntryPeer, u8 * pWinSize)
-{
-       u8 MaxSize;
-
-       if (pAd->MACVersion >= RALINK_2883_VERSION)     /* 3*3 */
-       {
-               if (pAd->MACVersion >= RALINK_3070_VERSION) {
-                       if (pEntryPeer->WepStatus !=
-                           Ndis802_11EncryptionDisabled)
-                               MaxSize = 7;    /* for non-open mode */
-                       else
-                               MaxSize = 13;
-               } else
-                       MaxSize = 31;
-       } else if (pAd->MACVersion >= RALINK_2880E_VERSION)     /* 2880 e */
-       {
-               if (pEntryPeer->WepStatus != Ndis802_11EncryptionDisabled)
-                       MaxSize = 7;    /* for non-open mode */
-               else
-                       MaxSize = 13;
-       } else
-               MaxSize = 7;
-
-       DBGPRINT(RT_DEBUG_TRACE, ("ba> Win Size = %d, Max Size = %d\n",
-                                 *pWinSize, MaxSize));
-
-       if ((*pWinSize) > MaxSize) {
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("ba> reassign max win size from %d to %d\n",
-                         *pWinSize, MaxSize));
-
-               *pWinSize = MaxSize;
-       }
-}
-
-void Announce_Reordering_Packet(struct rt_rtmp_adapter *pAd,
-                               IN struct reordering_mpdu *mpdu)
-{
-       void *pPacket;
-
-       pPacket = mpdu->pPacket;
-
-       if (mpdu->bAMSDU) {
-               ASSERT(0);
-               BA_Reorder_AMSDU_Announce(pAd, pPacket);
-       } else {
-               /* */
-               /* pass this 802.3 packet to upper layer or forward this packet to WM directly */
-               /* */
-
-               ANNOUNCE_OR_FORWARD_802_3_PACKET(pAd, pPacket,
-                                                RTMP_GET_PACKET_IF(pPacket));
-       }
-}
-
-/*
- * Insert a reordering mpdu into sorted linked list by sequence no.
- */
-BOOLEAN ba_reordering_mpdu_insertsorted(struct reordering_list *list,
-                                       struct reordering_mpdu *mpdu)
-{
-
-       struct reordering_mpdu **ppScan = &list->next;
-
-       while (*ppScan != NULL) {
-               if (SEQ_SMALLER((*ppScan)->Sequence, mpdu->Sequence, MAXSEQ)) {
-                       ppScan = &(*ppScan)->next;
-               } else if ((*ppScan)->Sequence == mpdu->Sequence) {
-                       /* give up this duplicated frame */
-                       return (FALSE);
-               } else {
-                       /* find position */
-                       break;
-               }
-       }
-
-       mpdu->next = *ppScan;
-       *ppScan = mpdu;
-       list->qlen++;
-       return TRUE;
-}
-
-/*
- * caller lock critical section if necessary
- */
-static inline void ba_enqueue(struct reordering_list *list,
-                             struct reordering_mpdu *mpdu_blk)
-{
-       list->qlen++;
-       mpdu_blk->next = list->next;
-       list->next = mpdu_blk;
-}
-
-/*
- * caller lock critical section if necessary
- */
-static inline struct reordering_mpdu *ba_dequeue(struct reordering_list *list)
-{
-       struct reordering_mpdu *mpdu_blk = NULL;
-
-       ASSERT(list);
-
-       if (list->qlen) {
-               list->qlen--;
-               mpdu_blk = list->next;
-               if (mpdu_blk) {
-                       list->next = mpdu_blk->next;
-                       mpdu_blk->next = NULL;
-               }
-       }
-       return mpdu_blk;
-}
-
-static inline struct reordering_mpdu *ba_reordering_mpdu_dequeue(struct
-                                                                reordering_list
-                                                                *list)
-{
-       return (ba_dequeue(list));
-}
-
-static inline struct reordering_mpdu *ba_reordering_mpdu_probe(struct
-                                                              reordering_list
-                                                              *list)
-{
-       ASSERT(list);
-
-       return (list->next);
-}
-
-/*
- * free all resource for reordering mechanism
- */
-void ba_reordering_resource_release(struct rt_rtmp_adapter *pAd)
-{
-       struct rt_ba_table *Tab;
-       struct rt_ba_rec_entry *pBAEntry;
-       struct reordering_mpdu *mpdu_blk;
-       int i;
-
-       Tab = &pAd->BATable;
-
-       /* I.  release all pending reordering packet */
-       NdisAcquireSpinLock(&pAd->BATabLock);
-       for (i = 0; i < MAX_LEN_OF_BA_REC_TABLE; i++) {
-               pBAEntry = &Tab->BARecEntry[i];
-               if (pBAEntry->REC_BA_Status != Recipient_NONE) {
-                       while ((mpdu_blk =
-                               ba_reordering_mpdu_dequeue(&pBAEntry->list))) {
-                               ASSERT(mpdu_blk->pPacket);
-                               RELEASE_NDIS_PACKET(pAd, mpdu_blk->pPacket,
-                                                   NDIS_STATUS_FAILURE);
-                               ba_mpdu_blk_free(pAd, mpdu_blk);
-                       }
-               }
-       }
-       NdisReleaseSpinLock(&pAd->BATabLock);
-
-       ASSERT(pBAEntry->list.qlen == 0);
-       /* II. free memory of reordering mpdu table */
-       NdisAcquireSpinLock(&pAd->mpdu_blk_pool.lock);
-       os_free_mem(pAd, pAd->mpdu_blk_pool.mem);
-       NdisReleaseSpinLock(&pAd->mpdu_blk_pool.lock);
-}
-
-/*
- * Allocate all resource for reordering mechanism
- */
-BOOLEAN ba_reordering_resource_init(struct rt_rtmp_adapter *pAd, int num)
-{
-       int i;
-       u8 *mem;
-       struct reordering_mpdu *mpdu_blk;
-       struct reordering_list *freelist;
-
-       /* allocate spinlock */
-       NdisAllocateSpinLock(&pAd->mpdu_blk_pool.lock);
-
-       /* initialize freelist */
-       freelist = &pAd->mpdu_blk_pool.freelist;
-       freelist->next = NULL;
-       freelist->qlen = 0;
-
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("Allocate %d memory for BA reordering\n",
-                 (u32)(num * sizeof(struct reordering_mpdu))));
-
-       /* allocate number of mpdu_blk memory */
-       os_alloc_mem(pAd, (u8 **) & mem,
-                    (num * sizeof(struct reordering_mpdu)));
-
-       pAd->mpdu_blk_pool.mem = mem;
-
-       if (mem == NULL) {
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("Can't Allocate Memory for BA Reordering\n"));
-               return (FALSE);
-       }
-
-       /* build mpdu_blk free list */
-       for (i = 0; i < num; i++) {
-               /* get mpdu_blk */
-               mpdu_blk = (struct reordering_mpdu *)mem;
-               /* initial mpdu_blk */
-               NdisZeroMemory(mpdu_blk, sizeof(struct reordering_mpdu));
-               /* next mpdu_blk */
-               mem += sizeof(struct reordering_mpdu);
-               /* insert mpdu_blk into freelist */
-               ba_enqueue(freelist, mpdu_blk);
-       }
-
-       return (TRUE);
-}
-
-/*static int blk_count=0; // sample take off, no use */
-
-static struct reordering_mpdu *ba_mpdu_blk_alloc(struct rt_rtmp_adapter *pAd)
-{
-       struct reordering_mpdu *mpdu_blk;
-
-       NdisAcquireSpinLock(&pAd->mpdu_blk_pool.lock);
-       mpdu_blk = ba_dequeue(&pAd->mpdu_blk_pool.freelist);
-       if (mpdu_blk) {
-/*              blk_count++; */
-               /* reset mpdu_blk */
-               NdisZeroMemory(mpdu_blk, sizeof(struct reordering_mpdu));
-       }
-       NdisReleaseSpinLock(&pAd->mpdu_blk_pool.lock);
-       return mpdu_blk;
-}
-
-static void ba_mpdu_blk_free(struct rt_rtmp_adapter *pAd,
-                            struct reordering_mpdu *mpdu_blk)
-{
-       ASSERT(mpdu_blk);
-
-       NdisAcquireSpinLock(&pAd->mpdu_blk_pool.lock);
-/*      blk_count--; */
-       ba_enqueue(&pAd->mpdu_blk_pool.freelist, mpdu_blk);
-       NdisReleaseSpinLock(&pAd->mpdu_blk_pool.lock);
-}
-
-static u16 ba_indicate_reordering_mpdus_in_order(struct rt_rtmp_adapter *pAd,
-                                                   struct rt_ba_rec_entry *pBAEntry,
-                                                   u16 StartSeq)
-{
-       struct reordering_mpdu *mpdu_blk;
-       u16 LastIndSeq = RESET_RCV_SEQ;
-
-       NdisAcquireSpinLock(&pBAEntry->RxReRingLock);
-
-       while ((mpdu_blk = ba_reordering_mpdu_probe(&pBAEntry->list))) {
-               /* find in-order frame */
-               if (!SEQ_STEPONE(mpdu_blk->Sequence, StartSeq, MAXSEQ)) {
-                       break;
-               }
-               /* dequeue in-order frame from reodering list */
-               mpdu_blk = ba_reordering_mpdu_dequeue(&pBAEntry->list);
-               /* pass this frame up */
-               ANNOUNCE_REORDERING_PACKET(pAd, mpdu_blk);
-               /* move to next sequence */
-               StartSeq = mpdu_blk->Sequence;
-               LastIndSeq = StartSeq;
-               /* free mpdu_blk */
-               ba_mpdu_blk_free(pAd, mpdu_blk);
-       }
-
-       NdisReleaseSpinLock(&pBAEntry->RxReRingLock);
-
-       /* update last indicated sequence */
-       return LastIndSeq;
-}
-
-static void ba_indicate_reordering_mpdus_le_seq(struct rt_rtmp_adapter *pAd,
-                                               struct rt_ba_rec_entry *pBAEntry,
-                                               u16 Sequence)
-{
-       struct reordering_mpdu *mpdu_blk;
-
-       NdisAcquireSpinLock(&pBAEntry->RxReRingLock);
-       while ((mpdu_blk = ba_reordering_mpdu_probe(&pBAEntry->list))) {
-               /* find in-order frame */
-               if ((mpdu_blk->Sequence == Sequence)
-                   || SEQ_SMALLER(mpdu_blk->Sequence, Sequence, MAXSEQ)) {
-                       /* dequeue in-order frame from reodering list */
-                       mpdu_blk = ba_reordering_mpdu_dequeue(&pBAEntry->list);
-                       /* pass this frame up */
-                       ANNOUNCE_REORDERING_PACKET(pAd, mpdu_blk);
-                       /* free mpdu_blk */
-                       ba_mpdu_blk_free(pAd, mpdu_blk);
-               } else {
-                       break;
-               }
-       }
-       NdisReleaseSpinLock(&pBAEntry->RxReRingLock);
-}
-
-static void ba_refresh_reordering_mpdus(struct rt_rtmp_adapter *pAd,
-                                       struct rt_ba_rec_entry *pBAEntry)
-{
-       struct reordering_mpdu *mpdu_blk;
-
-       NdisAcquireSpinLock(&pBAEntry->RxReRingLock);
-
-       /* dequeue in-order frame from reodering list */
-       while ((mpdu_blk = ba_reordering_mpdu_dequeue(&pBAEntry->list))) {
-               /* pass this frame up */
-               ANNOUNCE_REORDERING_PACKET(pAd, mpdu_blk);
-
-               pBAEntry->LastIndSeq = mpdu_blk->Sequence;
-               ba_mpdu_blk_free(pAd, mpdu_blk);
-
-               /* update last indicated sequence */
-       }
-       ASSERT(pBAEntry->list.qlen == 0);
-       pBAEntry->LastIndSeq = RESET_RCV_SEQ;
-       NdisReleaseSpinLock(&pBAEntry->RxReRingLock);
-}
-
-/*static */
-void ba_flush_reordering_timeout_mpdus(struct rt_rtmp_adapter *pAd,
-                                      struct rt_ba_rec_entry *pBAEntry,
-                                      unsigned long Now32)
-{
-       u16 Sequence;
-
-/*      if ((RTMP_TIME_AFTER((unsigned long)Now32, (unsigned long)(pBAEntry->LastIndSeqAtTimer+REORDERING_PACKET_TIMEOUT)) && */
-/*               (pBAEntry->list.qlen > ((pBAEntry->BAWinSize*7)/8))) //|| */
-/*              (RTMP_TIME_AFTER((unsigned long)Now32, (unsigned long)(pBAEntry->LastIndSeqAtTimer+(10*REORDERING_PACKET_TIMEOUT))) && */
-/*               (pBAEntry->list.qlen > (pBAEntry->BAWinSize/8))) */
-       if (RTMP_TIME_AFTER
-           ((unsigned long)Now32,
-            (unsigned long)(pBAEntry->LastIndSeqAtTimer +
-                            (MAX_REORDERING_PACKET_TIMEOUT / 6)))
-           && (pBAEntry->list.qlen > 1)
-           ) {
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("timeout[%d] (%08lx-%08lx = %d > %d): %x, flush all!\n ",
-                         pBAEntry->list.qlen, Now32,
-                         (pBAEntry->LastIndSeqAtTimer),
-                         (int)((long)Now32 -
-                               (long)(pBAEntry->LastIndSeqAtTimer)),
-                         MAX_REORDERING_PACKET_TIMEOUT, pBAEntry->LastIndSeq));
-               ba_refresh_reordering_mpdus(pAd, pBAEntry);
-               pBAEntry->LastIndSeqAtTimer = Now32;
-       } else
-           if (RTMP_TIME_AFTER
-               ((unsigned long)Now32,
-                (unsigned long)(pBAEntry->LastIndSeqAtTimer +
-                                (REORDERING_PACKET_TIMEOUT)))
-               && (pBAEntry->list.qlen > 0)
-           ) {
-               /* */
-               /* force LastIndSeq to shift to LastIndSeq+1 */
-               /* */
-               Sequence = (pBAEntry->LastIndSeq + 1) & MAXSEQ;
-               ba_indicate_reordering_mpdus_le_seq(pAd, pBAEntry, Sequence);
-               pBAEntry->LastIndSeqAtTimer = Now32;
-               pBAEntry->LastIndSeq = Sequence;
-               /* */
-               /* indicate in-order mpdus */
-               /* */
-               Sequence =
-                   ba_indicate_reordering_mpdus_in_order(pAd, pBAEntry,
-                                                         Sequence);
-               if (Sequence != RESET_RCV_SEQ) {
-                       pBAEntry->LastIndSeq = Sequence;
-               }
-
-               DBGPRINT(RT_DEBUG_OFF,
-                        ("%x, flush one!\n", pBAEntry->LastIndSeq));
-
-       }
-}
-
-/*
- * generate ADDBA request to
- * set up BA agreement
- */
-void BAOriSessionSetUp(struct rt_rtmp_adapter *pAd,
-                      struct rt_mac_table_entry *pEntry,
-                      u8 TID,
-                      u16 TimeOut,
-                      unsigned long DelayTime, IN BOOLEAN isForced)
-{
-       /*struct rt_mlme_addba_req AddbaReq; */
-       struct rt_ba_ori_entry *pBAEntry = NULL;
-       u16 Idx;
-       BOOLEAN Cancelled;
-
-       if ((pAd->CommonCfg.BACapability.field.AutoBA != TRUE)
-           && (isForced == FALSE))
-               return;
-
-       /* if this entry is limited to use legacy tx mode, it doesn't generate BA. */
-       if (RTMPStaFixedTxMode(pAd, pEntry) != FIXED_TXMODE_HT)
-               return;
-
-       if ((pEntry->BADeclineBitmap & (1 << TID)) && (isForced == FALSE)) {
-               /* try again after 3 secs */
-               DelayTime = 3000;
-/*              DBGPRINT(RT_DEBUG_TRACE, ("DeCline BA from Peer\n")); */
-/*              return; */
-       }
-
-       Idx = pEntry->BAOriWcidArray[TID];
-       if (Idx == 0) {
-               /* allocate a BA session */
-               pBAEntry = BATableAllocOriEntry(pAd, &Idx);
-               if (pBAEntry == NULL) {
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("ADDBA - MlmeADDBAAction() allocate BA session failed \n"));
-                       return;
-               }
-       } else {
-               pBAEntry = &pAd->BATable.BAOriEntry[Idx];
-       }
-
-       if (pBAEntry->ORI_BA_Status >= Originator_WaitRes) {
-               return;
-       }
-
-       pEntry->BAOriWcidArray[TID] = Idx;
-
-       /* Initialize BA session */
-       pBAEntry->ORI_BA_Status = Originator_WaitRes;
-       pBAEntry->Wcid = pEntry->Aid;
-       pBAEntry->BAWinSize = pAd->CommonCfg.BACapability.field.RxBAWinLimit;
-       pBAEntry->Sequence = BA_ORI_INIT_SEQ;
-       pBAEntry->Token = 1;    /* (2008-01-21) Jan Lee recommends it - this token can't be 0 */
-       pBAEntry->TID = TID;
-       pBAEntry->TimeOutValue = TimeOut;
-       pBAEntry->pAdapter = pAd;
-
-       if (!(pEntry->TXBAbitmap & (1 << TID))) {
-               RTMPInitTimer(pAd, &pBAEntry->ORIBATimer,
-                             GET_TIMER_FUNCTION(BAOriSessionSetupTimeout),
-                             pBAEntry, FALSE);
-       } else
-               RTMPCancelTimer(&pBAEntry->ORIBATimer, &Cancelled);
-
-       /* set timer to send ADDBA request */
-       RTMPSetTimer(&pBAEntry->ORIBATimer, DelayTime);
-}
-
-void BAOriSessionAdd(struct rt_rtmp_adapter *pAd,
-                    struct rt_mac_table_entry *pEntry, struct rt_frame_addba_rsp * pFrame)
-{
-       struct rt_ba_ori_entry *pBAEntry = NULL;
-       BOOLEAN Cancelled;
-       u8 TID;
-       u16 Idx;
-       u8 *pOutBuffer2 = NULL;
-       int NStatus;
-       unsigned long FrameLen;
-       struct rt_frame_bar FrameBar;
-
-       TID = pFrame->BaParm.TID;
-       Idx = pEntry->BAOriWcidArray[TID];
-       pBAEntry = &pAd->BATable.BAOriEntry[Idx];
-
-       /* Start fill in parameters. */
-       if ((Idx != 0) && (pBAEntry->TID == TID)
-           && (pBAEntry->ORI_BA_Status == Originator_WaitRes)) {
-               pBAEntry->BAWinSize =
-                   min(pBAEntry->BAWinSize, ((u8)pFrame->BaParm.BufSize));
-               BA_MaxWinSizeReasign(pAd, pEntry, &pBAEntry->BAWinSize);
-
-               pBAEntry->TimeOutValue = pFrame->TimeOutValue;
-               pBAEntry->ORI_BA_Status = Originator_Done;
-               pAd->BATable.numDoneOriginator++;
-
-               /* reset sequence number */
-               pBAEntry->Sequence = BA_ORI_INIT_SEQ;
-               /* Set Bitmap flag. */
-               pEntry->TXBAbitmap |= (1 << TID);
-               RTMPCancelTimer(&pBAEntry->ORIBATimer, &Cancelled);
-
-               pBAEntry->ORIBATimer.TimerValue = 0;    /*pFrame->TimeOutValue; */
-
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("%s : TXBAbitmap = %x, BAWinSize = %d, TimeOut = %ld\n",
-                         __func__, pEntry->TXBAbitmap, pBAEntry->BAWinSize,
-                         pBAEntry->ORIBATimer.TimerValue));
-
-               /* SEND BAR ; */
-               NStatus = MlmeAllocateMemory(pAd, &pOutBuffer2);        /*Get an unused nonpaged memory */
-               if (NStatus != NDIS_STATUS_SUCCESS) {
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("BA - BAOriSessionAdd() allocate memory failed \n"));
-                       return;
-               }
-
-               BarHeaderInit(pAd, &FrameBar,
-                             pAd->MacTab.Content[pBAEntry->Wcid].Addr,
-                             pAd->CurrentAddress);
-
-               FrameBar.StartingSeq.field.FragNum = 0; /* make sure sequence not clear in DEL function. */
-               FrameBar.StartingSeq.field.StartSeq = pBAEntry->Sequence;       /* make sure sequence not clear in DEL funciton. */
-               FrameBar.BarControl.TID = pBAEntry->TID;        /* make sure sequence not clear in DEL funciton. */
-               MakeOutgoingFrame(pOutBuffer2, &FrameLen,
-                                 sizeof(struct rt_frame_bar), &FrameBar, END_OF_ARGS);
-               MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer2, FrameLen);
-               MlmeFreeMemory(pAd, pOutBuffer2);
-
-               if (pBAEntry->ORIBATimer.TimerValue)
-                       RTMPSetTimer(&pBAEntry->ORIBATimer, pBAEntry->ORIBATimer.TimerValue);   /* in mSec */
-       }
-}
-
-BOOLEAN BARecSessionAdd(struct rt_rtmp_adapter *pAd,
-                       struct rt_mac_table_entry *pEntry, struct rt_frame_addba_req * pFrame)
-{
-       struct rt_ba_rec_entry *pBAEntry = NULL;
-       BOOLEAN Status = TRUE;
-       BOOLEAN Cancelled;
-       u16 Idx;
-       u8 TID;
-       u8 BAWinSize;
-       /*u32                  Value; */
-       /*u32                    offset; */
-
-       ASSERT(pEntry);
-
-       /* find TID */
-       TID = pFrame->BaParm.TID;
-
-       BAWinSize =
-           min(((u8)pFrame->BaParm.BufSize),
-               (u8)pAd->CommonCfg.BACapability.field.RxBAWinLimit);
-
-       /* Intel patch */
-       if (BAWinSize == 0) {
-               BAWinSize = 64;
-       }
-
-       Idx = pEntry->BARecWcidArray[TID];
-
-       if (Idx == 0) {
-               pBAEntry = BATableAllocRecEntry(pAd, &Idx);
-       } else {
-               pBAEntry = &pAd->BATable.BARecEntry[Idx];
-               /* flush all pending reordering mpdus */
-               ba_refresh_reordering_mpdus(pAd, pBAEntry);
-       }
-
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("%s(%ld): Idx = %d, BAWinSize(req %d) = %d\n", __func__,
-                 pAd->BATable.numAsRecipient, Idx, pFrame->BaParm.BufSize,
-                 BAWinSize));
-
-       /* Start fill in parameters. */
-       if (pBAEntry != NULL) {
-               ASSERT(pBAEntry->list.qlen == 0);
-
-               pBAEntry->REC_BA_Status = Recipient_HandleRes;
-               pBAEntry->BAWinSize = BAWinSize;
-               pBAEntry->Wcid = pEntry->Aid;
-               pBAEntry->TID = TID;
-               pBAEntry->TimeOutValue = pFrame->TimeOutValue;
-               pBAEntry->REC_BA_Status = Recipient_Accept;
-               /* initial sequence number */
-               pBAEntry->LastIndSeq = RESET_RCV_SEQ;   /*pFrame->BaStartSeq.field.StartSeq; */
-
-               DBGPRINT(RT_DEBUG_OFF,
-                        ("Start Seq = %08x\n",
-                         pFrame->BaStartSeq.field.StartSeq));
-
-               if (pEntry->RXBAbitmap & (1 << TID)) {
-                       RTMPCancelTimer(&pBAEntry->RECBATimer, &Cancelled);
-               } else {
-                       RTMPInitTimer(pAd, &pBAEntry->RECBATimer,
-                                     GET_TIMER_FUNCTION
-                                     (BARecSessionIdleTimeout), pBAEntry,
-                                     TRUE);
-               }
-
-               /* Set Bitmap flag. */
-               pEntry->RXBAbitmap |= (1 << TID);
-               pEntry->BARecWcidArray[TID] = Idx;
-
-               pEntry->BADeclineBitmap &= ~(1 << TID);
-
-               /* Set BA session mask in WCID table. */
-               RTMP_ADD_BA_SESSION_TO_ASIC(pAd, pEntry->Aid, TID);
-
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("MACEntry[%d]RXBAbitmap = 0x%x. BARecWcidArray=%d\n",
-                         pEntry->Aid, pEntry->RXBAbitmap,
-                         pEntry->BARecWcidArray[TID]));
-       } else {
-               Status = FALSE;
-               DBGPRINT(RT_DEBUG_TRACE,
-                       ("Can't Accept ADDBA for %pM TID = %d\n",
-                               pEntry->Addr, TID));
-       }
-       return (Status);
-}
-
-struct rt_ba_rec_entry *BATableAllocRecEntry(struct rt_rtmp_adapter *pAd, u16 * Idx)
-{
-       int i;
-       struct rt_ba_rec_entry *pBAEntry = NULL;
-
-       NdisAcquireSpinLock(&pAd->BATabLock);
-
-       if (pAd->BATable.numAsRecipient >= MAX_BARECI_SESSION) {
-               DBGPRINT(RT_DEBUG_OFF, ("BA Recipeint Session (%ld) > %d\n",
-                                       pAd->BATable.numAsRecipient,
-                                       MAX_BARECI_SESSION));
-               goto done;
-       }
-       /* reserve idx 0 to identify BAWcidArray[TID] as empty */
-       for (i = 1; i < MAX_LEN_OF_BA_REC_TABLE; i++) {
-               pBAEntry = &pAd->BATable.BARecEntry[i];
-               if ((pBAEntry->REC_BA_Status == Recipient_NONE)) {
-                       /* get one */
-                       pAd->BATable.numAsRecipient++;
-                       pBAEntry->REC_BA_Status = Recipient_USED;
-                       *Idx = i;
-                       break;
-               }
-       }
-
-done:
-       NdisReleaseSpinLock(&pAd->BATabLock);
-       return pBAEntry;
-}
-
-struct rt_ba_ori_entry *BATableAllocOriEntry(struct rt_rtmp_adapter *pAd, u16 * Idx)
-{
-       int i;
-       struct rt_ba_ori_entry *pBAEntry = NULL;
-
-       NdisAcquireSpinLock(&pAd->BATabLock);
-
-       if (pAd->BATable.numAsOriginator >= (MAX_LEN_OF_BA_ORI_TABLE)) {
-               goto done;
-       }
-       /* reserve idx 0 to identify BAWcidArray[TID] as empty */
-       for (i = 1; i < MAX_LEN_OF_BA_ORI_TABLE; i++) {
-               pBAEntry = &pAd->BATable.BAOriEntry[i];
-               if ((pBAEntry->ORI_BA_Status == Originator_NONE)) {
-                       /* get one */
-                       pAd->BATable.numAsOriginator++;
-                       pBAEntry->ORI_BA_Status = Originator_USED;
-                       pBAEntry->pAdapter = pAd;
-                       *Idx = i;
-                       break;
-               }
-       }
-
-done:
-       NdisReleaseSpinLock(&pAd->BATabLock);
-       return pBAEntry;
-}
-
-void BATableFreeOriEntry(struct rt_rtmp_adapter *pAd, unsigned long Idx)
-{
-       struct rt_ba_ori_entry *pBAEntry = NULL;
-       struct rt_mac_table_entry *pEntry;
-
-       if ((Idx == 0) || (Idx >= MAX_LEN_OF_BA_ORI_TABLE))
-               return;
-
-       pBAEntry = &pAd->BATable.BAOriEntry[Idx];
-
-       if (pBAEntry->ORI_BA_Status != Originator_NONE) {
-               pEntry = &pAd->MacTab.Content[pBAEntry->Wcid];
-               pEntry->BAOriWcidArray[pBAEntry->TID] = 0;
-
-               NdisAcquireSpinLock(&pAd->BATabLock);
-               if (pBAEntry->ORI_BA_Status == Originator_Done) {
-                       pAd->BATable.numDoneOriginator -= 1;
-                       pEntry->TXBAbitmap &= (~(1 << (pBAEntry->TID)));
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("BATableFreeOriEntry numAsOriginator= %ld\n",
-                                 pAd->BATable.numAsRecipient));
-                       /* Erase Bitmap flag. */
-               }
-
-               ASSERT(pAd->BATable.numAsOriginator != 0);
-
-               pAd->BATable.numAsOriginator -= 1;
-
-               pBAEntry->ORI_BA_Status = Originator_NONE;
-               pBAEntry->Token = 0;
-               NdisReleaseSpinLock(&pAd->BATabLock);
-       }
-}
-
-void BATableFreeRecEntry(struct rt_rtmp_adapter *pAd, unsigned long Idx)
-{
-       struct rt_ba_rec_entry *pBAEntry = NULL;
-       struct rt_mac_table_entry *pEntry;
-
-       if ((Idx == 0) || (Idx >= MAX_LEN_OF_BA_REC_TABLE))
-               return;
-
-       pBAEntry = &pAd->BATable.BARecEntry[Idx];
-
-       if (pBAEntry->REC_BA_Status != Recipient_NONE) {
-               pEntry = &pAd->MacTab.Content[pBAEntry->Wcid];
-               pEntry->BARecWcidArray[pBAEntry->TID] = 0;
-
-               NdisAcquireSpinLock(&pAd->BATabLock);
-
-               ASSERT(pAd->BATable.numAsRecipient != 0);
-
-               pAd->BATable.numAsRecipient -= 1;
-
-               pBAEntry->REC_BA_Status = Recipient_NONE;
-               NdisReleaseSpinLock(&pAd->BATabLock);
-       }
-}
-
-void BAOriSessionTearDown(struct rt_rtmp_adapter *pAd,
-                         u8 Wcid,
-                         u8 TID,
-                         IN BOOLEAN bPassive, IN BOOLEAN bForceSend)
-{
-       unsigned long Idx = 0;
-       struct rt_ba_ori_entry *pBAEntry;
-       BOOLEAN Cancelled;
-
-       if (Wcid >= MAX_LEN_OF_MAC_TABLE) {
-               return;
-       }
-       /* */
-       /* Locate corresponding BA Originator Entry in BA Table with the (pAddr,TID). */
-       /* */
-       Idx = pAd->MacTab.Content[Wcid].BAOriWcidArray[TID];
-       if ((Idx == 0) || (Idx >= MAX_LEN_OF_BA_ORI_TABLE)) {
-               if (bForceSend == TRUE) {
-                       /* force send specified TID DelBA */
-                       struct rt_mlme_delba_req DelbaReq;
-                       struct rt_mlme_queue_elem *Elem =
-                               kmalloc(sizeof(struct rt_mlme_queue_elem),
-                                       MEM_ALLOC_FLAG);
-                       if (Elem != NULL) {
-                               NdisZeroMemory(&DelbaReq, sizeof(DelbaReq));
-                               NdisZeroMemory(Elem, sizeof(struct rt_mlme_queue_elem));
-
-                               COPY_MAC_ADDR(DelbaReq.Addr,
-                                             pAd->MacTab.Content[Wcid].Addr);
-                               DelbaReq.Wcid = Wcid;
-                               DelbaReq.TID = TID;
-                               DelbaReq.Initiator = ORIGINATOR;
-                               Elem->MsgLen = sizeof(DelbaReq);
-                               NdisMoveMemory(Elem->Msg, &DelbaReq,
-                                              sizeof(DelbaReq));
-                               MlmeDELBAAction(pAd, Elem);
-                               kfree(Elem);
-                       } else {
-                               DBGPRINT(RT_DEBUG_ERROR,
-                                        ("%s(bForceSend):alloc memory failed!\n",
-                                         __func__));
-                       }
-               }
-
-               return;
-       }
-
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("%s===>Wcid=%d.TID=%d \n", __func__, Wcid, TID));
-
-       pBAEntry = &pAd->BATable.BAOriEntry[Idx];
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("\t===>Idx = %ld, Wcid=%d.TID=%d, ORI_BA_Status = %d \n", Idx,
-                 Wcid, TID, pBAEntry->ORI_BA_Status));
-       /* */
-       /* Prepare DelBA action frame and send to the peer. */
-       /* */
-       if ((bPassive == FALSE) && (TID == pBAEntry->TID)
-           && (pBAEntry->ORI_BA_Status == Originator_Done)) {
-               struct rt_mlme_delba_req DelbaReq;
-               struct rt_mlme_queue_elem *Elem =
-                       kmalloc(sizeof(struct rt_mlme_queue_elem),
-                               MEM_ALLOC_FLAG);
-               if (Elem != NULL) {
-                       NdisZeroMemory(&DelbaReq, sizeof(DelbaReq));
-                       NdisZeroMemory(Elem, sizeof(struct rt_mlme_queue_elem));
-
-                       COPY_MAC_ADDR(DelbaReq.Addr,
-                                     pAd->MacTab.Content[Wcid].Addr);
-                       DelbaReq.Wcid = Wcid;
-                       DelbaReq.TID = pBAEntry->TID;
-                       DelbaReq.Initiator = ORIGINATOR;
-                       Elem->MsgLen = sizeof(DelbaReq);
-                       NdisMoveMemory(Elem->Msg, &DelbaReq, sizeof(DelbaReq));
-                       MlmeDELBAAction(pAd, Elem);
-                       kfree(Elem);
-               } else {
-                       DBGPRINT(RT_DEBUG_ERROR,
-                                ("%s():alloc memory failed!\n", __func__));
-                       return;
-               }
-       }
-       RTMPCancelTimer(&pBAEntry->ORIBATimer, &Cancelled);
-       BATableFreeOriEntry(pAd, Idx);
-
-       if (bPassive) {
-               /*BAOriSessionSetUp(pAd, &pAd->MacTab.Content[Wcid], TID, 0, 10000, TRUE); */
-       }
-}
-
-void BARecSessionTearDown(struct rt_rtmp_adapter *pAd,
-                         u8 Wcid, u8 TID, IN BOOLEAN bPassive)
-{
-       unsigned long Idx = 0;
-       struct rt_ba_rec_entry *pBAEntry;
-
-       if (Wcid >= MAX_LEN_OF_MAC_TABLE) {
-               return;
-       }
-       /* */
-       /*  Locate corresponding BA Originator Entry in BA Table with the (pAddr,TID). */
-       /* */
-       Idx = pAd->MacTab.Content[Wcid].BARecWcidArray[TID];
-       if (Idx == 0)
-               return;
-
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("%s===>Wcid=%d.TID=%d \n", __func__, Wcid, TID));
-
-       pBAEntry = &pAd->BATable.BARecEntry[Idx];
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("\t===>Idx = %ld, Wcid=%d.TID=%d, REC_BA_Status = %d \n", Idx,
-                 Wcid, TID, pBAEntry->REC_BA_Status));
-       /* */
-       /* Prepare DelBA action frame and send to the peer. */
-       /* */
-       if ((TID == pBAEntry->TID)
-           && (pBAEntry->REC_BA_Status == Recipient_Accept)) {
-               struct rt_mlme_delba_req DelbaReq;
-               BOOLEAN Cancelled;
-               /*unsigned long   offset; */
-               /*u32  VALUE; */
-
-               RTMPCancelTimer(&pBAEntry->RECBATimer, &Cancelled);
-
-               /* */
-               /* 1. Send DELBA Action Frame */
-               /* */
-               if (bPassive == FALSE) {
-                       struct rt_mlme_queue_elem *Elem =
-                               kmalloc(sizeof(struct rt_mlme_queue_elem),
-                                       MEM_ALLOC_FLAG);
-                       if (Elem != NULL) {
-                               NdisZeroMemory(&DelbaReq, sizeof(DelbaReq));
-                               NdisZeroMemory(Elem, sizeof(struct rt_mlme_queue_elem));
-
-                               COPY_MAC_ADDR(DelbaReq.Addr,
-                                             pAd->MacTab.Content[Wcid].Addr);
-                               DelbaReq.Wcid = Wcid;
-                               DelbaReq.TID = TID;
-                               DelbaReq.Initiator = RECIPIENT;
-                               Elem->MsgLen = sizeof(DelbaReq);
-                               NdisMoveMemory(Elem->Msg, &DelbaReq,
-                                              sizeof(DelbaReq));
-                               MlmeDELBAAction(pAd, Elem);
-                               kfree(Elem);
-                       } else {
-                               DBGPRINT(RT_DEBUG_ERROR,
-                                        ("%s():alloc memory failed!\n",
-                                         __func__));
-                               return;
-                       }
-               }
-
-               /* */
-               /* 2. Free resource of BA session */
-               /* */
-               /* flush all pending reordering mpdus */
-               ba_refresh_reordering_mpdus(pAd, pBAEntry);
-
-               NdisAcquireSpinLock(&pAd->BATabLock);
-
-               /* Erase Bitmap flag. */
-               pBAEntry->LastIndSeq = RESET_RCV_SEQ;
-               pBAEntry->BAWinSize = 0;
-               /* Erase Bitmap flag at software mactable */
-               pAd->MacTab.Content[Wcid].RXBAbitmap &=
-                   (~(1 << (pBAEntry->TID)));
-               pAd->MacTab.Content[Wcid].BARecWcidArray[TID] = 0;
-
-               RTMP_DEL_BA_SESSION_FROM_ASIC(pAd, Wcid, TID);
-
-               NdisReleaseSpinLock(&pAd->BATabLock);
-
-       }
-
-       BATableFreeRecEntry(pAd, Idx);
-}
-
-void BASessionTearDownALL(struct rt_rtmp_adapter *pAd, u8 Wcid)
-{
-       int i;
-
-       for (i = 0; i < NUM_OF_TID; i++) {
-               BAOriSessionTearDown(pAd, Wcid, i, FALSE, FALSE);
-               BARecSessionTearDown(pAd, Wcid, i, FALSE);
-       }
-}
-
-/*
-       ==========================================================================
-       Description:
-               Retry sending ADDBA Reqest.
-
-       IRQL = DISPATCH_LEVEL
-
-       Parametrs:
-       p8023Header: if this is already 802.3 format, p8023Header is NULL
-
-       Return  : TRUE if put into rx reordering buffer, shouldn't indicaterxhere.
-                               FALSE , then continue indicaterx at this moment.
-       ==========================================================================
- */
-void BAOriSessionSetupTimeout(void *SystemSpecific1,
-                             void *FunctionContext,
-                             void *SystemSpecific2,
-                             void *SystemSpecific3)
-{
-       struct rt_ba_ori_entry *pBAEntry = (struct rt_ba_ori_entry *)FunctionContext;
-       struct rt_mac_table_entry *pEntry;
-       struct rt_rtmp_adapter *pAd;
-
-       if (pBAEntry == NULL)
-               return;
-
-       pAd = pBAEntry->pAdapter;
-
-       {
-               /* Do nothing if monitor mode is on */
-               if (MONITOR_ON(pAd))
-                       return;
-       }
-
-       pEntry = &pAd->MacTab.Content[pBAEntry->Wcid];
-
-       if ((pBAEntry->ORI_BA_Status == Originator_WaitRes)
-           && (pBAEntry->Token < ORI_SESSION_MAX_RETRY)) {
-               struct rt_mlme_addba_req AddbaReq;
-
-               NdisZeroMemory(&AddbaReq, sizeof(AddbaReq));
-               COPY_MAC_ADDR(AddbaReq.pAddr, pEntry->Addr);
-               AddbaReq.Wcid = (u8)(pEntry->Aid);
-               AddbaReq.TID = pBAEntry->TID;
-               AddbaReq.BaBufSize =
-                   pAd->CommonCfg.BACapability.field.RxBAWinLimit;
-               AddbaReq.TimeOutValue = 0;
-               AddbaReq.Token = pBAEntry->Token;
-               MlmeEnqueue(pAd, ACTION_STATE_MACHINE, MT2_MLME_ADD_BA_CATE,
-                           sizeof(struct rt_mlme_addba_req), (void *)& AddbaReq);
-               RTMP_MLME_HANDLER(pAd);
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("BA Ori Session Timeout(%d) : Send ADD BA again\n",
-                         pBAEntry->Token));
-
-               pBAEntry->Token++;
-               RTMPSetTimer(&pBAEntry->ORIBATimer, ORI_BA_SESSION_TIMEOUT);
-       } else {
-               BATableFreeOriEntry(pAd, pEntry->BAOriWcidArray[pBAEntry->TID]);
-       }
-}
-
-/*
-       ==========================================================================
-       Description:
-               Retry sending ADDBA Reqest.
-
-       IRQL = DISPATCH_LEVEL
-
-       Parametrs:
-       p8023Header: if this is already 802.3 format, p8023Header is NULL
-
-       Return  : TRUE if put into rx reordering buffer, shouldn't indicaterxhere.
-                               FALSE , then continue indicaterx at this moment.
-       ==========================================================================
- */
-void BARecSessionIdleTimeout(void *SystemSpecific1,
-                            void *FunctionContext,
-                            void *SystemSpecific2, void *SystemSpecific3)
-{
-
-       struct rt_ba_rec_entry *pBAEntry = (struct rt_ba_rec_entry *)FunctionContext;
-       struct rt_rtmp_adapter *pAd;
-       unsigned long Now32;
-
-       if (pBAEntry == NULL)
-               return;
-
-       if ((pBAEntry->REC_BA_Status == Recipient_Accept)) {
-               NdisGetSystemUpTime(&Now32);
-
-               if (RTMP_TIME_AFTER
-                   ((unsigned long)Now32,
-                    (unsigned long)(pBAEntry->LastIndSeqAtTimer +
-                                    REC_BA_SESSION_IDLE_TIMEOUT))) {
-                       pAd = pBAEntry->pAdapter;
-                       /* flush all pending reordering mpdus */
-                       ba_refresh_reordering_mpdus(pAd, pBAEntry);
-                       DBGPRINT(RT_DEBUG_OFF,
-                                ("%ld: REC BA session Timeout\n", Now32));
-               }
-       }
-}
-
-void PeerAddBAReqAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
-{
-       /*      7.4.4.1 */
-       /*unsigned long Idx; */
-       u8 Status = 1;
-       u8 pAddr[6];
-       struct rt_frame_addba_rsp ADDframe;
-       u8 *pOutBuffer = NULL;
-       int NStatus;
-       struct rt_frame_addba_req * pAddreqFrame = NULL;
-       /*u8         BufSize; */
-       unsigned long FrameLen;
-       unsigned long *ptemp;
-       struct rt_mac_table_entry *pMacEntry;
-
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("%s ==> (Wcid = %d)\n", __func__, Elem->Wcid));
-
-       /*hex_dump("AddBAReq", Elem->Msg, Elem->MsgLen); */
-
-       /*ADDBA Request from unknown peer, ignore this. */
-       if (Elem->Wcid >= MAX_LEN_OF_MAC_TABLE)
-               return;
-
-       pMacEntry = &pAd->MacTab.Content[Elem->Wcid];
-       DBGPRINT(RT_DEBUG_TRACE, ("BA - PeerAddBAReqAction----> \n"));
-       ptemp = (unsigned long *)Elem->Msg;
-       /*DBGPRINT_RAW(RT_DEBUG_EMU, ("%08x:: %08x:: %08x:: %08x:: %08x:: %08x:: %08x:: %08x:: %08x\n", *(ptemp), *(ptemp+1), *(ptemp+2), *(ptemp+3), *(ptemp+4), *(ptemp+5), *(ptemp+6), *(ptemp+7), *(ptemp+8))); */
-
-       if (PeerAddBAReqActionSanity(pAd, Elem->Msg, Elem->MsgLen, pAddr)) {
-
-               if ((pAd->CommonCfg.bBADecline == FALSE)
-                   && IS_HT_STA(pMacEntry)) {
-                       pAddreqFrame = (struct rt_frame_addba_req *) (&Elem->Msg[0]);
-                       DBGPRINT(RT_DEBUG_OFF,
-                                ("Rcv Wcid(%d) AddBAReq\n", Elem->Wcid));
-                       if (BARecSessionAdd
-                           (pAd, &pAd->MacTab.Content[Elem->Wcid],
-                            pAddreqFrame))
-                               Status = 0;
-                       else
-                               Status = 38;    /* more parameters have invalid values */
-               } else {
-                       Status = 37;    /* the request has been declined. */
-               }
-       }
-
-       if (pAd->MacTab.Content[Elem->Wcid].ValidAsCLI)
-               ASSERT(pAd->MacTab.Content[Elem->Wcid].Sst == SST_ASSOC);
-
-       pAddreqFrame = (struct rt_frame_addba_req *) (&Elem->Msg[0]);
-       /* 2. Always send back ADDBA Response */
-       NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); /*Get an unused nonpaged memory */
-       if (NStatus != NDIS_STATUS_SUCCESS) {
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("ACTION - PeerBAAction() allocate memory failed \n"));
-               return;
-       }
-
-       NdisZeroMemory(&ADDframe, sizeof(struct rt_frame_addba_rsp));
-
-       /* 2-1. Prepare ADDBA Response frame. */
-       {
-               if (ADHOC_ON(pAd))
-                       ActHeaderInit(pAd, &ADDframe.Hdr, pAddr,
-                                     pAd->CurrentAddress,
-                                     pAd->CommonCfg.Bssid);
-               else
-                       ActHeaderInit(pAd, &ADDframe.Hdr, pAd->CommonCfg.Bssid,
-                                     pAd->CurrentAddress, pAddr);
-       }
-
-       ADDframe.Category = CATEGORY_BA;
-       ADDframe.Action = ADDBA_RESP;
-       ADDframe.Token = pAddreqFrame->Token;
-       /* What is the Status code??  need to check. */
-       ADDframe.StatusCode = Status;
-       ADDframe.BaParm.BAPolicy = IMMED_BA;
-       ADDframe.BaParm.AMSDUSupported = 0;
-       ADDframe.BaParm.TID = pAddreqFrame->BaParm.TID;
-       ADDframe.BaParm.BufSize =
-           min(((u8)pAddreqFrame->BaParm.BufSize),
-               (u8)pAd->CommonCfg.BACapability.field.RxBAWinLimit);
-       if (ADDframe.BaParm.BufSize == 0) {
-               ADDframe.BaParm.BufSize = 64;
-       }
-       ADDframe.TimeOutValue = 0;      /*pAddreqFrame->TimeOutValue; */
-
-       *(u16 *) (&ADDframe.BaParm) =
-           cpu2le16(*(u16 *) (&ADDframe.BaParm));
-       ADDframe.StatusCode = cpu2le16(ADDframe.StatusCode);
-       ADDframe.TimeOutValue = cpu2le16(ADDframe.TimeOutValue);
-
-       MakeOutgoingFrame(pOutBuffer, &FrameLen,
-                         sizeof(struct rt_frame_addba_rsp), &ADDframe, END_OF_ARGS);
-       MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);
-       MlmeFreeMemory(pAd, pOutBuffer);
-
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("%s(%d): TID(%d), BufSize(%d) <== \n", __func__, Elem->Wcid,
-                 ADDframe.BaParm.TID, ADDframe.BaParm.BufSize));
-}
-
-void PeerAddBARspAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
-{
-       /*u8         Idx, i; */
-       /*u8 *                  pOutBuffer = NULL; */
-       struct rt_frame_addba_rsp * pFrame = NULL;
-       /*struct rt_ba_ori_entry *pBAEntry; */
-
-       /*ADDBA Response from unknown peer, ignore this. */
-       if (Elem->Wcid >= MAX_LEN_OF_MAC_TABLE)
-               return;
-
-       DBGPRINT(RT_DEBUG_TRACE, ("%s ==> Wcid(%d)\n", __func__, Elem->Wcid));
-
-       /*hex_dump("PeerAddBARspAction()", Elem->Msg, Elem->MsgLen); */
-
-       if (PeerAddBARspActionSanity(pAd, Elem->Msg, Elem->MsgLen)) {
-               pFrame = (struct rt_frame_addba_rsp *) (&Elem->Msg[0]);
-
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("\t\t StatusCode = %d\n", pFrame->StatusCode));
-               switch (pFrame->StatusCode) {
-               case 0:
-                       /* I want a BAsession with this peer as an originator. */
-                       BAOriSessionAdd(pAd, &pAd->MacTab.Content[Elem->Wcid],
-                                       pFrame);
-                       break;
-               default:
-                       /* check status == USED ??? */
-                       BAOriSessionTearDown(pAd, Elem->Wcid,
-                                            pFrame->BaParm.TID, TRUE, FALSE);
-                       break;
-               }
-               /* Rcv Decline StatusCode */
-               if ((pFrame->StatusCode == 37)
-                   || ((pAd->OpMode == OPMODE_STA) && STA_TGN_WIFI_ON(pAd)
-                       && (pFrame->StatusCode != 0))
-                   ) {
-                       pAd->MacTab.Content[Elem->Wcid].BADeclineBitmap |=
-                           1 << pFrame->BaParm.TID;
-               }
-       }
-}
-
-void PeerDelBAAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
-{
-       /*u8                         Idx; */
-       /*u8 *                               pOutBuffer = NULL; */
-       struct rt_frame_delba_req * pDelFrame = NULL;
-
-       DBGPRINT(RT_DEBUG_TRACE, ("%s ==>\n", __func__));
-       /*DELBA Request from unknown peer, ignore this. */
-       if (PeerDelBAActionSanity(pAd, Elem->Wcid, Elem->Msg, Elem->MsgLen)) {
-               pDelFrame = (struct rt_frame_delba_req *) (&Elem->Msg[0]);
-               if (pDelFrame->DelbaParm.Initiator == ORIGINATOR) {
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("BA - PeerDelBAAction----> ORIGINATOR\n"));
-                       BARecSessionTearDown(pAd, Elem->Wcid,
-                                            pDelFrame->DelbaParm.TID, TRUE);
-               } else {
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("BA - PeerDelBAAction----> RECIPIENT, Reason = %d\n",
-                                 pDelFrame->ReasonCode));
-                       /*hex_dump("DelBA Frame", pDelFrame, Elem->MsgLen); */
-                       BAOriSessionTearDown(pAd, Elem->Wcid,
-                                            pDelFrame->DelbaParm.TID, TRUE,
-                                            FALSE);
-               }
-       }
-}
-
-BOOLEAN CntlEnqueueForRecv(struct rt_rtmp_adapter *pAd,
-                          unsigned long Wcid,
-                          unsigned long MsgLen, struct rt_frame_ba_req * pMsg)
-{
-       struct rt_frame_ba_req * pFrame = pMsg;
-       /*PRTMP_REORDERBUF      pBuffer; */
-       /*PRTMP_REORDERBUF      pDmaBuf; */
-       struct rt_ba_rec_entry *pBAEntry;
-       /*BOOLEAN       Result; */
-       unsigned long Idx;
-       /*u8 NumRxPkt; */
-       u8 TID;         /*, i; */
-
-       TID = (u8)pFrame->BARControl.TID;
-
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("%s(): BAR-Wcid(%ld), Tid (%d)\n", __func__, Wcid, TID));
-       /*hex_dump("BAR", (char *)pFrame, MsgLen); */
-       /* Do nothing if the driver is starting halt state. */
-       /* This might happen when timer already been fired before cancel timer with mlmehalt */
-       if (RTMP_TEST_FLAG
-           (pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST))
-               return FALSE;
-
-       /* First check the size, it MUST not exceed the mlme queue size */
-       if (MsgLen > MGMT_DMA_BUFFER_SIZE) {
-               DBGPRINT_ERR("CntlEnqueueForRecv: frame too large, size = %ld \n", MsgLen);
-               return FALSE;
-       } else if (MsgLen != sizeof(struct rt_frame_ba_req)) {
-               DBGPRINT_ERR("CntlEnqueueForRecv: BlockAck Request frame length size = %ld incorrect\n", MsgLen);
-               return FALSE;
-       } else if (MsgLen != sizeof(struct rt_frame_ba_req)) {
-               DBGPRINT_ERR("CntlEnqueueForRecv: BlockAck Request frame length size = %ld incorrect\n", MsgLen);
-               return FALSE;
-       }
-
-       if ((Wcid < MAX_LEN_OF_MAC_TABLE) && (TID < 8)) {
-               /* if this receiving packet is from SA that is in our OriEntry. Since WCID <9 has direct mapping. no need search. */
-               Idx = pAd->MacTab.Content[Wcid].BARecWcidArray[TID];
-               pBAEntry = &pAd->BATable.BARecEntry[Idx];
-       } else {
-               return FALSE;
-       }
-
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("BAR(%ld) : Tid (%d) - %04x:%04x\n", Wcid, TID,
-                 pFrame->BAStartingSeq.field.StartSeq, pBAEntry->LastIndSeq));
-
-       if (SEQ_SMALLER
-           (pBAEntry->LastIndSeq, pFrame->BAStartingSeq.field.StartSeq,
-            MAXSEQ)) {
-               /*DBGPRINT(RT_DEBUG_TRACE, ("BAR Seq = %x, LastIndSeq = %x\n", pFrame->BAStartingSeq.field.StartSeq, pBAEntry->LastIndSeq)); */
-               ba_indicate_reordering_mpdus_le_seq(pAd, pBAEntry,
-                                                   pFrame->BAStartingSeq.field.
-                                                   StartSeq);
-               pBAEntry->LastIndSeq =
-                   (pFrame->BAStartingSeq.field.StartSeq ==
-                    0) ? MAXSEQ : (pFrame->BAStartingSeq.field.StartSeq - 1);
-       }
-       /*ba_refresh_reordering_mpdus(pAd, pBAEntry); */
-       return TRUE;
-}
-
-/*
-Description : Send PSMP Action frame If PSMP mode switches.
-*/
-void SendPSMPAction(struct rt_rtmp_adapter *pAd, u8 Wcid, u8 Psmp)
-{
-       u8 *pOutBuffer = NULL;
-       int NStatus;
-       /*unsigned long           Idx; */
-       struct rt_frame_psmp_action Frame;
-       unsigned long FrameLen;
-
-       NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); /*Get an unused nonpaged memory */
-       if (NStatus != NDIS_STATUS_SUCCESS) {
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("BA - MlmeADDBAAction() allocate memory failed \n"));
-               return;
-       }
-
-       ActHeaderInit(pAd, &Frame.Hdr, pAd->CommonCfg.Bssid,
-                     pAd->CurrentAddress, pAd->MacTab.Content[Wcid].Addr);
-
-       Frame.Category = CATEGORY_HT;
-       Frame.Action = SMPS_ACTION;
-       switch (Psmp) {
-       case MMPS_ENABLE:
-#ifdef RT30xx
-               if (IS_RT30xx(pAd)
-                   && (pAd->Antenna.field.RxPath > 1
-                       || pAd->Antenna.field.TxPath > 1)) {
-                       RTMP_ASIC_MMPS_DISABLE(pAd);
-               }
-#endif /* RT30xx // */
-               Frame.Psmp = 0;
-               break;
-       case MMPS_DYNAMIC:
-               Frame.Psmp = 3;
-               break;
-       case MMPS_STATIC:
-#ifdef RT30xx
-               if (IS_RT30xx(pAd)
-                   && (pAd->Antenna.field.RxPath > 1
-                       || pAd->Antenna.field.TxPath > 1)) {
-                       RTMP_ASIC_MMPS_ENABLE(pAd);
-               }
-#endif /* RT30xx // */
-               Frame.Psmp = 1;
-               break;
-       }
-       MakeOutgoingFrame(pOutBuffer, &FrameLen,
-                         sizeof(struct rt_frame_psmp_action), &Frame, END_OF_ARGS);
-       MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);
-       MlmeFreeMemory(pAd, pOutBuffer);
-       DBGPRINT(RT_DEBUG_ERROR, ("HT - SendPSMPAction( %d )  \n", Frame.Psmp));
-}
-
-#define RADIO_MEASUREMENT_REQUEST_ACTION       0
-
-struct PACKED rt_beacon_request {
-       u8 RegulatoryClass;
-       u8 ChannelNumber;
-       u16 RandomInterval;
-       u16 MeasurementDuration;
-       u8 MeasurementMode;
-       u8 BSSID[MAC_ADDR_LEN];
-       u8 ReportingCondition;
-       u8 Threshold;
-       u8 SSIDIE[2];   /* 2 byte */
-};
-
-struct PACKED rt_measurement_req {
-       u8 ID;
-       u8 Length;
-       u8 Token;
-       u8 RequestMode;
-       u8 Type;
-};
-
-void convert_reordering_packet_to_preAMSDU_or_802_3_packet(struct rt_rtmp_adapter *pAd,
-                                                          struct rt_rx_blk *pRxBlk,
-                                                          u8
-                                                          FromWhichBSSID)
-{
-       void *pRxPkt;
-       u8 Header802_3[LENGTH_802_3];
-
-       /* 1. get 802.3 Header */
-       /* 2. remove LLC */
-       /*              a. pointer pRxBlk->pData to payload */
-       /*      b. modify pRxBlk->DataSize */
-
-       RTMP_802_11_REMOVE_LLC_AND_CONVERT_TO_802_3(pRxBlk, Header802_3);
-
-       ASSERT(pRxBlk->pRxPacket);
-       pRxPkt = RTPKT_TO_OSPKT(pRxBlk->pRxPacket);
-
-       SET_OS_PKT_NETDEV(pRxPkt, get_netdev_from_bssid(pAd, FromWhichBSSID));
-       SET_OS_PKT_DATAPTR(pRxPkt, pRxBlk->pData);
-       SET_OS_PKT_LEN(pRxPkt, pRxBlk->DataSize);
-       SET_OS_PKT_DATATAIL(pRxPkt, pRxBlk->pData, pRxBlk->DataSize);
-
-       /* */
-       /* copy 802.3 header, if necessary */
-       /* */
-       if (!RX_BLK_TEST_FLAG(pRxBlk, fRX_AMSDU)) {
-               {
-#ifdef LINUX
-                       NdisMoveMemory(skb_push(pRxPkt, LENGTH_802_3),
-                                      Header802_3, LENGTH_802_3);
-#endif
-               }
-       }
-}
-
-#define INDICATE_LEGACY_OR_AMSDU(_pAd, _pRxBlk, _fromWhichBSSID)               \
-       do                                                                                                                                      \
-       {                                                                                                                                       \
-       if (RX_BLK_TEST_FLAG(_pRxBlk, fRX_AMSDU))                                               \
-       {                                                                                                                               \
-               Indicate_AMSDU_Packet(_pAd, _pRxBlk, _fromWhichBSSID);          \
-       }                                                                                                                               \
-               else if (RX_BLK_TEST_FLAG(_pRxBlk, fRX_EAP))                                    \
-               {                                                                                                                               \
-                       Indicate_EAPOL_Packet(_pAd, _pRxBlk, _fromWhichBSSID);          \
-               }                                                                                                                               \
-       else                                                                                                                    \
-       {                                                                                                                               \
-               Indicate_Legacy_Packet(_pAd, _pRxBlk, _fromWhichBSSID);         \
-       }                                                                                                                               \
-       } while (0);
-
-static void ba_enqueue_reordering_packet(struct rt_rtmp_adapter *pAd,
-                                        struct rt_ba_rec_entry *pBAEntry,
-                                        struct rt_rx_blk *pRxBlk,
-                                        u8 FromWhichBSSID)
-{
-       struct reordering_mpdu *mpdu_blk;
-       u16 Sequence = (u16)pRxBlk->pHeader->Sequence;
-
-       mpdu_blk = ba_mpdu_blk_alloc(pAd);
-       if ((mpdu_blk != NULL) && (!RX_BLK_TEST_FLAG(pRxBlk, fRX_EAP))) {
-               /* Write RxD buffer address & allocated buffer length */
-               NdisAcquireSpinLock(&pBAEntry->RxReRingLock);
-
-               mpdu_blk->Sequence = Sequence;
-
-               mpdu_blk->bAMSDU = RX_BLK_TEST_FLAG(pRxBlk, fRX_AMSDU);
-
-               convert_reordering_packet_to_preAMSDU_or_802_3_packet(pAd,
-                                                                     pRxBlk,
-                                                                     FromWhichBSSID);
-
-               STATS_INC_RX_PACKETS(pAd, FromWhichBSSID);
-
-               /* */
-               /* it is necessary for reordering packet to record */
-               /* which BSS it come from */
-               /* */
-               RTMP_SET_PACKET_IF(pRxBlk->pRxPacket, FromWhichBSSID);
-
-               mpdu_blk->pPacket = pRxBlk->pRxPacket;
-
-               if (ba_reordering_mpdu_insertsorted(&pBAEntry->list, mpdu_blk)
-                   == FALSE) {
-                       /* had been already within reordering list */
-                       /* don't indicate */
-                       RELEASE_NDIS_PACKET(pAd, pRxBlk->pRxPacket,
-                                           NDIS_STATUS_SUCCESS);
-                       ba_mpdu_blk_free(pAd, mpdu_blk);
-               }
-
-               ASSERT((0 <= pBAEntry->list.qlen)
-                      && (pBAEntry->list.qlen <= pBAEntry->BAWinSize));
-               NdisReleaseSpinLock(&pBAEntry->RxReRingLock);
-       } else {
-               DBGPRINT(RT_DEBUG_ERROR,
-                        (" (%d) Can't allocate reordering mpdu blk\n",
-                         pBAEntry->list.qlen));
-
-               /*
-                * flush all pending reordering mpdus
-                * and receiving mpdu to upper layer
-                * make tcp/ip to take care reordering mechanism
-                */
-               /*ba_refresh_reordering_mpdus(pAd, pBAEntry); */
-               ba_indicate_reordering_mpdus_le_seq(pAd, pBAEntry, Sequence);
-
-               pBAEntry->LastIndSeq = Sequence;
-               INDICATE_LEGACY_OR_AMSDU(pAd, pRxBlk, FromWhichBSSID);
-       }
-}
-
-/*
-       ==========================================================================
-       Description:
-               Indicate this packet to upper layer or put it into reordering buffer
-
-       Parametrs:
-               pRxBlk         : carry necessary packet info 802.11 format
-               FromWhichBSSID : the packet received from which BSS
-
-       Return  :
-                         none
-
-       Note    :
-                 the packet queued into reordering buffer need to cover to 802.3 format
-                         or pre_AMSDU format
-       ==========================================================================
- */
-
-void Indicate_AMPDU_Packet(struct rt_rtmp_adapter *pAd,
-                          struct rt_rx_blk *pRxBlk, u8 FromWhichBSSID)
-{
-       u16 Idx;
-       struct rt_ba_rec_entry *pBAEntry = NULL;
-       u16 Sequence = pRxBlk->pHeader->Sequence;
-       unsigned long Now32;
-       u8 Wcid = pRxBlk->pRxWI->WirelessCliID;
-       u8 TID = pRxBlk->pRxWI->TID;
-
-       if (!RX_BLK_TEST_FLAG(pRxBlk, fRX_AMSDU)
-           && (pRxBlk->DataSize > MAX_RX_PKT_LEN)) {
-               /* release packet */
-               RELEASE_NDIS_PACKET(pAd, pRxBlk->pRxPacket,
-                                   NDIS_STATUS_FAILURE);
-               return;
-       }
-
-       if (Wcid < MAX_LEN_OF_MAC_TABLE) {
-               Idx = pAd->MacTab.Content[Wcid].BARecWcidArray[TID];
-               if (Idx == 0) {
-                       /* Rec BA Session had been torn down */
-                       INDICATE_LEGACY_OR_AMSDU(pAd, pRxBlk, FromWhichBSSID);
-                       return;
-               }
-               pBAEntry = &pAd->BATable.BARecEntry[Idx];
-       } else {
-               /* impossible ! */
-               ASSERT(0);
-               /* release packet */
-               RELEASE_NDIS_PACKET(pAd, pRxBlk->pRxPacket,
-                                   NDIS_STATUS_FAILURE);
-               return;
-       }
-
-       ASSERT(pBAEntry);
-
-       /* update last rx time */
-       NdisGetSystemUpTime(&Now32);
-
-       pBAEntry->rcvSeq = Sequence;
-
-       ba_flush_reordering_timeout_mpdus(pAd, pBAEntry, Now32);
-       pBAEntry->LastIndSeqAtTimer = Now32;
-
-       /* */
-       /* Reset Last Indicate Sequence */
-       /* */
-       if (pBAEntry->LastIndSeq == RESET_RCV_SEQ) {
-               ASSERT((pBAEntry->list.qlen == 0)
-                      && (pBAEntry->list.next == NULL));
-
-               /* reset rcv sequence of BA session */
-               pBAEntry->LastIndSeq = Sequence;
-               pBAEntry->LastIndSeqAtTimer = Now32;
-               INDICATE_LEGACY_OR_AMSDU(pAd, pRxBlk, FromWhichBSSID);
-               return;
-       }
-
-       /* */
-       /* I. Check if in order. */
-       /* */
-       if (SEQ_STEPONE(Sequence, pBAEntry->LastIndSeq, MAXSEQ)) {
-               u16 LastIndSeq;
-
-               pBAEntry->LastIndSeq = Sequence;
-               INDICATE_LEGACY_OR_AMSDU(pAd, pRxBlk, FromWhichBSSID);
-               LastIndSeq =
-                   ba_indicate_reordering_mpdus_in_order(pAd, pBAEntry,
-                                                         pBAEntry->LastIndSeq);
-               if (LastIndSeq != RESET_RCV_SEQ) {
-                       pBAEntry->LastIndSeq = LastIndSeq;
-               }
-               pBAEntry->LastIndSeqAtTimer = Now32;
-       }
-       /* */
-       /* II. Drop Duplicated Packet */
-       /* */
-       else if (Sequence == pBAEntry->LastIndSeq) {
-
-               /* drop and release packet */
-               pBAEntry->nDropPacket++;
-               RELEASE_NDIS_PACKET(pAd, pRxBlk->pRxPacket,
-                                   NDIS_STATUS_FAILURE);
-       }
-       /* */
-       /* III. Drop Old Received Packet */
-       /* */
-       else if (SEQ_SMALLER(Sequence, pBAEntry->LastIndSeq, MAXSEQ)) {
-
-               /* drop and release packet */
-               pBAEntry->nDropPacket++;
-               RELEASE_NDIS_PACKET(pAd, pRxBlk->pRxPacket,
-                                   NDIS_STATUS_FAILURE);
-       }
-       /* */
-       /* IV. Receive Sequence within Window Size */
-       /* */
-       else if (SEQ_SMALLER
-                (Sequence,
-                 (((pBAEntry->LastIndSeq + pBAEntry->BAWinSize + 1)) & MAXSEQ),
-                 MAXSEQ)) {
-               ba_enqueue_reordering_packet(pAd, pBAEntry, pRxBlk,
-                                            FromWhichBSSID);
-       }
-       /* */
-       /* V. Receive seq surpasses Win(lastseq + nMSDU). So refresh all reorder buffer */
-       /* */
-       else {
-               long WinStartSeq, TmpSeq;
-
-               TmpSeq = Sequence - (pBAEntry->BAWinSize) - 1;
-               if (TmpSeq < 0) {
-                       TmpSeq = (MAXSEQ + 1) + TmpSeq;
-               }
-               WinStartSeq = (TmpSeq + 1) & MAXSEQ;
-               ba_indicate_reordering_mpdus_le_seq(pAd, pBAEntry, WinStartSeq);
-               pBAEntry->LastIndSeq = WinStartSeq;     /*TmpSeq; */
-
-               pBAEntry->LastIndSeqAtTimer = Now32;
-
-               ba_enqueue_reordering_packet(pAd, pBAEntry, pRxBlk,
-                                            FromWhichBSSID);
-
-               TmpSeq =
-                   ba_indicate_reordering_mpdus_in_order(pAd, pBAEntry,
-                                                         pBAEntry->LastIndSeq);
-               if (TmpSeq != RESET_RCV_SEQ) {
-                       pBAEntry->LastIndSeq = TmpSeq;
-               }
-       }
-}
diff --git a/drivers/staging/rt2860/common/cmm_aes.c b/drivers/staging/rt2860/common/cmm_aes.c
deleted file mode 100644 (file)
index d70d229..0000000
+++ /dev/null
@@ -1,1311 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-       Module Name:
-       cmm_aes.c
-
-       Abstract:
-
-       Revision History:
-       Who                     When                    What
-       --------        ----------              ----------------------------------------------
-       Paul Wu         02-25-02                Initial
-*/
-
-#include       "../rt_config.h"
-
-struct aes_context {
-       u32 erk[64];            /* encryption round keys */
-       u32 drk[64];            /* decryption round keys */
-       int nr;                 /* number of rounds */
-};
-
-/*****************************/
-/******** SBOX Table *********/
-/*****************************/
-
-u8 SboxTable[256] = {
-       0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5,
-       0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76,
-       0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0,
-       0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0,
-       0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc,
-       0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15,
-       0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a,
-       0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75,
-       0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0,
-       0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84,
-       0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b,
-       0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf,
-       0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85,
-       0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8,
-       0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5,
-       0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2,
-       0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17,
-       0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73,
-       0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88,
-       0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb,
-       0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c,
-       0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79,
-       0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9,
-       0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08,
-       0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6,
-       0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a,
-       0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e,
-       0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e,
-       0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94,
-       0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf,
-       0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68,
-       0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16
-};
-
-void xor_32(u8 *a, u8 *b, u8 *out)
-{
-       int i;
-
-       for (i = 0; i < 4; i++) {
-               out[i] = a[i] ^ b[i];
-       }
-}
-
-void xor_128(u8 *a, u8 *b, u8 *out)
-{
-       int i;
-
-       for (i = 0; i < 16; i++) {
-               out[i] = a[i] ^ b[i];
-       }
-}
-
-u8 RTMPCkipSbox(u8 a)
-{
-       return SboxTable[(int)a];
-}
-
-void next_key(u8 *key, int round)
-{
-       u8 rcon;
-       u8 sbox_key[4];
-       u8 rcon_table[12] = {
-               0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80,
-               0x1b, 0x36, 0x36, 0x36
-       };
-
-       sbox_key[0] = RTMPCkipSbox(key[13]);
-       sbox_key[1] = RTMPCkipSbox(key[14]);
-       sbox_key[2] = RTMPCkipSbox(key[15]);
-       sbox_key[3] = RTMPCkipSbox(key[12]);
-
-       rcon = rcon_table[round];
-
-       xor_32(&key[0], sbox_key, &key[0]);
-       key[0] = key[0] ^ rcon;
-
-       xor_32(&key[4], &key[0], &key[4]);
-       xor_32(&key[8], &key[4], &key[8]);
-       xor_32(&key[12], &key[8], &key[12]);
-}
-
-void byte_sub(u8 *in, u8 *out)
-{
-       int i;
-
-       for (i = 0; i < 16; i++) {
-               out[i] = RTMPCkipSbox(in[i]);
-       }
-}
-
-/************************************/
-/* bitwise_xor()                    */
-/* A 128 bit, bitwise exclusive or  */
-/************************************/
-
-void bitwise_xor(unsigned char *ina, unsigned char *inb, unsigned char *out)
-{
-       int i;
-       for (i = 0; i < 16; i++) {
-               out[i] = ina[i] ^ inb[i];
-       }
-}
-
-void shift_row(u8 *in, u8 *out)
-{
-       out[0] = in[0];
-       out[1] = in[5];
-       out[2] = in[10];
-       out[3] = in[15];
-       out[4] = in[4];
-       out[5] = in[9];
-       out[6] = in[14];
-       out[7] = in[3];
-       out[8] = in[8];
-       out[9] = in[13];
-       out[10] = in[2];
-       out[11] = in[7];
-       out[12] = in[12];
-       out[13] = in[1];
-       out[14] = in[6];
-       out[15] = in[11];
-}
-
-void mix_column(u8 *in, u8 *out)
-{
-       int i;
-       u8 add1b[4];
-       u8 add1bf7[4];
-       u8 rotl[4];
-       u8 swap_halfs[4];
-       u8 andf7[4];
-       u8 rotr[4];
-       u8 temp[4];
-       u8 tempb[4];
-
-       for (i = 0; i < 4; i++) {
-               if ((in[i] & 0x80) == 0x80)
-                       add1b[i] = 0x1b;
-               else
-                       add1b[i] = 0x00;
-       }
-
-       swap_halfs[0] = in[2];  /* Swap halfs */
-       swap_halfs[1] = in[3];
-       swap_halfs[2] = in[0];
-       swap_halfs[3] = in[1];
-
-       rotl[0] = in[3];        /* Rotate left 8 bits */
-       rotl[1] = in[0];
-       rotl[2] = in[1];
-       rotl[3] = in[2];
-
-       andf7[0] = in[0] & 0x7f;
-       andf7[1] = in[1] & 0x7f;
-       andf7[2] = in[2] & 0x7f;
-       andf7[3] = in[3] & 0x7f;
-
-       for (i = 3; i > 0; i--) {       /* logical shift left 1 bit */
-               andf7[i] = andf7[i] << 1;
-               if ((andf7[i - 1] & 0x80) == 0x80) {
-                       andf7[i] = (andf7[i] | 0x01);
-               }
-       }
-       andf7[0] = andf7[0] << 1;
-       andf7[0] = andf7[0] & 0xfe;
-
-       xor_32(add1b, andf7, add1bf7);
-
-       xor_32(in, add1bf7, rotr);
-
-       temp[0] = rotr[0];      /* Rotate right 8 bits */
-       rotr[0] = rotr[1];
-       rotr[1] = rotr[2];
-       rotr[2] = rotr[3];
-       rotr[3] = temp[0];
-
-       xor_32(add1bf7, rotr, temp);
-       xor_32(swap_halfs, rotl, tempb);
-       xor_32(temp, tempb, out);
-}
-
-/************************************************/
-/* construct_mic_header1()                      */
-/* Builds the first MIC header block from       */
-/* header fields.                               */
-/************************************************/
-
-void construct_mic_header1(unsigned char *mic_header1,
-                          int header_length, unsigned char *mpdu)
-{
-       mic_header1[0] = (unsigned char)((header_length - 2) / 256);
-       mic_header1[1] = (unsigned char)((header_length - 2) % 256);
-       mic_header1[2] = mpdu[0] & 0xcf;        /* Mute CF poll & CF ack bits */
-       mic_header1[3] = mpdu[1] & 0xc7;        /* Mute retry, more data and pwr mgt bits */
-       mic_header1[4] = mpdu[4];       /* A1 */
-       mic_header1[5] = mpdu[5];
-       mic_header1[6] = mpdu[6];
-       mic_header1[7] = mpdu[7];
-       mic_header1[8] = mpdu[8];
-       mic_header1[9] = mpdu[9];
-       mic_header1[10] = mpdu[10];     /* A2 */
-       mic_header1[11] = mpdu[11];
-       mic_header1[12] = mpdu[12];
-       mic_header1[13] = mpdu[13];
-       mic_header1[14] = mpdu[14];
-       mic_header1[15] = mpdu[15];
-}
-
-/************************************************/
-/* construct_mic_header2()                      */
-/* Builds the last MIC header block from        */
-/* header fields.                               */
-/************************************************/
-
-void construct_mic_header2(unsigned char *mic_header2,
-                          unsigned char *mpdu, int a4_exists, int qc_exists)
-{
-       int i;
-
-       for (i = 0; i < 16; i++)
-               mic_header2[i] = 0x00;
-
-       mic_header2[0] = mpdu[16];      /* A3 */
-       mic_header2[1] = mpdu[17];
-       mic_header2[2] = mpdu[18];
-       mic_header2[3] = mpdu[19];
-       mic_header2[4] = mpdu[20];
-       mic_header2[5] = mpdu[21];
-
-       /* In Sequence Control field, mute sequence numer bits (12-bit) */
-       mic_header2[6] = mpdu[22] & 0x0f;       /* SC */
-       mic_header2[7] = 0x00;  /* mpdu[23]; */
-
-       if ((!qc_exists) && a4_exists) {
-               for (i = 0; i < 6; i++)
-                       mic_header2[8 + i] = mpdu[24 + i];      /* A4 */
-
-       }
-
-       if (qc_exists && (!a4_exists)) {
-               mic_header2[8] = mpdu[24] & 0x0f;       /* mute bits 15 - 4 */
-               mic_header2[9] = mpdu[25] & 0x00;
-       }
-
-       if (qc_exists && a4_exists) {
-               for (i = 0; i < 6; i++)
-                       mic_header2[8 + i] = mpdu[24 + i];      /* A4 */
-
-               mic_header2[14] = mpdu[30] & 0x0f;
-               mic_header2[15] = mpdu[31] & 0x00;
-       }
-}
-
-/************************************************/
-/* construct_mic_iv()                           */
-/* Builds the MIC IV from header fields and PN  */
-/************************************************/
-
-void construct_mic_iv(unsigned char *mic_iv,
-                     int qc_exists,
-                     int a4_exists,
-                     unsigned char *mpdu,
-                     unsigned int payload_length, unsigned char *pn_vector)
-{
-       int i;
-
-       mic_iv[0] = 0x59;
-       if (qc_exists && a4_exists)
-               mic_iv[1] = mpdu[30] & 0x0f;    /* QoS_TC           */
-       if (qc_exists && !a4_exists)
-               mic_iv[1] = mpdu[24] & 0x0f;    /* mute bits 7-4    */
-       if (!qc_exists)
-               mic_iv[1] = 0x00;
-       for (i = 2; i < 8; i++)
-               mic_iv[i] = mpdu[i + 8];        /* mic_iv[2:7] = A2[0:5] = mpdu[10:15] */
-#ifdef CONSISTENT_PN_ORDER
-       for (i = 8; i < 14; i++)
-               mic_iv[i] = pn_vector[i - 8];   /* mic_iv[8:13] = PN[0:5] */
-#else
-       for (i = 8; i < 14; i++)
-               mic_iv[i] = pn_vector[13 - i];  /* mic_iv[8:13] = PN[5:0] */
-#endif
-       mic_iv[14] = (unsigned char)(payload_length / 256);
-       mic_iv[15] = (unsigned char)(payload_length % 256);
-
-}
-
-/****************************************/
-/* aes128k128d()                        */
-/* Performs a 128 bit AES encrypt with  */
-/* 128 bit data.                        */
-/****************************************/
-void aes128k128d(unsigned char *key, unsigned char *data,
-                unsigned char *ciphertext)
-{
-       int round;
-       int i;
-       unsigned char intermediatea[16];
-       unsigned char intermediateb[16];
-       unsigned char round_key[16];
-
-       for (i = 0; i < 16; i++)
-               round_key[i] = key[i];
-
-       for (round = 0; round < 11; round++) {
-               if (round == 0) {
-                       xor_128(round_key, data, ciphertext);
-                       next_key(round_key, round);
-               } else if (round == 10) {
-                       byte_sub(ciphertext, intermediatea);
-                       shift_row(intermediatea, intermediateb);
-                       xor_128(intermediateb, round_key, ciphertext);
-               } else {        /* 1 - 9 */
-
-                       byte_sub(ciphertext, intermediatea);
-                       shift_row(intermediatea, intermediateb);
-                       mix_column(&intermediateb[0], &intermediatea[0]);
-                       mix_column(&intermediateb[4], &intermediatea[4]);
-                       mix_column(&intermediateb[8], &intermediatea[8]);
-                       mix_column(&intermediateb[12], &intermediatea[12]);
-                       xor_128(intermediatea, round_key, ciphertext);
-                       next_key(round_key, round);
-               }
-       }
-
-}
-
-void construct_ctr_preload(unsigned char *ctr_preload,
-                          int a4_exists,
-                          int qc_exists,
-                          unsigned char *mpdu, unsigned char *pn_vector, int c)
-{
-
-       int i = 0;
-       for (i = 0; i < 16; i++)
-               ctr_preload[i] = 0x00;
-       i = 0;
-
-       ctr_preload[0] = 0x01;  /* flag */
-       if (qc_exists && a4_exists)
-               ctr_preload[1] = mpdu[30] & 0x0f;       /* QoC_Control  */
-       if (qc_exists && !a4_exists)
-               ctr_preload[1] = mpdu[24] & 0x0f;
-
-       for (i = 2; i < 8; i++)
-               ctr_preload[i] = mpdu[i + 8];   /* ctr_preload[2:7] = A2[0:5] = mpdu[10:15] */
-#ifdef CONSISTENT_PN_ORDER
-       for (i = 8; i < 14; i++)
-               ctr_preload[i] = pn_vector[i - 8];      /* ctr_preload[8:13] = PN[0:5] */
-#else
-       for (i = 8; i < 14; i++)
-               ctr_preload[i] = pn_vector[13 - i];     /* ctr_preload[8:13] = PN[5:0] */
-#endif
-       ctr_preload[14] = (unsigned char)(c / 256);     /* Ctr */
-       ctr_preload[15] = (unsigned char)(c % 256);
-
-}
-
-BOOLEAN RTMPSoftDecryptAES(struct rt_rtmp_adapter *pAd,
-                          u8 *pData,
-                          unsigned long DataByteCnt, struct rt_cipher_key *pWpaKey)
-{
-       u8 KeyID;
-       u32 HeaderLen;
-       u8 PN[6];
-       u32 payload_len;
-       u32 num_blocks;
-       u32 payload_remainder;
-       u16 fc;
-       u8 fc0;
-       u8 fc1;
-       u32 frame_type;
-       u32 frame_subtype;
-       u32 from_ds;
-       u32 to_ds;
-       int a4_exists;
-       int qc_exists;
-       u8 aes_out[16];
-       int payload_index;
-       u32 i;
-       u8 ctr_preload[16];
-       u8 chain_buffer[16];
-       u8 padded_buffer[16];
-       u8 mic_iv[16];
-       u8 mic_header1[16];
-       u8 mic_header2[16];
-       u8 MIC[8];
-       u8 TrailMIC[8];
-
-       fc0 = *pData;
-       fc1 = *(pData + 1);
-
-       fc = *((u16 *)pData);
-
-       frame_type = ((fc0 >> 2) & 0x03);
-       frame_subtype = ((fc0 >> 4) & 0x0f);
-
-       from_ds = (fc1 & 0x2) >> 1;
-       to_ds = (fc1 & 0x1);
-
-       a4_exists = (from_ds & to_ds);
-       qc_exists = ((frame_subtype == 0x08) || /* Assumed QoS subtypes */
-                    (frame_subtype == 0x09) || /* Likely to change.    */
-                    (frame_subtype == 0x0a) || (frame_subtype == 0x0b)
-           );
-
-       HeaderLen = 24;
-       if (a4_exists)
-               HeaderLen += 6;
-
-       KeyID = *((u8 *)(pData + HeaderLen + 3));
-       KeyID = KeyID >> 6;
-
-       if (pWpaKey[KeyID].KeyLen == 0) {
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("RTMPSoftDecryptAES failed!(KeyID[%d] Length can not be 0)\n",
-                         KeyID));
-               return FALSE;
-       }
-
-       PN[0] = *(pData + HeaderLen);
-       PN[1] = *(pData + HeaderLen + 1);
-       PN[2] = *(pData + HeaderLen + 4);
-       PN[3] = *(pData + HeaderLen + 5);
-       PN[4] = *(pData + HeaderLen + 6);
-       PN[5] = *(pData + HeaderLen + 7);
-
-       payload_len = DataByteCnt - HeaderLen - 8 - 8;  /* 8 bytes for CCMP header , 8 bytes for MIC */
-       payload_remainder = (payload_len) % 16;
-       num_blocks = (payload_len) / 16;
-
-       /* Find start of payload */
-       payload_index = HeaderLen + 8;  /*IV+EIV */
-
-       for (i = 0; i < num_blocks; i++) {
-               construct_ctr_preload(ctr_preload,
-                                     a4_exists, qc_exists, pData, PN, i + 1);
-
-               aes128k128d(pWpaKey[KeyID].Key, ctr_preload, aes_out);
-
-               bitwise_xor(aes_out, pData + payload_index, chain_buffer);
-               NdisMoveMemory(pData + payload_index - 8, chain_buffer, 16);
-               payload_index += 16;
-       }
-
-       /* */
-       /* If there is a short final block, then pad it */
-       /* encrypt it and copy the unpadded part back */
-       /* */
-       if (payload_remainder > 0) {
-               construct_ctr_preload(ctr_preload,
-                                     a4_exists,
-                                     qc_exists, pData, PN, num_blocks + 1);
-
-               NdisZeroMemory(padded_buffer, 16);
-               NdisMoveMemory(padded_buffer, pData + payload_index,
-                              payload_remainder);
-
-               aes128k128d(pWpaKey[KeyID].Key, ctr_preload, aes_out);
-
-               bitwise_xor(aes_out, padded_buffer, chain_buffer);
-               NdisMoveMemory(pData + payload_index - 8, chain_buffer,
-                              payload_remainder);
-               payload_index += payload_remainder;
-       }
-       /* */
-       /* Descrypt the MIC */
-       /* */
-       construct_ctr_preload(ctr_preload, a4_exists, qc_exists, pData, PN, 0);
-       NdisZeroMemory(padded_buffer, 16);
-       NdisMoveMemory(padded_buffer, pData + payload_index, 8);
-
-       aes128k128d(pWpaKey[KeyID].Key, ctr_preload, aes_out);
-
-       bitwise_xor(aes_out, padded_buffer, chain_buffer);
-
-       NdisMoveMemory(TrailMIC, chain_buffer, 8);
-
-       /* */
-       /* Calculate MIC */
-       /* */
-
-       /*Force the protected frame bit on */
-       *(pData + 1) = *(pData + 1) | 0x40;
-
-       /* Find start of payload */
-       /* Because the CCMP header has been removed */
-       payload_index = HeaderLen;
-
-       construct_mic_iv(mic_iv, qc_exists, a4_exists, pData, payload_len, PN);
-
-       construct_mic_header1(mic_header1, HeaderLen, pData);
-
-       construct_mic_header2(mic_header2, pData, a4_exists, qc_exists);
-
-       aes128k128d(pWpaKey[KeyID].Key, mic_iv, aes_out);
-       bitwise_xor(aes_out, mic_header1, chain_buffer);
-       aes128k128d(pWpaKey[KeyID].Key, chain_buffer, aes_out);
-       bitwise_xor(aes_out, mic_header2, chain_buffer);
-       aes128k128d(pWpaKey[KeyID].Key, chain_buffer, aes_out);
-
-       /* iterate through each 16 byte payload block */
-       for (i = 0; i < num_blocks; i++) {
-               bitwise_xor(aes_out, pData + payload_index, chain_buffer);
-               payload_index += 16;
-               aes128k128d(pWpaKey[KeyID].Key, chain_buffer, aes_out);
-       }
-
-       /* Add on the final payload block if it needs padding */
-       if (payload_remainder > 0) {
-               NdisZeroMemory(padded_buffer, 16);
-               NdisMoveMemory(padded_buffer, pData + payload_index,
-                              payload_remainder);
-
-               bitwise_xor(aes_out, padded_buffer, chain_buffer);
-               aes128k128d(pWpaKey[KeyID].Key, chain_buffer, aes_out);
-       }
-       /* aes_out contains padded mic, discard most significant */
-       /* 8 bytes to generate 64 bit MIC */
-       for (i = 0; i < 8; i++)
-               MIC[i] = aes_out[i];
-
-       if (!NdisEqualMemory(MIC, TrailMIC, 8)) {
-               DBGPRINT(RT_DEBUG_ERROR, ("RTMPSoftDecryptAES, MIC Error !\n"));        /*MIC error. */
-               return FALSE;
-       }
-
-       return TRUE;
-}
-
-/* =========================  AES En/Decryption ========================== */
-#ifndef        uint8
-#define        uint8  unsigned char
-#endif
-
-#ifndef        uint32
-#define        uint32 unsigned int
-#endif
-
-/* forward S-box */
-static uint32 FSb[256] = {
-       0x63, 0x7C, 0x77, 0x7B, 0xF2, 0x6B, 0x6F, 0xC5,
-       0x30, 0x01, 0x67, 0x2B, 0xFE, 0xD7, 0xAB, 0x76,
-       0xCA, 0x82, 0xC9, 0x7D, 0xFA, 0x59, 0x47, 0xF0,
-       0xAD, 0xD4, 0xA2, 0xAF, 0x9C, 0xA4, 0x72, 0xC0,
-       0xB7, 0xFD, 0x93, 0x26, 0x36, 0x3F, 0xF7, 0xCC,
-       0x34, 0xA5, 0xE5, 0xF1, 0x71, 0xD8, 0x31, 0x15,
-       0x04, 0xC7, 0x23, 0xC3, 0x18, 0x96, 0x05, 0x9A,
-       0x07, 0x12, 0x80, 0xE2, 0xEB, 0x27, 0xB2, 0x75,
-       0x09, 0x83, 0x2C, 0x1A, 0x1B, 0x6E, 0x5A, 0xA0,
-       0x52, 0x3B, 0xD6, 0xB3, 0x29, 0xE3, 0x2F, 0x84,
-       0x53, 0xD1, 0x00, 0xED, 0x20, 0xFC, 0xB1, 0x5B,
-       0x6A, 0xCB, 0xBE, 0x39, 0x4A, 0x4C, 0x58, 0xCF,
-       0xD0, 0xEF, 0xAA, 0xFB, 0x43, 0x4D, 0x33, 0x85,
-       0x45, 0xF9, 0x02, 0x7F, 0x50, 0x3C, 0x9F, 0xA8,
-       0x51, 0xA3, 0x40, 0x8F, 0x92, 0x9D, 0x38, 0xF5,
-       0xBC, 0xB6, 0xDA, 0x21, 0x10, 0xFF, 0xF3, 0xD2,
-       0xCD, 0x0C, 0x13, 0xEC, 0x5F, 0x97, 0x44, 0x17,
-       0xC4, 0xA7, 0x7E, 0x3D, 0x64, 0x5D, 0x19, 0x73,
-       0x60, 0x81, 0x4F, 0xDC, 0x22, 0x2A, 0x90, 0x88,
-       0x46, 0xEE, 0xB8, 0x14, 0xDE, 0x5E, 0x0B, 0xDB,
-       0xE0, 0x32, 0x3A, 0x0A, 0x49, 0x06, 0x24, 0x5C,
-       0xC2, 0xD3, 0xAC, 0x62, 0x91, 0x95, 0xE4, 0x79,
-       0xE7, 0xC8, 0x37, 0x6D, 0x8D, 0xD5, 0x4E, 0xA9,
-       0x6C, 0x56, 0xF4, 0xEA, 0x65, 0x7A, 0xAE, 0x08,
-       0xBA, 0x78, 0x25, 0x2E, 0x1C, 0xA6, 0xB4, 0xC6,
-       0xE8, 0xDD, 0x74, 0x1F, 0x4B, 0xBD, 0x8B, 0x8A,
-       0x70, 0x3E, 0xB5, 0x66, 0x48, 0x03, 0xF6, 0x0E,
-       0x61, 0x35, 0x57, 0xB9, 0x86, 0xC1, 0x1D, 0x9E,
-       0xE1, 0xF8, 0x98, 0x11, 0x69, 0xD9, 0x8E, 0x94,
-       0x9B, 0x1E, 0x87, 0xE9, 0xCE, 0x55, 0x28, 0xDF,
-       0x8C, 0xA1, 0x89, 0x0D, 0xBF, 0xE6, 0x42, 0x68,
-       0x41, 0x99, 0x2D, 0x0F, 0xB0, 0x54, 0xBB, 0x16
-};
-
-/* forward table */
-#define        FT \
-\
-       V(C6,63,63,A5), V(F8,7C,7C,84), V(EE,77,77,99), V(F6,7B,7B,8D), \
-       V(FF,F2,F2,0D), V(D6,6B,6B,BD), V(DE,6F,6F,B1), V(91,C5,C5,54), \
-       V(60,30,30,50), V(02,01,01,03), V(CE,67,67,A9), V(56,2B,2B,7D), \
-       V(E7,FE,FE,19), V(B5,D7,D7,62), V(4D,AB,AB,E6), V(EC,76,76,9A), \
-       V(8F,CA,CA,45), V(1F,82,82,9D), V(89,C9,C9,40), V(FA,7D,7D,87), \
-       V(EF,FA,FA,15), V(B2,59,59,EB), V(8E,47,47,C9), V(FB,F0,F0,0B), \
-       V(41,AD,AD,EC), V(B3,D4,D4,67), V(5F,A2,A2,FD), V(45,AF,AF,EA), \
-       V(23,9C,9C,BF), V(53,A4,A4,F7), V(E4,72,72,96), V(9B,C0,C0,5B), \
-       V(75,B7,B7,C2), V(E1,FD,FD,1C), V(3D,93,93,AE), V(4C,26,26,6A), \
-       V(6C,36,36,5A), V(7E,3F,3F,41), V(F5,F7,F7,02), V(83,CC,CC,4F), \
-       V(68,34,34,5C), V(51,A5,A5,F4), V(D1,E5,E5,34), V(F9,F1,F1,08), \
-       V(E2,71,71,93), V(AB,D8,D8,73), V(62,31,31,53), V(2A,15,15,3F), \
-       V(08,04,04,0C), V(95,C7,C7,52), V(46,23,23,65), V(9D,C3,C3,5E), \
-       V(30,18,18,28), V(37,96,96,A1), V(0A,05,05,0F), V(2F,9A,9A,B5), \
-       V(0E,07,07,09), V(24,12,12,36), V(1B,80,80,9B), V(DF,E2,E2,3D), \
-       V(CD,EB,EB,26), V(4E,27,27,69), V(7F,B2,B2,CD), V(EA,75,75,9F), \
-       V(12,09,09,1B), V(1D,83,83,9E), V(58,2C,2C,74), V(34,1A,1A,2E), \
-       V(36,1B,1B,2D), V(DC,6E,6E,B2), V(B4,5A,5A,EE), V(5B,A0,A0,FB), \
-       V(A4,52,52,F6), V(76,3B,3B,4D), V(B7,D6,D6,61), V(7D,B3,B3,CE), \
-       V(52,29,29,7B), V(DD,E3,E3,3E), V(5E,2F,2F,71), V(13,84,84,97), \
-       V(A6,53,53,F5), V(B9,D1,D1,68), V(00,00,00,00), V(C1,ED,ED,2C), \
-       V(40,20,20,60), V(E3,FC,FC,1F), V(79,B1,B1,C8), V(B6,5B,5B,ED), \
-       V(D4,6A,6A,BE), V(8D,CB,CB,46), V(67,BE,BE,D9), V(72,39,39,4B), \
-       V(94,4A,4A,DE), V(98,4C,4C,D4), V(B0,58,58,E8), V(85,CF,CF,4A), \
-       V(BB,D0,D0,6B), V(C5,EF,EF,2A), V(4F,AA,AA,E5), V(ED,FB,FB,16), \
-       V(86,43,43,C5), V(9A,4D,4D,D7), V(66,33,33,55), V(11,85,85,94), \
-       V(8A,45,45,CF), V(E9,F9,F9,10), V(04,02,02,06), V(FE,7F,7F,81), \
-       V(A0,50,50,F0), V(78,3C,3C,44), V(25,9F,9F,BA), V(4B,A8,A8,E3), \
-       V(A2,51,51,F3), V(5D,A3,A3,FE), V(80,40,40,C0), V(05,8F,8F,8A), \
-       V(3F,92,92,AD), V(21,9D,9D,BC), V(70,38,38,48), V(F1,F5,F5,04), \
-       V(63,BC,BC,DF), V(77,B6,B6,C1), V(AF,DA,DA,75), V(42,21,21,63), \
-       V(20,10,10,30), V(E5,FF,FF,1A), V(FD,F3,F3,0E), V(BF,D2,D2,6D), \
-       V(81,CD,CD,4C), V(18,0C,0C,14), V(26,13,13,35), V(C3,EC,EC,2F), \
-       V(BE,5F,5F,E1), V(35,97,97,A2), V(88,44,44,CC), V(2E,17,17,39), \
-       V(93,C4,C4,57), V(55,A7,A7,F2), V(FC,7E,7E,82), V(7A,3D,3D,47), \
-       V(C8,64,64,AC), V(BA,5D,5D,E7), V(32,19,19,2B), V(E6,73,73,95), \
-       V(C0,60,60,A0), V(19,81,81,98), V(9E,4F,4F,D1), V(A3,DC,DC,7F), \
-       V(44,22,22,66), V(54,2A,2A,7E), V(3B,90,90,AB), V(0B,88,88,83), \
-       V(8C,46,46,CA), V(C7,EE,EE,29), V(6B,B8,B8,D3), V(28,14,14,3C), \
-       V(A7,DE,DE,79), V(BC,5E,5E,E2), V(16,0B,0B,1D), V(AD,DB,DB,76), \
-       V(DB,E0,E0,3B), V(64,32,32,56), V(74,3A,3A,4E), V(14,0A,0A,1E), \
-       V(92,49,49,DB), V(0C,06,06,0A), V(48,24,24,6C), V(B8,5C,5C,E4), \
-       V(9F,C2,C2,5D), V(BD,D3,D3,6E), V(43,AC,AC,EF), V(C4,62,62,A6), \
-       V(39,91,91,A8), V(31,95,95,A4), V(D3,E4,E4,37), V(F2,79,79,8B), \
-       V(D5,E7,E7,32), V(8B,C8,C8,43), V(6E,37,37,59), V(DA,6D,6D,B7), \
-       V(01,8D,8D,8C), V(B1,D5,D5,64), V(9C,4E,4E,D2), V(49,A9,A9,E0), \
-       V(D8,6C,6C,B4), V(AC,56,56,FA), V(F3,F4,F4,07), V(CF,EA,EA,25), \
-       V(CA,65,65,AF), V(F4,7A,7A,8E), V(47,AE,AE,E9), V(10,08,08,18), \
-       V(6F,BA,BA,D5), V(F0,78,78,88), V(4A,25,25,6F), V(5C,2E,2E,72), \
-       V(38,1C,1C,24), V(57,A6,A6,F1), V(73,B4,B4,C7), V(97,C6,C6,51), \
-       V(CB,E8,E8,23), V(A1,DD,DD,7C), V(E8,74,74,9C), V(3E,1F,1F,21), \
-       V(96,4B,4B,DD), V(61,BD,BD,DC), V(0D,8B,8B,86), V(0F,8A,8A,85), \
-       V(E0,70,70,90), V(7C,3E,3E,42), V(71,B5,B5,C4), V(CC,66,66,AA), \
-       V(90,48,48,D8), V(06,03,03,05), V(F7,F6,F6,01), V(1C,0E,0E,12), \
-       V(C2,61,61,A3), V(6A,35,35,5F), V(AE,57,57,F9), V(69,B9,B9,D0), \
-       V(17,86,86,91), V(99,C1,C1,58), V(3A,1D,1D,27), V(27,9E,9E,B9), \
-       V(D9,E1,E1,38), V(EB,F8,F8,13), V(2B,98,98,B3), V(22,11,11,33), \
-       V(D2,69,69,BB), V(A9,D9,D9,70), V(07,8E,8E,89), V(33,94,94,A7), \
-       V(2D,9B,9B,B6), V(3C,1E,1E,22), V(15,87,87,92), V(C9,E9,E9,20), \
-       V(87,CE,CE,49), V(AA,55,55,FF), V(50,28,28,78), V(A5,DF,DF,7A), \
-       V(03,8C,8C,8F), V(59,A1,A1,F8), V(09,89,89,80), V(1A,0D,0D,17), \
-       V(65,BF,BF,DA), V(D7,E6,E6,31), V(84,42,42,C6), V(D0,68,68,B8), \
-       V(82,41,41,C3), V(29,99,99,B0), V(5A,2D,2D,77), V(1E,0F,0F,11), \
-       V(7B,B0,B0,CB), V(A8,54,54,FC), V(6D,BB,BB,D6), V(2C,16,16,3A)
-
-#define        V(a,b,c,d) 0x##a##b##c##d
-static uint32 FT0[256] = { FT };
-
-#undef V
-
-#define        V(a,b,c,d) 0x##d##a##b##c
-static uint32 FT1[256] = { FT };
-
-#undef V
-
-#define        V(a,b,c,d) 0x##c##d##a##b
-static uint32 FT2[256] = { FT };
-
-#undef V
-
-#define        V(a,b,c,d) 0x##b##c##d##a
-static uint32 FT3[256] = { FT };
-
-#undef V
-
-#undef FT
-
-/* reverse S-box */
-
-static uint32 RSb[256] = {
-       0x52, 0x09, 0x6A, 0xD5, 0x30, 0x36, 0xA5, 0x38,
-       0xBF, 0x40, 0xA3, 0x9E, 0x81, 0xF3, 0xD7, 0xFB,
-       0x7C, 0xE3, 0x39, 0x82, 0x9B, 0x2F, 0xFF, 0x87,
-       0x34, 0x8E, 0x43, 0x44, 0xC4, 0xDE, 0xE9, 0xCB,
-       0x54, 0x7B, 0x94, 0x32, 0xA6, 0xC2, 0x23, 0x3D,
-       0xEE, 0x4C, 0x95, 0x0B, 0x42, 0xFA, 0xC3, 0x4E,
-       0x08, 0x2E, 0xA1, 0x66, 0x28, 0xD9, 0x24, 0xB2,
-       0x76, 0x5B, 0xA2, 0x49, 0x6D, 0x8B, 0xD1, 0x25,
-       0x72, 0xF8, 0xF6, 0x64, 0x86, 0x68, 0x98, 0x16,
-       0xD4, 0xA4, 0x5C, 0xCC, 0x5D, 0x65, 0xB6, 0x92,
-       0x6C, 0x70, 0x48, 0x50, 0xFD, 0xED, 0xB9, 0xDA,
-       0x5E, 0x15, 0x46, 0x57, 0xA7, 0x8D, 0x9D, 0x84,
-       0x90, 0xD8, 0xAB, 0x00, 0x8C, 0xBC, 0xD3, 0x0A,
-       0xF7, 0xE4, 0x58, 0x05, 0xB8, 0xB3, 0x45, 0x06,
-       0xD0, 0x2C, 0x1E, 0x8F, 0xCA, 0x3F, 0x0F, 0x02,
-       0xC1, 0xAF, 0xBD, 0x03, 0x01, 0x13, 0x8A, 0x6B,
-       0x3A, 0x91, 0x11, 0x41, 0x4F, 0x67, 0xDC, 0xEA,
-       0x97, 0xF2, 0xCF, 0xCE, 0xF0, 0xB4, 0xE6, 0x73,
-       0x96, 0xAC, 0x74, 0x22, 0xE7, 0xAD, 0x35, 0x85,
-       0xE2, 0xF9, 0x37, 0xE8, 0x1C, 0x75, 0xDF, 0x6E,
-       0x47, 0xF1, 0x1A, 0x71, 0x1D, 0x29, 0xC5, 0x89,
-       0x6F, 0xB7, 0x62, 0x0E, 0xAA, 0x18, 0xBE, 0x1B,
-       0xFC, 0x56, 0x3E, 0x4B, 0xC6, 0xD2, 0x79, 0x20,
-       0x9A, 0xDB, 0xC0, 0xFE, 0x78, 0xCD, 0x5A, 0xF4,
-       0x1F, 0xDD, 0xA8, 0x33, 0x88, 0x07, 0xC7, 0x31,
-       0xB1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xEC, 0x5F,
-       0x60, 0x51, 0x7F, 0xA9, 0x19, 0xB5, 0x4A, 0x0D,
-       0x2D, 0xE5, 0x7A, 0x9F, 0x93, 0xC9, 0x9C, 0xEF,
-       0xA0, 0xE0, 0x3B, 0x4D, 0xAE, 0x2A, 0xF5, 0xB0,
-       0xC8, 0xEB, 0xBB, 0x3C, 0x83, 0x53, 0x99, 0x61,
-       0x17, 0x2B, 0x04, 0x7E, 0xBA, 0x77, 0xD6, 0x26,
-       0xE1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0C, 0x7D
-};
-
-/* reverse table */
-
-#define        RT \
-\
-       V(51,F4,A7,50), V(7E,41,65,53), V(1A,17,A4,C3), V(3A,27,5E,96), \
-       V(3B,AB,6B,CB), V(1F,9D,45,F1), V(AC,FA,58,AB), V(4B,E3,03,93), \
-       V(20,30,FA,55), V(AD,76,6D,F6), V(88,CC,76,91), V(F5,02,4C,25), \
-       V(4F,E5,D7,FC), V(C5,2A,CB,D7), V(26,35,44,80), V(B5,62,A3,8F), \
-       V(DE,B1,5A,49), V(25,BA,1B,67), V(45,EA,0E,98), V(5D,FE,C0,E1), \
-       V(C3,2F,75,02), V(81,4C,F0,12), V(8D,46,97,A3), V(6B,D3,F9,C6), \
-       V(03,8F,5F,E7), V(15,92,9C,95), V(BF,6D,7A,EB), V(95,52,59,DA), \
-       V(D4,BE,83,2D), V(58,74,21,D3), V(49,E0,69,29), V(8E,C9,C8,44), \
-       V(75,C2,89,6A), V(F4,8E,79,78), V(99,58,3E,6B), V(27,B9,71,DD), \
-       V(BE,E1,4F,B6), V(F0,88,AD,17), V(C9,20,AC,66), V(7D,CE,3A,B4), \
-       V(63,DF,4A,18), V(E5,1A,31,82), V(97,51,33,60), V(62,53,7F,45), \
-       V(B1,64,77,E0), V(BB,6B,AE,84), V(FE,81,A0,1C), V(F9,08,2B,94), \
-       V(70,48,68,58), V(8F,45,FD,19), V(94,DE,6C,87), V(52,7B,F8,B7), \
-       V(AB,73,D3,23), V(72,4B,02,E2), V(E3,1F,8F,57), V(66,55,AB,2A), \
-       V(B2,EB,28,07), V(2F,B5,C2,03), V(86,C5,7B,9A), V(D3,37,08,A5), \
-       V(30,28,87,F2), V(23,BF,A5,B2), V(02,03,6A,BA), V(ED,16,82,5C), \
-       V(8A,CF,1C,2B), V(A7,79,B4,92), V(F3,07,F2,F0), V(4E,69,E2,A1), \
-       V(65,DA,F4,CD), V(06,05,BE,D5), V(D1,34,62,1F), V(C4,A6,FE,8A), \
-       V(34,2E,53,9D), V(A2,F3,55,A0), V(05,8A,E1,32), V(A4,F6,EB,75), \
-       V(0B,83,EC,39), V(40,60,EF,AA), V(5E,71,9F,06), V(BD,6E,10,51), \
-       V(3E,21,8A,F9), V(96,DD,06,3D), V(DD,3E,05,AE), V(4D,E6,BD,46), \
-       V(91,54,8D,B5), V(71,C4,5D,05), V(04,06,D4,6F), V(60,50,15,FF), \
-       V(19,98,FB,24), V(D6,BD,E9,97), V(89,40,43,CC), V(67,D9,9E,77), \
-       V(B0,E8,42,BD), V(07,89,8B,88), V(E7,19,5B,38), V(79,C8,EE,DB), \
-       V(A1,7C,0A,47), V(7C,42,0F,E9), V(F8,84,1E,C9), V(00,00,00,00), \
-       V(09,80,86,83), V(32,2B,ED,48), V(1E,11,70,AC), V(6C,5A,72,4E), \
-       V(FD,0E,FF,FB), V(0F,85,38,56), V(3D,AE,D5,1E), V(36,2D,39,27), \
-       V(0A,0F,D9,64), V(68,5C,A6,21), V(9B,5B,54,D1), V(24,36,2E,3A), \
-       V(0C,0A,67,B1), V(93,57,E7,0F), V(B4,EE,96,D2), V(1B,9B,91,9E), \
-       V(80,C0,C5,4F), V(61,DC,20,A2), V(5A,77,4B,69), V(1C,12,1A,16), \
-       V(E2,93,BA,0A), V(C0,A0,2A,E5), V(3C,22,E0,43), V(12,1B,17,1D), \
-       V(0E,09,0D,0B), V(F2,8B,C7,AD), V(2D,B6,A8,B9), V(14,1E,A9,C8), \
-       V(57,F1,19,85), V(AF,75,07,4C), V(EE,99,DD,BB), V(A3,7F,60,FD), \
-       V(F7,01,26,9F), V(5C,72,F5,BC), V(44,66,3B,C5), V(5B,FB,7E,34), \
-       V(8B,43,29,76), V(CB,23,C6,DC), V(B6,ED,FC,68), V(B8,E4,F1,63), \
-       V(D7,31,DC,CA), V(42,63,85,10), V(13,97,22,40), V(84,C6,11,20), \
-       V(85,4A,24,7D), V(D2,BB,3D,F8), V(AE,F9,32,11), V(C7,29,A1,6D), \
-       V(1D,9E,2F,4B), V(DC,B2,30,F3), V(0D,86,52,EC), V(77,C1,E3,D0), \
-       V(2B,B3,16,6C), V(A9,70,B9,99), V(11,94,48,FA), V(47,E9,64,22), \
-       V(A8,FC,8C,C4), V(A0,F0,3F,1A), V(56,7D,2C,D8), V(22,33,90,EF), \
-       V(87,49,4E,C7), V(D9,38,D1,C1), V(8C,CA,A2,FE), V(98,D4,0B,36), \
-       V(A6,F5,81,CF), V(A5,7A,DE,28), V(DA,B7,8E,26), V(3F,AD,BF,A4), \
-       V(2C,3A,9D,E4), V(50,78,92,0D), V(6A,5F,CC,9B), V(54,7E,46,62), \
-       V(F6,8D,13,C2), V(90,D8,B8,E8), V(2E,39,F7,5E), V(82,C3,AF,F5), \
-       V(9F,5D,80,BE), V(69,D0,93,7C), V(6F,D5,2D,A9), V(CF,25,12,B3), \
-       V(C8,AC,99,3B), V(10,18,7D,A7), V(E8,9C,63,6E), V(DB,3B,BB,7B), \
-       V(CD,26,78,09), V(6E,59,18,F4), V(EC,9A,B7,01), V(83,4F,9A,A8), \
-       V(E6,95,6E,65), V(AA,FF,E6,7E), V(21,BC,CF,08), V(EF,15,E8,E6), \
-       V(BA,E7,9B,D9), V(4A,6F,36,CE), V(EA,9F,09,D4), V(29,B0,7C,D6), \
-       V(31,A4,B2,AF), V(2A,3F,23,31), V(C6,A5,94,30), V(35,A2,66,C0), \
-       V(74,4E,BC,37), V(FC,82,CA,A6), V(E0,90,D0,B0), V(33,A7,D8,15), \
-       V(F1,04,98,4A), V(41,EC,DA,F7), V(7F,CD,50,0E), V(17,91,F6,2F), \
-       V(76,4D,D6,8D), V(43,EF,B0,4D), V(CC,AA,4D,54), V(E4,96,04,DF), \
-       V(9E,D1,B5,E3), V(4C,6A,88,1B), V(C1,2C,1F,B8), V(46,65,51,7F), \
-       V(9D,5E,EA,04), V(01,8C,35,5D), V(FA,87,74,73), V(FB,0B,41,2E), \
-       V(B3,67,1D,5A), V(92,DB,D2,52), V(E9,10,56,33), V(6D,D6,47,13), \
-       V(9A,D7,61,8C), V(37,A1,0C,7A), V(59,F8,14,8E), V(EB,13,3C,89), \
-       V(CE,A9,27,EE), V(B7,61,C9,35), V(E1,1C,E5,ED), V(7A,47,B1,3C), \
-       V(9C,D2,DF,59), V(55,F2,73,3F), V(18,14,CE,79), V(73,C7,37,BF), \
-       V(53,F7,CD,EA), V(5F,FD,AA,5B), V(DF,3D,6F,14), V(78,44,DB,86), \
-       V(CA,AF,F3,81), V(B9,68,C4,3E), V(38,24,34,2C), V(C2,A3,40,5F), \
-       V(16,1D,C3,72), V(BC,E2,25,0C), V(28,3C,49,8B), V(FF,0D,95,41), \
-       V(39,A8,01,71), V(08,0C,B3,DE), V(D8,B4,E4,9C), V(64,56,C1,90), \
-       V(7B,CB,84,61), V(D5,32,B6,70), V(48,6C,5C,74), V(D0,B8,57,42)
-
-#define        V(a,b,c,d) 0x##a##b##c##d
-static uint32 RT0[256] = { RT };
-
-#undef V
-
-#define        V(a,b,c,d) 0x##d##a##b##c
-static uint32 RT1[256] = { RT };
-
-#undef V
-
-#define        V(a,b,c,d) 0x##c##d##a##b
-static uint32 RT2[256] = { RT };
-
-#undef V
-
-#define        V(a,b,c,d) 0x##b##c##d##a
-static uint32 RT3[256] = { RT };
-
-#undef V
-
-#undef RT
-
-/* round constants */
-
-static uint32 RCON[10] = {
-       0x01000000, 0x02000000, 0x04000000, 0x08000000,
-       0x10000000, 0x20000000, 0x40000000, 0x80000000,
-       0x1B000000, 0x36000000
-};
-
-/* key schedule        tables */
-
-static int KT_init = 1;
-
-static uint32 KT0[256];
-static uint32 KT1[256];
-static uint32 KT2[256];
-static uint32 KT3[256];
-
-/* platform-independent        32-bit integer manipulation     macros */
-
-#define        GET_UINT32(n,b,i)                                               \
-{                                                                                              \
-       (n)     = (     (uint32) (b)[(i)        ] << 24 )               \
-               | (     (uint32) (b)[(i) + 1] << 16     )               \
-               | (     (uint32) (b)[(i) + 2] <<  8     )               \
-               | (     (uint32) (b)[(i) + 3]           );              \
-}
-
-#define        PUT_UINT32(n,b,i)                                               \
-{                                                                                              \
-       (b)[(i)    ] = (uint8) ( (n) >> 24 );           \
-       (b)[(i) + 1] = (uint8) ( (n) >> 16 );           \
-       (b)[(i) + 2] = (uint8) ( (n) >>  8 );           \
-       (b)[(i) + 3] = (uint8) ( (n)       );           \
-}
-
-int rt_aes_set_key(struct aes_context * ctx, uint8 * key, int nbits)
-{
-       int i;
-       uint32 *RK, *SK;
-
-       switch (nbits) {
-       case 128:
-               ctx->nr = 10;
-               break;
-       case 192:
-               ctx->nr = 12;
-               break;
-       case 256:
-               ctx->nr = 14;
-               break;
-       default:
-               return (1);
-       }
-
-       RK = (uint32 *) ctx->erk;
-
-       for (i = 0; i < (nbits >> 5); i++) {
-               GET_UINT32(RK[i], key, i * 4);
-       }
-
-       /* setup encryption     round keys */
-
-       switch (nbits) {
-       case 128:
-
-               for (i = 0; i < 10; i++, RK += 4) {
-                       RK[4] = RK[0] ^ RCON[i] ^
-                           (FSb[(uint8) (RK[3] >> 16)] << 24) ^
-                           (FSb[(uint8) (RK[3] >> 8)] << 16) ^
-                           (FSb[(uint8) (RK[3])] << 8) ^
-                           (FSb[(uint8) (RK[3] >> 24)]);
-
-                       RK[5] = RK[1] ^ RK[4];
-                       RK[6] = RK[2] ^ RK[5];
-                       RK[7] = RK[3] ^ RK[6];
-               }
-               break;
-
-       case 192:
-
-               for (i = 0; i < 8; i++, RK += 6) {
-                       RK[6] = RK[0] ^ RCON[i] ^
-                           (FSb[(uint8) (RK[5] >> 16)] << 24) ^
-                           (FSb[(uint8) (RK[5] >> 8)] << 16) ^
-                           (FSb[(uint8) (RK[5])] << 8) ^
-                           (FSb[(uint8) (RK[5] >> 24)]);
-
-                       RK[7] = RK[1] ^ RK[6];
-                       RK[8] = RK[2] ^ RK[7];
-                       RK[9] = RK[3] ^ RK[8];
-                       RK[10] = RK[4] ^ RK[9];
-                       RK[11] = RK[5] ^ RK[10];
-               }
-               break;
-
-       case 256:
-
-               for (i = 0; i < 7; i++, RK += 8) {
-                       RK[8] = RK[0] ^ RCON[i] ^
-                           (FSb[(uint8) (RK[7] >> 16)] << 24) ^
-                           (FSb[(uint8) (RK[7] >> 8)] << 16) ^
-                           (FSb[(uint8) (RK[7])] << 8) ^
-                           (FSb[(uint8) (RK[7] >> 24)]);
-
-                       RK[9] = RK[1] ^ RK[8];
-                       RK[10] = RK[2] ^ RK[9];
-                       RK[11] = RK[3] ^ RK[10];
-
-                       RK[12] = RK[4] ^
-                           (FSb[(uint8) (RK[11] >> 24)] << 24) ^
-                           (FSb[(uint8) (RK[11] >> 16)] << 16) ^
-                           (FSb[(uint8) (RK[11] >> 8)] << 8) ^
-                           (FSb[(uint8) (RK[11])]);
-
-                       RK[13] = RK[5] ^ RK[12];
-                       RK[14] = RK[6] ^ RK[13];
-                       RK[15] = RK[7] ^ RK[14];
-               }
-               break;
-       }
-
-       /* setup decryption     round keys */
-
-       if (KT_init) {
-               for (i = 0; i < 256; i++) {
-                       KT0[i] = RT0[FSb[i]];
-                       KT1[i] = RT1[FSb[i]];
-                       KT2[i] = RT2[FSb[i]];
-                       KT3[i] = RT3[FSb[i]];
-               }
-
-               KT_init = 0;
-       }
-
-       SK = (uint32 *) ctx->drk;
-
-       *SK++ = *RK++;
-       *SK++ = *RK++;
-       *SK++ = *RK++;
-       *SK++ = *RK++;
-
-       for (i = 1; i < ctx->nr; i++) {
-               RK -= 8;
-
-               *SK++ = KT0[(uint8) (*RK >> 24)] ^
-                   KT1[(uint8) (*RK >> 16)] ^
-                   KT2[(uint8) (*RK >> 8)] ^ KT3[(uint8) (*RK)];
-               RK++;
-
-               *SK++ = KT0[(uint8) (*RK >> 24)] ^
-                   KT1[(uint8) (*RK >> 16)] ^
-                   KT2[(uint8) (*RK >> 8)] ^ KT3[(uint8) (*RK)];
-               RK++;
-
-               *SK++ = KT0[(uint8) (*RK >> 24)] ^
-                   KT1[(uint8) (*RK >> 16)] ^
-                   KT2[(uint8) (*RK >> 8)] ^ KT3[(uint8) (*RK)];
-               RK++;
-
-               *SK++ = KT0[(uint8) (*RK >> 24)] ^
-                   KT1[(uint8) (*RK >> 16)] ^
-                   KT2[(uint8) (*RK >> 8)] ^ KT3[(uint8) (*RK)];
-               RK++;
-       }
-
-       RK -= 8;
-
-       *SK++ = *RK++;
-       *SK++ = *RK++;
-       *SK++ = *RK++;
-       *SK++ = *RK++;
-
-       return (0);
-}
-
-/* AES 128-bit block encryption        routine */
-
-void rt_aes_encrypt(struct aes_context * ctx, uint8 input[16], uint8 output[16])
-{
-       uint32 *RK, X0, X1, X2, X3, Y0, Y1, Y2, Y3;
-
-       RK = (uint32 *) ctx->erk;
-       GET_UINT32(X0, input, 0);
-       X0 ^= RK[0];
-       GET_UINT32(X1, input, 4);
-       X1 ^= RK[1];
-       GET_UINT32(X2, input, 8);
-       X2 ^= RK[2];
-       GET_UINT32(X3, input, 12);
-       X3 ^= RK[3];
-
-#define        AES_FROUND(X0,X1,X2,X3,Y0,Y1,Y2,Y3)             \
-{                                                                                              \
-       RK += 4;                                                                        \
-                                                                                               \
-       X0 = RK[0] ^ FT0[ (uint8) (     Y0 >> 24 ) ] ^  \
-                                FT1[ (uint8) ( Y1 >> 16 ) ] ^  \
-                                FT2[ (uint8) ( Y2 >>  8 ) ] ^  \
-                                FT3[ (uint8) ( Y3               ) ];   \
-                                                                                               \
-       X1 = RK[1] ^ FT0[ (uint8) (     Y1 >> 24 ) ] ^  \
-                                FT1[ (uint8) ( Y2 >> 16 ) ] ^  \
-                                FT2[ (uint8) ( Y3 >>  8 ) ] ^  \
-                                FT3[ (uint8) ( Y0               ) ];   \
-                                                                                               \
-       X2 = RK[2] ^ FT0[ (uint8) (     Y2 >> 24 ) ] ^  \
-                                FT1[ (uint8) ( Y3 >> 16 ) ] ^  \
-                                FT2[ (uint8) ( Y0 >>  8 ) ] ^  \
-                                FT3[ (uint8) ( Y1               ) ];   \
-                                                                                               \
-       X3 = RK[3] ^ FT0[ (uint8) (     Y3 >> 24 ) ] ^  \
-                                FT1[ (uint8) ( Y0 >> 16 ) ] ^  \
-                                FT2[ (uint8) ( Y1 >>  8 ) ] ^  \
-                                FT3[ (uint8) ( Y2               ) ];   \
-}
-
-       AES_FROUND(Y0, Y1, Y2, Y3, X0, X1, X2, X3);     /* round 1 */
-       AES_FROUND(X0, X1, X2, X3, Y0, Y1, Y2, Y3);     /* round 2 */
-       AES_FROUND(Y0, Y1, Y2, Y3, X0, X1, X2, X3);     /* round 3 */
-       AES_FROUND(X0, X1, X2, X3, Y0, Y1, Y2, Y3);     /* round 4 */
-       AES_FROUND(Y0, Y1, Y2, Y3, X0, X1, X2, X3);     /* round 5 */
-       AES_FROUND(X0, X1, X2, X3, Y0, Y1, Y2, Y3);     /* round 6 */
-       AES_FROUND(Y0, Y1, Y2, Y3, X0, X1, X2, X3);     /* round 7 */
-       AES_FROUND(X0, X1, X2, X3, Y0, Y1, Y2, Y3);     /* round 8 */
-       AES_FROUND(Y0, Y1, Y2, Y3, X0, X1, X2, X3);     /* round 9 */
-
-       if (ctx->nr > 10) {
-               AES_FROUND(X0, X1, X2, X3, Y0, Y1, Y2, Y3);     /* round 10     */
-               AES_FROUND(Y0, Y1, Y2, Y3, X0, X1, X2, X3);     /* round 11     */
-       }
-
-       if (ctx->nr > 12) {
-               AES_FROUND(X0, X1, X2, X3, Y0, Y1, Y2, Y3);     /* round 12     */
-               AES_FROUND(Y0, Y1, Y2, Y3, X0, X1, X2, X3);     /* round 13     */
-       }
-
-       /* last round */
-
-       RK += 4;
-
-       X0 = RK[0] ^ (FSb[(uint8) (Y0 >> 24)] << 24) ^
-           (FSb[(uint8) (Y1 >> 16)] << 16) ^
-           (FSb[(uint8) (Y2 >> 8)] << 8) ^ (FSb[(uint8) (Y3)]);
-
-       X1 = RK[1] ^ (FSb[(uint8) (Y1 >> 24)] << 24) ^
-           (FSb[(uint8) (Y2 >> 16)] << 16) ^
-           (FSb[(uint8) (Y3 >> 8)] << 8) ^ (FSb[(uint8) (Y0)]);
-
-       X2 = RK[2] ^ (FSb[(uint8) (Y2 >> 24)] << 24) ^
-           (FSb[(uint8) (Y3 >> 16)] << 16) ^
-           (FSb[(uint8) (Y0 >> 8)] << 8) ^ (FSb[(uint8) (Y1)]);
-
-       X3 = RK[3] ^ (FSb[(uint8) (Y3 >> 24)] << 24) ^
-           (FSb[(uint8) (Y0 >> 16)] << 16) ^
-           (FSb[(uint8) (Y1 >> 8)] << 8) ^ (FSb[(uint8) (Y2)]);
-
-       PUT_UINT32(X0, output, 0);
-       PUT_UINT32(X1, output, 4);
-       PUT_UINT32(X2, output, 8);
-       PUT_UINT32(X3, output, 12);
-}
-
-/* AES 128-bit block decryption        routine */
-
-void rt_aes_decrypt(struct aes_context * ctx, uint8 input[16], uint8 output[16])
-{
-       uint32 *RK, X0, X1, X2, X3, Y0, Y1, Y2, Y3;
-
-       RK = (uint32 *) ctx->drk;
-
-       GET_UINT32(X0, input, 0);
-       X0 ^= RK[0];
-       GET_UINT32(X1, input, 4);
-       X1 ^= RK[1];
-       GET_UINT32(X2, input, 8);
-       X2 ^= RK[2];
-       GET_UINT32(X3, input, 12);
-       X3 ^= RK[3];
-
-#define        AES_RROUND(X0,X1,X2,X3,Y0,Y1,Y2,Y3)             \
-{                                                                                              \
-       RK += 4;                                                                        \
-                                                                                               \
-       X0 = RK[0] ^ RT0[ (uint8) (     Y0 >> 24 ) ] ^  \
-                                RT1[ (uint8) ( Y3 >> 16 ) ] ^  \
-                                RT2[ (uint8) ( Y2 >>  8 ) ] ^  \
-                                RT3[ (uint8) ( Y1               ) ];   \
-                                                                                               \
-       X1 = RK[1] ^ RT0[ (uint8) (     Y1 >> 24 ) ] ^  \
-                                RT1[ (uint8) ( Y0 >> 16 ) ] ^  \
-                                RT2[ (uint8) ( Y3 >>  8 ) ] ^  \
-                                RT3[ (uint8) ( Y2               ) ];   \
-                                                                                               \
-       X2 = RK[2] ^ RT0[ (uint8) (     Y2 >> 24 ) ] ^  \
-                                RT1[ (uint8) ( Y1 >> 16 ) ] ^  \
-                                RT2[ (uint8) ( Y0 >>  8 ) ] ^  \
-                                RT3[ (uint8) ( Y3               ) ];   \
-                                                                                               \
-       X3 = RK[3] ^ RT0[ (uint8) (     Y3 >> 24 ) ] ^  \
-                                RT1[ (uint8) ( Y2 >> 16 ) ] ^  \
-                                RT2[ (uint8) ( Y1 >>  8 ) ] ^  \
-                                RT3[ (uint8) ( Y0               ) ];   \
-}
-
-       AES_RROUND(Y0, Y1, Y2, Y3, X0, X1, X2, X3);     /* round 1 */
-       AES_RROUND(X0, X1, X2, X3, Y0, Y1, Y2, Y3);     /* round 2 */
-       AES_RROUND(Y0, Y1, Y2, Y3, X0, X1, X2, X3);     /* round 3 */
-       AES_RROUND(X0, X1, X2, X3, Y0, Y1, Y2, Y3);     /* round 4 */
-       AES_RROUND(Y0, Y1, Y2, Y3, X0, X1, X2, X3);     /* round 5 */
-       AES_RROUND(X0, X1, X2, X3, Y0, Y1, Y2, Y3);     /* round 6 */
-       AES_RROUND(Y0, Y1, Y2, Y3, X0, X1, X2, X3);     /* round 7 */
-       AES_RROUND(X0, X1, X2, X3, Y0, Y1, Y2, Y3);     /* round 8 */
-       AES_RROUND(Y0, Y1, Y2, Y3, X0, X1, X2, X3);     /* round 9 */
-
-       if (ctx->nr > 10) {
-               AES_RROUND(X0, X1, X2, X3, Y0, Y1, Y2, Y3);     /* round 10     */
-               AES_RROUND(Y0, Y1, Y2, Y3, X0, X1, X2, X3);     /* round 11     */
-       }
-
-       if (ctx->nr > 12) {
-               AES_RROUND(X0, X1, X2, X3, Y0, Y1, Y2, Y3);     /* round 12     */
-               AES_RROUND(Y0, Y1, Y2, Y3, X0, X1, X2, X3);     /* round 13     */
-       }
-
-       /* last round */
-
-       RK += 4;
-
-       X0 = RK[0] ^ (RSb[(uint8) (Y0 >> 24)] << 24) ^
-           (RSb[(uint8) (Y3 >> 16)] << 16) ^
-           (RSb[(uint8) (Y2 >> 8)] << 8) ^ (RSb[(uint8) (Y1)]);
-
-       X1 = RK[1] ^ (RSb[(uint8) (Y1 >> 24)] << 24) ^
-           (RSb[(uint8) (Y0 >> 16)] << 16) ^
-           (RSb[(uint8) (Y3 >> 8)] << 8) ^ (RSb[(uint8) (Y2)]);
-
-       X2 = RK[2] ^ (RSb[(uint8) (Y2 >> 24)] << 24) ^
-           (RSb[(uint8) (Y1 >> 16)] << 16) ^
-           (RSb[(uint8) (Y0 >> 8)] << 8) ^ (RSb[(uint8) (Y3)]);
-
-       X3 = RK[3] ^ (RSb[(uint8) (Y3 >> 24)] << 24) ^
-           (RSb[(uint8) (Y2 >> 16)] << 16) ^
-           (RSb[(uint8) (Y1 >> 8)] << 8) ^ (RSb[(uint8) (Y0)]);
-
-       PUT_UINT32(X0, output, 0);
-       PUT_UINT32(X1, output, 4);
-       PUT_UINT32(X2, output, 8);
-       PUT_UINT32(X3, output, 12);
-}
-
-/*
-    ==========================================================================
-    Description:
-        ENCRYPT AES GTK before sending in EAPOL frame.
-        AES GTK length = 128 bit,  so fix blocks for aes-key-wrap as 2 in this function.
-        This function references to RFC 3394 for aes key wrap algorithm.
-    Return:
-    ==========================================================================
-*/
-void AES_GTK_KEY_WRAP(u8 * key,
-                     u8 * plaintext,
-                     u32 p_len, u8 * ciphertext)
-{
-       u8 A[8], BIN[16], BOUT[16];
-       u8 R[512];
-       int num_blocks = p_len / 8;     /* unit:64bits */
-       int i, j;
-       struct aes_context aesctx;
-       u8 xor;
-
-       rt_aes_set_key(&aesctx, key, 128);
-
-       /* Init IA */
-       for (i = 0; i < 8; i++)
-               A[i] = 0xa6;
-
-       /*Input plaintext */
-       for (i = 0; i < num_blocks; i++) {
-               for (j = 0; j < 8; j++)
-                       R[8 * (i + 1) + j] = plaintext[8 * i + j];
-       }
-
-       /* Key Mix */
-       for (j = 0; j < 6; j++) {
-               for (i = 1; i <= num_blocks; i++) {
-                       /*phase 1 */
-                       NdisMoveMemory(BIN, A, 8);
-                       NdisMoveMemory(&BIN[8], &R[8 * i], 8);
-                       rt_aes_encrypt(&aesctx, BIN, BOUT);
-
-                       NdisMoveMemory(A, &BOUT[0], 8);
-                       xor = num_blocks * j + i;
-                       A[7] = BOUT[7] ^ xor;
-                       NdisMoveMemory(&R[8 * i], &BOUT[8], 8);
-               }
-       }
-
-       /* Output ciphertext */
-       NdisMoveMemory(ciphertext, A, 8);
-
-       for (i = 1; i <= num_blocks; i++) {
-               for (j = 0; j < 8; j++)
-                       ciphertext[8 * i + j] = R[8 * i + j];
-       }
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Misc function to decrypt AES body
-
-       Arguments:
-
-       Return Value:
-
-       Note:
-               This function references to     RFC     3394 for aes key unwrap algorithm.
-
-       ========================================================================
-*/
-void AES_GTK_KEY_UNWRAP(u8 * key,
-                       u8 * plaintext,
-                       u32 c_len, u8 * ciphertext)
-{
-       u8 A[8], BIN[16], BOUT[16];
-       u8 xor;
-       int i, j;
-       struct aes_context aesctx;
-       u8 *R;
-       int num_blocks = c_len / 8;     /* unit:64bits */
-
-       os_alloc_mem(NULL, (u8 **) & R, 512);
-
-       if (R == NULL) {
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("AES_GTK_KEY_UNWRAP: no memory!\n"));
-               return;
-       }
-       /* End of if */
-       /* Initialize */
-       NdisMoveMemory(A, ciphertext, 8);
-       /*Input plaintext */
-       for (i = 0; i < (c_len - 8); i++) {
-               R[i] = ciphertext[i + 8];
-       }
-
-       rt_aes_set_key(&aesctx, key, 128);
-
-       for (j = 5; j >= 0; j--) {
-               for (i = (num_blocks - 1); i > 0; i--) {
-                       xor = (num_blocks - 1) * j + i;
-                       NdisMoveMemory(BIN, A, 8);
-                       BIN[7] = A[7] ^ xor;
-                       NdisMoveMemory(&BIN[8], &R[(i - 1) * 8], 8);
-                       rt_aes_decrypt(&aesctx, BIN, BOUT);
-                       NdisMoveMemory(A, &BOUT[0], 8);
-                       NdisMoveMemory(&R[(i - 1) * 8], &BOUT[8], 8);
-               }
-       }
-
-       /* OUTPUT */
-       for (i = 0; i < c_len; i++) {
-               plaintext[i] = R[i];
-       }
-
-       os_free_mem(NULL, R);
-}
diff --git a/drivers/staging/rt2860/common/cmm_asic.c b/drivers/staging/rt2860/common/cmm_asic.c
deleted file mode 100644 (file)
index 4d77e83..0000000
+++ /dev/null
@@ -1,2565 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-       Module Name:
-       cmm_asic.c
-
-       Abstract:
-       Functions used to communicate with ASIC
-
-       Revision History:
-       Who                     When                    What
-       --------        ----------              ----------------------------------------------
-*/
-
-#include "../rt_config.h"
-
-/* Reset the RFIC setting to new series */
-struct rt_rtmp_rf_regs RF2850RegTable[] = {
-/*              ch       R1              R2              R3(TX0~4=0) R4 */
-       {1, 0x98402ecc, 0x984c0786, 0x9816b455, 0x9800510b}
-       ,
-       {2, 0x98402ecc, 0x984c0786, 0x98168a55, 0x9800519f}
-       ,
-       {3, 0x98402ecc, 0x984c078a, 0x98168a55, 0x9800518b}
-       ,
-       {4, 0x98402ecc, 0x984c078a, 0x98168a55, 0x9800519f}
-       ,
-       {5, 0x98402ecc, 0x984c078e, 0x98168a55, 0x9800518b}
-       ,
-       {6, 0x98402ecc, 0x984c078e, 0x98168a55, 0x9800519f}
-       ,
-       {7, 0x98402ecc, 0x984c0792, 0x98168a55, 0x9800518b}
-       ,
-       {8, 0x98402ecc, 0x984c0792, 0x98168a55, 0x9800519f}
-       ,
-       {9, 0x98402ecc, 0x984c0796, 0x98168a55, 0x9800518b}
-       ,
-       {10, 0x98402ecc, 0x984c0796, 0x98168a55, 0x9800519f}
-       ,
-       {11, 0x98402ecc, 0x984c079a, 0x98168a55, 0x9800518b}
-       ,
-       {12, 0x98402ecc, 0x984c079a, 0x98168a55, 0x9800519f}
-       ,
-       {13, 0x98402ecc, 0x984c079e, 0x98168a55, 0x9800518b}
-       ,
-       {14, 0x98402ecc, 0x984c07a2, 0x98168a55, 0x98005193}
-       ,
-
-       /* 802.11 UNI / HyperLan 2 */
-       {36, 0x98402ecc, 0x984c099a, 0x98158a55, 0x980ed1a3}
-       ,
-       {38, 0x98402ecc, 0x984c099e, 0x98158a55, 0x980ed193}
-       ,
-       {40, 0x98402ec8, 0x984c0682, 0x98158a55, 0x980ed183}
-       ,
-       {44, 0x98402ec8, 0x984c0682, 0x98158a55, 0x980ed1a3}
-       ,
-       {46, 0x98402ec8, 0x984c0686, 0x98158a55, 0x980ed18b}
-       ,
-       {48, 0x98402ec8, 0x984c0686, 0x98158a55, 0x980ed19b}
-       ,
-       {52, 0x98402ec8, 0x984c068a, 0x98158a55, 0x980ed193}
-       ,
-       {54, 0x98402ec8, 0x984c068a, 0x98158a55, 0x980ed1a3}
-       ,
-       {56, 0x98402ec8, 0x984c068e, 0x98158a55, 0x980ed18b}
-       ,
-       {60, 0x98402ec8, 0x984c0692, 0x98158a55, 0x980ed183}
-       ,
-       {62, 0x98402ec8, 0x984c0692, 0x98158a55, 0x980ed193}
-       ,
-       {64, 0x98402ec8, 0x984c0692, 0x98158a55, 0x980ed1a3}
-       ,                       /* Plugfest#4, Day4, change RFR3 left4th 9->5. */
-
-       /* 802.11 HyperLan 2 */
-       {100, 0x98402ec8, 0x984c06b2, 0x98178a55, 0x980ed783}
-       ,
-
-       /* 2008.04.30 modified */
-       /* The system team has AN to improve the EVM value */
-       /* for channel 102 to 108 for the RT2850/RT2750 dual band solution. */
-       {102, 0x98402ec8, 0x985c06b2, 0x98578a55, 0x980ed793}
-       ,
-       {104, 0x98402ec8, 0x985c06b2, 0x98578a55, 0x980ed1a3}
-       ,
-       {108, 0x98402ecc, 0x985c0a32, 0x98578a55, 0x980ed193}
-       ,
-
-       {110, 0x98402ecc, 0x984c0a36, 0x98178a55, 0x980ed183}
-       ,
-       {112, 0x98402ecc, 0x984c0a36, 0x98178a55, 0x980ed19b}
-       ,
-       {116, 0x98402ecc, 0x984c0a3a, 0x98178a55, 0x980ed1a3}
-       ,
-       {118, 0x98402ecc, 0x984c0a3e, 0x98178a55, 0x980ed193}
-       ,
-       {120, 0x98402ec4, 0x984c0382, 0x98178a55, 0x980ed183}
-       ,
-       {124, 0x98402ec4, 0x984c0382, 0x98178a55, 0x980ed193}
-       ,
-       {126, 0x98402ec4, 0x984c0382, 0x98178a55, 0x980ed15b}
-       ,                       /* 0x980ed1bb->0x980ed15b required by Rory 20070927 */
-       {128, 0x98402ec4, 0x984c0382, 0x98178a55, 0x980ed1a3}
-       ,
-       {132, 0x98402ec4, 0x984c0386, 0x98178a55, 0x980ed18b}
-       ,
-       {134, 0x98402ec4, 0x984c0386, 0x98178a55, 0x980ed193}
-       ,
-       {136, 0x98402ec4, 0x984c0386, 0x98178a55, 0x980ed19b}
-       ,
-       {140, 0x98402ec4, 0x984c038a, 0x98178a55, 0x980ed183}
-       ,
-
-       /* 802.11 UNII */
-       {149, 0x98402ec4, 0x984c038a, 0x98178a55, 0x980ed1a7}
-       ,
-       {151, 0x98402ec4, 0x984c038e, 0x98178a55, 0x980ed187}
-       ,
-       {153, 0x98402ec4, 0x984c038e, 0x98178a55, 0x980ed18f}
-       ,
-       {157, 0x98402ec4, 0x984c038e, 0x98178a55, 0x980ed19f}
-       ,
-       {159, 0x98402ec4, 0x984c038e, 0x98178a55, 0x980ed1a7}
-       ,
-       {161, 0x98402ec4, 0x984c0392, 0x98178a55, 0x980ed187}
-       ,
-       {165, 0x98402ec4, 0x984c0392, 0x98178a55, 0x980ed197}
-       ,
-       {167, 0x98402ec4, 0x984c03d2, 0x98179855, 0x9815531f}
-       ,
-       {169, 0x98402ec4, 0x984c03d2, 0x98179855, 0x98155327}
-       ,
-       {171, 0x98402ec4, 0x984c03d6, 0x98179855, 0x98155307}
-       ,
-       {173, 0x98402ec4, 0x984c03d6, 0x98179855, 0x9815530f}
-       ,
-
-       /* Japan */
-       {184, 0x95002ccc, 0x9500491e, 0x9509be55, 0x950c0a0b}
-       ,
-       {188, 0x95002ccc, 0x95004922, 0x9509be55, 0x950c0a13}
-       ,
-       {192, 0x95002ccc, 0x95004926, 0x9509be55, 0x950c0a1b}
-       ,
-       {196, 0x95002ccc, 0x9500492a, 0x9509be55, 0x950c0a23}
-       ,
-       {208, 0x95002ccc, 0x9500493a, 0x9509be55, 0x950c0a13}
-       ,
-       {212, 0x95002ccc, 0x9500493e, 0x9509be55, 0x950c0a1b}
-       ,
-       {216, 0x95002ccc, 0x95004982, 0x9509be55, 0x950c0a23}
-       ,
-
-       /* still lack of MMAC(Japan) ch 34,38,42,46 */
-};
-
-u8 NUM_OF_2850_CHNL = (sizeof(RF2850RegTable) / sizeof(struct rt_rtmp_rf_regs));
-
-struct rt_frequency_item FreqItems3020[] = {
-       /**************************************************/
-       /* ISM : 2.4 to 2.483 GHz                         // */
-       /**************************************************/
-       /* 11g */
-       /**************************************************/
-       /*-CH---N-------R---K----------- */
-       {1, 241, 2, 2}
-       ,
-       {2, 241, 2, 7}
-       ,
-       {3, 242, 2, 2}
-       ,
-       {4, 242, 2, 7}
-       ,
-       {5, 243, 2, 2}
-       ,
-       {6, 243, 2, 7}
-       ,
-       {7, 244, 2, 2}
-       ,
-       {8, 244, 2, 7}
-       ,
-       {9, 245, 2, 2}
-       ,
-       {10, 245, 2, 7}
-       ,
-       {11, 246, 2, 2}
-       ,
-       {12, 246, 2, 7}
-       ,
-       {13, 247, 2, 2}
-       ,
-       {14, 248, 2, 4}
-       ,
-};
-
-u8 NUM_OF_3020_CHNL = (sizeof(FreqItems3020) / sizeof(struct rt_frequency_item));
-
-void AsicUpdateAutoFallBackTable(struct rt_rtmp_adapter *pAd, u8 *pRateTable)
-{
-       u8 i;
-       HT_FBK_CFG0_STRUC HtCfg0;
-       HT_FBK_CFG1_STRUC HtCfg1;
-       LG_FBK_CFG0_STRUC LgCfg0;
-       LG_FBK_CFG1_STRUC LgCfg1;
-       struct rt_rtmp_tx_rate_switch *pCurrTxRate, *pNextTxRate;
-
-       /* set to initial value */
-       HtCfg0.word = 0x65432100;
-       HtCfg1.word = 0xedcba988;
-       LgCfg0.word = 0xedcba988;
-       LgCfg1.word = 0x00002100;
-
-       pNextTxRate = (struct rt_rtmp_tx_rate_switch *) pRateTable + 1;
-       for (i = 1; i < *((u8 *)pRateTable); i++) {
-               pCurrTxRate = (struct rt_rtmp_tx_rate_switch *) pRateTable + 1 + i;
-               switch (pCurrTxRate->Mode) {
-               case 0: /*CCK */
-                       break;
-               case 1: /*OFDM */
-                       {
-                               switch (pCurrTxRate->CurrMCS) {
-                               case 0:
-                                       LgCfg0.field.OFDMMCS0FBK =
-                                           (pNextTxRate->Mode ==
-                                            MODE_OFDM) ? (pNextTxRate->
-                                                          CurrMCS +
-                                                          8) : pNextTxRate->
-                                           CurrMCS;
-                                       break;
-                               case 1:
-                                       LgCfg0.field.OFDMMCS1FBK =
-                                           (pNextTxRate->Mode ==
-                                            MODE_OFDM) ? (pNextTxRate->
-                                                          CurrMCS +
-                                                          8) : pNextTxRate->
-                                           CurrMCS;
-                                       break;
-                               case 2:
-                                       LgCfg0.field.OFDMMCS2FBK =
-                                           (pNextTxRate->Mode ==
-                                            MODE_OFDM) ? (pNextTxRate->
-                                                          CurrMCS +
-                                                          8) : pNextTxRate->
-                                           CurrMCS;
-                                       break;
-                               case 3:
-                                       LgCfg0.field.OFDMMCS3FBK =
-                                           (pNextTxRate->Mode ==
-                                            MODE_OFDM) ? (pNextTxRate->
-                                                          CurrMCS +
-                                                          8) : pNextTxRate->
-                                           CurrMCS;
-                                       break;
-                               case 4:
-                                       LgCfg0.field.OFDMMCS4FBK =
-                                           (pNextTxRate->Mode ==
-                                            MODE_OFDM) ? (pNextTxRate->
-                                                          CurrMCS +
-                                                          8) : pNextTxRate->
-                                           CurrMCS;
-                                       break;
-                               case 5:
-                                       LgCfg0.field.OFDMMCS5FBK =
-                                           (pNextTxRate->Mode ==
-                                            MODE_OFDM) ? (pNextTxRate->
-                                                          CurrMCS +
-                                                          8) : pNextTxRate->
-                                           CurrMCS;
-                                       break;
-                               case 6:
-                                       LgCfg0.field.OFDMMCS6FBK =
-                                           (pNextTxRate->Mode ==
-                                            MODE_OFDM) ? (pNextTxRate->
-                                                          CurrMCS +
-                                                          8) : pNextTxRate->
-                                           CurrMCS;
-                                       break;
-                               case 7:
-                                       LgCfg0.field.OFDMMCS7FBK =
-                                           (pNextTxRate->Mode ==
-                                            MODE_OFDM) ? (pNextTxRate->
-                                                          CurrMCS +
-                                                          8) : pNextTxRate->
-                                           CurrMCS;
-                                       break;
-                               }
-                       }
-                       break;
-               case 2: /*HT-MIX */
-               case 3: /*HT-GF */
-                       {
-                               if ((pNextTxRate->Mode >= MODE_HTMIX)
-                                   && (pCurrTxRate->CurrMCS !=
-                                       pNextTxRate->CurrMCS)) {
-                                       switch (pCurrTxRate->CurrMCS) {
-                                       case 0:
-                                               HtCfg0.field.HTMCS0FBK =
-                                                   pNextTxRate->CurrMCS;
-                                               break;
-                                       case 1:
-                                               HtCfg0.field.HTMCS1FBK =
-                                                   pNextTxRate->CurrMCS;
-                                               break;
-                                       case 2:
-                                               HtCfg0.field.HTMCS2FBK =
-                                                   pNextTxRate->CurrMCS;
-                                               break;
-                                       case 3:
-                                               HtCfg0.field.HTMCS3FBK =
-                                                   pNextTxRate->CurrMCS;
-                                               break;
-                                       case 4:
-                                               HtCfg0.field.HTMCS4FBK =
-                                                   pNextTxRate->CurrMCS;
-                                               break;
-                                       case 5:
-                                               HtCfg0.field.HTMCS5FBK =
-                                                   pNextTxRate->CurrMCS;
-                                               break;
-                                       case 6:
-                                               HtCfg0.field.HTMCS6FBK =
-                                                   pNextTxRate->CurrMCS;
-                                               break;
-                                       case 7:
-                                               HtCfg0.field.HTMCS7FBK =
-                                                   pNextTxRate->CurrMCS;
-                                               break;
-                                       case 8:
-                                               HtCfg1.field.HTMCS8FBK =
-                                                   pNextTxRate->CurrMCS;
-                                               break;
-                                       case 9:
-                                               HtCfg1.field.HTMCS9FBK =
-                                                   pNextTxRate->CurrMCS;
-                                               break;
-                                       case 10:
-                                               HtCfg1.field.HTMCS10FBK =
-                                                   pNextTxRate->CurrMCS;
-                                               break;
-                                       case 11:
-                                               HtCfg1.field.HTMCS11FBK =
-                                                   pNextTxRate->CurrMCS;
-                                               break;
-                                       case 12:
-                                               HtCfg1.field.HTMCS12FBK =
-                                                   pNextTxRate->CurrMCS;
-                                               break;
-                                       case 13:
-                                               HtCfg1.field.HTMCS13FBK =
-                                                   pNextTxRate->CurrMCS;
-                                               break;
-                                       case 14:
-                                               HtCfg1.field.HTMCS14FBK =
-                                                   pNextTxRate->CurrMCS;
-                                               break;
-                                       case 15:
-                                               HtCfg1.field.HTMCS15FBK =
-                                                   pNextTxRate->CurrMCS;
-                                               break;
-                                       default:
-                                               DBGPRINT(RT_DEBUG_ERROR,
-                                                        ("AsicUpdateAutoFallBackTable: not support CurrMCS=%d\n",
-                                                         pCurrTxRate->
-                                                         CurrMCS));
-                                       }
-                               }
-                       }
-                       break;
-               }
-
-               pNextTxRate = pCurrTxRate;
-       }
-
-       RTMP_IO_WRITE32(pAd, HT_FBK_CFG0, HtCfg0.word);
-       RTMP_IO_WRITE32(pAd, HT_FBK_CFG1, HtCfg1.word);
-       RTMP_IO_WRITE32(pAd, LG_FBK_CFG0, LgCfg0.word);
-       RTMP_IO_WRITE32(pAd, LG_FBK_CFG1, LgCfg1.word);
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Set MAC register value according operation mode.
-               OperationMode AND bNonGFExist are for MM and GF Proteciton.
-               If MM or GF mask is not set, those passing argument doesn't not take effect.
-
-               Operation mode meaning:
-               = 0 : Pure HT, no preotection.
-               = 0x01; there may be non-HT devices in both the control and extension channel, protection is optional in BSS.
-               = 0x10: No Transmission in 40M is protected.
-               = 0x11: Transmission in both 40M and 20M shall be protected
-               if (bNonGFExist)
-                       we should choose not to use GF. But still set correct ASIC registers.
-       ========================================================================
-*/
-void AsicUpdateProtect(struct rt_rtmp_adapter *pAd,
-                      u16 OperationMode,
-                      u8 SetMask,
-                      IN BOOLEAN bDisableBGProtect, IN BOOLEAN bNonGFExist)
-{
-       PROT_CFG_STRUC ProtCfg, ProtCfg4;
-       u32 Protect[6];
-       u16 offset;
-       u8 i;
-       u32 MacReg = 0;
-
-       if (!(pAd->CommonCfg.bHTProtect) && (OperationMode != 8)) {
-               return;
-       }
-
-       if (pAd->BATable.numDoneOriginator) {
-               /* */
-               /* enable the RTS/CTS to avoid channel collision */
-               /* */
-               SetMask = ALLN_SETPROTECT;
-               OperationMode = 8;
-       }
-       /* Config ASIC RTS threshold register */
-       RTMP_IO_READ32(pAd, TX_RTS_CFG, &MacReg);
-       MacReg &= 0xFF0000FF;
-       /* If the user want disable RtsThreshold and enable Amsdu/Ralink-Aggregation, set the RtsThreshold as 4096 */
-       if (((pAd->CommonCfg.BACapability.field.AmsduEnable) ||
-            (pAd->CommonCfg.bAggregationCapable == TRUE))
-           && pAd->CommonCfg.RtsThreshold == MAX_RTS_THRESHOLD) {
-               MacReg |= (0x1000 << 8);
-       } else {
-               MacReg |= (pAd->CommonCfg.RtsThreshold << 8);
-       }
-
-       RTMP_IO_WRITE32(pAd, TX_RTS_CFG, MacReg);
-
-       /* Initial common protection settings */
-       RTMPZeroMemory(Protect, sizeof(Protect));
-       ProtCfg4.word = 0;
-       ProtCfg.word = 0;
-       ProtCfg.field.TxopAllowGF40 = 1;
-       ProtCfg.field.TxopAllowGF20 = 1;
-       ProtCfg.field.TxopAllowMM40 = 1;
-       ProtCfg.field.TxopAllowMM20 = 1;
-       ProtCfg.field.TxopAllowOfdm = 1;
-       ProtCfg.field.TxopAllowCck = 1;
-       ProtCfg.field.RTSThEn = 1;
-       ProtCfg.field.ProtectNav = ASIC_SHORTNAV;
-
-       /* update PHY mode and rate */
-       if (pAd->CommonCfg.Channel > 14)
-               ProtCfg.field.ProtectRate = 0x4000;
-       ProtCfg.field.ProtectRate |= pAd->CommonCfg.RtsRate;
-
-       /* Handle legacy(B/G) protection */
-       if (bDisableBGProtect) {
-               /*ProtCfg.field.ProtectRate = pAd->CommonCfg.RtsRate; */
-               ProtCfg.field.ProtectCtrl = 0;
-               Protect[0] = ProtCfg.word;
-               Protect[1] = ProtCfg.word;
-               pAd->FlgCtsEnabled = 0; /* CTS-self is not used */
-       } else {
-               /*ProtCfg.field.ProtectRate = pAd->CommonCfg.RtsRate; */
-               ProtCfg.field.ProtectCtrl = 0;  /* CCK do not need to be protected */
-               Protect[0] = ProtCfg.word;
-               ProtCfg.field.ProtectCtrl = ASIC_CTS;   /* OFDM needs using CCK to protect */
-               Protect[1] = ProtCfg.word;
-               pAd->FlgCtsEnabled = 1; /* CTS-self is used */
-       }
-
-       /* Decide HT frame protection. */
-       if ((SetMask & ALLN_SETPROTECT) != 0) {
-               switch (OperationMode) {
-               case 0x0:
-                       /* NO PROTECT */
-                       /* 1.All STAs in the BSS are 20/40 MHz HT */
-                       /* 2. in ai 20/40MHz BSS */
-                       /* 3. all STAs are 20MHz in a 20MHz BSS */
-                       /* Pure HT. no protection. */
-
-                       /* MM20_PROT_CFG */
-                       /*      Reserved (31:27) */
-                       /*      PROT_TXOP(25:20) -- 010111 */
-                       /*      PROT_NAV(19:18)  -- 01 (Short NAV protection) */
-                       /*  PROT_CTRL(17:16) -- 00 (None) */
-                       /*      PROT_RATE(15:0)  -- 0x4004 (OFDM 24M) */
-                       Protect[2] = 0x01744004;
-
-                       /* MM40_PROT_CFG */
-                       /*      Reserved (31:27) */
-                       /*      PROT_TXOP(25:20) -- 111111 */
-                       /*      PROT_NAV(19:18)  -- 01 (Short NAV protection) */
-                       /*  PROT_CTRL(17:16) -- 00 (None) */
-                       /*      PROT_RATE(15:0)  -- 0x4084 (duplicate OFDM 24M) */
-                       Protect[3] = 0x03f44084;
-
-                       /* CF20_PROT_CFG */
-                       /*      Reserved (31:27) */
-                       /*      PROT_TXOP(25:20) -- 010111 */
-                       /*      PROT_NAV(19:18)  -- 01 (Short NAV protection) */
-                       /*  PROT_CTRL(17:16) -- 00 (None) */
-                       /*      PROT_RATE(15:0)  -- 0x4004 (OFDM 24M) */
-                       Protect[4] = 0x01744004;
-
-                       /* CF40_PROT_CFG */
-                       /*      Reserved (31:27) */
-                       /*      PROT_TXOP(25:20) -- 111111 */
-                       /*      PROT_NAV(19:18)  -- 01 (Short NAV protection) */
-                       /*  PROT_CTRL(17:16) -- 00 (None) */
-                       /*      PROT_RATE(15:0)  -- 0x4084 (duplicate OFDM 24M) */
-                       Protect[5] = 0x03f44084;
-
-                       if (bNonGFExist) {
-                               /* PROT_NAV(19:18)  -- 01 (Short NAV protectiion) */
-                               /* PROT_CTRL(17:16) -- 01 (RTS/CTS) */
-                               Protect[4] = 0x01754004;
-                               Protect[5] = 0x03f54084;
-                       }
-                       pAd->CommonCfg.IOTestParm.bRTSLongProtOn = FALSE;
-                       break;
-
-               case 1:
-                       /* This is "HT non-member protection mode." */
-                       /* If there may be non-HT STAs my BSS */
-                       ProtCfg.word = 0x01744004;      /* PROT_CTRL(17:16) : 0 (None) */
-                       ProtCfg4.word = 0x03f44084;     /* duplicaet legacy 24M. BW set 1. */
-                       if (OPSTATUS_TEST_FLAG
-                           (pAd, fOP_STATUS_BG_PROTECTION_INUSED)) {
-                               ProtCfg.word = 0x01740003;      /*ERP use Protection bit is set, use protection rate at Clause 18.. */
-                               ProtCfg4.word = 0x03f40003;     /* Don't duplicate RTS/CTS in CCK mode. 0x03f40083; */
-                       }
-                       /*Assign Protection method for 20&40 MHz packets */
-                       ProtCfg.field.ProtectCtrl = ASIC_RTS;
-                       ProtCfg.field.ProtectNav = ASIC_SHORTNAV;
-                       ProtCfg4.field.ProtectCtrl = ASIC_RTS;
-                       ProtCfg4.field.ProtectNav = ASIC_SHORTNAV;
-                       Protect[2] = ProtCfg.word;
-                       Protect[3] = ProtCfg4.word;
-                       Protect[4] = ProtCfg.word;
-                       Protect[5] = ProtCfg4.word;
-                       pAd->CommonCfg.IOTestParm.bRTSLongProtOn = TRUE;
-                       break;
-
-               case 2:
-                       /* If only HT STAs are in BSS. at least one is 20MHz. Only protect 40MHz packets */
-                       ProtCfg.word = 0x01744004;      /* PROT_CTRL(17:16) : 0 (None) */
-                       ProtCfg4.word = 0x03f44084;     /* duplicaet legacy 24M. BW set 1. */
-
-                       /*Assign Protection method for 40MHz packets */
-                       ProtCfg4.field.ProtectCtrl = ASIC_RTS;
-                       ProtCfg4.field.ProtectNav = ASIC_SHORTNAV;
-                       Protect[2] = ProtCfg.word;
-                       Protect[3] = ProtCfg4.word;
-                       if (bNonGFExist) {
-                               ProtCfg.field.ProtectCtrl = ASIC_RTS;
-                               ProtCfg.field.ProtectNav = ASIC_SHORTNAV;
-                       }
-                       Protect[4] = ProtCfg.word;
-                       Protect[5] = ProtCfg4.word;
-
-                       pAd->CommonCfg.IOTestParm.bRTSLongProtOn = FALSE;
-                       break;
-
-               case 3:
-                       /* HT mixed mode.        PROTECT ALL! */
-                       /* Assign Rate */
-                       ProtCfg.word = 0x01744004;      /*duplicaet legacy 24M. BW set 1. */
-                       ProtCfg4.word = 0x03f44084;
-                       /* both 20MHz and 40MHz are protected. Whether use RTS or CTS-to-self depends on the */
-                       if (OPSTATUS_TEST_FLAG
-                           (pAd, fOP_STATUS_BG_PROTECTION_INUSED)) {
-                               ProtCfg.word = 0x01740003;      /*ERP use Protection bit is set, use protection rate at Clause 18.. */
-                               ProtCfg4.word = 0x03f40003;     /* Don't duplicate RTS/CTS in CCK mode. 0x03f40083 */
-                       }
-                       /*Assign Protection method for 20&40 MHz packets */
-                       ProtCfg.field.ProtectCtrl = ASIC_RTS;
-                       ProtCfg.field.ProtectNav = ASIC_SHORTNAV;
-                       ProtCfg4.field.ProtectCtrl = ASIC_RTS;
-                       ProtCfg4.field.ProtectNav = ASIC_SHORTNAV;
-                       Protect[2] = ProtCfg.word;
-                       Protect[3] = ProtCfg4.word;
-                       Protect[4] = ProtCfg.word;
-                       Protect[5] = ProtCfg4.word;
-                       pAd->CommonCfg.IOTestParm.bRTSLongProtOn = TRUE;
-                       break;
-
-               case 8:
-                       /* Special on for Atheros problem n chip. */
-                       Protect[2] = 0x01754004;
-                       Protect[3] = 0x03f54084;
-                       Protect[4] = 0x01754004;
-                       Protect[5] = 0x03f54084;
-                       pAd->CommonCfg.IOTestParm.bRTSLongProtOn = TRUE;
-                       break;
-               }
-       }
-
-       offset = CCK_PROT_CFG;
-       for (i = 0; i < 6; i++) {
-               if ((SetMask & (1 << i))) {
-                       RTMP_IO_WRITE32(pAd, offset + i * 4, Protect[i]);
-               }
-       }
-}
-
-/*
-       ==========================================================================
-       Description:
-
-       IRQL = PASSIVE_LEVEL
-       IRQL = DISPATCH_LEVEL
-
-       ==========================================================================
- */
-void AsicSwitchChannel(struct rt_rtmp_adapter *pAd, u8 Channel, IN BOOLEAN bScan)
-{
-       unsigned long R2 = 0, R3 = DEFAULT_RF_TX_POWER, R4 = 0;
-       char TxPwer = 0, TxPwer2 = DEFAULT_RF_TX_POWER; /*Bbp94 = BBPR94_DEFAULT, TxPwer2 = DEFAULT_RF_TX_POWER; */
-       u8 index;
-       u32 Value = 0;  /*BbpReg, Value; */
-       struct rt_rtmp_rf_regs *RFRegTable;
-       u8 RFValue;
-
-       RFValue = 0;
-       /* Search Tx power value */
-       /* We can't use ChannelList to search channel, since some central channl's txpowr doesn't list */
-       /* in ChannelList, so use TxPower array instead. */
-       /* */
-       for (index = 0; index < MAX_NUM_OF_CHANNELS; index++) {
-               if (Channel == pAd->TxPower[index].Channel) {
-                       TxPwer = pAd->TxPower[index].Power;
-                       TxPwer2 = pAd->TxPower[index].Power2;
-                       break;
-               }
-       }
-
-       if (index == MAX_NUM_OF_CHANNELS) {
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("AsicSwitchChannel: Can't find the Channel#%d \n",
-                         Channel));
-       }
-#ifdef RT30xx
-       /* The RF programming sequence is difference between 3xxx and 2xxx */
-       if ((IS_RT3070(pAd) || IS_RT3090(pAd) || IS_RT3390(pAd))
-           && ((pAd->RfIcType == RFIC_3020) || (pAd->RfIcType == RFIC_2020)
-               || (pAd->RfIcType == RFIC_3021)
-               || (pAd->RfIcType == RFIC_3022))) {
-               /* modify by WY for Read RF Reg. error */
-
-               for (index = 0; index < NUM_OF_3020_CHNL; index++) {
-                       if (Channel == FreqItems3020[index].Channel) {
-                               /* Programming channel parameters */
-                               RT30xxWriteRFRegister(pAd, RF_R02,
-                                                     FreqItems3020[index].N);
-                               RT30xxWriteRFRegister(pAd, RF_R03,
-                                                     FreqItems3020[index].K);
-                               RT30xxReadRFRegister(pAd, RF_R06, &RFValue);
-                               RFValue =
-                                   (RFValue & 0xFC) | FreqItems3020[index].R;
-                               RT30xxWriteRFRegister(pAd, RF_R06, RFValue);
-
-                               /* Set Tx0 Power */
-                               RT30xxReadRFRegister(pAd, RF_R12, &RFValue);
-                               RFValue = (RFValue & 0xE0) | TxPwer;
-                               RT30xxWriteRFRegister(pAd, RF_R12, RFValue);
-
-                               /* Set Tx1 Power */
-                               RT30xxReadRFRegister(pAd, RF_R13, &RFValue);
-                               RFValue = (RFValue & 0xE0) | TxPwer2;
-                               RT30xxWriteRFRegister(pAd, RF_R13, RFValue);
-
-                               /* Tx/Rx Stream setting */
-                               RT30xxReadRFRegister(pAd, RF_R01, &RFValue);
-                               /*if (IS_RT3090(pAd)) */
-                               /*      RFValue |= 0x01; // Enable RF block. */
-                               RFValue &= 0x03;        /*clear bit[7~2] */
-                               if (pAd->Antenna.field.TxPath == 1)
-                                       RFValue |= 0xA0;
-                               else if (pAd->Antenna.field.TxPath == 2)
-                                       RFValue |= 0x80;
-                               if (pAd->Antenna.field.RxPath == 1)
-                                       RFValue |= 0x50;
-                               else if (pAd->Antenna.field.RxPath == 2)
-                                       RFValue |= 0x40;
-                               RT30xxWriteRFRegister(pAd, RF_R01, RFValue);
-
-                               /* Set RF offset */
-                               RT30xxReadRFRegister(pAd, RF_R23, &RFValue);
-                               RFValue = (RFValue & 0x80) | pAd->RfFreqOffset;
-                               RT30xxWriteRFRegister(pAd, RF_R23, RFValue);
-
-                               /* Set BW */
-                               if (!bScan
-                                   && (pAd->CommonCfg.BBPCurrentBW == BW_40)) {
-                                       RFValue = pAd->Mlme.CaliBW40RfR24;
-                                       /*DISABLE_11N_CHECK(pAd); */
-                               } else {
-                                       RFValue = pAd->Mlme.CaliBW20RfR24;
-                               }
-                               RT30xxWriteRFRegister(pAd, RF_R24, RFValue);
-                               RT30xxWriteRFRegister(pAd, RF_R31, RFValue);
-
-                               /* Enable RF tuning */
-                               RT30xxReadRFRegister(pAd, RF_R07, &RFValue);
-                               RFValue = RFValue | 0x1;
-                               RT30xxWriteRFRegister(pAd, RF_R07, RFValue);
-
-                               /* latch channel for future usage. */
-                               pAd->LatchRfRegs.Channel = Channel;
-
-                               DBGPRINT(RT_DEBUG_TRACE,
-                                        ("SwitchChannel#%d(RF=%d, Pwr0=%d, Pwr1=%d, %dT), N=0x%02X, K=0x%02X, R=0x%02X\n",
-                                         Channel, pAd->RfIcType, TxPwer,
-                                         TxPwer2, pAd->Antenna.field.TxPath,
-                                         FreqItems3020[index].N,
-                                         FreqItems3020[index].K,
-                                         FreqItems3020[index].R));
-
-                               break;
-                       }
-               }
-       } else
-#endif /* RT30xx // */
-       {
-               RFRegTable = RF2850RegTable;
-               switch (pAd->RfIcType) {
-               case RFIC_2820:
-               case RFIC_2850:
-               case RFIC_2720:
-               case RFIC_2750:
-
-                       for (index = 0; index < NUM_OF_2850_CHNL; index++) {
-                               if (Channel == RFRegTable[index].Channel) {
-                                       R2 = RFRegTable[index].R2;
-                                       if (pAd->Antenna.field.TxPath == 1) {
-                                               R2 |= 0x4000;   /* If TXpath is 1, bit 14 = 1; */
-                                       }
-
-                                       if (pAd->Antenna.field.RxPath == 2) {
-                                               R2 |= 0x40;     /* write 1 to off Rxpath. */
-                                       } else if (pAd->Antenna.field.RxPath ==
-                                                  1) {
-                                               R2 |= 0x20040;  /* write 1 to off RxPath */
-                                       }
-
-                                       if (Channel > 14) {
-                                               /* initialize R3, R4 */
-                                               R3 = (RFRegTable[index].
-                                                     R3 & 0xffffc1ff);
-                                               R4 = (RFRegTable[index].
-                                                     R4 & (~0x001f87c0)) |
-                                                   (pAd->RfFreqOffset << 15);
-
-                                               /* 5G band power range: 0xF9~0X0F, TX0 Reg3 bit9/TX1 Reg4 bit6="0" means the TX power reduce 7dB */
-                                               /* R3 */
-                                               if ((TxPwer >= -7)
-                                                   && (TxPwer < 0)) {
-                                                       TxPwer = (7 + TxPwer);
-                                                       TxPwer =
-                                                           (TxPwer >
-                                                            0xF) ? (0xF)
-                                                           : (TxPwer);
-                                                       R3 |= (TxPwer << 10);
-                                                       DBGPRINT(RT_DEBUG_ERROR,
-                                                                ("AsicSwitchChannel: TxPwer=%d \n",
-                                                                 TxPwer));
-                                               } else {
-                                                       TxPwer =
-                                                           (TxPwer >
-                                                            0xF) ? (0xF)
-                                                           : (TxPwer);
-                                                       R3 |=
-                                                           (TxPwer << 10) | (1
-                                                                             <<
-                                                                             9);
-                                               }
-
-                                               /* R4 */
-                                               if ((TxPwer2 >= -7)
-                                                   && (TxPwer2 < 0)) {
-                                                       TxPwer2 = (7 + TxPwer2);
-                                                       TxPwer2 =
-                                                           (TxPwer2 >
-                                                            0xF) ? (0xF)
-                                                           : (TxPwer2);
-                                                       R4 |= (TxPwer2 << 7);
-                                                       DBGPRINT(RT_DEBUG_ERROR,
-                                                                ("AsicSwitchChannel: TxPwer2=%d \n",
-                                                                 TxPwer2));
-                                               } else {
-                                                       TxPwer2 =
-                                                           (TxPwer2 >
-                                                            0xF) ? (0xF)
-                                                           : (TxPwer2);
-                                                       R4 |=
-                                                           (TxPwer2 << 7) | (1
-                                                                             <<
-                                                                             6);
-                                               }
-                                       } else {
-                                               R3 = (RFRegTable[index].R3 & 0xffffc1ff) | (TxPwer << 9);       /* set TX power0 */
-                                               R4 = (RFRegTable[index].R4 & (~0x001f87c0)) | (pAd->RfFreqOffset << 15) | (TxPwer2 << 6);       /* Set freq Offset & TxPwr1 */
-                                       }
-
-                                       /* Based on BBP current mode before changing RF channel. */
-                                       if (!bScan
-                                           && (pAd->CommonCfg.BBPCurrentBW ==
-                                               BW_40)) {
-                                               R4 |= 0x200000;
-                                       }
-                                       /* Update variables */
-                                       pAd->LatchRfRegs.Channel = Channel;
-                                       pAd->LatchRfRegs.R1 =
-                                           RFRegTable[index].R1;
-                                       pAd->LatchRfRegs.R2 = R2;
-                                       pAd->LatchRfRegs.R3 = R3;
-                                       pAd->LatchRfRegs.R4 = R4;
-
-                                       /* Set RF value 1's set R3[bit2] = [0] */
-                                       RTMP_RF_IO_WRITE32(pAd,
-                                                          pAd->LatchRfRegs.R1);
-                                       RTMP_RF_IO_WRITE32(pAd,
-                                                          pAd->LatchRfRegs.R2);
-                                       RTMP_RF_IO_WRITE32(pAd,
-                                                          (pAd->LatchRfRegs.
-                                                           R3 & (~0x04)));
-                                       RTMP_RF_IO_WRITE32(pAd,
-                                                          pAd->LatchRfRegs.R4);
-
-                                       RTMPusecDelay(200);
-
-                                       /* Set RF value 2's set R3[bit2] = [1] */
-                                       RTMP_RF_IO_WRITE32(pAd,
-                                                          pAd->LatchRfRegs.R1);
-                                       RTMP_RF_IO_WRITE32(pAd,
-                                                          pAd->LatchRfRegs.R2);
-                                       RTMP_RF_IO_WRITE32(pAd,
-                                                          (pAd->LatchRfRegs.
-                                                           R3 | 0x04));
-                                       RTMP_RF_IO_WRITE32(pAd,
-                                                          pAd->LatchRfRegs.R4);
-
-                                       RTMPusecDelay(200);
-
-                                       /* Set RF value 3's set R3[bit2] = [0] */
-                                       RTMP_RF_IO_WRITE32(pAd,
-                                                          pAd->LatchRfRegs.R1);
-                                       RTMP_RF_IO_WRITE32(pAd,
-                                                          pAd->LatchRfRegs.R2);
-                                       RTMP_RF_IO_WRITE32(pAd,
-                                                          (pAd->LatchRfRegs.
-                                                           R3 & (~0x04)));
-                                       RTMP_RF_IO_WRITE32(pAd,
-                                                          pAd->LatchRfRegs.R4);
-
-                                       break;
-                               }
-                       }
-                       break;
-
-               default:
-                       break;
-               }
-
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("SwitchChannel#%d(RF=%d, Pwr0=%lu, Pwr1=%lu, %dT) to , R1=0x%08lx, R2=0x%08lx, R3=0x%08lx, R4=0x%08lx\n",
-                         Channel, pAd->RfIcType, (R3 & 0x00003e00) >> 9,
-                         (R4 & 0x000007c0) >> 6, pAd->Antenna.field.TxPath,
-                         pAd->LatchRfRegs.R1, pAd->LatchRfRegs.R2,
-                         pAd->LatchRfRegs.R3, pAd->LatchRfRegs.R4));
-       }
-
-       /* Change BBP setting during siwtch from a->g, g->a */
-       if (Channel <= 14) {
-               unsigned long TxPinCfg = 0x00050F0A;    /*Gary 2007/08/09 0x050A0A */
-
-               RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R62,
-                                            (0x37 - GET_LNA_GAIN(pAd)));
-               RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R63,
-                                            (0x37 - GET_LNA_GAIN(pAd)));
-               RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R64,
-                                            (0x37 - GET_LNA_GAIN(pAd)));
-               RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R86, 0);  /*(0x44 - GET_LNA_GAIN(pAd)));    // According the Rory's suggestion to solve the middle range issue. */
-               /*RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R82, 0x62); */
-
-               /* Rx High power VGA offset for LNA select */
-               if (pAd->NicConfig2.field.ExternalLNAForG) {
-                       RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R82, 0x62);
-                       RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R75, 0x46);
-               } else {
-                       RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R82, 0x84);
-                       RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R75, 0x50);
-               }
-
-               /* 5G band selection PIN, bit1 and bit2 are complement */
-               RTMP_IO_READ32(pAd, TX_BAND_CFG, &Value);
-               Value &= (~0x6);
-               Value |= (0x04);
-               RTMP_IO_WRITE32(pAd, TX_BAND_CFG, Value);
-
-               /* Turn off unused PA or LNA when only 1T or 1R */
-               if (pAd->Antenna.field.TxPath == 1) {
-                       TxPinCfg &= 0xFFFFFFF3;
-               }
-               if (pAd->Antenna.field.RxPath == 1) {
-                       TxPinCfg &= 0xFFFFF3FF;
-               }
-
-               RTMP_IO_WRITE32(pAd, TX_PIN_CFG, TxPinCfg);
-
-#if defined(RT3090) || defined(RT3390)
-               /* PCIe PHY Transmit attenuation adjustment */
-               if (IS_RT3090A(pAd) || IS_RT3390(pAd)) {
-                       TX_ATTENUATION_CTRL_STRUC TxAttenuationCtrl = {
-                       .word = 0};
-
-                       RTMP_IO_READ32(pAd, PCIE_PHY_TX_ATTENUATION_CTRL,
-                                      &TxAttenuationCtrl.word);
-
-                       if (Channel == 14)      /* Channel #14 */
-                       {
-                               TxAttenuationCtrl.field.PCIE_PHY_TX_ATTEN_EN = 1;       /* Enable PCIe PHY Tx attenuation */
-                               TxAttenuationCtrl.field.PCIE_PHY_TX_ATTEN_VALUE = 4;    /* 9/16 full drive level */
-                       } else  /* Channel #1~#13 */
-                       {
-                               TxAttenuationCtrl.field.PCIE_PHY_TX_ATTEN_EN = 0;       /* Disable PCIe PHY Tx attenuation */
-                               TxAttenuationCtrl.field.PCIE_PHY_TX_ATTEN_VALUE = 0;    /* n/a */
-                       }
-
-                       RTMP_IO_WRITE32(pAd, PCIE_PHY_TX_ATTENUATION_CTRL,
-                                       TxAttenuationCtrl.word);
-               }
-#endif
-       } else {
-               unsigned long TxPinCfg = 0x00050F05;    /*Gary 2007/8/9 0x050505 */
-
-               RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R62,
-                                            (0x37 - GET_LNA_GAIN(pAd)));
-               RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R63,
-                                            (0x37 - GET_LNA_GAIN(pAd)));
-               RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R64,
-                                            (0x37 - GET_LNA_GAIN(pAd)));
-               RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R86, 0);  /*(0x44 - GET_LNA_GAIN(pAd)));   // According the Rory's suggestion to solve the middle range issue. */
-               RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R82, 0xF2);
-
-               /* Rx High power VGA offset for LNA select */
-               if (pAd->NicConfig2.field.ExternalLNAForA) {
-                       RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R75, 0x46);
-               } else {
-                       RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R75, 0x50);
-               }
-
-               /* 5G band selection PIN, bit1 and bit2 are complement */
-               RTMP_IO_READ32(pAd, TX_BAND_CFG, &Value);
-               Value &= (~0x6);
-               Value |= (0x02);
-               RTMP_IO_WRITE32(pAd, TX_BAND_CFG, Value);
-
-               /* Turn off unused PA or LNA when only 1T or 1R */
-               if (pAd->Antenna.field.TxPath == 1) {
-                       TxPinCfg &= 0xFFFFFFF3;
-               }
-               if (pAd->Antenna.field.RxPath == 1) {
-                       TxPinCfg &= 0xFFFFF3FF;
-               }
-
-               RTMP_IO_WRITE32(pAd, TX_PIN_CFG, TxPinCfg);
-
-       }
-
-       /* R66 should be set according to Channel and use 20MHz when scanning */
-       /*RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66, (0x2E + GET_LNA_GAIN(pAd))); */
-       if (bScan)
-               RTMPSetAGCInitValue(pAd, BW_20);
-       else
-               RTMPSetAGCInitValue(pAd, pAd->CommonCfg.BBPCurrentBW);
-
-       /* */
-       /* On 11A, We should delay and wait RF/BBP to be stable */
-       /* and the appropriate time should be 1000 micro seconds */
-       /* 2005/06/05 - On 11G, We also need this delay time. Otherwise it's difficult to pass the WHQL. */
-       /* */
-       RTMPusecDelay(1000);
-}
-
-void AsicResetBBPAgent(struct rt_rtmp_adapter *pAd)
-{
-       BBP_CSR_CFG_STRUC BbpCsr;
-       DBGPRINT(RT_DEBUG_ERROR, ("Reset BBP Agent busy bit!\n"));
-       /* Still need to find why BBP agent keeps busy, but in fact, hardware still function ok. Now clear busy first. */
-       RTMP_IO_READ32(pAd, H2M_BBP_AGENT, &BbpCsr.word);
-       BbpCsr.field.Busy = 0;
-       RTMP_IO_WRITE32(pAd, H2M_BBP_AGENT, BbpCsr.word);
-}
-
-/*
-       ==========================================================================
-       Description:
-               This function is required for 2421 only, and should not be used during
-               site survey. It's only required after NIC decided to stay at a channel
-               for a longer period.
-               When this function is called, it's always after AsicSwitchChannel().
-
-       IRQL = PASSIVE_LEVEL
-       IRQL = DISPATCH_LEVEL
-
-       ==========================================================================
- */
-void AsicLockChannel(struct rt_rtmp_adapter *pAd, u8 Channel)
-{
-}
-
-void AsicRfTuningExec(void *SystemSpecific1,
-                     void *FunctionContext,
-                     void *SystemSpecific2, void *SystemSpecific3)
-{
-}
-
-/*
-       ==========================================================================
-       Description:
-               Gives CCK TX rate 2 more dB TX power.
-               This routine works only in LINK UP in INFRASTRUCTURE mode.
-
-               calculate desired Tx power in RF R3.Tx0~5,      should consider -
-               0. if current radio is a noisy environment (pAd->DrsCounters.fNoisyEnvironment)
-               1. TxPowerPercentage
-               2. auto calibration based on TSSI feedback
-               3. extra 2 db for CCK
-               4. -10 db upon very-short distance (AvgRSSI >= -40db) to AP
-
-       NOTE: Since this routine requires the value of (pAd->DrsCounters.fNoisyEnvironment),
-               it should be called AFTER MlmeDynamicTxRatSwitching()
-       ==========================================================================
- */
-void AsicAdjustTxPower(struct rt_rtmp_adapter *pAd)
-{
-       int i, j;
-       char DeltaPwr = 0;
-       BOOLEAN bAutoTxAgc = FALSE;
-       u8 TssiRef, *pTssiMinusBoundary, *pTssiPlusBoundary, TxAgcStep;
-       u8 BbpR1 = 0, BbpR49 = 0, idx;
-       char *pTxAgcCompensate;
-       unsigned long TxPwr[5];
-       char Value;
-       char Rssi = -127;
-
-       if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE) ||
-#ifdef RTMP_MAC_PCI
-           (pAd->bPCIclkOff == TRUE) ||
-#endif /* RTMP_MAC_PCI // */
-           RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_IDLE_RADIO_OFF) ||
-           RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
-               return;
-
-       Rssi = RTMPMaxRssi(pAd,
-                          pAd->StaCfg.RssiSample.AvgRssi0,
-                          pAd->StaCfg.RssiSample.AvgRssi1,
-                          pAd->StaCfg.RssiSample.AvgRssi2);
-
-       if (pAd->CommonCfg.BBPCurrentBW == BW_40) {
-               if (pAd->CommonCfg.CentralChannel > 14) {
-                       TxPwr[0] = pAd->Tx40MPwrCfgABand[0];
-                       TxPwr[1] = pAd->Tx40MPwrCfgABand[1];
-                       TxPwr[2] = pAd->Tx40MPwrCfgABand[2];
-                       TxPwr[3] = pAd->Tx40MPwrCfgABand[3];
-                       TxPwr[4] = pAd->Tx40MPwrCfgABand[4];
-               } else {
-                       TxPwr[0] = pAd->Tx40MPwrCfgGBand[0];
-                       TxPwr[1] = pAd->Tx40MPwrCfgGBand[1];
-                       TxPwr[2] = pAd->Tx40MPwrCfgGBand[2];
-                       TxPwr[3] = pAd->Tx40MPwrCfgGBand[3];
-                       TxPwr[4] = pAd->Tx40MPwrCfgGBand[4];
-               }
-       } else {
-               if (pAd->CommonCfg.Channel > 14) {
-                       TxPwr[0] = pAd->Tx20MPwrCfgABand[0];
-                       TxPwr[1] = pAd->Tx20MPwrCfgABand[1];
-                       TxPwr[2] = pAd->Tx20MPwrCfgABand[2];
-                       TxPwr[3] = pAd->Tx20MPwrCfgABand[3];
-                       TxPwr[4] = pAd->Tx20MPwrCfgABand[4];
-               } else {
-                       TxPwr[0] = pAd->Tx20MPwrCfgGBand[0];
-                       TxPwr[1] = pAd->Tx20MPwrCfgGBand[1];
-                       TxPwr[2] = pAd->Tx20MPwrCfgGBand[2];
-                       TxPwr[3] = pAd->Tx20MPwrCfgGBand[3];
-                       TxPwr[4] = pAd->Tx20MPwrCfgGBand[4];
-               }
-       }
-
-       /* TX power compensation for temperature variation based on TSSI. try every 4 second */
-       if (pAd->Mlme.OneSecPeriodicRound % 4 == 0) {
-               if (pAd->CommonCfg.Channel <= 14) {
-                       /* bg channel */
-                       bAutoTxAgc = pAd->bAutoTxAgcG;
-                       TssiRef = pAd->TssiRefG;
-                       pTssiMinusBoundary = &pAd->TssiMinusBoundaryG[0];
-                       pTssiPlusBoundary = &pAd->TssiPlusBoundaryG[0];
-                       TxAgcStep = pAd->TxAgcStepG;
-                       pTxAgcCompensate = &pAd->TxAgcCompensateG;
-               } else {
-                       /* a channel */
-                       bAutoTxAgc = pAd->bAutoTxAgcA;
-                       TssiRef = pAd->TssiRefA;
-                       pTssiMinusBoundary = &pAd->TssiMinusBoundaryA[0];
-                       pTssiPlusBoundary = &pAd->TssiPlusBoundaryA[0];
-                       TxAgcStep = pAd->TxAgcStepA;
-                       pTxAgcCompensate = &pAd->TxAgcCompensateA;
-               }
-
-               if (bAutoTxAgc) {
-                       /* BbpR1 is unsigned char */
-                       RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R49, &BbpR49);
-
-                       /* (p) TssiPlusBoundaryG[0] = 0 = (m) TssiMinusBoundaryG[0] */
-                       /* compensate: +4     +3   +2   +1    0   -1   -2   -3   -4 * steps */
-                       /* step value is defined in pAd->TxAgcStepG for tx power value */
-
-                       /* [4]+1+[4]   p4     p3   p2   p1   o1   m1   m2   m3   m4 */
-                       /* ex:         0x00 0x15 0x25 0x45 0x88 0xA0 0xB5 0xD0 0xF0
-                          above value are examined in mass factory production */
-                       /*             [4]    [3]  [2]  [1]  [0]  [1]  [2]  [3]  [4] */
-
-                       /* plus (+) is 0x00 ~ 0x45, minus (-) is 0xa0 ~ 0xf0 */
-                       /* if value is between p1 ~ o1 or o1 ~ s1, no need to adjust tx power */
-                       /* if value is 0xa5, tx power will be -= TxAgcStep*(2-1) */
-
-                       if (BbpR49 > pTssiMinusBoundary[1]) {
-                               /* Reading is larger than the reference value */
-                               /* check for how large we need to decrease the Tx power */
-                               for (idx = 1; idx < 5; idx++) {
-                                       if (BbpR49 <= pTssiMinusBoundary[idx])  /* Found the range */
-                                               break;
-                               }
-                               /* The index is the step we should decrease, idx = 0 means there is nothing to compensate */
-/*                              if (R3 > (unsigned long)(TxAgcStep * (idx-1))) */
-                               *pTxAgcCompensate = -(TxAgcStep * (idx - 1));
-/*                              else */
-/*                                      *pTxAgcCompensate = -((u8)R3); */
-
-                               DeltaPwr += (*pTxAgcCompensate);
-                               DBGPRINT(RT_DEBUG_TRACE,
-                                        ("-- Tx Power, BBP R1=%x, TssiRef=%x, TxAgcStep=%x, step = -%d\n",
-                                         BbpR49, TssiRef, TxAgcStep, idx - 1));
-                       } else if (BbpR49 < pTssiPlusBoundary[1]) {
-                               /* Reading is smaller than the reference value */
-                               /* check for how large we need to increase the Tx power */
-                               for (idx = 1; idx < 5; idx++) {
-                                       if (BbpR49 >= pTssiPlusBoundary[idx])   /* Found the range */
-                                               break;
-                               }
-                               /* The index is the step we should increase, idx = 0 means there is nothing to compensate */
-                               *pTxAgcCompensate = TxAgcStep * (idx - 1);
-                               DeltaPwr += (*pTxAgcCompensate);
-                               DBGPRINT(RT_DEBUG_TRACE,
-                                        ("++ Tx Power, BBP R1=%x, TssiRef=%x, TxAgcStep=%x, step = +%d\n",
-                                         BbpR49, TssiRef, TxAgcStep, idx - 1));
-                       } else {
-                               *pTxAgcCompensate = 0;
-                               DBGPRINT(RT_DEBUG_TRACE,
-                                        ("   Tx Power, BBP R49=%x, TssiRef=%x, TxAgcStep=%x, step = +%d\n",
-                                         BbpR49, TssiRef, TxAgcStep, 0));
-                       }
-               }
-       } else {
-               if (pAd->CommonCfg.Channel <= 14) {
-                       bAutoTxAgc = pAd->bAutoTxAgcG;
-                       pTxAgcCompensate = &pAd->TxAgcCompensateG;
-               } else {
-                       bAutoTxAgc = pAd->bAutoTxAgcA;
-                       pTxAgcCompensate = &pAd->TxAgcCompensateA;
-               }
-
-               if (bAutoTxAgc)
-                       DeltaPwr += (*pTxAgcCompensate);
-       }
-
-       RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R1, &BbpR1);
-       BbpR1 &= 0xFC;
-
-       /* calculate delta power based on the percentage specified from UI */
-       /* E2PROM setting is calibrated for maximum TX power (i.e. 100%) */
-       /* We lower TX power here according to the percentage specified from UI */
-       if (pAd->CommonCfg.TxPowerPercentage == 0xffffffff)     /* AUTO TX POWER control */
-       {
-               {
-                       /* to patch high power issue with some APs, like Belkin N1. */
-                       if (Rssi > -35) {
-                               BbpR1 |= 0x02;  /* DeltaPwr -= 12; */
-                       } else if (Rssi > -40) {
-                               BbpR1 |= 0x01;  /* DeltaPwr -= 6; */
-                       } else;
-               }
-       } else if (pAd->CommonCfg.TxPowerPercentage > 90)       /* 91 ~ 100% & AUTO, treat as 100% in terms of mW */
-               ;
-       else if (pAd->CommonCfg.TxPowerPercentage > 60) /* 61 ~ 90%, treat as 75% in terms of mW               // DeltaPwr -= 1; */
-       {
-               DeltaPwr -= 1;
-       } else if (pAd->CommonCfg.TxPowerPercentage > 30)       /* 31 ~ 60%, treat as 50% in terms of mW               // DeltaPwr -= 3; */
-       {
-               DeltaPwr -= 3;
-       } else if (pAd->CommonCfg.TxPowerPercentage > 15)       /* 16 ~ 30%, treat as 25% in terms of mW               // DeltaPwr -= 6; */
-       {
-               BbpR1 |= 0x01;
-       } else if (pAd->CommonCfg.TxPowerPercentage > 9)        /* 10 ~ 15%, treat as 12.5% in terms of mW             // DeltaPwr -= 9; */
-       {
-               BbpR1 |= 0x01;
-               DeltaPwr -= 3;
-       } else                  /* 0 ~ 9 %, treat as MIN(~3%) in terms of mW             // DeltaPwr -= 12; */
-       {
-               BbpR1 |= 0x02;
-       }
-
-       RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R1, BbpR1);
-
-       /* reset different new tx power for different TX rate */
-       for (i = 0; i < 5; i++) {
-               if (TxPwr[i] != 0xffffffff) {
-                       for (j = 0; j < 8; j++) {
-                               Value = (char)((TxPwr[i] >> j * 4) & 0x0F);     /* 0 ~ 15 */
-
-                               if ((Value + DeltaPwr) < 0) {
-                                       Value = 0;      /* min */
-                               } else if ((Value + DeltaPwr) > 0xF) {
-                                       Value = 0xF;    /* max */
-                               } else {
-                                       Value += DeltaPwr;      /* temperature compensation */
-                               }
-
-                               /* fill new value to CSR offset */
-                               TxPwr[i] =
-                                   (TxPwr[i] & ~(0x0000000F << j * 4)) | (Value
-                                                                          << j
-                                                                          * 4);
-                       }
-
-                       /* write tx power value to CSR */
-                       /* TX_PWR_CFG_0 (8 tx rate) for TX power for OFDM 12M/18M
-                          TX power for OFDM 6M/9M
-                          TX power for CCK5.5M/11M
-                          TX power for CCK1M/2M */
-                       /* TX_PWR_CFG_1 ~ TX_PWR_CFG_4 */
-                       RTMP_IO_WRITE32(pAd, TX_PWR_CFG_0 + i * 4, TxPwr[i]);
-               }
-       }
-
-}
-
-/*
-       ==========================================================================
-       Description:
-               put PHY to sleep here, and set next wakeup timer. PHY doesn't not wakeup
-               automatically. Instead, MCU will issue a TwakeUpInterrupt to host after
-               the wakeup timer timeout. Driver has to issue a separate command to wake
-               PHY up.
-
-       IRQL = DISPATCH_LEVEL
-
-       ==========================================================================
- */
-void AsicSleepThenAutoWakeup(struct rt_rtmp_adapter *pAd,
-                            u16 TbttNumToNextWakeUp)
-{
-       RTMP_STA_SLEEP_THEN_AUTO_WAKEUP(pAd, TbttNumToNextWakeUp);
-}
-
-/*
-       ==========================================================================
-       Description:
-               AsicForceWakeup() is used whenever manual wakeup is required
-               AsicForceSleep() should only be used when not in INFRA BSS. When
-               in INFRA BSS, we should use AsicSleepThenAutoWakeup() instead.
-       ==========================================================================
- */
-void AsicForceSleep(struct rt_rtmp_adapter *pAd)
-{
-
-}
-
-/*
-       ==========================================================================
-       Description:
-               AsicForceWakeup() is used whenever Twakeup timer (set via AsicSleepThenAutoWakeup)
-               expired.
-
-       IRQL = PASSIVE_LEVEL
-       IRQL = DISPATCH_LEVEL
-       ==========================================================================
- */
-void AsicForceWakeup(struct rt_rtmp_adapter *pAd, IN BOOLEAN bFromTx)
-{
-       DBGPRINT(RT_DEBUG_INFO, ("--> AsicForceWakeup \n"));
-       RTMP_STA_FORCE_WAKEUP(pAd, bFromTx);
-}
-
-/*
-       ==========================================================================
-       Description:
-               Set My BSSID
-
-       IRQL = DISPATCH_LEVEL
-
-       ==========================================================================
- */
-void AsicSetBssid(struct rt_rtmp_adapter *pAd, u8 *pBssid)
-{
-       unsigned long Addr4;
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("==============> AsicSetBssid %x:%x:%x:%x:%x:%x\n", pBssid[0],
-                 pBssid[1], pBssid[2], pBssid[3], pBssid[4], pBssid[5]));
-
-       Addr4 = (unsigned long)(pBssid[0]) |
-           (unsigned long)(pBssid[1] << 8) |
-           (unsigned long)(pBssid[2] << 16) | (unsigned long)(pBssid[3] << 24);
-       RTMP_IO_WRITE32(pAd, MAC_BSSID_DW0, Addr4);
-
-       Addr4 = 0;
-       /* always one BSSID in STA mode */
-       Addr4 = (unsigned long)(pBssid[4]) | (unsigned long)(pBssid[5] << 8);
-
-       RTMP_IO_WRITE32(pAd, MAC_BSSID_DW1, Addr4);
-}
-
-void AsicSetMcastWC(struct rt_rtmp_adapter *pAd)
-{
-       struct rt_mac_table_entry *pEntry = &pAd->MacTab.Content[MCAST_WCID];
-       u16 offset;
-
-       pEntry->Sst = SST_ASSOC;
-       pEntry->Aid = MCAST_WCID;       /* Softap supports 1 BSSID and use WCID=0 as multicast Wcid index */
-       pEntry->PsMode = PWR_ACTIVE;
-       pEntry->CurrTxRate = pAd->CommonCfg.MlmeRate;
-       offset = MAC_WCID_BASE + BSS0Mcast_WCID * HW_WCID_ENTRY_SIZE;
-}
-
-/*
-       ==========================================================================
-       Description:
-
-       IRQL = DISPATCH_LEVEL
-
-       ==========================================================================
- */
-void AsicDelWcidTab(struct rt_rtmp_adapter *pAd, u8 Wcid)
-{
-       unsigned long Addr0 = 0x0, Addr1 = 0x0;
-       unsigned long offset;
-
-       DBGPRINT(RT_DEBUG_TRACE, ("AsicDelWcidTab==>Wcid = 0x%x\n", Wcid));
-       offset = MAC_WCID_BASE + Wcid * HW_WCID_ENTRY_SIZE;
-       RTMP_IO_WRITE32(pAd, offset, Addr0);
-       offset += 4;
-       RTMP_IO_WRITE32(pAd, offset, Addr1);
-}
-
-/*
-       ==========================================================================
-       Description:
-
-       IRQL = DISPATCH_LEVEL
-
-       ==========================================================================
- */
-void AsicEnableRDG(struct rt_rtmp_adapter *pAd)
-{
-       TX_LINK_CFG_STRUC TxLinkCfg;
-       u32 Data = 0;
-
-       RTMP_IO_READ32(pAd, TX_LINK_CFG, &TxLinkCfg.word);
-       TxLinkCfg.field.TxRDGEn = 1;
-       RTMP_IO_WRITE32(pAd, TX_LINK_CFG, TxLinkCfg.word);
-
-       RTMP_IO_READ32(pAd, EDCA_AC0_CFG, &Data);
-       Data &= 0xFFFFFF00;
-       Data |= 0x80;
-       RTMP_IO_WRITE32(pAd, EDCA_AC0_CFG, Data);
-
-       /*OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_AGGREGATION_INUSED); */
-}
-
-/*
-       ==========================================================================
-       Description:
-
-       IRQL = DISPATCH_LEVEL
-
-       ==========================================================================
- */
-void AsicDisableRDG(struct rt_rtmp_adapter *pAd)
-{
-       TX_LINK_CFG_STRUC TxLinkCfg;
-       u32 Data = 0;
-
-       RTMP_IO_READ32(pAd, TX_LINK_CFG, &TxLinkCfg.word);
-       TxLinkCfg.field.TxRDGEn = 0;
-       RTMP_IO_WRITE32(pAd, TX_LINK_CFG, TxLinkCfg.word);
-
-       RTMP_IO_READ32(pAd, EDCA_AC0_CFG, &Data);
-
-       Data &= 0xFFFFFF00;
-       /*Data  |= 0x20; */
-#ifndef WIFI_TEST
-       /*if ( pAd->CommonCfg.bEnableTxBurst ) */
-       /*      Data |= 0x60; // for performance issue not set the TXOP to 0 */
-#endif
-       if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_DYNAMIC_BE_TXOP_ACTIVE)
-           && (pAd->MacTab.fAnyStationMIMOPSDynamic == FALSE)
-           ) {
-               /* For CWC test, change txop from 0x30 to 0x20 in TxBurst mode */
-               if (pAd->CommonCfg.bEnableTxBurst)
-                       Data |= 0x20;
-       }
-       RTMP_IO_WRITE32(pAd, EDCA_AC0_CFG, Data);
-}
-
-/*
-       ==========================================================================
-       Description:
-
-       IRQL = PASSIVE_LEVEL
-       IRQL = DISPATCH_LEVEL
-
-       ==========================================================================
- */
-void AsicDisableSync(struct rt_rtmp_adapter *pAd)
-{
-       BCN_TIME_CFG_STRUC csr;
-
-       DBGPRINT(RT_DEBUG_TRACE, ("--->Disable TSF synchronization\n"));
-
-       /* 2003-12-20 disable TSF and TBTT while NIC in power-saving have side effect */
-       /*                        that NIC will never wakes up because TSF stops and no more */
-       /*                        TBTT interrupts */
-       pAd->TbttTickCount = 0;
-       RTMP_IO_READ32(pAd, BCN_TIME_CFG, &csr.word);
-       csr.field.bBeaconGen = 0;
-       csr.field.bTBTTEnable = 0;
-       csr.field.TsfSyncMode = 0;
-       csr.field.bTsfTicking = 0;
-       RTMP_IO_WRITE32(pAd, BCN_TIME_CFG, csr.word);
-
-}
-
-/*
-       ==========================================================================
-       Description:
-
-       IRQL = DISPATCH_LEVEL
-
-       ==========================================================================
- */
-void AsicEnableBssSync(struct rt_rtmp_adapter *pAd)
-{
-       BCN_TIME_CFG_STRUC csr;
-
-       DBGPRINT(RT_DEBUG_TRACE, ("--->AsicEnableBssSync(INFRA mode)\n"));
-
-       RTMP_IO_READ32(pAd, BCN_TIME_CFG, &csr.word);
-/*      RTMP_IO_WRITE32(pAd, BCN_TIME_CFG, 0x00000000); */
-       {
-               csr.field.BeaconInterval = pAd->CommonCfg.BeaconPeriod << 4;    /* ASIC register in units of 1/16 TU */
-               csr.field.bTsfTicking = 1;
-               csr.field.TsfSyncMode = 1;      /* sync TSF in INFRASTRUCTURE mode */
-               csr.field.bBeaconGen = 0;       /* do NOT generate BEACON */
-               csr.field.bTBTTEnable = 1;
-       }
-       RTMP_IO_WRITE32(pAd, BCN_TIME_CFG, csr.word);
-}
-
-/*
-       ==========================================================================
-       Description:
-       Note:
-               BEACON frame in shared memory should be built ok before this routine
-               can be called. Otherwise, a garbage frame maybe transmitted out every
-               Beacon period.
-
-       IRQL = DISPATCH_LEVEL
-
-       ==========================================================================
- */
-void AsicEnableIbssSync(struct rt_rtmp_adapter *pAd)
-{
-       BCN_TIME_CFG_STRUC csr9;
-       u8 *ptr;
-       u32 i;
-
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("--->AsicEnableIbssSync(ADHOC mode. MPDUtotalByteCount = %d)\n",
-                 pAd->BeaconTxWI.MPDUtotalByteCount));
-
-       RTMP_IO_READ32(pAd, BCN_TIME_CFG, &csr9.word);
-       csr9.field.bBeaconGen = 0;
-       csr9.field.bTBTTEnable = 0;
-       csr9.field.bTsfTicking = 0;
-       RTMP_IO_WRITE32(pAd, BCN_TIME_CFG, csr9.word);
-
-#ifdef RTMP_MAC_PCI
-       /* move BEACON TXD and frame content to on-chip memory */
-       ptr = (u8 *)& pAd->BeaconTxWI;
-       for (i = 0; i < TXWI_SIZE; i += 4)      /* 16-byte TXWI field */
-       {
-               u32 longptr =
-                   *ptr + (*(ptr + 1) << 8) + (*(ptr + 2) << 16) +
-                   (*(ptr + 3) << 24);
-               RTMP_IO_WRITE32(pAd, HW_BEACON_BASE0 + i, longptr);
-               ptr += 4;
-       }
-
-       /* start right after the 16-byte TXWI field */
-       ptr = pAd->BeaconBuf;
-       for (i = 0; i < pAd->BeaconTxWI.MPDUtotalByteCount; i += 4) {
-               u32 longptr =
-                   *ptr + (*(ptr + 1) << 8) + (*(ptr + 2) << 16) +
-                   (*(ptr + 3) << 24);
-               RTMP_IO_WRITE32(pAd, HW_BEACON_BASE0 + TXWI_SIZE + i, longptr);
-               ptr += 4;
-       }
-#endif /* RTMP_MAC_PCI // */
-#ifdef RTMP_MAC_USB
-       /* move BEACON TXD and frame content to on-chip memory */
-       ptr = (u8 *)& pAd->BeaconTxWI;
-       for (i = 0; i < TXWI_SIZE; i += 2)      /* 16-byte TXWI field */
-       {
-               /*u32 longptr =  *ptr + (*(ptr+1)<<8) + (*(ptr+2)<<16) + (*(ptr+3)<<24); */
-               /*RTMP_IO_WRITE32(pAd, HW_BEACON_BASE0 + i, longptr); */
-               RTUSBMultiWrite(pAd, HW_BEACON_BASE0 + i, ptr, 2);
-               ptr += 2;
-       }
-
-       /* start right after the 16-byte TXWI field */
-       ptr = pAd->BeaconBuf;
-       for (i = 0; i < pAd->BeaconTxWI.MPDUtotalByteCount; i += 2) {
-               /*u32 longptr =  *ptr + (*(ptr+1)<<8) + (*(ptr+2)<<16) + (*(ptr+3)<<24); */
-               /*RTMP_IO_WRITE32(pAd, HW_BEACON_BASE0 + TXWI_SIZE + i, longptr); */
-               RTUSBMultiWrite(pAd, HW_BEACON_BASE0 + TXWI_SIZE + i, ptr, 2);
-               ptr += 2;
-       }
-#endif /* RTMP_MAC_USB // */
-
-       /* */
-       /* For Wi-Fi faily generated beacons between participating stations. */
-       /* Set TBTT phase adaptive adjustment step to 8us (default 16us) */
-       /* don't change settings 2006-5- by Jerry */
-       /*RTMP_IO_WRITE32(pAd, TBTT_SYNC_CFG, 0x00001010); */
-
-       /* start sending BEACON */
-       csr9.field.BeaconInterval = pAd->CommonCfg.BeaconPeriod << 4;   /* ASIC register in units of 1/16 TU */
-       csr9.field.bTsfTicking = 1;
-       csr9.field.TsfSyncMode = 2;     /* sync TSF in IBSS mode */
-       csr9.field.bTBTTEnable = 1;
-       csr9.field.bBeaconGen = 1;
-       RTMP_IO_WRITE32(pAd, BCN_TIME_CFG, csr9.word);
-}
-
-/*
-       ==========================================================================
-       Description:
-
-       IRQL = PASSIVE_LEVEL
-       IRQL = DISPATCH_LEVEL
-
-       ==========================================================================
- */
-void AsicSetEdcaParm(struct rt_rtmp_adapter *pAd, struct rt_edca_parm *pEdcaParm)
-{
-       EDCA_AC_CFG_STRUC Ac0Cfg, Ac1Cfg, Ac2Cfg, Ac3Cfg;
-       AC_TXOP_CSR0_STRUC csr0;
-       AC_TXOP_CSR1_STRUC csr1;
-       AIFSN_CSR_STRUC AifsnCsr;
-       CWMIN_CSR_STRUC CwminCsr;
-       CWMAX_CSR_STRUC CwmaxCsr;
-       int i;
-
-       Ac0Cfg.word = 0;
-       Ac1Cfg.word = 0;
-       Ac2Cfg.word = 0;
-       Ac3Cfg.word = 0;
-       if ((pEdcaParm == NULL) || (pEdcaParm->bValid == FALSE)) {
-               DBGPRINT(RT_DEBUG_TRACE, ("AsicSetEdcaParm\n"));
-               OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_WMM_INUSED);
-               for (i = 0; i < MAX_LEN_OF_MAC_TABLE; i++) {
-                       if (pAd->MacTab.Content[i].ValidAsCLI
-                           || pAd->MacTab.Content[i].ValidAsApCli)
-                               CLIENT_STATUS_CLEAR_FLAG(&pAd->MacTab.
-                                                        Content[i],
-                                                        fCLIENT_STATUS_WMM_CAPABLE);
-               }
-
-               /*======================================================== */
-               /*      MAC Register has a copy . */
-               /*======================================================== */
-/*#ifndef WIFI_TEST */
-               if (pAd->CommonCfg.bEnableTxBurst) {
-                       /* For CWC test, change txop from 0x30 to 0x20 in TxBurst mode */
-                       Ac0Cfg.field.AcTxop = 0x20;     /* Suggest by John for TxBurst in HT Mode */
-               } else
-                       Ac0Cfg.field.AcTxop = 0;        /* QID_AC_BE */
-/*#else */
-/*              Ac0Cfg.field.AcTxop = 0;        // QID_AC_BE */
-/*#endif */
-               Ac0Cfg.field.Cwmin = CW_MIN_IN_BITS;
-               Ac0Cfg.field.Cwmax = CW_MAX_IN_BITS;
-               Ac0Cfg.field.Aifsn = 2;
-               RTMP_IO_WRITE32(pAd, EDCA_AC0_CFG, Ac0Cfg.word);
-
-               Ac1Cfg.field.AcTxop = 0;        /* QID_AC_BK */
-               Ac1Cfg.field.Cwmin = CW_MIN_IN_BITS;
-               Ac1Cfg.field.Cwmax = CW_MAX_IN_BITS;
-               Ac1Cfg.field.Aifsn = 2;
-               RTMP_IO_WRITE32(pAd, EDCA_AC1_CFG, Ac1Cfg.word);
-
-               if (pAd->CommonCfg.PhyMode == PHY_11B) {
-                       Ac2Cfg.field.AcTxop = 192;      /* AC_VI: 192*32us ~= 6ms */
-                       Ac3Cfg.field.AcTxop = 96;       /* AC_VO: 96*32us  ~= 3ms */
-               } else {
-                       Ac2Cfg.field.AcTxop = 96;       /* AC_VI: 96*32us ~= 3ms */
-                       Ac3Cfg.field.AcTxop = 48;       /* AC_VO: 48*32us ~= 1.5ms */
-               }
-               Ac2Cfg.field.Cwmin = CW_MIN_IN_BITS;
-               Ac2Cfg.field.Cwmax = CW_MAX_IN_BITS;
-               Ac2Cfg.field.Aifsn = 2;
-               RTMP_IO_WRITE32(pAd, EDCA_AC2_CFG, Ac2Cfg.word);
-               Ac3Cfg.field.Cwmin = CW_MIN_IN_BITS;
-               Ac3Cfg.field.Cwmax = CW_MAX_IN_BITS;
-               Ac3Cfg.field.Aifsn = 2;
-               RTMP_IO_WRITE32(pAd, EDCA_AC3_CFG, Ac3Cfg.word);
-
-               /*======================================================== */
-               /*      DMA Register has a copy too. */
-               /*======================================================== */
-               csr0.field.Ac0Txop = 0; /* QID_AC_BE */
-               csr0.field.Ac1Txop = 0; /* QID_AC_BK */
-               RTMP_IO_WRITE32(pAd, WMM_TXOP0_CFG, csr0.word);
-               if (pAd->CommonCfg.PhyMode == PHY_11B) {
-                       csr1.field.Ac2Txop = 192;       /* AC_VI: 192*32us ~= 6ms */
-                       csr1.field.Ac3Txop = 96;        /* AC_VO: 96*32us  ~= 3ms */
-               } else {
-                       csr1.field.Ac2Txop = 96;        /* AC_VI: 96*32us ~= 3ms */
-                       csr1.field.Ac3Txop = 48;        /* AC_VO: 48*32us ~= 1.5ms */
-               }
-               RTMP_IO_WRITE32(pAd, WMM_TXOP1_CFG, csr1.word);
-
-               CwminCsr.word = 0;
-               CwminCsr.field.Cwmin0 = CW_MIN_IN_BITS;
-               CwminCsr.field.Cwmin1 = CW_MIN_IN_BITS;
-               CwminCsr.field.Cwmin2 = CW_MIN_IN_BITS;
-               CwminCsr.field.Cwmin3 = CW_MIN_IN_BITS;
-               RTMP_IO_WRITE32(pAd, WMM_CWMIN_CFG, CwminCsr.word);
-
-               CwmaxCsr.word = 0;
-               CwmaxCsr.field.Cwmax0 = CW_MAX_IN_BITS;
-               CwmaxCsr.field.Cwmax1 = CW_MAX_IN_BITS;
-               CwmaxCsr.field.Cwmax2 = CW_MAX_IN_BITS;
-               CwmaxCsr.field.Cwmax3 = CW_MAX_IN_BITS;
-               RTMP_IO_WRITE32(pAd, WMM_CWMAX_CFG, CwmaxCsr.word);
-
-               RTMP_IO_WRITE32(pAd, WMM_AIFSN_CFG, 0x00002222);
-
-               NdisZeroMemory(&pAd->CommonCfg.APEdcaParm, sizeof(struct rt_edca_parm));
-       } else {
-               OPSTATUS_SET_FLAG(pAd, fOP_STATUS_WMM_INUSED);
-               /*======================================================== */
-               /*      MAC Register has a copy. */
-               /*======================================================== */
-               /* */
-               /* Modify Cwmin/Cwmax/Txop on queue[QID_AC_VI], Recommend by Jerry 2005/07/27 */
-               /* To degrade our VIDO Queue's throughput for WiFi WMM S3T07 Issue. */
-               /* */
-               /*pEdcaParm->Txop[QID_AC_VI] = pEdcaParm->Txop[QID_AC_VI] * 7 / 10; // rt2860c need this */
-
-               Ac0Cfg.field.AcTxop = pEdcaParm->Txop[QID_AC_BE];
-               Ac0Cfg.field.Cwmin = pEdcaParm->Cwmin[QID_AC_BE];
-               Ac0Cfg.field.Cwmax = pEdcaParm->Cwmax[QID_AC_BE];
-               Ac0Cfg.field.Aifsn = pEdcaParm->Aifsn[QID_AC_BE];       /*+1; */
-
-               Ac1Cfg.field.AcTxop = pEdcaParm->Txop[QID_AC_BK];
-               Ac1Cfg.field.Cwmin = pEdcaParm->Cwmin[QID_AC_BK];       /*+2; */
-               Ac1Cfg.field.Cwmax = pEdcaParm->Cwmax[QID_AC_BK];
-               Ac1Cfg.field.Aifsn = pEdcaParm->Aifsn[QID_AC_BK];       /*+1; */
-
-               Ac2Cfg.field.AcTxop = (pEdcaParm->Txop[QID_AC_VI] * 6) / 10;
-               if (pAd->Antenna.field.TxPath == 1) {
-                       Ac2Cfg.field.Cwmin = pEdcaParm->Cwmin[QID_AC_VI] + 1;
-                       Ac2Cfg.field.Cwmax = pEdcaParm->Cwmax[QID_AC_VI] + 1;
-               } else {
-                       Ac2Cfg.field.Cwmin = pEdcaParm->Cwmin[QID_AC_VI];
-                       Ac2Cfg.field.Cwmax = pEdcaParm->Cwmax[QID_AC_VI];
-               }
-               Ac2Cfg.field.Aifsn = pEdcaParm->Aifsn[QID_AC_VI] + 1;
-#ifdef RTMP_MAC_USB
-               Ac2Cfg.field.Aifsn = pEdcaParm->Aifsn[QID_AC_VI] + 3;
-#endif /* RTMP_MAC_USB // */
-
-               {
-                       /* Tuning for Wi-Fi WMM S06 */
-                       if (pAd->CommonCfg.bWiFiTest &&
-                           pEdcaParm->Aifsn[QID_AC_VI] == 10)
-                               Ac2Cfg.field.Aifsn -= 1;
-
-                       /* Tuning for TGn Wi-Fi 5.2.32 */
-                       /* STA TestBed changes in this item: conexant legacy sta ==> broadcom 11n sta */
-                       if (STA_TGN_WIFI_ON(pAd) &&
-                           pEdcaParm->Aifsn[QID_AC_VI] == 10) {
-                               Ac0Cfg.field.Aifsn = 3;
-                               Ac2Cfg.field.AcTxop = 5;
-                       }
-#ifdef RT30xx
-                       if (pAd->RfIcType == RFIC_3020
-                           || pAd->RfIcType == RFIC_2020) {
-                               /* Tuning for WiFi WMM S3-T07: connexant legacy sta ==> broadcom 11n sta. */
-                               Ac2Cfg.field.Aifsn = 5;
-                       }
-#endif /* RT30xx // */
-               }
-
-               Ac3Cfg.field.AcTxop = pEdcaParm->Txop[QID_AC_VO];
-               Ac3Cfg.field.Cwmin = pEdcaParm->Cwmin[QID_AC_VO];
-               Ac3Cfg.field.Cwmax = pEdcaParm->Cwmax[QID_AC_VO];
-               Ac3Cfg.field.Aifsn = pEdcaParm->Aifsn[QID_AC_VO];
-
-/*#ifdef WIFI_TEST */
-               if (pAd->CommonCfg.bWiFiTest) {
-                       if (Ac3Cfg.field.AcTxop == 102) {
-                               Ac0Cfg.field.AcTxop =
-                                   pEdcaParm->Txop[QID_AC_BE] ? pEdcaParm->
-                                   Txop[QID_AC_BE] : 10;
-                               Ac0Cfg.field.Aifsn = pEdcaParm->Aifsn[QID_AC_BE] - 1;   /* AIFSN must >= 1 */
-                               Ac1Cfg.field.AcTxop =
-                                   pEdcaParm->Txop[QID_AC_BK];
-                               Ac1Cfg.field.Aifsn =
-                                   pEdcaParm->Aifsn[QID_AC_BK];
-                               Ac2Cfg.field.AcTxop =
-                                   pEdcaParm->Txop[QID_AC_VI];
-                       }       /* End of if */
-               }
-/*#endif // WIFI_TEST // */
-
-               RTMP_IO_WRITE32(pAd, EDCA_AC0_CFG, Ac0Cfg.word);
-               RTMP_IO_WRITE32(pAd, EDCA_AC1_CFG, Ac1Cfg.word);
-               RTMP_IO_WRITE32(pAd, EDCA_AC2_CFG, Ac2Cfg.word);
-               RTMP_IO_WRITE32(pAd, EDCA_AC3_CFG, Ac3Cfg.word);
-
-               /*======================================================== */
-               /*      DMA Register has a copy too. */
-               /*======================================================== */
-               csr0.field.Ac0Txop = Ac0Cfg.field.AcTxop;
-               csr0.field.Ac1Txop = Ac1Cfg.field.AcTxop;
-               RTMP_IO_WRITE32(pAd, WMM_TXOP0_CFG, csr0.word);
-
-               csr1.field.Ac2Txop = Ac2Cfg.field.AcTxop;
-               csr1.field.Ac3Txop = Ac3Cfg.field.AcTxop;
-               RTMP_IO_WRITE32(pAd, WMM_TXOP1_CFG, csr1.word);
-
-               CwminCsr.word = 0;
-               CwminCsr.field.Cwmin0 = pEdcaParm->Cwmin[QID_AC_BE];
-               CwminCsr.field.Cwmin1 = pEdcaParm->Cwmin[QID_AC_BK];
-               CwminCsr.field.Cwmin2 = pEdcaParm->Cwmin[QID_AC_VI];
-               CwminCsr.field.Cwmin3 = pEdcaParm->Cwmin[QID_AC_VO] - 1;        /*for TGn wifi test */
-               RTMP_IO_WRITE32(pAd, WMM_CWMIN_CFG, CwminCsr.word);
-
-               CwmaxCsr.word = 0;
-               CwmaxCsr.field.Cwmax0 = pEdcaParm->Cwmax[QID_AC_BE];
-               CwmaxCsr.field.Cwmax1 = pEdcaParm->Cwmax[QID_AC_BK];
-               CwmaxCsr.field.Cwmax2 = pEdcaParm->Cwmax[QID_AC_VI];
-               CwmaxCsr.field.Cwmax3 = pEdcaParm->Cwmax[QID_AC_VO];
-               RTMP_IO_WRITE32(pAd, WMM_CWMAX_CFG, CwmaxCsr.word);
-
-               AifsnCsr.word = 0;
-               AifsnCsr.field.Aifsn0 = Ac0Cfg.field.Aifsn;     /*pEdcaParm->Aifsn[QID_AC_BE]; */
-               AifsnCsr.field.Aifsn1 = Ac1Cfg.field.Aifsn;     /*pEdcaParm->Aifsn[QID_AC_BK]; */
-               AifsnCsr.field.Aifsn2 = Ac2Cfg.field.Aifsn;     /*pEdcaParm->Aifsn[QID_AC_VI]; */
-
-               {
-                       /* Tuning for Wi-Fi WMM S06 */
-                       if (pAd->CommonCfg.bWiFiTest &&
-                           pEdcaParm->Aifsn[QID_AC_VI] == 10)
-                               AifsnCsr.field.Aifsn2 = Ac2Cfg.field.Aifsn - 4;
-
-                       /* Tuning for TGn Wi-Fi 5.2.32 */
-                       /* STA TestBed changes in this item: connexant legacy sta ==> broadcom 11n sta */
-                       if (STA_TGN_WIFI_ON(pAd) &&
-                           pEdcaParm->Aifsn[QID_AC_VI] == 10) {
-                               AifsnCsr.field.Aifsn0 = 3;
-                               AifsnCsr.field.Aifsn2 = 7;
-                       }
-
-                       if (INFRA_ON(pAd))
-                               CLIENT_STATUS_SET_FLAG(&pAd->MacTab.
-                                                      Content[BSSID_WCID],
-                                                      fCLIENT_STATUS_WMM_CAPABLE);
-               }
-
-               {
-                       AifsnCsr.field.Aifsn3 = Ac3Cfg.field.Aifsn - 1; /*pEdcaParm->Aifsn[QID_AC_VO]; //for TGn wifi test */
-#ifdef RT30xx
-                       /* TODO: Shiang, this modification also suitable for RT3052/RT3050 ??? */
-                       if (pAd->RfIcType == RFIC_3020
-                           || pAd->RfIcType == RFIC_2020) {
-                               AifsnCsr.field.Aifsn2 = 0x2;    /*pEdcaParm->Aifsn[QID_AC_VI]; //for WiFi WMM S4-T04. */
-                       }
-#endif /* RT30xx // */
-               }
-               RTMP_IO_WRITE32(pAd, WMM_AIFSN_CFG, AifsnCsr.word);
-
-               NdisMoveMemory(&pAd->CommonCfg.APEdcaParm, pEdcaParm,
-                              sizeof(struct rt_edca_parm));
-               if (!ADHOC_ON(pAd)) {
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("EDCA [#%d]: AIFSN CWmin CWmax  TXOP(us)  ACM\n",
-                                 pEdcaParm->EdcaUpdateCount));
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("     AC_BE      %2d     %2d     %2d      %4d     %d\n",
-                                 pEdcaParm->Aifsn[0], pEdcaParm->Cwmin[0],
-                                 pEdcaParm->Cwmax[0], pEdcaParm->Txop[0] << 5,
-                                 pEdcaParm->bACM[0]));
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("     AC_BK      %2d     %2d     %2d      %4d     %d\n",
-                                 pEdcaParm->Aifsn[1], pEdcaParm->Cwmin[1],
-                                 pEdcaParm->Cwmax[1], pEdcaParm->Txop[1] << 5,
-                                 pEdcaParm->bACM[1]));
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("     AC_VI      %2d     %2d     %2d      %4d     %d\n",
-                                 pEdcaParm->Aifsn[2], pEdcaParm->Cwmin[2],
-                                 pEdcaParm->Cwmax[2], pEdcaParm->Txop[2] << 5,
-                                 pEdcaParm->bACM[2]));
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("     AC_VO      %2d     %2d     %2d      %4d     %d\n",
-                                 pEdcaParm->Aifsn[3], pEdcaParm->Cwmin[3],
-                                 pEdcaParm->Cwmax[3], pEdcaParm->Txop[3] << 5,
-                                 pEdcaParm->bACM[3]));
-               }
-       }
-
-}
-
-/*
-       ==========================================================================
-       Description:
-
-       IRQL = PASSIVE_LEVEL
-       IRQL = DISPATCH_LEVEL
-
-       ==========================================================================
- */
-void AsicSetSlotTime(struct rt_rtmp_adapter *pAd, IN BOOLEAN bUseShortSlotTime)
-{
-       unsigned long SlotTime;
-       u32 RegValue = 0;
-
-       if (pAd->CommonCfg.Channel > 14)
-               bUseShortSlotTime = TRUE;
-
-       if (bUseShortSlotTime
-           && OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_SHORT_SLOT_INUSED))
-               return;
-       else if ((!bUseShortSlotTime)
-                && (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_SHORT_SLOT_INUSED)))
-               return;
-
-       if (bUseShortSlotTime)
-               OPSTATUS_SET_FLAG(pAd, fOP_STATUS_SHORT_SLOT_INUSED);
-       else
-               OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_SHORT_SLOT_INUSED);
-
-       SlotTime = (bUseShortSlotTime) ? 9 : 20;
-
-       {
-               /* force using short SLOT time for FAE to demo performance when TxBurst is ON */
-               if (((pAd->StaActive.SupportedPhyInfo.bHtEnable == FALSE)
-                    && (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_WMM_INUSED)))
-                   || ((pAd->StaActive.SupportedPhyInfo.bHtEnable == TRUE)
-                       && (pAd->CommonCfg.BACapability.field.Policy ==
-                           BA_NOTUSE))
-                   ) {
-                       /* In this case, we will think it is doing Wi-Fi test */
-                       /* And we will not set to short slot when bEnableTxBurst is TRUE. */
-               } else if (pAd->CommonCfg.bEnableTxBurst) {
-                       OPSTATUS_SET_FLAG(pAd, fOP_STATUS_SHORT_SLOT_INUSED);
-                       SlotTime = 9;
-               }
-       }
-
-       /* */
-       /* For some reasons, always set it to short slot time. */
-       /* */
-       /* ToDo: Should consider capability with 11B */
-       /* */
-       {
-               if (pAd->StaCfg.BssType == BSS_ADHOC) {
-                       OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_SHORT_SLOT_INUSED);
-                       SlotTime = 20;
-               }
-       }
-
-       RTMP_IO_READ32(pAd, BKOFF_SLOT_CFG, &RegValue);
-       RegValue = RegValue & 0xFFFFFF00;
-
-       RegValue |= SlotTime;
-
-       RTMP_IO_WRITE32(pAd, BKOFF_SLOT_CFG, RegValue);
-}
-
-/*
-       ========================================================================
-       Description:
-               Add Shared key information into ASIC.
-               Update shared key, TxMic and RxMic to Asic Shared key table
-               Update its cipherAlg to Asic Shared key Mode.
-
-    Return:
-       ========================================================================
-*/
-void AsicAddSharedKeyEntry(struct rt_rtmp_adapter *pAd,
-                          u8 BssIndex,
-                          u8 KeyIdx,
-                          u8 CipherAlg,
-                          u8 *pKey, u8 *pTxMic, u8 *pRxMic)
-{
-       unsigned long offset;           /*, csr0; */
-       SHAREDKEY_MODE_STRUC csr1;
-#ifdef RTMP_MAC_PCI
-       int i;
-#endif /* RTMP_MAC_PCI // */
-
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("AsicAddSharedKeyEntry BssIndex=%d, KeyIdx=%d\n", BssIndex,
-                 KeyIdx));
-/*============================================================================================ */
-
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("AsicAddSharedKeyEntry: %s key #%d\n", CipherName[CipherAlg],
-                 BssIndex * 4 + KeyIdx));
-       DBGPRINT_RAW(RT_DEBUG_TRACE,
-                    ("         Key = %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n",
-                     pKey[0], pKey[1], pKey[2], pKey[3], pKey[4],
-                     pKey[5], pKey[6], pKey[7], pKey[8], pKey[9],
-                     pKey[10], pKey[11], pKey[12], pKey[13], pKey[14],
-                     pKey[15]));
-       if (pRxMic) {
-               DBGPRINT_RAW(RT_DEBUG_TRACE,
-                            ("         Rx MIC Key = %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n",
-                             pRxMic[0], pRxMic[1], pRxMic[2], pRxMic[3],
-                             pRxMic[4], pRxMic[5], pRxMic[6], pRxMic[7]));
-       }
-       if (pTxMic) {
-               DBGPRINT_RAW(RT_DEBUG_TRACE,
-                            ("         Tx MIC Key = %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n",
-                             pTxMic[0], pTxMic[1], pTxMic[2], pTxMic[3],
-                             pTxMic[4], pTxMic[5], pTxMic[6], pTxMic[7]));
-       }
-/*============================================================================================ */
-       /* */
-       /* fill key material - key + TX MIC + RX MIC */
-       /* */
-#ifdef RTMP_MAC_PCI
-       offset =
-           SHARED_KEY_TABLE_BASE + (4 * BssIndex + KeyIdx) * HW_KEY_ENTRY_SIZE;
-       for (i = 0; i < MAX_LEN_OF_SHARE_KEY; i++) {
-               RTMP_IO_WRITE8(pAd, offset + i, pKey[i]);
-       }
-
-       offset += MAX_LEN_OF_SHARE_KEY;
-       if (pTxMic) {
-               for (i = 0; i < 8; i++) {
-                       RTMP_IO_WRITE8(pAd, offset + i, pTxMic[i]);
-               }
-       }
-
-       offset += 8;
-       if (pRxMic) {
-               for (i = 0; i < 8; i++) {
-                       RTMP_IO_WRITE8(pAd, offset + i, pRxMic[i]);
-               }
-       }
-#endif /* RTMP_MAC_PCI // */
-#ifdef RTMP_MAC_USB
-       {
-               offset =
-                   SHARED_KEY_TABLE_BASE + (4 * BssIndex +
-                                            KeyIdx) * HW_KEY_ENTRY_SIZE;
-               RTUSBMultiWrite(pAd, offset, pKey, MAX_LEN_OF_SHARE_KEY);
-
-               offset += MAX_LEN_OF_SHARE_KEY;
-               if (pTxMic) {
-                       RTUSBMultiWrite(pAd, offset, pTxMic, 8);
-               }
-
-               offset += 8;
-               if (pRxMic) {
-                       RTUSBMultiWrite(pAd, offset, pRxMic, 8);
-               }
-       }
-#endif /* RTMP_MAC_USB // */
-
-       /* */
-       /* Update cipher algorithm. WSTA always use BSS0 */
-       /* */
-       RTMP_IO_READ32(pAd, SHARED_KEY_MODE_BASE + 4 * (BssIndex / 2),
-                      &csr1.word);
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("Read: SHARED_KEY_MODE_BASE at this Bss[%d] KeyIdx[%d]= 0x%x \n",
-                 BssIndex, KeyIdx, csr1.word));
-       if ((BssIndex % 2) == 0) {
-               if (KeyIdx == 0)
-                       csr1.field.Bss0Key0CipherAlg = CipherAlg;
-               else if (KeyIdx == 1)
-                       csr1.field.Bss0Key1CipherAlg = CipherAlg;
-               else if (KeyIdx == 2)
-                       csr1.field.Bss0Key2CipherAlg = CipherAlg;
-               else
-                       csr1.field.Bss0Key3CipherAlg = CipherAlg;
-       } else {
-               if (KeyIdx == 0)
-                       csr1.field.Bss1Key0CipherAlg = CipherAlg;
-               else if (KeyIdx == 1)
-                       csr1.field.Bss1Key1CipherAlg = CipherAlg;
-               else if (KeyIdx == 2)
-                       csr1.field.Bss1Key2CipherAlg = CipherAlg;
-               else
-                       csr1.field.Bss1Key3CipherAlg = CipherAlg;
-       }
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("Write: SHARED_KEY_MODE_BASE at this Bss[%d] = 0x%x \n",
-                 BssIndex, csr1.word));
-       RTMP_IO_WRITE32(pAd, SHARED_KEY_MODE_BASE + 4 * (BssIndex / 2),
-                       csr1.word);
-
-}
-
-/*      IRQL = DISPATCH_LEVEL */
-void AsicRemoveSharedKeyEntry(struct rt_rtmp_adapter *pAd,
-                             u8 BssIndex, u8 KeyIdx)
-{
-       /*unsigned long SecCsr0; */
-       SHAREDKEY_MODE_STRUC csr1;
-
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("AsicRemoveSharedKeyEntry: #%d \n", BssIndex * 4 + KeyIdx));
-
-       RTMP_IO_READ32(pAd, SHARED_KEY_MODE_BASE + 4 * (BssIndex / 2),
-                      &csr1.word);
-       if ((BssIndex % 2) == 0) {
-               if (KeyIdx == 0)
-                       csr1.field.Bss0Key0CipherAlg = 0;
-               else if (KeyIdx == 1)
-                       csr1.field.Bss0Key1CipherAlg = 0;
-               else if (KeyIdx == 2)
-                       csr1.field.Bss0Key2CipherAlg = 0;
-               else
-                       csr1.field.Bss0Key3CipherAlg = 0;
-       } else {
-               if (KeyIdx == 0)
-                       csr1.field.Bss1Key0CipherAlg = 0;
-               else if (KeyIdx == 1)
-                       csr1.field.Bss1Key1CipherAlg = 0;
-               else if (KeyIdx == 2)
-                       csr1.field.Bss1Key2CipherAlg = 0;
-               else
-                       csr1.field.Bss1Key3CipherAlg = 0;
-       }
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("Write: SHARED_KEY_MODE_BASE at this Bss[%d] = 0x%x \n",
-                 BssIndex, csr1.word));
-       RTMP_IO_WRITE32(pAd, SHARED_KEY_MODE_BASE + 4 * (BssIndex / 2),
-                       csr1.word);
-       ASSERT(BssIndex < 4);
-       ASSERT(KeyIdx < 4);
-
-}
-
-void AsicUpdateWCIDAttribute(struct rt_rtmp_adapter *pAd,
-                            u16 WCID,
-                            u8 BssIndex,
-                            u8 CipherAlg,
-                            IN BOOLEAN bUsePairewiseKeyTable)
-{
-       unsigned long WCIDAttri = 0, offset;
-
-       /* */
-       /* Update WCID attribute. */
-       /* Only TxKey could update WCID attribute. */
-       /* */
-       offset = MAC_WCID_ATTRIBUTE_BASE + (WCID * HW_WCID_ATTRI_SIZE);
-       WCIDAttri =
-           (BssIndex << 4) | (CipherAlg << 1) | (bUsePairewiseKeyTable);
-       RTMP_IO_WRITE32(pAd, offset, WCIDAttri);
-}
-
-void AsicUpdateWCIDIVEIV(struct rt_rtmp_adapter *pAd,
-                        u16 WCID, unsigned long uIV, unsigned long uEIV)
-{
-       unsigned long offset;
-
-       offset = MAC_IVEIV_TABLE_BASE + (WCID * HW_IVEIV_ENTRY_SIZE);
-
-       RTMP_IO_WRITE32(pAd, offset, uIV);
-       RTMP_IO_WRITE32(pAd, offset + 4, uEIV);
-}
-
-void AsicUpdateRxWCIDTable(struct rt_rtmp_adapter *pAd,
-                          u16 WCID, u8 *pAddr)
-{
-       unsigned long offset;
-       unsigned long Addr;
-
-       offset = MAC_WCID_BASE + (WCID * HW_WCID_ENTRY_SIZE);
-       Addr = pAddr[0] + (pAddr[1] << 8) + (pAddr[2] << 16) + (pAddr[3] << 24);
-       RTMP_IO_WRITE32(pAd, offset, Addr);
-       Addr = pAddr[4] + (pAddr[5] << 8);
-       RTMP_IO_WRITE32(pAd, offset + 4, Addr);
-}
-
-/*
-    ========================================================================
-
-    Routine Description:
-        Set Cipher Key, Cipher algorithm, IV/EIV to Asic
-
-    Arguments:
-        pAd                     Pointer to our adapter
-        WCID                    WCID Entry number.
-        BssIndex                BSSID index, station or none multiple BSSID support
-                                this value should be 0.
-        KeyIdx                  This KeyIdx will set to IV's KeyID if bTxKey enabled
-        pCipherKey              Pointer to Cipher Key.
-        bUsePairewiseKeyTable   TRUE means saved the key in SharedKey table,
-                                otherwise PairewiseKey table
-        bTxKey                  This is the transmit key if enabled.
-
-    Return Value:
-        None
-
-    Note:
-        This routine will set the relative key stuff to Asic including WCID attribute,
-        Cipher Key, Cipher algorithm and IV/EIV.
-
-        IV/EIV will be update if this CipherKey is the transmission key because
-        ASIC will base on IV's KeyID value to select Cipher Key.
-
-        If bTxKey sets to FALSE, this is not the TX key, but it could be
-        RX key
-
-       For AP mode bTxKey must be always set to TRUE.
-    ========================================================================
-*/
-void AsicAddKeyEntry(struct rt_rtmp_adapter *pAd,
-                    u16 WCID,
-                    u8 BssIndex,
-                    u8 KeyIdx,
-                    struct rt_cipher_key *pCipherKey,
-                    IN BOOLEAN bUsePairewiseKeyTable, IN BOOLEAN bTxKey)
-{
-       unsigned long offset;
-/*      unsigned long   WCIDAttri = 0; */
-       u8 IV4 = 0;
-       u8 *pKey = pCipherKey->Key;
-/*      unsigned long           KeyLen = pCipherKey->KeyLen; */
-       u8 *pTxMic = pCipherKey->TxMic;
-       u8 *pRxMic = pCipherKey->RxMic;
-       u8 *pTxtsc = pCipherKey->TxTsc;
-       u8 CipherAlg = pCipherKey->CipherAlg;
-       SHAREDKEY_MODE_STRUC csr1;
-#ifdef RTMP_MAC_PCI
-       u8 i;
-#endif /* RTMP_MAC_PCI // */
-
-/*      ASSERT(KeyLen <= MAX_LEN_OF_PEER_KEY); */
-
-       DBGPRINT(RT_DEBUG_TRACE, ("==> AsicAddKeyEntry\n"));
-       /* */
-       /* 1.) decide key table offset */
-       /* */
-       if (bUsePairewiseKeyTable)
-               offset = PAIRWISE_KEY_TABLE_BASE + (WCID * HW_KEY_ENTRY_SIZE);
-       else
-               offset =
-                   SHARED_KEY_TABLE_BASE + (4 * BssIndex +
-                                            KeyIdx) * HW_KEY_ENTRY_SIZE;
-
-       /* */
-       /* 2.) Set Key to Asic */
-       /* */
-       /*for (i = 0; i < KeyLen; i++) */
-#ifdef RTMP_MAC_PCI
-       for (i = 0; i < MAX_LEN_OF_PEER_KEY; i++) {
-               RTMP_IO_WRITE8(pAd, offset + i, pKey[i]);
-       }
-       offset += MAX_LEN_OF_PEER_KEY;
-
-       /* */
-       /* 3.) Set MIC key if available */
-       /* */
-       if (pTxMic) {
-               for (i = 0; i < 8; i++) {
-                       RTMP_IO_WRITE8(pAd, offset + i, pTxMic[i]);
-               }
-       }
-       offset += LEN_TKIP_TXMICK;
-
-       if (pRxMic) {
-               for (i = 0; i < 8; i++) {
-                       RTMP_IO_WRITE8(pAd, offset + i, pRxMic[i]);
-               }
-       }
-#endif /* RTMP_MAC_PCI // */
-#ifdef RTMP_MAC_USB
-       RTUSBMultiWrite(pAd, offset, pKey, MAX_LEN_OF_PEER_KEY);
-       offset += MAX_LEN_OF_PEER_KEY;
-
-       /* */
-       /* 3.) Set MIC key if available */
-       /* */
-       if (pTxMic) {
-               RTUSBMultiWrite(pAd, offset, pTxMic, 8);
-       }
-       offset += LEN_TKIP_TXMICK;
-
-       if (pRxMic) {
-               RTUSBMultiWrite(pAd, offset, pRxMic, 8);
-       }
-#endif /* RTMP_MAC_USB // */
-
-       /* */
-       /* 4.) Modify IV/EIV if needs */
-       /*     This will force Asic to use this key ID by setting IV. */
-       /* */
-       if (bTxKey) {
-#ifdef RTMP_MAC_PCI
-               offset = MAC_IVEIV_TABLE_BASE + (WCID * HW_IVEIV_ENTRY_SIZE);
-               /* */
-               /* Write IV */
-               /* */
-               RTMP_IO_WRITE8(pAd, offset, pTxtsc[1]);
-               RTMP_IO_WRITE8(pAd, offset + 1, ((pTxtsc[1] | 0x20) & 0x7f));
-               RTMP_IO_WRITE8(pAd, offset + 2, pTxtsc[0]);
-
-               IV4 = (KeyIdx << 6);
-               if ((CipherAlg == CIPHER_TKIP)
-                   || (CipherAlg == CIPHER_TKIP_NO_MIC)
-                   || (CipherAlg == CIPHER_AES))
-                       IV4 |= 0x20;    /* turn on extension bit means EIV existence */
-
-               RTMP_IO_WRITE8(pAd, offset + 3, IV4);
-
-               /* */
-               /* Write EIV */
-               /* */
-               offset += 4;
-               for (i = 0; i < 4; i++) {
-                       RTMP_IO_WRITE8(pAd, offset + i, pTxtsc[i + 2]);
-               }
-#endif /* RTMP_MAC_PCI // */
-#ifdef RTMP_MAC_USB
-               u32 tmpVal;
-
-               /* */
-               /* Write IV */
-               /* */
-               IV4 = (KeyIdx << 6);
-               if ((CipherAlg == CIPHER_TKIP)
-                   || (CipherAlg == CIPHER_TKIP_NO_MIC)
-                   || (CipherAlg == CIPHER_AES))
-                       IV4 |= 0x20;    /* turn on extension bit means EIV existence */
-
-               tmpVal =
-                   pTxtsc[1] + (((pTxtsc[1] | 0x20) & 0x7f) << 8) +
-                   (pTxtsc[0] << 16) + (IV4 << 24);
-               RTMP_IO_WRITE32(pAd, offset, tmpVal);
-
-               /* */
-               /* Write EIV */
-               /* */
-               offset += 4;
-               RTMP_IO_WRITE32(pAd, offset, *(u32 *)& pCipherKey->TxTsc[2]);
-#endif /* RTMP_MAC_USB // */
-
-               AsicUpdateWCIDAttribute(pAd, WCID, BssIndex, CipherAlg,
-                                       bUsePairewiseKeyTable);
-       }
-
-       if (!bUsePairewiseKeyTable) {
-               /* */
-               /* Only update the shared key security mode */
-               /* */
-               RTMP_IO_READ32(pAd, SHARED_KEY_MODE_BASE + 4 * (BssIndex / 2),
-                              &csr1.word);
-               if ((BssIndex % 2) == 0) {
-                       if (KeyIdx == 0)
-                               csr1.field.Bss0Key0CipherAlg = CipherAlg;
-                       else if (KeyIdx == 1)
-                               csr1.field.Bss0Key1CipherAlg = CipherAlg;
-                       else if (KeyIdx == 2)
-                               csr1.field.Bss0Key2CipherAlg = CipherAlg;
-                       else
-                               csr1.field.Bss0Key3CipherAlg = CipherAlg;
-               } else {
-                       if (KeyIdx == 0)
-                               csr1.field.Bss1Key0CipherAlg = CipherAlg;
-                       else if (KeyIdx == 1)
-                               csr1.field.Bss1Key1CipherAlg = CipherAlg;
-                       else if (KeyIdx == 2)
-                               csr1.field.Bss1Key2CipherAlg = CipherAlg;
-                       else
-                               csr1.field.Bss1Key3CipherAlg = CipherAlg;
-               }
-               RTMP_IO_WRITE32(pAd, SHARED_KEY_MODE_BASE + 4 * (BssIndex / 2),
-                               csr1.word);
-       }
-
-       DBGPRINT(RT_DEBUG_TRACE, ("<== AsicAddKeyEntry\n"));
-}
-
-/*
-       ========================================================================
-       Description:
-               Add Pair-wise key material into ASIC.
-               Update pairwise key, TxMic and RxMic to Asic Pair-wise key table
-
-    Return:
-       ========================================================================
-*/
-void AsicAddPairwiseKeyEntry(struct rt_rtmp_adapter *pAd,
-                            u8 *pAddr,
-                            u8 WCID, struct rt_cipher_key *pCipherKey)
-{
-       int i;
-       unsigned long offset;
-       u8 *pKey = pCipherKey->Key;
-       u8 *pTxMic = pCipherKey->TxMic;
-       u8 *pRxMic = pCipherKey->RxMic;
-#ifdef DBG
-       u8 CipherAlg = pCipherKey->CipherAlg;
-#endif /* DBG // */
-
-       /* EKEY */
-       offset = PAIRWISE_KEY_TABLE_BASE + (WCID * HW_KEY_ENTRY_SIZE);
-#ifdef RTMP_MAC_PCI
-       for (i = 0; i < MAX_LEN_OF_PEER_KEY; i++) {
-               RTMP_IO_WRITE8(pAd, offset + i, pKey[i]);
-       }
-#endif /* RTMP_MAC_PCI // */
-#ifdef RTMP_MAC_USB
-       RTUSBMultiWrite(pAd, offset, &pCipherKey->Key[0], MAX_LEN_OF_PEER_KEY);
-#endif /* RTMP_MAC_USB // */
-       for (i = 0; i < MAX_LEN_OF_PEER_KEY; i += 4) {
-               u32 Value;
-               RTMP_IO_READ32(pAd, offset + i, &Value);
-       }
-
-       offset += MAX_LEN_OF_PEER_KEY;
-
-       /*  MIC KEY */
-       if (pTxMic) {
-#ifdef RTMP_MAC_PCI
-               for (i = 0; i < 8; i++) {
-                       RTMP_IO_WRITE8(pAd, offset + i, pTxMic[i]);
-               }
-#endif /* RTMP_MAC_PCI // */
-#ifdef RTMP_MAC_USB
-               RTUSBMultiWrite(pAd, offset, &pCipherKey->TxMic[0], 8);
-#endif /* RTMP_MAC_USB // */
-       }
-       offset += 8;
-       if (pRxMic) {
-#ifdef RTMP_MAC_PCI
-               for (i = 0; i < 8; i++) {
-                       RTMP_IO_WRITE8(pAd, offset + i, pRxMic[i]);
-               }
-#endif /* RTMP_MAC_PCI // */
-#ifdef RTMP_MAC_USB
-               RTUSBMultiWrite(pAd, offset, &pCipherKey->RxMic[0], 8);
-#endif /* RTMP_MAC_USB // */
-       }
-
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("AsicAddPairwiseKeyEntry: WCID #%d Alg=%s\n", WCID,
-                 CipherName[CipherAlg]));
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("     Key = %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n",
-                 pKey[0], pKey[1], pKey[2], pKey[3], pKey[4], pKey[5],
-                 pKey[6], pKey[7], pKey[8], pKey[9], pKey[10], pKey[11],
-                 pKey[12], pKey[13], pKey[14], pKey[15]));
-       if (pRxMic) {
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("     Rx MIC Key = %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n",
-                         pRxMic[0], pRxMic[1], pRxMic[2], pRxMic[3],
-                         pRxMic[4], pRxMic[5], pRxMic[6], pRxMic[7]));
-       }
-       if (pTxMic) {
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("     Tx MIC Key = %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n",
-                         pTxMic[0], pTxMic[1], pTxMic[2], pTxMic[3],
-                         pTxMic[4], pTxMic[5], pTxMic[6], pTxMic[7]));
-       }
-}
-
-/*
-       ========================================================================
-       Description:
-               Remove Pair-wise key material from ASIC.
-
-    Return:
-       ========================================================================
-*/
-void AsicRemovePairwiseKeyEntry(struct rt_rtmp_adapter *pAd,
-                               u8 BssIdx, u8 Wcid)
-{
-       unsigned long WCIDAttri;
-       u16 offset;
-
-       /* re-set the entry's WCID attribute as OPEN-NONE. */
-       offset = MAC_WCID_ATTRIBUTE_BASE + (Wcid * HW_WCID_ATTRI_SIZE);
-       WCIDAttri = (BssIdx << 4) | PAIRWISEKEYTABLE;
-       RTMP_IO_WRITE32(pAd, offset, WCIDAttri);
-}
-
-BOOLEAN AsicSendCommandToMcu(struct rt_rtmp_adapter *pAd,
-                            u8 Command,
-                            u8 Token, u8 Arg0, u8 Arg1)
-{
-
-       if (pAd->chipOps.sendCommandToMcu)
-               pAd->chipOps.sendCommandToMcu(pAd, Command, Token, Arg0, Arg1);
-
-       return TRUE;
-}
-
-void AsicSetRxAnt(struct rt_rtmp_adapter *pAd, u8 Ant)
-{
-#ifdef RT30xx
-       /* RT3572 ATE need not to do this. */
-       RT30xxSetRxAnt(pAd, Ant);
-#endif /* RT30xx // */
-}
-
-void AsicTurnOffRFClk(struct rt_rtmp_adapter *pAd, u8 Channel)
-{
-       if (pAd->chipOps.AsicRfTurnOff) {
-               pAd->chipOps.AsicRfTurnOff(pAd);
-       } else {
-               /* RF R2 bit 18 = 0 */
-               u32 R1 = 0, R2 = 0, R3 = 0;
-               u8 index;
-               struct rt_rtmp_rf_regs *RFRegTable;
-
-               RFRegTable = RF2850RegTable;
-
-               switch (pAd->RfIcType) {
-               case RFIC_2820:
-               case RFIC_2850:
-               case RFIC_2720:
-               case RFIC_2750:
-
-                       for (index = 0; index < NUM_OF_2850_CHNL; index++) {
-                               if (Channel == RFRegTable[index].Channel) {
-                                       R1 = RFRegTable[index].R1 & 0xffffdfff;
-                                       R2 = RFRegTable[index].R2 & 0xfffbffff;
-                                       R3 = RFRegTable[index].R3 & 0xfff3ffff;
-
-                                       RTMP_RF_IO_WRITE32(pAd, R1);
-                                       RTMP_RF_IO_WRITE32(pAd, R2);
-
-                                       /* Program R1b13 to 1, R3/b18,19 to 0, R2b18 to 0. */
-                                       /* Set RF R2 bit18=0, R3 bit[18:19]=0 */
-                                       /*if (pAd->StaCfg.bRadio == FALSE) */
-                                       if (1) {
-                                               RTMP_RF_IO_WRITE32(pAd, R3);
-
-                                               DBGPRINT(RT_DEBUG_TRACE,
-                                                        ("AsicTurnOffRFClk#%d(RF=%d, ) , R2=0x%08x,  R3 = 0x%08x \n",
-                                                         Channel,
-                                                         pAd->RfIcType, R2,
-                                                         R3));
-                                       } else
-                                               DBGPRINT(RT_DEBUG_TRACE,
-                                                        ("AsicTurnOffRFClk#%d(RF=%d, ) , R2=0x%08x \n",
-                                                         Channel,
-                                                         pAd->RfIcType, R2));
-                                       break;
-                               }
-                       }
-                       break;
-
-               default:
-                       break;
-               }
-       }
-}
-
-void AsicTurnOnRFClk(struct rt_rtmp_adapter *pAd, u8 Channel)
-{
-       /* RF R2 bit 18 = 0 */
-       u32 R1 = 0, R2 = 0, R3 = 0;
-       u8 index;
-       struct rt_rtmp_rf_regs *RFRegTable;
-
-#ifdef PCIE_PS_SUPPORT
-       /* The RF programming sequence is difference between 3xxx and 2xxx */
-       if ((IS_RT3090(pAd) || IS_RT3572(pAd) || IS_RT3390(pAd))) {
-               return;
-       }
-#endif /* PCIE_PS_SUPPORT // */
-
-       RFRegTable = RF2850RegTable;
-
-       switch (pAd->RfIcType) {
-       case RFIC_2820:
-       case RFIC_2850:
-       case RFIC_2720:
-       case RFIC_2750:
-
-               for (index = 0; index < NUM_OF_2850_CHNL; index++) {
-                       if (Channel == RFRegTable[index].Channel) {
-                               R3 = pAd->LatchRfRegs.R3;
-                               R3 &= 0xfff3ffff;
-                               R3 |= 0x00080000;
-                               RTMP_RF_IO_WRITE32(pAd, R3);
-
-                               R1 = RFRegTable[index].R1;
-                               RTMP_RF_IO_WRITE32(pAd, R1);
-
-                               R2 = RFRegTable[index].R2;
-                               if (pAd->Antenna.field.TxPath == 1) {
-                                       R2 |= 0x4000;   /* If TXpath is 1, bit 14 = 1; */
-                               }
-
-                               if (pAd->Antenna.field.RxPath == 2) {
-                                       R2 |= 0x40;     /* write 1 to off Rxpath. */
-                               } else if (pAd->Antenna.field.RxPath == 1) {
-                                       R2 |= 0x20040;  /* write 1 to off RxPath */
-                               }
-                               RTMP_RF_IO_WRITE32(pAd, R2);
-
-                               break;
-                       }
-               }
-               break;
-
-       default:
-               break;
-       }
-
-       DBGPRINT(RT_DEBUG_TRACE, ("AsicTurnOnRFClk#%d(RF=%d, ) , R2=0x%08x\n",
-                                 Channel, pAd->RfIcType, R2));
-}
diff --git a/drivers/staging/rt2860/common/cmm_cfg.c b/drivers/staging/rt2860/common/cmm_cfg.c
deleted file mode 100644 (file)
index 727f799..0000000
+++ /dev/null
@@ -1,258 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-    Module Name:
-       cmm_cfg.c
-
-    Abstract:
-    Ralink WiFi Driver configuration related subroutines
-
-    Revision History:
-    Who          When          What
-    ---------    ----------    ----------------------------------------------
-*/
-
-#include "../rt_config.h"
-
-char *GetPhyMode(int Mode)
-{
-       switch (Mode) {
-       case MODE_CCK:
-               return "CCK";
-
-       case MODE_OFDM:
-               return "OFDM";
-       case MODE_HTMIX:
-               return "HTMIX";
-
-       case MODE_HTGREENFIELD:
-               return "GREEN";
-       default:
-               return "N/A";
-       }
-}
-
-char *GetBW(int BW)
-{
-       switch (BW) {
-       case BW_10:
-               return "10M";
-
-       case BW_20:
-               return "20M";
-       case BW_40:
-               return "40M";
-       default:
-               return "N/A";
-       }
-}
-
-/*
-    ==========================================================================
-    Description:
-        Set Country Region to pAd->CommonCfg.CountryRegion.
-        This command will not work, if the field of CountryRegion in eeprom is programmed.
-
-    Return:
-        TRUE if all parameters are OK, FALSE otherwise
-    ==========================================================================
-*/
-int RT_CfgSetCountryRegion(struct rt_rtmp_adapter *pAd, char *arg, int band)
-{
-       long region, regionMax;
-       u8 *pCountryRegion;
-
-       region = simple_strtol(arg, 0, 10);
-
-       if (band == BAND_24G) {
-               pCountryRegion = &pAd->CommonCfg.CountryRegion;
-               regionMax = REGION_MAXIMUM_BG_BAND;
-       } else {
-               pCountryRegion = &pAd->CommonCfg.CountryRegionForABand;
-               regionMax = REGION_MAXIMUM_A_BAND;
-       }
-
-       /* TODO: Is it neccesay for following check??? */
-       /* Country can be set only when EEPROM not programmed */
-       if (*pCountryRegion & 0x80) {
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("CfgSetCountryRegion():CountryRegion in eeprom was programmed\n"));
-               return FALSE;
-       }
-
-       if ((region >= 0) && (region <= REGION_MAXIMUM_BG_BAND)) {
-               *pCountryRegion = (u8)region;
-       } else if ((region == REGION_31_BG_BAND) && (band == BAND_24G)) {
-               *pCountryRegion = (u8)region;
-       } else {
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("CfgSetCountryRegion():region(%ld) out of range!\n",
-                         region));
-               return FALSE;
-       }
-
-       return TRUE;
-
-}
-
-/*
-    ==========================================================================
-    Description:
-        Set Wireless Mode
-    Return:
-        TRUE if all parameters are OK, FALSE otherwise
-    ==========================================================================
-*/
-int RT_CfgSetWirelessMode(struct rt_rtmp_adapter *pAd, char *arg)
-{
-       int MaxPhyMode = PHY_11G;
-       long WirelessMode;
-
-       MaxPhyMode = PHY_11N_5G;
-
-       WirelessMode = simple_strtol(arg, 0, 10);
-       if (WirelessMode <= MaxPhyMode) {
-               pAd->CommonCfg.PhyMode = WirelessMode;
-               return TRUE;
-       }
-
-       return FALSE;
-
-}
-
-int RT_CfgSetShortSlot(struct rt_rtmp_adapter *pAd, char *arg)
-{
-       long ShortSlot;
-
-       ShortSlot = simple_strtol(arg, 0, 10);
-
-       if (ShortSlot == 1)
-               pAd->CommonCfg.bUseShortSlotTime = TRUE;
-       else if (ShortSlot == 0)
-               pAd->CommonCfg.bUseShortSlotTime = FALSE;
-       else
-               return FALSE;   /*Invalid argument */
-
-       return TRUE;
-}
-
-/*
-    ==========================================================================
-    Description:
-        Set WEP KEY base on KeyIdx
-    Return:
-        TRUE if all parameters are OK, FALSE otherwise
-    ==========================================================================
-*/
-int RT_CfgSetWepKey(struct rt_rtmp_adapter *pAd,
-                   char *keyString,
-                   struct rt_cipher_key *pSharedKey, int keyIdx)
-{
-       int KeyLen;
-       int i;
-       u8 CipherAlg = CIPHER_NONE;
-       BOOLEAN bKeyIsHex = FALSE;
-
-       /* TODO: Shall we do memset for the original key info?? */
-       memset(pSharedKey, 0, sizeof(struct rt_cipher_key));
-       KeyLen = strlen(keyString);
-       switch (KeyLen) {
-       case 5:         /*wep 40 Ascii type */
-       case 13:                /*wep 104 Ascii type */
-               bKeyIsHex = FALSE;
-               pSharedKey->KeyLen = KeyLen;
-               NdisMoveMemory(pSharedKey->Key, keyString, KeyLen);
-               break;
-
-       case 10:                /*wep 40 Hex type */
-       case 26:                /*wep 104 Hex type */
-               for (i = 0; i < KeyLen; i++) {
-                       if (!isxdigit(*(keyString + i)))
-                               return FALSE;   /*Not Hex value; */
-               }
-               bKeyIsHex = TRUE;
-               pSharedKey->KeyLen = KeyLen / 2;
-               AtoH(keyString, pSharedKey->Key, pSharedKey->KeyLen);
-               break;
-
-       default:                /*Invalid argument */
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("RT_CfgSetWepKey(keyIdx=%d):Invalid argument (arg=%s)\n",
-                         keyIdx, keyString));
-               return FALSE;
-       }
-
-       pSharedKey->CipherAlg = ((KeyLen % 5) ? CIPHER_WEP128 : CIPHER_WEP64);
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("RT_CfgSetWepKey:(KeyIdx=%d,type=%s, Alg=%s)\n", keyIdx,
-                 (bKeyIsHex == FALSE ? "Ascii" : "Hex"),
-                 CipherName[CipherAlg]));
-
-       return TRUE;
-}
-
-/*
-    ==========================================================================
-    Description:
-        Set WPA PSK key
-
-    Arguments:
-        pAdapter       Pointer to our adapter
-        keyString      WPA pre-shared key string
-        pHashStr       String used for password hash function
-        hashStrLen     Length of the hash string
-        pPMKBuf                Output buffer of WPAPSK key
-
-    Return:
-        TRUE if all parameters are OK, FALSE otherwise
-    ==========================================================================
-*/
-int RT_CfgSetWPAPSKKey(struct rt_rtmp_adapter *pAd,
-                      char *keyString,
-                      u8 * pHashStr,
-                      int hashStrLen, u8 *pPMKBuf)
-{
-       int keyLen;
-       u8 keyMaterial[40];
-
-       keyLen = strlen(keyString);
-       if ((keyLen < 8) || (keyLen > 64)) {
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("WPAPSK Key length(%d) error, required 8 ~ 64 characters!(keyStr=%s)\n",
-                         keyLen, keyString));
-               return FALSE;
-       }
-
-       memset(pPMKBuf, 0, 32);
-       if (keyLen == 64) {
-               AtoH(keyString, pPMKBuf, 32);
-       } else {
-               PasswordHash(keyString, pHashStr, hashStrLen, keyMaterial);
-               NdisMoveMemory(pPMKBuf, keyMaterial, 32);
-       }
-
-       return TRUE;
-}
diff --git a/drivers/staging/rt2860/common/cmm_data.c b/drivers/staging/rt2860/common/cmm_data.c
deleted file mode 100644 (file)
index 33799e1..0000000
+++ /dev/null
@@ -1,2361 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-*/
-
-#include "../rt_config.h"
-
-u8 SNAP_802_1H[] = { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 };
-u8 SNAP_BRIDGE_TUNNEL[] = { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8 };
-
-/* Add Cisco Aironet SNAP heade for CCX2 support */
-u8 SNAP_AIRONET[] = { 0xaa, 0xaa, 0x03, 0x00, 0x40, 0x96, 0x00, 0x00 };
-u8 CKIP_LLC_SNAP[] = { 0xaa, 0xaa, 0x03, 0x00, 0x40, 0x96, 0x00, 0x02 };
-u8 EAPOL_LLC_SNAP[] = { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00, 0x88, 0x8e };
-u8 EAPOL[] = { 0x88, 0x8e };
-u8 TPID[] = { 0x81, 0x00 };    /* VLAN related */
-
-u8 IPX[] = { 0x81, 0x37 };
-u8 APPLE_TALK[] = { 0x80, 0xf3 };
-
-u8 RateIdToPlcpSignal[12] = {
-       0, /* RATE_1 */ 1, /* RATE_2 */ 2, /* RATE_5_5 */ 3,    /* RATE_11 *//* see BBP spec */
-       11, /* RATE_6 */ 15, /* RATE_9 */ 10, /* RATE_12 */ 14, /* RATE_18 *//* see IEEE802.11a-1999 p.14 */
-       9, /* RATE_24 */ 13, /* RATE_36 */ 8, /* RATE_48 */ 12 /* RATE_54 */
-};                             /* see IEEE802.11a-1999 p.14 */
-
-u8 OfdmSignalToRateId[16] = {
-       RATE_54, RATE_54, RATE_54, RATE_54,     /* OFDM PLCP Signal = 0,  1,  2,  3 respectively */
-       RATE_54, RATE_54, RATE_54, RATE_54,     /* OFDM PLCP Signal = 4,  5,  6,  7 respectively */
-       RATE_48, RATE_24, RATE_12, RATE_6,      /* OFDM PLCP Signal = 8,  9,  10, 11 respectively */
-       RATE_54, RATE_36, RATE_18, RATE_9,      /* OFDM PLCP Signal = 12, 13, 14, 15 respectively */
-};
-
-u8 OfdmRateToRxwiMCS[12] = {
-       0, 0, 0, 0,
-       0, 1, 2, 3,             /* OFDM rate 6,9,12,18 = rxwi mcs 0,1,2,3 */
-       4, 5, 6, 7,             /* OFDM rate 24,36,48,54 = rxwi mcs 4,5,6,7 */
-};
-
-u8 RxwiMCSToOfdmRate[12] = {
-       RATE_6, RATE_9, RATE_12, RATE_18,
-       RATE_24, RATE_36, RATE_48, RATE_54,     /* OFDM rate 6,9,12,18 = rxwi mcs 0,1,2,3 */
-       4, 5, 6, 7,             /* OFDM rate 24,36,48,54 = rxwi mcs 4,5,6,7 */
-};
-
-char *MCSToMbps[] =
-    { "1Mbps", "2Mbps", "5.5Mbps", "11Mbps", "06Mbps", "09Mbps", "12Mbps",
-"18Mbps", "24Mbps", "36Mbps", "48Mbps", "54Mbps", "MM-0", "MM-1", "MM-2", "MM-3",
-"MM-4", "MM-5", "MM-6", "MM-7", "MM-8", "MM-9", "MM-10", "MM-11", "MM-12", "MM-13",
-"MM-14", "MM-15", "MM-32", "ee1", "ee2", "ee3" };
-
-u8 default_cwmin[] =
-    { CW_MIN_IN_BITS, CW_MIN_IN_BITS, CW_MIN_IN_BITS - 1, CW_MIN_IN_BITS - 2 };
-/*u8 default_cwmax[]={CW_MAX_IN_BITS, CW_MAX_IN_BITS, CW_MIN_IN_BITS, CW_MIN_IN_BITS-1}; */
-u8 default_sta_aifsn[] = { 3, 7, 2, 2 };
-
-u8 MapUserPriorityToAccessCategory[8] =
-    { QID_AC_BE, QID_AC_BK, QID_AC_BK, QID_AC_BE, QID_AC_VI, QID_AC_VI,
-QID_AC_VO, QID_AC_VO };
-
-/*
-       ========================================================================
-
-       Routine Description:
-               API for MLME to transmit management frame to AP (BSS Mode)
-       or station (IBSS Mode)
-
-       Arguments:
-               pAd Pointer to our adapter
-               pData           Pointer to the outgoing 802.11 frame
-               Length          Size of outgoing management frame
-
-       Return Value:
-               NDIS_STATUS_FAILURE
-               NDIS_STATUS_PENDING
-               NDIS_STATUS_SUCCESS
-
-       IRQL = PASSIVE_LEVEL
-       IRQL = DISPATCH_LEVEL
-
-       Note:
-
-       ========================================================================
-*/
-int MiniportMMRequest(struct rt_rtmp_adapter *pAd,
-                             u8 QueIdx, u8 *pData, u32 Length)
-{
-       void *pPacket;
-       int Status = NDIS_STATUS_SUCCESS;
-       unsigned long FreeNum;
-       u8 rtmpHwHdr[TXINFO_SIZE + TXWI_SIZE];  /*RTMP_HW_HDR_LEN]; */
-#ifdef RTMP_MAC_PCI
-       unsigned long IrqFlags = 0;
-       u8 IrqState;
-#endif /* RTMP_MAC_PCI // */
-       BOOLEAN bUseDataQ = FALSE;
-       int retryCnt = 0;
-
-       ASSERT(Length <= MGMT_DMA_BUFFER_SIZE);
-
-       if ((QueIdx & MGMT_USE_QUEUE_FLAG) == MGMT_USE_QUEUE_FLAG) {
-               bUseDataQ = TRUE;
-               QueIdx &= (~MGMT_USE_QUEUE_FLAG);
-       }
-#ifdef RTMP_MAC_PCI
-       /* 2860C use Tx Ring */
-       IrqState = pAd->irq_disabled;
-       if (pAd->MACVersion == 0x28600100) {
-               QueIdx = (bUseDataQ == TRUE ? QueIdx : 3);
-               bUseDataQ = TRUE;
-       }
-       if (bUseDataQ && (!IrqState))
-               RTMP_IRQ_LOCK(&pAd->irq_lock, IrqFlags);
-#endif /* RTMP_MAC_PCI // */
-
-       do {
-               /* Reset is in progress, stop immediately */
-               if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS) ||
-                   RTMP_TEST_FLAG(pAd,
-                                  fRTMP_ADAPTER_HALT_IN_PROGRESS |
-                                  fRTMP_ADAPTER_NIC_NOT_EXIST)
-                   || !RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_START_UP)) {
-                       Status = NDIS_STATUS_FAILURE;
-                       break;
-               }
-               /* Check Free priority queue */
-               /* Since we use PBF Queue2 for management frame.  Its corresponding DMA ring should be using TxRing. */
-#ifdef RTMP_MAC_PCI
-               if (bUseDataQ) {
-                       retryCnt = MAX_DATAMM_RETRY;
-                       /* free Tx(QueIdx) resources */
-                       RTMPFreeTXDUponTxDmaDone(pAd, QueIdx);
-                       FreeNum = GET_TXRING_FREENO(pAd, QueIdx);
-               } else
-#endif /* RTMP_MAC_PCI // */
-               {
-                       FreeNum = GET_MGMTRING_FREENO(pAd);
-               }
-
-               if ((FreeNum > 0)) {
-                       /* We need to reserve space for rtmp hardware header. i.e., TxWI for RT2860 and TxInfo+TxWI for RT2870 */
-                       NdisZeroMemory(&rtmpHwHdr, (TXINFO_SIZE + TXWI_SIZE));
-                       Status =
-                           RTMPAllocateNdisPacket(pAd, &pPacket,
-                                                  (u8 *)& rtmpHwHdr,
-                                                  (TXINFO_SIZE + TXWI_SIZE),
-                                                  pData, Length);
-                       if (Status != NDIS_STATUS_SUCCESS) {
-                               DBGPRINT(RT_DEBUG_WARN,
-                                        ("MiniportMMRequest (error:: can't allocate NDIS PACKET)\n"));
-                               break;
-                       }
-                       /*pAd->CommonCfg.MlmeTransmit.field.MODE = MODE_CCK; */
-                       /*pAd->CommonCfg.MlmeRate = RATE_2; */
-
-#ifdef RTMP_MAC_PCI
-                       if (bUseDataQ) {
-                               Status =
-                                   MlmeDataHardTransmit(pAd, QueIdx, pPacket);
-                               retryCnt--;
-                       } else
-#endif /* RTMP_MAC_PCI // */
-                               Status = MlmeHardTransmit(pAd, QueIdx, pPacket);
-                       if (Status == NDIS_STATUS_SUCCESS)
-                               retryCnt = 0;
-                       else
-                               RTMPFreeNdisPacket(pAd, pPacket);
-               } else {
-                       pAd->RalinkCounters.MgmtRingFullCount++;
-#ifdef RTMP_MAC_PCI
-                       if (bUseDataQ) {
-                               retryCnt--;
-                               DBGPRINT(RT_DEBUG_TRACE,
-                                        ("retryCnt %d\n", retryCnt));
-                               if (retryCnt == 0) {
-                                       DBGPRINT(RT_DEBUG_ERROR,
-                                                ("Qidx(%d), not enough space in DataRing, MgmtRingFullCount=%ld!\n",
-                                                 QueIdx,
-                                                 pAd->RalinkCounters.
-                                                 MgmtRingFullCount));
-                               }
-                       }
-#endif /* RTMP_MAC_PCI // */
-                       DBGPRINT(RT_DEBUG_ERROR,
-                                ("Qidx(%d), not enough space in MgmtRing, MgmtRingFullCount=%ld!\n",
-                                 QueIdx,
-                                 pAd->RalinkCounters.MgmtRingFullCount));
-               }
-       } while (retryCnt > 0);
-
-#ifdef RTMP_MAC_PCI
-       if (bUseDataQ && (!IrqState))
-               RTMP_IRQ_UNLOCK(&pAd->irq_lock, IrqFlags);
-#endif /* RTMP_MAC_PCI // */
-
-       return Status;
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Copy frame from waiting queue into relative ring buffer and set
-       appropriate ASIC register to kick hardware transmit function
-
-       Arguments:
-               pAd Pointer to our adapter
-               pBuffer         Pointer to      memory of outgoing frame
-               Length          Size of outgoing management frame
-
-       Return Value:
-               NDIS_STATUS_FAILURE
-               NDIS_STATUS_PENDING
-               NDIS_STATUS_SUCCESS
-
-       IRQL = PASSIVE_LEVEL
-       IRQL = DISPATCH_LEVEL
-
-       Note:
-
-       ========================================================================
-*/
-int MlmeHardTransmit(struct rt_rtmp_adapter *pAd,
-                            u8 QueIdx, void *pPacket)
-{
-       struct rt_packet_info PacketInfo;
-       u8 *pSrcBufVA;
-       u32 SrcBufLen;
-       struct rt_header_802_11 * pHeader_802_11;
-
-       if ((pAd->CommonCfg.RadarDetect.RDMode != RD_NORMAL_MODE)
-           ) {
-               return NDIS_STATUS_FAILURE;
-       }
-
-       RTMP_QueryPacketInfo(pPacket, &PacketInfo, &pSrcBufVA, &SrcBufLen);
-       if (pSrcBufVA == NULL)
-               return NDIS_STATUS_FAILURE;
-
-       pHeader_802_11 = (struct rt_header_802_11 *) (pSrcBufVA + TXINFO_SIZE + TXWI_SIZE);
-
-#ifdef RTMP_MAC_PCI
-       if (pAd->MACVersion == 0x28600100)
-               return MlmeHardTransmitTxRing(pAd, QueIdx, pPacket);
-       else
-#endif /* RTMP_MAC_PCI // */
-               return MlmeHardTransmitMgmtRing(pAd, QueIdx, pPacket);
-
-}
-
-int MlmeHardTransmitMgmtRing(struct rt_rtmp_adapter *pAd,
-                                    u8 QueIdx, void *pPacket)
-{
-       struct rt_packet_info PacketInfo;
-       u8 *pSrcBufVA;
-       u32 SrcBufLen;
-       struct rt_header_802_11 * pHeader_802_11;
-       BOOLEAN bAckRequired, bInsertTimestamp;
-       u8 MlmeRate;
-       struct rt_txwi * pFirstTxWI;
-       struct rt_mac_table_entry *pMacEntry = NULL;
-       u8 PID;
-
-       RTMP_QueryPacketInfo(pPacket, &PacketInfo, &pSrcBufVA, &SrcBufLen);
-
-       /* Make sure MGMT ring resource won't be used by other threads */
-       RTMP_SEM_LOCK(&pAd->MgmtRingLock);
-       if (pSrcBufVA == NULL) {
-               /* The buffer shouldn't be NULL */
-               RTMP_SEM_UNLOCK(&pAd->MgmtRingLock);
-               return NDIS_STATUS_FAILURE;
-       }
-
-       {
-               /* outgoing frame always wakeup PHY to prevent frame lost */
-               if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))
-                       AsicForceWakeup(pAd, TRUE);
-       }
-
-       pFirstTxWI = (struct rt_txwi *) (pSrcBufVA + TXINFO_SIZE);
-       pHeader_802_11 = (struct rt_header_802_11 *) (pSrcBufVA + TXINFO_SIZE + TXWI_SIZE);     /*TXWI_SIZE); */
-
-       if (pHeader_802_11->Addr1[0] & 0x01) {
-               MlmeRate = pAd->CommonCfg.BasicMlmeRate;
-       } else {
-               MlmeRate = pAd->CommonCfg.MlmeRate;
-       }
-
-       /* Verify Mlme rate for a / g bands. */
-       if ((pAd->LatchRfRegs.Channel > 14) && (MlmeRate < RATE_6))     /* 11A band */
-               MlmeRate = RATE_6;
-
-       if ((pHeader_802_11->FC.Type == BTYPE_DATA) &&
-           (pHeader_802_11->FC.SubType == SUBTYPE_QOS_NULL)) {
-               pMacEntry = MacTableLookup(pAd, pHeader_802_11->Addr1);
-       }
-
-       {
-               /* Fixed W52 with Activity scan issue in ABG_MIXED and ABGN_MIXED mode. */
-               if (pAd->CommonCfg.PhyMode == PHY_11ABG_MIXED
-                   || pAd->CommonCfg.PhyMode == PHY_11ABGN_MIXED) {
-                       if (pAd->LatchRfRegs.Channel > 14)
-                               pAd->CommonCfg.MlmeTransmit.field.MODE = 1;
-                       else
-                               pAd->CommonCfg.MlmeTransmit.field.MODE = 0;
-               }
-       }
-
-       /* */
-       /* Should not be hard code to set PwrMgmt to 0 (PWR_ACTIVE) */
-       /* Snice it's been set to 0 while on MgtMacHeaderInit */
-       /* By the way this will cause frame to be send on PWR_SAVE failed. */
-       /* */
-       pHeader_802_11->FC.PwrMgmt = PWR_ACTIVE;        /* (pAd->StaCfg.Psm == PWR_SAVE); */
-
-       /* */
-       /* In WMM-UAPSD, mlme frame should be set psm as power saving but probe request frame */
-       /* Data-Null packets also pass through MMRequest in RT2860, however, we hope control the psm bit to pass APSD */
-/*      if ((pHeader_802_11->FC.Type != BTYPE_DATA) && (pHeader_802_11->FC.Type != BTYPE_CNTL)) */
-       {
-               if ((pHeader_802_11->FC.SubType == SUBTYPE_ACTION) ||
-                   ((pHeader_802_11->FC.Type == BTYPE_DATA) &&
-                    ((pHeader_802_11->FC.SubType == SUBTYPE_QOS_NULL) ||
-                     (pHeader_802_11->FC.SubType == SUBTYPE_NULL_FUNC)))) {
-                       if (pAd->StaCfg.Psm == PWR_SAVE)
-                               pHeader_802_11->FC.PwrMgmt = PWR_SAVE;
-                       else
-                               pHeader_802_11->FC.PwrMgmt =
-                                   pAd->CommonCfg.bAPSDForcePowerSave;
-               }
-       }
-
-       bInsertTimestamp = FALSE;
-       if (pHeader_802_11->FC.Type == BTYPE_CNTL)      /* must be PS-POLL */
-       {
-               /*Set PM bit in ps-poll, to fix WLK 1.2  PowerSaveMode_ext failure issue. */
-               if ((pAd->OpMode == OPMODE_STA)
-                   && (pHeader_802_11->FC.SubType == SUBTYPE_PS_POLL)) {
-                       pHeader_802_11->FC.PwrMgmt = PWR_SAVE;
-               }
-               bAckRequired = FALSE;
-       } else                  /* BTYPE_MGMT or BTYPE_DATA(must be NULL frame) */
-       {
-               /*pAd->Sequence++; */
-               /*pHeader_802_11->Sequence = pAd->Sequence; */
-
-               if (pHeader_802_11->Addr1[0] & 0x01)    /* MULTICAST, BROADCAST */
-               {
-                       bAckRequired = FALSE;
-                       pHeader_802_11->Duration = 0;
-               } else {
-                       bAckRequired = TRUE;
-                       pHeader_802_11->Duration =
-                           RTMPCalcDuration(pAd, MlmeRate, 14);
-                       if ((pHeader_802_11->FC.SubType == SUBTYPE_PROBE_RSP)
-                           && (pHeader_802_11->FC.Type == BTYPE_MGMT)) {
-                               bInsertTimestamp = TRUE;
-                               bAckRequired = FALSE;   /* Disable ACK to prevent retry 0x1f for Probe Response */
-                       } else
-                           if ((pHeader_802_11->FC.SubType ==
-                                SUBTYPE_PROBE_REQ)
-                               && (pHeader_802_11->FC.Type == BTYPE_MGMT)) {
-                               bAckRequired = FALSE;   /* Disable ACK to prevent retry 0x1f for Probe Request */
-                       }
-               }
-       }
-
-       pHeader_802_11->Sequence = pAd->Sequence++;
-       if (pAd->Sequence > 0xfff)
-               pAd->Sequence = 0;
-
-       /* Before radar detection done, mgmt frame can not be sent but probe req */
-       /* Because we need to use probe req to trigger driver to send probe req in passive scan */
-       if ((pHeader_802_11->FC.SubType != SUBTYPE_PROBE_REQ)
-           && (pAd->CommonCfg.bIEEE80211H == 1)
-           && (pAd->CommonCfg.RadarDetect.RDMode != RD_NORMAL_MODE)) {
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("MlmeHardTransmit --> radar detect not in normal mode!\n"));
-/*              if (!IrqState) */
-               RTMP_SEM_UNLOCK(&pAd->MgmtRingLock);
-               return (NDIS_STATUS_FAILURE);
-       }
-
-       /* */
-       /* fill scatter-and-gather buffer list into TXD. Internally created NDIS PACKET */
-       /* should always has only one physical buffer, and the whole frame size equals */
-       /* to the first scatter buffer size */
-       /* */
-
-       /* Initialize TX Descriptor */
-       /* For inter-frame gap, the number is for this frame and next frame */
-       /* For MLME rate, we will fix as 2Mb to match other vendor's implement */
-/*      pAd->CommonCfg.MlmeTransmit.field.MODE = 1; */
-
-/* management frame doesn't need encryption. so use RESERVED_WCID no matter u are sending to specific wcid or not. */
-       PID = PID_MGMT;
-
-       if (pMacEntry == NULL) {
-               RTMPWriteTxWI(pAd, pFirstTxWI, FALSE, FALSE, bInsertTimestamp,
-                             FALSE, bAckRequired, FALSE, 0, RESERVED_WCID,
-                             (SrcBufLen - TXINFO_SIZE - TXWI_SIZE), PID, 0,
-                             (u8)pAd->CommonCfg.MlmeTransmit.field.MCS,
-                             IFS_BACKOFF, FALSE, &pAd->CommonCfg.MlmeTransmit);
-       } else {
-               /* dont use low rate to send QoS Null data frame */
-               RTMPWriteTxWI(pAd, pFirstTxWI, FALSE, FALSE,
-                             bInsertTimestamp, FALSE, bAckRequired, FALSE,
-                             0, pMacEntry->Aid,
-                             (SrcBufLen - TXINFO_SIZE - TXWI_SIZE),
-                             pMacEntry->MaxHTPhyMode.field.MCS, 0,
-                             (u8)pMacEntry->MaxHTPhyMode.field.MCS,
-                             IFS_BACKOFF, FALSE, &pMacEntry->MaxHTPhyMode);
-       }
-
-       /* Now do hardware-depened kick out. */
-       HAL_KickOutMgmtTx(pAd, QueIdx, pPacket, pSrcBufVA, SrcBufLen);
-
-       /* Make sure to release MGMT ring resource */
-/*      if (!IrqState) */
-       RTMP_SEM_UNLOCK(&pAd->MgmtRingLock);
-       return NDIS_STATUS_SUCCESS;
-}
-
-/********************************************************************************
-
-       New DeQueue Procedures.
-
- ********************************************************************************/
-
-#define DEQUEUE_LOCK(lock, bIntContext, IrqFlags)                              \
-                       do{                                                                                                     \
-                               if (bIntContext == FALSE)                                               \
-                               RTMP_IRQ_LOCK((lock), IrqFlags);                \
-                       }while(0)
-
-#define DEQUEUE_UNLOCK(lock, bIntContext, IrqFlags)                            \
-                       do{                                                                                                     \
-                               if (bIntContext == FALSE)                                               \
-                                       RTMP_IRQ_UNLOCK((lock), IrqFlags);      \
-                       }while(0)
-
-/*
-       ========================================================================
-       Tx Path design algorithm:
-               Basically, we divide the packets into four types, Broadcast/Multicast, 11N Rate(AMPDU, AMSDU, Normal), B/G Rate(ARALINK, Normal),
-               Specific Packet Type. Following show the classification rule and policy for each kinds of packets.
-                               Classification Rule=>
-                                       Multicast: (*addr1 & 0x01) == 0x01
-                                       Specific : bDHCPFrame, bARPFrame, bEAPOLFrame, etc.
-                                       11N Rate : If peer support HT
-                                                               (1).AMPDU  -- If TXBA is negotiated.
-                                                               (2).AMSDU  -- If AMSDU is capable for both peer and ourself.
-                                                                                       *). AMSDU can embedded in a AMPDU, but now we didn't support it.
-                                                               (3).Normal -- Other packets which send as 11n rate.
-
-                                       B/G Rate : If peer is b/g only.
-                                                               (1).ARALINK-- If both of peer/us supprot Ralink proprietary Aggregation and the TxRate is large than RATE_6
-                                                               (2).Normal -- Other packets which send as b/g rate.
-                                       Fragment:
-                                                               The packet must be unicast, NOT A-RALINK, NOT A-MSDU, NOT 11n, then can consider about fragment.
-
-                               Classified Packet Handle Rule=>
-                                       Multicast:
-                                                               No ACK,                 //pTxBlk->bAckRequired = FALSE;
-                                                               No WMM,                 //pTxBlk->bWMM = FALSE;
-                                                               No piggyback,   //pTxBlk->bPiggyBack = FALSE;
-                                                               Force LowRate,  //pTxBlk->bForceLowRate = TRUE;
-                                       Specific :      Basically, for specific packet, we should handle it specifically, but now all specific packets are use
-                                                                       the same policy to handle it.
-                                                               Force LowRate,  //pTxBlk->bForceLowRate = TRUE;
-
-                                       11N Rate :
-                                                               No piggyback,   //pTxBlk->bPiggyBack = FALSE;
-
-                                                               (1).AMSDU
-                                                                       pTxBlk->bWMM = TRUE;
-                                                               (2).AMPDU
-                                                                       pTxBlk->bWMM = TRUE;
-                                                               (3).Normal
-
-                                       B/G Rate :
-                                                               (1).ARALINK
-
-                                                               (2).Normal
-       ========================================================================
-*/
-static u8 TxPktClassification(struct rt_rtmp_adapter *pAd, void *pPacket)
-{
-       u8 TxFrameType = TX_UNKOWN_FRAME;
-       u8 Wcid;
-       struct rt_mac_table_entry *pMacEntry = NULL;
-       BOOLEAN bHTRate = FALSE;
-
-       Wcid = RTMP_GET_PACKET_WCID(pPacket);
-       if (Wcid == MCAST_WCID) {       /* Handle for RA is Broadcast/Multicast Address. */
-               return TX_MCAST_FRAME;
-       }
-       /* Handle for unicast packets */
-       pMacEntry = &pAd->MacTab.Content[Wcid];
-       if (RTMP_GET_PACKET_LOWRATE(pPacket)) { /* It's a specific packet need to force low rate, i.e., bDHCPFrame, bEAPOLFrame, bWAIFrame */
-               TxFrameType = TX_LEGACY_FRAME;
-       } else if (IS_HT_RATE(pMacEntry)) {     /* it's a 11n capable packet */
-
-               /* Depends on HTPhyMode to check if the peer support the HTRate transmission. */
-               /*      Currently didn't support A-MSDU embedded in A-MPDU */
-               bHTRate = TRUE;
-               if (RTMP_GET_PACKET_MOREDATA(pPacket)
-                   || (pMacEntry->PsMode == PWR_SAVE))
-                       TxFrameType = TX_LEGACY_FRAME;
-               else if ((pMacEntry->
-                         TXBAbitmap & (1 << (RTMP_GET_PACKET_UP(pPacket)))) !=
-                        0)
-                       return TX_AMPDU_FRAME;
-               else if (CLIENT_STATUS_TEST_FLAG
-                        (pMacEntry, fCLIENT_STATUS_AMSDU_INUSED))
-                       return TX_AMSDU_FRAME;
-               else
-                       TxFrameType = TX_LEGACY_FRAME;
-       } else {                /* it's a legacy b/g packet. */
-               if ((CLIENT_STATUS_TEST_FLAG(pMacEntry, fCLIENT_STATUS_AGGREGATION_CAPABLE) && pAd->CommonCfg.bAggregationCapable) && (RTMP_GET_PACKET_TXRATE(pPacket) >= RATE_6) && (!(OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_WMM_INUSED) && CLIENT_STATUS_TEST_FLAG(pMacEntry, fCLIENT_STATUS_WMM_CAPABLE)))) {   /* if peer support Ralink Aggregation, we use it. */
-                       TxFrameType = TX_RALINK_FRAME;
-               } else {
-                       TxFrameType = TX_LEGACY_FRAME;
-               }
-       }
-
-       /* Currently, our fragment only support when a unicast packet send as NOT-ARALINK, NOT-AMSDU and NOT-AMPDU. */
-       if ((RTMP_GET_PACKET_FRAGMENTS(pPacket) > 1)
-           && (TxFrameType == TX_LEGACY_FRAME))
-               TxFrameType = TX_FRAG_FRAME;
-
-       return TxFrameType;
-}
-
-BOOLEAN RTMP_FillTxBlkInfo(struct rt_rtmp_adapter *pAd, struct rt_tx_blk *pTxBlk)
-{
-       struct rt_packet_info PacketInfo;
-       void *pPacket;
-       struct rt_mac_table_entry *pMacEntry = NULL;
-
-       pPacket = pTxBlk->pPacket;
-       RTMP_QueryPacketInfo(pPacket, &PacketInfo, &pTxBlk->pSrcBufHeader,
-                            &pTxBlk->SrcBufLen);
-
-       pTxBlk->Wcid = RTMP_GET_PACKET_WCID(pPacket);
-       pTxBlk->apidx = RTMP_GET_PACKET_IF(pPacket);
-       pTxBlk->UserPriority = RTMP_GET_PACKET_UP(pPacket);
-       pTxBlk->FrameGap = IFS_HTTXOP;  /* ASIC determine Frame Gap */
-
-       if (RTMP_GET_PACKET_CLEAR_EAP_FRAME(pTxBlk->pPacket))
-               TX_BLK_SET_FLAG(pTxBlk, fTX_bClearEAPFrame);
-       else
-               TX_BLK_CLEAR_FLAG(pTxBlk, fTX_bClearEAPFrame);
-
-       /* Default to clear this flag */
-       TX_BLK_CLEAR_FLAG(pTxBlk, fTX_bForceNonQoS);
-
-       if (pTxBlk->Wcid == MCAST_WCID) {
-               pTxBlk->pMacEntry = NULL;
-               {
-                       pTxBlk->pTransmit =
-                           &pAd->MacTab.Content[MCAST_WCID].HTPhyMode;
-               }
-
-               TX_BLK_CLEAR_FLAG(pTxBlk, fTX_bAckRequired);    /* AckRequired = FALSE, when broadcast packet in Adhoc mode. */
-               /*TX_BLK_SET_FLAG(pTxBlk, fTX_bForceLowRate); */
-               TX_BLK_CLEAR_FLAG(pTxBlk, fTX_bAllowFrag);
-               TX_BLK_CLEAR_FLAG(pTxBlk, fTX_bWMM);
-               if (RTMP_GET_PACKET_MOREDATA(pPacket)) {
-                       TX_BLK_SET_FLAG(pTxBlk, fTX_bMoreData);
-               }
-
-       } else {
-               pTxBlk->pMacEntry = &pAd->MacTab.Content[pTxBlk->Wcid];
-               pTxBlk->pTransmit = &pTxBlk->pMacEntry->HTPhyMode;
-
-               pMacEntry = pTxBlk->pMacEntry;
-
-               /* For all unicast packets, need Ack unless the Ack Policy is not set as NORMAL_ACK. */
-               if (pAd->CommonCfg.AckPolicy[pTxBlk->QueIdx] != NORMAL_ACK)
-                       TX_BLK_CLEAR_FLAG(pTxBlk, fTX_bAckRequired);
-               else
-                       TX_BLK_SET_FLAG(pTxBlk, fTX_bAckRequired);
-
-               if ((pAd->OpMode == OPMODE_STA) &&
-                   (ADHOC_ON(pAd)) &&
-                   (RX_FILTER_TEST_FLAG(pAd, fRX_FILTER_ACCEPT_PROMISCUOUS))) {
-                       if (pAd->CommonCfg.PSPXlink)
-                               TX_BLK_CLEAR_FLAG(pTxBlk, fTX_bAckRequired);
-               }
-
-               {
-                       {
-
-                               /* If support WMM, enable it. */
-                               if (OPSTATUS_TEST_FLAG
-                                   (pAd, fOP_STATUS_WMM_INUSED)
-                                   && CLIENT_STATUS_TEST_FLAG(pMacEntry,
-                                                              fCLIENT_STATUS_WMM_CAPABLE))
-                                       TX_BLK_SET_FLAG(pTxBlk, fTX_bWMM);
-
-/*                              if (pAd->StaCfg.bAutoTxRateSwitch) */
-/*                                      TX_BLK_SET_FLAG(pTxBlk, fTX_AutoRateSwitch); */
-                       }
-               }
-
-               if (pTxBlk->TxFrameType == TX_LEGACY_FRAME) {
-                       if ((RTMP_GET_PACKET_LOWRATE(pPacket)) || ((pAd->OpMode == OPMODE_AP) && (pMacEntry->MaxHTPhyMode.field.MODE == MODE_CCK) && (pMacEntry->MaxHTPhyMode.field.MCS == RATE_1))) {  /* Specific packet, i.e., bDHCPFrame, bEAPOLFrame, bWAIFrame, need force low rate. */
-                               pTxBlk->pTransmit =
-                                   &pAd->MacTab.Content[MCAST_WCID].HTPhyMode;
-
-                               /* Modify the WMM bit for ICV issue. If we have a packet with EOSP field need to set as 1, how to handle it??? */
-                               if (IS_HT_STA(pTxBlk->pMacEntry) &&
-                                   (CLIENT_STATUS_TEST_FLAG
-                                    (pMacEntry, fCLIENT_STATUS_RALINK_CHIPSET))
-                                   && ((pAd->CommonCfg.bRdg == TRUE)
-                                       && CLIENT_STATUS_TEST_FLAG(pMacEntry,
-                                                                  fCLIENT_STATUS_RDG_CAPABLE)))
-                               {
-                                       TX_BLK_CLEAR_FLAG(pTxBlk, fTX_bWMM);
-                                       TX_BLK_SET_FLAG(pTxBlk,
-                                                       fTX_bForceNonQoS);
-                               }
-                       }
-
-                       if ((IS_HT_RATE(pMacEntry) == FALSE) && (CLIENT_STATUS_TEST_FLAG(pMacEntry, fCLIENT_STATUS_PIGGYBACK_CAPABLE))) {       /* Currently piggy-back only support when peer is operate in b/g mode. */
-                               TX_BLK_SET_FLAG(pTxBlk, fTX_bPiggyBack);
-                       }
-
-                       if (RTMP_GET_PACKET_MOREDATA(pPacket)) {
-                               TX_BLK_SET_FLAG(pTxBlk, fTX_bMoreData);
-                       }
-               } else if (pTxBlk->TxFrameType == TX_FRAG_FRAME) {
-                       TX_BLK_SET_FLAG(pTxBlk, fTX_bAllowFrag);
-               }
-
-               pMacEntry->DebugTxCount++;
-       }
-
-       return TRUE;
-}
-
-BOOLEAN CanDoAggregateTransmit(struct rt_rtmp_adapter *pAd,
-                              char * pPacket, struct rt_tx_blk *pTxBlk)
-{
-
-       /*DBGPRINT(RT_DEBUG_TRACE, ("Check if can do aggregation! TxFrameType=%d!\n", pTxBlk->TxFrameType)); */
-
-       if (RTMP_GET_PACKET_WCID(pPacket) == MCAST_WCID)
-               return FALSE;
-
-       if (RTMP_GET_PACKET_DHCP(pPacket) ||
-           RTMP_GET_PACKET_EAPOL(pPacket) || RTMP_GET_PACKET_WAI(pPacket))
-               return FALSE;
-
-       if ((pTxBlk->TxFrameType == TX_AMSDU_FRAME) && ((pTxBlk->TotalFrameLen + GET_OS_PKT_LEN(pPacket)) > (RX_BUFFER_AGGRESIZE - 100))) {     /* For AMSDU, allow the packets with total length < max-amsdu size */
-               return FALSE;
-       }
-
-       if ((pTxBlk->TxFrameType == TX_RALINK_FRAME) && (pTxBlk->TxPacketList.Number == 2)) {   /* For RALINK-Aggregation, allow two frames in one batch. */
-               return FALSE;
-       }
-
-       if ((INFRA_ON(pAd)) && (pAd->OpMode == OPMODE_STA))     /* must be unicast to AP */
-               return TRUE;
-       else
-               return FALSE;
-
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               To do the enqueue operation and extract the first item of waiting
-               list. If a number of available shared memory segments could meet
-               the request of extracted item, the extracted item will be fragmented
-               into shared memory segments.
-
-       Arguments:
-               pAd Pointer to our adapter
-               pQueue          Pointer to Waiting Queue
-
-       Return Value:
-               None
-
-       IRQL = DISPATCH_LEVEL
-
-       Note:
-
-       ========================================================================
-*/
-void RTMPDeQueuePacket(struct rt_rtmp_adapter *pAd, IN BOOLEAN bIntContext, u8 QIdx,   /* BulkOutPipeId */
-                      u8 Max_Tx_Packets)
-{
-       struct rt_queue_entry *pEntry = NULL;
-       void *pPacket;
-       int Status = NDIS_STATUS_SUCCESS;
-       u8 Count = 0;
-       struct rt_queue_header *pQueue;
-       unsigned long FreeNumber[NUM_OF_TX_RING];
-       u8 QueIdx, sQIdx, eQIdx;
-       unsigned long IrqFlags = 0;
-       BOOLEAN hasTxDesc = FALSE;
-       struct rt_tx_blk TxBlk;
-       struct rt_tx_blk *pTxBlk;
-
-       if (QIdx == NUM_OF_TX_RING) {
-               sQIdx = 0;
-               eQIdx = 3;      /* 4 ACs, start from 0. */
-       } else {
-               sQIdx = eQIdx = QIdx;
-       }
-
-       for (QueIdx = sQIdx; QueIdx <= eQIdx; QueIdx++) {
-               Count = 0;
-
-               RTMP_START_DEQUEUE(pAd, QueIdx, IrqFlags);
-
-               while (1) {
-                       if ((RTMP_TEST_FLAG
-                            (pAd,
-                             (fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS |
-                              fRTMP_ADAPTER_RADIO_OFF |
-                              fRTMP_ADAPTER_RESET_IN_PROGRESS |
-                              fRTMP_ADAPTER_HALT_IN_PROGRESS |
-                              fRTMP_ADAPTER_NIC_NOT_EXIST)))) {
-                               RTMP_STOP_DEQUEUE(pAd, QueIdx, IrqFlags);
-                               return;
-                       }
-
-                       if (Count >= Max_Tx_Packets)
-                               break;
-
-                       DEQUEUE_LOCK(&pAd->irq_lock, bIntContext, IrqFlags);
-                       if (&pAd->TxSwQueue[QueIdx] == NULL) {
-                               DEQUEUE_UNLOCK(&pAd->irq_lock, bIntContext,
-                                              IrqFlags);
-                               break;
-                       }
-#ifdef RTMP_MAC_PCI
-                       FreeNumber[QueIdx] = GET_TXRING_FREENO(pAd, QueIdx);
-
-                       if (FreeNumber[QueIdx] <= 5) {
-                               /* free Tx(QueIdx) resources */
-                               RTMPFreeTXDUponTxDmaDone(pAd, QueIdx);
-                               FreeNumber[QueIdx] =
-                                   GET_TXRING_FREENO(pAd, QueIdx);
-                       }
-#endif /* RTMP_MAC_PCI // */
-
-                       /* probe the Queue Head */
-                       pQueue = &pAd->TxSwQueue[QueIdx];
-                       pEntry = pQueue->Head;
-                       if (pEntry == NULL) {
-                               DEQUEUE_UNLOCK(&pAd->irq_lock, bIntContext,
-                                              IrqFlags);
-                               break;
-                       }
-
-                       pTxBlk = &TxBlk;
-                       NdisZeroMemory((u8 *)pTxBlk, sizeof(struct rt_tx_blk));
-                       /*InitializeQueueHeader(&pTxBlk->TxPacketList);         // Didn't need it because we already memzero it. */
-                       pTxBlk->QueIdx = QueIdx;
-
-                       pPacket = QUEUE_ENTRY_TO_PACKET(pEntry);
-
-                       /* Early check to make sure we have enoguh Tx Resource. */
-                       hasTxDesc =
-                           RTMP_HAS_ENOUGH_FREE_DESC(pAd, pTxBlk,
-                                                     FreeNumber[QueIdx],
-                                                     pPacket);
-                       if (!hasTxDesc) {
-                               pAd->PrivateInfo.TxRingFullCnt++;
-
-                               DEQUEUE_UNLOCK(&pAd->irq_lock, bIntContext,
-                                              IrqFlags);
-
-                               break;
-                       }
-
-                       pTxBlk->TxFrameType = TxPktClassification(pAd, pPacket);
-                       pEntry = RemoveHeadQueue(pQueue);
-                       pTxBlk->TotalFrameNum++;
-                       pTxBlk->TotalFragNum += RTMP_GET_PACKET_FRAGMENTS(pPacket);     /* The real fragment number maybe vary */
-                       pTxBlk->TotalFrameLen += GET_OS_PKT_LEN(pPacket);
-                       pTxBlk->pPacket = pPacket;
-                       InsertTailQueue(&pTxBlk->TxPacketList,
-                                       PACKET_TO_QUEUE_ENTRY(pPacket));
-
-                       if (pTxBlk->TxFrameType == TX_RALINK_FRAME
-                           || pTxBlk->TxFrameType == TX_AMSDU_FRAME) {
-                               /* Enhance SW Aggregation Mechanism */
-                               if (NEED_QUEUE_BACK_FOR_AGG
-                                   (pAd, QueIdx, FreeNumber[QueIdx],
-                                    pTxBlk->TxFrameType)) {
-                                       InsertHeadQueue(pQueue,
-                                                       PACKET_TO_QUEUE_ENTRY
-                                                       (pPacket));
-                                       DEQUEUE_UNLOCK(&pAd->irq_lock,
-                                                      bIntContext, IrqFlags);
-                                       break;
-                               }
-
-                               do {
-                                       pEntry = pQueue->Head;
-                                       if (pEntry == NULL)
-                                               break;
-
-                                       /* For TX_AMSDU_FRAME/TX_RALINK_FRAME, Need to check if next pakcet can do aggregation. */
-                                       pPacket = QUEUE_ENTRY_TO_PACKET(pEntry);
-                                       FreeNumber[QueIdx] =
-                                           GET_TXRING_FREENO(pAd, QueIdx);
-                                       hasTxDesc =
-                                           RTMP_HAS_ENOUGH_FREE_DESC(pAd,
-                                                                     pTxBlk,
-                                                                     FreeNumber
-                                                                     [QueIdx],
-                                                                     pPacket);
-                                       if ((hasTxDesc == FALSE)
-                                           ||
-                                           (CanDoAggregateTransmit
-                                            (pAd, pPacket, pTxBlk) == FALSE))
-                                               break;
-
-                                       /*Remove the packet from the TxSwQueue and insert into pTxBlk */
-                                       pEntry = RemoveHeadQueue(pQueue);
-                                       ASSERT(pEntry);
-                                       pPacket = QUEUE_ENTRY_TO_PACKET(pEntry);
-                                       pTxBlk->TotalFrameNum++;
-                                       pTxBlk->TotalFragNum += RTMP_GET_PACKET_FRAGMENTS(pPacket);     /* The real fragment number maybe vary */
-                                       pTxBlk->TotalFrameLen +=
-                                           GET_OS_PKT_LEN(pPacket);
-                                       InsertTailQueue(&pTxBlk->TxPacketList,
-                                                       PACKET_TO_QUEUE_ENTRY
-                                                       (pPacket));
-                               } while (1);
-
-                               if (pTxBlk->TxPacketList.Number == 1)
-                                       pTxBlk->TxFrameType = TX_LEGACY_FRAME;
-                       }
-#ifdef RTMP_MAC_USB
-                       DEQUEUE_UNLOCK(&pAd->irq_lock, bIntContext, IrqFlags);
-#endif /* RTMP_MAC_USB // */
-                       Count += pTxBlk->TxPacketList.Number;
-
-                       /* Do HardTransmit now. */
-                       Status = STAHardTransmit(pAd, pTxBlk, QueIdx);
-
-#ifdef RTMP_MAC_PCI
-                       DEQUEUE_UNLOCK(&pAd->irq_lock, bIntContext, IrqFlags);
-                       /* static rate also need NICUpdateFifoStaCounters() function. */
-                       /*if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_TX_RATE_SWITCH_ENABLED)) */
-                       NICUpdateFifoStaCounters(pAd);
-#endif /* RTMP_MAC_PCI // */
-
-               }
-
-               RTMP_STOP_DEQUEUE(pAd, QueIdx, IrqFlags);
-
-#ifdef RTMP_MAC_USB
-               if (!hasTxDesc)
-                       RTUSBKickBulkOut(pAd);
-#endif /* RTMP_MAC_USB // */
-       }
-
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Calculates the duration which is required to transmit out frames
-       with given size and specified rate.
-
-       Arguments:
-               pAd     Pointer to our adapter
-               Rate                    Transmit rate
-               Size                    Frame size in units of byte
-
-       Return Value:
-               Duration number in units of usec
-
-       IRQL = PASSIVE_LEVEL
-       IRQL = DISPATCH_LEVEL
-
-       Note:
-
-       ========================================================================
-*/
-u16 RTMPCalcDuration(struct rt_rtmp_adapter *pAd, u8 Rate, unsigned long Size)
-{
-       unsigned long Duration = 0;
-
-       if (Rate < RATE_FIRST_OFDM_RATE)        /* CCK */
-       {
-               if ((Rate > RATE_1)
-                   && OPSTATUS_TEST_FLAG(pAd,
-                                         fOP_STATUS_SHORT_PREAMBLE_INUSED))
-                       Duration = 96;  /* 72+24 preamble+plcp */
-               else
-                       Duration = 192; /* 144+48 preamble+plcp */
-
-               Duration += (u16)((Size << 4) / RateIdTo500Kbps[Rate]);
-               if ((Size << 4) % RateIdTo500Kbps[Rate])
-                       Duration++;
-       } else if (Rate <= RATE_LAST_OFDM_RATE) /* OFDM rates */
-       {
-               Duration = 20 + 6;      /* 16+4 preamble+plcp + Signal Extension */
-               Duration +=
-                   4 * (u16)((11 + Size * 4) / RateIdTo500Kbps[Rate]);
-               if ((11 + Size * 4) % RateIdTo500Kbps[Rate])
-                       Duration += 4;
-       } else                  /*mimo rate */
-       {
-               Duration = 20 + 6;      /* 16+4 preamble+plcp + Signal Extension */
-       }
-
-       return (u16)Duration;
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Calculates the duration which is required to transmit out frames
-       with given size and specified rate.
-
-       Arguments:
-               pTxWI           Pointer to head of each MPDU to HW.
-               Ack             Setting for Ack requirement bit
-               Fragment        Setting for Fragment bit
-               RetryMode       Setting for retry mode
-               Ifs             Setting for IFS gap
-               Rate            Setting for transmit rate
-               Service         Setting for service
-               Length          Frame length
-               TxPreamble      Short or Long preamble when using CCK rates
-               QueIdx - 0-3, according to 802.11e/d4.4 June/2003
-
-       Return Value:
-               None
-
-       IRQL = PASSIVE_LEVEL
-       IRQL = DISPATCH_LEVEL
-
-    See also : BASmartHardTransmit()    !
-
-       ========================================================================
-*/
-void RTMPWriteTxWI(struct rt_rtmp_adapter *pAd, struct rt_txwi * pOutTxWI, IN BOOLEAN FRAG, IN BOOLEAN CFACK, IN BOOLEAN InsTimestamp, IN BOOLEAN AMPDU, IN BOOLEAN Ack, IN BOOLEAN NSeq,      /* HW new a sequence. */
-                  u8 BASize,
-                  u8 WCID,
-                  unsigned long Length,
-                  u8 PID,
-                  u8 TID,
-                  u8 TxRate,
-                  u8 Txopmode,
-                  IN BOOLEAN CfAck, IN HTTRANSMIT_SETTING * pTransmit)
-{
-       struct rt_mac_table_entry *pMac = NULL;
-       struct rt_txwi TxWI;
-       struct rt_txwi * pTxWI;
-
-       if (WCID < MAX_LEN_OF_MAC_TABLE)
-               pMac = &pAd->MacTab.Content[WCID];
-
-       /* */
-       /* Always use Long preamble before verifiation short preamble functionality works well. */
-       /* Todo: remove the following line if short preamble functionality works */
-       /* */
-       OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_SHORT_PREAMBLE_INUSED);
-       NdisZeroMemory(&TxWI, TXWI_SIZE);
-       pTxWI = &TxWI;
-
-       pTxWI->FRAG = FRAG;
-
-       pTxWI->CFACK = CFACK;
-       pTxWI->TS = InsTimestamp;
-       pTxWI->AMPDU = AMPDU;
-       pTxWI->ACK = Ack;
-       pTxWI->txop = Txopmode;
-
-       pTxWI->NSEQ = NSeq;
-       /* John tune the performace with Intel Client in 20 MHz performance */
-       BASize = pAd->CommonCfg.TxBASize;
-       if (pAd->MACVersion == 0x28720200) {
-               if (BASize > 13)
-                       BASize = 13;
-       } else {
-               if (BASize > 7)
-                       BASize = 7;
-       }
-       pTxWI->BAWinSize = BASize;
-       pTxWI->ShortGI = pTransmit->field.ShortGI;
-       pTxWI->STBC = pTransmit->field.STBC;
-
-       pTxWI->WirelessCliID = WCID;
-       pTxWI->MPDUtotalByteCount = Length;
-       pTxWI->PacketId = PID;
-
-       /* If CCK or OFDM, BW must be 20 */
-       pTxWI->BW =
-           (pTransmit->field.MODE <=
-            MODE_OFDM) ? (BW_20) : (pTransmit->field.BW);
-
-       pTxWI->MCS = pTransmit->field.MCS;
-       pTxWI->PHYMODE = pTransmit->field.MODE;
-       pTxWI->CFACK = CfAck;
-
-       if (pMac) {
-               if (pAd->CommonCfg.bMIMOPSEnable) {
-                       if ((pMac->MmpsMode == MMPS_DYNAMIC)
-                           && (pTransmit->field.MCS > 7)) {
-                               /* Dynamic MIMO Power Save Mode */
-                               pTxWI->MIMOps = 1;
-                       } else if (pMac->MmpsMode == MMPS_STATIC) {
-                               /* Static MIMO Power Save Mode */
-                               if (pTransmit->field.MODE >= MODE_HTMIX
-                                   && pTransmit->field.MCS > 7) {
-                                       pTxWI->MCS = 7;
-                                       pTxWI->MIMOps = 0;
-                               }
-                       }
-               }
-               /*pTxWI->MIMOps = (pMac->PsMode == PWR_MMPS)? 1:0; */
-               if (pMac->bIAmBadAtheros
-                   && (pMac->WepStatus != Ndis802_11WEPDisabled)) {
-                       pTxWI->MpduDensity = 7;
-               } else {
-                       pTxWI->MpduDensity = pMac->MpduDensity;
-               }
-       }
-
-       pTxWI->PacketId = pTxWI->MCS;
-       NdisMoveMemory(pOutTxWI, &TxWI, sizeof(struct rt_txwi));
-}
-
-void RTMPWriteTxWI_Data(struct rt_rtmp_adapter *pAd,
-                       struct rt_txwi * pTxWI, struct rt_tx_blk *pTxBlk)
-{
-       HTTRANSMIT_SETTING *pTransmit;
-       struct rt_mac_table_entry *pMacEntry;
-       u8 BASize;
-
-       ASSERT(pTxWI);
-
-       pTransmit = pTxBlk->pTransmit;
-       pMacEntry = pTxBlk->pMacEntry;
-
-       /* */
-       /* Always use Long preamble before verifiation short preamble functionality works well. */
-       /* Todo: remove the following line if short preamble functionality works */
-       /* */
-       OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_SHORT_PREAMBLE_INUSED);
-       NdisZeroMemory(pTxWI, TXWI_SIZE);
-
-       pTxWI->FRAG = TX_BLK_TEST_FLAG(pTxBlk, fTX_bAllowFrag);
-       pTxWI->ACK = TX_BLK_TEST_FLAG(pTxBlk, fTX_bAckRequired);
-       pTxWI->txop = pTxBlk->FrameGap;
-
-       pTxWI->WirelessCliID = pTxBlk->Wcid;
-
-       pTxWI->MPDUtotalByteCount = pTxBlk->MpduHeaderLen + pTxBlk->SrcBufLen;
-       pTxWI->CFACK = TX_BLK_TEST_FLAG(pTxBlk, fTX_bPiggyBack);
-
-       /* If CCK or OFDM, BW must be 20 */
-       pTxWI->BW =
-           (pTransmit->field.MODE <=
-            MODE_OFDM) ? (BW_20) : (pTransmit->field.BW);
-       pTxWI->AMPDU = ((pTxBlk->TxFrameType == TX_AMPDU_FRAME) ? TRUE : FALSE);
-
-       /* John tune the performace with Intel Client in 20 MHz performance */
-       BASize = pAd->CommonCfg.TxBASize;
-       if ((pTxBlk->TxFrameType == TX_AMPDU_FRAME) && (pMacEntry)) {
-               u8 RABAOriIdx = 0;      /*The RA's BA Originator table index. */
-
-               RABAOriIdx =
-                   pTxBlk->pMacEntry->BAOriWcidArray[pTxBlk->UserPriority];
-               BASize = pAd->BATable.BAOriEntry[RABAOriIdx].BAWinSize;
-       }
-
-       pTxWI->TxBF = pTransmit->field.TxBF;
-       pTxWI->BAWinSize = BASize;
-       pTxWI->ShortGI = pTransmit->field.ShortGI;
-       pTxWI->STBC = pTransmit->field.STBC;
-
-       pTxWI->MCS = pTransmit->field.MCS;
-       pTxWI->PHYMODE = pTransmit->field.MODE;
-
-       if (pMacEntry) {
-               if ((pMacEntry->MmpsMode == MMPS_DYNAMIC)
-                   && (pTransmit->field.MCS > 7)) {
-                       /* Dynamic MIMO Power Save Mode */
-                       pTxWI->MIMOps = 1;
-               } else if (pMacEntry->MmpsMode == MMPS_STATIC) {
-                       /* Static MIMO Power Save Mode */
-                       if (pTransmit->field.MODE >= MODE_HTMIX
-                           && pTransmit->field.MCS > 7) {
-                               pTxWI->MCS = 7;
-                               pTxWI->MIMOps = 0;
-                       }
-               }
-
-               if (pMacEntry->bIAmBadAtheros
-                   && (pMacEntry->WepStatus != Ndis802_11WEPDisabled)) {
-                       pTxWI->MpduDensity = 7;
-               } else {
-                       pTxWI->MpduDensity = pMacEntry->MpduDensity;
-               }
-       }
-
-       /* for rate adapation */
-       pTxWI->PacketId = pTxWI->MCS;
-}
-
-void RTMPWriteTxWI_Cache(struct rt_rtmp_adapter *pAd,
-                        struct rt_txwi * pTxWI, struct rt_tx_blk *pTxBlk)
-{
-       PHTTRANSMIT_SETTING /*pTxHTPhyMode, */ pTransmit;
-       struct rt_mac_table_entry *pMacEntry;
-
-       /* */
-       /* update TXWI */
-       /* */
-       pMacEntry = pTxBlk->pMacEntry;
-       pTransmit = pTxBlk->pTransmit;
-
-       /*if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_TX_RATE_SWITCH_ENABLED)) */
-       /*if (RTMPCheckEntryEnableAutoRateSwitch(pAd, pMacEntry)) */
-       /*if (TX_BLK_TEST_FLAG(pTxBlk, fTX_AutoRateSwitch)) */
-       if (pMacEntry->bAutoTxRateSwitch) {
-               pTxWI->txop = IFS_HTTXOP;
-
-               /* If CCK or OFDM, BW must be 20 */
-               pTxWI->BW =
-                   (pTransmit->field.MODE <=
-                    MODE_OFDM) ? (BW_20) : (pTransmit->field.BW);
-               pTxWI->ShortGI = pTransmit->field.ShortGI;
-               pTxWI->STBC = pTransmit->field.STBC;
-
-               pTxWI->MCS = pTransmit->field.MCS;
-               pTxWI->PHYMODE = pTransmit->field.MODE;
-
-               /* set PID for TxRateSwitching */
-               pTxWI->PacketId = pTransmit->field.MCS;
-       }
-
-       pTxWI->AMPDU = ((pMacEntry->NoBADataCountDown == 0) ? TRUE : FALSE);
-       pTxWI->MIMOps = 0;
-
-       if (pAd->CommonCfg.bMIMOPSEnable) {
-               /* MIMO Power Save Mode */
-               if ((pMacEntry->MmpsMode == MMPS_DYNAMIC)
-                   && (pTransmit->field.MCS > 7)) {
-                       /* Dynamic MIMO Power Save Mode */
-                       pTxWI->MIMOps = 1;
-               } else if (pMacEntry->MmpsMode == MMPS_STATIC) {
-                       /* Static MIMO Power Save Mode */
-                       if ((pTransmit->field.MODE >= MODE_HTMIX)
-                           && (pTransmit->field.MCS > 7)) {
-                               pTxWI->MCS = 7;
-                               pTxWI->MIMOps = 0;
-                       }
-               }
-       }
-
-       pTxWI->MPDUtotalByteCount = pTxBlk->MpduHeaderLen + pTxBlk->SrcBufLen;
-
-}
-
-/* should be called only when - */
-/* 1. MEADIA_CONNECTED */
-/* 2. AGGREGATION_IN_USED */
-/* 3. Fragmentation not in used */
-/* 4. either no previous frame (pPrevAddr1=NULL) .OR. previoud frame is aggregatible */
-BOOLEAN TxFrameIsAggregatible(struct rt_rtmp_adapter *pAd,
-                             u8 *pPrevAddr1, u8 *p8023hdr)
-{
-
-       /* can't aggregate EAPOL (802.1x) frame */
-       if ((p8023hdr[12] == 0x88) && (p8023hdr[13] == 0x8e))
-               return FALSE;
-
-       /* can't aggregate multicast/broadcast frame */
-       if (p8023hdr[0] & 0x01)
-               return FALSE;
-
-       if (INFRA_ON(pAd))      /* must be unicast to AP */
-               return TRUE;
-       else if ((pPrevAddr1 == NULL) || MAC_ADDR_EQUAL(pPrevAddr1, p8023hdr))  /* unicast to same STA */
-               return TRUE;
-       else
-               return FALSE;
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-          Check the MSDU Aggregation policy
-       1.HT aggregation is A-MSDU
-       2.legaacy rate aggregation is software aggregation by Ralink.
-
-       Arguments:
-
-       Return Value:
-
-       Note:
-
-       ========================================================================
-*/
-BOOLEAN PeerIsAggreOn(struct rt_rtmp_adapter *pAd,
-                     unsigned long TxRate, struct rt_mac_table_entry *pMacEntry)
-{
-       unsigned long AFlags =
-           (fCLIENT_STATUS_AMSDU_INUSED | fCLIENT_STATUS_AGGREGATION_CAPABLE);
-
-       if (pMacEntry != NULL && CLIENT_STATUS_TEST_FLAG(pMacEntry, AFlags)) {
-               if (pMacEntry->HTPhyMode.field.MODE >= MODE_HTMIX) {
-                       return TRUE;
-               }
-#ifdef AGGREGATION_SUPPORT
-               if (TxRate >= RATE_6 && pAd->CommonCfg.bAggregationCapable && (!(OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_WMM_INUSED) && CLIENT_STATUS_TEST_FLAG(pMacEntry, fCLIENT_STATUS_WMM_CAPABLE)))) {  /* legacy  Ralink Aggregation support */
-                       return TRUE;
-               }
-#endif /* AGGREGATION_SUPPORT // */
-       }
-
-       return FALSE;
-
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Check and fine the packet waiting in SW queue with highest priority
-
-       Arguments:
-               pAd Pointer to our adapter
-
-       Return Value:
-               pQueue          Pointer to Waiting Queue
-
-       IRQL = DISPATCH_LEVEL
-
-       Note:
-
-       ========================================================================
-*/
-struct rt_queue_header *RTMPCheckTxSwQueue(struct rt_rtmp_adapter *pAd, u8 *pQueIdx)
-{
-
-       unsigned long Number;
-       /* 2004-11-15 to be removed. test aggregation only */
-/*      if ((OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_AGGREGATION_INUSED)) && (*pNumber < 2)) */
-/*               return NULL; */
-
-       Number = pAd->TxSwQueue[QID_AC_BK].Number
-           + pAd->TxSwQueue[QID_AC_BE].Number
-           + pAd->TxSwQueue[QID_AC_VI].Number
-           + pAd->TxSwQueue[QID_AC_VO].Number;
-
-       if (pAd->TxSwQueue[QID_AC_VO].Head != NULL) {
-               *pQueIdx = QID_AC_VO;
-               return (&pAd->TxSwQueue[QID_AC_VO]);
-       } else if (pAd->TxSwQueue[QID_AC_VI].Head != NULL) {
-               *pQueIdx = QID_AC_VI;
-               return (&pAd->TxSwQueue[QID_AC_VI]);
-       } else if (pAd->TxSwQueue[QID_AC_BE].Head != NULL) {
-               *pQueIdx = QID_AC_BE;
-               return (&pAd->TxSwQueue[QID_AC_BE]);
-       } else if (pAd->TxSwQueue[QID_AC_BK].Head != NULL) {
-               *pQueIdx = QID_AC_BK;
-               return (&pAd->TxSwQueue[QID_AC_BK]);
-       }
-       /* No packet pending in Tx Sw queue */
-       *pQueIdx = QID_AC_BK;
-
-       return (NULL);
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Suspend MSDU transmission
-
-       Arguments:
-               pAd     Pointer to our adapter
-
-       Return Value:
-               None
-
-       Note:
-
-       ========================================================================
-*/
-void RTMPSuspendMsduTransmission(struct rt_rtmp_adapter *pAd)
-{
-       DBGPRINT(RT_DEBUG_TRACE, ("SCANNING, suspend MSDU transmission ...\n"));
-
-       /* */
-       /* Before BSS_SCAN_IN_PROGRESS, we need to keep Current R66 value and */
-       /* use Lowbound as R66 value on ScanNextChannel(...) */
-       /* */
-       RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R66,
-                                   &pAd->BbpTuning.R66CurrentValue);
-
-       /* set BBP_R66 to 0x30/0x40 when scanning (AsicSwitchChannel will set R66 according to channel when scanning) */
-       /*RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66, (0x26 + GET_LNA_GAIN(pAd))); */
-       RTMPSetAGCInitValue(pAd, BW_20);
-
-       RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS);
-       /*RTMP_IO_WRITE32(pAd, TX_CNTL_CSR, 0x000f0000);                // abort all TX rings */
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Resume MSDU transmission
-
-       Arguments:
-               pAd     Pointer to our adapter
-
-       Return Value:
-               None
-
-       IRQL = DISPATCH_LEVEL
-
-       Note:
-
-       ========================================================================
-*/
-void RTMPResumeMsduTransmission(struct rt_rtmp_adapter *pAd)
-{
-/*    u8                     IrqState; */
-
-       DBGPRINT(RT_DEBUG_TRACE, ("SCAN done, resume MSDU transmission ...\n"));
-
-       /* After finish BSS_SCAN_IN_PROGRESS, we need to restore Current R66 value */
-       /* R66 should not be 0 */
-       if (pAd->BbpTuning.R66CurrentValue == 0) {
-               pAd->BbpTuning.R66CurrentValue = 0x38;
-               DBGPRINT_ERR("RTMPResumeMsduTransmission, R66CurrentValue=0...\n");
-       }
-
-       RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66,
-                                    pAd->BbpTuning.R66CurrentValue);
-
-       RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS);
-/* sample, for IRQ LOCK to SEM LOCK */
-/*    IrqState = pAd->irq_disabled; */
-/*      if (IrqState) */
-/*              RTMPDeQueuePacket(pAd, TRUE, NUM_OF_TX_RING, MAX_TX_PROCESS); */
-/*    else */
-       RTMPDeQueuePacket(pAd, FALSE, NUM_OF_TX_RING, MAX_TX_PROCESS);
-}
-
-u32 deaggregate_AMSDU_announce(struct rt_rtmp_adapter *pAd,
-                               void *pPacket,
-                               u8 *pData, unsigned long DataSize)
-{
-       u16 PayloadSize;
-       u16 SubFrameSize;
-       struct rt_header_802_3 * pAMSDUsubheader;
-       u32 nMSDU;
-       u8 Header802_3[14];
-
-       u8 *pPayload, *pDA, *pSA, *pRemovedLLCSNAP;
-       void *pClonePacket;
-
-       nMSDU = 0;
-
-       while (DataSize > LENGTH_802_3) {
-
-               nMSDU++;
-
-               /*hex_dump("subheader", pData, 64); */
-               pAMSDUsubheader = (struct rt_header_802_3 *) pData;
-               /*pData += LENGTH_802_3; */
-               PayloadSize =
-                   pAMSDUsubheader->Octet[1] +
-                   (pAMSDUsubheader->Octet[0] << 8);
-               SubFrameSize = PayloadSize + LENGTH_802_3;
-
-               if ((DataSize < SubFrameSize) || (PayloadSize > 1518)) {
-                       break;
-               }
-               /*DBGPRINT(RT_DEBUG_TRACE,("%d subframe: Size = %d\n",  nMSDU, PayloadSize)); */
-
-               pPayload = pData + LENGTH_802_3;
-               pDA = pData;
-               pSA = pData + MAC_ADDR_LEN;
-
-               /* convert to 802.3 header */
-               CONVERT_TO_802_3(Header802_3, pDA, pSA, pPayload, PayloadSize,
-                                pRemovedLLCSNAP);
-
-               if ((Header802_3[12] == 0x88) && (Header802_3[13] == 0x8E)) {
-                       /* avoid local heap overflow, use dyanamic allocation */
-                       struct rt_mlme_queue_elem *Elem =
-                           kmalloc(sizeof(struct rt_mlme_queue_elem),
-                                                       MEM_ALLOC_FLAG);
-                       if (Elem != NULL) {
-                               memmove(Elem->Msg +
-                                       (LENGTH_802_11 + LENGTH_802_1_H),
-                                       pPayload, PayloadSize);
-                               Elem->MsgLen =
-                                   LENGTH_802_11 + LENGTH_802_1_H +
-                                   PayloadSize;
-                               /*WpaEAPOLKeyAction(pAd, Elem); */
-                               REPORT_MGMT_FRAME_TO_MLME(pAd, BSSID_WCID,
-                                                         Elem->Msg,
-                                                         Elem->MsgLen, 0, 0, 0,
-                                                         0);
-                               kfree(Elem);
-                       }
-               }
-
-               {
-                       if (pRemovedLLCSNAP) {
-                               pPayload -= LENGTH_802_3;
-                               PayloadSize += LENGTH_802_3;
-                               NdisMoveMemory(pPayload, &Header802_3[0],
-                                              LENGTH_802_3);
-                       }
-               }
-
-               pClonePacket = ClonePacket(pAd, pPacket, pPayload, PayloadSize);
-               if (pClonePacket) {
-                       ANNOUNCE_OR_FORWARD_802_3_PACKET(pAd, pClonePacket,
-                                                        RTMP_GET_PACKET_IF
-                                                        (pPacket));
-               }
-
-               /* A-MSDU has padding to multiple of 4 including subframe header. */
-               /* align SubFrameSize up to multiple of 4 */
-               SubFrameSize = (SubFrameSize + 3) & (~0x3);
-
-               if (SubFrameSize > 1528 || SubFrameSize < 32) {
-                       break;
-               }
-
-               if (DataSize > SubFrameSize) {
-                       pData += SubFrameSize;
-                       DataSize -= SubFrameSize;
-               } else {
-                       /* end of A-MSDU */
-                       DataSize = 0;
-               }
-       }
-
-       /* finally release original rx packet */
-       RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_SUCCESS);
-
-       return nMSDU;
-}
-
-u32 BA_Reorder_AMSDU_Announce(struct rt_rtmp_adapter *pAd, void *pPacket)
-{
-       u8 *pData;
-       u16 DataSize;
-       u32 nMSDU = 0;
-
-       pData = (u8 *)GET_OS_PKT_DATAPTR(pPacket);
-       DataSize = (u16)GET_OS_PKT_LEN(pPacket);
-
-       nMSDU = deaggregate_AMSDU_announce(pAd, pPacket, pData, DataSize);
-
-       return nMSDU;
-}
-
-/*
-       ==========================================================================
-       Description:
-               Look up the MAC address in the MAC table. Return NULL if not found.
-       Return:
-               pEntry - pointer to the MAC entry; NULL is not found
-       ==========================================================================
-*/
-struct rt_mac_table_entry *MacTableLookup(struct rt_rtmp_adapter *pAd, u8 *pAddr)
-{
-       unsigned long HashIdx;
-       struct rt_mac_table_entry *pEntry = NULL;
-
-       HashIdx = MAC_ADDR_HASH_INDEX(pAddr);
-       pEntry = pAd->MacTab.Hash[HashIdx];
-
-       while (pEntry
-              && (pEntry->ValidAsCLI || pEntry->ValidAsWDS
-                  || pEntry->ValidAsApCli || pEntry->ValidAsMesh)) {
-               if (MAC_ADDR_EQUAL(pEntry->Addr, pAddr)) {
-                       break;
-               } else
-                       pEntry = pEntry->pNext;
-       }
-
-       return pEntry;
-}
-
-struct rt_mac_table_entry *MacTableInsertEntry(struct rt_rtmp_adapter *pAd,
-                                    u8 *pAddr,
-                                    u8 apidx, IN BOOLEAN CleanAll)
-{
-       u8 HashIdx;
-       int i, FirstWcid;
-       struct rt_mac_table_entry *pEntry = NULL, *pCurrEntry;
-/*      u16  offset; */
-/*      unsigned long   addr; */
-
-       /* if FULL, return */
-       if (pAd->MacTab.Size >= MAX_LEN_OF_MAC_TABLE)
-               return NULL;
-
-       FirstWcid = 1;
-
-       if (pAd->StaCfg.BssType == BSS_INFRA)
-               FirstWcid = 2;
-
-       /* allocate one MAC entry */
-       NdisAcquireSpinLock(&pAd->MacTabLock);
-       for (i = FirstWcid; i < MAX_LEN_OF_MAC_TABLE; i++)      /* skip entry#0 so that "entry index == AID" for fast lookup */
-       {
-               /* pick up the first available vacancy */
-               if ((pAd->MacTab.Content[i].ValidAsCLI == FALSE) &&
-                   (pAd->MacTab.Content[i].ValidAsWDS == FALSE) &&
-                   (pAd->MacTab.Content[i].ValidAsApCli == FALSE) &&
-                   (pAd->MacTab.Content[i].ValidAsMesh == FALSE)
-                   ) {
-                       pEntry = &pAd->MacTab.Content[i];
-                       if (CleanAll == TRUE) {
-                               pEntry->MaxSupportedRate = RATE_11;
-                               pEntry->CurrTxRate = RATE_11;
-                               NdisZeroMemory(pEntry, sizeof(struct rt_mac_table_entry));
-                               pEntry->PairwiseKey.KeyLen = 0;
-                               pEntry->PairwiseKey.CipherAlg = CIPHER_NONE;
-                       }
-                       {
-                               {
-                                       pEntry->ValidAsCLI = TRUE;
-                                       pEntry->ValidAsWDS = FALSE;
-                                       pEntry->ValidAsApCli = FALSE;
-                                       pEntry->ValidAsMesh = FALSE;
-                                       pEntry->ValidAsDls = FALSE;
-                               }
-                       }
-
-                       pEntry->bIAmBadAtheros = FALSE;
-                       pEntry->pAd = pAd;
-                       pEntry->CMTimerRunning = FALSE;
-                       pEntry->EnqueueEapolStartTimerRunning =
-                           EAPOL_START_DISABLE;
-                       pEntry->RSNIE_Len = 0;
-                       NdisZeroMemory(pEntry->R_Counter,
-                                      sizeof(pEntry->R_Counter));
-                       pEntry->ReTryCounter = PEER_MSG1_RETRY_TIMER_CTR;
-
-                       if (pEntry->ValidAsMesh)
-                               pEntry->apidx =
-                                   (apidx - MIN_NET_DEVICE_FOR_MESH);
-                       else if (pEntry->ValidAsApCli)
-                               pEntry->apidx =
-                                   (apidx - MIN_NET_DEVICE_FOR_APCLI);
-                       else if (pEntry->ValidAsWDS)
-                               pEntry->apidx =
-                                   (apidx - MIN_NET_DEVICE_FOR_WDS);
-                       else
-                               pEntry->apidx = apidx;
-
-                       {
-                               {
-                                       pEntry->AuthMode = pAd->StaCfg.AuthMode;
-                                       pEntry->WepStatus =
-                                           pAd->StaCfg.WepStatus;
-                                       pEntry->PrivacyFilter =
-                                           Ndis802_11PrivFilterAcceptAll;
-#ifdef RTMP_MAC_PCI
-                                       AsicRemovePairwiseKeyEntry(pAd,
-                                                                  pEntry->
-                                                                  apidx,
-                                                                  (u8)i);
-#endif /* RTMP_MAC_PCI // */
-                               }
-                       }
-
-                       pEntry->GTKState = REKEY_NEGOTIATING;
-                       pEntry->PairwiseKey.KeyLen = 0;
-                       pEntry->PairwiseKey.CipherAlg = CIPHER_NONE;
-                       pEntry->PortSecured = WPA_802_1X_PORT_NOT_SECURED;
-
-                       pEntry->PMKID_CacheIdx = ENTRY_NOT_FOUND;
-                       COPY_MAC_ADDR(pEntry->Addr, pAddr);
-                       pEntry->Sst = SST_NOT_AUTH;
-                       pEntry->AuthState = AS_NOT_AUTH;
-                       pEntry->Aid = (u16)i;   /*0; */
-                       pEntry->CapabilityInfo = 0;
-                       pEntry->PsMode = PWR_ACTIVE;
-                       pEntry->PsQIdleCount = 0;
-                       pEntry->NoDataIdleCount = 0;
-                       pEntry->AssocDeadLine = MAC_TABLE_ASSOC_TIMEOUT;
-                       pEntry->ContinueTxFailCnt = 0;
-                       InitializeQueueHeader(&pEntry->PsQueue);
-
-                       pAd->MacTab.Size++;
-                       /* Add this entry into ASIC RX WCID search table */
-                       RTMP_STA_ENTRY_ADD(pAd, pEntry);
-
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("MacTableInsertEntry - allocate entry #%d, Total= %d\n",
-                                 i, pAd->MacTab.Size));
-                       break;
-               }
-       }
-
-       /* add this MAC entry into HASH table */
-       if (pEntry) {
-               HashIdx = MAC_ADDR_HASH_INDEX(pAddr);
-               if (pAd->MacTab.Hash[HashIdx] == NULL) {
-                       pAd->MacTab.Hash[HashIdx] = pEntry;
-               } else {
-                       pCurrEntry = pAd->MacTab.Hash[HashIdx];
-                       while (pCurrEntry->pNext != NULL)
-                               pCurrEntry = pCurrEntry->pNext;
-                       pCurrEntry->pNext = pEntry;
-               }
-       }
-
-       NdisReleaseSpinLock(&pAd->MacTabLock);
-       return pEntry;
-}
-
-/*
-       ==========================================================================
-       Description:
-               Delete a specified client from MAC table
-       ==========================================================================
- */
-BOOLEAN MacTableDeleteEntry(struct rt_rtmp_adapter *pAd,
-                           u16 wcid, u8 *pAddr)
-{
-       u16 HashIdx;
-       struct rt_mac_table_entry *pEntry, *pPrevEntry, *pProbeEntry;
-       BOOLEAN Cancelled;
-       /*u16        offset; // unused variable */
-       /*u8 j;                      // unused variable */
-
-       if (wcid >= MAX_LEN_OF_MAC_TABLE)
-               return FALSE;
-
-       NdisAcquireSpinLock(&pAd->MacTabLock);
-
-       HashIdx = MAC_ADDR_HASH_INDEX(pAddr);
-       /*pEntry = pAd->MacTab.Hash[HashIdx]; */
-       pEntry = &pAd->MacTab.Content[wcid];
-
-       if (pEntry
-           && (pEntry->ValidAsCLI || pEntry->ValidAsApCli || pEntry->ValidAsWDS
-               || pEntry->ValidAsMesh)) {
-               if (MAC_ADDR_EQUAL(pEntry->Addr, pAddr)) {
-
-                       /* Delete this entry from ASIC on-chip WCID Table */
-                       RTMP_STA_ENTRY_MAC_RESET(pAd, wcid);
-
-                       /* free resources of BA */
-                       BASessionTearDownALL(pAd, pEntry->Aid);
-
-                       pPrevEntry = NULL;
-                       pProbeEntry = pAd->MacTab.Hash[HashIdx];
-                       ASSERT(pProbeEntry);
-
-                       /* update Hash list */
-                       do {
-                               if (pProbeEntry == pEntry) {
-                                       if (pPrevEntry == NULL) {
-                                               pAd->MacTab.Hash[HashIdx] =
-                                                   pEntry->pNext;
-                                       } else {
-                                               pPrevEntry->pNext =
-                                                   pEntry->pNext;
-                                       }
-                                       break;
-                               }
-
-                               pPrevEntry = pProbeEntry;
-                               pProbeEntry = pProbeEntry->pNext;
-                       } while (pProbeEntry);
-
-                       /* not found ! */
-                       ASSERT(pProbeEntry != NULL);
-
-                       RTMP_STA_ENTRY_KEY_DEL(pAd, BSS0, wcid);
-
-                       if (pEntry->EnqueueEapolStartTimerRunning !=
-                           EAPOL_START_DISABLE) {
-                               RTMPCancelTimer(&pEntry->
-                                               EnqueueStartForPSKTimer,
-                                               &Cancelled);
-                               pEntry->EnqueueEapolStartTimerRunning =
-                                   EAPOL_START_DISABLE;
-                       }
-
-                       NdisZeroMemory(pEntry, sizeof(struct rt_mac_table_entry));
-                       pAd->MacTab.Size--;
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("MacTableDeleteEntry1 - Total= %d\n",
-                                 pAd->MacTab.Size));
-               } else {
-                       DBGPRINT(RT_DEBUG_OFF,
-                                ("\n%s: Impossible Wcid = %d !\n",
-                                 __func__, wcid));
-               }
-       }
-
-       NdisReleaseSpinLock(&pAd->MacTabLock);
-
-       /*Reset operating mode when no Sta. */
-       if (pAd->MacTab.Size == 0) {
-               pAd->CommonCfg.AddHTInfo.AddHtInfo2.OperaionMode = 0;
-               RTMP_UPDATE_PROTECT(pAd);       /* edit by johnli, fix "in_interrupt" error when call "MacTableDeleteEntry" in Rx tasklet */
-       }
-
-       return TRUE;
-}
-
-/*
-       ==========================================================================
-       Description:
-               This routine reset the entire MAC table. All packets pending in
-               the power-saving queues are freed here.
-       ==========================================================================
- */
-void MacTableReset(struct rt_rtmp_adapter *pAd)
-{
-       int i;
-
-       DBGPRINT(RT_DEBUG_TRACE, ("MacTableReset\n"));
-       /*NdisAcquireSpinLock(&pAd->MacTabLock); */
-
-       for (i = 1; i < MAX_LEN_OF_MAC_TABLE; i++) {
-#ifdef RTMP_MAC_PCI
-               RTMP_STA_ENTRY_MAC_RESET(pAd, i);
-#endif /* RTMP_MAC_PCI // */
-               if (pAd->MacTab.Content[i].ValidAsCLI == TRUE) {
-
-                       /* free resources of BA */
-                       BASessionTearDownALL(pAd, i);
-
-                       pAd->MacTab.Content[i].ValidAsCLI = FALSE;
-
-#ifdef RTMP_MAC_USB
-                       NdisZeroMemory(pAd->MacTab.Content[i].Addr, 6);
-                       RTMP_STA_ENTRY_MAC_RESET(pAd, i);
-#endif /* RTMP_MAC_USB // */
-
-                       /*AsicDelWcidTab(pAd, i); */
-               }
-       }
-
-       return;
-}
-
-/*
-       ==========================================================================
-       Description:
-
-       IRQL = DISPATCH_LEVEL
-
-       ==========================================================================
-*/
-void AssocParmFill(struct rt_rtmp_adapter *pAd,
-                  struct rt_mlme_assoc_req *AssocReq,
-                  u8 *pAddr,
-                  u16 CapabilityInfo,
-                  unsigned long Timeout, u16 ListenIntv)
-{
-       COPY_MAC_ADDR(AssocReq->Addr, pAddr);
-       /* Add mask to support 802.11b mode only */
-       AssocReq->CapabilityInfo = CapabilityInfo & SUPPORTED_CAPABILITY_INFO;  /* not cf-pollable, not cf-poll-request */
-       AssocReq->Timeout = Timeout;
-       AssocReq->ListenIntv = ListenIntv;
-}
-
-/*
-       ==========================================================================
-       Description:
-
-       IRQL = DISPATCH_LEVEL
-
-       ==========================================================================
-*/
-void DisassocParmFill(struct rt_rtmp_adapter *pAd,
-                     struct rt_mlme_disassoc_req *DisassocReq,
-                     u8 *pAddr, u16 Reason)
-{
-       COPY_MAC_ADDR(DisassocReq->Addr, pAddr);
-       DisassocReq->Reason = Reason;
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Check the out going frame, if this is an DHCP or ARP datagram
-       will be duplicate another frame at low data rate transmit.
-
-       Arguments:
-               pAd             Pointer to our adapter
-               pPacket         Pointer to outgoing Ndis frame
-
-       Return Value:
-               TRUE            To be duplicate at Low data rate transmit. (1mb)
-               FALSE           Do nothing.
-
-       IRQL = DISPATCH_LEVEL
-
-       Note:
-
-               MAC header + IP Header + UDP Header
-                 14 Bytes        20 Bytes
-
-               UDP Header
-               00|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|
-                                               Source Port
-               16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|
-                                       Destination Port
-
-               port 0x43 means Bootstrap Protocol, server.
-               Port 0x44 means Bootstrap Protocol, client.
-
-       ========================================================================
-*/
-
-BOOLEAN RTMPCheckDHCPFrame(struct rt_rtmp_adapter *pAd, void *pPacket)
-{
-       struct rt_packet_info PacketInfo;
-       unsigned long NumberOfBytesRead = 0;
-       unsigned long CurrentOffset = 0;
-       void *pVirtualAddress = NULL;
-       u32 NdisBufferLength;
-       u8 *pSrc;
-       u16 Protocol;
-       u8 ByteOffset36 = 0;
-       u8 ByteOffset38 = 0;
-       BOOLEAN ReadFirstParm = TRUE;
-
-       RTMP_QueryPacketInfo(pPacket, &PacketInfo, (u8 **) & pVirtualAddress,
-                            &NdisBufferLength);
-
-       NumberOfBytesRead += NdisBufferLength;
-       pSrc = (u8 *)pVirtualAddress;
-       Protocol = *(pSrc + 12) * 256 + *(pSrc + 13);
-
-       /* */
-       /* Check DHCP & BOOTP protocol */
-       /* */
-       while (NumberOfBytesRead <= PacketInfo.TotalPacketLength) {
-               if ((NumberOfBytesRead >= 35) && (ReadFirstParm == TRUE)) {
-                       CurrentOffset =
-                           35 - (NumberOfBytesRead - NdisBufferLength);
-                       ByteOffset36 = *(pSrc + CurrentOffset);
-                       ReadFirstParm = FALSE;
-               }
-
-               if (NumberOfBytesRead >= 37) {
-                       CurrentOffset =
-                           37 - (NumberOfBytesRead - NdisBufferLength);
-                       ByteOffset38 = *(pSrc + CurrentOffset);
-                       /*End of Read */
-                       break;
-               }
-               return FALSE;
-       }
-
-       /* Check for DHCP & BOOTP protocol */
-       if ((ByteOffset36 != 0x44) || (ByteOffset38 != 0x43)) {
-               /* */
-               /* 2054 (hex 0806) for ARP datagrams */
-               /* if this packet is not ARP datagrams, then do nothing */
-               /* ARP datagrams will also be duplicate at 1mb broadcast frames */
-               /* */
-               if (Protocol != 0x0806)
-                       return FALSE;
-       }
-
-       return TRUE;
-}
-
-BOOLEAN RTMPCheckEtherType(struct rt_rtmp_adapter *pAd, void *pPacket)
-{
-       u16 TypeLen;
-       u8 Byte0, Byte1;
-       u8 *pSrcBuf;
-       u32 pktLen;
-       u16 srcPort, dstPort;
-       BOOLEAN status = TRUE;
-
-       pSrcBuf = GET_OS_PKT_DATAPTR(pPacket);
-       pktLen = GET_OS_PKT_LEN(pPacket);
-
-       ASSERT(pSrcBuf);
-
-       RTMP_SET_PACKET_SPECIFIC(pPacket, 0);
-
-       /* get Ethernet protocol field */
-       TypeLen = (pSrcBuf[12] << 8) | pSrcBuf[13];
-
-       pSrcBuf += LENGTH_802_3;        /* Skip the Ethernet Header. */
-
-       if (TypeLen <= 1500) {  /* 802.3, 802.3 LLC */
-               /*
-                  DestMAC(6) + SrcMAC(6) + Length(2) +
-                  DSAP(1) + SSAP(1) + Control(1) +
-                  if the DSAP = 0xAA, SSAP=0xAA, Contorl = 0x03, it has a 5-bytes SNAP header.
-                  => + SNAP (5, OriginationID(3) + etherType(2))
-                */
-               if (pSrcBuf[0] == 0xAA && pSrcBuf[1] == 0xAA
-                   && pSrcBuf[2] == 0x03) {
-                       Sniff2BytesFromNdisBuffer((char *)pSrcBuf, 6,
-                                                 &Byte0, &Byte1);
-                       RTMP_SET_PACKET_LLCSNAP(pPacket, 1);
-                       TypeLen = (u16)((Byte0 << 8) + Byte1);
-                       pSrcBuf += 8;   /* Skip this LLC/SNAP header */
-               } else {
-                       /*It just has 3-byte LLC header, maybe a legacy ether type frame. we didn't handle it. */
-               }
-       }
-       /* If it's a VLAN packet, get the real Type/Length field. */
-       if (TypeLen == 0x8100) {
-               /* 0x8100 means VLAN packets */
-
-               /* Dest. MAC Address (6-bytes) +
-                  Source MAC Address (6-bytes) +
-                  Length/Type = 802.1Q Tag Type (2-byte) +
-                  Tag Control Information (2-bytes) +
-                  Length / Type (2-bytes) +
-                  data payload (0-n bytes) +
-                  Pad (0-p bytes) +
-                  Frame Check Sequence (4-bytes) */
-
-               RTMP_SET_PACKET_VLAN(pPacket, 1);
-               Sniff2BytesFromNdisBuffer((char *)pSrcBuf, 2, &Byte0,
-                                         &Byte1);
-               TypeLen = (u16)((Byte0 << 8) + Byte1);
-
-               pSrcBuf += 4;   /* Skip the VLAN Header. */
-       }
-
-       switch (TypeLen) {
-       case 0x0800:
-               {
-                       ASSERT((pktLen > 34));
-                       if (*(pSrcBuf + 9) == 0x11) {   /* udp packet */
-                               ASSERT((pktLen > 34));  /* 14 for ethernet header, 20 for IP header */
-
-                               pSrcBuf += 20;  /* Skip the IP header */
-                               srcPort =
-                                   OS_NTOHS(get_unaligned
-                                            ((u16 *)(pSrcBuf)));
-                               dstPort =
-                                   OS_NTOHS(get_unaligned
-                                            ((u16 *)(pSrcBuf + 2)));
-
-                               if ((srcPort == 0x44 && dstPort == 0x43) || (srcPort == 0x43 && dstPort == 0x44)) {     /*It's a BOOTP/DHCP packet */
-                                       RTMP_SET_PACKET_DHCP(pPacket, 1);
-                               }
-                       }
-               }
-               break;
-       case 0x0806:
-               {
-                       /*ARP Packet. */
-                       RTMP_SET_PACKET_DHCP(pPacket, 1);
-               }
-               break;
-       case 0x888e:
-               {
-                       /* EAPOL Packet. */
-                       RTMP_SET_PACKET_EAPOL(pPacket, 1);
-               }
-               break;
-       default:
-               status = FALSE;
-               break;
-       }
-
-       return status;
-
-}
-
-void Update_Rssi_Sample(struct rt_rtmp_adapter *pAd,
-                       struct rt_rssi_sample *pRssi, struct rt_rxwi * pRxWI)
-{
-       char rssi0 = pRxWI->RSSI0;
-       char rssi1 = pRxWI->RSSI1;
-       char rssi2 = pRxWI->RSSI2;
-
-       if (rssi0 != 0) {
-               pRssi->LastRssi0 = ConvertToRssi(pAd, (char)rssi0, RSSI_0);
-               pRssi->AvgRssi0X8 =
-                   (pRssi->AvgRssi0X8 - pRssi->AvgRssi0) + pRssi->LastRssi0;
-               pRssi->AvgRssi0 = pRssi->AvgRssi0X8 >> 3;
-       }
-
-       if (rssi1 != 0) {
-               pRssi->LastRssi1 = ConvertToRssi(pAd, (char)rssi1, RSSI_1);
-               pRssi->AvgRssi1X8 =
-                   (pRssi->AvgRssi1X8 - pRssi->AvgRssi1) + pRssi->LastRssi1;
-               pRssi->AvgRssi1 = pRssi->AvgRssi1X8 >> 3;
-       }
-
-       if (rssi2 != 0) {
-               pRssi->LastRssi2 = ConvertToRssi(pAd, (char)rssi2, RSSI_2);
-               pRssi->AvgRssi2X8 =
-                   (pRssi->AvgRssi2X8 - pRssi->AvgRssi2) + pRssi->LastRssi2;
-               pRssi->AvgRssi2 = pRssi->AvgRssi2X8 >> 3;
-       }
-}
-
-/* Normal legacy Rx packet indication */
-void Indicate_Legacy_Packet(struct rt_rtmp_adapter *pAd,
-                           struct rt_rx_blk *pRxBlk, u8 FromWhichBSSID)
-{
-       void *pRxPacket = pRxBlk->pRxPacket;
-       u8 Header802_3[LENGTH_802_3];
-
-       /* 1. get 802.3 Header */
-       /* 2. remove LLC */
-       /*              a. pointer pRxBlk->pData to payload */
-       /*      b. modify pRxBlk->DataSize */
-       RTMP_802_11_REMOVE_LLC_AND_CONVERT_TO_802_3(pRxBlk, Header802_3);
-
-       if (pRxBlk->DataSize > MAX_RX_PKT_LEN) {
-
-               /* release packet */
-               RELEASE_NDIS_PACKET(pAd, pRxPacket, NDIS_STATUS_FAILURE);
-               return;
-       }
-
-       STATS_INC_RX_PACKETS(pAd, FromWhichBSSID);
-
-#ifdef RTMP_MAC_USB
-       if (pAd->CommonCfg.bDisableReordering == 0) {
-               struct rt_ba_rec_entry *pBAEntry;
-               unsigned long Now32;
-               u8 Wcid = pRxBlk->pRxWI->WirelessCliID;
-               u8 TID = pRxBlk->pRxWI->TID;
-               u16 Idx;
-
-#define REORDERING_PACKET_TIMEOUT              ((100 * OS_HZ)/1000)    /* system ticks -- 100 ms */
-
-               if (Wcid < MAX_LEN_OF_MAC_TABLE) {
-                       Idx = pAd->MacTab.Content[Wcid].BARecWcidArray[TID];
-                       if (Idx != 0) {
-                               pBAEntry = &pAd->BATable.BARecEntry[Idx];
-                               /* update last rx time */
-                               NdisGetSystemUpTime(&Now32);
-                               if ((pBAEntry->list.qlen > 0) &&
-                                   RTMP_TIME_AFTER((unsigned long)Now32,
-                                                   (unsigned long)(pBAEntry->
-                                                                   LastIndSeqAtTimer
-                                                                   +
-                                                                   (REORDERING_PACKET_TIMEOUT)))
-                                   ) {
-                                       DBGPRINT(RT_DEBUG_OFF,
-                                                ("Indicate_Legacy_Packet():flush reordering_timeout_mpdus! RxWI->Flags=%d, pRxWI.TID=%d, RxD->AMPDU=%d!\n",
-                                                 pRxBlk->Flags,
-                                                 pRxBlk->pRxWI->TID,
-                                                 pRxBlk->RxD.AMPDU));
-                                       hex_dump("Dump the legacy Packet:",
-                                                GET_OS_PKT_DATAPTR(pRxBlk->
-                                                                   pRxPacket),
-                                                64);
-                                       ba_flush_reordering_timeout_mpdus(pAd,
-                                                                         pBAEntry,
-                                                                         Now32);
-                               }
-                       }
-               }
-       }
-#endif /* RTMP_MAC_USB // */
-
-       wlan_802_11_to_802_3_packet(pAd, pRxBlk, Header802_3, FromWhichBSSID);
-
-       /* */
-       /* pass this 802.3 packet to upper layer or forward this packet to WM directly */
-       /* */
-       ANNOUNCE_OR_FORWARD_802_3_PACKET(pAd, pRxPacket, FromWhichBSSID);
-}
-
-/* Normal, AMPDU or AMSDU */
-void CmmRxnonRalinkFrameIndicate(struct rt_rtmp_adapter *pAd,
-                                struct rt_rx_blk *pRxBlk, u8 FromWhichBSSID)
-{
-       if (RX_BLK_TEST_FLAG(pRxBlk, fRX_AMPDU)
-           && (pAd->CommonCfg.bDisableReordering == 0)) {
-               Indicate_AMPDU_Packet(pAd, pRxBlk, FromWhichBSSID);
-       } else {
-               if (RX_BLK_TEST_FLAG(pRxBlk, fRX_AMSDU)) {
-                       /* handle A-MSDU */
-                       Indicate_AMSDU_Packet(pAd, pRxBlk, FromWhichBSSID);
-               } else {
-                       Indicate_Legacy_Packet(pAd, pRxBlk, FromWhichBSSID);
-               }
-       }
-}
-
-void CmmRxRalinkFrameIndicate(struct rt_rtmp_adapter *pAd,
-                             struct rt_mac_table_entry *pEntry,
-                             struct rt_rx_blk *pRxBlk, u8 FromWhichBSSID)
-{
-       u8 Header802_3[LENGTH_802_3];
-       u16 Msdu2Size;
-       u16 Payload1Size, Payload2Size;
-       u8 *pData2;
-       void *pPacket2 = NULL;
-
-       Msdu2Size = *(pRxBlk->pData) + (*(pRxBlk->pData + 1) << 8);
-
-       if ((Msdu2Size <= 1536) && (Msdu2Size < pRxBlk->DataSize)) {
-               /* skip two byte MSDU2 len */
-               pRxBlk->pData += 2;
-               pRxBlk->DataSize -= 2;
-       } else {
-               /* release packet */
-               RELEASE_NDIS_PACKET(pAd, pRxBlk->pRxPacket,
-                                   NDIS_STATUS_FAILURE);
-               return;
-       }
-
-       /* get 802.3 Header and  remove LLC */
-       RTMP_802_11_REMOVE_LLC_AND_CONVERT_TO_802_3(pRxBlk, Header802_3);
-
-       ASSERT(pRxBlk->pRxPacket);
-
-       /* Ralink Aggregation frame */
-       pAd->RalinkCounters.OneSecRxAggregationCount++;
-       Payload1Size = pRxBlk->DataSize - Msdu2Size;
-       Payload2Size = Msdu2Size - LENGTH_802_3;
-
-       pData2 = pRxBlk->pData + Payload1Size + LENGTH_802_3;
-
-       pPacket2 =
-           duplicate_pkt(pAd, (pData2 - LENGTH_802_3), LENGTH_802_3, pData2,
-                         Payload2Size, FromWhichBSSID);
-
-       if (!pPacket2) {
-               /* release packet */
-               RELEASE_NDIS_PACKET(pAd, pRxBlk->pRxPacket,
-                                   NDIS_STATUS_FAILURE);
-               return;
-       }
-       /* update payload size of 1st packet */
-       pRxBlk->DataSize = Payload1Size;
-       wlan_802_11_to_802_3_packet(pAd, pRxBlk, Header802_3, FromWhichBSSID);
-
-       ANNOUNCE_OR_FORWARD_802_3_PACKET(pAd, pRxBlk->pRxPacket,
-                                        FromWhichBSSID);
-
-       if (pPacket2) {
-               ANNOUNCE_OR_FORWARD_802_3_PACKET(pAd, pPacket2, FromWhichBSSID);
-       }
-}
-
-#define RESET_FRAGFRAME(_fragFrame) \
-       {                                                               \
-               _fragFrame.RxSize = 0;          \
-               _fragFrame.Sequence = 0;        \
-               _fragFrame.LastFrag = 0;        \
-               _fragFrame.Flags = 0;           \
-       }
-
-void *RTMPDeFragmentDataFrame(struct rt_rtmp_adapter *pAd, struct rt_rx_blk *pRxBlk)
-{
-       struct rt_header_802_11 * pHeader = pRxBlk->pHeader;
-       void *pRxPacket = pRxBlk->pRxPacket;
-       u8 *pData = pRxBlk->pData;
-       u16 DataSize = pRxBlk->DataSize;
-       void *pRetPacket = NULL;
-       u8 *pFragBuffer = NULL;
-       BOOLEAN bReassDone = FALSE;
-       u8 HeaderRoom = 0;
-
-       ASSERT(pHeader);
-
-       HeaderRoom = pData - (u8 *) pHeader;
-
-       /* Re-assemble the fragmented packets */
-       if (pHeader->Frag == 0) /* Frag. Number is 0 : First frag or only one pkt */
-       {
-               /* the first pkt of fragment, record it. */
-               if (pHeader->FC.MoreFrag) {
-                       ASSERT(pAd->FragFrame.pFragPacket);
-                       pFragBuffer =
-                           GET_OS_PKT_DATAPTR(pAd->FragFrame.pFragPacket);
-                       pAd->FragFrame.RxSize = DataSize + HeaderRoom;
-                       NdisMoveMemory(pFragBuffer, pHeader,
-                                      pAd->FragFrame.RxSize);
-                       pAd->FragFrame.Sequence = pHeader->Sequence;
-                       pAd->FragFrame.LastFrag = pHeader->Frag;        /* Should be 0 */
-                       ASSERT(pAd->FragFrame.LastFrag == 0);
-                       goto done;      /* end of processing this frame */
-               }
-       } else                  /*Middle & End of fragment */
-       {
-               if ((pHeader->Sequence != pAd->FragFrame.Sequence) ||
-                   (pHeader->Frag != (pAd->FragFrame.LastFrag + 1))) {
-                       /* Fragment is not the same sequence or out of fragment number order */
-                       /* Reset Fragment control blk */
-                       RESET_FRAGFRAME(pAd->FragFrame);
-                       DBGPRINT(RT_DEBUG_ERROR,
-                                ("Fragment is not the same sequence or out of fragment number order.\n"));
-                       goto done;      /* give up this frame */
-               } else if ((pAd->FragFrame.RxSize + DataSize) > MAX_FRAME_SIZE) {
-                       /* Fragment frame is too large, it exeeds the maximum frame size. */
-                       /* Reset Fragment control blk */
-                       RESET_FRAGFRAME(pAd->FragFrame);
-                       DBGPRINT(RT_DEBUG_ERROR,
-                                ("Fragment frame is too large, it exeeds the maximum frame size.\n"));
-                       goto done;      /* give up this frame */
-               }
-               /* */
-               /* Broadcom AP(BCM94704AGR) will send out LLC in fragment's packet, LLC only can accpet at first fragment. */
-               /* In this case, we will dropt it. */
-               /* */
-               if (NdisEqualMemory(pData, SNAP_802_1H, sizeof(SNAP_802_1H))) {
-                       DBGPRINT(RT_DEBUG_ERROR,
-                                ("Find another LLC at Middle or End fragment(SN=%d, Frag=%d)\n",
-                                 pHeader->Sequence, pHeader->Frag));
-                       goto done;      /* give up this frame */
-               }
-
-               pFragBuffer = GET_OS_PKT_DATAPTR(pAd->FragFrame.pFragPacket);
-
-               /* concatenate this fragment into the re-assembly buffer */
-               NdisMoveMemory((pFragBuffer + pAd->FragFrame.RxSize), pData,
-                              DataSize);
-               pAd->FragFrame.RxSize += DataSize;
-               pAd->FragFrame.LastFrag = pHeader->Frag;        /* Update fragment number */
-
-               /* Last fragment */
-               if (pHeader->FC.MoreFrag == FALSE) {
-                       bReassDone = TRUE;
-               }
-       }
-
-done:
-       /* always release rx fragmented packet */
-       RELEASE_NDIS_PACKET(pAd, pRxPacket, NDIS_STATUS_FAILURE);
-
-       /* return defragmented packet if packet is reassembled completely */
-       /* otherwise return NULL */
-       if (bReassDone) {
-               void *pNewFragPacket;
-
-               /* allocate a new packet buffer for fragment */
-               pNewFragPacket =
-                   RTMP_AllocateFragPacketBuffer(pAd, RX_BUFFER_NORMSIZE);
-               if (pNewFragPacket) {
-                       /* update RxBlk */
-                       pRetPacket = pAd->FragFrame.pFragPacket;
-                       pAd->FragFrame.pFragPacket = pNewFragPacket;
-                       pRxBlk->pHeader =
-                           (struct rt_header_802_11 *) GET_OS_PKT_DATAPTR(pRetPacket);
-                       pRxBlk->pData = (u8 *) pRxBlk->pHeader + HeaderRoom;
-                       pRxBlk->DataSize = pAd->FragFrame.RxSize - HeaderRoom;
-                       pRxBlk->pRxPacket = pRetPacket;
-               } else {
-                       RESET_FRAGFRAME(pAd->FragFrame);
-               }
-       }
-
-       return pRetPacket;
-}
-
-void Indicate_AMSDU_Packet(struct rt_rtmp_adapter *pAd,
-                          struct rt_rx_blk *pRxBlk, u8 FromWhichBSSID)
-{
-       u32 nMSDU;
-
-       update_os_packet_info(pAd, pRxBlk, FromWhichBSSID);
-       RTMP_SET_PACKET_IF(pRxBlk->pRxPacket, FromWhichBSSID);
-       nMSDU =
-           deaggregate_AMSDU_announce(pAd, pRxBlk->pRxPacket, pRxBlk->pData,
-                                      pRxBlk->DataSize);
-}
-
-void Indicate_EAPOL_Packet(struct rt_rtmp_adapter *pAd,
-                          struct rt_rx_blk *pRxBlk, u8 FromWhichBSSID)
-{
-       struct rt_mac_table_entry *pEntry = NULL;
-
-       {
-               pEntry = &pAd->MacTab.Content[BSSID_WCID];
-               STARxEAPOLFrameIndicate(pAd, pEntry, pRxBlk, FromWhichBSSID);
-               return;
-       }
-
-       if (pEntry == NULL) {
-               DBGPRINT(RT_DEBUG_WARN,
-                        ("Indicate_EAPOL_Packet: drop and release the invalid packet.\n"));
-               /* release packet */
-               RELEASE_NDIS_PACKET(pAd, pRxBlk->pRxPacket,
-                                   NDIS_STATUS_FAILURE);
-               return;
-       }
-}
-
-#define BCN_TBTT_OFFSET                64      /*defer 64 us */
-void ReSyncBeaconTime(struct rt_rtmp_adapter *pAd)
-{
-
-       u32 Offset;
-
-       Offset = (pAd->TbttTickCount) % (BCN_TBTT_OFFSET);
-
-       pAd->TbttTickCount++;
-
-       /* */
-       /* The updated BeaconInterval Value will affect Beacon Interval after two TBTT */
-       /* beacasue the original BeaconInterval had been loaded into next TBTT_TIMER */
-       /* */
-       if (Offset == (BCN_TBTT_OFFSET - 2)) {
-               BCN_TIME_CFG_STRUC csr;
-               RTMP_IO_READ32(pAd, BCN_TIME_CFG, &csr.word);
-               csr.field.BeaconInterval = (pAd->CommonCfg.BeaconPeriod << 4) - 1;      /* ASIC register in units of 1/16 TU = 64us */
-               RTMP_IO_WRITE32(pAd, BCN_TIME_CFG, csr.word);
-       } else {
-               if (Offset == (BCN_TBTT_OFFSET - 1)) {
-                       BCN_TIME_CFG_STRUC csr;
-
-                       RTMP_IO_READ32(pAd, BCN_TIME_CFG, &csr.word);
-                       csr.field.BeaconInterval = (pAd->CommonCfg.BeaconPeriod) << 4;  /* ASIC register in units of 1/16 TU */
-                       RTMP_IO_WRITE32(pAd, BCN_TIME_CFG, csr.word);
-               }
-       }
-}
diff --git a/drivers/staging/rt2860/common/cmm_data_pci.c b/drivers/staging/rt2860/common/cmm_data_pci.c
deleted file mode 100644 (file)
index f01a51c..0000000
+++ /dev/null
@@ -1,1096 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
- */
-
-/*
-   All functions in this file must be PCI-depended, or you should out your function
-       in other files.
-
-*/
-#include       "../rt_config.h"
-
-u16 RtmpPCI_WriteTxResource(struct rt_rtmp_adapter *pAd,
-                              struct rt_tx_blk *pTxBlk,
-                              IN BOOLEAN bIsLast, u16 * FreeNumber)
-{
-
-       u8 *pDMAHeaderBufVA;
-       u16 TxIdx, RetTxIdx;
-       struct rt_txd * pTxD;
-       u32 BufBasePaLow;
-       struct rt_rtmp_tx_ring *pTxRing;
-       u16 hwHeaderLen;
-
-       /* */
-       /* get Tx Ring Resource */
-       /* */
-       pTxRing = &pAd->TxRing[pTxBlk->QueIdx];
-       TxIdx = pAd->TxRing[pTxBlk->QueIdx].TxCpuIdx;
-       pDMAHeaderBufVA = (u8 *)pTxRing->Cell[TxIdx].DmaBuf.AllocVa;
-       BufBasePaLow =
-           RTMP_GetPhysicalAddressLow(pTxRing->Cell[TxIdx].DmaBuf.AllocPa);
-
-       /* copy TXINFO + TXWI + WLAN Header + LLC into DMA Header Buffer */
-       if (pTxBlk->TxFrameType == TX_AMSDU_FRAME) {
-               /*hwHeaderLen = ROUND_UP(pTxBlk->MpduHeaderLen-LENGTH_AMSDU_SUBFRAMEHEAD, 4)+LENGTH_AMSDU_SUBFRAMEHEAD; */
-               hwHeaderLen =
-                   pTxBlk->MpduHeaderLen - LENGTH_AMSDU_SUBFRAMEHEAD +
-                   pTxBlk->HdrPadLen + LENGTH_AMSDU_SUBFRAMEHEAD;
-       } else {
-               /*hwHeaderLen = ROUND_UP(pTxBlk->MpduHeaderLen, 4); */
-               hwHeaderLen = pTxBlk->MpduHeaderLen + pTxBlk->HdrPadLen;
-       }
-       NdisMoveMemory(pDMAHeaderBufVA, pTxBlk->HeaderBuf,
-                      TXINFO_SIZE + TXWI_SIZE + hwHeaderLen);
-
-       pTxRing->Cell[TxIdx].pNdisPacket = pTxBlk->pPacket;
-       pTxRing->Cell[TxIdx].pNextNdisPacket = NULL;
-
-       /* */
-       /* build Tx Descriptor */
-       /* */
-
-       pTxD = (struct rt_txd *) pTxRing->Cell[TxIdx].AllocVa;
-       NdisZeroMemory(pTxD, TXD_SIZE);
-
-       pTxD->SDPtr0 = BufBasePaLow;
-       pTxD->SDLen0 = TXINFO_SIZE + TXWI_SIZE + hwHeaderLen;   /* include padding */
-       pTxD->SDPtr1 = PCI_MAP_SINGLE(pAd, pTxBlk, 0, 1, PCI_DMA_TODEVICE);
-       pTxD->SDLen1 = pTxBlk->SrcBufLen;
-       pTxD->LastSec0 = 0;
-       pTxD->LastSec1 = (bIsLast) ? 1 : 0;
-
-       RTMPWriteTxDescriptor(pAd, pTxD, FALSE, FIFO_EDCA);
-
-       RetTxIdx = TxIdx;
-       /* */
-       /* Update Tx index */
-       /* */
-       INC_RING_INDEX(TxIdx, TX_RING_SIZE);
-       pTxRing->TxCpuIdx = TxIdx;
-
-       *FreeNumber -= 1;
-
-       return RetTxIdx;
-}
-
-u16 RtmpPCI_WriteSingleTxResource(struct rt_rtmp_adapter *pAd,
-                                    struct rt_tx_blk *pTxBlk,
-                                    IN BOOLEAN bIsLast,
-                                    u16 * FreeNumber)
-{
-
-       u8 *pDMAHeaderBufVA;
-       u16 TxIdx, RetTxIdx;
-       struct rt_txd * pTxD;
-       u32 BufBasePaLow;
-       struct rt_rtmp_tx_ring *pTxRing;
-       u16 hwHeaderLen;
-
-       /* */
-       /* get Tx Ring Resource */
-       /* */
-       pTxRing = &pAd->TxRing[pTxBlk->QueIdx];
-       TxIdx = pAd->TxRing[pTxBlk->QueIdx].TxCpuIdx;
-       pDMAHeaderBufVA = (u8 *)pTxRing->Cell[TxIdx].DmaBuf.AllocVa;
-       BufBasePaLow =
-           RTMP_GetPhysicalAddressLow(pTxRing->Cell[TxIdx].DmaBuf.AllocPa);
-
-       /* copy TXINFO + TXWI + WLAN Header + LLC into DMA Header Buffer */
-       /*hwHeaderLen = ROUND_UP(pTxBlk->MpduHeaderLen, 4); */
-       hwHeaderLen = pTxBlk->MpduHeaderLen + pTxBlk->HdrPadLen;
-
-       NdisMoveMemory(pDMAHeaderBufVA, pTxBlk->HeaderBuf,
-                      TXINFO_SIZE + TXWI_SIZE + hwHeaderLen);
-
-       pTxRing->Cell[TxIdx].pNdisPacket = pTxBlk->pPacket;
-       pTxRing->Cell[TxIdx].pNextNdisPacket = NULL;
-
-       /* */
-       /* build Tx Descriptor */
-       /* */
-       pTxD = (struct rt_txd *) pTxRing->Cell[TxIdx].AllocVa;
-       NdisZeroMemory(pTxD, TXD_SIZE);
-
-       pTxD->SDPtr0 = BufBasePaLow;
-       pTxD->SDLen0 = TXINFO_SIZE + TXWI_SIZE + hwHeaderLen;   /* include padding */
-       pTxD->SDPtr1 = PCI_MAP_SINGLE(pAd, pTxBlk, 0, 1, PCI_DMA_TODEVICE);
-       pTxD->SDLen1 = pTxBlk->SrcBufLen;
-       pTxD->LastSec0 = 0;
-       pTxD->LastSec1 = (bIsLast) ? 1 : 0;
-
-       RTMPWriteTxDescriptor(pAd, pTxD, FALSE, FIFO_EDCA);
-
-       RetTxIdx = TxIdx;
-       /* */
-       /* Update Tx index */
-       /* */
-       INC_RING_INDEX(TxIdx, TX_RING_SIZE);
-       pTxRing->TxCpuIdx = TxIdx;
-
-       *FreeNumber -= 1;
-
-       return RetTxIdx;
-}
-
-u16 RtmpPCI_WriteMultiTxResource(struct rt_rtmp_adapter *pAd,
-                                   struct rt_tx_blk *pTxBlk,
-                                   u8 frameNum, u16 * FreeNumber)
-{
-       BOOLEAN bIsLast;
-       u8 *pDMAHeaderBufVA;
-       u16 TxIdx, RetTxIdx;
-       struct rt_txd * pTxD;
-       u32 BufBasePaLow;
-       struct rt_rtmp_tx_ring *pTxRing;
-       u16 hwHdrLen;
-       u32 firstDMALen;
-
-       bIsLast = ((frameNum == (pTxBlk->TotalFrameNum - 1)) ? 1 : 0);
-
-       /* */
-       /* get Tx Ring Resource */
-       /* */
-       pTxRing = &pAd->TxRing[pTxBlk->QueIdx];
-       TxIdx = pAd->TxRing[pTxBlk->QueIdx].TxCpuIdx;
-       pDMAHeaderBufVA = (u8 *)pTxRing->Cell[TxIdx].DmaBuf.AllocVa;
-       BufBasePaLow =
-           RTMP_GetPhysicalAddressLow(pTxRing->Cell[TxIdx].DmaBuf.AllocPa);
-
-       if (frameNum == 0) {
-               /* copy TXINFO + TXWI + WLAN Header + LLC into DMA Header Buffer */
-               if (pTxBlk->TxFrameType == TX_AMSDU_FRAME)
-                       /*hwHdrLen = ROUND_UP(pTxBlk->MpduHeaderLen-LENGTH_AMSDU_SUBFRAMEHEAD, 4)+LENGTH_AMSDU_SUBFRAMEHEAD; */
-                       hwHdrLen =
-                           pTxBlk->MpduHeaderLen - LENGTH_AMSDU_SUBFRAMEHEAD +
-                           pTxBlk->HdrPadLen + LENGTH_AMSDU_SUBFRAMEHEAD;
-               else if (pTxBlk->TxFrameType == TX_RALINK_FRAME)
-                       /*hwHdrLen = ROUND_UP(pTxBlk->MpduHeaderLen-LENGTH_ARALINK_HEADER_FIELD, 4)+LENGTH_ARALINK_HEADER_FIELD; */
-                       hwHdrLen =
-                           pTxBlk->MpduHeaderLen -
-                           LENGTH_ARALINK_HEADER_FIELD + pTxBlk->HdrPadLen +
-                           LENGTH_ARALINK_HEADER_FIELD;
-               else
-                       /*hwHdrLen = ROUND_UP(pTxBlk->MpduHeaderLen, 4); */
-                       hwHdrLen = pTxBlk->MpduHeaderLen + pTxBlk->HdrPadLen;
-
-               firstDMALen = TXINFO_SIZE + TXWI_SIZE + hwHdrLen;
-       } else {
-               firstDMALen = pTxBlk->MpduHeaderLen;
-       }
-
-       NdisMoveMemory(pDMAHeaderBufVA, pTxBlk->HeaderBuf, firstDMALen);
-
-       pTxRing->Cell[TxIdx].pNdisPacket = pTxBlk->pPacket;
-       pTxRing->Cell[TxIdx].pNextNdisPacket = NULL;
-
-       /* */
-       /* build Tx Descriptor */
-       /* */
-       pTxD = (struct rt_txd *) pTxRing->Cell[TxIdx].AllocVa;
-       NdisZeroMemory(pTxD, TXD_SIZE);
-
-       pTxD->SDPtr0 = BufBasePaLow;
-       pTxD->SDLen0 = firstDMALen;     /* include padding */
-       pTxD->SDPtr1 = PCI_MAP_SINGLE(pAd, pTxBlk, 0, 1, PCI_DMA_TODEVICE);
-       pTxD->SDLen1 = pTxBlk->SrcBufLen;
-       pTxD->LastSec0 = 0;
-       pTxD->LastSec1 = (bIsLast) ? 1 : 0;
-
-       RTMPWriteTxDescriptor(pAd, pTxD, FALSE, FIFO_EDCA);
-
-       RetTxIdx = TxIdx;
-       /* */
-       /* Update Tx index */
-       /* */
-       INC_RING_INDEX(TxIdx, TX_RING_SIZE);
-       pTxRing->TxCpuIdx = TxIdx;
-
-       *FreeNumber -= 1;
-
-       return RetTxIdx;
-
-}
-
-void RtmpPCI_FinalWriteTxResource(struct rt_rtmp_adapter *pAd,
-                                 struct rt_tx_blk *pTxBlk,
-                                 u16 totalMPDUSize, u16 FirstTxIdx)
-{
-
-       struct rt_txwi * pTxWI;
-       struct rt_rtmp_tx_ring *pTxRing;
-
-       /* */
-       /* get Tx Ring Resource */
-       /* */
-       pTxRing = &pAd->TxRing[pTxBlk->QueIdx];
-       pTxWI = (struct rt_txwi *) pTxRing->Cell[FirstTxIdx].DmaBuf.AllocVa;
-       pTxWI->MPDUtotalByteCount = totalMPDUSize;
-
-}
-
-void RtmpPCIDataLastTxIdx(struct rt_rtmp_adapter *pAd,
-                         u8 QueIdx, u16 LastTxIdx)
-{
-       struct rt_txd * pTxD;
-       struct rt_rtmp_tx_ring *pTxRing;
-
-       /* */
-       /* get Tx Ring Resource */
-       /* */
-       pTxRing = &pAd->TxRing[QueIdx];
-
-       /* */
-       /* build Tx Descriptor */
-       /* */
-       pTxD = (struct rt_txd *) pTxRing->Cell[LastTxIdx].AllocVa;
-
-       pTxD->LastSec1 = 1;
-
-}
-
-u16 RtmpPCI_WriteFragTxResource(struct rt_rtmp_adapter *pAd,
-                                  struct rt_tx_blk *pTxBlk,
-                                  u8 fragNum, u16 * FreeNumber)
-{
-       u8 *pDMAHeaderBufVA;
-       u16 TxIdx, RetTxIdx;
-       struct rt_txd * pTxD;
-       u32 BufBasePaLow;
-       struct rt_rtmp_tx_ring *pTxRing;
-       u16 hwHeaderLen;
-       u32 firstDMALen;
-
-       /* */
-       /* Get Tx Ring Resource */
-       /* */
-       pTxRing = &pAd->TxRing[pTxBlk->QueIdx];
-       TxIdx = pAd->TxRing[pTxBlk->QueIdx].TxCpuIdx;
-       pDMAHeaderBufVA = (u8 *)pTxRing->Cell[TxIdx].DmaBuf.AllocVa;
-       BufBasePaLow =
-           RTMP_GetPhysicalAddressLow(pTxRing->Cell[TxIdx].DmaBuf.AllocPa);
-
-       /* */
-       /* Copy TXINFO + TXWI + WLAN Header + LLC into DMA Header Buffer */
-       /* */
-       /*hwHeaderLen = ROUND_UP(pTxBlk->MpduHeaderLen, 4); */
-       hwHeaderLen = pTxBlk->MpduHeaderLen + pTxBlk->HdrPadLen;
-
-       firstDMALen = TXINFO_SIZE + TXWI_SIZE + hwHeaderLen;
-       NdisMoveMemory(pDMAHeaderBufVA, pTxBlk->HeaderBuf, firstDMALen);
-
-       /* */
-       /* Build Tx Descriptor */
-       /* */
-       pTxD = (struct rt_txd *) pTxRing->Cell[TxIdx].AllocVa;
-       NdisZeroMemory(pTxD, TXD_SIZE);
-
-       if (fragNum == pTxBlk->TotalFragNum) {
-               pTxRing->Cell[TxIdx].pNdisPacket = pTxBlk->pPacket;
-               pTxRing->Cell[TxIdx].pNextNdisPacket = NULL;
-       }
-
-       pTxD->SDPtr0 = BufBasePaLow;
-       pTxD->SDLen0 = firstDMALen;     /* include padding */
-       pTxD->SDPtr1 = PCI_MAP_SINGLE(pAd, pTxBlk, 0, 1, PCI_DMA_TODEVICE);
-       pTxD->SDLen1 = pTxBlk->SrcBufLen;
-       pTxD->LastSec0 = 0;
-       pTxD->LastSec1 = 1;
-
-       RTMPWriteTxDescriptor(pAd, pTxD, FALSE, FIFO_EDCA);
-
-       RetTxIdx = TxIdx;
-       pTxBlk->Priv += pTxBlk->SrcBufLen;
-
-       /* */
-       /* Update Tx index */
-       /* */
-       INC_RING_INDEX(TxIdx, TX_RING_SIZE);
-       pTxRing->TxCpuIdx = TxIdx;
-
-       *FreeNumber -= 1;
-
-       return RetTxIdx;
-
-}
-
-/*
-       Must be run in Interrupt context
-       This function handle PCI specific TxDesc and cpu index update and kick the packet out.
- */
-int RtmpPCIMgmtKickOut(struct rt_rtmp_adapter *pAd,
-                      u8 QueIdx,
-                      void *pPacket,
-                      u8 *pSrcBufVA, u32 SrcBufLen)
-{
-       struct rt_txd * pTxD;
-       unsigned long SwIdx = pAd->MgmtRing.TxCpuIdx;
-
-       pTxD = (struct rt_txd *) pAd->MgmtRing.Cell[SwIdx].AllocVa;
-
-       pAd->MgmtRing.Cell[SwIdx].pNdisPacket = pPacket;
-       pAd->MgmtRing.Cell[SwIdx].pNextNdisPacket = NULL;
-
-       RTMPWriteTxDescriptor(pAd, pTxD, TRUE, FIFO_MGMT);
-       pTxD->LastSec0 = 1;
-       pTxD->LastSec1 = 1;
-       pTxD->DMADONE = 0;
-       pTxD->SDLen1 = 0;
-       pTxD->SDPtr0 =
-           PCI_MAP_SINGLE(pAd, pSrcBufVA, SrcBufLen, 0, PCI_DMA_TODEVICE);
-       pTxD->SDLen0 = SrcBufLen;
-
-/*================================================================== */
-/*     DBGPRINT_RAW(RT_DEBUG_TRACE, ("MLMEHardTransmit\n"));
-       for (i = 0; i < (TXWI_SIZE+24); i++)
-       {
-
-               DBGPRINT_RAW(RT_DEBUG_TRACE, ("%x:", *(pSrcBufVA+i)));
-               if ( i%4 == 3)
-                       DBGPRINT_RAW(RT_DEBUG_TRACE, (" :: "));
-               if ( i%16 == 15)
-                       DBGPRINT_RAW(RT_DEBUG_TRACE, ("\n      "));
-       }
-       DBGPRINT_RAW(RT_DEBUG_TRACE, ("\n      "));*/
-/*======================================================================= */
-
-       pAd->RalinkCounters.KickTxCount++;
-       pAd->RalinkCounters.OneSecTxDoneCount++;
-
-       /* Increase TX_CTX_IDX, but write to register later. */
-       INC_RING_INDEX(pAd->MgmtRing.TxCpuIdx, MGMT_RING_SIZE);
-
-       RTMP_IO_WRITE32(pAd, TX_MGMTCTX_IDX, pAd->MgmtRing.TxCpuIdx);
-
-       return 0;
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Check Rx descriptor, return NDIS_STATUS_FAILURE if any error dound
-
-       Arguments:
-               pRxD            Pointer to the Rx descriptor
-
-       Return Value:
-               NDIS_STATUS_SUCCESS     No err
-               NDIS_STATUS_FAILURE     Error
-
-       Note:
-
-       ========================================================================
-*/
-int RTMPCheckRxError(struct rt_rtmp_adapter *pAd,
-                            struct rt_header_802_11 * pHeader,
-                            struct rt_rxwi * pRxWI, IN PRT28XX_RXD_STRUC pRxD)
-{
-       struct rt_cipher_key *pWpaKey;
-       int dBm;
-
-       /* Phy errors & CRC errors */
-       if ( /*(pRxD->PhyErr) || */ (pRxD->Crc)) {
-               /* Check RSSI for Noise Hist statistic collection. */
-               dBm = (int)(pRxWI->RSSI0) - pAd->BbpRssiToDbmDelta;
-               if (dBm <= -87)
-                       pAd->StaCfg.RPIDensity[0] += 1;
-               else if (dBm <= -82)
-                       pAd->StaCfg.RPIDensity[1] += 1;
-               else if (dBm <= -77)
-                       pAd->StaCfg.RPIDensity[2] += 1;
-               else if (dBm <= -72)
-                       pAd->StaCfg.RPIDensity[3] += 1;
-               else if (dBm <= -67)
-                       pAd->StaCfg.RPIDensity[4] += 1;
-               else if (dBm <= -62)
-                       pAd->StaCfg.RPIDensity[5] += 1;
-               else if (dBm <= -57)
-                       pAd->StaCfg.RPIDensity[6] += 1;
-               else if (dBm > -57)
-                       pAd->StaCfg.RPIDensity[7] += 1;
-
-               return (NDIS_STATUS_FAILURE);
-       }
-       /* Add Rx size to channel load counter, we should ignore error counts */
-       pAd->StaCfg.CLBusyBytes += (pRxD->SDL0 + 14);
-
-       /* Drop ToDs promiscuous frame, it is opened due to CCX 2 channel load statistics */
-       if (pHeader != NULL) {
-               if (pHeader->FC.ToDs) {
-                       return (NDIS_STATUS_FAILURE);
-               }
-       }
-       /* Drop not U2M frames, can't drop here because we will drop beacon in this case */
-       /* I am kind of doubting the U2M bit operation */
-       /* if (pRxD->U2M == 0) */
-       /*      return(NDIS_STATUS_FAILURE); */
-
-       /* drop decyption fail frame */
-       if (pRxD->CipherErr) {
-               if (pRxD->CipherErr == 2) {
-                       DBGPRINT_RAW(RT_DEBUG_TRACE,
-                                    ("pRxD ERROR: ICV ok but MICErr "));
-               } else if (pRxD->CipherErr == 1) {
-                       DBGPRINT_RAW(RT_DEBUG_TRACE, ("pRxD ERROR: ICV Err "));
-               } else if (pRxD->CipherErr == 3)
-                       DBGPRINT_RAW(RT_DEBUG_TRACE,
-                                    ("pRxD ERROR: Key not valid "));
-
-               if (((pRxD->CipherErr & 1) == 1)
-                   && pAd->CommonCfg.bWirelessEvent && INFRA_ON(pAd))
-                       RTMPSendWirelessEvent(pAd, IW_ICV_ERROR_EVENT_FLAG,
-                                             pAd->MacTab.Content[BSSID_WCID].
-                                             Addr, BSS0, 0);
-
-               DBGPRINT_RAW(RT_DEBUG_TRACE,
-                            (" %d (len=%d, Mcast=%d, MyBss=%d, Wcid=%d, KeyId=%d)\n",
-                             pRxD->CipherErr, pRxD->SDL0,
-                             pRxD->Mcast | pRxD->Bcast, pRxD->MyBss,
-                             pRxWI->WirelessCliID,
-/*                      CipherName[pRxD->CipherAlg], */
-                             pRxWI->KeyIndex));
-
-               /* */
-               /* MIC Error */
-               /* */
-               if (pRxD->CipherErr == 2) {
-                       pWpaKey = &pAd->SharedKey[BSS0][pRxWI->KeyIndex];
-                       if (pAd->StaCfg.WpaSupplicantUP)
-                               WpaSendMicFailureToWpaSupplicant(pAd,
-                                                                (pWpaKey->
-                                                                 Type ==
-                                                                 PAIRWISEKEY) ?
-                                                                TRUE : FALSE);
-                       else
-                               RTMPReportMicError(pAd, pWpaKey);
-
-                       if (((pRxD->CipherErr & 2) == 2)
-                           && pAd->CommonCfg.bWirelessEvent && INFRA_ON(pAd))
-                               RTMPSendWirelessEvent(pAd,
-                                                     IW_MIC_ERROR_EVENT_FLAG,
-                                                     pAd->MacTab.
-                                                     Content[BSSID_WCID].Addr,
-                                                     BSS0, 0);
-
-                       DBGPRINT_RAW(RT_DEBUG_ERROR, ("Rx MIC Value error\n"));
-               }
-
-               if (pHeader == NULL)
-                       return (NDIS_STATUS_SUCCESS);
-               /*if ((pRxD->CipherAlg == CIPHER_AES) &&
-                  (pHeader->Sequence == pAd->FragFrame.Sequence))
-                  {
-                  //
-                  // Acceptable since the First FragFrame no CipherErr problem.
-                  //
-                  return(NDIS_STATUS_SUCCESS);
-                  } */
-
-               return (NDIS_STATUS_FAILURE);
-       }
-
-       return (NDIS_STATUS_SUCCESS);
-}
-
-BOOLEAN RTMPFreeTXDUponTxDmaDone(struct rt_rtmp_adapter *pAd, u8 QueIdx)
-{
-       struct rt_rtmp_tx_ring *pTxRing;
-       struct rt_txd * pTxD;
-       void *pPacket;
-       u8 FREE = 0;
-       struct rt_txd TxD, *pOriTxD;
-       /*unsigned long         IrqFlags; */
-       BOOLEAN bReschedule = FALSE;
-
-       ASSERT(QueIdx < NUM_OF_TX_RING);
-       pTxRing = &pAd->TxRing[QueIdx];
-
-       RTMP_IO_READ32(pAd, TX_DTX_IDX0 + QueIdx * RINGREG_DIFF,
-                      &pTxRing->TxDmaIdx);
-       while (pTxRing->TxSwFreeIdx != pTxRing->TxDmaIdx) {
-/*              RTMP_IRQ_LOCK(&pAd->irq_lock, IrqFlags); */
-
-               /* static rate also need NICUpdateFifoStaCounters() function. */
-               /*if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_TX_RATE_SWITCH_ENABLED)) */
-               NICUpdateFifoStaCounters(pAd);
-
-               /* Note : If (pAd->ate.bQATxStart == TRUE), we will never reach here. */
-               FREE++;
-               pTxD =
-                   (struct rt_txd *) (pTxRing->Cell[pTxRing->TxSwFreeIdx].AllocVa);
-               pOriTxD = pTxD;
-               NdisMoveMemory(&TxD, pTxD, sizeof(struct rt_txd));
-               pTxD = &TxD;
-
-               pTxD->DMADONE = 0;
-
-               {
-                       pPacket =
-                           pTxRing->Cell[pTxRing->TxSwFreeIdx].pNdisPacket;
-                       if (pPacket) {
-                               PCI_UNMAP_SINGLE(pAd, pTxD->SDPtr1,
-                                                pTxD->SDLen1,
-                                                PCI_DMA_TODEVICE);
-                               RELEASE_NDIS_PACKET(pAd, pPacket,
-                                                   NDIS_STATUS_SUCCESS);
-                       }
-                       /*Always assign pNdisPacket as NULL after clear */
-                       pTxRing->Cell[pTxRing->TxSwFreeIdx].pNdisPacket = NULL;
-
-                       pPacket =
-                           pTxRing->Cell[pTxRing->TxSwFreeIdx].pNextNdisPacket;
-
-                       ASSERT(pPacket == NULL);
-                       if (pPacket) {
-                               PCI_UNMAP_SINGLE(pAd, pTxD->SDPtr1,
-                                                pTxD->SDLen1,
-                                                PCI_DMA_TODEVICE);
-                               RELEASE_NDIS_PACKET(pAd, pPacket,
-                                                   NDIS_STATUS_SUCCESS);
-                       }
-                       /*Always assign pNextNdisPacket as NULL after clear */
-                       pTxRing->Cell[pTxRing->TxSwFreeIdx].pNextNdisPacket =
-                           NULL;
-               }
-
-               pAd->RalinkCounters.TransmittedByteCount +=
-                   (pTxD->SDLen1 + pTxD->SDLen0);
-               pAd->RalinkCounters.OneSecDmaDoneCount[QueIdx]++;
-               INC_RING_INDEX(pTxRing->TxSwFreeIdx, TX_RING_SIZE);
-               /* get tx_tdx_idx again */
-               RTMP_IO_READ32(pAd, TX_DTX_IDX0 + QueIdx * RINGREG_DIFF,
-                              &pTxRing->TxDmaIdx);
-               NdisMoveMemory(pOriTxD, pTxD, sizeof(struct rt_txd));
-
-/*         RTMP_IRQ_UNLOCK(&pAd->irq_lock, IrqFlags); */
-       }
-
-       return bReschedule;
-
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Process TX Rings DMA Done interrupt, running in DPC level
-
-       Arguments:
-               Adapter         Pointer to our adapter
-
-       Return Value:
-               None
-
-       IRQL = DISPATCH_LEVEL
-
-       ========================================================================
-*/
-BOOLEAN RTMPHandleTxRingDmaDoneInterrupt(struct rt_rtmp_adapter *pAd,
-                                        INT_SOURCE_CSR_STRUC TxRingBitmap)
-{
-/*      u8                   Count = 0; */
-       unsigned long IrqFlags;
-       BOOLEAN bReschedule = FALSE;
-
-       /* Make sure Tx ring resource won't be used by other threads */
-       /*NdisAcquireSpinLock(&pAd->TxRingLock); */
-
-       RTMP_IRQ_LOCK(&pAd->irq_lock, IrqFlags);
-
-       if (TxRingBitmap.field.Ac0DmaDone)
-               bReschedule = RTMPFreeTXDUponTxDmaDone(pAd, QID_AC_BE);
-
-       if (TxRingBitmap.field.Ac3DmaDone)
-               bReschedule |= RTMPFreeTXDUponTxDmaDone(pAd, QID_AC_VO);
-
-       if (TxRingBitmap.field.Ac2DmaDone)
-               bReschedule |= RTMPFreeTXDUponTxDmaDone(pAd, QID_AC_VI);
-
-       if (TxRingBitmap.field.Ac1DmaDone)
-               bReschedule |= RTMPFreeTXDUponTxDmaDone(pAd, QID_AC_BK);
-
-       /* Make sure to release Tx ring resource */
-       /*NdisReleaseSpinLock(&pAd->TxRingLock); */
-       RTMP_IRQ_UNLOCK(&pAd->irq_lock, IrqFlags);
-
-       /* Dequeue outgoing frames from TxSwQueue[] and process it */
-       RTMPDeQueuePacket(pAd, FALSE, NUM_OF_TX_RING, MAX_TX_PROCESS);
-
-       return bReschedule;
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Process MGMT ring DMA done interrupt, running in DPC level
-
-       Arguments:
-               pAd     Pointer to our adapter
-
-       Return Value:
-               None
-
-       IRQL = DISPATCH_LEVEL
-
-       Note:
-
-       ========================================================================
-*/
-void RTMPHandleMgmtRingDmaDoneInterrupt(struct rt_rtmp_adapter *pAd)
-{
-       struct rt_txd * pTxD;
-       void *pPacket;
-/*      int              i; */
-       u8 FREE = 0;
-       struct rt_rtmp_mgmt_ring *pMgmtRing = &pAd->MgmtRing;
-
-       NdisAcquireSpinLock(&pAd->MgmtRingLock);
-
-       RTMP_IO_READ32(pAd, TX_MGMTDTX_IDX, &pMgmtRing->TxDmaIdx);
-       while (pMgmtRing->TxSwFreeIdx != pMgmtRing->TxDmaIdx) {
-               FREE++;
-               pTxD =
-                   (struct rt_txd *) (pMgmtRing->Cell[pAd->MgmtRing.TxSwFreeIdx].
-                                 AllocVa);
-               pTxD->DMADONE = 0;
-               pPacket = pMgmtRing->Cell[pMgmtRing->TxSwFreeIdx].pNdisPacket;
-
-               if (pPacket) {
-                       PCI_UNMAP_SINGLE(pAd, pTxD->SDPtr0, pTxD->SDLen0,
-                                        PCI_DMA_TODEVICE);
-                       RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_SUCCESS);
-               }
-               pMgmtRing->Cell[pMgmtRing->TxSwFreeIdx].pNdisPacket = NULL;
-
-               pPacket =
-                   pMgmtRing->Cell[pMgmtRing->TxSwFreeIdx].pNextNdisPacket;
-               if (pPacket) {
-                       PCI_UNMAP_SINGLE(pAd, pTxD->SDPtr1, pTxD->SDLen1,
-                                        PCI_DMA_TODEVICE);
-                       RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_SUCCESS);
-               }
-               pMgmtRing->Cell[pMgmtRing->TxSwFreeIdx].pNextNdisPacket = NULL;
-               INC_RING_INDEX(pMgmtRing->TxSwFreeIdx, MGMT_RING_SIZE);
-
-       }
-       NdisReleaseSpinLock(&pAd->MgmtRingLock);
-
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-       Arguments:
-               Adapter         Pointer to our adapter. Dequeue all power safe delayed braodcast frames after beacon.
-
-       IRQL = DISPATCH_LEVEL
-
-       ========================================================================
-*/
-void RTMPHandleTBTTInterrupt(struct rt_rtmp_adapter *pAd)
-{
-       {
-               if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE)) {
-               }
-       }
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-       Arguments:
-               pAd             Pointer to our adapter. Rewrite beacon content before next send-out.
-
-       IRQL = DISPATCH_LEVEL
-
-       ========================================================================
-*/
-void RTMPHandlePreTBTTInterrupt(struct rt_rtmp_adapter *pAd)
-{
-       {
-               if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE)) {
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("RTMPHandlePreTBTTInterrupt...\n"));
-               }
-       }
-
-}
-
-void RTMPHandleRxCoherentInterrupt(struct rt_rtmp_adapter *pAd)
-{
-       WPDMA_GLO_CFG_STRUC GloCfg;
-
-       if (pAd == NULL) {
-               DBGPRINT(RT_DEBUG_TRACE, ("====> pAd is NULL, return.\n"));
-               return;
-       }
-
-       DBGPRINT(RT_DEBUG_TRACE, ("==> RTMPHandleRxCoherentInterrupt \n"));
-
-       RTMP_IO_READ32(pAd, WPDMA_GLO_CFG, &GloCfg.word);
-
-       GloCfg.field.EnTXWriteBackDDONE = 0;
-       GloCfg.field.EnableRxDMA = 0;
-       GloCfg.field.EnableTxDMA = 0;
-       RTMP_IO_WRITE32(pAd, WPDMA_GLO_CFG, GloCfg.word);
-
-       RTMPRingCleanUp(pAd, QID_AC_BE);
-       RTMPRingCleanUp(pAd, QID_AC_BK);
-       RTMPRingCleanUp(pAd, QID_AC_VI);
-       RTMPRingCleanUp(pAd, QID_AC_VO);
-       RTMPRingCleanUp(pAd, QID_MGMT);
-       RTMPRingCleanUp(pAd, QID_RX);
-
-       RTMPEnableRxTx(pAd);
-
-       DBGPRINT(RT_DEBUG_TRACE, ("<== RTMPHandleRxCoherentInterrupt \n"));
-}
-
-void *GetPacketFromRxRing(struct rt_rtmp_adapter *pAd,
-                                OUT PRT28XX_RXD_STRUC pSaveRxD,
-                                OUT BOOLEAN * pbReschedule,
-                                IN u32 * pRxPending)
-{
-       struct rt_rxd * pRxD;
-       void *pRxPacket = NULL;
-       void *pNewPacket;
-       void *AllocVa;
-       dma_addr_t AllocPa;
-       BOOLEAN bReschedule = FALSE;
-       struct rt_rtmp_dmacb *pRxCell;
-
-       RTMP_SEM_LOCK(&pAd->RxRingLock);
-
-       if (*pRxPending == 0) {
-               /* Get how may packets had been received */
-               RTMP_IO_READ32(pAd, RX_DRX_IDX, &pAd->RxRing.RxDmaIdx);
-
-               if (pAd->RxRing.RxSwReadIdx == pAd->RxRing.RxDmaIdx) {
-                       /* no more rx packets */
-                       bReschedule = FALSE;
-                       goto done;
-               }
-               /* get rx pending count */
-               if (pAd->RxRing.RxDmaIdx > pAd->RxRing.RxSwReadIdx)
-                       *pRxPending =
-                           pAd->RxRing.RxDmaIdx - pAd->RxRing.RxSwReadIdx;
-               else
-                       *pRxPending =
-                           pAd->RxRing.RxDmaIdx + RX_RING_SIZE -
-                           pAd->RxRing.RxSwReadIdx;
-
-       }
-
-       pRxCell = &pAd->RxRing.Cell[pAd->RxRing.RxSwReadIdx];
-
-       /* Point to Rx indexed rx ring descriptor */
-       pRxD = (struct rt_rxd *) pRxCell->AllocVa;
-
-       if (pRxD->DDONE == 0) {
-               *pRxPending = 0;
-               /* DMAIndx had done but DDONE bit not ready */
-               bReschedule = TRUE;
-               goto done;
-       }
-
-       /* return rx descriptor */
-       NdisMoveMemory(pSaveRxD, pRxD, RXD_SIZE);
-
-       pNewPacket =
-           RTMP_AllocateRxPacketBuffer(pAd, RX_BUFFER_AGGRESIZE, FALSE,
-                                       &AllocVa, &AllocPa);
-
-       if (pNewPacket) {
-               /* unmap the rx buffer */
-               PCI_UNMAP_SINGLE(pAd, pRxCell->DmaBuf.AllocPa,
-                                pRxCell->DmaBuf.AllocSize, PCI_DMA_FROMDEVICE);
-               pRxPacket = pRxCell->pNdisPacket;
-
-               pRxCell->DmaBuf.AllocSize = RX_BUFFER_AGGRESIZE;
-               pRxCell->pNdisPacket = (void *)pNewPacket;
-               pRxCell->DmaBuf.AllocVa = AllocVa;
-               pRxCell->DmaBuf.AllocPa = AllocPa;
-               /* update SDP0 to new buffer of rx packet */
-               pRxD->SDP0 = AllocPa;
-       } else {
-               /*DBGPRINT(RT_DEBUG_TRACE,("No Rx Buffer\n")); */
-               pRxPacket = NULL;
-               bReschedule = TRUE;
-       }
-
-       pRxD->DDONE = 0;
-
-       /* had handled one rx packet */
-       *pRxPending = *pRxPending - 1;
-
-       /* update rx descriptor and kick rx */
-       INC_RING_INDEX(pAd->RxRing.RxSwReadIdx, RX_RING_SIZE);
-
-       pAd->RxRing.RxCpuIdx =
-           (pAd->RxRing.RxSwReadIdx ==
-            0) ? (RX_RING_SIZE - 1) : (pAd->RxRing.RxSwReadIdx - 1);
-       RTMP_IO_WRITE32(pAd, RX_CRX_IDX, pAd->RxRing.RxCpuIdx);
-
-done:
-       RTMP_SEM_UNLOCK(&pAd->RxRingLock);
-       *pbReschedule = bReschedule;
-       return pRxPacket;
-}
-
-int MlmeHardTransmitTxRing(struct rt_rtmp_adapter *pAd,
-                                  u8 QueIdx, void *pPacket)
-{
-       struct rt_packet_info PacketInfo;
-       u8 *pSrcBufVA;
-       u32 SrcBufLen;
-       struct rt_txd * pTxD;
-       struct rt_header_802_11 * pHeader_802_11;
-       BOOLEAN bAckRequired, bInsertTimestamp;
-       unsigned long SrcBufPA;
-       /*u8                 TxBufIdx; */
-       u8 MlmeRate;
-       unsigned long SwIdx = pAd->TxRing[QueIdx].TxCpuIdx;
-       struct rt_txwi * pFirstTxWI;
-       /*unsigned long i; */
-       /*HTTRANSMIT_SETTING    MlmeTransmit;   //Rate for this MGMT frame. */
-       unsigned long FreeNum;
-       struct rt_mac_table_entry *pMacEntry = NULL;
-
-       RTMP_QueryPacketInfo(pPacket, &PacketInfo, &pSrcBufVA, &SrcBufLen);
-
-       if (pSrcBufVA == NULL) {
-               /* The buffer shouldn't be NULL */
-               return NDIS_STATUS_FAILURE;
-       }
-       /* Make sure MGMT ring resource won't be used by other threads */
-       /*NdisAcquireSpinLock(&pAd->TxRingLock); */
-
-       FreeNum = GET_TXRING_FREENO(pAd, QueIdx);
-
-       if (FreeNum == 0) {
-               /*NdisReleaseSpinLock(&pAd->TxRingLock); */
-               return NDIS_STATUS_FAILURE;
-       }
-
-       SwIdx = pAd->TxRing[QueIdx].TxCpuIdx;
-
-       pTxD = (struct rt_txd *) pAd->TxRing[QueIdx].Cell[SwIdx].AllocVa;
-
-       if (pAd->TxRing[QueIdx].Cell[SwIdx].pNdisPacket) {
-               DBGPRINT(RT_DEBUG_OFF, ("MlmeHardTransmit Error\n"));
-               /*NdisReleaseSpinLock(&pAd->TxRingLock); */
-               return NDIS_STATUS_FAILURE;
-       }
-
-       {
-               /* outgoing frame always wakeup PHY to prevent frame lost */
-               /* if (pAd->StaCfg.Psm == PWR_SAVE) */
-               if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))
-                       AsicForceWakeup(pAd, TRUE);
-       }
-       pFirstTxWI = (struct rt_txwi *) pSrcBufVA;
-
-       pHeader_802_11 = (struct rt_header_802_11 *) (pSrcBufVA + TXWI_SIZE);
-       if (pHeader_802_11->Addr1[0] & 0x01) {
-               MlmeRate = pAd->CommonCfg.BasicMlmeRate;
-       } else {
-               MlmeRate = pAd->CommonCfg.MlmeRate;
-       }
-
-       if ((pHeader_802_11->FC.Type == BTYPE_DATA) &&
-           (pHeader_802_11->FC.SubType == SUBTYPE_QOS_NULL)) {
-               pMacEntry = MacTableLookup(pAd, pHeader_802_11->Addr1);
-       }
-       /* Verify Mlme rate for a / g bands. */
-       if ((pAd->LatchRfRegs.Channel > 14) && (MlmeRate < RATE_6))     /* 11A band */
-               MlmeRate = RATE_6;
-
-       /* */
-       /* Should not be hard code to set PwrMgmt to 0 (PWR_ACTIVE) */
-       /* Snice it's been set to 0 while on MgtMacHeaderInit */
-       /* By the way this will cause frame to be send on PWR_SAVE failed. */
-       /* */
-       /* */
-       /* In WMM-UAPSD, mlme frame should be set psm as power saving but probe request frame */
-       /* Data-Null packets also pass through MMRequest in RT2860, however, we hope control the psm bit to pass APSD */
-       if (pHeader_802_11->FC.Type != BTYPE_DATA) {
-               if ((pHeader_802_11->FC.SubType == SUBTYPE_PROBE_REQ)
-                   || !(pAd->CommonCfg.bAPSDCapable
-                        && pAd->CommonCfg.APEdcaParm.bAPSDCapable)) {
-                       pHeader_802_11->FC.PwrMgmt = PWR_ACTIVE;
-               } else {
-                       pHeader_802_11->FC.PwrMgmt =
-                           pAd->CommonCfg.bAPSDForcePowerSave;
-               }
-       }
-
-       bInsertTimestamp = FALSE;
-       if (pHeader_802_11->FC.Type == BTYPE_CNTL)      /* must be PS-POLL */
-       {
-               bAckRequired = FALSE;
-       } else                  /* BTYPE_MGMT or BTYPE_DATA(must be NULL frame) */
-       {
-               if (pHeader_802_11->Addr1[0] & 0x01)    /* MULTICAST, BROADCAST */
-               {
-                       bAckRequired = FALSE;
-                       pHeader_802_11->Duration = 0;
-               } else {
-                       bAckRequired = TRUE;
-                       pHeader_802_11->Duration =
-                           RTMPCalcDuration(pAd, MlmeRate, 14);
-                       if (pHeader_802_11->FC.SubType == SUBTYPE_PROBE_RSP) {
-                               bInsertTimestamp = TRUE;
-                       }
-               }
-       }
-       pHeader_802_11->Sequence = pAd->Sequence++;
-       if (pAd->Sequence > 0xfff)
-               pAd->Sequence = 0;
-       /* Before radar detection done, mgmt frame can not be sent but probe req */
-       /* Because we need to use probe req to trigger driver to send probe req in passive scan */
-       if ((pHeader_802_11->FC.SubType != SUBTYPE_PROBE_REQ)
-           && (pAd->CommonCfg.bIEEE80211H == 1)
-           && (pAd->CommonCfg.RadarDetect.RDMode != RD_NORMAL_MODE)) {
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("MlmeHardTransmit --> radar detect not in normal mode!\n"));
-               /*NdisReleaseSpinLock(&pAd->TxRingLock); */
-               return (NDIS_STATUS_FAILURE);
-       }
-       /* */
-       /* fill scatter-and-gather buffer list into TXD. Internally created NDIS PACKET */
-       /* should always has only one ohysical buffer, and the whole frame size equals */
-       /* to the first scatter buffer size */
-       /* */
-
-       /* Initialize TX Descriptor */
-       /* For inter-frame gap, the number is for this frame and next frame */
-       /* For MLME rate, we will fix as 2Mb to match other vendor's implement */
-/*      pAd->CommonCfg.MlmeTransmit.field.MODE = 1; */
-
-/* management frame doesn't need encryption. so use RESERVED_WCID no matter u are sending to specific wcid or not. */
-       /* Only beacon use Nseq=TRUE. So here we use Nseq=FALSE. */
-       if (pMacEntry == NULL) {
-               RTMPWriteTxWI(pAd, pFirstTxWI, FALSE, FALSE, bInsertTimestamp,
-                             FALSE, bAckRequired, FALSE, 0, RESERVED_WCID,
-                             (SrcBufLen - TXWI_SIZE), PID_MGMT, 0,
-                             (u8)pAd->CommonCfg.MlmeTransmit.field.MCS,
-                             IFS_BACKOFF, FALSE, &pAd->CommonCfg.MlmeTransmit);
-       } else {
-               RTMPWriteTxWI(pAd, pFirstTxWI, FALSE, FALSE,
-                             bInsertTimestamp, FALSE, bAckRequired, FALSE,
-                             0, pMacEntry->Aid, (SrcBufLen - TXWI_SIZE),
-                             pMacEntry->MaxHTPhyMode.field.MCS, 0,
-                             (u8)pMacEntry->MaxHTPhyMode.field.MCS,
-                             IFS_BACKOFF, FALSE, &pMacEntry->MaxHTPhyMode);
-       }
-
-       pAd->TxRing[QueIdx].Cell[SwIdx].pNdisPacket = pPacket;
-       pAd->TxRing[QueIdx].Cell[SwIdx].pNextNdisPacket = NULL;
-/*      pFirstTxWI->MPDUtotalByteCount = SrcBufLen - TXWI_SIZE; */
-       SrcBufPA =
-           PCI_MAP_SINGLE(pAd, pSrcBufVA, SrcBufLen, 0, PCI_DMA_TODEVICE);
-
-       RTMPWriteTxDescriptor(pAd, pTxD, TRUE, FIFO_EDCA);
-       pTxD->LastSec0 = 1;
-       pTxD->LastSec1 = 1;
-       pTxD->SDLen0 = SrcBufLen;
-       pTxD->SDLen1 = 0;
-       pTxD->SDPtr0 = SrcBufPA;
-       pTxD->DMADONE = 0;
-
-       pAd->RalinkCounters.KickTxCount++;
-       pAd->RalinkCounters.OneSecTxDoneCount++;
-
-       /* Increase TX_CTX_IDX, but write to register later. */
-       INC_RING_INDEX(pAd->TxRing[QueIdx].TxCpuIdx, TX_RING_SIZE);
-
-       RTMP_IO_WRITE32(pAd, TX_CTX_IDX0 + QueIdx * 0x10,
-                       pAd->TxRing[QueIdx].TxCpuIdx);
-
-       /* Make sure to release MGMT ring resource */
-/*      NdisReleaseSpinLock(&pAd->TxRingLock); */
-
-       return NDIS_STATUS_SUCCESS;
-}
-
-int MlmeDataHardTransmit(struct rt_rtmp_adapter *pAd,
-                                u8 QueIdx, void *pPacket)
-{
-       if ((pAd->CommonCfg.RadarDetect.RDMode != RD_NORMAL_MODE)
-           ) {
-               return NDIS_STATUS_FAILURE;
-       }
-
-       return MlmeHardTransmitTxRing(pAd, QueIdx, pPacket);
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Calculates the duration which is required to transmit out frames
-       with given size and specified rate.
-
-       Arguments:
-               pTxD            Pointer to transmit descriptor
-               Ack             Setting for Ack requirement bit
-               Fragment        Setting for Fragment bit
-               RetryMode       Setting for retry mode
-               Ifs             Setting for IFS gap
-               Rate            Setting for transmit rate
-               Service         Setting for service
-               Length          Frame length
-               TxPreamble      Short or Long preamble when using CCK rates
-               QueIdx - 0-3, according to 802.11e/d4.4 June/2003
-
-       Return Value:
-               None
-
-       IRQL = PASSIVE_LEVEL
-       IRQL = DISPATCH_LEVEL
-
-       ========================================================================
-*/
-void RTMPWriteTxDescriptor(struct rt_rtmp_adapter *pAd,
-                          struct rt_txd * pTxD,
-                          IN BOOLEAN bWIV, u8 QueueSEL)
-{
-       /* */
-       /* Always use Long preamble before verifiation short preamble functionality works well. */
-       /* Todo: remove the following line if short preamble functionality works */
-       /* */
-       OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_SHORT_PREAMBLE_INUSED);
-
-       pTxD->WIV = (bWIV) ? 1 : 0;
-       pTxD->QSEL = (QueueSEL);
-       /*RT2860c??  fixed using EDCA queue for test...  We doubt Queue1 has problem.  2006-09-26 Jan */
-       /*pTxD->QSEL= FIFO_EDCA; */
-       pTxD->DMADONE = 0;
-}
diff --git a/drivers/staging/rt2860/common/cmm_data_usb.c b/drivers/staging/rt2860/common/cmm_data_usb.c
deleted file mode 100644 (file)
index 83a62fa..0000000
+++ /dev/null
@@ -1,951 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-*/
-
-/*
-   All functions in this file must be USB-depended, or you should out your function
-       in other files.
-
-*/
-
-#ifdef RTMP_MAC_USB
-
-#include       "../rt_config.h"
-
-/*
-       We can do copy the frame into pTxContext when match following conditions.
-               =>
-               =>
-               =>
-*/
-static inline int RtmpUSBCanDoWrite(struct rt_rtmp_adapter *pAd,
-                                           u8 QueIdx,
-                                           struct rt_ht_tx_context *pHTTXContext)
-{
-       int canWrite = NDIS_STATUS_RESOURCES;
-
-       if (((pHTTXContext->CurWritePosition) <
-            pHTTXContext->NextBulkOutPosition)
-           && (pHTTXContext->CurWritePosition + LOCAL_TXBUF_SIZE) >
-           pHTTXContext->NextBulkOutPosition) {
-               DBGPRINT(RT_DEBUG_ERROR, ("RtmpUSBCanDoWrite c1!\n"));
-               RTUSB_SET_BULK_FLAG(pAd,
-                                   (fRTUSB_BULK_OUT_DATA_NORMAL << QueIdx));
-       } else if ((pHTTXContext->CurWritePosition == 8)
-                  && (pHTTXContext->NextBulkOutPosition < LOCAL_TXBUF_SIZE)) {
-               DBGPRINT(RT_DEBUG_ERROR, ("RtmpUSBCanDoWrite c2!\n"));
-               RTUSB_SET_BULK_FLAG(pAd,
-                                   (fRTUSB_BULK_OUT_DATA_NORMAL << QueIdx));
-       } else if (pHTTXContext->bCurWriting == TRUE) {
-               DBGPRINT(RT_DEBUG_ERROR, ("RtmpUSBCanDoWrite c3!\n"));
-       } else {
-               canWrite = NDIS_STATUS_SUCCESS;
-       }
-
-       return canWrite;
-}
-
-u16 RtmpUSB_WriteSubTxResource(struct rt_rtmp_adapter *pAd,
-                                 struct rt_tx_blk *pTxBlk,
-                                 IN BOOLEAN bIsLast, u16 * FreeNumber)
-{
-
-       /* Dummy function. Should be removed in the future. */
-       return 0;
-
-}
-
-u16 RtmpUSB_WriteFragTxResource(struct rt_rtmp_adapter *pAd,
-                                  struct rt_tx_blk *pTxBlk,
-                                  u8 fragNum, u16 * FreeNumber)
-{
-       struct rt_ht_tx_context *pHTTXContext;
-       u16 hwHdrLen;   /* The hwHdrLen consist of 802.11 header length plus the header padding length. */
-       u32 fillOffset;
-       struct rt_txinfo *pTxInfo;
-       struct rt_txwi *pTxWI;
-       u8 *pWirelessPacket = NULL;
-       u8 QueIdx;
-       int Status;
-       unsigned long IrqFlags;
-       u32 USBDMApktLen = 0, DMAHdrLen, padding;
-       BOOLEAN TxQLastRound = FALSE;
-
-       /* */
-       /* get Tx Ring Resource & Dma Buffer address */
-       /* */
-       QueIdx = pTxBlk->QueIdx;
-       pHTTXContext = &pAd->TxContext[QueIdx];
-
-       RTMP_IRQ_LOCK(&pAd->TxContextQueueLock[QueIdx], IrqFlags);
-
-       pHTTXContext = &pAd->TxContext[QueIdx];
-       fillOffset = pHTTXContext->CurWritePosition;
-
-       if (fragNum == 0) {
-               /* Check if we have enough space for this bulk-out batch. */
-               Status = RtmpUSBCanDoWrite(pAd, QueIdx, pHTTXContext);
-               if (Status == NDIS_STATUS_SUCCESS) {
-                       pHTTXContext->bCurWriting = TRUE;
-
-                       /* Reserve space for 8 bytes padding. */
-                       if ((pHTTXContext->ENextBulkOutPosition ==
-                            pHTTXContext->CurWritePosition)) {
-                               pHTTXContext->ENextBulkOutPosition += 8;
-                               pHTTXContext->CurWritePosition += 8;
-                               fillOffset += 8;
-                       }
-                       pTxBlk->Priv = 0;
-                       pHTTXContext->CurWriteRealPos =
-                           pHTTXContext->CurWritePosition;
-               } else {
-                       RTMP_IRQ_UNLOCK(&pAd->TxContextQueueLock[QueIdx],
-                                       IrqFlags);
-
-                       RELEASE_NDIS_PACKET(pAd, pTxBlk->pPacket,
-                                           NDIS_STATUS_FAILURE);
-                       return (Status);
-               }
-       } else {
-               /* For sub-sequent frames of this bulk-out batch. Just copy it to our bulk-out buffer. */
-               Status =
-                   ((pHTTXContext->bCurWriting ==
-                     TRUE) ? NDIS_STATUS_SUCCESS : NDIS_STATUS_FAILURE);
-               if (Status == NDIS_STATUS_SUCCESS) {
-                       fillOffset += pTxBlk->Priv;
-               } else {
-                       RTMP_IRQ_UNLOCK(&pAd->TxContextQueueLock[QueIdx],
-                                       IrqFlags);
-
-                       RELEASE_NDIS_PACKET(pAd, pTxBlk->pPacket,
-                                           NDIS_STATUS_FAILURE);
-                       return (Status);
-               }
-       }
-
-       NdisZeroMemory((u8 *)(&pTxBlk->HeaderBuf[0]), TXINFO_SIZE);
-       pTxInfo = (struct rt_txinfo *)(&pTxBlk->HeaderBuf[0]);
-       pTxWI = (struct rt_txwi *) (&pTxBlk->HeaderBuf[TXINFO_SIZE]);
-
-       pWirelessPacket =
-           &pHTTXContext->TransferBuffer->field.WirelessPacket[fillOffset];
-
-       /* copy TXWI + WLAN Header + LLC into DMA Header Buffer */
-       /*hwHdrLen = ROUND_UP(pTxBlk->MpduHeaderLen, 4); */
-       hwHdrLen = pTxBlk->MpduHeaderLen + pTxBlk->HdrPadLen;
-
-       /* Build our URB for USBD */
-       DMAHdrLen = TXWI_SIZE + hwHdrLen;
-       USBDMApktLen = DMAHdrLen + pTxBlk->SrcBufLen;
-       padding = (4 - (USBDMApktLen % 4)) & 0x03;      /* round up to 4 byte alignment */
-       USBDMApktLen += padding;
-
-       pTxBlk->Priv += (TXINFO_SIZE + USBDMApktLen);
-
-       /* For TxInfo, the length of USBDMApktLen = TXWI_SIZE + 802.11 header + payload */
-       RTMPWriteTxInfo(pAd, pTxInfo, (u16)(USBDMApktLen), FALSE, FIFO_EDCA,
-                       FALSE /*NextValid */ , FALSE);
-
-       if (fragNum == pTxBlk->TotalFragNum) {
-               pTxInfo->USBDMATxburst = 0;
-               if ((pHTTXContext->CurWritePosition + pTxBlk->Priv + 3906) >
-                   MAX_TXBULK_LIMIT) {
-                       pTxInfo->SwUseLastRound = 1;
-                       TxQLastRound = TRUE;
-               }
-       } else {
-               pTxInfo->USBDMATxburst = 1;
-       }
-
-       NdisMoveMemory(pWirelessPacket, pTxBlk->HeaderBuf,
-                      TXINFO_SIZE + TXWI_SIZE + hwHdrLen);
-       pWirelessPacket += (TXINFO_SIZE + TXWI_SIZE + hwHdrLen);
-       pHTTXContext->CurWriteRealPos += (TXINFO_SIZE + TXWI_SIZE + hwHdrLen);
-
-       RTMP_IRQ_UNLOCK(&pAd->TxContextQueueLock[QueIdx], IrqFlags);
-
-       NdisMoveMemory(pWirelessPacket, pTxBlk->pSrcBufData, pTxBlk->SrcBufLen);
-
-       /*      Zero the last padding. */
-       pWirelessPacket += pTxBlk->SrcBufLen;
-       NdisZeroMemory(pWirelessPacket, padding + 8);
-
-       if (fragNum == pTxBlk->TotalFragNum) {
-               RTMP_IRQ_LOCK(&pAd->TxContextQueueLock[QueIdx], IrqFlags);
-
-               /* Update the pHTTXContext->CurWritePosition. 3906 used to prevent the NextBulkOut is a A-RALINK/A-MSDU Frame. */
-               pHTTXContext->CurWritePosition += pTxBlk->Priv;
-               if (TxQLastRound == TRUE)
-                       pHTTXContext->CurWritePosition = 8;
-               pHTTXContext->CurWriteRealPos = pHTTXContext->CurWritePosition;
-
-               /* Finally, set bCurWriting as FALSE */
-               pHTTXContext->bCurWriting = FALSE;
-
-               RTMP_IRQ_UNLOCK(&pAd->TxContextQueueLock[QueIdx], IrqFlags);
-
-               /* succeed and release the skb buffer */
-               RELEASE_NDIS_PACKET(pAd, pTxBlk->pPacket, NDIS_STATUS_SUCCESS);
-       }
-
-       return (Status);
-
-}
-
-u16 RtmpUSB_WriteSingleTxResource(struct rt_rtmp_adapter *pAd,
-                                    struct rt_tx_blk *pTxBlk,
-                                    IN BOOLEAN bIsLast,
-                                    u16 * FreeNumber)
-{
-       struct rt_ht_tx_context *pHTTXContext;
-       u16 hwHdrLen;
-       u32 fillOffset;
-       struct rt_txinfo *pTxInfo;
-       struct rt_txwi *pTxWI;
-       u8 *pWirelessPacket;
-       u8 QueIdx;
-       unsigned long IrqFlags;
-       int Status;
-       u32 USBDMApktLen = 0, DMAHdrLen, padding;
-       BOOLEAN bTxQLastRound = FALSE;
-
-       /* For USB, didn't need PCI_MAP_SINGLE() */
-       /*SrcBufPA = PCI_MAP_SINGLE(pAd, (char *) pTxBlk->pSrcBufData, pTxBlk->SrcBufLen, PCI_DMA_TODEVICE); */
-
-       /* */
-       /* get Tx Ring Resource & Dma Buffer address */
-       /* */
-       QueIdx = pTxBlk->QueIdx;
-
-       RTMP_IRQ_LOCK(&pAd->TxContextQueueLock[QueIdx], IrqFlags);
-       pHTTXContext = &pAd->TxContext[QueIdx];
-       fillOffset = pHTTXContext->CurWritePosition;
-
-       /* Check ring full. */
-       Status = RtmpUSBCanDoWrite(pAd, QueIdx, pHTTXContext);
-       if (Status == NDIS_STATUS_SUCCESS) {
-               pHTTXContext->bCurWriting = TRUE;
-
-               pTxInfo = (struct rt_txinfo *)(&pTxBlk->HeaderBuf[0]);
-               pTxWI = (struct rt_txwi *) (&pTxBlk->HeaderBuf[TXINFO_SIZE]);
-
-               /* Reserve space for 8 bytes padding. */
-               if ((pHTTXContext->ENextBulkOutPosition ==
-                    pHTTXContext->CurWritePosition)) {
-                       pHTTXContext->ENextBulkOutPosition += 8;
-                       pHTTXContext->CurWritePosition += 8;
-                       fillOffset += 8;
-               }
-               pHTTXContext->CurWriteRealPos = pHTTXContext->CurWritePosition;
-
-               pWirelessPacket =
-                   &pHTTXContext->TransferBuffer->field.
-                   WirelessPacket[fillOffset];
-
-               /* copy TXWI + WLAN Header + LLC into DMA Header Buffer */
-               /*hwHdrLen = ROUND_UP(pTxBlk->MpduHeaderLen, 4); */
-               hwHdrLen = pTxBlk->MpduHeaderLen + pTxBlk->HdrPadLen;
-
-               /* Build our URB for USBD */
-               DMAHdrLen = TXWI_SIZE + hwHdrLen;
-               USBDMApktLen = DMAHdrLen + pTxBlk->SrcBufLen;
-               padding = (4 - (USBDMApktLen % 4)) & 0x03;      /* round up to 4 byte alignment */
-               USBDMApktLen += padding;
-
-               pTxBlk->Priv = (TXINFO_SIZE + USBDMApktLen);
-
-               /* For TxInfo, the length of USBDMApktLen = TXWI_SIZE + 802.11 header + payload */
-               RTMPWriteTxInfo(pAd, pTxInfo, (u16)(USBDMApktLen), FALSE,
-                               FIFO_EDCA, FALSE /*NextValid */ , FALSE);
-
-               if ((pHTTXContext->CurWritePosition + 3906 + pTxBlk->Priv) >
-                   MAX_TXBULK_LIMIT) {
-                       pTxInfo->SwUseLastRound = 1;
-                       bTxQLastRound = TRUE;
-               }
-               NdisMoveMemory(pWirelessPacket, pTxBlk->HeaderBuf,
-                              TXINFO_SIZE + TXWI_SIZE + hwHdrLen);
-               pWirelessPacket += (TXINFO_SIZE + TXWI_SIZE + hwHdrLen);
-
-               /* We unlock it here to prevent the first 8 bytes maybe over-writed issue. */
-               /*      1. First we got CurWritePosition but the first 8 bytes still not write to the pTxcontext. */
-               /*      2. An interrupt break our routine and handle bulk-out complete. */
-               /*      3. In the bulk-out compllete, it need to do another bulk-out, */
-               /*                      if the ENextBulkOutPosition is just the same as CurWritePosition, it will save the first 8 bytes from CurWritePosition, */
-               /*                      but the payload still not copyed. the pTxContext->SavedPad[] will save as allzero. and set the bCopyPad = TRUE. */
-               /*      4. Interrupt complete. */
-               /*  5. Our interrupted routine go back and fill the first 8 bytes to pTxContext. */
-               /*      6. Next time when do bulk-out, it found the bCopyPad==TRUE and will copy the SavedPad[] to pTxContext->NextBulkOutPosition. */
-               /*              and the packet will wrong. */
-               pHTTXContext->CurWriteRealPos +=
-                   (TXINFO_SIZE + TXWI_SIZE + hwHdrLen);
-               RTMP_IRQ_UNLOCK(&pAd->TxContextQueueLock[QueIdx], IrqFlags);
-
-               NdisMoveMemory(pWirelessPacket, pTxBlk->pSrcBufData,
-                              pTxBlk->SrcBufLen);
-               pWirelessPacket += pTxBlk->SrcBufLen;
-               NdisZeroMemory(pWirelessPacket, padding + 8);
-
-               RTMP_IRQ_LOCK(&pAd->TxContextQueueLock[QueIdx], IrqFlags);
-
-               pHTTXContext->CurWritePosition += pTxBlk->Priv;
-               if (bTxQLastRound)
-                       pHTTXContext->CurWritePosition = 8;
-               pHTTXContext->CurWriteRealPos = pHTTXContext->CurWritePosition;
-
-               pHTTXContext->bCurWriting = FALSE;
-       }
-
-       RTMP_IRQ_UNLOCK(&pAd->TxContextQueueLock[QueIdx], IrqFlags);
-
-       /* succeed and release the skb buffer */
-       RELEASE_NDIS_PACKET(pAd, pTxBlk->pPacket, NDIS_STATUS_SUCCESS);
-
-       return (Status);
-
-}
-
-u16 RtmpUSB_WriteMultiTxResource(struct rt_rtmp_adapter *pAd,
-                                   struct rt_tx_blk *pTxBlk,
-                                   u8 frameNum, u16 * FreeNumber)
-{
-       struct rt_ht_tx_context *pHTTXContext;
-       u16 hwHdrLen;   /* The hwHdrLen consist of 802.11 header length plus the header padding length. */
-       u32 fillOffset;
-       struct rt_txinfo *pTxInfo;
-       struct rt_txwi *pTxWI;
-       u8 *pWirelessPacket = NULL;
-       u8 QueIdx;
-       int Status;
-       unsigned long IrqFlags;
-       /*u32                        USBDMApktLen = 0, DMAHdrLen, padding; */
-
-       /* */
-       /* get Tx Ring Resource & Dma Buffer address */
-       /* */
-       QueIdx = pTxBlk->QueIdx;
-       pHTTXContext = &pAd->TxContext[QueIdx];
-
-       RTMP_IRQ_LOCK(&pAd->TxContextQueueLock[QueIdx], IrqFlags);
-
-       if (frameNum == 0) {
-               /* Check if we have enough space for this bulk-out batch. */
-               Status = RtmpUSBCanDoWrite(pAd, QueIdx, pHTTXContext);
-               if (Status == NDIS_STATUS_SUCCESS) {
-                       pHTTXContext->bCurWriting = TRUE;
-
-                       pTxInfo = (struct rt_txinfo *)(&pTxBlk->HeaderBuf[0]);
-                       pTxWI = (struct rt_txwi *) (&pTxBlk->HeaderBuf[TXINFO_SIZE]);
-
-                       /* Reserve space for 8 bytes padding. */
-                       if ((pHTTXContext->ENextBulkOutPosition ==
-                            pHTTXContext->CurWritePosition)) {
-
-                               pHTTXContext->CurWritePosition += 8;
-                               pHTTXContext->ENextBulkOutPosition += 8;
-                       }
-                       fillOffset = pHTTXContext->CurWritePosition;
-                       pHTTXContext->CurWriteRealPos =
-                           pHTTXContext->CurWritePosition;
-
-                       pWirelessPacket =
-                           &pHTTXContext->TransferBuffer->field.
-                           WirelessPacket[fillOffset];
-
-                       /* */
-                       /* Copy TXINFO + TXWI + WLAN Header + LLC into DMA Header Buffer */
-                       /* */
-                       if (pTxBlk->TxFrameType == TX_AMSDU_FRAME)
-                               /*hwHdrLen = ROUND_UP(pTxBlk->MpduHeaderLen-LENGTH_AMSDU_SUBFRAMEHEAD, 4)+LENGTH_AMSDU_SUBFRAMEHEAD; */
-                               hwHdrLen =
-                                   pTxBlk->MpduHeaderLen -
-                                   LENGTH_AMSDU_SUBFRAMEHEAD +
-                                   pTxBlk->HdrPadLen +
-                                   LENGTH_AMSDU_SUBFRAMEHEAD;
-                       else if (pTxBlk->TxFrameType == TX_RALINK_FRAME)
-                               /*hwHdrLen = ROUND_UP(pTxBlk->MpduHeaderLen-LENGTH_ARALINK_HEADER_FIELD, 4)+LENGTH_ARALINK_HEADER_FIELD; */
-                               hwHdrLen =
-                                   pTxBlk->MpduHeaderLen -
-                                   LENGTH_ARALINK_HEADER_FIELD +
-                                   pTxBlk->HdrPadLen +
-                                   LENGTH_ARALINK_HEADER_FIELD;
-                       else
-                               /*hwHdrLen = ROUND_UP(pTxBlk->MpduHeaderLen, 4); */
-                               hwHdrLen =
-                                   pTxBlk->MpduHeaderLen + pTxBlk->HdrPadLen;
-
-                       /* Update the pTxBlk->Priv. */
-                       pTxBlk->Priv = TXINFO_SIZE + TXWI_SIZE + hwHdrLen;
-
-                       /*      pTxInfo->USBDMApktLen now just a temp value and will to correct latter. */
-                       RTMPWriteTxInfo(pAd, pTxInfo, (u16)(pTxBlk->Priv),
-                                       FALSE, FIFO_EDCA, FALSE /*NextValid */ ,
-                                       FALSE);
-
-                       /* Copy it. */
-                       NdisMoveMemory(pWirelessPacket, pTxBlk->HeaderBuf,
-                                      pTxBlk->Priv);
-                       pHTTXContext->CurWriteRealPos += pTxBlk->Priv;
-                       pWirelessPacket += pTxBlk->Priv;
-               }
-       } else {                /* For sub-sequent frames of this bulk-out batch. Just copy it to our bulk-out buffer. */
-
-               Status =
-                   ((pHTTXContext->bCurWriting ==
-                     TRUE) ? NDIS_STATUS_SUCCESS : NDIS_STATUS_FAILURE);
-               if (Status == NDIS_STATUS_SUCCESS) {
-                       fillOffset =
-                           (pHTTXContext->CurWritePosition + pTxBlk->Priv);
-                       pWirelessPacket =
-                           &pHTTXContext->TransferBuffer->field.
-                           WirelessPacket[fillOffset];
-
-                       /*hwHdrLen = pTxBlk->MpduHeaderLen; */
-                       NdisMoveMemory(pWirelessPacket, pTxBlk->HeaderBuf,
-                                      pTxBlk->MpduHeaderLen);
-                       pWirelessPacket += (pTxBlk->MpduHeaderLen);
-                       pTxBlk->Priv += pTxBlk->MpduHeaderLen;
-               } else {        /* It should not happened now unless we are going to shutdown. */
-                       DBGPRINT(RT_DEBUG_ERROR,
-                                ("WriteMultiTxResource():bCurWriting is FALSE when handle sub-sequent frames.\n"));
-                       Status = NDIS_STATUS_FAILURE;
-               }
-       }
-
-       /* We unlock it here to prevent the first 8 bytes maybe over-write issue. */
-       /*      1. First we got CurWritePosition but the first 8 bytes still not write to the pTxContext. */
-       /*      2. An interrupt break our routine and handle bulk-out complete. */
-       /*      3. In the bulk-out compllete, it need to do another bulk-out, */
-       /*                      if the ENextBulkOutPosition is just the same as CurWritePosition, it will save the first 8 bytes from CurWritePosition, */
-       /*                      but the payload still not copyed. the pTxContext->SavedPad[] will save as allzero. and set the bCopyPad = TRUE. */
-       /*      4. Interrupt complete. */
-       /*  5. Our interrupted routine go back and fill the first 8 bytes to pTxContext. */
-       /*      6. Next time when do bulk-out, it found the bCopyPad==TRUE and will copy the SavedPad[] to pTxContext->NextBulkOutPosition. */
-       /*              and the packet will wrong. */
-       RTMP_IRQ_UNLOCK(&pAd->TxContextQueueLock[QueIdx], IrqFlags);
-
-       if (Status != NDIS_STATUS_SUCCESS) {
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("WriteMultiTxResource: CWPos = %ld, NBOutPos = %ld.\n",
-                         pHTTXContext->CurWritePosition,
-                         pHTTXContext->NextBulkOutPosition));
-               goto done;
-       }
-       /* Copy the frame content into DMA buffer and update the pTxBlk->Priv */
-       NdisMoveMemory(pWirelessPacket, pTxBlk->pSrcBufData, pTxBlk->SrcBufLen);
-       pWirelessPacket += pTxBlk->SrcBufLen;
-       pTxBlk->Priv += pTxBlk->SrcBufLen;
-
-done:
-       /* Release the skb buffer here */
-       RELEASE_NDIS_PACKET(pAd, pTxBlk->pPacket, NDIS_STATUS_SUCCESS);
-
-       return (Status);
-
-}
-
-void RtmpUSB_FinalWriteTxResource(struct rt_rtmp_adapter *pAd,
-                                 struct rt_tx_blk *pTxBlk,
-                                 u16 totalMPDUSize, u16 TxIdx)
-{
-       u8 QueIdx;
-       struct rt_ht_tx_context *pHTTXContext;
-       u32 fillOffset;
-       struct rt_txinfo *pTxInfo;
-       struct rt_txwi *pTxWI;
-       u32 USBDMApktLen, padding;
-       unsigned long IrqFlags;
-       u8 *pWirelessPacket;
-
-       QueIdx = pTxBlk->QueIdx;
-       pHTTXContext = &pAd->TxContext[QueIdx];
-
-       RTMP_IRQ_LOCK(&pAd->TxContextQueueLock[QueIdx], IrqFlags);
-
-       if (pHTTXContext->bCurWriting == TRUE) {
-               fillOffset = pHTTXContext->CurWritePosition;
-               if (((pHTTXContext->ENextBulkOutPosition ==
-                     pHTTXContext->CurWritePosition)
-                    || ((pHTTXContext->ENextBulkOutPosition - 8) ==
-                        pHTTXContext->CurWritePosition))
-                   && (pHTTXContext->bCopySavePad == TRUE))
-                       pWirelessPacket = (u8 *)(&pHTTXContext->SavedPad[0]);
-               else
-                       pWirelessPacket =
-                           (u8 *)(&pHTTXContext->TransferBuffer->field.
-                                     WirelessPacket[fillOffset]);
-
-               /* */
-               /* Update TxInfo->USBDMApktLen , */
-               /*              the length = TXWI_SIZE + 802.11_hdr + 802.11_hdr_pad + payload_of_all_batch_frames + Bulk-Out-padding */
-               /* */
-               pTxInfo = (struct rt_txinfo *)(pWirelessPacket);
-
-               /* Calculate the bulk-out padding */
-               USBDMApktLen = pTxBlk->Priv - TXINFO_SIZE;
-               padding = (4 - (USBDMApktLen % 4)) & 0x03;      /* round up to 4 byte alignment */
-               USBDMApktLen += padding;
-
-               pTxInfo->USBDMATxPktLen = USBDMApktLen;
-
-               /* */
-               /* Update TXWI->MPDUtotalByteCount , */
-               /*              the length = 802.11 header + payload_of_all_batch_frames */
-               pTxWI = (struct rt_txwi *) (pWirelessPacket + TXINFO_SIZE);
-               pTxWI->MPDUtotalByteCount = totalMPDUSize;
-
-               /* */
-               /* Update the pHTTXContext->CurWritePosition */
-               /* */
-               pHTTXContext->CurWritePosition += (TXINFO_SIZE + USBDMApktLen);
-               if ((pHTTXContext->CurWritePosition + 3906) > MAX_TXBULK_LIMIT) {       /* Add 3906 for prevent the NextBulkOut packet size is a A-RALINK/A-MSDU Frame. */
-                       pHTTXContext->CurWritePosition = 8;
-                       pTxInfo->SwUseLastRound = 1;
-               }
-               pHTTXContext->CurWriteRealPos = pHTTXContext->CurWritePosition;
-
-               /* */
-               /*      Zero the last padding. */
-               /* */
-               pWirelessPacket =
-                   (&pHTTXContext->TransferBuffer->field.
-                    WirelessPacket[fillOffset + pTxBlk->Priv]);
-               NdisZeroMemory(pWirelessPacket, padding + 8);
-
-               /* Finally, set bCurWriting as FALSE */
-               pHTTXContext->bCurWriting = FALSE;
-
-       } else {                /* It should not happened now unless we are going to shutdown. */
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("FinalWriteTxResource():bCurWriting is FALSE when handle last frames.\n"));
-       }
-
-       RTMP_IRQ_UNLOCK(&pAd->TxContextQueueLock[QueIdx], IrqFlags);
-
-}
-
-void RtmpUSBDataLastTxIdx(struct rt_rtmp_adapter *pAd,
-                         u8 QueIdx, u16 TxIdx)
-{
-       /* DO nothing for USB. */
-}
-
-/*
-       When can do bulk-out:
-               1. TxSwFreeIdx < TX_RING_SIZE;
-                       It means has at least one Ring entity is ready for bulk-out, kick it out.
-               2. If TxSwFreeIdx == TX_RING_SIZE
-                       Check if the CurWriting flag is FALSE, if it's FALSE, we can do kick out.
-
-*/
-void RtmpUSBDataKickOut(struct rt_rtmp_adapter *pAd,
-                       struct rt_tx_blk *pTxBlk, u8 QueIdx)
-{
-       RTUSB_SET_BULK_FLAG(pAd, (fRTUSB_BULK_OUT_DATA_NORMAL << QueIdx));
-       RTUSBKickBulkOut(pAd);
-
-}
-
-/*
-       Must be run in Interrupt context
-       This function handle RT2870 specific TxDesc and cpu index update and kick the packet out.
- */
-int RtmpUSBMgmtKickOut(struct rt_rtmp_adapter *pAd,
-                      u8 QueIdx,
-                      void *pPacket,
-                      u8 *pSrcBufVA, u32 SrcBufLen)
-{
-       struct rt_txinfo *pTxInfo;
-       unsigned long BulkOutSize;
-       u8 padLen;
-       u8 *pDest;
-       unsigned long SwIdx = pAd->MgmtRing.TxCpuIdx;
-       struct rt_tx_context *pMLMEContext =
-           (struct rt_tx_context *)pAd->MgmtRing.Cell[SwIdx].AllocVa;
-       unsigned long IrqFlags;
-
-       pTxInfo = (struct rt_txinfo *)(pSrcBufVA);
-
-       /* Build our URB for USBD */
-       BulkOutSize = SrcBufLen;
-       BulkOutSize = (BulkOutSize + 3) & (~3);
-       RTMPWriteTxInfo(pAd, pTxInfo, (u16)(BulkOutSize - TXINFO_SIZE),
-                       TRUE, EpToQueue[MGMTPIPEIDX], FALSE, FALSE);
-
-       BulkOutSize += 4;       /* Always add 4 extra bytes at every packet. */
-
-       /* If BulkOutSize is multiple of BulkOutMaxPacketSize, add extra 4 bytes again. */
-       if ((BulkOutSize % pAd->BulkOutMaxPacketSize) == 0)
-               BulkOutSize += 4;
-
-       padLen = BulkOutSize - SrcBufLen;
-       ASSERT((padLen <= RTMP_PKT_TAIL_PADDING));
-
-       /* Now memzero all extra padding bytes. */
-       pDest = (u8 *)(pSrcBufVA + SrcBufLen);
-       skb_put(GET_OS_PKT_TYPE(pPacket), padLen);
-       NdisZeroMemory(pDest, padLen);
-
-       RTMP_IRQ_LOCK(&pAd->MLMEBulkOutLock, IrqFlags);
-
-       pAd->MgmtRing.Cell[pAd->MgmtRing.TxCpuIdx].pNdisPacket = pPacket;
-       pMLMEContext->TransferBuffer =
-           (struct rt_tx_buffer *)(GET_OS_PKT_DATAPTR(pPacket));
-
-       /* Length in TxInfo should be 8 less than bulkout size. */
-       pMLMEContext->BulkOutSize = BulkOutSize;
-       pMLMEContext->InUse = TRUE;
-       pMLMEContext->bWaitingBulkOut = TRUE;
-
-       /*for debug */
-       /*hex_dump("RtmpUSBMgmtKickOut", &pMLMEContext->TransferBuffer->field.WirelessPacket[0], (pMLMEContext->BulkOutSize > 16 ? 16 : pMLMEContext->BulkOutSize)); */
-
-       /*pAd->RalinkCounters.KickTxCount++; */
-       /*pAd->RalinkCounters.OneSecTxDoneCount++; */
-
-       /*if (pAd->MgmtRing.TxSwFreeIdx == MGMT_RING_SIZE) */
-       /*      needKickOut = TRUE; */
-
-       /* Decrease the TxSwFreeIdx and Increase the TX_CTX_IDX */
-       pAd->MgmtRing.TxSwFreeIdx--;
-       INC_RING_INDEX(pAd->MgmtRing.TxCpuIdx, MGMT_RING_SIZE);
-
-       RTMP_IRQ_UNLOCK(&pAd->MLMEBulkOutLock, IrqFlags);
-
-       RTUSB_SET_BULK_FLAG(pAd, fRTUSB_BULK_OUT_MLME);
-       /*if (needKickOut) */
-       RTUSBKickBulkOut(pAd);
-
-       return 0;
-}
-
-void RtmpUSBNullFrameKickOut(struct rt_rtmp_adapter *pAd,
-                            u8 QueIdx,
-                            u8 * pNullFrame, u32 frameLen)
-{
-       if (pAd->NullContext.InUse == FALSE) {
-               struct rt_tx_context *pNullContext;
-               struct rt_txinfo *pTxInfo;
-               struct rt_txwi * pTxWI;
-               u8 *pWirelessPkt;
-
-               pNullContext = &(pAd->NullContext);
-
-               /* Set the in use bit */
-               pNullContext->InUse = TRUE;
-               pWirelessPkt =
-                   (u8 *)& pNullContext->TransferBuffer->field.
-                   WirelessPacket[0];
-
-               RTMPZeroMemory(&pWirelessPkt[0], 100);
-               pTxInfo = (struct rt_txinfo *)& pWirelessPkt[0];
-               RTMPWriteTxInfo(pAd, pTxInfo,
-                               (u16)(sizeof(struct rt_header_802_11) + TXWI_SIZE),
-                               TRUE, EpToQueue[MGMTPIPEIDX], FALSE, FALSE);
-               pTxInfo->QSEL = FIFO_EDCA;
-               pTxWI = (struct rt_txwi *) & pWirelessPkt[TXINFO_SIZE];
-               RTMPWriteTxWI(pAd, pTxWI, FALSE, FALSE, FALSE, FALSE, TRUE,
-                             FALSE, 0, BSSID_WCID, (sizeof(struct rt_header_802_11)), 0,
-                             0, (u8)pAd->CommonCfg.MlmeTransmit.field.MCS,
-                             IFS_HTTXOP, FALSE, &pAd->CommonCfg.MlmeTransmit);
-
-               RTMPMoveMemory(&pWirelessPkt[TXWI_SIZE + TXINFO_SIZE],
-                              &pAd->NullFrame, sizeof(struct rt_header_802_11));
-               pAd->NullContext.BulkOutSize =
-                   TXINFO_SIZE + TXWI_SIZE + sizeof(pAd->NullFrame) + 4;
-
-               /* Fill out frame length information for global Bulk out arbitor */
-               /*pNullContext->BulkOutSize = TransferBufferLength; */
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("SYNC - send NULL Frame @%d Mbps...\n",
-                         RateIdToMbps[pAd->CommonCfg.TxRate]));
-               RTUSB_SET_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_NULL);
-
-               /* Kick bulk out */
-               RTUSBKickBulkOut(pAd);
-       }
-
-}
-
-/*
-========================================================================
-Routine Description:
-    Get a received packet.
-
-Arguments:
-       pAd                                     device control block
-       pSaveRxD                        receive descriptor information
-       *pbReschedule           need reschedule flag
-       *pRxPending                     pending received packet flag
-
-Return Value:
-    the received packet
-
-Note:
-========================================================================
-*/
-void *GetPacketFromRxRing(struct rt_rtmp_adapter *pAd,
-                                OUT PRT28XX_RXD_STRUC pSaveRxD,
-                                OUT BOOLEAN * pbReschedule,
-                                IN u32 * pRxPending)
-{
-       struct rt_rx_context *pRxContext;
-       void *pSkb;
-       u8 *pData;
-       unsigned long ThisFrameLen;
-       unsigned long RxBufferLength;
-       struct rt_rxwi * pRxWI;
-
-       pRxContext = &pAd->RxContext[pAd->NextRxBulkInReadIndex];
-       if ((pRxContext->Readable == FALSE) || (pRxContext->InUse == TRUE))
-               return NULL;
-
-       RxBufferLength = pRxContext->BulkInOffset - pAd->ReadPosition;
-       if (RxBufferLength <
-           (RT2870_RXDMALEN_FIELD_SIZE + sizeof(struct rt_rxwi) +
-            sizeof(struct rt_rxinfo))) {
-               goto label_null;
-       }
-
-       pData = &pRxContext->TransferBuffer[pAd->ReadPosition]; /* 4KB */
-       /* The RXDMA field is 4 bytes, now just use the first 2 bytes. The Length including the (RXWI + MSDU + Padding) */
-       ThisFrameLen = *pData + (*(pData + 1) << 8);
-       if (ThisFrameLen == 0) {
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("BIRIdx(%d): RXDMALen is zero.[%ld], BulkInBufLen = %ld)\n",
-                         pAd->NextRxBulkInReadIndex, ThisFrameLen,
-                         pRxContext->BulkInOffset));
-               goto label_null;
-       }
-       if ((ThisFrameLen & 0x3) != 0) {
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("BIRIdx(%d): RXDMALen not multiple of 4.[%ld], BulkInBufLen = %ld)\n",
-                         pAd->NextRxBulkInReadIndex, ThisFrameLen,
-                         pRxContext->BulkInOffset));
-               goto label_null;
-       }
-
-       if ((ThisFrameLen + 8) > RxBufferLength)        /* 8 for (RT2870_RXDMALEN_FIELD_SIZE + sizeof(struct rt_rxinfo)) */
-       {
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("BIRIdx(%d):FrameLen(0x%lx) outranges. BulkInLen=0x%lx, remaining RxBufLen=0x%lx, ReadPos=0x%lx\n",
-                         pAd->NextRxBulkInReadIndex, ThisFrameLen,
-                         pRxContext->BulkInOffset, RxBufferLength,
-                         pAd->ReadPosition));
-
-               /* error frame. finish this loop */
-               goto label_null;
-       }
-       /* skip USB frame length field */
-       pData += RT2870_RXDMALEN_FIELD_SIZE;
-       pRxWI = (struct rt_rxwi *) pData;
-       if (pRxWI->MPDUtotalByteCount > ThisFrameLen) {
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("%s():pRxWIMPDUtotalByteCount(%d) large than RxDMALen(%ld)\n",
-                         __FUNCTION__, pRxWI->MPDUtotalByteCount,
-                         ThisFrameLen));
-               goto label_null;
-       }
-       /* allocate a rx packet */
-       pSkb = dev_alloc_skb(ThisFrameLen);
-       if (pSkb == NULL) {
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("%s():Cannot Allocate sk buffer for this Bulk-In buffer!\n",
-                         __FUNCTION__));
-               goto label_null;
-       }
-       /* copy the rx packet */
-       memcpy(skb_put(pSkb, ThisFrameLen), pData, ThisFrameLen);
-       RTPKT_TO_OSPKT(pSkb)->dev = get_netdev_from_bssid(pAd, BSS0);
-       RTMP_SET_PACKET_SOURCE(OSPKT_TO_RTPKT(pSkb), PKTSRC_NDIS);
-
-       /* copy RxD */
-       *pSaveRxD = *(struct rt_rxinfo *) (pData + ThisFrameLen);
-
-       /* update next packet read position. */
-       pAd->ReadPosition += (ThisFrameLen + RT2870_RXDMALEN_FIELD_SIZE + RXINFO_SIZE); /* 8 for (RT2870_RXDMALEN_FIELD_SIZE + sizeof(struct rt_rxinfo)) */
-
-       return pSkb;
-
-label_null:
-
-       return NULL;
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Check Rx descriptor, return NDIS_STATUS_FAILURE if any error dound
-
-       Arguments:
-               pRxD            Pointer to the Rx descriptor
-
-       Return Value:
-               NDIS_STATUS_SUCCESS             No err
-               NDIS_STATUS_FAILURE             Error
-
-       Note:
-
-       ========================================================================
-*/
-int RTMPCheckRxError(struct rt_rtmp_adapter *pAd,
-                            struct rt_header_802_11 * pHeader,
-                            struct rt_rxwi * pRxWI, IN PRT28XX_RXD_STRUC pRxINFO)
-{
-       struct rt_cipher_key *pWpaKey;
-       int dBm;
-
-       if (pAd->bPromiscuous == TRUE)
-               return (NDIS_STATUS_SUCCESS);
-       if (pRxINFO == NULL)
-               return (NDIS_STATUS_FAILURE);
-
-       /* Phy errors & CRC errors */
-       if (pRxINFO->Crc) {
-               /* Check RSSI for Noise Hist statistic collection. */
-               dBm = (int)(pRxWI->RSSI0) - pAd->BbpRssiToDbmDelta;
-               if (dBm <= -87)
-                       pAd->StaCfg.RPIDensity[0] += 1;
-               else if (dBm <= -82)
-                       pAd->StaCfg.RPIDensity[1] += 1;
-               else if (dBm <= -77)
-                       pAd->StaCfg.RPIDensity[2] += 1;
-               else if (dBm <= -72)
-                       pAd->StaCfg.RPIDensity[3] += 1;
-               else if (dBm <= -67)
-                       pAd->StaCfg.RPIDensity[4] += 1;
-               else if (dBm <= -62)
-                       pAd->StaCfg.RPIDensity[5] += 1;
-               else if (dBm <= -57)
-                       pAd->StaCfg.RPIDensity[6] += 1;
-               else if (dBm > -57)
-                       pAd->StaCfg.RPIDensity[7] += 1;
-
-               return (NDIS_STATUS_FAILURE);
-       }
-       /* Add Rx size to channel load counter, we should ignore error counts */
-       pAd->StaCfg.CLBusyBytes += (pRxWI->MPDUtotalByteCount + 14);
-
-       /* Drop ToDs promiscuous frame, it is opened due to CCX 2 channel load statistics */
-       if (pHeader->FC.ToDs) {
-               DBGPRINT_RAW(RT_DEBUG_ERROR, ("Err;FC.ToDs\n"));
-               return NDIS_STATUS_FAILURE;
-       }
-       /* Paul 04-03 for OFDM Rx length issue */
-       if (pRxWI->MPDUtotalByteCount > MAX_AGGREGATION_SIZE) {
-               DBGPRINT_RAW(RT_DEBUG_ERROR, ("received packet too long\n"));
-               return NDIS_STATUS_FAILURE;
-       }
-       /* Drop not U2M frames, can't drop here because we will drop beacon in this case */
-       /* I am kind of doubting the U2M bit operation */
-       /* if (pRxD->U2M == 0) */
-       /*      return(NDIS_STATUS_FAILURE); */
-
-       /* drop decyption fail frame */
-       if (pRxINFO->Decrypted && pRxINFO->CipherErr) {
-
-               if (((pRxINFO->CipherErr & 1) == 1)
-                   && pAd->CommonCfg.bWirelessEvent && INFRA_ON(pAd))
-                       RTMPSendWirelessEvent(pAd, IW_ICV_ERROR_EVENT_FLAG,
-                                             pAd->MacTab.Content[BSSID_WCID].
-                                             Addr, BSS0, 0);
-
-               if (((pRxINFO->CipherErr & 2) == 2)
-                   && pAd->CommonCfg.bWirelessEvent && INFRA_ON(pAd))
-                       RTMPSendWirelessEvent(pAd, IW_MIC_ERROR_EVENT_FLAG,
-                                             pAd->MacTab.Content[BSSID_WCID].
-                                             Addr, BSS0, 0);
-               /* */
-               /* MIC Error */
-               /* */
-               if ((pRxINFO->CipherErr == 2) && pRxINFO->MyBss) {
-                       pWpaKey = &pAd->SharedKey[BSS0][pRxWI->KeyIndex];
-                       RTMPReportMicError(pAd, pWpaKey);
-                       DBGPRINT_RAW(RT_DEBUG_ERROR, ("Rx MIC Value error\n"));
-               }
-
-               if (pRxINFO->Decrypted &&
-                   (pAd->SharedKey[BSS0][pRxWI->KeyIndex].CipherAlg ==
-                    CIPHER_AES)
-                   && (pHeader->Sequence == pAd->FragFrame.Sequence)) {
-                       /* */
-                       /* Acceptable since the First FragFrame no CipherErr problem. */
-                       /* */
-                       return (NDIS_STATUS_SUCCESS);
-               }
-
-               return (NDIS_STATUS_FAILURE);
-       }
-
-       return (NDIS_STATUS_SUCCESS);
-}
-
-void RtmpUsbStaAsicForceWakeupTimeout(void *SystemSpecific1,
-                                     void *FunctionContext,
-                                     void *SystemSpecific2,
-                                     void *SystemSpecific3)
-{
-       struct rt_rtmp_adapter *pAd = (struct rt_rtmp_adapter *)FunctionContext;
-
-       if (pAd && pAd->Mlme.AutoWakeupTimerRunning) {
-               AsicSendCommandToMcu(pAd, 0x31, 0xff, 0x00, 0x02);
-
-               OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_DOZE);
-               pAd->Mlme.AutoWakeupTimerRunning = FALSE;
-       }
-}
-
-void RT28xxUsbStaAsicForceWakeup(struct rt_rtmp_adapter *pAd, IN BOOLEAN bFromTx)
-{
-       BOOLEAN Canceled;
-
-       if (pAd->Mlme.AutoWakeupTimerRunning)
-               RTMPCancelTimer(&pAd->Mlme.AutoWakeupTimer, &Canceled);
-
-       AsicSendCommandToMcu(pAd, 0x31, 0xff, 0x00, 0x02);
-
-       OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_DOZE);
-}
-
-void RT28xxUsbStaAsicSleepThenAutoWakeup(struct rt_rtmp_adapter *pAd,
-                                        u16 TbttNumToNextWakeUp)
-{
-
-       /* we have decided to SLEEP, so at least do it for a BEACON period. */
-       if (TbttNumToNextWakeUp == 0)
-               TbttNumToNextWakeUp = 1;
-
-       RTMPSetTimer(&pAd->Mlme.AutoWakeupTimer, AUTO_WAKEUP_TIMEOUT);
-       pAd->Mlme.AutoWakeupTimerRunning = TRUE;
-
-       AsicSendCommandToMcu(pAd, 0x30, 0xff, 0xff, 0x02);      /* send POWER-SAVE command to MCU. Timeout 40us. */
-
-       OPSTATUS_SET_FLAG(pAd, fOP_STATUS_DOZE);
-
-}
-
-#endif /* RTMP_MAC_USB // */
diff --git a/drivers/staging/rt2860/common/cmm_info.c b/drivers/staging/rt2860/common/cmm_info.c
deleted file mode 100644 (file)
index 25302e8..0000000
+++ /dev/null
@@ -1,955 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
- */
-
-#include <linux/sched.h>
-#include "../rt_config.h"
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Remove WPA Key process
-
-       Arguments:
-               pAd                                     Pointer to our adapter
-               pBuf                                                    Pointer to the where the key stored
-
-       Return Value:
-               NDIS_SUCCESS                                    Add key successfully
-
-       IRQL = DISPATCH_LEVEL
-
-       Note:
-
-       ========================================================================
-*/
-void RTMPSetDesiredRates(struct rt_rtmp_adapter *pAdapter, long Rates)
-{
-       NDIS_802_11_RATES aryRates;
-
-       memset(&aryRates, 0x00, sizeof(NDIS_802_11_RATES));
-       switch (pAdapter->CommonCfg.PhyMode) {
-       case PHY_11A:           /* A only */
-               switch (Rates) {
-               case 6000000:   /*6M */
-                       aryRates[0] = 0x0c;     /* 6M */
-                       pAdapter->StaCfg.DesiredTransmitSetting.field.MCS =
-                           MCS_0;
-                       break;
-               case 9000000:   /*9M */
-                       aryRates[0] = 0x12;     /* 9M */
-                       pAdapter->StaCfg.DesiredTransmitSetting.field.MCS =
-                           MCS_1;
-                       break;
-               case 12000000:  /*12M */
-                       aryRates[0] = 0x18;     /* 12M */
-                       pAdapter->StaCfg.DesiredTransmitSetting.field.MCS =
-                           MCS_2;
-                       break;
-               case 18000000:  /*18M */
-                       aryRates[0] = 0x24;     /* 18M */
-                       pAdapter->StaCfg.DesiredTransmitSetting.field.MCS =
-                           MCS_3;
-                       break;
-               case 24000000:  /*24M */
-                       aryRates[0] = 0x30;     /* 24M */
-                       pAdapter->StaCfg.DesiredTransmitSetting.field.MCS =
-                           MCS_4;
-                       break;
-               case 36000000:  /*36M */
-                       aryRates[0] = 0x48;     /* 36M */
-                       pAdapter->StaCfg.DesiredTransmitSetting.field.MCS =
-                           MCS_5;
-                       break;
-               case 48000000:  /*48M */
-                       aryRates[0] = 0x60;     /* 48M */
-                       pAdapter->StaCfg.DesiredTransmitSetting.field.MCS =
-                           MCS_6;
-                       break;
-               case 54000000:  /*54M */
-                       aryRates[0] = 0x6c;     /* 54M */
-                       pAdapter->StaCfg.DesiredTransmitSetting.field.MCS =
-                           MCS_7;
-                       break;
-               case -1:        /*Auto */
-               default:
-                       aryRates[0] = 0x6c;     /* 54Mbps */
-                       aryRates[1] = 0x60;     /* 48Mbps */
-                       aryRates[2] = 0x48;     /* 36Mbps */
-                       aryRates[3] = 0x30;     /* 24Mbps */
-                       aryRates[4] = 0x24;     /* 18M */
-                       aryRates[5] = 0x18;     /* 12M */
-                       aryRates[6] = 0x12;     /* 9M */
-                       aryRates[7] = 0x0c;     /* 6M */
-                       pAdapter->StaCfg.DesiredTransmitSetting.field.MCS =
-                           MCS_AUTO;
-                       break;
-               }
-               break;
-       case PHY_11BG_MIXED:    /* B/G Mixed */
-       case PHY_11B:           /* B only */
-       case PHY_11ABG_MIXED:   /* A/B/G Mixed */
-       default:
-               switch (Rates) {
-               case 1000000:   /*1M */
-                       aryRates[0] = 0x02;
-                       pAdapter->StaCfg.DesiredTransmitSetting.field.MCS =
-                           MCS_0;
-                       break;
-               case 2000000:   /*2M */
-                       aryRates[0] = 0x04;
-                       pAdapter->StaCfg.DesiredTransmitSetting.field.MCS =
-                           MCS_1;
-                       break;
-               case 5000000:   /*5.5M */
-                       aryRates[0] = 0x0b;     /* 5.5M */
-                       pAdapter->StaCfg.DesiredTransmitSetting.field.MCS =
-                           MCS_2;
-                       break;
-               case 11000000:  /*11M */
-                       aryRates[0] = 0x16;     /* 11M */
-                       pAdapter->StaCfg.DesiredTransmitSetting.field.MCS =
-                           MCS_3;
-                       break;
-               case 6000000:   /*6M */
-                       aryRates[0] = 0x0c;     /* 6M */
-                       pAdapter->StaCfg.DesiredTransmitSetting.field.MCS =
-                           MCS_0;
-                       break;
-               case 9000000:   /*9M */
-                       aryRates[0] = 0x12;     /* 9M */
-                       pAdapter->StaCfg.DesiredTransmitSetting.field.MCS =
-                           MCS_1;
-                       break;
-               case 12000000:  /*12M */
-                       aryRates[0] = 0x18;     /* 12M */
-                       pAdapter->StaCfg.DesiredTransmitSetting.field.MCS =
-                           MCS_2;
-                       break;
-               case 18000000:  /*18M */
-                       aryRates[0] = 0x24;     /* 18M */
-                       pAdapter->StaCfg.DesiredTransmitSetting.field.MCS =
-                           MCS_3;
-                       break;
-               case 24000000:  /*24M */
-                       aryRates[0] = 0x30;     /* 24M */
-                       pAdapter->StaCfg.DesiredTransmitSetting.field.MCS =
-                           MCS_4;
-                       break;
-               case 36000000:  /*36M */
-                       aryRates[0] = 0x48;     /* 36M */
-                       pAdapter->StaCfg.DesiredTransmitSetting.field.MCS =
-                           MCS_5;
-                       break;
-               case 48000000:  /*48M */
-                       aryRates[0] = 0x60;     /* 48M */
-                       pAdapter->StaCfg.DesiredTransmitSetting.field.MCS =
-                           MCS_6;
-                       break;
-               case 54000000:  /*54M */
-                       aryRates[0] = 0x6c;     /* 54M */
-                       pAdapter->StaCfg.DesiredTransmitSetting.field.MCS =
-                           MCS_7;
-                       break;
-               case -1:        /*Auto */
-               default:
-                       if (pAdapter->CommonCfg.PhyMode == PHY_11B) {   /*B Only */
-                               aryRates[0] = 0x16;     /* 11Mbps */
-                               aryRates[1] = 0x0b;     /* 5.5Mbps */
-                               aryRates[2] = 0x04;     /* 2Mbps */
-                               aryRates[3] = 0x02;     /* 1Mbps */
-                       } else {        /*(B/G) Mixed or (A/B/G) Mixed */
-                               aryRates[0] = 0x6c;     /* 54Mbps */
-                               aryRates[1] = 0x60;     /* 48Mbps */
-                               aryRates[2] = 0x48;     /* 36Mbps */
-                               aryRates[3] = 0x30;     /* 24Mbps */
-                               aryRates[4] = 0x16;     /* 11Mbps */
-                               aryRates[5] = 0x0b;     /* 5.5Mbps */
-                               aryRates[6] = 0x04;     /* 2Mbps */
-                               aryRates[7] = 0x02;     /* 1Mbps */
-                       }
-                       pAdapter->StaCfg.DesiredTransmitSetting.field.MCS =
-                           MCS_AUTO;
-                       break;
-               }
-               break;
-       }
-
-       NdisZeroMemory(pAdapter->CommonCfg.DesireRate,
-                      MAX_LEN_OF_SUPPORTED_RATES);
-       NdisMoveMemory(pAdapter->CommonCfg.DesireRate, &aryRates,
-                      sizeof(NDIS_802_11_RATES));
-       DBGPRINT(RT_DEBUG_TRACE,
-                (" RTMPSetDesiredRates (%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x)\n",
-                 pAdapter->CommonCfg.DesireRate[0],
-                 pAdapter->CommonCfg.DesireRate[1],
-                 pAdapter->CommonCfg.DesireRate[2],
-                 pAdapter->CommonCfg.DesireRate[3],
-                 pAdapter->CommonCfg.DesireRate[4],
-                 pAdapter->CommonCfg.DesireRate[5],
-                 pAdapter->CommonCfg.DesireRate[6],
-                 pAdapter->CommonCfg.DesireRate[7]));
-       /* Changing DesiredRate may affect the MAX TX rate we used to TX frames out */
-       MlmeUpdateTxRates(pAdapter, FALSE, 0);
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Remove All WPA Keys
-
-       Arguments:
-               pAd                                     Pointer to our adapter
-
-       Return Value:
-               None
-
-       IRQL = DISPATCH_LEVEL
-
-       Note:
-
-       ========================================================================
-*/
-void RTMPWPARemoveAllKeys(struct rt_rtmp_adapter *pAd)
-{
-
-       u8 i;
-
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("RTMPWPARemoveAllKeys(AuthMode=%d, WepStatus=%d)\n",
-                 pAd->StaCfg.AuthMode, pAd->StaCfg.WepStatus));
-       RTMP_CLEAR_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
-       /* For WEP/CKIP, there is no need to remove it, since WinXP won't set it again after */
-       /* Link up. And it will be replaced if user changed it. */
-       if (pAd->StaCfg.AuthMode < Ndis802_11AuthModeWPA)
-               return;
-
-       /* For WPA-None, there is no need to remove it, since WinXP won't set it again after */
-       /* Link up. And it will be replaced if user changed it. */
-       if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
-               return;
-
-       /* set BSSID wcid entry of the Pair-wise Key table as no-security mode */
-       AsicRemovePairwiseKeyEntry(pAd, BSS0, BSSID_WCID);
-
-       /* set all shared key mode as no-security. */
-       for (i = 0; i < SHARE_KEY_NUM; i++) {
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("remove %s key #%d\n",
-                         CipherName[pAd->SharedKey[BSS0][i].CipherAlg], i));
-               NdisZeroMemory(&pAd->SharedKey[BSS0][i], sizeof(struct rt_cipher_key));
-
-               AsicRemoveSharedKeyEntry(pAd, BSS0, i);
-       }
-       RTMP_SET_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               As STA's BSSID is a WC too, it uses shared key table.
-               This function write correct unicast TX key to ASIC WCID.
-               And we still make a copy in our MacTab.Content[BSSID_WCID].PairwiseKey.
-               Caller guarantee TKIP/AES always has keyidx = 0. (pairwise key)
-               Caller guarantee WEP calls this function when set Txkey,  default key index=0~3.
-
-       Arguments:
-               pAd                                     Pointer to our adapter
-               pKey                                                    Pointer to the where the key stored
-
-       Return Value:
-               NDIS_SUCCESS                                    Add key successfully
-
-       IRQL = DISPATCH_LEVEL
-
-       Note:
-
-       ========================================================================
-*/
-/*
-       ========================================================================
-       Routine Description:
-               Change NIC PHY mode. Re-association may be necessary. possible settings
-               include - PHY_11B, PHY_11BG_MIXED, PHY_11A, and PHY_11ABG_MIXED
-
-       Arguments:
-               pAd - Pointer to our adapter
-               phymode  -
-
-       IRQL = PASSIVE_LEVEL
-       IRQL = DISPATCH_LEVEL
-
-       ========================================================================
-*/
-void RTMPSetPhyMode(struct rt_rtmp_adapter *pAd, unsigned long phymode)
-{
-       int i;
-       /* the selected phymode must be supported by the RF IC encoded in E2PROM */
-
-       /* if no change, do nothing */
-       /* bug fix
-          if (pAd->CommonCfg.PhyMode == phymode)
-          return;
-        */
-       pAd->CommonCfg.PhyMode = (u8)phymode;
-
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("RTMPSetPhyMode : PhyMode=%d, channel=%d \n",
-                 pAd->CommonCfg.PhyMode, pAd->CommonCfg.Channel));
-
-       BuildChannelList(pAd);
-
-       /* sanity check user setting */
-       for (i = 0; i < pAd->ChannelListNum; i++) {
-               if (pAd->CommonCfg.Channel == pAd->ChannelList[i].Channel)
-                       break;
-       }
-
-       if (i == pAd->ChannelListNum) {
-               pAd->CommonCfg.Channel = FirstChannel(pAd);
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("RTMPSetPhyMode: channel is out of range, use first channel=%d \n",
-                         pAd->CommonCfg.Channel));
-       }
-
-       NdisZeroMemory(pAd->CommonCfg.SupRate, MAX_LEN_OF_SUPPORTED_RATES);
-       NdisZeroMemory(pAd->CommonCfg.ExtRate, MAX_LEN_OF_SUPPORTED_RATES);
-       NdisZeroMemory(pAd->CommonCfg.DesireRate, MAX_LEN_OF_SUPPORTED_RATES);
-       switch (phymode) {
-       case PHY_11B:
-               pAd->CommonCfg.SupRate[0] = 0x82;       /* 1 mbps, in units of 0.5 Mbps, basic rate */
-               pAd->CommonCfg.SupRate[1] = 0x84;       /* 2 mbps, in units of 0.5 Mbps, basic rate */
-               pAd->CommonCfg.SupRate[2] = 0x8B;       /* 5.5 mbps, in units of 0.5 Mbps, basic rate */
-               pAd->CommonCfg.SupRate[3] = 0x96;       /* 11 mbps, in units of 0.5 Mbps, basic rate */
-               pAd->CommonCfg.SupRateLen = 4;
-               pAd->CommonCfg.ExtRateLen = 0;
-               pAd->CommonCfg.DesireRate[0] = 2;       /* 1 mbps, in units of 0.5 Mbps */
-               pAd->CommonCfg.DesireRate[1] = 4;       /* 2 mbps, in units of 0.5 Mbps */
-               pAd->CommonCfg.DesireRate[2] = 11;      /* 5.5 mbps, in units of 0.5 Mbps */
-               pAd->CommonCfg.DesireRate[3] = 22;      /* 11 mbps, in units of 0.5 Mbps */
-               /*pAd->CommonCfg.HTPhyMode.field.MODE = MODE_CCK; // This MODE is only FYI. not use */
-               break;
-
-       case PHY_11G:
-       case PHY_11BG_MIXED:
-       case PHY_11ABG_MIXED:
-       case PHY_11N_2_4G:
-       case PHY_11ABGN_MIXED:
-       case PHY_11BGN_MIXED:
-       case PHY_11GN_MIXED:
-               pAd->CommonCfg.SupRate[0] = 0x82;       /* 1 mbps, in units of 0.5 Mbps, basic rate */
-               pAd->CommonCfg.SupRate[1] = 0x84;       /* 2 mbps, in units of 0.5 Mbps, basic rate */
-               pAd->CommonCfg.SupRate[2] = 0x8B;       /* 5.5 mbps, in units of 0.5 Mbps, basic rate */
-               pAd->CommonCfg.SupRate[3] = 0x96;       /* 11 mbps, in units of 0.5 Mbps, basic rate */
-               pAd->CommonCfg.SupRate[4] = 0x12;       /* 9 mbps, in units of 0.5 Mbps */
-               pAd->CommonCfg.SupRate[5] = 0x24;       /* 18 mbps, in units of 0.5 Mbps */
-               pAd->CommonCfg.SupRate[6] = 0x48;       /* 36 mbps, in units of 0.5 Mbps */
-               pAd->CommonCfg.SupRate[7] = 0x6c;       /* 54 mbps, in units of 0.5 Mbps */
-               pAd->CommonCfg.SupRateLen = 8;
-               pAd->CommonCfg.ExtRate[0] = 0x0C;       /* 6 mbps, in units of 0.5 Mbps */
-               pAd->CommonCfg.ExtRate[1] = 0x18;       /* 12 mbps, in units of 0.5 Mbps */
-               pAd->CommonCfg.ExtRate[2] = 0x30;       /* 24 mbps, in units of 0.5 Mbps */
-               pAd->CommonCfg.ExtRate[3] = 0x60;       /* 48 mbps, in units of 0.5 Mbps */
-               pAd->CommonCfg.ExtRateLen = 4;
-               pAd->CommonCfg.DesireRate[0] = 2;       /* 1 mbps, in units of 0.5 Mbps */
-               pAd->CommonCfg.DesireRate[1] = 4;       /* 2 mbps, in units of 0.5 Mbps */
-               pAd->CommonCfg.DesireRate[2] = 11;      /* 5.5 mbps, in units of 0.5 Mbps */
-               pAd->CommonCfg.DesireRate[3] = 22;      /* 11 mbps, in units of 0.5 Mbps */
-               pAd->CommonCfg.DesireRate[4] = 12;      /* 6 mbps, in units of 0.5 Mbps */
-               pAd->CommonCfg.DesireRate[5] = 18;      /* 9 mbps, in units of 0.5 Mbps */
-               pAd->CommonCfg.DesireRate[6] = 24;      /* 12 mbps, in units of 0.5 Mbps */
-               pAd->CommonCfg.DesireRate[7] = 36;      /* 18 mbps, in units of 0.5 Mbps */
-               pAd->CommonCfg.DesireRate[8] = 48;      /* 24 mbps, in units of 0.5 Mbps */
-               pAd->CommonCfg.DesireRate[9] = 72;      /* 36 mbps, in units of 0.5 Mbps */
-               pAd->CommonCfg.DesireRate[10] = 96;     /* 48 mbps, in units of 0.5 Mbps */
-               pAd->CommonCfg.DesireRate[11] = 108;    /* 54 mbps, in units of 0.5 Mbps */
-               break;
-
-       case PHY_11A:
-       case PHY_11AN_MIXED:
-       case PHY_11AGN_MIXED:
-       case PHY_11N_5G:
-               pAd->CommonCfg.SupRate[0] = 0x8C;       /* 6 mbps, in units of 0.5 Mbps, basic rate */
-               pAd->CommonCfg.SupRate[1] = 0x12;       /* 9 mbps, in units of 0.5 Mbps */
-               pAd->CommonCfg.SupRate[2] = 0x98;       /* 12 mbps, in units of 0.5 Mbps, basic rate */
-               pAd->CommonCfg.SupRate[3] = 0x24;       /* 18 mbps, in units of 0.5 Mbps */
-               pAd->CommonCfg.SupRate[4] = 0xb0;       /* 24 mbps, in units of 0.5 Mbps, basic rate */
-               pAd->CommonCfg.SupRate[5] = 0x48;       /* 36 mbps, in units of 0.5 Mbps */
-               pAd->CommonCfg.SupRate[6] = 0x60;       /* 48 mbps, in units of 0.5 Mbps */
-               pAd->CommonCfg.SupRate[7] = 0x6c;       /* 54 mbps, in units of 0.5 Mbps */
-               pAd->CommonCfg.SupRateLen = 8;
-               pAd->CommonCfg.ExtRateLen = 0;
-               pAd->CommonCfg.DesireRate[0] = 12;      /* 6 mbps, in units of 0.5 Mbps */
-               pAd->CommonCfg.DesireRate[1] = 18;      /* 9 mbps, in units of 0.5 Mbps */
-               pAd->CommonCfg.DesireRate[2] = 24;      /* 12 mbps, in units of 0.5 Mbps */
-               pAd->CommonCfg.DesireRate[3] = 36;      /* 18 mbps, in units of 0.5 Mbps */
-               pAd->CommonCfg.DesireRate[4] = 48;      /* 24 mbps, in units of 0.5 Mbps */
-               pAd->CommonCfg.DesireRate[5] = 72;      /* 36 mbps, in units of 0.5 Mbps */
-               pAd->CommonCfg.DesireRate[6] = 96;      /* 48 mbps, in units of 0.5 Mbps */
-               pAd->CommonCfg.DesireRate[7] = 108;     /* 54 mbps, in units of 0.5 Mbps */
-               /*pAd->CommonCfg.HTPhyMode.field.MODE = MODE_OFDM; // This MODE is only FYI. not use */
-               break;
-
-       default:
-               break;
-       }
-
-       pAd->CommonCfg.BandState = UNKNOWN_BAND;
-}
-
-/*
-       ========================================================================
-       Routine Description:
-               Caller ensures we has 802.11n support.
-               Calls at setting HT from AP/STASetinformation
-
-       Arguments:
-               pAd - Pointer to our adapter
-               phymode  -
-
-       ========================================================================
-*/
-void RTMPSetHT(struct rt_rtmp_adapter *pAd, struct rt_oid_set_ht_phymode *pHTPhyMode)
-{
-       /*unsigned long *pmcs; */
-       u32 Value = 0;
-       u8 BBPValue = 0;
-       u8 BBP3Value = 0;
-       u8 RxStream = pAd->CommonCfg.RxStream;
-
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("RTMPSetHT : HT_mode(%d), ExtOffset(%d), MCS(%d), BW(%d), STBC(%d), SHORTGI(%d)\n",
-                 pHTPhyMode->HtMode, pHTPhyMode->ExtOffset, pHTPhyMode->MCS,
-                 pHTPhyMode->BW, pHTPhyMode->STBC, pHTPhyMode->SHORTGI));
-
-       /* Don't zero supportedHyPhy structure. */
-       RTMPZeroMemory(&pAd->CommonCfg.HtCapability,
-                      sizeof(pAd->CommonCfg.HtCapability));
-       RTMPZeroMemory(&pAd->CommonCfg.AddHTInfo,
-                      sizeof(pAd->CommonCfg.AddHTInfo));
-       RTMPZeroMemory(&pAd->CommonCfg.NewExtChanOffset,
-                      sizeof(pAd->CommonCfg.NewExtChanOffset));
-       RTMPZeroMemory(&pAd->CommonCfg.DesiredHtPhy,
-                      sizeof(pAd->CommonCfg.DesiredHtPhy));
-
-       if (pAd->CommonCfg.bRdg) {
-               pAd->CommonCfg.HtCapability.ExtHtCapInfo.PlusHTC = 1;
-               pAd->CommonCfg.HtCapability.ExtHtCapInfo.RDGSupport = 1;
-       } else {
-               pAd->CommonCfg.HtCapability.ExtHtCapInfo.PlusHTC = 0;
-               pAd->CommonCfg.HtCapability.ExtHtCapInfo.RDGSupport = 0;
-       }
-
-       pAd->CommonCfg.HtCapability.HtCapParm.MaxRAmpduFactor = 3;
-       pAd->CommonCfg.DesiredHtPhy.MaxRAmpduFactor = 3;
-
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("RTMPSetHT : RxBAWinLimit = %d\n",
-                 pAd->CommonCfg.BACapability.field.RxBAWinLimit));
-
-       /* Mimo power save, A-MSDU size, */
-       pAd->CommonCfg.DesiredHtPhy.AmsduEnable =
-           (u16)pAd->CommonCfg.BACapability.field.AmsduEnable;
-       pAd->CommonCfg.DesiredHtPhy.AmsduSize =
-           (u8)pAd->CommonCfg.BACapability.field.AmsduSize;
-       pAd->CommonCfg.DesiredHtPhy.MimoPs =
-           (u8)pAd->CommonCfg.BACapability.field.MMPSmode;
-       pAd->CommonCfg.DesiredHtPhy.MpduDensity =
-           (u8)pAd->CommonCfg.BACapability.field.MpduDensity;
-
-       pAd->CommonCfg.HtCapability.HtCapInfo.AMsduSize =
-           (u16)pAd->CommonCfg.BACapability.field.AmsduSize;
-       pAd->CommonCfg.HtCapability.HtCapInfo.MimoPs =
-           (u16)pAd->CommonCfg.BACapability.field.MMPSmode;
-       pAd->CommonCfg.HtCapability.HtCapParm.MpduDensity =
-           (u8)pAd->CommonCfg.BACapability.field.MpduDensity;
-
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("RTMPSetHT : AMsduSize = %d, MimoPs = %d, MpduDensity = %d, MaxRAmpduFactor = %d\n",
-                 pAd->CommonCfg.DesiredHtPhy.AmsduSize,
-                 pAd->CommonCfg.DesiredHtPhy.MimoPs,
-                 pAd->CommonCfg.DesiredHtPhy.MpduDensity,
-                 pAd->CommonCfg.DesiredHtPhy.MaxRAmpduFactor));
-
-       if (pHTPhyMode->HtMode == HTMODE_GF) {
-               pAd->CommonCfg.HtCapability.HtCapInfo.GF = 1;
-               pAd->CommonCfg.DesiredHtPhy.GF = 1;
-       } else
-               pAd->CommonCfg.DesiredHtPhy.GF = 0;
-
-       /* Decide Rx MCSSet */
-       switch (RxStream) {
-       case 1:
-               pAd->CommonCfg.HtCapability.MCSSet[0] = 0xff;
-               pAd->CommonCfg.HtCapability.MCSSet[1] = 0x00;
-               break;
-
-       case 2:
-               pAd->CommonCfg.HtCapability.MCSSet[0] = 0xff;
-               pAd->CommonCfg.HtCapability.MCSSet[1] = 0xff;
-               break;
-
-       case 3:         /* 3*3 */
-               pAd->CommonCfg.HtCapability.MCSSet[0] = 0xff;
-               pAd->CommonCfg.HtCapability.MCSSet[1] = 0xff;
-               pAd->CommonCfg.HtCapability.MCSSet[2] = 0xff;
-               break;
-       }
-
-       if (pAd->CommonCfg.bForty_Mhz_Intolerant
-           && (pAd->CommonCfg.Channel <= 14) && (pHTPhyMode->BW == BW_40)) {
-               pHTPhyMode->BW = BW_20;
-               pAd->CommonCfg.HtCapability.HtCapInfo.Forty_Mhz_Intolerant = 1;
-       }
-
-       if (pHTPhyMode->BW == BW_40) {
-               pAd->CommonCfg.HtCapability.MCSSet[4] = 0x1;    /* MCS 32 */
-               pAd->CommonCfg.HtCapability.HtCapInfo.ChannelWidth = 1;
-               if (pAd->CommonCfg.Channel <= 14)
-                       pAd->CommonCfg.HtCapability.HtCapInfo.CCKmodein40 = 1;
-
-               pAd->CommonCfg.DesiredHtPhy.ChannelWidth = 1;
-               pAd->CommonCfg.AddHTInfo.AddHtInfo.RecomWidth = 1;
-               pAd->CommonCfg.AddHTInfo.AddHtInfo.ExtChanOffset =
-                   (pHTPhyMode->ExtOffset ==
-                    EXTCHA_BELOW) ? (EXTCHA_BELOW) : EXTCHA_ABOVE;
-               /* Set Regsiter for extension channel position. */
-               RTMP_IO_READ32(pAd, TX_BAND_CFG, &Value);
-               RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &BBP3Value);
-               if ((pHTPhyMode->ExtOffset == EXTCHA_BELOW)) {
-                       Value |= 0x1;
-                       BBP3Value |= (0x20);
-                       RTMP_IO_WRITE32(pAd, TX_BAND_CFG, Value);
-               } else if ((pHTPhyMode->ExtOffset == EXTCHA_ABOVE)) {
-                       Value &= 0xfe;
-                       BBP3Value &= (~0x20);
-                       RTMP_IO_WRITE32(pAd, TX_BAND_CFG, Value);
-               }
-               /* Turn on BBP 40MHz mode now only as AP . */
-               /* Sta can turn on BBP 40MHz after connection with 40MHz AP. Sta only broadcast 40MHz capability before connection. */
-               if ((pAd->OpMode == OPMODE_AP) || INFRA_ON(pAd) || ADHOC_ON(pAd)
-                   ) {
-                       RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue);
-                       BBPValue &= (~0x18);
-                       BBPValue |= 0x10;
-                       RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue);
-
-                       RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BBP3Value);
-                       pAd->CommonCfg.BBPCurrentBW = BW_40;
-               }
-       } else {
-               pAd->CommonCfg.HtCapability.HtCapInfo.ChannelWidth = 0;
-               pAd->CommonCfg.DesiredHtPhy.ChannelWidth = 0;
-               pAd->CommonCfg.AddHTInfo.AddHtInfo.RecomWidth = 0;
-               pAd->CommonCfg.AddHTInfo.AddHtInfo.ExtChanOffset = EXTCHA_NONE;
-               pAd->CommonCfg.CentralChannel = pAd->CommonCfg.Channel;
-               /* Turn on BBP 20MHz mode by request here. */
-               {
-                       RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue);
-                       BBPValue &= (~0x18);
-                       RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue);
-                       pAd->CommonCfg.BBPCurrentBW = BW_20;
-               }
-       }
-
-       if (pHTPhyMode->STBC == STBC_USE) {
-               pAd->CommonCfg.HtCapability.HtCapInfo.TxSTBC = 1;
-               pAd->CommonCfg.DesiredHtPhy.TxSTBC = 1;
-               pAd->CommonCfg.HtCapability.HtCapInfo.RxSTBC = 1;
-               pAd->CommonCfg.DesiredHtPhy.RxSTBC = 1;
-       } else {
-               pAd->CommonCfg.DesiredHtPhy.TxSTBC = 0;
-               pAd->CommonCfg.DesiredHtPhy.RxSTBC = 0;
-       }
-
-       if (pHTPhyMode->SHORTGI == GI_400) {
-               pAd->CommonCfg.HtCapability.HtCapInfo.ShortGIfor20 = 1;
-               pAd->CommonCfg.HtCapability.HtCapInfo.ShortGIfor40 = 1;
-               pAd->CommonCfg.DesiredHtPhy.ShortGIfor20 = 1;
-               pAd->CommonCfg.DesiredHtPhy.ShortGIfor40 = 1;
-       } else {
-               pAd->CommonCfg.HtCapability.HtCapInfo.ShortGIfor20 = 0;
-               pAd->CommonCfg.HtCapability.HtCapInfo.ShortGIfor40 = 0;
-               pAd->CommonCfg.DesiredHtPhy.ShortGIfor20 = 0;
-               pAd->CommonCfg.DesiredHtPhy.ShortGIfor40 = 0;
-       }
-
-       /* We support link adaptation for unsolicit MCS feedback, set to 2. */
-       pAd->CommonCfg.HtCapability.ExtHtCapInfo.MCSFeedback = MCSFBK_NONE;     /*MCSFBK_UNSOLICIT; */
-       pAd->CommonCfg.AddHTInfo.ControlChan = pAd->CommonCfg.Channel;
-       /* 1, the extension channel above the control channel. */
-
-       /* EDCA parameters used for AP's own transmission */
-       if (pAd->CommonCfg.APEdcaParm.bValid == FALSE) {
-               pAd->CommonCfg.APEdcaParm.bValid = TRUE;
-               pAd->CommonCfg.APEdcaParm.Aifsn[0] = 3;
-               pAd->CommonCfg.APEdcaParm.Aifsn[1] = 7;
-               pAd->CommonCfg.APEdcaParm.Aifsn[2] = 1;
-               pAd->CommonCfg.APEdcaParm.Aifsn[3] = 1;
-
-               pAd->CommonCfg.APEdcaParm.Cwmin[0] = 4;
-               pAd->CommonCfg.APEdcaParm.Cwmin[1] = 4;
-               pAd->CommonCfg.APEdcaParm.Cwmin[2] = 3;
-               pAd->CommonCfg.APEdcaParm.Cwmin[3] = 2;
-
-               pAd->CommonCfg.APEdcaParm.Cwmax[0] = 6;
-               pAd->CommonCfg.APEdcaParm.Cwmax[1] = 10;
-               pAd->CommonCfg.APEdcaParm.Cwmax[2] = 4;
-               pAd->CommonCfg.APEdcaParm.Cwmax[3] = 3;
-
-               pAd->CommonCfg.APEdcaParm.Txop[0] = 0;
-               pAd->CommonCfg.APEdcaParm.Txop[1] = 0;
-               pAd->CommonCfg.APEdcaParm.Txop[2] = 94;
-               pAd->CommonCfg.APEdcaParm.Txop[3] = 47;
-       }
-       AsicSetEdcaParm(pAd, &pAd->CommonCfg.APEdcaParm);
-
-       {
-               RTMPSetIndividualHT(pAd, 0);
-       }
-
-}
-
-/*
-       ========================================================================
-       Routine Description:
-               Caller ensures we has 802.11n support.
-               Calls at setting HT from AP/STASetinformation
-
-       Arguments:
-               pAd - Pointer to our adapter
-               phymode  -
-
-       ========================================================================
-*/
-void RTMPSetIndividualHT(struct rt_rtmp_adapter *pAd, u8 apidx)
-{
-       struct rt_ht_phy_info *pDesired_ht_phy = NULL;
-       u8 TxStream = pAd->CommonCfg.TxStream;
-       u8 DesiredMcs = MCS_AUTO;
-
-       do {
-               {
-                       pDesired_ht_phy = &pAd->StaCfg.DesiredHtPhyInfo;
-                       DesiredMcs =
-                           pAd->StaCfg.DesiredTransmitSetting.field.MCS;
-                       /*pAd->StaCfg.bAutoTxRateSwitch = (DesiredMcs == MCS_AUTO) ? TRUE : FALSE; */
-                       break;
-               }
-       } while (FALSE);
-
-       if (pDesired_ht_phy == NULL) {
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("RTMPSetIndividualHT: invalid apidx(%d)\n", apidx));
-               return;
-       }
-       RTMPZeroMemory(pDesired_ht_phy, sizeof(struct rt_ht_phy_info));
-
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("RTMPSetIndividualHT : Desired MCS = %d\n", DesiredMcs));
-       /* Check the validity of MCS */
-       if ((TxStream == 1)
-           && ((DesiredMcs >= MCS_8) && (DesiredMcs <= MCS_15))) {
-               DBGPRINT(RT_DEBUG_WARN,
-                        ("RTMPSetIndividualHT: MCS(%d) is invalid in 1S, reset it as MCS_7\n",
-                         DesiredMcs));
-               DesiredMcs = MCS_7;
-       }
-
-       if ((pAd->CommonCfg.DesiredHtPhy.ChannelWidth == BW_20)
-           && (DesiredMcs == MCS_32)) {
-               DBGPRINT(RT_DEBUG_WARN,
-                        ("RTMPSetIndividualHT: MCS_32 is only supported in 40-MHz, reset it as MCS_0\n"));
-               DesiredMcs = MCS_0;
-       }
-
-       pDesired_ht_phy->bHtEnable = TRUE;
-
-       /* Decide desired Tx MCS */
-       switch (TxStream) {
-       case 1:
-               if (DesiredMcs == MCS_AUTO) {
-                       pDesired_ht_phy->MCSSet[0] = 0xff;
-                       pDesired_ht_phy->MCSSet[1] = 0x00;
-               } else if (DesiredMcs <= MCS_7) {
-                       pDesired_ht_phy->MCSSet[0] = 1 << DesiredMcs;
-                       pDesired_ht_phy->MCSSet[1] = 0x00;
-               }
-               break;
-
-       case 2:
-               if (DesiredMcs == MCS_AUTO) {
-                       pDesired_ht_phy->MCSSet[0] = 0xff;
-                       pDesired_ht_phy->MCSSet[1] = 0xff;
-               } else if (DesiredMcs <= MCS_15) {
-                       unsigned long mode;
-
-                       mode = DesiredMcs / 8;
-                       if (mode < 2)
-                               pDesired_ht_phy->MCSSet[mode] =
-                                   (1 << (DesiredMcs - mode * 8));
-               }
-               break;
-
-       case 3:         /* 3*3 */
-               if (DesiredMcs == MCS_AUTO) {
-                       /* MCS0 ~ MCS23, 3 bytes */
-                       pDesired_ht_phy->MCSSet[0] = 0xff;
-                       pDesired_ht_phy->MCSSet[1] = 0xff;
-                       pDesired_ht_phy->MCSSet[2] = 0xff;
-               } else if (DesiredMcs <= MCS_23) {
-                       unsigned long mode;
-
-                       mode = DesiredMcs / 8;
-                       if (mode < 3)
-                               pDesired_ht_phy->MCSSet[mode] =
-                                   (1 << (DesiredMcs - mode * 8));
-               }
-               break;
-       }
-
-       if (pAd->CommonCfg.DesiredHtPhy.ChannelWidth == BW_40) {
-               if (DesiredMcs == MCS_AUTO || DesiredMcs == MCS_32)
-                       pDesired_ht_phy->MCSSet[4] = 0x1;
-       }
-       /* update HT Rate setting */
-       if (pAd->OpMode == OPMODE_STA)
-               MlmeUpdateHtTxRates(pAd, BSS0);
-       else
-               MlmeUpdateHtTxRates(pAd, apidx);
-}
-
-/*
-       ========================================================================
-       Routine Description:
-               Update HT IE from our capability.
-
-       Arguments:
-               Send all HT IE in beacon/probe rsp/assoc rsp/action frame.
-
-       ========================================================================
-*/
-void RTMPUpdateHTIE(struct rt_ht_capability *pRtHt,
-                   u8 * pMcsSet,
-                   struct rt_ht_capability_ie * pHtCapability,
-                   struct rt_add_ht_info_ie * pAddHtInfo)
-{
-       RTMPZeroMemory(pHtCapability, sizeof(struct rt_ht_capability_ie));
-       RTMPZeroMemory(pAddHtInfo, sizeof(struct rt_add_ht_info_ie));
-
-       pHtCapability->HtCapInfo.ChannelWidth = pRtHt->ChannelWidth;
-       pHtCapability->HtCapInfo.MimoPs = pRtHt->MimoPs;
-       pHtCapability->HtCapInfo.GF = pRtHt->GF;
-       pHtCapability->HtCapInfo.ShortGIfor20 = pRtHt->ShortGIfor20;
-       pHtCapability->HtCapInfo.ShortGIfor40 = pRtHt->ShortGIfor40;
-       pHtCapability->HtCapInfo.TxSTBC = pRtHt->TxSTBC;
-       pHtCapability->HtCapInfo.RxSTBC = pRtHt->RxSTBC;
-       pHtCapability->HtCapInfo.AMsduSize = pRtHt->AmsduSize;
-       pHtCapability->HtCapParm.MaxRAmpduFactor = pRtHt->MaxRAmpduFactor;
-       pHtCapability->HtCapParm.MpduDensity = pRtHt->MpduDensity;
-
-       pAddHtInfo->AddHtInfo.ExtChanOffset = pRtHt->ExtChanOffset;
-       pAddHtInfo->AddHtInfo.RecomWidth = pRtHt->RecomWidth;
-       pAddHtInfo->AddHtInfo2.OperaionMode = pRtHt->OperaionMode;
-       pAddHtInfo->AddHtInfo2.NonGfPresent = pRtHt->NonGfPresent;
-       RTMPMoveMemory(pAddHtInfo->MCSSet, /*pRtHt->MCSSet */ pMcsSet, 4);      /* rt2860 only support MCS max=32, no need to copy all 16 uchar. */
-
-       DBGPRINT(RT_DEBUG_TRACE, ("RTMPUpdateHTIE <== \n"));
-}
-
-/*
-       ========================================================================
-       Description:
-               Add Client security information into ASIC WCID table and IVEIV table.
-    Return:
-       ========================================================================
-*/
-void RTMPAddWcidAttributeEntry(struct rt_rtmp_adapter *pAd,
-                              u8 BssIdx,
-                              u8 KeyIdx,
-                              u8 CipherAlg, struct rt_mac_table_entry *pEntry)
-{
-       u32 WCIDAttri = 0;
-       u16 offset;
-       u8 IVEIV = 0;
-       u16 Wcid = 0;
-
-       {
-               {
-                       if (BssIdx > BSS0) {
-                               DBGPRINT(RT_DEBUG_ERROR,
-                                        ("RTMPAddWcidAttributeEntry: The BSS-index(%d) is out of range for Infra link. \n",
-                                         BssIdx));
-                               return;
-                       }
-                       /* 1.   In ADHOC mode, the AID is wcid number. And NO mesh link exists. */
-                       /* 2.   In Infra mode, the AID:1 MUST be wcid of infra STA. */
-                       /*                                         the AID:2~ assign to mesh link entry. */
-                       if (pEntry)
-                               Wcid = pEntry->Aid;
-                       else
-                               Wcid = MCAST_WCID;
-               }
-       }
-
-       /* Update WCID attribute table */
-       offset = MAC_WCID_ATTRIBUTE_BASE + (Wcid * HW_WCID_ATTRI_SIZE);
-
-       {
-               if (pEntry && pEntry->ValidAsMesh)
-                       WCIDAttri = (CipherAlg << 1) | PAIRWISEKEYTABLE;
-               else
-                       WCIDAttri = (CipherAlg << 1) | SHAREDKEYTABLE;
-       }
-
-       RTMP_IO_WRITE32(pAd, offset, WCIDAttri);
-
-       /* Update IV/EIV table */
-       offset = MAC_IVEIV_TABLE_BASE + (Wcid * HW_IVEIV_ENTRY_SIZE);
-
-       /* WPA mode */
-       if ((CipherAlg == CIPHER_TKIP) || (CipherAlg == CIPHER_TKIP_NO_MIC)
-           || (CipherAlg == CIPHER_AES)) {
-               /* Eiv bit on. keyid always is 0 for pairwise key */
-               IVEIV = (KeyIdx << 6) | 0x20;
-       } else {
-               /* WEP KeyIdx is default tx key. */
-               IVEIV = (KeyIdx << 6);
-       }
-
-       /* For key index and ext IV bit, so only need to update the position(offset+3). */
-#ifdef RTMP_MAC_PCI
-       RTMP_IO_WRITE8(pAd, offset + 3, IVEIV);
-#endif /* RTMP_MAC_PCI // */
-#ifdef RTMP_MAC_USB
-       RTUSBMultiWrite_OneByte(pAd, offset + 3, &IVEIV);
-#endif /* RTMP_MAC_USB // */
-
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("RTMPAddWcidAttributeEntry: WCID #%d, KeyIndex #%d, Alg=%s\n",
-                 Wcid, KeyIdx, CipherName[CipherAlg]));
-       DBGPRINT(RT_DEBUG_TRACE, ("     WCIDAttri = 0x%x \n", WCIDAttri));
-
-}
-
-/*
-    ==========================================================================
-    Description:
-        Parse encryption type
-Arguments:
-    pAdapter                    Pointer to our adapter
-    wrq                         Pointer to the ioctl argument
-
-    Return Value:
-        None
-
-    Note:
-    ==========================================================================
-*/
-char *GetEncryptType(char enc)
-{
-       if (enc == Ndis802_11WEPDisabled)
-               return "NONE";
-       if (enc == Ndis802_11WEPEnabled)
-               return "WEP";
-       if (enc == Ndis802_11Encryption2Enabled)
-               return "TKIP";
-       if (enc == Ndis802_11Encryption3Enabled)
-               return "AES";
-       if (enc == Ndis802_11Encryption4Enabled)
-               return "TKIPAES";
-       else
-               return "UNKNOW";
-}
-
-char *GetAuthMode(char auth)
-{
-       if (auth == Ndis802_11AuthModeOpen)
-               return "OPEN";
-       if (auth == Ndis802_11AuthModeShared)
-               return "SHARED";
-       if (auth == Ndis802_11AuthModeAutoSwitch)
-               return "AUTOWEP";
-       if (auth == Ndis802_11AuthModeWPA)
-               return "WPA";
-       if (auth == Ndis802_11AuthModeWPAPSK)
-               return "WPAPSK";
-       if (auth == Ndis802_11AuthModeWPANone)
-               return "WPANONE";
-       if (auth == Ndis802_11AuthModeWPA2)
-               return "WPA2";
-       if (auth == Ndis802_11AuthModeWPA2PSK)
-               return "WPA2PSK";
-       if (auth == Ndis802_11AuthModeWPA1WPA2)
-               return "WPA1WPA2";
-       if (auth == Ndis802_11AuthModeWPA1PSKWPA2PSK)
-               return "WPA1PSKWPA2PSK";
-
-       return "UNKNOW";
-}
-
-int SetCommonHT(struct rt_rtmp_adapter *pAd)
-{
-       struct rt_oid_set_ht_phymode SetHT;
-
-       if (pAd->CommonCfg.PhyMode < PHY_11ABGN_MIXED)
-               return FALSE;
-
-       SetHT.PhyMode = pAd->CommonCfg.PhyMode;
-       SetHT.TransmitNo = ((u8)pAd->Antenna.field.TxPath);
-       SetHT.HtMode = (u8)pAd->CommonCfg.RegTransmitSetting.field.HTMODE;
-       SetHT.ExtOffset =
-           (u8)pAd->CommonCfg.RegTransmitSetting.field.EXTCHA;
-       SetHT.MCS = MCS_AUTO;
-       SetHT.BW = (u8)pAd->CommonCfg.RegTransmitSetting.field.BW;
-       SetHT.STBC = (u8)pAd->CommonCfg.RegTransmitSetting.field.STBC;
-       SetHT.SHORTGI = (u8)pAd->CommonCfg.RegTransmitSetting.field.ShortGI;
-
-       RTMPSetHT(pAd, &SetHT);
-
-       return TRUE;
-}
-
-char *RTMPGetRalinkEncryModeStr(u16 encryMode)
-{
-       switch (encryMode) {
-       case Ndis802_11WEPDisabled:
-               return "NONE";
-       case Ndis802_11WEPEnabled:
-               return "WEP";
-       case Ndis802_11Encryption2Enabled:
-               return "TKIP";
-       case Ndis802_11Encryption3Enabled:
-               return "AES";
-       case Ndis802_11Encryption4Enabled:
-               return "TKIPAES";
-       default:
-               return "UNKNOW";
-       }
-}
diff --git a/drivers/staging/rt2860/common/cmm_mac_pci.c b/drivers/staging/rt2860/common/cmm_mac_pci.c
deleted file mode 100644 (file)
index d06f0a6..0000000
+++ /dev/null
@@ -1,1661 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-*/
-
-#ifdef RTMP_MAC_PCI
-#include       "../rt_config.h"
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Allocate DMA memory blocks for send, receive
-
-       Arguments:
-               Adapter         Pointer to our adapter
-
-       Return Value:
-               NDIS_STATUS_SUCCESS
-               NDIS_STATUS_FAILURE
-               NDIS_STATUS_RESOURCES
-
-       IRQL = PASSIVE_LEVEL
-
-       Note:
-
-       ========================================================================
-*/
-int RTMPAllocTxRxRingMemory(struct rt_rtmp_adapter *pAd)
-{
-       int Status = NDIS_STATUS_SUCCESS;
-       unsigned long RingBasePaHigh;
-       unsigned long RingBasePaLow;
-       void *RingBaseVa;
-       int index, num;
-       struct rt_txd * pTxD;
-       struct rt_rxd * pRxD;
-       unsigned long ErrorValue = 0;
-       struct rt_rtmp_tx_ring *pTxRing;
-       struct rt_rtmp_dmabuf *pDmaBuf;
-       void *pPacket;
-/*      PRTMP_REORDERBUF        pReorderBuf; */
-
-       DBGPRINT(RT_DEBUG_TRACE, ("--> RTMPAllocTxRxRingMemory\n"));
-       do {
-               /* */
-               /* Allocate all ring descriptors, include TxD, RxD, MgmtD. */
-               /* Although each size is different, to prevent cacheline and alignment */
-               /* issue, I intentional set them all to 64 bytes. */
-               /* */
-               for (num = 0; num < NUM_OF_TX_RING; num++) {
-                       unsigned long BufBasePaHigh;
-                       unsigned long BufBasePaLow;
-                       void *BufBaseVa;
-
-                       /* */
-                       /* Allocate Tx ring descriptor's memory (5 TX rings = 4 ACs + 1 HCCA) */
-                       /* */
-                       pAd->TxDescRing[num].AllocSize =
-                           TX_RING_SIZE * TXD_SIZE;
-                       RTMP_AllocateTxDescMemory(pAd, num,
-                                                 pAd->TxDescRing[num].
-                                                 AllocSize, FALSE,
-                                                 &pAd->TxDescRing[num].AllocVa,
-                                                 &pAd->TxDescRing[num].
-                                                 AllocPa);
-
-                       if (pAd->TxDescRing[num].AllocVa == NULL) {
-                               ErrorValue = ERRLOG_OUT_OF_SHARED_MEMORY;
-                               DBGPRINT_ERR("Failed to allocate a big buffer\n");
-                               Status = NDIS_STATUS_RESOURCES;
-                               break;
-                       }
-                       /* Zero init this memory block */
-                       NdisZeroMemory(pAd->TxDescRing[num].AllocVa,
-                                      pAd->TxDescRing[num].AllocSize);
-
-                       /* Save PA & VA for further operation */
-                       RingBasePaHigh =
-                           RTMP_GetPhysicalAddressHigh(pAd->TxDescRing[num].
-                                                       AllocPa);
-                       RingBasePaLow =
-                           RTMP_GetPhysicalAddressLow(pAd->TxDescRing[num].
-                                                      AllocPa);
-                       RingBaseVa = pAd->TxDescRing[num].AllocVa;
-
-                       /* */
-                       /* Allocate all 1st TXBuf's memory for this TxRing */
-                       /* */
-                       pAd->TxBufSpace[num].AllocSize =
-                           TX_RING_SIZE * TX_DMA_1ST_BUFFER_SIZE;
-                       RTMP_AllocateFirstTxBuffer(pAd, num,
-                                                  pAd->TxBufSpace[num].
-                                                  AllocSize, FALSE,
-                                                  &pAd->TxBufSpace[num].
-                                                  AllocVa,
-                                                  &pAd->TxBufSpace[num].
-                                                  AllocPa);
-
-                       if (pAd->TxBufSpace[num].AllocVa == NULL) {
-                               ErrorValue = ERRLOG_OUT_OF_SHARED_MEMORY;
-                               DBGPRINT_ERR("Failed to allocate a big buffer\n");
-                               Status = NDIS_STATUS_RESOURCES;
-                               break;
-                       }
-                       /* Zero init this memory block */
-                       NdisZeroMemory(pAd->TxBufSpace[num].AllocVa,
-                                      pAd->TxBufSpace[num].AllocSize);
-
-                       /* Save PA & VA for further operation */
-                       BufBasePaHigh =
-                           RTMP_GetPhysicalAddressHigh(pAd->TxBufSpace[num].
-                                                       AllocPa);
-                       BufBasePaLow =
-                           RTMP_GetPhysicalAddressLow(pAd->TxBufSpace[num].
-                                                      AllocPa);
-                       BufBaseVa = pAd->TxBufSpace[num].AllocVa;
-
-                       /* */
-                       /* Initialize Tx Ring Descriptor and associated buffer memory */
-                       /* */
-                       pTxRing = &pAd->TxRing[num];
-                       for (index = 0; index < TX_RING_SIZE; index++) {
-                               pTxRing->Cell[index].pNdisPacket = NULL;
-                               pTxRing->Cell[index].pNextNdisPacket = NULL;
-                               /* Init Tx Ring Size, Va, Pa variables */
-                               pTxRing->Cell[index].AllocSize = TXD_SIZE;
-                               pTxRing->Cell[index].AllocVa = RingBaseVa;
-                               RTMP_SetPhysicalAddressHigh(pTxRing->
-                                                           Cell[index].AllocPa,
-                                                           RingBasePaHigh);
-                               RTMP_SetPhysicalAddressLow(pTxRing->Cell[index].
-                                                          AllocPa,
-                                                          RingBasePaLow);
-
-                               /* Setup Tx Buffer size & address. only 802.11 header will store in this space */
-                               pDmaBuf = &pTxRing->Cell[index].DmaBuf;
-                               pDmaBuf->AllocSize = TX_DMA_1ST_BUFFER_SIZE;
-                               pDmaBuf->AllocVa = BufBaseVa;
-                               RTMP_SetPhysicalAddressHigh(pDmaBuf->AllocPa,
-                                                           BufBasePaHigh);
-                               RTMP_SetPhysicalAddressLow(pDmaBuf->AllocPa,
-                                                          BufBasePaLow);
-
-                               /* link the pre-allocated TxBuf to TXD */
-                               pTxD =
-                                   (struct rt_txd *) pTxRing->Cell[index].AllocVa;
-                               pTxD->SDPtr0 = BufBasePaLow;
-                               /* advance to next ring descriptor address */
-                               pTxD->DMADONE = 1;
-                               RingBasePaLow += TXD_SIZE;
-                               RingBaseVa = (u8 *)RingBaseVa + TXD_SIZE;
-
-                               /* advance to next TxBuf address */
-                               BufBasePaLow += TX_DMA_1ST_BUFFER_SIZE;
-                               BufBaseVa =
-                                   (u8 *)BufBaseVa + TX_DMA_1ST_BUFFER_SIZE;
-                       }
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("TxRing[%d]: total %d entry allocated\n", num,
-                                 index));
-               }
-               if (Status == NDIS_STATUS_RESOURCES)
-                       break;
-
-               /* */
-               /* Allocate MGMT ring descriptor's memory except Tx ring which allocated eariler */
-               /* */
-               pAd->MgmtDescRing.AllocSize = MGMT_RING_SIZE * TXD_SIZE;
-               RTMP_AllocateMgmtDescMemory(pAd,
-                                           pAd->MgmtDescRing.AllocSize,
-                                           FALSE,
-                                           &pAd->MgmtDescRing.AllocVa,
-                                           &pAd->MgmtDescRing.AllocPa);
-
-               if (pAd->MgmtDescRing.AllocVa == NULL) {
-                       ErrorValue = ERRLOG_OUT_OF_SHARED_MEMORY;
-                       DBGPRINT_ERR("Failed to allocate a big buffer\n");
-                       Status = NDIS_STATUS_RESOURCES;
-                       break;
-               }
-               /* Zero init this memory block */
-               NdisZeroMemory(pAd->MgmtDescRing.AllocVa,
-                              pAd->MgmtDescRing.AllocSize);
-
-               /* Save PA & VA for further operation */
-               RingBasePaHigh =
-                   RTMP_GetPhysicalAddressHigh(pAd->MgmtDescRing.AllocPa);
-               RingBasePaLow =
-                   RTMP_GetPhysicalAddressLow(pAd->MgmtDescRing.AllocPa);
-               RingBaseVa = pAd->MgmtDescRing.AllocVa;
-
-               /* */
-               /* Initialize MGMT Ring and associated buffer memory */
-               /* */
-               for (index = 0; index < MGMT_RING_SIZE; index++) {
-                       pAd->MgmtRing.Cell[index].pNdisPacket = NULL;
-                       pAd->MgmtRing.Cell[index].pNextNdisPacket = NULL;
-                       /* Init MGMT Ring Size, Va, Pa variables */
-                       pAd->MgmtRing.Cell[index].AllocSize = TXD_SIZE;
-                       pAd->MgmtRing.Cell[index].AllocVa = RingBaseVa;
-                       RTMP_SetPhysicalAddressHigh(pAd->MgmtRing.Cell[index].
-                                                   AllocPa, RingBasePaHigh);
-                       RTMP_SetPhysicalAddressLow(pAd->MgmtRing.Cell[index].
-                                                  AllocPa, RingBasePaLow);
-
-                       /* Offset to next ring descriptor address */
-                       RingBasePaLow += TXD_SIZE;
-                       RingBaseVa = (u8 *)RingBaseVa + TXD_SIZE;
-
-                       /* link the pre-allocated TxBuf to TXD */
-                       pTxD = (struct rt_txd *) pAd->MgmtRing.Cell[index].AllocVa;
-                       pTxD->DMADONE = 1;
-
-                       /* no pre-allocated buffer required in MgmtRing for scatter-gather case */
-               }
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("MGMT Ring: total %d entry allocated\n", index));
-
-               /* */
-               /* Allocate RX ring descriptor's memory except Tx ring which allocated eariler */
-               /* */
-               pAd->RxDescRing.AllocSize = RX_RING_SIZE * RXD_SIZE;
-               RTMP_AllocateRxDescMemory(pAd,
-                                         pAd->RxDescRing.AllocSize,
-                                         FALSE,
-                                         &pAd->RxDescRing.AllocVa,
-                                         &pAd->RxDescRing.AllocPa);
-
-               if (pAd->RxDescRing.AllocVa == NULL) {
-                       ErrorValue = ERRLOG_OUT_OF_SHARED_MEMORY;
-                       DBGPRINT_ERR("Failed to allocate a big buffer\n");
-                       Status = NDIS_STATUS_RESOURCES;
-                       break;
-               }
-               /* Zero init this memory block */
-               NdisZeroMemory(pAd->RxDescRing.AllocVa,
-                              pAd->RxDescRing.AllocSize);
-
-               DBGPRINT(RT_DEBUG_OFF,
-                        ("RX DESC %p  size = %ld\n", pAd->RxDescRing.AllocVa,
-                         pAd->RxDescRing.AllocSize));
-
-               /* Save PA & VA for further operation */
-               RingBasePaHigh =
-                   RTMP_GetPhysicalAddressHigh(pAd->RxDescRing.AllocPa);
-               RingBasePaLow =
-                   RTMP_GetPhysicalAddressLow(pAd->RxDescRing.AllocPa);
-               RingBaseVa = pAd->RxDescRing.AllocVa;
-
-               /* */
-               /* Initialize Rx Ring and associated buffer memory */
-               /* */
-               for (index = 0; index < RX_RING_SIZE; index++) {
-                       /* Init RX Ring Size, Va, Pa variables */
-                       pAd->RxRing.Cell[index].AllocSize = RXD_SIZE;
-                       pAd->RxRing.Cell[index].AllocVa = RingBaseVa;
-                       RTMP_SetPhysicalAddressHigh(pAd->RxRing.Cell[index].
-                                                   AllocPa, RingBasePaHigh);
-                       RTMP_SetPhysicalAddressLow(pAd->RxRing.Cell[index].
-                                                  AllocPa, RingBasePaLow);
-
-                       /*NdisZeroMemory(RingBaseVa, RXD_SIZE); */
-
-                       /* Offset to next ring descriptor address */
-                       RingBasePaLow += RXD_SIZE;
-                       RingBaseVa = (u8 *)RingBaseVa + RXD_SIZE;
-
-                       /* Setup Rx associated Buffer size & allocate share memory */
-                       pDmaBuf = &pAd->RxRing.Cell[index].DmaBuf;
-                       pDmaBuf->AllocSize = RX_BUFFER_AGGRESIZE;
-                       pPacket = RTMP_AllocateRxPacketBuffer(pAd,
-                                                             pDmaBuf->
-                                                             AllocSize, FALSE,
-                                                             &pDmaBuf->AllocVa,
-                                                             &pDmaBuf->
-                                                             AllocPa);
-
-                       /* keep allocated rx packet */
-                       pAd->RxRing.Cell[index].pNdisPacket = pPacket;
-
-                       /* Error handling */
-                       if (pDmaBuf->AllocVa == NULL) {
-                               ErrorValue = ERRLOG_OUT_OF_SHARED_MEMORY;
-                               DBGPRINT_ERR("Failed to allocate RxRing's 1st buffer\n");
-                               Status = NDIS_STATUS_RESOURCES;
-                               break;
-                       }
-                       /* Zero init this memory block */
-                       NdisZeroMemory(pDmaBuf->AllocVa, pDmaBuf->AllocSize);
-
-                       /* Write RxD buffer address & allocated buffer length */
-                       pRxD = (struct rt_rxd *) pAd->RxRing.Cell[index].AllocVa;
-                       pRxD->SDP0 =
-                           RTMP_GetPhysicalAddressLow(pDmaBuf->AllocPa);
-                       pRxD->DDONE = 0;
-
-               }
-
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("Rx Ring: total %d entry allocated\n", index));
-
-       } while (FALSE);
-
-       NdisZeroMemory(&pAd->FragFrame, sizeof(struct rt_fragment_frame));
-       pAd->FragFrame.pFragPacket =
-           RTMP_AllocateFragPacketBuffer(pAd, RX_BUFFER_NORMSIZE);
-
-       if (pAd->FragFrame.pFragPacket == NULL) {
-               Status = NDIS_STATUS_RESOURCES;
-       }
-
-       if (Status != NDIS_STATUS_SUCCESS) {
-               /* Log error inforamtion */
-               NdisWriteErrorLogEntry(pAd->AdapterHandle,
-                                      NDIS_ERROR_CODE_OUT_OF_RESOURCES,
-                                      1, ErrorValue);
-       }
-       /* Following code segment get from original func:NICInitTxRxRingAndBacklogQueue(), now should integrate it to here. */
-       {
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("--> NICInitTxRxRingAndBacklogQueue\n"));
-
-/*
-               // Disable DMA.
-               RTMP_IO_READ32(pAd, WPDMA_GLO_CFG, &GloCfg.word);
-               GloCfg.word &= 0xff0;
-               GloCfg.field.EnTXWriteBackDDONE =1;
-               RTMP_IO_WRITE32(pAd, WPDMA_GLO_CFG, GloCfg.word);
-*/
-
-               /* Initialize all transmit related software queues */
-               for (index = 0; index < NUM_OF_TX_RING; index++) {
-                       InitializeQueueHeader(&pAd->TxSwQueue[index]);
-                       /* Init TX rings index pointer */
-                       pAd->TxRing[index].TxSwFreeIdx = 0;
-                       pAd->TxRing[index].TxCpuIdx = 0;
-                       /*RTMP_IO_WRITE32(pAd, (TX_CTX_IDX0 + i * 0x10) ,  pAd->TxRing[i].TX_CTX_IDX); */
-               }
-
-               /* Init RX Ring index pointer */
-               pAd->RxRing.RxSwReadIdx = 0;
-               pAd->RxRing.RxCpuIdx = RX_RING_SIZE - 1;
-               /*RTMP_IO_WRITE32(pAd, RX_CRX_IDX, pAd->RxRing.RX_CRX_IDX0); */
-
-               /* init MGMT ring index pointer */
-               pAd->MgmtRing.TxSwFreeIdx = 0;
-               pAd->MgmtRing.TxCpuIdx = 0;
-
-               pAd->PrivateInfo.TxRingFullCnt = 0;
-
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("<-- NICInitTxRxRingAndBacklogQueue\n"));
-       }
-
-       DBGPRINT_S(Status,
-                  ("<-- RTMPAllocTxRxRingMemory, Status=%x\n", Status));
-       return Status;
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Reset NIC Asics. Call after rest DMA. So reset TX_CTX_IDX to zero.
-
-       Arguments:
-               Adapter                                         Pointer to our adapter
-
-       Return Value:
-               None
-
-       IRQL = PASSIVE_LEVEL
-       IRQL = DISPATCH_LEVEL
-
-       Note:
-               Reset NIC to initial state AS IS system boot up time.
-
-       ========================================================================
-*/
-void RTMPRingCleanUp(struct rt_rtmp_adapter *pAd, u8 RingType)
-{
-       struct rt_txd * pTxD;
-       struct rt_rxd * pRxD;
-       struct rt_queue_entry *pEntry;
-       void *pPacket;
-       int i;
-       struct rt_rtmp_tx_ring *pTxRing;
-       unsigned long IrqFlags;
-       /*u32                        RxSwReadIdx; */
-
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("RTMPRingCleanUp(RingIdx=%d, Pending-NDIS=%ld)\n", RingType,
-                 pAd->RalinkCounters.PendingNdisPacketCount));
-       switch (RingType) {
-       case QID_AC_BK:
-       case QID_AC_BE:
-       case QID_AC_VI:
-       case QID_AC_VO:
-
-               pTxRing = &pAd->TxRing[RingType];
-
-               RTMP_IRQ_LOCK(&pAd->irq_lock, IrqFlags);
-               /* We have to clean all descriptors in case some error happened with reset */
-               for (i = 0; i < TX_RING_SIZE; i++)      /* We have to scan all TX ring */
-               {
-                       pTxD = (struct rt_txd *) pTxRing->Cell[i].AllocVa;
-
-                       pPacket = (void *)pTxRing->Cell[i].pNdisPacket;
-                       /* release scatter-and-gather char */
-                       if (pPacket) {
-                               RELEASE_NDIS_PACKET(pAd, pPacket,
-                                                   NDIS_STATUS_FAILURE);
-                               pTxRing->Cell[i].pNdisPacket = NULL;
-                       }
-
-                       pPacket =
-                           (void *)pTxRing->Cell[i].pNextNdisPacket;
-                       /* release scatter-and-gather char */
-                       if (pPacket) {
-                               RELEASE_NDIS_PACKET(pAd, pPacket,
-                                                   NDIS_STATUS_FAILURE);
-                               pTxRing->Cell[i].pNextNdisPacket = NULL;
-                       }
-               }
-
-               RTMP_IO_READ32(pAd, TX_DTX_IDX0 + RingType * 0x10,
-                              &pTxRing->TxDmaIdx);
-               pTxRing->TxSwFreeIdx = pTxRing->TxDmaIdx;
-               pTxRing->TxCpuIdx = pTxRing->TxDmaIdx;
-               RTMP_IO_WRITE32(pAd, TX_CTX_IDX0 + RingType * 0x10,
-                               pTxRing->TxCpuIdx);
-
-               RTMP_IRQ_UNLOCK(&pAd->irq_lock, IrqFlags);
-
-               RTMP_IRQ_LOCK(&pAd->irq_lock, IrqFlags);
-               while (pAd->TxSwQueue[RingType].Head != NULL) {
-                       pEntry = RemoveHeadQueue(&pAd->TxSwQueue[RingType]);
-                       pPacket = QUEUE_ENTRY_TO_PACKET(pEntry);
-                       RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("Release 1 NDIS packet from s/w backlog queue\n"));
-               }
-               RTMP_IRQ_UNLOCK(&pAd->irq_lock, IrqFlags);
-               break;
-
-       case QID_MGMT:
-               /* We have to clean all descriptors in case some error happened with reset */
-               NdisAcquireSpinLock(&pAd->MgmtRingLock);
-
-               for (i = 0; i < MGMT_RING_SIZE; i++) {
-                       pTxD = (struct rt_txd *) pAd->MgmtRing.Cell[i].AllocVa;
-
-                       pPacket =
-                           (void *)pAd->MgmtRing.Cell[i].pNdisPacket;
-                       /* rlease scatter-and-gather char */
-                       if (pPacket) {
-                               PCI_UNMAP_SINGLE(pAd, pTxD->SDPtr0,
-                                                pTxD->SDLen0,
-                                                PCI_DMA_TODEVICE);
-                               RELEASE_NDIS_PACKET(pAd, pPacket,
-                                                   NDIS_STATUS_FAILURE);
-                       }
-                       pAd->MgmtRing.Cell[i].pNdisPacket = NULL;
-
-                       pPacket =
-                           (void *)pAd->MgmtRing.Cell[i].
-                           pNextNdisPacket;
-                       /* release scatter-and-gather char */
-                       if (pPacket) {
-                               PCI_UNMAP_SINGLE(pAd, pTxD->SDPtr1,
-                                                pTxD->SDLen1,
-                                                PCI_DMA_TODEVICE);
-                               RELEASE_NDIS_PACKET(pAd, pPacket,
-                                                   NDIS_STATUS_FAILURE);
-                       }
-                       pAd->MgmtRing.Cell[i].pNextNdisPacket = NULL;
-
-               }
-
-               RTMP_IO_READ32(pAd, TX_MGMTDTX_IDX, &pAd->MgmtRing.TxDmaIdx);
-               pAd->MgmtRing.TxSwFreeIdx = pAd->MgmtRing.TxDmaIdx;
-               pAd->MgmtRing.TxCpuIdx = pAd->MgmtRing.TxDmaIdx;
-               RTMP_IO_WRITE32(pAd, TX_MGMTCTX_IDX, pAd->MgmtRing.TxCpuIdx);
-
-               NdisReleaseSpinLock(&pAd->MgmtRingLock);
-               pAd->RalinkCounters.MgmtRingFullCount = 0;
-               break;
-
-       case QID_RX:
-               /* We have to clean all descriptors in case some error happened with reset */
-               NdisAcquireSpinLock(&pAd->RxRingLock);
-
-               for (i = 0; i < RX_RING_SIZE; i++) {
-                       pRxD = (struct rt_rxd *) pAd->RxRing.Cell[i].AllocVa;
-                       pRxD->DDONE = 0;
-               }
-
-               RTMP_IO_READ32(pAd, RX_DRX_IDX, &pAd->RxRing.RxDmaIdx);
-               pAd->RxRing.RxSwReadIdx = pAd->RxRing.RxDmaIdx;
-               pAd->RxRing.RxCpuIdx =
-                   ((pAd->RxRing.RxDmaIdx ==
-                     0) ? (RX_RING_SIZE - 1) : (pAd->RxRing.RxDmaIdx - 1));
-               RTMP_IO_WRITE32(pAd, RX_CRX_IDX, pAd->RxRing.RxCpuIdx);
-
-               NdisReleaseSpinLock(&pAd->RxRingLock);
-               break;
-
-       default:
-               break;
-       }
-}
-
-void RTMPFreeTxRxRingMemory(struct rt_rtmp_adapter *pAd)
-{
-       int index, num, j;
-       struct rt_rtmp_tx_ring *pTxRing;
-       struct rt_txd * pTxD;
-       void *pPacket;
-       unsigned int IrqFlags;
-
-       /*struct os_cookie *pObj =(struct os_cookie *)pAd->OS_Cookie; */
-
-       DBGPRINT(RT_DEBUG_TRACE, ("--> RTMPFreeTxRxRingMemory\n"));
-
-       /* Free TxSwQueue Packet */
-       for (index = 0; index < NUM_OF_TX_RING; index++) {
-               struct rt_queue_entry *pEntry;
-               void *pPacket;
-               struct rt_queue_header *pQueue;
-
-               RTMP_IRQ_LOCK(&pAd->irq_lock, IrqFlags);
-               pQueue = &pAd->TxSwQueue[index];
-               while (pQueue->Head) {
-                       pEntry = RemoveHeadQueue(pQueue);
-                       pPacket = QUEUE_ENTRY_TO_PACKET(pEntry);
-                       RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
-               }
-               RTMP_IRQ_UNLOCK(&pAd->irq_lock, IrqFlags);
-       }
-
-       /* Free Tx Ring Packet */
-       for (index = 0; index < NUM_OF_TX_RING; index++) {
-               pTxRing = &pAd->TxRing[index];
-
-               for (j = 0; j < TX_RING_SIZE; j++) {
-                       pTxD = (struct rt_txd *) (pTxRing->Cell[j].AllocVa);
-                       pPacket = pTxRing->Cell[j].pNdisPacket;
-
-                       if (pPacket) {
-                               PCI_UNMAP_SINGLE(pAd, pTxD->SDPtr0,
-                                                pTxD->SDLen0,
-                                                PCI_DMA_TODEVICE);
-                               RELEASE_NDIS_PACKET(pAd, pPacket,
-                                                   NDIS_STATUS_SUCCESS);
-                       }
-                       /*Always assign pNdisPacket as NULL after clear */
-                       pTxRing->Cell[j].pNdisPacket = NULL;
-
-                       pPacket = pTxRing->Cell[j].pNextNdisPacket;
-
-                       if (pPacket) {
-                               PCI_UNMAP_SINGLE(pAd, pTxD->SDPtr1,
-                                                pTxD->SDLen1,
-                                                PCI_DMA_TODEVICE);
-                               RELEASE_NDIS_PACKET(pAd, pPacket,
-                                                   NDIS_STATUS_SUCCESS);
-                       }
-                       /*Always assign pNextNdisPacket as NULL after clear */
-                       pTxRing->Cell[pTxRing->TxSwFreeIdx].pNextNdisPacket =
-                           NULL;
-
-               }
-       }
-
-       for (index = RX_RING_SIZE - 1; index >= 0; index--) {
-               if ((pAd->RxRing.Cell[index].DmaBuf.AllocVa)
-                   && (pAd->RxRing.Cell[index].pNdisPacket)) {
-                       PCI_UNMAP_SINGLE(pAd,
-                                        pAd->RxRing.Cell[index].DmaBuf.AllocPa,
-                                        pAd->RxRing.Cell[index].DmaBuf.
-                                        AllocSize, PCI_DMA_FROMDEVICE);
-                       RELEASE_NDIS_PACKET(pAd,
-                                           pAd->RxRing.Cell[index].pNdisPacket,
-                                           NDIS_STATUS_SUCCESS);
-               }
-       }
-       NdisZeroMemory(pAd->RxRing.Cell, RX_RING_SIZE * sizeof(struct rt_rtmp_dmacb));
-
-       if (pAd->RxDescRing.AllocVa) {
-               RTMP_FreeDescMemory(pAd, pAd->RxDescRing.AllocSize,
-                                   pAd->RxDescRing.AllocVa,
-                                   pAd->RxDescRing.AllocPa);
-       }
-       NdisZeroMemory(&pAd->RxDescRing, sizeof(struct rt_rtmp_dmabuf));
-
-       if (pAd->MgmtDescRing.AllocVa) {
-               RTMP_FreeDescMemory(pAd, pAd->MgmtDescRing.AllocSize,
-                                   pAd->MgmtDescRing.AllocVa,
-                                   pAd->MgmtDescRing.AllocPa);
-       }
-       NdisZeroMemory(&pAd->MgmtDescRing, sizeof(struct rt_rtmp_dmabuf));
-
-       for (num = 0; num < NUM_OF_TX_RING; num++) {
-               if (pAd->TxBufSpace[num].AllocVa) {
-                       RTMP_FreeFirstTxBuffer(pAd,
-                                              pAd->TxBufSpace[num].AllocSize,
-                                              FALSE,
-                                              pAd->TxBufSpace[num].AllocVa,
-                                              pAd->TxBufSpace[num].AllocPa);
-               }
-               NdisZeroMemory(&pAd->TxBufSpace[num], sizeof(struct rt_rtmp_dmabuf));
-
-               if (pAd->TxDescRing[num].AllocVa) {
-                       RTMP_FreeDescMemory(pAd, pAd->TxDescRing[num].AllocSize,
-                                           pAd->TxDescRing[num].AllocVa,
-                                           pAd->TxDescRing[num].AllocPa);
-               }
-               NdisZeroMemory(&pAd->TxDescRing[num], sizeof(struct rt_rtmp_dmabuf));
-       }
-
-       if (pAd->FragFrame.pFragPacket)
-               RELEASE_NDIS_PACKET(pAd, pAd->FragFrame.pFragPacket,
-                                   NDIS_STATUS_SUCCESS);
-
-       DBGPRINT(RT_DEBUG_TRACE, ("<-- RTMPFreeTxRxRingMemory\n"));
-}
-
-/***************************************************************************
-  *
-  *    register related procedures.
-  *
-  **************************************************************************/
-/*
-========================================================================
-Routine Description:
-    Disable DMA.
-
-Arguments:
-       *pAd                            the raxx interface data pointer
-
-Return Value:
-       None
-
-Note:
-========================================================================
-*/
-void RT28XXDMADisable(struct rt_rtmp_adapter *pAd)
-{
-       WPDMA_GLO_CFG_STRUC GloCfg;
-
-       RTMP_IO_READ32(pAd, WPDMA_GLO_CFG, &GloCfg.word);
-       GloCfg.word &= 0xff0;
-       GloCfg.field.EnTXWriteBackDDONE = 1;
-       RTMP_IO_WRITE32(pAd, WPDMA_GLO_CFG, GloCfg.word);
-}
-
-/*
-========================================================================
-Routine Description:
-    Enable DMA.
-
-Arguments:
-       *pAd                            the raxx interface data pointer
-
-Return Value:
-       None
-
-Note:
-========================================================================
-*/
-void RT28XXDMAEnable(struct rt_rtmp_adapter *pAd)
-{
-       WPDMA_GLO_CFG_STRUC GloCfg;
-       int i = 0;
-
-       RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, 0x4);
-       do {
-               RTMP_IO_READ32(pAd, WPDMA_GLO_CFG, &GloCfg.word);
-               if ((GloCfg.field.TxDMABusy == 0)
-                   && (GloCfg.field.RxDMABusy == 0))
-                       break;
-
-               DBGPRINT(RT_DEBUG_TRACE, ("==>  DMABusy\n"));
-               RTMPusecDelay(1000);
-               i++;
-       } while (i < 200);
-
-       RTMPusecDelay(50);
-
-       GloCfg.field.EnTXWriteBackDDONE = 1;
-       GloCfg.field.WPDMABurstSIZE = 2;
-       GloCfg.field.EnableRxDMA = 1;
-       GloCfg.field.EnableTxDMA = 1;
-
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("<== WRITE DMA offset 0x208 = 0x%x\n", GloCfg.word));
-       RTMP_IO_WRITE32(pAd, WPDMA_GLO_CFG, GloCfg.word);
-
-}
-
-BOOLEAN AsicCheckCommanOk(struct rt_rtmp_adapter *pAd, u8 Command)
-{
-       u32 CmdStatus = 0, CID = 0, i;
-       u32 ThisCIDMask = 0;
-
-       i = 0;
-       do {
-               RTMP_IO_READ32(pAd, H2M_MAILBOX_CID, &CID);
-               /* Find where the command is. Because this is randomly specified by firmware. */
-               if ((CID & CID0MASK) == Command) {
-                       ThisCIDMask = CID0MASK;
-                       break;
-               } else if ((((CID & CID1MASK) >> 8) & 0xff) == Command) {
-                       ThisCIDMask = CID1MASK;
-                       break;
-               } else if ((((CID & CID2MASK) >> 16) & 0xff) == Command) {
-                       ThisCIDMask = CID2MASK;
-                       break;
-               } else if ((((CID & CID3MASK) >> 24) & 0xff) == Command) {
-                       ThisCIDMask = CID3MASK;
-                       break;
-               }
-
-               RTMPusecDelay(100);
-               i++;
-       } while (i < 200);
-
-       /* Get CommandStatus Value */
-       RTMP_IO_READ32(pAd, H2M_MAILBOX_STATUS, &CmdStatus);
-
-       /* This command's status is at the same position as command. So AND command position's bitmask to read status. */
-       if (i < 200) {
-               /* If Status is 1, the command is success. */
-               if (((CmdStatus & ThisCIDMask) == 0x1)
-                   || ((CmdStatus & ThisCIDMask) == 0x100)
-                   || ((CmdStatus & ThisCIDMask) == 0x10000)
-                   || ((CmdStatus & ThisCIDMask) == 0x1000000)) {
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("--> AsicCheckCommanOk CID = 0x%x, CmdStatus= 0x%x \n",
-                                 CID, CmdStatus));
-                       RTMP_IO_WRITE32(pAd, H2M_MAILBOX_STATUS, 0xffffffff);
-                       RTMP_IO_WRITE32(pAd, H2M_MAILBOX_CID, 0xffffffff);
-                       return TRUE;
-               }
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("--> AsicCheckCommanFail1 CID = 0x%x, CmdStatus= 0x%x \n",
-                         CID, CmdStatus));
-       } else {
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("--> AsicCheckCommanFail2 Timeout Command = %d, CmdStatus= 0x%x \n",
-                         Command, CmdStatus));
-       }
-       /* Clear Command and Status. */
-       RTMP_IO_WRITE32(pAd, H2M_MAILBOX_STATUS, 0xffffffff);
-       RTMP_IO_WRITE32(pAd, H2M_MAILBOX_CID, 0xffffffff);
-
-       return FALSE;
-}
-
-/*
-========================================================================
-Routine Description:
-    Write Beacon buffer to Asic.
-
-Arguments:
-       *pAd                            the raxx interface data pointer
-
-Return Value:
-       None
-
-Note:
-========================================================================
-*/
-void RT28xx_UpdateBeaconToAsic(struct rt_rtmp_adapter *pAd,
-                              int apidx,
-                              unsigned long FrameLen, unsigned long UpdatePos)
-{
-       unsigned long CapInfoPos = 0;
-       u8 *ptr, *ptr_update, *ptr_capinfo;
-       u32 i;
-       BOOLEAN bBcnReq = FALSE;
-       u8 bcn_idx = 0;
-
-       {
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("%s() : No valid Interface be found.\n", __func__));
-               return;
-       }
-
-       /*if ((pAd->WdsTab.Mode == WDS_BRIDGE_MODE) */
-       /*      || ((pAd->ApCfg.MBSSID[apidx].MSSIDDev == NULL) */
-       /*              || !(pAd->ApCfg.MBSSID[apidx].MSSIDDev->flags & IFF_UP)) */
-       /*      ) */
-       if (bBcnReq == FALSE) {
-               /* when the ra interface is down, do not send its beacon frame */
-               /* clear all zero */
-               for (i = 0; i < TXWI_SIZE; i += 4)
-                       RTMP_IO_WRITE32(pAd, pAd->BeaconOffset[bcn_idx] + i,
-                                       0x00);
-       } else {
-               ptr = (u8 *)& pAd->BeaconTxWI;
-               for (i = 0; i < TXWI_SIZE; i += 4)      /* 16-byte TXWI field */
-               {
-                       u32 longptr =
-                           *ptr + (*(ptr + 1) << 8) + (*(ptr + 2) << 16) +
-                           (*(ptr + 3) << 24);
-                       RTMP_IO_WRITE32(pAd, pAd->BeaconOffset[bcn_idx] + i,
-                                       longptr);
-                       ptr += 4;
-               }
-
-               /* Update CapabilityInfo in Beacon */
-               for (i = CapInfoPos; i < (CapInfoPos + 2); i++) {
-                       RTMP_IO_WRITE8(pAd,
-                                      pAd->BeaconOffset[bcn_idx] + TXWI_SIZE +
-                                      i, *ptr_capinfo);
-                       ptr_capinfo++;
-               }
-
-               if (FrameLen > UpdatePos) {
-                       for (i = UpdatePos; i < (FrameLen); i++) {
-                               RTMP_IO_WRITE8(pAd,
-                                              pAd->BeaconOffset[bcn_idx] +
-                                              TXWI_SIZE + i, *ptr_update);
-                               ptr_update++;
-                       }
-               }
-
-       }
-
-}
-
-void RT28xxPciStaAsicForceWakeup(struct rt_rtmp_adapter *pAd, IN BOOLEAN bFromTx)
-{
-       AUTO_WAKEUP_STRUC AutoWakeupCfg;
-
-       if (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))
-               return;
-
-       if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_WAKEUP_NOW)) {
-               DBGPRINT(RT_DEBUG_TRACE, ("waking up now!\n"));
-               return;
-       }
-
-       OPSTATUS_SET_FLAG(pAd, fOP_STATUS_WAKEUP_NOW);
-
-       RTMP_CLEAR_PSFLAG(pAd, fRTMP_PS_GO_TO_SLEEP_NOW);
-
-       if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_PCIE_DEVICE)
-           && pAd->StaCfg.PSControl.field.EnableNewPS == TRUE) {
-               /* Support PCIe Advance Power Save */
-               if (bFromTx == TRUE && (pAd->Mlme.bPsPollTimerRunning == TRUE)) {
-                       pAd->Mlme.bPsPollTimerRunning = FALSE;
-                       RTMPPCIeLinkCtrlValueRestore(pAd, RESTORE_WAKEUP);
-                       RTMPusecDelay(3000);
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("=======AsicForceWakeup===bFromTx\n"));
-               }
-
-               AutoWakeupCfg.word = 0;
-               RTMP_IO_WRITE32(pAd, AUTO_WAKEUP_CFG, AutoWakeupCfg.word);
-
-               if (RT28xxPciAsicRadioOn(pAd, DOT11POWERSAVE)) {
-#ifdef PCIE_PS_SUPPORT
-                       /* add by johnli, RF power sequence setup, load RF normal operation-mode setup */
-                       if ((IS_RT3090(pAd) || IS_RT3572(pAd) || IS_RT3390(pAd))
-                           && IS_VERSION_AFTER_F(pAd)) {
-                               struct rt_rtmp_chip_op *pChipOps = &pAd->chipOps;
-
-                               if (pChipOps->AsicReverseRfFromSleepMode)
-                                       pChipOps->
-                                           AsicReverseRfFromSleepMode(pAd);
-                       } else
-#endif /* PCIE_PS_SUPPORT // */
-                       {
-                               /* end johnli */
-                               /* In Radio Off, we turn off RF clk, So now need to call ASICSwitchChannel again. */
-                               if (INFRA_ON(pAd)
-                                   && (pAd->CommonCfg.CentralChannel !=
-                                       pAd->CommonCfg.Channel)
-                                   && (pAd->MlmeAux.HtCapability.HtCapInfo.
-                                       ChannelWidth == BW_40)) {
-                                       /* Must using 40MHz. */
-                                       AsicSwitchChannel(pAd,
-                                                         pAd->CommonCfg.
-                                                         CentralChannel,
-                                                         FALSE);
-                                       AsicLockChannel(pAd,
-                                                       pAd->CommonCfg.
-                                                       CentralChannel);
-                               } else {
-                                       /* Must using 20MHz. */
-                                       AsicSwitchChannel(pAd,
-                                                         pAd->CommonCfg.
-                                                         Channel, FALSE);
-                                       AsicLockChannel(pAd,
-                                                       pAd->CommonCfg.Channel);
-                               }
-                       }
-               }
-#ifdef PCIE_PS_SUPPORT
-               /* 3090 MCU Wakeup command needs more time to be stable. */
-               /* Before stable, don't issue other MCU command to prevent from firmware error. */
-               if (((IS_RT3090(pAd) || IS_RT3572(pAd) || IS_RT3390(pAd))
-                    && IS_VERSION_AFTER_F(pAd)) && IS_VERSION_AFTER_F(pAd)
-                   && (pAd->StaCfg.PSControl.field.rt30xxPowerMode == 3)
-                   && (pAd->StaCfg.PSControl.field.EnableNewPS == TRUE)) {
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("<==RT28xxPciStaAsicForceWakeup::Release the MCU Lock(3090)\n"));
-                       RTMP_SEM_LOCK(&pAd->McuCmdLock);
-                       pAd->brt30xxBanMcuCmd = FALSE;
-                       RTMP_SEM_UNLOCK(&pAd->McuCmdLock);
-               }
-#endif /* PCIE_PS_SUPPORT // */
-       } else {
-               /* PCI, 2860-PCIe */
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("<==RT28xxPciStaAsicForceWakeup::Original PCI Power Saving\n"));
-               AsicSendCommandToMcu(pAd, 0x31, 0xff, 0x00, 0x02);
-               AutoWakeupCfg.word = 0;
-               RTMP_IO_WRITE32(pAd, AUTO_WAKEUP_CFG, AutoWakeupCfg.word);
-       }
-
-       OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_DOZE);
-       OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_WAKEUP_NOW);
-       DBGPRINT(RT_DEBUG_TRACE, ("<=======RT28xxPciStaAsicForceWakeup\n"));
-}
-
-void RT28xxPciStaAsicSleepThenAutoWakeup(struct rt_rtmp_adapter *pAd,
-                                        u16 TbttNumToNextWakeUp)
-{
-       BOOLEAN brc;
-
-       if (pAd->StaCfg.bRadio == FALSE) {
-               OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_DOZE);
-               return;
-       }
-       if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_PCIE_DEVICE)
-           && pAd->StaCfg.PSControl.field.EnableNewPS == TRUE) {
-               unsigned long Now = 0;
-               if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_WAKEUP_NOW)) {
-                       DBGPRINT(RT_DEBUG_TRACE, ("waking up now!\n"));
-                       OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_DOZE);
-                       return;
-               }
-
-               NdisGetSystemUpTime(&Now);
-               /* If last send NULL fram time is too close to this receiving beacon (within 8ms), don't go to sleep for this DTM. */
-               /* Because Some AP can't queuing outgoing frames immediately. */
-               if (((pAd->Mlme.LastSendNULLpsmTime + 8) >= Now)
-                   && (pAd->Mlme.LastSendNULLpsmTime <= Now)) {
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("Now = %lu, LastSendNULLpsmTime=%lu :  RxCountSinceLastNULL = %lu. \n",
-                                 Now, pAd->Mlme.LastSendNULLpsmTime,
-                                 pAd->RalinkCounters.RxCountSinceLastNULL));
-                       return;
-               } else if ((pAd->RalinkCounters.RxCountSinceLastNULL > 0)
-                          &&
-                          ((pAd->Mlme.LastSendNULLpsmTime +
-                            pAd->CommonCfg.BeaconPeriod) >= Now)) {
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("Now = %lu, LastSendNULLpsmTime=%lu: RxCountSinceLastNULL = %lu > 0 \n",
-                                 Now, pAd->Mlme.LastSendNULLpsmTime,
-                                 pAd->RalinkCounters.RxCountSinceLastNULL));
-                       return;
-               }
-
-               brc =
-                   RT28xxPciAsicRadioOff(pAd, DOT11POWERSAVE,
-                                         TbttNumToNextWakeUp);
-               if (brc == TRUE)
-                       OPSTATUS_SET_FLAG(pAd, fOP_STATUS_DOZE);
-       } else {
-               AUTO_WAKEUP_STRUC AutoWakeupCfg;
-               /* we have decided to SLEEP, so at least do it for a BEACON period. */
-               if (TbttNumToNextWakeUp == 0)
-                       TbttNumToNextWakeUp = 1;
-
-               /*RTMP_IO_WRITE32(pAd, INT_MASK_CSR, AutoWakeupInt); */
-
-               AutoWakeupCfg.word = 0;
-               RTMP_IO_WRITE32(pAd, AUTO_WAKEUP_CFG, AutoWakeupCfg.word);
-               AutoWakeupCfg.field.NumofSleepingTbtt = TbttNumToNextWakeUp - 1;
-               AutoWakeupCfg.field.EnableAutoWakeup = 1;
-               AutoWakeupCfg.field.AutoLeadTime = 5;
-               RTMP_IO_WRITE32(pAd, AUTO_WAKEUP_CFG, AutoWakeupCfg.word);
-               AsicSendCommandToMcu(pAd, 0x30, 0xff, 0xff, 0x00);      /* send POWER-SAVE command to MCU. Timeout 40us. */
-               OPSTATUS_SET_FLAG(pAd, fOP_STATUS_DOZE);
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("<-- %s, TbttNumToNextWakeUp=%d \n", __func__,
-                         TbttNumToNextWakeUp));
-       }
-
-}
-
-void PsPollWakeExec(void *SystemSpecific1,
-                   void *FunctionContext,
-                   void *SystemSpecific2, void *SystemSpecific3)
-{
-       struct rt_rtmp_adapter *pAd = (struct rt_rtmp_adapter *)FunctionContext;
-       unsigned long flags;
-
-       DBGPRINT(RT_DEBUG_TRACE, ("-->PsPollWakeExec \n"));
-       RTMP_INT_LOCK(&pAd->irq_lock, flags);
-       if (pAd->Mlme.bPsPollTimerRunning) {
-               RTMPPCIeLinkCtrlValueRestore(pAd, RESTORE_WAKEUP);
-       }
-       pAd->Mlme.bPsPollTimerRunning = FALSE;
-       RTMP_INT_UNLOCK(&pAd->irq_lock, flags);
-#ifdef PCIE_PS_SUPPORT
-       /* For rt30xx power solution 3, Use software timer to wake up in psm. So call */
-       /* AsicForceWakeup here instead of handling twakeup interrupt. */
-       if (((IS_RT3090(pAd) || IS_RT3572(pAd) || IS_RT3390(pAd))
-            && IS_VERSION_AFTER_F(pAd))
-           && (pAd->StaCfg.PSControl.field.rt30xxPowerMode == 3)
-           && (pAd->StaCfg.PSControl.field.EnableNewPS == TRUE)) {
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("<--PsPollWakeExec::3090 calls AsicForceWakeup(pAd, DOT11POWERSAVE) in advance \n"));
-               AsicForceWakeup(pAd, DOT11POWERSAVE);
-       }
-#endif /* PCIE_PS_SUPPORT // */
-}
-
-void RadioOnExec(void *SystemSpecific1,
-                void *FunctionContext,
-                void *SystemSpecific2, void *SystemSpecific3)
-{
-       struct rt_rtmp_adapter *pAd = (struct rt_rtmp_adapter *)FunctionContext;
-       struct rt_rtmp_chip_op *pChipOps = &pAd->chipOps;
-       WPDMA_GLO_CFG_STRUC DmaCfg;
-       BOOLEAN Cancelled;
-
-       if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE)) {
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("-->RadioOnExec() return on fOP_STATUS_DOZE == TRUE; \n"));
-/*KH Debug: Add the compile flag "RT2860 and condition */
-#ifdef RTMP_PCI_SUPPORT
-               if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_PCIE_DEVICE)
-                   && pAd->StaCfg.PSControl.field.EnableNewPS == TRUE)
-                       RTMPSetTimer(&pAd->Mlme.RadioOnOffTimer, 10);
-#endif /* RTMP_PCI_SUPPORT // */
-               return;
-       }
-
-       if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS)) {
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("-->RadioOnExec() return on SCAN_IN_PROGRESS; \n"));
-#ifdef RTMP_PCI_SUPPORT
-               if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_PCIE_DEVICE)
-                   && pAd->StaCfg.PSControl.field.EnableNewPS == TRUE)
-                       RTMPSetTimer(&pAd->Mlme.RadioOnOffTimer, 10);
-#endif /* RTMP_PCI_SUPPORT // */
-               return;
-       }
-/*KH Debug: need to check. I add the compile flag "CONFIG_STA_SUPPORT" to enclose the following codes. */
-#ifdef RTMP_PCI_SUPPORT
-       if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_PCIE_DEVICE)
-           && pAd->StaCfg.PSControl.field.EnableNewPS == TRUE) {
-               pAd->Mlme.bPsPollTimerRunning = FALSE;
-               RTMPCancelTimer(&pAd->Mlme.PsPollTimer, &Cancelled);
-       }
-#endif /* RTMP_PCI_SUPPORT // */
-       if (pAd->StaCfg.bRadio == TRUE) {
-               pAd->bPCIclkOff = FALSE;
-               RTMPRingCleanUp(pAd, QID_AC_BK);
-               RTMPRingCleanUp(pAd, QID_AC_BE);
-               RTMPRingCleanUp(pAd, QID_AC_VI);
-               RTMPRingCleanUp(pAd, QID_AC_VO);
-               RTMPRingCleanUp(pAd, QID_MGMT);
-               RTMPRingCleanUp(pAd, QID_RX);
-
-               /* 2. Send wake up command. */
-               AsicSendCommandToMcu(pAd, 0x31, PowerWakeCID, 0x00, 0x02);
-               /* 2-1. wait command ok. */
-               AsicCheckCommanOk(pAd, PowerWakeCID);
-
-               /* When PCI clock is off, don't want to service interrupt. So when back to clock on, enable interrupt. */
-               /*RTMP_IO_WRITE32(pAd, INT_MASK_CSR, (DELAYINTMASK|RxINT)); */
-               RTMP_ASIC_INTERRUPT_ENABLE(pAd);
-
-               /* 3. Enable Tx DMA. */
-               RTMP_IO_READ32(pAd, WPDMA_GLO_CFG, &DmaCfg.word);
-               DmaCfg.field.EnableTxDMA = 1;
-               RTMP_IO_WRITE32(pAd, WPDMA_GLO_CFG, DmaCfg.word);
-
-               /* In Radio Off, we turn off RF clk, So now need to call ASICSwitchChannel again. */
-               if (INFRA_ON(pAd)
-                   && (pAd->CommonCfg.CentralChannel != pAd->CommonCfg.Channel)
-                   && (pAd->MlmeAux.HtCapability.HtCapInfo.ChannelWidth ==
-                       BW_40)) {
-                       /* Must using 40MHz. */
-                       AsicSwitchChannel(pAd, pAd->CommonCfg.CentralChannel,
-                                         FALSE);
-                       AsicLockChannel(pAd, pAd->CommonCfg.CentralChannel);
-               } else {
-                       /* Must using 20MHz. */
-                       AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE);
-                       AsicLockChannel(pAd, pAd->CommonCfg.Channel);
-               }
-
-/*KH Debug:The following codes should be enclosed by RT3090 compile flag */
-               if (pChipOps->AsicReverseRfFromSleepMode)
-                       pChipOps->AsicReverseRfFromSleepMode(pAd);
-
-#ifdef PCIE_PS_SUPPORT
-/* 3090 MCU Wakeup command needs more time to be stable. */
-/* Before stable, don't issue other MCU command to prevent from firmware error. */
-               if ((IS_RT3090(pAd) || IS_RT3572(pAd) || IS_RT3390(pAd))
-                   && IS_VERSION_AFTER_F(pAd)
-                   && (pAd->StaCfg.PSControl.field.rt30xxPowerMode == 3)
-                   && (pAd->StaCfg.PSControl.field.EnableNewPS == TRUE)) {
-                       RTMP_SEM_LOCK(&pAd->McuCmdLock);
-                       pAd->brt30xxBanMcuCmd = FALSE;
-                       RTMP_SEM_UNLOCK(&pAd->McuCmdLock);
-               }
-#endif /* PCIE_PS_SUPPORT // */
-
-               /* Clear Radio off flag */
-               RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF);
-
-               /* Set LED */
-               RTMPSetLED(pAd, LED_RADIO_ON);
-
-               if (pAd->StaCfg.Psm == PWR_ACTIVE) {
-                       RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3,
-                                                    pAd->StaCfg.BBPR3);
-               }
-       } else {
-               RT28xxPciAsicRadioOff(pAd, GUIRADIO_OFF, 0);
-       }
-}
-
-/*
-       ==========================================================================
-       Description:
-               This routine sends command to firmware and turn our chip to wake up mode from power save mode.
-               Both RadioOn and .11 power save function needs to call this routine.
-       Input:
-               Level = GUIRADIO_OFF : call this function is from Radio Off to Radio On.  Need to restore PCI host value.
-               Level = other value : normal wake up function.
-
-       ==========================================================================
- */
-BOOLEAN RT28xxPciAsicRadioOn(struct rt_rtmp_adapter *pAd, u8 Level)
-{
-       /*WPDMA_GLO_CFG_STRUC       DmaCfg; */
-       BOOLEAN Cancelled;
-       /*u32                        MACValue; */
-
-       if (pAd->OpMode == OPMODE_AP && Level == DOT11POWERSAVE)
-               return FALSE;
-
-       if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_PCIE_DEVICE)) {
-               if (pAd->StaCfg.PSControl.field.EnableNewPS == TRUE) {
-                       pAd->Mlme.bPsPollTimerRunning = FALSE;
-                       RTMPCancelTimer(&pAd->Mlme.PsPollTimer, &Cancelled);
-               }
-               if ((pAd->StaCfg.PSControl.field.EnableNewPS == TRUE &&
-                    (Level == GUIRADIO_OFF || Level == GUI_IDLE_POWER_SAVE)) ||
-                   RTMP_TEST_PSFLAG(pAd, fRTMP_PS_SET_PCI_CLK_OFF_COMMAND)) {
-                       /* Some chips don't need to delay 6ms, so copy RTMPPCIePowerLinkCtrlRestore */
-                       /* return condition here. */
-                       /*
-                          if (((pAd->MACVersion&0xffff0000) != 0x28600000)
-                          && ((pAd->DeviceID == NIC2860_PCIe_DEVICE_ID)
-                          ||(pAd->DeviceID == NIC2790_PCIe_DEVICE_ID)))
-                        */
-                       {
-                               DBGPRINT(RT_DEBUG_TRACE,
-                                        ("RT28xxPciAsicRadioOn ()\n"));
-                               /* 1. Set PCI Link Control in Configuration Space. */
-                               RTMPPCIeLinkCtrlValueRestore(pAd,
-                                                            RESTORE_WAKEUP);
-                               RTMPusecDelay(6000);
-                       }
-               }
-       }
-#ifdef PCIE_PS_SUPPORT
-       if (!
-           (((IS_RT3090(pAd) || IS_RT3572(pAd) || IS_RT3390(pAd))
-             && IS_VERSION_AFTER_F(pAd)
-             && (pAd->StaCfg.PSControl.field.rt30xxPowerMode == 3)
-             && (pAd->StaCfg.PSControl.field.EnableNewPS == TRUE))))
-#endif /* PCIE_PS_SUPPORT // */
-       {
-               pAd->bPCIclkOff = FALSE;
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("PSM :309xbPCIclkOff == %d\n", pAd->bPCIclkOff));
-       }
-       /* 2. Send wake up command. */
-       AsicSendCommandToMcu(pAd, 0x31, PowerWakeCID, 0x00, 0x02);
-       pAd->bPCIclkOff = FALSE;
-       /* 2-1. wait command ok. */
-       AsicCheckCommanOk(pAd, PowerWakeCID);
-       RTMP_ASIC_INTERRUPT_ENABLE(pAd);
-
-       RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_IDLE_RADIO_OFF);
-       if (Level == GUI_IDLE_POWER_SAVE) {
-#ifdef  PCIE_PS_SUPPORT
-
-               /* add by johnli, RF power sequence setup, load RF normal operation-mode setup */
-               if ((IS_RT3090(pAd) || IS_RT3572(pAd) || IS_RT3390(pAd))) {
-                       struct rt_rtmp_chip_op *pChipOps = &pAd->chipOps;
-
-                       if (pChipOps->AsicReverseRfFromSleepMode)
-                               pChipOps->AsicReverseRfFromSleepMode(pAd);
-                       /* 3090 MCU Wakeup command needs more time to be stable. */
-                       /* Before stable, don't issue other MCU command to prevent from firmware error. */
-                       if ((IS_RT3090(pAd) || IS_RT3572(pAd) || IS_RT3390(pAd))
-                           && IS_VERSION_AFTER_F(pAd)
-                           && (pAd->StaCfg.PSControl.field.rt30xxPowerMode ==
-                               3)
-                           && (pAd->StaCfg.PSControl.field.EnableNewPS ==
-                               TRUE)) {
-                               RTMP_SEM_LOCK(&pAd->McuCmdLock);
-                               pAd->brt30xxBanMcuCmd = FALSE;
-                               RTMP_SEM_UNLOCK(&pAd->McuCmdLock);
-                       }
-               } else
-                       /* end johnli */
-#endif /* PCIE_PS_SUPPORT // */
-               {
-                       /* In Radio Off, we turn off RF clk, So now need to call ASICSwitchChannel again. */
-                       {
-                               if (INFRA_ON(pAd)
-                                   && (pAd->CommonCfg.CentralChannel !=
-                                       pAd->CommonCfg.Channel)
-                                   && (pAd->MlmeAux.HtCapability.HtCapInfo.
-                                       ChannelWidth == BW_40)) {
-                                       /* Must using 40MHz. */
-                                       AsicSwitchChannel(pAd,
-                                                         pAd->CommonCfg.
-                                                         CentralChannel,
-                                                         FALSE);
-                                       AsicLockChannel(pAd,
-                                                       pAd->CommonCfg.
-                                                       CentralChannel);
-                               } else {
-                                       /* Must using 20MHz. */
-                                       AsicSwitchChannel(pAd,
-                                                         pAd->CommonCfg.
-                                                         Channel, FALSE);
-                                       AsicLockChannel(pAd,
-                                                       pAd->CommonCfg.Channel);
-                               }
-                       }
-
-               }
-       }
-       return TRUE;
-
-}
-
-/*
-       ==========================================================================
-       Description:
-               This routine sends command to firmware and turn our chip to power save mode.
-               Both RadioOff and .11 power save function needs to call this routine.
-       Input:
-               Level = GUIRADIO_OFF  : GUI Radio Off mode
-               Level = DOT11POWERSAVE  : 802.11 power save mode
-               Level = RTMP_HALT  : When Disable device.
-
-       ==========================================================================
- */
-BOOLEAN RT28xxPciAsicRadioOff(struct rt_rtmp_adapter *pAd,
-                             u8 Level, u16 TbttNumToNextWakeUp)
-{
-       WPDMA_GLO_CFG_STRUC DmaCfg;
-       u8 i, tempBBP_R3 = 0;
-       BOOLEAN brc = FALSE, Cancelled;
-       u32 TbTTTime = 0;
-       u32 PsPollTime = 0 /*, MACValue */ ;
-       unsigned long BeaconPeriodTime;
-       u32 RxDmaIdx, RxCpuIdx;
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("AsicRadioOff ===> Lv= %d, TxCpuIdx = %d, TxDmaIdx = %d. RxCpuIdx = %d, RxDmaIdx = %d.\n",
-                 Level, pAd->TxRing[0].TxCpuIdx, pAd->TxRing[0].TxDmaIdx,
-                 pAd->RxRing.RxCpuIdx, pAd->RxRing.RxDmaIdx));
-
-       if (pAd->OpMode == OPMODE_AP && Level == DOT11POWERSAVE)
-               return FALSE;
-
-       /* Check Rx DMA busy status, if more than half is occupied, give up this radio off. */
-       RTMP_IO_READ32(pAd, RX_DRX_IDX, &RxDmaIdx);
-       RTMP_IO_READ32(pAd, RX_CRX_IDX, &RxCpuIdx);
-       if ((RxDmaIdx > RxCpuIdx) && ((RxDmaIdx - RxCpuIdx) > RX_RING_SIZE / 3)) {
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("AsicRadioOff ===> return1. RxDmaIdx = %d ,  RxCpuIdx = %d. \n",
-                         RxDmaIdx, RxCpuIdx));
-               return FALSE;
-       } else if ((RxCpuIdx >= RxDmaIdx)
-                  && ((RxCpuIdx - RxDmaIdx) < RX_RING_SIZE / 3)) {
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("AsicRadioOff ===> return2.  RxCpuIdx = %d. RxDmaIdx = %d ,  \n",
-                         RxCpuIdx, RxDmaIdx));
-               return FALSE;
-       }
-       /* Once go into this function, disable tx because don't want too many packets in queue to prevent HW stops. */
-       /*pAd->bPCIclkOffDisableTx = TRUE; */
-       RTMP_SET_PSFLAG(pAd, fRTMP_PS_DISABLE_TX);
-       if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_PCIE_DEVICE)
-           && pAd->OpMode == OPMODE_STA
-           && pAd->StaCfg.PSControl.field.EnableNewPS == TRUE) {
-               RTMPCancelTimer(&pAd->Mlme.RadioOnOffTimer, &Cancelled);
-               RTMPCancelTimer(&pAd->Mlme.PsPollTimer, &Cancelled);
-
-               if (Level == DOT11POWERSAVE) {
-                       RTMP_IO_READ32(pAd, TBTT_TIMER, &TbTTTime);
-                       TbTTTime &= 0x1ffff;
-                       /* 00. check if need to do sleep in this DTIM period.   If next beacon will arrive within 30ms , ...doesn't necessarily sleep. */
-                       /* TbTTTime uint = 64us, LEAD_TIME unit = 1024us, PsPollTime unit = 1ms */
-                       if (((64 * TbTTTime) < ((LEAD_TIME * 1024) + 40000))
-                           && (TbttNumToNextWakeUp == 0)) {
-                               DBGPRINT(RT_DEBUG_TRACE,
-                                        ("TbTTTime = 0x%x , give up this sleep. \n",
-                                         TbTTTime));
-                               OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_DOZE);
-                               /*pAd->bPCIclkOffDisableTx = FALSE; */
-                               RTMP_CLEAR_PSFLAG(pAd, fRTMP_PS_DISABLE_TX);
-                               return FALSE;
-                       } else {
-                               PsPollTime =
-                                   (64 * TbTTTime - LEAD_TIME * 1024) / 1000;
-#ifdef PCIE_PS_SUPPORT
-                               if ((IS_RT3090(pAd) || IS_RT3572(pAd)
-                                    || IS_RT3390(pAd))
-                                   && IS_VERSION_AFTER_F(pAd)
-                                   && (pAd->StaCfg.PSControl.field.
-                                       rt30xxPowerMode == 3)
-                                   && (pAd->StaCfg.PSControl.field.
-                                       EnableNewPS == TRUE)) {
-                                       PsPollTime -= 5;
-                               } else
-#endif /* PCIE_PS_SUPPORT // */
-                                       PsPollTime -= 3;
-
-                               BeaconPeriodTime =
-                                   pAd->CommonCfg.BeaconPeriod * 102 / 100;
-                               if (TbttNumToNextWakeUp > 0)
-                                       PsPollTime +=
-                                           ((TbttNumToNextWakeUp -
-                                             1) * BeaconPeriodTime);
-
-                               pAd->Mlme.bPsPollTimerRunning = TRUE;
-                               RTMPSetTimer(&pAd->Mlme.PsPollTimer,
-                                            PsPollTime);
-                       }
-               }
-       } else {
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("RT28xxPciAsicRadioOff::Level!=DOT11POWERSAVE \n"));
-       }
-
-       pAd->bPCIclkOffDisableTx = FALSE;
-
-       RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_IDLE_RADIO_OFF);
-
-       /* Set to 1R. */
-       if (pAd->Antenna.field.RxPath > 1 && pAd->OpMode == OPMODE_STA) {
-               tempBBP_R3 = (pAd->StaCfg.BBPR3 & 0xE7);
-               RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, tempBBP_R3);
-       }
-       /* In Radio Off, we turn off RF clk, So now need to call ASICSwitchChannel again. */
-       if ((INFRA_ON(pAd) || pAd->OpMode == OPMODE_AP)
-           && (pAd->CommonCfg.CentralChannel != pAd->CommonCfg.Channel)
-           && (pAd->MlmeAux.HtCapability.HtCapInfo.ChannelWidth == BW_40)) {
-               /* Must using 40MHz. */
-               AsicTurnOffRFClk(pAd, pAd->CommonCfg.CentralChannel);
-       } else {
-               /* Must using 20MHz. */
-               AsicTurnOffRFClk(pAd, pAd->CommonCfg.Channel);
-       }
-
-       if (Level != RTMP_HALT) {
-               /* Change Interrupt bitmask. */
-               /* When PCI clock is off, don't want to service interrupt. */
-               RTMP_IO_WRITE32(pAd, INT_MASK_CSR, AutoWakeupInt);
-       } else {
-               RTMP_ASIC_INTERRUPT_DISABLE(pAd);
-       }
-
-       RTMP_IO_WRITE32(pAd, RX_CRX_IDX, pAd->RxRing.RxCpuIdx);
-       /*  2. Send Sleep command */
-       RTMP_IO_WRITE32(pAd, H2M_MAILBOX_STATUS, 0xffffffff);
-       RTMP_IO_WRITE32(pAd, H2M_MAILBOX_CID, 0xffffffff);
-       /* send POWER-SAVE command to MCU. high-byte = 1 save power as much as possible. high byte = 0 save less power */
-       AsicSendCommandToMcu(pAd, 0x30, PowerSafeCID, 0xff, 0x1);
-       /*  2-1. Wait command success */
-       /* Status = 1 : success, Status = 2, already sleep, Status = 3, Maybe MAC is busy so can't finish this task. */
-       brc = AsicCheckCommanOk(pAd, PowerSafeCID);
-
-       /*  3. After 0x30 command is ok, send radio off command. lowbyte = 0 for power safe. */
-       /* If 0x30 command is not ok this time, we can ignore 0x35 command. It will make sure not cause firmware'r problem. */
-       if ((Level == DOT11POWERSAVE) && (brc == TRUE)) {
-               AsicSendCommandToMcu(pAd, 0x35, PowerRadioOffCID, 0, 0x00);     /* lowbyte = 0 means to do power safe, NOT turn off radio. */
-               /*  3-1. Wait command success */
-               AsicCheckCommanOk(pAd, PowerRadioOffCID);
-       } else if (brc == TRUE) {
-               AsicSendCommandToMcu(pAd, 0x35, PowerRadioOffCID, 1, 0x00);     /* lowbyte = 0 means to do power safe, NOT turn off radio. */
-               /*  3-1. Wait command success */
-               AsicCheckCommanOk(pAd, PowerRadioOffCID);
-       }
-       /* 1. Wait DMA not busy */
-       i = 0;
-       do {
-               RTMP_IO_READ32(pAd, WPDMA_GLO_CFG, &DmaCfg.word);
-               if ((DmaCfg.field.RxDMABusy == 0)
-                   && (DmaCfg.field.TxDMABusy == 0))
-                       break;
-               RTMPusecDelay(20);
-               i++;
-       } while (i < 50);
-
-       /*
-          if (i >= 50)
-          {
-          pAd->CheckDmaBusyCount++;
-          DBGPRINT(RT_DEBUG_TRACE, ("DMA Rx keeps busy.  return on AsicRadioOff () CheckDmaBusyCount = %d \n", pAd->CheckDmaBusyCount));
-          }
-          else
-          {
-          pAd->CheckDmaBusyCount = 0;
-          }
-        */
-/*KH Debug:My original codes have the following codes, but currecnt codes do not have it. */
-/* Disable for stability. If PCIE Link Control is modified for advance power save, re-covery this code segment. */
-       RTMP_IO_WRITE32(pAd, PBF_SYS_CTRL, 0x1280);
-/*OPSTATUS_SET_FLAG(pAd, fOP_STATUS_CLKSELECT_40MHZ); */
-
-#ifdef PCIE_PS_SUPPORT
-       if ((IS_RT3090(pAd) || IS_RT3572(pAd) || IS_RT3390(pAd))
-           && IS_VERSION_AFTER_F(pAd)
-           && (pAd->StaCfg.PSControl.field.rt30xxPowerMode == 3)
-           && (pAd->StaCfg.PSControl.field.EnableNewPS == TRUE)) {
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("RT28xxPciAsicRadioOff::3090 return to skip the following TbttNumToNextWakeUp setting for 279x\n"));
-               pAd->bPCIclkOff = TRUE;
-               RTMP_CLEAR_PSFLAG(pAd, fRTMP_PS_DISABLE_TX);
-               /* For this case, doesn't need to below actions, so return here. */
-               return brc;
-       }
-#endif /* PCIE_PS_SUPPORT // */
-
-       if (Level == DOT11POWERSAVE) {
-               AUTO_WAKEUP_STRUC AutoWakeupCfg;
-               /*RTMPSetTimer(&pAd->Mlme.PsPollTimer, 90); */
-
-               /* we have decided to SLEEP, so at least do it for a BEACON period. */
-               if (TbttNumToNextWakeUp == 0)
-                       TbttNumToNextWakeUp = 1;
-
-               AutoWakeupCfg.word = 0;
-               RTMP_IO_WRITE32(pAd, AUTO_WAKEUP_CFG, AutoWakeupCfg.word);
-
-               /* 1. Set auto wake up timer. */
-               AutoWakeupCfg.field.NumofSleepingTbtt = TbttNumToNextWakeUp - 1;
-               AutoWakeupCfg.field.EnableAutoWakeup = 1;
-               AutoWakeupCfg.field.AutoLeadTime = LEAD_TIME;
-               RTMP_IO_WRITE32(pAd, AUTO_WAKEUP_CFG, AutoWakeupCfg.word);
-       }
-       /*  4-1. If it's to disable our device. Need to restore PCI Configuration Space to its original value. */
-       if (Level == RTMP_HALT && pAd->OpMode == OPMODE_STA) {
-               if ((brc == TRUE) && (i < 50))
-                       RTMPPCIeLinkCtrlSetting(pAd, 1);
-       }
-       /*  4. Set PCI configuration Space Link Comtrol fields.  Only Radio Off needs to call this function */
-       else if (pAd->OpMode == OPMODE_STA) {
-               if ((brc == TRUE) && (i < 50))
-                       RTMPPCIeLinkCtrlSetting(pAd, 3);
-       }
-       /*pAd->bPCIclkOffDisableTx = FALSE; */
-       RTMP_CLEAR_PSFLAG(pAd, fRTMP_PS_DISABLE_TX);
-       return TRUE;
-}
-
-void RT28xxPciMlmeRadioOn(struct rt_rtmp_adapter *pAd)
-{
-       if (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF))
-               return;
-
-       DBGPRINT(RT_DEBUG_TRACE, ("%s===>\n", __func__));
-
-       if ((pAd->OpMode == OPMODE_AP) || ((pAd->OpMode == OPMODE_STA)
-                                          &&
-                                          (!OPSTATUS_TEST_FLAG
-                                           (pAd, fOP_STATUS_PCIE_DEVICE)
-                                           || pAd->StaCfg.PSControl.field.
-                                           EnableNewPS == FALSE))) {
-               RT28xxPciAsicRadioOn(pAd, GUI_IDLE_POWER_SAVE);
-               /*NICResetFromError(pAd); */
-
-               RTMPRingCleanUp(pAd, QID_AC_BK);
-               RTMPRingCleanUp(pAd, QID_AC_BE);
-               RTMPRingCleanUp(pAd, QID_AC_VI);
-               RTMPRingCleanUp(pAd, QID_AC_VO);
-               RTMPRingCleanUp(pAd, QID_MGMT);
-               RTMPRingCleanUp(pAd, QID_RX);
-
-               /* Enable Tx/Rx */
-               RTMPEnableRxTx(pAd);
-
-               /* Clear Radio off flag */
-               RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF);
-
-               RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_IDLE_RADIO_OFF);
-
-               /* Set LED */
-               RTMPSetLED(pAd, LED_RADIO_ON);
-       }
-
-       if ((pAd->OpMode == OPMODE_STA) &&
-           (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_PCIE_DEVICE))
-           && (pAd->StaCfg.PSControl.field.EnableNewPS == TRUE)) {
-               BOOLEAN Cancelled;
-
-               RTMPPCIeLinkCtrlValueRestore(pAd, RESTORE_WAKEUP);
-
-               pAd->Mlme.bPsPollTimerRunning = FALSE;
-               RTMPCancelTimer(&pAd->Mlme.PsPollTimer, &Cancelled);
-               RTMPCancelTimer(&pAd->Mlme.RadioOnOffTimer, &Cancelled);
-               RTMPSetTimer(&pAd->Mlme.RadioOnOffTimer, 40);
-       }
-}
-
-void RT28xxPciMlmeRadioOFF(struct rt_rtmp_adapter *pAd)
-{
-       BOOLEAN brc = TRUE;
-
-       if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF))
-               return;
-
-       /* Link down first if any association exists */
-       if (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)) {
-               if (INFRA_ON(pAd) || ADHOC_ON(pAd)) {
-                       struct rt_mlme_disassoc_req DisReq;
-                       struct rt_mlme_queue_elem *pMsgElem =
-                           kmalloc(sizeof(struct rt_mlme_queue_elem),
-                                                       MEM_ALLOC_FLAG);
-
-                       if (pMsgElem) {
-                               COPY_MAC_ADDR(&DisReq.Addr,
-                                             pAd->CommonCfg.Bssid);
-                               DisReq.Reason = REASON_DISASSOC_STA_LEAVING;
-
-                               pMsgElem->Machine = ASSOC_STATE_MACHINE;
-                               pMsgElem->MsgType = MT2_MLME_DISASSOC_REQ;
-                               pMsgElem->MsgLen =
-                                   sizeof(struct rt_mlme_disassoc_req);
-                               NdisMoveMemory(pMsgElem->Msg, &DisReq,
-                                              sizeof
-                                              (struct rt_mlme_disassoc_req));
-
-                               MlmeDisassocReqAction(pAd, pMsgElem);
-                               kfree(pMsgElem);
-
-                               RTMPusecDelay(1000);
-                       }
-               }
-       }
-
-       DBGPRINT(RT_DEBUG_TRACE, ("%s===>\n", __func__));
-
-       /* Set Radio off flag */
-       RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF);
-
-       {
-               BOOLEAN Cancelled;
-               if (pAd->StaCfg.PSControl.field.EnableNewPS == TRUE) {
-                       if (RTMP_TEST_FLAG
-                           (pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS)) {
-                               RTMPCancelTimer(&pAd->MlmeAux.ScanTimer,
-                                               &Cancelled);
-                               RTMP_CLEAR_FLAG(pAd,
-                                               fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS);
-                       }
-                       /* If during power safe mode. */
-                       if (pAd->StaCfg.bRadio == TRUE) {
-                               DBGPRINT(RT_DEBUG_TRACE,
-                                        ("-->MlmeRadioOff() return on bRadio == TRUE; \n"));
-                               return;
-                       }
-                       /* Always radio on since the NIC needs to set the MCU command (LED_RADIO_OFF). */
-                       if (IDLE_ON(pAd) &&
-                           (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_IDLE_RADIO_OFF)))
-                       {
-                               RT28xxPciAsicRadioOn(pAd, GUI_IDLE_POWER_SAVE);
-                       }
-                       if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_PCIE_DEVICE)) {
-                               BOOLEAN Cancelled;
-                               pAd->Mlme.bPsPollTimerRunning = FALSE;
-                               RTMPCancelTimer(&pAd->Mlme.PsPollTimer,
-                                               &Cancelled);
-                               RTMPCancelTimer(&pAd->Mlme.RadioOnOffTimer,
-                                               &Cancelled);
-                       }
-               }
-               /* Link down first if any association exists */
-               if (INFRA_ON(pAd) || ADHOC_ON(pAd))
-                       LinkDown(pAd, FALSE);
-               RTMPusecDelay(10000);
-               /*========================================== */
-               /* Clean up old bss table */
-               BssTableInit(&pAd->ScanTab);
-
-               /*
-                  if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_PCIE_DEVICE))
-                  {
-                  RTMPSetTimer(&pAd->Mlme.RadioOnOffTimer, 10);
-                  return;
-                  }
-                */
-       }
-
-       /* Set LED.Move to here for fixing LED bug. This flag must be called after LinkDown */
-       RTMPSetLED(pAd, LED_RADIO_OFF);
-
-/*KH Debug:All PCIe devices need to use timer to execute radio off function, or the PCIe&&EnableNewPS needs. */
-/*KH Ans:It is right, because only when the PCIe and EnableNewPs is true, we need to delay the RadioOffTimer */
-/*to avoid the deadlock with PCIe Power saving function. */
-       if (pAd->OpMode == OPMODE_STA &&
-           OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_PCIE_DEVICE) &&
-           pAd->StaCfg.PSControl.field.EnableNewPS == TRUE) {
-               RTMPSetTimer(&pAd->Mlme.RadioOnOffTimer, 10);
-       } else {
-               brc = RT28xxPciAsicRadioOff(pAd, GUIRADIO_OFF, 0);
-
-               if (brc == FALSE) {
-                       DBGPRINT(RT_DEBUG_ERROR,
-                                ("%s call RT28xxPciAsicRadioOff fail!\n",
-                                 __func__));
-               }
-       }
-/*
-*/
-}
-
-#endif /* RTMP_MAC_PCI // */
diff --git a/drivers/staging/rt2860/common/cmm_mac_usb.c b/drivers/staging/rt2860/common/cmm_mac_usb.c
deleted file mode 100644 (file)
index 64a65a4..0000000
+++ /dev/null
@@ -1,1162 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-*/
-
-#ifdef RTMP_MAC_USB
-
-#include       "../rt_config.h"
-
-/*
-========================================================================
-Routine Description:
-    Initialize receive data structures.
-
-Arguments:
-    pAd                                        Pointer to our adapter
-
-Return Value:
-       NDIS_STATUS_SUCCESS
-       NDIS_STATUS_RESOURCES
-
-Note:
-       Initialize all receive releated private buffer, include those define
-       in struct rt_rtmp_adapter structure and all private data structures. The mahor
-       work is to allocate buffer for each packet and chain buffer to
-       NDIS packet descriptor.
-========================================================================
-*/
-int NICInitRecv(struct rt_rtmp_adapter *pAd)
-{
-       u8 i;
-       int Status = NDIS_STATUS_SUCCESS;
-       struct os_cookie *pObj = (struct os_cookie *)pAd->OS_Cookie;
-
-       DBGPRINT(RT_DEBUG_TRACE, ("--> NICInitRecv\n"));
-       pObj = pObj;
-
-       /*InterlockedExchange(&pAd->PendingRx, 0); */
-       pAd->PendingRx = 0;
-       pAd->NextRxBulkInReadIndex = 0; /* Next Rx Read index */
-       pAd->NextRxBulkInIndex = 0;     /*RX_RING_SIZE -1; // Rx Bulk pointer */
-       pAd->NextRxBulkInPosition = 0;
-
-       for (i = 0; i < (RX_RING_SIZE); i++) {
-               struct rt_rx_context *pRxContext = &(pAd->RxContext[i]);
-
-               /*Allocate URB */
-               pRxContext->pUrb = RTUSB_ALLOC_URB(0);
-               if (pRxContext->pUrb == NULL) {
-                       Status = NDIS_STATUS_RESOURCES;
-                       goto out1;
-               }
-               /* Allocate transfer buffer */
-               pRxContext->TransferBuffer =
-                   RTUSB_URB_ALLOC_BUFFER(pObj->pUsb_Dev, MAX_RXBULK_SIZE,
-                                          &pRxContext->data_dma);
-               if (pRxContext->TransferBuffer == NULL) {
-                       Status = NDIS_STATUS_RESOURCES;
-                       goto out1;
-               }
-
-               NdisZeroMemory(pRxContext->TransferBuffer, MAX_RXBULK_SIZE);
-
-               pRxContext->pAd = pAd;
-               pRxContext->pIrp = NULL;
-               pRxContext->InUse = FALSE;
-               pRxContext->IRPPending = FALSE;
-               pRxContext->Readable = FALSE;
-               /*pRxContext->ReorderInUse = FALSE; */
-               pRxContext->bRxHandling = FALSE;
-               pRxContext->BulkInOffset = 0;
-       }
-
-       DBGPRINT(RT_DEBUG_TRACE, ("<-- NICInitRecv(Status=%d)\n", Status));
-       return Status;
-
-out1:
-       for (i = 0; i < (RX_RING_SIZE); i++) {
-               struct rt_rx_context *pRxContext = &(pAd->RxContext[i]);
-
-               if (NULL != pRxContext->TransferBuffer) {
-                       RTUSB_URB_FREE_BUFFER(pObj->pUsb_Dev, MAX_RXBULK_SIZE,
-                                             pRxContext->TransferBuffer,
-                                             pRxContext->data_dma);
-                       pRxContext->TransferBuffer = NULL;
-               }
-
-               if (NULL != pRxContext->pUrb) {
-                       RTUSB_UNLINK_URB(pRxContext->pUrb);
-                       RTUSB_FREE_URB(pRxContext->pUrb);
-                       pRxContext->pUrb = NULL;
-               }
-       }
-
-       return Status;
-}
-
-/*
-========================================================================
-Routine Description:
-    Initialize transmit data structures.
-
-Arguments:
-    pAd                                        Pointer to our adapter
-
-Return Value:
-       NDIS_STATUS_SUCCESS
-       NDIS_STATUS_RESOURCES
-
-Note:
-========================================================================
-*/
-int NICInitTransmit(struct rt_rtmp_adapter *pAd)
-{
-#define LM_USB_ALLOC(pObj, Context, TB_Type, BufferSize, Status, msg1, err1, msg2, err2)       \
-       Context->pUrb = RTUSB_ALLOC_URB(0);             \
-       if (Context->pUrb == NULL) {                    \
-               DBGPRINT(RT_DEBUG_ERROR, msg1);         \
-               Status = NDIS_STATUS_RESOURCES;         \
-               goto err1; }                                            \
-                                                                                       \
-       Context->TransferBuffer =                               \
-               (TB_Type)RTUSB_URB_ALLOC_BUFFER(pObj->pUsb_Dev, BufferSize, &Context->data_dma);        \
-       if (Context->TransferBuffer == NULL) {  \
-               DBGPRINT(RT_DEBUG_ERROR, msg2);         \
-               Status = NDIS_STATUS_RESOURCES;         \
-               goto err2; }
-
-#define LM_URB_FREE(pObj, Context, BufferSize)                         \
-       if (NULL != Context->pUrb) {                                                    \
-               RTUSB_UNLINK_URB(Context->pUrb);                                        \
-               RTUSB_FREE_URB(Context->pUrb);                                          \
-               Context->pUrb = NULL; }                                                         \
-       if (NULL != Context->TransferBuffer) {                          \
-               RTUSB_URB_FREE_BUFFER(pObj->pUsb_Dev, BufferSize,       \
-                                                               Context->TransferBuffer,        \
-                                                               Context->data_dma);                     \
-               Context->TransferBuffer = NULL; }
-
-       u8 i, acidx;
-       int Status = NDIS_STATUS_SUCCESS;
-       struct rt_tx_context *pNullContext = &(pAd->NullContext);
-       struct rt_tx_context *pPsPollContext = &(pAd->PsPollContext);
-       struct rt_tx_context *pRTSContext = &(pAd->RTSContext);
-       struct rt_tx_context *pMLMEContext = NULL;
-/*      struct rt_ht_tx_context *pHTTXContext = NULL; */
-       struct os_cookie *pObj = (struct os_cookie *)pAd->OS_Cookie;
-       void *RingBaseVa;
-/*      struct rt_rtmp_tx_ring *pTxRing; */
-       struct rt_rtmp_mgmt_ring *pMgmtRing;
-
-       DBGPRINT(RT_DEBUG_TRACE, ("--> NICInitTransmit\n"));
-       pObj = pObj;
-
-       /* Init 4 set of Tx parameters */
-       for (acidx = 0; acidx < NUM_OF_TX_RING; acidx++) {
-               /* Initialize all Transmit releated queues */
-               InitializeQueueHeader(&pAd->TxSwQueue[acidx]);
-
-               /* Next Local tx ring pointer waiting for buck out */
-               pAd->NextBulkOutIndex[acidx] = acidx;
-               pAd->BulkOutPending[acidx] = FALSE;     /* Buck Out control flag */
-               /*pAd->DataBulkDoneIdx[acidx] = 0; */
-       }
-
-       /*pAd->NextMLMEIndex    = 0; */
-       /*pAd->PushMgmtIndex    = 0; */
-       /*pAd->PopMgmtIndex     = 0; */
-       /*InterlockedExchange(&pAd->MgmtQueueSize, 0); */
-       /*InterlockedExchange(&pAd->TxCount, 0); */
-
-       /*pAd->PrioRingFirstIndex       = 0; */
-       /*pAd->PrioRingTxCnt            = 0; */
-
-       do {
-               /* */
-               /* TX_RING_SIZE, 4 ACs */
-               /* */
-               for (acidx = 0; acidx < 4; acidx++) {
-                       struct rt_ht_tx_context *pHTTXContext = &(pAd->TxContext[acidx]);
-
-                       NdisZeroMemory(pHTTXContext, sizeof(struct rt_ht_tx_context));
-                       /*Allocate URB */
-                       LM_USB_ALLOC(pObj, pHTTXContext, struct rt_httx_buffer *,
-                                    sizeof(struct rt_httx_buffer), Status,
-                                    ("<-- ERROR in Alloc TX TxContext[%d] urb!\n",
-                                     acidx), done,
-                                    ("<-- ERROR in Alloc TX TxContext[%d] struct rt_httx_buffer!\n",
-                                     acidx), out1);
-
-                       NdisZeroMemory(pHTTXContext->TransferBuffer->
-                                      Aggregation, 4);
-                       pHTTXContext->pAd = pAd;
-                       pHTTXContext->pIrp = NULL;
-                       pHTTXContext->IRPPending = FALSE;
-                       pHTTXContext->NextBulkOutPosition = 0;
-                       pHTTXContext->ENextBulkOutPosition = 0;
-                       pHTTXContext->CurWritePosition = 0;
-                       pHTTXContext->CurWriteRealPos = 0;
-                       pHTTXContext->BulkOutSize = 0;
-                       pHTTXContext->BulkOutPipeId = acidx;
-                       pHTTXContext->bRingEmpty = TRUE;
-                       pHTTXContext->bCopySavePad = FALSE;
-                       pAd->BulkOutPending[acidx] = FALSE;
-               }
-
-               /* */
-               /* MGMT_RING_SIZE */
-               /* */
-
-               /* Allocate MGMT ring descriptor's memory */
-               pAd->MgmtDescRing.AllocSize =
-                   MGMT_RING_SIZE * sizeof(struct rt_tx_context);
-               os_alloc_mem(pAd, (u8 **) (&pAd->MgmtDescRing.AllocVa),
-                            pAd->MgmtDescRing.AllocSize);
-               if (pAd->MgmtDescRing.AllocVa == NULL) {
-                       DBGPRINT_ERR("Failed to allocate a big buffer for MgmtDescRing!\n");
-                       Status = NDIS_STATUS_RESOURCES;
-                       goto out1;
-               }
-               NdisZeroMemory(pAd->MgmtDescRing.AllocVa,
-                              pAd->MgmtDescRing.AllocSize);
-               RingBaseVa = pAd->MgmtDescRing.AllocVa;
-
-               /* Initialize MGMT Ring and associated buffer memory */
-               pMgmtRing = &pAd->MgmtRing;
-               for (i = 0; i < MGMT_RING_SIZE; i++) {
-                       /* link the pre-allocated Mgmt buffer to MgmtRing.Cell */
-                       pMgmtRing->Cell[i].AllocSize = sizeof(struct rt_tx_context);
-                       pMgmtRing->Cell[i].AllocVa = RingBaseVa;
-                       pMgmtRing->Cell[i].pNdisPacket = NULL;
-                       pMgmtRing->Cell[i].pNextNdisPacket = NULL;
-
-                       /*Allocate URB for MLMEContext */
-                       pMLMEContext =
-                           (struct rt_tx_context *)pAd->MgmtRing.Cell[i].AllocVa;
-                       pMLMEContext->pUrb = RTUSB_ALLOC_URB(0);
-                       if (pMLMEContext->pUrb == NULL) {
-                               DBGPRINT(RT_DEBUG_ERROR,
-                                        ("<-- ERROR in Alloc TX MLMEContext[%d] urb!\n",
-                                         i));
-                               Status = NDIS_STATUS_RESOURCES;
-                               goto out2;
-                       }
-                       pMLMEContext->pAd = pAd;
-                       pMLMEContext->pIrp = NULL;
-                       pMLMEContext->TransferBuffer = NULL;
-                       pMLMEContext->InUse = FALSE;
-                       pMLMEContext->IRPPending = FALSE;
-                       pMLMEContext->bWaitingBulkOut = FALSE;
-                       pMLMEContext->BulkOutSize = 0;
-                       pMLMEContext->SelfIdx = i;
-
-                       /* Offset to next ring descriptor address */
-                       RingBaseVa = (u8 *)RingBaseVa + sizeof(struct rt_tx_context);
-               }
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("MGMT Ring: total %d entry allocated\n", i));
-
-               /*pAd->MgmtRing.TxSwFreeIdx = (MGMT_RING_SIZE - 1); */
-               pAd->MgmtRing.TxSwFreeIdx = MGMT_RING_SIZE;
-               pAd->MgmtRing.TxCpuIdx = 0;
-               pAd->MgmtRing.TxDmaIdx = 0;
-
-               /* */
-               /* BEACON_RING_SIZE */
-               /* */
-               for (i = 0; i < BEACON_RING_SIZE; i++)  /* 2 */
-               {
-                       struct rt_tx_context *pBeaconContext = &(pAd->BeaconContext[i]);
-
-                       NdisZeroMemory(pBeaconContext, sizeof(struct rt_tx_context));
-
-                       /*Allocate URB */
-                       LM_USB_ALLOC(pObj, pBeaconContext, struct rt_tx_buffer *,
-                                    sizeof(struct rt_tx_buffer), Status,
-                                    ("<-- ERROR in Alloc TX BeaconContext[%d] urb!\n",
-                                     i), out2,
-                                    ("<-- ERROR in Alloc TX BeaconContext[%d] struct rt_tx_buffer!\n",
-                                     i), out3);
-
-                       pBeaconContext->pAd = pAd;
-                       pBeaconContext->pIrp = NULL;
-                       pBeaconContext->InUse = FALSE;
-                       pBeaconContext->IRPPending = FALSE;
-               }
-
-               /* */
-               /* NullContext */
-               /* */
-               NdisZeroMemory(pNullContext, sizeof(struct rt_tx_context));
-
-               /*Allocate URB */
-               LM_USB_ALLOC(pObj, pNullContext, struct rt_tx_buffer *, sizeof(struct rt_tx_buffer),
-                            Status,
-                            ("<-- ERROR in Alloc TX NullContext urb!\n"),
-                            out3,
-                            ("<-- ERROR in Alloc TX NullContext struct rt_tx_buffer!\n"),
-                            out4);
-
-               pNullContext->pAd = pAd;
-               pNullContext->pIrp = NULL;
-               pNullContext->InUse = FALSE;
-               pNullContext->IRPPending = FALSE;
-
-               /* */
-               /* RTSContext */
-               /* */
-               NdisZeroMemory(pRTSContext, sizeof(struct rt_tx_context));
-
-               /*Allocate URB */
-               LM_USB_ALLOC(pObj, pRTSContext, struct rt_tx_buffer *, sizeof(struct rt_tx_buffer),
-                            Status,
-                            ("<-- ERROR in Alloc TX RTSContext urb!\n"),
-                            out4,
-                            ("<-- ERROR in Alloc TX RTSContext struct rt_tx_buffer!\n"),
-                            out5);
-
-               pRTSContext->pAd = pAd;
-               pRTSContext->pIrp = NULL;
-               pRTSContext->InUse = FALSE;
-               pRTSContext->IRPPending = FALSE;
-
-               /* */
-               /* PsPollContext */
-               /* */
-               /*NdisZeroMemory(pPsPollContext, sizeof(struct rt_tx_context)); */
-               /*Allocate URB */
-               LM_USB_ALLOC(pObj, pPsPollContext, struct rt_tx_buffer *,
-                            sizeof(struct rt_tx_buffer), Status,
-                            ("<-- ERROR in Alloc TX PsPollContext urb!\n"),
-                            out5,
-                            ("<-- ERROR in Alloc TX PsPollContext struct rt_tx_buffer!\n"),
-                            out6);
-
-               pPsPollContext->pAd = pAd;
-               pPsPollContext->pIrp = NULL;
-               pPsPollContext->InUse = FALSE;
-               pPsPollContext->IRPPending = FALSE;
-               pPsPollContext->bAggregatible = FALSE;
-               pPsPollContext->LastOne = TRUE;
-
-       } while (FALSE);
-
-done:
-       DBGPRINT(RT_DEBUG_TRACE, ("<-- NICInitTransmit(Status=%d)\n", Status));
-
-       return Status;
-
-       /* --------------------------- ERROR HANDLE --------------------------- */
-out6:
-       LM_URB_FREE(pObj, pPsPollContext, sizeof(struct rt_tx_buffer));
-
-out5:
-       LM_URB_FREE(pObj, pRTSContext, sizeof(struct rt_tx_buffer));
-
-out4:
-       LM_URB_FREE(pObj, pNullContext, sizeof(struct rt_tx_buffer));
-
-out3:
-       for (i = 0; i < BEACON_RING_SIZE; i++) {
-               struct rt_tx_context *pBeaconContext = &(pAd->BeaconContext[i]);
-               if (pBeaconContext)
-                       LM_URB_FREE(pObj, pBeaconContext, sizeof(struct rt_tx_buffer));
-       }
-
-out2:
-       if (pAd->MgmtDescRing.AllocVa) {
-               pMgmtRing = &pAd->MgmtRing;
-               for (i = 0; i < MGMT_RING_SIZE; i++) {
-                       pMLMEContext =
-                           (struct rt_tx_context *)pAd->MgmtRing.Cell[i].AllocVa;
-                       if (pMLMEContext)
-                               LM_URB_FREE(pObj, pMLMEContext,
-                                           sizeof(struct rt_tx_buffer));
-               }
-               os_free_mem(pAd, pAd->MgmtDescRing.AllocVa);
-               pAd->MgmtDescRing.AllocVa = NULL;
-       }
-
-out1:
-       for (acidx = 0; acidx < 4; acidx++) {
-               struct rt_ht_tx_context *pTxContext = &(pAd->TxContext[acidx]);
-               if (pTxContext)
-                       LM_URB_FREE(pObj, pTxContext, sizeof(struct rt_httx_buffer));
-       }
-
-       /* Here we didn't have any pre-allocated memory need to free. */
-
-       return Status;
-}
-
-/*
-========================================================================
-Routine Description:
-    Allocate DMA memory blocks for send, receive.
-
-Arguments:
-    pAd                                        Pointer to our adapter
-
-Return Value:
-       NDIS_STATUS_SUCCESS
-       NDIS_STATUS_FAILURE
-       NDIS_STATUS_RESOURCES
-
-Note:
-========================================================================
-*/
-int RTMPAllocTxRxRingMemory(struct rt_rtmp_adapter *pAd)
-{
-/*      struct rt_counter_802_11  pCounter = &pAd->WlanCounters; */
-       int Status;
-       int num;
-
-       DBGPRINT(RT_DEBUG_TRACE, ("--> RTMPAllocTxRxRingMemory\n"));
-
-       do {
-               /* Init the struct rt_cmdq and CmdQLock */
-               NdisAllocateSpinLock(&pAd->CmdQLock);
-               NdisAcquireSpinLock(&pAd->CmdQLock);
-               RTUSBInitializeCmdQ(&pAd->CmdQ);
-               NdisReleaseSpinLock(&pAd->CmdQLock);
-
-               NdisAllocateSpinLock(&pAd->MLMEBulkOutLock);
-               /*NdisAllocateSpinLock(&pAd->MLMEWaitQueueLock); */
-               NdisAllocateSpinLock(&pAd->BulkOutLock[0]);
-               NdisAllocateSpinLock(&pAd->BulkOutLock[1]);
-               NdisAllocateSpinLock(&pAd->BulkOutLock[2]);
-               NdisAllocateSpinLock(&pAd->BulkOutLock[3]);
-               NdisAllocateSpinLock(&pAd->BulkOutLock[4]);
-               NdisAllocateSpinLock(&pAd->BulkOutLock[5]);
-               NdisAllocateSpinLock(&pAd->BulkInLock);
-
-               for (num = 0; num < NUM_OF_TX_RING; num++) {
-                       NdisAllocateSpinLock(&pAd->TxContextQueueLock[num]);
-               }
-
-/*              NdisAllocateSpinLock(&pAd->MemLock);    // Not used in RT28XX */
-
-/*              NdisAllocateSpinLock(&pAd->MacTabLock); // init it in UserCfgInit() */
-/*              NdisAllocateSpinLock(&pAd->BATabLock); // init it in BATableInit() */
-
-/*              for(num=0; num<MAX_LEN_OF_BA_REC_TABLE; num++) */
-/*              { */
-/*                      NdisAllocateSpinLock(&pAd->BATable.BARecEntry[num].RxReRingLock); */
-/*              } */
-
-               /* */
-               /* Init Mac Table */
-               /* */
-/*              MacTableInitialize(pAd); */
-
-               /* */
-               /* Init send data structures and related parameters */
-               /* */
-               Status = NICInitTransmit(pAd);
-               if (Status != NDIS_STATUS_SUCCESS)
-                       break;
-
-               /* */
-               /* Init receive data structures and related parameters */
-               /* */
-               Status = NICInitRecv(pAd);
-               if (Status != NDIS_STATUS_SUCCESS)
-                       break;
-
-               pAd->PendingIoCount = 1;
-
-       } while (FALSE);
-
-       NdisZeroMemory(&pAd->FragFrame, sizeof(struct rt_fragment_frame));
-       pAd->FragFrame.pFragPacket =
-           RTMP_AllocateFragPacketBuffer(pAd, RX_BUFFER_NORMSIZE);
-
-       if (pAd->FragFrame.pFragPacket == NULL) {
-               Status = NDIS_STATUS_RESOURCES;
-       }
-
-       DBGPRINT_S(Status,
-                  ("<-- RTMPAllocTxRxRingMemory, Status=%x\n", Status));
-       return Status;
-}
-
-/*
-========================================================================
-Routine Description:
-       Calls USB_InterfaceStop and frees memory allocated for the URBs
-    calls NdisMDeregisterDevice and frees the memory
-    allocated in VNetInitialize for the Adapter Object
-
-Arguments:
-       *pAd                            the raxx interface data pointer
-
-Return Value:
-       None
-
-Note:
-========================================================================
-*/
-void RTMPFreeTxRxRingMemory(struct rt_rtmp_adapter *pAd)
-{
-#define LM_URB_FREE(pObj, Context, BufferSize)                         \
-       if (NULL != Context->pUrb) {                                                    \
-               RTUSB_UNLINK_URB(Context->pUrb);                                        \
-               RTUSB_FREE_URB(Context->pUrb);                                          \
-               Context->pUrb = NULL; }                                                         \
-       if (NULL != Context->TransferBuffer) {                                  \
-               RTUSB_URB_FREE_BUFFER(pObj->pUsb_Dev, BufferSize,       \
-                                                               Context->TransferBuffer,        \
-                                                               Context->data_dma);                     \
-               Context->TransferBuffer = NULL; }
-
-       u32 i, acidx;
-       struct rt_tx_context *pNullContext = &pAd->NullContext;
-       struct rt_tx_context *pPsPollContext = &pAd->PsPollContext;
-       struct rt_tx_context *pRTSContext = &pAd->RTSContext;
-/*      struct rt_ht_tx_context *pHTTXContext; */
-       /*PRTMP_REORDERBUF      pReorderBuf; */
-       struct os_cookie *pObj = (struct os_cookie *)pAd->OS_Cookie;
-/*      struct rt_rtmp_tx_ring *pTxRing; */
-
-       DBGPRINT(RT_DEBUG_ERROR, ("---> RTMPFreeTxRxRingMemory\n"));
-       pObj = pObj;
-
-       /* Free all resources for the RECEIVE buffer queue. */
-       for (i = 0; i < (RX_RING_SIZE); i++) {
-               struct rt_rx_context *pRxContext = &(pAd->RxContext[i]);
-               if (pRxContext)
-                       LM_URB_FREE(pObj, pRxContext, MAX_RXBULK_SIZE);
-       }
-
-       /* Free PsPoll frame resource */
-       LM_URB_FREE(pObj, pPsPollContext, sizeof(struct rt_tx_buffer));
-
-       /* Free NULL frame resource */
-       LM_URB_FREE(pObj, pNullContext, sizeof(struct rt_tx_buffer));
-
-       /* Free RTS frame resource */
-       LM_URB_FREE(pObj, pRTSContext, sizeof(struct rt_tx_buffer));
-
-       /* Free beacon frame resource */
-       for (i = 0; i < BEACON_RING_SIZE; i++) {
-               struct rt_tx_context *pBeaconContext = &(pAd->BeaconContext[i]);
-               if (pBeaconContext)
-                       LM_URB_FREE(pObj, pBeaconContext, sizeof(struct rt_tx_buffer));
-       }
-
-       /* Free mgmt frame resource */
-       for (i = 0; i < MGMT_RING_SIZE; i++) {
-               struct rt_tx_context *pMLMEContext =
-                   (struct rt_tx_context *)pAd->MgmtRing.Cell[i].AllocVa;
-               /*LM_URB_FREE(pObj, pMLMEContext, sizeof(struct rt_tx_buffer)); */
-               if (NULL != pAd->MgmtRing.Cell[i].pNdisPacket) {
-                       RTMPFreeNdisPacket(pAd,
-                                          pAd->MgmtRing.Cell[i].pNdisPacket);
-                       pAd->MgmtRing.Cell[i].pNdisPacket = NULL;
-                       pMLMEContext->TransferBuffer = NULL;
-               }
-
-               if (pMLMEContext) {
-                       if (NULL != pMLMEContext->pUrb) {
-                               RTUSB_UNLINK_URB(pMLMEContext->pUrb);
-                               RTUSB_FREE_URB(pMLMEContext->pUrb);
-                               pMLMEContext->pUrb = NULL;
-                       }
-               }
-       }
-       if (pAd->MgmtDescRing.AllocVa)
-               os_free_mem(pAd, pAd->MgmtDescRing.AllocVa);
-
-       /* Free Tx frame resource */
-       for (acidx = 0; acidx < 4; acidx++) {
-               struct rt_ht_tx_context *pHTTXContext = &(pAd->TxContext[acidx]);
-               if (pHTTXContext)
-                       LM_URB_FREE(pObj, pHTTXContext, sizeof(struct rt_httx_buffer));
-       }
-
-       if (pAd->FragFrame.pFragPacket)
-               RELEASE_NDIS_PACKET(pAd, pAd->FragFrame.pFragPacket,
-                                   NDIS_STATUS_SUCCESS);
-
-       for (i = 0; i < 6; i++) {
-               NdisFreeSpinLock(&pAd->BulkOutLock[i]);
-       }
-
-       NdisFreeSpinLock(&pAd->BulkInLock);
-       NdisFreeSpinLock(&pAd->MLMEBulkOutLock);
-
-       NdisFreeSpinLock(&pAd->CmdQLock);
-       /* Clear all pending bulk-out request flags. */
-       RTUSB_CLEAR_BULK_FLAG(pAd, 0xffffffff);
-
-/*      NdisFreeSpinLock(&pAd->MacTabLock); */
-
-/*      for(i=0; i<MAX_LEN_OF_BA_REC_TABLE; i++) */
-/*      { */
-/*              NdisFreeSpinLock(&pAd->BATable.BARecEntry[i].RxReRingLock); */
-/*      } */
-
-       DBGPRINT(RT_DEBUG_ERROR, ("<--- RTMPFreeTxRxRingMemory\n"));
-}
-
-/*
-========================================================================
-Routine Description:
-    Write WLAN MAC address to USB 2870.
-
-Arguments:
-    pAd                                        Pointer to our adapter
-
-Return Value:
-       NDIS_STATUS_SUCCESS
-
-Note:
-========================================================================
-*/
-int RTUSBWriteHWMACAddress(struct rt_rtmp_adapter *pAd)
-{
-       MAC_DW0_STRUC StaMacReg0;
-       MAC_DW1_STRUC StaMacReg1;
-       int Status = NDIS_STATUS_SUCCESS;
-       LARGE_INTEGER NOW;
-
-       /* initialize the random number generator */
-       RTMP_GetCurrentSystemTime(&NOW);
-
-       if (pAd->bLocalAdminMAC != TRUE) {
-               pAd->CurrentAddress[0] = pAd->PermanentAddress[0];
-               pAd->CurrentAddress[1] = pAd->PermanentAddress[1];
-               pAd->CurrentAddress[2] = pAd->PermanentAddress[2];
-               pAd->CurrentAddress[3] = pAd->PermanentAddress[3];
-               pAd->CurrentAddress[4] = pAd->PermanentAddress[4];
-               pAd->CurrentAddress[5] = pAd->PermanentAddress[5];
-       }
-       /* Write New MAC address to MAC_CSR2 & MAC_CSR3 & let ASIC know our new MAC */
-       StaMacReg0.field.Byte0 = pAd->CurrentAddress[0];
-       StaMacReg0.field.Byte1 = pAd->CurrentAddress[1];
-       StaMacReg0.field.Byte2 = pAd->CurrentAddress[2];
-       StaMacReg0.field.Byte3 = pAd->CurrentAddress[3];
-       StaMacReg1.field.Byte4 = pAd->CurrentAddress[4];
-       StaMacReg1.field.Byte5 = pAd->CurrentAddress[5];
-       StaMacReg1.field.U2MeMask = 0xff;
-       DBGPRINT_RAW(RT_DEBUG_TRACE,
-               ("Local MAC = %pM\n", pAd->CurrentAddress));
-
-       RTUSBWriteMACRegister(pAd, MAC_ADDR_DW0, StaMacReg0.word);
-       RTUSBWriteMACRegister(pAd, MAC_ADDR_DW1, StaMacReg1.word);
-       return Status;
-}
-
-/*
-========================================================================
-Routine Description:
-    Disable DMA.
-
-Arguments:
-       *pAd                            the raxx interface data pointer
-
-Return Value:
-       None
-
-Note:
-========================================================================
-*/
-void RT28XXDMADisable(struct rt_rtmp_adapter *pAd)
-{
-       /* no use */
-}
-
-/*
-========================================================================
-Routine Description:
-    Enable DMA.
-
-Arguments:
-       *pAd                            the raxx interface data pointer
-
-Return Value:
-       None
-
-Note:
-========================================================================
-*/
-void RT28XXDMAEnable(struct rt_rtmp_adapter *pAd)
-{
-       WPDMA_GLO_CFG_STRUC GloCfg;
-       USB_DMA_CFG_STRUC UsbCfg;
-       int i = 0;
-
-       RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, 0x4);
-       do {
-               RTMP_IO_READ32(pAd, WPDMA_GLO_CFG, &GloCfg.word);
-               if ((GloCfg.field.TxDMABusy == 0)
-                   && (GloCfg.field.RxDMABusy == 0))
-                       break;
-
-               DBGPRINT(RT_DEBUG_TRACE, ("==>  DMABusy\n"));
-               RTMPusecDelay(1000);
-               i++;
-       } while (i < 200);
-
-       RTMPusecDelay(50);
-       GloCfg.field.EnTXWriteBackDDONE = 1;
-       GloCfg.field.EnableRxDMA = 1;
-       GloCfg.field.EnableTxDMA = 1;
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("<== WRITE DMA offset 0x208 = 0x%x\n", GloCfg.word));
-       RTMP_IO_WRITE32(pAd, WPDMA_GLO_CFG, GloCfg.word);
-
-       UsbCfg.word = 0;
-       UsbCfg.field.phyclear = 0;
-       /* usb version is 1.1,do not use bulk in aggregation */
-       if (pAd->BulkInMaxPacketSize == 512)
-               UsbCfg.field.RxBulkAggEn = 1;
-       /* for last packet, PBF might use more than limited, so minus 2 to prevent from error */
-       UsbCfg.field.RxBulkAggLmt = (MAX_RXBULK_SIZE / 1024) - 3;
-       UsbCfg.field.RxBulkAggTOut = 0x80;      /* 2006-10-18 */
-       UsbCfg.field.RxBulkEn = 1;
-       UsbCfg.field.TxBulkEn = 1;
-
-       RTUSBWriteMACRegister(pAd, USB_DMA_CFG, UsbCfg.word);
-
-}
-
-/********************************************************************
-  *
-  *    2870 Beacon Update Related functions.
-  *
-  ********************************************************************/
-
-/*
-========================================================================
-Routine Description:
-    Write Beacon buffer to Asic.
-
-Arguments:
-       *pAd                            the raxx interface data pointer
-
-Return Value:
-       None
-
-Note:
-========================================================================
-*/
-void RT28xx_UpdateBeaconToAsic(struct rt_rtmp_adapter *pAd,
-                              int apidx,
-                              unsigned long FrameLen, unsigned long UpdatePos)
-{
-       u8 *pBeaconFrame = NULL;
-       u8 *ptr;
-       u32 i, padding;
-       struct rt_beacon_sync *pBeaconSync = pAd->CommonCfg.pBeaconSync;
-       u32 longValue;
-/*      u16                  shortValue; */
-       BOOLEAN bBcnReq = FALSE;
-       u8 bcn_idx = 0;
-
-       if (pBeaconFrame == NULL) {
-               DBGPRINT(RT_DEBUG_ERROR, ("pBeaconFrame is NULL!\n"));
-               return;
-       }
-
-       if (pBeaconSync == NULL) {
-               DBGPRINT(RT_DEBUG_ERROR, ("pBeaconSync is NULL!\n"));
-               return;
-       }
-       /*if ((pAd->WdsTab.Mode == WDS_BRIDGE_MODE) || */
-       /*      ((pAd->ApCfg.MBSSID[apidx].MSSIDDev == NULL) || !(pAd->ApCfg.MBSSID[apidx].MSSIDDev->flags & IFF_UP)) */
-       /*      ) */
-       if (bBcnReq == FALSE) {
-               /* when the ra interface is down, do not send its beacon frame */
-               /* clear all zero */
-               for (i = 0; i < TXWI_SIZE; i += 4) {
-                       RTMP_IO_WRITE32(pAd, pAd->BeaconOffset[bcn_idx] + i,
-                                       0x00);
-               }
-               pBeaconSync->BeaconBitMap &=
-                   (~(BEACON_BITMAP_MASK & (1 << bcn_idx)));
-               NdisZeroMemory(pBeaconSync->BeaconTxWI[bcn_idx], TXWI_SIZE);
-       } else {
-               ptr = (u8 *)& pAd->BeaconTxWI;
-               if (NdisEqualMemory(pBeaconSync->BeaconTxWI[bcn_idx], &pAd->BeaconTxWI, TXWI_SIZE) == FALSE) {  /* If BeaconTxWI changed, we need to rewrite the TxWI for the Beacon frames. */
-                       pBeaconSync->BeaconBitMap &=
-                           (~(BEACON_BITMAP_MASK & (1 << bcn_idx)));
-                       NdisMoveMemory(pBeaconSync->BeaconTxWI[bcn_idx],
-                                      &pAd->BeaconTxWI, TXWI_SIZE);
-               }
-
-               if ((pBeaconSync->BeaconBitMap & (1 << bcn_idx)) !=
-                   (1 << bcn_idx)) {
-                       for (i = 0; i < TXWI_SIZE; i += 4)      /* 16-byte TXWI field */
-                       {
-                               longValue =
-                                   *ptr + (*(ptr + 1) << 8) +
-                                   (*(ptr + 2) << 16) + (*(ptr + 3) << 24);
-                               RTMP_IO_WRITE32(pAd,
-                                               pAd->BeaconOffset[bcn_idx] + i,
-                                               longValue);
-                               ptr += 4;
-                       }
-               }
-
-               ptr = pBeaconSync->BeaconBuf[bcn_idx];
-               padding = (FrameLen & 0x01);
-               NdisZeroMemory((u8 *)(pBeaconFrame + FrameLen), padding);
-               FrameLen += padding;
-               for (i = 0; i < FrameLen /*HW_BEACON_OFFSET */ ; i += 2) {
-                       if (NdisEqualMemory(ptr, pBeaconFrame, 2) == FALSE) {
-                               NdisMoveMemory(ptr, pBeaconFrame, 2);
-                               /*shortValue = *ptr + (*(ptr+1)<<8); */
-                               /*RTMP_IO_WRITE8(pAd, pAd->BeaconOffset[bcn_idx] + TXWI_SIZE + i, shortValue); */
-                               RTUSBMultiWrite(pAd,
-                                               pAd->BeaconOffset[bcn_idx] +
-                                               TXWI_SIZE + i, ptr, 2);
-                       }
-                       ptr += 2;
-                       pBeaconFrame += 2;
-               }
-
-               pBeaconSync->BeaconBitMap |= (1 << bcn_idx);
-
-               /* For AP interface, set the DtimBitOn so that we can send Bcast/Mcast frame out after this beacon frame. */
-       }
-
-}
-
-void RTUSBBssBeaconStop(struct rt_rtmp_adapter *pAd)
-{
-       struct rt_beacon_sync *pBeaconSync;
-       int i, offset;
-       BOOLEAN Cancelled = TRUE;
-
-       pBeaconSync = pAd->CommonCfg.pBeaconSync;
-       if (pBeaconSync && pBeaconSync->EnableBeacon) {
-               int NumOfBcn;
-
-               {
-                       NumOfBcn = MAX_MESH_NUM;
-               }
-
-               RTMPCancelTimer(&pAd->CommonCfg.BeaconUpdateTimer, &Cancelled);
-
-               for (i = 0; i < NumOfBcn; i++) {
-                       NdisZeroMemory(pBeaconSync->BeaconBuf[i],
-                                      HW_BEACON_OFFSET);
-                       NdisZeroMemory(pBeaconSync->BeaconTxWI[i], TXWI_SIZE);
-
-                       for (offset = 0; offset < HW_BEACON_OFFSET; offset += 4)
-                               RTMP_IO_WRITE32(pAd,
-                                               pAd->BeaconOffset[i] + offset,
-                                               0x00);
-
-                       pBeaconSync->CapabilityInfoLocationInBeacon[i] = 0;
-                       pBeaconSync->TimIELocationInBeacon[i] = 0;
-               }
-               pBeaconSync->BeaconBitMap = 0;
-               pBeaconSync->DtimBitOn = 0;
-       }
-}
-
-void RTUSBBssBeaconStart(struct rt_rtmp_adapter *pAd)
-{
-       int apidx;
-       struct rt_beacon_sync *pBeaconSync;
-/*      LARGE_INTEGER   tsfTime, deltaTime; */
-
-       pBeaconSync = pAd->CommonCfg.pBeaconSync;
-       if (pBeaconSync && pBeaconSync->EnableBeacon) {
-               int NumOfBcn;
-
-               {
-                       NumOfBcn = MAX_MESH_NUM;
-               }
-
-               for (apidx = 0; apidx < NumOfBcn; apidx++) {
-                       u8 CapabilityInfoLocationInBeacon = 0;
-                       u8 TimIELocationInBeacon = 0;
-
-                       NdisZeroMemory(pBeaconSync->BeaconBuf[apidx],
-                                      HW_BEACON_OFFSET);
-                       pBeaconSync->CapabilityInfoLocationInBeacon[apidx] =
-                           CapabilityInfoLocationInBeacon;
-                       pBeaconSync->TimIELocationInBeacon[apidx] =
-                           TimIELocationInBeacon;
-                       NdisZeroMemory(pBeaconSync->BeaconTxWI[apidx],
-                                      TXWI_SIZE);
-               }
-               pBeaconSync->BeaconBitMap = 0;
-               pBeaconSync->DtimBitOn = 0;
-               pAd->CommonCfg.BeaconUpdateTimer.Repeat = TRUE;
-
-               pAd->CommonCfg.BeaconAdjust = 0;
-               pAd->CommonCfg.BeaconFactor =
-                   0xffffffff / (pAd->CommonCfg.BeaconPeriod << 10);
-               pAd->CommonCfg.BeaconRemain =
-                   (0xffffffff % (pAd->CommonCfg.BeaconPeriod << 10)) + 1;
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("RTUSBBssBeaconStart:BeaconFactor=%d, BeaconRemain=%d!\n",
-                         pAd->CommonCfg.BeaconFactor,
-                         pAd->CommonCfg.BeaconRemain));
-               RTMPSetTimer(&pAd->CommonCfg.BeaconUpdateTimer,
-                            10 /*pAd->CommonCfg.BeaconPeriod */ );
-
-       }
-}
-
-void RTUSBBssBeaconInit(struct rt_rtmp_adapter *pAd)
-{
-       struct rt_beacon_sync *pBeaconSync;
-       int i;
-
-       os_alloc_mem(pAd, (u8 **) (&pAd->CommonCfg.pBeaconSync),
-                    sizeof(struct rt_beacon_sync));
-       /*NdisAllocMemory(pAd->CommonCfg.pBeaconSync, sizeof(struct rt_beacon_sync), MEM_ALLOC_FLAG); */
-       if (pAd->CommonCfg.pBeaconSync) {
-               pBeaconSync = pAd->CommonCfg.pBeaconSync;
-               NdisZeroMemory(pBeaconSync, sizeof(struct rt_beacon_sync));
-               for (i = 0; i < HW_BEACON_MAX_COUNT; i++) {
-                       NdisZeroMemory(pBeaconSync->BeaconBuf[i],
-                                      HW_BEACON_OFFSET);
-                       pBeaconSync->CapabilityInfoLocationInBeacon[i] = 0;
-                       pBeaconSync->TimIELocationInBeacon[i] = 0;
-                       NdisZeroMemory(pBeaconSync->BeaconTxWI[i], TXWI_SIZE);
-               }
-               pBeaconSync->BeaconBitMap = 0;
-
-               /*RTMPInitTimer(pAd, &pAd->CommonCfg.BeaconUpdateTimer, GET_TIMER_FUNCTION(BeaconUpdateExec), pAd, TRUE); */
-               pBeaconSync->EnableBeacon = TRUE;
-       }
-}
-
-void RTUSBBssBeaconExit(struct rt_rtmp_adapter *pAd)
-{
-       struct rt_beacon_sync *pBeaconSync;
-       BOOLEAN Cancelled = TRUE;
-       int i;
-
-       if (pAd->CommonCfg.pBeaconSync) {
-               pBeaconSync = pAd->CommonCfg.pBeaconSync;
-               pBeaconSync->EnableBeacon = FALSE;
-               RTMPCancelTimer(&pAd->CommonCfg.BeaconUpdateTimer, &Cancelled);
-               pBeaconSync->BeaconBitMap = 0;
-
-               for (i = 0; i < HW_BEACON_MAX_COUNT; i++) {
-                       NdisZeroMemory(pBeaconSync->BeaconBuf[i],
-                                      HW_BEACON_OFFSET);
-                       pBeaconSync->CapabilityInfoLocationInBeacon[i] = 0;
-                       pBeaconSync->TimIELocationInBeacon[i] = 0;
-                       NdisZeroMemory(pBeaconSync->BeaconTxWI[i], TXWI_SIZE);
-               }
-
-               os_free_mem(pAd, pAd->CommonCfg.pBeaconSync);
-               pAd->CommonCfg.pBeaconSync = NULL;
-       }
-}
-
-/*
-    ========================================================================
-    Routine Description:
-        For device work as AP mode but didn't have TBTT interrupt event, we need a mechanism
-        to update the beacon context in each Beacon interval. Here we use a periodical timer
-        to simulate the TBTT interrupt to handle the beacon context update.
-
-    Arguments:
-        SystemSpecific1         - Not used.
-        FunctionContext         - Pointer to our Adapter context.
-        SystemSpecific2         - Not used.
-        SystemSpecific3         - Not used.
-
-    Return Value:
-        None
-
-    ========================================================================
-*/
-void BeaconUpdateExec(void *SystemSpecific1,
-                     void *FunctionContext,
-                     void *SystemSpecific2, void *SystemSpecific3)
-{
-       struct rt_rtmp_adapter *pAd = (struct rt_rtmp_adapter *)FunctionContext;
-       LARGE_INTEGER tsfTime_a;        /*, tsfTime_b, deltaTime_exp, deltaTime_ab; */
-       u32 delta, delta2MS, period2US, remain, remain_low, remain_high;
-/*      BOOLEAN                 positive; */
-
-       if (pAd->CommonCfg.IsUpdateBeacon == TRUE) {
-               ReSyncBeaconTime(pAd);
-
-       }
-
-       RTMP_IO_READ32(pAd, TSF_TIMER_DW0, &tsfTime_a.u.LowPart);
-       RTMP_IO_READ32(pAd, TSF_TIMER_DW1, &tsfTime_a.u.HighPart);
-
-       /*positive=getDeltaTime(tsfTime_a, expectedTime, &deltaTime_exp); */
-       period2US = (pAd->CommonCfg.BeaconPeriod << 10);
-       remain_high = pAd->CommonCfg.BeaconRemain * tsfTime_a.u.HighPart;
-       remain_low = tsfTime_a.u.LowPart % (pAd->CommonCfg.BeaconPeriod << 10);
-       remain =
-           (remain_high + remain_low) % (pAd->CommonCfg.BeaconPeriod << 10);
-       delta = (pAd->CommonCfg.BeaconPeriod << 10) - remain;
-
-       delta2MS = (delta >> 10);
-       if (delta2MS > 150) {
-               pAd->CommonCfg.BeaconUpdateTimer.TimerValue = 100;
-               pAd->CommonCfg.IsUpdateBeacon = FALSE;
-       } else {
-               pAd->CommonCfg.BeaconUpdateTimer.TimerValue = delta2MS + 10;
-               pAd->CommonCfg.IsUpdateBeacon = TRUE;
-       }
-
-}
-
-/********************************************************************
-  *
-  *    2870 Radio on/off Related functions.
-  *
-  ********************************************************************/
-void RT28xxUsbMlmeRadioOn(struct rt_rtmp_adapter *pAd)
-{
-       struct rt_rtmp_chip_op *pChipOps = &pAd->chipOps;
-
-       DBGPRINT(RT_DEBUG_TRACE, ("RT28xxUsbMlmeRadioOn()\n"));
-
-       if (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF))
-               return;
-
-       {
-               AsicSendCommandToMcu(pAd, 0x31, 0xff, 0x00, 0x02);
-               RTMPusecDelay(10000);
-       }
-       /*NICResetFromError(pAd); */
-
-       /* Enable Tx/Rx */
-       RTMPEnableRxTx(pAd);
-
-       if (pChipOps->AsicReverseRfFromSleepMode)
-               pChipOps->AsicReverseRfFromSleepMode(pAd);
-
-       /* Clear Radio off flag */
-       RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF);
-
-       RTUSBBulkReceive(pAd);
-
-       /* Set LED */
-       RTMPSetLED(pAd, LED_RADIO_ON);
-}
-
-void RT28xxUsbMlmeRadioOFF(struct rt_rtmp_adapter *pAd)
-{
-       WPDMA_GLO_CFG_STRUC GloCfg;
-       u32 Value, i;
-
-       DBGPRINT(RT_DEBUG_TRACE, ("RT28xxUsbMlmeRadioOFF()\n"));
-
-       if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF))
-               return;
-
-       /* Clear PMKID cache. */
-       pAd->StaCfg.SavedPMKNum = 0;
-       RTMPZeroMemory(pAd->StaCfg.SavedPMK, (PMKID_NO * sizeof(struct rt_bssid_info)));
-
-       /* Link down first if any association exists */
-       if (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)) {
-               if (INFRA_ON(pAd) || ADHOC_ON(pAd)) {
-                       struct rt_mlme_disassoc_req DisReq;
-                       struct rt_mlme_queue_elem *pMsgElem =
-                           kmalloc(sizeof(struct rt_mlme_queue_elem),
-                                                       MEM_ALLOC_FLAG);
-
-                       if (pMsgElem) {
-                               COPY_MAC_ADDR(&DisReq.Addr,
-                                             pAd->CommonCfg.Bssid);
-                               DisReq.Reason = REASON_DISASSOC_STA_LEAVING;
-
-                               pMsgElem->Machine = ASSOC_STATE_MACHINE;
-                               pMsgElem->MsgType = MT2_MLME_DISASSOC_REQ;
-                               pMsgElem->MsgLen =
-                                   sizeof(struct rt_mlme_disassoc_req);
-                               NdisMoveMemory(pMsgElem->Msg, &DisReq,
-                                              sizeof
-                                              (struct rt_mlme_disassoc_req));
-
-                               MlmeDisassocReqAction(pAd, pMsgElem);
-                               kfree(pMsgElem);
-
-                               RTMPusecDelay(1000);
-                       }
-               }
-       }
-       /* Set Radio off flag */
-       RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF);
-
-       {
-               /* Link down first if any association exists */
-               if (INFRA_ON(pAd) || ADHOC_ON(pAd))
-                       LinkDown(pAd, FALSE);
-               RTMPusecDelay(10000);
-
-               /*========================================== */
-               /* Clean up old bss table */
-               BssTableInit(&pAd->ScanTab);
-       }
-
-       /* Set LED */
-       RTMPSetLED(pAd, LED_RADIO_OFF);
-
-       if (pAd->CommonCfg.BBPCurrentBW == BW_40) {
-               /* Must using 40MHz. */
-               AsicTurnOffRFClk(pAd, pAd->CommonCfg.CentralChannel);
-       } else {
-               /* Must using 20MHz. */
-               AsicTurnOffRFClk(pAd, pAd->CommonCfg.Channel);
-       }
-
-       /* Disable Tx/Rx DMA */
-       RTUSBReadMACRegister(pAd, WPDMA_GLO_CFG, &GloCfg.word); /* disable DMA */
-       GloCfg.field.EnableTxDMA = 0;
-       GloCfg.field.EnableRxDMA = 0;
-       RTUSBWriteMACRegister(pAd, WPDMA_GLO_CFG, GloCfg.word); /* abort all TX rings */
-
-       /* Waiting for DMA idle */
-       i = 0;
-       do {
-               RTMP_IO_READ32(pAd, WPDMA_GLO_CFG, &GloCfg.word);
-               if ((GloCfg.field.TxDMABusy == 0)
-                   && (GloCfg.field.RxDMABusy == 0))
-                       break;
-
-               RTMPusecDelay(1000);
-       } while (i++ < 100);
-
-       /* Disable MAC Tx/Rx */
-       RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
-       Value &= (0xfffffff3);
-       RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
-
-       {
-               AsicSendCommandToMcu(pAd, 0x30, 0xff, 0xff, 0x02);
-       }
-}
-
-#endif /* RTMP_MAC_USB // */
diff --git a/drivers/staging/rt2860/common/cmm_sanity.c b/drivers/staging/rt2860/common/cmm_sanity.c
deleted file mode 100644 (file)
index 3bfb4ad..0000000
+++ /dev/null
@@ -1,1205 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-       Module Name:
-       sanity.c
-
-       Abstract:
-
-       Revision History:
-       Who                     When                    What
-       --------        ----------              ----------------------------------------------
-       John Chang  2004-09-01      add WMM support
-*/
-#include "../rt_config.h"
-
-extern u8 CISCO_OUI[];
-
-extern u8 WPA_OUI[];
-extern u8 RSN_OUI[];
-extern u8 WME_INFO_ELEM[];
-extern u8 WME_PARM_ELEM[];
-extern u8 Ccx2QosInfo[];
-extern u8 RALINK_OUI[];
-extern u8 BROADCOM_OUI[];
-extern u8 WPS_OUI[];
-
-/*
-    ==========================================================================
-    Description:
-        MLME message sanity check
-    Return:
-        TRUE if all parameters are OK, FALSE otherwise
-
-       IRQL = DISPATCH_LEVEL
-
-    ==========================================================================
- */
-BOOLEAN MlmeAddBAReqSanity(struct rt_rtmp_adapter *pAd,
-                          void * Msg, unsigned long MsgLen, u8 *pAddr2)
-{
-       struct rt_mlme_addba_req *pInfo;
-
-       pInfo = (struct rt_mlme_addba_req *)Msg;
-
-       if ((MsgLen != sizeof(struct rt_mlme_addba_req))) {
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("MlmeAddBAReqSanity fail - message length not correct.\n"));
-               return FALSE;
-       }
-
-       if ((pInfo->Wcid >= MAX_LEN_OF_MAC_TABLE)) {
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("MlmeAddBAReqSanity fail - The peer Mac is not associated yet.\n"));
-               return FALSE;
-       }
-
-       if ((pInfo->pAddr[0] & 0x01) == 0x01) {
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("MlmeAddBAReqSanity fail - broadcast address not support BA\n"));
-               return FALSE;
-       }
-
-       return TRUE;
-}
-
-/*
-    ==========================================================================
-    Description:
-        MLME message sanity check
-    Return:
-        TRUE if all parameters are OK, FALSE otherwise
-
-       IRQL = DISPATCH_LEVEL
-
-    ==========================================================================
- */
-BOOLEAN MlmeDelBAReqSanity(struct rt_rtmp_adapter *pAd, void * Msg, unsigned long MsgLen)
-{
-       struct rt_mlme_delba_req *pInfo;
-       pInfo = (struct rt_mlme_delba_req *)Msg;
-
-       if ((MsgLen != sizeof(struct rt_mlme_delba_req))) {
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("MlmeDelBAReqSanity fail - message length not correct.\n"));
-               return FALSE;
-       }
-
-       if ((pInfo->Wcid >= MAX_LEN_OF_MAC_TABLE)) {
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("MlmeDelBAReqSanity fail - The peer Mac is not associated yet.\n"));
-               return FALSE;
-       }
-
-       if ((pInfo->TID & 0xf0)) {
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("MlmeDelBAReqSanity fail - The peer TID is incorrect.\n"));
-               return FALSE;
-       }
-
-       if (NdisEqualMemory
-           (pAd->MacTab.Content[pInfo->Wcid].Addr, pInfo->Addr,
-            MAC_ADDR_LEN) == 0) {
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("MlmeDelBAReqSanity fail - the peer addr dosen't exist.\n"));
-               return FALSE;
-       }
-
-       return TRUE;
-}
-
-BOOLEAN PeerAddBAReqActionSanity(struct rt_rtmp_adapter *pAd,
-                                void * pMsg,
-                                unsigned long MsgLen, u8 *pAddr2)
-{
-       struct rt_frame_802_11 * pFrame = (struct rt_frame_802_11 *) pMsg;
-       struct rt_frame_addba_req * pAddFrame;
-       pAddFrame = (struct rt_frame_addba_req *) (pMsg);
-       if (MsgLen < (sizeof(struct rt_frame_addba_req))) {
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("PeerAddBAReqActionSanity: ADDBA Request frame length size = %ld incorrect\n",
-                         MsgLen));
-               return FALSE;
-       }
-       /* we support immediate BA. */
-       *(u16 *) (&pAddFrame->BaParm) =
-           cpu2le16(*(u16 *) (&pAddFrame->BaParm));
-       pAddFrame->TimeOutValue = cpu2le16(pAddFrame->TimeOutValue);
-       pAddFrame->BaStartSeq.word = cpu2le16(pAddFrame->BaStartSeq.word);
-
-       if (pAddFrame->BaParm.BAPolicy != IMMED_BA) {
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("PeerAddBAReqActionSanity: ADDBA Request Ba Policy[%d] not support\n",
-                         pAddFrame->BaParm.BAPolicy));
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("ADDBA Request. tid=%x, Bufsize=%x, AMSDUSupported=%x \n",
-                         pAddFrame->BaParm.TID, pAddFrame->BaParm.BufSize,
-                         pAddFrame->BaParm.AMSDUSupported));
-               return FALSE;
-       }
-       /* we support immediate BA. */
-       if (pAddFrame->BaParm.TID & 0xfff0) {
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("PeerAddBAReqActionSanity: ADDBA Request incorrect TID = %d\n",
-                         pAddFrame->BaParm.TID));
-               return FALSE;
-       }
-       COPY_MAC_ADDR(pAddr2, pFrame->Hdr.Addr2);
-       return TRUE;
-}
-
-BOOLEAN PeerAddBARspActionSanity(struct rt_rtmp_adapter *pAd,
-                                void * pMsg, unsigned long MsgLen)
-{
-       struct rt_frame_addba_rsp * pAddFrame;
-
-       pAddFrame = (struct rt_frame_addba_rsp *) (pMsg);
-       if (MsgLen < (sizeof(struct rt_frame_addba_rsp))) {
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("PeerAddBARspActionSanity: ADDBA Response frame length size = %ld incorrect\n",
-                         MsgLen));
-               return FALSE;
-       }
-       /* we support immediate BA. */
-       *(u16 *) (&pAddFrame->BaParm) =
-           cpu2le16(*(u16 *) (&pAddFrame->BaParm));
-       pAddFrame->StatusCode = cpu2le16(pAddFrame->StatusCode);
-       pAddFrame->TimeOutValue = cpu2le16(pAddFrame->TimeOutValue);
-
-       if (pAddFrame->BaParm.BAPolicy != IMMED_BA) {
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("PeerAddBAReqActionSanity: ADDBA Response Ba Policy[%d] not support\n",
-                         pAddFrame->BaParm.BAPolicy));
-               return FALSE;
-       }
-       /* we support immediate BA. */
-       if (pAddFrame->BaParm.TID & 0xfff0) {
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("PeerAddBARspActionSanity: ADDBA Response incorrect TID = %d\n",
-                         pAddFrame->BaParm.TID));
-               return FALSE;
-       }
-       return TRUE;
-
-}
-
-BOOLEAN PeerDelBAActionSanity(struct rt_rtmp_adapter *pAd,
-                             u8 Wcid, void * pMsg, unsigned long MsgLen)
-{
-       /*struct rt_frame_802_11 * pFrame = (struct rt_frame_802_11 *)pMsg; */
-       struct rt_frame_delba_req * pDelFrame;
-       if (MsgLen != (sizeof(struct rt_frame_delba_req)))
-               return FALSE;
-
-       if (Wcid >= MAX_LEN_OF_MAC_TABLE)
-               return FALSE;
-
-       pDelFrame = (struct rt_frame_delba_req *) (pMsg);
-
-       *(u16 *) (&pDelFrame->DelbaParm) =
-           cpu2le16(*(u16 *) (&pDelFrame->DelbaParm));
-       pDelFrame->ReasonCode = cpu2le16(pDelFrame->ReasonCode);
-
-       if (pDelFrame->DelbaParm.TID & 0xfff0)
-               return FALSE;
-
-       return TRUE;
-}
-
-/*
-    ==========================================================================
-    Description:
-        MLME message sanity check
-    Return:
-        TRUE if all parameters are OK, FALSE otherwise
-
-       IRQL = DISPATCH_LEVEL
-
-    ==========================================================================
- */
-BOOLEAN PeerBeaconAndProbeRspSanity(struct rt_rtmp_adapter *pAd, void * Msg, unsigned long MsgLen, u8 MsgChannel, u8 *pAddr2, u8 *pBssid, char Ssid[], u8 * pSsidLen, u8 * pBssType, u16 * pBeaconPeriod, u8 * pChannel, u8 * pNewChannel, OUT LARGE_INTEGER * pTimestamp, struct rt_cf_parm * pCfParm, u16 * pAtimWin, u16 * pCapabilityInfo, u8 * pErp, u8 * pDtimCount, u8 * pDtimPeriod, u8 * pBcastFlag, u8 * pMessageToMe, u8 SupRate[], u8 * pSupRateLen, u8 ExtRate[], u8 * pExtRateLen, u8 * pCkipFlag, u8 * pAironetCellPowerLimit, struct rt_edca_parm *pEdcaParm, struct rt_qbss_load_parm *pQbssLoad, struct rt_qos_capability_parm *pQosCapability, unsigned long * pRalinkIe, u8 * pHtCapabilityLen, u8 * pPreNHtCapabilityLen, struct rt_ht_capability_ie * pHtCapability, u8 * AddHtInfoLen, struct rt_add_ht_info_ie * AddHtInfo, u8 * NewExtChannelOffset,  /* Ht extension channel offset(above or below) */
-                                   u16 * LengthVIE,
-                                   struct rt_ndis_802_11_variable_ies *pVIE)
-{
-       u8 *Ptr;
-       u8 TimLen;
-       struct rt_frame_802_11 * pFrame;
-       struct rt_eid * pEid;
-       u8 SubType;
-       u8 Sanity;
-       /*u8                             ECWMin, ECWMax; */
-       /*MAC_CSR9_STRUC            Csr9; */
-       unsigned long Length = 0;
-
-       /* For some 11a AP which didn't have DS_IE, we use two conditions to decide the channel */
-       /*      1. If the AP is 11n enabled, then check the control channel. */
-       /*      2. If the AP didn't have any info about channel, use the channel we received this frame as the channel. (May inaccuracy!) */
-       u8 CtrlChannel = 0;
-
-       /* Add for 3 necessary EID field check */
-       Sanity = 0;
-
-       *pAtimWin = 0;
-       *pErp = 0;
-       *pDtimCount = 0;
-       *pDtimPeriod = 0;
-       *pBcastFlag = 0;
-       *pMessageToMe = 0;
-       *pExtRateLen = 0;
-       *pCkipFlag = 0;         /* Default of CkipFlag is 0 */
-       *pAironetCellPowerLimit = 0xFF; /* Default of AironetCellPowerLimit is 0xFF */
-       *LengthVIE = 0;         /* Set the length of VIE to init value 0 */
-       *pHtCapabilityLen = 0;  /* Set the length of VIE to init value 0 */
-       if (pAd->OpMode == OPMODE_STA)
-               *pPreNHtCapabilityLen = 0;      /* Set the length of VIE to init value 0 */
-       *AddHtInfoLen = 0;      /* Set the length of VIE to init value 0 */
-       *pRalinkIe = 0;
-       *pNewChannel = 0;
-       *NewExtChannelOffset = 0xff;    /*Default 0xff means no such IE */
-       pCfParm->bValid = FALSE;        /* default: no IE_CF found */
-       pQbssLoad->bValid = FALSE;      /* default: no IE_QBSS_LOAD found */
-       pEdcaParm->bValid = FALSE;      /* default: no IE_EDCA_PARAMETER found */
-       pQosCapability->bValid = FALSE; /* default: no IE_QOS_CAPABILITY found */
-
-       pFrame = (struct rt_frame_802_11 *) Msg;
-
-       /* get subtype from header */
-       SubType = (u8)pFrame->Hdr.FC.SubType;
-
-       /* get Addr2 and BSSID from header */
-       COPY_MAC_ADDR(pAddr2, pFrame->Hdr.Addr2);
-       COPY_MAC_ADDR(pBssid, pFrame->Hdr.Addr3);
-
-       Ptr = pFrame->Octet;
-       Length += LENGTH_802_11;
-
-       /* get timestamp from payload and advance the pointer */
-       NdisMoveMemory(pTimestamp, Ptr, TIMESTAMP_LEN);
-
-       pTimestamp->u.LowPart = cpu2le32(pTimestamp->u.LowPart);
-       pTimestamp->u.HighPart = cpu2le32(pTimestamp->u.HighPart);
-
-       Ptr += TIMESTAMP_LEN;
-       Length += TIMESTAMP_LEN;
-
-       /* get beacon interval from payload and advance the pointer */
-       NdisMoveMemory(pBeaconPeriod, Ptr, 2);
-       Ptr += 2;
-       Length += 2;
-
-       /* get capability info from payload and advance the pointer */
-       NdisMoveMemory(pCapabilityInfo, Ptr, 2);
-       Ptr += 2;
-       Length += 2;
-
-       if (CAP_IS_ESS_ON(*pCapabilityInfo))
-               *pBssType = BSS_INFRA;
-       else
-               *pBssType = BSS_ADHOC;
-
-       pEid = (struct rt_eid *) Ptr;
-
-       /* get variable fields from payload and advance the pointer */
-       while ((Length + 2 + pEid->Len) <= MsgLen) {
-               /* */
-               /* Secure copy VIE to VarIE[MAX_VIE_LEN] didn't overflow. */
-               /* */
-               if ((*LengthVIE + pEid->Len + 2) >= MAX_VIE_LEN) {
-                       DBGPRINT(RT_DEBUG_WARN,
-                                ("PeerBeaconAndProbeRspSanity - Variable IEs out of resource [len(=%d) > MAX_VIE_LEN(=%d)]\n",
-                                 (*LengthVIE + pEid->Len + 2), MAX_VIE_LEN));
-                       break;
-               }
-
-               switch (pEid->Eid) {
-               case IE_SSID:
-                       /* Already has one SSID EID in this beacon, ignore the second one */
-                       if (Sanity & 0x1)
-                               break;
-                       if (pEid->Len <= MAX_LEN_OF_SSID) {
-                               NdisMoveMemory(Ssid, pEid->Octet, pEid->Len);
-                               *pSsidLen = pEid->Len;
-                               Sanity |= 0x1;
-                       } else {
-                               DBGPRINT(RT_DEBUG_TRACE,
-                                        ("PeerBeaconAndProbeRspSanity - wrong IE_SSID (len=%d)\n",
-                                         pEid->Len));
-                               return FALSE;
-                       }
-                       break;
-
-               case IE_SUPP_RATES:
-                       if (pEid->Len <= MAX_LEN_OF_SUPPORTED_RATES) {
-                               Sanity |= 0x2;
-                               NdisMoveMemory(SupRate, pEid->Octet, pEid->Len);
-                               *pSupRateLen = pEid->Len;
-
-                               /* TODO: 2004-09-14 not a good design here, cause it exclude extra rates */
-                               /* from ScanTab. We should report as is. And filter out unsupported */
-                               /* rates in MlmeAux. */
-                               /* Check against the supported rates */
-                               /* RTMPCheckRates(pAd, SupRate, pSupRateLen); */
-                       } else {
-                               DBGPRINT(RT_DEBUG_TRACE,
-                                        ("PeerBeaconAndProbeRspSanity - wrong IE_SUPP_RATES (len=%d)\n",
-                                         pEid->Len));
-                               return FALSE;
-                       }
-                       break;
-
-               case IE_HT_CAP:
-                       if (pEid->Len >= SIZE_HT_CAP_IE)        /*Note: allow extension! */
-                       {
-                               NdisMoveMemory(pHtCapability, pEid->Octet,
-                                              sizeof(struct rt_ht_capability_ie));
-                               *pHtCapabilityLen = SIZE_HT_CAP_IE;     /* Nnow we only support 26 bytes. */
-
-                               *(u16 *) (&pHtCapability->HtCapInfo) =
-                                   cpu2le16(*(u16 *)
-                                            (&pHtCapability->HtCapInfo));
-                               *(u16 *) (&pHtCapability->ExtHtCapInfo) =
-                                   cpu2le16(*(u16 *)
-                                            (&pHtCapability->ExtHtCapInfo));
-
-                               {
-                                       *pPreNHtCapabilityLen = 0;      /* Nnow we only support 26 bytes. */
-
-                                       Ptr = (u8 *)pVIE;
-                                       NdisMoveMemory(Ptr + *LengthVIE,
-                                                      &pEid->Eid,
-                                                      pEid->Len + 2);
-                                       *LengthVIE += (pEid->Len + 2);
-                               }
-                       } else {
-                               DBGPRINT(RT_DEBUG_WARN,
-                                        ("PeerBeaconAndProbeRspSanity - wrong IE_HT_CAP. pEid->Len = %d\n",
-                                         pEid->Len));
-                       }
-
-                       break;
-               case IE_ADD_HT:
-                       if (pEid->Len >= sizeof(struct rt_add_ht_info_ie)) {
-                               /* This IE allows extension, but we can ignore extra bytes beyond our knowledge , so only */
-                               /* copy first sizeof(struct rt_add_ht_info_ie) */
-                               NdisMoveMemory(AddHtInfo, pEid->Octet,
-                                              sizeof(struct rt_add_ht_info_ie));
-                               *AddHtInfoLen = SIZE_ADD_HT_INFO_IE;
-
-                               CtrlChannel = AddHtInfo->ControlChan;
-
-                               *(u16 *) (&AddHtInfo->AddHtInfo2) =
-                                   cpu2le16(*(u16 *)
-                                            (&AddHtInfo->AddHtInfo2));
-                               *(u16 *) (&AddHtInfo->AddHtInfo3) =
-                                   cpu2le16(*(u16 *)
-                                            (&AddHtInfo->AddHtInfo3));
-
-                               {
-                                       Ptr = (u8 *)pVIE;
-                                       NdisMoveMemory(Ptr + *LengthVIE,
-                                                      &pEid->Eid,
-                                                      pEid->Len + 2);
-                                       *LengthVIE += (pEid->Len + 2);
-                               }
-                       } else {
-                               DBGPRINT(RT_DEBUG_WARN,
-                                        ("PeerBeaconAndProbeRspSanity - wrong IE_ADD_HT. \n"));
-                       }
-
-                       break;
-               case IE_SECONDARY_CH_OFFSET:
-                       if (pEid->Len == 1) {
-                               *NewExtChannelOffset = pEid->Octet[0];
-                       } else {
-                               DBGPRINT(RT_DEBUG_WARN,
-                                        ("PeerBeaconAndProbeRspSanity - wrong IE_SECONDARY_CH_OFFSET. \n"));
-                       }
-
-                       break;
-               case IE_FH_PARM:
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("PeerBeaconAndProbeRspSanity(IE_FH_PARM) \n"));
-                       break;
-
-               case IE_DS_PARM:
-                       if (pEid->Len == 1) {
-                               *pChannel = *pEid->Octet;
-
-                               {
-                                       if (ChannelSanity(pAd, *pChannel) == 0) {
-
-                                               return FALSE;
-                                       }
-                               }
-
-                               Sanity |= 0x4;
-                       } else {
-                               DBGPRINT(RT_DEBUG_TRACE,
-                                        ("PeerBeaconAndProbeRspSanity - wrong IE_DS_PARM (len=%d)\n",
-                                         pEid->Len));
-                               return FALSE;
-                       }
-                       break;
-
-               case IE_CF_PARM:
-                       if (pEid->Len == 6) {
-                               pCfParm->bValid = TRUE;
-                               pCfParm->CfpCount = pEid->Octet[0];
-                               pCfParm->CfpPeriod = pEid->Octet[1];
-                               pCfParm->CfpMaxDuration =
-                                   pEid->Octet[2] + 256 * pEid->Octet[3];
-                               pCfParm->CfpDurRemaining =
-                                   pEid->Octet[4] + 256 * pEid->Octet[5];
-                       } else {
-                               DBGPRINT(RT_DEBUG_TRACE,
-                                        ("PeerBeaconAndProbeRspSanity - wrong IE_CF_PARM\n"));
-                               return FALSE;
-                       }
-                       break;
-
-               case IE_IBSS_PARM:
-                       if (pEid->Len == 2) {
-                               NdisMoveMemory(pAtimWin, pEid->Octet,
-                                              pEid->Len);
-                       } else {
-                               DBGPRINT(RT_DEBUG_TRACE,
-                                        ("PeerBeaconAndProbeRspSanity - wrong IE_IBSS_PARM\n"));
-                               return FALSE;
-                       }
-                       break;
-
-               case IE_TIM:
-                       if (INFRA_ON(pAd) && SubType == SUBTYPE_BEACON) {
-                               GetTimBit((char *)pEid, pAd->StaActive.Aid,
-                                         &TimLen, pBcastFlag, pDtimCount,
-                                         pDtimPeriod, pMessageToMe);
-                       }
-                       break;
-               case IE_CHANNEL_SWITCH_ANNOUNCEMENT:
-                       if (pEid->Len == 3) {
-                               *pNewChannel = pEid->Octet[1];  /*extract new channel number */
-                       }
-                       break;
-
-                       /* New for WPA */
-                       /* CCX v2 has the same IE, we need to parse that too */
-                       /* Wifi WMM use the same IE vale, need to parse that too */
-                       /* case IE_WPA: */
-               case IE_VENDOR_SPECIFIC:
-                       /* Check Broadcom/Atheros 802.11n OUI version, for HT Capability IE. */
-                       /* This HT IE is before IEEE draft set HT IE value.2006-09-28 by Jan. */
-                       /*if (NdisEqualMemory(pEid->Octet, BROADCOM_OUI, 3) && (pEid->Len >= 4))
-                          {
-                          if ((pEid->Octet[3] == OUI_BROADCOM_HT) && (pEid->Len >= 30))
-                          {
-                          {
-                          NdisMoveMemory(pHtCapability, &pEid->Octet[4], sizeof(struct rt_ht_capability_ie));
-                          *pHtCapabilityLen = SIZE_HT_CAP_IE;  // Nnow we only support 26 bytes.
-                          }
-                          }
-                          if ((pEid->Octet[3] == OUI_BROADCOM_HT) && (pEid->Len >= 26))
-                          {
-                          {
-                          NdisMoveMemory(AddHtInfo, &pEid->Octet[4], sizeof(struct rt_add_ht_info_ie));
-                          *AddHtInfoLen = SIZE_ADD_HT_INFO_IE; // Nnow we only support 26 bytes.
-                          }
-                          }
-                          }
-                        */
-                       /* Check the OUI version, filter out non-standard usage */
-                       if (NdisEqualMemory(pEid->Octet, RALINK_OUI, 3)
-                           && (pEid->Len == 7)) {
-                               /**pRalinkIe = pEid->Octet[3]; */
-                               if (pEid->Octet[3] != 0)
-                                       *pRalinkIe = pEid->Octet[3];
-                               else
-                                       *pRalinkIe = 0xf0000000;        /* Set to non-zero value (can't set bit0-2) to represent this is Ralink Chip. So at linkup, we will set ralinkchip flag. */
-                       }
-                       /* This HT IE is before IEEE draft set HT IE value.2006-09-28 by Jan. */
-
-                       /* Other vendors had production before IE_HT_CAP value is assigned. To backward support those old-firmware AP, */
-                       /* Check broadcom-defiend pre-802.11nD1.0 OUI for HT related IE, including HT Capatilities IE and HT Information IE */
-                       else if ((*pHtCapabilityLen == 0)
-                                && NdisEqualMemory(pEid->Octet, PRE_N_HT_OUI,
-                                                   3) && (pEid->Len >= 4)
-                                && (pAd->OpMode == OPMODE_STA)) {
-                               if ((pEid->Octet[3] == OUI_PREN_HT_CAP)
-                                   && (pEid->Len >= 30)
-                                   && (*pHtCapabilityLen == 0)) {
-                                       NdisMoveMemory(pHtCapability,
-                                                      &pEid->Octet[4],
-                                                      sizeof
-                                                      (struct rt_ht_capability_ie));
-                                       *pPreNHtCapabilityLen = SIZE_HT_CAP_IE;
-                               }
-
-                               if ((pEid->Octet[3] == OUI_PREN_ADD_HT)
-                                   && (pEid->Len >= 26)) {
-                                       NdisMoveMemory(AddHtInfo,
-                                                      &pEid->Octet[4],
-                                                      sizeof(struct rt_add_ht_info_ie));
-                                       *AddHtInfoLen = SIZE_ADD_HT_INFO_IE;
-                               }
-                       } else if (NdisEqualMemory(pEid->Octet, WPA_OUI, 4)) {
-                               /* Copy to pVIE which will report to microsoft bssid list. */
-                               Ptr = (u8 *)pVIE;
-                               NdisMoveMemory(Ptr + *LengthVIE, &pEid->Eid,
-                                              pEid->Len + 2);
-                               *LengthVIE += (pEid->Len + 2);
-                       } else
-                           if (NdisEqualMemory(pEid->Octet, WME_PARM_ELEM, 6)
-                               && (pEid->Len == 24)) {
-                               u8 *ptr;
-                               int i;
-
-                               /* parsing EDCA parameters */
-                               pEdcaParm->bValid = TRUE;
-                               pEdcaParm->bQAck = FALSE;       /* pEid->Octet[0] & 0x10; */
-                               pEdcaParm->bQueueRequest = FALSE;       /* pEid->Octet[0] & 0x20; */
-                               pEdcaParm->bTxopRequest = FALSE;        /* pEid->Octet[0] & 0x40; */
-                               pEdcaParm->EdcaUpdateCount =
-                                   pEid->Octet[6] & 0x0f;
-                               pEdcaParm->bAPSDCapable =
-                                   (pEid->Octet[6] & 0x80) ? 1 : 0;
-                               ptr = &pEid->Octet[8];
-                               for (i = 0; i < 4; i++) {
-                                       u8 aci = (*ptr & 0x60) >> 5;    /* b5~6 is AC INDEX */
-                                       pEdcaParm->bACM[aci] = (((*ptr) & 0x10) == 0x10);       /* b5 is ACM */
-                                       pEdcaParm->Aifsn[aci] = (*ptr) & 0x0f;  /* b0~3 is AIFSN */
-                                       pEdcaParm->Cwmin[aci] = *(ptr + 1) & 0x0f;      /* b0~4 is Cwmin */
-                                       pEdcaParm->Cwmax[aci] = *(ptr + 1) >> 4;        /* b5~8 is Cwmax */
-                                       pEdcaParm->Txop[aci] = *(ptr + 2) + 256 * (*(ptr + 3)); /* in unit of 32-us */
-                                       ptr += 4;       /* point to next AC */
-                               }
-                       } else
-                           if (NdisEqualMemory(pEid->Octet, WME_INFO_ELEM, 6)
-                               && (pEid->Len == 7)) {
-                               /* parsing EDCA parameters */
-                               pEdcaParm->bValid = TRUE;
-                               pEdcaParm->bQAck = FALSE;       /* pEid->Octet[0] & 0x10; */
-                               pEdcaParm->bQueueRequest = FALSE;       /* pEid->Octet[0] & 0x20; */
-                               pEdcaParm->bTxopRequest = FALSE;        /* pEid->Octet[0] & 0x40; */
-                               pEdcaParm->EdcaUpdateCount =
-                                   pEid->Octet[6] & 0x0f;
-                               pEdcaParm->bAPSDCapable =
-                                   (pEid->Octet[6] & 0x80) ? 1 : 0;
-
-                               /* use default EDCA parameter */
-                               pEdcaParm->bACM[QID_AC_BE] = 0;
-                               pEdcaParm->Aifsn[QID_AC_BE] = 3;
-                               pEdcaParm->Cwmin[QID_AC_BE] = CW_MIN_IN_BITS;
-                               pEdcaParm->Cwmax[QID_AC_BE] = CW_MAX_IN_BITS;
-                               pEdcaParm->Txop[QID_AC_BE] = 0;
-
-                               pEdcaParm->bACM[QID_AC_BK] = 0;
-                               pEdcaParm->Aifsn[QID_AC_BK] = 7;
-                               pEdcaParm->Cwmin[QID_AC_BK] = CW_MIN_IN_BITS;
-                               pEdcaParm->Cwmax[QID_AC_BK] = CW_MAX_IN_BITS;
-                               pEdcaParm->Txop[QID_AC_BK] = 0;
-
-                               pEdcaParm->bACM[QID_AC_VI] = 0;
-                               pEdcaParm->Aifsn[QID_AC_VI] = 2;
-                               pEdcaParm->Cwmin[QID_AC_VI] =
-                                   CW_MIN_IN_BITS - 1;
-                               pEdcaParm->Cwmax[QID_AC_VI] = CW_MAX_IN_BITS;
-                               pEdcaParm->Txop[QID_AC_VI] = 96;        /* AC_VI: 96*32us ~= 3ms */
-
-                               pEdcaParm->bACM[QID_AC_VO] = 0;
-                               pEdcaParm->Aifsn[QID_AC_VO] = 2;
-                               pEdcaParm->Cwmin[QID_AC_VO] =
-                                   CW_MIN_IN_BITS - 2;
-                               pEdcaParm->Cwmax[QID_AC_VO] =
-                                   CW_MAX_IN_BITS - 1;
-                               pEdcaParm->Txop[QID_AC_VO] = 48;        /* AC_VO: 48*32us ~= 1.5ms */
-                       }
-
-                       break;
-
-               case IE_EXT_SUPP_RATES:
-                       if (pEid->Len <= MAX_LEN_OF_SUPPORTED_RATES) {
-                               NdisMoveMemory(ExtRate, pEid->Octet, pEid->Len);
-                               *pExtRateLen = pEid->Len;
-
-                               /* TODO: 2004-09-14 not a good design here, cause it exclude extra rates */
-                               /* from ScanTab. We should report as is. And filter out unsupported */
-                               /* rates in MlmeAux. */
-                               /* Check against the supported rates */
-                               /* RTMPCheckRates(pAd, ExtRate, pExtRateLen); */
-                       }
-                       break;
-
-               case IE_ERP:
-                       if (pEid->Len == 1) {
-                               *pErp = (u8)pEid->Octet[0];
-                       }
-                       break;
-
-               case IE_AIRONET_CKIP:
-                       /* 0. Check Aironet IE length, it must be larger or equal to 28 */
-                       /* Cisco AP350 used length as 28 */
-                       /* Cisco AP12XX used length as 30 */
-                       if (pEid->Len < (CKIP_NEGOTIATION_LENGTH - 2))
-                               break;
-
-                       /* 1. Copy CKIP flag byte to buffer for process */
-                       *pCkipFlag = *(pEid->Octet + 8);
-                       break;
-
-               case IE_AP_TX_POWER:
-                       /* AP Control of Client Transmit Power */
-                       /*0. Check Aironet IE length, it must be 6 */
-                       if (pEid->Len != 0x06)
-                               break;
-
-                       /* Get cell power limit in dBm */
-                       if (NdisEqualMemory(pEid->Octet, CISCO_OUI, 3) == 1)
-                               *pAironetCellPowerLimit = *(pEid->Octet + 4);
-                       break;
-
-                       /* WPA2 & 802.11i RSN */
-               case IE_RSN:
-                       /* There is no OUI for version anymore, check the group cipher OUI before copying */
-                       if (RTMPEqualMemory(pEid->Octet + 2, RSN_OUI, 3)) {
-                               /* Copy to pVIE which will report to microsoft bssid list. */
-                               Ptr = (u8 *)pVIE;
-                               NdisMoveMemory(Ptr + *LengthVIE, &pEid->Eid,
-                                              pEid->Len + 2);
-                               *LengthVIE += (pEid->Len + 2);
-                       }
-                       break;
-
-               default:
-                       break;
-               }
-
-               Length = Length + 2 + pEid->Len;        /* Eid[1] + Len[1]+ content[Len] */
-               pEid = (struct rt_eid *) ((u8 *) pEid + 2 + pEid->Len);
-       }
-
-       /* For some 11a AP. it did not have the channel EID, patch here */
-       {
-               u8 LatchRfChannel = MsgChannel;
-               if ((pAd->LatchRfRegs.Channel > 14) && ((Sanity & 0x4) == 0)) {
-                       if (CtrlChannel != 0)
-                               *pChannel = CtrlChannel;
-                       else
-                               *pChannel = LatchRfChannel;
-                       Sanity |= 0x4;
-               }
-       }
-
-       if (Sanity != 0x7) {
-               DBGPRINT(RT_DEBUG_LOUD,
-                        ("PeerBeaconAndProbeRspSanity - missing field, Sanity=0x%02x\n",
-                         Sanity));
-               return FALSE;
-       } else {
-               return TRUE;
-       }
-
-}
-
-/*
-    ==========================================================================
-    Description:
-        MLME message sanity check
-    Return:
-        TRUE if all parameters are OK, FALSE otherwise
-    ==========================================================================
- */
-BOOLEAN MlmeScanReqSanity(struct rt_rtmp_adapter *pAd,
-                         void * Msg,
-                         unsigned long MsgLen,
-                         u8 * pBssType,
-                         char Ssid[],
-                         u8 * pSsidLen, u8 * pScanType)
-{
-       struct rt_mlme_scan_req *Info;
-
-       Info = (struct rt_mlme_scan_req *)(Msg);
-       *pBssType = Info->BssType;
-       *pSsidLen = Info->SsidLen;
-       NdisMoveMemory(Ssid, Info->Ssid, *pSsidLen);
-       *pScanType = Info->ScanType;
-
-       if ((*pBssType == BSS_INFRA || *pBssType == BSS_ADHOC
-            || *pBssType == BSS_ANY)
-           && (*pScanType == SCAN_ACTIVE || *pScanType == SCAN_PASSIVE)) {
-               return TRUE;
-       } else {
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("MlmeScanReqSanity fail - wrong BssType or ScanType\n"));
-               return FALSE;
-       }
-}
-
-/* IRQL = DISPATCH_LEVEL */
-u8 ChannelSanity(struct rt_rtmp_adapter *pAd, u8 channel)
-{
-       int i;
-
-       for (i = 0; i < pAd->ChannelListNum; i++) {
-               if (channel == pAd->ChannelList[i].Channel)
-                       return 1;
-       }
-       return 0;
-}
-
-/*
-    ==========================================================================
-    Description:
-        MLME message sanity check
-    Return:
-        TRUE if all parameters are OK, FALSE otherwise
-
-       IRQL = DISPATCH_LEVEL
-
-    ==========================================================================
- */
-BOOLEAN PeerDeauthSanity(struct rt_rtmp_adapter *pAd,
-                        void * Msg,
-                        unsigned long MsgLen,
-                        u8 *pAddr2, u16 * pReason)
-{
-       struct rt_frame_802_11 * pFrame = (struct rt_frame_802_11 *) Msg;
-
-       COPY_MAC_ADDR(pAddr2, pFrame->Hdr.Addr2);
-       NdisMoveMemory(pReason, &pFrame->Octet[0], 2);
-
-       return TRUE;
-}
-
-/*
-    ==========================================================================
-    Description:
-        MLME message sanity check
-    Return:
-        TRUE if all parameters are OK, FALSE otherwise
-
-       IRQL = DISPATCH_LEVEL
-
-    ==========================================================================
- */
-BOOLEAN PeerAuthSanity(struct rt_rtmp_adapter *pAd,
-                      void * Msg,
-                      unsigned long MsgLen,
-                      u8 *pAddr,
-                      u16 * pAlg,
-                      u16 * pSeq,
-                      u16 * pStatus, char * pChlgText)
-{
-       struct rt_frame_802_11 * pFrame = (struct rt_frame_802_11 *) Msg;
-
-       COPY_MAC_ADDR(pAddr, pFrame->Hdr.Addr2);
-       NdisMoveMemory(pAlg, &pFrame->Octet[0], 2);
-       NdisMoveMemory(pSeq, &pFrame->Octet[2], 2);
-       NdisMoveMemory(pStatus, &pFrame->Octet[4], 2);
-
-       if (*pAlg == AUTH_MODE_OPEN) {
-               if (*pSeq == 1 || *pSeq == 2) {
-                       return TRUE;
-               } else {
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("PeerAuthSanity fail - wrong Seg#\n"));
-                       return FALSE;
-               }
-       } else if (*pAlg == AUTH_MODE_KEY) {
-               if (*pSeq == 1 || *pSeq == 4) {
-                       return TRUE;
-               } else if (*pSeq == 2 || *pSeq == 3) {
-                       NdisMoveMemory(pChlgText, &pFrame->Octet[8],
-                                      CIPHER_TEXT_LEN);
-                       return TRUE;
-               } else {
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("PeerAuthSanity fail - wrong Seg#\n"));
-                       return FALSE;
-               }
-       } else {
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("PeerAuthSanity fail - wrong algorithm\n"));
-               return FALSE;
-       }
-}
-
-/*
-    ==========================================================================
-    Description:
-        MLME message sanity check
-    Return:
-        TRUE if all parameters are OK, FALSE otherwise
-    ==========================================================================
- */
-BOOLEAN MlmeAuthReqSanity(struct rt_rtmp_adapter *pAd,
-                         void * Msg,
-                         unsigned long MsgLen,
-                         u8 *pAddr,
-                         unsigned long * pTimeout, u16 * pAlg)
-{
-       struct rt_mlme_auth_req *pInfo;
-
-       pInfo = (struct rt_mlme_auth_req *)Msg;
-       COPY_MAC_ADDR(pAddr, pInfo->Addr);
-       *pTimeout = pInfo->Timeout;
-       *pAlg = pInfo->Alg;
-
-       if (((*pAlg == AUTH_MODE_KEY) || (*pAlg == AUTH_MODE_OPEN)
-           ) && ((*pAddr & 0x01) == 0)) {
-               return TRUE;
-       } else {
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("MlmeAuthReqSanity fail - wrong algorithm\n"));
-               return FALSE;
-       }
-}
-
-/*
-    ==========================================================================
-    Description:
-        MLME message sanity check
-    Return:
-        TRUE if all parameters are OK, FALSE otherwise
-
-       IRQL = DISPATCH_LEVEL
-
-    ==========================================================================
- */
-BOOLEAN MlmeAssocReqSanity(struct rt_rtmp_adapter *pAd,
-                          void * Msg,
-                          unsigned long MsgLen,
-                          u8 *pApAddr,
-                          u16 * pCapabilityInfo,
-                          unsigned long * pTimeout, u16 * pListenIntv)
-{
-       struct rt_mlme_assoc_req *pInfo;
-
-       pInfo = (struct rt_mlme_assoc_req *)Msg;
-       *pTimeout = pInfo->Timeout;     /* timeout */
-       COPY_MAC_ADDR(pApAddr, pInfo->Addr);    /* AP address */
-       *pCapabilityInfo = pInfo->CapabilityInfo;       /* capability info */
-       *pListenIntv = pInfo->ListenIntv;
-
-       return TRUE;
-}
-
-/*
-    ==========================================================================
-    Description:
-        MLME message sanity check
-    Return:
-        TRUE if all parameters are OK, FALSE otherwise
-
-       IRQL = DISPATCH_LEVEL
-
-    ==========================================================================
- */
-BOOLEAN PeerDisassocSanity(struct rt_rtmp_adapter *pAd,
-                          void * Msg,
-                          unsigned long MsgLen,
-                          u8 *pAddr2, u16 * pReason)
-{
-       struct rt_frame_802_11 * pFrame = (struct rt_frame_802_11 *) Msg;
-
-       COPY_MAC_ADDR(pAddr2, pFrame->Hdr.Addr2);
-       NdisMoveMemory(pReason, &pFrame->Octet[0], 2);
-
-       return TRUE;
-}
-
-/*
-       ========================================================================
-       Routine Description:
-               Sanity check NetworkType (11b, 11g or 11a)
-
-       Arguments:
-               pBss - Pointer to BSS table.
-
-       Return Value:
-        Ndis802_11DS .......(11b)
-        Ndis802_11OFDM24....(11g)
-        Ndis802_11OFDM5.....(11a)
-
-       IRQL = DISPATCH_LEVEL
-
-       ========================================================================
-*/
-NDIS_802_11_NETWORK_TYPE NetworkTypeInUseSanity(struct rt_bss_entry *pBss)
-{
-       NDIS_802_11_NETWORK_TYPE NetWorkType;
-       u8 rate, i;
-
-       NetWorkType = Ndis802_11DS;
-
-       if (pBss->Channel <= 14) {
-               /* */
-               /* First check support Rate. */
-               /* */
-               for (i = 0; i < pBss->SupRateLen; i++) {
-                       rate = pBss->SupRate[i] & 0x7f; /* Mask out basic rate set bit */
-                       if ((rate == 2) || (rate == 4) || (rate == 11)
-                           || (rate == 22)) {
-                               continue;
-                       } else {
-                               /* */
-                               /* Otherwise (even rate > 108) means Ndis802_11OFDM24 */
-                               /* */
-                               NetWorkType = Ndis802_11OFDM24;
-                               break;
-                       }
-               }
-
-               /* */
-               /* Second check Extend Rate. */
-               /* */
-               if (NetWorkType != Ndis802_11OFDM24) {
-                       for (i = 0; i < pBss->ExtRateLen; i++) {
-                               rate = pBss->SupRate[i] & 0x7f; /* Mask out basic rate set bit */
-                               if ((rate == 2) || (rate == 4) || (rate == 11)
-                                   || (rate == 22)) {
-                                       continue;
-                               } else {
-                                       /* */
-                                       /* Otherwise (even rate > 108) means Ndis802_11OFDM24 */
-                                       /* */
-                                       NetWorkType = Ndis802_11OFDM24;
-                                       break;
-                               }
-                       }
-               }
-       } else {
-               NetWorkType = Ndis802_11OFDM5;
-       }
-
-       if (pBss->HtCapabilityLen != 0) {
-               if (NetWorkType == Ndis802_11OFDM5)
-                       NetWorkType = Ndis802_11OFDM5_N;
-               else
-                       NetWorkType = Ndis802_11OFDM24_N;
-       }
-
-       return NetWorkType;
-}
-
-/*
-    ==========================================================================
-    Description:
-        Check the validity of the received EAPoL frame
-    Return:
-        TRUE if all parameters are OK,
-        FALSE otherwise
-    ==========================================================================
- */
-BOOLEAN PeerWpaMessageSanity(struct rt_rtmp_adapter *pAd,
-                            struct rt_eapol_packet * pMsg,
-                            unsigned long MsgLen,
-                            u8 MsgType, struct rt_mac_table_entry *pEntry)
-{
-       u8 mic[LEN_KEY_DESC_MIC], digest[80], KEYDATA[MAX_LEN_OF_RSNIE];
-       BOOLEAN bReplayDiff = FALSE;
-       BOOLEAN bWPA2 = FALSE;
-       struct rt_key_info EapolKeyInfo;
-       u8 GroupKeyIndex = 0;
-
-       NdisZeroMemory(mic, sizeof(mic));
-       NdisZeroMemory(digest, sizeof(digest));
-       NdisZeroMemory(KEYDATA, sizeof(KEYDATA));
-       NdisZeroMemory((u8 *)& EapolKeyInfo, sizeof(EapolKeyInfo));
-
-       NdisMoveMemory((u8 *)& EapolKeyInfo,
-                      (u8 *)& pMsg->KeyDesc.KeyInfo, sizeof(struct rt_key_info));
-
-       *((u16 *) & EapolKeyInfo) = cpu2le16(*((u16 *) & EapolKeyInfo));
-
-       /* Choose WPA2 or not */
-       if ((pEntry->AuthMode == Ndis802_11AuthModeWPA2)
-           || (pEntry->AuthMode == Ndis802_11AuthModeWPA2PSK))
-               bWPA2 = TRUE;
-
-       /* 0. Check MsgType */
-       if ((MsgType > EAPOL_GROUP_MSG_2) || (MsgType < EAPOL_PAIR_MSG_1)) {
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("The message type is invalid(%d)! \n", MsgType));
-               return FALSE;
-       }
-       /* 1. Replay counter check */
-       if (MsgType == EAPOL_PAIR_MSG_1 || MsgType == EAPOL_PAIR_MSG_3 || MsgType == EAPOL_GROUP_MSG_1) /* For supplicant */
-       {
-               /* First validate replay counter, only accept message with larger replay counter. */
-               /* Let equal pass, some AP start with all zero replay counter */
-               u8 ZeroReplay[LEN_KEY_DESC_REPLAY];
-
-               NdisZeroMemory(ZeroReplay, LEN_KEY_DESC_REPLAY);
-               if ((RTMPCompareMemory
-                    (pMsg->KeyDesc.ReplayCounter, pEntry->R_Counter,
-                     LEN_KEY_DESC_REPLAY) != 1)
-                   &&
-                   (RTMPCompareMemory
-                    (pMsg->KeyDesc.ReplayCounter, ZeroReplay,
-                     LEN_KEY_DESC_REPLAY) != 0)) {
-                       bReplayDiff = TRUE;
-               }
-       } else if (MsgType == EAPOL_PAIR_MSG_2 || MsgType == EAPOL_PAIR_MSG_4 || MsgType == EAPOL_GROUP_MSG_2)  /* For authenticator */
-       {
-               /* check Replay Counter coresponds to MSG from authenticator, otherwise discard */
-               if (!NdisEqualMemory
-                   (pMsg->KeyDesc.ReplayCounter, pEntry->R_Counter,
-                    LEN_KEY_DESC_REPLAY)) {
-                       bReplayDiff = TRUE;
-               }
-       }
-       /* Replay Counter different condition */
-       if (bReplayDiff) {
-               /* send wireless event - for replay counter different */
-               if (pAd->CommonCfg.bWirelessEvent)
-                       RTMPSendWirelessEvent(pAd,
-                                             IW_REPLAY_COUNTER_DIFF_EVENT_FLAG,
-                                             pEntry->Addr, pEntry->apidx, 0);
-
-               if (MsgType < EAPOL_GROUP_MSG_1) {
-                       DBGPRINT(RT_DEBUG_ERROR,
-                                ("Replay Counter Different in pairwise msg %d of 4-way handshake!\n",
-                                 MsgType));
-               } else {
-                       DBGPRINT(RT_DEBUG_ERROR,
-                                ("Replay Counter Different in group msg %d of 2-way handshake!\n",
-                                 (MsgType - EAPOL_PAIR_MSG_4)));
-               }
-
-               hex_dump("Receive replay counter ", pMsg->KeyDesc.ReplayCounter,
-                        LEN_KEY_DESC_REPLAY);
-               hex_dump("Current replay counter ", pEntry->R_Counter,
-                        LEN_KEY_DESC_REPLAY);
-               return FALSE;
-       }
-       /* 2. Verify MIC except Pairwise Msg1 */
-       if (MsgType != EAPOL_PAIR_MSG_1) {
-               u8 rcvd_mic[LEN_KEY_DESC_MIC];
-
-               /* Record the received MIC for check later */
-               NdisMoveMemory(rcvd_mic, pMsg->KeyDesc.KeyMic,
-                              LEN_KEY_DESC_MIC);
-               NdisZeroMemory(pMsg->KeyDesc.KeyMic, LEN_KEY_DESC_MIC);
-
-               if (EapolKeyInfo.KeyDescVer == DESC_TYPE_TKIP)  /* TKIP */
-               {
-                       HMAC_MD5(pEntry->PTK, LEN_EAP_MICK, (u8 *)pMsg,
-                                MsgLen, mic, MD5_DIGEST_SIZE);
-               } else if (EapolKeyInfo.KeyDescVer == DESC_TYPE_AES)    /* AES */
-               {
-                       HMAC_SHA1(pEntry->PTK, LEN_EAP_MICK, (u8 *)pMsg,
-                                 MsgLen, digest, SHA1_DIGEST_SIZE);
-                       NdisMoveMemory(mic, digest, LEN_KEY_DESC_MIC);
-               }
-
-               if (!NdisEqualMemory(rcvd_mic, mic, LEN_KEY_DESC_MIC)) {
-                       /* send wireless event - for MIC different */
-                       if (pAd->CommonCfg.bWirelessEvent)
-                               RTMPSendWirelessEvent(pAd,
-                                                     IW_MIC_DIFF_EVENT_FLAG,
-                                                     pEntry->Addr,
-                                                     pEntry->apidx, 0);
-
-                       if (MsgType < EAPOL_GROUP_MSG_1) {
-                               DBGPRINT(RT_DEBUG_ERROR,
-                                        ("MIC Different in pairwise msg %d of 4-way handshake!\n",
-                                         MsgType));
-                       } else {
-                               DBGPRINT(RT_DEBUG_ERROR,
-                                        ("MIC Different in group msg %d of 2-way handshake!\n",
-                                         (MsgType - EAPOL_PAIR_MSG_4)));
-                       }
-
-                       hex_dump("Received MIC", rcvd_mic, LEN_KEY_DESC_MIC);
-                       hex_dump("Desired  MIC", mic, LEN_KEY_DESC_MIC);
-
-                       return FALSE;
-               }
-       }
-       /* 1. Decrypt the Key Data field if GTK is included. */
-       /* 2. Extract the context of the Key Data field if it exist. */
-       /* The field in pairwise_msg_2_WPA1(WPA2) & pairwise_msg_3_WPA1 is clear. */
-       /* The field in group_msg_1_WPA1(WPA2) & pairwise_msg_3_WPA2 is encrypted. */
-       if (CONV_ARRARY_TO_u16(pMsg->KeyDesc.KeyDataLen) > 0) {
-               /* Decrypt this field */
-               if ((MsgType == EAPOL_PAIR_MSG_3 && bWPA2)
-                   || (MsgType == EAPOL_GROUP_MSG_1)) {
-                       if ((EapolKeyInfo.KeyDescVer == DESC_TYPE_AES)) {
-                               /* AES */
-                               AES_GTK_KEY_UNWRAP(&pEntry->PTK[16], KEYDATA,
-                                                  CONV_ARRARY_TO_u16(pMsg->
-                                                                        KeyDesc.
-                                                                        KeyDataLen),
-                                                  pMsg->KeyDesc.KeyData);
-                       } else {
-                               int i;
-                               u8 Key[32];
-                               /* Decrypt TKIP GTK */
-                               /* Construct 32 bytes RC4 Key */
-                               NdisMoveMemory(Key, pMsg->KeyDesc.KeyIv, 16);
-                               NdisMoveMemory(&Key[16], &pEntry->PTK[16], 16);
-                               ARCFOUR_INIT(&pAd->PrivateInfo.WEPCONTEXT, Key,
-                                            32);
-                               /*discard first 256 bytes */
-                               for (i = 0; i < 256; i++)
-                                       ARCFOUR_BYTE(&pAd->PrivateInfo.
-                                                    WEPCONTEXT);
-                               /* Decrypt GTK. Becareful, there is no ICV to check the result is correct or not */
-                               ARCFOUR_DECRYPT(&pAd->PrivateInfo.WEPCONTEXT,
-                                               KEYDATA, pMsg->KeyDesc.KeyData,
-                                               CONV_ARRARY_TO_u16(pMsg->
-                                                                     KeyDesc.
-                                                                     KeyDataLen));
-                       }
-
-                       if (!bWPA2 && (MsgType == EAPOL_GROUP_MSG_1))
-                               GroupKeyIndex = EapolKeyInfo.KeyIndex;
-
-               } else if ((MsgType == EAPOL_PAIR_MSG_2)
-                          || (MsgType == EAPOL_PAIR_MSG_3 && !bWPA2)) {
-                       NdisMoveMemory(KEYDATA, pMsg->KeyDesc.KeyData,
-                                      CONV_ARRARY_TO_u16(pMsg->KeyDesc.
-                                                            KeyDataLen));
-               } else {
-
-                       return TRUE;
-               }
-
-               /* Parse Key Data field to */
-               /* 1. verify RSN IE for pairwise_msg_2_WPA1(WPA2) ,pairwise_msg_3_WPA1(WPA2) */
-               /* 2. verify KDE format for pairwise_msg_3_WPA2, group_msg_1_WPA2 */
-               /* 3. update shared key for pairwise_msg_3_WPA2, group_msg_1_WPA1(WPA2) */
-               if (!RTMPParseEapolKeyData(pAd, KEYDATA,
-                                          CONV_ARRARY_TO_u16(pMsg->KeyDesc.
-                                                                KeyDataLen),
-                                          GroupKeyIndex, MsgType, bWPA2,
-                                          pEntry)) {
-                       return FALSE;
-               }
-       }
-
-       return TRUE;
-
-}
diff --git a/drivers/staging/rt2860/common/cmm_sync.c b/drivers/staging/rt2860/common/cmm_sync.c
deleted file mode 100644 (file)
index aefe1b7..0000000
+++ /dev/null
@@ -1,718 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-       Module Name:
-       cmm_sync.c
-
-       Abstract:
-
-       Revision History:
-       Who                     When                    What
-       --------        ----------              ----------------------------------------------
-       John Chang      2004-09-01      modified for rt2561/2661
-*/
-#include "../rt_config.h"
-
-/* 2.4 Ghz channel plan index in the TxPower arrays. */
-#define        BG_BAND_REGION_0_START  0       /* 1,2,3,4,5,6,7,8,9,10,11 */
-#define        BG_BAND_REGION_0_SIZE   11
-#define        BG_BAND_REGION_1_START  0       /* 1,2,3,4,5,6,7,8,9,10,11,12,13 */
-#define        BG_BAND_REGION_1_SIZE   13
-#define        BG_BAND_REGION_2_START  9       /* 10,11 */
-#define        BG_BAND_REGION_2_SIZE   2
-#define        BG_BAND_REGION_3_START  9       /* 10,11,12,13 */
-#define        BG_BAND_REGION_3_SIZE   4
-#define        BG_BAND_REGION_4_START  13      /* 14 */
-#define        BG_BAND_REGION_4_SIZE   1
-#define        BG_BAND_REGION_5_START  0       /* 1,2,3,4,5,6,7,8,9,10,11,12,13,14 */
-#define        BG_BAND_REGION_5_SIZE   14
-#define        BG_BAND_REGION_6_START  2       /* 3,4,5,6,7,8,9 */
-#define        BG_BAND_REGION_6_SIZE   7
-#define        BG_BAND_REGION_7_START  4       /* 5,6,7,8,9,10,11,12,13 */
-#define        BG_BAND_REGION_7_SIZE   9
-#define        BG_BAND_REGION_31_START 0       /* 1,2,3,4,5,6,7,8,9,10,11,12,13,14 */
-#define        BG_BAND_REGION_31_SIZE  14
-
-/* 5 Ghz channel plan index in the TxPower arrays. */
-u8 A_BAND_REGION_0_CHANNEL_LIST[] =
-    { 36, 40, 44, 48, 52, 56, 60, 64, 149, 153, 157, 161, 165 };
-u8 A_BAND_REGION_1_CHANNEL_LIST[] =
-    { 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128,
-132, 136, 140 };
-u8 A_BAND_REGION_2_CHANNEL_LIST[] = { 36, 40, 44, 48, 52, 56, 60, 64 };
-u8 A_BAND_REGION_3_CHANNEL_LIST[] = { 52, 56, 60, 64, 149, 153, 157, 161 };
-u8 A_BAND_REGION_4_CHANNEL_LIST[] = { 149, 153, 157, 161, 165 };
-u8 A_BAND_REGION_5_CHANNEL_LIST[] = { 149, 153, 157, 161 };
-u8 A_BAND_REGION_6_CHANNEL_LIST[] = { 36, 40, 44, 48 };
-u8 A_BAND_REGION_7_CHANNEL_LIST[] =
-    { 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128,
-132, 136, 140, 149, 153, 157, 161, 165, 169, 173 };
-u8 A_BAND_REGION_8_CHANNEL_LIST[] = { 52, 56, 60, 64 };
-u8 A_BAND_REGION_9_CHANNEL_LIST[] =
-    { 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140,
-149, 153, 157, 161, 165 };
-u8 A_BAND_REGION_10_CHANNEL_LIST[] =
-    { 36, 40, 44, 48, 149, 153, 157, 161, 165 };
-u8 A_BAND_REGION_11_CHANNEL_LIST[] =
-    { 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 149, 153,
-157, 161 };
-u8 A_BAND_REGION_12_CHANNEL_LIST[] =
-    { 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128,
-132, 136, 140 };
-u8 A_BAND_REGION_13_CHANNEL_LIST[] =
-    { 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140,
-149, 153, 157, 161 };
-u8 A_BAND_REGION_14_CHANNEL_LIST[] =
-    { 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 136, 140, 149,
-153, 157, 161, 165 };
-u8 A_BAND_REGION_15_CHANNEL_LIST[] = { 149, 153, 157, 161, 165, 169, 173 };
-
-/*BaSizeArray follows the 802.11n definition as MaxRxFactor.  2^(13+factor) bytes. When factor =0, it's about Ba buffer size =8. */
-u8 BaSizeArray[4] = { 8, 16, 32, 64 };
-
-/*
-       ==========================================================================
-       Description:
-               Update StaCfg->ChannelList[] according to 1) Country Region 2) RF IC type,
-               and 3) PHY-mode user selected.
-               The outcome is used by driver when doing site survey.
-
-       IRQL = PASSIVE_LEVEL
-       IRQL = DISPATCH_LEVEL
-
-       ==========================================================================
- */
-void BuildChannelList(struct rt_rtmp_adapter *pAd)
-{
-       u8 i, j, index = 0, num = 0;
-       u8 *pChannelList = NULL;
-
-       NdisZeroMemory(pAd->ChannelList,
-                      MAX_NUM_OF_CHANNELS * sizeof(struct rt_channel_tx_power));
-
-       /* if not 11a-only mode, channel list starts from 2.4Ghz band */
-       if ((pAd->CommonCfg.PhyMode != PHY_11A)
-           && (pAd->CommonCfg.PhyMode != PHY_11AN_MIXED)
-           && (pAd->CommonCfg.PhyMode != PHY_11N_5G)
-           ) {
-               switch (pAd->CommonCfg.CountryRegion & 0x7f) {
-               case REGION_0_BG_BAND:  /* 1 -11 */
-                       NdisMoveMemory(&pAd->ChannelList[index],
-                                      &pAd->TxPower[BG_BAND_REGION_0_START],
-                                      sizeof(struct rt_channel_tx_power) *
-                                      BG_BAND_REGION_0_SIZE);
-                       index += BG_BAND_REGION_0_SIZE;
-                       break;
-               case REGION_1_BG_BAND:  /* 1 - 13 */
-                       NdisMoveMemory(&pAd->ChannelList[index],
-                                      &pAd->TxPower[BG_BAND_REGION_1_START],
-                                      sizeof(struct rt_channel_tx_power) *
-                                      BG_BAND_REGION_1_SIZE);
-                       index += BG_BAND_REGION_1_SIZE;
-                       break;
-               case REGION_2_BG_BAND:  /* 10 - 11 */
-                       NdisMoveMemory(&pAd->ChannelList[index],
-                                      &pAd->TxPower[BG_BAND_REGION_2_START],
-                                      sizeof(struct rt_channel_tx_power) *
-                                      BG_BAND_REGION_2_SIZE);
-                       index += BG_BAND_REGION_2_SIZE;
-                       break;
-               case REGION_3_BG_BAND:  /* 10 - 13 */
-                       NdisMoveMemory(&pAd->ChannelList[index],
-                                      &pAd->TxPower[BG_BAND_REGION_3_START],
-                                      sizeof(struct rt_channel_tx_power) *
-                                      BG_BAND_REGION_3_SIZE);
-                       index += BG_BAND_REGION_3_SIZE;
-                       break;
-               case REGION_4_BG_BAND:  /* 14 */
-                       NdisMoveMemory(&pAd->ChannelList[index],
-                                      &pAd->TxPower[BG_BAND_REGION_4_START],
-                                      sizeof(struct rt_channel_tx_power) *
-                                      BG_BAND_REGION_4_SIZE);
-                       index += BG_BAND_REGION_4_SIZE;
-                       break;
-               case REGION_5_BG_BAND:  /* 1 - 14 */
-                       NdisMoveMemory(&pAd->ChannelList[index],
-                                      &pAd->TxPower[BG_BAND_REGION_5_START],
-                                      sizeof(struct rt_channel_tx_power) *
-                                      BG_BAND_REGION_5_SIZE);
-                       index += BG_BAND_REGION_5_SIZE;
-                       break;
-               case REGION_6_BG_BAND:  /* 3 - 9 */
-                       NdisMoveMemory(&pAd->ChannelList[index],
-                                      &pAd->TxPower[BG_BAND_REGION_6_START],
-                                      sizeof(struct rt_channel_tx_power) *
-                                      BG_BAND_REGION_6_SIZE);
-                       index += BG_BAND_REGION_6_SIZE;
-                       break;
-               case REGION_7_BG_BAND:  /* 5 - 13 */
-                       NdisMoveMemory(&pAd->ChannelList[index],
-                                      &pAd->TxPower[BG_BAND_REGION_7_START],
-                                      sizeof(struct rt_channel_tx_power) *
-                                      BG_BAND_REGION_7_SIZE);
-                       index += BG_BAND_REGION_7_SIZE;
-                       break;
-               case REGION_31_BG_BAND: /* 1 - 14 */
-                       NdisMoveMemory(&pAd->ChannelList[index],
-                                      &pAd->TxPower[BG_BAND_REGION_31_START],
-                                      sizeof(struct rt_channel_tx_power) *
-                                      BG_BAND_REGION_31_SIZE);
-                       index += BG_BAND_REGION_31_SIZE;
-                       break;
-               default:        /* Error. should never happen */
-                       break;
-               }
-               for (i = 0; i < index; i++)
-                       pAd->ChannelList[i].MaxTxPwr = 20;
-       }
-
-       if ((pAd->CommonCfg.PhyMode == PHY_11A)
-           || (pAd->CommonCfg.PhyMode == PHY_11ABG_MIXED)
-           || (pAd->CommonCfg.PhyMode == PHY_11ABGN_MIXED)
-           || (pAd->CommonCfg.PhyMode == PHY_11AN_MIXED)
-           || (pAd->CommonCfg.PhyMode == PHY_11AGN_MIXED)
-           || (pAd->CommonCfg.PhyMode == PHY_11N_5G)
-           ) {
-               switch (pAd->CommonCfg.CountryRegionForABand & 0x7f) {
-               case REGION_0_A_BAND:
-                       num =
-                           sizeof(A_BAND_REGION_0_CHANNEL_LIST) /
-                           sizeof(u8);
-                       pChannelList = A_BAND_REGION_0_CHANNEL_LIST;
-                       break;
-               case REGION_1_A_BAND:
-                       num =
-                           sizeof(A_BAND_REGION_1_CHANNEL_LIST) /
-                           sizeof(u8);
-                       pChannelList = A_BAND_REGION_1_CHANNEL_LIST;
-                       break;
-               case REGION_2_A_BAND:
-                       num =
-                           sizeof(A_BAND_REGION_2_CHANNEL_LIST) /
-                           sizeof(u8);
-                       pChannelList = A_BAND_REGION_2_CHANNEL_LIST;
-                       break;
-               case REGION_3_A_BAND:
-                       num =
-                           sizeof(A_BAND_REGION_3_CHANNEL_LIST) /
-                           sizeof(u8);
-                       pChannelList = A_BAND_REGION_3_CHANNEL_LIST;
-                       break;
-               case REGION_4_A_BAND:
-                       num =
-                           sizeof(A_BAND_REGION_4_CHANNEL_LIST) /
-                           sizeof(u8);
-                       pChannelList = A_BAND_REGION_4_CHANNEL_LIST;
-                       break;
-               case REGION_5_A_BAND:
-                       num =
-                           sizeof(A_BAND_REGION_5_CHANNEL_LIST) /
-                           sizeof(u8);
-                       pChannelList = A_BAND_REGION_5_CHANNEL_LIST;
-                       break;
-               case REGION_6_A_BAND:
-                       num =
-                           sizeof(A_BAND_REGION_6_CHANNEL_LIST) /
-                           sizeof(u8);
-                       pChannelList = A_BAND_REGION_6_CHANNEL_LIST;
-                       break;
-               case REGION_7_A_BAND:
-                       num =
-                           sizeof(A_BAND_REGION_7_CHANNEL_LIST) /
-                           sizeof(u8);
-                       pChannelList = A_BAND_REGION_7_CHANNEL_LIST;
-                       break;
-               case REGION_8_A_BAND:
-                       num =
-                           sizeof(A_BAND_REGION_8_CHANNEL_LIST) /
-                           sizeof(u8);
-                       pChannelList = A_BAND_REGION_8_CHANNEL_LIST;
-                       break;
-               case REGION_9_A_BAND:
-                       num =
-                           sizeof(A_BAND_REGION_9_CHANNEL_LIST) /
-                           sizeof(u8);
-                       pChannelList = A_BAND_REGION_9_CHANNEL_LIST;
-                       break;
-
-               case REGION_10_A_BAND:
-                       num =
-                           sizeof(A_BAND_REGION_10_CHANNEL_LIST) /
-                           sizeof(u8);
-                       pChannelList = A_BAND_REGION_10_CHANNEL_LIST;
-                       break;
-
-               case REGION_11_A_BAND:
-                       num =
-                           sizeof(A_BAND_REGION_11_CHANNEL_LIST) /
-                           sizeof(u8);
-                       pChannelList = A_BAND_REGION_11_CHANNEL_LIST;
-                       break;
-               case REGION_12_A_BAND:
-                       num =
-                           sizeof(A_BAND_REGION_12_CHANNEL_LIST) /
-                           sizeof(u8);
-                       pChannelList = A_BAND_REGION_12_CHANNEL_LIST;
-                       break;
-               case REGION_13_A_BAND:
-                       num =
-                           sizeof(A_BAND_REGION_13_CHANNEL_LIST) /
-                           sizeof(u8);
-                       pChannelList = A_BAND_REGION_13_CHANNEL_LIST;
-                       break;
-               case REGION_14_A_BAND:
-                       num =
-                           sizeof(A_BAND_REGION_14_CHANNEL_LIST) /
-                           sizeof(u8);
-                       pChannelList = A_BAND_REGION_14_CHANNEL_LIST;
-                       break;
-               case REGION_15_A_BAND:
-                       num =
-                           sizeof(A_BAND_REGION_15_CHANNEL_LIST) /
-                           sizeof(u8);
-                       pChannelList = A_BAND_REGION_15_CHANNEL_LIST;
-                       break;
-               default:        /* Error. should never happen */
-                       DBGPRINT(RT_DEBUG_WARN,
-                                ("countryregion=%d not support",
-                                 pAd->CommonCfg.CountryRegionForABand));
-                       break;
-               }
-
-               if (num != 0) {
-                       u8 RadarCh[15] =
-                           { 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124,
-                   128, 132, 136, 140 };
-                       for (i = 0; i < num; i++) {
-                               for (j = 0; j < MAX_NUM_OF_CHANNELS; j++) {
-                                       if (pChannelList[i] ==
-                                           pAd->TxPower[j].Channel)
-                                               NdisMoveMemory(&pAd->
-                                                              ChannelList[index
-                                                                          + i],
-                                                              &pAd->TxPower[j],
-                                                              sizeof
-                                                              (struct rt_channel_tx_power));
-                               }
-                               for (j = 0; j < 15; j++) {
-                                       if (pChannelList[i] == RadarCh[j])
-                                               pAd->ChannelList[index +
-                                                                i].DfsReq =
-                                                   TRUE;
-                               }
-                               pAd->ChannelList[index + i].MaxTxPwr = 20;
-                       }
-                       index += num;
-               }
-       }
-
-       pAd->ChannelListNum = index;
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("country code=%d/%d, RFIC=%d, PHY mode=%d, support %d channels\n",
-                 pAd->CommonCfg.CountryRegion,
-                 pAd->CommonCfg.CountryRegionForABand, pAd->RfIcType,
-                 pAd->CommonCfg.PhyMode, pAd->ChannelListNum));
-#ifdef DBG
-       for (i = 0; i < pAd->ChannelListNum; i++) {
-               DBGPRINT_RAW(RT_DEBUG_TRACE,
-                            ("BuildChannel # %d :: Pwr0 = %d, Pwr1 =%d, \n ",
-                             pAd->ChannelList[i].Channel,
-                             pAd->ChannelList[i].Power,
-                             pAd->ChannelList[i].Power2));
-       }
-#endif
-}
-
-/*
-       ==========================================================================
-       Description:
-               This routine return the first channel number according to the country
-               code selection and RF IC selection (signal band or dual band). It is called
-               whenever driver need to start a site survey of all supported channels.
-       Return:
-               ch - the first channel number of current country code setting
-
-       IRQL = PASSIVE_LEVEL
-
-       ==========================================================================
- */
-u8 FirstChannel(struct rt_rtmp_adapter *pAd)
-{
-       return pAd->ChannelList[0].Channel;
-}
-
-/*
-       ==========================================================================
-       Description:
-               This routine returns the next channel number. This routine is called
-               during driver need to start a site survey of all supported channels.
-       Return:
-               next_channel - the next channel number valid in current country code setting.
-       Note:
-               return 0 if no more next channel
-       ==========================================================================
- */
-u8 NextChannel(struct rt_rtmp_adapter *pAd, u8 channel)
-{
-       int i;
-       u8 next_channel = 0;
-
-       for (i = 0; i < (pAd->ChannelListNum - 1); i++)
-               if (channel == pAd->ChannelList[i].Channel) {
-                       next_channel = pAd->ChannelList[i + 1].Channel;
-                       break;
-               }
-       return next_channel;
-}
-
-/*
-       ==========================================================================
-       Description:
-               This routine is for Cisco Compatible Extensions 2.X
-               Spec31. AP Control of Client Transmit Power
-       Return:
-               None
-       Note:
-          Required by Aironet dBm(mW)
-                  0dBm(1mW),   1dBm(5mW), 13dBm(20mW), 15dBm(30mW),
-                 17dBm(50mw), 20dBm(100mW)
-
-          We supported
-                  3dBm(Lowest), 6dBm(10%), 9dBm(25%), 12dBm(50%),
-                 14dBm(75%),   15dBm(100%)
-
-               The client station's actual transmit power shall be within +/- 5dB of
-               the minimum value or next lower value.
-       ==========================================================================
- */
-void ChangeToCellPowerLimit(struct rt_rtmp_adapter *pAd,
-                           u8 AironetCellPowerLimit)
-{
-       /*valud 0xFF means that hasn't found power limit information */
-       /*from the AP's Beacon/Probe response. */
-       if (AironetCellPowerLimit == 0xFF)
-               return;
-
-       if (AironetCellPowerLimit < 6)  /*Used Lowest Power Percentage. */
-               pAd->CommonCfg.TxPowerPercentage = 6;
-       else if (AironetCellPowerLimit < 9)
-               pAd->CommonCfg.TxPowerPercentage = 10;
-       else if (AironetCellPowerLimit < 12)
-               pAd->CommonCfg.TxPowerPercentage = 25;
-       else if (AironetCellPowerLimit < 14)
-               pAd->CommonCfg.TxPowerPercentage = 50;
-       else if (AironetCellPowerLimit < 15)
-               pAd->CommonCfg.TxPowerPercentage = 75;
-       else
-               pAd->CommonCfg.TxPowerPercentage = 100; /*else used maximum */
-
-       if (pAd->CommonCfg.TxPowerPercentage > pAd->CommonCfg.TxPowerDefault)
-               pAd->CommonCfg.TxPowerPercentage =
-                   pAd->CommonCfg.TxPowerDefault;
-
-}
-
-char ConvertToRssi(struct rt_rtmp_adapter *pAd, char Rssi, u8 RssiNumber)
-{
-       u8 RssiOffset, LNAGain;
-
-       /* Rssi equals to zero should be an invalid value */
-       if (Rssi == 0)
-               return -99;
-
-       LNAGain = GET_LNA_GAIN(pAd);
-       if (pAd->LatchRfRegs.Channel > 14) {
-               if (RssiNumber == 0)
-                       RssiOffset = pAd->ARssiOffset0;
-               else if (RssiNumber == 1)
-                       RssiOffset = pAd->ARssiOffset1;
-               else
-                       RssiOffset = pAd->ARssiOffset2;
-       } else {
-               if (RssiNumber == 0)
-                       RssiOffset = pAd->BGRssiOffset0;
-               else if (RssiNumber == 1)
-                       RssiOffset = pAd->BGRssiOffset1;
-               else
-                       RssiOffset = pAd->BGRssiOffset2;
-       }
-
-       return (-12 - RssiOffset - LNAGain - Rssi);
-}
-
-/*
-       ==========================================================================
-       Description:
-               Scan next channel
-       ==========================================================================
- */
-void ScanNextChannel(struct rt_rtmp_adapter *pAd)
-{
-       struct rt_header_802_11 Hdr80211;
-       u8 *pOutBuffer = NULL;
-       int NStatus;
-       unsigned long FrameLen = 0;
-       u8 SsidLen = 0, ScanType = pAd->MlmeAux.ScanType, BBPValue = 0;
-       u16 Status;
-       struct rt_header_802_11 * pHdr80211;
-       u32 ScanTimeIn5gChannel = SHORT_CHANNEL_TIME;
-
-       {
-               if (MONITOR_ON(pAd))
-                       return;
-       }
-
-       if (pAd->MlmeAux.Channel == 0) {
-               if ((pAd->CommonCfg.BBPCurrentBW == BW_40)
-                   && (INFRA_ON(pAd)
-                       || (pAd->OpMode == OPMODE_AP))
-                   ) {
-                       AsicSwitchChannel(pAd, pAd->CommonCfg.CentralChannel,
-                                         FALSE);
-                       AsicLockChannel(pAd, pAd->CommonCfg.CentralChannel);
-                       RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue);
-                       BBPValue &= (~0x18);
-                       BBPValue |= 0x10;
-                       RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue);
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("SYNC - End of SCAN, restore to 40MHz channel %d, Total BSS[%02d]\n",
-                                 pAd->CommonCfg.CentralChannel,
-                                 pAd->ScanTab.BssNr));
-               } else {
-                       AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE);
-                       AsicLockChannel(pAd, pAd->CommonCfg.Channel);
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("SYNC - End of SCAN, restore to channel %d, Total BSS[%02d]\n",
-                                 pAd->CommonCfg.Channel, pAd->ScanTab.BssNr));
-               }
-
-               {
-                       /* */
-                       /* To prevent data lost. */
-                       /* Send an NULL data with turned PSM bit on to current associated AP before SCAN progress. */
-                       /* Now, we need to send an NULL data with turned PSM bit off to AP, when scan progress done */
-                       /* */
-                       if (OPSTATUS_TEST_FLAG
-                           (pAd, fOP_STATUS_MEDIA_STATE_CONNECTED)
-                           && (INFRA_ON(pAd))) {
-                               NStatus =
-                                   MlmeAllocateMemory(pAd,
-                                                      (void *)& pOutBuffer);
-                               if (NStatus == NDIS_STATUS_SUCCESS) {
-                                       pHdr80211 = (struct rt_header_802_11 *) pOutBuffer;
-                                       MgtMacHeaderInit(pAd, pHdr80211,
-                                                        SUBTYPE_NULL_FUNC, 1,
-                                                        pAd->CommonCfg.Bssid,
-                                                        pAd->CommonCfg.Bssid);
-                                       pHdr80211->Duration = 0;
-                                       pHdr80211->FC.Type = BTYPE_DATA;
-                                       pHdr80211->FC.PwrMgmt =
-                                           (pAd->StaCfg.Psm == PWR_SAVE);
-
-                                       /* Send using priority queue */
-                                       MiniportMMRequest(pAd, 0, pOutBuffer,
-                                                         sizeof
-                                                         (struct rt_header_802_11));
-                                       DBGPRINT(RT_DEBUG_TRACE,
-                                                ("MlmeScanReqAction -- Send PSM Data frame\n"));
-                                       MlmeFreeMemory(pAd, pOutBuffer);
-                                       RTMPusecDelay(5000);
-                               }
-                       }
-
-                       pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
-                       Status = MLME_SUCCESS;
-                       MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_SCAN_CONF,
-                                   2, &Status);
-               }
-
-               RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS);
-       }
-#ifdef RTMP_MAC_USB
-       else if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)
-                && (pAd->OpMode == OPMODE_STA)) {
-               pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
-               MlmeCntlConfirm(pAd, MT2_SCAN_CONF, MLME_FAIL_NO_RESOURCE);
-       }
-#endif /* RTMP_MAC_USB // */
-       else {
-               {
-                       /* BBP and RF are not accessible in PS mode, we has to wake them up first */
-                       if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))
-                               AsicForceWakeup(pAd, TRUE);
-
-                       /* leave PSM during scanning. otherwise we may lost ProbeRsp & BEACON */
-                       if (pAd->StaCfg.Psm == PWR_SAVE)
-                               RTMP_SET_PSM_BIT(pAd, PWR_ACTIVE);
-               }
-
-               AsicSwitchChannel(pAd, pAd->MlmeAux.Channel, TRUE);
-               AsicLockChannel(pAd, pAd->MlmeAux.Channel);
-
-               {
-                       if (pAd->MlmeAux.Channel > 14) {
-                               if ((pAd->CommonCfg.bIEEE80211H == 1)
-                                   && RadarChannelCheck(pAd,
-                                                        pAd->MlmeAux.
-                                                        Channel)) {
-                                       ScanType = SCAN_PASSIVE;
-                                       ScanTimeIn5gChannel = MIN_CHANNEL_TIME;
-                               }
-                       }
-               }
-
-               /*Global country domain(ch1-11:active scan, ch12-14 passive scan) */
-               if ((pAd->MlmeAux.Channel <= 14) && (pAd->MlmeAux.Channel >= 12)
-                   && ((pAd->CommonCfg.CountryRegion & 0x7f) ==
-                       REGION_31_BG_BAND)) {
-                       ScanType = SCAN_PASSIVE;
-               }
-               /* We need to shorten active scan time in order for WZC connect issue */
-               /* Chnage the channel scan time for CISCO stuff based on its IAPP announcement */
-               if (ScanType == FAST_SCAN_ACTIVE)
-                       RTMPSetTimer(&pAd->MlmeAux.ScanTimer,
-                                    FAST_ACTIVE_SCAN_TIME);
-               else            /* must be SCAN_PASSIVE or SCAN_ACTIVE */
-               {
-                       if ((pAd->CommonCfg.PhyMode == PHY_11ABG_MIXED)
-                           || (pAd->CommonCfg.PhyMode == PHY_11ABGN_MIXED)
-                           || (pAd->CommonCfg.PhyMode == PHY_11AGN_MIXED)
-                           ) {
-                               if (pAd->MlmeAux.Channel > 14)
-                                       RTMPSetTimer(&pAd->MlmeAux.ScanTimer,
-                                                    ScanTimeIn5gChannel);
-                               else
-                                       RTMPSetTimer(&pAd->MlmeAux.ScanTimer,
-                                                    MIN_CHANNEL_TIME);
-                       } else
-                               RTMPSetTimer(&pAd->MlmeAux.ScanTimer,
-                                            MAX_CHANNEL_TIME);
-               }
-
-               if ((ScanType == SCAN_ACTIVE)
-                   || (ScanType == FAST_SCAN_ACTIVE)
-                   ) {
-                       NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); /*Get an unused nonpaged memory */
-                       if (NStatus != NDIS_STATUS_SUCCESS) {
-                               DBGPRINT(RT_DEBUG_TRACE,
-                                        ("SYNC - ScanNextChannel() allocate memory fail\n"));
-
-                               {
-                                       pAd->Mlme.SyncMachine.CurrState =
-                                           SYNC_IDLE;
-                                       Status = MLME_FAIL_NO_RESOURCE;
-                                       MlmeEnqueue(pAd,
-                                                   MLME_CNTL_STATE_MACHINE,
-                                                   MT2_SCAN_CONF, 2, &Status);
-                               }
-
-                               return;
-                       }
-                       /* There is no need to send broadcast probe request if active scan is in effect. */
-                       if ((ScanType == SCAN_ACTIVE)
-                           || (ScanType == FAST_SCAN_ACTIVE)
-                           )
-                               SsidLen = pAd->MlmeAux.SsidLen;
-                       else
-                               SsidLen = 0;
-
-                       MgtMacHeaderInit(pAd, &Hdr80211, SUBTYPE_PROBE_REQ, 0,
-                                        BROADCAST_ADDR, BROADCAST_ADDR);
-                       MakeOutgoingFrame(pOutBuffer, &FrameLen,
-                                         sizeof(struct rt_header_802_11), &Hdr80211, 1,
-                                         &SsidIe, 1, &SsidLen, SsidLen,
-                                         pAd->MlmeAux.Ssid, 1, &SupRateIe, 1,
-                                         &pAd->CommonCfg.SupRateLen,
-                                         pAd->CommonCfg.SupRateLen,
-                                         pAd->CommonCfg.SupRate, END_OF_ARGS);
-
-                       if (pAd->CommonCfg.ExtRateLen) {
-                               unsigned long Tmp;
-                               MakeOutgoingFrame(pOutBuffer + FrameLen, &Tmp,
-                                                 1, &ExtRateIe,
-                                                 1, &pAd->CommonCfg.ExtRateLen,
-                                                 pAd->CommonCfg.ExtRateLen,
-                                                 pAd->CommonCfg.ExtRate,
-                                                 END_OF_ARGS);
-                               FrameLen += Tmp;
-                       }
-
-                       if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED) {
-                               unsigned long Tmp;
-                               u8 HtLen;
-                               u8 BROADCOM[4] = { 0x0, 0x90, 0x4c, 0x33 };
-
-                               if (pAd->bBroadComHT == TRUE) {
-                                       HtLen =
-                                           pAd->MlmeAux.HtCapabilityLen + 4;
-
-                                       MakeOutgoingFrame(pOutBuffer + FrameLen,
-                                                         &Tmp, 1, &WpaIe, 1,
-                                                         &HtLen, 4,
-                                                         &BROADCOM[0],
-                                                         pAd->MlmeAux.
-                                                         HtCapabilityLen,
-                                                         &pAd->MlmeAux.
-                                                         HtCapability,
-                                                         END_OF_ARGS);
-                               } else {
-                                       HtLen = pAd->MlmeAux.HtCapabilityLen;
-
-                                       MakeOutgoingFrame(pOutBuffer + FrameLen,
-                                                         &Tmp, 1, &HtCapIe, 1,
-                                                         &HtLen, HtLen,
-                                                         &pAd->CommonCfg.
-                                                         HtCapability,
-                                                         END_OF_ARGS);
-                               }
-                               FrameLen += Tmp;
-                       }
-
-                       MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
-                       MlmeFreeMemory(pAd, pOutBuffer);
-               }
-               /* For SCAN_CISCO_PASSIVE, do nothing and silently wait for beacon or other probe response */
-
-               pAd->Mlme.SyncMachine.CurrState = SCAN_LISTEN;
-       }
-}
-
-void MgtProbReqMacHeaderInit(struct rt_rtmp_adapter *pAd,
-                            struct rt_header_802_11 * pHdr80211,
-                            u8 SubType,
-                            u8 ToDs, u8 *pDA, u8 *pBssid)
-{
-       NdisZeroMemory(pHdr80211, sizeof(struct rt_header_802_11));
-
-       pHdr80211->FC.Type = BTYPE_MGMT;
-       pHdr80211->FC.SubType = SubType;
-       if (SubType == SUBTYPE_ACK)
-               pHdr80211->FC.Type = BTYPE_CNTL;
-       pHdr80211->FC.ToDs = ToDs;
-       COPY_MAC_ADDR(pHdr80211->Addr1, pDA);
-       COPY_MAC_ADDR(pHdr80211->Addr2, pAd->CurrentAddress);
-       COPY_MAC_ADDR(pHdr80211->Addr3, pBssid);
-}
diff --git a/drivers/staging/rt2860/common/cmm_tkip.c b/drivers/staging/rt2860/common/cmm_tkip.c
deleted file mode 100644 (file)
index 4881ef9..0000000
+++ /dev/null
@@ -1,833 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-       Module Name:
-       cmm_tkip.c
-
-       Abstract:
-
-       Revision History:
-       Who                     When                    What
-       --------        ----------              ----------------------------------------------
-       Paul Wu         02-25-02                Initial
-*/
-
-#include       "../rt_config.h"
-
-/* Rotation functions on 32 bit values */
-#define ROL32( A, n ) \
-       ( ((A) << (n)) | ( ((A)>>(32-(n))) & ( (1UL << (n)) - 1 ) ) )
-#define ROR32( A, n ) ROL32( (A), 32-(n) )
-
-u32 Tkip_Sbox_Lower[256] = {
-       0xA5, 0x84, 0x99, 0x8D, 0x0D, 0xBD, 0xB1, 0x54,
-       0x50, 0x03, 0xA9, 0x7D, 0x19, 0x62, 0xE6, 0x9A,
-       0x45, 0x9D, 0x40, 0x87, 0x15, 0xEB, 0xC9, 0x0B,
-       0xEC, 0x67, 0xFD, 0xEA, 0xBF, 0xF7, 0x96, 0x5B,
-       0xC2, 0x1C, 0xAE, 0x6A, 0x5A, 0x41, 0x02, 0x4F,
-       0x5C, 0xF4, 0x34, 0x08, 0x93, 0x73, 0x53, 0x3F,
-       0x0C, 0x52, 0x65, 0x5E, 0x28, 0xA1, 0x0F, 0xB5,
-       0x09, 0x36, 0x9B, 0x3D, 0x26, 0x69, 0xCD, 0x9F,
-       0x1B, 0x9E, 0x74, 0x2E, 0x2D, 0xB2, 0xEE, 0xFB,
-       0xF6, 0x4D, 0x61, 0xCE, 0x7B, 0x3E, 0x71, 0x97,
-       0xF5, 0x68, 0x00, 0x2C, 0x60, 0x1F, 0xC8, 0xED,
-       0xBE, 0x46, 0xD9, 0x4B, 0xDE, 0xD4, 0xE8, 0x4A,
-       0x6B, 0x2A, 0xE5, 0x16, 0xC5, 0xD7, 0x55, 0x94,
-       0xCF, 0x10, 0x06, 0x81, 0xF0, 0x44, 0xBA, 0xE3,
-       0xF3, 0xFE, 0xC0, 0x8A, 0xAD, 0xBC, 0x48, 0x04,
-       0xDF, 0xC1, 0x75, 0x63, 0x30, 0x1A, 0x0E, 0x6D,
-       0x4C, 0x14, 0x35, 0x2F, 0xE1, 0xA2, 0xCC, 0x39,
-       0x57, 0xF2, 0x82, 0x47, 0xAC, 0xE7, 0x2B, 0x95,
-       0xA0, 0x98, 0xD1, 0x7F, 0x66, 0x7E, 0xAB, 0x83,
-       0xCA, 0x29, 0xD3, 0x3C, 0x79, 0xE2, 0x1D, 0x76,
-       0x3B, 0x56, 0x4E, 0x1E, 0xDB, 0x0A, 0x6C, 0xE4,
-       0x5D, 0x6E, 0xEF, 0xA6, 0xA8, 0xA4, 0x37, 0x8B,
-       0x32, 0x43, 0x59, 0xB7, 0x8C, 0x64, 0xD2, 0xE0,
-       0xB4, 0xFA, 0x07, 0x25, 0xAF, 0x8E, 0xE9, 0x18,
-       0xD5, 0x88, 0x6F, 0x72, 0x24, 0xF1, 0xC7, 0x51,
-       0x23, 0x7C, 0x9C, 0x21, 0xDD, 0xDC, 0x86, 0x85,
-       0x90, 0x42, 0xC4, 0xAA, 0xD8, 0x05, 0x01, 0x12,
-       0xA3, 0x5F, 0xF9, 0xD0, 0x91, 0x58, 0x27, 0xB9,
-       0x38, 0x13, 0xB3, 0x33, 0xBB, 0x70, 0x89, 0xA7,
-       0xB6, 0x22, 0x92, 0x20, 0x49, 0xFF, 0x78, 0x7A,
-       0x8F, 0xF8, 0x80, 0x17, 0xDA, 0x31, 0xC6, 0xB8,
-       0xC3, 0xB0, 0x77, 0x11, 0xCB, 0xFC, 0xD6, 0x3A
-};
-
-u32 Tkip_Sbox_Upper[256] = {
-       0xC6, 0xF8, 0xEE, 0xF6, 0xFF, 0xD6, 0xDE, 0x91,
-       0x60, 0x02, 0xCE, 0x56, 0xE7, 0xB5, 0x4D, 0xEC,
-       0x8F, 0x1F, 0x89, 0xFA, 0xEF, 0xB2, 0x8E, 0xFB,
-       0x41, 0xB3, 0x5F, 0x45, 0x23, 0x53, 0xE4, 0x9B,
-       0x75, 0xE1, 0x3D, 0x4C, 0x6C, 0x7E, 0xF5, 0x83,
-       0x68, 0x51, 0xD1, 0xF9, 0xE2, 0xAB, 0x62, 0x2A,
-       0x08, 0x95, 0x46, 0x9D, 0x30, 0x37, 0x0A, 0x2F,
-       0x0E, 0x24, 0x1B, 0xDF, 0xCD, 0x4E, 0x7F, 0xEA,
-       0x12, 0x1D, 0x58, 0x34, 0x36, 0xDC, 0xB4, 0x5B,
-       0xA4, 0x76, 0xB7, 0x7D, 0x52, 0xDD, 0x5E, 0x13,
-       0xA6, 0xB9, 0x00, 0xC1, 0x40, 0xE3, 0x79, 0xB6,
-       0xD4, 0x8D, 0x67, 0x72, 0x94, 0x98, 0xB0, 0x85,
-       0xBB, 0xC5, 0x4F, 0xED, 0x86, 0x9A, 0x66, 0x11,
-       0x8A, 0xE9, 0x04, 0xFE, 0xA0, 0x78, 0x25, 0x4B,
-       0xA2, 0x5D, 0x80, 0x05, 0x3F, 0x21, 0x70, 0xF1,
-       0x63, 0x77, 0xAF, 0x42, 0x20, 0xE5, 0xFD, 0xBF,
-       0x81, 0x18, 0x26, 0xC3, 0xBE, 0x35, 0x88, 0x2E,
-       0x93, 0x55, 0xFC, 0x7A, 0xC8, 0xBA, 0x32, 0xE6,
-       0xC0, 0x19, 0x9E, 0xA3, 0x44, 0x54, 0x3B, 0x0B,
-       0x8C, 0xC7, 0x6B, 0x28, 0xA7, 0xBC, 0x16, 0xAD,
-       0xDB, 0x64, 0x74, 0x14, 0x92, 0x0C, 0x48, 0xB8,
-       0x9F, 0xBD, 0x43, 0xC4, 0x39, 0x31, 0xD3, 0xF2,
-       0xD5, 0x8B, 0x6E, 0xDA, 0x01, 0xB1, 0x9C, 0x49,
-       0xD8, 0xAC, 0xF3, 0xCF, 0xCA, 0xF4, 0x47, 0x10,
-       0x6F, 0xF0, 0x4A, 0x5C, 0x38, 0x57, 0x73, 0x97,
-       0xCB, 0xA1, 0xE8, 0x3E, 0x96, 0x61, 0x0D, 0x0F,
-       0xE0, 0x7C, 0x71, 0xCC, 0x90, 0x06, 0xF7, 0x1C,
-       0xC2, 0x6A, 0xAE, 0x69, 0x17, 0x99, 0x3A, 0x27,
-       0xD9, 0xEB, 0x2B, 0x22, 0xD2, 0xA9, 0x07, 0x33,
-       0x2D, 0x3C, 0x15, 0xC9, 0x87, 0xAA, 0x50, 0xA5,
-       0x03, 0x59, 0x09, 0x1A, 0x65, 0xD7, 0x84, 0xD0,
-       0x82, 0x29, 0x5A, 0x1E, 0x7B, 0xA8, 0x6D, 0x2C
-};
-
-/* */
-/* Expanded IV for TKIP function. */
-/* */
-struct PACKED rt_tkip_iv {
-       union PACKED {
-               struct PACKED {
-                       u8 rc0;
-                       u8 rc1;
-                       u8 rc2;
-
-                       union PACKED {
-                               struct PACKED {
-                                       u8 Rsvd:5;
-                                       u8 ExtIV:1;
-                                       u8 KeyID:2;
-                               } field;
-                               u8 Byte;
-                       } CONTROL;
-               } field;
-
-               unsigned long word;
-       } IV16;
-
-       unsigned long IV32;
-};
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Convert from u8[] to unsigned long in a portable way
-
-       Arguments:
-      pMICKey          pointer to MIC Key
-
-       Return Value:
-               None
-
-       Note:
-
-       ========================================================================
-*/
-unsigned long RTMPTkipGetUInt32(u8 *pMICKey)
-{
-       unsigned long res = 0;
-       int i;
-
-       for (i = 0; i < 4; i++) {
-               res |= (*pMICKey++) << (8 * i);
-       }
-
-       return res;
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Convert from unsigned long to u8[] in a portable way
-
-       Arguments:
-      pDst                     pointer to destination for convert unsigned long to u8[]
-      val                      the value for convert
-
-       Return Value:
-               None
-
-       IRQL = DISPATCH_LEVEL
-
-       Note:
-
-       ========================================================================
-*/
-void RTMPTkipPutUInt32(IN u8 *pDst, unsigned long val)
-{
-       int i;
-
-       for (i = 0; i < 4; i++) {
-               *pDst++ = (u8)(val & 0xff);
-               val >>= 8;
-       }
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Set the MIC Key.
-
-       Arguments:
-      pAd              Pointer to our adapter
-      pMICKey          pointer to MIC Key
-
-       Return Value:
-               None
-
-       IRQL = DISPATCH_LEVEL
-
-       Note:
-
-       ========================================================================
-*/
-void RTMPTkipSetMICKey(struct rt_tkip_key_info *pTkip, u8 *pMICKey)
-{
-       /* Set the key */
-       pTkip->K0 = RTMPTkipGetUInt32(pMICKey);
-       pTkip->K1 = RTMPTkipGetUInt32(pMICKey + 4);
-       /* and reset the message */
-       pTkip->L = pTkip->K0;
-       pTkip->R = pTkip->K1;
-       pTkip->nBytesInM = 0;
-       pTkip->M = 0;
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Calculate the MIC Value.
-
-       Arguments:
-      pAd              Pointer to our adapter
-      uChar                    Append this uChar
-
-       Return Value:
-               None
-
-       IRQL = DISPATCH_LEVEL
-
-       Note:
-
-       ========================================================================
-*/
-void RTMPTkipAppendByte(struct rt_tkip_key_info *pTkip, u8 uChar)
-{
-       /* Append the byte to our word-sized buffer */
-       pTkip->M |= (uChar << (8 * pTkip->nBytesInM));
-       pTkip->nBytesInM++;
-       /* Process the word if it is full. */
-       if (pTkip->nBytesInM >= 4) {
-               pTkip->L ^= pTkip->M;
-               pTkip->R ^= ROL32(pTkip->L, 17);
-               pTkip->L += pTkip->R;
-               pTkip->R ^=
-                   ((pTkip->L & 0xff00ff00) >> 8) | ((pTkip->
-                                                      L & 0x00ff00ff) << 8);
-               pTkip->L += pTkip->R;
-               pTkip->R ^= ROL32(pTkip->L, 3);
-               pTkip->L += pTkip->R;
-               pTkip->R ^= ROR32(pTkip->L, 2);
-               pTkip->L += pTkip->R;
-               /* Clear the buffer */
-               pTkip->M = 0;
-               pTkip->nBytesInM = 0;
-       }
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Calculate the MIC Value.
-
-       Arguments:
-      pAd              Pointer to our adapter
-      pSrc                     Pointer to source data for Calculate MIC Value
-      Len                      Indicate the length of the source data
-
-       Return Value:
-               None
-
-       IRQL = DISPATCH_LEVEL
-
-       Note:
-
-       ========================================================================
-*/
-void RTMPTkipAppend(struct rt_tkip_key_info *pTkip, u8 *pSrc, u32 nBytes)
-{
-       /* This is simple */
-       while (nBytes > 0) {
-               RTMPTkipAppendByte(pTkip, *pSrc++);
-               nBytes--;
-       }
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Get the MIC Value.
-
-       Arguments:
-      pAd              Pointer to our adapter
-
-       Return Value:
-               None
-
-       IRQL = DISPATCH_LEVEL
-
-       Note:
-               the MIC Value is store in pAd->PrivateInfo.MIC
-       ========================================================================
-*/
-void RTMPTkipGetMIC(struct rt_tkip_key_info *pTkip)
-{
-       /* Append the minimum padding */
-       RTMPTkipAppendByte(pTkip, 0x5a);
-       RTMPTkipAppendByte(pTkip, 0);
-       RTMPTkipAppendByte(pTkip, 0);
-       RTMPTkipAppendByte(pTkip, 0);
-       RTMPTkipAppendByte(pTkip, 0);
-       /* and then zeroes until the length is a multiple of 4 */
-       while (pTkip->nBytesInM != 0) {
-               RTMPTkipAppendByte(pTkip, 0);
-       }
-       /* The appendByte function has already computed the result. */
-       RTMPTkipPutUInt32(pTkip->MIC, pTkip->L);
-       RTMPTkipPutUInt32(pTkip->MIC + 4, pTkip->R);
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Init Tkip function.
-
-       Arguments:
-      pAd              Pointer to our adapter
-               pTKey       Pointer to the Temporal Key (TK), TK shall be 128bits.
-               KeyId           TK Key ID
-               pTA                     Pointer to transmitter address
-               pMICKey         pointer to MIC Key
-
-       Return Value:
-               None
-
-       IRQL = DISPATCH_LEVEL
-
-       Note:
-
-       ========================================================================
-*/
-void RTMPInitTkipEngine(struct rt_rtmp_adapter *pAd,
-                       u8 *pKey,
-                       u8 KeyId,
-                       u8 *pTA,
-                       u8 *pMICKey,
-                       u8 *pTSC, unsigned long *pIV16, unsigned long *pIV32)
-{
-       struct rt_tkip_iv tkipIv;
-
-       /* Prepare 8 bytes TKIP encapsulation for MPDU */
-       NdisZeroMemory(&tkipIv, sizeof(struct rt_tkip_iv));
-       tkipIv.IV16.field.rc0 = *(pTSC + 1);
-       tkipIv.IV16.field.rc1 = (tkipIv.IV16.field.rc0 | 0x20) & 0x7f;
-       tkipIv.IV16.field.rc2 = *pTSC;
-       tkipIv.IV16.field.CONTROL.field.ExtIV = 1;      /* 0: non-extended IV, 1: an extended IV */
-       tkipIv.IV16.field.CONTROL.field.KeyID = KeyId;
-/*      tkipIv.IV32 = *(unsigned long *)(pTSC + 2); */
-       NdisMoveMemory(&tkipIv.IV32, (pTSC + 2), 4);    /* Copy IV */
-
-       *pIV16 = tkipIv.IV16.word;
-       *pIV32 = tkipIv.IV32;
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Init MIC Value calculation function which include set MIC key &
-               calculate first 16 bytes (DA + SA + priority +  0)
-
-       Arguments:
-      pAd              Pointer to our adapter
-               pTKey       Pointer to the Temporal Key (TK), TK shall be 128bits.
-               pDA                     Pointer to DA address
-               pSA                     Pointer to SA address
-               pMICKey         pointer to MIC Key
-
-       Return Value:
-               None
-
-       Note:
-
-       ========================================================================
-*/
-void RTMPInitMICEngine(struct rt_rtmp_adapter *pAd,
-                      u8 *pKey,
-                      u8 *pDA,
-                      u8 *pSA, u8 UserPriority, u8 *pMICKey)
-{
-       unsigned long Priority = UserPriority;
-
-       /* Init MIC value calculation */
-       RTMPTkipSetMICKey(&pAd->PrivateInfo.Tx, pMICKey);
-       /* DA */
-       RTMPTkipAppend(&pAd->PrivateInfo.Tx, pDA, MAC_ADDR_LEN);
-       /* SA */
-       RTMPTkipAppend(&pAd->PrivateInfo.Tx, pSA, MAC_ADDR_LEN);
-       /* Priority + 3 bytes of 0 */
-       RTMPTkipAppend(&pAd->PrivateInfo.Tx, (u8 *)& Priority, 4);
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Compare MIC value of received MSDU
-
-       Arguments:
-               pAd     Pointer to our adapter
-               pSrc        Pointer to the received Plain text data
-               pDA                     Pointer to DA address
-               pSA                     Pointer to SA address
-               pMICKey         pointer to MIC Key
-               Len         the length of the received plain text data exclude MIC value
-
-       Return Value:
-               TRUE        MIC value matched
-               FALSE       MIC value mismatched
-
-       IRQL = DISPATCH_LEVEL
-
-       Note:
-
-       ========================================================================
-*/
-BOOLEAN RTMPTkipCompareMICValue(struct rt_rtmp_adapter *pAd,
-                               u8 *pSrc,
-                               u8 *pDA,
-                               u8 *pSA,
-                               u8 *pMICKey,
-                               u8 UserPriority, u32 Len)
-{
-       u8 OldMic[8];
-       unsigned long Priority = UserPriority;
-
-       /* Init MIC value calculation */
-       RTMPTkipSetMICKey(&pAd->PrivateInfo.Rx, pMICKey);
-       /* DA */
-       RTMPTkipAppend(&pAd->PrivateInfo.Rx, pDA, MAC_ADDR_LEN);
-       /* SA */
-       RTMPTkipAppend(&pAd->PrivateInfo.Rx, pSA, MAC_ADDR_LEN);
-       /* Priority + 3 bytes of 0 */
-       RTMPTkipAppend(&pAd->PrivateInfo.Rx, (u8 *)& Priority, 4);
-
-       /* Calculate MIC value from plain text data */
-       RTMPTkipAppend(&pAd->PrivateInfo.Rx, pSrc, Len);
-
-       /* Get MIC valude from received frame */
-       NdisMoveMemory(OldMic, pSrc + Len, 8);
-
-       /* Get MIC value from decrypted plain data */
-       RTMPTkipGetMIC(&pAd->PrivateInfo.Rx);
-
-       /* Move MIC value from MSDU, this steps should move to data path. */
-       /* Since the MIC value might cross MPDUs. */
-       if (!NdisEqualMemory(pAd->PrivateInfo.Rx.MIC, OldMic, 8)) {
-               DBGPRINT_RAW(RT_DEBUG_ERROR, ("RTMPTkipCompareMICValue(): TKIP MIC Error !\n"));        /*MIC error. */
-
-               return (FALSE);
-       }
-       return (TRUE);
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Copy frame from waiting queue into relative ring buffer and set
-       appropriate ASIC register to kick hardware transmit function
-
-       Arguments:
-               pAd             Pointer to our adapter
-               void *  Pointer to Ndis Packet for MIC calculation
-               pEncap                  Pointer to LLC encap data
-               LenEncap                Total encap length, might be 0 which indicates no encap
-
-       Return Value:
-               None
-
-       IRQL = DISPATCH_LEVEL
-
-       Note:
-
-       ========================================================================
-*/
-void RTMPCalculateMICValue(struct rt_rtmp_adapter *pAd,
-                          void *pPacket,
-                          u8 *pEncap,
-                          struct rt_cipher_key *pKey, u8 apidx)
-{
-       struct rt_packet_info PacketInfo;
-       u8 *pSrcBufVA;
-       u32 SrcBufLen;
-       u8 *pSrc;
-       u8 UserPriority;
-       u8 vlan_offset = 0;
-
-       RTMP_QueryPacketInfo(pPacket, &PacketInfo, &pSrcBufVA, &SrcBufLen);
-
-       UserPriority = RTMP_GET_PACKET_UP(pPacket);
-       pSrc = pSrcBufVA;
-
-       /* determine if this is a vlan packet */
-       if (((*(pSrc + 12) << 8) + *(pSrc + 13)) == 0x8100)
-               vlan_offset = 4;
-
-       {
-               RTMPInitMICEngine(pAd,
-                                 pKey->Key,
-                                 pSrc, pSrc + 6, UserPriority, pKey->TxMic);
-       }
-
-       if (pEncap != NULL) {
-               /* LLC encapsulation */
-               RTMPTkipAppend(&pAd->PrivateInfo.Tx, pEncap, 6);
-               /* Protocol Type */
-               RTMPTkipAppend(&pAd->PrivateInfo.Tx, pSrc + 12 + vlan_offset,
-                              2);
-       }
-       SrcBufLen -= (14 + vlan_offset);
-       pSrc += (14 + vlan_offset);
-       do {
-               if (SrcBufLen > 0) {
-                       RTMPTkipAppend(&pAd->PrivateInfo.Tx, pSrc, SrcBufLen);
-               }
-
-               break;          /* No need handle next packet */
-
-       } while (TRUE);         /* End of copying payload */
-
-       /* Compute the final MIC Value */
-       RTMPTkipGetMIC(&pAd->PrivateInfo.Tx);
-}
-
-/************************************************************/
-/* tkip_sbox()                                                                                                                         */
-/* Returns a 16 bit value from a 64K entry table. The Table */
-/* is synthesized from two 256 entry byte wide tables.         */
-/************************************************************/
-
-u32 tkip_sbox(u32 index)
-{
-       u32 index_low;
-       u32 index_high;
-       u32 left, right;
-
-       index_low = (index % 256);
-       index_high = ((index >> 8) % 256);
-
-       left = Tkip_Sbox_Lower[index_low] + (Tkip_Sbox_Upper[index_low] * 256);
-       right =
-           Tkip_Sbox_Upper[index_high] + (Tkip_Sbox_Lower[index_high] * 256);
-
-       return (left ^ right);
-}
-
-u32 rotr1(u32 a)
-{
-       unsigned int b;
-
-       if ((a & 0x01) == 0x01) {
-               b = (a >> 1) | 0x8000;
-       } else {
-               b = (a >> 1) & 0x7fff;
-       }
-       b = b % 65536;
-       return b;
-}
-
-void RTMPTkipMixKey(u8 * key, u8 * ta, unsigned long pnl,      /* Least significant 16 bits of PN */
-                   unsigned long pnh,  /* Most significant 32 bits of PN */
-                   u8 * rc4key, u32 * p1k)
-{
-
-       u32 tsc0;
-       u32 tsc1;
-       u32 tsc2;
-
-       u32 ppk0;
-       u32 ppk1;
-       u32 ppk2;
-       u32 ppk3;
-       u32 ppk4;
-       u32 ppk5;
-
-       int i;
-       int j;
-
-       tsc0 = (unsigned int)((pnh >> 16) % 65536);     /* msb */
-       tsc1 = (unsigned int)(pnh % 65536);
-       tsc2 = (unsigned int)(pnl % 65536);     /* lsb */
-
-       /* Phase 1, step 1 */
-       p1k[0] = tsc1;
-       p1k[1] = tsc0;
-       p1k[2] = (u32)(ta[0] + (ta[1] * 256));
-       p1k[3] = (u32)(ta[2] + (ta[3] * 256));
-       p1k[4] = (u32)(ta[4] + (ta[5] * 256));
-
-       /* Phase 1, step 2 */
-       for (i = 0; i < 8; i++) {
-               j = 2 * (i & 1);
-               p1k[0] =
-                   (p1k[0] +
-                    tkip_sbox((p1k[4] ^ ((256 * key[1 + j]) + key[j])) %
-                              65536)) % 65536;
-               p1k[1] =
-                   (p1k[1] +
-                    tkip_sbox((p1k[0] ^ ((256 * key[5 + j]) + key[4 + j])) %
-                              65536)) % 65536;
-               p1k[2] =
-                   (p1k[2] +
-                    tkip_sbox((p1k[1] ^ ((256 * key[9 + j]) + key[8 + j])) %
-                              65536)) % 65536;
-               p1k[3] =
-                   (p1k[3] +
-                    tkip_sbox((p1k[2] ^ ((256 * key[13 + j]) + key[12 + j])) %
-                              65536)) % 65536;
-               p1k[4] =
-                   (p1k[4] +
-                    tkip_sbox((p1k[3] ^ (((256 * key[1 + j]) + key[j]))) %
-                              65536)) % 65536;
-               p1k[4] = (p1k[4] + i) % 65536;
-       }
-
-       /* Phase 2, Step 1 */
-       ppk0 = p1k[0];
-       ppk1 = p1k[1];
-       ppk2 = p1k[2];
-       ppk3 = p1k[3];
-       ppk4 = p1k[4];
-       ppk5 = (p1k[4] + tsc2) % 65536;
-
-       /* Phase2, Step 2 */
-       ppk0 = ppk0 + tkip_sbox((ppk5 ^ ((256 * key[1]) + key[0])) % 65536);
-       ppk1 = ppk1 + tkip_sbox((ppk0 ^ ((256 * key[3]) + key[2])) % 65536);
-       ppk2 = ppk2 + tkip_sbox((ppk1 ^ ((256 * key[5]) + key[4])) % 65536);
-       ppk3 = ppk3 + tkip_sbox((ppk2 ^ ((256 * key[7]) + key[6])) % 65536);
-       ppk4 = ppk4 + tkip_sbox((ppk3 ^ ((256 * key[9]) + key[8])) % 65536);
-       ppk5 = ppk5 + tkip_sbox((ppk4 ^ ((256 * key[11]) + key[10])) % 65536);
-
-       ppk0 = ppk0 + rotr1(ppk5 ^ ((256 * key[13]) + key[12]));
-       ppk1 = ppk1 + rotr1(ppk0 ^ ((256 * key[15]) + key[14]));
-       ppk2 = ppk2 + rotr1(ppk1);
-       ppk3 = ppk3 + rotr1(ppk2);
-       ppk4 = ppk4 + rotr1(ppk3);
-       ppk5 = ppk5 + rotr1(ppk4);
-
-       /* Phase 2, Step 3 */
-       /* Phase 2, Step 3 */
-
-       tsc0 = (unsigned int)((pnh >> 16) % 65536);     /* msb */
-       tsc1 = (unsigned int)(pnh % 65536);
-       tsc2 = (unsigned int)(pnl % 65536);     /* lsb */
-
-       rc4key[0] = (tsc2 >> 8) % 256;
-       rc4key[1] = (((tsc2 >> 8) % 256) | 0x20) & 0x7f;
-       rc4key[2] = tsc2 % 256;
-       rc4key[3] = ((ppk5 ^ ((256 * key[1]) + key[0])) >> 1) % 256;
-
-       rc4key[4] = ppk0 % 256;
-       rc4key[5] = (ppk0 >> 8) % 256;
-
-       rc4key[6] = ppk1 % 256;
-       rc4key[7] = (ppk1 >> 8) % 256;
-
-       rc4key[8] = ppk2 % 256;
-       rc4key[9] = (ppk2 >> 8) % 256;
-
-       rc4key[10] = ppk3 % 256;
-       rc4key[11] = (ppk3 >> 8) % 256;
-
-       rc4key[12] = ppk4 % 256;
-       rc4key[13] = (ppk4 >> 8) % 256;
-
-       rc4key[14] = ppk5 % 256;
-       rc4key[15] = (ppk5 >> 8) % 256;
-}
-
-/* */
-/* TRUE: Success! */
-/* FALSE: Decrypt Error! */
-/* */
-BOOLEAN RTMPSoftDecryptTKIP(struct rt_rtmp_adapter *pAd,
-                           u8 *pData,
-                           unsigned long DataByteCnt,
-                           u8 UserPriority, struct rt_cipher_key *pWpaKey)
-{
-       u8 KeyID;
-       u32 HeaderLen;
-       u8 fc0;
-       u8 fc1;
-       u16 fc;
-       u32 frame_type;
-       u32 frame_subtype;
-       u32 from_ds;
-       u32 to_ds;
-       int a4_exists;
-       int qc_exists;
-       u16 duration;
-       u16 seq_control;
-       u16 qos_control;
-       u8 TA[MAC_ADDR_LEN];
-       u8 DA[MAC_ADDR_LEN];
-       u8 SA[MAC_ADDR_LEN];
-       u8 RC4Key[16];
-       u32 p1k[5];             /*for mix_key; */
-       unsigned long pnl;              /* Least significant 16 bits of PN */
-       unsigned long pnh;              /* Most significant 32 bits of PN */
-       u32 num_blocks;
-       u32 payload_remainder;
-       struct rt_arcfourcontext ArcFourContext;
-       u32 crc32 = 0;
-       u32 trailfcs = 0;
-       u8 MIC[8];
-       u8 TrailMIC[8];
-
-       fc0 = *pData;
-       fc1 = *(pData + 1);
-
-       fc = *((u16 *)pData);
-
-       frame_type = ((fc0 >> 2) & 0x03);
-       frame_subtype = ((fc0 >> 4) & 0x0f);
-
-       from_ds = (fc1 & 0x2) >> 1;
-       to_ds = (fc1 & 0x1);
-
-       a4_exists = (from_ds & to_ds);
-       qc_exists = ((frame_subtype == 0x08) || /* Assumed QoS subtypes */
-                    (frame_subtype == 0x09) || /* Likely to change.    */
-                    (frame_subtype == 0x0a) || (frame_subtype == 0x0b)
-           );
-
-       HeaderLen = 24;
-       if (a4_exists)
-               HeaderLen += 6;
-
-       KeyID = *((u8 *)(pData + HeaderLen + 3));
-       KeyID = KeyID >> 6;
-
-       if (pWpaKey[KeyID].KeyLen == 0) {
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("RTMPSoftDecryptTKIP failed!(KeyID[%d] Length can not be 0)\n",
-                         KeyID));
-               return FALSE;
-       }
-
-       duration = *((u16 *)(pData + 2));
-
-       seq_control = *((u16 *)(pData + 22));
-
-       if (qc_exists) {
-               if (a4_exists) {
-                       qos_control = *((u16 *)(pData + 30));
-               } else {
-                       qos_control = *((u16 *)(pData + 24));
-               }
-       }
-
-       if (to_ds == 0 && from_ds == 1) {
-               NdisMoveMemory(DA, pData + 4, MAC_ADDR_LEN);
-               NdisMoveMemory(SA, pData + 16, MAC_ADDR_LEN);
-               NdisMoveMemory(TA, pData + 10, MAC_ADDR_LEN);   /*BSSID */
-       } else if (to_ds == 0 && from_ds == 0) {
-               NdisMoveMemory(TA, pData + 10, MAC_ADDR_LEN);
-               NdisMoveMemory(DA, pData + 4, MAC_ADDR_LEN);
-               NdisMoveMemory(SA, pData + 10, MAC_ADDR_LEN);
-       } else if (to_ds == 1 && from_ds == 0) {
-               NdisMoveMemory(SA, pData + 10, MAC_ADDR_LEN);
-               NdisMoveMemory(TA, pData + 10, MAC_ADDR_LEN);
-               NdisMoveMemory(DA, pData + 16, MAC_ADDR_LEN);
-       } else if (to_ds == 1 && from_ds == 1) {
-               NdisMoveMemory(TA, pData + 10, MAC_ADDR_LEN);
-               NdisMoveMemory(DA, pData + 16, MAC_ADDR_LEN);
-               NdisMoveMemory(SA, pData + 22, MAC_ADDR_LEN);
-       }
-
-       num_blocks = (DataByteCnt - 16) / 16;
-       payload_remainder = (DataByteCnt - 16) % 16;
-
-       pnl = (*(pData + HeaderLen)) * 256 + *(pData + HeaderLen + 2);
-       pnh = *((unsigned long *)(pData + HeaderLen + 4));
-       pnh = cpu2le32(pnh);
-       RTMPTkipMixKey(pWpaKey[KeyID].Key, TA, pnl, pnh, RC4Key, p1k);
-
-       ARCFOUR_INIT(&ArcFourContext, RC4Key, 16);
-
-       ARCFOUR_DECRYPT(&ArcFourContext, pData + HeaderLen,
-                       pData + HeaderLen + 8, DataByteCnt - HeaderLen - 8);
-       NdisMoveMemory(&trailfcs, pData + DataByteCnt - 8 - 4, 4);
-       crc32 = RTMP_CALC_FCS32(PPPINITFCS32, pData + HeaderLen, DataByteCnt - HeaderLen - 8 - 4);      /*Skip IV+EIV 8 bytes & Skip last 4 bytes(FCS). */
-       crc32 ^= 0xffffffff;    /* complement */
-
-       if (crc32 != cpu2le32(trailfcs)) {
-               DBGPRINT(RT_DEBUG_TRACE, ("RTMPSoftDecryptTKIP, WEP Data ICV Error !\n"));      /*ICV error. */
-
-               return (FALSE);
-       }
-
-       NdisMoveMemory(TrailMIC, pData + DataByteCnt - 8 - 8 - 4, 8);
-       RTMPInitMICEngine(pAd, pWpaKey[KeyID].Key, DA, SA, UserPriority,
-                         pWpaKey[KeyID].RxMic);
-       RTMPTkipAppend(&pAd->PrivateInfo.Tx, pData + HeaderLen,
-                      DataByteCnt - HeaderLen - 8 - 12);
-       RTMPTkipGetMIC(&pAd->PrivateInfo.Tx);
-       NdisMoveMemory(MIC, pAd->PrivateInfo.Tx.MIC, 8);
-
-       if (!NdisEqualMemory(MIC, TrailMIC, 8)) {
-               DBGPRINT(RT_DEBUG_ERROR, ("RTMPSoftDecryptTKIP, WEP Data MIC Error !\n"));      /*MIC error. */
-               /*RTMPReportMicError(pAd, &pWpaKey[KeyID]);     // marked by AlbertY @ 20060630 */
-               return (FALSE);
-       }
-       /*DBGPRINT(RT_DEBUG_TRACE, "RTMPSoftDecryptTKIP Decript done!\n"); */
-       return TRUE;
-}
diff --git a/drivers/staging/rt2860/common/cmm_wep.c b/drivers/staging/rt2860/common/cmm_wep.c
deleted file mode 100644 (file)
index 76f880c..0000000
+++ /dev/null
@@ -1,473 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-       Module Name:
-       rtmp_wep.c
-
-       Abstract:
-
-       Revision History:
-       Who                     When                    What
-       --------        ----------              ----------------------------------------------
-       Paul Wu         10-28-02                Initial
-*/
-
-#include       "../rt_config.h"
-
-u32 FCSTAB_32[256] = {
-       0x00000000, 0x77073096, 0xee0e612c, 0x990951ba,
-       0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
-       0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
-       0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91,
-       0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de,
-       0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
-       0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec,
-       0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5,
-       0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,
-       0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
-       0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940,
-       0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
-       0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116,
-       0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f,
-       0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
-       0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d,
-       0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a,
-       0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
-       0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818,
-       0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
-       0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
-       0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457,
-       0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c,
-       0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
-       0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2,
-       0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb,
-       0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,
-       0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9,
-       0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086,
-       0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
-       0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4,
-       0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad,
-       0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
-       0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683,
-       0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8,
-       0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
-       0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe,
-       0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7,
-       0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
-       0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
-       0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252,
-       0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
-       0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60,
-       0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79,
-       0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
-       0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f,
-       0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04,
-       0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
-       0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a,
-       0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
-       0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,
-       0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21,
-       0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e,
-       0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
-       0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c,
-       0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45,
-       0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,
-       0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db,
-       0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0,
-       0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
-       0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6,
-       0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf,
-       0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
-       0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
-};
-
-/*
-u8   WEPKEY[] = {
-               //IV
-               0x00, 0x11, 0x22,
-               //WEP KEY
-               0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC
-       };
- */
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Init WEP function.
-
-       Arguments:
-      pAd              Pointer to our adapter
-               pKey        Pointer to the WEP KEY
-               KeyId              WEP Key ID
-               KeyLen      the length of WEP KEY
-               pDest       Pointer to the destination which Encryption data will store in.
-
-       Return Value:
-               None
-
-       IRQL = DISPATCH_LEVEL
-
-       Note:
-
-       ========================================================================
-*/
-void RTMPInitWepEngine(struct rt_rtmp_adapter *pAd,
-                      u8 *pKey,
-                      u8 KeyId, u8 KeyLen, IN u8 *pDest)
-{
-       u32 i;
-       u8 WEPKEY[] = {
-               /*IV */
-               0x00, 0x11, 0x22,
-               /*WEP KEY */
-               0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99,
-                   0xAA, 0xBB, 0xCC
-       };
-
-       pAd->PrivateInfo.FCSCRC32 = PPPINITFCS32;       /*Init crc32. */
-
-       {
-               NdisMoveMemory(WEPKEY + 3, pKey, KeyLen);
-
-               for (i = 0; i < 3; i++)
-                       WEPKEY[i] = RandomByte(pAd);    /*Call mlme RandomByte() function. */
-               ARCFOUR_INIT(&pAd->PrivateInfo.WEPCONTEXT, WEPKEY, KeyLen + 3); /*INIT SBOX, KEYLEN+3(IV) */
-
-               NdisMoveMemory(pDest, WEPKEY, 3);       /*Append Init Vector */
-       }
-       *(pDest + 3) = (KeyId << 6);    /*Append KEYID */
-
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Encrypt transimitted data
-
-       Arguments:
-      pAd              Pointer to our adapter
-      pSrc        Pointer to the transimitted source data that will be encrypt
-      pDest       Pointer to the destination where entryption data will be store in.
-      Len                      Indicate the length of the source data
-
-       Return Value:
-      None
-
-       IRQL = DISPATCH_LEVEL
-
-       Note:
-
-       ========================================================================
-*/
-void RTMPEncryptData(struct rt_rtmp_adapter *pAd,
-                    u8 *pSrc, u8 *pDest, u32 Len)
-{
-       pAd->PrivateInfo.FCSCRC32 =
-           RTMP_CALC_FCS32(pAd->PrivateInfo.FCSCRC32, pSrc, Len);
-       ARCFOUR_ENCRYPT(&pAd->PrivateInfo.WEPCONTEXT, pDest, pSrc, Len);
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Decrypt received WEP data
-
-       Arguments:
-               pAdapter                Pointer to our adapter
-               pSrc        Pointer to the received data
-               Len         the length of the received data
-
-       Return Value:
-               TRUE        Decrypt WEP data success
-               FALSE       Decrypt WEP data failed
-
-       Note:
-
-       ========================================================================
-*/
-BOOLEAN RTMPSoftDecryptWEP(struct rt_rtmp_adapter *pAd,
-                          u8 *pData,
-                          unsigned long DataByteCnt, struct rt_cipher_key *pGroupKey)
-{
-       u32 trailfcs;
-       u32 crc32;
-       u8 KeyIdx;
-       u8 WEPKEY[] = {
-               /*IV */
-               0x00, 0x11, 0x22,
-               /*WEP KEY */
-               0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99,
-                   0xAA, 0xBB, 0xCC
-       };
-       u8 *pPayload = (u8 *) pData + LENGTH_802_11;
-       unsigned long payload_len = DataByteCnt - LENGTH_802_11;
-
-       NdisMoveMemory(WEPKEY, pPayload, 3);    /*Get WEP IV */
-
-       KeyIdx = (*(pPayload + 3) & 0xc0) >> 6;
-       if (pGroupKey[KeyIdx].KeyLen == 0)
-               return (FALSE);
-
-       NdisMoveMemory(WEPKEY + 3, pGroupKey[KeyIdx].Key,
-                      pGroupKey[KeyIdx].KeyLen);
-       ARCFOUR_INIT(&pAd->PrivateInfo.WEPCONTEXT, WEPKEY,
-                    pGroupKey[KeyIdx].KeyLen + 3);
-       ARCFOUR_DECRYPT(&pAd->PrivateInfo.WEPCONTEXT, pPayload, pPayload + 4,
-                       payload_len - 4);
-       NdisMoveMemory(&trailfcs, pPayload + payload_len - 8, 4);
-       crc32 = RTMP_CALC_FCS32(PPPINITFCS32, pPayload, payload_len - 8);       /*Skip last 4 bytes(FCS). */
-       crc32 ^= 0xffffffff;    /* complement */
-
-       if (crc32 != cpu2le32(trailfcs)) {
-               DBGPRINT(RT_DEBUG_TRACE, ("WEP Data CRC Error!\n"));    /*CRC error. */
-               return (FALSE);
-       }
-       return (TRUE);
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               The Stream Cipher Encryption Algorithm "struct rt_arcfour" initialize
-
-       Arguments:
-          Ctx         Pointer to struct rt_arcfour CONTEXT (SBOX)
-               pKey        Pointer to the WEP KEY
-               KeyLen      Indicate the length fo the WEP KEY
-
-       Return Value:
-          None
-
-       IRQL = DISPATCH_LEVEL
-
-       Note:
-
-       ========================================================================
-*/
-void ARCFOUR_INIT(struct rt_arcfourcontext *Ctx, u8 *pKey, u32 KeyLen)
-{
-       u8 t, u;
-       u32 keyindex;
-       u32 stateindex;
-       u8 *state;
-       u32 counter;
-
-       state = Ctx->STATE;
-       Ctx->X = 0;
-       Ctx->Y = 0;
-       for (counter = 0; counter < 256; counter++)
-               state[counter] = (u8)counter;
-       keyindex = 0;
-       stateindex = 0;
-       for (counter = 0; counter < 256; counter++) {
-               t = state[counter];
-               stateindex = (stateindex + pKey[keyindex] + t) & 0xff;
-               u = state[stateindex];
-               state[stateindex] = t;
-               state[counter] = u;
-               if (++keyindex >= KeyLen)
-                       keyindex = 0;
-       }
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Get bytes from struct rt_arcfour CONTEXT (S-BOX)
-
-       Arguments:
-          Ctx         Pointer to struct rt_arcfour CONTEXT (SBOX)
-
-       Return Value:
-          u8  - the value of the struct rt_arcfour CONTEXT (S-BOX)
-
-       Note:
-
-       ========================================================================
-*/
-u8 ARCFOUR_BYTE(struct rt_arcfourcontext *Ctx)
-{
-       u32 x;
-       u32 y;
-       u8 sx, sy;
-       u8 *state;
-
-       state = Ctx->STATE;
-       x = (Ctx->X + 1) & 0xff;
-       sx = state[x];
-       y = (sx + Ctx->Y) & 0xff;
-       sy = state[y];
-       Ctx->X = x;
-       Ctx->Y = y;
-       state[y] = sx;
-       state[x] = sy;
-
-       return (state[(sx + sy) & 0xff]);
-
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               The Stream Cipher Decryption Algorithm
-
-       Arguments:
-               Ctx         Pointer to struct rt_arcfour CONTEXT (SBOX)
-               pDest                   Pointer to the Destination
-               pSrc        Pointer to the Source data
-               Len         Indicate the length of the Source data
-
-       Return Value:
-               None
-
-       Note:
-
-       ========================================================================
-*/
-void ARCFOUR_DECRYPT(struct rt_arcfourcontext *Ctx,
-                    u8 *pDest, u8 *pSrc, u32 Len)
-{
-       u32 i;
-
-       for (i = 0; i < Len; i++)
-               pDest[i] = pSrc[i] ^ ARCFOUR_BYTE(Ctx);
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               The Stream Cipher Encryption Algorithm
-
-       Arguments:
-               Ctx         Pointer to struct rt_arcfour CONTEXT (SBOX)
-               pDest                   Pointer to the Destination
-               pSrc        Pointer to the Source data
-               Len         Indicate the length of the Source dta
-
-       Return Value:
-               None
-
-       IRQL = DISPATCH_LEVEL
-
-       Note:
-
-       ========================================================================
-*/
-void ARCFOUR_ENCRYPT(struct rt_arcfourcontext *Ctx,
-                    u8 *pDest, u8 *pSrc, u32 Len)
-{
-       u32 i;
-
-       for (i = 0; i < Len; i++)
-               pDest[i] = pSrc[i] ^ ARCFOUR_BYTE(Ctx);
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               The Stream Cipher Encryption Algorithm which conform to the special requirement to encrypt  GTK.
-
-       Arguments:
-               Ctx         Pointer to struct rt_arcfour CONTEXT (SBOX)
-               pDest                   Pointer to the Destination
-               pSrc        Pointer to the Source data
-               Len         Indicate the length of the Source dta
-
-       ========================================================================
-*/
-
-void WPAARCFOUR_ENCRYPT(struct rt_arcfourcontext *Ctx,
-                       u8 *pDest, u8 *pSrc, u32 Len)
-{
-       u32 i;
-       /*discard first 256 bytes */
-       for (i = 0; i < 256; i++)
-               ARCFOUR_BYTE(Ctx);
-
-       for (i = 0; i < Len; i++)
-               pDest[i] = pSrc[i] ^ ARCFOUR_BYTE(Ctx);
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Calculate a new FCS given the current FCS and the new data.
-
-       Arguments:
-               Fcs           the original FCS value
-               Cp          pointer to the data which will be calculate the FCS
-               Len         the length of the data
-
-       Return Value:
-               u32 - FCS 32 bits
-
-       IRQL = DISPATCH_LEVEL
-
-       Note:
-
-       ========================================================================
-*/
-u32 RTMP_CALC_FCS32(u32 Fcs, u8 *Cp, int Len)
-{
-       while (Len--)
-               Fcs = (((Fcs) >> 8) ^ FCSTAB_32[((Fcs) ^ (*Cp++)) & 0xff]);
-
-       return (Fcs);
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Get last FCS and encrypt it to the destination
-
-       Arguments:
-               pDest                   Pointer to the Destination
-
-       Return Value:
-               None
-
-       Note:
-
-       ========================================================================
-*/
-void RTMPSetICV(struct rt_rtmp_adapter *pAd, u8 *pDest)
-{
-       pAd->PrivateInfo.FCSCRC32 ^= 0xffffffff;        /* complement */
-       pAd->PrivateInfo.FCSCRC32 = cpu2le32(pAd->PrivateInfo.FCSCRC32);
-
-       ARCFOUR_ENCRYPT(&pAd->PrivateInfo.WEPCONTEXT, pDest,
-                       (u8 *)& pAd->PrivateInfo.FCSCRC32, 4);
-}
diff --git a/drivers/staging/rt2860/common/cmm_wpa.c b/drivers/staging/rt2860/common/cmm_wpa.c
deleted file mode 100644 (file)
index 616ebec..0000000
+++ /dev/null
@@ -1,3010 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-       Module Name:
-       wpa.c
-
-       Abstract:
-
-       Revision History:
-       Who                     When                    What
-       --------        ----------              ----------------------------------------------
-       Jan     Lee             03-07-22                Initial
-       Paul Lin        03-11-28                Modify for supplicant
-*/
-#include "../rt_config.h"
-/* WPA OUI */
-u8 OUI_WPA_NONE_AKM[4] = { 0x00, 0x50, 0xF2, 0x00 };
-u8 OUI_WPA_VERSION[4] = { 0x00, 0x50, 0xF2, 0x01 };
-u8 OUI_WPA_WEP40[4] = { 0x00, 0x50, 0xF2, 0x01 };
-u8 OUI_WPA_TKIP[4] = { 0x00, 0x50, 0xF2, 0x02 };
-u8 OUI_WPA_CCMP[4] = { 0x00, 0x50, 0xF2, 0x04 };
-u8 OUI_WPA_WEP104[4] = { 0x00, 0x50, 0xF2, 0x05 };
-u8 OUI_WPA_8021X_AKM[4] = { 0x00, 0x50, 0xF2, 0x01 };
-u8 OUI_WPA_PSK_AKM[4] = { 0x00, 0x50, 0xF2, 0x02 };
-
-/* WPA2 OUI */
-u8 OUI_WPA2_WEP40[4] = { 0x00, 0x0F, 0xAC, 0x01 };
-u8 OUI_WPA2_TKIP[4] = { 0x00, 0x0F, 0xAC, 0x02 };
-u8 OUI_WPA2_CCMP[4] = { 0x00, 0x0F, 0xAC, 0x04 };
-u8 OUI_WPA2_8021X_AKM[4] = { 0x00, 0x0F, 0xAC, 0x01 };
-u8 OUI_WPA2_PSK_AKM[4] = { 0x00, 0x0F, 0xAC, 0x02 };
-u8 OUI_WPA2_WEP104[4] = { 0x00, 0x0F, 0xAC, 0x05 };
-
-static void ConstructEapolKeyData(struct rt_mac_table_entry *pEntry,
-                                 u8 GroupKeyWepStatus,
-                                 u8 keyDescVer,
-                                 u8 MsgType,
-                                 u8 DefaultKeyIdx,
-                                 u8 * GTK,
-                                 u8 * RSNIE,
-                                 u8 RSNIE_LEN, struct rt_eapol_packet * pMsg);
-
-static void CalculateMIC(u8 KeyDescVer,
-                        u8 * PTK, struct rt_eapol_packet * pMsg);
-
-static void WpaEAPPacketAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
-
-static void WpaEAPOLASFAlertAction(struct rt_rtmp_adapter *pAd,
-                                  struct rt_mlme_queue_elem *Elem);
-
-static void WpaEAPOLLogoffAction(struct rt_rtmp_adapter *pAd,
-                                struct rt_mlme_queue_elem *Elem);
-
-static void WpaEAPOLStartAction(struct rt_rtmp_adapter *pAd,
-                               struct rt_mlme_queue_elem *Elem);
-
-static void WpaEAPOLKeyAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
-
-/*
-    ==========================================================================
-    Description:
-        association state machine init, including state transition and timer init
-    Parameters:
-        S - pointer to the association state machine
-    ==========================================================================
- */
-void WpaStateMachineInit(struct rt_rtmp_adapter *pAd,
-                        struct rt_state_machine *S, OUT STATE_MACHINE_FUNC Trans[])
-{
-       StateMachineInit(S, (STATE_MACHINE_FUNC *) Trans, MAX_WPA_PTK_STATE,
-                        MAX_WPA_MSG, (STATE_MACHINE_FUNC) Drop, WPA_PTK,
-                        WPA_MACHINE_BASE);
-
-       StateMachineSetAction(S, WPA_PTK, MT2_EAPPacket,
-                             (STATE_MACHINE_FUNC) WpaEAPPacketAction);
-       StateMachineSetAction(S, WPA_PTK, MT2_EAPOLStart,
-                             (STATE_MACHINE_FUNC) WpaEAPOLStartAction);
-       StateMachineSetAction(S, WPA_PTK, MT2_EAPOLLogoff,
-                             (STATE_MACHINE_FUNC) WpaEAPOLLogoffAction);
-       StateMachineSetAction(S, WPA_PTK, MT2_EAPOLKey,
-                             (STATE_MACHINE_FUNC) WpaEAPOLKeyAction);
-       StateMachineSetAction(S, WPA_PTK, MT2_EAPOLASFAlert,
-                             (STATE_MACHINE_FUNC) WpaEAPOLASFAlertAction);
-}
-
-/*
-    ==========================================================================
-    Description:
-        this is state machine function.
-        When receiving EAP packets which is  for 802.1x authentication use.
-        Not use in PSK case
-    Return:
-    ==========================================================================
-*/
-void WpaEAPPacketAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
-{
-}
-
-void WpaEAPOLASFAlertAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
-{
-}
-
-void WpaEAPOLLogoffAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
-{
-}
-
-/*
-    ==========================================================================
-    Description:
-       Start 4-way HS when rcv EAPOL_START which may create by our driver in assoc.c
-    Return:
-    ==========================================================================
-*/
-void WpaEAPOLStartAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
-{
-       struct rt_mac_table_entry *pEntry;
-       struct rt_header_802_11 * pHeader;
-
-       DBGPRINT(RT_DEBUG_TRACE, ("WpaEAPOLStartAction ===> \n"));
-
-       pHeader = (struct rt_header_802_11 *) Elem->Msg;
-
-       /*For normaol PSK, we enqueue an EAPOL-Start command to trigger the process. */
-       if (Elem->MsgLen == 6)
-               pEntry = MacTableLookup(pAd, Elem->Msg);
-       else {
-               pEntry = MacTableLookup(pAd, pHeader->Addr2);
-       }
-
-       if (pEntry) {
-               DBGPRINT(RT_DEBUG_TRACE,
-                        (" PortSecured(%d), WpaState(%d), AuthMode(%d), PMKID_CacheIdx(%d) \n",
-                         pEntry->PortSecured, pEntry->WpaState,
-                         pEntry->AuthMode, pEntry->PMKID_CacheIdx));
-
-               if ((pEntry->PortSecured == WPA_802_1X_PORT_NOT_SECURED)
-                   && (pEntry->WpaState < AS_PTKSTART)
-                   && ((pEntry->AuthMode == Ndis802_11AuthModeWPAPSK)
-                       || (pEntry->AuthMode == Ndis802_11AuthModeWPA2PSK)
-                       || ((pEntry->AuthMode == Ndis802_11AuthModeWPA2)
-                           && (pEntry->PMKID_CacheIdx != ENTRY_NOT_FOUND)))) {
-                       pEntry->PrivacyFilter = Ndis802_11PrivFilter8021xWEP;
-                       pEntry->WpaState = AS_INITPSK;
-                       pEntry->PortSecured = WPA_802_1X_PORT_NOT_SECURED;
-                       NdisZeroMemory(pEntry->R_Counter,
-                                      sizeof(pEntry->R_Counter));
-                       pEntry->ReTryCounter = PEER_MSG1_RETRY_TIMER_CTR;
-
-                       WPAStart4WayHS(pAd, pEntry, PEER_MSG1_RETRY_EXEC_INTV);
-               }
-       }
-}
-
-/*
-    ==========================================================================
-    Description:
-        This is state machine function.
-        When receiving EAPOL packets which is  for 802.1x key management.
-        Use both in WPA, and WPAPSK case.
-        In this function, further dispatch to different functions according to the received packet.  3 categories are :
-          1.  normal 4-way pairwisekey and 2-way groupkey handshake
-          2.  MIC error (Countermeasures attack)  report packet from STA.
-          3.  Request for pairwise/group key update from STA
-    Return:
-    ==========================================================================
-*/
-void WpaEAPOLKeyAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
-{
-       struct rt_mac_table_entry *pEntry;
-       struct rt_header_802_11 * pHeader;
-       struct rt_eapol_packet * pEapol_packet;
-       struct rt_key_info peerKeyInfo;
-
-       DBGPRINT(RT_DEBUG_TRACE, ("WpaEAPOLKeyAction ===>\n"));
-
-       pHeader = (struct rt_header_802_11 *) Elem->Msg;
-       pEapol_packet =
-           (struct rt_eapol_packet *) & Elem->Msg[LENGTH_802_11 + LENGTH_802_1_H];
-
-       NdisZeroMemory((u8 *)& peerKeyInfo, sizeof(peerKeyInfo));
-       NdisMoveMemory((u8 *)& peerKeyInfo,
-                      (u8 *)& pEapol_packet->KeyDesc.KeyInfo,
-                      sizeof(struct rt_key_info));
-
-       hex_dump("Received Eapol frame", (unsigned char *)pEapol_packet,
-                (Elem->MsgLen - LENGTH_802_11 - LENGTH_802_1_H));
-
-       *((u16 *) & peerKeyInfo) = cpu2le16(*((u16 *) & peerKeyInfo));
-
-       do {
-               pEntry = MacTableLookup(pAd, pHeader->Addr2);
-
-               if (!pEntry
-                   || ((!pEntry->ValidAsCLI) && (!pEntry->ValidAsApCli)))
-                       break;
-
-               if (pEntry->AuthMode < Ndis802_11AuthModeWPA)
-                       break;
-
-               DBGPRINT(RT_DEBUG_TRACE,
-                       ("Receive EAPoL-Key frame from STA %pMF\n",
-                               pEntry->Addr));
-
-               if (((pEapol_packet->ProVer != EAPOL_VER)
-                    && (pEapol_packet->ProVer != EAPOL_VER2))
-                   || ((pEapol_packet->KeyDesc.Type != WPA1_KEY_DESC)
-                       && (pEapol_packet->KeyDesc.Type != WPA2_KEY_DESC))) {
-                       DBGPRINT(RT_DEBUG_ERROR,
-                                ("Key descripter does not match with WPA rule\n"));
-                       break;
-               }
-               /* The value 1 shall be used for all EAPOL-Key frames to and from a STA when */
-               /* neither the group nor pairwise ciphers are CCMP for Key Descriptor 1. */
-               if ((pEntry->WepStatus == Ndis802_11Encryption2Enabled)
-                   && (peerKeyInfo.KeyDescVer != DESC_TYPE_TKIP)) {
-                       DBGPRINT(RT_DEBUG_ERROR,
-                                ("Key descripter version not match(TKIP) \n"));
-                       break;
-               }
-               /* The value 2 shall be used for all EAPOL-Key frames to and from a STA when */
-               /* either the pairwise or the group cipher is AES-CCMP for Key Descriptor 2. */
-               else if ((pEntry->WepStatus == Ndis802_11Encryption3Enabled)
-                        && (peerKeyInfo.KeyDescVer != DESC_TYPE_AES)) {
-                       DBGPRINT(RT_DEBUG_ERROR,
-                                ("Key descripter version not match(AES) \n"));
-                       break;
-               }
-               /* Check if this STA is in class 3 state and the WPA state is started */
-               if ((pEntry->Sst == SST_ASSOC)
-                   && (pEntry->WpaState >= AS_INITPSK)) {
-                       /* Check the Key Ack (bit 7) of the Key Information to determine the Authenticator */
-                       /* or not. */
-                       /* An EAPOL-Key frame that is sent by the Supplicant in response to an EAPOL- */
-                       /* Key frame from the Authenticator must not have the Ack bit set. */
-                       if (peerKeyInfo.KeyAck == 1) {
-                               /* The frame is snet by Authenticator. */
-                               /* So the Supplicant side shall handle this. */
-
-                               if ((peerKeyInfo.Secure == 0)
-                                   && (peerKeyInfo.Request == 0)
-                                   && (peerKeyInfo.Error == 0)
-                                   && (peerKeyInfo.KeyType == PAIRWISEKEY)) {
-                                       /* Process 1. the message 1 of 4-way HS in WPA or WPA2 */
-                                       /*                        EAPOL-Key(0,0,1,0,P,0,0,ANonce,0,DataKD_M1) */
-                                       /*                 2. the message 3 of 4-way HS in WPA */
-                                       /*                        EAPOL-Key(0,1,1,1,P,0,KeyRSC,ANonce,MIC,DataKD_M3) */
-                                       if (peerKeyInfo.KeyMic == 0)
-                                               PeerPairMsg1Action(pAd, pEntry,
-                                                                  Elem);
-                                       else
-                                               PeerPairMsg3Action(pAd, pEntry,
-                                                                  Elem);
-                               } else if ((peerKeyInfo.Secure == 1)
-                                          && (peerKeyInfo.KeyMic == 1)
-                                          && (peerKeyInfo.Request == 0)
-                                          && (peerKeyInfo.Error == 0)) {
-                                       /* Process 1. the message 3 of 4-way HS in WPA2 */
-                                       /*                        EAPOL-Key(1,1,1,1,P,0,KeyRSC,ANonce,MIC,DataKD_M3) */
-                                       /*                 2. the message 1 of group KS in WPA or WPA2 */
-                                       /*                        EAPOL-Key(1,1,1,0,G,0,Key RSC,0, MIC,GTK[N]) */
-                                       if (peerKeyInfo.KeyType == PAIRWISEKEY)
-                                               PeerPairMsg3Action(pAd, pEntry,
-                                                                  Elem);
-                                       else
-                                               PeerGroupMsg1Action(pAd, pEntry,
-                                                                   Elem);
-                               }
-                       } else {
-                               /* The frame is snet by Supplicant. */
-                               /* So the Authenticator side shall handle this. */
-                               if ((peerKeyInfo.Request == 0) &&
-                                   (peerKeyInfo.Error == 0) &&
-                                   (peerKeyInfo.KeyMic == 1)) {
-                                       if (peerKeyInfo.Secure == 0
-                                           && peerKeyInfo.KeyType ==
-                                           PAIRWISEKEY) {
-                                               /* EAPOL-Key(0,1,0,0,P,0,0,SNonce,MIC,Data) */
-                                               /* Process 1. message 2 of 4-way HS in WPA or WPA2 */
-                                               /*                 2. message 4 of 4-way HS in WPA */
-                                               if (CONV_ARRARY_TO_u16
-                                                   (pEapol_packet->KeyDesc.
-                                                    KeyDataLen) == 0) {
-                                                       PeerPairMsg4Action(pAd,
-                                                                          pEntry,
-                                                                          Elem);
-                                               } else {
-                                                       PeerPairMsg2Action(pAd,
-                                                                          pEntry,
-                                                                          Elem);
-                                               }
-                                       } else if (peerKeyInfo.Secure == 1
-                                                  && peerKeyInfo.KeyType ==
-                                                  PAIRWISEKEY) {
-                                               /* EAPOL-Key(1,1,0,0,P,0,0,0,MIC,0) */
-                                               /* Process message 4 of 4-way HS in WPA2 */
-                                               PeerPairMsg4Action(pAd, pEntry,
-                                                                  Elem);
-                                       } else if (peerKeyInfo.Secure == 1
-                                                  && peerKeyInfo.KeyType ==
-                                                  GROUPKEY) {
-                                               /* EAPOL-Key(1,1,0,0,G,0,0,0,MIC,0) */
-                                               /* Process message 2 of Group key HS in WPA or WPA2 */
-                                               PeerGroupMsg2Action(pAd, pEntry,
-                                                                   &Elem->
-                                                                   Msg
-                                                                   [LENGTH_802_11],
-                                                                   (Elem->
-                                                                    MsgLen -
-                                                                    LENGTH_802_11));
-                                       }
-                               }
-                       }
-               }
-       } while (FALSE);
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Copy frame from waiting queue into relative ring buffer and set
-       appropriate ASIC register to kick hardware encryption before really
-       sent out to air.
-
-       Arguments:
-               pAd             Pointer to our adapter
-               void *  Pointer to outgoing Ndis frame
-               NumberOfFrag    Number of fragment required
-
-       Return Value:
-               None
-
-       Note:
-
-       ========================================================================
-*/
-void RTMPToWirelessSta(struct rt_rtmp_adapter *pAd,
-                      struct rt_mac_table_entry *pEntry,
-                      u8 *pHeader802_3,
-                      u32 HdrLen,
-                      u8 *pData, u32 DataLen, IN BOOLEAN bClearFrame)
-{
-       void *pPacket;
-       int Status;
-
-       if ((!pEntry) || ((!pEntry->ValidAsCLI) && (!pEntry->ValidAsApCli)))
-               return;
-
-       do {
-               /* build a NDIS packet */
-               Status =
-                   RTMPAllocateNdisPacket(pAd, &pPacket, pHeader802_3, HdrLen,
-                                          pData, DataLen);
-               if (Status != NDIS_STATUS_SUCCESS)
-                       break;
-
-               if (bClearFrame)
-                       RTMP_SET_PACKET_CLEAR_EAP_FRAME(pPacket, 1);
-               else
-                       RTMP_SET_PACKET_CLEAR_EAP_FRAME(pPacket, 0);
-               {
-                       RTMP_SET_PACKET_SOURCE(pPacket, PKTSRC_NDIS);
-
-                       RTMP_SET_PACKET_NET_DEVICE_MBSSID(pPacket, MAIN_MBSSID);        /* set a default value */
-                       if (pEntry->apidx != 0)
-                               RTMP_SET_PACKET_NET_DEVICE_MBSSID(pPacket,
-                                                                 pEntry->
-                                                                 apidx);
-
-                       RTMP_SET_PACKET_WCID(pPacket, (u8)pEntry->Aid);
-                       RTMP_SET_PACKET_MOREDATA(pPacket, FALSE);
-               }
-
-               {
-                       /* send out the packet */
-                       Status = STASendPacket(pAd, pPacket);
-                       if (Status == NDIS_STATUS_SUCCESS) {
-                               u8 Index;
-
-                               /* Dequeue one frame from TxSwQueue0..3 queue and process it */
-                               /* There are three place calling dequeue for TX ring. */
-                               /* 1. Here, right after queueing the frame. */
-                               /* 2. At the end of TxRingTxDone service routine. */
-                               /* 3. Upon NDIS call RTMPSendPackets */
-                               if ((!RTMP_TEST_FLAG
-                                    (pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
-                                   &&
-                                   (!RTMP_TEST_FLAG
-                                    (pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS))) {
-                                       for (Index = 0; Index < 5; Index++)
-                                               if (pAd->TxSwQueue[Index].
-                                                   Number > 0)
-                                                       RTMPDeQueuePacket(pAd,
-                                                                         FALSE,
-                                                                         Index,
-                                                                         MAX_TX_PROCESS);
-                               }
-                       }
-               }
-
-       } while (FALSE);
-}
-
-/*
-    ==========================================================================
-    Description:
-        This is a function to initialize 4-way handshake
-
-    Return:
-
-    ==========================================================================
-*/
-void WPAStart4WayHS(struct rt_rtmp_adapter *pAd,
-                   struct rt_mac_table_entry *pEntry, unsigned long TimeInterval)
-{
-       u8 Header802_3[14];
-       struct rt_eapol_packet EAPOLPKT;
-       u8 *pBssid = NULL;
-       u8 group_cipher = Ndis802_11WEPDisabled;
-
-       DBGPRINT(RT_DEBUG_TRACE, ("===> WPAStart4WayHS\n"));
-
-       if (RTMP_TEST_FLAG
-           (pAd,
-            fRTMP_ADAPTER_RESET_IN_PROGRESS | fRTMP_ADAPTER_HALT_IN_PROGRESS))
-       {
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("[ERROR]WPAStart4WayHS : The interface is closed...\n"));
-               return;
-       }
-
-       if (pBssid == NULL) {
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("[ERROR]WPAStart4WayHS : No corresponding Authenticator.\n"));
-               return;
-       }
-       /* Check the status */
-       if ((pEntry->WpaState > AS_PTKSTART) || (pEntry->WpaState < AS_INITPMK)) {
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("[ERROR]WPAStart4WayHS : Not expect calling\n"));
-               return;
-       }
-
-       /* Increment replay counter by 1 */
-       ADD_ONE_To_64BIT_VAR(pEntry->R_Counter);
-
-       /* Randomly generate ANonce */
-       GenRandom(pAd, (u8 *) pBssid, pEntry->ANonce);
-
-       /* Construct EAPoL message - Pairwise Msg 1 */
-       /* EAPOL-Key(0,0,1,0,P,0,0,ANonce,0,DataKD_M1) */
-       NdisZeroMemory(&EAPOLPKT, sizeof(struct rt_eapol_packet));
-       ConstructEapolMsg(pEntry, group_cipher, EAPOL_PAIR_MSG_1, 0,    /* Default key index */
-                         pEntry->ANonce, NULL, /* TxRSC */
-                         NULL, /* GTK */
-                         NULL, /* RSNIE */
-                         0,    /* RSNIE length */
-                         &EAPOLPKT);
-
-       /* Make outgoing frame */
-       MAKE_802_3_HEADER(Header802_3, pEntry->Addr, pBssid, EAPOL);
-       RTMPToWirelessSta(pAd, pEntry, Header802_3,
-                         LENGTH_802_3, (u8 *)& EAPOLPKT,
-                         CONV_ARRARY_TO_u16(EAPOLPKT.Body_Len) + 4,
-                         (pEntry->PortSecured ==
-                          WPA_802_1X_PORT_SECURED) ? FALSE : TRUE);
-
-       /* Trigger Retry Timer */
-       RTMPModTimer(&pEntry->RetryTimer, TimeInterval);
-
-       /* Update State */
-       pEntry->WpaState = AS_PTKSTART;
-
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("<=== WPAStart4WayHS: send Msg1 of 4-way \n"));
-
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Process Pairwise key Msg-1 of 4-way handshaking and send Msg-2
-
-       Arguments:
-               pAd                     Pointer to our adapter
-               Elem            Message body
-
-       Return Value:
-               None
-
-       Note:
-
-       ========================================================================
-*/
-void PeerPairMsg1Action(struct rt_rtmp_adapter *pAd,
-                       struct rt_mac_table_entry *pEntry, struct rt_mlme_queue_elem *Elem)
-{
-       u8 PTK[80];
-       u8 Header802_3[14];
-       struct rt_eapol_packet * pMsg1;
-       u32 MsgLen;
-       struct rt_eapol_packet EAPOLPKT;
-       u8 *pCurrentAddr = NULL;
-       u8 *pmk_ptr = NULL;
-       u8 group_cipher = Ndis802_11WEPDisabled;
-       u8 *rsnie_ptr = NULL;
-       u8 rsnie_len = 0;
-
-       DBGPRINT(RT_DEBUG_TRACE, ("===> PeerPairMsg1Action \n"));
-
-       if ((!pEntry) || ((!pEntry->ValidAsCLI) && (!pEntry->ValidAsApCli)))
-               return;
-
-       if (Elem->MsgLen <
-           (LENGTH_802_11 + LENGTH_802_1_H + LENGTH_EAPOL_H +
-            sizeof(struct rt_key_descripter) - MAX_LEN_OF_RSNIE - 2))
-               return;
-
-       {
-               pCurrentAddr = pAd->CurrentAddress;
-               pmk_ptr = pAd->StaCfg.PMK;
-               group_cipher = pAd->StaCfg.GroupCipher;
-               rsnie_ptr = pAd->StaCfg.RSN_IE;
-               rsnie_len = pAd->StaCfg.RSNIE_Len;
-       }
-
-       /* Store the received frame */
-       pMsg1 = (struct rt_eapol_packet *) & Elem->Msg[LENGTH_802_11 + LENGTH_802_1_H];
-       MsgLen = Elem->MsgLen - LENGTH_802_11 - LENGTH_802_1_H;
-
-       /* Sanity Check peer Pairwise message 1 - Replay Counter */
-       if (PeerWpaMessageSanity(pAd, pMsg1, MsgLen, EAPOL_PAIR_MSG_1, pEntry)
-           == FALSE)
-               return;
-
-       /* Store Replay counter, it will use to verify message 3 and construct message 2 */
-       NdisMoveMemory(pEntry->R_Counter, pMsg1->KeyDesc.ReplayCounter,
-                      LEN_KEY_DESC_REPLAY);
-
-       /* Store ANonce */
-       NdisMoveMemory(pEntry->ANonce, pMsg1->KeyDesc.KeyNonce,
-                      LEN_KEY_DESC_NONCE);
-
-       /* Generate random SNonce */
-       GenRandom(pAd, (u8 *) pCurrentAddr, pEntry->SNonce);
-
-       {
-               /* Calculate PTK(ANonce, SNonce) */
-               WpaDerivePTK(pAd,
-                            pmk_ptr,
-                            pEntry->ANonce,
-                            pEntry->Addr,
-                            pEntry->SNonce, pCurrentAddr, PTK, LEN_PTK);
-
-               /* Save key to PTK entry */
-               NdisMoveMemory(pEntry->PTK, PTK, LEN_PTK);
-       }
-
-       /* Update WpaState */
-       pEntry->WpaState = AS_PTKINIT_NEGOTIATING;
-
-       /* Construct EAPoL message - Pairwise Msg 2 */
-       /*  EAPOL-Key(0,1,0,0,P,0,0,SNonce,MIC,DataKD_M2) */
-       NdisZeroMemory(&EAPOLPKT, sizeof(struct rt_eapol_packet));
-       ConstructEapolMsg(pEntry, group_cipher, EAPOL_PAIR_MSG_2, 0,    /* DefaultKeyIdx */
-                         pEntry->SNonce, NULL, /* TxRsc */
-                         NULL, /* GTK */
-                         (u8 *) rsnie_ptr, rsnie_len, &EAPOLPKT);
-
-       /* Make outgoing frame */
-       MAKE_802_3_HEADER(Header802_3, pEntry->Addr, pCurrentAddr, EAPOL);
-
-       RTMPToWirelessSta(pAd, pEntry,
-                         Header802_3, sizeof(Header802_3), (u8 *)& EAPOLPKT,
-                         CONV_ARRARY_TO_u16(EAPOLPKT.Body_Len) + 4, TRUE);
-
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("<=== PeerPairMsg1Action: send Msg2 of 4-way \n"));
-}
-
-/*
-    ==========================================================================
-    Description:
-        When receiving the second packet of 4-way pairwisekey handshake.
-    Return:
-    ==========================================================================
-*/
-void PeerPairMsg2Action(struct rt_rtmp_adapter *pAd,
-                       struct rt_mac_table_entry *pEntry, struct rt_mlme_queue_elem *Elem)
-{
-       u8 PTK[80];
-       BOOLEAN Cancelled;
-       struct rt_header_802_11 * pHeader;
-       struct rt_eapol_packet EAPOLPKT;
-       struct rt_eapol_packet * pMsg2;
-       u32 MsgLen;
-       u8 Header802_3[LENGTH_802_3];
-       u8 TxTsc[6];
-       u8 *pBssid = NULL;
-       u8 *pmk_ptr = NULL;
-       u8 *gtk_ptr = NULL;
-       u8 default_key = 0;
-       u8 group_cipher = Ndis802_11WEPDisabled;
-       u8 *rsnie_ptr = NULL;
-       u8 rsnie_len = 0;
-
-       DBGPRINT(RT_DEBUG_TRACE, ("===> PeerPairMsg2Action \n"));
-
-       if ((!pEntry) || (!pEntry->ValidAsCLI))
-               return;
-
-       if (Elem->MsgLen <
-           (LENGTH_802_11 + LENGTH_802_1_H + LENGTH_EAPOL_H +
-            sizeof(struct rt_key_descripter) - MAX_LEN_OF_RSNIE - 2))
-               return;
-
-       /* check Entry in valid State */
-       if (pEntry->WpaState < AS_PTKSTART)
-               return;
-
-       /* pointer to 802.11 header */
-       pHeader = (struct rt_header_802_11 *) Elem->Msg;
-
-       /* skip 802.11_header(24-byte) and LLC_header(8) */
-       pMsg2 = (struct rt_eapol_packet *) & Elem->Msg[LENGTH_802_11 + LENGTH_802_1_H];
-       MsgLen = Elem->MsgLen - LENGTH_802_11 - LENGTH_802_1_H;
-
-       /* Store SNonce */
-       NdisMoveMemory(pEntry->SNonce, pMsg2->KeyDesc.KeyNonce,
-                      LEN_KEY_DESC_NONCE);
-
-       {
-               /* Derive PTK */
-               WpaDerivePTK(pAd, (u8 *) pmk_ptr, pEntry->ANonce,       /* ANONCE */
-                            (u8 *) pBssid, pEntry->SNonce,     /* SNONCE */
-                            pEntry->Addr, PTK, LEN_PTK);
-
-               NdisMoveMemory(pEntry->PTK, PTK, LEN_PTK);
-       }
-
-       /* Sanity Check peer Pairwise message 2 - Replay Counter, MIC, RSNIE */
-       if (PeerWpaMessageSanity(pAd, pMsg2, MsgLen, EAPOL_PAIR_MSG_2, pEntry)
-           == FALSE)
-               return;
-
-       do {
-               /* delete retry timer */
-               RTMPCancelTimer(&pEntry->RetryTimer, &Cancelled);
-
-               /* Change state */
-               pEntry->WpaState = AS_PTKINIT_NEGOTIATING;
-
-               /* Increment replay counter by 1 */
-               ADD_ONE_To_64BIT_VAR(pEntry->R_Counter);
-
-               /* Construct EAPoL message - Pairwise Msg 3 */
-               NdisZeroMemory(&EAPOLPKT, sizeof(struct rt_eapol_packet));
-               ConstructEapolMsg(pEntry,
-                                 group_cipher,
-                                 EAPOL_PAIR_MSG_3,
-                                 default_key,
-                                 pEntry->ANonce,
-                                 TxTsc,
-                                 (u8 *) gtk_ptr,
-                                 (u8 *) rsnie_ptr, rsnie_len, &EAPOLPKT);
-
-               /* Make outgoing frame */
-               MAKE_802_3_HEADER(Header802_3, pEntry->Addr, pBssid, EAPOL);
-               RTMPToWirelessSta(pAd, pEntry, Header802_3, LENGTH_802_3,
-                                 (u8 *)& EAPOLPKT,
-                                 CONV_ARRARY_TO_u16(EAPOLPKT.Body_Len) + 4,
-                                 (pEntry->PortSecured ==
-                                  WPA_802_1X_PORT_SECURED) ? FALSE : TRUE);
-
-               pEntry->ReTryCounter = PEER_MSG3_RETRY_TIMER_CTR;
-               RTMPSetTimer(&pEntry->RetryTimer, PEER_MSG3_RETRY_EXEC_INTV);
-
-               /* Update State */
-               pEntry->WpaState = AS_PTKINIT_NEGOTIATING;
-       } while (FALSE);
-
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("<=== PeerPairMsg2Action: send Msg3 of 4-way \n"));
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Process Pairwise key Msg 3 of 4-way handshaking and send Msg 4
-
-       Arguments:
-               pAd     Pointer to our adapter
-               Elem            Message body
-
-       Return Value:
-               None
-
-       Note:
-
-       ========================================================================
-*/
-void PeerPairMsg3Action(struct rt_rtmp_adapter *pAd,
-                       struct rt_mac_table_entry *pEntry, struct rt_mlme_queue_elem *Elem)
-{
-       struct rt_header_802_11 * pHeader;
-       u8 Header802_3[14];
-       struct rt_eapol_packet EAPOLPKT;
-       struct rt_eapol_packet * pMsg3;
-       u32 MsgLen;
-       u8 *pCurrentAddr = NULL;
-       u8 group_cipher = Ndis802_11WEPDisabled;
-
-       DBGPRINT(RT_DEBUG_TRACE, ("===> PeerPairMsg3Action \n"));
-
-       if ((!pEntry) || ((!pEntry->ValidAsCLI) && (!pEntry->ValidAsApCli)))
-               return;
-
-       if (Elem->MsgLen <
-           (LENGTH_802_11 + LENGTH_802_1_H + LENGTH_EAPOL_H +
-            sizeof(struct rt_key_descripter) - MAX_LEN_OF_RSNIE - 2))
-               return;
-
-       {
-               pCurrentAddr = pAd->CurrentAddress;
-               group_cipher = pAd->StaCfg.GroupCipher;
-
-       }
-
-       /* Record 802.11 header & the received EAPOL packet Msg3 */
-       pHeader = (struct rt_header_802_11 *) Elem->Msg;
-       pMsg3 = (struct rt_eapol_packet *) & Elem->Msg[LENGTH_802_11 + LENGTH_802_1_H];
-       MsgLen = Elem->MsgLen - LENGTH_802_11 - LENGTH_802_1_H;
-
-       /* Sanity Check peer Pairwise message 3 - Replay Counter, MIC, RSNIE */
-       if (PeerWpaMessageSanity(pAd, pMsg3, MsgLen, EAPOL_PAIR_MSG_3, pEntry)
-           == FALSE)
-               return;
-
-       /* Save Replay counter, it will use construct message 4 */
-       NdisMoveMemory(pEntry->R_Counter, pMsg3->KeyDesc.ReplayCounter,
-                      LEN_KEY_DESC_REPLAY);
-
-       /* Double check ANonce */
-       if (!NdisEqualMemory
-           (pEntry->ANonce, pMsg3->KeyDesc.KeyNonce, LEN_KEY_DESC_NONCE)) {
-               return;
-       }
-       /* Construct EAPoL message - Pairwise Msg 4 */
-       NdisZeroMemory(&EAPOLPKT, sizeof(struct rt_eapol_packet));
-       ConstructEapolMsg(pEntry, group_cipher, EAPOL_PAIR_MSG_4, 0,    /* group key index not used in message 4 */
-                         NULL, /* Nonce not used in message 4 */
-                         NULL, /* TxRSC not used in message 4 */
-                         NULL, /* GTK not used in message 4 */
-                         NULL, /* RSN IE not used in message 4 */
-                         0, &EAPOLPKT);
-
-       /* Update WpaState */
-       pEntry->WpaState = AS_PTKINITDONE;
-
-       /* Update pairwise key */
-       {
-               struct rt_cipher_key *pSharedKey;
-
-               pSharedKey = &pAd->SharedKey[BSS0][0];
-
-               NdisMoveMemory(pAd->StaCfg.PTK, pEntry->PTK, LEN_PTK);
-
-               /* Prepare pair-wise key information into shared key table */
-               NdisZeroMemory(pSharedKey, sizeof(struct rt_cipher_key));
-               pSharedKey->KeyLen = LEN_TKIP_EK;
-               NdisMoveMemory(pSharedKey->Key, &pAd->StaCfg.PTK[32],
-                              LEN_TKIP_EK);
-               NdisMoveMemory(pSharedKey->RxMic, &pAd->StaCfg.PTK[48],
-                              LEN_TKIP_RXMICK);
-               NdisMoveMemory(pSharedKey->TxMic,
-                              &pAd->StaCfg.PTK[48 + LEN_TKIP_RXMICK],
-                              LEN_TKIP_TXMICK);
-
-               /* Decide its ChiperAlg */
-               if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
-                       pSharedKey->CipherAlg = CIPHER_TKIP;
-               else if (pAd->StaCfg.PairCipher == Ndis802_11Encryption3Enabled)
-                       pSharedKey->CipherAlg = CIPHER_AES;
-               else
-                       pSharedKey->CipherAlg = CIPHER_NONE;
-
-               /* Update these related information to struct rt_mac_table_entry */
-               pEntry = &pAd->MacTab.Content[BSSID_WCID];
-               NdisMoveMemory(pEntry->PairwiseKey.Key, &pAd->StaCfg.PTK[32],
-                              LEN_TKIP_EK);
-               NdisMoveMemory(pEntry->PairwiseKey.RxMic, &pAd->StaCfg.PTK[48],
-                              LEN_TKIP_RXMICK);
-               NdisMoveMemory(pEntry->PairwiseKey.TxMic,
-                              &pAd->StaCfg.PTK[48 + LEN_TKIP_RXMICK],
-                              LEN_TKIP_TXMICK);
-               pEntry->PairwiseKey.CipherAlg = pSharedKey->CipherAlg;
-
-               /* Update pairwise key information to ASIC Shared Key Table */
-               AsicAddSharedKeyEntry(pAd,
-                                     BSS0,
-                                     0,
-                                     pSharedKey->CipherAlg,
-                                     pSharedKey->Key,
-                                     pSharedKey->TxMic, pSharedKey->RxMic);
-
-               /* Update ASIC WCID attribute table and IVEIV table */
-               RTMPAddWcidAttributeEntry(pAd,
-                                         BSS0,
-                                         0, pSharedKey->CipherAlg, pEntry);
-
-       }
-
-       /* open 802.1x port control and privacy filter */
-       if (pEntry->AuthMode == Ndis802_11AuthModeWPA2PSK ||
-           pEntry->AuthMode == Ndis802_11AuthModeWPA2) {
-               pEntry->PortSecured = WPA_802_1X_PORT_SECURED;
-               pEntry->PrivacyFilter = Ndis802_11PrivFilterAcceptAll;
-
-               STA_PORT_SECURED(pAd);
-               /* Indicate Connected for GUI */
-               pAd->IndicateMediaState = NdisMediaStateConnected;
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("PeerPairMsg3Action: AuthMode(%s) PairwiseCipher(%s) GroupCipher(%s) \n",
-                         GetAuthMode(pEntry->AuthMode),
-                         GetEncryptType(pEntry->WepStatus),
-                         GetEncryptType(group_cipher)));
-       } else {
-       }
-
-       /* Init 802.3 header and send out */
-       MAKE_802_3_HEADER(Header802_3, pEntry->Addr, pCurrentAddr, EAPOL);
-       RTMPToWirelessSta(pAd, pEntry,
-                         Header802_3, sizeof(Header802_3),
-                         (u8 *)& EAPOLPKT,
-                         CONV_ARRARY_TO_u16(EAPOLPKT.Body_Len) + 4, TRUE);
-
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("<=== PeerPairMsg3Action: send Msg4 of 4-way \n"));
-}
-
-/*
-    ==========================================================================
-    Description:
-        When receiving the last packet of 4-way pairwisekey handshake.
-        Initialize 2-way groupkey handshake following.
-    Return:
-    ==========================================================================
-*/
-void PeerPairMsg4Action(struct rt_rtmp_adapter *pAd,
-                       struct rt_mac_table_entry *pEntry, struct rt_mlme_queue_elem *Elem)
-{
-       struct rt_eapol_packet * pMsg4;
-       struct rt_header_802_11 * pHeader;
-       u32 MsgLen;
-       BOOLEAN Cancelled;
-       u8 group_cipher = Ndis802_11WEPDisabled;
-
-       DBGPRINT(RT_DEBUG_TRACE, ("===> PeerPairMsg4Action\n"));
-
-       do {
-               if ((!pEntry) || (!pEntry->ValidAsCLI))
-                       break;
-
-               if (Elem->MsgLen <
-                   (LENGTH_802_11 + LENGTH_802_1_H + LENGTH_EAPOL_H +
-                    sizeof(struct rt_key_descripter) - MAX_LEN_OF_RSNIE - 2))
-                       break;
-
-               if (pEntry->WpaState < AS_PTKINIT_NEGOTIATING)
-                       break;
-
-               /* pointer to 802.11 header */
-               pHeader = (struct rt_header_802_11 *) Elem->Msg;
-
-               /* skip 802.11_header(24-byte) and LLC_header(8) */
-               pMsg4 =
-                   (struct rt_eapol_packet *) & Elem->Msg[LENGTH_802_11 + LENGTH_802_1_H];
-               MsgLen = Elem->MsgLen - LENGTH_802_11 - LENGTH_802_1_H;
-
-               /* Sanity Check peer Pairwise message 4 - Replay Counter, MIC */
-               if (PeerWpaMessageSanity
-                   (pAd, pMsg4, MsgLen, EAPOL_PAIR_MSG_4, pEntry) == FALSE)
-                       break;
-
-               /* 3. uses the MLME.SETKEYS.request to configure PTK into MAC */
-               NdisZeroMemory(&pEntry->PairwiseKey, sizeof(struct rt_cipher_key));
-
-               /* reset IVEIV in Asic */
-               AsicUpdateWCIDIVEIV(pAd, pEntry->Aid, 1, 0);
-
-               pEntry->PairwiseKey.KeyLen = LEN_TKIP_EK;
-               NdisMoveMemory(pEntry->PairwiseKey.Key, &pEntry->PTK[32],
-                              LEN_TKIP_EK);
-               NdisMoveMemory(pEntry->PairwiseKey.RxMic,
-                              &pEntry->PTK[TKIP_AP_RXMICK_OFFSET],
-                              LEN_TKIP_RXMICK);
-               NdisMoveMemory(pEntry->PairwiseKey.TxMic,
-                              &pEntry->PTK[TKIP_AP_TXMICK_OFFSET],
-                              LEN_TKIP_TXMICK);
-
-               /* Set pairwise key to Asic */
-               {
-                       pEntry->PairwiseKey.CipherAlg = CIPHER_NONE;
-                       if (pEntry->WepStatus == Ndis802_11Encryption2Enabled)
-                               pEntry->PairwiseKey.CipherAlg = CIPHER_TKIP;
-                       else if (pEntry->WepStatus ==
-                                Ndis802_11Encryption3Enabled)
-                               pEntry->PairwiseKey.CipherAlg = CIPHER_AES;
-
-                       /* Add Pair-wise key to Asic */
-                       AsicAddPairwiseKeyEntry(pAd,
-                                               pEntry->Addr,
-                                               (u8)pEntry->Aid,
-                                               &pEntry->PairwiseKey);
-
-                       /* update WCID attribute table and IVEIV table for this entry */
-                       RTMPAddWcidAttributeEntry(pAd,
-                                                 pEntry->apidx,
-                                                 0,
-                                                 pEntry->PairwiseKey.CipherAlg,
-                                                 pEntry);
-               }
-
-               /* 4. upgrade state */
-               pEntry->PrivacyFilter = Ndis802_11PrivFilterAcceptAll;
-               pEntry->WpaState = AS_PTKINITDONE;
-               pEntry->PortSecured = WPA_802_1X_PORT_SECURED;
-
-               if (pEntry->AuthMode == Ndis802_11AuthModeWPA2 ||
-                   pEntry->AuthMode == Ndis802_11AuthModeWPA2PSK) {
-                       pEntry->GTKState = REKEY_ESTABLISHED;
-                       RTMPCancelTimer(&pEntry->RetryTimer, &Cancelled);
-
-                       /* send wireless event - for set key done WPA2 */
-                       if (pAd->CommonCfg.bWirelessEvent)
-                               RTMPSendWirelessEvent(pAd,
-                                                     IW_SET_KEY_DONE_WPA2_EVENT_FLAG,
-                                                     pEntry->Addr,
-                                                     pEntry->apidx, 0);
-
-                       DBGPRINT(RT_DEBUG_OFF,
-                                ("AP SETKEYS DONE - WPA2, AuthMode(%d)=%s, WepStatus(%d)=%s, GroupWepStatus(%d)=%s\n\n",
-                                 pEntry->AuthMode,
-                                 GetAuthMode(pEntry->AuthMode),
-                                 pEntry->WepStatus,
-                                 GetEncryptType(pEntry->WepStatus),
-                                 group_cipher, GetEncryptType(group_cipher)));
-               } else {
-                       /* 5. init Group 2-way handshake if necessary. */
-                       WPAStart2WayGroupHS(pAd, pEntry);
-
-                       pEntry->ReTryCounter = GROUP_MSG1_RETRY_TIMER_CTR;
-                       RTMPModTimer(&pEntry->RetryTimer,
-                                    PEER_MSG3_RETRY_EXEC_INTV);
-               }
-       } while (FALSE);
-
-}
-
-/*
-    ==========================================================================
-    Description:
-        This is a function to send the first packet of 2-way groupkey handshake
-    Return:
-
-    ==========================================================================
-*/
-void WPAStart2WayGroupHS(struct rt_rtmp_adapter *pAd, struct rt_mac_table_entry *pEntry)
-{
-       u8 Header802_3[14];
-       u8 TxTsc[6];
-       struct rt_eapol_packet EAPOLPKT;
-       u8 group_cipher = Ndis802_11WEPDisabled;
-       u8 default_key = 0;
-       u8 *gnonce_ptr = NULL;
-       u8 *gtk_ptr = NULL;
-       u8 *pBssid = NULL;
-
-       DBGPRINT(RT_DEBUG_TRACE, ("===> WPAStart2WayGroupHS\n"));
-
-       if ((!pEntry) || (!pEntry->ValidAsCLI))
-               return;
-
-       do {
-               /* Increment replay counter by 1 */
-               ADD_ONE_To_64BIT_VAR(pEntry->R_Counter);
-
-               /* Construct EAPoL message - Group Msg 1 */
-               NdisZeroMemory(&EAPOLPKT, sizeof(struct rt_eapol_packet));
-               ConstructEapolMsg(pEntry,
-                                 group_cipher,
-                                 EAPOL_GROUP_MSG_1,
-                                 default_key,
-                                 (u8 *) gnonce_ptr,
-                                 TxTsc, (u8 *) gtk_ptr, NULL, 0, &EAPOLPKT);
-
-               /* Make outgoing frame */
-               MAKE_802_3_HEADER(Header802_3, pEntry->Addr, pBssid, EAPOL);
-               RTMPToWirelessSta(pAd, pEntry,
-                                 Header802_3, LENGTH_802_3,
-                                 (u8 *)& EAPOLPKT,
-                                 CONV_ARRARY_TO_u16(EAPOLPKT.Body_Len) + 4,
-                                 FALSE);
-
-       } while (FALSE);
-
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("<=== WPAStart2WayGroupHS : send out Group Message 1 \n"));
-
-       return;
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Process Group key 2-way handshaking
-
-       Arguments:
-               pAd     Pointer to our adapter
-               Elem            Message body
-
-       Return Value:
-               None
-
-       Note:
-
-       ========================================================================
-*/
-void PeerGroupMsg1Action(struct rt_rtmp_adapter *pAd,
-                        struct rt_mac_table_entry *pEntry, struct rt_mlme_queue_elem *Elem)
-{
-       u8 Header802_3[14];
-       struct rt_eapol_packet EAPOLPKT;
-       struct rt_eapol_packet * pGroup;
-       u32 MsgLen;
-       BOOLEAN Cancelled;
-       u8 default_key = 0;
-       u8 group_cipher = Ndis802_11WEPDisabled;
-       u8 *pCurrentAddr = NULL;
-
-       DBGPRINT(RT_DEBUG_TRACE, ("===> PeerGroupMsg1Action \n"));
-
-       if ((!pEntry) || ((!pEntry->ValidAsCLI) && (!pEntry->ValidAsApCli)))
-               return;
-
-       {
-               pCurrentAddr = pAd->CurrentAddress;
-               group_cipher = pAd->StaCfg.GroupCipher;
-               default_key = pAd->StaCfg.DefaultKeyId;
-       }
-
-       /* Process Group Message 1 frame. skip 802.11 header(24) & LLC_SNAP header(8) */
-       pGroup = (struct rt_eapol_packet *) & Elem->Msg[LENGTH_802_11 + LENGTH_802_1_H];
-       MsgLen = Elem->MsgLen - LENGTH_802_11 - LENGTH_802_1_H;
-
-       /* Sanity Check peer group message 1 - Replay Counter, MIC, RSNIE */
-       if (PeerWpaMessageSanity(pAd, pGroup, MsgLen, EAPOL_GROUP_MSG_1, pEntry)
-           == FALSE)
-               return;
-
-       /* delete retry timer */
-       RTMPCancelTimer(&pEntry->RetryTimer, &Cancelled);
-
-       /* Save Replay counter, it will use to construct message 2 */
-       NdisMoveMemory(pEntry->R_Counter, pGroup->KeyDesc.ReplayCounter,
-                      LEN_KEY_DESC_REPLAY);
-
-       /* Construct EAPoL message - Group Msg 2 */
-       NdisZeroMemory(&EAPOLPKT, sizeof(struct rt_eapol_packet));
-       ConstructEapolMsg(pEntry, group_cipher, EAPOL_GROUP_MSG_2, default_key, NULL,   /* Nonce not used */
-                         NULL, /* TxRSC not used */
-                         NULL, /* GTK not used */
-                         NULL, /* RSN IE not used */
-                         0, &EAPOLPKT);
-
-       /* open 802.1x port control and privacy filter */
-       pEntry->PortSecured = WPA_802_1X_PORT_SECURED;
-       pEntry->PrivacyFilter = Ndis802_11PrivFilterAcceptAll;
-
-       STA_PORT_SECURED(pAd);
-       /* Indicate Connected for GUI */
-       pAd->IndicateMediaState = NdisMediaStateConnected;
-
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("PeerGroupMsg1Action: AuthMode(%s) PairwiseCipher(%s) GroupCipher(%s) \n",
-                 GetAuthMode(pEntry->AuthMode),
-                 GetEncryptType(pEntry->WepStatus),
-                 GetEncryptType(group_cipher)));
-
-       /* init header and Fill Packet and send Msg 2 to authenticator */
-       MAKE_802_3_HEADER(Header802_3, pEntry->Addr, pCurrentAddr, EAPOL);
-       RTMPToWirelessSta(pAd, pEntry,
-                         Header802_3, sizeof(Header802_3),
-                         (u8 *)& EAPOLPKT,
-                         CONV_ARRARY_TO_u16(EAPOLPKT.Body_Len) + 4, FALSE);
-
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("<=== PeerGroupMsg1Action: sned group message 2\n"));
-}
-
-/*
-    ==========================================================================
-    Description:
-        When receiving the last packet of 2-way groupkey handshake.
-    Return:
-    ==========================================================================
-*/
-void PeerGroupMsg2Action(struct rt_rtmp_adapter *pAd,
-                        struct rt_mac_table_entry *pEntry,
-                        void * Msg, u32 MsgLen)
-{
-       u32 Len;
-       u8 *pData;
-       BOOLEAN Cancelled;
-       struct rt_eapol_packet * pMsg2;
-       u8 group_cipher = Ndis802_11WEPDisabled;
-
-       DBGPRINT(RT_DEBUG_TRACE, ("===> PeerGroupMsg2Action \n"));
-
-       do {
-               if ((!pEntry) || (!pEntry->ValidAsCLI))
-                       break;
-
-               if (MsgLen <
-                   (LENGTH_802_1_H + LENGTH_EAPOL_H + sizeof(struct rt_key_descripter) -
-                    MAX_LEN_OF_RSNIE - 2))
-                       break;
-
-               if (pEntry->WpaState != AS_PTKINITDONE)
-                       break;
-
-               pData = (u8 *)Msg;
-               pMsg2 = (struct rt_eapol_packet *) (pData + LENGTH_802_1_H);
-               Len = MsgLen - LENGTH_802_1_H;
-
-               /* Sanity Check peer group message 2 - Replay Counter, MIC */
-               if (PeerWpaMessageSanity
-                   (pAd, pMsg2, Len, EAPOL_GROUP_MSG_2, pEntry) == FALSE)
-                       break;
-
-               /* 3.  upgrade state */
-
-               RTMPCancelTimer(&pEntry->RetryTimer, &Cancelled);
-               pEntry->GTKState = REKEY_ESTABLISHED;
-
-               if ((pEntry->AuthMode == Ndis802_11AuthModeWPA2)
-                   || (pEntry->AuthMode == Ndis802_11AuthModeWPA2PSK)) {
-                       /* send wireless event - for set key done WPA2 */
-                       if (pAd->CommonCfg.bWirelessEvent)
-                               RTMPSendWirelessEvent(pAd,
-                                                     IW_SET_KEY_DONE_WPA2_EVENT_FLAG,
-                                                     pEntry->Addr,
-                                                     pEntry->apidx, 0);
-
-                       DBGPRINT(RT_DEBUG_OFF,
-                                ("AP SETKEYS DONE - WPA2, AuthMode(%d)=%s, WepStatus(%d)=%s, GroupWepStatus(%d)=%s\n\n",
-                                 pEntry->AuthMode,
-                                 GetAuthMode(pEntry->AuthMode),
-                                 pEntry->WepStatus,
-                                 GetEncryptType(pEntry->WepStatus),
-                                 group_cipher, GetEncryptType(group_cipher)));
-               } else {
-                       /* send wireless event - for set key done WPA */
-                       if (pAd->CommonCfg.bWirelessEvent)
-                               RTMPSendWirelessEvent(pAd,
-                                                     IW_SET_KEY_DONE_WPA1_EVENT_FLAG,
-                                                     pEntry->Addr,
-                                                     pEntry->apidx, 0);
-
-                       DBGPRINT(RT_DEBUG_OFF,
-                                ("AP SETKEYS DONE - WPA1, AuthMode(%d)=%s, WepStatus(%d)=%s, GroupWepStatus(%d)=%s\n\n",
-                                 pEntry->AuthMode,
-                                 GetAuthMode(pEntry->AuthMode),
-                                 pEntry->WepStatus,
-                                 GetEncryptType(pEntry->WepStatus),
-                                 group_cipher, GetEncryptType(group_cipher)));
-               }
-       } while (FALSE);
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Classify WPA EAP message type
-
-       Arguments:
-               EAPType         Value of EAP message type
-               MsgType         Internal Message definition for MLME state machine
-
-       Return Value:
-               TRUE            Found appropriate message type
-               FALSE           No appropriate message type
-
-       IRQL = DISPATCH_LEVEL
-
-       Note:
-               All these constants are defined in wpa.h
-               For supplicant, there is only EAPOL Key message available
-
-       ========================================================================
-*/
-BOOLEAN WpaMsgTypeSubst(u8 EAPType, int * MsgType)
-{
-       switch (EAPType) {
-       case EAPPacket:
-               *MsgType = MT2_EAPPacket;
-               break;
-       case EAPOLStart:
-               *MsgType = MT2_EAPOLStart;
-               break;
-       case EAPOLLogoff:
-               *MsgType = MT2_EAPOLLogoff;
-               break;
-       case EAPOLKey:
-               *MsgType = MT2_EAPOLKey;
-               break;
-       case EAPOLASFAlert:
-               *MsgType = MT2_EAPOLASFAlert;
-               break;
-       default:
-               return FALSE;
-       }
-       return TRUE;
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               The pseudo-random function(PRF) that hashes various inputs to
-               derive a pseudo-random value. To add liveness to the pseudo-random
-               value, a nonce should be one of the inputs.
-
-               It is used to generate PTK, GTK or some specific random value.
-
-       Arguments:
-               u8      *key,           -       the key material for HMAC_SHA1 use
-               int             key_len         -       the length of key
-               u8      *prefix         -       a prefix label
-               int             prefix_len      -       the length of the label
-               u8      *data           -       a specific data with variable length
-               int             data_len        -       the length of a specific data
-               int             len                     -       the output length
-
-       Return Value:
-               u8      *output         -       the calculated result
-
-       Note:
-               802.11i-2004    Annex H.3
-
-       ========================================================================
-*/
-void PRF(u8 * key,
-        int key_len,
-        u8 * prefix,
-        int prefix_len,
-        u8 * data, int data_len, u8 * output, int len)
-{
-       int i;
-       u8 *input;
-       int currentindex = 0;
-       int total_len;
-
-       /* Allocate memory for input */
-       os_alloc_mem(NULL, (u8 **) & input, 1024);
-
-       if (input == NULL) {
-               DBGPRINT(RT_DEBUG_ERROR, ("PRF: no memory!\n"));
-               return;
-       }
-       /* Generate concatenation input */
-       NdisMoveMemory(input, prefix, prefix_len);
-
-       /* Concatenate a single octet containing 0 */
-       input[prefix_len] = 0;
-
-       /* Concatenate specific data */
-       NdisMoveMemory(&input[prefix_len + 1], data, data_len);
-       total_len = prefix_len + 1 + data_len;
-
-       /* Concatenate a single octet containing 0 */
-       /* This octet shall be update later */
-       input[total_len] = 0;
-       total_len++;
-
-       /* Iterate to calculate the result by hmac-sha-1 */
-       /* Then concatenate to last result */
-       for (i = 0; i < (len + 19) / 20; i++) {
-               HMAC_SHA1(key, key_len, input, total_len, &output[currentindex],
-                         SHA1_DIGEST_SIZE);
-               currentindex += 20;
-
-               /* update the last octet */
-               input[total_len - 1]++;
-       }
-       os_free_mem(NULL, input);
-}
-
-/*
-* F(P, S, c, i) = U1 xor U2 xor ... Uc
-* U1 = PRF(P, S || Int(i))
-* U2 = PRF(P, U1)
-* Uc = PRF(P, Uc-1)
-*/
-
-static void F(char *password, unsigned char *ssid, int ssidlength,
-             int iterations, int count, unsigned char *output)
-{
-       unsigned char digest[36], digest1[SHA1_DIGEST_SIZE];
-       int i, j;
-
-       /* U1 = PRF(P, S || int(i)) */
-       memcpy(digest, ssid, ssidlength);
-       digest[ssidlength] = (unsigned char)((count >> 24) & 0xff);
-       digest[ssidlength + 1] = (unsigned char)((count >> 16) & 0xff);
-       digest[ssidlength + 2] = (unsigned char)((count >> 8) & 0xff);
-       digest[ssidlength + 3] = (unsigned char)(count & 0xff);
-       HMAC_SHA1((unsigned char *)password, (int)strlen(password), digest, ssidlength + 4, digest1, SHA1_DIGEST_SIZE); /* for WPA update */
-
-       /* output = U1 */
-       memcpy(output, digest1, SHA1_DIGEST_SIZE);
-
-       for (i = 1; i < iterations; i++) {
-               /* Un = PRF(P, Un-1) */
-               HMAC_SHA1((unsigned char *)password, (int)strlen(password), digest1, SHA1_DIGEST_SIZE, digest, SHA1_DIGEST_SIZE);       /* for WPA update */
-               memcpy(digest1, digest, SHA1_DIGEST_SIZE);
-
-               /* output = output xor Un */
-               for (j = 0; j < SHA1_DIGEST_SIZE; j++) {
-                       output[j] ^= digest[j];
-               }
-       }
-}
-
-/*
-* password - ascii string up to 63 characters in length
-* ssid - octet string up to 32 octets
-* ssidlength - length of ssid in octets
-* output must be 40 octets in length and outputs 256 bits of key
-*/
-int PasswordHash(char *password, u8 *ssid, int ssidlength, u8 *output)
-{
-       if ((strlen(password) > 63) || (ssidlength > 32))
-               return 0;
-
-       F(password, ssid, ssidlength, 4096, 1, output);
-       F(password, ssid, ssidlength, 4096, 2, &output[SHA1_DIGEST_SIZE]);
-       return 1;
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               It utilizes PRF-384 or PRF-512 to derive session-specific keys from a PMK.
-               It shall be called by 4-way handshake processing.
-
-       Arguments:
-               pAd     -       pointer to our pAdapter context
-               PMK             -       pointer to PMK
-               ANonce  -       pointer to ANonce
-               AA              -       pointer to Authenticator Address
-               SNonce  -       pointer to SNonce
-               SA              -       pointer to Supplicant Address
-               len             -       indicate the length of PTK (octet)
-
-       Return Value:
-               Output          pointer to the PTK
-
-       Note:
-               Refer to IEEE 802.11i-2004 8.5.1.2
-
-       ========================================================================
-*/
-void WpaDerivePTK(struct rt_rtmp_adapter *pAd,
-                 u8 * PMK,
-                 u8 * ANonce,
-                 u8 * AA,
-                 u8 * SNonce,
-                 u8 * SA, u8 * output, u32 len)
-{
-       u8 concatenation[76];
-       u32 CurrPos = 0;
-       u8 temp[32];
-       u8 Prefix[] =
-           { 'P', 'a', 'i', 'r', 'w', 'i', 's', 'e', ' ', 'k', 'e', 'y', ' ',
-               'e', 'x', 'p', 'a', 'n', 's', 'i', 'o', 'n'
-       };
-
-       /* initiate the concatenation input */
-       NdisZeroMemory(temp, sizeof(temp));
-       NdisZeroMemory(concatenation, 76);
-
-       /* Get smaller address */
-       if (RTMPCompareMemory(SA, AA, 6) == 1)
-               NdisMoveMemory(concatenation, AA, 6);
-       else
-               NdisMoveMemory(concatenation, SA, 6);
-       CurrPos += 6;
-
-       /* Get larger address */
-       if (RTMPCompareMemory(SA, AA, 6) == 1)
-               NdisMoveMemory(&concatenation[CurrPos], SA, 6);
-       else
-               NdisMoveMemory(&concatenation[CurrPos], AA, 6);
-
-       /* store the larger mac address for backward compatible of */
-       /* ralink proprietary STA-key issue */
-       NdisMoveMemory(temp, &concatenation[CurrPos], MAC_ADDR_LEN);
-       CurrPos += 6;
-
-       /* Get smaller Nonce */
-       if (RTMPCompareMemory(ANonce, SNonce, 32) == 0)
-               NdisMoveMemory(&concatenation[CurrPos], temp, 32);      /* patch for ralink proprietary STA-key issue */
-       else if (RTMPCompareMemory(ANonce, SNonce, 32) == 1)
-               NdisMoveMemory(&concatenation[CurrPos], SNonce, 32);
-       else
-               NdisMoveMemory(&concatenation[CurrPos], ANonce, 32);
-       CurrPos += 32;
-
-       /* Get larger Nonce */
-       if (RTMPCompareMemory(ANonce, SNonce, 32) == 0)
-               NdisMoveMemory(&concatenation[CurrPos], temp, 32);      /* patch for ralink proprietary STA-key issue */
-       else if (RTMPCompareMemory(ANonce, SNonce, 32) == 1)
-               NdisMoveMemory(&concatenation[CurrPos], ANonce, 32);
-       else
-               NdisMoveMemory(&concatenation[CurrPos], SNonce, 32);
-       CurrPos += 32;
-
-       hex_dump("concatenation=", concatenation, 76);
-
-       /* Use PRF to generate PTK */
-       PRF(PMK, LEN_MASTER_KEY, Prefix, 22, concatenation, 76, output, len);
-
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Generate random number by software.
-
-       Arguments:
-               pAd             -       pointer to our pAdapter context
-               macAddr -       pointer to local MAC address
-
-       Return Value:
-
-       Note:
-               802.1ii-2004  Annex H.5
-
-       ========================================================================
-*/
-void GenRandom(struct rt_rtmp_adapter *pAd, u8 * macAddr, u8 * random)
-{
-       int i, curr;
-       u8 local[80], KeyCounter[32];
-       u8 result[80];
-       unsigned long CurrentTime;
-       u8 prefix[] =
-           { 'I', 'n', 'i', 't', ' ', 'C', 'o', 'u', 'n', 't', 'e', 'r' };
-
-       /* Zero the related information */
-       NdisZeroMemory(result, 80);
-       NdisZeroMemory(local, 80);
-       NdisZeroMemory(KeyCounter, 32);
-
-       for (i = 0; i < 32; i++) {
-               /* copy the local MAC address */
-               COPY_MAC_ADDR(local, macAddr);
-               curr = MAC_ADDR_LEN;
-
-               /* concatenate the current time */
-               NdisGetSystemUpTime(&CurrentTime);
-               NdisMoveMemory(&local[curr], &CurrentTime, sizeof(CurrentTime));
-               curr += sizeof(CurrentTime);
-
-               /* concatenate the last result */
-               NdisMoveMemory(&local[curr], result, 32);
-               curr += 32;
-
-               /* concatenate a variable */
-               NdisMoveMemory(&local[curr], &i, 2);
-               curr += 2;
-
-               /* calculate the result */
-               PRF(KeyCounter, 32, prefix, 12, local, curr, result, 32);
-       }
-
-       NdisMoveMemory(random, result, 32);
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Build cipher suite in RSN-IE.
-               It only shall be called by RTMPMakeRSNIE.
-
-       Arguments:
-               pAd                     -       pointer to our pAdapter context
-       ElementID       -       indicate the WPA1 or WPA2
-       WepStatus       -       indicate the encryption type
-               bMixCipher      -       a boolean to indicate the pairwise cipher and group
-                                               cipher are the same or not
-
-       Return Value:
-
-       Note:
-
-       ========================================================================
-*/
-static void RTMPMakeRsnIeCipher(struct rt_rtmp_adapter *pAd,
-                               u8 ElementID,
-                               u32 WepStatus,
-                               IN BOOLEAN bMixCipher,
-                               u8 FlexibleCipher,
-                               u8 *pRsnIe, u8 * rsn_len)
-{
-       u8 PairwiseCnt;
-
-       *rsn_len = 0;
-
-       /* decide WPA2 or WPA1 */
-       if (ElementID == Wpa2Ie) {
-               struct rt_rsnie2 *pRsnie_cipher = (struct rt_rsnie2 *)pRsnIe;
-
-               /* Assign the verson as 1 */
-               pRsnie_cipher->version = 1;
-
-               switch (WepStatus) {
-                       /* TKIP mode */
-               case Ndis802_11Encryption2Enabled:
-                       NdisMoveMemory(pRsnie_cipher->mcast, OUI_WPA2_TKIP, 4);
-                       pRsnie_cipher->ucount = 1;
-                       NdisMoveMemory(pRsnie_cipher->ucast[0].oui,
-                                      OUI_WPA2_TKIP, 4);
-                       *rsn_len = sizeof(struct rt_rsnie2);
-                       break;
-
-                       /* AES mode */
-               case Ndis802_11Encryption3Enabled:
-                       if (bMixCipher)
-                               NdisMoveMemory(pRsnie_cipher->mcast,
-                                              OUI_WPA2_TKIP, 4);
-                       else
-                               NdisMoveMemory(pRsnie_cipher->mcast,
-                                              OUI_WPA2_CCMP, 4);
-                       pRsnie_cipher->ucount = 1;
-                       NdisMoveMemory(pRsnie_cipher->ucast[0].oui,
-                                      OUI_WPA2_CCMP, 4);
-                       *rsn_len = sizeof(struct rt_rsnie2);
-                       break;
-
-                       /* TKIP-AES mix mode */
-               case Ndis802_11Encryption4Enabled:
-                       NdisMoveMemory(pRsnie_cipher->mcast, OUI_WPA2_TKIP, 4);
-
-                       PairwiseCnt = 1;
-                       /* Insert WPA2 TKIP as the first pairwise cipher */
-                       if (MIX_CIPHER_WPA2_TKIP_ON(FlexibleCipher)) {
-                               NdisMoveMemory(pRsnie_cipher->ucast[0].oui,
-                                              OUI_WPA2_TKIP, 4);
-                               /* Insert WPA2 AES as the secondary pairwise cipher */
-                               if (MIX_CIPHER_WPA2_AES_ON(FlexibleCipher)) {
-                                       NdisMoveMemory(pRsnie_cipher->ucast[0].
-                                                      oui + 4, OUI_WPA2_CCMP,
-                                                      4);
-                                       PairwiseCnt = 2;
-                               }
-                       } else {
-                               /* Insert WPA2 AES as the first pairwise cipher */
-                               NdisMoveMemory(pRsnie_cipher->ucast[0].oui,
-                                              OUI_WPA2_CCMP, 4);
-                       }
-
-                       pRsnie_cipher->ucount = PairwiseCnt;
-                       *rsn_len = sizeof(struct rt_rsnie2) + (4 * (PairwiseCnt - 1));
-                       break;
-               }
-
-               if ((pAd->OpMode == OPMODE_STA) &&
-                   (pAd->StaCfg.GroupCipher != Ndis802_11Encryption2Enabled) &&
-                   (pAd->StaCfg.GroupCipher != Ndis802_11Encryption3Enabled)) {
-                       u32 GroupCipher = pAd->StaCfg.GroupCipher;
-                       switch (GroupCipher) {
-                       case Ndis802_11GroupWEP40Enabled:
-                               NdisMoveMemory(pRsnie_cipher->mcast,
-                                              OUI_WPA2_WEP40, 4);
-                               break;
-                       case Ndis802_11GroupWEP104Enabled:
-                               NdisMoveMemory(pRsnie_cipher->mcast,
-                                              OUI_WPA2_WEP104, 4);
-                               break;
-                       }
-               }
-               /* swap for big-endian platform */
-               pRsnie_cipher->version = cpu2le16(pRsnie_cipher->version);
-               pRsnie_cipher->ucount = cpu2le16(pRsnie_cipher->ucount);
-       } else {
-               struct rt_rsnie *pRsnie_cipher = (struct rt_rsnie *)pRsnIe;
-
-               /* Assign OUI and version */
-               NdisMoveMemory(pRsnie_cipher->oui, OUI_WPA_VERSION, 4);
-               pRsnie_cipher->version = 1;
-
-               switch (WepStatus) {
-                       /* TKIP mode */
-               case Ndis802_11Encryption2Enabled:
-                       NdisMoveMemory(pRsnie_cipher->mcast, OUI_WPA_TKIP, 4);
-                       pRsnie_cipher->ucount = 1;
-                       NdisMoveMemory(pRsnie_cipher->ucast[0].oui,
-                                      OUI_WPA_TKIP, 4);
-                       *rsn_len = sizeof(struct rt_rsnie);
-                       break;
-
-                       /* AES mode */
-               case Ndis802_11Encryption3Enabled:
-                       if (bMixCipher)
-                               NdisMoveMemory(pRsnie_cipher->mcast,
-                                              OUI_WPA_TKIP, 4);
-                       else
-                               NdisMoveMemory(pRsnie_cipher->mcast,
-                                              OUI_WPA_CCMP, 4);
-                       pRsnie_cipher->ucount = 1;
-                       NdisMoveMemory(pRsnie_cipher->ucast[0].oui,
-                                      OUI_WPA_CCMP, 4);
-                       *rsn_len = sizeof(struct rt_rsnie);
-                       break;
-
-                       /* TKIP-AES mix mode */
-               case Ndis802_11Encryption4Enabled:
-                       NdisMoveMemory(pRsnie_cipher->mcast, OUI_WPA_TKIP, 4);
-
-                       PairwiseCnt = 1;
-                       /* Insert WPA TKIP as the first pairwise cipher */
-                       if (MIX_CIPHER_WPA_TKIP_ON(FlexibleCipher)) {
-                               NdisMoveMemory(pRsnie_cipher->ucast[0].oui,
-                                              OUI_WPA_TKIP, 4);
-                               /* Insert WPA AES as the secondary pairwise cipher */
-                               if (MIX_CIPHER_WPA_AES_ON(FlexibleCipher)) {
-                                       NdisMoveMemory(pRsnie_cipher->ucast[0].
-                                                      oui + 4, OUI_WPA_CCMP,
-                                                      4);
-                                       PairwiseCnt = 2;
-                               }
-                       } else {
-                               /* Insert WPA AES as the first pairwise cipher */
-                               NdisMoveMemory(pRsnie_cipher->ucast[0].oui,
-                                              OUI_WPA_CCMP, 4);
-                       }
-
-                       pRsnie_cipher->ucount = PairwiseCnt;
-                       *rsn_len = sizeof(struct rt_rsnie) + (4 * (PairwiseCnt - 1));
-                       break;
-               }
-
-               if ((pAd->OpMode == OPMODE_STA) &&
-                   (pAd->StaCfg.GroupCipher != Ndis802_11Encryption2Enabled) &&
-                   (pAd->StaCfg.GroupCipher != Ndis802_11Encryption3Enabled)) {
-                       u32 GroupCipher = pAd->StaCfg.GroupCipher;
-                       switch (GroupCipher) {
-                       case Ndis802_11GroupWEP40Enabled:
-                               NdisMoveMemory(pRsnie_cipher->mcast,
-                                              OUI_WPA_WEP40, 4);
-                               break;
-                       case Ndis802_11GroupWEP104Enabled:
-                               NdisMoveMemory(pRsnie_cipher->mcast,
-                                              OUI_WPA_WEP104, 4);
-                               break;
-                       }
-               }
-               /* swap for big-endian platform */
-               pRsnie_cipher->version = cpu2le16(pRsnie_cipher->version);
-               pRsnie_cipher->ucount = cpu2le16(pRsnie_cipher->ucount);
-       }
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Build AKM suite in RSN-IE.
-               It only shall be called by RTMPMakeRSNIE.
-
-       Arguments:
-               pAd                     -       pointer to our pAdapter context
-       ElementID       -       indicate the WPA1 or WPA2
-       AuthMode        -       indicate the authentication mode
-               apidx           -       indicate the interface index
-
-       Return Value:
-
-       Note:
-
-       ========================================================================
-*/
-static void RTMPMakeRsnIeAKM(struct rt_rtmp_adapter *pAd,
-                            u8 ElementID,
-                            u32 AuthMode,
-                            u8 apidx,
-                            u8 *pRsnIe, u8 * rsn_len)
-{
-       struct rt_rsnie_auth *pRsnie_auth;
-       u8 AkmCnt = 1;  /* default as 1 */
-
-       pRsnie_auth = (struct rt_rsnie_auth *) (pRsnIe + (*rsn_len));
-
-       /* decide WPA2 or WPA1 */
-       if (ElementID == Wpa2Ie) {
-
-               switch (AuthMode) {
-               case Ndis802_11AuthModeWPA2:
-               case Ndis802_11AuthModeWPA1WPA2:
-                       NdisMoveMemory(pRsnie_auth->auth[0].oui,
-                                      OUI_WPA2_8021X_AKM, 4);
-                       break;
-
-               case Ndis802_11AuthModeWPA2PSK:
-               case Ndis802_11AuthModeWPA1PSKWPA2PSK:
-                       NdisMoveMemory(pRsnie_auth->auth[0].oui,
-                                      OUI_WPA2_PSK_AKM, 4);
-                       break;
-               default:
-                       AkmCnt = 0;
-                       break;
-
-               }
-       } else {
-               switch (AuthMode) {
-               case Ndis802_11AuthModeWPA:
-               case Ndis802_11AuthModeWPA1WPA2:
-                       NdisMoveMemory(pRsnie_auth->auth[0].oui,
-                                      OUI_WPA_8021X_AKM, 4);
-                       break;
-
-               case Ndis802_11AuthModeWPAPSK:
-               case Ndis802_11AuthModeWPA1PSKWPA2PSK:
-                       NdisMoveMemory(pRsnie_auth->auth[0].oui,
-                                      OUI_WPA_PSK_AKM, 4);
-                       break;
-
-               case Ndis802_11AuthModeWPANone:
-                       NdisMoveMemory(pRsnie_auth->auth[0].oui,
-                                      OUI_WPA_NONE_AKM, 4);
-                       break;
-               default:
-                       AkmCnt = 0;
-                       break;
-               }
-       }
-
-       pRsnie_auth->acount = AkmCnt;
-       pRsnie_auth->acount = cpu2le16(pRsnie_auth->acount);
-
-       /* update current RSNIE length */
-       (*rsn_len) += (sizeof(struct rt_rsnie_auth) + (4 * (AkmCnt - 1)));
-
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Build capability in RSN-IE.
-               It only shall be called by RTMPMakeRSNIE.
-
-       Arguments:
-               pAd                     -       pointer to our pAdapter context
-       ElementID       -       indicate the WPA1 or WPA2
-               apidx           -       indicate the interface index
-
-       Return Value:
-
-       Note:
-
-       ========================================================================
-*/
-static void RTMPMakeRsnIeCap(struct rt_rtmp_adapter *pAd,
-                            u8 ElementID,
-                            u8 apidx,
-                            u8 *pRsnIe, u8 * rsn_len)
-{
-       RSN_CAPABILITIES *pRSN_Cap;
-
-       /* it could be ignored in WPA1 mode */
-       if (ElementID == WpaIe)
-               return;
-
-       pRSN_Cap = (RSN_CAPABILITIES *) (pRsnIe + (*rsn_len));
-
-       pRSN_Cap->word = cpu2le16(pRSN_Cap->word);
-
-       (*rsn_len) += sizeof(RSN_CAPABILITIES); /* update current RSNIE length */
-
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Build RSN IE context. It is not included element-ID and length.
-
-       Arguments:
-               pAd                     -       pointer to our pAdapter context
-       AuthMode        -       indicate the authentication mode
-       WepStatus       -       indicate the encryption type
-               apidx           -       indicate the interface index
-
-       Return Value:
-
-       Note:
-
-       ========================================================================
-*/
-void RTMPMakeRSNIE(struct rt_rtmp_adapter *pAd,
-                  u32 AuthMode, u32 WepStatus, u8 apidx)
-{
-       u8 *pRsnIe = NULL;      /* primary RSNIE */
-       u8 *rsnielen_cur_p = 0; /* the length of the primary RSNIE */
-       u8 *rsnielen_ex_cur_p = 0;      /* the length of the secondary RSNIE */
-       u8 PrimaryRsnie;
-       BOOLEAN bMixCipher = FALSE;     /* indicate the pairwise and group cipher are different */
-       u8 p_offset;
-       WPA_MIX_PAIR_CIPHER FlexibleCipher = WPA_TKIPAES_WPA2_TKIPAES;  /* it provide the more flexible cipher combination in WPA-WPA2 and TKIPAES mode */
-
-       rsnielen_cur_p = NULL;
-       rsnielen_ex_cur_p = NULL;
-
-       {
-               {
-                       if (pAd->StaCfg.WpaSupplicantUP !=
-                           WPA_SUPPLICANT_DISABLE) {
-                               if (AuthMode < Ndis802_11AuthModeWPA)
-                                       return;
-                       } else {
-                               /* Support WPAPSK or WPA2PSK in STA-Infra mode */
-                               /* Support WPANone in STA-Adhoc mode */
-                               if ((AuthMode != Ndis802_11AuthModeWPAPSK) &&
-                                   (AuthMode != Ndis802_11AuthModeWPA2PSK) &&
-                                   (AuthMode != Ndis802_11AuthModeWPANone)
-                                   )
-                                       return;
-                       }
-
-                       DBGPRINT(RT_DEBUG_TRACE, ("==> RTMPMakeRSNIE(STA)\n"));
-
-                       /* Zero RSNIE context */
-                       pAd->StaCfg.RSNIE_Len = 0;
-                       NdisZeroMemory(pAd->StaCfg.RSN_IE, MAX_LEN_OF_RSNIE);
-
-                       /* Pointer to RSNIE */
-                       rsnielen_cur_p = &pAd->StaCfg.RSNIE_Len;
-                       pRsnIe = pAd->StaCfg.RSN_IE;
-
-                       bMixCipher = pAd->StaCfg.bMixCipher;
-               }
-       }
-
-       /* indicate primary RSNIE as WPA or WPA2 */
-       if ((AuthMode == Ndis802_11AuthModeWPA) ||
-           (AuthMode == Ndis802_11AuthModeWPAPSK) ||
-           (AuthMode == Ndis802_11AuthModeWPANone) ||
-           (AuthMode == Ndis802_11AuthModeWPA1WPA2) ||
-           (AuthMode == Ndis802_11AuthModeWPA1PSKWPA2PSK))
-               PrimaryRsnie = WpaIe;
-       else
-               PrimaryRsnie = Wpa2Ie;
-
-       {
-               /* Build the primary RSNIE */
-               /* 1. insert cipher suite */
-               RTMPMakeRsnIeCipher(pAd, PrimaryRsnie, WepStatus, bMixCipher,
-                                   FlexibleCipher, pRsnIe, &p_offset);
-
-               /* 2. insert AKM */
-               RTMPMakeRsnIeAKM(pAd, PrimaryRsnie, AuthMode, apidx, pRsnIe,
-                                &p_offset);
-
-               /* 3. insert capability */
-               RTMPMakeRsnIeCap(pAd, PrimaryRsnie, apidx, pRsnIe, &p_offset);
-       }
-
-       /* 4. update the RSNIE length */
-       *rsnielen_cur_p = p_offset;
-
-       hex_dump("The primary RSNIE", pRsnIe, (*rsnielen_cur_p));
-
-}
-
-/*
-    ==========================================================================
-    Description:
-               Check whether the received frame is EAP frame.
-
-       Arguments:
-               pAd                             -       pointer to our pAdapter context
-               pEntry                  -       pointer to active entry
-               pData                   -       the received frame
-               DataByteCount   -       the received frame's length
-               FromWhichBSSID  -       indicate the interface index
-
-    Return:
-         TRUE                  -       This frame is EAP frame
-         FALSE                 -       otherwise
-    ==========================================================================
-*/
-BOOLEAN RTMPCheckWPAframe(struct rt_rtmp_adapter *pAd,
-                         struct rt_mac_table_entry *pEntry,
-                         u8 *pData,
-                         unsigned long DataByteCount, u8 FromWhichBSSID)
-{
-       unsigned long Body_len;
-       BOOLEAN Cancelled;
-
-       if (DataByteCount < (LENGTH_802_1_H + LENGTH_EAPOL_H))
-               return FALSE;
-
-       /* Skip LLC header */
-       if (NdisEqualMemory(SNAP_802_1H, pData, 6) ||
-           /* Cisco 1200 AP may send packet with SNAP_BRIDGE_TUNNEL */
-           NdisEqualMemory(SNAP_BRIDGE_TUNNEL, pData, 6)) {
-               pData += 6;
-       }
-       /* Skip 2-bytes EAPoL type */
-       if (NdisEqualMemory(EAPOL, pData, 2)) {
-               pData += 2;
-       } else
-               return FALSE;
-
-       switch (*(pData + 1)) {
-       case EAPPacket:
-               Body_len = (*(pData + 2) << 8) | (*(pData + 3));
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("Receive EAP-Packet frame, TYPE = 0, Length = %ld\n",
-                         Body_len));
-               break;
-       case EAPOLStart:
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("Receive EAPOL-Start frame, TYPE = 1 \n"));
-               if (pEntry->EnqueueEapolStartTimerRunning !=
-                   EAPOL_START_DISABLE) {
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("Cancel the EnqueueEapolStartTimerRunning \n"));
-                       RTMPCancelTimer(&pEntry->EnqueueStartForPSKTimer,
-                                       &Cancelled);
-                       pEntry->EnqueueEapolStartTimerRunning =
-                           EAPOL_START_DISABLE;
-               }
-               break;
-       case EAPOLLogoff:
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("Receive EAPOLLogoff frame, TYPE = 2 \n"));
-               break;
-       case EAPOLKey:
-               Body_len = (*(pData + 2) << 8) | (*(pData + 3));
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("Receive EAPOL-Key frame, TYPE = 3, Length = %ld\n",
-                         Body_len));
-               break;
-       case EAPOLASFAlert:
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("Receive EAPOLASFAlert frame, TYPE = 4 \n"));
-               break;
-       default:
-               return FALSE;
-
-       }
-       return TRUE;
-}
-
-/*
-    ==========================================================================
-    Description:
-               Report the EAP message type
-
-       Arguments:
-               msg             -       EAPOL_PAIR_MSG_1
-                                       EAPOL_PAIR_MSG_2
-                                       EAPOL_PAIR_MSG_3
-                                       EAPOL_PAIR_MSG_4
-                                       EAPOL_GROUP_MSG_1
-                                       EAPOL_GROUP_MSG_2
-
-    Return:
-         message type string
-
-    ==========================================================================
-*/
-char *GetEapolMsgType(char msg)
-{
-       if (msg == EAPOL_PAIR_MSG_1)
-               return "Pairwise Message 1";
-       else if (msg == EAPOL_PAIR_MSG_2)
-               return "Pairwise Message 2";
-       else if (msg == EAPOL_PAIR_MSG_3)
-               return "Pairwise Message 3";
-       else if (msg == EAPOL_PAIR_MSG_4)
-               return "Pairwise Message 4";
-       else if (msg == EAPOL_GROUP_MSG_1)
-               return "Group Message 1";
-       else if (msg == EAPOL_GROUP_MSG_2)
-               return "Group Message 2";
-       else
-               return "Invalid Message";
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-    Check Sanity RSN IE of EAPoL message
-
-       Arguments:
-
-       Return Value:
-
-       ========================================================================
-*/
-BOOLEAN RTMPCheckRSNIE(struct rt_rtmp_adapter *pAd,
-                      u8 *pData,
-                      u8 DataLen,
-                      struct rt_mac_table_entry *pEntry, u8 * Offset)
-{
-       u8 *pVIE;
-       u8 len;
-       struct rt_eid * pEid;
-       BOOLEAN result = FALSE;
-
-       pVIE = pData;
-       len = DataLen;
-       *Offset = 0;
-
-       while (len > sizeof(struct rt_rsnie2)) {
-               pEid = (struct rt_eid *) pVIE;
-               /* WPA RSN IE */
-               if ((pEid->Eid == IE_WPA)
-                   && (NdisEqualMemory(pEid->Octet, WPA_OUI, 4))) {
-                       if ((pEntry->AuthMode == Ndis802_11AuthModeWPA
-                            || pEntry->AuthMode == Ndis802_11AuthModeWPAPSK)
-                           &&
-                           (NdisEqualMemory
-                            (pVIE, pEntry->RSN_IE, pEntry->RSNIE_Len))
-                           && (pEntry->RSNIE_Len == (pEid->Len + 2))) {
-                               result = TRUE;
-                       }
-
-                       *Offset += (pEid->Len + 2);
-               }
-               /* WPA2 RSN IE */
-               else if ((pEid->Eid == IE_RSN)
-                        && (NdisEqualMemory(pEid->Octet + 2, RSN_OUI, 3))) {
-                       if ((pEntry->AuthMode == Ndis802_11AuthModeWPA2
-                            || pEntry->AuthMode == Ndis802_11AuthModeWPA2PSK)
-                           && (pEid->Eid == pEntry->RSN_IE[0])
-                           && ((pEid->Len + 2) >= pEntry->RSNIE_Len)
-                           &&
-                           (NdisEqualMemory
-                            (pEid->Octet, &pEntry->RSN_IE[2],
-                             pEntry->RSNIE_Len - 2))) {
-
-                               result = TRUE;
-                       }
-
-                       *Offset += (pEid->Len + 2);
-               } else {
-                       break;
-               }
-
-               pVIE += (pEid->Len + 2);
-               len -= (pEid->Len + 2);
-       }
-
-       return result;
-
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-    Parse KEYDATA field.  KEYDATA[] May contain 2 RSN IE and optionally GTK.
-    GTK  is encaptulated in KDE format at  p.83 802.11i D10
-
-       Arguments:
-
-       Return Value:
-
-       Note:
-        802.11i D10
-
-       ========================================================================
-*/
-BOOLEAN RTMPParseEapolKeyData(struct rt_rtmp_adapter *pAd,
-                             u8 *pKeyData,
-                             u8 KeyDataLen,
-                             u8 GroupKeyIndex,
-                             u8 MsgType,
-                             IN BOOLEAN bWPA2, struct rt_mac_table_entry *pEntry)
-{
-       struct rt_kde_encap * pKDE = NULL;
-       u8 *pMyKeyData = pKeyData;
-       u8 KeyDataLength = KeyDataLen;
-       u8 GTKLEN = 0;
-       u8 DefaultIdx = 0;
-       u8 skip_offset;
-
-       /* Verify The RSN IE contained in pairewise_msg_2 && pairewise_msg_3 and skip it */
-       if (MsgType == EAPOL_PAIR_MSG_2 || MsgType == EAPOL_PAIR_MSG_3) {
-               /* Check RSN IE whether it is WPA2/WPA2PSK */
-               if (!RTMPCheckRSNIE
-                   (pAd, pKeyData, KeyDataLen, pEntry, &skip_offset)) {
-                       /* send wireless event - for RSN IE different */
-                       if (pAd->CommonCfg.bWirelessEvent)
-                               RTMPSendWirelessEvent(pAd,
-                                                     IW_RSNIE_DIFF_EVENT_FLAG,
-                                                     pEntry->Addr,
-                                                     pEntry->apidx, 0);
-
-                       DBGPRINT(RT_DEBUG_ERROR,
-                                ("RSN_IE Different in msg %d of 4-way handshake!\n",
-                                 MsgType));
-                       hex_dump("Receive RSN_IE ", pKeyData, KeyDataLen);
-                       hex_dump("Desired RSN_IE ", pEntry->RSN_IE,
-                                pEntry->RSNIE_Len);
-
-                       return FALSE;
-               } else {
-                       if (bWPA2 && MsgType == EAPOL_PAIR_MSG_3) {
-                               WpaShowAllsuite(pMyKeyData, skip_offset);
-
-                               /* skip RSN IE */
-                               pMyKeyData += skip_offset;
-                               KeyDataLength -= skip_offset;
-                               DBGPRINT(RT_DEBUG_TRACE,
-                                        ("RTMPParseEapolKeyData ==> WPA2/WPA2PSK RSN IE matched in Msg 3, Length(%d) \n",
-                                         skip_offset));
-                       } else
-                               return TRUE;
-               }
-       }
-
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("RTMPParseEapolKeyData ==> KeyDataLength %d without RSN_IE \n",
-                 KeyDataLength));
-       /*hex_dump("remain data", pMyKeyData, KeyDataLength); */
-
-       /* Parse EKD format in pairwise_msg_3_WPA2 && group_msg_1_WPA2 */
-       if (bWPA2
-           && (MsgType == EAPOL_PAIR_MSG_3 || MsgType == EAPOL_GROUP_MSG_1)) {
-               if (KeyDataLength >= 8) /* KDE format exclude GTK length */
-               {
-                       pKDE = (struct rt_kde_encap *) pMyKeyData;
-
-                       DefaultIdx = pKDE->GTKEncap.Kid;
-
-                       /* Sanity check - KED length */
-                       if (KeyDataLength < (pKDE->Len + 2)) {
-                               DBGPRINT(RT_DEBUG_ERROR,
-                                        ("ERROR: The len from KDE is too short \n"));
-                               return FALSE;
-                       }
-                       /* Get GTK length - refer to IEEE 802.11i-2004 p.82 */
-                       GTKLEN = pKDE->Len - 6;
-                       if (GTKLEN < LEN_AES_KEY) {
-                               DBGPRINT(RT_DEBUG_ERROR,
-                                        ("ERROR: GTK Key length is too short (%d) \n",
-                                         GTKLEN));
-                               return FALSE;
-                       }
-
-               } else {
-                       DBGPRINT(RT_DEBUG_ERROR,
-                                ("ERROR: KDE format length is too short \n"));
-                       return FALSE;
-               }
-
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("GTK in KDE format ,DefaultKeyID=%d, KeyLen=%d \n",
-                         DefaultIdx, GTKLEN));
-               /* skip it */
-               pMyKeyData += 8;
-               KeyDataLength -= 8;
-
-       } else if (!bWPA2 && MsgType == EAPOL_GROUP_MSG_1) {
-               DefaultIdx = GroupKeyIndex;
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("GTK DefaultKeyID=%d \n", DefaultIdx));
-       }
-       /* Sanity check - shared key index must be 1 ~ 3 */
-       if (DefaultIdx < 1 || DefaultIdx > 3) {
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("ERROR: GTK Key index(%d) is invalid in %s %s \n",
-                         DefaultIdx, ((bWPA2) ? "WPA2" : "WPA"),
-                         GetEapolMsgType(MsgType)));
-               return FALSE;
-       }
-
-       {
-               struct rt_cipher_key *pSharedKey;
-
-               /* set key material, TxMic and RxMic */
-               NdisMoveMemory(pAd->StaCfg.GTK, pMyKeyData, 32);
-               pAd->StaCfg.DefaultKeyId = DefaultIdx;
-
-               pSharedKey = &pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId];
-
-               /* Prepare pair-wise key information into shared key table */
-               NdisZeroMemory(pSharedKey, sizeof(struct rt_cipher_key));
-               pSharedKey->KeyLen = LEN_TKIP_EK;
-               NdisMoveMemory(pSharedKey->Key, pAd->StaCfg.GTK, LEN_TKIP_EK);
-               NdisMoveMemory(pSharedKey->RxMic, &pAd->StaCfg.GTK[16],
-                              LEN_TKIP_RXMICK);
-               NdisMoveMemory(pSharedKey->TxMic, &pAd->StaCfg.GTK[24],
-                              LEN_TKIP_TXMICK);
-
-               /* Update Shared Key CipherAlg */
-               pSharedKey->CipherAlg = CIPHER_NONE;
-               if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)
-                       pSharedKey->CipherAlg = CIPHER_TKIP;
-               else if (pAd->StaCfg.GroupCipher ==
-                        Ndis802_11Encryption3Enabled)
-                       pSharedKey->CipherAlg = CIPHER_AES;
-               else if (pAd->StaCfg.GroupCipher == Ndis802_11GroupWEP40Enabled)
-                       pSharedKey->CipherAlg = CIPHER_WEP64;
-               else if (pAd->StaCfg.GroupCipher ==
-                        Ndis802_11GroupWEP104Enabled)
-                       pSharedKey->CipherAlg = CIPHER_WEP128;
-
-               /* Update group key information to ASIC Shared Key Table */
-               AsicAddSharedKeyEntry(pAd,
-                                     BSS0,
-                                     pAd->StaCfg.DefaultKeyId,
-                                     pSharedKey->CipherAlg,
-                                     pSharedKey->Key,
-                                     pSharedKey->TxMic, pSharedKey->RxMic);
-
-               /* Update ASIC WCID attribute table and IVEIV table */
-               RTMPAddWcidAttributeEntry(pAd,
-                                         BSS0,
-                                         pAd->StaCfg.DefaultKeyId,
-                                         pSharedKey->CipherAlg, NULL);
-       }
-
-       return TRUE;
-
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Construct EAPoL message for WPA handshaking
-               Its format is below,
-
-               +--------------------+
-               | Protocol Version       |  1 octet
-               +--------------------+
-               | Protocol Type          |      1 octet
-               +--------------------+
-               | Body Length            |  2 octets
-               +--------------------+
-               | Descriptor Type        |      1 octet
-               +--------------------+
-               | Key Information    |  2 octets
-               +--------------------+
-               | Key Length         |  1 octet
-               +--------------------+
-               | Key Repaly Counter |  8 octets
-               +--------------------+
-               | Key Nonce                  |  32 octets
-               +--------------------+
-               | Key IV                         |  16 octets
-               +--------------------+
-               | Key RSC                        |  8 octets
-               +--------------------+
-               | Key ID or Reserved |  8 octets
-               +--------------------+
-               | Key MIC                        |      16 octets
-               +--------------------+
-               | Key Data Length        |      2 octets
-               +--------------------+
-               | Key Data                       |      n octets
-               +--------------------+
-
-       Arguments:
-               pAd                     Pointer to our adapter
-
-       Return Value:
-               None
-
-       Note:
-
-       ========================================================================
-*/
-void ConstructEapolMsg(struct rt_mac_table_entry *pEntry,
-                      u8 GroupKeyWepStatus,
-                      u8 MsgType,
-                      u8 DefaultKeyIdx,
-                      u8 * KeyNonce,
-                      u8 * TxRSC,
-                      u8 * GTK,
-                      u8 * RSNIE,
-                      u8 RSNIE_Len, struct rt_eapol_packet * pMsg)
-{
-       BOOLEAN bWPA2 = FALSE;
-       u8 KeyDescVer;
-
-       /* Choose WPA2 or not */
-       if ((pEntry->AuthMode == Ndis802_11AuthModeWPA2) ||
-           (pEntry->AuthMode == Ndis802_11AuthModeWPA2PSK))
-               bWPA2 = TRUE;
-
-       /* Init Packet and Fill header */
-       pMsg->ProVer = EAPOL_VER;
-       pMsg->ProType = EAPOLKey;
-
-       /* Default 95 bytes, the EAPoL-Key descriptor exclude Key-data field */
-       SET_u16_TO_ARRARY(pMsg->Body_Len, LEN_EAPOL_KEY_MSG);
-
-       /* Fill in EAPoL descriptor */
-       if (bWPA2)
-               pMsg->KeyDesc.Type = WPA2_KEY_DESC;
-       else
-               pMsg->KeyDesc.Type = WPA1_KEY_DESC;
-
-       /* Key Descriptor Version (bits 0-2) specifies the key descriptor version type */
-       {
-               /* Fill in Key information, refer to IEEE Std 802.11i-2004 page 78 */
-               /* When either the pairwise or the group cipher is AES, the DESC_TYPE_AES(2) shall be used. */
-               KeyDescVer =
-                   (((pEntry->WepStatus == Ndis802_11Encryption3Enabled)
-                     || (GroupKeyWepStatus ==
-                         Ndis802_11Encryption3Enabled)) ? (DESC_TYPE_AES)
-                    : (DESC_TYPE_TKIP));
-       }
-
-       pMsg->KeyDesc.KeyInfo.KeyDescVer = KeyDescVer;
-
-       /* Specify Key Type as Group(0) or Pairwise(1) */
-       if (MsgType >= EAPOL_GROUP_MSG_1)
-               pMsg->KeyDesc.KeyInfo.KeyType = GROUPKEY;
-       else
-               pMsg->KeyDesc.KeyInfo.KeyType = PAIRWISEKEY;
-
-       /* Specify Key Index, only group_msg1_WPA1 */
-       if (!bWPA2 && (MsgType >= EAPOL_GROUP_MSG_1))
-               pMsg->KeyDesc.KeyInfo.KeyIndex = DefaultKeyIdx;
-
-       if (MsgType == EAPOL_PAIR_MSG_3)
-               pMsg->KeyDesc.KeyInfo.Install = 1;
-
-       if ((MsgType == EAPOL_PAIR_MSG_1) || (MsgType == EAPOL_PAIR_MSG_3)
-           || (MsgType == EAPOL_GROUP_MSG_1))
-               pMsg->KeyDesc.KeyInfo.KeyAck = 1;
-
-       if (MsgType != EAPOL_PAIR_MSG_1)
-               pMsg->KeyDesc.KeyInfo.KeyMic = 1;
-
-       if ((bWPA2 && (MsgType >= EAPOL_PAIR_MSG_3)) ||
-           (!bWPA2 && (MsgType >= EAPOL_GROUP_MSG_1))) {
-               pMsg->KeyDesc.KeyInfo.Secure = 1;
-       }
-
-       if (bWPA2 && ((MsgType == EAPOL_PAIR_MSG_3) ||
-                     (MsgType == EAPOL_GROUP_MSG_1))) {
-               pMsg->KeyDesc.KeyInfo.EKD_DL = 1;
-       }
-       /* key Information element has done. */
-       *(u16 *) (&pMsg->KeyDesc.KeyInfo) =
-           cpu2le16(*(u16 *) (&pMsg->KeyDesc.KeyInfo));
-
-       /* Fill in Key Length */
-       {
-               if (MsgType >= EAPOL_GROUP_MSG_1) {
-                       /* the length of group key cipher */
-                       pMsg->KeyDesc.KeyLength[1] =
-                           ((GroupKeyWepStatus ==
-                             Ndis802_11Encryption2Enabled) ? TKIP_GTK_LENGTH :
-                            LEN_AES_KEY);
-               } else {
-                       /* the length of pairwise key cipher */
-                       pMsg->KeyDesc.KeyLength[1] =
-                           ((pEntry->WepStatus ==
-                             Ndis802_11Encryption2Enabled) ? LEN_TKIP_KEY :
-                            LEN_AES_KEY);
-               }
-       }
-
-       /* Fill in replay counter */
-       NdisMoveMemory(pMsg->KeyDesc.ReplayCounter, pEntry->R_Counter,
-                      LEN_KEY_DESC_REPLAY);
-
-       /* Fill Key Nonce field */
-       /* ANonce : pairwise_msg1 & pairwise_msg3 */
-       /* SNonce : pairwise_msg2 */
-       /* GNonce : group_msg1_wpa1 */
-       if ((MsgType <= EAPOL_PAIR_MSG_3)
-           || ((!bWPA2 && (MsgType == EAPOL_GROUP_MSG_1))))
-               NdisMoveMemory(pMsg->KeyDesc.KeyNonce, KeyNonce,
-                              LEN_KEY_DESC_NONCE);
-
-       /* Fill key IV - WPA2 as 0, WPA1 as random */
-       if (!bWPA2 && (MsgType == EAPOL_GROUP_MSG_1)) {
-               /* Suggest IV be random number plus some number, */
-               NdisMoveMemory(pMsg->KeyDesc.KeyIv, &KeyNonce[16],
-                              LEN_KEY_DESC_IV);
-               pMsg->KeyDesc.KeyIv[15] += 2;
-       }
-       /* Fill Key RSC field */
-       /* It contains the RSC for the GTK being installed. */
-       if ((MsgType == EAPOL_PAIR_MSG_3 && bWPA2)
-           || (MsgType == EAPOL_GROUP_MSG_1)) {
-               NdisMoveMemory(pMsg->KeyDesc.KeyRsc, TxRSC, 6);
-       }
-       /* Clear Key MIC field for MIC calculation later */
-       NdisZeroMemory(pMsg->KeyDesc.KeyMic, LEN_KEY_DESC_MIC);
-
-       ConstructEapolKeyData(pEntry,
-                             GroupKeyWepStatus,
-                             KeyDescVer,
-                             MsgType,
-                             DefaultKeyIdx, GTK, RSNIE, RSNIE_Len, pMsg);
-
-       /* Calculate MIC and fill in KeyMic Field except Pairwise Msg 1. */
-       if (MsgType != EAPOL_PAIR_MSG_1) {
-               CalculateMIC(KeyDescVer, pEntry->PTK, pMsg);
-       }
-
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("===> ConstructEapolMsg for %s %s\n",
-                 ((bWPA2) ? "WPA2" : "WPA"), GetEapolMsgType(MsgType)));
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("          Body length = %d \n",
-                 CONV_ARRARY_TO_u16(pMsg->Body_Len)));
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("          Key length  = %d \n",
-                 CONV_ARRARY_TO_u16(pMsg->KeyDesc.KeyLength)));
-
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Construct the Key Data field of EAPoL message
-
-       Arguments:
-               pAd                     Pointer to our adapter
-               Elem            Message body
-
-       Return Value:
-               None
-
-       Note:
-
-       ========================================================================
-*/
-void ConstructEapolKeyData(struct rt_mac_table_entry *pEntry,
-                          u8 GroupKeyWepStatus,
-                          u8 keyDescVer,
-                          u8 MsgType,
-                          u8 DefaultKeyIdx,
-                          u8 * GTK,
-                          u8 * RSNIE,
-                          u8 RSNIE_LEN, struct rt_eapol_packet * pMsg)
-{
-       u8 *mpool, *Key_Data, *Rc4GTK;
-       u8 ekey[(LEN_KEY_DESC_IV + LEN_EAP_EK)];
-       unsigned long data_offset;
-       BOOLEAN bWPA2Capable = FALSE;
-       struct rt_rtmp_adapter *pAd = pEntry->pAd;
-       BOOLEAN GTK_Included = FALSE;
-
-       /* Choose WPA2 or not */
-       if ((pEntry->AuthMode == Ndis802_11AuthModeWPA2) ||
-           (pEntry->AuthMode == Ndis802_11AuthModeWPA2PSK))
-               bWPA2Capable = TRUE;
-
-       if (MsgType == EAPOL_PAIR_MSG_1 ||
-           MsgType == EAPOL_PAIR_MSG_4 || MsgType == EAPOL_GROUP_MSG_2)
-               return;
-
-       /* allocate memory pool */
-       os_alloc_mem(NULL, (u8 **) & mpool, 1500);
-
-       if (mpool == NULL)
-               return;
-
-       /* Rc4GTK Len = 512 */
-       Rc4GTK = (u8 *) ROUND_UP(mpool, 4);
-       /* Key_Data Len = 512 */
-       Key_Data = (u8 *) ROUND_UP(Rc4GTK + 512, 4);
-
-       NdisZeroMemory(Key_Data, 512);
-       SET_u16_TO_ARRARY(pMsg->KeyDesc.KeyDataLen, 0);
-       data_offset = 0;
-
-       /* Encapsulate RSNIE in pairwise_msg2 & pairwise_msg3 */
-       if (RSNIE_LEN
-           && ((MsgType == EAPOL_PAIR_MSG_2)
-               || (MsgType == EAPOL_PAIR_MSG_3))) {
-               u8 *pmkid_ptr = NULL;
-               u8 pmkid_len = 0;
-
-               RTMPInsertRSNIE(&Key_Data[data_offset],
-                               &data_offset,
-                               RSNIE, RSNIE_LEN, pmkid_ptr, pmkid_len);
-       }
-
-       /* Encapsulate KDE format in pairwise_msg3_WPA2 & group_msg1_WPA2 */
-       if (bWPA2Capable
-           && ((MsgType == EAPOL_PAIR_MSG_3)
-               || (MsgType == EAPOL_GROUP_MSG_1))) {
-               /* Key Data Encapsulation (KDE) format - 802.11i-2004  Figure-43w and Table-20h */
-               Key_Data[data_offset + 0] = 0xDD;
-
-               if (GroupKeyWepStatus == Ndis802_11Encryption3Enabled) {
-                       Key_Data[data_offset + 1] = 0x16;       /* 4+2+16(OUI+DataType+DataField) */
-               } else {
-                       Key_Data[data_offset + 1] = 0x26;       /* 4+2+32(OUI+DataType+DataField) */
-               }
-
-               Key_Data[data_offset + 2] = 0x00;
-               Key_Data[data_offset + 3] = 0x0F;
-               Key_Data[data_offset + 4] = 0xAC;
-               Key_Data[data_offset + 5] = 0x01;
-
-               /* GTK KDE format - 802.11i-2004  Figure-43x */
-               Key_Data[data_offset + 6] = (DefaultKeyIdx & 0x03);
-               Key_Data[data_offset + 7] = 0x00;       /* Reserved Byte */
-
-               data_offset += 8;
-       }
-
-       /* Encapsulate GTK */
-       /* Only for pairwise_msg3_WPA2 and group_msg1 */
-       if ((MsgType == EAPOL_PAIR_MSG_3 && bWPA2Capable)
-           || (MsgType == EAPOL_GROUP_MSG_1)) {
-               /* Fill in GTK */
-               if (GroupKeyWepStatus == Ndis802_11Encryption3Enabled) {
-                       NdisMoveMemory(&Key_Data[data_offset], GTK,
-                                      LEN_AES_KEY);
-                       data_offset += LEN_AES_KEY;
-               } else {
-                       NdisMoveMemory(&Key_Data[data_offset], GTK,
-                                      TKIP_GTK_LENGTH);
-                       data_offset += TKIP_GTK_LENGTH;
-               }
-
-               GTK_Included = TRUE;
-       }
-
-       /* This whole key-data field shall be encrypted if a GTK is included. */
-       /* Encrypt the data material in key data field with KEK */
-       if (GTK_Included) {
-               /*hex_dump("GTK_Included", Key_Data, data_offset); */
-
-               if ((keyDescVer == DESC_TYPE_AES)) {
-                       u8 remainder = 0;
-                       u8 pad_len = 0;
-
-                       /* Key Descriptor Version 2 or 3: AES key wrap, defined in IETF RFC 3394, */
-                       /* shall be used to encrypt the Key Data field using the KEK field from */
-                       /* the derived PTK. */
-
-                       /* If the Key Data field uses the NIST AES key wrap, then the Key Data field */
-                       /* shall be padded before encrypting if the key data length is less than 16 */
-                       /* octets or if it is not a multiple of 8. The padding consists of appending */
-                       /* a single octet 0xdd followed by zero or more 0x00 octets. */
-                       if ((remainder = data_offset & 0x07) != 0) {
-                               int i;
-
-                               pad_len = (8 - remainder);
-                               Key_Data[data_offset] = 0xDD;
-                               for (i = 1; i < pad_len; i++)
-                                       Key_Data[data_offset + i] = 0;
-
-                               data_offset += pad_len;
-                       }
-
-                       AES_GTK_KEY_WRAP(&pEntry->PTK[16], Key_Data,
-                                        data_offset, Rc4GTK);
-                       /* AES wrap function will grow 8 bytes in length */
-                       data_offset += 8;
-               } else {
-                       /*      Key Descriptor Version 1: ARC4 is used to encrypt the Key Data field
-                          using the KEK field from the derived PTK. */
-
-                       /* PREPARE Encrypted  "Key DATA" field.  (Encrypt GTK with RC4, usinf PTK[16]->[31] as Key, IV-field as IV) */
-                       /* put TxTsc in Key RSC field */
-                       pAd->PrivateInfo.FCSCRC32 = PPPINITFCS32;       /*Init crc32. */
-
-                       /* ekey is the contanetion of IV-field, and PTK[16]->PTK[31] */
-                       NdisMoveMemory(ekey, pMsg->KeyDesc.KeyIv,
-                                      LEN_KEY_DESC_IV);
-                       NdisMoveMemory(&ekey[LEN_KEY_DESC_IV], &pEntry->PTK[16],
-                                      LEN_EAP_EK);
-                       ARCFOUR_INIT(&pAd->PrivateInfo.WEPCONTEXT, ekey, sizeof(ekey)); /*INIT SBOX, KEYLEN+3(IV) */
-                       pAd->PrivateInfo.FCSCRC32 =
-                           RTMP_CALC_FCS32(pAd->PrivateInfo.FCSCRC32, Key_Data,
-                                           data_offset);
-                       WPAARCFOUR_ENCRYPT(&pAd->PrivateInfo.WEPCONTEXT, Rc4GTK,
-                                          Key_Data, data_offset);
-               }
-
-               NdisMoveMemory(pMsg->KeyDesc.KeyData, Rc4GTK, data_offset);
-       } else {
-               NdisMoveMemory(pMsg->KeyDesc.KeyData, Key_Data, data_offset);
-       }
-
-       /* Update key data length field and total body length */
-       SET_u16_TO_ARRARY(pMsg->KeyDesc.KeyDataLen, data_offset);
-       INC_u16_TO_ARRARY(pMsg->Body_Len, data_offset);
-
-       os_free_mem(NULL, mpool);
-
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Calcaulate MIC. It is used during 4-ways handsharking.
-
-       Arguments:
-               pAd                     -       pointer to our pAdapter context
-       PeerWepStatus   -       indicate the encryption type
-
-       Return Value:
-
-       Note:
-
-       ========================================================================
-*/
-static void CalculateMIC(u8 KeyDescVer,
-                        u8 * PTK, struct rt_eapol_packet * pMsg)
-{
-       u8 *OutBuffer;
-       unsigned long FrameLen = 0;
-       u8 mic[LEN_KEY_DESC_MIC];
-       u8 digest[80];
-
-       /* allocate memory for MIC calculation */
-       os_alloc_mem(NULL, (u8 **) & OutBuffer, 512);
-
-       if (OutBuffer == NULL) {
-               DBGPRINT(RT_DEBUG_ERROR, ("CalculateMIC: no memory!\n"));
-               return;
-       }
-       /* make a frame for calculating MIC. */
-       MakeOutgoingFrame(OutBuffer, &FrameLen,
-                         CONV_ARRARY_TO_u16(pMsg->Body_Len) + 4, pMsg,
-                         END_OF_ARGS);
-
-       NdisZeroMemory(mic, sizeof(mic));
-
-       /* Calculate MIC */
-       if (KeyDescVer == DESC_TYPE_AES) {
-               HMAC_SHA1(PTK, LEN_EAP_MICK, OutBuffer, FrameLen, digest,
-                         SHA1_DIGEST_SIZE);
-               NdisMoveMemory(mic, digest, LEN_KEY_DESC_MIC);
-       } else {
-               HMAC_MD5(PTK, LEN_EAP_MICK, OutBuffer, FrameLen, mic,
-                        MD5_DIGEST_SIZE);
-       }
-
-       /* store the calculated MIC */
-       NdisMoveMemory(pMsg->KeyDesc.KeyMic, mic, LEN_KEY_DESC_MIC);
-
-       os_free_mem(NULL, OutBuffer);
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Some received frames can't decrypt by Asic, so decrypt them by software.
-
-       Arguments:
-               pAd                     -       pointer to our pAdapter context
-       PeerWepStatus   -       indicate the encryption type
-
-       Return Value:
-               NDIS_STATUS_SUCCESS             -       decryption successful
-               NDIS_STATUS_FAILURE             -       decryption failure
-
-       ========================================================================
-*/
-int RTMPSoftDecryptBroadCastData(struct rt_rtmp_adapter *pAd,
-                                        struct rt_rx_blk *pRxBlk,
-                                        IN NDIS_802_11_ENCRYPTION_STATUS
-                                        GroupCipher, struct rt_cipher_key *pShard_key)
-{
-       struct rt_rxwi * pRxWI = pRxBlk->pRxWI;
-
-       /* handle WEP decryption */
-       if (GroupCipher == Ndis802_11Encryption1Enabled) {
-               if (RTMPSoftDecryptWEP
-                   (pAd, pRxBlk->pData, pRxWI->MPDUtotalByteCount,
-                    pShard_key)) {
-
-                       /*Minus IV[4] & ICV[4] */
-                       pRxWI->MPDUtotalByteCount -= 8;
-               } else {
-                       DBGPRINT(RT_DEBUG_ERROR,
-                                ("ERROR : Software decrypt WEP data fails.\n"));
-                       /* give up this frame */
-                       return NDIS_STATUS_FAILURE;
-               }
-       }
-       /* handle TKIP decryption */
-       else if (GroupCipher == Ndis802_11Encryption2Enabled) {
-               if (RTMPSoftDecryptTKIP
-                   (pAd, pRxBlk->pData, pRxWI->MPDUtotalByteCount, 0,
-                    pShard_key)) {
-
-                       /*Minus 8 bytes MIC, 8 bytes IV/EIV, 4 bytes ICV */
-                       pRxWI->MPDUtotalByteCount -= 20;
-               } else {
-                       DBGPRINT(RT_DEBUG_ERROR,
-                                ("ERROR : RTMPSoftDecryptTKIP Failed\n"));
-                       /* give up this frame */
-                       return NDIS_STATUS_FAILURE;
-               }
-       }
-       /* handle AES decryption */
-       else if (GroupCipher == Ndis802_11Encryption3Enabled) {
-               if (RTMPSoftDecryptAES
-                   (pAd, pRxBlk->pData, pRxWI->MPDUtotalByteCount,
-                    pShard_key)) {
-
-                       /*8 bytes MIC, 8 bytes IV/EIV (CCMP Header) */
-                       pRxWI->MPDUtotalByteCount -= 16;
-               } else {
-                       DBGPRINT(RT_DEBUG_ERROR,
-                                ("ERROR : RTMPSoftDecryptAES Failed\n"));
-                       /* give up this frame */
-                       return NDIS_STATUS_FAILURE;
-               }
-       } else {
-               /* give up this frame */
-               return NDIS_STATUS_FAILURE;
-       }
-
-       return NDIS_STATUS_SUCCESS;
-
-}
-
-u8 *GetSuiteFromRSNIE(u8 *rsnie,
-                        u32 rsnie_len, u8 type, u8 * count)
-{
-       struct rt_eid * pEid;
-       int len;
-       u8 *pBuf;
-       int offset = 0;
-       struct rt_rsnie_auth *pAkm;
-       u16 acount;
-       BOOLEAN isWPA2 = FALSE;
-
-       pEid = (struct rt_eid *) rsnie;
-       len = rsnie_len - 2;    /* exclude IE and length */
-       pBuf = (u8 *)& pEid->Octet[0];
-
-       /* set default value */
-       *count = 0;
-
-       /* Check length */
-       if ((len <= 0) || (pEid->Len != len)) {
-               DBGPRINT_ERR("%s : The length is invalid\n", __func__);
-               return NULL;
-       }
-       /* Check WPA or WPA2 */
-       if (pEid->Eid == IE_WPA) {
-               struct rt_rsnie *pRsnie = (struct rt_rsnie *)pBuf;
-               u16 ucount;
-
-               if (len < sizeof(struct rt_rsnie)) {
-                       DBGPRINT_ERR("%s : The length is too short for WPA\n", __func__);
-                       return NULL;
-               }
-               /* Get the count of pairwise cipher */
-               ucount = cpu2le16(pRsnie->ucount);
-               if (ucount > 2) {
-                       DBGPRINT_ERR("%s : The count(%d) of pairwise cipher is invlaid\n", __func__, ucount);
-                       return NULL;
-               }
-               /* Get the group cipher */
-               if (type == GROUP_SUITE) {
-                       *count = 1;
-                       return pRsnie->mcast;
-               }
-               /* Get the pairwise cipher suite */
-               else if (type == PAIRWISE_SUITE) {
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("%s : The count of pairwise cipher is %d\n",
-                                 __func__, ucount));
-                       *count = ucount;
-                       return pRsnie->ucast[0].oui;
-               }
-
-               offset = sizeof(struct rt_rsnie) + (4 * (ucount - 1));
-
-       } else if (pEid->Eid == IE_RSN) {
-               struct rt_rsnie2 *pRsnie = (struct rt_rsnie2 *)pBuf;
-               u16 ucount;
-
-               isWPA2 = TRUE;
-
-               if (len < sizeof(struct rt_rsnie2)) {
-                       DBGPRINT_ERR("%s : The length is too short for WPA2\n", __func__);
-                       return NULL;
-               }
-               /* Get the count of pairwise cipher */
-               ucount = cpu2le16(pRsnie->ucount);
-               if (ucount > 2) {
-                       DBGPRINT_ERR("%s : The count(%d) of pairwise cipher is invlaid\n", __func__, ucount);
-                       return NULL;
-               }
-               /* Get the group cipher */
-               if (type == GROUP_SUITE) {
-                       *count = 1;
-                       return pRsnie->mcast;
-               }
-               /* Get the pairwise cipher suite */
-               else if (type == PAIRWISE_SUITE) {
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("%s : The count of pairwise cipher is %d\n",
-                                 __func__, ucount));
-                       *count = ucount;
-                       return pRsnie->ucast[0].oui;
-               }
-
-               offset = sizeof(struct rt_rsnie2) + (4 * (ucount - 1));
-
-       } else {
-               DBGPRINT_ERR("%s : Unknown IE (%d)\n", __func__, pEid->Eid);
-               return NULL;
-       }
-
-       /* skip group cipher and pairwise cipher suite */
-       pBuf += offset;
-       len -= offset;
-
-       if (len < sizeof(struct rt_rsnie_auth)) {
-               DBGPRINT_ERR("%s : The length of RSNIE is too short\n", __func__);
-               return NULL;
-       }
-       /* pointer to AKM count */
-       pAkm = (struct rt_rsnie_auth *)pBuf;
-
-       /* Get the count of pairwise cipher */
-       acount = cpu2le16(pAkm->acount);
-       if (acount > 2) {
-               DBGPRINT_ERR("%s : The count(%d) of AKM is invlaid\n", __func__, acount);
-               return NULL;
-       }
-       /* Get the AKM suite */
-       if (type == AKM_SUITE) {
-               DBGPRINT(RT_DEBUG_TRACE, ("%s : The count of AKM is %d\n",
-                                         __func__, acount));
-               *count = acount;
-               return pAkm->auth[0].oui;
-       }
-       offset = sizeof(struct rt_rsnie_auth) + (4 * (acount - 1));
-
-       pBuf += offset;
-       len -= offset;
-
-       /* The remaining length must larger than (RSN-Capability(2) + PMKID-Count(2) + PMKID(16~)) */
-       if (len >= (sizeof(RSN_CAPABILITIES) + 2 + LEN_PMKID)) {
-               /* Skip RSN capability and PMKID-Count */
-               pBuf += (sizeof(RSN_CAPABILITIES) + 2);
-               len -= (sizeof(RSN_CAPABILITIES) + 2);
-
-               /* Get PMKID */
-               if (type == PMKID_LIST) {
-                       *count = 1;
-                       return pBuf;
-               }
-       } else {
-               DBGPRINT_ERR("%s : it can't get any more information beyond AKM \n", __func__);
-               return NULL;
-       }
-
-       *count = 0;
-       /*DBGPRINT_ERR(("%s : The type(%d) doesn't support \n", __func__, type)); */
-       return NULL;
-
-}
-
-void WpaShowAllsuite(u8 *rsnie, u32 rsnie_len)
-{
-       u8 *pSuite = NULL;
-       u8 count;
-
-       hex_dump("RSNIE", rsnie, rsnie_len);
-
-       /* group cipher */
-       pSuite = GetSuiteFromRSNIE(rsnie, rsnie_len, GROUP_SUITE, &count);
-       if (pSuite != NULL) {
-               hex_dump("group cipher", pSuite, 4 * count);
-       }
-       /* pairwise cipher */
-       pSuite = GetSuiteFromRSNIE(rsnie, rsnie_len, PAIRWISE_SUITE, &count);
-       if (pSuite != NULL) {
-               hex_dump("pairwise cipher", pSuite, 4 * count);
-       }
-       /* AKM */
-       pSuite = GetSuiteFromRSNIE(rsnie, rsnie_len, AKM_SUITE, &count);
-       if (pSuite != NULL) {
-               hex_dump("AKM suite", pSuite, 4 * count);
-       }
-       /* PMKID */
-       pSuite = GetSuiteFromRSNIE(rsnie, rsnie_len, PMKID_LIST, &count);
-       if (pSuite != NULL) {
-               hex_dump("PMKID", pSuite, LEN_PMKID);
-       }
-
-}
-
-void RTMPInsertRSNIE(u8 *pFrameBuf,
-                    unsigned long *pFrameLen,
-                    u8 *rsnie_ptr,
-                    u8 rsnie_len,
-                    u8 *pmkid_ptr, u8 pmkid_len)
-{
-       u8 *pTmpBuf;
-       unsigned long TempLen = 0;
-       u8 extra_len = 0;
-       u16 pmk_count = 0;
-       u8 ie_num;
-       u8 total_len = 0;
-       u8 WPA2_OUI[3] = { 0x00, 0x0F, 0xAC };
-
-       pTmpBuf = pFrameBuf;
-
-       /* PMKID-List Must larger than 0 and the multiple of 16. */
-       if (pmkid_len > 0 && ((pmkid_len & 0x0f) == 0)) {
-               extra_len = sizeof(u16)+ pmkid_len;
-
-               pmk_count = (pmkid_len >> 4);
-               pmk_count = cpu2le16(pmk_count);
-       } else {
-               DBGPRINT(RT_DEBUG_WARN,
-                        ("%s : The length is PMKID-List is invalid (%d), so don't insert it.\n",
-                         __func__, pmkid_len));
-       }
-
-       if (rsnie_len != 0) {
-               ie_num = IE_WPA;
-               total_len = rsnie_len;
-
-               if (NdisEqualMemory(rsnie_ptr + 2, WPA2_OUI, sizeof(WPA2_OUI))) {
-                       ie_num = IE_RSN;
-                       total_len += extra_len;
-               }
-
-               /* construct RSNIE body */
-               MakeOutgoingFrame(pTmpBuf, &TempLen,
-                                 1, &ie_num,
-                                 1, &total_len,
-                                 rsnie_len, rsnie_ptr, END_OF_ARGS);
-
-               pTmpBuf += TempLen;
-               *pFrameLen = *pFrameLen + TempLen;
-
-               if (ie_num == IE_RSN) {
-                       /* Insert PMKID-List field */
-                       if (extra_len > 0) {
-                               MakeOutgoingFrame(pTmpBuf, &TempLen,
-                                                 2, &pmk_count,
-                                                 pmkid_len, pmkid_ptr,
-                                                 END_OF_ARGS);
-
-                               pTmpBuf += TempLen;
-                               *pFrameLen = *pFrameLen + TempLen;
-                       }
-               }
-       }
-
-       return;
-}
diff --git a/drivers/staging/rt2860/common/crypt_hmac.c b/drivers/staging/rt2860/common/crypt_hmac.c
deleted file mode 100644 (file)
index d7ab08e..0000000
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************/
-
-#include "../crypt_hmac.h"
-
-#ifdef HMAC_SHA1_SUPPORT
-/*
-========================================================================
-Routine Description:
-    HMAC using SHA1 hash function
-
-Arguments:
-    key             Secret key
-    key_len         The length of the key in bytes
-    message         Message context
-    message_len     The length of message in bytes
-    macLen          Request the length of message authentication code
-
-Return Value:
-    mac             Message authentication code
-
-Note:
-    None
-========================================================================
-*/
-void HMAC_SHA1(IN const u8 Key[],
-              u32 KeyLen,
-              IN const u8 Message[],
-              u32 MessageLen, u8 MAC[], u32 MACLen)
-{
-       struct rt_sha1_ctx sha_ctx1;
-       struct rt_sha1_ctx sha_ctx2;
-       u8 K0[SHA1_BLOCK_SIZE];
-       u8 Digest[SHA1_DIGEST_SIZE];
-       u32 index;
-
-       NdisZeroMemory(&sha_ctx1, sizeof(struct rt_sha1_ctx));
-       NdisZeroMemory(&sha_ctx2, sizeof(struct rt_sha1_ctx));
-       /*
-        * If the length of K = B(Block size): K0 = K.
-        * If the length of K > B: hash K to obtain an L byte string,
-        * then append (B-L) zeros to create a B-byte string K0 (i.e., K0 = H(K) || 00...00).
-        * If the length of K < B: append zeros to the end of K to create a B-byte string K0
-        */
-       NdisZeroMemory(K0, SHA1_BLOCK_SIZE);
-       if (KeyLen <= SHA1_BLOCK_SIZE)
-               NdisMoveMemory(K0, Key, KeyLen);
-       else
-               RT_SHA1(Key, KeyLen, K0);
-       /* End of if */
-
-       /* Exclusive-Or K0 with ipad */
-       /* ipad: Inner pad; the byte x¡¦36¡¦ repeated B times. */
-       for (index = 0; index < SHA1_BLOCK_SIZE; index++)
-               K0[index] ^= 0x36;
-       /* End of for */
-
-       RT_SHA1_Init(&sha_ctx1);
-       /* H(K0^ipad) */
-       SHA1_Append(&sha_ctx1, K0, sizeof(K0));
-       /* H((K0^ipad)||text) */
-       SHA1_Append(&sha_ctx1, Message, MessageLen);
-       SHA1_End(&sha_ctx1, Digest);
-
-       /* Exclusive-Or K0 with opad and remove ipad */
-       /* opad: Outer pad; the byte x¡¦5c¡¦ repeated B times. */
-       for (index = 0; index < SHA1_BLOCK_SIZE; index++)
-               K0[index] ^= 0x36 ^ 0x5c;
-       /* End of for */
-
-       RT_SHA1_Init(&sha_ctx2);
-       /* H(K0^opad) */
-       SHA1_Append(&sha_ctx2, K0, sizeof(K0));
-       /* H( (K0^opad) || H((K0^ipad)||text) ) */
-       SHA1_Append(&sha_ctx2, Digest, SHA1_DIGEST_SIZE);
-       SHA1_End(&sha_ctx2, Digest);
-
-       if (MACLen > SHA1_DIGEST_SIZE)
-               NdisMoveMemory(MAC, Digest, SHA1_DIGEST_SIZE);
-       else
-               NdisMoveMemory(MAC, Digest, MACLen);
-}                              /* End of HMAC_SHA1 */
-#endif /* HMAC_SHA1_SUPPORT */
-
-#ifdef HMAC_MD5_SUPPORT
-/*
-========================================================================
-Routine Description:
-    HMAC using MD5 hash function
-
-Arguments:
-    key             Secret key
-    key_len         The length of the key in bytes
-    message         Message context
-    message_len     The length of message in bytes
-    macLen          Request the length of message authentication code
-
-Return Value:
-    mac             Message authentication code
-
-Note:
-    None
-========================================================================
-*/
-void HMAC_MD5(IN const u8 Key[],
-             u32 KeyLen,
-             IN const u8 Message[],
-             u32 MessageLen, u8 MAC[], u32 MACLen)
-{
-       struct rt_md5_ctx_struc md5_ctx1;
-       struct rt_md5_ctx_struc md5_ctx2;
-       u8 K0[MD5_BLOCK_SIZE];
-       u8 Digest[MD5_DIGEST_SIZE];
-       u32 index;
-
-       NdisZeroMemory(&md5_ctx1, sizeof(struct rt_md5_ctx_struc));
-       NdisZeroMemory(&md5_ctx2, sizeof(struct rt_md5_ctx_struc));
-       /*
-        * If the length of K = B(Block size): K0 = K.
-        * If the length of K > B: hash K to obtain an L byte string,
-        * then append (B-L) zeros to create a B-byte string K0 (i.e., K0 = H(K) || 00...00).
-        * If the length of K < B: append zeros to the end of K to create a B-byte string K0
-        */
-       NdisZeroMemory(K0, MD5_BLOCK_SIZE);
-       if (KeyLen <= MD5_BLOCK_SIZE) {
-               NdisMoveMemory(K0, Key, KeyLen);
-       } else {
-               RT_MD5(Key, KeyLen, K0);
-       }
-
-       /* Exclusive-Or K0 with ipad */
-       /* ipad: Inner pad; the byte x¡¦36¡¦ repeated B times. */
-       for (index = 0; index < MD5_BLOCK_SIZE; index++)
-               K0[index] ^= 0x36;
-       /* End of for */
-
-       MD5_Init(&md5_ctx1);
-       /* H(K0^ipad) */
-       MD5_Append(&md5_ctx1, K0, sizeof(K0));
-       /* H((K0^ipad)||text) */
-       MD5_Append(&md5_ctx1, Message, MessageLen);
-       MD5_End(&md5_ctx1, Digest);
-
-       /* Exclusive-Or K0 with opad and remove ipad */
-       /* opad: Outer pad; the byte x¡¦5c¡¦ repeated B times. */
-       for (index = 0; index < MD5_BLOCK_SIZE; index++)
-               K0[index] ^= 0x36 ^ 0x5c;
-       /* End of for */
-
-       MD5_Init(&md5_ctx2);
-       /* H(K0^opad) */
-       MD5_Append(&md5_ctx2, K0, sizeof(K0));
-       /* H( (K0^opad) || H((K0^ipad)||text) ) */
-       MD5_Append(&md5_ctx2, Digest, MD5_DIGEST_SIZE);
-       MD5_End(&md5_ctx2, Digest);
-
-       if (MACLen > MD5_DIGEST_SIZE)
-               NdisMoveMemory(MAC, Digest, MD5_DIGEST_SIZE);
-       else
-               NdisMoveMemory(MAC, Digest, MACLen);
-}                              /* End of HMAC_SHA256 */
-#endif /* HMAC_MD5_SUPPORT */
-
-/* End of crypt_hmac.c */
diff --git a/drivers/staging/rt2860/common/crypt_md5.c b/drivers/staging/rt2860/common/crypt_md5.c
deleted file mode 100644 (file)
index 6deab65..0000000
+++ /dev/null
@@ -1,339 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************/
-
-#include "../crypt_md5.h"
-
-#ifdef MD5_SUPPORT
-/*
- * F, G, H and I are basic MD5 functions.
- */
-#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
-#define G(x, y, z) (((x) & (z)) | ((y) & (~z)))
-#define H(x, y, z) ((x) ^ (y) ^ (z))
-#define I(x, y, z) ((y) ^ ((x) | (~z)))
-
-#define ROTL(x,n,w) ((x << n) | (x >> (w - n)))
-#define ROTL32(x,n) ROTL(x,n,32)       /* 32 bits word */
-
-#define ROUND1(a, b, c, d, x, s, ac) {          \
-    (a) += F((b),(c),(d)) + (x) + (u32)(ac); \
-    (a)  = ROTL32((a),(s));                     \
-    (a) += (b);                                 \
-}
-#define ROUND2(a, b, c, d, x, s, ac) {          \
-    (a) += G((b),(c),(d)) + (x) + (u32)(ac); \
-    (a)  = ROTL32((a),(s));                     \
-    (a) += (b);                                 \
-}
-#define ROUND3(a, b, c, d, x, s, ac) {          \
-    (a) += H((b),(c),(d)) + (x) + (u32)(ac); \
-    (a)  = ROTL32((a),(s));                     \
-    (a) += (b);                                 \
-}
-#define ROUND4(a, b, c, d, x, s, ac) {          \
-    (a) += I((b),(c),(d)) + (x) + (u32)(ac); \
-    (a)  = ROTL32((a),(s));                     \
-    (a) += (b);                                 \
-}
-static const u32 MD5_DefaultHashValue[4] = {
-       0x67452301UL, 0xefcdab89UL, 0x98badcfeUL, 0x10325476UL
-};
-#endif /* MD5_SUPPORT */
-
-#ifdef MD5_SUPPORT
-/*
-========================================================================
-Routine Description:
-    Initial Md5_CTX_STRUC
-
-Arguments:
-    pMD5_CTX        Pointer to Md5_CTX_STRUC
-
-Return Value:
-    None
-
-Note:
-    None
-========================================================================
-*/
-void MD5_Init(struct rt_md5_ctx_struc *pMD5_CTX)
-{
-       NdisMoveMemory(pMD5_CTX->HashValue, MD5_DefaultHashValue,
-                      sizeof(MD5_DefaultHashValue));
-       NdisZeroMemory(pMD5_CTX->Block, MD5_BLOCK_SIZE);
-       pMD5_CTX->BlockLen = 0;
-       pMD5_CTX->MessageLen = 0;
-}                              /* End of MD5_Init */
-
-/*
-========================================================================
-Routine Description:
-    MD5 computation for one block (512 bits)
-
-Arguments:
-    pMD5_CTX        Pointer to Md5_CTX_STRUC
-
-Return Value:
-    None
-
-Note:
-    T[i] := floor(abs(sin(i + 1)) * (2 pow 32)), i is number of round
-========================================================================
-*/
-void MD5_Hash(struct rt_md5_ctx_struc *pMD5_CTX)
-{
-       u32 X_i;
-       u32 X[16];
-       u32 a, b, c, d;
-
-       /* Prepare the message schedule, {X_i} */
-       NdisMoveMemory(X, pMD5_CTX->Block, MD5_BLOCK_SIZE);
-       for (X_i = 0; X_i < 16; X_i++)
-               X[X_i] = cpu2le32(X[X_i]);      /* Endian Swap */
-       /* End of for */
-
-       /* MD5 hash computation */
-       /* Initialize the working variables */
-       a = pMD5_CTX->HashValue[0];
-       b = pMD5_CTX->HashValue[1];
-       c = pMD5_CTX->HashValue[2];
-       d = pMD5_CTX->HashValue[3];
-
-       /*
-        *  Round 1
-        *  Let [abcd k s i] denote the operation
-        *  a = b + ((a + F(b,c,d) + X[k] + T[i]) <<< s)
-        */
-       ROUND1(a, b, c, d, X[0], 7, 0xd76aa478);        /* 1 */
-       ROUND1(d, a, b, c, X[1], 12, 0xe8c7b756);       /* 2 */
-       ROUND1(c, d, a, b, X[2], 17, 0x242070db);       /* 3 */
-       ROUND1(b, c, d, a, X[3], 22, 0xc1bdceee);       /* 4 */
-       ROUND1(a, b, c, d, X[4], 7, 0xf57c0faf);        /* 5 */
-       ROUND1(d, a, b, c, X[5], 12, 0x4787c62a);       /* 6 */
-       ROUND1(c, d, a, b, X[6], 17, 0xa8304613);       /* 7 */
-       ROUND1(b, c, d, a, X[7], 22, 0xfd469501);       /* 8 */
-       ROUND1(a, b, c, d, X[8], 7, 0x698098d8);        /* 9 */
-       ROUND1(d, a, b, c, X[9], 12, 0x8b44f7af);       /* 10 */
-       ROUND1(c, d, a, b, X[10], 17, 0xffff5bb1);      /* 11 */
-       ROUND1(b, c, d, a, X[11], 22, 0x895cd7be);      /* 12 */
-       ROUND1(a, b, c, d, X[12], 7, 0x6b901122);       /* 13 */
-       ROUND1(d, a, b, c, X[13], 12, 0xfd987193);      /* 14 */
-       ROUND1(c, d, a, b, X[14], 17, 0xa679438e);      /* 15 */
-       ROUND1(b, c, d, a, X[15], 22, 0x49b40821);      /* 16 */
-
-       /*
-        *  Round 2
-        *  Let [abcd k s i] denote the operation
-        *  a = b + ((a + G(b,c,d) + X[k] + T[i]) <<< s)
-        */
-       ROUND2(a, b, c, d, X[1], 5, 0xf61e2562);        /* 17 */
-       ROUND2(d, a, b, c, X[6], 9, 0xc040b340);        /* 18 */
-       ROUND2(c, d, a, b, X[11], 14, 0x265e5a51);      /* 19 */
-       ROUND2(b, c, d, a, X[0], 20, 0xe9b6c7aa);       /* 20 */
-       ROUND2(a, b, c, d, X[5], 5, 0xd62f105d);        /* 21 */
-       ROUND2(d, a, b, c, X[10], 9, 0x2441453);        /* 22 */
-       ROUND2(c, d, a, b, X[15], 14, 0xd8a1e681);      /* 23 */
-       ROUND2(b, c, d, a, X[4], 20, 0xe7d3fbc8);       /* 24 */
-       ROUND2(a, b, c, d, X[9], 5, 0x21e1cde6);        /* 25 */
-       ROUND2(d, a, b, c, X[14], 9, 0xc33707d6);       /* 26 */
-       ROUND2(c, d, a, b, X[3], 14, 0xf4d50d87);       /* 27 */
-       ROUND2(b, c, d, a, X[8], 20, 0x455a14ed);       /* 28 */
-       ROUND2(a, b, c, d, X[13], 5, 0xa9e3e905);       /* 29 */
-       ROUND2(d, a, b, c, X[2], 9, 0xfcefa3f8);        /* 30 */
-       ROUND2(c, d, a, b, X[7], 14, 0x676f02d9);       /* 31 */
-       ROUND2(b, c, d, a, X[12], 20, 0x8d2a4c8a);      /* 32 */
-
-       /*
-        *  Round 3
-        *  Let [abcd k s t] denote the operation
-        *  a = b + ((a + H(b,c,d) + X[k] + T[i]) <<< s)
-        */
-       ROUND3(a, b, c, d, X[5], 4, 0xfffa3942);        /* 33 */
-       ROUND3(d, a, b, c, X[8], 11, 0x8771f681);       /* 34 */
-       ROUND3(c, d, a, b, X[11], 16, 0x6d9d6122);      /* 35 */
-       ROUND3(b, c, d, a, X[14], 23, 0xfde5380c);      /* 36 */
-       ROUND3(a, b, c, d, X[1], 4, 0xa4beea44);        /* 37 */
-       ROUND3(d, a, b, c, X[4], 11, 0x4bdecfa9);       /* 38 */
-       ROUND3(c, d, a, b, X[7], 16, 0xf6bb4b60);       /* 39 */
-       ROUND3(b, c, d, a, X[10], 23, 0xbebfbc70);      /* 40 */
-       ROUND3(a, b, c, d, X[13], 4, 0x289b7ec6);       /* 41 */
-       ROUND3(d, a, b, c, X[0], 11, 0xeaa127fa);       /* 42 */
-       ROUND3(c, d, a, b, X[3], 16, 0xd4ef3085);       /* 43 */
-       ROUND3(b, c, d, a, X[6], 23, 0x4881d05);        /* 44 */
-       ROUND3(a, b, c, d, X[9], 4, 0xd9d4d039);        /* 45 */
-       ROUND3(d, a, b, c, X[12], 11, 0xe6db99e5);      /* 46 */
-       ROUND3(c, d, a, b, X[15], 16, 0x1fa27cf8);      /* 47 */
-       ROUND3(b, c, d, a, X[2], 23, 0xc4ac5665);       /* 48 */
-
-       /*
-        *  Round 4
-        *  Let [abcd k s t] denote the operation
-        *  a = b + ((a + I(b,c,d) + X[k] + T[i]) <<< s)
-        */
-       ROUND4(a, b, c, d, X[0], 6, 0xf4292244);        /* 49 */
-       ROUND4(d, a, b, c, X[7], 10, 0x432aff97);       /* 50 */
-       ROUND4(c, d, a, b, X[14], 15, 0xab9423a7);      /* 51 */
-       ROUND4(b, c, d, a, X[5], 21, 0xfc93a039);       /* 52 */
-       ROUND4(a, b, c, d, X[12], 6, 0x655b59c3);       /* 53 */
-       ROUND4(d, a, b, c, X[3], 10, 0x8f0ccc92);       /* 54 */
-       ROUND4(c, d, a, b, X[10], 15, 0xffeff47d);      /* 55 */
-       ROUND4(b, c, d, a, X[1], 21, 0x85845dd1);       /* 56 */
-       ROUND4(a, b, c, d, X[8], 6, 0x6fa87e4f);        /* 57 */
-       ROUND4(d, a, b, c, X[15], 10, 0xfe2ce6e0);      /* 58 */
-       ROUND4(c, d, a, b, X[6], 15, 0xa3014314);       /* 59 */
-       ROUND4(b, c, d, a, X[13], 21, 0x4e0811a1);      /* 60 */
-       ROUND4(a, b, c, d, X[4], 6, 0xf7537e82);        /* 61 */
-       ROUND4(d, a, b, c, X[11], 10, 0xbd3af235);      /* 62 */
-       ROUND4(c, d, a, b, X[2], 15, 0x2ad7d2bb);       /* 63 */
-       ROUND4(b, c, d, a, X[9], 21, 0xeb86d391);       /* 64 */
-
-       /* Compute the i^th intermediate hash value H^(i) */
-       pMD5_CTX->HashValue[0] += a;
-       pMD5_CTX->HashValue[1] += b;
-       pMD5_CTX->HashValue[2] += c;
-       pMD5_CTX->HashValue[3] += d;
-
-       NdisZeroMemory(pMD5_CTX->Block, MD5_BLOCK_SIZE);
-       pMD5_CTX->BlockLen = 0;
-}                              /* End of MD5_Hash */
-
-/*
-========================================================================
-Routine Description:
-    The message is appended to block. If block size > 64 bytes, the MD5_Hash
-will be called.
-
-Arguments:
-    pMD5_CTX        Pointer to struct rt_md5_ctx_struc
-    message         Message context
-    messageLen      The length of message in bytes
-
-Return Value:
-    None
-
-Note:
-    None
-========================================================================
-*/
-void MD5_Append(struct rt_md5_ctx_struc *pMD5_CTX,
-               IN const u8 Message[], u32 MessageLen)
-{
-       u32 appendLen = 0;
-       u32 diffLen = 0;
-
-       while (appendLen != MessageLen) {
-               diffLen = MessageLen - appendLen;
-               if ((pMD5_CTX->BlockLen + diffLen) < MD5_BLOCK_SIZE) {
-                       NdisMoveMemory(pMD5_CTX->Block + pMD5_CTX->BlockLen,
-                                      Message + appendLen, diffLen);
-                       pMD5_CTX->BlockLen += diffLen;
-                       appendLen += diffLen;
-               } else {
-                       NdisMoveMemory(pMD5_CTX->Block + pMD5_CTX->BlockLen,
-                                      Message + appendLen,
-                                      MD5_BLOCK_SIZE - pMD5_CTX->BlockLen);
-                       appendLen += (MD5_BLOCK_SIZE - pMD5_CTX->BlockLen);
-                       pMD5_CTX->BlockLen = MD5_BLOCK_SIZE;
-                       MD5_Hash(pMD5_CTX);
-               }               /* End of if */
-       }                       /* End of while */
-       pMD5_CTX->MessageLen += MessageLen;
-}                              /* End of MD5_Append */
-
-/*
-========================================================================
-Routine Description:
-    1. Append bit 1 to end of the message
-    2. Append the length of message in rightmost 64 bits
-    3. Transform the Hash Value to digest message
-
-Arguments:
-    pMD5_CTX        Pointer to struct rt_md5_ctx_struc
-
-Return Value:
-    digestMessage   Digest message
-
-Note:
-    None
-========================================================================
-*/
-void MD5_End(struct rt_md5_ctx_struc *pMD5_CTX, u8 DigestMessage[])
-{
-       u32 index;
-       u64 message_length_bits;
-
-       /* append 1 bits to end of the message */
-       NdisFillMemory(pMD5_CTX->Block + pMD5_CTX->BlockLen, 1, 0x80);
-
-       /* 55 = 64 - 8 - 1: append 1 bit(1 byte) and message length (8 bytes) */
-       if (pMD5_CTX->BlockLen > 55)
-               MD5_Hash(pMD5_CTX);
-       /* End of if */
-
-       /* Append the length of message in rightmost 64 bits */
-       message_length_bits = pMD5_CTX->MessageLen * 8;
-       message_length_bits = cpu2le64(message_length_bits);
-       NdisMoveMemory(&pMD5_CTX->Block[56], &message_length_bits, 8);
-       MD5_Hash(pMD5_CTX);
-
-       /* Return message digest, transform the u32 hash value to bytes */
-       for (index = 0; index < 4; index++)
-               pMD5_CTX->HashValue[index] =
-                   cpu2le32(pMD5_CTX->HashValue[index]);
-       /* End of for */
-       NdisMoveMemory(DigestMessage, pMD5_CTX->HashValue, MD5_DIGEST_SIZE);
-}                              /* End of MD5_End */
-
-/*
-========================================================================
-Routine Description:
-    MD5 algorithm
-
-Arguments:
-    message         Message context
-    messageLen      The length of message in bytes
-
-Return Value:
-    digestMessage   Digest message
-
-Note:
-    None
-========================================================================
-*/
-void RT_MD5(IN const u8 Message[],
-           u32 MessageLen, u8 DigestMessage[])
-{
-       struct rt_md5_ctx_struc md5_ctx;
-
-       NdisZeroMemory(&md5_ctx, sizeof(struct rt_md5_ctx_struc));
-       MD5_Init(&md5_ctx);
-       MD5_Append(&md5_ctx, Message, MessageLen);
-       MD5_End(&md5_ctx, DigestMessage);
-}                              /* End of RT_MD5 */
-
-#endif /* MD5_SUPPORT */
-
-/* End of crypt_md5.c */
diff --git a/drivers/staging/rt2860/common/crypt_sha2.c b/drivers/staging/rt2860/common/crypt_sha2.c
deleted file mode 100644 (file)
index fa83fb2..0000000
+++ /dev/null
@@ -1,269 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************/
-
-#include "../crypt_sha2.h"
-
-/* Basic operations */
-#define SHR(x,n) (x >> n)      /* SHR(x)^n, right shift n bits , x is w-bit word, 0 <= n <= w */
-#define ROTR(x,n,w) ((x >> n) | (x << (w - n)))        /* ROTR(x)^n, circular right shift n bits , x is w-bit word, 0 <= n <= w */
-#define ROTL(x,n,w) ((x << n) | (x >> (w - n)))        /* ROTL(x)^n, circular left shift n bits , x is w-bit word, 0 <= n <= w */
-#define ROTR32(x,n) ROTR(x,n,32)       /* 32 bits word */
-#define ROTL32(x,n) ROTL(x,n,32)       /* 32 bits word */
-
-/* Basic functions */
-#define Ch(x,y,z) ((x & y) ^ ((~x) & z))
-#define Maj(x,y,z) ((x & y) ^ (x & z) ^ (y & z))
-#define Parity(x,y,z) (x ^ y ^ z)
-
-#ifdef SHA1_SUPPORT
-/* SHA1 constants */
-#define SHA1_MASK 0x0000000f
-static const u32 SHA1_K[4] = {
-       0x5a827999UL, 0x6ed9eba1UL, 0x8f1bbcdcUL, 0xca62c1d6UL
-};
-
-static const u32 SHA1_DefaultHashValue[5] = {
-       0x67452301UL, 0xefcdab89UL, 0x98badcfeUL, 0x10325476UL, 0xc3d2e1f0UL
-};
-
-/*
-========================================================================
-Routine Description:
-    Initial struct rt_sha1_ctx
-
-Arguments:
-    pSHA_CTX        Pointer to struct rt_sha1_ctx
-
-Return Value:
-    None
-
-Note:
-    None
-========================================================================
-*/
-void RT_SHA1_Init(struct rt_sha1_ctx *pSHA_CTX)
-{
-       NdisMoveMemory(pSHA_CTX->HashValue, SHA1_DefaultHashValue,
-                      sizeof(SHA1_DefaultHashValue));
-       NdisZeroMemory(pSHA_CTX->Block, SHA1_BLOCK_SIZE);
-       pSHA_CTX->MessageLen = 0;
-       pSHA_CTX->BlockLen = 0;
-}                              /* End of RT_SHA1_Init */
-
-/*
-========================================================================
-Routine Description:
-    SHA1 computation for one block (512 bits)
-
-Arguments:
-    pSHA_CTX        Pointer to struct rt_sha1_ctx
-
-Return Value:
-    None
-
-Note:
-    None
-========================================================================
-*/
-void SHA1_Hash(struct rt_sha1_ctx *pSHA_CTX)
-{
-       u32 W_i, t, s;
-       u32 W[16];
-       u32 a, b, c, d, e, T, f_t = 0;
-
-       /* Prepare the message schedule, {W_i}, 0 < t < 15 */
-       NdisMoveMemory(W, pSHA_CTX->Block, SHA1_BLOCK_SIZE);
-       for (W_i = 0; W_i < 16; W_i++)
-               W[W_i] = cpu2be32(W[W_i]);      /* Endian Swap */
-       /* End of for */
-
-       /* SHA256 hash computation */
-       /* Initialize the working variables */
-       a = pSHA_CTX->HashValue[0];
-       b = pSHA_CTX->HashValue[1];
-       c = pSHA_CTX->HashValue[2];
-       d = pSHA_CTX->HashValue[3];
-       e = pSHA_CTX->HashValue[4];
-
-       /* 80 rounds */
-       for (t = 0; t < 80; t++) {
-               s = t & SHA1_MASK;
-               if (t > 15) {   /* Prepare the message schedule, {W_i}, 16 < t < 79 */
-                       W[s] =
-                           (W[(s + 13) & SHA1_MASK]) ^ (W[(s + 8) & SHA1_MASK])
-                           ^ (W[(s + 2) & SHA1_MASK]) ^ W[s];
-                       W[s] = ROTL32(W[s], 1);
-               }               /* End of if */
-               switch (t / 20) {
-               case 0:
-                       f_t = Ch(b, c, d);
-                       break;
-               case 1:
-                       f_t = Parity(b, c, d);
-                       break;
-               case 2:
-                       f_t = Maj(b, c, d);
-                       break;
-               case 3:
-                       f_t = Parity(b, c, d);
-                       break;
-               }               /* End of switch */
-               T = ROTL32(a, 5) + f_t + e + SHA1_K[t / 20] + W[s];
-               e = d;
-               d = c;
-               c = ROTL32(b, 30);
-               b = a;
-               a = T;
-       }                       /* End of for */
-
-       /* Compute the i^th intermediate hash value H^(i) */
-       pSHA_CTX->HashValue[0] += a;
-       pSHA_CTX->HashValue[1] += b;
-       pSHA_CTX->HashValue[2] += c;
-       pSHA_CTX->HashValue[3] += d;
-       pSHA_CTX->HashValue[4] += e;
-
-       NdisZeroMemory(pSHA_CTX->Block, SHA1_BLOCK_SIZE);
-       pSHA_CTX->BlockLen = 0;
-}                              /* End of SHA1_Hash */
-
-/*
-========================================================================
-Routine Description:
-    The message is appended to block. If block size > 64 bytes, the SHA1_Hash
-will be called.
-
-Arguments:
-    pSHA_CTX        Pointer to struct rt_sha1_ctx
-    message         Message context
-    messageLen      The length of message in bytes
-
-Return Value:
-    None
-
-Note:
-    None
-========================================================================
-*/
-void SHA1_Append(struct rt_sha1_ctx *pSHA_CTX,
-                IN const u8 Message[], u32 MessageLen)
-{
-       u32 appendLen = 0;
-       u32 diffLen = 0;
-
-       while (appendLen != MessageLen) {
-               diffLen = MessageLen - appendLen;
-               if ((pSHA_CTX->BlockLen + diffLen) < SHA1_BLOCK_SIZE) {
-                       NdisMoveMemory(pSHA_CTX->Block + pSHA_CTX->BlockLen,
-                                      Message + appendLen, diffLen);
-                       pSHA_CTX->BlockLen += diffLen;
-                       appendLen += diffLen;
-               } else {
-                       NdisMoveMemory(pSHA_CTX->Block + pSHA_CTX->BlockLen,
-                                      Message + appendLen,
-                                      SHA1_BLOCK_SIZE - pSHA_CTX->BlockLen);
-                       appendLen += (SHA1_BLOCK_SIZE - pSHA_CTX->BlockLen);
-                       pSHA_CTX->BlockLen = SHA1_BLOCK_SIZE;
-                       SHA1_Hash(pSHA_CTX);
-               }               /* End of if */
-       }                       /* End of while */
-       pSHA_CTX->MessageLen += MessageLen;
-}                              /* End of SHA1_Append */
-
-/*
-========================================================================
-Routine Description:
-    1. Append bit 1 to end of the message
-    2. Append the length of message in rightmost 64 bits
-    3. Transform the Hash Value to digest message
-
-Arguments:
-    pSHA_CTX        Pointer to struct rt_sha1_ctx
-
-Return Value:
-    digestMessage   Digest message
-
-Note:
-    None
-========================================================================
-*/
-void SHA1_End(struct rt_sha1_ctx *pSHA_CTX, u8 DigestMessage[])
-{
-       u32 index;
-       u64 message_length_bits;
-
-       /* Append bit 1 to end of the message */
-       NdisFillMemory(pSHA_CTX->Block + pSHA_CTX->BlockLen, 1, 0x80);
-
-       /* 55 = 64 - 8 - 1: append 1 bit(1 byte) and message length (8 bytes) */
-       if (pSHA_CTX->BlockLen > 55)
-               SHA1_Hash(pSHA_CTX);
-       /* End of if */
-
-       /* Append the length of message in rightmost 64 bits */
-       message_length_bits = pSHA_CTX->MessageLen * 8;
-       message_length_bits = cpu2be64(message_length_bits);
-       NdisMoveMemory(&pSHA_CTX->Block[56], &message_length_bits, 8);
-       SHA1_Hash(pSHA_CTX);
-
-       /* Return message digest, transform the u32 hash value to bytes */
-       for (index = 0; index < 5; index++)
-               pSHA_CTX->HashValue[index] =
-                   cpu2be32(pSHA_CTX->HashValue[index]);
-       /* End of for */
-       NdisMoveMemory(DigestMessage, pSHA_CTX->HashValue, SHA1_DIGEST_SIZE);
-}                              /* End of SHA1_End */
-
-/*
-========================================================================
-Routine Description:
-    SHA1 algorithm
-
-Arguments:
-    message         Message context
-    messageLen      The length of message in bytes
-
-Return Value:
-    digestMessage   Digest message
-
-Note:
-    None
-========================================================================
-*/
-void RT_SHA1(IN const u8 Message[],
-            u32 MessageLen, u8 DigestMessage[])
-{
-
-       struct rt_sha1_ctx sha_ctx;
-
-       NdisZeroMemory(&sha_ctx, sizeof(struct rt_sha1_ctx));
-       RT_SHA1_Init(&sha_ctx);
-       SHA1_Append(&sha_ctx, Message, MessageLen);
-       SHA1_End(&sha_ctx, DigestMessage);
-}                              /* End of RT_SHA1 */
-#endif /* SHA1_SUPPORT */
-
-/* End of crypt_sha2.c */
diff --git a/drivers/staging/rt2860/common/dfs.c b/drivers/staging/rt2860/common/dfs.c
deleted file mode 100644 (file)
index 71cbb26..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-    Module Name:
-    ap_dfs.c
-
-    Abstract:
-    Support DFS function.
-
-    Revision History:
-    Who       When            What
-    --------  ----------      ----------------------------------------------
-*/
-
-#include "../rt_config.h"
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Radar channel check routine
-
-       Arguments:
-               pAd     Pointer to our adapter
-
-       Return Value:
-               TRUE    need to do radar detect
-               FALSE   need not to do radar detect
-
-       ========================================================================
-*/
-BOOLEAN RadarChannelCheck(struct rt_rtmp_adapter *pAd, u8 Ch)
-{
-       int i;
-       BOOLEAN result = FALSE;
-
-       for (i = 0; i < pAd->ChannelListNum; i++) {
-               if (Ch == pAd->ChannelList[i].Channel) {
-                       result = pAd->ChannelList[i].DfsReq;
-                       break;
-               }
-       }
-
-       return result;
-}
diff --git a/drivers/staging/rt2860/common/ee_efuse.c b/drivers/staging/rt2860/common/ee_efuse.c
deleted file mode 100644 (file)
index fed0ba4..0000000
+++ /dev/null
@@ -1,351 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-       Module Name:
-       ee_efuse.c
-
-       Abstract:
-       Miniport generic portion header file
-
-       Revision History:
-       Who         When          What
-       --------    ----------    ----------------------------------------------
-*/
-
-#include       "../rt_config.h"
-
-#define EFUSE_USAGE_MAP_START  0x2d0
-#define EFUSE_USAGE_MAP_END            0x2fc
-#define EFUSE_USAGE_MAP_SIZE   45
-
-#define EFUSE_EEPROM_DEFULT_FILE       "RT30xxEEPROM.bin"
-#define MAX_EEPROM_BIN_FILE_SIZE       1024
-
-#define EFUSE_TAG                              0x2fe
-
-typedef union _EFUSE_CTRL_STRUC {
-       struct {
-               u32 EFSROM_AOUT:6;
-               u32 EFSROM_MODE:2;
-               u32 EFSROM_LDO_OFF_TIME:6;
-               u32 EFSROM_LDO_ON_TIME:2;
-               u32 EFSROM_AIN:10;
-               u32 RESERVED:4;
-               u32 EFSROM_KICK:1;
-               u32 SEL_EFUSE:1;
-       } field;
-       u32 word;
-} EFUSE_CTRL_STRUC, *PEFUSE_CTRL_STRUC;
-
-/*
-========================================================================
-
-       Routine Description:
-
-       Arguments:
-
-       Return Value:
-
-       Note:
-
-========================================================================
-*/
-u8 eFuseReadRegisters(struct rt_rtmp_adapter *pAd,
-                        u16 Offset, u16 Length, u16 * pData)
-{
-       EFUSE_CTRL_STRUC eFuseCtrlStruc;
-       int i;
-       u16 efuseDataOffset;
-       u32 data;
-
-       RTMP_IO_READ32(pAd, EFUSE_CTRL, &eFuseCtrlStruc.word);
-
-       /*Step0. Write 10-bit of address to EFSROM_AIN (0x580, bit25:bit16). The address must be 16-byte alignment. */
-       /*Use the eeprom logical address and covert to address to block number */
-       eFuseCtrlStruc.field.EFSROM_AIN = Offset & 0xfff0;
-
-       /*Step1. Write EFSROM_MODE (0x580, bit7:bit6) to 0. */
-       eFuseCtrlStruc.field.EFSROM_MODE = 0;
-
-       /*Step2. Write EFSROM_KICK (0x580, bit30) to 1 to kick-off physical read procedure. */
-       eFuseCtrlStruc.field.EFSROM_KICK = 1;
-
-       NdisMoveMemory(&data, &eFuseCtrlStruc, 4);
-       RTMP_IO_WRITE32(pAd, EFUSE_CTRL, data);
-
-       /*Step3. Polling EFSROM_KICK(0x580, bit30) until it become 0 again. */
-       i = 0;
-       while (i < 500) {
-               /*rtmp.HwMemoryReadDword(EFUSE_CTRL, (DWORD *) &eFuseCtrlStruc, 4); */
-               RTMP_IO_READ32(pAd, EFUSE_CTRL, &eFuseCtrlStruc.word);
-               if (eFuseCtrlStruc.field.EFSROM_KICK == 0) {
-                       break;
-               }
-               RTMPusecDelay(2);
-               i++;
-       }
-
-       /*if EFSROM_AOUT is not found in physical address, write 0xffff */
-       if (eFuseCtrlStruc.field.EFSROM_AOUT == 0x3f) {
-               for (i = 0; i < Length / 2; i++)
-                       *(pData + 2 * i) = 0xffff;
-       } else {
-               /*Step4. Read 16-byte of data from EFUSE_DATA0-3 (0x590-0x59C) */
-               efuseDataOffset = EFUSE_DATA3 - (Offset & 0xC);
-               /*data hold 4 bytes data. */
-               /*In RTMP_IO_READ32 will automatically execute 32-bytes swapping */
-               RTMP_IO_READ32(pAd, efuseDataOffset, &data);
-               /*Decide the upper 2 bytes or the bottom 2 bytes. */
-               /* Little-endian                S       |       S       Big-endian */
-               /* addr 3       2       1       0       |       0       1       2       3 */
-               /* Ori-V        D       C       B       A       |       A       B       C       D */
-               /*After swapping */
-               /*              D       C       B       A       |       D       C       B       A */
-               /*Return 2-bytes */
-               /*The return byte statrs from S. Therefore, the little-endian will return BA, the Big-endian will return DC. */
-               /*For returning the bottom 2 bytes, the Big-endian should shift right 2-bytes. */
-               data = data >> (8 * (Offset & 0x3));
-
-               NdisMoveMemory(pData, &data, Length);
-       }
-
-       return (u8)eFuseCtrlStruc.field.EFSROM_AOUT;
-
-}
-
-/*
-========================================================================
-
-       Routine Description:
-
-       Arguments:
-
-       Return Value:
-
-       Note:
-
-========================================================================
-*/
-void eFusePhysicalReadRegisters(struct rt_rtmp_adapter *pAd,
-                               u16 Offset,
-                               u16 Length, u16 * pData)
-{
-       EFUSE_CTRL_STRUC eFuseCtrlStruc;
-       int i;
-       u16 efuseDataOffset;
-       u32 data;
-
-       RTMP_IO_READ32(pAd, EFUSE_CTRL, &eFuseCtrlStruc.word);
-
-       /*Step0. Write 10-bit of address to EFSROM_AIN (0x580, bit25:bit16). The address must be 16-byte alignment. */
-       eFuseCtrlStruc.field.EFSROM_AIN = Offset & 0xfff0;
-
-       /*Step1. Write EFSROM_MODE (0x580, bit7:bit6) to 1. */
-       /*Read in physical view */
-       eFuseCtrlStruc.field.EFSROM_MODE = 1;
-
-       /*Step2. Write EFSROM_KICK (0x580, bit30) to 1 to kick-off physical read procedure. */
-       eFuseCtrlStruc.field.EFSROM_KICK = 1;
-
-       NdisMoveMemory(&data, &eFuseCtrlStruc, 4);
-       RTMP_IO_WRITE32(pAd, EFUSE_CTRL, data);
-
-       /*Step3. Polling EFSROM_KICK(0x580, bit30) until it become 0 again. */
-       i = 0;
-       while (i < 500) {
-               RTMP_IO_READ32(pAd, EFUSE_CTRL, &eFuseCtrlStruc.word);
-               if (eFuseCtrlStruc.field.EFSROM_KICK == 0)
-                       break;
-               RTMPusecDelay(2);
-               i++;
-       }
-
-       /*Step4. Read 16-byte of data from EFUSE_DATA0-3 (0x59C-0x590) */
-       /*Because the size of each EFUSE_DATA is 4 Bytes, the size of address of each is 2 bits. */
-       /*The previous 2 bits is the EFUSE_DATA number, the last 2 bits is used to decide which bytes */
-       /*Decide which EFUSE_DATA to read */
-       /*590:F E D C */
-       /*594:B A 9 8 */
-       /*598:7 6 5 4 */
-       /*59C:3 2 1 0 */
-       efuseDataOffset = EFUSE_DATA3 - (Offset & 0xC);
-
-       RTMP_IO_READ32(pAd, efuseDataOffset, &data);
-
-       data = data >> (8 * (Offset & 0x3));
-
-       NdisMoveMemory(pData, &data, Length);
-
-}
-
-/*
-========================================================================
-
-       Routine Description:
-
-       Arguments:
-
-       Return Value:
-
-       Note:
-
-========================================================================
-*/
-static void eFuseReadPhysical(struct rt_rtmp_adapter *pAd,
-                             u16 *lpInBuffer,
-                             unsigned long nInBufferSize,
-                             u16 *lpOutBuffer, unsigned long nOutBufferSize)
-{
-       u16 *pInBuf = (u16 *) lpInBuffer;
-       u16 *pOutBuf = (u16 *) lpOutBuffer;
-
-       u16 Offset = pInBuf[0]; /*addr */
-       u16 Length = pInBuf[1]; /*length */
-       int i;
-
-       for (i = 0; i < Length; i += 2) {
-               eFusePhysicalReadRegisters(pAd, Offset + i, 2, &pOutBuf[i / 2]);
-       }
-}
-
-/*
-========================================================================
-
-       Routine Description:
-
-       Arguments:
-
-       Return Value:
-
-       Note:
-
-========================================================================
-*/
-int set_eFuseGetFreeBlockCount_Proc(struct rt_rtmp_adapter *pAd, char *arg)
-{
-       u16 i;
-       u16 LogicalAddress;
-       u16 efusefreenum = 0;
-       if (!pAd->bUseEfuse)
-               return FALSE;
-       for (i = EFUSE_USAGE_MAP_START; i <= EFUSE_USAGE_MAP_END; i += 2) {
-               eFusePhysicalReadRegisters(pAd, i, 2, &LogicalAddress);
-               if ((LogicalAddress & 0xff) == 0) {
-                       efusefreenum = (u8)(EFUSE_USAGE_MAP_END - i + 1);
-                       break;
-               } else if (((LogicalAddress >> 8) & 0xff) == 0) {
-                       efusefreenum = (u8)(EFUSE_USAGE_MAP_END - i);
-                       break;
-               }
-
-               if (i == EFUSE_USAGE_MAP_END)
-                       efusefreenum = 0;
-       }
-       printk(KERN_DEBUG "efuseFreeNumber is %d\n", efusefreenum);
-       return TRUE;
-}
-
-int set_eFusedump_Proc(struct rt_rtmp_adapter *pAd, char *arg)
-{
-       u16 InBuf[3];
-       int i = 0;
-       if (!pAd->bUseEfuse)
-               return FALSE;
-
-       printk(KERN_DEBUG "Block 0: ");
-
-       for (i = 0; i < EFUSE_USAGE_MAP_END / 2; i++) {
-               InBuf[0] = 2 * i;
-               InBuf[1] = 2;
-               InBuf[2] = 0x0;
-
-               eFuseReadPhysical(pAd, &InBuf[0], 4, &InBuf[2], 2);
-               if (i && i % 4 == 0) {
-                       printk(KERN_CONT "\n");
-                       printk(KERN_DEBUG "Block %x:", i / 8);
-               }
-               printk(KERN_CONT "%04x ", InBuf[2]);
-       }
-       printk(KERN_CONT "\n");
-
-       return TRUE;
-}
-
-int rtmp_ee_efuse_read16(struct rt_rtmp_adapter *pAd,
-                        u16 Offset, u16 * pValue)
-{
-       eFuseReadRegisters(pAd, Offset, 2, pValue);
-       return (*pValue);
-}
-
-int RtmpEfuseSupportCheck(struct rt_rtmp_adapter *pAd)
-{
-       u16 value;
-
-       if (IS_RT30xx(pAd)) {
-               eFusePhysicalReadRegisters(pAd, EFUSE_TAG, 2, &value);
-               pAd->EFuseTag = (value & 0xff);
-       }
-       return 0;
-}
-
-void eFuseGetFreeBlockCount(struct rt_rtmp_adapter *pAd, u32 *EfuseFreeBlock)
-{
-       u16 i;
-       u16 LogicalAddress;
-       if (!pAd->bUseEfuse) {
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("eFuseGetFreeBlockCount Only supports efuse Mode\n"));
-               return;
-       }
-       for (i = EFUSE_USAGE_MAP_START; i <= EFUSE_USAGE_MAP_END; i += 2) {
-               eFusePhysicalReadRegisters(pAd, i, 2, &LogicalAddress);
-               if ((LogicalAddress & 0xff) == 0) {
-                       *EfuseFreeBlock = (u8)(EFUSE_USAGE_MAP_END - i + 1);
-                       break;
-               } else if (((LogicalAddress >> 8) & 0xff) == 0) {
-                       *EfuseFreeBlock = (u8)(EFUSE_USAGE_MAP_END - i);
-                       break;
-               }
-
-               if (i == EFUSE_USAGE_MAP_END)
-                       *EfuseFreeBlock = 0;
-       }
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("eFuseGetFreeBlockCount is 0x%x\n", *EfuseFreeBlock));
-}
-
-int eFuse_init(struct rt_rtmp_adapter *pAd)
-{
-       u32 EfuseFreeBlock = 0;
-       DBGPRINT(RT_DEBUG_ERROR,
-                ("NVM is Efuse and its size =%x[%x-%x] \n",
-                 EFUSE_USAGE_MAP_SIZE, EFUSE_USAGE_MAP_START,
-                 EFUSE_USAGE_MAP_END));
-       eFuseGetFreeBlockCount(pAd, &EfuseFreeBlock);
-
-       return 0;
-}
diff --git a/drivers/staging/rt2860/common/ee_prom.c b/drivers/staging/rt2860/common/ee_prom.c
deleted file mode 100644 (file)
index 2083740..0000000
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-       Module Name:
-       ee_prom.c
-
-       Abstract:
-       Miniport generic portion header file
-
-       Revision History:
-       Who         When          What
-       --------    ----------    ----------------------------------------------
-*/
-
-#include       "../rt_config.h"
-
-/* IRQL = PASSIVE_LEVEL */
-static inline void RaiseClock(struct rt_rtmp_adapter *pAd, u32 * x)
-{
-       *x = *x | EESK;
-       RTMP_IO_WRITE32(pAd, E2PROM_CSR, *x);
-       RTMPusecDelay(1);       /* Max frequency = 1MHz in Spec. definition */
-}
-
-/* IRQL = PASSIVE_LEVEL */
-static inline void LowerClock(struct rt_rtmp_adapter *pAd, u32 * x)
-{
-       *x = *x & ~EESK;
-       RTMP_IO_WRITE32(pAd, E2PROM_CSR, *x);
-       RTMPusecDelay(1);
-}
-
-/* IRQL = PASSIVE_LEVEL */
-static inline u16 ShiftInBits(struct rt_rtmp_adapter *pAd)
-{
-       u32 x, i;
-       u16 data = 0;
-
-       RTMP_IO_READ32(pAd, E2PROM_CSR, &x);
-
-       x &= ~(EEDO | EEDI);
-
-       for (i = 0; i < 16; i++) {
-               data = data << 1;
-               RaiseClock(pAd, &x);
-
-               RTMP_IO_READ32(pAd, E2PROM_CSR, &x);
-               LowerClock(pAd, &x);    /*prevent read failed */
-
-               x &= ~(EEDI);
-               if (x & EEDO)
-                       data |= 1;
-       }
-
-       return data;
-}
-
-/* IRQL = PASSIVE_LEVEL */
-static inline void ShiftOutBits(struct rt_rtmp_adapter *pAd,
-                               u16 data, u16 count)
-{
-       u32 x, mask;
-
-       mask = 0x01 << (count - 1);
-       RTMP_IO_READ32(pAd, E2PROM_CSR, &x);
-
-       x &= ~(EEDO | EEDI);
-
-       do {
-               x &= ~EEDI;
-               if (data & mask)
-                       x |= EEDI;
-
-               RTMP_IO_WRITE32(pAd, E2PROM_CSR, x);
-
-               RaiseClock(pAd, &x);
-               LowerClock(pAd, &x);
-
-               mask = mask >> 1;
-       } while (mask);
-
-       x &= ~EEDI;
-       RTMP_IO_WRITE32(pAd, E2PROM_CSR, x);
-}
-
-/* IRQL = PASSIVE_LEVEL */
-static inline void EEpromCleanup(struct rt_rtmp_adapter *pAd)
-{
-       u32 x;
-
-       RTMP_IO_READ32(pAd, E2PROM_CSR, &x);
-
-       x &= ~(EECS | EEDI);
-       RTMP_IO_WRITE32(pAd, E2PROM_CSR, x);
-
-       RaiseClock(pAd, &x);
-       LowerClock(pAd, &x);
-}
-
-static inline void EWEN(struct rt_rtmp_adapter *pAd)
-{
-       u32 x;
-
-       /* reset bits and set EECS */
-       RTMP_IO_READ32(pAd, E2PROM_CSR, &x);
-       x &= ~(EEDI | EEDO | EESK);
-       x |= EECS;
-       RTMP_IO_WRITE32(pAd, E2PROM_CSR, x);
-
-       /* kick a pulse */
-       RaiseClock(pAd, &x);
-       LowerClock(pAd, &x);
-
-       /* output the read_opcode and six pulse in that order */
-       ShiftOutBits(pAd, EEPROM_EWEN_OPCODE, 5);
-       ShiftOutBits(pAd, 0, 6);
-
-       EEpromCleanup(pAd);
-}
-
-static inline void EWDS(struct rt_rtmp_adapter *pAd)
-{
-       u32 x;
-
-       /* reset bits and set EECS */
-       RTMP_IO_READ32(pAd, E2PROM_CSR, &x);
-       x &= ~(EEDI | EEDO | EESK);
-       x |= EECS;
-       RTMP_IO_WRITE32(pAd, E2PROM_CSR, x);
-
-       /* kick a pulse */
-       RaiseClock(pAd, &x);
-       LowerClock(pAd, &x);
-
-       /* output the read_opcode and six pulse in that order */
-       ShiftOutBits(pAd, EEPROM_EWDS_OPCODE, 5);
-       ShiftOutBits(pAd, 0, 6);
-
-       EEpromCleanup(pAd);
-}
-
-/* IRQL = PASSIVE_LEVEL */
-int rtmp_ee_prom_read16(struct rt_rtmp_adapter *pAd,
-                       u16 Offset, u16 * pValue)
-{
-       u32 x;
-       u16 data;
-
-       Offset /= 2;
-       /* reset bits and set EECS */
-       RTMP_IO_READ32(pAd, E2PROM_CSR, &x);
-       x &= ~(EEDI | EEDO | EESK);
-       x |= EECS;
-       RTMP_IO_WRITE32(pAd, E2PROM_CSR, x);
-
-       /* patch can not access e-Fuse issue */
-       if (!(IS_RT3090(pAd) || IS_RT3572(pAd) || IS_RT3390(pAd))) {
-               /* kick a pulse */
-               RaiseClock(pAd, &x);
-               LowerClock(pAd, &x);
-       }
-       /* output the read_opcode and register number in that order */
-       ShiftOutBits(pAd, EEPROM_READ_OPCODE, 3);
-       ShiftOutBits(pAd, Offset, pAd->EEPROMAddressNum);
-
-       /* Now read the data (16 bits) in from the selected EEPROM word */
-       data = ShiftInBits(pAd);
-
-       EEpromCleanup(pAd);
-
-       *pValue = data;
-
-       return NDIS_STATUS_SUCCESS;
-}
diff --git a/drivers/staging/rt2860/common/eeprom.c b/drivers/staging/rt2860/common/eeprom.c
deleted file mode 100644 (file)
index 9467007..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-       Module Name:
-       eeprom.c
-
-       Abstract:
-
-       Revision History:
-       Who                     When                    What
-       --------        ----------              ----------------------------------------------
-       Name            Date                    Modification logs
-*/
-#include "../rt_config.h"
-
-int RtmpChipOpsEepromHook(struct rt_rtmp_adapter *pAd, int infType)
-{
-       struct rt_rtmp_chip_op *pChipOps = &pAd->chipOps;
-#ifdef RT30xx
-#ifdef RTMP_EFUSE_SUPPORT
-       u32 eFuseCtrl, MacCsr0;
-       int index;
-
-       index = 0;
-       do {
-               RTMP_IO_READ32(pAd, MAC_CSR0, &MacCsr0);
-               pAd->MACVersion = MacCsr0;
-
-               if ((pAd->MACVersion != 0x00)
-                   && (pAd->MACVersion != 0xFFFFFFFF))
-                       break;
-
-               RTMPusecDelay(10);
-       } while (index++ < 100);
-
-       pAd->bUseEfuse = FALSE;
-       RTMP_IO_READ32(pAd, EFUSE_CTRL, &eFuseCtrl);
-       pAd->bUseEfuse = ((eFuseCtrl & 0x80000000) == 0x80000000) ? 1 : 0;
-       if (pAd->bUseEfuse) {
-               pChipOps->eeinit = eFuse_init;
-               pChipOps->eeread = rtmp_ee_efuse_read16;
-               return 0;
-       } else
-               DBGPRINT(RT_DEBUG_TRACE, ("NVM is EEPROM\n"));
-#endif /* RTMP_EFUSE_SUPPORT // */
-#endif /* RT30xx // */
-
-       switch (infType) {
-#ifdef RTMP_PCI_SUPPORT
-       case RTMP_DEV_INF_PCI:
-               pChipOps->eeinit = NULL;
-               pChipOps->eeread = rtmp_ee_prom_read16;
-               break;
-#endif /* RTMP_PCI_SUPPORT // */
-#ifdef RTMP_USB_SUPPORT
-       case RTMP_DEV_INF_USB:
-               pChipOps->eeinit = NULL;
-               pChipOps->eeread = RTUSBReadEEPROM16;
-               break;
-#endif /* RTMP_USB_SUPPORT // */
-
-       default:
-               DBGPRINT(RT_DEBUG_ERROR, ("RtmpChipOpsEepromHook() failed!\n"));
-               break;
-       }
-
-       return 0;
-}
diff --git a/drivers/staging/rt2860/common/mlme.c b/drivers/staging/rt2860/common/mlme.c
deleted file mode 100644 (file)
index e48eac0..0000000
+++ /dev/null
@@ -1,6068 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-       Module Name:
-       mlme.c
-
-       Abstract:
-
-       Revision History:
-       Who                     When                    What
-       --------        ----------              ----------------------------------------------
-       John Chang      2004-08-25              Modify from RT2500 code base
-       John Chang      2004-09-06              modified for RT2600
-*/
-
-#include "../rt_config.h"
-#include <stdarg.h>
-#include <linux/kernel.h>
-
-u8 CISCO_OUI[] = { 0x00, 0x40, 0x96 };
-
-u8 WPA_OUI[] = { 0x00, 0x50, 0xf2, 0x01 };
-u8 RSN_OUI[] = { 0x00, 0x0f, 0xac };
-u8 WME_INFO_ELEM[] = { 0x00, 0x50, 0xf2, 0x02, 0x00, 0x01 };
-u8 WME_PARM_ELEM[] = { 0x00, 0x50, 0xf2, 0x02, 0x01, 0x01 };
-u8 Ccx2QosInfo[] = { 0x00, 0x40, 0x96, 0x04 };
-u8 RALINK_OUI[] = { 0x00, 0x0c, 0x43 };
-u8 BROADCOM_OUI[] = { 0x00, 0x90, 0x4c };
-u8 WPS_OUI[] = { 0x00, 0x50, 0xf2, 0x04 };
-u8 PRE_N_HT_OUI[] = { 0x00, 0x90, 0x4c };
-
-u8 RateSwitchTable[] = {
-/* Item No.   Mode   Curr-MCS   TrainUp   TrainDown             // Mode- Bit0: STBC, Bit1: Short GI, Bit4,5: Mode(0:CCK, 1:OFDM, 2:HT Mix, 3:HT GF) */
-       0x11, 0x00, 0, 0, 0,    /* Initial used item after association */
-       0x00, 0x00, 0, 40, 101,
-       0x01, 0x00, 1, 40, 50,
-       0x02, 0x00, 2, 35, 45,
-       0x03, 0x00, 3, 20, 45,
-       0x04, 0x21, 0, 30, 50,
-       0x05, 0x21, 1, 20, 50,
-       0x06, 0x21, 2, 20, 50,
-       0x07, 0x21, 3, 15, 50,
-       0x08, 0x21, 4, 15, 30,
-       0x09, 0x21, 5, 10, 25,
-       0x0a, 0x21, 6, 8, 25,
-       0x0b, 0x21, 7, 8, 25,
-       0x0c, 0x20, 12, 15, 30,
-       0x0d, 0x20, 13, 8, 20,
-       0x0e, 0x20, 14, 8, 20,
-       0x0f, 0x20, 15, 8, 25,
-       0x10, 0x22, 15, 8, 25,
-       0x11, 0x00, 0, 0, 0,
-       0x12, 0x00, 0, 0, 0,
-       0x13, 0x00, 0, 0, 0,
-       0x14, 0x00, 0, 0, 0,
-       0x15, 0x00, 0, 0, 0,
-       0x16, 0x00, 0, 0, 0,
-       0x17, 0x00, 0, 0, 0,
-       0x18, 0x00, 0, 0, 0,
-       0x19, 0x00, 0, 0, 0,
-       0x1a, 0x00, 0, 0, 0,
-       0x1b, 0x00, 0, 0, 0,
-       0x1c, 0x00, 0, 0, 0,
-       0x1d, 0x00, 0, 0, 0,
-       0x1e, 0x00, 0, 0, 0,
-       0x1f, 0x00, 0, 0, 0,
-};
-
-u8 RateSwitchTable11B[] = {
-/* Item No.   Mode   Curr-MCS   TrainUp   TrainDown             // Mode- Bit0: STBC, Bit1: Short GI, Bit4,5: Mode(0:CCK, 1:OFDM, 2:HT Mix, 3:HT GF) */
-       0x04, 0x03, 0, 0, 0,    /* Initial used item after association */
-       0x00, 0x00, 0, 40, 101,
-       0x01, 0x00, 1, 40, 50,
-       0x02, 0x00, 2, 35, 45,
-       0x03, 0x00, 3, 20, 45,
-};
-
-u8 RateSwitchTable11BG[] = {
-/* Item No.   Mode   Curr-MCS   TrainUp   TrainDown             // Mode- Bit0: STBC, Bit1: Short GI, Bit4,5: Mode(0:CCK, 1:OFDM, 2:HT Mix, 3:HT GF) */
-       0x0a, 0x00, 0, 0, 0,    /* Initial used item after association */
-       0x00, 0x00, 0, 40, 101,
-       0x01, 0x00, 1, 40, 50,
-       0x02, 0x00, 2, 35, 45,
-       0x03, 0x00, 3, 20, 45,
-       0x04, 0x10, 2, 20, 35,
-       0x05, 0x10, 3, 16, 35,
-       0x06, 0x10, 4, 10, 25,
-       0x07, 0x10, 5, 16, 25,
-       0x08, 0x10, 6, 10, 25,
-       0x09, 0x10, 7, 10, 13,
-};
-
-u8 RateSwitchTable11G[] = {
-/* Item No.   Mode   Curr-MCS   TrainUp   TrainDown             // Mode- Bit0: STBC, Bit1: Short GI, Bit4,5: Mode(0:CCK, 1:OFDM, 2:HT Mix, 3:HT GF) */
-       0x08, 0x00, 0, 0, 0,    /* Initial used item after association */
-       0x00, 0x10, 0, 20, 101,
-       0x01, 0x10, 1, 20, 35,
-       0x02, 0x10, 2, 20, 35,
-       0x03, 0x10, 3, 16, 35,
-       0x04, 0x10, 4, 10, 25,
-       0x05, 0x10, 5, 16, 25,
-       0x06, 0x10, 6, 10, 25,
-       0x07, 0x10, 7, 10, 13,
-};
-
-u8 RateSwitchTable11N1S[] = {
-/* Item No.   Mode   Curr-MCS   TrainUp   TrainDown             // Mode- Bit0: STBC, Bit1: Short GI, Bit4,5: Mode(0:CCK, 1:OFDM, 2:HT Mix, 3:HT GF) */
-       0x0c, 0x0a, 0, 0, 0,    /* Initial used item after association */
-       0x00, 0x00, 0, 40, 101,
-       0x01, 0x00, 1, 40, 50,
-       0x02, 0x00, 2, 25, 45,
-       0x03, 0x21, 0, 20, 35,
-       0x04, 0x21, 1, 20, 35,
-       0x05, 0x21, 2, 20, 35,
-       0x06, 0x21, 3, 15, 35,
-       0x07, 0x21, 4, 15, 30,
-       0x08, 0x21, 5, 10, 25,
-       0x09, 0x21, 6, 8, 14,
-       0x0a, 0x21, 7, 8, 14,
-       0x0b, 0x23, 7, 8, 14,
-};
-
-u8 RateSwitchTable11N2S[] = {
-/* Item No.   Mode   Curr-MCS   TrainUp   TrainDown             // Mode- Bit0: STBC, Bit1: Short GI, Bit4,5: Mode(0:CCK, 1:OFDM, 2:HT Mix, 3:HT GF) */
-       0x0e, 0x0c, 0, 0, 0,    /* Initial used item after association */
-       0x00, 0x00, 0, 40, 101,
-       0x01, 0x00, 1, 40, 50,
-       0x02, 0x00, 2, 25, 45,
-       0x03, 0x21, 0, 20, 35,
-       0x04, 0x21, 1, 20, 35,
-       0x05, 0x21, 2, 20, 35,
-       0x06, 0x21, 3, 15, 35,
-       0x07, 0x21, 4, 15, 30,
-       0x08, 0x20, 11, 15, 30,
-       0x09, 0x20, 12, 15, 30,
-       0x0a, 0x20, 13, 8, 20,
-       0x0b, 0x20, 14, 8, 20,
-       0x0c, 0x20, 15, 8, 25,
-       0x0d, 0x22, 15, 8, 15,
-};
-
-u8 RateSwitchTable11N3S[] = {
-/* Item No.     Mode    Curr-MCS        TrainUp TrainDown       // Mode- Bit0: STBC, Bit1: Short GI, Bit4,5: Mode(0:CCK, 1:OFDM, 2:HT Mix, 3:HT GF) */
-       0x0b, 0x00, 0, 0, 0,    /* 0x0a, 0x00,  0,  0,  0,      // Initial used item after association */
-       0x00, 0x21, 0, 30, 101,
-       0x01, 0x21, 1, 20, 50,
-       0x02, 0x21, 2, 20, 50,
-       0x03, 0x21, 3, 15, 50,
-       0x04, 0x21, 4, 15, 30,
-       0x05, 0x20, 11, 15, 30, /* Required by System-Alan @ 20080812 */
-       0x06, 0x20, 12, 15, 30, /* 0x05, 0x20, 12, 15, 30, */
-       0x07, 0x20, 13, 8, 20,  /* 0x06, 0x20, 13,  8, 20, */
-       0x08, 0x20, 14, 8, 20,  /* 0x07, 0x20, 14,  8, 20, */
-       0x09, 0x20, 15, 8, 25,  /* 0x08, 0x20, 15,  8, 25, */
-       0x0a, 0x22, 15, 8, 25,  /* 0x09, 0x22, 15,  8, 25, */
-};
-
-u8 RateSwitchTable11N2SForABand[] = {
-/* Item No.   Mode   Curr-MCS   TrainUp   TrainDown             // Mode- Bit0: STBC, Bit1: Short GI, Bit4,5: Mode(0:CCK, 1:OFDM, 2:HT Mix, 3:HT GF) */
-       0x0b, 0x09, 0, 0, 0,    /* Initial used item after association */
-       0x00, 0x21, 0, 30, 101,
-       0x01, 0x21, 1, 20, 50,
-       0x02, 0x21, 2, 20, 50,
-       0x03, 0x21, 3, 15, 50,
-       0x04, 0x21, 4, 15, 30,
-       0x05, 0x21, 5, 15, 30,
-       0x06, 0x20, 12, 15, 30,
-       0x07, 0x20, 13, 8, 20,
-       0x08, 0x20, 14, 8, 20,
-       0x09, 0x20, 15, 8, 25,
-       0x0a, 0x22, 15, 8, 25,
-};
-
-u8 RateSwitchTable11N3SForABand[] = {  /* 3*3 */
-/* Item No.   Mode   Curr-MCS   TrainUp   TrainDown             // Mode- Bit0: STBC, Bit1: Short GI, Bit4,5: Mode(0:CCK, 1:OFDM, 2:HT Mix, 3:HT GF) */
-       0x0b, 0x09, 0, 0, 0,    /* Initial used item after association */
-       0x00, 0x21, 0, 30, 101,
-       0x01, 0x21, 1, 20, 50,
-       0x02, 0x21, 2, 20, 50,
-       0x03, 0x21, 3, 15, 50,
-       0x04, 0x21, 4, 15, 30,
-       0x05, 0x21, 5, 15, 30,
-       0x06, 0x20, 12, 15, 30,
-       0x07, 0x20, 13, 8, 20,
-       0x08, 0x20, 14, 8, 20,
-       0x09, 0x20, 15, 8, 25,
-       0x0a, 0x22, 15, 8, 25,
-};
-
-u8 RateSwitchTable11BGN1S[] = {
-/* Item No.   Mode   Curr-MCS   TrainUp   TrainDown             // Mode- Bit0: STBC, Bit1: Short GI, Bit4,5: Mode(0:CCK, 1:OFDM, 2:HT Mix, 3:HT GF) */
-       0x0c, 0x0a, 0, 0, 0,    /* Initial used item after association */
-       0x00, 0x00, 0, 40, 101,
-       0x01, 0x00, 1, 40, 50,
-       0x02, 0x00, 2, 25, 45,
-       0x03, 0x21, 0, 20, 35,
-       0x04, 0x21, 1, 20, 35,
-       0x05, 0x21, 2, 20, 35,
-       0x06, 0x21, 3, 15, 35,
-       0x07, 0x21, 4, 15, 30,
-       0x08, 0x21, 5, 10, 25,
-       0x09, 0x21, 6, 8, 14,
-       0x0a, 0x21, 7, 8, 14,
-       0x0b, 0x23, 7, 8, 14,
-};
-
-u8 RateSwitchTable11BGN2S[] = {
-/* Item No.   Mode   Curr-MCS   TrainUp   TrainDown             // Mode- Bit0: STBC, Bit1: Short GI, Bit4,5: Mode(0:CCK, 1:OFDM, 2:HT Mix, 3:HT GF) */
-       0x0e, 0x0c, 0, 0, 0,    /* Initial used item after association */
-       0x00, 0x00, 0, 40, 101,
-       0x01, 0x00, 1, 40, 50,
-       0x02, 0x00, 2, 25, 45,
-       0x03, 0x21, 0, 20, 35,
-       0x04, 0x21, 1, 20, 35,
-       0x05, 0x21, 2, 20, 35,
-       0x06, 0x21, 3, 15, 35,
-       0x07, 0x21, 4, 15, 30,
-       0x08, 0x20, 11, 15, 30,
-       0x09, 0x20, 12, 15, 30,
-       0x0a, 0x20, 13, 8, 20,
-       0x0b, 0x20, 14, 8, 20,
-       0x0c, 0x20, 15, 8, 25,
-       0x0d, 0x22, 15, 8, 15,
-};
-
-u8 RateSwitchTable11BGN3S[] = {        /* 3*3 */
-/* Item No.   Mode   Curr-MCS   TrainUp   TrainDown             // Mode- Bit0: STBC, Bit1: Short GI, Bit4,5: Mode(0:CCK, 1:OFDM, 2:HT Mix, 3:HT GF) */
-       0x0a, 0x00, 0, 0, 0,    /* Initial used item after association */
-       0x00, 0x21, 0, 30, 101, /*50 */
-       0x01, 0x21, 1, 20, 50,
-       0x02, 0x21, 2, 20, 50,
-       0x03, 0x21, 3, 20, 50,
-       0x04, 0x21, 4, 15, 50,
-       0x05, 0x20, 20, 15, 30,
-       0x06, 0x20, 21, 8, 20,
-       0x07, 0x20, 22, 8, 20,
-       0x08, 0x20, 23, 8, 25,
-       0x09, 0x22, 23, 8, 25,
-};
-
-u8 RateSwitchTable11BGN2SForABand[] = {
-/* Item No.   Mode   Curr-MCS   TrainUp   TrainDown             // Mode- Bit0: STBC, Bit1: Short GI, Bit4,5: Mode(0:CCK, 1:OFDM, 2:HT Mix, 3:HT GF) */
-       0x0b, 0x09, 0, 0, 0,    /* Initial used item after association */
-       0x00, 0x21, 0, 30, 101, /*50 */
-       0x01, 0x21, 1, 20, 50,
-       0x02, 0x21, 2, 20, 50,
-       0x03, 0x21, 3, 15, 50,
-       0x04, 0x21, 4, 15, 30,
-       0x05, 0x21, 5, 15, 30,
-       0x06, 0x20, 12, 15, 30,
-       0x07, 0x20, 13, 8, 20,
-       0x08, 0x20, 14, 8, 20,
-       0x09, 0x20, 15, 8, 25,
-       0x0a, 0x22, 15, 8, 25,
-};
-
-u8 RateSwitchTable11BGN3SForABand[] = {        /* 3*3 */
-/* Item No.   Mode   Curr-MCS   TrainUp   TrainDown             // Mode- Bit0: STBC, Bit1: Short GI, Bit4,5: Mode(0:CCK, 1:OFDM, 2:HT Mix, 3:HT GF) */
-       0x0c, 0x09, 0, 0, 0,    /* Initial used item after association */
-       0x00, 0x21, 0, 30, 101, /*50 */
-       0x01, 0x21, 1, 20, 50,
-       0x02, 0x21, 2, 20, 50,
-       0x03, 0x21, 3, 15, 50,
-       0x04, 0x21, 4, 15, 30,
-       0x05, 0x21, 5, 15, 30,
-       0x06, 0x21, 12, 15, 30,
-       0x07, 0x20, 20, 15, 30,
-       0x08, 0x20, 21, 8, 20,
-       0x09, 0x20, 22, 8, 20,
-       0x0a, 0x20, 23, 8, 25,
-       0x0b, 0x22, 23, 8, 25,
-};
-
-extern u8 OfdmRateToRxwiMCS[];
-/* since RT61 has better RX sensibility, we have to limit TX ACK rate not to exceed our normal data TX rate. */
-/* otherwise the WLAN peer may not be able to receive the ACK thus downgrade its data TX rate */
-unsigned long BasicRateMask[12] =
-    { 0xfffff001 /* 1-Mbps */ , 0xfffff003 /* 2 Mbps */ , 0xfffff007 /* 5.5 */ ,
-0xfffff00f /* 11 */ ,
-       0xfffff01f /* 6 */ , 0xfffff03f /* 9 */ , 0xfffff07f /* 12 */ ,
-           0xfffff0ff /* 18 */ ,
-       0xfffff1ff /* 24 */ , 0xfffff3ff /* 36 */ , 0xfffff7ff /* 48 */ ,
-           0xffffffff /* 54 */
-};
-
-u8 BROADCAST_ADDR[MAC_ADDR_LEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
-u8 ZERO_MAC_ADDR[MAC_ADDR_LEN] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
-/* e.g. RssiSafeLevelForTxRate[RATE_36]" means if the current RSSI is greater than */
-/*              this value, then it's quaranteed capable of operating in 36 mbps TX rate in */
-/*              clean environment. */
-/*                                                                TxRate: 1   2   5.5   11       6        9    12       18       24   36   48   54       72  100 */
-char RssiSafeLevelForTxRate[] =
-    { -92, -91, -90, -87, -88, -86, -85, -83, -81, -78, -72, -71, -40, -40 };
-
-u8 RateIdToMbps[] = { 1, 2, 5, 11, 6, 9, 12, 18, 24, 36, 48, 54, 72, 100 };
-u16 RateIdTo500Kbps[] =
-    { 2, 4, 11, 22, 12, 18, 24, 36, 48, 72, 96, 108, 144, 200 };
-
-u8 SsidIe = IE_SSID;
-u8 SupRateIe = IE_SUPP_RATES;
-u8 ExtRateIe = IE_EXT_SUPP_RATES;
-u8 HtCapIe = IE_HT_CAP;
-u8 AddHtInfoIe = IE_ADD_HT;
-u8 NewExtChanIe = IE_SECONDARY_CH_OFFSET;
-u8 ErpIe = IE_ERP;
-u8 DsIe = IE_DS_PARM;
-u8 TimIe = IE_TIM;
-u8 WpaIe = IE_WPA;
-u8 Wpa2Ie = IE_WPA2;
-u8 IbssIe = IE_IBSS_PARM;
-
-extern u8 WPA_OUI[];
-
-u8 SES_OUI[] = { 0x00, 0x90, 0x4c };
-
-u8 ZeroSsid[32] =
-    { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00,
-       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-           0x00, 0x00, 0x00, 0x00
-};
-
-/*
-       ==========================================================================
-       Description:
-               initialize the MLME task and its data structure (queue, spinlock,
-               timer, state machines).
-
-       IRQL = PASSIVE_LEVEL
-
-       Return:
-               always return NDIS_STATUS_SUCCESS
-
-       ==========================================================================
-*/
-int MlmeInit(struct rt_rtmp_adapter *pAd)
-{
-       int Status = NDIS_STATUS_SUCCESS;
-
-       DBGPRINT(RT_DEBUG_TRACE, ("--> MLME Initialize\n"));
-
-       do {
-               Status = MlmeQueueInit(&pAd->Mlme.Queue);
-               if (Status != NDIS_STATUS_SUCCESS)
-                       break;
-
-               pAd->Mlme.bRunning = FALSE;
-               NdisAllocateSpinLock(&pAd->Mlme.TaskLock);
-
-               {
-                       BssTableInit(&pAd->ScanTab);
-
-                       /* init STA state machines */
-                       AssocStateMachineInit(pAd, &pAd->Mlme.AssocMachine,
-                                             pAd->Mlme.AssocFunc);
-                       AuthStateMachineInit(pAd, &pAd->Mlme.AuthMachine,
-                                            pAd->Mlme.AuthFunc);
-                       AuthRspStateMachineInit(pAd, &pAd->Mlme.AuthRspMachine,
-                                               pAd->Mlme.AuthRspFunc);
-                       SyncStateMachineInit(pAd, &pAd->Mlme.SyncMachine,
-                                            pAd->Mlme.SyncFunc);
-
-                       /* Since we are using switch/case to implement it, the init is different from the above */
-                       /* state machine init */
-                       MlmeCntlInit(pAd, &pAd->Mlme.CntlMachine, NULL);
-               }
-
-               WpaStateMachineInit(pAd, &pAd->Mlme.WpaMachine,
-                                   pAd->Mlme.WpaFunc);
-
-               ActionStateMachineInit(pAd, &pAd->Mlme.ActMachine,
-                                      pAd->Mlme.ActFunc);
-
-               /* Init mlme periodic timer */
-               RTMPInitTimer(pAd, &pAd->Mlme.PeriodicTimer,
-                             GET_TIMER_FUNCTION(MlmePeriodicExec), pAd, TRUE);
-
-               /* Set mlme periodic timer */
-               RTMPSetTimer(&pAd->Mlme.PeriodicTimer, MLME_TASK_EXEC_INTV);
-
-               /* software-based RX Antenna diversity */
-               RTMPInitTimer(pAd, &pAd->Mlme.RxAntEvalTimer,
-                             GET_TIMER_FUNCTION(AsicRxAntEvalTimeout), pAd,
-                             FALSE);
-
-               {
-#ifdef RTMP_PCI_SUPPORT
-                       if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_PCIE_DEVICE)) {
-                               /* only PCIe cards need these two timers */
-                               RTMPInitTimer(pAd, &pAd->Mlme.PsPollTimer,
-                                             GET_TIMER_FUNCTION
-                                             (PsPollWakeExec), pAd, FALSE);
-                               RTMPInitTimer(pAd, &pAd->Mlme.RadioOnOffTimer,
-                                             GET_TIMER_FUNCTION(RadioOnExec),
-                                             pAd, FALSE);
-                       }
-#endif /* RTMP_PCI_SUPPORT // */
-
-                       RTMPInitTimer(pAd, &pAd->Mlme.LinkDownTimer,
-                                     GET_TIMER_FUNCTION(LinkDownExec), pAd,
-                                     FALSE);
-
-#ifdef RTMP_MAC_USB
-                       RTMPInitTimer(pAd, &pAd->Mlme.AutoWakeupTimer,
-                                     GET_TIMER_FUNCTION
-                                     (RtmpUsbStaAsicForceWakeupTimeout), pAd,
-                                     FALSE);
-                       pAd->Mlme.AutoWakeupTimerRunning = FALSE;
-#endif /* RTMP_MAC_USB // */
-               }
-
-       } while (FALSE);
-
-       DBGPRINT(RT_DEBUG_TRACE, ("<-- MLME Initialize\n"));
-
-       return Status;
-}
-
-/*
-       ==========================================================================
-       Description:
-               main loop of the MLME
-       Pre:
-               Mlme has to be initialized, and there are something inside the queue
-       Note:
-               This function is invoked from MPSetInformation and MPReceive;
-               This task guarantee only one MlmeHandler will run.
-
-       IRQL = DISPATCH_LEVEL
-
-       ==========================================================================
- */
-void MlmeHandler(struct rt_rtmp_adapter *pAd)
-{
-       struct rt_mlme_queue_elem *Elem = NULL;
-
-       /* Only accept MLME and Frame from peer side, no other (control/data) frame should */
-       /* get into this state machine */
-
-       NdisAcquireSpinLock(&pAd->Mlme.TaskLock);
-       if (pAd->Mlme.bRunning) {
-               NdisReleaseSpinLock(&pAd->Mlme.TaskLock);
-               return;
-       } else {
-               pAd->Mlme.bRunning = TRUE;
-       }
-       NdisReleaseSpinLock(&pAd->Mlme.TaskLock);
-
-       while (!MlmeQueueEmpty(&pAd->Mlme.Queue)) {
-               if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_MLME_RESET_IN_PROGRESS) ||
-                   RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS) ||
-                   RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)) {
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("Device Halted or Removed or MlmeRest, exit MlmeHandler! (queue num = %ld)\n",
-                                 pAd->Mlme.Queue.Num));
-                       break;
-               }
-               /*From message type, determine which state machine I should drive */
-               if (MlmeDequeue(&pAd->Mlme.Queue, &Elem)) {
-#ifdef RTMP_MAC_USB
-                       if (Elem->MsgType == MT2_RESET_CONF) {
-                               DBGPRINT_RAW(RT_DEBUG_TRACE,
-                                            ("reset MLME state machine!\n"));
-                               MlmeRestartStateMachine(pAd);
-                               Elem->Occupied = FALSE;
-                               Elem->MsgLen = 0;
-                               continue;
-                       }
-#endif /* RTMP_MAC_USB // */
-
-                       /* if dequeue success */
-                       switch (Elem->Machine) {
-                               /* STA state machines */
-                       case ASSOC_STATE_MACHINE:
-                               StateMachinePerformAction(pAd,
-                                                         &pAd->Mlme.
-                                                         AssocMachine, Elem);
-                               break;
-                       case AUTH_STATE_MACHINE:
-                               StateMachinePerformAction(pAd,
-                                                         &pAd->Mlme.
-                                                         AuthMachine, Elem);
-                               break;
-                       case AUTH_RSP_STATE_MACHINE:
-                               StateMachinePerformAction(pAd,
-                                                         &pAd->Mlme.
-                                                         AuthRspMachine, Elem);
-                               break;
-                       case SYNC_STATE_MACHINE:
-                               StateMachinePerformAction(pAd,
-                                                         &pAd->Mlme.
-                                                         SyncMachine, Elem);
-                               break;
-                       case MLME_CNTL_STATE_MACHINE:
-                               MlmeCntlMachinePerformAction(pAd,
-                                                            &pAd->Mlme.
-                                                            CntlMachine, Elem);
-                               break;
-                       case WPA_PSK_STATE_MACHINE:
-                               StateMachinePerformAction(pAd,
-                                                         &pAd->Mlme.
-                                                         WpaPskMachine, Elem);
-                               break;
-
-                       case ACTION_STATE_MACHINE:
-                               StateMachinePerformAction(pAd,
-                                                         &pAd->Mlme.ActMachine,
-                                                         Elem);
-                               break;
-
-                       case WPA_STATE_MACHINE:
-                               StateMachinePerformAction(pAd,
-                                                         &pAd->Mlme.WpaMachine,
-                                                         Elem);
-                               break;
-
-                       default:
-                               DBGPRINT(RT_DEBUG_TRACE,
-                                        ("ERROR: Illegal machine %ld in MlmeHandler()\n",
-                                         Elem->Machine));
-                               break;
-                       }       /* end of switch */
-
-                       /* free MLME element */
-                       Elem->Occupied = FALSE;
-                       Elem->MsgLen = 0;
-
-               } else {
-                       DBGPRINT_ERR("MlmeHandler: MlmeQueue empty\n");
-               }
-       }
-
-       NdisAcquireSpinLock(&pAd->Mlme.TaskLock);
-       pAd->Mlme.bRunning = FALSE;
-       NdisReleaseSpinLock(&pAd->Mlme.TaskLock);
-}
-
-/*
-       ==========================================================================
-       Description:
-               Destructor of MLME (Destroy queue, state machine, spin lock and timer)
-       Parameters:
-               Adapter - NIC Adapter pointer
-       Post:
-               The MLME task will no longer work properly
-
-       IRQL = PASSIVE_LEVEL
-
-       ==========================================================================
- */
-void MlmeHalt(struct rt_rtmp_adapter *pAd)
-{
-       BOOLEAN Cancelled;
-
-       DBGPRINT(RT_DEBUG_TRACE, ("==> MlmeHalt\n"));
-
-       if (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)) {
-               /* disable BEACON generation and other BEACON related hardware timers */
-               AsicDisableSync(pAd);
-       }
-
-       {
-               /* Cancel pending timers */
-               RTMPCancelTimer(&pAd->MlmeAux.AssocTimer, &Cancelled);
-               RTMPCancelTimer(&pAd->MlmeAux.ReassocTimer, &Cancelled);
-               RTMPCancelTimer(&pAd->MlmeAux.DisassocTimer, &Cancelled);
-               RTMPCancelTimer(&pAd->MlmeAux.AuthTimer, &Cancelled);
-               RTMPCancelTimer(&pAd->MlmeAux.BeaconTimer, &Cancelled);
-               RTMPCancelTimer(&pAd->MlmeAux.ScanTimer, &Cancelled);
-
-#ifdef RTMP_MAC_PCI
-               if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_PCIE_DEVICE)
-                   && (pAd->StaCfg.PSControl.field.EnableNewPS == TRUE)) {
-                       RTMPCancelTimer(&pAd->Mlme.PsPollTimer, &Cancelled);
-                       RTMPCancelTimer(&pAd->Mlme.RadioOnOffTimer, &Cancelled);
-               }
-#endif /* RTMP_MAC_PCI // */
-
-               RTMPCancelTimer(&pAd->Mlme.LinkDownTimer, &Cancelled);
-
-#ifdef RTMP_MAC_USB
-               RTMPCancelTimer(&pAd->Mlme.AutoWakeupTimer, &Cancelled);
-#endif /* RTMP_MAC_USB // */
-       }
-
-       RTMPCancelTimer(&pAd->Mlme.PeriodicTimer, &Cancelled);
-       RTMPCancelTimer(&pAd->Mlme.RxAntEvalTimer, &Cancelled);
-
-       if (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)) {
-               struct rt_rtmp_chip_op *pChipOps = &pAd->chipOps;
-
-               /* Set LED */
-               RTMPSetLED(pAd, LED_HALT);
-               RTMPSetSignalLED(pAd, -100);    /* Force signal strength Led to be turned off, firmware is not done it. */
-#ifdef RTMP_MAC_USB
-               {
-                       LED_CFG_STRUC LedCfg;
-                       RTMP_IO_READ32(pAd, LED_CFG, &LedCfg.word);
-                       LedCfg.field.LedPolar = 0;
-                       LedCfg.field.RLedMode = 0;
-                       LedCfg.field.GLedMode = 0;
-                       LedCfg.field.YLedMode = 0;
-                       RTMP_IO_WRITE32(pAd, LED_CFG, LedCfg.word);
-               }
-#endif /* RTMP_MAC_USB // */
-
-               if (pChipOps->AsicHaltAction)
-                       pChipOps->AsicHaltAction(pAd);
-       }
-
-       RTMPusecDelay(5000);    /*  5 msec to guarantee Ant Diversity timer canceled */
-
-       MlmeQueueDestroy(&pAd->Mlme.Queue);
-       NdisFreeSpinLock(&pAd->Mlme.TaskLock);
-
-       DBGPRINT(RT_DEBUG_TRACE, ("<== MlmeHalt\n"));
-}
-
-void MlmeResetRalinkCounters(struct rt_rtmp_adapter *pAd)
-{
-       pAd->RalinkCounters.LastOneSecRxOkDataCnt =
-           pAd->RalinkCounters.OneSecRxOkDataCnt;
-       /* clear all OneSecxxx counters. */
-       pAd->RalinkCounters.OneSecBeaconSentCnt = 0;
-       pAd->RalinkCounters.OneSecFalseCCACnt = 0;
-       pAd->RalinkCounters.OneSecRxFcsErrCnt = 0;
-       pAd->RalinkCounters.OneSecRxOkCnt = 0;
-       pAd->RalinkCounters.OneSecTxFailCount = 0;
-       pAd->RalinkCounters.OneSecTxNoRetryOkCount = 0;
-       pAd->RalinkCounters.OneSecTxRetryOkCount = 0;
-       pAd->RalinkCounters.OneSecRxOkDataCnt = 0;
-       pAd->RalinkCounters.OneSecReceivedByteCount = 0;
-       pAd->RalinkCounters.OneSecTransmittedByteCount = 0;
-
-       /* TODO: for debug only. to be removed */
-       pAd->RalinkCounters.OneSecOsTxCount[QID_AC_BE] = 0;
-       pAd->RalinkCounters.OneSecOsTxCount[QID_AC_BK] = 0;
-       pAd->RalinkCounters.OneSecOsTxCount[QID_AC_VI] = 0;
-       pAd->RalinkCounters.OneSecOsTxCount[QID_AC_VO] = 0;
-       pAd->RalinkCounters.OneSecDmaDoneCount[QID_AC_BE] = 0;
-       pAd->RalinkCounters.OneSecDmaDoneCount[QID_AC_BK] = 0;
-       pAd->RalinkCounters.OneSecDmaDoneCount[QID_AC_VI] = 0;
-       pAd->RalinkCounters.OneSecDmaDoneCount[QID_AC_VO] = 0;
-       pAd->RalinkCounters.OneSecTxDoneCount = 0;
-       pAd->RalinkCounters.OneSecRxCount = 0;
-       pAd->RalinkCounters.OneSecTxAggregationCount = 0;
-       pAd->RalinkCounters.OneSecRxAggregationCount = 0;
-
-       return;
-}
-
-/*
-       ==========================================================================
-       Description:
-               This routine is executed periodically to -
-               1. Decide if it's a right time to turn on PwrMgmt bit of all
-                  outgoiing frames
-               2. Calculate ChannelQuality based on statistics of the last
-                  period, so that TX rate won't toggling very frequently between a
-                  successful TX and a failed TX.
-               3. If the calculated ChannelQuality indicated current connection not
-                  healthy, then a ROAMing attempt is tried here.
-
-       IRQL = DISPATCH_LEVEL
-
-       ==========================================================================
- */
-#define ADHOC_BEACON_LOST_TIME         (8*OS_HZ)       /* 8 sec */
-void MlmePeriodicExec(void *SystemSpecific1,
-                     void *FunctionContext,
-                     void *SystemSpecific2, void *SystemSpecific3)
-{
-       unsigned long TxTotalCnt;
-       struct rt_rtmp_adapter *pAd = (struct rt_rtmp_adapter *)FunctionContext;
-
-#ifdef RTMP_MAC_PCI
-       {
-               /* If Hardware controlled Radio enabled, we have to check GPIO pin2 every 2 second. */
-               /* Move code to here, because following code will return when radio is off */
-               if ((pAd->Mlme.PeriodicRound % (MLME_TASK_EXEC_MULTIPLE * 2) ==
-                    0) && (pAd->StaCfg.bHardwareRadio == TRUE)
-                   && (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST))
-                   && (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS))
-                   /*&&(pAd->bPCIclkOff == FALSE) */
-                   ) {
-                       u32 data = 0;
-
-                       /* Read GPIO pin2 as Hardware controlled radio state */
-#ifndef RT3090
-                       RTMP_IO_READ32(pAd, GPIO_CTRL_CFG, &data);
-#endif /* RT3090 // */
-/*KH(PCIE PS):Added based on Jane<-- */
-#ifdef RT3090
-/* Read GPIO pin2 as Hardware controlled radio state */
-/* We need to Read GPIO if HW said so no mater what advance power saving */
-                       if ((pAd->OpMode == OPMODE_STA) && (IDLE_ON(pAd))
-                           &&
-                           (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_IDLE_RADIO_OFF))
-                           && (pAd->StaCfg.PSControl.field.EnablePSinIdle ==
-                               TRUE)) {
-                               /* Want to make sure device goes to L0 state before reading register. */
-                               RTMPPCIeLinkCtrlValueRestore(pAd, 0);
-                               RTMP_IO_FORCE_READ32(pAd, GPIO_CTRL_CFG, &data);
-                               RTMPPCIeLinkCtrlSetting(pAd, 3);
-                       } else
-                               RTMP_IO_FORCE_READ32(pAd, GPIO_CTRL_CFG, &data);
-#endif /* RT3090 // */
-/*KH(PCIE PS):Added based on Jane--> */
-
-                       if (data & 0x04) {
-                               pAd->StaCfg.bHwRadio = TRUE;
-                       } else {
-                               pAd->StaCfg.bHwRadio = FALSE;
-                       }
-                       if (pAd->StaCfg.bRadio !=
-                           (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio)) {
-                               pAd->StaCfg.bRadio = (pAd->StaCfg.bHwRadio
-                                                     && pAd->StaCfg.bSwRadio);
-                               if (pAd->StaCfg.bRadio == TRUE) {
-                                       MlmeRadioOn(pAd);
-                                       /* Update extra information */
-                                       pAd->ExtraInfo = EXTRA_INFO_CLEAR;
-                               } else {
-                                       MlmeRadioOff(pAd);
-                                       /* Update extra information */
-                                       pAd->ExtraInfo = HW_RADIO_OFF;
-                               }
-                       }
-               }
-       }
-#endif /* RTMP_MAC_PCI // */
-
-       /* Do nothing if the driver is starting halt state. */
-       /* This might happen when timer already been fired before cancel timer with mlmehalt */
-       if ((RTMP_TEST_FLAG(pAd, (fRTMP_ADAPTER_HALT_IN_PROGRESS |
-                                 fRTMP_ADAPTER_RADIO_OFF |
-                                 fRTMP_ADAPTER_RADIO_MEASUREMENT |
-                                 fRTMP_ADAPTER_RESET_IN_PROGRESS))))
-               return;
-
-       RTMP_MLME_PRE_SANITY_CHECK(pAd);
-
-       {
-               /* Do nothing if monitor mode is on */
-               if (MONITOR_ON(pAd))
-                       return;
-
-               if (pAd->Mlme.PeriodicRound & 0x1) {
-                       /* This is the fix for wifi 11n extension channel overlapping test case.  for 2860D */
-                       if (((pAd->MACVersion & 0xffff) == 0x0101) &&
-                           (STA_TGN_WIFI_ON(pAd)) &&
-                           (pAd->CommonCfg.IOTestParm.bToggle == FALSE))
-                       {
-                               RTMP_IO_WRITE32(pAd, TXOP_CTRL_CFG, 0x24Bf);
-                               pAd->CommonCfg.IOTestParm.bToggle = TRUE;
-                       } else if ((STA_TGN_WIFI_ON(pAd)) &&
-                                  ((pAd->MACVersion & 0xffff) == 0x0101)) {
-                               RTMP_IO_WRITE32(pAd, TXOP_CTRL_CFG, 0x243f);
-                               pAd->CommonCfg.IOTestParm.bToggle = FALSE;
-                       }
-               }
-       }
-
-       pAd->bUpdateBcnCntDone = FALSE;
-
-/*      RECBATimerTimeout(SystemSpecific1,FunctionContext,SystemSpecific2,SystemSpecific3); */
-       pAd->Mlme.PeriodicRound++;
-
-#ifdef RTMP_MAC_USB
-       /* execute every 100ms, update the Tx FIFO Cnt for update Tx Rate. */
-       NICUpdateFifoStaCounters(pAd);
-#endif /* RTMP_MAC_USB // */
-
-       /* execute every 500ms */
-       if ((pAd->Mlme.PeriodicRound % 5 == 0)
-           && RTMPAutoRateSwitchCheck(pAd)
-           /*(OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_TX_RATE_SWITCH_ENABLED)) */ )
-       {
-               /* perform dynamic tx rate switching based on past TX history */
-               {
-                       if ((OPSTATUS_TEST_FLAG
-                            (pAd, fOP_STATUS_MEDIA_STATE_CONNECTED)
-                           )
-                           && (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE)))
-                               MlmeDynamicTxRateSwitching(pAd);
-               }
-       }
-       /* Normal 1 second Mlme PeriodicExec. */
-       if (pAd->Mlme.PeriodicRound % MLME_TASK_EXEC_MULTIPLE == 0) {
-               pAd->Mlme.OneSecPeriodicRound++;
-
-               /*ORIBATimerTimeout(pAd); */
-
-               /* Media status changed, report to NDIS */
-               if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_MEDIA_STATE_CHANGE)) {
-                       RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_MEDIA_STATE_CHANGE);
-                       if (OPSTATUS_TEST_FLAG
-                           (pAd, fOP_STATUS_MEDIA_STATE_CONNECTED)) {
-                               pAd->IndicateMediaState =
-                                   NdisMediaStateConnected;
-                               RTMP_IndicateMediaState(pAd);
-
-                       } else {
-                               pAd->IndicateMediaState =
-                                   NdisMediaStateDisconnected;
-                               RTMP_IndicateMediaState(pAd);
-                       }
-               }
-
-               NdisGetSystemUpTime(&pAd->Mlme.Now32);
-
-               /* add the most up-to-date h/w raw counters into software variable, so that */
-               /* the dynamic tuning mechanism below are based on most up-to-date information */
-               NICUpdateRawCounters(pAd);
-
-#ifdef RTMP_MAC_USB
-               RTUSBWatchDog(pAd);
-#endif /* RTMP_MAC_USB // */
-
-               /* Need statistics after read counter. So put after NICUpdateRawCounters */
-               ORIBATimerTimeout(pAd);
-
-               /* if MGMT RING is full more than twice within 1 second, we consider there's */
-               /* a hardware problem stucking the TX path. In this case, try a hardware reset */
-               /* to recover the system */
-               /*      if (pAd->RalinkCounters.MgmtRingFullCount >= 2) */
-               /*              RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_HARDWARE_ERROR); */
-               /*      else */
-               /*              pAd->RalinkCounters.MgmtRingFullCount = 0; */
-
-               /* The time period for checking antenna is according to traffic */
-               {
-                       if (pAd->Mlme.bEnableAutoAntennaCheck) {
-                               TxTotalCnt =
-                                   pAd->RalinkCounters.OneSecTxNoRetryOkCount +
-                                   pAd->RalinkCounters.OneSecTxRetryOkCount +
-                                   pAd->RalinkCounters.OneSecTxFailCount;
-
-                               /* dynamic adjust antenna evaluation period according to the traffic */
-                               if (TxTotalCnt > 50) {
-                                       if (pAd->Mlme.OneSecPeriodicRound %
-                                           10 == 0) {
-                                               AsicEvaluateRxAnt(pAd);
-                                       }
-                               } else {
-                                       if (pAd->Mlme.OneSecPeriodicRound % 3 ==
-                                           0) {
-                                               AsicEvaluateRxAnt(pAd);
-                                       }
-                               }
-                       }
-               }
-
-               STAMlmePeriodicExec(pAd);
-
-               MlmeResetRalinkCounters(pAd);
-
-               {
-#ifdef RTMP_MAC_PCI
-                       if (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)
-                           && (pAd->bPCIclkOff == FALSE))
-#endif /* RTMP_MAC_PCI // */
-                       {
-                               /* When Adhoc beacon is enabled and RTS/CTS is enabled, there is a chance that hardware MAC FSM will run into a deadlock */
-                               /* and sending CTS-to-self over and over. */
-                               /* Software Patch Solution: */
-                               /* 1. Polling debug state register 0x10F4 every one second. */
-                               /* 2. If in 0x10F4 the ((bit29==1) && (bit7==1)) OR ((bit29==1) && (bit5==1)), it means the deadlock has occurred. */
-                               /* 3. If the deadlock occurred, reset MAC/BBP by setting 0x1004 to 0x0001 for a while then setting it back to 0x000C again. */
-
-                               u32 MacReg = 0;
-
-                               RTMP_IO_READ32(pAd, 0x10F4, &MacReg);
-                               if (((MacReg & 0x20000000) && (MacReg & 0x80))
-                                   || ((MacReg & 0x20000000)
-                                       && (MacReg & 0x20))) {
-                                       RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, 0x1);
-                                       RTMPusecDelay(1);
-                                       RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, 0xC);
-
-                                       DBGPRINT(RT_DEBUG_WARN,
-                                                ("Warning, MAC specific condition occurs \n"));
-                               }
-                       }
-               }
-
-               RTMP_MLME_HANDLER(pAd);
-       }
-
-       pAd->bUpdateBcnCntDone = FALSE;
-}
-
-/*
-       ==========================================================================
-       Validate SSID for connection try and rescan purpose
-       Valid SSID will have visible chars only.
-       The valid length is from 0 to 32.
-       IRQL = DISPATCH_LEVEL
-       ==========================================================================
- */
-BOOLEAN MlmeValidateSSID(u8 *pSsid, u8 SsidLen)
-{
-       int index;
-
-       if (SsidLen > MAX_LEN_OF_SSID)
-               return (FALSE);
-
-       /* Check each character value */
-       for (index = 0; index < SsidLen; index++) {
-               if (pSsid[index] < 0x20)
-                       return (FALSE);
-       }
-
-       /* All checked */
-       return (TRUE);
-}
-
-void MlmeSelectTxRateTable(struct rt_rtmp_adapter *pAd,
-                          struct rt_mac_table_entry *pEntry,
-                          u8 ** ppTable,
-                          u8 *pTableSize, u8 *pInitTxRateIdx)
-{
-       do {
-               /* decide the rate table for tuning */
-               if (pAd->CommonCfg.TxRateTableSize > 0) {
-                       *ppTable = RateSwitchTable;
-                       *pTableSize = RateSwitchTable[0];
-                       *pInitTxRateIdx = RateSwitchTable[1];
-
-                       break;
-               }
-
-               if ((pAd->OpMode == OPMODE_STA) && ADHOC_ON(pAd)) {
-                       if ((pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED) && (pEntry->HTCapability.MCSSet[0] == 0xff) && ((pEntry->HTCapability.MCSSet[1] == 0x00) || (pAd->Antenna.field.TxPath == 1))) {       /* 11N 1S Adhoc */
-                               *ppTable = RateSwitchTable11N1S;
-                               *pTableSize = RateSwitchTable11N1S[0];
-                               *pInitTxRateIdx = RateSwitchTable11N1S[1];
-
-                       } else if ((pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED) && (pEntry->HTCapability.MCSSet[0] == 0xff) && (pEntry->HTCapability.MCSSet[1] == 0xff) && (pAd->Antenna.field.TxPath == 2)) {  /* 11N 2S Adhoc */
-                               if (pAd->LatchRfRegs.Channel <= 14) {
-                                       *ppTable = RateSwitchTable11N2S;
-                                       *pTableSize = RateSwitchTable11N2S[0];
-                                       *pInitTxRateIdx =
-                                           RateSwitchTable11N2S[1];
-                               } else {
-                                       *ppTable = RateSwitchTable11N2SForABand;
-                                       *pTableSize =
-                                           RateSwitchTable11N2SForABand[0];
-                                       *pInitTxRateIdx =
-                                           RateSwitchTable11N2SForABand[1];
-                               }
-
-                       } else if ((pEntry->RateLen == 4)
-                                  && (pEntry->HTCapability.MCSSet[0] == 0)
-                                  && (pEntry->HTCapability.MCSSet[1] == 0)
-                           ) {
-                               *ppTable = RateSwitchTable11B;
-                               *pTableSize = RateSwitchTable11B[0];
-                               *pInitTxRateIdx = RateSwitchTable11B[1];
-
-                       } else if (pAd->LatchRfRegs.Channel <= 14) {
-                               *ppTable = RateSwitchTable11BG;
-                               *pTableSize = RateSwitchTable11BG[0];
-                               *pInitTxRateIdx = RateSwitchTable11BG[1];
-
-                       } else {
-                               *ppTable = RateSwitchTable11G;
-                               *pTableSize = RateSwitchTable11G[0];
-                               *pInitTxRateIdx = RateSwitchTable11G[1];
-
-                       }
-                       break;
-               }
-               /*if ((pAd->StaActive.SupRateLen + pAd->StaActive.ExtRateLen == 12) && (pAd->StaActive.SupportedPhyInfo.MCSSet[0] == 0xff) && */
-               /*      ((pAd->StaActive.SupportedPhyInfo.MCSSet[1] == 0x00) || (pAd->Antenna.field.TxPath == 1))) */
-               if (((pEntry->RateLen == 12) || (pAd->OpMode == OPMODE_STA)) && (pEntry->HTCapability.MCSSet[0] == 0xff) && ((pEntry->HTCapability.MCSSet[1] == 0x00) || (pAd->CommonCfg.TxStream == 1))) {     /* 11BGN 1S AP */
-                       *ppTable = RateSwitchTable11BGN1S;
-                       *pTableSize = RateSwitchTable11BGN1S[0];
-                       *pInitTxRateIdx = RateSwitchTable11BGN1S[1];
-
-                       break;
-               }
-               /*else if ((pAd->StaActive.SupRateLen + pAd->StaActive.ExtRateLen == 12) && (pAd->StaActive.SupportedPhyInfo.MCSSet[0] == 0xff) && */
-               /*      (pAd->StaActive.SupportedPhyInfo.MCSSet[1] == 0xff) && (pAd->Antenna.field.TxPath == 2)) */
-               if (((pEntry->RateLen == 12) || (pAd->OpMode == OPMODE_STA)) && (pEntry->HTCapability.MCSSet[0] == 0xff) && (pEntry->HTCapability.MCSSet[1] == 0xff) && (pAd->CommonCfg.TxStream == 2)) {       /* 11BGN 2S AP */
-                       if (pAd->LatchRfRegs.Channel <= 14) {
-                               *ppTable = RateSwitchTable11BGN2S;
-                               *pTableSize = RateSwitchTable11BGN2S[0];
-                               *pInitTxRateIdx = RateSwitchTable11BGN2S[1];
-
-                       } else {
-                               *ppTable = RateSwitchTable11BGN2SForABand;
-                               *pTableSize = RateSwitchTable11BGN2SForABand[0];
-                               *pInitTxRateIdx =
-                                   RateSwitchTable11BGN2SForABand[1];
-
-                       }
-                       break;
-               }
-               /*else if ((pAd->StaActive.SupportedPhyInfo.MCSSet[0] == 0xff) && ((pAd->StaActive.SupportedPhyInfo.MCSSet[1] == 0x00) || (pAd->Antenna.field.TxPath == 1))) */
-               if ((pEntry->HTCapability.MCSSet[0] == 0xff) && ((pEntry->HTCapability.MCSSet[1] == 0x00) || (pAd->CommonCfg.TxStream == 1))) { /* 11N 1S AP */
-                       *ppTable = RateSwitchTable11N1S;
-                       *pTableSize = RateSwitchTable11N1S[0];
-                       *pInitTxRateIdx = RateSwitchTable11N1S[1];
-
-                       break;
-               }
-               /*else if ((pAd->StaActive.SupportedPhyInfo.MCSSet[0] == 0xff) && (pAd->StaActive.SupportedPhyInfo.MCSSet[1] == 0xff) && (pAd->Antenna.field.TxPath == 2)) */
-               if ((pEntry->HTCapability.MCSSet[0] == 0xff) && (pEntry->HTCapability.MCSSet[1] == 0xff) && (pAd->CommonCfg.TxStream == 2)) {   /* 11N 2S AP */
-                       if (pAd->LatchRfRegs.Channel <= 14) {
-                               *ppTable = RateSwitchTable11N2S;
-                               *pTableSize = RateSwitchTable11N2S[0];
-                               *pInitTxRateIdx = RateSwitchTable11N2S[1];
-                       } else {
-                               *ppTable = RateSwitchTable11N2SForABand;
-                               *pTableSize = RateSwitchTable11N2SForABand[0];
-                               *pInitTxRateIdx =
-                                   RateSwitchTable11N2SForABand[1];
-                       }
-
-                       break;
-               }
-               /*else if ((pAd->StaActive.SupRateLen == 4) && (pAd->StaActive.ExtRateLen == 0) && (pAd->StaActive.SupportedPhyInfo.MCSSet[0] == 0) && (pAd->StaActive.SupportedPhyInfo.MCSSet[1] == 0)) */
-               if ((pEntry->RateLen == 4 || pAd->CommonCfg.PhyMode == PHY_11B)
-                   /*Iverson mark for Adhoc b mode,sta will use rate 54  Mbps when connect with sta b/g/n mode */
-                   /* && (pEntry->HTCapability.MCSSet[0] == 0) && (pEntry->HTCapability.MCSSet[1] == 0) */
-                   ) {         /* B only AP */
-                       *ppTable = RateSwitchTable11B;
-                       *pTableSize = RateSwitchTable11B[0];
-                       *pInitTxRateIdx = RateSwitchTable11B[1];
-
-                       break;
-               }
-               /*else if ((pAd->StaActive.SupRateLen + pAd->StaActive.ExtRateLen > 8) && (pAd->StaActive.SupportedPhyInfo.MCSSet[0] == 0) && (pAd->StaActive.SupportedPhyInfo.MCSSet[1] == 0)) */
-               if ((pEntry->RateLen > 8)
-                   && (pEntry->HTCapability.MCSSet[0] == 0)
-                   && (pEntry->HTCapability.MCSSet[1] == 0)
-                   ) {         /* B/G  mixed AP */
-                       *ppTable = RateSwitchTable11BG;
-                       *pTableSize = RateSwitchTable11BG[0];
-                       *pInitTxRateIdx = RateSwitchTable11BG[1];
-
-                       break;
-               }
-               /*else if ((pAd->StaActive.SupRateLen + pAd->StaActive.ExtRateLen == 8) && (pAd->StaActive.SupportedPhyInfo.MCSSet[0] == 0) && (pAd->StaActive.SupportedPhyInfo.MCSSet[1] == 0)) */
-               if ((pEntry->RateLen == 8)
-                   && (pEntry->HTCapability.MCSSet[0] == 0)
-                   && (pEntry->HTCapability.MCSSet[1] == 0)
-                   ) {         /* G only AP */
-                       *ppTable = RateSwitchTable11G;
-                       *pTableSize = RateSwitchTable11G[0];
-                       *pInitTxRateIdx = RateSwitchTable11G[1];
-
-                       break;
-               }
-
-               {
-                       /*else if ((pAd->StaActive.SupportedPhyInfo.MCSSet[0] == 0) && (pAd->StaActive.SupportedPhyInfo.MCSSet[1] == 0)) */
-                       if ((pEntry->HTCapability.MCSSet[0] == 0) && (pEntry->HTCapability.MCSSet[1] == 0)) {   /* Legacy mode */
-                               if (pAd->CommonCfg.MaxTxRate <= RATE_11) {
-                                       *ppTable = RateSwitchTable11B;
-                                       *pTableSize = RateSwitchTable11B[0];
-                                       *pInitTxRateIdx = RateSwitchTable11B[1];
-                               } else if ((pAd->CommonCfg.MaxTxRate > RATE_11)
-                                          && (pAd->CommonCfg.MinTxRate >
-                                              RATE_11)) {
-                                       *ppTable = RateSwitchTable11G;
-                                       *pTableSize = RateSwitchTable11G[0];
-                                       *pInitTxRateIdx = RateSwitchTable11G[1];
-
-                               } else {
-                                       *ppTable = RateSwitchTable11BG;
-                                       *pTableSize = RateSwitchTable11BG[0];
-                                       *pInitTxRateIdx =
-                                           RateSwitchTable11BG[1];
-                               }
-                               break;
-                       }
-                       if (pAd->LatchRfRegs.Channel <= 14) {
-                               if (pAd->CommonCfg.TxStream == 1) {
-                                       *ppTable = RateSwitchTable11N1S;
-                                       *pTableSize = RateSwitchTable11N1S[0];
-                                       *pInitTxRateIdx =
-                                           RateSwitchTable11N1S[1];
-                                       DBGPRINT_RAW(RT_DEBUG_ERROR,
-                                                    ("DRS: unknown mode,default use 11N 1S AP \n"));
-                               } else {
-                                       *ppTable = RateSwitchTable11N2S;
-                                       *pTableSize = RateSwitchTable11N2S[0];
-                                       *pInitTxRateIdx =
-                                           RateSwitchTable11N2S[1];
-                                       DBGPRINT_RAW(RT_DEBUG_ERROR,
-                                                    ("DRS: unknown mode,default use 11N 2S AP \n"));
-                               }
-                       } else {
-                               if (pAd->CommonCfg.TxStream == 1) {
-                                       *ppTable = RateSwitchTable11N1S;
-                                       *pTableSize = RateSwitchTable11N1S[0];
-                                       *pInitTxRateIdx =
-                                           RateSwitchTable11N1S[1];
-                                       DBGPRINT_RAW(RT_DEBUG_ERROR,
-                                                    ("DRS: unknown mode,default use 11N 1S AP \n"));
-                               } else {
-                                       *ppTable = RateSwitchTable11N2SForABand;
-                                       *pTableSize =
-                                           RateSwitchTable11N2SForABand[0];
-                                       *pInitTxRateIdx =
-                                           RateSwitchTable11N2SForABand[1];
-                                       DBGPRINT_RAW(RT_DEBUG_ERROR,
-                                                    ("DRS: unknown mode,default use 11N 2S AP \n"));
-                               }
-                       }
-                       DBGPRINT_RAW(RT_DEBUG_ERROR,
-                                    ("DRS: unknown mode (SupRateLen=%d, ExtRateLen=%d, MCSSet[0]=0x%x, MCSSet[1]=0x%x)\n",
-                                     pAd->StaActive.SupRateLen,
-                                     pAd->StaActive.ExtRateLen,
-                                     pAd->StaActive.SupportedPhyInfo.MCSSet[0],
-                                     pAd->StaActive.SupportedPhyInfo.
-                                     MCSSet[1]));
-               }
-       } while (FALSE);
-}
-
-void STAMlmePeriodicExec(struct rt_rtmp_adapter *pAd)
-{
-       unsigned long TxTotalCnt;
-       int i;
-
-       /*
-          We return here in ATE mode, because the statistics
-          that ATE need are not collected via this routine.
-        */
-#if defined(RT305x)||defined(RT3070)
-       /* request by Gary, if Rssi0 > -42, BBP 82 need to be changed from 0x62 to 0x42, , bbp 67 need to be changed from 0x20 to 0x18 */
-       if (!pAd->CommonCfg.HighPowerPatchDisabled) {
-#ifdef RT3070
-               if ((IS_RT3070(pAd) && ((pAd->MACVersion & 0xffff) < 0x0201)))
-#endif /* RT3070 // */
-               {
-                       if ((pAd->StaCfg.RssiSample.AvgRssi0 != 0)
-                           && (pAd->StaCfg.RssiSample.AvgRssi0 >
-                               (pAd->BbpRssiToDbmDelta - 35))) {
-                               RT30xxWriteRFRegister(pAd, RF_R27, 0x20);
-                       } else {
-                               RT30xxWriteRFRegister(pAd, RF_R27, 0x23);
-                       }
-               }
-       }
-#endif
-#ifdef PCIE_PS_SUPPORT
-/* don't perform idle-power-save mechanism within 3 min after driver initialization. */
-/* This can make rebooter test more robust */
-       if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_PCIE_DEVICE)) {
-               if ((pAd->OpMode == OPMODE_STA) && (IDLE_ON(pAd))
-                   && (pAd->Mlme.SyncMachine.CurrState == SYNC_IDLE)
-                   && (pAd->Mlme.CntlMachine.CurrState == CNTL_IDLE)
-                   && (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_IDLE_RADIO_OFF))) {
-                       if (IS_RT3090(pAd) || IS_RT3572(pAd) || IS_RT3390(pAd)) {
-                               if (pAd->StaCfg.PSControl.field.EnableNewPS ==
-                                   TRUE) {
-                                       DBGPRINT(RT_DEBUG_TRACE,
-                                                ("%s\n", __func__));
-                                       RT28xxPciAsicRadioOff(pAd,
-                                                             GUI_IDLE_POWER_SAVE,
-                                                             0);
-                               } else {
-                                       AsicSendCommandToMcu(pAd, 0x30,
-                                                            PowerSafeCID, 0xff,
-                                                            0x2);
-                                       /* Wait command success */
-                                       AsicCheckCommanOk(pAd, PowerSafeCID);
-                                       RTMP_SET_FLAG(pAd,
-                                                     fRTMP_ADAPTER_IDLE_RADIO_OFF);
-                                       DBGPRINT(RT_DEBUG_TRACE,
-                                                ("PSM - rt30xx Issue Sleep command)\n"));
-                               }
-                       } else if (pAd->Mlme.OneSecPeriodicRound > 180) {
-                               if (pAd->StaCfg.PSControl.field.EnableNewPS ==
-                                   TRUE) {
-                                       DBGPRINT(RT_DEBUG_TRACE,
-                                                ("%s\n", __func__));
-                                       RT28xxPciAsicRadioOff(pAd,
-                                                             GUI_IDLE_POWER_SAVE,
-                                                             0);
-                               } else {
-                                       AsicSendCommandToMcu(pAd, 0x30,
-                                                            PowerSafeCID, 0xff,
-                                                            0x02);
-                                       /* Wait command success */
-                                       AsicCheckCommanOk(pAd, PowerSafeCID);
-                                       RTMP_SET_FLAG(pAd,
-                                                     fRTMP_ADAPTER_IDLE_RADIO_OFF);
-                                       DBGPRINT(RT_DEBUG_TRACE,
-                                                ("PSM -  rt28xx Issue Sleep command)\n"));
-                               }
-                       }
-               } else {
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("STAMlmePeriodicExec MMCHK - CommonCfg.Ssid[%d]=%c%c%c%c... MlmeAux.Ssid[%d]=%c%c%c%c...\n",
-                                 pAd->CommonCfg.SsidLen,
-                                 pAd->CommonCfg.Ssid[0],
-                                 pAd->CommonCfg.Ssid[1],
-                                 pAd->CommonCfg.Ssid[2],
-                                 pAd->CommonCfg.Ssid[3], pAd->MlmeAux.SsidLen,
-                                 pAd->MlmeAux.Ssid[0], pAd->MlmeAux.Ssid[1],
-                                 pAd->MlmeAux.Ssid[2], pAd->MlmeAux.Ssid[3]));
-               }
-       }
-#endif /* PCIE_PS_SUPPORT // */
-
-       if (pAd->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_DISABLE) {
-               /* WPA MIC error should block association attempt for 60 seconds */
-               if (pAd->StaCfg.bBlockAssoc &&
-                   RTMP_TIME_AFTER(pAd->Mlme.Now32,
-                                   pAd->StaCfg.LastMicErrorTime +
-                                   (60 * OS_HZ)))
-                       pAd->StaCfg.bBlockAssoc = FALSE;
-       }
-
-       if ((pAd->PreMediaState != pAd->IndicateMediaState)
-           && (pAd->CommonCfg.bWirelessEvent)) {
-               if (pAd->IndicateMediaState == NdisMediaStateConnected) {
-                       RTMPSendWirelessEvent(pAd, IW_STA_LINKUP_EVENT_FLAG,
-                                             pAd->MacTab.Content[BSSID_WCID].
-                                             Addr, BSS0, 0);
-               }
-               pAd->PreMediaState = pAd->IndicateMediaState;
-       }
-
-       if (pAd->CommonCfg.PSPXlink && ADHOC_ON(pAd)) {
-       } else {
-               AsicStaBbpTuning(pAd);
-       }
-
-       TxTotalCnt = pAd->RalinkCounters.OneSecTxNoRetryOkCount +
-           pAd->RalinkCounters.OneSecTxRetryOkCount +
-           pAd->RalinkCounters.OneSecTxFailCount;
-
-       if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED)) {
-               /* update channel quality for Roaming and UI LinkQuality display */
-               MlmeCalculateChannelQuality(pAd, NULL, pAd->Mlme.Now32);
-       }
-       /* must be AFTER MlmeDynamicTxRateSwitching() because it needs to know if */
-       /* Radio is currently in noisy environment */
-       if (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
-               AsicAdjustTxPower(pAd);
-
-       if (INFRA_ON(pAd)) {
-
-               /* Is PSM bit consistent with user power management policy? */
-               /* This is the only place that will set PSM bit ON. */
-               if (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))
-                       MlmeCheckPsmChange(pAd, pAd->Mlme.Now32);
-
-               pAd->RalinkCounters.LastOneSecTotalTxCount = TxTotalCnt;
-
-               if ((RTMP_TIME_AFTER
-                    (pAd->Mlme.Now32,
-                     pAd->StaCfg.LastBeaconRxTime + (1 * OS_HZ)))
-                   &&
-                   (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
-                   &&
-                   (((TxTotalCnt + pAd->RalinkCounters.OneSecRxOkCnt) <
-                     600))) {
-                       RTMPSetAGCInitValue(pAd, BW_20);
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("MMCHK - No BEACON. restore R66 to the low bound(%d) \n",
-                                 (0x2E + GET_LNA_GAIN(pAd))));
-               }
-               /*if ((pAd->RalinkCounters.OneSecTxNoRetryOkCount == 0) && */
-               /*    (pAd->RalinkCounters.OneSecTxRetryOkCount == 0)) */
-               {
-                       if (pAd->CommonCfg.bAPSDCapable
-                           && pAd->CommonCfg.APEdcaParm.bAPSDCapable) {
-                               /* When APSD is enabled, the period changes as 20 sec */
-                               if ((pAd->Mlme.OneSecPeriodicRound % 20) == 8)
-                                       RTMPSendNullFrame(pAd,
-                                                         pAd->CommonCfg.TxRate,
-                                                         TRUE);
-                       } else {
-                               /* Send out a NULL frame every 10 sec to inform AP that STA is still alive (Avoid being age out) */
-                               if ((pAd->Mlme.OneSecPeriodicRound % 10) == 8) {
-                                       if (pAd->CommonCfg.bWmmCapable)
-                                               RTMPSendNullFrame(pAd,
-                                                                 pAd->
-                                                                 CommonCfg.
-                                                                 TxRate, TRUE);
-                                       else
-                                               RTMPSendNullFrame(pAd,
-                                                                 pAd->
-                                                                 CommonCfg.
-                                                                 TxRate,
-                                                                 FALSE);
-                               }
-                       }
-               }
-
-               if (CQI_IS_DEAD(pAd->Mlme.ChannelQuality)) {
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("MMCHK - No BEACON. Dead CQI. Auto Recovery attempt #%ld\n",
-                                 pAd->RalinkCounters.BadCQIAutoRecoveryCount));
-
-                       /* Lost AP, send disconnect & link down event */
-                       LinkDown(pAd, FALSE);
-
-                       RtmpOSWrielessEventSend(pAd, SIOCGIWAP, -1, NULL, NULL,
-                                               0);
-
-                       /* RTMPPatchMacBbpBug(pAd); */
-                       MlmeAutoReconnectLastSSID(pAd);
-               } else if (CQI_IS_BAD(pAd->Mlme.ChannelQuality)) {
-                       pAd->RalinkCounters.BadCQIAutoRecoveryCount++;
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("MMCHK - Bad CQI. Auto Recovery attempt #%ld\n",
-                                 pAd->RalinkCounters.BadCQIAutoRecoveryCount));
-                       MlmeAutoReconnectLastSSID(pAd);
-               }
-
-               if (pAd->StaCfg.bAutoRoaming) {
-                       BOOLEAN rv = FALSE;
-                       char dBmToRoam = pAd->StaCfg.dBmToRoam;
-                       char MaxRssi = RTMPMaxRssi(pAd,
-                                                  pAd->StaCfg.RssiSample.
-                                                  LastRssi0,
-                                                  pAd->StaCfg.RssiSample.
-                                                  LastRssi1,
-                                                  pAd->StaCfg.RssiSample.
-                                                  LastRssi2);
-
-                       /* Scanning, ignore Roaming */
-                       if (!RTMP_TEST_FLAG
-                           (pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS)
-                           && (pAd->Mlme.SyncMachine.CurrState == SYNC_IDLE)
-                           && (MaxRssi <= dBmToRoam)) {
-                               DBGPRINT(RT_DEBUG_TRACE,
-                                        ("Rssi=%d, dBmToRoam=%d\n", MaxRssi,
-                                         (char)dBmToRoam));
-
-                               /* Add auto seamless roaming */
-                               if (rv == FALSE)
-                                       rv = MlmeCheckForFastRoaming(pAd);
-
-                               if (rv == FALSE) {
-                                       if ((pAd->StaCfg.LastScanTime +
-                                            10 * OS_HZ) < pAd->Mlme.Now32) {
-                                               DBGPRINT(RT_DEBUG_TRACE,
-                                                        ("MMCHK - Roaming, No eligible entry, try new scan!\n"));
-                                               pAd->StaCfg.ScanCnt = 2;
-                                               pAd->StaCfg.LastScanTime =
-                                                   pAd->Mlme.Now32;
-                                               MlmeAutoScan(pAd);
-                                       }
-                               }
-                       }
-               }
-       } else if (ADHOC_ON(pAd)) {
-               /* If all peers leave, and this STA becomes the last one in this IBSS, then change MediaState */
-               /* to DISCONNECTED. But still holding this IBSS (i.e. sending BEACON) so that other STAs can */
-               /* join later. */
-               if (RTMP_TIME_AFTER
-                   (pAd->Mlme.Now32,
-                    pAd->StaCfg.LastBeaconRxTime + ADHOC_BEACON_LOST_TIME)
-                   && OPSTATUS_TEST_FLAG(pAd,
-                                         fOP_STATUS_MEDIA_STATE_CONNECTED)) {
-                       struct rt_mlme_start_req StartReq;
-
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("MMCHK - excessive BEACON lost, last STA in this IBSS, MediaState=Disconnected\n"));
-                       LinkDown(pAd, FALSE);
-
-                       StartParmFill(pAd, &StartReq,
-                                     (char *) pAd->MlmeAux.Ssid,
-                                     pAd->MlmeAux.SsidLen);
-                       MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_MLME_START_REQ,
-                                   sizeof(struct rt_mlme_start_req), &StartReq);
-                       pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_START;
-               }
-
-               for (i = 1; i < MAX_LEN_OF_MAC_TABLE; i++) {
-                       struct rt_mac_table_entry *pEntry = &pAd->MacTab.Content[i];
-
-                       if (pEntry->ValidAsCLI == FALSE)
-                               continue;
-
-                       if (RTMP_TIME_AFTER
-                           (pAd->Mlme.Now32,
-                            pEntry->LastBeaconRxTime + ADHOC_BEACON_LOST_TIME))
-                               MacTableDeleteEntry(pAd, pEntry->Aid,
-                                                   pEntry->Addr);
-               }
-       } else                  /* no INFRA nor ADHOC connection */
-       {
-
-               if (pAd->StaCfg.bScanReqIsFromWebUI &&
-                   RTMP_TIME_BEFORE(pAd->Mlme.Now32,
-                                    pAd->StaCfg.LastScanTime + (30 * OS_HZ)))
-                       goto SKIP_AUTO_SCAN_CONN;
-               else
-                       pAd->StaCfg.bScanReqIsFromWebUI = FALSE;
-
-               if ((pAd->StaCfg.bAutoReconnect == TRUE)
-                   && RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_START_UP)
-                   &&
-                   (MlmeValidateSSID
-                    (pAd->MlmeAux.AutoReconnectSsid,
-                     pAd->MlmeAux.AutoReconnectSsidLen) == TRUE)) {
-                       if ((pAd->ScanTab.BssNr == 0)
-                           && (pAd->Mlme.CntlMachine.CurrState == CNTL_IDLE)) {
-                               struct rt_mlme_scan_req ScanReq;
-
-                               if (RTMP_TIME_AFTER
-                                   (pAd->Mlme.Now32,
-                                    pAd->StaCfg.LastScanTime + (10 * OS_HZ))) {
-                                       DBGPRINT(RT_DEBUG_TRACE,
-                                                ("STAMlmePeriodicExec():CNTL - ScanTab.BssNr==0, start a new ACTIVE scan SSID[%s]\n",
-                                                 pAd->MlmeAux.
-                                                 AutoReconnectSsid));
-                                       ScanParmFill(pAd, &ScanReq,
-                                                    (char *)pAd->MlmeAux.
-                                                    AutoReconnectSsid,
-                                                    pAd->MlmeAux.
-                                                    AutoReconnectSsidLen,
-                                                    BSS_ANY, SCAN_ACTIVE);
-                                       MlmeEnqueue(pAd, SYNC_STATE_MACHINE,
-                                                   MT2_MLME_SCAN_REQ,
-                                                   sizeof
-                                                   (struct rt_mlme_scan_req),
-                                                   &ScanReq);
-                                       pAd->Mlme.CntlMachine.CurrState =
-                                           CNTL_WAIT_OID_LIST_SCAN;
-                                       /* Reset Missed scan number */
-                                       pAd->StaCfg.LastScanTime =
-                                           pAd->Mlme.Now32;
-                               } else if (pAd->StaCfg.BssType == BSS_ADHOC)    /* Quit the forever scan when in a very clean room */
-                                       MlmeAutoReconnectLastSSID(pAd);
-                       } else if (pAd->Mlme.CntlMachine.CurrState == CNTL_IDLE) {
-                               if ((pAd->Mlme.OneSecPeriodicRound % 7) == 0) {
-                                       MlmeAutoScan(pAd);
-                                       pAd->StaCfg.LastScanTime =
-                                           pAd->Mlme.Now32;
-                               } else {
-                                       MlmeAutoReconnectLastSSID(pAd);
-                               }
-                       }
-               }
-       }
-
-SKIP_AUTO_SCAN_CONN:
-
-       if ((pAd->MacTab.Content[BSSID_WCID].TXBAbitmap != 0)
-           && (pAd->MacTab.fAnyBASession == FALSE)) {
-               pAd->MacTab.fAnyBASession = TRUE;
-               AsicUpdateProtect(pAd, HT_FORCERTSCTS, ALLN_SETPROTECT, FALSE,
-                                 FALSE);
-       } else if ((pAd->MacTab.Content[BSSID_WCID].TXBAbitmap == 0)
-                  && (pAd->MacTab.fAnyBASession == TRUE)) {
-               pAd->MacTab.fAnyBASession = FALSE;
-               AsicUpdateProtect(pAd,
-                                 pAd->MlmeAux.AddHtInfo.AddHtInfo2.
-                                 OperaionMode, ALLN_SETPROTECT, FALSE, FALSE);
-       }
-
-       return;
-}
-
-/* Link down report */
-void LinkDownExec(void *SystemSpecific1,
-                 void *FunctionContext,
-                 void *SystemSpecific2, void *SystemSpecific3)
-{
-       struct rt_rtmp_adapter *pAd = (struct rt_rtmp_adapter *)FunctionContext;
-
-       if (pAd != NULL) {
-               struct rt_mlme_disassoc_req DisassocReq;
-
-               if ((pAd->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED) &&
-                   (INFRA_ON(pAd))) {
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("LinkDownExec(): disassociate with current AP...\n"));
-                       DisassocParmFill(pAd, &DisassocReq,
-                                        pAd->CommonCfg.Bssid,
-                                        REASON_DISASSOC_STA_LEAVING);
-                       MlmeEnqueue(pAd, ASSOC_STATE_MACHINE,
-                                   MT2_MLME_DISASSOC_REQ,
-                                   sizeof(struct rt_mlme_disassoc_req),
-                                   &DisassocReq);
-                       pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_DISASSOC;
-
-                       pAd->IndicateMediaState = NdisMediaStateDisconnected;
-                       RTMP_IndicateMediaState(pAd);
-                       pAd->ExtraInfo = GENERAL_LINK_DOWN;
-               }
-       }
-}
-
-/* IRQL = DISPATCH_LEVEL */
-void MlmeAutoScan(struct rt_rtmp_adapter *pAd)
-{
-       /* check CntlMachine.CurrState to avoid collision with NDIS SetOID request */
-       if (pAd->Mlme.CntlMachine.CurrState == CNTL_IDLE) {
-               DBGPRINT(RT_DEBUG_TRACE, ("MMCHK - Driver auto scan\n"));
-               MlmeEnqueue(pAd,
-                           MLME_CNTL_STATE_MACHINE,
-                           OID_802_11_BSSID_LIST_SCAN,
-                           pAd->MlmeAux.AutoReconnectSsidLen,
-                           pAd->MlmeAux.AutoReconnectSsid);
-               RTMP_MLME_HANDLER(pAd);
-       }
-}
-
-/* IRQL = DISPATCH_LEVEL */
-void MlmeAutoReconnectLastSSID(struct rt_rtmp_adapter *pAd)
-{
-       if (pAd->StaCfg.bAutoConnectByBssid) {
-               DBGPRINT(RT_DEBUG_TRACE,
-                       ("Driver auto reconnect to last OID_802_11_BSSID "
-                               "setting - %pM\n", pAd->MlmeAux.Bssid));
-
-               pAd->MlmeAux.Channel = pAd->CommonCfg.Channel;
-               MlmeEnqueue(pAd,
-                           MLME_CNTL_STATE_MACHINE,
-                           OID_802_11_BSSID, MAC_ADDR_LEN, pAd->MlmeAux.Bssid);
-
-               pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
-
-               RTMP_MLME_HANDLER(pAd);
-       }
-       /* check CntlMachine.CurrState to avoid collision with NDIS SetOID request */
-       else if ((pAd->Mlme.CntlMachine.CurrState == CNTL_IDLE) &&
-                (MlmeValidateSSID
-                 (pAd->MlmeAux.AutoReconnectSsid,
-                  pAd->MlmeAux.AutoReconnectSsidLen) == TRUE)) {
-               struct rt_ndis_802_11_ssid OidSsid;
-               OidSsid.SsidLength = pAd->MlmeAux.AutoReconnectSsidLen;
-               NdisMoveMemory(OidSsid.Ssid, pAd->MlmeAux.AutoReconnectSsid,
-                              pAd->MlmeAux.AutoReconnectSsidLen);
-
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("Driver auto reconnect to last OID_802_11_SSID setting - %s, len - %d\n",
-                         pAd->MlmeAux.AutoReconnectSsid,
-                         pAd->MlmeAux.AutoReconnectSsidLen));
-               MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, OID_802_11_SSID,
-                           sizeof(struct rt_ndis_802_11_ssid), &OidSsid);
-               RTMP_MLME_HANDLER(pAd);
-       }
-}
-
-/*
-       ==========================================================================
-       Description:
-               This routine checks if there're other APs out there capable for
-               roaming. Caller should call this routine only when Link up in INFRA mode
-               and channel quality is below CQI_GOOD_THRESHOLD.
-
-       IRQL = DISPATCH_LEVEL
-
-       Output:
-       ==========================================================================
- */
-void MlmeCheckForRoaming(struct rt_rtmp_adapter *pAd, unsigned long Now32)
-{
-       u16 i;
-       struct rt_bss_table *pRoamTab = &pAd->MlmeAux.RoamTab;
-       struct rt_bss_entry *pBss;
-
-       DBGPRINT(RT_DEBUG_TRACE, ("==> MlmeCheckForRoaming\n"));
-       /* put all roaming candidates into RoamTab, and sort in RSSI order */
-       BssTableInit(pRoamTab);
-       for (i = 0; i < pAd->ScanTab.BssNr; i++) {
-               pBss = &pAd->ScanTab.BssEntry[i];
-
-               if ((pBss->LastBeaconRxTime + pAd->StaCfg.BeaconLostTime) <
-                   Now32)
-                       continue;       /* AP disappear */
-               if (pBss->Rssi <= RSSI_THRESHOLD_FOR_ROAMING)
-                       continue;       /* RSSI too weak. forget it. */
-               if (MAC_ADDR_EQUAL(pBss->Bssid, pAd->CommonCfg.Bssid))
-                       continue;       /* skip current AP */
-               if (pBss->Rssi <
-                   (pAd->StaCfg.RssiSample.LastRssi0 + RSSI_DELTA))
-                       continue;       /* only AP with stronger RSSI is eligible for roaming */
-
-               /* AP passing all above rules is put into roaming candidate table */
-               NdisMoveMemory(&pRoamTab->BssEntry[pRoamTab->BssNr], pBss,
-                              sizeof(struct rt_bss_entry));
-               pRoamTab->BssNr += 1;
-       }
-
-       if (pRoamTab->BssNr > 0) {
-               /* check CntlMachine.CurrState to avoid collision with NDIS SetOID request */
-               if (pAd->Mlme.CntlMachine.CurrState == CNTL_IDLE) {
-                       pAd->RalinkCounters.PoorCQIRoamingCount++;
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("MMCHK - Roaming attempt #%ld\n",
-                                 pAd->RalinkCounters.PoorCQIRoamingCount));
-                       MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE,
-                                   MT2_MLME_ROAMING_REQ, 0, NULL);
-                       RTMP_MLME_HANDLER(pAd);
-               }
-       }
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("<== MlmeCheckForRoaming(# of candidate= %d)\n",
-                 pRoamTab->BssNr));
-}
-
-/*
-       ==========================================================================
-       Description:
-               This routine checks if there're other APs out there capable for
-               roaming. Caller should call this routine only when link up in INFRA mode
-               and channel quality is below CQI_GOOD_THRESHOLD.
-
-       IRQL = DISPATCH_LEVEL
-
-       Output:
-       ==========================================================================
- */
-BOOLEAN MlmeCheckForFastRoaming(struct rt_rtmp_adapter *pAd)
-{
-       u16 i;
-       struct rt_bss_table *pRoamTab = &pAd->MlmeAux.RoamTab;
-       struct rt_bss_entry *pBss;
-
-       DBGPRINT(RT_DEBUG_TRACE, ("==> MlmeCheckForFastRoaming\n"));
-       /* put all roaming candidates into RoamTab, and sort in RSSI order */
-       BssTableInit(pRoamTab);
-       for (i = 0; i < pAd->ScanTab.BssNr; i++) {
-               pBss = &pAd->ScanTab.BssEntry[i];
-
-               if ((pBss->Rssi <= -50)
-                   && (pBss->Channel == pAd->CommonCfg.Channel))
-                       continue;       /* RSSI too weak. forget it. */
-               if (MAC_ADDR_EQUAL(pBss->Bssid, pAd->CommonCfg.Bssid))
-                       continue;       /* skip current AP */
-               if (!SSID_EQUAL
-                   (pBss->Ssid, pBss->SsidLen, pAd->CommonCfg.Ssid,
-                    pAd->CommonCfg.SsidLen))
-                       continue;       /* skip different SSID */
-               if (pBss->Rssi <
-                   (RTMPMaxRssi
-                    (pAd, pAd->StaCfg.RssiSample.LastRssi0,
-                     pAd->StaCfg.RssiSample.LastRssi1,
-                     pAd->StaCfg.RssiSample.LastRssi2) + RSSI_DELTA))
-                       continue;       /* skip AP without better RSSI */
-
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("LastRssi0 = %d, pBss->Rssi = %d\n",
-                         RTMPMaxRssi(pAd, pAd->StaCfg.RssiSample.LastRssi0,
-                                     pAd->StaCfg.RssiSample.LastRssi1,
-                                     pAd->StaCfg.RssiSample.LastRssi2),
-                         pBss->Rssi));
-               /* AP passing all above rules is put into roaming candidate table */
-               NdisMoveMemory(&pRoamTab->BssEntry[pRoamTab->BssNr], pBss,
-                              sizeof(struct rt_bss_entry));
-               pRoamTab->BssNr += 1;
-       }
-
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("<== MlmeCheckForFastRoaming (BssNr=%d)\n", pRoamTab->BssNr));
-       if (pRoamTab->BssNr > 0) {
-               /* check CntlMachine.CurrState to avoid collision with NDIS SetOID request */
-               if (pAd->Mlme.CntlMachine.CurrState == CNTL_IDLE) {
-                       pAd->RalinkCounters.PoorCQIRoamingCount++;
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("MMCHK - Roaming attempt #%ld\n",
-                                 pAd->RalinkCounters.PoorCQIRoamingCount));
-                       MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE,
-                                   MT2_MLME_ROAMING_REQ, 0, NULL);
-                       RTMP_MLME_HANDLER(pAd);
-                       return TRUE;
-               }
-       }
-
-       return FALSE;
-}
-
-void MlmeSetTxRate(struct rt_rtmp_adapter *pAd,
-                  struct rt_mac_table_entry *pEntry, struct rt_rtmp_tx_rate_switch * pTxRate)
-{
-       u8 MaxMode = MODE_OFDM;
-
-       MaxMode = MODE_HTGREENFIELD;
-
-       if (pTxRate->STBC && (pAd->StaCfg.MaxHTPhyMode.field.STBC)
-           && (pAd->Antenna.field.TxPath == 2))
-               pAd->StaCfg.HTPhyMode.field.STBC = STBC_USE;
-       else
-               pAd->StaCfg.HTPhyMode.field.STBC = STBC_NONE;
-
-       if (pTxRate->CurrMCS < MCS_AUTO)
-               pAd->StaCfg.HTPhyMode.field.MCS = pTxRate->CurrMCS;
-
-       if (pAd->StaCfg.HTPhyMode.field.MCS > 7)
-               pAd->StaCfg.HTPhyMode.field.STBC = STBC_NONE;
-
-       if (ADHOC_ON(pAd)) {
-               /* If peer adhoc is b-only mode, we can't send 11g rate. */
-               pAd->StaCfg.HTPhyMode.field.ShortGI = GI_800;
-               pEntry->HTPhyMode.field.STBC = STBC_NONE;
-
-               /* */
-               /* For Adhoc MODE_CCK, driver will use AdhocBOnlyJoined flag to roll back to B only if necessary */
-               /* */
-               pEntry->HTPhyMode.field.MODE = pTxRate->Mode;
-               pEntry->HTPhyMode.field.ShortGI =
-                   pAd->StaCfg.HTPhyMode.field.ShortGI;
-               pEntry->HTPhyMode.field.MCS = pAd->StaCfg.HTPhyMode.field.MCS;
-
-               /* Patch speed error in status page */
-               pAd->StaCfg.HTPhyMode.field.MODE = pEntry->HTPhyMode.field.MODE;
-       } else {
-               if (pTxRate->Mode <= MaxMode)
-                       pAd->StaCfg.HTPhyMode.field.MODE = pTxRate->Mode;
-
-               if (pTxRate->ShortGI
-                   && (pAd->StaCfg.MaxHTPhyMode.field.ShortGI))
-                       pAd->StaCfg.HTPhyMode.field.ShortGI = GI_400;
-               else
-                       pAd->StaCfg.HTPhyMode.field.ShortGI = GI_800;
-
-               /* Reexam each bandwidth's SGI support. */
-               if (pAd->StaCfg.HTPhyMode.field.ShortGI == GI_400) {
-                       if ((pEntry->HTPhyMode.field.BW == BW_20)
-                           &&
-                           (!CLIENT_STATUS_TEST_FLAG
-                            (pEntry, fCLIENT_STATUS_SGI20_CAPABLE)))
-                               pAd->StaCfg.HTPhyMode.field.ShortGI = GI_800;
-                       if ((pEntry->HTPhyMode.field.BW == BW_40)
-                           &&
-                           (!CLIENT_STATUS_TEST_FLAG
-                            (pEntry, fCLIENT_STATUS_SGI40_CAPABLE)))
-                               pAd->StaCfg.HTPhyMode.field.ShortGI = GI_800;
-               }
-               /* Turn RTS/CTS rate to 6Mbps. */
-               if ((pEntry->HTPhyMode.field.MCS == 0)
-                   && (pAd->StaCfg.HTPhyMode.field.MCS != 0)) {
-                       pEntry->HTPhyMode.field.MCS =
-                           pAd->StaCfg.HTPhyMode.field.MCS;
-                       if (pAd->MacTab.fAnyBASession) {
-                               AsicUpdateProtect(pAd, HT_FORCERTSCTS,
-                                                 ALLN_SETPROTECT, TRUE,
-                                                 (BOOLEAN) pAd->MlmeAux.
-                                                 AddHtInfo.AddHtInfo2.
-                                                 NonGfPresent);
-                       } else {
-                               AsicUpdateProtect(pAd,
-                                                 pAd->MlmeAux.AddHtInfo.
-                                                 AddHtInfo2.OperaionMode,
-                                                 ALLN_SETPROTECT, TRUE,
-                                                 (BOOLEAN) pAd->MlmeAux.
-                                                 AddHtInfo.AddHtInfo2.
-                                                 NonGfPresent);
-                       }
-               } else if ((pEntry->HTPhyMode.field.MCS == 8)
-                          && (pAd->StaCfg.HTPhyMode.field.MCS != 8)) {
-                       pEntry->HTPhyMode.field.MCS =
-                           pAd->StaCfg.HTPhyMode.field.MCS;
-                       if (pAd->MacTab.fAnyBASession) {
-                               AsicUpdateProtect(pAd, HT_FORCERTSCTS,
-                                                 ALLN_SETPROTECT, TRUE,
-                                                 (BOOLEAN) pAd->MlmeAux.
-                                                 AddHtInfo.AddHtInfo2.
-                                                 NonGfPresent);
-                       } else {
-                               AsicUpdateProtect(pAd,
-                                                 pAd->MlmeAux.AddHtInfo.
-                                                 AddHtInfo2.OperaionMode,
-                                                 ALLN_SETPROTECT, TRUE,
-                                                 (BOOLEAN) pAd->MlmeAux.
-                                                 AddHtInfo.AddHtInfo2.
-                                                 NonGfPresent);
-                       }
-               } else if ((pEntry->HTPhyMode.field.MCS != 0)
-                          && (pAd->StaCfg.HTPhyMode.field.MCS == 0)) {
-                       AsicUpdateProtect(pAd, HT_RTSCTS_6M, ALLN_SETPROTECT,
-                                         TRUE,
-                                         (BOOLEAN) pAd->MlmeAux.AddHtInfo.
-                                         AddHtInfo2.NonGfPresent);
-
-               } else if ((pEntry->HTPhyMode.field.MCS != 8)
-                          && (pAd->StaCfg.HTPhyMode.field.MCS == 8)) {
-                       AsicUpdateProtect(pAd, HT_RTSCTS_6M, ALLN_SETPROTECT,
-                                         TRUE,
-                                         (BOOLEAN) pAd->MlmeAux.AddHtInfo.
-                                         AddHtInfo2.NonGfPresent);
-               }
-
-               pEntry->HTPhyMode.field.STBC = pAd->StaCfg.HTPhyMode.field.STBC;
-               pEntry->HTPhyMode.field.ShortGI =
-                   pAd->StaCfg.HTPhyMode.field.ShortGI;
-               pEntry->HTPhyMode.field.MCS = pAd->StaCfg.HTPhyMode.field.MCS;
-               pEntry->HTPhyMode.field.MODE = pAd->StaCfg.HTPhyMode.field.MODE;
-               if ((pAd->StaCfg.MaxHTPhyMode.field.MODE == MODE_HTGREENFIELD)
-                   && pAd->WIFItestbed.bGreenField)
-                       pEntry->HTPhyMode.field.MODE = MODE_HTGREENFIELD;
-       }
-
-       pAd->LastTxRate = (u16)(pEntry->HTPhyMode.word);
-}
-
-/*
-       ==========================================================================
-       Description:
-               This routine calculates the acumulated TxPER of eaxh TxRate. And
-               according to the calculation result, change CommonCfg.TxRate which
-               is the stable TX Rate we expect the Radio situation could sustained.
-
-               CommonCfg.TxRate will change dynamically within {RATE_1/RATE_6, MaxTxRate}
-       Output:
-               CommonCfg.TxRate -
-
-       IRQL = DISPATCH_LEVEL
-
-       NOTE:
-               call this routine every second
-       ==========================================================================
- */
-void MlmeDynamicTxRateSwitching(struct rt_rtmp_adapter *pAd)
-{
-       u8 UpRateIdx = 0, DownRateIdx = 0, CurrRateIdx;
-       unsigned long i, AccuTxTotalCnt = 0, TxTotalCnt;
-       unsigned long TxErrorRatio = 0;
-       BOOLEAN bTxRateChanged = FALSE, bUpgradeQuality = FALSE;
-       struct rt_rtmp_tx_rate_switch *pCurrTxRate, *pNextTxRate = NULL;
-       u8 *pTable;
-       u8 TableSize = 0;
-       u8 InitTxRateIdx = 0, TrainUp, TrainDown;
-       char Rssi, RssiOffset = 0;
-       TX_STA_CNT1_STRUC StaTx1;
-       TX_STA_CNT0_STRUC TxStaCnt0;
-       unsigned long TxRetransmit = 0, TxSuccess = 0, TxFailCount = 0;
-       struct rt_mac_table_entry *pEntry;
-       struct rt_rssi_sample *pRssi = &pAd->StaCfg.RssiSample;
-
-       /* */
-       /* walk through MAC table, see if need to change AP's TX rate toward each entry */
-       /* */
-       for (i = 1; i < MAX_LEN_OF_MAC_TABLE; i++) {
-               pEntry = &pAd->MacTab.Content[i];
-
-               /* check if this entry need to switch rate automatically */
-               if (RTMPCheckEntryEnableAutoRateSwitch(pAd, pEntry) == FALSE)
-                       continue;
-
-               if ((pAd->MacTab.Size == 1) || (pEntry->ValidAsDls)) {
-                       Rssi = RTMPMaxRssi(pAd,
-                                          pRssi->AvgRssi0,
-                                          pRssi->AvgRssi1, pRssi->AvgRssi2);
-
-                       /* Update statistic counter */
-                       RTMP_IO_READ32(pAd, TX_STA_CNT0, &TxStaCnt0.word);
-                       RTMP_IO_READ32(pAd, TX_STA_CNT1, &StaTx1.word);
-                       pAd->bUpdateBcnCntDone = TRUE;
-                       TxRetransmit = StaTx1.field.TxRetransmit;
-                       TxSuccess = StaTx1.field.TxSuccess;
-                       TxFailCount = TxStaCnt0.field.TxFailCount;
-                       TxTotalCnt = TxRetransmit + TxSuccess + TxFailCount;
-
-                       pAd->RalinkCounters.OneSecTxRetryOkCount +=
-                           StaTx1.field.TxRetransmit;
-                       pAd->RalinkCounters.OneSecTxNoRetryOkCount +=
-                           StaTx1.field.TxSuccess;
-                       pAd->RalinkCounters.OneSecTxFailCount +=
-                           TxStaCnt0.field.TxFailCount;
-                       pAd->WlanCounters.TransmittedFragmentCount.u.LowPart +=
-                           StaTx1.field.TxSuccess;
-                       pAd->WlanCounters.RetryCount.u.LowPart +=
-                           StaTx1.field.TxRetransmit;
-                       pAd->WlanCounters.FailedCount.u.LowPart +=
-                           TxStaCnt0.field.TxFailCount;
-
-                       /* if no traffic in the past 1-sec period, don't change TX rate, */
-                       /* but clear all bad history. because the bad history may affect the next */
-                       /* Chariot throughput test */
-                       AccuTxTotalCnt =
-                           pAd->RalinkCounters.OneSecTxNoRetryOkCount +
-                           pAd->RalinkCounters.OneSecTxRetryOkCount +
-                           pAd->RalinkCounters.OneSecTxFailCount;
-
-                       if (TxTotalCnt)
-                               TxErrorRatio =
-                                   ((TxRetransmit +
-                                     TxFailCount) * 100) / TxTotalCnt;
-               } else {
-                       if (INFRA_ON(pAd) && (i == 1))
-                               Rssi = RTMPMaxRssi(pAd,
-                                                  pRssi->AvgRssi0,
-                                                  pRssi->AvgRssi1,
-                                                  pRssi->AvgRssi2);
-                       else
-                               Rssi = RTMPMaxRssi(pAd,
-                                                  pEntry->RssiSample.AvgRssi0,
-                                                  pEntry->RssiSample.AvgRssi1,
-                                                  pEntry->RssiSample.AvgRssi2);
-
-                       TxTotalCnt = pEntry->OneSecTxNoRetryOkCount +
-                           pEntry->OneSecTxRetryOkCount +
-                           pEntry->OneSecTxFailCount;
-
-                       if (TxTotalCnt)
-                               TxErrorRatio =
-                                   ((pEntry->OneSecTxRetryOkCount +
-                                     pEntry->OneSecTxFailCount) * 100) /
-                                   TxTotalCnt;
-               }
-
-               if (TxTotalCnt) {
-                       /*
-                          Three AdHoc connections can not work normally if one AdHoc connection is disappeared from a heavy traffic environment generated by ping tool
-                          We force to set LongRtyLimit and ShortRtyLimit to 0 to stop retransmitting packet, after a while, resoring original settings
-                        */
-                       if (TxErrorRatio == 100) {
-                               TX_RTY_CFG_STRUC TxRtyCfg, TxRtyCfgtmp;
-                               unsigned long Index;
-                               unsigned long MACValue;
-
-                               RTMP_IO_READ32(pAd, TX_RTY_CFG, &TxRtyCfg.word);
-                               TxRtyCfgtmp.word = TxRtyCfg.word;
-                               TxRtyCfg.field.LongRtyLimit = 0x0;
-                               TxRtyCfg.field.ShortRtyLimit = 0x0;
-                               RTMP_IO_WRITE32(pAd, TX_RTY_CFG, TxRtyCfg.word);
-
-                               RTMPusecDelay(1);
-
-                               Index = 0;
-                               MACValue = 0;
-                               do {
-                                       RTMP_IO_READ32(pAd, TXRXQ_PCNT,
-                                                      &MACValue);
-                                       if ((MACValue & 0xffffff) == 0)
-                                               break;
-                                       Index++;
-                                       RTMPusecDelay(1000);
-                               } while ((Index < 330)
-                                        &&
-                                        (!RTMP_TEST_FLAG
-                                         (pAd,
-                                          fRTMP_ADAPTER_HALT_IN_PROGRESS)));
-
-                               RTMP_IO_READ32(pAd, TX_RTY_CFG, &TxRtyCfg.word);
-                               TxRtyCfg.field.LongRtyLimit =
-                                   TxRtyCfgtmp.field.LongRtyLimit;
-                               TxRtyCfg.field.ShortRtyLimit =
-                                   TxRtyCfgtmp.field.ShortRtyLimit;
-                               RTMP_IO_WRITE32(pAd, TX_RTY_CFG, TxRtyCfg.word);
-                       }
-               }
-
-               CurrRateIdx = pEntry->CurrTxRateIndex;
-
-               MlmeSelectTxRateTable(pAd, pEntry, &pTable, &TableSize,
-                                     &InitTxRateIdx);
-
-               if (CurrRateIdx >= TableSize) {
-                       CurrRateIdx = TableSize - 1;
-               }
-               /* When switch from Fixed rate -> auto rate, the REAL TX rate might be different from pAd->CommonCfg.TxRateIndex. */
-               /* So need to sync here. */
-               pCurrTxRate =
-                   (struct rt_rtmp_tx_rate_switch *) & pTable[(CurrRateIdx + 1) * 5];
-               if ((pEntry->HTPhyMode.field.MCS != pCurrTxRate->CurrMCS)
-                   /*&& (pAd->StaCfg.bAutoTxRateSwitch == TRUE) */
-                   ) {
-
-                       /* Need to sync Real Tx rate and our record. */
-                       /* Then return for next DRS. */
-                       pCurrTxRate =
-                           (struct rt_rtmp_tx_rate_switch *) & pTable[(InitTxRateIdx + 1)
-                                                           * 5];
-                       pEntry->CurrTxRateIndex = InitTxRateIdx;
-                       MlmeSetTxRate(pAd, pEntry, pCurrTxRate);
-
-                       /* reset all OneSecTx counters */
-                       RESET_ONE_SEC_TX_CNT(pEntry);
-                       continue;
-               }
-               /* decide the next upgrade rate and downgrade rate, if any */
-               if ((CurrRateIdx > 0) && (CurrRateIdx < (TableSize - 1))) {
-                       UpRateIdx = CurrRateIdx + 1;
-                       DownRateIdx = CurrRateIdx - 1;
-               } else if (CurrRateIdx == 0) {
-                       UpRateIdx = CurrRateIdx + 1;
-                       DownRateIdx = CurrRateIdx;
-               } else if (CurrRateIdx == (TableSize - 1)) {
-                       UpRateIdx = CurrRateIdx;
-                       DownRateIdx = CurrRateIdx - 1;
-               }
-
-               pCurrTxRate =
-                   (struct rt_rtmp_tx_rate_switch *) & pTable[(CurrRateIdx + 1) * 5];
-
-               if ((Rssi > -65) && (pCurrTxRate->Mode >= MODE_HTMIX)) {
-                       TrainUp =
-                           (pCurrTxRate->TrainUp +
-                            (pCurrTxRate->TrainUp >> 1));
-                       TrainDown =
-                           (pCurrTxRate->TrainDown +
-                            (pCurrTxRate->TrainDown >> 1));
-               } else {
-                       TrainUp = pCurrTxRate->TrainUp;
-                       TrainDown = pCurrTxRate->TrainDown;
-               }
-
-               /*pAd->DrsCounters.LastTimeTxRateChangeAction = pAd->DrsCounters.LastSecTxRateChangeAction; */
-
-               /* */
-               /* Keep the last time TxRateChangeAction status. */
-               /* */
-               pEntry->LastTimeTxRateChangeAction =
-                   pEntry->LastSecTxRateChangeAction;
-
-               /* */
-               /* CASE 1. when TX samples are fewer than 15, then decide TX rate solely on RSSI */
-               /*         (criteria copied from RT2500 for Netopia case) */
-               /* */
-               if (TxTotalCnt <= 15) {
-                       char idx = 0;
-                       u8 TxRateIdx;
-                       u8 MCS0 = 0, MCS1 = 0, MCS2 = 0, MCS3 = 0, MCS4 =
-                           0, MCS5 = 0, MCS6 = 0, MCS7 = 0;
-                       u8 MCS12 = 0, MCS13 = 0, MCS14 = 0, MCS15 = 0;
-                       u8 MCS20 = 0, MCS21 = 0, MCS22 = 0, MCS23 = 0;  /* 3*3 */
-
-                       /* check the existence and index of each needed MCS */
-                       while (idx < pTable[0]) {
-                               pCurrTxRate =
-                                   (struct rt_rtmp_tx_rate_switch *) & pTable[(idx + 1) *
-                                                                   5];
-
-                               if (pCurrTxRate->CurrMCS == MCS_0) {
-                                       MCS0 = idx;
-                               } else if (pCurrTxRate->CurrMCS == MCS_1) {
-                                       MCS1 = idx;
-                               } else if (pCurrTxRate->CurrMCS == MCS_2) {
-                                       MCS2 = idx;
-                               } else if (pCurrTxRate->CurrMCS == MCS_3) {
-                                       MCS3 = idx;
-                               } else if (pCurrTxRate->CurrMCS == MCS_4) {
-                                       MCS4 = idx;
-                               } else if (pCurrTxRate->CurrMCS == MCS_5) {
-                                       MCS5 = idx;
-                               } else if (pCurrTxRate->CurrMCS == MCS_6) {
-                                       MCS6 = idx;
-                               }
-                               /*else if (pCurrTxRate->CurrMCS == MCS_7) */
-                               else if ((pCurrTxRate->CurrMCS == MCS_7) && (pCurrTxRate->ShortGI == GI_800))   /* prevent the highest MCS using short GI when 1T and low throughput */
-                               {
-                                       MCS7 = idx;
-                               } else if (pCurrTxRate->CurrMCS == MCS_12) {
-                                       MCS12 = idx;
-                               } else if (pCurrTxRate->CurrMCS == MCS_13) {
-                                       MCS13 = idx;
-                               } else if (pCurrTxRate->CurrMCS == MCS_14) {
-                                       MCS14 = idx;
-                               }
-                               else if ((pCurrTxRate->CurrMCS == MCS_15) && (pCurrTxRate->ShortGI == GI_800))  /*we hope to use ShortGI as initial rate, however Atheros's chip has bugs when short GI */
-                               {
-                                       MCS15 = idx;
-                               } else if (pCurrTxRate->CurrMCS == MCS_20)      /* 3*3 */
-                               {
-                                       MCS20 = idx;
-                               } else if (pCurrTxRate->CurrMCS == MCS_21) {
-                                       MCS21 = idx;
-                               } else if (pCurrTxRate->CurrMCS == MCS_22) {
-                                       MCS22 = idx;
-                               } else if (pCurrTxRate->CurrMCS == MCS_23) {
-                                       MCS23 = idx;
-                               }
-                               idx++;
-                       }
-
-                       if (pAd->LatchRfRegs.Channel <= 14) {
-                               if (pAd->NicConfig2.field.ExternalLNAForG) {
-                                       RssiOffset = 2;
-                               } else {
-                                       RssiOffset = 5;
-                               }
-                       } else {
-                               if (pAd->NicConfig2.field.ExternalLNAForA) {
-                                       RssiOffset = 5;
-                               } else {
-                                       RssiOffset = 8;
-                               }
-                       }
-
-                       /*if (MCS15) */
-                       if ((pTable == RateSwitchTable11BGN3S) || (pTable == RateSwitchTable11N3S) || (pTable == RateSwitchTable)) {    /* N mode with 3 stream // 3*3 */
-                               if (MCS23 && (Rssi >= -70))
-                                       TxRateIdx = MCS23;
-                               else if (MCS22 && (Rssi >= -72))
-                                       TxRateIdx = MCS22;
-                               else if (MCS21 && (Rssi >= -76))
-                                       TxRateIdx = MCS21;
-                               else if (MCS20 && (Rssi >= -78))
-                                       TxRateIdx = MCS20;
-                               else if (MCS4 && (Rssi >= -82))
-                                       TxRateIdx = MCS4;
-                               else if (MCS3 && (Rssi >= -84))
-                                       TxRateIdx = MCS3;
-                               else if (MCS2 && (Rssi >= -86))
-                                       TxRateIdx = MCS2;
-                               else if (MCS1 && (Rssi >= -88))
-                                       TxRateIdx = MCS1;
-                               else
-                                       TxRateIdx = MCS0;
-                       }
-/*              else if ((pTable == RateSwitchTable11BGN2S) || (pTable == RateSwitchTable11BGN2SForABand) ||(pTable == RateSwitchTable11N2S) ||(pTable == RateSwitchTable11N2SForABand) || (pTable == RateSwitchTable)) */
-                       else if ((pTable == RateSwitchTable11BGN2S) || (pTable == RateSwitchTable11BGN2SForABand) || (pTable == RateSwitchTable11N2S) || (pTable == RateSwitchTable11N2SForABand))      /* 3*3 */
-                       {       /* N mode with 2 stream */
-                               if (MCS15 && (Rssi >= (-70 + RssiOffset)))
-                                       TxRateIdx = MCS15;
-                               else if (MCS14 && (Rssi >= (-72 + RssiOffset)))
-                                       TxRateIdx = MCS14;
-                               else if (MCS13 && (Rssi >= (-76 + RssiOffset)))
-                                       TxRateIdx = MCS13;
-                               else if (MCS12 && (Rssi >= (-78 + RssiOffset)))
-                                       TxRateIdx = MCS12;
-                               else if (MCS4 && (Rssi >= (-82 + RssiOffset)))
-                                       TxRateIdx = MCS4;
-                               else if (MCS3 && (Rssi >= (-84 + RssiOffset)))
-                                       TxRateIdx = MCS3;
-                               else if (MCS2 && (Rssi >= (-86 + RssiOffset)))
-                                       TxRateIdx = MCS2;
-                               else if (MCS1 && (Rssi >= (-88 + RssiOffset)))
-                                       TxRateIdx = MCS1;
-                               else
-                                       TxRateIdx = MCS0;
-                       } else if ((pTable == RateSwitchTable11BGN1S) || (pTable == RateSwitchTable11N1S)) {    /* N mode with 1 stream */
-                               if (MCS7 && (Rssi > (-72 + RssiOffset)))
-                                       TxRateIdx = MCS7;
-                               else if (MCS6 && (Rssi > (-74 + RssiOffset)))
-                                       TxRateIdx = MCS6;
-                               else if (MCS5 && (Rssi > (-77 + RssiOffset)))
-                                       TxRateIdx = MCS5;
-                               else if (MCS4 && (Rssi > (-79 + RssiOffset)))
-                                       TxRateIdx = MCS4;
-                               else if (MCS3 && (Rssi > (-81 + RssiOffset)))
-                                       TxRateIdx = MCS3;
-                               else if (MCS2 && (Rssi > (-83 + RssiOffset)))
-                                       TxRateIdx = MCS2;
-                               else if (MCS1 && (Rssi > (-86 + RssiOffset)))
-                                       TxRateIdx = MCS1;
-                               else
-                                       TxRateIdx = MCS0;
-                       } else {        /* Legacy mode */
-                               if (MCS7 && (Rssi > -70))
-                                       TxRateIdx = MCS7;
-                               else if (MCS6 && (Rssi > -74))
-                                       TxRateIdx = MCS6;
-                               else if (MCS5 && (Rssi > -78))
-                                       TxRateIdx = MCS5;
-                               else if (MCS4 && (Rssi > -82))
-                                       TxRateIdx = MCS4;
-                               else if (MCS4 == 0)     /* for B-only mode */
-                                       TxRateIdx = MCS3;
-                               else if (MCS3 && (Rssi > -85))
-                                       TxRateIdx = MCS3;
-                               else if (MCS2 && (Rssi > -87))
-                                       TxRateIdx = MCS2;
-                               else if (MCS1 && (Rssi > -90))
-                                       TxRateIdx = MCS1;
-                               else
-                                       TxRateIdx = MCS0;
-                       }
-
-                       /*              if (TxRateIdx != pAd->CommonCfg.TxRateIndex) */
-                       {
-                               pEntry->CurrTxRateIndex = TxRateIdx;
-                               pNextTxRate =
-                                   (struct rt_rtmp_tx_rate_switch *) &
-                                   pTable[(pEntry->CurrTxRateIndex + 1) * 5];
-                               MlmeSetTxRate(pAd, pEntry, pNextTxRate);
-                       }
-
-                       NdisZeroMemory(pEntry->TxQuality,
-                                      sizeof(u16)*
-                                      MAX_STEP_OF_TX_RATE_SWITCH);
-                       NdisZeroMemory(pEntry->PER,
-                                      sizeof(u8)*
-                                      MAX_STEP_OF_TX_RATE_SWITCH);
-                       pEntry->fLastSecAccordingRSSI = TRUE;
-                       /* reset all OneSecTx counters */
-                       RESET_ONE_SEC_TX_CNT(pEntry);
-
-                       continue;
-               }
-
-               if (pEntry->fLastSecAccordingRSSI == TRUE) {
-                       pEntry->fLastSecAccordingRSSI = FALSE;
-                       pEntry->LastSecTxRateChangeAction = 0;
-                       /* reset all OneSecTx counters */
-                       RESET_ONE_SEC_TX_CNT(pEntry);
-
-                       continue;
-               }
-
-               do {
-                       BOOLEAN bTrainUpDown = FALSE;
-
-                       pEntry->CurrTxRateStableTime++;
-
-                       /* downgrade TX quality if PER >= Rate-Down threshold */
-                       if (TxErrorRatio >= TrainDown) {
-                               bTrainUpDown = TRUE;
-                               pEntry->TxQuality[CurrRateIdx] =
-                                   DRS_TX_QUALITY_WORST_BOUND;
-                       }
-                       /* upgrade TX quality if PER <= Rate-Up threshold */
-                       else if (TxErrorRatio <= TrainUp) {
-                               bTrainUpDown = TRUE;
-                               bUpgradeQuality = TRUE;
-                               if (pEntry->TxQuality[CurrRateIdx])
-                                       pEntry->TxQuality[CurrRateIdx]--;       /* quality very good in CurrRate */
-
-                               if (pEntry->TxRateUpPenalty)
-                                       pEntry->TxRateUpPenalty--;
-                               else if (pEntry->TxQuality[UpRateIdx])
-                                       pEntry->TxQuality[UpRateIdx]--; /* may improve next UP rate's quality */
-                       }
-
-                       pEntry->PER[CurrRateIdx] = (u8)TxErrorRatio;
-
-                       if (bTrainUpDown) {
-                               /* perform DRS - consider TxRate Down first, then rate up. */
-                               if ((CurrRateIdx != DownRateIdx)
-                                   && (pEntry->TxQuality[CurrRateIdx] >=
-                                       DRS_TX_QUALITY_WORST_BOUND)) {
-                                       pEntry->CurrTxRateIndex = DownRateIdx;
-                               } else if ((CurrRateIdx != UpRateIdx)
-                                          && (pEntry->TxQuality[UpRateIdx] <=
-                                              0)) {
-                                       pEntry->CurrTxRateIndex = UpRateIdx;
-                               }
-                       }
-               } while (FALSE);
-
-               /* if rate-up happen, clear all bad history of all TX rates */
-               if (pEntry->CurrTxRateIndex > CurrRateIdx) {
-                       pEntry->CurrTxRateStableTime = 0;
-                       pEntry->TxRateUpPenalty = 0;
-                       pEntry->LastSecTxRateChangeAction = 1;  /* rate UP */
-                       NdisZeroMemory(pEntry->TxQuality,
-                                      sizeof(u16)*
-                                      MAX_STEP_OF_TX_RATE_SWITCH);
-                       NdisZeroMemory(pEntry->PER,
-                                      sizeof(u8)*
-                                      MAX_STEP_OF_TX_RATE_SWITCH);
-
-                       /* */
-                       /* For TxRate fast train up */
-                       /* */
-                       if (!pAd->StaCfg.StaQuickResponeForRateUpTimerRunning) {
-                               RTMPSetTimer(&pAd->StaCfg.
-                                            StaQuickResponeForRateUpTimer,
-                                            100);
-
-                               pAd->StaCfg.
-                                   StaQuickResponeForRateUpTimerRunning = TRUE;
-                       }
-                       bTxRateChanged = TRUE;
-               }
-               /* if rate-down happen, only clear DownRate's bad history */
-               else if (pEntry->CurrTxRateIndex < CurrRateIdx) {
-                       pEntry->CurrTxRateStableTime = 0;
-                       pEntry->TxRateUpPenalty = 0;    /* no penalty */
-                       pEntry->LastSecTxRateChangeAction = 2;  /* rate DOWN */
-                       pEntry->TxQuality[pEntry->CurrTxRateIndex] = 0;
-                       pEntry->PER[pEntry->CurrTxRateIndex] = 0;
-
-                       /* */
-                       /* For TxRate fast train down */
-                       /* */
-                       if (!pAd->StaCfg.StaQuickResponeForRateUpTimerRunning) {
-                               RTMPSetTimer(&pAd->StaCfg.
-                                            StaQuickResponeForRateUpTimer,
-                                            100);
-
-                               pAd->StaCfg.
-                                   StaQuickResponeForRateUpTimerRunning = TRUE;
-                       }
-                       bTxRateChanged = TRUE;
-               } else {
-                       pEntry->LastSecTxRateChangeAction = 0;  /* rate no change */
-                       bTxRateChanged = FALSE;
-               }
-
-               pEntry->LastTxOkCount = TxSuccess;
-               {
-                       u8 tmpTxRate;
-
-                       /* to fix tcp ack issue */
-                       if (!bTxRateChanged
-                           && (pAd->RalinkCounters.OneSecReceivedByteCount >
-                               (pAd->RalinkCounters.
-                                OneSecTransmittedByteCount * 5))) {
-                               tmpTxRate = DownRateIdx;
-                               DBGPRINT_RAW(RT_DEBUG_TRACE,
-                                            ("DRS: Rx(%d) is 5 times larger than Tx(%d), use low rate (curr=%d, tmp=%d)\n",
-                                             pAd->RalinkCounters.
-                                             OneSecReceivedByteCount,
-                                             pAd->RalinkCounters.
-                                             OneSecTransmittedByteCount,
-                                             pEntry->CurrTxRateIndex,
-                                             tmpTxRate));
-                       } else {
-                               tmpTxRate = pEntry->CurrTxRateIndex;
-                       }
-
-                       pNextTxRate =
-                           (struct rt_rtmp_tx_rate_switch *) & pTable[(tmpTxRate + 1) *
-                                                           5];
-               }
-               if (bTxRateChanged && pNextTxRate) {
-                       MlmeSetTxRate(pAd, pEntry, pNextTxRate);
-               }
-               /* reset all OneSecTx counters */
-               RESET_ONE_SEC_TX_CNT(pEntry);
-       }
-}
-
-/*
-       ========================================================================
-       Routine Description:
-               Station side, Auto TxRate faster train up timer call back function.
-
-       Arguments:
-               SystemSpecific1                 - Not used.
-               FunctionContext                 - Pointer to our Adapter context.
-               SystemSpecific2                 - Not used.
-               SystemSpecific3                 - Not used.
-
-       Return Value:
-               None
-
-       ========================================================================
-*/
-void StaQuickResponeForRateUpExec(void *SystemSpecific1,
-                                 void *FunctionContext,
-                                 void *SystemSpecific2,
-                                 void *SystemSpecific3)
-{
-       struct rt_rtmp_adapter *pAd = (struct rt_rtmp_adapter *)FunctionContext;
-       u8 UpRateIdx = 0, DownRateIdx = 0, CurrRateIdx = 0;
-       unsigned long TxTotalCnt;
-       unsigned long TxErrorRatio = 0;
-       BOOLEAN bTxRateChanged; /*, bUpgradeQuality = FALSE; */
-       struct rt_rtmp_tx_rate_switch *pCurrTxRate, *pNextTxRate = NULL;
-       u8 *pTable;
-       u8 TableSize = 0;
-       u8 InitTxRateIdx = 0, TrainUp, TrainDown;
-       TX_STA_CNT1_STRUC StaTx1;
-       TX_STA_CNT0_STRUC TxStaCnt0;
-       char Rssi, ratio;
-       unsigned long TxRetransmit = 0, TxSuccess = 0, TxFailCount = 0;
-       struct rt_mac_table_entry *pEntry;
-       unsigned long i;
-
-       pAd->StaCfg.StaQuickResponeForRateUpTimerRunning = FALSE;
-
-       /* */
-       /* walk through MAC table, see if need to change AP's TX rate toward each entry */
-       /* */
-       for (i = 1; i < MAX_LEN_OF_MAC_TABLE; i++) {
-               pEntry = &pAd->MacTab.Content[i];
-
-               /* check if this entry need to switch rate automatically */
-               if (RTMPCheckEntryEnableAutoRateSwitch(pAd, pEntry) == FALSE)
-                       continue;
-
-               if (INFRA_ON(pAd) && (i == 1))
-                       Rssi = RTMPMaxRssi(pAd,
-                                          pAd->StaCfg.RssiSample.AvgRssi0,
-                                          pAd->StaCfg.RssiSample.AvgRssi1,
-                                          pAd->StaCfg.RssiSample.AvgRssi2);
-               else
-                       Rssi = RTMPMaxRssi(pAd,
-                                          pEntry->RssiSample.AvgRssi0,
-                                          pEntry->RssiSample.AvgRssi1,
-                                          pEntry->RssiSample.AvgRssi2);
-
-               CurrRateIdx = pAd->CommonCfg.TxRateIndex;
-
-               MlmeSelectTxRateTable(pAd, pEntry, &pTable, &TableSize,
-                                     &InitTxRateIdx);
-
-               /* decide the next upgrade rate and downgrade rate, if any */
-               if ((CurrRateIdx > 0) && (CurrRateIdx < (TableSize - 1))) {
-                       UpRateIdx = CurrRateIdx + 1;
-                       DownRateIdx = CurrRateIdx - 1;
-               } else if (CurrRateIdx == 0) {
-                       UpRateIdx = CurrRateIdx + 1;
-                       DownRateIdx = CurrRateIdx;
-               } else if (CurrRateIdx == (TableSize - 1)) {
-                       UpRateIdx = CurrRateIdx;
-                       DownRateIdx = CurrRateIdx - 1;
-               }
-
-               pCurrTxRate =
-                   (struct rt_rtmp_tx_rate_switch *) & pTable[(CurrRateIdx + 1) * 5];
-
-               if ((Rssi > -65) && (pCurrTxRate->Mode >= MODE_HTMIX)) {
-                       TrainUp =
-                           (pCurrTxRate->TrainUp +
-                            (pCurrTxRate->TrainUp >> 1));
-                       TrainDown =
-                           (pCurrTxRate->TrainDown +
-                            (pCurrTxRate->TrainDown >> 1));
-               } else {
-                       TrainUp = pCurrTxRate->TrainUp;
-                       TrainDown = pCurrTxRate->TrainDown;
-               }
-
-               if (pAd->MacTab.Size == 1) {
-                       /* Update statistic counter */
-                       RTMP_IO_READ32(pAd, TX_STA_CNT0, &TxStaCnt0.word);
-                       RTMP_IO_READ32(pAd, TX_STA_CNT1, &StaTx1.word);
-
-                       TxRetransmit = StaTx1.field.TxRetransmit;
-                       TxSuccess = StaTx1.field.TxSuccess;
-                       TxFailCount = TxStaCnt0.field.TxFailCount;
-                       TxTotalCnt = TxRetransmit + TxSuccess + TxFailCount;
-
-                       pAd->RalinkCounters.OneSecTxRetryOkCount +=
-                           StaTx1.field.TxRetransmit;
-                       pAd->RalinkCounters.OneSecTxNoRetryOkCount +=
-                           StaTx1.field.TxSuccess;
-                       pAd->RalinkCounters.OneSecTxFailCount +=
-                           TxStaCnt0.field.TxFailCount;
-                       pAd->WlanCounters.TransmittedFragmentCount.u.LowPart +=
-                           StaTx1.field.TxSuccess;
-                       pAd->WlanCounters.RetryCount.u.LowPart +=
-                           StaTx1.field.TxRetransmit;
-                       pAd->WlanCounters.FailedCount.u.LowPart +=
-                           TxStaCnt0.field.TxFailCount;
-
-                       if (TxTotalCnt)
-                               TxErrorRatio =
-                                   ((TxRetransmit +
-                                     TxFailCount) * 100) / TxTotalCnt;
-               } else {
-                       TxTotalCnt = pEntry->OneSecTxNoRetryOkCount +
-                           pEntry->OneSecTxRetryOkCount +
-                           pEntry->OneSecTxFailCount;
-
-                       if (TxTotalCnt)
-                               TxErrorRatio =
-                                   ((pEntry->OneSecTxRetryOkCount +
-                                     pEntry->OneSecTxFailCount) * 100) /
-                                   TxTotalCnt;
-               }
-
-               /* */
-               /* CASE 1. when TX samples are fewer than 15, then decide TX rate solely on RSSI */
-               /*         (criteria copied from RT2500 for Netopia case) */
-               /* */
-               if (TxTotalCnt <= 12) {
-                       NdisZeroMemory(pAd->DrsCounters.TxQuality,
-                                      sizeof(u16)*
-                                      MAX_STEP_OF_TX_RATE_SWITCH);
-                       NdisZeroMemory(pAd->DrsCounters.PER,
-                                      sizeof(u8)*
-                                      MAX_STEP_OF_TX_RATE_SWITCH);
-
-                       if ((pAd->DrsCounters.LastSecTxRateChangeAction == 1)
-                           && (CurrRateIdx != DownRateIdx)) {
-                               pAd->CommonCfg.TxRateIndex = DownRateIdx;
-                               pAd->DrsCounters.TxQuality[CurrRateIdx] =
-                                   DRS_TX_QUALITY_WORST_BOUND;
-                       } else
-                           if ((pAd->DrsCounters.LastSecTxRateChangeAction ==
-                                2) && (CurrRateIdx != UpRateIdx)) {
-                               pAd->CommonCfg.TxRateIndex = UpRateIdx;
-                       }
-
-                       DBGPRINT_RAW(RT_DEBUG_TRACE,
-                                    ("QuickDRS: TxTotalCnt <= 15, train back to original rate \n"));
-                       return;
-               }
-
-               do {
-                       unsigned long OneSecTxNoRetryOKRationCount;
-
-                       if (pAd->DrsCounters.LastTimeTxRateChangeAction == 0)
-                               ratio = 5;
-                       else
-                               ratio = 4;
-
-                       /* downgrade TX quality if PER >= Rate-Down threshold */
-                       if (TxErrorRatio >= TrainDown) {
-                               pAd->DrsCounters.TxQuality[CurrRateIdx] =
-                                   DRS_TX_QUALITY_WORST_BOUND;
-                       }
-
-                       pAd->DrsCounters.PER[CurrRateIdx] =
-                           (u8)TxErrorRatio;
-
-                       OneSecTxNoRetryOKRationCount = (TxSuccess * ratio);
-
-                       /* perform DRS - consider TxRate Down first, then rate up. */
-                       if ((pAd->DrsCounters.LastSecTxRateChangeAction == 1)
-                           && (CurrRateIdx != DownRateIdx)) {
-                               if ((pAd->DrsCounters.LastTxOkCount + 2) >=
-                                   OneSecTxNoRetryOKRationCount) {
-                                       pAd->CommonCfg.TxRateIndex =
-                                           DownRateIdx;
-                                       pAd->DrsCounters.
-                                           TxQuality[CurrRateIdx] =
-                                           DRS_TX_QUALITY_WORST_BOUND;
-
-                               }
-
-                       } else
-                           if ((pAd->DrsCounters.LastSecTxRateChangeAction ==
-                                2) && (CurrRateIdx != UpRateIdx)) {
-                               if ((TxErrorRatio >= 50)
-                                   || (TxErrorRatio >= TrainDown)) {
-
-                               } else if ((pAd->DrsCounters.LastTxOkCount + 2)
-                                          >= OneSecTxNoRetryOKRationCount) {
-                                       pAd->CommonCfg.TxRateIndex = UpRateIdx;
-                               }
-                       }
-               } while (FALSE);
-
-               /* if rate-up happen, clear all bad history of all TX rates */
-               if (pAd->CommonCfg.TxRateIndex > CurrRateIdx) {
-                       pAd->DrsCounters.TxRateUpPenalty = 0;
-                       NdisZeroMemory(pAd->DrsCounters.TxQuality,
-                                      sizeof(u16)*
-                                      MAX_STEP_OF_TX_RATE_SWITCH);
-                       NdisZeroMemory(pAd->DrsCounters.PER,
-                                      sizeof(u8)*
-                                      MAX_STEP_OF_TX_RATE_SWITCH);
-                       bTxRateChanged = TRUE;
-               }
-               /* if rate-down happen, only clear DownRate's bad history */
-               else if (pAd->CommonCfg.TxRateIndex < CurrRateIdx) {
-                       DBGPRINT_RAW(RT_DEBUG_TRACE,
-                                    ("QuickDRS: --TX rate from %d to %d \n",
-                                     CurrRateIdx, pAd->CommonCfg.TxRateIndex));
-
-                       pAd->DrsCounters.TxRateUpPenalty = 0;   /* no penalty */
-                       pAd->DrsCounters.TxQuality[pAd->CommonCfg.TxRateIndex] =
-                           0;
-                       pAd->DrsCounters.PER[pAd->CommonCfg.TxRateIndex] = 0;
-                       bTxRateChanged = TRUE;
-               } else {
-                       bTxRateChanged = FALSE;
-               }
-
-               pNextTxRate =
-                   (struct rt_rtmp_tx_rate_switch *) &
-                   pTable[(pAd->CommonCfg.TxRateIndex + 1) * 5];
-               if (bTxRateChanged && pNextTxRate) {
-                       MlmeSetTxRate(pAd, pEntry, pNextTxRate);
-               }
-       }
-}
-
-/*
-       ==========================================================================
-       Description:
-               This routine is executed periodically inside MlmePeriodicExec() after
-               association with an AP.
-               It checks if StaCfg.Psm is consistent with user policy (recorded in
-               StaCfg.WindowsPowerMode). If not, enforce user policy. However,
-               there're some conditions to consider:
-               1. we don't support power-saving in ADHOC mode, so Psm=PWR_ACTIVE all
-                  the time when Mibss==TRUE
-               2. When link up in INFRA mode, Psm should not be switch to PWR_SAVE
-                  if outgoing traffic available in TxRing or MgmtRing.
-       Output:
-               1. change pAd->StaCfg.Psm to PWR_SAVE or leave it untouched
-
-       IRQL = DISPATCH_LEVEL
-
-       ==========================================================================
- */
-void MlmeCheckPsmChange(struct rt_rtmp_adapter *pAd, unsigned long Now32)
-{
-       unsigned long PowerMode;
-
-       /* condition - */
-       /* 1. Psm maybe ON only happen in INFRASTRUCTURE mode */
-       /* 2. user wants either MAX_PSP or FAST_PSP */
-       /* 3. but current psm is not in PWR_SAVE */
-       /* 4. CNTL state machine is not doing SCANning */
-       /* 5. no TX SUCCESS event for the past 1-sec period */
-       PowerMode = pAd->StaCfg.WindowsPowerMode;
-
-       if (INFRA_ON(pAd) &&
-           (PowerMode != Ndis802_11PowerModeCAM) &&
-           (pAd->StaCfg.Psm == PWR_ACTIVE) &&
-/*              (! RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS)) */
-           (pAd->Mlme.CntlMachine.CurrState == CNTL_IDLE) &&
-           RTMP_TEST_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP)
-           /*&&
-              (pAd->RalinkCounters.OneSecTxNoRetryOkCount == 0) &&
-              (pAd->RalinkCounters.OneSecTxRetryOkCount == 0) */
-           ) {
-               NdisGetSystemUpTime(&pAd->Mlme.LastSendNULLpsmTime);
-               pAd->RalinkCounters.RxCountSinceLastNULL = 0;
-               RTMP_SET_PSM_BIT(pAd, PWR_SAVE);
-               if (!
-                   (pAd->CommonCfg.bAPSDCapable
-                    && pAd->CommonCfg.APEdcaParm.bAPSDCapable)) {
-                       RTMPSendNullFrame(pAd, pAd->CommonCfg.TxRate, FALSE);
-               } else {
-                       RTMPSendNullFrame(pAd, pAd->CommonCfg.TxRate, TRUE);
-               }
-       }
-}
-
-/* IRQL = PASSIVE_LEVEL */
-/* IRQL = DISPATCH_LEVEL */
-void MlmeSetPsmBit(struct rt_rtmp_adapter *pAd, u16 psm)
-{
-       AUTO_RSP_CFG_STRUC csr4;
-
-       pAd->StaCfg.Psm = psm;
-       RTMP_IO_READ32(pAd, AUTO_RSP_CFG, &csr4.word);
-       csr4.field.AckCtsPsmBit = (psm == PWR_SAVE) ? 1 : 0;
-       RTMP_IO_WRITE32(pAd, AUTO_RSP_CFG, csr4.word);
-
-       DBGPRINT(RT_DEBUG_TRACE, ("MlmeSetPsmBit = %d\n", psm));
-}
-
-/*
-       ==========================================================================
-       Description:
-               This routine calculates TxPER, RxPER of the past N-sec period. And
-               according to the calculation result, ChannelQuality is calculated here
-               to decide if current AP is still doing the job.
-
-               If ChannelQuality is not good, a ROAMing attempt may be tried later.
-       Output:
-               StaCfg.ChannelQuality - 0..100
-
-       IRQL = DISPATCH_LEVEL
-
-       NOTE: This routine decide channle quality based on RX CRC error ratio.
-               Caller should make sure a function call to NICUpdateRawCounters(pAd)
-               is performed right before this routine, so that this routine can decide
-               channel quality based on the most up-to-date information
-       ==========================================================================
- */
-void MlmeCalculateChannelQuality(struct rt_rtmp_adapter *pAd,
-                                struct rt_mac_table_entry *pMacEntry, unsigned long Now32)
-{
-       unsigned long TxOkCnt, TxCnt, TxPER, TxPRR;
-       unsigned long RxCnt, RxPER;
-       u8 NorRssi;
-       char MaxRssi;
-       struct rt_rssi_sample *pRssiSample = NULL;
-       u32 OneSecTxNoRetryOkCount = 0;
-       u32 OneSecTxRetryOkCount = 0;
-       u32 OneSecTxFailCount = 0;
-       u32 OneSecRxOkCnt = 0;
-       u32 OneSecRxFcsErrCnt = 0;
-       unsigned long ChannelQuality = 0;       /* 0..100, Channel Quality Indication for Roaming */
-       unsigned long BeaconLostTime = pAd->StaCfg.BeaconLostTime;
-
-       if (pAd->OpMode == OPMODE_STA) {
-               pRssiSample = &pAd->StaCfg.RssiSample;
-               OneSecTxNoRetryOkCount =
-                   pAd->RalinkCounters.OneSecTxNoRetryOkCount;
-               OneSecTxRetryOkCount = pAd->RalinkCounters.OneSecTxRetryOkCount;
-               OneSecTxFailCount = pAd->RalinkCounters.OneSecTxFailCount;
-               OneSecRxOkCnt = pAd->RalinkCounters.OneSecRxOkCnt;
-               OneSecRxFcsErrCnt = pAd->RalinkCounters.OneSecRxFcsErrCnt;
-       }
-
-       MaxRssi = RTMPMaxRssi(pAd, pRssiSample->LastRssi0,
-                             pRssiSample->LastRssi1, pRssiSample->LastRssi2);
-
-       /* */
-       /* calculate TX packet error ratio and TX retry ratio - if too few TX samples, skip TX related statistics */
-       /* */
-       TxOkCnt = OneSecTxNoRetryOkCount + OneSecTxRetryOkCount;
-       TxCnt = TxOkCnt + OneSecTxFailCount;
-       if (TxCnt < 5) {
-               TxPER = 0;
-               TxPRR = 0;
-       } else {
-               TxPER = (OneSecTxFailCount * 100) / TxCnt;
-               TxPRR = ((TxCnt - OneSecTxNoRetryOkCount) * 100) / TxCnt;
-       }
-
-       /* */
-       /* calculate RX PER - don't take RxPER into consideration if too few sample */
-       /* */
-       RxCnt = OneSecRxOkCnt + OneSecRxFcsErrCnt;
-       if (RxCnt < 5)
-               RxPER = 0;
-       else
-               RxPER = (OneSecRxFcsErrCnt * 100) / RxCnt;
-
-       /* */
-       /* decide ChannelQuality based on: 1)last BEACON received time, 2)last RSSI, 3)TxPER, and 4)RxPER */
-       /* */
-       if ((pAd->OpMode == OPMODE_STA) && INFRA_ON(pAd) && (OneSecTxNoRetryOkCount < 2) &&     /* no heavy traffic */
-           ((pAd->StaCfg.LastBeaconRxTime + BeaconLostTime) < Now32)) {
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("BEACON lost > %ld msec with TxOkCnt=%ld -> CQI=0\n",
-                         BeaconLostTime, TxOkCnt));
-               ChannelQuality = 0;
-       } else {
-               /* Normalize Rssi */
-               if (MaxRssi > -40)
-                       NorRssi = 100;
-               else if (MaxRssi < -90)
-                       NorRssi = 0;
-               else
-                       NorRssi = (MaxRssi + 90) * 2;
-
-               /* ChannelQuality = W1*RSSI + W2*TxPRR + W3*RxPER        (RSSI 0..100), (TxPER 100..0), (RxPER 100..0) */
-               ChannelQuality = (RSSI_WEIGHTING * NorRssi +
-                                 TX_WEIGHTING * (100 - TxPRR) +
-                                 RX_WEIGHTING * (100 - RxPER)) / 100;
-       }
-
-       if (pAd->OpMode == OPMODE_STA)
-               pAd->Mlme.ChannelQuality =
-                   (ChannelQuality > 100) ? 100 : ChannelQuality;
-
-}
-
-/* IRQL = DISPATCH_LEVEL */
-void MlmeSetTxPreamble(struct rt_rtmp_adapter *pAd, u16 TxPreamble)
-{
-       AUTO_RSP_CFG_STRUC csr4;
-
-       /* */
-       /* Always use Long preamble before verifiation short preamble functionality works well. */
-       /* Todo: remove the following line if short preamble functionality works */
-       /* */
-       /*TxPreamble = Rt802_11PreambleLong; */
-
-       RTMP_IO_READ32(pAd, AUTO_RSP_CFG, &csr4.word);
-       if (TxPreamble == Rt802_11PreambleLong) {
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("MlmeSetTxPreamble (= long PREAMBLE)\n"));
-               OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_SHORT_PREAMBLE_INUSED);
-               csr4.field.AutoResponderPreamble = 0;
-       } else {
-               /* NOTE: 1Mbps should always use long preamble */
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("MlmeSetTxPreamble (= short PREAMBLE)\n"));
-               OPSTATUS_SET_FLAG(pAd, fOP_STATUS_SHORT_PREAMBLE_INUSED);
-               csr4.field.AutoResponderPreamble = 1;
-       }
-
-       RTMP_IO_WRITE32(pAd, AUTO_RSP_CFG, csr4.word);
-}
-
-/*
-    ==========================================================================
-    Description:
-        Update basic rate bitmap
-    ==========================================================================
- */
-
-void UpdateBasicRateBitmap(struct rt_rtmp_adapter *pAdapter)
-{
-       int i, j;
-       /* 1  2  5.5, 11,  6,  9, 12, 18, 24, 36, 48,  54 */
-       u8 rate[] = { 2, 4, 11, 22, 12, 18, 24, 36, 48, 72, 96, 108 };
-       u8 *sup_p = pAdapter->CommonCfg.SupRate;
-       u8 *ext_p = pAdapter->CommonCfg.ExtRate;
-       unsigned long bitmap = pAdapter->CommonCfg.BasicRateBitmap;
-
-       /* if A mode, always use fix BasicRateBitMap */
-       /*if (pAdapter->CommonCfg.Channel == PHY_11A) */
-       if (pAdapter->CommonCfg.Channel > 14)
-               pAdapter->CommonCfg.BasicRateBitmap = 0x150;    /* 6, 12, 24M */
-       /* End of if */
-
-       if (pAdapter->CommonCfg.BasicRateBitmap > 4095) {
-               /* (2 ^ MAX_LEN_OF_SUPPORTED_RATES) -1 */
-               return;
-       }
-       /* End of if */
-       for (i = 0; i < MAX_LEN_OF_SUPPORTED_RATES; i++) {
-               sup_p[i] &= 0x7f;
-               ext_p[i] &= 0x7f;
-       }                       /* End of for */
-
-       for (i = 0; i < MAX_LEN_OF_SUPPORTED_RATES; i++) {
-               if (bitmap & (1 << i)) {
-                       for (j = 0; j < MAX_LEN_OF_SUPPORTED_RATES; j++) {
-                               if (sup_p[j] == rate[i])
-                                       sup_p[j] |= 0x80;
-                               /* End of if */
-                       }       /* End of for */
-
-                       for (j = 0; j < MAX_LEN_OF_SUPPORTED_RATES; j++) {
-                               if (ext_p[j] == rate[i])
-                                       ext_p[j] |= 0x80;
-                               /* End of if */
-                       }       /* End of for */
-               }               /* End of if */
-       }                       /* End of for */
-}                              /* End of UpdateBasicRateBitmap */
-
-/* IRQL = PASSIVE_LEVEL */
-/* IRQL = DISPATCH_LEVEL */
-/* bLinkUp is to identify the initial link speed. */
-/* TRUE indicates the rate update at linkup, we should not try to set the rate at 54Mbps. */
-void MlmeUpdateTxRates(struct rt_rtmp_adapter *pAd, IN BOOLEAN bLinkUp, u8 apidx)
-{
-       int i, num;
-       u8 Rate = RATE_6, MaxDesire = RATE_1, MaxSupport = RATE_1;
-       u8 MinSupport = RATE_54;
-       unsigned long BasicRateBitmap = 0;
-       u8 CurrBasicRate = RATE_1;
-       u8 *pSupRate, SupRateLen, *pExtRate, ExtRateLen;
-       PHTTRANSMIT_SETTING pHtPhy = NULL;
-       PHTTRANSMIT_SETTING pMaxHtPhy = NULL;
-       PHTTRANSMIT_SETTING pMinHtPhy = NULL;
-       BOOLEAN *auto_rate_cur_p;
-       u8 HtMcs = MCS_AUTO;
-
-       /* find max desired rate */
-       UpdateBasicRateBitmap(pAd);
-
-       num = 0;
-       auto_rate_cur_p = NULL;
-       for (i = 0; i < MAX_LEN_OF_SUPPORTED_RATES; i++) {
-               switch (pAd->CommonCfg.DesireRate[i] & 0x7f) {
-               case 2:
-                       Rate = RATE_1;
-                       num++;
-                       break;
-               case 4:
-                       Rate = RATE_2;
-                       num++;
-                       break;
-               case 11:
-                       Rate = RATE_5_5;
-                       num++;
-                       break;
-               case 22:
-                       Rate = RATE_11;
-                       num++;
-                       break;
-               case 12:
-                       Rate = RATE_6;
-                       num++;
-                       break;
-               case 18:
-                       Rate = RATE_9;
-                       num++;
-                       break;
-               case 24:
-                       Rate = RATE_12;
-                       num++;
-                       break;
-               case 36:
-                       Rate = RATE_18;
-                       num++;
-                       break;
-               case 48:
-                       Rate = RATE_24;
-                       num++;
-                       break;
-               case 72:
-                       Rate = RATE_36;
-                       num++;
-                       break;
-               case 96:
-                       Rate = RATE_48;
-                       num++;
-                       break;
-               case 108:
-                       Rate = RATE_54;
-                       num++;
-                       break;
-                       /*default: Rate = RATE_1;   break; */
-               }
-               if (MaxDesire < Rate)
-                       MaxDesire = Rate;
-       }
-
-/*=========================================================================== */
-/*=========================================================================== */
-       {
-               pHtPhy = &pAd->StaCfg.HTPhyMode;
-               pMaxHtPhy = &pAd->StaCfg.MaxHTPhyMode;
-               pMinHtPhy = &pAd->StaCfg.MinHTPhyMode;
-
-               auto_rate_cur_p = &pAd->StaCfg.bAutoTxRateSwitch;
-               HtMcs = pAd->StaCfg.DesiredTransmitSetting.field.MCS;
-
-               if ((pAd->StaCfg.BssType == BSS_ADHOC) &&
-                   (pAd->CommonCfg.PhyMode == PHY_11B) &&
-                   (MaxDesire > RATE_11)) {
-                       MaxDesire = RATE_11;
-               }
-       }
-
-       pAd->CommonCfg.MaxDesiredRate = MaxDesire;
-       pMinHtPhy->word = 0;
-       pMaxHtPhy->word = 0;
-       pHtPhy->word = 0;
-
-       /* Auto rate switching is enabled only if more than one DESIRED RATES are */
-       /* specified; otherwise disabled */
-       if (num <= 1) {
-               /*OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_TX_RATE_SWITCH_ENABLED); */
-               /*pAd->CommonCfg.bAutoTxRateSwitch      = FALSE; */
-               *auto_rate_cur_p = FALSE;
-       } else {
-               /*OPSTATUS_SET_FLAG(pAd, fOP_STATUS_TX_RATE_SWITCH_ENABLED); */
-               /*pAd->CommonCfg.bAutoTxRateSwitch      = TRUE; */
-               *auto_rate_cur_p = TRUE;
-       }
-
-       if (HtMcs != MCS_AUTO) {
-               /*OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_TX_RATE_SWITCH_ENABLED); */
-               /*pAd->CommonCfg.bAutoTxRateSwitch      = FALSE; */
-               *auto_rate_cur_p = FALSE;
-       } else {
-               /*OPSTATUS_SET_FLAG(pAd, fOP_STATUS_TX_RATE_SWITCH_ENABLED); */
-               /*pAd->CommonCfg.bAutoTxRateSwitch      = TRUE; */
-               *auto_rate_cur_p = TRUE;
-       }
-
-       if ((ADHOC_ON(pAd) || INFRA_ON(pAd)) && (pAd->OpMode == OPMODE_STA)) {
-               pSupRate = &pAd->StaActive.SupRate[0];
-               pExtRate = &pAd->StaActive.ExtRate[0];
-               SupRateLen = pAd->StaActive.SupRateLen;
-               ExtRateLen = pAd->StaActive.ExtRateLen;
-       } else {
-               pSupRate = &pAd->CommonCfg.SupRate[0];
-               pExtRate = &pAd->CommonCfg.ExtRate[0];
-               SupRateLen = pAd->CommonCfg.SupRateLen;
-               ExtRateLen = pAd->CommonCfg.ExtRateLen;
-       }
-
-       /* find max supported rate */
-       for (i = 0; i < SupRateLen; i++) {
-               switch (pSupRate[i] & 0x7f) {
-               case 2:
-                       Rate = RATE_1;
-                       if (pSupRate[i] & 0x80)
-                               BasicRateBitmap |= 0x0001;
-                       break;
-               case 4:
-                       Rate = RATE_2;
-                       if (pSupRate[i] & 0x80)
-                               BasicRateBitmap |= 0x0002;
-                       break;
-               case 11:
-                       Rate = RATE_5_5;
-                       if (pSupRate[i] & 0x80)
-                               BasicRateBitmap |= 0x0004;
-                       break;
-               case 22:
-                       Rate = RATE_11;
-                       if (pSupRate[i] & 0x80)
-                               BasicRateBitmap |= 0x0008;
-                       break;
-               case 12:
-                       Rate = RATE_6;  /*if (pSupRate[i] & 0x80) */
-                       BasicRateBitmap |= 0x0010;
-                       break;
-               case 18:
-                       Rate = RATE_9;
-                       if (pSupRate[i] & 0x80)
-                               BasicRateBitmap |= 0x0020;
-                       break;
-               case 24:
-                       Rate = RATE_12; /*if (pSupRate[i] & 0x80) */
-                       BasicRateBitmap |= 0x0040;
-                       break;
-               case 36:
-                       Rate = RATE_18;
-                       if (pSupRate[i] & 0x80)
-                               BasicRateBitmap |= 0x0080;
-                       break;
-               case 48:
-                       Rate = RATE_24; /*if (pSupRate[i] & 0x80) */
-                       BasicRateBitmap |= 0x0100;
-                       break;
-               case 72:
-                       Rate = RATE_36;
-                       if (pSupRate[i] & 0x80)
-                               BasicRateBitmap |= 0x0200;
-                       break;
-               case 96:
-                       Rate = RATE_48;
-                       if (pSupRate[i] & 0x80)
-                               BasicRateBitmap |= 0x0400;
-                       break;
-               case 108:
-                       Rate = RATE_54;
-                       if (pSupRate[i] & 0x80)
-                               BasicRateBitmap |= 0x0800;
-                       break;
-               default:
-                       Rate = RATE_1;
-                       break;
-               }
-               if (MaxSupport < Rate)
-                       MaxSupport = Rate;
-
-               if (MinSupport > Rate)
-                       MinSupport = Rate;
-       }
-
-       for (i = 0; i < ExtRateLen; i++) {
-               switch (pExtRate[i] & 0x7f) {
-               case 2:
-                       Rate = RATE_1;
-                       if (pExtRate[i] & 0x80)
-                               BasicRateBitmap |= 0x0001;
-                       break;
-               case 4:
-                       Rate = RATE_2;
-                       if (pExtRate[i] & 0x80)
-                               BasicRateBitmap |= 0x0002;
-                       break;
-               case 11:
-                       Rate = RATE_5_5;
-                       if (pExtRate[i] & 0x80)
-                               BasicRateBitmap |= 0x0004;
-                       break;
-               case 22:
-                       Rate = RATE_11;
-                       if (pExtRate[i] & 0x80)
-                               BasicRateBitmap |= 0x0008;
-                       break;
-               case 12:
-                       Rate = RATE_6;  /*if (pExtRate[i] & 0x80) */
-                       BasicRateBitmap |= 0x0010;
-                       break;
-               case 18:
-                       Rate = RATE_9;
-                       if (pExtRate[i] & 0x80)
-                               BasicRateBitmap |= 0x0020;
-                       break;
-               case 24:
-                       Rate = RATE_12; /*if (pExtRate[i] & 0x80) */
-                       BasicRateBitmap |= 0x0040;
-                       break;
-               case 36:
-                       Rate = RATE_18;
-                       if (pExtRate[i] & 0x80)
-                               BasicRateBitmap |= 0x0080;
-                       break;
-               case 48:
-                       Rate = RATE_24; /*if (pExtRate[i] & 0x80) */
-                       BasicRateBitmap |= 0x0100;
-                       break;
-               case 72:
-                       Rate = RATE_36;
-                       if (pExtRate[i] & 0x80)
-                               BasicRateBitmap |= 0x0200;
-                       break;
-               case 96:
-                       Rate = RATE_48;
-                       if (pExtRate[i] & 0x80)
-                               BasicRateBitmap |= 0x0400;
-                       break;
-               case 108:
-                       Rate = RATE_54;
-                       if (pExtRate[i] & 0x80)
-                               BasicRateBitmap |= 0x0800;
-                       break;
-               default:
-                       Rate = RATE_1;
-                       break;
-               }
-               if (MaxSupport < Rate)
-                       MaxSupport = Rate;
-
-               if (MinSupport > Rate)
-                       MinSupport = Rate;
-       }
-
-       RTMP_IO_WRITE32(pAd, LEGACY_BASIC_RATE, BasicRateBitmap);
-
-       /* bug fix */
-       /* pAd->CommonCfg.BasicRateBitmap = BasicRateBitmap; */
-
-       /* calculate the exptected ACK rate for each TX rate. This info is used to caculate */
-       /* the DURATION field of outgoing uniicast DATA/MGMT frame */
-       for (i = 0; i < MAX_LEN_OF_SUPPORTED_RATES; i++) {
-               if (BasicRateBitmap & (0x01 << i))
-                       CurrBasicRate = (u8)i;
-               pAd->CommonCfg.ExpectedACKRate[i] = CurrBasicRate;
-       }
-
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("MlmeUpdateTxRates[MaxSupport = %d] = MaxDesire %d Mbps\n",
-                 RateIdToMbps[MaxSupport], RateIdToMbps[MaxDesire]));
-       /* max tx rate = min {max desire rate, max supported rate} */
-       if (MaxSupport < MaxDesire)
-               pAd->CommonCfg.MaxTxRate = MaxSupport;
-       else
-               pAd->CommonCfg.MaxTxRate = MaxDesire;
-
-       pAd->CommonCfg.MinTxRate = MinSupport;
-       /* 2003-07-31 john - 2500 doesn't have good sensitivity at high OFDM rates. to increase the success */
-       /* ratio of initial DHCP packet exchange, TX rate starts from a lower rate depending */
-       /* on average RSSI */
-       /*       1. RSSI >= -70db, start at 54 Mbps (short distance) */
-       /*       2. -70 > RSSI >= -75, start at 24 Mbps (mid distance) */
-       /*       3. -75 > RSSI, start at 11 Mbps (long distance) */
-       if (*auto_rate_cur_p) {
-               short dbm = 0;
-
-               dbm = pAd->StaCfg.RssiSample.AvgRssi0 - pAd->BbpRssiToDbmDelta;
-
-               if (bLinkUp == TRUE)
-                       pAd->CommonCfg.TxRate = RATE_24;
-               else
-                       pAd->CommonCfg.TxRate = pAd->CommonCfg.MaxTxRate;
-
-               if (dbm < -75)
-                       pAd->CommonCfg.TxRate = RATE_11;
-               else if (dbm < -70)
-                       pAd->CommonCfg.TxRate = RATE_24;
-
-               /* should never exceed MaxTxRate (consider 11B-only mode) */
-               if (pAd->CommonCfg.TxRate > pAd->CommonCfg.MaxTxRate)
-                       pAd->CommonCfg.TxRate = pAd->CommonCfg.MaxTxRate;
-
-               pAd->CommonCfg.TxRateIndex = 0;
-       } else {
-               pAd->CommonCfg.TxRate = pAd->CommonCfg.MaxTxRate;
-               pHtPhy->field.MCS =
-                   (pAd->CommonCfg.MaxTxRate >
-                    3) ? (pAd->CommonCfg.MaxTxRate -
-                          4) : pAd->CommonCfg.MaxTxRate;
-               pHtPhy->field.MODE =
-                   (pAd->CommonCfg.MaxTxRate > 3) ? MODE_OFDM : MODE_CCK;
-
-               pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.STBC =
-                   pHtPhy->field.STBC;
-               pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.ShortGI =
-                   pHtPhy->field.ShortGI;
-               pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MCS =
-                   pHtPhy->field.MCS;
-               pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE =
-                   pHtPhy->field.MODE;
-       }
-
-       if (pAd->CommonCfg.TxRate <= RATE_11) {
-               pMaxHtPhy->field.MODE = MODE_CCK;
-               pMaxHtPhy->field.MCS = pAd->CommonCfg.TxRate;
-               pMinHtPhy->field.MCS = pAd->CommonCfg.MinTxRate;
-       } else {
-               pMaxHtPhy->field.MODE = MODE_OFDM;
-               pMaxHtPhy->field.MCS = OfdmRateToRxwiMCS[pAd->CommonCfg.TxRate];
-               if (pAd->CommonCfg.MinTxRate >= RATE_6
-                   && (pAd->CommonCfg.MinTxRate <= RATE_54)) {
-                       pMinHtPhy->field.MCS =
-                           OfdmRateToRxwiMCS[pAd->CommonCfg.MinTxRate];
-               } else {
-                       pMinHtPhy->field.MCS = pAd->CommonCfg.MinTxRate;
-               }
-       }
-
-       pHtPhy->word = (pMaxHtPhy->word);
-       if (bLinkUp && (pAd->OpMode == OPMODE_STA)) {
-               pAd->MacTab.Content[BSSID_WCID].HTPhyMode.word = pHtPhy->word;
-               pAd->MacTab.Content[BSSID_WCID].MaxHTPhyMode.word =
-                   pMaxHtPhy->word;
-               pAd->MacTab.Content[BSSID_WCID].MinHTPhyMode.word =
-                   pMinHtPhy->word;
-       } else {
-               switch (pAd->CommonCfg.PhyMode) {
-               case PHY_11BG_MIXED:
-               case PHY_11B:
-               case PHY_11BGN_MIXED:
-                       pAd->CommonCfg.MlmeRate = RATE_1;
-                       pAd->CommonCfg.MlmeTransmit.field.MODE = MODE_CCK;
-                       pAd->CommonCfg.MlmeTransmit.field.MCS = RATE_1;
-
-/*#ifdef        WIFI_TEST */
-                       pAd->CommonCfg.RtsRate = RATE_11;
-/*#else */
-/*                              pAd->CommonCfg.RtsRate = RATE_1; */
-/*#endif */
-                       break;
-               case PHY_11G:
-               case PHY_11A:
-               case PHY_11AGN_MIXED:
-               case PHY_11GN_MIXED:
-               case PHY_11N_2_4G:
-               case PHY_11AN_MIXED:
-               case PHY_11N_5G:
-                       pAd->CommonCfg.MlmeRate = RATE_6;
-                       pAd->CommonCfg.RtsRate = RATE_6;
-                       pAd->CommonCfg.MlmeTransmit.field.MODE = MODE_OFDM;
-                       pAd->CommonCfg.MlmeTransmit.field.MCS =
-                           OfdmRateToRxwiMCS[pAd->CommonCfg.MlmeRate];
-                       break;
-               case PHY_11ABG_MIXED:
-               case PHY_11ABGN_MIXED:
-                       if (pAd->CommonCfg.Channel <= 14) {
-                               pAd->CommonCfg.MlmeRate = RATE_1;
-                               pAd->CommonCfg.RtsRate = RATE_1;
-                               pAd->CommonCfg.MlmeTransmit.field.MODE =
-                                   MODE_CCK;
-                               pAd->CommonCfg.MlmeTransmit.field.MCS = RATE_1;
-                       } else {
-                               pAd->CommonCfg.MlmeRate = RATE_6;
-                               pAd->CommonCfg.RtsRate = RATE_6;
-                               pAd->CommonCfg.MlmeTransmit.field.MODE =
-                                   MODE_OFDM;
-                               pAd->CommonCfg.MlmeTransmit.field.MCS =
-                                   OfdmRateToRxwiMCS[pAd->CommonCfg.MlmeRate];
-                       }
-                       break;
-               default:        /* error */
-                       pAd->CommonCfg.MlmeRate = RATE_6;
-                       pAd->CommonCfg.MlmeTransmit.field.MODE = MODE_OFDM;
-                       pAd->CommonCfg.MlmeTransmit.field.MCS =
-                           OfdmRateToRxwiMCS[pAd->CommonCfg.MlmeRate];
-                       pAd->CommonCfg.RtsRate = RATE_1;
-                       break;
-               }
-               /* */
-               /* Keep Basic Mlme Rate. */
-               /* */
-               pAd->MacTab.Content[MCAST_WCID].HTPhyMode.word =
-                   pAd->CommonCfg.MlmeTransmit.word;
-               if (pAd->CommonCfg.MlmeTransmit.field.MODE == MODE_OFDM)
-                       pAd->MacTab.Content[MCAST_WCID].HTPhyMode.field.MCS =
-                           OfdmRateToRxwiMCS[RATE_24];
-               else
-                       pAd->MacTab.Content[MCAST_WCID].HTPhyMode.field.MCS =
-                           RATE_1;
-               pAd->CommonCfg.BasicMlmeRate = pAd->CommonCfg.MlmeRate;
-       }
-
-       DBGPRINT(RT_DEBUG_TRACE,
-                (" MlmeUpdateTxRates (MaxDesire=%d, MaxSupport=%d, MaxTxRate=%d, MinRate=%d, Rate Switching =%d)\n",
-                 RateIdToMbps[MaxDesire], RateIdToMbps[MaxSupport],
-                 RateIdToMbps[pAd->CommonCfg.MaxTxRate],
-                 RateIdToMbps[pAd->CommonCfg.MinTxRate],
-                 /*OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_TX_RATE_SWITCH_ENABLED) */
-                 *auto_rate_cur_p));
-       DBGPRINT(RT_DEBUG_TRACE,
-                (" MlmeUpdateTxRates (TxRate=%d, RtsRate=%d, BasicRateBitmap=0x%04lx)\n",
-                 RateIdToMbps[pAd->CommonCfg.TxRate],
-                 RateIdToMbps[pAd->CommonCfg.RtsRate], BasicRateBitmap));
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("MlmeUpdateTxRates (MlmeTransmit=0x%x, MinHTPhyMode=%x, MaxHTPhyMode=0x%x, HTPhyMode=0x%x)\n",
-                 pAd->CommonCfg.MlmeTransmit.word,
-                 pAd->MacTab.Content[BSSID_WCID].MinHTPhyMode.word,
-                 pAd->MacTab.Content[BSSID_WCID].MaxHTPhyMode.word,
-                 pAd->MacTab.Content[BSSID_WCID].HTPhyMode.word));
-}
-
-/*
-       ==========================================================================
-       Description:
-               This function update HT Rate setting.
-               Input Wcid value is valid for 2 case :
-               1. it's used for Station in infra mode that copy AP rate to Mactable.
-               2. OR Station   in adhoc mode to copy peer's HT rate to Mactable.
-
- IRQL = DISPATCH_LEVEL
-
-       ==========================================================================
- */
-void MlmeUpdateHtTxRates(struct rt_rtmp_adapter *pAd, u8 apidx)
-{
-       u8 StbcMcs;             /*j, StbcMcs, bitmask; */
-       char i;                 /* 3*3 */
-       struct rt_ht_capability *pRtHtCap = NULL;
-       struct rt_ht_phy_info *pActiveHtPhy = NULL;
-       unsigned long BasicMCS;
-       u8 j, bitmask;
-       struct rt_ht_phy_info *pDesireHtPhy = NULL;
-       PHTTRANSMIT_SETTING pHtPhy = NULL;
-       PHTTRANSMIT_SETTING pMaxHtPhy = NULL;
-       PHTTRANSMIT_SETTING pMinHtPhy = NULL;
-       BOOLEAN *auto_rate_cur_p;
-
-       DBGPRINT(RT_DEBUG_TRACE, ("MlmeUpdateHtTxRates===> \n"));
-
-       auto_rate_cur_p = NULL;
-
-       {
-               pDesireHtPhy = &pAd->StaCfg.DesiredHtPhyInfo;
-               pActiveHtPhy = &pAd->StaCfg.DesiredHtPhyInfo;
-               pHtPhy = &pAd->StaCfg.HTPhyMode;
-               pMaxHtPhy = &pAd->StaCfg.MaxHTPhyMode;
-               pMinHtPhy = &pAd->StaCfg.MinHTPhyMode;
-
-               auto_rate_cur_p = &pAd->StaCfg.bAutoTxRateSwitch;
-       }
-
-       if ((ADHOC_ON(pAd) || INFRA_ON(pAd)) && (pAd->OpMode == OPMODE_STA)) {
-               if (pAd->StaActive.SupportedPhyInfo.bHtEnable == FALSE)
-                       return;
-
-               pRtHtCap = &pAd->StaActive.SupportedHtPhy;
-               pActiveHtPhy = &pAd->StaActive.SupportedPhyInfo;
-               StbcMcs = (u8)pAd->MlmeAux.AddHtInfo.AddHtInfo3.StbcMcs;
-               BasicMCS =
-                   pAd->MlmeAux.AddHtInfo.MCSSet[0] +
-                   (pAd->MlmeAux.AddHtInfo.MCSSet[1] << 8) + (StbcMcs << 16);
-               if ((pAd->CommonCfg.DesiredHtPhy.TxSTBC) && (pRtHtCap->RxSTBC)
-                   && (pAd->Antenna.field.TxPath == 2))
-                       pMaxHtPhy->field.STBC = STBC_USE;
-               else
-                       pMaxHtPhy->field.STBC = STBC_NONE;
-       } else {
-               if (pDesireHtPhy->bHtEnable == FALSE)
-                       return;
-
-               pRtHtCap = &pAd->CommonCfg.DesiredHtPhy;
-               StbcMcs = (u8)pAd->CommonCfg.AddHTInfo.AddHtInfo3.StbcMcs;
-               BasicMCS =
-                   pAd->CommonCfg.AddHTInfo.MCSSet[0] +
-                   (pAd->CommonCfg.AddHTInfo.MCSSet[1] << 8) + (StbcMcs << 16);
-               if ((pAd->CommonCfg.DesiredHtPhy.TxSTBC) && (pRtHtCap->RxSTBC)
-                   && (pAd->Antenna.field.TxPath == 2))
-                       pMaxHtPhy->field.STBC = STBC_USE;
-               else
-                       pMaxHtPhy->field.STBC = STBC_NONE;
-       }
-
-       /* Decide MAX ht rate. */
-       if ((pRtHtCap->GF) && (pAd->CommonCfg.DesiredHtPhy.GF))
-               pMaxHtPhy->field.MODE = MODE_HTGREENFIELD;
-       else
-               pMaxHtPhy->field.MODE = MODE_HTMIX;
-
-       if ((pAd->CommonCfg.DesiredHtPhy.ChannelWidth)
-           && (pRtHtCap->ChannelWidth))
-               pMaxHtPhy->field.BW = BW_40;
-       else
-               pMaxHtPhy->field.BW = BW_20;
-
-       if (pMaxHtPhy->field.BW == BW_20)
-               pMaxHtPhy->field.ShortGI =
-                   (pAd->CommonCfg.DesiredHtPhy.ShortGIfor20 & pRtHtCap->
-                    ShortGIfor20);
-       else
-               pMaxHtPhy->field.ShortGI =
-                   (pAd->CommonCfg.DesiredHtPhy.ShortGIfor40 & pRtHtCap->
-                    ShortGIfor40);
-
-       if (pDesireHtPhy->MCSSet[4] != 0) {
-               pMaxHtPhy->field.MCS = 32;
-       }
-
-       for (i = 23; i >= 0; i--)       /* 3*3 */
-       {
-               j = i / 8;
-               bitmask = (1 << (i - (j * 8)));
-
-               if ((pActiveHtPhy->MCSSet[j] & bitmask)
-                   && (pDesireHtPhy->MCSSet[j] & bitmask)) {
-                       pMaxHtPhy->field.MCS = i;
-                       break;
-               }
-
-               if (i == 0)
-                       break;
-       }
-
-       /* Copy MIN ht rate.  rt2860??? */
-       pMinHtPhy->field.BW = BW_20;
-       pMinHtPhy->field.MCS = 0;
-       pMinHtPhy->field.STBC = 0;
-       pMinHtPhy->field.ShortGI = 0;
-       /*If STA assigns fixed rate. update to fixed here. */
-       if ((pAd->OpMode == OPMODE_STA) && (pDesireHtPhy->MCSSet[0] != 0xff)) {
-               if (pDesireHtPhy->MCSSet[4] != 0) {
-                       pMaxHtPhy->field.MCS = 32;
-                       pMinHtPhy->field.MCS = 32;
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("MlmeUpdateHtTxRates<=== Use Fixed MCS = %d\n",
-                                 pMinHtPhy->field.MCS));
-               }
-
-               for (i = 23; (char)i >= 0; i--) /* 3*3 */
-               {
-                       j = i / 8;
-                       bitmask = (1 << (i - (j * 8)));
-                       if ((pDesireHtPhy->MCSSet[j] & bitmask)
-                           && (pActiveHtPhy->MCSSet[j] & bitmask)) {
-                               pMaxHtPhy->field.MCS = i;
-                               pMinHtPhy->field.MCS = i;
-                               break;
-                       }
-                       if (i == 0)
-                               break;
-               }
-       }
-
-       /* Decide ht rate */
-       pHtPhy->field.STBC = pMaxHtPhy->field.STBC;
-       pHtPhy->field.BW = pMaxHtPhy->field.BW;
-       pHtPhy->field.MODE = pMaxHtPhy->field.MODE;
-       pHtPhy->field.MCS = pMaxHtPhy->field.MCS;
-       pHtPhy->field.ShortGI = pMaxHtPhy->field.ShortGI;
-
-       /* use default now. rt2860 */
-       if (pDesireHtPhy->MCSSet[0] != 0xff)
-               *auto_rate_cur_p = FALSE;
-       else
-               *auto_rate_cur_p = TRUE;
-
-       DBGPRINT(RT_DEBUG_TRACE,
-                (" MlmeUpdateHtTxRates<---.AMsduSize = %d  \n",
-                 pAd->CommonCfg.DesiredHtPhy.AmsduSize));
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("TX: MCS[0] = %x (choose %d), BW = %d, ShortGI = %d, MODE = %d,  \n",
-                 pActiveHtPhy->MCSSet[0], pHtPhy->field.MCS, pHtPhy->field.BW,
-                 pHtPhy->field.ShortGI, pHtPhy->field.MODE));
-       DBGPRINT(RT_DEBUG_TRACE, ("MlmeUpdateHtTxRates<=== \n"));
-}
-
-void BATableInit(struct rt_rtmp_adapter *pAd, struct rt_ba_table *Tab)
-{
-       int i;
-
-       Tab->numAsOriginator = 0;
-       Tab->numAsRecipient = 0;
-       Tab->numDoneOriginator = 0;
-       NdisAllocateSpinLock(&pAd->BATabLock);
-       for (i = 0; i < MAX_LEN_OF_BA_REC_TABLE; i++) {
-               Tab->BARecEntry[i].REC_BA_Status = Recipient_NONE;
-               NdisAllocateSpinLock(&(Tab->BARecEntry[i].RxReRingLock));
-       }
-       for (i = 0; i < MAX_LEN_OF_BA_ORI_TABLE; i++) {
-               Tab->BAOriEntry[i].ORI_BA_Status = Originator_NONE;
-       }
-}
-
-/* IRQL = DISPATCH_LEVEL */
-void MlmeRadioOff(struct rt_rtmp_adapter *pAd)
-{
-       RTMP_MLME_RADIO_OFF(pAd);
-}
-
-/* IRQL = DISPATCH_LEVEL */
-void MlmeRadioOn(struct rt_rtmp_adapter *pAd)
-{
-       RTMP_MLME_RADIO_ON(pAd);
-}
-
-/* =========================================================================================== */
-/* bss_table.c */
-/* =========================================================================================== */
-
-/*! \brief initialize BSS table
- *     \param p_tab pointer to the table
- *     \return none
- *     \pre
- *     \post
-
- IRQL = PASSIVE_LEVEL
- IRQL = DISPATCH_LEVEL
-
- */
-void BssTableInit(struct rt_bss_table *Tab)
-{
-       int i;
-
-       Tab->BssNr = 0;
-       Tab->BssOverlapNr = 0;
-       for (i = 0; i < MAX_LEN_OF_BSS_TABLE; i++) {
-               NdisZeroMemory(&Tab->BssEntry[i], sizeof(struct rt_bss_entry));
-               Tab->BssEntry[i].Rssi = -127;   /* initial the rssi as a minimum value */
-       }
-}
-
-/*! \brief search the BSS table by SSID
- *     \param p_tab pointer to the bss table
- *     \param ssid SSID string
- *     \return index of the table, BSS_NOT_FOUND if not in the table
- *     \pre
- *     \post
- *     \note search by sequential search
-
- IRQL = DISPATCH_LEVEL
-
- */
-unsigned long BssTableSearch(struct rt_bss_table *Tab, u8 *pBssid, u8 Channel)
-{
-       u8 i;
-
-       for (i = 0; i < Tab->BssNr; i++) {
-               /* */
-               /* Some AP that support A/B/G mode that may used the same BSSID on 11A and 11B/G. */
-               /* We should distinguish this case. */
-               /* */
-               if ((((Tab->BssEntry[i].Channel <= 14) && (Channel <= 14)) ||
-                    ((Tab->BssEntry[i].Channel > 14) && (Channel > 14))) &&
-                   MAC_ADDR_EQUAL(Tab->BssEntry[i].Bssid, pBssid)) {
-                       return i;
-               }
-       }
-       return (unsigned long)BSS_NOT_FOUND;
-}
-
-unsigned long BssSsidTableSearch(struct rt_bss_table *Tab,
-                        u8 *pBssid,
-                        u8 *pSsid, u8 SsidLen, u8 Channel)
-{
-       u8 i;
-
-       for (i = 0; i < Tab->BssNr; i++) {
-               /* */
-               /* Some AP that support A/B/G mode that may used the same BSSID on 11A and 11B/G. */
-               /* We should distinguish this case. */
-               /* */
-               if ((((Tab->BssEntry[i].Channel <= 14) && (Channel <= 14)) ||
-                    ((Tab->BssEntry[i].Channel > 14) && (Channel > 14))) &&
-                   MAC_ADDR_EQUAL(Tab->BssEntry[i].Bssid, pBssid) &&
-                   SSID_EQUAL(pSsid, SsidLen, Tab->BssEntry[i].Ssid,
-                              Tab->BssEntry[i].SsidLen)) {
-                       return i;
-               }
-       }
-       return (unsigned long)BSS_NOT_FOUND;
-}
-
-unsigned long BssTableSearchWithSSID(struct rt_bss_table *Tab,
-                            u8 *Bssid,
-                            u8 *pSsid,
-                            u8 SsidLen, u8 Channel)
-{
-       u8 i;
-
-       for (i = 0; i < Tab->BssNr; i++) {
-               if ((((Tab->BssEntry[i].Channel <= 14) && (Channel <= 14)) ||
-                    ((Tab->BssEntry[i].Channel > 14) && (Channel > 14))) &&
-                   MAC_ADDR_EQUAL(&(Tab->BssEntry[i].Bssid), Bssid) &&
-                   (SSID_EQUAL
-                    (pSsid, SsidLen, Tab->BssEntry[i].Ssid,
-                     Tab->BssEntry[i].SsidLen)
-                    || (NdisEqualMemory(pSsid, ZeroSsid, SsidLen))
-                    ||
-                    (NdisEqualMemory
-                     (Tab->BssEntry[i].Ssid, ZeroSsid,
-                      Tab->BssEntry[i].SsidLen)))) {
-                       return i;
-               }
-       }
-       return (unsigned long)BSS_NOT_FOUND;
-}
-
-unsigned long BssSsidTableSearchBySSID(struct rt_bss_table *Tab,
-                              u8 *pSsid, u8 SsidLen)
-{
-       u8 i;
-
-       for (i = 0; i < Tab->BssNr; i++) {
-               if (SSID_EQUAL
-                   (pSsid, SsidLen, Tab->BssEntry[i].Ssid,
-                    Tab->BssEntry[i].SsidLen)) {
-                       return i;
-               }
-       }
-       return (unsigned long)BSS_NOT_FOUND;
-}
-
-/* IRQL = DISPATCH_LEVEL */
-void BssTableDeleteEntry(struct rt_bss_table *Tab,
-                        u8 *pBssid, u8 Channel)
-{
-       u8 i, j;
-
-       for (i = 0; i < Tab->BssNr; i++) {
-               if ((Tab->BssEntry[i].Channel == Channel) &&
-                   (MAC_ADDR_EQUAL(Tab->BssEntry[i].Bssid, pBssid))) {
-                       for (j = i; j < Tab->BssNr - 1; j++) {
-                               NdisMoveMemory(&(Tab->BssEntry[j]),
-                                              &(Tab->BssEntry[j + 1]),
-                                              sizeof(struct rt_bss_entry));
-                       }
-                       NdisZeroMemory(&(Tab->BssEntry[Tab->BssNr - 1]),
-                                      sizeof(struct rt_bss_entry));
-                       Tab->BssNr -= 1;
-                       return;
-               }
-       }
-}
-
-/*
-       ========================================================================
-       Routine Description:
-               Delete the Originator Entry in BAtable. Or decrease numAs Originator by 1 if needed.
-
-       Arguments:
-       // IRQL = DISPATCH_LEVEL
-       ========================================================================
-*/
-void BATableDeleteORIEntry(struct rt_rtmp_adapter *pAd,
-                          struct rt_ba_ori_entry *pBAORIEntry)
-{
-
-       if (pBAORIEntry->ORI_BA_Status != Originator_NONE) {
-               NdisAcquireSpinLock(&pAd->BATabLock);
-               if (pBAORIEntry->ORI_BA_Status == Originator_Done) {
-                       pAd->BATable.numAsOriginator -= 1;
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("BATableDeleteORIEntry numAsOriginator= %ld\n",
-                                 pAd->BATable.numAsRecipient));
-                       /* Erase Bitmap flag. */
-               }
-               pAd->MacTab.Content[pBAORIEntry->Wcid].TXBAbitmap &= (~(1 << (pBAORIEntry->TID)));      /* If STA mode,  erase flag here */
-               pAd->MacTab.Content[pBAORIEntry->Wcid].BAOriWcidArray[pBAORIEntry->TID] = 0;    /* If STA mode,  erase flag here */
-               pBAORIEntry->ORI_BA_Status = Originator_NONE;
-               pBAORIEntry->Token = 1;
-               /* Not clear Sequence here. */
-               NdisReleaseSpinLock(&pAd->BATabLock);
-       }
-}
-
-/*! \brief
- *     \param
- *     \return
- *     \pre
- *     \post
-
- IRQL = DISPATCH_LEVEL
-
- */
-void BssEntrySet(struct rt_rtmp_adapter *pAd, struct rt_bss_entry *pBss, u8 *pBssid, char Ssid[], u8 SsidLen, u8 BssType, u16 BeaconPeriod, struct rt_cf_parm * pCfParm, u16 AtimWin, u16 CapabilityInfo, u8 SupRate[], u8 SupRateLen, u8 ExtRate[], u8 ExtRateLen, struct rt_ht_capability_ie * pHtCapability, struct rt_add_ht_info_ie * pAddHtInfo, /* AP might use this additional ht info IE */
-                u8 HtCapabilityLen,
-                u8 AddHtInfoLen,
-                u8 NewExtChanOffset,
-                u8 Channel,
-                char Rssi,
-                IN LARGE_INTEGER TimeStamp,
-                u8 CkipFlag,
-                struct rt_edca_parm *pEdcaParm,
-                struct rt_qos_capability_parm *pQosCapability,
-                struct rt_qbss_load_parm *pQbssLoad,
-                u16 LengthVIE, struct rt_ndis_802_11_variable_ies *pVIE)
-{
-       COPY_MAC_ADDR(pBss->Bssid, pBssid);
-       /* Default Hidden SSID to be TRUE, it will be turned to FALSE after coping SSID */
-       pBss->Hidden = 1;
-       if (SsidLen > 0) {
-               /* For hidden SSID AP, it might send beacon with SSID len equal to 0 */
-               /* Or send beacon /probe response with SSID len matching real SSID length, */
-               /* but SSID is all zero. such as "00-00-00-00" with length 4. */
-               /* We have to prevent this case overwrite correct table */
-               if (NdisEqualMemory(Ssid, ZeroSsid, SsidLen) == 0) {
-                       NdisZeroMemory(pBss->Ssid, MAX_LEN_OF_SSID);
-                       NdisMoveMemory(pBss->Ssid, Ssid, SsidLen);
-                       pBss->SsidLen = SsidLen;
-                       pBss->Hidden = 0;
-               }
-       } else
-               pBss->SsidLen = 0;
-       pBss->BssType = BssType;
-       pBss->BeaconPeriod = BeaconPeriod;
-       if (BssType == BSS_INFRA) {
-               if (pCfParm->bValid) {
-                       pBss->CfpCount = pCfParm->CfpCount;
-                       pBss->CfpPeriod = pCfParm->CfpPeriod;
-                       pBss->CfpMaxDuration = pCfParm->CfpMaxDuration;
-                       pBss->CfpDurRemaining = pCfParm->CfpDurRemaining;
-               }
-       } else {
-               pBss->AtimWin = AtimWin;
-       }
-
-       pBss->CapabilityInfo = CapabilityInfo;
-       /* The privacy bit indicate security is ON, it maight be WEP, TKIP or AES */
-       /* Combine with AuthMode, they will decide the connection methods. */
-       pBss->Privacy = CAP_IS_PRIVACY_ON(pBss->CapabilityInfo);
-       ASSERT(SupRateLen <= MAX_LEN_OF_SUPPORTED_RATES);
-       if (SupRateLen <= MAX_LEN_OF_SUPPORTED_RATES)
-               NdisMoveMemory(pBss->SupRate, SupRate, SupRateLen);
-       else
-               NdisMoveMemory(pBss->SupRate, SupRate,
-                              MAX_LEN_OF_SUPPORTED_RATES);
-       pBss->SupRateLen = SupRateLen;
-       ASSERT(ExtRateLen <= MAX_LEN_OF_SUPPORTED_RATES);
-       NdisMoveMemory(pBss->ExtRate, ExtRate, ExtRateLen);
-       pBss->NewExtChanOffset = NewExtChanOffset;
-       pBss->ExtRateLen = ExtRateLen;
-       pBss->Channel = Channel;
-       pBss->CentralChannel = Channel;
-       pBss->Rssi = Rssi;
-       /* Update CkipFlag. if not exists, the value is 0x0 */
-       pBss->CkipFlag = CkipFlag;
-
-       /* New for microsoft Fixed IEs */
-       NdisMoveMemory(pBss->FixIEs.Timestamp, &TimeStamp, 8);
-       pBss->FixIEs.BeaconInterval = BeaconPeriod;
-       pBss->FixIEs.Capabilities = CapabilityInfo;
-
-       /* New for microsoft Variable IEs */
-       if (LengthVIE != 0) {
-               pBss->VarIELen = LengthVIE;
-               NdisMoveMemory(pBss->VarIEs, pVIE, pBss->VarIELen);
-       } else {
-               pBss->VarIELen = 0;
-       }
-
-       pBss->AddHtInfoLen = 0;
-       pBss->HtCapabilityLen = 0;
-       if (HtCapabilityLen > 0) {
-               pBss->HtCapabilityLen = HtCapabilityLen;
-               NdisMoveMemory(&pBss->HtCapability, pHtCapability,
-                              HtCapabilityLen);
-               if (AddHtInfoLen > 0) {
-                       pBss->AddHtInfoLen = AddHtInfoLen;
-                       NdisMoveMemory(&pBss->AddHtInfo, pAddHtInfo,
-                                      AddHtInfoLen);
-
-                       if ((pAddHtInfo->ControlChan > 2)
-                           && (pAddHtInfo->AddHtInfo.ExtChanOffset ==
-                               EXTCHA_BELOW)
-                           && (pHtCapability->HtCapInfo.ChannelWidth ==
-                               BW_40)) {
-                               pBss->CentralChannel =
-                                   pAddHtInfo->ControlChan - 2;
-                       } else
-                           if ((pAddHtInfo->AddHtInfo.ExtChanOffset ==
-                                EXTCHA_ABOVE)
-                               && (pHtCapability->HtCapInfo.ChannelWidth ==
-                                   BW_40)) {
-                               pBss->CentralChannel =
-                                   pAddHtInfo->ControlChan + 2;
-                       }
-               }
-       }
-
-       BssCipherParse(pBss);
-
-       /* new for QOS */
-       if (pEdcaParm)
-               NdisMoveMemory(&pBss->EdcaParm, pEdcaParm, sizeof(struct rt_edca_parm));
-       else
-               pBss->EdcaParm.bValid = FALSE;
-       if (pQosCapability)
-               NdisMoveMemory(&pBss->QosCapability, pQosCapability,
-                              sizeof(struct rt_qos_capability_parm));
-       else
-               pBss->QosCapability.bValid = FALSE;
-       if (pQbssLoad)
-               NdisMoveMemory(&pBss->QbssLoad, pQbssLoad,
-                              sizeof(struct rt_qbss_load_parm));
-       else
-               pBss->QbssLoad.bValid = FALSE;
-
-       {
-               struct rt_eid * pEid;
-               u16 Length = 0;
-
-               NdisZeroMemory(&pBss->WpaIE.IE[0], MAX_CUSTOM_LEN);
-               NdisZeroMemory(&pBss->RsnIE.IE[0], MAX_CUSTOM_LEN);
-               pEid = (struct rt_eid *) pVIE;
-               while ((Length + 2 + (u16)pEid->Len) <= LengthVIE) {
-                       switch (pEid->Eid) {
-                       case IE_WPA:
-                               if (NdisEqualMemory(pEid->Octet, WPA_OUI, 4)) {
-                                       if ((pEid->Len + 2) > MAX_CUSTOM_LEN) {
-                                               pBss->WpaIE.IELen = 0;
-                                               break;
-                                       }
-                                       pBss->WpaIE.IELen = pEid->Len + 2;
-                                       NdisMoveMemory(pBss->WpaIE.IE, pEid,
-                                                      pBss->WpaIE.IELen);
-                               }
-                               break;
-                       case IE_RSN:
-                               if (NdisEqualMemory
-                                   (pEid->Octet + 2, RSN_OUI, 3)) {
-                                       if ((pEid->Len + 2) > MAX_CUSTOM_LEN) {
-                                               pBss->RsnIE.IELen = 0;
-                                               break;
-                                       }
-                                       pBss->RsnIE.IELen = pEid->Len + 2;
-                                       NdisMoveMemory(pBss->RsnIE.IE, pEid,
-                                                      pBss->RsnIE.IELen);
-                               }
-                               break;
-                       }
-                       Length = Length + 2 + (u16)pEid->Len;   /* Eid[1] + Len[1]+ content[Len] */
-                       pEid = (struct rt_eid *) ((u8 *) pEid + 2 + pEid->Len);
-               }
-       }
-}
-
-/*!
- *     \brief insert an entry into the bss table
- *     \param p_tab The BSS table
- *     \param Bssid BSSID
- *     \param ssid SSID
- *     \param ssid_len Length of SSID
- *     \param bss_type
- *     \param beacon_period
- *     \param timestamp
- *     \param p_cf
- *     \param atim_win
- *     \param cap
- *     \param rates
- *     \param rates_len
- *     \param channel_idx
- *     \return none
- *     \pre
- *     \post
- *     \note If SSID is identical, the old entry will be replaced by the new one
-
- IRQL = DISPATCH_LEVEL
-
- */
-unsigned long BssTableSetEntry(struct rt_rtmp_adapter *pAd, struct rt_bss_table *Tab, u8 *pBssid, char Ssid[], u8 SsidLen, u8 BssType, u16 BeaconPeriod, struct rt_cf_parm * CfParm, u16 AtimWin, u16 CapabilityInfo, u8 SupRate[], u8 SupRateLen, u8 ExtRate[], u8 ExtRateLen, struct rt_ht_capability_ie * pHtCapability, struct rt_add_ht_info_ie * pAddHtInfo,     /* AP might use this additional ht info IE */
-                      u8 HtCapabilityLen,
-                      u8 AddHtInfoLen,
-                      u8 NewExtChanOffset,
-                      u8 ChannelNo,
-                      char Rssi,
-                      IN LARGE_INTEGER TimeStamp,
-                      u8 CkipFlag,
-                      struct rt_edca_parm *pEdcaParm,
-                      struct rt_qos_capability_parm *pQosCapability,
-                      struct rt_qbss_load_parm *pQbssLoad,
-                      u16 LengthVIE, struct rt_ndis_802_11_variable_ies *pVIE)
-{
-       unsigned long Idx;
-
-       Idx =
-           BssTableSearchWithSSID(Tab, pBssid, (u8 *) Ssid, SsidLen,
-                                  ChannelNo);
-       if (Idx == BSS_NOT_FOUND) {
-               if (Tab->BssNr >= MAX_LEN_OF_BSS_TABLE) {
-                       /* */
-                       /* It may happen when BSS Table was full. */
-                       /* The desired AP will not be added into BSS Table */
-                       /* In this case, if we found the desired AP then overwrite BSS Table. */
-                       /* */
-                       if (!OPSTATUS_TEST_FLAG
-                           (pAd, fOP_STATUS_MEDIA_STATE_CONNECTED)) {
-                               if (MAC_ADDR_EQUAL(pAd->MlmeAux.Bssid, pBssid)
-                                   || SSID_EQUAL(pAd->MlmeAux.Ssid,
-                                                 pAd->MlmeAux.SsidLen, Ssid,
-                                                 SsidLen)) {
-                                       Idx = Tab->BssOverlapNr;
-                                       BssEntrySet(pAd, &Tab->BssEntry[Idx],
-                                                   pBssid, Ssid, SsidLen,
-                                                   BssType, BeaconPeriod,
-                                                   CfParm, AtimWin,
-                                                   CapabilityInfo, SupRate,
-                                                   SupRateLen, ExtRate,
-                                                   ExtRateLen, pHtCapability,
-                                                   pAddHtInfo, HtCapabilityLen,
-                                                   AddHtInfoLen,
-                                                   NewExtChanOffset, ChannelNo,
-                                                   Rssi, TimeStamp, CkipFlag,
-                                                   pEdcaParm, pQosCapability,
-                                                   pQbssLoad, LengthVIE, pVIE);
-                                       Tab->BssOverlapNr =
-                                           (Tab->BssOverlapNr++) %
-                                           MAX_LEN_OF_BSS_TABLE;
-                               }
-                               return Idx;
-                       } else {
-                               return BSS_NOT_FOUND;
-                       }
-               }
-               Idx = Tab->BssNr;
-               BssEntrySet(pAd, &Tab->BssEntry[Idx], pBssid, Ssid, SsidLen,
-                           BssType, BeaconPeriod, CfParm, AtimWin,
-                           CapabilityInfo, SupRate, SupRateLen, ExtRate,
-                           ExtRateLen, pHtCapability, pAddHtInfo,
-                           HtCapabilityLen, AddHtInfoLen, NewExtChanOffset,
-                           ChannelNo, Rssi, TimeStamp, CkipFlag, pEdcaParm,
-                           pQosCapability, pQbssLoad, LengthVIE, pVIE);
-               Tab->BssNr++;
-       } else {
-               /* avoid  Hidden SSID form beacon to overwirite correct SSID from probe response */
-               if ((SSID_EQUAL
-                    (Ssid, SsidLen, Tab->BssEntry[Idx].Ssid,
-                     Tab->BssEntry[Idx].SsidLen))
-                   ||
-                   (NdisEqualMemory
-                    (Tab->BssEntry[Idx].Ssid, ZeroSsid,
-                     Tab->BssEntry[Idx].SsidLen))) {
-                       BssEntrySet(pAd, &Tab->BssEntry[Idx], pBssid, Ssid,
-                                   SsidLen, BssType, BeaconPeriod, CfParm,
-                                   AtimWin, CapabilityInfo, SupRate,
-                                   SupRateLen, ExtRate, ExtRateLen,
-                                   pHtCapability, pAddHtInfo, HtCapabilityLen,
-                                   AddHtInfoLen, NewExtChanOffset, ChannelNo,
-                                   Rssi, TimeStamp, CkipFlag, pEdcaParm,
-                                   pQosCapability, pQbssLoad, LengthVIE, pVIE);
-               }
-       }
-
-       return Idx;
-}
-
-/* IRQL = DISPATCH_LEVEL */
-void BssTableSsidSort(struct rt_rtmp_adapter *pAd,
-                     struct rt_bss_table *OutTab, char Ssid[], u8 SsidLen)
-{
-       int i;
-       BssTableInit(OutTab);
-
-       for (i = 0; i < pAd->ScanTab.BssNr; i++) {
-               struct rt_bss_entry *pInBss = &pAd->ScanTab.BssEntry[i];
-               BOOLEAN bIsHiddenApIncluded = FALSE;
-
-               if (((pAd->CommonCfg.bIEEE80211H == 1) &&
-                    (pAd->MlmeAux.Channel > 14) &&
-                    RadarChannelCheck(pAd, pInBss->Channel))
-                   ) {
-                       if (pInBss->Hidden)
-                               bIsHiddenApIncluded = TRUE;
-               }
-
-               if ((pInBss->BssType == pAd->StaCfg.BssType) &&
-                   (SSID_EQUAL(Ssid, SsidLen, pInBss->Ssid, pInBss->SsidLen)
-                    || bIsHiddenApIncluded)) {
-                       struct rt_bss_entry *pOutBss = &OutTab->BssEntry[OutTab->BssNr];
-
-                       /* 2.4G/5G N only mode */
-                       if ((pInBss->HtCapabilityLen == 0) &&
-                           ((pAd->CommonCfg.PhyMode == PHY_11N_2_4G)
-                            || (pAd->CommonCfg.PhyMode == PHY_11N_5G))) {
-                               DBGPRINT(RT_DEBUG_TRACE,
-                                        ("STA is in N-only Mode, this AP don't have Ht capability in Beacon.\n"));
-                               continue;
-                       }
-                       /* New for WPA2 */
-                       /* Check the Authmode first */
-                       if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) {
-                               /* Check AuthMode and AuthModeAux for matching, in case AP support dual-mode */
-                               if ((pAd->StaCfg.AuthMode != pInBss->AuthMode)
-                                   && (pAd->StaCfg.AuthMode !=
-                                       pInBss->AuthModeAux))
-                                       /* None matched */
-                                       continue;
-
-                               /* Check cipher suite, AP must have more secured cipher than station setting */
-                               if ((pAd->StaCfg.AuthMode ==
-                                    Ndis802_11AuthModeWPA)
-                                   || (pAd->StaCfg.AuthMode ==
-                                       Ndis802_11AuthModeWPAPSK)) {
-                                       /* If it's not mixed mode, we should only let BSS pass with the same encryption */
-                                       if (pInBss->WPA.bMixMode == FALSE)
-                                               if (pAd->StaCfg.WepStatus !=
-                                                   pInBss->WPA.GroupCipher)
-                                                       continue;
-
-                                       /* check group cipher */
-                                       if ((pAd->StaCfg.WepStatus <
-                                            pInBss->WPA.GroupCipher)
-                                           && (pInBss->WPA.GroupCipher !=
-                                               Ndis802_11GroupWEP40Enabled)
-                                           && (pInBss->WPA.GroupCipher !=
-                                               Ndis802_11GroupWEP104Enabled))
-                                               continue;
-
-                                       /* check pairwise cipher, skip if none matched */
-                                       /* If profile set to AES, let it pass without question. */
-                                       /* If profile set to TKIP, we must find one mateched */
-                                       if ((pAd->StaCfg.WepStatus ==
-                                            Ndis802_11Encryption2Enabled)
-                                           && (pAd->StaCfg.WepStatus !=
-                                               pInBss->WPA.PairCipher)
-                                           && (pAd->StaCfg.WepStatus !=
-                                               pInBss->WPA.PairCipherAux))
-                                               continue;
-                               } else
-                                   if ((pAd->StaCfg.AuthMode ==
-                                        Ndis802_11AuthModeWPA2)
-                                       || (pAd->StaCfg.AuthMode ==
-                                           Ndis802_11AuthModeWPA2PSK)) {
-                                       /* If it's not mixed mode, we should only let BSS pass with the same encryption */
-                                       if (pInBss->WPA2.bMixMode == FALSE)
-                                               if (pAd->StaCfg.WepStatus !=
-                                                   pInBss->WPA2.GroupCipher)
-                                                       continue;
-
-                                       /* check group cipher */
-                                       if ((pAd->StaCfg.WepStatus <
-                                            pInBss->WPA.GroupCipher)
-                                           && (pInBss->WPA2.GroupCipher !=
-                                               Ndis802_11GroupWEP40Enabled)
-                                           && (pInBss->WPA2.GroupCipher !=
-                                               Ndis802_11GroupWEP104Enabled))
-                                               continue;
-
-                                       /* check pairwise cipher, skip if none matched */
-                                       /* If profile set to AES, let it pass without question. */
-                                       /* If profile set to TKIP, we must find one mateched */
-                                       if ((pAd->StaCfg.WepStatus ==
-                                            Ndis802_11Encryption2Enabled)
-                                           && (pAd->StaCfg.WepStatus !=
-                                               pInBss->WPA2.PairCipher)
-                                           && (pAd->StaCfg.WepStatus !=
-                                               pInBss->WPA2.PairCipherAux))
-                                               continue;
-                               }
-                       }
-                       /* Bss Type matched, SSID matched. */
-                       /* We will check wepstatus for qualification Bss */
-                       else if (pAd->StaCfg.WepStatus != pInBss->WepStatus) {
-                               DBGPRINT(RT_DEBUG_TRACE,
-                                        ("StaCfg.WepStatus=%d, while pInBss->WepStatus=%d\n",
-                                         pAd->StaCfg.WepStatus,
-                                         pInBss->WepStatus));
-                               /* */
-                               /* For the SESv2 case, we will not qualify WepStatus. */
-                               /* */
-                               if (!pInBss->bSES)
-                                       continue;
-                       }
-                       /* Since the AP is using hidden SSID, and we are trying to connect to ANY */
-                       /* It definitely will fail. So, skip it. */
-                       /* CCX also require not even try to connect it! */
-                       if (SsidLen == 0)
-                               continue;
-
-                       /* If both station and AP use 40MHz, still need to check if the 40MHZ band's legality in my country region */
-                       /* If this 40MHz wideband is not allowed in my country list, use bandwidth 20MHZ instead, */
-                       if ((pInBss->CentralChannel != pInBss->Channel) &&
-                           (pAd->CommonCfg.RegTransmitSetting.field.BW ==
-                            BW_40)) {
-                               if (RTMPCheckChannel
-                                   (pAd, pInBss->CentralChannel,
-                                    pInBss->Channel) == FALSE) {
-                                       pAd->CommonCfg.RegTransmitSetting.field.
-                                           BW = BW_20;
-                                       SetCommonHT(pAd);
-                                       pAd->CommonCfg.RegTransmitSetting.field.
-                                           BW = BW_40;
-                               } else {
-                                       if (pAd->CommonCfg.DesiredHtPhy.
-                                           ChannelWidth == BAND_WIDTH_20) {
-                                               SetCommonHT(pAd);
-                                       }
-                               }
-                       }
-                       /* copy matching BSS from InTab to OutTab */
-                       NdisMoveMemory(pOutBss, pInBss, sizeof(struct rt_bss_entry));
-
-                       OutTab->BssNr++;
-               } else if ((pInBss->BssType == pAd->StaCfg.BssType)
-                          && (SsidLen == 0)) {
-                       struct rt_bss_entry *pOutBss = &OutTab->BssEntry[OutTab->BssNr];
-
-                       /* 2.4G/5G N only mode */
-                       if ((pInBss->HtCapabilityLen == 0) &&
-                           ((pAd->CommonCfg.PhyMode == PHY_11N_2_4G)
-                            || (pAd->CommonCfg.PhyMode == PHY_11N_5G))) {
-                               DBGPRINT(RT_DEBUG_TRACE,
-                                        ("STA is in N-only Mode, this AP don't have Ht capability in Beacon.\n"));
-                               continue;
-                       }
-                       /* New for WPA2 */
-                       /* Check the Authmode first */
-                       if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) {
-                               /* Check AuthMode and AuthModeAux for matching, in case AP support dual-mode */
-                               if ((pAd->StaCfg.AuthMode != pInBss->AuthMode)
-                                   && (pAd->StaCfg.AuthMode !=
-                                       pInBss->AuthModeAux))
-                                       /* None matched */
-                                       continue;
-
-                               /* Check cipher suite, AP must have more secured cipher than station setting */
-                               if ((pAd->StaCfg.AuthMode ==
-                                    Ndis802_11AuthModeWPA)
-                                   || (pAd->StaCfg.AuthMode ==
-                                       Ndis802_11AuthModeWPAPSK)) {
-                                       /* If it's not mixed mode, we should only let BSS pass with the same encryption */
-                                       if (pInBss->WPA.bMixMode == FALSE)
-                                               if (pAd->StaCfg.WepStatus !=
-                                                   pInBss->WPA.GroupCipher)
-                                                       continue;
-
-                                       /* check group cipher */
-                                       if (pAd->StaCfg.WepStatus <
-                                           pInBss->WPA.GroupCipher)
-                                               continue;
-
-                                       /* check pairwise cipher, skip if none matched */
-                                       /* If profile set to AES, let it pass without question. */
-                                       /* If profile set to TKIP, we must find one mateched */
-                                       if ((pAd->StaCfg.WepStatus ==
-                                            Ndis802_11Encryption2Enabled)
-                                           && (pAd->StaCfg.WepStatus !=
-                                               pInBss->WPA.PairCipher)
-                                           && (pAd->StaCfg.WepStatus !=
-                                               pInBss->WPA.PairCipherAux))
-                                               continue;
-                               } else
-                                   if ((pAd->StaCfg.AuthMode ==
-                                        Ndis802_11AuthModeWPA2)
-                                       || (pAd->StaCfg.AuthMode ==
-                                           Ndis802_11AuthModeWPA2PSK)) {
-                                       /* If it's not mixed mode, we should only let BSS pass with the same encryption */
-                                       if (pInBss->WPA2.bMixMode == FALSE)
-                                               if (pAd->StaCfg.WepStatus !=
-                                                   pInBss->WPA2.GroupCipher)
-                                                       continue;
-
-                                       /* check group cipher */
-                                       if (pAd->StaCfg.WepStatus <
-                                           pInBss->WPA2.GroupCipher)
-                                               continue;
-
-                                       /* check pairwise cipher, skip if none matched */
-                                       /* If profile set to AES, let it pass without question. */
-                                       /* If profile set to TKIP, we must find one mateched */
-                                       if ((pAd->StaCfg.WepStatus ==
-                                            Ndis802_11Encryption2Enabled)
-                                           && (pAd->StaCfg.WepStatus !=
-                                               pInBss->WPA2.PairCipher)
-                                           && (pAd->StaCfg.WepStatus !=
-                                               pInBss->WPA2.PairCipherAux))
-                                               continue;
-                               }
-                       }
-                       /* Bss Type matched, SSID matched. */
-                       /* We will check wepstatus for qualification Bss */
-                       else if (pAd->StaCfg.WepStatus != pInBss->WepStatus)
-                               continue;
-
-                       /* If both station and AP use 40MHz, still need to check if the 40MHZ band's legality in my country region */
-                       /* If this 40MHz wideband is not allowed in my country list, use bandwidth 20MHZ instead, */
-                       if ((pInBss->CentralChannel != pInBss->Channel) &&
-                           (pAd->CommonCfg.RegTransmitSetting.field.BW ==
-                            BW_40)) {
-                               if (RTMPCheckChannel
-                                   (pAd, pInBss->CentralChannel,
-                                    pInBss->Channel) == FALSE) {
-                                       pAd->CommonCfg.RegTransmitSetting.field.
-                                           BW = BW_20;
-                                       SetCommonHT(pAd);
-                                       pAd->CommonCfg.RegTransmitSetting.field.
-                                           BW = BW_40;
-                               }
-                       }
-                       /* copy matching BSS from InTab to OutTab */
-                       NdisMoveMemory(pOutBss, pInBss, sizeof(struct rt_bss_entry));
-
-                       OutTab->BssNr++;
-               }
-
-               if (OutTab->BssNr >= MAX_LEN_OF_BSS_TABLE)
-                       break;
-       }
-
-       BssTableSortByRssi(OutTab);
-}
-
-/* IRQL = DISPATCH_LEVEL */
-void BssTableSortByRssi(struct rt_bss_table *OutTab)
-{
-       int i, j;
-       struct rt_bss_entry TmpBss;
-
-       for (i = 0; i < OutTab->BssNr - 1; i++) {
-               for (j = i + 1; j < OutTab->BssNr; j++) {
-                       if (OutTab->BssEntry[j].Rssi > OutTab->BssEntry[i].Rssi) {
-                               NdisMoveMemory(&TmpBss, &OutTab->BssEntry[j],
-                                              sizeof(struct rt_bss_entry));
-                               NdisMoveMemory(&OutTab->BssEntry[j],
-                                              &OutTab->BssEntry[i],
-                                              sizeof(struct rt_bss_entry));
-                               NdisMoveMemory(&OutTab->BssEntry[i], &TmpBss,
-                                              sizeof(struct rt_bss_entry));
-                       }
-               }
-       }
-}
-
-void BssCipherParse(struct rt_bss_entry *pBss)
-{
-       struct rt_eid * pEid;
-       u8 *pTmp;
-       struct rt_rsn_ie_header * pRsnHeader;
-       struct rt_cipher_suite_struct * pCipher;
-       struct rt_akm_suite * pAKM;
-       u16 Count;
-       int Length;
-       NDIS_802_11_ENCRYPTION_STATUS TmpCipher;
-
-       /* */
-       /* WepStatus will be reset later, if AP announce TKIP or AES on the beacon frame. */
-       /* */
-       if (pBss->Privacy) {
-               pBss->WepStatus = Ndis802_11WEPEnabled;
-       } else {
-               pBss->WepStatus = Ndis802_11WEPDisabled;
-       }
-       /* Set default to disable & open authentication before parsing variable IE */
-       pBss->AuthMode = Ndis802_11AuthModeOpen;
-       pBss->AuthModeAux = Ndis802_11AuthModeOpen;
-
-       /* Init WPA setting */
-       pBss->WPA.PairCipher = Ndis802_11WEPDisabled;
-       pBss->WPA.PairCipherAux = Ndis802_11WEPDisabled;
-       pBss->WPA.GroupCipher = Ndis802_11WEPDisabled;
-       pBss->WPA.RsnCapability = 0;
-       pBss->WPA.bMixMode = FALSE;
-
-       /* Init WPA2 setting */
-       pBss->WPA2.PairCipher = Ndis802_11WEPDisabled;
-       pBss->WPA2.PairCipherAux = Ndis802_11WEPDisabled;
-       pBss->WPA2.GroupCipher = Ndis802_11WEPDisabled;
-       pBss->WPA2.RsnCapability = 0;
-       pBss->WPA2.bMixMode = FALSE;
-
-       Length = (int)pBss->VarIELen;
-
-       while (Length > 0) {
-               /* Parse cipher suite base on WPA1 & WPA2, they should be parsed differently */
-               pTmp = ((u8 *)pBss->VarIEs) + pBss->VarIELen - Length;
-               pEid = (struct rt_eid *) pTmp;
-               switch (pEid->Eid) {
-               case IE_WPA:
-                       if (NdisEqualMemory(pEid->Octet, SES_OUI, 3)
-                           && (pEid->Len == 7)) {
-                               pBss->bSES = TRUE;
-                               break;
-                       } else if (NdisEqualMemory(pEid->Octet, WPA_OUI, 4) !=
-                                  1) {
-                               /* if unsupported vendor specific IE */
-                               break;
-                       }
-                       /* Skip OUI, version, and multicast suite */
-                       /* This part should be improved in the future when AP supported multiple cipher suite. */
-                       /* For now, it's OK since almost all APs have fixed cipher suite supported. */
-                       /* pTmp = (u8 *)pEid->Octet; */
-                       pTmp += 11;
-
-                       /* Cipher Suite Selectors from Spec P802.11i/D3.2 P26. */
-                       /*      Value      Meaning */
-                       /*      0                       None */
-                       /*      1                       WEP-40 */
-                       /*      2                       Tkip */
-                       /*      3                       WRAP */
-                       /*      4                       AES */
-                       /*      5                       WEP-104 */
-                       /* Parse group cipher */
-                       switch (*pTmp) {
-                       case 1:
-                               pBss->WPA.GroupCipher =
-                                   Ndis802_11GroupWEP40Enabled;
-                               break;
-                       case 5:
-                               pBss->WPA.GroupCipher =
-                                   Ndis802_11GroupWEP104Enabled;
-                               break;
-                       case 2:
-                               pBss->WPA.GroupCipher =
-                                   Ndis802_11Encryption2Enabled;
-                               break;
-                       case 4:
-                               pBss->WPA.GroupCipher =
-                                   Ndis802_11Encryption3Enabled;
-                               break;
-                       default:
-                               break;
-                       }
-                       /* number of unicast suite */
-                       pTmp += 1;
-
-                       /* skip all unicast cipher suites */
-                       /*Count = *(u16 *)pTmp; */
-                       Count = (pTmp[1] << 8) + pTmp[0];
-                       pTmp += sizeof(u16);
-
-                       /* Parsing all unicast cipher suite */
-                       while (Count > 0) {
-                               /* Skip OUI */
-                               pTmp += 3;
-                               TmpCipher = Ndis802_11WEPDisabled;
-                               switch (*pTmp) {
-                               case 1:
-                               case 5: /* Although WEP is not allowed in WPA related auth mode, we parse it anyway */
-                                       TmpCipher =
-                                           Ndis802_11Encryption1Enabled;
-                                       break;
-                               case 2:
-                                       TmpCipher =
-                                           Ndis802_11Encryption2Enabled;
-                                       break;
-                               case 4:
-                                       TmpCipher =
-                                           Ndis802_11Encryption3Enabled;
-                                       break;
-                               default:
-                                       break;
-                               }
-                               if (TmpCipher > pBss->WPA.PairCipher) {
-                                       /* Move the lower cipher suite to PairCipherAux */
-                                       pBss->WPA.PairCipherAux =
-                                           pBss->WPA.PairCipher;
-                                       pBss->WPA.PairCipher = TmpCipher;
-                               } else {
-                                       pBss->WPA.PairCipherAux = TmpCipher;
-                               }
-                               pTmp++;
-                               Count--;
-                       }
-
-                       /* 4. get AKM suite counts */
-                       /*Count = *(u16 *)pTmp; */
-                       Count = (pTmp[1] << 8) + pTmp[0];
-                       pTmp += sizeof(u16);
-                       pTmp += 3;
-
-                       switch (*pTmp) {
-                       case 1:
-                               /* Set AP support WPA-enterprise mode */
-                               if (pBss->AuthMode == Ndis802_11AuthModeOpen)
-                                       pBss->AuthMode = Ndis802_11AuthModeWPA;
-                               else
-                                       pBss->AuthModeAux =
-                                           Ndis802_11AuthModeWPA;
-                               break;
-                       case 2:
-                               /* Set AP support WPA-PSK mode */
-                               if (pBss->AuthMode == Ndis802_11AuthModeOpen)
-                                       pBss->AuthMode =
-                                           Ndis802_11AuthModeWPAPSK;
-                               else
-                                       pBss->AuthModeAux =
-                                           Ndis802_11AuthModeWPAPSK;
-                               break;
-                       default:
-                               break;
-                       }
-                       pTmp += 1;
-
-                       /* Fixed for WPA-None */
-                       if (pBss->BssType == BSS_ADHOC) {
-                               pBss->AuthMode = Ndis802_11AuthModeWPANone;
-                               pBss->AuthModeAux = Ndis802_11AuthModeWPANone;
-                               pBss->WepStatus = pBss->WPA.GroupCipher;
-                               /* Patched bugs for old driver */
-                               if (pBss->WPA.PairCipherAux ==
-                                   Ndis802_11WEPDisabled)
-                                       pBss->WPA.PairCipherAux =
-                                           pBss->WPA.GroupCipher;
-                       } else
-                               pBss->WepStatus = pBss->WPA.PairCipher;
-
-                       /* Check the Pair & Group, if different, turn on mixed mode flag */
-                       if (pBss->WPA.GroupCipher != pBss->WPA.PairCipher)
-                               pBss->WPA.bMixMode = TRUE;
-
-                       break;
-
-               case IE_RSN:
-                       pRsnHeader = (struct rt_rsn_ie_header *) pTmp;
-
-                       /* 0. Version must be 1 */
-                       if (le2cpu16(pRsnHeader->Version) != 1)
-                               break;
-                       pTmp += sizeof(struct rt_rsn_ie_header);
-
-                       /* 1. Check group cipher */
-                       pCipher = (struct rt_cipher_suite_struct *) pTmp;
-                       if (!RTMPEqualMemory(pTmp, RSN_OUI, 3))
-                               break;
-
-                       /* Parse group cipher */
-                       switch (pCipher->Type) {
-                       case 1:
-                               pBss->WPA2.GroupCipher =
-                                   Ndis802_11GroupWEP40Enabled;
-                               break;
-                       case 5:
-                               pBss->WPA2.GroupCipher =
-                                   Ndis802_11GroupWEP104Enabled;
-                               break;
-                       case 2:
-                               pBss->WPA2.GroupCipher =
-                                   Ndis802_11Encryption2Enabled;
-                               break;
-                       case 4:
-                               pBss->WPA2.GroupCipher =
-                                   Ndis802_11Encryption3Enabled;
-                               break;
-                       default:
-                               break;
-                       }
-                       /* set to correct offset for next parsing */
-                       pTmp += sizeof(struct rt_cipher_suite_struct);
-
-                       /* 2. Get pairwise cipher counts */
-                       /*Count = *(u16 *)pTmp; */
-                       Count = (pTmp[1] << 8) + pTmp[0];
-                       pTmp += sizeof(u16);
-
-                       /* 3. Get pairwise cipher */
-                       /* Parsing all unicast cipher suite */
-                       while (Count > 0) {
-                               /* Skip OUI */
-                               pCipher = (struct rt_cipher_suite_struct *) pTmp;
-                               TmpCipher = Ndis802_11WEPDisabled;
-                               switch (pCipher->Type) {
-                               case 1:
-                               case 5: /* Although WEP is not allowed in WPA related auth mode, we parse it anyway */
-                                       TmpCipher =
-                                           Ndis802_11Encryption1Enabled;
-                                       break;
-                               case 2:
-                                       TmpCipher =
-                                           Ndis802_11Encryption2Enabled;
-                                       break;
-                               case 4:
-                                       TmpCipher =
-                                           Ndis802_11Encryption3Enabled;
-                                       break;
-                               default:
-                                       break;
-                               }
-                               if (TmpCipher > pBss->WPA2.PairCipher) {
-                                       /* Move the lower cipher suite to PairCipherAux */
-                                       pBss->WPA2.PairCipherAux =
-                                           pBss->WPA2.PairCipher;
-                                       pBss->WPA2.PairCipher = TmpCipher;
-                               } else {
-                                       pBss->WPA2.PairCipherAux = TmpCipher;
-                               }
-                               pTmp += sizeof(struct rt_cipher_suite_struct);
-                               Count--;
-                       }
-
-                       /* 4. get AKM suite counts */
-                       /*Count = *(u16 *)pTmp; */
-                       Count = (pTmp[1] << 8) + pTmp[0];
-                       pTmp += sizeof(u16);
-
-                       /* 5. Get AKM ciphers */
-                       /* Parsing all AKM ciphers */
-                       while (Count > 0) {
-                               pAKM = (struct rt_akm_suite *) pTmp;
-                               if (!RTMPEqualMemory(pTmp, RSN_OUI, 3))
-                                       break;
-
-                               switch (pAKM->Type) {
-                               case 1:
-                                       /* Set AP support WPA-enterprise mode */
-                                       if (pBss->AuthMode ==
-                                           Ndis802_11AuthModeOpen)
-                                               pBss->AuthMode =
-                                                   Ndis802_11AuthModeWPA2;
-                                       else
-                                               pBss->AuthModeAux =
-                                                   Ndis802_11AuthModeWPA2;
-                                       break;
-                               case 2:
-                                       /* Set AP support WPA-PSK mode */
-                                       if (pBss->AuthMode ==
-                                           Ndis802_11AuthModeOpen)
-                                               pBss->AuthMode =
-                                                   Ndis802_11AuthModeWPA2PSK;
-                                       else
-                                               pBss->AuthModeAux =
-                                                   Ndis802_11AuthModeWPA2PSK;
-                                       break;
-                               default:
-                                       if (pBss->AuthMode ==
-                                           Ndis802_11AuthModeOpen)
-                                               pBss->AuthMode =
-                                                   Ndis802_11AuthModeMax;
-                                       else
-                                               pBss->AuthModeAux =
-                                                   Ndis802_11AuthModeMax;
-                                       break;
-                               }
-                               pTmp += (Count * sizeof(struct rt_akm_suite));
-                               Count--;
-                       }
-
-                       /* Fixed for WPA-None */
-                       if (pBss->BssType == BSS_ADHOC) {
-                               pBss->AuthMode = Ndis802_11AuthModeWPANone;
-                               pBss->AuthModeAux = Ndis802_11AuthModeWPANone;
-                               pBss->WPA.PairCipherAux =
-                                   pBss->WPA2.PairCipherAux;
-                               pBss->WPA.GroupCipher = pBss->WPA2.GroupCipher;
-                               pBss->WepStatus = pBss->WPA.GroupCipher;
-                               /* Patched bugs for old driver */
-                               if (pBss->WPA.PairCipherAux ==
-                                   Ndis802_11WEPDisabled)
-                                       pBss->WPA.PairCipherAux =
-                                           pBss->WPA.GroupCipher;
-                       }
-                       pBss->WepStatus = pBss->WPA2.PairCipher;
-
-                       /* 6. Get RSN capability */
-                       /*pBss->WPA2.RsnCapability = *(u16 *)pTmp; */
-                       pBss->WPA2.RsnCapability = (pTmp[1] << 8) + pTmp[0];
-                       pTmp += sizeof(u16);
-
-                       /* Check the Pair & Group, if different, turn on mixed mode flag */
-                       if (pBss->WPA2.GroupCipher != pBss->WPA2.PairCipher)
-                               pBss->WPA2.bMixMode = TRUE;
-
-                       break;
-               default:
-                       break;
-               }
-               Length -= (pEid->Len + 2);
-       }
-}
-
-/* =========================================================================================== */
-/* mac_table.c */
-/* =========================================================================================== */
-
-/*! \brief generates a random mac address value for IBSS BSSID
- *     \param Addr the bssid location
- *     \return none
- *     \pre
- *     \post
- */
-void MacAddrRandomBssid(struct rt_rtmp_adapter *pAd, u8 *pAddr)
-{
-       int i;
-
-       for (i = 0; i < MAC_ADDR_LEN; i++) {
-               pAddr[i] = RandomByte(pAd);
-       }
-
-       pAddr[0] = (pAddr[0] & 0xfe) | 0x02;    /* the first 2 bits must be 01xxxxxxxx */
-}
-
-/*! \brief init the management mac frame header
- *     \param p_hdr mac header
- *     \param subtype subtype of the frame
- *     \param p_ds destination address, don't care if it is a broadcast address
- *     \return none
- *     \pre the station has the following information in the pAd->StaCfg
- *      - bssid
- *      - station address
- *     \post
- *     \note this function initializes the following field
-
-       IRQL = PASSIVE_LEVEL
-       IRQL = DISPATCH_LEVEL
-
- */
-void MgtMacHeaderInit(struct rt_rtmp_adapter *pAd,
-                     struct rt_header_802_11 * pHdr80211,
-                     u8 SubType,
-                     u8 ToDs, u8 *pDA, u8 *pBssid)
-{
-       NdisZeroMemory(pHdr80211, sizeof(struct rt_header_802_11));
-
-       pHdr80211->FC.Type = BTYPE_MGMT;
-       pHdr80211->FC.SubType = SubType;
-/*      if (SubType == SUBTYPE_ACK)     // sample, no use, it will conflict with ACTION frame sub type */
-/*              pHdr80211->FC.Type = BTYPE_CNTL; */
-       pHdr80211->FC.ToDs = ToDs;
-       COPY_MAC_ADDR(pHdr80211->Addr1, pDA);
-       COPY_MAC_ADDR(pHdr80211->Addr2, pAd->CurrentAddress);
-       COPY_MAC_ADDR(pHdr80211->Addr3, pBssid);
-}
-
-/* =========================================================================================== */
-/* mem_mgmt.c */
-/* =========================================================================================== */
-
-/*!***************************************************************************
- * This routine build an outgoing frame, and fill all information specified
- * in argument list to the frame body. The actual frame size is the summation
- * of all arguments.
- * input params:
- *             Buffer - pointer to a pre-allocated memory segment
- *             args - a list of <int arg_size, arg> pairs.
- *             NOTE NOTE NOTE! the last argument must be NULL, otherwise this
- *                                                function will FAIL!
- * return:
- *             Size of the buffer
- * usage:
- *             MakeOutgoingFrame(Buffer, output_length, 2, &fc, 2, &dur, 6, p_addr1, 6,p_addr2, END_OF_ARGS);
-
- IRQL = PASSIVE_LEVEL
-       IRQL = DISPATCH_LEVEL
-
- ****************************************************************************/
-unsigned long MakeOutgoingFrame(u8 * Buffer, unsigned long * FrameLen, ...)
-{
-       u8 *p;
-       int leng;
-       unsigned long TotLeng;
-       va_list Args;
-
-       /* calculates the total length */
-       TotLeng = 0;
-       va_start(Args, FrameLen);
-       do {
-               leng = va_arg(Args, int);
-               if (leng == END_OF_ARGS) {
-                       break;
-               }
-               p = va_arg(Args, void *);
-               NdisMoveMemory(&Buffer[TotLeng], p, leng);
-               TotLeng = TotLeng + leng;
-       } while (TRUE);
-
-       va_end(Args);           /* clean up */
-       *FrameLen = TotLeng;
-       return TotLeng;
-}
-
-/* =========================================================================================== */
-/* mlme_queue.c */
-/* =========================================================================================== */
-
-/*! \brief     Initialize The MLME Queue, used by MLME Functions
- *     \param  *Queue     The MLME Queue
- *     \return Always     Return NDIS_STATE_SUCCESS in this implementation
- *     \pre
- *     \post
- *     \note   Because this is done only once (at the init stage), no need to be locked
-
- IRQL = PASSIVE_LEVEL
-
- */
-int MlmeQueueInit(struct rt_mlme_queue *Queue)
-{
-       int i;
-
-       NdisAllocateSpinLock(&Queue->Lock);
-
-       Queue->Num = 0;
-       Queue->Head = 0;
-       Queue->Tail = 0;
-
-       for (i = 0; i < MAX_LEN_OF_MLME_QUEUE; i++) {
-               Queue->Entry[i].Occupied = FALSE;
-               Queue->Entry[i].MsgLen = 0;
-               NdisZeroMemory(Queue->Entry[i].Msg, MGMT_DMA_BUFFER_SIZE);
-       }
-
-       return NDIS_STATUS_SUCCESS;
-}
-
-/*! \brief      Enqueue a message for other threads, if they want to send messages to MLME thread
- *     \param  *Queue    The MLME Queue
- *     \param   Machine  The State Machine Id
- *     \param   MsgType  The Message Type
- *     \param   MsgLen   The Message length
- *     \param  *Msg      The message pointer
- *     \return  TRUE if enqueue is successful, FALSE if the queue is full
- *     \pre
- *     \post
- *     \note    The message has to be initialized
-
-       IRQL = PASSIVE_LEVEL
-       IRQL = DISPATCH_LEVEL
-
- */
-BOOLEAN MlmeEnqueue(struct rt_rtmp_adapter *pAd,
-                   unsigned long Machine,
-                   unsigned long MsgType, unsigned long MsgLen, void * Msg)
-{
-       int Tail;
-       struct rt_mlme_queue *Queue = (struct rt_mlme_queue *)& pAd->Mlme.Queue;
-
-       /* Do nothing if the driver is starting halt state. */
-       /* This might happen when timer already been fired before cancel timer with mlmehalt */
-       if (RTMP_TEST_FLAG
-           (pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST))
-               return FALSE;
-
-       /* First check the size, it MUST not exceed the mlme queue size */
-       if (MsgLen > MGMT_DMA_BUFFER_SIZE) {
-               DBGPRINT_ERR("MlmeEnqueue: msg too large, size = %ld \n", MsgLen);
-               return FALSE;
-       }
-
-       if (MlmeQueueFull(Queue)) {
-               return FALSE;
-       }
-
-       NdisAcquireSpinLock(&(Queue->Lock));
-       Tail = Queue->Tail;
-       Queue->Tail++;
-       Queue->Num++;
-       if (Queue->Tail == MAX_LEN_OF_MLME_QUEUE) {
-               Queue->Tail = 0;
-       }
-
-       Queue->Entry[Tail].Wcid = RESERVED_WCID;
-       Queue->Entry[Tail].Occupied = TRUE;
-       Queue->Entry[Tail].Machine = Machine;
-       Queue->Entry[Tail].MsgType = MsgType;
-       Queue->Entry[Tail].MsgLen = MsgLen;
-
-       if (Msg != NULL) {
-               NdisMoveMemory(Queue->Entry[Tail].Msg, Msg, MsgLen);
-       }
-
-       NdisReleaseSpinLock(&(Queue->Lock));
-       return TRUE;
-}
-
-/*! \brief      This function is used when Recv gets a MLME message
- *     \param  *Queue                   The MLME Queue
- *     \param   TimeStampHigh   The upper 32 bit of timestamp
- *     \param   TimeStampLow    The lower 32 bit of timestamp
- *     \param   Rssi                    The receiving RSSI strength
- *     \param   MsgLen                  The length of the message
- *     \param  *Msg                     The message pointer
- *     \return  TRUE if everything ok, FALSE otherwise (like Queue Full)
- *     \pre
- *     \post
-
- IRQL = DISPATCH_LEVEL
-
- */
-BOOLEAN MlmeEnqueueForRecv(struct rt_rtmp_adapter *pAd,
-                          unsigned long Wcid,
-                          unsigned long TimeStampHigh,
-                          unsigned long TimeStampLow,
-                          u8 Rssi0,
-                          u8 Rssi1,
-                          u8 Rssi2,
-                          unsigned long MsgLen, void * Msg, u8 Signal)
-{
-       int Tail, Machine;
-       struct rt_frame_802_11 * pFrame = (struct rt_frame_802_11 *) Msg;
-       int MsgType;
-       struct rt_mlme_queue *Queue = (struct rt_mlme_queue *)& pAd->Mlme.Queue;
-
-       /* Do nothing if the driver is starting halt state. */
-       /* This might happen when timer already been fired before cancel timer with mlmehalt */
-       if (RTMP_TEST_FLAG
-           (pAd,
-            fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST)) {
-               DBGPRINT_ERR("MlmeEnqueueForRecv: fRTMP_ADAPTER_HALT_IN_PROGRESS\n");
-               return FALSE;
-       }
-       /* First check the size, it MUST not exceed the mlme queue size */
-       if (MsgLen > MGMT_DMA_BUFFER_SIZE) {
-               DBGPRINT_ERR("MlmeEnqueueForRecv: frame too large, size = %ld \n", MsgLen);
-               return FALSE;
-       }
-
-       if (MlmeQueueFull(Queue)) {
-               return FALSE;
-       }
-
-       {
-               if (!MsgTypeSubst(pAd, pFrame, &Machine, &MsgType)) {
-                       DBGPRINT_ERR("MlmeEnqueueForRecv: un-recongnized mgmt->subtype=%d\n", pFrame->Hdr.FC.SubType);
-                       return FALSE;
-               }
-       }
-
-       /* OK, we got all the informations, it is time to put things into queue */
-       NdisAcquireSpinLock(&(Queue->Lock));
-       Tail = Queue->Tail;
-       Queue->Tail++;
-       Queue->Num++;
-       if (Queue->Tail == MAX_LEN_OF_MLME_QUEUE) {
-               Queue->Tail = 0;
-       }
-       Queue->Entry[Tail].Occupied = TRUE;
-       Queue->Entry[Tail].Machine = Machine;
-       Queue->Entry[Tail].MsgType = MsgType;
-       Queue->Entry[Tail].MsgLen = MsgLen;
-       Queue->Entry[Tail].TimeStamp.u.LowPart = TimeStampLow;
-       Queue->Entry[Tail].TimeStamp.u.HighPart = TimeStampHigh;
-       Queue->Entry[Tail].Rssi0 = Rssi0;
-       Queue->Entry[Tail].Rssi1 = Rssi1;
-       Queue->Entry[Tail].Rssi2 = Rssi2;
-       Queue->Entry[Tail].Signal = Signal;
-       Queue->Entry[Tail].Wcid = (u8)Wcid;
-
-       Queue->Entry[Tail].Channel = pAd->LatchRfRegs.Channel;
-
-       if (Msg != NULL) {
-               NdisMoveMemory(Queue->Entry[Tail].Msg, Msg, MsgLen);
-       }
-
-       NdisReleaseSpinLock(&(Queue->Lock));
-
-       RTMP_MLME_HANDLER(pAd);
-
-       return TRUE;
-}
-
-/*! \brief      Dequeue a message from the MLME Queue
- *     \param  *Queue    The MLME Queue
- *     \param  *Elem     The message dequeued from MLME Queue
- *     \return  TRUE if the Elem contains something, FALSE otherwise
- *     \pre
- *     \post
-
- IRQL = DISPATCH_LEVEL
-
- */
-BOOLEAN MlmeDequeue(struct rt_mlme_queue *Queue, struct rt_mlme_queue_elem ** Elem)
-{
-       NdisAcquireSpinLock(&(Queue->Lock));
-       *Elem = &(Queue->Entry[Queue->Head]);
-       Queue->Num--;
-       Queue->Head++;
-       if (Queue->Head == MAX_LEN_OF_MLME_QUEUE) {
-               Queue->Head = 0;
-       }
-       NdisReleaseSpinLock(&(Queue->Lock));
-       return TRUE;
-}
-
-/* IRQL = DISPATCH_LEVEL */
-void MlmeRestartStateMachine(struct rt_rtmp_adapter *pAd)
-{
-#ifdef RTMP_MAC_PCI
-       struct rt_mlme_queue_elem *Elem = NULL;
-#endif /* RTMP_MAC_PCI // */
-       BOOLEAN Cancelled;
-
-       DBGPRINT(RT_DEBUG_TRACE, ("MlmeRestartStateMachine \n"));
-
-#ifdef RTMP_MAC_PCI
-       NdisAcquireSpinLock(&pAd->Mlme.TaskLock);
-       if (pAd->Mlme.bRunning) {
-               NdisReleaseSpinLock(&pAd->Mlme.TaskLock);
-               return;
-       } else {
-               pAd->Mlme.bRunning = TRUE;
-       }
-       NdisReleaseSpinLock(&pAd->Mlme.TaskLock);
-
-       /* Remove all Mlme queues elements */
-       while (!MlmeQueueEmpty(&pAd->Mlme.Queue)) {
-               /*From message type, determine which state machine I should drive */
-               if (MlmeDequeue(&pAd->Mlme.Queue, &Elem)) {
-                       /* free MLME element */
-                       Elem->Occupied = FALSE;
-                       Elem->MsgLen = 0;
-
-               } else {
-                       DBGPRINT_ERR("MlmeRestartStateMachine: MlmeQueue empty\n");
-               }
-       }
-#endif /* RTMP_MAC_PCI // */
-
-       {
-               /* Cancel all timer events */
-               /* Be careful to cancel new added timer */
-               RTMPCancelTimer(&pAd->MlmeAux.AssocTimer, &Cancelled);
-               RTMPCancelTimer(&pAd->MlmeAux.ReassocTimer, &Cancelled);
-               RTMPCancelTimer(&pAd->MlmeAux.DisassocTimer, &Cancelled);
-               RTMPCancelTimer(&pAd->MlmeAux.AuthTimer, &Cancelled);
-               RTMPCancelTimer(&pAd->MlmeAux.BeaconTimer, &Cancelled);
-               RTMPCancelTimer(&pAd->MlmeAux.ScanTimer, &Cancelled);
-
-       }
-
-       /* Change back to original channel in case of doing scan */
-       AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE);
-       AsicLockChannel(pAd, pAd->CommonCfg.Channel);
-
-       /* Resume MSDU which is turned off durning scan */
-       RTMPResumeMsduTransmission(pAd);
-
-       {
-               /* Set all state machines back IDLE */
-               pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
-               pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
-               pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
-               pAd->Mlme.AuthRspMachine.CurrState = AUTH_RSP_IDLE;
-               pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
-               pAd->Mlme.ActMachine.CurrState = ACT_IDLE;
-       }
-
-#ifdef RTMP_MAC_PCI
-       /* Remove running state */
-       NdisAcquireSpinLock(&pAd->Mlme.TaskLock);
-       pAd->Mlme.bRunning = FALSE;
-       NdisReleaseSpinLock(&pAd->Mlme.TaskLock);
-#endif /* RTMP_MAC_PCI // */
-}
-
-/*! \brief     test if the MLME Queue is empty
- *     \param  *Queue    The MLME Queue
- *     \return TRUE if the Queue is empty, FALSE otherwise
- *     \pre
- *     \post
-
- IRQL = DISPATCH_LEVEL
-
- */
-BOOLEAN MlmeQueueEmpty(struct rt_mlme_queue *Queue)
-{
-       BOOLEAN Ans;
-
-       NdisAcquireSpinLock(&(Queue->Lock));
-       Ans = (Queue->Num == 0);
-       NdisReleaseSpinLock(&(Queue->Lock));
-
-       return Ans;
-}
-
-/*! \brief      test if the MLME Queue is full
- *     \param   *Queue          The MLME Queue
- *     \return  TRUE if the Queue is empty, FALSE otherwise
- *     \pre
- *     \post
-
- IRQL = PASSIVE_LEVEL
- IRQL = DISPATCH_LEVEL
-
- */
-BOOLEAN MlmeQueueFull(struct rt_mlme_queue *Queue)
-{
-       BOOLEAN Ans;
-
-       NdisAcquireSpinLock(&(Queue->Lock));
-       Ans = (Queue->Num == MAX_LEN_OF_MLME_QUEUE
-              || Queue->Entry[Queue->Tail].Occupied);
-       NdisReleaseSpinLock(&(Queue->Lock));
-
-       return Ans;
-}
-
-/*! \brief      The destructor of MLME Queue
- *     \param
- *     \return
- *     \pre
- *     \post
- *     \note   Clear Mlme Queue, Set Queue->Num to Zero.
-
- IRQL = PASSIVE_LEVEL
-
- */
-void MlmeQueueDestroy(struct rt_mlme_queue *pQueue)
-{
-       NdisAcquireSpinLock(&(pQueue->Lock));
-       pQueue->Num = 0;
-       pQueue->Head = 0;
-       pQueue->Tail = 0;
-       NdisReleaseSpinLock(&(pQueue->Lock));
-       NdisFreeSpinLock(&(pQueue->Lock));
-}
-
-/*! \brief      To substitute the message type if the message is coming from external
- *     \param  pFrame             The frame received
- *     \param  *Machine           The state machine
- *     \param  *MsgType           the message type for the state machine
- *     \return TRUE if the substitution is successful, FALSE otherwise
- *     \pre
- *     \post
-
- IRQL = DISPATCH_LEVEL
-
- */
-BOOLEAN MsgTypeSubst(struct rt_rtmp_adapter *pAd,
-                    struct rt_frame_802_11 * pFrame,
-                    int * Machine, int * MsgType)
-{
-       u16 Seq, Alg;
-       u8 EAPType;
-       u8 *pData;
-
-       /* Pointer to start of data frames including SNAP header */
-       pData = (u8 *)pFrame + LENGTH_802_11;
-
-       /* The only data type will pass to this function is EAPOL frame */
-       if (pFrame->Hdr.FC.Type == BTYPE_DATA) {
-               {
-                       *Machine = WPA_STATE_MACHINE;
-                       EAPType =
-                           *((u8 *) pFrame + LENGTH_802_11 +
-                             LENGTH_802_1_H + 1);
-                       return (WpaMsgTypeSubst(EAPType, (int *) MsgType));
-               }
-       }
-
-       switch (pFrame->Hdr.FC.SubType) {
-       case SUBTYPE_ASSOC_REQ:
-               *Machine = ASSOC_STATE_MACHINE;
-               *MsgType = MT2_PEER_ASSOC_REQ;
-               break;
-       case SUBTYPE_ASSOC_RSP:
-               *Machine = ASSOC_STATE_MACHINE;
-               *MsgType = MT2_PEER_ASSOC_RSP;
-               break;
-       case SUBTYPE_REASSOC_REQ:
-               *Machine = ASSOC_STATE_MACHINE;
-               *MsgType = MT2_PEER_REASSOC_REQ;
-               break;
-       case SUBTYPE_REASSOC_RSP:
-               *Machine = ASSOC_STATE_MACHINE;
-               *MsgType = MT2_PEER_REASSOC_RSP;
-               break;
-       case SUBTYPE_PROBE_REQ:
-               *Machine = SYNC_STATE_MACHINE;
-               *MsgType = MT2_PEER_PROBE_REQ;
-               break;
-       case SUBTYPE_PROBE_RSP:
-               *Machine = SYNC_STATE_MACHINE;
-               *MsgType = MT2_PEER_PROBE_RSP;
-               break;
-       case SUBTYPE_BEACON:
-               *Machine = SYNC_STATE_MACHINE;
-               *MsgType = MT2_PEER_BEACON;
-               break;
-       case SUBTYPE_ATIM:
-               *Machine = SYNC_STATE_MACHINE;
-               *MsgType = MT2_PEER_ATIM;
-               break;
-       case SUBTYPE_DISASSOC:
-               *Machine = ASSOC_STATE_MACHINE;
-               *MsgType = MT2_PEER_DISASSOC_REQ;
-               break;
-       case SUBTYPE_AUTH:
-               /* get the sequence number from payload 24 Mac Header + 2 bytes algorithm */
-               NdisMoveMemory(&Seq, &pFrame->Octet[2], sizeof(u16));
-               NdisMoveMemory(&Alg, &pFrame->Octet[0], sizeof(u16));
-               if (Seq == 1 || Seq == 3) {
-                       *Machine = AUTH_RSP_STATE_MACHINE;
-                       *MsgType = MT2_PEER_AUTH_ODD;
-               } else if (Seq == 2 || Seq == 4) {
-                       if (Alg == AUTH_MODE_OPEN || Alg == AUTH_MODE_KEY) {
-                               *Machine = AUTH_STATE_MACHINE;
-                               *MsgType = MT2_PEER_AUTH_EVEN;
-                       }
-               } else {
-                       return FALSE;
-               }
-               break;
-       case SUBTYPE_DEAUTH:
-               *Machine = AUTH_RSP_STATE_MACHINE;
-               *MsgType = MT2_PEER_DEAUTH;
-               break;
-       case SUBTYPE_ACTION:
-               *Machine = ACTION_STATE_MACHINE;
-               /*  Sometimes Sta will return with category bytes with MSB = 1, if they receive catogory out of their support */
-               if ((pFrame->Octet[0] & 0x7F) > MAX_PEER_CATE_MSG) {
-                       *MsgType = MT2_ACT_INVALID;
-               } else {
-                       *MsgType = (pFrame->Octet[0] & 0x7F);
-               }
-               break;
-       default:
-               return FALSE;
-               break;
-       }
-
-       return TRUE;
-}
-
-/* =========================================================================================== */
-/* state_machine.c */
-/* =========================================================================================== */
-
-/*! \brief Initialize the state machine.
- *     \param *S                       pointer to the state machine
- *     \param  Trans           State machine transition function
- *     \param  StNr            number of states
- *     \param  MsgNr           number of messages
- *     \param  DefFunc         default function, when there is invalid state/message combination
- *     \param  InitState       initial state of the state machine
- *     \param  Base            StateMachine base, internal use only
- *     \pre p_sm should be a legal pointer
- *     \post
-
- IRQL = PASSIVE_LEVEL
-
- */
-void StateMachineInit(struct rt_state_machine *S,
-                     IN STATE_MACHINE_FUNC Trans[],
-                     unsigned long StNr,
-                     unsigned long MsgNr,
-                     IN STATE_MACHINE_FUNC DefFunc,
-                     unsigned long InitState, unsigned long Base)
-{
-       unsigned long i, j;
-
-       /* set number of states and messages */
-       S->NrState = StNr;
-       S->NrMsg = MsgNr;
-       S->Base = Base;
-
-       S->TransFunc = Trans;
-
-       /* init all state transition to default function */
-       for (i = 0; i < StNr; i++) {
-               for (j = 0; j < MsgNr; j++) {
-                       S->TransFunc[i * MsgNr + j] = DefFunc;
-               }
-       }
-
-       /* set the starting state */
-       S->CurrState = InitState;
-}
-
-/*! \brief This function fills in the function pointer into the cell in the state machine
- *     \param *S       pointer to the state machine
- *     \param St       state
- *     \param Msg      incoming message
- *     \param f        the function to be executed when (state, message) combination occurs at the state machine
- *     \pre *S should be a legal pointer to the state machine, st, msg, should be all within the range, Base should be set in the initial state
- *     \post
-
- IRQL = PASSIVE_LEVEL
-
- */
-void StateMachineSetAction(struct rt_state_machine *S,
-                          unsigned long St,
-                          unsigned long Msg, IN STATE_MACHINE_FUNC Func)
-{
-       unsigned long MsgIdx;
-
-       MsgIdx = Msg - S->Base;
-
-       if (St < S->NrState && MsgIdx < S->NrMsg) {
-               /* boundary checking before setting the action */
-               S->TransFunc[St * S->NrMsg + MsgIdx] = Func;
-       }
-}
-
-/*! \brief      This function does the state transition
- *     \param   *Adapter the NIC adapter pointer
- *     \param   *S       the state machine
- *     \param   *Elem    the message to be executed
- *     \return   None
-
- IRQL = DISPATCH_LEVEL
-
- */
-void StateMachinePerformAction(struct rt_rtmp_adapter *pAd,
-                              struct rt_state_machine *S, struct rt_mlme_queue_elem *Elem)
-{
-       (*(S->TransFunc[S->CurrState * S->NrMsg + Elem->MsgType - S->Base]))
-           (pAd, Elem);
-}
-
-/*
-       ==========================================================================
-       Description:
-               The drop function, when machine executes this, the message is simply
-               ignored. This function does nothing, the message is freed in
-               StateMachinePerformAction()
-       ==========================================================================
- */
-void Drop(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
-{
-}
-
-/* =========================================================================================== */
-/* lfsr.c */
-/* =========================================================================================== */
-
-/*
-       ==========================================================================
-       Description:
-
-       IRQL = PASSIVE_LEVEL
-
-       ==========================================================================
- */
-void LfsrInit(struct rt_rtmp_adapter *pAd, unsigned long Seed)
-{
-       if (Seed == 0)
-               pAd->Mlme.ShiftReg = 1;
-       else
-               pAd->Mlme.ShiftReg = Seed;
-}
-
-/*
-       ==========================================================================
-       Description:
-       ==========================================================================
- */
-u8 RandomByte(struct rt_rtmp_adapter *pAd)
-{
-       unsigned long i;
-       u8 R, Result;
-
-       R = 0;
-
-       if (pAd->Mlme.ShiftReg == 0)
-               NdisGetSystemUpTime((unsigned long *) & pAd->Mlme.ShiftReg);
-
-       for (i = 0; i < 8; i++) {
-               if (pAd->Mlme.ShiftReg & 0x00000001) {
-                       pAd->Mlme.ShiftReg =
-                           ((pAd->Mlme.
-                             ShiftReg ^ LFSR_MASK) >> 1) | 0x80000000;
-                       Result = 1;
-               } else {
-                       pAd->Mlme.ShiftReg = pAd->Mlme.ShiftReg >> 1;
-                       Result = 0;
-               }
-               R = (R << 1) | Result;
-       }
-
-       return R;
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Verify the support rate for different PHY type
-
-       Arguments:
-               pAd                             Pointer to our adapter
-
-       Return Value:
-               None
-
-       IRQL = PASSIVE_LEVEL
-
-       ========================================================================
-*/
-void RTMPCheckRates(struct rt_rtmp_adapter *pAd,
-                   IN u8 SupRate[], IN u8 * SupRateLen)
-{
-       u8 RateIdx, i, j;
-       u8 NewRate[12], NewRateLen;
-
-       NewRateLen = 0;
-
-       if (pAd->CommonCfg.PhyMode == PHY_11B)
-               RateIdx = 4;
-       else
-               RateIdx = 12;
-
-       /* Check for support rates exclude basic rate bit */
-       for (i = 0; i < *SupRateLen; i++)
-               for (j = 0; j < RateIdx; j++)
-                       if ((SupRate[i] & 0x7f) == RateIdTo500Kbps[j])
-                               NewRate[NewRateLen++] = SupRate[i];
-
-       *SupRateLen = NewRateLen;
-       NdisMoveMemory(SupRate, NewRate, NewRateLen);
-}
-
-BOOLEAN RTMPCheckChannel(struct rt_rtmp_adapter *pAd,
-                        u8 CentralChannel, u8 Channel)
-{
-       u8 k;
-       u8 UpperChannel = 0, LowerChannel = 0;
-       u8 NoEffectChannelinList = 0;
-
-       /* Find upper and lower channel according to 40MHz current operation. */
-       if (CentralChannel < Channel) {
-               UpperChannel = Channel;
-               if (CentralChannel > 2)
-                       LowerChannel = CentralChannel - 2;
-               else
-                       return FALSE;
-       } else if (CentralChannel > Channel) {
-               UpperChannel = CentralChannel + 2;
-               LowerChannel = Channel;
-       }
-
-       for (k = 0; k < pAd->ChannelListNum; k++) {
-               if (pAd->ChannelList[k].Channel == UpperChannel) {
-                       NoEffectChannelinList++;
-               }
-               if (pAd->ChannelList[k].Channel == LowerChannel) {
-                       NoEffectChannelinList++;
-               }
-       }
-
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("Total Channel in Channel List = [%d]\n",
-                 NoEffectChannelinList));
-       if (NoEffectChannelinList == 2)
-               return TRUE;
-       else
-               return FALSE;
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Verify the support rate for HT phy type
-
-       Arguments:
-               pAd                             Pointer to our adapter
-
-       Return Value:
-               FALSE if pAd->CommonCfg.SupportedHtPhy doesn't accept the pHtCapability.  (AP Mode)
-
-       IRQL = PASSIVE_LEVEL
-
-       ========================================================================
-*/
-BOOLEAN RTMPCheckHt(struct rt_rtmp_adapter *pAd,
-                   u8 Wcid,
-                   struct rt_ht_capability_ie * pHtCapability,
-                   struct rt_add_ht_info_ie * pAddHtInfo)
-{
-       if (Wcid >= MAX_LEN_OF_MAC_TABLE)
-               return FALSE;
-
-       /* If use AMSDU, set flag. */
-       if (pAd->CommonCfg.DesiredHtPhy.AmsduEnable)
-               CLIENT_STATUS_SET_FLAG(&pAd->MacTab.Content[Wcid],
-                                      fCLIENT_STATUS_AMSDU_INUSED);
-       /* Save Peer Capability */
-       if (pHtCapability->HtCapInfo.ShortGIfor20)
-               CLIENT_STATUS_SET_FLAG(&pAd->MacTab.Content[Wcid],
-                                      fCLIENT_STATUS_SGI20_CAPABLE);
-       if (pHtCapability->HtCapInfo.ShortGIfor40)
-               CLIENT_STATUS_SET_FLAG(&pAd->MacTab.Content[Wcid],
-                                      fCLIENT_STATUS_SGI40_CAPABLE);
-       if (pHtCapability->HtCapInfo.TxSTBC)
-               CLIENT_STATUS_SET_FLAG(&pAd->MacTab.Content[Wcid],
-                                      fCLIENT_STATUS_TxSTBC_CAPABLE);
-       if (pHtCapability->HtCapInfo.RxSTBC)
-               CLIENT_STATUS_SET_FLAG(&pAd->MacTab.Content[Wcid],
-                                      fCLIENT_STATUS_RxSTBC_CAPABLE);
-       if (pAd->CommonCfg.bRdg && pHtCapability->ExtHtCapInfo.RDGSupport) {
-               CLIENT_STATUS_SET_FLAG(&pAd->MacTab.Content[Wcid],
-                                      fCLIENT_STATUS_RDG_CAPABLE);
-       }
-
-       if (Wcid < MAX_LEN_OF_MAC_TABLE) {
-               pAd->MacTab.Content[Wcid].MpduDensity =
-                   pHtCapability->HtCapParm.MpduDensity;
-       }
-       /* Will check ChannelWidth for MCSSet[4] below */
-       pAd->MlmeAux.HtCapability.MCSSet[4] = 0x1;
-       switch (pAd->CommonCfg.RxStream) {
-       case 1:
-               pAd->MlmeAux.HtCapability.MCSSet[0] = 0xff;
-               pAd->MlmeAux.HtCapability.MCSSet[1] = 0x00;
-               pAd->MlmeAux.HtCapability.MCSSet[2] = 0x00;
-               pAd->MlmeAux.HtCapability.MCSSet[3] = 0x00;
-               break;
-       case 2:
-               pAd->MlmeAux.HtCapability.MCSSet[0] = 0xff;
-               pAd->MlmeAux.HtCapability.MCSSet[1] = 0xff;
-               pAd->MlmeAux.HtCapability.MCSSet[2] = 0x00;
-               pAd->MlmeAux.HtCapability.MCSSet[3] = 0x00;
-               break;
-       case 3:
-               pAd->MlmeAux.HtCapability.MCSSet[0] = 0xff;
-               pAd->MlmeAux.HtCapability.MCSSet[1] = 0xff;
-               pAd->MlmeAux.HtCapability.MCSSet[2] = 0xff;
-               pAd->MlmeAux.HtCapability.MCSSet[3] = 0x00;
-               break;
-       }
-
-       pAd->MlmeAux.HtCapability.HtCapInfo.ChannelWidth =
-           pAddHtInfo->AddHtInfo.RecomWidth & pAd->CommonCfg.DesiredHtPhy.
-           ChannelWidth;
-
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("RTMPCheckHt:: HtCapInfo.ChannelWidth=%d, RecomWidth=%d, DesiredHtPhy.ChannelWidth=%d, BW40MAvailForA/G=%d/%d, PhyMode=%d \n",
-                 pAd->MlmeAux.HtCapability.HtCapInfo.ChannelWidth,
-                 pAddHtInfo->AddHtInfo.RecomWidth,
-                 pAd->CommonCfg.DesiredHtPhy.ChannelWidth,
-                 pAd->NicConfig2.field.BW40MAvailForA,
-                 pAd->NicConfig2.field.BW40MAvailForG,
-                 pAd->CommonCfg.PhyMode));
-
-       pAd->MlmeAux.HtCapability.HtCapInfo.GF =
-           pHtCapability->HtCapInfo.GF & pAd->CommonCfg.DesiredHtPhy.GF;
-
-       /* Send Assoc Req with my HT capability. */
-       pAd->MlmeAux.HtCapability.HtCapInfo.AMsduSize =
-           pAd->CommonCfg.DesiredHtPhy.AmsduSize;
-       pAd->MlmeAux.HtCapability.HtCapInfo.MimoPs =
-           pAd->CommonCfg.DesiredHtPhy.MimoPs;
-       pAd->MlmeAux.HtCapability.HtCapInfo.ShortGIfor20 =
-           (pAd->CommonCfg.DesiredHtPhy.ShortGIfor20) & (pHtCapability->
-                                                         HtCapInfo.
-                                                         ShortGIfor20);
-       pAd->MlmeAux.HtCapability.HtCapInfo.ShortGIfor40 =
-           (pAd->CommonCfg.DesiredHtPhy.ShortGIfor40) & (pHtCapability->
-                                                         HtCapInfo.
-                                                         ShortGIfor40);
-       pAd->MlmeAux.HtCapability.HtCapInfo.TxSTBC =
-           (pAd->CommonCfg.DesiredHtPhy.TxSTBC) & (pHtCapability->HtCapInfo.
-                                                   RxSTBC);
-       pAd->MlmeAux.HtCapability.HtCapInfo.RxSTBC =
-           (pAd->CommonCfg.DesiredHtPhy.RxSTBC) & (pHtCapability->HtCapInfo.
-                                                   TxSTBC);
-       pAd->MlmeAux.HtCapability.HtCapParm.MaxRAmpduFactor =
-           pAd->CommonCfg.DesiredHtPhy.MaxRAmpduFactor;
-       pAd->MlmeAux.HtCapability.HtCapParm.MpduDensity =
-           pAd->CommonCfg.HtCapability.HtCapParm.MpduDensity;
-       pAd->MlmeAux.HtCapability.ExtHtCapInfo.PlusHTC =
-           pHtCapability->ExtHtCapInfo.PlusHTC;
-       pAd->MacTab.Content[Wcid].HTCapability.ExtHtCapInfo.PlusHTC =
-           pHtCapability->ExtHtCapInfo.PlusHTC;
-       if (pAd->CommonCfg.bRdg) {
-               pAd->MlmeAux.HtCapability.ExtHtCapInfo.RDGSupport =
-                   pHtCapability->ExtHtCapInfo.RDGSupport;
-               pAd->MlmeAux.HtCapability.ExtHtCapInfo.PlusHTC = 1;
-       }
-
-       if (pAd->MlmeAux.HtCapability.HtCapInfo.ChannelWidth == BW_20)
-               pAd->MlmeAux.HtCapability.MCSSet[4] = 0x0;      /* BW20 can't transmit MCS32 */
-
-       COPY_AP_HTSETTINGS_FROM_BEACON(pAd, pHtCapability);
-       return TRUE;
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Verify the support rate for different PHY type
-
-       Arguments:
-               pAd                             Pointer to our adapter
-
-       Return Value:
-               None
-
-       IRQL = PASSIVE_LEVEL
-
-       ========================================================================
-*/
-void RTMPUpdateMlmeRate(struct rt_rtmp_adapter *pAd)
-{
-       u8 MinimumRate;
-       u8 ProperMlmeRate;      /*= RATE_54; */
-       u8 i, j, RateIdx = 12;  /*1, 2, 5.5, 11, 6, 9, 12, 18, 24, 36, 48, 54 */
-       BOOLEAN bMatch = FALSE;
-
-       switch (pAd->CommonCfg.PhyMode) {
-       case PHY_11B:
-               ProperMlmeRate = RATE_11;
-               MinimumRate = RATE_1;
-               break;
-       case PHY_11BG_MIXED:
-       case PHY_11ABGN_MIXED:
-       case PHY_11BGN_MIXED:
-               if ((pAd->MlmeAux.SupRateLen == 4) &&
-                   (pAd->MlmeAux.ExtRateLen == 0))
-                       /* B only AP */
-                       ProperMlmeRate = RATE_11;
-               else
-                       ProperMlmeRate = RATE_24;
-
-               if (pAd->MlmeAux.Channel <= 14)
-                       MinimumRate = RATE_1;
-               else
-                       MinimumRate = RATE_6;
-               break;
-       case PHY_11A:
-       case PHY_11N_2_4G:      /* rt2860 need to check mlmerate for 802.11n */
-       case PHY_11GN_MIXED:
-       case PHY_11AGN_MIXED:
-       case PHY_11AN_MIXED:
-       case PHY_11N_5G:
-               ProperMlmeRate = RATE_24;
-               MinimumRate = RATE_6;
-               break;
-       case PHY_11ABG_MIXED:
-               ProperMlmeRate = RATE_24;
-               if (pAd->MlmeAux.Channel <= 14)
-                       MinimumRate = RATE_1;
-               else
-                       MinimumRate = RATE_6;
-               break;
-       default:                /* error */
-               ProperMlmeRate = RATE_1;
-               MinimumRate = RATE_1;
-               break;
-       }
-
-       for (i = 0; i < pAd->MlmeAux.SupRateLen; i++) {
-               for (j = 0; j < RateIdx; j++) {
-                       if ((pAd->MlmeAux.SupRate[i] & 0x7f) ==
-                           RateIdTo500Kbps[j]) {
-                               if (j == ProperMlmeRate) {
-                                       bMatch = TRUE;
-                                       break;
-                               }
-                       }
-               }
-
-               if (bMatch)
-                       break;
-       }
-
-       if (bMatch == FALSE) {
-               for (i = 0; i < pAd->MlmeAux.ExtRateLen; i++) {
-                       for (j = 0; j < RateIdx; j++) {
-                               if ((pAd->MlmeAux.ExtRate[i] & 0x7f) ==
-                                   RateIdTo500Kbps[j]) {
-                                       if (j == ProperMlmeRate) {
-                                               bMatch = TRUE;
-                                               break;
-                                       }
-                               }
-                       }
-
-                       if (bMatch)
-                               break;
-               }
-       }
-
-       if (bMatch == FALSE) {
-               ProperMlmeRate = MinimumRate;
-       }
-
-       pAd->CommonCfg.MlmeRate = MinimumRate;
-       pAd->CommonCfg.RtsRate = ProperMlmeRate;
-       if (pAd->CommonCfg.MlmeRate >= RATE_6) {
-               pAd->CommonCfg.MlmeTransmit.field.MODE = MODE_OFDM;
-               pAd->CommonCfg.MlmeTransmit.field.MCS =
-                   OfdmRateToRxwiMCS[pAd->CommonCfg.MlmeRate];
-               pAd->MacTab.Content[BSS0Mcast_WCID].HTPhyMode.field.MODE =
-                   MODE_OFDM;
-               pAd->MacTab.Content[BSS0Mcast_WCID].HTPhyMode.field.MCS =
-                   OfdmRateToRxwiMCS[pAd->CommonCfg.MlmeRate];
-       } else {
-               pAd->CommonCfg.MlmeTransmit.field.MODE = MODE_CCK;
-               pAd->CommonCfg.MlmeTransmit.field.MCS = pAd->CommonCfg.MlmeRate;
-               pAd->MacTab.Content[BSS0Mcast_WCID].HTPhyMode.field.MODE =
-                   MODE_CCK;
-               pAd->MacTab.Content[BSS0Mcast_WCID].HTPhyMode.field.MCS =
-                   pAd->CommonCfg.MlmeRate;
-       }
-
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("RTMPUpdateMlmeRate ==>   MlmeTransmit = 0x%x  \n",
-                 pAd->CommonCfg.MlmeTransmit.word));
-}
-
-char RTMPMaxRssi(struct rt_rtmp_adapter *pAd,
-                char Rssi0, char Rssi1, char Rssi2)
-{
-       char larger = -127;
-
-       if ((pAd->Antenna.field.RxPath == 1) && (Rssi0 != 0)) {
-               larger = Rssi0;
-       }
-
-       if ((pAd->Antenna.field.RxPath >= 2) && (Rssi1 != 0)) {
-               larger = max(Rssi0, Rssi1);
-       }
-
-       if ((pAd->Antenna.field.RxPath == 3) && (Rssi2 != 0)) {
-               larger = max(larger, Rssi2);
-       }
-
-       if (larger == -127)
-               larger = 0;
-
-       return larger;
-}
-
-/*
-    ========================================================================
-    Routine Description:
-        Periodic evaluate antenna link status
-
-    Arguments:
-        pAd         - Adapter pointer
-
-    Return Value:
-        None
-
-    ========================================================================
-*/
-void AsicEvaluateRxAnt(struct rt_rtmp_adapter *pAd)
-{
-       u8 BBPR3 = 0;
-
-       if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS |
-                          fRTMP_ADAPTER_HALT_IN_PROGRESS |
-                          fRTMP_ADAPTER_RADIO_OFF |
-                          fRTMP_ADAPTER_NIC_NOT_EXIST |
-                          fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS) ||
-           OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE)
-#ifdef RT30xx
-           || (pAd->EepromAccess)
-#endif /* RT30xx // */
-#ifdef RT3090
-           || (pAd->bPCIclkOff == TRUE)
-#endif /* RT3090 // */
-           )
-               return;
-
-       {
-               /*if (pAd->StaCfg.Psm == PWR_SAVE) */
-               /*      return; */
-
-               {
-
-                       if (pAd->StaCfg.Psm == PWR_SAVE)
-                               return;
-
-                       RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &BBPR3);
-                       BBPR3 &= (~0x18);
-                       if (pAd->Antenna.field.RxPath == 3) {
-                               BBPR3 |= (0x10);
-                       } else if (pAd->Antenna.field.RxPath == 2) {
-                               BBPR3 |= (0x8);
-                       } else if (pAd->Antenna.field.RxPath == 1) {
-                               BBPR3 |= (0x0);
-                       }
-                       RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BBPR3);
-#ifdef RTMP_MAC_PCI
-                       pAd->StaCfg.BBPR3 = BBPR3;
-#endif /* RTMP_MAC_PCI // */
-                       if (OPSTATUS_TEST_FLAG
-                           (pAd, fOP_STATUS_MEDIA_STATE_CONNECTED)
-                           ) {
-                               unsigned long TxTotalCnt =
-                                   pAd->RalinkCounters.OneSecTxNoRetryOkCount +
-                                   pAd->RalinkCounters.OneSecTxRetryOkCount +
-                                   pAd->RalinkCounters.OneSecTxFailCount;
-
-                               /* dynamic adjust antenna evaluation period according to the traffic */
-                               if (TxTotalCnt > 50) {
-                                       RTMPSetTimer(&pAd->Mlme.RxAntEvalTimer,
-                                                    20);
-                                       pAd->Mlme.bLowThroughput = FALSE;
-                               } else {
-                                       RTMPSetTimer(&pAd->Mlme.RxAntEvalTimer,
-                                                    300);
-                                       pAd->Mlme.bLowThroughput = TRUE;
-                               }
-                       }
-               }
-
-       }
-
-}
-
-/*
-    ========================================================================
-    Routine Description:
-        After evaluation, check antenna link status
-
-    Arguments:
-        pAd         - Adapter pointer
-
-    Return Value:
-        None
-
-    ========================================================================
-*/
-void AsicRxAntEvalTimeout(void *SystemSpecific1,
-                         void *FunctionContext,
-                         void *SystemSpecific2, void *SystemSpecific3)
-{
-       struct rt_rtmp_adapter *pAd = (struct rt_rtmp_adapter *)FunctionContext;
-       u8 BBPR3 = 0;
-       char larger = -127, rssi0, rssi1, rssi2;
-
-       if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS |
-                          fRTMP_ADAPTER_HALT_IN_PROGRESS |
-                          fRTMP_ADAPTER_RADIO_OFF |
-                          fRTMP_ADAPTER_NIC_NOT_EXIST) ||
-           OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE)
-#ifdef RT30xx
-           || (pAd->EepromAccess)
-#endif /* RT30xx // */
-#ifdef RT3090
-           || (pAd->bPCIclkOff == TRUE)
-#endif /* RT3090 // */
-           )
-               return;
-
-       {
-               /*if (pAd->StaCfg.Psm == PWR_SAVE) */
-               /*      return; */
-               {
-                       if (pAd->StaCfg.Psm == PWR_SAVE)
-                               return;
-
-                       /* if the traffic is low, use average rssi as the criteria */
-                       if (pAd->Mlme.bLowThroughput == TRUE) {
-                               rssi0 = pAd->StaCfg.RssiSample.LastRssi0;
-                               rssi1 = pAd->StaCfg.RssiSample.LastRssi1;
-                               rssi2 = pAd->StaCfg.RssiSample.LastRssi2;
-                       } else {
-                               rssi0 = pAd->StaCfg.RssiSample.AvgRssi0;
-                               rssi1 = pAd->StaCfg.RssiSample.AvgRssi1;
-                               rssi2 = pAd->StaCfg.RssiSample.AvgRssi2;
-                       }
-
-                       if (pAd->Antenna.field.RxPath == 3) {
-                               larger = max(rssi0, rssi1);
-
-                               if (larger > (rssi2 + 20))
-                                       pAd->Mlme.RealRxPath = 2;
-                               else
-                                       pAd->Mlme.RealRxPath = 3;
-                       } else if (pAd->Antenna.field.RxPath == 2) {
-                               if (rssi0 > (rssi1 + 20))
-                                       pAd->Mlme.RealRxPath = 1;
-                               else
-                                       pAd->Mlme.RealRxPath = 2;
-                       }
-
-                       RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &BBPR3);
-                       BBPR3 &= (~0x18);
-                       if (pAd->Mlme.RealRxPath == 3) {
-                               BBPR3 |= (0x10);
-                       } else if (pAd->Mlme.RealRxPath == 2) {
-                               BBPR3 |= (0x8);
-                       } else if (pAd->Mlme.RealRxPath == 1) {
-                               BBPR3 |= (0x0);
-                       }
-                       RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BBPR3);
-#ifdef RTMP_MAC_PCI
-                       pAd->StaCfg.BBPR3 = BBPR3;
-#endif /* RTMP_MAC_PCI // */
-               }
-       }
-
-}
-
-void APSDPeriodicExec(void *SystemSpecific1,
-                     void *FunctionContext,
-                     void *SystemSpecific2, void *SystemSpecific3)
-{
-       struct rt_rtmp_adapter *pAd = (struct rt_rtmp_adapter *)FunctionContext;
-
-       if (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED))
-               return;
-
-       pAd->CommonCfg.TriggerTimerCount++;
-
-/* Driver should not send trigger frame, it should be send by application layer */
-/*
-       if (pAd->CommonCfg.bAPSDCapable && pAd->CommonCfg.APEdcaParm.bAPSDCapable
-               && (pAd->CommonCfg.bNeedSendTriggerFrame ||
-               (((pAd->CommonCfg.TriggerTimerCount%20) == 19) && (!pAd->CommonCfg.bAPSDAC_BE || !pAd->CommonCfg.bAPSDAC_BK || !pAd->CommonCfg.bAPSDAC_VI || !pAd->CommonCfg.bAPSDAC_VO))))
-       {
-               DBGPRINT(RT_DEBUG_TRACE,("Sending trigger frame and enter service period when support APSD\n"));
-               RTMPSendNullFrame(pAd, pAd->CommonCfg.TxRate, TRUE);
-               pAd->CommonCfg.bNeedSendTriggerFrame = FALSE;
-               pAd->CommonCfg.TriggerTimerCount = 0;
-               pAd->CommonCfg.bInServicePeriod = TRUE;
-       }*/
-}
-
-/*
-    ========================================================================
-    Routine Description:
-        Set/reset MAC registers according to bPiggyBack parameter
-
-    Arguments:
-        pAd         - Adapter pointer
-        bPiggyBack  - Enable / Disable Piggy-Back
-
-    Return Value:
-        None
-
-    ========================================================================
-*/
-void RTMPSetPiggyBack(struct rt_rtmp_adapter *pAd, IN BOOLEAN bPiggyBack)
-{
-       TX_LINK_CFG_STRUC TxLinkCfg;
-
-       RTMP_IO_READ32(pAd, TX_LINK_CFG, &TxLinkCfg.word);
-
-       TxLinkCfg.field.TxCFAckEn = bPiggyBack;
-       RTMP_IO_WRITE32(pAd, TX_LINK_CFG, TxLinkCfg.word);
-}
-
-/*
-    ========================================================================
-    Routine Description:
-        check if this entry need to switch rate automatically
-
-    Arguments:
-        pAd
-        pEntry
-
-    Return Value:
-        TURE
-        FALSE
-
-    ========================================================================
-*/
-BOOLEAN RTMPCheckEntryEnableAutoRateSwitch(struct rt_rtmp_adapter *pAd,
-                                          struct rt_mac_table_entry *pEntry)
-{
-       BOOLEAN result = TRUE;
-
-       {
-               /* only associated STA counts */
-               if (pEntry && (pEntry->ValidAsCLI)
-                   && (pEntry->Sst == SST_ASSOC)) {
-                       result = pAd->StaCfg.bAutoTxRateSwitch;
-               } else
-                       result = FALSE;
-       }
-
-       return result;
-}
-
-BOOLEAN RTMPAutoRateSwitchCheck(struct rt_rtmp_adapter *pAd)
-{
-       {
-               if (pAd->StaCfg.bAutoTxRateSwitch)
-                       return TRUE;
-       }
-       return FALSE;
-}
-
-/*
-    ========================================================================
-    Routine Description:
-        check if this entry need to fix tx legacy rate
-
-    Arguments:
-        pAd
-        pEntry
-
-    Return Value:
-        TURE
-        FALSE
-
-    ========================================================================
-*/
-u8 RTMPStaFixedTxMode(struct rt_rtmp_adapter *pAd, struct rt_mac_table_entry *pEntry)
-{
-       u8 tx_mode = FIXED_TXMODE_HT;
-
-       {
-               tx_mode =
-                   (u8)pAd->StaCfg.DesiredTransmitSetting.field.
-                   FixedTxMode;
-       }
-
-       return tx_mode;
-}
-
-/*
-    ========================================================================
-    Routine Description:
-        Overwrite HT Tx Mode by Fixed Legency Tx Mode, if specified.
-
-    Arguments:
-        pAd
-        pEntry
-
-    Return Value:
-        TURE
-        FALSE
-
-    ========================================================================
-*/
-void RTMPUpdateLegacyTxSetting(u8 fixed_tx_mode, struct rt_mac_table_entry *pEntry)
-{
-       HTTRANSMIT_SETTING TransmitSetting;
-
-       if (fixed_tx_mode == FIXED_TXMODE_HT)
-               return;
-
-       TransmitSetting.word = 0;
-
-       TransmitSetting.field.MODE = pEntry->HTPhyMode.field.MODE;
-       TransmitSetting.field.MCS = pEntry->HTPhyMode.field.MCS;
-
-       if (fixed_tx_mode == FIXED_TXMODE_CCK) {
-               TransmitSetting.field.MODE = MODE_CCK;
-               /* CCK mode allow MCS 0~3 */
-               if (TransmitSetting.field.MCS > MCS_3)
-                       TransmitSetting.field.MCS = MCS_3;
-       } else {
-               TransmitSetting.field.MODE = MODE_OFDM;
-               /* OFDM mode allow MCS 0~7 */
-               if (TransmitSetting.field.MCS > MCS_7)
-                       TransmitSetting.field.MCS = MCS_7;
-       }
-
-       if (pEntry->HTPhyMode.field.MODE >= TransmitSetting.field.MODE) {
-               pEntry->HTPhyMode.word = TransmitSetting.word;
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("RTMPUpdateLegacyTxSetting : wcid-%d, MODE=%s, MCS=%d \n",
-                         pEntry->Aid, GetPhyMode(pEntry->HTPhyMode.field.MODE),
-                         pEntry->HTPhyMode.field.MCS));
-       }
-}
-
-/*
-       ==========================================================================
-       Description:
-               dynamic tune BBP R66 to find a balance between sensibility and
-               noise isolation
-
-       IRQL = DISPATCH_LEVEL
-
-       ==========================================================================
- */
-void AsicStaBbpTuning(struct rt_rtmp_adapter *pAd)
-{
-       u8 OrigR66Value = 0, R66;       /*, R66UpperBound = 0x30, R66LowerBound = 0x30; */
-       char Rssi;
-
-       /* 2860C did not support Fase CCA, therefore can't tune */
-       if (pAd->MACVersion == 0x28600100)
-               return;
-
-       /* */
-       /* work as a STA */
-       /* */
-       if (pAd->Mlme.CntlMachine.CurrState != CNTL_IDLE)       /* no R66 tuning when SCANNING */
-               return;
-
-       if ((pAd->OpMode == OPMODE_STA)
-           && (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED)
-           )
-           && !(OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))
-#ifdef RTMP_MAC_PCI
-           && (pAd->bPCIclkOff == FALSE)
-#endif /* RTMP_MAC_PCI // */
-           ) {
-               RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R66, &OrigR66Value);
-               R66 = OrigR66Value;
-
-               if (pAd->Antenna.field.RxPath > 1)
-                       Rssi =
-                           (pAd->StaCfg.RssiSample.AvgRssi0 +
-                            pAd->StaCfg.RssiSample.AvgRssi1) >> 1;
-               else
-                       Rssi = pAd->StaCfg.RssiSample.AvgRssi0;
-
-               if (pAd->LatchRfRegs.Channel <= 14) {   /*BG band */
-#ifdef RT30xx
-                       /* RT3070 is a no LNA solution, it should have different control regarding to AGC gain control */
-                       /* Otherwise, it will have some throughput side effect when low RSSI */
-
-                       if (IS_RT3070(pAd) || IS_RT3090(pAd) || IS_RT3572(pAd)
-                           || IS_RT3390(pAd)) {
-                               if (Rssi > RSSI_FOR_MID_LOW_SENSIBILITY) {
-                                       R66 =
-                                           0x1C + 2 * GET_LNA_GAIN(pAd) + 0x20;
-                                       if (OrigR66Value != R66) {
-                                               RTMP_BBP_IO_WRITE8_BY_REG_ID
-                                                   (pAd, BBP_R66, R66);
-                                       }
-                               } else {
-                                       R66 = 0x1C + 2 * GET_LNA_GAIN(pAd);
-                                       if (OrigR66Value != R66) {
-                                               RTMP_BBP_IO_WRITE8_BY_REG_ID
-                                                   (pAd, BBP_R66, R66);
-                                       }
-                               }
-                       } else
-#endif /* RT30xx // */
-                       {
-                               if (Rssi > RSSI_FOR_MID_LOW_SENSIBILITY) {
-                                       R66 = (0x2E + GET_LNA_GAIN(pAd)) + 0x10;
-                                       if (OrigR66Value != R66) {
-                                               RTMP_BBP_IO_WRITE8_BY_REG_ID
-                                                   (pAd, BBP_R66, R66);
-                                       }
-                               } else {
-                                       R66 = 0x2E + GET_LNA_GAIN(pAd);
-                                       if (OrigR66Value != R66) {
-                                               RTMP_BBP_IO_WRITE8_BY_REG_ID
-                                                   (pAd, BBP_R66, R66);
-                                       }
-                               }
-                       }
-               } else {        /*A band */
-                       if (pAd->CommonCfg.BBPCurrentBW == BW_20) {
-                               if (Rssi > RSSI_FOR_MID_LOW_SENSIBILITY) {
-                                       R66 =
-                                           0x32 + (GET_LNA_GAIN(pAd) * 5) / 3 +
-                                           0x10;
-                                       if (OrigR66Value != R66) {
-                                               RTMP_BBP_IO_WRITE8_BY_REG_ID
-                                                   (pAd, BBP_R66, R66);
-                                       }
-                               } else {
-                                       R66 =
-                                           0x32 + (GET_LNA_GAIN(pAd) * 5) / 3;
-                                       if (OrigR66Value != R66) {
-                                               RTMP_BBP_IO_WRITE8_BY_REG_ID
-                                                   (pAd, BBP_R66, R66);
-                                       }
-                               }
-                       } else {
-                               if (Rssi > RSSI_FOR_MID_LOW_SENSIBILITY) {
-                                       R66 =
-                                           0x3A + (GET_LNA_GAIN(pAd) * 5) / 3 +
-                                           0x10;
-                                       if (OrigR66Value != R66) {
-                                               RTMP_BBP_IO_WRITE8_BY_REG_ID
-                                                   (pAd, BBP_R66, R66);
-                                       }
-                               } else {
-                                       R66 =
-                                           0x3A + (GET_LNA_GAIN(pAd) * 5) / 3;
-                                       if (OrigR66Value != R66) {
-                                               RTMP_BBP_IO_WRITE8_BY_REG_ID
-                                                   (pAd, BBP_R66, R66);
-                                       }
-                               }
-                       }
-               }
-
-       }
-}
-
-void RTMPSetAGCInitValue(struct rt_rtmp_adapter *pAd, u8 BandWidth)
-{
-       u8 R66 = 0x30;
-
-       if (pAd->LatchRfRegs.Channel <= 14) {   /* BG band */
-#ifdef RT30xx
-               /* Gary was verified Amazon AP and find that RT307x has BBP_R66 invalid default value */
-
-               if (IS_RT3070(pAd) || IS_RT3090(pAd) || IS_RT3572(pAd)
-                   || IS_RT3390(pAd)) {
-                       R66 = 0x1C + 2 * GET_LNA_GAIN(pAd);
-                       RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66, R66);
-               } else
-#endif /* RT30xx // */
-               {
-                       R66 = 0x2E + GET_LNA_GAIN(pAd);
-                       RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66, R66);
-               }
-       } else {                /*A band */
-               {
-                       if (BandWidth == BW_20) {
-                               R66 =
-                                   (u8)(0x32 +
-                                            (GET_LNA_GAIN(pAd) * 5) / 3);
-                               RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66, R66);
-                       } else {
-                               R66 =
-                                   (u8)(0x3A +
-                                            (GET_LNA_GAIN(pAd) * 5) / 3);
-                               RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66, R66);
-                       }
-               }
-       }
-
-}
diff --git a/drivers/staging/rt2860/common/rt_channel.c b/drivers/staging/rt2860/common/rt_channel.c
deleted file mode 100644 (file)
index 5387989..0000000
+++ /dev/null
@@ -1,1705 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-*/
-#include "../rt_config.h"
-
-struct rt_ch_freq_map CH_HZ_ID_MAP[] = {
-       {1, 2412}
-       ,
-       {2, 2417}
-       ,
-       {3, 2422}
-       ,
-       {4, 2427}
-       ,
-       {5, 2432}
-       ,
-       {6, 2437}
-       ,
-       {7, 2442}
-       ,
-       {8, 2447}
-       ,
-       {9, 2452}
-       ,
-       {10, 2457}
-       ,
-       {11, 2462}
-       ,
-       {12, 2467}
-       ,
-       {13, 2472}
-       ,
-       {14, 2484}
-       ,
-
-       /*  UNII */
-       {36, 5180}
-       ,
-       {40, 5200}
-       ,
-       {44, 5220}
-       ,
-       {48, 5240}
-       ,
-       {52, 5260}
-       ,
-       {56, 5280}
-       ,
-       {60, 5300}
-       ,
-       {64, 5320}
-       ,
-       {149, 5745}
-       ,
-       {153, 5765}
-       ,
-       {157, 5785}
-       ,
-       {161, 5805}
-       ,
-       {165, 5825}
-       ,
-       {167, 5835}
-       ,
-       {169, 5845}
-       ,
-       {171, 5855}
-       ,
-       {173, 5865}
-       ,
-
-       /* HiperLAN2 */
-       {100, 5500}
-       ,
-       {104, 5520}
-       ,
-       {108, 5540}
-       ,
-       {112, 5560}
-       ,
-       {116, 5580}
-       ,
-       {120, 5600}
-       ,
-       {124, 5620}
-       ,
-       {128, 5640}
-       ,
-       {132, 5660}
-       ,
-       {136, 5680}
-       ,
-       {140, 5700}
-       ,
-
-       /* Japan MMAC */
-       {34, 5170}
-       ,
-       {38, 5190}
-       ,
-       {42, 5210}
-       ,
-       {46, 5230}
-       ,
-
-       /*  Japan */
-       {184, 4920}
-       ,
-       {188, 4940}
-       ,
-       {192, 4960}
-       ,
-       {196, 4980}
-       ,
-
-       {208, 5040}
-       ,                       /* Japan, means J08 */
-       {212, 5060}
-       ,                       /* Japan, means J12 */
-       {216, 5080}
-       ,                       /* Japan, means J16 */
-};
-
-int CH_HZ_ID_MAP_NUM = (sizeof(CH_HZ_ID_MAP) / sizeof(struct rt_ch_freq_map));
-
-struct rt_ch_region ChRegion[] = {
-       {                       /* Antigua and Berbuda */
-        "AG",
-        CE,
-        {
-         {1, 13, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~13 */
-         {36, 4, 23, BOTH, FALSE}
-         ,                     /* 5G, ch 36~48 */
-         {52, 4, 23, BOTH, FALSE}
-         ,                     /* 5G, ch 52~64 */
-         {100, 11, 30, BOTH, FALSE}
-         ,                     /* 5G, ch 100~140 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* Argentina */
-        "AR",
-        CE,
-        {
-         {1, 13, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~13 */
-         {52, 4, 24, BOTH, FALSE}
-         ,                     /* 5G, ch 52~64 */
-         {149, 4, 30, BOTH, FALSE}
-         ,                     /* 5G, ch 149~161 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* Aruba */
-        "AW",
-        CE,
-        {
-         {1, 13, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~13 */
-         {36, 4, 23, BOTH, FALSE}
-         ,                     /* 5G, ch 36~48 */
-         {52, 4, 23, BOTH, FALSE}
-         ,                     /* 5G, ch 52~64 */
-         {100, 11, 30, BOTH, FALSE}
-         ,                     /* 5G, ch 100~140 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* Australia */
-        "AU",
-        CE,
-        {
-         {1, 13, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~13 */
-         {36, 4, 23, BOTH, FALSE}
-         ,                     /* 5G, ch 36~48 */
-         {52, 4, 24, BOTH, FALSE}
-         ,                     /* 5G, ch 52~64 */
-         {149, 5, 30, BOTH, FALSE}
-         ,                     /* 5G, ch 149~165 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* Austria */
-        "AT",
-        CE,
-        {
-         {1, 13, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~13 */
-         {36, 4, 23, IDOR, TRUE}
-         ,                     /* 5G, ch 36~48 */
-         {52, 4, 23, IDOR, TRUE}
-         ,                     /* 5G, ch 52~64 */
-         {100, 11, 30, BOTH, TRUE}
-         ,                     /* 5G, ch 100~140 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* Bahamas */
-        "BS",
-        CE,
-        {
-         {1, 13, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~13 */
-         {36, 4, 23, BOTH, FALSE}
-         ,                     /* 5G, ch 36~48 */
-         {52, 4, 24, BOTH, FALSE}
-         ,                     /* 5G, ch 52~64 */
-         {149, 5, 30, BOTH, FALSE}
-         ,                     /* 5G, ch 149~165 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* Barbados */
-        "BB",
-        CE,
-        {
-         {1, 13, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~13 */
-         {36, 4, 23, BOTH, FALSE}
-         ,                     /* 5G, ch 36~48 */
-         {52, 4, 24, BOTH, FALSE}
-         ,                     /* 5G, ch 52~64 */
-         {100, 11, 30, BOTH, FALSE}
-         ,                     /* 5G, ch 100~140 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* Bermuda */
-        "BM",
-        CE,
-        {
-         {1, 13, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~13 */
-         {36, 4, 23, BOTH, FALSE}
-         ,                     /* 5G, ch 36~48 */
-         {52, 4, 24, BOTH, FALSE}
-         ,                     /* 5G, ch 52~64 */
-         {100, 11, 30, BOTH, FALSE}
-         ,                     /* 5G, ch 100~140 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* Brazil */
-        "BR",
-        CE,
-        {
-         {1, 13, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~13 */
-         {36, 4, 23, BOTH, FALSE}
-         ,                     /* 5G, ch 36~48 */
-         {52, 4, 24, BOTH, FALSE}
-         ,                     /* 5G, ch 52~64 */
-         {100, 11, 24, BOTH, FALSE}
-         ,                     /* 5G, ch 100~140 */
-         {149, 5, 30, BOTH, FALSE}
-         ,                     /* 5G, ch 100~140 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* Belgium */
-        "BE",
-        CE,
-        {
-         {1, 13, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~13 */
-         {36, 4, 18, IDOR, FALSE}
-         ,                     /* 5G, ch 36~48 */
-         {52, 4, 18, IDOR, FALSE}
-         ,                     /* 5G, ch 52~64 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* Bulgaria */
-        "BG",
-        CE,
-        {
-         {1, 13, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~13 */
-         {36, 4, 23, IDOR, FALSE}
-         ,                     /* 5G, ch 36~48 */
-         {52, 4, 23, IDOR, TRUE}
-         ,                     /* 5G, ch 52~64 */
-         {100, 11, 30, ODOR, TRUE}
-         ,                     /* 5G, ch 100~140 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* Canada */
-        "CA",
-        CE,
-        {
-         {1, 13, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~13 */
-         {36, 4, 23, BOTH, FALSE}
-         ,                     /* 5G, ch 36~48 */
-         {52, 4, 23, BOTH, FALSE}
-         ,                     /* 5G, ch 52~64 */
-         {149, 5, 30, BOTH, FALSE}
-         ,                     /* 5G, ch 149~165 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* Cayman IsLands */
-        "KY",
-        CE,
-        {
-         {1, 13, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~13 */
-         {36, 4, 23, BOTH, FALSE}
-         ,                     /* 5G, ch 36~48 */
-         {52, 4, 24, BOTH, FALSE}
-         ,                     /* 5G, ch 52~64 */
-         {100, 11, 30, BOTH, FALSE}
-         ,                     /* 5G, ch 100~140 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* Chile */
-        "CL",
-        CE,
-        {
-         {1, 13, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~13 */
-         {36, 4, 20, BOTH, FALSE}
-         ,                     /* 5G, ch 36~48 */
-         {52, 4, 20, BOTH, FALSE}
-         ,                     /* 5G, ch 52~64 */
-         {149, 5, 20, BOTH, FALSE}
-         ,                     /* 5G, ch 149~165 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* China */
-        "CN",
-        CE,
-        {
-         {1, 13, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~13 */
-         {149, 4, 27, BOTH, FALSE}
-         ,                     /* 5G, ch 149~161 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* Colombia */
-        "CO",
-        CE,
-        {
-         {1, 13, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~13 */
-         {36, 4, 17, BOTH, FALSE}
-         ,                     /* 5G, ch 36~48 */
-         {52, 4, 24, BOTH, FALSE}
-         ,                     /* 5G, ch 52~64 */
-         {100, 11, 30, BOTH, FALSE}
-         ,                     /* 5G, ch 100~140 */
-         {149, 5, 30, BOTH, FALSE}
-         ,                     /* 5G, ch 149~165 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* Costa Rica */
-        "CR",
-        CE,
-        {
-         {1, 13, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~13 */
-         {36, 4, 17, BOTH, FALSE}
-         ,                     /* 5G, ch 36~48 */
-         {52, 4, 24, BOTH, FALSE}
-         ,                     /* 5G, ch 52~64 */
-         {149, 4, 30, BOTH, FALSE}
-         ,                     /* 5G, ch 149~161 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* Cyprus */
-        "CY",
-        CE,
-        {
-         {1, 13, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~13 */
-         {36, 4, 23, IDOR, FALSE}
-         ,                     /* 5G, ch 36~48 */
-         {52, 4, 24, IDOR, TRUE}
-         ,                     /* 5G, ch 52~64 */
-         {100, 11, 30, BOTH, TRUE}
-         ,                     /* 5G, ch 100~140 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* Czech_Republic */
-        "CZ",
-        CE,
-        {
-         {1, 13, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~13 */
-         {36, 4, 23, IDOR, FALSE}
-         ,                     /* 5G, ch 36~48 */
-         {52, 4, 23, IDOR, TRUE}
-         ,                     /* 5G, ch 52~64 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* Denmark */
-        "DK",
-        CE,
-        {
-         {1, 13, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~13 */
-         {36, 4, 23, IDOR, FALSE}
-         ,                     /* 5G, ch 36~48 */
-         {52, 4, 23, IDOR, TRUE}
-         ,                     /* 5G, ch 52~64 */
-         {100, 11, 30, BOTH, TRUE}
-         ,                     /* 5G, ch 100~140 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* Dominican Republic */
-        "DO",
-        CE,
-        {
-         {1, 0, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 0 */
-         {149, 4, 20, BOTH, FALSE}
-         ,                     /* 5G, ch 149~161 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* Equador */
-        "EC",
-        CE,
-        {
-         {1, 13, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~13 */
-         {100, 11, 27, BOTH, FALSE}
-         ,                     /* 5G, ch 100~140 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* El Salvador */
-        "SV",
-        CE,
-        {
-         {1, 13, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~13 */
-         {36, 4, 23, IDOR, FALSE}
-         ,                     /* 5G, ch 36~48 */
-         {52, 4, 30, BOTH, TRUE}
-         ,                     /* 5G, ch 52~64 */
-         {149, 4, 36, BOTH, TRUE}
-         ,                     /* 5G, ch 149~165 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* Finland */
-        "FI",
-        CE,
-        {
-         {1, 13, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~13 */
-         {36, 4, 23, IDOR, FALSE}
-         ,                     /* 5G, ch 36~48 */
-         {52, 4, 23, IDOR, TRUE}
-         ,                     /* 5G, ch 52~64 */
-         {100, 11, 30, BOTH, TRUE}
-         ,                     /* 5G, ch 100~140 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* France */
-        "FR",
-        CE,
-        {
-         {1, 13, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~13 */
-         {36, 4, 23, IDOR, FALSE}
-         ,                     /* 5G, ch 36~48 */
-         {52, 4, 23, IDOR, TRUE}
-         ,                     /* 5G, ch 52~64 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* Germany */
-        "DE",
-        CE,
-        {
-         {1, 13, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~13 */
-         {36, 4, 23, IDOR, FALSE}
-         ,                     /* 5G, ch 36~48 */
-         {52, 4, 23, IDOR, TRUE}
-         ,                     /* 5G, ch 52~64 */
-         {100, 11, 30, BOTH, TRUE}
-         ,                     /* 5G, ch 100~140 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* Greece */
-        "GR",
-        CE,
-        {
-         {1, 13, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~13 */
-         {36, 4, 23, IDOR, FALSE}
-         ,                     /* 5G, ch 36~48 */
-         {52, 4, 23, IDOR, TRUE}
-         ,                     /* 5G, ch 52~64 */
-         {100, 11, 30, ODOR, TRUE}
-         ,                     /* 5G, ch 100~140 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* Guam */
-        "GU",
-        CE,
-        {
-         {1, 11, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~11 */
-         {36, 4, 17, BOTH, FALSE}
-         ,                     /* 5G, ch 36~48 */
-         {52, 4, 24, BOTH, FALSE}
-         ,                     /* 5G, ch 52~64 */
-         {100, 11, 30, BOTH, FALSE}
-         ,                     /* 5G, ch 100~140 */
-         {149, 5, 30, BOTH, FALSE}
-         ,                     /* 5G, ch 149~165 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* Guatemala */
-        "GT",
-        CE,
-        {
-         {1, 13, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~13 */
-         {36, 4, 17, BOTH, FALSE}
-         ,                     /* 5G, ch 36~48 */
-         {52, 4, 24, BOTH, FALSE}
-         ,                     /* 5G, ch 52~64 */
-         {149, 4, 30, BOTH, FALSE}
-         ,                     /* 5G, ch 149~161 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* Haiti */
-        "HT",
-        CE,
-        {
-         {1, 13, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~13 */
-         {36, 4, 17, BOTH, FALSE}
-         ,                     /* 5G, ch 36~48 */
-         {52, 4, 24, BOTH, FALSE}
-         ,                     /* 5G, ch 52~64 */
-         {149, 4, 30, BOTH, FALSE}
-         ,                     /* 5G, ch 149~161 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* Honduras */
-        "HN",
-        CE,
-        {
-         {1, 13, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~13 */
-         {149, 4, 27, BOTH, FALSE}
-         ,                     /* 5G, ch 149~161 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* Hong Kong */
-        "HK",
-        CE,
-        {
-         {1, 13, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~13 */
-         {36, 4, 23, IDOR, FALSE}
-         ,                     /* 5G, ch 36~48 */
-         {52, 4, 23, IDOR, FALSE}
-         ,                     /* 5G, ch 52~64 */
-         {149, 4, 30, BOTH, FALSE}
-         ,                     /* 5G, ch 149~161 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* Hungary */
-        "HU",
-        CE,
-        {
-         {1, 13, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~13 */
-         {36, 4, 23, IDOR, FALSE}
-         ,                     /* 5G, ch 36~48 */
-         {52, 4, 23, IDOR, TRUE}
-         ,                     /* 5G, ch 52~64 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* Iceland */
-        "IS",
-        CE,
-        {
-         {1, 13, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~13 */
-         {36, 4, 23, IDOR, FALSE}
-         ,                     /* 5G, ch 36~48 */
-         {52, 4, 23, IDOR, TRUE}
-         ,                     /* 5G, ch 52~64 */
-         {100, 11, 30, BOTH, TRUE}
-         ,                     /* 5G, ch 100~140 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* India */
-        "IN",
-        CE,
-        {
-         {1, 13, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~13 */
-         {149, 4, 24, IDOR, FALSE}
-         ,                     /* 5G, ch 149~161 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* Indonesia */
-        "ID",
-        CE,
-        {
-         {1, 13, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~13 */
-         {149, 4, 27, BOTH, FALSE}
-         ,                     /* 5G, ch 149~161 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* Ireland */
-        "IE",
-        CE,
-        {
-         {1, 13, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~13 */
-         {36, 4, 23, IDOR, FALSE}
-         ,                     /* 5G, ch 36~48 */
-         {52, 4, 23, IDOR, TRUE}
-         ,                     /* 5G, ch 52~64 */
-         {100, 11, 30, ODOR, TRUE}
-         ,                     /* 5G, ch 100~140 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* Israel */
-        "IL",
-        CE,
-        {
-         {1, 3, 20, IDOR, FALSE}
-         ,                     /* 2.4 G, ch 1~3 */
-         {4, 6, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 4~9 */
-         {10, 4, 20, IDOR, FALSE}
-         ,                     /* 2.4 G, ch 10~13 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* Italy */
-        "IT",
-        CE,
-        {
-         {1, 13, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~13 */
-         {36, 4, 23, IDOR, FALSE}
-         ,                     /* 5G, ch 36~48 */
-         {52, 4, 23, IDOR, TRUE}
-         ,                     /* 5G, ch 52~64 */
-         {100, 11, 30, ODOR, TRUE}
-         ,                     /* 5G, ch 100~140 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* Japan */
-        "JP",
-        JAP,
-        {
-         {1, 14, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~14 */
-         {36, 4, 23, IDOR, FALSE}
-         ,                     /* 5G, ch 36~48 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* Jordan */
-        "JO",
-        CE,
-        {
-         {1, 13, 20, IDOR, FALSE}
-         ,                     /* 2.4 G, ch 1~13 */
-         {36, 4, 23, IDOR, FALSE}
-         ,                     /* 5G, ch 36~48 */
-         {149, 4, 23, IDOR, FALSE}
-         ,                     /* 5G, ch 149~161 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* Latvia */
-        "LV",
-        CE,
-        {
-         {1, 13, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~13 */
-         {36, 4, 23, IDOR, FALSE}
-         ,                     /* 5G, ch 36~48 */
-         {52, 4, 23, IDOR, TRUE}
-         ,                     /* 5G, ch 52~64 */
-         {100, 11, 30, BOTH, TRUE}
-         ,                     /* 5G, ch 100~140 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* Liechtenstein */
-        "LI",
-        CE,
-        {
-         {1, 13, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~13 */
-         {52, 4, 23, IDOR, TRUE}
-         ,                     /* 5G, ch 52~64 */
-         {100, 11, 30, BOTH, TRUE}
-         ,                     /* 5G, ch 100~140 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* Lithuania */
-        "LT",
-        CE,
-        {
-         {1, 13, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~13 */
-         {36, 4, 23, IDOR, FALSE}
-         ,                     /* 5G, ch 36~48 */
-         {52, 4, 23, IDOR, TRUE}
-         ,                     /* 5G, ch 52~64 */
-         {100, 11, 30, BOTH, TRUE}
-         ,                     /* 5G, ch 100~140 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* Luxemburg */
-        "LU",
-        CE,
-        {
-         {1, 13, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~13 */
-         {36, 4, 23, IDOR, FALSE}
-         ,                     /* 5G, ch 36~48 */
-         {52, 4, 23, IDOR, TRUE}
-         ,                     /* 5G, ch 52~64 */
-         {100, 11, 30, BOTH, TRUE}
-         ,                     /* 5G, ch 100~140 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* Malaysia */
-        "MY",
-        CE,
-        {
-         {36, 4, 23, BOTH, FALSE}
-         ,                     /* 5G, ch 36~48 */
-         {52, 4, 23, BOTH, FALSE}
-         ,                     /* 5G, ch 52~64 */
-         {149, 5, 20, BOTH, FALSE}
-         ,                     /* 5G, ch 149~165 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* Malta */
-        "MT",
-        CE,
-        {
-         {1, 13, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~13 */
-         {36, 4, 23, IDOR, FALSE}
-         ,                     /* 5G, ch 36~48 */
-         {52, 4, 23, IDOR, TRUE}
-         ,                     /* 5G, ch 52~64 */
-         {100, 11, 30, BOTH, TRUE}
-         ,                     /* 5G, ch 100~140 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* Marocco */
-        "MA",
-        CE,
-        {
-         {1, 13, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~13 */
-         {36, 4, 24, IDOR, FALSE}
-         ,                     /* 5G, ch 36~48 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* Mexico */
-        "MX",
-        CE,
-        {
-         {1, 13, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~13 */
-         {36, 4, 23, BOTH, FALSE}
-         ,                     /* 5G, ch 36~48 */
-         {52, 4, 24, BOTH, FALSE}
-         ,                     /* 5G, ch 52~64 */
-         {149, 5, 30, IDOR, FALSE}
-         ,                     /* 5G, ch 149~165 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* Netherlands */
-        "NL",
-        CE,
-        {
-         {1, 13, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~13 */
-         {36, 4, 23, IDOR, FALSE}
-         ,                     /* 5G, ch 36~48 */
-         {52, 4, 24, IDOR, TRUE}
-         ,                     /* 5G, ch 52~64 */
-         {100, 11, 30, BOTH, TRUE}
-         ,                     /* 5G, ch 100~140 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* New Zealand */
-        "NZ",
-        CE,
-        {
-         {1, 13, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~13 */
-         {36, 4, 24, BOTH, FALSE}
-         ,                     /* 5G, ch 36~48 */
-         {52, 4, 24, BOTH, FALSE}
-         ,                     /* 5G, ch 52~64 */
-         {149, 4, 30, BOTH, FALSE}
-         ,                     /* 5G, ch 149~161 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* Norway */
-        "NO",
-        CE,
-        {
-         {1, 13, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~13 */
-         {36, 4, 24, IDOR, FALSE}
-         ,                     /* 5G, ch 36~48 */
-         {52, 4, 24, IDOR, TRUE}
-         ,                     /* 5G, ch 52~64 */
-         {100, 11, 30, BOTH, TRUE}
-         ,                     /* 5G, ch 149~161 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* Peru */
-        "PE",
-        CE,
-        {
-         {1, 13, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~13 */
-         {149, 4, 27, BOTH, FALSE}
-         ,                     /* 5G, ch 149~161 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* Portugal */
-        "PT",
-        CE,
-        {
-         {1, 13, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~13 */
-         {36, 4, 23, IDOR, FALSE}
-         ,                     /* 5G, ch 36~48 */
-         {52, 4, 23, IDOR, TRUE}
-         ,                     /* 5G, ch 52~64 */
-         {100, 11, 30, BOTH, TRUE}
-         ,                     /* 5G, ch 100~140 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* Poland */
-        "PL",
-        CE,
-        {
-         {1, 13, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~13 */
-         {36, 4, 23, IDOR, FALSE}
-         ,                     /* 5G, ch 36~48 */
-         {52, 4, 23, IDOR, TRUE}
-         ,                     /* 5G, ch 52~64 */
-         {100, 11, 30, BOTH, TRUE}
-         ,                     /* 5G, ch 100~140 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* Romania */
-        "RO",
-        CE,
-        {
-         {1, 13, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~13 */
-         {36, 4, 23, IDOR, FALSE}
-         ,                     /* 5G, ch 36~48 */
-         {52, 4, 23, IDOR, TRUE}
-         ,                     /* 5G, ch 52~64 */
-         {100, 11, 30, BOTH, TRUE}
-         ,                     /* 5G, ch 100~140 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* Russia */
-        "RU",
-        CE,
-        {
-         {1, 13, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~13 */
-         {149, 4, 20, IDOR, FALSE}
-         ,                     /* 5G, ch 149~161 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* Saudi Arabia */
-        "SA",
-        CE,
-        {
-         {1, 13, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~13 */
-         {36, 4, 23, BOTH, FALSE}
-         ,                     /* 5G, ch 36~48 */
-         {52, 4, 23, BOTH, FALSE}
-         ,                     /* 5G, ch 52~64 */
-         {149, 4, 23, BOTH, FALSE}
-         ,                     /* 5G, ch 149~161 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* Serbia_and_Montenegro */
-        "CS",
-        CE,
-        {
-         {1, 13, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~13 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* Singapore */
-        "SG",
-        CE,
-        {
-         {1, 13, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~13 */
-         {36, 4, 23, BOTH, FALSE}
-         ,                     /* 5G, ch 36~48 */
-         {52, 4, 23, BOTH, FALSE}
-         ,                     /* 5G, ch 52~64 */
-         {149, 4, 20, BOTH, FALSE}
-         ,                     /* 5G, ch 149~161 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* Slovakia */
-        "SK",
-        CE,
-        {
-         {1, 13, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~13 */
-         {36, 4, 23, IDOR, FALSE}
-         ,                     /* 5G, ch 36~48 */
-         {52, 4, 23, IDOR, TRUE}
-         ,                     /* 5G, ch 52~64 */
-         {100, 11, 30, BOTH, TRUE}
-         ,                     /* 5G, ch 100~140 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* Slovenia */
-        "SI",
-        CE,
-        {
-         {1, 13, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~13 */
-         {36, 4, 23, IDOR, FALSE}
-         ,                     /* 5G, ch 36~48 */
-         {52, 4, 23, IDOR, TRUE}
-         ,                     /* 5G, ch 52~64 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* South Africa */
-        "ZA",
-        CE,
-        {
-         {1, 13, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~13 */
-         {36, 4, 23, BOTH, FALSE}
-         ,                     /* 5G, ch 36~48 */
-         {52, 4, 23, IDOR, FALSE}
-         ,                     /* 5G, ch 52~64 */
-         {100, 11, 30, BOTH, TRUE}
-         ,                     /* 5G, ch 100~140 */
-         {149, 4, 30, BOTH, FALSE}
-         ,                     /* 5G, ch 149~161 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* South Korea */
-        "KR",
-        CE,
-        {
-         {1, 13, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~13 */
-         {36, 4, 20, BOTH, FALSE}
-         ,                     /* 5G, ch 36~48 */
-         {52, 4, 20, BOTH, FALSE}
-         ,                     /* 5G, ch 52~64 */
-         {100, 8, 20, BOTH, FALSE}
-         ,                     /* 5G, ch 100~128 */
-         {149, 4, 20, BOTH, FALSE}
-         ,                     /* 5G, ch 149~161 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* Spain */
-        "ES",
-        CE,
-        {
-         {1, 13, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~13 */
-         {36, 4, 17, IDOR, FALSE}
-         ,                     /* 5G, ch 36~48 */
-         {52, 4, 23, IDOR, TRUE}
-         ,                     /* 5G, ch 52~64 */
-         {100, 11, 30, BOTH, TRUE}
-         ,                     /* 5G, ch 100~140 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* Sweden */
-        "SE",
-        CE,
-        {
-         {1, 13, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~13 */
-         {36, 4, 23, IDOR, FALSE}
-         ,                     /* 5G, ch 36~48 */
-         {52, 4, 23, IDOR, TRUE}
-         ,                     /* 5G, ch 52~64 */
-         {100, 11, 30, BOTH, TRUE}
-         ,                     /* 5G, ch 100~140 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* Switzerland */
-        "CH",
-        CE,
-        {
-         {1, 13, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~13 */
-         {36, 4, 23, IDOR, TRUE}
-         ,                     /* 5G, ch 36~48 */
-         {52, 4, 23, IDOR, TRUE}
-         ,                     /* 5G, ch 52~64 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* Taiwan */
-        "TW",
-        CE,
-        {
-         {1, 11, 30, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~11 */
-         {52, 4, 23, IDOR, FALSE}
-         ,                     /* 5G, ch 52~64 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* Turkey */
-        "TR",
-        CE,
-        {
-         {1, 13, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~11 */
-         {36, 4, 23, BOTH, FALSE}
-         ,                     /* 5G, ch 36~48 */
-         {52, 4, 23, BOTH, FALSE}
-         ,                     /* 5G, ch 52~64 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* UK */
-        "GB",
-        CE,
-        {
-         {1, 13, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~11 */
-         {36, 4, 23, IDOR, FALSE}
-         ,                     /* 5G, ch 52~64 */
-         {52, 4, 23, IDOR, TRUE}
-         ,                     /* 5G, ch 52~64 */
-         {100, 11, 30, BOTH, TRUE}
-         ,                     /* 5G, ch 100~140 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* Ukraine */
-        "UA",
-        CE,
-        {
-         {1, 13, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~11 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* United_Arab_Emirates */
-        "AE",
-        CE,
-        {
-         {1, 13, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~11 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* United_States */
-        "US",
-        CE,
-        {
-         {1, 11, 30, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~11 */
-         {36, 4, 17, IDOR, FALSE}
-         ,                     /* 5G, ch 52~64 */
-         {52, 4, 24, BOTH, TRUE}
-         ,                     /* 5G, ch 52~64 */
-         {100, 11, 30, BOTH, TRUE}
-         ,                     /* 5G, ch 100~140 */
-         {149, 5, 30, BOTH, FALSE}
-         ,                     /* 5G, ch 149~165 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* Venezuela */
-        "VE",
-        CE,
-        {
-         {1, 13, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~11 */
-         {149, 4, 27, BOTH, FALSE}
-         ,                     /* 5G, ch 149~161 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-
-       {                       /* Default */
-        "",
-        CE,
-        {
-         {1, 11, 20, BOTH, FALSE}
-         ,                     /* 2.4 G, ch 1~11 */
-         {36, 4, 20, BOTH, FALSE}
-         ,                     /* 5G, ch 52~64 */
-         {52, 4, 20, BOTH, FALSE}
-         ,                     /* 5G, ch 52~64 */
-         {100, 11, 20, BOTH, FALSE}
-         ,                     /* 5G, ch 100~140 */
-         {149, 5, 20, BOTH, FALSE}
-         ,                     /* 5G, ch 149~165 */
-         {0}
-         ,                     /* end */
-         }
-        }
-       ,
-};
-
-static struct rt_ch_region *GetChRegion(u8 *CntryCode)
-{
-       int loop = 0;
-       struct rt_ch_region *pChRegion = NULL;
-
-       while (strcmp((char *)ChRegion[loop].CountReg, "") != 0) {
-               if (strncmp
-                   ((char *)ChRegion[loop].CountReg, (char *)CntryCode,
-                    2) == 0) {
-                       pChRegion = &ChRegion[loop];
-                       break;
-               }
-               loop++;
-       }
-
-       if (pChRegion == NULL)
-               pChRegion = &ChRegion[loop];
-       return pChRegion;
-}
-
-static void ChBandCheck(u8 PhyMode, u8 *pChType)
-{
-       switch (PhyMode) {
-       case PHY_11A:
-       case PHY_11AN_MIXED:
-               *pChType = BAND_5G;
-               break;
-       case PHY_11ABG_MIXED:
-       case PHY_11AGN_MIXED:
-       case PHY_11ABGN_MIXED:
-               *pChType = BAND_BOTH;
-               break;
-
-       default:
-               *pChType = BAND_24G;
-               break;
-       }
-}
-
-static u8 FillChList(struct rt_rtmp_adapter *pAd,
-                       struct rt_ch_desp *pChDesp,
-                       u8 Offset, u8 increment)
-{
-       int i, j, l;
-       u8 channel;
-
-       j = Offset;
-       for (i = 0; i < pChDesp->NumOfCh; i++) {
-               channel = pChDesp->FirstChannel + i * increment;
-               for (l = 0; l < MAX_NUM_OF_CHANNELS; l++) {
-                       if (channel == pAd->TxPower[l].Channel) {
-                               pAd->ChannelList[j].Power =
-                                   pAd->TxPower[l].Power;
-                               pAd->ChannelList[j].Power2 =
-                                   pAd->TxPower[l].Power2;
-                               break;
-                       }
-               }
-               if (l == MAX_NUM_OF_CHANNELS)
-                       continue;
-
-               pAd->ChannelList[j].Channel =
-                   pChDesp->FirstChannel + i * increment;
-               pAd->ChannelList[j].MaxTxPwr = pChDesp->MaxTxPwr;
-               pAd->ChannelList[j].DfsReq = pChDesp->DfsReq;
-               j++;
-       }
-       pAd->ChannelListNum = j;
-
-       return j;
-}
-
-static inline void CreateChList(struct rt_rtmp_adapter *pAd,
-                               struct rt_ch_region *pChRegion, u8 Geography)
-{
-       int i;
-       u8 offset = 0;
-       struct rt_ch_desp *pChDesp;
-       u8 ChType;
-       u8 increment;
-
-       if (pChRegion == NULL)
-               return;
-
-       ChBandCheck(pAd->CommonCfg.PhyMode, &ChType);
-
-       for (i = 0; i < 10; i++) {
-               pChDesp = &pChRegion->ChDesp[i];
-               if (pChDesp->FirstChannel == 0)
-                       break;
-
-               if (ChType == BAND_5G) {
-                       if (pChDesp->FirstChannel <= 14)
-                               continue;
-               } else if (ChType == BAND_24G) {
-                       if (pChDesp->FirstChannel > 14)
-                               continue;
-               }
-
-               if ((pChDesp->Geography == BOTH)
-                   || (pChDesp->Geography == Geography)) {
-                       if (pChDesp->FirstChannel > 14)
-                               increment = 4;
-                       else
-                               increment = 1;
-                       offset = FillChList(pAd, pChDesp, offset, increment);
-               }
-       }
-}
-
-void BuildChannelListEx(struct rt_rtmp_adapter *pAd)
-{
-       struct rt_ch_region *pChReg;
-
-       pChReg = GetChRegion(pAd->CommonCfg.CountryCode);
-       CreateChList(pAd, pChReg, pAd->CommonCfg.Geography);
-}
-
-void BuildBeaconChList(struct rt_rtmp_adapter *pAd,
-                      u8 *pBuf, unsigned long *pBufLen)
-{
-       int i;
-       unsigned long TmpLen;
-       struct rt_ch_region *pChRegion;
-       struct rt_ch_desp *pChDesp;
-       u8 ChType;
-
-       pChRegion = GetChRegion(pAd->CommonCfg.CountryCode);
-
-       if (pChRegion == NULL)
-               return;
-
-       ChBandCheck(pAd->CommonCfg.PhyMode, &ChType);
-       *pBufLen = 0;
-
-       for (i = 0; i < 10; i++) {
-               pChDesp = &pChRegion->ChDesp[i];
-               if (pChDesp->FirstChannel == 0)
-                       break;
-
-               if (ChType == BAND_5G) {
-                       if (pChDesp->FirstChannel <= 14)
-                               continue;
-               } else if (ChType == BAND_24G) {
-                       if (pChDesp->FirstChannel > 14)
-                               continue;
-               }
-
-               if ((pChDesp->Geography == BOTH)
-                   || (pChDesp->Geography == pAd->CommonCfg.Geography)) {
-                       MakeOutgoingFrame(pBuf + *pBufLen, &TmpLen,
-                                         1, &pChDesp->FirstChannel,
-                                         1, &pChDesp->NumOfCh,
-                                         1, &pChDesp->MaxTxPwr, END_OF_ARGS);
-                       *pBufLen += TmpLen;
-               }
-       }
-}
-
-static BOOLEAN IsValidChannel(struct rt_rtmp_adapter *pAd, u8 channel)
-{
-       int i;
-
-       for (i = 0; i < pAd->ChannelListNum; i++) {
-               if (pAd->ChannelList[i].Channel == channel)
-                       break;
-       }
-
-       if (i == pAd->ChannelListNum)
-               return FALSE;
-       else
-               return TRUE;
-}
-
-static u8 GetExtCh(u8 Channel, u8 Direction)
-{
-       char ExtCh;
-
-       if (Direction == EXTCHA_ABOVE)
-               ExtCh = Channel + 4;
-       else
-               ExtCh = (Channel - 4) > 0 ? (Channel - 4) : 0;
-
-       return ExtCh;
-}
-
-void N_ChannelCheck(struct rt_rtmp_adapter *pAd)
-{
-       /*u8 ChannelNum = pAd->ChannelListNum; */
-       u8 Channel = pAd->CommonCfg.Channel;
-
-       if ((pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)
-           && (pAd->CommonCfg.RegTransmitSetting.field.BW == BW_40)) {
-               if (Channel > 14) {
-                       if ((Channel == 36) || (Channel == 44)
-                           || (Channel == 52) || (Channel == 60)
-                           || (Channel == 100) || (Channel == 108)
-                           || (Channel == 116) || (Channel == 124)
-                           || (Channel == 132) || (Channel == 149)
-                           || (Channel == 157)) {
-                               pAd->CommonCfg.RegTransmitSetting.field.EXTCHA =
-                                   EXTCHA_ABOVE;
-                       } else if ((Channel == 40) || (Channel == 48)
-                                  || (Channel == 56) || (Channel == 64)
-                                  || (Channel == 104) || (Channel == 112)
-                                  || (Channel == 120) || (Channel == 128)
-                                  || (Channel == 136) || (Channel == 153)
-                                  || (Channel == 161)) {
-                               pAd->CommonCfg.RegTransmitSetting.field.EXTCHA =
-                                   EXTCHA_BELOW;
-                       } else {
-                               pAd->CommonCfg.RegTransmitSetting.field.BW =
-                                   BW_20;
-                       }
-               } else {
-                       do {
-                               u8 ExtCh;
-                               u8 Dir =
-                                   pAd->CommonCfg.RegTransmitSetting.field.
-                                   EXTCHA;
-                               ExtCh = GetExtCh(Channel, Dir);
-                               if (IsValidChannel(pAd, ExtCh))
-                                       break;
-
-                               Dir =
-                                   (Dir ==
-                                    EXTCHA_ABOVE) ? EXTCHA_BELOW :
-                                   EXTCHA_ABOVE;
-                               ExtCh = GetExtCh(Channel, Dir);
-                               if (IsValidChannel(pAd, ExtCh)) {
-                                       pAd->CommonCfg.RegTransmitSetting.field.
-                                           EXTCHA = Dir;
-                                       break;
-                               }
-                               pAd->CommonCfg.RegTransmitSetting.field.BW =
-                                   BW_20;
-                       } while (FALSE);
-
-                       if (Channel == 14) {
-                               pAd->CommonCfg.RegTransmitSetting.field.BW =
-                                   BW_20;
-                               /*pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = EXTCHA_NONE; // We didn't set the ExtCh as NONE due to it'll set in RTMPSetHT() */
-                       }
-               }
-       }
-
-}
-
-void N_SetCenCh(struct rt_rtmp_adapter *pAd)
-{
-       if (pAd->CommonCfg.RegTransmitSetting.field.BW == BW_40) {
-               if (pAd->CommonCfg.RegTransmitSetting.field.EXTCHA ==
-                   EXTCHA_ABOVE) {
-                       pAd->CommonCfg.CentralChannel =
-                           pAd->CommonCfg.Channel + 2;
-               } else {
-                       if (pAd->CommonCfg.Channel == 14)
-                               pAd->CommonCfg.CentralChannel =
-                                   pAd->CommonCfg.Channel - 1;
-                       else
-                               pAd->CommonCfg.CentralChannel =
-                                   pAd->CommonCfg.Channel - 2;
-               }
-       } else {
-               pAd->CommonCfg.CentralChannel = pAd->CommonCfg.Channel;
-       }
-}
-
-u8 GetCuntryMaxTxPwr(struct rt_rtmp_adapter *pAd, u8 channel)
-{
-       int i;
-       for (i = 0; i < pAd->ChannelListNum; i++) {
-               if (pAd->ChannelList[i].Channel == channel)
-                       break;
-       }
-
-       if (i == pAd->ChannelListNum)
-               return 0xff;
-       else
-               return pAd->ChannelList[i].MaxTxPwr;
-}
diff --git a/drivers/staging/rt2860/common/rt_rf.c b/drivers/staging/rt2860/common/rt_rf.c
deleted file mode 100644 (file)
index 2895447..0000000
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-       Module Name:
-       rt_rf.c
-
-       Abstract:
-       Ralink Wireless driver RF related functions
-
-       Revision History:
-       Who         When          What
-       --------    ----------    ----------------------------------------------
-*/
-
-#include "../rt_config.h"
-
-#ifdef RTMP_RF_RW_SUPPORT
-/*
-       ========================================================================
-
-       Routine Description: Write RT30xx RF register through MAC
-
-       Arguments:
-
-       Return Value:
-
-       IRQL =
-
-       Note:
-
-       ========================================================================
-*/
-int RT30xxWriteRFRegister(struct rt_rtmp_adapter *pAd,
-                                 u8 regID, u8 value)
-{
-       RF_CSR_CFG_STRUC rfcsr;
-       u32 i = 0;
-
-       do {
-               RTMP_IO_READ32(pAd, RF_CSR_CFG, &rfcsr.word);
-
-               if (!rfcsr.field.RF_CSR_KICK)
-                       break;
-               i++;
-       }
-       while ((i < RETRY_LIMIT)
-              && (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)));
-
-       if ((i == RETRY_LIMIT)
-           || (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST))) {
-               DBGPRINT_RAW(RT_DEBUG_ERROR,
-                            ("Retry count exhausted or device removed!\n"));
-               return STATUS_UNSUCCESSFUL;
-       }
-
-       rfcsr.field.RF_CSR_WR = 1;
-       rfcsr.field.RF_CSR_KICK = 1;
-       rfcsr.field.TESTCSR_RFACC_REGNUM = regID;
-       rfcsr.field.RF_CSR_DATA = value;
-
-       RTMP_IO_WRITE32(pAd, RF_CSR_CFG, rfcsr.word);
-
-       return NDIS_STATUS_SUCCESS;
-}
-
-/*
-       ========================================================================
-
-       Routine Description: Read RT30xx RF register through MAC
-
-       Arguments:
-
-       Return Value:
-
-       IRQL =
-
-       Note:
-
-       ========================================================================
-*/
-int RT30xxReadRFRegister(struct rt_rtmp_adapter *pAd,
-                                u8 regID, u8 *pValue)
-{
-       RF_CSR_CFG_STRUC rfcsr;
-       u32 i = 0, k = 0;
-
-       for (i = 0; i < MAX_BUSY_COUNT; i++) {
-               RTMP_IO_READ32(pAd, RF_CSR_CFG, &rfcsr.word);
-
-               if (rfcsr.field.RF_CSR_KICK == BUSY) {
-                       continue;
-               }
-               rfcsr.word = 0;
-               rfcsr.field.RF_CSR_WR = 0;
-               rfcsr.field.RF_CSR_KICK = 1;
-               rfcsr.field.TESTCSR_RFACC_REGNUM = regID;
-               RTMP_IO_WRITE32(pAd, RF_CSR_CFG, rfcsr.word);
-               for (k = 0; k < MAX_BUSY_COUNT; k++) {
-                       RTMP_IO_READ32(pAd, RF_CSR_CFG, &rfcsr.word);
-
-                       if (rfcsr.field.RF_CSR_KICK == IDLE)
-                               break;
-               }
-               if ((rfcsr.field.RF_CSR_KICK == IDLE) &&
-                   (rfcsr.field.TESTCSR_RFACC_REGNUM == regID)) {
-                       *pValue = (u8)rfcsr.field.RF_CSR_DATA;
-                       break;
-               }
-       }
-       if (rfcsr.field.RF_CSR_KICK == BUSY) {
-               DBGPRINT_ERR("RF read R%d=0x%x fail, i[%d], k[%d]\n", regID, rfcsr.word, i, k);
-               return STATUS_UNSUCCESSFUL;
-       }
-
-       return STATUS_SUCCESS;
-}
-
-void NICInitRFRegisters(struct rt_rtmp_adapter *pAd)
-{
-       if (pAd->chipOps.AsicRfInit)
-               pAd->chipOps.AsicRfInit(pAd);
-}
-
-void RtmpChipOpsRFHook(struct rt_rtmp_adapter *pAd)
-{
-       struct rt_rtmp_chip_op *pChipOps = &pAd->chipOps;
-
-       pChipOps->pRFRegTable = NULL;
-       pChipOps->AsicRfInit = NULL;
-       pChipOps->AsicRfTurnOn = NULL;
-       pChipOps->AsicRfTurnOff = NULL;
-       pChipOps->AsicReverseRfFromSleepMode = NULL;
-       pChipOps->AsicHaltAction = NULL;
-       /* We depends on RfICType and MACVersion to assign the corresponding operation callbacks. */
-
-#ifdef RT30xx
-       if (IS_RT30xx(pAd)) {
-               pChipOps->pRFRegTable = RT30xx_RFRegTable;
-               pChipOps->AsicHaltAction = RT30xxHaltAction;
-#ifdef RT3070
-               if ((IS_RT3070(pAd) || IS_RT3071(pAd))
-                   && (pAd->infType == RTMP_DEV_INF_USB)) {
-                       pChipOps->AsicRfInit = NICInitRT3070RFRegisters;
-                       if (IS_RT3071(pAd)) {
-                               pChipOps->AsicRfTurnOff =
-                                   RT30xxLoadRFSleepModeSetup;
-                               pChipOps->AsicReverseRfFromSleepMode =
-                                   RT30xxReverseRFSleepModeSetup;
-                       }
-               }
-#endif /* RT3070 // */
-#ifdef RT3090
-               if (IS_RT3090(pAd) && (pAd->infType == RTMP_DEV_INF_PCI)) {
-                       pChipOps->AsicRfTurnOff = RT30xxLoadRFSleepModeSetup;
-                       pChipOps->AsicRfInit = NICInitRT3090RFRegisters;
-                       pChipOps->AsicReverseRfFromSleepMode =
-                           RT30xxReverseRFSleepModeSetup;
-               }
-#endif /* RT3090 // */
-       }
-#endif /* RT30xx // */
-}
-
-#endif /* RTMP_RF_RW_SUPPORT // */
diff --git a/drivers/staging/rt2860/common/rtmp_init.c b/drivers/staging/rt2860/common/rtmp_init.c
deleted file mode 100644 (file)
index 5fa193e..0000000
+++ /dev/null
@@ -1,3536 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-       Module Name:
-       rtmp_init.c
-
-       Abstract:
-       Miniport generic portion header file
-
-       Revision History:
-       Who         When          What
-       --------    ----------    ----------------------------------------------
-*/
-#include "../rt_config.h"
-
-u8 BIT8[] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 };
-char *CipherName[] =
-    { "none", "wep64", "wep128", "TKIP", "AES", "CKIP64", "CKIP128" };
-
-/* */
-/* BBP register initialization set */
-/* */
-struct rt_reg_pair BBPRegTable[] = {
-       {BBP_R65, 0x2C},        /* fix rssi issue */
-       {BBP_R66, 0x38},        /* Also set this default value to pAd->BbpTuning.R66CurrentValue at initial */
-       {BBP_R69, 0x12},
-       {BBP_R70, 0xa},         /* BBP_R70 will change to 0x8 in ApStartUp and LinkUp for rt2860C, otherwise value is 0xa */
-       {BBP_R73, 0x10},
-       {BBP_R81, 0x37},
-       {BBP_R82, 0x62},
-       {BBP_R83, 0x6A},
-       {BBP_R84, 0x99},        /* 0x19 is for rt2860E and after. This is for extension channel overlapping IOT. 0x99 is for rt2860D and before */
-       {BBP_R86, 0x00},        /* middle range issue, Rory @2008-01-28 */
-       {BBP_R91, 0x04},        /* middle range issue, Rory @2008-01-28 */
-       {BBP_R92, 0x00},        /* middle range issue, Rory @2008-01-28 */
-       {BBP_R103, 0x00},       /* near range high-power issue, requested from Gary @2008-0528 */
-       {BBP_R105, 0x05},       /* 0x05 is for rt2860E to turn on FEQ control. It is safe for rt2860D and before, because Bit 7:2 are reserved in rt2860D and before. */
-       {BBP_R106, 0x35},       /* for ShortGI throughput */
-};
-
-#define        NUM_BBP_REG_PARMS       (sizeof(BBPRegTable) / sizeof(struct rt_reg_pair))
-
-/* */
-/* ASIC register initialization sets */
-/* */
-
-struct rt_rtmp_reg_pair MACRegTable[] = {
-#if defined(HW_BEACON_OFFSET) && (HW_BEACON_OFFSET == 0x200)
-       {BCN_OFFSET0, 0xf8f0e8e0},      /* 0x3800(e0), 0x3A00(e8), 0x3C00(f0), 0x3E00(f8), 512B for each beacon */
-       {BCN_OFFSET1, 0x6f77d0c8},      /* 0x3200(c8), 0x3400(d0), 0x1DC0(77), 0x1BC0(6f), 512B for each beacon */
-#elif defined(HW_BEACON_OFFSET) && (HW_BEACON_OFFSET == 0x100)
-       {BCN_OFFSET0, 0xece8e4e0},      /* 0x3800, 0x3A00, 0x3C00, 0x3E00, 512B for each beacon */
-       {BCN_OFFSET1, 0xfcf8f4f0},      /* 0x3800, 0x3A00, 0x3C00, 0x3E00, 512B for each beacon */
-#else
-#error You must re-calculate new value for BCN_OFFSET0 & BCN_OFFSET1 in MACRegTable[]!
-#endif /* HW_BEACON_OFFSET // */
-
-       {LEGACY_BASIC_RATE, 0x0000013f},        /*  Basic rate set bitmap */
-       {HT_BASIC_RATE, 0x00008003},    /* Basic HT rate set , 20M, MCS=3, MM. Format is the same as in TXWI. */
-       {MAC_SYS_CTRL, 0x00},   /* 0x1004, , default Disable RX */
-       {RX_FILTR_CFG, 0x17f97},        /*0x1400  , RX filter control, */
-       {BKOFF_SLOT_CFG, 0x209},        /* default set short slot time, CC_DELAY_TIME should be 2 */
-       /*{TX_SW_CFG0,          0x40a06}, // Gary,2006-08-23 */
-       {TX_SW_CFG0, 0x0},      /* Gary,2008-05-21 for CWC test */
-       {TX_SW_CFG1, 0x80606},  /* Gary,2006-08-23 */
-       {TX_LINK_CFG, 0x1020},  /* Gary,2006-08-23 */
-       /*{TX_TIMEOUT_CFG,      0x00182090},    // CCK has some problem. So increase timieout value. 2006-10-09// MArvek RT */
-       {TX_TIMEOUT_CFG, 0x000a2090},   /* CCK has some problem. So increase timieout value. 2006-10-09// MArvek RT , Modify for 2860E ,2007-08-01 */
-       {MAX_LEN_CFG, MAX_AGGREGATION_SIZE | 0x00001000},       /* 0x3018, MAX frame length. Max PSDU = 16kbytes. */
-       {LED_CFG, 0x7f031e46},  /* Gary, 2006-08-23 */
-
-       {PBF_MAX_PCNT, 0x1F3FBF9F},     /*0x1F3f7f9f},          //Jan, 2006/04/20 */
-
-       {TX_RTY_CFG, 0x47d01f0f},       /* Jan, 2006/11/16, Set TxWI->ACK =0 in Probe Rsp Modify for 2860E ,2007-08-03 */
-
-       {AUTO_RSP_CFG, 0x00000013},     /* Initial Auto_Responder, because QA will turn off Auto-Responder */
-       {CCK_PROT_CFG, 0x05740003 /*0x01740003 */ },    /* Initial Auto_Responder, because QA will turn off Auto-Responder. And RTS threshold is enabled. */
-       {OFDM_PROT_CFG, 0x05740003 /*0x01740003 */ },   /* Initial Auto_Responder, because QA will turn off Auto-Responder. And RTS threshold is enabled. */
-#ifdef RTMP_MAC_USB
-       {PBF_CFG, 0xf40006},    /* Only enable Queue 2 */
-       {MM40_PROT_CFG, 0x3F44084},     /* Initial Auto_Responder, because QA will turn off Auto-Responder */
-       {WPDMA_GLO_CFG, 0x00000030},
-#endif /* RTMP_MAC_USB // */
-       {GF20_PROT_CFG, 0x01744004},    /* set 19:18 --> Short NAV for MIMO PS */
-       {GF40_PROT_CFG, 0x03F44084},
-       {MM20_PROT_CFG, 0x01744004},
-#ifdef RTMP_MAC_PCI
-       {MM40_PROT_CFG, 0x03F54084},
-#endif /* RTMP_MAC_PCI // */
-       {TXOP_CTRL_CFG, 0x0000583f, /*0x0000243f *//*0x000024bf */ },   /*Extension channel backoff. */
-       {TX_RTS_CFG, 0x00092b20},
-       {EXP_ACK_TIME, 0x002400ca},     /* default value */
-
-       {TXOP_HLDR_ET, 0x00000002},
-
-       /* Jerry comments 2008/01/16: we use SIFS = 10us in CCK defaultly, but it seems that 10us
-          is too small for INTEL 2200bg card, so in MBSS mode, the delta time between beacon0
-          and beacon1 is SIFS (10us), so if INTEL 2200bg card connects to BSS0, the ping
-          will always lost. So we change the SIFS of CCK from 10us to 16us. */
-       {XIFS_TIME_CFG, 0x33a41010},
-       {PWR_PIN_CFG, 0x00000003},      /* patch for 2880-E */
-};
-
-struct rt_rtmp_reg_pair STAMACRegTable[] = {
-       {WMM_AIFSN_CFG, 0x00002273},
-       {WMM_CWMIN_CFG, 0x00002344},
-       {WMM_CWMAX_CFG, 0x000034aa},
-};
-
-#define        NUM_MAC_REG_PARMS               (sizeof(MACRegTable) / sizeof(struct rt_rtmp_reg_pair))
-#define        NUM_STA_MAC_REG_PARMS   (sizeof(STAMACRegTable) / sizeof(struct rt_rtmp_reg_pair))
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Allocate struct rt_rtmp_adapter data block and do some initialization
-
-       Arguments:
-               Adapter         Pointer to our adapter
-
-       Return Value:
-               NDIS_STATUS_SUCCESS
-               NDIS_STATUS_FAILURE
-
-       IRQL = PASSIVE_LEVEL
-
-       Note:
-
-       ========================================================================
-*/
-int RTMPAllocAdapterBlock(void *handle,
-                                 struct rt_rtmp_adapter * * ppAdapter)
-{
-       struct rt_rtmp_adapter *pAd;
-       int Status;
-       int index;
-       u8 *pBeaconBuf = NULL;
-
-       DBGPRINT(RT_DEBUG_TRACE, ("--> RTMPAllocAdapterBlock\n"));
-
-       *ppAdapter = NULL;
-
-       do {
-               /* Allocate struct rt_rtmp_adapter memory block */
-               pBeaconBuf = kmalloc(MAX_BEACON_SIZE, MEM_ALLOC_FLAG);
-               if (pBeaconBuf == NULL) {
-                       Status = NDIS_STATUS_FAILURE;
-                       DBGPRINT_ERR("Failed to allocate memory - BeaconBuf!\n");
-                       break;
-               }
-               NdisZeroMemory(pBeaconBuf, MAX_BEACON_SIZE);
-
-               Status = AdapterBlockAllocateMemory(handle, (void **) & pAd);
-               if (Status != NDIS_STATUS_SUCCESS) {
-                       DBGPRINT_ERR("Failed to allocate memory - ADAPTER\n");
-                       break;
-               }
-               pAd->BeaconBuf = pBeaconBuf;
-               DBGPRINT(RT_DEBUG_OFF,
-                        ("=== pAd = %p, size = %d ===\n", pAd,
-                         (u32)sizeof(struct rt_rtmp_adapter)));
-
-               /* Init spin locks */
-               NdisAllocateSpinLock(&pAd->MgmtRingLock);
-#ifdef RTMP_MAC_PCI
-               NdisAllocateSpinLock(&pAd->RxRingLock);
-#ifdef RT3090
-               NdisAllocateSpinLock(&pAd->McuCmdLock);
-#endif /* RT3090 // */
-#endif /* RTMP_MAC_PCI // */
-
-               for (index = 0; index < NUM_OF_TX_RING; index++) {
-                       NdisAllocateSpinLock(&pAd->TxSwQueueLock[index]);
-                       NdisAllocateSpinLock(&pAd->DeQueueLock[index]);
-                       pAd->DeQueueRunning[index] = FALSE;
-               }
-
-               NdisAllocateSpinLock(&pAd->irq_lock);
-
-       } while (FALSE);
-
-       if ((Status != NDIS_STATUS_SUCCESS) && (pBeaconBuf))
-               kfree(pBeaconBuf);
-
-       *ppAdapter = pAd;
-
-       DBGPRINT_S(Status, ("<-- RTMPAllocAdapterBlock, Status=%x\n", Status));
-       return Status;
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Read initial Tx power per MCS and BW from EEPROM
-
-       Arguments:
-               Adapter                                         Pointer to our adapter
-
-       Return Value:
-               None
-
-       IRQL = PASSIVE_LEVEL
-
-       Note:
-
-       ========================================================================
-*/
-void RTMPReadTxPwrPerRate(struct rt_rtmp_adapter *pAd)
-{
-       unsigned long data, Adata, Gdata;
-       u16 i, value, value2;
-       int Apwrdelta, Gpwrdelta;
-       u8 t1, t2, t3, t4;
-       BOOLEAN bApwrdeltaMinus = TRUE, bGpwrdeltaMinus = TRUE;
-
-       /* */
-       /* Get power delta for 20MHz and 40MHz. */
-       /* */
-       DBGPRINT(RT_DEBUG_TRACE, ("Txpower per Rate\n"));
-       RT28xx_EEPROM_READ16(pAd, EEPROM_TXPOWER_DELTA, value2);
-       Apwrdelta = 0;
-       Gpwrdelta = 0;
-
-       if ((value2 & 0xff) != 0xff) {
-               if ((value2 & 0x80))
-                       Gpwrdelta = (value2 & 0xf);
-
-               if ((value2 & 0x40))
-                       bGpwrdeltaMinus = FALSE;
-               else
-                       bGpwrdeltaMinus = TRUE;
-       }
-       if ((value2 & 0xff00) != 0xff00) {
-               if ((value2 & 0x8000))
-                       Apwrdelta = ((value2 & 0xf00) >> 8);
-
-               if ((value2 & 0x4000))
-                       bApwrdeltaMinus = FALSE;
-               else
-                       bApwrdeltaMinus = TRUE;
-       }
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("Gpwrdelta = %x, Apwrdelta = %x .\n", Gpwrdelta, Apwrdelta));
-
-       /* */
-       /* Get Txpower per MCS for 20MHz in 2.4G. */
-       /* */
-       for (i = 0; i < 5; i++) {
-               RT28xx_EEPROM_READ16(pAd,
-                                    EEPROM_TXPOWER_BYRATE_20MHZ_2_4G + i * 4,
-                                    value);
-               data = value;
-               if (bApwrdeltaMinus == FALSE) {
-                       t1 = (value & 0xf) + (Apwrdelta);
-                       if (t1 > 0xf)
-                               t1 = 0xf;
-                       t2 = ((value & 0xf0) >> 4) + (Apwrdelta);
-                       if (t2 > 0xf)
-                               t2 = 0xf;
-                       t3 = ((value & 0xf00) >> 8) + (Apwrdelta);
-                       if (t3 > 0xf)
-                               t3 = 0xf;
-                       t4 = ((value & 0xf000) >> 12) + (Apwrdelta);
-                       if (t4 > 0xf)
-                               t4 = 0xf;
-               } else {
-                       if ((value & 0xf) > Apwrdelta)
-                               t1 = (value & 0xf) - (Apwrdelta);
-                       else
-                               t1 = 0;
-                       if (((value & 0xf0) >> 4) > Apwrdelta)
-                               t2 = ((value & 0xf0) >> 4) - (Apwrdelta);
-                       else
-                               t2 = 0;
-                       if (((value & 0xf00) >> 8) > Apwrdelta)
-                               t3 = ((value & 0xf00) >> 8) - (Apwrdelta);
-                       else
-                               t3 = 0;
-                       if (((value & 0xf000) >> 12) > Apwrdelta)
-                               t4 = ((value & 0xf000) >> 12) - (Apwrdelta);
-                       else
-                               t4 = 0;
-               }
-               Adata = t1 + (t2 << 4) + (t3 << 8) + (t4 << 12);
-               if (bGpwrdeltaMinus == FALSE) {
-                       t1 = (value & 0xf) + (Gpwrdelta);
-                       if (t1 > 0xf)
-                               t1 = 0xf;
-                       t2 = ((value & 0xf0) >> 4) + (Gpwrdelta);
-                       if (t2 > 0xf)
-                               t2 = 0xf;
-                       t3 = ((value & 0xf00) >> 8) + (Gpwrdelta);
-                       if (t3 > 0xf)
-                               t3 = 0xf;
-                       t4 = ((value & 0xf000) >> 12) + (Gpwrdelta);
-                       if (t4 > 0xf)
-                               t4 = 0xf;
-               } else {
-                       if ((value & 0xf) > Gpwrdelta)
-                               t1 = (value & 0xf) - (Gpwrdelta);
-                       else
-                               t1 = 0;
-                       if (((value & 0xf0) >> 4) > Gpwrdelta)
-                               t2 = ((value & 0xf0) >> 4) - (Gpwrdelta);
-                       else
-                               t2 = 0;
-                       if (((value & 0xf00) >> 8) > Gpwrdelta)
-                               t3 = ((value & 0xf00) >> 8) - (Gpwrdelta);
-                       else
-                               t3 = 0;
-                       if (((value & 0xf000) >> 12) > Gpwrdelta)
-                               t4 = ((value & 0xf000) >> 12) - (Gpwrdelta);
-                       else
-                               t4 = 0;
-               }
-               Gdata = t1 + (t2 << 4) + (t3 << 8) + (t4 << 12);
-
-               RT28xx_EEPROM_READ16(pAd,
-                                    EEPROM_TXPOWER_BYRATE_20MHZ_2_4G + i * 4 +
-                                    2, value);
-               if (bApwrdeltaMinus == FALSE) {
-                       t1 = (value & 0xf) + (Apwrdelta);
-                       if (t1 > 0xf)
-                               t1 = 0xf;
-                       t2 = ((value & 0xf0) >> 4) + (Apwrdelta);
-                       if (t2 > 0xf)
-                               t2 = 0xf;
-                       t3 = ((value & 0xf00) >> 8) + (Apwrdelta);
-                       if (t3 > 0xf)
-                               t3 = 0xf;
-                       t4 = ((value & 0xf000) >> 12) + (Apwrdelta);
-                       if (t4 > 0xf)
-                               t4 = 0xf;
-               } else {
-                       if ((value & 0xf) > Apwrdelta)
-                               t1 = (value & 0xf) - (Apwrdelta);
-                       else
-                               t1 = 0;
-                       if (((value & 0xf0) >> 4) > Apwrdelta)
-                               t2 = ((value & 0xf0) >> 4) - (Apwrdelta);
-                       else
-                               t2 = 0;
-                       if (((value & 0xf00) >> 8) > Apwrdelta)
-                               t3 = ((value & 0xf00) >> 8) - (Apwrdelta);
-                       else
-                               t3 = 0;
-                       if (((value & 0xf000) >> 12) > Apwrdelta)
-                               t4 = ((value & 0xf000) >> 12) - (Apwrdelta);
-                       else
-                               t4 = 0;
-               }
-               Adata |= ((t1 << 16) + (t2 << 20) + (t3 << 24) + (t4 << 28));
-               if (bGpwrdeltaMinus == FALSE) {
-                       t1 = (value & 0xf) + (Gpwrdelta);
-                       if (t1 > 0xf)
-                               t1 = 0xf;
-                       t2 = ((value & 0xf0) >> 4) + (Gpwrdelta);
-                       if (t2 > 0xf)
-                               t2 = 0xf;
-                       t3 = ((value & 0xf00) >> 8) + (Gpwrdelta);
-                       if (t3 > 0xf)
-                               t3 = 0xf;
-                       t4 = ((value & 0xf000) >> 12) + (Gpwrdelta);
-                       if (t4 > 0xf)
-                               t4 = 0xf;
-               } else {
-                       if ((value & 0xf) > Gpwrdelta)
-                               t1 = (value & 0xf) - (Gpwrdelta);
-                       else
-                               t1 = 0;
-                       if (((value & 0xf0) >> 4) > Gpwrdelta)
-                               t2 = ((value & 0xf0) >> 4) - (Gpwrdelta);
-                       else
-                               t2 = 0;
-                       if (((value & 0xf00) >> 8) > Gpwrdelta)
-                               t3 = ((value & 0xf00) >> 8) - (Gpwrdelta);
-                       else
-                               t3 = 0;
-                       if (((value & 0xf000) >> 12) > Gpwrdelta)
-                               t4 = ((value & 0xf000) >> 12) - (Gpwrdelta);
-                       else
-                               t4 = 0;
-               }
-               Gdata |= ((t1 << 16) + (t2 << 20) + (t3 << 24) + (t4 << 28));
-               data |= (value << 16);
-
-               /* For 20M/40M Power Delta issue */
-               pAd->Tx20MPwrCfgABand[i] = data;
-               pAd->Tx20MPwrCfgGBand[i] = data;
-               pAd->Tx40MPwrCfgABand[i] = Adata;
-               pAd->Tx40MPwrCfgGBand[i] = Gdata;
-
-               if (data != 0xffffffff)
-                       RTMP_IO_WRITE32(pAd, TX_PWR_CFG_0 + i * 4, data);
-               DBGPRINT_RAW(RT_DEBUG_TRACE,
-                            ("20MHz BW, 2.4G band-%lx,  Adata = %lx,  Gdata = %lx \n",
-                             data, Adata, Gdata));
-       }
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Read initial channel power parameters from EEPROM
-
-       Arguments:
-               Adapter                                         Pointer to our adapter
-
-       Return Value:
-               None
-
-       IRQL = PASSIVE_LEVEL
-
-       Note:
-
-       ========================================================================
-*/
-void RTMPReadChannelPwr(struct rt_rtmp_adapter *pAd)
-{
-       u8 i, choffset;
-       EEPROM_TX_PWR_STRUC Power;
-       EEPROM_TX_PWR_STRUC Power2;
-
-       /* Read Tx power value for all channels */
-       /* Value from 1 - 0x7f. Default value is 24. */
-       /* Power value : 2.4G 0x00 (0) ~ 0x1F (31) */
-       /*             : 5.5G 0xF9 (-7) ~ 0x0F (15) */
-
-       /* 0. 11b/g, ch1 - ch 14 */
-       for (i = 0; i < 7; i++) {
-               RT28xx_EEPROM_READ16(pAd, EEPROM_G_TX_PWR_OFFSET + i * 2,
-                                    Power.word);
-               RT28xx_EEPROM_READ16(pAd, EEPROM_G_TX2_PWR_OFFSET + i * 2,
-                                    Power2.word);
-               pAd->TxPower[i * 2].Channel = i * 2 + 1;
-               pAd->TxPower[i * 2 + 1].Channel = i * 2 + 2;
-
-               if ((Power.field.Byte0 > 31) || (Power.field.Byte0 < 0))
-                       pAd->TxPower[i * 2].Power = DEFAULT_RF_TX_POWER;
-               else
-                       pAd->TxPower[i * 2].Power = Power.field.Byte0;
-
-               if ((Power.field.Byte1 > 31) || (Power.field.Byte1 < 0))
-                       pAd->TxPower[i * 2 + 1].Power = DEFAULT_RF_TX_POWER;
-               else
-                       pAd->TxPower[i * 2 + 1].Power = Power.field.Byte1;
-
-               if ((Power2.field.Byte0 > 31) || (Power2.field.Byte0 < 0))
-                       pAd->TxPower[i * 2].Power2 = DEFAULT_RF_TX_POWER;
-               else
-                       pAd->TxPower[i * 2].Power2 = Power2.field.Byte0;
-
-               if ((Power2.field.Byte1 > 31) || (Power2.field.Byte1 < 0))
-                       pAd->TxPower[i * 2 + 1].Power2 = DEFAULT_RF_TX_POWER;
-               else
-                       pAd->TxPower[i * 2 + 1].Power2 = Power2.field.Byte1;
-       }
-
-       /* 1. U-NII lower/middle band: 36, 38, 40; 44, 46, 48; 52, 54, 56; 60, 62, 64 (including central frequency in BW 40MHz) */
-       /* 1.1 Fill up channel */
-       choffset = 14;
-       for (i = 0; i < 4; i++) {
-               pAd->TxPower[3 * i + choffset + 0].Channel = 36 + i * 8 + 0;
-               pAd->TxPower[3 * i + choffset + 0].Power = DEFAULT_RF_TX_POWER;
-               pAd->TxPower[3 * i + choffset + 0].Power2 = DEFAULT_RF_TX_POWER;
-
-               pAd->TxPower[3 * i + choffset + 1].Channel = 36 + i * 8 + 2;
-               pAd->TxPower[3 * i + choffset + 1].Power = DEFAULT_RF_TX_POWER;
-               pAd->TxPower[3 * i + choffset + 1].Power2 = DEFAULT_RF_TX_POWER;
-
-               pAd->TxPower[3 * i + choffset + 2].Channel = 36 + i * 8 + 4;
-               pAd->TxPower[3 * i + choffset + 2].Power = DEFAULT_RF_TX_POWER;
-               pAd->TxPower[3 * i + choffset + 2].Power2 = DEFAULT_RF_TX_POWER;
-       }
-
-       /* 1.2 Fill up power */
-       for (i = 0; i < 6; i++) {
-               RT28xx_EEPROM_READ16(pAd, EEPROM_A_TX_PWR_OFFSET + i * 2,
-                                    Power.word);
-               RT28xx_EEPROM_READ16(pAd, EEPROM_A_TX2_PWR_OFFSET + i * 2,
-                                    Power2.word);
-
-               if ((Power.field.Byte0 < 16) && (Power.field.Byte0 >= -7))
-                       pAd->TxPower[i * 2 + choffset + 0].Power =
-                           Power.field.Byte0;
-
-               if ((Power.field.Byte1 < 16) && (Power.field.Byte1 >= -7))
-                       pAd->TxPower[i * 2 + choffset + 1].Power =
-                           Power.field.Byte1;
-
-               if ((Power2.field.Byte0 < 16) && (Power2.field.Byte0 >= -7))
-                       pAd->TxPower[i * 2 + choffset + 0].Power2 =
-                           Power2.field.Byte0;
-
-               if ((Power2.field.Byte1 < 16) && (Power2.field.Byte1 >= -7))
-                       pAd->TxPower[i * 2 + choffset + 1].Power2 =
-                           Power2.field.Byte1;
-       }
-
-       /* 2. HipperLAN 2 100, 102 ,104; 108, 110, 112; 116, 118, 120; 124, 126, 128; 132, 134, 136; 140 (including central frequency in BW 40MHz) */
-       /* 2.1 Fill up channel */
-       choffset = 14 + 12;
-       for (i = 0; i < 5; i++) {
-               pAd->TxPower[3 * i + choffset + 0].Channel = 100 + i * 8 + 0;
-               pAd->TxPower[3 * i + choffset + 0].Power = DEFAULT_RF_TX_POWER;
-               pAd->TxPower[3 * i + choffset + 0].Power2 = DEFAULT_RF_TX_POWER;
-
-               pAd->TxPower[3 * i + choffset + 1].Channel = 100 + i * 8 + 2;
-               pAd->TxPower[3 * i + choffset + 1].Power = DEFAULT_RF_TX_POWER;
-               pAd->TxPower[3 * i + choffset + 1].Power2 = DEFAULT_RF_TX_POWER;
-
-               pAd->TxPower[3 * i + choffset + 2].Channel = 100 + i * 8 + 4;
-               pAd->TxPower[3 * i + choffset + 2].Power = DEFAULT_RF_TX_POWER;
-               pAd->TxPower[3 * i + choffset + 2].Power2 = DEFAULT_RF_TX_POWER;
-       }
-       pAd->TxPower[3 * 5 + choffset + 0].Channel = 140;
-       pAd->TxPower[3 * 5 + choffset + 0].Power = DEFAULT_RF_TX_POWER;
-       pAd->TxPower[3 * 5 + choffset + 0].Power2 = DEFAULT_RF_TX_POWER;
-
-       /* 2.2 Fill up power */
-       for (i = 0; i < 8; i++) {
-               RT28xx_EEPROM_READ16(pAd,
-                                    EEPROM_A_TX_PWR_OFFSET + (choffset - 14) +
-                                    i * 2, Power.word);
-               RT28xx_EEPROM_READ16(pAd,
-                                    EEPROM_A_TX2_PWR_OFFSET + (choffset - 14) +
-                                    i * 2, Power2.word);
-
-               if ((Power.field.Byte0 < 16) && (Power.field.Byte0 >= -7))
-                       pAd->TxPower[i * 2 + choffset + 0].Power =
-                           Power.field.Byte0;
-
-               if ((Power.field.Byte1 < 16) && (Power.field.Byte1 >= -7))
-                       pAd->TxPower[i * 2 + choffset + 1].Power =
-                           Power.field.Byte1;
-
-               if ((Power2.field.Byte0 < 16) && (Power2.field.Byte0 >= -7))
-                       pAd->TxPower[i * 2 + choffset + 0].Power2 =
-                           Power2.field.Byte0;
-
-               if ((Power2.field.Byte1 < 16) && (Power2.field.Byte1 >= -7))
-                       pAd->TxPower[i * 2 + choffset + 1].Power2 =
-                           Power2.field.Byte1;
-       }
-
-       /* 3. U-NII upper band: 149, 151, 153; 157, 159, 161; 165, 167, 169; 171, 173 (including central frequency in BW 40MHz) */
-       /* 3.1 Fill up channel */
-       choffset = 14 + 12 + 16;
-       /*for (i = 0; i < 2; i++) */
-       for (i = 0; i < 3; i++) {
-               pAd->TxPower[3 * i + choffset + 0].Channel = 149 + i * 8 + 0;
-               pAd->TxPower[3 * i + choffset + 0].Power = DEFAULT_RF_TX_POWER;
-               pAd->TxPower[3 * i + choffset + 0].Power2 = DEFAULT_RF_TX_POWER;
-
-               pAd->TxPower[3 * i + choffset + 1].Channel = 149 + i * 8 + 2;
-               pAd->TxPower[3 * i + choffset + 1].Power = DEFAULT_RF_TX_POWER;
-               pAd->TxPower[3 * i + choffset + 1].Power2 = DEFAULT_RF_TX_POWER;
-
-               pAd->TxPower[3 * i + choffset + 2].Channel = 149 + i * 8 + 4;
-               pAd->TxPower[3 * i + choffset + 2].Power = DEFAULT_RF_TX_POWER;
-               pAd->TxPower[3 * i + choffset + 2].Power2 = DEFAULT_RF_TX_POWER;
-       }
-       pAd->TxPower[3 * 3 + choffset + 0].Channel = 171;
-       pAd->TxPower[3 * 3 + choffset + 0].Power = DEFAULT_RF_TX_POWER;
-       pAd->TxPower[3 * 3 + choffset + 0].Power2 = DEFAULT_RF_TX_POWER;
-
-       pAd->TxPower[3 * 3 + choffset + 1].Channel = 173;
-       pAd->TxPower[3 * 3 + choffset + 1].Power = DEFAULT_RF_TX_POWER;
-       pAd->TxPower[3 * 3 + choffset + 1].Power2 = DEFAULT_RF_TX_POWER;
-
-       /* 3.2 Fill up power */
-       /*for (i = 0; i < 4; i++) */
-       for (i = 0; i < 6; i++) {
-               RT28xx_EEPROM_READ16(pAd,
-                                    EEPROM_A_TX_PWR_OFFSET + (choffset - 14) +
-                                    i * 2, Power.word);
-               RT28xx_EEPROM_READ16(pAd,
-                                    EEPROM_A_TX2_PWR_OFFSET + (choffset - 14) +
-                                    i * 2, Power2.word);
-
-               if ((Power.field.Byte0 < 16) && (Power.field.Byte0 >= -7))
-                       pAd->TxPower[i * 2 + choffset + 0].Power =
-                           Power.field.Byte0;
-
-               if ((Power.field.Byte1 < 16) && (Power.field.Byte1 >= -7))
-                       pAd->TxPower[i * 2 + choffset + 1].Power =
-                           Power.field.Byte1;
-
-               if ((Power2.field.Byte0 < 16) && (Power2.field.Byte0 >= -7))
-                       pAd->TxPower[i * 2 + choffset + 0].Power2 =
-                           Power2.field.Byte0;
-
-               if ((Power2.field.Byte1 < 16) && (Power2.field.Byte1 >= -7))
-                       pAd->TxPower[i * 2 + choffset + 1].Power2 =
-                           Power2.field.Byte1;
-       }
-
-       /* 4. Print and Debug */
-       /*choffset = 14 + 12 + 16 + 7; */
-       choffset = 14 + 12 + 16 + 11;
-
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Read the following from the registry
-               1. All the parameters
-               2. NetworkAddres
-
-       Arguments:
-               Adapter                                         Pointer to our adapter
-               WrapperConfigurationContext     For use by NdisOpenConfiguration
-
-       Return Value:
-               NDIS_STATUS_SUCCESS
-               NDIS_STATUS_FAILURE
-               NDIS_STATUS_RESOURCES
-
-       IRQL = PASSIVE_LEVEL
-
-       Note:
-
-       ========================================================================
-*/
-int NICReadRegParameters(struct rt_rtmp_adapter *pAd,
-                                void *WrapperConfigurationContext)
-{
-       int Status = NDIS_STATUS_SUCCESS;
-       DBGPRINT_S(Status, ("<-- NICReadRegParameters, Status=%x\n", Status));
-       return Status;
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Read initial parameters from EEPROM
-
-       Arguments:
-               Adapter                                         Pointer to our adapter
-
-       Return Value:
-               None
-
-       IRQL = PASSIVE_LEVEL
-
-       Note:
-
-       ========================================================================
-*/
-void NICReadEEPROMParameters(struct rt_rtmp_adapter *pAd, u8 *mac_addr)
-{
-       u32 data = 0;
-       u16 i, value, value2;
-       u8 TmpPhy;
-       EEPROM_TX_PWR_STRUC Power;
-       EEPROM_VERSION_STRUC Version;
-       EEPROM_ANTENNA_STRUC Antenna;
-       EEPROM_NIC_CONFIG2_STRUC NicConfig2;
-
-       DBGPRINT(RT_DEBUG_TRACE, ("--> NICReadEEPROMParameters\n"));
-
-       if (pAd->chipOps.eeinit)
-               pAd->chipOps.eeinit(pAd);
-
-       /* Init EEPROM Address Number, before access EEPROM; if 93c46, EEPROMAddressNum=6, else if 93c66, EEPROMAddressNum=8 */
-       RTMP_IO_READ32(pAd, E2PROM_CSR, &data);
-       DBGPRINT(RT_DEBUG_TRACE, ("--> E2PROM_CSR = 0x%x\n", data));
-
-       if ((data & 0x30) == 0)
-               pAd->EEPROMAddressNum = 6;      /* 93C46 */
-       else if ((data & 0x30) == 0x10)
-               pAd->EEPROMAddressNum = 8;      /* 93C66 */
-       else
-               pAd->EEPROMAddressNum = 8;      /* 93C86 */
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("--> EEPROMAddressNum = %d\n", pAd->EEPROMAddressNum));
-
-       /* RT2860 MAC no longer auto load MAC address from E2PROM. Driver has to initialize */
-       /* MAC address registers according to E2PROM setting */
-       if (mac_addr == NULL ||
-           strlen((char *)mac_addr) != 17 ||
-           mac_addr[2] != ':' || mac_addr[5] != ':' || mac_addr[8] != ':' ||
-           mac_addr[11] != ':' || mac_addr[14] != ':') {
-               u16 Addr01, Addr23, Addr45;
-
-               RT28xx_EEPROM_READ16(pAd, 0x04, Addr01);
-               RT28xx_EEPROM_READ16(pAd, 0x06, Addr23);
-               RT28xx_EEPROM_READ16(pAd, 0x08, Addr45);
-
-               pAd->PermanentAddress[0] = (u8)(Addr01 & 0xff);
-               pAd->PermanentAddress[1] = (u8)(Addr01 >> 8);
-               pAd->PermanentAddress[2] = (u8)(Addr23 & 0xff);
-               pAd->PermanentAddress[3] = (u8)(Addr23 >> 8);
-               pAd->PermanentAddress[4] = (u8)(Addr45 & 0xff);
-               pAd->PermanentAddress[5] = (u8)(Addr45 >> 8);
-
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("Initialize MAC Address from E2PROM \n"));
-       } else {
-               int j;
-               char *macptr;
-
-               macptr = (char *)mac_addr;
-
-               for (j = 0; j < MAC_ADDR_LEN; j++) {
-                       AtoH(macptr, &pAd->PermanentAddress[j], 1);
-                       macptr = macptr + 3;
-               }
-
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("Initialize MAC Address from module parameter \n"));
-       }
-
-       {
-               /*more conveninet to test mbssid, so ap's bssid &0xf1 */
-               if (pAd->PermanentAddress[0] == 0xff)
-                       pAd->PermanentAddress[0] = RandomByte(pAd) & 0xf8;
-
-               /*if (pAd->PermanentAddress[5] == 0xff) */
-               /*      pAd->PermanentAddress[5] = RandomByte(pAd)&0xf8; */
-
-               DBGPRINT_RAW(RT_DEBUG_TRACE,
-                       ("E2PROM MAC: =%pM\n", pAd->PermanentAddress));
-               if (pAd->bLocalAdminMAC == FALSE) {
-                       MAC_DW0_STRUC csr2;
-                       MAC_DW1_STRUC csr3;
-                       COPY_MAC_ADDR(pAd->CurrentAddress,
-                                     pAd->PermanentAddress);
-                       csr2.field.Byte0 = pAd->CurrentAddress[0];
-                       csr2.field.Byte1 = pAd->CurrentAddress[1];
-                       csr2.field.Byte2 = pAd->CurrentAddress[2];
-                       csr2.field.Byte3 = pAd->CurrentAddress[3];
-                       RTMP_IO_WRITE32(pAd, MAC_ADDR_DW0, csr2.word);
-                       csr3.word = 0;
-                       csr3.field.Byte4 = pAd->CurrentAddress[4];
-                       csr3.field.Byte5 = pAd->CurrentAddress[5];
-                       csr3.field.U2MeMask = 0xff;
-                       RTMP_IO_WRITE32(pAd, MAC_ADDR_DW1, csr3.word);
-                       DBGPRINT_RAW(RT_DEBUG_TRACE,
-                               ("E2PROM MAC: =%pM\n",
-                                       pAd->PermanentAddress));
-               }
-       }
-
-       /* if not return early. cause fail at emulation. */
-       /* Init the channel number for TX channel power */
-       RTMPReadChannelPwr(pAd);
-
-       /* if E2PROM version mismatch with driver's expectation, then skip */
-       /* all subsequent E2RPOM retieval and set a system error bit to notify GUI */
-       RT28xx_EEPROM_READ16(pAd, EEPROM_VERSION_OFFSET, Version.word);
-       pAd->EepromVersion =
-           Version.field.Version + Version.field.FaeReleaseNumber * 256;
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("E2PROM: Version = %d, FAE release #%d\n",
-                 Version.field.Version, Version.field.FaeReleaseNumber));
-
-       if (Version.field.Version > VALID_EEPROM_VERSION) {
-               DBGPRINT_ERR("E2PROM: WRONG VERSION 0x%x, should be %d\n", Version.field.Version, VALID_EEPROM_VERSION);
-               /*pAd->SystemErrorBitmap |= 0x00000001;
-
-                  // hard-code default value when no proper E2PROM installed
-                  pAd->bAutoTxAgcA = FALSE;
-                  pAd->bAutoTxAgcG = FALSE;
-
-                  // Default the channel power
-                  for (i = 0; i < MAX_NUM_OF_CHANNELS; i++)
-                  pAd->TxPower[i].Power = DEFAULT_RF_TX_POWER;
-
-                  // Default the channel power
-                  for (i = 0; i < MAX_NUM_OF_11JCHANNELS; i++)
-                  pAd->TxPower11J[i].Power = DEFAULT_RF_TX_POWER;
-
-                  for(i = 0; i < NUM_EEPROM_BBP_PARMS; i++)
-                  pAd->EEPROMDefaultValue[i] = 0xffff;
-                  return;  */
-       }
-       /* Read BBP default value from EEPROM and store to array(EEPROMDefaultValue) in pAd */
-       RT28xx_EEPROM_READ16(pAd, EEPROM_NIC1_OFFSET, value);
-       pAd->EEPROMDefaultValue[0] = value;
-
-       RT28xx_EEPROM_READ16(pAd, EEPROM_NIC2_OFFSET, value);
-       pAd->EEPROMDefaultValue[1] = value;
-
-       RT28xx_EEPROM_READ16(pAd, 0x38, value); /* Country Region */
-       pAd->EEPROMDefaultValue[2] = value;
-
-       for (i = 0; i < 8; i++) {
-               RT28xx_EEPROM_READ16(pAd, EEPROM_BBP_BASE_OFFSET + i * 2,
-                                    value);
-               pAd->EEPROMDefaultValue[i + 3] = value;
-       }
-
-       /* We have to parse NIC configuration 0 at here. */
-       /* If TSSI did not have preloaded value, it should reset the TxAutoAgc to false */
-       /* Therefore, we have to read TxAutoAgc control beforehand. */
-       /* Read Tx AGC control bit */
-       Antenna.word = pAd->EEPROMDefaultValue[0];
-       if (Antenna.word == 0xFFFF) {
-#ifdef RT30xx
-               if (IS_RT3090(pAd) || IS_RT3390(pAd)) {
-                       Antenna.word = 0;
-                       Antenna.field.RfIcType = RFIC_3020;
-                       Antenna.field.TxPath = 1;
-                       Antenna.field.RxPath = 1;
-               } else
-#endif /* RT30xx // */
-               {
-
-                       Antenna.word = 0;
-                       Antenna.field.RfIcType = RFIC_2820;
-                       Antenna.field.TxPath = 1;
-                       Antenna.field.RxPath = 2;
-                       DBGPRINT(RT_DEBUG_WARN,
-                                ("E2PROM error, hard code as 0x%04x\n",
-                                 Antenna.word));
-               }
-       }
-       /* Choose the desired Tx&Rx stream. */
-       if ((pAd->CommonCfg.TxStream == 0)
-           || (pAd->CommonCfg.TxStream > Antenna.field.TxPath))
-               pAd->CommonCfg.TxStream = Antenna.field.TxPath;
-
-       if ((pAd->CommonCfg.RxStream == 0)
-           || (pAd->CommonCfg.RxStream > Antenna.field.RxPath)) {
-               pAd->CommonCfg.RxStream = Antenna.field.RxPath;
-
-               if ((pAd->MACVersion < RALINK_2883_VERSION) &&
-                   (pAd->CommonCfg.RxStream > 2)) {
-                       /* only 2 Rx streams for RT2860 series */
-                       pAd->CommonCfg.RxStream = 2;
-               }
-       }
-       /* 3*3 */
-       /* read value from EEPROM and set them to CSR174 ~ 177 in chain0 ~ chain2 */
-       /* yet implement */
-       for (i = 0; i < 3; i++) {
-       }
-
-       NicConfig2.word = pAd->EEPROMDefaultValue[1];
-
-       {
-               if ((NicConfig2.word & 0x00ff) == 0xff) {
-                       NicConfig2.word &= 0xff00;
-               }
-
-               if ((NicConfig2.word >> 8) == 0xff) {
-                       NicConfig2.word &= 0x00ff;
-               }
-       }
-
-       if (NicConfig2.field.DynamicTxAgcControl == 1)
-               pAd->bAutoTxAgcA = pAd->bAutoTxAgcG = TRUE;
-       else
-               pAd->bAutoTxAgcA = pAd->bAutoTxAgcG = FALSE;
-
-       DBGPRINT_RAW(RT_DEBUG_TRACE,
-                    ("NICReadEEPROMParameters: RxPath = %d, TxPath = %d\n",
-                     Antenna.field.RxPath, Antenna.field.TxPath));
-
-       /* Save the antenna for future use */
-       pAd->Antenna.word = Antenna.word;
-
-       /* Set the RfICType here, then we can initialize RFIC related operation callbacks */
-       pAd->Mlme.RealRxPath = (u8)Antenna.field.RxPath;
-       pAd->RfIcType = (u8)Antenna.field.RfIcType;
-
-#ifdef RTMP_RF_RW_SUPPORT
-       RtmpChipOpsRFHook(pAd);
-#endif /* RTMP_RF_RW_SUPPORT // */
-
-#ifdef RTMP_MAC_PCI
-       sprintf((char *)pAd->nickname, "RT2860STA");
-#endif /* RTMP_MAC_PCI // */
-
-       /* */
-       /* Reset PhyMode if we don't support 802.11a */
-       /* Only RFIC_2850 & RFIC_2750 support 802.11a */
-       /* */
-       if ((Antenna.field.RfIcType != RFIC_2850)
-           && (Antenna.field.RfIcType != RFIC_2750)
-           && (Antenna.field.RfIcType != RFIC_3052)) {
-               if ((pAd->CommonCfg.PhyMode == PHY_11ABG_MIXED) ||
-                   (pAd->CommonCfg.PhyMode == PHY_11A))
-                       pAd->CommonCfg.PhyMode = PHY_11BG_MIXED;
-               else if ((pAd->CommonCfg.PhyMode == PHY_11ABGN_MIXED) ||
-                        (pAd->CommonCfg.PhyMode == PHY_11AN_MIXED) ||
-                        (pAd->CommonCfg.PhyMode == PHY_11AGN_MIXED) ||
-                        (pAd->CommonCfg.PhyMode == PHY_11N_5G))
-                       pAd->CommonCfg.PhyMode = PHY_11BGN_MIXED;
-       }
-       /* Read TSSI reference and TSSI boundary for temperature compensation. This is ugly */
-       /* 0. 11b/g */
-       {
-               /* these are tempature reference value (0x00 ~ 0xFE)
-                  ex: 0x00 0x15 0x25 0x45 0x88 0xA0 0xB5 0xD0 0xF0
-                  TssiPlusBoundaryG [4] [3] [2] [1] [0] (smaller) +
-                  TssiMinusBoundaryG[0] [1] [2] [3] [4] (larger) */
-               RT28xx_EEPROM_READ16(pAd, 0x6E, Power.word);
-               pAd->TssiMinusBoundaryG[4] = Power.field.Byte0;
-               pAd->TssiMinusBoundaryG[3] = Power.field.Byte1;
-               RT28xx_EEPROM_READ16(pAd, 0x70, Power.word);
-               pAd->TssiMinusBoundaryG[2] = Power.field.Byte0;
-               pAd->TssiMinusBoundaryG[1] = Power.field.Byte1;
-               RT28xx_EEPROM_READ16(pAd, 0x72, Power.word);
-               pAd->TssiRefG = Power.field.Byte0;      /* reference value [0] */
-               pAd->TssiPlusBoundaryG[1] = Power.field.Byte1;
-               RT28xx_EEPROM_READ16(pAd, 0x74, Power.word);
-               pAd->TssiPlusBoundaryG[2] = Power.field.Byte0;
-               pAd->TssiPlusBoundaryG[3] = Power.field.Byte1;
-               RT28xx_EEPROM_READ16(pAd, 0x76, Power.word);
-               pAd->TssiPlusBoundaryG[4] = Power.field.Byte0;
-               pAd->TxAgcStepG = Power.field.Byte1;
-               pAd->TxAgcCompensateG = 0;
-               pAd->TssiMinusBoundaryG[0] = pAd->TssiRefG;
-               pAd->TssiPlusBoundaryG[0] = pAd->TssiRefG;
-
-               /* Disable TxAgc if the based value is not right */
-               if (pAd->TssiRefG == 0xff)
-                       pAd->bAutoTxAgcG = FALSE;
-
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("E2PROM: G Tssi[-4 .. +4] = %d %d %d %d - %d -%d %d %d %d, step=%d, tuning=%d\n",
-                         pAd->TssiMinusBoundaryG[4],
-                         pAd->TssiMinusBoundaryG[3],
-                         pAd->TssiMinusBoundaryG[2],
-                         pAd->TssiMinusBoundaryG[1], pAd->TssiRefG,
-                         pAd->TssiPlusBoundaryG[1], pAd->TssiPlusBoundaryG[2],
-                         pAd->TssiPlusBoundaryG[3], pAd->TssiPlusBoundaryG[4],
-                         pAd->TxAgcStepG, pAd->bAutoTxAgcG));
-       }
-       /* 1. 11a */
-       {
-               RT28xx_EEPROM_READ16(pAd, 0xD4, Power.word);
-               pAd->TssiMinusBoundaryA[4] = Power.field.Byte0;
-               pAd->TssiMinusBoundaryA[3] = Power.field.Byte1;
-               RT28xx_EEPROM_READ16(pAd, 0xD6, Power.word);
-               pAd->TssiMinusBoundaryA[2] = Power.field.Byte0;
-               pAd->TssiMinusBoundaryA[1] = Power.field.Byte1;
-               RT28xx_EEPROM_READ16(pAd, 0xD8, Power.word);
-               pAd->TssiRefA = Power.field.Byte0;
-               pAd->TssiPlusBoundaryA[1] = Power.field.Byte1;
-               RT28xx_EEPROM_READ16(pAd, 0xDA, Power.word);
-               pAd->TssiPlusBoundaryA[2] = Power.field.Byte0;
-               pAd->TssiPlusBoundaryA[3] = Power.field.Byte1;
-               RT28xx_EEPROM_READ16(pAd, 0xDC, Power.word);
-               pAd->TssiPlusBoundaryA[4] = Power.field.Byte0;
-               pAd->TxAgcStepA = Power.field.Byte1;
-               pAd->TxAgcCompensateA = 0;
-               pAd->TssiMinusBoundaryA[0] = pAd->TssiRefA;
-               pAd->TssiPlusBoundaryA[0] = pAd->TssiRefA;
-
-               /* Disable TxAgc if the based value is not right */
-               if (pAd->TssiRefA == 0xff)
-                       pAd->bAutoTxAgcA = FALSE;
-
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("E2PROM: A Tssi[-4 .. +4] = %d %d %d %d - %d -%d %d %d %d, step=%d, tuning=%d\n",
-                         pAd->TssiMinusBoundaryA[4],
-                         pAd->TssiMinusBoundaryA[3],
-                         pAd->TssiMinusBoundaryA[2],
-                         pAd->TssiMinusBoundaryA[1], pAd->TssiRefA,
-                         pAd->TssiPlusBoundaryA[1], pAd->TssiPlusBoundaryA[2],
-                         pAd->TssiPlusBoundaryA[3], pAd->TssiPlusBoundaryA[4],
-                         pAd->TxAgcStepA, pAd->bAutoTxAgcA));
-       }
-       pAd->BbpRssiToDbmDelta = 0x0;
-
-       /* Read frequency offset setting for RF */
-       RT28xx_EEPROM_READ16(pAd, EEPROM_FREQ_OFFSET, value);
-       if ((value & 0x00FF) != 0x00FF)
-               pAd->RfFreqOffset = (unsigned long)(value & 0x00FF);
-       else
-               pAd->RfFreqOffset = 0;
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("E2PROM: RF FreqOffset=0x%lx \n", pAd->RfFreqOffset));
-
-       /*CountryRegion byte offset (38h) */
-       value = pAd->EEPROMDefaultValue[2] >> 8;        /* 2.4G band */
-       value2 = pAd->EEPROMDefaultValue[2] & 0x00FF;   /* 5G band */
-
-       if ((value <= REGION_MAXIMUM_BG_BAND)
-           && (value2 <= REGION_MAXIMUM_A_BAND)) {
-               pAd->CommonCfg.CountryRegion = ((u8)value) | 0x80;
-               pAd->CommonCfg.CountryRegionForABand = ((u8)value2) | 0x80;
-               TmpPhy = pAd->CommonCfg.PhyMode;
-               pAd->CommonCfg.PhyMode = 0xff;
-               RTMPSetPhyMode(pAd, TmpPhy);
-               SetCommonHT(pAd);
-       }
-       /* */
-       /* Get RSSI Offset on EEPROM 0x9Ah & 0x9Ch. */
-       /* The valid value are (-10 ~ 10) */
-       /* */
-       RT28xx_EEPROM_READ16(pAd, EEPROM_RSSI_BG_OFFSET, value);
-       pAd->BGRssiOffset0 = value & 0x00ff;
-       pAd->BGRssiOffset1 = (value >> 8);
-       RT28xx_EEPROM_READ16(pAd, EEPROM_RSSI_BG_OFFSET + 2, value);
-       pAd->BGRssiOffset2 = value & 0x00ff;
-       pAd->ALNAGain1 = (value >> 8);
-       RT28xx_EEPROM_READ16(pAd, EEPROM_LNA_OFFSET, value);
-       pAd->BLNAGain = value & 0x00ff;
-       pAd->ALNAGain0 = (value >> 8);
-
-       /* Validate 11b/g RSSI_0 offset. */
-       if ((pAd->BGRssiOffset0 < -10) || (pAd->BGRssiOffset0 > 10))
-               pAd->BGRssiOffset0 = 0;
-
-       /* Validate 11b/g RSSI_1 offset. */
-       if ((pAd->BGRssiOffset1 < -10) || (pAd->BGRssiOffset1 > 10))
-               pAd->BGRssiOffset1 = 0;
-
-       /* Validate 11b/g RSSI_2 offset. */
-       if ((pAd->BGRssiOffset2 < -10) || (pAd->BGRssiOffset2 > 10))
-               pAd->BGRssiOffset2 = 0;
-
-       RT28xx_EEPROM_READ16(pAd, EEPROM_RSSI_A_OFFSET, value);
-       pAd->ARssiOffset0 = value & 0x00ff;
-       pAd->ARssiOffset1 = (value >> 8);
-       RT28xx_EEPROM_READ16(pAd, (EEPROM_RSSI_A_OFFSET + 2), value);
-       pAd->ARssiOffset2 = value & 0x00ff;
-       pAd->ALNAGain2 = (value >> 8);
-
-       if (((u8)pAd->ALNAGain1 == 0xFF) || (pAd->ALNAGain1 == 0x00))
-               pAd->ALNAGain1 = pAd->ALNAGain0;
-       if (((u8)pAd->ALNAGain2 == 0xFF) || (pAd->ALNAGain2 == 0x00))
-               pAd->ALNAGain2 = pAd->ALNAGain0;
-
-       /* Validate 11a RSSI_0 offset. */
-       if ((pAd->ARssiOffset0 < -10) || (pAd->ARssiOffset0 > 10))
-               pAd->ARssiOffset0 = 0;
-
-       /* Validate 11a RSSI_1 offset. */
-       if ((pAd->ARssiOffset1 < -10) || (pAd->ARssiOffset1 > 10))
-               pAd->ARssiOffset1 = 0;
-
-       /*Validate 11a RSSI_2 offset. */
-       if ((pAd->ARssiOffset2 < -10) || (pAd->ARssiOffset2 > 10))
-               pAd->ARssiOffset2 = 0;
-
-#ifdef RT30xx
-       /* */
-       /* Get TX mixer gain setting */
-       /* 0xff are invalid value */
-       /* Note: RT30xX default value is 0x00 and will program to RF_R17 only when this value is not zero. */
-       /*       RT359X default value is 0x02 */
-       /* */
-       if (IS_RT30xx(pAd) || IS_RT3572(pAd)) {
-               RT28xx_EEPROM_READ16(pAd, EEPROM_TXMIXER_GAIN_2_4G, value);
-               pAd->TxMixerGain24G = 0;
-               value &= 0x00ff;
-               if (value != 0xff) {
-                       value &= 0x07;
-                       pAd->TxMixerGain24G = (u8)value;
-               }
-       }
-#endif /* RT30xx // */
-
-       /* */
-       /* Get LED Setting. */
-       /* */
-       RT28xx_EEPROM_READ16(pAd, 0x3a, value);
-       pAd->LedCntl.word = (value >> 8);
-       RT28xx_EEPROM_READ16(pAd, EEPROM_LED1_OFFSET, value);
-       pAd->Led1 = value;
-       RT28xx_EEPROM_READ16(pAd, EEPROM_LED2_OFFSET, value);
-       pAd->Led2 = value;
-       RT28xx_EEPROM_READ16(pAd, EEPROM_LED3_OFFSET, value);
-       pAd->Led3 = value;
-
-       RTMPReadTxPwrPerRate(pAd);
-
-#ifdef RT30xx
-#ifdef RTMP_EFUSE_SUPPORT
-       RtmpEfuseSupportCheck(pAd);
-#endif /* RTMP_EFUSE_SUPPORT // */
-#endif /* RT30xx // */
-
-       DBGPRINT(RT_DEBUG_TRACE, ("<-- NICReadEEPROMParameters\n"));
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Set default value from EEPROM
-
-       Arguments:
-               Adapter                                         Pointer to our adapter
-
-       Return Value:
-               None
-
-       IRQL = PASSIVE_LEVEL
-
-       Note:
-
-       ========================================================================
-*/
-void NICInitAsicFromEEPROM(struct rt_rtmp_adapter *pAd)
-{
-       u32 data = 0;
-       u8 BBPR1 = 0;
-       u16 i;
-/*      EEPROM_ANTENNA_STRUC    Antenna; */
-       EEPROM_NIC_CONFIG2_STRUC NicConfig2;
-       u8 BBPR3 = 0;
-
-       DBGPRINT(RT_DEBUG_TRACE, ("--> NICInitAsicFromEEPROM\n"));
-       for (i = 3; i < NUM_EEPROM_BBP_PARMS; i++) {
-               u8 BbpRegIdx, BbpValue;
-
-               if ((pAd->EEPROMDefaultValue[i] != 0xFFFF)
-                   && (pAd->EEPROMDefaultValue[i] != 0)) {
-                       BbpRegIdx = (u8)(pAd->EEPROMDefaultValue[i] >> 8);
-                       BbpValue = (u8)(pAd->EEPROMDefaultValue[i] & 0xff);
-                       RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BbpRegIdx, BbpValue);
-               }
-       }
-
-       NicConfig2.word = pAd->EEPROMDefaultValue[1];
-
-       {
-               if ((NicConfig2.word & 0x00ff) == 0xff) {
-                       NicConfig2.word &= 0xff00;
-               }
-
-               if ((NicConfig2.word >> 8) == 0xff) {
-                       NicConfig2.word &= 0x00ff;
-               }
-       }
-
-       /* Save the antenna for future use */
-       pAd->NicConfig2.word = NicConfig2.word;
-
-#ifdef RT30xx
-       /* set default antenna as main */
-       if (pAd->RfIcType == RFIC_3020)
-               AsicSetRxAnt(pAd, pAd->RxAnt.Pair1PrimaryRxAnt);
-#endif /* RT30xx // */
-
-       /* */
-       /* Send LED Setting to MCU. */
-       /* */
-       if (pAd->LedCntl.word == 0xFF) {
-               pAd->LedCntl.word = 0x01;
-               pAd->Led1 = 0x5555;
-               pAd->Led2 = 0x2221;
-
-#ifdef RTMP_MAC_PCI
-               pAd->Led3 = 0xA9F8;
-#endif /* RTMP_MAC_PCI // */
-#ifdef RTMP_MAC_USB
-               pAd->Led3 = 0x5627;
-#endif /* RTMP_MAC_USB // */
-       }
-
-       AsicSendCommandToMcu(pAd, 0x52, 0xff, (u8)pAd->Led1,
-                            (u8)(pAd->Led1 >> 8));
-       AsicSendCommandToMcu(pAd, 0x53, 0xff, (u8)pAd->Led2,
-                            (u8)(pAd->Led2 >> 8));
-       AsicSendCommandToMcu(pAd, 0x54, 0xff, (u8)pAd->Led3,
-                            (u8)(pAd->Led3 >> 8));
-       AsicSendCommandToMcu(pAd, 0x51, 0xff, 0, pAd->LedCntl.field.Polarity);
-
-       pAd->LedIndicatorStrength = 0xFF;
-       RTMPSetSignalLED(pAd, -100);    /* Force signal strength Led to be turned off, before link up */
-
-       {
-               /* Read Hardware controlled Radio state enable bit */
-               if (NicConfig2.field.HardwareRadioControl == 1) {
-                       pAd->StaCfg.bHardwareRadio = TRUE;
-
-                       /* Read GPIO pin2 as Hardware controlled radio state */
-                       RTMP_IO_READ32(pAd, GPIO_CTRL_CFG, &data);
-                       if ((data & 0x04) == 0) {
-                               pAd->StaCfg.bHwRadio = FALSE;
-                               pAd->StaCfg.bRadio = FALSE;
-/*                              RTMP_IO_WRITE32(pAd, PWR_PIN_CFG, 0x00001818); */
-                               RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF);
-                       }
-               } else
-                       pAd->StaCfg.bHardwareRadio = FALSE;
-
-               if (pAd->StaCfg.bRadio == FALSE) {
-                       RTMPSetLED(pAd, LED_RADIO_OFF);
-               } else {
-                       RTMPSetLED(pAd, LED_RADIO_ON);
-#ifdef RTMP_MAC_PCI
-#ifdef RT3090
-                       AsicSendCommandToMcu(pAd, 0x30, PowerRadioOffCID, 0xff,
-                                            0x02);
-                       AsicCheckCommanOk(pAd, PowerRadioOffCID);
-#endif /* RT3090 // */
-#ifndef RT3090
-                       AsicSendCommandToMcu(pAd, 0x30, 0xff, 0xff, 0x02);
-#endif /* RT3090 // */
-                       AsicSendCommandToMcu(pAd, 0x31, PowerWakeCID, 0x00,
-                                            0x00);
-                       /* 2-1. wait command ok. */
-                       AsicCheckCommanOk(pAd, PowerWakeCID);
-#endif /* RTMP_MAC_PCI // */
-               }
-       }
-
-#ifdef RTMP_MAC_PCI
-#ifdef RT30xx
-       if (IS_RT3090(pAd) || IS_RT3572(pAd) || IS_RT3390(pAd)) {
-               struct rt_rtmp_chip_op *pChipOps = &pAd->chipOps;
-               if (pChipOps->AsicReverseRfFromSleepMode)
-                       pChipOps->AsicReverseRfFromSleepMode(pAd);
-       }
-       /* 3090 MCU Wakeup command needs more time to be stable. */
-       /* Before stable, don't issue other MCU command to prevent from firmware error. */
-
-       if ((IS_RT3090(pAd) || IS_RT3572(pAd) || IS_RT3390(pAd))
-           && IS_VERSION_AFTER_F(pAd)
-           && (pAd->StaCfg.PSControl.field.rt30xxPowerMode == 3)
-           && (pAd->StaCfg.PSControl.field.EnableNewPS == TRUE)) {
-               DBGPRINT(RT_DEBUG_TRACE, ("%s, release Mcu Lock\n", __func__));
-               RTMP_SEM_LOCK(&pAd->McuCmdLock);
-               pAd->brt30xxBanMcuCmd = FALSE;
-               RTMP_SEM_UNLOCK(&pAd->McuCmdLock);
-       }
-#endif /* RT30xx // */
-#endif /* RTMP_MAC_PCI // */
-
-       /* Turn off patching for cardbus controller */
-       if (NicConfig2.field.CardbusAcceleration == 1) {
-/*              pAd->bTest1 = TRUE; */
-       }
-
-       if (NicConfig2.field.DynamicTxAgcControl == 1)
-               pAd->bAutoTxAgcA = pAd->bAutoTxAgcG = TRUE;
-       else
-               pAd->bAutoTxAgcA = pAd->bAutoTxAgcG = FALSE;
-       /* */
-       /* Since BBP has been progamed, to make sure BBP setting will be */
-       /* upate inside of AsicAntennaSelect, so reset to UNKNOWN_BAND! */
-       /* */
-       pAd->CommonCfg.BandState = UNKNOWN_BAND;
-
-       RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &BBPR3);
-       BBPR3 &= (~0x18);
-       if (pAd->Antenna.field.RxPath == 3) {
-               BBPR3 |= (0x10);
-       } else if (pAd->Antenna.field.RxPath == 2) {
-               BBPR3 |= (0x8);
-       } else if (pAd->Antenna.field.RxPath == 1) {
-               BBPR3 |= (0x0);
-       }
-       RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BBPR3);
-
-       {
-               /* Handle the difference when 1T */
-               RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R1, &BBPR1);
-               if (pAd->Antenna.field.TxPath == 1) {
-                       BBPR1 &= (~0x18);
-               }
-               RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R1, BBPR1);
-
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("Use Hw Radio Control Pin=%d; if used Pin=%d;\n",
-                         pAd->CommonCfg.bHardwareRadio,
-                         pAd->CommonCfg.bHardwareRadio));
-       }
-
-#ifdef RTMP_MAC_USB
-#ifdef RT30xx
-       /* update registers from EEPROM for RT3071 or later(3572/3592). */
-
-       if (IS_RT3090(pAd) || IS_RT3572(pAd) || IS_RT3390(pAd)) {
-               u8 RegIdx, RegValue;
-               u16 value;
-
-               /* after RT3071, write BBP from EEPROM 0xF0 to 0x102 */
-               for (i = 0xF0; i <= 0x102; i = i + 2) {
-                       value = 0xFFFF;
-                       RT28xx_EEPROM_READ16(pAd, i, value);
-                       if ((value != 0xFFFF) && (value != 0)) {
-                               RegIdx = (u8)(value >> 8);
-                               RegValue = (u8)(value & 0xff);
-                               RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, RegIdx,
-                                                            RegValue);
-                               DBGPRINT(RT_DEBUG_TRACE,
-                                        ("Update BBP Registers from EEPROM(0x%0x), BBP(0x%x) = 0x%x\n",
-                                         i, RegIdx, RegValue));
-                       }
-               }
-
-               /* after RT3071, write RF from EEPROM 0x104 to 0x116 */
-               for (i = 0x104; i <= 0x116; i = i + 2) {
-                       value = 0xFFFF;
-                       RT28xx_EEPROM_READ16(pAd, i, value);
-                       if ((value != 0xFFFF) && (value != 0)) {
-                               RegIdx = (u8)(value >> 8);
-                               RegValue = (u8)(value & 0xff);
-                               RT30xxWriteRFRegister(pAd, RegIdx, RegValue);
-                               DBGPRINT(RT_DEBUG_TRACE,
-                                        ("Update RF Registers from EEPROM0x%x), BBP(0x%x) = 0x%x\n",
-                                         i, RegIdx, RegValue));
-                       }
-               }
-       }
-#endif /* RT30xx // */
-#endif /* RTMP_MAC_USB // */
-
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("TxPath = %d, RxPath = %d, RFIC=%d, Polar+LED mode=%x\n",
-                 pAd->Antenna.field.TxPath, pAd->Antenna.field.RxPath,
-                 pAd->RfIcType, pAd->LedCntl.word));
-       DBGPRINT(RT_DEBUG_TRACE, ("<-- NICInitAsicFromEEPROM\n"));
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Initialize NIC hardware
-
-       Arguments:
-               Adapter                                         Pointer to our adapter
-
-       Return Value:
-               None
-
-       IRQL = PASSIVE_LEVEL
-
-       Note:
-
-       ========================================================================
-*/
-int NICInitializeAdapter(struct rt_rtmp_adapter *pAd, IN BOOLEAN bHardReset)
-{
-       int Status = NDIS_STATUS_SUCCESS;
-       WPDMA_GLO_CFG_STRUC GloCfg;
-#ifdef RTMP_MAC_PCI
-       u32 Value;
-       DELAY_INT_CFG_STRUC IntCfg;
-#endif /* RTMP_MAC_PCI // */
-/*      INT_MASK_CSR_STRUC              IntMask; */
-       unsigned long i = 0, j = 0;
-       AC_TXOP_CSR0_STRUC csr0;
-
-       DBGPRINT(RT_DEBUG_TRACE, ("--> NICInitializeAdapter\n"));
-
-       /* 3. Set DMA global configuration except TX_DMA_EN and RX_DMA_EN bits: */
-retry:
-       i = 0;
-       do {
-               RTMP_IO_READ32(pAd, WPDMA_GLO_CFG, &GloCfg.word);
-               if ((GloCfg.field.TxDMABusy == 0)
-                   && (GloCfg.field.RxDMABusy == 0))
-                       break;
-
-               RTMPusecDelay(1000);
-               i++;
-       } while (i < 100);
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("<== DMA offset 0x208 = 0x%x\n", GloCfg.word));
-       GloCfg.word &= 0xff0;
-       GloCfg.field.EnTXWriteBackDDONE = 1;
-       RTMP_IO_WRITE32(pAd, WPDMA_GLO_CFG, GloCfg.word);
-
-       /* Record HW Beacon offset */
-       pAd->BeaconOffset[0] = HW_BEACON_BASE0;
-       pAd->BeaconOffset[1] = HW_BEACON_BASE1;
-       pAd->BeaconOffset[2] = HW_BEACON_BASE2;
-       pAd->BeaconOffset[3] = HW_BEACON_BASE3;
-       pAd->BeaconOffset[4] = HW_BEACON_BASE4;
-       pAd->BeaconOffset[5] = HW_BEACON_BASE5;
-       pAd->BeaconOffset[6] = HW_BEACON_BASE6;
-       pAd->BeaconOffset[7] = HW_BEACON_BASE7;
-
-       /* */
-       /* write all shared Ring's base address into ASIC */
-       /* */
-
-       /* asic simulation sequence put this ahead before loading firmware. */
-       /* pbf hardware reset */
-#ifdef RTMP_MAC_PCI
-       RTMP_IO_WRITE32(pAd, WPDMA_RST_IDX, 0x1003f);   /* 0x10000 for reset rx, 0x3f resets all 6 tx rings. */
-       RTMP_IO_WRITE32(pAd, PBF_SYS_CTRL, 0xe1f);
-       RTMP_IO_WRITE32(pAd, PBF_SYS_CTRL, 0xe00);
-#endif /* RTMP_MAC_PCI // */
-
-       /* Initialze ASIC for TX & Rx operation */
-       if (NICInitializeAsic(pAd, bHardReset) != NDIS_STATUS_SUCCESS) {
-               if (j++ == 0) {
-                       NICLoadFirmware(pAd);
-                       goto retry;
-               }
-               return NDIS_STATUS_FAILURE;
-       }
-
-#ifdef RTMP_MAC_PCI
-       /* Write AC_BK base address register */
-       Value =
-           RTMP_GetPhysicalAddressLow(pAd->TxRing[QID_AC_BK].Cell[0].AllocPa);
-       RTMP_IO_WRITE32(pAd, TX_BASE_PTR1, Value);
-       DBGPRINT(RT_DEBUG_TRACE, ("--> TX_BASE_PTR1 : 0x%x\n", Value));
-
-       /* Write AC_BE base address register */
-       Value =
-           RTMP_GetPhysicalAddressLow(pAd->TxRing[QID_AC_BE].Cell[0].AllocPa);
-       RTMP_IO_WRITE32(pAd, TX_BASE_PTR0, Value);
-       DBGPRINT(RT_DEBUG_TRACE, ("--> TX_BASE_PTR0 : 0x%x\n", Value));
-
-       /* Write AC_VI base address register */
-       Value =
-           RTMP_GetPhysicalAddressLow(pAd->TxRing[QID_AC_VI].Cell[0].AllocPa);
-       RTMP_IO_WRITE32(pAd, TX_BASE_PTR2, Value);
-       DBGPRINT(RT_DEBUG_TRACE, ("--> TX_BASE_PTR2 : 0x%x\n", Value));
-
-       /* Write AC_VO base address register */
-       Value =
-           RTMP_GetPhysicalAddressLow(pAd->TxRing[QID_AC_VO].Cell[0].AllocPa);
-       RTMP_IO_WRITE32(pAd, TX_BASE_PTR3, Value);
-       DBGPRINT(RT_DEBUG_TRACE, ("--> TX_BASE_PTR3 : 0x%x\n", Value));
-
-       /* Write MGMT_BASE_CSR register */
-       Value = RTMP_GetPhysicalAddressLow(pAd->MgmtRing.Cell[0].AllocPa);
-       RTMP_IO_WRITE32(pAd, TX_BASE_PTR5, Value);
-       DBGPRINT(RT_DEBUG_TRACE, ("--> TX_BASE_PTR5 : 0x%x\n", Value));
-
-       /* Write RX_BASE_CSR register */
-       Value = RTMP_GetPhysicalAddressLow(pAd->RxRing.Cell[0].AllocPa);
-       RTMP_IO_WRITE32(pAd, RX_BASE_PTR, Value);
-       DBGPRINT(RT_DEBUG_TRACE, ("--> RX_BASE_PTR : 0x%x\n", Value));
-
-       /* Init RX Ring index pointer */
-       pAd->RxRing.RxSwReadIdx = 0;
-       pAd->RxRing.RxCpuIdx = RX_RING_SIZE - 1;
-       RTMP_IO_WRITE32(pAd, RX_CRX_IDX, pAd->RxRing.RxCpuIdx);
-
-       /* Init TX rings index pointer */
-       {
-               for (i = 0; i < NUM_OF_TX_RING; i++) {
-                       pAd->TxRing[i].TxSwFreeIdx = 0;
-                       pAd->TxRing[i].TxCpuIdx = 0;
-                       RTMP_IO_WRITE32(pAd, (TX_CTX_IDX0 + i * 0x10),
-                                       pAd->TxRing[i].TxCpuIdx);
-               }
-       }
-
-       /* init MGMT ring index pointer */
-       pAd->MgmtRing.TxSwFreeIdx = 0;
-       pAd->MgmtRing.TxCpuIdx = 0;
-       RTMP_IO_WRITE32(pAd, TX_MGMTCTX_IDX, pAd->MgmtRing.TxCpuIdx);
-
-       /* */
-       /* set each Ring's SIZE  into ASIC. Descriptor Size is fixed by design. */
-       /* */
-
-       /* Write TX_RING_CSR0 register */
-       Value = TX_RING_SIZE;
-       RTMP_IO_WRITE32(pAd, TX_MAX_CNT0, Value);
-       RTMP_IO_WRITE32(pAd, TX_MAX_CNT1, Value);
-       RTMP_IO_WRITE32(pAd, TX_MAX_CNT2, Value);
-       RTMP_IO_WRITE32(pAd, TX_MAX_CNT3, Value);
-       RTMP_IO_WRITE32(pAd, TX_MAX_CNT4, Value);
-       Value = MGMT_RING_SIZE;
-       RTMP_IO_WRITE32(pAd, TX_MGMTMAX_CNT, Value);
-
-       /* Write RX_RING_CSR register */
-       Value = RX_RING_SIZE;
-       RTMP_IO_WRITE32(pAd, RX_MAX_CNT, Value);
-#endif /* RTMP_MAC_PCI // */
-
-       /* WMM parameter */
-       csr0.word = 0;
-       RTMP_IO_WRITE32(pAd, WMM_TXOP0_CFG, csr0.word);
-       if (pAd->CommonCfg.PhyMode == PHY_11B) {
-               csr0.field.Ac0Txop = 192;       /* AC_VI: 192*32us ~= 6ms */
-               csr0.field.Ac1Txop = 96;        /* AC_VO: 96*32us  ~= 3ms */
-       } else {
-               csr0.field.Ac0Txop = 96;        /* AC_VI: 96*32us ~= 3ms */
-               csr0.field.Ac1Txop = 48;        /* AC_VO: 48*32us ~= 1.5ms */
-       }
-       RTMP_IO_WRITE32(pAd, WMM_TXOP1_CFG, csr0.word);
-
-#ifdef RTMP_MAC_PCI
-       /* 3. Set DMA global configuration except TX_DMA_EN and RX_DMA_EN bits: */
-       i = 0;
-       do {
-               RTMP_IO_READ32(pAd, WPDMA_GLO_CFG, &GloCfg.word);
-               if ((GloCfg.field.TxDMABusy == 0)
-                   && (GloCfg.field.RxDMABusy == 0))
-                       break;
-
-               RTMPusecDelay(1000);
-               i++;
-       } while (i < 100);
-
-       GloCfg.word &= 0xff0;
-       GloCfg.field.EnTXWriteBackDDONE = 1;
-       RTMP_IO_WRITE32(pAd, WPDMA_GLO_CFG, GloCfg.word);
-
-       IntCfg.word = 0;
-       RTMP_IO_WRITE32(pAd, DELAY_INT_CFG, IntCfg.word);
-#endif /* RTMP_MAC_PCI // */
-
-       /* reset action */
-       /* Load firmware */
-       /*  Status = NICLoadFirmware(pAd); */
-
-       DBGPRINT(RT_DEBUG_TRACE, ("<-- NICInitializeAdapter\n"));
-       return Status;
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Initialize ASIC
-
-       Arguments:
-               Adapter                                         Pointer to our adapter
-
-       Return Value:
-               None
-
-       IRQL = PASSIVE_LEVEL
-
-       Note:
-
-       ========================================================================
-*/
-int NICInitializeAsic(struct rt_rtmp_adapter *pAd, IN BOOLEAN bHardReset)
-{
-       unsigned long Index = 0;
-       u8 R0 = 0xff;
-       u32 MacCsr12 = 0, Counter = 0;
-#ifdef RTMP_MAC_USB
-       u32 MacCsr0 = 0;
-       int Status;
-       u8 Value = 0xff;
-#endif /* RTMP_MAC_USB // */
-#ifdef RT30xx
-       u8 bbpreg = 0;
-       u8 RFValue = 0;
-#endif /* RT30xx // */
-       u16 KeyIdx;
-       int i, apidx;
-
-       DBGPRINT(RT_DEBUG_TRACE, ("--> NICInitializeAsic\n"));
-
-#ifdef RTMP_MAC_PCI
-       RTMP_IO_WRITE32(pAd, PWR_PIN_CFG, 0x3); /* To fix driver disable/enable hang issue when radio off */
-       if (bHardReset == TRUE) {
-               RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, 0x3);
-       } else
-               RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, 0x1);
-
-       RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, 0x0);
-       /* Initialize MAC register to default value */
-       for (Index = 0; Index < NUM_MAC_REG_PARMS; Index++) {
-               RTMP_IO_WRITE32(pAd, MACRegTable[Index].Register,
-                               MACRegTable[Index].Value);
-       }
-
-       {
-               for (Index = 0; Index < NUM_STA_MAC_REG_PARMS; Index++) {
-                       RTMP_IO_WRITE32(pAd, STAMACRegTable[Index].Register,
-                                       STAMACRegTable[Index].Value);
-               }
-       }
-#endif /* RTMP_MAC_PCI // */
-#ifdef RTMP_MAC_USB
-       /* */
-       /* Make sure MAC gets ready after NICLoadFirmware(). */
-       /* */
-       Index = 0;
-
-       /*To avoid hang-on issue when interface up in kernel 2.4, */
-       /*we use a local variable "MacCsr0" instead of using "pAd->MACVersion" directly. */
-       do {
-               RTMP_IO_READ32(pAd, MAC_CSR0, &MacCsr0);
-
-               if ((MacCsr0 != 0x00) && (MacCsr0 != 0xFFFFFFFF))
-                       break;
-
-               RTMPusecDelay(10);
-       } while (Index++ < 100);
-
-       pAd->MACVersion = MacCsr0;
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("MAC_CSR0  [ Ver:Rev=0x%08x]\n", pAd->MACVersion));
-       /* turn on bit13 (set to zero) after rt2860D. This is to solve high-current issue. */
-       RTMP_IO_READ32(pAd, PBF_SYS_CTRL, &MacCsr12);
-       MacCsr12 &= (~0x2000);
-       RTMP_IO_WRITE32(pAd, PBF_SYS_CTRL, MacCsr12);
-
-       RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, 0x3);
-       RTMP_IO_WRITE32(pAd, USB_DMA_CFG, 0x0);
-       Status = RTUSBVenderReset(pAd);
-
-       RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, 0x0);
-
-       /* Initialize MAC register to default value */
-       for (Index = 0; Index < NUM_MAC_REG_PARMS; Index++) {
-#ifdef RT30xx
-               if ((MACRegTable[Index].Register == TX_SW_CFG0)
-                   && (IS_RT3070(pAd) || IS_RT3071(pAd) || IS_RT3572(pAd)
-                       || IS_RT3090(pAd) || IS_RT3390(pAd))) {
-                       MACRegTable[Index].Value = 0x00000400;
-               }
-#endif /* RT30xx // */
-               RTMP_IO_WRITE32(pAd, (u16)MACRegTable[Index].Register,
-                               MACRegTable[Index].Value);
-       }
-
-       {
-               for (Index = 0; Index < NUM_STA_MAC_REG_PARMS; Index++) {
-                       RTMP_IO_WRITE32(pAd,
-                                       (u16)STAMACRegTable[Index].Register,
-                                       STAMACRegTable[Index].Value);
-               }
-       }
-#endif /* RTMP_MAC_USB // */
-
-#ifdef RT30xx
-       /* Initialize RT3070 serial MAC registers which is different from RT2870 serial */
-       if (IS_RT3090(pAd) || IS_RT3572(pAd) || IS_RT3390(pAd)) {
-               RTMP_IO_WRITE32(pAd, TX_SW_CFG1, 0);
-
-               /* RT3071 version E has fixed this issue */
-               if ((pAd->MACVersion & 0xffff) < 0x0211) {
-                       if (pAd->NicConfig2.field.DACTestBit == 1) {
-                               RTMP_IO_WRITE32(pAd, TX_SW_CFG2, 0x2C); /* To fix throughput drop drastically */
-                       } else {
-                               RTMP_IO_WRITE32(pAd, TX_SW_CFG2, 0x0F); /* To fix throughput drop drastically */
-                       }
-               } else {
-                       RTMP_IO_WRITE32(pAd, TX_SW_CFG2, 0x0);
-               }
-       } else if (IS_RT3070(pAd)) {
-               if (((pAd->MACVersion & 0xffff) < 0x0201)) {
-                       RTMP_IO_WRITE32(pAd, TX_SW_CFG1, 0);
-                       RTMP_IO_WRITE32(pAd, TX_SW_CFG2, 0x2C); /* To fix throughput drop drastically */
-               } else {
-                       RTMP_IO_WRITE32(pAd, TX_SW_CFG2, 0);
-               }
-       }
-#endif /* RT30xx // */
-
-       /* */
-       /* Before program BBP, we need to wait BBP/RF get wake up. */
-       /* */
-       Index = 0;
-       do {
-               RTMP_IO_READ32(pAd, MAC_STATUS_CFG, &MacCsr12);
-
-               if ((MacCsr12 & 0x03) == 0)     /* if BB.RF is stable */
-                       break;
-
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("Check MAC_STATUS_CFG  = Busy = %x\n", MacCsr12));
-               RTMPusecDelay(1000);
-       } while (Index++ < 100);
-
-       /* The commands to firmware should be after these commands, these commands will init firmware */
-       /* PCI and USB are not the same because PCI driver needs to wait for PCI bus ready */
-       RTMP_IO_WRITE32(pAd, H2M_BBP_AGENT, 0); /* initialize BBP R/W access agent */
-       RTMP_IO_WRITE32(pAd, H2M_MAILBOX_CSR, 0);
-#ifdef RT3090
-       /*2008/11/28:KH add to fix the dead rf frequency offset bug<-- */
-       AsicSendCommandToMcu(pAd, 0x72, 0, 0, 0);
-       /*2008/11/28:KH add to fix the dead rf frequency offset bug--> */
-#endif /* RT3090 // */
-       RTMPusecDelay(1000);
-
-       /* Read BBP register, make sure BBP is up and running before write new data */
-       Index = 0;
-       do {
-               RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R0, &R0);
-               DBGPRINT(RT_DEBUG_TRACE, ("BBP version = %x\n", R0));
-       } while ((++Index < 20) && ((R0 == 0xff) || (R0 == 0x00)));
-       /*ASSERT(Index < 20); //this will cause BSOD on Check-build driver */
-
-       if ((R0 == 0xff) || (R0 == 0x00))
-               return NDIS_STATUS_FAILURE;
-
-       /* Initialize BBP register to default value */
-       for (Index = 0; Index < NUM_BBP_REG_PARMS; Index++) {
-               RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBPRegTable[Index].Register,
-                                            BBPRegTable[Index].Value);
-       }
-
-#ifdef RTMP_MAC_PCI
-       /* TODO: shiang, check MACVersion, currently, rbus-based chip use this. */
-       if (pAd->MACVersion == 0x28720200) {
-               /*u8 value; */
-               unsigned long value2;
-
-               /*disable MLD by Bruce 20080704 */
-               /*BBP_IO_READ8_BY_REG_ID(pAd, BBP_R105, &value); */
-               /*BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R105, value | 4); */
-
-               /*Maximum PSDU length from 16K to 32K bytes */
-               RTMP_IO_READ32(pAd, MAX_LEN_CFG, &value2);
-               value2 &= ~(0x3 << 12);
-               value2 |= (0x2 << 12);
-               RTMP_IO_WRITE32(pAd, MAX_LEN_CFG, value2);
-       }
-#endif /* RTMP_MAC_PCI // */
-
-       /* for rt2860E and after, init BBP_R84 with 0x19. This is for extension channel overlapping IOT. */
-       /* RT3090 should not program BBP R84 to 0x19, otherwise TX will block. */
-       /*3070/71/72,3090,3090A( are included in RT30xx),3572,3390 */
-       if (((pAd->MACVersion & 0xffff) != 0x0101)
-           && !(IS_RT30xx(pAd) || IS_RT3572(pAd) || IS_RT3390(pAd)))
-               RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R84, 0x19);
-
-#ifdef RT30xx
-/* add by johnli, RF power sequence setup */
-       if (IS_RT30xx(pAd) || IS_RT3572(pAd) || IS_RT3390(pAd)) {       /*update for RT3070/71/72/90/91/92,3572,3390. */
-               RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R79, 0x13);
-               RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R80, 0x05);
-               RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R81, 0x33);
-       }
-
-       if (IS_RT3090(pAd) || IS_RT3390(pAd))   /* RT309x, RT3071/72 */
-       {
-               /* enable DC filter */
-               if ((pAd->MACVersion & 0xffff) >= 0x0211) {
-                       RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R103, 0xc0);
-               }
-               /* improve power consumption */
-               RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R138, &bbpreg);
-               if (pAd->Antenna.field.TxPath == 1) {
-                       /* turn off tx DAC_1 */
-                       bbpreg = (bbpreg | 0x20);
-               }
-
-               if (pAd->Antenna.field.RxPath == 1) {
-                       /* turn off tx ADC_1 */
-                       bbpreg &= (~0x2);
-               }
-               RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R138, bbpreg);
-
-               /* improve power consumption in RT3071 Ver.E */
-               if ((pAd->MACVersion & 0xffff) >= 0x0211) {
-                       RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R31, &bbpreg);
-                       bbpreg &= (~0x3);
-                       RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R31, bbpreg);
-               }
-       } else if (IS_RT3070(pAd)) {
-               if ((pAd->MACVersion & 0xffff) >= 0x0201) {
-                       /* enable DC filter */
-                       RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R103, 0xc0);
-
-                       /* improve power consumption in RT3070 Ver.F */
-                       RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R31, &bbpreg);
-                       bbpreg &= (~0x3);
-                       RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R31, bbpreg);
-               }
-               /* TX_LO1_en, RF R17 register Bit 3 to 0 */
-               RT30xxReadRFRegister(pAd, RF_R17, &RFValue);
-               RFValue &= (~0x08);
-               /* to fix rx long range issue */
-               if (pAd->NicConfig2.field.ExternalLNAForG == 0) {
-                       RFValue |= 0x20;
-               }
-               /* set RF_R17_bit[2:0] equal to EEPROM setting at 0x48h */
-               if (pAd->TxMixerGain24G >= 1) {
-                       RFValue &= (~0x7);      /* clean bit [2:0] */
-                       RFValue |= pAd->TxMixerGain24G;
-               }
-               RT30xxWriteRFRegister(pAd, RF_R17, RFValue);
-       }
-/* end johnli */
-#endif /* RT30xx // */
-
-       if (pAd->MACVersion == 0x28600100) {
-               RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R69, 0x16);
-               RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R73, 0x12);
-       }
-
-       if (pAd->MACVersion >= RALINK_2880E_VERSION && pAd->MACVersion < RALINK_3070_VERSION)   /* 3*3 */
-       {
-               /* enlarge MAX_LEN_CFG */
-               u32 csr;
-               RTMP_IO_READ32(pAd, MAX_LEN_CFG, &csr);
-               csr &= 0xFFF;
-               csr |= 0x2000;
-               RTMP_IO_WRITE32(pAd, MAX_LEN_CFG, csr);
-       }
-#ifdef RTMP_MAC_USB
-       {
-               u8 MAC_Value[] =
-                   { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0, 0 };
-
-               /*Initialize WCID table */
-               Value = 0xff;
-               for (Index = 0; Index < 254; Index++) {
-                       RTUSBMultiWrite(pAd,
-                                       (u16)(MAC_WCID_BASE + Index * 8),
-                                       MAC_Value, 8);
-               }
-       }
-#endif /* RTMP_MAC_USB // */
-
-       /* Add radio off control */
-       {
-               if (pAd->StaCfg.bRadio == FALSE) {
-/*                      RTMP_IO_WRITE32(pAd, PWR_PIN_CFG, 0x00001818); */
-                       RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF);
-                       DBGPRINT(RT_DEBUG_TRACE, ("Set Radio Off\n"));
-               }
-       }
-
-       /* Clear raw counters */
-       RTMP_IO_READ32(pAd, RX_STA_CNT0, &Counter);
-       RTMP_IO_READ32(pAd, RX_STA_CNT1, &Counter);
-       RTMP_IO_READ32(pAd, RX_STA_CNT2, &Counter);
-       RTMP_IO_READ32(pAd, TX_STA_CNT0, &Counter);
-       RTMP_IO_READ32(pAd, TX_STA_CNT1, &Counter);
-       RTMP_IO_READ32(pAd, TX_STA_CNT2, &Counter);
-
-       /* ASIC will keep garbage value after boot */
-       /* Clear all shared key table when initial */
-       /* This routine can be ignored in radio-ON/OFF operation. */
-       if (bHardReset) {
-               for (KeyIdx = 0; KeyIdx < 4; KeyIdx++) {
-                       RTMP_IO_WRITE32(pAd, SHARED_KEY_MODE_BASE + 4 * KeyIdx,
-                                       0);
-               }
-
-               /* Clear all pairwise key table when initial */
-               for (KeyIdx = 0; KeyIdx < 256; KeyIdx++) {
-                       RTMP_IO_WRITE32(pAd,
-                                       MAC_WCID_ATTRIBUTE_BASE +
-                                       (KeyIdx * HW_WCID_ATTRI_SIZE), 1);
-               }
-       }
-       /* assert HOST ready bit */
-/*  RTMP_IO_WRITE32(pAd, MAC_CSR1, 0x0); // 2004-09-14 asked by Mark */
-/*  RTMP_IO_WRITE32(pAd, MAC_CSR1, 0x4); */
-
-       /* It isn't necessary to clear this space when not hard reset. */
-       if (bHardReset == TRUE) {
-               /* clear all on-chip BEACON frame space */
-               for (apidx = 0; apidx < HW_BEACON_MAX_COUNT; apidx++) {
-                       for (i = 0; i < HW_BEACON_OFFSET >> 2; i += 4)
-                               RTMP_IO_WRITE32(pAd,
-                                               pAd->BeaconOffset[apidx] + i,
-                                               0x00);
-               }
-       }
-#ifdef RTMP_MAC_USB
-       AsicDisableSync(pAd);
-       /* Clear raw counters */
-       RTMP_IO_READ32(pAd, RX_STA_CNT0, &Counter);
-       RTMP_IO_READ32(pAd, RX_STA_CNT1, &Counter);
-       RTMP_IO_READ32(pAd, RX_STA_CNT2, &Counter);
-       RTMP_IO_READ32(pAd, TX_STA_CNT0, &Counter);
-       RTMP_IO_READ32(pAd, TX_STA_CNT1, &Counter);
-       RTMP_IO_READ32(pAd, TX_STA_CNT2, &Counter);
-       /* Default PCI clock cycle per ms is different as default setting, which is based on PCI. */
-       RTMP_IO_READ32(pAd, USB_CYC_CFG, &Counter);
-       Counter &= 0xffffff00;
-       Counter |= 0x000001e;
-       RTMP_IO_WRITE32(pAd, USB_CYC_CFG, Counter);
-#endif /* RTMP_MAC_USB // */
-
-       {
-               /* for rt2860E and after, init TXOP_CTRL_CFG with 0x583f. This is for extension channel overlapping IOT. */
-               if ((pAd->MACVersion & 0xffff) != 0x0101)
-                       RTMP_IO_WRITE32(pAd, TXOP_CTRL_CFG, 0x583f);
-       }
-
-       DBGPRINT(RT_DEBUG_TRACE, ("<-- NICInitializeAsic\n"));
-       return NDIS_STATUS_SUCCESS;
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Reset NIC Asics
-
-       Arguments:
-               Adapter                                         Pointer to our adapter
-
-       Return Value:
-               None
-
-       IRQL = PASSIVE_LEVEL
-
-       Note:
-               Reset NIC to initial state AS IS system boot up time.
-
-       ========================================================================
-*/
-void NICIssueReset(struct rt_rtmp_adapter *pAd)
-{
-       u32 Value = 0;
-       DBGPRINT(RT_DEBUG_TRACE, ("--> NICIssueReset\n"));
-
-       /* Abort Tx, prevent ASIC from writing to Host memory */
-       /*RTMP_IO_WRITE32(pAd, TX_CNTL_CSR, 0x001f0000); */
-
-       /* Disable Rx, register value supposed will remain after reset */
-       RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
-       Value &= (0xfffffff3);
-       RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
-
-       /* Issue reset and clear from reset state */
-       RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, 0x03);       /* 2004-09-17 change from 0x01 */
-       RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, 0x00);
-
-       DBGPRINT(RT_DEBUG_TRACE, ("<-- NICIssueReset\n"));
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Check ASIC registers and find any reason the system might hang
-
-       Arguments:
-               Adapter                                         Pointer to our adapter
-
-       Return Value:
-               None
-
-       IRQL = DISPATCH_LEVEL
-
-       ========================================================================
-*/
-BOOLEAN NICCheckForHang(struct rt_rtmp_adapter *pAd)
-{
-       return (FALSE);
-}
-
-void NICUpdateFifoStaCounters(struct rt_rtmp_adapter *pAd)
-{
-       TX_STA_FIFO_STRUC StaFifo;
-       struct rt_mac_table_entry *pEntry;
-       u8 i = 0;
-       u8 pid = 0, wcid = 0;
-       char reTry;
-       u8 succMCS;
-
-       do {
-               RTMP_IO_READ32(pAd, TX_STA_FIFO, &StaFifo.word);
-
-               if (StaFifo.field.bValid == 0)
-                       break;
-
-               wcid = (u8)StaFifo.field.wcid;
-
-               /* ignore NoACK and MGMT frame use 0xFF as WCID */
-               if ((StaFifo.field.TxAckRequired == 0)
-                   || (wcid >= MAX_LEN_OF_MAC_TABLE)) {
-                       i++;
-                       continue;
-               }
-
-               /* PID store Tx MCS Rate */
-               pid = (u8)StaFifo.field.PidType;
-
-               pEntry = &pAd->MacTab.Content[wcid];
-
-               pEntry->DebugFIFOCount++;
-
-               if (StaFifo.field.TxBF) /* 3*3 */
-                       pEntry->TxBFCount++;
-
-               if (!StaFifo.field.TxSuccess) {
-                       pEntry->FIFOCount++;
-                       pEntry->OneSecTxFailCount++;
-
-                       if (pEntry->FIFOCount >= 1) {
-                               DBGPRINT(RT_DEBUG_TRACE, ("#"));
-                               pEntry->NoBADataCountDown = 64;
-
-                               if (pEntry->PsMode == PWR_ACTIVE) {
-                                       int tid;
-                                       for (tid = 0; tid < NUM_OF_TID; tid++) {
-                                               BAOriSessionTearDown(pAd,
-                                                                    pEntry->
-                                                                    Aid, tid,
-                                                                    FALSE,
-                                                                    FALSE);
-                                       }
-
-                                       /* Update the continuous transmission counter except PS mode */
-                                       pEntry->ContinueTxFailCnt++;
-                               } else {
-                                       /* Clear the FIFOCount when sta in Power Save mode. Basically we assume */
-                                       /*     this tx error happened due to sta just go to sleep. */
-                                       pEntry->FIFOCount = 0;
-                                       pEntry->ContinueTxFailCnt = 0;
-                               }
-                               /*pEntry->FIFOCount = 0; */
-                       }
-                       /*pEntry->bSendBAR = TRUE; */
-               } else {
-                       if ((pEntry->PsMode != PWR_SAVE)
-                           && (pEntry->NoBADataCountDown > 0)) {
-                               pEntry->NoBADataCountDown--;
-                               if (pEntry->NoBADataCountDown == 0) {
-                                       DBGPRINT(RT_DEBUG_TRACE, ("@\n"));
-                               }
-                       }
-
-                       pEntry->FIFOCount = 0;
-                       pEntry->OneSecTxNoRetryOkCount++;
-                       /* update NoDataIdleCount when successful send packet to STA. */
-                       pEntry->NoDataIdleCount = 0;
-                       pEntry->ContinueTxFailCnt = 0;
-               }
-
-               succMCS = StaFifo.field.SuccessRate & 0x7F;
-
-               reTry = pid - succMCS;
-
-               if (StaFifo.field.TxSuccess) {
-                       pEntry->TXMCSExpected[pid]++;
-                       if (pid == succMCS) {
-                               pEntry->TXMCSSuccessful[pid]++;
-                       } else {
-                               pEntry->TXMCSAutoFallBack[pid][succMCS]++;
-                       }
-               } else {
-                       pEntry->TXMCSFailed[pid]++;
-               }
-
-               if (reTry > 0) {
-                       if ((pid >= 12) && succMCS <= 7) {
-                               reTry -= 4;
-                       }
-                       pEntry->OneSecTxRetryOkCount += reTry;
-               }
-
-               i++;
-               /* ASIC store 16 stack */
-       } while (i < (2 * TX_RING_SIZE));
-
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Read statistical counters from hardware registers and record them
-               in software variables for later on query
-
-       Arguments:
-               pAd                                     Pointer to our adapter
-
-       Return Value:
-               None
-
-       IRQL = DISPATCH_LEVEL
-
-       ========================================================================
-*/
-void NICUpdateRawCounters(struct rt_rtmp_adapter *pAd)
-{
-       u32 OldValue;   /*, Value2; */
-       /*unsigned long PageSum, OneSecTransmitCount; */
-       /*unsigned long TxErrorRatio, Retry, Fail; */
-       RX_STA_CNT0_STRUC RxStaCnt0;
-       RX_STA_CNT1_STRUC RxStaCnt1;
-       RX_STA_CNT2_STRUC RxStaCnt2;
-       TX_STA_CNT0_STRUC TxStaCnt0;
-       TX_STA_CNT1_STRUC StaTx1;
-       TX_STA_CNT2_STRUC StaTx2;
-       TX_AGG_CNT_STRUC TxAggCnt;
-       TX_AGG_CNT0_STRUC TxAggCnt0;
-       TX_AGG_CNT1_STRUC TxAggCnt1;
-       TX_AGG_CNT2_STRUC TxAggCnt2;
-       TX_AGG_CNT3_STRUC TxAggCnt3;
-       TX_AGG_CNT4_STRUC TxAggCnt4;
-       TX_AGG_CNT5_STRUC TxAggCnt5;
-       TX_AGG_CNT6_STRUC TxAggCnt6;
-       TX_AGG_CNT7_STRUC TxAggCnt7;
-       struct rt_counter_ralink *pRalinkCounters;
-
-       pRalinkCounters = &pAd->RalinkCounters;
-
-       RTMP_IO_READ32(pAd, RX_STA_CNT0, &RxStaCnt0.word);
-       RTMP_IO_READ32(pAd, RX_STA_CNT2, &RxStaCnt2.word);
-
-       {
-               RTMP_IO_READ32(pAd, RX_STA_CNT1, &RxStaCnt1.word);
-               /* Update RX PLCP error counter */
-               pAd->PrivateInfo.PhyRxErrCnt += RxStaCnt1.field.PlcpErr;
-               /* Update False CCA counter */
-               pAd->RalinkCounters.OneSecFalseCCACnt +=
-                   RxStaCnt1.field.FalseCca;
-       }
-
-       /* Update FCS counters */
-       OldValue = pAd->WlanCounters.FCSErrorCount.u.LowPart;
-       pAd->WlanCounters.FCSErrorCount.u.LowPart += (RxStaCnt0.field.CrcErr);  /* >> 7); */
-       if (pAd->WlanCounters.FCSErrorCount.u.LowPart < OldValue)
-               pAd->WlanCounters.FCSErrorCount.u.HighPart++;
-
-       /* Add FCS error count to private counters */
-       pRalinkCounters->OneSecRxFcsErrCnt += RxStaCnt0.field.CrcErr;
-       OldValue = pRalinkCounters->RealFcsErrCount.u.LowPart;
-       pRalinkCounters->RealFcsErrCount.u.LowPart += RxStaCnt0.field.CrcErr;
-       if (pRalinkCounters->RealFcsErrCount.u.LowPart < OldValue)
-               pRalinkCounters->RealFcsErrCount.u.HighPart++;
-
-       /* Update Duplicate Rcv check */
-       pRalinkCounters->DuplicateRcv += RxStaCnt2.field.RxDupliCount;
-       pAd->WlanCounters.FrameDuplicateCount.u.LowPart +=
-           RxStaCnt2.field.RxDupliCount;
-       /* Update RX Overflow counter */
-       pAd->Counters8023.RxNoBuffer += (RxStaCnt2.field.RxFifoOverflowCount);
-
-       /*pAd->RalinkCounters.RxCount = 0; */
-#ifdef RTMP_MAC_USB
-       if (pRalinkCounters->RxCount != pAd->watchDogRxCnt) {
-               pAd->watchDogRxCnt = pRalinkCounters->RxCount;
-               pAd->watchDogRxOverFlowCnt = 0;
-       } else {
-               if (RxStaCnt2.field.RxFifoOverflowCount)
-                       pAd->watchDogRxOverFlowCnt++;
-               else
-                       pAd->watchDogRxOverFlowCnt = 0;
-       }
-#endif /* RTMP_MAC_USB // */
-
-       /*if (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_TX_RATE_SWITCH_ENABLED) || */
-       /*      (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_TX_RATE_SWITCH_ENABLED) && (pAd->MacTab.Size != 1))) */
-       if (!pAd->bUpdateBcnCntDone) {
-               /* Update BEACON sent count */
-               RTMP_IO_READ32(pAd, TX_STA_CNT0, &TxStaCnt0.word);
-               RTMP_IO_READ32(pAd, TX_STA_CNT1, &StaTx1.word);
-               RTMP_IO_READ32(pAd, TX_STA_CNT2, &StaTx2.word);
-               pRalinkCounters->OneSecBeaconSentCnt +=
-                   TxStaCnt0.field.TxBeaconCount;
-               pRalinkCounters->OneSecTxRetryOkCount +=
-                   StaTx1.field.TxRetransmit;
-               pRalinkCounters->OneSecTxNoRetryOkCount +=
-                   StaTx1.field.TxSuccess;
-               pRalinkCounters->OneSecTxFailCount +=
-                   TxStaCnt0.field.TxFailCount;
-               pAd->WlanCounters.TransmittedFragmentCount.u.LowPart +=
-                   StaTx1.field.TxSuccess;
-               pAd->WlanCounters.RetryCount.u.LowPart +=
-                   StaTx1.field.TxRetransmit;
-               pAd->WlanCounters.FailedCount.u.LowPart +=
-                   TxStaCnt0.field.TxFailCount;
-       }
-
-       /*if (pAd->bStaFifoTest == TRUE) */
-       {
-               RTMP_IO_READ32(pAd, TX_AGG_CNT, &TxAggCnt.word);
-               RTMP_IO_READ32(pAd, TX_AGG_CNT0, &TxAggCnt0.word);
-               RTMP_IO_READ32(pAd, TX_AGG_CNT1, &TxAggCnt1.word);
-               RTMP_IO_READ32(pAd, TX_AGG_CNT2, &TxAggCnt2.word);
-               RTMP_IO_READ32(pAd, TX_AGG_CNT3, &TxAggCnt3.word);
-               RTMP_IO_READ32(pAd, TX_AGG_CNT4, &TxAggCnt4.word);
-               RTMP_IO_READ32(pAd, TX_AGG_CNT5, &TxAggCnt5.word);
-               RTMP_IO_READ32(pAd, TX_AGG_CNT6, &TxAggCnt6.word);
-               RTMP_IO_READ32(pAd, TX_AGG_CNT7, &TxAggCnt7.word);
-               pRalinkCounters->TxAggCount += TxAggCnt.field.AggTxCount;
-               pRalinkCounters->TxNonAggCount += TxAggCnt.field.NonAggTxCount;
-               pRalinkCounters->TxAgg1MPDUCount +=
-                   TxAggCnt0.field.AggSize1Count;
-               pRalinkCounters->TxAgg2MPDUCount +=
-                   TxAggCnt0.field.AggSize2Count;
-
-               pRalinkCounters->TxAgg3MPDUCount +=
-                   TxAggCnt1.field.AggSize3Count;
-               pRalinkCounters->TxAgg4MPDUCount +=
-                   TxAggCnt1.field.AggSize4Count;
-               pRalinkCounters->TxAgg5MPDUCount +=
-                   TxAggCnt2.field.AggSize5Count;
-               pRalinkCounters->TxAgg6MPDUCount +=
-                   TxAggCnt2.field.AggSize6Count;
-
-               pRalinkCounters->TxAgg7MPDUCount +=
-                   TxAggCnt3.field.AggSize7Count;
-               pRalinkCounters->TxAgg8MPDUCount +=
-                   TxAggCnt3.field.AggSize8Count;
-               pRalinkCounters->TxAgg9MPDUCount +=
-                   TxAggCnt4.field.AggSize9Count;
-               pRalinkCounters->TxAgg10MPDUCount +=
-                   TxAggCnt4.field.AggSize10Count;
-
-               pRalinkCounters->TxAgg11MPDUCount +=
-                   TxAggCnt5.field.AggSize11Count;
-               pRalinkCounters->TxAgg12MPDUCount +=
-                   TxAggCnt5.field.AggSize12Count;
-               pRalinkCounters->TxAgg13MPDUCount +=
-                   TxAggCnt6.field.AggSize13Count;
-               pRalinkCounters->TxAgg14MPDUCount +=
-                   TxAggCnt6.field.AggSize14Count;
-
-               pRalinkCounters->TxAgg15MPDUCount +=
-                   TxAggCnt7.field.AggSize15Count;
-               pRalinkCounters->TxAgg16MPDUCount +=
-                   TxAggCnt7.field.AggSize16Count;
-
-               /* Calculate the transmitted A-MPDU count */
-               pRalinkCounters->TransmittedAMPDUCount.u.LowPart +=
-                   TxAggCnt0.field.AggSize1Count;
-               pRalinkCounters->TransmittedAMPDUCount.u.LowPart +=
-                   (TxAggCnt0.field.AggSize2Count / 2);
-
-               pRalinkCounters->TransmittedAMPDUCount.u.LowPart +=
-                   (TxAggCnt1.field.AggSize3Count / 3);
-               pRalinkCounters->TransmittedAMPDUCount.u.LowPart +=
-                   (TxAggCnt1.field.AggSize4Count / 4);
-
-               pRalinkCounters->TransmittedAMPDUCount.u.LowPart +=
-                   (TxAggCnt2.field.AggSize5Count / 5);
-               pRalinkCounters->TransmittedAMPDUCount.u.LowPart +=
-                   (TxAggCnt2.field.AggSize6Count / 6);
-
-               pRalinkCounters->TransmittedAMPDUCount.u.LowPart +=
-                   (TxAggCnt3.field.AggSize7Count / 7);
-               pRalinkCounters->TransmittedAMPDUCount.u.LowPart +=
-                   (TxAggCnt3.field.AggSize8Count / 8);
-
-               pRalinkCounters->TransmittedAMPDUCount.u.LowPart +=
-                   (TxAggCnt4.field.AggSize9Count / 9);
-               pRalinkCounters->TransmittedAMPDUCount.u.LowPart +=
-                   (TxAggCnt4.field.AggSize10Count / 10);
-
-               pRalinkCounters->TransmittedAMPDUCount.u.LowPart +=
-                   (TxAggCnt5.field.AggSize11Count / 11);
-               pRalinkCounters->TransmittedAMPDUCount.u.LowPart +=
-                   (TxAggCnt5.field.AggSize12Count / 12);
-
-               pRalinkCounters->TransmittedAMPDUCount.u.LowPart +=
-                   (TxAggCnt6.field.AggSize13Count / 13);
-               pRalinkCounters->TransmittedAMPDUCount.u.LowPart +=
-                   (TxAggCnt6.field.AggSize14Count / 14);
-
-               pRalinkCounters->TransmittedAMPDUCount.u.LowPart +=
-                   (TxAggCnt7.field.AggSize15Count / 15);
-               pRalinkCounters->TransmittedAMPDUCount.u.LowPart +=
-                   (TxAggCnt7.field.AggSize16Count / 16);
-       }
-
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Reset NIC from error
-
-       Arguments:
-               Adapter                                         Pointer to our adapter
-
-       Return Value:
-               None
-
-       IRQL = PASSIVE_LEVEL
-
-       Note:
-               Reset NIC from error state
-
-       ========================================================================
-*/
-void NICResetFromError(struct rt_rtmp_adapter *pAd)
-{
-       /* Reset BBP (according to alex, reset ASIC will force reset BBP */
-       /* Therefore, skip the reset BBP */
-       /* RTMP_IO_WRITE32(pAd, MAC_CSR1, 0x2); */
-
-       RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, 0x1);
-       /* Remove ASIC from reset state */
-       RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, 0x0);
-
-       NICInitializeAdapter(pAd, FALSE);
-       NICInitAsicFromEEPROM(pAd);
-
-       /* Switch to current channel, since during reset process, the connection should remains on. */
-       AsicSwitchChannel(pAd, pAd->CommonCfg.CentralChannel, FALSE);
-       AsicLockChannel(pAd, pAd->CommonCfg.CentralChannel);
-}
-
-int NICLoadFirmware(struct rt_rtmp_adapter *pAd)
-{
-       int status = NDIS_STATUS_SUCCESS;
-       if (pAd->chipOps.loadFirmware)
-               status = pAd->chipOps.loadFirmware(pAd);
-
-       return status;
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               erase 8051 firmware image in MAC ASIC
-
-       Arguments:
-               Adapter                                         Pointer to our adapter
-
-       IRQL = PASSIVE_LEVEL
-
-       ========================================================================
-*/
-void NICEraseFirmware(struct rt_rtmp_adapter *pAd)
-{
-       if (pAd->chipOps.eraseFirmware)
-               pAd->chipOps.eraseFirmware(pAd);
-
-}                              /* End of NICEraseFirmware */
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Load Tx rate switching parameters
-
-       Arguments:
-               Adapter                                         Pointer to our adapter
-
-       Return Value:
-               NDIS_STATUS_SUCCESS         firmware image load ok
-               NDIS_STATUS_FAILURE         image not found
-
-       IRQL = PASSIVE_LEVEL
-
-       Rate Table Format:
-               1. (B0: Valid Item number) (B1:Initial item from zero)
-               2. Item Number(Dec)      Mode(Hex)     Current MCS(Dec)    TrainUp(Dec)    TrainDown(Dec)
-
-       ========================================================================
-*/
-int NICLoadRateSwitchingParams(struct rt_rtmp_adapter *pAd)
-{
-       return NDIS_STATUS_SUCCESS;
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Compare two memory block
-
-       Arguments:
-               pSrc1           Pointer to first memory address
-               pSrc2           Pointer to second memory address
-
-       Return Value:
-               0:                      memory is equal
-               1:                      pSrc1 memory is larger
-               2:                      pSrc2 memory is larger
-
-       IRQL = DISPATCH_LEVEL
-
-       Note:
-
-       ========================================================================
-*/
-unsigned long RTMPCompareMemory(void *pSrc1, void *pSrc2, unsigned long Length)
-{
-       u8 *pMem1;
-       u8 *pMem2;
-       unsigned long Index = 0;
-
-       pMem1 = (u8 *)pSrc1;
-       pMem2 = (u8 *)pSrc2;
-
-       for (Index = 0; Index < Length; Index++) {
-               if (pMem1[Index] > pMem2[Index])
-                       return (1);
-               else if (pMem1[Index] < pMem2[Index])
-                       return (2);
-       }
-
-       /* Equal */
-       return (0);
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Zero out memory block
-
-       Arguments:
-               pSrc1           Pointer to memory address
-               Length          Size
-
-       Return Value:
-               None
-
-       IRQL = PASSIVE_LEVEL
-       IRQL = DISPATCH_LEVEL
-
-       Note:
-
-       ========================================================================
-*/
-void RTMPZeroMemory(void *pSrc, unsigned long Length)
-{
-       u8 *pMem;
-       unsigned long Index = 0;
-
-       pMem = (u8 *)pSrc;
-
-       for (Index = 0; Index < Length; Index++) {
-               pMem[Index] = 0x00;
-       }
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Copy data from memory block 1 to memory block 2
-
-       Arguments:
-               pDest           Pointer to destination memory address
-               pSrc            Pointer to source memory address
-               Length          Copy size
-
-       Return Value:
-               None
-
-       IRQL = PASSIVE_LEVEL
-       IRQL = DISPATCH_LEVEL
-
-       Note:
-
-       ========================================================================
-*/
-void RTMPMoveMemory(void *pDest, void *pSrc, unsigned long Length)
-{
-       u8 *pMem1;
-       u8 *pMem2;
-       u32 Index;
-
-       ASSERT((Length == 0) || (pDest && pSrc));
-
-       pMem1 = (u8 *)pDest;
-       pMem2 = (u8 *)pSrc;
-
-       for (Index = 0; Index < Length; Index++) {
-               pMem1[Index] = pMem2[Index];
-       }
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Initialize port configuration structure
-
-       Arguments:
-               Adapter                                         Pointer to our adapter
-
-       Return Value:
-               None
-
-       IRQL = PASSIVE_LEVEL
-
-       Note:
-
-       ========================================================================
-*/
-void UserCfgInit(struct rt_rtmp_adapter *pAd)
-{
-       u32 key_index, bss_index;
-
-       DBGPRINT(RT_DEBUG_TRACE, ("--> UserCfgInit\n"));
-
-       /* */
-       /*  part I. initialize common configuration */
-       /* */
-#ifdef RTMP_MAC_USB
-       pAd->BulkOutReq = 0;
-
-       pAd->BulkOutComplete = 0;
-       pAd->BulkOutCompleteOther = 0;
-       pAd->BulkOutCompleteCancel = 0;
-       pAd->BulkInReq = 0;
-       pAd->BulkInComplete = 0;
-       pAd->BulkInCompleteFail = 0;
-
-       /*pAd->QuickTimerP = 100; */
-       /*pAd->TurnAggrBulkInCount = 0; */
-       pAd->bUsbTxBulkAggre = 0;
-
-       /* init as unused value to ensure driver will set to MCU once. */
-       pAd->LedIndicatorStrength = 0xFF;
-
-       pAd->CommonCfg.MaxPktOneTxBulk = 2;
-       pAd->CommonCfg.TxBulkFactor = 1;
-       pAd->CommonCfg.RxBulkFactor = 1;
-
-       pAd->CommonCfg.TxPower = 100;   /*mW */
-
-       NdisZeroMemory(&pAd->CommonCfg.IOTestParm,
-                      sizeof(pAd->CommonCfg.IOTestParm));
-#endif /* RTMP_MAC_USB // */
-
-       for (key_index = 0; key_index < SHARE_KEY_NUM; key_index++) {
-               for (bss_index = 0; bss_index < MAX_MBSSID_NUM; bss_index++) {
-                       pAd->SharedKey[bss_index][key_index].KeyLen = 0;
-                       pAd->SharedKey[bss_index][key_index].CipherAlg =
-                           CIPHER_NONE;
-               }
-       }
-
-       pAd->EepromAccess = FALSE;
-
-       pAd->Antenna.word = 0;
-       pAd->CommonCfg.BBPCurrentBW = BW_20;
-
-       pAd->LedCntl.word = 0;
-#ifdef RTMP_MAC_PCI
-       pAd->LedIndicatorStrength = 0;
-       pAd->RLnkCtrlOffset = 0;
-       pAd->HostLnkCtrlOffset = 0;
-       pAd->StaCfg.PSControl.field.EnableNewPS = TRUE;
-       pAd->CheckDmaBusyCount = 0;
-#endif /* RTMP_MAC_PCI // */
-
-       pAd->bAutoTxAgcA = FALSE;       /* Default is OFF */
-       pAd->bAutoTxAgcG = FALSE;       /* Default is OFF */
-       pAd->RfIcType = RFIC_2820;
-
-       /* Init timer for reset complete event */
-       pAd->CommonCfg.CentralChannel = 1;
-       pAd->bForcePrintTX = FALSE;
-       pAd->bForcePrintRX = FALSE;
-       pAd->bStaFifoTest = FALSE;
-       pAd->bProtectionTest = FALSE;
-       pAd->CommonCfg.Dsifs = 10;      /* in units of usec */
-       pAd->CommonCfg.TxPower = 100;   /*mW */
-       pAd->CommonCfg.TxPowerPercentage = 0xffffffff;  /* AUTO */
-       pAd->CommonCfg.TxPowerDefault = 0xffffffff;     /* AUTO */
-       pAd->CommonCfg.TxPreamble = Rt802_11PreambleAuto;       /* use Long preamble on TX by defaut */
-       pAd->CommonCfg.bUseZeroToDisableFragment = FALSE;
-       pAd->CommonCfg.RtsThreshold = 2347;
-       pAd->CommonCfg.FragmentThreshold = 2346;
-       pAd->CommonCfg.UseBGProtection = 0;     /* 0: AUTO */
-       pAd->CommonCfg.bEnableTxBurst = TRUE;   /*0; */
-       pAd->CommonCfg.PhyMode = 0xff;  /* unknown */
-       pAd->CommonCfg.BandState = UNKNOWN_BAND;
-       pAd->CommonCfg.RadarDetect.CSPeriod = 10;
-       pAd->CommonCfg.RadarDetect.CSCount = 0;
-       pAd->CommonCfg.RadarDetect.RDMode = RD_NORMAL_MODE;
-
-       pAd->CommonCfg.RadarDetect.ChMovingTime = 65;
-       pAd->CommonCfg.RadarDetect.LongPulseRadarTh = 3;
-       pAd->CommonCfg.bAPSDCapable = FALSE;
-       pAd->CommonCfg.bNeedSendTriggerFrame = FALSE;
-       pAd->CommonCfg.TriggerTimerCount = 0;
-       pAd->CommonCfg.bAPSDForcePowerSave = FALSE;
-       pAd->CommonCfg.bCountryFlag = FALSE;
-       pAd->CommonCfg.TxStream = 0;
-       pAd->CommonCfg.RxStream = 0;
-
-       NdisZeroMemory(&pAd->BeaconTxWI, sizeof(pAd->BeaconTxWI));
-
-       NdisZeroMemory(&pAd->CommonCfg.HtCapability,
-                      sizeof(pAd->CommonCfg.HtCapability));
-       pAd->HTCEnable = FALSE;
-       pAd->bBroadComHT = FALSE;
-       pAd->CommonCfg.bRdg = FALSE;
-
-       NdisZeroMemory(&pAd->CommonCfg.AddHTInfo,
-                      sizeof(pAd->CommonCfg.AddHTInfo));
-       pAd->CommonCfg.BACapability.field.MMPSmode = MMPS_ENABLE;
-       pAd->CommonCfg.BACapability.field.MpduDensity = 0;
-       pAd->CommonCfg.BACapability.field.Policy = IMMED_BA;
-       pAd->CommonCfg.BACapability.field.RxBAWinLimit = 64;    /*32; */
-       pAd->CommonCfg.BACapability.field.TxBAWinLimit = 64;    /*32; */
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("--> UserCfgInit. BACapability = 0x%x\n",
-                 pAd->CommonCfg.BACapability.word));
-
-       pAd->CommonCfg.BACapability.field.AutoBA = FALSE;
-       BATableInit(pAd, &pAd->BATable);
-
-       pAd->CommonCfg.bExtChannelSwitchAnnouncement = 1;
-       pAd->CommonCfg.bHTProtect = 1;
-       pAd->CommonCfg.bMIMOPSEnable = TRUE;
-       /*2008/11/05:KH add to support Antenna power-saving of AP<-- */
-       pAd->CommonCfg.bGreenAPEnable = FALSE;
-       /*2008/11/05:KH add to support Antenna power-saving of AP--> */
-       pAd->CommonCfg.bBADecline = FALSE;
-       pAd->CommonCfg.bDisableReordering = FALSE;
-
-       if (pAd->MACVersion == 0x28720200) {
-               pAd->CommonCfg.TxBASize = 13;   /*by Jerry recommend */
-       } else {
-               pAd->CommonCfg.TxBASize = 7;
-       }
-
-       pAd->CommonCfg.REGBACapability.word = pAd->CommonCfg.BACapability.word;
-
-       /*pAd->CommonCfg.HTPhyMode.field.BW = BW_20; */
-       /*pAd->CommonCfg.HTPhyMode.field.MCS = MCS_AUTO; */
-       /*pAd->CommonCfg.HTPhyMode.field.ShortGI = GI_800; */
-       /*pAd->CommonCfg.HTPhyMode.field.STBC = STBC_NONE; */
-       pAd->CommonCfg.TxRate = RATE_6;
-
-       pAd->CommonCfg.MlmeTransmit.field.MCS = MCS_RATE_6;
-       pAd->CommonCfg.MlmeTransmit.field.BW = BW_20;
-       pAd->CommonCfg.MlmeTransmit.field.MODE = MODE_OFDM;
-
-       pAd->CommonCfg.BeaconPeriod = 100;      /* in mSec */
-
-       /* */
-       /* part II. initialize STA specific configuration */
-       /* */
-       {
-               RX_FILTER_SET_FLAG(pAd, fRX_FILTER_ACCEPT_DIRECT);
-               RX_FILTER_CLEAR_FLAG(pAd, fRX_FILTER_ACCEPT_MULTICAST);
-               RX_FILTER_SET_FLAG(pAd, fRX_FILTER_ACCEPT_BROADCAST);
-               RX_FILTER_SET_FLAG(pAd, fRX_FILTER_ACCEPT_ALL_MULTICAST);
-
-               pAd->StaCfg.Psm = PWR_ACTIVE;
-
-               pAd->StaCfg.OrigWepStatus = Ndis802_11EncryptionDisabled;
-               pAd->StaCfg.PairCipher = Ndis802_11EncryptionDisabled;
-               pAd->StaCfg.GroupCipher = Ndis802_11EncryptionDisabled;
-               pAd->StaCfg.bMixCipher = FALSE;
-               pAd->StaCfg.DefaultKeyId = 0;
-
-               /* 802.1x port control */
-               pAd->StaCfg.PrivacyFilter = Ndis802_11PrivFilter8021xWEP;
-               pAd->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
-               pAd->StaCfg.LastMicErrorTime = 0;
-               pAd->StaCfg.MicErrCnt = 0;
-               pAd->StaCfg.bBlockAssoc = FALSE;
-               pAd->StaCfg.WpaState = SS_NOTUSE;
-
-               pAd->CommonCfg.NdisRadioStateOff = FALSE;       /* New to support microsoft disable radio with OID command */
-
-               pAd->StaCfg.RssiTrigger = 0;
-               NdisZeroMemory(&pAd->StaCfg.RssiSample, sizeof(struct rt_rssi_sample));
-               pAd->StaCfg.RssiTriggerMode =
-                   RSSI_TRIGGERED_UPON_BELOW_THRESHOLD;
-               pAd->StaCfg.AtimWin = 0;
-               pAd->StaCfg.DefaultListenCount = 3;     /*default listen count; */
-               pAd->StaCfg.BssType = BSS_INFRA;        /* BSS_INFRA or BSS_ADHOC or BSS_MONITOR */
-               pAd->StaCfg.bScanReqIsFromWebUI = FALSE;
-               OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_DOZE);
-               OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_WAKEUP_NOW);
-
-               pAd->StaCfg.bAutoTxRateSwitch = TRUE;
-               pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
-       }
-
-#ifdef PCIE_PS_SUPPORT
-       pAd->brt30xxBanMcuCmd = FALSE;
-       pAd->b3090ESpecialChip = FALSE;
-/*KH Debug:the following must be removed */
-       pAd->StaCfg.PSControl.field.rt30xxPowerMode = 3;
-       pAd->StaCfg.PSControl.field.rt30xxForceASPMTest = 0;
-       pAd->StaCfg.PSControl.field.rt30xxFollowHostASPM = 1;
-#endif /* PCIE_PS_SUPPORT // */
-
-       /* global variables mXXXX used in MAC protocol state machines */
-       OPSTATUS_SET_FLAG(pAd, fOP_STATUS_RECEIVE_DTIM);
-       OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_ADHOC_ON);
-       OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_INFRA_ON);
-
-       /* PHY specification */
-       pAd->CommonCfg.PhyMode = PHY_11BG_MIXED;        /* default PHY mode */
-       OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_SHORT_PREAMBLE_INUSED);     /* CCK use long preamble */
-
-       {
-               /* user desired power mode */
-               pAd->StaCfg.WindowsPowerMode = Ndis802_11PowerModeCAM;
-               pAd->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeCAM;
-               pAd->StaCfg.bWindowsACCAMEnable = FALSE;
-
-               RTMPInitTimer(pAd, &pAd->StaCfg.StaQuickResponeForRateUpTimer,
-                             GET_TIMER_FUNCTION(StaQuickResponeForRateUpExec),
-                             pAd, FALSE);
-               pAd->StaCfg.StaQuickResponeForRateUpTimerRunning = FALSE;
-
-               /* Patch for Ndtest */
-               pAd->StaCfg.ScanCnt = 0;
-
-               pAd->StaCfg.bHwRadio = TRUE;    /* Default Hardware Radio status is On */
-               pAd->StaCfg.bSwRadio = TRUE;    /* Default Software Radio status is On */
-               pAd->StaCfg.bRadio = TRUE;      /* bHwRadio && bSwRadio */
-               pAd->StaCfg.bHardwareRadio = FALSE;     /* Default is OFF */
-               pAd->StaCfg.bShowHiddenSSID = FALSE;    /* Default no show */
-
-               /* Nitro mode control */
-               pAd->StaCfg.bAutoReconnect = TRUE;
-
-               /* Save the init time as last scan time, the system should do scan after 2 seconds. */
-               /* This patch is for driver wake up from standby mode, system will do scan right away. */
-               NdisGetSystemUpTime(&pAd->StaCfg.LastScanTime);
-               if (pAd->StaCfg.LastScanTime > 10 * OS_HZ)
-                       pAd->StaCfg.LastScanTime -= (10 * OS_HZ);
-
-               NdisZeroMemory(pAd->nickname, IW_ESSID_MAX_SIZE + 1);
-#ifdef RTMP_MAC_PCI
-               sprintf((char *)pAd->nickname, "RT2860STA");
-#endif /* RTMP_MAC_PCI // */
-#ifdef RTMP_MAC_USB
-               sprintf((char *)pAd->nickname, "RT2870STA");
-#endif /* RTMP_MAC_USB // */
-               RTMPInitTimer(pAd, &pAd->StaCfg.WpaDisassocAndBlockAssocTimer,
-                             GET_TIMER_FUNCTION(WpaDisassocApAndBlockAssoc),
-                             pAd, FALSE);
-               pAd->StaCfg.IEEE8021X = FALSE;
-               pAd->StaCfg.IEEE8021x_required_keys = FALSE;
-               pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_DISABLE;
-               pAd->StaCfg.bRSN_IE_FromWpaSupplicant = FALSE;
-               pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_ENABLE;
-
-               NdisZeroMemory(pAd->StaCfg.ReplayCounter, 8);
-
-               pAd->StaCfg.bAutoConnectByBssid = FALSE;
-               pAd->StaCfg.BeaconLostTime = BEACON_LOST_TIME;
-               NdisZeroMemory(pAd->StaCfg.WpaPassPhrase, 64);
-               pAd->StaCfg.WpaPassPhraseLen = 0;
-               pAd->StaCfg.bAutoRoaming = FALSE;
-               pAd->StaCfg.bForceTxBurst = FALSE;
-       }
-
-       /* Default for extra information is not valid */
-       pAd->ExtraInfo = EXTRA_INFO_CLEAR;
-
-       /* Default Config change flag */
-       pAd->bConfigChanged = FALSE;
-
-       /* */
-       /* part III. AP configurations */
-       /* */
-
-       /* */
-       /* part IV. others */
-       /* */
-       /* dynamic BBP R66:sensibity tuning to overcome background noise */
-       pAd->BbpTuning.bEnable = TRUE;
-       pAd->BbpTuning.FalseCcaLowerThreshold = 100;
-       pAd->BbpTuning.FalseCcaUpperThreshold = 512;
-       pAd->BbpTuning.R66Delta = 4;
-       pAd->Mlme.bEnableAutoAntennaCheck = TRUE;
-
-       /* */
-       /* Also initial R66CurrentValue, RTUSBResumeMsduTransmission might use this value. */
-       /* if not initial this value, the default value will be 0. */
-       /* */
-       pAd->BbpTuning.R66CurrentValue = 0x38;
-
-       pAd->Bbp94 = BBPR94_DEFAULT;
-       pAd->BbpForCCK = FALSE;
-
-       /* Default is FALSE for test bit 1 */
-       /*pAd->bTest1 = FALSE; */
-
-       /* initialize MAC table and allocate spin lock */
-       NdisZeroMemory(&pAd->MacTab, sizeof(struct rt_mac_table));
-       InitializeQueueHeader(&pAd->MacTab.McastPsQueue);
-       NdisAllocateSpinLock(&pAd->MacTabLock);
-
-       /*RTMPInitTimer(pAd, &pAd->RECBATimer, RECBATimerTimeout, pAd, TRUE); */
-       /*RTMPSetTimer(&pAd->RECBATimer, REORDER_EXEC_INTV); */
-
-       pAd->CommonCfg.bWiFiTest = FALSE;
-#ifdef RTMP_MAC_PCI
-       pAd->bPCIclkOff = FALSE;
-#endif /* RTMP_MAC_PCI // */
-
-       RTMP_SET_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
-       DBGPRINT(RT_DEBUG_TRACE, ("<-- UserCfgInit\n"));
-}
-
-/* IRQL = PASSIVE_LEVEL */
-/* */
-/*  FUNCTION: AtoH(char *, u8 *, int) */
-/* */
-/*  PURPOSE:  Converts ascii string to network order hex */
-/* */
-/*  PARAMETERS: */
-/*    src    - pointer to input ascii string */
-/*    dest   - pointer to output hex */
-/*    destlen - size of dest */
-/* */
-/*  COMMENTS: */
-/* */
-/*    2 ascii bytes make a hex byte so must put 1st ascii byte of pair */
-/*    into upper nibble and 2nd ascii byte of pair into lower nibble. */
-/* */
-/* IRQL = PASSIVE_LEVEL */
-
-void AtoH(char *src, u8 *dest, int destlen)
-{
-       char *srcptr;
-       u8 *destTemp;
-
-       srcptr = src;
-       destTemp = (u8 *)dest;
-
-       while (destlen--) {
-               *destTemp = hex_to_bin(*srcptr++) << 4; /* Put 1st ascii byte in upper nibble. */
-               *destTemp += hex_to_bin(*srcptr++);     /* Add 2nd ascii byte to above. */
-               destTemp++;
-       }
-}
-
-/*+++Mark by shiang, not use now, need to remove after confirm */
-/*---Mark by shiang, not use now, need to remove after confirm */
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Init timer objects
-
-       Arguments:
-               pAd                     Pointer to our adapter
-               pTimer                          Timer structure
-               pTimerFunc                      Function to execute when timer expired
-               Repeat                          Ture for period timer
-
-       Return Value:
-               None
-
-       Note:
-
-       ========================================================================
-*/
-void RTMPInitTimer(struct rt_rtmp_adapter *pAd,
-                  struct rt_ralink_timer *pTimer,
-                  void *pTimerFunc, void *pData, IN BOOLEAN Repeat)
-{
-       /* */
-       /* Set Valid to TRUE for later used. */
-       /* It will crash if we cancel a timer or set a timer */
-       /* that we haven't initialize before. */
-       /* */
-       pTimer->Valid = TRUE;
-
-       pTimer->PeriodicType = Repeat;
-       pTimer->State = FALSE;
-       pTimer->cookie = (unsigned long)pData;
-
-#ifdef RTMP_TIMER_TASK_SUPPORT
-       pTimer->pAd = pAd;
-#endif /* RTMP_TIMER_TASK_SUPPORT // */
-
-       RTMP_OS_Init_Timer(pAd, &pTimer->TimerObj, pTimerFunc, (void *)pTimer);
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Init timer objects
-
-       Arguments:
-               pTimer                          Timer structure
-               Value                           Timer value in milliseconds
-
-       Return Value:
-               None
-
-       Note:
-               To use this routine, must call RTMPInitTimer before.
-
-       ========================================================================
-*/
-void RTMPSetTimer(struct rt_ralink_timer *pTimer, unsigned long Value)
-{
-       if (pTimer->Valid) {
-               pTimer->TimerValue = Value;
-               pTimer->State = FALSE;
-               if (pTimer->PeriodicType == TRUE) {
-                       pTimer->Repeat = TRUE;
-                       RTMP_SetPeriodicTimer(&pTimer->TimerObj, Value);
-               } else {
-                       pTimer->Repeat = FALSE;
-                       RTMP_OS_Add_Timer(&pTimer->TimerObj, Value);
-               }
-       } else {
-               DBGPRINT_ERR("RTMPSetTimer failed, Timer hasn't been initialize!\n");
-       }
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Init timer objects
-
-       Arguments:
-               pTimer                          Timer structure
-               Value                           Timer value in milliseconds
-
-       Return Value:
-               None
-
-       Note:
-               To use this routine, must call RTMPInitTimer before.
-
-       ========================================================================
-*/
-void RTMPModTimer(struct rt_ralink_timer *pTimer, unsigned long Value)
-{
-       BOOLEAN Cancel;
-
-       if (pTimer->Valid) {
-               pTimer->TimerValue = Value;
-               pTimer->State = FALSE;
-               if (pTimer->PeriodicType == TRUE) {
-                       RTMPCancelTimer(pTimer, &Cancel);
-                       RTMPSetTimer(pTimer, Value);
-               } else {
-                       RTMP_OS_Mod_Timer(&pTimer->TimerObj, Value);
-               }
-       } else {
-               DBGPRINT_ERR("RTMPModTimer failed, Timer hasn't been initialize!\n");
-       }
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Cancel timer objects
-
-       Arguments:
-               Adapter                                         Pointer to our adapter
-
-       Return Value:
-               None
-
-       IRQL = PASSIVE_LEVEL
-       IRQL = DISPATCH_LEVEL
-
-       Note:
-               1.) To use this routine, must call RTMPInitTimer before.
-               2.) Reset NIC to initial state AS IS system boot up time.
-
-       ========================================================================
-*/
-void RTMPCancelTimer(struct rt_ralink_timer *pTimer, OUT BOOLEAN * pCancelled)
-{
-       if (pTimer->Valid) {
-               if (pTimer->State == FALSE)
-                       pTimer->Repeat = FALSE;
-
-               RTMP_OS_Del_Timer(&pTimer->TimerObj, pCancelled);
-
-               if (*pCancelled == TRUE)
-                       pTimer->State = TRUE;
-
-#ifdef RTMP_TIMER_TASK_SUPPORT
-               /* We need to go-through the TimerQ to findout this timer handler and remove it if */
-               /*              it's still waiting for execution. */
-               RtmpTimerQRemove(pTimer->pAd, pTimer);
-#endif /* RTMP_TIMER_TASK_SUPPORT // */
-       } else {
-               DBGPRINT_ERR("RTMPCancelTimer failed, Timer hasn't been initialize!\n");
-       }
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Set LED Status
-
-       Arguments:
-               pAd                                             Pointer to our adapter
-               Status                                  LED Status
-
-       Return Value:
-               None
-
-       IRQL = PASSIVE_LEVEL
-       IRQL = DISPATCH_LEVEL
-
-       Note:
-
-       ========================================================================
-*/
-void RTMPSetLED(struct rt_rtmp_adapter *pAd, u8 Status)
-{
-       /*unsigned long                 data; */
-       u8 HighByte = 0;
-       u8 LowByte;
-
-       LowByte = pAd->LedCntl.field.LedMode & 0x7f;
-       switch (Status) {
-       case LED_LINK_DOWN:
-               HighByte = 0x20;
-               AsicSendCommandToMcu(pAd, 0x50, 0xff, LowByte, HighByte);
-               pAd->LedIndicatorStrength = 0;
-               break;
-       case LED_LINK_UP:
-               if (pAd->CommonCfg.Channel > 14)
-                       HighByte = 0xa0;
-               else
-                       HighByte = 0x60;
-               AsicSendCommandToMcu(pAd, 0x50, 0xff, LowByte, HighByte);
-               break;
-       case LED_RADIO_ON:
-               HighByte = 0x20;
-               AsicSendCommandToMcu(pAd, 0x50, 0xff, LowByte, HighByte);
-               break;
-       case LED_HALT:
-               LowByte = 0;    /* Driver sets MAC register and MAC controls LED */
-       case LED_RADIO_OFF:
-               HighByte = 0;
-               AsicSendCommandToMcu(pAd, 0x50, 0xff, LowByte, HighByte);
-               break;
-       case LED_WPS:
-               HighByte = 0x10;
-               AsicSendCommandToMcu(pAd, 0x50, 0xff, LowByte, HighByte);
-               break;
-       case LED_ON_SITE_SURVEY:
-               HighByte = 0x08;
-               AsicSendCommandToMcu(pAd, 0x50, 0xff, LowByte, HighByte);
-               break;
-       case LED_POWER_UP:
-               HighByte = 0x04;
-               AsicSendCommandToMcu(pAd, 0x50, 0xff, LowByte, HighByte);
-               break;
-       default:
-               DBGPRINT(RT_DEBUG_WARN,
-                        ("RTMPSetLED::Unknown Status %d\n", Status));
-               break;
-       }
-
-       /* */
-       /* Keep LED status for LED SiteSurvey mode. */
-       /* After SiteSurvey, we will set the LED mode to previous status. */
-       /* */
-       if ((Status != LED_ON_SITE_SURVEY) && (Status != LED_POWER_UP))
-               pAd->LedStatus = Status;
-
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("RTMPSetLED::Mode=%d,HighByte=0x%02x,LowByte=0x%02x\n",
-                 pAd->LedCntl.field.LedMode, HighByte, LowByte));
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Set LED Signal Strength
-
-       Arguments:
-               pAd                                             Pointer to our adapter
-               Dbm                                             Signal Strength
-
-       Return Value:
-               None
-
-       IRQL = PASSIVE_LEVEL
-
-       Note:
-               Can be run on any IRQL level.
-
-               According to Microsoft Zero Config Wireless Signal Strength definition as belows.
-               <= -90  No Signal
-               <= -81  Very Low
-               <= -71  Low
-               <= -67  Good
-               <= -57  Very Good
-                > -57  Excellent
-       ========================================================================
-*/
-void RTMPSetSignalLED(struct rt_rtmp_adapter *pAd, IN NDIS_802_11_RSSI Dbm)
-{
-       u8 nLed = 0;
-
-       if (pAd->LedCntl.field.LedMode == LED_MODE_SIGNAL_STREGTH) {
-               if (Dbm <= -90)
-                       nLed = 0;
-               else if (Dbm <= -81)
-                       nLed = 1;
-               else if (Dbm <= -71)
-                       nLed = 3;
-               else if (Dbm <= -67)
-                       nLed = 7;
-               else if (Dbm <= -57)
-                       nLed = 15;
-               else
-                       nLed = 31;
-
-               /* */
-               /* Update Signal Strength to firmware if changed. */
-               /* */
-               if (pAd->LedIndicatorStrength != nLed) {
-                       AsicSendCommandToMcu(pAd, 0x51, 0xff, nLed,
-                                            pAd->LedCntl.field.Polarity);
-                       pAd->LedIndicatorStrength = nLed;
-               }
-       }
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Enable RX
-
-       Arguments:
-               pAd                                             Pointer to our adapter
-
-       Return Value:
-               None
-
-       IRQL <= DISPATCH_LEVEL
-
-       Note:
-               Before Enable RX, make sure you have enabled Interrupt.
-       ========================================================================
-*/
-void RTMPEnableRxTx(struct rt_rtmp_adapter *pAd)
-{
-/*      WPDMA_GLO_CFG_STRUC     GloCfg; */
-/*      unsigned long   i = 0; */
-       u32 rx_filter_flag;
-
-       DBGPRINT(RT_DEBUG_TRACE, ("==> RTMPEnableRxTx\n"));
-
-       /* Enable Rx DMA. */
-       RT28XXDMAEnable(pAd);
-
-       /* enable RX of MAC block */
-       if (pAd->OpMode == OPMODE_AP) {
-               rx_filter_flag = APNORMAL;
-
-               RTMP_IO_WRITE32(pAd, RX_FILTR_CFG, rx_filter_flag);     /* enable RX of DMA block */
-       } else {
-               if (pAd->CommonCfg.PSPXlink)
-                       rx_filter_flag = PSPXLINK;
-               else
-                       rx_filter_flag = STANORMAL;     /* Station not drop control frame will fail WiFi Certification. */
-               RTMP_IO_WRITE32(pAd, RX_FILTR_CFG, rx_filter_flag);
-       }
-
-       RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, 0xc);
-       DBGPRINT(RT_DEBUG_TRACE, ("<== RTMPEnableRxTx\n"));
-}
-
-/*+++Add by shiang, move from os/linux/rt_main_dev.c */
-void CfgInitHook(struct rt_rtmp_adapter *pAd)
-{
-       pAd->bBroadComHT = TRUE;
-}
-
-int rt28xx_init(struct rt_rtmp_adapter *pAd,
-               char *pDefaultMac, char *pHostName)
-{
-       u32 index;
-       u8 TmpPhy;
-       int Status;
-       u32 MacCsr0 = 0;
-
-#ifdef RTMP_MAC_PCI
-       {
-               /* If dirver doesn't wake up firmware here, */
-               /* NICLoadFirmware will hang forever when interface is up again. */
-               /* RT2860 PCI */
-               if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE) &&
-                   OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_PCIE_DEVICE)) {
-                       AUTO_WAKEUP_STRUC AutoWakeupCfg;
-                       AsicForceWakeup(pAd, TRUE);
-                       AutoWakeupCfg.word = 0;
-                       RTMP_IO_WRITE32(pAd, AUTO_WAKEUP_CFG,
-                                       AutoWakeupCfg.word);
-                       OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_DOZE);
-               }
-       }
-#endif /* RTMP_MAC_PCI // */
-
-       /* reset Adapter flags */
-       RTMP_CLEAR_FLAGS(pAd);
-
-       /* Init BssTab & ChannelInfo tabbles for auto channel select. */
-
-       /* Allocate BA Reordering memory */
-       ba_reordering_resource_init(pAd, MAX_REORDERING_MPDU_NUM);
-
-       /* Make sure MAC gets ready. */
-       index = 0;
-       do {
-               RTMP_IO_READ32(pAd, MAC_CSR0, &MacCsr0);
-               pAd->MACVersion = MacCsr0;
-
-               if ((pAd->MACVersion != 0x00)
-                   && (pAd->MACVersion != 0xFFFFFFFF))
-                       break;
-
-               RTMPusecDelay(10);
-       } while (index++ < 100);
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("MAC_CSR0  [ Ver:Rev=0x%08x]\n", pAd->MACVersion));
-
-#ifdef RTMP_MAC_PCI
-#ifdef PCIE_PS_SUPPORT
-       /*Iverson patch PCIE L1 issue to make sure that driver can be read,write ,BBP and RF register  at pcie L.1 level */
-       if ((IS_RT3090(pAd) || IS_RT3572(pAd) || IS_RT3390(pAd))
-           && OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_PCIE_DEVICE)) {
-               RTMP_IO_READ32(pAd, AUX_CTRL, &MacCsr0);
-               MacCsr0 |= 0x402;
-               RTMP_IO_WRITE32(pAd, AUX_CTRL, MacCsr0);
-               DBGPRINT(RT_DEBUG_TRACE, ("AUX_CTRL = 0x%x\n", MacCsr0));
-       }
-#endif /* PCIE_PS_SUPPORT // */
-
-       /* To fix driver disable/enable hang issue when radio off */
-       RTMP_IO_WRITE32(pAd, PWR_PIN_CFG, 0x2);
-#endif /* RTMP_MAC_PCI // */
-
-       /* Disable DMA */
-       RT28XXDMADisable(pAd);
-
-       /* Load 8051 firmware */
-       Status = NICLoadFirmware(pAd);
-       if (Status != NDIS_STATUS_SUCCESS) {
-               DBGPRINT_ERR("NICLoadFirmware failed, Status[=0x%08x]\n", Status);
-               goto err1;
-       }
-
-       NICLoadRateSwitchingParams(pAd);
-
-       /* Disable interrupts here which is as soon as possible */
-       /* This statement should never be true. We might consider to remove it later */
-#ifdef RTMP_MAC_PCI
-       if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_ACTIVE)) {
-               RTMP_ASIC_INTERRUPT_DISABLE(pAd);
-       }
-#endif /* RTMP_MAC_PCI // */
-
-       Status = RTMPAllocTxRxRingMemory(pAd);
-       if (Status != NDIS_STATUS_SUCCESS) {
-               DBGPRINT_ERR("RTMPAllocDMAMemory failed, Status[=0x%08x]\n", Status);
-               goto err1;
-       }
-
-       RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE);
-
-       /* initialize MLME */
-       /* */
-
-       Status = RtmpMgmtTaskInit(pAd);
-       if (Status != NDIS_STATUS_SUCCESS)
-               goto err2;
-
-       Status = MlmeInit(pAd);
-       if (Status != NDIS_STATUS_SUCCESS) {
-               DBGPRINT_ERR("MlmeInit failed, Status[=0x%08x]\n", Status);
-               goto err2;
-       }
-       /* Initialize pAd->StaCfg, pAd->ApCfg, pAd->CommonCfg to manufacture default */
-       /* */
-       UserCfgInit(pAd);
-       Status = RtmpNetTaskInit(pAd);
-       if (Status != NDIS_STATUS_SUCCESS)
-               goto err3;
-
-/*      COPY_MAC_ADDR(pAd->ApCfg.MBSSID[apidx].Bssid, netif->hwaddr); */
-/*      pAd->bForcePrintTX = TRUE; */
-
-       CfgInitHook(pAd);
-
-       NdisAllocateSpinLock(&pAd->MacTabLock);
-
-       MeasureReqTabInit(pAd);
-       TpcReqTabInit(pAd);
-
-       /* */
-       /* Init the hardware, we need to init asic before read registry, otherwise mac register will be reset */
-       /* */
-       Status = NICInitializeAdapter(pAd, TRUE);
-       if (Status != NDIS_STATUS_SUCCESS) {
-               DBGPRINT_ERR("NICInitializeAdapter failed, Status[=0x%08x]\n", Status);
-               if (Status != NDIS_STATUS_SUCCESS)
-                       goto err3;
-       }
-
-       DBGPRINT(RT_DEBUG_OFF, ("1. Phy Mode = %d\n", pAd->CommonCfg.PhyMode));
-
-#ifdef RTMP_MAC_USB
-       pAd->CommonCfg.bMultipleIRP = FALSE;
-
-       if (pAd->CommonCfg.bMultipleIRP)
-               pAd->CommonCfg.NumOfBulkInIRP = RX_RING_SIZE;
-       else
-               pAd->CommonCfg.NumOfBulkInIRP = 1;
-#endif /* RTMP_MAC_USB // */
-
-       /*Init Ba Capability parameters. */
-/*      RT28XX_BA_INIT(pAd); */
-       pAd->CommonCfg.DesiredHtPhy.MpduDensity =
-           (u8)pAd->CommonCfg.BACapability.field.MpduDensity;
-       pAd->CommonCfg.DesiredHtPhy.AmsduEnable =
-           (u16)pAd->CommonCfg.BACapability.field.AmsduEnable;
-       pAd->CommonCfg.DesiredHtPhy.AmsduSize =
-           (u16)pAd->CommonCfg.BACapability.field.AmsduSize;
-       pAd->CommonCfg.DesiredHtPhy.MimoPs =
-           (u16)pAd->CommonCfg.BACapability.field.MMPSmode;
-       /* UPdata to HT IE */
-       pAd->CommonCfg.HtCapability.HtCapInfo.MimoPs =
-           (u16)pAd->CommonCfg.BACapability.field.MMPSmode;
-       pAd->CommonCfg.HtCapability.HtCapInfo.AMsduSize =
-           (u16)pAd->CommonCfg.BACapability.field.AmsduSize;
-       pAd->CommonCfg.HtCapability.HtCapParm.MpduDensity =
-           (u8)pAd->CommonCfg.BACapability.field.MpduDensity;
-
-       /* after reading Registry, we now know if in AP mode or STA mode */
-
-       /* Load 8051 firmware; crash when FW image not existent */
-       /* Status = NICLoadFirmware(pAd); */
-       /* if (Status != NDIS_STATUS_SUCCESS) */
-       /*    break; */
-
-       DBGPRINT(RT_DEBUG_OFF, ("2. Phy Mode = %d\n", pAd->CommonCfg.PhyMode));
-
-       /* We should read EEPROM for all cases.  rt2860b */
-       NICReadEEPROMParameters(pAd, (u8 *)pDefaultMac);
-
-       DBGPRINT(RT_DEBUG_OFF, ("3. Phy Mode = %d\n", pAd->CommonCfg.PhyMode));
-
-       NICInitAsicFromEEPROM(pAd);     /*rt2860b */
-
-       /* Set PHY to appropriate mode */
-       TmpPhy = pAd->CommonCfg.PhyMode;
-       pAd->CommonCfg.PhyMode = 0xff;
-       RTMPSetPhyMode(pAd, TmpPhy);
-       SetCommonHT(pAd);
-
-       /* No valid channels. */
-       if (pAd->ChannelListNum == 0) {
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("Wrong configuration. No valid channel found. Check \"ContryCode\" and \"ChannelGeography\" setting.\n"));
-               goto err4;
-       }
-
-       DBGPRINT(RT_DEBUG_OFF,
-                ("MCS Set = %02x %02x %02x %02x %02x\n",
-                 pAd->CommonCfg.HtCapability.MCSSet[0],
-                 pAd->CommonCfg.HtCapability.MCSSet[1],
-                 pAd->CommonCfg.HtCapability.MCSSet[2],
-                 pAd->CommonCfg.HtCapability.MCSSet[3],
-                 pAd->CommonCfg.HtCapability.MCSSet[4]));
-
-#ifdef RTMP_RF_RW_SUPPORT
-       /*Init RT30xx RFRegisters after read RFIC type from EEPROM */
-       NICInitRFRegisters(pAd);
-#endif /* RTMP_RF_RW_SUPPORT // */
-
-/*              APInitialize(pAd); */
-
-       /* */
-       /* Initialize RF register to default value */
-       /* */
-       AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE);
-       AsicLockChannel(pAd, pAd->CommonCfg.Channel);
-
-       /* 8051 firmware require the signal during booting time. */
-       /*2008/11/28:KH marked the following codes to patch Frequency offset bug */
-       /*AsicSendCommandToMcu(pAd, 0x72, 0xFF, 0x00, 0x00); */
-
-       if (pAd && (Status != NDIS_STATUS_SUCCESS)) {
-               /* */
-               /* Undo everything if it failed */
-               /* */
-               if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE)) {
-/*                      NdisMDeregisterInterrupt(&pAd->Interrupt); */
-                       RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE);
-               }
-/*              RTMPFreeAdapter(pAd); // we will free it in disconnect() */
-       } else if (pAd) {
-               /* Microsoft HCT require driver send a disconnect event after driver initialization. */
-               OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED);
-/*              pAd->IndicateMediaState = NdisMediaStateDisconnected; */
-               RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_MEDIA_STATE_CHANGE);
-
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("NDIS_STATUS_MEDIA_DISCONNECT Event B!\n"));
-
-#ifdef RTMP_MAC_USB
-               RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS);
-               RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_REMOVE_IN_PROGRESS);
-
-               /* */
-               /* Support multiple BulkIn IRP, */
-               /* the value on pAd->CommonCfg.NumOfBulkInIRP may be large than 1. */
-               /* */
-               for (index = 0; index < pAd->CommonCfg.NumOfBulkInIRP; index++) {
-                       RTUSBBulkReceive(pAd);
-                       DBGPRINT(RT_DEBUG_TRACE, ("RTUSBBulkReceive!\n"));
-               }
-#endif /* RTMP_MAC_USB // */
-       }                       /* end of else */
-
-       /* Set up the Mac address */
-       RtmpOSNetDevAddrSet(pAd->net_dev, &pAd->CurrentAddress[0]);
-
-       DBGPRINT_S(Status, ("<==== rt28xx_init, Status=%x\n", Status));
-
-       return TRUE;
-
-err4:
-err3:
-       MlmeHalt(pAd);
-err2:
-       RTMPFreeTxRxRingMemory(pAd);
-err1:
-
-       os_free_mem(pAd, pAd->mpdu_blk_pool.mem);       /* free BA pool */
-
-       /* shall not set priv to NULL here because the priv didn't been free yet. */
-       /*net_dev->ml_priv = 0; */
-#ifdef ST
-err0:
-#endif /* ST // */
-
-       DBGPRINT(RT_DEBUG_ERROR, ("rt28xx Initialized fail!\n"));
-       return FALSE;
-}
-
-/*---Add by shiang, move from os/linux/rt_main_dev.c */
-
-static int RtmpChipOpsRegister(struct rt_rtmp_adapter *pAd, int infType)
-{
-       struct rt_rtmp_chip_op *pChipOps = &pAd->chipOps;
-       int status;
-
-       memset(pChipOps, 0, sizeof(struct rt_rtmp_chip_op));
-
-       /* set eeprom related hook functions */
-       status = RtmpChipOpsEepromHook(pAd, infType);
-
-       /* set mcu related hook functions */
-       switch (infType) {
-#ifdef RTMP_PCI_SUPPORT
-       case RTMP_DEV_INF_PCI:
-               pChipOps->loadFirmware = RtmpAsicLoadFirmware;
-               pChipOps->eraseFirmware = RtmpAsicEraseFirmware;
-               pChipOps->sendCommandToMcu = RtmpAsicSendCommandToMcu;
-               break;
-#endif /* RTMP_PCI_SUPPORT // */
-#ifdef RTMP_USB_SUPPORT
-       case RTMP_DEV_INF_USB:
-               pChipOps->loadFirmware = RtmpAsicLoadFirmware;
-               pChipOps->sendCommandToMcu = RtmpAsicSendCommandToMcu;
-               break;
-#endif /* RTMP_USB_SUPPORT // */
-       default:
-               break;
-       }
-
-       return status;
-}
-
-int RtmpRaDevCtrlInit(struct rt_rtmp_adapter *pAd, IN RTMP_INF_TYPE infType)
-{
-       /*void  *handle; */
-
-       /* Assign the interface type. We need use it when do register/EEPROM access. */
-       pAd->infType = infType;
-
-       pAd->OpMode = OPMODE_STA;
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("STA Driver version-%s\n", STA_DRIVER_VERSION));
-
-#ifdef RTMP_MAC_USB
-       sema_init(&(pAd->UsbVendorReq_semaphore), 1);
-       os_alloc_mem(pAd, (u8 **) & pAd->UsbVendorReqBuf,
-                    MAX_PARAM_BUFFER_SIZE - 1);
-       if (pAd->UsbVendorReqBuf == NULL) {
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("Allocate vendor request temp buffer failed!\n"));
-               return FALSE;
-       }
-#endif /* RTMP_MAC_USB // */
-
-       RtmpChipOpsRegister(pAd, infType);
-
-       return 0;
-}
-
-BOOLEAN RtmpRaDevCtrlExit(struct rt_rtmp_adapter *pAd)
-{
-
-       RTMPFreeAdapter(pAd);
-
-       return TRUE;
-}
-
-/* not yet support MBSS */
-struct net_device *get_netdev_from_bssid(struct rt_rtmp_adapter *pAd, u8 FromWhichBSSID)
-{
-       struct net_device *dev_p = NULL;
-
-       {
-               dev_p = pAd->net_dev;
-       }
-
-       ASSERT(dev_p);
-       return dev_p;           /* return one of MBSS */
-}
diff --git a/drivers/staging/rt2860/common/rtmp_mcu.c b/drivers/staging/rt2860/common/rtmp_mcu.c
deleted file mode 100644 (file)
index 80fa416..0000000
+++ /dev/null
@@ -1,336 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-       Module Name:
-       rtmp_mcu.c
-
-       Abstract:
-       Miniport generic portion header file
-
-       Revision History:
-       Who         When          What
-       --------    ----------    ----------------------------------------------
-*/
-
-#include       "../rt_config.h"
-
-#include <linux/crc-ccitt.h>
-#include <linux/firmware.h>
-
-#ifdef RTMP_MAC_USB
-
-#define FIRMWAREIMAGE_LENGTH           0x1000
-
-#define FIRMWARE_2870_MIN_VERSION      12
-#define FIRMWARE_2870_FILENAME         "rt2870.bin"
-MODULE_FIRMWARE(FIRMWARE_2870_FILENAME);
-
-#define FIRMWARE_3070_MIN_VERSION      17
-#define FIRMWARE_3070_FILENAME         "rt3070.bin"
-MODULE_FIRMWARE(FIRMWARE_3070_FILENAME);
-
-#define FIRMWARE_3071_MIN_VERSION      17
-#define FIRMWARE_3071_FILENAME         "rt3071.bin"    /* for RT3071/RT3072 */
-MODULE_FIRMWARE(FIRMWARE_3071_FILENAME);
-
-#else /* RTMP_MAC_PCI */
-
-#define FIRMWAREIMAGE_LENGTH           0x2000
-
-#define FIRMWARE_2860_MIN_VERSION      11
-#define FIRMWARE_2860_FILENAME         "rt2860.bin"
-MODULE_FIRMWARE(FIRMWARE_2860_FILENAME);
-
-#define FIRMWARE_3090_MIN_VERSION      19
-#define FIRMWARE_3090_FILENAME         "rt3090.bin"    /* for RT3090/RT3390 */
-MODULE_FIRMWARE(FIRMWARE_3090_FILENAME);
-
-#endif
-
-/*
-       ========================================================================
-
-       Routine Description:
-               erase 8051 firmware image in MAC ASIC
-
-       Arguments:
-               Adapter                                         Pointer to our adapter
-
-       IRQL = PASSIVE_LEVEL
-
-       ========================================================================
-*/
-int RtmpAsicEraseFirmware(struct rt_rtmp_adapter *pAd)
-{
-       unsigned long i;
-
-       for (i = 0; i < MAX_FIRMWARE_IMAGE_SIZE; i += 4)
-               RTMP_IO_WRITE32(pAd, FIRMWARE_IMAGE_BASE + i, 0);
-
-       return 0;
-}
-
-static const struct firmware *rtmp_get_firmware(struct rt_rtmp_adapter *adapter)
-{
-       const char *name;
-       const struct firmware *fw = NULL;
-       u8 min_version;
-       struct device *dev;
-       int err;
-
-       if (adapter->firmware)
-               return adapter->firmware;
-
-#ifdef RTMP_MAC_USB
-       if (IS_RT3071(adapter)) {
-               name = FIRMWARE_3071_FILENAME;
-               min_version = FIRMWARE_3071_MIN_VERSION;
-       } else if (IS_RT3070(adapter)) {
-               name = FIRMWARE_3070_FILENAME;
-               min_version = FIRMWARE_3070_MIN_VERSION;
-       } else {
-               name = FIRMWARE_2870_FILENAME;
-               min_version = FIRMWARE_2870_MIN_VERSION;
-       }
-       dev = &((struct os_cookie *)adapter->OS_Cookie)->pUsb_Dev->dev;
-#else /* RTMP_MAC_PCI */
-       if (IS_RT3090(adapter) || IS_RT3390(adapter)) {
-               name = FIRMWARE_3090_FILENAME;
-               min_version = FIRMWARE_3090_MIN_VERSION;
-       } else {
-               name = FIRMWARE_2860_FILENAME;
-               min_version = FIRMWARE_2860_MIN_VERSION;
-       }
-       dev = &((struct os_cookie *)adapter->OS_Cookie)->pci_dev->dev;
-#endif
-
-       err = request_firmware(&fw, name, dev);
-       if (err) {
-               dev_err(dev, "firmware file %s request failed (%d)\n",
-                       name, err);
-               return NULL;
-       }
-
-       if (fw->size < FIRMWAREIMAGE_LENGTH) {
-               dev_err(dev, "firmware file %s size is invalid\n", name);
-               goto invalid;
-       }
-
-       /* is it new enough? */
-       adapter->FirmwareVersion = fw->data[FIRMWAREIMAGE_LENGTH - 3];
-       if (adapter->FirmwareVersion < min_version) {
-               dev_err(dev,
-                       "firmware file %s is too old;"
-                       " driver requires v%d or later\n",
-                       name, min_version);
-               goto invalid;
-       }
-
-       /* is the internal CRC correct? */
-       if (crc_ccitt(0xffff, fw->data, FIRMWAREIMAGE_LENGTH - 2) !=
-           (fw->data[FIRMWAREIMAGE_LENGTH - 2] |
-            (fw->data[FIRMWAREIMAGE_LENGTH - 1] << 8))) {
-               dev_err(dev, "firmware file %s failed internal CRC\n", name);
-               goto invalid;
-       }
-
-       adapter->firmware = fw;
-       return fw;
-
-invalid:
-       release_firmware(fw);
-       return NULL;
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Load 8051 firmware file into MAC ASIC
-
-       Arguments:
-               Adapter                                         Pointer to our adapter
-
-       Return Value:
-               NDIS_STATUS_SUCCESS         firmware image load ok
-               NDIS_STATUS_FAILURE         image not found
-
-       IRQL = PASSIVE_LEVEL
-
-       ========================================================================
-*/
-int RtmpAsicLoadFirmware(struct rt_rtmp_adapter *pAd)
-{
-       const struct firmware *fw;
-       int Status = NDIS_STATUS_SUCCESS;
-       unsigned long Index;
-       u32 MacReg = 0;
-
-       fw = rtmp_get_firmware(pAd);
-       if (!fw)
-               return NDIS_STATUS_FAILURE;
-
-       RTMP_WRITE_FIRMWARE(pAd, fw->data, FIRMWAREIMAGE_LENGTH);
-
-       /* check if MCU is ready */
-       Index = 0;
-       do {
-               RTMP_IO_READ32(pAd, PBF_SYS_CTRL, &MacReg);
-
-               if (MacReg & 0x80)
-                       break;
-
-               RTMPusecDelay(1000);
-       } while (Index++ < 1000);
-
-       if (Index > 1000) {
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("NICLoadFirmware: MCU is not ready\n"));
-               Status = NDIS_STATUS_FAILURE;
-       }
-
-       DBGPRINT(RT_DEBUG_TRACE, ("<=== %s (status=%d)\n", __func__, Status));
-
-       return Status;
-}
-
-int RtmpAsicSendCommandToMcu(struct rt_rtmp_adapter *pAd,
-                            u8 Command,
-                            u8 Token, u8 Arg0, u8 Arg1)
-{
-       HOST_CMD_CSR_STRUC H2MCmd;
-       H2M_MAILBOX_STRUC H2MMailbox;
-       unsigned long i = 0;
-
-#ifdef PCIE_PS_SUPPORT
-       /* 3090F power solution 3 has hw limitation that needs to ban all mcu command */
-       /* when firmware is in radio state.  For other chip doesn't have this limitation. */
-       if (((IS_RT3090(pAd) || IS_RT3572(pAd) || IS_RT3390(pAd))
-            && IS_VERSION_AFTER_F(pAd)) && IS_VERSION_AFTER_F(pAd)
-           && (pAd->StaCfg.PSControl.field.rt30xxPowerMode == 3)
-           && (pAd->StaCfg.PSControl.field.EnableNewPS == TRUE)) {
-               RTMP_SEM_LOCK(&pAd->McuCmdLock);
-               if ((pAd->brt30xxBanMcuCmd == TRUE)
-                   && (Command != WAKE_MCU_CMD) && (Command != RFOFF_MCU_CMD)) {
-                       RTMP_SEM_UNLOCK(&pAd->McuCmdLock);
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                (" Ban Mcu Cmd %x in sleep mode\n", Command));
-                       return FALSE;
-               } else if ((Command == SLEEP_MCU_CMD)
-                          || (Command == RFOFF_MCU_CMD)) {
-                       pAd->brt30xxBanMcuCmd = TRUE;
-               } else if (Command != WAKE_MCU_CMD) {
-                       pAd->brt30xxBanMcuCmd = FALSE;
-               }
-
-               RTMP_SEM_UNLOCK(&pAd->McuCmdLock);
-
-       }
-       if (((IS_RT3090(pAd) || IS_RT3572(pAd) || IS_RT3390(pAd))
-            && IS_VERSION_AFTER_F(pAd)) && IS_VERSION_AFTER_F(pAd)
-           && (pAd->StaCfg.PSControl.field.rt30xxPowerMode == 3)
-           && (pAd->StaCfg.PSControl.field.EnableNewPS == TRUE)
-           && (Command == WAKE_MCU_CMD)) {
-
-               do {
-                       RTMP_IO_FORCE_READ32(pAd, H2M_MAILBOX_CSR,
-                                            &H2MMailbox.word);
-                       if (H2MMailbox.field.Owner == 0)
-                               break;
-
-                       RTMPusecDelay(2);
-                       DBGPRINT(RT_DEBUG_INFO,
-                                ("AsicSendCommanToMcu::Mail box is busy\n"));
-               } while (i++ < 100);
-
-               if (i > 100) {
-                       DBGPRINT_ERR("H2M_MAILBOX still hold by MCU. command fail\n");
-                       return FALSE;
-               }
-
-               H2MMailbox.field.Owner = 1;     /* pass ownership to MCU */
-               H2MMailbox.field.CmdToken = Token;
-               H2MMailbox.field.HighByte = Arg1;
-               H2MMailbox.field.LowByte = Arg0;
-               RTMP_IO_FORCE_WRITE32(pAd, H2M_MAILBOX_CSR, H2MMailbox.word);
-
-               H2MCmd.word = 0;
-               H2MCmd.field.HostCommand = Command;
-               RTMP_IO_FORCE_WRITE32(pAd, HOST_CMD_CSR, H2MCmd.word);
-
-       } else
-#endif /* PCIE_PS_SUPPORT // */
-       {
-               do {
-                       RTMP_IO_READ32(pAd, H2M_MAILBOX_CSR, &H2MMailbox.word);
-                       if (H2MMailbox.field.Owner == 0)
-                               break;
-
-                       RTMPusecDelay(2);
-               } while (i++ < 100);
-
-               if (i > 100) {
-#ifdef RTMP_MAC_PCI
-#endif /* RTMP_MAC_PCI // */
-                       {
-                               DBGPRINT_ERR("H2M_MAILBOX still hold by MCU. command fail\n");
-                       }
-                       return FALSE;
-               }
-#ifdef RTMP_MAC_PCI
-#endif /* RTMP_MAC_PCI // */
-
-               H2MMailbox.field.Owner = 1;     /* pass ownership to MCU */
-               H2MMailbox.field.CmdToken = Token;
-               H2MMailbox.field.HighByte = Arg1;
-               H2MMailbox.field.LowByte = Arg0;
-               RTMP_IO_WRITE32(pAd, H2M_MAILBOX_CSR, H2MMailbox.word);
-
-               H2MCmd.word = 0;
-               H2MCmd.field.HostCommand = Command;
-               RTMP_IO_WRITE32(pAd, HOST_CMD_CSR, H2MCmd.word);
-
-               if (Command != 0x80) {
-               }
-       }
-#ifdef PCIE_PS_SUPPORT
-       /* 3090 MCU Wakeup command needs more time to be stable. */
-       /* Before stable, don't issue other MCU command to prevent from firmware error. */
-       if (((IS_RT3090(pAd) || IS_RT3572(pAd) || IS_RT3390(pAd))
-            && IS_VERSION_AFTER_F(pAd)) && IS_VERSION_AFTER_F(pAd)
-           && (pAd->StaCfg.PSControl.field.rt30xxPowerMode == 3)
-           && (pAd->StaCfg.PSControl.field.EnableNewPS == TRUE)
-           && (Command == WAKE_MCU_CMD)) {
-               RTMPusecDelay(2000);
-               /*Put this is after RF programming. */
-               /*NdisAcquireSpinLock(&pAd->McuCmdLock); */
-               /*pAd->brt30xxBanMcuCmd = FALSE; */
-               /*NdisReleaseSpinLock(&pAd->McuCmdLock); */
-       }
-#endif /* PCIE_PS_SUPPORT // */
-
-       return TRUE;
-}
diff --git a/drivers/staging/rt2860/common/rtmp_timer.c b/drivers/staging/rt2860/common/rtmp_timer.c
deleted file mode 100644 (file)
index ab52090..0000000
+++ /dev/null
@@ -1,302 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-    Module Name:
-    rtmp_timer.c
-
-    Abstract:
-    task for timer handling
-
-    Revision History:
-    Who         When            What
-    --------    ----------      ----------------------------------------------
-    Name          Date            Modification logs
-    Shiang Tu  08-28-2008   init version
-
-*/
-
-#include "../rt_config.h"
-
-BUILD_TIMER_FUNCTION(MlmePeriodicExec);
-/*BUILD_TIMER_FUNCTION(MlmeRssiReportExec); */
-BUILD_TIMER_FUNCTION(AsicRxAntEvalTimeout);
-BUILD_TIMER_FUNCTION(APSDPeriodicExec);
-BUILD_TIMER_FUNCTION(AsicRfTuningExec);
-#ifdef RTMP_MAC_USB
-BUILD_TIMER_FUNCTION(BeaconUpdateExec);
-#endif /* RTMP_MAC_USB // */
-
-BUILD_TIMER_FUNCTION(BeaconTimeout);
-BUILD_TIMER_FUNCTION(ScanTimeout);
-BUILD_TIMER_FUNCTION(AuthTimeout);
-BUILD_TIMER_FUNCTION(AssocTimeout);
-BUILD_TIMER_FUNCTION(ReassocTimeout);
-BUILD_TIMER_FUNCTION(DisassocTimeout);
-BUILD_TIMER_FUNCTION(LinkDownExec);
-BUILD_TIMER_FUNCTION(StaQuickResponeForRateUpExec);
-BUILD_TIMER_FUNCTION(WpaDisassocApAndBlockAssoc);
-#ifdef RTMP_MAC_PCI
-BUILD_TIMER_FUNCTION(PsPollWakeExec);
-BUILD_TIMER_FUNCTION(RadioOnExec);
-#endif /* RTMP_MAC_PCI // */
-#ifdef RTMP_MAC_USB
-BUILD_TIMER_FUNCTION(RtmpUsbStaAsicForceWakeupTimeout);
-#endif /* RTMP_MAC_USB // */
-
-#if defined(AP_LED) || defined(STA_LED)
-extern void LedCtrlMain(void *SystemSpecific1,
-                       void *FunctionContext,
-                       void *SystemSpecific2, void *SystemSpecific3);
-BUILD_TIMER_FUNCTION(LedCtrlMain);
-#endif
-
-#ifdef RTMP_TIMER_TASK_SUPPORT
-static void RtmpTimerQHandle(struct rt_rtmp_adapter *pAd)
-{
-#ifndef KTHREAD_SUPPORT
-       int status;
-#endif
-       struct rt_ralink_timer *pTimer;
-       struct rt_rtmp_timer_task_entry *pEntry;
-       unsigned long irqFlag;
-       struct rt_rtmp_os_task *pTask;
-
-       pTask = &pAd->timerTask;
-       while (!pTask->task_killed) {
-               pTimer = NULL;
-
-#ifdef KTHREAD_SUPPORT
-               RTMP_WAIT_EVENT_INTERRUPTIBLE(pAd, pTask);
-#else
-               RTMP_SEM_EVENT_WAIT(&(pTask->taskSema), status);
-#endif
-
-               if (pAd->TimerQ.status == RTMP_TASK_STAT_STOPED)
-                       break;
-
-               /* event happened. */
-               while (pAd->TimerQ.pQHead) {
-                       RTMP_INT_LOCK(&pAd->TimerQLock, irqFlag);
-                       pEntry = pAd->TimerQ.pQHead;
-                       if (pEntry) {
-                               pTimer = pEntry->pRaTimer;
-
-                               /* update pQHead */
-                               pAd->TimerQ.pQHead = pEntry->pNext;
-                               if (pEntry == pAd->TimerQ.pQTail)
-                                       pAd->TimerQ.pQTail = NULL;
-
-                               /* return this queue entry to timerQFreeList. */
-                               pEntry->pNext = pAd->TimerQ.pQPollFreeList;
-                               pAd->TimerQ.pQPollFreeList = pEntry;
-                       }
-                       RTMP_INT_UNLOCK(&pAd->TimerQLock, irqFlag);
-
-                       if (pTimer) {
-                               if ((pTimer->handle != NULL)
-                                   && (!pAd->PM_FlgSuspend))
-                                       pTimer->handle(NULL,
-                                                      (void *)pTimer->cookie,
-                                                      NULL, pTimer);
-                               if ((pTimer->Repeat)
-                                   && (pTimer->State == FALSE))
-                                       RTMP_OS_Add_Timer(&pTimer->TimerObj,
-                                                         pTimer->TimerValue);
-                       }
-               }
-
-#ifndef KTHREAD_SUPPORT
-               if (status != 0) {
-                       pAd->TimerQ.status = RTMP_TASK_STAT_STOPED;
-                       RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS);
-                       break;
-               }
-#endif
-       }
-}
-
-int RtmpTimerQThread(IN void *Context)
-{
-       struct rt_rtmp_os_task *pTask;
-       struct rt_rtmp_adapter *pAd;
-
-       pTask = Context;
-       pAd = pTask->priv;
-
-       RtmpOSTaskCustomize(pTask);
-
-       RtmpTimerQHandle(pAd);
-
-       DBGPRINT(RT_DEBUG_TRACE, ("<---%s\n", __func__));
-#ifndef KTHREAD_SUPPORT
-       pTask->taskPID = THREAD_PID_INIT_VALUE;
-#endif
-       /* notify the exit routine that we're actually exiting now
-        *
-        * complete()/wait_for_completion() is similar to up()/down(),
-        * except that complete() is safe in the case where the structure
-        * is getting deleted in a parallel mode of execution (i.e. just
-        * after the down() -- that's necessary for the thread-shutdown
-        * case.
-        *
-        * complete_and_exit() goes even further than this -- it is safe in
-        * the case that the thread of the caller is going away (not just
-        * the structure) -- this is necessary for the module-remove case.
-        * This is important in preemption kernels, which transfer the flow
-        * of execution immediately upon a complete().
-        */
-       RtmpOSTaskNotifyToExit(pTask);
-
-       return 0;
-
-}
-
-struct rt_rtmp_timer_task_entry *RtmpTimerQInsert(struct rt_rtmp_adapter *pAd,
-                                       struct rt_ralink_timer *pTimer)
-{
-       struct rt_rtmp_timer_task_entry *pQNode = NULL, *pQTail;
-       unsigned long irqFlags;
-       struct rt_rtmp_os_task *pTask = &pAd->timerTask;
-
-       RTMP_INT_LOCK(&pAd->TimerQLock, irqFlags);
-       if (pAd->TimerQ.status & RTMP_TASK_CAN_DO_INSERT) {
-               if (pAd->TimerQ.pQPollFreeList) {
-                       pQNode = pAd->TimerQ.pQPollFreeList;
-                       pAd->TimerQ.pQPollFreeList = pQNode->pNext;
-
-                       pQNode->pRaTimer = pTimer;
-                       pQNode->pNext = NULL;
-
-                       pQTail = pAd->TimerQ.pQTail;
-                       if (pAd->TimerQ.pQTail != NULL)
-                               pQTail->pNext = pQNode;
-                       pAd->TimerQ.pQTail = pQNode;
-                       if (pAd->TimerQ.pQHead == NULL)
-                               pAd->TimerQ.pQHead = pQNode;
-               }
-       }
-       RTMP_INT_UNLOCK(&pAd->TimerQLock, irqFlags);
-
-       if (pQNode) {
-#ifdef KTHREAD_SUPPORT
-               WAKE_UP(pTask);
-#else
-               RTMP_SEM_EVENT_UP(&pTask->taskSema);
-#endif
-       }
-
-       return pQNode;
-}
-
-BOOLEAN RtmpTimerQRemove(struct rt_rtmp_adapter *pAd, struct rt_ralink_timer *pTimer)
-{
-       struct rt_rtmp_timer_task_entry *pNode, *pPrev = NULL;
-       unsigned long irqFlags;
-
-       RTMP_INT_LOCK(&pAd->TimerQLock, irqFlags);
-       if (pAd->TimerQ.status >= RTMP_TASK_STAT_INITED) {
-               pNode = pAd->TimerQ.pQHead;
-               while (pNode) {
-                       if (pNode->pRaTimer == pTimer)
-                               break;
-                       pPrev = pNode;
-                       pNode = pNode->pNext;
-               }
-
-               /* Now move it to freeList queue. */
-               if (pNode) {
-                       if (pNode == pAd->TimerQ.pQHead)
-                               pAd->TimerQ.pQHead = pNode->pNext;
-                       if (pNode == pAd->TimerQ.pQTail)
-                               pAd->TimerQ.pQTail = pPrev;
-                       if (pPrev != NULL)
-                               pPrev->pNext = pNode->pNext;
-
-                       /* return this queue entry to timerQFreeList. */
-                       pNode->pNext = pAd->TimerQ.pQPollFreeList;
-                       pAd->TimerQ.pQPollFreeList = pNode;
-               }
-       }
-       RTMP_INT_UNLOCK(&pAd->TimerQLock, irqFlags);
-
-       return TRUE;
-}
-
-void RtmpTimerQExit(struct rt_rtmp_adapter *pAd)
-{
-       struct rt_rtmp_timer_task_entry *pTimerQ;
-       unsigned long irqFlags;
-
-       RTMP_INT_LOCK(&pAd->TimerQLock, irqFlags);
-       while (pAd->TimerQ.pQHead) {
-               pTimerQ = pAd->TimerQ.pQHead;
-               pAd->TimerQ.pQHead = pTimerQ->pNext;
-               /* remove the timeQ */
-       }
-       pAd->TimerQ.pQPollFreeList = NULL;
-       os_free_mem(pAd, pAd->TimerQ.pTimerQPoll);
-       pAd->TimerQ.pQTail = NULL;
-       pAd->TimerQ.pQHead = NULL;
-#ifndef KTHREAD_SUPPORT
-       pAd->TimerQ.status = RTMP_TASK_STAT_STOPED;
-#endif
-       RTMP_INT_UNLOCK(&pAd->TimerQLock, irqFlags);
-
-}
-
-void RtmpTimerQInit(struct rt_rtmp_adapter *pAd)
-{
-       int i;
-       struct rt_rtmp_timer_task_entry *pQNode, *pEntry;
-       unsigned long irqFlags;
-
-       NdisAllocateSpinLock(&pAd->TimerQLock);
-
-       NdisZeroMemory(&pAd->TimerQ, sizeof(pAd->TimerQ));
-
-       os_alloc_mem(pAd, &pAd->TimerQ.pTimerQPoll,
-                    sizeof(struct rt_rtmp_timer_task_entry) * TIMER_QUEUE_SIZE_MAX);
-       if (pAd->TimerQ.pTimerQPoll) {
-               pEntry = NULL;
-               pQNode = (struct rt_rtmp_timer_task_entry *)pAd->TimerQ.pTimerQPoll;
-               NdisZeroMemory(pAd->TimerQ.pTimerQPoll,
-                              sizeof(struct rt_rtmp_timer_task_entry) *
-                              TIMER_QUEUE_SIZE_MAX);
-
-               RTMP_INT_LOCK(&pAd->TimerQLock, irqFlags);
-               for (i = 0; i < TIMER_QUEUE_SIZE_MAX; i++) {
-                       pQNode->pNext = pEntry;
-                       pEntry = pQNode;
-                       pQNode++;
-               }
-               pAd->TimerQ.pQPollFreeList = pEntry;
-               pAd->TimerQ.pQHead = NULL;
-               pAd->TimerQ.pQTail = NULL;
-               pAd->TimerQ.status = RTMP_TASK_STAT_INITED;
-               RTMP_INT_UNLOCK(&pAd->TimerQLock, irqFlags);
-       }
-}
-#endif /* RTMP_TIMER_TASK_SUPPORT // */
diff --git a/drivers/staging/rt2860/common/spectrum.c b/drivers/staging/rt2860/common/spectrum.c
deleted file mode 100644 (file)
index ceb622d..0000000
+++ /dev/null
@@ -1,2205 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-    Module Name:
-       action.c
-
-    Abstract:
-    Handle association related requests either from WSTA or from local MLME
-
-    Revision History:
-    Who          When          What
-    ---------    ----------    ----------------------------------------------
-       Fonchi Wu    2008                  created for 802.11h
- */
-
-#include "../rt_config.h"
-#include "action.h"
-
-/* The regulatory information in the USA (US) */
-struct rt_dot11_regulatory_information USARegulatoryInfo[] = {
-/*  "regulatory class"  "number of channels"  "Max Tx Pwr"  "channel list" */
-       {0, {0, 0, {0}
-            }
-        }
-       ,                       /* Invlid entry */
-       {1, {4, 16, {36, 40, 44, 48}
-            }
-        }
-       ,
-       {2, {4, 23, {52, 56, 60, 64}
-            }
-        }
-       ,
-       {3, {4, 29, {149, 153, 157, 161}
-            }
-        }
-       ,
-       {4, {11, 23, {100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140}
-            }
-        }
-       ,
-       {5, {5, 30, {149, 153, 157, 161, 165}
-            }
-        }
-       ,
-       {6, {10, 14, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
-            }
-        }
-       ,
-       {7, {10, 27, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
-            }
-        }
-       ,
-       {8, {5, 17, {11, 13, 15, 17, 19}
-            }
-        }
-       ,
-       {9, {5, 30, {11, 13, 15, 17, 19}
-            }
-        }
-       ,
-       {10, {2, 20, {21, 25}
-             }
-        }
-       ,
-       {11, {2, 33, {21, 25}
-             }
-        }
-       ,
-       {12, {11, 30, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}
-             }
-        }
-};
-
-#define USA_REGULATORY_INFO_SIZE (sizeof(USARegulatoryInfo) / sizeof(struct rt_dot11_regulatory_information))
-
-/* The regulatory information in Europe */
-struct rt_dot11_regulatory_information EuropeRegulatoryInfo[] = {
-/*  "regulatory class"  "number of channels"  "Max Tx Pwr"  "channel list" */
-       {0, {0, 0, {0}
-            }
-        }
-       ,                       /* Invalid entry */
-       {1, {4, 20, {36, 40, 44, 48}
-            }
-        }
-       ,
-       {2, {4, 20, {52, 56, 60, 64}
-            }
-        }
-       ,
-       {3, {11, 30, {100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140}
-            }
-        }
-       ,
-       {4, {13, 20, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}
-            }
-        }
-};
-
-#define EU_REGULATORY_INFO_SIZE (sizeof(EuropeRegulatoryInfo) / sizeof(struct rt_dot11_regulatory_information))
-
-/* The regulatory information in Japan */
-struct rt_dot11_regulatory_information JapanRegulatoryInfo[] = {
-/*  "regulatory class"  "number of channels"  "Max Tx Pwr"  "channel list" */
-       {0, {0, 0, {0}
-            }
-        }
-       ,                       /* Invalid entry */
-       {1, {4, 22, {34, 38, 42, 46}
-            }
-        }
-       ,
-       {2, {3, 24, {8, 12, 16}
-            }
-        }
-       ,
-       {3, {3, 24, {8, 12, 16}
-            }
-        }
-       ,
-       {4, {3, 24, {8, 12, 16}
-            }
-        }
-       ,
-       {5, {3, 24, {8, 12, 16}
-            }
-        }
-       ,
-       {6, {3, 22, {8, 12, 16}
-            }
-        }
-       ,
-       {7, {4, 24, {184, 188, 192, 196}
-            }
-        }
-       ,
-       {8, {4, 24, {184, 188, 192, 196}
-            }
-        }
-       ,
-       {9, {4, 24, {184, 188, 192, 196}
-            }
-        }
-       ,
-       {10, {4, 24, {184, 188, 192, 196}
-             }
-        }
-       ,
-       {11, {4, 22, {184, 188, 192, 196}
-             }
-        }
-       ,
-       {12, {4, 24, {7, 8, 9, 11}
-             }
-        }
-       ,
-       {13, {4, 24, {7, 8, 9, 11}
-             }
-        }
-       ,
-       {14, {4, 24, {7, 8, 9, 11}
-             }
-        }
-       ,
-       {15, {4, 24, {7, 8, 9, 11}
-             }
-        }
-       ,
-       {16, {6, 24, {183, 184, 185, 187, 188, 189}
-             }
-        }
-       ,
-       {17, {6, 24, {183, 184, 185, 187, 188, 189}
-             }
-        }
-       ,
-       {18, {6, 24, {183, 184, 185, 187, 188, 189}
-             }
-        }
-       ,
-       {19, {6, 24, {183, 184, 185, 187, 188, 189}
-             }
-        }
-       ,
-       {20, {6, 17, {183, 184, 185, 187, 188, 189}
-             }
-        }
-       ,
-       {21, {6, 24, {6, 7, 8, 9, 10, 11}
-             }
-        }
-       ,
-       {22, {6, 24, {6, 7, 8, 9, 10, 11}
-             }
-        }
-       ,
-       {23, {6, 24, {6, 7, 8, 9, 10, 11}
-             }
-        }
-       ,
-       {24, {6, 24, {6, 7, 8, 9, 10, 11}
-             }
-        }
-       ,
-       {25, {8, 24, {182, 183, 184, 185, 186, 187, 188, 189}
-             }
-        }
-       ,
-       {26, {8, 24, {182, 183, 184, 185, 186, 187, 188, 189}
-             }
-        }
-       ,
-       {27, {8, 24, {182, 183, 184, 185, 186, 187, 188, 189}
-             }
-        }
-       ,
-       {28, {8, 24, {182, 183, 184, 185, 186, 187, 188, 189}
-             }
-        }
-       ,
-       {29, {8, 17, {182, 183, 184, 185, 186, 187, 188, 189}
-             }
-        }
-       ,
-       {30, {13, 23, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}
-             }
-        }
-       ,
-       {31, {1, 23, {14}
-             }
-        }
-       ,
-       {32, {4, 22, {52, 56, 60, 64}
-             }
-        }
-};
-
-#define JP_REGULATORY_INFO_SIZE (sizeof(JapanRegulatoryInfo) / sizeof(struct rt_dot11_regulatory_information))
-
-char RTMP_GetTxPwr(struct rt_rtmp_adapter *pAd, IN HTTRANSMIT_SETTING HTTxMode)
-{
-       struct tx_pwr_cfg {
-               u8 Mode;
-               u8 MCS;
-               u16 req;
-               u8 shift;
-               u32 BitMask;
-       };
-
-       u32 Value;
-       int Idx;
-       u8 PhyMode;
-       char CurTxPwr;
-       u8 TxPwrRef = 0;
-       char DaltaPwr;
-       unsigned long TxPwr[5];
-
-       struct tx_pwr_cfg TxPwrCfg[] = {
-               {MODE_CCK, 0, 0, 4, 0x000000f0},
-               {MODE_CCK, 1, 0, 0, 0x0000000f},
-               {MODE_CCK, 2, 0, 12, 0x0000f000},
-               {MODE_CCK, 3, 0, 8, 0x00000f00},
-
-               {MODE_OFDM, 0, 0, 20, 0x00f00000},
-               {MODE_OFDM, 1, 0, 16, 0x000f0000},
-               {MODE_OFDM, 2, 0, 28, 0xf0000000},
-               {MODE_OFDM, 3, 0, 24, 0x0f000000},
-               {MODE_OFDM, 4, 1, 4, 0x000000f0},
-               {MODE_OFDM, 5, 1, 0, 0x0000000f},
-               {MODE_OFDM, 6, 1, 12, 0x0000f000},
-               {MODE_OFDM, 7, 1, 8, 0x00000f00}
-               , {MODE_HTMIX, 0, 1, 20, 0x00f00000},
-               {MODE_HTMIX, 1, 1, 16, 0x000f0000},
-               {MODE_HTMIX, 2, 1, 28, 0xf0000000},
-               {MODE_HTMIX, 3, 1, 24, 0x0f000000},
-               {MODE_HTMIX, 4, 2, 4, 0x000000f0},
-               {MODE_HTMIX, 5, 2, 0, 0x0000000f},
-               {MODE_HTMIX, 6, 2, 12, 0x0000f000},
-               {MODE_HTMIX, 7, 2, 8, 0x00000f00},
-               {MODE_HTMIX, 8, 2, 20, 0x00f00000},
-               {MODE_HTMIX, 9, 2, 16, 0x000f0000},
-               {MODE_HTMIX, 10, 2, 28, 0xf0000000},
-               {MODE_HTMIX, 11, 2, 24, 0x0f000000},
-               {MODE_HTMIX, 12, 3, 4, 0x000000f0},
-               {MODE_HTMIX, 13, 3, 0, 0x0000000f},
-               {MODE_HTMIX, 14, 3, 12, 0x0000f000},
-               {MODE_HTMIX, 15, 3, 8, 0x00000f00}
-       };
-#define MAX_TXPWR_TAB_SIZE (sizeof(TxPwrCfg) / sizeof(struct tx_pwr_cfg))
-
-       CurTxPwr = 19;
-
-       /* check Tx Power setting from UI. */
-       if (pAd->CommonCfg.TxPowerPercentage > 90) ;
-       else if (pAd->CommonCfg.TxPowerPercentage > 60) /* reduce Pwr for 1 dB. */
-               CurTxPwr -= 1;
-       else if (pAd->CommonCfg.TxPowerPercentage > 30) /* reduce Pwr for 3 dB. */
-               CurTxPwr -= 3;
-       else if (pAd->CommonCfg.TxPowerPercentage > 15) /* reduce Pwr for 6 dB. */
-               CurTxPwr -= 6;
-       else if (pAd->CommonCfg.TxPowerPercentage > 9)  /* reduce Pwr for 9 dB. */
-               CurTxPwr -= 9;
-       else                    /* reduce Pwr for 12 dB. */
-               CurTxPwr -= 12;
-
-       if (pAd->CommonCfg.BBPCurrentBW == BW_40) {
-               if (pAd->CommonCfg.CentralChannel > 14) {
-                       TxPwr[0] = pAd->Tx40MPwrCfgABand[0];
-                       TxPwr[1] = pAd->Tx40MPwrCfgABand[1];
-                       TxPwr[2] = pAd->Tx40MPwrCfgABand[2];
-                       TxPwr[3] = pAd->Tx40MPwrCfgABand[3];
-                       TxPwr[4] = pAd->Tx40MPwrCfgABand[4];
-               } else {
-                       TxPwr[0] = pAd->Tx40MPwrCfgGBand[0];
-                       TxPwr[1] = pAd->Tx40MPwrCfgGBand[1];
-                       TxPwr[2] = pAd->Tx40MPwrCfgGBand[2];
-                       TxPwr[3] = pAd->Tx40MPwrCfgGBand[3];
-                       TxPwr[4] = pAd->Tx40MPwrCfgGBand[4];
-               }
-       } else {
-               if (pAd->CommonCfg.Channel > 14) {
-                       TxPwr[0] = pAd->Tx20MPwrCfgABand[0];
-                       TxPwr[1] = pAd->Tx20MPwrCfgABand[1];
-                       TxPwr[2] = pAd->Tx20MPwrCfgABand[2];
-                       TxPwr[3] = pAd->Tx20MPwrCfgABand[3];
-                       TxPwr[4] = pAd->Tx20MPwrCfgABand[4];
-               } else {
-                       TxPwr[0] = pAd->Tx20MPwrCfgGBand[0];
-                       TxPwr[1] = pAd->Tx20MPwrCfgGBand[1];
-                       TxPwr[2] = pAd->Tx20MPwrCfgGBand[2];
-                       TxPwr[3] = pAd->Tx20MPwrCfgGBand[3];
-                       TxPwr[4] = pAd->Tx20MPwrCfgGBand[4];
-               }
-       }
-
-       switch (HTTxMode.field.MODE) {
-       case MODE_CCK:
-       case MODE_OFDM:
-               Value = TxPwr[1];
-               TxPwrRef = (Value & 0x00000f00) >> 8;
-
-               break;
-
-       case MODE_HTMIX:
-       case MODE_HTGREENFIELD:
-               if (pAd->CommonCfg.TxStream == 1) {
-                       Value = TxPwr[2];
-                       TxPwrRef = (Value & 0x00000f00) >> 8;
-               } else if (pAd->CommonCfg.TxStream == 2) {
-                       Value = TxPwr[3];
-                       TxPwrRef = (Value & 0x00000f00) >> 8;
-               }
-               break;
-       }
-
-       PhyMode = (HTTxMode.field.MODE == MODE_HTGREENFIELD)
-           ? MODE_HTMIX : HTTxMode.field.MODE;
-
-       for (Idx = 0; Idx < MAX_TXPWR_TAB_SIZE; Idx++) {
-               if ((TxPwrCfg[Idx].Mode == PhyMode)
-                   && (TxPwrCfg[Idx].MCS == HTTxMode.field.MCS)) {
-                       Value = TxPwr[TxPwrCfg[Idx].req];
-                       DaltaPwr =
-                           TxPwrRef - (char)((Value & TxPwrCfg[Idx].BitMask)
-                                              >> TxPwrCfg[Idx].shift);
-                       CurTxPwr -= DaltaPwr;
-                       break;
-               }
-       }
-
-       return CurTxPwr;
-}
-
-void MeasureReqTabInit(struct rt_rtmp_adapter *pAd)
-{
-       NdisAllocateSpinLock(&pAd->CommonCfg.MeasureReqTabLock);
-
-       pAd->CommonCfg.pMeasureReqTab =
-           kmalloc(sizeof(struct rt_measure_req_tab), GFP_ATOMIC);
-       if (pAd->CommonCfg.pMeasureReqTab)
-               NdisZeroMemory(pAd->CommonCfg.pMeasureReqTab,
-                              sizeof(struct rt_measure_req_tab));
-       else
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("%s Fail to alloc memory for pAd->CommonCfg.pMeasureReqTab.\n",
-                         __func__));
-
-       return;
-}
-
-void MeasureReqTabExit(struct rt_rtmp_adapter *pAd)
-{
-       NdisFreeSpinLock(&pAd->CommonCfg.MeasureReqTabLock);
-
-       kfree(pAd->CommonCfg.pMeasureReqTab);
-       pAd->CommonCfg.pMeasureReqTab = NULL;
-
-       return;
-}
-
-struct rt_measure_req_entry *MeasureReqLookUp(struct rt_rtmp_adapter *pAd, u8 DialogToken)
-{
-       u32 HashIdx;
-       struct rt_measure_req_tab *pTab = pAd->CommonCfg.pMeasureReqTab;
-       struct rt_measure_req_entry *pEntry = NULL;
-       struct rt_measure_req_entry *pPrevEntry = NULL;
-
-       if (pTab == NULL) {
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("%s: pMeasureReqTab doesn't exist.\n", __func__));
-               return NULL;
-       }
-
-       RTMP_SEM_LOCK(&pAd->CommonCfg.MeasureReqTabLock);
-
-       HashIdx = MQ_DIALOGTOKEN_HASH_INDEX(DialogToken);
-       pEntry = pTab->Hash[HashIdx];
-
-       while (pEntry) {
-               if (pEntry->DialogToken == DialogToken)
-                       break;
-               else {
-                       pPrevEntry = pEntry;
-                       pEntry = pEntry->pNext;
-               }
-       }
-
-       RTMP_SEM_UNLOCK(&pAd->CommonCfg.MeasureReqTabLock);
-
-       return pEntry;
-}
-
-struct rt_measure_req_entry *MeasureReqInsert(struct rt_rtmp_adapter *pAd, u8 DialogToken)
-{
-       int i;
-       unsigned long HashIdx;
-       struct rt_measure_req_tab *pTab = pAd->CommonCfg.pMeasureReqTab;
-       struct rt_measure_req_entry *pEntry = NULL, *pCurrEntry;
-       unsigned long Now;
-
-       if (pTab == NULL) {
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("%s: pMeasureReqTab doesn't exist.\n", __func__));
-               return NULL;
-       }
-
-       pEntry = MeasureReqLookUp(pAd, DialogToken);
-       if (pEntry == NULL) {
-               RTMP_SEM_LOCK(&pAd->CommonCfg.MeasureReqTabLock);
-               for (i = 0; i < MAX_MEASURE_REQ_TAB_SIZE; i++) {
-                       NdisGetSystemUpTime(&Now);
-                       pEntry = &pTab->Content[i];
-
-                       if ((pEntry->Valid == TRUE)
-                           && RTMP_TIME_AFTER((unsigned long)Now,
-                                              (unsigned long)(pEntry->
-                                                              lastTime +
-                                                              MQ_REQ_AGE_OUT)))
-                       {
-                               struct rt_measure_req_entry *pPrevEntry = NULL;
-                               unsigned long HashIdx =
-                                   MQ_DIALOGTOKEN_HASH_INDEX(pEntry->
-                                                             DialogToken);
-                               struct rt_measure_req_entry *pProbeEntry =
-                                   pTab->Hash[HashIdx];
-
-                               /* update Hash list */
-                               do {
-                                       if (pProbeEntry == pEntry) {
-                                               if (pPrevEntry == NULL) {
-                                                       pTab->Hash[HashIdx] =
-                                                           pEntry->pNext;
-                                               } else {
-                                                       pPrevEntry->pNext =
-                                                           pEntry->pNext;
-                                               }
-                                               break;
-                                       }
-
-                                       pPrevEntry = pProbeEntry;
-                                       pProbeEntry = pProbeEntry->pNext;
-                               } while (pProbeEntry);
-
-                               NdisZeroMemory(pEntry,
-                                              sizeof(struct rt_measure_req_entry));
-                               pTab->Size--;
-
-                               break;
-                       }
-
-                       if (pEntry->Valid == FALSE)
-                               break;
-               }
-
-               if (i < MAX_MEASURE_REQ_TAB_SIZE) {
-                       NdisGetSystemUpTime(&Now);
-                       pEntry->lastTime = Now;
-                       pEntry->Valid = TRUE;
-                       pEntry->DialogToken = DialogToken;
-                       pTab->Size++;
-               } else {
-                       pEntry = NULL;
-                       DBGPRINT(RT_DEBUG_ERROR,
-                                ("%s: pMeasureReqTab tab full.\n", __func__));
-               }
-
-               /* add this Neighbor entry into HASH table */
-               if (pEntry) {
-                       HashIdx = MQ_DIALOGTOKEN_HASH_INDEX(DialogToken);
-                       if (pTab->Hash[HashIdx] == NULL) {
-                               pTab->Hash[HashIdx] = pEntry;
-                       } else {
-                               pCurrEntry = pTab->Hash[HashIdx];
-                               while (pCurrEntry->pNext != NULL)
-                                       pCurrEntry = pCurrEntry->pNext;
-                               pCurrEntry->pNext = pEntry;
-                       }
-               }
-
-               RTMP_SEM_UNLOCK(&pAd->CommonCfg.MeasureReqTabLock);
-       }
-
-       return pEntry;
-}
-
-void MeasureReqDelete(struct rt_rtmp_adapter *pAd, u8 DialogToken)
-{
-       struct rt_measure_req_tab *pTab = pAd->CommonCfg.pMeasureReqTab;
-       struct rt_measure_req_entry *pEntry = NULL;
-
-       if (pTab == NULL) {
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("%s: pMeasureReqTab doesn't exist.\n", __func__));
-               return;
-       }
-       /* if empty, return */
-       if (pTab->Size == 0) {
-               DBGPRINT(RT_DEBUG_ERROR, ("pMeasureReqTab empty.\n"));
-               return;
-       }
-
-       pEntry = MeasureReqLookUp(pAd, DialogToken);
-       if (pEntry != NULL) {
-               struct rt_measure_req_entry *pPrevEntry = NULL;
-               unsigned long HashIdx = MQ_DIALOGTOKEN_HASH_INDEX(pEntry->DialogToken);
-               struct rt_measure_req_entry *pProbeEntry = pTab->Hash[HashIdx];
-
-               RTMP_SEM_LOCK(&pAd->CommonCfg.MeasureReqTabLock);
-               /* update Hash list */
-               do {
-                       if (pProbeEntry == pEntry) {
-                               if (pPrevEntry == NULL) {
-                                       pTab->Hash[HashIdx] = pEntry->pNext;
-                               } else {
-                                       pPrevEntry->pNext = pEntry->pNext;
-                               }
-                               break;
-                       }
-
-                       pPrevEntry = pProbeEntry;
-                       pProbeEntry = pProbeEntry->pNext;
-               } while (pProbeEntry);
-
-               NdisZeroMemory(pEntry, sizeof(struct rt_measure_req_entry));
-               pTab->Size--;
-
-               RTMP_SEM_UNLOCK(&pAd->CommonCfg.MeasureReqTabLock);
-       }
-
-       return;
-}
-
-void TpcReqTabInit(struct rt_rtmp_adapter *pAd)
-{
-       NdisAllocateSpinLock(&pAd->CommonCfg.TpcReqTabLock);
-
-       pAd->CommonCfg.pTpcReqTab = kmalloc(sizeof(struct rt_tpc_req_tab), GFP_ATOMIC);
-       if (pAd->CommonCfg.pTpcReqTab)
-               NdisZeroMemory(pAd->CommonCfg.pTpcReqTab, sizeof(struct rt_tpc_req_tab));
-       else
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("%s Fail to alloc memory for pAd->CommonCfg.pTpcReqTab.\n",
-                         __func__));
-
-       return;
-}
-
-void TpcReqTabExit(struct rt_rtmp_adapter *pAd)
-{
-       NdisFreeSpinLock(&pAd->CommonCfg.TpcReqTabLock);
-
-       kfree(pAd->CommonCfg.pTpcReqTab);
-       pAd->CommonCfg.pTpcReqTab = NULL;
-
-       return;
-}
-
-static struct rt_tpc_req_entry *TpcReqLookUp(struct rt_rtmp_adapter *pAd, u8 DialogToken)
-{
-       u32 HashIdx;
-       struct rt_tpc_req_tab *pTab = pAd->CommonCfg.pTpcReqTab;
-       struct rt_tpc_req_entry *pEntry = NULL;
-       struct rt_tpc_req_entry *pPrevEntry = NULL;
-
-       if (pTab == NULL) {
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("%s: pTpcReqTab doesn't exist.\n", __func__));
-               return NULL;
-       }
-
-       RTMP_SEM_LOCK(&pAd->CommonCfg.TpcReqTabLock);
-
-       HashIdx = TPC_DIALOGTOKEN_HASH_INDEX(DialogToken);
-       pEntry = pTab->Hash[HashIdx];
-
-       while (pEntry) {
-               if (pEntry->DialogToken == DialogToken)
-                       break;
-               else {
-                       pPrevEntry = pEntry;
-                       pEntry = pEntry->pNext;
-               }
-       }
-
-       RTMP_SEM_UNLOCK(&pAd->CommonCfg.TpcReqTabLock);
-
-       return pEntry;
-}
-
-static struct rt_tpc_req_entry *TpcReqInsert(struct rt_rtmp_adapter *pAd, u8 DialogToken)
-{
-       int i;
-       unsigned long HashIdx;
-       struct rt_tpc_req_tab *pTab = pAd->CommonCfg.pTpcReqTab;
-       struct rt_tpc_req_entry *pEntry = NULL, *pCurrEntry;
-       unsigned long Now;
-
-       if (pTab == NULL) {
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("%s: pTpcReqTab doesn't exist.\n", __func__));
-               return NULL;
-       }
-
-       pEntry = TpcReqLookUp(pAd, DialogToken);
-       if (pEntry == NULL) {
-               RTMP_SEM_LOCK(&pAd->CommonCfg.TpcReqTabLock);
-               for (i = 0; i < MAX_TPC_REQ_TAB_SIZE; i++) {
-                       NdisGetSystemUpTime(&Now);
-                       pEntry = &pTab->Content[i];
-
-                       if ((pEntry->Valid == TRUE)
-                           && RTMP_TIME_AFTER((unsigned long)Now,
-                                              (unsigned long)(pEntry->
-                                                              lastTime +
-                                                              TPC_REQ_AGE_OUT)))
-                       {
-                               struct rt_tpc_req_entry *pPrevEntry = NULL;
-                               unsigned long HashIdx =
-                                   TPC_DIALOGTOKEN_HASH_INDEX(pEntry->
-                                                              DialogToken);
-                               struct rt_tpc_req_entry *pProbeEntry =
-                                   pTab->Hash[HashIdx];
-
-                               /* update Hash list */
-                               do {
-                                       if (pProbeEntry == pEntry) {
-                                               if (pPrevEntry == NULL) {
-                                                       pTab->Hash[HashIdx] =
-                                                           pEntry->pNext;
-                                               } else {
-                                                       pPrevEntry->pNext =
-                                                           pEntry->pNext;
-                                               }
-                                               break;
-                                       }
-
-                                       pPrevEntry = pProbeEntry;
-                                       pProbeEntry = pProbeEntry->pNext;
-                               } while (pProbeEntry);
-
-                               NdisZeroMemory(pEntry, sizeof(struct rt_tpc_req_entry));
-                               pTab->Size--;
-
-                               break;
-                       }
-
-                       if (pEntry->Valid == FALSE)
-                               break;
-               }
-
-               if (i < MAX_TPC_REQ_TAB_SIZE) {
-                       NdisGetSystemUpTime(&Now);
-                       pEntry->lastTime = Now;
-                       pEntry->Valid = TRUE;
-                       pEntry->DialogToken = DialogToken;
-                       pTab->Size++;
-               } else {
-                       pEntry = NULL;
-                       DBGPRINT(RT_DEBUG_ERROR,
-                                ("%s: pTpcReqTab tab full.\n", __func__));
-               }
-
-               /* add this Neighbor entry into HASH table */
-               if (pEntry) {
-                       HashIdx = TPC_DIALOGTOKEN_HASH_INDEX(DialogToken);
-                       if (pTab->Hash[HashIdx] == NULL) {
-                               pTab->Hash[HashIdx] = pEntry;
-                       } else {
-                               pCurrEntry = pTab->Hash[HashIdx];
-                               while (pCurrEntry->pNext != NULL)
-                                       pCurrEntry = pCurrEntry->pNext;
-                               pCurrEntry->pNext = pEntry;
-                       }
-               }
-
-               RTMP_SEM_UNLOCK(&pAd->CommonCfg.TpcReqTabLock);
-       }
-
-       return pEntry;
-}
-
-static void TpcReqDelete(struct rt_rtmp_adapter *pAd, u8 DialogToken)
-{
-       struct rt_tpc_req_tab *pTab = pAd->CommonCfg.pTpcReqTab;
-       struct rt_tpc_req_entry *pEntry = NULL;
-
-       if (pTab == NULL) {
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("%s: pTpcReqTab doesn't exist.\n", __func__));
-               return;
-       }
-       /* if empty, return */
-       if (pTab->Size == 0) {
-               DBGPRINT(RT_DEBUG_ERROR, ("pTpcReqTab empty.\n"));
-               return;
-       }
-
-       pEntry = TpcReqLookUp(pAd, DialogToken);
-       if (pEntry != NULL) {
-               struct rt_tpc_req_entry *pPrevEntry = NULL;
-               unsigned long HashIdx = TPC_DIALOGTOKEN_HASH_INDEX(pEntry->DialogToken);
-               struct rt_tpc_req_entry *pProbeEntry = pTab->Hash[HashIdx];
-
-               RTMP_SEM_LOCK(&pAd->CommonCfg.TpcReqTabLock);
-               /* update Hash list */
-               do {
-                       if (pProbeEntry == pEntry) {
-                               if (pPrevEntry == NULL) {
-                                       pTab->Hash[HashIdx] = pEntry->pNext;
-                               } else {
-                                       pPrevEntry->pNext = pEntry->pNext;
-                               }
-                               break;
-                       }
-
-                       pPrevEntry = pProbeEntry;
-                       pProbeEntry = pProbeEntry->pNext;
-               } while (pProbeEntry);
-
-               NdisZeroMemory(pEntry, sizeof(struct rt_tpc_req_entry));
-               pTab->Size--;
-
-               RTMP_SEM_UNLOCK(&pAd->CommonCfg.TpcReqTabLock);
-       }
-
-       return;
-}
-
-/*
-       ==========================================================================
-       Description:
-               Get Current TimeS tamp.
-
-       Parametrs:
-
-       Return  : Current Time Stamp.
-       ==========================================================================
- */
-static u64 GetCurrentTimeStamp(struct rt_rtmp_adapter *pAd)
-{
-       /* get current time stamp. */
-       return 0;
-}
-
-/*
-       ==========================================================================
-       Description:
-               Get Current Transmit Power.
-
-       Parametrs:
-
-       Return  : Current Time Stamp.
-       ==========================================================================
- */
-static u8 GetCurTxPwr(struct rt_rtmp_adapter *pAd, u8 Wcid)
-{
-       return 16;              /* 16 dBm */
-}
-
-/*
-       ==========================================================================
-       Description:
-               Get Current Transmit Power.
-
-       Parametrs:
-
-       Return  : Current Time Stamp.
-       ==========================================================================
- */
-void InsertChannelRepIE(struct rt_rtmp_adapter *pAd,
-                       u8 *pFrameBuf,
-                       unsigned long *pFrameLen,
-                       char *pCountry, u8 RegulatoryClass)
-{
-       unsigned long TempLen;
-       u8 Len;
-       u8 IEId = IE_AP_CHANNEL_REPORT;
-       u8 *pChListPtr = NULL;
-
-       Len = 1;
-       if (strncmp(pCountry, "US", 2) == 0) {
-               if (RegulatoryClass >= USA_REGULATORY_INFO_SIZE) {
-                       DBGPRINT(RT_DEBUG_ERROR,
-                                ("%s: USA Unknow Requlatory class (%d)\n",
-                                 __func__, RegulatoryClass));
-                       return;
-               }
-
-               Len +=
-                   USARegulatoryInfo[RegulatoryClass].ChannelSet.
-                   NumberOfChannels;
-               pChListPtr =
-                   USARegulatoryInfo[RegulatoryClass].ChannelSet.ChannelList;
-       } else if (strncmp(pCountry, "JP", 2) == 0) {
-               if (RegulatoryClass >= JP_REGULATORY_INFO_SIZE) {
-                       DBGPRINT(RT_DEBUG_ERROR,
-                                ("%s: JP Unknow Requlatory class (%d)\n",
-                                 __func__, RegulatoryClass));
-                       return;
-               }
-
-               Len +=
-                   JapanRegulatoryInfo[RegulatoryClass].ChannelSet.
-                   NumberOfChannels;
-               pChListPtr =
-                   JapanRegulatoryInfo[RegulatoryClass].ChannelSet.ChannelList;
-       } else {
-               DBGPRINT(RT_DEBUG_ERROR, ("%s: Unknow Country (%s)\n",
-                                         __func__, pCountry));
-               return;
-       }
-
-       MakeOutgoingFrame(pFrameBuf, &TempLen,
-                         1, &IEId,
-                         1, &Len,
-                         1, &RegulatoryClass,
-                         Len - 1, pChListPtr, END_OF_ARGS);
-
-       *pFrameLen = *pFrameLen + TempLen;
-
-       return;
-}
-
-/*
-       ==========================================================================
-       Description:
-               Insert Dialog Token into frame.
-
-       Parametrs:
-               1. frame buffer pointer.
-               2. frame length.
-               3. Dialog token.
-
-       Return  : None.
-       ==========================================================================
- */
-void InsertDialogToken(struct rt_rtmp_adapter *pAd,
-                      u8 *pFrameBuf,
-                      unsigned long *pFrameLen, u8 DialogToken)
-{
-       unsigned long TempLen;
-       MakeOutgoingFrame(pFrameBuf, &TempLen, 1, &DialogToken, END_OF_ARGS);
-
-       *pFrameLen = *pFrameLen + TempLen;
-
-       return;
-}
-
-/*
-       ==========================================================================
-       Description:
-               Insert TPC Request IE into frame.
-
-       Parametrs:
-               1. frame buffer pointer.
-               2. frame length.
-
-       Return  : None.
-       ==========================================================================
- */
-static void InsertTpcReqIE(struct rt_rtmp_adapter *pAd,
-                          u8 *pFrameBuf, unsigned long *pFrameLen)
-{
-       unsigned long TempLen;
-       unsigned long Len = 0;
-       u8 ElementID = IE_TPC_REQUEST;
-
-       MakeOutgoingFrame(pFrameBuf, &TempLen,
-                         1, &ElementID, 1, &Len, END_OF_ARGS);
-
-       *pFrameLen = *pFrameLen + TempLen;
-
-       return;
-}
-
-/*
-       ==========================================================================
-       Description:
-               Insert TPC Report IE into frame.
-
-       Parametrs:
-               1. frame buffer pointer.
-               2. frame length.
-               3. Transmit Power.
-               4. Link Margin.
-
-       Return  : None.
-       ==========================================================================
- */
-void InsertTpcReportIE(struct rt_rtmp_adapter *pAd,
-                      u8 *pFrameBuf,
-                      unsigned long *pFrameLen,
-                      u8 TxPwr, u8 LinkMargin)
-{
-       unsigned long TempLen;
-       unsigned long Len = sizeof(struct rt_tpc_report_info);
-       u8 ElementID = IE_TPC_REPORT;
-       struct rt_tpc_report_info TpcReportIE;
-
-       TpcReportIE.TxPwr = TxPwr;
-       TpcReportIE.LinkMargin = LinkMargin;
-
-       MakeOutgoingFrame(pFrameBuf, &TempLen,
-                         1, &ElementID,
-                         1, &Len, Len, &TpcReportIE, END_OF_ARGS);
-
-       *pFrameLen = *pFrameLen + TempLen;
-
-       return;
-}
-
-/*
-       ==========================================================================
-       Description:
-               Insert Channel Switch Announcement IE into frame.
-
-       Parametrs:
-               1. frame buffer pointer.
-               2. frame length.
-               3. channel switch announcement mode.
-               4. new selected channel.
-               5. channel switch announcement count.
-
-       Return  : None.
-       ==========================================================================
- */
-static void InsertChSwAnnIE(struct rt_rtmp_adapter *pAd,
-                           u8 *pFrameBuf,
-                           unsigned long *pFrameLen,
-                           u8 ChSwMode,
-                           u8 NewChannel, u8 ChSwCnt)
-{
-       unsigned long TempLen;
-       unsigned long Len = sizeof(struct rt_ch_sw_ann_info);
-       u8 ElementID = IE_CHANNEL_SWITCH_ANNOUNCEMENT;
-       struct rt_ch_sw_ann_info ChSwAnnIE;
-
-       ChSwAnnIE.ChSwMode = ChSwMode;
-       ChSwAnnIE.Channel = NewChannel;
-       ChSwAnnIE.ChSwCnt = ChSwCnt;
-
-       MakeOutgoingFrame(pFrameBuf, &TempLen,
-                         1, &ElementID, 1, &Len, Len, &ChSwAnnIE, END_OF_ARGS);
-
-       *pFrameLen = *pFrameLen + TempLen;
-
-       return;
-}
-
-/*
-       ==========================================================================
-       Description:
-               Insert Measure Request IE into frame.
-
-       Parametrs:
-               1. frame buffer pointer.
-               2. frame length.
-               3. Measure Token.
-               4. Measure Request Mode.
-               5. Measure Request Type.
-               6. Measure Channel.
-               7. Measure Start time.
-               8. Measure Duration.
-
-       Return  : None.
-       ==========================================================================
- */
-static void InsertMeasureReqIE(struct rt_rtmp_adapter *pAd,
-                              u8 *pFrameBuf,
-                              unsigned long *pFrameLen,
-                              u8 Len, struct rt_measure_req_info * pMeasureReqIE)
-{
-       unsigned long TempLen;
-       u8 ElementID = IE_MEASUREMENT_REQUEST;
-
-       MakeOutgoingFrame(pFrameBuf, &TempLen,
-                         1, &ElementID,
-                         1, &Len,
-                         sizeof(struct rt_measure_req_info), pMeasureReqIE, END_OF_ARGS);
-
-       *pFrameLen = *pFrameLen + TempLen;
-
-       return;
-}
-
-/*
-       ==========================================================================
-       Description:
-               Insert Measure Report IE into frame.
-
-       Parametrs:
-               1. frame buffer pointer.
-               2. frame length.
-               3. Measure Token.
-               4. Measure Request Mode.
-               5. Measure Request Type.
-               6. Length of Report Information
-               7. Pointer of Report Information Buffer.
-
-       Return  : None.
-       ==========================================================================
- */
-static void InsertMeasureReportIE(struct rt_rtmp_adapter *pAd,
-                                 u8 *pFrameBuf,
-                                 unsigned long *pFrameLen,
-                                 struct rt_measure_report_info * pMeasureReportIE,
-                                 u8 ReportLnfoLen, u8 *pReportInfo)
-{
-       unsigned long TempLen;
-       unsigned long Len;
-       u8 ElementID = IE_MEASUREMENT_REPORT;
-
-       Len = sizeof(struct rt_measure_report_info) + ReportLnfoLen;
-
-       MakeOutgoingFrame(pFrameBuf, &TempLen,
-                         1, &ElementID,
-                         1, &Len, Len, pMeasureReportIE, END_OF_ARGS);
-
-       *pFrameLen = *pFrameLen + TempLen;
-
-       if ((ReportLnfoLen > 0) && (pReportInfo != NULL)) {
-               MakeOutgoingFrame(pFrameBuf + *pFrameLen, &TempLen,
-                                 ReportLnfoLen, pReportInfo, END_OF_ARGS);
-
-               *pFrameLen = *pFrameLen + TempLen;
-       }
-       return;
-}
-
-/*
-       ==========================================================================
-       Description:
-               Prepare Measurement request action frame and enqueue it into
-               management queue waiting for transmition.
-
-       Parametrs:
-               1. the destination mac address of the frame.
-
-       Return  : None.
-       ==========================================================================
- */
-void MakeMeasurementReqFrame(struct rt_rtmp_adapter *pAd,
-                            u8 *pOutBuffer,
-                            unsigned long *pFrameLen,
-                            u8 TotalLen,
-                            u8 Category,
-                            u8 Action,
-                            u8 MeasureToken,
-                            u8 MeasureReqMode,
-                            u8 MeasureReqType, u8 NumOfRepetitions)
-{
-       unsigned long TempLen;
-       struct rt_measure_req_info MeasureReqIE;
-
-       InsertActField(pAd, (pOutBuffer + *pFrameLen), pFrameLen, Category,
-                      Action);
-
-       /* fill Dialog Token */
-       InsertDialogToken(pAd, (pOutBuffer + *pFrameLen), pFrameLen,
-                         MeasureToken);
-
-       /* fill Number of repetitions. */
-       if (Category == CATEGORY_RM) {
-               MakeOutgoingFrame((pOutBuffer + *pFrameLen), &TempLen,
-                                 2, &NumOfRepetitions, END_OF_ARGS);
-
-               *pFrameLen += TempLen;
-       }
-       /* prepare Measurement IE. */
-       NdisZeroMemory(&MeasureReqIE, sizeof(struct rt_measure_req_info));
-       MeasureReqIE.Token = MeasureToken;
-       MeasureReqIE.ReqMode.word = MeasureReqMode;
-       MeasureReqIE.ReqType = MeasureReqType;
-       InsertMeasureReqIE(pAd, (pOutBuffer + *pFrameLen), pFrameLen,
-                          TotalLen, &MeasureReqIE);
-
-       return;
-}
-
-/*
-       ==========================================================================
-       Description:
-               Prepare Measurement report action frame and enqueue it into
-               management queue waiting for transmition.
-
-       Parametrs:
-               1. the destination mac address of the frame.
-
-       Return  : None.
-       ==========================================================================
- */
-void EnqueueMeasurementRep(struct rt_rtmp_adapter *pAd,
-                          u8 *pDA,
-                          u8 DialogToken,
-                          u8 MeasureToken,
-                          u8 MeasureReqMode,
-                          u8 MeasureReqType,
-                          u8 ReportInfoLen, u8 *pReportInfo)
-{
-       u8 *pOutBuffer = NULL;
-       int NStatus;
-       unsigned long FrameLen;
-       struct rt_header_802_11 ActHdr;
-       struct rt_measure_report_info MeasureRepIE;
-
-       /* build action frame header. */
-       MgtMacHeaderInit(pAd, &ActHdr, SUBTYPE_ACTION, 0, pDA,
-                        pAd->CurrentAddress);
-
-       NStatus = MlmeAllocateMemory(pAd, (void *)& pOutBuffer);        /*Get an unused nonpaged memory */
-       if (NStatus != NDIS_STATUS_SUCCESS) {
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("%s() allocate memory failed \n", __func__));
-               return;
-       }
-       NdisMoveMemory(pOutBuffer, (char *)& ActHdr, sizeof(struct rt_header_802_11));
-       FrameLen = sizeof(struct rt_header_802_11);
-
-       InsertActField(pAd, (pOutBuffer + FrameLen), &FrameLen,
-                      CATEGORY_SPECTRUM, SPEC_MRP);
-
-       /* fill Dialog Token */
-       InsertDialogToken(pAd, (pOutBuffer + FrameLen), &FrameLen, DialogToken);
-
-       /* prepare Measurement IE. */
-       NdisZeroMemory(&MeasureRepIE, sizeof(struct rt_measure_report_info));
-       MeasureRepIE.Token = MeasureToken;
-       MeasureRepIE.ReportMode = MeasureReqMode;
-       MeasureRepIE.ReportType = MeasureReqType;
-       InsertMeasureReportIE(pAd, (pOutBuffer + FrameLen), &FrameLen,
-                             &MeasureRepIE, ReportInfoLen, pReportInfo);
-
-       MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);
-       MlmeFreeMemory(pAd, pOutBuffer);
-
-       return;
-}
-
-/*
-       ==========================================================================
-       Description:
-               Prepare TPC Request action frame and enqueue it into
-               management queue waiting for transmition.
-
-       Parametrs:
-               1. the destination mac address of the frame.
-
-       Return  : None.
-       ==========================================================================
- */
-void EnqueueTPCReq(struct rt_rtmp_adapter *pAd, u8 *pDA, u8 DialogToken)
-{
-       u8 *pOutBuffer = NULL;
-       int NStatus;
-       unsigned long FrameLen;
-
-       struct rt_header_802_11 ActHdr;
-
-       /* build action frame header. */
-       MgtMacHeaderInit(pAd, &ActHdr, SUBTYPE_ACTION, 0, pDA,
-                        pAd->CurrentAddress);
-
-       NStatus = MlmeAllocateMemory(pAd, (void *)& pOutBuffer);        /*Get an unused nonpaged memory */
-       if (NStatus != NDIS_STATUS_SUCCESS) {
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("%s() allocate memory failed \n", __func__));
-               return;
-       }
-       NdisMoveMemory(pOutBuffer, (char *)& ActHdr, sizeof(struct rt_header_802_11));
-       FrameLen = sizeof(struct rt_header_802_11);
-
-       InsertActField(pAd, (pOutBuffer + FrameLen), &FrameLen,
-                      CATEGORY_SPECTRUM, SPEC_TPCRQ);
-
-       /* fill Dialog Token */
-       InsertDialogToken(pAd, (pOutBuffer + FrameLen), &FrameLen, DialogToken);
-
-       /* Insert TPC Request IE. */
-       InsertTpcReqIE(pAd, (pOutBuffer + FrameLen), &FrameLen);
-
-       MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);
-       MlmeFreeMemory(pAd, pOutBuffer);
-
-       return;
-}
-
-/*
-       ==========================================================================
-       Description:
-               Prepare TPC Report action frame and enqueue it into
-               management queue waiting for transmition.
-
-       Parametrs:
-               1. the destination mac address of the frame.
-
-       Return  : None.
-       ==========================================================================
- */
-void EnqueueTPCRep(struct rt_rtmp_adapter *pAd,
-                  u8 *pDA,
-                  u8 DialogToken, u8 TxPwr, u8 LinkMargin)
-{
-       u8 *pOutBuffer = NULL;
-       int NStatus;
-       unsigned long FrameLen;
-
-       struct rt_header_802_11 ActHdr;
-
-       /* build action frame header. */
-       MgtMacHeaderInit(pAd, &ActHdr, SUBTYPE_ACTION, 0, pDA,
-                        pAd->CurrentAddress);
-
-       NStatus = MlmeAllocateMemory(pAd, (void *)& pOutBuffer);        /*Get an unused nonpaged memory */
-       if (NStatus != NDIS_STATUS_SUCCESS) {
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("%s() allocate memory failed \n", __func__));
-               return;
-       }
-       NdisMoveMemory(pOutBuffer, (char *)& ActHdr, sizeof(struct rt_header_802_11));
-       FrameLen = sizeof(struct rt_header_802_11);
-
-       InsertActField(pAd, (pOutBuffer + FrameLen), &FrameLen,
-                      CATEGORY_SPECTRUM, SPEC_TPCRP);
-
-       /* fill Dialog Token */
-       InsertDialogToken(pAd, (pOutBuffer + FrameLen), &FrameLen, DialogToken);
-
-       /* Insert TPC Request IE. */
-       InsertTpcReportIE(pAd, (pOutBuffer + FrameLen), &FrameLen, TxPwr,
-                         LinkMargin);
-
-       MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);
-       MlmeFreeMemory(pAd, pOutBuffer);
-
-       return;
-}
-
-/*
-       ==========================================================================
-       Description:
-               Prepare Channel Switch Announcement action frame and enqueue it into
-               management queue waiting for transmition.
-
-       Parametrs:
-               1. the destination mac address of the frame.
-               2. Channel switch announcement mode.
-               2. a New selected channel.
-
-       Return  : None.
-       ==========================================================================
- */
-void EnqueueChSwAnn(struct rt_rtmp_adapter *pAd,
-                   u8 *pDA, u8 ChSwMode, u8 NewCh)
-{
-       u8 *pOutBuffer = NULL;
-       int NStatus;
-       unsigned long FrameLen;
-
-       struct rt_header_802_11 ActHdr;
-
-       /* build action frame header. */
-       MgtMacHeaderInit(pAd, &ActHdr, SUBTYPE_ACTION, 0, pDA,
-                        pAd->CurrentAddress);
-
-       NStatus = MlmeAllocateMemory(pAd, (void *)& pOutBuffer);        /*Get an unused nonpaged memory */
-       if (NStatus != NDIS_STATUS_SUCCESS) {
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("%s() allocate memory failed \n", __func__));
-               return;
-       }
-       NdisMoveMemory(pOutBuffer, (char *)& ActHdr, sizeof(struct rt_header_802_11));
-       FrameLen = sizeof(struct rt_header_802_11);
-
-       InsertActField(pAd, (pOutBuffer + FrameLen), &FrameLen,
-                      CATEGORY_SPECTRUM, SPEC_CHANNEL_SWITCH);
-
-       InsertChSwAnnIE(pAd, (pOutBuffer + FrameLen), &FrameLen, ChSwMode,
-                       NewCh, 0);
-
-       MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);
-       MlmeFreeMemory(pAd, pOutBuffer);
-
-       return;
-}
-
-static BOOLEAN DfsRequirementCheck(struct rt_rtmp_adapter *pAd, u8 Channel)
-{
-       BOOLEAN Result = FALSE;
-       int i;
-
-       do {
-               /* check DFS procedure is running. */
-               /* make sure DFS procedure won't start twice. */
-               if (pAd->CommonCfg.RadarDetect.RDMode != RD_NORMAL_MODE) {
-                       Result = FALSE;
-                       break;
-               }
-               /* check the new channel carried from Channel Switch Announcemnet is valid. */
-               for (i = 0; i < pAd->ChannelListNum; i++) {
-                       if ((Channel == pAd->ChannelList[i].Channel)
-                           && (pAd->ChannelList[i].RemainingTimeForUse == 0)) {
-                               /* found radar signal in the channel. the channel can't use at least for 30 minutes. */
-                               pAd->ChannelList[i].RemainingTimeForUse = 1800; /*30 min = 1800 sec */
-                               Result = TRUE;
-                               break;
-                       }
-               }
-       } while (FALSE);
-
-       return Result;
-}
-
-void NotifyChSwAnnToPeerAPs(struct rt_rtmp_adapter *pAd,
-                           u8 *pRA,
-                           u8 *pTA, u8 ChSwMode, u8 Channel)
-{
-}
-
-static void StartDFSProcedure(struct rt_rtmp_adapter *pAd,
-                             u8 Channel, u8 ChSwMode)
-{
-       /* start DFS procedure */
-       pAd->CommonCfg.Channel = Channel;
-
-       N_ChannelCheck(pAd);
-
-       pAd->CommonCfg.RadarDetect.RDMode = RD_SWITCHING_MODE;
-       pAd->CommonCfg.RadarDetect.CSCount = 0;
-}
-
-/*
-       ==========================================================================
-       Description:
-               Channel Switch Announcement action frame sanity check.
-
-       Parametrs:
-               1. MLME message containing the received frame
-               2. message length.
-               3. Channel switch announcement information buffer.
-
-       Return  : None.
-       ==========================================================================
- */
-
-/*
-  Channel Switch Announcement IE.
-  +----+-----+-----------+------------+-----------+
-  | ID | Len |Ch Sw Mode | New Ch Num | Ch Sw Cnt |
-  +----+-----+-----------+------------+-----------+
-    1    1        1           1            1
-*/
-static BOOLEAN PeerChSwAnnSanity(struct rt_rtmp_adapter *pAd,
-                                void * pMsg,
-                                unsigned long MsgLen,
-                                struct rt_ch_sw_ann_info * pChSwAnnInfo)
-{
-       struct rt_frame_802_11 * Fr = (struct rt_frame_802_11 *) pMsg;
-       u8 *pFramePtr = Fr->Octet;
-       BOOLEAN result = FALSE;
-       struct rt_eid * eid_ptr;
-
-       /* skip 802.11 header. */
-       MsgLen -= sizeof(struct rt_header_802_11);
-
-       /* skip category and action code. */
-       pFramePtr += 2;
-       MsgLen -= 2;
-
-       if (pChSwAnnInfo == NULL)
-               return result;
-
-       eid_ptr = (struct rt_eid *) pFramePtr;
-       while (((u8 *) eid_ptr + eid_ptr->Len + 1) <
-              ((u8 *)pFramePtr + MsgLen)) {
-               switch (eid_ptr->Eid) {
-               case IE_CHANNEL_SWITCH_ANNOUNCEMENT:
-                       NdisMoveMemory(&pChSwAnnInfo->ChSwMode, eid_ptr->Octet,
-                                      1);
-                       NdisMoveMemory(&pChSwAnnInfo->Channel,
-                                      eid_ptr->Octet + 1, 1);
-                       NdisMoveMemory(&pChSwAnnInfo->ChSwCnt,
-                                      eid_ptr->Octet + 2, 1);
-
-                       result = TRUE;
-                       break;
-
-               default:
-                       break;
-               }
-               eid_ptr = (struct rt_eid *) ((u8 *) eid_ptr + 2 + eid_ptr->Len);
-       }
-
-       return result;
-}
-
-/*
-       ==========================================================================
-       Description:
-               Measurement request action frame sanity check.
-
-       Parametrs:
-               1. MLME message containing the received frame
-               2. message length.
-               3. Measurement request information buffer.
-
-       Return  : None.
-       ==========================================================================
- */
-static BOOLEAN PeerMeasureReqSanity(struct rt_rtmp_adapter *pAd,
-                                   void * pMsg,
-                                   unsigned long MsgLen,
-                                   u8 *pDialogToken,
-                                   struct rt_measure_req_info * pMeasureReqInfo,
-                                   struct rt_measure_req * pMeasureReq)
-{
-       struct rt_frame_802_11 * Fr = (struct rt_frame_802_11 *) pMsg;
-       u8 *pFramePtr = Fr->Octet;
-       BOOLEAN result = FALSE;
-       struct rt_eid * eid_ptr;
-       u8 *ptr;
-       u64 MeasureStartTime;
-       u16 MeasureDuration;
-
-       /* skip 802.11 header. */
-       MsgLen -= sizeof(struct rt_header_802_11);
-
-       /* skip category and action code. */
-       pFramePtr += 2;
-       MsgLen -= 2;
-
-       if (pMeasureReqInfo == NULL)
-               return result;
-
-       NdisMoveMemory(pDialogToken, pFramePtr, 1);
-       pFramePtr += 1;
-       MsgLen -= 1;
-
-       eid_ptr = (struct rt_eid *) pFramePtr;
-       while (((u8 *) eid_ptr + eid_ptr->Len + 1) <
-              ((u8 *)pFramePtr + MsgLen)) {
-               switch (eid_ptr->Eid) {
-               case IE_MEASUREMENT_REQUEST:
-                       NdisMoveMemory(&pMeasureReqInfo->Token, eid_ptr->Octet,
-                                      1);
-                       NdisMoveMemory(&pMeasureReqInfo->ReqMode.word,
-                                      eid_ptr->Octet + 1, 1);
-                       NdisMoveMemory(&pMeasureReqInfo->ReqType,
-                                      eid_ptr->Octet + 2, 1);
-                       ptr = (u8 *)(eid_ptr->Octet + 3);
-                       NdisMoveMemory(&pMeasureReq->ChNum, ptr, 1);
-                       NdisMoveMemory(&MeasureStartTime, ptr + 1, 8);
-                       pMeasureReq->MeasureStartTime =
-                           SWAP64(MeasureStartTime);
-                       NdisMoveMemory(&MeasureDuration, ptr + 9, 2);
-                       pMeasureReq->MeasureDuration = SWAP16(MeasureDuration);
-
-                       result = TRUE;
-                       break;
-
-               default:
-                       break;
-               }
-               eid_ptr = (struct rt_eid *) ((u8 *) eid_ptr + 2 + eid_ptr->Len);
-       }
-
-       return result;
-}
-
-/*
-       ==========================================================================
-       Description:
-               Measurement report action frame sanity check.
-
-       Parametrs:
-               1. MLME message containing the received frame
-               2. message length.
-               3. Measurement report information buffer.
-               4. basic report information buffer.
-
-       Return  : None.
-       ==========================================================================
- */
-
-/*
-  Measurement Report IE.
-  +----+-----+-------+-------------+--------------+----------------+
-  | ID | Len | Token | Report Mode | Measure Type | Measure Report |
-  +----+-----+-------+-------------+--------------+----------------+
-    1     1      1          1             1            variable
-
-  Basic Report.
-  +--------+------------+----------+-----+
-  | Ch Num | Start Time | Duration | Map |
-  +--------+------------+----------+-----+
-      1          8           2        1
-
-  Map Field Bit Format.
-  +-----+---------------+---------------------+-------+------------+----------+
-  | Bss | OFDM Preamble | Unidentified signal | Radar | Unmeasured | Reserved |
-  +-----+---------------+---------------------+-------+------------+----------+
-     0          1                  2              3         4          5-7
-*/
-static BOOLEAN PeerMeasureReportSanity(struct rt_rtmp_adapter *pAd,
-                                      void * pMsg,
-                                      unsigned long MsgLen,
-                                      u8 *pDialogToken,
-                                      struct rt_measure_report_info *
-                                      pMeasureReportInfo,
-                                      u8 *pReportBuf)
-{
-       struct rt_frame_802_11 * Fr = (struct rt_frame_802_11 *) pMsg;
-       u8 *pFramePtr = Fr->Octet;
-       BOOLEAN result = FALSE;
-       struct rt_eid * eid_ptr;
-       u8 *ptr;
-
-       /* skip 802.11 header. */
-       MsgLen -= sizeof(struct rt_header_802_11);
-
-       /* skip category and action code. */
-       pFramePtr += 2;
-       MsgLen -= 2;
-
-       if (pMeasureReportInfo == NULL)
-               return result;
-
-       NdisMoveMemory(pDialogToken, pFramePtr, 1);
-       pFramePtr += 1;
-       MsgLen -= 1;
-
-       eid_ptr = (struct rt_eid *) pFramePtr;
-       while (((u8 *) eid_ptr + eid_ptr->Len + 1) <
-              ((u8 *)pFramePtr + MsgLen)) {
-               switch (eid_ptr->Eid) {
-               case IE_MEASUREMENT_REPORT:
-                       NdisMoveMemory(&pMeasureReportInfo->Token,
-                                      eid_ptr->Octet, 1);
-                       NdisMoveMemory(&pMeasureReportInfo->ReportMode,
-                                      eid_ptr->Octet + 1, 1);
-                       NdisMoveMemory(&pMeasureReportInfo->ReportType,
-                                      eid_ptr->Octet + 2, 1);
-                       if (pMeasureReportInfo->ReportType == RM_BASIC) {
-                               struct rt_measure_basic_report * pReport =
-                                   (struct rt_measure_basic_report *) pReportBuf;
-                               ptr = (u8 *)(eid_ptr->Octet + 3);
-                               NdisMoveMemory(&pReport->ChNum, ptr, 1);
-                               NdisMoveMemory(&pReport->MeasureStartTime,
-                                              ptr + 1, 8);
-                               NdisMoveMemory(&pReport->MeasureDuration,
-                                              ptr + 9, 2);
-                               NdisMoveMemory(&pReport->Map, ptr + 11, 1);
-
-                       } else if (pMeasureReportInfo->ReportType == RM_CCA) {
-                               struct rt_measure_cca_report * pReport =
-                                   (struct rt_measure_cca_report *) pReportBuf;
-                               ptr = (u8 *)(eid_ptr->Octet + 3);
-                               NdisMoveMemory(&pReport->ChNum, ptr, 1);
-                               NdisMoveMemory(&pReport->MeasureStartTime,
-                                              ptr + 1, 8);
-                               NdisMoveMemory(&pReport->MeasureDuration,
-                                              ptr + 9, 2);
-                               NdisMoveMemory(&pReport->CCA_Busy_Fraction,
-                                              ptr + 11, 1);
-
-                       } else if (pMeasureReportInfo->ReportType ==
-                                  RM_RPI_HISTOGRAM) {
-                               struct rt_measure_rpi_report * pReport =
-                                   (struct rt_measure_rpi_report *) pReportBuf;
-                               ptr = (u8 *)(eid_ptr->Octet + 3);
-                               NdisMoveMemory(&pReport->ChNum, ptr, 1);
-                               NdisMoveMemory(&pReport->MeasureStartTime,
-                                              ptr + 1, 8);
-                               NdisMoveMemory(&pReport->MeasureDuration,
-                                              ptr + 9, 2);
-                               NdisMoveMemory(&pReport->RPI_Density, ptr + 11,
-                                              8);
-                       }
-                       result = TRUE;
-                       break;
-
-               default:
-                       break;
-               }
-               eid_ptr = (struct rt_eid *) ((u8 *) eid_ptr + 2 + eid_ptr->Len);
-       }
-
-       return result;
-}
-
-/*
-       ==========================================================================
-       Description:
-               TPC Request action frame sanity check.
-
-       Parametrs:
-               1. MLME message containing the received frame
-               2. message length.
-               3. Dialog Token.
-
-       Return  : None.
-       ==========================================================================
- */
-static BOOLEAN PeerTpcReqSanity(struct rt_rtmp_adapter *pAd,
-                               void * pMsg,
-                               unsigned long MsgLen, u8 *pDialogToken)
-{
-       struct rt_frame_802_11 * Fr = (struct rt_frame_802_11 *) pMsg;
-       u8 *pFramePtr = Fr->Octet;
-       BOOLEAN result = FALSE;
-       struct rt_eid * eid_ptr;
-
-       MsgLen -= sizeof(struct rt_header_802_11);
-
-       /* skip category and action code. */
-       pFramePtr += 2;
-       MsgLen -= 2;
-
-       if (pDialogToken == NULL)
-               return result;
-
-       NdisMoveMemory(pDialogToken, pFramePtr, 1);
-       pFramePtr += 1;
-       MsgLen -= 1;
-
-       eid_ptr = (struct rt_eid *) pFramePtr;
-       while (((u8 *) eid_ptr + eid_ptr->Len + 1) <
-              ((u8 *)pFramePtr + MsgLen)) {
-               switch (eid_ptr->Eid) {
-               case IE_TPC_REQUEST:
-                       result = TRUE;
-                       break;
-
-               default:
-                       break;
-               }
-               eid_ptr = (struct rt_eid *) ((u8 *) eid_ptr + 2 + eid_ptr->Len);
-       }
-
-       return result;
-}
-
-/*
-       ==========================================================================
-       Description:
-               TPC Report action frame sanity check.
-
-       Parametrs:
-               1. MLME message containing the received frame
-               2. message length.
-               3. Dialog Token.
-               4. TPC Report IE.
-
-       Return  : None.
-       ==========================================================================
- */
-static BOOLEAN PeerTpcRepSanity(struct rt_rtmp_adapter *pAd,
-                               void * pMsg,
-                               unsigned long MsgLen,
-                               u8 *pDialogToken,
-                               struct rt_tpc_report_info * pTpcRepInfo)
-{
-       struct rt_frame_802_11 * Fr = (struct rt_frame_802_11 *) pMsg;
-       u8 *pFramePtr = Fr->Octet;
-       BOOLEAN result = FALSE;
-       struct rt_eid * eid_ptr;
-
-       MsgLen -= sizeof(struct rt_header_802_11);
-
-       /* skip category and action code. */
-       pFramePtr += 2;
-       MsgLen -= 2;
-
-       if (pDialogToken == NULL)
-               return result;
-
-       NdisMoveMemory(pDialogToken, pFramePtr, 1);
-       pFramePtr += 1;
-       MsgLen -= 1;
-
-       eid_ptr = (struct rt_eid *) pFramePtr;
-       while (((u8 *) eid_ptr + eid_ptr->Len + 1) <
-              ((u8 *)pFramePtr + MsgLen)) {
-               switch (eid_ptr->Eid) {
-               case IE_TPC_REPORT:
-                       NdisMoveMemory(&pTpcRepInfo->TxPwr, eid_ptr->Octet, 1);
-                       NdisMoveMemory(&pTpcRepInfo->LinkMargin,
-                                      eid_ptr->Octet + 1, 1);
-                       result = TRUE;
-                       break;
-
-               default:
-                       break;
-               }
-               eid_ptr = (struct rt_eid *) ((u8 *) eid_ptr + 2 + eid_ptr->Len);
-       }
-
-       return result;
-}
-
-/*
-       ==========================================================================
-       Description:
-               Channel Switch Announcement action frame handler.
-
-       Parametrs:
-               Elme - MLME message containing the received frame
-
-       Return  : None.
-       ==========================================================================
- */
-static void PeerChSwAnnAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
-{
-       struct rt_ch_sw_ann_info ChSwAnnInfo;
-       struct rt_frame_802_11 * pFr = (struct rt_frame_802_11 *) Elem->Msg;
-       u8 index = 0, Channel = 0, NewChannel = 0;
-       unsigned long Bssidx = 0;
-
-       NdisZeroMemory(&ChSwAnnInfo, sizeof(struct rt_ch_sw_ann_info));
-       if (!PeerChSwAnnSanity(pAd, Elem->Msg, Elem->MsgLen, &ChSwAnnInfo)) {
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("Invalid Channel Switch Action Frame.\n"));
-               return;
-       }
-
-       if (pAd->OpMode == OPMODE_STA) {
-               Bssidx =
-                   BssTableSearch(&pAd->ScanTab, pFr->Hdr.Addr3,
-                                  pAd->CommonCfg.Channel);
-               if (Bssidx == BSS_NOT_FOUND) {
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("PeerChSwAnnAction - Bssidx is not found\n"));
-                       return;
-               }
-
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("\n****Bssidx is %d, Channel = %d\n", index,
-                         pAd->ScanTab.BssEntry[Bssidx].Channel));
-               hex_dump("SSID", pAd->ScanTab.BssEntry[Bssidx].Bssid, 6);
-
-               Channel = pAd->CommonCfg.Channel;
-               NewChannel = ChSwAnnInfo.Channel;
-
-               if ((pAd->CommonCfg.bIEEE80211H == 1) && (NewChannel != 0)
-                   && (Channel != NewChannel)) {
-                       /* Switching to channel 1 can prevent from rescanning the current channel immediately (by auto reconnection). */
-                       /* In addition, clear the MLME queue and the scan table to discard the RX packets and previous scanning results. */
-                       AsicSwitchChannel(pAd, 1, FALSE);
-                       AsicLockChannel(pAd, 1);
-                       LinkDown(pAd, FALSE);
-                       MlmeQueueInit(&pAd->Mlme.Queue);
-                       BssTableInit(&pAd->ScanTab);
-                       RTMPusecDelay(1000000); /* use delay to prevent STA do reassoc */
-
-                       /* channel sanity check */
-                       for (index = 0; index < pAd->ChannelListNum; index++) {
-                               if (pAd->ChannelList[index].Channel ==
-                                   NewChannel) {
-                                       pAd->ScanTab.BssEntry[Bssidx].Channel =
-                                           NewChannel;
-                                       pAd->CommonCfg.Channel = NewChannel;
-                                       AsicSwitchChannel(pAd,
-                                                         pAd->CommonCfg.
-                                                         Channel, FALSE);
-                                       AsicLockChannel(pAd,
-                                                       pAd->CommonCfg.Channel);
-                                       DBGPRINT(RT_DEBUG_TRACE,
-                                                ("&&&&&&&&&&&&&&&&PeerChSwAnnAction - STA receive channel switch announcement IE (New Channel =%d)\n",
-                                                 NewChannel));
-                                       break;
-                               }
-                       }
-
-                       if (index >= pAd->ChannelListNum) {
-                               DBGPRINT_ERR("&&&&&&&&&&&&&&&&&&&&&&&&&&PeerChSwAnnAction(can not find New Channel=%d in ChannelList[%d]\n", pAd->CommonCfg.Channel, pAd->ChannelListNum);
-                       }
-               }
-       }
-
-       return;
-}
-
-/*
-       ==========================================================================
-       Description:
-               Measurement Request action frame handler.
-
-       Parametrs:
-               Elme - MLME message containing the received frame
-
-       Return  : None.
-       ==========================================================================
- */
-static void PeerMeasureReqAction(struct rt_rtmp_adapter *pAd,
-                                struct rt_mlme_queue_elem *Elem)
-{
-       struct rt_frame_802_11 * pFr = (struct rt_frame_802_11 *) Elem->Msg;
-       u8 DialogToken;
-       struct rt_measure_req_info MeasureReqInfo;
-       struct rt_measure_req MeasureReq;
-       MEASURE_REPORT_MODE ReportMode;
-
-       if (PeerMeasureReqSanity
-           (pAd, Elem->Msg, Elem->MsgLen, &DialogToken, &MeasureReqInfo,
-            &MeasureReq)) {
-               ReportMode.word = 0;
-               ReportMode.field.Incapable = 1;
-               EnqueueMeasurementRep(pAd, pFr->Hdr.Addr2, DialogToken,
-                                     MeasureReqInfo.Token, ReportMode.word,
-                                     MeasureReqInfo.ReqType, 0, NULL);
-       }
-
-       return;
-}
-
-/*
-       ==========================================================================
-       Description:
-               Measurement Report action frame handler.
-
-       Parametrs:
-               Elme - MLME message containing the received frame
-
-       Return  : None.
-       ==========================================================================
- */
-static void PeerMeasureReportAction(struct rt_rtmp_adapter *pAd,
-                                   struct rt_mlme_queue_elem *Elem)
-{
-       struct rt_measure_report_info MeasureReportInfo;
-       struct rt_frame_802_11 * pFr = (struct rt_frame_802_11 *) Elem->Msg;
-       u8 DialogToken;
-       u8 *pMeasureReportInfo;
-
-/*      if (pAd->CommonCfg.bIEEE80211H != TRUE) */
-/*              return; */
-
-       pMeasureReportInfo = kmalloc(sizeof(struct rt_measure_rpi_report), GFP_ATOMIC);
-       if (pMeasureReportInfo == NULL) {
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("%s unable to alloc memory for measure report buffer (size=%zu).\n",
-                         __func__, sizeof(struct rt_measure_rpi_report)));
-               return;
-       }
-
-       NdisZeroMemory(&MeasureReportInfo, sizeof(struct rt_measure_report_info));
-       NdisZeroMemory(pMeasureReportInfo, sizeof(struct rt_measure_rpi_report));
-       if (PeerMeasureReportSanity
-           (pAd, Elem->Msg, Elem->MsgLen, &DialogToken, &MeasureReportInfo,
-            pMeasureReportInfo)) {
-               do {
-                       struct rt_measure_req_entry *pEntry = NULL;
-
-                       /* Not a autonomous measure report. */
-                       /* check the dialog token field. drop it if the dialog token doesn't match. */
-                       if ((DialogToken != 0)
-                           && ((pEntry = MeasureReqLookUp(pAd, DialogToken)) ==
-                               NULL))
-                               break;
-
-                       if (pEntry != NULL)
-                               MeasureReqDelete(pAd, pEntry->DialogToken);
-
-                       if (MeasureReportInfo.ReportType == RM_BASIC) {
-                               struct rt_measure_basic_report * pBasicReport =
-                                   (struct rt_measure_basic_report *) pMeasureReportInfo;
-                               if ((pBasicReport->Map.field.Radar)
-                                   &&
-                                   (DfsRequirementCheck
-                                    (pAd, pBasicReport->ChNum) == TRUE)) {
-                                       NotifyChSwAnnToPeerAPs(pAd,
-                                                              pFr->Hdr.Addr1,
-                                                              pFr->Hdr.Addr2,
-                                                              1,
-                                                              pBasicReport->
-                                                              ChNum);
-                                       StartDFSProcedure(pAd,
-                                                         pBasicReport->ChNum,
-                                                         1);
-                               }
-                       }
-               } while (FALSE);
-       } else
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("Invalid Measurement Report Frame.\n"));
-
-       kfree(pMeasureReportInfo);
-
-       return;
-}
-
-/*
-       ==========================================================================
-       Description:
-               TPC Request action frame handler.
-
-       Parametrs:
-               Elme - MLME message containing the received frame
-
-       Return  : None.
-       ==========================================================================
- */
-static void PeerTpcReqAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
-{
-       struct rt_frame_802_11 * pFr = (struct rt_frame_802_11 *) Elem->Msg;
-       u8 *pFramePtr = pFr->Octet;
-       u8 DialogToken;
-       u8 TxPwr = GetCurTxPwr(pAd, Elem->Wcid);
-       u8 LinkMargin = 0;
-       char RealRssi;
-
-       /* link margin: Ratio of the received signal power to the minimum desired by the station (STA). The */
-       /*                              STA may incorporate rate information and channel conditions, including interference, into its computation */
-       /*                              of link margin. */
-
-       RealRssi = RTMPMaxRssi(pAd, ConvertToRssi(pAd, Elem->Rssi0, RSSI_0),
-                              ConvertToRssi(pAd, Elem->Rssi1, RSSI_1),
-                              ConvertToRssi(pAd, Elem->Rssi2, RSSI_2));
-
-       /* skip Category and action code. */
-       pFramePtr += 2;
-
-       /* Dialog token. */
-       NdisMoveMemory(&DialogToken, pFramePtr, 1);
-
-       LinkMargin = (RealRssi / MIN_RCV_PWR);
-       if (PeerTpcReqSanity(pAd, Elem->Msg, Elem->MsgLen, &DialogToken))
-               EnqueueTPCRep(pAd, pFr->Hdr.Addr2, DialogToken, TxPwr,
-                             LinkMargin);
-
-       return;
-}
-
-/*
-       ==========================================================================
-       Description:
-               TPC Report action frame handler.
-
-       Parametrs:
-               Elme - MLME message containing the received frame
-
-       Return  : None.
-       ==========================================================================
- */
-static void PeerTpcRepAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
-{
-       u8 DialogToken;
-       struct rt_tpc_report_info TpcRepInfo;
-       struct rt_tpc_req_entry *pEntry = NULL;
-
-       NdisZeroMemory(&TpcRepInfo, sizeof(struct rt_tpc_report_info));
-       if (PeerTpcRepSanity
-           (pAd, Elem->Msg, Elem->MsgLen, &DialogToken, &TpcRepInfo)) {
-               pEntry = TpcReqLookUp(pAd, DialogToken);
-               if (pEntry != NULL) {
-                       TpcReqDelete(pAd, pEntry->DialogToken);
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("%s: DialogToken=%x, TxPwr=%d, LinkMargin=%d\n",
-                                 __func__, DialogToken, TpcRepInfo.TxPwr,
-                                 TpcRepInfo.LinkMargin));
-               }
-       }
-
-       return;
-}
-
-/*
-       ==========================================================================
-       Description:
-               Spectrun action frames Handler such as channel switch annoucement,
-               measurement report, measurement request actions frames.
-
-       Parametrs:
-               Elme - MLME message containing the received frame
-
-       Return  : None.
-       ==========================================================================
- */
-void PeerSpectrumAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
-{
-
-       u8 Action = Elem->Msg[LENGTH_802_11 + 1];
-
-       if (pAd->CommonCfg.bIEEE80211H != TRUE)
-               return;
-
-       switch (Action) {
-       case SPEC_MRQ:
-               /* current rt2860 unable do such measure specified in Measurement Request. */
-               /* reject all measurement request. */
-               PeerMeasureReqAction(pAd, Elem);
-               break;
-
-       case SPEC_MRP:
-               PeerMeasureReportAction(pAd, Elem);
-               break;
-
-       case SPEC_TPCRQ:
-               PeerTpcReqAction(pAd, Elem);
-               break;
-
-       case SPEC_TPCRP:
-               PeerTpcRepAction(pAd, Elem);
-               break;
-
-       case SPEC_CHANNEL_SWITCH:
-
-               PeerChSwAnnAction(pAd, Elem);
-               break;
-       }
-
-       return;
-}
-
-/*
-       ==========================================================================
-       Description:
-
-       Parametrs:
-
-       Return  : None.
-       ==========================================================================
- */
-int Set_MeasureReq_Proc(struct rt_rtmp_adapter *pAd, char *arg)
-{
-       u32 Aid = 1;
-       u32 ArgIdx;
-       char *thisChar;
-
-       MEASURE_REQ_MODE MeasureReqMode;
-       u8 MeasureReqToken = RandomByte(pAd);
-       u8 MeasureReqType = RM_BASIC;
-       u8 MeasureCh = 1;
-       u64 MeasureStartTime = GetCurrentTimeStamp(pAd);
-       struct rt_measure_req MeasureReq;
-       u8 TotalLen;
-
-       struct rt_header_802_11 ActHdr;
-       u8 *pOutBuffer = NULL;
-       int NStatus;
-       unsigned long FrameLen;
-
-       NStatus = MlmeAllocateMemory(pAd, (void *)& pOutBuffer);        /*Get an unused nonpaged memory */
-       if (NStatus != NDIS_STATUS_SUCCESS) {
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("%s() allocate memory failed \n", __func__));
-               goto END_OF_MEASURE_REQ;
-       }
-
-       ArgIdx = 1;
-       while ((thisChar = strsep((char **)&arg, "-")) != NULL) {
-               switch (ArgIdx) {
-               case 1: /* Aid. */
-                       Aid = (u8)simple_strtol(thisChar, 0, 16);
-                       break;
-
-               case 2: /* Measurement Request Type. */
-                       MeasureReqType = simple_strtol(thisChar, 0, 16);
-                       if (MeasureReqType > 3) {
-                               DBGPRINT(RT_DEBUG_ERROR,
-                                        ("%s: unknow MeasureReqType(%d)\n",
-                                         __func__, MeasureReqType));
-                               goto END_OF_MEASURE_REQ;
-                       }
-                       break;
-
-               case 3: /* Measurement channel. */
-                       MeasureCh = (u8)simple_strtol(thisChar, 0, 16);
-                       break;
-               }
-               ArgIdx++;
-       }
-
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("%s::Aid = %d, MeasureReqType=%d MeasureCh=%d\n", __func__,
-                 Aid, MeasureReqType, MeasureCh));
-       if (!VALID_WCID(Aid)) {
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("%s: unknow sta of Aid(%d)\n", __func__, Aid));
-               goto END_OF_MEASURE_REQ;
-       }
-
-       MeasureReqMode.word = 0;
-       MeasureReqMode.field.Enable = 1;
-
-       MeasureReqInsert(pAd, MeasureReqToken);
-
-       /* build action frame header. */
-       MgtMacHeaderInit(pAd, &ActHdr, SUBTYPE_ACTION, 0,
-                        pAd->MacTab.Content[Aid].Addr, pAd->CurrentAddress);
-
-       NdisMoveMemory(pOutBuffer, (char *)& ActHdr, sizeof(struct rt_header_802_11));
-       FrameLen = sizeof(struct rt_header_802_11);
-
-       TotalLen = sizeof(struct rt_measure_req_info) + sizeof(struct rt_measure_req);
-
-       MakeMeasurementReqFrame(pAd, pOutBuffer, &FrameLen,
-                               sizeof(struct rt_measure_req_info), CATEGORY_RM, RM_BASIC,
-                               MeasureReqToken, MeasureReqMode.word,
-                               MeasureReqType, 0);
-
-       MeasureReq.ChNum = MeasureCh;
-       MeasureReq.MeasureStartTime = cpu2le64(MeasureStartTime);
-       MeasureReq.MeasureDuration = cpu2le16(2000);
-
-       {
-               unsigned long TempLen;
-               MakeOutgoingFrame(pOutBuffer + FrameLen, &TempLen,
-                                 sizeof(struct rt_measure_req), &MeasureReq,
-                                 END_OF_ARGS);
-               FrameLen += TempLen;
-       }
-
-       MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, (u32)FrameLen);
-
-END_OF_MEASURE_REQ:
-       MlmeFreeMemory(pAd, pOutBuffer);
-
-       return TRUE;
-}
-
-int Set_TpcReq_Proc(struct rt_rtmp_adapter *pAd, char *arg)
-{
-       u32 Aid;
-
-       u8 TpcReqToken = RandomByte(pAd);
-
-       Aid = (u32)simple_strtol(arg, 0, 16);
-
-       DBGPRINT(RT_DEBUG_TRACE, ("%s::Aid = %d\n", __func__, Aid));
-       if (!VALID_WCID(Aid)) {
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("%s: unknow sta of Aid(%d)\n", __func__, Aid));
-               return TRUE;
-       }
-
-       TpcReqInsert(pAd, TpcReqToken);
-
-       EnqueueTPCReq(pAd, pAd->MacTab.Content[Aid].Addr, TpcReqToken);
-
-       return TRUE;
-}
diff --git a/drivers/staging/rt2860/crypt_hmac.h b/drivers/staging/rt2860/crypt_hmac.h
deleted file mode 100644 (file)
index 7a56515..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
- */
-
-/****************************************************************************
-    Module Name:
-    HMAC
-
-    Abstract:
-    FIPS 198: The Keyed-Hash Message Authentication Code (HMAC)
-
-    Revision History:
-    Who         When            What
-    --------    ----------      ------------------------------------------
-    Eddy        2008/11/24      Create HMAC-SHA1, HMAC-SHA256
-***************************************************************************/
-#ifndef __CRYPT_HMAC_H__
-#define __CRYPT_HMAC_H__
-
-#ifdef CRYPT_TESTPLAN
-#include "crypt_testplan.h"
-#else
-#include "rt_config.h"
-#endif /* CRYPT_TESTPLAN */
-
-#ifdef SHA1_SUPPORT
-#define HMAC_SHA1_SUPPORT
-void HMAC_SHA1(IN const u8 Key[],
-              u32 KeyLen,
-              IN const u8 Message[],
-              u32 MessageLen, u8 MAC[], u32 MACLen);
-#endif /* SHA1_SUPPORT */
-
-#ifdef MD5_SUPPORT
-#define HMAC_MD5_SUPPORT
-void HMAC_MD5(IN const u8 Key[],
-             u32 KeyLen,
-             IN const u8 Message[],
-             u32 MessageLen, u8 MAC[], u32 MACLen);
-#endif /* MD5_SUPPORT */
-
-#endif /* __CRYPT_HMAC_H__ */
diff --git a/drivers/staging/rt2860/crypt_md5.h b/drivers/staging/rt2860/crypt_md5.h
deleted file mode 100644 (file)
index 26f9745..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
- */
-
-/****************************************************************************
-    Module Name:
-    MD5
-
-    Abstract:
-    RFC1321: The MD5 Message-Digest Algorithm
-
-    Revision History:
-    Who         When            What
-    --------    ----------      ------------------------------------------
-    Eddy        2008/11/24      Create md5
-***************************************************************************/
-
-#ifndef __CRYPT_MD5_H__
-#define __CRYPT_MD5_H__
-
-#ifdef CRYPT_TESTPLAN
-#include "crypt_testplan.h"
-#else
-#include "rt_config.h"
-#endif /* CRYPT_TESTPLAN */
-
-/* Algorithm options */
-#define MD5_SUPPORT
-
-#ifdef MD5_SUPPORT
-#define MD5_BLOCK_SIZE    64   /* 512 bits = 64 bytes */
-#define MD5_DIGEST_SIZE   16   /* 128 bits = 16 bytes */
-
-struct rt_md5_ctx_struc {
-       u32 HashValue[4];
-       u64 MessageLen;
-       u8 Block[MD5_BLOCK_SIZE];
-       u32 BlockLen;
-};
-
-void MD5_Init(struct rt_md5_ctx_struc *pMD5_CTX);
-void MD5_Hash(struct rt_md5_ctx_struc *pMD5_CTX);
-void MD5_Append(struct rt_md5_ctx_struc *pMD5_CTX,
-               IN const u8 Message[], u32 MessageLen);
-void MD5_End(struct rt_md5_ctx_struc *pMD5_CTX, u8 DigestMessage[]);
-void RT_MD5(IN const u8 Message[],
-           u32 MessageLen, u8 DigestMessage[]);
-#endif /* MD5_SUPPORT */
-
-#endif /* __CRYPT_MD5_H__ */
diff --git a/drivers/staging/rt2860/crypt_sha2.h b/drivers/staging/rt2860/crypt_sha2.h
deleted file mode 100644 (file)
index 20d11ab..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
- */
-
-/****************************************************************************
-    Module Name:
-    SHA2
-
-    Abstract:
-    FIPS 180-2: Secure Hash Standard (SHS)
-
-    Revision History:
-    Who         When            What
-    --------    ----------      ------------------------------------------
-    Eddy        2008/11/24      Create SHA1
-    Eddy        2008/07/23      Create SHA256
-***************************************************************************/
-
-#ifndef __CRYPT_SHA2_H__
-#define __CRYPT_SHA2_H__
-
-#ifdef CRYPT_TESTPLAN
-#include "crypt_testplan.h"
-#else
-#include "rt_config.h"
-#endif /* CRYPT_TESTPLAN */
-
-/* Algorithm options */
-#define SHA1_SUPPORT
-
-#ifdef SHA1_SUPPORT
-#define SHA1_BLOCK_SIZE    64  /* 512 bits = 64 bytes */
-#define SHA1_DIGEST_SIZE   20  /* 160 bits = 20 bytes */
-struct rt_sha1_ctx {
-       u32 HashValue[5];       /* 5 = (SHA1_DIGEST_SIZE / 32) */
-       u64 MessageLen; /* total size */
-       u8 Block[SHA1_BLOCK_SIZE];
-       u32 BlockLen;
-};
-
-void RT_SHA1_Init(struct rt_sha1_ctx *pSHA_CTX);
-void SHA1_Hash(struct rt_sha1_ctx *pSHA_CTX);
-void SHA1_Append(struct rt_sha1_ctx *pSHA_CTX,
-                IN const u8 Message[], u32 MessageLen);
-void SHA1_End(struct rt_sha1_ctx *pSHA_CTX, u8 DigestMessage[]);
-void RT_SHA1(IN const u8 Message[],
-            u32 MessageLen, u8 DigestMessage[]);
-#endif /* SHA1_SUPPORT */
-
-#endif /* __CRYPT_SHA2_H__ */
diff --git a/drivers/staging/rt2860/dfs.h b/drivers/staging/rt2860/dfs.h
deleted file mode 100644 (file)
index 5fbab25..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-    Module Name:
-    dfs.h
-
-    Abstract:
-    Support DFS function.
-
-    Revision History:
-    Who       When            What
-    --------  ----------      ----------------------------------------------
-    Fonchi    03-12-2007      created
-*/
-
-BOOLEAN RadarChannelCheck(struct rt_rtmp_adapter *pAd, u8 Ch);
diff --git a/drivers/staging/rt2860/eeprom.h b/drivers/staging/rt2860/eeprom.h
deleted file mode 100644 (file)
index 72c8fb9..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-       Module Name:
-       eeprom.h
-
-       Abstract:
-       Miniport header file for eeprom related information
-
-       Revision History:
-       Who         When          What
-       --------    ----------    ----------------------------------------------
-*/
-#ifndef __EEPROM_H__
-#define __EEPROM_H__
-
-#ifdef RTMP_PCI_SUPPORT
-/*************************************************************************
-  *    Public function declarations for prom-based chipset
-  ************************************************************************/
-int rtmp_ee_prom_read16(struct rt_rtmp_adapter *pAd,
-                       u16 Offset, u16 *pValue);
-#endif /* RTMP_PCI_SUPPORT // */
-#ifdef RTMP_USB_SUPPORT
-/*************************************************************************
-  *    Public function declarations for usb-based prom chipset
-  ************************************************************************/
-int RTUSBReadEEPROM16(struct rt_rtmp_adapter *pAd,
-                          u16 offset, u16 *pData);
-#endif /* RTMP_USB_SUPPORT // */
-
-#ifdef RT30xx
-#ifdef RTMP_EFUSE_SUPPORT
-int rtmp_ee_efuse_read16(struct rt_rtmp_adapter *pAd,
-                        u16 Offset, u16 *pValue);
-#endif /* RTMP_EFUSE_SUPPORT // */
-#endif /* RT30xx // */
-
-/*************************************************************************
-  *    Public function declarations for prom operation callback functions setting
-  ************************************************************************/
-int RtmpChipOpsEepromHook(struct rt_rtmp_adapter *pAd, int infType);
-
-#endif /* __EEPROM_H__ // */
diff --git a/drivers/staging/rt2860/iface/rtmp_pci.h b/drivers/staging/rt2860/iface/rtmp_pci.h
deleted file mode 100644 (file)
index 3d66e38..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-*/
-
-#ifndef __RTMP_PCI_H__
-#define __RTMP_PCI_H__
-
-#define RT28XX_HANDLE_DEV_ASSIGN(handle, dev_p)                                \
-       ((struct os_cookie *)handle)->pci_dev = dev_p;
-
-#ifdef LINUX
-/* set driver data */
-#define RT28XX_DRVDATA_SET(_a)                 pci_set_drvdata(_a, net_dev);
-
-#define RT28XX_PUT_DEVICE(dev_p)
-
-#define SA_SHIRQ IRQF_SHARED
-
-#ifdef PCI_MSI_SUPPORT
-#define RTMP_MSI_ENABLE(_pAd) \
-       {     struct os_cookie *_pObj = (struct os_cookie *)(_pAd->OS_Cookie); \
-               (_pAd)->HaveMsi = pci_enable_msi(_pObj->pci_dev) \
-                                                       == 0 ? TRUE : FALSE; \
-       }
-
-#define RTMP_MSI_DISABLE(_pAd) \
-       {     struct os_cookie *_pObj = (struct os_cookie *)(_pAd->OS_Cookie); \
-               if (_pAd->HaveMsi == TRUE) \
-                       pci_disable_msi(_pObj->pci_dev); \
-               _pAd->HaveMsi = FALSE;  \
-       }
-#else
-#define RTMP_MSI_ENABLE(_pAd)          do {} while (0)
-#define RTMP_MSI_DISABLE(_pAd)         do {} while (0)
-#endif /* PCI_MSI_SUPPORT */
-
-#define RTMP_PCI_DEV_UNMAP()                                           \
-{      if (net_dev->base_addr) {                                       \
-               iounmap((void *)(net_dev->base_addr));                  \
-               release_mem_region(pci_resource_start(dev_p, 0),        \
-                                       pci_resource_len(dev_p, 0)); } \
-       if (net_dev->irq) \
-               pci_release_regions(dev_p); }
-
-#define PCI_REG_READ_WORD(pci_dev, offset, Configuration)   {\
-       if (pci_read_config_word(pci_dev, offset, &reg16) == 0)     \
-               Configuration = le2cpu16(reg16);                        \
-       else                                                        \
-               Configuration = 0; }
-
-#define PCI_REG_WIRTE_WORD(pci_dev, offset, Configuration)  {\
-       reg16 = cpu2le16(Configuration);                        \
-       pci_write_config_word(pci_dev, offset, reg16); }
-
-#endif /* LINUX */
-
-#endif /* __RTMP_PCI_H__ */
diff --git a/drivers/staging/rt2860/iface/rtmp_usb.h b/drivers/staging/rt2860/iface/rtmp_usb.h
deleted file mode 100644 (file)
index 5712896..0000000
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-*/
-
-#ifndef __RTMP_USB_H__
-#define __RTMP_USB_H__
-
-#include "../rtusb_io.h"
-
-#ifdef LINUX
-#include <linux/usb.h>
-#endif /* LINUX */
-
-extern u8 EpToQueue[6];
-
-#define RXBULKAGGRE_ZISE                       12
-#define MAX_TXBULK_LIMIT               (LOCAL_TXBUF_SIZE*(BULKAGGRE_ZISE-1))
-#define MAX_TXBULK_SIZE                (LOCAL_TXBUF_SIZE*BULKAGGRE_ZISE)
-#define MAX_RXBULK_SIZE                (LOCAL_TXBUF_SIZE*RXBULKAGGRE_ZISE)
-#define MAX_MLME_HANDLER_MEMORY 20
-
-/* Flags for Bulkflags control for bulk out data */
-#define        fRTUSB_BULK_OUT_DATA_NULL                               0x00000001
-#define        fRTUSB_BULK_OUT_RTS                                     0x00000002
-#define        fRTUSB_BULK_OUT_MLME                                    0x00000004
-
-#define        fRTUSB_BULK_OUT_PSPOLL                          0x00000010
-#define        fRTUSB_BULK_OUT_DATA_FRAG                               0x00000020
-#define        fRTUSB_BULK_OUT_DATA_FRAG_2                     0x00000040
-#define        fRTUSB_BULK_OUT_DATA_FRAG_3                     0x00000080
-#define        fRTUSB_BULK_OUT_DATA_FRAG_4                     0x00000100
-
-#define        fRTUSB_BULK_OUT_DATA_NORMAL                     0x00010000
-#define        fRTUSB_BULK_OUT_DATA_NORMAL_2                   0x00020000
-#define        fRTUSB_BULK_OUT_DATA_NORMAL_3                   0x00040000
-#define        fRTUSB_BULK_OUT_DATA_NORMAL_4                   0x00080000
-
-/* TODO:move to ./ate/include/iface/ate_usb.h */
-
-#define FREE_HTTX_RING(_pCookie, _pipeId, _txContext)                  \
-{                                                                      \
-       if ((_txContext)->ENextBulkOutPosition == \
-       (_txContext)->CurWritePosition) {\
-               (_txContext)->bRingEmpty = TRUE;                        \
-       }                                                               \
-       /*NdisInterlockedDecrement(&(_p)->TxCount); */\
-}
-
-/******************************************************************************
-
-       USB Bulk operation related definitions
-
-******************************************************************************/
-
-#ifdef LINUX
-#define BULKAGGRE_ZISE                 100
-#define RT28XX_PUT_DEVICE                      usb_put_dev
-#define RTUSB_ALLOC_URB(iso)           usb_alloc_urb(iso, GFP_ATOMIC)
-#define RTUSB_SUBMIT_URB(pUrb)         usb_submit_urb(pUrb, \
-                                                               GFP_ATOMIC)
-#define RTUSB_URB_ALLOC_BUFFER(pUsb_Dev, \
-                                                       BufSize, \
-                                                       pDma_addr)      \
-                                                       usb_alloc_coherent(\
-                                                       pUsb_Dev, \
-                                                       BufSize, \
-                                                       GFP_ATOMIC, \
-                                                       pDma_addr)
-#define RTUSB_URB_FREE_BUFFER(pUsb_Dev, \
-                                                       BufSize, \
-                                                       pTransferBuf, \
-                                                       Dma_addr)       \
-                                                       usb_free_coherent( \
-                                                       pUsb_Dev, \
-                                                       BufSize, \
-                                                       pTransferBuf, \
-                                                       Dma_addr)
-
-#define RTUSB_FREE_URB(pUrb)   usb_free_urb(pUrb)
-
-/* unlink urb */
-#define RTUSB_UNLINK_URB(pUrb)         usb_kill_urb(pUrb)
-
-extern void dump_urb(struct urb *purb);
-
-#define InterlockedIncrement           atomic_inc
-#define NdisInterlockedIncrement       atomic_inc
-#define InterlockedDecrement           atomic_dec
-#define NdisInterlockedDecrement       atomic_dec
-#define InterlockedExchange            atomic_set
-
-#endif /* LINUX */
-
-#define NT_SUCCESS(status)             (((status) >= 0) ? (TRUE) : (FALSE))
-
-#define USBD_TRANSFER_DIRECTION_OUT            0
-#define USBD_TRANSFER_DIRECTION_IN             0
-#define USBD_SHORT_TRANSFER_OK                 0
-#define PURB                   struct urb *
-
-#define PIRP           void *
-#define NDIS_OID       u32
-#ifndef USB_ST_NOERROR
-#define USB_ST_NOERROR     0
-#endif
-
-/* vendor-specific control operations */
-#define CONTROL_TIMEOUT_JIFFIES ((100 * OS_HZ) / 1000)
-#define UNLINK_TIMEOUT_MS              3
-
-void RTUSBBulkOutDataPacketComplete(struct urb *purb, struct pt_regs *pt_regs);
-void RTUSBBulkOutMLMEPacketComplete(struct urb *pUrb, struct pt_regs *pt_regs);
-void RTUSBBulkOutNullFrameComplete(struct urb *pUrb, struct pt_regs *pt_regs);
-void RTUSBBulkOutRTSFrameComplete(struct urb *pUrb, struct pt_regs *pt_regs);
-void RTUSBBulkOutPsPollComplete(struct urb *pUrb, struct pt_regs *pt_regs);
-void RTUSBBulkRxComplete(struct urb *pUrb, struct pt_regs *pt_regs);
-
-#ifdef KTHREAD_SUPPORT
-#define RTUSBMlmeUp(pAd) \
-       do {                                                                \
-               struct rt_rtmp_os_task *_pTask = &((pAd)->mlmeTask);\
-               if (_pTask->kthread_task) {\
-                       _pTask->kthread_running = TRUE; \
-               wake_up(&_pTask->kthread_q); \
-               } \
-       } while (0)
-#else
-#define RTUSBMlmeUp(pAd)               \
-       do {                                                                \
-               struct rt_rtmp_os_task *_pTask = &((pAd)->mlmeTask);\
-               CHECK_PID_LEGALITY(_pTask->taskPID)                 \
-               { \
-                       RTMP_SEM_EVENT_UP(&(_pTask->taskSema)); \
-               } \
-       } while (0)
-#endif
-
-#ifdef KTHREAD_SUPPORT
-#define RTUSBCMDUp(pAd) \
-       do {    \
-               struct rt_rtmp_os_task *_pTask = &((pAd)->cmdQTask);    \
-               { \
-                       _pTask->kthread_running = TRUE; \
-               wake_up(&_pTask->kthread_q); \
-               } \
-       } while (0)
-
-#else
-#define RTUSBCMDUp(pAd)                        \
-       do {                                                        \
-               struct rt_rtmp_os_task *_pTask = &((pAd)->cmdQTask);    \
-               CHECK_PID_LEGALITY(_pTask->taskPID)         \
-               {\
-                       RTMP_SEM_EVENT_UP(&(_pTask->taskSema)); \
-               } \
-       } while (0)
-#endif
-
-#define DEVICE_VENDOR_REQUEST_OUT       0x40
-#define DEVICE_VENDOR_REQUEST_IN        0xc0
-/*#define INTERFACE_VENDOR_REQUEST_OUT    0x41*/
-/*#define INTERFACE_VENDOR_REQUEST_IN     0xc1*/
-
-#define BULKOUT_MGMT_RESET_FLAG                0x80
-
-#define RTUSB_SET_BULK_FLAG(_M, _F)    ((_M)->BulkFlags |= (_F))
-#define RTUSB_CLEAR_BULK_FLAG(_M, _F)  ((_M)->BulkFlags &= ~(_F))
-#define RTUSB_TEST_BULK_FLAG(_M, _F)   (((_M)->BulkFlags & (_F)) != 0)
-
-#define RTMP_IRQ_REQUEST(net_dev)              do {} while (0)
-#define RTMP_IRQ_RELEASE(net_dev)              do {} while (0)
-
-#endif /* __RTMP_USB_H__ */
diff --git a/drivers/staging/rt2860/mlme.h b/drivers/staging/rt2860/mlme.h
deleted file mode 100644 (file)
index a285851..0000000
+++ /dev/null
@@ -1,1050 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-       Module Name:
-       mlme.h
-
-       Abstract:
-
-       Revision History:
-       Who                     When                    What
-       --------        ----------              ------------------------------
-       John Chang              2003-08-28              Created
-       John Chang              2004-09-06              modified for RT2600
-       Justin P. Mattock       11/07/2010              Fix typos in comments
-
-*/
-#ifndef __MLME_H__
-#define __MLME_H__
-
-#include "rtmp_dot11.h"
-
-/* maximum supported capability information */
-/* ESS, IBSS, Privacy, Short Preamble, Spectrum mgmt, Short Slot */
-#define SUPPORTED_CAPABILITY_INFO   0x0533
-
-#define END_OF_ARGS                 -1
-#define LFSR_MASK                   0x80000057
-#define MLME_TASK_EXEC_INTV         100/*200*/ /* */
-#define LEAD_TIME                   5
-#define MLME_TASK_EXEC_MULTIPLE       10  /*5*/        /* MLME_TASK_EXEC_MULTIPLE * MLME_TASK_EXEC_INTV = 1 sec */
-#define REORDER_EXEC_INTV              100     /* 0.1 sec */
-
-/* The definition of Radar detection duration region */
-#define CE             0
-#define FCC            1
-#define JAP            2
-#define JAP_W53        3
-#define JAP_W56        4
-#define MAX_RD_REGION 5
-
-#define BEACON_LOST_TIME            (4 * OS_HZ)        /* 2048 msec = 2 sec */
-
-#define DLS_TIMEOUT                 1200       /* unit: msec */
-#define AUTH_TIMEOUT                300        /* unit: msec */
-#define ASSOC_TIMEOUT               300        /* unit: msec */
-#define JOIN_TIMEOUT                2000       /* unit: msec */
-#define SHORT_CHANNEL_TIME          90 /* unit: msec */
-#define MIN_CHANNEL_TIME            110        /* unit: msec, for dual band scan */
-#define MAX_CHANNEL_TIME            140        /* unit: msec, for single band scan */
-#define        FAST_ACTIVE_SCAN_TIME       30  /* Active scan waiting for probe response time */
-#define CW_MIN_IN_BITS              4  /* actual CwMin = 2^CW_MIN_IN_BITS - 1 */
-#define LINK_DOWN_TIMEOUT           20000      /* unit: msec */
-#define AUTO_WAKEUP_TIMEOUT                    70      /*unit: msec */
-
-#define CW_MAX_IN_BITS              10 /* actual CwMax = 2^CW_MAX_IN_BITS - 1 */
-
-/* Note: RSSI_TO_DBM_OFFSET has been changed to variable for new RF (2004-0720). */
-/* Should not refer to this constant anymore */
-/*#define RSSI_TO_DBM_OFFSET          120 // for RT2530 RSSI-115 = dBm */
-#define RSSI_FOR_MID_TX_POWER       -55        /* -55 db is considered mid-distance */
-#define RSSI_FOR_LOW_TX_POWER       -45        /* -45 db is considered very short distance and */
-                                       /* eligible to use a lower TX power */
-#define RSSI_FOR_LOWEST_TX_POWER    -30
-/*#define MID_TX_POWER_DELTA          0   // 0 db from full TX power upon mid-distance to AP */
-#define LOW_TX_POWER_DELTA          6  /* -3 db from full TX power upon very short distance. 1 grade is 0.5 db */
-#define LOWEST_TX_POWER_DELTA       16 /* -8 db from full TX power upon shortest distance. 1 grade is 0.5 db */
-
-#define RSSI_TRIGGERED_UPON_BELOW_THRESHOLD     0
-#define RSSI_TRIGGERED_UPON_EXCCEED_THRESHOLD   1
-#define RSSI_THRESHOLD_FOR_ROAMING              25
-#define RSSI_DELTA                              5
-
-/* Channel Quality Indication */
-#define CQI_IS_GOOD(cqi)            ((cqi) >= 50)
-/*#define CQI_IS_FAIR(cqi)          (((cqi) >= 20) && ((cqi) < 50)) */
-#define CQI_IS_POOR(cqi)            (cqi < 50) /*(((cqi) >= 5) && ((cqi) < 20)) */
-#define CQI_IS_BAD(cqi)             (cqi < 5)
-#define CQI_IS_DEAD(cqi)            (cqi == 0)
-
-/* weighting factor to calculate Channel quality, total should be 100% */
-#define RSSI_WEIGHTING                   50
-#define TX_WEIGHTING                     30
-#define RX_WEIGHTING                     20
-
-#define BSS_NOT_FOUND                    0xFFFFFFFF
-
-#define MAX_LEN_OF_MLME_QUEUE            40    /*10 */
-
-#define SCAN_PASSIVE                     18    /* scan with no probe request, only wait beacon and probe response */
-#define SCAN_ACTIVE                      19    /* scan with probe request, and wait beacon and probe response */
-#define        SCAN_CISCO_PASSIVE                               20     /* Single channel passive scan */
-#define        SCAN_CISCO_ACTIVE                                21     /* Single channel active scan */
-#define        SCAN_CISCO_NOISE                                 22     /* Single channel passive scan for noise histogram collection */
-#define        SCAN_CISCO_CHANNEL_LOAD                  23     /* Single channel passive scan for channel load collection */
-#define FAST_SCAN_ACTIVE                 24    /* scan with probe request, and wait beacon and probe response */
-
-#define MAC_ADDR_IS_GROUP(Addr)       (((Addr[0]) & 0x01))
-#define MAC_ADDR_HASH(Addr)            (Addr[0] ^ Addr[1] ^ Addr[2] ^ Addr[3] ^ Addr[4] ^ Addr[5])
-#define MAC_ADDR_HASH_INDEX(Addr)      (MAC_ADDR_HASH(Addr) % HASH_TABLE_SIZE)
-#define TID_MAC_HASH(Addr, TID)            (TID^Addr[0] ^ Addr[1] ^ Addr[2] ^ Addr[3] ^ Addr[4] ^ Addr[5])
-#define TID_MAC_HASH_INDEX(Addr, TID)      (TID_MAC_HASH(Addr, TID) % HASH_TABLE_SIZE)
-
-/* LED Control */
-/* association ON. one LED ON. another blinking when TX, OFF when idle */
-/* no association, both LED off */
-#define ASIC_LED_ACT_ON(pAd)        RTMP_IO_WRITE32(pAd, MAC_CSR14, 0x00031e46)
-#define ASIC_LED_ACT_OFF(pAd)       RTMP_IO_WRITE32(pAd, MAC_CSR14, 0x00001e46)
-
-/* bit definition of the 2-byte pBEACON->Capability field */
-#define CAP_IS_ESS_ON(x)                 (((x) & 0x0001) != 0)
-#define CAP_IS_IBSS_ON(x)                (((x) & 0x0002) != 0)
-#define CAP_IS_CF_POLLABLE_ON(x)         (((x) & 0x0004) != 0)
-#define CAP_IS_CF_POLL_REQ_ON(x)         (((x) & 0x0008) != 0)
-#define CAP_IS_PRIVACY_ON(x)             (((x) & 0x0010) != 0)
-#define CAP_IS_SHORT_PREAMBLE_ON(x)      (((x) & 0x0020) != 0)
-#define CAP_IS_PBCC_ON(x)                (((x) & 0x0040) != 0)
-#define CAP_IS_AGILITY_ON(x)             (((x) & 0x0080) != 0)
-#define CAP_IS_SPECTRUM_MGMT(x)          (((x) & 0x0100) != 0) /* 802.11e d9 */
-#define CAP_IS_QOS(x)                    (((x) & 0x0200) != 0) /* 802.11e d9 */
-#define CAP_IS_SHORT_SLOT(x)             (((x) & 0x0400) != 0)
-#define CAP_IS_APSD(x)                   (((x) & 0x0800) != 0) /* 802.11e d9 */
-#define CAP_IS_IMMED_BA(x)               (((x) & 0x1000) != 0) /* 802.11e d9 */
-#define CAP_IS_DSSS_OFDM(x)              (((x) & 0x2000) != 0)
-#define CAP_IS_DELAY_BA(x)               (((x) & 0x4000) != 0) /* 802.11e d9 */
-
-#define CAP_GENERATE(ess, ibss, priv, s_pre, s_slot, spectrum)  (((ess) ? 0x0001 : 0x0000) | ((ibss) ? 0x0002 : 0x0000) | ((priv) ? 0x0010 : 0x0000) | ((s_pre) ? 0x0020 : 0x0000) | ((s_slot) ? 0x0400 : 0x0000) | ((spectrum) ? 0x0100 : 0x0000))
-
-#define ERP_IS_NON_ERP_PRESENT(x)        (((x) & 0x01) != 0)   /* 802.11g */
-#define ERP_IS_USE_PROTECTION(x)         (((x) & 0x02) != 0)   /* 802.11g */
-#define ERP_IS_USE_BARKER_PREAMBLE(x)    (((x) & 0x04) != 0)   /* 802.11g */
-
-#define DRS_TX_QUALITY_WORST_BOUND       8     /* 3  // just test by gary */
-#define DRS_PENALTY                      8
-
-#define BA_NOTUSE      2
-/*BA Policy subfiled value in ADDBA frame */
-#define IMMED_BA       1
-#define DELAY_BA       0
-
-/* BA Initiator subfield in DELBA frame */
-#define ORIGINATOR     1
-#define RECIPIENT      0
-
-/* ADDBA Status Code */
-#define ADDBA_RESULTCODE_SUCCESS                                       0
-#define ADDBA_RESULTCODE_REFUSED                                       37
-#define ADDBA_RESULTCODE_INVALID_PARAMETERS                    38
-
-/* DELBA Reason Code */
-#define DELBA_REASONCODE_QSTA_LEAVING                          36
-#define DELBA_REASONCODE_END_BA                                                37
-#define DELBA_REASONCODE_UNKNOWN_BA                                    38
-#define DELBA_REASONCODE_TIMEOUT                                       39
-
-/* reset all OneSecTx counters */
-#define RESET_ONE_SEC_TX_CNT(__pEntry) \
-if (((__pEntry)) != NULL) { \
-       (__pEntry)->OneSecTxRetryOkCount = 0; \
-       (__pEntry)->OneSecTxFailCount = 0; \
-       (__pEntry)->OneSecTxNoRetryOkCount = 0; \
-}
-
-/* */
-/* 802.11 frame formats */
-/* */
-/*  HT Capability INFO field in HT Cap IE . */
-struct PACKED rt_ht_cap_info {
-       u16 AdvCoding:1;
-       u16 ChannelWidth:1;
-       u16 MimoPs:2;   /*momi power safe */
-       u16 GF:1;               /*green field */
-       u16 ShortGIfor20:1;
-       u16 ShortGIfor40:1;     /*for40MHz */
-       u16 TxSTBC:1;
-       u16 RxSTBC:2;
-       u16 DelayedBA:1;        /*rt2860c not support */
-       u16 AMsduSize:1;        /* only support as zero */
-       u16 CCKmodein40:1;
-       u16 PSMP:1;
-       u16 Forty_Mhz_Intolerant:1;
-       u16 LSIGTxopProSup:1;
-};
-
-/*  HT Capability INFO field in HT Cap IE . */
-struct PACKED rt_ht_cap_parm {
-       u8 MaxRAmpduFactor:2;
-       u8 MpduDensity:3;
-       u8 rsv:3;               /*momi power safe */
-};
-
-/*  HT Capability INFO field in HT Cap IE . */
-struct PACKED rt_ht_mcs_set {
-       u8 MCSSet[10];
-       u8 SupRate[2];  /* unit : 1Mbps */
-       u8 TxMCSSetDefined:1;
-       u8 TxRxNotEqual:1;
-       u8 TxStream:2;
-       u8 MpduDensity:1;
-       u8 rsv:3;
-       u8 rsv3[3];
-};
-
-/*  HT Capability INFO field in HT Cap IE . */
-struct PACKED rt_ext_ht_cap_info {
-       u16 Pco:1;
-       u16 TranTime:2;
-       u16 rsv:5;              /*momi power safe */
-       u16 MCSFeedback:2;      /*0:no MCS feedback, 2:unsolicited MCS feedback, 3:Full MCS feedback,  1:rsv. */
-       u16 PlusHTC:1;  /*+HTC control field support */
-       u16 RDGSupport:1;       /*reverse Direction Grant  support */
-       u16 rsv2:4;
-};
-
-/*  HT Beamforming field in HT Cap IE . */
-struct PACKED rt_ht_bf_cap {
-       unsigned long TxBFRecCapable:1;
-       unsigned long RxSoundCapable:1;
-       unsigned long TxSoundCapable:1;
-       unsigned long RxNDPCapable:1;
-       unsigned long TxNDPCapable:1;
-       unsigned long ImpTxBFCapable:1;
-       unsigned long Calibration:2;
-       unsigned long ExpCSICapable:1;
-       unsigned long ExpNoComSteerCapable:1;
-       unsigned long ExpComSteerCapable:1;
-       unsigned long ExpCSIFbk:2;
-       unsigned long ExpNoComBF:2;
-       unsigned long ExpComBF:2;
-       unsigned long MinGrouping:2;
-       unsigned long CSIBFAntSup:2;
-       unsigned long NoComSteerBFAntSup:2;
-       unsigned long ComSteerBFAntSup:2;
-       unsigned long CSIRowBFSup:2;
-       unsigned long ChanEstimation:2;
-       unsigned long rsv:3;
-};
-
-/*  HT antenna selection field in HT Cap IE . */
-struct PACKED rt_ht_as_cap {
-       u8 AntSelect:1;
-       u8 ExpCSIFbkTxASEL:1;
-       u8 AntIndFbkTxASEL:1;
-       u8 ExpCSIFbk:1;
-       u8 AntIndFbk:1;
-       u8 RxASel:1;
-       u8 TxSoundPPDU:1;
-       u8 rsv:1;
-};
-
-/* Draft 1.0 set IE length 26, but is extensible.. */
-#define SIZE_HT_CAP_IE         26
-/* The structure for HT Capability IE. */
-struct PACKED rt_ht_capability_ie {
-       struct rt_ht_cap_info HtCapInfo;
-       struct rt_ht_cap_parm HtCapParm;
-/*      struct rt_ht_mcs_set              HtMCSSet; */
-       u8 MCSSet[16];
-       struct rt_ext_ht_cap_info ExtHtCapInfo;
-       struct rt_ht_bf_cap TxBFCap;    /* beamforming cap. rt2860c not support beamforming. */
-       struct rt_ht_as_cap ASCap;      /*antenna selection. */
-};
-
-/* 802.11n draft3 related structure definitions. */
-/* 7.3.2.60 */
-#define dot11OBSSScanPassiveDwell                                                      20      /* in TU. min amount of time that the STA continuously scans each channel when performing an active OBSS scan. */
-#define dot11OBSSScanActiveDwell                                                       10      /* in TU.min amount of time that the STA continuously scans each channel when performing an passive OBSS scan. */
-#define dot11BSSWidthTriggerScanInterval                                       300     /* in sec. max interval between scan operations to be performed to detect BSS channel width trigger events. */
-#define dot11OBSSScanPassiveTotalPerChannel                                    200     /* in TU. min total amount of time that the STA scans each channel when performing a passive OBSS scan. */
-#define dot11OBSSScanActiveTotalPerChannel                                     20      /*in TU. min total amount of time that the STA scans each channel when performing a active OBSS scan */
-#define dot11BSSWidthChannelTransactionDelayFactor                     5       /* min ratio between the delay time in performing a switch from 20MHz BSS to 20/40 BSS operation and the maximum */
-                                                                                                                               /*      interval between overlapping BSS scan operations. */
-#define dot11BSSScanActivityThreshold                                          25      /* in %%, max total time that a STA may be active on the medium during a period of */
-                                                                                                                               /*      (dot11BSSWidthChannelTransactionDelayFactor * dot11BSSWidthTriggerScanInterval) seconds without */
-                                                                                                                               /*      being obligated to perform OBSS Scan operations. default is 25(== 0.25%) */
-
-struct PACKED rt_overlap_bss_scan_ie {
-       u16 ScanPassiveDwell;
-       u16 ScanActiveDwell;
-       u16 TriggerScanInt;     /* Trigger scan interval */
-       u16 PassiveTalPerChannel;       /* passive total per channel */
-       u16 ActiveTalPerChannel;        /* active total per channel */
-       u16 DelayFactor;        /* BSS width channel transition delay factor */
-       u16 ScanActThre;        /* Scan Activity threshold */
-};
-
-/*  7.3.2.56. 20/40 Coexistence element used in  Element ID = 72 = IE_2040_BSS_COEXIST */
-typedef union PACKED _BSS_2040_COEXIST_IE {
-       struct PACKED {
-               u8 InfoReq:1;
-               u8 Intolerant40:1;      /* Inter-BSS. set 1 when prohibits a receiving BSS from operating as a 20/40 Mhz BSS. */
-               u8 BSS20WidthReq:1;     /* Intra-BSS set 1 when prohibits a receiving AP from operating its BSS as a 20/40MHz BSS. */
-               u8 rsv:5;
-       } field;
-       u8 word;
-} BSS_2040_COEXIST_IE, *PBSS_2040_COEXIST_IE;
-
-struct rt_trigger_eventa {
-       BOOLEAN bValid;
-       u8 BSSID[6];
-       u8 RegClass;            /* Regulatory Class */
-       u16 Channel;
-       unsigned long CDCounter;        /* Maintain a separate count down counter for each Event A. */
-};
-
-/* 20/40 trigger event table */
-/* If one Event (A) is deleted or created, or if Event (B) is detected or not detected, STA should send 2040BSSCoexistence to AP. */
-#define MAX_TRIGGER_EVENT              64
-struct rt_trigger_event_tab {
-       u8 EventANo;
-       struct rt_trigger_eventa EventA[MAX_TRIGGER_EVENT];
-       unsigned long EventBCountDown;  /* Count down counter for Event B. */
-};
-
-/* 7.3.27 20/40 Bss Coexistence Mgmt capability used in extended capabilities information IE( ID = 127 = IE_EXT_CAPABILITY). */
-/*      This is the first octet and was defined in 802.11n D3.03 and 802.11yD9.0 */
-struct PACKED rt_ext_cap_info_element {
-       u8 BssCoexistMgmtSupport:1;
-       u8 rsv:1;
-       u8 ExtendChannelSwitch:1;
-       u8 rsv2:5;
-};
-
-/* 802.11n 7.3.2.61 */
-struct PACKED rt_bss_2040_coexist_element {
-       u8 ElementID;   /* ID = IE_2040_BSS_COEXIST = 72 */
-       u8 Len;
-       BSS_2040_COEXIST_IE BssCoexistIe;
-};
-
-/*802.11n 7.3.2.59 */
-struct PACKED rt_bss_2040_intolerant_ch_report {
-       u8 ElementID;   /* ID = IE_2040_BSS_INTOLERANT_REPORT = 73 */
-       u8 Len;
-       u8 RegulatoryClass;
-       u8 ChList[0];
-};
-
-/* The structure for channel switch announcement IE. This is in 802.11n D3.03 */
-struct PACKED rt_cha_switch_announce_ie {
-       u8 SwitchMode;  /*channel switch mode */
-       u8 NewChannel;  /* */
-       u8 SwitchCount; /* */
-};
-
-/* The structure for channel switch announcement IE. This is in 802.11n D3.03 */
-struct PACKED rt_sec_cha_offset_ie {
-       u8 SecondaryChannelOffset;      /* 1: Secondary above, 3: Secondary below, 0: no Secondary */
-};
-
-/* This structure is extracted from struct struct rt_ht_capability */
-struct rt_ht_phy_info {
-       BOOLEAN bHtEnable;      /* If we should use ht rate. */
-       BOOLEAN bPreNHt;        /* If we should use ht rate. */
-       /*Subtract from HT Capability IE */
-       u8 MCSSet[16];
-};
-
-/*This structure subtracts ralink supports from all 802.11n-related features. */
-/*Features not listed here but contained in 802.11n spec are not supported in rt2860. */
-struct rt_ht_capability {
-       u16 ChannelWidth:1;
-       u16 MimoPs:2;   /*mimo power safe MMPS_ */
-       u16 GF:1;               /*green field */
-       u16 ShortGIfor20:1;
-       u16 ShortGIfor40:1;     /*for40MHz */
-       u16 TxSTBC:1;
-       u16 RxSTBC:2;   /* 2 bits */
-       u16 AmsduEnable:1;      /* Enable to transmit A-MSDU. Suggest disable. We should use A-MPDU to gain best benefit of 802.11n */
-       u16 AmsduSize:1;        /* Max receiving A-MSDU size */
-       u16 rsv:5;
-
-       /*Subtract from Addiont HT INFO IE */
-       u8 MaxRAmpduFactor:2;
-       u8 MpduDensity:3;
-       u8 ExtChanOffset:2;     /* Please note the difference with following     u8   NewExtChannelOffset; from 802.11n */
-       u8 RecomWidth:1;
-
-       u16 OperaionMode:2;
-       u16 NonGfPresent:1;
-       u16 rsv3:1;
-       u16 OBSS_NonHTExist:1;
-       u16 rsv2:11;
-
-       /* New Extension Channel Offset IE */
-       u8 NewExtChannelOffset;
-       /* Extension Capability IE = 127 */
-       u8 BSSCoexist2040;
-};
-
-/*   field in Additional HT Information IE . */
-struct PACKED rt_add_htinfo {
-       u8 ExtChanOffset:2;
-       u8 RecomWidth:1;
-       u8 RifsMode:1;
-       u8 S_PSMPSup:1; /*Indicate support for scheduled PSMP */
-       u8 SerInterGranu:3;     /*service interval granularity */
-};
-
-struct PACKED rt_add_htinfo2 {
-       u16 OperaionMode:2;
-       u16 NonGfPresent:1;
-       u16 rsv:1;
-       u16 OBSS_NonHTExist:1;
-       u16 rsv2:11;
-};
-
-/* TODO: Need sync with spec about the definition of StbcMcs. In Draft 3.03, it's reserved. */
-struct PACKED rt_add_htinfo3 {
-       u16 StbcMcs:6;
-       u16 DualBeacon:1;
-       u16 DualCTSProtect:1;
-       u16 STBCBeacon:1;
-       u16 LsigTxopProt:1;     /* L-SIG TXOP protection full support */
-       u16 PcoActive:1;
-       u16 PcoPhase:1;
-       u16 rsv:4;
-};
-
-#define SIZE_ADD_HT_INFO_IE            22
-struct PACKED rt_add_ht_info_ie {
-       u8 ControlChan;
-       struct rt_add_htinfo AddHtInfo;
-       struct rt_add_htinfo2 AddHtInfo2;
-       struct rt_add_htinfo3 AddHtInfo3;
-       u8 MCSSet[16];  /* Basic MCS set */
-};
-
-struct PACKED rt_new_ext_chan_ie {
-       u8 NewExtChanOffset;
-};
-
-struct PACKED rt_frame_802_11 {
-       struct rt_header_802_11 Hdr;
-       u8 Octet[1];
-};
-
-/* QoSNull embedding of management action. When HT Control MA field set to 1. */
-struct PACKED rt_ma_body {
-       u8 Category;
-       u8 Action;
-       u8 Octet[1];
-};
-
-struct PACKED rt_header_802_3 {
-       u8 DAAddr1[MAC_ADDR_LEN];
-       u8 SAAddr2[MAC_ADDR_LEN];
-       u8 Octet[2];
-};
-/*//Block ACK related format */
-/* 2-byte BA Parameter  field  in       DELBA frames to terminate an already set up bA */
-struct PACKED rt_delba_parm {
-       u16 Rsv:11;             /* always set to 0 */
-       u16 Initiator:1;        /* 1: originator    0:recipient */
-       u16 TID:4;              /* value of TC os TS */
-};
-
-/* 2-byte BA Parameter Set field  in ADDBA frames to signal parm for setting up a BA */
-struct PACKED rt_ba_parm {
-       u16 AMSDUSupported:1;   /* 0: not permitted             1: permitted */
-       u16 BAPolicy:1; /* 1: immediately BA    0:delayed BA */
-       u16 TID:4;              /* value of TC os TS */
-       u16 BufSize:10; /* number of buffer of size 2304 octetsr */
-};
-
-/* 2-byte BA Starting Seq CONTROL field */
-typedef union PACKED _BASEQ_CONTROL {
-       struct PACKED {
-               u16 FragNum:4;  /* always set to 0 */
-               u16 StartSeq:12;        /* sequence number of the 1st MSDU for which this BAR is sent */
-       } field;
-       u16 word;
-} BASEQ_CONTROL, *PBASEQ_CONTROL;
-
-/*BAControl and BARControl are the same */
-/* 2-byte BA CONTROL field in BA frame */
-struct PACKED rt_ba_control {
-       u16 ACKPolicy:1;        /* only related to N-Delayed BA. But not support in RT2860b. 0:NormalACK  1:No ACK */
-       u16 MTID:1;             /*EWC V1.24 */
-       u16 Compressed:1;
-       u16 Rsv:9;
-       u16 TID:4;
-};
-
-/* 2-byte BAR CONTROL field in BAR frame */
-struct PACKED rt_bar_control {
-       u16 ACKPolicy:1;        /* 0:normal ack,  1:no ack. */
-       u16 MTID:1;             /*if this bit1, use  struct rt_frame_mtba_req,  if 0, use struct rt_frame_ba_req */
-       u16 Compressed:1;
-       u16 Rsv1:9;
-       u16 TID:4;
-};
-
-/* BARControl in MTBAR frame */
-struct PACKED rt_mtbar_control {
-       u16 ACKPolicy:1;
-       u16 MTID:1;
-       u16 Compressed:1;
-       u16 Rsv1:9;
-       u16 NumTID:4;
-};
-
-struct PACKED rt_per_tid_info {
-       u16 Rsv1:12;
-       u16 TID:4;
-};
-
-struct rt_each_tid {
-       struct rt_per_tid_info PerTID;
-       BASEQ_CONTROL BAStartingSeq;
-};
-
-/* BAREQ AND MTBAREQ have the same subtype BAR, 802.11n BAR use compressed bitmap. */
-struct PACKED rt_frame_ba_req {
-       struct rt_frame_control FC;
-       u16 Duration;
-       u8 Addr1[MAC_ADDR_LEN];
-       u8 Addr2[MAC_ADDR_LEN];
-       struct rt_bar_control BARControl;
-       BASEQ_CONTROL BAStartingSeq;
-};
-
-struct PACKED rt_frame_mtba_req {
-       struct rt_frame_control FC;
-       u16 Duration;
-       u8 Addr1[MAC_ADDR_LEN];
-       u8 Addr2[MAC_ADDR_LEN];
-       struct rt_mtbar_control MTBARControl;
-       struct rt_per_tid_info PerTIDInfo;
-       BASEQ_CONTROL BAStartingSeq;
-};
-
-/* Compressed format is mandatory in HT STA */
-struct PACKED rt_frame_mtba {
-       struct rt_frame_control FC;
-       u16 Duration;
-       u8 Addr1[MAC_ADDR_LEN];
-       u8 Addr2[MAC_ADDR_LEN];
-       struct rt_ba_control BAControl;
-       BASEQ_CONTROL BAStartingSeq;
-       u8 BitMap[8];
-};
-
-struct PACKED rt_frame_psmp_action {
-       struct rt_header_802_11 Hdr;
-       u8 Category;
-       u8 Action;
-       u8 Psmp;                /* 7.3.1.25 */
-};
-
-struct PACKED rt_frame_action_hdr {
-       struct rt_header_802_11 Hdr;
-       u8 Category;
-       u8 Action;
-};
-
-/*Action Frame */
-/*Action Frame  Category:Spectrum,  Action:Channel Switch. 7.3.2.20 */
-struct PACKED rt_chan_switch_announce {
-       u8 ElementID;   /* ID = IE_CHANNEL_SWITCH_ANNOUNCEMENT = 37 */
-       u8 Len;
-       struct rt_cha_switch_announce_ie CSAnnounceIe;
-};
-
-/*802.11n : 7.3.2.20a */
-struct PACKED rt_second_chan_offset {
-       u8 ElementID;   /* ID = IE_SECONDARY_CH_OFFSET = 62 */
-       u8 Len;
-       struct rt_sec_cha_offset_ie SecChOffsetIe;
-};
-
-struct PACKED rt_frame_spetrum_cs {
-       struct rt_header_802_11 Hdr;
-       u8 Category;
-       u8 Action;
-       struct rt_chan_switch_announce CSAnnounce;
-       struct rt_second_chan_offset SecondChannel;
-};
-
-struct PACKED rt_frame_addba_req {
-       struct rt_header_802_11 Hdr;
-       u8 Category;
-       u8 Action;
-       u8 Token;               /* 1 */
-       struct rt_ba_parm BaParm;               /*  2 - 10 */
-       u16 TimeOutValue;       /* 0 - 0 */
-       BASEQ_CONTROL BaStartSeq;       /* 0-0 */
-};
-
-struct PACKED rt_frame_addba_rsp {
-       struct rt_header_802_11 Hdr;
-       u8 Category;
-       u8 Action;
-       u8 Token;
-       u16 StatusCode;
-       struct rt_ba_parm BaParm;               /*0 - 2 */
-       u16 TimeOutValue;
-};
-
-struct PACKED rt_frame_delba_req {
-       struct rt_header_802_11 Hdr;
-       u8 Category;
-       u8 Action;
-       struct rt_delba_parm DelbaParm;
-       u16 ReasonCode;
-};
-
-/*7.2.1.7 */
-struct PACKED rt_frame_bar {
-       struct rt_frame_control FC;
-       u16 Duration;
-       u8 Addr1[MAC_ADDR_LEN];
-       u8 Addr2[MAC_ADDR_LEN];
-       struct rt_bar_control BarControl;
-       BASEQ_CONTROL StartingSeq;
-};
-
-/*7.2.1.7 */
-struct PACKED rt_frame_ba {
-       struct rt_frame_control FC;
-       u16 Duration;
-       u8 Addr1[MAC_ADDR_LEN];
-       u8 Addr2[MAC_ADDR_LEN];
-       struct rt_bar_control BarControl;
-       BASEQ_CONTROL StartingSeq;
-       u8 bitmask[8];
-};
-
-/* Radio Measurement Request Frame Format */
-struct PACKED rt_frame_rm_req_action {
-       struct rt_header_802_11 Hdr;
-       u8 Category;
-       u8 Action;
-       u8 Token;
-       u16 Repetition;
-       u8 data[0];
-};
-
-struct PACKED rt_ht_ext_channel_switch_announcement_ie {
-       u8 ID;
-       u8 Length;
-       u8 ChannelSwitchMode;
-       u8 NewRegClass;
-       u8 NewChannelNum;
-       u8 ChannelSwitchCount;
-};
-
-/* */
-/* _Limit must be the 2**n - 1 */
-/* _SEQ1 , _SEQ2 must be within 0 ~ _Limit */
-/* */
-#define SEQ_STEPONE(_SEQ1, _SEQ2, _Limit)      ((_SEQ1 == ((_SEQ2+1) & _Limit)))
-#define SEQ_SMALLER(_SEQ1, _SEQ2, _Limit)      (((_SEQ1-_SEQ2) & ((_Limit+1)>>1)))
-#define SEQ_LARGER(_SEQ1, _SEQ2, _Limit)       ((_SEQ1 != _SEQ2) && !(((_SEQ1-_SEQ2) & ((_Limit+1)>>1))))
-#define SEQ_WITHIN_WIN(_SEQ1, _SEQ2, _WIN, _Limit) (SEQ_LARGER(_SEQ1, _SEQ2, _Limit) &&  \
-                                                                                               SEQ_SMALLER(_SEQ1, ((_SEQ2+_WIN+1)&_Limit), _Limit))
-
-/* */
-/* Contention-free parameter (without ID and Length) */
-/* */
-struct PACKED rt_cf_parm {
-       BOOLEAN bValid;         /* 1: variable contains valid value */
-       u8 CfpCount;
-       u8 CfpPeriod;
-       u16 CfpMaxDuration;
-       u16 CfpDurRemaining;
-};
-
-struct rt_cipher_suite {
-       NDIS_802_11_ENCRYPTION_STATUS PairCipher;       /* Unicast cipher 1, this one has more secured cipher suite */
-       NDIS_802_11_ENCRYPTION_STATUS PairCipherAux;    /* Unicast cipher 2 if AP announce two unicast cipher suite */
-       NDIS_802_11_ENCRYPTION_STATUS GroupCipher;      /* Group cipher */
-       u16 RsnCapability;      /* RSN capability from beacon */
-       BOOLEAN bMixMode;       /* Indicate Pair & Group cipher might be different */
-};
-
-/* EDCA configuration from AP's BEACON/ProbeRsp */
-struct rt_edca_parm {
-       BOOLEAN bValid;         /* 1: variable contains valid value */
-       BOOLEAN bAdd;           /* 1: variable contains valid value */
-       BOOLEAN bQAck;
-       BOOLEAN bQueueRequest;
-       BOOLEAN bTxopRequest;
-       BOOLEAN bAPSDCapable;
-/*  BOOLEAN     bMoreDataAck; */
-       u8 EdcaUpdateCount;
-       u8 Aifsn[4];            /* 0:AC_BK, 1:AC_BE, 2:AC_VI, 3:AC_VO */
-       u8 Cwmin[4];
-       u8 Cwmax[4];
-       u16 Txop[4];            /* in unit of 32-us */
-       BOOLEAN bACM[4];        /* 1: Admission Control of AC_BK is mandatory */
-};
-
-/* QBSS LOAD information from QAP's BEACON/ProbeRsp */
-struct rt_qbss_load_parm {
-       BOOLEAN bValid;         /* 1: variable contains valid value */
-       u16 StaNum;
-       u8 ChannelUtilization;
-       u16 RemainingAdmissionControl;  /* in unit of 32-us */
-};
-
-/* QBSS Info field in QSTA's assoc req */
-struct PACKED rt_qbss_sta_info_parm {
-       u8 UAPSD_AC_VO:1;
-       u8 UAPSD_AC_VI:1;
-       u8 UAPSD_AC_BK:1;
-       u8 UAPSD_AC_BE:1;
-       u8 Rsv1:1;
-       u8 MaxSPLength:2;
-       u8 Rsv2:1;
-};
-
-/* QBSS Info field in QAP's Beacon/ProbeRsp */
-struct PACKED rt_qbss_ap_info_parm {
-       u8 ParamSetCount:4;
-       u8 Rsv:3;
-       u8 UAPSD:1;
-};
-
-/* QOS Capability reported in QAP's BEACON/ProbeRsp */
-/* QOS Capability sent out in QSTA's AssociateReq/ReAssociateReq */
-struct rt_qos_capability_parm {
-       BOOLEAN bValid;         /* 1: variable contains valid value */
-       BOOLEAN bQAck;
-       BOOLEAN bQueueRequest;
-       BOOLEAN bTxopRequest;
-/*  BOOLEAN     bMoreDataAck; */
-       u8 EdcaUpdateCount;
-};
-
-struct rt_wpa_ie {
-       u8 IELen;
-       u8 IE[MAX_CUSTOM_LEN];
-};
-
-struct rt_bss_entry {
-       u8 Bssid[MAC_ADDR_LEN];
-       u8 Channel;
-       u8 CentralChannel;      /*Store the wide-band central channel for 40MHz. used in 40MHz AP. Or this is the same as Channel. */
-       u8 BssType;
-       u16 AtimWin;
-       u16 BeaconPeriod;
-
-       u8 SupRate[MAX_LEN_OF_SUPPORTED_RATES];
-       u8 SupRateLen;
-       u8 ExtRate[MAX_LEN_OF_SUPPORTED_RATES];
-       u8 ExtRateLen;
-       struct rt_ht_capability_ie HtCapability;
-       u8 HtCapabilityLen;
-       struct rt_add_ht_info_ie AddHtInfo;     /* AP might use this additional ht info IE */
-       u8 AddHtInfoLen;
-       u8 NewExtChanOffset;
-       char Rssi;
-       u8 Privacy;             /* Indicate security function ON/OFF. Don't mess up with auth mode. */
-       u8 Hidden;
-
-       u16 DtimPeriod;
-       u16 CapabilityInfo;
-
-       u16 CfpCount;
-       u16 CfpPeriod;
-       u16 CfpMaxDuration;
-       u16 CfpDurRemaining;
-       u8 SsidLen;
-       char Ssid[MAX_LEN_OF_SSID];
-
-       unsigned long LastBeaconRxTime; /* OS's timestamp */
-
-       BOOLEAN bSES;
-
-       /* New for WPA2 */
-       struct rt_cipher_suite WPA;     /* AP announced WPA cipher suite */
-       struct rt_cipher_suite WPA2;    /* AP announced WPA2 cipher suite */
-
-       /* New for microsoft WPA support */
-       struct rt_ndis_802_11_fixed_ies FixIEs;
-       NDIS_802_11_AUTHENTICATION_MODE AuthModeAux;    /* Addition mode for WPA2 / WPA capable AP */
-       NDIS_802_11_AUTHENTICATION_MODE AuthMode;
-       NDIS_802_11_WEP_STATUS WepStatus;       /* Unicast Encryption Algorithm extract from VAR_IE */
-       u16 VarIELen;   /* Length of next VIE include EID & Length */
-       u8 VarIEs[MAX_VIE_LEN];
-
-       /* CCX Ckip information */
-       u8 CkipFlag;
-
-       /* CCX 2 TSF */
-       u8 PTSF[4];             /* Parent TSF */
-       u8 TTSF[8];             /* Target TSF */
-
-       /* 802.11e d9, and WMM */
-       struct rt_edca_parm EdcaParm;
-       struct rt_qos_capability_parm QosCapability;
-       struct rt_qbss_load_parm QbssLoad;
-       struct rt_wpa_ie WpaIE;
-       struct rt_wpa_ie RsnIE;
-};
-
-struct rt_bss_table {
-       u8 BssNr;
-       u8 BssOverlapNr;
-       struct rt_bss_entry BssEntry[MAX_LEN_OF_BSS_TABLE];
-};
-
-struct rt_mlme_queue_elem {
-       unsigned long Machine;
-       unsigned long MsgType;
-       unsigned long MsgLen;
-       u8 Msg[MGMT_DMA_BUFFER_SIZE];
-       LARGE_INTEGER TimeStamp;
-       u8 Rssi0;
-       u8 Rssi1;
-       u8 Rssi2;
-       u8 Signal;
-       u8 Channel;
-       u8 Wcid;
-       BOOLEAN Occupied;
-};
-
-struct rt_mlme_queue {
-       unsigned long Num;
-       unsigned long Head;
-       unsigned long Tail;
-       spinlock_t Lock;
-       struct rt_mlme_queue_elem Entry[MAX_LEN_OF_MLME_QUEUE];
-};
-
-typedef void(*STATE_MACHINE_FUNC) (void *Adaptor, struct rt_mlme_queue_elem *Elem);
-
-struct rt_state_machine {
-       unsigned long Base;
-       unsigned long NrState;
-       unsigned long NrMsg;
-       unsigned long CurrState;
-       STATE_MACHINE_FUNC *TransFunc;
-};
-
-/* MLME AUX data structure that holds temporarliy settings during a connection attempt. */
-/* Once this attempt succeeds, all settings will be copy to pAd->StaActive. */
-/* A connection attempt (user set OID, roaming, CCX fast roaming,..) consists of */
-/* several steps (JOIN, AUTH, ASSOC or REASSOC) and may fail at any step. We purposely */
-/* separate this under-trial settings away from pAd->StaActive so that once */
-/* this new attempt failed, driver can auto-recover back to the active settings. */
-struct rt_mlme_aux {
-       u8 BssType;
-       u8 Ssid[MAX_LEN_OF_SSID];
-       u8 SsidLen;
-       u8 Bssid[MAC_ADDR_LEN];
-       u8 AutoReconnectSsid[MAX_LEN_OF_SSID];
-       u8 AutoReconnectSsidLen;
-       u16 Alg;
-       u8 ScanType;
-       u8 Channel;
-       u8 CentralChannel;
-       u16 Aid;
-       u16 CapabilityInfo;
-       u16 BeaconPeriod;
-       u16 CfpMaxDuration;
-       u16 CfpPeriod;
-       u16 AtimWin;
-
-       /* Copy supported rate from desired AP's beacon. We are trying to match */
-       /* AP's supported and extended rate settings. */
-       u8 SupRate[MAX_LEN_OF_SUPPORTED_RATES];
-       u8 ExtRate[MAX_LEN_OF_SUPPORTED_RATES];
-       u8 SupRateLen;
-       u8 ExtRateLen;
-       struct rt_ht_capability_ie HtCapability;
-       u8 HtCapabilityLen;
-       struct rt_add_ht_info_ie AddHtInfo;     /* AP might use this additional ht info IE */
-       u8 NewExtChannelOffset;
-       /*struct rt_ht_capability      SupportedHtPhy; */
-
-       /* new for QOS */
-       struct rt_qos_capability_parm APQosCapability;  /* QOS capability of the current associated AP */
-       struct rt_edca_parm APEdcaParm; /* EDCA parameters of the current associated AP */
-       struct rt_qbss_load_parm APQbssLoad;    /* QBSS load of the current associated AP */
-
-       /* new to keep Ralink specific feature */
-       unsigned long APRalinkIe;
-
-       struct rt_bss_table SsidBssTab; /* AP list for the same SSID */
-       struct rt_bss_table RoamTab;    /* AP list eligible for roaming */
-       unsigned long BssIdx;
-       unsigned long RoamIdx;
-
-       BOOLEAN CurrReqIsFromNdis;
-
-       struct rt_ralink_timer BeaconTimer, ScanTimer;
-       struct rt_ralink_timer AuthTimer;
-       struct rt_ralink_timer AssocTimer, ReassocTimer, DisassocTimer;
-};
-
-struct rt_mlme_addba_req {
-       u8 Wcid;                /* */
-       u8 pAddr[MAC_ADDR_LEN];
-       u8 BaBufSize;
-       u16 TimeOutValue;
-       u8 TID;
-       u8 Token;
-       u16 BaStartSeq;
-};
-
-struct rt_mlme_delba_req {
-       u8 Wcid;                /* */
-       u8 Addr[MAC_ADDR_LEN];
-       u8 TID;
-       u8 Initiator;
-};
-
-/* assoc struct is equal to reassoc */
-struct rt_mlme_assoc_req {
-       u8 Addr[MAC_ADDR_LEN];
-       u16 CapabilityInfo;
-       u16 ListenIntv;
-       unsigned long Timeout;
-};
-
-struct rt_mlme_disassoc_req {
-       u8 Addr[MAC_ADDR_LEN];
-       u16 Reason;
-};
-
-struct rt_mlme_auth_req {
-       u8 Addr[MAC_ADDR_LEN];
-       u16 Alg;
-       unsigned long Timeout;
-};
-
-struct rt_mlme_deauth_req {
-       u8 Addr[MAC_ADDR_LEN];
-       u16 Reason;
-};
-
-struct rt_mlme_join_req {
-       unsigned long BssIdx;
-};
-
-struct rt_mlme_scan_req {
-       u8 Bssid[MAC_ADDR_LEN];
-       u8 BssType;
-       u8 ScanType;
-       u8 SsidLen;
-       char Ssid[MAX_LEN_OF_SSID];
-};
-
-struct rt_mlme_start_req {
-       char Ssid[MAX_LEN_OF_SSID];
-       u8 SsidLen;
-};
-
-struct PACKED rt_eid {
-       u8 Eid;
-       u8 Len;
-       u8 Octet[1];
-};
-
-struct PACKED rt_rtmp_tx_rate_switch {
-       u8 ItemNo;
-       u8 STBC:1;
-       u8 ShortGI:1;
-       u8 BW:1;
-       u8 Rsv1:1;
-       u8 Mode:2;
-       u8 Rsv2:2;
-       u8 CurrMCS;
-       u8 TrainUp;
-       u8 TrainDown;
-};
-
-/* ========================== AP mlme.h =============================== */
-#define TBTT_PRELOAD_TIME       384    /* usec. LomgPreamble + 24-byte at 1Mbps */
-#define DEFAULT_DTIM_PERIOD     1
-
-#define MAC_TABLE_AGEOUT_TIME                  300     /* unit: sec */
-#define MAC_TABLE_ASSOC_TIMEOUT                        5       /* unit: sec */
-#define MAC_TABLE_FULL(Tab)                            ((Tab).size == MAX_LEN_OF_MAC_TABLE)
-
-/* AP shall drop the sta if continue Tx fail count reach it. */
-#define MAC_ENTRY_LIFE_CHECK_CNT               20      /* packet cnt. */
-
-/* Value domain of pMacEntry->Sst */
-typedef enum _Sst {
-       SST_NOT_AUTH,           /* 0: equivalent to IEEE 802.11/1999 state 1 */
-       SST_AUTH,               /* 1: equivalent to IEEE 802.11/1999 state 2 */
-       SST_ASSOC               /* 2: equivalent to IEEE 802.11/1999 state 3 */
-} SST;
-
-/* value domain of pMacEntry->AuthState */
-typedef enum _AuthState {
-       AS_NOT_AUTH,
-       AS_AUTH_OPEN,           /* STA has been authenticated using OPEN SYSTEM */
-       AS_AUTH_KEY,            /* STA has been authenticated using SHARED KEY */
-       AS_AUTHENTICATING       /* STA is waiting for AUTH seq#3 using SHARED KEY */
-} AUTH_STATE;
-
-/*for-wpa value domain of pMacEntry->WpaState  802.1i D3   p.114 */
-typedef enum _ApWpaState {
-       AS_NOTUSE,              /* 0 */
-       AS_DISCONNECT,          /* 1 */
-       AS_DISCONNECTED,        /* 2 */
-       AS_INITIALIZE,          /* 3 */
-       AS_AUTHENTICATION,      /* 4 */
-       AS_AUTHENTICATION2,     /* 5 */
-       AS_INITPMK,             /* 6 */
-       AS_INITPSK,             /* 7 */
-       AS_PTKSTART,            /* 8 */
-       AS_PTKINIT_NEGOTIATING, /* 9 */
-       AS_PTKINITDONE,         /* 10 */
-       AS_UPDATEKEYS,          /* 11 */
-       AS_INTEGRITY_FAILURE,   /* 12 */
-       AS_KEYUPDATE,           /* 13 */
-} AP_WPA_STATE;
-
-/* for-wpa value domain of pMacEntry->WpaState  802.1i D3   p.114 */
-typedef enum _GTKState {
-       REKEY_NEGOTIATING,
-       REKEY_ESTABLISHED,
-       KEYERROR,
-} GTK_STATE;
-
-/*  for-wpa  value domain of pMacEntry->WpaState  802.1i D3   p.114 */
-typedef enum _WpaGTKState {
-       SETKEYS,
-       SETKEYS_DONE,
-} WPA_GTK_STATE;
-/* ====================== end of AP mlme.h ============================ */
-
-#endif /* MLME_H__ */
diff --git a/drivers/staging/rt2860/oid.h b/drivers/staging/rt2860/oid.h
deleted file mode 100644 (file)
index 5a25f0d..0000000
+++ /dev/null
@@ -1,779 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-       Module Name:
-       oid.h
-
-       Abstract:
-
-       Revision History:
-       Who                     When                    What
-       --------        ----------              ----------------------------------------------
-       Name                    Date                    Modification logs
-       Justin P. Mattock       11/07/2010      Fix typos in comments
-*/
-#ifndef _OID_H_
-#define _OID_H_
-
-/*#include <linux/wireless.h> */
-
-#ifndef TRUE
-#define TRUE                           1
-#endif
-#ifndef FALSE
-#define FALSE                          0
-#endif
-/* */
-/* IEEE 802.11 Structures and definitions */
-/* */
-#define MAX_TX_POWER_LEVEL              100    /* mW */
-#define MAX_RSSI_TRIGGER                -10    /* dBm */
-#define MIN_RSSI_TRIGGER                -200   /* dBm */
-#define MAX_FRAG_THRESHOLD              2346   /* byte count */
-#define MIN_FRAG_THRESHOLD              256    /* byte count */
-#define MAX_RTS_THRESHOLD               2347   /* byte count */
-
-/* new types for Media Specific Indications */
-/* Extension channel offset */
-#define EXTCHA_NONE                    0
-#define EXTCHA_ABOVE           0x1
-#define EXTCHA_BELOW           0x3
-
-/* BW */
-#define BAND_WIDTH_20          0
-#define BAND_WIDTH_40          1
-#define BAND_WIDTH_BOTH                2
-#define BAND_WIDTH_10          3       /* 802.11j has 10MHz. This definition is for internal usage. doesn't fill in the IE or other field. */
-/* SHORTGI */
-#define GAP_INTERVAL_400       1       /* only support in HT mode */
-#define GAP_INTERVAL_800       0
-#define GAP_INTERVAL_BOTH      2
-
-#define NdisMediaStateConnected                        1
-#define NdisMediaStateDisconnected             0
-
-#define NDIS_802_11_LENGTH_SSID         32
-#define NDIS_802_11_LENGTH_RATES        8
-#define NDIS_802_11_LENGTH_RATES_EX     16
-#define MAC_ADDR_LENGTH                 6
-/*#define MAX_NUM_OF_CHS                                        49 // 14 channels @2.4G +  12@UNII + 4 @MMAC + 11 @HiperLAN2 + 7 @Japan + 1 as NULL termination */
-#define MAX_NUM_OF_CHS                         54      /* 14 channels @2.4G +  12@UNII(lower/middle) + 16@HiperLAN2 + 11@UNII(upper) + 0 @Japan + 1 as NULL termination */
-#define MAX_NUMBER_OF_EVENT                            10      /* entry # in EVENT table */
-#define MAX_NUMBER_OF_MAC                              32      /* if MAX_MBSSID_NUM is 8, this value can't be larger than 211 */
-#define MAX_NUMBER_OF_ACL                              64
-#define MAX_LENGTH_OF_SUPPORT_RATES            12      /* 1, 2, 5.5, 11, 6, 9, 12, 18, 24, 36, 48, 54 */
-#define MAX_NUMBER_OF_DLS_ENTRY                        4
-
-#define RT_QUERY_SIGNAL_CONTEXT                                0x0402
-#define RT_SET_IAPP_PID                                0x0404
-#define RT_SET_APD_PID                                         0x0405
-#define RT_SET_DEL_MAC_ENTRY                           0x0406
-#define RT_QUERY_EVENT_TABLE                   0x0407
-/* */
-/* IEEE 802.11 OIDs */
-/* */
-#define        OID_GET_SET_TOGGLE                      0x8000
-#define        OID_GET_SET_FROM_UI                     0x4000
-
-#define OID_802_11_ADD_WEP                     0x0112
-#define OID_802_11_DISASSOCIATE                        0x0114
-#define OID_802_11_BSSID_LIST_SCAN             0x0508
-#define OID_802_11_SSID                                0x0509
-#define OID_802_11_BSSID                       0x050A
-#define OID_802_11_MIC_FAILURE_REPORT_FRAME    0x0528
-
-#define        RT_OID_DEVICE_NAME                                                      0x0607
-#define        RT_OID_VERSION_INFO                                                     0x0608
-#define        OID_802_11_BSSID_LIST                                           0x0609
-#define        OID_802_3_CURRENT_ADDRESS                                       0x060A
-#define        OID_GEN_MEDIA_CONNECT_STATUS                            0x060B
-#define        RT_OID_802_11_QUERY_LINK_STATUS                         0x060C
-#define        OID_802_11_RSSI                                                         0x060D
-#define        OID_802_11_STATISTICS                                           0x060E
-#define        OID_GEN_RCV_OK                                                          0x060F
-#define        OID_GEN_RCV_NO_BUFFER                                           0x0610
-#define        RT_OID_802_11_QUERY_EEPROM_VERSION                      0x0611
-#define        RT_OID_802_11_QUERY_FIRMWARE_VERSION            0x0612
-#define        RT_OID_802_11_QUERY_LAST_RX_RATE                        0x0613
-#define        RT_OID_802_11_TX_POWER_LEVEL_1                          0x0614
-#define        RT_OID_802_11_QUERY_PIDVID                                      0x0615
-/*for WPA_SUPPLICANT_SUPPORT */
-#define OID_SET_COUNTERMEASURES                     0x0616
-#define RT_OID_WPA_SUPPLICANT_SUPPORT               0x0621
-#define RT_OID_WE_VERSION_COMPILED                  0x0622
-#define RT_OID_NEW_DRIVER                           0x0623
-
-#define RT_OID_DRIVER_DEVICE_NAME                   0x0645
-#define RT_OID_QUERY_MULTIPLE_CARD_SUPPORT          0x0647
-
-typedef enum _NDIS_802_11_STATUS_TYPE {
-       Ndis802_11StatusType_Authentication,
-       Ndis802_11StatusType_MediaStreamMode,
-       Ndis802_11StatusType_PMKID_CandidateList,
-       Ndis802_11StatusTypeMax /* not a real type, defined as an upper bound */
-} NDIS_802_11_STATUS_TYPE, *PNDIS_802_11_STATUS_TYPE;
-
-typedef u8 NDIS_802_11_MAC_ADDRESS[6];
-
-struct rt_ndis_802_11_status_indication {
-       NDIS_802_11_STATUS_TYPE StatusType;
-};
-
-/* mask for authentication/integrity fields */
-#define NDIS_802_11_AUTH_REQUEST_AUTH_FIELDS        0x0f
-
-#define NDIS_802_11_AUTH_REQUEST_REAUTH             0x01
-#define NDIS_802_11_AUTH_REQUEST_KEYUPDATE          0x02
-#define NDIS_802_11_AUTH_REQUEST_PAIRWISE_ERROR     0x06
-#define NDIS_802_11_AUTH_REQUEST_GROUP_ERROR        0x0E
-
-struct rt_ndis_802_11_authentication_request {
-       unsigned long Length;           /* Length of structure */
-       NDIS_802_11_MAC_ADDRESS Bssid;
-       unsigned long Flags;
-};
-
-/*Added new types for PMKID Candidate lists. */
-struct rt_pmkid_candidate {
-       NDIS_802_11_MAC_ADDRESS BSSID;
-       unsigned long Flags;
-};
-
-struct rt_ndis_802_11_pmkid_candidate_list {
-       unsigned long Version;          /* Version of the structure */
-       unsigned long NumCandidates;    /* No. of pmkid candidates */
-       struct rt_pmkid_candidate CandidateList[1];
-};
-
-/*Flags for PMKID Candidate list structure */
-#define NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED    0x01
-
-/* Added new types for OFDM 5G and 2.4G */
-typedef enum _NDIS_802_11_NETWORK_TYPE {
-       Ndis802_11FH,
-       Ndis802_11DS,
-       Ndis802_11OFDM5,
-       Ndis802_11OFDM24,
-       Ndis802_11Automode,
-       Ndis802_11OFDM5_N,
-       Ndis802_11OFDM24_N,
-       Ndis802_11NetworkTypeMax        /* not a real type, defined as an upper bound */
-} NDIS_802_11_NETWORK_TYPE, *PNDIS_802_11_NETWORK_TYPE;
-
-struct rt_ndis_802_11_network_type_list {
-       u32 NumberOfItems;      /* in list below, at least 1 */
-       NDIS_802_11_NETWORK_TYPE NetworkType[1];
-};
-
-typedef enum _NDIS_802_11_POWER_MODE {
-       Ndis802_11PowerModeCAM,
-       Ndis802_11PowerModeMAX_PSP,
-       Ndis802_11PowerModeFast_PSP,
-       Ndis802_11PowerModeLegacy_PSP,
-       Ndis802_11PowerModeMax  /* not a real mode, defined as an upper bound */
-} NDIS_802_11_POWER_MODE, *PNDIS_802_11_POWER_MODE;
-
-typedef unsigned long NDIS_802_11_TX_POWER_LEVEL;      /* in milliwatts */
-
-/* */
-/* Received Signal Strength Indication */
-/* */
-typedef long NDIS_802_11_RSSI; /* in dBm */
-
-struct rt_ndis_802_11_configuration_fh {
-       unsigned long Length;           /* Length of structure */
-       unsigned long HopPattern;       /* As defined by 802.11, MSB set */
-       unsigned long HopSet;           /* to one if non-802.11 */
-       unsigned long DwellTime;        /* units are Kusec */
-};
-
-struct rt_ndis_802_11_configuration {
-       unsigned long Length;           /* Length of structure */
-       unsigned long BeaconPeriod;     /* units are Kusec */
-       unsigned long ATIMWindow;       /* units are Kusec */
-       unsigned long DSConfig;         /* Frequency, units are kHz */
-       struct rt_ndis_802_11_configuration_fh FHConfig;
-};
-
-struct rt_ndis_802_11_statistics {
-       unsigned long Length;           /* Length of structure */
-       LARGE_INTEGER TransmittedFragmentCount;
-       LARGE_INTEGER MulticastTransmittedFrameCount;
-       LARGE_INTEGER FailedCount;
-       LARGE_INTEGER RetryCount;
-       LARGE_INTEGER MultipleRetryCount;
-       LARGE_INTEGER RTSSuccessCount;
-       LARGE_INTEGER RTSFailureCount;
-       LARGE_INTEGER ACKFailureCount;
-       LARGE_INTEGER FrameDuplicateCount;
-       LARGE_INTEGER ReceivedFragmentCount;
-       LARGE_INTEGER MulticastReceivedFrameCount;
-       LARGE_INTEGER FCSErrorCount;
-       LARGE_INTEGER TKIPLocalMICFailures;
-       LARGE_INTEGER TKIPRemoteMICErrors;
-       LARGE_INTEGER TKIPICVErrors;
-       LARGE_INTEGER TKIPCounterMeasuresInvoked;
-       LARGE_INTEGER TKIPReplays;
-       LARGE_INTEGER CCMPFormatErrors;
-       LARGE_INTEGER CCMPReplays;
-       LARGE_INTEGER CCMPDecryptErrors;
-       LARGE_INTEGER FourWayHandshakeFailures;
-};
-
-typedef unsigned long NDIS_802_11_KEY_INDEX;
-typedef unsigned long long NDIS_802_11_KEY_RSC;
-
-#define MAX_RADIUS_SRV_NUM                     2       /* 802.1x failover number */
-
-struct PACKED rt_radius_srv_info {
-       u32 radius_ip;
-       u32 radius_port;
-       u8 radius_key[64];
-       u8 radius_key_len;
-};
-
-struct PACKED rt_radius_key_info {
-       u8 radius_srv_num;
-       struct rt_radius_srv_info radius_srv_info[MAX_RADIUS_SRV_NUM];
-       u8 ieee8021xWEP;        /* dynamic WEP */
-       u8 key_index;
-       u8 key_length;  /* length of key in bytes */
-       u8 key_material[13];
-};
-
-/* It's used by 802.1x daemon to require relative configuration */
-struct PACKED rt_radius_conf {
-       u32 Length;             /* Length of this structure */
-       u8 mbss_num;            /* indicate multiple BSS number */
-       u32 own_ip_addr;
-       u32 retry_interval;
-       u32 session_timeout_interval;
-       u8 EAPifname[8][IFNAMSIZ];
-       u8 EAPifname_len[8];
-       u8 PreAuthifname[8][IFNAMSIZ];
-       u8 PreAuthifname_len[8];
-       struct rt_radius_key_info RadiusInfo[8];
-};
-
-/* Key mapping keys require a BSSID */
-struct rt_ndis_802_11_key {
-       u32 Length;             /* Length of this structure */
-       u32 KeyIndex;
-       u32 KeyLength;          /* length of key in bytes */
-       NDIS_802_11_MAC_ADDRESS BSSID;
-       NDIS_802_11_KEY_RSC KeyRSC;
-       u8 KeyMaterial[1];      /* variable length depending on above field */
-};
-
-struct rt_ndis_802_11_passphrase {
-       u32 KeyLength;          /* length of key in bytes */
-       NDIS_802_11_MAC_ADDRESS BSSID;
-       u8 KeyMaterial[1];      /* variable length depending on above field */
-};
-
-struct rt_ndis_802_11_remove_key {
-       u32 Length;             /* Length of this structure */
-       u32 KeyIndex;
-       NDIS_802_11_MAC_ADDRESS BSSID;
-};
-
-struct rt_ndis_802_11_wep {
-       u32 Length;             /* Length of this structure */
-       u32 KeyIndex;           /* 0 is the per-client key, 1-N are the */
-       /* global keys */
-       u32 KeyLength;          /* length of key in bytes */
-       u8 KeyMaterial[1];      /* variable length depending on above field */
-};
-
-typedef enum _NDIS_802_11_NETWORK_INFRASTRUCTURE {
-       Ndis802_11IBSS,
-       Ndis802_11Infrastructure,
-       Ndis802_11AutoUnknown,
-       Ndis802_11Monitor,
-       Ndis802_11InfrastructureMax     /* Not a real value, defined as upper bound */
-} NDIS_802_11_NETWORK_INFRASTRUCTURE, *PNDIS_802_11_NETWORK_INFRASTRUCTURE;
-
-/* Add new authentication modes */
-typedef enum _NDIS_802_11_AUTHENTICATION_MODE {
-       Ndis802_11AuthModeOpen,
-       Ndis802_11AuthModeShared,
-       Ndis802_11AuthModeAutoSwitch,
-       Ndis802_11AuthModeWPA,
-       Ndis802_11AuthModeWPAPSK,
-       Ndis802_11AuthModeWPANone,
-       Ndis802_11AuthModeWPA2,
-       Ndis802_11AuthModeWPA2PSK,
-       Ndis802_11AuthModeWPA1WPA2,
-       Ndis802_11AuthModeWPA1PSKWPA2PSK,
-       Ndis802_11AuthModeMax   /* Not a real mode, defined as upper bound */
-} NDIS_802_11_AUTHENTICATION_MODE, *PNDIS_802_11_AUTHENTICATION_MODE;
-
-typedef u8 NDIS_802_11_RATES[NDIS_802_11_LENGTH_RATES];        /* Set of 8 data rates */
-typedef u8 NDIS_802_11_RATES_EX[NDIS_802_11_LENGTH_RATES_EX];  /* Set of 16 data rates */
-
-struct PACKED rt_ndis_802_11_ssid {
-       u32 SsidLength; /* length of SSID field below, in bytes; */
-       /* this can be zero. */
-       u8 Ssid[NDIS_802_11_LENGTH_SSID];       /* SSID information field */
-};
-
-struct PACKED rt_ndis_wlan_bssid {
-       unsigned long Length;           /* Length of this structure */
-       NDIS_802_11_MAC_ADDRESS MacAddress;     /* BSSID */
-       u8 Reserved[2];
-       struct rt_ndis_802_11_ssid Ssid;        /* SSID */
-       unsigned long Privacy;          /* WEP encryption requirement */
-       NDIS_802_11_RSSI Rssi;  /* receive signal strength in dBm */
-       NDIS_802_11_NETWORK_TYPE NetworkTypeInUse;
-       struct rt_ndis_802_11_configuration Configuration;
-       NDIS_802_11_NETWORK_INFRASTRUCTURE InfrastructureMode;
-       NDIS_802_11_RATES SupportedRates;
-};
-
-struct PACKED rt_ndis_802_11_bssid_list {
-       u32 NumberOfItems;      /* in list below, at least 1 */
-       struct rt_ndis_wlan_bssid Bssid[1];
-};
-
-/* Added Capabilities, IELength and IEs for each BSSID */
-struct PACKED rt_ndis_wlan_bssid_ex {
-       unsigned long Length;           /* Length of this structure */
-       NDIS_802_11_MAC_ADDRESS MacAddress;     /* BSSID */
-       u8 Reserved[2];
-       struct rt_ndis_802_11_ssid Ssid;        /* SSID */
-       u32 Privacy;            /* WEP encryption requirement */
-       NDIS_802_11_RSSI Rssi;  /* receive signal */
-       /* strength in dBm */
-       NDIS_802_11_NETWORK_TYPE NetworkTypeInUse;
-       struct rt_ndis_802_11_configuration Configuration;
-       NDIS_802_11_NETWORK_INFRASTRUCTURE InfrastructureMode;
-       NDIS_802_11_RATES_EX SupportedRates;
-       unsigned long IELength;
-       u8 IEs[1];
-};
-
-struct PACKED rt_ndis_802_11_bssid_list_ex {
-       u32 NumberOfItems;      /* in list below, at least 1 */
-       struct rt_ndis_wlan_bssid_ex Bssid[1];
-};
-
-struct PACKED rt_ndis_802_11_fixed_ies {
-       u8 Timestamp[8];
-       u16 BeaconInterval;
-       u16 Capabilities;
-};
-
-struct rt_ndis_802_11_variable_ies {
-       u8 ElementID;
-       u8 Length;              /* Number of bytes in data field */
-       u8 data[1];
-};
-
-typedef unsigned long NDIS_802_11_FRAGMENTATION_THRESHOLD;
-
-typedef unsigned long NDIS_802_11_RTS_THRESHOLD;
-
-typedef unsigned long NDIS_802_11_ANTENNA;
-
-typedef enum _NDIS_802_11_PRIVACY_FILTER {
-       Ndis802_11PrivFilterAcceptAll,
-       Ndis802_11PrivFilter8021xWEP
-} NDIS_802_11_PRIVACY_FILTER, *PNDIS_802_11_PRIVACY_FILTER;
-
-/* Added new encryption types */
-/* Also aliased typedef to new name */
-typedef enum _NDIS_802_11_WEP_STATUS {
-       Ndis802_11WEPEnabled,
-       Ndis802_11Encryption1Enabled = Ndis802_11WEPEnabled,
-       Ndis802_11WEPDisabled,
-       Ndis802_11EncryptionDisabled = Ndis802_11WEPDisabled,
-       Ndis802_11WEPKeyAbsent,
-       Ndis802_11Encryption1KeyAbsent = Ndis802_11WEPKeyAbsent,
-       Ndis802_11WEPNotSupported,
-       Ndis802_11EncryptionNotSupported = Ndis802_11WEPNotSupported,
-       Ndis802_11Encryption2Enabled,
-       Ndis802_11Encryption2KeyAbsent,
-       Ndis802_11Encryption3Enabled,
-       Ndis802_11Encryption3KeyAbsent,
-       Ndis802_11Encryption4Enabled,   /* TKIP or AES mix */
-       Ndis802_11Encryption4KeyAbsent,
-       Ndis802_11GroupWEP40Enabled,
-       Ndis802_11GroupWEP104Enabled,
-} NDIS_802_11_WEP_STATUS, *PNDIS_802_11_WEP_STATUS,
-    NDIS_802_11_ENCRYPTION_STATUS, *PNDIS_802_11_ENCRYPTION_STATUS;
-
-typedef enum _NDIS_802_11_RELOAD_DEFAULTS {
-       Ndis802_11ReloadWEPKeys
-} NDIS_802_11_RELOAD_DEFAULTS, *PNDIS_802_11_RELOAD_DEFAULTS;
-
-#define NDIS_802_11_AI_REQFI_CAPABILITIES      1
-#define NDIS_802_11_AI_REQFI_LISTENINTERVAL    2
-#define NDIS_802_11_AI_REQFI_CURRENTAPADDRESS  4
-
-#define NDIS_802_11_AI_RESFI_CAPABILITIES      1
-#define NDIS_802_11_AI_RESFI_STATUSCODE        2
-#define NDIS_802_11_AI_RESFI_ASSOCIATIONID     4
-
-struct rt_ndis_802_11_ai_reqfi {
-       u16 Capabilities;
-       u16 ListenInterval;
-       NDIS_802_11_MAC_ADDRESS CurrentAPAddress;
-};
-
-struct rt_ndis_802_11_ai_resfi {
-       u16 Capabilities;
-       u16 StatusCode;
-       u16 AssociationId;
-};
-
-struct rt_ndis_802_11_association_information {
-       unsigned long Length;
-       u16 AvailableRequestFixedIEs;
-       struct rt_ndis_802_11_ai_reqfi RequestFixedIEs;
-       unsigned long RequestIELength;
-       unsigned long OffsetRequestIEs;
-       u16 AvailableResponseFixedIEs;
-       struct rt_ndis_802_11_ai_resfi ResponseFixedIEs;
-       unsigned long ResponseIELength;
-       unsigned long OffsetResponseIEs;
-};
-
-struct rt_ndis_802_11_authentication_event {
-       struct rt_ndis_802_11_status_indication Status;
-       struct rt_ndis_802_11_authentication_request Request[1];
-};
-
-/* 802.11 Media stream constraints, associated with OID_802_11_MEDIA_STREAM_MODE */
-typedef enum _NDIS_802_11_MEDIA_STREAM_MODE {
-       Ndis802_11MediaStreamOff,
-       Ndis802_11MediaStreamOn,
-} NDIS_802_11_MEDIA_STREAM_MODE, *PNDIS_802_11_MEDIA_STREAM_MODE;
-
-/* PMKID Structures */
-typedef u8 NDIS_802_11_PMKID_VALUE[16];
-
-struct rt_bssid_info {
-       NDIS_802_11_MAC_ADDRESS BSSID;
-       NDIS_802_11_PMKID_VALUE PMKID;
-};
-
-struct rt_ndis_802_11_pmkid {
-       u32 Length;
-       u32 BSSIDInfoCount;
-       struct rt_bssid_info BSSIDInfo[1];
-};
-
-struct rt_ndis_802_11_authentication_encryption {
-       NDIS_802_11_AUTHENTICATION_MODE AuthModeSupported;
-       NDIS_802_11_ENCRYPTION_STATUS EncryptStatusSupported;
-};
-
-struct rt_ndis_802_11_capability {
-       unsigned long Length;
-       unsigned long Version;
-       unsigned long NoOfPMKIDs;
-       unsigned long NoOfAuthEncryptPairsSupported;
-       struct rt_ndis_802_11_authentication_encryption
-           AuthenticationEncryptionSupported[1];
-};
-
-#define RT_PRIV_IOCTL                                                  (SIOCIWFIRSTPRIV + 0x01)        /* Sync. with AP for wsc upnp daemon */
-#define RTPRIV_IOCTL_SET                                                       (SIOCIWFIRSTPRIV + 0x02)
-
-#define RTPRIV_IOCTL_STATISTICS                     (SIOCIWFIRSTPRIV + 0x09)
-#define RTPRIV_IOCTL_ADD_PMKID_CACHE                (SIOCIWFIRSTPRIV + 0x0A)
-#define RTPRIV_IOCTL_RADIUS_DATA                    (SIOCIWFIRSTPRIV + 0x0C)
-#define RTPRIV_IOCTL_GSITESURVEY                                       (SIOCIWFIRSTPRIV + 0x0D)
-#define RT_PRIV_IOCTL_EXT                                                      (SIOCIWFIRSTPRIV + 0x0E)        /* Sync. with RT61 (for wpa_supplicant) */
-#define RTPRIV_IOCTL_GET_MAC_TABLE                                     (SIOCIWFIRSTPRIV + 0x0F)
-
-#define RTPRIV_IOCTL_SHOW                                                      (SIOCIWFIRSTPRIV + 0x11)
-enum {
-       SHOW_CONN_STATUS = 4,
-       SHOW_DRVIER_VERION = 5,
-       SHOW_BA_INFO = 6,
-       SHOW_DESC_INFO = 7,
-#ifdef RTMP_MAC_USB
-       SHOW_RXBULK_INFO = 8,
-       SHOW_TXBULK_INFO = 9,
-#endif /* RTMP_MAC_USB // */
-       RAIO_OFF = 10,
-       RAIO_ON = 11,
-       SHOW_CFG_VALUE = 20,
-       SHOW_ADHOC_ENTRY_INFO = 21,
-};
-
-#define OID_802_11_BUILD_CHANNEL_EX                            0x0714
-#define OID_802_11_GET_CH_LIST                                 0x0715
-#define OID_802_11_GET_COUNTRY_CODE                            0x0716
-#define OID_802_11_GET_CHANNEL_GEOGRAPHY               0x0717
-
-#define RT_OID_WSC_SET_PASSPHRASE                   0x0740     /* passphrase for wpa(2)-psk */
-#define RT_OID_WSC_DRIVER_AUTO_CONNECT              0x0741
-#define RT_OID_WSC_QUERY_DEFAULT_PROFILE            0x0742
-#define RT_OID_WSC_SET_CONN_BY_PROFILE_INDEX        0x0743
-#define RT_OID_WSC_SET_ACTION                       0x0744
-#define RT_OID_WSC_SET_SSID                         0x0745
-#define RT_OID_WSC_SET_PIN_CODE                     0x0746
-#define RT_OID_WSC_SET_MODE                         0x0747     /* PIN or PBC */
-#define RT_OID_WSC_SET_CONF_MODE                    0x0748     /* Enrollee or Registrar */
-#define RT_OID_WSC_SET_PROFILE                      0x0749
-#define        RT_OID_WSC_CONFIG_STATUS                                        0x074F
-#define RT_OID_802_11_WSC_QUERY_PROFILE                                0x0750
-/* for consistency with RT61 */
-#define RT_OID_WSC_QUERY_STATUS                                                0x0751
-#define RT_OID_WSC_PIN_CODE                                                    0x0752
-#define RT_OID_WSC_UUID                                                                0x0753
-#define RT_OID_WSC_SET_SELECTED_REGISTRAR                      0x0754
-#define RT_OID_WSC_EAPMSG                                                      0x0755
-#define RT_OID_WSC_MANUFACTURER                                                0x0756
-#define RT_OID_WSC_MODEL_NAME                                          0x0757
-#define RT_OID_WSC_MODEL_NO                                                    0x0758
-#define RT_OID_WSC_SERIAL_NO                                           0x0759
-#define RT_OID_WSC_MAC_ADDRESS                                         0x0760
-
-/* New for MeetingHouse Api support */
-#define OID_MH_802_1X_SUPPORTED               0xFFEDC100
-
-/* MIMO Tx parameter, ShortGI, MCS, STBC, etc.  these are fields in TXWI. Don't change this definition! */
-typedef union _HTTRANSMIT_SETTING {
-       struct {
-               u16 MCS:7;      /* MCS */
-               u16 BW:1;       /*channel bandwidth 20MHz or 40 MHz */
-               u16 ShortGI:1;
-               u16 STBC:2;     /*SPACE */
-/*      u16          rsv:3; */
-               u16 rsv:2;
-               u16 TxBF:1;
-               u16 MODE:2;     /* Use definition MODE_xxx. */
-       } field;
-       u16 word;
-} HTTRANSMIT_SETTING, *PHTTRANSMIT_SETTING;
-
-typedef enum _RT_802_11_PREAMBLE {
-       Rt802_11PreambleLong,
-       Rt802_11PreambleShort,
-       Rt802_11PreambleAuto
-} RT_802_11_PREAMBLE, *PRT_802_11_PREAMBLE;
-
-typedef enum _RT_802_11_PHY_MODE {
-       PHY_11BG_MIXED = 0,
-       PHY_11B,
-       PHY_11A,
-       PHY_11ABG_MIXED,
-       PHY_11G,
-       PHY_11ABGN_MIXED,       /* both band   5 */
-       PHY_11N_2_4G,           /* 11n-only with 2.4G band      6 */
-       PHY_11GN_MIXED,         /* 2.4G band      7 */
-       PHY_11AN_MIXED,         /* 5G  band       8 */
-       PHY_11BGN_MIXED,        /* if check 802.11b.      9 */
-       PHY_11AGN_MIXED,        /* if check 802.11b.      10 */
-       PHY_11N_5G,             /* 11n-only with 5G band                11 */
-} RT_802_11_PHY_MODE;
-
-/* put all proprietery for-query objects here to reduce # of Query_OID */
-struct rt_802_11_link_status {
-       unsigned long CurrTxRate;       /* in units of 0.5Mbps */
-       unsigned long ChannelQuality;   /* 0..100 % */
-       unsigned long TxByteCount;      /* both ok and fail */
-       unsigned long RxByteCount;      /* both ok and fail */
-       unsigned long CentralChannel;   /* 40MHz central channel number */
-};
-
-struct rt_802_11_event_log {
-       LARGE_INTEGER SystemTime;       /* timestammp via NdisGetCurrentSystemTime() */
-       u8 Addr[MAC_ADDR_LENGTH];
-       u16 Event;              /* EVENT_xxx */
-};
-
-struct rt_802_11_event_table {
-       unsigned long Num;
-       unsigned long Rsv;              /* to align Log[] at LARGE_INTEGER boundary */
-       struct rt_802_11_event_log Log[MAX_NUMBER_OF_EVENT];
-};
-
-/* MIMO Tx parameter, ShortGI, MCS, STBC, etc.  these are fields in TXWI. Don't change this definition! */
-typedef union _MACHTTRANSMIT_SETTING {
-       struct {
-               u16 MCS:7;      /* MCS */
-               u16 BW:1;       /*channel bandwidth 20MHz or 40 MHz */
-               u16 ShortGI:1;
-               u16 STBC:2;     /*SPACE */
-               u16 rsv:3;
-               u16 MODE:2;     /* Use definition MODE_xxx. */
-       } field;
-       u16 word;
-} MACHTTRANSMIT_SETTING, *PMACHTTRANSMIT_SETTING;
-
-struct rt_802_11_mac_entry {
-       u8 Addr[MAC_ADDR_LENGTH];
-       u8 Aid;
-       u8 Psm;         /* 0:PWR_ACTIVE, 1:PWR_SAVE */
-       u8 MimoPs;              /* 0:MMPS_STATIC, 1:MMPS_DYNAMIC, 3:MMPS_Enabled */
-       char AvgRssi0;
-       char AvgRssi1;
-       char AvgRssi2;
-       u32 ConnectedTime;
-       MACHTTRANSMIT_SETTING TxRate;
-};
-
-struct rt_802_11_mac_table {
-       unsigned long Num;
-       struct rt_802_11_mac_entry Entry[MAX_NUMBER_OF_MAC];
-};
-
-/* structure for query/set hardware register - MAC, BBP, RF register */
-struct rt_802_11_hardware_register {
-       unsigned long HardwareType;     /* 0:MAC, 1:BBP, 2:RF register, 3:EEPROM */
-       unsigned long Offset;           /* Q/S register offset addr */
-       unsigned long Data;             /* R/W data buffer */
-};
-
-struct rt_802_11_ap_config {
-       unsigned long EnableTxBurst;    /* 0-disable, 1-enable */
-       unsigned long EnableTurboRate;  /* 0-disable, 1-enable 72/100mbps turbo rate */
-       unsigned long IsolateInterStaTraffic;   /* 0-disable, 1-enable isolation */
-       unsigned long HideSsid;         /* 0-disable, 1-enable hiding */
-       unsigned long UseBGProtection;  /* 0-AUTO, 1-always ON, 2-always OFF */
-       unsigned long UseShortSlotTime; /* 0-no use, 1-use 9-us short slot time */
-       unsigned long Rsv1;             /* must be 0 */
-       unsigned long SystemErrorBitmap;        /* ignore upon SET, return system error upon QUERY */
-};
-
-/* structure to query/set STA_CONFIG */
-struct rt_802_11_sta_config {
-       unsigned long EnableTxBurst;    /* 0-disable, 1-enable */
-       unsigned long EnableTurboRate;  /* 0-disable, 1-enable 72/100mbps turbo rate */
-       unsigned long UseBGProtection;  /* 0-AUTO, 1-always ON, 2-always OFF */
-       unsigned long UseShortSlotTime; /* 0-no use, 1-use 9-us short slot time when applicable */
-       unsigned long AdhocMode;        /* 0-11b rates only (WIFI spec), 1 - b/g mixed, 2 - g only */
-       unsigned long HwRadioStatus;    /* 0-OFF, 1-ON, default is 1, Read-Only */
-       unsigned long Rsv1;             /* must be 0 */
-       unsigned long SystemErrorBitmap;        /* ignore upon SET, return system error upon QUERY */
-};
-
-/* */
-/*  For OID Query or Set about BA structure */
-/* */
-struct rt_oid_bacap {
-       u8 RxBAWinLimit;
-       u8 TxBAWinLimit;
-       u8 Policy;              /* 0: DELAY_BA 1:IMMED_BA  (//BA Policy subfiled value in ADDBA frame)   2:BA-not use. other value invalid */
-       u8 MpduDensity; /* 0: DELAY_BA 1:IMMED_BA  (//BA Policy subfiled value in ADDBA frame)   2:BA-not use. other value invalid */
-       u8 AmsduEnable; /*Enable AMSDU transmisstion */
-       u8 AmsduSize;   /* 0:3839, 1:7935 bytes. u32  MSDUSizeToBytes[]        = { 3839, 7935}; */
-       u8 MMPSmode;            /* MIMO power save more, 0:static, 1:dynamic, 2:rsv, 3:mimo enable */
-       BOOLEAN AutoBA;         /* Auto BA will automatically */
-};
-
-struct rt_802_11_acl_entry {
-       u8 Addr[MAC_ADDR_LENGTH];
-       u16 Rsv;
-};
-
-struct PACKED rt_rt_802_11_acl {
-       unsigned long Policy;           /* 0-disable, 1-positive list, 2-negative list */
-       unsigned long Num;
-       struct rt_802_11_acl_entry Entry[MAX_NUMBER_OF_ACL];
-};
-
-struct rt_802_11_wds {
-       unsigned long Num;
-       NDIS_802_11_MAC_ADDRESS Entry[24 /*MAX_NUM_OF_WDS_LINK */];
-       unsigned long KeyLength;
-       u8 KeyMaterial[32];
-};
-
-struct rt_802_11_tx_rates {
-       u8 SupRateLen;
-       u8 SupRate[MAX_LENGTH_OF_SUPPORT_RATES];
-       u8 ExtRateLen;
-       u8 ExtRate[MAX_LENGTH_OF_SUPPORT_RATES];
-};
-
-/* Definition of extra information code */
-#define        GENERAL_LINK_UP                 0x0     /* Link is Up */
-#define        GENERAL_LINK_DOWN               0x1     /* Link is Down */
-#define        HW_RADIO_OFF                    0x2     /* Hardware radio off */
-#define        SW_RADIO_OFF                    0x3     /* Software radio off */
-#define        AUTH_FAIL                               0x4     /* Open authentication fail */
-#define        AUTH_FAIL_KEYS                  0x5     /* Shared authentication fail */
-#define        ASSOC_FAIL                              0x6     /* Association failed */
-#define        EAP_MIC_FAILURE                 0x7     /* Deauthentication because MIC failure */
-#define        EAP_4WAY_TIMEOUT                0x8     /* Deauthentication on 4-way handshake timeout */
-#define        EAP_GROUP_KEY_TIMEOUT   0x9     /* Deauthentication on group key handshake timeout */
-#define        EAP_SUCCESS                             0xa     /* EAP succeed */
-#define        DETECT_RADAR_SIGNAL             0xb     /* Radar signal occur in current channel */
-#define EXTRA_INFO_MAX                 0xb     /* Indicate Last OID */
-
-#define EXTRA_INFO_CLEAR               0xffffffff
-
-/* This is OID setting structure. So only GF or MM as Mode. This is valid when our wirelss mode has 802.11n in use. */
-struct rt_oid_set_ht_phymode {
-       RT_802_11_PHY_MODE PhyMode;     /* */
-       u8 TransmitNo;
-       u8 HtMode;              /*HTMODE_GF or HTMODE_MM */
-       u8 ExtOffset;   /*extension channel above or below */
-       u8 MCS;
-       u8 BW;
-       u8 STBC;
-       u8 SHORTGI;
-       u8 rsv;
-};
-
-#define MAX_CUSTOM_LEN 128
-
-typedef enum _RT_802_11_D_CLIENT_MODE {
-       Rt802_11_D_None,
-       Rt802_11_D_Flexible,
-       Rt802_11_D_Strict,
-} RT_802_11_D_CLIENT_MODE, *PRT_802_11_D_CLIENT_MODE;
-
-struct rt_channel_list_info {
-       u8 ChannelList[MAX_NUM_OF_CHS]; /* list all supported channels for site survey */
-       u8 ChannelListNum;      /* number of channel in ChannelList[] */
-};
-
-/* WSC configured credential */
-struct rt_wsc_credential {
-       struct rt_ndis_802_11_ssid SSID;        /* mandatory */
-       u16 AuthType;   /* mandatory, 1: open, 2: wpa-psk, 4: shared, 8:wpa, 0x10: wpa2, 0x20: wpa2-psk */
-       u16 EncrType;   /* mandatory, 1: none, 2: wep, 4: tkip, 8: aes */
-       u8 Key[64];             /* mandatory, Maximum 64 byte */
-       u16 KeyLength;
-       u8 MacAddr[6];  /* mandatory, AP MAC address */
-       u8 KeyIndex;            /* optional, default is 1 */
-       u8 Rsvd[3];             /* Make alignment */
-};
-
-/* WSC configured profiles */
-struct rt_wsc_profile {
-       u32 ProfileCnt;
-       u32 ApplyProfileIdx;    /* add by johnli, fix WPS test plan 5.1.1 */
-       struct rt_wsc_credential Profile[8];    /* Support up to 8 profiles */
-};
-
-#endif /* _OID_H_ */
diff --git a/drivers/staging/rt2860/pci_main_dev.c b/drivers/staging/rt2860/pci_main_dev.c
deleted file mode 100644 (file)
index 25fbb18..0000000
+++ /dev/null
@@ -1,1192 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-    Module Name:
-    pci_main_dev.c
-
-    Abstract:
-    Create and register network interface for PCI based chipsets in Linux platform.
-
-    Revision History:
-    Who                When            What
-    Justin P. Mattock  11/07/2010      Fix typos in some comments
-    --------    ----------      ----------------------------------------------
-*/
-
-#include "rt_config.h"
-#include <linux/pci.h>
-#include <linux/slab.h>
-
-/* Following information will be show when you run 'modinfo' */
-/* If you have a solution for a bug in current version of driver, please e-mail me. */
-/* Otherwise post to forum in ralinktech's web site(www.ralinktech.com) and let all users help you. */
-MODULE_AUTHOR("Jett Chen <jett_chen@ralinktech.com>");
-MODULE_DESCRIPTION("RT2860/RT3090 Wireless Lan Linux Driver");
-MODULE_LICENSE("GPL");
-MODULE_ALIAS("rt3090sta");
-
-/* */
-/* Function declarations */
-/* */
-static void __devexit rt2860_remove_one(struct pci_dev *pci_dev);
-static int __devinit rt2860_probe(struct pci_dev *pci_dev,
-                                 const struct pci_device_id *ent);
-static void __exit rt2860_cleanup_module(void);
-static int __init rt2860_init_module(void);
-
-static void RTMPInitPCIeDevice(IN struct pci_dev *pci_dev,
-                              struct rt_rtmp_adapter *pAd);
-
-#ifdef CONFIG_PM
-static int rt2860_suspend(struct pci_dev *pci_dev, pm_message_t state);
-static int rt2860_resume(struct pci_dev *pci_dev);
-#endif /* CONFIG_PM // */
-
-/* */
-/* Ralink PCI device table, include all supported chipsets */
-/* */
-static struct pci_device_id rt2860_pci_tbl[] __devinitdata = {
-#ifdef RT2860
-       {PCI_DEVICE(NIC_PCI_VENDOR_ID, NIC2860_PCI_DEVICE_ID)}, /*RT28602.4G */
-       {PCI_DEVICE(NIC_PCI_VENDOR_ID, NIC2860_PCIe_DEVICE_ID)},
-       {PCI_DEVICE(NIC_PCI_VENDOR_ID, NIC2760_PCI_DEVICE_ID)},
-       {PCI_DEVICE(NIC_PCI_VENDOR_ID, NIC2790_PCIe_DEVICE_ID)},
-       {PCI_DEVICE(VEN_AWT_PCI_VENDOR_ID, VEN_AWT_PCIe_DEVICE_ID)},
-       {PCI_DEVICE(EDIMAX_PCI_VENDOR_ID, 0x7708)},
-       {PCI_DEVICE(EDIMAX_PCI_VENDOR_ID, 0x7728)},
-       {PCI_DEVICE(EDIMAX_PCI_VENDOR_ID, 0x7758)},
-       {PCI_DEVICE(EDIMAX_PCI_VENDOR_ID, 0x7727)},
-       {PCI_DEVICE(EDIMAX_PCI_VENDOR_ID, 0x7738)},
-       {PCI_DEVICE(EDIMAX_PCI_VENDOR_ID, 0x7748)},
-       {PCI_DEVICE(EDIMAX_PCI_VENDOR_ID, 0x7768)},
-#endif
-#ifdef RT3090
-       {PCI_DEVICE(NIC_PCI_VENDOR_ID, NIC3090_PCIe_DEVICE_ID)},
-       {PCI_DEVICE(NIC_PCI_VENDOR_ID, NIC3091_PCIe_DEVICE_ID)},
-       {PCI_DEVICE(NIC_PCI_VENDOR_ID, NIC3092_PCIe_DEVICE_ID)},
-#endif /* RT3090 // */
-#ifdef RT3390
-       {PCI_DEVICE(NIC_PCI_VENDOR_ID, NIC3390_PCIe_DEVICE_ID)},
-       {PCI_DEVICE(NIC_PCI_VENDOR_ID, NIC3391_PCIe_DEVICE_ID)},
-       {PCI_DEVICE(NIC_PCI_VENDOR_ID, NIC3392_PCIe_DEVICE_ID)},
-#endif /* RT3390 // */
-       {0,}                    /* terminate list */
-};
-
-MODULE_DEVICE_TABLE(pci, rt2860_pci_tbl);
-#ifdef MODULE_VERSION
-MODULE_VERSION(STA_DRIVER_VERSION);
-#endif
-
-/* */
-/* Our PCI driver structure */
-/* */
-static struct pci_driver rt2860_driver = {
-name: "rt2860",
-id_table : rt2860_pci_tbl,
-probe : rt2860_probe,
-remove : __devexit_p(rt2860_remove_one),
-#ifdef CONFIG_PM
-suspend : rt2860_suspend,
-resume : rt2860_resume,
-#endif
-};
-
-/***************************************************************************
- *
- *     PCI device initialization related procedures.
- *
- ***************************************************************************/
-#ifdef CONFIG_PM
-
-void RT2860RejectPendingPackets(struct rt_rtmp_adapter *pAd)
-{
-       /* clear PS packets */
-       /* clear TxSw packets */
-}
-
-static int rt2860_suspend(struct pci_dev *pci_dev, pm_message_t state)
-{
-       struct net_device *net_dev = pci_get_drvdata(pci_dev);
-       struct rt_rtmp_adapter *pAd = (struct rt_rtmp_adapter *)NULL;
-       int retval = 0;
-
-       DBGPRINT(RT_DEBUG_TRACE, ("===> rt2860_suspend()\n"));
-
-       if (net_dev == NULL) {
-               DBGPRINT(RT_DEBUG_ERROR, ("net_dev == NULL!\n"));
-       } else {
-               GET_PAD_FROM_NET_DEV(pAd, net_dev);
-
-               /* we can not use IFF_UP because ra0 down but ra1 up */
-               /* and 1 suspend/resume function for 1 module, not for each interface */
-               /* so Linux will call suspend/resume function once */
-               if (VIRTUAL_IF_NUM(pAd) > 0) {
-                       /* avoid users do suspend after interface is down */
-
-                       /* stop interface */
-                       netif_carrier_off(net_dev);
-                       netif_stop_queue(net_dev);
-
-                       /* mark device as removed from system and therefore no longer available */
-                       netif_device_detach(net_dev);
-
-                       /* mark halt flag */
-                       RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS);
-                       RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF);
-
-                       /* take down the device */
-                       rt28xx_close((struct net_device *)net_dev);
-
-                       RT_MOD_DEC_USE_COUNT();
-               }
-       }
-
-       /* reference to http://vovo2000.com/type-lab/linux/kernel-api/linux-kernel-api.html */
-       /* enable device to generate PME# when suspended */
-       /* pci_choose_state(): Choose the power state of a PCI device to be suspended */
-       retval = pci_enable_wake(pci_dev, pci_choose_state(pci_dev, state), 1);
-       /* save the PCI configuration space of a device before suspending */
-       pci_save_state(pci_dev);
-       /* disable PCI device after use */
-       pci_disable_device(pci_dev);
-
-       retval = pci_set_power_state(pci_dev, pci_choose_state(pci_dev, state));
-
-       DBGPRINT(RT_DEBUG_TRACE, ("<=== rt2860_suspend()\n"));
-       return retval;
-}
-
-static int rt2860_resume(struct pci_dev *pci_dev)
-{
-       struct net_device *net_dev = pci_get_drvdata(pci_dev);
-       struct rt_rtmp_adapter *pAd = (struct rt_rtmp_adapter *)NULL;
-       int retval;
-
-       /* set the power state of a PCI device */
-       /* PCI has 4 power states, DO (normal) ~ D3(less power) */
-       /* in include/linux/pci.h, you can find that */
-       /* #define PCI_D0          ((pci_power_t __force) 0) */
-       /* #define PCI_D1          ((pci_power_t __force) 1) */
-       /* #define PCI_D2          ((pci_power_t __force) 2) */
-       /* #define PCI_D3hot       ((pci_power_t __force) 3) */
-       /* #define PCI_D3cold      ((pci_power_t __force) 4) */
-       /* #define PCI_UNKNOWN     ((pci_power_t __force) 5) */
-       /* #define PCI_POWER_ERROR ((pci_power_t __force) -1) */
-       retval = pci_set_power_state(pci_dev, PCI_D0);
-
-       /* restore the saved state of a PCI device */
-       pci_restore_state(pci_dev);
-
-       /* initialize device before it's used by a driver */
-       if (pci_enable_device(pci_dev)) {
-               printk(KERN_ERR "rt2860: pci enable fail!\n");
-               return 0;
-       }
-
-       DBGPRINT(RT_DEBUG_TRACE, ("===> rt2860_resume()\n"));
-
-       if (net_dev == NULL)
-               DBGPRINT(RT_DEBUG_ERROR, ("net_dev == NULL!\n"));
-       else
-               GET_PAD_FROM_NET_DEV(pAd, net_dev);
-
-       if (pAd != NULL) {
-               /* we can not use IFF_UP because ra0 down but ra1 up */
-               /* and 1 suspend/resume function for 1 module, not for each interface */
-               /* so Linux will call suspend/resume function once */
-               if (VIRTUAL_IF_NUM(pAd) > 0) {
-                       /* mark device as attached from system and restart if needed */
-                       netif_device_attach(net_dev);
-
-                       if (rt28xx_open((struct net_device *)net_dev) != 0) {
-                               /* open fail */
-                               DBGPRINT(RT_DEBUG_TRACE,
-                                        ("<=== rt2860_resume()\n"));
-                               return 0;
-                       }
-                       /* increase MODULE use count */
-                       RT_MOD_INC_USE_COUNT();
-
-                       RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS);
-                       RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF);
-
-                       netif_start_queue(net_dev);
-                       netif_carrier_on(net_dev);
-                       netif_wake_queue(net_dev);
-               }
-       }
-
-       DBGPRINT(RT_DEBUG_TRACE, ("<=== rt2860_resume()\n"));
-       return 0;
-}
-#endif /* CONFIG_PM // */
-
-static int __init rt2860_init_module(void)
-{
-       return pci_register_driver(&rt2860_driver);
-}
-
-/* */
-/* Driver module unload function */
-/* */
-static void __exit rt2860_cleanup_module(void)
-{
-       pci_unregister_driver(&rt2860_driver);
-}
-
-module_init(rt2860_init_module);
-module_exit(rt2860_cleanup_module);
-
-/* */
-/* PCI device probe & initialization function */
-/* */
-static int __devinit rt2860_probe(IN struct pci_dev *pci_dev,
-                                 IN const struct pci_device_id *pci_id)
-{
-       struct rt_rtmp_adapter *pAd = (struct rt_rtmp_adapter *)NULL;
-       struct net_device *net_dev;
-       void *handle;
-       char *print_name;
-       unsigned long csr_addr;
-       int rv = 0;
-       struct rt_rtmp_os_netdev_op_hook netDevHook;
-
-       DBGPRINT(RT_DEBUG_TRACE, ("===> rt2860_probe\n"));
-
-/*PCIDevInit============================================== */
-       /* wake up and enable device */
-       rv = pci_enable_device(pci_dev);
-
-       if (rv != 0) {
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("Enable PCI device failed, errno=%d!\n", rv));
-               return rv;
-       }
-
-       print_name = (char *)pci_name(pci_dev);
-
-       rv = pci_request_regions(pci_dev, print_name);
-
-       if (rv != 0) {
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("Request PCI resource failed, errno=%d!\n", rv));
-               goto err_out;
-       }
-       /* map physical address to virtual address for accessing register */
-       csr_addr =
-           (unsigned long)ioremap(pci_resource_start(pci_dev, 0),
-                                  pci_resource_len(pci_dev, 0));
-       if (!csr_addr) {
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("ioremap failed for device %s, region 0x%lX @ 0x%lX\n",
-                         print_name, (unsigned long)pci_resource_len(pci_dev, 0),
-                         (unsigned long)pci_resource_start(pci_dev, 0)));
-               goto err_out_free_res;
-       } else {
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("%s: at 0x%lx, VA 0x%lx, IRQ %d. \n", print_name,
-                         (unsigned long)pci_resource_start(pci_dev, 0),
-                         (unsigned long)csr_addr, pci_dev->irq));
-       }
-
-       /* Set DMA master */
-       pci_set_master(pci_dev);
-
-/*RtmpDevInit============================================== */
-       /* Allocate struct rt_rtmp_adapter adapter structure */
-       handle = kmalloc(sizeof(struct os_cookie), GFP_KERNEL);
-       if (handle == NULL) {
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("%s(): Allocate memory for os handle failed!\n",
-                         __func__));
-               goto err_out_iounmap;
-       }
-
-       ((struct os_cookie *)handle)->pci_dev = pci_dev;
-
-       rv = RTMPAllocAdapterBlock(handle, &pAd);       /*shiang: we may need the pci_dev for allocate structure of "struct rt_rtmp_adapter" */
-       if (rv != NDIS_STATUS_SUCCESS)
-               goto err_out_iounmap;
-       /* Here are the struct rt_rtmp_adapter structure with pci-bus specific parameters. */
-       pAd->CSRBaseAddress = (u8 *)csr_addr;
-       DBGPRINT(RT_DEBUG_ERROR,
-                ("pAd->CSRBaseAddress =0x%lx, csr_addr=0x%lx!\n",
-                 (unsigned long)pAd->CSRBaseAddress, csr_addr));
-       RtmpRaDevCtrlInit(pAd, RTMP_DEV_INF_PCI);
-
-/*NetDevInit============================================== */
-       net_dev = RtmpPhyNetDevInit(pAd, &netDevHook);
-       if (net_dev == NULL)
-               goto err_out_free_radev;
-
-       /* Here are the net_device structure with pci-bus specific parameters. */
-       net_dev->irq = pci_dev->irq;    /* Interrupt IRQ number */
-       net_dev->base_addr = csr_addr;  /* Save CSR virtual address and irq to device structure */
-       pci_set_drvdata(pci_dev, net_dev);      /* Set driver data */
-
-/* for supporting Network Manager */
-       /* Set the sysfs physical device reference for the network logical device
-        * if set prior to registration will cause a symlink during initialization.
-        */
-       SET_NETDEV_DEV(net_dev, &(pci_dev->dev));
-
-/*All done, it's time to register the net device to linux kernel. */
-       /* Register this device */
-       rv = RtmpOSNetDevAttach(net_dev, &netDevHook);
-       if (rv)
-               goto err_out_free_netdev;
-
-       pAd->StaCfg.OriDevType = net_dev->type;
-       RTMPInitPCIeDevice(pci_dev, pAd);
-
-       DBGPRINT(RT_DEBUG_TRACE, ("<=== rt2860_probe\n"));
-
-       return 0;               /* probe ok */
-
-       /* --------------------------- ERROR HANDLE --------------------------- */
-err_out_free_netdev:
-       RtmpOSNetDevFree(net_dev);
-
-err_out_free_radev:
-       /* free struct rt_rtmp_adapter strcuture and os_cookie */
-       RTMPFreeAdapter(pAd);
-
-err_out_iounmap:
-       iounmap((void *)(csr_addr));
-       release_mem_region(pci_resource_start(pci_dev, 0),
-                          pci_resource_len(pci_dev, 0));
-
-err_out_free_res:
-       pci_release_regions(pci_dev);
-
-err_out:
-       pci_disable_device(pci_dev);
-
-       DBGPRINT(RT_DEBUG_ERROR,
-                ("<=== rt2860_probe failed with rv = %d!\n", rv));
-
-       return -ENODEV;         /* probe fail */
-}
-
-static void __devexit rt2860_remove_one(IN struct pci_dev *pci_dev)
-{
-       struct net_device *net_dev = pci_get_drvdata(pci_dev);
-       struct rt_rtmp_adapter *pAd = NULL;
-       unsigned long csr_addr = net_dev->base_addr;    /* pAd->CSRBaseAddress; */
-
-       GET_PAD_FROM_NET_DEV(pAd, net_dev);
-
-       DBGPRINT(RT_DEBUG_TRACE, ("===> rt2860_remove_one\n"));
-
-       if (pAd != NULL) {
-               /* Unregister/Free all allocated net_device. */
-               RtmpPhyNetDevExit(pAd, net_dev);
-
-               /* Unmap CSR base address */
-               iounmap((char *)(csr_addr));
-
-               /* release memory region */
-               release_mem_region(pci_resource_start(pci_dev, 0),
-                                  pci_resource_len(pci_dev, 0));
-
-               /* Free struct rt_rtmp_adapter related structures. */
-               RtmpRaDevCtrlExit(pAd);
-
-       } else {
-               /* Unregister network device */
-               RtmpOSNetDevDetach(net_dev);
-
-               /* Unmap CSR base address */
-               iounmap((char *)(net_dev->base_addr));
-
-               /* release memory region */
-               release_mem_region(pci_resource_start(pci_dev, 0),
-                                  pci_resource_len(pci_dev, 0));
-       }
-
-       /* Free the root net_device */
-       RtmpOSNetDevFree(net_dev);
-
-}
-
-/*
-========================================================================
-Routine Description:
-    Check the chipset vendor/product ID.
-
-Arguments:
-    _dev_p                             Point to the PCI or USB device
-
-Return Value:
-    TRUE                               Check ok
-       FALSE                           Check fail
-
-Note:
-========================================================================
-*/
-BOOLEAN RT28XXChipsetCheck(IN void *_dev_p)
-{
-       /* always TRUE */
-       return TRUE;
-}
-
-/***************************************************************************
- *
- *     PCIe device initialization related procedures.
- *
- ***************************************************************************/
-static void RTMPInitPCIeDevice(struct pci_dev *pci_dev, struct rt_rtmp_adapter *pAd)
-{
-       u16 device_id;
-       struct os_cookie *pObj;
-
-       pObj = (struct os_cookie *)pAd->OS_Cookie;
-       pci_read_config_word(pci_dev, PCI_DEVICE_ID, &device_id);
-       device_id = le2cpu16(device_id);
-       pObj->DeviceID = device_id;
-       if (
-#ifdef RT2860
-                  (device_id == NIC2860_PCIe_DEVICE_ID) ||
-                  (device_id == NIC2790_PCIe_DEVICE_ID) ||
-                  (device_id == VEN_AWT_PCIe_DEVICE_ID) ||
-#endif
-#ifdef RT3090
-                  (device_id == NIC3090_PCIe_DEVICE_ID) ||
-                  (device_id == NIC3091_PCIe_DEVICE_ID) ||
-                  (device_id == NIC3092_PCIe_DEVICE_ID) ||
-#endif /* RT3090 // */
-                  0) {
-               u32 MacCsr0 = 0, Index = 0;
-               do {
-                       RTMP_IO_READ32(pAd, MAC_CSR0, &MacCsr0);
-
-                       if ((MacCsr0 != 0x00) && (MacCsr0 != 0xFFFFFFFF))
-                               break;
-
-                       RTMPusecDelay(10);
-               } while (Index++ < 100);
-
-               /* Support advanced power save after 2892/2790. */
-               /* MAC version at offset 0x1000 is 0x2872XXXX/0x2870XXXX(PCIe, USB, SDIO). */
-               if ((MacCsr0 & 0xffff0000) != 0x28600000)
-                       OPSTATUS_SET_FLAG(pAd, fOP_STATUS_PCIE_DEVICE);
-       }
-}
-
-void RTMPInitPCIeLinkCtrlValue(struct rt_rtmp_adapter *pAd)
-{
-       int pos;
-       u16 reg16, data2, PCIePowerSaveLevel, Configuration;
-       u32 MacValue;
-       BOOLEAN bFindIntel = FALSE;
-       struct os_cookie *pObj;
-
-       pObj = (struct os_cookie *)pAd->OS_Cookie;
-
-       if (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_PCIE_DEVICE))
-               return;
-
-       DBGPRINT(RT_DEBUG_TRACE, ("%s.===>\n", __func__));
-       /* Init EEPROM, and save settings */
-       if (!(IS_RT3090(pAd) || IS_RT3572(pAd) || IS_RT3390(pAd))) {
-               RT28xx_EEPROM_READ16(pAd, 0x22, PCIePowerSaveLevel);
-               pAd->PCIePowerSaveLevel = PCIePowerSaveLevel & 0xff;
-
-               pAd->LnkCtrlBitMask = 0;
-               if ((PCIePowerSaveLevel & 0xff) == 0xff) {
-                       OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_PCIE_DEVICE);
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("====> PCIePowerSaveLevel = 0x%x.\n",
-                                 PCIePowerSaveLevel));
-                       return;
-               } else {
-                       PCIePowerSaveLevel &= 0x3;
-                       RT28xx_EEPROM_READ16(pAd, 0x24, data2);
-
-                       if (!
-                           (((data2 & 0xff00) == 0x9200)
-                            && ((data2 & 0x80) != 0))) {
-                               if (PCIePowerSaveLevel > 1)
-                                       PCIePowerSaveLevel = 1;
-                       }
-
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("====> Write 0x83 = 0x%x.\n",
-                                 PCIePowerSaveLevel));
-                       AsicSendCommandToMcu(pAd, 0x83, 0xff,
-                                            (u8)PCIePowerSaveLevel, 0x00);
-                       RT28xx_EEPROM_READ16(pAd, 0x22, PCIePowerSaveLevel);
-                       PCIePowerSaveLevel &= 0xff;
-                       PCIePowerSaveLevel = PCIePowerSaveLevel >> 6;
-                       switch (PCIePowerSaveLevel) {
-                       case 0: /* Only support L0 */
-                               pAd->LnkCtrlBitMask = 0;
-                               break;
-                       case 1: /* Only enable L0s */
-                               pAd->LnkCtrlBitMask = 1;
-                               break;
-                       case 2: /* enable L1, L0s */
-                               pAd->LnkCtrlBitMask = 3;
-                               break;
-                       case 3: /* sync with host clk and enable L1, L0s */
-                               pAd->LnkCtrlBitMask = 0x103;
-                               break;
-                       }
-                       RT28xx_EEPROM_READ16(pAd, 0x24, data2);
-                       if ((PCIePowerSaveLevel & 0xff) != 0xff) {
-                               PCIePowerSaveLevel &= 0x3;
-
-                               if (!
-                                   (((data2 & 0xff00) == 0x9200)
-                                    && ((data2 & 0x80) != 0))) {
-                                       if (PCIePowerSaveLevel > 1)
-                                               PCIePowerSaveLevel = 1;
-                               }
-
-                               DBGPRINT(RT_DEBUG_TRACE,
-                                        ("====> rt28xx Write 0x83 Command = 0x%x.\n",
-                                         PCIePowerSaveLevel));
-
-                               AsicSendCommandToMcu(pAd, 0x83, 0xff,
-                                                    (u8)PCIePowerSaveLevel,
-                                                    0x00);
-                       }
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("====> LnkCtrlBitMask = 0x%x.\n",
-                                 pAd->LnkCtrlBitMask));
-               }
-       } else if (IS_RT3090(pAd) || IS_RT3572(pAd) || IS_RT3390(pAd)) {
-               u8 LinkCtrlSetting = 0;
-
-               /* Check 3090E special setting chip. */
-               RT28xx_EEPROM_READ16(pAd, 0x24, data2);
-               if ((data2 == 0x9280) && ((pAd->MACVersion & 0xffff) == 0x0211)) {
-                       pAd->b3090ESpecialChip = TRUE;
-                       DBGPRINT_RAW(RT_DEBUG_ERROR, ("Special 3090E chip \n"));
-               }
-
-               RTMP_IO_READ32(pAd, AUX_CTRL, &MacValue);
-               /*enable WAKE_PCIE function, which forces to enable PCIE clock when mpu interrupt asserting. */
-               /*Force PCIE 125MHz CLK to toggle */
-               MacValue |= 0x402;
-               RTMP_IO_WRITE32(pAd, AUX_CTRL, MacValue);
-               DBGPRINT_RAW(RT_DEBUG_ERROR,
-                            (" AUX_CTRL = 0x%32x\n", MacValue));
-
-               /* for RT30xx F and after, PCIe interface, and for power solution 3 */
-               if ((IS_VERSION_AFTER_F(pAd))
-                   && (pAd->StaCfg.PSControl.field.rt30xxPowerMode >= 2)
-                   && (pAd->StaCfg.PSControl.field.rt30xxPowerMode <= 3)) {
-                       RTMP_IO_READ32(pAd, AUX_CTRL, &MacValue);
-                       DBGPRINT_RAW(RT_DEBUG_ERROR,
-                                    (" Read AUX_CTRL = 0x%x\n", MacValue));
-                       /* turn on bit 12. */
-                       /*enable 32KHz clock mode for power saving */
-                       MacValue |= 0x1000;
-                       if (MacValue != 0xffffffff) {
-                               RTMP_IO_WRITE32(pAd, AUX_CTRL, MacValue);
-                               DBGPRINT_RAW(RT_DEBUG_ERROR,
-                                            (" Write AUX_CTRL = 0x%x\n",
-                                             MacValue));
-                               /* 1. if use PCIePowerSetting is 2 or 3, need to program OSC_CTRL to 0x3ff11. */
-                               MacValue = 0x3ff11;
-                               RTMP_IO_WRITE32(pAd, OSC_CTRL, MacValue);
-                               DBGPRINT_RAW(RT_DEBUG_ERROR,
-                                            (" OSC_CTRL = 0x%x\n", MacValue));
-                               /* 2. Write PCI register Clk ref bit */
-                               RTMPrt3xSetPCIePowerLinkCtrl(pAd);
-                       } else {
-                               /* Error read Aux_Ctrl value.  Force to use solution 1 */
-                               DBGPRINT(RT_DEBUG_ERROR,
-                                        (" Error Value in AUX_CTRL = 0x%x\n",
-                                         MacValue));
-                               pAd->StaCfg.PSControl.field.rt30xxPowerMode = 1;
-                               DBGPRINT(RT_DEBUG_ERROR,
-                                        (" Force to use power solution1 \n"));
-                       }
-               }
-               /* 1. read setting from inf file. */
-
-               PCIePowerSaveLevel =
-                   (u16)pAd->StaCfg.PSControl.field.rt30xxPowerMode;
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("====> rt30xx Read PowerLevelMode =  0x%x.\n",
-                         PCIePowerSaveLevel));
-               /* 2. Check EnableNewPS. */
-               if (pAd->StaCfg.PSControl.field.EnableNewPS == FALSE)
-                       PCIePowerSaveLevel = 1;
-
-               if (IS_VERSION_BEFORE_F(pAd)
-                   && (pAd->b3090ESpecialChip == FALSE)) {
-                       /* Chip Version E only allow 1, So force set 1. */
-                       PCIePowerSaveLevel &= 0x1;
-                       pAd->PCIePowerSaveLevel = (u16)PCIePowerSaveLevel;
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("====> rt30xx E Write 0x83 Command = 0x%x.\n",
-                                 PCIePowerSaveLevel));
-
-                       AsicSendCommandToMcu(pAd, 0x83, 0xff,
-                                            (u8)PCIePowerSaveLevel, 0x00);
-               } else {
-                       /* Chip Version F and after only allow 1 or 2 or 3. This might be modified after new chip version come out. */
-                       if (!
-                           ((PCIePowerSaveLevel == 1)
-                            || (PCIePowerSaveLevel == 3)))
-                               PCIePowerSaveLevel = 1;
-                       DBGPRINT(RT_DEBUG_ERROR,
-                                ("====> rt30xx F Write 0x83 Command = 0x%x.\n",
-                                 PCIePowerSaveLevel));
-                       pAd->PCIePowerSaveLevel = (u16)PCIePowerSaveLevel;
-                       /* for 3090F , we need to add high-byte arg for 0x83 command to indicate the link control setting in */
-                       /* PCI Configuration Space. Because firmware can't read PCI Configuration Space */
-                       if ((pAd->Rt3xxRalinkLinkCtrl & 0x2)
-                           && (pAd->Rt3xxHostLinkCtrl & 0x2)) {
-                               LinkCtrlSetting = 1;
-                       }
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("====> rt30xxF LinkCtrlSetting = 0x%x.\n",
-                                 LinkCtrlSetting));
-                       AsicSendCommandToMcu(pAd, 0x83, 0xff,
-                                            (u8)PCIePowerSaveLevel,
-                                            LinkCtrlSetting);
-               }
-       }
-       /* Find Ralink PCIe Device's Express Capability Offset */
-       pos = pci_find_capability(pObj->pci_dev, PCI_CAP_ID_EXP);
-
-       if (pos != 0) {
-               /* Ralink PCIe Device's Link Control Register Offset */
-               pAd->RLnkCtrlOffset = pos + PCI_EXP_LNKCTL;
-               pci_read_config_word(pObj->pci_dev, pAd->RLnkCtrlOffset,
-                                    &reg16);
-               Configuration = le2cpu16(reg16);
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("Read (Ralink PCIe Link Control Register) offset 0x%x = 0x%x\n",
-                         pAd->RLnkCtrlOffset, Configuration));
-               pAd->RLnkCtrlConfiguration = (Configuration & 0x103);
-               Configuration &= 0xfefc;
-               Configuration |= (0x0);
-#ifdef RT2860
-               if ((pObj->DeviceID == NIC2860_PCIe_DEVICE_ID)
-                   || (pObj->DeviceID == NIC2790_PCIe_DEVICE_ID)) {
-                       reg16 = cpu2le16(Configuration);
-                       pci_write_config_word(pObj->pci_dev,
-                                             pAd->RLnkCtrlOffset, reg16);
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("Write (Ralink PCIe Link Control Register)  offset 0x%x = 0x%x\n",
-                                 pos + PCI_EXP_LNKCTL, Configuration));
-               }
-#endif /* RT2860 // */
-
-               RTMPFindHostPCIDev(pAd);
-               if (pObj->parent_pci_dev) {
-                       u16 vendor_id;
-
-                       pci_read_config_word(pObj->parent_pci_dev,
-                                            PCI_VENDOR_ID, &vendor_id);
-                       vendor_id = le2cpu16(vendor_id);
-                       if (vendor_id == PCIBUS_INTEL_VENDOR) {
-                               bFindIntel = TRUE;
-                               RTMP_SET_PSFLAG(pAd, fRTMP_PS_TOGGLE_L1);
-                       }
-                       /* Find PCI-to-PCI Bridge Express Capability Offset */
-                       pos =
-                           pci_find_capability(pObj->parent_pci_dev,
-                                               PCI_CAP_ID_EXP);
-
-                       if (pos != 0) {
-                               BOOLEAN bChange = FALSE;
-                               /* PCI-to-PCI Bridge Link Control Register Offset */
-                               pAd->HostLnkCtrlOffset = pos + PCI_EXP_LNKCTL;
-                               pci_read_config_word(pObj->parent_pci_dev,
-                                                    pAd->HostLnkCtrlOffset,
-                                                    &reg16);
-                               Configuration = le2cpu16(reg16);
-                               DBGPRINT(RT_DEBUG_TRACE,
-                                        ("Read (Host PCI-to-PCI Bridge Link Control Register) offset 0x%x = 0x%x\n",
-                                         pAd->HostLnkCtrlOffset,
-                                         Configuration));
-                               pAd->HostLnkCtrlConfiguration =
-                                   (Configuration & 0x103);
-                               Configuration &= 0xfefc;
-                               Configuration |= (0x0);
-
-                               switch (pObj->DeviceID) {
-#ifdef RT2860
-                               case NIC2860_PCIe_DEVICE_ID:
-                               case NIC2790_PCIe_DEVICE_ID:
-                                       bChange = TRUE;
-                                       break;
-#endif /* RT2860 // */
-#ifdef RT3090
-                               case NIC3090_PCIe_DEVICE_ID:
-                               case NIC3091_PCIe_DEVICE_ID:
-                               case NIC3092_PCIe_DEVICE_ID:
-                                       if (bFindIntel == FALSE)
-                                               bChange = TRUE;
-                                       break;
-#endif /* RT3090 // */
-                               default:
-                                       break;
-                               }
-
-                               if (bChange) {
-                                       reg16 = cpu2le16(Configuration);
-                                       pci_write_config_word(pObj->
-                                                             parent_pci_dev,
-                                                             pAd->
-                                                             HostLnkCtrlOffset,
-                                                             reg16);
-                                       DBGPRINT(RT_DEBUG_TRACE,
-                                                ("Write (Host PCI-to-PCI Bridge Link Control Register) offset 0x%x = 0x%x\n",
-                                                 pAd->HostLnkCtrlOffset,
-                                                 Configuration));
-                               }
-                       } else {
-                               pAd->HostLnkCtrlOffset = 0;
-                               DBGPRINT(RT_DEBUG_ERROR,
-                                        ("%s: cannot find PCI-to-PCI Bridge PCI Express Capability!\n",
-                                         __func__));
-                       }
-               }
-       } else {
-               pAd->RLnkCtrlOffset = 0;
-               pAd->HostLnkCtrlOffset = 0;
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("%s: cannot find Ralink PCIe Device's PCI Express Capability!\n",
-                         __func__));
-       }
-
-       if (bFindIntel == FALSE) {
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("Doesn't find Intel PCI host controller. \n"));
-               /* Doesn't switch L0, L1, So set PCIePowerSaveLevel to 0xff */
-               pAd->PCIePowerSaveLevel = 0xff;
-               if ((pAd->RLnkCtrlOffset != 0)
-#ifdef RT3090
-                   && ((pObj->DeviceID == NIC3090_PCIe_DEVICE_ID)
-                       || (pObj->DeviceID == NIC3091_PCIe_DEVICE_ID)
-                       || (pObj->DeviceID == NIC3092_PCIe_DEVICE_ID))
-#endif /* RT3090 // */
-                   ) {
-                       pci_read_config_word(pObj->pci_dev, pAd->RLnkCtrlOffset,
-                                            &reg16);
-                       Configuration = le2cpu16(reg16);
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("Read (Ralink 30xx PCIe Link Control Register) offset 0x%x = 0x%x\n",
-                                 pAd->RLnkCtrlOffset, Configuration));
-                       pAd->RLnkCtrlConfiguration = (Configuration & 0x103);
-                       Configuration &= 0xfefc;
-                       Configuration |= (0x0);
-                       reg16 = cpu2le16(Configuration);
-                       pci_write_config_word(pObj->pci_dev,
-                                             pAd->RLnkCtrlOffset, reg16);
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("Write (Ralink PCIe Link Control Register)  offset 0x%x = 0x%x\n",
-                                 pos + PCI_EXP_LNKCTL, Configuration));
-               }
-       }
-}
-
-void RTMPFindHostPCIDev(struct rt_rtmp_adapter *pAd)
-{
-       u16 reg16;
-       u8 reg8;
-       u32 DevFn;
-       struct pci_dev *pPci_dev;
-       struct os_cookie *pObj;
-
-       pObj = (struct os_cookie *)pAd->OS_Cookie;
-
-       if (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_PCIE_DEVICE))
-               return;
-
-       DBGPRINT(RT_DEBUG_TRACE, ("%s.===>\n", __func__));
-
-       pObj->parent_pci_dev = NULL;
-       if (pObj->pci_dev->bus->parent) {
-               for (DevFn = 0; DevFn < 255; DevFn++) {
-                       pPci_dev =
-                           pci_get_slot(pObj->pci_dev->bus->parent, DevFn);
-                       if (pPci_dev) {
-                               pci_read_config_word(pPci_dev, PCI_CLASS_DEVICE,
-                                                    &reg16);
-                               reg16 = le2cpu16(reg16);
-                               pci_read_config_byte(pPci_dev, PCI_CB_CARD_BUS,
-                                                    &reg8);
-                               if ((reg16 == PCI_CLASS_BRIDGE_PCI)
-                                   && (reg8 == pObj->pci_dev->bus->number)) {
-                                       pObj->parent_pci_dev = pPci_dev;
-                               }
-                       }
-               }
-       }
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-
-       Arguments:
-               Level = RESTORE_HALT : Restore PCI host and Ralink PCIe Link Control field to its default value.
-               Level = Other Value : Restore from dot11 power save or radio off status. And force PCI host Link Control fields to 0x1
-
-       ========================================================================
-*/
-void RTMPPCIeLinkCtrlValueRestore(struct rt_rtmp_adapter *pAd, u8 Level)
-{
-       u16 PCIePowerSaveLevel, reg16;
-       u16 Configuration;
-       struct os_cookie *pObj;
-
-       pObj = (struct os_cookie *)pAd->OS_Cookie;
-
-       if (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_PCIE_DEVICE))
-               return;
-
-#ifdef RT2860
-       if (!((pObj->DeviceID == NIC2860_PCIe_DEVICE_ID)
-             || (pObj->DeviceID == NIC2790_PCIe_DEVICE_ID)))
-               return;
-#endif /* RT2860 // */
-       /* Check PSControl Configuration */
-       if (pAd->StaCfg.PSControl.field.EnableNewPS == FALSE)
-               return;
-
-       /*3090 will not execute the following codes. */
-       /* Check interface : If not PCIe interface, return. */
-
-#ifdef RT3090
-       if ((pObj->DeviceID == NIC3090_PCIe_DEVICE_ID)
-           || (pObj->DeviceID == NIC3091_PCIe_DEVICE_ID)
-           || (pObj->DeviceID == NIC3092_PCIe_DEVICE_ID))
-               return;
-#endif /* RT3090 // */
-
-       DBGPRINT(RT_DEBUG_TRACE, ("%s.===>\n", __func__));
-       PCIePowerSaveLevel = pAd->PCIePowerSaveLevel;
-       if ((PCIePowerSaveLevel & 0xff) == 0xff) {
-               DBGPRINT(RT_DEBUG_TRACE, ("return  \n"));
-               return;
-       }
-
-       if (pObj->parent_pci_dev && (pAd->HostLnkCtrlOffset != 0)) {
-               PCI_REG_READ_WORD(pObj->parent_pci_dev, pAd->HostLnkCtrlOffset,
-                                 Configuration);
-               if ((Configuration != 0) && (Configuration != 0xFFFF)) {
-                       Configuration &= 0xfefc;
-                       /* If call from interface down, restore to original setting. */
-                       if (Level == RESTORE_CLOSE)
-                               Configuration |= pAd->HostLnkCtrlConfiguration;
-                       else
-                               Configuration |= 0x0;
-                       PCI_REG_WIRTE_WORD(pObj->parent_pci_dev,
-                                          pAd->HostLnkCtrlOffset,
-                                          Configuration);
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("Restore PCI host : offset 0x%x = 0x%x\n",
-                                 pAd->HostLnkCtrlOffset, Configuration));
-               } else
-                       DBGPRINT(RT_DEBUG_ERROR,
-                                ("Restore PCI host : PCI_REG_READ_WORD failed (Configuration = 0x%x)\n",
-                                 Configuration));
-       }
-
-       if (pObj->pci_dev && (pAd->RLnkCtrlOffset != 0)) {
-               PCI_REG_READ_WORD(pObj->pci_dev, pAd->RLnkCtrlOffset,
-                                 Configuration);
-               if ((Configuration != 0) && (Configuration != 0xFFFF)) {
-                       Configuration &= 0xfefc;
-                       /* If call from interface down, restore to original setting. */
-                       if (Level == RESTORE_CLOSE)
-                               Configuration |= pAd->RLnkCtrlConfiguration;
-                       else
-                               Configuration |= 0x0;
-                       PCI_REG_WIRTE_WORD(pObj->pci_dev, pAd->RLnkCtrlOffset,
-                                          Configuration);
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("Restore Ralink : offset 0x%x = 0x%x\n",
-                                 pAd->RLnkCtrlOffset, Configuration));
-               } else
-                       DBGPRINT(RT_DEBUG_ERROR,
-                                ("Restore Ralink : PCI_REG_READ_WORD failed (Configuration = 0x%x)\n",
-                                 Configuration));
-       }
-
-       DBGPRINT(RT_DEBUG_TRACE, ("%s <===\n", __func__));
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-
-       Arguments:
-               Max : limit Host PCI and Ralink PCIe device's LINK CONTROL field's value.
-               Because now frequently set our device to mode 1 or mode 3 will cause problem.
-
-       ========================================================================
-*/
-void RTMPPCIeLinkCtrlSetting(struct rt_rtmp_adapter *pAd, u16 Max)
-{
-       u16 PCIePowerSaveLevel, reg16;
-       u16 Configuration;
-       struct os_cookie *pObj;
-
-       pObj = (struct os_cookie *)pAd->OS_Cookie;
-
-       if (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_PCIE_DEVICE))
-               return;
-
-#ifdef RT2860
-       if (!((pObj->DeviceID == NIC2860_PCIe_DEVICE_ID)
-             || (pObj->DeviceID == NIC2790_PCIe_DEVICE_ID)))
-               return;
-#endif /* RT2860 // */
-       /* Check PSControl Configuration */
-       if (pAd->StaCfg.PSControl.field.EnableNewPS == FALSE)
-               return;
-
-       /* Check interface : If not PCIe interface, return. */
-       /*Block 3090 to enter the following function */
-
-#ifdef RT3090
-       if ((pObj->DeviceID == NIC3090_PCIe_DEVICE_ID)
-           || (pObj->DeviceID == NIC3091_PCIe_DEVICE_ID)
-           || (pObj->DeviceID == NIC3092_PCIe_DEVICE_ID))
-               return;
-#endif /* RT3090 // */
-       if (!RTMP_TEST_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP)) {
-               DBGPRINT(RT_DEBUG_INFO,
-                        ("RTMPPCIePowerLinkCtrl return on fRTMP_PS_CAN_GO_SLEEP flag\n"));
-               return;
-       }
-
-       DBGPRINT(RT_DEBUG_TRACE, ("%s===>\n", __func__));
-       PCIePowerSaveLevel = pAd->PCIePowerSaveLevel;
-       if ((PCIePowerSaveLevel & 0xff) == 0xff) {
-               DBGPRINT(RT_DEBUG_TRACE, ("return  \n"));
-               return;
-       }
-       PCIePowerSaveLevel = PCIePowerSaveLevel >> 6;
-
-       /* Skip non-exist deice right away */
-       if (pObj->parent_pci_dev && (pAd->HostLnkCtrlOffset != 0)) {
-               PCI_REG_READ_WORD(pObj->parent_pci_dev, pAd->HostLnkCtrlOffset,
-                                 Configuration);
-               switch (PCIePowerSaveLevel) {
-               case 0:
-                       /* Set b0 and b1 of LinkControl (both 2892 and PCIe bridge) to 00 */
-                       Configuration &= 0xfefc;
-                       break;
-               case 1:
-                       /* Set b0 and b1 of LinkControl (both 2892 and PCIe bridge) to 01 */
-                       Configuration &= 0xfefc;
-                       Configuration |= 0x1;
-                       break;
-               case 2:
-                       /*  Set b0 and b1 of LinkControl (both 2892 and PCIe bridge) to 11 */
-                       Configuration &= 0xfefc;
-                       Configuration |= 0x3;
-                       break;
-               case 3:
-                       /* Set b0 and b1 of LinkControl (both 2892 and PCIe bridge) to 11 and bit 8 of LinkControl of 2892 to 1 */
-                       Configuration &= 0xfefc;
-                       Configuration |= 0x103;
-                       break;
-               }
-               PCI_REG_WIRTE_WORD(pObj->parent_pci_dev, pAd->HostLnkCtrlOffset,
-                                  Configuration);
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("Write PCI host offset 0x%x = 0x%x\n",
-                         pAd->HostLnkCtrlOffset, Configuration));
-       }
-
-       if (pObj->pci_dev && (pAd->RLnkCtrlOffset != 0)) {
-               /* first 2892 chip not allow to frequently set mode 3. will cause hang problem. */
-               if (PCIePowerSaveLevel > Max)
-                       PCIePowerSaveLevel = Max;
-
-               PCI_REG_READ_WORD(pObj->pci_dev, pAd->RLnkCtrlOffset,
-                                 Configuration);
-               switch (PCIePowerSaveLevel) {
-               case 0:
-                       /* No PCI power safe */
-                       /* Set b0 and b1 of LinkControl (both 2892 and PCIe bridge) to 00 . */
-                       Configuration &= 0xfefc;
-                       break;
-               case 1:
-                       /*  L0 */
-                       /* Set b0 and b1 of LinkControl (both 2892 and PCIe bridge) to 01 . */
-                       Configuration &= 0xfefc;
-                       Configuration |= 0x1;
-                       break;
-               case 2:
-                       /* L0 and L1 */
-                       /*  Set b0 and b1 of LinkControl (both 2892 and PCIe bridge) to 11 */
-                       Configuration &= 0xfefc;
-                       Configuration |= 0x3;
-                       break;
-               case 3:
-                       /* L0 , L1 and clock management. */
-                       /* Set b0 and b1 of LinkControl (both 2892 and PCIe bridge) to 11 and bit 8 of LinkControl of 2892 to 1 */
-                       Configuration &= 0xfefc;
-                       Configuration |= 0x103;
-                       pAd->bPCIclkOff = TRUE;
-                       break;
-               }
-               PCI_REG_WIRTE_WORD(pObj->pci_dev, pAd->RLnkCtrlOffset,
-                                  Configuration);
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("Write Ralink device : offset 0x%x = 0x%x\n",
-                         pAd->RLnkCtrlOffset, Configuration));
-       }
-
-       DBGPRINT(RT_DEBUG_TRACE, ("RTMPPCIePowerLinkCtrl <==============\n"));
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               1. Write a PCI register for rt30xx power solution 3
-
-       ========================================================================
-*/
-void RTMPrt3xSetPCIePowerLinkCtrl(struct rt_rtmp_adapter *pAd)
-{
-
-       unsigned long HostConfiguration = 0;
-       unsigned long Configuration;
-       struct os_cookie *pObj;
-       int pos;
-       u16 reg16;
-
-       pObj = (struct os_cookie *)pAd->OS_Cookie;
-
-       DBGPRINT(RT_DEBUG_INFO,
-                ("RTMPrt3xSetPCIePowerLinkCtrl.===> %lx\n",
-                 pAd->StaCfg.PSControl.word));
-
-       /* Check PSControl Configuration */
-       if (pAd->StaCfg.PSControl.field.EnableNewPS == FALSE)
-               return;
-       RTMPFindHostPCIDev(pAd);
-       if (pObj->parent_pci_dev) {
-               /* Find PCI-to-PCI Bridge Express Capability Offset */
-               pos = pci_find_capability(pObj->parent_pci_dev, PCI_CAP_ID_EXP);
-
-               if (pos != 0)
-                       pAd->HostLnkCtrlOffset = pos + PCI_EXP_LNKCTL;
-
-               /* If configured to turn on L1. */
-               HostConfiguration = 0;
-               if (pAd->StaCfg.PSControl.field.rt30xxForceASPMTest == 1) {
-                       DBGPRINT(RT_DEBUG_TRACE, ("Enter,PSM : Force ASPM\n"));
-
-                       /* Skip non-exist device right away */
-                       if ((pAd->HostLnkCtrlOffset != 0)) {
-                               PCI_REG_READ_WORD(pObj->parent_pci_dev,
-                                                 pAd->HostLnkCtrlOffset,
-                                                 HostConfiguration);
-                               /* Prepare Configuration to write to Host */
-                               HostConfiguration |= 0x3;
-                               PCI_REG_WIRTE_WORD(pObj->parent_pci_dev,
-                                                  pAd->HostLnkCtrlOffset,
-                                                  HostConfiguration);
-                               pAd->Rt3xxHostLinkCtrl = HostConfiguration;
-                               /* Because in rt30xxForceASPMTest Mode, Force turn on L0s, L1. */
-                               /* Fix HostConfiguration bit0:1 = 0x3 for later use. */
-                               HostConfiguration = 0x3;
-                               DBGPRINT(RT_DEBUG_TRACE,
-                                        ("PSM : Force ASPM : "
-                                         "Host device L1/L0s Value =  0x%lx\n",
-                                         HostConfiguration));
-                       }
-               } else if (pAd->StaCfg.PSControl.field.rt30xxFollowHostASPM ==
-                          1) {
-
-                       /* Skip non-exist deice right away */
-                       if ((pAd->HostLnkCtrlOffset != 0)) {
-                               PCI_REG_READ_WORD(pObj->parent_pci_dev,
-                                                 pAd->HostLnkCtrlOffset,
-                                                 HostConfiguration);
-                               pAd->Rt3xxHostLinkCtrl = HostConfiguration;
-                               HostConfiguration &= 0x3;
-                               DBGPRINT(RT_DEBUG_TRACE,
-                                        ("PSM : Follow Host ASPM : "
-                                         "Host device L1/L0s Value =  0x%lx\n",
-                                         HostConfiguration));
-                       }
-               }
-       }
-       /* Prepare to write Ralink setting. */
-       /* Find Ralink PCIe Device's Express Capability Offset */
-       pos = pci_find_capability(pObj->pci_dev, PCI_CAP_ID_EXP);
-
-       if (pos != 0) {
-               /* Ralink PCIe Device's Link Control Register Offset */
-               pAd->RLnkCtrlOffset = pos + PCI_EXP_LNKCTL;
-               pci_read_config_word(pObj->pci_dev, pAd->RLnkCtrlOffset,
-                                    &reg16);
-               Configuration = le2cpu16(reg16);
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("Read (Ralink PCIe Link Control Register) "
-                         "offset 0x%x = 0x%lx\n",
-                         pAd->RLnkCtrlOffset, Configuration));
-               Configuration |= 0x100;
-               if ((pAd->StaCfg.PSControl.field.rt30xxFollowHostASPM == 1)
-                   || (pAd->StaCfg.PSControl.field.rt30xxForceASPMTest == 1)) {
-                       switch (HostConfiguration) {
-                       case 0:
-                               Configuration &= 0xffffffc;
-                               break;
-                       case 1:
-                               Configuration &= 0xffffffc;
-                               Configuration |= 0x1;
-                               break;
-                       case 2:
-                               Configuration &= 0xffffffc;
-                               Configuration |= 0x2;
-                               break;
-                       case 3:
-                               Configuration |= 0x3;
-                               break;
-                       }
-               }
-               reg16 = cpu2le16(Configuration);
-               pci_write_config_word(pObj->pci_dev, pAd->RLnkCtrlOffset,
-                                     reg16);
-               pAd->Rt3xxRalinkLinkCtrl = Configuration;
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("PSM :Write Ralink device L1/L0s Value =  0x%lx\n",
-                         Configuration));
-       }
-       DBGPRINT(RT_DEBUG_INFO,
-                ("PSM :RTMPrt3xSetPCIePowerLinkCtrl <==============\n"));
-}
diff --git a/drivers/staging/rt2860/rt_config.h b/drivers/staging/rt2860/rt_config.h
deleted file mode 100644 (file)
index d1adef8..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-       Module Name:
-       rt_config.h
-
-       Abstract:
-       Central header file to maintain all include files for all NDIS
-       miniport driver routines.
-
-       Revision History:
-       Who         When          What
-       --------    ----------    ----------------------------------------------
-       Paul Lin    08-01-2002    created
-
-*/
-#ifndef        __RT_CONFIG_H__
-#define        __RT_CONFIG_H__
-
-#include    "rtmp_type.h"
-#include "rtmp_os.h"
-
-#include "rtmp_def.h"
-#include "rtmp_chip.h"
-#include "rtmp_timer.h"
-
-#include    "oid.h"
-#include    "mlme.h"
-#include    "wpa.h"
-#include "crypt_md5.h"
-#include "crypt_sha2.h"
-#include "crypt_hmac.h"
-#include    "rtmp.h"
-#include       "ap.h"
-#include       "dfs.h"
-#include       "chlist.h"
-#include       "spectrum.h"
-
-#include "eeprom.h"
-#if defined(RTMP_PCI_SUPPORT) || defined(RTMP_USB_SUPPORT)
-#include "rtmp_mcu.h"
-#endif
-
-#ifdef IGMP_SNOOP_SUPPORT
-#include "igmp_snoop.h"
-#endif /* IGMP_SNOOP_SUPPORT // */
-
-#endif /* __RT_CONFIG_H__ */
diff --git a/drivers/staging/rt2860/rt_linux.c b/drivers/staging/rt2860/rt_linux.c
deleted file mode 100644 (file)
index 1583347..0000000
+++ /dev/null
@@ -1,1367 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
- */
-
-#include <linux/firmware.h>
-#include <linux/sched.h>
-#include <linux/slab.h>
-#include "rt_config.h"
-
-unsigned long RTDebugLevel = RT_DEBUG_ERROR;
-
-/* for wireless system event message */
-char const *pWirelessSysEventText[IW_SYS_EVENT_TYPE_NUM] = {
-       /* system status event */
-       "had associated successfully",  /* IW_ASSOC_EVENT_FLAG */
-       "had disassociated",    /* IW_DISASSOC_EVENT_FLAG */
-       "had deauthenticated",  /* IW_DEAUTH_EVENT_FLAG */
-       "had been aged-out and disassociated",  /* IW_AGEOUT_EVENT_FLAG */
-       "occurred CounterMeasures attack",      /* IW_COUNTER_MEASURES_EVENT_FLAG */
-       "occurred replay counter different in Key Handshaking", /* IW_REPLAY_COUNTER_DIFF_EVENT_FLAG */
-       "occurred RSNIE different in Key Handshaking",  /* IW_RSNIE_DIFF_EVENT_FLAG */
-       "occurred MIC different in Key Handshaking",    /* IW_MIC_DIFF_EVENT_FLAG */
-       "occurred ICV error in RX",     /* IW_ICV_ERROR_EVENT_FLAG */
-       "occurred MIC error in RX",     /* IW_MIC_ERROR_EVENT_FLAG */
-       "Group Key Handshaking timeout",        /* IW_GROUP_HS_TIMEOUT_EVENT_FLAG */
-       "Pairwise Key Handshaking timeout",     /* IW_PAIRWISE_HS_TIMEOUT_EVENT_FLAG */
-       "RSN IE sanity check failure",  /* IW_RSNIE_SANITY_FAIL_EVENT_FLAG */
-       "set key done in WPA/WPAPSK",   /* IW_SET_KEY_DONE_WPA1_EVENT_FLAG */
-       "set key done in WPA2/WPA2PSK", /* IW_SET_KEY_DONE_WPA2_EVENT_FLAG */
-       "connects with our wireless client",    /* IW_STA_LINKUP_EVENT_FLAG */
-       "disconnects with our wireless client", /* IW_STA_LINKDOWN_EVENT_FLAG */
-       "scan completed"        /* IW_SCAN_COMPLETED_EVENT_FLAG */
-           "scan terminate! Busy! Enqueue fail!"       /* IW_SCAN_ENQUEUE_FAIL_EVENT_FLAG */
-};
-
-/* for wireless IDS_spoof_attack event message */
-char const *pWirelessSpoofEventText[IW_SPOOF_EVENT_TYPE_NUM] = {
-       "detected conflict SSID",       /* IW_CONFLICT_SSID_EVENT_FLAG */
-       "detected spoofed association response",        /* IW_SPOOF_ASSOC_RESP_EVENT_FLAG */
-       "detected spoofed reassociation responses",     /* IW_SPOOF_REASSOC_RESP_EVENT_FLAG */
-       "detected spoofed probe response",      /* IW_SPOOF_PROBE_RESP_EVENT_FLAG */
-       "detected spoofed beacon",      /* IW_SPOOF_BEACON_EVENT_FLAG */
-       "detected spoofed disassociation",      /* IW_SPOOF_DISASSOC_EVENT_FLAG */
-       "detected spoofed authentication",      /* IW_SPOOF_AUTH_EVENT_FLAG */
-       "detected spoofed deauthentication",    /* IW_SPOOF_DEAUTH_EVENT_FLAG */
-       "detected spoofed unknown management frame",    /* IW_SPOOF_UNKNOWN_MGMT_EVENT_FLAG */
-       "detected replay attack"        /* IW_REPLAY_ATTACK_EVENT_FLAG */
-};
-
-/* for wireless IDS_flooding_attack event message */
-char const *pWirelessFloodEventText[IW_FLOOD_EVENT_TYPE_NUM] = {
-       "detected authentication flooding",     /* IW_FLOOD_AUTH_EVENT_FLAG */
-       "detected association request flooding",        /* IW_FLOOD_ASSOC_REQ_EVENT_FLAG */
-       "detected reassociation request flooding",      /* IW_FLOOD_REASSOC_REQ_EVENT_FLAG */
-       "detected probe request flooding",      /* IW_FLOOD_PROBE_REQ_EVENT_FLAG */
-       "detected disassociation flooding",     /* IW_FLOOD_DISASSOC_EVENT_FLAG */
-       "detected deauthentication flooding",   /* IW_FLOOD_DEAUTH_EVENT_FLAG */
-       "detected 802.1x eap-request flooding"  /* IW_FLOOD_EAP_REQ_EVENT_FLAG */
-};
-
-/* timeout -- ms */
-void RTMP_SetPeriodicTimer(struct timer_list *pTimer,
-                          IN unsigned long timeout)
-{
-       timeout = ((timeout * OS_HZ) / 1000);
-       pTimer->expires = jiffies + timeout;
-       add_timer(pTimer);
-}
-
-/* convert NdisMInitializeTimer --> RTMP_OS_Init_Timer */
-void RTMP_OS_Init_Timer(struct rt_rtmp_adapter *pAd,
-                       struct timer_list *pTimer,
-                       IN TIMER_FUNCTION function, void *data)
-{
-       init_timer(pTimer);
-       pTimer->data = (unsigned long)data;
-       pTimer->function = function;
-}
-
-void RTMP_OS_Add_Timer(struct timer_list *pTimer,
-                      IN unsigned long timeout)
-{
-       if (timer_pending(pTimer))
-               return;
-
-       timeout = ((timeout * OS_HZ) / 1000);
-       pTimer->expires = jiffies + timeout;
-       add_timer(pTimer);
-}
-
-void RTMP_OS_Mod_Timer(struct timer_list *pTimer,
-                      IN unsigned long timeout)
-{
-       timeout = ((timeout * OS_HZ) / 1000);
-       mod_timer(pTimer, jiffies + timeout);
-}
-
-void RTMP_OS_Del_Timer(struct timer_list *pTimer, OUT BOOLEAN *pCancelled)
-{
-       if (timer_pending(pTimer)) {
-               *pCancelled = del_timer_sync(pTimer);
-       } else {
-               *pCancelled = TRUE;
-       }
-
-}
-
-void RTMP_OS_Release_Packet(struct rt_rtmp_adapter *pAd, struct rt_queue_entry *pEntry)
-{
-       /*RTMPFreeNdisPacket(pAd, (struct sk_buff *)pEntry); */
-}
-
-/* Unify all delay routine by using udelay */
-void RTMPusecDelay(unsigned long usec)
-{
-       unsigned long i;
-
-       for (i = 0; i < (usec / 50); i++)
-               udelay(50);
-
-       if (usec % 50)
-               udelay(usec % 50);
-}
-
-void RTMP_GetCurrentSystemTime(LARGE_INTEGER *time)
-{
-       time->u.LowPart = jiffies;
-}
-
-/* pAd MUST allow to be NULL */
-int os_alloc_mem(struct rt_rtmp_adapter *pAd, u8 ** mem, unsigned long size)
-{
-       *mem = kmalloc(size, GFP_ATOMIC);
-       if (*mem)
-               return NDIS_STATUS_SUCCESS;
-       else
-               return NDIS_STATUS_FAILURE;
-}
-
-/* pAd MUST allow to be NULL */
-int os_free_mem(struct rt_rtmp_adapter *pAd, void *mem)
-{
-
-       ASSERT(mem);
-       kfree(mem);
-       return NDIS_STATUS_SUCCESS;
-}
-
-void *RtmpOSNetPktAlloc(struct rt_rtmp_adapter *pAd, IN int size)
-{
-       struct sk_buff *skb;
-       /* Add 2 more bytes for ip header alignment */
-       skb = dev_alloc_skb(size + 2);
-
-       return (void *)skb;
-}
-
-void *RTMP_AllocateFragPacketBuffer(struct rt_rtmp_adapter *pAd,
-                                          unsigned long Length)
-{
-       struct sk_buff *pkt;
-
-       pkt = dev_alloc_skb(Length);
-
-       if (pkt == NULL) {
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("can't allocate frag rx %ld size packet\n", Length));
-       }
-
-       if (pkt) {
-               RTMP_SET_PACKET_SOURCE(OSPKT_TO_RTPKT(pkt), PKTSRC_NDIS);
-       }
-
-       return (void *)pkt;
-}
-
-void *RTMP_AllocateTxPacketBuffer(struct rt_rtmp_adapter *pAd,
-                                        unsigned long Length,
-                                        IN BOOLEAN Cached,
-                                        void **VirtualAddress)
-{
-       struct sk_buff *pkt;
-
-       pkt = dev_alloc_skb(Length);
-
-       if (pkt == NULL) {
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("can't allocate tx %ld size packet\n", Length));
-       }
-
-       if (pkt) {
-               RTMP_SET_PACKET_SOURCE(OSPKT_TO_RTPKT(pkt), PKTSRC_NDIS);
-               *VirtualAddress = (void *)pkt->data;
-       } else {
-               *VirtualAddress = (void *)NULL;
-       }
-
-       return (void *)pkt;
-}
-
-void build_tx_packet(struct rt_rtmp_adapter *pAd,
-                    void *pPacket,
-                    u8 *pFrame, unsigned long FrameLen)
-{
-
-       struct sk_buff *pTxPkt;
-
-       ASSERT(pPacket);
-       pTxPkt = RTPKT_TO_OSPKT(pPacket);
-
-       NdisMoveMemory(skb_put(pTxPkt, FrameLen), pFrame, FrameLen);
-}
-
-void RTMPFreeAdapter(struct rt_rtmp_adapter *pAd)
-{
-       struct os_cookie *os_cookie;
-       int index;
-
-       os_cookie = (struct os_cookie *)pAd->OS_Cookie;
-
-       kfree(pAd->BeaconBuf);
-
-       NdisFreeSpinLock(&pAd->MgmtRingLock);
-
-#ifdef RTMP_MAC_PCI
-       NdisFreeSpinLock(&pAd->RxRingLock);
-#ifdef RT3090
-       NdisFreeSpinLock(&pAd->McuCmdLock);
-#endif /* RT3090 // */
-#endif /* RTMP_MAC_PCI // */
-
-       for (index = 0; index < NUM_OF_TX_RING; index++) {
-               NdisFreeSpinLock(&pAd->TxSwQueueLock[index]);
-               NdisFreeSpinLock(&pAd->DeQueueLock[index]);
-               pAd->DeQueueRunning[index] = FALSE;
-       }
-
-       NdisFreeSpinLock(&pAd->irq_lock);
-
-       release_firmware(pAd->firmware);
-
-       vfree(pAd);             /* pci_free_consistent(os_cookie->pci_dev,sizeof(struct rt_rtmp_adapter),pAd,os_cookie->pAd_pa); */
-       kfree(os_cookie);
-}
-
-BOOLEAN OS_Need_Clone_Packet(void)
-{
-       return FALSE;
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               clone an input NDIS PACKET to another one. The new internally created NDIS PACKET
-               must have only one NDIS BUFFER
-               return - byte copied. 0 means can't create NDIS PACKET
-               NOTE: internally created char should be destroyed by RTMPFreeNdisPacket
-
-       Arguments:
-               pAd     Pointer to our adapter
-               pInsAMSDUHdr    EWC A-MSDU format has extra 14-bytes header. if TRUE, insert this 14-byte hdr in front of MSDU.
-               *pSrcTotalLen                   return total packet length. This length is calculated with 802.3 format packet.
-
-       Return Value:
-               NDIS_STATUS_SUCCESS
-               NDIS_STATUS_FAILURE
-
-       Note:
-
-       ========================================================================
-*/
-int RTMPCloneNdisPacket(struct rt_rtmp_adapter *pAd,
-                               IN BOOLEAN pInsAMSDUHdr,
-                               void *pInPacket,
-                               void **ppOutPacket)
-{
-
-       struct sk_buff *pkt;
-
-       ASSERT(pInPacket);
-       ASSERT(ppOutPacket);
-
-       /* 1. Allocate a packet */
-       pkt = dev_alloc_skb(2048);
-
-       if (pkt == NULL) {
-               return NDIS_STATUS_FAILURE;
-       }
-
-       skb_put(pkt, GET_OS_PKT_LEN(pInPacket));
-       NdisMoveMemory(pkt->data, GET_OS_PKT_DATAPTR(pInPacket),
-                      GET_OS_PKT_LEN(pInPacket));
-       *ppOutPacket = OSPKT_TO_RTPKT(pkt);
-
-       RTMP_SET_PACKET_SOURCE(OSPKT_TO_RTPKT(pkt), PKTSRC_NDIS);
-
-       printk(KERN_DEBUG "###Clone###\n");
-
-       return NDIS_STATUS_SUCCESS;
-}
-
-/* the allocated NDIS PACKET must be freed via RTMPFreeNdisPacket() */
-int RTMPAllocateNdisPacket(struct rt_rtmp_adapter *pAd,
-                                  void **ppPacket,
-                                  u8 *pHeader,
-                                  u32 HeaderLen,
-                                  u8 *pData, u32 DataLen)
-{
-       void *pPacket;
-       ASSERT(pData);
-       ASSERT(DataLen);
-
-       /* 1. Allocate a packet */
-       pPacket =
-           (void **) dev_alloc_skb(HeaderLen + DataLen +
-                                          RTMP_PKT_TAIL_PADDING);
-       if (pPacket == NULL) {
-               *ppPacket = NULL;
-               pr_devel("RTMPAllocateNdisPacket Fail\n");
-
-               return NDIS_STATUS_FAILURE;
-       }
-       /* 2. clone the frame content */
-       if (HeaderLen > 0)
-               NdisMoveMemory(GET_OS_PKT_DATAPTR(pPacket), pHeader, HeaderLen);
-       if (DataLen > 0)
-               NdisMoveMemory(GET_OS_PKT_DATAPTR(pPacket) + HeaderLen, pData,
-                              DataLen);
-
-       /* 3. update length of packet */
-       skb_put(GET_OS_PKT_TYPE(pPacket), HeaderLen + DataLen);
-
-       RTMP_SET_PACKET_SOURCE(pPacket, PKTSRC_NDIS);
-/*      printk("%s : pPacket = %p, len = %d\n", __func__, pPacket, GET_OS_PKT_LEN(pPacket)); */
-       *ppPacket = pPacket;
-       return NDIS_STATUS_SUCCESS;
-}
-
-/*
-  ========================================================================
-  Description:
-       This routine frees a miniport internally allocated char and its
-       corresponding NDIS_BUFFER and allocated memory.
-  ========================================================================
-*/
-void RTMPFreeNdisPacket(struct rt_rtmp_adapter *pAd, void *pPacket)
-{
-       dev_kfree_skb_any(RTPKT_TO_OSPKT(pPacket));
-}
-
-/* IRQL = DISPATCH_LEVEL */
-/* NOTE: we do have an assumption here, that Byte0 and Byte1 always reasid at the same */
-/*                       scatter gather buffer */
-int Sniff2BytesFromNdisBuffer(char *pFirstBuffer,
-                                     u8 DesiredOffset,
-                                     u8 *pByte0, u8 *pByte1)
-{
-       *pByte0 = *(u8 *)(pFirstBuffer + DesiredOffset);
-       *pByte1 = *(u8 *)(pFirstBuffer + DesiredOffset + 1);
-
-       return NDIS_STATUS_SUCCESS;
-}
-
-void RTMP_QueryPacketInfo(void *pPacket,
-                         struct rt_packet_info *pPacketInfo,
-                         u8 **pSrcBufVA, u32 * pSrcBufLen)
-{
-       pPacketInfo->BufferCount = 1;
-       pPacketInfo->pFirstBuffer = (char *)GET_OS_PKT_DATAPTR(pPacket);
-       pPacketInfo->PhysicalBufferCount = 1;
-       pPacketInfo->TotalPacketLength = GET_OS_PKT_LEN(pPacket);
-
-       *pSrcBufVA = GET_OS_PKT_DATAPTR(pPacket);
-       *pSrcBufLen = GET_OS_PKT_LEN(pPacket);
-}
-
-void RTMP_QueryNextPacketInfo(void **ppPacket,
-                             struct rt_packet_info *pPacketInfo,
-                             u8 **pSrcBufVA, u32 * pSrcBufLen)
-{
-       void *pPacket = NULL;
-
-       if (*ppPacket)
-               pPacket = GET_OS_PKT_NEXT(*ppPacket);
-
-       if (pPacket) {
-               pPacketInfo->BufferCount = 1;
-               pPacketInfo->pFirstBuffer =
-                   (char *)GET_OS_PKT_DATAPTR(pPacket);
-               pPacketInfo->PhysicalBufferCount = 1;
-               pPacketInfo->TotalPacketLength = GET_OS_PKT_LEN(pPacket);
-
-               *pSrcBufVA = GET_OS_PKT_DATAPTR(pPacket);
-               *pSrcBufLen = GET_OS_PKT_LEN(pPacket);
-               *ppPacket = GET_OS_PKT_NEXT(pPacket);
-       } else {
-               pPacketInfo->BufferCount = 0;
-               pPacketInfo->pFirstBuffer = NULL;
-               pPacketInfo->PhysicalBufferCount = 0;
-               pPacketInfo->TotalPacketLength = 0;
-
-               *pSrcBufVA = NULL;
-               *pSrcBufLen = 0;
-               *ppPacket = NULL;
-       }
-}
-
-void *DuplicatePacket(struct rt_rtmp_adapter *pAd,
-                            void *pPacket, u8 FromWhichBSSID)
-{
-       struct sk_buff *skb;
-       void *pRetPacket = NULL;
-       u16 DataSize;
-       u8 *pData;
-
-       DataSize = (u16)GET_OS_PKT_LEN(pPacket);
-       pData = (u8 *)GET_OS_PKT_DATAPTR(pPacket);
-
-       skb = skb_clone(RTPKT_TO_OSPKT(pPacket), MEM_ALLOC_FLAG);
-       if (skb) {
-               skb->dev = get_netdev_from_bssid(pAd, FromWhichBSSID);
-               pRetPacket = OSPKT_TO_RTPKT(skb);
-       }
-
-       return pRetPacket;
-
-}
-
-void *duplicate_pkt(struct rt_rtmp_adapter *pAd,
-                          u8 *pHeader802_3,
-                          u32 HdrLen,
-                          u8 *pData,
-                          unsigned long DataSize, u8 FromWhichBSSID)
-{
-       struct sk_buff *skb;
-       void *pPacket = NULL;
-
-       skb = __dev_alloc_skb(HdrLen + DataSize + 2, MEM_ALLOC_FLAG);
-       if (skb != NULL) {
-               skb_reserve(skb, 2);
-               NdisMoveMemory(skb_tail_pointer(skb), pHeader802_3, HdrLen);
-               skb_put(skb, HdrLen);
-               NdisMoveMemory(skb_tail_pointer(skb), pData, DataSize);
-               skb_put(skb, DataSize);
-               skb->dev = get_netdev_from_bssid(pAd, FromWhichBSSID);
-               pPacket = OSPKT_TO_RTPKT(skb);
-       }
-
-       return pPacket;
-}
-
-#define TKIP_TX_MIC_SIZE               8
-void *duplicate_pkt_with_TKIP_MIC(struct rt_rtmp_adapter *pAd,
-                                        void *pPacket)
-{
-       struct sk_buff *skb, *newskb;
-
-       skb = RTPKT_TO_OSPKT(pPacket);
-       if (skb_tailroom(skb) < TKIP_TX_MIC_SIZE) {
-               /* alloc a new skb and copy the packet */
-               newskb =
-                   skb_copy_expand(skb, skb_headroom(skb), TKIP_TX_MIC_SIZE,
-                                   GFP_ATOMIC);
-               dev_kfree_skb_any(skb);
-               if (newskb == NULL) {
-                       DBGPRINT(RT_DEBUG_ERROR,
-                                ("Extend Tx.MIC for packet failed!, dropping packet!\n"));
-                       return NULL;
-               }
-               skb = newskb;
-       }
-
-       return OSPKT_TO_RTPKT(skb);
-}
-
-void *ClonePacket(struct rt_rtmp_adapter *pAd,
-                        void *pPacket,
-                        u8 *pData, unsigned long DataSize)
-{
-       struct sk_buff *pRxPkt;
-       struct sk_buff *pClonedPkt;
-
-       ASSERT(pPacket);
-       pRxPkt = RTPKT_TO_OSPKT(pPacket);
-
-       /* clone the packet */
-       pClonedPkt = skb_clone(pRxPkt, MEM_ALLOC_FLAG);
-
-       if (pClonedPkt) {
-               /* set the correct dataptr and data len */
-               pClonedPkt->dev = pRxPkt->dev;
-               pClonedPkt->data = pData;
-               pClonedPkt->len = DataSize;
-               skb_set_tail_pointer(pClonedPkt, DataSize)
-               ASSERT(DataSize < 1530);
-       }
-       return pClonedPkt;
-}
-
-/* */
-/* change OS packet DataPtr and DataLen */
-/* */
-void update_os_packet_info(struct rt_rtmp_adapter *pAd,
-                          struct rt_rx_blk *pRxBlk, u8 FromWhichBSSID)
-{
-       struct sk_buff *pOSPkt;
-
-       ASSERT(pRxBlk->pRxPacket);
-       pOSPkt = RTPKT_TO_OSPKT(pRxBlk->pRxPacket);
-
-       pOSPkt->dev = get_netdev_from_bssid(pAd, FromWhichBSSID);
-       pOSPkt->data = pRxBlk->pData;
-       pOSPkt->len = pRxBlk->DataSize;
-       skb_set_tail_pointer(pOSPkt, pOSPkt->len);
-}
-
-void wlan_802_11_to_802_3_packet(struct rt_rtmp_adapter *pAd,
-                                struct rt_rx_blk *pRxBlk,
-                                u8 *pHeader802_3,
-                                u8 FromWhichBSSID)
-{
-       struct sk_buff *pOSPkt;
-
-       ASSERT(pRxBlk->pRxPacket);
-       ASSERT(pHeader802_3);
-
-       pOSPkt = RTPKT_TO_OSPKT(pRxBlk->pRxPacket);
-
-       pOSPkt->dev = get_netdev_from_bssid(pAd, FromWhichBSSID);
-       pOSPkt->data = pRxBlk->pData;
-       pOSPkt->len = pRxBlk->DataSize;
-       skb_set_tail_pointer(pOSPkt, pOSPkt->len);
-
-       /* */
-       /* copy 802.3 header */
-       /* */
-       /* */
-
-       NdisMoveMemory(skb_push(pOSPkt, LENGTH_802_3), pHeader802_3,
-                      LENGTH_802_3);
-}
-
-void announce_802_3_packet(struct rt_rtmp_adapter *pAd, void *pPacket)
-{
-
-       struct sk_buff *pRxPkt;
-
-       ASSERT(pPacket);
-
-       pRxPkt = RTPKT_TO_OSPKT(pPacket);
-
-       /* Push up the protocol stack */
-       pRxPkt->protocol = eth_type_trans(pRxPkt, pRxPkt->dev);
-
-       netif_rx(pRxPkt);
-}
-
-struct rt_rtmp_sg_list *
-rt_get_sg_list_from_packet(void *pPacket, struct rt_rtmp_sg_list *sg)
-{
-       sg->NumberOfElements = 1;
-       sg->Elements[0].Address = GET_OS_PKT_DATAPTR(pPacket);
-       sg->Elements[0].Length = GET_OS_PKT_LEN(pPacket);
-       return sg;
-}
-
-void hex_dump(char *str, unsigned char *pSrcBufVA, unsigned int SrcBufLen)
-{
-       unsigned char *pt;
-       int x;
-
-       if (RTDebugLevel < RT_DEBUG_TRACE)
-               return;
-
-       pt = pSrcBufVA;
-       printk(KERN_DEBUG "%s: %p, len = %d\n", str, pSrcBufVA, SrcBufLen);
-       for (x = 0; x < SrcBufLen; x++) {
-               if (x % 16 == 0)
-                       printk(KERN_DEBUG "0x%04x : ", x);
-               printk(KERN_DEBUG "%02x ", ((unsigned char)pt[x]));
-               if (x % 16 == 15)
-                       printk(KERN_DEBUG "\n");
-       }
-       printk(KERN_DEBUG "\n");
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Send log message through wireless event
-
-               Support standard iw_event with IWEVCUSTOM. It is used below.
-
-               iwreq_data.data.flags is used to store event_flag that is defined by user.
-               iwreq_data.data.length is the length of the event log.
-
-               The format of the event log is composed of the entry's MAC address and
-               the desired log message (refer to pWirelessEventText).
-
-                       ex: 11:22:33:44:55:66 has associated successfully
-
-               p.s. The requirement of Wireless Extension is v15 or newer.
-
-       ========================================================================
-*/
-void RTMPSendWirelessEvent(struct rt_rtmp_adapter *pAd,
-                          u16 Event_flag,
-                          u8 *pAddr, u8 BssIdx, char Rssi)
-{
-
-       /*union         iwreq_data      wrqu; */
-       char *pBuf = NULL, *pBufPtr = NULL;
-       u16 event, type, BufLen;
-       u8 event_table_len = 0;
-
-       type = Event_flag & 0xFF00;
-       event = Event_flag & 0x00FF;
-
-       switch (type) {
-       case IW_SYS_EVENT_FLAG_START:
-               event_table_len = IW_SYS_EVENT_TYPE_NUM;
-               break;
-
-       case IW_SPOOF_EVENT_FLAG_START:
-               event_table_len = IW_SPOOF_EVENT_TYPE_NUM;
-               break;
-
-       case IW_FLOOD_EVENT_FLAG_START:
-               event_table_len = IW_FLOOD_EVENT_TYPE_NUM;
-               break;
-       }
-
-       if (event_table_len == 0) {
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("%s : The type(%0x02x) is not valid.\n", __func__,
-                         type));
-               return;
-       }
-
-       if (event >= event_table_len) {
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("%s : The event(%0x02x) is not valid.\n", __func__,
-                         event));
-               return;
-       }
-       /*Allocate memory and copy the msg. */
-       pBuf = kmalloc(IW_CUSTOM_MAX_LEN, GFP_ATOMIC);
-       if (pBuf != NULL) {
-               /*Prepare the payload */
-               memset(pBuf, 0, IW_CUSTOM_MAX_LEN);
-
-               pBufPtr = pBuf;
-
-               if (pAddr)
-                       pBufPtr +=
-                           sprintf(pBufPtr, "(RT2860) STA(%pM) ", pAddr);
-               else if (BssIdx < MAX_MBSSID_NUM)
-                       pBufPtr +=
-                           sprintf(pBufPtr, "(RT2860) BSS(wlan%d) ", BssIdx);
-               else
-                       pBufPtr += sprintf(pBufPtr, "(RT2860) ");
-
-               if (type == IW_SYS_EVENT_FLAG_START)
-                       pBufPtr +=
-                           sprintf(pBufPtr, "%s",
-                                   pWirelessSysEventText[event]);
-               else if (type == IW_SPOOF_EVENT_FLAG_START)
-                       pBufPtr +=
-                           sprintf(pBufPtr, "%s (RSSI=%d)",
-                                   pWirelessSpoofEventText[event], Rssi);
-               else if (type == IW_FLOOD_EVENT_FLAG_START)
-                       pBufPtr +=
-                           sprintf(pBufPtr, "%s",
-                                   pWirelessFloodEventText[event]);
-               else
-                       pBufPtr += sprintf(pBufPtr, "%s", "unknown event");
-
-               pBufPtr[pBufPtr - pBuf] = '\0';
-               BufLen = pBufPtr - pBuf;
-
-               RtmpOSWrielessEventSend(pAd, IWEVCUSTOM, Event_flag, NULL,
-                                       (u8 *)pBuf, BufLen);
-               /*DBGPRINT(RT_DEBUG_TRACE, ("%s : %s\n", __func__, pBuf)); */
-
-               kfree(pBuf);
-       } else
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("%s : Can't allocate memory for wireless event.\n",
-                         __func__));
-}
-
-void send_monitor_packets(struct rt_rtmp_adapter *pAd, struct rt_rx_blk *pRxBlk)
-{
-       struct sk_buff *pOSPkt;
-       struct rt_wlan_ng_prism2_header *ph;
-       int rate_index = 0;
-       u16 header_len = 0;
-       u8 temp_header[40] = { 0 };
-
-       u_int32_t ralinkrate[256] = { 2, 4, 11, 22, 12, 18, 24, 36, 48, 72, 96, 108, 109, 110, 111, 112, 13, 26, 39, 52, 78, 104, 117, 130, 26, 52, 78, 104, 156, 208, 234, 260, 27, 54, 81, 108, 162, 216, 243, 270,   /* Last 38 */
-               54, 108, 162, 216, 324, 432, 486, 540, 14, 29, 43, 57, 87, 115,
-                   130, 144, 29, 59, 87, 115, 173, 230, 260, 288, 30, 60, 90,
-                   120, 180, 240, 270, 300, 60, 120, 180, 240, 360, 480, 540,
-                   600, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
-               11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
-                   27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
-                   42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
-                   57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71,
-                   72, 73, 74, 75, 76, 77, 78, 79, 80
-       };
-
-       ASSERT(pRxBlk->pRxPacket);
-       if (pRxBlk->DataSize < 10) {
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("%s : Size is too small! (%d)\n", __func__,
-                         pRxBlk->DataSize));
-               goto err_free_sk_buff;
-       }
-
-       if (pRxBlk->DataSize + sizeof(struct rt_wlan_ng_prism2_header) >
-           RX_BUFFER_AGGRESIZE) {
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("%s : Size is too large! (%zu)\n", __func__,
-                         pRxBlk->DataSize + sizeof(struct rt_wlan_ng_prism2_header)));
-               goto err_free_sk_buff;
-       }
-
-       pOSPkt = RTPKT_TO_OSPKT(pRxBlk->pRxPacket);
-       pOSPkt->dev = get_netdev_from_bssid(pAd, BSS0);
-       if (pRxBlk->pHeader->FC.Type == BTYPE_DATA) {
-               pRxBlk->DataSize -= LENGTH_802_11;
-               if ((pRxBlk->pHeader->FC.ToDs == 1) &&
-                   (pRxBlk->pHeader->FC.FrDs == 1))
-                       header_len = LENGTH_802_11_WITH_ADDR4;
-               else
-                       header_len = LENGTH_802_11;
-
-               /* QOS */
-               if (pRxBlk->pHeader->FC.SubType & 0x08) {
-                       header_len += 2;
-                       /* Data skip QOS control field */
-                       pRxBlk->DataSize -= 2;
-               }
-               /* Order bit: A-Ralink or HTC+ */
-               if (pRxBlk->pHeader->FC.Order) {
-                       header_len += 4;
-                       /* Data skip HTC control field */
-                       pRxBlk->DataSize -= 4;
-               }
-               /* Copy Header */
-               if (header_len <= 40)
-                       NdisMoveMemory(temp_header, pRxBlk->pData, header_len);
-
-               /* skip HW padding */
-               if (pRxBlk->RxD.L2PAD)
-                       pRxBlk->pData += (header_len + 2);
-               else
-                       pRxBlk->pData += header_len;
-       }                       /*end if */
-
-       if (pRxBlk->DataSize < pOSPkt->len) {
-               skb_trim(pOSPkt, pRxBlk->DataSize);
-       } else {
-               skb_put(pOSPkt, (pRxBlk->DataSize - pOSPkt->len));
-       }                       /*end if */
-
-       if ((pRxBlk->pData - pOSPkt->data) > 0) {
-               skb_put(pOSPkt, (pRxBlk->pData - pOSPkt->data));
-               skb_pull(pOSPkt, (pRxBlk->pData - pOSPkt->data));
-       }                       /*end if */
-
-       if (skb_headroom(pOSPkt) < (sizeof(struct rt_wlan_ng_prism2_header) + header_len)) {
-               if (pskb_expand_head
-                   (pOSPkt, (sizeof(struct rt_wlan_ng_prism2_header) + header_len), 0,
-                    GFP_ATOMIC)) {
-                       DBGPRINT(RT_DEBUG_ERROR,
-                                ("%s : Reallocate header size of sk_buff fail!\n",
-                                 __func__));
-                       goto err_free_sk_buff;
-               }               /*end if */
-       }                       /*end if */
-
-       if (header_len > 0)
-               NdisMoveMemory(skb_push(pOSPkt, header_len), temp_header,
-                              header_len);
-
-       ph = (struct rt_wlan_ng_prism2_header *)skb_push(pOSPkt,
-                                               sizeof(struct rt_wlan_ng_prism2_header));
-       NdisZeroMemory(ph, sizeof(struct rt_wlan_ng_prism2_header));
-
-       ph->msgcode = DIDmsg_lnxind_wlansniffrm;
-       ph->msglen = sizeof(struct rt_wlan_ng_prism2_header);
-       strcpy((char *)ph->devname, (char *)pAd->net_dev->name);
-
-       ph->hosttime.did = DIDmsg_lnxind_wlansniffrm_hosttime;
-       ph->hosttime.status = 0;
-       ph->hosttime.len = 4;
-       ph->hosttime.data = jiffies;
-
-       ph->mactime.did = DIDmsg_lnxind_wlansniffrm_mactime;
-       ph->mactime.status = 0;
-       ph->mactime.len = 0;
-       ph->mactime.data = 0;
-
-       ph->istx.did = DIDmsg_lnxind_wlansniffrm_istx;
-       ph->istx.status = 0;
-       ph->istx.len = 0;
-       ph->istx.data = 0;
-
-       ph->channel.did = DIDmsg_lnxind_wlansniffrm_channel;
-       ph->channel.status = 0;
-       ph->channel.len = 4;
-
-       ph->channel.data = (u_int32_t) pAd->CommonCfg.Channel;
-
-       ph->rssi.did = DIDmsg_lnxind_wlansniffrm_rssi;
-       ph->rssi.status = 0;
-       ph->rssi.len = 4;
-       ph->rssi.data =
-           (u_int32_t) RTMPMaxRssi(pAd,
-                                   ConvertToRssi(pAd, pRxBlk->pRxWI->RSSI0,
-                                                 RSSI_0), ConvertToRssi(pAd,
-                                                                        pRxBlk->
-                                                                        pRxWI->
-                                                                        RSSI1,
-                                                                        RSSI_1),
-                                   ConvertToRssi(pAd, pRxBlk->pRxWI->RSSI2,
-                                                 RSSI_2));
-
-       ph->signal.did = DIDmsg_lnxind_wlansniffrm_signal;
-       ph->signal.status = 0;
-       ph->signal.len = 4;
-       ph->signal.data = 0;    /*rssi + noise; */
-
-       ph->noise.did = DIDmsg_lnxind_wlansniffrm_noise;
-       ph->noise.status = 0;
-       ph->noise.len = 4;
-       ph->noise.data = 0;
-
-       if (pRxBlk->pRxWI->PHYMODE >= MODE_HTMIX) {
-               rate_index =
-                   16 + ((u8)pRxBlk->pRxWI->BW * 16) +
-                   ((u8)pRxBlk->pRxWI->ShortGI * 32) +
-                   ((u8)pRxBlk->pRxWI->MCS);
-       } else if (pRxBlk->pRxWI->PHYMODE == MODE_OFDM)
-               rate_index = (u8)(pRxBlk->pRxWI->MCS) + 4;
-       else
-               rate_index = (u8)(pRxBlk->pRxWI->MCS);
-       if (rate_index < 0)
-               rate_index = 0;
-       if (rate_index > 255)
-               rate_index = 255;
-
-       ph->rate.did = DIDmsg_lnxind_wlansniffrm_rate;
-       ph->rate.status = 0;
-       ph->rate.len = 4;
-       ph->rate.data = ralinkrate[rate_index];
-
-       ph->frmlen.did = DIDmsg_lnxind_wlansniffrm_frmlen;
-       ph->frmlen.status = 0;
-       ph->frmlen.len = 4;
-       ph->frmlen.data = (u_int32_t) pRxBlk->DataSize;
-
-       pOSPkt->pkt_type = PACKET_OTHERHOST;
-       pOSPkt->protocol = eth_type_trans(pOSPkt, pOSPkt->dev);
-       pOSPkt->ip_summed = CHECKSUM_NONE;
-       netif_rx(pOSPkt);
-
-       return;
-
-err_free_sk_buff:
-       RELEASE_NDIS_PACKET(pAd, pRxBlk->pRxPacket, NDIS_STATUS_FAILURE);
-       return;
-
-}
-
-/*******************************************************************************
-
-       Device IRQ related functions.
-
- *******************************************************************************/
-int RtmpOSIRQRequest(struct net_device *pNetDev)
-{
-#ifdef RTMP_PCI_SUPPORT
-       struct net_device *net_dev = pNetDev;
-       struct rt_rtmp_adapter *pAd = NULL;
-       int retval = 0;
-
-       GET_PAD_FROM_NET_DEV(pAd, pNetDev);
-
-       ASSERT(pAd);
-
-       if (pAd->infType == RTMP_DEV_INF_PCI) {
-               struct os_cookie *_pObj = (struct os_cookie *)(pAd->OS_Cookie);
-               RTMP_MSI_ENABLE(pAd);
-               retval =
-                   request_irq(_pObj->pci_dev->irq, rt2860_interrupt, SA_SHIRQ,
-                               (net_dev)->name, (net_dev));
-               if (retval != 0)
-                       printk(KERN_ERR "rt2860: request_irq  ERROR(%d)\n", retval);
-       }
-
-       return retval;
-#else
-       return 0;
-#endif
-}
-
-int RtmpOSIRQRelease(struct net_device *pNetDev)
-{
-       struct net_device *net_dev = pNetDev;
-       struct rt_rtmp_adapter *pAd = NULL;
-
-       GET_PAD_FROM_NET_DEV(pAd, net_dev);
-
-       ASSERT(pAd);
-
-#ifdef RTMP_PCI_SUPPORT
-       if (pAd->infType == RTMP_DEV_INF_PCI) {
-               struct os_cookie *pObj = (struct os_cookie *)(pAd->OS_Cookie);
-               synchronize_irq(pObj->pci_dev->irq);
-               free_irq(pObj->pci_dev->irq, (net_dev));
-               RTMP_MSI_DISABLE(pAd);
-       }
-#endif /* RTMP_PCI_SUPPORT // */
-
-       return 0;
-}
-
-/*******************************************************************************
-
-       File open/close related functions.
-
- *******************************************************************************/
-struct file *RtmpOSFileOpen(char *pPath, int flag, int mode)
-{
-       struct file *filePtr;
-
-       filePtr = filp_open(pPath, flag, 0);
-       if (IS_ERR(filePtr)) {
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("%s(): Error %ld opening %s\n", __func__,
-                         -PTR_ERR(filePtr), pPath));
-       }
-
-       return (struct file *)filePtr;
-}
-
-int RtmpOSFileClose(struct file *osfd)
-{
-       filp_close(osfd, NULL);
-       return 0;
-}
-
-void RtmpOSFileSeek(struct file *osfd, int offset)
-{
-       osfd->f_pos = offset;
-}
-
-int RtmpOSFileRead(struct file *osfd, char *pDataPtr, int readLen)
-{
-       /* The object must have a read method */
-       if (osfd->f_op && osfd->f_op->read) {
-               return osfd->f_op->read(osfd, pDataPtr, readLen, &osfd->f_pos);
-       } else {
-               DBGPRINT(RT_DEBUG_ERROR, ("no file read method\n"));
-               return -1;
-       }
-}
-
-int RtmpOSFileWrite(struct file *osfd, char *pDataPtr, int writeLen)
-{
-       return osfd->f_op->write(osfd, pDataPtr, (size_t) writeLen,
-                                &osfd->f_pos);
-}
-
-/*******************************************************************************
-
-       Task create/management/kill related functions.
-
- *******************************************************************************/
-int RtmpOSTaskKill(struct rt_rtmp_os_task *pTask)
-{
-       struct rt_rtmp_adapter *pAd;
-       int ret = NDIS_STATUS_FAILURE;
-
-       pAd = pTask->priv;
-
-#ifdef KTHREAD_SUPPORT
-       if (pTask->kthread_task) {
-               kthread_stop(pTask->kthread_task);
-               ret = NDIS_STATUS_SUCCESS;
-       }
-#else
-       CHECK_PID_LEGALITY(pTask->taskPID) {
-               printk(KERN_INFO "Terminate the task(%s) with pid(%d)!\n",
-                      pTask->taskName, GET_PID_NUMBER(pTask->taskPID));
-               mb();
-               pTask->task_killed = 1;
-               mb();
-               ret = KILL_THREAD_PID(pTask->taskPID, SIGTERM, 1);
-               if (ret) {
-                       printk(KERN_WARNING
-                              "kill task(%s) with pid(%d) failed(retVal=%d)!\n",
-                              pTask->taskName, GET_PID_NUMBER(pTask->taskPID),
-                              ret);
-               } else {
-                       wait_for_completion(&pTask->taskComplete);
-                       pTask->taskPID = THREAD_PID_INIT_VALUE;
-                       pTask->task_killed = 0;
-                       ret = NDIS_STATUS_SUCCESS;
-               }
-       }
-#endif
-
-       return ret;
-
-}
-
-int RtmpOSTaskNotifyToExit(struct rt_rtmp_os_task *pTask)
-{
-
-#ifndef KTHREAD_SUPPORT
-       complete_and_exit(&pTask->taskComplete, 0);
-#endif
-
-       return 0;
-}
-
-void RtmpOSTaskCustomize(struct rt_rtmp_os_task *pTask)
-{
-
-#ifndef KTHREAD_SUPPORT
-
-       daemonize((char *)&pTask->taskName[0] /*"%s",pAd->net_dev->name */);
-
-       allow_signal(SIGTERM);
-       allow_signal(SIGKILL);
-       current->flags |= PF_NOFREEZE;
-
-       /* signal that we've started the thread */
-       complete(&pTask->taskComplete);
-
-#endif
-}
-
-int RtmpOSTaskAttach(struct rt_rtmp_os_task *pTask,
-                            IN int (*fn) (void *), IN void *arg)
-{
-       int status = NDIS_STATUS_SUCCESS;
-
-#ifdef KTHREAD_SUPPORT
-       pTask->task_killed = 0;
-       pTask->kthread_task = NULL;
-       pTask->kthread_task = kthread_run(fn, arg, pTask->taskName);
-       if (IS_ERR(pTask->kthread_task))
-               status = NDIS_STATUS_FAILURE;
-#else
-       pid_number = kernel_thread(fn, arg, RTMP_OS_MGMT_TASK_FLAGS);
-       if (pid_number < 0) {
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("Attach task(%s) failed!\n", pTask->taskName));
-               status = NDIS_STATUS_FAILURE;
-       } else {
-               pTask->taskPID = GET_PID(pid_number);
-
-               /* Wait for the thread to start */
-               wait_for_completion(&pTask->taskComplete);
-               status = NDIS_STATUS_SUCCESS;
-       }
-#endif
-       return status;
-}
-
-int RtmpOSTaskInit(struct rt_rtmp_os_task *pTask,
-                          char *pTaskName, void * pPriv)
-{
-       int len;
-
-       ASSERT(pTask);
-
-#ifndef KTHREAD_SUPPORT
-       NdisZeroMemory((u8 *)(pTask), sizeof(struct rt_rtmp_os_task));
-#endif
-
-       len = strlen(pTaskName);
-       len =
-           len >
-           (RTMP_OS_TASK_NAME_LEN - 1) ? (RTMP_OS_TASK_NAME_LEN - 1) : len;
-       NdisMoveMemory(&pTask->taskName[0], pTaskName, len);
-       pTask->priv = pPriv;
-
-#ifndef KTHREAD_SUPPORT
-       RTMP_SEM_EVENT_INIT_LOCKED(&(pTask->taskSema));
-       pTask->taskPID = THREAD_PID_INIT_VALUE;
-
-       init_completion(&pTask->taskComplete);
-#endif
-
-       return NDIS_STATUS_SUCCESS;
-}
-
-void RTMP_IndicateMediaState(struct rt_rtmp_adapter *pAd)
-{
-       if (pAd->CommonCfg.bWirelessEvent) {
-               if (pAd->IndicateMediaState == NdisMediaStateConnected) {
-                       RTMPSendWirelessEvent(pAd, IW_STA_LINKUP_EVENT_FLAG,
-                                             pAd->MacTab.Content[BSSID_WCID].
-                                             Addr, BSS0, 0);
-               } else {
-                       RTMPSendWirelessEvent(pAd, IW_STA_LINKDOWN_EVENT_FLAG,
-                                             pAd->MacTab.Content[BSSID_WCID].
-                                             Addr, BSS0, 0);
-               }
-       }
-}
-
-int RtmpOSWrielessEventSend(struct rt_rtmp_adapter *pAd,
-                           u32 eventType,
-                           int flags,
-                           u8 *pSrcMac,
-                           u8 *pData, u32 dataLen)
-{
-       union iwreq_data wrqu;
-
-       memset(&wrqu, 0, sizeof(wrqu));
-
-       if (flags > -1)
-               wrqu.data.flags = flags;
-
-       if (pSrcMac)
-               memcpy(wrqu.ap_addr.sa_data, pSrcMac, MAC_ADDR_LEN);
-
-       if ((pData != NULL) && (dataLen > 0))
-               wrqu.data.length = dataLen;
-
-       wireless_send_event(pAd->net_dev, eventType, &wrqu, (char *)pData);
-       return 0;
-}
-
-int RtmpOSNetDevAddrSet(struct net_device *pNetDev, u8 *pMacAddr)
-{
-       struct net_device *net_dev;
-       struct rt_rtmp_adapter *pAd;
-
-       net_dev = pNetDev;
-       GET_PAD_FROM_NET_DEV(pAd, net_dev);
-
-       /* work-around for SuSE, due to them having their own interface name management system. */
-       {
-               NdisZeroMemory(pAd->StaCfg.dev_name, 16);
-               NdisMoveMemory(pAd->StaCfg.dev_name, net_dev->name,
-                              strlen(net_dev->name));
-       }
-
-       NdisMoveMemory(net_dev->dev_addr, pMacAddr, 6);
-
-       return 0;
-}
-
-/*
-  *    Assign the network dev name for created Ralink WiFi interface.
-  */
-static int RtmpOSNetDevRequestName(struct rt_rtmp_adapter *pAd,
-                                  struct net_device *dev,
-                                  char *pPrefixStr, int devIdx)
-{
-       struct net_device *existNetDev;
-       char suffixName[IFNAMSIZ];
-       char desiredName[IFNAMSIZ];
-       int ifNameIdx, prefixLen, slotNameLen;
-       int Status;
-
-       prefixLen = strlen(pPrefixStr);
-       ASSERT((prefixLen < IFNAMSIZ));
-
-       for (ifNameIdx = devIdx; ifNameIdx < 32; ifNameIdx++) {
-               memset(suffixName, 0, IFNAMSIZ);
-               memset(desiredName, 0, IFNAMSIZ);
-               strncpy(&desiredName[0], pPrefixStr, prefixLen);
-
-               sprintf(suffixName, "%d", ifNameIdx);
-
-               slotNameLen = strlen(suffixName);
-               ASSERT(((slotNameLen + prefixLen) < IFNAMSIZ));
-               strcat(desiredName, suffixName);
-
-               existNetDev = RtmpOSNetDevGetByName(dev, &desiredName[0]);
-               if (existNetDev == NULL)
-                       break;
-               else
-                       RtmpOSNetDeviceRefPut(existNetDev);
-       }
-
-       if (ifNameIdx < 32) {
-               strcpy(&dev->name[0], &desiredName[0]);
-               Status = NDIS_STATUS_SUCCESS;
-       } else {
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("Cannot request DevName with preifx(%s) and in range(0~32) as suffix from OS!\n",
-                         pPrefixStr));
-               Status = NDIS_STATUS_FAILURE;
-       }
-
-       return Status;
-}
-
-void RtmpOSNetDevClose(struct net_device *pNetDev)
-{
-       dev_close(pNetDev);
-}
-
-void RtmpOSNetDevFree(struct net_device *pNetDev)
-{
-       ASSERT(pNetDev);
-
-       free_netdev(pNetDev);
-}
-
-int RtmpOSNetDevAlloc(struct net_device **new_dev_p, u32 privDataSize)
-{
-       /* assign it as null first. */
-       *new_dev_p = NULL;
-
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("Allocate a net device with private data size=%d!\n",
-                 privDataSize));
-       *new_dev_p = alloc_etherdev(privDataSize);
-       if (*new_dev_p)
-               return NDIS_STATUS_SUCCESS;
-       else
-               return NDIS_STATUS_FAILURE;
-}
-
-struct net_device *RtmpOSNetDevGetByName(struct net_device *pNetDev, char *pDevName)
-{
-       struct net_device *pTargetNetDev = NULL;
-
-       pTargetNetDev = dev_get_by_name(dev_net(pNetDev), pDevName);
-
-       return pTargetNetDev;
-}
-
-void RtmpOSNetDeviceRefPut(struct net_device *pNetDev)
-{
-       /*
-          every time dev_get_by_name is called, and it has returned a valid struct
-          net_device*, dev_put should be called afterwards, because otherwise the
-          machine hangs when the device is unregistered (since dev->refcnt > 1).
-        */
-       if (pNetDev)
-               dev_put(pNetDev);
-}
-
-int RtmpOSNetDevDestory(struct rt_rtmp_adapter *pAd, struct net_device *pNetDev)
-{
-
-       /* TODO: Need to fix this */
-       printk("WARNING: This function(%s) not implement yet!\n", __func__);
-       return 0;
-}
-
-void RtmpOSNetDevDetach(struct net_device *pNetDev)
-{
-       unregister_netdev(pNetDev);
-}
-
-int RtmpOSNetDevAttach(struct net_device *pNetDev,
-                      struct rt_rtmp_os_netdev_op_hook *pDevOpHook)
-{
-       int ret, rtnl_locked = FALSE;
-
-       DBGPRINT(RT_DEBUG_TRACE, ("RtmpOSNetDevAttach()--->\n"));
-       /* If we need hook some callback function to the net device structure, now do it. */
-       if (pDevOpHook) {
-               struct rt_rtmp_adapter *pAd = NULL;
-
-               GET_PAD_FROM_NET_DEV(pAd, pNetDev);
-
-               pNetDev->netdev_ops = pDevOpHook->netdev_ops;
-
-               /* OS specific flags, here we used to indicate if we are virtual interface */
-               pNetDev->priv_flags = pDevOpHook->priv_flags;
-
-               if (pAd->OpMode == OPMODE_STA)
-                       pNetDev->wireless_handlers = &rt28xx_iw_handler_def;
-
-               /* copy the net device mac address to the net_device structure. */
-               NdisMoveMemory(pNetDev->dev_addr, &pDevOpHook->devAddr[0],
-                              MAC_ADDR_LEN);
-
-               rtnl_locked = pDevOpHook->needProtcted;
-       }
-
-       if (rtnl_locked)
-               ret = register_netdevice(pNetDev);
-       else
-               ret = register_netdev(pNetDev);
-
-       DBGPRINT(RT_DEBUG_TRACE, ("<---RtmpOSNetDevAttach(), ret=%d\n", ret));
-       if (ret == 0)
-               return NDIS_STATUS_SUCCESS;
-       else
-               return NDIS_STATUS_FAILURE;
-}
-
-struct net_device *RtmpOSNetDevCreate(struct rt_rtmp_adapter *pAd,
-                           int devType,
-                           int devNum,
-                           int privMemSize, char *pNamePrefix)
-{
-       struct net_device *pNetDev = NULL;
-       int status;
-
-       /* allocate a new network device */
-       status = RtmpOSNetDevAlloc(&pNetDev, 0 /*privMemSize */);
-       if (status != NDIS_STATUS_SUCCESS) {
-               /* allocation fail, exit */
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("Allocate network device fail (%s)...\n",
-                         pNamePrefix));
-               return NULL;
-       }
-
-       /* find an available interface name, max 32 interfaces */
-       status = RtmpOSNetDevRequestName(pAd, pNetDev, pNamePrefix, devNum);
-       if (status != NDIS_STATUS_SUCCESS) {
-               /* error! no available ra name can be used! */
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("Assign interface name (%s with suffix 0~32) failed...\n",
-                         pNamePrefix));
-               RtmpOSNetDevFree(pNetDev);
-
-               return NULL;
-       } else {
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("The name of the new %s interface is %s...\n",
-                         pNamePrefix, pNetDev->name));
-       }
-
-       return pNetDev;
-}
diff --git a/drivers/staging/rt2860/rt_linux.h b/drivers/staging/rt2860/rt_linux.h
deleted file mode 100644 (file)
index 3efb88f..0000000
+++ /dev/null
@@ -1,835 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-    Module Name:
-       rt_linux.h
-
-    Abstract:
-
-    Revision History:
-    Who                When            What
-    Justin P. Mattock  11/07/2010      Fix typo in a comment
-    ---------    ----------    ----------------------------------------------
-*/
-
-#ifndef __RT_LINUX_H__
-#define __RT_LINUX_H__
-
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/spinlock.h>
-#include <linux/init.h>
-#include <linux/string.h>
-#include <linux/timer.h>
-#include <linux/errno.h>
-#include <linux/slab.h>
-#include <linux/interrupt.h>
-#include <linux/pci.h>
-#include <linux/netdevice.h>
-#include <linux/etherdevice.h>
-#include <linux/skbuff.h>
-#include <linux/ethtool.h>
-#include <linux/wireless.h>
-#include <linux/proc_fs.h>
-#include <linux/delay.h>
-#include <linux/if_arp.h>
-#include <linux/ctype.h>
-#include <linux/vmalloc.h>
-
-#include <net/iw_handler.h>
-
-/* load firmware */
-#define __KERNEL_SYSCALLS__
-#include <linux/unistd.h>
-#include <asm/uaccess.h>
-#include <asm/types.h>
-#include <asm/unaligned.h>     /* for get_unaligned() */
-
-#define KTHREAD_SUPPORT 1
-/* RT2870 2.1.0.0 has it disabled */
-
-#ifdef KTHREAD_SUPPORT
-#include <linux/err.h>
-#include <linux/kthread.h>
-#endif /* KTHREAD_SUPPORT // */
-
-/***********************************************************************************
- *     Profile related sections
- ***********************************************************************************/
-
-#ifdef RTMP_MAC_PCI
-#define STA_DRIVER_VERSION                     "2.1.0.0"
-#endif /* RTMP_MAC_PCI // */
-#ifdef RTMP_MAC_USB
-#define STA_DRIVER_VERSION                     "2.1.0.0"
-/* RT3070 version: 2.1.1.0 */
-#endif /* RTMP_MAC_USB // */
-
-extern const struct iw_handler_def rt28xx_iw_handler_def;
-
-/***********************************************************************************
- *     Compiler related definitions
- ***********************************************************************************/
-#undef __inline
-#define __inline          static inline
-#define IN
-#define OUT
-#define INOUT
-
-/***********************************************************************************
- *     OS Specific definitions and data structures
- ***********************************************************************************/
-typedef int (*HARD_START_XMIT_FUNC) (struct sk_buff *skb,
-                                    struct net_device *net_dev);
-
-#ifdef RTMP_MAC_PCI
-#ifndef PCI_DEVICE
-#define PCI_DEVICE(vend,dev) \
-       .vendor = (vend), .device = (dev), \
-       .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID
-#endif /* PCI_DEVICE // */
-#endif /* RTMP_MAC_PCI // */
-
-#define RT_MOD_INC_USE_COUNT() \
-       if (!try_module_get(THIS_MODULE)) \
-       { \
-               DBGPRINT(RT_DEBUG_ERROR, ("%s: cannot reserve module\n", __func__)); \
-               return -1; \
-       }
-
-#define RT_MOD_DEC_USE_COUNT() module_put(THIS_MODULE);
-
-#define RTMP_INC_REF(_A)               0
-#define RTMP_DEC_REF(_A)               0
-#define RTMP_GET_REF(_A)               0
-
-/* This function will be called when query /proc */
-struct iw_statistics *rt28xx_get_wireless_stats(IN struct net_device *net_dev);
-
-/***********************************************************************************
- *     Network related constant definitions
- ***********************************************************************************/
-#ifndef IFNAMSIZ
-#define IFNAMSIZ 16
-#endif
-
-#define ETH_LENGTH_OF_ADDRESS  6
-
-#define NDIS_STATUS_SUCCESS                     0x00
-#define NDIS_STATUS_FAILURE                     0x01
-#define NDIS_STATUS_INVALID_DATA                               0x02
-#define NDIS_STATUS_RESOURCES                   0x03
-
-#define NDIS_SET_PACKET_STATUS(_p, _status)                    do{} while(0)
-#define NdisWriteErrorLogEntry(_a, _b, _c, _d)         do{} while(0)
-
-/* statistics counter */
-#define STATS_INC_RX_PACKETS(_pAd, _dev)
-#define STATS_INC_TX_PACKETS(_pAd, _dev)
-
-#define STATS_INC_RX_BYTESS(_pAd, _dev, len)
-#define STATS_INC_TX_BYTESS(_pAd, _dev, len)
-
-#define STATS_INC_RX_ERRORS(_pAd, _dev)
-#define STATS_INC_TX_ERRORS(_pAd, _dev)
-
-#define STATS_INC_RX_DROPPED(_pAd, _dev)
-#define STATS_INC_TX_DROPPED(_pAd, _dev)
-
-/***********************************************************************************
- *     Ralink Specific network related constant definitions
- ***********************************************************************************/
-#define MIN_NET_DEVICE_FOR_AID                 0x00    /*0x00~0x3f */
-#define MIN_NET_DEVICE_FOR_MBSSID              0x00    /*0x00,0x10,0x20,0x30 */
-#define MIN_NET_DEVICE_FOR_WDS                 0x10    /*0x40,0x50,0x60,0x70 */
-#define MIN_NET_DEVICE_FOR_APCLI               0x20
-#define MIN_NET_DEVICE_FOR_MESH                        0x30
-#define MIN_NET_DEVICE_FOR_DLS                 0x40
-#define NET_DEVICE_REAL_IDX_MASK               0x0f    /* for each operation mode, we maximum support 15 entities. */
-
-#define NDIS_PACKET_TYPE_DIRECTED              0
-#define NDIS_PACKET_TYPE_MULTICAST             1
-#define NDIS_PACKET_TYPE_BROADCAST             2
-#define NDIS_PACKET_TYPE_ALL_MULTICAST 3
-#define NDIS_PACKET_TYPE_PROMISCUOUS   4
-
-/***********************************************************************************
- *     OS signaling related constant definitions
- ***********************************************************************************/
-
-/***********************************************************************************
- *     OS file operation related data structure definitions
- ***********************************************************************************/
-struct rt_rtmp_os_fs_info {
-       int fsuid;
-       int fsgid;
-       mm_segment_t fs;
-};
-
-#define IS_FILE_OPEN_ERR(_fd)  IS_ERR((_fd))
-
-/***********************************************************************************
- *     OS semaphore related data structure and definitions
- ***********************************************************************************/
-struct os_lock {
-       spinlock_t lock;
-       unsigned long flags;
-};
-
-/* */
-/*  spin_lock enhanced for Nested spin lock */
-/* */
-#define NdisAllocateSpinLock(__lock)      \
-{                                       \
-    spin_lock_init((spinlock_t *)(__lock));               \
-}
-
-#define NdisFreeSpinLock(lock)          \
-       do{}while(0)
-
-#define RTMP_SEM_LOCK(__lock)                                  \
-{                                                                                              \
-       spin_lock_bh((spinlock_t *)(__lock));           \
-}
-
-#define RTMP_SEM_UNLOCK(__lock)                                        \
-{                                                                                              \
-       spin_unlock_bh((spinlock_t *)(__lock));         \
-}
-
-/* sample, use semaphore lock to replace IRQ lock, 2007/11/15 */
-#define RTMP_IRQ_LOCK(__lock, __irqflags)                      \
-{                                                                                                      \
-       __irqflags = 0;                                                                 \
-       spin_lock_bh((spinlock_t *)(__lock));                   \
-       pAd->irq_disabled |= 1; \
-}
-
-#define RTMP_IRQ_UNLOCK(__lock, __irqflag)                     \
-{                                                                                                      \
-       pAd->irq_disabled &= 0;                                                 \
-       spin_unlock_bh((spinlock_t *)(__lock));                 \
-}
-
-#define RTMP_INT_LOCK(__lock, __irqflags)                      \
-{                                                                                                      \
-       spin_lock_irqsave((spinlock_t *)__lock, __irqflags);    \
-}
-
-#define RTMP_INT_UNLOCK(__lock, __irqflag)                     \
-{                                                                                                      \
-       spin_unlock_irqrestore((spinlock_t *)(__lock), ((unsigned long)__irqflag));     \
-}
-
-#define NdisAcquireSpinLock            RTMP_SEM_LOCK
-#define NdisReleaseSpinLock            RTMP_SEM_UNLOCK
-
-#ifndef wait_event_interruptible_timeout
-#define __wait_event_interruptible_timeout(wq, condition, ret) \
-do { \
-        wait_queue_t __wait; \
-        init_waitqueue_entry(&__wait, current); \
-        add_wait_queue(&wq, &__wait); \
-        for (;;) { \
-                set_current_state(TASK_INTERRUPTIBLE); \
-                if (condition) \
-                        break; \
-                if (!signal_pending(current)) { \
-                        ret = schedule_timeout(ret); \
-                        if (!ret) \
-                                break; \
-                        continue; \
-                } \
-                ret = -ERESTARTSYS; \
-                break; \
-        } \
-        current->state = TASK_RUNNING; \
-        remove_wait_queue(&wq, &__wait); \
-} while (0)
-
-#define wait_event_interruptible_timeout(wq, condition, timeout) \
-({ \
-        long __ret = timeout; \
-        if (!(condition)) \
-                __wait_event_interruptible_timeout(wq, condition, __ret); \
-        __ret; \
-})
-#endif
-
-#define RTMP_SEM_EVENT_INIT_LOCKED(_pSema)     sema_init((_pSema), 0)
-#define RTMP_SEM_EVENT_INIT(_pSema)                    sema_init((_pSema), 1)
-#define RTMP_SEM_EVENT_WAIT(_pSema, _status)   ((_status) = down_interruptible((_pSema)))
-#define RTMP_SEM_EVENT_UP(_pSema)                      up(_pSema)
-
-#ifdef KTHREAD_SUPPORT
-#define RTMP_WAIT_EVENT_INTERRUPTIBLE(_pAd, _pTask) \
-{ \
-               wait_event_interruptible(_pTask->kthread_q, \
-                                                                _pTask->kthread_running || kthread_should_stop()); \
-               _pTask->kthread_running = FALSE; \
-               if (kthread_should_stop()) \
-               { \
-                       RTMP_SET_FLAG(_pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS); \
-                       break; \
-               } \
-}
-#endif
-
-#ifdef KTHREAD_SUPPORT
-#define WAKE_UP(_pTask) \
-       do{ \
-               if ((_pTask)->kthread_task) \
-        { \
-                       (_pTask)->kthread_running = TRUE; \
-               wake_up(&(_pTask)->kthread_q); \
-               } \
-       }while(0)
-#endif
-
-/***********************************************************************************
- *     OS Memory Access related data structure and definitions
- ***********************************************************************************/
-#define MEM_ALLOC_FLAG      (GFP_ATOMIC)       /*(GFP_DMA | GFP_ATOMIC) */
-
-#define NdisMoveMemory(Destination, Source, Length) memmove(Destination, Source, Length)
-#define NdisCopyMemory(Destination, Source, Length) memcpy(Destination, Source, Length)
-#define NdisZeroMemory(Destination, Length)         memset(Destination, 0, Length)
-#define NdisFillMemory(Destination, Length, Fill)   memset(Destination, Fill, Length)
-#define NdisCmpMemory(Destination, Source, Length)  memcmp(Destination, Source, Length)
-#define NdisEqualMemory(Source1, Source2, Length)   (!memcmp(Source1, Source2, Length))
-#define RTMPEqualMemory(Source1, Source2, Length)      (!memcmp(Source1, Source2, Length))
-
-#define MlmeAllocateMemory(_pAd, _ppVA)                os_alloc_mem(_pAd, _ppVA, MGMT_DMA_BUFFER_SIZE)
-#define MlmeFreeMemory(_pAd, _pVA)                     os_free_mem(_pAd, _pVA)
-
-#define COPY_MAC_ADDR(Addr1, Addr2)             memcpy((Addr1), (Addr2), MAC_ADDR_LEN)
-
-/***********************************************************************************
- *     OS task related data structure and definitions
- ***********************************************************************************/
-#define RTMP_OS_MGMT_TASK_FLAGS        CLONE_VM
-
-#define        THREAD_PID_INIT_VALUE   NULL
-#define        GET_PID(_v)     find_get_pid((_v))
-#define        GET_PID_NUMBER(_v)      pid_nr((_v))
-#define CHECK_PID_LEGALITY(_pid)       if (pid_nr((_pid)) > 0)
-#define KILL_THREAD_PID(_A, _B, _C)    kill_pid((_A), (_B), (_C))
-
-/***********************************************************************************
- * Timer related definitions and data structures.
- **********************************************************************************/
-#define OS_HZ                  HZ
-
-typedef void (*TIMER_FUNCTION) (unsigned long);
-
-#define OS_WAIT(_time) \
-{      int _i; \
-       long _loop = ((_time)/(1000/OS_HZ)) > 0 ? ((_time)/(1000/OS_HZ)) : 1;\
-       wait_queue_head_t _wait; \
-       init_waitqueue_head(&_wait); \
-       for (_i=0; _i<(_loop); _i++) \
-               wait_event_interruptible_timeout(_wait, 0, ONE_TICK); }
-
-#define RTMP_TIME_AFTER(a,b)           \
-       (typecheck(unsigned long, (unsigned long)a) && \
-        typecheck(unsigned long, (unsigned long)b) && \
-        ((long)(b) - (long)(a) < 0))
-
-#define RTMP_TIME_AFTER_EQ(a,b)        \
-       (typecheck(unsigned long, (unsigned long)a) && \
-        typecheck(unsigned long, (unsigned long)b) && \
-        ((long)(a) - (long)(b) >= 0))
-#define RTMP_TIME_BEFORE(a,b)  RTMP_TIME_AFTER_EQ(b,a)
-
-#define ONE_TICK 1
-
-static inline void NdisGetSystemUpTime(unsigned long *time)
-{
-       *time = jiffies;
-}
-
-/***********************************************************************************
- *     OS specific cookie data structure binding to struct rt_rtmp_adapter
- ***********************************************************************************/
-
-struct os_cookie {
-#ifdef RTMP_MAC_PCI
-       struct pci_dev *pci_dev;
-       struct pci_dev *parent_pci_dev;
-       u16 DeviceID;
-       dma_addr_t pAd_pa;
-#endif                         /* RTMP_MAC_PCI // */
-#ifdef RTMP_MAC_USB
-       struct usb_device *pUsb_Dev;
-#endif                         /* RTMP_MAC_USB // */
-
-       struct tasklet_struct rx_done_task;
-       struct tasklet_struct mgmt_dma_done_task;
-       struct tasklet_struct ac0_dma_done_task;
-       struct tasklet_struct ac1_dma_done_task;
-       struct tasklet_struct ac2_dma_done_task;
-       struct tasklet_struct ac3_dma_done_task;
-       struct tasklet_struct tbtt_task;
-#ifdef RTMP_MAC_PCI
-       struct tasklet_struct fifo_statistic_full_task;
-#endif                         /* RTMP_MAC_PCI // */
-#ifdef RTMP_MAC_USB
-       struct tasklet_struct null_frame_complete_task;
-       struct tasklet_struct rts_frame_complete_task;
-       struct tasklet_struct pspoll_frame_complete_task;
-#endif                         /* RTMP_MAC_USB // */
-
-       unsigned long apd_pid;  /*802.1x daemon pid */
-       int ioctl_if_type;
-       int ioctl_if;
-};
-
-/***********************************************************************************
- *     OS debugging and printing related definitions and data structure
- ***********************************************************************************/
-#ifdef DBG
-extern unsigned long RTDebugLevel;
-
-#define DBGPRINT_RAW(Level, Fmt)    \
-do{                                   \
-    if (Level <= RTDebugLevel)      \
-    {                               \
-        printk Fmt;               \
-    }                               \
-}while(0)
-
-#define DBGPRINT(Level, Fmt)    DBGPRINT_RAW(Level, Fmt)
-
-#define DBGPRINT_ERR(fmt, args...) printk(KERN_ERR fmt, ##args)
-
-#define DBGPRINT_S(Status, Fmt)                \
-{                                                                      \
-       printk Fmt;                                     \
-}
-
-#else
-#define DBGPRINT(Level, Fmt)
-#define DBGPRINT_RAW(Level, Fmt)
-#define DBGPRINT_S(Status, Fmt)
-#define DBGPRINT_ERR(Fmt)
-#endif
-
-#define ASSERT(x)
-
-void hex_dump(char *str, unsigned char *pSrcBufVA, unsigned int SrcBufLen);
-
-/*********************************************************************************************************
-       The following code are not revised, temporary put it here.
-  *********************************************************************************************************/
-
-/***********************************************************************************
- * Device DMA Access related definitions and data structures.
- **********************************************************************************/
-#ifdef RTMP_MAC_PCI
-struct rt_rtmp_adapter;
-dma_addr_t linux_pci_map_single(struct rt_rtmp_adapter *pAd, void *ptr,
-                               size_t size, int sd_idx, int direction);
-void linux_pci_unmap_single(struct rt_rtmp_adapter *pAd, dma_addr_t dma_addr,
-                           size_t size, int direction);
-
-#define PCI_MAP_SINGLE(_handle, _ptr, _size, _sd_idx, _dir) \
-       linux_pci_map_single(_handle, _ptr, _size, _sd_idx, _dir)
-
-#define PCI_UNMAP_SINGLE(_handle, _ptr, _size, _dir) \
-       linux_pci_unmap_single(_handle, _ptr, _size, _dir)
-
-#define PCI_ALLOC_CONSISTENT(_pci_dev, _size, _ptr) \
-       pci_alloc_consistent(_pci_dev, _size, _ptr)
-
-#define PCI_FREE_CONSISTENT(_pci_dev, _size, _virtual_addr, _physical_addr) \
-       pci_free_consistent(_pci_dev, _size, _virtual_addr, _physical_addr)
-
-#define DEV_ALLOC_SKB(_length) \
-       dev_alloc_skb(_length)
-#endif /* RTMP_MAC_PCI // */
-
-/*
- * unsigned long
- * RTMP_GetPhysicalAddressLow(
- *   dma_addr_t  PhysicalAddress);
- */
-#define RTMP_GetPhysicalAddressLow(PhysicalAddress)            (PhysicalAddress)
-
-/*
- * unsigned long
- * RTMP_GetPhysicalAddressHigh(
- *   dma_addr_t  PhysicalAddress);
- */
-#define RTMP_GetPhysicalAddressHigh(PhysicalAddress)           (0)
-
-/*
- * void
- * RTMP_SetPhysicalAddressLow(
- *   dma_addr_t  PhysicalAddress,
- *   unsigned long  Value);
- */
-#define RTMP_SetPhysicalAddressLow(PhysicalAddress, Value)     \
-                       PhysicalAddress = Value;
-
-/*
- * void
- * RTMP_SetPhysicalAddressHigh(
- *   dma_addr_t  PhysicalAddress,
- *   unsigned long  Value);
- */
-#define RTMP_SetPhysicalAddressHigh(PhysicalAddress, Value)
-
-#define NdisMIndicateStatus(_w, _x, _y, _z)
-
-/***********************************************************************************
- * Device Register I/O Access related definitions and data structures.
- **********************************************************************************/
-#ifdef RTMP_MAC_PCI
-/*Patch for ASIC turst read/write bug, needs to remove after metel fix */
-#define RTMP_IO_READ32(_A, _R, _pV)                                                            \
-{                                                                                                                              \
-    if ((_A)->bPCIclkOff == FALSE)                                  \
-    {                                                               \
-               (*_pV = readl((void *)((_A)->CSRBaseAddress + MAC_CSR0)));              \
-               (*_pV = readl((void *)((_A)->CSRBaseAddress + (_R))));                  \
-    }                                                               \
-    else                                                                                                                       \
-               *_pV = 0;                                                                                                       \
-}
-
-#define RTMP_IO_FORCE_READ32(_A, _R, _pV)                                                      \
-{                                                                                                                                      \
-       (*_pV = readl((void *)((_A)->CSRBaseAddress + MAC_CSR0)));              \
-       (*_pV = readl((void *)((_A)->CSRBaseAddress + (_R))));                  \
-}
-
-#define RTMP_IO_READ8(_A, _R, _pV)                                                             \
-{                                                                                                                              \
-       (*_pV = readl((void *)((_A)->CSRBaseAddress + MAC_CSR0)));                      \
-       (*_pV = readb((void *)((_A)->CSRBaseAddress + (_R))));                          \
-}
-#define RTMP_IO_WRITE32(_A, _R, _V)                                                                                            \
-{                                                                                                                                                              \
-    if ((_A)->bPCIclkOff == FALSE)                                  \
-    {                                                               \
-       u32 Val;                                                                                                                                \
-       Val = readl((void *)((_A)->CSRBaseAddress + MAC_CSR0));                 \
-       writel((_V), (void *)((_A)->CSRBaseAddress + (_R)));                                                            \
-    }                                                               \
-}
-
-#define RTMP_IO_FORCE_WRITE32(_A, _R, _V)                                                                                              \
-{                                                                                                                                                              \
-       u32 Val;                                                                                                                                \
-       Val = readl((void *)((_A)->CSRBaseAddress + MAC_CSR0));                 \
-       writel(_V, (void *)((_A)->CSRBaseAddress + (_R)));                                                              \
-}
-
-#if defined(RALINK_2880) || defined(RALINK_3052)
-#define RTMP_IO_WRITE8(_A, _R, _V)            \
-{                    \
-       unsigned long Val;                \
-       u8 _i;                \
-       _i = ((_R) & 0x3);             \
-       Val = readl((void *)((_A)->CSRBaseAddress + ((_R) - _i)));   \
-       Val = Val & (~(0x000000ff << ((_i)*8)));         \
-       Val = Val | ((unsigned long)(_V) << ((_i)*8));         \
-       writel((Val), (void *)((_A)->CSRBaseAddress + ((_R) - _i)));    \
-}
-#else
-#define RTMP_IO_WRITE8(_A, _R, _V)                                                                                             \
-{                                                                                                                                                              \
-       u32 Val;                                                                                                                                \
-       Val = readl((void *)((_A)->CSRBaseAddress + MAC_CSR0));                 \
-       writeb((_V), (u8 *)((_A)->CSRBaseAddress + (_R)));              \
-}
-#endif /* #if defined(BRCM_6358) || defined(RALINK_2880) // */
-
-#define RTMP_IO_WRITE16(_A, _R, _V)                                                                                            \
-{                                                                                                                                                              \
-       u32 Val;                                                                                                                                \
-       Val = readl((void *)((_A)->CSRBaseAddress + MAC_CSR0));                 \
-       writew((_V), (u16 *)((_A)->CSRBaseAddress + (_R)));     \
-}
-#endif /* RTMP_MAC_PCI // */
-#ifdef RTMP_MAC_USB
-/*Patch for ASIC turst read/write bug, needs to remove after metel fix */
-#define RTMP_IO_READ32(_A, _R, _pV)                                                            \
-       RTUSBReadMACRegister((_A), (_R), (u32 *)(_pV))
-
-#define RTMP_IO_READ8(_A, _R, _pV)                                                             \
-{                                                                                                                              \
-}
-
-#define RTMP_IO_WRITE32(_A, _R, _V)                                                            \
-       RTUSBWriteMACRegister((_A), (_R), (u32)(_V))
-
-#define RTMP_IO_WRITE8(_A, _R, _V)                                                             \
-{                                                                                                                              \
-       u16     _Val = _V;                                                                                      \
-       RTUSBSingleWrite((_A), (_R), (u16)(_Val));                                                              \
-}
-
-#define RTMP_IO_WRITE16(_A, _R, _V)                                                            \
-{                                                                                                                              \
-       RTUSBSingleWrite((_A), (_R), (u16)(_V));                                                                \
-}
-#endif /* RTMP_MAC_USB // */
-
-/***********************************************************************************
- *     Network Related data structure and marco definitions
- ***********************************************************************************/
-#define PKTSRC_NDIS             0x7f
-#define PKTSRC_DRIVER           0x0f
-
-#define RTMP_OS_NETDEV_SET_PRIV(_pNetDev, _pPriv)      ((_pNetDev)->ml_priv = (_pPriv))
-#define RTMP_OS_NETDEV_GET_PRIV(_pNetDev)              ((_pNetDev)->ml_priv)
-#define RTMP_OS_NETDEV_GET_DEVNAME(_pNetDev)   ((_pNetDev)->name)
-#define RTMP_OS_NETDEV_GET_PHYADDR(_PNETDEV)   ((_PNETDEV)->dev_addr)
-
-#define RTMP_OS_NETDEV_START_QUEUE(_pNetDev)   netif_start_queue((_pNetDev))
-#define RTMP_OS_NETDEV_STOP_QUEUE(_pNetDev)    netif_stop_queue((_pNetDev))
-#define RTMP_OS_NETDEV_WAKE_QUEUE(_pNetDev)    netif_wake_queue((_pNetDev))
-#define RTMP_OS_NETDEV_CARRIER_OFF(_pNetDev)   netif_carrier_off((_pNetDev))
-
-#define QUEUE_ENTRY_TO_PACKET(pEntry) \
-       (void *)(pEntry)
-
-#define PACKET_TO_QUEUE_ENTRY(pPacket) \
-       (struct rt_queue_entry *)(pPacket)
-
-#define GET_SG_LIST_FROM_PACKET(_p, _sc)       \
-    rt_get_sg_list_from_packet(_p, _sc)
-
-#define RELEASE_NDIS_PACKET(_pAd, _pPacket, _Status)                    \
-{                                                                       \
-        RTMPFreeNdisPacket(_pAd, _pPacket);                             \
-}
-
-/*
- * packet helper
- *     - convert internal rt packet to os packet or
- *             os packet to rt packet
- */
-#define RTPKT_TO_OSPKT(_p)             ((struct sk_buff *)(_p))
-#define OSPKT_TO_RTPKT(_p)             ((void *)(_p))
-
-#define GET_OS_PKT_DATAPTR(_pkt) \
-               (RTPKT_TO_OSPKT(_pkt)->data)
-#define SET_OS_PKT_DATAPTR(_pkt, _dataPtr)     \
-               (RTPKT_TO_OSPKT(_pkt)->data) = (_dataPtr)
-
-#define GET_OS_PKT_LEN(_pkt) \
-               (RTPKT_TO_OSPKT(_pkt)->len)
-#define SET_OS_PKT_LEN(_pkt, _len)     \
-               (RTPKT_TO_OSPKT(_pkt)->len) = (_len)
-
-#define GET_OS_PKT_DATATAIL(_pkt) \
-               (skb_tail_pointer(RTPKT_TO_OSPKT(_pkt))
-#define SET_OS_PKT_DATATAIL(_pkt, _start, _len)        \
-               (skb_set_tail_pointer(RTPKT_TO_OSPKT(_pkt), _len))
-
-#define GET_OS_PKT_HEAD(_pkt) \
-               (RTPKT_TO_OSPKT(_pkt)->head)
-
-#define GET_OS_PKT_END(_pkt) \
-               (RTPKT_TO_OSPKT(_pkt)->end)
-
-#define GET_OS_PKT_NETDEV(_pkt) \
-               (RTPKT_TO_OSPKT(_pkt)->dev)
-#define SET_OS_PKT_NETDEV(_pkt, _pNetDev)      \
-               (RTPKT_TO_OSPKT(_pkt)->dev) = (_pNetDev)
-
-#define GET_OS_PKT_TYPE(_pkt) \
-               (RTPKT_TO_OSPKT(_pkt))
-
-#define GET_OS_PKT_NEXT(_pkt) \
-               (RTPKT_TO_OSPKT(_pkt)->next)
-
-#define OS_PKT_CLONED(_pkt)            skb_cloned(RTPKT_TO_OSPKT(_pkt))
-
-#define OS_NTOHS(_Val) \
-               (ntohs(_Val))
-#define OS_HTONS(_Val) \
-               (htons(_Val))
-#define OS_NTOHL(_Val) \
-               (ntohl(_Val))
-#define OS_HTONL(_Val) \
-               (htonl(_Val))
-
-#define CB_OFF  10
-
-/* User Priority */
-#define RTMP_SET_PACKET_UP(_p, _prio)                  (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+0] = _prio)
-#define RTMP_GET_PACKET_UP(_p)                                 (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+0])
-
-/* Fragment # */
-#define RTMP_SET_PACKET_FRAGMENTS(_p, _num)            (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+1] = _num)
-#define RTMP_GET_PACKET_FRAGMENTS(_p)                  (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+1])
-
-/* 0x0 ~0x7f: TX to AP's own BSS which has the specified AID. if AID>127, set bit 7 in RTMP_SET_PACKET_EMACTAB too. */
-/*(this value also as MAC(on-chip WCID) table index) */
-/* 0x80~0xff: TX to a WDS link. b0~6: WDS index */
-#define RTMP_SET_PACKET_WCID(_p, _wdsidx)              (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+2] = _wdsidx)
-#define RTMP_GET_PACKET_WCID(_p)                       ((u8)(RTPKT_TO_OSPKT(_p)->cb[CB_OFF+2]))
-
-/* 0xff: PKTSRC_NDIS, others: local TX buffer index. This value affects how to a packet */
-#define RTMP_SET_PACKET_SOURCE(_p, _pktsrc)            (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+3] = _pktsrc)
-#define RTMP_GET_PACKET_SOURCE(_p)                     (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+3])
-
-/* RTS/CTS-to-self protection method */
-#define RTMP_SET_PACKET_RTS(_p, _num)                  (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+4] = _num)
-#define RTMP_GET_PACKET_RTS(_p)                        (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+4])
-/* see RTMP_S(G)ET_PACKET_EMACTAB */
-
-/* TX rate index */
-#define RTMP_SET_PACKET_TXRATE(_p, _rate)              (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+5] = _rate)
-#define RTMP_GET_PACKET_TXRATE(_p)                             (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+5])
-
-/* From which Interface */
-#define RTMP_SET_PACKET_IF(_p, _ifdx)          (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+6] = _ifdx)
-#define RTMP_GET_PACKET_IF(_p)                         (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+6])
-#define RTMP_SET_PACKET_NET_DEVICE_MBSSID(_p, _bss)            RTMP_SET_PACKET_IF((_p), (_bss))
-#define RTMP_SET_PACKET_NET_DEVICE_WDS(_p, _bss)               RTMP_SET_PACKET_IF((_p), ((_bss) + MIN_NET_DEVICE_FOR_WDS))
-#define RTMP_SET_PACKET_NET_DEVICE_APCLI(_p, _idx)     RTMP_SET_PACKET_IF((_p), ((_idx) + MIN_NET_DEVICE_FOR_APCLI))
-#define RTMP_SET_PACKET_NET_DEVICE_MESH(_p, _idx)      RTMP_SET_PACKET_IF((_p), ((_idx) + MIN_NET_DEVICE_FOR_MESH))
-#define RTMP_GET_PACKET_NET_DEVICE_MBSSID(_p)                  RTMP_GET_PACKET_IF((_p))
-#define RTMP_GET_PACKET_NET_DEVICE(_p)                                 RTMP_GET_PACKET_IF((_p))
-
-#define RTMP_SET_PACKET_MOREDATA(_p, _morebit)         (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+7] = _morebit)
-#define RTMP_GET_PACKET_MOREDATA(_p)                           (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+7])
-
-/* */
-/*      Specific Packet Type definition */
-/* */
-#define RTMP_PACKET_SPECIFIC_CB_OFFSET 11
-
-#define RTMP_PACKET_SPECIFIC_DHCP              0x01
-#define RTMP_PACKET_SPECIFIC_EAPOL             0x02
-#define RTMP_PACKET_SPECIFIC_IPV4              0x04
-#define RTMP_PACKET_SPECIFIC_WAI               0x08
-#define RTMP_PACKET_SPECIFIC_VLAN              0x10
-#define RTMP_PACKET_SPECIFIC_LLCSNAP   0x20
-
-/*Specific */
-#define RTMP_SET_PACKET_SPECIFIC(_p, _flg)             (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] = _flg)
-
-/*DHCP */
-#define RTMP_SET_PACKET_DHCP(_p, _flg)                                                                                                         \
-                       do{                                                                                                                                                             \
-                               if (_flg)                                                                                                                                       \
-                                       (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_DHCP);             \
-                               else                                                                                                                                            \
-                                       (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (!RTMP_PACKET_SPECIFIC_DHCP);    \
-                       }while(0)
-#define RTMP_GET_PACKET_DHCP(_p)               (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_DHCP)
-
-/*EAPOL */
-#define RTMP_SET_PACKET_EAPOL(_p, _flg)                                                                                                        \
-                       do{                                                                                                                                                             \
-                               if (_flg)                                                                                                                                       \
-                                       (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_EAPOL);            \
-                               else                                                                                                                                            \
-                                       (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (!RTMP_PACKET_SPECIFIC_EAPOL);   \
-                       }while(0)
-#define RTMP_GET_PACKET_EAPOL(_p)              (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_EAPOL)
-
-/*WAI */
-#define RTMP_SET_PACKET_WAI(_p, _flg)                                                                                                          \
-                       do{                                                                                                                                                             \
-                               if (_flg)                                                                                                                                       \
-                                       (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_WAI);              \
-                               else                                                                                                                                            \
-                                       (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (!RTMP_PACKET_SPECIFIC_WAI);     \
-                       }while(0)
-#define RTMP_GET_PACKET_WAI(_p)                (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_WAI)
-
-#define RTMP_GET_PACKET_LOWRATE(_p)            (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & (RTMP_PACKET_SPECIFIC_EAPOL | RTMP_PACKET_SPECIFIC_DHCP | RTMP_PACKET_SPECIFIC_WAI))
-
-/*VLAN */
-#define RTMP_SET_PACKET_VLAN(_p, _flg)                                                                                                         \
-                       do{                                                                                                                                                             \
-                               if (_flg)                                                                                                                                       \
-                                       (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_VLAN);             \
-                               else                                                                                                                                            \
-                                       (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (!RTMP_PACKET_SPECIFIC_VLAN);    \
-                       }while(0)
-#define RTMP_GET_PACKET_VLAN(_p)               (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_VLAN)
-
-/*LLC/SNAP */
-#define RTMP_SET_PACKET_LLCSNAP(_p, _flg)                                                                                                      \
-                       do{                                                                                                                                                             \
-                               if (_flg)                                                                                                                                       \
-                                       (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_LLCSNAP);          \
-                               else                                                                                                                                            \
-                                       (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (!RTMP_PACKET_SPECIFIC_LLCSNAP);         \
-                       }while(0)
-
-#define RTMP_GET_PACKET_LLCSNAP(_p)            (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_LLCSNAP)
-
-/* IP */
-#define RTMP_SET_PACKET_IPV4(_p, _flg)                                                                                                         \
-                       do{                                                                                                                                                             \
-                               if (_flg)                                                                                                                                       \
-                                       (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_IPV4);             \
-                               else                                                                                                                                            \
-                                       (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (!RTMP_PACKET_SPECIFIC_IPV4);    \
-                       }while(0)
-
-#define RTMP_GET_PACKET_IPV4(_p)               (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_IPV4)
-
-/* If this flag is set, it indicates that this EAPoL frame MUST be clear. */
-#define RTMP_SET_PACKET_CLEAR_EAP_FRAME(_p, _flg)   (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+12] = _flg)
-#define RTMP_GET_PACKET_CLEAR_EAP_FRAME(_p)         (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+12])
-
-/* use bit3 of cb[CB_OFF+16] */
-
-#define RTMP_SET_PACKET_5VT(_p, _flg)   (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+22] = _flg)
-#define RTMP_GET_PACKET_5VT(_p)         (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+22])
-
-/* Max skb->cb = 48B = [CB_OFF+38] */
-
-/***********************************************************************************
- *     Other function prototypes definitions
- ***********************************************************************************/
-void RTMP_GetCurrentSystemTime(LARGE_INTEGER *time);
-int rt28xx_packet_xmit(struct sk_buff *skb);
-
-#ifdef RTMP_MAC_PCI
-/* function declarations */
-#define IRQ_HANDLE_TYPE  irqreturn_t
-
-IRQ_HANDLE_TYPE rt2860_interrupt(int irq, void *dev_instance);
-#endif /* RTMP_MAC_PCI // */
-
-int rt28xx_sta_ioctl(struct net_device *net_dev, IN OUT struct ifreq *rq, int cmd);
-
-extern int ra_mtd_write(int num, loff_t to, size_t len, const u_char *buf);
-extern int ra_mtd_read(int num, loff_t from, size_t len, u_char *buf);
-
-#define GET_PAD_FROM_NET_DEV(_pAd, _net_dev)   (_pAd) = (struct rt_rtmp_adapter *)(_net_dev)->ml_priv;
-
-#endif /* __RT_LINUX_H__ // */
diff --git a/drivers/staging/rt2860/rt_main_dev.c b/drivers/staging/rt2860/rt_main_dev.c
deleted file mode 100644 (file)
index 236dd36..0000000
+++ /dev/null
@@ -1,736 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-    Module Name:
-    rt_main_dev.c
-
-    Abstract:
-    Create and register network interface.
-
-    Revision History:
-    Who                When            What
-    Justin P. Mattock  11/07/2010      Fix typos in comments
-    --------    ----------      ----------------------------------------------
-*/
-
-#include "rt_config.h"
-
-/*---------------------------------------------------------------------*/
-/* Private Variables Used                                              */
-/*---------------------------------------------------------------------*/
-
-char *mac = "";                /* default 00:00:00:00:00:00 */
-char *hostname = "";           /* default CMPC */
-module_param(mac, charp, 0);
-MODULE_PARM_DESC(mac, "rt28xx: wireless mac addr");
-
-/*---------------------------------------------------------------------*/
-/* Prototypes of Functions Used                                        */
-/*---------------------------------------------------------------------*/
-
-/* public function prototype */
-int rt28xx_close(IN struct net_device *net_dev);
-int rt28xx_open(struct net_device *net_dev);
-
-/* private function prototype */
-static int rt28xx_send_packets(IN struct sk_buff *skb_p,
-                              IN struct net_device *net_dev);
-
-static struct net_device_stats *RT28xx_get_ether_stats(IN struct net_device
-                                                      *net_dev);
-
-/*
-========================================================================
-Routine Description:
-    Close raxx interface.
-
-Arguments:
-       *net_dev                        the raxx interface pointer
-
-Return Value:
-    0                                  Open OK
-       otherwise                       Open Fail
-
-Note:
-       1. if open fail, kernel will not call the close function.
-       2. Free memory for
-               (1) Mlme Memory Handler:                MlmeHalt()
-               (2) TX & RX:                                    RTMPFreeTxRxRingMemory()
-               (3) BA Reordering:                              ba_reordering_resource_release()
-========================================================================
-*/
-int MainVirtualIF_close(IN struct net_device *net_dev)
-{
-       struct rt_rtmp_adapter *pAd = NULL;
-
-       GET_PAD_FROM_NET_DEV(pAd, net_dev);
-
-       /* Sanity check for pAd */
-       if (pAd == NULL)
-               return 0;       /* close ok */
-
-       netif_carrier_off(pAd->net_dev);
-       netif_stop_queue(pAd->net_dev);
-
-       {
-               BOOLEAN Cancelled;
-
-               if (INFRA_ON(pAd) &&
-                   (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST))) {
-                       struct rt_mlme_disassoc_req DisReq;
-                       struct rt_mlme_queue_elem *MsgElem =
-                               kmalloc(sizeof(struct rt_mlme_queue_elem),
-                                       MEM_ALLOC_FLAG);
-
-                       if (MsgElem) {
-                               COPY_MAC_ADDR(DisReq.Addr,
-                                             pAd->CommonCfg.Bssid);
-                               DisReq.Reason = REASON_DEAUTH_STA_LEAVING;
-
-                               MsgElem->Machine = ASSOC_STATE_MACHINE;
-                               MsgElem->MsgType = MT2_MLME_DISASSOC_REQ;
-                               MsgElem->MsgLen =
-                                   sizeof(struct rt_mlme_disassoc_req);
-                               NdisMoveMemory(MsgElem->Msg, &DisReq,
-                                              sizeof
-                                              (struct rt_mlme_disassoc_req));
-
-                               /* Prevent to connect AP again in STAMlmePeriodicExec */
-                               pAd->MlmeAux.AutoReconnectSsidLen = 32;
-                               NdisZeroMemory(pAd->MlmeAux.AutoReconnectSsid,
-                                              pAd->MlmeAux.
-                                              AutoReconnectSsidLen);
-
-                               pAd->Mlme.CntlMachine.CurrState =
-                                   CNTL_WAIT_OID_DISASSOC;
-                               MlmeDisassocReqAction(pAd, MsgElem);
-                               kfree(MsgElem);
-                       }
-
-                       RTMPusecDelay(1000);
-               }
-
-               RTMPCancelTimer(&pAd->StaCfg.StaQuickResponeForRateUpTimer,
-                               &Cancelled);
-               RTMPCancelTimer(&pAd->StaCfg.WpaDisassocAndBlockAssocTimer,
-                               &Cancelled);
-       }
-
-       VIRTUAL_IF_DOWN(pAd);
-
-       RT_MOD_DEC_USE_COUNT();
-
-       return 0;               /* close ok */
-}
-
-/*
-========================================================================
-Routine Description:
-    Open raxx interface.
-
-Arguments:
-       *net_dev                        the raxx interface pointer
-
-Return Value:
-    0                                  Open OK
-       otherwise                       Open Fail
-
-Note:
-       1. if open fail, kernel will not call the close function.
-       2. Free memory for
-               (1) Mlme Memory Handler:                MlmeHalt()
-               (2) TX & RX:                                    RTMPFreeTxRxRingMemory()
-               (3) BA Reordering:                              ba_reordering_resource_release()
-========================================================================
-*/
-int MainVirtualIF_open(IN struct net_device *net_dev)
-{
-       struct rt_rtmp_adapter *pAd = NULL;
-
-       GET_PAD_FROM_NET_DEV(pAd, net_dev);
-
-       /* Sanity check for pAd */
-       if (pAd == NULL)
-               return 0;       /* close ok */
-
-       if (VIRTUAL_IF_UP(pAd) != 0)
-               return -1;
-
-       /* increase MODULE use count */
-       RT_MOD_INC_USE_COUNT();
-
-       netif_start_queue(net_dev);
-       netif_carrier_on(net_dev);
-       netif_wake_queue(net_dev);
-
-       return 0;
-}
-
-/*
-========================================================================
-Routine Description:
-    Close raxx interface.
-
-Arguments:
-       *net_dev                        the raxx interface pointer
-
-Return Value:
-    0                                  Open OK
-       otherwise                       Open Fail
-
-Note:
-       1. if open fail, kernel will not call the close function.
-       2. Free memory for
-               (1) Mlme Memory Handler:                MlmeHalt()
-               (2) TX & RX:                                    RTMPFreeTxRxRingMemory()
-               (3) BA Reordering:                              ba_reordering_resource_release()
-========================================================================
-*/
-int rt28xx_close(struct net_device *dev)
-{
-       struct net_device *net_dev = (struct net_device *)dev;
-       struct rt_rtmp_adapter *pAd = NULL;
-       BOOLEAN Cancelled;
-       u32 i = 0;
-
-#ifdef RTMP_MAC_USB
-       DECLARE_WAIT_QUEUE_HEAD_ONSTACK(unlink_wakeup);
-       DECLARE_WAITQUEUE(wait, current);
-#endif /* RTMP_MAC_USB // */
-
-       GET_PAD_FROM_NET_DEV(pAd, net_dev);
-
-       DBGPRINT(RT_DEBUG_TRACE, ("===> rt28xx_close\n"));
-
-       Cancelled = FALSE;
-       /* Sanity check for pAd */
-       if (pAd == NULL)
-               return 0;       /* close ok */
-
-       {
-#ifdef RTMP_MAC_PCI
-               RTMPPCIeLinkCtrlValueRestore(pAd, RESTORE_CLOSE);
-#endif /* RTMP_MAC_PCI // */
-
-               /* If driver doesn't wake up firmware here, */
-               /* NICLoadFirmware will hang forever when interface is up again. */
-               if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE)) {
-                       AsicForceWakeup(pAd, TRUE);
-               }
-#ifdef RTMP_MAC_USB
-               RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_REMOVE_IN_PROGRESS);
-#endif /* RTMP_MAC_USB // */
-
-               MlmeRadioOff(pAd);
-#ifdef RTMP_MAC_PCI
-               pAd->bPCIclkOff = FALSE;
-#endif /* RTMP_MAC_PCI // */
-       }
-
-       RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS);
-
-       for (i = 0; i < NUM_OF_TX_RING; i++) {
-               while (pAd->DeQueueRunning[i] == TRUE) {
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("Waiting for TxQueue[%d] done..........\n",
-                                 i));
-                       RTMPusecDelay(1000);
-               }
-       }
-
-#ifdef RTMP_MAC_USB
-       /* ensure there are no more active urbs. */
-       add_wait_queue(&unlink_wakeup, &wait);
-       pAd->wait = &unlink_wakeup;
-
-       /* maybe wait for deletions to finish. */
-       i = 0;
-       /*while((i < 25) && atomic_read(&pAd->PendingRx) > 0) */
-       while (i < 25) {
-               unsigned long IrqFlags;
-
-               RTMP_IRQ_LOCK(&pAd->BulkInLock, IrqFlags);
-               if (pAd->PendingRx == 0) {
-                       RTMP_IRQ_UNLOCK(&pAd->BulkInLock, IrqFlags);
-                       break;
-               }
-               RTMP_IRQ_UNLOCK(&pAd->BulkInLock, IrqFlags);
-
-               msleep(UNLINK_TIMEOUT_MS);      /*Time in millisecond */
-               i++;
-       }
-       pAd->wait = NULL;
-       remove_wait_queue(&unlink_wakeup, &wait);
-#endif /* RTMP_MAC_USB // */
-
-       /* Stop Mlme state machine */
-       MlmeHalt(pAd);
-
-       /* Close net tasklets */
-       RtmpNetTaskExit(pAd);
-
-       {
-               MacTableReset(pAd);
-       }
-
-       MeasureReqTabExit(pAd);
-       TpcReqTabExit(pAd);
-
-       /* Close kernel threads */
-       RtmpMgmtTaskExit(pAd);
-
-#ifdef RTMP_MAC_PCI
-       {
-               BOOLEAN brc;
-               /*      unsigned long                   Value; */
-
-               if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_ACTIVE)) {
-                       RTMP_ASIC_INTERRUPT_DISABLE(pAd);
-               }
-               /* Receive packets to clear DMA index after disable interrupt. */
-               /* RTMPHandleRxDoneInterrupt(pAd); */
-               /* put radio off to save power when driver unloads.  After radiooff, can't write/read register, so need to finish all. */
-               /* register access before Radio off. */
-
-               brc = RT28xxPciAsicRadioOff(pAd, RTMP_HALT, 0);
-
-/*In  solution 3 of 3090F, the bPCIclkOff will be set to TRUE after calling RT28xxPciAsicRadioOff */
-               pAd->bPCIclkOff = FALSE;
-
-               if (brc == FALSE) {
-                       DBGPRINT(RT_DEBUG_ERROR,
-                                ("%s call RT28xxPciAsicRadioOff fail!\n",
-                                 __func__));
-               }
-       }
-
-/*
-       if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_ACTIVE))
-       {
-               RTMP_ASIC_INTERRUPT_DISABLE(pAd);
-       }
-
-       // Disable Rx, register value supposed will remain after reset
-       NICIssueReset(pAd);
-*/
-#endif /* RTMP_MAC_PCI // */
-
-       /* Free IRQ */
-       if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE)) {
-#ifdef RTMP_MAC_PCI
-               /* Deregister interrupt function */
-               RtmpOSIRQRelease(net_dev);
-#endif /* RTMP_MAC_PCI // */
-               RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE);
-       }
-       /* Free Ring or USB buffers */
-       RTMPFreeTxRxRingMemory(pAd);
-
-       RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS);
-
-       /* Free BA reorder resource */
-       ba_reordering_resource_release(pAd);
-
-       RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_START_UP);
-
-/*+++Modify by woody to solve the bulk fail+++*/
-       {
-       }
-
-       DBGPRINT(RT_DEBUG_TRACE, ("<=== rt28xx_close\n"));
-       return 0;               /* close ok */
-}                              /* End of rt28xx_close */
-
-/*
-========================================================================
-Routine Description:
-    Open raxx interface.
-
-Arguments:
-       *net_dev                        the raxx interface pointer
-
-Return Value:
-    0                                  Open OK
-       otherwise                       Open Fail
-
-Note:
-========================================================================
-*/
-int rt28xx_open(struct net_device *dev)
-{
-       struct net_device *net_dev = (struct net_device *)dev;
-       struct rt_rtmp_adapter *pAd = NULL;
-       int retval = 0;
-       /*struct os_cookie *pObj; */
-
-       GET_PAD_FROM_NET_DEV(pAd, net_dev);
-
-       /* Sanity check for pAd */
-       if (pAd == NULL) {
-               /* if 1st open fail, pAd will be free;
-                  So the net_dev->ml_priv will be NULL in 2rd open */
-               return -1;
-       }
-
-       if (net_dev->priv_flags == INT_MAIN) {
-               if (pAd->OpMode == OPMODE_STA)
-                       net_dev->wireless_handlers =
-                           (struct iw_handler_def *)&rt28xx_iw_handler_def;
-       }
-       /* Request interrupt service routine for PCI device */
-       /* register the interrupt routine with the os */
-       RtmpOSIRQRequest(net_dev);
-
-       /* Init IRQ parameters stored in pAd */
-       RTMP_IRQ_INIT(pAd);
-
-       /* Chip & other init */
-       if (rt28xx_init(pAd, mac, hostname) == FALSE)
-               goto err;
-
-       /* Enable Interrupt */
-       RTMP_IRQ_ENABLE(pAd);
-
-       /* Now Enable RxTx */
-       RTMPEnableRxTx(pAd);
-       RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_START_UP);
-
-       {
-               u32 reg = 0;
-               RTMP_IO_READ32(pAd, 0x1300, &reg);      /* clear garbage interrupts */
-               printk(KERN_DEBUG "0x1300 = %08x\n", reg);
-       }
-
-       {
-/*      u32 reg; */
-/*      u8  byte; */
-/*      u16 tmp; */
-
-/*      RTMP_IO_READ32(pAd, XIFS_TIME_CFG, &reg); */
-
-/*      tmp = 0x0805; */
-/*      reg  = (reg & 0xffff0000) | tmp; */
-/*      RTMP_IO_WRITE32(pAd, XIFS_TIME_CFG, reg); */
-
-       }
-#ifdef RTMP_MAC_PCI
-       RTMPInitPCIeLinkCtrlValue(pAd);
-#endif /* RTMP_MAC_PCI // */
-
-       return retval;
-
-err:
-/*+++Add by shiang, move from rt28xx_init() to here. */
-       RtmpOSIRQRelease(net_dev);
-/*---Add by shiang, move from rt28xx_init() to here. */
-       return -1;
-}                              /* End of rt28xx_open */
-
-static const struct net_device_ops rt2860_netdev_ops = {
-       .ndo_open = MainVirtualIF_open,
-       .ndo_stop = MainVirtualIF_close,
-       .ndo_do_ioctl = rt28xx_sta_ioctl,
-       .ndo_get_stats = RT28xx_get_ether_stats,
-       .ndo_validate_addr = NULL,
-       .ndo_set_mac_address = eth_mac_addr,
-       .ndo_change_mtu = eth_change_mtu,
-       .ndo_start_xmit = rt28xx_send_packets,
-};
-
-struct net_device *RtmpPhyNetDevInit(struct rt_rtmp_adapter *pAd,
-                          struct rt_rtmp_os_netdev_op_hook *pNetDevHook)
-{
-       struct net_device *net_dev = NULL;
-/*      int             Status; */
-
-       net_dev =
-           RtmpOSNetDevCreate(pAd, INT_MAIN, 0, sizeof(struct rt_rtmp_adapter *),
-                              INF_MAIN_DEV_NAME);
-       if (net_dev == NULL) {
-               printk
-                   ("RtmpPhyNetDevInit(): creation failed for main physical net device!\n");
-               return NULL;
-       }
-
-       NdisZeroMemory((unsigned char *)pNetDevHook,
-                      sizeof(struct rt_rtmp_os_netdev_op_hook));
-       pNetDevHook->netdev_ops = &rt2860_netdev_ops;
-       pNetDevHook->priv_flags = INT_MAIN;
-       pNetDevHook->needProtcted = FALSE;
-
-       net_dev->ml_priv = (void *)pAd;
-       pAd->net_dev = net_dev;
-
-       return net_dev;
-
-}
-
-/*
-========================================================================
-Routine Description:
-    The entry point for Linux kernel sent packet to our driver.
-
-Arguments:
-    sk_buff *skb               the pointer refer to a sk_buffer.
-
-Return Value:
-    0
-
-Note:
-       This function is the entry point of Tx Path for Os delivery packet to
-       our driver. You only can put OS-depened & STA/AP common handle procedures
-       in here.
-========================================================================
-*/
-int rt28xx_packet_xmit(struct sk_buff *skb)
-{
-       struct net_device *net_dev = skb->dev;
-       struct rt_rtmp_adapter *pAd = NULL;
-       int status = NETDEV_TX_OK;
-       void *pPacket = (void *)skb;
-
-       GET_PAD_FROM_NET_DEV(pAd, net_dev);
-
-       /* RT2870STA does this in RTMPSendPackets() */
-
-       {
-               /* Drop send request since we are in monitor mode */
-               if (MONITOR_ON(pAd)) {
-                       RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
-                       goto done;
-               }
-       }
-
-       /* EapolStart size is 18 */
-       if (skb->len < 14) {
-               /*printk("bad packet size: %d\n", pkt->len); */
-               hex_dump("bad packet", skb->data, skb->len);
-               RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
-               goto done;
-       }
-
-       RTMP_SET_PACKET_5VT(pPacket, 0);
-       STASendPackets((void *)pAd, (void **)&pPacket, 1);
-
-       status = NETDEV_TX_OK;
-done:
-
-       return status;
-}
-
-/*
-========================================================================
-Routine Description:
-    Send a packet to WLAN.
-
-Arguments:
-    skb_p           points to our adapter
-    dev_p           which WLAN network interface
-
-Return Value:
-    0: transmit successfully
-    otherwise: transmit fail
-
-Note:
-========================================================================
-*/
-static int rt28xx_send_packets(IN struct sk_buff *skb_p,
-                              IN struct net_device *net_dev)
-{
-       struct rt_rtmp_adapter *pAd = NULL;
-
-       GET_PAD_FROM_NET_DEV(pAd, net_dev);
-
-       if (!(net_dev->flags & IFF_UP)) {
-               RELEASE_NDIS_PACKET(pAd, (void *)skb_p,
-                                   NDIS_STATUS_FAILURE);
-               return NETDEV_TX_OK;
-       }
-
-       NdisZeroMemory((u8 *)&skb_p->cb[CB_OFF], 15);
-       RTMP_SET_PACKET_NET_DEVICE_MBSSID(skb_p, MAIN_MBSSID);
-
-       return rt28xx_packet_xmit(skb_p);
-}
-
-/* This function will be called when query /proc */
-struct iw_statistics *rt28xx_get_wireless_stats(IN struct net_device *net_dev)
-{
-       struct rt_rtmp_adapter *pAd = NULL;
-
-       GET_PAD_FROM_NET_DEV(pAd, net_dev);
-
-       DBGPRINT(RT_DEBUG_TRACE, ("rt28xx_get_wireless_stats --->\n"));
-
-       pAd->iw_stats.status = 0;       /* Status - device dependent for now */
-
-       /* link quality */
-       if (pAd->OpMode == OPMODE_STA)
-               pAd->iw_stats.qual.qual =
-                   ((pAd->Mlme.ChannelQuality * 12) / 10 + 10);
-
-       if (pAd->iw_stats.qual.qual > 100)
-               pAd->iw_stats.qual.qual = 100;
-
-       if (pAd->OpMode == OPMODE_STA) {
-               pAd->iw_stats.qual.level =
-                   RTMPMaxRssi(pAd, pAd->StaCfg.RssiSample.LastRssi0,
-                               pAd->StaCfg.RssiSample.LastRssi1,
-                               pAd->StaCfg.RssiSample.LastRssi2);
-       }
-
-       pAd->iw_stats.qual.noise = pAd->BbpWriteLatch[66];      /* noise level (dBm) */
-
-       pAd->iw_stats.qual.noise += 256 - 143;
-       pAd->iw_stats.qual.updated = 1; /* Flags to know if updated */
-#ifdef IW_QUAL_DBM
-       pAd->iw_stats.qual.updated |= IW_QUAL_DBM;      /* Level + Noise are dBm */
-#endif /* IW_QUAL_DBM // */
-
-       pAd->iw_stats.discard.nwid = 0; /* Rx : Wrong nwid/essid */
-       pAd->iw_stats.miss.beacon = 0;  /* Missed beacons/superframe */
-
-       DBGPRINT(RT_DEBUG_TRACE, ("<--- rt28xx_get_wireless_stats\n"));
-       return &pAd->iw_stats;
-}
-
-void tbtt_tasklet(unsigned long data)
-{
-/*#define MAX_TX_IN_TBTT                (16) */
-
-}
-
-/*
-    ========================================================================
-
-    Routine Description:
-       return ethernet statistics counter
-
-    Arguments:
-       net_dev                         Pointer to net_device
-
-    Return Value:
-       net_device_stats*
-
-    Note:
-
-    ========================================================================
-*/
-static struct net_device_stats *RT28xx_get_ether_stats(IN struct net_device
-                                                      *net_dev)
-{
-       struct rt_rtmp_adapter *pAd = NULL;
-
-       if (net_dev)
-               GET_PAD_FROM_NET_DEV(pAd, net_dev);
-
-       if (pAd) {
-
-               pAd->stats.rx_packets =
-                   pAd->WlanCounters.ReceivedFragmentCount.QuadPart;
-               pAd->stats.tx_packets =
-                   pAd->WlanCounters.TransmittedFragmentCount.QuadPart;
-
-               pAd->stats.rx_bytes = pAd->RalinkCounters.ReceivedByteCount;
-               pAd->stats.tx_bytes = pAd->RalinkCounters.TransmittedByteCount;
-
-               pAd->stats.rx_errors = pAd->Counters8023.RxErrors;
-               pAd->stats.tx_errors = pAd->Counters8023.TxErrors;
-
-               pAd->stats.rx_dropped = 0;
-               pAd->stats.tx_dropped = 0;
-
-               pAd->stats.multicast = pAd->WlanCounters.MulticastReceivedFrameCount.QuadPart;  /* multicast packets received */
-               pAd->stats.collisions = pAd->Counters8023.OneCollision + pAd->Counters8023.MoreCollisions;      /* Collision packets */
-
-               pAd->stats.rx_length_errors = 0;
-               pAd->stats.rx_over_errors = pAd->Counters8023.RxNoBuffer;       /* receiver ring buff overflow */
-               pAd->stats.rx_crc_errors = 0;   /*pAd->WlanCounters.FCSErrorCount;     // recved pkt with crc error */
-               pAd->stats.rx_frame_errors = pAd->Counters8023.RcvAlignmentErrors;      /* recv'd frame alignment error */
-               pAd->stats.rx_fifo_errors = pAd->Counters8023.RxNoBuffer;       /* recv'r fifo overrun */
-               pAd->stats.rx_missed_errors = 0;        /* receiver missed packet */
-
-               /* detailed tx_errors */
-               pAd->stats.tx_aborted_errors = 0;
-               pAd->stats.tx_carrier_errors = 0;
-               pAd->stats.tx_fifo_errors = 0;
-               pAd->stats.tx_heartbeat_errors = 0;
-               pAd->stats.tx_window_errors = 0;
-
-               /* for cslip etc */
-               pAd->stats.rx_compressed = 0;
-               pAd->stats.tx_compressed = 0;
-
-               return &pAd->stats;
-       } else
-               return NULL;
-}
-
-BOOLEAN RtmpPhyNetDevExit(struct rt_rtmp_adapter *pAd, struct net_device *net_dev)
-{
-
-       /* Unregister network device */
-       if (net_dev != NULL) {
-               printk
-                   ("RtmpOSNetDevDetach(): RtmpOSNetDeviceDetach(), dev->name=%s!\n",
-                    net_dev->name);
-               RtmpOSNetDevDetach(net_dev);
-       }
-
-       return TRUE;
-
-}
-
-/*
-========================================================================
-Routine Description:
-    Allocate memory for adapter control block.
-
-Arguments:
-    pAd                                        Pointer to our adapter
-
-Return Value:
-       NDIS_STATUS_SUCCESS
-       NDIS_STATUS_FAILURE
-       NDIS_STATUS_RESOURCES
-
-Note:
-========================================================================
-*/
-int AdapterBlockAllocateMemory(void *handle, void ** ppAd)
-{
-
-       *ppAd = vmalloc(sizeof(struct rt_rtmp_adapter));
-       /* pci_alloc_consistent(pci_dev, sizeof(struct rt_rtmp_adapter), phy_addr); */
-
-       if (*ppAd) {
-               NdisZeroMemory(*ppAd, sizeof(struct rt_rtmp_adapter));
-               ((struct rt_rtmp_adapter *)*ppAd)->OS_Cookie = handle;
-               return NDIS_STATUS_SUCCESS;
-       } else {
-               return NDIS_STATUS_FAILURE;
-       }
-}
diff --git a/drivers/staging/rt2860/rt_pci_rbus.c b/drivers/staging/rt2860/rt_pci_rbus.c
deleted file mode 100644 (file)
index f80ab4e..0000000
+++ /dev/null
@@ -1,837 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-    Module Name:
-    rt_pci_rbus.c
-
-    Abstract:
-    Create and register network interface.
-
-    Revision History:
-    Who                When            What
-    Justin P. Mattock  11/07/2010      Fix a typo
-    --------    ----------      ----------------------------------------------
-*/
-
-#include "rt_config.h"
-#include <linux/pci.h>
-
-IRQ_HANDLE_TYPE rt2860_interrupt(int irq, void *dev_instance);
-
-static void rx_done_tasklet(unsigned long data);
-static void mgmt_dma_done_tasklet(unsigned long data);
-static void ac0_dma_done_tasklet(unsigned long data);
-static void ac1_dma_done_tasklet(unsigned long data);
-static void ac2_dma_done_tasklet(unsigned long data);
-static void ac3_dma_done_tasklet(unsigned long data);
-static void fifo_statistic_full_tasklet(unsigned long data);
-
-/*---------------------------------------------------------------------*/
-/* Symbol & Macro Definitions                                          */
-/*---------------------------------------------------------------------*/
-#define RT2860_INT_RX_DLY                              (1<<0)  /* bit 0 */
-#define RT2860_INT_TX_DLY                              (1<<1)  /* bit 1 */
-#define RT2860_INT_RX_DONE                             (1<<2)  /* bit 2 */
-#define RT2860_INT_AC0_DMA_DONE                        (1<<3)  /* bit 3 */
-#define RT2860_INT_AC1_DMA_DONE                        (1<<4)  /* bit 4 */
-#define RT2860_INT_AC2_DMA_DONE                        (1<<5)  /* bit 5 */
-#define RT2860_INT_AC3_DMA_DONE                        (1<<6)  /* bit 6 */
-#define RT2860_INT_HCCA_DMA_DONE               (1<<7)  /* bit 7 */
-#define RT2860_INT_MGMT_DONE                   (1<<8)  /* bit 8 */
-
-#define INT_RX                 RT2860_INT_RX_DONE
-
-#define INT_AC0_DLY            (RT2860_INT_AC0_DMA_DONE)       /*| RT2860_INT_TX_DLY) */
-#define INT_AC1_DLY            (RT2860_INT_AC1_DMA_DONE)       /*| RT2860_INT_TX_DLY) */
-#define INT_AC2_DLY            (RT2860_INT_AC2_DMA_DONE)       /*| RT2860_INT_TX_DLY) */
-#define INT_AC3_DLY            (RT2860_INT_AC3_DMA_DONE)       /*| RT2860_INT_TX_DLY) */
-#define INT_HCCA_DLY   (RT2860_INT_HCCA_DMA_DONE)      /*| RT2860_INT_TX_DLY) */
-#define INT_MGMT_DLY   RT2860_INT_MGMT_DONE
-
-/***************************************************************************
-  *
-  *    Interface-depended memory allocation/Free related procedures.
-  *            Mainly for Hardware TxDesc/RxDesc/MgmtDesc, DMA Memory for TxData/RxData, etc.,
-  *
-  **************************************************************************/
-/* Function for TxDesc Memory allocation. */
-void RTMP_AllocateTxDescMemory(struct rt_rtmp_adapter *pAd,
-                              u32 Index,
-                              unsigned long Length,
-                              IN BOOLEAN Cached,
-                              void **VirtualAddress,
-                              dma_addr_t *PhysicalAddress)
-{
-       struct os_cookie *pObj = (struct os_cookie *)pAd->OS_Cookie;
-
-       *VirtualAddress =
-           (void *)pci_alloc_consistent(pObj->pci_dev, sizeof(char) * Length,
-                                        PhysicalAddress);
-
-}
-
-/* Function for MgmtDesc Memory allocation. */
-void RTMP_AllocateMgmtDescMemory(struct rt_rtmp_adapter *pAd,
-                                unsigned long Length,
-                                IN BOOLEAN Cached,
-                                void **VirtualAddress,
-                                dma_addr_t *PhysicalAddress)
-{
-       struct os_cookie *pObj = (struct os_cookie *)pAd->OS_Cookie;
-
-       *VirtualAddress =
-           (void *)pci_alloc_consistent(pObj->pci_dev, sizeof(char) * Length,
-                                        PhysicalAddress);
-
-}
-
-/* Function for RxDesc Memory allocation. */
-void RTMP_AllocateRxDescMemory(struct rt_rtmp_adapter *pAd,
-                              unsigned long Length,
-                              IN BOOLEAN Cached,
-                              void **VirtualAddress,
-                              dma_addr_t *PhysicalAddress)
-{
-       struct os_cookie *pObj = (struct os_cookie *)pAd->OS_Cookie;
-
-       *VirtualAddress =
-           (void *)pci_alloc_consistent(pObj->pci_dev, sizeof(char) * Length,
-                                        PhysicalAddress);
-
-}
-
-/* Function for free allocated Desc Memory. */
-void RTMP_FreeDescMemory(struct rt_rtmp_adapter *pAd,
-                        unsigned long Length,
-                        void *VirtualAddress,
-                        dma_addr_t PhysicalAddress)
-{
-       struct os_cookie *pObj = (struct os_cookie *)pAd->OS_Cookie;
-
-       pci_free_consistent(pObj->pci_dev, Length, VirtualAddress,
-                           PhysicalAddress);
-}
-
-/* Function for TxData DMA Memory allocation. */
-void RTMP_AllocateFirstTxBuffer(struct rt_rtmp_adapter *pAd,
-                               u32 Index,
-                               unsigned long Length,
-                               IN BOOLEAN Cached,
-                               void **VirtualAddress,
-                               dma_addr_t *PhysicalAddress)
-{
-       struct os_cookie *pObj = (struct os_cookie *)pAd->OS_Cookie;
-
-       *VirtualAddress =
-           (void *)pci_alloc_consistent(pObj->pci_dev, sizeof(char) * Length,
-                                        PhysicalAddress);
-}
-
-void RTMP_FreeFirstTxBuffer(struct rt_rtmp_adapter *pAd,
-                           unsigned long Length,
-                           IN BOOLEAN Cached,
-                           void *VirtualAddress,
-                           dma_addr_t PhysicalAddress)
-{
-       struct os_cookie *pObj = (struct os_cookie *)pAd->OS_Cookie;
-
-       pci_free_consistent(pObj->pci_dev, Length, VirtualAddress,
-                           PhysicalAddress);
-}
-
-/*
- * FUNCTION: Allocate a common buffer for DMA
- * ARGUMENTS:
- *     AdapterHandle:  AdapterHandle
- *     Length:  Number of bytes to allocate
- *     Cached:  Whether or not the memory can be cached
- *     VirtualAddress:  Pointer to memory is returned here
- *     PhysicalAddress:  Physical address corresponding to virtual address
- */
-void RTMP_AllocateSharedMemory(struct rt_rtmp_adapter *pAd,
-                              unsigned long Length,
-                              IN BOOLEAN Cached,
-                              void **VirtualAddress,
-                              dma_addr_t *PhysicalAddress)
-{
-       struct os_cookie *pObj = (struct os_cookie *)pAd->OS_Cookie;
-
-       *VirtualAddress =
-           (void *)pci_alloc_consistent(pObj->pci_dev, sizeof(char) * Length,
-                                        PhysicalAddress);
-}
-
-/*
- * FUNCTION: Allocate a packet buffer for DMA
- * ARGUMENTS:
- *     AdapterHandle:  AdapterHandle
- *     Length:  Number of bytes to allocate
- *     Cached:  Whether or not the memory can be cached
- *     VirtualAddress:  Pointer to memory is returned here
- *     PhysicalAddress:  Physical address corresponding to virtual address
- * Notes:
- *     Cached is ignored: always cached memory
- */
-void *RTMP_AllocateRxPacketBuffer(struct rt_rtmp_adapter *pAd,
-                                        unsigned long Length,
-                                        IN BOOLEAN Cached,
-                                        void **VirtualAddress,
-                                        OUT dma_addr_t *
-                                        PhysicalAddress)
-{
-       struct sk_buff *pkt;
-
-       pkt = dev_alloc_skb(Length);
-
-       if (pkt == NULL) {
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("can't allocate rx %ld size packet\n", Length));
-       }
-
-       if (pkt) {
-               RTMP_SET_PACKET_SOURCE(OSPKT_TO_RTPKT(pkt), PKTSRC_NDIS);
-               *VirtualAddress = (void *)pkt->data;
-               *PhysicalAddress =
-                   PCI_MAP_SINGLE(pAd, *VirtualAddress, Length, -1,
-                                  PCI_DMA_FROMDEVICE);
-       } else {
-               *VirtualAddress = (void *)NULL;
-               *PhysicalAddress = (dma_addr_t)NULL;
-       }
-
-       return (void *)pkt;
-}
-
-void Invalid_Remaining_Packet(struct rt_rtmp_adapter *pAd, unsigned long VirtualAddress)
-{
-       dma_addr_t PhysicalAddress;
-
-       PhysicalAddress =
-           PCI_MAP_SINGLE(pAd, (void *)(VirtualAddress + 1600),
-                          RX_BUFFER_NORMSIZE - 1600, -1, PCI_DMA_FROMDEVICE);
-}
-
-int RtmpNetTaskInit(struct rt_rtmp_adapter *pAd)
-{
-       struct os_cookie *pObj;
-
-       pObj = (struct os_cookie *)pAd->OS_Cookie;
-
-       tasklet_init(&pObj->rx_done_task, rx_done_tasklet, (unsigned long)pAd);
-       tasklet_init(&pObj->mgmt_dma_done_task, mgmt_dma_done_tasklet,
-                    (unsigned long)pAd);
-       tasklet_init(&pObj->ac0_dma_done_task, ac0_dma_done_tasklet,
-                    (unsigned long)pAd);
-       tasklet_init(&pObj->ac1_dma_done_task, ac1_dma_done_tasklet,
-                    (unsigned long)pAd);
-       tasklet_init(&pObj->ac2_dma_done_task, ac2_dma_done_tasklet,
-                    (unsigned long)pAd);
-       tasklet_init(&pObj->ac3_dma_done_task, ac3_dma_done_tasklet,
-                    (unsigned long)pAd);
-       tasklet_init(&pObj->tbtt_task, tbtt_tasklet, (unsigned long)pAd);
-       tasklet_init(&pObj->fifo_statistic_full_task,
-                    fifo_statistic_full_tasklet, (unsigned long)pAd);
-
-       return NDIS_STATUS_SUCCESS;
-}
-
-void RtmpNetTaskExit(struct rt_rtmp_adapter *pAd)
-{
-       struct os_cookie *pObj;
-
-       pObj = (struct os_cookie *)pAd->OS_Cookie;
-
-       tasklet_kill(&pObj->rx_done_task);
-       tasklet_kill(&pObj->mgmt_dma_done_task);
-       tasklet_kill(&pObj->ac0_dma_done_task);
-       tasklet_kill(&pObj->ac1_dma_done_task);
-       tasklet_kill(&pObj->ac2_dma_done_task);
-       tasklet_kill(&pObj->ac3_dma_done_task);
-       tasklet_kill(&pObj->tbtt_task);
-       tasklet_kill(&pObj->fifo_statistic_full_task);
-}
-
-int RtmpMgmtTaskInit(struct rt_rtmp_adapter *pAd)
-{
-
-       return NDIS_STATUS_SUCCESS;
-}
-
-/*
-========================================================================
-Routine Description:
-    Close kernel threads.
-
-Arguments:
-       *pAd                            the raxx interface data pointer
-
-Return Value:
-    NONE
-
-Note:
-========================================================================
-*/
-void RtmpMgmtTaskExit(struct rt_rtmp_adapter *pAd)
-{
-
-       return;
-}
-
-static inline void rt2860_int_enable(struct rt_rtmp_adapter *pAd, unsigned int mode)
-{
-       u32 regValue;
-
-       pAd->int_disable_mask &= ~(mode);
-       regValue = pAd->int_enable_reg & ~(pAd->int_disable_mask);
-       /*if (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE)) */
-       {
-               RTMP_IO_WRITE32(pAd, INT_MASK_CSR, regValue);   /* 1:enable */
-       }
-       /*else */
-       /*      DBGPRINT(RT_DEBUG_TRACE, ("fOP_STATUS_DOZE !\n")); */
-
-       if (regValue != 0)
-               RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_ACTIVE);
-}
-
-static inline void rt2860_int_disable(struct rt_rtmp_adapter *pAd, unsigned int mode)
-{
-       u32 regValue;
-
-       pAd->int_disable_mask |= mode;
-       regValue = pAd->int_enable_reg & ~(pAd->int_disable_mask);
-       RTMP_IO_WRITE32(pAd, INT_MASK_CSR, regValue);   /* 0: disable */
-
-       if (regValue == 0) {
-               RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_ACTIVE);
-       }
-}
-
-/***************************************************************************
-  *
-  *    tasklet related procedures.
-  *
-  **************************************************************************/
-static void mgmt_dma_done_tasklet(unsigned long data)
-{
-       unsigned long flags;
-       struct rt_rtmp_adapter *pAd = (struct rt_rtmp_adapter *)data;
-       INT_SOURCE_CSR_STRUC IntSource;
-       struct os_cookie *pObj;
-
-       /* Do nothing if the driver is starting halt state. */
-       /* This might happen when timer already been fired before cancel timer with mlmehalt */
-       if (RTMP_TEST_FLAG
-           (pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST))
-               return;
-
-       pObj = (struct os_cookie *)pAd->OS_Cookie;
-
-/*      printk("mgmt_dma_done_process\n"); */
-       IntSource.word = 0;
-       IntSource.field.MgmtDmaDone = 1;
-       pAd->int_pending &= ~INT_MGMT_DLY;
-
-       RTMPHandleMgmtRingDmaDoneInterrupt(pAd);
-
-       /* if you use RTMP_SEM_LOCK, sometimes kernel will hang up, without any */
-       /* bug report output */
-       RTMP_INT_LOCK(&pAd->irq_lock, flags);
-       /*
-        * double check to avoid lose of interrupts
-        */
-       if (pAd->int_pending & INT_MGMT_DLY) {
-               tasklet_hi_schedule(&pObj->mgmt_dma_done_task);
-               RTMP_INT_UNLOCK(&pAd->irq_lock, flags);
-               return;
-       }
-
-       /* enable TxDataInt again */
-       rt2860_int_enable(pAd, INT_MGMT_DLY);
-       RTMP_INT_UNLOCK(&pAd->irq_lock, flags);
-}
-
-static void rx_done_tasklet(unsigned long data)
-{
-       unsigned long flags;
-       struct rt_rtmp_adapter *pAd = (struct rt_rtmp_adapter *)data;
-       BOOLEAN bReschedule = 0;
-       struct os_cookie *pObj;
-
-       /* Do nothing if the driver is starting halt state. */
-       /* This might happen when timer already been fired before cancel timer with mlmehalt */
-       if (RTMP_TEST_FLAG
-           (pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST))
-               return;
-
-       pObj = (struct os_cookie *)pAd->OS_Cookie;
-
-       pAd->int_pending &= ~(INT_RX);
-       bReschedule = STARxDoneInterruptHandle(pAd, 0);
-
-       RTMP_INT_LOCK(&pAd->irq_lock, flags);
-       /*
-        * double check to avoid rotting packet
-        */
-       if (pAd->int_pending & INT_RX || bReschedule) {
-               tasklet_hi_schedule(&pObj->rx_done_task);
-               RTMP_INT_UNLOCK(&pAd->irq_lock, flags);
-               return;
-       }
-
-       /* enable Rxint again */
-       rt2860_int_enable(pAd, INT_RX);
-       RTMP_INT_UNLOCK(&pAd->irq_lock, flags);
-
-}
-
-void fifo_statistic_full_tasklet(unsigned long data)
-{
-       unsigned long flags;
-       struct rt_rtmp_adapter *pAd = (struct rt_rtmp_adapter *)data;
-       struct os_cookie *pObj;
-
-       /* Do nothing if the driver is starting halt state. */
-       /* This might happen when timer already been fired before cancel timer with mlmehalt */
-       if (RTMP_TEST_FLAG
-           (pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST))
-               return;
-
-       pObj = (struct os_cookie *)pAd->OS_Cookie;
-
-       pAd->int_pending &= ~(FifoStaFullInt);
-       NICUpdateFifoStaCounters(pAd);
-
-       RTMP_INT_LOCK(&pAd->irq_lock, flags);
-       /*
-        * double check to avoid rotting packet
-        */
-       if (pAd->int_pending & FifoStaFullInt) {
-               tasklet_hi_schedule(&pObj->fifo_statistic_full_task);
-               RTMP_INT_UNLOCK(&pAd->irq_lock, flags);
-               return;
-       }
-
-       /* enable Rxint again */
-
-       rt2860_int_enable(pAd, FifoStaFullInt);
-       RTMP_INT_UNLOCK(&pAd->irq_lock, flags);
-
-}
-
-static void ac3_dma_done_tasklet(unsigned long data)
-{
-       unsigned long flags;
-       struct rt_rtmp_adapter *pAd = (struct rt_rtmp_adapter *)data;
-       INT_SOURCE_CSR_STRUC IntSource;
-       struct os_cookie *pObj;
-       BOOLEAN bReschedule = 0;
-
-       /* Do nothing if the driver is starting halt state. */
-       /* This might happen when timer already been fired before cancel timer with mlmehalt */
-       if (RTMP_TEST_FLAG
-           (pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST))
-               return;
-
-       pObj = (struct os_cookie *)pAd->OS_Cookie;
-
-/*      printk("ac0_dma_done_process\n"); */
-       IntSource.word = 0;
-       IntSource.field.Ac3DmaDone = 1;
-       pAd->int_pending &= ~INT_AC3_DLY;
-
-       bReschedule = RTMPHandleTxRingDmaDoneInterrupt(pAd, IntSource);
-
-       RTMP_INT_LOCK(&pAd->irq_lock, flags);
-       /*
-        * double check to avoid lose of interrupts
-        */
-       if ((pAd->int_pending & INT_AC3_DLY) || bReschedule) {
-               tasklet_hi_schedule(&pObj->ac3_dma_done_task);
-               RTMP_INT_UNLOCK(&pAd->irq_lock, flags);
-               return;
-       }
-
-       /* enable TxDataInt again */
-       rt2860_int_enable(pAd, INT_AC3_DLY);
-       RTMP_INT_UNLOCK(&pAd->irq_lock, flags);
-}
-
-static void ac2_dma_done_tasklet(unsigned long data)
-{
-       unsigned long flags;
-       struct rt_rtmp_adapter *pAd = (struct rt_rtmp_adapter *)data;
-       INT_SOURCE_CSR_STRUC IntSource;
-       struct os_cookie *pObj;
-       BOOLEAN bReschedule = 0;
-
-       /* Do nothing if the driver is starting halt state. */
-       /* This might happen when timer already been fired before cancel timer with mlmehalt */
-       if (RTMP_TEST_FLAG
-           (pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST))
-               return;
-
-       pObj = (struct os_cookie *)pAd->OS_Cookie;
-
-       IntSource.word = 0;
-       IntSource.field.Ac2DmaDone = 1;
-       pAd->int_pending &= ~INT_AC2_DLY;
-
-       bReschedule = RTMPHandleTxRingDmaDoneInterrupt(pAd, IntSource);
-
-       RTMP_INT_LOCK(&pAd->irq_lock, flags);
-
-       /*
-        * double check to avoid lose of interrupts
-        */
-       if ((pAd->int_pending & INT_AC2_DLY) || bReschedule) {
-               tasklet_hi_schedule(&pObj->ac2_dma_done_task);
-               RTMP_INT_UNLOCK(&pAd->irq_lock, flags);
-               return;
-       }
-
-       /* enable TxDataInt again */
-       rt2860_int_enable(pAd, INT_AC2_DLY);
-       RTMP_INT_UNLOCK(&pAd->irq_lock, flags);
-}
-
-static void ac1_dma_done_tasklet(unsigned long data)
-{
-       unsigned long flags;
-       struct rt_rtmp_adapter *pAd = (struct rt_rtmp_adapter *)data;
-       INT_SOURCE_CSR_STRUC IntSource;
-       struct os_cookie *pObj;
-       BOOLEAN bReschedule = 0;
-
-       /* Do nothing if the driver is starting halt state. */
-       /* This might happen when timer already been fired before cancel timer with mlmehalt */
-       if (RTMP_TEST_FLAG
-           (pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST))
-               return;
-
-       pObj = (struct os_cookie *)pAd->OS_Cookie;
-
-/*      printk("ac0_dma_done_process\n"); */
-       IntSource.word = 0;
-       IntSource.field.Ac1DmaDone = 1;
-       pAd->int_pending &= ~INT_AC1_DLY;
-
-       bReschedule = RTMPHandleTxRingDmaDoneInterrupt(pAd, IntSource);
-
-       RTMP_INT_LOCK(&pAd->irq_lock, flags);
-       /*
-        * double check to avoid lose of interrupts
-        */
-       if ((pAd->int_pending & INT_AC1_DLY) || bReschedule) {
-               tasklet_hi_schedule(&pObj->ac1_dma_done_task);
-               RTMP_INT_UNLOCK(&pAd->irq_lock, flags);
-               return;
-       }
-
-       /* enable TxDataInt again */
-       rt2860_int_enable(pAd, INT_AC1_DLY);
-       RTMP_INT_UNLOCK(&pAd->irq_lock, flags);
-}
-
-static void ac0_dma_done_tasklet(unsigned long data)
-{
-       unsigned long flags;
-       struct rt_rtmp_adapter *pAd = (struct rt_rtmp_adapter *)data;
-       INT_SOURCE_CSR_STRUC IntSource;
-       struct os_cookie *pObj;
-       BOOLEAN bReschedule = 0;
-
-       /* Do nothing if the driver is starting halt state. */
-       /* This might happen when timer already been fired before cancel timer with mlmehalt */
-       if (RTMP_TEST_FLAG
-           (pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST))
-               return;
-
-       pObj = (struct os_cookie *)pAd->OS_Cookie;
-
-/*      printk("ac0_dma_done_process\n"); */
-       IntSource.word = 0;
-       IntSource.field.Ac0DmaDone = 1;
-       pAd->int_pending &= ~INT_AC0_DLY;
-
-/*      RTMPHandleMgmtRingDmaDoneInterrupt(pAd); */
-       bReschedule = RTMPHandleTxRingDmaDoneInterrupt(pAd, IntSource);
-
-       RTMP_INT_LOCK(&pAd->irq_lock, flags);
-       /*
-        * double check to avoid lose of interrupts
-        */
-       if ((pAd->int_pending & INT_AC0_DLY) || bReschedule) {
-               tasklet_hi_schedule(&pObj->ac0_dma_done_task);
-               RTMP_INT_UNLOCK(&pAd->irq_lock, flags);
-               return;
-       }
-
-       /* enable TxDataInt again */
-       rt2860_int_enable(pAd, INT_AC0_DLY);
-       RTMP_INT_UNLOCK(&pAd->irq_lock, flags);
-}
-
-/***************************************************************************
-  *
-  *    interrupt handler related procedures.
-  *
-  **************************************************************************/
-int print_int_count;
-
-IRQ_HANDLE_TYPE rt2860_interrupt(int irq, void *dev_instance)
-{
-       struct net_device *net_dev = (struct net_device *)dev_instance;
-       struct rt_rtmp_adapter *pAd = NULL;
-       INT_SOURCE_CSR_STRUC IntSource;
-       struct os_cookie *pObj;
-
-       GET_PAD_FROM_NET_DEV(pAd, net_dev);
-
-       pObj = (struct os_cookie *)pAd->OS_Cookie;
-
-       /* Note 03312008: we can not return here before
-          RTMP_IO_READ32(pAd, INT_SOURCE_CSR, &IntSource.word);
-          RTMP_IO_WRITE32(pAd, INT_SOURCE_CSR, IntSource.word);
-          Or kernel will panic after ifconfig ra0 down sometimes */
-
-       /* */
-       /* Initial the Interrupt source. */
-       /* */
-       IntSource.word = 0x00000000L;
-/*      McuIntSource.word = 0x00000000L; */
-
-       /* */
-       /* Get the interrupt sources & saved to local variable */
-       /* */
-       /*RTMP_IO_READ32(pAd, where, &McuIntSource.word); */
-       /*RTMP_IO_WRITE32(pAd, , McuIntSource.word); */
-
-       /* */
-       /* Flag fOP_STATUS_DOZE On, means ASIC put to sleep, elase means ASICK WakeUp */
-       /* And at the same time, clock maybe turned off that say there is no DMA service. */
-       /* when ASIC get to sleep. */
-       /* To prevent system hang on power saving. */
-       /* We need to check it before handle the INT_SOURCE_CSR, ASIC must be wake up. */
-       /* */
-       /* RT2661 => when ASIC is sleeping, MAC register cannot be read and written. */
-       /* RT2860 => when ASIC is sleeping, MAC register can be read and written. */
-/*      if (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE)) */
-       {
-               RTMP_IO_READ32(pAd, INT_SOURCE_CSR, &IntSource.word);
-               RTMP_IO_WRITE32(pAd, INT_SOURCE_CSR, IntSource.word);   /* write 1 to clear */
-       }
-/*      else */
-/*              DBGPRINT(RT_DEBUG_TRACE, (">>>fOP_STATUS_DOZE<<<\n")); */
-
-/*      RTMP_IO_READ32(pAd, INT_SOURCE_CSR, &IsrAfterClear); */
-/*      RTMP_IO_READ32(pAd, MCU_INT_SOURCE_CSR, &McuIsrAfterClear); */
-/*      DBGPRINT(RT_DEBUG_INFO, ("====> RTMPHandleInterrupt(ISR=%08x,Mcu ISR=%08x, After clear ISR=%08x, MCU ISR=%08x)\n", */
-/*                      IntSource.word, McuIntSource.word, IsrAfterClear, McuIsrAfterClear)); */
-
-       /* Do nothing if Reset in progress */
-       if (RTMP_TEST_FLAG
-           (pAd,
-            (fRTMP_ADAPTER_RESET_IN_PROGRESS |
-             fRTMP_ADAPTER_HALT_IN_PROGRESS))) {
-               return IRQ_HANDLED;
-       }
-       /* */
-       /* Handle interrupt, walk through all bits */
-       /* Should start from highest priority interrupt */
-       /* The priority can be adjust by altering processing if statement */
-       /* */
-
-#ifdef DBG
-
-#endif
-
-       pAd->bPCIclkOff = FALSE;
-
-       /* If required spinlock, each interrupt service routine has to acquire */
-       /* and release itself. */
-       /* */
-
-       /* Do nothing if NIC doesn't exist */
-       if (IntSource.word == 0xffffffff) {
-               RTMP_SET_FLAG(pAd,
-                             (fRTMP_ADAPTER_NIC_NOT_EXIST |
-                              fRTMP_ADAPTER_HALT_IN_PROGRESS));
-               return IRQ_HANDLED;
-       }
-
-       if (IntSource.word & TxCoherent) {
-               DBGPRINT(RT_DEBUG_ERROR, (">>>TxCoherent<<<\n"));
-               RTMPHandleRxCoherentInterrupt(pAd);
-       }
-
-       if (IntSource.word & RxCoherent) {
-               DBGPRINT(RT_DEBUG_ERROR, (">>>RxCoherent<<<\n"));
-               RTMPHandleRxCoherentInterrupt(pAd);
-       }
-
-       if (IntSource.word & FifoStaFullInt) {
-               if ((pAd->int_disable_mask & FifoStaFullInt) == 0) {
-                       /* mask FifoStaFullInt */
-                       rt2860_int_disable(pAd, FifoStaFullInt);
-                       tasklet_hi_schedule(&pObj->fifo_statistic_full_task);
-               }
-               pAd->int_pending |= FifoStaFullInt;
-       }
-
-       if (IntSource.word & INT_MGMT_DLY) {
-               if ((pAd->int_disable_mask & INT_MGMT_DLY) == 0) {
-                       rt2860_int_disable(pAd, INT_MGMT_DLY);
-                       tasklet_hi_schedule(&pObj->mgmt_dma_done_task);
-               }
-               pAd->int_pending |= INT_MGMT_DLY;
-       }
-
-       if (IntSource.word & INT_RX) {
-               if ((pAd->int_disable_mask & INT_RX) == 0) {
-
-                       /* mask Rxint */
-                       rt2860_int_disable(pAd, INT_RX);
-                       tasklet_hi_schedule(&pObj->rx_done_task);
-               }
-               pAd->int_pending |= INT_RX;
-       }
-
-       if (IntSource.word & INT_AC3_DLY) {
-
-               if ((pAd->int_disable_mask & INT_AC3_DLY) == 0) {
-                       /* mask TxDataInt */
-                       rt2860_int_disable(pAd, INT_AC3_DLY);
-                       tasklet_hi_schedule(&pObj->ac3_dma_done_task);
-               }
-               pAd->int_pending |= INT_AC3_DLY;
-       }
-
-       if (IntSource.word & INT_AC2_DLY) {
-
-               if ((pAd->int_disable_mask & INT_AC2_DLY) == 0) {
-                       /* mask TxDataInt */
-                       rt2860_int_disable(pAd, INT_AC2_DLY);
-                       tasklet_hi_schedule(&pObj->ac2_dma_done_task);
-               }
-               pAd->int_pending |= INT_AC2_DLY;
-       }
-
-       if (IntSource.word & INT_AC1_DLY) {
-
-               pAd->int_pending |= INT_AC1_DLY;
-
-               if ((pAd->int_disable_mask & INT_AC1_DLY) == 0) {
-                       /* mask TxDataInt */
-                       rt2860_int_disable(pAd, INT_AC1_DLY);
-                       tasklet_hi_schedule(&pObj->ac1_dma_done_task);
-               }
-
-       }
-
-       if (IntSource.word & INT_AC0_DLY) {
-
-/*
-               if (IntSource.word & 0x2) {
-                       u32 reg;
-                       RTMP_IO_READ32(pAd, DELAY_INT_CFG, &reg);
-                       printk("IntSource.word = %08x, DELAY_REG = %08x\n", IntSource.word, reg);
-               }
-*/
-               pAd->int_pending |= INT_AC0_DLY;
-
-               if ((pAd->int_disable_mask & INT_AC0_DLY) == 0) {
-                       /* mask TxDataInt */
-                       rt2860_int_disable(pAd, INT_AC0_DLY);
-                       tasklet_hi_schedule(&pObj->ac0_dma_done_task);
-               }
-
-       }
-
-       if (IntSource.word & PreTBTTInt) {
-               RTMPHandlePreTBTTInterrupt(pAd);
-       }
-
-       if (IntSource.word & TBTTInt) {
-               RTMPHandleTBTTInterrupt(pAd);
-       }
-
-       {
-               if (IntSource.word & AutoWakeupInt)
-                       RTMPHandleTwakeupInterrupt(pAd);
-       }
-
-       return IRQ_HANDLED;
-}
-
-/*
- * invalid or writeback cache
- * and convert virtual address to physical address
- */
-dma_addr_t linux_pci_map_single(struct rt_rtmp_adapter *pAd, void *ptr,
-                               size_t size, int sd_idx, int direction)
-{
-       struct os_cookie *pObj;
-
-       /*
-          ------ Porting Information ------
-          > For Tx Alloc:
-          mgmt packets => sd_idx = 0
-          SwIdx: pAd->MgmtRing.TxCpuIdx
-          pTxD : pAd->MgmtRing.Cell[SwIdx].AllocVa;
-
-          data packets => sd_idx = 1
-          TxIdx : pAd->TxRing[pTxBlk->QueIdx].TxCpuIdx
-          QueIdx: pTxBlk->QueIdx
-          pTxD  : pAd->TxRing[pTxBlk->QueIdx].Cell[TxIdx].AllocVa;
-
-          > For Rx Alloc:
-          sd_idx = -1
-        */
-
-       pObj = (struct os_cookie *)pAd->OS_Cookie;
-
-       if (sd_idx == 1) {
-               struct rt_tx_blk *pTxBlk;
-               pTxBlk = (struct rt_tx_blk *)ptr;
-               return pci_map_single(pObj->pci_dev, pTxBlk->pSrcBufData,
-                                     pTxBlk->SrcBufLen, direction);
-       } else {
-               return pci_map_single(pObj->pci_dev, ptr, size, direction);
-       }
-
-}
-
-void linux_pci_unmap_single(struct rt_rtmp_adapter *pAd, dma_addr_t dma_addr,
-                           size_t size, int direction)
-{
-       struct os_cookie *pObj;
-
-       pObj = (struct os_cookie *)pAd->OS_Cookie;
-
-       pci_unmap_single(pObj->pci_dev, dma_addr, size, direction);
-
-}
diff --git a/drivers/staging/rt2860/rt_usb.c b/drivers/staging/rt2860/rt_usb.c
deleted file mode 100644 (file)
index eb037d2..0000000
+++ /dev/null
@@ -1,794 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-       Module Name:
-       rtusb_bulk.c
-
-       Abstract:
-
-       Revision History:
-       Who                     When            What
-       --------        ----------      ----------------------------------------------
-       Name                    Date            Modification logs
-       Justin P. Mattock       11/07/2010      Fix some typos.
-
-*/
-
-#include "rt_config.h"
-
-void dump_urb(struct urb *purb)
-{
-       printk(KERN_DEBUG "urb                  :0x%08lx\n", (unsigned long)purb);
-       printk(KERN_DEBUG "\tdev                   :0x%08lx\n", (unsigned long)purb->dev);
-       printk(KERN_DEBUG "\t\tdev->state          :0x%d\n", purb->dev->state);
-       printk(KERN_DEBUG "\tpipe                  :0x%08x\n", purb->pipe);
-       printk(KERN_DEBUG "\tstatus                :%d\n", purb->status);
-       printk(KERN_DEBUG "\ttransfer_flags        :0x%08x\n", purb->transfer_flags);
-       printk(KERN_DEBUG "\ttransfer_buffer       :0x%08lx\n",
-              (unsigned long)purb->transfer_buffer);
-       printk(KERN_DEBUG "\ttransfer_buffer_length:%d\n", purb->transfer_buffer_length);
-       printk(KERN_DEBUG "\tactual_length         :%d\n", purb->actual_length);
-       printk(KERN_DEBUG "\tsetup_packet          :0x%08lx\n",
-              (unsigned long)purb->setup_packet);
-       printk(KERN_DEBUG "\tstart_frame           :%d\n", purb->start_frame);
-       printk(KERN_DEBUG "\tnumber_of_packets     :%d\n", purb->number_of_packets);
-       printk(KERN_DEBUG "\tinterval              :%d\n", purb->interval);
-       printk(KERN_DEBUG "\terror_count           :%d\n", purb->error_count);
-       printk(KERN_DEBUG "\tcontext               :0x%08lx\n",
-              (unsigned long)purb->context);
-       printk(KERN_DEBUG "\tcomplete              :0x%08lx\n\n",
-              (unsigned long)purb->complete);
-}
-
-/*
-========================================================================
-Routine Description:
-    Create kernel threads & tasklets.
-
-Arguments:
-    *net_dev                   Pointer to wireless net device interface
-
-Return Value:
-       NDIS_STATUS_SUCCESS
-       NDIS_STATUS_FAILURE
-
-Note:
-========================================================================
-*/
-int RtmpMgmtTaskInit(struct rt_rtmp_adapter *pAd)
-{
-       struct rt_rtmp_os_task *pTask;
-       int status;
-
-       /*
-          Creat TimerQ Thread, We need init timerQ related structure before create the timer thread.
-        */
-       RtmpTimerQInit(pAd);
-
-       pTask = &pAd->timerTask;
-       RtmpOSTaskInit(pTask, "RtmpTimerTask", pAd);
-       status = RtmpOSTaskAttach(pTask, RtmpTimerQThread, pTask);
-       if (status == NDIS_STATUS_FAILURE) {
-               printk(KERN_WARNING "%s: unable to start RtmpTimerQThread\n",
-                      RTMP_OS_NETDEV_GET_DEVNAME(pAd->net_dev));
-               return NDIS_STATUS_FAILURE;
-       }
-
-       /* Creat MLME Thread */
-       pTask = &pAd->mlmeTask;
-       RtmpOSTaskInit(pTask, "RtmpMlmeTask", pAd);
-       status = RtmpOSTaskAttach(pTask, MlmeThread, pTask);
-       if (status == NDIS_STATUS_FAILURE) {
-               printk(KERN_WARNING "%s: unable to start MlmeThread\n",
-                      RTMP_OS_NETDEV_GET_DEVNAME(pAd->net_dev));
-               return NDIS_STATUS_FAILURE;
-       }
-
-       /* Creat Command Thread */
-       pTask = &pAd->cmdQTask;
-       RtmpOSTaskInit(pTask, "RtmpCmdQTask", pAd);
-       status = RtmpOSTaskAttach(pTask, RTUSBCmdThread, pTask);
-       if (status == NDIS_STATUS_FAILURE) {
-               printk(KERN_WARNING "%s: unable to start RTUSBCmdThread\n",
-                      RTMP_OS_NETDEV_GET_DEVNAME(pAd->net_dev));
-               return NDIS_STATUS_FAILURE;
-       }
-
-       return NDIS_STATUS_SUCCESS;
-}
-
-/*
-========================================================================
-Routine Description:
-    Close kernel threads.
-
-Arguments:
-       *pAd                            the raxx interface data pointer
-
-Return Value:
-    NONE
-
-Note:
-========================================================================
-*/
-void RtmpMgmtTaskExit(struct rt_rtmp_adapter *pAd)
-{
-       int ret;
-       struct rt_rtmp_os_task *pTask;
-
-       /* Sleep 50 milliseconds so pending io might finish normally */
-       RTMPusecDelay(50000);
-
-       /* We want to wait until all pending receives and sends to the */
-       /* device object. We cancel any */
-       /* irps. Wait until sends and receives have stopped. */
-       RTUSBCancelPendingIRPs(pAd);
-
-       /* We need clear timerQ related structure before exits of the timer thread. */
-       RtmpTimerQExit(pAd);
-
-       /* Terminate Mlme Thread */
-       pTask = &pAd->mlmeTask;
-       ret = RtmpOSTaskKill(pTask);
-       if (ret == NDIS_STATUS_FAILURE) {
-               DBGPRINT(RT_DEBUG_ERROR, ("%s: kill task(%s) failed!\n",
-                                         RTMP_OS_NETDEV_GET_DEVNAME(pAd->
-                                                                    net_dev),
-                                         pTask->taskName));
-       }
-
-       /* Terminate cmdQ thread */
-       pTask = &pAd->cmdQTask;
-#ifdef KTHREAD_SUPPORT
-       if (pTask->kthread_task)
-#else
-       CHECK_PID_LEGALITY(pTask->taskPID)
-#endif
-       {
-               mb();
-               NdisAcquireSpinLock(&pAd->CmdQLock);
-               pAd->CmdQ.CmdQState = RTMP_TASK_STAT_STOPED;
-               NdisReleaseSpinLock(&pAd->CmdQLock);
-               mb();
-               /*RTUSBCMDUp(pAd); */
-               ret = RtmpOSTaskKill(pTask);
-               if (ret == NDIS_STATUS_FAILURE) {
-                       DBGPRINT(RT_DEBUG_ERROR, ("%s: kill task(%s) failed!\n",
-                                                 RTMP_OS_NETDEV_GET_DEVNAME
-                                                 (pAd->net_dev),
-                                                 pTask->taskName));
-               }
-               pAd->CmdQ.CmdQState = RTMP_TASK_STAT_UNKNOWN;
-       }
-
-       /* Terminate timer thread */
-       pTask = &pAd->timerTask;
-       ret = RtmpOSTaskKill(pTask);
-       if (ret == NDIS_STATUS_FAILURE) {
-               DBGPRINT(RT_DEBUG_ERROR, ("%s: kill task(%s) failed!\n",
-                                         RTMP_OS_NETDEV_GET_DEVNAME(pAd->
-                                                                    net_dev),
-                                         pTask->taskName));
-       }
-
-}
-
-static void rtusb_dataout_complete(unsigned long data)
-{
-       struct rt_rtmp_adapter *pAd;
-       struct urb *pUrb;
-       struct os_cookie *pObj;
-       struct rt_ht_tx_context *pHTTXContext;
-       u8 BulkOutPipeId;
-       int Status;
-       unsigned long IrqFlags;
-
-       pUrb = (struct urb *)data;
-       pHTTXContext = (struct rt_ht_tx_context *)pUrb->context;
-       pAd = pHTTXContext->pAd;
-       pObj = (struct os_cookie *)pAd->OS_Cookie;
-       Status = pUrb->status;
-
-       /* Store BulkOut PipeId */
-       BulkOutPipeId = pHTTXContext->BulkOutPipeId;
-       pAd->BulkOutDataOneSecCount++;
-
-       /*DBGPRINT(RT_DEBUG_LOUD, ("Done-B(%d):I=0x%lx, CWPos=%ld, NBPos=%ld, ENBPos=%ld, bCopy=%d!\n", BulkOutPipeId, in_interrupt(), pHTTXContext->CurWritePosition, */
-       /*              pHTTXContext->NextBulkOutPosition, pHTTXContext->ENextBulkOutPosition, pHTTXContext->bCopySavePad)); */
-
-       RTMP_IRQ_LOCK(&pAd->BulkOutLock[BulkOutPipeId], IrqFlags);
-       pAd->BulkOutPending[BulkOutPipeId] = FALSE;
-       pHTTXContext->IRPPending = FALSE;
-       pAd->watchDogTxPendingCnt[BulkOutPipeId] = 0;
-
-       if (Status == USB_ST_NOERROR) {
-               pAd->BulkOutComplete++;
-
-               RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[BulkOutPipeId], IrqFlags);
-
-               pAd->Counters8023.GoodTransmits++;
-               /*RTMP_IRQ_LOCK(&pAd->TxContextQueueLock[BulkOutPipeId], IrqFlags); */
-               FREE_HTTX_RING(pAd, BulkOutPipeId, pHTTXContext);
-               /*RTMP_IRQ_UNLOCK(&pAd->TxContextQueueLock[BulkOutPipeId], IrqFlags); */
-
-       } else {                /* STATUS_OTHER */
-               u8 *pBuf;
-
-               pAd->BulkOutCompleteOther++;
-
-               pBuf =
-                   &pHTTXContext->TransferBuffer->field.
-                   WirelessPacket[pHTTXContext->NextBulkOutPosition];
-
-               if (!RTMP_TEST_FLAG(pAd, (fRTMP_ADAPTER_RESET_IN_PROGRESS |
-                                         fRTMP_ADAPTER_HALT_IN_PROGRESS |
-                                         fRTMP_ADAPTER_NIC_NOT_EXIST |
-                                         fRTMP_ADAPTER_BULKOUT_RESET))) {
-                       RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET);
-                       pAd->bulkResetPipeid = BulkOutPipeId;
-                       pAd->bulkResetReq[BulkOutPipeId] = pAd->BulkOutReq;
-               }
-               RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[BulkOutPipeId], IrqFlags);
-
-               DBGPRINT_RAW(RT_DEBUG_ERROR,
-                            ("BulkOutDataPacket failed: ReasonCode=%d!\n",
-                             Status));
-               DBGPRINT_RAW(RT_DEBUG_ERROR,
-                            ("\t>>BulkOut Req=0x%lx, Complete=0x%lx, Other=0x%lx\n",
-                             pAd->BulkOutReq, pAd->BulkOutComplete,
-                             pAd->BulkOutCompleteOther));
-               DBGPRINT_RAW(RT_DEBUG_ERROR,
-                            ("\t>>BulkOut Header:%x %x %x %x %x %x %x %x\n",
-                             pBuf[0], pBuf[1], pBuf[2], pBuf[3], pBuf[4],
-                             pBuf[5], pBuf[6], pBuf[7]));
-               /*DBGPRINT_RAW(RT_DEBUG_ERROR, (">>BulkOutCompleteCancel=0x%x, BulkOutCompleteOther=0x%x\n", pAd->BulkOutCompleteCancel, pAd->BulkOutCompleteOther)); */
-
-       }
-
-       /* */
-       /* bInUse = TRUE, means some process are filling TX data, after that must turn on bWaitingBulkOut */
-       /* bWaitingBulkOut = TRUE, means the TX data are waiting for bulk out. */
-       /* */
-       /*RTMP_IRQ_LOCK(&pAd->TxContextQueueLock[BulkOutPipeId], IrqFlags); */
-       if ((pHTTXContext->ENextBulkOutPosition !=
-            pHTTXContext->CurWritePosition)
-           && (pHTTXContext->ENextBulkOutPosition !=
-               (pHTTXContext->CurWritePosition + 8))
-           && !RTUSB_TEST_BULK_FLAG(pAd,
-                                    (fRTUSB_BULK_OUT_DATA_FRAG <<
-                                     BulkOutPipeId))) {
-               /* Indicate There is data available */
-               RTUSB_SET_BULK_FLAG(pAd,
-                                   (fRTUSB_BULK_OUT_DATA_NORMAL <<
-                                    BulkOutPipeId));
-       }
-       /*RTMP_IRQ_UNLOCK(&pAd->TxContextQueueLock[BulkOutPipeId], IrqFlags); */
-
-       /* Always call Bulk routine, even reset bulk. */
-       /* The protection of rest bulk should be in BulkOut routine */
-       RTUSBKickBulkOut(pAd);
-}
-
-static void rtusb_null_frame_done_tasklet(unsigned long data)
-{
-       struct rt_rtmp_adapter *pAd;
-       struct rt_tx_context *pNullContext;
-       struct urb *pUrb;
-       int Status;
-       unsigned long irqFlag;
-
-       pUrb = (struct urb *)data;
-       pNullContext = (struct rt_tx_context *)pUrb->context;
-       pAd = pNullContext->pAd;
-       Status = pUrb->status;
-
-       /* Reset Null frame context flags */
-       RTMP_IRQ_LOCK(&pAd->BulkOutLock[0], irqFlag);
-       pNullContext->IRPPending = FALSE;
-       pNullContext->InUse = FALSE;
-       pAd->BulkOutPending[0] = FALSE;
-       pAd->watchDogTxPendingCnt[0] = 0;
-
-       if (Status == USB_ST_NOERROR) {
-               RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[0], irqFlag);
-
-               RTMPDeQueuePacket(pAd, FALSE, NUM_OF_TX_RING, MAX_TX_PROCESS);
-       } else {                /* STATUS_OTHER */
-               if ((!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS)) &&
-                   (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS)) &&
-                   (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)) &&
-                   (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET))) {
-                       DBGPRINT_RAW(RT_DEBUG_ERROR,
-                                    ("Bulk Out Null Frame Failed, ReasonCode=%d!\n",
-                                     Status));
-                       RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET);
-                       pAd->bulkResetPipeid =
-                           (MGMTPIPEIDX | BULKOUT_MGMT_RESET_FLAG);
-                       RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[0], irqFlag);
-                       RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_RESET_BULK_OUT,
-                                               NULL, 0);
-               } else {
-                       RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[0], irqFlag);
-               }
-       }
-
-       /* Always call Bulk routine, even reset bulk. */
-       /* The protection of rest bulk should be in BulkOut routine */
-       RTUSBKickBulkOut(pAd);
-}
-
-static void rtusb_rts_frame_done_tasklet(unsigned long data)
-{
-       struct rt_rtmp_adapter *pAd;
-       struct rt_tx_context *pRTSContext;
-       struct urb *pUrb;
-       int Status;
-       unsigned long irqFlag;
-
-       pUrb = (struct urb *)data;
-       pRTSContext = (struct rt_tx_context *)pUrb->context;
-       pAd = pRTSContext->pAd;
-       Status = pUrb->status;
-
-       /* Reset RTS frame context flags */
-       RTMP_IRQ_LOCK(&pAd->BulkOutLock[0], irqFlag);
-       pRTSContext->IRPPending = FALSE;
-       pRTSContext->InUse = FALSE;
-
-       if (Status == USB_ST_NOERROR) {
-               RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[0], irqFlag);
-               RTMPDeQueuePacket(pAd, FALSE, NUM_OF_TX_RING, MAX_TX_PROCESS);
-       } else {                /* STATUS_OTHER */
-               if ((!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS)) &&
-                   (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS)) &&
-                   (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)) &&
-                   (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET))) {
-                       DBGPRINT_RAW(RT_DEBUG_ERROR,
-                                    ("Bulk Out RTS Frame Failed\n"));
-                       RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET);
-                       pAd->bulkResetPipeid =
-                           (MGMTPIPEIDX | BULKOUT_MGMT_RESET_FLAG);
-                       RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[0], irqFlag);
-                       RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_RESET_BULK_OUT,
-                                               NULL, 0);
-               } else {
-                       RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[0], irqFlag);
-               }
-       }
-
-       RTMP_SEM_LOCK(&pAd->BulkOutLock[pRTSContext->BulkOutPipeId]);
-       pAd->BulkOutPending[pRTSContext->BulkOutPipeId] = FALSE;
-       RTMP_SEM_UNLOCK(&pAd->BulkOutLock[pRTSContext->BulkOutPipeId]);
-
-       /* Always call Bulk routine, even reset bulk. */
-       /* The protection of rest bulk should be in BulkOut routine */
-       RTUSBKickBulkOut(pAd);
-
-}
-
-static void rtusb_pspoll_frame_done_tasklet(unsigned long data)
-{
-       struct rt_rtmp_adapter *pAd;
-       struct rt_tx_context *pPsPollContext;
-       struct urb *pUrb;
-       int Status;
-
-       pUrb = (struct urb *)data;
-       pPsPollContext = (struct rt_tx_context *)pUrb->context;
-       pAd = pPsPollContext->pAd;
-       Status = pUrb->status;
-
-       /* Reset PsPoll context flags */
-       pPsPollContext->IRPPending = FALSE;
-       pPsPollContext->InUse = FALSE;
-       pAd->watchDogTxPendingCnt[0] = 0;
-
-       if (Status == USB_ST_NOERROR) {
-               RTMPDeQueuePacket(pAd, FALSE, NUM_OF_TX_RING, MAX_TX_PROCESS);
-       } else {                /* STATUS_OTHER */
-               if ((!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS)) &&
-                   (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS)) &&
-                   (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)) &&
-                   (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET))) {
-                       DBGPRINT_RAW(RT_DEBUG_ERROR,
-                                    ("Bulk Out PSPoll Failed\n"));
-                       RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET);
-                       pAd->bulkResetPipeid =
-                           (MGMTPIPEIDX | BULKOUT_MGMT_RESET_FLAG);
-                       RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_RESET_BULK_OUT,
-                                               NULL, 0);
-               }
-       }
-
-       RTMP_SEM_LOCK(&pAd->BulkOutLock[0]);
-       pAd->BulkOutPending[0] = FALSE;
-       RTMP_SEM_UNLOCK(&pAd->BulkOutLock[0]);
-
-       /* Always call Bulk routine, even reset bulk. */
-       /* The protection of rest bulk should be in BulkOut routine */
-       RTUSBKickBulkOut(pAd);
-
-}
-
-/*
-========================================================================
-Routine Description:
-    Handle received packets.
-
-Arguments:
-       data                            - URB information pointer
-
-Return Value:
-    None
-
-Note:
-========================================================================
-*/
-static void rx_done_tasklet(unsigned long data)
-{
-       struct urb *pUrb;
-       struct rt_rx_context *pRxContext;
-       struct rt_rtmp_adapter *pAd;
-       int Status;
-       unsigned int IrqFlags;
-
-       pUrb = (struct urb *)data;
-       pRxContext = (struct rt_rx_context *)pUrb->context;
-       pAd = pRxContext->pAd;
-       Status = pUrb->status;
-
-       RTMP_IRQ_LOCK(&pAd->BulkInLock, IrqFlags);
-       pRxContext->InUse = FALSE;
-       pRxContext->IRPPending = FALSE;
-       pRxContext->BulkInOffset += pUrb->actual_length;
-       /*NdisInterlockedDecrement(&pAd->PendingRx); */
-       pAd->PendingRx--;
-
-       if (Status == USB_ST_NOERROR) {
-               pAd->BulkInComplete++;
-               pAd->NextRxBulkInPosition = 0;
-               if (pRxContext->BulkInOffset) { /* As jan's comment, it may bulk-in success but size is zero. */
-                       pRxContext->Readable = TRUE;
-                       INC_RING_INDEX(pAd->NextRxBulkInIndex, RX_RING_SIZE);
-               }
-               RTMP_IRQ_UNLOCK(&pAd->BulkInLock, IrqFlags);
-       } else {                        /* STATUS_OTHER */
-               pAd->BulkInCompleteFail++;
-               /* Still read this packet although it may comtain wrong bytes. */
-               pRxContext->Readable = FALSE;
-               RTMP_IRQ_UNLOCK(&pAd->BulkInLock, IrqFlags);
-
-               /* Parsing all packets. because after reset, the index will reset to all zero. */
-               if ((!RTMP_TEST_FLAG(pAd, (fRTMP_ADAPTER_RESET_IN_PROGRESS |
-                                          fRTMP_ADAPTER_BULKIN_RESET |
-                                          fRTMP_ADAPTER_HALT_IN_PROGRESS |
-                                          fRTMP_ADAPTER_NIC_NOT_EXIST)))) {
-
-                       DBGPRINT_RAW(RT_DEBUG_ERROR,
-                                    ("Bulk In Failed. Status=%d, BIIdx=0x%x, BIRIdx=0x%x, actual_length= 0x%x\n",
-                                     Status, pAd->NextRxBulkInIndex,
-                                     pAd->NextRxBulkInReadIndex,
-                                     pRxContext->pUrb->actual_length));
-
-                       RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_BULKIN_RESET);
-                       RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_RESET_BULK_IN,
-                                               NULL, 0);
-               }
-       }
-
-       ASSERT((pRxContext->InUse == pRxContext->IRPPending));
-
-       RTUSBBulkReceive(pAd);
-
-       return;
-
-}
-
-static void rtusb_mgmt_dma_done_tasklet(unsigned long data)
-{
-       struct rt_rtmp_adapter *pAd;
-       struct rt_tx_context *pMLMEContext;
-       int index;
-       void *pPacket;
-       struct urb *pUrb;
-       int Status;
-       unsigned long IrqFlags;
-
-       pUrb = (struct urb *)data;
-       pMLMEContext = (struct rt_tx_context *)pUrb->context;
-       pAd = pMLMEContext->pAd;
-       Status = pUrb->status;
-       index = pMLMEContext->SelfIdx;
-
-       ASSERT((pAd->MgmtRing.TxDmaIdx == index));
-
-       RTMP_IRQ_LOCK(&pAd->BulkOutLock[MGMTPIPEIDX], IrqFlags);
-
-       if (Status != USB_ST_NOERROR) {
-               /*Bulk-Out fail status handle */
-               if ((!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS)) &&
-                   (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS)) &&
-                   (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)) &&
-                   (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET))) {
-                       DBGPRINT_RAW(RT_DEBUG_ERROR,
-                                    ("Bulk Out MLME Failed, Status=%d!\n",
-                                     Status));
-                       /* TODO: How to handle about the MLMEBulkOut failed issue. Need to resend the mgmt pkt? */
-                       RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET);
-                       pAd->bulkResetPipeid =
-                           (MGMTPIPEIDX | BULKOUT_MGMT_RESET_FLAG);
-               }
-       }
-
-       pAd->BulkOutPending[MGMTPIPEIDX] = FALSE;
-       RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[MGMTPIPEIDX], IrqFlags);
-
-       RTMP_IRQ_LOCK(&pAd->MLMEBulkOutLock, IrqFlags);
-       /* Reset MLME context flags */
-       pMLMEContext->IRPPending = FALSE;
-       pMLMEContext->InUse = FALSE;
-       pMLMEContext->bWaitingBulkOut = FALSE;
-       pMLMEContext->BulkOutSize = 0;
-
-       pPacket = pAd->MgmtRing.Cell[index].pNdisPacket;
-       pAd->MgmtRing.Cell[index].pNdisPacket = NULL;
-
-       /* Increase MgmtRing Index */
-       INC_RING_INDEX(pAd->MgmtRing.TxDmaIdx, MGMT_RING_SIZE);
-       pAd->MgmtRing.TxSwFreeIdx++;
-       RTMP_IRQ_UNLOCK(&pAd->MLMEBulkOutLock, IrqFlags);
-
-       /* No-matter success or fail, we free the mgmt packet. */
-       if (pPacket)
-               RTMPFreeNdisPacket(pAd, pPacket);
-
-       if ((RTMP_TEST_FLAG(pAd, (fRTMP_ADAPTER_RESET_IN_PROGRESS |
-                                 fRTMP_ADAPTER_HALT_IN_PROGRESS |
-                                 fRTMP_ADAPTER_NIC_NOT_EXIST)))) {
-               /* do nothing and return directly. */
-       } else {
-               if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET) && ((pAd->bulkResetPipeid & BULKOUT_MGMT_RESET_FLAG) == BULKOUT_MGMT_RESET_FLAG)) {        /* For Mgmt Bulk-Out failed, ignore it now. */
-                       RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_RESET_BULK_OUT,
-                                               NULL, 0);
-               } else {
-
-                       /* Always call Bulk routine, even reset bulk. */
-                       /* The protection of rest bulk should be in BulkOut routine */
-                       if (pAd->MgmtRing.TxSwFreeIdx <
-                           MGMT_RING_SIZE
-                           /* pMLMEContext->bWaitingBulkOut == TRUE */) {
-                               RTUSB_SET_BULK_FLAG(pAd, fRTUSB_BULK_OUT_MLME);
-                       }
-                       RTUSBKickBulkOut(pAd);
-               }
-       }
-
-}
-
-static void rtusb_ac3_dma_done_tasklet(unsigned long data)
-{
-       struct rt_rtmp_adapter *pAd;
-       struct rt_ht_tx_context *pHTTXContext;
-       u8 BulkOutPipeId = 3;
-       struct urb *pUrb;
-
-       pUrb = (struct urb *)data;
-       pHTTXContext = (struct rt_ht_tx_context *)pUrb->context;
-       pAd = pHTTXContext->pAd;
-
-       rtusb_dataout_complete((unsigned long)pUrb);
-
-       if ((RTMP_TEST_FLAG(pAd, (fRTMP_ADAPTER_RESET_IN_PROGRESS |
-                                 fRTMP_ADAPTER_HALT_IN_PROGRESS |
-                                 fRTMP_ADAPTER_NIC_NOT_EXIST)))) {
-               /* do nothing and return directly. */
-       } else {
-               if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET)) {
-                       RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_RESET_BULK_OUT,
-                                               NULL, 0);
-               } else {
-                       pHTTXContext = &pAd->TxContext[BulkOutPipeId];
-                       if ((pAd->TxSwQueue[BulkOutPipeId].Number > 0) &&
-                           /*((pHTTXContext->CurWritePosition > (pHTTXContext->NextBulkOutPosition + 0x6000)) || (pHTTXContext->NextBulkOutPosition > pHTTXContext->CurWritePosition + 0x6000)) && */
-                           (pAd->DeQueueRunning[BulkOutPipeId] == FALSE) &&
-                           (pHTTXContext->bCurWriting == FALSE)) {
-                               RTMPDeQueuePacket(pAd, FALSE, BulkOutPipeId,
-                                                 MAX_TX_PROCESS);
-                       }
-
-                       RTUSB_SET_BULK_FLAG(pAd,
-                                           fRTUSB_BULK_OUT_DATA_NORMAL << 3);
-                       RTUSBKickBulkOut(pAd);
-               }
-       }
-
-       return;
-}
-
-static void rtusb_ac2_dma_done_tasklet(unsigned long data)
-{
-       struct rt_rtmp_adapter *pAd;
-       struct rt_ht_tx_context *pHTTXContext;
-       u8 BulkOutPipeId = 2;
-       struct urb *pUrb;
-
-       pUrb = (struct urb *)data;
-       pHTTXContext = (struct rt_ht_tx_context *)pUrb->context;
-       pAd = pHTTXContext->pAd;
-
-       rtusb_dataout_complete((unsigned long)pUrb);
-
-       if ((RTMP_TEST_FLAG(pAd, (fRTMP_ADAPTER_RESET_IN_PROGRESS |
-                                 fRTMP_ADAPTER_HALT_IN_PROGRESS |
-                                 fRTMP_ADAPTER_NIC_NOT_EXIST)))) {
-               /* do nothing and return directly. */
-       } else {
-               if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET)) {
-                       RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_RESET_BULK_OUT,
-                                               NULL, 0);
-               } else {
-                       pHTTXContext = &pAd->TxContext[BulkOutPipeId];
-                       if ((pAd->TxSwQueue[BulkOutPipeId].Number > 0) &&
-                           /*((pHTTXContext->CurWritePosition > (pHTTXContext->NextBulkOutPosition + 0x6000)) || (pHTTXContext->NextBulkOutPosition > pHTTXContext->CurWritePosition + 0x6000)) && */
-                           (pAd->DeQueueRunning[BulkOutPipeId] == FALSE) &&
-                           (pHTTXContext->bCurWriting == FALSE)) {
-                               RTMPDeQueuePacket(pAd, FALSE, BulkOutPipeId,
-                                                 MAX_TX_PROCESS);
-                       }
-
-                       RTUSB_SET_BULK_FLAG(pAd,
-                                           fRTUSB_BULK_OUT_DATA_NORMAL << 2);
-                       RTUSBKickBulkOut(pAd);
-               }
-       }
-
-       return;
-}
-
-static void rtusb_ac1_dma_done_tasklet(unsigned long data)
-{
-       struct rt_rtmp_adapter *pAd;
-       struct rt_ht_tx_context *pHTTXContext;
-       u8 BulkOutPipeId = 1;
-       struct urb *pUrb;
-
-       pUrb = (struct urb *)data;
-       pHTTXContext = (struct rt_ht_tx_context *)pUrb->context;
-       pAd = pHTTXContext->pAd;
-
-       rtusb_dataout_complete((unsigned long)pUrb);
-
-       if ((RTMP_TEST_FLAG(pAd, (fRTMP_ADAPTER_RESET_IN_PROGRESS |
-                                 fRTMP_ADAPTER_HALT_IN_PROGRESS |
-                                 fRTMP_ADAPTER_NIC_NOT_EXIST)))) {
-               /* do nothing and return directly. */
-       } else {
-               if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET)) {
-                       RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_RESET_BULK_OUT,
-                                               NULL, 0);
-               } else {
-                       pHTTXContext = &pAd->TxContext[BulkOutPipeId];
-                       if ((pAd->TxSwQueue[BulkOutPipeId].Number > 0) &&
-                           /*((pHTTXContext->CurWritePosition > (pHTTXContext->NextBulkOutPosition + 0x6000)) || (pHTTXContext->NextBulkOutPosition > pHTTXContext->CurWritePosition + 0x6000)) && */
-                           (pAd->DeQueueRunning[BulkOutPipeId] == FALSE) &&
-                           (pHTTXContext->bCurWriting == FALSE)) {
-                               RTMPDeQueuePacket(pAd, FALSE, BulkOutPipeId,
-                                                 MAX_TX_PROCESS);
-                       }
-
-                       RTUSB_SET_BULK_FLAG(pAd,
-                                           fRTUSB_BULK_OUT_DATA_NORMAL << 1);
-                       RTUSBKickBulkOut(pAd);
-               }
-       }
-       return;
-
-}
-
-static void rtusb_ac0_dma_done_tasklet(unsigned long data)
-{
-       struct rt_rtmp_adapter *pAd;
-       struct rt_ht_tx_context *pHTTXContext;
-       u8 BulkOutPipeId = 0;
-       struct urb *pUrb;
-
-       pUrb = (struct urb *)data;
-       pHTTXContext = (struct rt_ht_tx_context *)pUrb->context;
-       pAd = pHTTXContext->pAd;
-
-       rtusb_dataout_complete((unsigned long)pUrb);
-
-       if ((RTMP_TEST_FLAG(pAd, (fRTMP_ADAPTER_RESET_IN_PROGRESS |
-                                 fRTMP_ADAPTER_HALT_IN_PROGRESS |
-                                 fRTMP_ADAPTER_NIC_NOT_EXIST)))) {
-               /* do nothing and return directly. */
-       } else {
-               if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BULKOUT_RESET)) {
-                       RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_RESET_BULK_OUT,
-                                               NULL, 0);
-               } else {
-                       pHTTXContext = &pAd->TxContext[BulkOutPipeId];
-                       if ((pAd->TxSwQueue[BulkOutPipeId].Number > 0) &&
-                           /*  ((pHTTXContext->CurWritePosition > (pHTTXContext->NextBulkOutPosition + 0x6000)) || (pHTTXContext->NextBulkOutPosition > pHTTXContext->CurWritePosition + 0x6000)) && */
-                           (pAd->DeQueueRunning[BulkOutPipeId] == FALSE) &&
-                           (pHTTXContext->bCurWriting == FALSE)) {
-                               RTMPDeQueuePacket(pAd, FALSE, BulkOutPipeId,
-                                                 MAX_TX_PROCESS);
-                       }
-
-                       RTUSB_SET_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_NORMAL);
-                       RTUSBKickBulkOut(pAd);
-               }
-       }
-
-       return;
-
-}
-
-int RtmpNetTaskInit(struct rt_rtmp_adapter *pAd)
-{
-       struct os_cookie *pObj = (struct os_cookie *)pAd->OS_Cookie;
-
-       /* Create receive tasklet */
-       tasklet_init(&pObj->rx_done_task, rx_done_tasklet, (unsigned long)pAd);
-       tasklet_init(&pObj->mgmt_dma_done_task, rtusb_mgmt_dma_done_tasklet,
-                    (unsigned long)pAd);
-       tasklet_init(&pObj->ac0_dma_done_task, rtusb_ac0_dma_done_tasklet,
-                    (unsigned long)pAd);
-       tasklet_init(&pObj->ac1_dma_done_task, rtusb_ac1_dma_done_tasklet,
-                    (unsigned long)pAd);
-       tasklet_init(&pObj->ac2_dma_done_task, rtusb_ac2_dma_done_tasklet,
-                    (unsigned long)pAd);
-       tasklet_init(&pObj->ac3_dma_done_task, rtusb_ac3_dma_done_tasklet,
-                    (unsigned long)pAd);
-       tasklet_init(&pObj->tbtt_task, tbtt_tasklet, (unsigned long)pAd);
-       tasklet_init(&pObj->null_frame_complete_task,
-                    rtusb_null_frame_done_tasklet, (unsigned long)pAd);
-       tasklet_init(&pObj->rts_frame_complete_task,
-                    rtusb_rts_frame_done_tasklet, (unsigned long)pAd);
-       tasklet_init(&pObj->pspoll_frame_complete_task,
-                    rtusb_pspoll_frame_done_tasklet, (unsigned long)pAd);
-
-       return NDIS_STATUS_SUCCESS;
-}
-
-void RtmpNetTaskExit(struct rt_rtmp_adapter *pAd)
-{
-       struct os_cookie *pObj;
-
-       pObj = (struct os_cookie *)pAd->OS_Cookie;
-
-       tasklet_kill(&pObj->rx_done_task);
-       tasklet_kill(&pObj->mgmt_dma_done_task);
-       tasklet_kill(&pObj->ac0_dma_done_task);
-       tasklet_kill(&pObj->ac1_dma_done_task);
-       tasklet_kill(&pObj->ac2_dma_done_task);
-       tasklet_kill(&pObj->ac3_dma_done_task);
-       tasklet_kill(&pObj->tbtt_task);
-       tasklet_kill(&pObj->null_frame_complete_task);
-       tasklet_kill(&pObj->rts_frame_complete_task);
-       tasklet_kill(&pObj->pspoll_frame_complete_task);
-}
diff --git a/drivers/staging/rt2860/rtmp.h b/drivers/staging/rt2860/rtmp.h
deleted file mode 100644 (file)
index 3c31340..0000000
+++ /dev/null
@@ -1,4332 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-    Module Name:
-    rtmp.h
-
-    Abstract:
-    Miniport generic portion header file
-
-    Revision History:
-    Who                When            What
-    --------    ----------    ----------------------------------------------
-    Paul Lin           2002-08-01      created
-    James Tan          2002-09-06      modified (Revise NTCRegTable)
-    John Chang         2004-09-06      modified for RT2600
-    Justin P. Mattock  11/07/2010      Fix some typos
-*/
-#ifndef __RTMP_H__
-#define __RTMP_H__
-
-#include "spectrum_def.h"
-#include "rtmp_dot11.h"
-#include "rtmp_chip.h"
-
-struct rt_rtmp_adapter;
-
-/*#define DBG           1 */
-
-/*#define DBG_DIAGNOSE          1 */
-
-/*+++Add by shiang for merge MiniportMMRequest() and MiniportDataMMRequest() into one function */
-#define MAX_DATAMM_RETRY       3
-#define MGMT_USE_QUEUE_FLAG    0x80
-/*---Add by shiang for merge MiniportMMRequest() and MiniportDataMMRequest() into one function */
-
-#define        MAXSEQ          (0xFFF)
-
-extern unsigned char SNAP_AIRONET[];
-extern unsigned char CISCO_OUI[];
-extern u8 BaSizeArray[4];
-
-extern u8 BROADCAST_ADDR[MAC_ADDR_LEN];
-extern u8 ZERO_MAC_ADDR[MAC_ADDR_LEN];
-extern unsigned long BIT32[32];
-extern u8 BIT8[8];
-extern char *CipherName[];
-extern char *MCSToMbps[];
-extern u8 RxwiMCSToOfdmRate[12];
-extern u8 SNAP_802_1H[6];
-extern u8 SNAP_BRIDGE_TUNNEL[6];
-extern u8 SNAP_AIRONET[8];
-extern u8 CKIP_LLC_SNAP[8];
-extern u8 EAPOL_LLC_SNAP[8];
-extern u8 EAPOL[2];
-extern u8 IPX[2];
-extern u8 APPLE_TALK[2];
-extern u8 RateIdToPlcpSignal[12];      /* see IEEE802.11a-1999 p.14 */
-extern u8 OfdmRateToRxwiMCS[];
-extern u8 OfdmSignalToRateId[16];
-extern u8 default_cwmin[4];
-extern u8 default_cwmax[4];
-extern u8 default_sta_aifsn[4];
-extern u8 MapUserPriorityToAccessCategory[8];
-
-extern u16 RateUpPER[];
-extern u16 RateDownPER[];
-extern u8 Phy11BNextRateDownward[];
-extern u8 Phy11BNextRateUpward[];
-extern u8 Phy11BGNextRateDownward[];
-extern u8 Phy11BGNextRateUpward[];
-extern u8 Phy11ANextRateDownward[];
-extern u8 Phy11ANextRateUpward[];
-extern char RssiSafeLevelForTxRate[];
-extern u8 RateIdToMbps[];
-extern u16 RateIdTo500Kbps[];
-
-extern u8 CipherSuiteWpaNoneTkip[];
-extern u8 CipherSuiteWpaNoneTkipLen;
-
-extern u8 CipherSuiteWpaNoneAes[];
-extern u8 CipherSuiteWpaNoneAesLen;
-
-extern u8 SsidIe;
-extern u8 SupRateIe;
-extern u8 ExtRateIe;
-
-extern u8 HtCapIe;
-extern u8 AddHtInfoIe;
-extern u8 NewExtChanIe;
-
-extern u8 ErpIe;
-extern u8 DsIe;
-extern u8 TimIe;
-extern u8 WpaIe;
-extern u8 Wpa2Ie;
-extern u8 IbssIe;
-extern u8 Ccx2Ie;
-extern u8 WapiIe;
-
-extern u8 WPA_OUI[];
-extern u8 RSN_OUI[];
-extern u8 WAPI_OUI[];
-extern u8 WME_INFO_ELEM[];
-extern u8 WME_PARM_ELEM[];
-extern u8 Ccx2QosInfo[];
-extern u8 Ccx2IeInfo[];
-extern u8 RALINK_OUI[];
-extern u8 PowerConstraintIE[];
-
-extern u8 RateSwitchTable[];
-extern u8 RateSwitchTable11B[];
-extern u8 RateSwitchTable11G[];
-extern u8 RateSwitchTable11BG[];
-
-extern u8 RateSwitchTable11BGN1S[];
-extern u8 RateSwitchTable11BGN2S[];
-extern u8 RateSwitchTable11BGN2SForABand[];
-extern u8 RateSwitchTable11N1S[];
-extern u8 RateSwitchTable11N2S[];
-extern u8 RateSwitchTable11N2SForABand[];
-
-extern u8 PRE_N_HT_OUI[];
-
-struct rt_rssi_sample {
-       char LastRssi0;         /* last received RSSI */
-       char LastRssi1;         /* last received RSSI */
-       char LastRssi2;         /* last received RSSI */
-       char AvgRssi0;
-       char AvgRssi1;
-       char AvgRssi2;
-       short AvgRssi0X8;
-       short AvgRssi1X8;
-       short AvgRssi2X8;
-};
-
-/* */
-/*  Queue structure and macros */
-/* */
-struct rt_queue_entry;
-
-struct rt_queue_entry {
-       struct rt_queue_entry *Next;
-};
-
-/* Queue structure */
-struct rt_queue_header {
-       struct rt_queue_entry *Head;
-       struct rt_queue_entry *Tail;
-       unsigned long Number;
-};
-
-#define InitializeQueueHeader(QueueHeader)              \
-{                                                       \
-       (QueueHeader)->Head = (QueueHeader)->Tail = NULL;   \
-       (QueueHeader)->Number = 0;                          \
-}
-
-#define RemoveHeadQueue(QueueHeader)                \
-(QueueHeader)->Head;                                \
-{                                                   \
-       struct rt_queue_entry *pNext;                             \
-       if ((QueueHeader)->Head != NULL) {                              \
-               pNext = (QueueHeader)->Head->Next;          \
-               (QueueHeader)->Head->Next = NULL;               \
-               (QueueHeader)->Head = pNext;                \
-               if (pNext == NULL)                          \
-                       (QueueHeader)->Tail = NULL;             \
-               (QueueHeader)->Number--;                    \
-       }                                                                                               \
-}
-
-#define InsertHeadQueue(QueueHeader, QueueEntry)            \
-{                                                           \
-               ((struct rt_queue_entry *)QueueEntry)->Next = (QueueHeader)->Head; \
-               (QueueHeader)->Head = (struct rt_queue_entry *)(QueueEntry);       \
-               if ((QueueHeader)->Tail == NULL)                        \
-                       (QueueHeader)->Tail = (struct rt_queue_entry *)(QueueEntry);   \
-               (QueueHeader)->Number++;                                \
-}
-
-#define InsertTailQueue(QueueHeader, QueueEntry)                \
-{                                                               \
-       ((struct rt_queue_entry *)QueueEntry)->Next = NULL;                    \
-       if ((QueueHeader)->Tail)                                    \
-               (QueueHeader)->Tail->Next = (struct rt_queue_entry *)(QueueEntry); \
-       else                                                        \
-               (QueueHeader)->Head = (struct rt_queue_entry *)(QueueEntry);       \
-       (QueueHeader)->Tail = (struct rt_queue_entry *)(QueueEntry);           \
-       (QueueHeader)->Number++;                                    \
-}
-
-#define InsertTailQueueAc(pAd, pEntry, QueueHeader, QueueEntry)                        \
-{                                                                                                                                              \
-       ((struct rt_queue_entry *)QueueEntry)->Next = NULL;                                                     \
-       if ((QueueHeader)->Tail)                                                                                        \
-               (QueueHeader)->Tail->Next = (struct rt_queue_entry *)(QueueEntry);                      \
-       else                                                                                                                            \
-               (QueueHeader)->Head = (struct rt_queue_entry *)(QueueEntry);                            \
-       (QueueHeader)->Tail = (struct rt_queue_entry *)(QueueEntry);                                    \
-       (QueueHeader)->Number++;                                                                                        \
-}
-
-/* */
-/*  Macros for flag and ref count operations */
-/* */
-#define RTMP_SET_FLAG(_M, _F)       ((_M)->Flags |= (_F))
-#define RTMP_CLEAR_FLAG(_M, _F)     ((_M)->Flags &= ~(_F))
-#define RTMP_CLEAR_FLAGS(_M)        ((_M)->Flags = 0)
-#define RTMP_TEST_FLAG(_M, _F)      (((_M)->Flags & (_F)) != 0)
-#define RTMP_TEST_FLAGS(_M, _F)     (((_M)->Flags & (_F)) == (_F))
-/* Macro for power save flag. */
-#define RTMP_SET_PSFLAG(_M, _F)       ((_M)->PSFlags |= (_F))
-#define RTMP_CLEAR_PSFLAG(_M, _F)     ((_M)->PSFlags &= ~(_F))
-#define RTMP_CLEAR_PSFLAGS(_M)        ((_M)->PSFlags = 0)
-#define RTMP_TEST_PSFLAG(_M, _F)      (((_M)->PSFlags & (_F)) != 0)
-#define RTMP_TEST_PSFLAGS(_M, _F)     (((_M)->PSFlags & (_F)) == (_F))
-
-#define OPSTATUS_SET_FLAG(_pAd, _F)     ((_pAd)->CommonCfg.OpStatusFlags |= (_F))
-#define OPSTATUS_CLEAR_FLAG(_pAd, _F)   ((_pAd)->CommonCfg.OpStatusFlags &= ~(_F))
-#define OPSTATUS_TEST_FLAG(_pAd, _F)    (((_pAd)->CommonCfg.OpStatusFlags & (_F)) != 0)
-
-#define CLIENT_STATUS_SET_FLAG(_pEntry, _F)      ((_pEntry)->ClientStatusFlags |= (_F))
-#define CLIENT_STATUS_CLEAR_FLAG(_pEntry, _F)    ((_pEntry)->ClientStatusFlags &= ~(_F))
-#define CLIENT_STATUS_TEST_FLAG(_pEntry, _F)     (((_pEntry)->ClientStatusFlags & (_F)) != 0)
-
-#define RX_FILTER_SET_FLAG(_pAd, _F)    ((_pAd)->CommonCfg.PacketFilter |= (_F))
-#define RX_FILTER_CLEAR_FLAG(_pAd, _F)  ((_pAd)->CommonCfg.PacketFilter &= ~(_F))
-#define RX_FILTER_TEST_FLAG(_pAd, _F)   (((_pAd)->CommonCfg.PacketFilter & (_F)) != 0)
-
-#define STA_NO_SECURITY_ON(_p)          (_p->StaCfg.WepStatus == Ndis802_11EncryptionDisabled)
-#define STA_WEP_ON(_p)                  (_p->StaCfg.WepStatus == Ndis802_11Encryption1Enabled)
-#define STA_TKIP_ON(_p)                 (_p->StaCfg.WepStatus == Ndis802_11Encryption2Enabled)
-#define STA_AES_ON(_p)                  (_p->StaCfg.WepStatus == Ndis802_11Encryption3Enabled)
-
-#define STA_TGN_WIFI_ON(_p)             (_p->StaCfg.bTGnWifiTest == TRUE)
-
-#define CKIP_KP_ON(_p)                         ((((_p)->StaCfg.CkipFlag) & 0x10) && ((_p)->StaCfg.bCkipCmicOn == TRUE))
-#define CKIP_CMIC_ON(_p)                       ((((_p)->StaCfg.CkipFlag) & 0x08) && ((_p)->StaCfg.bCkipCmicOn == TRUE))
-
-#define INC_RING_INDEX(_idx, _RingSize)    \
-{                                          \
-    (_idx) = (_idx+1) % (_RingSize);       \
-}
-
-/* StaActive.SupportedHtPhy.MCSSet is copied from AP beacon.  Don't need to update here. */
-#define COPY_HTSETTINGS_FROM_MLME_AUX_TO_ACTIVE_CFG(_pAd)                                 \
-{                                                                                       \
-       _pAd->StaActive.SupportedHtPhy.ChannelWidth = _pAd->MlmeAux.HtCapability.HtCapInfo.ChannelWidth;      \
-       _pAd->StaActive.SupportedHtPhy.MimoPs = _pAd->MlmeAux.HtCapability.HtCapInfo.MimoPs;      \
-       _pAd->StaActive.SupportedHtPhy.GF = _pAd->MlmeAux.HtCapability.HtCapInfo.GF;      \
-       _pAd->StaActive.SupportedHtPhy.ShortGIfor20 = _pAd->MlmeAux.HtCapability.HtCapInfo.ShortGIfor20;      \
-       _pAd->StaActive.SupportedHtPhy.ShortGIfor40 = _pAd->MlmeAux.HtCapability.HtCapInfo.ShortGIfor40;      \
-       _pAd->StaActive.SupportedHtPhy.TxSTBC = _pAd->MlmeAux.HtCapability.HtCapInfo.TxSTBC;      \
-       _pAd->StaActive.SupportedHtPhy.RxSTBC = _pAd->MlmeAux.HtCapability.HtCapInfo.RxSTBC;      \
-       _pAd->StaActive.SupportedHtPhy.ExtChanOffset = _pAd->MlmeAux.AddHtInfo.AddHtInfo.ExtChanOffset;      \
-       _pAd->StaActive.SupportedHtPhy.RecomWidth = _pAd->MlmeAux.AddHtInfo.AddHtInfo.RecomWidth;      \
-       _pAd->StaActive.SupportedHtPhy.OperaionMode = _pAd->MlmeAux.AddHtInfo.AddHtInfo2.OperaionMode;      \
-       _pAd->StaActive.SupportedHtPhy.NonGfPresent = _pAd->MlmeAux.AddHtInfo.AddHtInfo2.NonGfPresent;      \
-       NdisMoveMemory((_pAd)->MacTab.Content[BSSID_WCID].HTCapability.MCSSet, (_pAd)->StaActive.SupportedPhyInfo.MCSSet, sizeof(u8) * 16);\
-}
-
-#define COPY_AP_HTSETTINGS_FROM_BEACON(_pAd, _pHtCapability)                                 \
-{                                                                                       \
-       _pAd->MacTab.Content[BSSID_WCID].AMsduSize = (u8)(_pHtCapability->HtCapInfo.AMsduSize); \
-       _pAd->MacTab.Content[BSSID_WCID].MmpsMode = (u8)(_pHtCapability->HtCapInfo.MimoPs);     \
-       _pAd->MacTab.Content[BSSID_WCID].MaxRAmpduFactor = (u8)(_pHtCapability->HtCapParm.MaxRAmpduFactor);     \
-}
-
-/* */
-/* MACRO for 32-bit PCI register read / write */
-/* */
-/* Usage : RTMP_IO_READ32( */
-/*              struct rt_rtmp_adapter *pAd, */
-/*              unsigned long Register_Offset, */
-/*              unsigned long * pValue) */
-/* */
-/*         RTMP_IO_WRITE32( */
-/*              struct rt_rtmp_adapter *pAd, */
-/*              unsigned long Register_Offset, */
-/*              unsigned long Value) */
-/* */
-
-/* */
-/* Common fragment list structure -  Identical to the scatter gather frag list structure */
-/* */
-/*#define struct rt_rtmp_sg_element         SCATTER_GATHER_ELEMENT */
-/*#define struct rt_rtmp_sg_element *PSCATTER_GATHER_ELEMENT */
-#define NIC_MAX_PHYS_BUF_COUNT              8
-
-struct rt_rtmp_sg_element {
-       void *Address;
-       unsigned long Length;
-       unsigned long *Reserved;
-};
-
-struct rt_rtmp_sg_list {
-       unsigned long NumberOfElements;
-       unsigned long *Reserved;
-       struct rt_rtmp_sg_element Elements[NIC_MAX_PHYS_BUF_COUNT];
-};
-
-/* */
-/*  Some utility macros */
-/* */
-#define GET_LNA_GAIN(_pAd)     ((_pAd->LatchRfRegs.Channel <= 14) ? (_pAd->BLNAGain) : ((_pAd->LatchRfRegs.Channel <= 64) ? (_pAd->ALNAGain0) : ((_pAd->LatchRfRegs.Channel <= 128) ? (_pAd->ALNAGain1) : (_pAd->ALNAGain2))))
-
-#define INC_COUNTER64(Val)          (Val.QuadPart++)
-
-#define INFRA_ON(_p)                (OPSTATUS_TEST_FLAG(_p, fOP_STATUS_INFRA_ON))
-#define ADHOC_ON(_p)                (OPSTATUS_TEST_FLAG(_p, fOP_STATUS_ADHOC_ON))
-#define MONITOR_ON(_p)              (((_p)->StaCfg.BssType) == BSS_MONITOR)
-#define IDLE_ON(_p)                 (!INFRA_ON(_p) && !ADHOC_ON(_p))
-
-/* Check LEAP & CCKM flags */
-#define LEAP_ON(_p)                 (((_p)->StaCfg.LeapAuthMode) == CISCO_AuthModeLEAP)
-#define LEAP_CCKM_ON(_p)            ((((_p)->StaCfg.LeapAuthMode) == CISCO_AuthModeLEAP) && ((_p)->StaCfg.LeapAuthInfo.CCKM == TRUE))
-
-/* if original Ethernet frame contains no LLC/SNAP, then an extra LLC/SNAP encap is required */
-#define EXTRA_LLCSNAP_ENCAP_FROM_PKT_START(_pBufVA, _pExtraLlcSnapEncap)               \
-{                                                                                                                              \
-       if (((*(_pBufVA + 12) << 8) + *(_pBufVA + 13)) > 1500) {        \
-               _pExtraLlcSnapEncap = SNAP_802_1H;                                              \
-               if (NdisEqualMemory(IPX, _pBufVA + 12, 2) ||                    \
-                       NdisEqualMemory(APPLE_TALK, _pBufVA + 12, 2)) { \
-                       _pExtraLlcSnapEncap = SNAP_BRIDGE_TUNNEL;                       \
-               }                                                                                                               \
-       }                                                                                                                       \
-       else {                          \
-               _pExtraLlcSnapEncap = NULL;                                                             \
-       }                                                                                                                       \
-}
-
-/* New Define for new Tx Path. */
-#define EXTRA_LLCSNAP_ENCAP_FROM_PKT_OFFSET(_pBufVA, _pExtraLlcSnapEncap)      \
-{                                                                                                                              \
-       if (((*(_pBufVA) << 8) + *(_pBufVA + 1)) > 1500) {              \
-               _pExtraLlcSnapEncap = SNAP_802_1H;                                              \
-               if (NdisEqualMemory(IPX, _pBufVA, 2) ||                                 \
-                       NdisEqualMemory(APPLE_TALK, _pBufVA, 2)) {              \
-                       _pExtraLlcSnapEncap = SNAP_BRIDGE_TUNNEL;                       \
-               }                                                                                                               \
-       }                                                                                                                       \
-       else {          \
-               _pExtraLlcSnapEncap = NULL;                                                             \
-       }                                                                                                                       \
-}
-
-#define MAKE_802_3_HEADER(_p, _pMac1, _pMac2, _pType)                   \
-{                                                                       \
-    NdisMoveMemory(_p, _pMac1, MAC_ADDR_LEN);                           \
-    NdisMoveMemory((_p + MAC_ADDR_LEN), _pMac2, MAC_ADDR_LEN);          \
-    NdisMoveMemory((_p + MAC_ADDR_LEN * 2), _pType, LENGTH_802_3_TYPE); \
-}
-
-/* if pData has no LLC/SNAP (neither RFC1042 nor Bridge tunnel), keep it that way. */
-/* else if the received frame is LLC/SNAP-encaped IPX or APPLETALK, preserve the LLC/SNAP field */
-/* else remove the LLC/SNAP field from the result Ethernet frame */
-/* Patch for WHQL only, which did not turn on Netbios but use IPX within its payload */
-/* Note: */
-/*     _pData & _DataSize may be altered (remove 8-byte LLC/SNAP) by this MACRO */
-/*     _pRemovedLLCSNAP: pointer to removed LLC/SNAP; NULL is not removed */
-#define CONVERT_TO_802_3(_p8023hdr, _pDA, _pSA, _pData, _DataSize, _pRemovedLLCSNAP)      \
-{                                                                       \
-    char LLC_Len[2];                                                    \
-                                                                       \
-    _pRemovedLLCSNAP = NULL;                                            \
-    if (NdisEqualMemory(SNAP_802_1H, _pData, 6)  ||                     \
-       NdisEqualMemory(SNAP_BRIDGE_TUNNEL, _pData, 6)) {               \
-       u8 *pProto = _pData + 6;                                        \
-                                                                       \
-       if ((NdisEqualMemory(IPX, pProto, 2) || NdisEqualMemory(APPLE_TALK, pProto, 2)) &&  \
-               NdisEqualMemory(SNAP_802_1H, _pData, 6))        {       \
-               LLC_Len[0] = (u8)(_DataSize / 256);                     \
-               LLC_Len[1] = (u8)(_DataSize % 256);                     \
-               MAKE_802_3_HEADER(_p8023hdr, _pDA, _pSA, LLC_Len);      \
-       }                                                               \
-       else    {                                                       \
-               MAKE_802_3_HEADER(_p8023hdr, _pDA, _pSA, pProto);       \
-               _pRemovedLLCSNAP = _pData;                              \
-               _DataSize -= LENGTH_802_1_H;                            \
-               _pData += LENGTH_802_1_H;                               \
-       }                                                               \
-    }                                                                   \
-       else    {                                                       \
-       LLC_Len[0] = (u8)(_DataSize / 256);                             \
-       LLC_Len[1] = (u8)(_DataSize % 256);                             \
-       MAKE_802_3_HEADER(_p8023hdr, _pDA, _pSA, LLC_Len);              \
-    }                                                                   \
-}
-
-/* Enqueue this frame to MLME engine */
-/* We need to enqueue the whole frame because MLME need to pass data type */
-/* information from 802.11 header */
-#ifdef RTMP_MAC_PCI
-#define REPORT_MGMT_FRAME_TO_MLME(_pAd, Wcid, _pFrame, _FrameSize, _Rssi0, _Rssi1, _Rssi2, _PlcpSignal)        \
-{                                                                                       \
-    u32 High32TSF, Low32TSF;                                                          \
-    RTMP_IO_READ32(_pAd, TSF_TIMER_DW1, &High32TSF);                                       \
-    RTMP_IO_READ32(_pAd, TSF_TIMER_DW0, &Low32TSF);                                        \
-    MlmeEnqueueForRecv(_pAd, Wcid, High32TSF, Low32TSF, (u8)_Rssi0, (u8)_Rssi1, (u8)_Rssi2, _FrameSize, _pFrame, (u8)_PlcpSignal);   \
-}
-#endif /* RTMP_MAC_PCI // */
-#ifdef RTMP_MAC_USB
-#define REPORT_MGMT_FRAME_TO_MLME(_pAd, Wcid, _pFrame, _FrameSize, _Rssi0, _Rssi1, _Rssi2, _PlcpSignal)        \
-{                                                                                       \
-    u32 High32TSF = 0, Low32TSF = 0;                                                          \
-    MlmeEnqueueForRecv(_pAd, Wcid, High32TSF, Low32TSF, (u8)_Rssi0, (u8)_Rssi1, (u8)_Rssi2, _FrameSize, _pFrame, (u8)_PlcpSignal);   \
-}
-#endif /* RTMP_MAC_USB // */
-
-#define MAC_ADDR_EQUAL(pAddr1, pAddr2)           RTMPEqualMemory((void *)(pAddr1), (void *)(pAddr2), MAC_ADDR_LEN)
-#define SSID_EQUAL(ssid1, len1, ssid2, len2)    ((len1 == len2) && (RTMPEqualMemory(ssid1, ssid2, len1)))
-
-/* */
-/* Check if it is Japan W53(ch52,56,60,64) channel. */
-/* */
-#define JapanChannelCheck(channel)  ((channel == 52) || (channel == 56) || (channel == 60) || (channel == 64))
-
-#define STA_EXTRA_SETTING(_pAd)
-
-#define STA_PORT_SECURED(_pAd) \
-{ \
-       BOOLEAN Cancelled; \
-       (_pAd)->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED; \
-       NdisAcquireSpinLock(&((_pAd)->MacTabLock)); \
-       (_pAd)->MacTab.Content[BSSID_WCID].PortSecured = (_pAd)->StaCfg.PortSecured; \
-       (_pAd)->MacTab.Content[BSSID_WCID].PrivacyFilter = Ndis802_11PrivFilterAcceptAll;\
-       NdisReleaseSpinLock(&(_pAd)->MacTabLock); \
-       RTMPCancelTimer(&((_pAd)->Mlme.LinkDownTimer), &Cancelled);\
-       STA_EXTRA_SETTING(_pAd); \
-}
-
-/* */
-/*  Data buffer for DMA operation, the buffer must be contiguous physical memory */
-/*  Both DMA to / from CPU use the same structure. */
-/* */
-struct rt_rtmp_dmabuf {
-       unsigned long AllocSize;
-       void *AllocVa;          /* TxBuf virtual address */
-       dma_addr_t AllocPa;     /* TxBuf physical address */
-};
-
-/* */
-/* Control block (Descriptor) for all ring descriptor DMA operation, buffer must be */
-/* contiguous physical memory. char stored the binding Rx packet descriptor */
-/* which won't be released, driver has to wait until upper layer return the packet */
-/* before giving up this rx ring descriptor to ASIC. NDIS_BUFFER is associated pair */
-/* to describe the packet buffer. For Tx, char stored the tx packet descriptor */
-/* which driver should ACK upper layer when the tx is physically done or failed. */
-/* */
-struct rt_rtmp_dmacb {
-       unsigned long AllocSize;        /* Control block size */
-       void *AllocVa;          /* Control block virtual address */
-       dma_addr_t AllocPa;     /* Control block physical address */
-       void *pNdisPacket;
-       void *pNextNdisPacket;
-
-       struct rt_rtmp_dmabuf DmaBuf;   /* Associated DMA buffer structure */
-};
-
-struct rt_rtmp_tx_ring {
-       struct rt_rtmp_dmacb Cell[TX_RING_SIZE];
-       u32 TxCpuIdx;
-       u32 TxDmaIdx;
-       u32 TxSwFreeIdx;        /* software next free tx index */
-};
-
-struct rt_rtmp_rx_ring {
-       struct rt_rtmp_dmacb Cell[RX_RING_SIZE];
-       u32 RxCpuIdx;
-       u32 RxDmaIdx;
-       int RxSwReadIdx;        /* software next read index */
-};
-
-struct rt_rtmp_mgmt_ring {
-       struct rt_rtmp_dmacb Cell[MGMT_RING_SIZE];
-       u32 TxCpuIdx;
-       u32 TxDmaIdx;
-       u32 TxSwFreeIdx;        /* software next free tx index */
-};
-
-/* */
-/*  Statistic counter structure */
-/* */
-struct rt_counter_802_3 {
-       /* General Stats */
-       unsigned long GoodTransmits;
-       unsigned long GoodReceives;
-       unsigned long TxErrors;
-       unsigned long RxErrors;
-       unsigned long RxNoBuffer;
-
-       /* Ethernet Stats */
-       unsigned long RcvAlignmentErrors;
-       unsigned long OneCollision;
-       unsigned long MoreCollisions;
-
-};
-
-struct rt_counter_802_11 {
-       unsigned long Length;
-       LARGE_INTEGER LastTransmittedFragmentCount;
-       LARGE_INTEGER TransmittedFragmentCount;
-       LARGE_INTEGER MulticastTransmittedFrameCount;
-       LARGE_INTEGER FailedCount;
-       LARGE_INTEGER RetryCount;
-       LARGE_INTEGER MultipleRetryCount;
-       LARGE_INTEGER RTSSuccessCount;
-       LARGE_INTEGER RTSFailureCount;
-       LARGE_INTEGER ACKFailureCount;
-       LARGE_INTEGER FrameDuplicateCount;
-       LARGE_INTEGER ReceivedFragmentCount;
-       LARGE_INTEGER MulticastReceivedFrameCount;
-       LARGE_INTEGER FCSErrorCount;
-};
-
-struct rt_counter_ralink {
-       unsigned long TransmittedByteCount;     /* both successful and failure, used to calculate TX throughput */
-       unsigned long ReceivedByteCount;        /* both CRC okay and CRC error, used to calculate RX throughput */
-       unsigned long BeenDisassociatedCount;
-       unsigned long BadCQIAutoRecoveryCount;
-       unsigned long PoorCQIRoamingCount;
-       unsigned long MgmtRingFullCount;
-       unsigned long RxCountSinceLastNULL;
-       unsigned long RxCount;
-       unsigned long RxRingErrCount;
-       unsigned long KickTxCount;
-       unsigned long TxRingErrCount;
-       LARGE_INTEGER RealFcsErrCount;
-       unsigned long PendingNdisPacketCount;
-
-       unsigned long OneSecOsTxCount[NUM_OF_TX_RING];
-       unsigned long OneSecDmaDoneCount[NUM_OF_TX_RING];
-       u32 OneSecTxDoneCount;
-       unsigned long OneSecRxCount;
-       u32 OneSecTxAggregationCount;
-       u32 OneSecRxAggregationCount;
-       u32 OneSecReceivedByteCount;
-       u32 OneSecFrameDuplicateCount;
-
-       u32 OneSecTransmittedByteCount; /* both successful and failure, used to calculate TX throughput */
-       u32 OneSecTxNoRetryOkCount;
-       u32 OneSecTxRetryOkCount;
-       u32 OneSecTxFailCount;
-       u32 OneSecFalseCCACnt;  /* CCA error count, for debug purpose, might move to global counter */
-       u32 OneSecRxOkCnt;      /* RX without error */
-       u32 OneSecRxOkDataCnt;  /* unicast-to-me DATA frame count */
-       u32 OneSecRxFcsErrCnt;  /* CRC error */
-       u32 OneSecBeaconSentCnt;
-       u32 LastOneSecTotalTxCount;     /* OneSecTxNoRetryOkCount + OneSecTxRetryOkCount + OneSecTxFailCount */
-       u32 LastOneSecRxOkDataCnt;      /* OneSecRxOkDataCnt */
-       unsigned long DuplicateRcv;
-       unsigned long TxAggCount;
-       unsigned long TxNonAggCount;
-       unsigned long TxAgg1MPDUCount;
-       unsigned long TxAgg2MPDUCount;
-       unsigned long TxAgg3MPDUCount;
-       unsigned long TxAgg4MPDUCount;
-       unsigned long TxAgg5MPDUCount;
-       unsigned long TxAgg6MPDUCount;
-       unsigned long TxAgg7MPDUCount;
-       unsigned long TxAgg8MPDUCount;
-       unsigned long TxAgg9MPDUCount;
-       unsigned long TxAgg10MPDUCount;
-       unsigned long TxAgg11MPDUCount;
-       unsigned long TxAgg12MPDUCount;
-       unsigned long TxAgg13MPDUCount;
-       unsigned long TxAgg14MPDUCount;
-       unsigned long TxAgg15MPDUCount;
-       unsigned long TxAgg16MPDUCount;
-
-       LARGE_INTEGER TransmittedOctetsInAMSDU;
-       LARGE_INTEGER TransmittedAMSDUCount;
-       LARGE_INTEGER ReceivedOctesInAMSDUCount;
-       LARGE_INTEGER ReceivedAMSDUCount;
-       LARGE_INTEGER TransmittedAMPDUCount;
-       LARGE_INTEGER TransmittedMPDUsInAMPDUCount;
-       LARGE_INTEGER TransmittedOctetsInAMPDUCount;
-       LARGE_INTEGER MPDUInReceivedAMPDUCount;
-};
-
-struct rt_counter_drs {
-       /* record each TX rate's quality. 0 is best, the bigger the worse. */
-       u16 TxQuality[MAX_STEP_OF_TX_RATE_SWITCH];
-       u8 PER[MAX_STEP_OF_TX_RATE_SWITCH];
-       u8 TxRateUpPenalty;     /* extra # of second penalty due to last unstable condition */
-       unsigned long CurrTxRateStableTime;     /* # of second in current TX rate */
-       BOOLEAN fNoisyEnvironment;
-       BOOLEAN fLastSecAccordingRSSI;
-       u8 LastSecTxRateChangeAction;   /* 0: no change, 1:rate UP, 2:rate down */
-       u8 LastTimeTxRateChangeAction;  /*Keep last time value of LastSecTxRateChangeAction */
-       unsigned long LastTxOkCount;
-};
-
-/***************************************************************************
-  *    security key related data structure
-  **************************************************************************/
-struct rt_cipher_key {
-       u8 Key[16];             /* right now we implement 4 keys, 128 bits max */
-       u8 RxMic[8];            /* make alignment */
-       u8 TxMic[8];
-       u8 TxTsc[6];            /* 48bit TSC value */
-       u8 RxTsc[6];            /* 48bit TSC value */
-       u8 CipherAlg;   /* 0-none, 1:WEP64, 2:WEP128, 3:TKIP, 4:AES, 5:CKIP64, 6:CKIP128 */
-       u8 KeyLen;
-       u8 BssId[6];
-       /* Key length for each key, 0: entry is invalid */
-       u8 Type;                /* Indicate Pairwise/Group when reporting MIC error */
-};
-
-/* structure to define WPA Group Key Rekey Interval */
-struct PACKED rt_802_11_wpa_rekey {
-       unsigned long ReKeyMethod;      /* mechanism for rekeying: 0:disable, 1: time-based, 2: packet-based */
-       unsigned long ReKeyInterval;    /* time-based: seconds, packet-based: kilo-packets */
-};
-
-#ifdef RTMP_MAC_USB
-/***************************************************************************
-  *    RTUSB I/O related data structure
-  **************************************************************************/
-struct rt_set_asic_wcid {
-       unsigned long WCID;             /* mechanism for rekeying: 0:disable, 1: time-based, 2: packet-based */
-       unsigned long SetTid;           /* time-based: seconds, packet-based: kilo-packets */
-       unsigned long DeleteTid;        /* time-based: seconds, packet-based: kilo-packets */
-       u8 Addr[MAC_ADDR_LEN];  /* avoid in interrupt when write key */
-};
-
-struct rt_set_asic_wcid_attri {
-       unsigned long WCID;             /* mechanism for rekeying: 0:disable, 1: time-based, 2: packet-based */
-       unsigned long Cipher;           /* ASIC Cipher definition */
-       u8 Addr[ETH_LENGTH_OF_ADDRESS];
-};
-
-/* for USB interface, avoid in interrupt when write key */
-struct rt_add_pairwise_key_entry {
-       u8 MacAddr[6];
-       u16 MacTabMatchWCID;    /* ASIC */
-       struct rt_cipher_key CipherKey;
-};
-
-/* Cipher suite type for mixed mode group cipher, P802.11i-2004 */
-typedef enum _RT_802_11_CIPHER_SUITE_TYPE {
-       Cipher_Type_NONE,
-       Cipher_Type_WEP40,
-       Cipher_Type_TKIP,
-       Cipher_Type_RSVD,
-       Cipher_Type_CCMP,
-       Cipher_Type_WEP104
-} RT_802_11_CIPHER_SUITE_TYPE, *PRT_802_11_CIPHER_SUITE_TYPE;
-#endif /* RTMP_MAC_USB // */
-
-struct rt_rogueap_entry {
-       u8 Addr[MAC_ADDR_LEN];
-       u8 ErrorCode[2];        /*00 01-Invalid authentication type */
-       /*00 02-Authentication timeout */
-       /*00 03-Challenge from AP failed */
-       /*00 04-Challenge to AP failed */
-       BOOLEAN Reported;
-};
-
-struct rt_rogueap_table {
-       u8 RogueApNr;
-       struct rt_rogueap_entry RogueApEntry[MAX_LEN_OF_BSS_TABLE];
-};
-
-/* */
-/* Cisco IAPP format */
-/* */
-struct rt_cisco_iapp_content {
-       u16 Length;             /*IAPP Length */
-       u8 MessageType; /*IAPP type */
-       u8 FunctionCode;        /*IAPP function type */
-       u8 DestinaionMAC[MAC_ADDR_LEN];
-       u8 SourceMAC[MAC_ADDR_LEN];
-       u16 Tag;                /*Tag(element IE) - Adjacent AP report */
-       u16 TagLength;  /*Length of element not including 4 byte header */
-       u8 OUI[4];              /*0x00, 0x40, 0x96, 0x00 */
-       u8 PreviousAP[MAC_ADDR_LEN];    /*MAC Address of access point */
-       u16 Channel;
-       u16 SsidLen;
-       u8 Ssid[MAX_LEN_OF_SSID];
-       u16 Seconds;            /*Seconds that the client has been disassociated. */
-};
-
-/*
-  *    Fragment Frame structure
-  */
-struct rt_fragment_frame {
-       void *pFragPacket;
-       unsigned long RxSize;
-       u16 Sequence;
-       u16 LastFrag;
-       unsigned long Flags;            /* Some extra frame information. bit 0: LLC presented */
-};
-
-/* */
-/* Packet information for NdisQueryPacket */
-/* */
-struct rt_packet_info {
-       u32 PhysicalBufferCount;        /* Physical breaks of buffer descriptor chained */
-       u32 BufferCount;        /* Number of Buffer descriptor chained */
-       u32 TotalPacketLength;  /* Self explained */
-       char *pFirstBuffer;     /* Pointer to first buffer descriptor */
-};
-
-/* */
-/*  Arcfour Structure Added by PaulWu */
-/* */
-struct rt_arcfourcontext {
-       u32 X;
-       u32 Y;
-       u8 STATE[256];
-};
-
-/* */
-/* Tkip Key structure which RC4 key & MIC calculation */
-/* */
-struct rt_tkip_key_info {
-       u32 nBytesInM;          /* # bytes in M for MICKEY */
-       unsigned long IV16;
-       unsigned long IV32;
-       unsigned long K0;               /* for MICKEY Low */
-       unsigned long K1;               /* for MICKEY Hig */
-       unsigned long L;                /* Current state for MICKEY */
-       unsigned long R;                /* Current state for MICKEY */
-       unsigned long M;                /* Message accumulator for MICKEY */
-       u8 RC4KEY[16];
-       u8 MIC[8];
-};
-
-/* */
-/* Private / Misc data, counters for driver internal use */
-/* */
-struct rt_private {
-       u32 SystemResetCnt;     /* System reset counter */
-       u32 TxRingFullCnt;      /* Tx ring full occurrence number */
-       u32 PhyRxErrCnt;        /* PHY Rx error count, for debug purpose, might move to global counter */
-       /* Variables for WEP encryption / decryption in rtmp_wep.c */
-       u32 FCSCRC32;
-       struct rt_arcfourcontext WEPCONTEXT;
-       /* Tkip stuff */
-       struct rt_tkip_key_info Tx;
-       struct rt_tkip_key_info Rx;
-};
-
-/***************************************************************************
-  *    Channel and BBP related data structures
-  **************************************************************************/
-/* structure to tune BBP R66 (BBP TUNING) */
-struct rt_bbp_r66_tuning {
-       BOOLEAN bEnable;
-       u16 FalseCcaLowerThreshold;     /* default 100 */
-       u16 FalseCcaUpperThreshold;     /* default 512 */
-       u8 R66Delta;
-       u8 R66CurrentValue;
-       BOOLEAN R66LowerUpperSelect;    /*Before LinkUp, Used LowerBound or UpperBound as R66 value. */
-};
-
-/* structure to store channel TX power */
-struct rt_channel_tx_power {
-       u16 RemainingTimeForUse;        /*unit: sec */
-       u8 Channel;
-       char Power;
-       char Power2;
-       u8 MaxTxPwr;
-       u8 DfsReq;
-};
-
-/* structure to store 802.11j channel TX power */
-struct rt_channel_11j_tx_power {
-       u8 Channel;
-       u8 BW;          /* BW_10 or BW_20 */
-       char Power;
-       char Power2;
-       u16 RemainingTimeForUse;        /*unit: sec */
-};
-
-struct rt_soft_rx_ant_diversity {
-       u8 EvaluatePeriod;      /* 0:not evalute status, 1: evaluate status, 2: switching status */
-       u8 EvaluateStableCnt;
-       u8 Pair1PrimaryRxAnt;   /* 0:Ant-E1, 1:Ant-E2 */
-       u8 Pair1SecondaryRxAnt; /* 0:Ant-E1, 1:Ant-E2 */
-       u8 Pair2PrimaryRxAnt;   /* 0:Ant-E3, 1:Ant-E4 */
-       u8 Pair2SecondaryRxAnt; /* 0:Ant-E3, 1:Ant-E4 */
-       short Pair1AvgRssi[2];  /* AvgRssi[0]:E1, AvgRssi[1]:E2 */
-       short Pair2AvgRssi[2];  /* AvgRssi[0]:E3, AvgRssi[1]:E4 */
-       short Pair1LastAvgRssi; /* */
-       short Pair2LastAvgRssi; /* */
-       unsigned long RcvPktNumWhenEvaluate;
-       BOOLEAN FirstPktArrivedWhenEvaluate;
-       struct rt_ralink_timer RxAntDiversityTimer;
-};
-
-/***************************************************************************
-  *    structure for radar detection and channel switch
-  **************************************************************************/
-struct rt_radar_detect {
-       /*BOOLEAN           IEEE80211H;                     // 0: disable, 1: enable IEEE802.11h */
-       u8 CSCount;             /*Channel switch counter */
-       u8 CSPeriod;            /*Channel switch period (beacon count) */
-       u8 RDCount;             /*Radar detection counter */
-       u8 RDMode;              /*Radar Detection mode */
-       u8 RDDurRegion; /*Radar detection duration region */
-       u8 BBPR16;
-       u8 BBPR17;
-       u8 BBPR18;
-       u8 BBPR21;
-       u8 BBPR22;
-       u8 BBPR64;
-       unsigned long InServiceMonitorCount;    /* unit: sec */
-       u8 DfsSessionTime;
-       BOOLEAN bFastDfs;
-       u8 ChMovingTime;
-       u8 LongPulseRadarTh;
-};
-
-typedef enum _ABGBAND_STATE_ {
-       UNKNOWN_BAND,
-       BG_BAND,
-       A_BAND,
-} ABGBAND_STATE;
-
-#ifdef RTMP_MAC_PCI
-/* Power save method control */
-typedef union _PS_CONTROL {
-       struct {
-               unsigned long EnablePSinIdle:1; /* Enable radio off when not connected to AP. radio on only when sitesurvey, */
-               unsigned long EnableNewPS:1;    /* Enable new  Chip power save function . New method can only be applied in chip version after 2872. and PCIe. */
-               unsigned long rt30xxPowerMode:2;        /* Power Level Mode for rt30xx chip */
-               unsigned long rt30xxFollowHostASPM:1;   /* Card Follows Host's setting for rt30xx chip. */
-               unsigned long rt30xxForceASPMTest:1;    /* Force enable L1 for rt30xx chip. This has higher priority than rt30xxFollowHostASPM Mode. */
-               unsigned long rsv:26;   /* Radio Measurement Enable */
-       } field;
-       unsigned long word;
-} PS_CONTROL, *PPS_CONTROL;
-#endif /* RTMP_MAC_PCI // */
-
-/***************************************************************************
-  *    structure for MLME state machine
-  **************************************************************************/
-struct rt_mlme {
-       /* STA state machines */
-       struct rt_state_machine CntlMachine;
-       struct rt_state_machine AssocMachine;
-       struct rt_state_machine AuthMachine;
-       struct rt_state_machine AuthRspMachine;
-       struct rt_state_machine SyncMachine;
-       struct rt_state_machine WpaPskMachine;
-       struct rt_state_machine LeapMachine;
-       STATE_MACHINE_FUNC AssocFunc[ASSOC_FUNC_SIZE];
-       STATE_MACHINE_FUNC AuthFunc[AUTH_FUNC_SIZE];
-       STATE_MACHINE_FUNC AuthRspFunc[AUTH_RSP_FUNC_SIZE];
-       STATE_MACHINE_FUNC SyncFunc[SYNC_FUNC_SIZE];
-       STATE_MACHINE_FUNC ActFunc[ACT_FUNC_SIZE];
-       /* Action */
-       struct rt_state_machine ActMachine;
-
-       /* common WPA state machine */
-       struct rt_state_machine WpaMachine;
-       STATE_MACHINE_FUNC WpaFunc[WPA_FUNC_SIZE];
-
-       unsigned long ChannelQuality;   /* 0..100, Channel Quality Indication for Roaming */
-       unsigned long Now32;            /* latch the value of NdisGetSystemUpTime() */
-       unsigned long LastSendNULLpsmTime;
-
-       BOOLEAN bRunning;
-       spinlock_t TaskLock;
-       struct rt_mlme_queue Queue;
-
-       u32 ShiftReg;
-
-       struct rt_ralink_timer PeriodicTimer;
-       struct rt_ralink_timer APSDPeriodicTimer;
-       struct rt_ralink_timer LinkDownTimer;
-       struct rt_ralink_timer LinkUpTimer;
-#ifdef RTMP_MAC_PCI
-       u8 bPsPollTimerRunning;
-       struct rt_ralink_timer PsPollTimer;
-       struct rt_ralink_timer RadioOnOffTimer;
-#endif                         /* RTMP_MAC_PCI // */
-       unsigned long PeriodicRound;
-       unsigned long OneSecPeriodicRound;
-
-       u8 RealRxPath;
-       BOOLEAN bLowThroughput;
-       BOOLEAN bEnableAutoAntennaCheck;
-       struct rt_ralink_timer RxAntEvalTimer;
-
-#ifdef RT30xx
-       u8 CaliBW40RfR24;
-       u8 CaliBW20RfR24;
-#endif                         /* RT30xx // */
-
-#ifdef RTMP_MAC_USB
-       struct rt_ralink_timer AutoWakeupTimer;
-       BOOLEAN AutoWakeupTimerRunning;
-#endif                         /* RTMP_MAC_USB // */
-};
-
-/***************************************************************************
-  *    802.11 N related data structures
-  **************************************************************************/
-struct reordering_mpdu {
-       struct reordering_mpdu *next;
-       void *pPacket;  /* converted to 802.3 frame */
-       int Sequence;           /* sequence number of MPDU */
-       BOOLEAN bAMSDU;
-};
-
-struct reordering_list {
-       struct reordering_mpdu *next;
-       int qlen;
-};
-
-struct reordering_mpdu_pool {
-       void *mem;
-       spinlock_t lock;
-       struct reordering_list freelist;
-};
-
-typedef enum _REC_BLOCKACK_STATUS {
-       Recipient_NONE = 0,
-       Recipient_USED,
-       Recipient_HandleRes,
-       Recipient_Accept
-} REC_BLOCKACK_STATUS, *PREC_BLOCKACK_STATUS;
-
-typedef enum _ORI_BLOCKACK_STATUS {
-       Originator_NONE = 0,
-       Originator_USED,
-       Originator_WaitRes,
-       Originator_Done
-} ORI_BLOCKACK_STATUS, *PORI_BLOCKACK_STATUS;
-
-struct rt_ba_ori_entry {
-       u8 Wcid;
-       u8 TID;
-       u8 BAWinSize;
-       u8 Token;
-/* Sequence is to fill every outgoing QoS DATA frame's sequence field in 802.11 header. */
-       u16 Sequence;
-       u16 TimeOutValue;
-       ORI_BLOCKACK_STATUS ORI_BA_Status;
-       struct rt_ralink_timer ORIBATimer;
-       void *pAdapter;
-};
-
-struct rt_ba_rec_entry {
-       u8 Wcid;
-       u8 TID;
-       u8 BAWinSize;   /* 7.3.1.14. each buffer is capable of holding a max AMSDU or MSDU. */
-       /*u8 NumOfRxPkt; */
-       /*u8    Curindidx; // the head in the RX reordering buffer */
-       u16 LastIndSeq;
-/*      u16          LastIndSeqAtTimer; */
-       u16 TimeOutValue;
-       struct rt_ralink_timer RECBATimer;
-       unsigned long LastIndSeqAtTimer;
-       unsigned long nDropPacket;
-       unsigned long rcvSeq;
-       REC_BLOCKACK_STATUS REC_BA_Status;
-/*      u8   RxBufIdxUsed; */
-       /* corresponding virtual address for RX reordering packet storage. */
-       /*RTMP_REORDERDMABUF MAP_RXBuf[MAX_RX_REORDERBUF]; */
-       spinlock_t RxReRingLock;        /* Rx Ring spinlock */
-/*      struct _BA_REC_ENTRY *pNext; */
-       void *pAdapter;
-       struct reordering_list list;
-};
-
-struct rt_ba_table {
-       unsigned long numAsRecipient;   /* I am recipient of numAsRecipient clients. These client are in the BARecEntry[] */
-       unsigned long numAsOriginator;  /* I am originator of   numAsOriginator clients. These clients are in the BAOriEntry[] */
-       unsigned long numDoneOriginator;        /* count Done Originator sessions */
-       struct rt_ba_ori_entry BAOriEntry[MAX_LEN_OF_BA_ORI_TABLE];
-       struct rt_ba_rec_entry BARecEntry[MAX_LEN_OF_BA_REC_TABLE];
-};
-
-/*For QureyBATableOID use; */
-struct PACKED rt_oid_ba_rec_entry {
-       u8 MACAddr[MAC_ADDR_LEN];
-       u8 BaBitmap;            /* if (BaBitmap&(1<<TID)), this session with{MACAddr, TID}exists, so read BufSize[TID] for BufferSize */
-       u8 rsv;
-       u8 BufSize[8];
-       REC_BLOCKACK_STATUS REC_BA_Status[8];
-};
-
-/*For QureyBATableOID use; */
-struct PACKED rt_oid_ba_ori_entry {
-       u8 MACAddr[MAC_ADDR_LEN];
-       u8 BaBitmap;            /* if (BaBitmap&(1<<TID)), this session with{MACAddr, TID}exists, so read BufSize[TID] for BufferSize, read ORI_BA_Status[TID] for status */
-       u8 rsv;
-       u8 BufSize[8];
-       ORI_BLOCKACK_STATUS ORI_BA_Status[8];
-};
-
-struct rt_queryba_table {
-       struct rt_oid_ba_ori_entry BAOriEntry[32];
-       struct rt_oid_ba_rec_entry BARecEntry[32];
-       u8 OriNum;              /* Number of below BAOriEntry */
-       u8 RecNum;              /* Number of below BARecEntry */
-};
-
-typedef union _BACAP_STRUC {
-       struct {
-               u32 RxBAWinLimit:8;
-               u32 TxBAWinLimit:8;
-               u32 AutoBA:1;   /* automatically BA */
-               u32 Policy:2;   /* 0: DELAY_BA 1:IMMED_BA  (//BA Policy subfiled value in ADDBA frame)   2:BA-not use */
-               u32 MpduDensity:3;
-               u32 AmsduEnable:1;      /*Enable AMSDU transmisstion */
-               u32 AmsduSize:1;        /* 0:3839, 1:7935 bytes. u32  MSDUSizeToBytes[]        = { 3839, 7935}; */
-               u32 MMPSmode:2; /* MIMO power save more, 0:static, 1:dynamic, 2:rsv, 3:mimo enable */
-               u32 bHtAdhoc:1; /* adhoc can use ht rate. */
-               u32 b2040CoexistScanSup:1;      /*As Sta, support do 2040 coexistence scan for AP. As Ap, support monitor trigger event to check if can use BW 40MHz. */
-               u32: 4;
-       } field;
-       u32 word;
-} BACAP_STRUC, *PBACAP_STRUC;
-
-struct rt_oid_add_ba_entry {
-       BOOLEAN IsRecipient;
-       u8 MACAddr[MAC_ADDR_LEN];
-       u8 TID;
-       u8 nMSDU;
-       u16 TimeOut;
-       BOOLEAN bAllTid;        /* If True, delete all TID for BA sessions with this MACaddr. */
-};
-
-#define IS_HT_STA(_pMacEntry)  \
-       (_pMacEntry->MaxHTPhyMode.field.MODE >= MODE_HTMIX)
-
-#define IS_HT_RATE(_pMacEntry) \
-       (_pMacEntry->HTPhyMode.field.MODE >= MODE_HTMIX)
-
-#define PEER_IS_HT_RATE(_pMacEntry)    \
-       (_pMacEntry->HTPhyMode.field.MODE >= MODE_HTMIX)
-
-/*This structure is for all 802.11n card InterOptibilityTest action. Reset all Num every n second.  (Details see MLMEPeriodic) */
-struct rt_iot {
-       u8 Threshold[2];
-       u8 ReorderTimeOutNum[MAX_LEN_OF_BA_REC_TABLE];  /* compare with threshold[0] */
-       u8 RefreshNum[MAX_LEN_OF_BA_REC_TABLE]; /* compare with threshold[1] */
-       unsigned long OneSecInWindowCount;
-       unsigned long OneSecFrameDuplicateCount;
-       unsigned long OneSecOutWindowCount;
-       u8 DelOriAct;
-       u8 DelRecAct;
-       u8 RTSShortProt;
-       u8 RTSLongProt;
-       BOOLEAN bRTSLongProtOn;
-       BOOLEAN bLastAtheros;
-       BOOLEAN bCurrentAtheros;
-       BOOLEAN bNowAtherosBurstOn;
-       BOOLEAN bNextDisableRxBA;
-       BOOLEAN bToggle;
-};
-
-/* This is the registry setting for 802.11n transmit setting.  Used in advanced page. */
-typedef union _REG_TRANSMIT_SETTING {
-       struct {
-               /*u32  PhyMode:4; */
-               /*u32  MCS:7;                 // MCS */
-               u32 rsv0:10;
-               u32 TxBF:1;
-               u32 BW:1;       /*channel bandwidth 20MHz or 40 MHz */
-               u32 ShortGI:1;
-               u32 STBC:1;     /*SPACE */
-               u32 TRANSNO:2;
-               u32 HTMODE:1;
-               u32 EXTCHA:2;
-               u32 rsv:13;
-       } field;
-       u32 word;
-} REG_TRANSMIT_SETTING, *PREG_TRANSMIT_SETTING;
-
-typedef union _DESIRED_TRANSMIT_SETTING {
-       struct {
-               u16 MCS:7;      /* MCS */
-               u16 PhyMode:4;
-               u16 FixedTxMode:2;      /* If MCS isn't AUTO, fix rate in CCK, OFDM or HT mode. */
-               u16 rsv:3;
-       } field;
-       u16 word;
-} DESIRED_TRANSMIT_SETTING, *PDESIRED_TRANSMIT_SETTING;
-
-#ifdef RTMP_MAC_USB
-/***************************************************************************
-  *    USB-based chip Beacon related data structures
-  **************************************************************************/
-#define BEACON_BITMAP_MASK             0xff
-struct rt_beacon_sync {
-       u8 BeaconBuf[HW_BEACON_MAX_COUNT][HW_BEACON_OFFSET];
-       u8 BeaconTxWI[HW_BEACON_MAX_COUNT][TXWI_SIZE];
-       unsigned long TimIELocationInBeacon[HW_BEACON_MAX_COUNT];
-       unsigned long CapabilityInfoLocationInBeacon[HW_BEACON_MAX_COUNT];
-       BOOLEAN EnableBeacon;   /* trigger to enable beacon transmission. */
-       u8 BeaconBitMap;        /* NOTE: If the MAX_MBSSID_NUM is larger than 8, this parameter needs to change. */
-       u8 DtimBitOn;   /* NOTE: If the MAX_MBSSID_NUM is larger than 8, this parameter needs to change. */
-};
-#endif /* RTMP_MAC_USB // */
-
-/***************************************************************************
-  *    Multiple SSID related data structures
-  **************************************************************************/
-#define WLAN_MAX_NUM_OF_TIM                    ((MAX_LEN_OF_MAC_TABLE >> 3) + 1)       /* /8 + 1 */
-#define WLAN_CT_TIM_BCMC_OFFSET                0       /* unit: 32B */
-
-/* clear bcmc TIM bit */
-#define WLAN_MR_TIM_BCMC_CLEAR(apidx) \
-       pAd->ApCfg.MBSSID[apidx].TimBitmaps[WLAN_CT_TIM_BCMC_OFFSET] &= ~BIT8[0];
-
-/* set bcmc TIM bit */
-#define WLAN_MR_TIM_BCMC_SET(apidx) \
-       pAd->ApCfg.MBSSID[apidx].TimBitmaps[WLAN_CT_TIM_BCMC_OFFSET] |= BIT8[0];
-
-/* clear a station PS TIM bit */
-#define WLAN_MR_TIM_BIT_CLEAR(ad_p, apidx, wcid) \
-       {       u8 tim_offset = wcid >> 3; \
-               u8 bit_offset = wcid & 0x7; \
-               ad_p->ApCfg.MBSSID[apidx].TimBitmaps[tim_offset] &= (~BIT8[bit_offset]); }
-
-/* set a station PS TIM bit */
-#define WLAN_MR_TIM_BIT_SET(ad_p, apidx, wcid) \
-       {       u8 tim_offset = wcid >> 3; \
-               u8 bit_offset = wcid & 0x7; \
-               ad_p->ApCfg.MBSSID[apidx].TimBitmaps[tim_offset] |= BIT8[bit_offset]; }
-
-/* configuration common to OPMODE_AP as well as OPMODE_STA */
-struct rt_common_config {
-
-       BOOLEAN bCountryFlag;
-       u8 CountryCode[3];
-       u8 Geography;
-       u8 CountryRegion;       /* Enum of country region, 0:FCC, 1:IC, 2:ETSI, 3:SPAIN, 4:France, 5:MKK, 6:MKK1, 7:Israel */
-       u8 CountryRegionForABand;       /* Enum of country region for A band */
-       u8 PhyMode;             /* PHY_11A, PHY_11B, PHY_11BG_MIXED, PHY_ABG_MIXED */
-       u16 Dsifs;              /* in units of usec */
-       unsigned long PacketFilter;     /* Packet filter for receiving */
-       u8 RegulatoryClass;
-
-       char Ssid[MAX_LEN_OF_SSID];     /* NOT NULL-terminated */
-       u8 SsidLen;             /* the actual ssid length in used */
-       u8 LastSsidLen; /* the actual ssid length in used */
-       char LastSsid[MAX_LEN_OF_SSID]; /* NOT NULL-terminated */
-       u8 LastBssid[MAC_ADDR_LEN];
-
-       u8 Bssid[MAC_ADDR_LEN];
-       u16 BeaconPeriod;
-       u8 Channel;
-       u8 CentralChannel;      /* Central Channel when using 40MHz is indicating. not real channel. */
-
-       u8 SupRate[MAX_LEN_OF_SUPPORTED_RATES];
-       u8 SupRateLen;
-       u8 ExtRate[MAX_LEN_OF_SUPPORTED_RATES];
-       u8 ExtRateLen;
-       u8 DesireRate[MAX_LEN_OF_SUPPORTED_RATES];      /* OID_802_11_DESIRED_RATES */
-       u8 MaxDesiredRate;
-       u8 ExpectedACKRate[MAX_LEN_OF_SUPPORTED_RATES];
-
-       unsigned long BasicRateBitmap;  /* backup basic ratebitmap */
-
-       BOOLEAN bAPSDCapable;
-       BOOLEAN bInServicePeriod;
-       BOOLEAN bAPSDAC_BE;
-       BOOLEAN bAPSDAC_BK;
-       BOOLEAN bAPSDAC_VI;
-       BOOLEAN bAPSDAC_VO;
-
-       /* because TSPEC can modify the APSD flag, we need to keep the APSD flag
-          requested in association stage from the station;
-          we need to recover the APSD flag after the TSPEC is deleted. */
-       BOOLEAN bACMAPSDBackup[4];      /* for delivery-enabled & trigger-enabled both */
-       BOOLEAN bACMAPSDTr[4];  /* no use */
-
-       BOOLEAN bNeedSendTriggerFrame;
-       BOOLEAN bAPSDForcePowerSave;    /* Force power save mode, should only use in APSD-STAUT */
-       unsigned long TriggerTimerCount;
-       u8 MaxSPLength;
-       u8 BBPCurrentBW;        /* BW_10,       BW_20, BW_40 */
-       /* move to MULTISSID_STRUCT for MBSS */
-       /*HTTRANSMIT_SETTING    HTPhyMode, MaxHTPhyMode, MinHTPhyMode;// For transmit phy setting in TXWI. */
-       REG_TRANSMIT_SETTING RegTransmitSetting;        /*registry transmit setting. this is for reading registry setting only. not useful. */
-       /*u8       FixedTxMode;              // Fixed Tx Mode (CCK, OFDM), for HT fixed tx mode (GF, MIX) , refer to RegTransmitSetting.field.HTMode */
-       u8 TxRate;              /* Same value to fill in TXD. TxRate is 6-bit */
-       u8 MaxTxRate;   /* RATE_1, RATE_2, RATE_5_5, RATE_11 */
-       u8 TxRateIndex; /* Tx rate index in RateSwitchTable */
-       u8 TxRateTableSize;     /* Valid Tx rate table size in RateSwitchTable */
-       /*BOOLEAN               bAutoTxRateSwitch; */
-       u8 MinTxRate;   /* RATE_1, RATE_2, RATE_5_5, RATE_11 */
-       u8 RtsRate;             /* RATE_xxx */
-       HTTRANSMIT_SETTING MlmeTransmit;        /* MGMT frame PHY rate setting when operation at Ht rate. */
-       u8 MlmeRate;            /* RATE_xxx, used to send MLME frames */
-       u8 BasicMlmeRate;       /* Default Rate for sending MLME frames */
-
-       u16 RtsThreshold;       /* in unit of BYTE */
-       u16 FragmentThreshold;  /* in unit of BYTE */
-
-       u8 TxPower;             /* in unit of mW */
-       unsigned long TxPowerPercentage;        /* 0~100 % */
-       unsigned long TxPowerDefault;   /* keep for TxPowerPercentage */
-       u8 PwrConstraint;
-
-       BACAP_STRUC BACapability;       /*   NO USE = 0XFF  ;  IMMED_BA =1  ;  DELAY_BA=0 */
-       BACAP_STRUC REGBACapability;    /*   NO USE = 0XFF  ;  IMMED_BA =1  ;  DELAY_BA=0 */
-
-       struct rt_iot IOTestParm;       /* 802.11n InterOpbility Test Parameter; */
-       unsigned long TxPreamble;       /* Rt802_11PreambleLong, Rt802_11PreambleShort, Rt802_11PreambleAuto */
-       BOOLEAN bUseZeroToDisableFragment;      /* Microsoft use 0 as disable */
-       unsigned long UseBGProtection;  /* 0: auto, 1: always use, 2: always not use */
-       BOOLEAN bUseShortSlotTime;      /* 0: disable, 1 - use short slot (9us) */
-       BOOLEAN bEnableTxBurst; /* 1: enble TX PACKET BURST (when BA is established or AP is not a legacy WMM AP), 0: disable TX PACKET BURST */
-       BOOLEAN bAggregationCapable;    /* 1: enable TX aggregation when the peer supports it */
-       BOOLEAN bPiggyBackCapable;      /* 1: enable TX piggy-back according MAC's version */
-       BOOLEAN bIEEE80211H;    /* 1: enable IEEE802.11h spec. */
-       unsigned long DisableOLBCDetect;        /* 0: enable OLBC detect; 1 disable OLBC detect */
-
-       BOOLEAN bRdg;
-
-       BOOLEAN bWmmCapable;    /* 0:disable WMM, 1:enable WMM */
-       struct rt_qos_capability_parm APQosCapability;  /* QOS capability of the current associated AP */
-       struct rt_edca_parm APEdcaParm; /* EDCA parameters of the current associated AP */
-       struct rt_qbss_load_parm APQbssLoad;    /* QBSS load of the current associated AP */
-       u8 AckPolicy[4];        /* ACK policy of the specified AC. see ACK_xxx */
-       BOOLEAN bDLSCapable;    /* 0:disable DLS, 1:enable DLS */
-       /* a bitmap of BOOLEAN flags. each bit represent an operation status of a particular */
-       /* BOOLEAN control, either ON or OFF. These flags should always be accessed via */
-       /* OPSTATUS_TEST_FLAG(), OPSTATUS_SET_FLAG(), OP_STATUS_CLEAR_FLAG() macros. */
-       /* see fOP_STATUS_xxx in RTMP_DEF.C for detail bit definition */
-       unsigned long OpStatusFlags;
-
-       BOOLEAN NdisRadioStateOff;      /*For HCT 12.0, set this flag to TRUE instead of called MlmeRadioOff. */
-       ABGBAND_STATE BandState;        /* For setting BBP used on B/G or A mode. */
-
-       /* IEEE802.11H--DFS. */
-       struct rt_radar_detect RadarDetect;
-
-       /* HT */
-       u8 BASize;              /* USer desired BAWindowSize. Should not exceed our max capability */
-       /*struct rt_ht_capability      SupportedHtPhy; */
-       struct rt_ht_capability DesiredHtPhy;
-       struct rt_ht_capability_ie HtCapability;
-       struct rt_add_ht_info_ie AddHTInfo;     /* Useful as AP. */
-       /*This IE is used with channel switch announcement element when changing to a new 40MHz. */
-       /*This IE is included in channel switch announcement frames 7.4.1.5, beacons, probe Rsp. */
-       struct rt_new_ext_chan_ie NewExtChanOffset;     /*7.3.2.20A, 1 if extension channel is above the control channel, 3 if below, 0 if not present */
-
-       BOOLEAN bHTProtect;
-       BOOLEAN bMIMOPSEnable;
-       BOOLEAN bBADecline;
-/*2008/11/05: KH add to support Antenna power-saving of AP<-- */
-       BOOLEAN bGreenAPEnable;
-/*2008/11/05: KH add to support Antenna power-saving of AP--> */
-       BOOLEAN bDisableReordering;
-       BOOLEAN bForty_Mhz_Intolerant;
-       BOOLEAN bExtChannelSwitchAnnouncement;
-       BOOLEAN bRcvBSSWidthTriggerEvents;
-       unsigned long LastRcvBSSWidthTriggerEventsTime;
-
-       u8 TxBASize;
-
-       /* Enable wireless event */
-       BOOLEAN bWirelessEvent;
-       BOOLEAN bWiFiTest;      /* Enable this parameter for WiFi test */
-
-       /* Tx & Rx Stream number selection */
-       u8 TxStream;
-       u8 RxStream;
-
-       BOOLEAN bHardwareRadio; /* Hardware controlled Radio enabled */
-
-#ifdef RTMP_MAC_USB
-       BOOLEAN bMultipleIRP;   /* Multiple Bulk IN flag */
-       u8 NumOfBulkInIRP;      /* if bMultipleIRP == TRUE, NumOfBulkInIRP will be 4 otherwise be 1 */
-       struct rt_ht_capability SupportedHtPhy;
-       unsigned long MaxPktOneTxBulk;
-       u8 TxBulkFactor;
-       u8 RxBulkFactor;
-
-       BOOLEAN IsUpdateBeacon;
-       struct rt_beacon_sync *pBeaconSync;
-       struct rt_ralink_timer BeaconUpdateTimer;
-       u32 BeaconAdjust;
-       u32 BeaconFactor;
-       u32 BeaconRemain;
-#endif                         /* RTMP_MAC_USB // */
-
-       spinlock_t MeasureReqTabLock;
-       struct rt_measure_req_tab *pMeasureReqTab;
-
-       spinlock_t TpcReqTabLock;
-       struct rt_tpc_req_tab *pTpcReqTab;
-
-       BOOLEAN PSPXlink;       /* 0: Disable. 1: Enable */
-
-#if defined(RT305x) || defined(RT30xx)
-       /* request by Gary, for High Power issue */
-       u8 HighPowerPatchDisabled;
-#endif
-
-       BOOLEAN HT_DisallowTKIP;        /* Restrict the encryption type in 11n HT mode */
-};
-
-/* Modified by Wu Xi-Kun 4/21/2006 */
-/* STA configuration and status */
-struct rt_sta_admin_config {
-       /* GROUP 1 - */
-       /*   User configuration loaded from Registry, E2PROM or OID_xxx. These settings describe */
-       /*   the user intended configuration, but not necessary fully equal to the final */
-       /*   settings in ACTIVE BSS after negotiation/compromise with the BSS holder (either */
-       /*   AP or IBSS holder). */
-       /*   Once initialized, user configuration can only be changed via OID_xxx */
-       u8 BssType;             /* BSS_INFRA or BSS_ADHOC */
-       u16 AtimWin;            /* used when starting a new IBSS */
-
-       /* GROUP 2 - */
-       /*   User configuration loaded from Registry, E2PROM or OID_xxx. These settings describe */
-       /*   the user intended configuration, and should be always applied to the final */
-       /*   settings in ACTIVE BSS without compromising with the BSS holder. */
-       /*   Once initialized, user configuration can only be changed via OID_xxx */
-       u8 RssiTrigger;
-       u8 RssiTriggerMode;     /* RSSI_TRIGGERED_UPON_BELOW_THRESHOLD or RSSI_TRIGGERED_UPON_EXCCEED_THRESHOLD */
-       u16 DefaultListenCount; /* default listen count; */
-       unsigned long WindowsPowerMode; /* Power mode for AC power */
-       unsigned long WindowsBatteryPowerMode;  /* Power mode for battery if exists */
-       BOOLEAN bWindowsACCAMEnable;    /* Enable CAM power mode when AC on */
-       BOOLEAN bAutoReconnect; /* Set to TRUE when setting OID_802_11_SSID with no matching BSSID */
-       unsigned long WindowsPowerProfile;      /* Windows power profile, for NDIS5.1 PnP */
-
-       /* MIB:ieee802dot11.dot11smt(1).dot11StationConfigTable(1) */
-       u16 Psm;                /* power management mode   (PWR_ACTIVE|PWR_SAVE) */
-       u16 DisassocReason;
-       u8 DisassocSta[MAC_ADDR_LEN];
-       u16 DeauthReason;
-       u8 DeauthSta[MAC_ADDR_LEN];
-       u16 AuthFailReason;
-       u8 AuthFailSta[MAC_ADDR_LEN];
-
-       NDIS_802_11_PRIVACY_FILTER PrivacyFilter;       /* PrivacyFilter enum for 802.1X */
-       NDIS_802_11_AUTHENTICATION_MODE AuthMode;       /* This should match to whatever microsoft defined */
-       NDIS_802_11_WEP_STATUS WepStatus;
-       NDIS_802_11_WEP_STATUS OrigWepStatus;   /* Original wep status set from OID */
-
-       /* Add to support different cipher suite for WPA2/WPA mode */
-       NDIS_802_11_ENCRYPTION_STATUS GroupCipher;      /* Multicast cipher suite */
-       NDIS_802_11_ENCRYPTION_STATUS PairCipher;       /* Unicast cipher suite */
-       BOOLEAN bMixCipher;     /* Indicate current Pair & Group use different cipher suites */
-       u16 RsnCapability;
-
-       NDIS_802_11_WEP_STATUS GroupKeyWepStatus;
-
-       u8 WpaPassPhrase[64];   /* WPA PSK pass phrase */
-       u32 WpaPassPhraseLen;   /* the length of WPA PSK pass phrase */
-       u8 PMK[32];             /* WPA PSK mode PMK */
-       u8 PTK[64];             /* WPA PSK mode PTK */
-       u8 GTK[32];             /* GTK from authenticator */
-       struct rt_bssid_info SavedPMK[PMKID_NO];
-       u32 SavedPMKNum;        /* Saved PMKID number */
-
-       u8 DefaultKeyId;
-
-       /* WPA 802.1x port control, WPA_802_1X_PORT_SECURED, WPA_802_1X_PORT_NOT_SECURED */
-       u8 PortSecured;
-
-       /* For WPA countermeasures */
-       unsigned long LastMicErrorTime; /* record last MIC error time */
-       unsigned long MicErrCnt;        /* Should be 0, 1, 2, then reset to zero (after disassociation). */
-       BOOLEAN bBlockAssoc;    /* Block associate attempt for 60 seconds after counter measure occurred. */
-       /* For WPA-PSK supplicant state */
-       WPA_STATE WpaState;     /* Default is SS_NOTUSE and handled by microsoft 802.1x */
-       u8 ReplayCounter[8];
-       u8 ANonce[32];  /* ANonce for WPA-PSK from auhenticator */
-       u8 SNonce[32];  /* SNonce for WPA-PSK */
-
-       u8 LastSNR0;            /* last received BEACON's SNR */
-       u8 LastSNR1;            /* last received BEACON's SNR for 2nd  antenna */
-       struct rt_rssi_sample RssiSample;
-       unsigned long NumOfAvgRssiSample;
-
-       unsigned long LastBeaconRxTime; /* OS's timestamp of the last BEACON RX time */
-       unsigned long Last11bBeaconRxTime;      /* OS's timestamp of the last 11B BEACON RX time */
-       unsigned long Last11gBeaconRxTime;      /* OS's timestamp of the last 11G BEACON RX time */
-       unsigned long Last20NBeaconRxTime;      /* OS's timestamp of the last 20MHz N BEACON RX time */
-
-       unsigned long LastScanTime;     /* Record last scan time for issue BSSID_SCAN_LIST */
-       unsigned long ScanCnt;          /* Scan counts since most recent SSID, BSSID, SCAN OID request */
-       BOOLEAN bSwRadio;       /* Software controlled Radio On/Off, TRUE: On */
-       BOOLEAN bHwRadio;       /* Hardware controlled Radio On/Off, TRUE: On */
-       BOOLEAN bRadio;         /* Radio state, And of Sw & Hw radio state */
-       BOOLEAN bHardwareRadio; /* Hardware controlled Radio enabled */
-       BOOLEAN bShowHiddenSSID;        /* Show all known SSID in SSID list get operation */
-
-       /* New for WPA, windows want us to keep association information and */
-       /* Fixed IEs from last association response */
-       struct rt_ndis_802_11_association_information AssocInfo;
-       u16 ReqVarIELen;        /* Length of next VIE include EID & Length */
-       u8 ReqVarIEs[MAX_VIE_LEN];      /* The content saved here should be little-endian format. */
-       u16 ResVarIELen;        /* Length of next VIE include EID & Length */
-       u8 ResVarIEs[MAX_VIE_LEN];
-
-       u8 RSNIE_Len;
-       u8 RSN_IE[MAX_LEN_OF_RSNIE];    /* The content saved here should be little-endian format. */
-
-       unsigned long CLBusyBytes;      /* Save the total bytes received during channel load scan time */
-       u16 RPIDensity[8];      /* Array for RPI density collection */
-
-       u8 RMReqCnt;            /* Number of measurement request saved. */
-       u8 CurrentRMReqIdx;     /* Number of measurement request saved. */
-       BOOLEAN ParallelReq;    /* Parallel measurement, only one request performed, */
-       /* It must be the same channel with maximum duration */
-       u16 ParallelDuration;   /* Maximum duration for parallel measurement */
-       u8 ParallelChannel;     /* Only one channel with parallel measurement */
-       u16 IAPPToken;  /* IAPP dialog token */
-       /* Hack for channel load and noise histogram parameters */
-       u8 NHFactor;            /* Parameter for Noise histogram */
-       u8 CLFactor;            /* Parameter for channel load */
-
-       struct rt_ralink_timer StaQuickResponeForRateUpTimer;
-       BOOLEAN StaQuickResponeForRateUpTimerRunning;
-
-       u8 DtimCount;   /* 0.. DtimPeriod-1 */
-       u8 DtimPeriod;  /* default = 3 */
-
-       /*////////////////////////////////////////////////////////////////////////////////////// */
-       /* This is only for WHQL test. */
-       BOOLEAN WhqlTest;
-       /*////////////////////////////////////////////////////////////////////////////////////// */
-
-       struct rt_ralink_timer WpaDisassocAndBlockAssocTimer;
-       /* Fast Roaming */
-       BOOLEAN bAutoRoaming;   /* 0:disable auto roaming by RSSI, 1:enable auto roaming by RSSI */
-       char dBmToRoam;         /* the condition to roam when receiving Rssi less than this value. It's negative value. */
-
-       BOOLEAN IEEE8021X;
-       BOOLEAN IEEE8021x_required_keys;
-       struct rt_cipher_key DesireSharedKey[4];        /* Record user desired WEP keys */
-       u8 DesireSharedKeyId;
-
-       /* 0: driver ignores wpa_supplicant */
-       /* 1: wpa_supplicant initiates scanning and AP selection */
-       /* 2: driver takes care of scanning, AP selection, and IEEE 802.11 association parameters */
-       u8 WpaSupplicantUP;
-       u8 WpaSupplicantScanCount;
-       BOOLEAN bRSN_IE_FromWpaSupplicant;
-
-       char dev_name[16];
-       u16 OriDevType;
-
-       BOOLEAN bTGnWifiTest;
-       BOOLEAN bScanReqIsFromWebUI;
-
-       HTTRANSMIT_SETTING HTPhyMode, MaxHTPhyMode, MinHTPhyMode;       /* For transmit phy setting in TXWI. */
-       DESIRED_TRANSMIT_SETTING DesiredTransmitSetting;
-       struct rt_ht_phy_info DesiredHtPhyInfo;
-       BOOLEAN bAutoTxRateSwitch;
-
-#ifdef RTMP_MAC_PCI
-       u8 BBPR3;
-       /* PS Control has 2 meanings for advanced power save function. */
-       /* 1. EnablePSinIdle : When no connection, always radio off except need to do site survey. */
-       /* 2. EnableNewPS  : will save more current in sleep or radio off mode. */
-       PS_CONTROL PSControl;
-#endif                         /* RTMP_MAC_PCI // */
-
-       BOOLEAN bAutoConnectByBssid;
-       unsigned long BeaconLostTime;   /* seconds */
-       BOOLEAN bForceTxBurst;  /* 1: force enble TX PACKET BURST, 0: disable */
-};
-
-/* This data structure keeps the current active BSS/IBSS's configuration that this STA */
-/* had agreed upon joining the network. Which means these parameters are usually decided */
-/* by the BSS/IBSS creator instead of user configuration. Data in this data structure */
-/* is valid only when either ADHOC_ON(pAd) or INFRA_ON(pAd) is TRUE. */
-/* Normally, after SCAN or failed roaming attempts, we need to recover back to */
-/* the current active settings. */
-struct rt_sta_active_config {
-       u16 Aid;
-       u16 AtimWin;            /* in kusec; IBSS parameter set element */
-       u16 CapabilityInfo;
-       u16 CfpMaxDuration;
-       u16 CfpPeriod;
-
-       /* Copy supported rate from desired AP's beacon. We are trying to match */
-       /* AP's supported and extended rate settings. */
-       u8 SupRate[MAX_LEN_OF_SUPPORTED_RATES];
-       u8 ExtRate[MAX_LEN_OF_SUPPORTED_RATES];
-       u8 SupRateLen;
-       u8 ExtRateLen;
-       /* Copy supported ht from desired AP's beacon. We are trying to match */
-       struct rt_ht_phy_info SupportedPhyInfo;
-       struct rt_ht_capability SupportedHtPhy;
-};
-
-struct rt_mac_table_entry;
-
-struct rt_mac_table_entry {
-       /*Choose 1 from ValidAsWDS and ValidAsCLI  to validize. */
-       BOOLEAN ValidAsCLI;     /* Sta mode, set this TRUE after Linkup,too. */
-       BOOLEAN ValidAsWDS;     /* This is WDS Entry. only for AP mode. */
-       BOOLEAN ValidAsApCli;   /* This is a AP-Client entry, only for AP mode which enable AP-Client functions. */
-       BOOLEAN ValidAsMesh;
-       BOOLEAN ValidAsDls;     /* This is DLS Entry. only for STA mode. */
-       BOOLEAN isCached;
-       BOOLEAN bIAmBadAtheros; /* Flag if this is Atheros chip that has IOT problem.  We need to turn on RTS/CTS protection. */
-
-       u8 EnqueueEapolStartTimerRunning;       /* Enqueue EAPoL-Start for triggering EAP SM */
-       /*jan for wpa */
-       /* record which entry revoke MIC Failure, if it leaves the BSS itself, AP won't update aMICFailTime MIB */
-       u8 CMTimerRunning;
-       u8 apidx;               /* MBSS number */
-       u8 RSNIE_Len;
-       u8 RSN_IE[MAX_LEN_OF_RSNIE];
-       u8 ANonce[LEN_KEY_DESC_NONCE];
-       u8 SNonce[LEN_KEY_DESC_NONCE];
-       u8 R_Counter[LEN_KEY_DESC_REPLAY];
-       u8 PTK[64];
-       u8 ReTryCounter;
-       struct rt_ralink_timer RetryTimer;
-       struct rt_ralink_timer EnqueueStartForPSKTimer; /* A timer which enqueue EAPoL-Start for triggering PSK SM */
-       NDIS_802_11_AUTHENTICATION_MODE AuthMode;       /* This should match to whatever microsoft defined */
-       NDIS_802_11_WEP_STATUS WepStatus;
-       NDIS_802_11_WEP_STATUS GroupKeyWepStatus;
-       AP_WPA_STATE WpaState;
-       GTK_STATE GTKState;
-       u16 PortSecured;
-       NDIS_802_11_PRIVACY_FILTER PrivacyFilter;       /* PrivacyFilter enum for 802.1X */
-       struct rt_cipher_key PairwiseKey;
-       void *pAd;
-       int PMKID_CacheIdx;
-       u8 PMKID[LEN_PMKID];
-
-       u8 Addr[MAC_ADDR_LEN];
-       u8 PsMode;
-       SST Sst;
-       AUTH_STATE AuthState;   /* for SHARED KEY authentication state machine used only */
-       BOOLEAN IsReassocSta;   /* Indicate whether this is a reassociation procedure */
-       u16 Aid;
-       u16 CapabilityInfo;
-       u8 LastRssi;
-       unsigned long NoDataIdleCount;
-       u16 StationKeepAliveCount;      /* unit: second */
-       unsigned long PsQIdleCount;
-       struct rt_queue_header PsQueue;
-
-       u32 StaConnectTime;     /* the live time of this station since associated with AP */
-
-       BOOLEAN bSendBAR;
-       u16 NoBADataCountDown;
-
-       u32 CachedBuf[16];      /* u32 (4 bytes) for alignment */
-       u32 TxBFCount;          /* 3*3 */
-       u32 FIFOCount;
-       u32 DebugFIFOCount;
-       u32 DebugTxCount;
-       BOOLEAN bDlsInit;
-
-/*==================================================== */
-/*WDS entry needs these */
-/* if ValidAsWDS==TRUE, MatchWDSTabIdx is the index in WdsTab.MacTab */
-       u32 MatchWDSTabIdx;
-       u8 MaxSupportedRate;
-       u8 CurrTxRate;
-       u8 CurrTxRateIndex;
-       /* to record the each TX rate's quality. 0 is best, the bigger the worse. */
-       u16 TxQuality[MAX_STEP_OF_TX_RATE_SWITCH];
-/*      u16          OneSecTxOkCount; */
-       u32 OneSecTxNoRetryOkCount;
-       u32 OneSecTxRetryOkCount;
-       u32 OneSecTxFailCount;
-       u32 ContinueTxFailCnt;
-       u32 CurrTxRateStableTime;       /* # of second in current TX rate */
-       u8 TxRateUpPenalty;     /* extra # of second penalty due to last unstable condition */
-/*==================================================== */
-
-       BOOLEAN fNoisyEnvironment;
-       BOOLEAN fLastSecAccordingRSSI;
-       u8 LastSecTxRateChangeAction;   /* 0: no change, 1:rate UP, 2:rate down */
-       char LastTimeTxRateChangeAction;        /*Keep last time value of LastSecTxRateChangeAction */
-       unsigned long LastTxOkCount;
-       u8 PER[MAX_STEP_OF_TX_RATE_SWITCH];
-
-       /* a bitmap of BOOLEAN flags. each bit represent an operation status of a particular */
-       /* BOOLEAN control, either ON or OFF. These flags should always be accessed via */
-       /* CLIENT_STATUS_TEST_FLAG(), CLIENT_STATUS_SET_FLAG(), CLIENT_STATUS_CLEAR_FLAG() macros. */
-       /* see fOP_STATUS_xxx in RTMP_DEF.C for detail bit definition. fCLIENT_STATUS_AMSDU_INUSED */
-       unsigned long ClientStatusFlags;
-
-       HTTRANSMIT_SETTING HTPhyMode, MaxHTPhyMode, MinHTPhyMode;       /* For transmit phy setting in TXWI. */
-
-       /* HT EWC MIMO-N used parameters */
-       u16 RXBAbitmap; /* fill to on-chip  RXWI_BA_BITMASK in 8.1.3RX attribute entry format */
-       u16 TXBAbitmap; /* This bitmap as originator, only keep in software used to mark AMPDU bit in TXWI */
-       u16 TXAutoBAbitmap;
-       u16 BADeclineBitmap;
-       u16 BARecWcidArray[NUM_OF_TID]; /* The mapping wcid of recipient session. if RXBAbitmap bit is masked */
-       u16 BAOriWcidArray[NUM_OF_TID]; /* The mapping wcid of originator session. if TXBAbitmap bit is masked */
-       u16 BAOriSequence[NUM_OF_TID];  /* The mapping wcid of originator session. if TXBAbitmap bit is masked */
-
-       /* 802.11n features. */
-       u8 MpduDensity;
-       u8 MaxRAmpduFactor;
-       u8 AMsduSize;
-       u8 MmpsMode;            /* MIMO power save more. */
-
-       struct rt_ht_capability_ie HTCapability;
-
-       BOOLEAN bAutoTxRateSwitch;
-
-       u8 RateLen;
-       struct rt_mac_table_entry *pNext;
-       u16 TxSeq[NUM_OF_TID];
-       u16 NonQosDataSeq;
-
-       struct rt_rssi_sample RssiSample;
-
-       u32 TXMCSExpected[16];
-       u32 TXMCSSuccessful[16];
-       u32 TXMCSFailed[16];
-       u32 TXMCSAutoFallBack[16][16];
-
-       unsigned long LastBeaconRxTime;
-
-       unsigned long AssocDeadLine;
-};
-
-struct rt_mac_table {
-       u16 Size;
-       struct rt_mac_table_entry *Hash[HASH_TABLE_SIZE];
-       struct rt_mac_table_entry Content[MAX_LEN_OF_MAC_TABLE];
-       struct rt_queue_header McastPsQueue;
-       unsigned long PsQIdleCount;
-       BOOLEAN fAnyStationInPsm;
-       BOOLEAN fAnyStationBadAtheros;  /* Check if any Station is atheros 802.11n Chip.  We need to use RTS/CTS with Atheros 802,.11n chip. */
-       BOOLEAN fAnyTxOPForceDisable;   /* Check if it is necessary to disable BE TxOP */
-       BOOLEAN fAllStationAsRalink;    /* Check if all stations are ralink-chipset */
-       BOOLEAN fAnyStationIsLegacy;    /* Check if I use legacy rate to transmit to my BSS Station/ */
-       BOOLEAN fAnyStationNonGF;       /* Check if any Station can't support GF. */
-       BOOLEAN fAnyStation20Only;      /* Check if any Station can't support GF. */
-       BOOLEAN fAnyStationMIMOPSDynamic;       /* Check if any Station is MIMO Dynamic */
-       BOOLEAN fAnyBASession;  /* Check if there is BA session.  Force turn on RTS/CTS */
-/*2008/10/28: KH add to support Antenna power-saving of AP<-- */
-/*2008/10/28: KH add to support Antenna power-saving of AP--> */
-};
-
-struct wificonf {
-       BOOLEAN bShortGI;
-       BOOLEAN bGreenField;
-};
-
-struct rt_rtmp_dev_info {
-       u8 chipName[16];
-       RTMP_INF_TYPE infType;
-};
-
-struct rt_rtmp_chip_op {
-       /*  Calibration access related callback functions */
-       int (*eeinit) (struct rt_rtmp_adapter *pAd);    /* int (*eeinit)(struct rt_rtmp_adapter *pAd); */
-       int (*eeread) (struct rt_rtmp_adapter *pAd, u16 offset, u16 *pValue);   /* int (*eeread)(struct rt_rtmp_adapter *pAd, int offset, u16 *pValue); */
-
-       /* MCU related callback functions */
-       int (*loadFirmware) (struct rt_rtmp_adapter *pAd);      /* int (*loadFirmware)(struct rt_rtmp_adapter *pAd); */
-       int (*eraseFirmware) (struct rt_rtmp_adapter *pAd);     /* int (*eraseFirmware)(struct rt_rtmp_adapter *pAd); */
-       int (*sendCommandToMcu) (struct rt_rtmp_adapter *pAd, u8 cmd, u8 token, u8 arg0, u8 arg1);;     /* int (*sendCommandToMcu)(struct rt_rtmp_adapter *pAd, u8 cmd, u8 token, u8 arg0, u8 arg1); */
-
-       /* RF access related callback functions */
-       struct rt_reg_pair *pRFRegTable;
-       void (*AsicRfInit) (struct rt_rtmp_adapter *pAd);
-       void (*AsicRfTurnOn) (struct rt_rtmp_adapter *pAd);
-       void (*AsicRfTurnOff) (struct rt_rtmp_adapter *pAd);
-       void (*AsicReverseRfFromSleepMode) (struct rt_rtmp_adapter *pAd);
-       void (*AsicHaltAction) (struct rt_rtmp_adapter *pAd);
-};
-
-/* */
-/*  The miniport adapter structure */
-/* */
-struct rt_rtmp_adapter {
-       void *OS_Cookie;        /* save specific structure relative to OS */
-       struct net_device *net_dev;
-       unsigned long VirtualIfCnt;
-       const struct firmware *firmware;
-
-       struct rt_rtmp_chip_op chipOps;
-       u16 ThisTbttNumToNextWakeUp;
-
-#ifdef RTMP_MAC_PCI
-/*****************************************************************************************/
-/*      PCI related parameters                                                                                                                           */
-/*****************************************************************************************/
-       u8 *CSRBaseAddress;     /* PCI MMIO Base Address, all access will use */
-       unsigned int irq_num;
-
-       u16 LnkCtrlBitMask;
-       u16 RLnkCtrlConfiguration;
-       u16 RLnkCtrlOffset;
-       u16 HostLnkCtrlConfiguration;
-       u16 HostLnkCtrlOffset;
-       u16 PCIePowerSaveLevel;
-       unsigned long Rt3xxHostLinkCtrl;        /* USed for 3090F chip */
-       unsigned long Rt3xxRalinkLinkCtrl;      /* USed for 3090F chip */
-       u16 DeviceID;   /* Read from PCI config */
-       unsigned long AccessBBPFailCount;
-       BOOLEAN bPCIclkOff;     /* flag that indicates if the PICE power status in Configuration Space.. */
-       BOOLEAN bPCIclkOffDisableTx;    /* */
-
-       BOOLEAN brt30xxBanMcuCmd;       /*when = 0xff means all commands are ok to set . */
-       BOOLEAN b3090ESpecialChip;      /*3090E special chip that write EEPROM 0x24=0x9280. */
-       unsigned long CheckDmaBusyCount;        /* Check Interrupt Status Register Count. */
-
-       u32 int_enable_reg;
-       u32 int_disable_mask;
-       u32 int_pending;
-
-       struct rt_rtmp_dmabuf TxBufSpace[NUM_OF_TX_RING];       /* Shared memory of all 1st pre-allocated TxBuf associated with each TXD */
-       struct rt_rtmp_dmabuf RxDescRing;       /* Shared memory for RX descriptors */
-       struct rt_rtmp_dmabuf TxDescRing[NUM_OF_TX_RING];       /* Shared memory for Tx descriptors */
-       struct rt_rtmp_tx_ring TxRing[NUM_OF_TX_RING];  /* AC0~4 + HCCA */
-#endif                         /* RTMP_MAC_PCI // */
-
-       spinlock_t irq_lock;
-       u8 irq_disabled;
-
-#ifdef RTMP_MAC_USB
-/*****************************************************************************************/
-/*      USB related parameters                                                           */
-/*****************************************************************************************/
-       struct usb_config_descriptor *config;
-       u32 BulkInEpAddr;       /* bulk-in endpoint address */
-       u32 BulkOutEpAddr[6];   /* bulk-out endpoint address */
-
-       u32 NumberOfPipes;
-       u16 BulkOutMaxPacketSize;
-       u16 BulkInMaxPacketSize;
-
-       /*======Control Flags */
-       long PendingIoCount;
-       unsigned long BulkFlags;
-       BOOLEAN bUsbTxBulkAggre;        /* Flags for bulk out data priority */
-
-       /*======Cmd Thread */
-       struct rt_cmdq CmdQ;
-       spinlock_t CmdQLock;    /* CmdQLock spinlock */
-       struct rt_rtmp_os_task cmdQTask;
-
-       /*======Semaphores (event) */
-       struct semaphore UsbVendorReq_semaphore;
-       void *UsbVendorReqBuf;
-       wait_queue_head_t *wait;
-#endif                         /* RTMP_MAC_USB // */
-
-/*****************************************************************************************/
-/*      RBUS related parameters                                                                                                                                  */
-/*****************************************************************************************/
-
-/*****************************************************************************************/
-/*      Both PCI/USB related parameters                                                                                                                  */
-/*****************************************************************************************/
-       /*struct rt_rtmp_dev_info                 chipInfo; */
-       RTMP_INF_TYPE infType;
-
-/*****************************************************************************************/
-/*      Driver Mgmt related parameters                                                                                                           */
-/*****************************************************************************************/
-       struct rt_rtmp_os_task mlmeTask;
-#ifdef RTMP_TIMER_TASK_SUPPORT
-       /* If you want use timer task to handle the timer related jobs, enable this. */
-       struct rt_rtmp_timer_task_queue TimerQ;
-       spinlock_t TimerQLock;
-       struct rt_rtmp_os_task timerTask;
-#endif                         /* RTMP_TIMER_TASK_SUPPORT // */
-
-/*****************************************************************************************/
-/*      Tx related parameters                                                           */
-/*****************************************************************************************/
-       BOOLEAN DeQueueRunning[NUM_OF_TX_RING]; /* for ensuring RTUSBDeQueuePacket get call once */
-       spinlock_t DeQueueLock[NUM_OF_TX_RING];
-
-#ifdef RTMP_MAC_USB
-       /* Data related context and AC specified, 4 AC supported */
-       spinlock_t BulkOutLock[6];      /* BulkOut spinlock for 4 ACs */
-       spinlock_t MLMEBulkOutLock;     /* MLME BulkOut lock */
-
-       struct rt_ht_tx_context TxContext[NUM_OF_TX_RING];
-       spinlock_t TxContextQueueLock[NUM_OF_TX_RING];  /* TxContextQueue spinlock */
-
-       /* 4 sets of Bulk Out index and pending flag */
-       u8 NextBulkOutIndex[4]; /* only used for 4 EDCA bulkout pipe */
-
-       BOOLEAN BulkOutPending[6];      /* used for total 6 bulkout pipe */
-       u8 bulkResetPipeid;
-       BOOLEAN MgmtBulkPending;
-       unsigned long bulkResetReq[6];
-#endif                         /* RTMP_MAC_USB // */
-
-       /* resource for software backlog queues */
-       struct rt_queue_header TxSwQueue[NUM_OF_TX_RING];       /* 4 AC + 1 HCCA */
-       spinlock_t TxSwQueueLock[NUM_OF_TX_RING];       /* TxSwQueue spinlock */
-
-       struct rt_rtmp_dmabuf MgmtDescRing;     /* Shared memory for MGMT descriptors */
-       struct rt_rtmp_mgmt_ring MgmtRing;
-       spinlock_t MgmtRingLock;        /* Prio Ring spinlock */
-
-/*****************************************************************************************/
-/*      Rx related parameters                                                           */
-/*****************************************************************************************/
-
-#ifdef RTMP_MAC_PCI
-       struct rt_rtmp_rx_ring RxRing;
-       spinlock_t RxRingLock;  /* Rx Ring spinlock */
-#ifdef RT3090
-       spinlock_t McuCmdLock;  /*MCU Command Queue spinlock */
-#endif                         /* RT3090 // */
-#endif                         /* RTMP_MAC_PCI // */
-#ifdef RTMP_MAC_USB
-       struct rt_rx_context RxContext[RX_RING_SIZE];   /* 1 for redundant multiple IRP bulk in. */
-       spinlock_t BulkInLock;  /* BulkIn spinlock for 4 ACs */
-       u8 PendingRx;   /* The Maximum pending Rx value should be       RX_RING_SIZE. */
-       u8 NextRxBulkInIndex;   /* Indicate the current RxContext Index which hold by Host controller. */
-       u8 NextRxBulkInReadIndex;       /* Indicate the current RxContext Index which driver can read & process it. */
-       unsigned long NextRxBulkInPosition;     /* Want to contatenate 2 URB buffer while 1st is bulkin failed URB. This Position is 1st URB TransferLength. */
-       unsigned long TransferBufferLength;     /* current length of the packet buffer */
-       unsigned long ReadPosition;     /* current read position in a packet buffer */
-#endif                         /* RTMP_MAC_USB // */
-
-/*****************************************************************************************/
-/*      ASIC related parameters                                                          */
-/*****************************************************************************************/
-       u32 MACVersion; /* MAC version. Record rt2860C(0x28600100) or rt2860D (0x28600101).. */
-
-       /* --------------------------- */
-       /* E2PROM */
-       /* --------------------------- */
-       unsigned long EepromVersion;    /* byte 0: version, byte 1: revision, byte 2~3: unused */
-       unsigned long FirmwareVersion;  /* byte 0: Minor version, byte 1: Major version, otherwise unused. */
-       u16 EEPROMDefaultValue[NUM_EEPROM_BBP_PARMS];
-       u8 EEPROMAddressNum;    /* 93c46=6  93c66=8 */
-       BOOLEAN EepromAccess;
-       u8 EFuseTag;
-
-       /* --------------------------- */
-       /* BBP Control */
-       /* --------------------------- */
-       u8 BbpWriteLatch[140];  /* record last BBP register value written via BBP_IO_WRITE/BBP_IO_WRITE_VY_REG_ID */
-       char BbpRssiToDbmDelta; /* change from u8 to char for high power */
-       struct rt_bbp_r66_tuning BbpTuning;
-
-       /* ---------------------------- */
-       /* RFIC control */
-       /* ---------------------------- */
-       u8 RfIcType;            /* RFIC_xxx */
-       unsigned long RfFreqOffset;     /* Frequency offset for channel switching */
-       struct rt_rtmp_rf_regs LatchRfRegs;     /* latch the latest RF programming value since RF IC doesn't support READ */
-
-       EEPROM_ANTENNA_STRUC Antenna;   /* Since Antenna definition is different for a & g. We need to save it for future reference. */
-       EEPROM_NIC_CONFIG2_STRUC NicConfig2;
-
-       /* This soft Rx Antenna Diversity mechanism is used only when user set */
-       /* RX Antenna = DIVERSITY ON */
-       struct rt_soft_rx_ant_diversity RxAnt;
-
-       u8 RFProgSeq;
-       struct rt_channel_tx_power TxPower[MAX_NUM_OF_CHANNELS];        /* Store Tx power value for all channels. */
-       struct rt_channel_tx_power ChannelList[MAX_NUM_OF_CHANNELS];    /* list all supported channels for site survey */
-       struct rt_channel_11j_tx_power TxPower11J[MAX_NUM_OF_11JCHANNELS];      /* 802.11j channel and bw */
-       struct rt_channel_11j_tx_power ChannelList11J[MAX_NUM_OF_11JCHANNELS];  /* list all supported channels for site survey */
-
-       u8 ChannelListNum;      /* number of channel in ChannelList[] */
-       u8 Bbp94;
-       BOOLEAN BbpForCCK;
-       unsigned long Tx20MPwrCfgABand[5];
-       unsigned long Tx20MPwrCfgGBand[5];
-       unsigned long Tx40MPwrCfgABand[5];
-       unsigned long Tx40MPwrCfgGBand[5];
-
-       BOOLEAN bAutoTxAgcA;    /* Enable driver auto Tx Agc control */
-       u8 TssiRefA;            /* Store Tssi reference value as 25 temperature. */
-       u8 TssiPlusBoundaryA[5];        /* Tssi boundary for increase Tx power to compensate. */
-       u8 TssiMinusBoundaryA[5];       /* Tssi boundary for decrease Tx power to compensate. */
-       u8 TxAgcStepA;  /* Store Tx TSSI delta increment / decrement value */
-       char TxAgcCompensateA;  /* Store the compensation (TxAgcStep * (idx-1)) */
-
-       BOOLEAN bAutoTxAgcG;    /* Enable driver auto Tx Agc control */
-       u8 TssiRefG;            /* Store Tssi reference value as 25 temperature. */
-       u8 TssiPlusBoundaryG[5];        /* Tssi boundary for increase Tx power to compensate. */
-       u8 TssiMinusBoundaryG[5];       /* Tssi boundary for decrease Tx power to compensate. */
-       u8 TxAgcStepG;  /* Store Tx TSSI delta increment / decrement value */
-       char TxAgcCompensateG;  /* Store the compensation (TxAgcStep * (idx-1)) */
-
-       char BGRssiOffset0;     /* Store B/G RSSI#0 Offset value on EEPROM 0x46h */
-       char BGRssiOffset1;     /* Store B/G RSSI#1 Offset value */
-       char BGRssiOffset2;     /* Store B/G RSSI#2 Offset value */
-
-       char ARssiOffset0;      /* Store A RSSI#0 Offset value on EEPROM 0x4Ah */
-       char ARssiOffset1;      /* Store A RSSI#1 Offset value */
-       char ARssiOffset2;      /* Store A RSSI#2 Offset value */
-
-       char BLNAGain;          /* Store B/G external LNA#0 value on EEPROM 0x44h */
-       char ALNAGain0;         /* Store A external LNA#0 value for ch36~64 */
-       char ALNAGain1;         /* Store A external LNA#1 value for ch100~128 */
-       char ALNAGain2;         /* Store A external LNA#2 value for ch132~165 */
-#ifdef RT30xx
-       /* for 3572 */
-       u8 Bbp25;
-       u8 Bbp26;
-
-       u8 TxMixerGain24G;      /* Tx mixer gain value from EEPROM to improve Tx EVM / Tx DAC, 2.4G */
-       u8 TxMixerGain5G;
-#endif                         /* RT30xx // */
-       /* ---------------------------- */
-       /* LED control */
-       /* ---------------------------- */
-       MCU_LEDCS_STRUC LedCntl;
-       u16 Led1;               /* read from EEPROM 0x3c */
-       u16 Led2;               /* EEPROM 0x3e */
-       u16 Led3;               /* EEPROM 0x40 */
-       u8 LedIndicatorStrength;
-       u8 RssiSingalstrengthOffet;
-       BOOLEAN bLedOnScanning;
-       u8 LedStatus;
-
-/*****************************************************************************************/
-/*      802.11 related parameters                                                        */
-/*****************************************************************************************/
-       /* outgoing BEACON frame buffer and corresponding TXD */
-       struct rt_txwi BeaconTxWI;
-       u8 *BeaconBuf;
-       u16 BeaconOffset[HW_BEACON_MAX_COUNT];
-
-       /* pre-build PS-POLL and NULL frame upon link up. for efficiency purpose. */
-       struct rt_pspoll_frame PsPollFrame;
-       struct rt_header_802_11 NullFrame;
-
-#ifdef RTMP_MAC_USB
-       struct rt_tx_context BeaconContext[BEACON_RING_SIZE];
-       struct rt_tx_context NullContext;
-       struct rt_tx_context PsPollContext;
-       struct rt_tx_context RTSContext;
-#endif                         /* RTMP_MAC_USB // */
-
-/*=========AP=========== */
-
-/*=======STA=========== */
-       /* ----------------------------------------------- */
-       /* STA specific configuration & operation status */
-       /* used only when pAd->OpMode == OPMODE_STA */
-       /* ----------------------------------------------- */
-       struct rt_sta_admin_config StaCfg;      /* user desired settings */
-       struct rt_sta_active_config StaActive;  /* valid only when ADHOC_ON(pAd) || INFRA_ON(pAd) */
-       char nickname[IW_ESSID_MAX_SIZE + 1];   /* nickname, only used in the iwconfig i/f */
-       int PreMediaState;
-
-/*=======Common=========== */
-       /* OP mode: either AP or STA */
-       u8 OpMode;              /* OPMODE_STA, OPMODE_AP */
-
-       int IndicateMediaState; /* Base on Indication state, default is NdisMediaStateDisConnected */
-
-       /* MAT related parameters */
-
-       /* configuration: read from Registry & E2PROM */
-       BOOLEAN bLocalAdminMAC; /* Use user changed MAC */
-       u8 PermanentAddress[MAC_ADDR_LEN];      /* Factory default MAC address */
-       u8 CurrentAddress[MAC_ADDR_LEN];        /* User changed MAC address */
-
-       /* ------------------------------------------------------ */
-       /* common configuration to both OPMODE_STA and OPMODE_AP */
-       /* ------------------------------------------------------ */
-       struct rt_common_config CommonCfg;
-       struct rt_mlme Mlme;
-
-       /* AP needs those variables for site survey feature. */
-       struct rt_mlme_aux MlmeAux;     /* temporary settings used during MLME state machine */
-       struct rt_bss_table ScanTab;    /* store the latest SCAN result */
-
-       /*About MacTab, the sta driver will use #0 and #1 for multicast and AP. */
-       struct rt_mac_table MacTab;     /* ASIC on-chip WCID entry table.  At TX, ASIC always use key according to this on-chip table. */
-       spinlock_t MacTabLock;
-
-       struct rt_ba_table BATable;
-
-       spinlock_t BATabLock;
-       struct rt_ralink_timer RECBATimer;
-
-       /* encryption/decryption KEY tables */
-       struct rt_cipher_key SharedKey[MAX_MBSSID_NUM][4];      /* STA always use SharedKey[BSS0][0..3] */
-
-       /* RX re-assembly buffer for fragmentation */
-       struct rt_fragment_frame FragFrame;     /* Frame storage for fragment frame */
-
-       /* various Counters */
-       struct rt_counter_802_3 Counters8023;   /* 802.3 counters */
-       struct rt_counter_802_11 WlanCounters;  /* 802.11 MIB counters */
-       struct rt_counter_ralink RalinkCounters;        /* Ralink proprietary counters */
-       struct rt_counter_drs DrsCounters;      /* counters for Dynamic TX Rate Switching */
-       struct rt_private PrivateInfo;  /* Private information & counters */
-
-       /* flags, see fRTMP_ADAPTER_xxx flags */
-       unsigned long Flags;            /* Represent current device status */
-       unsigned long PSFlags;          /* Power Save operation flag. */
-
-       /* current TX sequence # */
-       u16 Sequence;
-
-       /* Control disconnect / connect event generation */
-       /*+++Not used anymore */
-       unsigned long LinkDownTime;
-       /*--- */
-       unsigned long LastRxRate;
-       unsigned long LastTxRate;
-       /*+++Used only for Station */
-       BOOLEAN bConfigChanged; /* Config Change flag for the same SSID setting */
-       /*--- */
-
-       unsigned long ExtraInfo;        /* Extra information for displaying status */
-       unsigned long SystemErrorBitmap;        /* b0: E2PROM version error */
-
-       /*+++Not used anymore */
-       unsigned long MacIcVersion;     /* MAC/BBP serial interface issue solved after ver.D */
-       /*--- */
-
-       /* --------------------------- */
-       /* System event log */
-       /* --------------------------- */
-       struct rt_802_11_event_table EventTab;
-
-       BOOLEAN HTCEnable;
-
-       /*****************************************************************************************/
-       /*      Statistic related parameters                                                     */
-       /*****************************************************************************************/
-#ifdef RTMP_MAC_USB
-       unsigned long BulkOutDataOneSecCount;
-       unsigned long BulkInDataOneSecCount;
-       unsigned long BulkLastOneSecCount;      /* BulkOutDataOneSecCount + BulkInDataOneSecCount */
-       unsigned long watchDogRxCnt;
-       unsigned long watchDogRxOverFlowCnt;
-       unsigned long watchDogTxPendingCnt[NUM_OF_TX_RING];
-       int TransferedLength[NUM_OF_TX_RING];
-#endif                         /* RTMP_MAC_USB // */
-
-       BOOLEAN bUpdateBcnCntDone;
-       unsigned long watchDogMacDeadlock;      /* prevent MAC/BBP into deadlock condition */
-       /* ---------------------------- */
-       /* DEBUG paramerts */
-       /* ---------------------------- */
-       /*unsigned long         DebugSetting[4]; */
-       BOOLEAN bBanAllBaSetup;
-       BOOLEAN bPromiscuous;
-
-       /* ---------------------------- */
-       /* rt2860c emulation-use Parameters */
-       /* ---------------------------- */
-       /*unsigned long         rtsaccu[30]; */
-       /*unsigned long         ctsaccu[30]; */
-       /*unsigned long         cfendaccu[30]; */
-       /*unsigned long         bacontent[16]; */
-       /*unsigned long         rxint[RX_RING_SIZE+1]; */
-       /*u8         rcvba[60]; */
-       BOOLEAN bLinkAdapt;
-       BOOLEAN bForcePrintTX;
-       BOOLEAN bForcePrintRX;
-       /*BOOLEAN               bDisablescanning;               //defined in RT2870 USB */
-       BOOLEAN bStaFifoTest;
-       BOOLEAN bProtectionTest;
-       BOOLEAN bBroadComHT;
-       /*+++Following add from RT2870 USB. */
-       unsigned long BulkOutReq;
-       unsigned long BulkOutComplete;
-       unsigned long BulkOutCompleteOther;
-       unsigned long BulkOutCompleteCancel;    /* seems not used now? */
-       unsigned long BulkInReq;
-       unsigned long BulkInComplete;
-       unsigned long BulkInCompleteFail;
-       /*--- */
-
-       struct wificonf WIFItestbed;
-
-       struct reordering_mpdu_pool mpdu_blk_pool;
-
-       unsigned long OneSecondnonBEpackets;    /* record non BE packets per second */
-
-#ifdef LINUX
-       struct iw_statistics iw_stats;
-
-       struct net_device_stats stats;
-#endif                         /* LINUX // */
-
-       unsigned long TbttTickCount;
-#ifdef PCI_MSI_SUPPORT
-       BOOLEAN HaveMsi;
-#endif                         /* PCI_MSI_SUPPORT // */
-
-       u8 is_on;
-
-#define TIME_BASE                      (1000000/OS_HZ)
-#define TIME_ONE_SECOND                (1000000/TIME_BASE)
-       u8 flg_be_adjust;
-       unsigned long be_adjust_last_time;
-
-       u8 FlgCtsEnabled;
-       u8 PM_FlgSuspend;
-
-#ifdef RT30xx
-#ifdef RTMP_EFUSE_SUPPORT
-       BOOLEAN bUseEfuse;
-       u8 EEPROMImage[1024];
-#endif                         /* RTMP_EFUSE_SUPPORT // */
-#endif                         /* RT30xx // */
-};
-
-#define DELAYINTMASK           0x0003fffb
-#define INTMASK                                0x0003fffb
-#define IndMask                                0x0003fffc
-#define RxINT                          0x00000005      /* Delayed Rx or indivi rx */
-#define TxDataInt                      0x000000fa      /* Delayed Tx or indivi tx */
-#define TxMgmtInt                      0x00000102      /* Delayed Tx or indivi tx */
-#define TxCoherent                     0x00020000      /* tx coherent */
-#define RxCoherent                     0x00010000      /* rx coherent */
-#define McuCommand                     0x00000200      /* mcu */
-#define PreTBTTInt                     0x00001000      /* Pre-TBTT interrupt */
-#define TBTTInt                                0x00000800      /* TBTT interrupt */
-#define GPTimeOutInt                   0x00008000      /* GPtimeout interrupt */
-#define AutoWakeupInt          0x00004000      /* AutoWakeupInt interrupt */
-#define FifoStaFullInt                 0x00002000      /*  fifo statistics full interrupt */
-
-/***************************************************************************
-  *    Rx Path software control block related data structures
-  **************************************************************************/
-struct rt_rx_blk {
-       RT28XX_RXD_STRUC RxD;
-       struct rt_rxwi *pRxWI;
-       struct rt_header_802_11 *pHeader;
-       void *pRxPacket;
-       u8 *pData;
-       u16 DataSize;
-       u16 Flags;
-       u8 UserPriority;        /* for calculate TKIP MIC using */
-};
-
-#define RX_BLK_SET_FLAG(_pRxBlk, _flag)                (_pRxBlk->Flags |= _flag)
-#define RX_BLK_TEST_FLAG(_pRxBlk, _flag)       (_pRxBlk->Flags & _flag)
-#define RX_BLK_CLEAR_FLAG(_pRxBlk, _flag)      (_pRxBlk->Flags &= ~(_flag))
-
-#define fRX_WDS                        0x0001
-#define fRX_AMSDU       0x0002
-#define fRX_ARALINK     0x0004
-#define fRX_HTC         0x0008
-#define fRX_PAD         0x0010
-#define fRX_AMPDU       0x0020
-#define fRX_QOS                        0x0040
-#define fRX_INFRA              0x0080
-#define fRX_EAP                        0x0100
-#define fRX_MESH               0x0200
-#define fRX_APCLI              0x0400
-#define fRX_DLS                        0x0800
-#define fRX_WPI                        0x1000
-
-#define LENGTH_AMSDU_SUBFRAMEHEAD      14
-#define LENGTH_ARALINK_SUBFRAMEHEAD    14
-#define LENGTH_ARALINK_HEADER_FIELD     2
-
-/***************************************************************************
-  *    Tx Path software control block related data structures
-  **************************************************************************/
-#define TX_UNKOWN_FRAME                        0x00
-#define TX_MCAST_FRAME                 0x01
-#define TX_LEGACY_FRAME                        0x02
-#define TX_AMPDU_FRAME                 0x04
-#define TX_AMSDU_FRAME                 0x08
-#define TX_RALINK_FRAME                        0x10
-#define TX_FRAG_FRAME                  0x20
-
-/*      Currently the sizeof(struct rt_tx_blk) is 148 bytes. */
-struct rt_tx_blk {
-       u8 QueIdx;
-       u8 TxFrameType; /* Indicate the Transmission type of the all frames in one batch */
-       u8 TotalFrameNum;       /* Total frame number that wants to send-out in one batch */
-       u16 TotalFragNum;       /* Total frame fragments required in one batch */
-       u16 TotalFrameLen;      /* Total length of all frames that wants to send-out in one batch */
-
-       struct rt_queue_header TxPacketList;
-       struct rt_mac_table_entry *pMacEntry;   /* NULL: packet with 802.11 RA field is multicast/broadcast address */
-       HTTRANSMIT_SETTING *pTransmit;
-
-       /* Following structure used for the characteristics of a specific packet. */
-       void *pPacket;
-       u8 *pSrcBufHeader;      /* Reference to the head of sk_buff->data */
-       u8 *pSrcBufData;        /* Reference to the sk_buff->data, will change depending on the handling progresss */
-       u32 SrcBufLen;          /* Length of packet payload which not including Layer 2 header */
-       u8 *pExtraLlcSnapEncap; /* NULL means no extra LLC/SNAP is required */
-       u8 HeaderBuf[128];      /* TempBuffer for TX_INFO + TX_WI + 802.11 Header + padding + AMSDU SubHeader + LLC/SNAP */
-       /*RT2870 2.1.0.0 uses only 80 bytes */
-       /*RT3070 2.1.1.0 uses only 96 bytes */
-       /*RT3090 2.1.0.0 uses only 96 bytes */
-       u8 MpduHeaderLen;       /* 802.11 header length NOT including the padding */
-       u8 HdrPadLen;   /* recording Header Padding Length; */
-       u8 apidx;               /* The interface associated to this packet */
-       u8 Wcid;                /* The MAC entry associated to this packet */
-       u8 UserPriority;        /* priority class of packet */
-       u8 FrameGap;            /* what kind of IFS does this packet use */
-       u8 MpduReqNum;  /* number of fragments of this frame */
-       u8 TxRate;              /* TODO: Obsoleted? Should change to MCS? */
-       u8 CipherAlg;   /* cipher alogrithm */
-       struct rt_cipher_key *pKey;
-
-       u16 Flags;              /*See following definitions for detail. */
-
-       /*YOU SHOULD NOT TOUCH IT! Following parameters are used for hardware-depended layer. */
-       unsigned long Priv;             /* Hardware specific value saved in here. */
-};
-
-#define fTX_bRtsRequired       0x0001  /* Indicate if need send RTS frame for protection. Not used in RT2860/RT2870. */
-#define fTX_bAckRequired       0x0002  /* the packet need ack response */
-#define fTX_bPiggyBack         0x0004  /* Legacy device use Piggback or not */
-#define fTX_bHTRate            0x0008  /* allow to use HT rate */
-#define fTX_bForceNonQoS       0x0010  /* force to transmit frame without WMM-QoS in HT mode */
-#define fTX_bAllowFrag         0x0020  /* allow to fragment the packet, A-MPDU, A-MSDU, A-Ralink is not allowed to fragment */
-#define fTX_bMoreData          0x0040  /* there are more data packets in PowerSave Queue */
-#define fTX_bWMM               0x0080  /* QOS Data */
-#define fTX_bClearEAPFrame     0x0100
-
-#define TX_BLK_SET_FLAG(_pTxBlk, _flag)                (_pTxBlk->Flags |= _flag)
-#define TX_BLK_TEST_FLAG(_pTxBlk, _flag)       (((_pTxBlk->Flags & _flag) == _flag) ? 1 : 0)
-#define TX_BLK_CLEAR_FLAG(_pTxBlk, _flag)      (_pTxBlk->Flags &= ~(_flag))
-
-/***************************************************************************
-  *    Other static inline function definitions
-  **************************************************************************/
-static inline void ConvertMulticastIP2MAC(u8 *pIpAddr,
-                                         u8 **ppMacAddr,
-                                         u16 ProtoType)
-{
-       if (pIpAddr == NULL)
-               return;
-
-       if (ppMacAddr == NULL || *ppMacAddr == NULL)
-               return;
-
-       switch (ProtoType) {
-       case ETH_P_IPV6:
-/*                      memset(*ppMacAddr, 0, ETH_LENGTH_OF_ADDRESS); */
-               *(*ppMacAddr) = 0x33;
-               *(*ppMacAddr + 1) = 0x33;
-               *(*ppMacAddr + 2) = pIpAddr[12];
-               *(*ppMacAddr + 3) = pIpAddr[13];
-               *(*ppMacAddr + 4) = pIpAddr[14];
-               *(*ppMacAddr + 5) = pIpAddr[15];
-               break;
-
-       case ETH_P_IP:
-       default:
-/*                      memset(*ppMacAddr, 0, ETH_LENGTH_OF_ADDRESS); */
-               *(*ppMacAddr) = 0x01;
-               *(*ppMacAddr + 1) = 0x00;
-               *(*ppMacAddr + 2) = 0x5e;
-               *(*ppMacAddr + 3) = pIpAddr[1] & 0x7f;
-               *(*ppMacAddr + 4) = pIpAddr[2];
-               *(*ppMacAddr + 5) = pIpAddr[3];
-               break;
-       }
-
-       return;
-}
-
-char *GetPhyMode(int Mode);
-char *GetBW(int BW);
-
-/* */
-/*  Private routines in rtmp_init.c */
-/* */
-int RTMPAllocAdapterBlock(void *handle,
-                                 struct rt_rtmp_adapter **ppAdapter);
-
-int RTMPAllocTxRxRingMemory(struct rt_rtmp_adapter *pAd);
-
-void RTMPFreeAdapter(struct rt_rtmp_adapter *pAd);
-
-int NICReadRegParameters(struct rt_rtmp_adapter *pAd,
-                                void *WrapperConfigurationContext);
-
-#ifdef RTMP_RF_RW_SUPPORT
-void NICInitRFRegisters(struct rt_rtmp_adapter *pAd);
-
-void RtmpChipOpsRFHook(struct rt_rtmp_adapter *pAd);
-
-int RT30xxWriteRFRegister(struct rt_rtmp_adapter *pAd,
-                                 u8 regID, u8 value);
-
-int RT30xxReadRFRegister(struct rt_rtmp_adapter *pAd,
-                                u8 regID, u8 *pValue);
-#endif /* RTMP_RF_RW_SUPPORT // */
-
-void NICReadEEPROMParameters(struct rt_rtmp_adapter *pAd, u8 *mac_addr);
-
-void NICInitAsicFromEEPROM(struct rt_rtmp_adapter *pAd);
-
-int NICInitializeAdapter(struct rt_rtmp_adapter *pAd, IN BOOLEAN bHardReset);
-
-int NICInitializeAsic(struct rt_rtmp_adapter *pAd, IN BOOLEAN bHardReset);
-
-void NICIssueReset(struct rt_rtmp_adapter *pAd);
-
-void RTMPRingCleanUp(struct rt_rtmp_adapter *pAd, u8 RingType);
-
-void UserCfgInit(struct rt_rtmp_adapter *pAd);
-
-void NICResetFromError(struct rt_rtmp_adapter *pAd);
-
-int NICLoadFirmware(struct rt_rtmp_adapter *pAd);
-
-void NICEraseFirmware(struct rt_rtmp_adapter *pAd);
-
-int NICLoadRateSwitchingParams(struct rt_rtmp_adapter *pAd);
-
-BOOLEAN NICCheckForHang(struct rt_rtmp_adapter *pAd);
-
-void NICUpdateFifoStaCounters(struct rt_rtmp_adapter *pAd);
-
-void NICUpdateRawCounters(struct rt_rtmp_adapter *pAd);
-
-void RTMPZeroMemory(void *pSrc, unsigned long Length);
-
-unsigned long RTMPCompareMemory(void *pSrc1, void *pSrc2, unsigned long Length);
-
-void RTMPMoveMemory(void *pDest, void *pSrc, unsigned long Length);
-
-void AtoH(char *src, u8 *dest, int destlen);
-
-void RTMPPatchMacBbpBug(struct rt_rtmp_adapter *pAd);
-
-void RTMPInitTimer(struct rt_rtmp_adapter *pAd,
-                  struct rt_ralink_timer *pTimer,
-                  void *pTimerFunc, void *pData, IN BOOLEAN Repeat);
-
-void RTMPSetTimer(struct rt_ralink_timer *pTimer, unsigned long Value);
-
-void RTMPModTimer(struct rt_ralink_timer *pTimer, unsigned long Value);
-
-void RTMPCancelTimer(struct rt_ralink_timer *pTimer, OUT BOOLEAN * pCancelled);
-
-void RTMPSetLED(struct rt_rtmp_adapter *pAd, u8 Status);
-
-void RTMPSetSignalLED(struct rt_rtmp_adapter *pAd, IN NDIS_802_11_RSSI Dbm);
-
-void RTMPEnableRxTx(struct rt_rtmp_adapter *pAd);
-
-/* */
-/* prototype in action.c */
-/* */
-void ActionStateMachineInit(struct rt_rtmp_adapter *pAd,
-                           struct rt_state_machine *S,
-                           OUT STATE_MACHINE_FUNC Trans[]);
-
-void MlmeADDBAAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
-
-void MlmeDELBAAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
-
-void MlmeDLSAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
-
-void MlmeInvalidAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
-
-void MlmeQOSAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
-
-void PeerAddBAReqAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
-
-void PeerAddBARspAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
-
-void PeerDelBAAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
-
-void PeerBAAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
-
-void SendPSMPAction(struct rt_rtmp_adapter *pAd, u8 Wcid, u8 Psmp);
-
-void PeerRMAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
-
-void PeerPublicAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
-
-void PeerHTAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
-
-void PeerQOSAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
-
-void RECBATimerTimeout(void *SystemSpecific1,
-                      void *FunctionContext,
-                      void *SystemSpecific2, void *SystemSpecific3);
-
-void ORIBATimerTimeout(struct rt_rtmp_adapter *pAd);
-
-void SendRefreshBAR(struct rt_rtmp_adapter *pAd, struct rt_mac_table_entry *pEntry);
-
-void ActHeaderInit(struct rt_rtmp_adapter *pAd,
-                  struct rt_header_802_11 *pHdr80211,
-                  u8 *Addr1, u8 *Addr2, u8 *Addr3);
-
-void BarHeaderInit(struct rt_rtmp_adapter *pAd,
-                  struct rt_frame_bar *pCntlBar, u8 *pDA, u8 *pSA);
-
-void InsertActField(struct rt_rtmp_adapter *pAd,
-                   u8 *pFrameBuf,
-                   unsigned long *pFrameLen, u8 Category, u8 ActCode);
-
-BOOLEAN CntlEnqueueForRecv(struct rt_rtmp_adapter *pAd,
-                          unsigned long Wcid,
-                          unsigned long MsgLen, struct rt_frame_ba_req *pMsg);
-
-/* */
-/* Private routines in rtmp_data.c */
-/* */
-BOOLEAN RTMPHandleRxDoneInterrupt(struct rt_rtmp_adapter *pAd);
-
-BOOLEAN RTMPHandleTxRingDmaDoneInterrupt(struct rt_rtmp_adapter *pAd,
-                                        INT_SOURCE_CSR_STRUC TxRingBitmap);
-
-void RTMPHandleMgmtRingDmaDoneInterrupt(struct rt_rtmp_adapter *pAd);
-
-void RTMPHandleTBTTInterrupt(struct rt_rtmp_adapter *pAd);
-
-void RTMPHandlePreTBTTInterrupt(struct rt_rtmp_adapter *pAd);
-
-void RTMPHandleTwakeupInterrupt(struct rt_rtmp_adapter *pAd);
-
-void RTMPHandleRxCoherentInterrupt(struct rt_rtmp_adapter *pAd);
-
-BOOLEAN TxFrameIsAggregatible(struct rt_rtmp_adapter *pAd,
-                             u8 *pPrevAddr1, u8 *p8023hdr);
-
-BOOLEAN PeerIsAggreOn(struct rt_rtmp_adapter *pAd,
-                     unsigned long TxRate, struct rt_mac_table_entry *pMacEntry);
-
-int Sniff2BytesFromNdisBuffer(char *pFirstBuffer,
-                                     u8 DesiredOffset,
-                                     u8 *pByte0, u8 *pByte1);
-
-int STASendPacket(struct rt_rtmp_adapter *pAd, void *pPacket);
-
-void STASendPackets(void *MiniportAdapterContext,
-                   void **ppPacketArray, u32 NumberOfPackets);
-
-void RTMPDeQueuePacket(struct rt_rtmp_adapter *pAd,
-                      IN BOOLEAN bIntContext,
-                      u8 QueIdx, u8 Max_Tx_Packets);
-
-int RTMPHardTransmit(struct rt_rtmp_adapter *pAd,
-                            void *pPacket,
-                            u8 QueIdx, unsigned long *pFreeTXDLeft);
-
-int STAHardTransmit(struct rt_rtmp_adapter *pAd,
-                           struct rt_tx_blk *pTxBlk, u8 QueIdx);
-
-void STARxEAPOLFrameIndicate(struct rt_rtmp_adapter *pAd,
-                            struct rt_mac_table_entry *pEntry,
-                            struct rt_rx_blk *pRxBlk, u8 FromWhichBSSID);
-
-int RTMPFreeTXDRequest(struct rt_rtmp_adapter *pAd,
-                              u8 RingType,
-                              u8 NumberRequired, u8 *FreeNumberIs);
-
-int MlmeHardTransmit(struct rt_rtmp_adapter *pAd,
-                            u8 QueIdx, void *pPacket);
-
-int MlmeHardTransmitMgmtRing(struct rt_rtmp_adapter *pAd,
-                                    u8 QueIdx, void *pPacket);
-
-#ifdef RTMP_MAC_PCI
-int MlmeHardTransmitTxRing(struct rt_rtmp_adapter *pAd,
-                                  u8 QueIdx, void *pPacket);
-
-int MlmeDataHardTransmit(struct rt_rtmp_adapter *pAd,
-                                u8 QueIdx, void *pPacket);
-
-void RTMPWriteTxDescriptor(struct rt_rtmp_adapter *pAd,
-                          struct rt_txd *pTxD, IN BOOLEAN bWIV, u8 QSEL);
-#endif /* RTMP_MAC_PCI // */
-
-u16 RTMPCalcDuration(struct rt_rtmp_adapter *pAd, u8 Rate, unsigned long Size);
-
-void RTMPWriteTxWI(struct rt_rtmp_adapter *pAd, struct rt_txwi * pTxWI, IN BOOLEAN FRAG, IN BOOLEAN CFACK, IN BOOLEAN InsTimestamp, IN BOOLEAN AMPDU, IN BOOLEAN Ack, IN BOOLEAN NSeq, /* HW new a sequence. */
-                  u8 BASize,
-                  u8 WCID,
-                  unsigned long Length,
-                  u8 PID,
-                  u8 TID,
-                  u8 TxRate,
-                  u8 Txopmode,
-                  IN BOOLEAN CfAck, IN HTTRANSMIT_SETTING *pTransmit);
-
-void RTMPWriteTxWI_Data(struct rt_rtmp_adapter *pAd,
-                       struct rt_txwi *pTxWI, struct rt_tx_blk *pTxBlk);
-
-void RTMPWriteTxWI_Cache(struct rt_rtmp_adapter *pAd,
-                        struct rt_txwi *pTxWI, struct rt_tx_blk *pTxBlk);
-
-void RTMPSuspendMsduTransmission(struct rt_rtmp_adapter *pAd);
-
-void RTMPResumeMsduTransmission(struct rt_rtmp_adapter *pAd);
-
-int MiniportMMRequest(struct rt_rtmp_adapter *pAd,
-                             u8 QueIdx, u8 *pData, u32 Length);
-
-/*+++mark by shiang, now this function merge to MiniportMMRequest() */
-/*---mark by shiang, now this function merge to MiniportMMRequest() */
-
-void RTMPSendNullFrame(struct rt_rtmp_adapter *pAd,
-                      u8 TxRate, IN BOOLEAN bQosNull);
-
-void RTMPSendDisassociationFrame(struct rt_rtmp_adapter *pAd);
-
-void RTMPSendRTSFrame(struct rt_rtmp_adapter *pAd,
-                     u8 *pDA,
-                     IN unsigned int NextMpduSize,
-                     u8 TxRate,
-                     u8 RTSRate,
-                     u16 AckDuration,
-                     u8 QueIdx, u8 FrameGap);
-
-struct rt_queue_header *RTMPCheckTxSwQueue(struct rt_rtmp_adapter *pAd, u8 * QueIdx);
-
-void RTMPReportMicError(struct rt_rtmp_adapter *pAd, struct rt_cipher_key *pWpaKey);
-
-void WpaMicFailureReportFrame(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
-
-void WpaDisassocApAndBlockAssoc(void *SystemSpecific1,
-                               void *FunctionContext,
-                               void *SystemSpecific2,
-                               void *SystemSpecific3);
-
-void WpaStaPairwiseKeySetting(struct rt_rtmp_adapter *pAd);
-
-void WpaStaGroupKeySetting(struct rt_rtmp_adapter *pAd);
-
-int RTMPCloneNdisPacket(struct rt_rtmp_adapter *pAd,
-                               IN BOOLEAN pInsAMSDUHdr,
-                               void *pInPacket,
-                               void **ppOutPacket);
-
-int RTMPAllocateNdisPacket(struct rt_rtmp_adapter *pAd,
-                                  void **pPacket,
-                                  u8 *pHeader,
-                                  u32 HeaderLen,
-                                  u8 *pData, u32 DataLen);
-
-void RTMPFreeNdisPacket(struct rt_rtmp_adapter *pAd, void *pPacket);
-
-BOOLEAN RTMPFreeTXDUponTxDmaDone(struct rt_rtmp_adapter *pAd, u8 QueIdx);
-
-BOOLEAN RTMPCheckDHCPFrame(struct rt_rtmp_adapter *pAd, void *pPacket);
-
-BOOLEAN RTMPCheckEtherType(struct rt_rtmp_adapter *pAd, void *pPacket);
-
-/* */
-/* Private routines in rtmp_wep.c */
-/* */
-void RTMPInitWepEngine(struct rt_rtmp_adapter *pAd,
-                      u8 *pKey,
-                      u8 KeyId, u8 KeyLen, u8 *pDest);
-
-void RTMPEncryptData(struct rt_rtmp_adapter *pAd,
-                    u8 *pSrc, u8 *pDest, u32 Len);
-
-BOOLEAN RTMPSoftDecryptWEP(struct rt_rtmp_adapter *pAd,
-                          u8 *pData,
-                          unsigned long DataByteCnt, struct rt_cipher_key *pGroupKey);
-
-void RTMPSetICV(struct rt_rtmp_adapter *pAd, u8 *pDest);
-
-void ARCFOUR_INIT(struct rt_arcfourcontext *Ctx, u8 *pKey, u32 KeyLen);
-
-u8 ARCFOUR_BYTE(struct rt_arcfourcontext *Ctx);
-
-void ARCFOUR_DECRYPT(struct rt_arcfourcontext *Ctx,
-                    u8 *pDest, u8 *pSrc, u32 Len);
-
-void ARCFOUR_ENCRYPT(struct rt_arcfourcontext *Ctx,
-                    u8 *pDest, u8 *pSrc, u32 Len);
-
-void WPAARCFOUR_ENCRYPT(struct rt_arcfourcontext *Ctx,
-                       u8 *pDest, u8 *pSrc, u32 Len);
-
-u32 RTMP_CALC_FCS32(u32 Fcs, u8 *Cp, int Len);
-
-/* */
-/* MLME routines */
-/* */
-
-/* Asic/RF/BBP related functions */
-
-void AsicAdjustTxPower(struct rt_rtmp_adapter *pAd);
-
-void AsicUpdateProtect(struct rt_rtmp_adapter *pAd,
-                      u16 OperaionMode,
-                      u8 SetMask,
-                      IN BOOLEAN bDisableBGProtect, IN BOOLEAN bNonGFExist);
-
-void AsicSwitchChannel(struct rt_rtmp_adapter *pAd,
-                      u8 Channel, IN BOOLEAN bScan);
-
-void AsicLockChannel(struct rt_rtmp_adapter *pAd, u8 Channel);
-
-void AsicRfTuningExec(void *SystemSpecific1,
-                     void *FunctionContext,
-                     void *SystemSpecific2, void *SystemSpecific3);
-
-void AsicResetBBPAgent(struct rt_rtmp_adapter *pAd);
-
-void AsicSleepThenAutoWakeup(struct rt_rtmp_adapter *pAd,
-                            u16 TbttNumToNextWakeUp);
-
-void AsicForceSleep(struct rt_rtmp_adapter *pAd);
-
-void AsicForceWakeup(struct rt_rtmp_adapter *pAd, IN BOOLEAN bFromTx);
-
-void AsicSetBssid(struct rt_rtmp_adapter *pAd, u8 *pBssid);
-
-void AsicSetMcastWC(struct rt_rtmp_adapter *pAd);
-
-void AsicDelWcidTab(struct rt_rtmp_adapter *pAd, u8 Wcid);
-
-void AsicEnableRDG(struct rt_rtmp_adapter *pAd);
-
-void AsicDisableRDG(struct rt_rtmp_adapter *pAd);
-
-void AsicDisableSync(struct rt_rtmp_adapter *pAd);
-
-void AsicEnableBssSync(struct rt_rtmp_adapter *pAd);
-
-void AsicEnableIbssSync(struct rt_rtmp_adapter *pAd);
-
-void AsicSetEdcaParm(struct rt_rtmp_adapter *pAd, struct rt_edca_parm *pEdcaParm);
-
-void AsicSetSlotTime(struct rt_rtmp_adapter *pAd, IN BOOLEAN bUseShortSlotTime);
-
-void AsicAddSharedKeyEntry(struct rt_rtmp_adapter *pAd,
-                          u8 BssIndex,
-                          u8 KeyIdx,
-                          u8 CipherAlg,
-                          u8 *pKey, u8 *pTxMic, u8 *pRxMic);
-
-void AsicRemoveSharedKeyEntry(struct rt_rtmp_adapter *pAd,
-                             u8 BssIndex, u8 KeyIdx);
-
-void AsicUpdateWCIDAttribute(struct rt_rtmp_adapter *pAd,
-                            u16 WCID,
-                            u8 BssIndex,
-                            u8 CipherAlg,
-                            IN BOOLEAN bUsePairewiseKeyTable);
-
-void AsicUpdateWCIDIVEIV(struct rt_rtmp_adapter *pAd,
-                        u16 WCID, unsigned long uIV, unsigned long uEIV);
-
-void AsicUpdateRxWCIDTable(struct rt_rtmp_adapter *pAd,
-                          u16 WCID, u8 *pAddr);
-
-void AsicAddKeyEntry(struct rt_rtmp_adapter *pAd,
-                    u16 WCID,
-                    u8 BssIndex,
-                    u8 KeyIdx,
-                    struct rt_cipher_key *pCipherKey,
-                    IN BOOLEAN bUsePairewiseKeyTable, IN BOOLEAN bTxKey);
-
-void AsicAddPairwiseKeyEntry(struct rt_rtmp_adapter *pAd,
-                            u8 *pAddr,
-                            u8 WCID, struct rt_cipher_key *pCipherKey);
-
-void AsicRemovePairwiseKeyEntry(struct rt_rtmp_adapter *pAd,
-                               u8 BssIdx, u8 Wcid);
-
-BOOLEAN AsicSendCommandToMcu(struct rt_rtmp_adapter *pAd,
-                            u8 Command,
-                            u8 Token, u8 Arg0, u8 Arg1);
-
-#ifdef RTMP_MAC_PCI
-BOOLEAN AsicCheckCommanOk(struct rt_rtmp_adapter *pAd, u8 Command);
-#endif /* RTMP_MAC_PCI // */
-
-void MacAddrRandomBssid(struct rt_rtmp_adapter *pAd, u8 *pAddr);
-
-void MgtMacHeaderInit(struct rt_rtmp_adapter *pAd,
-                     struct rt_header_802_11 *pHdr80211,
-                     u8 SubType,
-                     u8 ToDs, u8 *pDA, u8 *pBssid);
-
-void MlmeRadioOff(struct rt_rtmp_adapter *pAd);
-
-void MlmeRadioOn(struct rt_rtmp_adapter *pAd);
-
-void BssTableInit(struct rt_bss_table *Tab);
-
-void BATableInit(struct rt_rtmp_adapter *pAd, struct rt_ba_table *Tab);
-
-unsigned long BssTableSearch(struct rt_bss_table *Tab, u8 *pBssid, u8 Channel);
-
-unsigned long BssSsidTableSearch(struct rt_bss_table *Tab,
-                        u8 *pBssid,
-                        u8 *pSsid, u8 SsidLen, u8 Channel);
-
-unsigned long BssTableSearchWithSSID(struct rt_bss_table *Tab,
-                            u8 *Bssid,
-                            u8 *pSsid,
-                            u8 SsidLen, u8 Channel);
-
-unsigned long BssSsidTableSearchBySSID(struct rt_bss_table *Tab,
-                              u8 *pSsid, u8 SsidLen);
-
-void BssTableDeleteEntry(struct rt_bss_table *pTab,
-                        u8 *pBssid, u8 Channel);
-
-void BATableDeleteORIEntry(struct rt_rtmp_adapter *pAd,
-                          struct rt_ba_ori_entry *pBAORIEntry);
-
-void BssEntrySet(struct rt_rtmp_adapter *pAd, struct rt_bss_entry *pBss, u8 *pBssid, char Ssid[], u8 SsidLen, u8 BssType, u16 BeaconPeriod, struct rt_cf_parm * CfParm, u16 AtimWin, u16 CapabilityInfo, u8 SupRate[], u8 SupRateLen, u8 ExtRate[], u8 ExtRateLen, struct rt_ht_capability_ie * pHtCapability, struct rt_add_ht_info_ie * pAddHtInfo,  /* AP might use this additional ht info IE */
-                u8 HtCapabilityLen,
-                u8 AddHtInfoLen,
-                u8 NewExtChanOffset,
-                u8 Channel,
-                char Rssi,
-                IN LARGE_INTEGER TimeStamp,
-                u8 CkipFlag,
-                struct rt_edca_parm *pEdcaParm,
-                struct rt_qos_capability_parm *pQosCapability,
-                struct rt_qbss_load_parm *pQbssLoad,
-                u16 LengthVIE, struct rt_ndis_802_11_variable_ies *pVIE);
-
-unsigned long BssTableSetEntry(struct rt_rtmp_adapter *pAd, struct rt_bss_table *pTab, u8 *pBssid, char Ssid[], u8 SsidLen, u8 BssType, u16 BeaconPeriod, struct rt_cf_parm * CfParm, u16 AtimWin, u16 CapabilityInfo, u8 SupRate[], u8 SupRateLen, u8 ExtRate[], u8 ExtRateLen, struct rt_ht_capability_ie * pHtCapability, struct rt_add_ht_info_ie * pAddHtInfo,    /* AP might use this additional ht info IE */
-                      u8 HtCapabilityLen,
-                      u8 AddHtInfoLen,
-                      u8 NewExtChanOffset,
-                      u8 Channel,
-                      char Rssi,
-                      IN LARGE_INTEGER TimeStamp,
-                      u8 CkipFlag,
-                      struct rt_edca_parm *pEdcaParm,
-                      struct rt_qos_capability_parm *pQosCapability,
-                      struct rt_qbss_load_parm *pQbssLoad,
-                      u16 LengthVIE, struct rt_ndis_802_11_variable_ies *pVIE);
-
-void BATableInsertEntry(struct rt_rtmp_adapter *pAd,
-                       u16 Aid,
-                       u16 TimeOutValue,
-                       u16 StartingSeq,
-                       u8 TID,
-                       u8 BAWinSize,
-                       u8 OriginatorStatus, IN BOOLEAN IsRecipient);
-
-void BssTableSsidSort(struct rt_rtmp_adapter *pAd,
-                     struct rt_bss_table *OutTab, char Ssid[], u8 SsidLen);
-
-void BssTableSortByRssi(struct rt_bss_table *OutTab);
-
-void BssCipherParse(struct rt_bss_entry *pBss);
-
-int MlmeQueueInit(struct rt_mlme_queue *Queue);
-
-void MlmeQueueDestroy(struct rt_mlme_queue *Queue);
-
-BOOLEAN MlmeEnqueue(struct rt_rtmp_adapter *pAd,
-                   unsigned long Machine,
-                   unsigned long MsgType, unsigned long MsgLen, void *Msg);
-
-BOOLEAN MlmeEnqueueForRecv(struct rt_rtmp_adapter *pAd,
-                          unsigned long Wcid,
-                          unsigned long TimeStampHigh,
-                          unsigned long TimeStampLow,
-                          u8 Rssi0,
-                          u8 Rssi1,
-                          u8 Rssi2,
-                          unsigned long MsgLen, void *Msg, u8 Signal);
-
-BOOLEAN MlmeDequeue(struct rt_mlme_queue *Queue, struct rt_mlme_queue_elem **Elem);
-
-void MlmeRestartStateMachine(struct rt_rtmp_adapter *pAd);
-
-BOOLEAN MlmeQueueEmpty(struct rt_mlme_queue *Queue);
-
-BOOLEAN MlmeQueueFull(struct rt_mlme_queue *Queue);
-
-BOOLEAN MsgTypeSubst(struct rt_rtmp_adapter *pAd,
-                    struct rt_frame_802_11 *pFrame,
-                    int *Machine, int *MsgType);
-
-void StateMachineInit(struct rt_state_machine *Sm,
-                     IN STATE_MACHINE_FUNC Trans[],
-                     unsigned long StNr,
-                     unsigned long MsgNr,
-                     IN STATE_MACHINE_FUNC DefFunc,
-                     unsigned long InitState, unsigned long Base);
-
-void StateMachineSetAction(struct rt_state_machine *S,
-                          unsigned long St, unsigned long Msg, IN STATE_MACHINE_FUNC F);
-
-void StateMachinePerformAction(struct rt_rtmp_adapter *pAd,
-                              struct rt_state_machine *S, struct rt_mlme_queue_elem *Elem);
-
-void Drop(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
-
-void AssocStateMachineInit(struct rt_rtmp_adapter *pAd,
-                          struct rt_state_machine *Sm,
-                          OUT STATE_MACHINE_FUNC Trans[]);
-
-void ReassocTimeout(void *SystemSpecific1,
-                   void *FunctionContext,
-                   void *SystemSpecific2, void *SystemSpecific3);
-
-void AssocTimeout(void *SystemSpecific1,
-                 void *FunctionContext,
-                 void *SystemSpecific2, void *SystemSpecific3);
-
-void DisassocTimeout(void *SystemSpecific1,
-                    void *FunctionContext,
-                    void *SystemSpecific2, void *SystemSpecific3);
-
-/*---------------------------------------------- */
-void MlmeAssocReqAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
-
-void MlmeReassocReqAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
-
-void MlmeDisassocReqAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
-
-void PeerAssocRspAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
-
-void PeerReassocRspAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
-
-void PeerDisassocAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
-
-void DisassocTimeoutAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
-
-void AssocTimeoutAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
-
-void ReassocTimeoutAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
-
-void Cls3errAction(struct rt_rtmp_adapter *pAd, u8 *pAddr);
-
-void InvalidStateWhenAssoc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
-
-void InvalidStateWhenReassoc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
-
-void InvalidStateWhenDisassociate(struct rt_rtmp_adapter *pAd,
-                                 struct rt_mlme_queue_elem *Elem);
-
-#ifdef RTMP_MAC_USB
-void MlmeCntlConfirm(struct rt_rtmp_adapter *pAd, unsigned long MsgType, u16 Msg);
-#endif /* RTMP_MAC_USB // */
-
-void ComposePsPoll(struct rt_rtmp_adapter *pAd);
-
-void ComposeNullFrame(struct rt_rtmp_adapter *pAd);
-
-void AssocPostProc(struct rt_rtmp_adapter *pAd,
-                  u8 *pAddr2,
-                  u16 CapabilityInfo,
-                  u16 Aid,
-                  u8 SupRate[],
-                  u8 SupRateLen,
-                  u8 ExtRate[],
-                  u8 ExtRateLen,
-                  struct rt_edca_parm *pEdcaParm,
-                  struct rt_ht_capability_ie *pHtCapability,
-                  u8 HtCapabilityLen, struct rt_add_ht_info_ie *pAddHtInfo);
-
-void AuthStateMachineInit(struct rt_rtmp_adapter *pAd,
-                         struct rt_state_machine *sm, OUT STATE_MACHINE_FUNC Trans[]);
-
-void AuthTimeout(void *SystemSpecific1,
-                void *FunctionContext,
-                void *SystemSpecific2, void *SystemSpecific3);
-
-void MlmeAuthReqAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
-
-void PeerAuthRspAtSeq2Action(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
-
-void PeerAuthRspAtSeq4Action(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
-
-void AuthTimeoutAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
-
-void Cls2errAction(struct rt_rtmp_adapter *pAd, u8 *pAddr);
-
-void MlmeDeauthReqAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
-
-void InvalidStateWhenAuth(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
-
-/*============================================= */
-
-void AuthRspStateMachineInit(struct rt_rtmp_adapter *pAd,
-                            struct rt_state_machine *Sm,
-                            IN STATE_MACHINE_FUNC Trans[]);
-
-void PeerDeauthAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
-
-void PeerAuthSimpleRspGenAndSend(struct rt_rtmp_adapter *pAd,
-                                struct rt_header_802_11 *pHdr80211,
-                                u16 Alg,
-                                u16 Seq,
-                                u16 Reason, u16 Status);
-
-/* */
-/* Private routines in dls.c */
-/* */
-
-/*======================================== */
-
-void SyncStateMachineInit(struct rt_rtmp_adapter *pAd,
-                         struct rt_state_machine *Sm,
-                         OUT STATE_MACHINE_FUNC Trans[]);
-
-void BeaconTimeout(void *SystemSpecific1,
-                  void *FunctionContext,
-                  void *SystemSpecific2, void *SystemSpecific3);
-
-void ScanTimeout(void *SystemSpecific1,
-                void *FunctionContext,
-                void *SystemSpecific2, void *SystemSpecific3);
-
-void InvalidStateWhenScan(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
-
-void InvalidStateWhenJoin(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
-
-void InvalidStateWhenStart(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
-
-void EnqueueProbeRequest(struct rt_rtmp_adapter *pAd);
-
-BOOLEAN ScanRunning(struct rt_rtmp_adapter *pAd);
-/*========================================= */
-
-void MlmeCntlInit(struct rt_rtmp_adapter *pAd,
-                 struct rt_state_machine *S, OUT STATE_MACHINE_FUNC Trans[]);
-
-void MlmeCntlMachinePerformAction(struct rt_rtmp_adapter *pAd,
-                                 struct rt_state_machine *S,
-                                 struct rt_mlme_queue_elem *Elem);
-
-void CntlIdleProc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
-
-void CntlOidScanProc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
-
-void CntlOidSsidProc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
-
-void CntlOidRTBssidProc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
-
-void CntlMlmeRoamingProc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
-
-void CntlWaitDisassocProc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
-
-void CntlWaitJoinProc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
-
-void CntlWaitReassocProc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
-
-void CntlWaitStartProc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
-
-void CntlWaitAuthProc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
-
-void CntlWaitAuthProc2(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
-
-void CntlWaitAssocProc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
-
-void LinkUp(struct rt_rtmp_adapter *pAd, u8 BssType);
-
-void LinkDown(struct rt_rtmp_adapter *pAd, IN BOOLEAN IsReqFromAP);
-
-void IterateOnBssTab(struct rt_rtmp_adapter *pAd);
-
-void IterateOnBssTab2(struct rt_rtmp_adapter *pAd);
-
-void JoinParmFill(struct rt_rtmp_adapter *pAd,
-                 struct rt_mlme_join_req *JoinReq, unsigned long BssIdx);
-
-void AssocParmFill(struct rt_rtmp_adapter *pAd,
-                  struct rt_mlme_assoc_req *AssocReq,
-                  u8 *pAddr,
-                  u16 CapabilityInfo,
-                  unsigned long Timeout, u16 ListenIntv);
-
-void ScanParmFill(struct rt_rtmp_adapter *pAd,
-                 struct rt_mlme_scan_req *ScanReq,
-                 char Ssid[],
-                 u8 SsidLen, u8 BssType, u8 ScanType);
-
-void DisassocParmFill(struct rt_rtmp_adapter *pAd,
-                     struct rt_mlme_disassoc_req *DisassocReq,
-                     u8 *pAddr, u16 Reason);
-
-void StartParmFill(struct rt_rtmp_adapter *pAd,
-                  struct rt_mlme_start_req *StartReq,
-                  char Ssid[], u8 SsidLen);
-
-void AuthParmFill(struct rt_rtmp_adapter *pAd,
-                 struct rt_mlme_auth_req *AuthReq,
-                 u8 *pAddr, u16 Alg);
-
-void EnqueuePsPoll(struct rt_rtmp_adapter *pAd);
-
-void EnqueueBeaconFrame(struct rt_rtmp_adapter *pAd);
-
-void MlmeJoinReqAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
-
-void MlmeScanReqAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
-
-void MlmeStartReqAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
-
-void ScanTimeoutAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
-
-void BeaconTimeoutAtJoinAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
-
-void PeerBeaconAtScanAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
-
-void PeerBeaconAtJoinAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
-
-void PeerBeacon(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
-
-void PeerProbeReqAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
-
-void ScanNextChannel(struct rt_rtmp_adapter *pAd);
-
-unsigned long MakeIbssBeacon(struct rt_rtmp_adapter *pAd);
-
-BOOLEAN MlmeScanReqSanity(struct rt_rtmp_adapter *pAd,
-                         void *Msg,
-                         unsigned long MsgLen,
-                         u8 *BssType,
-                         char ssid[],
-                         u8 *SsidLen, u8 *ScanType);
-
-BOOLEAN PeerBeaconAndProbeRspSanity(struct rt_rtmp_adapter *pAd,
-                                   void *Msg,
-                                   unsigned long MsgLen,
-                                   u8 MsgChannel,
-                                   u8 *pAddr2,
-                                   u8 *pBssid,
-                                   char Ssid[],
-                                   u8 *pSsidLen,
-                                   u8 *pBssType,
-                                   u16 *pBeaconPeriod,
-                                   u8 *pChannel,
-                                   u8 *pNewChannel,
-                                   OUT LARGE_INTEGER *pTimestamp,
-                                   struct rt_cf_parm *pCfParm,
-                                   u16 *pAtimWin,
-                                   u16 *pCapabilityInfo,
-                                   u8 *pErp,
-                                   u8 *pDtimCount,
-                                   u8 *pDtimPeriod,
-                                   u8 *pBcastFlag,
-                                   u8 *pMessageToMe,
-                                   u8 SupRate[],
-                                   u8 *pSupRateLen,
-                                   u8 ExtRate[],
-                                   u8 *pExtRateLen,
-                                   u8 *pCkipFlag,
-                                   u8 *pAironetCellPowerLimit,
-                                   struct rt_edca_parm *pEdcaParm,
-                                   struct rt_qbss_load_parm *pQbssLoad,
-                                   struct rt_qos_capability_parm *pQosCapability,
-                                   unsigned long *pRalinkIe,
-                                   u8 *pHtCapabilityLen,
-                                   u8 *pPreNHtCapabilityLen,
-                                   struct rt_ht_capability_ie *pHtCapability,
-                                   u8 *AddHtInfoLen,
-                                   struct rt_add_ht_info_ie *AddHtInfo,
-                                   u8 *NewExtChannel,
-                                   u16 *LengthVIE,
-                                   struct rt_ndis_802_11_variable_ies *pVIE);
-
-BOOLEAN PeerAddBAReqActionSanity(struct rt_rtmp_adapter *pAd,
-                                void *pMsg,
-                                unsigned long MsgLen, u8 *pAddr2);
-
-BOOLEAN PeerAddBARspActionSanity(struct rt_rtmp_adapter *pAd,
-                                void *pMsg, unsigned long MsgLen);
-
-BOOLEAN PeerDelBAActionSanity(struct rt_rtmp_adapter *pAd,
-                             u8 Wcid, void *pMsg, unsigned long MsgLen);
-
-BOOLEAN MlmeAssocReqSanity(struct rt_rtmp_adapter *pAd,
-                          void *Msg,
-                          unsigned long MsgLen,
-                          u8 *pApAddr,
-                          u16 *CapabilityInfo,
-                          unsigned long *Timeout, u16 *ListenIntv);
-
-BOOLEAN MlmeAuthReqSanity(struct rt_rtmp_adapter *pAd,
-                         void *Msg,
-                         unsigned long MsgLen,
-                         u8 *pAddr,
-                         unsigned long *Timeout, u16 *Alg);
-
-BOOLEAN MlmeStartReqSanity(struct rt_rtmp_adapter *pAd,
-                          void *Msg,
-                          unsigned long MsgLen,
-                          char Ssid[], u8 *Ssidlen);
-
-BOOLEAN PeerAuthSanity(struct rt_rtmp_adapter *pAd,
-                      void *Msg,
-                      unsigned long MsgLen,
-                      u8 *pAddr,
-                      u16 *Alg,
-                      u16 *Seq,
-                      u16 *Status, char ChlgText[]);
-
-BOOLEAN PeerAssocRspSanity(struct rt_rtmp_adapter *pAd, void *pMsg, unsigned long MsgLen, u8 *pAddr2, u16 *pCapabilityInfo, u16 *pStatus, u16 *pAid, u8 SupRate[], u8 *pSupRateLen, u8 ExtRate[], u8 *pExtRateLen, struct rt_ht_capability_ie *pHtCapability, struct rt_add_ht_info_ie *pAddHtInfo,    /* AP might use this additional ht info IE */
-                          u8 *pHtCapabilityLen,
-                          u8 *pAddHtInfoLen,
-                          u8 *pNewExtChannelOffset,
-                          struct rt_edca_parm *pEdcaParm, u8 *pCkipFlag);
-
-BOOLEAN PeerDisassocSanity(struct rt_rtmp_adapter *pAd,
-                          void *Msg,
-                          unsigned long MsgLen,
-                          u8 *pAddr2, u16 *Reason);
-
-BOOLEAN PeerWpaMessageSanity(struct rt_rtmp_adapter *pAd,
-                            struct rt_eapol_packet *pMsg,
-                            unsigned long MsgLen,
-                            u8 MsgType, struct rt_mac_table_entry *pEntry);
-
-BOOLEAN PeerDeauthSanity(struct rt_rtmp_adapter *pAd,
-                        void *Msg,
-                        unsigned long MsgLen,
-                        u8 *pAddr2, u16 *Reason);
-
-BOOLEAN PeerProbeReqSanity(struct rt_rtmp_adapter *pAd,
-                          void *Msg,
-                          unsigned long MsgLen,
-                          u8 *pAddr2,
-                          char Ssid[], u8 *pSsidLen);
-
-BOOLEAN GetTimBit(char *Ptr,
-                 u16 Aid,
-                 u8 *TimLen,
-                 u8 *BcastFlag,
-                 u8 *DtimCount,
-                 u8 *DtimPeriod, u8 *MessageToMe);
-
-u8 ChannelSanity(struct rt_rtmp_adapter *pAd, u8 channel);
-
-NDIS_802_11_NETWORK_TYPE NetworkTypeInUseSanity(struct rt_bss_entry *pBss);
-
-BOOLEAN MlmeDelBAReqSanity(struct rt_rtmp_adapter *pAd,
-                          void *Msg, unsigned long MsgLen);
-
-BOOLEAN MlmeAddBAReqSanity(struct rt_rtmp_adapter *pAd,
-                          void *Msg, unsigned long MsgLen, u8 *pAddr2);
-
-unsigned long MakeOutgoingFrame(u8 *Buffer, unsigned long *Length, ...);
-
-void LfsrInit(struct rt_rtmp_adapter *pAd, unsigned long Seed);
-
-u8 RandomByte(struct rt_rtmp_adapter *pAd);
-
-void AsicUpdateAutoFallBackTable(struct rt_rtmp_adapter *pAd, u8 *pTxRate);
-
-void MlmePeriodicExec(void *SystemSpecific1,
-                     void *FunctionContext,
-                     void *SystemSpecific2, void *SystemSpecific3);
-
-void LinkDownExec(void *SystemSpecific1,
-                 void *FunctionContext,
-                 void *SystemSpecific2, void *SystemSpecific3);
-
-void STAMlmePeriodicExec(struct rt_rtmp_adapter *pAd);
-
-void MlmeAutoScan(struct rt_rtmp_adapter *pAd);
-
-void MlmeAutoReconnectLastSSID(struct rt_rtmp_adapter *pAd);
-
-BOOLEAN MlmeValidateSSID(u8 *pSsid, u8 SsidLen);
-
-void MlmeCheckForRoaming(struct rt_rtmp_adapter *pAd, unsigned long Now32);
-
-BOOLEAN MlmeCheckForFastRoaming(struct rt_rtmp_adapter *pAd);
-
-void MlmeDynamicTxRateSwitching(struct rt_rtmp_adapter *pAd);
-
-void MlmeSetTxRate(struct rt_rtmp_adapter *pAd,
-                  struct rt_mac_table_entry *pEntry, struct rt_rtmp_tx_rate_switch * pTxRate);
-
-void MlmeSelectTxRateTable(struct rt_rtmp_adapter *pAd,
-                          struct rt_mac_table_entry *pEntry,
-                          u8 **ppTable,
-                          u8 *pTableSize, u8 *pInitTxRateIdx);
-
-void MlmeCalculateChannelQuality(struct rt_rtmp_adapter *pAd,
-                                struct rt_mac_table_entry *pMacEntry, unsigned long Now);
-
-void MlmeCheckPsmChange(struct rt_rtmp_adapter *pAd, unsigned long Now32);
-
-void MlmeSetPsmBit(struct rt_rtmp_adapter *pAd, u16 psm);
-
-void MlmeSetTxPreamble(struct rt_rtmp_adapter *pAd, u16 TxPreamble);
-
-void UpdateBasicRateBitmap(struct rt_rtmp_adapter *pAd);
-
-void MlmeUpdateTxRates(struct rt_rtmp_adapter *pAd,
-                      IN BOOLEAN bLinkUp, u8 apidx);
-
-void MlmeUpdateHtTxRates(struct rt_rtmp_adapter *pAd, u8 apidx);
-
-void RTMPCheckRates(struct rt_rtmp_adapter *pAd,
-                   IN u8 SupRate[], IN u8 *SupRateLen);
-
-BOOLEAN RTMPCheckChannel(struct rt_rtmp_adapter *pAd,
-                        u8 CentralChannel, u8 Channel);
-
-BOOLEAN RTMPCheckHt(struct rt_rtmp_adapter *pAd,
-                   u8 Wcid,
-                   struct rt_ht_capability_ie *pHtCapability,
-                   struct rt_add_ht_info_ie *pAddHtInfo);
-
-void StaQuickResponeForRateUpExec(void *SystemSpecific1,
-                                 void *FunctionContext,
-                                 void *SystemSpecific2,
-                                 void *SystemSpecific3);
-
-void RTMPUpdateMlmeRate(struct rt_rtmp_adapter *pAd);
-
-char RTMPMaxRssi(struct rt_rtmp_adapter *pAd,
-                char Rssi0, char Rssi1, char Rssi2);
-
-#ifdef RT30xx
-void AsicSetRxAnt(struct rt_rtmp_adapter *pAd, u8 Ant);
-
-void RTMPFilterCalibration(struct rt_rtmp_adapter *pAd);
-
-#ifdef RTMP_EFUSE_SUPPORT
-/*2008/09/11:KH add to support efuse<-- */
-int set_eFuseGetFreeBlockCount_Proc(struct rt_rtmp_adapter *pAd, char *arg);
-
-int set_eFusedump_Proc(struct rt_rtmp_adapter *pAd, char *arg);
-
-void eFusePhysicalReadRegisters(struct rt_rtmp_adapter *pAd,
-                               u16 Offset,
-                               u16 Length, u16 *pData);
-
-int RtmpEfuseSupportCheck(struct rt_rtmp_adapter *pAd);
-
-void eFuseGetFreeBlockCount(struct rt_rtmp_adapter *pAd, u32 *EfuseFreeBlock);
-
-int eFuse_init(struct rt_rtmp_adapter *pAd);
-/*2008/09/11:KH add to support efuse--> */
-#endif /* RTMP_EFUSE_SUPPORT // */
-
-/* add by johnli, RF power sequence setup */
-void RT30xxLoadRFNormalModeSetup(struct rt_rtmp_adapter *pAd);
-
-void RT30xxLoadRFSleepModeSetup(struct rt_rtmp_adapter *pAd);
-
-void RT30xxReverseRFSleepModeSetup(struct rt_rtmp_adapter *pAd);
-/* end johnli */
-
-#ifdef RT3070
-void NICInitRT3070RFRegisters(struct rt_rtmp_adapter *pAd);
-#endif /* RT3070 // */
-#ifdef RT3090
-void NICInitRT3090RFRegisters(struct rt_rtmp_adapter *pAd);
-#endif /* RT3090 // */
-
-void RT30xxHaltAction(struct rt_rtmp_adapter *pAd);
-
-void RT30xxSetRxAnt(struct rt_rtmp_adapter *pAd, u8 Ant);
-#endif /* RT30xx // */
-
-void AsicEvaluateRxAnt(struct rt_rtmp_adapter *pAd);
-
-void AsicRxAntEvalTimeout(void *SystemSpecific1,
-                         void *FunctionContext,
-                         void *SystemSpecific2, void *SystemSpecific3);
-
-void APSDPeriodicExec(void *SystemSpecific1,
-                     void *FunctionContext,
-                     void *SystemSpecific2, void *SystemSpecific3);
-
-BOOLEAN RTMPCheckEntryEnableAutoRateSwitch(struct rt_rtmp_adapter *pAd,
-                                          struct rt_mac_table_entry *pEntry);
-
-u8 RTMPStaFixedTxMode(struct rt_rtmp_adapter *pAd, struct rt_mac_table_entry *pEntry);
-
-void RTMPUpdateLegacyTxSetting(u8 fixed_tx_mode, struct rt_mac_table_entry *pEntry);
-
-BOOLEAN RTMPAutoRateSwitchCheck(struct rt_rtmp_adapter *pAd);
-
-int MlmeInit(struct rt_rtmp_adapter *pAd);
-
-void MlmeHandler(struct rt_rtmp_adapter *pAd);
-
-void MlmeHalt(struct rt_rtmp_adapter *pAd);
-
-void MlmeResetRalinkCounters(struct rt_rtmp_adapter *pAd);
-
-void BuildChannelList(struct rt_rtmp_adapter *pAd);
-
-u8 FirstChannel(struct rt_rtmp_adapter *pAd);
-
-u8 NextChannel(struct rt_rtmp_adapter *pAd, u8 channel);
-
-void ChangeToCellPowerLimit(struct rt_rtmp_adapter *pAd,
-                           u8 AironetCellPowerLimit);
-
-/* */
-/* Prototypes of function definition in rtmp_tkip.c */
-/* */
-void RTMPInitTkipEngine(struct rt_rtmp_adapter *pAd,
-                       u8 *pTKey,
-                       u8 KeyId,
-                       u8 *pTA,
-                       u8 *pMICKey,
-                       u8 *pTSC, unsigned long *pIV16, unsigned long *pIV32);
-
-void RTMPInitMICEngine(struct rt_rtmp_adapter *pAd,
-                      u8 *pKey,
-                      u8 *pDA,
-                      u8 *pSA, u8 UserPriority, u8 *pMICKey);
-
-BOOLEAN RTMPTkipCompareMICValue(struct rt_rtmp_adapter *pAd,
-                               u8 *pSrc,
-                               u8 *pDA,
-                               u8 *pSA,
-                               u8 *pMICKey,
-                               u8 UserPriority, u32 Len);
-
-void RTMPCalculateMICValue(struct rt_rtmp_adapter *pAd,
-                          void *pPacket,
-                          u8 *pEncap,
-                          struct rt_cipher_key *pKey, u8 apidx);
-
-void RTMPTkipAppendByte(struct rt_tkip_key_info *pTkip, u8 uChar);
-
-void RTMPTkipAppend(struct rt_tkip_key_info *pTkip, u8 *pSrc, u32 nBytes);
-
-void RTMPTkipGetMIC(struct rt_tkip_key_info *pTkip);
-
-BOOLEAN RTMPSoftDecryptTKIP(struct rt_rtmp_adapter *pAd,
-                           u8 *pData,
-                           unsigned long DataByteCnt,
-                           u8 UserPriority, struct rt_cipher_key *pWpaKey);
-
-BOOLEAN RTMPSoftDecryptAES(struct rt_rtmp_adapter *pAd,
-                          u8 *pData,
-                          unsigned long DataByteCnt, struct rt_cipher_key *pWpaKey);
-
-/* */
-/* Prototypes of function definition in cmm_info.c */
-/* */
-int RT_CfgSetCountryRegion(struct rt_rtmp_adapter *pAd, char *arg, int band);
-
-int RT_CfgSetWirelessMode(struct rt_rtmp_adapter *pAd, char *arg);
-
-int RT_CfgSetShortSlot(struct rt_rtmp_adapter *pAd, char *arg);
-
-int RT_CfgSetWepKey(struct rt_rtmp_adapter *pAd,
-                   char *keyString,
-                   struct rt_cipher_key *pSharedKey, int keyIdx);
-
-int RT_CfgSetWPAPSKKey(struct rt_rtmp_adapter *pAd,
-                      char *keyString,
-                      u8 *pHashStr,
-                      int hashStrLen, u8 *pPMKBuf);
-
-/* */
-/* Prototypes of function definition in cmm_info.c */
-/* */
-void RTMPWPARemoveAllKeys(struct rt_rtmp_adapter *pAd);
-
-void RTMPSetPhyMode(struct rt_rtmp_adapter *pAd, unsigned long phymode);
-
-void RTMPUpdateHTIE(struct rt_ht_capability *pRtHt,
-                   u8 *pMcsSet,
-                   struct rt_ht_capability_ie *pHtCapability,
-                   struct rt_add_ht_info_ie *pAddHtInfo);
-
-void RTMPAddWcidAttributeEntry(struct rt_rtmp_adapter *pAd,
-                              u8 BssIdx,
-                              u8 KeyIdx,
-                              u8 CipherAlg, struct rt_mac_table_entry *pEntry);
-
-char *GetEncryptType(char enc);
-
-char *GetAuthMode(char auth);
-
-void RTMPSetHT(struct rt_rtmp_adapter *pAd, struct rt_oid_set_ht_phymode *pHTPhyMode);
-
-void RTMPSetIndividualHT(struct rt_rtmp_adapter *pAd, u8 apidx);
-
-void RTMPSendWirelessEvent(struct rt_rtmp_adapter *pAd,
-                          u16 Event_flag,
-                          u8 *pAddr, u8 BssIdx, char Rssi);
-
-char ConvertToRssi(struct rt_rtmp_adapter *pAd, char Rssi, u8 RssiNumber);
-
-/*===================================
-       Function prototype in cmm_wpa.c
-  =================================== */
-void RTMPToWirelessSta(struct rt_rtmp_adapter *pAd,
-                      struct rt_mac_table_entry *pEntry,
-                      u8 *pHeader802_3,
-                      u32 HdrLen,
-                      u8 *pData,
-                      u32 DataLen, IN BOOLEAN bClearFrame);
-
-void WpaDerivePTK(struct rt_rtmp_adapter *pAd,
-                 u8 *PMK,
-                 u8 *ANonce,
-                 u8 *AA,
-                 u8 *SNonce,
-                 u8 *SA, u8 *output, u32 len);
-
-void GenRandom(struct rt_rtmp_adapter *pAd, u8 *macAddr, u8 *random);
-
-BOOLEAN RTMPCheckWPAframe(struct rt_rtmp_adapter *pAd,
-                         struct rt_mac_table_entry *pEntry,
-                         u8 *pData,
-                         unsigned long DataByteCount, u8 FromWhichBSSID);
-
-void AES_GTK_KEY_UNWRAP(u8 *key,
-                       u8 *plaintext,
-                       u32 c_len, u8 *ciphertext);
-
-BOOLEAN RTMPParseEapolKeyData(struct rt_rtmp_adapter *pAd,
-                             u8 *pKeyData,
-                             u8 KeyDataLen,
-                             u8 GroupKeyIndex,
-                             u8 MsgType,
-                             IN BOOLEAN bWPA2, struct rt_mac_table_entry *pEntry);
-
-void ConstructEapolMsg(struct rt_mac_table_entry *pEntry,
-                      u8 GroupKeyWepStatus,
-                      u8 MsgType,
-                      u8 DefaultKeyIdx,
-                      u8 *KeyNonce,
-                      u8 *TxRSC,
-                      u8 *GTK,
-                      u8 *RSNIE,
-                      u8 RSNIE_Len, struct rt_eapol_packet *pMsg);
-
-int RTMPSoftDecryptBroadCastData(struct rt_rtmp_adapter *pAd,
-                                        struct rt_rx_blk *pRxBlk,
-                                        IN NDIS_802_11_ENCRYPTION_STATUS
-                                        GroupCipher,
-                                        struct rt_cipher_key *pShard_key);
-
-void RTMPMakeRSNIE(struct rt_rtmp_adapter *pAd,
-                  u32 AuthMode, u32 WepStatus, u8 apidx);
-
-/* */
-/* function prototype in ap_wpa.c */
-/* */
-void RTMPGetTxTscFromAsic(struct rt_rtmp_adapter *pAd,
-                         u8 apidx, u8 *pTxTsc);
-
-void APInstallPairwiseKey(struct rt_rtmp_adapter *pAd, struct rt_mac_table_entry *pEntry);
-
-u32 APValidateRSNIE(struct rt_rtmp_adapter *pAd,
-                    struct rt_mac_table_entry *pEntry,
-                    u8 *pRsnIe, u8 rsnie_len);
-
-void HandleCounterMeasure(struct rt_rtmp_adapter *pAd, struct rt_mac_table_entry *pEntry);
-
-void WPAStart4WayHS(struct rt_rtmp_adapter *pAd,
-                   struct rt_mac_table_entry *pEntry, unsigned long TimeInterval);
-
-void WPAStart2WayGroupHS(struct rt_rtmp_adapter *pAd, struct rt_mac_table_entry *pEntry);
-
-void PeerPairMsg1Action(struct rt_rtmp_adapter *pAd,
-                       struct rt_mac_table_entry *pEntry, struct rt_mlme_queue_elem *Elem);
-
-void PeerPairMsg2Action(struct rt_rtmp_adapter *pAd,
-                       struct rt_mac_table_entry *pEntry, struct rt_mlme_queue_elem *Elem);
-
-void PeerPairMsg3Action(struct rt_rtmp_adapter *pAd,
-                       struct rt_mac_table_entry *pEntry, struct rt_mlme_queue_elem *Elem);
-
-void PeerPairMsg4Action(struct rt_rtmp_adapter *pAd,
-                       struct rt_mac_table_entry *pEntry, struct rt_mlme_queue_elem *Elem);
-
-void PeerGroupMsg1Action(struct rt_rtmp_adapter *pAd,
-                        struct rt_mac_table_entry *pEntry, struct rt_mlme_queue_elem *Elem);
-
-void PeerGroupMsg2Action(struct rt_rtmp_adapter *pAd,
-                        struct rt_mac_table_entry *pEntry,
-                        void *Msg, u32 MsgLen);
-
-void WpaDeriveGTK(u8 *PMK,
-                 u8 *GNonce,
-                 u8 *AA, u8 *output, u32 len);
-
-void AES_GTK_KEY_WRAP(u8 *key,
-                     u8 *plaintext,
-                     u32 p_len, u8 *ciphertext);
-
-/*typedef void (*TIMER_FUNCTION)(unsigned long); */
-
-/* timeout -- ms */
-void RTMP_SetPeriodicTimer(struct timer_list *pTimer,
-                          IN unsigned long timeout);
-
-void RTMP_OS_Init_Timer(struct rt_rtmp_adapter *pAd,
-                       struct timer_list *pTimer,
-                       IN TIMER_FUNCTION function, void *data);
-
-void RTMP_OS_Add_Timer(struct timer_list *pTimer,
-                      IN unsigned long timeout);
-
-void RTMP_OS_Mod_Timer(struct timer_list *pTimer,
-                      IN unsigned long timeout);
-
-void RTMP_OS_Del_Timer(struct timer_list *pTimer,
-                      OUT BOOLEAN *pCancelled);
-
-void RTMP_OS_Release_Packet(struct rt_rtmp_adapter *pAd, struct rt_queue_entry *pEntry);
-
-void RTMPusecDelay(unsigned long usec);
-
-int os_alloc_mem(struct rt_rtmp_adapter *pAd,
-                        u8 **mem, unsigned long size);
-
-int os_free_mem(struct rt_rtmp_adapter *pAd, void *mem);
-
-void RTMP_AllocateSharedMemory(struct rt_rtmp_adapter *pAd,
-                              unsigned long Length,
-                              IN BOOLEAN Cached,
-                              void **VirtualAddress,
-                              dma_addr_t *PhysicalAddress);
-
-void RTMPFreeTxRxRingMemory(struct rt_rtmp_adapter *pAd);
-
-int AdapterBlockAllocateMemory(void *handle, void **ppAd);
-
-void RTMP_AllocateTxDescMemory(struct rt_rtmp_adapter *pAd,
-                              u32 Index,
-                              unsigned long Length,
-                              IN BOOLEAN Cached,
-                              void **VirtualAddress,
-                              dma_addr_t *PhysicalAddress);
-
-void RTMP_AllocateFirstTxBuffer(struct rt_rtmp_adapter *pAd,
-                               u32 Index,
-                               unsigned long Length,
-                               IN BOOLEAN Cached,
-                               void **VirtualAddress,
-                               dma_addr_t *PhysicalAddress);
-
-void RTMP_FreeFirstTxBuffer(struct rt_rtmp_adapter *pAd,
-                           unsigned long Length,
-                           IN BOOLEAN Cached,
-                           void *VirtualAddress,
-                           dma_addr_t PhysicalAddress);
-
-void RTMP_AllocateMgmtDescMemory(struct rt_rtmp_adapter *pAd,
-                                unsigned long Length,
-                                IN BOOLEAN Cached,
-                                void **VirtualAddress,
-                                dma_addr_t *PhysicalAddress);
-
-void RTMP_AllocateRxDescMemory(struct rt_rtmp_adapter *pAd,
-                              unsigned long Length,
-                              IN BOOLEAN Cached,
-                              void **VirtualAddress,
-                              dma_addr_t *PhysicalAddress);
-
-void RTMP_FreeDescMemory(struct rt_rtmp_adapter *pAd,
-                        unsigned long Length,
-                        void *VirtualAddress,
-                        dma_addr_t PhysicalAddress);
-
-void *RtmpOSNetPktAlloc(struct rt_rtmp_adapter *pAd, IN int size);
-
-void *RTMP_AllocateRxPacketBuffer(struct rt_rtmp_adapter *pAd,
-                                        unsigned long Length,
-                                        IN BOOLEAN Cached,
-                                        void **VirtualAddress,
-                                        OUT dma_addr_t *PhysicalAddress);
-
-void *RTMP_AllocateTxPacketBuffer(struct rt_rtmp_adapter *pAd,
-                                        unsigned long Length,
-                                        IN BOOLEAN Cached,
-                                        void **VirtualAddress);
-
-void *RTMP_AllocateFragPacketBuffer(struct rt_rtmp_adapter *pAd,
-                                          unsigned long Length);
-
-void RTMP_QueryPacketInfo(void *pPacket,
-                         struct rt_packet_info *pPacketInfo,
-                         u8 **pSrcBufVA, u32 *pSrcBufLen);
-
-void RTMP_QueryNextPacketInfo(void **ppPacket,
-                             struct rt_packet_info *pPacketInfo,
-                             u8 **pSrcBufVA, u32 *pSrcBufLen);
-
-BOOLEAN RTMP_FillTxBlkInfo(struct rt_rtmp_adapter *pAd, struct rt_tx_blk *pTxBlk);
-
-struct rt_rtmp_sg_list *rt_get_sg_list_from_packet(void *pPacket,
-                                               struct rt_rtmp_sg_list *sg);
-
-void announce_802_3_packet(struct rt_rtmp_adapter *pAd, void *pPacket);
-
-u32 BA_Reorder_AMSDU_Announce(struct rt_rtmp_adapter *pAd, void *pPacket);
-
-struct net_device *get_netdev_from_bssid(struct rt_rtmp_adapter *pAd, u8 FromWhichBSSID);
-
-void *duplicate_pkt(struct rt_rtmp_adapter *pAd,
-                          u8 *pHeader802_3,
-                          u32 HdrLen,
-                          u8 *pData,
-                          unsigned long DataSize, u8 FromWhichBSSID);
-
-void *duplicate_pkt_with_TKIP_MIC(struct rt_rtmp_adapter *pAd,
-                                        void *pOldPkt);
-
-void ba_flush_reordering_timeout_mpdus(struct rt_rtmp_adapter *pAd,
-                                      struct rt_ba_rec_entry *pBAEntry,
-                                      unsigned long Now32);
-
-void BAOriSessionSetUp(struct rt_rtmp_adapter *pAd,
-                      struct rt_mac_table_entry *pEntry,
-                      u8 TID,
-                      u16 TimeOut,
-                      unsigned long DelayTime, IN BOOLEAN isForced);
-
-void BASessionTearDownALL(struct rt_rtmp_adapter *pAd, u8 Wcid);
-
-BOOLEAN OS_Need_Clone_Packet(void);
-
-void build_tx_packet(struct rt_rtmp_adapter *pAd,
-                    void *pPacket,
-                    u8 *pFrame, unsigned long FrameLen);
-
-void BAOriSessionTearDown(struct rt_rtmp_adapter *pAd,
-                         u8 Wcid,
-                         u8 TID,
-                         IN BOOLEAN bPassive, IN BOOLEAN bForceSend);
-
-void BARecSessionTearDown(struct rt_rtmp_adapter *pAd,
-                         u8 Wcid, u8 TID, IN BOOLEAN bPassive);
-
-BOOLEAN ba_reordering_resource_init(struct rt_rtmp_adapter *pAd, int num);
-void ba_reordering_resource_release(struct rt_rtmp_adapter *pAd);
-
-char *rstrtok(char *s, IN const char *ct);
-
-/*//////// common ioctl functions ////////// */
-int SetCommonHT(struct rt_rtmp_adapter *pAd);
-
-int WpaCheckEapCode(struct rt_rtmp_adapter *pAd,
-                   u8 *pFrame, u16 FrameLen, u16 OffSet);
-
-void WpaSendMicFailureToWpaSupplicant(struct rt_rtmp_adapter *pAd,
-                                     IN BOOLEAN bUnicast);
-
-int wext_notify_event_assoc(struct rt_rtmp_adapter *pAd);
-
-BOOLEAN STARxDoneInterruptHandle(struct rt_rtmp_adapter *pAd, IN BOOLEAN argc);
-
-/* AMPDU packet indication */
-void Indicate_AMPDU_Packet(struct rt_rtmp_adapter *pAd,
-                          struct rt_rx_blk *pRxBlk, u8 FromWhichBSSID);
-
-/* AMSDU packet indication */
-void Indicate_AMSDU_Packet(struct rt_rtmp_adapter *pAd,
-                          struct rt_rx_blk *pRxBlk, u8 FromWhichBSSID);
-
-/* Normal legacy Rx packet indication */
-void Indicate_Legacy_Packet(struct rt_rtmp_adapter *pAd,
-                           struct rt_rx_blk *pRxBlk, u8 FromWhichBSSID);
-
-void Indicate_EAPOL_Packet(struct rt_rtmp_adapter *pAd,
-                          struct rt_rx_blk *pRxBlk, u8 FromWhichBSSID);
-
-void update_os_packet_info(struct rt_rtmp_adapter *pAd,
-                          struct rt_rx_blk *pRxBlk, u8 FromWhichBSSID);
-
-void wlan_802_11_to_802_3_packet(struct rt_rtmp_adapter *pAd,
-                                struct rt_rx_blk *pRxBlk,
-                                u8 *pHeader802_3,
-                                u8 FromWhichBSSID);
-
-/* remove LLC and get 802_3 Header */
-#define  RTMP_802_11_REMOVE_LLC_AND_CONVERT_TO_802_3(_pRxBlk, _pHeader802_3)   \
-{                                                                                                                                                              \
-       u8 *_pRemovedLLCSNAP = NULL, *_pDA, *_pSA;                                 \
-                                                                                                                                                               \
-       if (RX_BLK_TEST_FLAG(_pRxBlk, fRX_MESH))        {            \
-               _pDA = _pRxBlk->pHeader->Addr3;                                         \
-               _pSA = (u8 *)_pRxBlk->pHeader + sizeof(struct rt_header_802_11);                \
-       }                                                                           \
-       else    {\
-               if (RX_BLK_TEST_FLAG(_pRxBlk, fRX_INFRA))       {\
-                       _pDA = _pRxBlk->pHeader->Addr1;                                     \
-               if (RX_BLK_TEST_FLAG(_pRxBlk, fRX_DLS))                                                                 \
-                       _pSA = _pRxBlk->pHeader->Addr2;                                                                         \
-               else                                                                                                                                    \
-                       _pSA = _pRxBlk->pHeader->Addr3;                                     \
-               }                                                                       \
-               else    {       \
-                       _pDA = _pRxBlk->pHeader->Addr1;                                     \
-                       _pSA = _pRxBlk->pHeader->Addr2;                                     \
-               }                                                                       \
-       }                                                                           \
-                                                                                                                                                               \
-       CONVERT_TO_802_3(_pHeader802_3, _pDA, _pSA, _pRxBlk->pData,                             \
-               _pRxBlk->DataSize, _pRemovedLLCSNAP);                                   \
-}
-
-void Sta_Announce_or_Forward_802_3_Packet(struct rt_rtmp_adapter *pAd,
-                                         void *pPacket,
-                                         u8 FromWhichBSSID);
-
-#define ANNOUNCE_OR_FORWARD_802_3_PACKET(_pAd, _pPacket, _FromWhichBSS)\
-                       Sta_Announce_or_Forward_802_3_Packet(_pAd, _pPacket, _FromWhichBSS);
-                       /*announce_802_3_packet(_pAd, _pPacket); */
-
-void *DuplicatePacket(struct rt_rtmp_adapter *pAd,
-                            void *pPacket, u8 FromWhichBSSID);
-
-void *ClonePacket(struct rt_rtmp_adapter *pAd,
-                        void *pPacket,
-                        u8 *pData, unsigned long DataSize);
-
-/* Normal, AMPDU or AMSDU */
-void CmmRxnonRalinkFrameIndicate(struct rt_rtmp_adapter *pAd,
-                                struct rt_rx_blk *pRxBlk, u8 FromWhichBSSID);
-
-void CmmRxRalinkFrameIndicate(struct rt_rtmp_adapter *pAd,
-                             struct rt_mac_table_entry *pEntry,
-                             struct rt_rx_blk *pRxBlk, u8 FromWhichBSSID);
-
-void Update_Rssi_Sample(struct rt_rtmp_adapter *pAd,
-                       struct rt_rssi_sample *pRssi, struct rt_rxwi * pRxWI);
-
-void *GetPacketFromRxRing(struct rt_rtmp_adapter *pAd,
-                                OUT PRT28XX_RXD_STRUC pSaveRxD,
-                                OUT BOOLEAN *pbReschedule,
-                                IN u32 *pRxPending);
-
-void *RTMPDeFragmentDataFrame(struct rt_rtmp_adapter *pAd, struct rt_rx_blk *pRxBlk);
-
-enum {
-       DIDmsg_lnxind_wlansniffrm = 0x00000044,
-       DIDmsg_lnxind_wlansniffrm_hosttime = 0x00010044,
-       DIDmsg_lnxind_wlansniffrm_mactime = 0x00020044,
-       DIDmsg_lnxind_wlansniffrm_channel = 0x00030044,
-       DIDmsg_lnxind_wlansniffrm_rssi = 0x00040044,
-       DIDmsg_lnxind_wlansniffrm_sq = 0x00050044,
-       DIDmsg_lnxind_wlansniffrm_signal = 0x00060044,
-       DIDmsg_lnxind_wlansniffrm_noise = 0x00070044,
-       DIDmsg_lnxind_wlansniffrm_rate = 0x00080044,
-       DIDmsg_lnxind_wlansniffrm_istx = 0x00090044,
-       DIDmsg_lnxind_wlansniffrm_frmlen = 0x000A0044
-};
-enum {
-       P80211ENUM_msgitem_status_no_value = 0x00
-};
-enum {
-       P80211ENUM_truth_false = 0x00,
-       P80211ENUM_truth_true = 0x01
-};
-
-/* Definition from madwifi */
-struct rt_p80211item_uint32 {
-       u32 did;
-       u16 status;
-       u16 len;
-       u32 data;
-};
-
-struct rt_wlan_ng_prism2_header {
-       u32 msgcode;
-       u32 msglen;
-#define WLAN_DEVNAMELEN_MAX 16
-       u8 devname[WLAN_DEVNAMELEN_MAX];
-       struct rt_p80211item_uint32 hosttime;
-       struct rt_p80211item_uint32 mactime;
-       struct rt_p80211item_uint32 channel;
-       struct rt_p80211item_uint32 rssi;
-       struct rt_p80211item_uint32 sq;
-       struct rt_p80211item_uint32 signal;
-       struct rt_p80211item_uint32 noise;
-       struct rt_p80211item_uint32 rate;
-       struct rt_p80211item_uint32 istx;
-       struct rt_p80211item_uint32 frmlen;
-};
-
-/* The radio capture header precedes the 802.11 header. */
-struct PACKED rt_ieee80211_radiotap_header {
-       u8 it_version;  /* Version 0. Only increases
-                                * for drastic changes,
-                                * introduction of compatible
-                                * new fields does not count.
-                                */
-       u8 it_pad;
-       u16 it_len;             /* length of the whole
-                                * header in bytes, including
-                                * it_version, it_pad,
-                                * it_len, and data fields.
-                                */
-       u32 it_present; /* A bitmap telling which
-                                * fields are present. Set bit 31
-                                * (0x80000000) to extend the
-                                * bitmap by another 32 bits.
-                                * Additional extensions are made
-                                * by setting bit 31.
-                                */
-};
-
-enum ieee80211_radiotap_type {
-       IEEE80211_RADIOTAP_TSFT = 0,
-       IEEE80211_RADIOTAP_FLAGS = 1,
-       IEEE80211_RADIOTAP_RATE = 2,
-       IEEE80211_RADIOTAP_CHANNEL = 3,
-       IEEE80211_RADIOTAP_FHSS = 4,
-       IEEE80211_RADIOTAP_DBM_ANTSIGNAL = 5,
-       IEEE80211_RADIOTAP_DBM_ANTNOISE = 6,
-       IEEE80211_RADIOTAP_LOCK_QUALITY = 7,
-       IEEE80211_RADIOTAP_TX_ATTENUATION = 8,
-       IEEE80211_RADIOTAP_DB_TX_ATTENUATION = 9,
-       IEEE80211_RADIOTAP_DBM_TX_POWER = 10,
-       IEEE80211_RADIOTAP_ANTENNA = 11,
-       IEEE80211_RADIOTAP_DB_ANTSIGNAL = 12,
-       IEEE80211_RADIOTAP_DB_ANTNOISE = 13
-};
-
-#define WLAN_RADIOTAP_PRESENT (                        \
-       (1 << IEEE80211_RADIOTAP_TSFT)  |       \
-       (1 << IEEE80211_RADIOTAP_FLAGS) |       \
-       (1 << IEEE80211_RADIOTAP_RATE)  |       \
-        0)
-
-struct rt_wlan_radiotap_header {
-       struct rt_ieee80211_radiotap_header wt_ihdr;
-       long long wt_tsft;
-       u8 wt_flags;
-       u8 wt_rate;
-};
-/* Definition from madwifi */
-
-void send_monitor_packets(struct rt_rtmp_adapter *pAd, struct rt_rx_blk *pRxBlk);
-
-void RTMPSetDesiredRates(struct rt_rtmp_adapter *pAdapter, long Rates);
-
-int Set_FixedTxMode_Proc(struct rt_rtmp_adapter *pAd, char *arg);
-
-BOOLEAN RT28XXChipsetCheck(IN void *_dev_p);
-
-void RT28XXDMADisable(struct rt_rtmp_adapter *pAd);
-
-void RT28XXDMAEnable(struct rt_rtmp_adapter *pAd);
-
-void RT28xx_UpdateBeaconToAsic(struct rt_rtmp_adapter *pAd,
-                              int apidx,
-                              unsigned long BeaconLen, unsigned long UpdatePos);
-
-int rt28xx_init(struct rt_rtmp_adapter *pAd,
-               char *pDefaultMac, char *pHostName);
-
-int RtmpNetTaskInit(struct rt_rtmp_adapter *pAd);
-
-void RtmpNetTaskExit(struct rt_rtmp_adapter *pAd);
-
-int RtmpMgmtTaskInit(struct rt_rtmp_adapter *pAd);
-
-void RtmpMgmtTaskExit(struct rt_rtmp_adapter *pAd);
-
-void tbtt_tasklet(unsigned long data);
-
-struct net_device *RtmpPhyNetDevInit(struct rt_rtmp_adapter *pAd,
-                          struct rt_rtmp_os_netdev_op_hook *pNetHook);
-
-BOOLEAN RtmpPhyNetDevExit(struct rt_rtmp_adapter *pAd, struct net_device *net_dev);
-
-int RtmpRaDevCtrlInit(struct rt_rtmp_adapter *pAd, IN RTMP_INF_TYPE infType);
-
-BOOLEAN RtmpRaDevCtrlExit(struct rt_rtmp_adapter *pAd);
-
-#ifdef RTMP_MAC_PCI
-/* */
-/* Function Prototype in cmm_data_pci.c */
-/* */
-u16 RtmpPCI_WriteTxResource(struct rt_rtmp_adapter *pAd,
-                              struct rt_tx_blk *pTxBlk,
-                              IN BOOLEAN bIsLast, u16 *FreeNumber);
-
-u16 RtmpPCI_WriteSingleTxResource(struct rt_rtmp_adapter *pAd,
-                                    struct rt_tx_blk *pTxBlk,
-                                    IN BOOLEAN bIsLast,
-                                    u16 *FreeNumber);
-
-u16 RtmpPCI_WriteMultiTxResource(struct rt_rtmp_adapter *pAd,
-                                   struct rt_tx_blk *pTxBlk,
-                                   u8 frameNum, u16 *FreeNumber);
-
-u16 RtmpPCI_WriteFragTxResource(struct rt_rtmp_adapter *pAd,
-                                  struct rt_tx_blk *pTxBlk,
-                                  u8 fragNum, u16 *FreeNumber);
-
-u16 RtmpPCI_WriteSubTxResource(struct rt_rtmp_adapter *pAd,
-                                 struct rt_tx_blk *pTxBlk,
-                                 IN BOOLEAN bIsLast, u16 *FreeNumber);
-
-void RtmpPCI_FinalWriteTxResource(struct rt_rtmp_adapter *pAd,
-                                 struct rt_tx_blk *pTxBlk,
-                                 u16 totalMPDUSize,
-                                 u16 FirstTxIdx);
-
-void RtmpPCIDataLastTxIdx(struct rt_rtmp_adapter *pAd,
-                         u8 QueIdx, u16 LastTxIdx);
-
-void RtmpPCIDataKickOut(struct rt_rtmp_adapter *pAd,
-                       struct rt_tx_blk *pTxBlk, u8 QueIdx);
-
-int RtmpPCIMgmtKickOut(struct rt_rtmp_adapter *pAd,
-                      u8 QueIdx,
-                      void *pPacket,
-                      u8 *pSrcBufVA, u32 SrcBufLen);
-
-int RTMPCheckRxError(struct rt_rtmp_adapter *pAd,
-                            struct rt_header_802_11 *pHeader,
-                            struct rt_rxwi *pRxWI, IN PRT28XX_RXD_STRUC pRxD);
-
-BOOLEAN RT28xxPciAsicRadioOff(struct rt_rtmp_adapter *pAd,
-                             u8 Level, u16 TbttNumToNextWakeUp);
-
-BOOLEAN RT28xxPciAsicRadioOn(struct rt_rtmp_adapter *pAd, u8 Level);
-
-void RTMPInitPCIeLinkCtrlValue(struct rt_rtmp_adapter *pAd);
-
-void RTMPFindHostPCIDev(struct rt_rtmp_adapter *pAd);
-
-void RTMPPCIeLinkCtrlValueRestore(struct rt_rtmp_adapter *pAd, u8 Level);
-
-void RTMPPCIeLinkCtrlSetting(struct rt_rtmp_adapter *pAd, u16 Max);
-
-void RTMPrt3xSetPCIePowerLinkCtrl(struct rt_rtmp_adapter *pAd);
-
-void PsPollWakeExec(void *SystemSpecific1,
-                   void *FunctionContext,
-                   void *SystemSpecific2, void *SystemSpecific3);
-
-void RadioOnExec(void *SystemSpecific1,
-                void *FunctionContext,
-                void *SystemSpecific2, void *SystemSpecific3);
-
-void RT28xxPciStaAsicForceWakeup(struct rt_rtmp_adapter *pAd, IN BOOLEAN bFromTx);
-
-void RT28xxPciStaAsicSleepThenAutoWakeup(struct rt_rtmp_adapter *pAd,
-                                        u16 TbttNumToNextWakeUp);
-
-void RT28xxPciMlmeRadioOn(struct rt_rtmp_adapter *pAd);
-
-void RT28xxPciMlmeRadioOFF(struct rt_rtmp_adapter *pAd);
-#endif /* RTMP_MAC_PCI // */
-
-#ifdef RTMP_MAC_USB
-/* */
-/* Function Prototype in rtusb_bulk.c */
-/* */
-void RTUSBInitTxDesc(struct rt_rtmp_adapter *pAd,
-                    struct rt_tx_context *pTxContext,
-                    u8 BulkOutPipeId, IN usb_complete_t Func);
-
-void RTUSBInitHTTxDesc(struct rt_rtmp_adapter *pAd,
-                      struct rt_ht_tx_context *pTxContext,
-                      u8 BulkOutPipeId,
-                      unsigned long BulkOutSize, IN usb_complete_t Func);
-
-void RTUSBInitRxDesc(struct rt_rtmp_adapter *pAd, struct rt_rx_context *pRxContext);
-
-void RTUSBCleanUpDataBulkOutQueue(struct rt_rtmp_adapter *pAd);
-
-void RTUSBCancelPendingBulkOutIRP(struct rt_rtmp_adapter *pAd);
-
-void RTUSBBulkOutDataPacket(struct rt_rtmp_adapter *pAd,
-                           u8 BulkOutPipeId, u8 Index);
-
-void RTUSBBulkOutNullFrame(struct rt_rtmp_adapter *pAd);
-
-void RTUSBBulkOutRTSFrame(struct rt_rtmp_adapter *pAd);
-
-void RTUSBCancelPendingBulkInIRP(struct rt_rtmp_adapter *pAd);
-
-void RTUSBCancelPendingIRPs(struct rt_rtmp_adapter *pAd);
-
-void RTUSBBulkOutMLMEPacket(struct rt_rtmp_adapter *pAd, u8 Index);
-
-void RTUSBBulkOutPsPoll(struct rt_rtmp_adapter *pAd);
-
-void RTUSBCleanUpMLMEBulkOutQueue(struct rt_rtmp_adapter *pAd);
-
-void RTUSBKickBulkOut(struct rt_rtmp_adapter *pAd);
-
-void RTUSBBulkReceive(struct rt_rtmp_adapter *pAd);
-
-void DoBulkIn(struct rt_rtmp_adapter *pAd);
-
-void RTUSBInitRxDesc(struct rt_rtmp_adapter *pAd, struct rt_rx_context *pRxContext);
-
-void RTUSBBulkRxHandle(IN unsigned long data);
-
-/* */
-/* Function Prototype in rtusb_io.c */
-/* */
-int RTUSBMultiRead(struct rt_rtmp_adapter *pAd,
-                       u16 Offset, u8 *pData, u16 length);
-
-int RTUSBMultiWrite(struct rt_rtmp_adapter *pAd,
-                   u16 Offset, const u8 *pData, u16 length);
-
-int RTUSBMultiWrite_OneByte(struct rt_rtmp_adapter *pAd,
-                           u16 Offset, const u8 *pData);
-
-int RTUSBReadBBPRegister(struct rt_rtmp_adapter *pAd,
-                             u8 Id, u8 *pValue);
-
-int RTUSBWriteBBPRegister(struct rt_rtmp_adapter *pAd,
-                              u8 Id, u8 Value);
-
-int RTUSBWriteRFRegister(struct rt_rtmp_adapter *pAd, u32 Value);
-
-int RTUSB_VendorRequest(struct rt_rtmp_adapter *pAd,
-                            u32 TransferFlags,
-                            u8 ReservedBits,
-                            u8 Request,
-                            u16 Value,
-                            u16 Index,
-                            void *TransferBuffer,
-                            u32 TransferBufferLength);
-
-int RTUSBReadEEPROM(struct rt_rtmp_adapter *pAd,
-                        u16 Offset, u8 *pData, u16 length);
-
-int RTUSBWriteEEPROM(struct rt_rtmp_adapter *pAd,
-                         u16 Offset, u8 *pData, u16 length);
-
-void RTUSBPutToSleep(struct rt_rtmp_adapter *pAd);
-
-int RTUSBWakeUp(struct rt_rtmp_adapter *pAd);
-
-void RTUSBInitializeCmdQ(struct rt_cmdq *cmdq);
-
-int RTUSBEnqueueCmdFromNdis(struct rt_rtmp_adapter *pAd,
-                                   IN NDIS_OID Oid,
-                                   IN BOOLEAN SetInformation,
-                                   void *pInformationBuffer,
-                                   u32 InformationBufferLength);
-
-int RTUSBEnqueueInternalCmd(struct rt_rtmp_adapter *pAd,
-                                   IN NDIS_OID Oid,
-                                   void *pInformationBuffer,
-                                   u32 InformationBufferLength);
-
-void RTUSBDequeueCmd(struct rt_cmdq *cmdq, struct rt_cmdqelmt * * pcmdqelmt);
-
-int RTUSBCmdThread(IN void *Context);
-
-void RTUSBBssBeaconExit(struct rt_rtmp_adapter *pAd);
-
-void RTUSBBssBeaconStop(struct rt_rtmp_adapter *pAd);
-
-void RTUSBBssBeaconStart(struct rt_rtmp_adapter *pAd);
-
-void RTUSBBssBeaconInit(struct rt_rtmp_adapter *pAd);
-
-void RTUSBWatchDog(struct rt_rtmp_adapter *pAd);
-
-int RTUSBWriteMACRegister(struct rt_rtmp_adapter *pAd,
-                              u16 Offset, u32 Value);
-
-int RTUSBReadMACRegister(struct rt_rtmp_adapter *pAd,
-                             u16 Offset, u32 *pValue);
-
-int RTUSBSingleWrite(struct rt_rtmp_adapter *pAd,
-                         u16 Offset, u16 Value);
-
-int RTUSBFirmwareWrite(struct rt_rtmp_adapter *pAd,
-                      const u8 *pFwImage, unsigned long FwLen);
-
-int RTUSBVenderReset(struct rt_rtmp_adapter *pAd);
-
-int RTUSBSetHardWareRegister(struct rt_rtmp_adapter *pAdapter, void *pBuf);
-
-int RTUSBQueryHardWareRegister(struct rt_rtmp_adapter *pAdapter,
-                                      void *pBuf);
-
-void CMDHandler(struct rt_rtmp_adapter *pAd);
-
-int RTUSBWriteHWMACAddress(struct rt_rtmp_adapter *pAdapter);
-
-void MacTableInitialize(struct rt_rtmp_adapter *pAd);
-
-void MlmeSetPsm(struct rt_rtmp_adapter *pAd, u16 psm);
-
-int RTMPWPAAddKeyProc(struct rt_rtmp_adapter *pAd, void *pBuf);
-
-void AsicRxAntEvalAction(struct rt_rtmp_adapter *pAd);
-
-void append_pkt(struct rt_rtmp_adapter *pAd,
-               u8 *pHeader802_3,
-               u32 HdrLen,
-               u8 *pData,
-               unsigned long DataSize, void **ppPacket);
-
-u32 deaggregate_AMSDU_announce(struct rt_rtmp_adapter *pAd,
-                               void *pPacket,
-                               u8 *pData, unsigned long DataSize);
-
-int RTMPCheckRxError(struct rt_rtmp_adapter *pAd,
-                            struct rt_header_802_11 *pHeader,
-                            struct rt_rxwi *pRxWI,
-                            IN PRT28XX_RXD_STRUC pRxINFO);
-
-void RTUSBMlmeHardTransmit(struct rt_rtmp_adapter *pAd, struct rt_mgmt *pMgmt);
-
-int MlmeThread(void *Context);
-
-/* */
-/* Function Prototype in rtusb_data.c */
-/* */
-int RTUSBFreeDescriptorRequest(struct rt_rtmp_adapter *pAd,
-                                      u8 BulkOutPipeId,
-                                      u32 NumberRequired);
-
-BOOLEAN RTUSBNeedQueueBackForAgg(struct rt_rtmp_adapter *pAd, u8 BulkOutPipeId);
-
-void RTMPWriteTxInfo(struct rt_rtmp_adapter *pAd,
-                    struct rt_txinfo *pTxInfo,
-                    u16 USBDMApktLen,
-                    IN BOOLEAN bWiv,
-                    u8 QueueSel, u8 NextValid, u8 TxBurst);
-
-/* */
-/* Function Prototype in cmm_data_usb.c */
-/* */
-u16 RtmpUSB_WriteSubTxResource(struct rt_rtmp_adapter *pAd,
-                                 struct rt_tx_blk *pTxBlk,
-                                 IN BOOLEAN bIsLast, u16 *FreeNumber);
-
-u16 RtmpUSB_WriteSingleTxResource(struct rt_rtmp_adapter *pAd,
-                                    struct rt_tx_blk *pTxBlk,
-                                    IN BOOLEAN bIsLast,
-                                    u16 *FreeNumber);
-
-u16 RtmpUSB_WriteFragTxResource(struct rt_rtmp_adapter *pAd,
-                                  struct rt_tx_blk *pTxBlk,
-                                  u8 fragNum, u16 *FreeNumber);
-
-u16 RtmpUSB_WriteMultiTxResource(struct rt_rtmp_adapter *pAd,
-                                   struct rt_tx_blk *pTxBlk,
-                                   u8 frameNum, u16 *FreeNumber);
-
-void RtmpUSB_FinalWriteTxResource(struct rt_rtmp_adapter *pAd,
-                                 struct rt_tx_blk *pTxBlk,
-                                 u16 totalMPDUSize, u16 TxIdx);
-
-void RtmpUSBDataLastTxIdx(struct rt_rtmp_adapter *pAd,
-                         u8 QueIdx, u16 TxIdx);
-
-void RtmpUSBDataKickOut(struct rt_rtmp_adapter *pAd,
-                       struct rt_tx_blk *pTxBlk, u8 QueIdx);
-
-int RtmpUSBMgmtKickOut(struct rt_rtmp_adapter *pAd,
-                      u8 QueIdx,
-                      void *pPacket,
-                      u8 *pSrcBufVA, u32 SrcBufLen);
-
-void RtmpUSBNullFrameKickOut(struct rt_rtmp_adapter *pAd,
-                            u8 QueIdx,
-                            u8 *pNullFrame, u32 frameLen);
-
-void RtmpUsbStaAsicForceWakeupTimeout(void *SystemSpecific1,
-                                     void *FunctionContext,
-                                     void *SystemSpecific2,
-                                     void *SystemSpecific3);
-
-void RT28xxUsbStaAsicForceWakeup(struct rt_rtmp_adapter *pAd, IN BOOLEAN bFromTx);
-
-void RT28xxUsbStaAsicSleepThenAutoWakeup(struct rt_rtmp_adapter *pAd,
-                                        u16 TbttNumToNextWakeUp);
-
-void RT28xxUsbMlmeRadioOn(struct rt_rtmp_adapter *pAd);
-
-void RT28xxUsbMlmeRadioOFF(struct rt_rtmp_adapter *pAd);
-#endif /* RTMP_MAC_USB // */
-
-void AsicTurnOffRFClk(struct rt_rtmp_adapter *pAd, u8 Channel);
-
-void AsicTurnOnRFClk(struct rt_rtmp_adapter *pAd, u8 Channel);
-
-#ifdef RTMP_TIMER_TASK_SUPPORT
-int RtmpTimerQThread(IN void *Context);
-
-struct rt_rtmp_timer_task_entry *RtmpTimerQInsert(struct rt_rtmp_adapter *pAd,
-                                       struct rt_ralink_timer *pTimer);
-
-BOOLEAN RtmpTimerQRemove(struct rt_rtmp_adapter *pAd,
-                        struct rt_ralink_timer *pTimer);
-
-void RtmpTimerQExit(struct rt_rtmp_adapter *pAd);
-
-void RtmpTimerQInit(struct rt_rtmp_adapter *pAd);
-#endif /* RTMP_TIMER_TASK_SUPPORT // */
-
-void AsicStaBbpTuning(struct rt_rtmp_adapter *pAd);
-
-BOOLEAN StaAddMacTableEntry(struct rt_rtmp_adapter *pAd,
-                           struct rt_mac_table_entry *pEntry,
-                           u8 MaxSupportedRateIn500Kbps,
-                           struct rt_ht_capability_ie *pHtCapability,
-                           u8 HtCapabilityLen,
-                           struct rt_add_ht_info_ie *pAddHtInfo,
-                           u8 AddHtInfoLen, u16 CapabilityInfo);
-
-BOOLEAN AUTH_ReqSend(struct rt_rtmp_adapter *pAd,
-                    struct rt_mlme_queue_elem *pElem,
-                    struct rt_ralink_timer *pAuthTimer,
-                    char *pSMName,
-                    u16 SeqNo,
-                    u8 *pNewElement, unsigned long ElementLen);
-
-void RTMP_IndicateMediaState(struct rt_rtmp_adapter *pAd);
-
-void ReSyncBeaconTime(struct rt_rtmp_adapter *pAd);
-
-void RTMPSetAGCInitValue(struct rt_rtmp_adapter *pAd, u8 BandWidth);
-
-int rt28xx_close(struct net_device *dev);
-int rt28xx_open(struct net_device *dev);
-
-#define VIRTUAL_IF_INC(__pAd) ((__pAd)->VirtualIfCnt++)
-#define VIRTUAL_IF_DEC(__pAd) ((__pAd)->VirtualIfCnt--)
-#define VIRTUAL_IF_NUM(__pAd) ((__pAd)->VirtualIfCnt)
-
-#ifdef LINUX
-__inline int VIRTUAL_IF_UP(struct rt_rtmp_adapter *pAd)
-{
-       if (VIRTUAL_IF_NUM(pAd) == 0) {
-               if (rt28xx_open(pAd->net_dev) != 0) {
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("rt28xx_open return fail!\n"));
-                       return -1;
-               }
-       } else {
-       }
-       VIRTUAL_IF_INC(pAd);
-       return 0;
-}
-
-__inline void VIRTUAL_IF_DOWN(struct rt_rtmp_adapter *pAd)
-{
-       VIRTUAL_IF_DEC(pAd);
-       if (VIRTUAL_IF_NUM(pAd) == 0)
-               rt28xx_close(pAd->net_dev);
-       return;
-}
-#endif /* LINUX // */
-
-/*
-       OS Related funciton prototype definitions.
-       TODO: Maybe we need to move these function prototypes to other proper place.
-*/
-int RtmpOSWrielessEventSend(struct rt_rtmp_adapter *pAd,
-                           u32 eventType,
-                           int flags,
-                           u8 *pSrcMac,
-                           u8 *pData, u32 dataLen);
-
-int RtmpOSNetDevAddrSet(struct net_device *pNetDev, u8 *pMacAddr);
-
-int RtmpOSNetDevAttach(struct net_device *pNetDev,
-                      struct rt_rtmp_os_netdev_op_hook *pDevOpHook);
-
-void RtmpOSNetDevClose(struct net_device *pNetDev);
-
-void RtmpOSNetDevDetach(struct net_device *pNetDev);
-
-int RtmpOSNetDevAlloc(struct net_device **pNewNetDev, u32 privDataSize);
-
-void RtmpOSNetDevFree(struct net_device *pNetDev);
-
-struct net_device *RtmpOSNetDevGetByName(struct net_device *pNetDev, char *pDevName);
-
-void RtmpOSNetDeviceRefPut(struct net_device *pNetDev);
-
-struct net_device *RtmpOSNetDevCreate(struct rt_rtmp_adapter *pAd,
-                           int devType,
-                           int devNum,
-                           int privMemSize, char *pNamePrefix);
-
-/*
-       Task operation related function prototypes
-*/
-void RtmpOSTaskCustomize(struct rt_rtmp_os_task *pTask);
-
-int RtmpOSTaskNotifyToExit(struct rt_rtmp_os_task *pTask);
-
-int RtmpOSTaskKill(struct rt_rtmp_os_task *pTask);
-
-int RtmpOSTaskInit(struct rt_rtmp_os_task *pTask,
-                          char *pTaskName, void * pPriv);
-
-int RtmpOSTaskAttach(struct rt_rtmp_os_task *pTask,
-                            IN int (*fn) (void *), IN void *arg);
-
-/*
-       File operation related function prototypes
-*/
-struct file *RtmpOSFileOpen(IN char *pPath, IN int flag, IN int mode);
-
-int RtmpOSFileClose(struct file *osfd);
-
-void RtmpOSFileSeek(struct file *osfd, IN int offset);
-
-int RtmpOSFileRead(struct file *osfd, IN char *pDataPtr, IN int readLen);
-
-int RtmpOSFileWrite(struct file *osfd, IN char *pDataPtr, IN int writeLen);
-
-#endif /* __RTMP_H__ */
diff --git a/drivers/staging/rt2860/rtmp_chip.h b/drivers/staging/rt2860/rtmp_chip.h
deleted file mode 100644 (file)
index 0adf2cd..0000000
+++ /dev/null
@@ -1,258 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-       Module Name:
-       rtmp_chip.h
-
-       Abstract:
-       Ralink Wireless Chip related definition & structures
-
-       Revision History:
-       Who                     When              What
-       --------        ----------        ----------------------------------------------
-*/
-
-#ifndef        __RTMP_CHIP_H__
-#define        __RTMP_CHIP_H__
-
-#include "rtmp_type.h"
-
-#ifdef RT2860
-#include "chip/rt2860.h"
-#endif /* RT2860 // */
-#ifdef RT2870
-#include "chip/rt2870.h"
-#endif /* RT2870 // */
-#ifdef RT3070
-#include "chip/rt3070.h"
-#endif /* RT3070 // */
-#ifdef RT3090
-#include "chip/rt3090.h"
-#endif /* RT3090 // */
-
-/* We will have a cost down version which mac version is 0x3090xxxx */
-/* */
-/* RT3090A facts */
-/* */
-/* a) 2.4 GHz */
-/* b) Replacement for RT3090 */
-/* c) Internal LNA */
-/* d) Interference over channel #14 */
-/* e) New BBP features (e.g., SIG re-modulation) */
-/* */
-#define IS_RT3090A(_pAd)                               ((((_pAd)->MACVersion & 0xffff0000) == 0x30900000))
-
-/* We will have a cost down version which mac version is 0x3090xxxx */
-#define IS_RT3090(_pAd)                                ((((_pAd)->MACVersion & 0xffff0000) == 0x30710000) || (IS_RT3090A(_pAd)))
-
-#define IS_RT3070(_pAd)                (((_pAd)->MACVersion & 0xffff0000) == 0x30700000)
-#define IS_RT3071(_pAd)                (((_pAd)->MACVersion & 0xffff0000) == 0x30710000)
-#define IS_RT2070(_pAd)                (((_pAd)->RfIcType == RFIC_2020) || ((_pAd)->EFuseTag == 0x27))
-
-#define IS_RT30xx(_pAd)                (((_pAd)->MACVersion & 0xfff00000) == 0x30700000||IS_RT3090A(_pAd))
-/*#define IS_RT305X(_pAd)               ((_pAd)->MACVersion == 0x28720200) */
-
-/* RT3572, 3592, 3562, 3062 share the same MAC version */
-#define IS_RT3572(_pAd)                (((_pAd)->MACVersion & 0xffff0000) == 0x35720000)
-#define IS_VERSION_BEFORE_F(_pAd)                      (((_pAd)->MACVersion&0xffff) <= 0x0211)
-/* F version is 0x0212, E version is 0x0211. 309x can save more power after F version. */
-#define IS_VERSION_AFTER_F(_pAd)                       ((((_pAd)->MACVersion&0xffff) >= 0x0212) || (((_pAd)->b3090ESpecialChip == TRUE)))
-/* */
-/* RT3390 facts */
-/* */
-/* a) Base on RT3090 (RF IC: RT3020) */
-/* b) 2.4 GHz */
-/* c) 1x1 */
-/* d) Single chip */
-/* e) Internal components: PA and LNA */
-/* */
-/*RT3390,RT3370 */
-#define IS_RT3390(_pAd)                                (((_pAd)->MACVersion & 0xFFFF0000) == 0x33900000)
-
-/* ------------------------------------------------------ */
-/* PCI registers - base address 0x0000 */
-/* ------------------------------------------------------ */
-#define CHIP_PCI_CFG           0x0000
-#define CHIP_PCI_EECTRL                0x0004
-#define CHIP_PCI_MCUCTRL       0x0008
-
-#define OPT_14                 0x114
-
-#define RETRY_LIMIT            10
-
-/* ------------------------------------------------------ */
-/* BBP & RF     definition */
-/* ------------------------------------------------------ */
-#define        BUSY                            1
-#define        IDLE                            0
-
-/*------------------------------------------------------------------------- */
-/* EEPROM definition */
-/*------------------------------------------------------------------------- */
-#define EEDO                        0x08
-#define EEDI                        0x04
-#define EECS                        0x02
-#define EESK                        0x01
-#define EERL                        0x80
-
-#define EEPROM_WRITE_OPCODE         0x05
-#define EEPROM_READ_OPCODE          0x06
-#define EEPROM_EWDS_OPCODE          0x10
-#define EEPROM_EWEN_OPCODE          0x13
-
-#define NUM_EEPROM_BBP_PARMS           19      /* Include NIC Config 0, 1, CR, TX ALC step, BBPs */
-#define NUM_EEPROM_TX_G_PARMS          7
-#define EEPROM_NIC1_OFFSET          0x34       /* The address is from NIC config 0, not BBP register ID */
-#define EEPROM_NIC2_OFFSET          0x36       /* The address is from NIC config 0, not BBP register ID */
-#define EEPROM_BBP_BASE_OFFSET         0xf0    /* The address is from NIC config 0, not BBP register ID */
-#define EEPROM_G_TX_PWR_OFFSET         0x52
-#define EEPROM_G_TX2_PWR_OFFSET                0x60
-#define EEPROM_LED1_OFFSET                     0x3c
-#define EEPROM_LED2_OFFSET                     0x3e
-#define EEPROM_LED3_OFFSET                     0x40
-#define EEPROM_LNA_OFFSET                      0x44
-#define EEPROM_RSSI_BG_OFFSET          0x46
-#define EEPROM_TXMIXER_GAIN_2_4G       0x48
-#define EEPROM_RSSI_A_OFFSET           0x4a
-#define EEPROM_TXMIXER_GAIN_5G         0x4c
-#define EEPROM_DEFINE_MAX_TXPWR                0x4e
-#define EEPROM_TXPOWER_BYRATE_20MHZ_2_4G       0xde    /* 20MHZ 2.4G tx power. */
-#define EEPROM_TXPOWER_BYRATE_40MHZ_2_4G       0xee    /* 40MHZ 2.4G tx power. */
-#define EEPROM_TXPOWER_BYRATE_20MHZ_5G         0xfa    /* 20MHZ 5G tx power. */
-#define EEPROM_TXPOWER_BYRATE_40MHZ_5G         0x10a   /* 40MHZ 5G tx power. */
-#define EEPROM_A_TX_PWR_OFFSET      0x78
-#define EEPROM_A_TX2_PWR_OFFSET      0xa6
-/*#define EEPROM_Japan_TX_PWR_OFFSET      0x90 // 802.11j */
-/*#define EEPROM_Japan_TX2_PWR_OFFSET      0xbe */
-/*#define EEPROM_TSSI_REF_OFFSET        0x54 */
-/*#define EEPROM_TSSI_DELTA_OFFSET      0x24 */
-/*#define EEPROM_CCK_TX_PWR_OFFSET  0x62 */
-/*#define EEPROM_CALIBRATE_OFFSET       0x7c */
-#define EEPROM_VERSION_OFFSET       0x02
-#define EEPROM_FREQ_OFFSET                     0x3a
-#define EEPROM_TXPOWER_BYRATE  0xde    /* 20MHZ power. */
-#define EEPROM_TXPOWER_DELTA           0x50    /* 20MHZ AND 40 MHZ use different power. This is delta in 40MHZ. */
-#define VALID_EEPROM_VERSION        1
-
-/*
-  *   EEPROM operation related marcos
-  */
-#define RT28xx_EEPROM_READ16(_pAd, _offset, _value)                    \
-       (_pAd)->chipOps.eeread((struct rt_rtmp_adapter *)(_pAd), (u16)(_offset), (u16 *)&(_value))
-
-/* ------------------------------------------------------------------- */
-/*  E2PROM data layout */
-/* ------------------------------------------------------------------- */
-
-/* */
-/* MCU_LEDCS: MCU LED Control Setting. */
-/* */
-typedef union _MCU_LEDCS_STRUC {
-       struct {
-               u8 LedMode:7;
-               u8 Polarity:1;
-       } field;
-       u8 word;
-} MCU_LEDCS_STRUC, *PMCU_LEDCS_STRUC;
-
-/* */
-/* EEPROM antenna select format */
-/* */
-typedef union _EEPROM_ANTENNA_STRUC {
-       struct {
-               u16 RxPath:4;   /* 1: 1R, 2: 2R, 3: 3R */
-               u16 TxPath:4;   /* 1: 1T, 2: 2T */
-               u16 RfIcType:4; /* see E2PROM document */
-               u16 Rsv:4;
-       } field;
-       u16 word;
-} EEPROM_ANTENNA_STRUC, *PEEPROM_ANTENNA_STRUC;
-
-typedef union _EEPROM_NIC_CINFIG2_STRUC {
-       struct {
-               u16 HardwareRadioControl:1;     /* 1:enable, 0:disable */
-               u16 DynamicTxAgcControl:1;      /* */
-               u16 ExternalLNAForG:1;  /* */
-               u16 ExternalLNAForA:1;  /* external LNA enable for 2.4G */
-               u16 CardbusAcceleration:1;      /* ! NOTE: 0 - enable, 1 - disable */
-               u16 BW40MSidebandForG:1;
-               u16 BW40MSidebandForA:1;
-               u16 EnableWPSPBC:1;     /* WPS PBC Control bit */
-               u16 BW40MAvailForG:1;   /* 0:enable, 1:disable */
-               u16 BW40MAvailForA:1;   /* 0:enable, 1:disable */
-               u16 Rsv1:1;     /* must be 0 */
-               u16 AntDiversity:1;     /* Antenna diversity */
-               u16 Rsv2:3;     /* must be 0 */
-               u16 DACTestBit:1;       /* control if driver should patch the DAC issue */
-       } field;
-       u16 word;
-} EEPROM_NIC_CONFIG2_STRUC, *PEEPROM_NIC_CONFIG2_STRUC;
-
-/* */
-/* TX_PWR Value valid range 0xFA(-6) ~ 0x24(36) */
-/* */
-typedef union _EEPROM_TX_PWR_STRUC {
-       struct {
-               char Byte0;     /* Low Byte */
-               char Byte1;     /* High Byte */
-       } field;
-       u16 word;
-} EEPROM_TX_PWR_STRUC, *PEEPROM_TX_PWR_STRUC;
-
-typedef union _EEPROM_VERSION_STRUC {
-       struct {
-               u8 FaeReleaseNumber;    /* Low Byte */
-               u8 Version;     /* High Byte */
-       } field;
-       u16 word;
-} EEPROM_VERSION_STRUC, *PEEPROM_VERSION_STRUC;
-
-typedef union _EEPROM_LED_STRUC {
-       struct {
-               u16 PolarityRDY_G:1;    /* Polarity RDY_G setting. */
-               u16 PolarityRDY_A:1;    /* Polarity RDY_A setting. */
-               u16 PolarityACT:1;      /* Polarity ACT setting. */
-               u16 PolarityGPIO_0:1;   /* Polarity GPIO#0 setting. */
-               u16 PolarityGPIO_1:1;   /* Polarity GPIO#1 setting. */
-               u16 PolarityGPIO_2:1;   /* Polarity GPIO#2 setting. */
-               u16 PolarityGPIO_3:1;   /* Polarity GPIO#3 setting. */
-               u16 PolarityGPIO_4:1;   /* Polarity GPIO#4 setting. */
-               u16 LedMode:5;  /* Led mode. */
-               u16 Rsvd:3;     /* Reserved */
-       } field;
-       u16 word;
-} EEPROM_LED_STRUC, *PEEPROM_LED_STRUC;
-
-typedef union _EEPROM_TXPOWER_DELTA_STRUC {
-       struct {
-               u8 DeltaValue:6;        /* Tx Power dalta value (MAX=4) */
-               u8 Type:1;      /* 1: plus the delta value, 0: minus the delta value */
-               u8 TxPowerEnable:1;     /* Enable */
-       } field;
-       u8 value;
-} EEPROM_TXPOWER_DELTA_STRUC, *PEEPROM_TXPOWER_DELTA_STRUC;
-
-#endif /* __RTMP_CHIP_H__ // */
diff --git a/drivers/staging/rt2860/rtmp_ckipmic.h b/drivers/staging/rt2860/rtmp_ckipmic.h
deleted file mode 100644 (file)
index 6ff935d..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-       Module Name:
-       rtmp_ckipmic.h
-
-       Abstract:
-
-       Revision History:
-       Who                     When                    What
-       --------        ----------              ----------------------------------------------
-       Name            Date                    Modification logs
-*/
-#ifndef        __RTMP_CKIPMIC_H__
-#define        __RTMP_CKIPMIC_H__
-
-struct rt_mic_context {
-       /* --- MMH context                            */
-       u8 CK[16];              /* the key                                    */
-       u8 coefficient[16];     /* current aes counter mode coefficients      */
-       unsigned long long accum;       /* accumulated mic, reduced to u32 in final() */
-       u32 position;           /* current position (byte offset) in message  */
-       u8 part[4];             /* for conversion of message to u32 for mmh   */
-};
-
-void xor_128(u8 *a, u8 *b, u8 *out);
-
-u8 RTMPCkipSbox(u8 a);
-
-void xor_32(u8 *a, u8 *b, u8 *out);
-
-void next_key(u8 *key, int round);
-
-void byte_sub(u8 *in, u8 *out);
-
-void shift_row(u8 *in, u8 *out);
-
-void mix_column(u8 *in, u8 *out);
-
-#endif /*__RTMP_CKIPMIC_H__ */
diff --git a/drivers/staging/rt2860/rtmp_def.h b/drivers/staging/rt2860/rtmp_def.h
deleted file mode 100644 (file)
index 6ac617e..0000000
+++ /dev/null
@@ -1,1427 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-    Module Name:
-    rtmp_def.h
-
-    Abstract:
-    Miniport related definition header
-
-    Revision History:
-    Who                        When            What
-    --------    ----------    ----------------------------------------------
-    Paul Lin           08-01-2002      created
-    John Chang         08-05-2003      add definition for 11g & other drafts
-    Justin P. Mattock  11/07/2010      Fix some typos
-*/
-#ifndef __RTMP_DEF_H__
-#define __RTMP_DEF_H__
-
-#include "oid.h"
-
-/* */
-/*  Debug information verbosity: lower values indicate higher urgency */
-/* */
-#define RT_DEBUG_OFF        0
-#define RT_DEBUG_ERROR      1
-#define RT_DEBUG_WARN       2
-#define RT_DEBUG_TRACE      3
-#define RT_DEBUG_INFO       4
-#define RT_DEBUG_LOUD       5
-
-#define NIC_TAG             ((unsigned long)'0682')
-#define NIC_DBG_char      ("**RT28xx**")
-
-#ifdef RTMP_MAC_USB
-#define TX_RING_SIZE            8      /* 1 */
-#define PRIO_RING_SIZE          8
-#define MGMT_RING_SIZE         32      /* PRIO_RING_SIZE */
-#define RX_RING_SIZE            8
-#define MAX_TX_PROCESS          4
-#define LOCAL_TXBUF_SIZE        2048
-#endif /* RTMP_MAC_USB // */
-
-/*#define PACKED */
-
-#define RALINK_2883_VERSION            ((u32)0x28830300)
-#define RALINK_2880E_VERSION   ((u32)0x28720200)
-#define RALINK_3070_VERSION            ((u32)0x30700200)
-
-#define MAX_RX_PKT_LEN 1520
-
-/* */
-/* Entry number for each DMA descriptor ring */
-/* */
-
-#ifdef RTMP_MAC_PCI
-#define TX_RING_SIZE            64     /*64 */
-#define MGMT_RING_SIZE          128
-#define RX_RING_SIZE            128    /*64 */
-#define MAX_TX_PROCESS          TX_RING_SIZE   /*8 */
-#define MAX_DMA_DONE_PROCESS    TX_RING_SIZE
-#define MAX_TX_DONE_PROCESS     TX_RING_SIZE   /*8 */
-#define LOCAL_TXBUF_SIZE        2
-#endif /* RTMP_MAC_PCI // */
-
-#define MAX_RX_PROCESS          128    /*64 //32 */
-#define NUM_OF_LOCAL_TXBUF      2
-#define TXD_SIZE                16
-#define TXWI_SIZE               16
-#define RXD_SIZE                       16
-#define RXWI_SIZE              16
-/* TXINFO_SIZE + TXWI_SIZE + 802.11 Header Size + AMSDU sub frame header */
-#define TX_DMA_1ST_BUFFER_SIZE  96     /* only the 1st physical buffer is pre-allocated */
-#define MGMT_DMA_BUFFER_SIZE    1536   /*2048 */
-#define RX_BUFFER_AGGRESIZE     3840   /*3904 //3968 //4096 //2048 //4096 */
-#define RX_BUFFER_NORMSIZE      3840   /*3904 //3968 //4096 //2048 //4096 */
-#define TX_BUFFER_NORMSIZE             RX_BUFFER_NORMSIZE
-#define MAX_FRAME_SIZE          2346   /* Maximum 802.11 frame size */
-#define MAX_AGGREGATION_SIZE    3840   /*3904 //3968 //4096 */
-#define MAX_NUM_OF_TUPLE_CACHE  2
-#define MAX_MCAST_LIST_SIZE     32
-#define MAX_LEN_OF_VENDOR_DESC  64
-/*#define MAX_SIZE_OF_MCAST_PSQ   (NUM_OF_LOCAL_TXBUF >> 2) // AP won't spend more than 1/4 of total buffers on M/BCAST PSQ */
-#define MAX_SIZE_OF_MCAST_PSQ               32
-
-#define MAX_RX_PROCESS_CNT     (RX_RING_SIZE)
-
-/*
-       WMM Note: If memory of your system is not much, please reduce the definition;
-       or when you do WMM test, the queue for low priority AC will be full, i.e.
-       TX_RING_SIZE + MAX_PACKETS_IN_QUEUE packets for the AC will be buffered in
-       WLAN, maybe no packet buffers can get into the Ethernet driver.
-
-       Sometimes no packet buffer can be get into the Ethernet driver, the system will
-       send flow control packet to the sender to slow down its sending rate.
-       So no WMM can be seen in the air.
-*/
-
-/*
-       Need to use 64 in vxworks for test case WMM A5-T07
-       Two dnlink (10Mbps) from a WMM station to a non-WMM station.
-       If use 256, queue is not enough.
-       And in rt_main_end.c, clConfig.clNum = RX_RING_SIZE * 3; is changed to
-       clConfig.clNum = RX_RING_SIZE * 4;
-*/
-/* TODO: For VxWorks the size is 256. Shall we change the value as 256 for all OS? */
-#define MAX_PACKETS_IN_QUEUE                           (512)   /*(512)    // to pass WMM A5-WPAPSK */
-
-#define MAX_PACKETS_IN_MCAST_PS_QUEUE          32
-#define MAX_PACKETS_IN_PS_QUEUE                                128     /*32 */
-#define WMM_NUM_OF_AC                       4  /* AC0, AC1, AC2, and AC3 */
-
-#ifdef RTMP_EFUSE_SUPPORT
-/*2008/09/11:KH add to support efuse<-- */
-#define MAX_EEPROM_BIN_FILE_SIZE                                       1024
-#define EFUSE_BUFFER_PATH                                              "/tmp/RT30xxEEPROM.bin"
-/*2008/09/11:KH add to support efuse--> */
-#endif /* RTMP_EFUSE_SUPPORT // */
-
-/* RxFilter */
-#define STANORMAL       0x17f97
-#define APNORMAL        0x15f97
-#define PSPXLINK        0x17f93
-/* */
-/*  struct rt_rtmp_adapter flags */
-/* */
-#define fRTMP_ADAPTER_MAP_REGISTER          0x00000001
-#define fRTMP_ADAPTER_INTERRUPT_IN_USE      0x00000002
-#define fRTMP_ADAPTER_HARDWARE_ERROR        0x00000004
-#define fRTMP_ADAPTER_SCATTER_GATHER        0x00000008
-#define fRTMP_ADAPTER_SEND_PACKET_ERROR     0x00000010
-#define fRTMP_ADAPTER_MLME_RESET_IN_PROGRESS 0x00000020
-#define fRTMP_ADAPTER_HALT_IN_PROGRESS      0x00000040
-#define fRTMP_ADAPTER_RESET_IN_PROGRESS     0x00000080
-#define fRTMP_ADAPTER_NIC_NOT_EXIST         0x00000100
-#define fRTMP_ADAPTER_TX_RING_ALLOCATED     0x00000200
-#define fRTMP_ADAPTER_REMOVE_IN_PROGRESS    0x00000400
-#define fRTMP_ADAPTER_MIMORATE_INUSED       0x00000800
-#define fRTMP_ADAPTER_RX_RING_ALLOCATED     0x00001000
-#define fRTMP_ADAPTER_INTERRUPT_ACTIVE      0x00002000
-#define fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS  0x00004000
-#define        fRTMP_ADAPTER_REASSOC_IN_PROGRESS       0x00008000
-#define        fRTMP_ADAPTER_MEDIA_STATE_PENDING       0x00010000
-#define        fRTMP_ADAPTER_RADIO_OFF                         0x00020000
-#define fRTMP_ADAPTER_BULKOUT_RESET                    0x00040000
-#define        fRTMP_ADAPTER_BULKIN_RESET                      0x00080000
-#define fRTMP_ADAPTER_RDG_ACTIVE                       0x00100000
-#define fRTMP_ADAPTER_DYNAMIC_BE_TXOP_ACTIVE 0x00200000
-#define fRTMP_ADAPTER_SCAN_2040                        0x04000000
-#define        fRTMP_ADAPTER_RADIO_MEASUREMENT         0x08000000
-
-#define fRTMP_ADAPTER_START_UP                         0x10000000      /*Device already initialized and enabled Tx/Rx. */
-#define fRTMP_ADAPTER_MEDIA_STATE_CHANGE    0x20000000
-#define fRTMP_ADAPTER_IDLE_RADIO_OFF        0x40000000
-
-/* */
-/*  STA operation status flags */
-/* */
-#define fOP_STATUS_INFRA_ON                 0x00000001
-#define fOP_STATUS_ADHOC_ON                 0x00000002
-#define fOP_STATUS_BG_PROTECTION_INUSED     0x00000004
-#define fOP_STATUS_SHORT_SLOT_INUSED        0x00000008
-#define fOP_STATUS_SHORT_PREAMBLE_INUSED    0x00000010
-#define fOP_STATUS_RECEIVE_DTIM             0x00000020
-#define fOP_STATUS_MEDIA_STATE_CONNECTED    0x00000080
-#define fOP_STATUS_WMM_INUSED               0x00000100
-#define fOP_STATUS_AGGREGATION_INUSED       0x00000200
-#define fOP_STATUS_DOZE                     0x00000400 /* debug purpose */
-#define fOP_STATUS_PIGGYBACK_INUSED         0x00000800 /* piggy-back, and aggregation */
-#define fOP_STATUS_APSD_INUSED                         0x00001000
-#define fOP_STATUS_TX_AMSDU_INUSED                     0x00002000
-#define fOP_STATUS_MAX_RETRY_ENABLED           0x00004000
-#define fOP_STATUS_WAKEUP_NOW               0x00008000
-#define fOP_STATUS_PCIE_DEVICE       0x00020000
-#define fOP_STATUS_ADVANCE_POWER_SAVE_PCIE_DEVICE fOP_STATUS_PCIE_DEVICE
-
-/* */
-/*  struct rt_rtmp_adapter PSFlags : related to advanced power save. */
-/* */
-/* Indicate whether driver can go to sleep mode from now. This flag is useful AFTER link up */
-#define fRTMP_PS_CAN_GO_SLEEP          0x00000001
-/* Indicate whether driver has issue a LinkControl command to PCIe L1 */
-#define fRTMP_PS_SET_PCI_CLK_OFF_COMMAND          0x00000002
-/* Indicate driver should disable kick off hardware to send packets from now. */
-#define fRTMP_PS_DISABLE_TX         0x00000004
-/* Indicate driver should IMMEDIATELY go to sleep after receiving AP's beacon in which doesn't indicate unicate nor multicast packets for me */
-/* This flag is used ONLY in RTMPHandleRxDoneInterrupt routine. */
-#define fRTMP_PS_GO_TO_SLEEP_NOW         0x00000008
-#define fRTMP_PS_TOGGLE_L1             0x00000010      /* Use Toggle L1 mechanism for rt28xx PCIe */
-
-#ifdef RT3090
-#define WAKE_MCU_CMD                           0x31
-#define SLEEP_MCU_CMD                                  0x30
-#define RFOFF_MCU_CMD                          0x35
-#endif /* RT3090 // */
-
-#define CCKSETPROTECT          0x1
-#define OFDMSETPROTECT         0x2
-#define MM20SETPROTECT         0x4
-#define MM40SETPROTECT         0x8
-#define GF20SETPROTECT         0x10
-#define GR40SETPROTECT         0x20
-#define ALLN_SETPROTECT                (GR40SETPROTECT | GF20SETPROTECT | MM40SETPROTECT | MM20SETPROTECT)
-
-/* */
-/*  AP's client table operation status flags */
-/* */
-#define fCLIENT_STATUS_WMM_CAPABLE          0x00000001 /* CLIENT can parse QOS DATA frame */
-#define fCLIENT_STATUS_AGGREGATION_CAPABLE  0x00000002 /* CLIENT can receive Ralink's proprietary TX aggregation frame */
-#define fCLIENT_STATUS_PIGGYBACK_CAPABLE    0x00000004 /* CLIENT support piggy-back */
-#define fCLIENT_STATUS_AMSDU_INUSED                    0x00000008
-#define fCLIENT_STATUS_SGI20_CAPABLE           0x00000010
-#define fCLIENT_STATUS_SGI40_CAPABLE           0x00000020
-#define fCLIENT_STATUS_TxSTBC_CAPABLE          0x00000040
-#define fCLIENT_STATUS_RxSTBC_CAPABLE          0x00000080
-#define fCLIENT_STATUS_HTC_CAPABLE                     0x00000100
-#define fCLIENT_STATUS_RDG_CAPABLE                     0x00000200
-#define fCLIENT_STATUS_MCSFEEDBACK_CAPABLE  0x00000400
-#define fCLIENT_STATUS_APSD_CAPABLE         0x00000800 /* UAPSD STATION */
-
-#define fCLIENT_STATUS_RALINK_CHIPSET          0x00100000
-/* */
-/*  STA configuration flags */
-/* */
-
-/* 802.11n Operating Mode Definition. 0-3 also used in ASICUPdateProtect switch case */
-#define HT_NO_PROTECT  0
-#define HT_LEGACY_PROTECT      1
-#define HT_40_PROTECT  2
-#define HT_2040_PROTECT        3
-#define HT_RTSCTS_6M   7
-/*following is our own definition in order to turn on our ASIC protection register in INFRASTRUCTURE. */
-#define HT_ATHEROS     8       /* rt2860c has problem with atheros chip. we need to turn on RTS/CTS . */
-#define HT_FORCERTSCTS 9       /* Force turn on RTS/CTS first. then go to evaluate if this force RTS is necessary. */
-
-/* */
-/* RX Packet Filter control flags. Apply on pAd->PacketFilter */
-/* */
-#define fRX_FILTER_ACCEPT_DIRECT            NDIS_PACKET_TYPE_DIRECTED
-#define fRX_FILTER_ACCEPT_MULTICAST         NDIS_PACKET_TYPE_MULTICAST
-#define fRX_FILTER_ACCEPT_BROADCAST         NDIS_PACKET_TYPE_BROADCAST
-#define fRX_FILTER_ACCEPT_ALL_MULTICAST     NDIS_PACKET_TYPE_ALL_MULTICAST
-#define fRX_FILTER_ACCEPT_PROMISCUOUS       NDIS_PACKET_TYPE_PROMISCUOUS
-
-/* */
-/* Error code section */
-/* */
-/* NDIS_ERROR_CODE_ADAPTER_NOT_FOUND */
-#define ERRLOG_READ_PCI_SLOT_FAILED     0x00000101L
-#define ERRLOG_WRITE_PCI_SLOT_FAILED    0x00000102L
-#define ERRLOG_VENDOR_DEVICE_NOMATCH    0x00000103L
-
-/* NDIS_ERROR_CODE_ADAPTER_DISABLED */
-#define ERRLOG_BUS_MASTER_DISABLED      0x00000201L
-
-/* NDIS_ERROR_CODE_UNSUPPORTED_CONFIGURATION */
-#define ERRLOG_INVALID_SPEED_DUPLEX     0x00000301L
-#define ERRLOG_SET_SECONDARY_FAILED     0x00000302L
-
-/* NDIS_ERROR_CODE_OUT_OF_RESOURCES */
-#define ERRLOG_OUT_OF_MEMORY            0x00000401L
-#define ERRLOG_OUT_OF_SHARED_MEMORY     0x00000402L
-#define ERRLOG_OUT_OF_MAP_REGISTERS     0x00000403L
-#define ERRLOG_OUT_OF_BUFFER_POOL       0x00000404L
-#define ERRLOG_OUT_OF_NDIS_BUFFER       0x00000405L
-#define ERRLOG_OUT_OF_PACKET_POOL       0x00000406L
-#define ERRLOG_OUT_OF_NDIS_PACKET       0x00000407L
-#define ERRLOG_OUT_OF_LOOKASIDE_MEMORY  0x00000408L
-
-/* NDIS_ERROR_CODE_HARDWARE_FAILURE */
-#define ERRLOG_SELFTEST_FAILED          0x00000501L
-#define ERRLOG_INITIALIZE_ADAPTER       0x00000502L
-#define ERRLOG_REMOVE_MINIPORT          0x00000503L
-
-/* NDIS_ERROR_CODE_RESOURCE_CONFLICT */
-#define ERRLOG_MAP_IO_SPACE             0x00000601L
-#define ERRLOG_QUERY_ADAPTER_RESOURCES  0x00000602L
-#define ERRLOG_NO_IO_RESOURCE           0x00000603L
-#define ERRLOG_NO_INTERRUPT_RESOURCE    0x00000604L
-#define ERRLOG_NO_MEMORY_RESOURCE       0x00000605L
-
-/* WDS definition */
-#define        MAX_WDS_ENTRY               4
-#define WDS_PAIRWISE_KEY_OFFSET     60 /* WDS links use pairwise key#60 ~ 63 in ASIC pairwise key table */
-
-#define        WDS_DISABLE_MODE            0
-#define        WDS_RESTRICT_MODE           1
-#define        WDS_BRIDGE_MODE             2
-#define        WDS_REPEATER_MODE           3
-#define        WDS_LAZY_MODE               4
-
-#define MAX_MESH_NUM                           0
-
-#define MAX_APCLI_NUM                          0
-
-#define MAX_MBSSID_NUM                         1
-#ifdef MBSS_SUPPORT
-#undef MAX_MBSSID_NUM
-#define MAX_MBSSID_NUM                         (8 - MAX_MESH_NUM - MAX_APCLI_NUM)
-#endif /* MBSS_SUPPORT // */
-
-/* sanity check for apidx */
-#define MBSS_MR_APIDX_SANITY_CHECK(apidx) \
-    { if (apidx > MAX_MBSSID_NUM) { \
-          DBGPRINT(RT_DEBUG_ERROR, ("%s> Error! apidx = %d > MAX_MBSSID_NUM!\n", __func__, apidx)); \
-         apidx = MAIN_MBSSID; } }
-
-#define VALID_WCID(_wcid)      ((_wcid) > 0 && (_wcid) < MAX_LEN_OF_MAC_TABLE )
-
-#define MAIN_MBSSID                 0
-#define FIRST_MBSSID                1
-
-#define MAX_BEACON_SIZE                                512
-/* If the MAX_MBSSID_NUM is larger than 6, */
-/* it shall reserve some WCID space(wcid 222~253) for beacon frames. */
-/* -    these wcid 238~253 are reserved for beacon#6(ra6). */
-/* -    these wcid 222~237 are reserved for beacon#7(ra7). */
-#if defined(MAX_MBSSID_NUM) && (MAX_MBSSID_NUM == 8)
-#define HW_RESERVED_WCID       222
-#elif defined(MAX_MBSSID_NUM) && (MAX_MBSSID_NUM == 7)
-#define HW_RESERVED_WCID       238
-#else
-#define HW_RESERVED_WCID       255
-#endif
-
-/* Then dedicate wcid of DFS and Carrier-Sense. */
-#define DFS_CTS_WCID           (HW_RESERVED_WCID - 1)
-#define CS_CTS_WCID            (HW_RESERVED_WCID - 2)
-#define LAST_SPECIFIC_WCID     (HW_RESERVED_WCID - 2)
-
-/* If MAX_MBSSID_NUM is 8, the maximum available wcid for the associated STA is 211. */
-/* If MAX_MBSSID_NUM is 7, the maximum available wcid for the associated STA is 228. */
-#define MAX_AVAILABLE_CLIENT_WCID      (LAST_SPECIFIC_WCID - MAX_MBSSID_NUM - 1)
-
-/* TX need WCID to find Cipher Key */
-/* these wcid 212 ~ 219 are reserved for bc/mc packets if MAX_MBSSID_NUM is 8. */
-#define GET_GroupKey_WCID(__wcid, __bssidx) \
-       {                                                                               \
-               __wcid = LAST_SPECIFIC_WCID - (MAX_MBSSID_NUM) + __bssidx;      \
-       }
-
-#define IsGroupKeyWCID(__wcid) (((__wcid) < LAST_SPECIFIC_WCID) && ((__wcid) >= (LAST_SPECIFIC_WCID - (MAX_MBSSID_NUM))))
-
-/* definition to support multiple BSSID */
-#define BSS0                            0
-#define BSS1                            1
-#define BSS2                            2
-#define BSS3                            3
-#define BSS4                            4
-#define BSS5                            5
-#define BSS6                            6
-#define BSS7                            7
-
-/*============================================================ */
-/* Length definitions */
-#define PEER_KEY_NO                     2
-#define MAC_ADDR_LEN                    6
-#define TIMESTAMP_LEN                   8
-#define MAX_LEN_OF_SUPPORTED_RATES      MAX_LENGTH_OF_SUPPORT_RATES    /* 1, 2, 5.5, 11, 6, 9, 12, 18, 24, 36, 48, 54 */
-#define MAX_LEN_OF_KEY                  32     /* 32 octets == 256 bits, Redefine for WPA */
-#define MAX_NUM_OF_CHANNELS             MAX_NUM_OF_CHS /* 14 channels @2.4G +  12@UNII + 4 @MMAC + 11 @HiperLAN2 + 7 @Japan + 1 as NULL termination */
-#define MAX_NUM_OF_11JCHANNELS             20  /* 14 channels @2.4G +  12@UNII + 4 @MMAC + 11 @HiperLAN2 + 7 @Japan + 1 as NULL termination */
-#define MAX_LEN_OF_SSID                 32
-#define CIPHER_TEXT_LEN                 128
-#define HASH_TABLE_SIZE                 256
-#define MAX_VIE_LEN                     1024   /* New for WPA cipher suite variable IE sizes. */
-#define MAX_SUPPORT_MCS             32
-#define MAX_NUM_OF_BBP_LATCH             140
-
-/*============================================================ */
-/* ASIC WCID Table definition. */
-/*============================================================ */
-#define BSSID_WCID             1       /* in infra mode, always put bssid with this WCID */
-#define MCAST_WCID     0x0
-#define BSS0Mcast_WCID 0x0
-#define BSS1Mcast_WCID 0xf8
-#define BSS2Mcast_WCID 0xf9
-#define BSS3Mcast_WCID 0xfa
-#define BSS4Mcast_WCID 0xfb
-#define BSS5Mcast_WCID 0xfc
-#define BSS6Mcast_WCID 0xfd
-#define BSS7Mcast_WCID 0xfe
-#define RESERVED_WCID          0xff
-
-#define MAX_NUM_OF_ACL_LIST                            MAX_NUMBER_OF_ACL
-
-#define MAX_LEN_OF_MAC_TABLE            MAX_NUMBER_OF_MAC      /* if MAX_MBSSID_NUM is 8, this value can't be larger than 211 */
-
-#if MAX_LEN_OF_MAC_TABLE>MAX_AVAILABLE_CLIENT_WCID
-#error MAX_LEN_OF_MAC_TABLE can not be larger than MAX_AVAILABLE_CLIENT_WCID!
-#endif
-
-#define MAX_NUM_OF_WDS_LINK_PERBSSID               3
-#define MAX_NUM_OF_WDS_LINK                (MAX_NUM_OF_WDS_LINK_PERBSSID*MAX_MBSSID_NUM)
-#define MAX_NUM_OF_EVENT                MAX_NUMBER_OF_EVENT
-#define WDS_LINK_START_WCID                            (MAX_LEN_OF_MAC_TABLE-1)
-
-#define NUM_OF_TID                     8
-#define MAX_AID_BA                    4
-#define MAX_LEN_OF_BA_REC_TABLE          ((NUM_OF_TID * MAX_LEN_OF_MAC_TABLE)/2)       /*   (NUM_OF_TID*MAX_AID_BA + 32)        //Block ACK recipient */
-#define MAX_LEN_OF_BA_ORI_TABLE          ((NUM_OF_TID * MAX_LEN_OF_MAC_TABLE)/2)       /*   (NUM_OF_TID*MAX_AID_BA + 32)   // Block ACK originator */
-#define MAX_LEN_OF_BSS_TABLE             64
-#define MAX_REORDERING_MPDU_NUM                         512
-
-/* key related definitions */
-#define SHARE_KEY_NUM                   4
-#define MAX_LEN_OF_SHARE_KEY            16     /* byte count */
-#define MAX_LEN_OF_PEER_KEY             16     /* byte count */
-#define PAIRWISE_KEY_NUM                64     /* in MAC ASIC pairwise key table */
-#define GROUP_KEY_NUM                   4
-#define PMK_LEN                         32
-#define WDS_PAIRWISE_KEY_OFFSET         60     /* WDS links uses pairwise key#60 ~ 63 in ASIC pairwise key table */
-#define        PMKID_NO                        4       /* Number of PMKID saved supported */
-#define MAX_LEN_OF_MLME_BUFFER          2048
-
-/* power status related definitions */
-#define PWR_ACTIVE                      0
-#define PWR_SAVE                        1
-#define PWR_MMPS                        2      /*MIMO power save */
-
-/* Auth and Assoc mode related definitions */
-#define AUTH_MODE_OPEN                  0x00
-#define AUTH_MODE_KEY                   0x01
-
-/* BSS Type definitions */
-#define BSS_ADHOC                       0      /* = Ndis802_11IBSS */
-#define BSS_INFRA                       1      /* = Ndis802_11Infrastructure */
-#define BSS_ANY                         2      /* = Ndis802_11AutoUnknown */
-#define BSS_MONITOR                                3   /* = Ndis802_11Monitor */
-
-/* Reason code definitions */
-#define REASON_RESERVED                 0
-#define REASON_UNSPECIFY                1
-#define REASON_NO_longER_VALID          2
-#define REASON_DEAUTH_STA_LEAVING       3
-#define REASON_DISASSOC_INACTIVE        4
-#define REASON_DISASSPC_AP_UNABLE       5
-#define REASON_CLS2ERR                  6
-#define REASON_CLS3ERR                  7
-#define REASON_DISASSOC_STA_LEAVING     8
-#define REASON_STA_REQ_ASSOC_NOT_AUTH   9
-#define REASON_INVALID_IE               13
-#define REASON_MIC_FAILURE              14
-#define REASON_4_WAY_TIMEOUT            15
-#define REASON_GROUP_KEY_HS_TIMEOUT     16
-#define REASON_IE_DIFFERENT             17
-#define REASON_MCIPHER_NOT_VALID        18
-#define REASON_UCIPHER_NOT_VALID        19
-#define REASON_AKMP_NOT_VALID           20
-#define REASON_UNSUPPORT_RSNE_VER       21
-#define REASON_INVALID_RSNE_CAP         22
-#define REASON_8021X_AUTH_FAIL          23
-#define REASON_CIPHER_SUITE_REJECTED    24
-#define REASON_DECLINED                 37
-
-#define REASON_QOS_UNSPECIFY              32
-#define REASON_QOS_LACK_BANDWIDTH         33
-#define REASON_POOR_CHANNEL_CONDITION     34
-#define REASON_QOS_OUTSIDE_TXOP_LIMITION  35
-#define REASON_QOS_QSTA_LEAVING_QBSS      36
-#define REASON_QOS_UNWANTED_MECHANISM     37
-#define REASON_QOS_MECH_SETUP_REQUIRED    38
-#define REASON_QOS_REQUEST_TIMEOUT        39
-#define REASON_QOS_CIPHER_NOT_SUPPORT     45
-
-/* Status code definitions */
-#define MLME_SUCCESS                    0
-#define MLME_UNSPECIFY_FAIL             1
-#define MLME_CANNOT_SUPPORT_CAP         10
-#define MLME_REASSOC_DENY_ASSOC_EXIST   11
-#define MLME_ASSOC_DENY_OUT_SCOPE       12
-#define MLME_ALG_NOT_SUPPORT            13
-#define MLME_SEQ_NR_OUT_OF_SEQUENCE     14
-#define MLME_REJ_CHALLENGE_FAILURE      15
-#define MLME_REJ_TIMEOUT                  16
-#define MLME_ASSOC_REJ_UNABLE_HANDLE_STA  17
-#define MLME_ASSOC_REJ_DATA_RATE          18
-
-#define MLME_ASSOC_REJ_NO_EXT_RATE        22
-#define MLME_ASSOC_REJ_NO_EXT_RATE_PBCC   23
-#define MLME_ASSOC_REJ_NO_CCK_OFDM        24
-
-#define MLME_QOS_UNSPECIFY                32
-#define MLME_REQUEST_DECLINED             37
-#define MLME_REQUEST_WITH_INVALID_PARAM   38
-#define MLME_INVALID_GROUP_CIPHER        41
-#define MLME_INVALID_PAIRWISE_CIPHER     42
-#define MLME_INVALID_AKMP                        43
-#define MLME_DLS_NOT_ALLOW_IN_QBSS        48
-#define MLME_DEST_STA_NOT_IN_QBSS         49
-#define MLME_DEST_STA_IS_NOT_A_QSTA       50
-
-#define MLME_INVALID_FORMAT             0x51
-#define MLME_FAIL_NO_RESOURCE           0x52
-#define MLME_STATE_MACHINE_REJECT       0x53
-#define MLME_MAC_TABLE_FAIL             0x54
-
-/* IE code */
-#define IE_SSID                         0
-#define IE_SUPP_RATES                   1
-#define IE_FH_PARM                      2
-#define IE_DS_PARM                      3
-#define IE_CF_PARM                      4
-#define IE_TIM                          5
-#define IE_IBSS_PARM                    6
-#define IE_COUNTRY                      7      /* 802.11d */
-#define IE_802_11D_REQUEST              10     /* 802.11d */
-#define IE_QBSS_LOAD                    11     /* 802.11e d9 */
-#define IE_EDCA_PARAMETER               12     /* 802.11e d9 */
-#define IE_TSPEC                        13     /* 802.11e d9 */
-#define IE_TCLAS                        14     /* 802.11e d9 */
-#define IE_SCHEDULE                     15     /* 802.11e d9 */
-#define IE_CHALLENGE_TEXT               16
-#define IE_POWER_CONSTRAint             32     /* 802.11h d3.3 */
-#define IE_POWER_CAPABILITY             33     /* 802.11h d3.3 */
-#define IE_TPC_REQUEST                  34     /* 802.11h d3.3 */
-#define IE_TPC_REPORT                   35     /* 802.11h d3.3 */
-#define IE_SUPP_CHANNELS                36     /* 802.11h d3.3 */
-#define IE_CHANNEL_SWITCH_ANNOUNCEMENT  37     /* 802.11h d3.3 */
-#define IE_MEASUREMENT_REQUEST          38     /* 802.11h d3.3 */
-#define IE_MEASUREMENT_REPORT           39     /* 802.11h d3.3 */
-#define IE_QUIET                        40     /* 802.11h d3.3 */
-#define IE_IBSS_DFS                     41     /* 802.11h d3.3 */
-#define IE_ERP                          42     /* 802.11g */
-#define IE_TS_DELAY                     43     /* 802.11e d9 */
-#define IE_TCLAS_PROCESSING             44     /* 802.11e d9 */
-#define IE_QOS_CAPABILITY               46     /* 802.11e d6 */
-#define IE_HT_CAP                       45     /* 802.11n d1. HT CAPABILITY. ELEMENT ID TBD */
-#define IE_AP_CHANNEL_REPORT                   51      /* 802.11k d6 */
-#define IE_HT_CAP2                         52  /* 802.11n d1. HT CAPABILITY. ELEMENT ID TBD */
-#define IE_RSN                          48     /* 802.11i d3.0 */
-#define IE_WPA2                         48     /* WPA2 */
-#define IE_EXT_SUPP_RATES               50     /* 802.11g */
-#define IE_SUPP_REG_CLASS               59     /* 802.11y. Supported regulatory classes. */
-#define IE_EXT_CHANNEL_SWITCH_ANNOUNCEMENT     60      /* 802.11n */
-#define IE_ADD_HT                         61   /* 802.11n d1. ADDITIONAL HT CAPABILITY. ELEMENT ID TBD */
-#define IE_ADD_HT2                        53   /* 802.11n d1. ADDITIONAL HT CAPABILITY. ELEMENT ID TBD */
-
-/* For 802.11n D3.03 */
-/*#define IE_NEW_EXT_CHA_OFFSET             62    // 802.11n d1. New extension channel offset element */
-#define IE_SECONDARY_CH_OFFSET         62      /* 802.11n D3.03        Secondary Channel Offset element */
-#define IE_WAPI                                                        68      /* WAPI information element */
-#define IE_2040_BSS_COEXIST               72   /* 802.11n D3.0.3 */
-#define IE_2040_BSS_INTOLERANT_REPORT     73   /* 802.11n D3.03 */
-#define IE_OVERLAPBSS_SCAN_PARM           74   /* 802.11n D3.03 */
-#define IE_EXT_CAPABILITY                127   /* 802.11n D3.03 */
-
-#define IE_WPA                          221    /* WPA */
-#define IE_VENDOR_SPECIFIC              221    /* Wifi WMM (WME) */
-
-#define OUI_BROADCOM_HT              51        /* */
-#define OUI_BROADCOM_HTADD              52     /* */
-#define OUI_PREN_HT_CAP              51        /* */
-#define OUI_PREN_ADD_HT              52        /* */
-
-/* CCX information */
-#define IE_AIRONET_CKIP                 133    /* CCX1.0 ID 85H for CKIP */
-#define IE_AP_TX_POWER                  150    /* CCX 2.0 for AP transmit power */
-#define IE_MEASUREMENT_CAPABILITY       221    /* CCX 2.0 */
-#define IE_CCX_V2                       221
-#define IE_AIRONET_IPADDRESS            149    /* CCX ID 95H for IP Address */
-#define IE_AIRONET_CCKMREASSOC          156    /* CCX ID 9CH for CCKM Reassociation Request element */
-#define CKIP_NEGOTIATION_LENGTH         30
-#define AIRONET_IPADDRESS_LENGTH        10
-#define AIRONET_CCKMREASSOC_LENGTH      24
-
-/* ======================================================== */
-/* MLME state machine definition */
-/* ======================================================== */
-
-/* STA MLME state mahcines */
-#define ASSOC_STATE_MACHINE             1
-#define AUTH_STATE_MACHINE              2
-#define AUTH_RSP_STATE_MACHINE          3
-#define SYNC_STATE_MACHINE              4
-#define MLME_CNTL_STATE_MACHINE         5
-#define WPA_PSK_STATE_MACHINE           6
-/*#define LEAP_STATE_MACHINE              7 */
-#define AIRONET_STATE_MACHINE           8
-#define ACTION_STATE_MACHINE           9
-
-/* AP MLME state machines */
-#define AP_ASSOC_STATE_MACHINE          11
-#define AP_AUTH_STATE_MACHINE           12
-#define AP_SYNC_STATE_MACHINE           14
-#define AP_CNTL_STATE_MACHINE           15
-#define WSC_STATE_MACHINE            17
-#define WSC_UPNP_STATE_MACHINE             18
-
-#define WPA_STATE_MACHINE                      23
-
-/* */
-/* STA's CONTROL/CONNECT state machine: states, events, total function # */
-/* */
-#define CNTL_IDLE                       0
-#define CNTL_WAIT_DISASSOC              1
-#define CNTL_WAIT_JOIN                  2
-#define CNTL_WAIT_REASSOC               3
-#define CNTL_WAIT_START                 4
-#define CNTL_WAIT_AUTH                  5
-#define CNTL_WAIT_ASSOC                 6
-#define CNTL_WAIT_AUTH2                 7
-#define CNTL_WAIT_OID_LIST_SCAN         8
-#define CNTL_WAIT_OID_DISASSOC          9
-#ifdef RTMP_MAC_USB
-#define CNTL_WAIT_SCAN_FOR_CONNECT      10
-#endif /* RTMP_MAC_USB // */
-
-#define MT2_ASSOC_CONF                  34
-#define MT2_AUTH_CONF                   35
-#define MT2_DEAUTH_CONF                 36
-#define MT2_DISASSOC_CONF               37
-#define MT2_REASSOC_CONF                38
-#define MT2_PWR_MGMT_CONF               39
-#define MT2_JOIN_CONF                   40
-#define MT2_SCAN_CONF                   41
-#define MT2_START_CONF                  42
-#define MT2_GET_CONF                    43
-#define MT2_SET_CONF                    44
-#define MT2_RESET_CONF                  45
-#define MT2_FT_OTD_CONF                                        46
-#define MT2_MLME_ROAMING_REQ            52
-
-#define CNTL_FUNC_SIZE                  1
-
-/* */
-/* STA's ASSOC state machine: states, events, total function # */
-/* */
-#define ASSOC_IDLE                      0
-#define ASSOC_WAIT_RSP                  1
-#define REASSOC_WAIT_RSP                2
-#define DISASSOC_WAIT_RSP               3
-#define MAX_ASSOC_STATE                 4
-
-#define ASSOC_MACHINE_BASE              0
-#define MT2_MLME_ASSOC_REQ              0
-#define MT2_MLME_REASSOC_REQ            1
-#define MT2_MLME_DISASSOC_REQ           2
-#define MT2_PEER_DISASSOC_REQ           3
-#define MT2_PEER_ASSOC_REQ              4
-#define MT2_PEER_ASSOC_RSP              5
-#define MT2_PEER_REASSOC_REQ            6
-#define MT2_PEER_REASSOC_RSP            7
-#define MT2_DISASSOC_TIMEOUT            8
-#define MT2_ASSOC_TIMEOUT               9
-#define MT2_REASSOC_TIMEOUT             10
-#define MAX_ASSOC_MSG                   11
-
-#define ASSOC_FUNC_SIZE                 (MAX_ASSOC_STATE * MAX_ASSOC_MSG)
-
-/* */
-/* ACT state machine: states, events, total function # */
-/* */
-#define ACT_IDLE                      0
-#define MAX_ACT_STATE                 1
-
-#define ACT_MACHINE_BASE              0
-
-/*Those PEER_xx_CATE number is based on real Categary value in IEEE spec. Please do not modify it by your self. */
-/*Category */
-#define MT2_PEER_SPECTRUM_CATE              0
-#define MT2_PEER_QOS_CATE              1
-#define MT2_PEER_DLS_CATE             2
-#define MT2_PEER_BA_CATE             3
-#define MT2_PEER_PUBLIC_CATE             4
-#define MT2_PEER_RM_CATE             5
-/* "FT_CATEGORY_BSS_TRANSITION equal to 6" is defined file of "dot11r_ft.h" */
-#define MT2_PEER_HT_CATE             7 /*      7.4.7 */
-#define MAX_PEER_CATE_MSG                   7
-
-#define MT2_MLME_ADD_BA_CATE             8
-#define MT2_MLME_ORI_DELBA_CATE             9
-#define MT2_MLME_REC_DELBA_CATE             10
-#define MT2_MLME_QOS_CATE              11
-#define MT2_MLME_DLS_CATE             12
-#define MT2_ACT_INVALID             13
-#define MAX_ACT_MSG                   14
-
-/*Category field */
-#define CATEGORY_SPECTRUM              0
-#define CATEGORY_QOS                   1
-#define CATEGORY_DLS                   2
-#define CATEGORY_BA                    3
-#define CATEGORY_PUBLIC                4
-#define CATEGORY_RM                    5
-#define CATEGORY_HT                    7
-
-/* DLS Action frame definition */
-#define ACTION_DLS_REQUEST                     0
-#define ACTION_DLS_RESPONSE                    1
-#define ACTION_DLS_TEARDOWN                    2
-
-/*Spectrum  Action field value 802.11h 7.4.1 */
-#define SPEC_MRQ       0       /* Request */
-#define SPEC_MRP       1       /*Report */
-#define SPEC_TPCRQ     2
-#define SPEC_TPCRP     3
-#define SPEC_CHANNEL_SWITCH    4
-
-/*BA  Action field value */
-#define ADDBA_REQ      0
-#define ADDBA_RESP     1
-#define DELBA   2
-
-/*Public's  Action field value in Public Category.  Some in 802.11y and some in 11n */
-#define ACTION_BSS_2040_COEXIST                                0       /* 11n */
-#define ACTION_DSE_ENABLEMENT                                  1       /* 11y D9.0 */
-#define ACTION_DSE_DEENABLEMENT                                2       /* 11y D9.0 */
-#define ACTION_DSE_REG_LOCATION_ANNOUNCE       3       /* 11y D9.0 */
-#define ACTION_EXT_CH_SWITCH_ANNOUNCE          4       /* 11y D9.0 */
-#define ACTION_DSE_MEASUREMENT_REQ                     5       /* 11y D9.0 */
-#define ACTION_DSE_MEASUREMENT_REPORT          6       /* 11y D9.0 */
-#define ACTION_MEASUREMENT_PILOT_ACTION                7       /* 11y D9.0 */
-#define ACTION_DSE_POWER_CONSTRAINT                    8       /* 11y D9.0 */
-
-/*HT  Action field value */
-#define NOTIFY_BW_ACTION                               0
-#define SMPS_ACTION                                            1
-#define PSMP_ACTION                                    2
-#define SETPCO_ACTION                                  3
-#define MIMO_CHA_MEASURE_ACTION                        4
-#define MIMO_N_BEACONFORM                              5
-#define MIMO_BEACONFORM                                        6
-#define ANTENNA_SELECT                                 7
-#define HT_INFO_EXCHANGE                               8
-
-#define ACT_FUNC_SIZE                 (MAX_ACT_STATE * MAX_ACT_MSG)
-/* */
-/* STA's AUTHENTICATION state machine: states, events, total function # */
-/* */
-#define AUTH_REQ_IDLE                   0
-#define AUTH_WAIT_SEQ2                  1
-#define AUTH_WAIT_SEQ4                  2
-#define MAX_AUTH_STATE                  3
-
-#define AUTH_MACHINE_BASE               0
-#define MT2_MLME_AUTH_REQ               0
-#define MT2_PEER_AUTH_EVEN              1
-#define MT2_AUTH_TIMEOUT                2
-#define MAX_AUTH_MSG                    3
-
-#define AUTH_FUNC_SIZE                  (MAX_AUTH_STATE * MAX_AUTH_MSG)
-
-/* */
-/* STA's AUTH_RSP state machine: states, events, total function # */
-/* */
-#define AUTH_RSP_IDLE                   0
-#define AUTH_RSP_WAIT_CHAL              1
-#define MAX_AUTH_RSP_STATE              2
-
-#define AUTH_RSP_MACHINE_BASE           0
-#define MT2_AUTH_CHALLENGE_TIMEOUT      0
-#define MT2_PEER_AUTH_ODD               1
-#define MT2_PEER_DEAUTH                 2
-#define MAX_AUTH_RSP_MSG                3
-
-#define AUTH_RSP_FUNC_SIZE              (MAX_AUTH_RSP_STATE * MAX_AUTH_RSP_MSG)
-
-/* */
-/* STA's SYNC state machine: states, events, total function # */
-/* */
-#define SYNC_IDLE                       0      /* merge NO_BSS,IBSS_IDLE,IBSS_ACTIVE and BSS in to 1 state */
-#define JOIN_WAIT_BEACON                1
-#define SCAN_LISTEN                     2
-#define MAX_SYNC_STATE                  3
-
-#define SYNC_MACHINE_BASE               0
-#define MT2_MLME_SCAN_REQ               0
-#define MT2_MLME_JOIN_REQ               1
-#define MT2_MLME_START_REQ              2
-#define MT2_PEER_BEACON                 3
-#define MT2_PEER_PROBE_RSP              4
-#define MT2_PEER_ATIM                   5
-#define MT2_SCAN_TIMEOUT                6
-#define MT2_BEACON_TIMEOUT              7
-#define MT2_ATIM_TIMEOUT                8
-#define MT2_PEER_PROBE_REQ              9
-#define MAX_SYNC_MSG                    10
-
-#define SYNC_FUNC_SIZE                  (MAX_SYNC_STATE * MAX_SYNC_MSG)
-
-/*Messages for the DLS state machine */
-#define DLS_IDLE                                               0
-#define MAX_DLS_STATE                                  1
-
-#define DLS_MACHINE_BASE                               0
-#define MT2_MLME_DLS_REQ                           0
-#define MT2_PEER_DLS_REQ                           1
-#define MT2_PEER_DLS_RSP                           2
-#define MT2_MLME_DLS_TEAR_DOWN             3
-#define MT2_PEER_DLS_TEAR_DOWN             4
-#define MAX_DLS_MSG                                    5
-
-#define DLS_FUNC_SIZE                                  (MAX_DLS_STATE * MAX_DLS_MSG)
-
-/* */
-/* WSC State machine: states, events, total function # */
-/* */
-
-/* */
-/* AP's CONTROL/CONNECT state machine: states, events, total function # */
-/* */
-#define AP_CNTL_FUNC_SIZE               1
-
-/* */
-/* AP's ASSOC state machine: states, events, total function # */
-/* */
-#define AP_ASSOC_IDLE                   0
-#define AP_MAX_ASSOC_STATE              1
-
-#define AP_ASSOC_MACHINE_BASE           0
-#define APMT2_MLME_DISASSOC_REQ         0
-#define APMT2_PEER_DISASSOC_REQ         1
-#define APMT2_PEER_ASSOC_REQ            2
-#define APMT2_PEER_REASSOC_REQ          3
-#define APMT2_CLS3ERR                   4
-#define AP_MAX_ASSOC_MSG                5
-
-#define AP_ASSOC_FUNC_SIZE              (AP_MAX_ASSOC_STATE * AP_MAX_ASSOC_MSG)
-
-/* */
-/* AP's AUTHENTICATION state machine: states, events, total function # */
-/* */
-#define AP_AUTH_REQ_IDLE                0
-#define AP_MAX_AUTH_STATE               1
-
-#define AP_AUTH_MACHINE_BASE            0
-#define APMT2_MLME_DEAUTH_REQ           0
-#define APMT2_CLS2ERR                   1
-#define APMT2_PEER_DEAUTH               2
-#define APMT2_PEER_AUTH_REQ                            3
-#define APMT2_PEER_AUTH_CONFIRM                        4
-#define AP_MAX_AUTH_MSG                 5
-
-#define AP_AUTH_FUNC_SIZE               (AP_MAX_AUTH_STATE * AP_MAX_AUTH_MSG)
-
-/* */
-/* AP's SYNC state machine: states, events, total function # */
-/* */
-#define AP_SYNC_IDLE                    0
-#define AP_SCAN_LISTEN                                 1
-#define AP_MAX_SYNC_STATE               2
-
-#define AP_SYNC_MACHINE_BASE            0
-#define APMT2_PEER_PROBE_REQ            0
-#define APMT2_PEER_BEACON               1
-#define APMT2_MLME_SCAN_REQ                            2
-#define APMT2_PEER_PROBE_RSP                   3
-#define APMT2_SCAN_TIMEOUT                             4
-#define APMT2_MLME_SCAN_CNCL                   5
-#define AP_MAX_SYNC_MSG                 6
-
-#define AP_SYNC_FUNC_SIZE               (AP_MAX_SYNC_STATE * AP_MAX_SYNC_MSG)
-
-/* */
-/* Common WPA state machine: states, events, total function # */
-/* */
-#define WPA_PTK                      0
-#define MAX_WPA_PTK_STATE            1
-
-#define WPA_MACHINE_BASE             0
-#define MT2_EAPPacket                0
-#define MT2_EAPOLStart               1
-#define MT2_EAPOLLogoff              2
-#define MT2_EAPOLKey                 3
-#define MT2_EAPOLASFAlert            4
-#define MAX_WPA_MSG                  5
-
-#define WPA_FUNC_SIZE                (MAX_WPA_PTK_STATE * MAX_WPA_MSG)
-
-/* ============================================================================= */
-
-/* value domain of 802.11 header FC.Tyte, which is b3..b2 of the 1st-byte of MAC header */
-#define BTYPE_MGMT                  0
-#define BTYPE_CNTL                  1
-#define BTYPE_DATA                  2
-
-/* value domain of 802.11 MGMT frame's FC.subtype, which is b7..4 of the 1st-byte of MAC header */
-#define SUBTYPE_ASSOC_REQ           0
-#define SUBTYPE_ASSOC_RSP           1
-#define SUBTYPE_REASSOC_REQ         2
-#define SUBTYPE_REASSOC_RSP         3
-#define SUBTYPE_PROBE_REQ           4
-#define SUBTYPE_PROBE_RSP           5
-#define SUBTYPE_BEACON              8
-#define SUBTYPE_ATIM                9
-#define SUBTYPE_DISASSOC            10
-#define SUBTYPE_AUTH                11
-#define SUBTYPE_DEAUTH              12
-#define SUBTYPE_ACTION              13
-#define SUBTYPE_ACTION_NO_ACK              14
-
-/* value domain of 802.11 CNTL frame's FC.subtype, which is b7..4 of the 1st-byte of MAC header */
-#define SUBTYPE_WRAPPER        7
-#define SUBTYPE_BLOCK_ACK_REQ       8
-#define SUBTYPE_BLOCK_ACK           9
-#define SUBTYPE_PS_POLL             10
-#define SUBTYPE_RTS                 11
-#define SUBTYPE_CTS                 12
-#define SUBTYPE_ACK                 13
-#define SUBTYPE_CFEND               14
-#define SUBTYPE_CFEND_CFACK         15
-
-/* value domain of 802.11 DATA frame's FC.subtype, which is b7..4 of the 1st-byte of MAC header */
-#define SUBTYPE_DATA                0
-#define SUBTYPE_DATA_CFACK          1
-#define SUBTYPE_DATA_CFPOLL         2
-#define SUBTYPE_DATA_CFACK_CFPOLL   3
-#define SUBTYPE_NULL_FUNC           4
-#define SUBTYPE_CFACK               5
-#define SUBTYPE_CFPOLL              6
-#define SUBTYPE_CFACK_CFPOLL        7
-#define SUBTYPE_QDATA               8
-#define SUBTYPE_QDATA_CFACK         9
-#define SUBTYPE_QDATA_CFPOLL        10
-#define SUBTYPE_QDATA_CFACK_CFPOLL  11
-#define SUBTYPE_QOS_NULL            12
-#define SUBTYPE_QOS_CFACK           13
-#define SUBTYPE_QOS_CFPOLL          14
-#define SUBTYPE_QOS_CFACK_CFPOLL    15
-
-/* ACK policy of QOS Control field bit 6:5 */
-#define NORMAL_ACK                  0x00       /* b6:5 = 00 */
-#define NO_ACK                      0x20       /* b6:5 = 01 */
-#define NO_EXPLICIT_ACK             0x40       /* b6:5 = 10 */
-#define BLOCK_ACK                   0x60       /* b6:5 = 11 */
-
-/* */
-/* rtmp_data.c uses this definition */
-/* */
-#define LENGTH_802_11               24
-#define LENGTH_802_11_AND_H         30
-#define LENGTH_802_11_CRC_H         34
-#define LENGTH_802_11_CRC           28
-#define LENGTH_802_11_WITH_ADDR4    30
-#define LENGTH_802_3                14
-#define LENGTH_802_3_TYPE           2
-#define LENGTH_802_1_H              8
-#define LENGTH_EAPOL_H              4
-#define LENGTH_WMMQOS_H                                2
-#define LENGTH_CRC                  4
-#define MAX_SEQ_NUMBER              0x0fff
-#define LENGTH_802_3_NO_TYPE           12
-#define LENGTH_802_1Q                          4       /* VLAN related */
-
-/* STA_CSR4.field.TxResult */
-#define TX_RESULT_SUCCESS           0
-#define TX_RESULT_ZERO_LENGTH       1
-#define TX_RESULT_UNDER_RUN         2
-#define TX_RESULT_OHY_ERROR         4
-#define TX_RESULT_RETRY_FAIL        6
-
-/* All PHY rate summary in TXD */
-/* Preamble MODE in TxD */
-#define MODE_CCK       0
-#define MODE_OFDM   1
-#define MODE_HTMIX     2
-#define MODE_HTGREENFIELD      3
-
-/* MCS for CCK.  BW.SGI.STBC are reserved */
-#define MCS_longP_RATE_1                      0        /* long preamble CCK 1Mbps */
-#define MCS_longP_RATE_2                      1        /* long preamble CCK 1Mbps */
-#define MCS_longP_RATE_5_5                    2
-#define MCS_longP_RATE_11                     3
-#define MCS_SHORTP_RATE_1                      4       /* long preamble CCK 1Mbps. short is forbidden in 1Mbps */
-#define MCS_SHORTP_RATE_2                      5       /* short preamble CCK 2Mbps */
-#define MCS_SHORTP_RATE_5_5                    6
-#define MCS_SHORTP_RATE_11                     7
-/* To send duplicate legacy OFDM. set BW=BW_40.  SGI.STBC are reserved */
-#define MCS_RATE_6                      0      /* legacy OFDM */
-#define MCS_RATE_9                      1      /* OFDM */
-#define MCS_RATE_12                     2      /* OFDM */
-#define MCS_RATE_18                     3      /* OFDM */
-#define MCS_RATE_24                     4      /* OFDM */
-#define MCS_RATE_36                     5      /* OFDM */
-#define MCS_RATE_48                     6      /* OFDM */
-#define MCS_RATE_54                     7      /* OFDM */
-/* HT */
-#define MCS_0          0       /* 1S */
-#define MCS_1          1
-#define MCS_2          2
-#define MCS_3          3
-#define MCS_4          4
-#define MCS_5          5
-#define MCS_6          6
-#define MCS_7          7
-#define MCS_8          8       /* 2S */
-#define MCS_9          9
-#define MCS_10         10
-#define MCS_11         11
-#define MCS_12         12
-#define MCS_13         13
-#define MCS_14         14
-#define MCS_15         15
-#define MCS_16         16      /* 3*3 */
-#define MCS_17         17
-#define MCS_18         18
-#define MCS_19         19
-#define MCS_20         20
-#define MCS_21         21
-#define MCS_22         22
-#define MCS_23         23
-#define MCS_32         32
-#define MCS_AUTO               33
-
-/* OID_HTPHYMODE */
-/* MODE */
-#define HTMODE_MM      0
-#define HTMODE_GF      1
-
-/* Fixed Tx MODE - HT, CCK or OFDM */
-#define FIXED_TXMODE_HT                0
-#define FIXED_TXMODE_CCK       1
-#define FIXED_TXMODE_OFDM      2
-/* BW */
-#define BW_20          BAND_WIDTH_20
-#define BW_40          BAND_WIDTH_40
-#define BW_BOTH                BAND_WIDTH_BOTH
-#define BW_10          BAND_WIDTH_10   /* 802.11j has 10MHz. This definition is for internal usage. doesn't fill in the IE or other field. */
-
-/* SHORTGI */
-#define GI_400         GAP_INTERVAL_400        /* only support in HT mode */
-#define GI_BOTH                GAP_INTERVAL_BOTH
-#define GI_800         GAP_INTERVAL_800
-/* STBC */
-#define STBC_NONE      0
-#define STBC_USE       1       /* limited use in rt2860b phy */
-#define RXSTBC_ONE     1       /* rx support of one spatial stream */
-#define RXSTBC_TWO     2       /* rx support of 1 and 2 spatial stream */
-#define RXSTBC_THR     3       /* rx support of 1~3 spatial stream */
-/* MCS FEEDBACK */
-#define MCSFBK_NONE    0       /* not support mcs feedback / */
-#define MCSFBK_RSV     1       /* reserved */
-#define MCSFBK_UNSOLICIT       2       /* only support unsolict mcs feedback */
-#define MCSFBK_MRQ     3       /* response to both MRQ and unsolict mcs feedback */
-
-/* MIMO power safe */
-#define        MMPS_STATIC     0
-#define        MMPS_DYNAMIC            1
-#define   MMPS_RSV             2
-#define MMPS_ENABLE            3
-
-/* A-MSDU size */
-#define        AMSDU_0 0
-#define        AMSDU_1         1
-
-/* MCS use 7 bits */
-#define TXRATEMIMO             0x80
-#define TXRATEMCS              0x7F
-#define TXRATEOFDM             0x7F
-#define RATE_1                      0
-#define RATE_2                      1
-#define RATE_5_5                    2
-#define RATE_11                     3
-#define RATE_6                      4  /* OFDM */
-#define RATE_9                      5  /* OFDM */
-#define RATE_12                     6  /* OFDM */
-#define RATE_18                     7  /* OFDM */
-#define RATE_24                     8  /* OFDM */
-#define RATE_36                     9  /* OFDM */
-#define RATE_48                     10 /* OFDM */
-#define RATE_54                     11 /* OFDM */
-#define RATE_FIRST_OFDM_RATE        RATE_6
-#define RATE_LAST_OFDM_RATE            RATE_54
-#define RATE_6_5                    12 /* HT mix */
-#define RATE_13                     13 /* HT mix */
-#define RATE_19_5                   14 /* HT mix */
-#define RATE_26                     15 /* HT mix */
-#define RATE_39                     16 /* HT mix */
-#define RATE_52                     17 /* HT mix */
-#define RATE_58_5                   18 /* HT mix */
-#define RATE_65                     19 /* HT mix */
-#define RATE_78                     20 /* HT mix */
-#define RATE_104                    21 /* HT mix */
-#define RATE_117                    22 /* HT mix */
-#define RATE_130                    23 /* HT mix */
-/*#define RATE_AUTO_SWITCH            255 // for StaCfg.FixedTxRate only */
-#define HTRATE_0                      12
-#define RATE_FIRST_MM_RATE        HTRATE_0
-#define RATE_FIRST_HT_RATE        HTRATE_0
-#define RATE_LAST_HT_RATE        HTRATE_0
-
-/* pTxWI->txop */
-#define IFS_HTTXOP                 0   /* The txop will be handles by ASIC. */
-#define IFS_PIFS                    1
-#define IFS_SIFS                    2
-#define IFS_BACKOFF                 3
-
-/* pTxD->RetryMode */
-#define long_RETRY                  1
-#define SHORT_RETRY                 0
-
-/* Country Region definition */
-#define REGION_MINIMUM_BG_BAND            0
-#define REGION_0_BG_BAND                  0    /* 1-11 */
-#define REGION_1_BG_BAND                  1    /* 1-13 */
-#define REGION_2_BG_BAND                  2    /* 10-11 */
-#define REGION_3_BG_BAND                  3    /* 10-13 */
-#define REGION_4_BG_BAND                  4    /* 14 */
-#define REGION_5_BG_BAND                  5    /* 1-14 */
-#define REGION_6_BG_BAND                  6    /* 3-9 */
-#define REGION_7_BG_BAND                  7    /* 5-13 */
-#define REGION_31_BG_BAND                 31   /* 5-13 */
-#define REGION_MAXIMUM_BG_BAND            7
-
-#define REGION_MINIMUM_A_BAND             0
-#define REGION_0_A_BAND                   0    /* 36, 40, 44, 48, 52, 56, 60, 64, 149, 153, 157, 161, 165 */
-#define REGION_1_A_BAND                   1    /* 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140 */
-#define REGION_2_A_BAND                   2    /* 36, 40, 44, 48, 52, 56, 60, 64 */
-#define REGION_3_A_BAND                   3    /* 52, 56, 60, 64, 149, 153, 157, 161 */
-#define REGION_4_A_BAND                   4    /* 149, 153, 157, 161, 165 */
-#define REGION_5_A_BAND                   5    /* 149, 153, 157, 161 */
-#define REGION_6_A_BAND                   6    /* 36, 40, 44, 48 */
-#define REGION_7_A_BAND                   7    /* 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165, 169, 173 */
-#define REGION_8_A_BAND                   8    /* 52, 56, 60, 64 */
-#define REGION_9_A_BAND                   9    /* 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140, 149, 153, 157, 161, 165 */
-#define REGION_10_A_BAND                  10   /* 36, 40, 44, 48, 149, 153, 157, 161, 165 */
-#define REGION_11_A_BAND                  11   /* 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 149, 153, 157, 161 */
-#define REGION_12_A_BAND                  12   /* 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140 */
-#define REGION_13_A_BAND                  13   /* 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161 */
-#define REGION_14_A_BAND                  14   /* 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 136, 140, 149, 153, 157, 161, 165 */
-#define REGION_15_A_BAND                  15   /* 149, 153, 157, 161, 165, 169, 173 */
-#define REGION_MAXIMUM_A_BAND             15
-
-/* pTxD->CipherAlg */
-#define CIPHER_NONE                 0
-#define CIPHER_WEP64                1
-#define CIPHER_WEP128               2
-#define CIPHER_TKIP                 3
-#define CIPHER_AES                  4
-#define CIPHER_CKIP64               5
-#define CIPHER_CKIP128              6
-#define CIPHER_TKIP_NO_MIC          7  /* MIC appended by driver: not a valid value in hardware key table */
-#define CIPHER_SMS4                                    8
-
-/* LED Status. */
-#define LED_LINK_DOWN               0
-#define LED_LINK_UP                 1
-#define LED_RADIO_OFF               2
-#define LED_RADIO_ON                3
-#define LED_HALT                    4
-#define LED_WPS                     5
-#define LED_ON_SITE_SURVEY          6
-#define LED_POWER_UP                7
-
-/* value domain of pAd->LedCntl.LedMode and E2PROM */
-#define LED_MODE_DEFAULT            0
-#define LED_MODE_TWO_LED                       1
-/*#define LED_MODE_SIGNAL_STREGTH               8  // EEPROM define =8 */
-#define LED_MODE_SIGNAL_STREGTH                0x40    /* EEPROM define = 64 */
-
-/* RC4 init value, used fro WEP & TKIP */
-#define PPPINITFCS32                0xffffffff /* Initial FCS value */
-
-/* value domain of pAd->StaCfg.PortSecured. 802.1X controlled port definition */
-#define WPA_802_1X_PORT_SECURED     1
-#define WPA_802_1X_PORT_NOT_SECURED 2
-
-#define PAIRWISE_KEY                1
-#define GROUP_KEY                   2
-
-/*definition of DRS */
-#define MAX_STEP_OF_TX_RATE_SWITCH     32
-
-/* pre-allocated free NDIS PACKET/BUFFER poll for internal usage */
-#define MAX_NUM_OF_FREE_NDIS_PACKET 128
-
-/*Block ACK */
-#define MAX_TX_REORDERBUF   64
-#define MAX_RX_REORDERBUF   64
-#define DEFAULT_TX_TIMEOUT   30
-#define DEFAULT_RX_TIMEOUT   30
-
-/* definition of Recipient or Originator */
-#define I_RECIPIENT                  TRUE
-#define I_ORIGINATOR                   FALSE
-
-#define DEFAULT_BBP_TX_POWER        0
-#define DEFAULT_RF_TX_POWER         5
-
-#define MAX_INI_BUFFER_SIZE                    4096
-#define MAX_PARAM_BUFFER_SIZE          (2048)  /* enough for ACL (18*64) */
-                                                                                       /*18 : the length of Mac address acceptable format "01:02:03:04:05:06;") */
-                                                                                       /*64 : MAX_NUM_OF_ACL_LIST */
-/* definition of pAd->OpMode */
-#define OPMODE_STA                  0
-#define OPMODE_AP                   1
-/*#define OPMODE_L3_BRG               2       // as AP and STA at the same time */
-
-/* ========================= AP rtmp_def.h =========================== */
-/* value domain for pAd->EventTab.Log[].Event */
-#define EVENT_RESET_ACCESS_POint    0  /* Log = "hh:mm:ss   Restart Access Point" */
-#define EVENT_ASSOCIATED            1  /* Log = "hh:mm:ss   STA 00:01:02:03:04:05 associated" */
-#define EVENT_DISASSOCIATED         2  /* Log = "hh:mm:ss   STA 00:01:02:03:04:05 left this BSS" */
-#define EVENT_AGED_OUT              3  /* Log = "hh:mm:ss   STA 00:01:02:03:04:05 was aged-out and removed from this BSS" */
-#define EVENT_COUNTER_M             4
-#define EVENT_INVALID_PSK           5
-#define EVENT_MAX_EVENT_TYPE        6
-/* ==== end of AP rtmp_def.h ============ */
-
-/* definition RSSI Number */
-#define RSSI_0                                 0
-#define RSSI_1                                 1
-#define RSSI_2                                 2
-
-/* definition of radar detection */
-#define RD_NORMAL_MODE                         0       /* Not found radar signal */
-#define RD_SWITCHING_MODE                      1       /* Found radar signal, and doing channel switch */
-#define RD_SILENCE_MODE                                2       /* After channel switch, need to be silence a while to ensure radar not found */
-
-/*Driver defined cid for mapping status and command. */
-#define  SLEEPCID      0x11
-#define  WAKECID       0x22
-#define  QUERYPOWERCID 0x33
-#define  OWNERMCU      0x1
-#define  OWNERCPU      0x0
-
-/* MBSSID definition */
-#define ENTRY_NOT_FOUND             0xFF
-
-/* After Linux 2.6.9,
- * VLAN module use Private (from user) interface flags (netdevice->priv_flags).
- * #define IFF_802_1Q_VLAN 0x1         --    802.1Q VLAN device.  in if.h
- * ref to ip_sabotage_out() [ out->priv_flags & IFF_802_1Q_VLAN ] in br_netfilter.c
- *
- * For this reason, we MUST use EVEN value in priv_flags
- */
-#define INT_MAIN                    0x0100
-#define INT_MBSSID                  0x0200
-#define INT_WDS                     0x0300
-#define INT_APCLI                   0x0400
-#define INT_MESH                       0x0500
-
-#define INF_MAIN_DEV_NAME              "wlan"
-#define INF_MBSSID_DEV_NAME            "ra"
-#define INF_WDS_DEV_NAME               "wds"
-#define INF_APCLI_DEV_NAME             "apcli"
-#define INF_MESH_DEV_NAME              "mesh"
-
-/* WEP Key TYPE */
-#define WEP_HEXADECIMAL_TYPE    0
-#define WEP_ASCII_TYPE          1
-
-/* WIRELESS EVENTS definition */
-/* Max number of char in custom event, refer to wireless_tools.28/wireless.20.h */
-#define IW_CUSTOM_MAX_LEN                                                      255     /* In bytes */
-
-/* For system event - start */
-#define        IW_SYS_EVENT_FLAG_START                     0x0200
-#define        IW_ASSOC_EVENT_FLAG                         0x0200
-#define        IW_DISASSOC_EVENT_FLAG                      0x0201
-#define        IW_DEAUTH_EVENT_FLAG                            0x0202
-#define        IW_AGEOUT_EVENT_FLAG                            0x0203
-#define        IW_COUNTER_MEASURES_EVENT_FLAG              0x0204
-#define        IW_REPLAY_COUNTER_DIFF_EVENT_FLAG           0x0205
-#define        IW_RSNIE_DIFF_EVENT_FLAG                                0x0206
-#define        IW_MIC_DIFF_EVENT_FLAG                                  0x0207
-#define IW_ICV_ERROR_EVENT_FLAG                                                0x0208
-#define IW_MIC_ERROR_EVENT_FLAG                                                0x0209
-#define IW_GROUP_HS_TIMEOUT_EVENT_FLAG                         0x020A
-#define        IW_PAIRWISE_HS_TIMEOUT_EVENT_FLAG                       0x020B
-#define IW_RSNIE_SANITY_FAIL_EVENT_FLAG                                0x020C
-#define IW_SET_KEY_DONE_WPA1_EVENT_FLAG                                0x020D
-#define IW_SET_KEY_DONE_WPA2_EVENT_FLAG                                0x020E
-#define IW_STA_LINKUP_EVENT_FLAG                                       0x020F
-#define IW_STA_LINKDOWN_EVENT_FLAG                                     0x0210
-#define IW_SCAN_COMPLETED_EVENT_FLAG                           0x0211
-#define IW_SCAN_ENQUEUE_FAIL_EVENT_FLAG                                0x0212
-/* if add new system event flag, please update the IW_SYS_EVENT_FLAG_END */
-#define        IW_SYS_EVENT_FLAG_END                       0x0212
-#define        IW_SYS_EVENT_TYPE_NUM                                           (IW_SYS_EVENT_FLAG_END - IW_SYS_EVENT_FLAG_START + 1)
-/* For system event - end */
-
-/* For spoof attack event - start */
-#define        IW_SPOOF_EVENT_FLAG_START                   0x0300
-#define IW_CONFLICT_SSID_EVENT_FLAG                                    0x0300
-#define IW_SPOOF_ASSOC_RESP_EVENT_FLAG                         0x0301
-#define IW_SPOOF_REASSOC_RESP_EVENT_FLAG                       0x0302
-#define IW_SPOOF_PROBE_RESP_EVENT_FLAG                         0x0303
-#define IW_SPOOF_BEACON_EVENT_FLAG                                     0x0304
-#define IW_SPOOF_DISASSOC_EVENT_FLAG                           0x0305
-#define IW_SPOOF_AUTH_EVENT_FLAG                                       0x0306
-#define IW_SPOOF_DEAUTH_EVENT_FLAG                                     0x0307
-#define IW_SPOOF_UNKNOWN_MGMT_EVENT_FLAG                       0x0308
-#define IW_REPLAY_ATTACK_EVENT_FLAG                                    0x0309
-/* if add new spoof attack event flag, please update the IW_SPOOF_EVENT_FLAG_END */
-#define        IW_SPOOF_EVENT_FLAG_END                     0x0309
-#define        IW_SPOOF_EVENT_TYPE_NUM                                         (IW_SPOOF_EVENT_FLAG_END - IW_SPOOF_EVENT_FLAG_START + 1)
-/* For spoof attack event - end */
-
-/* For flooding attack event - start */
-#define        IW_FLOOD_EVENT_FLAG_START                   0x0400
-#define IW_FLOOD_AUTH_EVENT_FLAG                                       0x0400
-#define IW_FLOOD_ASSOC_REQ_EVENT_FLAG                          0x0401
-#define IW_FLOOD_REASSOC_REQ_EVENT_FLAG                                0x0402
-#define IW_FLOOD_PROBE_REQ_EVENT_FLAG                          0x0403
-#define IW_FLOOD_DISASSOC_EVENT_FLAG                           0x0404
-#define IW_FLOOD_DEAUTH_EVENT_FLAG                                     0x0405
-#define IW_FLOOD_EAP_REQ_EVENT_FLAG                                    0x0406
-/* if add new flooding attack event flag, please update the IW_FLOOD_EVENT_FLAG_END */
-#define        IW_FLOOD_EVENT_FLAG_END                         0x0406
-#define        IW_FLOOD_EVENT_TYPE_NUM                                         (IW_FLOOD_EVENT_FLAG_END - IW_FLOOD_EVENT_FLAG_START + 1)
-/* For flooding attack - end */
-
-/* End - WIRELESS EVENTS definition */
-
-/* definition for DLS, kathy */
-#define        MAX_NUM_OF_INIT_DLS_ENTRY   1
-#define        MAX_NUM_OF_DLS_ENTRY        MAX_NUMBER_OF_DLS_ENTRY
-
-/*Block ACK, kathy */
-#define MAX_TX_REORDERBUF              64
-#define MAX_RX_REORDERBUF              64
-#define DEFAULT_TX_TIMEOUT             30
-#define DEFAULT_RX_TIMEOUT             30
-#define MAX_BARECI_SESSION             8
-
-#ifndef IW_ESSID_MAX_SIZE
-/* Maximum size of the ESSID and pAd->nickname strings */
-#define IW_ESSID_MAX_SIZE              32
-#endif
-
-/* For AsicRadioOff/AsicRadioOn function */
-#define DOT11POWERSAVE         0
-#define GUIRADIO_OFF           1
-#define RTMP_HALT                  2
-#define GUI_IDLE_POWER_SAVE            3
-/* -- */
-
-/* definition for WpaSupport flag */
-#define WPA_SUPPLICANT_DISABLE                         0
-#define WPA_SUPPLICANT_ENABLE                          1
-#define        WPA_SUPPLICANT_ENABLE_WITH_WEB_UI       2
-
-/* Endian byte swapping codes */
-#define SWAP16(x) \
-    ((u16)( \
-    (((u16)(x) & (u16)0x00ffU) << 8) | \
-    (((u16)(x) & (u16)0xff00U) >> 8) ))
-
-#define SWAP32(x) \
-    ((u32)( \
-    (((u32)(x) & (u32)0x000000ffUL) << 24) | \
-    (((u32)(x) & (u32)0x0000ff00UL) <<  8) | \
-    (((u32)(x) & (u32)0x00ff0000UL) >>  8) | \
-    (((u32)(x) & (u32)0xff000000UL) >> 24) ))
-
-#define SWAP64(x) \
-    ((u64)( \
-    (u64)(((u64)(x) & (u64)0x00000000000000ffULL) << 56) | \
-    (u64)(((u64)(x) & (u64)0x000000000000ff00ULL) << 40) | \
-    (u64)(((u64)(x) & (u64)0x0000000000ff0000ULL) << 24) | \
-    (u64)(((u64)(x) & (u64)0x00000000ff000000ULL) <<  8) | \
-    (u64)(((u64)(x) & (u64)0x000000ff00000000ULL) >>  8) | \
-    (u64)(((u64)(x) & (u64)0x0000ff0000000000ULL) >> 24) | \
-    (u64)(((u64)(x) & (u64)0x00ff000000000000ULL) >> 40) | \
-    (u64)(((u64)(x) & (u64)0xff00000000000000ULL) >> 56) ))
-
-#define cpu2le64(x) ((u64)(x))
-#define le2cpu64(x) ((u64)(x))
-#define cpu2le32(x) ((u32)(x))
-#define le2cpu32(x) ((u32)(x))
-#define cpu2le16(x) ((u16)(x))
-#define le2cpu16(x) ((u16)(x))
-#define cpu2be64(x) SWAP64((x))
-#define be2cpu64(x) SWAP64((x))
-#define cpu2be32(x) SWAP32((x))
-#define be2cpu32(x) SWAP32((x))
-#define cpu2be16(x) SWAP16((x))
-#define be2cpu16(x) SWAP16((x))
-
-#define ABS(_x, _y) ((_x) > (_y)) ? ((_x) -(_y)) : ((_y) -(_x))
-
-#define A2Dec(_X, _p)                          \
-{                                                                      \
-       u8 *p;                                          \
-       _X = 0;                                                 \
-       p = _p;                                                 \
-       while (((*p >= '0') && (*p <= '9')))            \
-       {                                                                                               \
-               if ((*p >= '0') && (*p <= '9'))         \
-                       _X = _X * 10 + *p - 48;                                 \
-               p++;                                                                            \
-       }                                                                                               \
-}
-
-#define A2Hex(_X, _p)                          \
-do{                                                                    \
-       char *__p;                                              \
-       (_X) = 0;                                                       \
-       __p = (char *)(_p);                                                     \
-       while (((*__p >= 'a') && (*__p <= 'f')) || ((*__p >= 'A') && (*__p <= 'F')) || ((*__p >= '0') && (*__p <= '9')))                \
-       {                                                                                               \
-               if ((*__p >= 'a') && (*__p <= 'f'))                             \
-                       (_X) = (_X) * 16 + *__p - 87;                                   \
-               else if ((*__p >= 'A') && (*__p <= 'F'))                \
-                       (_X) = (_X) * 16 + *__p - 55;                                   \
-               else if ((*__p >= '0') && (*__p <= '9'))                \
-                       (_X) = (_X) * 16 + *__p - 48;                                   \
-               __p++;                                                                          \
-       }                                                                                               \
-}while(0)
-
-#endif /* __RTMP_DEF_H__ */
diff --git a/drivers/staging/rt2860/rtmp_dot11.h b/drivers/staging/rt2860/rtmp_dot11.h
deleted file mode 100644 (file)
index 4f8abd7..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-*/
-
-#ifndef __DOT11_BASE_H__
-#define __DOT11_BASE_H__
-
-#include "rtmp_type.h"
-
-/* 4-byte HTC field.  maybe included in any frame except non-QOS data frame.  The Order bit must set 1. */
-struct PACKED rt_ht_control {
-       u32 MA:1;               /*management action payload exist in (QoS Null+HTC) */
-       u32 TRQ:1;              /*sounding request */
-       u32 MRQ:1;              /*MCS feedback. Request for a MCS feedback */
-       u32 MRSorASI:3; /* MRQ Sequence identifier. unchanged during entire procedure. 0x000-0x110. */
-       u32 MFS:3;              /*SET to the received value of MRS. 0x111 for unsolicited MFB. */
-       u32 MFBorASC:7; /*Link adaptation feedback containing recommended MCS. 0x7f for no feedback or not available */
-       u32 CalPos:2;   /* calibration position */
-       u32 CalSeq:2;   /*calibration sequence */
-       u32 FBKReq:2;   /*feedback request */
-       u32 CSISTEERING:2;      /*CSI/ STEERING */
-       u32 ZLFAnnouce:1;       /* ZLF announcement */
-       u32 rsv:5;              /*calibration sequence */
-       u32 ACConstraint:1;     /*feedback request */
-       u32 RDG:1;              /*RDG / More PPDU */
-};
-
-/* 2-byte QOS CONTROL field */
-struct PACKED rt_qos_control {
-       u16 TID:4;
-       u16 EOSP:1;
-       u16 AckPolicy:2;        /*0: normal ACK 1:No ACK 2:scheduled under MTBA/PSMP  3: BA */
-       u16 AMsduPresent:1;
-       u16 Txop_QueueSize:8;
-};
-
-/* 2-byte Frame control field */
-struct PACKED rt_frame_control {
-       u16 Ver:2;              /* Protocol version */
-       u16 Type:2;             /* MSDU type */
-       u16 SubType:4;  /* MSDU subtype */
-       u16 ToDs:1;             /* To DS indication */
-       u16 FrDs:1;             /* From DS indication */
-       u16 MoreFrag:1; /* More fragment bit */
-       u16 Retry:1;            /* Retry status bit */
-       u16 PwrMgmt:1;  /* Power management bit */
-       u16 MoreData:1; /* More data bit */
-       u16 Wep:1;              /* Wep data */
-       u16 Order:1;            /* Strict order expected */
-};
-
-struct PACKED rt_header_802_11 {
-       struct rt_frame_control FC;
-       u16 Duration;
-       u8 Addr1[MAC_ADDR_LEN];
-       u8 Addr2[MAC_ADDR_LEN];
-       u8 Addr3[MAC_ADDR_LEN];
-       u16 Frag:4;
-       u16 Sequence:12;
-       u8 Octet[0];
-};
-
-struct PACKED rt_pspoll_frame {
-       struct rt_frame_control FC;
-       u16 Aid;
-       u8 Bssid[MAC_ADDR_LEN];
-       u8 Ta[MAC_ADDR_LEN];
-};
-
-struct PACKED rt_rts_frame {
-       struct rt_frame_control FC;
-       u16 Duration;
-       u8 Addr1[MAC_ADDR_LEN];
-       u8 Addr2[MAC_ADDR_LEN];
-};
-
-#endif /* __DOT11_BASE_H__ // */
diff --git a/drivers/staging/rt2860/rtmp_iface.h b/drivers/staging/rt2860/rtmp_iface.h
deleted file mode 100644 (file)
index 808c055..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-    Module Name:
-       rt_iface.h
-
-    Abstract:
-
-    Revision History:
-    Who          When          What
-    ---------    ----------    ----------------------------------------------
- */
-
-#ifndef __RTMP_IFACE_H__
-#define __RTMP_IFACE_H__
-
-#ifdef RTMP_PCI_SUPPORT
-#include "iface/rtmp_pci.h"
-#endif /* RTMP_PCI_SUPPORT // */
-#ifdef RTMP_USB_SUPPORT
-#include "iface/rtmp_usb.h"
-#endif /* RTMP_USB_SUPPORT // */
-
-struct rt_inf_pci_config {
-       unsigned long CSRBaseAddress;   /* PCI MMIO Base Address, all access will use */
-       unsigned int irq_num;
-};
-
-struct rt_inf_usb_config {
-       u8 BulkInEpAddr;        /* bulk-in endpoint address */
-       u8 BulkOutEpAddr[6];    /* bulk-out endpoint address */
-};
-
-struct rt_inf_rbus_config {
-       unsigned long csr_addr;
-       unsigned int irq;
-};
-
-typedef enum _RTMP_INF_TYPE_ {
-       RTMP_DEV_INF_UNKNOWN = 0,
-       RTMP_DEV_INF_PCI = 1,
-       RTMP_DEV_INF_USB = 2,
-       RTMP_DEV_INF_RBUS = 4,
-} RTMP_INF_TYPE;
-
-typedef union _RTMP_INF_CONFIG_ {
-       struct rt_inf_pci_config pciConfig;
-       struct rt_inf_usb_config usbConfig;
-       struct rt_inf_rbus_config rbusConfig;
-} RTMP_INF_CONFIG;
-
-#endif /* __RTMP_IFACE_H__ // */
diff --git a/drivers/staging/rt2860/rtmp_mcu.h b/drivers/staging/rt2860/rtmp_mcu.h
deleted file mode 100644 (file)
index d0987e5..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-       Module Name:
-       rtmp_mcu.h
-
-       Abstract:
-       Miniport header file for mcu related information
-
-       Revision History:
-       Who         When          What
-       --------    ----------    ----------------------------------------------
-*/
-
-#ifndef __RTMP_MCU_H__
-#define __RTMP_MCU_H__
-
-int RtmpAsicEraseFirmware(struct rt_rtmp_adapter *pAd);
-
-int RtmpAsicLoadFirmware(struct rt_rtmp_adapter *pAd);
-
-int RtmpAsicSendCommandToMcu(struct rt_rtmp_adapter *pAd,
-                            u8 Command,
-                            u8 Token, u8 Arg0, u8 Arg1);
-
-#endif /* __RTMP_MCU_H__ // */
diff --git a/drivers/staging/rt2860/rtmp_os.h b/drivers/staging/rt2860/rtmp_os.h
deleted file mode 100644 (file)
index 94c30c8..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-    Module Name:
-       rtmp_os.h
-
-    Abstract:
-
-    Revision History:
-    Who          When          What
-    ---------    ----------    ----------------------------------------------
- */
-
-#ifndef __RTMP_OS_H__
-#define __RTMP_OS_H__
-
-#ifdef LINUX
-#include "rt_linux.h"
-#endif /* LINUX // */
-
-/*
-       This data structure mainly strip some callback function defined in
-       "struct net_device" in kernel source "include/linux/netdevice.h".
-
-       The definition of this data structure may various depends on different
-       OS. Use it carefully.
-*/
-struct rt_rtmp_os_netdev_op_hook {
-       const struct net_device_ops *netdev_ops;
-       void *priv;
-       int priv_flags;
-       unsigned char devAddr[6];
-       unsigned char devName[16];
-       unsigned char needProtcted;
-};
-
-typedef enum _RTMP_TASK_STATUS_ {
-       RTMP_TASK_STAT_UNKNOWN = 0,
-       RTMP_TASK_STAT_INITED = 1,
-       RTMP_TASK_STAT_RUNNING = 2,
-       RTMP_TASK_STAT_STOPED = 4,
-} RTMP_TASK_STATUS;
-#define RTMP_TASK_CAN_DO_INSERT                (RTMP_TASK_STAT_INITED |RTMP_TASK_STAT_RUNNING)
-
-#define RTMP_OS_TASK_NAME_LEN  16
-struct rt_rtmp_os_task {
-       char taskName[RTMP_OS_TASK_NAME_LEN];
-       void *priv;
-       /*unsigned long         taskFlags; */
-       RTMP_TASK_STATUS taskStatus;
-#ifndef KTHREAD_SUPPORT
-       struct semaphore taskSema;
-       struct pid *taskPID;
-       struct completion taskComplete;
-#endif
-       unsigned char task_killed;
-#ifdef KTHREAD_SUPPORT
-       struct task_struct *kthread_task;
-       wait_queue_head_t kthread_q;
-       BOOLEAN kthread_running;
-#endif
-};
-
-int RtmpOSIRQRequest(struct net_device *pNetDev);
-int RtmpOSIRQRelease(struct net_device *pNetDev);
-
-#endif /* __RMTP_OS_H__ // */
diff --git a/drivers/staging/rt2860/rtmp_timer.h b/drivers/staging/rt2860/rtmp_timer.h
deleted file mode 100644 (file)
index 15b6287..0000000
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-    Module Name:
-       rtmp_timer.h
-
-    Abstract:
-       Ralink Wireless Driver timer related data structures and declarations 
-
-    Revision History:
-       Who                     When                 What
-       --------    ----------      ----------------------------------------------
-       Name                    Date                 Modification logs
-       Shiang Tu               Aug-28-2008          init version
-       Justin P. Mattock       11/07/2010           Fix a typo
-
-*/
-
-#ifndef __RTMP_TIMER_H__
-#define  __RTMP_TIMER_H__
-
-#include "rtmp_os.h"
-
-#define DECLARE_TIMER_FUNCTION(_func)                  \
-       void rtmp_timer_##_func(unsigned long data)
-
-#define GET_TIMER_FUNCTION(_func)                              \
-       rtmp_timer_##_func
-
-/* ----------------- Timer Related MARCO ---------------*/
-/* In some os or chipset, we have a lot of timer functions and will read/write register, */
-/* it's not allowed in Linux USB sub-system to do it ( because of sleep issue when */
-/* submit to ctrl pipe). So we need a wrapper function to take care it. */
-
-#ifdef RTMP_TIMER_TASK_SUPPORT
-typedef void(*RTMP_TIMER_TASK_HANDLE) (void *SystemSpecific1,
-                                      void *FunctionContext,
-                                      void *SystemSpecific2,
-                                      void *SystemSpecific3);
-#endif /* RTMP_TIMER_TASK_SUPPORT // */
-
-struct rt_ralink_timer {
-       struct timer_list TimerObj;     /* Ndis Timer object */
-       BOOLEAN Valid;          /* Set to True when call RTMPInitTimer */
-       BOOLEAN State;          /* True if timer cancelled */
-       BOOLEAN PeriodicType;   /* True if timer is periodic timer */
-       BOOLEAN Repeat;         /* True if periodic timer */
-       unsigned long TimerValue;       /* Timer value in milliseconds */
-       unsigned long cookie;           /* os specific object */
-#ifdef RTMP_TIMER_TASK_SUPPORT
-       RTMP_TIMER_TASK_HANDLE handle;
-       void *pAd;
-#endif                         /* RTMP_TIMER_TASK_SUPPORT // */
-};
-
-#ifdef RTMP_TIMER_TASK_SUPPORT
-struct rt_rtmp_timer_task_entry {
-       struct rt_ralink_timer *pRaTimer;
-       struct rt_rtmp_timer_task_entry *pNext;
-};
-
-#define TIMER_QUEUE_SIZE_MAX   128
-struct rt_rtmp_timer_task_queue {
-       unsigned int status;
-       unsigned char *pTimerQPoll;
-       struct rt_rtmp_timer_task_entry *pQPollFreeList;
-       struct rt_rtmp_timer_task_entry *pQHead;
-       struct rt_rtmp_timer_task_entry *pQTail;
-};
-
-#define BUILD_TIMER_FUNCTION(_func)                                                                            \
-void rtmp_timer_##_func(unsigned long data)                                                                            \
-{                                                                                                                                                      \
-       struct rt_ralink_timer *_pTimer = (struct rt_ralink_timer *)data;                               \
-       struct rt_rtmp_timer_task_entry *_pQNode;                                                                               \
-       struct rt_rtmp_adapter *_pAd;                                                                                   \
-                                                                                                                                                       \
-       _pTimer->handle = _func;                                                                                                        \
-       _pAd = (struct rt_rtmp_adapter *)_pTimer->pAd;                                                                          \
-       _pQNode = RtmpTimerQInsert(_pAd, _pTimer);                                                              \
-       if ((_pQNode == NULL) && (_pAd->TimerQ.status & RTMP_TASK_CAN_DO_INSERT))       \
-               RTMP_OS_Add_Timer(&_pTimer->TimerObj, OS_HZ);                                                   \
-}
-#else
-#define BUILD_TIMER_FUNCTION(_func)                                                                            \
-void rtmp_timer_##_func(unsigned long data)                                                                            \
-{                                                                                                                                                      \
-       struct rt_ralink_timer *pTimer = (struct rt_ralink_timer *)data;                                \
-                                                                                                                                                       \
-       _func(NULL, (void *)pTimer->cookie, NULL, pTimer);                                                      \
-       if (pTimer->Repeat)                                                                                                             \
-               RTMP_OS_Add_Timer(&pTimer->TimerObj, pTimer->TimerValue);                       \
-}
-#endif /* RTMP_TIMER_TASK_SUPPORT // */
-
-DECLARE_TIMER_FUNCTION(MlmePeriodicExec);
-DECLARE_TIMER_FUNCTION(MlmeRssiReportExec);
-DECLARE_TIMER_FUNCTION(AsicRxAntEvalTimeout);
-DECLARE_TIMER_FUNCTION(APSDPeriodicExec);
-DECLARE_TIMER_FUNCTION(AsicRfTuningExec);
-#ifdef RTMP_MAC_USB
-DECLARE_TIMER_FUNCTION(BeaconUpdateExec);
-#endif /* RTMP_MAC_USB // */
-
-DECLARE_TIMER_FUNCTION(BeaconTimeout);
-DECLARE_TIMER_FUNCTION(ScanTimeout);
-DECLARE_TIMER_FUNCTION(AuthTimeout);
-DECLARE_TIMER_FUNCTION(AssocTimeout);
-DECLARE_TIMER_FUNCTION(ReassocTimeout);
-DECLARE_TIMER_FUNCTION(DisassocTimeout);
-DECLARE_TIMER_FUNCTION(LinkDownExec);
-DECLARE_TIMER_FUNCTION(StaQuickResponeForRateUpExec);
-DECLARE_TIMER_FUNCTION(WpaDisassocApAndBlockAssoc);
-DECLARE_TIMER_FUNCTION(PsPollWakeExec);
-DECLARE_TIMER_FUNCTION(RadioOnExec);
-
-#ifdef RTMP_MAC_USB
-DECLARE_TIMER_FUNCTION(RtmpUsbStaAsicForceWakeupTimeout);
-#endif /* RTMP_MAC_USB // */
-
-#if defined(AP_LED) || defined(STA_LED)
-DECLARE_TIMER_FUNCTION(LedCtrlMain);
-#endif
-
-#endif /* __RTMP_TIMER_H__ // */
diff --git a/drivers/staging/rt2860/rtmp_type.h b/drivers/staging/rt2860/rtmp_type.h
deleted file mode 100644 (file)
index d9bb2d6..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-    Module Name:
-    rtmp_type.h
-
-    Abstract:
-
-    Revision History:
-    Who         When            What
-    --------    ----------      ----------------------------------------------
-    Name        Date            Modification logs
-    Paul Lin    1-2-2004
-*/
-#ifndef __RTMP_TYPE_H__
-#define __RTMP_TYPE_H__
-
-#include <linux/types.h>
-
-#define PACKED  __attribute__ ((packed))
-
-typedef unsigned char BOOLEAN;
-
-typedef union _LARGE_INTEGER {
-       struct {
-               u32 LowPart;
-               int HighPart;
-       } u;
-       long long QuadPart;
-} LARGE_INTEGER;
-
-/* */
-/* Register set pair for initialzation register set definition */
-/* */
-struct rt_rtmp_reg_pair {
-       unsigned long Register;
-       unsigned long Value;
-};
-
-struct rt_reg_pair {
-       u8 Register;
-       u8 Value;
-};
-
-/* */
-/* Register set pair for initialzation register set definition */
-/* */
-struct rt_rtmp_rf_regs {
-       u8 Channel;
-       unsigned long R1;
-       unsigned long R2;
-       unsigned long R3;
-       unsigned long R4;
-};
-
-struct rt_frequency_item {
-       u8 Channel;
-       u8 N;
-       u8 R;
-       u8 K;
-};
-
-#define STATUS_SUCCESS                         0x00
-#define STATUS_UNSUCCESSFUL            0x01
-
-#endif /* __RTMP_TYPE_H__ // */
diff --git a/drivers/staging/rt2860/rtusb_io.h b/drivers/staging/rt2860/rtusb_io.h
deleted file mode 100644 (file)
index 64a2fe4..0000000
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-*/
-
-#ifndef __RTUSB_IO_H__
-#define __RTUSB_IO_H__
-
-#include "rtmp_type.h"
-
-/* New for MeetingHouse Api support */
-#define CMDTHREAD_VENDOR_RESET                      0x0D730101 /* cmd */
-#define CMDTHREAD_VENDOR_UNPLUG                     0x0D730102 /* cmd */
-#define CMDTHREAD_VENDOR_SWITCH_FUNCTION            0x0D730103 /* cmd */
-#define CMDTHREAD_MULTI_WRITE_MAC                   0x0D730107 /* cmd */
-#define CMDTHREAD_MULTI_READ_MAC                    0x0D730108 /* cmd */
-#define CMDTHREAD_VENDOR_EEPROM_WRITE               0x0D73010A /* cmd */
-#define CMDTHREAD_VENDOR_EEPROM_READ                0x0D73010B /* cmd */
-#define CMDTHREAD_VENDOR_ENTER_TESTMODE             0x0D73010C /* cmd */
-#define CMDTHREAD_VENDOR_EXIT_TESTMODE              0x0D73010D /* cmd */
-#define CMDTHREAD_VENDOR_WRITE_BBP                  0x0D730119 /* cmd */
-#define CMDTHREAD_VENDOR_READ_BBP                   0x0D730118 /* cmd */
-#define CMDTHREAD_VENDOR_WRITE_RF                   0x0D73011A /* cmd */
-#define CMDTHREAD_VENDOR_FLIP_IQ                    0x0D73011D /* cmd */
-#define CMDTHREAD_RESET_BULK_OUT                    0x0D730210 /* cmd */
-#define CMDTHREAD_RESET_BULK_IN                     0x0D730211 /* cmd */
-#define CMDTHREAD_SET_PSM_BIT                          0x0D730212      /* cmd */
-#define CMDTHREAD_SET_RADIO                         0x0D730214 /* cmd */
-#define CMDTHREAD_UPDATE_TX_RATE                    0x0D730216 /* cmd */
-#define CMDTHREAD_802_11_ADD_KEY_WEP                0x0D730218 /* cmd */
-#define CMDTHREAD_RESET_FROM_ERROR                  0x0D73021A /* cmd */
-#define CMDTHREAD_LINK_DOWN                         0x0D73021B /* cmd */
-#define CMDTHREAD_RESET_FROM_NDIS                   0x0D73021C /* cmd */
-#define CMDTHREAD_CHECK_GPIO                        0x0D730215 /* cmd */
-#define CMDTHREAD_FORCE_WAKE_UP                     0x0D730222 /* cmd */
-#define CMDTHREAD_SET_BW                            0x0D730225 /* cmd */
-#define CMDTHREAD_SET_ASIC_WCID                     0x0D730226 /* cmd */
-#define CMDTHREAD_SET_ASIC_WCID_CIPHER              0x0D730227 /* cmd */
-#define CMDTHREAD_QKERIODIC_EXECUT                  0x0D73023D /* cmd */
-#define RT_CMD_SET_KEY_TABLE                        0x0D730228 /* cmd */
-#define RT_CMD_SET_RX_WCID_TABLE                    0x0D730229 /* cmd */
-#define CMDTHREAD_SET_CLIENT_MAC_ENTRY              0x0D73023E /* cmd */
-#define CMDTHREAD_SET_GROUP_KEY                                                0x0D73023F      /* cmd */
-#define CMDTHREAD_SET_PAIRWISE_KEY                                     0x0D730240      /* cmd */
-
-#define CMDTHREAD_802_11_QUERY_HARDWARE_REGISTER    0x0D710105 /* cmd */
-#define CMDTHREAD_802_11_SET_PHY_MODE               0x0D79010C /* cmd */
-#define CMDTHREAD_802_11_SET_STA_CONFIG             0x0D790111 /* cmd */
-#define CMDTHREAD_802_11_SET_PREAMBLE               0x0D790101 /* cmd */
-#define CMDTHREAD_802_11_COUNTER_MEASURE                       0x0D790102      /* cmd */
-/* add by johnli, fix "in_interrupt" error when call "MacTableDeleteEntry" in Rx tasklet */
-#define CMDTHREAD_UPDATE_PROTECT                                       0x0D790103      /* cmd */
-/* end johnli */
-
-/*CMDTHREAD_MULTI_READ_MAC */
-/*CMDTHREAD_MULTI_WRITE_MAC */
-/*CMDTHREAD_VENDOR_EEPROM_READ */
-/*CMDTHREAD_VENDOR_EEPROM_WRITE */
-struct rt_cmdhandler_tlv {
-       u16 Offset;
-       u16 Length;
-       u8 DataFirst;
-};
-
-struct rt_cmdqelmt;
-
-struct rt_cmdqelmt {
-       u32 command;
-       void *buffer;
-       unsigned long bufferlength;
-       BOOLEAN CmdFromNdis;
-       BOOLEAN SetOperation;
-       struct rt_cmdqelmt *next;
-};
-
-struct rt_cmdq {
-       u32 size;
-       struct rt_cmdqelmt *head;
-       struct rt_cmdqelmt *tail;
-       u32 CmdQState;
-};
-
-#define EnqueueCmd(cmdq, cmdqelmt)             \
-{                                                                              \
-       if (cmdq->size == 0)                            \
-               cmdq->head = cmdqelmt;                  \
-       else                                                            \
-               cmdq->tail->next = cmdqelmt;    \
-       cmdq->tail = cmdqelmt;                          \
-       cmdqelmt->next = NULL;                          \
-       cmdq->size++;                                           \
-}
-
-/******************************************************************************
-
-       USB Cmd to ASIC Related MACRO
-
-******************************************************************************/
-/* reset MAC of a station entry to 0xFFFFFFFFFFFF */
-#define RTMP_STA_ENTRY_MAC_RESET(pAd, Wcid)                                    \
-       {       struct rt_set_asic_wcid SetAsicWcid;                                            \
-               SetAsicWcid.WCID = Wcid;                                                                \
-               SetAsicWcid.SetTid = 0xffffffff;                                                \
-               SetAsicWcid.DeleteTid = 0xffffffff;                                             \
-               RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_SET_ASIC_WCID,   \
-                               &SetAsicWcid, sizeof(struct rt_set_asic_wcid)); }
-
-/* add this entry into ASIC RX WCID search table */
-#define RTMP_STA_ENTRY_ADD(pAd, pEntry)                                                        \
-       RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_SET_CLIENT_MAC_ENTRY,    \
-                                                       pEntry, sizeof(struct rt_mac_table_entry));
-
-/* add by johnli, fix "in_interrupt" error when call "MacTableDeleteEntry" in Rx tasklet */
-/* Set MAC register value according operation mode */
-#define RTMP_UPDATE_PROTECT(pAd)       \
-       RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_UPDATE_PROTECT, NULL, 0);
-/* end johnli */
-
-/* remove Pair-wise key material from ASIC */
-/* yet implement */
-#define RTMP_STA_ENTRY_KEY_DEL(pAd, BssIdx, Wcid)
-
-/* add Client security information into ASIC WCID table and IVEIV table */
-#define RTMP_STA_SECURITY_INFO_ADD(pAd, apidx, KeyID, pEntry)                                          \
-       {       RTMP_STA_ENTRY_MAC_RESET(pAd, pEntry->Aid);                                                             \
-               if (pEntry->Aid >= 1) {                                                                                                         \
-                       struct rt_set_asic_wcid_attri   SetAsicWcidAttri;                                                               \
-                       SetAsicWcidAttri.WCID = pEntry->Aid;                                                                    \
-                       if ((pEntry->AuthMode <= Ndis802_11AuthModeAutoSwitch) &&                               \
-                               (pEntry->WepStatus == Ndis802_11Encryption1Enabled))                            \
-                       {                                                                                                                                               \
-                               SetAsicWcidAttri.Cipher = pAd->SharedKey[apidx][KeyID].CipherAlg;       \
-                       }                                                                                                                                               \
-                       else if (pEntry->AuthMode == Ndis802_11AuthModeWPANone)                                 \
-                       {                                                                                                                                               \
-                               SetAsicWcidAttri.Cipher = pAd->SharedKey[apidx][KeyID].CipherAlg;       \
-                       }                                                                                                                                               \
-                       else SetAsicWcidAttri.Cipher = 0;                                                                               \
-            DBGPRINT(RT_DEBUG_TRACE, ("aid cipher = %ld\n",SetAsicWcidAttri.Cipher));       \
-                       RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_SET_ASIC_WCID_CIPHER,                    \
-                                                       &SetAsicWcidAttri, sizeof(struct rt_set_asic_wcid_attri)); } }
-
-/* Insert the BA bitmap to ASIC for the Wcid entry */
-#define RTMP_ADD_BA_SESSION_TO_ASIC(_pAd, _Aid, _TID)                                  \
-               do{                                                                                                                             \
-                       struct rt_set_asic_wcid SetAsicWcid;                                                    \
-                       SetAsicWcid.WCID = (_Aid);                                                                      \
-                       SetAsicWcid.SetTid = (0x10000<<(_TID));                                         \
-                       SetAsicWcid.DeleteTid = 0xffffffff;                                                     \
-                       RTUSBEnqueueInternalCmd((_pAd), CMDTHREAD_SET_ASIC_WCID, &SetAsicWcid, sizeof(struct rt_set_asic_wcid));        \
-               }while(0)
-
-/* Remove the BA bitmap from ASIC for the Wcid entry */
-#define RTMP_DEL_BA_SESSION_FROM_ASIC(_pAd, _Wcid, _TID)                               \
-               do{                                                                                                                             \
-                       struct rt_set_asic_wcid SetAsicWcid;                                                    \
-                       SetAsicWcid.WCID = (_Wcid);                                                                     \
-                       SetAsicWcid.SetTid = (0xffffffff);                                                      \
-                       SetAsicWcid.DeleteTid = (0x10000<<(_TID) );                                     \
-                       RTUSBEnqueueInternalCmd((_pAd), CMDTHREAD_SET_ASIC_WCID, &SetAsicWcid, sizeof(struct rt_set_asic_wcid));        \
-               }while(0)
-
-#endif /* __RTUSB_IO_H__ // */
diff --git a/drivers/staging/rt2860/spectrum.h b/drivers/staging/rt2860/spectrum.h
deleted file mode 100644 (file)
index 4c325ba..0000000
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
- */
-
-#ifndef __SPECTRUM_H__
-#define __SPECTRUM_H__
-
-#include "rtmp_type.h"
-#include "spectrum_def.h"
-
-char RTMP_GetTxPwr(struct rt_rtmp_adapter *pAd, IN HTTRANSMIT_SETTING HTTxMode);
-
-/*
-       ==========================================================================
-       Description:
-               Prepare Measurement request action frame and enqueue it into
-               management queue waiting for transmission.
-
-       Parametrs:
-               1. the destination mac address of the frame.
-
-       Return  : None.
-       ==========================================================================
- */
-void MakeMeasurementReqFrame(struct rt_rtmp_adapter *pAd,
-                            u8 *pOutBuffer,
-                            unsigned long *pFrameLen,
-                            u8 TotalLen,
-                            u8 Category,
-                            u8 Action,
-                            u8 MeasureToken,
-                            u8 MeasureReqMode,
-                            u8 MeasureReqType,
-                            u8 NumOfRepetitions);
-
-/*
-       ==========================================================================
-       Description:
-               Prepare Measurement report action frame and enqueue it into
-               management queue waiting for transmission.
-
-       Parametrs:
-               1. the destination mac address of the frame.
-
-       Return  : None.
-       ==========================================================================
- */
-void EnqueueMeasurementRep(struct rt_rtmp_adapter *pAd,
-                          u8 *pDA,
-                          u8 DialogToken,
-                          u8 MeasureToken,
-                          u8 MeasureReqMode,
-                          u8 MeasureReqType,
-                          u8 ReportInfoLen, u8 *pReportInfo);
-
-/*
-       ==========================================================================
-       Description:
-               Prepare TPC Request action frame and enqueue it into
-               management queue waiting for transmission.
-
-       Parametrs:
-               1. the destination mac address of the frame.
-
-       Return  : None.
-       ==========================================================================
- */
-void EnqueueTPCReq(struct rt_rtmp_adapter *pAd, u8 *pDA, u8 DialogToken);
-
-/*
-       ==========================================================================
-       Description:
-               Prepare TPC Report action frame and enqueue it into
-               management queue waiting for transmission.
-
-       Parametrs:
-               1. the destination mac address of the frame.
-
-       Return  : None.
-       ==========================================================================
- */
-void EnqueueTPCRep(struct rt_rtmp_adapter *pAd,
-                  u8 *pDA,
-                  u8 DialogToken, u8 TxPwr, u8 LinkMargin);
-
-/*
-       ==========================================================================
-       Description:
-               Prepare Channel Switch Announcement action frame and enqueue it into
-               management queue waiting for transmission.
-
-       Parametrs:
-               1. the destination mac address of the frame.
-               2. Channel switch announcement mode.
-               2. a New selected channel.
-
-       Return  : None.
-       ==========================================================================
- */
-void EnqueueChSwAnn(struct rt_rtmp_adapter *pAd,
-                   u8 *pDA, u8 ChSwMode, u8 NewCh);
-
-/*
-       ==========================================================================
-       Description:
-               Spectrun action frames Handler such as channel switch announcement,
-               measurement report, measurement request actions frames.
-
-       Parametrs:
-               Elme - MLME message containing the received frame
-
-       Return  : None.
-       ==========================================================================
- */
-void PeerSpectrumAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem);
-
-/*
-       ==========================================================================
-       Description:
-
-       Parametrs:
-
-       Return  : None.
-       ==========================================================================
- */
-int Set_MeasureReq_Proc(struct rt_rtmp_adapter *pAd, char *arg);
-
-int Set_TpcReq_Proc(struct rt_rtmp_adapter *pAd, char *arg);
-
-int Set_PwrConstraint(struct rt_rtmp_adapter *pAd, char *arg);
-
-void MeasureReqTabInit(struct rt_rtmp_adapter *pAd);
-
-void MeasureReqTabExit(struct rt_rtmp_adapter *pAd);
-
-struct rt_measure_req_entry *MeasureReqLookUp(struct rt_rtmp_adapter *pAd, u8 DialogToken);
-
-struct rt_measure_req_entry *MeasureReqInsert(struct rt_rtmp_adapter *pAd, u8 DialogToken);
-
-void MeasureReqDelete(struct rt_rtmp_adapter *pAd, u8 DialogToken);
-
-void InsertChannelRepIE(struct rt_rtmp_adapter *pAd,
-                       u8 *pFrameBuf,
-                       unsigned long *pFrameLen,
-                       char *pCountry, u8 RegulatoryClass);
-
-void InsertTpcReportIE(struct rt_rtmp_adapter *pAd,
-                      u8 *pFrameBuf,
-                      unsigned long *pFrameLen,
-                      u8 TxPwr, u8 LinkMargin);
-
-void InsertDialogToken(struct rt_rtmp_adapter *pAd,
-                      u8 *pFrameBuf,
-                      unsigned long *pFrameLen, u8 DialogToken);
-
-void TpcReqTabInit(struct rt_rtmp_adapter *pAd);
-
-void TpcReqTabExit(struct rt_rtmp_adapter *pAd);
-
-void NotifyChSwAnnToPeerAPs(struct rt_rtmp_adapter *pAd,
-                           u8 *pRA,
-                           u8 *pTA, u8 ChSwMode, u8 Channel);
-
-void RguClass_BuildBcnChList(struct rt_rtmp_adapter *pAd,
-                            u8 *pBuf, unsigned long *pBufLen);
-#endif /* __SPECTRUM_H__ // */
diff --git a/drivers/staging/rt2860/spectrum_def.h b/drivers/staging/rt2860/spectrum_def.h
deleted file mode 100644 (file)
index 8ffcfb0..0000000
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-    Module Name:
-       spectrum_def.h
-
-    Abstract:
-    Handle association related requests either from WSTA or from local MLME
-
-    Revision History:
-    Who          When          What
-    ---------    ----------    ----------------------------------------------
-       Fonchi Wu    2008                  created for 802.11h
- */
-
-#ifndef __SPECTRUM_DEF_H__
-#define __SPECTRUM_DEF_H__
-
-#define MAX_MEASURE_REQ_TAB_SIZE               32
-#define MAX_HASH_MEASURE_REQ_TAB_SIZE  MAX_MEASURE_REQ_TAB_SIZE
-
-#define MAX_TPC_REQ_TAB_SIZE                   32
-#define MAX_HASH_TPC_REQ_TAB_SIZE              MAX_TPC_REQ_TAB_SIZE
-
-#define MIN_RCV_PWR                            100     /* Negative value ((dBm) */
-
-#define TPC_REQ_AGE_OUT                        500     /* ms */
-#define MQ_REQ_AGE_OUT                 500     /* ms */
-
-#define TPC_DIALOGTOKEN_HASH_INDEX(_DialogToken)       ((_DialogToken) % MAX_HASH_TPC_REQ_TAB_SIZE)
-#define MQ_DIALOGTOKEN_HASH_INDEX(_DialogToken)                ((_DialogToken) % MAX_MEASURE_REQ_TAB_SIZE)
-
-struct rt_measure_req_entry;
-
-struct rt_measure_req_entry {
-       struct rt_measure_req_entry *pNext;
-       unsigned long lastTime;
-       BOOLEAN Valid;
-       u8 DialogToken;
-       u8 MeasureDialogToken[3];       /* 0:basic measure, 1: CCA measure, 2: RPI_Histogram measure. */
-};
-
-struct rt_measure_req_tab {
-       u8 Size;
-       struct rt_measure_req_entry *Hash[MAX_HASH_MEASURE_REQ_TAB_SIZE];
-       struct rt_measure_req_entry Content[MAX_MEASURE_REQ_TAB_SIZE];
-};
-
-struct rt_tpc_req_entry;
-
-struct rt_tpc_req_entry {
-       struct rt_tpc_req_entry *pNext;
-       unsigned long lastTime;
-       BOOLEAN Valid;
-       u8 DialogToken;
-};
-
-struct rt_tpc_req_tab {
-       u8 Size;
-       struct rt_tpc_req_entry *Hash[MAX_HASH_TPC_REQ_TAB_SIZE];
-       struct rt_tpc_req_entry Content[MAX_TPC_REQ_TAB_SIZE];
-};
-
-/* The regulatory information */
-struct rt_dot11_channel_set {
-       u8 NumberOfChannels;
-       u8 MaxTxPwr;
-       u8 ChannelList[16];
-};
-
-struct rt_dot11_regulatory_information {
-       u8 RegulatoryClass;
-       struct rt_dot11_channel_set ChannelSet;
-};
-
-#define RM_TPC_REQ                             0
-#define RM_MEASURE_REQ                 1
-
-#define RM_BASIC                               0
-#define RM_CCA                                 1
-#define RM_RPI_HISTOGRAM               2
-#define RM_CH_LOAD                             3
-#define RM_NOISE_HISTOGRAM             4
-
-struct PACKED rt_tpc_report_info {
-       u8 TxPwr;
-       u8 LinkMargin;
-};
-
-struct PACKED rt_ch_sw_ann_info {
-       u8 ChSwMode;
-       u8 Channel;
-       u8 ChSwCnt;
-};
-
-typedef union PACKED _MEASURE_REQ_MODE {
-       struct PACKED {
-               u8 Parallel:1;
-               u8 Enable:1;
-               u8 Request:1;
-               u8 Report:1;
-               u8 DurationMandatory:1;
-                u8:3;
-       } field;
-       u8 word;
-} MEASURE_REQ_MODE, *PMEASURE_REQ_MODE;
-
-struct PACKED rt_measure_req {
-       u8 ChNum;
-       u64 MeasureStartTime;
-       u16 MeasureDuration;
-};
-
-struct PACKED rt_measure_req_info {
-       u8 Token;
-       MEASURE_REQ_MODE ReqMode;
-       u8 ReqType;
-       u8 Oct[0];
-};
-
-typedef union PACKED _MEASURE_BASIC_REPORT_MAP {
-       struct PACKED {
-               u8 BSS:1;
-
-               u8 OfdmPreamble:1;
-               u8 UnidentifiedSignal:1;
-               u8 Radar:1;
-               u8 Unmeasure:1;
-               u8 Rev:3;
-       } field;
-       u8 word;
-} MEASURE_BASIC_REPORT_MAP, *PMEASURE_BASIC_REPORT_MAP;
-
-struct PACKED rt_measure_basic_report {
-       u8 ChNum;
-       u64 MeasureStartTime;
-       u16 MeasureDuration;
-       MEASURE_BASIC_REPORT_MAP Map;
-};
-
-struct PACKED rt_measure_cca_report {
-       u8 ChNum;
-       u64 MeasureStartTime;
-       u16 MeasureDuration;
-       u8 CCA_Busy_Fraction;
-};
-
-struct PACKED rt_measure_rpi_report {
-       u8 ChNum;
-       u64 MeasureStartTime;
-       u16 MeasureDuration;
-       u8 RPI_Density[8];
-};
-
-typedef union PACKED _MEASURE_REPORT_MODE {
-       struct PACKED {
-               u8 Late:1;
-               u8 Incapable:1;
-               u8 Refused:1;
-               u8 Rev:5;
-       } field;
-       u8 word;
-} MEASURE_REPORT_MODE, *PMEASURE_REPORT_MODE;
-
-struct PACKED rt_measure_report_info {
-       u8 Token;
-       u8 ReportMode;
-       u8 ReportType;
-       u8 Octect[0];
-};
-
-struct PACKED rt_quiet_info {
-       u8 QuietCnt;
-       u8 QuietPeriod;
-       u16 QuietDuration;
-       u16 QuietOffset;
-};
-
-#endif /* __SPECTRUM_DEF_H__ // */
diff --git a/drivers/staging/rt2860/sta/assoc.c b/drivers/staging/rt2860/sta/assoc.c
deleted file mode 100644 (file)
index 59e931c..0000000
+++ /dev/null
@@ -1,1602 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-       Module Name:
-       assoc.c
-
-       Abstract:
-
-       Revision History:
-       Who                     When                    What
-       --------        ----------              ----------------------------------------------
-       John                    2004-9-3                porting from RT2500
-       Justin P. Mattock       11/07/2010              Fix typos
-*/
-#include "../rt_config.h"
-
-u8 CipherWpaTemplate[] = {
-       0xdd,                   /* WPA IE */
-       0x16,                   /* Length */
-       0x00, 0x50, 0xf2, 0x01, /* oui */
-       0x01, 0x00,             /* Version */
-       0x00, 0x50, 0xf2, 0x02, /* Multicast */
-       0x01, 0x00,             /* Number of unicast */
-       0x00, 0x50, 0xf2, 0x02, /* unicast */
-       0x01, 0x00,             /* number of authentication method */
-       0x00, 0x50, 0xf2, 0x01  /* authentication */
-};
-
-u8 CipherWpa2Template[] = {
-       0x30,                   /* RSN IE */
-       0x14,                   /* Length */
-       0x01, 0x00,             /* Version */
-       0x00, 0x0f, 0xac, 0x02, /* group cipher, TKIP */
-       0x01, 0x00,             /* number of pairwise */
-       0x00, 0x0f, 0xac, 0x02, /* unicast */
-       0x01, 0x00,             /* number of authentication method */
-       0x00, 0x0f, 0xac, 0x02, /* authentication */
-       0x00, 0x00,             /* RSN capability */
-};
-
-u8 Ccx2IeInfo[] = { 0x00, 0x40, 0x96, 0x03, 0x02 };
-
-/*
-       ==========================================================================
-       Description:
-               association state machine init, including state transition and timer init
-       Parameters:
-               S - pointer to the association state machine
-
-       IRQL = PASSIVE_LEVEL
-
-       ==========================================================================
- */
-void AssocStateMachineInit(struct rt_rtmp_adapter *pAd,
-                          struct rt_state_machine *S, OUT STATE_MACHINE_FUNC Trans[])
-{
-       StateMachineInit(S, Trans, MAX_ASSOC_STATE, MAX_ASSOC_MSG,
-                        (STATE_MACHINE_FUNC) Drop, ASSOC_IDLE,
-                        ASSOC_MACHINE_BASE);
-
-       /* first column */
-       StateMachineSetAction(S, ASSOC_IDLE, MT2_MLME_ASSOC_REQ,
-                             (STATE_MACHINE_FUNC) MlmeAssocReqAction);
-       StateMachineSetAction(S, ASSOC_IDLE, MT2_MLME_REASSOC_REQ,
-                             (STATE_MACHINE_FUNC) MlmeReassocReqAction);
-       StateMachineSetAction(S, ASSOC_IDLE, MT2_MLME_DISASSOC_REQ,
-                             (STATE_MACHINE_FUNC) MlmeDisassocReqAction);
-       StateMachineSetAction(S, ASSOC_IDLE, MT2_PEER_DISASSOC_REQ,
-                             (STATE_MACHINE_FUNC) PeerDisassocAction);
-
-       /* second column */
-       StateMachineSetAction(S, ASSOC_WAIT_RSP, MT2_MLME_ASSOC_REQ,
-                             (STATE_MACHINE_FUNC) InvalidStateWhenAssoc);
-       StateMachineSetAction(S, ASSOC_WAIT_RSP, MT2_MLME_REASSOC_REQ,
-                             (STATE_MACHINE_FUNC) InvalidStateWhenReassoc);
-       StateMachineSetAction(S, ASSOC_WAIT_RSP, MT2_MLME_DISASSOC_REQ,
-                             (STATE_MACHINE_FUNC)
-                             InvalidStateWhenDisassociate);
-       StateMachineSetAction(S, ASSOC_WAIT_RSP, MT2_PEER_DISASSOC_REQ,
-                             (STATE_MACHINE_FUNC) PeerDisassocAction);
-       StateMachineSetAction(S, ASSOC_WAIT_RSP, MT2_PEER_ASSOC_RSP,
-                             (STATE_MACHINE_FUNC) PeerAssocRspAction);
-       /* */
-       /* Patch 3Com AP MOde:3CRWE454G72 */
-       /* We send Assoc request frame to this AP, it always send Reassoc Rsp not Associate Rsp. */
-       /* */
-       StateMachineSetAction(S, ASSOC_WAIT_RSP, MT2_PEER_REASSOC_RSP,
-                             (STATE_MACHINE_FUNC) PeerAssocRspAction);
-       StateMachineSetAction(S, ASSOC_WAIT_RSP, MT2_ASSOC_TIMEOUT,
-                             (STATE_MACHINE_FUNC) AssocTimeoutAction);
-
-       /* third column */
-       StateMachineSetAction(S, REASSOC_WAIT_RSP, MT2_MLME_ASSOC_REQ,
-                             (STATE_MACHINE_FUNC) InvalidStateWhenAssoc);
-       StateMachineSetAction(S, REASSOC_WAIT_RSP, MT2_MLME_REASSOC_REQ,
-                             (STATE_MACHINE_FUNC) InvalidStateWhenReassoc);
-       StateMachineSetAction(S, REASSOC_WAIT_RSP, MT2_MLME_DISASSOC_REQ,
-                             (STATE_MACHINE_FUNC)
-                             InvalidStateWhenDisassociate);
-       StateMachineSetAction(S, REASSOC_WAIT_RSP, MT2_PEER_DISASSOC_REQ,
-                             (STATE_MACHINE_FUNC) PeerDisassocAction);
-       StateMachineSetAction(S, REASSOC_WAIT_RSP, MT2_PEER_REASSOC_RSP,
-                             (STATE_MACHINE_FUNC) PeerReassocRspAction);
-       /* */
-       /* Patch, AP doesn't send Reassociate Rsp frame to Station. */
-       /* */
-       StateMachineSetAction(S, REASSOC_WAIT_RSP, MT2_PEER_ASSOC_RSP,
-                             (STATE_MACHINE_FUNC) PeerReassocRspAction);
-       StateMachineSetAction(S, REASSOC_WAIT_RSP, MT2_REASSOC_TIMEOUT,
-                             (STATE_MACHINE_FUNC) ReassocTimeoutAction);
-
-       /* fourth column */
-       StateMachineSetAction(S, DISASSOC_WAIT_RSP, MT2_MLME_ASSOC_REQ,
-                             (STATE_MACHINE_FUNC) InvalidStateWhenAssoc);
-       StateMachineSetAction(S, DISASSOC_WAIT_RSP, MT2_MLME_REASSOC_REQ,
-                             (STATE_MACHINE_FUNC) InvalidStateWhenReassoc);
-       StateMachineSetAction(S, DISASSOC_WAIT_RSP, MT2_MLME_DISASSOC_REQ,
-                             (STATE_MACHINE_FUNC)
-                             InvalidStateWhenDisassociate);
-       StateMachineSetAction(S, DISASSOC_WAIT_RSP, MT2_PEER_DISASSOC_REQ,
-                             (STATE_MACHINE_FUNC) PeerDisassocAction);
-       StateMachineSetAction(S, DISASSOC_WAIT_RSP, MT2_DISASSOC_TIMEOUT,
-                             (STATE_MACHINE_FUNC) DisassocTimeoutAction);
-
-       /* initialize the timer */
-       RTMPInitTimer(pAd, &pAd->MlmeAux.AssocTimer,
-                     GET_TIMER_FUNCTION(AssocTimeout), pAd, FALSE);
-       RTMPInitTimer(pAd, &pAd->MlmeAux.ReassocTimer,
-                     GET_TIMER_FUNCTION(ReassocTimeout), pAd, FALSE);
-       RTMPInitTimer(pAd, &pAd->MlmeAux.DisassocTimer,
-                     GET_TIMER_FUNCTION(DisassocTimeout), pAd, FALSE);
-}
-
-/*
-       ==========================================================================
-       Description:
-               Association timeout procedure. After association timeout, this function
-               will be called and it will put a message into the MLME queue
-       Parameters:
-               Standard timer parameters
-
-       IRQL = DISPATCH_LEVEL
-
-       ==========================================================================
- */
-void AssocTimeout(void *SystemSpecific1,
-                 void *FunctionContext,
-                 void *SystemSpecific2, void *SystemSpecific3)
-{
-       struct rt_rtmp_adapter *pAd = (struct rt_rtmp_adapter *)FunctionContext;
-
-       /* Do nothing if the driver is starting halt state. */
-       /* This might happen when timer already been fired before cancel timer with mlmehalt */
-       if (RTMP_TEST_FLAG
-           (pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST))
-               return;
-
-       MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_ASSOC_TIMEOUT, 0, NULL);
-       RTMP_MLME_HANDLER(pAd);
-}
-
-/*
-       ==========================================================================
-       Description:
-               Reassociation timeout procedure. After reassociation timeout, this
-               function will be called and put a message into the MLME queue
-       Parameters:
-               Standard timer parameters
-
-       IRQL = DISPATCH_LEVEL
-
-       ==========================================================================
- */
-void ReassocTimeout(void *SystemSpecific1,
-                   void *FunctionContext,
-                   void *SystemSpecific2, void *SystemSpecific3)
-{
-       struct rt_rtmp_adapter *pAd = (struct rt_rtmp_adapter *)FunctionContext;
-
-       /* Do nothing if the driver is starting halt state. */
-       /* This might happen when timer already been fired before cancel timer with mlmehalt */
-       if (RTMP_TEST_FLAG
-           (pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST))
-               return;
-
-       MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_REASSOC_TIMEOUT, 0, NULL);
-       RTMP_MLME_HANDLER(pAd);
-}
-
-/*
-       ==========================================================================
-       Description:
-               Disassociation timeout procedure. After disassociation timeout, this
-               function will be called and put a message into the MLME queue
-       Parameters:
-               Standard timer parameters
-
-       IRQL = DISPATCH_LEVEL
-
-       ==========================================================================
- */
-void DisassocTimeout(void *SystemSpecific1,
-                    void *FunctionContext,
-                    void *SystemSpecific2, void *SystemSpecific3)
-{
-       struct rt_rtmp_adapter *pAd = (struct rt_rtmp_adapter *)FunctionContext;
-
-       /* Do nothing if the driver is starting halt state. */
-       /* This might happen when timer already been fired before cancel timer with mlmehalt */
-       if (RTMP_TEST_FLAG
-           (pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST))
-               return;
-
-       MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_DISASSOC_TIMEOUT, 0, NULL);
-       RTMP_MLME_HANDLER(pAd);
-}
-
-/*
-       ==========================================================================
-       Description:
-               mlme assoc req handling procedure
-       Parameters:
-               Adapter - Adapter pointer
-               Elem - MLME Queue Element
-       Pre:
-               the station has been authenticated and the following information is stored in the config
-                       -# SSID
-                       -# supported rates and their length
-                       -# listen interval (Adapter->StaCfg.default_listen_count)
-                       -# Transmit power  (Adapter->StaCfg.tx_power)
-       Post  :
-               -# An association request frame is generated and sent to the air
-               -# Association timer starts
-               -# Association state -> ASSOC_WAIT_RSP
-
-       IRQL = DISPATCH_LEVEL
-
-       ==========================================================================
- */
-void MlmeAssocReqAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
-{
-       u8 ApAddr[6];
-       struct rt_header_802_11 AssocHdr;
-       u8 WmeIe[9] =
-           { IE_VENDOR_SPECIFIC, 0x07, 0x00, 0x50, 0xf2, 0x02, 0x00, 0x01,
-       0x00 };
-       u16 ListenIntv;
-       unsigned long Timeout;
-       u16 CapabilityInfo;
-       BOOLEAN TimerCancelled;
-       u8 *pOutBuffer = NULL;
-       int NStatus;
-       unsigned long FrameLen = 0;
-       unsigned long tmp;
-       u16 VarIesOffset;
-       u16 Status;
-
-       /* Block all authentication request during WPA block period */
-       if (pAd->StaCfg.bBlockAssoc == TRUE) {
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("ASSOC - Block Assoc request during WPA block period!\n"));
-               pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
-               Status = MLME_STATE_MACHINE_REJECT;
-               MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_ASSOC_CONF, 2,
-                           &Status);
-       }
-       /* check sanity first */
-       else if (MlmeAssocReqSanity
-                (pAd, Elem->Msg, Elem->MsgLen, ApAddr, &CapabilityInfo,
-                 &Timeout, &ListenIntv)) {
-               RTMPCancelTimer(&pAd->MlmeAux.AssocTimer, &TimerCancelled);
-               COPY_MAC_ADDR(pAd->MlmeAux.Bssid, ApAddr);
-
-               /* Get an unused nonpaged memory */
-               NStatus = MlmeAllocateMemory(pAd, &pOutBuffer);
-               if (NStatus != NDIS_STATUS_SUCCESS) {
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("ASSOC - MlmeAssocReqAction() allocate memory failed \n"));
-                       pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
-                       Status = MLME_FAIL_NO_RESOURCE;
-                       MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE,
-                                   MT2_ASSOC_CONF, 2, &Status);
-                       return;
-               }
-               /* Add by James 03/06/27 */
-               pAd->StaCfg.AssocInfo.Length =
-                   sizeof(struct rt_ndis_802_11_association_information);
-               /* Association don't need to report MAC address */
-               pAd->StaCfg.AssocInfo.AvailableRequestFixedIEs =
-                   NDIS_802_11_AI_REQFI_CAPABILITIES |
-                   NDIS_802_11_AI_REQFI_LISTENINTERVAL;
-               pAd->StaCfg.AssocInfo.RequestFixedIEs.Capabilities =
-                   CapabilityInfo;
-               pAd->StaCfg.AssocInfo.RequestFixedIEs.ListenInterval =
-                   ListenIntv;
-               /* Only reassociate need this */
-               /*COPY_MAC_ADDR(pAd->StaCfg.AssocInfo.RequestFixedIEs.CurrentAPAddress, ApAddr); */
-               pAd->StaCfg.AssocInfo.OffsetRequestIEs =
-                   sizeof(struct rt_ndis_802_11_association_information);
-
-               NdisZeroMemory(pAd->StaCfg.ReqVarIEs, MAX_VIE_LEN);
-               /* First add SSID */
-               VarIesOffset = 0;
-               NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset, &SsidIe,
-                              1);
-               VarIesOffset += 1;
-               NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset,
-                              &pAd->MlmeAux.SsidLen, 1);
-               VarIesOffset += 1;
-               NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset,
-                              pAd->MlmeAux.Ssid, pAd->MlmeAux.SsidLen);
-               VarIesOffset += pAd->MlmeAux.SsidLen;
-
-               /* Second add Supported rates */
-               NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset, &SupRateIe,
-                              1);
-               VarIesOffset += 1;
-               NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset,
-                              &pAd->MlmeAux.SupRateLen, 1);
-               VarIesOffset += 1;
-               NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset,
-                              pAd->MlmeAux.SupRate, pAd->MlmeAux.SupRateLen);
-               VarIesOffset += pAd->MlmeAux.SupRateLen;
-               /* End Add by James */
-
-               if ((pAd->CommonCfg.Channel > 14) &&
-                   (pAd->CommonCfg.bIEEE80211H == TRUE))
-                       CapabilityInfo |= 0x0100;
-
-               DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - Send ASSOC request...\n"));
-               MgtMacHeaderInit(pAd, &AssocHdr, SUBTYPE_ASSOC_REQ, 0, ApAddr,
-                                ApAddr);
-
-               /* Build basic frame first */
-               MakeOutgoingFrame(pOutBuffer, &FrameLen,
-                                 sizeof(struct rt_header_802_11), &AssocHdr,
-                                 2, &CapabilityInfo,
-                                 2, &ListenIntv,
-                                 1, &SsidIe,
-                                 1, &pAd->MlmeAux.SsidLen,
-                                 pAd->MlmeAux.SsidLen, pAd->MlmeAux.Ssid,
-                                 1, &SupRateIe,
-                                 1, &pAd->MlmeAux.SupRateLen,
-                                 pAd->MlmeAux.SupRateLen, pAd->MlmeAux.SupRate,
-                                 END_OF_ARGS);
-
-               if (pAd->MlmeAux.ExtRateLen != 0) {
-                       MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
-                                         1, &ExtRateIe,
-                                         1, &pAd->MlmeAux.ExtRateLen,
-                                         pAd->MlmeAux.ExtRateLen,
-                                         pAd->MlmeAux.ExtRate, END_OF_ARGS);
-                       FrameLen += tmp;
-               }
-               /* HT */
-               if ((pAd->MlmeAux.HtCapabilityLen > 0)
-                   && (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)) {
-                       unsigned long TmpLen;
-                       u8 HtLen;
-                       u8 BROADCOM[4] = { 0x0, 0x90, 0x4c, 0x33 };
-                       if (pAd->StaActive.SupportedPhyInfo.bPreNHt == TRUE) {
-                               HtLen = SIZE_HT_CAP_IE + 4;
-                               MakeOutgoingFrame(pOutBuffer + FrameLen,
-                                                 &TmpLen, 1, &WpaIe, 1, &HtLen,
-                                                 4, &BROADCOM[0],
-                                                 pAd->MlmeAux.HtCapabilityLen,
-                                                 &pAd->MlmeAux.HtCapability,
-                                                 END_OF_ARGS);
-                       } else {
-                               MakeOutgoingFrame(pOutBuffer + FrameLen,
-                                                 &TmpLen, 1, &HtCapIe, 1,
-                                                 &pAd->MlmeAux.HtCapabilityLen,
-                                                 pAd->MlmeAux.HtCapabilityLen,
-                                                 &pAd->MlmeAux.HtCapability,
-                                                 END_OF_ARGS);
-                       }
-                       FrameLen += TmpLen;
-               }
-               /* add Ralink proprietary IE to inform AP this STA is going to use AGGREGATION or PIGGY-BACK+AGGREGATION */
-               /* Case I: (Aggregation + Piggy-Back) */
-               /* 1. user enable aggregation, AND */
-               /* 2. Mac support piggy-back */
-               /* 3. AP annouces it's PIGGY-BACK+AGGREGATION-capable in BEACON */
-               /* Case II: (Aggregation) */
-               /* 1. user enable aggregation, AND */
-               /* 2. AP annouces it's AGGREGATION-capable in BEACON */
-               if (pAd->CommonCfg.bAggregationCapable) {
-                       if ((pAd->CommonCfg.bPiggyBackCapable)
-                           && ((pAd->MlmeAux.APRalinkIe & 0x00000003) == 3)) {
-                               unsigned long TmpLen;
-                               u8 RalinkIe[9] =
-                                   { IE_VENDOR_SPECIFIC, 7, 0x00, 0x0c, 0x43,
-                           0x03, 0x00, 0x00, 0x00 };
-                               MakeOutgoingFrame(pOutBuffer + FrameLen,
-                                                 &TmpLen, 9, RalinkIe,
-                                                 END_OF_ARGS);
-                               FrameLen += TmpLen;
-                       } else if (pAd->MlmeAux.APRalinkIe & 0x00000001) {
-                               unsigned long TmpLen;
-                               u8 RalinkIe[9] =
-                                   { IE_VENDOR_SPECIFIC, 7, 0x00, 0x0c, 0x43,
-                           0x01, 0x00, 0x00, 0x00 };
-                               MakeOutgoingFrame(pOutBuffer + FrameLen,
-                                                 &TmpLen, 9, RalinkIe,
-                                                 END_OF_ARGS);
-                               FrameLen += TmpLen;
-                       }
-               } else {
-                       unsigned long TmpLen;
-                       u8 RalinkIe[9] =
-                           { IE_VENDOR_SPECIFIC, 7, 0x00, 0x0c, 0x43, 0x06,
-                   0x00, 0x00, 0x00 };
-                       MakeOutgoingFrame(pOutBuffer + FrameLen, &TmpLen, 9,
-                                         RalinkIe, END_OF_ARGS);
-                       FrameLen += TmpLen;
-               }
-
-               if (pAd->MlmeAux.APEdcaParm.bValid) {
-                       if (pAd->CommonCfg.bAPSDCapable
-                           && pAd->MlmeAux.APEdcaParm.bAPSDCapable) {
-                               struct rt_qbss_sta_info_parm QosInfo;
-
-                               NdisZeroMemory(&QosInfo,
-                                              sizeof(struct rt_qbss_sta_info_parm));
-                               QosInfo.UAPSD_AC_BE = pAd->CommonCfg.bAPSDAC_BE;
-                               QosInfo.UAPSD_AC_BK = pAd->CommonCfg.bAPSDAC_BK;
-                               QosInfo.UAPSD_AC_VI = pAd->CommonCfg.bAPSDAC_VI;
-                               QosInfo.UAPSD_AC_VO = pAd->CommonCfg.bAPSDAC_VO;
-                               QosInfo.MaxSPLength =
-                                   pAd->CommonCfg.MaxSPLength;
-                               WmeIe[8] |= *(u8 *)& QosInfo;
-                       } else {
-                               /* The Parameter Set Count is set to ¡§0¡¨ in the association request frames */
-                               /* WmeIe[8] |= (pAd->MlmeAux.APEdcaParm.EdcaUpdateCount & 0x0f); */
-                       }
-
-                       MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
-                                         9, &WmeIe[0], END_OF_ARGS);
-                       FrameLen += tmp;
-               }
-               /* */
-               /* Let WPA(#221) Element ID on the end of this association frame. */
-               /* Otherwise some AP will fail on parsing Element ID and set status fail on Assoc Rsp. */
-               /* For example: Put Vendor Specific IE on the front of WPA IE. */
-               /* This happens on AP (Model No:Linksys WRK54G) */
-               /* */
-               if (((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
-                    (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
-                    (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
-                    (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2)
-                   )
-                   ) {
-                       u8 RSNIe = IE_WPA;
-
-                       if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)
-                           || (pAd->StaCfg.AuthMode ==
-                               Ndis802_11AuthModeWPA2)) {
-                               RSNIe = IE_WPA2;
-                       }
-
-                       if ((pAd->StaCfg.WpaSupplicantUP !=
-                            WPA_SUPPLICANT_ENABLE)
-                           && (pAd->StaCfg.bRSN_IE_FromWpaSupplicant == FALSE))
-                               RTMPMakeRSNIE(pAd, pAd->StaCfg.AuthMode,
-                                             pAd->StaCfg.WepStatus, BSS0);
-
-                       /* Check for WPA PMK cache list */
-                       if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) {
-                               int idx;
-                               BOOLEAN FoundPMK = FALSE;
-                               /* Search chched PMKID, append it if existed */
-                               for (idx = 0; idx < PMKID_NO; idx++) {
-                                       if (NdisEqualMemory
-                                           (ApAddr,
-                                            &pAd->StaCfg.SavedPMK[idx].BSSID,
-                                            6)) {
-                                               FoundPMK = TRUE;
-                                               break;
-                                       }
-                               }
-                               if (FoundPMK) {
-                                       /* Set PMK number */
-                                       *(u16 *)& pAd->StaCfg.RSN_IE[pAd->
-                                                                       StaCfg.
-                                                                       RSNIE_Len]
-                                           = 1;
-                                       NdisMoveMemory(&pAd->StaCfg.
-                                                      RSN_IE[pAd->StaCfg.
-                                                             RSNIE_Len + 2],
-                                                      &pAd->StaCfg.
-                                                      SavedPMK[idx].PMKID, 16);
-                                       pAd->StaCfg.RSNIE_Len += 18;
-                               }
-                       }
-
-                       if ((pAd->StaCfg.WpaSupplicantUP ==
-                            WPA_SUPPLICANT_ENABLE)
-                           && (pAd->StaCfg.bRSN_IE_FromWpaSupplicant ==
-                               TRUE)) {
-                               MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
-                                                 pAd->StaCfg.RSNIE_Len,
-                                                 pAd->StaCfg.RSN_IE,
-                                                 END_OF_ARGS);
-                       } else {
-                               MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
-                                                 1, &RSNIe,
-                                                 1, &pAd->StaCfg.RSNIE_Len,
-                                                 pAd->StaCfg.RSNIE_Len,
-                                                 pAd->StaCfg.RSN_IE,
-                                                 END_OF_ARGS);
-                       }
-
-                       FrameLen += tmp;
-
-                       if ((pAd->StaCfg.WpaSupplicantUP !=
-                            WPA_SUPPLICANT_ENABLE)
-                           || (pAd->StaCfg.bRSN_IE_FromWpaSupplicant ==
-                               FALSE)) {
-                               /* Append Variable IE */
-                               NdisMoveMemory(pAd->StaCfg.ReqVarIEs +
-                                              VarIesOffset, &RSNIe, 1);
-                               VarIesOffset += 1;
-                               NdisMoveMemory(pAd->StaCfg.ReqVarIEs +
-                                              VarIesOffset,
-                                              &pAd->StaCfg.RSNIE_Len, 1);
-                               VarIesOffset += 1;
-                       }
-                       NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset,
-                                      pAd->StaCfg.RSN_IE,
-                                      pAd->StaCfg.RSNIE_Len);
-                       VarIesOffset += pAd->StaCfg.RSNIE_Len;
-
-                       /* Set Variable IEs Length */
-                       pAd->StaCfg.ReqVarIELen = VarIesOffset;
-               }
-
-               MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
-               MlmeFreeMemory(pAd, pOutBuffer);
-
-               RTMPSetTimer(&pAd->MlmeAux.AssocTimer, Timeout);
-               pAd->Mlme.AssocMachine.CurrState = ASSOC_WAIT_RSP;
-       } else {
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("ASSOC - MlmeAssocReqAction() sanity check failed. BUG!\n"));
-               pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
-               Status = MLME_INVALID_FORMAT;
-               MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_ASSOC_CONF, 2,
-                           &Status);
-       }
-
-}
-
-/*
-       ==========================================================================
-       Description:
-               mlme reassoc req handling procedure
-       Parameters:
-               Elem -
-       Pre:
-               -# SSID  (Adapter->StaCfg.ssid[])
-               -# BSSID (AP address, Adapter->StaCfg.bssid)
-               -# Supported rates (Adapter->StaCfg.supported_rates[])
-               -# Supported rates length (Adapter->StaCfg.supported_rates_len)
-               -# Tx power (Adapter->StaCfg.tx_power)
-
-       IRQL = DISPATCH_LEVEL
-
-       ==========================================================================
- */
-void MlmeReassocReqAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
-{
-       u8 ApAddr[6];
-       struct rt_header_802_11 ReassocHdr;
-       u8 WmeIe[9] =
-           { IE_VENDOR_SPECIFIC, 0x07, 0x00, 0x50, 0xf2, 0x02, 0x00, 0x01,
-       0x00 };
-       u16 CapabilityInfo, ListenIntv;
-       unsigned long Timeout;
-       unsigned long FrameLen = 0;
-       BOOLEAN TimerCancelled;
-       int NStatus;
-       unsigned long tmp;
-       u8 *pOutBuffer = NULL;
-       u16 Status;
-
-       /* Block all authentication request during WPA block period */
-       if (pAd->StaCfg.bBlockAssoc == TRUE) {
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("ASSOC - Block ReAssoc request during WPA block period!\n"));
-               pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
-               Status = MLME_STATE_MACHINE_REJECT;
-               MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_REASSOC_CONF, 2,
-                           &Status);
-       }
-       /* the parameters are the same as the association */
-       else if (MlmeAssocReqSanity
-                (pAd, Elem->Msg, Elem->MsgLen, ApAddr, &CapabilityInfo,
-                 &Timeout, &ListenIntv)) {
-               RTMPCancelTimer(&pAd->MlmeAux.ReassocTimer, &TimerCancelled);
-
-               NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); /*Get an unused nonpaged memory */
-               if (NStatus != NDIS_STATUS_SUCCESS) {
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("ASSOC - MlmeReassocReqAction() allocate memory failed \n"));
-                       pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
-                       Status = MLME_FAIL_NO_RESOURCE;
-                       MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE,
-                                   MT2_REASSOC_CONF, 2, &Status);
-                       return;
-               }
-
-               COPY_MAC_ADDR(pAd->MlmeAux.Bssid, ApAddr);
-
-               /* make frame, use bssid as the AP address?? */
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("ASSOC - Send RE-ASSOC request...\n"));
-               MgtMacHeaderInit(pAd, &ReassocHdr, SUBTYPE_REASSOC_REQ, 0,
-                                ApAddr, ApAddr);
-               MakeOutgoingFrame(pOutBuffer, &FrameLen, sizeof(struct rt_header_802_11),
-                                 &ReassocHdr, 2, &CapabilityInfo, 2,
-                                 &ListenIntv, MAC_ADDR_LEN, ApAddr, 1, &SsidIe,
-                                 1, &pAd->MlmeAux.SsidLen,
-                                 pAd->MlmeAux.SsidLen, pAd->MlmeAux.Ssid, 1,
-                                 &SupRateIe, 1, &pAd->MlmeAux.SupRateLen,
-                                 pAd->MlmeAux.SupRateLen, pAd->MlmeAux.SupRate,
-                                 END_OF_ARGS);
-
-               if (pAd->MlmeAux.ExtRateLen != 0) {
-                       MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
-                                         1, &ExtRateIe,
-                                         1, &pAd->MlmeAux.ExtRateLen,
-                                         pAd->MlmeAux.ExtRateLen,
-                                         pAd->MlmeAux.ExtRate, END_OF_ARGS);
-                       FrameLen += tmp;
-               }
-
-               if (pAd->MlmeAux.APEdcaParm.bValid) {
-                       if (pAd->CommonCfg.bAPSDCapable
-                           && pAd->MlmeAux.APEdcaParm.bAPSDCapable) {
-                               struct rt_qbss_sta_info_parm QosInfo;
-
-                               NdisZeroMemory(&QosInfo,
-                                              sizeof(struct rt_qbss_sta_info_parm));
-                               QosInfo.UAPSD_AC_BE = pAd->CommonCfg.bAPSDAC_BE;
-                               QosInfo.UAPSD_AC_BK = pAd->CommonCfg.bAPSDAC_BK;
-                               QosInfo.UAPSD_AC_VI = pAd->CommonCfg.bAPSDAC_VI;
-                               QosInfo.UAPSD_AC_VO = pAd->CommonCfg.bAPSDAC_VO;
-                               QosInfo.MaxSPLength =
-                                   pAd->CommonCfg.MaxSPLength;
-                               WmeIe[8] |= *(u8 *)& QosInfo;
-                       }
-
-                       MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
-                                         9, &WmeIe[0], END_OF_ARGS);
-                       FrameLen += tmp;
-               }
-               /* HT */
-               if ((pAd->MlmeAux.HtCapabilityLen > 0)
-                   && (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)) {
-                       unsigned long TmpLen;
-                       u8 HtLen;
-                       u8 BROADCOM[4] = { 0x0, 0x90, 0x4c, 0x33 };
-                       if (pAd->StaActive.SupportedPhyInfo.bPreNHt == TRUE) {
-                               HtLen = SIZE_HT_CAP_IE + 4;
-                               MakeOutgoingFrame(pOutBuffer + FrameLen,
-                                                 &TmpLen, 1, &WpaIe, 1, &HtLen,
-                                                 4, &BROADCOM[0],
-                                                 pAd->MlmeAux.HtCapabilityLen,
-                                                 &pAd->MlmeAux.HtCapability,
-                                                 END_OF_ARGS);
-                       } else {
-                               MakeOutgoingFrame(pOutBuffer + FrameLen,
-                                                 &TmpLen, 1, &HtCapIe, 1,
-                                                 &pAd->MlmeAux.HtCapabilityLen,
-                                                 pAd->MlmeAux.HtCapabilityLen,
-                                                 &pAd->MlmeAux.HtCapability,
-                                                 END_OF_ARGS);
-                       }
-                       FrameLen += TmpLen;
-               }
-               /* add Ralink proprietary IE to inform AP this STA is going to use AGGREGATION or PIGGY-BACK+AGGREGATION */
-               /* Case I: (Aggregation + Piggy-Back) */
-               /* 1. user enable aggregation, AND */
-               /* 2. Mac support piggy-back */
-               /* 3. AP annouces it's PIGGY-BACK+AGGREGATION-capable in BEACON */
-               /* Case II: (Aggregation) */
-               /* 1. user enable aggregation, AND */
-               /* 2. AP annouces it's AGGREGATION-capable in BEACON */
-               if (pAd->CommonCfg.bAggregationCapable) {
-                       if ((pAd->CommonCfg.bPiggyBackCapable)
-                           && ((pAd->MlmeAux.APRalinkIe & 0x00000003) == 3)) {
-                               unsigned long TmpLen;
-                               u8 RalinkIe[9] =
-                                   { IE_VENDOR_SPECIFIC, 7, 0x00, 0x0c, 0x43,
-                           0x03, 0x00, 0x00, 0x00 };
-                               MakeOutgoingFrame(pOutBuffer + FrameLen,
-                                                 &TmpLen, 9, RalinkIe,
-                                                 END_OF_ARGS);
-                               FrameLen += TmpLen;
-                       } else if (pAd->MlmeAux.APRalinkIe & 0x00000001) {
-                               unsigned long TmpLen;
-                               u8 RalinkIe[9] =
-                                   { IE_VENDOR_SPECIFIC, 7, 0x00, 0x0c, 0x43,
-                           0x01, 0x00, 0x00, 0x00 };
-                               MakeOutgoingFrame(pOutBuffer + FrameLen,
-                                                 &TmpLen, 9, RalinkIe,
-                                                 END_OF_ARGS);
-                               FrameLen += TmpLen;
-                       }
-               } else {
-                       unsigned long TmpLen;
-                       u8 RalinkIe[9] =
-                           { IE_VENDOR_SPECIFIC, 7, 0x00, 0x0c, 0x43, 0x04,
-                   0x00, 0x00, 0x00 };
-                       MakeOutgoingFrame(pOutBuffer + FrameLen, &TmpLen, 9,
-                                         RalinkIe, END_OF_ARGS);
-                       FrameLen += TmpLen;
-               }
-
-               MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
-               MlmeFreeMemory(pAd, pOutBuffer);
-
-               RTMPSetTimer(&pAd->MlmeAux.ReassocTimer, Timeout);      /* in mSec */
-               pAd->Mlme.AssocMachine.CurrState = REASSOC_WAIT_RSP;
-       } else {
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("ASSOC - MlmeReassocReqAction() sanity check failed. BUG!\n"));
-               pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
-               Status = MLME_INVALID_FORMAT;
-               MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_REASSOC_CONF, 2,
-                           &Status);
-       }
-}
-
-/*
-       ==========================================================================
-       Description:
-               Upper layer issues disassoc request
-       Parameters:
-               Elem -
-
-       IRQL = PASSIVE_LEVEL
-
-       ==========================================================================
- */
-void MlmeDisassocReqAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
-{
-       struct rt_mlme_disassoc_req *pDisassocReq;
-       struct rt_header_802_11 DisassocHdr;
-       struct rt_header_802_11 * pDisassocHdr;
-       u8 *pOutBuffer = NULL;
-       unsigned long FrameLen = 0;
-       int NStatus;
-       BOOLEAN TimerCancelled;
-       unsigned long Timeout = 500;
-       u16 Status;
-
-       /* skip sanity check */
-       pDisassocReq = (struct rt_mlme_disassoc_req *)(Elem->Msg);
-
-       NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); /*Get an unused nonpaged memory */
-       if (NStatus != NDIS_STATUS_SUCCESS) {
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("ASSOC - MlmeDisassocReqAction() allocate memory failed\n"));
-               pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
-               Status = MLME_FAIL_NO_RESOURCE;
-               MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_DISASSOC_CONF, 2,
-                           &Status);
-               return;
-       }
-
-       RTMPCancelTimer(&pAd->MlmeAux.DisassocTimer, &TimerCancelled);
-
-       DBGPRINT(RT_DEBUG_TRACE,
-               ("ASSOC - Send DISASSOC request[BSSID::%pM (Reason=%d)\n",
-                       pDisassocReq->Addr, pDisassocReq->Reason));
-       MgtMacHeaderInit(pAd, &DisassocHdr, SUBTYPE_DISASSOC, 0, pDisassocReq->Addr, pDisassocReq->Addr);       /* patch peap ttls switching issue */
-       MakeOutgoingFrame(pOutBuffer, &FrameLen,
-                         sizeof(struct rt_header_802_11), &DisassocHdr,
-                         2, &pDisassocReq->Reason, END_OF_ARGS);
-       MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
-
-       /* To patch Instance and Buffalo(N) AP */
-       /* Driver has to send deauth to Instance AP, but Buffalo(N) needs to send disassoc to reset Authenticator's state machine */
-       /* Therefore, we send both of them. */
-       pDisassocHdr = (struct rt_header_802_11 *) pOutBuffer;
-       pDisassocHdr->FC.SubType = SUBTYPE_DEAUTH;
-       MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
-
-       MlmeFreeMemory(pAd, pOutBuffer);
-
-       pAd->StaCfg.DisassocReason = REASON_DISASSOC_STA_LEAVING;
-       COPY_MAC_ADDR(pAd->StaCfg.DisassocSta, pDisassocReq->Addr);
-
-       RTMPSetTimer(&pAd->MlmeAux.DisassocTimer, Timeout);     /* in mSec */
-       pAd->Mlme.AssocMachine.CurrState = DISASSOC_WAIT_RSP;
-
-       RtmpOSWrielessEventSend(pAd, SIOCGIWAP, -1, NULL, NULL, 0);
-
-}
-
-/*
-       ==========================================================================
-       Description:
-               peer sends assoc rsp back
-       Parameters:
-               Elme - MLME message containing the received frame
-
-       IRQL = DISPATCH_LEVEL
-
-       ==========================================================================
- */
-void PeerAssocRspAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
-{
-       u16 CapabilityInfo, Status, Aid;
-       u8 SupRate[MAX_LEN_OF_SUPPORTED_RATES], SupRateLen;
-       u8 ExtRate[MAX_LEN_OF_SUPPORTED_RATES], ExtRateLen;
-       u8 Addr2[MAC_ADDR_LEN];
-       BOOLEAN TimerCancelled;
-       u8 CkipFlag;
-       struct rt_edca_parm EdcaParm;
-       struct rt_ht_capability_ie HtCapability;
-       struct rt_add_ht_info_ie AddHtInfo;     /* AP might use this additional ht info IE */
-       u8 HtCapabilityLen = 0;
-       u8 AddHtInfoLen;
-       u8 NewExtChannelOffset = 0xff;
-
-       if (PeerAssocRspSanity
-           (pAd, Elem->Msg, Elem->MsgLen, Addr2, &CapabilityInfo, &Status,
-            &Aid, SupRate, &SupRateLen, ExtRate, &ExtRateLen, &HtCapability,
-            &AddHtInfo, &HtCapabilityLen, &AddHtInfoLen, &NewExtChannelOffset,
-            &EdcaParm, &CkipFlag)) {
-               /* The frame is for me ? */
-               if (MAC_ADDR_EQUAL(Addr2, pAd->MlmeAux.Bssid)) {
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("PeerAssocRspAction():ASSOC - receive ASSOC_RSP to me (status=%d)\n",
-                                 Status));
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("PeerAssocRspAction():MacTable [%d].AMsduSize = %d. ClientStatusFlags = 0x%lx \n",
-                                 Elem->Wcid,
-                                 pAd->MacTab.Content[BSSID_WCID].AMsduSize,
-                                 pAd->MacTab.Content[BSSID_WCID].
-                                 ClientStatusFlags));
-                       RTMPCancelTimer(&pAd->MlmeAux.AssocTimer,
-                                       &TimerCancelled);
-
-                       if (Status == MLME_SUCCESS) {
-                               u8 MaxSupportedRateIn500Kbps = 0;
-                               u8 idx;
-
-                               /* supported rates array may not be sorted. sort it and find the maximum rate */
-                               for (idx = 0; idx < SupRateLen; idx++) {
-                                       if (MaxSupportedRateIn500Kbps <
-                                           (SupRate[idx] & 0x7f))
-                                               MaxSupportedRateIn500Kbps =
-                                                   SupRate[idx] & 0x7f;
-                               }
-
-                               for (idx = 0; idx < ExtRateLen; idx++) {
-                                       if (MaxSupportedRateIn500Kbps <
-                                           (ExtRate[idx] & 0x7f))
-                                               MaxSupportedRateIn500Kbps =
-                                                   ExtRate[idx] & 0x7f;
-                               }
-                               /* go to procedure listed on page 376 */
-                               AssocPostProc(pAd, Addr2, CapabilityInfo, Aid,
-                                             SupRate, SupRateLen, ExtRate,
-                                             ExtRateLen, &EdcaParm,
-                                             &HtCapability, HtCapabilityLen,
-                                             &AddHtInfo);
-
-                               StaAddMacTableEntry(pAd,
-                                                   &pAd->MacTab.
-                                                   Content[BSSID_WCID],
-                                                   MaxSupportedRateIn500Kbps,
-                                                   &HtCapability,
-                                                   HtCapabilityLen, &AddHtInfo,
-                                                   AddHtInfoLen,
-                                                   CapabilityInfo);
-                       }
-                       pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
-                       MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE,
-                                   MT2_ASSOC_CONF, 2, &Status);
-               }
-       } else {
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("ASSOC - PeerAssocRspAction() sanity check fail\n"));
-       }
-}
-
-/*
-       ==========================================================================
-       Description:
-               peer sends reassoc rsp
-       Parametrs:
-               Elem - MLME message cntaining the received frame
-
-       IRQL = DISPATCH_LEVEL
-
-       ==========================================================================
- */
-void PeerReassocRspAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
-{
-       u16 CapabilityInfo;
-       u16 Status;
-       u16 Aid;
-       u8 SupRate[MAX_LEN_OF_SUPPORTED_RATES], SupRateLen;
-       u8 ExtRate[MAX_LEN_OF_SUPPORTED_RATES], ExtRateLen;
-       u8 Addr2[MAC_ADDR_LEN];
-       u8 CkipFlag;
-       BOOLEAN TimerCancelled;
-       struct rt_edca_parm EdcaParm;
-       struct rt_ht_capability_ie HtCapability;
-       struct rt_add_ht_info_ie AddHtInfo;     /* AP might use this additional ht info IE */
-       u8 HtCapabilityLen;
-       u8 AddHtInfoLen;
-       u8 NewExtChannelOffset = 0xff;
-
-       if (PeerAssocRspSanity
-           (pAd, Elem->Msg, Elem->MsgLen, Addr2, &CapabilityInfo, &Status,
-            &Aid, SupRate, &SupRateLen, ExtRate, &ExtRateLen, &HtCapability,
-            &AddHtInfo, &HtCapabilityLen, &AddHtInfoLen, &NewExtChannelOffset,
-            &EdcaParm, &CkipFlag)) {
-               if (MAC_ADDR_EQUAL(Addr2, pAd->MlmeAux.Bssid))  /* The frame is for me ? */
-               {
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("ASSOC - receive REASSOC_RSP to me (status=%d)\n",
-                                 Status));
-                       RTMPCancelTimer(&pAd->MlmeAux.ReassocTimer,
-                                       &TimerCancelled);
-
-                       if (Status == MLME_SUCCESS) {
-                               /* go to procedure listed on page 376 */
-                               AssocPostProc(pAd, Addr2, CapabilityInfo, Aid,
-                                             SupRate, SupRateLen, ExtRate,
-                                             ExtRateLen, &EdcaParm,
-                                             &HtCapability, HtCapabilityLen,
-                                             &AddHtInfo);
-
-                               {
-                                       wext_notify_event_assoc(pAd);
-                                       RtmpOSWrielessEventSend(pAd, SIOCGIWAP,
-                                                               -1,
-                                                               &pAd->MlmeAux.
-                                                               Bssid[0], NULL,
-                                                               0);
-                               }
-
-                       }
-                       /* CkipFlag is no use for reassociate */
-                       pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
-                       MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE,
-                                   MT2_REASSOC_CONF, 2, &Status);
-               }
-       } else {
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("ASSOC - PeerReassocRspAction() sanity check fail\n"));
-       }
-
-}
-
-/*
-       ==========================================================================
-       Description:
-               procedures on IEEE 802.11/1999 p.376
-       Parametrs:
-
-       IRQL = DISPATCH_LEVEL
-
-       ==========================================================================
- */
-void AssocPostProc(struct rt_rtmp_adapter *pAd, u8 *pAddr2, u16 CapabilityInfo, u16 Aid, u8 SupRate[], u8 SupRateLen, u8 ExtRate[], u8 ExtRateLen, struct rt_edca_parm *pEdcaParm, struct rt_ht_capability_ie * pHtCapability, u8 HtCapabilityLen, struct rt_add_ht_info_ie * pAddHtInfo)      /* AP might use this additional ht info IE */
-{
-       unsigned long Idx;
-
-       pAd->MlmeAux.BssType = BSS_INFRA;
-       COPY_MAC_ADDR(pAd->MlmeAux.Bssid, pAddr2);
-       pAd->MlmeAux.Aid = Aid;
-       pAd->MlmeAux.CapabilityInfo =
-           CapabilityInfo & SUPPORTED_CAPABILITY_INFO;
-
-       /* Some HT AP might lost WMM IE. We add WMM ourselves. because HT requires QoS on. */
-       if ((HtCapabilityLen > 0) && (pEdcaParm->bValid == FALSE)) {
-               pEdcaParm->bValid = TRUE;
-               pEdcaParm->Aifsn[0] = 3;
-               pEdcaParm->Aifsn[1] = 7;
-               pEdcaParm->Aifsn[2] = 2;
-               pEdcaParm->Aifsn[3] = 2;
-
-               pEdcaParm->Cwmin[0] = 4;
-               pEdcaParm->Cwmin[1] = 4;
-               pEdcaParm->Cwmin[2] = 3;
-               pEdcaParm->Cwmin[3] = 2;
-
-               pEdcaParm->Cwmax[0] = 10;
-               pEdcaParm->Cwmax[1] = 10;
-               pEdcaParm->Cwmax[2] = 4;
-               pEdcaParm->Cwmax[3] = 3;
-
-               pEdcaParm->Txop[0] = 0;
-               pEdcaParm->Txop[1] = 0;
-               pEdcaParm->Txop[2] = 96;
-               pEdcaParm->Txop[3] = 48;
-
-       }
-
-       NdisMoveMemory(&pAd->MlmeAux.APEdcaParm, pEdcaParm, sizeof(struct rt_edca_parm));
-
-       /* filter out un-supported rates */
-       pAd->MlmeAux.SupRateLen = SupRateLen;
-       NdisMoveMemory(pAd->MlmeAux.SupRate, SupRate, SupRateLen);
-       RTMPCheckRates(pAd, pAd->MlmeAux.SupRate, &pAd->MlmeAux.SupRateLen);
-
-       /* filter out un-supported rates */
-       pAd->MlmeAux.ExtRateLen = ExtRateLen;
-       NdisMoveMemory(pAd->MlmeAux.ExtRate, ExtRate, ExtRateLen);
-       RTMPCheckRates(pAd, pAd->MlmeAux.ExtRate, &pAd->MlmeAux.ExtRateLen);
-
-       if (HtCapabilityLen > 0) {
-               RTMPCheckHt(pAd, BSSID_WCID, pHtCapability, pAddHtInfo);
-       }
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("AssocPostProc===>  AP.AMsduSize = %d. ClientStatusFlags = 0x%lx \n",
-                 pAd->MacTab.Content[BSSID_WCID].AMsduSize,
-                 pAd->MacTab.Content[BSSID_WCID].ClientStatusFlags));
-
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("AssocPostProc===>    (Mmps=%d, AmsduSize=%d, )\n",
-                 pAd->MacTab.Content[BSSID_WCID].MmpsMode,
-                 pAd->MacTab.Content[BSSID_WCID].AMsduSize));
-
-       /* Set New WPA information */
-       Idx = BssTableSearch(&pAd->ScanTab, pAddr2, pAd->MlmeAux.Channel);
-       if (Idx == BSS_NOT_FOUND) {
-               DBGPRINT_ERR("ASSOC - Can't find BSS after receiving Assoc response\n");
-       } else {
-               /* Init variable */
-               pAd->MacTab.Content[BSSID_WCID].RSNIE_Len = 0;
-               NdisZeroMemory(pAd->MacTab.Content[BSSID_WCID].RSN_IE,
-                              MAX_LEN_OF_RSNIE);
-
-               /* Store appropriate RSN_IE for WPA SM negotiation later */
-               if ((pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
-                   && (pAd->ScanTab.BssEntry[Idx].VarIELen != 0)) {
-                       u8 *pVIE;
-                       u16 len;
-                       struct rt_eid * pEid;
-
-                       pVIE = pAd->ScanTab.BssEntry[Idx].VarIEs;
-                       len = pAd->ScanTab.BssEntry[Idx].VarIELen;
-                       /*KH need to check again */
-                       /* Don't allow to go to sleep mode if authmode is WPA-related. */
-                       /*This can make Authentication process more smoothly. */
-                       RTMP_CLEAR_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
-
-                       while (len > 0) {
-                               pEid = (struct rt_eid *) pVIE;
-                               /* For WPA/WPAPSK */
-                               if ((pEid->Eid == IE_WPA)
-                                   &&
-                                   (NdisEqualMemory(pEid->Octet, WPA_OUI, 4))
-                                   && (pAd->StaCfg.AuthMode ==
-                                       Ndis802_11AuthModeWPA
-                                       || pAd->StaCfg.AuthMode ==
-                                       Ndis802_11AuthModeWPAPSK)) {
-                                       NdisMoveMemory(pAd->MacTab.
-                                                      Content[BSSID_WCID].
-                                                      RSN_IE, pVIE,
-                                                      (pEid->Len + 2));
-                                       pAd->MacTab.Content[BSSID_WCID].
-                                           RSNIE_Len = (pEid->Len + 2);
-                                       DBGPRINT(RT_DEBUG_TRACE,
-                                                ("AssocPostProc===> Store RSN_IE for WPA SM negotiation \n"));
-                               }
-                               /* For WPA2/WPA2PSK */
-                               else if ((pEid->Eid == IE_RSN)
-                                        &&
-                                        (NdisEqualMemory
-                                         (pEid->Octet + 2, RSN_OUI, 3))
-                                        && (pAd->StaCfg.AuthMode ==
-                                            Ndis802_11AuthModeWPA2
-                                            || pAd->StaCfg.AuthMode ==
-                                            Ndis802_11AuthModeWPA2PSK)) {
-                                       NdisMoveMemory(pAd->MacTab.
-                                                      Content[BSSID_WCID].
-                                                      RSN_IE, pVIE,
-                                                      (pEid->Len + 2));
-                                       pAd->MacTab.Content[BSSID_WCID].
-                                           RSNIE_Len = (pEid->Len + 2);
-                                       DBGPRINT(RT_DEBUG_TRACE,
-                                                ("AssocPostProc===> Store RSN_IE for WPA2 SM negotiation \n"));
-                               }
-
-                               pVIE += (pEid->Len + 2);
-                               len -= (pEid->Len + 2);
-                       }
-
-               }
-
-               if (pAd->MacTab.Content[BSSID_WCID].RSNIE_Len == 0) {
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("AssocPostProc===> no RSN_IE \n"));
-               } else {
-                       hex_dump("RSN_IE",
-                                pAd->MacTab.Content[BSSID_WCID].RSN_IE,
-                                pAd->MacTab.Content[BSSID_WCID].RSNIE_Len);
-               }
-       }
-}
-
-/*
-       ==========================================================================
-       Description:
-               left part of IEEE 802.11/1999 p.374
-       Parameters:
-               Elem - MLME message containing the received frame
-
-       IRQL = DISPATCH_LEVEL
-
-       ==========================================================================
- */
-void PeerDisassocAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
-{
-       u8 Addr2[MAC_ADDR_LEN];
-       u16 Reason;
-
-       DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - PeerDisassocAction()\n"));
-       if (PeerDisassocSanity(pAd, Elem->Msg, Elem->MsgLen, Addr2, &Reason)) {
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("ASSOC - PeerDisassocAction() Reason = %d\n",
-                         Reason));
-               if (INFRA_ON(pAd)
-                   && MAC_ADDR_EQUAL(pAd->CommonCfg.Bssid, Addr2)) {
-
-                       if (pAd->CommonCfg.bWirelessEvent) {
-                               RTMPSendWirelessEvent(pAd,
-                                                     IW_DISASSOC_EVENT_FLAG,
-                                                     pAd->MacTab.
-                                                     Content[BSSID_WCID].Addr,
-                                                     BSS0, 0);
-                       }
-
-                       LinkDown(pAd, TRUE);
-                       pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
-
-                       RtmpOSWrielessEventSend(pAd, SIOCGIWAP, -1, NULL, NULL,
-                                               0);
-               }
-       } else {
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("ASSOC - PeerDisassocAction() sanity check fail\n"));
-       }
-
-}
-
-/*
-       ==========================================================================
-       Description:
-               what the state machine will do after assoc timeout
-       Parameters:
-               Elme -
-
-       IRQL = DISPATCH_LEVEL
-
-       ==========================================================================
- */
-void AssocTimeoutAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
-{
-       u16 Status;
-       DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - AssocTimeoutAction\n"));
-       pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
-       Status = MLME_REJ_TIMEOUT;
-       MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_ASSOC_CONF, 2, &Status);
-}
-
-/*
-       ==========================================================================
-       Description:
-               what the state machine will do after reassoc timeout
-
-       IRQL = DISPATCH_LEVEL
-
-       ==========================================================================
- */
-void ReassocTimeoutAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
-{
-       u16 Status;
-       DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - ReassocTimeoutAction\n"));
-       pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
-       Status = MLME_REJ_TIMEOUT;
-       MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_REASSOC_CONF, 2, &Status);
-}
-
-/*
-       ==========================================================================
-       Description:
-               what the state machine will do after disassoc timeout
-
-       IRQL = DISPATCH_LEVEL
-
-       ==========================================================================
- */
-void DisassocTimeoutAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
-{
-       u16 Status;
-       DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - DisassocTimeoutAction\n"));
-       pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
-       Status = MLME_SUCCESS;
-       MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_DISASSOC_CONF, 2,
-                   &Status);
-}
-
-void InvalidStateWhenAssoc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
-{
-       u16 Status;
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("ASSOC - InvalidStateWhenAssoc(state=%ld), reset ASSOC state machine\n",
-                 pAd->Mlme.AssocMachine.CurrState));
-       pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
-       Status = MLME_STATE_MACHINE_REJECT;
-       MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_ASSOC_CONF, 2, &Status);
-}
-
-void InvalidStateWhenReassoc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
-{
-       u16 Status;
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("ASSOC - InvalidStateWhenReassoc(state=%ld), reset ASSOC state machine\n",
-                 pAd->Mlme.AssocMachine.CurrState));
-       pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
-       Status = MLME_STATE_MACHINE_REJECT;
-       MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_REASSOC_CONF, 2, &Status);
-}
-
-void InvalidStateWhenDisassociate(struct rt_rtmp_adapter *pAd,
-                                 struct rt_mlme_queue_elem *Elem)
-{
-       u16 Status;
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("ASSOC - InvalidStateWhenDisassoc(state=%ld), reset ASSOC state machine\n",
-                 pAd->Mlme.AssocMachine.CurrState));
-       pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
-       Status = MLME_STATE_MACHINE_REJECT;
-       MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_DISASSOC_CONF, 2,
-                   &Status);
-}
-
-/*
-       ==========================================================================
-       Description:
-               right part of IEEE 802.11/1999 page 374
-       Note:
-               This event should never cause ASSOC state machine perform state
-               transition, and has no relationship with CNTL machine. So we separate
-               this routine as a service outside of ASSOC state transition table.
-
-       IRQL = DISPATCH_LEVEL
-
-       ==========================================================================
- */
-void Cls3errAction(struct rt_rtmp_adapter *pAd, u8 *pAddr)
-{
-       struct rt_header_802_11 DisassocHdr;
-       struct rt_header_802_11 * pDisassocHdr;
-       u8 *pOutBuffer = NULL;
-       unsigned long FrameLen = 0;
-       int NStatus;
-       u16 Reason = REASON_CLS3ERR;
-
-       NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); /*Get an unused nonpaged memory */
-       if (NStatus != NDIS_STATUS_SUCCESS)
-               return;
-
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("ASSOC - Class 3 Error, Send DISASSOC frame\n"));
-       MgtMacHeaderInit(pAd, &DisassocHdr, SUBTYPE_DISASSOC, 0, pAddr, pAd->CommonCfg.Bssid);  /* patch peap ttls switching issue */
-       MakeOutgoingFrame(pOutBuffer, &FrameLen,
-                         sizeof(struct rt_header_802_11), &DisassocHdr,
-                         2, &Reason, END_OF_ARGS);
-       MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
-
-       /* To patch Instance and Buffalo(N) AP */
-       /* Driver has to send deauth to Instance AP, but Buffalo(N) needs to send disassoc to reset Authenticator's state machine */
-       /* Therefore, we send both of them. */
-       pDisassocHdr = (struct rt_header_802_11 *) pOutBuffer;
-       pDisassocHdr->FC.SubType = SUBTYPE_DEAUTH;
-       MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
-
-       MlmeFreeMemory(pAd, pOutBuffer);
-
-       pAd->StaCfg.DisassocReason = REASON_CLS3ERR;
-       COPY_MAC_ADDR(pAd->StaCfg.DisassocSta, pAddr);
-}
-
-int wext_notify_event_assoc(struct rt_rtmp_adapter *pAd)
-{
-       char custom[IW_CUSTOM_MAX] = { 0 };
-
-       if (pAd->StaCfg.ReqVarIELen <= IW_CUSTOM_MAX) {
-               NdisMoveMemory(custom, pAd->StaCfg.ReqVarIEs,
-                              pAd->StaCfg.ReqVarIELen);
-               RtmpOSWrielessEventSend(pAd, IWEVASSOCREQIE, -1, NULL, custom,
-                                       pAd->StaCfg.ReqVarIELen);
-       } else
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("pAd->StaCfg.ReqVarIELen > MAX_CUSTOM_LEN\n"));
-
-       return 0;
-
-}
-
-BOOLEAN StaAddMacTableEntry(struct rt_rtmp_adapter *pAd,
-                           struct rt_mac_table_entry *pEntry,
-                           u8 MaxSupportedRateIn500Kbps,
-                           struct rt_ht_capability_ie * pHtCapability,
-                           u8 HtCapabilityLen,
-                           struct rt_add_ht_info_ie * pAddHtInfo,
-                           u8 AddHtInfoLen, u16 CapabilityInfo)
-{
-       u8 MaxSupportedRate = RATE_11;
-
-       if (ADHOC_ON(pAd))
-               CLIENT_STATUS_CLEAR_FLAG(pEntry, fCLIENT_STATUS_WMM_CAPABLE);
-
-       switch (MaxSupportedRateIn500Kbps) {
-       case 108:
-               MaxSupportedRate = RATE_54;
-               break;
-       case 96:
-               MaxSupportedRate = RATE_48;
-               break;
-       case 72:
-               MaxSupportedRate = RATE_36;
-               break;
-       case 48:
-               MaxSupportedRate = RATE_24;
-               break;
-       case 36:
-               MaxSupportedRate = RATE_18;
-               break;
-       case 24:
-               MaxSupportedRate = RATE_12;
-               break;
-       case 18:
-               MaxSupportedRate = RATE_9;
-               break;
-       case 12:
-               MaxSupportedRate = RATE_6;
-               break;
-       case 22:
-               MaxSupportedRate = RATE_11;
-               break;
-       case 11:
-               MaxSupportedRate = RATE_5_5;
-               break;
-       case 4:
-               MaxSupportedRate = RATE_2;
-               break;
-       case 2:
-               MaxSupportedRate = RATE_1;
-               break;
-       default:
-               MaxSupportedRate = RATE_11;
-               break;
-       }
-
-       if ((pAd->CommonCfg.PhyMode == PHY_11G)
-           && (MaxSupportedRate < RATE_FIRST_OFDM_RATE))
-               return FALSE;
-
-       /* 11n only */
-       if (((pAd->CommonCfg.PhyMode == PHY_11N_2_4G)
-            || (pAd->CommonCfg.PhyMode == PHY_11N_5G))
-           && (HtCapabilityLen == 0))
-               return FALSE;
-
-       if (!pEntry)
-               return FALSE;
-
-       NdisAcquireSpinLock(&pAd->MacTabLock);
-       if (pEntry) {
-               pEntry->PortSecured = WPA_802_1X_PORT_SECURED;
-               if ((MaxSupportedRate < RATE_FIRST_OFDM_RATE) ||
-                   (pAd->CommonCfg.PhyMode == PHY_11B)) {
-                       pEntry->RateLen = 4;
-                       if (MaxSupportedRate >= RATE_FIRST_OFDM_RATE)
-                               MaxSupportedRate = RATE_11;
-               } else
-                       pEntry->RateLen = 12;
-
-               pEntry->MaxHTPhyMode.word = 0;
-               pEntry->MinHTPhyMode.word = 0;
-               pEntry->HTPhyMode.word = 0;
-               pEntry->MaxSupportedRate = MaxSupportedRate;
-               if (pEntry->MaxSupportedRate < RATE_FIRST_OFDM_RATE) {
-                       pEntry->MaxHTPhyMode.field.MODE = MODE_CCK;
-                       pEntry->MaxHTPhyMode.field.MCS =
-                           pEntry->MaxSupportedRate;
-                       pEntry->MinHTPhyMode.field.MODE = MODE_CCK;
-                       pEntry->MinHTPhyMode.field.MCS =
-                           pEntry->MaxSupportedRate;
-                       pEntry->HTPhyMode.field.MODE = MODE_CCK;
-                       pEntry->HTPhyMode.field.MCS = pEntry->MaxSupportedRate;
-               } else {
-                       pEntry->MaxHTPhyMode.field.MODE = MODE_OFDM;
-                       pEntry->MaxHTPhyMode.field.MCS =
-                           OfdmRateToRxwiMCS[pEntry->MaxSupportedRate];
-                       pEntry->MinHTPhyMode.field.MODE = MODE_OFDM;
-                       pEntry->MinHTPhyMode.field.MCS =
-                           OfdmRateToRxwiMCS[pEntry->MaxSupportedRate];
-                       pEntry->HTPhyMode.field.MODE = MODE_OFDM;
-                       pEntry->HTPhyMode.field.MCS =
-                           OfdmRateToRxwiMCS[pEntry->MaxSupportedRate];
-               }
-               pEntry->CapabilityInfo = CapabilityInfo;
-               CLIENT_STATUS_CLEAR_FLAG(pEntry,
-                                        fCLIENT_STATUS_AGGREGATION_CAPABLE);
-               CLIENT_STATUS_CLEAR_FLAG(pEntry,
-                                        fCLIENT_STATUS_PIGGYBACK_CAPABLE);
-       }
-
-       NdisZeroMemory(&pEntry->HTCapability, sizeof(pEntry->HTCapability));
-       /* If this Entry supports 802.11n, upgrade to HT rate. */
-       if ((HtCapabilityLen != 0)
-           && (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)) {
-               u8 j, bitmask;  /*k,bitmask; */
-               char i;
-
-               if (ADHOC_ON(pAd))
-                       CLIENT_STATUS_SET_FLAG(pEntry,
-                                              fCLIENT_STATUS_WMM_CAPABLE);
-               if ((pHtCapability->HtCapInfo.GF)
-                   && (pAd->CommonCfg.DesiredHtPhy.GF)) {
-                       pEntry->MaxHTPhyMode.field.MODE = MODE_HTGREENFIELD;
-               } else {
-                       pEntry->MaxHTPhyMode.field.MODE = MODE_HTMIX;
-                       pAd->MacTab.fAnyStationNonGF = TRUE;
-                       pAd->CommonCfg.AddHTInfo.AddHtInfo2.NonGfPresent = 1;
-               }
-
-               if ((pHtCapability->HtCapInfo.ChannelWidth) &&
-                   (pAd->CommonCfg.DesiredHtPhy.ChannelWidth) &&
-                   ((pAd->StaCfg.BssType == BSS_INFRA)
-                    || ((pAd->StaCfg.BssType == BSS_ADHOC)
-                        && (pAddHtInfo->AddHtInfo.ExtChanOffset ==
-                            pAd->CommonCfg.AddHTInfo.AddHtInfo.
-                            ExtChanOffset)))) {
-                       pEntry->MaxHTPhyMode.field.BW = BW_40;
-                       pEntry->MaxHTPhyMode.field.ShortGI =
-                           ((pAd->CommonCfg.DesiredHtPhy.
-                             ShortGIfor40) & (pHtCapability->HtCapInfo.
-                                              ShortGIfor40));
-               } else {
-                       pEntry->MaxHTPhyMode.field.BW = BW_20;
-                       pEntry->MaxHTPhyMode.field.ShortGI =
-                           ((pAd->CommonCfg.DesiredHtPhy.
-                             ShortGIfor20) & (pHtCapability->HtCapInfo.
-                                              ShortGIfor20));
-                       pAd->MacTab.fAnyStation20Only = TRUE;
-               }
-
-               /* 3*3 */
-               if (pAd->MACVersion >= RALINK_2883_VERSION
-                   && pAd->MACVersion < RALINK_3070_VERSION)
-                       pEntry->MaxHTPhyMode.field.TxBF =
-                           pAd->CommonCfg.RegTransmitSetting.field.TxBF;
-
-               /* find max fixed rate */
-               for (i = 23; i >= 0; i--)       /* 3*3 */
-               {
-                       j = i / 8;
-                       bitmask = (1 << (i - (j * 8)));
-                       if ((pAd->StaCfg.DesiredHtPhyInfo.MCSSet[j] & bitmask)
-                           && (pHtCapability->MCSSet[j] & bitmask)) {
-                               pEntry->MaxHTPhyMode.field.MCS = i;
-                               break;
-                       }
-                       if (i == 0)
-                               break;
-               }
-
-               if (pAd->StaCfg.DesiredTransmitSetting.field.MCS != MCS_AUTO) {
-                       if (pAd->StaCfg.DesiredTransmitSetting.field.MCS == 32) {
-                               /* Fix MCS as HT Duplicated Mode */
-                               pEntry->MaxHTPhyMode.field.BW = 1;
-                               pEntry->MaxHTPhyMode.field.MODE = MODE_HTMIX;
-                               pEntry->MaxHTPhyMode.field.STBC = 0;
-                               pEntry->MaxHTPhyMode.field.ShortGI = 0;
-                               pEntry->MaxHTPhyMode.field.MCS = 32;
-                       } else if (pEntry->MaxHTPhyMode.field.MCS >
-                                  pAd->StaCfg.HTPhyMode.field.MCS) {
-                               /* STA supports fixed MCS */
-                               pEntry->MaxHTPhyMode.field.MCS =
-                                   pAd->StaCfg.HTPhyMode.field.MCS;
-                       }
-               }
-
-               pEntry->MaxHTPhyMode.field.STBC =
-                   (pHtCapability->HtCapInfo.
-                    RxSTBC & (pAd->CommonCfg.DesiredHtPhy.TxSTBC));
-               pEntry->MpduDensity = pHtCapability->HtCapParm.MpduDensity;
-               pEntry->MaxRAmpduFactor =
-                   pHtCapability->HtCapParm.MaxRAmpduFactor;
-               pEntry->MmpsMode = (u8)pHtCapability->HtCapInfo.MimoPs;
-               pEntry->AMsduSize = (u8)pHtCapability->HtCapInfo.AMsduSize;
-               pEntry->HTPhyMode.word = pEntry->MaxHTPhyMode.word;
-
-               if (pAd->CommonCfg.DesiredHtPhy.AmsduEnable
-                   && (pAd->CommonCfg.REGBACapability.field.AutoBA == FALSE))
-                       CLIENT_STATUS_SET_FLAG(pEntry,
-                                              fCLIENT_STATUS_AMSDU_INUSED);
-               if (pHtCapability->HtCapInfo.ShortGIfor20)
-                       CLIENT_STATUS_SET_FLAG(pEntry,
-                                              fCLIENT_STATUS_SGI20_CAPABLE);
-               if (pHtCapability->HtCapInfo.ShortGIfor40)
-                       CLIENT_STATUS_SET_FLAG(pEntry,
-                                              fCLIENT_STATUS_SGI40_CAPABLE);
-               if (pHtCapability->HtCapInfo.TxSTBC)
-                       CLIENT_STATUS_SET_FLAG(pEntry,
-                                              fCLIENT_STATUS_TxSTBC_CAPABLE);
-               if (pHtCapability->HtCapInfo.RxSTBC)
-                       CLIENT_STATUS_SET_FLAG(pEntry,
-                                              fCLIENT_STATUS_RxSTBC_CAPABLE);
-               if (pHtCapability->ExtHtCapInfo.PlusHTC)
-                       CLIENT_STATUS_SET_FLAG(pEntry,
-                                              fCLIENT_STATUS_HTC_CAPABLE);
-               if (pAd->CommonCfg.bRdg
-                   && pHtCapability->ExtHtCapInfo.RDGSupport)
-                       CLIENT_STATUS_SET_FLAG(pEntry,
-                                              fCLIENT_STATUS_RDG_CAPABLE);
-               if (pHtCapability->ExtHtCapInfo.MCSFeedback == 0x03)
-                       CLIENT_STATUS_SET_FLAG(pEntry,
-                                              fCLIENT_STATUS_MCSFEEDBACK_CAPABLE);
-               NdisMoveMemory(&pEntry->HTCapability, pHtCapability,
-                              HtCapabilityLen);
-       } else {
-               pAd->MacTab.fAnyStationIsLegacy = TRUE;
-       }
-
-       pEntry->HTPhyMode.word = pEntry->MaxHTPhyMode.word;
-       pEntry->CurrTxRate = pEntry->MaxSupportedRate;
-
-       /* Set asic auto fall back */
-       if (pAd->StaCfg.bAutoTxRateSwitch == TRUE) {
-               u8 *pTable;
-               u8 TableSize = 0;
-
-               MlmeSelectTxRateTable(pAd, pEntry, &pTable, &TableSize,
-                                     &pEntry->CurrTxRateIndex);
-               pEntry->bAutoTxRateSwitch = TRUE;
-       } else {
-               pEntry->HTPhyMode.field.MODE = pAd->StaCfg.HTPhyMode.field.MODE;
-               pEntry->HTPhyMode.field.MCS = pAd->StaCfg.HTPhyMode.field.MCS;
-               pEntry->bAutoTxRateSwitch = FALSE;
-
-               /* If the legacy mode is set, overwrite the transmit setting of this entry. */
-               RTMPUpdateLegacyTxSetting((u8)pAd->StaCfg.
-                                         DesiredTransmitSetting.field.
-                                         FixedTxMode, pEntry);
-       }
-
-       pEntry->PortSecured = WPA_802_1X_PORT_SECURED;
-       pEntry->Sst = SST_ASSOC;
-       pEntry->AuthState = AS_AUTH_OPEN;
-       pEntry->AuthMode = pAd->StaCfg.AuthMode;
-       pEntry->WepStatus = pAd->StaCfg.WepStatus;
-
-       NdisReleaseSpinLock(&pAd->MacTabLock);
-
-       {
-               union iwreq_data wrqu;
-               wext_notify_event_assoc(pAd);
-
-               memcpy(wrqu.ap_addr.sa_data, pAd->MlmeAux.Bssid, MAC_ADDR_LEN);
-               wireless_send_event(pAd->net_dev, SIOCGIWAP, &wrqu, NULL);
-
-       }
-       return TRUE;
-}
diff --git a/drivers/staging/rt2860/sta/auth.c b/drivers/staging/rt2860/sta/auth.c
deleted file mode 100644 (file)
index 23ea00b..0000000
+++ /dev/null
@@ -1,517 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-       Module Name:
-       auth.c
-
-       Abstract:
-
-       Revision History:
-       Who                     When                    What
-       --------        ----------              ----------------------------------------------
-       John                    2004-9-3                porting from RT2500
-       Justin P. Mattock       11/07/2010              Fix typos
-*/
-#include "../rt_config.h"
-
-/*
-    ==========================================================================
-    Description:
-        authenticate state machine init, including state transition and timer init
-    Parameters:
-        Sm - pointer to the auth state machine
-    Note:
-        The state machine looks like this
-
-                        AUTH_REQ_IDLE           AUTH_WAIT_SEQ2                   AUTH_WAIT_SEQ4
-    MT2_MLME_AUTH_REQ   mlme_auth_req_action    invalid_state_when_auth          invalid_state_when_auth
-    MT2_PEER_AUTH_EVEN  drop                    peer_auth_even_at_seq2_action    peer_auth_even_at_seq4_action
-    MT2_AUTH_TIMEOUT    Drop                    auth_timeout_action              auth_timeout_action
-
-       IRQL = PASSIVE_LEVEL
-
-    ==========================================================================
- */
-
-void AuthStateMachineInit(struct rt_rtmp_adapter *pAd,
-                         struct rt_state_machine *Sm, OUT STATE_MACHINE_FUNC Trans[])
-{
-       StateMachineInit(Sm, Trans, MAX_AUTH_STATE, MAX_AUTH_MSG,
-                        (STATE_MACHINE_FUNC) Drop, AUTH_REQ_IDLE,
-                        AUTH_MACHINE_BASE);
-
-       /* the first column */
-       StateMachineSetAction(Sm, AUTH_REQ_IDLE, MT2_MLME_AUTH_REQ,
-                             (STATE_MACHINE_FUNC) MlmeAuthReqAction);
-
-       /* the second column */
-       StateMachineSetAction(Sm, AUTH_WAIT_SEQ2, MT2_MLME_AUTH_REQ,
-                             (STATE_MACHINE_FUNC) InvalidStateWhenAuth);
-       StateMachineSetAction(Sm, AUTH_WAIT_SEQ2, MT2_PEER_AUTH_EVEN,
-                             (STATE_MACHINE_FUNC) PeerAuthRspAtSeq2Action);
-       StateMachineSetAction(Sm, AUTH_WAIT_SEQ2, MT2_AUTH_TIMEOUT,
-                             (STATE_MACHINE_FUNC) AuthTimeoutAction);
-
-       /* the third column */
-       StateMachineSetAction(Sm, AUTH_WAIT_SEQ4, MT2_MLME_AUTH_REQ,
-                             (STATE_MACHINE_FUNC) InvalidStateWhenAuth);
-       StateMachineSetAction(Sm, AUTH_WAIT_SEQ4, MT2_PEER_AUTH_EVEN,
-                             (STATE_MACHINE_FUNC) PeerAuthRspAtSeq4Action);
-       StateMachineSetAction(Sm, AUTH_WAIT_SEQ4, MT2_AUTH_TIMEOUT,
-                             (STATE_MACHINE_FUNC) AuthTimeoutAction);
-
-       RTMPInitTimer(pAd, &pAd->MlmeAux.AuthTimer,
-                     GET_TIMER_FUNCTION(AuthTimeout), pAd, FALSE);
-}
-
-/*
-    ==========================================================================
-    Description:
-        function to be executed at timer thread when auth timer expires
-
-       IRQL = DISPATCH_LEVEL
-
-    ==========================================================================
- */
-void AuthTimeout(void *SystemSpecific1,
-                void *FunctionContext,
-                void *SystemSpecific2, void *SystemSpecific3)
-{
-       struct rt_rtmp_adapter *pAd = (struct rt_rtmp_adapter *)FunctionContext;
-
-       DBGPRINT(RT_DEBUG_TRACE, ("AUTH - AuthTimeout\n"));
-
-       /* Do nothing if the driver is starting halt state. */
-       /* This might happen when timer already been fired before cancel timer with mlmehalt */
-       if (RTMP_TEST_FLAG
-           (pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST))
-               return;
-
-       /* send a de-auth to reset AP's state machine (Patch AP-Dir635) */
-       if (pAd->Mlme.AuthMachine.CurrState == AUTH_WAIT_SEQ2)
-               Cls2errAction(pAd, pAd->MlmeAux.Bssid);
-
-       MlmeEnqueue(pAd, AUTH_STATE_MACHINE, MT2_AUTH_TIMEOUT, 0, NULL);
-       RTMP_MLME_HANDLER(pAd);
-}
-
-/*
-    ==========================================================================
-    Description:
-
-       IRQL = DISPATCH_LEVEL
-
-    ==========================================================================
- */
-void MlmeAuthReqAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
-{
-       if (AUTH_ReqSend
-           (pAd, Elem, &pAd->MlmeAux.AuthTimer, "AUTH", 1, NULL, 0))
-               pAd->Mlme.AuthMachine.CurrState = AUTH_WAIT_SEQ2;
-       else {
-               u16 Status;
-
-               pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
-               Status = MLME_INVALID_FORMAT;
-               MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_AUTH_CONF, 2,
-                           &Status);
-       }
-}
-
-/*
-    ==========================================================================
-    Description:
-
-       IRQL = DISPATCH_LEVEL
-
-    ==========================================================================
- */
-void PeerAuthRspAtSeq2Action(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
-{
-       u8 Addr2[MAC_ADDR_LEN];
-       u16 Seq, Status, RemoteStatus, Alg;
-       u8 ChlgText[CIPHER_TEXT_LEN];
-       u8 CyperChlgText[CIPHER_TEXT_LEN + 8 + 8];
-       u8 Element[2];
-       struct rt_header_802_11 AuthHdr;
-       BOOLEAN TimerCancelled;
-       u8 *pOutBuffer = NULL;
-       int NStatus;
-       unsigned long FrameLen = 0;
-       u16 Status2;
-
-       if (PeerAuthSanity
-           (pAd, Elem->Msg, Elem->MsgLen, Addr2, &Alg, &Seq, &Status,
-            (char *)ChlgText)) {
-               if (MAC_ADDR_EQUAL(pAd->MlmeAux.Bssid, Addr2) && Seq == 2) {
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("AUTH - Receive AUTH_RSP seq#2 to me (Alg=%d, Status=%d)\n",
-                                 Alg, Status));
-                       RTMPCancelTimer(&pAd->MlmeAux.AuthTimer,
-                                       &TimerCancelled);
-
-                       if (Status == MLME_SUCCESS) {
-                               /* Authentication Mode "LEAP" has allow for CCX 1.X */
-                               if (pAd->MlmeAux.Alg == Ndis802_11AuthModeOpen) {
-                                       pAd->Mlme.AuthMachine.CurrState =
-                                           AUTH_REQ_IDLE;
-                                       MlmeEnqueue(pAd,
-                                                   MLME_CNTL_STATE_MACHINE,
-                                                   MT2_AUTH_CONF, 2, &Status);
-                               } else {
-                                       /* 2. shared key, need to be challenged */
-                                       Seq++;
-                                       RemoteStatus = MLME_SUCCESS;
-
-                                       /* Get an unused nonpaged memory */
-                                       NStatus =
-                                           MlmeAllocateMemory(pAd,
-                                                              &pOutBuffer);
-                                       if (NStatus != NDIS_STATUS_SUCCESS) {
-                                               DBGPRINT(RT_DEBUG_TRACE,
-                                                        ("AUTH - PeerAuthRspAtSeq2Action() allocate memory fail\n"));
-                                               pAd->Mlme.AuthMachine.
-                                                   CurrState = AUTH_REQ_IDLE;
-                                               Status2 = MLME_FAIL_NO_RESOURCE;
-                                               MlmeEnqueue(pAd,
-                                                           MLME_CNTL_STATE_MACHINE,
-                                                           MT2_AUTH_CONF, 2,
-                                                           &Status2);
-                                               return;
-                                       }
-
-                                       DBGPRINT(RT_DEBUG_TRACE,
-                                                ("AUTH - Send AUTH request seq#3...\n"));
-                                       MgtMacHeaderInit(pAd, &AuthHdr,
-                                                        SUBTYPE_AUTH, 0, Addr2,
-                                                        pAd->MlmeAux.Bssid);
-                                       AuthHdr.FC.Wep = 1;
-                                       /* Encrypt challenge text & auth information */
-                                       RTMPInitWepEngine(pAd,
-                                                         pAd->
-                                                         SharedKey[BSS0][pAd->
-                                                                         StaCfg.
-                                                                         DefaultKeyId].
-                                                         Key,
-                                                         pAd->StaCfg.
-                                                         DefaultKeyId,
-                                                         pAd->
-                                                         SharedKey[BSS0][pAd->
-                                                                         StaCfg.
-                                                                         DefaultKeyId].
-                                                         KeyLen,
-                                                         CyperChlgText);
-
-                                       Alg = cpu2le16(*(u16 *) & Alg);
-                                       Seq = cpu2le16(*(u16 *) & Seq);
-                                       RemoteStatus =
-                                           cpu2le16(*(u16 *) &
-                                                    RemoteStatus);
-
-                                       RTMPEncryptData(pAd, (u8 *)& Alg,
-                                                       CyperChlgText + 4, 2);
-                                       RTMPEncryptData(pAd, (u8 *)& Seq,
-                                                       CyperChlgText + 6, 2);
-                                       RTMPEncryptData(pAd,
-                                                       (u8 *)& RemoteStatus,
-                                                       CyperChlgText + 8, 2);
-                                       Element[0] = 16;
-                                       Element[1] = 128;
-                                       RTMPEncryptData(pAd, Element,
-                                                       CyperChlgText + 10, 2);
-                                       RTMPEncryptData(pAd, ChlgText,
-                                                       CyperChlgText + 12,
-                                                       128);
-                                       RTMPSetICV(pAd, CyperChlgText + 140);
-                                       MakeOutgoingFrame(pOutBuffer, &FrameLen,
-                                                         sizeof(struct rt_header_802_11),
-                                                         &AuthHdr,
-                                                         CIPHER_TEXT_LEN + 16,
-                                                         CyperChlgText,
-                                                         END_OF_ARGS);
-                                       MiniportMMRequest(pAd, 0, pOutBuffer,
-                                                         FrameLen);
-                                       MlmeFreeMemory(pAd, pOutBuffer);
-
-                                       RTMPSetTimer(&pAd->MlmeAux.AuthTimer,
-                                                    AUTH_TIMEOUT);
-                                       pAd->Mlme.AuthMachine.CurrState =
-                                           AUTH_WAIT_SEQ4;
-                               }
-                       } else {
-                               pAd->StaCfg.AuthFailReason = Status;
-                               COPY_MAC_ADDR(pAd->StaCfg.AuthFailSta, Addr2);
-                               pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
-                               MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE,
-                                           MT2_AUTH_CONF, 2, &Status);
-                       }
-               }
-       } else {
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("AUTH - PeerAuthSanity() sanity check fail\n"));
-       }
-}
-
-/*
-    ==========================================================================
-    Description:
-
-       IRQL = DISPATCH_LEVEL
-
-    ==========================================================================
- */
-void PeerAuthRspAtSeq4Action(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
-{
-       u8 Addr2[MAC_ADDR_LEN];
-       u16 Alg, Seq, Status;
-       char ChlgText[CIPHER_TEXT_LEN];
-       BOOLEAN TimerCancelled;
-
-       if (PeerAuthSanity
-           (pAd, Elem->Msg, Elem->MsgLen, Addr2, &Alg, &Seq, &Status,
-            ChlgText)) {
-               if (MAC_ADDR_EQUAL(pAd->MlmeAux.Bssid, Addr2) && Seq == 4) {
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("AUTH - Receive AUTH_RSP seq#4 to me\n"));
-                       RTMPCancelTimer(&pAd->MlmeAux.AuthTimer,
-                                       &TimerCancelled);
-
-                       if (Status != MLME_SUCCESS) {
-                               pAd->StaCfg.AuthFailReason = Status;
-                               COPY_MAC_ADDR(pAd->StaCfg.AuthFailSta, Addr2);
-                       }
-
-                       pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
-                       MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_AUTH_CONF,
-                                   2, &Status);
-               }
-       } else {
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("AUTH - PeerAuthRspAtSeq4Action() sanity check fail\n"));
-       }
-}
-
-/*
-    ==========================================================================
-    Description:
-
-       IRQL = DISPATCH_LEVEL
-
-    ==========================================================================
- */
-void MlmeDeauthReqAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
-{
-       struct rt_mlme_deauth_req *pInfo;
-       struct rt_header_802_11 DeauthHdr;
-       u8 *pOutBuffer = NULL;
-       int NStatus;
-       unsigned long FrameLen = 0;
-       u16 Status;
-
-       pInfo = (struct rt_mlme_deauth_req *)Elem->Msg;
-
-       NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); /*Get an unused nonpaged memory */
-       if (NStatus != NDIS_STATUS_SUCCESS) {
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("AUTH - MlmeDeauthReqAction() allocate memory fail\n"));
-               pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
-               Status = MLME_FAIL_NO_RESOURCE;
-               MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_DEAUTH_CONF, 2,
-                           &Status);
-               return;
-       }
-
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("AUTH - Send DE-AUTH request (Reason=%d)...\n",
-                 pInfo->Reason));
-       MgtMacHeaderInit(pAd, &DeauthHdr, SUBTYPE_DEAUTH, 0, pInfo->Addr,
-                        pAd->MlmeAux.Bssid);
-       MakeOutgoingFrame(pOutBuffer, &FrameLen, sizeof(struct rt_header_802_11),
-                         &DeauthHdr, 2, &pInfo->Reason, END_OF_ARGS);
-       MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
-       MlmeFreeMemory(pAd, pOutBuffer);
-
-       pAd->StaCfg.DeauthReason = pInfo->Reason;
-       COPY_MAC_ADDR(pAd->StaCfg.DeauthSta, pInfo->Addr);
-       pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
-       Status = MLME_SUCCESS;
-       MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_DEAUTH_CONF, 2, &Status);
-
-       /* send wireless event - for deauthentication */
-       if (pAd->CommonCfg.bWirelessEvent)
-               RTMPSendWirelessEvent(pAd, IW_DEAUTH_EVENT_FLAG,
-                                     pAd->MacTab.Content[BSSID_WCID].Addr,
-                                     BSS0, 0);
-}
-
-/*
-    ==========================================================================
-    Description:
-
-       IRQL = DISPATCH_LEVEL
-
-    ==========================================================================
- */
-void AuthTimeoutAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
-{
-       u16 Status;
-       DBGPRINT(RT_DEBUG_TRACE, ("AUTH - AuthTimeoutAction\n"));
-       pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
-       Status = MLME_REJ_TIMEOUT;
-       MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_AUTH_CONF, 2, &Status);
-}
-
-/*
-    ==========================================================================
-    Description:
-
-       IRQL = DISPATCH_LEVEL
-
-    ==========================================================================
- */
-void InvalidStateWhenAuth(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
-{
-       u16 Status;
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("AUTH - InvalidStateWhenAuth (state=%ld), reset AUTH state machine\n",
-                 pAd->Mlme.AuthMachine.CurrState));
-       pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
-       Status = MLME_STATE_MACHINE_REJECT;
-       MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_AUTH_CONF, 2, &Status);
-}
-
-/*
-    ==========================================================================
-    Description:
-        Some STA/AP
-    Note:
-        This action should never trigger AUTH state transition, therefore we
-        separate it from AUTH state machine, and make it as a standalone service
-
-       IRQL = DISPATCH_LEVEL
-
-    ==========================================================================
- */
-void Cls2errAction(struct rt_rtmp_adapter *pAd, u8 *pAddr)
-{
-       struct rt_header_802_11 DeauthHdr;
-       u8 *pOutBuffer = NULL;
-       int NStatus;
-       unsigned long FrameLen = 0;
-       u16 Reason = REASON_CLS2ERR;
-
-       NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); /*Get an unused nonpaged memory */
-       if (NStatus != NDIS_STATUS_SUCCESS)
-               return;
-
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("AUTH - Class 2 error, Send DEAUTH frame...\n"));
-       MgtMacHeaderInit(pAd, &DeauthHdr, SUBTYPE_DEAUTH, 0, pAddr,
-                        pAd->MlmeAux.Bssid);
-       MakeOutgoingFrame(pOutBuffer, &FrameLen, sizeof(struct rt_header_802_11),
-                         &DeauthHdr, 2, &Reason, END_OF_ARGS);
-       MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
-       MlmeFreeMemory(pAd, pOutBuffer);
-
-       pAd->StaCfg.DeauthReason = Reason;
-       COPY_MAC_ADDR(pAd->StaCfg.DeauthSta, pAddr);
-}
-
-BOOLEAN AUTH_ReqSend(struct rt_rtmp_adapter *pAd,
-                    struct rt_mlme_queue_elem *pElem,
-                    struct rt_ralink_timer *pAuthTimer,
-                    char *pSMName,
-                    u16 SeqNo,
-                    u8 *pNewElement, unsigned long ElementLen)
-{
-       u16 Alg, Seq, Status;
-       u8 Addr[6];
-       unsigned long Timeout;
-       struct rt_header_802_11 AuthHdr;
-       BOOLEAN TimerCancelled;
-       int NStatus;
-       u8 *pOutBuffer = NULL;
-       unsigned long FrameLen = 0, tmp = 0;
-
-       /* Block all authentication request during WPA block period */
-       if (pAd->StaCfg.bBlockAssoc == TRUE) {
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("%s - Block Auth request during WPA block period!\n",
-                         pSMName));
-               pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
-               Status = MLME_STATE_MACHINE_REJECT;
-               MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_AUTH_CONF, 2,
-                           &Status);
-       } else
-           if (MlmeAuthReqSanity
-               (pAd, pElem->Msg, pElem->MsgLen, Addr, &Timeout, &Alg)) {
-               /* reset timer */
-               RTMPCancelTimer(pAuthTimer, &TimerCancelled);
-
-               COPY_MAC_ADDR(pAd->MlmeAux.Bssid, Addr);
-               pAd->MlmeAux.Alg = Alg;
-               Seq = SeqNo;
-               Status = MLME_SUCCESS;
-
-               NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); /*Get an unused nonpaged memory */
-               if (NStatus != NDIS_STATUS_SUCCESS) {
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("%s - MlmeAuthReqAction(Alg:%d) allocate memory failed\n",
-                                 pSMName, Alg));
-                       pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
-                       Status = MLME_FAIL_NO_RESOURCE;
-                       MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_AUTH_CONF,
-                                   2, &Status);
-                       return FALSE;
-               }
-
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("%s - Send AUTH request seq#1 (Alg=%d)...\n", pSMName,
-                         Alg));
-               MgtMacHeaderInit(pAd, &AuthHdr, SUBTYPE_AUTH, 0, Addr,
-                                pAd->MlmeAux.Bssid);
-               MakeOutgoingFrame(pOutBuffer, &FrameLen, sizeof(struct rt_header_802_11),
-                                 &AuthHdr, 2, &Alg, 2, &Seq, 2, &Status,
-                                 END_OF_ARGS);
-
-               if (pNewElement && ElementLen) {
-                       MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
-                                         ElementLen, pNewElement, END_OF_ARGS);
-                       FrameLen += tmp;
-               }
-
-               MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
-               MlmeFreeMemory(pAd, pOutBuffer);
-
-               RTMPSetTimer(pAuthTimer, Timeout);
-               return TRUE;
-       } else {
-               DBGPRINT_ERR("%s - MlmeAuthReqAction() sanity check failed\n", pSMName);
-               return FALSE;
-       }
-
-       return TRUE;
-}
diff --git a/drivers/staging/rt2860/sta/auth_rsp.c b/drivers/staging/rt2860/sta/auth_rsp.c
deleted file mode 100644 (file)
index 5b018b7..0000000
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-       Module Name:
-       auth_rsp.c
-
-       Abstract:
-
-       Revision History:
-       Who                     When                    What
-       --------        ----------              ----------------------------------------------
-       John            2004-10-1               copy from RT2560
-*/
-#include "../rt_config.h"
-
-/*
-    ==========================================================================
-    Description:
-        authentication state machine init procedure
-    Parameters:
-        Sm - the state machine
-
-       IRQL = PASSIVE_LEVEL
-
-    ==========================================================================
- */
-void AuthRspStateMachineInit(struct rt_rtmp_adapter *pAd,
-                            struct rt_state_machine *Sm,
-                            IN STATE_MACHINE_FUNC Trans[])
-{
-       StateMachineInit(Sm, Trans, MAX_AUTH_RSP_STATE, MAX_AUTH_RSP_MSG,
-                        (STATE_MACHINE_FUNC) Drop, AUTH_RSP_IDLE,
-                        AUTH_RSP_MACHINE_BASE);
-
-       /* column 1 */
-       StateMachineSetAction(Sm, AUTH_RSP_IDLE, MT2_PEER_DEAUTH,
-                             (STATE_MACHINE_FUNC) PeerDeauthAction);
-
-       /* column 2 */
-       StateMachineSetAction(Sm, AUTH_RSP_WAIT_CHAL, MT2_PEER_DEAUTH,
-                             (STATE_MACHINE_FUNC) PeerDeauthAction);
-
-}
-
-/*
-    ==========================================================================
-    Description:
-
-       IRQL = DISPATCH_LEVEL
-
-    ==========================================================================
-*/
-void PeerAuthSimpleRspGenAndSend(struct rt_rtmp_adapter *pAd,
-                                struct rt_header_802_11 * pHdr80211,
-                                u16 Alg,
-                                u16 Seq,
-                                u16 Reason, u16 Status)
-{
-       struct rt_header_802_11 AuthHdr;
-       unsigned long FrameLen = 0;
-       u8 *pOutBuffer = NULL;
-       int NStatus;
-
-       if (Reason != MLME_SUCCESS) {
-               DBGPRINT(RT_DEBUG_TRACE, ("Peer AUTH fail...\n"));
-               return;
-       }
-       /*Get an unused nonpaged memory */
-       NStatus = MlmeAllocateMemory(pAd, &pOutBuffer);
-       if (NStatus != NDIS_STATUS_SUCCESS)
-               return;
-
-       DBGPRINT(RT_DEBUG_TRACE, ("Send AUTH response (seq#2)...\n"));
-       MgtMacHeaderInit(pAd, &AuthHdr, SUBTYPE_AUTH, 0, pHdr80211->Addr2,
-                        pAd->MlmeAux.Bssid);
-       MakeOutgoingFrame(pOutBuffer, &FrameLen, sizeof(struct rt_header_802_11),
-                         &AuthHdr, 2, &Alg, 2, &Seq, 2, &Reason, END_OF_ARGS);
-       MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
-       MlmeFreeMemory(pAd, pOutBuffer);
-}
-
-/*
-    ==========================================================================
-    Description:
-
-       IRQL = DISPATCH_LEVEL
-
-    ==========================================================================
-*/
-void PeerDeauthAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
-{
-       u8 Addr2[MAC_ADDR_LEN];
-       u16 Reason;
-
-       if (PeerDeauthSanity(pAd, Elem->Msg, Elem->MsgLen, Addr2, &Reason)) {
-               if (INFRA_ON(pAd)
-                   && MAC_ADDR_EQUAL(Addr2, pAd->CommonCfg.Bssid)
-                   ) {
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("AUTH_RSP - receive DE-AUTH from our AP (Reason=%d)\n",
-                                 Reason));
-
-                       RtmpOSWrielessEventSend(pAd, SIOCGIWAP, -1, NULL, NULL,
-                                               0);
-
-                       /* send wireless event - for deauthentication */
-                       if (pAd->CommonCfg.bWirelessEvent)
-                               RTMPSendWirelessEvent(pAd, IW_DEAUTH_EVENT_FLAG,
-                                                     pAd->MacTab.
-                                                     Content[BSSID_WCID].Addr,
-                                                     BSS0, 0);
-
-                       LinkDown(pAd, TRUE);
-               }
-       } else {
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("AUTH_RSP - PeerDeauthAction() sanity check fail\n"));
-       }
-}
diff --git a/drivers/staging/rt2860/sta/connect.c b/drivers/staging/rt2860/sta/connect.c
deleted file mode 100644 (file)
index 4996258..0000000
+++ /dev/null
@@ -1,2613 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-       Module Name:
-       connect.c
-
-       Abstract:
-
-       Revision History:
-       Who                     When                    What
-       --------        ----------              ----------------------------------------------
-       John                    2004-08-08              Major modification from RT2560
-       Justin P. Mattock       11/07/2010              Fix typos
-*/
-#include "../rt_config.h"
-
-u8 CipherSuiteWpaNoneTkip[] = {
-       0x00, 0x50, 0xf2, 0x01, /* oui */
-       0x01, 0x00,             /* Version */
-       0x00, 0x50, 0xf2, 0x02, /* Multicast */
-       0x01, 0x00,             /* Number of unicast */
-       0x00, 0x50, 0xf2, 0x02, /* unicast */
-       0x01, 0x00,             /* number of authentication method */
-       0x00, 0x50, 0xf2, 0x00  /* authentication */
-};
-
-u8 CipherSuiteWpaNoneTkipLen =
-    (sizeof(CipherSuiteWpaNoneTkip) / sizeof(u8));
-
-u8 CipherSuiteWpaNoneAes[] = {
-       0x00, 0x50, 0xf2, 0x01, /* oui */
-       0x01, 0x00,             /* Version */
-       0x00, 0x50, 0xf2, 0x04, /* Multicast */
-       0x01, 0x00,             /* Number of unicast */
-       0x00, 0x50, 0xf2, 0x04, /* unicast */
-       0x01, 0x00,             /* number of authentication method */
-       0x00, 0x50, 0xf2, 0x00  /* authentication */
-};
-
-u8 CipherSuiteWpaNoneAesLen =
-    (sizeof(CipherSuiteWpaNoneAes) / sizeof(u8));
-
-/* The following MACRO is called after 1. starting an new IBSS, 2. successfully JOIN an IBSS, */
-/* or 3. successfully ASSOCIATE to a BSS, 4. successfully RE_ASSOCIATE to a BSS */
-/* All settings successfuly negotiated firing MLME state machines become final settings */
-/* and are copied to pAd->StaActive */
-#define COPY_SETTINGS_FROM_MLME_AUX_TO_ACTIVE_CFG(_pAd)                                 \
-{                                                                                       \
-       NdisZeroMemory((_pAd)->CommonCfg.Ssid, MAX_LEN_OF_SSID);                                                        \
-       (_pAd)->CommonCfg.SsidLen = (_pAd)->MlmeAux.SsidLen;                                \
-       NdisMoveMemory((_pAd)->CommonCfg.Ssid, (_pAd)->MlmeAux.Ssid, (_pAd)->MlmeAux.SsidLen); \
-       COPY_MAC_ADDR((_pAd)->CommonCfg.Bssid, (_pAd)->MlmeAux.Bssid);                      \
-       (_pAd)->CommonCfg.Channel = (_pAd)->MlmeAux.Channel;                                \
-       (_pAd)->CommonCfg.CentralChannel = (_pAd)->MlmeAux.CentralChannel;                  \
-       (_pAd)->StaActive.Aid = (_pAd)->MlmeAux.Aid;                                        \
-       (_pAd)->StaActive.AtimWin = (_pAd)->MlmeAux.AtimWin;                                \
-       (_pAd)->StaActive.CapabilityInfo = (_pAd)->MlmeAux.CapabilityInfo;                  \
-       (_pAd)->CommonCfg.BeaconPeriod = (_pAd)->MlmeAux.BeaconPeriod;                      \
-       (_pAd)->StaActive.CfpMaxDuration = (_pAd)->MlmeAux.CfpMaxDuration;                  \
-       (_pAd)->StaActive.CfpPeriod = (_pAd)->MlmeAux.CfpPeriod;                            \
-       (_pAd)->StaActive.SupRateLen = (_pAd)->MlmeAux.SupRateLen;                          \
-       NdisMoveMemory((_pAd)->StaActive.SupRate, (_pAd)->MlmeAux.SupRate, (_pAd)->MlmeAux.SupRateLen);\
-       (_pAd)->StaActive.ExtRateLen = (_pAd)->MlmeAux.ExtRateLen;                          \
-       NdisMoveMemory((_pAd)->StaActive.ExtRate, (_pAd)->MlmeAux.ExtRate, (_pAd)->MlmeAux.ExtRateLen);\
-       NdisMoveMemory(&(_pAd)->CommonCfg.APEdcaParm, &(_pAd)->MlmeAux.APEdcaParm, sizeof(struct rt_edca_parm));\
-       NdisMoveMemory(&(_pAd)->CommonCfg.APQosCapability, &(_pAd)->MlmeAux.APQosCapability, sizeof(struct rt_qos_capability_parm));\
-       NdisMoveMemory(&(_pAd)->CommonCfg.APQbssLoad, &(_pAd)->MlmeAux.APQbssLoad, sizeof(struct rt_qbss_load_parm));\
-       COPY_MAC_ADDR((_pAd)->MacTab.Content[BSSID_WCID].Addr, (_pAd)->MlmeAux.Bssid);      \
-       (_pAd)->MacTab.Content[BSSID_WCID].Aid = (_pAd)->MlmeAux.Aid;                       \
-       (_pAd)->MacTab.Content[BSSID_WCID].PairwiseKey.CipherAlg = (_pAd)->StaCfg.PairCipher;\
-       COPY_MAC_ADDR((_pAd)->MacTab.Content[BSSID_WCID].PairwiseKey.BssId, (_pAd)->MlmeAux.Bssid);\
-       (_pAd)->MacTab.Content[BSSID_WCID].RateLen = (_pAd)->StaActive.SupRateLen + (_pAd)->StaActive.ExtRateLen;\
-}
-
-/*
-       ==========================================================================
-       Description:
-
-       IRQL = PASSIVE_LEVEL
-
-       ==========================================================================
-*/
-void MlmeCntlInit(struct rt_rtmp_adapter *pAd,
-                 struct rt_state_machine *S, OUT STATE_MACHINE_FUNC Trans[])
-{
-       /* Control state machine differs from other state machines, the interface */
-       /* follows the standard interface */
-       pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
-}
-
-/*
-       ==========================================================================
-       Description:
-
-       IRQL = DISPATCH_LEVEL
-
-       ==========================================================================
-*/
-void MlmeCntlMachinePerformAction(struct rt_rtmp_adapter *pAd,
-                                 struct rt_state_machine *S,
-                                 struct rt_mlme_queue_elem *Elem)
-{
-       switch (pAd->Mlme.CntlMachine.CurrState) {
-       case CNTL_IDLE:
-               CntlIdleProc(pAd, Elem);
-               break;
-       case CNTL_WAIT_DISASSOC:
-               CntlWaitDisassocProc(pAd, Elem);
-               break;
-       case CNTL_WAIT_JOIN:
-               CntlWaitJoinProc(pAd, Elem);
-               break;
-
-               /* CNTL_WAIT_REASSOC is the only state in CNTL machine that does */
-               /* not triggered directly or indirectly by "RTMPSetInformation(OID_xxx)". */
-               /* Therefore not protected by NDIS's "only one outstanding OID request" */
-               /* rule. Which means NDIS may SET OID in the middle of ROAMing attempts. */
-               /* Current approach is to block new SET request at RTMPSetInformation() */
-               /* when CntlMachine.CurrState is not CNTL_IDLE */
-       case CNTL_WAIT_REASSOC:
-               CntlWaitReassocProc(pAd, Elem);
-               break;
-
-       case CNTL_WAIT_START:
-               CntlWaitStartProc(pAd, Elem);
-               break;
-       case CNTL_WAIT_AUTH:
-               CntlWaitAuthProc(pAd, Elem);
-               break;
-       case CNTL_WAIT_AUTH2:
-               CntlWaitAuthProc2(pAd, Elem);
-               break;
-       case CNTL_WAIT_ASSOC:
-               CntlWaitAssocProc(pAd, Elem);
-               break;
-
-       case CNTL_WAIT_OID_LIST_SCAN:
-               if (Elem->MsgType == MT2_SCAN_CONF) {
-                       /* Resume TxRing after SCANING complete. We hope the out-of-service time */
-                       /* won't be too long to let upper layer time-out the waiting frames */
-                       RTMPResumeMsduTransmission(pAd);
-
-                       pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
-
-                       /* */
-                       /* Set LED status to previous status. */
-                       /* */
-                       if (pAd->bLedOnScanning) {
-                               pAd->bLedOnScanning = FALSE;
-                               RTMPSetLED(pAd, pAd->LedStatus);
-                       }
-               }
-               break;
-
-       case CNTL_WAIT_OID_DISASSOC:
-               if (Elem->MsgType == MT2_DISASSOC_CONF) {
-                       LinkDown(pAd, FALSE);
-                       pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
-               }
-               break;
-#ifdef RTMP_MAC_USB
-               /* */
-               /* This state is for that we want to connect to an AP but */
-               /* it didn't find on BSS List table. So we need to scan the air first, */
-               /* after that we can try to connect to the desired AP if available. */
-               /* */
-       case CNTL_WAIT_SCAN_FOR_CONNECT:
-               if (Elem->MsgType == MT2_SCAN_CONF) {
-                       /* Resume TxRing after SCANING complete. We hope the out-of-service time */
-                       /* won't be too long to let upper layer time-out the waiting frames */
-                       RTMPResumeMsduTransmission(pAd);
-#ifdef CCX_SUPPORT
-                       if (pAd->StaCfg.CCXReqType != MSRN_TYPE_UNUSED) {
-                               /* Cisco scan request is finished, prepare beacon report */
-                               MlmeEnqueue(pAd, AIRONET_STATE_MACHINE,
-                                           MT2_AIRONET_SCAN_DONE, 0, NULL);
-                       }
-#endif /* CCX_SUPPORT // */
-                       pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
-
-                       /* */
-                       /* Check if we can connect to. */
-                       /* */
-                       BssTableSsidSort(pAd, &pAd->MlmeAux.SsidBssTab,
-                                        (char *) pAd->MlmeAux.
-                                        AutoReconnectSsid,
-                                        pAd->MlmeAux.AutoReconnectSsidLen);
-                       if (pAd->MlmeAux.SsidBssTab.BssNr > 0) {
-                               MlmeAutoReconnectLastSSID(pAd);
-                       }
-               }
-               break;
-#endif /* RTMP_MAC_USB // */
-       default:
-               DBGPRINT_ERR("ERROR! CNTL - Illegal message type(=%ld)", Elem->MsgType);
-               break;
-       }
-}
-
-/*
-       ==========================================================================
-       Description:
-
-       IRQL = DISPATCH_LEVEL
-
-       ==========================================================================
-*/
-void CntlIdleProc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
-{
-       struct rt_mlme_disassoc_req DisassocReq;
-
-       if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF))
-               return;
-
-       switch (Elem->MsgType) {
-       case OID_802_11_SSID:
-               CntlOidSsidProc(pAd, Elem);
-               break;
-
-       case OID_802_11_BSSID:
-               CntlOidRTBssidProc(pAd, Elem);
-               break;
-
-       case OID_802_11_BSSID_LIST_SCAN:
-               CntlOidScanProc(pAd, Elem);
-               break;
-
-       case OID_802_11_DISASSOCIATE:
-               DisassocParmFill(pAd, &DisassocReq, pAd->CommonCfg.Bssid,
-                                REASON_DISASSOC_STA_LEAVING);
-               MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_MLME_DISASSOC_REQ,
-                           sizeof(struct rt_mlme_disassoc_req), &DisassocReq);
-               pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_DISASSOC;
-
-               if (pAd->StaCfg.WpaSupplicantUP !=
-                   WPA_SUPPLICANT_ENABLE_WITH_WEB_UI) {
-                       /* Set the AutoReconnectSsid to prevent it reconnect to old SSID */
-                       /* Since calling this indicate user don't want to connect to that SSID anymore. */
-                       pAd->MlmeAux.AutoReconnectSsidLen = 32;
-                       NdisZeroMemory(pAd->MlmeAux.AutoReconnectSsid,
-                                      pAd->MlmeAux.AutoReconnectSsidLen);
-               }
-               break;
-
-       case MT2_MLME_ROAMING_REQ:
-               CntlMlmeRoamingProc(pAd, Elem);
-               break;
-
-       case OID_802_11_MIC_FAILURE_REPORT_FRAME:
-               WpaMicFailureReportFrame(pAd, Elem);
-               break;
-
-       default:
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("CNTL - Illegal message in CntlIdleProc(MsgType=%ld)\n",
-                         Elem->MsgType));
-               break;
-       }
-}
-
-void CntlOidScanProc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
-{
-       struct rt_mlme_scan_req ScanReq;
-       unsigned long BssIdx = BSS_NOT_FOUND;
-       struct rt_bss_entry CurrBss;
-
-       /* record current BSS if network is connected. */
-       /* 2003-2-13 do not include current IBSS if this is the only STA in this IBSS. */
-       if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED)) {
-               BssIdx =
-                   BssSsidTableSearch(&pAd->ScanTab, pAd->CommonCfg.Bssid,
-                                      (u8 *)pAd->CommonCfg.Ssid,
-                                      pAd->CommonCfg.SsidLen,
-                                      pAd->CommonCfg.Channel);
-               if (BssIdx != BSS_NOT_FOUND) {
-                       NdisMoveMemory(&CurrBss, &pAd->ScanTab.BssEntry[BssIdx],
-                                      sizeof(struct rt_bss_entry));
-               }
-       }
-       /* clean up previous SCAN result, add current BSS back to table if any */
-       BssTableInit(&pAd->ScanTab);
-       if (BssIdx != BSS_NOT_FOUND) {
-               /* DDK Note: If the NIC is associated with a particular BSSID and SSID */
-               /*    that are not contained in the list of BSSIDs generated by this scan, the */
-               /*    BSSID description of the currently associated BSSID and SSID should be */
-               /*    appended to the list of BSSIDs in the NIC's database. */
-               /* To ensure this, we append this BSS as the first entry in SCAN result */
-               NdisMoveMemory(&pAd->ScanTab.BssEntry[0], &CurrBss,
-                              sizeof(struct rt_bss_entry));
-               pAd->ScanTab.BssNr = 1;
-       }
-
-       ScanParmFill(pAd, &ScanReq, (char *)Elem->Msg, Elem->MsgLen, BSS_ANY,
-                    SCAN_ACTIVE);
-       MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_MLME_SCAN_REQ,
-                   sizeof(struct rt_mlme_scan_req), &ScanReq);
-       pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_LIST_SCAN;
-}
-
-/*
-       ==========================================================================
-       Description:
-               Before calling this routine, user desired SSID should already been
-               recorded in CommonCfg.Ssid[]
-       IRQL = DISPATCH_LEVEL
-
-       ==========================================================================
-*/
-void CntlOidSsidProc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
-{
-       struct rt_ndis_802_11_ssid * pOidSsid = (struct rt_ndis_802_11_ssid *) Elem->Msg;
-       struct rt_mlme_disassoc_req DisassocReq;
-       unsigned long Now;
-
-       /* Step 1. record the desired user settings to MlmeAux */
-       NdisZeroMemory(pAd->MlmeAux.Ssid, MAX_LEN_OF_SSID);
-       NdisMoveMemory(pAd->MlmeAux.Ssid, pOidSsid->Ssid, pOidSsid->SsidLength);
-       pAd->MlmeAux.SsidLen = (u8)pOidSsid->SsidLength;
-       NdisZeroMemory(pAd->MlmeAux.Bssid, MAC_ADDR_LEN);
-       pAd->MlmeAux.BssType = pAd->StaCfg.BssType;
-
-       pAd->StaCfg.bAutoConnectByBssid = FALSE;
-
-       /* */
-       /* Update Reconnect Ssid, that user desired to connect. */
-       /* */
-       NdisZeroMemory(pAd->MlmeAux.AutoReconnectSsid, MAX_LEN_OF_SSID);
-       NdisMoveMemory(pAd->MlmeAux.AutoReconnectSsid, pAd->MlmeAux.Ssid,
-                      pAd->MlmeAux.SsidLen);
-       pAd->MlmeAux.AutoReconnectSsidLen = pAd->MlmeAux.SsidLen;
-
-       /* step 2. find all matching BSS in the lastest SCAN result (inBssTab) */
-       /*    & log them into MlmeAux.SsidBssTab for later-on iteration. Sort by RSSI order */
-       BssTableSsidSort(pAd, &pAd->MlmeAux.SsidBssTab,
-                        (char *)pAd->MlmeAux.Ssid, pAd->MlmeAux.SsidLen);
-
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("CntlOidSsidProc():CNTL - %d BSS of %d BSS match the desire (%d)SSID - %s\n",
-                 pAd->MlmeAux.SsidBssTab.BssNr, pAd->ScanTab.BssNr,
-                 pAd->MlmeAux.SsidLen, pAd->MlmeAux.Ssid));
-       NdisGetSystemUpTime(&Now);
-
-       if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED) &&
-           (pAd->CommonCfg.SsidLen ==
-            pAd->MlmeAux.SsidBssTab.BssEntry[0].SsidLen)
-           && NdisEqualMemory(pAd->CommonCfg.Ssid,
-                              pAd->MlmeAux.SsidBssTab.BssEntry[0].Ssid,
-                              pAd->CommonCfg.SsidLen)
-           && MAC_ADDR_EQUAL(pAd->CommonCfg.Bssid,
-                             pAd->MlmeAux.SsidBssTab.BssEntry[0].Bssid)) {
-               /* Case 1. already connected with an AP who has the desired SSID */
-               /*         with highest RSSI */
-
-               /* Add checking Mode "LEAP" for CCX 1.0 */
-               if (((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
-                    (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
-                    (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) ||
-                    (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)
-                   ) &&
-                   (pAd->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED)) {
-                       /* case 1.1 For WPA, WPA-PSK, if the 1x port is not secured, we have to redo */
-                       /*          connection process */
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("CntlOidSsidProc():CNTL - disassociate with current AP...\n"));
-                       DisassocParmFill(pAd, &DisassocReq,
-                                        pAd->CommonCfg.Bssid,
-                                        REASON_DISASSOC_STA_LEAVING);
-                       MlmeEnqueue(pAd, ASSOC_STATE_MACHINE,
-                                   MT2_MLME_DISASSOC_REQ,
-                                   sizeof(struct rt_mlme_disassoc_req),
-                                   &DisassocReq);
-                       pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_DISASSOC;
-               } else if (pAd->bConfigChanged == TRUE) {
-                       /* case 1.2 Important Config has changed, we have to reconnect to the same AP */
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("CntlOidSsidProc():CNTL - disassociate with current AP Because config changed...\n"));
-                       DisassocParmFill(pAd, &DisassocReq,
-                                        pAd->CommonCfg.Bssid,
-                                        REASON_DISASSOC_STA_LEAVING);
-                       MlmeEnqueue(pAd, ASSOC_STATE_MACHINE,
-                                   MT2_MLME_DISASSOC_REQ,
-                                   sizeof(struct rt_mlme_disassoc_req),
-                                   &DisassocReq);
-                       pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_DISASSOC;
-               } else {
-                       /* case 1.3. already connected to the SSID with highest RSSI. */
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("CntlOidSsidProc():CNTL - already with this BSSID. ignore this SET_SSID request\n"));
-                       /* */
-                       /* (HCT 12.1) 1c_wlan_mediaevents required */
-                       /* media connect events are indicated when associating with the same AP */
-                       /* */
-                       if (INFRA_ON(pAd)) {
-                               /* */
-                               /* Since MediaState already is NdisMediaStateConnected */
-                               /* We just indicate the connect event again to meet the WHQL required. */
-                               /* */
-                               pAd->IndicateMediaState =
-                                   NdisMediaStateConnected;
-                               RTMP_IndicateMediaState(pAd);
-                               pAd->ExtraInfo = GENERAL_LINK_UP;       /* Update extra information to link is up */
-                       }
-
-                       pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
-                       RtmpOSWrielessEventSend(pAd, SIOCGIWAP, -1,
-                                               &pAd->MlmeAux.Bssid[0], NULL,
-                                               0);
-               }
-       } else if (INFRA_ON(pAd)) {
-               /* */
-               /* For RT61 */
-               /* [88888] OID_802_11_SSID should have returned NDTEST_WEP_AP2(Returned: ) */
-               /* RT61 may lost SSID, and not connect to NDTEST_WEP_AP2 and will connect to NDTEST_WEP_AP2 by Autoreconnect */
-               /* But media status is connected, so the SSID not report correctly. */
-               /* */
-               if (!SSID_EQUAL
-                   (pAd->CommonCfg.Ssid, pAd->CommonCfg.SsidLen,
-                    pAd->MlmeAux.Ssid, pAd->MlmeAux.SsidLen)) {
-                       /* */
-                       /* Different SSID means not Roaming case, so we let LinkDown() to Indicate a disconnect event. */
-                       /* */
-                       pAd->MlmeAux.CurrReqIsFromNdis = TRUE;
-               }
-               /* case 2. active INFRA association existent */
-               /*    roaming is done within miniport driver, nothing to do with configuration */
-               /*    utility. so upon a new SET(OID_802_11_SSID) is received, we just */
-               /*    disassociate with the current associated AP, */
-               /*    then perform a new association with this new SSID, no matter the */
-               /*    new/old SSID are the same or not. */
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("CntlOidSsidProc():CNTL - disassociate with current AP...\n"));
-               DisassocParmFill(pAd, &DisassocReq, pAd->CommonCfg.Bssid,
-                                REASON_DISASSOC_STA_LEAVING);
-               MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_MLME_DISASSOC_REQ,
-                           sizeof(struct rt_mlme_disassoc_req), &DisassocReq);
-               pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_DISASSOC;
-       } else {
-               if (ADHOC_ON(pAd)) {
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("CntlOidSsidProc():CNTL - drop current ADHOC\n"));
-                       LinkDown(pAd, FALSE);
-                       OPSTATUS_CLEAR_FLAG(pAd,
-                                           fOP_STATUS_MEDIA_STATE_CONNECTED);
-                       pAd->IndicateMediaState = NdisMediaStateDisconnected;
-                       RTMP_IndicateMediaState(pAd);
-                       pAd->ExtraInfo = GENERAL_LINK_DOWN;
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("CntlOidSsidProc():NDIS_STATUS_MEDIA_DISCONNECT Event C!\n"));
-               }
-
-               if ((pAd->MlmeAux.SsidBssTab.BssNr == 0) &&
-                   (pAd->StaCfg.bAutoReconnect == TRUE) &&
-                   (pAd->MlmeAux.BssType == BSS_INFRA) &&
-                   (MlmeValidateSSID(pAd->MlmeAux.Ssid, pAd->MlmeAux.SsidLen)
-                    == TRUE)
-                   ) {
-                       struct rt_mlme_scan_req ScanReq;
-
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("CntlOidSsidProc():CNTL - No matching BSS, start a new scan\n"));
-                       ScanParmFill(pAd, &ScanReq, (char *)pAd->MlmeAux.Ssid,
-                                    pAd->MlmeAux.SsidLen, BSS_ANY,
-                                    SCAN_ACTIVE);
-                       MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_MLME_SCAN_REQ,
-                                   sizeof(struct rt_mlme_scan_req), &ScanReq);
-                       pAd->Mlme.CntlMachine.CurrState =
-                           CNTL_WAIT_OID_LIST_SCAN;
-                       /* Reset Missed scan number */
-                       pAd->StaCfg.LastScanTime = Now;
-               } else {
-                       pAd->MlmeAux.BssIdx = 0;
-                       IterateOnBssTab(pAd);
-               }
-       }
-}
-
-/*
-       ==========================================================================
-       Description:
-
-       IRQL = DISPATCH_LEVEL
-
-       ==========================================================================
-*/
-void CntlOidRTBssidProc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
-{
-       unsigned long BssIdx;
-       u8 *pOidBssid = (u8 *)Elem->Msg;
-       struct rt_mlme_disassoc_req DisassocReq;
-       struct rt_mlme_join_req JoinReq;
-
-       /* record user desired settings */
-       COPY_MAC_ADDR(pAd->MlmeAux.Bssid, pOidBssid);
-       pAd->MlmeAux.BssType = pAd->StaCfg.BssType;
-
-       /* find the desired BSS in the latest SCAN result table */
-       BssIdx = BssTableSearch(&pAd->ScanTab, pOidBssid, pAd->MlmeAux.Channel);
-       if (BssIdx == BSS_NOT_FOUND) {
-               struct rt_mlme_scan_req ScanReq;
-
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("CNTL - BSSID not found. reply NDIS_STATUS_NOT_ACCEPTED\n"));
-               /*pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE; */
-
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("CNTL - BSSID not found. start a new scan\n"));
-               ScanParmFill(pAd, &ScanReq, (char *)pAd->MlmeAux.Ssid,
-                            pAd->MlmeAux.SsidLen, BSS_ANY, SCAN_ACTIVE);
-               MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_MLME_SCAN_REQ,
-                           sizeof(struct rt_mlme_scan_req), &ScanReq);
-               pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_LIST_SCAN;
-               /* Reset Missed scan number */
-               NdisGetSystemUpTime(&pAd->StaCfg.LastScanTime);
-               return;
-       }
-       /* */
-       /* Update Reconnect Ssid, that user desired to connect. */
-       /* */
-       NdisZeroMemory(pAd->MlmeAux.AutoReconnectSsid, MAX_LEN_OF_SSID);
-       pAd->MlmeAux.AutoReconnectSsidLen =
-           pAd->ScanTab.BssEntry[BssIdx].SsidLen;
-       NdisMoveMemory(pAd->MlmeAux.AutoReconnectSsid,
-                      pAd->ScanTab.BssEntry[BssIdx].Ssid,
-                      pAd->ScanTab.BssEntry[BssIdx].SsidLen);
-
-       /* copy the matched BSS entry from ScanTab to MlmeAux.SsidBssTab. Why? */
-       /* Because we need this entry to become the JOIN target in later on SYNC state machine */
-       pAd->MlmeAux.BssIdx = 0;
-       pAd->MlmeAux.SsidBssTab.BssNr = 1;
-       NdisMoveMemory(&pAd->MlmeAux.SsidBssTab.BssEntry[0],
-                      &pAd->ScanTab.BssEntry[BssIdx], sizeof(struct rt_bss_entry));
-
-       /* Add SSID into MlmeAux for site survey joining hidden SSID */
-       pAd->MlmeAux.SsidLen = pAd->ScanTab.BssEntry[BssIdx].SsidLen;
-       NdisMoveMemory(pAd->MlmeAux.Ssid, pAd->ScanTab.BssEntry[BssIdx].Ssid,
-                      pAd->MlmeAux.SsidLen);
-
-       {
-               if (INFRA_ON(pAd)) {
-                       /* disassoc from current AP first */
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("CNTL - disassociate with current AP ...\n"));
-                       DisassocParmFill(pAd, &DisassocReq,
-                                        pAd->CommonCfg.Bssid,
-                                        REASON_DISASSOC_STA_LEAVING);
-                       MlmeEnqueue(pAd, ASSOC_STATE_MACHINE,
-                                   MT2_MLME_DISASSOC_REQ,
-                                   sizeof(struct rt_mlme_disassoc_req),
-                                   &DisassocReq);
-
-                       pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_DISASSOC;
-               } else {
-                       if (ADHOC_ON(pAd)) {
-                               DBGPRINT(RT_DEBUG_TRACE,
-                                        ("CNTL - drop current ADHOC\n"));
-                               LinkDown(pAd, FALSE);
-                               OPSTATUS_CLEAR_FLAG(pAd,
-                                                   fOP_STATUS_MEDIA_STATE_CONNECTED);
-                               pAd->IndicateMediaState =
-                                   NdisMediaStateDisconnected;
-                               RTMP_IndicateMediaState(pAd);
-                               pAd->ExtraInfo = GENERAL_LINK_DOWN;
-                               DBGPRINT(RT_DEBUG_TRACE,
-                                        ("NDIS_STATUS_MEDIA_DISCONNECT Event C!\n"));
-                       }
-                       /* Change the wepstatus to original wepstatus */
-                       pAd->StaCfg.WepStatus = pAd->StaCfg.OrigWepStatus;
-                       pAd->StaCfg.PairCipher = pAd->StaCfg.OrigWepStatus;
-                       pAd->StaCfg.GroupCipher = pAd->StaCfg.OrigWepStatus;
-
-                       /* Check cipher suite, AP must have more secured cipher than station setting */
-                       /* Set the Pairwise and Group cipher to match the intended AP setting */
-                       /* We can only connect to AP with less secured cipher setting */
-                       if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA)
-                           || (pAd->StaCfg.AuthMode ==
-                               Ndis802_11AuthModeWPAPSK)) {
-                               pAd->StaCfg.GroupCipher =
-                                   pAd->ScanTab.BssEntry[BssIdx].WPA.
-                                   GroupCipher;
-
-                               if (pAd->StaCfg.WepStatus ==
-                                   pAd->ScanTab.BssEntry[BssIdx].WPA.
-                                   PairCipher)
-                                       pAd->StaCfg.PairCipher =
-                                           pAd->ScanTab.BssEntry[BssIdx].WPA.
-                                           PairCipher;
-                               else if (pAd->ScanTab.BssEntry[BssIdx].WPA.
-                                        PairCipherAux != Ndis802_11WEPDisabled)
-                                       pAd->StaCfg.PairCipher =
-                                           pAd->ScanTab.BssEntry[BssIdx].WPA.
-                                           PairCipherAux;
-                               else    /* There is no PairCipher Aux, downgrade our capability to TKIP */
-                                       pAd->StaCfg.PairCipher =
-                                           Ndis802_11Encryption2Enabled;
-                       } else
-                           if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2)
-                               || (pAd->StaCfg.AuthMode ==
-                                   Ndis802_11AuthModeWPA2PSK)) {
-                               pAd->StaCfg.GroupCipher =
-                                   pAd->ScanTab.BssEntry[BssIdx].WPA2.
-                                   GroupCipher;
-
-                               if (pAd->StaCfg.WepStatus ==
-                                   pAd->ScanTab.BssEntry[BssIdx].WPA2.
-                                   PairCipher)
-                                       pAd->StaCfg.PairCipher =
-                                           pAd->ScanTab.BssEntry[BssIdx].WPA2.
-                                           PairCipher;
-                               else if (pAd->ScanTab.BssEntry[BssIdx].WPA2.
-                                        PairCipherAux != Ndis802_11WEPDisabled)
-                                       pAd->StaCfg.PairCipher =
-                                           pAd->ScanTab.BssEntry[BssIdx].WPA2.
-                                           PairCipherAux;
-                               else    /* There is no PairCipher Aux, downgrade our capability to TKIP */
-                                       pAd->StaCfg.PairCipher =
-                                           Ndis802_11Encryption2Enabled;
-
-                               /* RSN capability */
-                               pAd->StaCfg.RsnCapability =
-                                   pAd->ScanTab.BssEntry[BssIdx].WPA2.
-                                   RsnCapability;
-                       }
-                       /* Set Mix cipher flag */
-                       pAd->StaCfg.bMixCipher =
-                           (pAd->StaCfg.PairCipher ==
-                            pAd->StaCfg.GroupCipher) ? FALSE : TRUE;
-                       /*if (pAd->StaCfg.bMixCipher == TRUE)
-                          {
-                          // If mix cipher, re-build RSNIE
-                          RTMPMakeRSNIE(pAd, pAd->StaCfg.AuthMode, pAd->StaCfg.WepStatus, 0);
-                          } */
-                       /* No active association, join the BSS immediately */
-                       DBGPRINT(RT_DEBUG_TRACE, ("CNTL - joining %pM ...\n",
-                                       pOidBssid));
-
-                       JoinParmFill(pAd, &JoinReq, pAd->MlmeAux.BssIdx);
-                       MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_MLME_JOIN_REQ,
-                                   sizeof(struct rt_mlme_join_req), &JoinReq);
-
-                       pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_JOIN;
-               }
-       }
-}
-
-/* Roaming is the only external request triggering CNTL state machine */
-/* despite of other "SET OID" operation. All "SET OID" related operations */
-/* happen in sequence, because no other SET OID will be sent to this device */
-/* until the the previous SET operation is complete (successful o failed). */
-/* So, how do we quarantee this ROAMING request won't corrupt other "SET OID"? */
-/* or been corrupted by other "SET OID"? */
-/* */
-/* IRQL = DISPATCH_LEVEL */
-void CntlMlmeRoamingProc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
-{
-       u8 BBPValue = 0;
-
-       DBGPRINT(RT_DEBUG_TRACE, ("CNTL - Roaming in MlmeAux.RoamTab...\n"));
-
-       {
-               /*Let BBP register at 20MHz to do (fast) roaming. */
-               RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue);
-               BBPValue &= (~0x18);
-               RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue);
-
-               NdisMoveMemory(&pAd->MlmeAux.SsidBssTab, &pAd->MlmeAux.RoamTab,
-                              sizeof(pAd->MlmeAux.RoamTab));
-               pAd->MlmeAux.SsidBssTab.BssNr = pAd->MlmeAux.RoamTab.BssNr;
-
-               BssTableSortByRssi(&pAd->MlmeAux.SsidBssTab);
-               pAd->MlmeAux.BssIdx = 0;
-               IterateOnBssTab(pAd);
-       }
-}
-
-/*
-       ==========================================================================
-       Description:
-
-       IRQL = DISPATCH_LEVEL
-
-       ==========================================================================
-*/
-void CntlWaitDisassocProc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
-{
-       struct rt_mlme_start_req StartReq;
-
-       if (Elem->MsgType == MT2_DISASSOC_CONF) {
-               DBGPRINT(RT_DEBUG_TRACE, ("CNTL - Dis-associate successful\n"));
-
-               if (pAd->CommonCfg.bWirelessEvent) {
-                       RTMPSendWirelessEvent(pAd, IW_DISASSOC_EVENT_FLAG,
-                                             pAd->MacTab.Content[BSSID_WCID].
-                                             Addr, BSS0, 0);
-               }
-
-               LinkDown(pAd, FALSE);
-
-               /* case 1. no matching BSS, and user wants ADHOC, so we just start a new one */
-               if ((pAd->MlmeAux.SsidBssTab.BssNr == 0)
-                   && (pAd->StaCfg.BssType == BSS_ADHOC)) {
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("CNTL - No matching BSS, start a new ADHOC (Ssid=%s)...\n",
-                                 pAd->MlmeAux.Ssid));
-                       StartParmFill(pAd, &StartReq, (char *)pAd->MlmeAux.Ssid,
-                                     pAd->MlmeAux.SsidLen);
-                       MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_MLME_START_REQ,
-                                   sizeof(struct rt_mlme_start_req), &StartReq);
-                       pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_START;
-               }
-               /* case 2. try each matched BSS */
-               else {
-                       pAd->MlmeAux.BssIdx = 0;
-
-                       IterateOnBssTab(pAd);
-               }
-       }
-}
-
-/*
-       ==========================================================================
-       Description:
-
-       IRQL = DISPATCH_LEVEL
-
-       ==========================================================================
-*/
-void CntlWaitJoinProc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
-{
-       u16 Reason;
-       struct rt_mlme_auth_req AuthReq;
-
-       if (Elem->MsgType == MT2_JOIN_CONF) {
-               NdisMoveMemory(&Reason, Elem->Msg, sizeof(u16));
-               if (Reason == MLME_SUCCESS) {
-                       /* 1. joined an IBSS, we are pretty much done here */
-                       if (pAd->MlmeAux.BssType == BSS_ADHOC) {
-                               /* */
-                               /* 5G bands rules of Japan: */
-                               /* Ad hoc must be disabled in W53(ch52,56,60,64) channels. */
-                               /* */
-                               if ((pAd->CommonCfg.bIEEE80211H == 1) &&
-                                   RadarChannelCheck(pAd,
-                                                     pAd->CommonCfg.Channel)
-                                   ) {
-                                       pAd->Mlme.CntlMachine.CurrState =
-                                           CNTL_IDLE;
-                                       DBGPRINT(RT_DEBUG_TRACE,
-                                                ("CNTL - Channel=%d, Join adhoc on W53(52,56,60,64) Channels are not accepted\n",
-                                                 pAd->CommonCfg.Channel));
-                                       return;
-                               }
-
-                               LinkUp(pAd, BSS_ADHOC);
-                               pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
-                               DBGPRINT(RT_DEBUG_TRACE,
-                                       ("CNTL - join the IBSS = %pM ...\n",
-                                               pAd->CommonCfg.Bssid));
-
-                               pAd->IndicateMediaState =
-                                   NdisMediaStateConnected;
-                               pAd->ExtraInfo = GENERAL_LINK_UP;
-                       }
-                       /* 2. joined a new INFRA network, start from authentication */
-                       else {
-                               {
-                                       /* either Ndis802_11AuthModeShared or Ndis802_11AuthModeAutoSwitch, try shared key first */
-                                       if ((pAd->StaCfg.AuthMode ==
-                                            Ndis802_11AuthModeShared)
-                                           || (pAd->StaCfg.AuthMode ==
-                                               Ndis802_11AuthModeAutoSwitch)) {
-                                               AuthParmFill(pAd, &AuthReq,
-                                                            pAd->MlmeAux.Bssid,
-                                                            AUTH_MODE_KEY);
-                                       } else {
-                                               AuthParmFill(pAd, &AuthReq,
-                                                            pAd->MlmeAux.Bssid,
-                                                            AUTH_MODE_OPEN);
-                                       }
-                                       MlmeEnqueue(pAd, AUTH_STATE_MACHINE,
-                                                   MT2_MLME_AUTH_REQ,
-                                                   sizeof
-                                                   (struct rt_mlme_auth_req),
-                                                   &AuthReq);
-                               }
-
-                               pAd->Mlme.CntlMachine.CurrState =
-                                   CNTL_WAIT_AUTH;
-                       }
-               } else {
-                       /* 3. failed, try next BSS */
-                       pAd->MlmeAux.BssIdx++;
-                       IterateOnBssTab(pAd);
-               }
-       }
-}
-
-/*
-       ==========================================================================
-       Description:
-
-       IRQL = DISPATCH_LEVEL
-
-       ==========================================================================
-*/
-void CntlWaitStartProc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
-{
-       u16 Result;
-
-       if (Elem->MsgType == MT2_START_CONF) {
-               NdisMoveMemory(&Result, Elem->Msg, sizeof(u16));
-               if (Result == MLME_SUCCESS) {
-                       /* */
-                       /* 5G bands rules of Japan: */
-                       /* Ad hoc must be disabled in W53(ch52,56,60,64) channels. */
-                       /* */
-                       if ((pAd->CommonCfg.bIEEE80211H == 1) &&
-                           RadarChannelCheck(pAd, pAd->CommonCfg.Channel)
-                           ) {
-                               pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
-                               DBGPRINT(RT_DEBUG_TRACE,
-                                        ("CNTL - Channel=%d, Start adhoc on W53(52,56,60,64) Channels are not accepted\n",
-                                         pAd->CommonCfg.Channel));
-                               return;
-                       }
-                       NdisZeroMemory(&pAd->StaActive.SupportedPhyInfo.
-                                      MCSSet[0], 16);
-                       if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED) {
-                               N_ChannelCheck(pAd);
-                               SetCommonHT(pAd);
-                               NdisMoveMemory(&pAd->MlmeAux.AddHtInfo,
-                                              &pAd->CommonCfg.AddHTInfo,
-                                              sizeof(struct rt_add_ht_info_ie));
-                               RTMPCheckHt(pAd, BSSID_WCID,
-                                           &pAd->CommonCfg.HtCapability,
-                                           &pAd->CommonCfg.AddHTInfo);
-                               pAd->StaActive.SupportedPhyInfo.bHtEnable =
-                                   TRUE;
-                               NdisMoveMemory(&pAd->StaActive.SupportedPhyInfo.
-                                              MCSSet[0],
-                                              &pAd->CommonCfg.HtCapability.
-                                              MCSSet[0], 16);
-                               COPY_HTSETTINGS_FROM_MLME_AUX_TO_ACTIVE_CFG
-                                   (pAd);
-
-                               if ((pAd->CommonCfg.HtCapability.HtCapInfo.
-                                    ChannelWidth == BW_40)
-                                   && (pAd->CommonCfg.AddHTInfo.AddHtInfo.
-                                       ExtChanOffset == EXTCHA_ABOVE)) {
-                                       pAd->MlmeAux.CentralChannel =
-                                           pAd->CommonCfg.Channel + 2;
-                               } else
-                                   if ((pAd->CommonCfg.HtCapability.HtCapInfo.
-                                        ChannelWidth == BW_40)
-                                       && (pAd->CommonCfg.AddHTInfo.AddHtInfo.
-                                           ExtChanOffset == EXTCHA_BELOW)) {
-                                       pAd->MlmeAux.CentralChannel =
-                                           pAd->CommonCfg.Channel - 2;
-                               }
-                       } else {
-                               pAd->StaActive.SupportedPhyInfo.bHtEnable =
-                                   FALSE;
-                       }
-                       LinkUp(pAd, BSS_ADHOC);
-                       pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
-                       /* Before send beacon, driver need do radar detection */
-                       if ((pAd->CommonCfg.Channel > 14)
-                           && (pAd->CommonCfg.bIEEE80211H == 1)
-                           && RadarChannelCheck(pAd, pAd->CommonCfg.Channel)) {
-                               pAd->CommonCfg.RadarDetect.RDMode =
-                                   RD_SILENCE_MODE;
-                               pAd->CommonCfg.RadarDetect.RDCount = 0;
-                       }
-
-                       DBGPRINT(RT_DEBUG_TRACE,
-                               ("CNTL - start a new IBSS = %pM ...\n",
-                                       pAd->CommonCfg.Bssid));
-               } else {
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("CNTL - Start IBSS fail. BUG!\n"));
-                       pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
-               }
-       }
-}
-
-/*
-       ==========================================================================
-       Description:
-
-       IRQL = DISPATCH_LEVEL
-
-       ==========================================================================
-*/
-void CntlWaitAuthProc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
-{
-       u16 Reason;
-       struct rt_mlme_assoc_req AssocReq;
-       struct rt_mlme_auth_req AuthReq;
-
-       if (Elem->MsgType == MT2_AUTH_CONF) {
-               NdisMoveMemory(&Reason, Elem->Msg, sizeof(u16));
-               if (Reason == MLME_SUCCESS) {
-                       DBGPRINT(RT_DEBUG_TRACE, ("CNTL - AUTH OK\n"));
-                       AssocParmFill(pAd, &AssocReq, pAd->MlmeAux.Bssid,
-                                     pAd->MlmeAux.CapabilityInfo,
-                                     ASSOC_TIMEOUT,
-                                     pAd->StaCfg.DefaultListenCount);
-
-                       {
-                               MlmeEnqueue(pAd, ASSOC_STATE_MACHINE,
-                                           MT2_MLME_ASSOC_REQ,
-                                           sizeof(struct rt_mlme_assoc_req),
-                                           &AssocReq);
-
-                               pAd->Mlme.CntlMachine.CurrState =
-                                   CNTL_WAIT_ASSOC;
-                       }
-               } else {
-                       /* This fail may because of the AP already keep us in its MAC table without */
-                       /* ageing-out. The previous authentication attempt must have let it remove us. */
-                       /* so try Authentication again may help. For D-Link DWL-900AP+ compatibility. */
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("CNTL - AUTH FAIL, try again...\n"));
-
-                       {
-                               if ((pAd->StaCfg.AuthMode ==
-                                    Ndis802_11AuthModeShared)
-                                   || (pAd->StaCfg.AuthMode ==
-                                       Ndis802_11AuthModeAutoSwitch)) {
-                                       /* either Ndis802_11AuthModeShared or Ndis802_11AuthModeAutoSwitch, try shared key first */
-                                       AuthParmFill(pAd, &AuthReq,
-                                                    pAd->MlmeAux.Bssid,
-                                                    AUTH_MODE_KEY);
-                               } else {
-                                       AuthParmFill(pAd, &AuthReq,
-                                                    pAd->MlmeAux.Bssid,
-                                                    AUTH_MODE_OPEN);
-                               }
-                               MlmeEnqueue(pAd, AUTH_STATE_MACHINE,
-                                           MT2_MLME_AUTH_REQ,
-                                           sizeof(struct rt_mlme_auth_req),
-                                           &AuthReq);
-
-                       }
-                       pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_AUTH2;
-               }
-       }
-}
-
-/*
-       ==========================================================================
-       Description:
-
-       IRQL = DISPATCH_LEVEL
-
-       ==========================================================================
-*/
-void CntlWaitAuthProc2(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
-{
-       u16 Reason;
-       struct rt_mlme_assoc_req AssocReq;
-       struct rt_mlme_auth_req AuthReq;
-
-       if (Elem->MsgType == MT2_AUTH_CONF) {
-               NdisMoveMemory(&Reason, Elem->Msg, sizeof(u16));
-               if (Reason == MLME_SUCCESS) {
-                       DBGPRINT(RT_DEBUG_TRACE, ("CNTL - AUTH OK\n"));
-                       AssocParmFill(pAd, &AssocReq, pAd->MlmeAux.Bssid,
-                                     pAd->MlmeAux.CapabilityInfo,
-                                     ASSOC_TIMEOUT,
-                                     pAd->StaCfg.DefaultListenCount);
-                       {
-                               MlmeEnqueue(pAd, ASSOC_STATE_MACHINE,
-                                           MT2_MLME_ASSOC_REQ,
-                                           sizeof(struct rt_mlme_assoc_req),
-                                           &AssocReq);
-
-                               pAd->Mlme.CntlMachine.CurrState =
-                                   CNTL_WAIT_ASSOC;
-                       }
-               } else {
-                       if ((pAd->StaCfg.AuthMode ==
-                            Ndis802_11AuthModeAutoSwitch)
-                           && (pAd->MlmeAux.Alg == Ndis802_11AuthModeShared)) {
-                               DBGPRINT(RT_DEBUG_TRACE,
-                                        ("CNTL - AUTH FAIL, try OPEN system...\n"));
-                               AuthParmFill(pAd, &AuthReq, pAd->MlmeAux.Bssid,
-                                            Ndis802_11AuthModeOpen);
-                               MlmeEnqueue(pAd, AUTH_STATE_MACHINE,
-                                           MT2_MLME_AUTH_REQ,
-                                           sizeof(struct rt_mlme_auth_req),
-                                           &AuthReq);
-
-                               pAd->Mlme.CntlMachine.CurrState =
-                                   CNTL_WAIT_AUTH2;
-                       } else {
-                               /* not success, try next BSS */
-                               DBGPRINT(RT_DEBUG_TRACE,
-                                        ("CNTL - AUTH FAIL, give up; try next BSS\n"));
-                               pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;    /*??????? */
-                               pAd->MlmeAux.BssIdx++;
-                               IterateOnBssTab(pAd);
-                       }
-               }
-       }
-}
-
-/*
-       ==========================================================================
-       Description:
-
-       IRQL = DISPATCH_LEVEL
-
-       ==========================================================================
-*/
-void CntlWaitAssocProc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
-{
-       u16 Reason;
-
-       if (Elem->MsgType == MT2_ASSOC_CONF) {
-               NdisMoveMemory(&Reason, Elem->Msg, sizeof(u16));
-               if (Reason == MLME_SUCCESS) {
-                       if (pAd->CommonCfg.bWirelessEvent) {
-                               RTMPSendWirelessEvent(pAd, IW_ASSOC_EVENT_FLAG,
-                                                     pAd->MacTab.
-                                                     Content[BSSID_WCID].Addr,
-                                                     BSS0, 0);
-                       }
-
-                       LinkUp(pAd, BSS_INFRA);
-                       pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("CNTL - Association successful on BSS #%ld\n",
-                                 pAd->MlmeAux.BssIdx));
-               } else {
-                       /* not success, try next BSS */
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("CNTL - Association fails on BSS #%ld\n",
-                                 pAd->MlmeAux.BssIdx));
-                       pAd->MlmeAux.BssIdx++;
-                       IterateOnBssTab(pAd);
-               }
-       }
-}
-
-/*
-       ==========================================================================
-       Description:
-
-       IRQL = DISPATCH_LEVEL
-
-       ==========================================================================
-*/
-void CntlWaitReassocProc(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
-{
-       u16 Result;
-
-       if (Elem->MsgType == MT2_REASSOC_CONF) {
-               NdisMoveMemory(&Result, Elem->Msg, sizeof(u16));
-               if (Result == MLME_SUCCESS) {
-                       /* send wireless event - for association */
-                       if (pAd->CommonCfg.bWirelessEvent)
-                               RTMPSendWirelessEvent(pAd, IW_ASSOC_EVENT_FLAG,
-                                                     pAd->MacTab.
-                                                     Content[BSSID_WCID].Addr,
-                                                     BSS0, 0);
-
-                       /* */
-                       /* NDIS requires a new Link UP indication but no Link Down for RE-ASSOC */
-                       /* */
-                       LinkUp(pAd, BSS_INFRA);
-
-                       pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("CNTL - Re-assocition successful on BSS #%ld\n",
-                                 pAd->MlmeAux.RoamIdx));
-               } else {
-                       /* reassoc failed, try to pick next BSS in the BSS Table */
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("CNTL - Re-assocition fails on BSS #%ld\n",
-                                 pAd->MlmeAux.RoamIdx));
-                       {
-                               pAd->MlmeAux.RoamIdx++;
-                               IterateOnBssTab2(pAd);
-                       }
-               }
-       }
-}
-
-void AdhocTurnOnQos(struct rt_rtmp_adapter *pAd)
-{
-#define AC0_DEF_TXOP           0
-#define AC1_DEF_TXOP           0
-#define AC2_DEF_TXOP           94
-#define AC3_DEF_TXOP           47
-
-       /* Turn on QOs if use HT rate. */
-       if (pAd->CommonCfg.APEdcaParm.bValid == FALSE) {
-               pAd->CommonCfg.APEdcaParm.bValid = TRUE;
-               pAd->CommonCfg.APEdcaParm.Aifsn[0] = 3;
-               pAd->CommonCfg.APEdcaParm.Aifsn[1] = 7;
-               pAd->CommonCfg.APEdcaParm.Aifsn[2] = 1;
-               pAd->CommonCfg.APEdcaParm.Aifsn[3] = 1;
-
-               pAd->CommonCfg.APEdcaParm.Cwmin[0] = 4;
-               pAd->CommonCfg.APEdcaParm.Cwmin[1] = 4;
-               pAd->CommonCfg.APEdcaParm.Cwmin[2] = 3;
-               pAd->CommonCfg.APEdcaParm.Cwmin[3] = 2;
-
-               pAd->CommonCfg.APEdcaParm.Cwmax[0] = 10;
-               pAd->CommonCfg.APEdcaParm.Cwmax[1] = 6;
-               pAd->CommonCfg.APEdcaParm.Cwmax[2] = 4;
-               pAd->CommonCfg.APEdcaParm.Cwmax[3] = 3;
-
-               pAd->CommonCfg.APEdcaParm.Txop[0] = 0;
-               pAd->CommonCfg.APEdcaParm.Txop[1] = 0;
-               pAd->CommonCfg.APEdcaParm.Txop[2] = AC2_DEF_TXOP;
-               pAd->CommonCfg.APEdcaParm.Txop[3] = AC3_DEF_TXOP;
-       }
-       AsicSetEdcaParm(pAd, &pAd->CommonCfg.APEdcaParm);
-}
-
-/*
-       ==========================================================================
-       Description:
-
-       IRQL = DISPATCH_LEVEL
-
-       ==========================================================================
-*/
-void LinkUp(struct rt_rtmp_adapter *pAd, u8 BssType)
-{
-       unsigned long Now;
-       u32 Data;
-       BOOLEAN Cancelled;
-       u8 Value = 0, idx = 0, HashIdx = 0;
-       struct rt_mac_table_entry *pEntry = NULL, *pCurrEntry = NULL;
-
-       /* Init ChannelQuality to prevent DEAD_CQI at initial LinkUp */
-       pAd->Mlme.ChannelQuality = 50;
-
-       pEntry = MacTableLookup(pAd, pAd->CommonCfg.Bssid);
-       if (pEntry) {
-               MacTableDeleteEntry(pAd, pEntry->Aid, pEntry->Addr);
-               pEntry = NULL;
-       }
-
-       pEntry = &pAd->MacTab.Content[BSSID_WCID];
-
-       /* */
-       /* ASSOC - DisassocTimeoutAction */
-       /* CNTL - Dis-associate successful */
-       /* ! LINK DOWN ! */
-       /* [88888] OID_802_11_SSID should have returned NDTEST_WEP_AP2(Returned: ) */
-       /* */
-       /* To prevent DisassocTimeoutAction to call Link down after we link up, */
-       /* cancel the DisassocTimer no matter what it start or not. */
-       /* */
-       RTMPCancelTimer(&pAd->MlmeAux.DisassocTimer, &Cancelled);
-
-       COPY_SETTINGS_FROM_MLME_AUX_TO_ACTIVE_CFG(pAd);
-
-       COPY_HTSETTINGS_FROM_MLME_AUX_TO_ACTIVE_CFG(pAd);
-
-#ifdef RTMP_MAC_PCI
-       /* Before power save before link up function, We will force use 1R. */
-       /* So after link up, check Rx antenna # again. */
-       RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &Value);
-       if (pAd->Antenna.field.RxPath == 3) {
-               Value |= (0x10);
-       } else if (pAd->Antenna.field.RxPath == 2) {
-               Value |= (0x8);
-       } else if (pAd->Antenna.field.RxPath == 1) {
-               Value |= (0x0);
-       }
-       RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, Value);
-       pAd->StaCfg.BBPR3 = Value;
-#endif /* RTMP_MAC_PCI // */
-
-       if (BssType == BSS_ADHOC) {
-               OPSTATUS_SET_FLAG(pAd, fOP_STATUS_ADHOC_ON);
-               OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_INFRA_ON);
-
-               if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)
-                       AdhocTurnOnQos(pAd);
-
-               DBGPRINT(RT_DEBUG_TRACE, ("Adhoc LINK UP!\n"));
-       } else {
-               OPSTATUS_SET_FLAG(pAd, fOP_STATUS_INFRA_ON);
-               OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_ADHOC_ON);
-
-               DBGPRINT(RT_DEBUG_TRACE, ("Infra LINK UP!\n"));
-       }
-
-       /* 3*3 */
-       /* reset Tx beamforming bit */
-       RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &Value);
-       Value &= (~0x01);
-       Value |= pAd->CommonCfg.RegTransmitSetting.field.TxBF;
-       RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, Value);
-
-       /* Change to AP channel */
-       if ((pAd->CommonCfg.CentralChannel > pAd->CommonCfg.Channel)
-           && (pAd->MlmeAux.HtCapability.HtCapInfo.ChannelWidth == BW_40)) {
-               /* Must use 40MHz. */
-               pAd->CommonCfg.BBPCurrentBW = BW_40;
-               AsicSwitchChannel(pAd, pAd->CommonCfg.CentralChannel, FALSE);
-               AsicLockChannel(pAd, pAd->CommonCfg.CentralChannel);
-
-               RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &Value);
-               Value &= (~0x18);
-               Value |= 0x10;
-               RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, Value);
-
-               /*  RX : control channel at lower */
-               RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &Value);
-               Value &= (~0x20);
-               RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, Value);
-#ifdef RTMP_MAC_PCI
-               pAd->StaCfg.BBPR3 = Value;
-#endif /* RTMP_MAC_PCI // */
-
-               RTMP_IO_READ32(pAd, TX_BAND_CFG, &Data);
-               Data &= 0xfffffffe;
-               RTMP_IO_WRITE32(pAd, TX_BAND_CFG, Data);
-
-               if (pAd->MACVersion == 0x28600100) {
-                       RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R69, 0x1A);
-                       RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R70, 0x0A);
-                       RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R73, 0x16);
-                       DBGPRINT(RT_DEBUG_TRACE, ("rt2860C !\n"));
-               }
-
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("40MHz Lower LINK UP! Control Channel at Below. Central = %d \n",
-                         pAd->CommonCfg.CentralChannel));
-       } else if ((pAd->CommonCfg.CentralChannel < pAd->CommonCfg.Channel)
-                  && (pAd->MlmeAux.HtCapability.HtCapInfo.ChannelWidth ==
-                      BW_40)) {
-               /* Must use 40MHz. */
-               pAd->CommonCfg.BBPCurrentBW = BW_40;
-               AsicSwitchChannel(pAd, pAd->CommonCfg.CentralChannel, FALSE);
-               AsicLockChannel(pAd, pAd->CommonCfg.CentralChannel);
-
-               RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &Value);
-               Value &= (~0x18);
-               Value |= 0x10;
-               RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, Value);
-
-               RTMP_IO_READ32(pAd, TX_BAND_CFG, &Data);
-               Data |= 0x1;
-               RTMP_IO_WRITE32(pAd, TX_BAND_CFG, Data);
-
-               RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &Value);
-               Value |= (0x20);
-               RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, Value);
-#ifdef RTMP_MAC_PCI
-               pAd->StaCfg.BBPR3 = Value;
-#endif /* RTMP_MAC_PCI // */
-
-               if (pAd->MACVersion == 0x28600100) {
-                       RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R69, 0x1A);
-                       RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R70, 0x0A);
-                       RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R73, 0x16);
-                       DBGPRINT(RT_DEBUG_TRACE, ("rt2860C !\n"));
-               }
-
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("40MHz Upper LINK UP! Control Channel at UpperCentral = %d \n",
-                         pAd->CommonCfg.CentralChannel));
-       } else {
-               pAd->CommonCfg.BBPCurrentBW = BW_20;
-               pAd->CommonCfg.CentralChannel = pAd->CommonCfg.Channel;
-               AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE);
-               AsicLockChannel(pAd, pAd->CommonCfg.Channel);
-
-               RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &Value);
-               Value &= (~0x18);
-               RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, Value);
-
-               RTMP_IO_READ32(pAd, TX_BAND_CFG, &Data);
-               Data &= 0xfffffffe;
-               RTMP_IO_WRITE32(pAd, TX_BAND_CFG, Data);
-
-               RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &Value);
-               Value &= (~0x20);
-               RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, Value);
-#ifdef RTMP_MAC_PCI
-               pAd->StaCfg.BBPR3 = Value;
-#endif /* RTMP_MAC_PCI // */
-
-               if (pAd->MACVersion == 0x28600100) {
-                       RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R69, 0x16);
-                       RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R70, 0x08);
-                       RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R73, 0x11);
-                       DBGPRINT(RT_DEBUG_TRACE, ("rt2860C !\n"));
-               }
-
-               DBGPRINT(RT_DEBUG_TRACE, ("20MHz LINK UP!\n"));
-       }
-
-       RTMPSetAGCInitValue(pAd, pAd->CommonCfg.BBPCurrentBW);
-
-       /* */
-       /* Save BBP_R66 value, it will be used in RTUSBResumeMsduTransmission */
-       /* */
-       RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R66,
-                                   &pAd->BbpTuning.R66CurrentValue);
-
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("LINK UP! (BssType=%d, AID=%d, ssid=%s, Channel=%d, CentralChannel = %d)\n",
-                 BssType, pAd->StaActive.Aid, pAd->CommonCfg.Ssid,
-                 pAd->CommonCfg.Channel, pAd->CommonCfg.CentralChannel));
-
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("LINK UP! (Density =%d, )\n",
-                 pAd->MacTab.Content[BSSID_WCID].MpduDensity));
-
-       AsicSetBssid(pAd, pAd->CommonCfg.Bssid);
-
-       AsicSetSlotTime(pAd, TRUE);
-       AsicSetEdcaParm(pAd, &pAd->CommonCfg.APEdcaParm);
-
-       /* Call this for RTS protection for legacy rate, we will always enable RTS threshold, but normally it will not hit */
-       AsicUpdateProtect(pAd, 0, (OFDMSETPROTECT | CCKSETPROTECT), TRUE,
-                         FALSE);
-
-       if ((pAd->StaActive.SupportedPhyInfo.bHtEnable == TRUE)) {
-               /* Update HT protection for based on AP's operating mode. */
-               if (pAd->MlmeAux.AddHtInfo.AddHtInfo2.NonGfPresent == 1) {
-                       AsicUpdateProtect(pAd,
-                                         pAd->MlmeAux.AddHtInfo.AddHtInfo2.
-                                         OperaionMode, ALLN_SETPROTECT, FALSE,
-                                         TRUE);
-               } else
-                       AsicUpdateProtect(pAd,
-                                         pAd->MlmeAux.AddHtInfo.AddHtInfo2.
-                                         OperaionMode, ALLN_SETPROTECT, FALSE,
-                                         FALSE);
-       }
-
-       NdisZeroMemory(&pAd->DrsCounters, sizeof(struct rt_counter_drs));
-
-       NdisGetSystemUpTime(&Now);
-       pAd->StaCfg.LastBeaconRxTime = Now;     /* last RX timestamp */
-
-       if ((pAd->CommonCfg.TxPreamble != Rt802_11PreambleLong) &&
-           CAP_IS_SHORT_PREAMBLE_ON(pAd->StaActive.CapabilityInfo)) {
-               MlmeSetTxPreamble(pAd, Rt802_11PreambleShort);
-       }
-
-       OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_AGGREGATION_INUSED);
-
-       if (pAd->CommonCfg.RadarDetect.RDMode == RD_SILENCE_MODE) {
-       }
-       pAd->CommonCfg.RadarDetect.RDMode = RD_NORMAL_MODE;
-
-       if (BssType == BSS_ADHOC) {
-               MakeIbssBeacon(pAd);
-               if ((pAd->CommonCfg.Channel > 14)
-                   && (pAd->CommonCfg.bIEEE80211H == 1)
-                   && RadarChannelCheck(pAd, pAd->CommonCfg.Channel)) {
-                       ;       /*Do nothing */
-               } else {
-                       AsicEnableIbssSync(pAd);
-               }
-
-               /* In ad hoc mode, use MAC table from index 1. */
-               /* p.s ASIC use all 0xff as termination of WCID table search.To prevent it's 0xff-ff-ff-ff-ff-ff, Write 0 here. */
-               RTMP_IO_WRITE32(pAd, MAC_WCID_BASE, 0x00);
-               RTMP_IO_WRITE32(pAd, 0x1808, 0x00);
-
-               /* If WEP is enabled, add key material and cipherAlg into Asic */
-               /* Fill in Shared Key Table(offset: 0x6c00) and Shared Key Mode(offset: 0x7000) */
-
-               if (pAd->StaCfg.WepStatus == Ndis802_11WEPEnabled) {
-                       u8 *Key;
-                       u8 CipherAlg;
-
-                       for (idx = 0; idx < SHARE_KEY_NUM; idx++) {
-                               CipherAlg = pAd->SharedKey[BSS0][idx].CipherAlg;
-                               Key = pAd->SharedKey[BSS0][idx].Key;
-
-                               if (pAd->SharedKey[BSS0][idx].KeyLen > 0) {
-                                       /* Set key material and cipherAlg to Asic */
-                                       AsicAddSharedKeyEntry(pAd, BSS0, idx,
-                                                             CipherAlg, Key,
-                                                             NULL, NULL);
-
-                                       if (idx == pAd->StaCfg.DefaultKeyId) {
-                                               /* Update WCID attribute table and IVEIV table for this group key table */
-                                               RTMPAddWcidAttributeEntry(pAd,
-                                                                         BSS0,
-                                                                         idx,
-                                                                         CipherAlg,
-                                                                         NULL);
-                                       }
-                               }
-
-                       }
-               }
-               /* If WPANone is enabled, add key material and cipherAlg into Asic */
-               /* Fill in Shared Key Table(offset: 0x6c00) and Shared Key Mode(offset: 0x7000) */
-               else if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone) {
-                       pAd->StaCfg.DefaultKeyId = 0;   /* always be zero */
-
-                       NdisZeroMemory(&pAd->SharedKey[BSS0][0],
-                                      sizeof(struct rt_cipher_key));
-                       pAd->SharedKey[BSS0][0].KeyLen = LEN_TKIP_EK;
-                       NdisMoveMemory(pAd->SharedKey[BSS0][0].Key,
-                                      pAd->StaCfg.PMK, LEN_TKIP_EK);
-
-                       if (pAd->StaCfg.PairCipher ==
-                           Ndis802_11Encryption2Enabled) {
-                               NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic,
-                                              &pAd->StaCfg.PMK[16],
-                                              LEN_TKIP_RXMICK);
-                               NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic,
-                                              &pAd->StaCfg.PMK[16],
-                                              LEN_TKIP_TXMICK);
-                       }
-                       /* Decide its ChiperAlg */
-                       if (pAd->StaCfg.PairCipher ==
-                           Ndis802_11Encryption2Enabled)
-                               pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_TKIP;
-                       else if (pAd->StaCfg.PairCipher ==
-                                Ndis802_11Encryption3Enabled)
-                               pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_AES;
-                       else {
-                               DBGPRINT(RT_DEBUG_TRACE,
-                                        ("Unknow Cipher (=%d), set Cipher to AES\n",
-                                         pAd->StaCfg.PairCipher));
-                               pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_AES;
-                       }
-
-                       /* Set key material and cipherAlg to Asic */
-                       AsicAddSharedKeyEntry(pAd,
-                                             BSS0,
-                                             0,
-                                             pAd->SharedKey[BSS0][0].CipherAlg,
-                                             pAd->SharedKey[BSS0][0].Key,
-                                             pAd->SharedKey[BSS0][0].TxMic,
-                                             pAd->SharedKey[BSS0][0].RxMic);
-
-                       /* Update WCID attribute table and IVEIV table for this group key table */
-                       RTMPAddWcidAttributeEntry(pAd, BSS0, 0,
-                                                 pAd->SharedKey[BSS0][0].
-                                                 CipherAlg, NULL);
-
-               }
-
-       } else                  /* BSS_INFRA */
-       {
-               /* Check the new SSID with last SSID */
-               while (Cancelled == TRUE) {
-                       if (pAd->CommonCfg.LastSsidLen ==
-                           pAd->CommonCfg.SsidLen) {
-                               if (RTMPCompareMemory
-                                   (pAd->CommonCfg.LastSsid,
-                                    pAd->CommonCfg.Ssid,
-                                    pAd->CommonCfg.LastSsidLen) == 0) {
-                                       /* Link to the old one no linkdown is required. */
-                                       break;
-                               }
-                       }
-                       /* Send link down event before set to link up */
-                       pAd->IndicateMediaState = NdisMediaStateDisconnected;
-                       RTMP_IndicateMediaState(pAd);
-                       pAd->ExtraInfo = GENERAL_LINK_DOWN;
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("NDIS_STATUS_MEDIA_DISCONNECT Event AA!\n"));
-                       break;
-               }
-
-               /* */
-               /* On WPA mode, Remove All Keys if not connect to the last BSSID */
-               /* Key will be set after 4-way handshake. */
-               /* */
-               if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) {
-                       unsigned long IV;
-
-                       /* Remove all WPA keys */
-                       RTMP_CLEAR_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
-                       RTMPWPARemoveAllKeys(pAd);
-                       pAd->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
-                       pAd->StaCfg.PrivacyFilter =
-                           Ndis802_11PrivFilter8021xWEP;
-
-                       /* Fixed connection failed with Range Maximizer - 515 AP (Marvell Chip) when security is WPAPSK/TKIP */
-                       /* If IV related values are too large in GroupMsg2, AP would ignore this message. */
-                       IV = 1;
-                       IV |= (pAd->StaCfg.DefaultKeyId << 30);
-                       AsicUpdateWCIDIVEIV(pAd, BSSID_WCID, IV, 0);
-               }
-               /* NOTE: */
-               /* the decision of using "short slot time" or not may change dynamically due to */
-               /* new STA association to the AP. so we have to decide that upon parsing BEACON, not here */
-
-               /* NOTE: */
-               /* the decision to use "RTC/CTS" or "CTS-to-self" protection or not may change dynamically */
-               /* due to new STA association to the AP. so we have to decide that upon parsing BEACON, not here */
-
-               ComposePsPoll(pAd);
-               ComposeNullFrame(pAd);
-
-               AsicEnableBssSync(pAd);
-
-               /* Add BSSID to WCID search table */
-               AsicUpdateRxWCIDTable(pAd, BSSID_WCID, pAd->CommonCfg.Bssid);
-
-               /* If WEP is enabled, add pairwise and shared key */
-               if (((pAd->StaCfg.WpaSupplicantUP) &&
-                    (pAd->StaCfg.WepStatus == Ndis802_11WEPEnabled) &&
-                    (pAd->StaCfg.PortSecured == WPA_802_1X_PORT_SECURED)) ||
-                   ((pAd->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_DISABLE) &&
-                    (pAd->StaCfg.WepStatus == Ndis802_11WEPEnabled))) {
-                       u8 *Key;
-                       u8 CipherAlg;
-
-                       for (idx = 0; idx < SHARE_KEY_NUM; idx++) {
-                               CipherAlg = pAd->SharedKey[BSS0][idx].CipherAlg;
-                               Key = pAd->SharedKey[BSS0][idx].Key;
-
-                               if (pAd->SharedKey[BSS0][idx].KeyLen > 0) {
-                                       /* Set key material and cipherAlg to Asic */
-                                       AsicAddSharedKeyEntry(pAd, BSS0, idx,
-                                                             CipherAlg, Key,
-                                                             NULL, NULL);
-
-                                       if (idx == pAd->StaCfg.DefaultKeyId) {
-                                               /* Assign group key info */
-                                               RTMPAddWcidAttributeEntry(pAd,
-                                                                         BSS0,
-                                                                         idx,
-                                                                         CipherAlg,
-                                                                         NULL);
-
-                                               pEntry->Aid = BSSID_WCID;
-                                               /* Assign pairwise key info */
-                                               RTMPAddWcidAttributeEntry(pAd,
-                                                                         BSS0,
-                                                                         idx,
-                                                                         CipherAlg,
-                                                                         pEntry);
-                                       }
-                               }
-                       }
-               }
-               /* only INFRASTRUCTURE mode need to indicate connectivity immediately; ADHOC mode */
-               /* should wait until at least 2 active nodes in this BSSID. */
-               OPSTATUS_SET_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED);
-
-               /* For GUI ++ */
-               if (pAd->StaCfg.AuthMode < Ndis802_11AuthModeWPA) {
-                       pAd->IndicateMediaState = NdisMediaStateConnected;
-                       pAd->ExtraInfo = GENERAL_LINK_UP;
-                       RTMP_IndicateMediaState(pAd);
-               } else if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
-                          (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK))
-               {
-                       if (pAd->StaCfg.WpaSupplicantUP ==
-                           WPA_SUPPLICANT_DISABLE)
-                               RTMPSetTimer(&pAd->Mlme.LinkDownTimer,
-                                            LINK_DOWN_TIMEOUT);
-               }
-               /* -- */
-
-               /* Add BSSID in my MAC Table. */
-               NdisAcquireSpinLock(&pAd->MacTabLock);
-               /* add this MAC entry into HASH table */
-               if (pEntry) {
-                       HashIdx = MAC_ADDR_HASH_INDEX(pAd->CommonCfg.Bssid);
-                       if (pAd->MacTab.Hash[HashIdx] == NULL) {
-                               pAd->MacTab.Hash[HashIdx] = pEntry;
-                       } else {
-                               pCurrEntry = pAd->MacTab.Hash[HashIdx];
-                               while (pCurrEntry->pNext != NULL) {
-                                       pCurrEntry = pCurrEntry->pNext;
-                               }
-                               pCurrEntry->pNext = pEntry;
-                       }
-               }
-               RTMPMoveMemory(pEntry->Addr, pAd->CommonCfg.Bssid,
-                              MAC_ADDR_LEN);
-               pEntry->Aid = BSSID_WCID;
-               pEntry->pAd = pAd;
-               pEntry->ValidAsCLI = TRUE;      /*Although this is bssid..still set ValidAsCl */
-               pAd->MacTab.Size = 1;   /* infra mode always set MACtab size =1. */
-               pEntry->Sst = SST_ASSOC;
-               pEntry->AuthState = SST_ASSOC;
-               pEntry->AuthMode = pAd->StaCfg.AuthMode;
-               pEntry->WepStatus = pAd->StaCfg.WepStatus;
-               if (pEntry->AuthMode < Ndis802_11AuthModeWPA) {
-                       pEntry->WpaState = AS_NOTUSE;
-                       pEntry->PrivacyFilter = Ndis802_11PrivFilterAcceptAll;
-               } else {
-                       pEntry->WpaState = AS_PTKSTART;
-                       pEntry->PrivacyFilter = Ndis802_11PrivFilter8021xWEP;
-               }
-               NdisReleaseSpinLock(&pAd->MacTabLock);
-
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("LINK UP!  ClientStatusFlags=%lx)\n",
-                         pAd->MacTab.Content[BSSID_WCID].ClientStatusFlags));
-
-               MlmeUpdateTxRates(pAd, TRUE, BSS0);
-               MlmeUpdateHtTxRates(pAd, BSS0);
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("LINK UP! (StaActive.bHtEnable =%d, )\n",
-                         pAd->StaActive.SupportedPhyInfo.bHtEnable));
-
-               if (pAd->CommonCfg.bAggregationCapable) {
-                       if ((pAd->CommonCfg.bPiggyBackCapable)
-                           && (pAd->MlmeAux.APRalinkIe & 0x00000003) == 3) {
-                               OPSTATUS_SET_FLAG(pAd,
-                                                 fOP_STATUS_PIGGYBACK_INUSED);
-                               OPSTATUS_SET_FLAG(pAd,
-                                                 fOP_STATUS_AGGREGATION_INUSED);
-                               CLIENT_STATUS_SET_FLAG(pEntry,
-                                                      fCLIENT_STATUS_AGGREGATION_CAPABLE);
-                               CLIENT_STATUS_SET_FLAG(pEntry,
-                                                      fCLIENT_STATUS_PIGGYBACK_CAPABLE);
-                               RTMPSetPiggyBack(pAd, TRUE);
-                               DBGPRINT(RT_DEBUG_TRACE,
-                                        ("Turn on Piggy-Back\n"));
-                       } else if (pAd->MlmeAux.APRalinkIe & 0x00000001) {
-                               OPSTATUS_SET_FLAG(pAd,
-                                                 fOP_STATUS_AGGREGATION_INUSED);
-                               CLIENT_STATUS_SET_FLAG(pEntry,
-                                                      fCLIENT_STATUS_AGGREGATION_CAPABLE);
-                               DBGPRINT(RT_DEBUG_TRACE,
-                                        ("Ralink Aggregation\n"));
-                       }
-               }
-
-               if (pAd->MlmeAux.APRalinkIe != 0x0) {
-                       if (CLIENT_STATUS_TEST_FLAG
-                           (pEntry, fCLIENT_STATUS_RDG_CAPABLE)) {
-                               AsicEnableRDG(pAd);
-                       }
-                       OPSTATUS_SET_FLAG(pAd, fCLIENT_STATUS_RALINK_CHIPSET);
-                       CLIENT_STATUS_SET_FLAG(pEntry,
-                                              fCLIENT_STATUS_RALINK_CHIPSET);
-               } else {
-                       OPSTATUS_CLEAR_FLAG(pAd, fCLIENT_STATUS_RALINK_CHIPSET);
-                       CLIENT_STATUS_CLEAR_FLAG(pEntry,
-                                                fCLIENT_STATUS_RALINK_CHIPSET);
-               }
-       }
-
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("NDIS_STATUS_MEDIA_CONNECT Event B!.BACapability = %x. ClientStatusFlags = %lx\n",
-                 pAd->CommonCfg.BACapability.word,
-                 pAd->MacTab.Content[BSSID_WCID].ClientStatusFlags));
-
-       /* Set LED */
-       RTMPSetLED(pAd, LED_LINK_UP);
-
-       pAd->Mlme.PeriodicRound = 0;
-       pAd->Mlme.OneSecPeriodicRound = 0;
-       pAd->bConfigChanged = FALSE;    /* Reset config flag */
-       pAd->ExtraInfo = GENERAL_LINK_UP;       /* Update extra information after link is up */
-
-       /* Set basic auto fall back */
-       {
-               u8 *pTable;
-               u8 TableSize = 0;
-
-               MlmeSelectTxRateTable(pAd, &pAd->MacTab.Content[BSSID_WCID],
-                                     &pTable, &TableSize,
-                                     &pAd->CommonCfg.TxRateIndex);
-               AsicUpdateAutoFallBackTable(pAd, pTable);
-       }
-
-       NdisAcquireSpinLock(&pAd->MacTabLock);
-       pEntry->HTPhyMode.word = pAd->StaCfg.HTPhyMode.word;
-       pEntry->MaxHTPhyMode.word = pAd->StaCfg.HTPhyMode.word;
-       if (pAd->StaCfg.bAutoTxRateSwitch == FALSE) {
-               pEntry->bAutoTxRateSwitch = FALSE;
-
-               if (pEntry->HTPhyMode.field.MCS == 32)
-                       pEntry->HTPhyMode.field.ShortGI = GI_800;
-
-               if ((pEntry->HTPhyMode.field.MCS > MCS_7)
-                   || (pEntry->HTPhyMode.field.MCS == 32))
-                       pEntry->HTPhyMode.field.STBC = STBC_NONE;
-
-               /* If the legacy mode is set, overwrite the transmit setting of this entry. */
-               if (pEntry->HTPhyMode.field.MODE <= MODE_OFDM)
-                       RTMPUpdateLegacyTxSetting((u8)pAd->StaCfg.
-                                                 DesiredTransmitSetting.field.
-                                                 FixedTxMode, pEntry);
-       } else
-               pEntry->bAutoTxRateSwitch = TRUE;
-       NdisReleaseSpinLock(&pAd->MacTabLock);
-
-       /*  Let Link Status Page display first initial rate. */
-       pAd->LastTxRate = (u16)(pEntry->HTPhyMode.word);
-       /* Select DAC according to HT or Legacy */
-       if (pAd->StaActive.SupportedPhyInfo.MCSSet[0] != 0x00) {
-               RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R1, &Value);
-               Value &= (~0x18);
-               if (pAd->Antenna.field.TxPath == 2) {
-                       Value |= 0x10;
-               }
-               RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R1, Value);
-       } else {
-               RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R1, &Value);
-               Value &= (~0x18);
-               RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R1, Value);
-       }
-
-       if (pAd->StaActive.SupportedPhyInfo.bHtEnable == FALSE) {
-       } else if (pEntry->MaxRAmpduFactor == 0) {
-               /* If HT AP doesn't support MaxRAmpduFactor = 1, we need to set max PSDU to 0. */
-               /* Because our Init value is 1 at MACRegTable. */
-               RTMP_IO_WRITE32(pAd, MAX_LEN_CFG, 0x0fff);
-       }
-       /* Patch for Marvel AP to gain high throughput */
-       /* Need to set as following, */
-       /* 1. Set txop in register-EDCA_AC0_CFG as 0x60 */
-       /* 2. Set EnTXWriteBackDDONE in register-WPDMA_GLO_CFG as zero */
-       /* 3. PBF_MAX_PCNT as 0x1F3FBF9F */
-       /* 4. kick per two packets when dequeue */
-       /* */
-       /* Txop can only be modified when RDG is off, WMM is disable and TxBurst is enable */
-       /* */
-       /* if 1. Legacy AP WMM on,  or 2. 11n AP, AMPDU disable.  Force turn off burst no matter what bEnableTxBurst is. */
-       if (!((pAd->CommonCfg.RxStream == 1) && (pAd->CommonCfg.TxStream == 1))
-           && (pAd->StaCfg.bForceTxBurst == FALSE)
-           &&
-           (((pAd->StaActive.SupportedPhyInfo.bHtEnable == FALSE)
-             && OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_WMM_INUSED))
-            || ((pAd->StaActive.SupportedPhyInfo.bHtEnable == TRUE)
-                && (pAd->CommonCfg.BACapability.field.Policy == BA_NOTUSE)))) {
-               RTMP_IO_READ32(pAd, EDCA_AC0_CFG, &Data);
-               Data &= 0xFFFFFF00;
-               RTMP_IO_WRITE32(pAd, EDCA_AC0_CFG, Data);
-
-               RTMP_IO_WRITE32(pAd, PBF_MAX_PCNT, 0x1F3F7F9F);
-               DBGPRINT(RT_DEBUG_TRACE, ("Txburst 1\n"));
-       } else if (pAd->CommonCfg.bEnableTxBurst) {
-               RTMP_IO_READ32(pAd, EDCA_AC0_CFG, &Data);
-               Data &= 0xFFFFFF00;
-               Data |= 0x60;
-               RTMP_IO_WRITE32(pAd, EDCA_AC0_CFG, Data);
-               pAd->CommonCfg.IOTestParm.bNowAtherosBurstOn = TRUE;
-
-               RTMP_IO_WRITE32(pAd, PBF_MAX_PCNT, 0x1F3FBF9F);
-               DBGPRINT(RT_DEBUG_TRACE, ("Txburst 2\n"));
-       } else {
-               RTMP_IO_READ32(pAd, EDCA_AC0_CFG, &Data);
-               Data &= 0xFFFFFF00;
-               RTMP_IO_WRITE32(pAd, EDCA_AC0_CFG, Data);
-
-               RTMP_IO_WRITE32(pAd, PBF_MAX_PCNT, 0x1F3F7F9F);
-               DBGPRINT(RT_DEBUG_TRACE, ("Txburst 3\n"));
-       }
-
-       /* Re-check to turn on TX burst or not. */
-       if ((pAd->CommonCfg.IOTestParm.bLastAtheros == TRUE)
-           && ((STA_WEP_ON(pAd)) || (STA_TKIP_ON(pAd)))) {
-               pAd->CommonCfg.IOTestParm.bNextDisableRxBA = TRUE;
-               if (pAd->CommonCfg.bEnableTxBurst) {
-                       u32 MACValue = 0;
-                       /* Force disable  TXOP value in this case. The same action in MLMEUpdateProtect too. */
-                       /* I didn't change PBF_MAX_PCNT setting. */
-                       RTMP_IO_READ32(pAd, EDCA_AC0_CFG, &MACValue);
-                       MACValue &= 0xFFFFFF00;
-                       RTMP_IO_WRITE32(pAd, EDCA_AC0_CFG, MACValue);
-                       pAd->CommonCfg.IOTestParm.bNowAtherosBurstOn = FALSE;
-               }
-       } else {
-               pAd->CommonCfg.IOTestParm.bNextDisableRxBA = FALSE;
-       }
-
-       pAd->CommonCfg.IOTestParm.bLastAtheros = FALSE;
-       COPY_MAC_ADDR(pAd->CommonCfg.LastBssid, pAd->CommonCfg.Bssid);
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("pAd->bNextDisableRxBA= %d \n",
-                 pAd->CommonCfg.IOTestParm.bNextDisableRxBA));
-       /* BSSID add in one MAC entry too.  Because in Tx, ASIC need to check Cipher and IV/EIV, BAbitmap */
-       /* Pther information in MACTab.Content[BSSID_WCID] is not necessary for driver. */
-       /* Note: As STA, The MACTab.Content[BSSID_WCID]. PairwiseKey and Shared Key for BSS0 are the same. */
-
-       if (pAd->StaCfg.WepStatus <= Ndis802_11WEPDisabled) {
-               if (pAd->StaCfg.WpaSupplicantUP &&
-                   (pAd->StaCfg.WepStatus == Ndis802_11WEPEnabled) &&
-                   (pAd->StaCfg.IEEE8021X == TRUE)) ;
-               else {
-                       pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
-                       pAd->StaCfg.PrivacyFilter =
-                           Ndis802_11PrivFilterAcceptAll;
-               }
-       }
-
-       NdisAcquireSpinLock(&pAd->MacTabLock);
-       pEntry->PortSecured = pAd->StaCfg.PortSecured;
-       NdisReleaseSpinLock(&pAd->MacTabLock);
-
-       /* */
-       /* Patch Atheros AP TX will breakdown issue. */
-       /* AP Model: DLink DWL-8200AP */
-       /* */
-       if (INFRA_ON(pAd) && OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_WMM_INUSED)
-           && STA_TKIP_ON(pAd)) {
-               RTMP_IO_WRITE32(pAd, RX_PARSER_CFG, 0x01);
-       } else {
-               RTMP_IO_WRITE32(pAd, RX_PARSER_CFG, 0x00);
-       }
-
-       RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS);
-
-       RTMP_CLEAR_PSFLAG(pAd, fRTMP_PS_GO_TO_SLEEP_NOW);
-}
-
-/*
-       ==========================================================================
-
-       Routine Description:
-               Disconnect current BSSID
-
-       Arguments:
-               pAd                             - Pointer to our adapter
-               IsReqFromAP             - Request from AP
-
-       Return Value:
-               None
-
-       IRQL = DISPATCH_LEVEL
-
-       Note:
-               We need more information to know it's this requst from AP.
-               If yes! we need to do extra handling, for example, remove the WPA key.
-               Otherwise on 4-way handshaking will fail, since the WPA key didn't get
-               removed while auto reconnect.
-               Disconnect request from AP, it means we will start afresh 4-way handshaking
-               on WPA mode.
-
-       ==========================================================================
-*/
-void LinkDown(struct rt_rtmp_adapter *pAd, IN BOOLEAN IsReqFromAP)
-{
-       u8 i, ByteValue = 0;
-
-       /* Do nothing if monitor mode is on */
-       if (MONITOR_ON(pAd))
-               return;
-
-       RTMP_CLEAR_PSFLAG(pAd, fRTMP_PS_GO_TO_SLEEP_NOW);
-       /* Comment the codes, because the line 2291 call the same function. */
-       /* RTMPCancelTimer(&pAd->Mlme.PsPollTimer, &Cancelled); */
-       /* Not allowed go to sleep within the linkdown function. */
-       RTMP_CLEAR_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
-
-       if (pAd->CommonCfg.bWirelessEvent) {
-               RTMPSendWirelessEvent(pAd, IW_STA_LINKDOWN_EVENT_FLAG,
-                                     pAd->MacTab.Content[BSSID_WCID].Addr,
-                                     BSS0, 0);
-       }
-
-       DBGPRINT(RT_DEBUG_TRACE, ("LINK DOWN!\n"));
-       OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_AGGREGATION_INUSED);
-
-#ifdef RTMP_MAC_PCI
-       if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_PCIE_DEVICE)) {
-               BOOLEAN Cancelled;
-               pAd->Mlme.bPsPollTimerRunning = FALSE;
-               RTMPCancelTimer(&pAd->Mlme.PsPollTimer, &Cancelled);
-       }
-
-       pAd->bPCIclkOff = FALSE;
-#endif /* RTMP_MAC_PCI // */
-
-       if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE)
-           || RTMP_TEST_PSFLAG(pAd, fRTMP_PS_SET_PCI_CLK_OFF_COMMAND)
-           || RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_IDLE_RADIO_OFF)) {
-               AUTO_WAKEUP_STRUC AutoWakeupCfg;
-               AsicForceWakeup(pAd, TRUE);
-               AutoWakeupCfg.word = 0;
-               RTMP_IO_WRITE32(pAd, AUTO_WAKEUP_CFG, AutoWakeupCfg.word);
-               OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_DOZE);
-       }
-#ifdef RTMP_MAC_PCI
-       pAd->bPCIclkOff = FALSE;
-#endif /* RTMP_MAC_PCI // */
-
-       if (ADHOC_ON(pAd))      /* Adhoc mode link down */
-       {
-               DBGPRINT(RT_DEBUG_TRACE, ("LINK DOWN 1!\n"));
-
-               OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_ADHOC_ON);
-               OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED);
-               pAd->IndicateMediaState = NdisMediaStateDisconnected;
-               RTMP_IndicateMediaState(pAd);
-               pAd->ExtraInfo = GENERAL_LINK_DOWN;
-               BssTableDeleteEntry(&pAd->ScanTab, pAd->CommonCfg.Bssid,
-                                   pAd->CommonCfg.Channel);
-               DBGPRINT(RT_DEBUG_TRACE,
-                        (" MacTab.Size=%d !\n", pAd->MacTab.Size));
-       } else                  /* Infra structure mode */
-       {
-               DBGPRINT(RT_DEBUG_TRACE, ("LINK DOWN 2!\n"));
-
-               OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_INFRA_ON);
-               OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED);
-
-               /* Saved last SSID for linkup comparison */
-               pAd->CommonCfg.LastSsidLen = pAd->CommonCfg.SsidLen;
-               NdisMoveMemory(pAd->CommonCfg.LastSsid, pAd->CommonCfg.Ssid,
-                              pAd->CommonCfg.LastSsidLen);
-               COPY_MAC_ADDR(pAd->CommonCfg.LastBssid, pAd->CommonCfg.Bssid);
-               if (pAd->MlmeAux.CurrReqIsFromNdis == TRUE) {
-                       pAd->IndicateMediaState = NdisMediaStateDisconnected;
-                       RTMP_IndicateMediaState(pAd);
-                       pAd->ExtraInfo = GENERAL_LINK_DOWN;
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("NDIS_STATUS_MEDIA_DISCONNECT Event A!\n"));
-                       pAd->MlmeAux.CurrReqIsFromNdis = FALSE;
-               } else {
-                       /* */
-                       /* If disassociation request is from NDIS, then we don't need to delete BSSID from entry. */
-                       /* Otherwise lost beacon or receive De-Authentication from AP, */
-                       /* then we should delete BSSID from BssTable. */
-                       /* If we don't delete from entry, roaming will fail. */
-                       /* */
-                       BssTableDeleteEntry(&pAd->ScanTab, pAd->CommonCfg.Bssid,
-                                           pAd->CommonCfg.Channel);
-               }
-
-               /* restore back to - */
-               /*      1. long slot (20 us) or short slot (9 us) time */
-               /*      2. turn on/off RTS/CTS and/or CTS-to-self protection */
-               /*      3. short preamble */
-               OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_BG_PROTECTION_INUSED);
-
-       }
-
-       for (i = 1; i < MAX_LEN_OF_MAC_TABLE; i++) {
-               if (pAd->MacTab.Content[i].ValidAsCLI == TRUE)
-                       MacTableDeleteEntry(pAd, pAd->MacTab.Content[i].Aid,
-                                           pAd->MacTab.Content[i].Addr);
-       }
-
-       AsicSetSlotTime(pAd, TRUE);     /*FALSE); */
-       AsicSetEdcaParm(pAd, NULL);
-
-       /* Set LED */
-       RTMPSetLED(pAd, LED_LINK_DOWN);
-       pAd->LedIndicatorStrength = 0xF0;
-       RTMPSetSignalLED(pAd, -100);    /* Force signal strength Led to be turned off, firmware has not done it. */
-
-       AsicDisableSync(pAd);
-
-       pAd->Mlme.PeriodicRound = 0;
-       pAd->Mlme.OneSecPeriodicRound = 0;
-
-       if (pAd->StaCfg.BssType == BSS_INFRA) {
-               /* Remove StaCfg Information after link down */
-               NdisZeroMemory(pAd->CommonCfg.Bssid, MAC_ADDR_LEN);
-               NdisZeroMemory(pAd->CommonCfg.Ssid, MAX_LEN_OF_SSID);
-               pAd->CommonCfg.SsidLen = 0;
-       }
-
-       NdisZeroMemory(&pAd->MlmeAux.HtCapability, sizeof(struct rt_ht_capability_ie));
-       NdisZeroMemory(&pAd->MlmeAux.AddHtInfo, sizeof(struct rt_add_ht_info_ie));
-       pAd->MlmeAux.HtCapabilityLen = 0;
-       pAd->MlmeAux.NewExtChannelOffset = 0xff;
-
-       /* Reset WPA-PSK state. Only reset when supplicant enabled */
-       if (pAd->StaCfg.WpaState != SS_NOTUSE) {
-               pAd->StaCfg.WpaState = SS_START;
-               /* Clear Replay counter */
-               NdisZeroMemory(pAd->StaCfg.ReplayCounter, 8);
-
-       }
-       /* */
-       /* if link down come from AP, we need to remove all WPA keys on WPA mode. */
-       /* otherwise will cause 4-way handshaking failed, since the WPA key not empty. */
-       /* */
-       if ((IsReqFromAP) && (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)) {
-               /* Remove all WPA keys */
-               RTMPWPARemoveAllKeys(pAd);
-       }
-       /* 802.1x port control */
-
-       /* Prevent clear PortSecured here with static WEP */
-       /* NetworkManger set security policy first then set SSID to connect AP. */
-       if (pAd->StaCfg.WpaSupplicantUP &&
-           (pAd->StaCfg.WepStatus == Ndis802_11WEPEnabled) &&
-           (pAd->StaCfg.IEEE8021X == FALSE)) {
-               pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
-       } else {
-               pAd->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
-               pAd->StaCfg.PrivacyFilter = Ndis802_11PrivFilter8021xWEP;
-       }
-
-       NdisAcquireSpinLock(&pAd->MacTabLock);
-       NdisZeroMemory(&pAd->MacTab, sizeof(struct rt_mac_table));
-       pAd->MacTab.Content[BSSID_WCID].PortSecured = pAd->StaCfg.PortSecured;
-       NdisReleaseSpinLock(&pAd->MacTabLock);
-
-       pAd->StaCfg.MicErrCnt = 0;
-
-       pAd->IndicateMediaState = NdisMediaStateDisconnected;
-       /* Update extra information to link is up */
-       pAd->ExtraInfo = GENERAL_LINK_DOWN;
-
-       pAd->StaActive.SupportedPhyInfo.bHtEnable = FALSE;
-
-#ifdef RTMP_MAC_USB
-       pAd->bUsbTxBulkAggre = FALSE;
-#endif /* RTMP_MAC_USB // */
-
-       /* Clean association information */
-       NdisZeroMemory(&pAd->StaCfg.AssocInfo,
-                      sizeof(struct rt_ndis_802_11_association_information));
-       pAd->StaCfg.AssocInfo.Length =
-           sizeof(struct rt_ndis_802_11_association_information);
-       pAd->StaCfg.ReqVarIELen = 0;
-       pAd->StaCfg.ResVarIELen = 0;
-
-       /* */
-       /* Reset RSSI value after link down */
-       /* */
-       pAd->StaCfg.RssiSample.AvgRssi0 = 0;
-       pAd->StaCfg.RssiSample.AvgRssi0X8 = 0;
-       pAd->StaCfg.RssiSample.AvgRssi1 = 0;
-       pAd->StaCfg.RssiSample.AvgRssi1X8 = 0;
-       pAd->StaCfg.RssiSample.AvgRssi2 = 0;
-       pAd->StaCfg.RssiSample.AvgRssi2X8 = 0;
-
-       /* Restore MlmeRate */
-       pAd->CommonCfg.MlmeRate = pAd->CommonCfg.BasicMlmeRate;
-       pAd->CommonCfg.RtsRate = pAd->CommonCfg.BasicMlmeRate;
-
-       /* */
-       /* After Link down, reset piggy-back setting in ASIC. Disable RDG. */
-       /* */
-       if (pAd->CommonCfg.BBPCurrentBW == BW_40) {
-               pAd->CommonCfg.BBPCurrentBW = BW_20;
-               RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &ByteValue);
-               ByteValue &= (~0x18);
-               RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, ByteValue);
-       }
-       /* Reset DAC */
-       RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R1, &ByteValue);
-       ByteValue &= (~0x18);
-       if (pAd->Antenna.field.TxPath == 2) {
-               ByteValue |= 0x10;
-       }
-       RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R1, ByteValue);
-
-       RTMPSetPiggyBack(pAd, FALSE);
-       OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_PIGGYBACK_INUSED);
-
-       pAd->CommonCfg.BACapability.word = pAd->CommonCfg.REGBACapability.word;
-
-       /* Restore all settings in the following. */
-       AsicUpdateProtect(pAd, 0,
-                         (ALLN_SETPROTECT | CCKSETPROTECT | OFDMSETPROTECT),
-                         TRUE, FALSE);
-       AsicDisableRDG(pAd);
-       pAd->CommonCfg.IOTestParm.bCurrentAtheros = FALSE;
-       pAd->CommonCfg.IOTestParm.bNowAtherosBurstOn = FALSE;
-
-       RTMP_IO_WRITE32(pAd, MAX_LEN_CFG, 0x1fff);
-       RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS);
-
-/* Allow go to sleep after linkdown steps. */
-       RTMP_SET_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
-
-       RtmpOSWrielessEventSend(pAd, SIOCGIWAP, -1, NULL, NULL, 0);
-
-#ifdef RT30xx
-       if ((IS_RT30xx(pAd) || IS_RT3090(pAd) || IS_RT3390(pAd))
-           && (pAd->Antenna.field.RxPath > 1 || pAd->Antenna.field.TxPath > 1)) {
-               RTMP_ASIC_MMPS_DISABLE(pAd);
-       }
-#endif /* RT30xx // */
-}
-
-/*
-       ==========================================================================
-       Description:
-
-       IRQL = DISPATCH_LEVEL
-
-       ==========================================================================
-*/
-void IterateOnBssTab(struct rt_rtmp_adapter *pAd)
-{
-       struct rt_mlme_start_req StartReq;
-       struct rt_mlme_join_req JoinReq;
-       unsigned long BssIdx;
-
-       /* Change the wepstatus to original wepstatus */
-       pAd->StaCfg.WepStatus = pAd->StaCfg.OrigWepStatus;
-       pAd->StaCfg.PairCipher = pAd->StaCfg.OrigWepStatus;
-       pAd->StaCfg.GroupCipher = pAd->StaCfg.OrigWepStatus;
-
-       BssIdx = pAd->MlmeAux.BssIdx;
-       if (BssIdx < pAd->MlmeAux.SsidBssTab.BssNr) {
-               /* Check cipher suite, AP must have more secured cipher than station setting */
-               /* Set the Pairwise and Group cipher to match the intended AP setting */
-               /* We can only connect to AP with less secured cipher setting */
-               if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA)
-                   || (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK)) {
-                       pAd->StaCfg.GroupCipher =
-                           pAd->MlmeAux.SsidBssTab.BssEntry[BssIdx].WPA.
-                           GroupCipher;
-
-                       if (pAd->StaCfg.WepStatus ==
-                           pAd->MlmeAux.SsidBssTab.BssEntry[BssIdx].WPA.
-                           PairCipher)
-                               pAd->StaCfg.PairCipher =
-                                   pAd->MlmeAux.SsidBssTab.BssEntry[BssIdx].
-                                   WPA.PairCipher;
-                       else if (pAd->MlmeAux.SsidBssTab.BssEntry[BssIdx].WPA.
-                                PairCipherAux != Ndis802_11WEPDisabled)
-                               pAd->StaCfg.PairCipher =
-                                   pAd->MlmeAux.SsidBssTab.BssEntry[BssIdx].
-                                   WPA.PairCipherAux;
-                       else    /* There is no PairCipher Aux, downgrade our capability to TKIP */
-                               pAd->StaCfg.PairCipher =
-                                   Ndis802_11Encryption2Enabled;
-               } else if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2)
-                          || (pAd->StaCfg.AuthMode ==
-                              Ndis802_11AuthModeWPA2PSK)) {
-                       pAd->StaCfg.GroupCipher =
-                           pAd->MlmeAux.SsidBssTab.BssEntry[BssIdx].WPA2.
-                           GroupCipher;
-
-                       if (pAd->StaCfg.WepStatus ==
-                           pAd->MlmeAux.SsidBssTab.BssEntry[BssIdx].WPA2.
-                           PairCipher)
-                               pAd->StaCfg.PairCipher =
-                                   pAd->MlmeAux.SsidBssTab.BssEntry[BssIdx].
-                                   WPA2.PairCipher;
-                       else if (pAd->MlmeAux.SsidBssTab.BssEntry[BssIdx].WPA2.
-                                PairCipherAux != Ndis802_11WEPDisabled)
-                               pAd->StaCfg.PairCipher =
-                                   pAd->MlmeAux.SsidBssTab.BssEntry[BssIdx].
-                                   WPA2.PairCipherAux;
-                       else    /* There is no PairCipher Aux, downgrade our capability to TKIP */
-                               pAd->StaCfg.PairCipher =
-                                   Ndis802_11Encryption2Enabled;
-
-                       /* RSN capability */
-                       pAd->StaCfg.RsnCapability =
-                           pAd->MlmeAux.SsidBssTab.BssEntry[BssIdx].WPA2.
-                           RsnCapability;
-               }
-               /* Set Mix cipher flag */
-               pAd->StaCfg.bMixCipher =
-                   (pAd->StaCfg.PairCipher ==
-                    pAd->StaCfg.GroupCipher) ? FALSE : TRUE;
-               /*if (pAd->StaCfg.bMixCipher == TRUE)
-                  {
-                  // If mix cipher, re-build RSNIE
-                  RTMPMakeRSNIE(pAd, pAd->StaCfg.AuthMode, pAd->StaCfg.WepStatus, 0);
-                  } */
-
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("CNTL - iterate BSS %ld of %d\n", BssIdx,
-                         pAd->MlmeAux.SsidBssTab.BssNr));
-               JoinParmFill(pAd, &JoinReq, BssIdx);
-               MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_MLME_JOIN_REQ,
-                           sizeof(struct rt_mlme_join_req), &JoinReq);
-               pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_JOIN;
-       } else if (pAd->StaCfg.BssType == BSS_ADHOC) {
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("CNTL - All BSS fail; start a new ADHOC (Ssid=%s)...\n",
-                         pAd->MlmeAux.Ssid));
-               StartParmFill(pAd, &StartReq, (char *)pAd->MlmeAux.Ssid,
-                             pAd->MlmeAux.SsidLen);
-               MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_MLME_START_REQ,
-                           sizeof(struct rt_mlme_start_req), &StartReq);
-               pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_START;
-       } else                  /* no more BSS */
-       {
-
-               {
-                       AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE);
-                       AsicLockChannel(pAd, pAd->CommonCfg.Channel);
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("CNTL - All roaming failed, restore to channel %d, Total BSS[%02d]\n",
-                                 pAd->CommonCfg.Channel, pAd->ScanTab.BssNr));
-               }
-
-               pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
-       }
-}
-
-/* for re-association only */
-/* IRQL = DISPATCH_LEVEL */
-void IterateOnBssTab2(struct rt_rtmp_adapter *pAd)
-{
-       struct rt_mlme_assoc_req ReassocReq;
-       unsigned long BssIdx;
-       struct rt_bss_entry *pBss;
-
-       BssIdx = pAd->MlmeAux.RoamIdx;
-       pBss = &pAd->MlmeAux.RoamTab.BssEntry[BssIdx];
-
-       if (BssIdx < pAd->MlmeAux.RoamTab.BssNr) {
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("CNTL - iterate BSS %ld of %d\n", BssIdx,
-                         pAd->MlmeAux.RoamTab.BssNr));
-
-               AsicSwitchChannel(pAd, pBss->Channel, FALSE);
-               AsicLockChannel(pAd, pBss->Channel);
-
-               /* reassociate message has the same structure as associate message */
-               AssocParmFill(pAd, &ReassocReq, pBss->Bssid,
-                             pBss->CapabilityInfo, ASSOC_TIMEOUT,
-                             pAd->StaCfg.DefaultListenCount);
-               MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_MLME_REASSOC_REQ,
-                           sizeof(struct rt_mlme_assoc_req), &ReassocReq);
-
-               pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_REASSOC;
-       } else                  /* no more BSS */
-       {
-
-               {
-                       AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE);
-                       AsicLockChannel(pAd, pAd->CommonCfg.Channel);
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("CNTL - All roaming failed, restore to channel %d, Total BSS[%02d]\n",
-                                 pAd->CommonCfg.Channel, pAd->ScanTab.BssNr));
-               }
-
-               pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
-       }
-}
-
-/*
-       ==========================================================================
-       Description:
-
-       IRQL = DISPATCH_LEVEL
-
-       ==========================================================================
-*/
-void JoinParmFill(struct rt_rtmp_adapter *pAd,
-                 struct rt_mlme_join_req *JoinReq, unsigned long BssIdx)
-{
-       JoinReq->BssIdx = BssIdx;
-}
-
-/*
-       ==========================================================================
-       Description:
-
-       IRQL = DISPATCH_LEVEL
-
-       ==========================================================================
-*/
-void ScanParmFill(struct rt_rtmp_adapter *pAd,
-                 struct rt_mlme_scan_req *ScanReq,
-                 char Ssid[],
-                 u8 SsidLen, u8 BssType, u8 ScanType)
-{
-       NdisZeroMemory(ScanReq->Ssid, MAX_LEN_OF_SSID);
-       ScanReq->SsidLen = SsidLen;
-       NdisMoveMemory(ScanReq->Ssid, Ssid, SsidLen);
-       ScanReq->BssType = BssType;
-       ScanReq->ScanType = ScanType;
-}
-
-/*
-       ==========================================================================
-       Description:
-
-       IRQL = DISPATCH_LEVEL
-
-       ==========================================================================
-*/
-void StartParmFill(struct rt_rtmp_adapter *pAd,
-                  struct rt_mlme_start_req *StartReq,
-                  char Ssid[], u8 SsidLen)
-{
-       ASSERT(SsidLen <= MAX_LEN_OF_SSID);
-       NdisMoveMemory(StartReq->Ssid, Ssid, SsidLen);
-       StartReq->SsidLen = SsidLen;
-}
-
-/*
-       ==========================================================================
-       Description:
-
-       IRQL = DISPATCH_LEVEL
-
-       ==========================================================================
-*/
-void AuthParmFill(struct rt_rtmp_adapter *pAd,
-                 struct rt_mlme_auth_req *AuthReq,
-                 u8 *pAddr, u16 Alg)
-{
-       COPY_MAC_ADDR(AuthReq->Addr, pAddr);
-       AuthReq->Alg = Alg;
-       AuthReq->Timeout = AUTH_TIMEOUT;
-}
-
-/*
-       ==========================================================================
-       Description:
-
-       IRQL = DISPATCH_LEVEL
-
-       ==========================================================================
- */
-#ifdef RTMP_MAC_PCI
-void ComposePsPoll(struct rt_rtmp_adapter *pAd)
-{
-       NdisZeroMemory(&pAd->PsPollFrame, sizeof(struct rt_pspoll_frame));
-       pAd->PsPollFrame.FC.Type = BTYPE_CNTL;
-       pAd->PsPollFrame.FC.SubType = SUBTYPE_PS_POLL;
-       pAd->PsPollFrame.Aid = pAd->StaActive.Aid | 0xC000;
-       COPY_MAC_ADDR(pAd->PsPollFrame.Bssid, pAd->CommonCfg.Bssid);
-       COPY_MAC_ADDR(pAd->PsPollFrame.Ta, pAd->CurrentAddress);
-}
-
-/* IRQL = DISPATCH_LEVEL */
-void ComposeNullFrame(struct rt_rtmp_adapter *pAd)
-{
-       NdisZeroMemory(&pAd->NullFrame, sizeof(struct rt_header_802_11));
-       pAd->NullFrame.FC.Type = BTYPE_DATA;
-       pAd->NullFrame.FC.SubType = SUBTYPE_NULL_FUNC;
-       pAd->NullFrame.FC.ToDs = 1;
-       COPY_MAC_ADDR(pAd->NullFrame.Addr1, pAd->CommonCfg.Bssid);
-       COPY_MAC_ADDR(pAd->NullFrame.Addr2, pAd->CurrentAddress);
-       COPY_MAC_ADDR(pAd->NullFrame.Addr3, pAd->CommonCfg.Bssid);
-}
-#endif /* RTMP_MAC_PCI // */
-#ifdef RTMP_MAC_USB
-void MlmeCntlConfirm(struct rt_rtmp_adapter *pAd, unsigned long MsgType, u16 Msg)
-{
-       MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MsgType, sizeof(u16),
-                   &Msg);
-}
-
-void ComposePsPoll(struct rt_rtmp_adapter *pAd)
-{
-       struct rt_txinfo *pTxInfo;
-       struct rt_txwi * pTxWI;
-
-       DBGPRINT(RT_DEBUG_TRACE, ("ComposePsPoll\n"));
-       NdisZeroMemory(&pAd->PsPollFrame, sizeof(struct rt_pspoll_frame));
-
-       pAd->PsPollFrame.FC.PwrMgmt = 0;
-       pAd->PsPollFrame.FC.Type = BTYPE_CNTL;
-       pAd->PsPollFrame.FC.SubType = SUBTYPE_PS_POLL;
-       pAd->PsPollFrame.Aid = pAd->StaActive.Aid | 0xC000;
-       COPY_MAC_ADDR(pAd->PsPollFrame.Bssid, pAd->CommonCfg.Bssid);
-       COPY_MAC_ADDR(pAd->PsPollFrame.Ta, pAd->CurrentAddress);
-
-       RTMPZeroMemory(&pAd->PsPollContext.TransferBuffer->field.
-                      WirelessPacket[0], 100);
-       pTxInfo =
-           (struct rt_txinfo *)& pAd->PsPollContext.TransferBuffer->field.
-           WirelessPacket[0];
-       RTMPWriteTxInfo(pAd, pTxInfo,
-                       (u16)(sizeof(struct rt_pspoll_frame) + TXWI_SIZE), TRUE,
-                       EpToQueue[MGMTPIPEIDX], FALSE, FALSE);
-       pTxWI =
-           (struct rt_txwi *) & pAd->PsPollContext.TransferBuffer->field.
-           WirelessPacket[TXINFO_SIZE];
-       RTMPWriteTxWI(pAd, pTxWI, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, 0,
-                     BSSID_WCID, (sizeof(struct rt_pspoll_frame)), 0, 0,
-                     (u8)pAd->CommonCfg.MlmeTransmit.field.MCS,
-                     IFS_BACKOFF, FALSE, &pAd->CommonCfg.MlmeTransmit);
-       RTMPMoveMemory(&pAd->PsPollContext.TransferBuffer->field.
-                      WirelessPacket[TXWI_SIZE + TXINFO_SIZE],
-                      &pAd->PsPollFrame, sizeof(struct rt_pspoll_frame));
-       /* Append 4 extra zero bytes. */
-       pAd->PsPollContext.BulkOutSize =
-           TXINFO_SIZE + TXWI_SIZE + sizeof(struct rt_pspoll_frame) + 4;
-}
-
-/* IRQL = DISPATCH_LEVEL */
-void ComposeNullFrame(struct rt_rtmp_adapter *pAd)
-{
-       struct rt_txinfo *pTxInfo;
-       struct rt_txwi * pTxWI;
-
-       NdisZeroMemory(&pAd->NullFrame, sizeof(struct rt_header_802_11));
-       pAd->NullFrame.FC.Type = BTYPE_DATA;
-       pAd->NullFrame.FC.SubType = SUBTYPE_NULL_FUNC;
-       pAd->NullFrame.FC.ToDs = 1;
-       COPY_MAC_ADDR(pAd->NullFrame.Addr1, pAd->CommonCfg.Bssid);
-       COPY_MAC_ADDR(pAd->NullFrame.Addr2, pAd->CurrentAddress);
-       COPY_MAC_ADDR(pAd->NullFrame.Addr3, pAd->CommonCfg.Bssid);
-       RTMPZeroMemory(&pAd->NullContext.TransferBuffer->field.
-                      WirelessPacket[0], 100);
-       pTxInfo =
-           (struct rt_txinfo *)& pAd->NullContext.TransferBuffer->field.
-           WirelessPacket[0];
-       RTMPWriteTxInfo(pAd, pTxInfo,
-                       (u16)(sizeof(struct rt_header_802_11) + TXWI_SIZE), TRUE,
-                       EpToQueue[MGMTPIPEIDX], FALSE, FALSE);
-       pTxWI =
-           (struct rt_txwi *) & pAd->NullContext.TransferBuffer->field.
-           WirelessPacket[TXINFO_SIZE];
-       RTMPWriteTxWI(pAd, pTxWI, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, 0,
-                     BSSID_WCID, (sizeof(struct rt_header_802_11)), 0, 0,
-                     (u8)pAd->CommonCfg.MlmeTransmit.field.MCS,
-                     IFS_BACKOFF, FALSE, &pAd->CommonCfg.MlmeTransmit);
-       RTMPMoveMemory(&pAd->NullContext.TransferBuffer->field.
-                      WirelessPacket[TXWI_SIZE + TXINFO_SIZE], &pAd->NullFrame,
-                      sizeof(struct rt_header_802_11));
-       pAd->NullContext.BulkOutSize =
-           TXINFO_SIZE + TXWI_SIZE + sizeof(pAd->NullFrame) + 4;
-}
-#endif /* RTMP_MAC_USB // */
-
-/*
-       ==========================================================================
-       Description:
-               Pre-build a BEACON frame in the shared memory
-
-       IRQL = PASSIVE_LEVEL
-       IRQL = DISPATCH_LEVEL
-
-       ==========================================================================
-*/
-unsigned long MakeIbssBeacon(struct rt_rtmp_adapter *pAd)
-{
-       u8 DsLen = 1, IbssLen = 2;
-       u8 LocalErpIe[3] = { IE_ERP, 1, 0x04 };
-       struct rt_header_802_11 BcnHdr;
-       u16 CapabilityInfo;
-       LARGE_INTEGER FakeTimestamp;
-       unsigned long FrameLen = 0;
-       struct rt_txwi * pTxWI = &pAd->BeaconTxWI;
-       u8 *pBeaconFrame = pAd->BeaconBuf;
-       BOOLEAN Privacy;
-       u8 SupRate[MAX_LEN_OF_SUPPORTED_RATES];
-       u8 SupRateLen = 0;
-       u8 ExtRate[MAX_LEN_OF_SUPPORTED_RATES];
-       u8 ExtRateLen = 0;
-       u8 RSNIe = IE_WPA;
-
-       if ((pAd->CommonCfg.PhyMode == PHY_11B)
-           && (pAd->CommonCfg.Channel <= 14)) {
-               SupRate[0] = 0x82;      /* 1 mbps */
-               SupRate[1] = 0x84;      /* 2 mbps */
-               SupRate[2] = 0x8b;      /* 5.5 mbps */
-               SupRate[3] = 0x96;      /* 11 mbps */
-               SupRateLen = 4;
-               ExtRateLen = 0;
-       } else if (pAd->CommonCfg.Channel > 14) {
-               SupRate[0] = 0x8C;      /* 6 mbps, in units of 0.5 Mbps, basic rate */
-               SupRate[1] = 0x12;      /* 9 mbps, in units of 0.5 Mbps */
-               SupRate[2] = 0x98;      /* 12 mbps, in units of 0.5 Mbps, basic rate */
-               SupRate[3] = 0x24;      /* 18 mbps, in units of 0.5 Mbps */
-               SupRate[4] = 0xb0;      /* 24 mbps, in units of 0.5 Mbps, basic rate */
-               SupRate[5] = 0x48;      /* 36 mbps, in units of 0.5 Mbps */
-               SupRate[6] = 0x60;      /* 48 mbps, in units of 0.5 Mbps */
-               SupRate[7] = 0x6c;      /* 54 mbps, in units of 0.5 Mbps */
-               SupRateLen = 8;
-               ExtRateLen = 0;
-
-               /* */
-               /* Also Update MlmeRate & RtsRate for G only & A only */
-               /* */
-               pAd->CommonCfg.MlmeRate = RATE_6;
-               pAd->CommonCfg.RtsRate = RATE_6;
-               pAd->CommonCfg.MlmeTransmit.field.MODE = MODE_OFDM;
-               pAd->CommonCfg.MlmeTransmit.field.MCS =
-                   OfdmRateToRxwiMCS[pAd->CommonCfg.MlmeRate];
-               pAd->MacTab.Content[BSS0Mcast_WCID].HTPhyMode.field.MODE =
-                   MODE_OFDM;
-               pAd->MacTab.Content[BSS0Mcast_WCID].HTPhyMode.field.MCS =
-                   OfdmRateToRxwiMCS[pAd->CommonCfg.MlmeRate];
-       } else {
-               SupRate[0] = 0x82;      /* 1 mbps */
-               SupRate[1] = 0x84;      /* 2 mbps */
-               SupRate[2] = 0x8b;      /* 5.5 mbps */
-               SupRate[3] = 0x96;      /* 11 mbps */
-               SupRateLen = 4;
-
-               ExtRate[0] = 0x0C;      /* 6 mbps, in units of 0.5 Mbps, */
-               ExtRate[1] = 0x12;      /* 9 mbps, in units of 0.5 Mbps */
-               ExtRate[2] = 0x18;      /* 12 mbps, in units of 0.5 Mbps, */
-               ExtRate[3] = 0x24;      /* 18 mbps, in units of 0.5 Mbps */
-               ExtRate[4] = 0x30;      /* 24 mbps, in units of 0.5 Mbps, */
-               ExtRate[5] = 0x48;      /* 36 mbps, in units of 0.5 Mbps */
-               ExtRate[6] = 0x60;      /* 48 mbps, in units of 0.5 Mbps */
-               ExtRate[7] = 0x6c;      /* 54 mbps, in units of 0.5 Mbps */
-               ExtRateLen = 8;
-       }
-
-       pAd->StaActive.SupRateLen = SupRateLen;
-       NdisMoveMemory(pAd->StaActive.SupRate, SupRate, SupRateLen);
-       pAd->StaActive.ExtRateLen = ExtRateLen;
-       NdisMoveMemory(pAd->StaActive.ExtRate, ExtRate, ExtRateLen);
-
-       /* compose IBSS beacon frame */
-       MgtMacHeaderInit(pAd, &BcnHdr, SUBTYPE_BEACON, 0, BROADCAST_ADDR,
-                        pAd->CommonCfg.Bssid);
-       Privacy = (pAd->StaCfg.WepStatus == Ndis802_11Encryption1Enabled)
-           || (pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled)
-           || (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled);
-       CapabilityInfo =
-           CAP_GENERATE(0, 1, Privacy,
-                        (pAd->CommonCfg.TxPreamble == Rt802_11PreambleShort),
-                        0, 0);
-
-       MakeOutgoingFrame(pBeaconFrame, &FrameLen,
-                         sizeof(struct rt_header_802_11), &BcnHdr,
-                         TIMESTAMP_LEN, &FakeTimestamp,
-                         2, &pAd->CommonCfg.BeaconPeriod,
-                         2, &CapabilityInfo,
-                         1, &SsidIe,
-                         1, &pAd->CommonCfg.SsidLen,
-                         pAd->CommonCfg.SsidLen, pAd->CommonCfg.Ssid,
-                         1, &SupRateIe,
-                         1, &SupRateLen,
-                         SupRateLen, SupRate,
-                         1, &DsIe,
-                         1, &DsLen,
-                         1, &pAd->CommonCfg.Channel,
-                         1, &IbssIe,
-                         1, &IbssLen, 2, &pAd->StaActive.AtimWin, END_OF_ARGS);
-
-       /* add ERP_IE and EXT_RAE IE of in 802.11g */
-       if (ExtRateLen) {
-               unsigned long tmp;
-
-               MakeOutgoingFrame(pBeaconFrame + FrameLen, &tmp,
-                                 3, LocalErpIe,
-                                 1, &ExtRateIe,
-                                 1, &ExtRateLen,
-                                 ExtRateLen, ExtRate, END_OF_ARGS);
-               FrameLen += tmp;
-       }
-       /* If adhoc secruity is set for WPA-None, append the cipher suite IE */
-       if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone) {
-               unsigned long tmp;
-               RTMPMakeRSNIE(pAd, pAd->StaCfg.AuthMode, pAd->StaCfg.WepStatus,
-                             BSS0);
-
-               MakeOutgoingFrame(pBeaconFrame + FrameLen, &tmp,
-                                 1, &RSNIe,
-                                 1, &pAd->StaCfg.RSNIE_Len,
-                                 pAd->StaCfg.RSNIE_Len, pAd->StaCfg.RSN_IE,
-                                 END_OF_ARGS);
-               FrameLen += tmp;
-       }
-
-       if ((pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)) {
-               unsigned long TmpLen;
-               u8 HtLen, HtLen1;
-
-               /* add HT Capability IE */
-               HtLen = sizeof(pAd->CommonCfg.HtCapability);
-               HtLen1 = sizeof(pAd->CommonCfg.AddHTInfo);
-
-               MakeOutgoingFrame(pBeaconFrame + FrameLen, &TmpLen,
-                                 1, &HtCapIe,
-                                 1, &HtLen,
-                                 HtLen, &pAd->CommonCfg.HtCapability,
-                                 1, &AddHtInfoIe,
-                                 1, &HtLen1,
-                                 HtLen1, &pAd->CommonCfg.AddHTInfo,
-                                 END_OF_ARGS);
-
-               FrameLen += TmpLen;
-       }
-       /*beacon use reserved WCID 0xff */
-       if (pAd->CommonCfg.Channel > 14) {
-               RTMPWriteTxWI(pAd, pTxWI, FALSE, FALSE, TRUE, FALSE, FALSE,
-                             TRUE, 0, 0xff, FrameLen, PID_MGMT, PID_BEACON,
-                             RATE_1, IFS_HTTXOP, FALSE,
-                             &pAd->CommonCfg.MlmeTransmit);
-       } else {
-               /* Set to use 1Mbps for Adhoc beacon. */
-               HTTRANSMIT_SETTING Transmit;
-               Transmit.word = 0;
-               RTMPWriteTxWI(pAd, pTxWI, FALSE, FALSE, TRUE, FALSE, FALSE,
-                             TRUE, 0, 0xff, FrameLen, PID_MGMT, PID_BEACON,
-                             RATE_1, IFS_HTTXOP, FALSE, &Transmit);
-       }
-
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("MakeIbssBeacon (len=%ld), SupRateLen=%d, ExtRateLen=%d, Channel=%d, PhyMode=%d\n",
-                 FrameLen, SupRateLen, ExtRateLen, pAd->CommonCfg.Channel,
-                 pAd->CommonCfg.PhyMode));
-       return FrameLen;
-}
diff --git a/drivers/staging/rt2860/sta/rtmp_data.c b/drivers/staging/rt2860/sta/rtmp_data.c
deleted file mode 100644 (file)
index e82c6b6..0000000
+++ /dev/null
@@ -1,2552 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-       Module Name:
-       rtmp_data.c
-
-       Abstract:
-       Data path subroutines
-
-       Revision History:
-       Who                     When            What
-       Justin P. Mattock       11/07/2010      Fix typos
-       --------        ----------              ----------------------------------------------
-*/
-#include "../rt_config.h"
-#include <linux/kernel.h>
-
-void STARxEAPOLFrameIndicate(struct rt_rtmp_adapter *pAd,
-                            struct rt_mac_table_entry *pEntry,
-                            struct rt_rx_blk *pRxBlk, u8 FromWhichBSSID)
-{
-       PRT28XX_RXD_STRUC pRxD = &(pRxBlk->RxD);
-       struct rt_rxwi * pRxWI = pRxBlk->pRxWI;
-       u8 *pTmpBuf;
-
-       if (pAd->StaCfg.WpaSupplicantUP) {
-               /* All EAPoL frames have to pass to upper layer (ex. WPA_SUPPLICANT daemon) */
-               /* TBD : process fragmented EAPol frames */
-               {
-                       /* In 802.1x mode, if the received frame is EAP-SUCCESS packet, turn on the PortSecured variable */
-                       if (pAd->StaCfg.IEEE8021X == TRUE &&
-                           (EAP_CODE_SUCCESS ==
-                            WpaCheckEapCode(pAd, pRxBlk->pData,
-                                            pRxBlk->DataSize,
-                                            LENGTH_802_1_H))) {
-                               u8 *Key;
-                               u8 CipherAlg;
-                               int idx = 0;
-
-                               DBGPRINT_RAW(RT_DEBUG_TRACE,
-                                            ("Receive EAP-SUCCESS Packet\n"));
-                               /*pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED; */
-                               STA_PORT_SECURED(pAd);
-
-                               if (pAd->StaCfg.IEEE8021x_required_keys ==
-                                   FALSE) {
-                                       idx = pAd->StaCfg.DesireSharedKeyId;
-                                       CipherAlg =
-                                           pAd->StaCfg.DesireSharedKey[idx].
-                                           CipherAlg;
-                                       Key =
-                                           pAd->StaCfg.DesireSharedKey[idx].
-                                           Key;
-
-                                       if (pAd->StaCfg.DesireSharedKey[idx].
-                                           KeyLen > 0) {
-#ifdef RTMP_MAC_PCI
-                                               struct rt_mac_table_entry *pEntry =
-                                                   &pAd->MacTab.
-                                                   Content[BSSID_WCID];
-
-                                               /* Set key material and cipherAlg to Asic */
-                                               AsicAddSharedKeyEntry(pAd, BSS0,
-                                                                     idx,
-                                                                     CipherAlg,
-                                                                     Key, NULL,
-                                                                     NULL);
-
-                                               /* Assign group key info */
-                                               RTMPAddWcidAttributeEntry(pAd,
-                                                                         BSS0,
-                                                                         idx,
-                                                                         CipherAlg,
-                                                                         NULL);
-
-                                               /* Assign pairwise key info */
-                                               RTMPAddWcidAttributeEntry(pAd,
-                                                                         BSS0,
-                                                                         idx,
-                                                                         CipherAlg,
-                                                                         pEntry);
-
-                                               pAd->IndicateMediaState =
-                                                   NdisMediaStateConnected;
-                                               pAd->ExtraInfo =
-                                                   GENERAL_LINK_UP;
-#endif /* RTMP_MAC_PCI // */
-#ifdef RTMP_MAC_USB
-                                               union {
-                                                       char buf[sizeof
-                                                                (struct rt_ndis_802_11_wep)
-                                                                +
-                                                                MAX_LEN_OF_KEY
-                                                                - 1];
-                                                       struct rt_ndis_802_11_wep keyinfo;
-                                               }
-                                               WepKey;
-                                               int len;
-
-                                               NdisZeroMemory(&WepKey,
-                                                              sizeof(WepKey));
-                                               len =
-                                                   pAd->StaCfg.
-                                                   DesireSharedKey[idx].KeyLen;
-
-                                               NdisMoveMemory(WepKey.keyinfo.
-                                                              KeyMaterial,
-                                                              pAd->StaCfg.
-                                                              DesireSharedKey
-                                                              [idx].Key,
-                                                              pAd->StaCfg.
-                                                              DesireSharedKey
-                                                              [idx].KeyLen);
-
-                                               WepKey.keyinfo.KeyIndex =
-                                                   0x80000000 + idx;
-                                               WepKey.keyinfo.KeyLength = len;
-                                               pAd->SharedKey[BSS0][idx].
-                                                   KeyLen =
-                                                   (u8)(len <= 5 ? 5 : 13);
-
-                                               pAd->IndicateMediaState =
-                                                   NdisMediaStateConnected;
-                                               pAd->ExtraInfo =
-                                                   GENERAL_LINK_UP;
-                                               /* need to enqueue cmd to thread */
-                                               RTUSBEnqueueCmdFromNdis(pAd,
-                                                                       OID_802_11_ADD_WEP,
-                                                                       TRUE,
-                                                                       &WepKey,
-                                                                       sizeof
-                                                                       (WepKey.
-                                                                        keyinfo)
-                                                                       + len -
-                                                                       1);
-#endif /* RTMP_MAC_USB // */
-                                               /* For Preventing ShardKey Table is cleared by remove key procedure. */
-                                               pAd->SharedKey[BSS0][idx].
-                                                   CipherAlg = CipherAlg;
-                                               pAd->SharedKey[BSS0][idx].
-                                                   KeyLen =
-                                                   pAd->StaCfg.
-                                                   DesireSharedKey[idx].KeyLen;
-                                               NdisMoveMemory(pAd->
-                                                              SharedKey[BSS0]
-                                                              [idx].Key,
-                                                              pAd->StaCfg.
-                                                              DesireSharedKey
-                                                              [idx].Key,
-                                                              pAd->StaCfg.
-                                                              DesireSharedKey
-                                                              [idx].KeyLen);
-                                       }
-                               }
-                       }
-
-                       Indicate_Legacy_Packet(pAd, pRxBlk, FromWhichBSSID);
-                       return;
-               }
-       } else {
-               /* Special DATA frame that has to pass to MLME */
-               /*       1. Cisco Aironet frames for CCX2. We need pass it to MLME for special process */
-               /*       2. EAPOL handshaking frames when driver supplicant enabled, pass to MLME for special process */
-               {
-                       pTmpBuf = pRxBlk->pData - LENGTH_802_11;
-                       NdisMoveMemory(pTmpBuf, pRxBlk->pHeader, LENGTH_802_11);
-                       REPORT_MGMT_FRAME_TO_MLME(pAd, pRxWI->WirelessCliID,
-                                                 pTmpBuf,
-                                                 pRxBlk->DataSize +
-                                                 LENGTH_802_11, pRxWI->RSSI0,
-                                                 pRxWI->RSSI1, pRxWI->RSSI2,
-                                                 pRxD->PlcpSignal);
-                       DBGPRINT_RAW(RT_DEBUG_TRACE,
-                                    ("report EAPOL/AIRONET DATA to MLME (len=%d) !\n",
-                                     pRxBlk->DataSize));
-               }
-       }
-
-       RELEASE_NDIS_PACKET(pAd, pRxBlk->pRxPacket, NDIS_STATUS_FAILURE);
-       return;
-
-}
-
-void STARxDataFrameAnnounce(struct rt_rtmp_adapter *pAd,
-                           struct rt_mac_table_entry *pEntry,
-                           struct rt_rx_blk *pRxBlk, u8 FromWhichBSSID)
-{
-
-       /* non-EAP frame */
-       if (!RTMPCheckWPAframe
-           (pAd, pEntry, pRxBlk->pData, pRxBlk->DataSize, FromWhichBSSID)) {
-
-               {
-                       /* drop all non-EAP DATA frame before */
-                       /* this client's Port-Access-Control is secured */
-                       if (pRxBlk->pHeader->FC.Wep) {
-                               /* unsupported cipher suite */
-                               if (pAd->StaCfg.WepStatus ==
-                                   Ndis802_11EncryptionDisabled) {
-                                       /* release packet */
-                                       RELEASE_NDIS_PACKET(pAd,
-                                                           pRxBlk->pRxPacket,
-                                                           NDIS_STATUS_FAILURE);
-                                       return;
-                               }
-                       } else {
-                               /* encryption in-use but receive a non-EAPOL clear text frame, drop it */
-                               if ((pAd->StaCfg.WepStatus !=
-                                    Ndis802_11EncryptionDisabled)
-                                   && (pAd->StaCfg.PortSecured ==
-                                       WPA_802_1X_PORT_NOT_SECURED)) {
-                                       /* release packet */
-                                       RELEASE_NDIS_PACKET(pAd,
-                                                           pRxBlk->pRxPacket,
-                                                           NDIS_STATUS_FAILURE);
-                                       return;
-                               }
-                       }
-               }
-               RX_BLK_CLEAR_FLAG(pRxBlk, fRX_EAP);
-               if (!RX_BLK_TEST_FLAG(pRxBlk, fRX_ARALINK)) {
-                       /* Normal legacy, AMPDU or AMSDU */
-                       CmmRxnonRalinkFrameIndicate(pAd, pRxBlk,
-                                                   FromWhichBSSID);
-
-               } else {
-                       /* ARALINK */
-                       CmmRxRalinkFrameIndicate(pAd, pEntry, pRxBlk,
-                                                FromWhichBSSID);
-               }
-       } else {
-               RX_BLK_SET_FLAG(pRxBlk, fRX_EAP);
-
-               if (RX_BLK_TEST_FLAG(pRxBlk, fRX_AMPDU)
-                   && (pAd->CommonCfg.bDisableReordering == 0)) {
-                       Indicate_AMPDU_Packet(pAd, pRxBlk, FromWhichBSSID);
-               } else {
-                       /* Determine the destination of the EAP frame */
-                       /* to WPA state machine or upper layer */
-                       STARxEAPOLFrameIndicate(pAd, pEntry, pRxBlk,
-                                               FromWhichBSSID);
-               }
-       }
-}
-
-/* For TKIP frame, calculate the MIC value */
-BOOLEAN STACheckTkipMICValue(struct rt_rtmp_adapter *pAd,
-                            struct rt_mac_table_entry *pEntry, struct rt_rx_blk *pRxBlk)
-{
-       struct rt_header_802_11 * pHeader = pRxBlk->pHeader;
-       u8 *pData = pRxBlk->pData;
-       u16 DataSize = pRxBlk->DataSize;
-       u8 UserPriority = pRxBlk->UserPriority;
-       struct rt_cipher_key *pWpaKey;
-       u8 *pDA, *pSA;
-
-       pWpaKey = &pAd->SharedKey[BSS0][pRxBlk->pRxWI->KeyIndex];
-
-       pDA = pHeader->Addr1;
-       if (RX_BLK_TEST_FLAG(pRxBlk, fRX_INFRA)) {
-               pSA = pHeader->Addr3;
-       } else {
-               pSA = pHeader->Addr2;
-       }
-
-       if (RTMPTkipCompareMICValue(pAd,
-                                   pData,
-                                   pDA,
-                                   pSA,
-                                   pWpaKey->RxMic,
-                                   UserPriority, DataSize) == FALSE) {
-               DBGPRINT_RAW(RT_DEBUG_ERROR, ("Rx MIC Value error 2\n"));
-
-               if (pAd->StaCfg.WpaSupplicantUP) {
-                       WpaSendMicFailureToWpaSupplicant(pAd,
-                                                        (pWpaKey->Type ==
-                                                         PAIRWISEKEY) ? TRUE :
-                                                        FALSE);
-               } else {
-                       RTMPReportMicError(pAd, pWpaKey);
-               }
-
-               /* release packet */
-               RELEASE_NDIS_PACKET(pAd, pRxBlk->pRxPacket,
-                                   NDIS_STATUS_FAILURE);
-               return FALSE;
-       }
-
-       return TRUE;
-}
-
-/* */
-/* All Rx routines use struct rt_rx_blk structure to hande rx events */
-/* It is very important to build pRxBlk attributes */
-/*  1. pHeader pointer to 802.11 Header */
-/*  2. pData pointer to payload including LLC (just skip Header) */
-/*  3. set payload size including LLC to DataSize */
-/*  4. set some flags with RX_BLK_SET_FLAG() */
-/* */
-void STAHandleRxDataFrame(struct rt_rtmp_adapter *pAd, struct rt_rx_blk *pRxBlk)
-{
-       PRT28XX_RXD_STRUC pRxD = &(pRxBlk->RxD);
-       struct rt_rxwi * pRxWI = pRxBlk->pRxWI;
-       struct rt_header_802_11 * pHeader = pRxBlk->pHeader;
-       void *pRxPacket = pRxBlk->pRxPacket;
-       BOOLEAN bFragment = FALSE;
-       struct rt_mac_table_entry *pEntry = NULL;
-       u8 FromWhichBSSID = BSS0;
-       u8 UserPriority = 0;
-
-       {
-               /* before LINK UP, all DATA frames are rejected */
-               if (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED)) {
-                       /* release packet */
-                       RELEASE_NDIS_PACKET(pAd, pRxPacket,
-                                           NDIS_STATUS_FAILURE);
-                       return;
-               }
-               /* Drop not my BSS frames */
-               if (pRxD->MyBss == 0) {
-                       {
-                               /* release packet */
-                               RELEASE_NDIS_PACKET(pAd, pRxPacket,
-                                                   NDIS_STATUS_FAILURE);
-                               return;
-                       }
-               }
-
-               pAd->RalinkCounters.RxCountSinceLastNULL++;
-               if (pAd->CommonCfg.bAPSDCapable
-                   && pAd->CommonCfg.APEdcaParm.bAPSDCapable
-                   && (pHeader->FC.SubType & 0x08)) {
-                       u8 *pData;
-                       DBGPRINT(RT_DEBUG_INFO, ("bAPSDCapable\n"));
-
-                       /* Qos bit 4 */
-                       pData = (u8 *)pHeader + LENGTH_802_11;
-                       if ((*pData >> 4) & 0x01) {
-                               DBGPRINT(RT_DEBUG_INFO,
-                                        ("RxDone- Rcv EOSP frame, driver may fall into sleep\n"));
-                               pAd->CommonCfg.bInServicePeriod = FALSE;
-
-                               /* Force driver to fall into sleep mode when rcv EOSP frame */
-                               if (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE)) {
-                                       u16 TbttNumToNextWakeUp;
-                                       u16 NextDtim =
-                                           pAd->StaCfg.DtimPeriod;
-                                       unsigned long Now;
-
-                                       NdisGetSystemUpTime(&Now);
-                                       NextDtim -=
-                                           (u16)(Now -
-                                                     pAd->StaCfg.
-                                                     LastBeaconRxTime) /
-                                           pAd->CommonCfg.BeaconPeriod;
-
-                                       TbttNumToNextWakeUp =
-                                           pAd->StaCfg.DefaultListenCount;
-                                       if (OPSTATUS_TEST_FLAG
-                                           (pAd, fOP_STATUS_RECEIVE_DTIM)
-                                           && (TbttNumToNextWakeUp > NextDtim))
-                                               TbttNumToNextWakeUp = NextDtim;
-
-                                       RTMP_SET_PSM_BIT(pAd, PWR_SAVE);
-                                       /* if WMM-APSD is failed, try to disable following line */
-                                       AsicSleepThenAutoWakeup(pAd,
-                                                               TbttNumToNextWakeUp);
-                               }
-                       }
-
-                       if ((pHeader->FC.MoreData)
-                           && (pAd->CommonCfg.bInServicePeriod)) {
-                               DBGPRINT(RT_DEBUG_TRACE,
-                                        ("Sending another trigger frame when More Data bit is set to 1\n"));
-                       }
-               }
-               /* Drop NULL, CF-ACK(no data), CF-POLL(no data), and CF-ACK+CF-POLL(no data) data frame */
-               if ((pHeader->FC.SubType & 0x04))       /* bit 2 : no DATA */
-               {
-                       /* release packet */
-                       RELEASE_NDIS_PACKET(pAd, pRxPacket,
-                                           NDIS_STATUS_FAILURE);
-                       return;
-               }
-               /* Drop not my BSS frame (we can not only check the MyBss bit in RxD) */
-
-               if (INFRA_ON(pAd)) {
-                       /* Infrastructure mode, check address 2 for BSSID */
-                       if (!RTMPEqualMemory
-                           (&pHeader->Addr2, &pAd->CommonCfg.Bssid, 6)) {
-                               /* Receive frame not my BSSID */
-                               /* release packet */
-                               RELEASE_NDIS_PACKET(pAd, pRxPacket,
-                                                   NDIS_STATUS_FAILURE);
-                               return;
-                       }
-               } else          /* Ad-Hoc mode or Not associated */
-               {
-                       /* Ad-Hoc mode, check address 3 for BSSID */
-                       if (!RTMPEqualMemory
-                           (&pHeader->Addr3, &pAd->CommonCfg.Bssid, 6)) {
-                               /* Receive frame not my BSSID */
-                               /* release packet */
-                               RELEASE_NDIS_PACKET(pAd, pRxPacket,
-                                                   NDIS_STATUS_FAILURE);
-                               return;
-                       }
-               }
-
-               /* */
-               /* find pEntry */
-               /* */
-               if (pRxWI->WirelessCliID < MAX_LEN_OF_MAC_TABLE) {
-                       pEntry = &pAd->MacTab.Content[pRxWI->WirelessCliID];
-               } else {
-                       /* 1. release packet if infra mode */
-                       /* 2. new a pEntry if ad-hoc mode */
-                       RELEASE_NDIS_PACKET(pAd, pRxPacket,
-                                           NDIS_STATUS_FAILURE);
-                       return;
-               }
-
-               /* infra or ad-hoc */
-               if (INFRA_ON(pAd)) {
-                       RX_BLK_SET_FLAG(pRxBlk, fRX_INFRA);
-                       ASSERT(pRxWI->WirelessCliID == BSSID_WCID);
-               }
-               /* check Atheros Client */
-               if ((pEntry->bIAmBadAtheros == FALSE) && (pRxD->AMPDU == 1)
-                   && (pHeader->FC.Retry)) {
-                       pEntry->bIAmBadAtheros = TRUE;
-                       pAd->CommonCfg.IOTestParm.bCurrentAtheros = TRUE;
-                       pAd->CommonCfg.IOTestParm.bLastAtheros = TRUE;
-                       if (!STA_AES_ON(pAd)) {
-                               AsicUpdateProtect(pAd, 8, ALLN_SETPROTECT, TRUE,
-                                                 FALSE);
-                       }
-               }
-       }
-
-       pRxBlk->pData = (u8 *) pHeader;
-
-       /* */
-       /* update RxBlk->pData, DataSize */
-       /* 802.11 Header, QOS, HTC, Hw Padding */
-       /* */
-
-       /* 1. skip 802.11 HEADER */
-       {
-               pRxBlk->pData += LENGTH_802_11;
-               pRxBlk->DataSize -= LENGTH_802_11;
-       }
-
-       /* 2. QOS */
-       if (pHeader->FC.SubType & 0x08) {
-               RX_BLK_SET_FLAG(pRxBlk, fRX_QOS);
-               UserPriority = *(pRxBlk->pData) & 0x0f;
-               /* bit 7 in QoS Control field signals the HT A-MSDU format */
-               if ((*pRxBlk->pData) & 0x80) {
-                       RX_BLK_SET_FLAG(pRxBlk, fRX_AMSDU);
-               }
-               /* skip QOS contorl field */
-               pRxBlk->pData += 2;
-               pRxBlk->DataSize -= 2;
-       }
-       pRxBlk->UserPriority = UserPriority;
-
-       /* check if need to resend PS Poll when received packet with MoreData = 1 */
-       if ((pAd->StaCfg.Psm == PWR_SAVE) && (pHeader->FC.MoreData == 1)) {
-               if ((((UserPriority == 0) || (UserPriority == 3)) &&
-                    pAd->CommonCfg.bAPSDAC_BE == 0) ||
-                   (((UserPriority == 1) || (UserPriority == 2)) &&
-                    pAd->CommonCfg.bAPSDAC_BK == 0) ||
-                   (((UserPriority == 4) || (UserPriority == 5)) &&
-                    pAd->CommonCfg.bAPSDAC_VI == 0) ||
-                   (((UserPriority == 6) || (UserPriority == 7)) &&
-                    pAd->CommonCfg.bAPSDAC_VO == 0)) {
-                       /* non-UAPSD delivery-enabled AC */
-                       RTMP_PS_POLL_ENQUEUE(pAd);
-               }
-       }
-       /* 3. Order bit: A-Ralink or HTC+ */
-       if (pHeader->FC.Order) {
-#ifdef AGGREGATION_SUPPORT
-               if ((pRxWI->PHYMODE <= MODE_OFDM)
-                   && (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_AGGREGATION_INUSED)))
-               {
-                       RX_BLK_SET_FLAG(pRxBlk, fRX_ARALINK);
-               } else
-#endif /* AGGREGATION_SUPPORT // */
-               {
-                       RX_BLK_SET_FLAG(pRxBlk, fRX_HTC);
-                       /* skip HTC contorl field */
-                       pRxBlk->pData += 4;
-                       pRxBlk->DataSize -= 4;
-               }
-       }
-       /* 4. skip HW padding */
-       if (pRxD->L2PAD) {
-               /* just move pData pointer */
-               /* because DataSize excluding HW padding */
-               RX_BLK_SET_FLAG(pRxBlk, fRX_PAD);
-               pRxBlk->pData += 2;
-       }
-
-       if (pRxD->BA) {
-               RX_BLK_SET_FLAG(pRxBlk, fRX_AMPDU);
-       }
-       /* */
-       /* Case I  Process Broadcast & Multicast data frame */
-       /* */
-       if (pRxD->Bcast || pRxD->Mcast) {
-               INC_COUNTER64(pAd->WlanCounters.MulticastReceivedFrameCount);
-
-               /* Drop Mcast/Bcast frame with fragment bit on */
-               if (pHeader->FC.MoreFrag) {
-                       /* release packet */
-                       RELEASE_NDIS_PACKET(pAd, pRxPacket,
-                                           NDIS_STATUS_FAILURE);
-                       return;
-               }
-               /* Filter out Bcast frame which AP relayed for us */
-               if (pHeader->FC.FrDs
-                   && MAC_ADDR_EQUAL(pHeader->Addr3, pAd->CurrentAddress)) {
-                       /* release packet */
-                       RELEASE_NDIS_PACKET(pAd, pRxPacket,
-                                           NDIS_STATUS_FAILURE);
-                       return;
-               }
-
-               Indicate_Legacy_Packet(pAd, pRxBlk, FromWhichBSSID);
-               return;
-       } else if (pRxD->U2M) {
-               pAd->LastRxRate =
-                   (u16)((pRxWI->MCS) + (pRxWI->BW << 7) +
-                             (pRxWI->ShortGI << 8) + (pRxWI->PHYMODE << 14));
-
-               if (ADHOC_ON(pAd)) {
-                       pEntry = MacTableLookup(pAd, pHeader->Addr2);
-                       if (pEntry)
-                               Update_Rssi_Sample(pAd, &pEntry->RssiSample,
-                                                  pRxWI);
-               }
-
-               Update_Rssi_Sample(pAd, &pAd->StaCfg.RssiSample, pRxWI);
-
-               pAd->StaCfg.LastSNR0 = (u8)(pRxWI->SNR0);
-               pAd->StaCfg.LastSNR1 = (u8)(pRxWI->SNR1);
-
-               pAd->RalinkCounters.OneSecRxOkDataCnt++;
-
-               if (!((pHeader->Frag == 0) && (pHeader->FC.MoreFrag == 0))) {
-                       /* re-assemble the fragmented packets */
-                       /* return complete frame (pRxPacket) or NULL */
-                       bFragment = TRUE;
-                       pRxPacket = RTMPDeFragmentDataFrame(pAd, pRxBlk);
-               }
-
-               if (pRxPacket) {
-                       pEntry = &pAd->MacTab.Content[pRxWI->WirelessCliID];
-
-                       /* process complete frame */
-                       if (bFragment && (pRxD->Decrypted)
-                           && (pEntry->WepStatus ==
-                               Ndis802_11Encryption2Enabled)) {
-                               /* Minus MIC length */
-                               pRxBlk->DataSize -= 8;
-
-                               /* For TKIP frame, calculate the MIC value */
-                               if (STACheckTkipMICValue(pAd, pEntry, pRxBlk) ==
-                                   FALSE) {
-                                       return;
-                               }
-                       }
-
-                       STARxDataFrameAnnounce(pAd, pEntry, pRxBlk,
-                                              FromWhichBSSID);
-                       return;
-               } else {
-                       /* just return */
-                       /* because RTMPDeFragmentDataFrame() will release rx packet, */
-                       /* if packet is fragmented */
-                       return;
-               }
-       }
-
-       ASSERT(0);
-       /* release packet */
-       RELEASE_NDIS_PACKET(pAd, pRxPacket, NDIS_STATUS_FAILURE);
-}
-
-void STAHandleRxMgmtFrame(struct rt_rtmp_adapter *pAd, struct rt_rx_blk *pRxBlk)
-{
-       PRT28XX_RXD_STRUC pRxD = &(pRxBlk->RxD);
-       struct rt_rxwi * pRxWI = pRxBlk->pRxWI;
-       struct rt_header_802_11 * pHeader = pRxBlk->pHeader;
-       void *pRxPacket = pRxBlk->pRxPacket;
-
-       do {
-
-               /* check if need to resend PS Poll when received packet with MoreData = 1 */
-               if ((pAd->StaCfg.Psm == PWR_SAVE)
-                   && (pHeader->FC.MoreData == 1)) {
-                       /* for UAPSD, all management frames will be VO priority */
-                       if (pAd->CommonCfg.bAPSDAC_VO == 0) {
-                               /* non-UAPSD delivery-enabled AC */
-                               RTMP_PS_POLL_ENQUEUE(pAd);
-                       }
-               }
-
-               /* TODO: if MoreData == 0, station can go to sleep */
-
-               /* We should collect RSSI not only U2M data but also my beacon */
-               if ((pHeader->FC.SubType == SUBTYPE_BEACON)
-                   && (MAC_ADDR_EQUAL(&pAd->CommonCfg.Bssid, &pHeader->Addr2))
-                   && (pAd->RxAnt.EvaluatePeriod == 0)) {
-                       Update_Rssi_Sample(pAd, &pAd->StaCfg.RssiSample, pRxWI);
-
-                       pAd->StaCfg.LastSNR0 = (u8)(pRxWI->SNR0);
-                       pAd->StaCfg.LastSNR1 = (u8)(pRxWI->SNR1);
-               }
-
-               /* First check the size, it MUST not exceed the mlme queue size */
-               if (pRxWI->MPDUtotalByteCount > MGMT_DMA_BUFFER_SIZE) {
-                       DBGPRINT_ERR("STAHandleRxMgmtFrame: frame too large, size = %d \n", pRxWI->MPDUtotalByteCount);
-                       break;
-               }
-
-               REPORT_MGMT_FRAME_TO_MLME(pAd, pRxWI->WirelessCliID, pHeader,
-                                         pRxWI->MPDUtotalByteCount,
-                                         pRxWI->RSSI0, pRxWI->RSSI1,
-                                         pRxWI->RSSI2, pRxD->PlcpSignal);
-       } while (FALSE);
-
-       RELEASE_NDIS_PACKET(pAd, pRxPacket, NDIS_STATUS_SUCCESS);
-}
-
-void STAHandleRxControlFrame(struct rt_rtmp_adapter *pAd, struct rt_rx_blk *pRxBlk)
-{
-       struct rt_rxwi * pRxWI = pRxBlk->pRxWI;
-       struct rt_header_802_11 * pHeader = pRxBlk->pHeader;
-       void *pRxPacket = pRxBlk->pRxPacket;
-
-       switch (pHeader->FC.SubType) {
-       case SUBTYPE_BLOCK_ACK_REQ:
-               {
-                       CntlEnqueueForRecv(pAd, pRxWI->WirelessCliID,
-                                          (pRxWI->MPDUtotalByteCount),
-                                          (struct rt_frame_ba_req *) pHeader);
-               }
-               break;
-       case SUBTYPE_BLOCK_ACK:
-       case SUBTYPE_ACK:
-       default:
-               break;
-       }
-
-       RELEASE_NDIS_PACKET(pAd, pRxPacket, NDIS_STATUS_FAILURE);
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Process RxDone interrupt, running in DPC level
-
-       Arguments:
-               pAd Pointer to our adapter
-
-       Return Value:
-               None
-
-       IRQL = DISPATCH_LEVEL
-
-       Note:
-               This routine has to maintain Rx ring read pointer.
-               Need to consider QOS DATA format when converting to 802.3
-       ========================================================================
-*/
-BOOLEAN STARxDoneInterruptHandle(struct rt_rtmp_adapter *pAd, IN BOOLEAN argc)
-{
-       int Status;
-       u32 RxProcessed, RxPending;
-       BOOLEAN bReschedule = FALSE;
-       PRT28XX_RXD_STRUC pRxD;
-       u8 *pData;
-       struct rt_rxwi * pRxWI;
-       void *pRxPacket;
-       struct rt_header_802_11 * pHeader;
-       struct rt_rx_blk RxCell;
-
-       RxProcessed = RxPending = 0;
-
-       /* process whole rx ring */
-       while (1) {
-
-               if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF |
-                                  fRTMP_ADAPTER_RESET_IN_PROGRESS |
-                                  fRTMP_ADAPTER_HALT_IN_PROGRESS |
-                                  fRTMP_ADAPTER_NIC_NOT_EXIST) ||
-                   !RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_START_UP)) {
-                       break;
-               }
-#ifdef RTMP_MAC_PCI
-               if (RxProcessed++ > MAX_RX_PROCESS_CNT) {
-                       /* need to reschedule rx handle */
-                       bReschedule = TRUE;
-                       break;
-               }
-#endif /* RTMP_MAC_PCI // */
-
-               RxProcessed++;  /* test */
-
-               /* 1. allocate a new data packet into rx ring to replace received packet */
-               /*    then processing the received packet */
-               /* 2. the callee must take charge of release of packet */
-               /* 3. As far as driver is concerned , */
-               /*    the rx packet must */
-               /*      a. be indicated to upper layer or */
-               /*      b. be released if it is discarded */
-               pRxPacket =
-                   GetPacketFromRxRing(pAd, &(RxCell.RxD), &bReschedule,
-                                       &RxPending);
-               if (pRxPacket == NULL) {
-                       /* no more packet to process */
-                       break;
-               }
-               /* get rx ring descriptor */
-               pRxD = &(RxCell.RxD);
-               /* get rx data buffer */
-               pData = GET_OS_PKT_DATAPTR(pRxPacket);
-               pRxWI = (struct rt_rxwi *) pData;
-               pHeader = (struct rt_header_802_11 *) (pData + RXWI_SIZE);
-
-               /* build RxCell */
-               RxCell.pRxWI = pRxWI;
-               RxCell.pHeader = pHeader;
-               RxCell.pRxPacket = pRxPacket;
-               RxCell.pData = (u8 *) pHeader;
-               RxCell.DataSize = pRxWI->MPDUtotalByteCount;
-               RxCell.Flags = 0;
-
-               /* Increase Total receive byte counter after real data received no mater any error or not */
-               pAd->RalinkCounters.ReceivedByteCount +=
-                   pRxWI->MPDUtotalByteCount;
-               pAd->RalinkCounters.OneSecReceivedByteCount +=
-                   pRxWI->MPDUtotalByteCount;
-               pAd->RalinkCounters.RxCount++;
-
-               INC_COUNTER64(pAd->WlanCounters.ReceivedFragmentCount);
-
-               if (pRxWI->MPDUtotalByteCount < 14)
-                       Status = NDIS_STATUS_FAILURE;
-
-               if (MONITOR_ON(pAd)) {
-                       send_monitor_packets(pAd, &RxCell);
-                       break;
-               }
-
-               /* STARxDoneInterruptHandle() is called in rtusb_bulk.c */
-
-               /* Check for all RxD errors */
-               Status = RTMPCheckRxError(pAd, pHeader, pRxWI, pRxD);
-
-               /* Handle the received frame */
-               if (Status == NDIS_STATUS_SUCCESS) {
-                       switch (pHeader->FC.Type) {
-                               /* CASE I, receive a DATA frame */
-                       case BTYPE_DATA:
-                               {
-                                       /* process DATA frame */
-                                       STAHandleRxDataFrame(pAd, &RxCell);
-                               }
-                               break;
-                               /* CASE II, receive a MGMT frame */
-                       case BTYPE_MGMT:
-                               {
-                                       STAHandleRxMgmtFrame(pAd, &RxCell);
-                               }
-                               break;
-                               /* CASE III. receive a CNTL frame */
-                       case BTYPE_CNTL:
-                               {
-                                       STAHandleRxControlFrame(pAd, &RxCell);
-                               }
-                               break;
-                               /* discard other type */
-                       default:
-                               RELEASE_NDIS_PACKET(pAd, pRxPacket,
-                                                   NDIS_STATUS_FAILURE);
-                               break;
-                       }
-               } else {
-                       pAd->Counters8023.RxErrors++;
-                       /* discard this frame */
-                       RELEASE_NDIS_PACKET(pAd, pRxPacket,
-                                           NDIS_STATUS_FAILURE);
-               }
-       }
-
-       return bReschedule;
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-       Arguments:
-               pAd     Pointer to our adapter
-
-       IRQL = DISPATCH_LEVEL
-
-       ========================================================================
-*/
-void RTMPHandleTwakeupInterrupt(struct rt_rtmp_adapter *pAd)
-{
-       AsicForceWakeup(pAd, FALSE);
-}
-
-/*
-========================================================================
-Routine Description:
-    Early checking and OS-depened parsing for Tx packet send to our STA driver.
-
-Arguments:
-    void *     MiniportAdapterContext  Pointer refer to the device handle, i.e., the pAd.
-       void ** ppPacketArray                   The packet array need to do transmission.
-       u32                     NumberOfPackets                 Number of packet in packet array.
-
-Return Value:
-       NONE
-
-Note:
-       This function does early checking and classification for send-out packet.
-       You only can put OS-depened & STA related code in here.
-========================================================================
-*/
-void STASendPackets(void *MiniportAdapterContext,
-                   void **ppPacketArray, u32 NumberOfPackets)
-{
-       u32 Index;
-       struct rt_rtmp_adapter *pAd = (struct rt_rtmp_adapter *)MiniportAdapterContext;
-       void *pPacket;
-       BOOLEAN allowToSend = FALSE;
-
-       for (Index = 0; Index < NumberOfPackets; Index++) {
-               pPacket = ppPacketArray[Index];
-
-               do {
-                       if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS)
-                           || RTMP_TEST_FLAG(pAd,
-                                             fRTMP_ADAPTER_HALT_IN_PROGRESS)
-                           || RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF)) {
-                               /* Drop send request since hardware is in reset state */
-                               break;
-                       } else if (!INFRA_ON(pAd) && !ADHOC_ON(pAd)) {
-                               /* Drop send request since there are no physical connection yet */
-                               break;
-                       } else {
-                               /* Record that orignal packet source is from NDIS layer,so that */
-                               /* later on driver knows how to release this NDIS PACKET */
-                               RTMP_SET_PACKET_WCID(pPacket, 0);       /* this field is useless when in STA mode */
-                               RTMP_SET_PACKET_SOURCE(pPacket, PKTSRC_NDIS);
-                               NDIS_SET_PACKET_STATUS(pPacket,
-                                                      NDIS_STATUS_PENDING);
-                               pAd->RalinkCounters.PendingNdisPacketCount++;
-
-                               allowToSend = TRUE;
-                       }
-               } while (FALSE);
-
-               if (allowToSend == TRUE)
-                       STASendPacket(pAd, pPacket);
-               else
-                       RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
-       }
-
-       /* Dequeue outgoing frames from TxSwQueue[] and process it */
-       RTMPDeQueuePacket(pAd, FALSE, NUM_OF_TX_RING, MAX_TX_PROCESS);
-
-}
-
-/*
-========================================================================
-Routine Description:
-       This routine is used to do packet parsing and classification for Tx packet
-       to STA device, and it will en-queue packets to our TxSwQueue depends on AC
-       class.
-
-Arguments:
-       pAd             Pointer to our adapter
-       pPacket         Pointer to send packet
-
-Return Value:
-       NDIS_STATUS_SUCCESS                     If success to queue the packet into TxSwQueue.
-       NDIS_STATUS_FAILURE                     If failed to do en-queue.
-
-Note:
-       You only can put OS-indepened & STA related code in here.
-========================================================================
-*/
-int STASendPacket(struct rt_rtmp_adapter *pAd, void *pPacket)
-{
-       struct rt_packet_info PacketInfo;
-       u8 *pSrcBufVA;
-       u32 SrcBufLen;
-       u32 AllowFragSize;
-       u8 NumberOfFrag;
-       u8 RTSRequired;
-       u8 QueIdx, UserPriority;
-       struct rt_mac_table_entry *pEntry = NULL;
-       unsigned int IrqFlags;
-       u8 FlgIsIP = 0;
-       u8 Rate;
-
-       /* Prepare packet information structure for buffer descriptor */
-       /* chained within a single NDIS packet. */
-       RTMP_QueryPacketInfo(pPacket, &PacketInfo, &pSrcBufVA, &SrcBufLen);
-
-       if (pSrcBufVA == NULL) {
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("STASendPacket --> pSrcBufVA == NULL !SrcBufLen=%x\n",
-                         SrcBufLen));
-               /* Resource is low, system did not allocate virtual address */
-               /* return NDIS_STATUS_FAILURE directly to upper layer */
-               RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
-               return NDIS_STATUS_FAILURE;
-       }
-
-       if (SrcBufLen < 14) {
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("STASendPacket --> Ndis Packet buffer error!\n"));
-               RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
-               return (NDIS_STATUS_FAILURE);
-       }
-       /* In HT rate adhoc mode, A-MPDU is often used. So need to lookup BA Table and MAC Entry. */
-       /* Note multicast packets in adhoc also use BSSID_WCID index. */
-       {
-               if (INFRA_ON(pAd)) {
-                       {
-                               pEntry = &pAd->MacTab.Content[BSSID_WCID];
-                               RTMP_SET_PACKET_WCID(pPacket, BSSID_WCID);
-                               Rate = pAd->CommonCfg.TxRate;
-                       }
-               } else if (ADHOC_ON(pAd)) {
-                       if (*pSrcBufVA & 0x01) {
-                               RTMP_SET_PACKET_WCID(pPacket, MCAST_WCID);
-                               pEntry = &pAd->MacTab.Content[MCAST_WCID];
-                       } else {
-                               pEntry = MacTableLookup(pAd, pSrcBufVA);
-                       }
-                       Rate = pAd->CommonCfg.TxRate;
-               }
-       }
-
-       if (!pEntry) {
-               DBGPRINT(RT_DEBUG_ERROR,
-                       ("STASendPacket->Cannot find pEntry(%pM) in MacTab!\n",
-                               pSrcBufVA));
-               /* Resource is low, system did not allocate virtual address */
-               /* return NDIS_STATUS_FAILURE directly to upper layer */
-               RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
-               return NDIS_STATUS_FAILURE;
-       }
-
-       if (ADHOC_ON(pAd)
-           ) {
-               RTMP_SET_PACKET_WCID(pPacket, (u8)pEntry->Aid);
-       }
-       /* */
-       /* Check the Ethernet Frame type of this packet, and set the RTMP_SET_PACKET_SPECIFIC flags. */
-       /*              Here we set the PACKET_SPECIFIC flags(LLC, VLAN, DHCP/ARP, EAPOL). */
-       RTMPCheckEtherType(pAd, pPacket);
-
-       /* */
-       /* WPA 802.1x secured port control - drop all non-802.1x frame before port secured */
-       /* */
-       if (((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
-            (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
-            (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) ||
-            (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)
-            || (pAd->StaCfg.IEEE8021X == TRUE)
-           )
-           && ((pAd->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED)
-               || (pAd->StaCfg.MicErrCnt >= 2))
-           && (RTMP_GET_PACKET_EAPOL(pPacket) == FALSE)
-           ) {
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("STASendPacket --> Drop packet before port secured!\n"));
-               RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
-
-               return (NDIS_STATUS_FAILURE);
-       }
-
-       /* STEP 1. Decide number of fragments required to deliver this MSDU. */
-       /*         The estimation here is not very accurate because difficult to */
-       /*         take encryption overhead into consideration here. The result */
-       /*         "NumberOfFrag" is then just used to pre-check if enough free */
-       /*         TXD are available to hold this MSDU. */
-
-       if (*pSrcBufVA & 0x01)  /* fragmentation not allowed on multicast & broadcast */
-               NumberOfFrag = 1;
-       else if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_AGGREGATION_INUSED))
-               NumberOfFrag = 1;       /* Aggregation overwhelms fragmentation */
-       else if (CLIENT_STATUS_TEST_FLAG(pEntry, fCLIENT_STATUS_AMSDU_INUSED))
-               NumberOfFrag = 1;       /* Aggregation overwhelms fragmentation */
-       else if ((pAd->StaCfg.HTPhyMode.field.MODE == MODE_HTMIX)
-                || (pAd->StaCfg.HTPhyMode.field.MODE == MODE_HTGREENFIELD))
-               NumberOfFrag = 1;       /* MIMO RATE overwhelms fragmentation */
-       else {
-               /* The calculated "NumberOfFrag" is a rough estimation because of various */
-               /* encryption/encapsulation overhead not taken into consideration. This number is just */
-               /* used to make sure enough free TXD are available before fragmentation takes place. */
-               /* In case the actual required number of fragments of an NDIS packet */
-               /* excceeds "NumberOfFrag"caculated here and not enough free TXD available, the */
-               /* last fragment (i.e. last MPDU) will be dropped in RTMPHardTransmit() due to out of */
-               /* resource, and the NDIS packet will be indicated NDIS_STATUS_FAILURE. This should */
-               /* rarely happen and the penalty is just like a TX RETRY fail. Affordable. */
-
-               AllowFragSize =
-                   (pAd->CommonCfg.FragmentThreshold) - LENGTH_802_11 -
-                   LENGTH_CRC;
-               NumberOfFrag =
-                   ((PacketInfo.TotalPacketLength - LENGTH_802_3 +
-                     LENGTH_802_1_H) / AllowFragSize) + 1;
-               /* To get accurate number of fragmentation, Minus 1 if the size just match to allowable fragment size */
-               if (((PacketInfo.TotalPacketLength - LENGTH_802_3 +
-                     LENGTH_802_1_H) % AllowFragSize) == 0) {
-                       NumberOfFrag--;
-               }
-       }
-
-       /* Save fragment number to Ndis packet reserved field */
-       RTMP_SET_PACKET_FRAGMENTS(pPacket, NumberOfFrag);
-
-       /* STEP 2. Check the requirement of RTS: */
-       /*         If multiple fragment required, RTS is required only for the first fragment */
-       /*         if the fragment size is larger than RTS threshold */
-       /*     For RT28xx, Let ASIC send RTS/CTS */
-       /*      RTMP_SET_PACKET_RTS(pPacket, 0); */
-       if (NumberOfFrag > 1)
-               RTSRequired =
-                   (pAd->CommonCfg.FragmentThreshold >
-                    pAd->CommonCfg.RtsThreshold) ? 1 : 0;
-       else
-               RTSRequired =
-                   (PacketInfo.TotalPacketLength >
-                    pAd->CommonCfg.RtsThreshold) ? 1 : 0;
-
-       /* Save RTS requirement to Ndis packet reserved field */
-       RTMP_SET_PACKET_RTS(pPacket, RTSRequired);
-       RTMP_SET_PACKET_TXRATE(pPacket, pAd->CommonCfg.TxRate);
-
-       /* */
-       /* STEP 3. Traffic classification. outcome = <UserPriority, QueIdx> */
-       /* */
-       UserPriority = 0;
-       QueIdx = QID_AC_BE;
-       if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_WMM_INUSED) &&
-           CLIENT_STATUS_TEST_FLAG(pEntry, fCLIENT_STATUS_WMM_CAPABLE)) {
-               u16 Protocol;
-               u8 LlcSnapLen = 0, Byte0, Byte1;
-               do {
-                       /* get Ethernet protocol field */
-                       Protocol =
-                           (u16)((pSrcBufVA[12] << 8) + pSrcBufVA[13]);
-                       if (Protocol <= 1500) {
-                               /* get Ethernet protocol field from LLC/SNAP */
-                               if (Sniff2BytesFromNdisBuffer
-                                   (PacketInfo.pFirstBuffer, LENGTH_802_3 + 6,
-                                    &Byte0, &Byte1) != NDIS_STATUS_SUCCESS)
-                                       break;
-
-                               Protocol = (u16)((Byte0 << 8) + Byte1);
-                               LlcSnapLen = 8;
-                       }
-                       /* always AC_BE for non-IP packet */
-                       if (Protocol != 0x0800)
-                               break;
-
-                       /* get IP header */
-                       if (Sniff2BytesFromNdisBuffer
-                           (PacketInfo.pFirstBuffer, LENGTH_802_3 + LlcSnapLen,
-                            &Byte0, &Byte1) != NDIS_STATUS_SUCCESS)
-                               break;
-
-                       /* return AC_BE if packet is not IPv4 */
-                       if ((Byte0 & 0xf0) != 0x40)
-                               break;
-
-                       FlgIsIP = 1;
-                       UserPriority = (Byte1 & 0xe0) >> 5;
-                       QueIdx = MapUserPriorityToAccessCategory[UserPriority];
-
-                       /* TODO: have to check ACM bit. apply TSPEC if ACM is ON */
-                       /* TODO: downgrade UP & QueIdx before passing ACM */
-                       /*
-                          Under WMM ACM control, we dont need to check the bit;
-                          Or when a TSPEC is built for VO but we will change to issue
-                          BA session for BE here, so we will not use BA to send VO packets.
-                        */
-                       if (pAd->CommonCfg.APEdcaParm.bACM[QueIdx]) {
-                               UserPriority = 0;
-                               QueIdx = QID_AC_BE;
-                       }
-               } while (FALSE);
-       }
-
-       RTMP_SET_PACKET_UP(pPacket, UserPriority);
-
-       /* Make sure SendTxWait queue resource won't be used by other threads */
-       RTMP_IRQ_LOCK(&pAd->irq_lock, IrqFlags);
-       if (pAd->TxSwQueue[QueIdx].Number >= MAX_PACKETS_IN_QUEUE) {
-               RTMP_IRQ_UNLOCK(&pAd->irq_lock, IrqFlags);
-               RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
-
-               return NDIS_STATUS_FAILURE;
-       } else {
-               InsertTailQueueAc(pAd, pEntry, &pAd->TxSwQueue[QueIdx],
-                                 PACKET_TO_QUEUE_ENTRY(pPacket));
-       }
-       RTMP_IRQ_UNLOCK(&pAd->irq_lock, IrqFlags);
-
-       if ((pAd->CommonCfg.BACapability.field.AutoBA == TRUE) &&
-           IS_HT_STA(pEntry)) {
-               /*struct rt_mac_table_entry *pMacEntry = &pAd->MacTab.Content[BSSID_WCID]; */
-               if (((pEntry->TXBAbitmap & (1 << UserPriority)) == 0) &&
-                   ((pEntry->BADeclineBitmap & (1 << UserPriority)) == 0) &&
-                   (pEntry->PortSecured == WPA_802_1X_PORT_SECURED)
-                   /* For IOT compatibility, if */
-                   /* 1. It is Ralink chip or */
-                   /* 2. It is OPEN or AES mode, */
-                   /* then BA session can be bulit. */
-                   && ((pEntry->ValidAsCLI && pAd->MlmeAux.APRalinkIe != 0x0)
-                       || (pEntry->WepStatus != Ndis802_11WEPEnabled
-                           && pEntry->WepStatus !=
-                           Ndis802_11Encryption2Enabled))
-                   ) {
-                       BAOriSessionSetUp(pAd, pEntry, UserPriority, 0, 10,
-                                         FALSE);
-               }
-       }
-
-       pAd->RalinkCounters.OneSecOsTxCount[QueIdx]++;  /* TODO: for debug only. to be removed */
-       return NDIS_STATUS_SUCCESS;
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               This subroutine will scan through relative ring descriptor to find
-               out available free ring descriptor and compare with request size.
-
-       Arguments:
-               pAd Pointer to our adapter
-               QueIdx          Selected TX Ring
-
-       Return Value:
-               NDIS_STATUS_FAILURE     Not enough free descriptor
-               NDIS_STATUS_SUCCESS     Enough free descriptor
-
-       IRQL = PASSIVE_LEVEL
-       IRQL = DISPATCH_LEVEL
-
-       Note:
-
-       ========================================================================
-*/
-#ifdef RTMP_MAC_PCI
-int RTMPFreeTXDRequest(struct rt_rtmp_adapter *pAd,
-                              u8 QueIdx,
-                              u8 NumberRequired, u8 *FreeNumberIs)
-{
-       unsigned long FreeNumber = 0;
-       int Status = NDIS_STATUS_FAILURE;
-
-       switch (QueIdx) {
-       case QID_AC_BK:
-       case QID_AC_BE:
-       case QID_AC_VI:
-       case QID_AC_VO:
-               if (pAd->TxRing[QueIdx].TxSwFreeIdx >
-                   pAd->TxRing[QueIdx].TxCpuIdx)
-                       FreeNumber =
-                           pAd->TxRing[QueIdx].TxSwFreeIdx -
-                           pAd->TxRing[QueIdx].TxCpuIdx - 1;
-               else
-                       FreeNumber =
-                           pAd->TxRing[QueIdx].TxSwFreeIdx + TX_RING_SIZE -
-                           pAd->TxRing[QueIdx].TxCpuIdx - 1;
-
-               if (FreeNumber >= NumberRequired)
-                       Status = NDIS_STATUS_SUCCESS;
-               break;
-
-       case QID_MGMT:
-               if (pAd->MgmtRing.TxSwFreeIdx > pAd->MgmtRing.TxCpuIdx)
-                       FreeNumber =
-                           pAd->MgmtRing.TxSwFreeIdx - pAd->MgmtRing.TxCpuIdx -
-                           1;
-               else
-                       FreeNumber =
-                           pAd->MgmtRing.TxSwFreeIdx + MGMT_RING_SIZE -
-                           pAd->MgmtRing.TxCpuIdx - 1;
-
-               if (FreeNumber >= NumberRequired)
-                       Status = NDIS_STATUS_SUCCESS;
-               break;
-
-       default:
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("RTMPFreeTXDRequest::Invalid QueIdx(=%d)\n", QueIdx));
-               break;
-       }
-       *FreeNumberIs = (u8)FreeNumber;
-
-       return (Status);
-}
-#endif /* RTMP_MAC_PCI // */
-#ifdef RTMP_MAC_USB
-/*
-       Actually, this function used to check if the TxHardware Queue still has frame need to send.
-       If no frame need to send, go to sleep, else, still wake up.
-*/
-int RTMPFreeTXDRequest(struct rt_rtmp_adapter *pAd,
-                              u8 QueIdx,
-                              u8 NumberRequired, u8 *FreeNumberIs)
-{
-       /*unsigned long         FreeNumber = 0; */
-       int Status = NDIS_STATUS_FAILURE;
-       unsigned long IrqFlags;
-       struct rt_ht_tx_context *pHTTXContext;
-
-       switch (QueIdx) {
-       case QID_AC_BK:
-       case QID_AC_BE:
-       case QID_AC_VI:
-       case QID_AC_VO:
-               {
-                       pHTTXContext = &pAd->TxContext[QueIdx];
-                       RTMP_IRQ_LOCK(&pAd->TxContextQueueLock[QueIdx],
-                                     IrqFlags);
-                       if ((pHTTXContext->CurWritePosition !=
-                            pHTTXContext->ENextBulkOutPosition)
-                           || (pHTTXContext->IRPPending == TRUE)) {
-                               Status = NDIS_STATUS_FAILURE;
-                       } else {
-                               Status = NDIS_STATUS_SUCCESS;
-                       }
-                       RTMP_IRQ_UNLOCK(&pAd->TxContextQueueLock[QueIdx],
-                                       IrqFlags);
-               }
-               break;
-       case QID_MGMT:
-               if (pAd->MgmtRing.TxSwFreeIdx != MGMT_RING_SIZE)
-                       Status = NDIS_STATUS_FAILURE;
-               else
-                       Status = NDIS_STATUS_SUCCESS;
-               break;
-       default:
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("RTMPFreeTXDRequest::Invalid QueIdx(=%d)\n", QueIdx));
-               break;
-       }
-
-       return (Status);
-}
-#endif /* RTMP_MAC_USB // */
-
-void RTMPSendDisassociationFrame(struct rt_rtmp_adapter *pAd)
-{
-}
-
-void RTMPSendNullFrame(struct rt_rtmp_adapter *pAd,
-                      u8 TxRate, IN BOOLEAN bQosNull)
-{
-       u8 NullFrame[48];
-       unsigned long Length;
-       struct rt_header_802_11 * pHeader_802_11;
-
-       /* WPA 802.1x secured port control */
-       if (((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
-            (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
-            (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) ||
-            (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)
-            || (pAd->StaCfg.IEEE8021X == TRUE)
-           ) && (pAd->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED)) {
-               return;
-       }
-
-       NdisZeroMemory(NullFrame, 48);
-       Length = sizeof(struct rt_header_802_11);
-
-       pHeader_802_11 = (struct rt_header_802_11 *) NullFrame;
-
-       pHeader_802_11->FC.Type = BTYPE_DATA;
-       pHeader_802_11->FC.SubType = SUBTYPE_NULL_FUNC;
-       pHeader_802_11->FC.ToDs = 1;
-       COPY_MAC_ADDR(pHeader_802_11->Addr1, pAd->CommonCfg.Bssid);
-       COPY_MAC_ADDR(pHeader_802_11->Addr2, pAd->CurrentAddress);
-       COPY_MAC_ADDR(pHeader_802_11->Addr3, pAd->CommonCfg.Bssid);
-
-       if (pAd->CommonCfg.bAPSDForcePowerSave) {
-               pHeader_802_11->FC.PwrMgmt = PWR_SAVE;
-       } else {
-               pHeader_802_11->FC.PwrMgmt =
-                   (pAd->StaCfg.Psm == PWR_SAVE) ? 1 : 0;
-       }
-       pHeader_802_11->Duration =
-           pAd->CommonCfg.Dsifs + RTMPCalcDuration(pAd, TxRate, 14);
-
-       pAd->Sequence++;
-       pHeader_802_11->Sequence = pAd->Sequence;
-
-       /* Prepare QosNull function frame */
-       if (bQosNull) {
-               pHeader_802_11->FC.SubType = SUBTYPE_QOS_NULL;
-
-               /* copy QOS control bytes */
-               NullFrame[Length] = 0;
-               NullFrame[Length + 1] = 0;
-               Length += 2;    /* if pad with 2 bytes for alignment, APSD will fail */
-       }
-
-       HAL_KickOutNullFrameTx(pAd, 0, NullFrame, Length);
-
-}
-
-/* IRQL = DISPATCH_LEVEL */
-void RTMPSendRTSFrame(struct rt_rtmp_adapter *pAd,
-                     u8 *pDA,
-                     IN unsigned int NextMpduSize,
-                     u8 TxRate,
-                     u8 RTSRate,
-                     u16 AckDuration, u8 QueIdx, u8 FrameGap)
-{
-}
-
-/* -------------------------------------------------------- */
-/*  FIND ENCRYPT KEY AND DECIDE CIPHER ALGORITHM */
-/*              Find the WPA key, either Group or Pairwise Key */
-/*              LEAP + TKIP also use WPA key. */
-/* -------------------------------------------------------- */
-/* Decide WEP bit and cipher suite to be used. Same cipher suite should be used for whole fragment burst */
-/* In Cisco CCX 2.0 Leap Authentication */
-/*                 WepStatus is Ndis802_11Encryption1Enabled but the key will use PairwiseKey */
-/*                 Instead of the SharedKey, SharedKey Length may be Zero. */
-void STAFindCipherAlgorithm(struct rt_rtmp_adapter *pAd, struct rt_tx_blk *pTxBlk)
-{
-       NDIS_802_11_ENCRYPTION_STATUS Cipher;   /* To indicate cipher used for this packet */
-       u8 CipherAlg = CIPHER_NONE;     /* cipher alogrithm */
-       u8 KeyIdx = 0xff;
-       u8 *pSrcBufVA;
-       struct rt_cipher_key *pKey = NULL;
-
-       pSrcBufVA = GET_OS_PKT_DATAPTR(pTxBlk->pPacket);
-
-       {
-               /* Select Cipher */
-               if ((*pSrcBufVA & 0x01) && (ADHOC_ON(pAd)))
-                       Cipher = pAd->StaCfg.GroupCipher;       /* Cipher for Multicast or Broadcast */
-               else
-                       Cipher = pAd->StaCfg.PairCipher;        /* Cipher for Unicast */
-
-               if (RTMP_GET_PACKET_EAPOL(pTxBlk->pPacket)) {
-                       ASSERT(pAd->SharedKey[BSS0][0].CipherAlg <=
-                              CIPHER_CKIP128);
-
-                       /* 4-way handshaking frame must be clear */
-                       if (!(TX_BLK_TEST_FLAG(pTxBlk, fTX_bClearEAPFrame))
-                           && (pAd->SharedKey[BSS0][0].CipherAlg)
-                           && (pAd->SharedKey[BSS0][0].KeyLen)) {
-                               CipherAlg = pAd->SharedKey[BSS0][0].CipherAlg;
-                               KeyIdx = 0;
-                       }
-               } else if (Cipher == Ndis802_11Encryption1Enabled) {
-                       KeyIdx = pAd->StaCfg.DefaultKeyId;
-               } else if ((Cipher == Ndis802_11Encryption2Enabled) ||
-                          (Cipher == Ndis802_11Encryption3Enabled)) {
-                       if ((*pSrcBufVA & 0x01) && (ADHOC_ON(pAd)))     /* multicast */
-                               KeyIdx = pAd->StaCfg.DefaultKeyId;
-                       else if (pAd->SharedKey[BSS0][0].KeyLen)
-                               KeyIdx = 0;
-                       else
-                               KeyIdx = pAd->StaCfg.DefaultKeyId;
-               }
-
-               if (KeyIdx == 0xff)
-                       CipherAlg = CIPHER_NONE;
-               else if ((Cipher == Ndis802_11EncryptionDisabled)
-                        || (pAd->SharedKey[BSS0][KeyIdx].KeyLen == 0))
-                       CipherAlg = CIPHER_NONE;
-               else if (pAd->StaCfg.WpaSupplicantUP &&
-                        (Cipher == Ndis802_11Encryption1Enabled) &&
-                        (pAd->StaCfg.IEEE8021X == TRUE) &&
-                        (pAd->StaCfg.PortSecured ==
-                         WPA_802_1X_PORT_NOT_SECURED))
-                       CipherAlg = CIPHER_NONE;
-               else {
-                       /*Header_802_11.FC.Wep = 1; */
-                       CipherAlg = pAd->SharedKey[BSS0][KeyIdx].CipherAlg;
-                       pKey = &pAd->SharedKey[BSS0][KeyIdx];
-               }
-       }
-
-       pTxBlk->CipherAlg = CipherAlg;
-       pTxBlk->pKey = pKey;
-}
-
-void STABuildCommon802_11Header(struct rt_rtmp_adapter *pAd, struct rt_tx_blk *pTxBlk)
-{
-       struct rt_header_802_11 *pHeader_802_11;
-
-       /* */
-       /* MAKE A COMMON 802.11 HEADER */
-       /* */
-
-       /* normal wlan header size : 24 octets */
-       pTxBlk->MpduHeaderLen = sizeof(struct rt_header_802_11);
-
-       pHeader_802_11 =
-           (struct rt_header_802_11 *) & pTxBlk->HeaderBuf[TXINFO_SIZE + TXWI_SIZE];
-
-       NdisZeroMemory(pHeader_802_11, sizeof(struct rt_header_802_11));
-
-       pHeader_802_11->FC.FrDs = 0;
-       pHeader_802_11->FC.Type = BTYPE_DATA;
-       pHeader_802_11->FC.SubType =
-           ((TX_BLK_TEST_FLAG(pTxBlk, fTX_bWMM)) ? SUBTYPE_QDATA :
-            SUBTYPE_DATA);
-
-       if (pTxBlk->pMacEntry) {
-               if (TX_BLK_TEST_FLAG(pTxBlk, fTX_bForceNonQoS)) {
-                       pHeader_802_11->Sequence =
-                           pTxBlk->pMacEntry->NonQosDataSeq;
-                       pTxBlk->pMacEntry->NonQosDataSeq =
-                           (pTxBlk->pMacEntry->NonQosDataSeq + 1) & MAXSEQ;
-               } else {
-                       {
-                               pHeader_802_11->Sequence =
-                                   pTxBlk->pMacEntry->TxSeq[pTxBlk->
-                                                            UserPriority];
-                               pTxBlk->pMacEntry->TxSeq[pTxBlk->UserPriority] =
-                                   (pTxBlk->pMacEntry->
-                                    TxSeq[pTxBlk->UserPriority] + 1) & MAXSEQ;
-                       }
-               }
-       } else {
-               pHeader_802_11->Sequence = pAd->Sequence;
-               pAd->Sequence = (pAd->Sequence + 1) & MAXSEQ;   /* next sequence */
-       }
-
-       pHeader_802_11->Frag = 0;
-
-       pHeader_802_11->FC.MoreData = TX_BLK_TEST_FLAG(pTxBlk, fTX_bMoreData);
-
-       {
-               if (INFRA_ON(pAd)) {
-                       {
-                               COPY_MAC_ADDR(pHeader_802_11->Addr1,
-                                             pAd->CommonCfg.Bssid);
-                               COPY_MAC_ADDR(pHeader_802_11->Addr2,
-                                             pAd->CurrentAddress);
-                               COPY_MAC_ADDR(pHeader_802_11->Addr3,
-                                             pTxBlk->pSrcBufHeader);
-                               pHeader_802_11->FC.ToDs = 1;
-                       }
-               } else if (ADHOC_ON(pAd)) {
-                       COPY_MAC_ADDR(pHeader_802_11->Addr1,
-                                     pTxBlk->pSrcBufHeader);
-                       COPY_MAC_ADDR(pHeader_802_11->Addr2,
-                                     pAd->CurrentAddress);
-                       COPY_MAC_ADDR(pHeader_802_11->Addr3,
-                                     pAd->CommonCfg.Bssid);
-                       pHeader_802_11->FC.ToDs = 0;
-               }
-       }
-
-       if (pTxBlk->CipherAlg != CIPHER_NONE)
-               pHeader_802_11->FC.Wep = 1;
-
-       /* ----------------------------------------------------------------- */
-       /* STEP 2. MAKE A COMMON 802.11 HEADER SHARED BY ENTIRE FRAGMENT BURST. Fill sequence later. */
-       /* ----------------------------------------------------------------- */
-       if (pAd->CommonCfg.bAPSDForcePowerSave)
-               pHeader_802_11->FC.PwrMgmt = PWR_SAVE;
-       else
-               pHeader_802_11->FC.PwrMgmt = (pAd->StaCfg.Psm == PWR_SAVE);
-}
-
-void STABuildCache802_11Header(struct rt_rtmp_adapter *pAd,
-                              struct rt_tx_blk *pTxBlk, u8 * pHeader)
-{
-       struct rt_mac_table_entry *pMacEntry;
-       struct rt_header_802_11 * pHeader80211;
-
-       pHeader80211 = (struct rt_header_802_11 *) pHeader;
-       pMacEntry = pTxBlk->pMacEntry;
-
-       /* */
-       /* Update the cached 802.11 HEADER */
-       /* */
-
-       /* normal wlan header size : 24 octets */
-       pTxBlk->MpduHeaderLen = sizeof(struct rt_header_802_11);
-
-       /* More Bit */
-       pHeader80211->FC.MoreData = TX_BLK_TEST_FLAG(pTxBlk, fTX_bMoreData);
-
-       /* Sequence */
-       pHeader80211->Sequence = pMacEntry->TxSeq[pTxBlk->UserPriority];
-       pMacEntry->TxSeq[pTxBlk->UserPriority] =
-           (pMacEntry->TxSeq[pTxBlk->UserPriority] + 1) & MAXSEQ;
-
-       {
-               /* Check if the frame can be sent through DLS direct link interface */
-               /* If packet can be sent through DLS, then force aggregation disable. (Hard to determine peer STA's capability) */
-
-               /* The addr3 of normal packet send from DS is Dest Mac address. */
-               if (ADHOC_ON(pAd))
-                       COPY_MAC_ADDR(pHeader80211->Addr3,
-                                     pAd->CommonCfg.Bssid);
-               else
-                       COPY_MAC_ADDR(pHeader80211->Addr3,
-                                     pTxBlk->pSrcBufHeader);
-       }
-
-       /* ----------------------------------------------------------------- */
-       /* STEP 2. MAKE A COMMON 802.11 HEADER SHARED BY ENTIRE FRAGMENT BURST. Fill sequence later. */
-       /* ----------------------------------------------------------------- */
-       if (pAd->CommonCfg.bAPSDForcePowerSave)
-               pHeader80211->FC.PwrMgmt = PWR_SAVE;
-       else
-               pHeader80211->FC.PwrMgmt = (pAd->StaCfg.Psm == PWR_SAVE);
-}
-
-static inline u8 *STA_Build_ARalink_Frame_Header(struct rt_rtmp_adapter *pAd,
-                                                   struct rt_tx_blk *pTxBlk)
-{
-       u8 *pHeaderBufPtr;
-       struct rt_header_802_11 *pHeader_802_11;
-       void *pNextPacket;
-       u32 nextBufLen;
-       struct rt_queue_entry *pQEntry;
-
-       STAFindCipherAlgorithm(pAd, pTxBlk);
-       STABuildCommon802_11Header(pAd, pTxBlk);
-
-       pHeaderBufPtr = &pTxBlk->HeaderBuf[TXINFO_SIZE + TXWI_SIZE];
-       pHeader_802_11 = (struct rt_header_802_11 *) pHeaderBufPtr;
-
-       /* steal "order" bit to mark "aggregation" */
-       pHeader_802_11->FC.Order = 1;
-
-       /* skip common header */
-       pHeaderBufPtr += pTxBlk->MpduHeaderLen;
-
-       if (TX_BLK_TEST_FLAG(pTxBlk, fTX_bWMM)) {
-               /* */
-               /* build QOS Control bytes */
-               /* */
-               *pHeaderBufPtr = (pTxBlk->UserPriority & 0x0F);
-
-               *(pHeaderBufPtr + 1) = 0;
-               pHeaderBufPtr += 2;
-               pTxBlk->MpduHeaderLen += 2;
-       }
-       /* padding at front of LLC header. LLC header should at 4-bytes alignment. */
-       pTxBlk->HdrPadLen = (unsigned long)pHeaderBufPtr;
-       pHeaderBufPtr = (u8 *)ROUND_UP(pHeaderBufPtr, 4);
-       pTxBlk->HdrPadLen = (unsigned long)(pHeaderBufPtr - pTxBlk->HdrPadLen);
-
-       /* For RA Aggregation, */
-       /* put the 2nd MSDU length(extra 2-byte field) after struct rt_qos_control in little endian format */
-       pQEntry = pTxBlk->TxPacketList.Head;
-       pNextPacket = QUEUE_ENTRY_TO_PACKET(pQEntry);
-       nextBufLen = GET_OS_PKT_LEN(pNextPacket);
-       if (RTMP_GET_PACKET_VLAN(pNextPacket))
-               nextBufLen -= LENGTH_802_1Q;
-
-       *pHeaderBufPtr = (u8)nextBufLen & 0xff;
-       *(pHeaderBufPtr + 1) = (u8)(nextBufLen >> 8);
-
-       pHeaderBufPtr += 2;
-       pTxBlk->MpduHeaderLen += 2;
-
-       return pHeaderBufPtr;
-
-}
-
-static inline u8 *STA_Build_AMSDU_Frame_Header(struct rt_rtmp_adapter *pAd,
-                                                 struct rt_tx_blk *pTxBlk)
-{
-       u8 *pHeaderBufPtr;      /*, pSaveBufPtr; */
-       struct rt_header_802_11 *pHeader_802_11;
-
-       STAFindCipherAlgorithm(pAd, pTxBlk);
-       STABuildCommon802_11Header(pAd, pTxBlk);
-
-       pHeaderBufPtr = &pTxBlk->HeaderBuf[TXINFO_SIZE + TXWI_SIZE];
-       pHeader_802_11 = (struct rt_header_802_11 *) pHeaderBufPtr;
-
-       /* skip common header */
-       pHeaderBufPtr += pTxBlk->MpduHeaderLen;
-
-       /* */
-       /* build QOS Control bytes */
-       /* */
-       *pHeaderBufPtr = (pTxBlk->UserPriority & 0x0F);
-
-       /* */
-       /* A-MSDU packet */
-       /* */
-       *pHeaderBufPtr |= 0x80;
-
-       *(pHeaderBufPtr + 1) = 0;
-       pHeaderBufPtr += 2;
-       pTxBlk->MpduHeaderLen += 2;
-
-       /*pSaveBufPtr = pHeaderBufPtr; */
-
-       /* */
-       /* padding at front of LLC header */
-       /* LLC header should locate at 4-octets aligment */
-       /* */
-       /* @@@ MpduHeaderLen excluding padding @@@ */
-       /* */
-       pTxBlk->HdrPadLen = (unsigned long)pHeaderBufPtr;
-       pHeaderBufPtr = (u8 *)ROUND_UP(pHeaderBufPtr, 4);
-       pTxBlk->HdrPadLen = (unsigned long)(pHeaderBufPtr - pTxBlk->HdrPadLen);
-
-       return pHeaderBufPtr;
-
-}
-
-void STA_AMPDU_Frame_Tx(struct rt_rtmp_adapter *pAd, struct rt_tx_blk *pTxBlk)
-{
-       struct rt_header_802_11 *pHeader_802_11;
-       u8 *pHeaderBufPtr;
-       u16 FreeNumber;
-       struct rt_mac_table_entry *pMacEntry;
-       BOOLEAN bVLANPkt;
-       struct rt_queue_entry *pQEntry;
-
-       ASSERT(pTxBlk);
-
-       while (pTxBlk->TxPacketList.Head) {
-               pQEntry = RemoveHeadQueue(&pTxBlk->TxPacketList);
-               pTxBlk->pPacket = QUEUE_ENTRY_TO_PACKET(pQEntry);
-               if (RTMP_FillTxBlkInfo(pAd, pTxBlk) != TRUE) {
-                       RELEASE_NDIS_PACKET(pAd, pTxBlk->pPacket,
-                                           NDIS_STATUS_FAILURE);
-                       continue;
-               }
-
-               bVLANPkt =
-                   (RTMP_GET_PACKET_VLAN(pTxBlk->pPacket) ? TRUE : FALSE);
-
-               pMacEntry = pTxBlk->pMacEntry;
-               if (pMacEntry->isCached) {
-                       /* NOTE: Please make sure the size of pMacEntry->CachedBuf[] is smaller than pTxBlk->HeaderBuf[]! */
-                       NdisMoveMemory((u8 *)& pTxBlk->
-                                      HeaderBuf[TXINFO_SIZE],
-                                      (u8 *)& pMacEntry->CachedBuf[0],
-                                      TXWI_SIZE + sizeof(struct rt_header_802_11));
-                       pHeaderBufPtr =
-                           (u8 *)(&pTxBlk->
-                                     HeaderBuf[TXINFO_SIZE + TXWI_SIZE]);
-                       STABuildCache802_11Header(pAd, pTxBlk, pHeaderBufPtr);
-               } else {
-                       STAFindCipherAlgorithm(pAd, pTxBlk);
-                       STABuildCommon802_11Header(pAd, pTxBlk);
-
-                       pHeaderBufPtr =
-                           &pTxBlk->HeaderBuf[TXINFO_SIZE + TXWI_SIZE];
-               }
-
-               pHeader_802_11 = (struct rt_header_802_11 *) pHeaderBufPtr;
-
-               /* skip common header */
-               pHeaderBufPtr += pTxBlk->MpduHeaderLen;
-
-               /* */
-               /* build QOS Control bytes */
-               /* */
-               *pHeaderBufPtr = (pTxBlk->UserPriority & 0x0F);
-               *(pHeaderBufPtr + 1) = 0;
-               pHeaderBufPtr += 2;
-               pTxBlk->MpduHeaderLen += 2;
-
-               /* */
-               /* build HTC+ */
-               /* HTC control filed following QoS field */
-               /* */
-               if ((pAd->CommonCfg.bRdg == TRUE)
-                   && CLIENT_STATUS_TEST_FLAG(pTxBlk->pMacEntry,
-                                              fCLIENT_STATUS_RDG_CAPABLE)) {
-                       if (pMacEntry->isCached == FALSE) {
-                               /* mark HTC bit */
-                               pHeader_802_11->FC.Order = 1;
-
-                               NdisZeroMemory(pHeaderBufPtr, 4);
-                               *(pHeaderBufPtr + 3) |= 0x80;
-                       }
-                       pHeaderBufPtr += 4;
-                       pTxBlk->MpduHeaderLen += 4;
-               }
-               /*pTxBlk->MpduHeaderLen = pHeaderBufPtr - pTxBlk->HeaderBuf - TXWI_SIZE - TXINFO_SIZE; */
-               ASSERT(pTxBlk->MpduHeaderLen >= 24);
-
-               /* skip 802.3 header */
-               pTxBlk->pSrcBufData = pTxBlk->pSrcBufHeader + LENGTH_802_3;
-               pTxBlk->SrcBufLen -= LENGTH_802_3;
-
-               /* skip vlan tag */
-               if (bVLANPkt) {
-                       pTxBlk->pSrcBufData += LENGTH_802_1Q;
-                       pTxBlk->SrcBufLen -= LENGTH_802_1Q;
-               }
-               /* */
-               /* padding at front of LLC header */
-               /* LLC header should locate at 4-octets aligment */
-               /* */
-               /* @@@ MpduHeaderLen excluding padding @@@ */
-               /* */
-               pTxBlk->HdrPadLen = (unsigned long)pHeaderBufPtr;
-               pHeaderBufPtr = (u8 *)ROUND_UP(pHeaderBufPtr, 4);
-               pTxBlk->HdrPadLen = (unsigned long)(pHeaderBufPtr - pTxBlk->HdrPadLen);
-
-               {
-
-                       /* */
-                       /* Insert LLC-SNAP encapsulation - 8 octets */
-                       /* */
-                       EXTRA_LLCSNAP_ENCAP_FROM_PKT_OFFSET(pTxBlk->
-                                                           pSrcBufData - 2,
-                                                           pTxBlk->
-                                                           pExtraLlcSnapEncap);
-                       if (pTxBlk->pExtraLlcSnapEncap) {
-                               NdisMoveMemory(pHeaderBufPtr,
-                                              pTxBlk->pExtraLlcSnapEncap, 6);
-                               pHeaderBufPtr += 6;
-                               /* get 2 octets (TypeofLen) */
-                               NdisMoveMemory(pHeaderBufPtr,
-                                              pTxBlk->pSrcBufData - 2, 2);
-                               pHeaderBufPtr += 2;
-                               pTxBlk->MpduHeaderLen += LENGTH_802_1_H;
-                       }
-
-               }
-
-               if (pMacEntry->isCached) {
-                       RTMPWriteTxWI_Cache(pAd,
-                                           (struct rt_txwi *) (&pTxBlk->
-                                                          HeaderBuf
-                                                          [TXINFO_SIZE]),
-                                           pTxBlk);
-               } else {
-                       RTMPWriteTxWI_Data(pAd,
-                                          (struct rt_txwi *) (&pTxBlk->
-                                                         HeaderBuf
-                                                         [TXINFO_SIZE]),
-                                          pTxBlk);
-
-                       NdisZeroMemory((u8 *)(&pMacEntry->CachedBuf[0]),
-                                      sizeof(pMacEntry->CachedBuf));
-                       NdisMoveMemory((u8 *)(&pMacEntry->CachedBuf[0]),
-                                      (u8 *)(&pTxBlk->
-                                                HeaderBuf[TXINFO_SIZE]),
-                                      (pHeaderBufPtr -
-                                       (u8 *)(&pTxBlk->
-                                                 HeaderBuf[TXINFO_SIZE])));
-                       pMacEntry->isCached = TRUE;
-               }
-
-               /* calculate Transmitted AMPDU count and ByteCount */
-               {
-                       pAd->RalinkCounters.TransmittedMPDUsInAMPDUCount.u.
-                           LowPart++;
-                       pAd->RalinkCounters.TransmittedOctetsInAMPDUCount.
-                           QuadPart += pTxBlk->SrcBufLen;
-               }
-
-               /*FreeNumber = GET_TXRING_FREENO(pAd, QueIdx); */
-
-               HAL_WriteTxResource(pAd, pTxBlk, TRUE, &FreeNumber);
-
-               /* */
-               /* Kick out Tx */
-               /* */
-               if (!RTMP_TEST_PSFLAG(pAd, fRTMP_PS_DISABLE_TX))
-                       HAL_KickOutTx(pAd, pTxBlk, pTxBlk->QueIdx);
-
-               pAd->RalinkCounters.KickTxCount++;
-               pAd->RalinkCounters.OneSecTxDoneCount++;
-       }
-
-}
-
-void STA_AMSDU_Frame_Tx(struct rt_rtmp_adapter *pAd, struct rt_tx_blk *pTxBlk)
-{
-       u8 *pHeaderBufPtr;
-       u16 FreeNumber;
-       u16 subFramePayloadLen = 0;     /* AMSDU Subframe length without AMSDU-Header / Padding. */
-       u16 totalMPDUSize = 0;
-       u8 *subFrameHeader;
-       u8 padding = 0;
-       u16 FirstTx = 0, LastTxIdx = 0;
-       BOOLEAN bVLANPkt;
-       int frameNum = 0;
-       struct rt_queue_entry *pQEntry;
-
-       ASSERT(pTxBlk);
-
-       ASSERT((pTxBlk->TxPacketList.Number > 1));
-
-       while (pTxBlk->TxPacketList.Head) {
-               pQEntry = RemoveHeadQueue(&pTxBlk->TxPacketList);
-               pTxBlk->pPacket = QUEUE_ENTRY_TO_PACKET(pQEntry);
-               if (RTMP_FillTxBlkInfo(pAd, pTxBlk) != TRUE) {
-                       RELEASE_NDIS_PACKET(pAd, pTxBlk->pPacket,
-                                           NDIS_STATUS_FAILURE);
-                       continue;
-               }
-
-               bVLANPkt =
-                   (RTMP_GET_PACKET_VLAN(pTxBlk->pPacket) ? TRUE : FALSE);
-
-               /* skip 802.3 header */
-               pTxBlk->pSrcBufData = pTxBlk->pSrcBufHeader + LENGTH_802_3;
-               pTxBlk->SrcBufLen -= LENGTH_802_3;
-
-               /* skip vlan tag */
-               if (bVLANPkt) {
-                       pTxBlk->pSrcBufData += LENGTH_802_1Q;
-                       pTxBlk->SrcBufLen -= LENGTH_802_1Q;
-               }
-
-               if (frameNum == 0) {
-                       pHeaderBufPtr =
-                           STA_Build_AMSDU_Frame_Header(pAd, pTxBlk);
-
-                       /* NOTE: TxWI->MPDUtotalByteCount will be updated after final frame was handled. */
-                       RTMPWriteTxWI_Data(pAd,
-                                          (struct rt_txwi *) (&pTxBlk->
-                                                         HeaderBuf
-                                                         [TXINFO_SIZE]),
-                                          pTxBlk);
-               } else {
-                       pHeaderBufPtr = &pTxBlk->HeaderBuf[0];
-                       padding =
-                           ROUND_UP(LENGTH_AMSDU_SUBFRAMEHEAD +
-                                    subFramePayloadLen,
-                                    4) - (LENGTH_AMSDU_SUBFRAMEHEAD +
-                                          subFramePayloadLen);
-                       NdisZeroMemory(pHeaderBufPtr,
-                                      padding + LENGTH_AMSDU_SUBFRAMEHEAD);
-                       pHeaderBufPtr += padding;
-                       pTxBlk->MpduHeaderLen = padding;
-               }
-
-               /* */
-               /* A-MSDU subframe */
-               /*   DA(6)+SA(6)+Length(2) + LLC/SNAP Encap */
-               /* */
-               subFrameHeader = pHeaderBufPtr;
-               subFramePayloadLen = pTxBlk->SrcBufLen;
-
-               NdisMoveMemory(subFrameHeader, pTxBlk->pSrcBufHeader, 12);
-
-               pHeaderBufPtr += LENGTH_AMSDU_SUBFRAMEHEAD;
-               pTxBlk->MpduHeaderLen += LENGTH_AMSDU_SUBFRAMEHEAD;
-
-               /* */
-               /* Insert LLC-SNAP encapsulation - 8 octets */
-               /* */
-               EXTRA_LLCSNAP_ENCAP_FROM_PKT_OFFSET(pTxBlk->pSrcBufData - 2,
-                                                   pTxBlk->pExtraLlcSnapEncap);
-
-               subFramePayloadLen = pTxBlk->SrcBufLen;
-
-               if (pTxBlk->pExtraLlcSnapEncap) {
-                       NdisMoveMemory(pHeaderBufPtr,
-                                      pTxBlk->pExtraLlcSnapEncap, 6);
-                       pHeaderBufPtr += 6;
-                       /* get 2 octets (TypeofLen) */
-                       NdisMoveMemory(pHeaderBufPtr, pTxBlk->pSrcBufData - 2,
-                                      2);
-                       pHeaderBufPtr += 2;
-                       pTxBlk->MpduHeaderLen += LENGTH_802_1_H;
-                       subFramePayloadLen += LENGTH_802_1_H;
-               }
-               /* update subFrame Length field */
-               subFrameHeader[12] = (subFramePayloadLen & 0xFF00) >> 8;
-               subFrameHeader[13] = subFramePayloadLen & 0xFF;
-
-               totalMPDUSize += pTxBlk->MpduHeaderLen + pTxBlk->SrcBufLen;
-
-               if (frameNum == 0)
-                       FirstTx =
-                           HAL_WriteMultiTxResource(pAd, pTxBlk, frameNum,
-                                                    &FreeNumber);
-               else
-                       LastTxIdx =
-                           HAL_WriteMultiTxResource(pAd, pTxBlk, frameNum,
-                                                    &FreeNumber);
-
-               frameNum++;
-
-               pAd->RalinkCounters.KickTxCount++;
-               pAd->RalinkCounters.OneSecTxDoneCount++;
-
-               /* calculate Transmitted AMSDU Count and ByteCount */
-               {
-                       pAd->RalinkCounters.TransmittedAMSDUCount.u.LowPart++;
-                       pAd->RalinkCounters.TransmittedOctetsInAMSDU.QuadPart +=
-                           totalMPDUSize;
-               }
-
-       }
-
-       HAL_FinalWriteTxResource(pAd, pTxBlk, totalMPDUSize, FirstTx);
-       HAL_LastTxIdx(pAd, pTxBlk->QueIdx, LastTxIdx);
-
-       /* */
-       /* Kick out Tx */
-       /* */
-       if (!RTMP_TEST_PSFLAG(pAd, fRTMP_PS_DISABLE_TX))
-               HAL_KickOutTx(pAd, pTxBlk, pTxBlk->QueIdx);
-}
-
-void STA_Legacy_Frame_Tx(struct rt_rtmp_adapter *pAd, struct rt_tx_blk *pTxBlk)
-{
-       struct rt_header_802_11 *pHeader_802_11;
-       u8 *pHeaderBufPtr;
-       u16 FreeNumber;
-       BOOLEAN bVLANPkt;
-       struct rt_queue_entry *pQEntry;
-
-       ASSERT(pTxBlk);
-
-       pQEntry = RemoveHeadQueue(&pTxBlk->TxPacketList);
-       pTxBlk->pPacket = QUEUE_ENTRY_TO_PACKET(pQEntry);
-       if (RTMP_FillTxBlkInfo(pAd, pTxBlk) != TRUE) {
-               RELEASE_NDIS_PACKET(pAd, pTxBlk->pPacket, NDIS_STATUS_FAILURE);
-               return;
-       }
-
-       if (pTxBlk->TxFrameType == TX_MCAST_FRAME) {
-               INC_COUNTER64(pAd->WlanCounters.MulticastTransmittedFrameCount);
-       }
-
-       if (RTMP_GET_PACKET_RTS(pTxBlk->pPacket))
-               TX_BLK_SET_FLAG(pTxBlk, fTX_bRtsRequired);
-       else
-               TX_BLK_CLEAR_FLAG(pTxBlk, fTX_bRtsRequired);
-
-       bVLANPkt = (RTMP_GET_PACKET_VLAN(pTxBlk->pPacket) ? TRUE : FALSE);
-
-       if (pTxBlk->TxRate < pAd->CommonCfg.MinTxRate)
-               pTxBlk->TxRate = pAd->CommonCfg.MinTxRate;
-
-       STAFindCipherAlgorithm(pAd, pTxBlk);
-       STABuildCommon802_11Header(pAd, pTxBlk);
-
-       /* skip 802.3 header */
-       pTxBlk->pSrcBufData = pTxBlk->pSrcBufHeader + LENGTH_802_3;
-       pTxBlk->SrcBufLen -= LENGTH_802_3;
-
-       /* skip vlan tag */
-       if (bVLANPkt) {
-               pTxBlk->pSrcBufData += LENGTH_802_1Q;
-               pTxBlk->SrcBufLen -= LENGTH_802_1Q;
-       }
-
-       pHeaderBufPtr = &pTxBlk->HeaderBuf[TXINFO_SIZE + TXWI_SIZE];
-       pHeader_802_11 = (struct rt_header_802_11 *) pHeaderBufPtr;
-
-       /* skip common header */
-       pHeaderBufPtr += pTxBlk->MpduHeaderLen;
-
-       if (TX_BLK_TEST_FLAG(pTxBlk, fTX_bWMM)) {
-               /* */
-               /* build QOS Control bytes */
-               /* */
-               *(pHeaderBufPtr) =
-                   ((pTxBlk->UserPriority & 0x0F) | (pAd->CommonCfg.
-                                                     AckPolicy[pTxBlk->
-                                                               QueIdx] << 5));
-               *(pHeaderBufPtr + 1) = 0;
-               pHeaderBufPtr += 2;
-               pTxBlk->MpduHeaderLen += 2;
-       }
-       /* The remaining content of MPDU header should locate at 4-octets alignment */
-       pTxBlk->HdrPadLen = (unsigned long)pHeaderBufPtr;
-       pHeaderBufPtr = (u8 *)ROUND_UP(pHeaderBufPtr, 4);
-       pTxBlk->HdrPadLen = (unsigned long)(pHeaderBufPtr - pTxBlk->HdrPadLen);
-
-       {
-
-               /* */
-               /* Insert LLC-SNAP encapsulation - 8 octets */
-               /* */
-               /* */
-               /* if original Ethernet frame contains no LLC/SNAP, */
-               /* then an extra LLC/SNAP encap is required */
-               /* */
-               EXTRA_LLCSNAP_ENCAP_FROM_PKT_START(pTxBlk->pSrcBufHeader,
-                                                  pTxBlk->pExtraLlcSnapEncap);
-               if (pTxBlk->pExtraLlcSnapEncap) {
-                       u8 vlan_size;
-
-                       NdisMoveMemory(pHeaderBufPtr,
-                                      pTxBlk->pExtraLlcSnapEncap, 6);
-                       pHeaderBufPtr += 6;
-                       /* skip vlan tag */
-                       vlan_size = (bVLANPkt) ? LENGTH_802_1Q : 0;
-                       /* get 2 octets (TypeofLen) */
-                       NdisMoveMemory(pHeaderBufPtr,
-                                      pTxBlk->pSrcBufHeader + 12 + vlan_size,
-                                      2);
-                       pHeaderBufPtr += 2;
-                       pTxBlk->MpduHeaderLen += LENGTH_802_1_H;
-               }
-
-       }
-
-       /* */
-       /* prepare for TXWI */
-       /* use Wcid as Key Index */
-       /* */
-
-       RTMPWriteTxWI_Data(pAd, (struct rt_txwi *) (&pTxBlk->HeaderBuf[TXINFO_SIZE]),
-                          pTxBlk);
-
-       /*FreeNumber = GET_TXRING_FREENO(pAd, QueIdx); */
-
-       HAL_WriteTxResource(pAd, pTxBlk, TRUE, &FreeNumber);
-
-       pAd->RalinkCounters.KickTxCount++;
-       pAd->RalinkCounters.OneSecTxDoneCount++;
-
-       /* */
-       /* Kick out Tx */
-       /* */
-       if (!RTMP_TEST_PSFLAG(pAd, fRTMP_PS_DISABLE_TX))
-               HAL_KickOutTx(pAd, pTxBlk, pTxBlk->QueIdx);
-}
-
-void STA_ARalink_Frame_Tx(struct rt_rtmp_adapter *pAd, struct rt_tx_blk *pTxBlk)
-{
-       u8 *pHeaderBufPtr;
-       u16 FreeNumber;
-       u16 totalMPDUSize = 0;
-       u16 FirstTx, LastTxIdx;
-       int frameNum = 0;
-       BOOLEAN bVLANPkt;
-       struct rt_queue_entry *pQEntry;
-
-       ASSERT(pTxBlk);
-
-       ASSERT((pTxBlk->TxPacketList.Number == 2));
-
-       FirstTx = LastTxIdx = 0;        /* Is it ok init they as 0? */
-       while (pTxBlk->TxPacketList.Head) {
-               pQEntry = RemoveHeadQueue(&pTxBlk->TxPacketList);
-               pTxBlk->pPacket = QUEUE_ENTRY_TO_PACKET(pQEntry);
-
-               if (RTMP_FillTxBlkInfo(pAd, pTxBlk) != TRUE) {
-                       RELEASE_NDIS_PACKET(pAd, pTxBlk->pPacket,
-                                           NDIS_STATUS_FAILURE);
-                       continue;
-               }
-
-               bVLANPkt =
-                   (RTMP_GET_PACKET_VLAN(pTxBlk->pPacket) ? TRUE : FALSE);
-
-               /* skip 802.3 header */
-               pTxBlk->pSrcBufData = pTxBlk->pSrcBufHeader + LENGTH_802_3;
-               pTxBlk->SrcBufLen -= LENGTH_802_3;
-
-               /* skip vlan tag */
-               if (bVLANPkt) {
-                       pTxBlk->pSrcBufData += LENGTH_802_1Q;
-                       pTxBlk->SrcBufLen -= LENGTH_802_1Q;
-               }
-
-               if (frameNum == 0) {    /* For first frame, we need to create the 802.11 header + padding(optional) + RA-AGG-LEN + SNAP Header */
-
-                       pHeaderBufPtr =
-                           STA_Build_ARalink_Frame_Header(pAd, pTxBlk);
-
-                       /* It's ok write the TxWI here, because the TxWI->MPDUtotalByteCount */
-                       /* will be updated after final frame was handled. */
-                       RTMPWriteTxWI_Data(pAd,
-                                          (struct rt_txwi *) (&pTxBlk->
-                                                         HeaderBuf
-                                                         [TXINFO_SIZE]),
-                                          pTxBlk);
-
-                       /* */
-                       /* Insert LLC-SNAP encapsulation - 8 octets */
-                       /* */
-                       EXTRA_LLCSNAP_ENCAP_FROM_PKT_OFFSET(pTxBlk->
-                                                           pSrcBufData - 2,
-                                                           pTxBlk->
-                                                           pExtraLlcSnapEncap);
-
-                       if (pTxBlk->pExtraLlcSnapEncap) {
-                               NdisMoveMemory(pHeaderBufPtr,
-                                              pTxBlk->pExtraLlcSnapEncap, 6);
-                               pHeaderBufPtr += 6;
-                               /* get 2 octets (TypeofLen) */
-                               NdisMoveMemory(pHeaderBufPtr,
-                                              pTxBlk->pSrcBufData - 2, 2);
-                               pHeaderBufPtr += 2;
-                               pTxBlk->MpduHeaderLen += LENGTH_802_1_H;
-                       }
-               } else {        /* For second aggregated frame, we need create the 802.3 header to headerBuf, because PCI will copy it to SDPtr0. */
-
-                       pHeaderBufPtr = &pTxBlk->HeaderBuf[0];
-                       pTxBlk->MpduHeaderLen = 0;
-
-                       /* A-Ralink sub-sequent frame header is the same as 802.3 header. */
-                       /*   DA(6)+SA(6)+FrameType(2) */
-                       NdisMoveMemory(pHeaderBufPtr, pTxBlk->pSrcBufHeader,
-                                      12);
-                       pHeaderBufPtr += 12;
-                       /* get 2 octets (TypeofLen) */
-                       NdisMoveMemory(pHeaderBufPtr, pTxBlk->pSrcBufData - 2,
-                                      2);
-                       pHeaderBufPtr += 2;
-                       pTxBlk->MpduHeaderLen = LENGTH_ARALINK_SUBFRAMEHEAD;
-               }
-
-               totalMPDUSize += pTxBlk->MpduHeaderLen + pTxBlk->SrcBufLen;
-
-               /*FreeNumber = GET_TXRING_FREENO(pAd, QueIdx); */
-               if (frameNum == 0)
-                       FirstTx =
-                           HAL_WriteMultiTxResource(pAd, pTxBlk, frameNum,
-                                                    &FreeNumber);
-               else
-                       LastTxIdx =
-                           HAL_WriteMultiTxResource(pAd, pTxBlk, frameNum,
-                                                    &FreeNumber);
-
-               frameNum++;
-
-               pAd->RalinkCounters.OneSecTxAggregationCount++;
-               pAd->RalinkCounters.KickTxCount++;
-               pAd->RalinkCounters.OneSecTxDoneCount++;
-
-       }
-
-       HAL_FinalWriteTxResource(pAd, pTxBlk, totalMPDUSize, FirstTx);
-       HAL_LastTxIdx(pAd, pTxBlk->QueIdx, LastTxIdx);
-
-       /* */
-       /* Kick out Tx */
-       /* */
-       if (!RTMP_TEST_PSFLAG(pAd, fRTMP_PS_DISABLE_TX))
-               HAL_KickOutTx(pAd, pTxBlk, pTxBlk->QueIdx);
-
-}
-
-void STA_Fragment_Frame_Tx(struct rt_rtmp_adapter *pAd, struct rt_tx_blk *pTxBlk)
-{
-       struct rt_header_802_11 *pHeader_802_11;
-       u8 *pHeaderBufPtr;
-       u16 FreeNumber;
-       u8 fragNum = 0;
-       struct rt_packet_info PacketInfo;
-       u16 EncryptionOverhead = 0;
-       u32 FreeMpduSize, SrcRemainingBytes;
-       u16 AckDuration;
-       u32 NextMpduSize;
-       BOOLEAN bVLANPkt;
-       struct rt_queue_entry *pQEntry;
-       HTTRANSMIT_SETTING *pTransmit;
-
-       ASSERT(pTxBlk);
-
-       pQEntry = RemoveHeadQueue(&pTxBlk->TxPacketList);
-       pTxBlk->pPacket = QUEUE_ENTRY_TO_PACKET(pQEntry);
-       if (RTMP_FillTxBlkInfo(pAd, pTxBlk) != TRUE) {
-               RELEASE_NDIS_PACKET(pAd, pTxBlk->pPacket, NDIS_STATUS_FAILURE);
-               return;
-       }
-
-       ASSERT(TX_BLK_TEST_FLAG(pTxBlk, fTX_bAllowFrag));
-       bVLANPkt = (RTMP_GET_PACKET_VLAN(pTxBlk->pPacket) ? TRUE : FALSE);
-
-       STAFindCipherAlgorithm(pAd, pTxBlk);
-       STABuildCommon802_11Header(pAd, pTxBlk);
-
-       if (pTxBlk->CipherAlg == CIPHER_TKIP) {
-               pTxBlk->pPacket =
-                   duplicate_pkt_with_TKIP_MIC(pAd, pTxBlk->pPacket);
-               if (pTxBlk->pPacket == NULL)
-                       return;
-               RTMP_QueryPacketInfo(pTxBlk->pPacket, &PacketInfo,
-                                    &pTxBlk->pSrcBufHeader,
-                                    &pTxBlk->SrcBufLen);
-       }
-       /* skip 802.3 header */
-       pTxBlk->pSrcBufData = pTxBlk->pSrcBufHeader + LENGTH_802_3;
-       pTxBlk->SrcBufLen -= LENGTH_802_3;
-
-       /* skip vlan tag */
-       if (bVLANPkt) {
-               pTxBlk->pSrcBufData += LENGTH_802_1Q;
-               pTxBlk->SrcBufLen -= LENGTH_802_1Q;
-       }
-
-       pHeaderBufPtr = &pTxBlk->HeaderBuf[TXINFO_SIZE + TXWI_SIZE];
-       pHeader_802_11 = (struct rt_header_802_11 *) pHeaderBufPtr;
-
-       /* skip common header */
-       pHeaderBufPtr += pTxBlk->MpduHeaderLen;
-
-       if (TX_BLK_TEST_FLAG(pTxBlk, fTX_bWMM)) {
-               /* */
-               /* build QOS Control bytes */
-               /* */
-               *pHeaderBufPtr = (pTxBlk->UserPriority & 0x0F);
-
-               *(pHeaderBufPtr + 1) = 0;
-               pHeaderBufPtr += 2;
-               pTxBlk->MpduHeaderLen += 2;
-       }
-       /* */
-       /* padding at front of LLC header */
-       /* LLC header should locate at 4-octets aligment */
-       /* */
-       pTxBlk->HdrPadLen = (unsigned long)pHeaderBufPtr;
-       pHeaderBufPtr = (u8 *)ROUND_UP(pHeaderBufPtr, 4);
-       pTxBlk->HdrPadLen = (unsigned long)(pHeaderBufPtr - pTxBlk->HdrPadLen);
-
-       /* */
-       /* Insert LLC-SNAP encapsulation - 8 octets */
-       /* */
-       /* */
-       /* if original Ethernet frame contains no LLC/SNAP, */
-       /* then an extra LLC/SNAP encap is required */
-       /* */
-       EXTRA_LLCSNAP_ENCAP_FROM_PKT_START(pTxBlk->pSrcBufHeader,
-                                          pTxBlk->pExtraLlcSnapEncap);
-       if (pTxBlk->pExtraLlcSnapEncap) {
-               u8 vlan_size;
-
-               NdisMoveMemory(pHeaderBufPtr, pTxBlk->pExtraLlcSnapEncap, 6);
-               pHeaderBufPtr += 6;
-               /* skip vlan tag */
-               vlan_size = (bVLANPkt) ? LENGTH_802_1Q : 0;
-               /* get 2 octets (TypeofLen) */
-               NdisMoveMemory(pHeaderBufPtr,
-                              pTxBlk->pSrcBufHeader + 12 + vlan_size, 2);
-               pHeaderBufPtr += 2;
-               pTxBlk->MpduHeaderLen += LENGTH_802_1_H;
-       }
-
-       /* If TKIP is used and fragmentation is required. Driver has to */
-       /*      append TKIP MIC at tail of the scatter buffer */
-       /*      MAC ASIC will only perform IV/EIV/ICV insertion but no TKIP MIC */
-       if (pTxBlk->CipherAlg == CIPHER_TKIP) {
-               RTMPCalculateMICValue(pAd, pTxBlk->pPacket,
-                                     pTxBlk->pExtraLlcSnapEncap, pTxBlk->pKey,
-                                     0);
-
-               /* NOTE: DON'T refer the skb->len directly after following copy. Because the length is not adjusted */
-               /*                      to correct length, refer to pTxBlk->SrcBufLen for the packet length in following progress. */
-               NdisMoveMemory(pTxBlk->pSrcBufData + pTxBlk->SrcBufLen,
-                              &pAd->PrivateInfo.Tx.MIC[0], 8);
-               /*skb_put((RTPKT_TO_OSPKT(pTxBlk->pPacket))->tail, 8); */
-               pTxBlk->SrcBufLen += 8;
-               pTxBlk->TotalFrameLen += 8;
-               pTxBlk->CipherAlg = CIPHER_TKIP_NO_MIC;
-       }
-       /* */
-       /* calculate the overhead bytes that encryption algorithm may add. This */
-       /* affects the calculate of "duration" field */
-       /* */
-       if ((pTxBlk->CipherAlg == CIPHER_WEP64)
-           || (pTxBlk->CipherAlg == CIPHER_WEP128))
-               EncryptionOverhead = 8; /*WEP: IV[4] + ICV[4]; */
-       else if (pTxBlk->CipherAlg == CIPHER_TKIP_NO_MIC)
-               EncryptionOverhead = 12;        /*TKIP: IV[4] + EIV[4] + ICV[4], MIC will be added to TotalPacketLength */
-       else if (pTxBlk->CipherAlg == CIPHER_TKIP)
-               EncryptionOverhead = 20;        /*TKIP: IV[4] + EIV[4] + ICV[4] + MIC[8] */
-       else if (pTxBlk->CipherAlg == CIPHER_AES)
-               EncryptionOverhead = 16;        /* AES: IV[4] + EIV[4] + MIC[8] */
-       else
-               EncryptionOverhead = 0;
-
-       pTransmit = pTxBlk->pTransmit;
-       /* Decide the TX rate */
-       if (pTransmit->field.MODE == MODE_CCK)
-               pTxBlk->TxRate = pTransmit->field.MCS;
-       else if (pTransmit->field.MODE == MODE_OFDM)
-               pTxBlk->TxRate = pTransmit->field.MCS + RATE_FIRST_OFDM_RATE;
-       else
-               pTxBlk->TxRate = RATE_6_5;
-
-       /* decide how much time an ACK/CTS frame will consume in the air */
-       if (pTxBlk->TxRate <= RATE_LAST_OFDM_RATE)
-               AckDuration =
-                   RTMPCalcDuration(pAd,
-                                    pAd->CommonCfg.ExpectedACKRate[pTxBlk->
-                                                                   TxRate],
-                                    14);
-       else
-               AckDuration = RTMPCalcDuration(pAd, RATE_6_5, 14);
-
-       /* Init the total payload length of this frame. */
-       SrcRemainingBytes = pTxBlk->SrcBufLen;
-
-       pTxBlk->TotalFragNum = 0xff;
-
-       do {
-
-               FreeMpduSize = pAd->CommonCfg.FragmentThreshold - LENGTH_CRC;
-
-               FreeMpduSize -= pTxBlk->MpduHeaderLen;
-
-               if (SrcRemainingBytes <= FreeMpduSize) {        /* this is the last or only fragment */
-
-                       pTxBlk->SrcBufLen = SrcRemainingBytes;
-
-                       pHeader_802_11->FC.MoreFrag = 0;
-                       pHeader_802_11->Duration =
-                           pAd->CommonCfg.Dsifs + AckDuration;
-
-                       /* Indicate the lower layer that this's the last fragment. */
-                       pTxBlk->TotalFragNum = fragNum;
-               } else {        /* more fragment is required */
-
-                       pTxBlk->SrcBufLen = FreeMpduSize;
-
-                       NextMpduSize =
-                           min(((u32)SrcRemainingBytes - pTxBlk->SrcBufLen),
-                               ((u32)pAd->CommonCfg.FragmentThreshold));
-                       pHeader_802_11->FC.MoreFrag = 1;
-                       pHeader_802_11->Duration =
-                           (3 * pAd->CommonCfg.Dsifs) + (2 * AckDuration) +
-                           RTMPCalcDuration(pAd, pTxBlk->TxRate,
-                                            NextMpduSize + EncryptionOverhead);
-               }
-
-               if (fragNum == 0)
-                       pTxBlk->FrameGap = IFS_HTTXOP;
-               else
-                       pTxBlk->FrameGap = IFS_SIFS;
-
-               RTMPWriteTxWI_Data(pAd,
-                                  (struct rt_txwi *) (&pTxBlk->
-                                                 HeaderBuf[TXINFO_SIZE]),
-                                  pTxBlk);
-
-               HAL_WriteFragTxResource(pAd, pTxBlk, fragNum, &FreeNumber);
-
-               pAd->RalinkCounters.KickTxCount++;
-               pAd->RalinkCounters.OneSecTxDoneCount++;
-
-               /* Update the frame number, remaining size of the NDIS packet payload. */
-
-               /* space for 802.11 header. */
-               if (fragNum == 0 && pTxBlk->pExtraLlcSnapEncap)
-                       pTxBlk->MpduHeaderLen -= LENGTH_802_1_H;
-
-               fragNum++;
-               SrcRemainingBytes -= pTxBlk->SrcBufLen;
-               pTxBlk->pSrcBufData += pTxBlk->SrcBufLen;
-
-               pHeader_802_11->Frag++; /* increase Frag # */
-
-       } while (SrcRemainingBytes > 0);
-
-       /* */
-       /* Kick out Tx */
-       /* */
-       if (!RTMP_TEST_PSFLAG(pAd, fRTMP_PS_DISABLE_TX))
-               HAL_KickOutTx(pAd, pTxBlk, pTxBlk->QueIdx);
-}
-
-#define RELEASE_FRAMES_OF_TXBLK(_pAd, _pTxBlk, _pQEntry, _Status)                                                                              \
-               while(_pTxBlk->TxPacketList.Head)                                                                                                               \
-               {                                                                                                                                                                               \
-                       _pQEntry = RemoveHeadQueue(&_pTxBlk->TxPacketList);                                                                     \
-                       RELEASE_NDIS_PACKET(_pAd, QUEUE_ENTRY_TO_PACKET(_pQEntry), _Status);    \
-               }
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Copy frame from waiting queue into relative ring buffer and set
-       appropriate ASIC register to kick hardware encryption before really
-       sent out to air.
-
-       Arguments:
-               pAd     Pointer to our adapter
-               void *  Pointer to outgoing Ndis frame
-               NumberOfFrag    Number of fragment required
-
-       Return Value:
-               None
-
-       IRQL = DISPATCH_LEVEL
-
-       Note:
-
-       ========================================================================
-*/
-int STAHardTransmit(struct rt_rtmp_adapter *pAd,
-                           struct rt_tx_blk *pTxBlk, u8 QueIdx)
-{
-       char *pPacket;
-       struct rt_queue_entry *pQEntry;
-
-       /* --------------------------------------------- */
-       /* STEP 0. DO SANITY CHECK AND SOME EARLY PREPARATION. */
-       /* --------------------------------------------- */
-       /* */
-       ASSERT(pTxBlk->TxPacketList.Number);
-       if (pTxBlk->TxPacketList.Head == NULL) {
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("pTxBlk->TotalFrameNum == %ld!\n",
-                         pTxBlk->TxPacketList.Number));
-               return NDIS_STATUS_FAILURE;
-       }
-
-       pPacket = QUEUE_ENTRY_TO_PACKET(pTxBlk->TxPacketList.Head);
-
-       /* ------------------------------------------------------------------ */
-       /* STEP 1. WAKE UP PHY */
-       /*              outgoing frame always wakeup PHY to prevent frame lost and */
-       /*              turn off PSM bit to improve performance */
-       /* ------------------------------------------------------------------ */
-       /* not to change PSM bit, just send this frame out? */
-       if ((pAd->StaCfg.Psm == PWR_SAVE)
-           && OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE)) {
-               DBGPRINT_RAW(RT_DEBUG_INFO, ("AsicForceWakeup At HardTx\n"));
-#ifdef RTMP_MAC_PCI
-               AsicForceWakeup(pAd, TRUE);
-#endif /* RTMP_MAC_PCI // */
-#ifdef RTMP_MAC_USB
-               RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_FORCE_WAKE_UP, NULL, 0);
-#endif /* RTMP_MAC_USB // */
-       }
-       /* It should not change PSM bit, when APSD turn on. */
-       if ((!
-            (pAd->CommonCfg.bAPSDCapable
-             && pAd->CommonCfg.APEdcaParm.bAPSDCapable)
-            && (pAd->CommonCfg.bAPSDForcePowerSave == FALSE))
-           || (RTMP_GET_PACKET_EAPOL(pTxBlk->pPacket))
-           || (RTMP_GET_PACKET_WAI(pTxBlk->pPacket))) {
-               if ((pAd->StaCfg.Psm == PWR_SAVE) &&
-                   (pAd->StaCfg.WindowsPowerMode ==
-                    Ndis802_11PowerModeFast_PSP))
-                       RTMP_SET_PSM_BIT(pAd, PWR_ACTIVE);
-       }
-
-       switch (pTxBlk->TxFrameType) {
-       case TX_AMPDU_FRAME:
-               STA_AMPDU_Frame_Tx(pAd, pTxBlk);
-               break;
-       case TX_AMSDU_FRAME:
-               STA_AMSDU_Frame_Tx(pAd, pTxBlk);
-               break;
-       case TX_LEGACY_FRAME:
-               STA_Legacy_Frame_Tx(pAd, pTxBlk);
-               break;
-       case TX_MCAST_FRAME:
-               STA_Legacy_Frame_Tx(pAd, pTxBlk);
-               break;
-       case TX_RALINK_FRAME:
-               STA_ARalink_Frame_Tx(pAd, pTxBlk);
-               break;
-       case TX_FRAG_FRAME:
-               STA_Fragment_Frame_Tx(pAd, pTxBlk);
-               break;
-       default:
-               {
-                       /* It should not happened! */
-                       DBGPRINT(RT_DEBUG_ERROR,
-                                ("Send a packet was not classified! It should not happen!\n"));
-                       while (pTxBlk->TxPacketList.Number) {
-                               pQEntry =
-                                   RemoveHeadQueue(&pTxBlk->TxPacketList);
-                               pPacket = QUEUE_ENTRY_TO_PACKET(pQEntry);
-                               if (pPacket)
-                                       RELEASE_NDIS_PACKET(pAd, pPacket,
-                                                           NDIS_STATUS_FAILURE);
-                       }
-               }
-               break;
-       }
-
-       return (NDIS_STATUS_SUCCESS);
-
-}
-
-unsigned long HashBytesPolynomial(u8 * value, unsigned int len)
-{
-       unsigned char *word = value;
-       unsigned int ret = 0;
-       unsigned int i;
-
-       for (i = 0; i < len; i++) {
-               int mod = i % 32;
-               ret ^= (unsigned int)(word[i]) << mod;
-               ret ^= (unsigned int)(word[i]) >> (32 - mod);
-       }
-       return ret;
-}
-
-void Sta_Announce_or_Forward_802_3_Packet(struct rt_rtmp_adapter *pAd,
-                                         void *pPacket,
-                                         u8 FromWhichBSSID)
-{
-       if (TRUE) {
-               announce_802_3_packet(pAd, pPacket);
-       } else {
-               /* release packet */
-               RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
-       }
-}
diff --git a/drivers/staging/rt2860/sta/sanity.c b/drivers/staging/rt2860/sta/sanity.c
deleted file mode 100644 (file)
index 0c32604..0000000
+++ /dev/null
@@ -1,362 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-       Module Name:
-       sanity.c
-
-       Abstract:
-
-       Revision History:
-       Who                     When                    What
-       --------        ----------              ----------------------------------------------
-       John Chang              2004-09-01      add WMM support
-       Justin P. Mattock       11/07/2010      Fix typos
-*/
-#include "../rt_config.h"
-
-extern u8 CISCO_OUI[];
-
-extern u8 WPA_OUI[];
-extern u8 RSN_OUI[];
-extern u8 WME_INFO_ELEM[];
-extern u8 WME_PARM_ELEM[];
-extern u8 Ccx2QosInfo[];
-extern u8 RALINK_OUI[];
-extern u8 BROADCOM_OUI[];
-
-/*
-    ==========================================================================
-    Description:
-        MLME message sanity check
-    Return:
-        TRUE if all parameters are OK, FALSE otherwise
-    ==========================================================================
- */
-BOOLEAN MlmeStartReqSanity(struct rt_rtmp_adapter *pAd,
-                          void * Msg,
-                          unsigned long MsgLen,
-                          char Ssid[], u8 * pSsidLen)
-{
-       struct rt_mlme_start_req *Info;
-
-       Info = (struct rt_mlme_start_req *)(Msg);
-
-       if (Info->SsidLen > MAX_LEN_OF_SSID) {
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("MlmeStartReqSanity fail - wrong SSID length\n"));
-               return FALSE;
-       }
-
-       *pSsidLen = Info->SsidLen;
-       NdisMoveMemory(Ssid, Info->Ssid, *pSsidLen);
-
-       return TRUE;
-}
-
-/*
-    ==========================================================================
-    Description:
-        MLME message sanity check
-    Return:
-        TRUE if all parameters are OK, FALSE otherwise
-
-    IRQL = DISPATCH_LEVEL
-
-    ==========================================================================
- */
-BOOLEAN PeerAssocRspSanity(struct rt_rtmp_adapter *pAd, void * pMsg, unsigned long MsgLen, u8 *pAddr2, u16 * pCapabilityInfo, u16 * pStatus, u16 * pAid, u8 SupRate[], u8 * pSupRateLen, u8 ExtRate[], u8 * pExtRateLen, struct rt_ht_capability_ie * pHtCapability, struct rt_add_ht_info_ie * pAddHtInfo,    /* AP might use this additional ht info IE */
-                          u8 * pHtCapabilityLen,
-                          u8 * pAddHtInfoLen,
-                          u8 * pNewExtChannelOffset,
-                          struct rt_edca_parm *pEdcaParm, u8 * pCkipFlag)
-{
-       char IeType, *Ptr;
-       struct rt_frame_802_11 * pFrame = (struct rt_frame_802_11 *) pMsg;
-       struct rt_eid * pEid;
-       unsigned long Length = 0;
-
-       *pNewExtChannelOffset = 0xff;
-       *pHtCapabilityLen = 0;
-       *pAddHtInfoLen = 0;
-       COPY_MAC_ADDR(pAddr2, pFrame->Hdr.Addr2);
-       Ptr = (char *)pFrame->Octet;
-       Length += LENGTH_802_11;
-
-       NdisMoveMemory(pCapabilityInfo, &pFrame->Octet[0], 2);
-       Length += 2;
-       NdisMoveMemory(pStatus, &pFrame->Octet[2], 2);
-       Length += 2;
-       *pCkipFlag = 0;
-       *pExtRateLen = 0;
-       pEdcaParm->bValid = FALSE;
-
-       if (*pStatus != MLME_SUCCESS)
-               return TRUE;
-
-       NdisMoveMemory(pAid, &pFrame->Octet[4], 2);
-       Length += 2;
-
-       /* Aid already swapped byte order in RTMPFrameEndianChange() for big endian platform */
-       *pAid = (*pAid) & 0x3fff;       /* AID is low 14-bit */
-
-       /* -- get supported rates from payload and advance the pointer */
-       IeType = pFrame->Octet[6];
-       *pSupRateLen = pFrame->Octet[7];
-       if ((IeType != IE_SUPP_RATES)
-           || (*pSupRateLen > MAX_LEN_OF_SUPPORTED_RATES)) {
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("PeerAssocRspSanity fail - wrong SupportedRates IE\n"));
-               return FALSE;
-       } else
-               NdisMoveMemory(SupRate, &pFrame->Octet[8], *pSupRateLen);
-
-       Length = Length + 2 + *pSupRateLen;
-
-       /* many AP implement proprietary IEs in non-standard order, we'd better */
-       /* tolerate mis-ordered IEs to get best compatibility */
-       pEid = (struct rt_eid *) & pFrame->Octet[8 + (*pSupRateLen)];
-
-       /* get variable fields from payload and advance the pointer */
-       while ((Length + 2 + pEid->Len) <= MsgLen) {
-               switch (pEid->Eid) {
-               case IE_EXT_SUPP_RATES:
-                       if (pEid->Len <= MAX_LEN_OF_SUPPORTED_RATES) {
-                               NdisMoveMemory(ExtRate, pEid->Octet, pEid->Len);
-                               *pExtRateLen = pEid->Len;
-                       }
-                       break;
-
-               case IE_HT_CAP:
-               case IE_HT_CAP2:
-                       if (pEid->Len >= SIZE_HT_CAP_IE)        /*Note: allow extension! */
-                       {
-                               NdisMoveMemory(pHtCapability, pEid->Octet,
-                                              SIZE_HT_CAP_IE);
-
-                               *(u16 *) (&pHtCapability->HtCapInfo) =
-                                   cpu2le16(*(u16 *)
-                                            (&pHtCapability->HtCapInfo));
-                               *(u16 *) (&pHtCapability->ExtHtCapInfo) =
-                                   cpu2le16(*(u16 *)
-                                            (&pHtCapability->ExtHtCapInfo));
-
-                               *pHtCapabilityLen = SIZE_HT_CAP_IE;
-                       } else {
-                               DBGPRINT(RT_DEBUG_WARN,
-                                        ("PeerAssocRspSanity - wrong IE_HT_CAP. \n"));
-                       }
-
-                       break;
-               case IE_ADD_HT:
-               case IE_ADD_HT2:
-                       if (pEid->Len >= sizeof(struct rt_add_ht_info_ie)) {
-                               /* This IE allows extension, but we can ignore extra bytes beyond our knowledge , so only */
-                               /* copy first sizeof(struct rt_add_ht_info_ie) */
-                               NdisMoveMemory(pAddHtInfo, pEid->Octet,
-                                              sizeof(struct rt_add_ht_info_ie));
-
-                               *(u16 *) (&pAddHtInfo->AddHtInfo2) =
-                                   cpu2le16(*(u16 *)
-                                            (&pAddHtInfo->AddHtInfo2));
-                               *(u16 *) (&pAddHtInfo->AddHtInfo3) =
-                                   cpu2le16(*(u16 *)
-                                            (&pAddHtInfo->AddHtInfo3));
-
-                               *pAddHtInfoLen = SIZE_ADD_HT_INFO_IE;
-                       } else {
-                               DBGPRINT(RT_DEBUG_WARN,
-                                        ("PeerAssocRspSanity - wrong IE_ADD_HT. \n"));
-                       }
-
-                       break;
-               case IE_SECONDARY_CH_OFFSET:
-                       if (pEid->Len == 1) {
-                               *pNewExtChannelOffset = pEid->Octet[0];
-                       } else {
-                               DBGPRINT(RT_DEBUG_WARN,
-                                        ("PeerAssocRspSanity - wrong IE_SECONDARY_CH_OFFSET. \n"));
-                       }
-                       break;
-
-               case IE_VENDOR_SPECIFIC:
-                       /* handle WME PARAMTER ELEMENT */
-                       if (NdisEqualMemory(pEid->Octet, WME_PARM_ELEM, 6)
-                           && (pEid->Len == 24)) {
-                               u8 *ptr;
-                               int i;
-
-                               /* parsing EDCA parameters */
-                               pEdcaParm->bValid = TRUE;
-                               pEdcaParm->bQAck = FALSE;       /* pEid->Octet[0] & 0x10; */
-                               pEdcaParm->bQueueRequest = FALSE;       /* pEid->Octet[0] & 0x20; */
-                               pEdcaParm->bTxopRequest = FALSE;        /* pEid->Octet[0] & 0x40; */
-                               /*pEdcaParm->bMoreDataAck    = FALSE; // pEid->Octet[0] & 0x80; */
-                               pEdcaParm->EdcaUpdateCount =
-                                   pEid->Octet[6] & 0x0f;
-                               pEdcaParm->bAPSDCapable =
-                                   (pEid->Octet[6] & 0x80) ? 1 : 0;
-                               ptr = (u8 *)& pEid->Octet[8];
-                               for (i = 0; i < 4; i++) {
-                                       u8 aci = (*ptr & 0x60) >> 5;    /* b5~6 is AC INDEX */
-                                       pEdcaParm->bACM[aci] = (((*ptr) & 0x10) == 0x10);       /* b5 is ACM */
-                                       pEdcaParm->Aifsn[aci] = (*ptr) & 0x0f;  /* b0~3 is AIFSN */
-                                       pEdcaParm->Cwmin[aci] = *(ptr + 1) & 0x0f;      /* b0~4 is Cwmin */
-                                       pEdcaParm->Cwmax[aci] = *(ptr + 1) >> 4;        /* b5~8 is Cwmax */
-                                       pEdcaParm->Txop[aci] = *(ptr + 2) + 256 * (*(ptr + 3)); /* in unit of 32-us */
-                                       ptr += 4;       /* point to next AC */
-                               }
-                       }
-                       break;
-               default:
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("PeerAssocRspSanity - ignore unrecognized EID = %d\n",
-                                 pEid->Eid));
-                       break;
-               }
-
-               Length = Length + 2 + pEid->Len;
-               pEid = (struct rt_eid *) ((u8 *) pEid + 2 + pEid->Len);
-       }
-
-       return TRUE;
-}
-
-/*
-    ==========================================================================
-    Description:
-        MLME message sanity check
-    Return:
-        TRUE if all parameters are OK, FALSE otherwise
-
-       IRQL = DISPATCH_LEVEL
-
-    ==========================================================================
- */
-BOOLEAN PeerProbeReqSanity(struct rt_rtmp_adapter *pAd,
-                          void * Msg,
-                          unsigned long MsgLen,
-                          u8 *pAddr2,
-                          char Ssid[], u8 * pSsidLen)
-{
-       u8 Idx;
-       u8 RateLen;
-       char IeType;
-       struct rt_frame_802_11 * pFrame = (struct rt_frame_802_11 *) Msg;
-
-       COPY_MAC_ADDR(pAddr2, pFrame->Hdr.Addr2);
-
-       if ((pFrame->Octet[0] != IE_SSID)
-           || (pFrame->Octet[1] > MAX_LEN_OF_SSID)) {
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("PeerProbeReqSanity fail - wrong SSID IE(Type=%d,Len=%d)\n",
-                         pFrame->Octet[0], pFrame->Octet[1]));
-               return FALSE;
-       }
-
-       *pSsidLen = pFrame->Octet[1];
-       NdisMoveMemory(Ssid, &pFrame->Octet[2], *pSsidLen);
-
-       Idx = *pSsidLen + 2;
-
-       /* -- get supported rates from payload and advance the pointer */
-       IeType = pFrame->Octet[Idx];
-       RateLen = pFrame->Octet[Idx + 1];
-       if (IeType != IE_SUPP_RATES) {
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("PeerProbeReqSanity fail - wrong SupportRates IE(Type=%d,Len=%d)\n",
-                         pFrame->Octet[Idx], pFrame->Octet[Idx + 1]));
-               return FALSE;
-       } else {
-               if ((pAd->CommonCfg.PhyMode == PHY_11G) && (RateLen < 8))
-                       return (FALSE);
-       }
-
-       return TRUE;
-}
-
-/*
-    ==========================================================================
-    Description:
-
-       IRQL = DISPATCH_LEVEL
-
-    ==========================================================================
- */
-BOOLEAN GetTimBit(char * Ptr,
-                 u16 Aid,
-                 u8 * TimLen,
-                 u8 * BcastFlag,
-                 u8 * DtimCount,
-                 u8 * DtimPeriod, u8 * MessageToMe)
-{
-       u8 BitCntl, N1, N2, MyByte, MyBit;
-       char *IdxPtr;
-
-       IdxPtr = Ptr;
-
-       IdxPtr++;
-       *TimLen = *IdxPtr;
-
-       /* get DTIM Count from TIM element */
-       IdxPtr++;
-       *DtimCount = *IdxPtr;
-
-       /* get DTIM Period from TIM element */
-       IdxPtr++;
-       *DtimPeriod = *IdxPtr;
-
-       /* get Bitmap Control from TIM element */
-       IdxPtr++;
-       BitCntl = *IdxPtr;
-
-       if ((*DtimCount == 0) && (BitCntl & 0x01))
-               *BcastFlag = TRUE;
-       else
-               *BcastFlag = FALSE;
-
-       /* Parse Partial Virtual Bitmap from TIM element */
-       N1 = BitCntl & 0xfe;    /* N1 is the first bitmap byte# */
-       N2 = *TimLen - 4 + N1;  /* N2 is the last bitmap byte# */
-
-       if ((Aid < (N1 << 3)) || (Aid >= ((N2 + 1) << 3)))
-               *MessageToMe = FALSE;
-       else {
-               MyByte = (Aid >> 3) - N1;       /* my byte position in the bitmap byte-stream */
-               MyBit = Aid % 16 - ((MyByte & 0x01) ? 8 : 0);
-
-               IdxPtr += (MyByte + 1);
-
-               /*if (*IdxPtr) */
-               /*    DBGPRINT(RT_DEBUG_WARN, ("TIM bitmap = 0x%02x\n", *IdxPtr)); */
-
-               if (*IdxPtr & (0x01 << MyBit))
-                       *MessageToMe = TRUE;
-               else
-                       *MessageToMe = FALSE;
-       }
-
-       return TRUE;
-}
diff --git a/drivers/staging/rt2860/sta/sync.c b/drivers/staging/rt2860/sta/sync.c
deleted file mode 100644 (file)
index 7054ba1..0000000
+++ /dev/null
@@ -1,1968 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-       Module Name:
-       sync.c
-
-       Abstract:
-
-       Revision History:
-       Who                     When                    What
-       --------        ----------              ----------------------------------------------
-       John Chang              2004-09-01              modified for rt2561/2661
-       Jan Lee                 2006-08-01              modified for rt2860 for 802.11n
-       Justin P. Mattock       11/07/2010              Fix typos
-*/
-#include "../rt_config.h"
-
-#define ADHOC_ENTRY_BEACON_LOST_TIME   (2*OS_HZ)       /* 2 sec */
-
-/*
-       ==========================================================================
-       Description:
-               The sync state machine,
-       Parameters:
-               Sm - pointer to the state machine
-       Note:
-               the state machine looks like the following
-
-       ==========================================================================
- */
-void SyncStateMachineInit(struct rt_rtmp_adapter *pAd,
-                         struct rt_state_machine *Sm, OUT STATE_MACHINE_FUNC Trans[])
-{
-       StateMachineInit(Sm, Trans, MAX_SYNC_STATE, MAX_SYNC_MSG,
-                        (STATE_MACHINE_FUNC) Drop, SYNC_IDLE,
-                        SYNC_MACHINE_BASE);
-
-       /* column 1 */
-       StateMachineSetAction(Sm, SYNC_IDLE, MT2_MLME_SCAN_REQ,
-                             (STATE_MACHINE_FUNC) MlmeScanReqAction);
-       StateMachineSetAction(Sm, SYNC_IDLE, MT2_MLME_JOIN_REQ,
-                             (STATE_MACHINE_FUNC) MlmeJoinReqAction);
-       StateMachineSetAction(Sm, SYNC_IDLE, MT2_MLME_START_REQ,
-                             (STATE_MACHINE_FUNC) MlmeStartReqAction);
-       StateMachineSetAction(Sm, SYNC_IDLE, MT2_PEER_BEACON,
-                             (STATE_MACHINE_FUNC) PeerBeacon);
-       StateMachineSetAction(Sm, SYNC_IDLE, MT2_PEER_PROBE_REQ,
-                             (STATE_MACHINE_FUNC) PeerProbeReqAction);
-
-       /*column 2 */
-       StateMachineSetAction(Sm, JOIN_WAIT_BEACON, MT2_MLME_SCAN_REQ,
-                             (STATE_MACHINE_FUNC) InvalidStateWhenScan);
-       StateMachineSetAction(Sm, JOIN_WAIT_BEACON, MT2_MLME_JOIN_REQ,
-                             (STATE_MACHINE_FUNC) InvalidStateWhenJoin);
-       StateMachineSetAction(Sm, JOIN_WAIT_BEACON, MT2_MLME_START_REQ,
-                             (STATE_MACHINE_FUNC) InvalidStateWhenStart);
-       StateMachineSetAction(Sm, JOIN_WAIT_BEACON, MT2_PEER_BEACON,
-                             (STATE_MACHINE_FUNC) PeerBeaconAtJoinAction);
-       StateMachineSetAction(Sm, JOIN_WAIT_BEACON, MT2_BEACON_TIMEOUT,
-                             (STATE_MACHINE_FUNC) BeaconTimeoutAtJoinAction);
-
-       /* column 3 */
-       StateMachineSetAction(Sm, SCAN_LISTEN, MT2_MLME_SCAN_REQ,
-                             (STATE_MACHINE_FUNC) InvalidStateWhenScan);
-       StateMachineSetAction(Sm, SCAN_LISTEN, MT2_MLME_JOIN_REQ,
-                             (STATE_MACHINE_FUNC) InvalidStateWhenJoin);
-       StateMachineSetAction(Sm, SCAN_LISTEN, MT2_MLME_START_REQ,
-                             (STATE_MACHINE_FUNC) InvalidStateWhenStart);
-       StateMachineSetAction(Sm, SCAN_LISTEN, MT2_PEER_BEACON,
-                             (STATE_MACHINE_FUNC) PeerBeaconAtScanAction);
-       StateMachineSetAction(Sm, SCAN_LISTEN, MT2_PEER_PROBE_RSP,
-                             (STATE_MACHINE_FUNC) PeerBeaconAtScanAction);
-       StateMachineSetAction(Sm, SCAN_LISTEN, MT2_SCAN_TIMEOUT,
-                             (STATE_MACHINE_FUNC) ScanTimeoutAction);
-
-       /* timer init */
-       RTMPInitTimer(pAd, &pAd->MlmeAux.BeaconTimer,
-                     GET_TIMER_FUNCTION(BeaconTimeout), pAd, FALSE);
-       RTMPInitTimer(pAd, &pAd->MlmeAux.ScanTimer,
-                     GET_TIMER_FUNCTION(ScanTimeout), pAd, FALSE);
-}
-
-/*
-       ==========================================================================
-       Description:
-               Beacon timeout handler, executed in timer thread
-
-       IRQL = DISPATCH_LEVEL
-
-       ==========================================================================
- */
-void BeaconTimeout(void *SystemSpecific1,
-                  void *FunctionContext,
-                  void *SystemSpecific2, void *SystemSpecific3)
-{
-       struct rt_rtmp_adapter *pAd = (struct rt_rtmp_adapter *)FunctionContext;
-
-       DBGPRINT(RT_DEBUG_TRACE, ("SYNC - BeaconTimeout\n"));
-
-       /* Do nothing if the driver is starting halt state. */
-       /* This might happen when timer already been fired before cancel timer with mlmehalt */
-       if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS))
-               return;
-
-       if ((pAd->CommonCfg.BBPCurrentBW == BW_40)
-           ) {
-               u8 BBPValue = 0;
-               AsicSwitchChannel(pAd, pAd->CommonCfg.CentralChannel, FALSE);
-               AsicLockChannel(pAd, pAd->CommonCfg.CentralChannel);
-               RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue);
-               BBPValue &= (~0x18);
-               BBPValue |= 0x10;
-               RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue);
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("SYNC - End of SCAN, restore to 40MHz channel %d, Total BSS[%02d]\n",
-                         pAd->CommonCfg.CentralChannel, pAd->ScanTab.BssNr));
-       }
-
-       MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_BEACON_TIMEOUT, 0, NULL);
-       RTMP_MLME_HANDLER(pAd);
-}
-
-/*
-       ==========================================================================
-       Description:
-               Scan timeout handler, executed in timer thread
-
-       IRQL = DISPATCH_LEVEL
-
-       ==========================================================================
- */
-void ScanTimeout(void *SystemSpecific1,
-                void *FunctionContext,
-                void *SystemSpecific2, void *SystemSpecific3)
-{
-       struct rt_rtmp_adapter *pAd = (struct rt_rtmp_adapter *)FunctionContext;
-
-       /* Do nothing if the driver is starting halt state. */
-       /* This might happen when timer already been fired before cancel timer with mlmehalt */
-       if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS))
-               return;
-
-       if (MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_SCAN_TIMEOUT, 0, NULL)) {
-               RTMP_MLME_HANDLER(pAd);
-       } else {
-               /* To prevent SyncMachine.CurrState is SCAN_LISTEN forever. */
-               pAd->MlmeAux.Channel = 0;
-               ScanNextChannel(pAd);
-               if (pAd->CommonCfg.bWirelessEvent) {
-                       RTMPSendWirelessEvent(pAd,
-                                             IW_SCAN_ENQUEUE_FAIL_EVENT_FLAG,
-                                             pAd->MacTab.Content[BSSID_WCID].
-                                             Addr, BSS0, 0);
-               }
-       }
-}
-
-/*
-       ==========================================================================
-       Description:
-               MLME SCAN req state machine procedure
-       ==========================================================================
- */
-void MlmeScanReqAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
-{
-       u8 Ssid[MAX_LEN_OF_SSID], SsidLen, ScanType, BssType, BBPValue = 0;
-       BOOLEAN TimerCancelled;
-       unsigned long Now;
-       u16 Status;
-       struct rt_header_802_11 * pHdr80211;
-       u8 *pOutBuffer = NULL;
-       int NStatus;
-
-       /* Check the total scan tries for one single OID command */
-       /* If this is the CCX 2.0 Case, skip that! */
-       if (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_START_UP)) {
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("SYNC - MlmeScanReqAction before Startup\n"));
-               return;
-       }
-       /* Increase the scan retry counters. */
-       pAd->StaCfg.ScanCnt++;
-
-#ifdef RTMP_MAC_PCI
-       if ((OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_PCIE_DEVICE)) &&
-           (IDLE_ON(pAd)) &&
-           (pAd->StaCfg.bRadio == TRUE) &&
-           (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_IDLE_RADIO_OFF))) {
-               if (pAd->StaCfg.PSControl.field.EnableNewPS == FALSE) {
-                       AsicSendCommandToMcu(pAd, 0x31, PowerWakeCID, 0x00,
-                                            0x02);
-                       AsicCheckCommanOk(pAd, PowerWakeCID);
-                       RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_IDLE_RADIO_OFF);
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("PSM - Issue Wake up command \n"));
-               } else {
-                       RT28xxPciAsicRadioOn(pAd, GUI_IDLE_POWER_SAVE);
-               }
-       }
-#endif /* RTMP_MAC_PCI // */
-
-       /* first check the parameter sanity */
-       if (MlmeScanReqSanity(pAd,
-                             Elem->Msg,
-                             Elem->MsgLen,
-                             &BssType, (char *)Ssid, &SsidLen, &ScanType)) {
-
-               /* Check for channel load and noise hist request */
-               /* Suspend MSDU only at scan request, not the last two mentioned */
-               /* Suspend MSDU transmission here */
-               RTMPSuspendMsduTransmission(pAd);
-
-               /* */
-               /* To prevent data loss. */
-               /* Send a NULL data with turned PSM bit on to current associated AP before SCAN progress. */
-               /* And should send a NULL data with turned PSM bit off to AP, when scan progress done */
-               /* */
-               if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED)
-                   && (INFRA_ON(pAd))) {
-                       NStatus = MlmeAllocateMemory(pAd, (void *)& pOutBuffer);
-                       if (NStatus == NDIS_STATUS_SUCCESS) {
-                               pHdr80211 = (struct rt_header_802_11 *) pOutBuffer;
-                               MgtMacHeaderInit(pAd, pHdr80211,
-                                                SUBTYPE_NULL_FUNC, 1,
-                                                pAd->CommonCfg.Bssid,
-                                                pAd->CommonCfg.Bssid);
-                               pHdr80211->Duration = 0;
-                               pHdr80211->FC.Type = BTYPE_DATA;
-                               pHdr80211->FC.PwrMgmt = PWR_SAVE;
-
-                               /* Send using priority queue */
-                               MiniportMMRequest(pAd, 0, pOutBuffer,
-                                                 sizeof(struct rt_header_802_11));
-                               DBGPRINT(RT_DEBUG_TRACE,
-                                        ("MlmeScanReqAction -- Send PSM Data frame for off channel RM\n"));
-                               MlmeFreeMemory(pAd, pOutBuffer);
-                               RTMPusecDelay(5000);
-                       }
-               }
-
-               NdisGetSystemUpTime(&Now);
-               pAd->StaCfg.LastScanTime = Now;
-               /* reset all the timers */
-               RTMPCancelTimer(&pAd->MlmeAux.BeaconTimer, &TimerCancelled);
-               RTMPCancelTimer(&pAd->MlmeAux.ScanTimer, &TimerCancelled);
-
-               /* record desired BSS parameters */
-               pAd->MlmeAux.BssType = BssType;
-               pAd->MlmeAux.ScanType = ScanType;
-               pAd->MlmeAux.SsidLen = SsidLen;
-               NdisZeroMemory(pAd->MlmeAux.Ssid, MAX_LEN_OF_SSID);
-               NdisMoveMemory(pAd->MlmeAux.Ssid, Ssid, SsidLen);
-
-               /* start from the first channel */
-               pAd->MlmeAux.Channel = FirstChannel(pAd);
-
-               /* Let BBP register at 20MHz to do scan */
-               RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue);
-               BBPValue &= (~0x18);
-               RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue);
-               DBGPRINT(RT_DEBUG_TRACE, ("SYNC - BBP R4 to 20MHz.l\n"));
-               ScanNextChannel(pAd);
-       } else {
-               DBGPRINT_ERR("SYNC - MlmeScanReqAction() sanity check fail\n");
-               pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
-               Status = MLME_INVALID_FORMAT;
-               MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_SCAN_CONF, 2,
-                           &Status);
-       }
-}
-
-/*
-       ==========================================================================
-       Description:
-               MLME JOIN req state machine procedure
-       ==========================================================================
- */
-void MlmeJoinReqAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
-{
-       u8 BBPValue = 0;
-       struct rt_bss_entry *pBss;
-       BOOLEAN TimerCancelled;
-       struct rt_header_802_11 Hdr80211;
-       int NStatus;
-       unsigned long FrameLen = 0;
-       u8 *pOutBuffer = NULL;
-       u8 *pSupRate = NULL;
-       u8 SupRateLen;
-       u8 *pExtRate = NULL;
-       u8 ExtRateLen;
-       u8 ASupRate[] = { 0x8C, 0x12, 0x98, 0x24, 0xb0, 0x48, 0x60, 0x6C };
-       u8 ASupRateLen = sizeof(ASupRate) / sizeof(u8);
-       struct rt_mlme_join_req *pInfo = (struct rt_mlme_join_req *)(Elem->Msg);
-
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("SYNC - MlmeJoinReqAction(BSS #%ld)\n", pInfo->BssIdx));
-
-#ifdef RTMP_MAC_PCI
-       if ((OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_PCIE_DEVICE)) &&
-           (IDLE_ON(pAd)) &&
-           (pAd->StaCfg.bRadio == TRUE) &&
-           (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_IDLE_RADIO_OFF))) {
-               RT28xxPciAsicRadioOn(pAd, GUI_IDLE_POWER_SAVE);
-       }
-#endif /* RTMP_MAC_PCI // */
-
-       /* reset all the timers */
-       RTMPCancelTimer(&pAd->MlmeAux.ScanTimer, &TimerCancelled);
-       RTMPCancelTimer(&pAd->MlmeAux.BeaconTimer, &TimerCancelled);
-
-       pBss = &pAd->MlmeAux.SsidBssTab.BssEntry[pInfo->BssIdx];
-
-       /* record the desired SSID & BSSID we're waiting for */
-       COPY_MAC_ADDR(pAd->MlmeAux.Bssid, pBss->Bssid);
-
-       /* If AP's SSID is not hidden, it is OK for updating ssid to MlmeAux again. */
-       if (pBss->Hidden == 0) {
-               RTMPZeroMemory(pAd->MlmeAux.Ssid, MAX_LEN_OF_SSID);
-               NdisMoveMemory(pAd->MlmeAux.Ssid, pBss->Ssid, pBss->SsidLen);
-               pAd->MlmeAux.SsidLen = pBss->SsidLen;
-       }
-
-       pAd->MlmeAux.BssType = pBss->BssType;
-       pAd->MlmeAux.Channel = pBss->Channel;
-       pAd->MlmeAux.CentralChannel = pBss->CentralChannel;
-
-       /* Let BBP register at 20MHz to do scan */
-       RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue);
-       BBPValue &= (~0x18);
-       RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue);
-
-       DBGPRINT(RT_DEBUG_TRACE, ("SYNC - BBP R4 to 20MHz.l\n"));
-
-       /* switch channel and waiting for beacon timer */
-       AsicSwitchChannel(pAd, pAd->MlmeAux.Channel, FALSE);
-       AsicLockChannel(pAd, pAd->MlmeAux.Channel);
-       RTMPSetTimer(&pAd->MlmeAux.BeaconTimer, JOIN_TIMEOUT);
-
-       do {
-               if (((pAd->CommonCfg.bIEEE80211H == 1) &&
-                    (pAd->MlmeAux.Channel > 14) &&
-                    RadarChannelCheck(pAd, pAd->MlmeAux.Channel))
-                   ) {
-                       /* */
-                       /* We can't send any Probe request frame to meet 802.11h. */
-                       /* */
-                       if (pBss->Hidden == 0)
-                               break;
-               }
-               /* */
-               /* send probe request */
-               /* */
-               NStatus = MlmeAllocateMemory(pAd, &pOutBuffer);
-               if (NStatus == NDIS_STATUS_SUCCESS) {
-                       if (pAd->MlmeAux.Channel <= 14) {
-                               pSupRate = pAd->CommonCfg.SupRate;
-                               SupRateLen = pAd->CommonCfg.SupRateLen;
-                               pExtRate = pAd->CommonCfg.ExtRate;
-                               ExtRateLen = pAd->CommonCfg.ExtRateLen;
-                       } else {
-                               /* */
-                               /* Overwrite Support Rate, CCK rate are not allowed */
-                               /* */
-                               pSupRate = ASupRate;
-                               SupRateLen = ASupRateLen;
-                               ExtRateLen = 0;
-                       }
-
-                       if (pAd->MlmeAux.BssType == BSS_INFRA)
-                               MgtMacHeaderInit(pAd, &Hdr80211,
-                                                SUBTYPE_PROBE_REQ, 0,
-                                                pAd->MlmeAux.Bssid,
-                                                pAd->MlmeAux.Bssid);
-                       else
-                               MgtMacHeaderInit(pAd, &Hdr80211,
-                                                SUBTYPE_PROBE_REQ, 0,
-                                                BROADCAST_ADDR,
-                                                BROADCAST_ADDR);
-
-                       MakeOutgoingFrame(pOutBuffer, &FrameLen,
-                                         sizeof(struct rt_header_802_11), &Hdr80211,
-                                         1, &SsidIe,
-                                         1, &pAd->MlmeAux.SsidLen,
-                                         pAd->MlmeAux.SsidLen,
-                                         pAd->MlmeAux.Ssid, 1, &SupRateIe, 1,
-                                         &SupRateLen, SupRateLen, pSupRate,
-                                         END_OF_ARGS);
-
-                       if (ExtRateLen) {
-                               unsigned long Tmp;
-                               MakeOutgoingFrame(pOutBuffer + FrameLen, &Tmp,
-                                                 1, &ExtRateIe,
-                                                 1, &ExtRateLen,
-                                                 ExtRateLen, pExtRate,
-                                                 END_OF_ARGS);
-                               FrameLen += Tmp;
-                       }
-
-                       MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
-                       MlmeFreeMemory(pAd, pOutBuffer);
-               }
-       } while (FALSE);
-
-       DBGPRINT(RT_DEBUG_TRACE,
-               ("SYNC - Switch to ch %d, Wait BEACON from %pM\n",
-                       pBss->Channel, pBss->Bssid));
-
-       pAd->Mlme.SyncMachine.CurrState = JOIN_WAIT_BEACON;
-}
-
-/*
-       ==========================================================================
-       Description:
-               MLME START Request state machine procedure, starting an IBSS
-       ==========================================================================
- */
-void MlmeStartReqAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
-{
-       u8 Ssid[MAX_LEN_OF_SSID], SsidLen;
-       BOOLEAN TimerCancelled;
-
-       /* New for WPA security suites */
-       u8 VarIE[MAX_VIE_LEN];  /* Total VIE length = MAX_VIE_LEN - -5 */
-       struct rt_ndis_802_11_variable_ies *pVIE = NULL;
-       LARGE_INTEGER TimeStamp;
-       BOOLEAN Privacy;
-       u16 Status;
-
-       /* Init Variable IE structure */
-       pVIE = (struct rt_ndis_802_11_variable_ies *)VarIE;
-       pVIE->Length = 0;
-       TimeStamp.u.LowPart = 0;
-       TimeStamp.u.HighPart = 0;
-
-       if (MlmeStartReqSanity
-           (pAd, Elem->Msg, Elem->MsgLen, (char *)Ssid, &SsidLen)) {
-               /* reset all the timers */
-               RTMPCancelTimer(&pAd->MlmeAux.ScanTimer, &TimerCancelled);
-               RTMPCancelTimer(&pAd->MlmeAux.BeaconTimer, &TimerCancelled);
-
-               /* */
-               /* Start a new IBSS. All IBSS parameters are decided now.... */
-               /* */
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("MlmeStartReqAction - Start a new IBSS. All IBSS parameters are decided now.... \n"));
-               pAd->MlmeAux.BssType = BSS_ADHOC;
-               NdisMoveMemory(pAd->MlmeAux.Ssid, Ssid, SsidLen);
-               pAd->MlmeAux.SsidLen = SsidLen;
-
-               /* generate a radom number as BSSID */
-               MacAddrRandomBssid(pAd, pAd->MlmeAux.Bssid);
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("MlmeStartReqAction - generate a radom number as BSSID \n"));
-
-               Privacy =
-                   (pAd->StaCfg.WepStatus == Ndis802_11Encryption1Enabled)
-                   || (pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled)
-                   || (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled);
-               pAd->MlmeAux.CapabilityInfo =
-                   CAP_GENERATE(0, 1, Privacy,
-                                (pAd->CommonCfg.TxPreamble ==
-                                 Rt802_11PreambleShort), 1, 0);
-               pAd->MlmeAux.BeaconPeriod = pAd->CommonCfg.BeaconPeriod;
-               pAd->MlmeAux.AtimWin = pAd->StaCfg.AtimWin;
-               pAd->MlmeAux.Channel = pAd->CommonCfg.Channel;
-
-               pAd->CommonCfg.CentralChannel = pAd->CommonCfg.Channel;
-               pAd->MlmeAux.CentralChannel = pAd->CommonCfg.CentralChannel;
-
-               pAd->MlmeAux.SupRateLen = pAd->CommonCfg.SupRateLen;
-               NdisMoveMemory(pAd->MlmeAux.SupRate, pAd->CommonCfg.SupRate,
-                              MAX_LEN_OF_SUPPORTED_RATES);
-               RTMPCheckRates(pAd, pAd->MlmeAux.SupRate,
-                              &pAd->MlmeAux.SupRateLen);
-               pAd->MlmeAux.ExtRateLen = pAd->CommonCfg.ExtRateLen;
-               NdisMoveMemory(pAd->MlmeAux.ExtRate, pAd->CommonCfg.ExtRate,
-                              MAX_LEN_OF_SUPPORTED_RATES);
-               RTMPCheckRates(pAd, pAd->MlmeAux.ExtRate,
-                              &pAd->MlmeAux.ExtRateLen);
-
-               if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED) {
-                       RTMPUpdateHTIE(&pAd->CommonCfg.DesiredHtPhy,
-                                      &pAd->StaCfg.DesiredHtPhyInfo.MCSSet[0],
-                                      &pAd->MlmeAux.HtCapability,
-                                      &pAd->MlmeAux.AddHtInfo);
-                       pAd->MlmeAux.HtCapabilityLen = sizeof(struct rt_ht_capability_ie);
-                       /* Not turn pAd->StaActive.SupportedHtPhy.bHtEnable = TRUE here. */
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("SYNC -pAd->StaActive.SupportedHtPhy.bHtEnable = TRUE\n"));
-               } else {
-                       pAd->MlmeAux.HtCapabilityLen = 0;
-                       pAd->StaActive.SupportedPhyInfo.bHtEnable = FALSE;
-                       NdisZeroMemory(&pAd->StaActive.SupportedPhyInfo.
-                                      MCSSet[0], 16);
-               }
-               /* temporarily not support QOS in IBSS */
-               NdisZeroMemory(&pAd->MlmeAux.APEdcaParm, sizeof(struct rt_edca_parm));
-               NdisZeroMemory(&pAd->MlmeAux.APQbssLoad,
-                              sizeof(struct rt_qbss_load_parm));
-               NdisZeroMemory(&pAd->MlmeAux.APQosCapability,
-                              sizeof(struct rt_qos_capability_parm));
-
-               AsicSwitchChannel(pAd, pAd->MlmeAux.Channel, FALSE);
-               AsicLockChannel(pAd, pAd->MlmeAux.Channel);
-
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("SYNC - MlmeStartReqAction(ch= %d,sup rates= %d, ext rates=%d)\n",
-                         pAd->MlmeAux.Channel, pAd->MlmeAux.SupRateLen,
-                         pAd->MlmeAux.ExtRateLen));
-
-               pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
-               Status = MLME_SUCCESS;
-               MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_START_CONF, 2,
-                           &Status);
-       } else {
-               DBGPRINT_ERR("SYNC - MlmeStartReqAction() sanity check fail.\n");
-               pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
-               Status = MLME_INVALID_FORMAT;
-               MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_START_CONF, 2,
-                           &Status);
-       }
-}
-
-/*
-       ==========================================================================
-       Description:
-               peer sends beacon back when scanning
-       ==========================================================================
- */
-void PeerBeaconAtScanAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
-{
-       u8 Bssid[MAC_ADDR_LEN], Addr2[MAC_ADDR_LEN];
-       u8 Ssid[MAX_LEN_OF_SSID], BssType, Channel, NewChannel,
-           SsidLen, DtimCount, DtimPeriod, BcastFlag, MessageToMe;
-       struct rt_cf_parm CfParm;
-       u16 BeaconPeriod, AtimWin, CapabilityInfo;
-       struct rt_frame_802_11 * pFrame;
-       LARGE_INTEGER TimeStamp;
-       u8 Erp;
-       u8 SupRate[MAX_LEN_OF_SUPPORTED_RATES],
-           ExtRate[MAX_LEN_OF_SUPPORTED_RATES];
-       u8 SupRateLen, ExtRateLen;
-       u16 LenVIE;
-       u8 CkipFlag;
-       u8 AironetCellPowerLimit;
-       struct rt_edca_parm EdcaParm;
-       struct rt_qbss_load_parm QbssLoad;
-       struct rt_qos_capability_parm QosCapability;
-       unsigned long RalinkIe;
-       u8 VarIE[MAX_VIE_LEN];  /* Total VIE length = MAX_VIE_LEN - -5 */
-       struct rt_ndis_802_11_variable_ies *pVIE = NULL;
-       struct rt_ht_capability_ie HtCapability;
-       struct rt_add_ht_info_ie AddHtInfo;     /* AP might use this additional ht info IE */
-       u8 HtCapabilityLen = 0, PreNHtCapabilityLen = 0;
-       u8 AddHtInfoLen;
-       u8 NewExtChannelOffset = 0xff;
-
-       /* NdisFillMemory(Ssid, MAX_LEN_OF_SSID, 0x00); */
-       pFrame = (struct rt_frame_802_11 *) Elem->Msg;
-       /* Init Variable IE structure */
-       pVIE = (struct rt_ndis_802_11_variable_ies *)VarIE;
-       pVIE->Length = 0;
-
-       RTMPZeroMemory(&HtCapability, sizeof(HtCapability));
-       RTMPZeroMemory(&AddHtInfo, sizeof(struct rt_add_ht_info_ie));
-
-       if (PeerBeaconAndProbeRspSanity(pAd,
-                                       Elem->Msg,
-                                       Elem->MsgLen,
-                                       Elem->Channel,
-                                       Addr2,
-                                       Bssid,
-                                       (char *)Ssid,
-                                       &SsidLen,
-                                       &BssType,
-                                       &BeaconPeriod,
-                                       &Channel,
-                                       &NewChannel,
-                                       &TimeStamp,
-                                       &CfParm,
-                                       &AtimWin,
-                                       &CapabilityInfo,
-                                       &Erp,
-                                       &DtimCount,
-                                       &DtimPeriod,
-                                       &BcastFlag,
-                                       &MessageToMe,
-                                       SupRate,
-                                       &SupRateLen,
-                                       ExtRate,
-                                       &ExtRateLen,
-                                       &CkipFlag,
-                                       &AironetCellPowerLimit,
-                                       &EdcaParm,
-                                       &QbssLoad,
-                                       &QosCapability,
-                                       &RalinkIe,
-                                       &HtCapabilityLen,
-                                       &PreNHtCapabilityLen,
-                                       &HtCapability,
-                                       &AddHtInfoLen,
-                                       &AddHtInfo,
-                                       &NewExtChannelOffset, &LenVIE, pVIE)) {
-               unsigned long Idx;
-               char Rssi = 0;
-
-               Idx = BssTableSearch(&pAd->ScanTab, Bssid, Channel);
-               if (Idx != BSS_NOT_FOUND)
-                       Rssi = pAd->ScanTab.BssEntry[Idx].Rssi;
-
-               Rssi =
-                   RTMPMaxRssi(pAd, ConvertToRssi(pAd, Elem->Rssi0, RSSI_0),
-                               ConvertToRssi(pAd, Elem->Rssi1, RSSI_1),
-                               ConvertToRssi(pAd, Elem->Rssi2, RSSI_2));
-
-               if ((HtCapabilityLen > 0) || (PreNHtCapabilityLen > 0))
-                       HtCapabilityLen = SIZE_HT_CAP_IE;
-
-               Idx =
-                   BssTableSetEntry(pAd, &pAd->ScanTab, Bssid, (char *)Ssid,
-                                    SsidLen, BssType, BeaconPeriod, &CfParm,
-                                    AtimWin, CapabilityInfo, SupRate,
-                                    SupRateLen, ExtRate, ExtRateLen,
-                                    &HtCapability, &AddHtInfo, HtCapabilityLen,
-                                    AddHtInfoLen, NewExtChannelOffset, Channel,
-                                    Rssi, TimeStamp, CkipFlag, &EdcaParm,
-                                    &QosCapability, &QbssLoad, LenVIE, pVIE);
-
-               if (Idx != BSS_NOT_FOUND) {
-                       NdisMoveMemory(pAd->ScanTab.BssEntry[Idx].PTSF,
-                                      &Elem->Msg[24], 4);
-                       NdisMoveMemory(&pAd->ScanTab.BssEntry[Idx].TTSF[0],
-                                      &Elem->TimeStamp.u.LowPart, 4);
-                       NdisMoveMemory(&pAd->ScanTab.BssEntry[Idx].TTSF[4],
-                                      &Elem->TimeStamp.u.LowPart, 4);
-               }
-
-       }
-       /* sanity check fail, ignored */
-}
-
-/*
-       ==========================================================================
-       Description:
-               When waiting joining the (I)BSS, beacon received from external
-       ==========================================================================
- */
-void PeerBeaconAtJoinAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
-{
-       u8 Bssid[MAC_ADDR_LEN], Addr2[MAC_ADDR_LEN];
-       u8 Ssid[MAX_LEN_OF_SSID], SsidLen, BssType, Channel, MessageToMe,
-           DtimCount, DtimPeriod, BcastFlag, NewChannel;
-       LARGE_INTEGER TimeStamp;
-       u16 BeaconPeriod, AtimWin, CapabilityInfo;
-       struct rt_cf_parm Cf;
-       BOOLEAN TimerCancelled;
-       u8 Erp;
-       u8 SupRate[MAX_LEN_OF_SUPPORTED_RATES],
-           ExtRate[MAX_LEN_OF_SUPPORTED_RATES];
-       u8 SupRateLen, ExtRateLen;
-       u8 CkipFlag;
-       u16 LenVIE;
-       u8 AironetCellPowerLimit;
-       struct rt_edca_parm EdcaParm;
-       struct rt_qbss_load_parm QbssLoad;
-       struct rt_qos_capability_parm QosCapability;
-       u16 Status;
-       u8 VarIE[MAX_VIE_LEN];  /* Total VIE length = MAX_VIE_LEN - -5 */
-       struct rt_ndis_802_11_variable_ies *pVIE = NULL;
-       unsigned long RalinkIe;
-       unsigned long Idx;
-       struct rt_ht_capability_ie HtCapability;
-       struct rt_add_ht_info_ie AddHtInfo;     /* AP might use this additional ht info IE */
-       u8 HtCapabilityLen = 0, PreNHtCapabilityLen = 0;
-       u8 AddHtInfoLen;
-       u8 NewExtChannelOffset = 0xff;
-       u8 CentralChannel;
-       BOOLEAN bAllowNrate = FALSE;
-
-       /* Init Variable IE structure */
-       pVIE = (struct rt_ndis_802_11_variable_ies *)VarIE;
-       pVIE->Length = 0;
-       RTMPZeroMemory(&HtCapability, sizeof(HtCapability));
-       RTMPZeroMemory(&AddHtInfo, sizeof(struct rt_add_ht_info_ie));
-
-       if (PeerBeaconAndProbeRspSanity(pAd,
-                                       Elem->Msg,
-                                       Elem->MsgLen,
-                                       Elem->Channel,
-                                       Addr2,
-                                       Bssid,
-                                       (char *)Ssid,
-                                       &SsidLen,
-                                       &BssType,
-                                       &BeaconPeriod,
-                                       &Channel,
-                                       &NewChannel,
-                                       &TimeStamp,
-                                       &Cf,
-                                       &AtimWin,
-                                       &CapabilityInfo,
-                                       &Erp,
-                                       &DtimCount,
-                                       &DtimPeriod,
-                                       &BcastFlag,
-                                       &MessageToMe,
-                                       SupRate,
-                                       &SupRateLen,
-                                       ExtRate,
-                                       &ExtRateLen,
-                                       &CkipFlag,
-                                       &AironetCellPowerLimit,
-                                       &EdcaParm,
-                                       &QbssLoad,
-                                       &QosCapability,
-                                       &RalinkIe,
-                                       &HtCapabilityLen,
-                                       &PreNHtCapabilityLen,
-                                       &HtCapability,
-                                       &AddHtInfoLen,
-                                       &AddHtInfo,
-                                       &NewExtChannelOffset, &LenVIE, pVIE)) {
-               /* Disqualify 11b only adhoc when we are in 11g only adhoc mode */
-               if ((BssType == BSS_ADHOC)
-                   && (pAd->CommonCfg.PhyMode == PHY_11G)
-                   && ((SupRateLen + ExtRateLen) < 12))
-                       return;
-
-               /* BEACON from desired BSS/IBSS found. We should be able to decide most */
-               /* BSS parameters here. */
-               /* Q. But what happen if this JOIN doesn't conclude a successful ASSOCIATION? */
-               /*    Do we need to recover back all parameters belonging to previous BSS? */
-               /* A. Should be not. There's no back-door recover to previous AP. It still needs */
-               /*    a new JOIN-AUTH-ASSOC sequence. */
-               if (MAC_ADDR_EQUAL(pAd->MlmeAux.Bssid, Bssid)) {
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("SYNC - receive desired BEACON at JoinWaitBeacon... Channel = %d\n",
-                                 Channel));
-                       RTMPCancelTimer(&pAd->MlmeAux.BeaconTimer,
-                                       &TimerCancelled);
-
-                       /* Update RSSI to prevent No signal display when cards first initialized */
-                       pAd->StaCfg.RssiSample.LastRssi0 =
-                           ConvertToRssi(pAd, Elem->Rssi0, RSSI_0);
-                       pAd->StaCfg.RssiSample.LastRssi1 =
-                           ConvertToRssi(pAd, Elem->Rssi1, RSSI_1);
-                       pAd->StaCfg.RssiSample.LastRssi2 =
-                           ConvertToRssi(pAd, Elem->Rssi2, RSSI_2);
-                       pAd->StaCfg.RssiSample.AvgRssi0 =
-                           pAd->StaCfg.RssiSample.LastRssi0;
-                       pAd->StaCfg.RssiSample.AvgRssi0X8 =
-                           pAd->StaCfg.RssiSample.AvgRssi0 << 3;
-                       pAd->StaCfg.RssiSample.AvgRssi1 =
-                           pAd->StaCfg.RssiSample.LastRssi1;
-                       pAd->StaCfg.RssiSample.AvgRssi1X8 =
-                           pAd->StaCfg.RssiSample.AvgRssi1 << 3;
-                       pAd->StaCfg.RssiSample.AvgRssi2 =
-                           pAd->StaCfg.RssiSample.LastRssi2;
-                       pAd->StaCfg.RssiSample.AvgRssi2X8 =
-                           pAd->StaCfg.RssiSample.AvgRssi2 << 3;
-
-                       /* */
-                       /* We need to check if SSID only set to any, then we can record the current SSID. */
-                       /* Otherwise will cause hidden SSID association failed. */
-                       /* */
-                       if (pAd->MlmeAux.SsidLen == 0) {
-                               NdisMoveMemory(pAd->MlmeAux.Ssid, Ssid,
-                                              SsidLen);
-                               pAd->MlmeAux.SsidLen = SsidLen;
-                       } else {
-                               Idx =
-                                   BssSsidTableSearch(&pAd->ScanTab, Bssid,
-                                                      pAd->MlmeAux.Ssid,
-                                                      pAd->MlmeAux.SsidLen,
-                                                      Channel);
-
-                               if (Idx == BSS_NOT_FOUND) {
-                                       char Rssi = 0;
-                                       Rssi =
-                                           RTMPMaxRssi(pAd,
-                                                       ConvertToRssi(pAd,
-                                                                     Elem->
-                                                                     Rssi0,
-                                                                     RSSI_0),
-                                                       ConvertToRssi(pAd,
-                                                                     Elem->
-                                                                     Rssi1,
-                                                                     RSSI_1),
-                                                       ConvertToRssi(pAd,
-                                                                     Elem->
-                                                                     Rssi2,
-                                                                     RSSI_2));
-                                       Idx =
-                                           BssTableSetEntry(pAd, &pAd->ScanTab,
-                                                            Bssid,
-                                                            (char *) Ssid,
-                                                            SsidLen, BssType,
-                                                            BeaconPeriod, &Cf,
-                                                            AtimWin,
-                                                            CapabilityInfo,
-                                                            SupRate,
-                                                            SupRateLen,
-                                                            ExtRate,
-                                                            ExtRateLen,
-                                                            &HtCapability,
-                                                            &AddHtInfo,
-                                                            HtCapabilityLen,
-                                                            AddHtInfoLen,
-                                                            NewExtChannelOffset,
-                                                            Channel, Rssi,
-                                                            TimeStamp,
-                                                            CkipFlag,
-                                                            &EdcaParm,
-                                                            &QosCapability,
-                                                            &QbssLoad, LenVIE,
-                                                            pVIE);
-                                       if (Idx != BSS_NOT_FOUND) {
-                                               NdisMoveMemory(pAd->ScanTab.
-                                                              BssEntry[Idx].
-                                                              PTSF,
-                                                              &Elem->Msg[24],
-                                                              4);
-                                               NdisMoveMemory(&pAd->ScanTab.
-                                                              BssEntry[Idx].
-                                                              TTSF[0],
-                                                              &Elem->TimeStamp.
-                                                              u.LowPart, 4);
-                                               NdisMoveMemory(&pAd->ScanTab.
-                                                              BssEntry[Idx].
-                                                              TTSF[4],
-                                                              &Elem->TimeStamp.
-                                                              u.LowPart, 4);
-                                               CapabilityInfo =
-                                                   pAd->ScanTab.BssEntry[Idx].
-                                                   CapabilityInfo;
-                                       }
-                               } else {
-                                       /* */
-                                       /* Multiple SSID case, used correct CapabilityInfo */
-                                       /* */
-                                       CapabilityInfo =
-                                           pAd->ScanTab.BssEntry[Idx].
-                                           CapabilityInfo;
-                               }
-                       }
-                       NdisMoveMemory(pAd->MlmeAux.Bssid, Bssid, MAC_ADDR_LEN);
-                       pAd->MlmeAux.CapabilityInfo =
-                           CapabilityInfo & SUPPORTED_CAPABILITY_INFO;
-                       pAd->MlmeAux.BssType = BssType;
-                       pAd->MlmeAux.BeaconPeriod = BeaconPeriod;
-                       pAd->MlmeAux.Channel = Channel;
-                       pAd->MlmeAux.AtimWin = AtimWin;
-                       pAd->MlmeAux.CfpPeriod = Cf.CfpPeriod;
-                       pAd->MlmeAux.CfpMaxDuration = Cf.CfpMaxDuration;
-                       pAd->MlmeAux.APRalinkIe = RalinkIe;
-
-                       /* Copy AP's supported rate to MlmeAux for creating association request */
-                       /* Also filter out not supported rate */
-                       pAd->MlmeAux.SupRateLen = SupRateLen;
-                       NdisMoveMemory(pAd->MlmeAux.SupRate, SupRate,
-                                      SupRateLen);
-                       RTMPCheckRates(pAd, pAd->MlmeAux.SupRate,
-                                      &pAd->MlmeAux.SupRateLen);
-                       pAd->MlmeAux.ExtRateLen = ExtRateLen;
-                       NdisMoveMemory(pAd->MlmeAux.ExtRate, ExtRate,
-                                      ExtRateLen);
-                       RTMPCheckRates(pAd, pAd->MlmeAux.ExtRate,
-                                      &pAd->MlmeAux.ExtRateLen);
-
-                       NdisZeroMemory(pAd->StaActive.SupportedPhyInfo.MCSSet,
-                                      16);
-
-                       if (((pAd->StaCfg.WepStatus != Ndis802_11WEPEnabled)
-                            && (pAd->StaCfg.WepStatus !=
-                                Ndis802_11Encryption2Enabled))
-                           || (pAd->CommonCfg.HT_DisallowTKIP == FALSE)) {
-                               bAllowNrate = TRUE;
-                       }
-
-                       pAd->MlmeAux.NewExtChannelOffset = NewExtChannelOffset;
-                       pAd->MlmeAux.HtCapabilityLen = HtCapabilityLen;
-
-                       RTMPZeroMemory(&pAd->MlmeAux.HtCapability,
-                                      SIZE_HT_CAP_IE);
-                       /* filter out un-supported ht rates */
-                       if (((HtCapabilityLen > 0) || (PreNHtCapabilityLen > 0))
-                           && ((pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)
-                               && (bAllowNrate))) {
-                               RTMPMoveMemory(&pAd->MlmeAux.AddHtInfo,
-                                              &AddHtInfo, SIZE_ADD_HT_INFO_IE);
-
-                               /* StaActive.SupportedHtPhy.MCSSet stores Peer AP's 11n Rx capability */
-                               NdisMoveMemory(pAd->StaActive.SupportedPhyInfo.
-                                              MCSSet, HtCapability.MCSSet, 16);
-                               pAd->MlmeAux.NewExtChannelOffset =
-                                   NewExtChannelOffset;
-                               pAd->MlmeAux.HtCapabilityLen = SIZE_HT_CAP_IE;
-                               pAd->StaActive.SupportedPhyInfo.bHtEnable =
-                                   TRUE;
-                               if (PreNHtCapabilityLen > 0)
-                                       pAd->StaActive.SupportedPhyInfo.
-                                           bPreNHt = TRUE;
-                               RTMPCheckHt(pAd, BSSID_WCID, &HtCapability,
-                                           &AddHtInfo);
-                               /* Copy AP Parameter to StaActive.  This is also in LinkUp. */
-                               DBGPRINT(RT_DEBUG_TRACE,
-                                        ("PeerBeaconAtJoinAction! (MpduDensity=%d, MaxRAmpduFactor=%d, BW=%d)\n",
-                                         pAd->StaActive.SupportedHtPhy.
-                                         MpduDensity,
-                                         pAd->StaActive.SupportedHtPhy.
-                                         MaxRAmpduFactor,
-                                         HtCapability.HtCapInfo.ChannelWidth));
-
-                               if (AddHtInfoLen > 0) {
-                                       CentralChannel = AddHtInfo.ControlChan;
-                                       /* Check again the Bandwidth capability of this AP. */
-                                       if ((AddHtInfo.ControlChan > 2)
-                                           && (AddHtInfo.AddHtInfo.
-                                               ExtChanOffset == EXTCHA_BELOW)
-                                           && (HtCapability.HtCapInfo.
-                                               ChannelWidth == BW_40)) {
-                                               CentralChannel =
-                                                   AddHtInfo.ControlChan - 2;
-                                       } else
-                                           if ((AddHtInfo.AddHtInfo.
-                                                ExtChanOffset == EXTCHA_ABOVE)
-                                               && (HtCapability.HtCapInfo.
-                                                   ChannelWidth == BW_40)) {
-                                               CentralChannel =
-                                                   AddHtInfo.ControlChan + 2;
-                                       }
-                                       /* Check Error . */
-                                       if (pAd->MlmeAux.CentralChannel !=
-                                           CentralChannel)
-                                               DBGPRINT(RT_DEBUG_ERROR,
-                                                        ("PeerBeaconAtJoinAction HT===>Beacon Central Channel = %d, Control Channel = %d. Mlmeaux CentralChannel = %d\n",
-                                                         CentralChannel,
-                                                         AddHtInfo.ControlChan,
-                                                         pAd->MlmeAux.
-                                                         CentralChannel));
-
-                                       DBGPRINT(RT_DEBUG_TRACE,
-                                                ("PeerBeaconAtJoinAction HT===>Central Channel = %d, Control Channel = %d,  .\n",
-                                                 CentralChannel,
-                                                 AddHtInfo.ControlChan));
-
-                               }
-
-                       } else {
-                               /* To prevent error, let legacy AP must have same CentralChannel and Channel. */
-                               if ((HtCapabilityLen == 0)
-                                   && (PreNHtCapabilityLen == 0))
-                                       pAd->MlmeAux.CentralChannel =
-                                           pAd->MlmeAux.Channel;
-
-                               pAd->StaActive.SupportedPhyInfo.bHtEnable =
-                                   FALSE;
-                               pAd->MlmeAux.NewExtChannelOffset = 0xff;
-                               RTMPZeroMemory(&pAd->MlmeAux.HtCapability,
-                                              SIZE_HT_CAP_IE);
-                               pAd->MlmeAux.HtCapabilityLen = 0;
-                               RTMPZeroMemory(&pAd->MlmeAux.AddHtInfo,
-                                              SIZE_ADD_HT_INFO_IE);
-                       }
-
-                       RTMPUpdateMlmeRate(pAd);
-
-                       /* copy QOS related information */
-                       if ((pAd->CommonCfg.bWmmCapable)
-                           || (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)
-                           ) {
-                               NdisMoveMemory(&pAd->MlmeAux.APEdcaParm,
-                                              &EdcaParm, sizeof(struct rt_edca_parm));
-                               NdisMoveMemory(&pAd->MlmeAux.APQbssLoad,
-                                              &QbssLoad,
-                                              sizeof(struct rt_qbss_load_parm));
-                               NdisMoveMemory(&pAd->MlmeAux.APQosCapability,
-                                              &QosCapability,
-                                              sizeof(struct rt_qos_capability_parm));
-                       } else {
-                               NdisZeroMemory(&pAd->MlmeAux.APEdcaParm,
-                                              sizeof(struct rt_edca_parm));
-                               NdisZeroMemory(&pAd->MlmeAux.APQbssLoad,
-                                              sizeof(struct rt_qbss_load_parm));
-                               NdisZeroMemory(&pAd->MlmeAux.APQosCapability,
-                                              sizeof(struct rt_qos_capability_parm));
-                       }
-
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("SYNC - after JOIN, SupRateLen=%d, ExtRateLen=%d\n",
-                                 pAd->MlmeAux.SupRateLen,
-                                 pAd->MlmeAux.ExtRateLen));
-
-                       if (AironetCellPowerLimit != 0xFF) {
-                               /*We need to change our TxPower for CCX 2.0 AP Control of Client Transmit Power */
-                               ChangeToCellPowerLimit(pAd,
-                                                      AironetCellPowerLimit);
-                       } else  /*Used the default TX Power Percentage. */
-                               pAd->CommonCfg.TxPowerPercentage =
-                                   pAd->CommonCfg.TxPowerDefault;
-
-                       pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
-                       Status = MLME_SUCCESS;
-                       MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_JOIN_CONF,
-                                   2, &Status);
-               }
-               /* not to me BEACON, ignored */
-       }
-       /* sanity check fail, ignore this frame */
-}
-
-/*
-       ==========================================================================
-       Description:
-               receive BEACON from peer
-
-       IRQL = DISPATCH_LEVEL
-
-       ==========================================================================
- */
-void PeerBeacon(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
-{
-       u8 Bssid[MAC_ADDR_LEN], Addr2[MAC_ADDR_LEN];
-       char Ssid[MAX_LEN_OF_SSID];
-       struct rt_cf_parm CfParm;
-       u8 SsidLen, MessageToMe = 0, BssType, Channel, NewChannel, index = 0;
-       u8 DtimCount = 0, DtimPeriod = 0, BcastFlag = 0;
-       u16 CapabilityInfo, AtimWin, BeaconPeriod;
-       LARGE_INTEGER TimeStamp;
-       u16 TbttNumToNextWakeUp;
-       u8 Erp;
-       u8 SupRate[MAX_LEN_OF_SUPPORTED_RATES],
-           ExtRate[MAX_LEN_OF_SUPPORTED_RATES];
-       u8 SupRateLen, ExtRateLen;
-       u8 CkipFlag;
-       u16 LenVIE;
-       u8 AironetCellPowerLimit;
-       struct rt_edca_parm EdcaParm;
-       struct rt_qbss_load_parm QbssLoad;
-       struct rt_qos_capability_parm QosCapability;
-       unsigned long RalinkIe;
-       /* New for WPA security suites */
-       u8 VarIE[MAX_VIE_LEN];  /* Total VIE length = MAX_VIE_LEN - -5 */
-       struct rt_ndis_802_11_variable_ies *pVIE = NULL;
-       struct rt_ht_capability_ie HtCapability;
-       struct rt_add_ht_info_ie AddHtInfo;     /* AP might use this additional ht info IE */
-       u8 HtCapabilityLen, PreNHtCapabilityLen;
-       u8 AddHtInfoLen;
-       u8 NewExtChannelOffset = 0xff;
-
-       if (!(INFRA_ON(pAd) || ADHOC_ON(pAd)
-           ))
-               return;
-
-       /* Init Variable IE structure */
-       pVIE = (struct rt_ndis_802_11_variable_ies *)VarIE;
-       pVIE->Length = 0;
-       RTMPZeroMemory(&HtCapability, sizeof(HtCapability));
-       RTMPZeroMemory(&AddHtInfo, sizeof(struct rt_add_ht_info_ie));
-
-       if (PeerBeaconAndProbeRspSanity(pAd,
-                                       Elem->Msg,
-                                       Elem->MsgLen,
-                                       Elem->Channel,
-                                       Addr2,
-                                       Bssid,
-                                       Ssid,
-                                       &SsidLen,
-                                       &BssType,
-                                       &BeaconPeriod,
-                                       &Channel,
-                                       &NewChannel,
-                                       &TimeStamp,
-                                       &CfParm,
-                                       &AtimWin,
-                                       &CapabilityInfo,
-                                       &Erp,
-                                       &DtimCount,
-                                       &DtimPeriod,
-                                       &BcastFlag,
-                                       &MessageToMe,
-                                       SupRate,
-                                       &SupRateLen,
-                                       ExtRate,
-                                       &ExtRateLen,
-                                       &CkipFlag,
-                                       &AironetCellPowerLimit,
-                                       &EdcaParm,
-                                       &QbssLoad,
-                                       &QosCapability,
-                                       &RalinkIe,
-                                       &HtCapabilityLen,
-                                       &PreNHtCapabilityLen,
-                                       &HtCapability,
-                                       &AddHtInfoLen,
-                                       &AddHtInfo,
-                                       &NewExtChannelOffset, &LenVIE, pVIE)) {
-               BOOLEAN is_my_bssid, is_my_ssid;
-               unsigned long Bssidx, Now;
-               struct rt_bss_entry *pBss;
-               char RealRssi =
-                   RTMPMaxRssi(pAd, ConvertToRssi(pAd, Elem->Rssi0, RSSI_0),
-                               ConvertToRssi(pAd, Elem->Rssi1, RSSI_1),
-                               ConvertToRssi(pAd, Elem->Rssi2, RSSI_2));
-
-               is_my_bssid =
-                   MAC_ADDR_EQUAL(Bssid, pAd->CommonCfg.Bssid) ? TRUE : FALSE;
-               is_my_ssid =
-                   SSID_EQUAL(Ssid, SsidLen, pAd->CommonCfg.Ssid,
-                              pAd->CommonCfg.SsidLen) ? TRUE : FALSE;
-
-               /* ignore BEACON not for my SSID */
-               if ((!is_my_ssid) && (!is_my_bssid))
-                       return;
-
-               /* It means STA waits disassoc completely from this AP, ignores this beacon. */
-               if (pAd->Mlme.CntlMachine.CurrState == CNTL_WAIT_DISASSOC)
-                       return;
-
-               /* Copy Control channel for this BSSID. */
-               if (AddHtInfoLen != 0)
-                       Channel = AddHtInfo.ControlChan;
-
-               if ((HtCapabilityLen > 0) || (PreNHtCapabilityLen > 0))
-                       HtCapabilityLen = SIZE_HT_CAP_IE;
-
-               /* */
-               /* Housekeeping "SsidBssTab" table for later-on ROAMing usage. */
-               /* */
-               Bssidx = BssTableSearch(&pAd->ScanTab, Bssid, Channel);
-               if (Bssidx == BSS_NOT_FOUND) {
-                       /* discover new AP of this network, create BSS entry */
-                       Bssidx =
-                           BssTableSetEntry(pAd, &pAd->ScanTab, Bssid, Ssid,
-                                            SsidLen, BssType, BeaconPeriod,
-                                            &CfParm, AtimWin, CapabilityInfo,
-                                            SupRate, SupRateLen, ExtRate,
-                                            ExtRateLen, &HtCapability,
-                                            &AddHtInfo, HtCapabilityLen,
-                                            AddHtInfoLen, NewExtChannelOffset,
-                                            Channel, RealRssi, TimeStamp,
-                                            CkipFlag, &EdcaParm,
-                                            &QosCapability, &QbssLoad, LenVIE,
-                                            pVIE);
-                       if (Bssidx == BSS_NOT_FOUND)    /* return if BSS table full */
-                               return;
-
-                       NdisMoveMemory(pAd->ScanTab.BssEntry[Bssidx].PTSF,
-                                      &Elem->Msg[24], 4);
-                       NdisMoveMemory(&pAd->ScanTab.BssEntry[Bssidx].TTSF[0],
-                                      &Elem->TimeStamp.u.LowPart, 4);
-                       NdisMoveMemory(&pAd->ScanTab.BssEntry[Bssidx].TTSF[4],
-                                      &Elem->TimeStamp.u.LowPart, 4);
-
-               }
-
-               if ((pAd->CommonCfg.bIEEE80211H == 1) && (NewChannel != 0)
-                   && (Channel != NewChannel)) {
-                       /* Switching to channel 1 can prevent from rescanning the current channel immediately (by auto reconnection). */
-                       /* In addition, clear the MLME queue and the scan table to discard the RX packets and previous scanning results. */
-                       AsicSwitchChannel(pAd, 1, FALSE);
-                       AsicLockChannel(pAd, 1);
-                       LinkDown(pAd, FALSE);
-                       MlmeQueueInit(&pAd->Mlme.Queue);
-                       BssTableInit(&pAd->ScanTab);
-                       RTMPusecDelay(1000000); /* use delay to prevent STA do reassoc */
-
-                       /* channel sanity check */
-                       for (index = 0; index < pAd->ChannelListNum; index++) {
-                               if (pAd->ChannelList[index].Channel ==
-                                   NewChannel) {
-                                       pAd->ScanTab.BssEntry[Bssidx].Channel =
-                                           NewChannel;
-                                       pAd->CommonCfg.Channel = NewChannel;
-                                       AsicSwitchChannel(pAd,
-                                                         pAd->CommonCfg.
-                                                         Channel, FALSE);
-                                       AsicLockChannel(pAd,
-                                                       pAd->CommonCfg.Channel);
-                                       DBGPRINT(RT_DEBUG_TRACE,
-                                                ("PeerBeacon - STA receive channel switch announcement IE (New Channel =%d)\n",
-                                                 NewChannel));
-                                       break;
-                               }
-                       }
-
-                       if (index >= pAd->ChannelListNum) {
-                               DBGPRINT_ERR("PeerBeacon(can not find New Channel=%d in ChannelList[%d]\n", pAd->CommonCfg.Channel, pAd->ChannelListNum);
-                       }
-               }
-               /* if the ssid matched & bssid unmatched, we should select the bssid with large value. */
-               /* This might happened when two STA start at the same time */
-               if ((!is_my_bssid) && ADHOC_ON(pAd)) {
-                       int i;
-
-                       /* Add the safeguard against the mismatch of adhoc wep status */
-                       if (pAd->StaCfg.WepStatus !=
-                           pAd->ScanTab.BssEntry[Bssidx].WepStatus) {
-                               return;
-                       }
-                       /* collapse into the ADHOC network which has bigger BSSID value. */
-                       for (i = 0; i < 6; i++) {
-                               if (Bssid[i] > pAd->CommonCfg.Bssid[i]) {
-                                       DBGPRINT(RT_DEBUG_TRACE,
-                                               ("SYNC - merge to the IBSS "
-                                                       "with bigger BSSID="
-                                                       "%pM\n", Bssid));
-                                       AsicDisableSync(pAd);
-                                       COPY_MAC_ADDR(pAd->CommonCfg.Bssid,
-                                                     Bssid);
-                                       AsicSetBssid(pAd, pAd->CommonCfg.Bssid);
-                                       MakeIbssBeacon(pAd);    /* re-build BEACON frame */
-                                       AsicEnableIbssSync(pAd);        /* copy BEACON frame to on-chip memory */
-                                       is_my_bssid = TRUE;
-                                       break;
-                               } else if (Bssid[i] < pAd->CommonCfg.Bssid[i])
-                                       break;
-                       }
-               }
-
-               NdisGetSystemUpTime(&Now);
-               pBss = &pAd->ScanTab.BssEntry[Bssidx];
-               pBss->Rssi = RealRssi;  /* lastest RSSI */
-               pBss->LastBeaconRxTime = Now;   /* last RX timestamp */
-
-               /* */
-               /* BEACON from my BSSID - either IBSS or INFRA network */
-               /* */
-               if (is_my_bssid) {
-                       struct rt_rxwi RxWI;
-
-                       pAd->StaCfg.DtimCount = DtimCount;
-                       pAd->StaCfg.DtimPeriod = DtimPeriod;
-                       pAd->StaCfg.LastBeaconRxTime = Now;
-
-                       RxWI.RSSI0 = Elem->Rssi0;
-                       RxWI.RSSI1 = Elem->Rssi1;
-                       RxWI.RSSI2 = Elem->Rssi2;
-
-                       Update_Rssi_Sample(pAd, &pAd->StaCfg.RssiSample, &RxWI);
-                       if (AironetCellPowerLimit != 0xFF) {
-                               /* */
-                               /* We get the Cisco (ccx) "TxPower Limit" required */
-                               /* Changed to appropriate TxPower Limit for Ciso Compatible Extensions */
-                               /* */
-                               ChangeToCellPowerLimit(pAd,
-                                                      AironetCellPowerLimit);
-                       } else {
-                               /* */
-                               /* AironetCellPowerLimit equal to 0xFF means the Cisco (ccx) "TxPower Limit" not exist. */
-                               /* Used the default TX Power Percentage, that set from UI. */
-                               /* */
-                               pAd->CommonCfg.TxPowerPercentage =
-                                   pAd->CommonCfg.TxPowerDefault;
-                       }
-
-                       if (ADHOC_ON(pAd) && (CAP_IS_IBSS_ON(CapabilityInfo))) {
-                               u8 MaxSupportedRateIn500Kbps = 0;
-                               u8 idx;
-                               struct rt_mac_table_entry *pEntry;
-
-                               /* supported rates array may not be sorted. sort it and find the maximum rate */
-                               for (idx = 0; idx < SupRateLen; idx++) {
-                                       if (MaxSupportedRateIn500Kbps <
-                                           (SupRate[idx] & 0x7f))
-                                               MaxSupportedRateIn500Kbps =
-                                                   SupRate[idx] & 0x7f;
-                               }
-
-                               for (idx = 0; idx < ExtRateLen; idx++) {
-                                       if (MaxSupportedRateIn500Kbps <
-                                           (ExtRate[idx] & 0x7f))
-                                               MaxSupportedRateIn500Kbps =
-                                                   ExtRate[idx] & 0x7f;
-                               }
-
-                               /* look up the existing table */
-                               pEntry = MacTableLookup(pAd, Addr2);
-
-                               /* Ad-hoc mode is using MAC address as BA session. So we need to continuously find newly joined adhoc station by receiving beacon. */
-                               /* To prevent always check this, we use wcid == RESERVED_WCID to recognize it as newly joined adhoc station. */
-                               if ((ADHOC_ON(pAd)
-                                    && (Elem->Wcid == RESERVED_WCID))
-                                   || (pEntry
-                                       &&
-                                       ((pEntry->LastBeaconRxTime +
-                                         ADHOC_ENTRY_BEACON_LOST_TIME) <
-                                        Now))) {
-                                       if (pEntry == NULL)
-                                               /* Another adhoc joining, add to our MAC table. */
-                                               pEntry =
-                                                   MacTableInsertEntry(pAd,
-                                                                       Addr2,
-                                                                       BSS0,
-                                                                       FALSE);
-
-                                       if (StaAddMacTableEntry(pAd,
-                                                               pEntry,
-                                                               MaxSupportedRateIn500Kbps,
-                                                               &HtCapability,
-                                                               HtCapabilityLen,
-                                                               &AddHtInfo,
-                                                               AddHtInfoLen,
-                                                               CapabilityInfo)
-                                           == FALSE) {
-                                               DBGPRINT(RT_DEBUG_TRACE,
-                                                        ("ADHOC - Add Entry failed.\n"));
-                                               return;
-                                       }
-
-                                       if (pEntry &&
-                                           (Elem->Wcid == RESERVED_WCID)) {
-                                               idx = pAd->StaCfg.DefaultKeyId;
-                                               RTMP_STA_SECURITY_INFO_ADD(pAd,
-                                                                          BSS0,
-                                                                          idx,
-                                                                          pEntry);
-                                       }
-                               }
-
-                               if (pEntry && pEntry->ValidAsCLI)
-                                       pEntry->LastBeaconRxTime = Now;
-
-                               /* At least another peer in this IBSS, declare MediaState as CONNECTED */
-                               if (!OPSTATUS_TEST_FLAG
-                                   (pAd, fOP_STATUS_MEDIA_STATE_CONNECTED)) {
-                                       OPSTATUS_SET_FLAG(pAd,
-                                                         fOP_STATUS_MEDIA_STATE_CONNECTED);
-
-                                       pAd->IndicateMediaState =
-                                           NdisMediaStateConnected;
-                                       RTMP_IndicateMediaState(pAd);
-                                       pAd->ExtraInfo = GENERAL_LINK_UP;
-                                       AsicSetBssid(pAd, pAd->CommonCfg.Bssid);
-
-                                       /* 2003/03/12 - john */
-                                       /* Make sure this entry in "ScanTab" table, thus complies to Microsoft's policy that */
-                                       /* "site survey" result should always include the current connected network. */
-                                       /* */
-                                       Bssidx =
-                                           BssTableSearch(&pAd->ScanTab, Bssid,
-                                                          Channel);
-                                       if (Bssidx == BSS_NOT_FOUND) {
-                                               Bssidx =
-                                                   BssTableSetEntry(pAd,
-                                                                    &pAd->
-                                                                    ScanTab,
-                                                                    Bssid,
-                                                                    Ssid,
-                                                                    SsidLen,
-                                                                    BssType,
-                                                                    BeaconPeriod,
-                                                                    &CfParm,
-                                                                    AtimWin,
-                                                                    CapabilityInfo,
-                                                                    SupRate,
-                                                                    SupRateLen,
-                                                                    ExtRate,
-                                                                    ExtRateLen,
-                                                                    &HtCapability,
-                                                                    &AddHtInfo,
-                                                                    HtCapabilityLen,
-                                                                    AddHtInfoLen,
-                                                                    NewExtChannelOffset,
-                                                                    Channel,
-                                                                    RealRssi,
-                                                                    TimeStamp,
-                                                                    0,
-                                                                    &EdcaParm,
-                                                                    &QosCapability,
-                                                                    &QbssLoad,
-                                                                    LenVIE,
-                                                                    pVIE);
-                                       }
-                                       DBGPRINT(RT_DEBUG_TRACE,
-                                                ("ADHOC  fOP_STATUS_MEDIA_STATE_CONNECTED.\n"));
-                               }
-                       }
-
-                       if (INFRA_ON(pAd)) {
-                               BOOLEAN bUseShortSlot, bUseBGProtection;
-
-                               /* decide to use/change to - */
-                               /*      1. long slot (20 us) or short slot (9 us) time */
-                               /*      2. turn on/off RTS/CTS and/or CTS-to-self protection */
-                               /*      3. short preamble */
-
-                               /*bUseShortSlot = pAd->CommonCfg.bUseShortSlotTime && CAP_IS_SHORT_SLOT(CapabilityInfo); */
-                               bUseShortSlot =
-                                   CAP_IS_SHORT_SLOT(CapabilityInfo);
-                               if (bUseShortSlot !=
-                                   OPSTATUS_TEST_FLAG(pAd,
-                                                      fOP_STATUS_SHORT_SLOT_INUSED))
-                                       AsicSetSlotTime(pAd, bUseShortSlot);
-
-                               bUseBGProtection = (pAd->CommonCfg.UseBGProtection == 1) ||     /* always use */
-                                   ((pAd->CommonCfg.UseBGProtection == 0)
-                                    && ERP_IS_USE_PROTECTION(Erp));
-
-                               if (pAd->CommonCfg.Channel > 14)        /* always no BG protection in A-band. falsely happened when switching A/G band to a dual-band AP */
-                                       bUseBGProtection = FALSE;
-
-                               if (bUseBGProtection !=
-                                   OPSTATUS_TEST_FLAG(pAd,
-                                                      fOP_STATUS_BG_PROTECTION_INUSED))
-                               {
-                                       if (bUseBGProtection) {
-                                               OPSTATUS_SET_FLAG(pAd,
-                                                                 fOP_STATUS_BG_PROTECTION_INUSED);
-                                               AsicUpdateProtect(pAd,
-                                                                 pAd->MlmeAux.
-                                                                 AddHtInfo.
-                                                                 AddHtInfo2.
-                                                                 OperaionMode,
-                                                                 (OFDMSETPROTECT
-                                                                  |
-                                                                  CCKSETPROTECT
-                                                                  |
-                                                                  ALLN_SETPROTECT),
-                                                                 FALSE,
-                                                                 (pAd->MlmeAux.
-                                                                  AddHtInfo.
-                                                                  AddHtInfo2.
-                                                                  NonGfPresent
-                                                                  == 1));
-                                       } else {
-                                               OPSTATUS_CLEAR_FLAG(pAd,
-                                                                   fOP_STATUS_BG_PROTECTION_INUSED);
-                                               AsicUpdateProtect(pAd,
-                                                                 pAd->MlmeAux.
-                                                                 AddHtInfo.
-                                                                 AddHtInfo2.
-                                                                 OperaionMode,
-                                                                 (OFDMSETPROTECT
-                                                                  |
-                                                                  CCKSETPROTECT
-                                                                  |
-                                                                  ALLN_SETPROTECT),
-                                                                 TRUE,
-                                                                 (pAd->MlmeAux.
-                                                                  AddHtInfo.
-                                                                  AddHtInfo2.
-                                                                  NonGfPresent
-                                                                  == 1));
-                                       }
-
-                                       DBGPRINT(RT_DEBUG_WARN,
-                                                ("SYNC - AP changed B/G protection to %d\n",
-                                                 bUseBGProtection));
-                               }
-                               /* check Ht protection mode. and adhere to the Non-GF device indication by AP. */
-                               if ((AddHtInfoLen != 0) &&
-                                   ((AddHtInfo.AddHtInfo2.OperaionMode !=
-                                     pAd->MlmeAux.AddHtInfo.AddHtInfo2.
-                                     OperaionMode)
-                                    || (AddHtInfo.AddHtInfo2.NonGfPresent !=
-                                        pAd->MlmeAux.AddHtInfo.AddHtInfo2.
-                                        NonGfPresent))) {
-                                       pAd->MlmeAux.AddHtInfo.AddHtInfo2.
-                                           NonGfPresent =
-                                           AddHtInfo.AddHtInfo2.NonGfPresent;
-                                       pAd->MlmeAux.AddHtInfo.AddHtInfo2.
-                                           OperaionMode =
-                                           AddHtInfo.AddHtInfo2.OperaionMode;
-                                       if (pAd->MlmeAux.AddHtInfo.AddHtInfo2.
-                                           NonGfPresent == 1) {
-                                               AsicUpdateProtect(pAd,
-                                                                 pAd->MlmeAux.
-                                                                 AddHtInfo.
-                                                                 AddHtInfo2.
-                                                                 OperaionMode,
-                                                                 ALLN_SETPROTECT,
-                                                                 FALSE, TRUE);
-                                       } else
-                                               AsicUpdateProtect(pAd,
-                                                                 pAd->MlmeAux.
-                                                                 AddHtInfo.
-                                                                 AddHtInfo2.
-                                                                 OperaionMode,
-                                                                 ALLN_SETPROTECT,
-                                                                 FALSE, FALSE);
-
-                                       DBGPRINT(RT_DEBUG_TRACE,
-                                                ("SYNC - AP changed N OperaionMode to %d\n",
-                                                 pAd->MlmeAux.AddHtInfo.
-                                                 AddHtInfo2.OperaionMode));
-                               }
-
-                               if (OPSTATUS_TEST_FLAG
-                                   (pAd, fOP_STATUS_SHORT_PREAMBLE_INUSED)
-                                   && ERP_IS_USE_BARKER_PREAMBLE(Erp)) {
-                                       MlmeSetTxPreamble(pAd,
-                                                         Rt802_11PreambleLong);
-                                       DBGPRINT(RT_DEBUG_TRACE,
-                                                ("SYNC - AP forced to use long preamble\n"));
-                               }
-
-                               if (OPSTATUS_TEST_FLAG
-                                   (pAd, fOP_STATUS_WMM_INUSED)
-                                   && (EdcaParm.bValid == TRUE)
-                                   && (EdcaParm.EdcaUpdateCount !=
-                                       pAd->CommonCfg.APEdcaParm.
-                                       EdcaUpdateCount)) {
-                                       DBGPRINT(RT_DEBUG_TRACE,
-                                                ("SYNC - AP change EDCA parameters(from %d to %d)\n",
-                                                 pAd->CommonCfg.APEdcaParm.
-                                                 EdcaUpdateCount,
-                                                 EdcaParm.EdcaUpdateCount));
-                                       AsicSetEdcaParm(pAd, &EdcaParm);
-                               }
-                               /* copy QOS related information */
-                               NdisMoveMemory(&pAd->CommonCfg.APQbssLoad,
-                                              &QbssLoad,
-                                              sizeof(struct rt_qbss_load_parm));
-                               NdisMoveMemory(&pAd->CommonCfg.APQosCapability,
-                                              &QosCapability,
-                                              sizeof(struct rt_qos_capability_parm));
-                       }
-                       /* only INFRASTRUCTURE mode support power-saving feature */
-                       if ((INFRA_ON(pAd) && (pAd->StaCfg.Psm == PWR_SAVE))
-                           || (pAd->CommonCfg.bAPSDForcePowerSave)) {
-                               u8 FreeNumber;
-                               /*  1. AP has backlogged unicast-to-me frame, stay AWAKE, send PSPOLL */
-                               /*  2. AP has backlogged broadcast/multicast frame and we want those frames, stay AWAKE */
-                               /*  3. we have outgoing frames in TxRing or MgmtRing, better stay AWAKE */
-                               /*  4. Psm change to PWR_SAVE, but AP not been informed yet, we better stay AWAKE */
-                               /*  5. otherwise, put PHY back to sleep to save battery. */
-                               if (MessageToMe) {
-#ifdef RTMP_MAC_PCI
-                                       if (OPSTATUS_TEST_FLAG
-                                           (pAd, fOP_STATUS_PCIE_DEVICE)) {
-                                               /* Restore to correct BBP R3 value */
-                                               if (pAd->Antenna.field.RxPath >
-                                                   1)
-                                                       RTMP_BBP_IO_WRITE8_BY_REG_ID
-                                                           (pAd, BBP_R3,
-                                                            pAd->StaCfg.BBPR3);
-                                               /* Turn clk to 80Mhz. */
-                                       }
-#endif /* RTMP_MAC_PCI // */
-                                       if (pAd->CommonCfg.bAPSDCapable
-                                           && pAd->CommonCfg.APEdcaParm.
-                                           bAPSDCapable
-                                           && pAd->CommonCfg.bAPSDAC_BE
-                                           && pAd->CommonCfg.bAPSDAC_BK
-                                           && pAd->CommonCfg.bAPSDAC_VI
-                                           && pAd->CommonCfg.bAPSDAC_VO) {
-                                               pAd->CommonCfg.
-                                                   bNeedSendTriggerFrame =
-                                                   TRUE;
-                                       } else
-                                               RTMP_PS_POLL_ENQUEUE(pAd);
-                               } else if (BcastFlag && (DtimCount == 0)
-                                          && OPSTATUS_TEST_FLAG(pAd,
-                                                                fOP_STATUS_RECEIVE_DTIM))
-                               {
-#ifdef RTMP_MAC_PCI
-                                       if (OPSTATUS_TEST_FLAG
-                                           (pAd, fOP_STATUS_PCIE_DEVICE)) {
-                                               if (pAd->Antenna.field.RxPath >
-                                                   1)
-                                                       RTMP_BBP_IO_WRITE8_BY_REG_ID
-                                                           (pAd, BBP_R3,
-                                                            pAd->StaCfg.BBPR3);
-                                       }
-#endif /* RTMP_MAC_PCI // */
-                               } else
-                                   if ((pAd->TxSwQueue[QID_AC_BK].Number != 0)
-                                       || (pAd->TxSwQueue[QID_AC_BE].Number !=
-                                           0)
-                                       || (pAd->TxSwQueue[QID_AC_VI].Number !=
-                                           0)
-                                       || (pAd->TxSwQueue[QID_AC_VO].Number !=
-                                           0)
-                                       ||
-                                       (RTMPFreeTXDRequest
-                                        (pAd, QID_AC_BK, TX_RING_SIZE - 1,
-                                         &FreeNumber) != NDIS_STATUS_SUCCESS)
-                                       ||
-                                       (RTMPFreeTXDRequest
-                                        (pAd, QID_AC_BE, TX_RING_SIZE - 1,
-                                         &FreeNumber) != NDIS_STATUS_SUCCESS)
-                                       ||
-                                       (RTMPFreeTXDRequest
-                                        (pAd, QID_AC_VI, TX_RING_SIZE - 1,
-                                         &FreeNumber) != NDIS_STATUS_SUCCESS)
-                                       ||
-                                       (RTMPFreeTXDRequest
-                                        (pAd, QID_AC_VO, TX_RING_SIZE - 1,
-                                         &FreeNumber) != NDIS_STATUS_SUCCESS)
-                                       ||
-                                       (RTMPFreeTXDRequest
-                                        (pAd, QID_MGMT, MGMT_RING_SIZE - 1,
-                                         &FreeNumber) !=
-                                        NDIS_STATUS_SUCCESS)) {
-                                       /* TODO: consider scheduled HCCA. might not be proper to use traditional DTIM-based power-saving scheme */
-                                       /* can we cheat here (i.e. just check MGMT & AC_BE) for better performance? */
-#ifdef RTMP_MAC_PCI
-                                       if (OPSTATUS_TEST_FLAG
-                                           (pAd, fOP_STATUS_PCIE_DEVICE)) {
-                                               if (pAd->Antenna.field.RxPath >
-                                                   1)
-                                                       RTMP_BBP_IO_WRITE8_BY_REG_ID
-                                                           (pAd, BBP_R3,
-                                                            pAd->StaCfg.BBPR3);
-                                       }
-#endif /* RTMP_MAC_PCI // */
-                               } else {
-                                       if ((pAd->CommonCfg.
-                                            bACMAPSDTr[QID_AC_VO])
-                                           || (pAd->CommonCfg.
-                                               bACMAPSDTr[QID_AC_VI])
-                                           || (pAd->CommonCfg.
-                                               bACMAPSDTr[QID_AC_BK])
-                                           || (pAd->CommonCfg.
-                                               bACMAPSDTr[QID_AC_BE])) {
-                                               /*
-                                                  WMM Spec v1.0 3.6.2.4,
-                                                  The WMM STA shall remain awake until it receives a
-                                                  QoS Data or Null frame addressed to it, with the
-                                                  EOSP subfield in QoS Control field set to 1.
-
-                                                  So we can not sleep here or we will suffer a case:
-
-                                                  PS Management Frame -->
-                                                  Trigger frame -->
-                                                  Beacon (TIM=0) (Beacon is closer to Trig frame) -->
-                                                  Station goes to sleep -->
-                                                  AP delivery queued UAPSD packets -->
-                                                  Station can NOT receive the reply
-
-                                                  Maybe we need a timeout timer to avoid that we do
-                                                  NOT receive the EOSP frame.
-
-                                                  We can not use More Data to check if SP is ended
-                                                  due to MaxSPLength.
-                                                */
-                                       } else {
-                                               u16 NextDtim = DtimCount;
-
-                                               if (NextDtim == 0)
-                                                       NextDtim = DtimPeriod;
-
-                                               TbttNumToNextWakeUp =
-                                                   pAd->StaCfg.
-                                                   DefaultListenCount;
-                                               if (OPSTATUS_TEST_FLAG
-                                                   (pAd,
-                                                    fOP_STATUS_RECEIVE_DTIM)
-                                                   && (TbttNumToNextWakeUp >
-                                                       NextDtim))
-                                                       TbttNumToNextWakeUp =
-                                                           NextDtim;
-
-                                               if (!OPSTATUS_TEST_FLAG
-                                                   (pAd, fOP_STATUS_DOZE)) {
-                                                       /* Set a flag to go to sleep . Then after parse this RxDoneInterrupt, will go to sleep mode. */
-                                                       pAd->
-                                                           ThisTbttNumToNextWakeUp
-                                                           =
-                                                           TbttNumToNextWakeUp;
-                                                       AsicSleepThenAutoWakeup
-                                                           (pAd,
-                                                            pAd->
-                                                            ThisTbttNumToNextWakeUp);
-                                               }
-                                       }
-                               }
-                       }
-               }
-               /* not my BSSID, ignore it */
-       }
-       /* sanity check fail, ignore this frame */
-}
-
-/*
-       ==========================================================================
-       Description:
-               Receive PROBE REQ from remote peer when operating in IBSS mode
-       ==========================================================================
- */
-void PeerProbeReqAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
-{
-       u8 Addr2[MAC_ADDR_LEN];
-       char Ssid[MAX_LEN_OF_SSID];
-       u8 SsidLen;
-       u8 HtLen, AddHtLen, NewExtLen;
-       struct rt_header_802_11 ProbeRspHdr;
-       int NStatus;
-       u8 *pOutBuffer = NULL;
-       unsigned long FrameLen = 0;
-       LARGE_INTEGER FakeTimestamp;
-       u8 DsLen = 1, IbssLen = 2;
-       u8 LocalErpIe[3] = { IE_ERP, 1, 0 };
-       BOOLEAN Privacy;
-       u16 CapabilityInfo;
-       u8 RSNIe = IE_WPA;
-
-       if (!ADHOC_ON(pAd))
-               return;
-
-       if (PeerProbeReqSanity
-           (pAd, Elem->Msg, Elem->MsgLen, Addr2, Ssid, &SsidLen)) {
-               if ((SsidLen == 0)
-                   || SSID_EQUAL(Ssid, SsidLen, pAd->CommonCfg.Ssid,
-                                 pAd->CommonCfg.SsidLen)) {
-                       /* allocate and send out ProbeRsp frame */
-                       NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); /*Get an unused nonpaged memory */
-                       if (NStatus != NDIS_STATUS_SUCCESS)
-                               return;
-
-                       /*pAd->StaCfg.AtimWin = 0;  // ?????? */
-
-                       Privacy =
-                           (pAd->StaCfg.WepStatus ==
-                            Ndis802_11Encryption1Enabled)
-                           || (pAd->StaCfg.WepStatus ==
-                               Ndis802_11Encryption2Enabled)
-                           || (pAd->StaCfg.WepStatus ==
-                               Ndis802_11Encryption3Enabled);
-                       CapabilityInfo =
-                           CAP_GENERATE(0, 1, Privacy,
-                                        (pAd->CommonCfg.TxPreamble ==
-                                         Rt802_11PreambleShort), 0, 0);
-
-                       MakeOutgoingFrame(pOutBuffer, &FrameLen,
-                                         sizeof(struct rt_header_802_11), &ProbeRspHdr,
-                                         TIMESTAMP_LEN, &FakeTimestamp,
-                                         2, &pAd->CommonCfg.BeaconPeriod,
-                                         2, &CapabilityInfo,
-                                         1, &SsidIe,
-                                         1, &pAd->CommonCfg.SsidLen,
-                                         pAd->CommonCfg.SsidLen,
-                                         pAd->CommonCfg.Ssid, 1, &SupRateIe, 1,
-                                         &pAd->StaActive.SupRateLen,
-                                         pAd->StaActive.SupRateLen,
-                                         pAd->StaActive.SupRate, 1, &DsIe, 1,
-                                         &DsLen, 1, &pAd->CommonCfg.Channel, 1,
-                                         &IbssIe, 1, &IbssLen, 2,
-                                         &pAd->StaActive.AtimWin, END_OF_ARGS);
-
-                       if (pAd->StaActive.ExtRateLen) {
-                               unsigned long tmp;
-                               MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
-                                                 3, LocalErpIe,
-                                                 1, &ExtRateIe,
-                                                 1, &pAd->StaActive.ExtRateLen,
-                                                 pAd->StaActive.ExtRateLen,
-                                                 &pAd->StaActive.ExtRate,
-                                                 END_OF_ARGS);
-                               FrameLen += tmp;
-                       }
-                       /* If adhoc secruity is set for WPA-None, append the cipher suite IE */
-                       if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone) {
-                               unsigned long tmp;
-                               MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
-                                                 1, &RSNIe,
-                                                 1, &pAd->StaCfg.RSNIE_Len,
-                                                 pAd->StaCfg.RSNIE_Len,
-                                                 pAd->StaCfg.RSN_IE,
-                                                 END_OF_ARGS);
-                               FrameLen += tmp;
-                       }
-
-                       if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED) {
-                               unsigned long TmpLen;
-                               u8 BROADCOM[4] = { 0x0, 0x90, 0x4c, 0x33 };
-                               HtLen = sizeof(pAd->CommonCfg.HtCapability);
-                               AddHtLen = sizeof(pAd->CommonCfg.AddHTInfo);
-                               NewExtLen = 1;
-                               /*New extension channel offset IE is included in Beacon, Probe Rsp or channel Switch Announcement Frame */
-                               if (pAd->bBroadComHT == TRUE) {
-                                       MakeOutgoingFrame(pOutBuffer + FrameLen,
-                                                         &TmpLen, 1, &WpaIe, 4,
-                                                         &BROADCOM[0],
-                                                         pAd->MlmeAux.
-                                                         HtCapabilityLen,
-                                                         &pAd->MlmeAux.
-                                                         HtCapability,
-                                                         END_OF_ARGS);
-                               } else {
-                                       MakeOutgoingFrame(pOutBuffer + FrameLen,
-                                                         &TmpLen, 1, &HtCapIe,
-                                                         1, &HtLen,
-                                                         sizeof
-                                                         (struct rt_ht_capability_ie),
-                                                         &pAd->CommonCfg.
-                                                         HtCapability, 1,
-                                                         &AddHtInfoIe, 1,
-                                                         &AddHtLen,
-                                                         sizeof
-                                                         (struct rt_add_ht_info_ie),
-                                                         &pAd->CommonCfg.
-                                                         AddHTInfo, 1,
-                                                         &NewExtChanIe, 1,
-                                                         &NewExtLen,
-                                                         sizeof
-                                                         (struct rt_new_ext_chan_ie),
-                                                         &pAd->CommonCfg.
-                                                         NewExtChanOffset,
-                                                         END_OF_ARGS);
-                               }
-                               FrameLen += TmpLen;
-                       }
-
-                       MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
-                       MlmeFreeMemory(pAd, pOutBuffer);
-               }
-       }
-}
-
-void BeaconTimeoutAtJoinAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
-{
-       u16 Status;
-       DBGPRINT(RT_DEBUG_TRACE, ("SYNC - BeaconTimeoutAtJoinAction\n"));
-       pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
-       Status = MLME_REJ_TIMEOUT;
-       MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_JOIN_CONF, 2, &Status);
-}
-
-/*
-       ==========================================================================
-       Description:
-               Scan timeout procedure. basically add channel index by 1 and rescan
-       ==========================================================================
- */
-void ScanTimeoutAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
-{
-       pAd->MlmeAux.Channel = NextChannel(pAd, pAd->MlmeAux.Channel);
-
-       /* Only one channel scanned for CISCO beacon request */
-       if ((pAd->MlmeAux.ScanType == SCAN_CISCO_ACTIVE) ||
-           (pAd->MlmeAux.ScanType == SCAN_CISCO_PASSIVE) ||
-           (pAd->MlmeAux.ScanType == SCAN_CISCO_NOISE) ||
-           (pAd->MlmeAux.ScanType == SCAN_CISCO_CHANNEL_LOAD))
-               pAd->MlmeAux.Channel = 0;
-
-       /* this routine will stop if pAd->MlmeAux.Channel == 0 */
-       ScanNextChannel(pAd);
-}
-
-/*
-       ==========================================================================
-       Description:
-       ==========================================================================
- */
-void InvalidStateWhenScan(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
-{
-       u16 Status;
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("AYNC - InvalidStateWhenScan(state=%ld). Reset SYNC machine\n",
-                 pAd->Mlme.SyncMachine.CurrState));
-       pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
-       Status = MLME_STATE_MACHINE_REJECT;
-       MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_SCAN_CONF, 2, &Status);
-}
-
-/*
-       ==========================================================================
-       Description:
-       ==========================================================================
- */
-void InvalidStateWhenJoin(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
-{
-       u16 Status;
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("InvalidStateWhenJoin(state=%ld). Reset SYNC machine\n",
-                 pAd->Mlme.SyncMachine.CurrState));
-       pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
-       Status = MLME_STATE_MACHINE_REJECT;
-       MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_JOIN_CONF, 2, &Status);
-}
-
-/*
-       ==========================================================================
-       Description:
-       ==========================================================================
- */
-void InvalidStateWhenStart(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
-{
-       u16 Status;
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("InvalidStateWhenStart(state=%ld). Reset SYNC machine\n",
-                 pAd->Mlme.SyncMachine.CurrState));
-       pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
-       Status = MLME_STATE_MACHINE_REJECT;
-       MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_START_CONF, 2, &Status);
-}
-
-/*
-       ==========================================================================
-       Description:
-
-       IRQL = DISPATCH_LEVEL
-
-       ==========================================================================
- */
-void EnqueuePsPoll(struct rt_rtmp_adapter *pAd)
-{
-
-       if (pAd->StaCfg.WindowsPowerMode == Ndis802_11PowerModeLegacy_PSP)
-               pAd->PsPollFrame.FC.PwrMgmt = PWR_SAVE;
-       MiniportMMRequest(pAd, 0, (u8 *)& pAd->PsPollFrame,
-                         sizeof(struct rt_pspoll_frame));
-}
-
-/*
-       ==========================================================================
-       Description:
-       ==========================================================================
- */
-void EnqueueProbeRequest(struct rt_rtmp_adapter *pAd)
-{
-       int NState;
-       u8 *pOutBuffer;
-       unsigned long FrameLen = 0;
-       struct rt_header_802_11 Hdr80211;
-
-       DBGPRINT(RT_DEBUG_TRACE, ("force out a ProbeRequest ...\n"));
-
-       NState = MlmeAllocateMemory(pAd, &pOutBuffer);  /*Get an unused nonpaged memory */
-       if (NState == NDIS_STATUS_SUCCESS) {
-               MgtMacHeaderInit(pAd, &Hdr80211, SUBTYPE_PROBE_REQ, 0,
-                                BROADCAST_ADDR, BROADCAST_ADDR);
-
-               /* this ProbeRequest explicitly specify SSID to reduce unwanted ProbeResponse */
-               MakeOutgoingFrame(pOutBuffer, &FrameLen,
-                                 sizeof(struct rt_header_802_11), &Hdr80211,
-                                 1, &SsidIe,
-                                 1, &pAd->CommonCfg.SsidLen,
-                                 pAd->CommonCfg.SsidLen, pAd->CommonCfg.Ssid,
-                                 1, &SupRateIe,
-                                 1, &pAd->StaActive.SupRateLen,
-                                 pAd->StaActive.SupRateLen,
-                                 pAd->StaActive.SupRate, END_OF_ARGS);
-               MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
-               MlmeFreeMemory(pAd, pOutBuffer);
-       }
-
-}
-
-BOOLEAN ScanRunning(struct rt_rtmp_adapter *pAd)
-{
-       return (pAd->Mlme.SyncMachine.CurrState == SCAN_LISTEN) ? TRUE : FALSE;
-}
diff --git a/drivers/staging/rt2860/sta/wpa.c b/drivers/staging/rt2860/sta/wpa.c
deleted file mode 100644 (file)
index ff34832..0000000
+++ /dev/null
@@ -1,374 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-       Module Name:
-       wpa.c
-
-       Abstract:
-
-       Revision History:
-       Who                     When                    What
-       --------        ----------              ----------------------------------------------
-       Jan     Lee             03-07-22                Initial
-       Paul Lin                03-11-28                Modify for supplicant
-       Justin P. Mattock       11/07/2010              Fix typos
-*/
-#include "../rt_config.h"
-
-void inc_byte_array(u8 * counter, int len);
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Process MIC error indication and record MIC error timer.
-
-       Arguments:
-               pAd     Pointer to our adapter
-               pWpaKey                 Pointer to the WPA key structure
-
-       Return Value:
-               None
-
-       IRQL = DISPATCH_LEVEL
-
-       Note:
-
-       ========================================================================
-*/
-void RTMPReportMicError(struct rt_rtmp_adapter *pAd, struct rt_cipher_key *pWpaKey)
-{
-       unsigned long Now;
-       u8 unicastKey = (pWpaKey->Type == PAIRWISE_KEY ? 1 : 0);
-
-       /* Record Last MIC error time and count */
-       NdisGetSystemUpTime(&Now);
-       if (pAd->StaCfg.MicErrCnt == 0) {
-               pAd->StaCfg.MicErrCnt++;
-               pAd->StaCfg.LastMicErrorTime = Now;
-               NdisZeroMemory(pAd->StaCfg.ReplayCounter, 8);
-       } else if (pAd->StaCfg.MicErrCnt == 1) {
-               if ((pAd->StaCfg.LastMicErrorTime + (60 * OS_HZ)) < Now) {
-                       /* Update Last MIC error time, this did not violate two MIC errors within 60 seconds */
-                       pAd->StaCfg.LastMicErrorTime = Now;
-               } else {
-
-                       if (pAd->CommonCfg.bWirelessEvent)
-                               RTMPSendWirelessEvent(pAd,
-                                                     IW_COUNTER_MEASURES_EVENT_FLAG,
-                                                     pAd->MacTab.
-                                                     Content[BSSID_WCID].Addr,
-                                                     BSS0, 0);
-
-                       pAd->StaCfg.LastMicErrorTime = Now;
-                       /* Violate MIC error counts, MIC countermeasures kicks in */
-                       pAd->StaCfg.MicErrCnt++;
-                       /* We shall block all reception */
-                       /* We shall clean all Tx ring and disassociate from AP after next EAPOL frame */
-                       /* */
-                       /* No necessary to clean all Tx ring, on RTMPHardTransmit will stop sending non-802.1X EAPOL packets */
-                       /* if pAd->StaCfg.MicErrCnt greater than 2. */
-                       /* */
-                       /* RTMPRingCleanUp(pAd, QID_AC_BK); */
-                       /* RTMPRingCleanUp(pAd, QID_AC_BE); */
-                       /* RTMPRingCleanUp(pAd, QID_AC_VI); */
-                       /* RTMPRingCleanUp(pAd, QID_AC_VO); */
-                       /* RTMPRingCleanUp(pAd, QID_HCCA); */
-               }
-       } else {
-               /* MIC error count >= 2 */
-               /* This should not happen */
-               ;
-       }
-       MlmeEnqueue(pAd,
-                   MLME_CNTL_STATE_MACHINE,
-                   OID_802_11_MIC_FAILURE_REPORT_FRAME, 1, &unicastKey);
-
-       if (pAd->StaCfg.MicErrCnt == 2) {
-               RTMPSetTimer(&pAd->StaCfg.WpaDisassocAndBlockAssocTimer, 100);
-       }
-}
-
-#define        LENGTH_EAP_H    4
-/* If the received frame is EAP-Packet ,find out its EAP-Code (Request(0x01), Response(0x02), Success(0x03), Failure(0x04)). */
-int WpaCheckEapCode(struct rt_rtmp_adapter *pAd,
-                   u8 *pFrame, u16 FrameLen, u16 OffSet)
-{
-
-       u8 *pData;
-       int result = 0;
-
-       if (FrameLen < OffSet + LENGTH_EAPOL_H + LENGTH_EAP_H)
-               return result;
-
-       pData = pFrame + OffSet;        /* skip offset bytes */
-
-       if (*(pData + 1) == EAPPacket)  /* 802.1x header - Packet Type */
-       {
-               result = *(pData + 4);  /* EAP header - Code */
-       }
-
-       return result;
-}
-
-void WpaSendMicFailureToWpaSupplicant(struct rt_rtmp_adapter *pAd, IN BOOLEAN bUnicast)
-{
-       char custom[IW_CUSTOM_MAX] = { 0 };
-
-       sprintf(custom, "MLME-MICHAELMICFAILURE.indication");
-       if (bUnicast)
-               sprintf(custom, "%s unicast", custom);
-
-       RtmpOSWrielessEventSend(pAd, IWEVCUSTOM, -1, NULL, (u8 *)custom,
-                               strlen(custom));
-
-       return;
-}
-
-void WpaMicFailureReportFrame(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem)
-{
-       u8 *pOutBuffer = NULL;
-       u8 Header802_3[14];
-       unsigned long FrameLen = 0;
-       struct rt_eapol_packet Packet;
-       u8 Mic[16];
-       BOOLEAN bUnicast;
-
-       DBGPRINT(RT_DEBUG_TRACE, ("WpaMicFailureReportFrame ----->\n"));
-
-       bUnicast = (Elem->Msg[0] == 1 ? TRUE : FALSE);
-       pAd->Sequence = ((pAd->Sequence) + 1) & (MAX_SEQ_NUMBER);
-
-       /* init 802.3 header and Fill Packet */
-       MAKE_802_3_HEADER(Header802_3, pAd->CommonCfg.Bssid,
-                         pAd->CurrentAddress, EAPOL);
-
-       NdisZeroMemory(&Packet, sizeof(Packet));
-       Packet.ProVer = EAPOL_VER;
-       Packet.ProType = EAPOLKey;
-
-       Packet.KeyDesc.Type = WPA1_KEY_DESC;
-
-       /* Request field presented */
-       Packet.KeyDesc.KeyInfo.Request = 1;
-
-       if (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled) {
-               Packet.KeyDesc.KeyInfo.KeyDescVer = 2;
-       } else                  /* TKIP */
-       {
-               Packet.KeyDesc.KeyInfo.KeyDescVer = 1;
-       }
-
-       Packet.KeyDesc.KeyInfo.KeyType = (bUnicast ? PAIRWISEKEY : GROUPKEY);
-
-       /* KeyMic field presented */
-       Packet.KeyDesc.KeyInfo.KeyMic = 1;
-
-       /* Error field presented */
-       Packet.KeyDesc.KeyInfo.Error = 1;
-
-       /* Update packet length after decide Key data payload */
-       SET_u16_TO_ARRARY(Packet.Body_Len, LEN_EAPOL_KEY_MSG)
-           /* Key Replay Count */
-           NdisMoveMemory(Packet.KeyDesc.ReplayCounter,
-                          pAd->StaCfg.ReplayCounter, LEN_KEY_DESC_REPLAY);
-       inc_byte_array(pAd->StaCfg.ReplayCounter, 8);
-
-       /* Convert to little-endian format. */
-       *((u16 *) & Packet.KeyDesc.KeyInfo) =
-           cpu2le16(*((u16 *) & Packet.KeyDesc.KeyInfo));
-
-       MlmeAllocateMemory(pAd, (u8 **) & pOutBuffer);  /* allocate memory */
-       if (pOutBuffer == NULL) {
-               return;
-       }
-       /* Prepare EAPOL frame for MIC calculation */
-       /* Be careful, only EAPOL frame is counted for MIC calculation */
-       MakeOutgoingFrame(pOutBuffer, &FrameLen,
-                         CONV_ARRARY_TO_u16(Packet.Body_Len) + 4, &Packet,
-                         END_OF_ARGS);
-
-       /* Prepare and Fill MIC value */
-       NdisZeroMemory(Mic, sizeof(Mic));
-       if (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled) {    /* AES */
-               u8 digest[20] = { 0 };
-               HMAC_SHA1(pAd->StaCfg.PTK, LEN_EAP_MICK, pOutBuffer, FrameLen,
-                         digest, SHA1_DIGEST_SIZE);
-               NdisMoveMemory(Mic, digest, LEN_KEY_DESC_MIC);
-       } else {                /* TKIP */
-               HMAC_MD5(pAd->StaCfg.PTK, LEN_EAP_MICK, pOutBuffer, FrameLen,
-                        Mic, MD5_DIGEST_SIZE);
-       }
-       NdisMoveMemory(Packet.KeyDesc.KeyMic, Mic, LEN_KEY_DESC_MIC);
-
-       /* copy frame to Tx ring and send MIC failure report frame to authenticator */
-       RTMPToWirelessSta(pAd, &pAd->MacTab.Content[BSSID_WCID],
-                         Header802_3, LENGTH_802_3,
-                         (u8 *)& Packet,
-                         CONV_ARRARY_TO_u16(Packet.Body_Len) + 4, FALSE);
-
-       MlmeFreeMemory(pAd, (u8 *)pOutBuffer);
-
-       DBGPRINT(RT_DEBUG_TRACE, ("WpaMicFailureReportFrame <-----\n"));
-}
-
-/** from wpa_supplicant
- * inc_byte_array - Increment arbitrary length byte array by one
- * @counter: Pointer to byte array
- * @len: Length of the counter in bytes
- *
- * This function increments the last byte of the counter by one and continues
- * rolling over to more significant bytes if the byte was incremented from
- * 0xff to 0x00.
- */
-void inc_byte_array(u8 * counter, int len)
-{
-       int pos = len - 1;
-       while (pos >= 0) {
-               counter[pos]++;
-               if (counter[pos] != 0)
-                       break;
-               pos--;
-       }
-}
-
-void WpaDisassocApAndBlockAssoc(void *SystemSpecific1,
-                               void *FunctionContext,
-                               void *SystemSpecific2,
-                               void *SystemSpecific3)
-{
-       struct rt_rtmp_adapter *pAd = (struct rt_rtmp_adapter *)FunctionContext;
-       struct rt_mlme_disassoc_req DisassocReq;
-
-       /* disassoc from current AP first */
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("RTMPReportMicError - disassociate with current AP after sending second continuous EAPOL frame\n"));
-       DisassocParmFill(pAd, &DisassocReq, pAd->CommonCfg.Bssid,
-                        REASON_MIC_FAILURE);
-       MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_MLME_DISASSOC_REQ,
-                   sizeof(struct rt_mlme_disassoc_req), &DisassocReq);
-
-       pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_DISASSOC;
-       pAd->StaCfg.bBlockAssoc = TRUE;
-}
-
-void WpaStaPairwiseKeySetting(struct rt_rtmp_adapter *pAd)
-{
-       struct rt_cipher_key *pSharedKey;
-       struct rt_mac_table_entry *pEntry;
-
-       pEntry = &pAd->MacTab.Content[BSSID_WCID];
-
-       /* Pairwise key shall use key#0 */
-       pSharedKey = &pAd->SharedKey[BSS0][0];
-
-       NdisMoveMemory(pAd->StaCfg.PTK, pEntry->PTK, LEN_PTK);
-
-       /* Prepare pair-wise key information into shared key table */
-       NdisZeroMemory(pSharedKey, sizeof(struct rt_cipher_key));
-       pSharedKey->KeyLen = LEN_TKIP_EK;
-       NdisMoveMemory(pSharedKey->Key, &pAd->StaCfg.PTK[32], LEN_TKIP_EK);
-       NdisMoveMemory(pSharedKey->RxMic, &pAd->StaCfg.PTK[48],
-                      LEN_TKIP_RXMICK);
-       NdisMoveMemory(pSharedKey->TxMic,
-                      &pAd->StaCfg.PTK[48 + LEN_TKIP_RXMICK], LEN_TKIP_TXMICK);
-
-       /* Decide its ChiperAlg */
-       if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
-               pSharedKey->CipherAlg = CIPHER_TKIP;
-       else if (pAd->StaCfg.PairCipher == Ndis802_11Encryption3Enabled)
-               pSharedKey->CipherAlg = CIPHER_AES;
-       else
-               pSharedKey->CipherAlg = CIPHER_NONE;
-
-       /* Update these related information to struct rt_mac_table_entry */
-       NdisMoveMemory(pEntry->PairwiseKey.Key, &pAd->StaCfg.PTK[32],
-                      LEN_TKIP_EK);
-       NdisMoveMemory(pEntry->PairwiseKey.RxMic, &pAd->StaCfg.PTK[48],
-                      LEN_TKIP_RXMICK);
-       NdisMoveMemory(pEntry->PairwiseKey.TxMic,
-                      &pAd->StaCfg.PTK[48 + LEN_TKIP_RXMICK], LEN_TKIP_TXMICK);
-       pEntry->PairwiseKey.CipherAlg = pSharedKey->CipherAlg;
-
-       /* Update pairwise key information to ASIC Shared Key Table */
-       AsicAddSharedKeyEntry(pAd,
-                             BSS0,
-                             0,
-                             pSharedKey->CipherAlg,
-                             pSharedKey->Key,
-                             pSharedKey->TxMic, pSharedKey->RxMic);
-
-       /* Update ASIC WCID attribute table and IVEIV table */
-       RTMPAddWcidAttributeEntry(pAd, BSS0, 0, pSharedKey->CipherAlg, pEntry);
-       STA_PORT_SECURED(pAd);
-       pAd->IndicateMediaState = NdisMediaStateConnected;
-
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("%s : AID(%d) port secured\n", __func__, pEntry->Aid));
-
-}
-
-void WpaStaGroupKeySetting(struct rt_rtmp_adapter *pAd)
-{
-       struct rt_cipher_key *pSharedKey;
-
-       pSharedKey = &pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId];
-
-       /* Prepare pair-wise key information into shared key table */
-       NdisZeroMemory(pSharedKey, sizeof(struct rt_cipher_key));
-       pSharedKey->KeyLen = LEN_TKIP_EK;
-       NdisMoveMemory(pSharedKey->Key, pAd->StaCfg.GTK, LEN_TKIP_EK);
-       NdisMoveMemory(pSharedKey->RxMic, &pAd->StaCfg.GTK[16],
-                      LEN_TKIP_RXMICK);
-       NdisMoveMemory(pSharedKey->TxMic, &pAd->StaCfg.GTK[24],
-                      LEN_TKIP_TXMICK);
-
-       /* Update Shared Key CipherAlg */
-       pSharedKey->CipherAlg = CIPHER_NONE;
-       if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)
-               pSharedKey->CipherAlg = CIPHER_TKIP;
-       else if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption3Enabled)
-               pSharedKey->CipherAlg = CIPHER_AES;
-       else if (pAd->StaCfg.GroupCipher == Ndis802_11GroupWEP40Enabled)
-               pSharedKey->CipherAlg = CIPHER_WEP64;
-       else if (pAd->StaCfg.GroupCipher == Ndis802_11GroupWEP104Enabled)
-               pSharedKey->CipherAlg = CIPHER_WEP128;
-
-       /* Update group key information to ASIC Shared Key Table */
-       AsicAddSharedKeyEntry(pAd,
-                             BSS0,
-                             pAd->StaCfg.DefaultKeyId,
-                             pSharedKey->CipherAlg,
-                             pSharedKey->Key,
-                             pSharedKey->TxMic, pSharedKey->RxMic);
-
-       /* Update ASIC WCID attribute table and IVEIV table */
-       RTMPAddWcidAttributeEntry(pAd,
-                                 BSS0,
-                                 pAd->StaCfg.DefaultKeyId,
-                                 pSharedKey->CipherAlg, NULL);
-
-}
diff --git a/drivers/staging/rt2860/sta_ioctl.c b/drivers/staging/rt2860/sta_ioctl.c
deleted file mode 100644 (file)
index 49b1013..0000000
+++ /dev/null
@@ -1,2912 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-    Module Name:
-    sta_ioctl.c
-
-    Abstract:
-    IOCTL related subroutines
-
-    Revision History:
-       Who                      When          What
-    --------    ----------    ----------------------------------------------
-       Rory Chen               01-03-2003      created
-       Rory Chen               02-14-2005      modify to support RT61
-       Justin P. Mattock       11/07/2010      Fix typos
-*/
-
-#include       "rt_config.h"
-
-#ifdef DBG
-extern unsigned long RTDebugLevel;
-#endif
-
-#define NR_WEP_KEYS                            4
-#define WEP_SMALL_KEY_LEN                      (40/8)
-#define WEP_LARGE_KEY_LEN                      (104/8)
-
-#define GROUP_KEY_NO                4
-
-extern u8 CipherWpa2Template[];
-
-struct PACKED rt_version_info {
-       u8 DriverVersionW;
-       u8 DriverVersionX;
-       u8 DriverVersionY;
-       u8 DriverVersionZ;
-       u32 DriverBuildYear;
-       u32 DriverBuildMonth;
-       u32 DriverBuildDay;
-};
-
-static __s32 ralinkrate[] = { 2, 4, 11, 22,    /* CCK */
-       12, 18, 24, 36, 48, 72, 96, 108,        /* OFDM */
-       13, 26, 39, 52, 78, 104, 117, 130, 26, 52, 78, 104, 156, 208, 234, 260, /* 20MHz, 800ns GI, MCS: 0 ~ 15 */
-       39, 78, 117, 156, 234, 312, 351, 390,   /* 20MHz, 800ns GI, MCS: 16 ~ 23 */
-       27, 54, 81, 108, 162, 216, 243, 270, 54, 108, 162, 216, 324, 432, 486, 540,     /* 40MHz, 800ns GI, MCS: 0 ~ 15 */
-       81, 162, 243, 324, 486, 648, 729, 810,  /* 40MHz, 800ns GI, MCS: 16 ~ 23 */
-       14, 29, 43, 57, 87, 115, 130, 144, 29, 59, 87, 115, 173, 230, 260, 288, /* 20MHz, 400ns GI, MCS: 0 ~ 15 */
-       43, 87, 130, 173, 260, 317, 390, 433,   /* 20MHz, 400ns GI, MCS: 16 ~ 23 */
-       30, 60, 90, 120, 180, 240, 270, 300, 60, 120, 180, 240, 360, 480, 540, 600,     /* 40MHz, 400ns GI, MCS: 0 ~ 15 */
-       90, 180, 270, 360, 540, 720, 810, 900
-};
-
-int Set_SSID_Proc(struct rt_rtmp_adapter *pAdapter, char *arg);
-
-int Set_NetworkType_Proc(struct rt_rtmp_adapter *pAdapter, char *arg);
-
-void RTMPAddKey(struct rt_rtmp_adapter *pAd, struct rt_ndis_802_11_key *pKey)
-{
-       unsigned long KeyIdx;
-       struct rt_mac_table_entry *pEntry;
-
-       DBGPRINT(RT_DEBUG_TRACE, ("RTMPAddKey ------>\n"));
-
-       if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) {
-               if (pKey->KeyIndex & 0x80000000) {
-                       if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone) {
-                               NdisZeroMemory(pAd->StaCfg.PMK, 32);
-                               NdisMoveMemory(pAd->StaCfg.PMK,
-                                              pKey->KeyMaterial,
-                                              pKey->KeyLength);
-                               goto end;
-                       }
-                       /* Update PTK */
-                       NdisZeroMemory(&pAd->SharedKey[BSS0][0],
-                                      sizeof(struct rt_cipher_key));
-                       pAd->SharedKey[BSS0][0].KeyLen = LEN_TKIP_EK;
-                       NdisMoveMemory(pAd->SharedKey[BSS0][0].Key,
-                                      pKey->KeyMaterial, LEN_TKIP_EK);
-
-                       if (pAd->StaCfg.PairCipher ==
-                           Ndis802_11Encryption2Enabled) {
-                               NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic,
-                                              pKey->KeyMaterial + LEN_TKIP_EK,
-                                              LEN_TKIP_TXMICK);
-                               NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic,
-                                              pKey->KeyMaterial + LEN_TKIP_EK +
-                                              LEN_TKIP_TXMICK,
-                                              LEN_TKIP_RXMICK);
-                       } else {
-                               NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic,
-                                              pKey->KeyMaterial + LEN_TKIP_EK,
-                                              LEN_TKIP_TXMICK);
-                               NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic,
-                                              pKey->KeyMaterial + LEN_TKIP_EK +
-                                              LEN_TKIP_TXMICK,
-                                              LEN_TKIP_RXMICK);
-                       }
-
-                       /* Decide its ChiperAlg */
-                       if (pAd->StaCfg.PairCipher ==
-                           Ndis802_11Encryption2Enabled)
-                               pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_TKIP;
-                       else if (pAd->StaCfg.PairCipher ==
-                                Ndis802_11Encryption3Enabled)
-                               pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_AES;
-                       else
-                               pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_NONE;
-
-                       /* Update these related information to struct rt_mac_table_entry */
-                       pEntry = &pAd->MacTab.Content[BSSID_WCID];
-                       NdisMoveMemory(pEntry->PairwiseKey.Key,
-                                      pAd->SharedKey[BSS0][0].Key,
-                                      LEN_TKIP_EK);
-                       NdisMoveMemory(pEntry->PairwiseKey.RxMic,
-                                      pAd->SharedKey[BSS0][0].RxMic,
-                                      LEN_TKIP_RXMICK);
-                       NdisMoveMemory(pEntry->PairwiseKey.TxMic,
-                                      pAd->SharedKey[BSS0][0].TxMic,
-                                      LEN_TKIP_TXMICK);
-                       pEntry->PairwiseKey.CipherAlg =
-                           pAd->SharedKey[BSS0][0].CipherAlg;
-
-                       /* Update pairwise key information to ASIC Shared Key Table */
-                       AsicAddSharedKeyEntry(pAd,
-                                             BSS0,
-                                             0,
-                                             pAd->SharedKey[BSS0][0].CipherAlg,
-                                             pAd->SharedKey[BSS0][0].Key,
-                                             pAd->SharedKey[BSS0][0].TxMic,
-                                             pAd->SharedKey[BSS0][0].RxMic);
-
-                       /* Update ASIC WCID attribute table and IVEIV table */
-                       RTMPAddWcidAttributeEntry(pAd,
-                                                 BSS0,
-                                                 0,
-                                                 pAd->SharedKey[BSS0][0].
-                                                 CipherAlg, pEntry);
-
-                       if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2) {
-                               /* set 802.1x port control */
-                               /*pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED; */
-                               STA_PORT_SECURED(pAd);
-
-                               /* Indicate Connected for GUI */
-                               pAd->IndicateMediaState =
-                                   NdisMediaStateConnected;
-                       }
-               } else {
-                       /* Update GTK */
-                       pAd->StaCfg.DefaultKeyId = (pKey->KeyIndex & 0xFF);
-                       NdisZeroMemory(&pAd->
-                                      SharedKey[BSS0][pAd->StaCfg.
-                                                      DefaultKeyId],
-                                      sizeof(struct rt_cipher_key));
-                       pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].KeyLen =
-                           LEN_TKIP_EK;
-                       NdisMoveMemory(pAd->
-                                      SharedKey[BSS0][pAd->StaCfg.
-                                                      DefaultKeyId].Key,
-                                      pKey->KeyMaterial, LEN_TKIP_EK);
-
-                       if (pAd->StaCfg.GroupCipher ==
-                           Ndis802_11Encryption2Enabled) {
-                               NdisMoveMemory(pAd->
-                                              SharedKey[BSS0][pAd->StaCfg.
-                                                              DefaultKeyId].
-                                              RxMic,
-                                              pKey->KeyMaterial + LEN_TKIP_EK,
-                                              LEN_TKIP_TXMICK);
-                               NdisMoveMemory(pAd->
-                                              SharedKey[BSS0][pAd->StaCfg.
-                                                              DefaultKeyId].
-                                              TxMic,
-                                              pKey->KeyMaterial + LEN_TKIP_EK +
-                                              LEN_TKIP_TXMICK,
-                                              LEN_TKIP_RXMICK);
-                       } else {
-                               NdisMoveMemory(pAd->
-                                              SharedKey[BSS0][pAd->StaCfg.
-                                                              DefaultKeyId].
-                                              TxMic,
-                                              pKey->KeyMaterial + LEN_TKIP_EK,
-                                              LEN_TKIP_TXMICK);
-                               NdisMoveMemory(pAd->
-                                              SharedKey[BSS0][pAd->StaCfg.
-                                                              DefaultKeyId].
-                                              RxMic,
-                                              pKey->KeyMaterial + LEN_TKIP_EK +
-                                              LEN_TKIP_TXMICK,
-                                              LEN_TKIP_RXMICK);
-                       }
-
-                       /* Update Shared Key CipherAlg */
-                       pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].
-                           CipherAlg = CIPHER_NONE;
-                       if (pAd->StaCfg.GroupCipher ==
-                           Ndis802_11Encryption2Enabled)
-                               pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].
-                                   CipherAlg = CIPHER_TKIP;
-                       else if (pAd->StaCfg.GroupCipher ==
-                                Ndis802_11Encryption3Enabled)
-                               pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].
-                                   CipherAlg = CIPHER_AES;
-
-                       /* Update group key information to ASIC Shared Key Table */
-                       AsicAddSharedKeyEntry(pAd,
-                                             BSS0,
-                                             pAd->StaCfg.DefaultKeyId,
-                                             pAd->SharedKey[BSS0][pAd->StaCfg.
-                                                                  DefaultKeyId].
-                                             CipherAlg,
-                                             pAd->SharedKey[BSS0][pAd->StaCfg.
-                                                                  DefaultKeyId].
-                                             Key,
-                                             pAd->SharedKey[BSS0][pAd->StaCfg.
-                                                                  DefaultKeyId].
-                                             TxMic,
-                                             pAd->SharedKey[BSS0][pAd->StaCfg.
-                                                                  DefaultKeyId].
-                                             RxMic);
-
-                       /* Update ASIC WCID attribute table and IVEIV table */
-                       RTMPAddWcidAttributeEntry(pAd,
-                                                 BSS0,
-                                                 pAd->StaCfg.DefaultKeyId,
-                                                 pAd->SharedKey[BSS0][pAd->
-                                                                      StaCfg.
-                                                                      DefaultKeyId].
-                                                 CipherAlg, NULL);
-
-                       /* set 802.1x port control */
-                       /*pAd->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED; */
-                       STA_PORT_SECURED(pAd);
-
-                       /* Indicate Connected for GUI */
-                       pAd->IndicateMediaState = NdisMediaStateConnected;
-               }
-       } else                  /* dynamic WEP from wpa_supplicant */
-       {
-               u8 CipherAlg;
-               u8 *Key;
-
-               if (pKey->KeyLength == 32)
-                       goto end;
-
-               KeyIdx = pKey->KeyIndex & 0x0fffffff;
-
-               if (KeyIdx < 4) {
-                       /* it is a default shared key, for Pairwise key setting */
-                       if (pKey->KeyIndex & 0x80000000) {
-                               pEntry = MacTableLookup(pAd, pKey->BSSID);
-
-                               if (pEntry) {
-                                       DBGPRINT(RT_DEBUG_TRACE,
-                                                ("RTMPAddKey: Set Pair-wise Key\n"));
-
-                                       /* set key material and key length */
-                                       pEntry->PairwiseKey.KeyLen =
-                                           (u8)pKey->KeyLength;
-                                       NdisMoveMemory(pEntry->PairwiseKey.Key,
-                                                      &pKey->KeyMaterial,
-                                                      pKey->KeyLength);
-
-                                       /* set Cipher type */
-                                       if (pKey->KeyLength == 5)
-                                               pEntry->PairwiseKey.CipherAlg =
-                                                   CIPHER_WEP64;
-                                       else
-                                               pEntry->PairwiseKey.CipherAlg =
-                                                   CIPHER_WEP128;
-
-                                       /* Add Pair-wise key to Asic */
-                                       AsicAddPairwiseKeyEntry(pAd,
-                                                               pEntry->Addr,
-                                                               (u8)pEntry->
-                                                               Aid,
-                                                               &pEntry->
-                                                               PairwiseKey);
-
-                                       /* update WCID attribute table and IVEIV table for this entry */
-                                       RTMPAddWcidAttributeEntry(pAd, BSS0, KeyIdx,    /* The value may be not zero */
-                                                                 pEntry->
-                                                                 PairwiseKey.
-                                                                 CipherAlg,
-                                                                 pEntry);
-
-                               }
-                       } else {
-                               /* Default key for tx (shared key) */
-                               pAd->StaCfg.DefaultKeyId = (u8)KeyIdx;
-
-                               /* set key material and key length */
-                               pAd->SharedKey[BSS0][KeyIdx].KeyLen =
-                                   (u8)pKey->KeyLength;
-                               NdisMoveMemory(pAd->SharedKey[BSS0][KeyIdx].Key,
-                                              &pKey->KeyMaterial,
-                                              pKey->KeyLength);
-
-                               /* Set Ciper type */
-                               if (pKey->KeyLength == 5)
-                                       pAd->SharedKey[BSS0][KeyIdx].CipherAlg =
-                                           CIPHER_WEP64;
-                               else
-                                       pAd->SharedKey[BSS0][KeyIdx].CipherAlg =
-                                           CIPHER_WEP128;
-
-                               CipherAlg =
-                                   pAd->SharedKey[BSS0][KeyIdx].CipherAlg;
-                               Key = pAd->SharedKey[BSS0][KeyIdx].Key;
-
-                               /* Set Group key material to Asic */
-                               AsicAddSharedKeyEntry(pAd, BSS0, KeyIdx,
-                                                     CipherAlg, Key, NULL,
-                                                     NULL);
-
-                               /* Update WCID attribute table and IVEIV table for this group key table */
-                               RTMPAddWcidAttributeEntry(pAd, BSS0, KeyIdx,
-                                                         CipherAlg, NULL);
-
-                       }
-               }
-       }
-end:
-       return;
-}
-
-char *rtstrchr(const char *s, int c)
-{
-       for (; *s != (char)c; ++s)
-               if (*s == '\0')
-                       return NULL;
-       return (char *)s;
-}
-
-/*
-This is required for LinEX2004/kernel2.6.7 to provide iwlist scanning function
-*/
-
-int
-rt_ioctl_giwname(struct net_device *dev,
-                struct iw_request_info *info, char *name, char *extra)
-{
-       strncpy(name, "Ralink STA", IFNAMSIZ);
-       /* RT2870 2.1.0.0 uses "RT2870 Wireless" */
-       /* RT3090 2.1.0.0 uses "RT2860 Wireless" */
-       return 0;
-}
-
-int rt_ioctl_siwfreq(struct net_device *dev,
-                    struct iw_request_info *info,
-                    struct iw_freq *freq, char *extra)
-{
-       struct rt_rtmp_adapter *pAdapter = NULL;
-       int chan = -1;
-
-       GET_PAD_FROM_NET_DEV(pAdapter, dev);
-
-       /*check if the interface is down */
-       if (!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE)) {
-               DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
-               return -ENETDOWN;
-       }
-
-       if (freq->e > 1)
-               return -EINVAL;
-
-       if ((freq->e == 0) && (freq->m <= 1000))
-               chan = freq->m; /* Setting by channel number */
-       else
-               MAP_KHZ_TO_CHANNEL_ID((freq->m / 100), chan);   /* Setting by frequency - search the table , like 2.412G, 2.422G, */
-
-       if (ChannelSanity(pAdapter, chan) == TRUE) {
-               pAdapter->CommonCfg.Channel = chan;
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("==>rt_ioctl_siwfreq::SIOCSIWFREQ[cmd=0x%x] (Channel=%d)\n",
-                         SIOCSIWFREQ, pAdapter->CommonCfg.Channel));
-       } else
-               return -EINVAL;
-
-       return 0;
-}
-
-int rt_ioctl_giwfreq(struct net_device *dev,
-                    struct iw_request_info *info,
-                    struct iw_freq *freq, char *extra)
-{
-       struct rt_rtmp_adapter *pAdapter = NULL;
-       u8 ch;
-       unsigned long m = 2412000;
-
-       GET_PAD_FROM_NET_DEV(pAdapter, dev);
-
-       ch = pAdapter->CommonCfg.Channel;
-
-       DBGPRINT(RT_DEBUG_TRACE, ("==>rt_ioctl_giwfreq  %d\n", ch));
-
-       MAP_CHANNEL_ID_TO_KHZ(ch, m);
-       freq->m = m * 100;
-       freq->e = 1;
-       return 0;
-}
-
-int rt_ioctl_siwmode(struct net_device *dev,
-                    struct iw_request_info *info, __u32 * mode, char *extra)
-{
-       struct rt_rtmp_adapter *pAdapter = NULL;
-
-       GET_PAD_FROM_NET_DEV(pAdapter, dev);
-
-       /*check if the interface is down */
-       if (!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE)) {
-               DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
-               return -ENETDOWN;
-       }
-
-       switch (*mode) {
-       case IW_MODE_ADHOC:
-               Set_NetworkType_Proc(pAdapter, "Adhoc");
-               break;
-       case IW_MODE_INFRA:
-               Set_NetworkType_Proc(pAdapter, "Infra");
-               break;
-       case IW_MODE_MONITOR:
-               Set_NetworkType_Proc(pAdapter, "Monitor");
-               break;
-       default:
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("===>rt_ioctl_siwmode::SIOCSIWMODE (unknown %d)\n",
-                         *mode));
-               return -EINVAL;
-       }
-
-       /* Reset Ralink supplicant to not use, it will be set to start when UI set PMK key */
-       pAdapter->StaCfg.WpaState = SS_NOTUSE;
-
-       return 0;
-}
-
-int rt_ioctl_giwmode(struct net_device *dev,
-                    struct iw_request_info *info, __u32 * mode, char *extra)
-{
-       struct rt_rtmp_adapter *pAdapter = NULL;
-
-       GET_PAD_FROM_NET_DEV(pAdapter, dev);
-
-       if (ADHOC_ON(pAdapter))
-               *mode = IW_MODE_ADHOC;
-       else if (INFRA_ON(pAdapter))
-               *mode = IW_MODE_INFRA;
-       else if (MONITOR_ON(pAdapter)) {
-               *mode = IW_MODE_MONITOR;
-       } else
-               *mode = IW_MODE_AUTO;
-
-       DBGPRINT(RT_DEBUG_TRACE, ("==>rt_ioctl_giwmode(mode=%d)\n", *mode));
-       return 0;
-}
-
-int rt_ioctl_siwsens(struct net_device *dev,
-                    struct iw_request_info *info, char *name, char *extra)
-{
-       struct rt_rtmp_adapter *pAdapter = NULL;
-
-       GET_PAD_FROM_NET_DEV(pAdapter, dev);
-
-       /*check if the interface is down */
-       if (!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE)) {
-               DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
-               return -ENETDOWN;
-       }
-
-       return 0;
-}
-
-int rt_ioctl_giwsens(struct net_device *dev,
-                    struct iw_request_info *info, char *name, char *extra)
-{
-       return 0;
-}
-
-int rt_ioctl_giwrange(struct net_device *dev,
-                     struct iw_request_info *info,
-                     struct iw_point *data, char *extra)
-{
-       struct rt_rtmp_adapter *pAdapter = NULL;
-       struct iw_range *range = (struct iw_range *)extra;
-       u16 val;
-       int i;
-
-       GET_PAD_FROM_NET_DEV(pAdapter, dev);
-
-       DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_giwrange\n"));
-       data->length = sizeof(struct iw_range);
-       memset(range, 0, sizeof(struct iw_range));
-
-       range->txpower_capa = IW_TXPOW_DBM;
-
-       if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter)) {
-               range->min_pmp = 1 * 1024;
-               range->max_pmp = 65535 * 1024;
-               range->min_pmt = 1 * 1024;
-               range->max_pmt = 1000 * 1024;
-               range->pmp_flags = IW_POWER_PERIOD;
-               range->pmt_flags = IW_POWER_TIMEOUT;
-               range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT |
-                   IW_POWER_UNICAST_R | IW_POWER_ALL_R;
-       }
-
-       range->we_version_compiled = WIRELESS_EXT;
-       range->we_version_source = 14;
-
-       range->retry_capa = IW_RETRY_LIMIT;
-       range->retry_flags = IW_RETRY_LIMIT;
-       range->min_retry = 0;
-       range->max_retry = 255;
-
-       range->num_channels = pAdapter->ChannelListNum;
-
-       val = 0;
-       for (i = 1; i <= range->num_channels; i++) {
-               u32 m = 2412000;
-               range->freq[val].i = pAdapter->ChannelList[i - 1].Channel;
-               MAP_CHANNEL_ID_TO_KHZ(pAdapter->ChannelList[i - 1].Channel, m);
-               range->freq[val].m = m * 100;   /* OS_HZ */
-
-               range->freq[val].e = 1;
-               val++;
-               if (val == IW_MAX_FREQUENCIES)
-                       break;
-       }
-       range->num_frequency = val;
-
-       range->max_qual.qual = 100;     /* what is correct max? This was not
-                                        * documented exactly. At least
-                                        * 69 has been observed. */
-       range->max_qual.level = 0;      /* dB */
-       range->max_qual.noise = 0;      /* dB */
-
-       /* What would be suitable values for "average/typical" qual? */
-       range->avg_qual.qual = 20;
-       range->avg_qual.level = -60;
-       range->avg_qual.noise = -95;
-       range->sensitivity = 3;
-
-       range->max_encoding_tokens = NR_WEP_KEYS;
-       range->num_encoding_sizes = 2;
-       range->encoding_size[0] = 5;
-       range->encoding_size[1] = 13;
-
-       range->min_rts = 0;
-       range->max_rts = 2347;
-       range->min_frag = 256;
-       range->max_frag = 2346;
-
-       /* IW_ENC_CAPA_* bit field */
-       range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
-           IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
-
-       return 0;
-}
-
-int rt_ioctl_siwap(struct net_device *dev,
-                  struct iw_request_info *info,
-                  struct sockaddr *ap_addr, char *extra)
-{
-       struct rt_rtmp_adapter *pAdapter = NULL;
-       NDIS_802_11_MAC_ADDRESS Bssid;
-
-       GET_PAD_FROM_NET_DEV(pAdapter, dev);
-
-       /*check if the interface is down */
-       if (!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE)) {
-               DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
-               return -ENETDOWN;
-       }
-
-       if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE) {
-               RTMP_MLME_RESET_STATE_MACHINE(pAdapter);
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("MLME busy, reset MLME state machine!\n"));
-       }
-       /* tell CNTL state machine to call NdisMSetInformationComplete() after completing */
-       /* this request, because this request is initiated by NDIS. */
-       pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
-       /* Prevent to connect AP again in STAMlmePeriodicExec */
-       pAdapter->MlmeAux.AutoReconnectSsidLen = 32;
-
-       memcpy(Bssid, ap_addr->sa_data, MAC_ADDR_LEN);
-       MlmeEnqueue(pAdapter,
-                   MLME_CNTL_STATE_MACHINE,
-                   OID_802_11_BSSID,
-                   sizeof(NDIS_802_11_MAC_ADDRESS), (void *) & Bssid);
-
-       DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCSIWAP %pM\n", Bssid));
-
-       return 0;
-}
-
-int rt_ioctl_giwap(struct net_device *dev,
-                  struct iw_request_info *info,
-                  struct sockaddr *ap_addr, char *extra)
-{
-       struct rt_rtmp_adapter *pAdapter = NULL;
-
-       GET_PAD_FROM_NET_DEV(pAdapter, dev);
-
-       if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter)) {
-               ap_addr->sa_family = ARPHRD_ETHER;
-               memcpy(ap_addr->sa_data, &pAdapter->CommonCfg.Bssid, ETH_ALEN);
-       }
-       /* Add for RT2870 */
-       else if (pAdapter->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE) {
-               ap_addr->sa_family = ARPHRD_ETHER;
-               memcpy(ap_addr->sa_data, &pAdapter->MlmeAux.Bssid, ETH_ALEN);
-       } else {
-               DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCGIWAP(=EMPTY)\n"));
-               return -ENOTCONN;
-       }
-
-       return 0;
-}
-
-/*
- * Units are in db above the noise floor. That means the
- * rssi values reported in the tx/rx descriptors in the
- * driver are the SNR expressed in db.
- *
- * If you assume that the noise floor is -95, which is an
- * excellent assumption 99.5 % of the time, then you can
- * derive the absolute signal level (i.e. -95 + rssi).
- * There are some other slight factors to take into account
- * depending on whether the rssi measurement is from 11b,
- * 11g, or 11a.   These differences are at most 2db and
- * can be documented.
- *
- * NB: various calculations are based on the orinoco/wavelan
- *     drivers for compatibility
- */
-static void set_quality(struct rt_rtmp_adapter *pAdapter,
-                       struct iw_quality *iq, signed char rssi)
-{
-       __u8 ChannelQuality;
-
-       /* Normalize Rssi */
-       if (rssi >= -50)
-               ChannelQuality = 100;
-       else if (rssi >= -80)   /* between -50 ~ -80dbm */
-               ChannelQuality = (__u8) (24 + ((rssi + 80) * 26) / 10);
-       else if (rssi >= -90)   /* between -80 ~ -90dbm */
-               ChannelQuality = (__u8) ((rssi + 90) * 26) / 10;
-       else
-               ChannelQuality = 0;
-
-       iq->qual = (__u8) ChannelQuality;
-
-       iq->level = (__u8) (rssi);
-       iq->noise = (pAdapter->BbpWriteLatch[66] > pAdapter->BbpTuning.FalseCcaUpperThreshold) ? ((__u8) pAdapter->BbpTuning.FalseCcaUpperThreshold) : ((__u8) pAdapter->BbpWriteLatch[66]);    /* noise level (dBm) */
-       iq->noise += 256 - 143;
-       iq->updated = pAdapter->iw_stats.qual.updated;
-}
-
-int rt_ioctl_iwaplist(struct net_device *dev,
-                     struct iw_request_info *info,
-                     struct iw_point *data, char *extra)
-{
-       struct rt_rtmp_adapter *pAdapter = NULL;
-
-       struct sockaddr addr[IW_MAX_AP];
-       struct iw_quality qual[IW_MAX_AP];
-       int i;
-
-       GET_PAD_FROM_NET_DEV(pAdapter, dev);
-
-       /*check if the interface is down */
-       if (!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE)) {
-               DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
-               data->length = 0;
-               return 0;
-               /*return -ENETDOWN; */
-       }
-
-       for (i = 0; i < IW_MAX_AP; i++) {
-               if (i >= pAdapter->ScanTab.BssNr)
-                       break;
-               addr[i].sa_family = ARPHRD_ETHER;
-               memcpy(addr[i].sa_data, &pAdapter->ScanTab.BssEntry[i].Bssid,
-                      MAC_ADDR_LEN);
-               set_quality(pAdapter, &qual[i],
-                           pAdapter->ScanTab.BssEntry[i].Rssi);
-       }
-       data->length = i;
-       memcpy(extra, &addr, i * sizeof(addr[0]));
-       data->flags = 1;        /* signal quality present (sort of) */
-       memcpy(extra + i * sizeof(addr[0]), &qual, i * sizeof(qual[i]));
-
-       return 0;
-}
-
-int rt_ioctl_siwscan(struct net_device *dev,
-                    struct iw_request_info *info,
-                    struct iw_point *data, char *extra)
-{
-       struct rt_rtmp_adapter *pAdapter = NULL;
-
-       unsigned long Now;
-       int Status = NDIS_STATUS_SUCCESS;
-
-       GET_PAD_FROM_NET_DEV(pAdapter, dev);
-
-       /*check if the interface is down */
-       if (!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE)) {
-               DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
-               return -ENETDOWN;
-       }
-
-       if (MONITOR_ON(pAdapter)) {
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("Driver is in Monitor Mode now!\n"));
-               return -EINVAL;
-       }
-
-       if (pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE) {
-               pAdapter->StaCfg.WpaSupplicantScanCount++;
-       }
-
-       pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
-       if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
-               return NDIS_STATUS_SUCCESS;
-       do {
-               Now = jiffies;
-
-               if ((pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE)
-                   && (pAdapter->StaCfg.WpaSupplicantScanCount > 3)) {
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("WpaSupplicantScanCount > 3\n"));
-                       Status = NDIS_STATUS_SUCCESS;
-                       break;
-               }
-
-               if ((OPSTATUS_TEST_FLAG
-                    (pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED))
-                   && ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA)
-                       || (pAdapter->StaCfg.AuthMode ==
-                           Ndis802_11AuthModeWPAPSK))
-                   && (pAdapter->StaCfg.PortSecured ==
-                       WPA_802_1X_PORT_NOT_SECURED)) {
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("Link UP, Port Not Secured! ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
-                       Status = NDIS_STATUS_SUCCESS;
-                       break;
-               }
-
-               if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE) {
-                       RTMP_MLME_RESET_STATE_MACHINE(pAdapter);
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("MLME busy, reset MLME state machine!\n"));
-               }
-               /* tell CNTL state machine to call NdisMSetInformationComplete() after completing */
-               /* this request, because this request is initiated by NDIS. */
-               pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
-               /* Reset allowed scan retries */
-               pAdapter->StaCfg.ScanCnt = 0;
-               pAdapter->StaCfg.LastScanTime = Now;
-
-               MlmeEnqueue(pAdapter,
-                           MLME_CNTL_STATE_MACHINE,
-                           OID_802_11_BSSID_LIST_SCAN, 0, NULL);
-
-               Status = NDIS_STATUS_SUCCESS;
-               RTMP_MLME_HANDLER(pAdapter);
-       } while (0);
-       return NDIS_STATUS_SUCCESS;
-}
-
-int rt_ioctl_giwscan(struct net_device *dev,
-                    struct iw_request_info *info,
-                    struct iw_point *data, char *extra)
-{
-       struct rt_rtmp_adapter *pAdapter = NULL;
-       int i = 0;
-       char *current_ev = extra, *previous_ev = extra;
-       char *end_buf;
-       char *current_val;
-       char custom[MAX_CUSTOM_LEN] = { 0 };
-       struct iw_event iwe;
-
-       GET_PAD_FROM_NET_DEV(pAdapter, dev);
-
-       if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS)) {
-               /*
-                * Still scanning, indicate the caller should try again.
-                */
-               return -EAGAIN;
-       }
-
-       if (pAdapter->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE) {
-               pAdapter->StaCfg.WpaSupplicantScanCount = 0;
-       }
-
-       if (pAdapter->ScanTab.BssNr == 0) {
-               data->length = 0;
-               return 0;
-       }
-
-       if (data->length > 0)
-               end_buf = extra + data->length;
-       else
-               end_buf = extra + IW_SCAN_MAX_DATA;
-
-       for (i = 0; i < pAdapter->ScanTab.BssNr; i++) {
-               if (current_ev >= end_buf) {
-                       return -E2BIG;
-               }
-               /*MAC address */
-               /*================================ */
-               memset(&iwe, 0, sizeof(iwe));
-               iwe.cmd = SIOCGIWAP;
-               iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
-               memcpy(iwe.u.ap_addr.sa_data,
-                      &pAdapter->ScanTab.BssEntry[i].Bssid, ETH_ALEN);
-
-               previous_ev = current_ev;
-               current_ev =
-                   iwe_stream_add_event(info, current_ev, end_buf, &iwe,
-                                        IW_EV_ADDR_LEN);
-               if (current_ev == previous_ev)
-                       return -E2BIG;
-
-               /*
-                  Protocol:
-                  it will show scanned AP's WirelessMode.
-                  it might be
-                  802.11a
-                  802.11a/n
-                  802.11g/n
-                  802.11b/g/n
-                  802.11g
-                  802.11b/g
-                */
-               memset(&iwe, 0, sizeof(iwe));
-               iwe.cmd = SIOCGIWNAME;
-
-               {
-                       struct rt_bss_entry *pBssEntry = &pAdapter->ScanTab.BssEntry[i];
-                       BOOLEAN isGonly = FALSE;
-                       int rateCnt = 0;
-
-                       if (pBssEntry->Channel > 14) {
-                               if (pBssEntry->HtCapabilityLen != 0)
-                                       strcpy(iwe.u.name, "802.11a/n");
-                               else
-                                       strcpy(iwe.u.name, "802.11a");
-                       } else {
-                               /*
-                                  if one of non B mode rate is set supported rate, it means G only.
-                                */
-                               for (rateCnt = 0;
-                                    rateCnt < pBssEntry->SupRateLen;
-                                    rateCnt++) {
-                                       /*
-                                          6Mbps(140) 9Mbps(146) and >=12Mbps(152) are supported rate, it means G only.
-                                        */
-                                       if (pBssEntry->SupRate[rateCnt] == 140
-                                           || pBssEntry->SupRate[rateCnt] ==
-                                           146
-                                           || pBssEntry->SupRate[rateCnt] >=
-                                           152)
-                                               isGonly = TRUE;
-                               }
-
-                               for (rateCnt = 0;
-                                    rateCnt < pBssEntry->ExtRateLen;
-                                    rateCnt++) {
-                                       if (pBssEntry->ExtRate[rateCnt] == 140
-                                           || pBssEntry->ExtRate[rateCnt] ==
-                                           146
-                                           || pBssEntry->ExtRate[rateCnt] >=
-                                           152)
-                                               isGonly = TRUE;
-                               }
-
-                               if (pBssEntry->HtCapabilityLen != 0) {
-                                       if (isGonly == TRUE)
-                                               strcpy(iwe.u.name, "802.11g/n");
-                                       else
-                                               strcpy(iwe.u.name,
-                                                      "802.11b/g/n");
-                               } else {
-                                       if (isGonly == TRUE)
-                                               strcpy(iwe.u.name, "802.11g");
-                                       else {
-                                               if (pBssEntry->SupRateLen == 4
-                                                   && pBssEntry->ExtRateLen ==
-                                                   0)
-                                                       strcpy(iwe.u.name,
-                                                              "802.11b");
-                                               else
-                                                       strcpy(iwe.u.name,
-                                                              "802.11b/g");
-                                       }
-                               }
-                       }
-               }
-
-               previous_ev = current_ev;
-               current_ev =
-                   iwe_stream_add_event(info, current_ev, end_buf, &iwe,
-                                        IW_EV_ADDR_LEN);
-               if (current_ev == previous_ev)
-                       return -E2BIG;
-
-               /*ESSID */
-               /*================================ */
-               memset(&iwe, 0, sizeof(iwe));
-               iwe.cmd = SIOCGIWESSID;
-               iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].SsidLen;
-               iwe.u.data.flags = 1;
-
-               previous_ev = current_ev;
-               current_ev =
-                   iwe_stream_add_point(info, current_ev, end_buf, &iwe,
-                                        (char *)pAdapter->ScanTab.
-                                        BssEntry[i].Ssid);
-               if (current_ev == previous_ev)
-                       return -E2BIG;
-
-               /*Network Type */
-               /*================================ */
-               memset(&iwe, 0, sizeof(iwe));
-               iwe.cmd = SIOCGIWMODE;
-               if (pAdapter->ScanTab.BssEntry[i].BssType == Ndis802_11IBSS) {
-                       iwe.u.mode = IW_MODE_ADHOC;
-               } else if (pAdapter->ScanTab.BssEntry[i].BssType ==
-                          Ndis802_11Infrastructure) {
-                       iwe.u.mode = IW_MODE_INFRA;
-               } else {
-                       iwe.u.mode = IW_MODE_AUTO;
-               }
-               iwe.len = IW_EV_UINT_LEN;
-
-               previous_ev = current_ev;
-               current_ev =
-                   iwe_stream_add_event(info, current_ev, end_buf, &iwe,
-                                        IW_EV_UINT_LEN);
-               if (current_ev == previous_ev)
-                       return -E2BIG;
-
-               /*Channel and Frequency */
-               /*================================ */
-               memset(&iwe, 0, sizeof(iwe));
-               iwe.cmd = SIOCGIWFREQ;
-               iwe.u.freq.m = pAdapter->ScanTab.BssEntry[i].Channel;
-               iwe.u.freq.e = 0;
-               iwe.u.freq.i = 0;
-
-               previous_ev = current_ev;
-               current_ev =
-                   iwe_stream_add_event(info, current_ev, end_buf, &iwe,
-                                        IW_EV_FREQ_LEN);
-               if (current_ev == previous_ev)
-                       return -E2BIG;
-
-               /*Add quality statistics */
-               /*================================ */
-               memset(&iwe, 0, sizeof(iwe));
-               iwe.cmd = IWEVQUAL;
-               iwe.u.qual.level = 0;
-               iwe.u.qual.noise = 0;
-               set_quality(pAdapter, &iwe.u.qual,
-                           pAdapter->ScanTab.BssEntry[i].Rssi);
-               current_ev =
-                   iwe_stream_add_event(info, current_ev, end_buf, &iwe,
-                                        IW_EV_QUAL_LEN);
-               if (current_ev == previous_ev)
-                       return -E2BIG;
-
-               /*Encyption key */
-               /*================================ */
-               memset(&iwe, 0, sizeof(iwe));
-               iwe.cmd = SIOCGIWENCODE;
-               if (CAP_IS_PRIVACY_ON
-                   (pAdapter->ScanTab.BssEntry[i].CapabilityInfo))
-                       iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
-               else
-                       iwe.u.data.flags = IW_ENCODE_DISABLED;
-
-               previous_ev = current_ev;
-               current_ev =
-                   iwe_stream_add_point(info, current_ev, end_buf, &iwe,
-                                        (char *)pAdapter->
-                                        SharedKey[BSS0][(iwe.u.data.
-                                                         flags &
-                                                         IW_ENCODE_INDEX) -
-                                                        1].Key);
-               if (current_ev == previous_ev)
-                       return -E2BIG;
-
-               /*Bit Rate */
-               /*================================ */
-               if (pAdapter->ScanTab.BssEntry[i].SupRateLen) {
-                       u8 tmpRate =
-                           pAdapter->ScanTab.BssEntry[i].SupRate[pAdapter->
-                                                                 ScanTab.
-                                                                 BssEntry[i].
-                                                                 SupRateLen -
-                                                                 1];
-                       memset(&iwe, 0, sizeof(iwe));
-                       iwe.cmd = SIOCGIWRATE;
-                       current_val = current_ev + IW_EV_LCP_LEN;
-                       if (tmpRate == 0x82)
-                               iwe.u.bitrate.value = 1 * 1000000;
-                       else if (tmpRate == 0x84)
-                               iwe.u.bitrate.value = 2 * 1000000;
-                       else if (tmpRate == 0x8B)
-                               iwe.u.bitrate.value = 5.5 * 1000000;
-                       else if (tmpRate == 0x96)
-                               iwe.u.bitrate.value = 11 * 1000000;
-                       else
-                               iwe.u.bitrate.value = (tmpRate / 2) * 1000000;
-
-                       if (tmpRate == 0x6c
-                           && pAdapter->ScanTab.BssEntry[i].HtCapabilityLen >
-                           0) {
-                               int rate_count = ARRAY_SIZE(ralinkrate);
-                               struct rt_ht_cap_info capInfo =
-                                   pAdapter->ScanTab.BssEntry[i].HtCapability.
-                                   HtCapInfo;
-                               int shortGI =
-                                   capInfo.ChannelWidth ? capInfo.
-                                   ShortGIfor40 : capInfo.ShortGIfor20;
-                               int maxMCS =
-                                   pAdapter->ScanTab.BssEntry[i].HtCapability.
-                                   MCSSet[1] ? 15 : 7;
-                               int rate_index =
-                                   12 + ((u8)capInfo.ChannelWidth * 24) +
-                                   ((u8)shortGI * 48) + ((u8)maxMCS);
-
-                               if (rate_index < 0)
-                                       rate_index = 0;
-                               if (rate_index >= rate_count)
-                                       rate_index = rate_count - 1;
-                               iwe.u.bitrate.value =
-                                   ralinkrate[rate_index] * 500000;
-                       }
-
-                       iwe.u.bitrate.disabled = 0;
-                       current_val = iwe_stream_add_value(info, current_ev,
-                                                          current_val, end_buf,
-                                                          &iwe,
-                                                          IW_EV_PARAM_LEN);
-
-                       if ((current_val - current_ev) > IW_EV_LCP_LEN)
-                               current_ev = current_val;
-                       else
-                               return -E2BIG;
-               }
-               /*WPA IE */
-               if (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen > 0) {
-                       memset(&iwe, 0, sizeof(iwe));
-                       memset(&custom[0], 0, MAX_CUSTOM_LEN);
-                       memcpy(custom,
-                              &(pAdapter->ScanTab.BssEntry[i].WpaIE.IE[0]),
-                              pAdapter->ScanTab.BssEntry[i].WpaIE.IELen);
-                       iwe.cmd = IWEVGENIE;
-                       iwe.u.data.length =
-                           pAdapter->ScanTab.BssEntry[i].WpaIE.IELen;
-                       current_ev =
-                           iwe_stream_add_point(info, current_ev, end_buf,
-                                                &iwe, custom);
-                       if (current_ev == previous_ev)
-                               return -E2BIG;
-               }
-               /*WPA2 IE */
-               if (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen > 0) {
-                       memset(&iwe, 0, sizeof(iwe));
-                       memset(&custom[0], 0, MAX_CUSTOM_LEN);
-                       memcpy(custom,
-                              &(pAdapter->ScanTab.BssEntry[i].RsnIE.IE[0]),
-                              pAdapter->ScanTab.BssEntry[i].RsnIE.IELen);
-                       iwe.cmd = IWEVGENIE;
-                       iwe.u.data.length =
-                           pAdapter->ScanTab.BssEntry[i].RsnIE.IELen;
-                       current_ev =
-                           iwe_stream_add_point(info, current_ev, end_buf,
-                                                &iwe, custom);
-                       if (current_ev == previous_ev)
-                               return -E2BIG;
-               }
-       }
-
-       data->length = current_ev - extra;
-       pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
-       DBGPRINT(RT_DEBUG_ERROR,
-                ("===>rt_ioctl_giwscan. %d(%d) BSS returned, data->length = %d\n",
-                 i, pAdapter->ScanTab.BssNr, data->length));
-       return 0;
-}
-
-int rt_ioctl_siwessid(struct net_device *dev,
-                     struct iw_request_info *info,
-                     struct iw_point *data, char *essid)
-{
-       struct rt_rtmp_adapter *pAdapter = NULL;
-
-       GET_PAD_FROM_NET_DEV(pAdapter, dev);
-
-       /*check if the interface is down */
-       if (!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE)) {
-               DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
-               return -ENETDOWN;
-       }
-
-       if (data->flags) {
-               char *pSsidString = NULL;
-
-               /* Includes null character. */
-               if (data->length > (IW_ESSID_MAX_SIZE + 1))
-                       return -E2BIG;
-
-               pSsidString = kmalloc(MAX_LEN_OF_SSID + 1, MEM_ALLOC_FLAG);
-               if (pSsidString) {
-                       NdisZeroMemory(pSsidString, MAX_LEN_OF_SSID + 1);
-                       NdisMoveMemory(pSsidString, essid, data->length);
-                       if (Set_SSID_Proc(pAdapter, pSsidString) == FALSE)
-                               return -EINVAL;
-               } else
-                       return -ENOMEM;
-       } else {
-               /* ANY ssid */
-               if (Set_SSID_Proc(pAdapter, "") == FALSE)
-                       return -EINVAL;
-       }
-       return 0;
-}
-
-int rt_ioctl_giwessid(struct net_device *dev,
-                     struct iw_request_info *info,
-                     struct iw_point *data, char *essid)
-{
-       struct rt_rtmp_adapter *pAdapter = NULL;
-
-       GET_PAD_FROM_NET_DEV(pAdapter, dev);
-
-       data->flags = 1;
-       if (MONITOR_ON(pAdapter)) {
-               data->length = 0;
-               return 0;
-       }
-
-       if (OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED)) {
-               DBGPRINT(RT_DEBUG_TRACE, ("MediaState is connected\n"));
-               data->length = pAdapter->CommonCfg.SsidLen;
-               memcpy(essid, pAdapter->CommonCfg.Ssid,
-                      pAdapter->CommonCfg.SsidLen);
-       }
-#ifdef RTMP_MAC_USB
-       /* Add for RT2870 */
-       else if (pAdapter->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE) {
-               data->length = pAdapter->CommonCfg.SsidLen;
-               memcpy(essid, pAdapter->CommonCfg.Ssid,
-                      pAdapter->CommonCfg.SsidLen);
-       }
-#endif /* RTMP_MAC_USB // */
-       else {                  /*the ANY ssid was specified */
-               data->length = 0;
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("MediaState is not connected, ess\n"));
-       }
-
-       return 0;
-
-}
-
-int rt_ioctl_siwnickn(struct net_device *dev,
-                     struct iw_request_info *info,
-                     struct iw_point *data, char *nickname)
-{
-       struct rt_rtmp_adapter *pAdapter = NULL;
-
-       GET_PAD_FROM_NET_DEV(pAdapter, dev);
-
-       /*check if the interface is down */
-       if (!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE)) {
-               DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
-               return -ENETDOWN;
-       }
-
-       if (data->length > IW_ESSID_MAX_SIZE)
-               return -EINVAL;
-
-       memset(pAdapter->nickname, 0, IW_ESSID_MAX_SIZE + 1);
-       memcpy(pAdapter->nickname, nickname, data->length);
-
-       return 0;
-}
-
-int rt_ioctl_giwnickn(struct net_device *dev,
-                     struct iw_request_info *info,
-                     struct iw_point *data, char *nickname)
-{
-       struct rt_rtmp_adapter *pAdapter = NULL;
-
-       GET_PAD_FROM_NET_DEV(pAdapter, dev);
-
-       if (data->length > strlen((char *)pAdapter->nickname) + 1)
-               data->length = strlen((char *)pAdapter->nickname) + 1;
-       if (data->length > 0) {
-               memcpy(nickname, pAdapter->nickname, data->length - 1);
-               nickname[data->length - 1] = '\0';
-       }
-       return 0;
-}
-
-int rt_ioctl_siwrts(struct net_device *dev,
-                   struct iw_request_info *info,
-                   struct iw_param *rts, char *extra)
-{
-       struct rt_rtmp_adapter *pAdapter = NULL;
-       u16 val;
-
-       GET_PAD_FROM_NET_DEV(pAdapter, dev);
-
-       /*check if the interface is down */
-       if (!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE)) {
-               DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
-               return -ENETDOWN;
-       }
-
-       if (rts->disabled)
-               val = MAX_RTS_THRESHOLD;
-       else if (rts->value < 0 || rts->value > MAX_RTS_THRESHOLD)
-               return -EINVAL;
-       else if (rts->value == 0)
-               val = MAX_RTS_THRESHOLD;
-       else
-               val = rts->value;
-
-       if (val != pAdapter->CommonCfg.RtsThreshold)
-               pAdapter->CommonCfg.RtsThreshold = val;
-
-       return 0;
-}
-
-int rt_ioctl_giwrts(struct net_device *dev,
-                   struct iw_request_info *info,
-                   struct iw_param *rts, char *extra)
-{
-       struct rt_rtmp_adapter *pAdapter = NULL;
-
-       GET_PAD_FROM_NET_DEV(pAdapter, dev);
-
-       /*check if the interface is down */
-       if (!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE)) {
-               DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
-               return -ENETDOWN;
-       }
-
-       rts->value = pAdapter->CommonCfg.RtsThreshold;
-       rts->disabled = (rts->value == MAX_RTS_THRESHOLD);
-       rts->fixed = 1;
-
-       return 0;
-}
-
-int rt_ioctl_siwfrag(struct net_device *dev,
-                    struct iw_request_info *info,
-                    struct iw_param *frag, char *extra)
-{
-       struct rt_rtmp_adapter *pAdapter = NULL;
-       u16 val;
-
-       GET_PAD_FROM_NET_DEV(pAdapter, dev);
-
-       /*check if the interface is down */
-       if (!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE)) {
-               DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
-               return -ENETDOWN;
-       }
-
-       if (frag->disabled)
-               val = MAX_FRAG_THRESHOLD;
-       else if (frag->value >= MIN_FRAG_THRESHOLD
-                && frag->value <= MAX_FRAG_THRESHOLD)
-               val = __cpu_to_le16(frag->value & ~0x1);        /* even numbers only */
-       else if (frag->value == 0)
-               val = MAX_FRAG_THRESHOLD;
-       else
-               return -EINVAL;
-
-       pAdapter->CommonCfg.FragmentThreshold = val;
-       return 0;
-}
-
-int rt_ioctl_giwfrag(struct net_device *dev,
-                    struct iw_request_info *info,
-                    struct iw_param *frag, char *extra)
-{
-       struct rt_rtmp_adapter *pAdapter = NULL;
-
-       GET_PAD_FROM_NET_DEV(pAdapter, dev);
-
-       /*check if the interface is down */
-       if (!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE)) {
-               DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
-               return -ENETDOWN;
-       }
-
-       frag->value = pAdapter->CommonCfg.FragmentThreshold;
-       frag->disabled = (frag->value == MAX_FRAG_THRESHOLD);
-       frag->fixed = 1;
-
-       return 0;
-}
-
-#define MAX_WEP_KEY_SIZE 13
-#define MIN_WEP_KEY_SIZE 5
-int rt_ioctl_siwencode(struct net_device *dev,
-                      struct iw_request_info *info,
-                      struct iw_point *erq, char *extra)
-{
-       struct rt_rtmp_adapter *pAdapter = NULL;
-
-       GET_PAD_FROM_NET_DEV(pAdapter, dev);
-
-       /*check if the interface is down */
-       if (!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE)) {
-               DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
-               return -ENETDOWN;
-       }
-
-       if ((erq->length == 0) && (erq->flags & IW_ENCODE_DISABLED)) {
-               pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
-               pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
-               pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
-               pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
-               pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
-               goto done;
-       } else if (erq->flags & IW_ENCODE_RESTRICTED
-                  || erq->flags & IW_ENCODE_OPEN) {
-               /*pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED; */
-               STA_PORT_SECURED(pAdapter);
-               pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
-               pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
-               pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
-               pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
-               if (erq->flags & IW_ENCODE_RESTRICTED)
-                       pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
-               else
-                       pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
-       }
-
-       if (erq->length > 0) {
-               int keyIdx = (erq->flags & IW_ENCODE_INDEX) - 1;
-               /* Check the size of the key */
-               if (erq->length > MAX_WEP_KEY_SIZE) {
-                       return -EINVAL;
-               }
-               /* Check key index */
-               if ((keyIdx < 0) || (keyIdx >= NR_WEP_KEYS)) {
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("==>rt_ioctl_siwencode::Wrong keyIdx=%d! Using default key instead (%d)\n",
-                                 keyIdx, pAdapter->StaCfg.DefaultKeyId));
-
-                       /*Using default key */
-                       keyIdx = pAdapter->StaCfg.DefaultKeyId;
-               } else
-                       pAdapter->StaCfg.DefaultKeyId = keyIdx;
-
-               NdisZeroMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, 16);
-
-               if (erq->length == MAX_WEP_KEY_SIZE) {
-                       pAdapter->SharedKey[BSS0][keyIdx].KeyLen =
-                           MAX_WEP_KEY_SIZE;
-                       pAdapter->SharedKey[BSS0][keyIdx].CipherAlg =
-                           CIPHER_WEP128;
-               } else if (erq->length == MIN_WEP_KEY_SIZE) {
-                       pAdapter->SharedKey[BSS0][keyIdx].KeyLen =
-                           MIN_WEP_KEY_SIZE;
-                       pAdapter->SharedKey[BSS0][keyIdx].CipherAlg =
-                           CIPHER_WEP64;
-               } else
-                       /* Disable the key */
-                       pAdapter->SharedKey[BSS0][keyIdx].KeyLen = 0;
-
-               /* Check if the key is not marked as invalid */
-               if (!(erq->flags & IW_ENCODE_NOKEY)) {
-                       /* Copy the key in the driver */
-                       NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key,
-                                      extra, erq->length);
-               }
-       } else {
-               /* Do we want to just set the transmit key index ? */
-               int index = (erq->flags & IW_ENCODE_INDEX) - 1;
-               if ((index >= 0) && (index < 4)) {
-                       pAdapter->StaCfg.DefaultKeyId = index;
-               } else
-                       /* Don't complain if the mode is only changed */
-               if (!(erq->flags & IW_ENCODE_MODE))
-                       return -EINVAL;
-       }
-
-done:
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("==>rt_ioctl_siwencode::erq->flags=%x\n", erq->flags));
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("==>rt_ioctl_siwencode::AuthMode=%x\n",
-                 pAdapter->StaCfg.AuthMode));
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("==>rt_ioctl_siwencode::DefaultKeyId=%x, KeyLen = %d\n",
-                 pAdapter->StaCfg.DefaultKeyId,
-                 pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].
-                 KeyLen));
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("==>rt_ioctl_siwencode::WepStatus=%x\n",
-                 pAdapter->StaCfg.WepStatus));
-       return 0;
-}
-
-int
-rt_ioctl_giwencode(struct net_device *dev,
-                  struct iw_request_info *info,
-                  struct iw_point *erq, char *key)
-{
-       int kid;
-       struct rt_rtmp_adapter *pAdapter = NULL;
-
-       GET_PAD_FROM_NET_DEV(pAdapter, dev);
-
-       /*check if the interface is down */
-       if (!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE)) {
-               DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
-               return -ENETDOWN;
-       }
-
-       kid = erq->flags & IW_ENCODE_INDEX;
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("===>rt_ioctl_giwencode %d\n", erq->flags & IW_ENCODE_INDEX));
-
-       if (pAdapter->StaCfg.WepStatus == Ndis802_11WEPDisabled) {
-               erq->length = 0;
-               erq->flags = IW_ENCODE_DISABLED;
-       } else if ((kid > 0) && (kid <= 4)) {
-               /* copy wep key */
-               erq->flags = kid;       /* NB: base 1 */
-               if (erq->length > pAdapter->SharedKey[BSS0][kid - 1].KeyLen)
-                       erq->length = pAdapter->SharedKey[BSS0][kid - 1].KeyLen;
-               memcpy(key, pAdapter->SharedKey[BSS0][kid - 1].Key,
-                      erq->length);
-               /*if ((kid == pAdapter->PortCfg.DefaultKeyId)) */
-               /*erq->flags |= IW_ENCODE_ENABLED; */   /* XXX */
-               if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
-                       erq->flags |= IW_ENCODE_RESTRICTED;     /* XXX */
-               else
-                       erq->flags |= IW_ENCODE_OPEN;   /* XXX */
-
-       } else if (kid == 0) {
-               if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
-                       erq->flags |= IW_ENCODE_RESTRICTED;     /* XXX */
-               else
-                       erq->flags |= IW_ENCODE_OPEN;   /* XXX */
-               erq->length =
-                   pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].
-                   KeyLen;
-               memcpy(key,
-                      pAdapter->SharedKey[BSS0][pAdapter->StaCfg.DefaultKeyId].
-                      Key, erq->length);
-               /* copy default key ID */
-               if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeShared)
-                       erq->flags |= IW_ENCODE_RESTRICTED;     /* XXX */
-               else
-                       erq->flags |= IW_ENCODE_OPEN;   /* XXX */
-               erq->flags = pAdapter->StaCfg.DefaultKeyId + 1; /* NB: base 1 */
-               erq->flags |= IW_ENCODE_ENABLED;        /* XXX */
-       }
-
-       return 0;
-
-}
-
-void getBaInfo(struct rt_rtmp_adapter *pAd, char *pOutBuf)
-{
-       int i, j;
-       struct rt_ba_ori_entry *pOriBAEntry;
-       struct rt_ba_rec_entry *pRecBAEntry;
-
-       for (i = 0; i < MAX_LEN_OF_MAC_TABLE; i++) {
-               struct rt_mac_table_entry *pEntry = &pAd->MacTab.Content[i];
-               if (((pEntry->ValidAsCLI || pEntry->ValidAsApCli)
-                    && (pEntry->Sst == SST_ASSOC))
-                   || (pEntry->ValidAsWDS) || (pEntry->ValidAsMesh)) {
-                       sprintf(pOutBuf + strlen(pOutBuf), "\n%pM (Aid = %d) "
-                               "(AP) -\n", pEntry->Addr, pEntry->Aid);
-
-                       sprintf(pOutBuf, "%s[Recipient]\n", pOutBuf);
-                       for (j = 0; j < NUM_OF_TID; j++) {
-                               if (pEntry->BARecWcidArray[j] != 0) {
-                                       pRecBAEntry =
-                                           &pAd->BATable.BARecEntry[pEntry->
-                                                                    BARecWcidArray
-                                                                    [j]];
-                                       sprintf(pOutBuf + strlen(pOutBuf),
-                                               "TID=%d, BAWinSize=%d, LastIndSeq=%d, ReorderingPkts=%d\n",
-                                               j, pRecBAEntry->BAWinSize,
-                                               pRecBAEntry->LastIndSeq,
-                                               pRecBAEntry->list.qlen);
-                               }
-                       }
-                       sprintf(pOutBuf, "%s\n", pOutBuf);
-
-                       sprintf(pOutBuf, "%s[Originator]\n", pOutBuf);
-                       for (j = 0; j < NUM_OF_TID; j++) {
-                               if (pEntry->BAOriWcidArray[j] != 0) {
-                                       pOriBAEntry =
-                                           &pAd->BATable.BAOriEntry[pEntry->
-                                                                    BAOriWcidArray
-                                                                    [j]];
-                                       sprintf(pOutBuf + strlen(pOutBuf),
-                                               "TID=%d, BAWinSize=%d, StartSeq=%d, CurTxSeq=%d\n",
-                                               j, pOriBAEntry->BAWinSize,
-                                               pOriBAEntry->Sequence,
-                                               pEntry->TxSeq[j]);
-                               }
-                       }
-                       sprintf(pOutBuf, "%s\n\n", pOutBuf);
-               }
-               if (strlen(pOutBuf) > (IW_PRIV_SIZE_MASK - 30))
-                       break;
-       }
-
-       return;
-}
-
-int rt_ioctl_siwmlme(struct net_device *dev,
-                    struct iw_request_info *info,
-                    union iwreq_data *wrqu, char *extra)
-{
-       struct rt_rtmp_adapter *pAd = NULL;
-       struct iw_mlme *pMlme = (struct iw_mlme *)wrqu->data.pointer;
-       struct rt_mlme_queue_elem MsgElem;
-       struct rt_mlme_disassoc_req DisAssocReq;
-       struct rt_mlme_deauth_req DeAuthReq;
-
-       GET_PAD_FROM_NET_DEV(pAd, dev);
-
-       DBGPRINT(RT_DEBUG_TRACE, ("====> %s\n", __func__));
-
-       if (pMlme == NULL)
-               return -EINVAL;
-
-       switch (pMlme->cmd) {
-#ifdef IW_MLME_DEAUTH
-       case IW_MLME_DEAUTH:
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("====> %s - IW_MLME_DEAUTH\n", __func__));
-               COPY_MAC_ADDR(DeAuthReq.Addr, pAd->CommonCfg.Bssid);
-               DeAuthReq.Reason = pMlme->reason_code;
-               MsgElem.MsgLen = sizeof(struct rt_mlme_deauth_req);
-               NdisMoveMemory(MsgElem.Msg, &DeAuthReq,
-                              sizeof(struct rt_mlme_deauth_req));
-               MlmeDeauthReqAction(pAd, &MsgElem);
-               if (INFRA_ON(pAd)) {
-                       LinkDown(pAd, FALSE);
-                       pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
-               }
-               break;
-#endif /* IW_MLME_DEAUTH // */
-#ifdef IW_MLME_DISASSOC
-       case IW_MLME_DISASSOC:
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("====> %s - IW_MLME_DISASSOC\n", __func__));
-               COPY_MAC_ADDR(DisAssocReq.Addr, pAd->CommonCfg.Bssid);
-               DisAssocReq.Reason = pMlme->reason_code;
-
-               MsgElem.Machine = ASSOC_STATE_MACHINE;
-               MsgElem.MsgType = MT2_MLME_DISASSOC_REQ;
-               MsgElem.MsgLen = sizeof(struct rt_mlme_disassoc_req);
-               NdisMoveMemory(MsgElem.Msg, &DisAssocReq,
-                              sizeof(struct rt_mlme_disassoc_req));
-
-               pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_DISASSOC;
-               MlmeDisassocReqAction(pAd, &MsgElem);
-               break;
-#endif /* IW_MLME_DISASSOC // */
-       default:
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("====> %s - Unknow Command\n", __func__));
-               break;
-       }
-
-       return 0;
-}
-
-int rt_ioctl_siwauth(struct net_device *dev,
-                    struct iw_request_info *info,
-                    union iwreq_data *wrqu, char *extra)
-{
-       struct rt_rtmp_adapter *pAdapter = NULL;
-       struct iw_param *param = &wrqu->param;
-
-       GET_PAD_FROM_NET_DEV(pAdapter, dev);
-
-       /*check if the interface is down */
-       if (!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE)) {
-               DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
-               return -ENETDOWN;
-       }
-       switch (param->flags & IW_AUTH_INDEX) {
-       case IW_AUTH_WPA_VERSION:
-               if (param->value == IW_AUTH_WPA_VERSION_WPA) {
-                       pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPAPSK;
-                       if (pAdapter->StaCfg.BssType == BSS_ADHOC)
-                               pAdapter->StaCfg.AuthMode =
-                                   Ndis802_11AuthModeWPANone;
-               } else if (param->value == IW_AUTH_WPA_VERSION_WPA2)
-                       pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
-
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n",
-                         __func__, param->value));
-               break;
-       case IW_AUTH_CIPHER_PAIRWISE:
-               if (param->value == IW_AUTH_CIPHER_NONE) {
-                       pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
-                       pAdapter->StaCfg.OrigWepStatus =
-                           pAdapter->StaCfg.WepStatus;
-                       pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
-               } else if (param->value == IW_AUTH_CIPHER_WEP40 ||
-                          param->value == IW_AUTH_CIPHER_WEP104) {
-                       pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
-                       pAdapter->StaCfg.OrigWepStatus =
-                           pAdapter->StaCfg.WepStatus;
-                       pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
-                       pAdapter->StaCfg.IEEE8021X = FALSE;
-               } else if (param->value == IW_AUTH_CIPHER_TKIP) {
-                       pAdapter->StaCfg.WepStatus =
-                           Ndis802_11Encryption2Enabled;
-                       pAdapter->StaCfg.OrigWepStatus =
-                           pAdapter->StaCfg.WepStatus;
-                       pAdapter->StaCfg.PairCipher =
-                           Ndis802_11Encryption2Enabled;
-               } else if (param->value == IW_AUTH_CIPHER_CCMP) {
-                       pAdapter->StaCfg.WepStatus =
-                           Ndis802_11Encryption3Enabled;
-                       pAdapter->StaCfg.OrigWepStatus =
-                           pAdapter->StaCfg.WepStatus;
-                       pAdapter->StaCfg.PairCipher =
-                           Ndis802_11Encryption3Enabled;
-               }
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("%s::IW_AUTH_CIPHER_PAIRWISE - param->value = %d!\n",
-                         __func__, param->value));
-               break;
-       case IW_AUTH_CIPHER_GROUP:
-               if (param->value == IW_AUTH_CIPHER_NONE) {
-                       pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
-               } else if (param->value == IW_AUTH_CIPHER_WEP40 ||
-                          param->value == IW_AUTH_CIPHER_WEP104) {
-                       pAdapter->StaCfg.GroupCipher = Ndis802_11WEPEnabled;
-               } else if (param->value == IW_AUTH_CIPHER_TKIP) {
-                       pAdapter->StaCfg.GroupCipher =
-                           Ndis802_11Encryption2Enabled;
-               } else if (param->value == IW_AUTH_CIPHER_CCMP) {
-                       pAdapter->StaCfg.GroupCipher =
-                           Ndis802_11Encryption3Enabled;
-               }
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("%s::IW_AUTH_CIPHER_GROUP - param->value = %d!\n",
-                         __func__, param->value));
-               break;
-       case IW_AUTH_KEY_MGMT:
-               if (param->value == IW_AUTH_KEY_MGMT_802_1X) {
-                       if (pAdapter->StaCfg.AuthMode ==
-                           Ndis802_11AuthModeWPAPSK) {
-                               pAdapter->StaCfg.AuthMode =
-                                   Ndis802_11AuthModeWPA;
-                               pAdapter->StaCfg.IEEE8021X = FALSE;
-                       } else if (pAdapter->StaCfg.AuthMode ==
-                                  Ndis802_11AuthModeWPA2PSK) {
-                               pAdapter->StaCfg.AuthMode =
-                                   Ndis802_11AuthModeWPA2;
-                               pAdapter->StaCfg.IEEE8021X = FALSE;
-                       } else
-                               /* WEP 1x */
-                               pAdapter->StaCfg.IEEE8021X = TRUE;
-               } else if (param->value == 0) {
-                       /*pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED; */
-                       STA_PORT_SECURED(pAdapter);
-               }
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("%s::IW_AUTH_KEY_MGMT - param->value = %d!\n",
-                         __func__, param->value));
-               break;
-       case IW_AUTH_RX_UNENCRYPTED_EAPOL:
-               break;
-       case IW_AUTH_PRIVACY_INVOKED:
-               /*if (param->value == 0)
-                  {
-                  pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
-                  pAdapter->StaCfg.WepStatus = Ndis802_11WEPDisabled;
-                  pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
-                  pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
-                  pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
-                  } */
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("%s::IW_AUTH_PRIVACY_INVOKED - param->value = %d!\n",
-                         __func__, param->value));
-               break;
-       case IW_AUTH_DROP_UNENCRYPTED:
-               if (param->value != 0)
-                       pAdapter->StaCfg.PortSecured =
-                           WPA_802_1X_PORT_NOT_SECURED;
-               else {
-                       /*pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED; */
-                       STA_PORT_SECURED(pAdapter);
-               }
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n",
-                         __func__, param->value));
-               break;
-       case IW_AUTH_80211_AUTH_ALG:
-               if (param->value & IW_AUTH_ALG_SHARED_KEY) {
-                       pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
-               } else if (param->value & IW_AUTH_ALG_OPEN_SYSTEM) {
-                       pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
-               } else
-                       return -EINVAL;
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("%s::IW_AUTH_80211_AUTH_ALG - param->value = %d!\n",
-                         __func__, param->value));
-               break;
-       case IW_AUTH_WPA_ENABLED:
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("%s::IW_AUTH_WPA_ENABLED - Driver supports WPA!(param->value = %d)\n",
-                         __func__, param->value));
-               break;
-       default:
-               return -EOPNOTSUPP;
-       }
-
-       return 0;
-}
-
-int rt_ioctl_giwauth(struct net_device *dev,
-                    struct iw_request_info *info,
-                    union iwreq_data *wrqu, char *extra)
-{
-       struct rt_rtmp_adapter *pAdapter = NULL;
-       struct iw_param *param = &wrqu->param;
-
-       GET_PAD_FROM_NET_DEV(pAdapter, dev);
-
-       /*check if the interface is down */
-       if (!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE)) {
-               DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
-               return -ENETDOWN;
-       }
-
-       switch (param->flags & IW_AUTH_INDEX) {
-       case IW_AUTH_DROP_UNENCRYPTED:
-               param->value =
-                   (pAdapter->StaCfg.WepStatus ==
-                    Ndis802_11WEPDisabled) ? 0 : 1;
-               break;
-
-       case IW_AUTH_80211_AUTH_ALG:
-               param->value =
-                   (pAdapter->StaCfg.AuthMode ==
-                    Ndis802_11AuthModeShared) ? IW_AUTH_ALG_SHARED_KEY :
-                   IW_AUTH_ALG_OPEN_SYSTEM;
-               break;
-
-       case IW_AUTH_WPA_ENABLED:
-               param->value =
-                   (pAdapter->StaCfg.AuthMode >=
-                    Ndis802_11AuthModeWPA) ? 1 : 0;
-               break;
-
-       default:
-               return -EOPNOTSUPP;
-       }
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("rt_ioctl_giwauth::param->value = %d!\n", param->value));
-       return 0;
-}
-
-void fnSetCipherKey(struct rt_rtmp_adapter *pAdapter,
-                   int keyIdx,
-                   u8 CipherAlg,
-                   IN BOOLEAN bGTK, IN struct iw_encode_ext *ext)
-{
-       NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx], sizeof(struct rt_cipher_key));
-       pAdapter->SharedKey[BSS0][keyIdx].KeyLen = LEN_TKIP_EK;
-       NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key,
-                      LEN_TKIP_EK);
-       NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].TxMic,
-                      ext->key + LEN_TKIP_EK, LEN_TKIP_TXMICK);
-       NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].RxMic,
-                      ext->key + LEN_TKIP_EK + LEN_TKIP_TXMICK,
-                      LEN_TKIP_RXMICK);
-       pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CipherAlg;
-
-       /* Update group key information to ASIC Shared Key Table */
-       AsicAddSharedKeyEntry(pAdapter,
-                             BSS0,
-                             keyIdx,
-                             pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
-                             pAdapter->SharedKey[BSS0][keyIdx].Key,
-                             pAdapter->SharedKey[BSS0][keyIdx].TxMic,
-                             pAdapter->SharedKey[BSS0][keyIdx].RxMic);
-
-       if (bGTK)
-               /* Update ASIC WCID attribute table and IVEIV table */
-               RTMPAddWcidAttributeEntry(pAdapter,
-                                         BSS0,
-                                         keyIdx,
-                                         pAdapter->SharedKey[BSS0][keyIdx].
-                                         CipherAlg, NULL);
-       else
-               /* Update ASIC WCID attribute table and IVEIV table */
-               RTMPAddWcidAttributeEntry(pAdapter,
-                                         BSS0,
-                                         keyIdx,
-                                         pAdapter->SharedKey[BSS0][keyIdx].
-                                         CipherAlg,
-                                         &pAdapter->MacTab.
-                                         Content[BSSID_WCID]);
-}
-
-int rt_ioctl_siwencodeext(struct net_device *dev,
-                         struct iw_request_info *info,
-                         union iwreq_data *wrqu, char *extra)
-{
-       struct rt_rtmp_adapter *pAdapter = NULL;
-       struct iw_point *encoding = &wrqu->encoding;
-       struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
-       int keyIdx, alg = ext->alg;
-
-       GET_PAD_FROM_NET_DEV(pAdapter, dev);
-
-       /*check if the interface is down */
-       if (!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE)) {
-               DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
-               return -ENETDOWN;
-       }
-
-       if (encoding->flags & IW_ENCODE_DISABLED) {
-               keyIdx = (encoding->flags & IW_ENCODE_INDEX) - 1;
-               /* set BSSID wcid entry of the Pair-wise Key table as no-security mode */
-               AsicRemovePairwiseKeyEntry(pAdapter, BSS0, BSSID_WCID);
-               pAdapter->SharedKey[BSS0][keyIdx].KeyLen = 0;
-               pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_NONE;
-               AsicRemoveSharedKeyEntry(pAdapter, 0, (u8)keyIdx);
-               NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx],
-                              sizeof(struct rt_cipher_key));
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("%s::Remove all keys!(encoding->flags = %x)\n",
-                         __func__, encoding->flags));
-       } else {
-               /* Get Key Index and convet to our own defined key index */
-               keyIdx = (encoding->flags & IW_ENCODE_INDEX) - 1;
-               if ((keyIdx < 0) || (keyIdx >= NR_WEP_KEYS))
-                       return -EINVAL;
-
-               if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) {
-                       pAdapter->StaCfg.DefaultKeyId = keyIdx;
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("%s::DefaultKeyId = %d\n", __func__,
-                                 pAdapter->StaCfg.DefaultKeyId));
-               }
-
-               switch (alg) {
-               case IW_ENCODE_ALG_NONE:
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("%s::IW_ENCODE_ALG_NONE\n", __func__));
-                       break;
-               case IW_ENCODE_ALG_WEP:
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("%s::IW_ENCODE_ALG_WEP - ext->key_len = %d, keyIdx = %d\n",
-                                 __func__, ext->key_len, keyIdx));
-                       if (ext->key_len == MAX_WEP_KEY_SIZE) {
-                               pAdapter->SharedKey[BSS0][keyIdx].KeyLen =
-                                   MAX_WEP_KEY_SIZE;
-                               pAdapter->SharedKey[BSS0][keyIdx].CipherAlg =
-                                   CIPHER_WEP128;
-                       } else if (ext->key_len == MIN_WEP_KEY_SIZE) {
-                               pAdapter->SharedKey[BSS0][keyIdx].KeyLen =
-                                   MIN_WEP_KEY_SIZE;
-                               pAdapter->SharedKey[BSS0][keyIdx].CipherAlg =
-                                   CIPHER_WEP64;
-                       } else
-                               return -EINVAL;
-
-                       NdisZeroMemory(pAdapter->SharedKey[BSS0][keyIdx].Key,
-                                      16);
-                       NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key,
-                                      ext->key, ext->key_len);
-                       if (pAdapter->StaCfg.GroupCipher ==
-                           Ndis802_11GroupWEP40Enabled
-                           || pAdapter->StaCfg.GroupCipher ==
-                           Ndis802_11GroupWEP104Enabled) {
-                               /* Set Group key material to Asic */
-                               AsicAddSharedKeyEntry(pAdapter, BSS0, keyIdx,
-                                                     pAdapter->
-                                                     SharedKey[BSS0][keyIdx].
-                                                     CipherAlg,
-                                                     pAdapter->
-                                                     SharedKey[BSS0][keyIdx].
-                                                     Key, NULL, NULL);
-
-                               /* Update WCID attribute table and IVEIV table for this group key table */
-                               RTMPAddWcidAttributeEntry(pAdapter, BSS0,
-                                                         keyIdx,
-                                                         pAdapter->
-                                                         SharedKey[BSS0]
-                                                         [keyIdx].CipherAlg,
-                                                         NULL);
-
-                               STA_PORT_SECURED(pAdapter);
-
-                               /* Indicate Connected for GUI */
-                               pAdapter->IndicateMediaState =
-                                   NdisMediaStateConnected;
-                       }
-                       break;
-               case IW_ENCODE_ALG_TKIP:
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("%s::IW_ENCODE_ALG_TKIP - keyIdx = %d, ext->key_len = %d\n",
-                                 __func__, keyIdx, ext->key_len));
-                       if (ext->key_len == 32) {
-                               if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) {
-                                       fnSetCipherKey(pAdapter, keyIdx,
-                                                      CIPHER_TKIP, FALSE, ext);
-                                       if (pAdapter->StaCfg.AuthMode >=
-                                           Ndis802_11AuthModeWPA2) {
-                                               /*pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED; */
-                                               STA_PORT_SECURED(pAdapter);
-                                               pAdapter->IndicateMediaState =
-                                                   NdisMediaStateConnected;
-                                       }
-                               } else if (ext->
-                                          ext_flags & IW_ENCODE_EXT_GROUP_KEY)
-                               {
-                                       fnSetCipherKey(pAdapter, keyIdx,
-                                                      CIPHER_TKIP, TRUE, ext);
-
-                                       /* set 802.1x port control */
-                                       /*pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED; */
-                                       STA_PORT_SECURED(pAdapter);
-                                       pAdapter->IndicateMediaState =
-                                           NdisMediaStateConnected;
-                               }
-                       } else
-                               return -EINVAL;
-                       break;
-               case IW_ENCODE_ALG_CCMP:
-                       if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) {
-                               fnSetCipherKey(pAdapter, keyIdx, CIPHER_AES,
-                                              FALSE, ext);
-                               if (pAdapter->StaCfg.AuthMode >=
-                                   Ndis802_11AuthModeWPA2)
-                                       /*pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED; */
-                                       STA_PORT_SECURED(pAdapter);
-                               pAdapter->IndicateMediaState =
-                                   NdisMediaStateConnected;
-                       } else if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
-                               fnSetCipherKey(pAdapter, keyIdx, CIPHER_AES,
-                                              TRUE, ext);
-
-                               /* set 802.1x port control */
-                               /*pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED; */
-                               STA_PORT_SECURED(pAdapter);
-                               pAdapter->IndicateMediaState =
-                                   NdisMediaStateConnected;
-                       }
-                       break;
-               default:
-                       return -EINVAL;
-               }
-       }
-
-       return 0;
-}
-
-int
-rt_ioctl_giwencodeext(struct net_device *dev,
-                     struct iw_request_info *info,
-                     union iwreq_data *wrqu, char *extra)
-{
-       struct rt_rtmp_adapter *pAd = NULL;
-       char *pKey = NULL;
-       struct iw_point *encoding = &wrqu->encoding;
-       struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
-       int idx, max_key_len;
-
-       GET_PAD_FROM_NET_DEV(pAd, dev);
-
-       DBGPRINT(RT_DEBUG_TRACE, ("===> rt_ioctl_giwencodeext\n"));
-
-       max_key_len = encoding->length - sizeof(*ext);
-       if (max_key_len < 0)
-               return -EINVAL;
-
-       idx = encoding->flags & IW_ENCODE_INDEX;
-       if (idx) {
-               if (idx < 1 || idx > 4)
-                       return -EINVAL;
-               idx--;
-
-               if ((pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled) ||
-                   (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled)) {
-                       if (idx != pAd->StaCfg.DefaultKeyId) {
-                               ext->key_len = 0;
-                               return 0;
-                       }
-               }
-       } else
-               idx = pAd->StaCfg.DefaultKeyId;
-
-       encoding->flags = idx + 1;
-       memset(ext, 0, sizeof(*ext));
-
-       ext->key_len = 0;
-       switch (pAd->StaCfg.WepStatus) {
-       case Ndis802_11WEPDisabled:
-               ext->alg = IW_ENCODE_ALG_NONE;
-               encoding->flags |= IW_ENCODE_DISABLED;
-               break;
-       case Ndis802_11WEPEnabled:
-               ext->alg = IW_ENCODE_ALG_WEP;
-               if (pAd->SharedKey[BSS0][idx].KeyLen > max_key_len)
-                       return -E2BIG;
-               else {
-                       ext->key_len = pAd->SharedKey[BSS0][idx].KeyLen;
-                       pKey = (char *)& (pAd->SharedKey[BSS0][idx].Key[0]);
-               }
-               break;
-       case Ndis802_11Encryption2Enabled:
-       case Ndis802_11Encryption3Enabled:
-               if (pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled)
-                       ext->alg = IW_ENCODE_ALG_TKIP;
-               else
-                       ext->alg = IW_ENCODE_ALG_CCMP;
-
-               if (max_key_len < 32)
-                       return -E2BIG;
-               else {
-                       ext->key_len = 32;
-                       pKey = (char *)& pAd->StaCfg.PMK[0];
-               }
-               break;
-       default:
-               return -EINVAL;
-       }
-
-       if (ext->key_len && pKey) {
-               encoding->flags |= IW_ENCODE_ENABLED;
-               memcpy(ext->key, pKey, ext->key_len);
-       }
-
-       return 0;
-}
-
-int rt_ioctl_siwgenie(struct net_device *dev,
-                     struct iw_request_info *info,
-                     union iwreq_data *wrqu, char *extra)
-{
-       struct rt_rtmp_adapter *pAd = NULL;
-
-       GET_PAD_FROM_NET_DEV(pAd, dev);
-
-       DBGPRINT(RT_DEBUG_TRACE, ("===> rt_ioctl_siwgenie\n"));
-       pAd->StaCfg.bRSN_IE_FromWpaSupplicant = FALSE;
-       if (wrqu->data.length > MAX_LEN_OF_RSNIE ||
-           (wrqu->data.length && extra == NULL))
-               return -EINVAL;
-
-       if (wrqu->data.length) {
-               pAd->StaCfg.RSNIE_Len = wrqu->data.length;
-               NdisMoveMemory(&pAd->StaCfg.RSN_IE[0], extra,
-                              pAd->StaCfg.RSNIE_Len);
-               pAd->StaCfg.bRSN_IE_FromWpaSupplicant = TRUE;
-       } else {
-               pAd->StaCfg.RSNIE_Len = 0;
-               NdisZeroMemory(&pAd->StaCfg.RSN_IE[0], MAX_LEN_OF_RSNIE);
-       }
-
-       return 0;
-}
-
-int rt_ioctl_giwgenie(struct net_device *dev,
-                     struct iw_request_info *info,
-                     union iwreq_data *wrqu, char *extra)
-{
-       struct rt_rtmp_adapter *pAd = NULL;
-
-       GET_PAD_FROM_NET_DEV(pAd, dev);
-
-       if ((pAd->StaCfg.RSNIE_Len == 0) ||
-           (pAd->StaCfg.AuthMode < Ndis802_11AuthModeWPA)) {
-               wrqu->data.length = 0;
-               return 0;
-       }
-
-       if (pAd->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE) {
-               if (wrqu->data.length < pAd->StaCfg.RSNIE_Len)
-                       return -E2BIG;
-
-               wrqu->data.length = pAd->StaCfg.RSNIE_Len;
-               memcpy(extra, &pAd->StaCfg.RSN_IE[0], pAd->StaCfg.RSNIE_Len);
-       } else {
-               u8 RSNIe = IE_WPA;
-
-               if (wrqu->data.length < (pAd->StaCfg.RSNIE_Len + 2))    /* ID, Len */
-                       return -E2BIG;
-               wrqu->data.length = pAd->StaCfg.RSNIE_Len + 2;
-
-               if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
-                   (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2))
-                       RSNIe = IE_RSN;
-
-               extra[0] = (char)RSNIe;
-               extra[1] = pAd->StaCfg.RSNIE_Len;
-               memcpy(extra + 2, &pAd->StaCfg.RSN_IE[0],
-                      pAd->StaCfg.RSNIE_Len);
-       }
-
-       return 0;
-}
-
-int rt_ioctl_siwpmksa(struct net_device *dev,
-                     struct iw_request_info *info,
-                     union iwreq_data *wrqu, char *extra)
-{
-       struct rt_rtmp_adapter *pAd = NULL;
-       struct iw_pmksa *pPmksa = (struct iw_pmksa *)wrqu->data.pointer;
-       int CachedIdx = 0, idx = 0;
-
-       GET_PAD_FROM_NET_DEV(pAd, dev);
-
-       if (pPmksa == NULL)
-               return -EINVAL;
-
-       DBGPRINT(RT_DEBUG_TRACE, ("===> rt_ioctl_siwpmksa\n"));
-       switch (pPmksa->cmd) {
-       case IW_PMKSA_FLUSH:
-               NdisZeroMemory(pAd->StaCfg.SavedPMK,
-                              sizeof(struct rt_bssid_info) * PMKID_NO);
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("rt_ioctl_siwpmksa - IW_PMKSA_FLUSH\n"));
-               break;
-       case IW_PMKSA_REMOVE:
-               for (CachedIdx = 0; CachedIdx < pAd->StaCfg.SavedPMKNum;
-                    CachedIdx++) {
-                       /* compare the BSSID */
-                       if (NdisEqualMemory
-                           (pPmksa->bssid.sa_data,
-                            pAd->StaCfg.SavedPMK[CachedIdx].BSSID,
-                            MAC_ADDR_LEN)) {
-                               NdisZeroMemory(pAd->StaCfg.SavedPMK[CachedIdx].
-                                              BSSID, MAC_ADDR_LEN);
-                               NdisZeroMemory(pAd->StaCfg.SavedPMK[CachedIdx].
-                                              PMKID, 16);
-                               for (idx = CachedIdx;
-                                    idx < (pAd->StaCfg.SavedPMKNum - 1);
-                                    idx++) {
-                                       NdisMoveMemory(&pAd->StaCfg.
-                                                      SavedPMK[idx].BSSID[0],
-                                                      &pAd->StaCfg.
-                                                      SavedPMK[idx +
-                                                               1].BSSID[0],
-                                                      MAC_ADDR_LEN);
-                                       NdisMoveMemory(&pAd->StaCfg.
-                                                      SavedPMK[idx].PMKID[0],
-                                                      &pAd->StaCfg.
-                                                      SavedPMK[idx +
-                                                               1].PMKID[0],
-                                                      16);
-                               }
-                               pAd->StaCfg.SavedPMKNum--;
-                               break;
-                       }
-               }
-
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("rt_ioctl_siwpmksa - IW_PMKSA_REMOVE\n"));
-               break;
-       case IW_PMKSA_ADD:
-               for (CachedIdx = 0; CachedIdx < pAd->StaCfg.SavedPMKNum;
-                    CachedIdx++) {
-                       /* compare the BSSID */
-                       if (NdisEqualMemory
-                           (pPmksa->bssid.sa_data,
-                            pAd->StaCfg.SavedPMK[CachedIdx].BSSID,
-                            MAC_ADDR_LEN))
-                               break;
-               }
-
-               /* Found, replace it */
-               if (CachedIdx < PMKID_NO) {
-                       DBGPRINT(RT_DEBUG_OFF,
-                                ("Update PMKID, idx = %d\n", CachedIdx));
-                       NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].
-                                      BSSID[0], pPmksa->bssid.sa_data,
-                                      MAC_ADDR_LEN);
-                       NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].
-                                      PMKID[0], pPmksa->pmkid, 16);
-                       pAd->StaCfg.SavedPMKNum++;
-               }
-               /* Not found, replace the last one */
-               else {
-                       /* Randomly replace one */
-                       CachedIdx = (pPmksa->bssid.sa_data[5] % PMKID_NO);
-                       DBGPRINT(RT_DEBUG_OFF,
-                                ("Update PMKID, idx = %d\n", CachedIdx));
-                       NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].
-                                      BSSID[0], pPmksa->bssid.sa_data,
-                                      MAC_ADDR_LEN);
-                       NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].
-                                      PMKID[0], pPmksa->pmkid, 16);
-               }
-
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("rt_ioctl_siwpmksa - IW_PMKSA_ADD\n"));
-               break;
-       default:
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("rt_ioctl_siwpmksa - Unknown Command!\n"));
-               break;
-       }
-
-       return 0;
-}
-
-int rt_ioctl_siwrate(struct net_device *dev,
-                    struct iw_request_info *info,
-                    union iwreq_data *wrqu, char *extra)
-{
-       struct rt_rtmp_adapter *pAd = NULL;
-       u32 rate = wrqu->bitrate.value, fixed = wrqu->bitrate.fixed;
-
-       GET_PAD_FROM_NET_DEV(pAd, dev);
-
-       /*check if the interface is down */
-       if (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE)) {
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("rt_ioctl_siwrate::Network is down!\n"));
-               return -ENETDOWN;
-       }
-
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("rt_ioctl_siwrate::(rate = %d, fixed = %d)\n", rate, fixed));
-       /* rate = -1 => auto rate
-          rate = X, fixed = 1 => (fixed rate X)
-        */
-       if (rate == -1) {
-               /*Auto Rate */
-               pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
-               pAd->StaCfg.bAutoTxRateSwitch = TRUE;
-               if ((pAd->CommonCfg.PhyMode <= PHY_11G) ||
-                   (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <=
-                    MODE_OFDM))
-                       RTMPSetDesiredRates(pAd, -1);
-
-               SetCommonHT(pAd);
-       } else {
-               if (fixed) {
-                       pAd->StaCfg.bAutoTxRateSwitch = FALSE;
-                       if ((pAd->CommonCfg.PhyMode <= PHY_11G) ||
-                           (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.
-                            MODE <= MODE_OFDM))
-                               RTMPSetDesiredRates(pAd, rate);
-                       else {
-                               pAd->StaCfg.DesiredTransmitSetting.field.MCS =
-                                   MCS_AUTO;
-                               SetCommonHT(pAd);
-                       }
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("rt_ioctl_siwrate::(HtMcs=%d)\n",
-                                 pAd->StaCfg.DesiredTransmitSetting.field.
-                                 MCS));
-               } else {
-                       /* TODO: rate = X, fixed = 0 => (rates <= X) */
-                       return -EOPNOTSUPP;
-               }
-       }
-
-       return 0;
-}
-
-int rt_ioctl_giwrate(struct net_device *dev,
-                    struct iw_request_info *info,
-                    union iwreq_data *wrqu, char *extra)
-{
-       struct rt_rtmp_adapter *pAd = NULL;
-       int rate_index = 0, rate_count = 0;
-       HTTRANSMIT_SETTING ht_setting;
-/* Remove to global variable
-    __s32 ralinkrate[] =
-       {2,  4,   11,  22, // CCK
-       12, 18,   24,  36, 48, 72, 96, 108, // OFDM
-       13, 26,   39,  52,  78, 104, 117, 130, 26,  52,  78, 104, 156, 208, 234, 260, // 20MHz, 800ns GI, MCS: 0 ~ 15
-       39, 78,  117, 156, 234, 312, 351, 390,                                                                            // 20MHz, 800ns GI, MCS: 16 ~ 23
-       27, 54,   81, 108, 162, 216, 243, 270, 54, 108, 162, 216, 324, 432, 486, 540, // 40MHz, 800ns GI, MCS: 0 ~ 15
-       81, 162, 243, 324, 486, 648, 729, 810,                                                                            // 40MHz, 800ns GI, MCS: 16 ~ 23
-       14, 29,   43,  57,  87, 115, 130, 144, 29, 59,   87, 115, 173, 230, 260, 288, // 20MHz, 400ns GI, MCS: 0 ~ 15
-       43, 87,  130, 173, 260, 317, 390, 433,                                                                            // 20MHz, 400ns GI, MCS: 16 ~ 23
-       30, 60,   90, 120, 180, 240, 270, 300, 60, 120, 180, 240, 360, 480, 540, 600, // 40MHz, 400ns GI, MCS: 0 ~ 15
-       90, 180, 270, 360, 540, 720, 810, 900};                                                                           // 40MHz, 400ns GI, MCS: 16 ~ 23
-*/
-       GET_PAD_FROM_NET_DEV(pAd, dev);
-
-       rate_count = ARRAY_SIZE(ralinkrate);
-       /*check if the interface is down */
-       if (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE)) {
-               DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
-               return -ENETDOWN;
-       }
-
-       if ((pAd->StaCfg.bAutoTxRateSwitch == FALSE) &&
-           (INFRA_ON(pAd)) &&
-           ((pAd->CommonCfg.PhyMode <= PHY_11G)
-            || (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <=
-                MODE_OFDM)))
-               ht_setting.word = pAd->StaCfg.HTPhyMode.word;
-       else
-               ht_setting.word =
-                   pAd->MacTab.Content[BSSID_WCID].HTPhyMode.word;
-
-       if (ht_setting.field.MODE >= MODE_HTMIX) {
-/*      rate_index = 12 + ((u8)ht_setting.field.BW *16) + ((u8)ht_setting.field.ShortGI *32) + ((u8)ht_setting.field.MCS); */
-               rate_index =
-                   12 + ((u8)ht_setting.field.BW * 24) +
-                   ((u8)ht_setting.field.ShortGI * 48) +
-                   ((u8)ht_setting.field.MCS);
-       } else if (ht_setting.field.MODE == MODE_OFDM)
-               rate_index = (u8)(ht_setting.field.MCS) + 4;
-       else if (ht_setting.field.MODE == MODE_CCK)
-               rate_index = (u8)(ht_setting.field.MCS);
-
-       if (rate_index < 0)
-               rate_index = 0;
-
-       if (rate_index >= rate_count)
-               rate_index = rate_count - 1;
-
-       wrqu->bitrate.value = ralinkrate[rate_index] * 500000;
-       wrqu->bitrate.disabled = 0;
-
-       return 0;
-}
-
-static const iw_handler rt_handler[] = {
-       (iw_handler) NULL,      /* SIOCSIWCOMMIT */
-       (iw_handler) rt_ioctl_giwname,  /* SIOCGIWNAME   */
-       (iw_handler) NULL,      /* SIOCSIWNWID   */
-       (iw_handler) NULL,      /* SIOCGIWNWID   */
-       (iw_handler) rt_ioctl_siwfreq,  /* SIOCSIWFREQ   */
-       (iw_handler) rt_ioctl_giwfreq,  /* SIOCGIWFREQ   */
-       (iw_handler) rt_ioctl_siwmode,  /* SIOCSIWMODE   */
-       (iw_handler) rt_ioctl_giwmode,  /* SIOCGIWMODE   */
-       (iw_handler) NULL,      /* SIOCSIWSENS   */
-       (iw_handler) NULL,      /* SIOCGIWSENS   */
-       (iw_handler) NULL /* not used */ ,      /* SIOCSIWRANGE  */
-       (iw_handler) rt_ioctl_giwrange, /* SIOCGIWRANGE  */
-       (iw_handler) NULL /* not used */ ,      /* SIOCSIWPRIV   */
-       (iw_handler) NULL /* kernel code */ ,   /* SIOCGIWPRIV   */
-       (iw_handler) NULL /* not used */ ,      /* SIOCSIWSTATS  */
-       (iw_handler) rt28xx_get_wireless_stats /* kernel code */ ,      /* SIOCGIWSTATS  */
-       (iw_handler) NULL,      /* SIOCSIWSPY    */
-       (iw_handler) NULL,      /* SIOCGIWSPY    */
-       (iw_handler) NULL,      /* SIOCSIWTHRSPY */
-       (iw_handler) NULL,      /* SIOCGIWTHRSPY */
-       (iw_handler) rt_ioctl_siwap,    /* SIOCSIWAP     */
-       (iw_handler) rt_ioctl_giwap,    /* SIOCGIWAP     */
-       (iw_handler) rt_ioctl_siwmlme,  /* SIOCSIWMLME   */
-       (iw_handler) rt_ioctl_iwaplist, /* SIOCGIWAPLIST */
-       (iw_handler) rt_ioctl_siwscan,  /* SIOCSIWSCAN   */
-       (iw_handler) rt_ioctl_giwscan,  /* SIOCGIWSCAN   */
-       (iw_handler) rt_ioctl_siwessid, /* SIOCSIWESSID  */
-       (iw_handler) rt_ioctl_giwessid, /* SIOCGIWESSID  */
-       (iw_handler) rt_ioctl_siwnickn, /* SIOCSIWNICKN  */
-       (iw_handler) rt_ioctl_giwnickn, /* SIOCGIWNICKN  */
-       (iw_handler) NULL,      /* -- hole --    */
-       (iw_handler) NULL,      /* -- hole --    */
-       (iw_handler) rt_ioctl_siwrate,  /* SIOCSIWRATE   */
-       (iw_handler) rt_ioctl_giwrate,  /* SIOCGIWRATE   */
-       (iw_handler) rt_ioctl_siwrts,   /* SIOCSIWRTS    */
-       (iw_handler) rt_ioctl_giwrts,   /* SIOCGIWRTS    */
-       (iw_handler) rt_ioctl_siwfrag,  /* SIOCSIWFRAG   */
-       (iw_handler) rt_ioctl_giwfrag,  /* SIOCGIWFRAG   */
-       (iw_handler) NULL,      /* SIOCSIWTXPOW  */
-       (iw_handler) NULL,      /* SIOCGIWTXPOW  */
-       (iw_handler) NULL,      /* SIOCSIWRETRY  */
-       (iw_handler) NULL,      /* SIOCGIWRETRY  */
-       (iw_handler) rt_ioctl_siwencode,        /* SIOCSIWENCODE */
-       (iw_handler) rt_ioctl_giwencode,        /* SIOCGIWENCODE */
-       (iw_handler) NULL,      /* SIOCSIWPOWER  */
-       (iw_handler) NULL,      /* SIOCGIWPOWER  */
-       (iw_handler) NULL,      /* -- hole -- */
-       (iw_handler) NULL,      /* -- hole -- */
-       (iw_handler) rt_ioctl_siwgenie, /* SIOCSIWGENIE  */
-       (iw_handler) rt_ioctl_giwgenie, /* SIOCGIWGENIE  */
-       (iw_handler) rt_ioctl_siwauth,  /* SIOCSIWAUTH   */
-       (iw_handler) rt_ioctl_giwauth,  /* SIOCGIWAUTH   */
-       (iw_handler) rt_ioctl_siwencodeext,     /* SIOCSIWENCODEEXT */
-       (iw_handler) rt_ioctl_giwencodeext,     /* SIOCGIWENCODEEXT */
-       (iw_handler) rt_ioctl_siwpmksa, /* SIOCSIWPMKSA  */
-};
-
-const struct iw_handler_def rt28xx_iw_handler_def = {
-       .standard = (iw_handler *) rt_handler,
-       .num_standard = sizeof(rt_handler) / sizeof(iw_handler),
-#if IW_HANDLER_VERSION >= 7
-       .get_wireless_stats = rt28xx_get_wireless_stats,
-#endif
-};
-
-int rt28xx_sta_ioctl(IN struct net_device *net_dev,
-                    IN OUT struct ifreq *rq, int cmd)
-{
-       struct os_cookie *pObj;
-       struct rt_rtmp_adapter *pAd = NULL;
-       struct iwreq *wrq = (struct iwreq *)rq;
-       BOOLEAN StateMachineTouched = FALSE;
-       int Status = NDIS_STATUS_SUCCESS;
-
-       GET_PAD_FROM_NET_DEV(pAd, net_dev);
-
-       pObj = (struct os_cookie *)pAd->OS_Cookie;
-
-       /*check if the interface is down */
-       if (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE)) {
-               {
-                       DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
-                       return -ENETDOWN;
-               }
-       }
-
-       {                       /* determine this ioctl command is coming from which interface. */
-               pObj->ioctl_if_type = INT_MAIN;
-               pObj->ioctl_if = MAIN_MBSSID;
-       }
-
-       switch (cmd) {
-       case SIOCGIFHWADDR:
-               DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCGIFHWADDR\n"));
-               memcpy(wrq->u.name, pAd->CurrentAddress, ETH_ALEN);
-               break;
-       case SIOCGIWNAME:
-               {
-                       char *name = &wrq->u.name[0];
-                       rt_ioctl_giwname(net_dev, NULL, name, NULL);
-                       break;
-               }
-       case SIOCGIWESSID:      /*Get ESSID */
-               {
-                       struct iw_point *essid = &wrq->u.essid;
-                       rt_ioctl_giwessid(net_dev, NULL, essid, essid->pointer);
-                       break;
-               }
-       case SIOCSIWESSID:      /*Set ESSID */
-               {
-                       struct iw_point *essid = &wrq->u.essid;
-                       rt_ioctl_siwessid(net_dev, NULL, essid, essid->pointer);
-                       break;
-               }
-       case SIOCSIWNWID:       /* set network id (the cell) */
-       case SIOCGIWNWID:       /* get network id */
-               Status = -EOPNOTSUPP;
-               break;
-       case SIOCSIWFREQ:       /*set channel/frequency (Hz) */
-               {
-                       struct iw_freq *freq = &wrq->u.freq;
-                       rt_ioctl_siwfreq(net_dev, NULL, freq, NULL);
-                       break;
-               }
-       case SIOCGIWFREQ:       /* get channel/frequency (Hz) */
-               {
-                       struct iw_freq *freq = &wrq->u.freq;
-                       rt_ioctl_giwfreq(net_dev, NULL, freq, NULL);
-                       break;
-               }
-       case SIOCSIWNICKN:      /*set node name/nickname */
-               {
-                       /*struct iw_point *data=&wrq->u.data; */
-                       /*rt_ioctl_siwnickn(net_dev, NULL, data, NULL); */
-                       break;
-               }
-       case SIOCGIWNICKN:      /*get node name/nickname */
-               {
-                       struct iw_point *erq = NULL;
-                       erq = &wrq->u.data;
-                       erq->length = strlen((char *)pAd->nickname);
-                       Status =
-                           copy_to_user(erq->pointer, pAd->nickname,
-                                        erq->length);
-                       if (Status)
-                               Status = -EFAULT;
-                       break;
-               }
-       case SIOCGIWRATE:       /*get default bit rate (bps) */
-               rt_ioctl_giwrate(net_dev, NULL, &wrq->u, NULL);
-               break;
-       case SIOCSIWRATE:       /*set default bit rate (bps) */
-               rt_ioctl_siwrate(net_dev, NULL, &wrq->u, NULL);
-               break;
-       case SIOCGIWRTS:        /* get RTS/CTS threshold (bytes) */
-               {
-                       struct iw_param *rts = &wrq->u.rts;
-                       rt_ioctl_giwrts(net_dev, NULL, rts, NULL);
-                       break;
-               }
-       case SIOCSIWRTS:        /*set RTS/CTS threshold (bytes) */
-               {
-                       struct iw_param *rts = &wrq->u.rts;
-                       rt_ioctl_siwrts(net_dev, NULL, rts, NULL);
-                       break;
-               }
-       case SIOCGIWFRAG:       /*get fragmentation thr (bytes) */
-               {
-                       struct iw_param *frag = &wrq->u.frag;
-                       rt_ioctl_giwfrag(net_dev, NULL, frag, NULL);
-                       break;
-               }
-       case SIOCSIWFRAG:       /*set fragmentation thr (bytes) */
-               {
-                       struct iw_param *frag = &wrq->u.frag;
-                       rt_ioctl_siwfrag(net_dev, NULL, frag, NULL);
-                       break;
-               }
-       case SIOCGIWENCODE:     /*get encoding token & mode */
-               {
-                       struct iw_point *erq = &wrq->u.encoding;
-                       if (erq)
-                               rt_ioctl_giwencode(net_dev, NULL, erq,
-                                                  erq->pointer);
-                       break;
-               }
-       case SIOCSIWENCODE:     /*set encoding token & mode */
-               {
-                       struct iw_point *erq = &wrq->u.encoding;
-                       if (erq)
-                               rt_ioctl_siwencode(net_dev, NULL, erq,
-                                                  erq->pointer);
-                       break;
-               }
-       case SIOCGIWAP: /*get access point MAC addresses */
-               {
-                       struct sockaddr *ap_addr = &wrq->u.ap_addr;
-                       rt_ioctl_giwap(net_dev, NULL, ap_addr,
-                                      ap_addr->sa_data);
-                       break;
-               }
-       case SIOCSIWAP: /*set access point MAC addresses */
-               {
-                       struct sockaddr *ap_addr = &wrq->u.ap_addr;
-                       rt_ioctl_siwap(net_dev, NULL, ap_addr,
-                                      ap_addr->sa_data);
-                       break;
-               }
-       case SIOCGIWMODE:       /*get operation mode */
-               {
-                       __u32 *mode = &wrq->u.mode;
-                       rt_ioctl_giwmode(net_dev, NULL, mode, NULL);
-                       break;
-               }
-       case SIOCSIWMODE:       /*set operation mode */
-               {
-                       __u32 *mode = &wrq->u.mode;
-                       rt_ioctl_siwmode(net_dev, NULL, mode, NULL);
-                       break;
-               }
-       case SIOCGIWSENS:       /*get sensitivity (dBm) */
-       case SIOCSIWSENS:       /*set sensitivity (dBm) */
-       case SIOCGIWPOWER:      /*get Power Management settings */
-       case SIOCSIWPOWER:      /*set Power Management settings */
-       case SIOCGIWTXPOW:      /*get transmit power (dBm) */
-       case SIOCSIWTXPOW:      /*set transmit power (dBm) */
-       case SIOCGIWRANGE:      /*Get range of parameters */
-       case SIOCGIWRETRY:      /*get retry limits and lifetime */
-       case SIOCSIWRETRY:      /*set retry limits and lifetime */
-       case RT_PRIV_IOCTL:
-       case RT_PRIV_IOCTL_EXT:
-       case RTPRIV_IOCTL_SET:
-       case RTPRIV_IOCTL_GSITESURVEY:
-       case SIOCGIWPRIV:
-               Status = -EOPNOTSUPP;
-               break;
-       case SIOCETHTOOL:
-               break;
-       default:
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("IOCTL::unknown IOCTL's cmd = 0x%08x\n", cmd));
-               Status = -EOPNOTSUPP;
-               break;
-       }
-
-       if (StateMachineTouched)        /* Upper layer sent a MLME-related operations */
-               RTMP_MLME_HANDLER(pAd);
-
-       return Status;
-}
-
-/*
-    ==========================================================================
-    Description:
-        Set SSID
-    Return:
-        TRUE if all parameters are OK, FALSE otherwise
-    ==========================================================================
-*/
-int Set_SSID_Proc(struct rt_rtmp_adapter *pAdapter, char *arg)
-{
-       struct rt_ndis_802_11_ssid Ssid, *pSsid = NULL;
-       BOOLEAN StateMachineTouched = FALSE;
-       int success = TRUE;
-
-       if (strlen(arg) <= MAX_LEN_OF_SSID) {
-               NdisZeroMemory(&Ssid, sizeof(struct rt_ndis_802_11_ssid));
-               if (strlen(arg) != 0) {
-                       NdisMoveMemory(Ssid.Ssid, arg, strlen(arg));
-                       Ssid.SsidLength = strlen(arg);
-               } else          /*ANY ssid */
-               {
-                       Ssid.SsidLength = 0;
-                       memcpy(Ssid.Ssid, "", 0);
-                       pAdapter->StaCfg.BssType = BSS_INFRA;
-                       pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
-                       pAdapter->StaCfg.WepStatus =
-                           Ndis802_11EncryptionDisabled;
-               }
-               pSsid = &Ssid;
-
-               if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE) {
-                       RTMP_MLME_RESET_STATE_MACHINE(pAdapter);
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("MLME busy, reset MLME state machine!\n"));
-               }
-
-               if ((pAdapter->StaCfg.WpaPassPhraseLen >= 8) &&
-                   (pAdapter->StaCfg.WpaPassPhraseLen <= 64)) {
-                       char passphrase_str[65] = { 0 };
-                       u8 keyMaterial[40];
-
-                       RTMPMoveMemory(passphrase_str,
-                                      pAdapter->StaCfg.WpaPassPhrase,
-                                      pAdapter->StaCfg.WpaPassPhraseLen);
-                       RTMPZeroMemory(pAdapter->StaCfg.PMK, 32);
-                       if (pAdapter->StaCfg.WpaPassPhraseLen == 64) {
-                               AtoH((char *)pAdapter->StaCfg.WpaPassPhrase,
-                                    pAdapter->StaCfg.PMK, 32);
-                       } else {
-                               PasswordHash((char *)pAdapter->StaCfg.
-                                            WpaPassPhrase, Ssid.Ssid,
-                                            Ssid.SsidLength, keyMaterial);
-                               NdisMoveMemory(pAdapter->StaCfg.PMK,
-                                              keyMaterial, 32);
-                       }
-               }
-
-               pAdapter->MlmeAux.CurrReqIsFromNdis = TRUE;
-               pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
-               pAdapter->bConfigChanged = TRUE;
-
-               MlmeEnqueue(pAdapter,
-                           MLME_CNTL_STATE_MACHINE,
-                           OID_802_11_SSID,
-                           sizeof(struct rt_ndis_802_11_ssid), (void *) pSsid);
-
-               StateMachineTouched = TRUE;
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("Set_SSID_Proc::(Len=%d,Ssid=%s)\n", Ssid.SsidLength,
-                         Ssid.Ssid));
-       } else
-               success = FALSE;
-
-       if (StateMachineTouched)        /* Upper layer sent a MLME-related operations */
-               RTMP_MLME_HANDLER(pAdapter);
-
-       return success;
-}
-
-/*
-    ==========================================================================
-    Description:
-        Set Network Type(Infrastructure/Adhoc mode)
-    Return:
-        TRUE if all parameters are OK, FALSE otherwise
-    ==========================================================================
-*/
-int Set_NetworkType_Proc(struct rt_rtmp_adapter *pAdapter, char *arg)
-{
-       u32 Value = 0;
-
-       if (strcmp(arg, "Adhoc") == 0) {
-               if (pAdapter->StaCfg.BssType != BSS_ADHOC) {
-                       /* Config has changed */
-                       pAdapter->bConfigChanged = TRUE;
-                       if (MONITOR_ON(pAdapter)) {
-                               RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG,
-                                               STANORMAL);
-                               RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
-                               Value &= (~0x80);
-                               RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
-                               OPSTATUS_CLEAR_FLAG(pAdapter,
-                                                   fOP_STATUS_MEDIA_STATE_CONNECTED);
-                               pAdapter->StaCfg.bAutoReconnect = TRUE;
-                               LinkDown(pAdapter, FALSE);
-                       }
-                       if (INFRA_ON(pAdapter)) {
-                               /*BOOLEAN Cancelled; */
-                               /* Set the AutoReconnectSsid to prevent it from reconnecting to the old SSID */
-                               /* Since calling this indicates users don't want to connect to that SSID anymore. */
-                               pAdapter->MlmeAux.AutoReconnectSsidLen = 32;
-                               NdisZeroMemory(pAdapter->MlmeAux.
-                                              AutoReconnectSsid,
-                                              pAdapter->MlmeAux.
-                                              AutoReconnectSsidLen);
-
-                               LinkDown(pAdapter, FALSE);
-
-                               DBGPRINT(RT_DEBUG_TRACE,
-                                        ("NDIS_STATUS_MEDIA_DISCONNECT Event BB!\n"));
-                       }
-               }
-               pAdapter->StaCfg.BssType = BSS_ADHOC;
-               pAdapter->net_dev->type = pAdapter->StaCfg.OriDevType;
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("===>Set_NetworkType_Proc::(AD-HOC)\n"));
-       } else if (strcmp(arg, "Infra") == 0) {
-               if (pAdapter->StaCfg.BssType != BSS_INFRA) {
-                       /* Config has changed */
-                       pAdapter->bConfigChanged = TRUE;
-                       if (MONITOR_ON(pAdapter)) {
-                               RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG,
-                                               STANORMAL);
-                               RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value);
-                               Value &= (~0x80);
-                               RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value);
-                               OPSTATUS_CLEAR_FLAG(pAdapter,
-                                                   fOP_STATUS_MEDIA_STATE_CONNECTED);
-                               pAdapter->StaCfg.bAutoReconnect = TRUE;
-                               LinkDown(pAdapter, FALSE);
-                       }
-                       if (ADHOC_ON(pAdapter)) {
-                               /* Set the AutoReconnectSsid to prevent it from reconnecting to the old SSID */
-                               /* Since calling this indicates users don't want to connect to that SSID anymore. */
-                               pAdapter->MlmeAux.AutoReconnectSsidLen = 32;
-                               NdisZeroMemory(pAdapter->MlmeAux.
-                                              AutoReconnectSsid,
-                                              pAdapter->MlmeAux.
-                                              AutoReconnectSsidLen);
-
-                               LinkDown(pAdapter, FALSE);
-                       }
-               }
-               pAdapter->StaCfg.BssType = BSS_INFRA;
-               pAdapter->net_dev->type = pAdapter->StaCfg.OriDevType;
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("===>Set_NetworkType_Proc::(INFRA)\n"));
-       } else if (strcmp(arg, "Monitor") == 0) {
-               u8 bbpValue = 0;
-               BCN_TIME_CFG_STRUC csr;
-               OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_INFRA_ON);
-               OPSTATUS_CLEAR_FLAG(pAdapter, fOP_STATUS_ADHOC_ON);
-               OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED);
-               /* disable all periodic state machine */
-               pAdapter->StaCfg.bAutoReconnect = FALSE;
-               /* reset all mlme state machine */
-               RTMP_MLME_RESET_STATE_MACHINE(pAdapter);
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("fOP_STATUS_MEDIA_STATE_CONNECTED \n"));
-               if (pAdapter->CommonCfg.CentralChannel == 0) {
-                       if (pAdapter->CommonCfg.PhyMode == PHY_11AN_MIXED)
-                               pAdapter->CommonCfg.CentralChannel = 36;
-                       else
-                               pAdapter->CommonCfg.CentralChannel = 6;
-               } else
-                       N_ChannelCheck(pAdapter);
-
-               if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED &&
-                   pAdapter->CommonCfg.RegTransmitSetting.field.BW == BW_40 &&
-                   pAdapter->CommonCfg.RegTransmitSetting.field.EXTCHA ==
-                   EXTCHA_ABOVE) {
-                       /* 40MHz ,control channel at lower */
-                       RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4,
-                                                   &bbpValue);
-                       bbpValue &= (~0x18);
-                       bbpValue |= 0x10;
-                       RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4,
-                                                    bbpValue);
-                       pAdapter->CommonCfg.BBPCurrentBW = BW_40;
-                       /*  RX : control channel at lower */
-                       RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R3,
-                                                   &bbpValue);
-                       bbpValue &= (~0x20);
-                       RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R3,
-                                                    bbpValue);
-
-                       RTMP_IO_READ32(pAdapter, TX_BAND_CFG, &Value);
-                       Value &= 0xfffffffe;
-                       RTMP_IO_WRITE32(pAdapter, TX_BAND_CFG, Value);
-                       pAdapter->CommonCfg.CentralChannel =
-                           pAdapter->CommonCfg.Channel + 2;
-                       AsicSwitchChannel(pAdapter,
-                                         pAdapter->CommonCfg.CentralChannel,
-                                         FALSE);
-                       AsicLockChannel(pAdapter,
-                                       pAdapter->CommonCfg.CentralChannel);
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("BW_40 ,control_channel(%d), CentralChannel(%d) \n",
-                                 pAdapter->CommonCfg.Channel,
-                                 pAdapter->CommonCfg.CentralChannel));
-               } else if (pAdapter->CommonCfg.PhyMode >= PHY_11ABGN_MIXED
-                          && pAdapter->CommonCfg.RegTransmitSetting.field.BW ==
-                          BW_40
-                          && pAdapter->CommonCfg.RegTransmitSetting.field.
-                          EXTCHA == EXTCHA_BELOW) {
-                       /* 40MHz ,control channel at upper */
-                       RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4,
-                                                   &bbpValue);
-                       bbpValue &= (~0x18);
-                       bbpValue |= 0x10;
-                       RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4,
-                                                    bbpValue);
-                       pAdapter->CommonCfg.BBPCurrentBW = BW_40;
-                       RTMP_IO_READ32(pAdapter, TX_BAND_CFG, &Value);
-                       Value |= 0x1;
-                       RTMP_IO_WRITE32(pAdapter, TX_BAND_CFG, Value);
-
-                       RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R3,
-                                                   &bbpValue);
-                       bbpValue |= (0x20);
-                       RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R3,
-                                                    bbpValue);
-                       pAdapter->CommonCfg.CentralChannel =
-                           pAdapter->CommonCfg.Channel - 2;
-                       AsicSwitchChannel(pAdapter,
-                                         pAdapter->CommonCfg.CentralChannel,
-                                         FALSE);
-                       AsicLockChannel(pAdapter,
-                                       pAdapter->CommonCfg.CentralChannel);
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("BW_40 ,control_channel(%d), CentralChannel(%d) \n",
-                                 pAdapter->CommonCfg.Channel,
-                                 pAdapter->CommonCfg.CentralChannel));
-               } else {
-                       /* 20MHz */
-                       RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R4,
-                                                   &bbpValue);
-                       bbpValue &= (~0x18);
-                       RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4,
-                                                    bbpValue);
-                       pAdapter->CommonCfg.BBPCurrentBW = BW_20;
-                       AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.Channel,
-                                         FALSE);
-                       AsicLockChannel(pAdapter, pAdapter->CommonCfg.Channel);
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("BW_20, Channel(%d)\n",
-                                 pAdapter->CommonCfg.Channel));
-               }
-               /* Enable Rx with promiscuous reception */
-               RTMP_IO_WRITE32(pAdapter, RX_FILTR_CFG, 0x3);
-               /* ASIC supports sniffer function with replacing RSSI with timestamp. */
-               /*RTMP_IO_READ32(pAdapter, MAC_SYS_CTRL, &Value); */
-               /*Value |= (0x80); */
-               /*RTMP_IO_WRITE32(pAdapter, MAC_SYS_CTRL, Value); */
-               /* disable sync */
-               RTMP_IO_READ32(pAdapter, BCN_TIME_CFG, &csr.word);
-               csr.field.bBeaconGen = 0;
-               csr.field.bTBTTEnable = 0;
-               csr.field.TsfSyncMode = 0;
-               RTMP_IO_WRITE32(pAdapter, BCN_TIME_CFG, csr.word);
-
-               pAdapter->StaCfg.BssType = BSS_MONITOR;
-               pAdapter->net_dev->type = ARPHRD_IEEE80211_PRISM;       /*ARPHRD_IEEE80211; // IEEE80211 */
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("===>Set_NetworkType_Proc::(MONITOR)\n"));
-       }
-       /* Reset Ralink supplicant to not use, it will be set to start when UI set PMK key */
-       pAdapter->StaCfg.WpaState = SS_NOTUSE;
-
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("Set_NetworkType_Proc::(NetworkType=%d)\n",
-                 pAdapter->StaCfg.BssType));
-
-       return TRUE;
-}
diff --git a/drivers/staging/rt2860/usb_main_dev.c b/drivers/staging/rt2860/usb_main_dev.c
deleted file mode 100644 (file)
index 322bf49..0000000
+++ /dev/null
@@ -1,927 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************/
-
-#include "rt_config.h"
-
-/* Following information will be show when you run 'modinfo' */
-/* If you have a solution for the bug in current version of driver, please e-mail me. */
-/* Otherwise post to the forum at ralinktech's web site(www.ralinktech.com) and let all users help you. */
-MODULE_AUTHOR("Paul Lin <paul_lin@ralinktech.com>");
-MODULE_DESCRIPTION("RT2870/RT3070 Wireless Lan Linux Driver");
-MODULE_LICENSE("GPL");
-#ifdef MODULE_VERSION
-MODULE_VERSION(STA_DRIVER_VERSION);
-#endif
-
-/* module table */
-struct usb_device_id rtusb_usb_id[] = {
-#ifdef RT2870
-       {USB_DEVICE(0x148F, 0x2770)},   /* Ralink */
-       {USB_DEVICE(0x148F, 0x2870)},   /* Ralink */
-       {USB_DEVICE(0x07B8, 0x2870)},   /* AboCom */
-       {USB_DEVICE(0x07B8, 0x2770)},   /* AboCom */
-       {USB_DEVICE(0x0DF6, 0x0039)},   /* Sitecom 2770 */
-       {USB_DEVICE(0x0DF6, 0x003F)},   /* Sitecom 2770 */
-       {USB_DEVICE(0x083A, 0x7512)},   /* Arcadyan 2770 */
-       {USB_DEVICE(0x0789, 0x0162)},   /* Logitec 2870 */
-       {USB_DEVICE(0x0789, 0x0163)},   /* Logitec 2870 */
-       {USB_DEVICE(0x0789, 0x0164)},   /* Logitec 2870 */
-       {USB_DEVICE(0x177f, 0x0302)},   /* lsusb */
-       {USB_DEVICE(0x0B05, 0x1731)},   /* Asus */
-       {USB_DEVICE(0x0B05, 0x1732)},   /* Asus */
-       {USB_DEVICE(0x0B05, 0x1742)},   /* Asus */
-       {USB_DEVICE(0x0DF6, 0x0017)},   /* Sitecom */
-       {USB_DEVICE(0x0DF6, 0x002B)},   /* Sitecom */
-       {USB_DEVICE(0x0DF6, 0x002C)},   /* Sitecom */
-       {USB_DEVICE(0x0DF6, 0x002D)},   /* Sitecom */
-       {USB_DEVICE(0x14B2, 0x3C06)},   /* Conceptronic */
-       {USB_DEVICE(0x14B2, 0x3C28)},   /* Conceptronic */
-       {USB_DEVICE(0x2019, 0xED06)},   /* Planex Communications, Inc. */
-       {USB_DEVICE(0x07D1, 0x3C09)},   /* D-Link */
-       {USB_DEVICE(0x07D1, 0x3C11)},   /* D-Link */
-       {USB_DEVICE(0x14B2, 0x3C07)},   /* AL */
-       {USB_DEVICE(0x050D, 0x8053)},   /* Belkin */
-       {USB_DEVICE(0x050D, 0x825B)},   /* Belkin */
-       {USB_DEVICE(0x050D, 0x935A)},   /* Belkin F6D4050 v1 */
-       {USB_DEVICE(0x050D, 0x935B)},   /* Belkin F6D4050 v2 */
-       {USB_DEVICE(0x14B2, 0x3C23)},   /* Airlink */
-       {USB_DEVICE(0x14B2, 0x3C27)},   /* Airlink */
-       {USB_DEVICE(0x07AA, 0x002F)},   /* Corega */
-       {USB_DEVICE(0x07AA, 0x003C)},   /* Corega */
-       {USB_DEVICE(0x07AA, 0x003F)},   /* Corega */
-       {USB_DEVICE(0x1044, 0x800B)},   /* Gigabyte */
-       {USB_DEVICE(0x15A9, 0x0006)},   /* Sparklan */
-       {USB_DEVICE(0x083A, 0xB522)},   /* SMC */
-       {USB_DEVICE(0x083A, 0xA618)},   /* SMC */
-       {USB_DEVICE(0x083A, 0x8522)},   /* Arcadyan */
-       {USB_DEVICE(0x083A, 0x7522)},   /* Arcadyan */
-       {USB_DEVICE(0x0CDE, 0x0022)},   /* ZCOM */
-       {USB_DEVICE(0x0586, 0x3416)},   /* Zyxel */
-       {USB_DEVICE(0x0586, 0x341a)},   /* Zyxel NWD-270N */
-       {USB_DEVICE(0x0CDE, 0x0025)},   /* Zyxel */
-       {USB_DEVICE(0x1740, 0x9701)},   /* EnGenius */
-       {USB_DEVICE(0x1740, 0x9702)},   /* EnGenius */
-       {USB_DEVICE(0x0471, 0x200f)},   /* Philips */
-       {USB_DEVICE(0x14B2, 0x3C25)},   /* Draytek */
-       {USB_DEVICE(0x13D3, 0x3247)},   /* AzureWave */
-       {USB_DEVICE(0x083A, 0x6618)},   /* Accton */
-       {USB_DEVICE(0x15c5, 0x0008)},   /* Amit */
-       {USB_DEVICE(0x0E66, 0x0001)},   /* Hawking */
-       {USB_DEVICE(0x0E66, 0x0003)},   /* Hawking */
-       {USB_DEVICE(0x129B, 0x1828)},   /* Siemens */
-       {USB_DEVICE(0x157E, 0x300E)},   /* U-Media */
-       {USB_DEVICE(0x050d, 0x805c)},
-       {USB_DEVICE(0x050d, 0x815c)},
-       {USB_DEVICE(0x1482, 0x3C09)},   /* Abocom */
-       {USB_DEVICE(0x14B2, 0x3C09)},   /* Alpha */
-       {USB_DEVICE(0x04E8, 0x2018)},   /* samsung linkstick2 */
-       {USB_DEVICE(0x1690, 0x0740)},   /* Askey */
-       {USB_DEVICE(0x5A57, 0x0280)},   /* Zinwell */
-       {USB_DEVICE(0x5A57, 0x0282)},   /* Zinwell */
-       {USB_DEVICE(0x7392, 0x7718)},
-       {USB_DEVICE(0x7392, 0x7717)},
-       {USB_DEVICE(0x0411, 0x016f)},   /* MelCo.,Inc. WLI-UC-G301N */
-       {USB_DEVICE(0x1737, 0x0070)},   /* Linksys WUSB100 */
-       {USB_DEVICE(0x1737, 0x0071)},   /* Linksys WUSB600N */
-       {USB_DEVICE(0x1737, 0x0078)},   /* Linksys WUSB100v2 */
-       {USB_DEVICE(0x0411, 0x00e8)},   /* Buffalo WLI-UC-G300N */
-       {USB_DEVICE(0x050d, 0x815c)},   /* Belkin F5D8053 */
-       {USB_DEVICE(0x100D, 0x9031)},   /* Motorola 2770 */
-#endif /* RT2870 // */
-#ifdef RT3070
-       {USB_DEVICE(0x148F, 0x3070)},   /* Ralink 3070 */
-       {USB_DEVICE(0x148F, 0x3071)},   /* Ralink 3071 */
-       {USB_DEVICE(0x148F, 0x3072)},   /* Ralink 3072 */
-       {USB_DEVICE(0x0DB0, 0x3820)},   /* Ralink 3070 */
-       {USB_DEVICE(0x0DB0, 0x871C)},   /* Ralink 3070 */
-       {USB_DEVICE(0x0DB0, 0x822C)},   /* Ralink 3070 */
-       {USB_DEVICE(0x0DB0, 0x871B)},   /* Ralink 3070 */
-       {USB_DEVICE(0x0DB0, 0x822B)},   /* Ralink 3070 */
-       {USB_DEVICE(0x0DF6, 0x003E)},   /* Sitecom 3070 */
-       {USB_DEVICE(0x0DF6, 0x0042)},   /* Sitecom 3072 */
-       {USB_DEVICE(0x0DF6, 0x0048)},   /* Sitecom 3070 */
-       {USB_DEVICE(0x0DF6, 0x0047)},   /* Sitecom 3071 */
-       {USB_DEVICE(0x14B2, 0x3C12)},   /* AL 3070 */
-       {USB_DEVICE(0x18C5, 0x0012)},   /* Corega 3070 */
-       {USB_DEVICE(0x083A, 0x7511)},   /* Arcadyan 3070 */
-       {USB_DEVICE(0x083A, 0xA701)},   /* SMC 3070 */
-       {USB_DEVICE(0x083A, 0xA702)},   /* SMC 3072 */
-       {USB_DEVICE(0x1740, 0x9703)},   /* EnGenius 3070 */
-       {USB_DEVICE(0x1740, 0x9705)},   /* EnGenius 3071 */
-       {USB_DEVICE(0x1740, 0x9706)},   /* EnGenius 3072 */
-       {USB_DEVICE(0x1740, 0x9707)},   /* EnGenius 3070 */
-       {USB_DEVICE(0x1740, 0x9708)},   /* EnGenius 3071 */
-       {USB_DEVICE(0x1740, 0x9709)},   /* EnGenius 3072 */
-       {USB_DEVICE(0x13D3, 0x3273)},   /* AzureWave 3070 */
-       {USB_DEVICE(0x13D3, 0x3305)},   /* AzureWave 3070*/
-       {USB_DEVICE(0x1044, 0x800D)},   /* Gigabyte GN-WB32L 3070 */
-       {USB_DEVICE(0x2019, 0xAB25)},   /* Planex Communications, Inc. RT3070 */
-       {USB_DEVICE(0x07B8, 0x3070)},   /* AboCom 3070 */
-       {USB_DEVICE(0x07B8, 0x3071)},   /* AboCom 3071 */
-       {USB_DEVICE(0x07B8, 0x3072)},   /* Abocom 3072 */
-       {USB_DEVICE(0x7392, 0x7711)},   /* Edimax 3070 */
-       {USB_DEVICE(0x1A32, 0x0304)},   /* Quanta 3070 */
-       {USB_DEVICE(0x1EDA, 0x2310)},   /* AirTies 3070 */
-       {USB_DEVICE(0x07D1, 0x3C0A)},   /* D-Link 3072 */
-       {USB_DEVICE(0x07D1, 0x3C0D)},   /* D-Link 3070 */
-       {USB_DEVICE(0x07D1, 0x3C0E)},   /* D-Link 3070 */
-       {USB_DEVICE(0x07D1, 0x3C0F)},   /* D-Link 3070 */
-       {USB_DEVICE(0x07D1, 0x3C16)},   /* D-Link 3070 */
-       {USB_DEVICE(0x07D1, 0x3C17)},   /* D-Link 8070 */
-       {USB_DEVICE(0x1D4D, 0x000C)},   /* Pegatron Corporation 3070 */
-       {USB_DEVICE(0x1D4D, 0x000E)},   /* Pegatron Corporation 3070 */
-       {USB_DEVICE(0x5A57, 0x5257)},   /* Zinwell 3070 */
-       {USB_DEVICE(0x5A57, 0x0283)},   /* Zinwell 3072 */
-       {USB_DEVICE(0x04BB, 0x0945)},   /* I-O DATA 3072 */
-       {USB_DEVICE(0x04BB, 0x0947)},   /* I-O DATA 3070 */
-       {USB_DEVICE(0x04BB, 0x0948)},   /* I-O DATA 3072 */
-       {USB_DEVICE(0x203D, 0x1480)},   /* Encore 3070 */
-       {USB_DEVICE(0x20B8, 0x8888)},   /* PARA INDUSTRIAL 3070 */
-       {USB_DEVICE(0x0B05, 0x1784)},   /* Asus 3072 */
-       {USB_DEVICE(0x203D, 0x14A9)},   /* Encore 3070*/
-       {USB_DEVICE(0x0DB0, 0x899A)},   /* MSI 3070*/
-       {USB_DEVICE(0x0DB0, 0x3870)},   /* MSI 3070*/
-       {USB_DEVICE(0x0DB0, 0x870A)},   /* MSI 3070*/
-       {USB_DEVICE(0x0DB0, 0x6899)},   /* MSI 3070 */
-       {USB_DEVICE(0x0DB0, 0x3822)},   /* MSI 3070 */
-       {USB_DEVICE(0x0DB0, 0x3871)},   /* MSI 3070 */
-       {USB_DEVICE(0x0DB0, 0x871A)},   /* MSI 3070 */
-       {USB_DEVICE(0x0DB0, 0x822A)},   /* MSI 3070 */
-       {USB_DEVICE(0x0DB0, 0x3821)},   /* Ralink 3070 */
-       {USB_DEVICE(0x0DB0, 0x821A)},   /* Ralink 3070 */
-       {USB_DEVICE(0x083A, 0xA703)},   /* IO-MAGIC */
-       {USB_DEVICE(0x13D3, 0x3307)},   /* Azurewave */
-       {USB_DEVICE(0x13D3, 0x3321)},   /* Azurewave */
-       {USB_DEVICE(0x07FA, 0x7712)},   /* Edimax */
-       {USB_DEVICE(0x0789, 0x0166)},   /* Edimax */
-       {USB_DEVICE(0x148F, 0x2070)},   /* Edimax */
-#endif /* RT3070 // */
-       {USB_DEVICE(0x1737, 0x0077)},   /* Linksys WUSB54GC-EU v3 */
-       {USB_DEVICE(0x2001, 0x3C09)},   /* D-Link */
-       {USB_DEVICE(0x2001, 0x3C0A)},   /* D-Link 3072 */
-       {USB_DEVICE(0x2019, 0xED14)},   /* Planex Communications, Inc. */
-       {USB_DEVICE(0x0411, 0x015D)},   /* Buffalo Airstation WLI-UC-GN */
-       {}                      /* Terminating entry */
-};
-
-int const rtusb_usb_id_len =
-    sizeof(rtusb_usb_id) / sizeof(struct usb_device_id);
-
-MODULE_DEVICE_TABLE(usb, rtusb_usb_id);
-
-static void rt2870_disconnect(struct usb_device *dev, struct rt_rtmp_adapter *pAd);
-
-static int __devinit rt2870_probe(IN struct usb_interface *intf,
-                                 IN struct usb_device *usb_dev,
-                                 IN const struct usb_device_id *dev_id,
-                                 struct rt_rtmp_adapter **ppAd);
-
-#ifndef PF_NOFREEZE
-#define PF_NOFREEZE  0
-#endif
-
-extern int rt28xx_close(IN struct net_device *net_dev);
-extern int rt28xx_open(struct net_device *net_dev);
-
-static BOOLEAN USBDevConfigInit(IN struct usb_device *dev,
-                               IN struct usb_interface *intf,
-                               struct rt_rtmp_adapter *pAd);
-
-/*
-========================================================================
-Routine Description:
-    Check the chipset vendor/product ID.
-
-Arguments:
-    _dev_p                             Point to the PCI or USB device
-
-Return Value:
-    TRUE                               Check ok
-       FALSE                           Check fail
-
-Note:
-========================================================================
-*/
-BOOLEAN RT28XXChipsetCheck(IN void *_dev_p)
-{
-       struct usb_interface *intf = (struct usb_interface *)_dev_p;
-       struct usb_device *dev_p = interface_to_usbdev(intf);
-       u32 i;
-
-       for (i = 0; i < rtusb_usb_id_len; i++) {
-               if (dev_p->descriptor.idVendor == rtusb_usb_id[i].idVendor &&
-                   dev_p->descriptor.idProduct == rtusb_usb_id[i].idProduct) {
-                       printk(KERN_INFO "rt2870: idVendor = 0x%x, idProduct = 0x%x\n",
-                              dev_p->descriptor.idVendor,
-                              dev_p->descriptor.idProduct);
-                       break;
-               }
-       }
-
-       if (i == rtusb_usb_id_len) {
-               printk(KERN_ERR "rt2870: Error! Device Descriptor not matching!\n");
-               return FALSE;
-       }
-
-       return TRUE;
-}
-
-/**************************************************************************/
-/**************************************************************************/
-/*tested for kernel 2.6series */
-/**************************************************************************/
-/**************************************************************************/
-
-#ifdef CONFIG_PM
-static int rt2870_suspend(struct usb_interface *intf, pm_message_t state);
-static int rt2870_resume(struct usb_interface *intf);
-#endif /* CONFIG_PM // */
-
-static BOOLEAN USBDevConfigInit(IN struct usb_device *dev,
-                               IN struct usb_interface *intf,
-                               struct rt_rtmp_adapter *pAd)
-{
-       struct usb_host_interface *iface_desc;
-       unsigned long BulkOutIdx;
-       u32 i;
-
-       /* get the active interface descriptor */
-       iface_desc = intf->cur_altsetting;
-
-       /* get # of enpoints  */
-       pAd->NumberOfPipes = iface_desc->desc.bNumEndpoints;
-       DBGPRINT(RT_DEBUG_TRACE,
-                ("NumEndpoints=%d\n", iface_desc->desc.bNumEndpoints));
-
-       /* Configure Pipes */
-       BulkOutIdx = 0;
-
-       for (i = 0; i < pAd->NumberOfPipes; i++) {
-               if ((iface_desc->endpoint[i].desc.bmAttributes ==
-                    USB_ENDPOINT_XFER_BULK) &&
-                   ((iface_desc->endpoint[i].desc.bEndpointAddress &
-                     USB_ENDPOINT_DIR_MASK) == USB_DIR_IN)) {
-                       pAd->BulkInEpAddr =
-                           iface_desc->endpoint[i].desc.bEndpointAddress;
-                       pAd->BulkInMaxPacketSize =
-                           le2cpu16(iface_desc->endpoint[i].desc.
-                                    wMaxPacketSize);
-
-                       DBGPRINT_RAW(RT_DEBUG_TRACE,
-                                    ("BULK IN MaxPacketSize = %d\n",
-                                     pAd->BulkInMaxPacketSize));
-                       DBGPRINT_RAW(RT_DEBUG_TRACE,
-                                    ("EP address = 0x%2x\n",
-                                     iface_desc->endpoint[i].desc.
-                                     bEndpointAddress));
-               } else
-                   if ((iface_desc->endpoint[i].desc.bmAttributes ==
-                        USB_ENDPOINT_XFER_BULK)
-                       &&
-                       ((iface_desc->endpoint[i].desc.
-                         bEndpointAddress & USB_ENDPOINT_DIR_MASK) ==
-                        USB_DIR_OUT)) {
-                       /* there are 6 bulk out EP. EP6 highest priority. */
-                       /* EP1-4 is EDCA.  EP5 is HCCA. */
-                       pAd->BulkOutEpAddr[BulkOutIdx++] =
-                           iface_desc->endpoint[i].desc.bEndpointAddress;
-                       pAd->BulkOutMaxPacketSize =
-                           le2cpu16(iface_desc->endpoint[i].desc.
-                                    wMaxPacketSize);
-
-                       DBGPRINT_RAW(RT_DEBUG_TRACE,
-                                    ("BULK OUT MaxPacketSize = %d\n",
-                                     pAd->BulkOutMaxPacketSize));
-                       DBGPRINT_RAW(RT_DEBUG_TRACE,
-                                    ("EP address = 0x%2x  \n",
-                                     iface_desc->endpoint[i].desc.
-                                     bEndpointAddress));
-               }
-       }
-
-       if (!(pAd->BulkInEpAddr && pAd->BulkOutEpAddr[0])) {
-               printk
-                   (KERN_ERR "%s: Could not find both bulk-in and bulk-out endpoints\n",
-                    __FUNCTION__);
-               return FALSE;
-       }
-
-       pAd->config = &dev->config->desc;
-       usb_set_intfdata(intf, pAd);
-
-       return TRUE;
-
-}
-
-static int __devinit rtusb_probe(struct usb_interface *intf,
-                      const struct usb_device_id *id)
-{
-       struct rt_rtmp_adapter *pAd;
-       struct usb_device *dev;
-       int rv;
-
-       dev = interface_to_usbdev(intf);
-       dev = usb_get_dev(dev);
-
-       rv = rt2870_probe(intf, dev, id, &pAd);
-       if (rv != 0)
-               usb_put_dev(dev);
-
-       return rv;
-}
-
-static void rtusb_disconnect(struct usb_interface *intf)
-{
-       struct usb_device *dev = interface_to_usbdev(intf);
-       struct rt_rtmp_adapter *pAd;
-
-       pAd = usb_get_intfdata(intf);
-       usb_set_intfdata(intf, NULL);
-
-       rt2870_disconnect(dev, pAd);
-}
-
-struct usb_driver rtusb_driver = {
-       .name = "rt2870",
-       .probe = rtusb_probe,
-       .disconnect = rtusb_disconnect,
-       .id_table = rtusb_usb_id,
-
-#ifdef CONFIG_PM
-suspend:rt2870_suspend,
-resume:rt2870_resume,
-#endif
-};
-
-#ifdef CONFIG_PM
-
-void RT2870RejectPendingPackets(struct rt_rtmp_adapter *pAd)
-{
-       /* clear PS packets */
-       /* clear TxSw packets */
-}
-
-static int rt2870_suspend(struct usb_interface *intf, pm_message_t state)
-{
-       struct net_device *net_dev;
-       struct rt_rtmp_adapter *pAd = usb_get_intfdata(intf);
-
-       DBGPRINT(RT_DEBUG_TRACE, ("===> rt2870_suspend()\n"));
-       net_dev = pAd->net_dev;
-       netif_device_detach(net_dev);
-
-       pAd->PM_FlgSuspend = 1;
-       if (netif_running(net_dev)) {
-               RTUSBCancelPendingBulkInIRP(pAd);
-               RTUSBCancelPendingBulkOutIRP(pAd);
-       }
-       DBGPRINT(RT_DEBUG_TRACE, ("<=== rt2870_suspend()\n"));
-       return 0;
-}
-
-static int rt2870_resume(struct usb_interface *intf)
-{
-       struct net_device *net_dev;
-       struct rt_rtmp_adapter *pAd = usb_get_intfdata(intf);
-
-       DBGPRINT(RT_DEBUG_TRACE, ("===> rt2870_resume()\n"));
-
-       pAd->PM_FlgSuspend = 0;
-       net_dev = pAd->net_dev;
-       netif_device_attach(net_dev);
-       netif_start_queue(net_dev);
-       netif_carrier_on(net_dev);
-       netif_wake_queue(net_dev);
-
-       DBGPRINT(RT_DEBUG_TRACE, ("<=== rt2870_resume()\n"));
-       return 0;
-}
-#endif /* CONFIG_PM // */
-
-/* Init driver module */
-int __init rtusb_init(void)
-{
-       printk(KERN_DEBUG "rtusb init --->\n");
-       return usb_register(&rtusb_driver);
-}
-
-/* Deinit driver module */
-void __exit rtusb_exit(void)
-{
-       usb_deregister(&rtusb_driver);
-       printk(KERN_DEBUG "<--- rtusb exit\n");
-}
-
-module_init(rtusb_init);
-module_exit(rtusb_exit);
-
-/*---------------------------------------------------------------------        */
-/* function declarations                                                                                               */
-/*---------------------------------------------------------------------        */
-
-/*
-========================================================================
-Routine Description:
-    MLME kernel thread.
-
-Arguments:
-       *Context                        the pAd, driver control block pointer
-
-Return Value:
-    0                                  close the thread
-
-Note:
-========================================================================
-*/
-int MlmeThread(IN void *Context)
-{
-       struct rt_rtmp_adapter *pAd;
-       struct rt_rtmp_os_task *pTask;
-       int status;
-       status = 0;
-
-       pTask = Context;
-       pAd = pTask->priv;
-
-       RtmpOSTaskCustomize(pTask);
-
-       while (!pTask->task_killed) {
-#ifdef KTHREAD_SUPPORT
-               RTMP_WAIT_EVENT_INTERRUPTIBLE(pAd, pTask);
-#else
-               RTMP_SEM_EVENT_WAIT(&(pTask->taskSema), status);
-
-               /* unlock the device pointers */
-               if (status != 0) {
-                       RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS);
-                       break;
-               }
-#endif
-
-               /* lock the device pointers , need to check if required */
-               /*down(&(pAd->usbdev_semaphore)); */
-
-               if (!pAd->PM_FlgSuspend)
-                       MlmeHandler(pAd);
-       }
-
-       /* notify the exit routine that we're actually exiting now
-        *
-        * complete()/wait_for_completion() is similar to up()/down(),
-        * except that complete() is safe in the case where the structure
-        * is getting deleted in a parallel mode of execution (i.e. just
-        * after the down() -- that's necessary for the thread-shutdown
-        * case.
-        *
-        * complete_and_exit() goes even further than this -- it is safe in
-        * the case that the thread of the caller is going away (not just
-        * the structure) -- this is necessary for the module-remove case.
-        * This is important in preemption kernels, which transfer the flow
-        * of execution immediately upon a complete().
-        */
-       DBGPRINT(RT_DEBUG_TRACE, ("<---%s\n", __FUNCTION__));
-#ifndef KTHREAD_SUPPORT
-       pTask->taskPID = THREAD_PID_INIT_VALUE;
-       complete_and_exit(&pTask->taskComplete, 0);
-#endif
-       return 0;
-
-}
-
-/*
-========================================================================
-Routine Description:
-    USB command kernel thread.
-
-Arguments:
-       *Context                        the pAd, driver control block pointer
-
-Return Value:
-    0                                  close the thread
-
-Note:
-========================================================================
-*/
-int RTUSBCmdThread(IN void *Context)
-{
-       struct rt_rtmp_adapter *pAd;
-       struct rt_rtmp_os_task *pTask;
-       int status;
-       status = 0;
-
-       pTask = Context;
-       pAd = pTask->priv;
-
-       RtmpOSTaskCustomize(pTask);
-
-       NdisAcquireSpinLock(&pAd->CmdQLock);
-       pAd->CmdQ.CmdQState = RTMP_TASK_STAT_RUNNING;
-       NdisReleaseSpinLock(&pAd->CmdQLock);
-
-       while (pAd && pAd->CmdQ.CmdQState == RTMP_TASK_STAT_RUNNING) {
-#ifdef KTHREAD_SUPPORT
-               RTMP_WAIT_EVENT_INTERRUPTIBLE(pAd, pTask);
-#else
-               /* lock the device pointers */
-               RTMP_SEM_EVENT_WAIT(&(pTask->taskSema), status);
-
-               if (status != 0) {
-                       RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS);
-                       break;
-               }
-#endif
-
-               if (pAd->CmdQ.CmdQState == RTMP_TASK_STAT_STOPED)
-                       break;
-
-               if (!pAd->PM_FlgSuspend)
-                       CMDHandler(pAd);
-       }
-
-       if (pAd && !pAd->PM_FlgSuspend) {       /* Clear the CmdQElements. */
-               struct rt_cmdqelmt *pCmdQElmt = NULL;
-
-               NdisAcquireSpinLock(&pAd->CmdQLock);
-               pAd->CmdQ.CmdQState = RTMP_TASK_STAT_STOPED;
-               while (pAd->CmdQ.size) {
-                       RTUSBDequeueCmd(&pAd->CmdQ, &pCmdQElmt);
-                       if (pCmdQElmt) {
-                               if (pCmdQElmt->CmdFromNdis == TRUE) {
-                                       if (pCmdQElmt->buffer != NULL)
-                                               os_free_mem(pAd,
-                                                           pCmdQElmt->buffer);
-                                       os_free_mem(pAd, (u8 *)pCmdQElmt);
-                               } else {
-                                       if ((pCmdQElmt->buffer != NULL)
-                                           && (pCmdQElmt->bufferlength != 0))
-                                               os_free_mem(pAd,
-                                                           pCmdQElmt->buffer);
-                                       os_free_mem(pAd, (u8 *)pCmdQElmt);
-                               }
-                       }
-               }
-
-               NdisReleaseSpinLock(&pAd->CmdQLock);
-       }
-       /* notify the exit routine that we're actually exiting now
-        *
-        * complete()/wait_for_completion() is similar to up()/down(),
-        * except that complete() is safe in the case where the structure
-        * is getting deleted in a parallel mode of execution (i.e. just
-        * after the down() -- that's necessary for the thread-shutdown
-        * case.
-        *
-        * complete_and_exit() goes even further than this -- it is safe in
-        * the case that the thread of the caller is going away (not just
-        * the structure) -- this is necessary for the module-remove case.
-        * This is important in preemption kernels, which transfer the flow
-        * of execution immediately upon a complete().
-        */
-       DBGPRINT(RT_DEBUG_TRACE, ("<---RTUSBCmdThread\n"));
-
-#ifndef KTHREAD_SUPPORT
-       pTask->taskPID = THREAD_PID_INIT_VALUE;
-       complete_and_exit(&pTask->taskComplete, 0);
-#endif
-       return 0;
-
-}
-
-void RTUSBWatchDog(struct rt_rtmp_adapter *pAd)
-{
-       struct rt_ht_tx_context *pHTTXContext;
-       int idx;
-       unsigned long irqFlags;
-       PURB pUrb;
-       BOOLEAN needDumpSeq = FALSE;
-       u32 MACValue;
-       u32 TxRxQ_Pcnt;
-
-       idx = 0;
-       RTMP_IO_READ32(pAd, TXRXQ_PCNT, &MACValue);
-       if ((MACValue & 0xff) != 0) {
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("TX QUEUE 0 Not EMPTY(Value=0x%0x)!\n",
-                         MACValue));
-               RTMP_IO_WRITE32(pAd, PBF_CFG, 0xf40012);
-               while ((MACValue & 0xff) != 0 && (idx++ < 10)) {
-                       RTMP_IO_READ32(pAd, TXRXQ_PCNT, &MACValue);
-                       RTMPusecDelay(1);
-               }
-               RTMP_IO_WRITE32(pAd, PBF_CFG, 0xf40006);
-       }
-
-       if (pAd->watchDogRxOverFlowCnt >= 2) {
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("Maybe the Rx Bulk-In hanged! Cancel the pending Rx bulks request!\n"));
-               if ((!RTMP_TEST_FLAG
-                    (pAd,
-                     (fRTMP_ADAPTER_RESET_IN_PROGRESS |
-                      fRTMP_ADAPTER_BULKIN_RESET |
-                      fRTMP_ADAPTER_HALT_IN_PROGRESS |
-                      fRTMP_ADAPTER_NIC_NOT_EXIST)))) {
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("Call CMDTHREAD_RESET_BULK_IN to cancel the pending Rx Bulk!\n"));
-                       RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_BULKIN_RESET);
-                       RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_RESET_BULK_IN,
-                                               NULL, 0);
-                       needDumpSeq = TRUE;
-               }
-               pAd->watchDogRxOverFlowCnt = 0;
-       }
-
-       RTUSBReadMACRegister(pAd, 0x438, &TxRxQ_Pcnt);
-
-       for (idx = 0; idx < NUM_OF_TX_RING; idx++) {
-               pUrb = NULL;
-
-               RTMP_IRQ_LOCK(&pAd->BulkOutLock[idx], irqFlags);
-               if ((pAd->BulkOutPending[idx] == TRUE)
-                   && pAd->watchDogTxPendingCnt) {
-                       int actual_length = 0, transfer_buffer_length = 0;
-                       BOOLEAN isDataPacket = FALSE;
-                       pAd->watchDogTxPendingCnt[idx]++;
-
-                       if ((pAd->watchDogTxPendingCnt[idx] > 2) &&
-                           (!RTMP_TEST_FLAG
-                            (pAd,
-                             (fRTMP_ADAPTER_RESET_IN_PROGRESS |
-                              fRTMP_ADAPTER_HALT_IN_PROGRESS |
-                              fRTMP_ADAPTER_NIC_NOT_EXIST |
-                              fRTMP_ADAPTER_BULKOUT_RESET)))
-                           ) {
-                               /* FIXME: Following code just support single bulk out. If you wanna support multiple bulk out. Modify it! */
-                               pHTTXContext =
-                                   (struct rt_ht_tx_context *)(&pAd->TxContext[idx]);
-                               if (pHTTXContext->IRPPending) { /* Check TxContext. */
-                                       pUrb = pHTTXContext->pUrb;
-
-                                       actual_length = pUrb->actual_length;
-                                       transfer_buffer_length =
-                                           pUrb->transfer_buffer_length;
-                                       isDataPacket = TRUE;
-                               } else if (idx == MGMTPIPEIDX) {
-                                       struct rt_tx_context *pMLMEContext, *pNULLContext,
-                                           *pPsPollContext;
-
-                                       /*Check MgmtContext. */
-                                       pMLMEContext =
-                                           (struct rt_tx_context *)(pAd->MgmtRing.
-                                                          Cell[pAd->MgmtRing.
-                                                               TxDmaIdx].
-                                                          AllocVa);
-                                       pPsPollContext =
-                                           (struct rt_tx_context *)(&pAd->PsPollContext);
-                                       pNULLContext =
-                                           (struct rt_tx_context *)(&pAd->NullContext);
-
-                                       if (pMLMEContext->IRPPending) {
-                                               ASSERT(pMLMEContext->
-                                                      IRPPending);
-                                               pUrb = pMLMEContext->pUrb;
-                                       } else if (pNULLContext->IRPPending) {
-                                               ASSERT(pNULLContext->
-                                                      IRPPending);
-                                               pUrb = pNULLContext->pUrb;
-                                       } else if (pPsPollContext->IRPPending) {
-                                               ASSERT(pPsPollContext->
-                                                      IRPPending);
-                                               pUrb = pPsPollContext->pUrb;
-                                       }
-                               }
-
-                               RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[idx],
-                                               irqFlags);
-
-                               printk(KERN_INFO "%d:%lu LTL=%d , TL=%d L:%d\n",
-                                      idx, pAd->watchDogTxPendingCnt[idx],
-                                      pAd->TransferedLength[idx],
-                                      actual_length, transfer_buffer_length);
-
-                               if (pUrb) {
-                                       if ((isDataPacket
-                                            && pAd->TransferedLength[idx] ==
-                                            actual_length
-                                            && pAd->TransferedLength[idx] <
-                                            transfer_buffer_length
-                                            && actual_length != 0
-/*                                      && TxRxQ_Pcnt==0 */
-                                            && pAd->watchDogTxPendingCnt[idx] >
-                                            3)
-                                           || isDataPacket == FALSE
-                                           || pAd->watchDogTxPendingCnt[idx] >
-                                           6) {
-                                               DBGPRINT(RT_DEBUG_TRACE,
-                                                        ("Maybe the Tx Bulk-Out hanged! Cancel the pending Tx bulks request of idx(%d)!\n",
-                                                         idx));
-                                               DBGPRINT(RT_DEBUG_TRACE,
-                                                        ("Unlink the pending URB!\n"));
-                                               /* unlink it now */
-                                               RTUSB_UNLINK_URB(pUrb);
-                                               /* Sleep 200 microseconds to give cancellation time to work */
-                                               /*RTMPusecDelay(200); */
-                                               needDumpSeq = TRUE;
-                                       }
-                               } else {
-                                       DBGPRINT(RT_DEBUG_ERROR,
-                                                ("Unknown bulkOut URB maybe hanged!\n"));
-                               }
-                       } else {
-                               RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[idx],
-                                               irqFlags);
-                       }
-
-                       if (isDataPacket == TRUE)
-                               pAd->TransferedLength[idx] = actual_length;
-               } else {
-                       RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[idx], irqFlags);
-               }
-       }
-
-       /* For Sigma debug, dump the ba_reordering sequence. */
-       if ((needDumpSeq == TRUE) && (pAd->CommonCfg.bDisableReordering == 0)) {
-               u16 Idx;
-               struct rt_ba_rec_entry *pBAEntry = NULL;
-               u8 count = 0;
-               struct reordering_mpdu *mpdu_blk;
-
-               Idx = pAd->MacTab.Content[BSSID_WCID].BARecWcidArray[0];
-
-               pBAEntry = &pAd->BATable.BARecEntry[Idx];
-               if ((pBAEntry->list.qlen > 0) && (pBAEntry->list.next != NULL)) {
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("NICUpdateRawCounters():The Queueing pkt in reordering buffer:\n"));
-                       NdisAcquireSpinLock(&pBAEntry->RxReRingLock);
-                       mpdu_blk = pBAEntry->list.next;
-                       while (mpdu_blk) {
-                               DBGPRINT(RT_DEBUG_TRACE,
-                                        ("\t%d:Seq-%d, bAMSDU-%d!\n", count,
-                                         mpdu_blk->Sequence,
-                                         mpdu_blk->bAMSDU));
-                               mpdu_blk = mpdu_blk->next;
-                               count++;
-                       }
-
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("\npBAEntry->LastIndSeq=%d!\n",
-                                 pBAEntry->LastIndSeq));
-                       NdisReleaseSpinLock(&pBAEntry->RxReRingLock);
-               }
-       }
-}
-
-/*
-========================================================================
-Routine Description:
-    Release allocated resources.
-
-Arguments:
-    *dev                               Point to the PCI or USB device
-       pAd                                     driver control block pointer
-
-Return Value:
-    None
-
-Note:
-========================================================================
-*/
-static void rt2870_disconnect(struct usb_device *dev, struct rt_rtmp_adapter *pAd)
-{
-       DBGPRINT(RT_DEBUG_ERROR,
-                ("rtusb_disconnect: unregister usbnet usb-%s-%s\n",
-                 dev->bus->bus_name, dev->devpath));
-       if (!pAd) {
-               usb_put_dev(dev);
-               printk(KERN_ERR "rtusb_disconnect: pAd == NULL!\n");
-               return;
-       }
-       RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST);
-
-       /* for debug, wait to show some messages to /proc system */
-       udelay(1);
-
-       RtmpPhyNetDevExit(pAd, pAd->net_dev);
-
-       /* FIXME: Shall we need following delay and flush the schedule?? */
-       udelay(1);
-       flush_scheduled_work();
-       udelay(1);
-
-       /* free the root net_device */
-       RtmpOSNetDevFree(pAd->net_dev);
-
-       RtmpRaDevCtrlExit(pAd);
-
-       /* release a use of the usb device structure */
-       usb_put_dev(dev);
-       udelay(1);
-
-       DBGPRINT(RT_DEBUG_ERROR, (" RTUSB disconnect successfully\n"));
-}
-
-static int __devinit rt2870_probe(IN struct usb_interface *intf,
-                                 IN struct usb_device *usb_dev,
-                                 IN const struct usb_device_id *dev_id,
-                                 struct rt_rtmp_adapter **ppAd)
-{
-       struct net_device *net_dev = NULL;
-       struct rt_rtmp_adapter *pAd = (struct rt_rtmp_adapter *)NULL;
-       int status, rv;
-       void *handle;
-       struct rt_rtmp_os_netdev_op_hook netDevHook;
-
-       DBGPRINT(RT_DEBUG_TRACE, ("===>rt2870_probe()!\n"));
-
-       /* Check chipset vendor/product ID */
-       /*if (RT28XXChipsetCheck(_dev_p) == FALSE) */
-       /*      goto err_out; */
-
-/*RtmpDevInit============================================= */
-       /* Allocate struct rt_rtmp_adapter adapter structure */
-       handle = kmalloc(sizeof(struct os_cookie), GFP_KERNEL);
-       if (handle == NULL) {
-               printk
-                   ("rt2870_probe(): Allocate memory for os handle failed!\n");
-               return -ENOMEM;
-       }
-       ((struct os_cookie *)handle)->pUsb_Dev = usb_dev;
-
-       rv = RTMPAllocAdapterBlock(handle, &pAd);
-       if (rv != NDIS_STATUS_SUCCESS) {
-               kfree(handle);
-               goto err_out;
-       }
-/*USBDevInit============================================== */
-       if (USBDevConfigInit(usb_dev, intf, pAd) == FALSE)
-               goto err_out_free_radev;
-
-       RtmpRaDevCtrlInit(pAd, RTMP_DEV_INF_USB);
-
-/*NetDevInit============================================== */
-       net_dev = RtmpPhyNetDevInit(pAd, &netDevHook);
-       if (net_dev == NULL)
-               goto err_out_free_radev;
-
-       /* Here are the net_device structure with usb specific parameters. 
-        * for supporting Network Manager.
-        * Set the sysfs physical device reference for the network logical device if set prior to registration will
-        * cause a symlink during initialization.
-        */
-       SET_NETDEV_DEV(net_dev, &(usb_dev->dev));
-
-       pAd->StaCfg.OriDevType = net_dev->type;
-
-/*All done, it's time to register the net device to linux kernel. */
-       /* Register this device */
-       status = RtmpOSNetDevAttach(net_dev, &netDevHook);
-       if (status != 0)
-               goto err_out_free_netdev;
-
-#ifdef KTHREAD_SUPPORT
-       init_waitqueue_head(&pAd->mlmeTask.kthread_q);
-       init_waitqueue_head(&pAd->timerTask.kthread_q);
-       init_waitqueue_head(&pAd->cmdQTask.kthread_q);
-#endif
-
-       *ppAd = pAd;
-
-       DBGPRINT(RT_DEBUG_TRACE, ("<===rt2870_probe()!\n"));
-
-       return 0;
-
-       /* --------------------------- ERROR HANDLE --------------------------- */
-err_out_free_netdev:
-       RtmpOSNetDevFree(net_dev);
-
-err_out_free_radev:
-       RTMPFreeAdapter(pAd);
-
-err_out:
-       *ppAd = NULL;
-
-       return -1;
-
-}
diff --git a/drivers/staging/rt2860/wpa.h b/drivers/staging/rt2860/wpa.h
deleted file mode 100644 (file)
index a7796d3..0000000
+++ /dev/null
@@ -1,390 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-       Module Name:
-       wpa.h
-
-       Abstract:
-
-       Revision History:
-       Who                     When                    What
-       --------        ----------              ----------------------------------------------
-       Name                    Date                    Modification logs
-       Justin P. Mattock       11/07/2010              Fix a typo
-*/
-
-#ifndef        __WPA_H__
-#define        __WPA_H__
-
-/* EAPOL Key descriptor frame format related length */
-#define LEN_KEY_DESC_NONCE                     32
-#define LEN_KEY_DESC_IV                                16
-#define LEN_KEY_DESC_RSC                       8
-#define LEN_KEY_DESC_ID                                8
-#define LEN_KEY_DESC_REPLAY                    8
-#define LEN_KEY_DESC_MIC                       16
-
-/* The length is the EAPoL-Key frame except key data field. */
-/* Please refer to 802.11i-2004 ,Figure 43u in p.78 */
-#define LEN_EAPOL_KEY_MSG                      (sizeof(struct rt_key_descripter) - MAX_LEN_OF_RSNIE)
-
-/* EAP Code Type. */
-#define EAP_CODE_REQUEST       1
-#define EAP_CODE_RESPONSE      2
-#define EAP_CODE_SUCCESS    3
-#define EAP_CODE_FAILURE    4
-
-/* EAPOL frame Protocol Version */
-#define        EAPOL_VER                                       1
-#define        EAPOL_VER2                                      2
-
-/* EAPOL-KEY Descriptor Type */
-#define        WPA1_KEY_DESC                           0xfe
-#define WPA2_KEY_DESC               0x02
-
-/* Key Descriptor Version of Key Information */
-#define        DESC_TYPE_TKIP                          1
-#define        DESC_TYPE_AES                           2
-
-#define LEN_MSG1_2WAY               0x7f
-#define MAX_LEN_OF_EAP_HS           256
-
-#define LEN_MASTER_KEY                         32
-
-/* EAPOL EK, MK */
-#define LEN_EAP_EK                                     16
-#define LEN_EAP_MICK                           16
-#define LEN_EAP_KEY                                    ((LEN_EAP_EK)+(LEN_EAP_MICK))
-/* TKIP key related */
-#define LEN_PMKID                                      16
-#define LEN_TKIP_EK                                    16
-#define LEN_TKIP_RXMICK                                8
-#define LEN_TKIP_TXMICK                                8
-#define LEN_AES_EK                                     16
-#define LEN_AES_KEY                                    LEN_AES_EK
-#define LEN_TKIP_KEY                           ((LEN_TKIP_EK)+(LEN_TKIP_RXMICK)+(LEN_TKIP_TXMICK))
-#define TKIP_AP_TXMICK_OFFSET          ((LEN_EAP_KEY)+(LEN_TKIP_EK))
-#define TKIP_AP_RXMICK_OFFSET          (TKIP_AP_TXMICK_OFFSET+LEN_TKIP_TXMICK)
-#define TKIP_GTK_LENGTH                                ((LEN_TKIP_EK)+(LEN_TKIP_RXMICK)+(LEN_TKIP_TXMICK))
-#define LEN_PTK                                                ((LEN_EAP_KEY)+(LEN_TKIP_KEY))
-#define MIN_LEN_OF_GTK                         5
-#define LEN_PMK                                                32
-#define LEN_PMK_NAME                           16
-#define LEN_NONCE                                      32
-
-/* RSN IE Length definition */
-#define MAX_LEN_OF_RSNIE               255
-#define MIN_LEN_OF_RSNIE               8
-
-#define KEY_LIFETIME                           3600
-
-/*EAP Packet Type */
-#define        EAPPacket               0
-#define        EAPOLStart              1
-#define        EAPOLLogoff             2
-#define        EAPOLKey                3
-#define        EAPOLASFAlert   4
-#define        EAPTtypeMax             5
-
-#define        EAPOL_MSG_INVALID       0
-#define        EAPOL_PAIR_MSG_1        1
-#define        EAPOL_PAIR_MSG_2        2
-#define        EAPOL_PAIR_MSG_3        3
-#define        EAPOL_PAIR_MSG_4        4
-#define        EAPOL_GROUP_MSG_1       5
-#define        EAPOL_GROUP_MSG_2       6
-
-#define PAIRWISEKEY                                    1
-#define GROUPKEY                                       0
-
-/* Retry timer counter initial value */
-#define PEER_MSG1_RETRY_TIMER_CTR           0
-#define PEER_MSG3_RETRY_TIMER_CTR           10
-#define GROUP_MSG1_RETRY_TIMER_CTR          20
-
-/*#ifdef CONFIG_AP_SUPPORT */
-/* WPA mechanism retry timer interval */
-#define PEER_MSG1_RETRY_EXEC_INTV           1000       /* 1 sec */
-#define PEER_MSG3_RETRY_EXEC_INTV           3000       /* 3 sec */
-#define GROUP_KEY_UPDATE_EXEC_INTV          1000       /* 1 sec */
-#define PEER_GROUP_KEY_UPDATE_INIV                     2000    /* 2 sec */
-
-#define ENQUEUE_EAPOL_START_TIMER                      200     /* 200 ms */
-
-/* group rekey interval */
-#define TIME_REKEY                          0
-#define PKT_REKEY                           1
-#define DISABLE_REKEY                       2
-#define MAX_REKEY                           2
-
-#define MAX_REKEY_INTER                     0x3ffffff
-/*#endif // CONFIG_AP_SUPPORT // */
-
-#define GROUP_SUITE                                    0
-#define PAIRWISE_SUITE                         1
-#define AKM_SUITE                                      2
-#define PMKID_LIST                                     3
-
-#define EAPOL_START_DISABLE                                    0
-#define EAPOL_START_PSK                                                1
-#define EAPOL_START_1X                                         2
-
-#define MIX_CIPHER_WPA_TKIP_ON(x)       (((x) & 0x08) != 0)
-#define MIX_CIPHER_WPA_AES_ON(x)        (((x) & 0x04) != 0)
-#define MIX_CIPHER_WPA2_TKIP_ON(x)      (((x) & 0x02) != 0)
-#define MIX_CIPHER_WPA2_AES_ON(x)       (((x) & 0x01) != 0)
-
-#ifndef ROUND_UP
-#define ROUND_UP(__x, __y) \
-       (((unsigned long)((__x)+((__y)-1))) & ((unsigned long)~((__y)-1)))
-#endif
-
-#define        SET_u16_TO_ARRARY(_V, _LEN)             \
-{                                                                                      \
-       _V[0] = (_LEN & 0xFF00) >> 8;                   \
-       _V[1] = (_LEN & 0xFF);                                  \
-}
-
-#define        INC_u16_TO_ARRARY(_V, _LEN)                     \
-{                                                                                              \
-       u16     var_len;                                                        \
-                                                                                               \
-       var_len = (_V[0]<<8) | (_V[1]);                         \
-       var_len += _LEN;                                                        \
-                                                                                               \
-       _V[0] = (var_len & 0xFF00) >> 8;                        \
-       _V[1] = (var_len & 0xFF);                                       \
-}
-
-#define        CONV_ARRARY_TO_u16(_V)  ((_V[0]<<8) | (_V[1]))
-
-#define        ADD_ONE_To_64BIT_VAR(_V)                \
-{                                                                              \
-       u8      cnt = LEN_KEY_DESC_REPLAY;      \
-       do                                                                      \
-       {                                                                       \
-               cnt--;                                                  \
-               _V[cnt]++;                                              \
-               if (cnt == 0)                                   \
-                       break;                                          \
-       }while (_V[cnt] == 0);                          \
-}
-
-#define IS_WPA_CAPABILITY(a)       (((a) >= Ndis802_11AuthModeWPA) && ((a) <= Ndis802_11AuthModeWPA1PSKWPA2PSK))
-
-/* EAPOL Key Information definition within Key descriptor format */
-struct PACKED rt_key_info {
-       u8 KeyMic:1;
-       u8 Secure:1;
-       u8 Error:1;
-       u8 Request:1;
-       u8 EKD_DL:1;            /* EKD for AP; DL for STA */
-       u8 Rsvd:3;
-       u8 KeyDescVer:3;
-       u8 KeyType:1;
-       u8 KeyIndex:2;
-       u8 Install:1;
-       u8 KeyAck:1;
-};
-
-/* EAPOL Key descriptor format */
-struct PACKED rt_key_descripter {
-       u8 Type;
-       struct rt_key_info KeyInfo;
-       u8 KeyLength[2];
-       u8 ReplayCounter[LEN_KEY_DESC_REPLAY];
-       u8 KeyNonce[LEN_KEY_DESC_NONCE];
-       u8 KeyIv[LEN_KEY_DESC_IV];
-       u8 KeyRsc[LEN_KEY_DESC_RSC];
-       u8 KeyId[LEN_KEY_DESC_ID];
-       u8 KeyMic[LEN_KEY_DESC_MIC];
-       u8 KeyDataLen[2];
-       u8 KeyData[MAX_LEN_OF_RSNIE];
-};
-
-struct PACKED rt_eapol_packet {
-       u8 ProVer;
-       u8 ProType;
-       u8 Body_Len[2];
-       struct rt_key_descripter KeyDesc;
-};
-
-/*802.11i D10 page 83 */
-struct PACKED rt_gtk_encap {
-       u8 Kid:2;
-       u8 tx:1;
-       u8 rsv:5;
-       u8 rsv1;
-       u8 GTK[TKIP_GTK_LENGTH];
-};
-
-struct PACKED rt_kde_encap {
-       u8 Type;
-       u8 Len;
-       u8 OUI[3];
-       u8 DataType;
-       struct rt_gtk_encap GTKEncap;
-};
-
-/* For WPA1 */
-struct PACKED rt_rsnie {
-       u8 oui[4];
-       u16 version;
-       u8 mcast[4];
-       u16 ucount;
-       struct PACKED {
-               u8 oui[4];
-       } ucast[1];
-};
-
-/* For WPA2 */
-struct PACKED rt_rsnie2 {
-       u16 version;
-       u8 mcast[4];
-       u16 ucount;
-       struct PACKED {
-               u8 oui[4];
-       } ucast[1];
-};
-
-/* AKM Suite */
-struct PACKED rt_rsnie_auth {
-       u16 acount;
-       struct PACKED {
-               u8 oui[4];
-       } auth[1];
-};
-
-typedef union PACKED _RSN_CAPABILITIES {
-       struct PACKED {
-               u16 PreAuth:1;
-               u16 No_Pairwise:1;
-               u16 PTKSA_R_Counter:2;
-               u16 GTKSA_R_Counter:2;
-               u16 Rsvd:10;
-       } field;
-       u16 word;
-} RSN_CAPABILITIES, *PRSN_CAPABILITIES;
-
-struct PACKED rt_eap_hdr {
-       u8 ProVer;
-       u8 ProType;
-       u8 Body_Len[2];
-       u8 code;
-       u8 identifier;
-       u8 length[2];   /* including code and identifier, followed by length-2 octets of data */
-};
-
-/* For supplicant state machine states. 802.11i Draft 4.1, p. 97 */
-/* We simplified it */
-typedef enum _WpaState {
-       SS_NOTUSE,              /* 0 */
-       SS_START,               /* 1 */
-       SS_WAIT_MSG_3,          /* 2 */
-       SS_WAIT_GROUP,          /* 3 */
-       SS_FINISH,              /* 4 */
-       SS_KEYUPDATE,           /* 5 */
-} WPA_STATE;
-
-/* */
-/*      The definition of the cipher combination */
-/* */
-/*       bit3   bit2  bit1   bit0 */
-/*      +------------+------------+ */
-/*      |         WPA    |         WPA2   | */
-/*      +------+-----+------+-----+ */
-/*      | TKIP | AES | TKIP | AES | */
-/*      |       0  |  1  |   1  |  0  | -> 0x06 */
-/*      |       0  |  1  |   1  |  1  | -> 0x07 */
-/*      |       1  |  0  |   0  |  1  | -> 0x09 */
-/*      |       1  |  0  |   1  |  1  | -> 0x0B */
-/*      |       1  |  1  |   0  |  1  | -> 0x0D */
-/*      |       1  |  1  |   1  |  0  | -> 0x0E */
-/*      |       1  |  1  |   1  |  1  | -> 0x0F */
-/*      +------+-----+------+-----+ */
-/* */
-typedef enum _WpaMixPairCipher {
-       MIX_CIPHER_NOTUSE = 0x00,
-       WPA_NONE_WPA2_TKIPAES = 0x03,   /* WPA2-TKIPAES */
-       WPA_AES_WPA2_TKIP = 0x06,
-       WPA_AES_WPA2_TKIPAES = 0x07,
-       WPA_TKIP_WPA2_AES = 0x09,
-       WPA_TKIP_WPA2_TKIPAES = 0x0B,
-       WPA_TKIPAES_WPA2_NONE = 0x0C,   /* WPA-TKIPAES */
-       WPA_TKIPAES_WPA2_AES = 0x0D,
-       WPA_TKIPAES_WPA2_TKIP = 0x0E,
-       WPA_TKIPAES_WPA2_TKIPAES = 0x0F,
-} WPA_MIX_PAIR_CIPHER;
-
-struct PACKED rt_rsn_ie_header {
-       u8 Eid;
-       u8 Length;
-       u16 Version;            /* Little endian format */
-};
-
-/* Cipher suite selector types */
-struct PACKED rt_cipher_suite_struct {
-       u8 Oui[3];
-       u8 Type;
-};
-
-/* Authentication and Key Management suite selector */
-struct PACKED rt_akm_suite {
-       u8 Oui[3];
-       u8 Type;
-};
-
-/* RSN capability */
-struct PACKED rt_rsn_capability {
-       u16 Rsv:10;
-       u16 GTKSAReplayCnt:2;
-       u16 PTKSAReplayCnt:2;
-       u16 NoPairwise:1;
-       u16 PreAuth:1;
-};
-
-/*========================================
-       The prototype is defined in cmm_wpa.c
-  ========================================*/
-BOOLEAN WpaMsgTypeSubst(u8 EAPType, int *MsgType);
-
-void PRF(u8 *key, int key_len, u8 *prefix, int prefix_len,
-        u8 *data, int data_len, u8 *output, int len);
-
-int PasswordHash(char *password,
-                unsigned char *ssid, int ssidlength, unsigned char *output);
-
-u8 *GetSuiteFromRSNIE(u8 *rsnie, u32 rsnie_len, u8 type, u8 *count);
-
-void WpaShowAllsuite(u8 *rsnie, u32 rsnie_len);
-
-void RTMPInsertRSNIE(u8 *pFrameBuf,
-                    unsigned long *pFrameLen,
-                    u8 *rsnie_ptr,
-                    u8 rsnie_len,
-                    u8 *pmkid_ptr, u8 pmkid_len);
-
-#endif
diff --git a/drivers/staging/rt2870/Kconfig b/drivers/staging/rt2870/Kconfig
deleted file mode 100644 (file)
index e988680..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-config RT2870
-       tristate "Ralink 2870/3070 wireless support"
-       depends on USB && (X86 || ARM) && WLAN
-       select WIRELESS_EXT
-       select WEXT_PRIV
-       select CRC_CCITT
-       select FW_LOADER
-       ---help---
-         This is an experimental driver for the Ralink xx70 wireless chips.
diff --git a/drivers/staging/rt2870/Makefile b/drivers/staging/rt2870/Makefile
deleted file mode 100644 (file)
index b499910..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-#
-obj-$(CONFIG_RT2870)   += rt2870sta.o
-
-# TODO: all of these should be removed
-ccflags-y := -DLINUX -DAGGREGATION_SUPPORT -DPIGGYBACK_SUPPORT -DWMM_SUPPORT
-ccflags-y += -DRTMP_MAC_USB -DRTMP_USB_SUPPORT -DRT2870 -DRTMP_TIMER_TASK_SUPPORT
-ccflags-y += -DRTMP_RF_RW_SUPPORT -DRTMP_EFUSE_SUPPORT -DRT30xx -DRT3070
-ccflags-y += -DDBG
-
-rt2870sta-y :=         \
-       common/crypt_md5.o      \
-       common/crypt_sha2.o     \
-       common/crypt_hmac.o     \
-       common/mlme.o           \
-       common/cmm_wep.o        \
-       common/action.o         \
-       common/cmm_data.o       \
-       common/rtmp_init.o      \
-       common/cmm_tkip.o       \
-       common/cmm_aes.o        \
-       common/cmm_sync.o       \
-       common/eeprom.o         \
-       common/cmm_sanity.o     \
-       common/cmm_info.o       \
-       common/cmm_cfg.o        \
-       common/cmm_wpa.o        \
-       common/dfs.o            \
-       common/spectrum.o       \
-       common/rtmp_timer.o     \
-       common/rt_channel.o     \
-       common/cmm_asic.o       \
-       sta/assoc.o             \
-       sta/auth.o              \
-       sta/auth_rsp.o          \
-       sta/sync.o              \
-       sta/sanity.o            \
-       sta/rtmp_data.o         \
-       sta/connect.o           \
-       sta/wpa.o               \
-       rt_linux.o              \
-       rt_main_dev.o           \
-       sta_ioctl.o             \
-       common/ba_action.o      \
-       usb_main_dev.o          \
-       rt_usb.o                \
-       common/cmm_mac_usb.o    \
-       common/rtusb_io.o       \
-       common/rtusb_bulk.o     \
-       common/rtusb_data.o     \
-       common/cmm_data_usb.o   \
-       common/rtmp_mcu.o       \
-       common/ee_efuse.o       \
-       chips/rt30xx.o          \
-       common/rt_rf.o          \
-       chips/rt3070.o
diff --git a/drivers/staging/rt2870/TODO b/drivers/staging/rt2870/TODO
deleted file mode 100644 (file)
index 2df1bfe..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-I'm hesitant to add a TODO file here, as the wireless developers would
-really have people help them out on the "clean" rt2870 driver that can
-be found at the http://rt2x00.serialmonkey.com/ site.
-
-But, if you wish to clean up this driver instead, here's a short list of
-things that need to be done to get it into a more mergable shape:
-
-TODO:
-       - checkpatch.pl clean
-       - sparse clean
-       - port to in-kernel 80211 stack and common rt2x00 infrastructure
-       - remove reading from /etc/ config files
-       - review by the wireless developer community
-
-Please send any patches or complaints about this driver to Greg
-Kroah-Hartman <greg@kroah.com> and don't bother the upstream wireless
-kernel developers about it, they want nothing to do with it.
diff --git a/drivers/staging/rt2870/aironet.h b/drivers/staging/rt2870/aironet.h
deleted file mode 100644 (file)
index ae62597..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../rt2860/aironet.h"
diff --git a/drivers/staging/rt2870/ap.h b/drivers/staging/rt2870/ap.h
deleted file mode 100644 (file)
index fe04b5f..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../rt2860/ap.h"
diff --git a/drivers/staging/rt2870/chips/rt3070.c b/drivers/staging/rt2870/chips/rt3070.c
deleted file mode 100644 (file)
index 3a6db5e..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../rt2860/chips/rt3070.c"
diff --git a/drivers/staging/rt2870/chips/rt30xx.c b/drivers/staging/rt2870/chips/rt30xx.c
deleted file mode 100644 (file)
index 6c56b84..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../rt2860/chips/rt30xx.c"
diff --git a/drivers/staging/rt2870/chlist.h b/drivers/staging/rt2870/chlist.h
deleted file mode 100644 (file)
index 3199958..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../rt2860/chlist.h"
diff --git a/drivers/staging/rt2870/common/acction.c b/drivers/staging/rt2870/common/acction.c
deleted file mode 100644 (file)
index fd806c3..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../rt2860/common/action.c"
diff --git a/drivers/staging/rt2870/common/action.c b/drivers/staging/rt2870/common/action.c
deleted file mode 100644 (file)
index fd806c3..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../rt2860/common/action.c"
diff --git a/drivers/staging/rt2870/common/action.h b/drivers/staging/rt2870/common/action.h
deleted file mode 100644 (file)
index 9a18955..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../rt2860/common/action.h"
diff --git a/drivers/staging/rt2870/common/ba_action.c b/drivers/staging/rt2870/common/ba_action.c
deleted file mode 100644 (file)
index a9e6a09..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../rt2860/common/ba_action.c"
diff --git a/drivers/staging/rt2870/common/cmm_aes.c b/drivers/staging/rt2870/common/cmm_aes.c
deleted file mode 100644 (file)
index 15d6a14..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../rt2860/common/cmm_aes.c"
diff --git a/drivers/staging/rt2870/common/cmm_asic.c b/drivers/staging/rt2870/common/cmm_asic.c
deleted file mode 100644 (file)
index 38de817..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../rt2860/common/cmm_asic.c"
diff --git a/drivers/staging/rt2870/common/cmm_cfg.c b/drivers/staging/rt2870/common/cmm_cfg.c
deleted file mode 100644 (file)
index 6b2bdd7..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../rt2860/common/cmm_cfg.c"
diff --git a/drivers/staging/rt2870/common/cmm_data.c b/drivers/staging/rt2870/common/cmm_data.c
deleted file mode 100644 (file)
index df775c3..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../rt2860/common/cmm_data.c"
diff --git a/drivers/staging/rt2870/common/cmm_data_usb.c b/drivers/staging/rt2870/common/cmm_data_usb.c
deleted file mode 100644 (file)
index 704675f..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../rt2860/common/cmm_data_usb.c"
diff --git a/drivers/staging/rt2870/common/cmm_info.c b/drivers/staging/rt2870/common/cmm_info.c
deleted file mode 100644 (file)
index 226187e..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../rt2860/common/cmm_info.c"
diff --git a/drivers/staging/rt2870/common/cmm_mac_usb.c b/drivers/staging/rt2870/common/cmm_mac_usb.c
deleted file mode 100644 (file)
index b26af4a..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../rt2860/common/cmm_mac_usb.c"
diff --git a/drivers/staging/rt2870/common/cmm_profile.c b/drivers/staging/rt2870/common/cmm_profile.c
deleted file mode 100644 (file)
index 9926e45..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../rt2860/common/cmm_profile.c"
diff --git a/drivers/staging/rt2870/common/cmm_sanity.c b/drivers/staging/rt2870/common/cmm_sanity.c
deleted file mode 100644 (file)
index cb33521..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../rt2860/common/cmm_sanity.c"
diff --git a/drivers/staging/rt2870/common/cmm_sync.c b/drivers/staging/rt2870/common/cmm_sync.c
deleted file mode 100644 (file)
index 5e7221d..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../rt2860/common/cmm_sync.c"
diff --git a/drivers/staging/rt2870/common/cmm_tkip.c b/drivers/staging/rt2870/common/cmm_tkip.c
deleted file mode 100644 (file)
index f73c71b..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../rt2860/common/cmm_tkip.c"
diff --git a/drivers/staging/rt2870/common/cmm_wep.c b/drivers/staging/rt2870/common/cmm_wep.c
deleted file mode 100644 (file)
index 5f68107..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../rt2860/common/cmm_wep.c"
diff --git a/drivers/staging/rt2870/common/cmm_wpa.c b/drivers/staging/rt2870/common/cmm_wpa.c
deleted file mode 100644 (file)
index 04a54bb..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../rt2860/common/cmm_wpa.c"
diff --git a/drivers/staging/rt2870/common/crypt_hmac.c b/drivers/staging/rt2870/common/crypt_hmac.c
deleted file mode 100644 (file)
index 24d84e7..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../rt2860/common/crypt_hmac.c"
diff --git a/drivers/staging/rt2870/common/crypt_md5.c b/drivers/staging/rt2870/common/crypt_md5.c
deleted file mode 100644 (file)
index 457a2ca..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../rt2860/common/crypt_md5.c"
diff --git a/drivers/staging/rt2870/common/crypt_sha2.c b/drivers/staging/rt2870/common/crypt_sha2.c
deleted file mode 100644 (file)
index 07ffb30..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../rt2860/common/crypt_sha2.c"
diff --git a/drivers/staging/rt2870/common/dfs.c b/drivers/staging/rt2870/common/dfs.c
deleted file mode 100644 (file)
index ac2da4c..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../rt2860/common/dfs.c"
diff --git a/drivers/staging/rt2870/common/ee_efuse.c b/drivers/staging/rt2870/common/ee_efuse.c
deleted file mode 100644 (file)
index 0e34e65..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../rt2860/common/ee_efuse.c"
diff --git a/drivers/staging/rt2870/common/eeprom.c b/drivers/staging/rt2870/common/eeprom.c
deleted file mode 100644 (file)
index def0965..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../rt2860/common/eeprom.c"
diff --git a/drivers/staging/rt2870/common/md5.c b/drivers/staging/rt2870/common/md5.c
deleted file mode 100644 (file)
index 195645c..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../rt2860/common/md5.c"
diff --git a/drivers/staging/rt2870/common/mlme.c b/drivers/staging/rt2870/common/mlme.c
deleted file mode 100644 (file)
index f88040a..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../rt2860/common/mlme.c"
diff --git a/drivers/staging/rt2870/common/rt_channel.c b/drivers/staging/rt2870/common/rt_channel.c
deleted file mode 100644 (file)
index c8ceb4c..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../rt2860/common/rt_channel.c"
diff --git a/drivers/staging/rt2870/common/rt_rf.c b/drivers/staging/rt2870/common/rt_rf.c
deleted file mode 100644 (file)
index b81cff3..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../rt2860/common/rt_rf.c"
diff --git a/drivers/staging/rt2870/common/rtmp_init.c b/drivers/staging/rt2870/common/rtmp_init.c
deleted file mode 100644 (file)
index eef10ef..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../rt2860/common/rtmp_init.c"
diff --git a/drivers/staging/rt2870/common/rtmp_mcu.c b/drivers/staging/rt2870/common/rtmp_mcu.c
deleted file mode 100644 (file)
index 20b7f13..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../rt2860/common/rtmp_mcu.c"
diff --git a/drivers/staging/rt2870/common/rtmp_timer.c b/drivers/staging/rt2870/common/rtmp_timer.c
deleted file mode 100644 (file)
index fd4aedc..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../rt2860/common/rtmp_timer.c"
diff --git a/drivers/staging/rt2870/common/rtmp_tkip.c b/drivers/staging/rt2870/common/rtmp_tkip.c
deleted file mode 100644 (file)
index 240bf67..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../rt2860/common/rtmp_tkip.c"
diff --git a/drivers/staging/rt2870/common/rtmp_wep.c b/drivers/staging/rt2870/common/rtmp_wep.c
deleted file mode 100644 (file)
index ae255ad..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../rt2860/common/rtmp_wep.c"
diff --git a/drivers/staging/rt2870/common/rtusb_bulk.c b/drivers/staging/rt2870/common/rtusb_bulk.c
deleted file mode 100644 (file)
index 679b802..0000000
+++ /dev/null
@@ -1,1232 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-       Module Name:
-       rtusb_bulk.c
-
-       Abstract:
-
-       Revision History:
-       Who                     When            What
-       --------        ----------      ----------------------------------------------
-       Name            Date            Modification logs
-       Paul Lin        06-25-2004      created
-
-*/
-
-#ifdef RTMP_MAC_USB
-
-#include "../rt_config.h"
-/* Match total 6 bulkout endpoint to corresponding queue. */
-u8 EpToQueue[6] =
-    { FIFO_EDCA, FIFO_EDCA, FIFO_EDCA, FIFO_EDCA, FIFO_EDCA, FIFO_MGMT };
-
-/*static BOOLEAN SingleBulkOut = FALSE; */
-
-void RTUSB_FILL_BULK_URB(struct urb *pUrb,
-                        struct usb_device *pUsb_Dev,
-                        unsigned int bulkpipe,
-                        void *pTransferBuf,
-                        int BufSize, usb_complete_t Complete, void *pContext)
-{
-
-       usb_fill_bulk_urb(pUrb, pUsb_Dev, bulkpipe, pTransferBuf, BufSize,
-                         (usb_complete_t) Complete, pContext);
-
-}
-
-void RTUSBInitTxDesc(struct rt_rtmp_adapter *pAd,
-                    struct rt_tx_context *pTxContext,
-                    u8 BulkOutPipeId, IN usb_complete_t Func)
-{
-       PURB pUrb;
-       u8 *pSrc = NULL;
-       struct os_cookie *pObj = (struct os_cookie *)pAd->OS_Cookie;
-
-       pUrb = pTxContext->pUrb;
-       ASSERT(pUrb);
-
-       /* Store BulkOut PipeId */
-       pTxContext->BulkOutPipeId = BulkOutPipeId;
-
-       if (pTxContext->bAggregatible) {
-               pSrc = &pTxContext->TransferBuffer->Aggregation[2];
-       } else {
-               pSrc =
-                   (u8 *)pTxContext->TransferBuffer->field.WirelessPacket;
-       }
-
-       /*Initialize a tx bulk urb */
-       RTUSB_FILL_BULK_URB(pUrb,
-                           pObj->pUsb_Dev,
-                           usb_sndbulkpipe(pObj->pUsb_Dev,
-                                           pAd->BulkOutEpAddr[BulkOutPipeId]),
-                           pSrc, pTxContext->BulkOutSize, Func, pTxContext);
-
-       if (pTxContext->bAggregatible)
-               pUrb->transfer_dma =
-                   (pTxContext->data_dma + TX_BUFFER_NORMSIZE + 2);
-       else
-               pUrb->transfer_dma = pTxContext->data_dma;
-
-       pUrb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
-
-}
-
-void RTUSBInitHTTxDesc(struct rt_rtmp_adapter *pAd,
-                      struct rt_ht_tx_context *pTxContext,
-                      u8 BulkOutPipeId,
-                      unsigned long BulkOutSize, IN usb_complete_t Func)
-{
-       PURB pUrb;
-       u8 *pSrc = NULL;
-       struct os_cookie *pObj = (struct os_cookie *)pAd->OS_Cookie;
-
-       pUrb = pTxContext->pUrb;
-       ASSERT(pUrb);
-
-       /* Store BulkOut PipeId */
-       pTxContext->BulkOutPipeId = BulkOutPipeId;
-
-       pSrc =
-           &pTxContext->TransferBuffer->field.WirelessPacket[pTxContext->
-                                                             NextBulkOutPosition];
-
-       /*Initialize a tx bulk urb */
-       RTUSB_FILL_BULK_URB(pUrb,
-                           pObj->pUsb_Dev,
-                           usb_sndbulkpipe(pObj->pUsb_Dev,
-                                           pAd->BulkOutEpAddr[BulkOutPipeId]),
-                           pSrc, BulkOutSize, Func, pTxContext);
-
-       pUrb->transfer_dma =
-           (pTxContext->data_dma + pTxContext->NextBulkOutPosition);
-       pUrb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
-
-}
-
-void RTUSBInitRxDesc(struct rt_rtmp_adapter *pAd, struct rt_rx_context *pRxContext)
-{
-       PURB pUrb;
-       struct os_cookie *pObj = (struct os_cookie *)pAd->OS_Cookie;
-       unsigned long RX_bulk_size;
-
-       pUrb = pRxContext->pUrb;
-       ASSERT(pUrb);
-
-       if (pAd->BulkInMaxPacketSize == 64)
-               RX_bulk_size = 4096;
-       else
-               RX_bulk_size = MAX_RXBULK_SIZE;
-
-       /*Initialize a rx bulk urb */
-       RTUSB_FILL_BULK_URB(pUrb,
-                           pObj->pUsb_Dev,
-                           usb_rcvbulkpipe(pObj->pUsb_Dev, pAd->BulkInEpAddr),
-                           &(pRxContext->
-                             TransferBuffer[pAd->NextRxBulkInPosition]),
-                           RX_bulk_size - (pAd->NextRxBulkInPosition),
-                           (usb_complete_t) RTUSBBulkRxComplete,
-                           (void *)pRxContext);
-
-       pUrb->transfer_dma = pRxContext->data_dma + pAd->NextRxBulkInPosition;
-       pUrb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
-
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-
-       Arguments:
-
-       Return Value:
-
-       Note:
-
-       ========================================================================
-*/
-
-#define BULK_OUT_LOCK(pLock, IrqFlags) \
-               if (1 /*!(in_interrupt() & 0xffff0000)*/)       \
-                       RTMP_IRQ_LOCK((pLock), IrqFlags);
-
-#define BULK_OUT_UNLOCK(pLock, IrqFlags)       \
-               if (1 /*!(in_interrupt() & 0xffff0000)*/)       \
-                       RTMP_IRQ_UNLOCK((pLock), IrqFlags);
-
-void RTUSBBulkOutDataPacket(struct rt_rtmp_adapter *pAd,
-                           u8 BulkOutPipeId, u8 Index)
-{
-
-       struct rt_ht_tx_context *pHTTXContext;
-       PURB pUrb;
-       int ret = 0;
-       struct rt_txinfo *pTxInfo, *pLastTxInfo = NULL;
-       struct rt_txwi *pTxWI;
-       unsigned long TmpBulkEndPos, ThisBulkSize;
-       unsigned long IrqFlags = 0, IrqFlags2 = 0;
-       u8 *pWirelessPkt, *pAppendant;
-       BOOLEAN bTxQLastRound = FALSE;
-       u8 allzero[4] = { 0x0, 0x0, 0x0, 0x0 };
-
-       BULK_OUT_LOCK(&pAd->BulkOutLock[BulkOutPipeId], IrqFlags);
-       if ((pAd->BulkOutPending[BulkOutPipeId] == TRUE)
-           || RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NEED_STOP_TX)) {
-               BULK_OUT_UNLOCK(&pAd->BulkOutLock[BulkOutPipeId], IrqFlags);
-               return;
-       }
-       pAd->BulkOutPending[BulkOutPipeId] = TRUE;
-
-       if (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED)
-           ) {
-               pAd->BulkOutPending[BulkOutPipeId] = FALSE;
-               BULK_OUT_UNLOCK(&pAd->BulkOutLock[BulkOutPipeId], IrqFlags);
-               return;
-       }
-       BULK_OUT_UNLOCK(&pAd->BulkOutLock[BulkOutPipeId], IrqFlags);
-
-       pHTTXContext = &(pAd->TxContext[BulkOutPipeId]);
-
-       BULK_OUT_LOCK(&pAd->TxContextQueueLock[BulkOutPipeId], IrqFlags2);
-       if ((pHTTXContext->ENextBulkOutPosition ==
-            pHTTXContext->CurWritePosition)
-           || ((pHTTXContext->ENextBulkOutPosition - 8) ==
-               pHTTXContext->CurWritePosition)) {
-               BULK_OUT_UNLOCK(&pAd->TxContextQueueLock[BulkOutPipeId],
-                               IrqFlags2);
-
-               BULK_OUT_LOCK(&pAd->BulkOutLock[BulkOutPipeId], IrqFlags);
-               pAd->BulkOutPending[BulkOutPipeId] = FALSE;
-
-               /* Clear Data flag */
-               RTUSB_CLEAR_BULK_FLAG(pAd,
-                                     (fRTUSB_BULK_OUT_DATA_FRAG <<
-                                      BulkOutPipeId));
-               RTUSB_CLEAR_BULK_FLAG(pAd,
-                                     (fRTUSB_BULK_OUT_DATA_NORMAL <<
-                                      BulkOutPipeId));
-
-               BULK_OUT_UNLOCK(&pAd->BulkOutLock[BulkOutPipeId], IrqFlags);
-               return;
-       }
-       /* Clear Data flag */
-       RTUSB_CLEAR_BULK_FLAG(pAd,
-                             (fRTUSB_BULK_OUT_DATA_FRAG << BulkOutPipeId));
-       RTUSB_CLEAR_BULK_FLAG(pAd,
-                             (fRTUSB_BULK_OUT_DATA_NORMAL << BulkOutPipeId));
-
-       /*DBGPRINT(RT_DEBUG_TRACE,("BulkOut-B:I=0x%lx, CWPos=%ld, CWRPos=%ld, NBPos=%ld, ENBPos=%ld, bCopy=%d!\n", in_interrupt(), */
-       /*                                                      pHTTXContext->CurWritePosition, pHTTXContext->CurWriteRealPos, pHTTXContext->NextBulkOutPosition, */
-       /*                                                      pHTTXContext->ENextBulkOutPosition, pHTTXContext->bCopySavePad)); */
-       pHTTXContext->NextBulkOutPosition = pHTTXContext->ENextBulkOutPosition;
-       ThisBulkSize = 0;
-       TmpBulkEndPos = pHTTXContext->NextBulkOutPosition;
-       pWirelessPkt = &pHTTXContext->TransferBuffer->field.WirelessPacket[0];
-
-       if ((pHTTXContext->bCopySavePad == TRUE)) {
-               if (RTMPEqualMemory(pHTTXContext->SavedPad, allzero, 4)) {
-                       DBGPRINT_RAW(RT_DEBUG_ERROR,
-                                    ("e1, allzero : %x  %x  %x  %x  %x  %x  %x  %x \n",
-                                     pHTTXContext->SavedPad[0],
-                                     pHTTXContext->SavedPad[1],
-                                     pHTTXContext->SavedPad[2],
-                                     pHTTXContext->SavedPad[3]
-                                     , pHTTXContext->SavedPad[4],
-                                     pHTTXContext->SavedPad[5],
-                                     pHTTXContext->SavedPad[6],
-                                     pHTTXContext->SavedPad[7]));
-               }
-               NdisMoveMemory(&pWirelessPkt[TmpBulkEndPos],
-                              pHTTXContext->SavedPad, 8);
-               pHTTXContext->bCopySavePad = FALSE;
-               if (pAd->bForcePrintTX == TRUE)
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("RTUSBBulkOutDataPacket --> COPY PAD. CurWrite = %ld, NextBulk = %ld.   ENextBulk = %ld.\n",
-                                 pHTTXContext->CurWritePosition,
-                                 pHTTXContext->NextBulkOutPosition,
-                                 pHTTXContext->ENextBulkOutPosition));
-       }
-
-       do {
-               pTxInfo = (struct rt_txinfo *)&pWirelessPkt[TmpBulkEndPos];
-               pTxWI =
-                       (struct rt_txwi *)&pWirelessPkt[TmpBulkEndPos + TXINFO_SIZE];
-
-               if (pAd->bForcePrintTX == TRUE)
-                       DBGPRINT(RT_DEBUG_TRACE,
-                                ("RTUSBBulkOutDataPacket AMPDU = %d.\n",
-                                 pTxWI->AMPDU));
-
-               /* add by Iverson, limit BulkOut size to 4k to pass WMM b mode 2T1R test items */
-               /*if ((ThisBulkSize != 0)  && (pTxWI->AMPDU == 0)) */
-               if ((ThisBulkSize != 0) && (pTxWI->PHYMODE == MODE_CCK)) {
-                       if (((ThisBulkSize & 0xffff8000) != 0)
-                           || ((ThisBulkSize & 0x1000) == 0x1000)) {
-                               /* Limit BulkOut size to about 4k bytes. */
-                               pHTTXContext->ENextBulkOutPosition =
-                                   TmpBulkEndPos;
-                               break;
-                       } else
-                           if (((pAd->BulkOutMaxPacketSize < 512)
-                                && ((ThisBulkSize & 0xfffff800) !=
-                                    0))
-                               /*|| ( (ThisBulkSize != 0)  && (pTxWI->AMPDU == 0)) */
-                               ) {
-                               /* For USB 1.1 or peer which didn't support AMPDU, limit the BulkOut size. */
-                               /* For performance in b/g mode, now just check for USB 1.1 and didn't care about the APMDU or not! 2008/06/04. */
-                               pHTTXContext->ENextBulkOutPosition =
-                                   TmpBulkEndPos;
-                               break;
-                       }
-               }
-               /* end Iverson */
-               else {
-                       if (((ThisBulkSize & 0xffff8000) != 0) || ((ThisBulkSize & 0x6000) == 0x6000)) {        /* Limit BulkOut size to about 24k bytes. */
-                               pHTTXContext->ENextBulkOutPosition =
-                                   TmpBulkEndPos;
-                               break;
-                       } else if (((pAd->BulkOutMaxPacketSize < 512) && ((ThisBulkSize & 0xfffff800) != 0)) /*|| ( (ThisBulkSize != 0)  && (pTxWI->AMPDU == 0)) */) {  /* For USB 1.1 or peer which didn't support AMPDU, limit the BulkOut size. */
-                               /* For performance in b/g mode, now just check for USB 1.1 and didn't care about the APMDU or not! 2008/06/04. */
-                               pHTTXContext->ENextBulkOutPosition =
-                                   TmpBulkEndPos;
-                               break;
-                       }
-               }
-
-               if (TmpBulkEndPos == pHTTXContext->CurWritePosition) {
-                       pHTTXContext->ENextBulkOutPosition = TmpBulkEndPos;
-                       break;
-               }
-
-               if (pTxInfo->QSEL != FIFO_EDCA) {
-                       DBGPRINT(RT_DEBUG_ERROR,
-                                ("%s(): ====> pTxInfo->QueueSel(%d)!= FIFO_EDCA!!!!\n",
-                                 __func__, pTxInfo->QSEL));
-                       DBGPRINT(RT_DEBUG_ERROR,
-                                ("\tCWPos=%ld, NBPos=%ld, ENBPos=%ld, bCopy=%d!\n",
-                                 pHTTXContext->CurWritePosition,
-                                 pHTTXContext->NextBulkOutPosition,
-                                 pHTTXContext->ENextBulkOutPosition,
-                                 pHTTXContext->bCopySavePad));
-                       hex_dump("Wrong QSel Pkt:",
-                                (u8 *)&pWirelessPkt[TmpBulkEndPos],
-                                (pHTTXContext->CurWritePosition -
-                                 pHTTXContext->NextBulkOutPosition));
-               }
-
-               if (pTxInfo->USBDMATxPktLen <= 8) {
-                       BULK_OUT_UNLOCK(&pAd->TxContextQueueLock[BulkOutPipeId],
-                                       IrqFlags2);
-                       DBGPRINT(RT_DEBUG_ERROR /*RT_DEBUG_TRACE */ ,
-                                ("e2, USBDMATxPktLen==0, Size=%ld, bCSPad=%d, CWPos=%ld, NBPos=%ld, CWRPos=%ld!\n",
-                                 pHTTXContext->BulkOutSize,
-                                 pHTTXContext->bCopySavePad,
-                                 pHTTXContext->CurWritePosition,
-                                 pHTTXContext->NextBulkOutPosition,
-                                 pHTTXContext->CurWriteRealPos));
-                       {
-                               DBGPRINT_RAW(RT_DEBUG_ERROR /*RT_DEBUG_TRACE */
-                                            ,
-                                            ("%x  %x  %x  %x  %x  %x  %x  %x \n",
-                                             pHTTXContext->SavedPad[0],
-                                             pHTTXContext->SavedPad[1],
-                                             pHTTXContext->SavedPad[2],
-                                             pHTTXContext->SavedPad[3]
-                                             , pHTTXContext->SavedPad[4],
-                                             pHTTXContext->SavedPad[5],
-                                             pHTTXContext->SavedPad[6],
-                                             pHTTXContext->SavedPad[7]));
-                       }
-                       pAd->bForcePrintTX = TRUE;
-                       BULK_OUT_LOCK(&pAd->BulkOutLock[BulkOutPipeId],
-                                     IrqFlags);
-                       pAd->BulkOutPending[BulkOutPipeId] = FALSE;
-                       BULK_OUT_UNLOCK(&pAd->BulkOutLock[BulkOutPipeId],
-                                       IrqFlags);
-                       /*DBGPRINT(RT_DEBUG_LOUD,("Out:pTxInfo->USBDMATxPktLen=%d!\n", pTxInfo->USBDMATxPktLen)); */
-                       return;
-               }
-               /* Increase Total transmit byte counter */
-               pAd->RalinkCounters.OneSecTransmittedByteCount +=
-                   pTxWI->MPDUtotalByteCount;
-               pAd->RalinkCounters.TransmittedByteCount +=
-                   pTxWI->MPDUtotalByteCount;
-
-               pLastTxInfo = pTxInfo;
-
-               /* Make sure we use EDCA QUEUE. */
-               pTxInfo->QSEL = FIFO_EDCA;
-               ThisBulkSize += (pTxInfo->USBDMATxPktLen + 4);
-               TmpBulkEndPos += (pTxInfo->USBDMATxPktLen + 4);
-
-               if (TmpBulkEndPos != pHTTXContext->CurWritePosition)
-                       pTxInfo->USBDMANextVLD = 1;
-
-               if (pTxInfo->SwUseLastRound == 1) {
-                       if (pHTTXContext->CurWritePosition == 8)
-                               pTxInfo->USBDMANextVLD = 0;
-                       pTxInfo->SwUseLastRound = 0;
-
-                       bTxQLastRound = TRUE;
-                       pHTTXContext->ENextBulkOutPosition = 8;
-
-                       break;
-               }
-
-       } while (TRUE);
-
-       /* adjust the pTxInfo->USBDMANextVLD value of last pTxInfo. */
-       if (pLastTxInfo)
-               pLastTxInfo->USBDMANextVLD = 0;
-
-       /*
-          We need to copy SavedPad when following condition matched!
-          1. Not the last round of the TxQueue and
-          2. any match of following cases:
-          (1). The End Position of this bulk out is reach to the Currenct Write position and
-          the TxInfo and related header already write to the CurWritePosition.
-          =>(ENextBulkOutPosition == CurWritePosition) && (CurWriteRealPos > CurWritePosition)
-
-          (2). The EndPosition of the bulk out is not reach to the Current Write Position.
-          =>(ENextBulkOutPosition != CurWritePosition)
-        */
-       if ((bTxQLastRound == FALSE) &&
-           (((pHTTXContext->ENextBulkOutPosition ==
-              pHTTXContext->CurWritePosition)
-             && (pHTTXContext->CurWriteRealPos >
-                 pHTTXContext->CurWritePosition))
-            || (pHTTXContext->ENextBulkOutPosition !=
-                pHTTXContext->CurWritePosition))
-           ) {
-               NdisMoveMemory(pHTTXContext->SavedPad,
-                              &pWirelessPkt[pHTTXContext->
-                                            ENextBulkOutPosition], 8);
-               pHTTXContext->bCopySavePad = TRUE;
-               if (RTMPEqualMemory(pHTTXContext->SavedPad, allzero, 4)) {
-                       u8 *pBuf = &pHTTXContext->SavedPad[0];
-                       DBGPRINT_RAW(RT_DEBUG_ERROR,
-                                    ("WARNING-Zero-3:%02x%02x%02x%02x%02x%02x%02x%02x,CWPos=%ld, CWRPos=%ld, bCW=%d, NBPos=%ld, TBPos=%ld, TBSize=%ld\n",
-                                     pBuf[0], pBuf[1], pBuf[2], pBuf[3],
-                                     pBuf[4], pBuf[5], pBuf[6], pBuf[7],
-                                     pHTTXContext->CurWritePosition,
-                                     pHTTXContext->CurWriteRealPos,
-                                     pHTTXContext->bCurWriting,
-                                     pHTTXContext->NextBulkOutPosition,
-                                     TmpBulkEndPos, ThisBulkSize));
-
-                       pBuf = &pWirelessPkt[pHTTXContext->CurWritePosition];
-                       DBGPRINT_RAW(RT_DEBUG_ERROR,
-                                    ("\tCWPos=%02x%02x%02x%02x%02x%02x%02x%02x\n",
-                                     pBuf[0], pBuf[1], pBuf[2], pBuf[3],
-                                     pBuf[4], pBuf[5], pBuf[6], pBuf[7]));
-               }
-               /*DBGPRINT(RT_DEBUG_LOUD,("ENPos==CWPos=%ld, CWRPos=%ld, bCSPad=%d!\n", pHTTXContext->CurWritePosition, pHTTXContext->CurWriteRealPos, pHTTXContext->bCopySavePad)); */
-       }
-
-       if (pAd->bForcePrintTX == TRUE)
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("BulkOut-A:Size=%ld, CWPos=%ld, NBPos=%ld, ENBPos=%ld, bCopy=%d!\n",
-                         ThisBulkSize, pHTTXContext->CurWritePosition,
-                         pHTTXContext->NextBulkOutPosition,
-                         pHTTXContext->ENextBulkOutPosition,
-                         pHTTXContext->bCopySavePad));
-       /*DBGPRINT(RT_DEBUG_LOUD,("BulkOut-A:Size=%ld, CWPos=%ld, CWRPos=%ld, NBPos=%ld, ENBPos=%ld, bCopy=%d, bLRound=%d!\n", ThisBulkSize, pHTTXContext->CurWritePosition, pHTTXContext->CurWriteRealPos, pHTTXContext->NextBulkOutPosition, pHTTXContext->ENextBulkOutPosition, pHTTXContext->bCopySavePad, bTxQLastRound)); */
-
-       /* USB DMA engine requires to pad extra 4 bytes. This pad doesn't count into real bulkoutsize. */
-       pAppendant = &pWirelessPkt[TmpBulkEndPos];
-       NdisZeroMemory(pAppendant, 8);
-       ThisBulkSize += 4;
-       pHTTXContext->LastOne = TRUE;
-       if ((ThisBulkSize % pAd->BulkOutMaxPacketSize) == 0)
-               ThisBulkSize += 4;
-       pHTTXContext->BulkOutSize = ThisBulkSize;
-
-       pAd->watchDogTxPendingCnt[BulkOutPipeId] = 1;
-       BULK_OUT_UNLOCK(&pAd->TxContextQueueLock[BulkOutPipeId], IrqFlags2);
-
-       /* Init Tx context descriptor */
-       RTUSBInitHTTxDesc(pAd, pHTTXContext, BulkOutPipeId, ThisBulkSize,
-                         (usb_complete_t) RTUSBBulkOutDataPacketComplete);
-
-       pUrb = pHTTXContext->pUrb;
-       ret = RTUSB_SUBMIT_URB(pUrb);
-       if (ret != 0) {
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("RTUSBBulkOutDataPacket: Submit Tx URB failed %d\n",
-                         ret));
-
-               BULK_OUT_LOCK(&pAd->BulkOutLock[BulkOutPipeId], IrqFlags);
-               pAd->BulkOutPending[BulkOutPipeId] = FALSE;
-               pAd->watchDogTxPendingCnt[BulkOutPipeId] = 0;
-               BULK_OUT_UNLOCK(&pAd->BulkOutLock[BulkOutPipeId], IrqFlags);
-
-               return;
-       }
-
-       BULK_OUT_LOCK(&pAd->BulkOutLock[BulkOutPipeId], IrqFlags);
-       pHTTXContext->IRPPending = TRUE;
-       BULK_OUT_UNLOCK(&pAd->BulkOutLock[BulkOutPipeId], IrqFlags);
-       pAd->BulkOutReq++;
-
-}
-
-void RTUSBBulkOutDataPacketComplete(struct urb *pUrb, struct pt_regs * pt_regs)
-{
-       struct rt_ht_tx_context *pHTTXContext;
-       struct rt_rtmp_adapter *pAd;
-       struct os_cookie *pObj;
-       u8 BulkOutPipeId;
-
-       pHTTXContext = (struct rt_ht_tx_context *)pUrb->context;
-       pAd = pHTTXContext->pAd;
-       pObj = (struct os_cookie *)pAd->OS_Cookie;
-
-       /* Store BulkOut PipeId */
-       BulkOutPipeId = pHTTXContext->BulkOutPipeId;
-       pAd->BulkOutDataOneSecCount++;
-
-       switch (BulkOutPipeId) {
-       case 0:
-               pObj->ac0_dma_done_task.data = (unsigned long)pUrb;
-               tasklet_hi_schedule(&pObj->ac0_dma_done_task);
-               break;
-       case 1:
-               pObj->ac1_dma_done_task.data = (unsigned long)pUrb;
-               tasklet_hi_schedule(&pObj->ac1_dma_done_task);
-               break;
-       case 2:
-               pObj->ac2_dma_done_task.data = (unsigned long)pUrb;
-               tasklet_hi_schedule(&pObj->ac2_dma_done_task);
-               break;
-       case 3:
-               pObj->ac3_dma_done_task.data = (unsigned long)pUrb;
-               tasklet_hi_schedule(&pObj->ac3_dma_done_task);
-               break;
-       }
-
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-
-       Arguments:
-
-       Return Value:
-
-       Note: NULL frame use BulkOutPipeId = 0
-
-       ========================================================================
-*/
-void RTUSBBulkOutNullFrame(struct rt_rtmp_adapter *pAd)
-{
-       struct rt_tx_context *pNullContext = &(pAd->NullContext);
-       PURB pUrb;
-       int ret = 0;
-       unsigned long IrqFlags;
-
-       RTMP_IRQ_LOCK(&pAd->BulkOutLock[0], IrqFlags);
-       if ((pAd->BulkOutPending[0] == TRUE)
-           || RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NEED_STOP_TX)) {
-               RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[0], IrqFlags);
-               return;
-       }
-       pAd->BulkOutPending[0] = TRUE;
-       pAd->watchDogTxPendingCnt[0] = 1;
-       pNullContext->IRPPending = TRUE;
-       RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[0], IrqFlags);
-
-       /* Increase Total transmit byte counter */
-       pAd->RalinkCounters.TransmittedByteCount += pNullContext->BulkOutSize;
-
-       /* Clear Null frame bulk flag */
-       RTUSB_CLEAR_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_NULL);
-
-       /* Init Tx context descriptor */
-       RTUSBInitTxDesc(pAd, pNullContext, 0,
-                       (usb_complete_t) RTUSBBulkOutNullFrameComplete);
-
-       pUrb = pNullContext->pUrb;
-       ret = RTUSB_SUBMIT_URB(pUrb);
-       if (ret != 0) {
-               RTMP_IRQ_LOCK(&pAd->BulkOutLock[0], IrqFlags);
-               pAd->BulkOutPending[0] = FALSE;
-               pAd->watchDogTxPendingCnt[0] = 0;
-               pNullContext->IRPPending = FALSE;
-               RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[0], IrqFlags);
-
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("RTUSBBulkOutNullFrame: Submit Tx URB failed %d\n",
-                         ret));
-               return;
-       }
-
-}
-
-/* NULL frame use BulkOutPipeId = 0 */
-void RTUSBBulkOutNullFrameComplete(struct urb *pUrb, struct pt_regs * pt_regs)
-{
-       struct rt_rtmp_adapter *pAd;
-       struct rt_tx_context *pNullContext;
-       int Status;
-       struct os_cookie *pObj;
-
-       pNullContext = (struct rt_tx_context *)pUrb->context;
-       pAd = pNullContext->pAd;
-       Status = pUrb->status;
-
-       pObj = (struct os_cookie *)pAd->OS_Cookie;
-       pObj->null_frame_complete_task.data = (unsigned long)pUrb;
-       tasklet_hi_schedule(&pObj->null_frame_complete_task);
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-
-       Arguments:
-
-       Return Value:
-
-       Note: MLME use BulkOutPipeId = 0
-
-       ========================================================================
-*/
-void RTUSBBulkOutMLMEPacket(struct rt_rtmp_adapter *pAd, u8 Index)
-{
-       struct rt_tx_context *pMLMEContext;
-       PURB pUrb;
-       int ret = 0;
-       unsigned long IrqFlags;
-
-       pMLMEContext =
-           (struct rt_tx_context *)pAd->MgmtRing.Cell[pAd->MgmtRing.TxDmaIdx].AllocVa;
-       pUrb = pMLMEContext->pUrb;
-
-       if ((pAd->MgmtRing.TxSwFreeIdx >= MGMT_RING_SIZE) ||
-           (pMLMEContext->InUse == FALSE) ||
-           (pMLMEContext->bWaitingBulkOut == FALSE)) {
-
-               /* Clear MLME bulk flag */
-               RTUSB_CLEAR_BULK_FLAG(pAd, fRTUSB_BULK_OUT_MLME);
-
-               return;
-       }
-
-       RTMP_IRQ_LOCK(&pAd->BulkOutLock[MGMTPIPEIDX], IrqFlags);
-       if ((pAd->BulkOutPending[MGMTPIPEIDX] == TRUE)
-           || RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NEED_STOP_TX)) {
-               RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[MGMTPIPEIDX], IrqFlags);
-               return;
-       }
-
-       pAd->BulkOutPending[MGMTPIPEIDX] = TRUE;
-       pAd->watchDogTxPendingCnt[MGMTPIPEIDX] = 1;
-       pMLMEContext->IRPPending = TRUE;
-       pMLMEContext->bWaitingBulkOut = FALSE;
-       RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[MGMTPIPEIDX], IrqFlags);
-
-       /* Increase Total transmit byte counter */
-       pAd->RalinkCounters.TransmittedByteCount += pMLMEContext->BulkOutSize;
-
-       /* Clear MLME bulk flag */
-       RTUSB_CLEAR_BULK_FLAG(pAd, fRTUSB_BULK_OUT_MLME);
-
-       /* Init Tx context descriptor */
-       RTUSBInitTxDesc(pAd, pMLMEContext, MGMTPIPEIDX,
-                       (usb_complete_t) RTUSBBulkOutMLMEPacketComplete);
-
-       /*For mgmt urb buffer, because we use sk_buff, so we need to notify the USB controller do dma mapping. */
-       pUrb->transfer_dma = 0;
-       pUrb->transfer_flags &= (~URB_NO_TRANSFER_DMA_MAP);
-
-       pUrb = pMLMEContext->pUrb;
-       ret = RTUSB_SUBMIT_URB(pUrb);
-       if (ret != 0) {
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("RTUSBBulkOutMLMEPacket: Submit MLME URB failed %d\n",
-                         ret));
-               RTMP_IRQ_LOCK(&pAd->BulkOutLock[MGMTPIPEIDX], IrqFlags);
-               pAd->BulkOutPending[MGMTPIPEIDX] = FALSE;
-               pAd->watchDogTxPendingCnt[MGMTPIPEIDX] = 0;
-               pMLMEContext->IRPPending = FALSE;
-               pMLMEContext->bWaitingBulkOut = TRUE;
-               RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[MGMTPIPEIDX], IrqFlags);
-
-               return;
-       }
-       /*DBGPRINT_RAW(RT_DEBUG_INFO, ("<---RTUSBBulkOutMLMEPacket \n")); */
-/*      printk("<---RTUSBBulkOutMLMEPacket,Cpu=%d!, Dma=%d, SwIdx=%d!\n", pAd->MgmtRing.TxCpuIdx, pAd->MgmtRing.TxDmaIdx, pAd->MgmtRing.TxSwFreeIdx); */
-}
-
-void RTUSBBulkOutMLMEPacketComplete(struct urb *pUrb, struct pt_regs * pt_regs)
-{
-       struct rt_tx_context *pMLMEContext;
-       struct rt_rtmp_adapter *pAd;
-       int Status;
-       struct os_cookie *pObj;
-       int index;
-
-       /*DBGPRINT_RAW(RT_DEBUG_INFO, ("--->RTUSBBulkOutMLMEPacketComplete\n")); */
-       pMLMEContext = (struct rt_tx_context *)pUrb->context;
-       pAd = pMLMEContext->pAd;
-       pObj = (struct os_cookie *)pAd->OS_Cookie;
-       Status = pUrb->status;
-       index = pMLMEContext->SelfIdx;
-
-       pObj->mgmt_dma_done_task.data = (unsigned long)pUrb;
-       tasklet_hi_schedule(&pObj->mgmt_dma_done_task);
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-
-       Arguments:
-
-       Return Value:
-
-       Note: PsPoll use BulkOutPipeId = 0
-
-       ========================================================================
-*/
-void RTUSBBulkOutPsPoll(struct rt_rtmp_adapter *pAd)
-{
-       struct rt_tx_context *pPsPollContext = &(pAd->PsPollContext);
-       PURB pUrb;
-       int ret = 0;
-       unsigned long IrqFlags;
-
-       RTMP_IRQ_LOCK(&pAd->BulkOutLock[0], IrqFlags);
-       if ((pAd->BulkOutPending[0] == TRUE)
-           || RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NEED_STOP_TX)) {
-               RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[0], IrqFlags);
-               return;
-       }
-       pAd->BulkOutPending[0] = TRUE;
-       pAd->watchDogTxPendingCnt[0] = 1;
-       pPsPollContext->IRPPending = TRUE;
-       RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[0], IrqFlags);
-
-       /* Clear PS-Poll bulk flag */
-       RTUSB_CLEAR_BULK_FLAG(pAd, fRTUSB_BULK_OUT_PSPOLL);
-
-       /* Init Tx context descriptor */
-       RTUSBInitTxDesc(pAd, pPsPollContext, MGMTPIPEIDX,
-                       (usb_complete_t) RTUSBBulkOutPsPollComplete);
-
-       pUrb = pPsPollContext->pUrb;
-       ret = RTUSB_SUBMIT_URB(pUrb);
-       if (ret != 0) {
-               RTMP_IRQ_LOCK(&pAd->BulkOutLock[0], IrqFlags);
-               pAd->BulkOutPending[0] = FALSE;
-               pAd->watchDogTxPendingCnt[0] = 0;
-               pPsPollContext->IRPPending = FALSE;
-               RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[0], IrqFlags);
-
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("RTUSBBulkOutPsPoll: Submit Tx URB failed %d\n",
-                         ret));
-               return;
-       }
-
-}
-
-/* PS-Poll frame use BulkOutPipeId = 0 */
-void RTUSBBulkOutPsPollComplete(struct urb *pUrb, struct pt_regs * pt_regs)
-{
-       struct rt_rtmp_adapter *pAd;
-       struct rt_tx_context *pPsPollContext;
-       int Status;
-       struct os_cookie *pObj;
-
-       pPsPollContext = (struct rt_tx_context *)pUrb->context;
-       pAd = pPsPollContext->pAd;
-       Status = pUrb->status;
-
-       pObj = (struct os_cookie *)pAd->OS_Cookie;
-       pObj->pspoll_frame_complete_task.data = (unsigned long)pUrb;
-       tasklet_hi_schedule(&pObj->pspoll_frame_complete_task);
-}
-
-void DoBulkIn(struct rt_rtmp_adapter *pAd)
-{
-       struct rt_rx_context *pRxContext;
-       PURB pUrb;
-       int ret = 0;
-       unsigned long IrqFlags;
-
-       RTMP_IRQ_LOCK(&pAd->BulkInLock, IrqFlags);
-       pRxContext = &(pAd->RxContext[pAd->NextRxBulkInIndex]);
-       if ((pAd->PendingRx > 0) || (pRxContext->Readable == TRUE)
-           || (pRxContext->InUse == TRUE)) {
-               RTMP_IRQ_UNLOCK(&pAd->BulkInLock, IrqFlags);
-               return;
-       }
-       pRxContext->InUse = TRUE;
-       pRxContext->IRPPending = TRUE;
-       pAd->PendingRx++;
-       pAd->BulkInReq++;
-       RTMP_IRQ_UNLOCK(&pAd->BulkInLock, IrqFlags);
-
-       /* Init Rx context descriptor */
-       NdisZeroMemory(pRxContext->TransferBuffer, pRxContext->BulkInOffset);
-       RTUSBInitRxDesc(pAd, pRxContext);
-
-       pUrb = pRxContext->pUrb;
-       ret = RTUSB_SUBMIT_URB(pUrb);
-       if (ret != 0) { /* fail */
-
-               RTMP_IRQ_LOCK(&pAd->BulkInLock, IrqFlags);
-               pRxContext->InUse = FALSE;
-               pRxContext->IRPPending = FALSE;
-               pAd->PendingRx--;
-               pAd->BulkInReq--;
-               RTMP_IRQ_UNLOCK(&pAd->BulkInLock, IrqFlags);
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("RTUSBBulkReceive: Submit Rx URB failed %d\n", ret));
-       } else {                /* success */
-               ASSERT((pRxContext->InUse == pRxContext->IRPPending));
-               /*printk("BIDone, Pend=%d,BIIdx=%d,BIRIdx=%d!\n", pAd->PendingRx, pAd->NextRxBulkInIndex, pAd->NextRxBulkInReadIndex); */
-       }
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-       USB_RxPacket initializes a URB and uses the Rx IRP to submit it
-       to USB. It checks if an Rx Descriptor is available and passes the
-       the coresponding buffer to be filled. If no descriptor is available
-       fails the request. When setting the completion routine we pass our
-       Adapter Object as Context.
-
-       Arguments:
-
-       Return Value:
-               TRUE                    found matched tuple cache
-               FALSE                   no matched found
-
-       Note:
-
-       ========================================================================
-*/
-#define fRTMP_ADAPTER_NEED_STOP_RX             \
-               (fRTMP_ADAPTER_NIC_NOT_EXIST | fRTMP_ADAPTER_HALT_IN_PROGRESS | \
-                fRTMP_ADAPTER_RADIO_OFF | fRTMP_ADAPTER_RESET_IN_PROGRESS | \
-                fRTMP_ADAPTER_REMOVE_IN_PROGRESS | fRTMP_ADAPTER_BULKIN_RESET)
-
-#define fRTMP_ADAPTER_NEED_STOP_HANDLE_RX      \
-               (fRTMP_ADAPTER_NIC_NOT_EXIST | fRTMP_ADAPTER_HALT_IN_PROGRESS | \
-                fRTMP_ADAPTER_RADIO_OFF | fRTMP_ADAPTER_RESET_IN_PROGRESS | \
-                fRTMP_ADAPTER_REMOVE_IN_PROGRESS)
-
-void RTUSBBulkReceive(struct rt_rtmp_adapter *pAd)
-{
-       struct rt_rx_context *pRxContext;
-       unsigned long IrqFlags;
-
-       /* sanity check */
-       if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NEED_STOP_HANDLE_RX))
-               return;
-
-       while (1) {
-
-               RTMP_IRQ_LOCK(&pAd->BulkInLock, IrqFlags);
-               pRxContext = &(pAd->RxContext[pAd->NextRxBulkInReadIndex]);
-               if (((pRxContext->InUse == FALSE)
-                    && (pRxContext->Readable == TRUE))
-                   && (pRxContext->bRxHandling == FALSE)) {
-                       pRxContext->bRxHandling = TRUE;
-                       RTMP_IRQ_UNLOCK(&pAd->BulkInLock, IrqFlags);
-
-                       /* read RxContext, Since not */
-                       STARxDoneInterruptHandle(pAd, TRUE);
-
-                       /* Finish to handle this bulkIn buffer. */
-                       RTMP_IRQ_LOCK(&pAd->BulkInLock, IrqFlags);
-                       pRxContext->BulkInOffset = 0;
-                       pRxContext->Readable = FALSE;
-                       pRxContext->bRxHandling = FALSE;
-                       pAd->ReadPosition = 0;
-                       pAd->TransferBufferLength = 0;
-                       INC_RING_INDEX(pAd->NextRxBulkInReadIndex,
-                                      RX_RING_SIZE);
-                       RTMP_IRQ_UNLOCK(&pAd->BulkInLock, IrqFlags);
-
-               } else {
-                       RTMP_IRQ_UNLOCK(&pAd->BulkInLock, IrqFlags);
-                       break;
-               }
-       }
-
-       if (!(RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NEED_STOP_RX)))
-               DoBulkIn(pAd);
-
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               This routine process Rx Irp and call rx complete function.
-
-       Arguments:
-               DeviceObject    Pointer to the device object for next lower
-                                               device. DeviceObject passed in here belongs to
-                                               the next lower driver in the stack because we
-                                               were invoked via IoCallDriver in USB_RxPacket
-                                               AND it is not OUR device object
-         Irp                           Ptr to completed IRP
-         Context                       Ptr to our Adapter object (context specified
-                                               in IoSetCompletionRoutine
-
-       Return Value:
-               Always returns STATUS_MORE_PROCESSING_REQUIRED
-
-       Note:
-               Always returns STATUS_MORE_PROCESSING_REQUIRED
-       ========================================================================
-*/
-void RTUSBBulkRxComplete(struct urb *pUrb, struct pt_regs *pt_regs)
-{
-       /* use a receive tasklet to handle received packets; */
-       /* or sometimes hardware IRQ will be disabled here, so we can not */
-       /* use spin_lock_bh()/spin_unlock_bh() after IRQ is disabled. :< */
-       struct rt_rx_context *pRxContext;
-       struct rt_rtmp_adapter *pAd;
-       struct os_cookie *pObj;
-
-       pRxContext = (struct rt_rx_context *)pUrb->context;
-       pAd = pRxContext->pAd;
-       pObj = (struct os_cookie *)pAd->OS_Cookie;
-
-       pObj->rx_done_task.data = (unsigned long)pUrb;
-       tasklet_hi_schedule(&pObj->rx_done_task);
-
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-
-       Arguments:
-
-       Return Value:
-
-       Note:
-
-       ========================================================================
-*/
-void RTUSBKickBulkOut(struct rt_rtmp_adapter *pAd)
-{
-       /* BulkIn Reset will reset whole USB PHY. So we need to make sure fRTMP_ADAPTER_BULKIN_RESET not flaged. */
-       if (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NEED_STOP_TX)
-           ) {
-               /* 2. PS-Poll frame is next */
-               if (RTUSB_TEST_BULK_FLAG(pAd, fRTUSB_BULK_OUT_PSPOLL))
-                       RTUSBBulkOutPsPoll(pAd);
-               /* 5. Mlme frame is next */
-               else if ((RTUSB_TEST_BULK_FLAG(pAd, fRTUSB_BULK_OUT_MLME)) ||
-                        (pAd->MgmtRing.TxSwFreeIdx < MGMT_RING_SIZE)) {
-                       RTUSBBulkOutMLMEPacket(pAd, pAd->MgmtRing.TxDmaIdx);
-               }
-               /* 6. Data frame normal is next */
-               if (RTUSB_TEST_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_NORMAL)) {
-                       if (((!RTMP_TEST_FLAG
-                             (pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
-                            ||
-                            (!OPSTATUS_TEST_FLAG
-                             (pAd, fOP_STATUS_MEDIA_STATE_CONNECTED))
-                           )) {
-                               RTUSBBulkOutDataPacket(pAd, 0,
-                                                      pAd->
-                                                      NextBulkOutIndex[0]);
-                       }
-               }
-               if (RTUSB_TEST_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_NORMAL_2)) {
-                       if (((!RTMP_TEST_FLAG
-                             (pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
-                            ||
-                            (!OPSTATUS_TEST_FLAG
-                             (pAd, fOP_STATUS_MEDIA_STATE_CONNECTED))
-                           )) {
-                               RTUSBBulkOutDataPacket(pAd, 1,
-                                                      pAd->
-                                                      NextBulkOutIndex[1]);
-                       }
-               }
-               if (RTUSB_TEST_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_NORMAL_3)) {
-                       if (((!RTMP_TEST_FLAG
-                             (pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
-                            ||
-                            (!OPSTATUS_TEST_FLAG
-                             (pAd, fOP_STATUS_MEDIA_STATE_CONNECTED))
-                           )) {
-                               RTUSBBulkOutDataPacket(pAd, 2,
-                                                      pAd->
-                                                      NextBulkOutIndex[2]);
-                       }
-               }
-               if (RTUSB_TEST_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_NORMAL_4)) {
-                       if (((!RTMP_TEST_FLAG
-                             (pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
-                            ||
-                            (!OPSTATUS_TEST_FLAG
-                             (pAd, fOP_STATUS_MEDIA_STATE_CONNECTED))
-                           )) {
-                               RTUSBBulkOutDataPacket(pAd, 3,
-                                                      pAd->
-                                                      NextBulkOutIndex[3]);
-                       }
-               }
-               /* 7. Null frame is the last */
-               else if (RTUSB_TEST_BULK_FLAG(pAd, fRTUSB_BULK_OUT_DATA_NULL)) {
-                       if (!RTMP_TEST_FLAG
-                           (pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS)) {
-                               RTUSBBulkOutNullFrame(pAd);
-                       }
-               }
-               /* 8. No data available */
-               else
-                       ;
-       }
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-       Call from Reset action after BulkOut failed.
-       Arguments:
-
-       Return Value:
-
-       Note:
-
-       ========================================================================
-*/
-void RTUSBCleanUpDataBulkOutQueue(struct rt_rtmp_adapter *pAd)
-{
-       u8 Idx;
-       struct rt_ht_tx_context *pTxContext;
-
-       DBGPRINT(RT_DEBUG_TRACE, ("--->CleanUpDataBulkOutQueue\n"));
-
-       for (Idx = 0; Idx < 4; Idx++) {
-               pTxContext = &pAd->TxContext[Idx];
-
-               pTxContext->CurWritePosition = pTxContext->NextBulkOutPosition;
-               pTxContext->LastOne = FALSE;
-               NdisAcquireSpinLock(&pAd->BulkOutLock[Idx]);
-               pAd->BulkOutPending[Idx] = FALSE;
-               NdisReleaseSpinLock(&pAd->BulkOutLock[Idx]);
-       }
-
-       DBGPRINT(RT_DEBUG_TRACE, ("<---CleanUpDataBulkOutQueue\n"));
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-
-       Arguments:
-
-       Return Value:
-
-       Note:
-
-       ========================================================================
-*/
-void RTUSBCleanUpMLMEBulkOutQueue(struct rt_rtmp_adapter *pAd)
-{
-       DBGPRINT(RT_DEBUG_TRACE, ("--->CleanUpMLMEBulkOutQueue\n"));
-       DBGPRINT(RT_DEBUG_TRACE, ("<---CleanUpMLMEBulkOutQueue\n"));
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-
-       Arguments:
-
-       Return Value:
-
-       Note:
-
-       ========================================================================
-*/
-void RTUSBCancelPendingIRPs(struct rt_rtmp_adapter *pAd)
-{
-       RTUSBCancelPendingBulkInIRP(pAd);
-       RTUSBCancelPendingBulkOutIRP(pAd);
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-
-       Arguments:
-
-       Return Value:
-
-       Note:
-
-       ========================================================================
-*/
-void RTUSBCancelPendingBulkInIRP(struct rt_rtmp_adapter *pAd)
-{
-       struct rt_rx_context *pRxContext;
-       u32 i;
-
-       DBGPRINT_RAW(RT_DEBUG_TRACE, ("--->RTUSBCancelPendingBulkInIRP\n"));
-       for (i = 0; i < (RX_RING_SIZE); i++) {
-               pRxContext = &(pAd->RxContext[i]);
-               if (pRxContext->IRPPending == TRUE) {
-                       RTUSB_UNLINK_URB(pRxContext->pUrb);
-                       pRxContext->IRPPending = FALSE;
-                       pRxContext->InUse = FALSE;
-                       /*NdisInterlockedDecrement(&pAd->PendingRx); */
-                       /*pAd->PendingRx--; */
-               }
-       }
-       DBGPRINT_RAW(RT_DEBUG_TRACE, ("<---RTUSBCancelPendingBulkInIRP\n"));
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-
-       Arguments:
-
-       Return Value:
-
-       Note:
-
-       ========================================================================
-*/
-void RTUSBCancelPendingBulkOutIRP(struct rt_rtmp_adapter *pAd)
-{
-       struct rt_ht_tx_context *pHTTXContext;
-       struct rt_tx_context *pMLMEContext;
-       struct rt_tx_context *pBeaconContext;
-       struct rt_tx_context *pNullContext;
-       struct rt_tx_context *pPsPollContext;
-       struct rt_tx_context *pRTSContext;
-       u32 i, Idx;
-/*      unsigned int            IrqFlags; */
-/*      spinlock_t          *pLock; */
-/*      BOOLEAN                         *pPending; */
-
-/*      pLock = &pAd->BulkOutLock[MGMTPIPEIDX]; */
-/*      pPending = &pAd->BulkOutPending[MGMTPIPEIDX]; */
-
-       for (Idx = 0; Idx < 4; Idx++) {
-               pHTTXContext = &(pAd->TxContext[Idx]);
-
-               if (pHTTXContext->IRPPending == TRUE) {
-
-                       /* Get the USB_CONTEXT and cancel it's IRP; the completion routine will itself */
-                       /* remove it from the HeadPendingSendList and NULL out HeadPendingSendList */
-                       /*      when the last IRP on the list has been  cancelled; that's how we exit this loop */
-                       /* */
-
-                       RTUSB_UNLINK_URB(pHTTXContext->pUrb);
-
-                       /* Sleep 200 microseconds to give cancellation time to work */
-                       RTMPusecDelay(200);
-               }
-
-               pAd->BulkOutPending[Idx] = FALSE;
-       }
-
-       /*RTMP_IRQ_LOCK(pLock, IrqFlags); */
-       for (i = 0; i < MGMT_RING_SIZE; i++) {
-               pMLMEContext = (struct rt_tx_context *)pAd->MgmtRing.Cell[i].AllocVa;
-               if (pMLMEContext && (pMLMEContext->IRPPending == TRUE)) {
-
-                       /* Get the USB_CONTEXT and cancel it's IRP; the completion routine will itself */
-                       /* remove it from the HeadPendingSendList and NULL out HeadPendingSendList */
-                       /*      when the last IRP on the list has been  cancelled; that's how we exit this loop */
-                       /* */
-
-                       RTUSB_UNLINK_URB(pMLMEContext->pUrb);
-                       pMLMEContext->IRPPending = FALSE;
-
-                       /* Sleep 200 microsecs to give cancellation time to work */
-                       RTMPusecDelay(200);
-               }
-       }
-       pAd->BulkOutPending[MGMTPIPEIDX] = FALSE;
-       /*RTMP_IRQ_UNLOCK(pLock, IrqFlags); */
-
-       for (i = 0; i < BEACON_RING_SIZE; i++) {
-               pBeaconContext = &(pAd->BeaconContext[i]);
-
-               if (pBeaconContext->IRPPending == TRUE) {
-
-                       /* Get the USB_CONTEXT and cancel it's IRP; the completion routine will itself */
-                       /* remove it from the HeadPendingSendList and NULL out HeadPendingSendList */
-                       /*      when the last IRP on the list has been  cancelled; that's how we exit this loop */
-                       /* */
-
-                       RTUSB_UNLINK_URB(pBeaconContext->pUrb);
-
-                       /* Sleep 200 microsecs to give cancellation time to work */
-                       RTMPusecDelay(200);
-               }
-       }
-
-       pNullContext = &(pAd->NullContext);
-       if (pNullContext->IRPPending == TRUE)
-               RTUSB_UNLINK_URB(pNullContext->pUrb);
-
-       pRTSContext = &(pAd->RTSContext);
-       if (pRTSContext->IRPPending == TRUE)
-               RTUSB_UNLINK_URB(pRTSContext->pUrb);
-
-       pPsPollContext = &(pAd->PsPollContext);
-       if (pPsPollContext->IRPPending == TRUE)
-               RTUSB_UNLINK_URB(pPsPollContext->pUrb);
-
-       for (Idx = 0; Idx < 4; Idx++) {
-               NdisAcquireSpinLock(&pAd->BulkOutLock[Idx]);
-               pAd->BulkOutPending[Idx] = FALSE;
-               NdisReleaseSpinLock(&pAd->BulkOutLock[Idx]);
-       }
-}
-
-#endif /* RTMP_MAC_USB // */
diff --git a/drivers/staging/rt2870/common/rtusb_data.c b/drivers/staging/rt2870/common/rtusb_data.c
deleted file mode 100644 (file)
index 5b72bcd..0000000
+++ /dev/null
@@ -1,262 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-       Module Name:
-       rtusb_data.c
-
-       Abstract:
-       Ralink USB driver Tx/Rx functions.
-
-       Revision History:
-       Who         When          What
-       --------    ----------    ----------------------------------------------
-       Jan            03-25-2006    created
-
-*/
-
-#ifdef RTMP_MAC_USB
-
-#include "../rt_config.h"
-
-extern u8 Phy11BGNextRateUpward[];     /* defined in mlme.c */
-extern u8 EpToQueue[];
-
-void REPORT_AMSDU_FRAMES_TO_LLC(struct rt_rtmp_adapter *pAd,
-                               u8 *pData, unsigned long DataSize)
-{
-       void *pPacket;
-       u32 nMSDU;
-       struct sk_buff *pSkb;
-
-       nMSDU = 0;
-       /* allocate a rx packet */
-       pSkb = dev_alloc_skb(RX_BUFFER_AGGRESIZE);
-       pPacket = (void *)OSPKT_TO_RTPKT(pSkb);
-       if (pSkb) {
-
-               /* convert 802.11 to 802.3 packet */
-               pSkb->dev = get_netdev_from_bssid(pAd, BSS0);
-               RTMP_SET_PACKET_SOURCE(pPacket, PKTSRC_NDIS);
-               deaggregate_AMSDU_announce(pAd, pPacket, pData, DataSize);
-       } else {
-               DBGPRINT(RT_DEBUG_ERROR, ("Can't allocate skb\n"));
-       }
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               This subroutine will scan through releative ring descriptor to find
-               out available free ring descriptor and compare with request size.
-
-       Arguments:
-               pAd     Pointer to our adapter
-               RingType        Selected Ring
-
-       Return Value:
-               NDIS_STATUS_FAILURE             Not enough free descriptor
-               NDIS_STATUS_SUCCESS             Enough free descriptor
-
-       Note:
-
-       ========================================================================
-*/
-int RTUSBFreeDescriptorRequest(struct rt_rtmp_adapter *pAd,
-                                      u8 BulkOutPipeId,
-                                      u32 NumberRequired)
-{
-/*      u8                   FreeNumber = 0; */
-/*      u32                    Index; */
-       int Status = NDIS_STATUS_FAILURE;
-       unsigned long IrqFlags;
-       struct rt_ht_tx_context *pHTTXContext;
-
-       pHTTXContext = &pAd->TxContext[BulkOutPipeId];
-       RTMP_IRQ_LOCK(&pAd->TxContextQueueLock[BulkOutPipeId], IrqFlags);
-       if ((pHTTXContext->CurWritePosition < pHTTXContext->NextBulkOutPosition)
-           &&
-           ((pHTTXContext->CurWritePosition + NumberRequired +
-             LOCAL_TXBUF_SIZE) > pHTTXContext->NextBulkOutPosition)) {
-
-               RTUSB_SET_BULK_FLAG(pAd,
-                                   (fRTUSB_BULK_OUT_DATA_NORMAL <<
-                                    BulkOutPipeId));
-       } else if ((pHTTXContext->CurWritePosition == 8)
-                  && (pHTTXContext->NextBulkOutPosition <
-                      (NumberRequired + LOCAL_TXBUF_SIZE))) {
-               RTUSB_SET_BULK_FLAG(pAd,
-                                   (fRTUSB_BULK_OUT_DATA_NORMAL <<
-                                    BulkOutPipeId));
-       } else if (pHTTXContext->bCurWriting == TRUE) {
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("RTUSBFreeD c3 --> QueIdx=%d, CWPos=%ld, NBOutPos=%ld!\n",
-                         BulkOutPipeId, pHTTXContext->CurWritePosition,
-                         pHTTXContext->NextBulkOutPosition));
-               RTUSB_SET_BULK_FLAG(pAd,
-                                   (fRTUSB_BULK_OUT_DATA_NORMAL <<
-                                    BulkOutPipeId));
-       } else {
-               Status = NDIS_STATUS_SUCCESS;
-       }
-       RTMP_IRQ_UNLOCK(&pAd->TxContextQueueLock[BulkOutPipeId], IrqFlags);
-
-       return Status;
-}
-
-int RTUSBFreeDescriptorRelease(struct rt_rtmp_adapter *pAd,
-                                      u8 BulkOutPipeId)
-{
-       unsigned long IrqFlags;
-       struct rt_ht_tx_context *pHTTXContext;
-
-       pHTTXContext = &pAd->TxContext[BulkOutPipeId];
-       RTMP_IRQ_LOCK(&pAd->TxContextQueueLock[BulkOutPipeId], IrqFlags);
-       pHTTXContext->bCurWriting = FALSE;
-       RTMP_IRQ_UNLOCK(&pAd->TxContextQueueLock[BulkOutPipeId], IrqFlags);
-
-       return NDIS_STATUS_SUCCESS;
-}
-
-BOOLEAN RTUSBNeedQueueBackForAgg(struct rt_rtmp_adapter *pAd, u8 BulkOutPipeId)
-{
-       unsigned long IrqFlags;
-       struct rt_ht_tx_context *pHTTXContext;
-       BOOLEAN needQueBack = FALSE;
-
-       pHTTXContext = &pAd->TxContext[BulkOutPipeId];
-
-       RTMP_IRQ_LOCK(&pAd->TxContextQueueLock[BulkOutPipeId], IrqFlags);
-       if ((pHTTXContext->IRPPending ==
-            TRUE) /*&& (pAd->TxSwQueue[BulkOutPipeId].Number == 0) */) {
-               if ((pHTTXContext->CurWritePosition <
-                    pHTTXContext->ENextBulkOutPosition)
-                   &&
-                   (((pHTTXContext->ENextBulkOutPosition +
-                      MAX_AGGREGATION_SIZE) < MAX_TXBULK_LIMIT)
-                    || (pHTTXContext->CurWritePosition >
-                        MAX_AGGREGATION_SIZE))) {
-                       needQueBack = TRUE;
-               } else
-                   if ((pHTTXContext->CurWritePosition >
-                        pHTTXContext->ENextBulkOutPosition)
-                       &&
-                       ((pHTTXContext->ENextBulkOutPosition +
-                         MAX_AGGREGATION_SIZE) <
-                        pHTTXContext->CurWritePosition)) {
-                       needQueBack = TRUE;
-               }
-       }
-       RTMP_IRQ_UNLOCK(&pAd->TxContextQueueLock[BulkOutPipeId], IrqFlags);
-
-       return needQueBack;
-
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-
-       Arguments:
-
-       Return Value:
-
-       IRQL =
-
-       Note:
-
-       ========================================================================
-*/
-void RTUSBRejectPendingPackets(struct rt_rtmp_adapter *pAd)
-{
-       u8 Index;
-       struct rt_queue_entry *pEntry;
-       void *pPacket;
-       struct rt_queue_header *pQueue;
-
-       for (Index = 0; Index < 4; Index++) {
-               NdisAcquireSpinLock(&pAd->TxSwQueueLock[Index]);
-               while (pAd->TxSwQueue[Index].Head != NULL) {
-                       pQueue = (struct rt_queue_header *)&(pAd->TxSwQueue[Index]);
-                       pEntry = RemoveHeadQueue(pQueue);
-                       pPacket = QUEUE_ENTRY_TO_PACKET(pEntry);
-                       RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
-               }
-               NdisReleaseSpinLock(&pAd->TxSwQueueLock[Index]);
-
-       }
-
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-               Calculates the duration which is required to transmit out frames
-       with given size and specified rate.
-
-       Arguments:
-               pTxD            Pointer to transmit descriptor
-               Ack                     Setting for Ack requirement bit
-               Fragment        Setting for Fragment bit
-               RetryMode       Setting for retry mode
-               Ifs                     Setting for IFS gap
-               Rate            Setting for transmit rate
-               Service         Setting for service
-               Length          Frame length
-               TxPreamble  Short or Long preamble when using CCK rates
-               QueIdx - 0-3, according to 802.11e/d4.4 June/2003
-
-       Return Value:
-               None
-
-       IRQL = PASSIVE_LEVEL
-       IRQL = DISPATCH_LEVEL
-
-       ========================================================================
-*/
-
-void RTMPWriteTxInfo(struct rt_rtmp_adapter *pAd,
-                    struct rt_txinfo *pTxInfo,
-                    u16 USBDMApktLen,
-                    IN BOOLEAN bWiv,
-                    u8 QueueSel, u8 NextValid, u8 TxBurst)
-{
-       pTxInfo->USBDMATxPktLen = USBDMApktLen;
-       pTxInfo->QSEL = QueueSel;
-       if (QueueSel != FIFO_EDCA)
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("====> QueueSel != FIFO_EDCA<============\n"));
-       pTxInfo->USBDMANextVLD = FALSE; /*NextValid;  // Need to check with Jan about this. */
-       pTxInfo->USBDMATxburst = TxBurst;
-       pTxInfo->WIV = bWiv;
-       pTxInfo->SwUseLastRound = 0;
-       pTxInfo->rsv = 0;
-       pTxInfo->rsv2 = 0;
-}
-
-#endif /* RTMP_MAC_USB // */
diff --git a/drivers/staging/rt2870/common/rtusb_io.c b/drivers/staging/rt2870/common/rtusb_io.c
deleted file mode 100644 (file)
index 7d2f7e0..0000000
+++ /dev/null
@@ -1,2104 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  *
- * it under the terms of the GNU General Public License as published by  *
- * the Free Software Foundation; either version 2 of the License, or     *
- * (at your option) any later version.                                   *
- *                                                                       *
- * This program is distributed in the hope that it will be useful,       *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- * GNU General Public License for more details.                          *
- *                                                                       *
- * You should have received a copy of the GNU General Public License     *
- * along with this program; if not, write to the                         *
- * Free Software Foundation, Inc.,                                       *
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- *                                                                       *
- *************************************************************************
-
-       Module Name:
-       rtusb_io.c
-
-       Abstract:
-
-       Revision History:
-       Who                     When        What
-       --------        ----------  ----------------------------------------------
-       Name            Date        Modification logs
-       Paul Lin    06-25-2004  created
-*/
-
-#ifdef RTMP_MAC_USB
-
-#include "../rt_config.h"
-
-/*
-       ========================================================================
-
-       Routine Description: NIC initialization complete
-
-       Arguments:
-
-       Return Value:
-
-       IRQL =
-
-       Note:
-
-       ========================================================================
-*/
-
-static int RTUSBFirmwareRun(struct rt_rtmp_adapter *pAd)
-{
-       int Status;
-
-       Status = RTUSB_VendorRequest(pAd,
-                                    USBD_TRANSFER_DIRECTION_OUT,
-                                    DEVICE_VENDOR_REQUEST_OUT,
-                                    0x01, 0x8, 0, NULL, 0);
-
-       return Status;
-}
-
-/*
-       ========================================================================
-
-       Routine Description: Write Firmware to NIC.
-
-       Arguments:
-
-       Return Value:
-
-       IRQL =
-
-       Note:
-
-       ========================================================================
-*/
-int RTUSBFirmwareWrite(struct rt_rtmp_adapter *pAd,
-                      const u8 *pFwImage, unsigned long FwLen)
-{
-       u32 MacReg;
-       int Status;
-/*      unsigned long           i; */
-       u16 writeLen;
-
-       Status = RTUSBReadMACRegister(pAd, MAC_CSR0, &MacReg);
-
-       writeLen = FwLen;
-       RTUSBMultiWrite(pAd, FIRMWARE_IMAGE_BASE, pFwImage, writeLen);
-
-       Status = RTUSBWriteMACRegister(pAd, 0x7014, 0xffffffff);
-       Status = RTUSBWriteMACRegister(pAd, 0x701c, 0xffffffff);
-       Status = RTUSBFirmwareRun(pAd);
-
-       /*2008/11/28:KH add to fix the dead rf frequency offset bug<-- */
-       RTMPusecDelay(10000);
-       RTUSBWriteMACRegister(pAd, H2M_MAILBOX_CSR, 0);
-       AsicSendCommandToMcu(pAd, 0x72, 0x00, 0x00, 0x00);      /*reset rf by MCU supported by new firmware */
-       /*2008/11/28:KH add to fix the dead rf frequency offset bug--> */
-
-       return Status;
-}
-
-int RTUSBVenderReset(struct rt_rtmp_adapter *pAd)
-{
-       int Status;
-       DBGPRINT_RAW(RT_DEBUG_ERROR, ("-->RTUSBVenderReset\n"));
-       Status = RTUSB_VendorRequest(pAd,
-                                    USBD_TRANSFER_DIRECTION_OUT,
-                                    DEVICE_VENDOR_REQUEST_OUT,
-                                    0x01, 0x1, 0, NULL, 0);
-
-       DBGPRINT_RAW(RT_DEBUG_ERROR, ("<--RTUSBVenderReset\n"));
-       return Status;
-}
-
-/*
-       ========================================================================
-
-       Routine Description: Read various length data from RT2573
-
-       Arguments:
-
-       Return Value:
-
-       IRQL =
-
-       Note:
-
-       ========================================================================
-*/
-int RTUSBMultiRead(struct rt_rtmp_adapter *pAd,
-                       u16 Offset, u8 *pData, u16 length)
-{
-       int Status;
-
-       Status = RTUSB_VendorRequest(pAd,
-                                    (USBD_TRANSFER_DIRECTION_IN |
-                                     USBD_SHORT_TRANSFER_OK),
-                                    DEVICE_VENDOR_REQUEST_IN, 0x7, 0, Offset,
-                                    pData, length);
-
-       return Status;
-}
-
-/*
-       ========================================================================
-
-       Routine Description: Write various length data to RT2573
-
-       Arguments:
-
-       Return Value:
-
-       IRQL =
-
-       Note:
-
-       ========================================================================
-*/
-int RTUSBMultiWrite_OneByte(struct rt_rtmp_adapter *pAd,
-                           u16 Offset, const u8 *pData)
-{
-       int Status;
-
-       /* TODO: In 2870, use this funciton carefully cause it's not stable. */
-       Status = RTUSB_VendorRequest(pAd,
-                                    USBD_TRANSFER_DIRECTION_OUT,
-                                    DEVICE_VENDOR_REQUEST_OUT,
-                                    0x6, 0, Offset, (u8 *)pData, 1);
-
-       return Status;
-}
-
-int RTUSBMultiWrite(struct rt_rtmp_adapter *pAd,
-                   u16 Offset, const u8 *pData, u16 length)
-{
-       int Status;
-
-       u16 index = 0, Value;
-       const u8 *pSrc = pData;
-       u16 resude = 0;
-
-       resude = length % 2;
-       length += resude;
-       do {
-               Value = (u16)(*pSrc | (*(pSrc + 1) << 8));
-               Status = RTUSBSingleWrite(pAd, Offset + index, Value);
-               index += 2;
-               length -= 2;
-               pSrc = pSrc + 2;
-       } while (length > 0);
-
-       return Status;
-}
-
-int RTUSBSingleWrite(struct rt_rtmp_adapter *pAd,
-                         u16 Offset, u16 Value)
-{
-       int Status;
-
-       Status = RTUSB_VendorRequest(pAd,
-                                    USBD_TRANSFER_DIRECTION_OUT,
-                                    DEVICE_VENDOR_REQUEST_OUT,
-                                    0x2, Value, Offset, NULL, 0);
-
-       return Status;
-
-}
-
-/*
-       ========================================================================
-
-       Routine Description: Read 32-bit MAC register
-
-       Arguments:
-
-       Return Value:
-
-       IRQL =
-
-       Note:
-
-       ========================================================================
-*/
-int RTUSBReadMACRegister(struct rt_rtmp_adapter *pAd,
-                             u16 Offset, u32 *pValue)
-{
-       int Status = 0;
-       u32 localVal;
-
-       Status = RTUSB_VendorRequest(pAd,
-                                    (USBD_TRANSFER_DIRECTION_IN |
-                                     USBD_SHORT_TRANSFER_OK),
-                                    DEVICE_VENDOR_REQUEST_IN, 0x7, 0, Offset,
-                                    &localVal, 4);
-
-       *pValue = le2cpu32(localVal);
-
-       if (Status < 0)
-               *pValue = 0xffffffff;
-
-       return Status;
-}
-
-/*
-       ========================================================================
-
-       Routine Description: Write 32-bit MAC register
-
-       Arguments:
-
-       Return Value:
-
-       IRQL =
-
-       Note:
-
-       ========================================================================
-*/
-int RTUSBWriteMACRegister(struct rt_rtmp_adapter *pAd,
-                              u16 Offset, u32 Value)
-{
-       int Status;
-       u32 localVal;
-
-       localVal = Value;
-
-       Status = RTUSBSingleWrite(pAd, Offset, (u16)(localVal & 0xffff));
-       Status =
-           RTUSBSingleWrite(pAd, Offset + 2,
-                            (u16)((localVal & 0xffff0000) >> 16));
-
-       return Status;
-}
-
-/*
-       ========================================================================
-
-       Routine Description: Read 8-bit BBP register
-
-       Arguments:
-
-       Return Value:
-
-       IRQL =
-
-       Note:
-
-       ========================================================================
-*/
-int RTUSBReadBBPRegister(struct rt_rtmp_adapter *pAd,
-                             u8 Id, u8 *pValue)
-{
-       BBP_CSR_CFG_STRUC BbpCsr;
-       u32 i = 0;
-       int status;
-
-       /* Verify the busy condition */
-       do {
-               status = RTUSBReadMACRegister(pAd, BBP_CSR_CFG, &BbpCsr.word);
-               if (status >= 0) {
-                       if (!(BbpCsr.field.Busy == BUSY))
-                               break;
-               }
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("RTUSBReadBBPRegister(BBP_CSR_CFG_1):retry count=%d!\n",
-                         i));
-               i++;
-       } while ((i < RETRY_LIMIT)
-                && (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)));
-
-       if ((i == RETRY_LIMIT)
-           || (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST))) {
-               /* */
-               /* Read failed then Return Default value. */
-               /* */
-               *pValue = pAd->BbpWriteLatch[Id];
-
-               DBGPRINT_RAW(RT_DEBUG_ERROR,
-                            ("Retry count exhausted or device removed!!!\n"));
-               return STATUS_UNSUCCESSFUL;
-       }
-       /* Prepare for write material */
-       BbpCsr.word = 0;
-       BbpCsr.field.fRead = 1;
-       BbpCsr.field.Busy = 1;
-       BbpCsr.field.RegNum = Id;
-       RTUSBWriteMACRegister(pAd, BBP_CSR_CFG, BbpCsr.word);
-
-       i = 0;
-       /* Verify the busy condition */
-       do {
-               status = RTUSBReadMACRegister(pAd, BBP_CSR_CFG, &BbpCsr.word);
-               if (status >= 0) {
-                       if (!(BbpCsr.field.Busy == BUSY)) {
-                               *pValue = (u8)BbpCsr.field.Value;
-                               break;
-                       }
-               }
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("RTUSBReadBBPRegister(BBP_CSR_CFG_2):retry count=%d!\n",
-                         i));
-               i++;
-       } while ((i < RETRY_LIMIT)
-                && (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)));
-
-       if ((i == RETRY_LIMIT)
-           || (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST))) {
-               /* */
-               /* Read failed then Return Default value. */
-               /* */
-               *pValue = pAd->BbpWriteLatch[Id];
-
-               DBGPRINT_RAW(RT_DEBUG_ERROR,
-                            ("Retry count exhausted or device removed!!!\n"));
-               return STATUS_UNSUCCESSFUL;
-       }
-
-       return STATUS_SUCCESS;
-}
-
-/*
-       ========================================================================
-
-       Routine Description: Write 8-bit BBP register
-
-       Arguments:
-
-       Return Value:
-
-       IRQL =
-
-       Note:
-
-       ========================================================================
-*/
-int RTUSBWriteBBPRegister(struct rt_rtmp_adapter *pAd,
-                              u8 Id, u8 Value)
-{
-       BBP_CSR_CFG_STRUC BbpCsr;
-       u32 i = 0;
-       int status;
-       /* Verify the busy condition */
-       do {
-               status = RTUSBReadMACRegister(pAd, BBP_CSR_CFG, &BbpCsr.word);
-               if (status >= 0) {
-                       if (!(BbpCsr.field.Busy == BUSY))
-                               break;
-               }
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("RTUSBWriteBBPRegister(BBP_CSR_CFG):retry count=%d!\n",
-                         i));
-               i++;
-       } while ((i < RETRY_LIMIT)
-              && (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)));
-
-       if ((i == RETRY_LIMIT)
-           || (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST))) {
-               DBGPRINT_RAW(RT_DEBUG_ERROR,
-                            ("Retry count exhausted or device removed!!!\n"));
-               return STATUS_UNSUCCESSFUL;
-       }
-       /* Prepare for write material */
-       BbpCsr.word = 0;
-       BbpCsr.field.fRead = 0;
-       BbpCsr.field.Value = Value;
-       BbpCsr.field.Busy = 1;
-       BbpCsr.field.RegNum = Id;
-       RTUSBWriteMACRegister(pAd, BBP_CSR_CFG, BbpCsr.word);
-
-       pAd->BbpWriteLatch[Id] = Value;
-
-       return STATUS_SUCCESS;
-}
-
-/*
-       ========================================================================
-
-       Routine Description: Write RF register through MAC
-
-       Arguments:
-
-       Return Value:
-
-       IRQL =
-
-       Note:
-
-       ========================================================================
-*/
-int RTUSBWriteRFRegister(struct rt_rtmp_adapter *pAd, u32 Value)
-{
-       PHY_CSR4_STRUC PhyCsr4;
-       u32 i = 0;
-       int status;
-
-       NdisZeroMemory(&PhyCsr4, sizeof(PHY_CSR4_STRUC));
-       do {
-               status = RTUSBReadMACRegister(pAd, RF_CSR_CFG0, &PhyCsr4.word);
-               if (status >= 0) {
-                       if (!(PhyCsr4.field.Busy))
-                               break;
-               }
-               DBGPRINT(RT_DEBUG_TRACE,
-                        ("RTUSBWriteRFRegister(RF_CSR_CFG0):retry count=%d!\n",
-                         i));
-               i++;
-       } while ((i < RETRY_LIMIT)
-              && (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)));
-
-       if ((i == RETRY_LIMIT)
-           || (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST))) {
-               DBGPRINT_RAW(RT_DEBUG_ERROR,
-                            ("Retry count exhausted or device removed!!!\n"));
-               return STATUS_UNSUCCESSFUL;
-       }
-
-       RTUSBWriteMACRegister(pAd, RF_CSR_CFG0, Value);
-
-       return STATUS_SUCCESS;
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-
-       Arguments:
-
-       Return Value:
-
-       IRQL =
-
-       Note:
-
-       ========================================================================
-*/
-int RTUSBReadEEPROM(struct rt_rtmp_adapter *pAd,
-                        u16 Offset, u8 *pData, u16 length)
-{
-       int Status = STATUS_SUCCESS;
-
-       Status = RTUSB_VendorRequest(pAd,
-                                    (USBD_TRANSFER_DIRECTION_IN |
-                                     USBD_SHORT_TRANSFER_OK),
-                                    DEVICE_VENDOR_REQUEST_IN, 0x9, 0, Offset,
-                                    pData, length);
-
-       return Status;
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-
-       Arguments:
-
-       Return Value:
-
-       IRQL =
-
-       Note:
-
-       ========================================================================
-*/
-int RTUSBWriteEEPROM(struct rt_rtmp_adapter *pAd,
-                         u16 Offset, u8 *pData, u16 length)
-{
-       int Status = STATUS_SUCCESS;
-
-       Status = RTUSB_VendorRequest(pAd,
-                                    USBD_TRANSFER_DIRECTION_OUT,
-                                    DEVICE_VENDOR_REQUEST_OUT,
-                                    0x8, 0, Offset, pData, length);
-
-       return Status;
-}
-
-int RTUSBReadEEPROM16(struct rt_rtmp_adapter *pAd,
-                          u16 offset, u16 *pData)
-{
-       int status;
-       u16 localData;
-
-       status = RTUSBReadEEPROM(pAd, offset, (u8 *)(&localData), 2);
-       if (status == STATUS_SUCCESS)
-               *pData = le2cpu16(localData);
-
-       return status;
-
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-
-       Arguments:
-
-       Return Value:
-
-       IRQL =
-
-       Note:
-
-       ========================================================================
-*/
-void RTUSBPutToSleep(struct rt_rtmp_adapter *pAd)
-{
-       u32 value;
-
-       /* Timeout 0x40 x 50us */
-       value = (SLEEPCID << 16) + (OWNERMCU << 24) + (0x40 << 8) + 1;
-       RTUSBWriteMACRegister(pAd, 0x7010, value);
-       RTUSBWriteMACRegister(pAd, 0x404, 0x30);
-       /*RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS); */
-       DBGPRINT_RAW(RT_DEBUG_ERROR, ("Sleep Mailbox testvalue %x\n", value));
-
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-
-       Arguments:
-
-       Return Value:
-
-       IRQL =
-
-       Note:
-
-       ========================================================================
-*/
-int RTUSBWakeUp(struct rt_rtmp_adapter *pAd)
-{
-       int Status;
-
-       Status = RTUSB_VendorRequest(pAd,
-                                    USBD_TRANSFER_DIRECTION_OUT,
-                                    DEVICE_VENDOR_REQUEST_OUT,
-                                    0x01, 0x09, 0, NULL, 0);
-
-       return Status;
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-
-       Arguments:
-
-       Return Value:
-
-       IRQL =
-
-       Note:
-
-       ========================================================================
-*/
-void RTUSBInitializeCmdQ(struct rt_cmdq *cmdq)
-{
-       cmdq->head = NULL;
-       cmdq->tail = NULL;
-       cmdq->size = 0;
-       cmdq->CmdQState = RTMP_TASK_STAT_INITED;
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-
-       Arguments:
-
-       Return Value:
-
-       IRQL =
-
-       Note:
-
-       ========================================================================
-*/
-int RTUSBEnqueueCmdFromNdis(struct rt_rtmp_adapter *pAd,
-                                   IN NDIS_OID Oid,
-                                   IN BOOLEAN SetInformation,
-                                   void *pInformationBuffer,
-                                   u32 InformationBufferLength)
-{
-       int status;
-       struct rt_cmdqelmt *cmdqelmt = NULL;
-       struct rt_rtmp_os_task *pTask = &pAd->cmdQTask;
-
-#ifdef KTHREAD_SUPPORT
-       if (pTask->kthread_task == NULL)
-#else
-       CHECK_PID_LEGALITY(pTask->taskPID) {
-       }
-       else
-#endif
-       return NDIS_STATUS_RESOURCES;
-
-       status = os_alloc_mem(pAd, (u8 **) (&cmdqelmt), sizeof(struct rt_cmdqelmt));
-       if ((status != NDIS_STATUS_SUCCESS) || (cmdqelmt == NULL))
-               return NDIS_STATUS_RESOURCES;
-
-       cmdqelmt->buffer = NULL;
-       if (pInformationBuffer != NULL) {
-               status =
-                   os_alloc_mem(pAd, (u8 **) & cmdqelmt->buffer,
-                                InformationBufferLength);
-               if ((status != NDIS_STATUS_SUCCESS)
-                   || (cmdqelmt->buffer == NULL)) {
-                       kfree(cmdqelmt);
-                       return NDIS_STATUS_RESOURCES;
-               } else {
-                       NdisMoveMemory(cmdqelmt->buffer, pInformationBuffer,
-                                      InformationBufferLength);
-                       cmdqelmt->bufferlength = InformationBufferLength;
-               }
-       } else
-               cmdqelmt->bufferlength = 0;
-
-       cmdqelmt->command = Oid;
-       cmdqelmt->CmdFromNdis = TRUE;
-       if (SetInformation == TRUE)
-               cmdqelmt->SetOperation = TRUE;
-       else
-               cmdqelmt->SetOperation = FALSE;
-
-       NdisAcquireSpinLock(&pAd->CmdQLock);
-       if (pAd->CmdQ.CmdQState & RTMP_TASK_CAN_DO_INSERT) {
-               EnqueueCmd((&pAd->CmdQ), cmdqelmt);
-               status = NDIS_STATUS_SUCCESS;
-       } else {
-               status = NDIS_STATUS_FAILURE;
-       }
-       NdisReleaseSpinLock(&pAd->CmdQLock);
-
-       if (status == NDIS_STATUS_FAILURE) {
-               if (cmdqelmt->buffer)
-                       os_free_mem(pAd, cmdqelmt->buffer);
-               os_free_mem(pAd, cmdqelmt);
-       } else
-               RTUSBCMDUp(pAd);
-
-       return NDIS_STATUS_SUCCESS;
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-
-       Arguments:
-
-       Return Value:
-
-       IRQL =
-
-       Note:
-
-       ========================================================================
-*/
-int RTUSBEnqueueInternalCmd(struct rt_rtmp_adapter *pAd,
-                                   IN NDIS_OID Oid,
-                                   void *pInformationBuffer,
-                                   u32 InformationBufferLength)
-{
-       int status;
-       struct rt_cmdqelmt *cmdqelmt = NULL;
-
-       status = os_alloc_mem(pAd, (u8 **) & cmdqelmt, sizeof(struct rt_cmdqelmt));
-       if ((status != NDIS_STATUS_SUCCESS) || (cmdqelmt == NULL))
-               return NDIS_STATUS_RESOURCES;
-       NdisZeroMemory(cmdqelmt, sizeof(struct rt_cmdqelmt));
-
-       if (InformationBufferLength > 0) {
-               status =
-                   os_alloc_mem(pAd, (u8 **) & cmdqelmt->buffer,
-                                InformationBufferLength);
-               if ((status != NDIS_STATUS_SUCCESS)
-                   || (cmdqelmt->buffer == NULL)) {
-                       os_free_mem(pAd, cmdqelmt);
-                       return NDIS_STATUS_RESOURCES;
-               } else {
-                       NdisMoveMemory(cmdqelmt->buffer, pInformationBuffer,
-                                      InformationBufferLength);
-                       cmdqelmt->bufferlength = InformationBufferLength;
-               }
-       } else {
-               cmdqelmt->buffer = NULL;
-               cmdqelmt->bufferlength = 0;
-       }
-
-       cmdqelmt->command = Oid;
-       cmdqelmt->CmdFromNdis = FALSE;
-
-       if (cmdqelmt != NULL) {
-               NdisAcquireSpinLock(&pAd->CmdQLock);
-               if (pAd->CmdQ.CmdQState & RTMP_TASK_CAN_DO_INSERT) {
-                       EnqueueCmd((&pAd->CmdQ), cmdqelmt);
-                       status = NDIS_STATUS_SUCCESS;
-               } else {
-                       status = NDIS_STATUS_FAILURE;
-               }
-               NdisReleaseSpinLock(&pAd->CmdQLock);
-
-               if (status == NDIS_STATUS_FAILURE) {
-                       if (cmdqelmt->buffer)
-                               os_free_mem(pAd, cmdqelmt->buffer);
-                       os_free_mem(pAd, cmdqelmt);
-               } else
-                       RTUSBCMDUp(pAd);
-       }
-       return NDIS_STATUS_SUCCESS;
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-
-       Arguments:
-
-       Return Value:
-
-       IRQL =
-
-       Note:
-
-       ========================================================================
-*/
-void RTUSBDequeueCmd(struct rt_cmdq *cmdq, struct rt_cmdqelmt * * pcmdqelmt)
-{
-       *pcmdqelmt = cmdq->head;
-
-       if (*pcmdqelmt != NULL) {
-               cmdq->head = cmdq->head->next;
-               cmdq->size--;
-               if (cmdq->size == 0)
-                       cmdq->tail = NULL;
-       }
-}
-
-/*
-    ========================================================================
-         usb_control_msg - Builds a control urb, sends it off and waits for completion
-         @dev: pointer to the usb device to send the message to
-         @pipe: endpoint "pipe" to send the message to
-         @request: USB message request value
-         @requesttype: USB message request type value
-         @value: USB message value
-         @index: USB message index value
-         @data: pointer to the data to send
-         @size: length in bytes of the data to send
-         @timeout: time in jiffies to wait for the message to complete before
-                         timing out (if 0 the wait is forever)
-         Context: !in_interrupt ()
-
-         This function sends a simple control message to a specified endpoint
-         and waits for the message to complete, or timeout.
-         If successful, it returns the number of bytes transferred, otherwise a negative error number.
-
-        Don't use this function from within an interrupt context, like a
-         bottom half handler.  If you need an asynchronous message, or need to send
-         a message from within interrupt context, use usb_submit_urb()
-         If a thread in your driver uses this call, make sure your disconnect()
-         method can wait for it to complete.  Since you don't have a handle on
-         the URB used, you can't cancel the request.
-
-       Routine Description:
-
-       Arguments:
-
-       Return Value:
-
-       Note:
-
-       ========================================================================
-*/
-int RTUSB_VendorRequest(struct rt_rtmp_adapter *pAd,
-                            u32 TransferFlags,
-                            u8 RequestType,
-                            u8 Request,
-                            u16 Value,
-                            u16 Index,
-                            void *TransferBuffer,
-                            u32 TransferBufferLength)
-{
-       int ret = 0;
-       struct os_cookie *pObj = (struct os_cookie *)pAd->OS_Cookie;
-
-       if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)) {
-               DBGPRINT(RT_DEBUG_ERROR, ("device disconnected\n"));
-               return -1;
-       } else if (in_interrupt()) {
-               DBGPRINT(RT_DEBUG_ERROR,
-                        ("in_interrupt, RTUSB_VendorRequest Request%02x Value%04x Offset%04x\n",
-                         Request, Value, Index));
-
-               return -1;
-       } else {
-#define MAX_RETRY_COUNT  10
-
-               int retryCount = 0;
-               void *tmpBuf = TransferBuffer;
-
-               ret = down_interruptible(&(pAd->UsbVendorReq_semaphore));
-               if (pAd->UsbVendorReqBuf) {
-                       ASSERT(TransferBufferLength < MAX_PARAM_BUFFER_SIZE);
-
-                       tmpBuf = (void *)pAd->UsbVendorReqBuf;
-                       NdisZeroMemory(pAd->UsbVendorReqBuf,
-                                      TransferBufferLength);
-
-                       if (RequestType == DEVICE_VENDOR_REQUEST_OUT)
-                               NdisMoveMemory(tmpBuf, TransferBuffer,
-                                              TransferBufferLength);
-               }
-
-               do {
-                       if (RequestType == DEVICE_VENDOR_REQUEST_OUT)
-                               ret =
-                                   usb_control_msg(pObj->pUsb_Dev,
-                                                   usb_sndctrlpipe(pObj->
-                                                                   pUsb_Dev,
-                                                                   0), Request,
-                                                   RequestType, Value, Index,
-                                                   tmpBuf,
-                                                   TransferBufferLength,
-                                                   CONTROL_TIMEOUT_JIFFIES);
-                       else if (RequestType == DEVICE_VENDOR_REQUEST_IN)
-                               ret =
-                                   usb_control_msg(pObj->pUsb_Dev,
-                                                   usb_rcvctrlpipe(pObj->
-                                                                   pUsb_Dev,
-                                                                   0), Request,
-                                                   RequestType, Value, Index,
-                                                   tmpBuf,
-                                                   TransferBufferLength,
-                                                   CONTROL_TIMEOUT_JIFFIES);
-                       else {
-                               DBGPRINT(RT_DEBUG_ERROR,
-                                        ("vendor request direction is failed\n"));
-                               ret = -1;
-                       }
-
-                       retryCount++;
-                       if (ret < 0) {
-                               DBGPRINT(RT_DEBUG_OFF, ("#\n"));
-                               RTMPusecDelay(5000);
-                       }
-               } while ((ret < 0) && (retryCount < MAX_RETRY_COUNT));
-
-               if ((pAd->UsbVendorReqBuf)
-                   && (RequestType == DEVICE_VENDOR_REQUEST_IN))
-                       NdisMoveMemory(TransferBuffer, tmpBuf,
-                                      TransferBufferLength);
-               up(&(pAd->UsbVendorReq_semaphore));
-
-               if (ret < 0) {
-                       DBGPRINT(RT_DEBUG_ERROR,
-                                ("RTUSB_VendorRequest failed(%d),TxFlags=0x%x, ReqType=%s, Req=0x%x, Index=0x%x\n",
-                                 ret, TransferFlags,
-                                 (RequestType ==
-                                  DEVICE_VENDOR_REQUEST_OUT ? "OUT" : "IN"),
-                                 Request, Index));
-                       if (Request == 0x2)
-                               DBGPRINT(RT_DEBUG_ERROR,
-                                        ("\tRequest Value=0x%04x!\n", Value));
-
-                       if ((TransferBuffer != NULL)
-                           && (TransferBufferLength > 0))
-                               hex_dump("Failed TransferBuffer value",
-                                        TransferBuffer, TransferBufferLength);
-               }
-
-       }
-
-       if (ret != -1)
-               return STATUS_SUCCESS;
-       else
-               return STATUS_UNSUCCESSFUL;
-}
-
-/*
-       ========================================================================
-
-       Routine Description:
-         Creates an IRP to submite an IOCTL_INTERNAL_USB_RESET_PORT
-         synchronously. Callers of this function must be running at
-         PASSIVE LEVEL.
-
-       Arguments:
-
-       Return Value:
-
-       Note:
-
-       ========================================================================
-*/
-int RTUSB_ResetDevice(struct rt_rtmp_adapter *pAd)
-{
-       int Status = TRUE;
-
-       DBGPRINT_RAW(RT_DEBUG_TRACE, ("--->USB_ResetDevice\n"));
-       /*RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS); */
-       return Status;
-}
-
-void CMDHandler(struct rt_rtmp_adapter *pAd)
-{
-       struct rt_cmdqelmt *cmdqelmt;
-       u8 *pData;
-       int NdisStatus = NDIS_STATUS_SUCCESS;
-/*      unsigned long                   Now = 0; */
-       int ntStatus;
-/*      unsigned long   IrqFlags; */
-
-       while (pAd && pAd->CmdQ.size > 0) {
-               NdisStatus = NDIS_STATUS_SUCCESS;
-
-               NdisAcquireSpinLock(&pAd->CmdQLock);
-               RTUSBDequeueCmd(&pAd->CmdQ, &cmdqelmt);
-               NdisReleaseSpinLock(&pAd->CmdQLock);
-
-               if (cmdqelmt == NULL)
-                       break;
-
-               pData = cmdqelmt->buffer;
-
-               if (!
-                   (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)
-                    || RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS))) {
-                       switch (cmdqelmt->command) {
-                       case CMDTHREAD_CHECK_GPIO:
-                               {
-                                       u32 data;
-
-                                       {
-                                               /* Read GPIO pin2 as Hardware controlled radio state */
-
-                                               RTUSBReadMACRegister(pAd,
-                                                                    GPIO_CTRL_CFG,
-                                                                    &data);
-
-                                               if (data & 0x04) {
-                                                       pAd->StaCfg.bHwRadio =
-                                                           TRUE;
-                                               } else {
-                                                       pAd->StaCfg.bHwRadio =
-                                                           FALSE;
-                                               }
-
-                                               if (pAd->StaCfg.bRadio !=
-                                                   (pAd->StaCfg.bHwRadio
-                                                    && pAd->StaCfg.bSwRadio)) {
-                                                       pAd->StaCfg.bRadio =
-                                                           (pAd->StaCfg.
-                                                            bHwRadio
-                                                            && pAd->StaCfg.
-                                                            bSwRadio);
-                                                       if (pAd->StaCfg.
-                                                           bRadio == TRUE) {
-                                                               DBGPRINT_RAW
-                                                                   (RT_DEBUG_ERROR,
-                                                                    ("!!! Radio On !!!\n"));
-
-                                                               MlmeRadioOn
-                                                                   (pAd);
-                                                               /* Update extra information */
-                                                               pAd->ExtraInfo =
-                                                                   EXTRA_INFO_CLEAR;
-                                                       } else {
-                                                               DBGPRINT_RAW
-                                                                   (RT_DEBUG_ERROR,
-                                                                    ("!!! Radio Off !!!\n"));
-
-                                                               MlmeRadioOff
-                                                                   (pAd);
-                                                               /* Update extra information */
-                                                               pAd->ExtraInfo =
-                                                                   HW_RADIO_OFF;
-                                                       }
-                                               }
-                                       }
-                               }
-                               break;
-
-                       case CMDTHREAD_QKERIODIC_EXECUT:
-                               {
-                                       StaQuickResponeForRateUpExec(NULL, pAd,
-                                                                    NULL,
-                                                                    NULL);
-                               }
-                               break;
-
-                       case CMDTHREAD_RESET_BULK_OUT:
-                               {
-                                       u32 MACValue;
-                                       u8 Index;
-                                       int ret = 0;
-                                       struct rt_ht_tx_context *pHTTXContext;
-/*                                              struct rt_rtmp_tx_ring *pTxRing; */
-                                       unsigned long IrqFlags;
-
-                                       DBGPRINT_RAW(RT_DEBUG_TRACE,
-                                                    ("CmdThread : CMDTHREAD_RESET_BULK_OUT(ResetPipeid=0x%0x)===>\n",
-                                                     pAd->bulkResetPipeid));
-                                       /* All transfers must be aborted or cancelled before attempting to reset the pipe. */
-                                       /*RTUSBCancelPendingBulkOutIRP(pAd); */
-                                       /* Wait 10ms to let previous packet that are already in HW FIFO to clear. by MAXLEE 12-25-2007 */
-                                       Index = 0;
-                                       do {
-                                               RTUSBReadMACRegister(pAd,
-                                                                    TXRXQ_PCNT,
-                                                                    &MACValue);
-                                               if ((MACValue & 0xf00000
-                                                    /*0x800000 */) == 0)
-                                                       break;
-                                               Index++;
-                                               RTMPusecDelay(10000);
-                                       } while (Index < 100);
-                                       MACValue = 0;
-                                       RTUSBReadMACRegister(pAd, USB_DMA_CFG,
-                                                            &MACValue);
-                                       /* To prevent Read Register error, we 2nd check the validity. */
-                                       if ((MACValue & 0xc00000) == 0)
-                                               RTUSBReadMACRegister(pAd,
-                                                                    USB_DMA_CFG,
-                                                                    &MACValue);
-                                       /* To prevent Read Register error, we 3rd check the validity. */
-                                       if ((MACValue & 0xc00000) == 0)
-                                               RTUSBReadMACRegister(pAd,
-                                                                    USB_DMA_CFG,
-                                                                    &MACValue);
-                                       MACValue |= 0x80000;
-                                       RTUSBWriteMACRegister(pAd, USB_DMA_CFG,
-                                                             MACValue);
-
-                                       /* Wait 1ms to prevent next URB to bulkout before HW reset. by MAXLEE 12-25-2007 */
-                                       RTMPusecDelay(1000);
-
-                                       MACValue &= (~0x80000);
-                                       RTUSBWriteMACRegister(pAd, USB_DMA_CFG,
-                                                             MACValue);
-                                       DBGPRINT_RAW(RT_DEBUG_TRACE,
-                                                    ("\tSet 0x2a0 bit19. Clear USB DMA TX path\n"));
-
-                                       /* Wait 5ms to prevent next URB to bulkout before HW reset. by MAXLEE 12-25-2007 */
-                                       /*RTMPusecDelay(5000); */
-
-                                       if ((pAd->
-                                            bulkResetPipeid &
-                                            BULKOUT_MGMT_RESET_FLAG) ==
-                                           BULKOUT_MGMT_RESET_FLAG) {
-                                               RTMP_CLEAR_FLAG(pAd,
-                                                               fRTMP_ADAPTER_BULKOUT_RESET);
-                                               if (pAd->MgmtRing.TxSwFreeIdx <
-                                                   MGMT_RING_SIZE
-                                                   /* pMLMEContext->bWaitingBulkOut == TRUE */
-                                                   ) {
-                                                       RTUSB_SET_BULK_FLAG(pAd,
-                                                                           fRTUSB_BULK_OUT_MLME);
-                                               }
-                                               RTUSBKickBulkOut(pAd);
-
-                                               DBGPRINT_RAW(RT_DEBUG_TRACE,
-                                                            ("\tTX MGMT RECOVER Done!\n"));
-                                       } else {
-                                               pHTTXContext =
-                                                   &(pAd->
-                                                     TxContext[pAd->
-                                                               bulkResetPipeid]);
-                                               /*NdisAcquireSpinLock(&pAd->BulkOutLock[pAd->bulkResetPipeid]); */
-                                               RTMP_INT_LOCK(&pAd->
-                                                             BulkOutLock[pAd->
-                                                                         bulkResetPipeid],
-                                                             IrqFlags);
-                                               if (pAd->
-                                                   BulkOutPending[pAd->
-                                                                  bulkResetPipeid]
-                                                   == FALSE) {
-                                                       pAd->
-                                                           BulkOutPending[pAd->
-                                                                          bulkResetPipeid]
-                                                           = TRUE;
-                                                       pHTTXContext->
-                                                           IRPPending = TRUE;
-                                                       pAd->
-                                                           watchDogTxPendingCnt
-                                                           [pAd->
-                                                            bulkResetPipeid] =
-                                                           1;
-
-                                                       /* no matter what, clean the flag */
-                                                       RTMP_CLEAR_FLAG(pAd,
-                                                                       fRTMP_ADAPTER_BULKOUT_RESET);
-
-                                                       /*NdisReleaseSpinLock(&pAd->BulkOutLock[pAd->bulkResetPipeid]); */
-                                                       RTMP_INT_UNLOCK(&pAd->
-                                                                       BulkOutLock
-                                                                       [pAd->
-                                                                        bulkResetPipeid],
-                                                                       IrqFlags);
-                                                       {
-                                                               RTUSBInitHTTxDesc
-                                                                   (pAd,
-                                                                    pHTTXContext,
-                                                                    pAd->
-                                                                    bulkResetPipeid,
-                                                                    pHTTXContext->
-                                                                    BulkOutSize,
-                                                                    (usb_complete_t)
-                                                                    RTUSBBulkOutDataPacketComplete);
-
-                                                               ret = RTUSB_SUBMIT_URB
-                                                                    (pHTTXContext->
-                                                                     pUrb);
-                                                               if (ret != 0) {
-                                                                       RTMP_INT_LOCK
-                                                                           (&pAd->
-                                                                            BulkOutLock
-                                                                            [pAd->
-                                                                             bulkResetPipeid],
-                                                                            IrqFlags);
-                                                                       pAd->
-                                                                           BulkOutPending
-                                                                           [pAd->
-                                                                            bulkResetPipeid]
-                                                                           =
-                                                                           FALSE;
-                                                                       pHTTXContext->
-                                                                           IRPPending
-                                                                           =
-                                                                           FALSE;
-                                                                       pAd->
-                                                                           watchDogTxPendingCnt
-                                                                           [pAd->
-                                                                            bulkResetPipeid]
-                                                                           = 0;
-                                                                       RTMP_INT_UNLOCK
-                                                                           (&pAd->
-                                                                            BulkOutLock
-                                                                            [pAd->
-                                                                             bulkResetPipeid],
-                                                                            IrqFlags);
-
-                                                                       DBGPRINT
-                                                                           (RT_DEBUG_ERROR,
-                                                                            ("CmdThread : CMDTHREAD_RESET_BULK_OUT: Submit Tx URB failed %d\n",
-                                                                             ret));
-                                                               } else {
-                                                                       RTMP_IRQ_LOCK
-                                                                           (&pAd->
-                                                                            BulkOutLock
-                                                                            [pAd->
-                                                                             bulkResetPipeid],
-                                                                            IrqFlags);
-                                                                       DBGPRINT_RAW
-                                                                           (RT_DEBUG_TRACE,
-                                                                            ("\tCMDTHREAD_RESET_BULK_OUT: TxContext[%d]:CWPos=%ld, NBPos=%ld, ENBPos=%ld, bCopy=%d, pending=%d!\n",
-                                                                             pAd->
-                                                                             bulkResetPipeid,
-                                                                             pHTTXContext->
-                                                                             CurWritePosition,
-                                                                             pHTTXContext->
-                                                                             NextBulkOutPosition,
-                                                                             pHTTXContext->
-                                                                             ENextBulkOutPosition,
-                                                                             pHTTXContext->
-                                                                             bCopySavePad,
-                                                                             pAd->
-                                                                             BulkOutPending
-                                                                             [pAd->
-                                                                              bulkResetPipeid]));
-                                                                       DBGPRINT_RAW
-                                                                           (RT_DEBUG_TRACE,
-                                                                            ("\t\tBulkOut Req=0x%lx, Complete=0x%lx, Other=0x%lx\n",
-                                                                             pAd->
-                                                                             BulkOutReq,
-                                                                             pAd->
-                                                                             BulkOutComplete,
-                                                                             pAd->
-                                                                             BulkOutCompleteOther));
-                                                                       RTMP_IRQ_UNLOCK
-                                                                           (&pAd->
-                                                                            BulkOutLock
-                                                                            [pAd->
-                                                                             bulkResetPipeid],
-                                                                            IrqFlags);
-                                                                       DBGPRINT_RAW
-                                                                           (RT_DEBUG_TRACE,
-                                                                            ("\tCMDTHREAD_RESET_BULK_OUT: Submit Tx DATA URB for failed BulkReq(0x%lx) Done, status=%d!\n",
-                                                                             pAd->
-                                                                             bulkResetReq
-                                                                             [pAd->
-                                                                              bulkResetPipeid],
-                                                                             pHTTXContext->
-                                                                             pUrb->
-                                                                             status));
-
-                                                               }
-                                                       }
-                                               } else {
-                                                       /*NdisReleaseSpinLock(&pAd->BulkOutLock[pAd->bulkResetPipeid]); */
-                                                       /*RTMP_INT_UNLOCK(&pAd->BulkOutLock[pAd->bulkResetPipeid], IrqFlags); */
-
-                                                       DBGPRINT_RAW
-                                                           (RT_DEBUG_ERROR,
-                                                            ("CmdThread : TX DATA RECOVER FAIL for BulkReq(0x%lx) because BulkOutPending[%d] is TRUE!\n",
-                                                             pAd->
-                                                             bulkResetReq[pAd->
-                                                                          bulkResetPipeid],
-                                                             pAd->
-                                                             bulkResetPipeid));
-                                                       if (pAd->
-                                                           bulkResetPipeid ==
-                                                           0) {
-                                                               u8
-                                                                   pendingContext
-                                                                   = 0;
-                                                               struct rt_ht_tx_context *
-                                                                   pHTTXContext
-                                                                   =
-                                                                   (struct rt_ht_tx_context *)
-                                                                   (&pAd->
-                                                                    TxContext
-                                                                    [pAd->
-                                                                     bulkResetPipeid]);
-                                                               struct rt_tx_context *
-                                                                   pMLMEContext
-                                                                   =
-                                                                   (struct rt_tx_context *)
-                                                                   (pAd->
-                                                                    MgmtRing.
-                                                                    Cell[pAd->
-                                                                         MgmtRing.
-                                                                         TxDmaIdx].
-                                                                    AllocVa);
-                                                               struct rt_tx_context *
-                                                                   pNULLContext
-                                                                   =
-                                                                   (struct rt_tx_context *)
-                                                                   (&pAd->
-                                                                    PsPollContext);
-                                                               struct rt_tx_context *
-                                                                   pPsPollContext
-                                                                   =
-                                                                   (struct rt_tx_context *)
-                                                                   (&pAd->
-                                                                    NullContext);
-
-                                                               if (pHTTXContext->IRPPending)
-                                                                       pendingContext
-                                                                           |=
-                                                                           1;
-                                                               else if
-                                                                   (pMLMEContext->
-                                                                    IRPPending)
-                                                                       pendingContext
-                                                                           |=
-                                                                           2;
-                                                               else if
-                                                                   (pNULLContext->
-                                                                    IRPPending)
-                                                                       pendingContext
-                                                                           |=
-                                                                           4;
-                                                               else if
-                                                                   (pPsPollContext->
-                                                                    IRPPending)
-                                                                       pendingContext
-                                                                           |=
-                                                                           8;
-                                                               else
-                                                                       pendingContext
-                                                                           = 0;
-
-                                                               DBGPRINT_RAW
-                                                                   (RT_DEBUG_ERROR,
-                                                                    ("\tTX Occupied by %d!\n",
-                                                                     pendingContext));
-                                                       }
-                                                       /* no matter what, clean the flag */
-                                                       RTMP_CLEAR_FLAG(pAd,
-                                                                       fRTMP_ADAPTER_BULKOUT_RESET);
-
-                                                       RTMP_INT_UNLOCK(&pAd->
-                                                                       BulkOutLock
-                                                                       [pAd->
-                                                                        bulkResetPipeid],
-                                                                       IrqFlags);
-
-                                                       RTUSB_SET_BULK_FLAG(pAd,
-                                                                           (fRTUSB_BULK_OUT_DATA_NORMAL
-                                                                            <<
-                                                                            pAd->
-                                                                            bulkResetPipeid));
-                                               }
-
-                                               RTMPDeQueuePacket(pAd, FALSE,
-                                                                 NUM_OF_TX_RING,
-                                                                 MAX_TX_PROCESS);
-                                               /*RTUSBKickBulkOut(pAd); */
-                                       }
-
-                               }
-                               /*
-                                  // Don't cancel BULKIN.
-                                  while ((atomic_read(&pAd->PendingRx) > 0) &&
-                                  (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)))
-                                  {
-                                  if (atomic_read(&pAd->PendingRx) > 0)
-                                  {
-                                  DBGPRINT_RAW(RT_DEBUG_ERROR, ("BulkIn IRP Pending!!cancel it!\n"));
-                                  RTUSBCancelPendingBulkInIRP(pAd);
-                                  }
-                                  RTMPusecDelay(100000);
-                                  }
-
-                                  if ((atomic_read(&pAd->PendingRx) == 0) && (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS)))
-                                  {
-                                  u8        i;
-                                  RTUSBRxPacket(pAd);
-                                  pAd->NextRxBulkInReadIndex = 0;      // Next Rx Read index
-                                  pAd->NextRxBulkInIndex               = 0;    // Rx Bulk pointer
-                                  for (i = 0; i < (RX_RING_SIZE); i++)
-                                  {
-                                  struct rt_rx_context *pRxContext = &(pAd->RxContext[i]);
-
-                                  pRxContext->pAd      = pAd;
-                                  pRxContext->InUse            = FALSE;
-                                  pRxContext->IRPPending       = FALSE;
-                                  pRxContext->Readable = FALSE;
-                                  pRxContext->ReorderInUse = FALSE;
-
-                                  }
-                                  RTUSBBulkReceive(pAd);
-                                  DBGPRINT_RAW(RT_DEBUG_ERROR, ("RTUSBBulkReceive\n"));
-                                  } */
-                               DBGPRINT_RAW(RT_DEBUG_TRACE,
-                                            ("CmdThread : CMDTHREAD_RESET_BULK_OUT<===\n"));
-                               break;
-
-                       case CMDTHREAD_RESET_BULK_IN:
-                               DBGPRINT_RAW(RT_DEBUG_TRACE,
-                                            ("CmdThread : CMDTHREAD_RESET_BULK_IN === >\n"));
-
-                               /* All transfers must be aborted or cancelled before attempting to reset the pipe. */
-                               {
-                                       u32 MACValue;
-                                       {
-                                               /*while ((atomic_read(&pAd->PendingRx) > 0) && (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST))) */
-                                               if ((pAd->PendingRx > 0)
-                                                   &&
-                                                   (!RTMP_TEST_FLAG
-                                                    (pAd,
-                                                     fRTMP_ADAPTER_NIC_NOT_EXIST))) {
-                                                       DBGPRINT_RAW
-                                                           (RT_DEBUG_ERROR,
-                                                            ("BulkIn IRP Pending!!!\n"));
-                                                       RTUSBCancelPendingBulkInIRP
-                                                           (pAd);
-                                                       RTMPusecDelay(100000);
-                                                       pAd->PendingRx = 0;
-                                               }
-                                       }
-                                       /* Wait 10ms before reading register. */
-                                       RTMPusecDelay(10000);
-                                       ntStatus =
-                                           RTUSBReadMACRegister(pAd, MAC_CSR0,
-                                                                &MACValue);
-
-                                       if ((NT_SUCCESS(ntStatus) == TRUE) &&
-                                           (!(RTMP_TEST_FLAG
-                                              (pAd,
-                                               (fRTMP_ADAPTER_RESET_IN_PROGRESS
-                                                | fRTMP_ADAPTER_RADIO_OFF |
-                                                fRTMP_ADAPTER_HALT_IN_PROGRESS
-                                                |
-                                                fRTMP_ADAPTER_NIC_NOT_EXIST)))))
-                                       {
-                                               u8 i;
-
-                                               if (RTMP_TEST_FLAG
-                                                   (pAd,
-                                                    (fRTMP_ADAPTER_RESET_IN_PROGRESS
-                                                     | fRTMP_ADAPTER_RADIO_OFF
-                                                     |
-                                                     fRTMP_ADAPTER_HALT_IN_PROGRESS
-                                                     |
-                                                     fRTMP_ADAPTER_NIC_NOT_EXIST)))
-                                                       break;
-                                               pAd->NextRxBulkInPosition =
-                                                   pAd->RxContext[pAd->
-                                                                  NextRxBulkInIndex].
-                                                   BulkInOffset;
-                                               DBGPRINT(RT_DEBUG_TRACE,
-                                                        ("BULK_IN_RESET: NBIIdx=0x%x,NBIRIdx=0x%x, BIRPos=0x%lx. BIReq=x%lx, BIComplete=0x%lx, BICFail0x%lx\n",
-                                                         pAd->
-                                                         NextRxBulkInIndex,
-                                                         pAd->
-                                                         NextRxBulkInReadIndex,
-                                                         pAd->
-                                                         NextRxBulkInPosition,
-                                                         pAd->BulkInReq,
-                                                         pAd->BulkInComplete,
-                                                         pAd->
-                                                         BulkInCompleteFail));
-                                               for (i = 0; i < RX_RING_SIZE;
-                                                    i++) {
-                                                       DBGPRINT(RT_DEBUG_TRACE,
-                                                                ("\tRxContext[%d]: IRPPending=%d, InUse=%d, Readable=%d!\n",
-                                                                 i,
-                                                                 pAd->
-                                                                 RxContext[i].
-                                                                 IRPPending,
-                                                                 pAd->
-                                                                 RxContext[i].
-                                                                 InUse,
-                                                                 pAd->
-                                                                 RxContext[i].
-                                                                 Readable));
-                                               }
-                                               /*
-
-                                                  DBGPRINT_RAW(RT_DEBUG_ERROR, ("==========================================\n"));
-
-                                                  pAd->NextRxBulkInReadIndex = 0;      // Next Rx Read index
-                                                  pAd->NextRxBulkInIndex               = 0;    // Rx Bulk pointer
-                                                  for (i = 0; i < (RX_RING_SIZE); i++)
-                                                  {
-                                                  struct rt_rx_context *pRxContext = &(pAd->RxContext[i]);
-
-                                                  pRxContext->pAd      = pAd;
-                                                  pRxContext->InUse            = FALSE;
-                                                  pRxContext->IRPPending       = FALSE;
-                                                  pRxContext->Readable = FALSE;
-                                                  pRxContext->ReorderInUse = FALSE;
-
-                                                  } */
-                                               RTMP_CLEAR_FLAG(pAd,
-                                                               fRTMP_ADAPTER_BULKIN_RESET);
-                                               for (i = 0;
-                                                    i <
-                                                    pAd->CommonCfg.
-                                                    NumOfBulkInIRP; i++) {
-                                                       /*RTUSBBulkReceive(pAd); */
-                                                       struct rt_rx_context *pRxContext;
-                                                       PURB pUrb;
-                                                       int ret = 0;
-                                                       unsigned long IrqFlags;
-
-                                                       RTMP_IRQ_LOCK(&pAd->
-                                                                     BulkInLock,
-                                                                     IrqFlags);
-                                                       pRxContext =
-                                                           &(pAd->
-                                                             RxContext[pAd->
-                                                                       NextRxBulkInIndex]);
-                                                       if ((pAd->PendingRx > 0)
-                                                           || (pRxContext->
-                                                               Readable ==
-                                                               TRUE)
-                                                           || (pRxContext->
-                                                               InUse ==
-                                                               TRUE)) {
-                                                               RTMP_IRQ_UNLOCK
-                                                                   (&pAd->
-                                                                    BulkInLock,
-                                                                    IrqFlags);
-                                                               break;
-                                                       }
-                                                       pRxContext->InUse =
-                                                           TRUE;
-                                                       pRxContext->IRPPending =
-                                                           TRUE;
-                                                       pAd->PendingRx++;
-                                                       pAd->BulkInReq++;
-                                                       RTMP_IRQ_UNLOCK(&pAd->
-                                                                       BulkInLock,
-                                                                       IrqFlags);
-
-                                                       /* Init Rx context descriptor */
-                                                       RTUSBInitRxDesc(pAd,
-                                                                       pRxContext);
-                                                       pUrb = pRxContext->pUrb;
-                                                       ret = RTUSB_SUBMIT_URB(pUrb);
-                                                       if (ret != 0) { /* fail */
-
-                                                               RTMP_IRQ_LOCK
-                                                                   (&pAd->
-                                                                    BulkInLock,
-                                                                    IrqFlags);
-                                                               pRxContext->
-                                                                   InUse =
-                                                                   FALSE;
-                                                               pRxContext->
-                                                                   IRPPending =
-                                                                   FALSE;
-                                                               pAd->
-                                                                   PendingRx--;
-                                                               pAd->
-                                                                   BulkInReq--;
-                                                               RTMP_IRQ_UNLOCK
-                                                                   (&pAd->
-                                                                    BulkInLock,
-                                                                    IrqFlags);
-                                                               DBGPRINT
-                                                                   (RT_DEBUG_ERROR,
-                                                                    ("CMDTHREAD_RESET_BULK_IN: Submit Rx URB failed(%d), status=%d\n",
-                                                                     ret,
-                                                                     pUrb->
-                                                                     status));
-                                                       } else {        /* success */
-                                                               /*DBGPRINT(RT_DEBUG_TRACE, ("BIDone, Pend=%d,BIIdx=%d,BIRIdx=%d!\n", */
-                                                               /*                                                      pAd->PendingRx, pAd->NextRxBulkInIndex, pAd->NextRxBulkInReadIndex)); */
-                                                               DBGPRINT_RAW
-                                                                   (RT_DEBUG_TRACE,
-                                                                    ("CMDTHREAD_RESET_BULK_IN: Submit Rx URB Done, status=%d!\n",
-                                                                     pUrb->
-                                                                     status));
-                                                               ASSERT((pRxContext->InUse == pRxContext->IRPPending));
-                                                       }
-                                               }
-
-                                       } else {
-                                               /* Card must be removed */
-                                               if (NT_SUCCESS(ntStatus) !=
-                                                   TRUE) {
-                                                       RTMP_SET_FLAG(pAd,
-                                                                     fRTMP_ADAPTER_NIC_NOT_EXIST);
-                                                       DBGPRINT_RAW
-                                                           (RT_DEBUG_ERROR,
-                                                            ("CMDTHREAD_RESET_BULK_IN: Read Register Failed!Card must be removed!!\n\n"));
-                                               } else {
-                                                       DBGPRINT_RAW
-                                                           (RT_DEBUG_ERROR,
-                                                            ("CMDTHREAD_RESET_BULK_IN: Cannot do bulk in because flags(0x%lx) on !\n",
-                                                             pAd->Flags));
-                                               }
-                                       }
-                               }
-                               DBGPRINT_RAW(RT_DEBUG_TRACE,
-                                            ("CmdThread : CMDTHREAD_RESET_BULK_IN <===\n"));
-                               break;
-
-                       case CMDTHREAD_SET_ASIC_WCID:
-                               {
-                                       struct rt_set_asic_wcid SetAsicWcid;
-                                       u16 offset;
-                                       u32 MACValue, MACRValue = 0;
-                                       SetAsicWcid =
-                                           *((struct rt_set_asic_wcid *)(pData));
-
-                                       if (SetAsicWcid.WCID >=
-                                           MAX_LEN_OF_MAC_TABLE)
-                                               return;
-
-                                       offset =
-                                           MAC_WCID_BASE +
-                                           ((u8)SetAsicWcid.WCID) *
-                                           HW_WCID_ENTRY_SIZE;
-
-                                       DBGPRINT_RAW(RT_DEBUG_TRACE,
-                                                    ("CmdThread : CMDTHREAD_SET_ASIC_WCID : WCID = %ld, SetTid  = %lx, DeleteTid = %lx.\n",
-                                                     SetAsicWcid.WCID,
-                                                     SetAsicWcid.SetTid,
-                                                     SetAsicWcid.DeleteTid));
-                                       MACValue =
-                                           (pAd->MacTab.
-                                            Content[SetAsicWcid.WCID].
-                                            Addr[3] << 24) +
-                                           (pAd->MacTab.
-                                            Content[SetAsicWcid.WCID].
-                                            Addr[2] << 16) +
-                                           (pAd->MacTab.
-                                            Content[SetAsicWcid.WCID].
-                                            Addr[1] << 8) +
-                                           (pAd->MacTab.
-                                            Content[SetAsicWcid.WCID].Addr[0]);
-                                       DBGPRINT_RAW(RT_DEBUG_TRACE,
-                                                    ("1-MACValue= %x,\n",
-                                                     MACValue));
-                                       RTUSBWriteMACRegister(pAd, offset,
-                                                             MACValue);
-                                       /* Read bitmask */
-                                       RTUSBReadMACRegister(pAd, offset + 4,
-                                                            &MACRValue);
-                                       if (SetAsicWcid.DeleteTid != 0xffffffff)
-                                               MACRValue &=
-                                                   (~SetAsicWcid.DeleteTid);
-                                       if (SetAsicWcid.SetTid != 0xffffffff)
-                                               MACRValue |=
-                                                   (SetAsicWcid.SetTid);
-                                       MACRValue &= 0xffff0000;
-
-                                       MACValue =
-                                           (pAd->MacTab.
-                                            Content[SetAsicWcid.WCID].
-                                            Addr[5] << 8) +
-                                           pAd->MacTab.Content[SetAsicWcid.
-                                                               WCID].Addr[4];
-                                       MACValue |= MACRValue;
-                                       RTUSBWriteMACRegister(pAd, offset + 4,
-                                                             MACValue);
-
-                                       DBGPRINT_RAW(RT_DEBUG_TRACE,
-                                                    ("2-MACValue= %x,\n",
-                                                     MACValue));
-                               }
-                               break;
-
-                       case CMDTHREAD_SET_ASIC_WCID_CIPHER:
-                               {
-                                       struct rt_set_asic_wcid_attri SetAsicWcidAttri;
-                                       u16 offset;
-                                       u32 MACRValue = 0;
-                                       SHAREDKEY_MODE_STRUC csr1;
-                                       SetAsicWcidAttri =
-                                           *((struct rt_set_asic_wcid_attri *)
-                                             (pData));
-
-                                       if (SetAsicWcidAttri.WCID >=
-                                           MAX_LEN_OF_MAC_TABLE)
-                                               return;
-
-                                       offset =
-                                           MAC_WCID_ATTRIBUTE_BASE +
-                                           ((u8)SetAsicWcidAttri.WCID) *
-                                           HW_WCID_ATTRI_SIZE;
-
-                                       DBGPRINT_RAW(RT_DEBUG_TRACE,
-                                                    ("Cmd : CMDTHREAD_SET_ASIC_WCID_CIPHER : WCID = %ld, Cipher = %lx.\n",
-                                                     SetAsicWcidAttri.WCID,
-                                                     SetAsicWcidAttri.Cipher));
-                                       /* Read bitmask */
-                                       RTUSBReadMACRegister(pAd, offset,
-                                                            &MACRValue);
-                                       MACRValue = 0;
-                                       MACRValue |=
-                                           (((u8)SetAsicWcidAttri.
-                                             Cipher) << 1);
-
-                                       RTUSBWriteMACRegister(pAd, offset,
-                                                             MACRValue);
-                                       DBGPRINT_RAW(RT_DEBUG_TRACE,
-                                                    ("2-offset = %x , MACValue= %x,\n",
-                                                     offset, MACRValue));
-
-                                       offset =
-                                           PAIRWISE_IVEIV_TABLE_BASE +
-                                           ((u8)SetAsicWcidAttri.WCID) *
-                                           HW_IVEIV_ENTRY_SIZE;
-                                       MACRValue = 0;
-                                       if ((SetAsicWcidAttri.Cipher <=
-                                            CIPHER_WEP128))
-                                               MACRValue |=
-                                                   (pAd->StaCfg.
-                                                    DefaultKeyId << 30);
-                                       else
-                                               MACRValue |= (0x20000000);
-                                       RTUSBWriteMACRegister(pAd, offset,
-                                                             MACRValue);
-                                       DBGPRINT_RAW(RT_DEBUG_TRACE,
-                                                    ("2-offset = %x , MACValue= %x,\n",
-                                                     offset, MACRValue));
-
-                                       /* */
-                                       /* Update cipher algorithm. WSTA always use BSS0 */
-                                       /* */
-                                       /* for adhoc mode only ,because wep status slow than add key, when use zero config */
-                                       if (pAd->StaCfg.BssType == BSS_ADHOC) {
-                                               offset =
-                                                   MAC_WCID_ATTRIBUTE_BASE;
-
-                                               RTUSBReadMACRegister(pAd,
-                                                                    offset,
-                                                                    &MACRValue);
-                                               MACRValue &= (~0xe);
-                                               MACRValue |=
-                                                   (((u8)SetAsicWcidAttri.
-                                                     Cipher) << 1);
-
-                                               RTUSBWriteMACRegister(pAd,
-                                                                     offset,
-                                                                     MACRValue);
-
-                                               /*Update group key cipher,,because wep status slow than add key, when use zero config */
-                                               RTUSBReadMACRegister(pAd,
-                                                                    SHARED_KEY_MODE_BASE
-                                                                    +
-                                                                    4 * (0 /
-                                                                         2),
-                                                                    &csr1.
-                                                                    word);
-
-                                               csr1.field.Bss0Key0CipherAlg =
-                                                   SetAsicWcidAttri.Cipher;
-                                               csr1.field.Bss0Key1CipherAlg =
-                                                   SetAsicWcidAttri.Cipher;
-
-                                               RTUSBWriteMACRegister(pAd,
-                                                                     SHARED_KEY_MODE_BASE
-                                                                     +
-                                                                     4 * (0 /
-                                                                          2),
-                                                                     csr1.
-                                                                     word);
-                                       }
-                               }
-                               break;
-
-/*Benson modified for USB interface, avoid in interrupt when write key, 20080724 --> */
-                       case RT_CMD_SET_KEY_TABLE:      /*General call for AsicAddPairwiseKeyEntry() */
-                               {
-                                       struct rt_add_pairwise_key_entry KeyInfo;
-                                       KeyInfo =
-                                           *((struct rt_add_pairwise_key_entry *)
-                                             (pData));
-                                       AsicAddPairwiseKeyEntry(pAd,
-                                                               KeyInfo.MacAddr,
-                                                               (u8)KeyInfo.
-                                                               MacTabMatchWCID,
-                                                               &KeyInfo.
-                                                               CipherKey);
-                               }
-                               break;
-
-                       case RT_CMD_SET_RX_WCID_TABLE:  /*General call for RTMPAddWcidAttributeEntry() */
-                               {
-                                       struct rt_mac_table_entry *pEntry;
-                                       u8 KeyIdx = 0;
-                                       u8 CipherAlg = CIPHER_NONE;
-                                       u8 ApIdx = BSS0;
-
-                                       pEntry = (struct rt_mac_table_entry *)(pData);
-
-                                       RTMPAddWcidAttributeEntry(pAd,
-                                                                 ApIdx,
-                                                                 KeyIdx,
-                                                                 CipherAlg,
-                                                                 pEntry);
-                               }
-                               break;
-/*Benson modified for USB interface, avoid in interrupt when write key, 20080724 <-- */
-
-                       case CMDTHREAD_SET_CLIENT_MAC_ENTRY:
-                               {
-                                       struct rt_mac_table_entry *pEntry;
-                                       pEntry = (struct rt_mac_table_entry *)pData;
-
-                                       {
-                                               AsicRemovePairwiseKeyEntry(pAd,
-                                                                          pEntry->
-                                                                          apidx,
-                                                                          (u8)
-                                                                          pEntry->
-                                                                          Aid);
-                                               if ((pEntry->AuthMode <=
-                                                    Ndis802_11AuthModeAutoSwitch)
-                                                   && (pEntry->WepStatus ==
-                                                       Ndis802_11Encryption1Enabled))
-                                               {
-                                                       u32 uIV = 1;
-                                                       u8 *ptr;
-
-                                                       ptr = (u8 *)& uIV;
-                                                       *(ptr + 3) =
-                                                           (pAd->StaCfg.
-                                                            DefaultKeyId << 6);
-                                                       AsicUpdateWCIDIVEIV(pAd,
-                                                                           pEntry->
-                                                                           Aid,
-                                                                           uIV,
-                                                                           0);
-                                                       AsicUpdateWCIDAttribute
-                                                           (pAd, pEntry->Aid,
-                                                            BSS0,
-                                                            pAd->
-                                                            SharedKey[BSS0]
-                                                            [pAd->StaCfg.
-                                                             DefaultKeyId].
-                                                            CipherAlg, FALSE);
-                                               } else if (pEntry->AuthMode ==
-                                                          Ndis802_11AuthModeWPANone)
-                                               {
-                                                       u32 uIV = 1;
-                                                       u8 *ptr;
-
-                                                       ptr = (u8 *)& uIV;
-                                                       *(ptr + 3) =
-                                                           (pAd->StaCfg.
-                                                            DefaultKeyId << 6);
-                                                       AsicUpdateWCIDIVEIV(pAd,
-                                                                           pEntry->
-                                                                           Aid,
-                                                                           uIV,
-                                                                           0);
-                                                       AsicUpdateWCIDAttribute
-                                                           (pAd, pEntry->Aid,
-                                                            BSS0,
-                                                            pAd->
-                                                            SharedKey[BSS0]
-                                                            [pAd->StaCfg.
-                                                             DefaultKeyId].
-                                                            CipherAlg, FALSE);
-                                               } else {
-                                                       /* */
-                                                       /* Other case, disable engine. */
-                                                       /* Don't worry WPA key, we will add WPA Key after 4-Way handshaking. */
-                                                       /* */
-                                                       u16 offset;
-                                                       offset =
-                                                           MAC_WCID_ATTRIBUTE_BASE
-                                                           +
-                                                           (pEntry->Aid *
-                                                            HW_WCID_ATTRI_SIZE);
-                                                       /* RX_PKEY_MODE:0 for no security; RX_KEY_TAB:0 for shared key table; BSS_IDX:0 */
-                                                       RTUSBWriteMACRegister
-                                                           (pAd, offset, 0);
-                                               }
-                                       }
-
-                                       AsicUpdateRxWCIDTable(pAd, pEntry->Aid,
-                                                             pEntry->Addr);
-                                       DBGPRINT(RT_DEBUG_TRACE,
-                                               ("UpdateRxWCIDTable(): Aid=%d, "
-                                                       "Addr=%pM!\n",
-                                                       pEntry->Aid,
-                                                       pEntry->Addr));
-                               }
-                               break;
-
-/* add by johnli, fix "in_interrupt" error when call "MacTableDeleteEntry" in Rx tasklet */
-                       case CMDTHREAD_UPDATE_PROTECT:
-                               {
-                                       AsicUpdateProtect(pAd, 0,
-                                                         (ALLN_SETPROTECT),
-                                                         TRUE, 0);
-                               }
-                               break;
-/* end johnli */
-
-                       case OID_802_11_ADD_WEP:
-                               {
-                                       u32 i;
-                                       u32 KeyIdx;
-                                       struct rt_ndis_802_11_wep *pWepKey;
-
-                                       DBGPRINT(RT_DEBUG_TRACE,
-                                                ("CmdThread::OID_802_11_ADD_WEP  \n"));
-
-                                       pWepKey = (struct rt_ndis_802_11_wep *)pData;
-                                       KeyIdx = pWepKey->KeyIndex & 0x0fffffff;
-
-                                       /* it is a shared key */
-                                       if ((KeyIdx >= 4)
-                                           || ((pWepKey->KeyLength != 5)
-                                               && (pWepKey->KeyLength !=
-                                                   13))) {
-                                               NdisStatus =
-                                                   NDIS_STATUS_INVALID_DATA;
-                                               DBGPRINT(RT_DEBUG_ERROR,
-                                                        ("CmdThread::OID_802_11_ADD_WEP, INVALID_DATA!!\n"));
-                                       } else {
-                                               u8 CipherAlg;
-                                               pAd->SharedKey[BSS0][KeyIdx].
-                                                   KeyLen =
-                                                   (u8)pWepKey->KeyLength;
-                                               NdisMoveMemory(pAd->
-                                                              SharedKey[BSS0]
-                                                              [KeyIdx].Key,
-                                                              &pWepKey->
-                                                              KeyMaterial,
-                                                              pWepKey->
-                                                              KeyLength);
-                                               CipherAlg =
-                                                   (pAd->
-                                                    SharedKey[BSS0][KeyIdx].
-                                                    KeyLen ==
-                                                    5) ? CIPHER_WEP64 :
-                                                   CIPHER_WEP128;
-
-                                               /* */
-                                               /* Change the WEP cipher to CKIP cipher if CKIP KP on. */
-                                               /* Funk UI or Meetinghouse UI will add ckip key from this path. */
-                                               /* */
-
-                                               if (pAd->OpMode == OPMODE_STA) {
-                                                       pAd->MacTab.
-                                                           Content[BSSID_WCID].
-                                                           PairwiseKey.
-                                                           CipherAlg =
-                                                           pAd->
-                                                           SharedKey[BSS0]
-                                                           [KeyIdx].CipherAlg;
-                                                       pAd->MacTab.
-                                                           Content[BSSID_WCID].
-                                                           PairwiseKey.KeyLen =
-                                                           pAd->
-                                                           SharedKey[BSS0]
-                                                           [KeyIdx].KeyLen;
-                                               }
-                                               pAd->SharedKey[BSS0][KeyIdx].
-                                                   CipherAlg = CipherAlg;
-                                               if (pWepKey->
-                                                   KeyIndex & 0x80000000) {
-                                                       /* Default key for tx (shared key) */
-                                                       u8 IVEIV[8];
-                                                       u32 WCIDAttri, Value;
-                                                       u16 offset, offset2;
-                                                       NdisZeroMemory(IVEIV,
-                                                                      8);
-                                                       pAd->StaCfg.
-                                                           DefaultKeyId =
-                                                           (u8)KeyIdx;
-                                                       /* Add BSSID to WCTable. because this is Tx wep key. */
-                                                       /* WCID Attribute UDF:3, BSSIdx:3, Alg:3, Keytable:1=PAIRWISE KEY, BSSIdx is 0 */
-                                                       WCIDAttri =
-                                                           (CipherAlg << 1) |
-                                                           SHAREDKEYTABLE;
-
-                                                       offset =
-                                                           MAC_WCID_ATTRIBUTE_BASE
-                                                           +
-                                                           (BSSID_WCID *
-                                                            HW_WCID_ATTRI_SIZE);
-                                                       RTUSBWriteMACRegister
-                                                           (pAd, offset,
-                                                            WCIDAttri);
-                                                       /* 1. IV/EIV */
-                                                       /* Specify key index to find shared key. */
-                                                       IVEIV[3] = (u8)(KeyIdx << 6);   /*WEP Eiv bit off. groupkey index is not 0 */
-                                                       offset =
-                                                           PAIRWISE_IVEIV_TABLE_BASE
-                                                           +
-                                                           (BSS0Mcast_WCID *
-                                                            HW_IVEIV_ENTRY_SIZE);
-                                                       offset2 =
-                                                           PAIRWISE_IVEIV_TABLE_BASE
-                                                           +
-                                                           (BSSID_WCID *
-                                                            HW_IVEIV_ENTRY_SIZE);
-                                                       for (i = 0; i < 8;) {
-                                                               Value =
-                                                                   IVEIV[i];
-                                                               Value +=
-                                                                   (IVEIV
-                                                                    [i +
-                                                                     1] << 8);
-                                                               Value +=
-                                                                   (IVEIV
-                                                                    [i +
-                                                                     2] << 16);
-                                                               Value +=
-                                                                   (IVEIV
-                                                                    [i +
-                                                                     3] << 24);
-                                                               RTUSBWriteMACRegister
-                                                                   (pAd,
-                                                                    offset + i,
-                                                                    Value);
-                                                               RTUSBWriteMACRegister
-                                                                   (pAd,
-                                                                    offset2 +
-                                                                    i, Value);
-                                                               i += 4;
-                                                       }
-
-                                                       /* 2. WCID Attribute UDF:3, BSSIdx:3, Alg:3, Keytable:use share key, BSSIdx is 0 */
-                                                       WCIDAttri =
-                                                           (pAd->
-                                                            SharedKey[BSS0]
-                                                            [KeyIdx].
-                                                            CipherAlg << 1) |
-                                                           SHAREDKEYTABLE;
-                                                       offset =
-                                                           MAC_WCID_ATTRIBUTE_BASE
-                                                           +
-                                                           (BSS0Mcast_WCID *
-                                                            HW_WCID_ATTRI_SIZE);
-                                                       DBGPRINT(RT_DEBUG_TRACE,
-                                                                ("BSS0Mcast_WCID : offset = %x, WCIDAttri = %x\n",
-                                                                 offset,
-                                                                 WCIDAttri));
-                                                       RTUSBWriteMACRegister
-                                                           (pAd, offset,
-                                                            WCIDAttri);
-
-                                               }
-                                               AsicAddSharedKeyEntry(pAd, BSS0,
-                                                                     (u8)
-                                                                     KeyIdx,
-                                                                     CipherAlg,
-                                                                     pWepKey->
-                                                                     KeyMaterial,
-                                                                     NULL,
-                                                                     NULL);
-                                               DBGPRINT(RT_DEBUG_TRACE,
-                                                        ("CmdThread::OID_802_11_ADD_WEP (KeyIdx=%d, Len=%d-byte)\n",
-                                                         KeyIdx,
-                                                         pWepKey->KeyLength));
-                                       }
-                               }
-                               break;
-
-                       case CMDTHREAD_802_11_COUNTER_MEASURE:
-                               break;
-
-                       case CMDTHREAD_SET_GROUP_KEY:
-                               WpaStaGroupKeySetting(pAd);
-                               break;
-
-                       case CMDTHREAD_SET_PAIRWISE_KEY:
-                               WpaStaPairwiseKeySetting(pAd);
-                               break;
-
-                       case CMDTHREAD_SET_PSM_BIT:
-                               {
-                                       u16 *pPsm = (u16 *) pData;
-                                       MlmeSetPsmBit(pAd, *pPsm);
-                               }
-                               break;
-                       case CMDTHREAD_FORCE_WAKE_UP:
-                               AsicForceWakeup(pAd, TRUE);
-                               break;
-
-                       default:
-                               DBGPRINT(RT_DEBUG_ERROR,
-                                        ("--> Control Thread !! ERROR !! Unknown(cmdqelmt->command=0x%x) !! \n",
-                                         cmdqelmt->command));
-                               break;
-                       }
-               }
-
-               if (cmdqelmt->CmdFromNdis == TRUE) {
-                       if (cmdqelmt->buffer != NULL)
-                               os_free_mem(pAd, cmdqelmt->buffer);
-                       os_free_mem(pAd, cmdqelmt);
-               } else {
-                       if ((cmdqelmt->buffer != NULL)
-                           && (cmdqelmt->bufferlength != 0))
-                               os_free_mem(pAd, cmdqelmt->buffer);
-                       os_free_mem(pAd, cmdqelmt);
-               }
-       }                       /* end of while */
-}
-
-#endif /* RTMP_MAC_USB // */
diff --git a/drivers/staging/rt2870/common/spectrum.c b/drivers/staging/rt2870/common/spectrum.c
deleted file mode 100644 (file)
index 1cf2c26..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../rt2860/common/spectrum.c"
diff --git a/drivers/staging/rt2870/dfs.h b/drivers/staging/rt2870/dfs.h
deleted file mode 100644 (file)
index 1fdbd7b..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../rt2860/dfs.h"
diff --git a/drivers/staging/rt2870/md5.h b/drivers/staging/rt2870/md5.h
deleted file mode 100644 (file)
index d60cd05..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../rt2860/md5.h"
diff --git a/drivers/staging/rt2870/mlme.h b/drivers/staging/rt2870/mlme.h
deleted file mode 100644 (file)
index 58753ac..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../rt2860/mlme.h"
diff --git a/drivers/staging/rt2870/oid.h b/drivers/staging/rt2870/oid.h
deleted file mode 100644 (file)
index 1223d81..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../rt2860/oid.h"
diff --git a/drivers/staging/rt2870/rt28xx.h b/drivers/staging/rt2870/rt28xx.h
deleted file mode 100644 (file)
index 29bad95..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../rt2860/rt28xx.h"
diff --git a/drivers/staging/rt2870/rt_config.h b/drivers/staging/rt2870/rt_config.h
deleted file mode 100644 (file)
index 1f6d6ed..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../rt2860/rt_config.h"
diff --git a/drivers/staging/rt2870/rt_linux.c b/drivers/staging/rt2870/rt_linux.c
deleted file mode 100644 (file)
index 88c697b..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../rt2860/rt_linux.c"
diff --git a/drivers/staging/rt2870/rt_linux.h b/drivers/staging/rt2870/rt_linux.h
deleted file mode 100644 (file)
index b2aeafb..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../rt2860/rt_linux.h"
diff --git a/drivers/staging/rt2870/rt_main_dev.c b/drivers/staging/rt2870/rt_main_dev.c
deleted file mode 100644 (file)
index 121e163..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../rt2860/rt_main_dev.c"
diff --git a/drivers/staging/rt2870/rt_profile.c b/drivers/staging/rt2870/rt_profile.c
deleted file mode 100644 (file)
index 15988c5..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../rt2860/rt_profile.c"
diff --git a/drivers/staging/rt2870/rt_usb.c b/drivers/staging/rt2870/rt_usb.c
deleted file mode 100644 (file)
index 5e02d4c..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../rt2860/rt_usb.c"
diff --git a/drivers/staging/rt2870/rtmp.h b/drivers/staging/rt2870/rtmp.h
deleted file mode 100644 (file)
index e5ef89f..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../rt2860/rtmp.h"
diff --git a/drivers/staging/rt2870/rtmp_ckipmic.h b/drivers/staging/rt2870/rtmp_ckipmic.h
deleted file mode 100644 (file)
index 0e7f1df..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../rt2860/rtmp_ckipmic.h"
diff --git a/drivers/staging/rt2870/rtmp_def.h b/drivers/staging/rt2870/rtmp_def.h
deleted file mode 100644 (file)
index 839d791..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../rt2860/rtmp_def.h"
diff --git a/drivers/staging/rt2870/rtmp_type.h b/drivers/staging/rt2870/rtmp_type.h
deleted file mode 100644 (file)
index fbf97d0..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../rt2860/rtmp_type.h"
diff --git a/drivers/staging/rt2870/spectrum.h b/drivers/staging/rt2870/spectrum.h
deleted file mode 100644 (file)
index 8aa23a1..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../rt2860/spectrum.h"
diff --git a/drivers/staging/rt2870/spectrum_def.h b/drivers/staging/rt2870/spectrum_def.h
deleted file mode 100644 (file)
index a65f551..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../rt2860/spectrum_def.h"
diff --git a/drivers/staging/rt2870/sta/aironet.c b/drivers/staging/rt2870/sta/aironet.c
deleted file mode 100644 (file)
index 72b7f2e..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../rt2860/sta/aironet.c"
diff --git a/drivers/staging/rt2870/sta/assoc.c b/drivers/staging/rt2870/sta/assoc.c
deleted file mode 100644 (file)
index 46564d7..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../rt2860/sta/assoc.c"
diff --git a/drivers/staging/rt2870/sta/auth.c b/drivers/staging/rt2870/sta/auth.c
deleted file mode 100644 (file)
index 57632f9..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../rt2860/sta/auth.c"
diff --git a/drivers/staging/rt2870/sta/auth_rsp.c b/drivers/staging/rt2870/sta/auth_rsp.c
deleted file mode 100644 (file)
index 783e266..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../rt2860/sta/auth_rsp.c"
diff --git a/drivers/staging/rt2870/sta/connect.c b/drivers/staging/rt2870/sta/connect.c
deleted file mode 100644 (file)
index f6c7bbf..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../rt2860/sta/connect.c"
diff --git a/drivers/staging/rt2870/sta/rtmp_data.c b/drivers/staging/rt2870/sta/rtmp_data.c
deleted file mode 100644 (file)
index b67e069..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../rt2860/sta/rtmp_data.c"
diff --git a/drivers/staging/rt2870/sta/sanity.c b/drivers/staging/rt2870/sta/sanity.c
deleted file mode 100644 (file)
index f1f2333..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../rt2860/sta/sanity.c"
diff --git a/drivers/staging/rt2870/sta/sync.c b/drivers/staging/rt2870/sta/sync.c
deleted file mode 100644 (file)
index 66c8772..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../rt2860/sta/sync.c"
diff --git a/drivers/staging/rt2870/sta/wpa.c b/drivers/staging/rt2870/sta/wpa.c
deleted file mode 100644 (file)
index 57a2eb2..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../rt2860/sta/wpa.c"
diff --git a/drivers/staging/rt2870/sta_ioctl.c b/drivers/staging/rt2870/sta_ioctl.c
deleted file mode 100644 (file)
index 3553a6c..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../rt2860/sta_ioctl.c"
diff --git a/drivers/staging/rt2870/usb_main_dev.c b/drivers/staging/rt2870/usb_main_dev.c
deleted file mode 100644 (file)
index 6e63bc5..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../rt2860/usb_main_dev.c"
diff --git a/drivers/staging/rt2870/wpa.h b/drivers/staging/rt2870/wpa.h
deleted file mode 100644 (file)
index 7125072..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../rt2860/wpa.h"
index 432cf8a7605f5ea4ea7011adf365a742a5e63819..1f4d147c4b68bd167373aeaa3db36bf50bf19d19 100644 (file)
@@ -76,7 +76,7 @@ struct ieee_param {
                        u8 reserved[32];
                        u8 data[0];
                } wpa_ie;
-               struct{
+               struct {
                        int command;
                        int reason_code;
                } mlme;
@@ -149,11 +149,11 @@ struct    ieee80211_hdr_qos {
 struct  ieee80211_hdr_3addr_qos {
        u16 frame_ctl;
        u16 duration_id;
-       u8 addr1[ETH_ALEN];
-       u8 addr2[ETH_ALEN];
-       u8 addr3[ETH_ALEN];
+       u8  addr1[ETH_ALEN];
+       u8  addr2[ETH_ALEN];
+       u8  addr3[ETH_ALEN];
        u16 seq_ctl;
-       u16     qc;
+       u16 qc;
 }  __attribute__ ((packed));
 
 struct eapol {
@@ -461,7 +461,7 @@ struct ieee80211_stats {
        uint rx_message_in_bad_msg_fragments;
 };
 
-struct ieee80211_softmac_stats{
+struct ieee80211_softmac_stats {
        uint rx_ass_ok;
        uint rx_ass_err;
        uint rx_probe_rq;
@@ -754,15 +754,17 @@ struct registry_priv;
 u8 *r8712_set_ie(u8 *pbuf, sint index, uint len, u8 *source, uint *frlen);
 u8 *r8712_get_ie(u8*pbuf, sint index, sint *len, sint limit);
 unsigned char *r8712_get_wpa_ie(unsigned char *pie, int *rsn_ie_len, int limit);
-unsigned char *r8712_get_wpa2_ie(unsigned char *pie, int *rsn_ie_len, int limit);
+unsigned char *r8712_get_wpa2_ie(unsigned char *pie, int *rsn_ie_len,
+                                int limit);
 int r8712_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher,
-                      int *pairwise_cipher);
+                       int *pairwise_cipher);
 int r8712_parse_wpa2_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher,
-                       int *pairwise_cipher);
-int r8712_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, u8 *wpa_ie,
-              u16 *wpa_len);
+                       int *pairwise_cipher);
+int r8712_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len,
+                    u8 *wpa_ie, u16 *wpa_len);
 int r8712_get_wps_ie(u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen);
-int r8712_generate_ie(struct registry_priv *pregistrypriv, struct _adapter *padapter);
+int r8712_generate_ie(struct registry_priv *pregistrypriv,
+                     struct _adapter *padapter);
 uint r8712_is_cckrates_included(u8 *rate);
 uint r8712_is_cckratesonly_included(u8 *rate);
 
index 36a2ba5c86f1a1c0b9bdd158b7bf58272b733dda..0e9753b9ed3714cb3a8f3945f5c6cd8d8e57d8c9 100644 (file)
@@ -99,8 +99,8 @@ struct ethhdr {
 };
 
 struct _vlan {
-   unsigned short       h_vlan_TCI;    /* Encapsulates priority and VLAN ID*/
-   unsigned short       h_vlan_encapsulated_proto;
+       unsigned short  h_vlan_TCI;     /* Encapsulates priority and VLAN ID*/
+       unsigned short  h_vlan_encapsulated_proto;
 };
 
 
index 4785a591486cb2741030d701d31a069ff4e72008..f37b0f8d14d4212e6e21569a52b8239e8fbae919 100644 (file)
 #define        IPOPT_TS_PRESPEC        3               /* specified modules only */
 
 struct ip_options {
-  __u32                faddr;                          /* Saved first hop address */
-  unsigned char        optlen;
-  unsigned char srr;
-  unsigned char rr;
-  unsigned char ts;
-  unsigned char is_setbyuser:1,        /* Set by setsockopt?                   */
-               is_data:1,      /* Options in __data, rather than skb   */
-               is_strictroute:1, /* Strict source route                */
-               srr_is_hit:1,   /* Packet destination addr was our one  */
-               is_changed:1,   /* IP checksum more not valid           */
-               rr_needaddr:1,  /* Need to record addr of outgoing dev  */
-               ts_needtime:1,  /* Need to record timestamp             */
-               ts_needaddr:1;  /* Need to record addr of outgoing dev  */
-  unsigned char router_alert;
-  unsigned char __pad1;
-  unsigned char __pad2;
-  unsigned char __data[0];
+       __u32           faddr;                  /* Saved first hop address */
+       unsigned char   optlen;
+       unsigned char srr;
+       unsigned char rr;
+       unsigned char ts;
+       unsigned char is_setbyuser:1,   /* Set by setsockopt?                 */
+                     is_data:1,        /* Options in __data, rather than skb */
+                     is_strictroute:1, /* Strict source route                */
+                     srr_is_hit:1,     /* Packet destination addr was our one*/
+                     is_changed:1,     /* IP checksum more not valid         */
+                     rr_needaddr:1,    /* Need to record addr of outgoing dev*/
+                     ts_needtime:1,    /* Need to record timestamp           */
+                     ts_needaddr:1;    /* Need to record addr of outgoing dev*/
+       unsigned char router_alert;
+       unsigned char __pad1;
+       unsigned char __pad2;
+       unsigned char __data[0];
 };
 
 #define optlength(opt) (sizeof(struct ip_options) + opt->optlen)
index 7013a4980802c92f42ac79c7103481e2b8f726b1..968e78765a3bc613884bdd075a9d941e52cfb0ce 100644 (file)
@@ -9,8 +9,8 @@ void r8712_os_indicate_disconnect(struct _adapter *adapter);
 void r8712_os_indicate_connect(struct _adapter *adapter);
 void r8712_report_sec_ie(struct _adapter *adapter, u8 authmode, u8 *sec_ie);
 int r8712_recv_indicatepkts_in_order(struct _adapter *adapter,
-                                    struct recv_reorder_ctrl *precvreorder_ctrl,
-                                    int bforced);
+                               struct recv_reorder_ctrl *precvreorder_ctrl,
+                               int bforced);
 void r8712_indicate_wx_assoc_event(struct _adapter *padapter);
 void r8712_indicate_wx_disassoc_event(struct _adapter *padapter);
 
index 36eeb5a1b5a567dde592c22d9ec510a3624af4dc..3d3f73c5cd5bc47c2681bc9879bc5702fc00fff9 100644 (file)
@@ -145,7 +145,8 @@ static inline u32 is_list_empty(struct list_head *phead)
                return false;
 }
 
-static inline void list_insert_tail(struct list_head *plist, struct list_head *phead)
+static inline void list_insert_tail(struct list_head *plist,
+                                   struct list_head *phead)
 {
        list_add_tail(plist, phead);
 }
index b23dd6b159f4b24a6d0cd48c18af0480066b0b10..60a54dd90ff1587addfb3711f344b16c8fe1335c 100644 (file)
@@ -12,7 +12,8 @@ s32  r8712_recv_entry(union recv_frame *precv_frame);
 void r8712_recv_indicatepkt(struct _adapter *adapter,
                            union recv_frame *precv_frame);
 void r8712_handle_tkip_mic_err(struct _adapter *padapter, u8 bgroup);
-int r8712_init_recv_priv(struct recv_priv *precvpriv, struct _adapter *padapter);
+int r8712_init_recv_priv(struct recv_priv *precvpriv,
+                        struct _adapter *padapter);
 void r8712_free_recv_priv(struct recv_priv *precvpriv);
 int r8712_os_recv_resource_alloc(struct _adapter *padapter,
                                 union recv_frame *precvframe);
@@ -24,4 +25,3 @@ void r8712_os_read_port(struct _adapter *padapter, struct recv_buf *precvbuf);
 void r8712_init_recv_timer(struct recv_reorder_ctrl *preorder_ctrl);
 
 #endif
-
index 48408f72546ceb5552b7904f14d3293b12b32422..27316934b1a396e92dcfc5c6d4216b1e97ad7ee6 100644 (file)
@@ -5,33 +5,33 @@ void r8712_event_handle(struct _adapter *padapter, uint *peventbuf);
 void r8712_got_addbareq_event_callback(struct _adapter *adapter , u8 *pbuf);
 
 enum rtl8712_c2h_event {
-       GEN_EVT_CODE(_Read_MACREG) = 0, /*0*/
+       GEN_EVT_CODE(_Read_MACREG) = 0,         /*0*/
        GEN_EVT_CODE(_Read_BBREG),
        GEN_EVT_CODE(_Read_RFREG),
        GEN_EVT_CODE(_Read_EEPROM),
        GEN_EVT_CODE(_Read_EFUSE),
-       GEN_EVT_CODE(_Read_CAM),                        /*5*/
+       GEN_EVT_CODE(_Read_CAM),                /*5*/
        GEN_EVT_CODE(_Get_BasicRate),
        GEN_EVT_CODE(_Get_DataRate),
-       GEN_EVT_CODE(_Survey),   /*8*/
-       GEN_EVT_CODE(_SurveyDone),       /*9*/
+       GEN_EVT_CODE(_Survey),                  /*8*/
+       GEN_EVT_CODE(_SurveyDone),              /*9*/
 
-       GEN_EVT_CODE(_JoinBss) , /*10*/
+       GEN_EVT_CODE(_JoinBss),                 /*10*/
        GEN_EVT_CODE(_AddSTA),
        GEN_EVT_CODE(_DelSTA),
-       GEN_EVT_CODE(_AtimDone) ,
+       GEN_EVT_CODE(_AtimDone),
        GEN_EVT_CODE(_TX_Report),
-       GEN_EVT_CODE(_CCX_Report),                      /*15*/
+       GEN_EVT_CODE(_CCX_Report),              /*15*/
        GEN_EVT_CODE(_DTM_Report),
        GEN_EVT_CODE(_TX_Rate_Statistics),
        GEN_EVT_CODE(_C2HLBK),
        GEN_EVT_CODE(_FWDBG),
-       GEN_EVT_CODE(_C2HFEEDBACK),               /*20*/
+       GEN_EVT_CODE(_C2HFEEDBACK),             /*20*/
        GEN_EVT_CODE(_ADDBA),
        GEN_EVT_CODE(_C2HBCN),
        GEN_EVT_CODE(_ReportPwrState),          /*filen: only for PCIE, USB*/
        GEN_EVT_CODE(_WPS_PBC),                 /*24*/
-       GEN_EVT_CODE(_ADDBAReq_Report), /*25*/
+       GEN_EVT_CODE(_ADDBAReq_Report),         /*25*/
        MAX_C2HEVT
 };
 
@@ -48,7 +48,8 @@ static struct fwevent wlanevents[] = {
        {0, NULL},
        {0, NULL},
        {0, &r8712_survey_event_callback},              /*8*/
-       {sizeof(struct surveydone_event), &r8712_surveydone_event_callback},/*9*/
+       {sizeof(struct surveydone_event),
+               &r8712_surveydone_event_callback},      /*9*/
 
        {0, &r8712_joinbss_event_callback},             /*10*/
        {sizeof(struct stassoc_event), &r8712_stassoc_event_callback},
@@ -59,8 +60,8 @@ static struct fwevent wlanevents[] = {
        {0, NULL},
        {0, NULL},
        {0, NULL},
-       {0, NULL}, /*fwdbg_event_callback},*/
-       {0, NULL},       /*20*/
+       {0, NULL},      /*fwdbg_event_callback},*/
+       {0, NULL},      /*20*/
        {0, NULL},
        {0, NULL},
        {0, &r8712_cpwm_event_callback},
index 13df2001e9adfb4442844ab3a4c5582adcd3e567..66baa87cd4b04de94919e1bd51dbea64c12f991a 100644 (file)
@@ -21,13 +21,13 @@ enum RTL871X_HCI_TYPE {
        RTL8712_USB,
 };
 
-enum RTL8712_RF_CONFIG{
+enum RTL8712_RF_CONFIG {
        RTL8712_RF_1T1R,
        RTL8712_RF_1T2R,
        RTL8712_RF_2T2R
 };
 
-enum _RTL8712_HCI_TYPE_{
+enum _RTL8712_HCI_TYPE_ {
        RTL8712_HCI_TYPE_PCIE = 0x01,
        RTL8712_HCI_TYPE_AP_PCIE = 0x81,
        RTL8712_HCI_TYPE_USB = 0x02,
@@ -40,62 +40,62 @@ enum _RTL8712_HCI_TYPE_{
 
 struct fw_priv {   /*8-bytes alignment required*/
        /*--- long word 0 ----*/
unsigned char  signature_0;  /*0x12: CE product, 0x92: IT product*/
unsigned char  signature_1;  /*0x87: CE product, 0x81: IT product*/
unsigned char  hci_sel;   /*0x81: PCI-AP, 01:PCIe, 02: 92S-U, 0x82: USB-AP,
      unsigned char signature_0;  /*0x12: CE product, 0x92: IT product*/
      unsigned char signature_1;  /*0x87: CE product, 0x81: IT product*/
      unsigned char hci_sel; /*0x81: PCI-AP, 01:PCIe, 02: 92S-U, 0x82: USB-AP,
                            * 0x12: 72S-U, 03:SDIO*/
unsigned char  chip_version; /*the same value as register value*/
unsigned char  customer_ID_0; /*customer  ID low byte*/
unsigned char  customer_ID_1; /*customer  ID high byte*/
unsigned char  rf_config;  /*0x11:  1T1R, 0x12: 1T2R, 0x92: 1T2R turbo,
      unsigned char chip_version; /*the same value as register value*/
      unsigned char customer_ID_0; /*customer  ID low byte*/
      unsigned char customer_ID_1; /*customer  ID high byte*/
      unsigned char rf_config;  /*0x11:  1T1R, 0x12: 1T2R, 0x92: 1T2R turbo,
                             * 0x22: 2T2R*/
unsigned char  usb_ep_num;  /* 4: 4EP, 6: 6EP, 11: 11EP*/
      unsigned char usb_ep_num;  /* 4: 4EP, 6: 6EP, 11: 11EP*/
        /*--- long word 1 ----*/
unsigned char  regulatory_class_0; /*regulatory class bit map 0*/
unsigned char  regulatory_class_1; /*regulatory class bit map 1*/
unsigned char  regulatory_class_2; /*regulatory class bit map 2*/
unsigned char  regulatory_class_3; /*regulatory class bit map 3*/
unsigned char  rfintfs;    /* 0:SWSI, 1:HWSI, 2:HWPI*/
unsigned char  def_nettype;
unsigned char  turboMode;
unsigned char  lowPowerMode;/* 0: noral mode, 1: low power mode*/
      unsigned char regulatory_class_0; /*regulatory class bit map 0*/
      unsigned char regulatory_class_1; /*regulatory class bit map 1*/
      unsigned char regulatory_class_2; /*regulatory class bit map 2*/
      unsigned char regulatory_class_3; /*regulatory class bit map 3*/
      unsigned char rfintfs;    /* 0:SWSI, 1:HWSI, 2:HWPI*/
      unsigned char def_nettype;
      unsigned char turboMode;
      unsigned char lowPowerMode;/* 0: noral mode, 1: low power mode*/
        /*--- long word 2 ----*/
unsigned char  lbk_mode; /*0x00: normal, 0x03: MACLBK, 0x01: PHYLBK*/
unsigned char  mp_mode; /* 1: for MP use, 0: for normal driver */
unsigned char  vcsType; /* 0:off 1:on 2:auto */
unsigned char  vcsMode; /* 1:RTS/CTS 2:CTS to self */
unsigned char  rsvd022;
unsigned char  rsvd023;
unsigned char  rsvd024;
unsigned char  rsvd025;
      unsigned char lbk_mode; /*0x00: normal, 0x03: MACLBK, 0x01: PHYLBK*/
      unsigned char mp_mode; /* 1: for MP use, 0: for normal driver */
      unsigned char vcsType; /* 0:off 1:on 2:auto */
      unsigned char vcsMode; /* 1:RTS/CTS 2:CTS to self */
      unsigned char rsvd022;
      unsigned char rsvd023;
      unsigned char rsvd024;
      unsigned char rsvd025;
        /*--- long word 3 ----*/
unsigned char  qos_en;    /*1: QoS enable*/
unsigned char  bw_40MHz_en;   /*1: 40MHz BW enable*/
unsigned char  AMSDU2AMPDU_en;   /*1: 4181 convert AMSDU to AMPDU,
      unsigned char qos_en;    /*1: QoS enable*/
      unsigned char bw_40MHz_en;   /*1: 40MHz BW enable*/
      unsigned char AMSDU2AMPDU_en;   /*1: 4181 convert AMSDU to AMPDU,
                                   * 0: disable*/
unsigned char  AMPDU_en;   /*1: 11n AMPDU enable*/
unsigned char  rate_control_offload;  /*1: FW offloads, 0: driver handles*/
unsigned char  aggregation_offload;  /*1: FW offloads, 0: driver handles*/
unsigned char  rsvd030;
unsigned char  rsvd031;
      unsigned char AMPDU_en;   /*1: 11n AMPDU enable*/
      unsigned char rate_control_offload; /*1: FW offloads,0: driver handles*/
      unsigned char aggregation_offload;  /*1: FW offloads,0: driver handles*/
      unsigned char rsvd030;
      unsigned char rsvd031;
        /*--- long word 4 ----*/
unsigned char  beacon_offload;   /* 1. FW offloads, 0: driver handles*/
unsigned char  MLME_offload;   /* 2. FW offloads, 0: driver handles*/
unsigned char  hwpc_offload;   /* 3. FW offloads, 0: driver handles*/
unsigned char  tcp_checksum_offload; /* 4. FW offloads, 0: driver handles*/
unsigned char  tcp_offload;    /* 5. FW offloads, 0: driver handles*/
unsigned char  ps_control_offload;  /* 6. FW offloads, 0: driver handles*/
unsigned char  WWLAN_offload;   /* 7. FW offloads, 0: driver handles*/
unsigned char  rsvd040;
      unsigned char beacon_offload;   /* 1. FW offloads, 0: driver handles*/
      unsigned char MLME_offload;   /* 2. FW offloads, 0: driver handles*/
      unsigned char hwpc_offload;   /* 3. FW offloads, 0: driver handles*/
      unsigned char tcp_checksum_offload; /*4. FW offloads,0: driver handles*/
      unsigned char tcp_offload;    /* 5. FW offloads, 0: driver handles*/
      unsigned char ps_control_offload; /* 6. FW offloads, 0: driver handles*/
      unsigned char WWLAN_offload;   /* 7. FW offloads, 0: driver handles*/
      unsigned char rsvd040;
        /*--- long word 5 ----*/
unsigned char  tcp_tx_frame_len_L;  /*tcp tx packet length low byte*/
unsigned char  tcp_tx_frame_len_H;  /*tcp tx packet length high byte*/
unsigned char  tcp_rx_frame_len_L;  /*tcp rx packet length low byte*/
unsigned char  tcp_rx_frame_len_H;  /*tcp rx packet length high byte*/
unsigned char  rsvd050;
unsigned char  rsvd051;
unsigned char  rsvd052;
unsigned char  rsvd053;
      unsigned char tcp_tx_frame_len_L;  /*tcp tx packet length low byte*/
      unsigned char tcp_tx_frame_len_H;  /*tcp tx packet length high byte*/
      unsigned char tcp_rx_frame_len_L;  /*tcp rx packet length low byte*/
      unsigned char tcp_rx_frame_len_H;  /*tcp rx packet length high byte*/
      unsigned char rsvd050;
      unsigned char rsvd051;
      unsigned char rsvd052;
      unsigned char rsvd053;
 };
 
 struct fw_hdr {/*8-byte alinment required*/
index 5024ee42b04b9c2f1884631b502089f33c697a3d..cb1751e95f0696e0682345821df2c1ea7444c7a1 100644 (file)
@@ -49,7 +49,7 @@
  * LED object.
  *===========================================================================
  */
-enum _LED_STATE_871x{
+enum _LED_STATE_871x {
        LED_UNKNOWN = 0,
        LED_ON = 1,
        LED_OFF = 2,
index 569e14b599b4b9f3d314b7aa7b01989e7993d378..625a8a03966350d3b36aaf12d7a9ae1e5ed2fb1f 100644 (file)
@@ -251,7 +251,7 @@ static union recv_frame *recvframe_defrag(struct _adapter *adapter,
                recvframe_put(prframe, pnfhdr->len);
                pfhdr->attrib.icv_len = pnfhdr->attrib.icv_len;
                plist = get_next(plist);
-       };
+       }
 exit:
        /* free the defrag_q queue and return the prframe */
        r8712_free_recvframe_queue(defrag_q, pfree_recv_queue);
index 4ba52b9c169796f8acdd1af8ea8a783ed00370ae..c48757f97da40d3e8da47a6e61f0e8a0c7800294 100644 (file)
@@ -93,7 +93,7 @@ struct recv_buf {
        end   ----->
        len = (unsigned int )(tail - data);
 */
-struct recv_frame_hdr{
+struct recv_frame_hdr {
        struct list_head list;
        _pkt    *pkt;
        _pkt *pkt_newalloc;
index 5d77c51072426f43699421022cda118fe1aa5c03..12a080f545ab9681779b23f47f1a6c719ea489fd 100644 (file)
 /*OFFSET 20*/
 #define DISFB BIT(15)
 
-struct tx_desc{
-
+struct tx_desc {
        /*DWORD 0*/
        unsigned int txdw0;
-
        unsigned int txdw1;
-
        unsigned int txdw2;
-
        unsigned int txdw3;
-
        unsigned int txdw4;
-
        unsigned int txdw5;
-
        unsigned int txdw6;
-
        unsigned int txdw7;
-
 };
 
 
index fbb2e4eaae5189b10885907482ad9f8f3fb5b480..ba92762dbb1c44f3eb280d2f7c51f7d3d5e37fad 100644 (file)
@@ -431,8 +431,7 @@ u8 r8712_joinbss_cmd(struct _adapter  *padapter, struct wlan_network *pnetwork)
        }
        psecnetwork = (struct ndis_wlan_bssid_ex *)&psecuritypriv->sec_bss;
        if (psecnetwork == NULL) {
-               if (pcmd != NULL)
-                       kfree((unsigned char *)pcmd);
+               kfree(pcmd);
                return _FAIL;
        }
        memset(psecnetwork, 0, t_len);
@@ -478,8 +477,8 @@ u8 r8712_joinbss_cmd(struct _adapter  *padapter, struct wlan_network *pnetwork)
                 * to avoid some IOT issues, especially for Realtek 8192u
                 * SoftAP.
                 */
-               if ((padapter->securitypriv.PrivacyAlgrthm != _WEP40_ ) &&
-                   (padapter->securitypriv.PrivacyAlgrthm != _WEP104_ )) {
+               if ((padapter->securitypriv.PrivacyAlgrthm != _WEP40_) &&
+                   (padapter->securitypriv.PrivacyAlgrthm != _WEP104_)) {
                        /* restructure_ht_ie */
                        r8712_restructure_ht_ie(padapter,
                                                &pnetwork->network.IEs[0],
index 2dc78476b7d35db903b06dfb1763faf882a417ca..dcf256d44d1ccd972cc9e1b3ffdcdbb792bbf9ac 100644 (file)
@@ -562,54 +562,54 @@ struct getratable_rsp {
 };
 
 /*to get TX,RX retry count*/
-struct gettxretrycnt_parm{
+struct gettxretrycnt_parm {
        unsigned int rsvd;
 };
 
-struct gettxretrycnt_rsp{
+struct gettxretrycnt_rsp {
        unsigned long tx_retrycnt;
 };
 
-struct getrxretrycnt_parm{
+struct getrxretrycnt_parm {
        unsigned int rsvd;
 };
 
-struct getrxretrycnt_rsp{
+struct getrxretrycnt_rsp {
        unsigned long rx_retrycnt;
 };
 
 /*to get BCNOK,BCNERR count*/
-struct getbcnokcnt_parm{
+struct getbcnokcnt_parm {
        unsigned int rsvd;
 };
 
-struct getbcnokcnt_rsp{
-       unsigned long  bcnokcnt;
+struct getbcnokcnt_rsp {
+       unsigned long bcnokcnt;
 };
 
-struct getbcnerrcnt_parm{
+struct getbcnerrcnt_parm {
        unsigned int rsvd;
 };
-struct getbcnerrcnt_rsp{
+struct getbcnerrcnt_rsp {
        unsigned long bcnerrcnt;
 };
 
 /* to get current TX power level*/
-struct getcurtxpwrlevel_parm{
+struct getcurtxpwrlevel_parm {
        unsigned int rsvd;
 };
 
-struct getcurtxpwrlevel_rsp{
+struct getcurtxpwrlevel_rsp {
        unsigned short tx_power;
 };
 
 /*dynamic on/off DIG*/
-struct setdig_parm{
+struct setdig_parm {
        unsigned char dig_on;   /* 1:on , 0:off */
 };
 
 /*dynamic on/off RA*/
-struct setra_parm{
+struct setra_parm {
        unsigned char ra_on;    /* 1:on , 0:off */
 };
 
index d45229356bf6aa2f4953bc65140d4de0d08b3761..6ce06767130d6316a157d2e18239af6bec60aa61 100644 (file)
@@ -45,8 +45,8 @@ struct stassoc_event {
 };
 
 struct stadel_event {
- unsigned char macaddr[6];
- unsigned char rsvd[2];
      unsigned char macaddr[6];
      unsigned char rsvd[2];
 };
 
 struct addba_event {
@@ -61,7 +61,7 @@ struct fwevent {
 };
 
 #define C2HEVENT_SZ                    32
-struct event_node{
+struct event_node {
        unsigned char *node;
        unsigned char evt_code;
        unsigned short evt_sz;
@@ -85,9 +85,9 @@ struct network_queue {
 };
 
 struct ADDBA_Req_Report_parm {
- unsigned char MacAddress[ETH_ALEN];
- unsigned short StartSeqNum;
- unsigned char tid;
      unsigned char MacAddress[ETH_ALEN];
      unsigned short StartSeqNum;
      unsigned char tid;
 };
 #include "rtl8712_event.h"
 
index e6e3c3752a9721f8547db8610f21b01547fa17ff..ca84ee02eacc1cb7288ca268ac4cad8945c07c09 100644 (file)
@@ -73,8 +73,7 @@ static uint _init_intf_hdl(struct _adapter *padapter,
                goto _init_intf_hdl_fail;
        return _SUCCESS;
 _init_intf_hdl_fail:
-       if (pintf_priv)
-               kfree((u8 *)pintf_priv);
+       kfree(pintf_priv);
        return _FAIL;
 }
 
@@ -84,8 +83,7 @@ static void _unload_intf_hdl(struct intf_priv *pintfpriv)
 
        unload_intf_priv = &r8712_usb_unload_intf_priv;
        unload_intf_priv(pintfpriv);
-       if (pintfpriv)
-               kfree((u8 *)pintfpriv);
+       kfree(pintfpriv);
 }
 
 static uint register_intf_hdl(u8 *dev, struct intf_hdl *pintfhdl)
index bd315c77610adb1fdf4ed3005bd213adf4f76198..40e6b5cc412d4dea8b3bc12eed4646842741b97b 100644 (file)
@@ -291,7 +291,8 @@ static inline char *translate_scan(struct _adapter *padapter,
                        memset(buf, 0, MAX_WPA_IE_LEN);
                        n = sprintf(buf, "wpa_ie=");
                        for (i = 0; i < wpa_len; i++) {
-                               n += snprintf(buf + n, MAX_WPA_IE_LEN - n, "%02x", wpa_ie[i]);
+                               n += snprintf(buf + n, MAX_WPA_IE_LEN - n,
+                                                       "%02x", wpa_ie[i]);
                                if (n >= MAX_WPA_IE_LEN)
                                        break;
                        }
@@ -310,7 +311,8 @@ static inline char *translate_scan(struct _adapter *padapter,
                        memset(buf, 0, MAX_WPA_IE_LEN);
                        n = sprintf(buf, "rsn_ie=");
                        for (i = 0; i < rsn_len; i++) {
-                               n += snprintf(buf + n, MAX_WPA_IE_LEN - n, "%02x", rsn_ie[i]);
+                               n += snprintf(buf + n, MAX_WPA_IE_LEN - n,
+                                                       "%02x", rsn_ie[i]);
                                if (n >= MAX_WPA_IE_LEN)
                                        break;
                        }
@@ -1732,8 +1734,7 @@ static int r871x_wx_set_enc_ext(struct net_device *dev,
                memcpy(param + 1, pext + 1, pext->key_len);
        }
        ret = wpa_set_encryption(dev, param, param_len);
-       if (param)
-               kfree((u8 *)param);
+       kfree(param);
        return ret;
 }
 
index 7adbe82cd0858dcd176ebbbc96320270aa3c8fba..9a33eaee879bb370201929f9114179e4fb6bb559 100644 (file)
@@ -493,7 +493,7 @@ uint oid_rt_pro_rf_read_registry_hdl(struct oid_par_priv *poid_par_priv)
        return status;
 }
 
-enum _CONNECT_STATE_{
+enum _CONNECT_STATE_ {
        CHECKINGSTATUS,
        ASSOCIATED,
        ADHOCMODE,
index 8b1451d030698351f3f34f3d2ad12624227263c6..8486eb1503cc0884e9b518803d78a64c3f4b33e5 100644 (file)
@@ -68,7 +68,10 @@ static u8 do_join(struct _adapter *padapter)
        pmlmepriv->fw_state |= _FW_UNDER_LINKING;
        pmlmepriv->pscanned = plist;
        pmlmepriv->to_join = true;
-       if (_queue_empty(queue) == true) {
+
+       /* adhoc mode will start with an empty queue, but skip checking */
+       if (!check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) &&
+           _queue_empty(queue)) {
                if (pmlmepriv->fw_state & _FW_UNDER_LINKING)
                        pmlmepriv->fw_state ^= _FW_UNDER_LINKING;
                /* when set_ssid/set_bssid for do_join(), but scanning queue
index 283afbfc1d02f532a20adf6856b1700cbf76e07a..8dff2b196ff28f5e206153d66348a8d95714d6ea 100644 (file)
@@ -6,19 +6,27 @@
 typedef u8 NDIS_802_11_PMKID_VALUE[16];
 
 struct BSSIDInfo {
-       unsigned char  BSSID[6];
-       NDIS_802_11_PMKID_VALUE  PMKID;
+       unsigned char BSSID[6];
+       NDIS_802_11_PMKID_VALUE PMKID;
 };
 
 u8 r8712_set_802_11_authentication_mode(struct _adapter *pdapter,
                        enum NDIS_802_11_AUTHENTICATION_MODE authmode);
+
 u8 r8712_set_802_11_bssid(struct _adapter *padapter, u8 *bssid);
-u8 r8712_set_802_11_add_wep(struct _adapter *padapter, struct NDIS_802_11_WEP *wep);
+
+u8 r8712_set_802_11_add_wep(struct _adapter *padapter,
+                           struct NDIS_802_11_WEP *wep);
+
 u8 r8712_set_802_11_disassociate(struct _adapter *padapter);
+
 u8 r8712_set_802_11_bssid_list_scan(struct _adapter *padapter);
+
 u8 r8712_set_802_11_infrastructure_mode(struct _adapter *padapter,
                        enum NDIS_802_11_NETWORK_INFRASTRUCTURE networktype);
-void r8712_set_802_11_ssid(struct _adapter *padapter, struct ndis_802_11_ssid *ssid);
+
+void r8712_set_802_11_ssid(struct _adapter *padapter,
+                          struct ndis_802_11_ssid *ssid);
 
 #endif
 
index 427467cb10bde866f449cc6c2d53dfadc7204241..41e00a2c862dddf6f16eae4c5dbfe55c9a321de3 100644 (file)
@@ -217,7 +217,10 @@ static u32 get_bb_reg(struct _adapter *pAdapter, u16 offset, u32 bitmask)
        return new_value;
 }
 
-static u8 set_bb_reg(struct _adapter *pAdapter, u16 offset, u32 bitmask, u32 value)
+static u8 set_bb_reg(struct _adapter *pAdapter,
+                    u16 offset,
+                    u32 bitmask,
+                    u32 value)
 {
        u32 org_value, bit_shift, new_value;
 
@@ -274,8 +277,7 @@ void r8712_SetChannel(struct _adapter *pAdapter)
        pparm = (struct SetChannel_parm *)_malloc(sizeof(struct
                                         SetChannel_parm));
        if (pparm == NULL) {
-               if (pcmd != NULL)
-                       kfree((u8 *)pcmd);
+               kfree(pcmd);
                return;
        }
        pparm->curr_ch = pAdapter->mppriv.curr_ch;
index fdd2278936d8c66f040c50ab4bf005241c123f6d..67759c31b1da5fccab6d42bb8cb8e9f414a2aa6f 100644 (file)
@@ -281,23 +281,23 @@ enum MP_MODE {
        MP_ERR_MODE
 };
 
-struct rwreg_param{
+struct rwreg_param {
        unsigned int offset;
        unsigned int width;
        unsigned int value;
 };
 
-struct bbreg_param{
+struct bbreg_param {
        unsigned int offset;
        unsigned int phymask;
        unsigned int value;
 };
 
-struct txpower_param{
+struct txpower_param {
        unsigned int pwr_index;
 };
 
-struct datarate_param{
+struct datarate_param {
        unsigned int rate_index;
 };
 
@@ -321,7 +321,7 @@ struct mp_ioctl_handler {
        unsigned int oid;
 };
 
-struct mp_ioctl_param{
+struct mp_ioctl_param {
        unsigned int subcode;
        unsigned int len;
        unsigned char data[0];
index a3165e67f8578cc76ef6e2891e0a12f608a1987c..aec83dd8a01f94452335acae3e6ca7276fc33451 100644 (file)
@@ -307,9 +307,9 @@ static sint recv_decache(union recv_frame *precv_frame, u8 bretry,
        return _SUCCESS;
 }
 
-static sint sta2sta_data_frame(struct _adapter *adapter, union recv_frame *precv_frame,
-                       struct sta_info **psta
-)
+static sint sta2sta_data_frame(struct _adapter *adapter,
+                              union recv_frame *precv_frame,
+                              struct sta_info **psta)
 {
        u8 *ptr = precv_frame->u.hdr.rx_data;
        sint ret = _SUCCESS;
@@ -373,8 +373,9 @@ static sint sta2sta_data_frame(struct _adapter *adapter, union recv_frame *precv
        return ret;
 }
 
-static sint ap2sta_data_frame(struct _adapter *adapter, union recv_frame *precv_frame,
-                      struct sta_info **psta)
+static sint ap2sta_data_frame(struct _adapter *adapter,
+                             union recv_frame *precv_frame,
+                             struct sta_info **psta)
 {
        u8 *ptr = precv_frame->u.hdr.rx_data;
        struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib;
@@ -431,8 +432,9 @@ static sint ap2sta_data_frame(struct _adapter *adapter, union recv_frame *precv_
        return _SUCCESS;
 }
 
-static sint sta2ap_data_frame(struct _adapter *adapter, union recv_frame *precv_frame,
-                      struct sta_info **psta)
+static sint sta2ap_data_frame(struct _adapter *adapter,
+                             union recv_frame *precv_frame,
+                             struct sta_info **psta)
 {
        struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib;
        struct  sta_priv *pstapriv = &adapter->stapriv;
index bf8115dbcb61fe65bdc2a5368525bc57934275ed..cc7a72fee1c2601360b9c43423c098ffc14cb9d1 100644 (file)
@@ -19,9 +19,9 @@
 /* for Rx reordering buffer control */
 struct recv_reorder_ctrl {
        struct _adapter *padapter;
-       u16 indicate_seq;/* =wstart_b, init_value=0xffff */
+       u16 indicate_seq; /* =wstart_b, init_value=0xffff */
        u16 wend_b;
-       u8 wsize_b;
+       u8 wsize_b;
        struct  __queue pending_recvframe_queue;
        struct timer_list reordering_ctrl_timer;
 };
index c709d8cadf0ca3fc35c7faed15cad6d1d11e8a75..6c54966f13f7dbd23492cad615330a3831e83815 100644 (file)
@@ -22,7 +22,7 @@ struct        regulatory_class {
        u8      modem;
 };
 
-enum   _REG_PREAMBLE_MODE{
+enum   _REG_PREAMBLE_MODE {
        PREAMBLE_LONG   = 1,
        PREAMBLE_AUTO   = 2,
        PREAMBLE_SHORT  = 3,
index 782b70a352fbdf9ef7d809a98141e024715b6a7c..bff71d2aae98e30e3c30df4d97a652825d9e63a7 100644 (file)
 #ifndef Ndis802_11AuthModeWPA2PSK
 #define Ndis802_11AuthModeWPA2PSK (Ndis802_11AuthModeWPANone + 2)
 #endif
+
 union pn48 {
        u64 val;
 #if defined(__BIG_ENDIAN)
-struct {
-  u8 TSC7;
-  u8 TSC6;
-  u8 TSC5;
-  u8 TSC4;
-  u8 TSC3;
-  u8 TSC2;
-  u8 TSC1;
-  u8 TSC0;
-} _byte_;
+       struct {
+               u8 TSC7;
+               u8 TSC6;
+               u8 TSC5;
+               u8 TSC4;
+               u8 TSC3;
+               u8 TSC2;
+               u8 TSC1;
+               u8 TSC0;
+       } _byte_;
 #else
-struct {
-  u8 TSC0;
-  u8 TSC1;
-  u8 TSC2;
-  u8 TSC3;
-  u8 TSC4;
-  u8 TSC5;
-  u8 TSC6;
-  u8 TSC7;
-} _byte_;
+       struct {
+               u8 TSC0;
+               u8 TSC1;
+               u8 TSC2;
+               u8 TSC3;
+               u8 TSC4;
+               u8 TSC5;
+               u8 TSC6;
+               u8 TSC7;
+       } _byte_;
 #endif
 };
 
@@ -174,11 +175,11 @@ struct mic_data {
 };
 
 void seccalctkipmic(
-       u8 *key,
-       u8 *header,
-       u8 *data,
-       u32 data_len,
-       u8 *Miccode,
+       u8  *key,
+       u8  *header,
+       u8  *data,
+       u32  data_len,
+       u8  *Miccode,
        u8   priority);
 
 void r8712_secmicsetkey(struct mic_data *pmicdata, u8 * key);
index 75f1a6bba2f6c607b347042d57fd64527eacedf2..ccf08911f58b7a91a7560e3a1e4935127f748410 100644 (file)
@@ -996,8 +996,7 @@ static void free_hwxmits(struct _adapter *padapter)
 {
        struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
 
-       if (pxmitpriv->hwxmits)
-               kfree((u8 *)pxmitpriv->hwxmits);
+       kfree(pxmitpriv->hwxmits);
 }
 
 static void init_hwxmits(struct hw_xmit *phwxmit, sint entry)
index d518ce85585d73c055e4c22366721ef2e9af1828..df13e67b3eb86f4c0c645cccfb757493e441df36 100644 (file)
@@ -244,7 +244,8 @@ sint r8712_update_attrib(struct _adapter *padapter, _pkt *pkt,
                         struct pkt_attrib *pattrib);
 int r8712_txframes_sta_ac_pending(struct _adapter *padapter,
                                  struct pkt_attrib *pattrib);
-sint _r8712_init_xmit_priv(struct xmit_priv *pxmitpriv, struct _adapter *padapter);
+sint _r8712_init_xmit_priv(struct xmit_priv *pxmitpriv,
+                          struct _adapter *padapter);
 void _free_xmit_priv(struct xmit_priv *pxmitpriv);
 void r8712_free_xmitframe_ex(struct xmit_priv *pxmitpriv,
                             struct xmit_frame *pxmitframe);
index 86d4b98e243922162f6a346d4b80212c7253b0cb..6032cdc653944d5ef5db69f4905f960a91dd3ca9 100644 (file)
@@ -39,38 +39,35 @@ enum WIFI_FRAME_TYPE {
 };
 
 enum WIFI_FRAME_SUBTYPE {
-
-    /* below is for mgt frame */
-    WIFI_ASSOCREQ       = (0 | WIFI_MGT_TYPE),
-    WIFI_ASSOCRSP       = (BIT(4) | WIFI_MGT_TYPE),
-    WIFI_REASSOCREQ     = (BIT(5) | WIFI_MGT_TYPE),
-    WIFI_REASSOCRSP     = (BIT(5) | BIT(4) | WIFI_MGT_TYPE),
-    WIFI_PROBEREQ       = (BIT(6) | WIFI_MGT_TYPE),
-    WIFI_PROBERSP       = (BIT(6) | BIT(4) | WIFI_MGT_TYPE),
-    WIFI_BEACON         = (BIT(7) | WIFI_MGT_TYPE),
-    WIFI_ATIM           = (BIT(7) | BIT(4) | WIFI_MGT_TYPE),
-    WIFI_DISASSOC       = (BIT(7) | BIT(5) | WIFI_MGT_TYPE),
-    WIFI_AUTH           = (BIT(7) | BIT(5) | BIT(4) | WIFI_MGT_TYPE),
-    WIFI_DEAUTH         = (BIT(7) | BIT(6) | WIFI_MGT_TYPE),
-    WIFI_ACTION         = (BIT(7) | BIT(6) | BIT(4) | WIFI_MGT_TYPE),
-
-    /* below is for control frame */
-    WIFI_PSPOLL         = (BIT(7) | BIT(5) | WIFI_CTRL_TYPE),
-    WIFI_RTS            = (BIT(7) | BIT(5) | BIT(4) | WIFI_CTRL_TYPE),
-    WIFI_CTS            = (BIT(7) | BIT(6) | WIFI_CTRL_TYPE),
-    WIFI_ACK            = (BIT(7) | BIT(6) | BIT(4) | WIFI_CTRL_TYPE),
-    WIFI_CFEND          = (BIT(7) | BIT(6) | BIT(5) | WIFI_CTRL_TYPE),
-    WIFI_CFEND_CFACK    = (BIT(7) | BIT(6) | BIT(5) | BIT(4) | WIFI_CTRL_TYPE),
-
-    /* below is for data frame */
-    WIFI_DATA           = (0 | WIFI_DATA_TYPE),
-    WIFI_DATA_CFACK     = (BIT(4) | WIFI_DATA_TYPE),
-    WIFI_DATA_CFPOLL    = (BIT(5) | WIFI_DATA_TYPE),
-    WIFI_DATA_CFACKPOLL = (BIT(5) | BIT(4) | WIFI_DATA_TYPE),
-    WIFI_DATA_NULL      = (BIT(6) | WIFI_DATA_TYPE),
-    WIFI_CF_ACK         = (BIT(6) | BIT(4) | WIFI_DATA_TYPE),
-    WIFI_CF_POLL        = (BIT(6) | BIT(5) | WIFI_DATA_TYPE),
-    WIFI_CF_ACKPOLL     = (BIT(6) | BIT(5) | BIT(4) | WIFI_DATA_TYPE),
+       /* below is for mgt frame */
+       WIFI_ASSOCREQ       = (0 | WIFI_MGT_TYPE),
+       WIFI_ASSOCRSP       = (BIT(4) | WIFI_MGT_TYPE),
+       WIFI_REASSOCREQ     = (BIT(5) | WIFI_MGT_TYPE),
+       WIFI_REASSOCRSP     = (BIT(5) | BIT(4) | WIFI_MGT_TYPE),
+       WIFI_PROBEREQ       = (BIT(6) | WIFI_MGT_TYPE),
+       WIFI_PROBERSP       = (BIT(6) | BIT(4) | WIFI_MGT_TYPE),
+       WIFI_BEACON         = (BIT(7) | WIFI_MGT_TYPE),
+       WIFI_ATIM           = (BIT(7) | BIT(4) | WIFI_MGT_TYPE),
+       WIFI_DISASSOC       = (BIT(7) | BIT(5) | WIFI_MGT_TYPE),
+       WIFI_AUTH           = (BIT(7) | BIT(5) | BIT(4) | WIFI_MGT_TYPE),
+       WIFI_DEAUTH         = (BIT(7) | BIT(6) | WIFI_MGT_TYPE),
+       WIFI_ACTION         = (BIT(7) | BIT(6) | BIT(4) | WIFI_MGT_TYPE),
+       /* below is for control frame */
+       WIFI_PSPOLL         = (BIT(7) | BIT(5) | WIFI_CTRL_TYPE),
+       WIFI_RTS            = (BIT(7) | BIT(5) | BIT(4) | WIFI_CTRL_TYPE),
+       WIFI_CTS            = (BIT(7) | BIT(6) | WIFI_CTRL_TYPE),
+       WIFI_ACK            = (BIT(7) | BIT(6) | BIT(4) | WIFI_CTRL_TYPE),
+       WIFI_CFEND          = (BIT(7) | BIT(6) | BIT(5) | WIFI_CTRL_TYPE),
+       WIFI_CFEND_CFACK = (BIT(7) | BIT(6) | BIT(5) | BIT(4) | WIFI_CTRL_TYPE),
+       /* below is for data frame */
+       WIFI_DATA           = (0 | WIFI_DATA_TYPE),
+       WIFI_DATA_CFACK     = (BIT(4) | WIFI_DATA_TYPE),
+       WIFI_DATA_CFPOLL    = (BIT(5) | WIFI_DATA_TYPE),
+       WIFI_DATA_CFACKPOLL = (BIT(5) | BIT(4) | WIFI_DATA_TYPE),
+       WIFI_DATA_NULL      = (BIT(6) | WIFI_DATA_TYPE),
+       WIFI_CF_ACK         = (BIT(6) | BIT(4) | WIFI_DATA_TYPE),
+       WIFI_CF_POLL        = (BIT(6) | BIT(5) | WIFI_DATA_TYPE),
+       WIFI_CF_ACKPOLL     = (BIT(6) | BIT(5) | BIT(4) | WIFI_DATA_TYPE),
 };
 
 enum WIFI_REASON_CODE  {
@@ -84,7 +81,6 @@ enum WIFI_REASON_CODE {
        _RSON_CLS3_                     = 7,
        _RSON_DISAOC_STA_LEAVING_       = 8,
        _RSON_ASOC_NOT_AUTH_            = 9,
-
        /* WPA reason */
        _RSON_INVALID_IE_               = 13,
        _RSON_MIC_FAILURE_              = 14,
@@ -97,7 +93,6 @@ enum WIFI_REASON_CODE {
        _RSON_UNSUPPORT_RSNE_VER_       = 21,
        _RSON_INVALID_RSNE_CAP_         = 22,
        _RSON_IEEE_802DOT1X_AUTH_FAIL_  = 23,
-
        /* below are Realtek definitions */
        _RSON_PMK_NOT_AVAILABLE_        = 24,
 };
index 6d9295270f83ff7e6e7c8ed534a1bfcbc5ee2011..0d90e1f5b29aed1e7b3b7ea803db657e2b104b36 100644 (file)
@@ -13,23 +13,23 @@ typedef unsigned char   NDIS_802_11_RATES[NDIS_802_11_LENGTH_RATES];
 typedef unsigned char   NDIS_802_11_RATES_EX[NDIS_802_11_LENGTH_RATES_EX];
 
 struct ndis_802_11_ssid {
-  u32  SsidLength;
-  u8  Ssid[32];
+       u32 SsidLength;
+       u8  Ssid[32];
 };
 
 enum NDIS_802_11_NETWORK_TYPE {
-    Ndis802_11FH,
-    Ndis802_11DS,
-    Ndis802_11OFDM5,
-    Ndis802_11OFDM24,
-    Ndis802_11NetworkTypeMax    /* not a real type, defined as an upper bound */
+       Ndis802_11FH,
+       Ndis802_11DS,
+       Ndis802_11OFDM5,
+       Ndis802_11OFDM24,
+       Ndis802_11NetworkTypeMax /* not a real type, defined as an upper bound*/
 };
 
 struct NDIS_802_11_CONFIGURATION_FH {
-    u32           Length;             /* Length of structure */
-    u32           HopPattern;         /* As defined by 802.11, MSB set */
-    u32           HopSet;             /* to one if non-802.11 */
-    u32           DwellTime;          /* units are Kusec */
+       u32 Length;             /* Length of structure */
+       u32 HopPattern;         /* As defined by 802.11, MSB set */
+       u32 HopSet;             /* to one if non-802.11 */
+       u32 DwellTime;          /* units are Kusec */
 };
 
 /*
@@ -37,25 +37,25 @@ struct NDIS_802_11_CONFIGURATION_FH {
        ODI Handler will convert the channel number to freq. number.
 */
 struct NDIS_802_11_CONFIGURATION {
-    u32           Length;             /* Length of structure */
-    u32           BeaconPeriod;       /* units are Kusec */
-    u32           ATIMWindow;         /* units are Kusec */
-    u32           DSConfig;           /* Frequency, units are kHz */
-    struct NDIS_802_11_CONFIGURATION_FH    FHConfig;
+       u32 Length;             /* Length of structure */
+       u32 BeaconPeriod;       /* units are Kusec */
+       u32 ATIMWindow;         /* units are Kusec */
+       u32 DSConfig;           /* Frequency, units are kHz */
+       struct NDIS_802_11_CONFIGURATION_FH FHConfig;
 };
 
 enum NDIS_802_11_NETWORK_INFRASTRUCTURE {
-    Ndis802_11IBSS,
-    Ndis802_11Infrastructure,
-    Ndis802_11AutoUnknown,
-    Ndis802_11InfrastructureMax, /* Not a real value, defined as upper bound */
-    Ndis802_11APMode
+       Ndis802_11IBSS,
+       Ndis802_11Infrastructure,
+       Ndis802_11AutoUnknown,
+       Ndis802_11InfrastructureMax, /*Not a real value,defined as upper bound*/
+       Ndis802_11APMode
 };
 
 struct NDIS_802_11_FIXED_IEs {
-  u8  Timestamp[8];
-  u16  BeaconInterval;
-  u16  Capabilities;
+       u8  Timestamp[8];
+       u16 BeaconInterval;
+       u16 Capabilities;
 };
 
 /*
@@ -70,44 +70,44 @@ struct NDIS_802_11_FIXED_IEs {
  */
 
 struct ndis_wlan_bssid_ex {
-  u32  Length;
-  unsigned char  MacAddress[6];
-  u8  Reserved[2];
-  struct ndis_802_11_ssid  Ssid;
-  u32  Privacy;
-  s32  Rssi;
-  enum NDIS_802_11_NETWORK_TYPE  NetworkTypeInUse;
-  struct NDIS_802_11_CONFIGURATION  Configuration;
-  enum NDIS_802_11_NETWORK_INFRASTRUCTURE  InfrastructureMode;
-  NDIS_802_11_RATES_EX  SupportedRates;
-  u32  IELength;
-/*(timestamp, beacon interval, and capability information) */
-  u8  IEs[MAX_IE_SZ];
+       u32 Length;
+       unsigned char  MacAddress[6];
+       u8  Reserved[2];
+       struct ndis_802_11_ssid  Ssid;
+       u32 Privacy;
+       s32 Rssi;
+       enum NDIS_802_11_NETWORK_TYPE  NetworkTypeInUse;
+       struct NDIS_802_11_CONFIGURATION  Configuration;
+       enum NDIS_802_11_NETWORK_INFRASTRUCTURE  InfrastructureMode;
+       NDIS_802_11_RATES_EX  SupportedRates;
+       u32 IELength;
+       /*(timestamp, beacon interval, and capability information) */
+       u8 IEs[MAX_IE_SZ];
 };
 
 enum NDIS_802_11_AUTHENTICATION_MODE {
-    Ndis802_11AuthModeOpen,
-    Ndis802_11AuthModeShared,
-    Ndis802_11AuthModeAutoSwitch,
-    Ndis802_11AuthModeWPA,
-    Ndis802_11AuthModeWPAPSK,
-    Ndis802_11AuthModeWPANone,
-    Ndis802_11AuthModeMax     /* Not a real mode, defined as upper bound */
+       Ndis802_11AuthModeOpen,
+       Ndis802_11AuthModeShared,
+       Ndis802_11AuthModeAutoSwitch,
+       Ndis802_11AuthModeWPA,
+       Ndis802_11AuthModeWPAPSK,
+       Ndis802_11AuthModeWPANone,
+       Ndis802_11AuthModeMax      /* Not a real mode, defined as upper bound */
 };
 
 enum {
-    Ndis802_11WEPEnabled,
-    Ndis802_11Encryption1Enabled = Ndis802_11WEPEnabled,
-    Ndis802_11WEPDisabled,
-    Ndis802_11EncryptionDisabled = Ndis802_11WEPDisabled,
-    Ndis802_11WEPKeyAbsent,
-    Ndis802_11Encryption1KeyAbsent = Ndis802_11WEPKeyAbsent,
-    Ndis802_11WEPNotSupported,
-    Ndis802_11EncryptionNotSupported = Ndis802_11WEPNotSupported,
-    Ndis802_11Encryption2Enabled,
-    Ndis802_11Encryption2KeyAbsent,
-    Ndis802_11Encryption3Enabled,
-    Ndis802_11Encryption3KeyAbsent
+       Ndis802_11WEPEnabled,
+       Ndis802_11Encryption1Enabled = Ndis802_11WEPEnabled,
+       Ndis802_11WEPDisabled,
+       Ndis802_11EncryptionDisabled = Ndis802_11WEPDisabled,
+       Ndis802_11WEPKeyAbsent,
+       Ndis802_11Encryption1KeyAbsent = Ndis802_11WEPKeyAbsent,
+       Ndis802_11WEPNotSupported,
+       Ndis802_11EncryptionNotSupported = Ndis802_11WEPNotSupported,
+       Ndis802_11Encryption2Enabled,
+       Ndis802_11Encryption2KeyAbsent,
+       Ndis802_11Encryption3Enabled,
+       Ndis802_11Encryption3KeyAbsent
 };
 
 #define NDIS_802_11_AI_REQFI_CAPABILITIES      1
@@ -119,51 +119,51 @@ enum {
 #define NDIS_802_11_AI_RESFI_ASSOCIATIONID     4
 
 struct NDIS_802_11_AI_REQFI {
-    u16 Capabilities;
-    u16 ListenInterval;
-    unsigned char CurrentAPAddress[6];
+       u16 Capabilities;
+       u16 ListenInterval;
+       unsigned char CurrentAPAddress[6];
 };
 
 struct NDIS_802_11_AI_RESFI {
-    u16 Capabilities;
-    u16 StatusCode;
-    u16 AssociationId;
+       u16 Capabilities;
+       u16 StatusCode;
+       u16 AssociationId;
 };
 
 struct NDIS_802_11_ASSOCIATION_INFORMATION {
-    u32                   Length;
-    u16                  AvailableRequestFixedIEs;
-    struct NDIS_802_11_AI_REQFI    RequestFixedIEs;
-    u32                   RequestIELength;
-    u32                   OffsetRequestIEs;
-    u16                  AvailableResponseFixedIEs;
-    struct NDIS_802_11_AI_RESFI    ResponseFixedIEs;
-    u32                   ResponseIELength;
-    u32                   OffsetResponseIEs;
+       u32 Length;
+       u16 AvailableRequestFixedIEs;
+       struct NDIS_802_11_AI_REQFI RequestFixedIEs;
+       u32 RequestIELength;
+       u32 OffsetRequestIEs;
+       u16 AvailableResponseFixedIEs;
+       struct NDIS_802_11_AI_RESFI ResponseFixedIEs;
+       u32 ResponseIELength;
+       u32 OffsetResponseIEs;
 };
 
 /* Key mapping keys require a BSSID*/
 struct NDIS_802_11_KEY {
-    u32           Length;             /* Length of this structure */
-    u32           KeyIndex;
-    u32           KeyLength;          /* length of key in bytes */
-    unsigned char BSSID[6];
-    unsigned long long KeyRSC;
-    u8           KeyMaterial[32];     /* variable length */
+       u32 Length;                     /* Length of this structure */
+       u32 KeyIndex;
+       u32 KeyLength;                  /* length of key in bytes */
+       unsigned char BSSID[6];
+       unsigned long long KeyRSC;
+       u8  KeyMaterial[32];            /* variable length */
 };
 
 struct NDIS_802_11_REMOVE_KEY {
-    u32                   Length;        /* Length of this structure */
-    u32                   KeyIndex;
-    unsigned char BSSID[6];
+       u32 Length;                     /* Length of this structure */
+       u32 KeyIndex;
+       unsigned char BSSID[6];
 };
 
 struct NDIS_802_11_WEP {
-    u32     Length;        /* Length of this structure */
-    u32     KeyIndex;      /* 0 is the per-client key,
-                             * 1-N are the global keys */
-    u32     KeyLength;     /* length of key in bytes */
-    u8     KeyMaterial[16];/* variable length depending on above field */
+       u32 Length;               /* Length of this structure */
+       u32 KeyIndex;             /* 0 is the per-client key,
+                                  * 1-N are the global keys */
+       u32 KeyLength;            /* length of key in bytes */
+       u8  KeyMaterial[16];      /* variable length depending on above field */
 };
 
 /* mask for authentication/integrity fields */
@@ -192,15 +192,15 @@ struct    wlan_network {
 };
 
 enum VRTL_CARRIER_SENSE {
-    DISABLE_VCS,
-    ENABLE_VCS,
-    AUTO_VCS
+       DISABLE_VCS,
+       ENABLE_VCS,
+       AUTO_VCS
 };
 
 enum VCS_TYPE {
-    NONE_VCS,
-    RTS_CTS,
-    CTS_TO_SELF
+       NONE_VCS,
+       RTS_CTS,
+       CTS_TO_SELF
 };
 
 #define PWR_CAM 0
@@ -211,9 +211,9 @@ enum VCS_TYPE {
 
 enum UAPSD_MAX_SP {
        NO_LIMIT,
-       TWO_MSDU,
-       FOUR_MSDU,
-       SIX_MSDU
+       TWO_MSDU,
+       FOUR_MSDU,
+       SIX_MSDU
 };
 
 #define NUM_PRE_AUTH_KEY 16
@@ -223,18 +223,18 @@ enum UAPSD_MAX_SP {
  *     WPA2
  */
 struct wlan_bssid_ex {
-  u32  Length;
-  unsigned char  MacAddress[6];
-  u8  Reserved[2];
-  struct ndis_802_11_ssid  Ssid;
-  u32  Privacy;
-  s32  Rssi;
-  enum NDIS_802_11_NETWORK_TYPE  NetworkTypeInUse;
-  struct NDIS_802_11_CONFIGURATION  Configuration;
-  enum NDIS_802_11_NETWORK_INFRASTRUCTURE  InfrastructureMode;
-  NDIS_802_11_RATES_EX  SupportedRates;
-  u32  IELength;
-  u8  IEs[MAX_IE_SZ];  /* (timestamp, beacon interval, and capability
+       u32 Length;
+       unsigned char  MacAddress[6];
+       u8  Reserved[2];
+       struct ndis_802_11_ssid  Ssid;
+       u32 Privacy;
+       s32 Rssi;
+       enum NDIS_802_11_NETWORK_TYPE  NetworkTypeInUse;
+       struct NDIS_802_11_CONFIGURATION  Configuration;
+       enum NDIS_802_11_NETWORK_INFRASTRUCTURE  InfrastructureMode;
+       NDIS_802_11_RATES_EX  SupportedRates;
+       u32 IELength;
+       u8  IEs[MAX_IE_SZ];     /* (timestamp, beacon interval, and capability
                                 * information) */
 };
 
index d89795c6a3ac2545be028198604443b3f37debe0..2e8258754c96b0e3d03beee82b45b461bdc96e59 100644 (file)
@@ -864,7 +864,7 @@ static int ms_read_attribute_info(struct rtsx_chip *chip)
                TRACE_RET(chip, STATUS_FAIL);
        }
 
-       buf = (u8 *)rtsx_alloc_dma_buf(chip, 64 * 512, GFP_KERNEL);
+       buf = kmalloc(64 * 512, GFP_KERNEL);
        if (buf == NULL) {
                TRACE_RET(chip, STATUS_ERROR);
        }
@@ -876,11 +876,11 @@ static int ms_read_attribute_info(struct rtsx_chip *chip)
                }
                retval = rtsx_read_register(chip, MS_TRANS_CFG, &val);
                if (retval != STATUS_SUCCESS) {
-                       rtsx_free_dma_buf(chip, buf);
+                       kfree(buf);
                        TRACE_RET(chip, STATUS_FAIL);
                }
                if (!(val & MS_INT_BREQ)) {
-                       rtsx_free_dma_buf(chip, buf);
+                       kfree(buf);
                        TRACE_RET(chip, STATUS_FAIL);
                }
                retval = ms_transfer_data(chip, MS_TM_AUTO_READ, PRO_READ_LONG_DATA,
@@ -892,7 +892,7 @@ static int ms_read_attribute_info(struct rtsx_chip *chip)
                }
        }
        if (retval != STATUS_SUCCESS) {
-               rtsx_free_dma_buf(chip, buf);
+               kfree(buf);
                TRACE_RET(chip, STATUS_FAIL);
        }
 
@@ -900,7 +900,7 @@ static int ms_read_attribute_info(struct rtsx_chip *chip)
        do {
                retval = rtsx_read_register(chip, MS_TRANS_CFG, &val);
                if (retval != STATUS_SUCCESS) {
-                       rtsx_free_dma_buf(chip, buf);
+                       kfree(buf);
                        TRACE_RET(chip, STATUS_FAIL);
                }
 
@@ -909,7 +909,7 @@ static int ms_read_attribute_info(struct rtsx_chip *chip)
 
                retval = ms_transfer_tpc(chip, MS_TM_NORMAL_READ, PRO_READ_LONG_DATA, 0, WAIT_INT);
                if (retval != STATUS_SUCCESS) {
-                       rtsx_free_dma_buf(chip, buf);
+                       kfree(buf);
                        TRACE_RET(chip, STATUS_FAIL);
                }
 
@@ -917,18 +917,18 @@ static int ms_read_attribute_info(struct rtsx_chip *chip)
        } while (i < 1024);
 
        if (retval != STATUS_SUCCESS) {
-               rtsx_free_dma_buf(chip, buf);
+               kfree(buf);
                TRACE_RET(chip, STATUS_FAIL);
        }
 
        if ((buf[0] != 0xa5) && (buf[1] != 0xc3)) {
                /* Signature code is wrong */
-               rtsx_free_dma_buf(chip, buf);
+               kfree(buf);
                TRACE_RET(chip, STATUS_FAIL);
        }
 
        if ((buf[4] < 1) || (buf[4] > 12)) {
-               rtsx_free_dma_buf(chip, buf);
+               kfree(buf);
                TRACE_RET(chip, STATUS_FAIL);
        }
 
@@ -950,15 +950,15 @@ static int ms_read_attribute_info(struct rtsx_chip *chip)
                        RTSX_DEBUGP("sys_info_addr = 0x%x, sys_info_size = 0x%x\n",
                                        sys_info_addr, sys_info_size);
                        if (sys_info_size != 96)  {
-                               rtsx_free_dma_buf(chip, buf);
+                               kfree(buf);
                                TRACE_RET(chip, STATUS_FAIL);
                        }
                        if (sys_info_addr < 0x1A0) {
-                               rtsx_free_dma_buf(chip, buf);
+                               kfree(buf);
                                TRACE_RET(chip, STATUS_FAIL);
                        }
                        if ((sys_info_size + sys_info_addr) > 0x8000) {
-                               rtsx_free_dma_buf(chip, buf);
+                               kfree(buf);
                                TRACE_RET(chip, STATUS_FAIL);
                        }
 
@@ -984,15 +984,15 @@ static int ms_read_attribute_info(struct rtsx_chip *chip)
                        RTSX_DEBUGP("model_name_addr = 0x%x, model_name_size = 0x%x\n",
                                        model_name_addr, model_name_size);
                        if (model_name_size != 48)  {
-                               rtsx_free_dma_buf(chip, buf);
+                               kfree(buf);
                                TRACE_RET(chip, STATUS_FAIL);
                        }
                        if (model_name_addr < 0x1A0) {
-                               rtsx_free_dma_buf(chip, buf);
+                               kfree(buf);
                                TRACE_RET(chip, STATUS_FAIL);
                        }
                        if ((model_name_size + model_name_addr) > 0x8000) {
-                               rtsx_free_dma_buf(chip, buf);
+                               kfree(buf);
                                TRACE_RET(chip, STATUS_FAIL);
                        }
 
@@ -1005,7 +1005,7 @@ static int ms_read_attribute_info(struct rtsx_chip *chip)
        }
 
        if (i == buf[4]) {
-               rtsx_free_dma_buf(chip, buf);
+               kfree(buf);
                TRACE_RET(chip, STATUS_FAIL);
        }
 
@@ -1042,7 +1042,7 @@ static int ms_read_attribute_info(struct rtsx_chip *chip)
        memcpy(ms_card->raw_model_name, buf + model_name_addr, 48);
 #endif
 
-       rtsx_free_dma_buf(chip, buf);
+       kfree(buf);
 
 #ifdef SUPPORT_MSXC
        if (CHK_MSXC(ms_card)) {
@@ -3784,7 +3784,7 @@ int mg_get_local_EKB(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                TRACE_RET(chip, STATUS_FAIL);
        }
 
-       buf = (u8 *)rtsx_alloc_dma_buf(chip, 1540, GFP_KERNEL);
+       buf = kmalloc(1540, GFP_KERNEL);
        if (!buf) {
                TRACE_RET(chip, STATUS_ERROR);
        }
@@ -3817,9 +3817,7 @@ int mg_get_local_EKB(struct scsi_cmnd *srb, struct rtsx_chip *chip)
        rtsx_stor_set_xfer_buf(buf, bufflen, srb);
 
 GetEKBFinish:
-       if (buf) {
-               rtsx_free_dma_buf(chip, buf);
-       }
+       kfree(buf);
        return retval;
 }
 
@@ -4022,7 +4020,7 @@ int mg_get_ICV(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                TRACE_RET(chip, STATUS_FAIL);
        }
 
-       buf = (u8 *)rtsx_alloc_dma_buf(chip, 1028, GFP_KERNEL);
+       buf = kmalloc(1028, GFP_KERNEL);
        if (!buf) {
                TRACE_RET(chip, STATUS_ERROR);
        }
@@ -4055,9 +4053,7 @@ int mg_get_ICV(struct scsi_cmnd *srb, struct rtsx_chip *chip)
        rtsx_stor_set_xfer_buf(buf, bufflen, srb);
 
 GetICVFinish:
-       if (buf) {
-               rtsx_free_dma_buf(chip, buf);
-       }
+       kfree(buf);
        return retval;
 }
 
@@ -4081,7 +4077,7 @@ int mg_set_ICV(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                TRACE_RET(chip, STATUS_FAIL);
        }
 
-       buf = (u8 *)rtsx_alloc_dma_buf(chip, 1028, GFP_KERNEL);
+       buf = kmalloc(1028, GFP_KERNEL);
        if (!buf) {
                TRACE_RET(chip, STATUS_ERROR);
        }
@@ -4156,9 +4152,7 @@ int mg_set_ICV(struct scsi_cmnd *srb, struct rtsx_chip *chip)
 #endif
 
 SetICVFinish:
-       if (buf) {
-               rtsx_free_dma_buf(chip, buf);
-       }
+       kfree(buf);
        return retval;
 }
 
index 02525d57ba83c8bb5278200baaed59b267bc6a0b..5ff59f27d101cf341f6660b98fb2945482957a4f 100644 (file)
@@ -594,7 +594,9 @@ static int rtsx_polling_thread(void *__dev)
        wait_timeout((delay_use + 5) * 1000);
 
        for (;;) {
-               wait_timeout(POLLING_INTERVAL);
+
+               set_current_state(TASK_INTERRUPTIBLE);
+               schedule_timeout(POLLING_INTERVAL);
 
                /* lock the device pointers */
                mutex_lock(&(dev->dev_mutex));
index 4d5ddf6fbb5e1af4dde7b6e57847d2514f0aae8d..6afb6358e7750d902fedee8e9da3165be5d0d7ba 100644 (file)
@@ -98,9 +98,6 @@ do {                                                  \
 
 #define SCSI_LUN(srb)          ((srb)->device->lun)
 
-#define rtsx_alloc_dma_buf(chip, size, flag)   kmalloc((size), (flag))
-#define rtsx_free_dma_buf(chip, ptr)           kfree((ptr))
-
 typedef unsigned long DELAY_PARA_T;
 
 struct rtsx_chip;
index b1277a6c7a8b857dd602ee610a764ab7810ec099..bddb0312b31eb2543f2baa75751c6a6e5d5c6109 100644 (file)
@@ -2227,6 +2227,7 @@ static int sd_read_lba0(struct rtsx_chip *chip)
        retval = sd_read_data(chip, SD_TM_NORMAL_READ, cmd,
                5, 512, 1, bus_width, NULL, 0, 100);
        if (retval != STATUS_SUCCESS) {
+               rtsx_clear_sd_error(chip);
                TRACE_RET(chip, STATUS_FAIL);
        }
 
index 8a8689b327ae20e3c49353e8e1004aa984c6215e..c803ba635509dc05ca523a9c46b79adf70f30aaf 100644 (file)
@@ -505,7 +505,7 @@ int spi_read_flash(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                TRACE_RET(chip, STATUS_FAIL);
        }
 
-       buf = (u8 *)rtsx_alloc_dma_buf(chip, SF_PAGE_LEN, GFP_KERNEL);
+       buf = kmalloc(SF_PAGE_LEN, GFP_KERNEL);
        if (buf == NULL)
                TRACE_RET(chip, STATUS_ERROR);
 
@@ -543,7 +543,7 @@ int spi_read_flash(struct scsi_cmnd *srb, struct rtsx_chip *chip)
 
                retval = rtsx_transfer_data(chip, 0, buf, pagelen, 0, DMA_FROM_DEVICE, 10000);
                if (retval < 0) {
-                       rtsx_free_dma_buf(chip, buf);
+                       kfree(buf);
                        rtsx_clear_spi_error(chip);
                        spi_set_err_code(chip, SPI_HW_ERR);
                        TRACE_RET(chip, STATUS_FAIL);
@@ -556,7 +556,7 @@ int spi_read_flash(struct scsi_cmnd *srb, struct rtsx_chip *chip)
        }
 
        scsi_set_resid(srb, 0);
-       rtsx_free_dma_buf(chip, buf);
+       kfree(buf);
 
        return STATUS_SUCCESS;
 }
@@ -584,14 +584,14 @@ int spi_write_flash(struct scsi_cmnd *srb, struct rtsx_chip *chip)
        }
 
        if (program_mode == BYTE_PROGRAM) {
-               buf = rtsx_alloc_dma_buf(chip, 4, GFP_KERNEL);
+               buf = kmalloc(4, GFP_KERNEL);
                if (!buf)
                        TRACE_RET(chip, STATUS_ERROR);
 
                while (len) {
                        retval = sf_enable_write(chip, SPI_WREN);
                        if (retval != STATUS_SUCCESS) {
-                               rtsx_free_dma_buf(chip, buf);
+                               kfree(buf);
                                TRACE_RET(chip, STATUS_FAIL);
                        }
 
@@ -605,7 +605,7 @@ int spi_write_flash(struct scsi_cmnd *srb, struct rtsx_chip *chip)
 
                        retval = rtsx_send_cmd(chip, 0, 100);
                        if (retval < 0) {
-                               rtsx_free_dma_buf(chip, buf);
+                               kfree(buf);
                                rtsx_clear_spi_error(chip);
                                spi_set_err_code(chip, SPI_HW_ERR);
                                TRACE_RET(chip, STATUS_FAIL);
@@ -613,7 +613,7 @@ int spi_write_flash(struct scsi_cmnd *srb, struct rtsx_chip *chip)
 
                        retval = sf_polling_status(chip, 100);
                        if (retval != STATUS_SUCCESS) {
-                               rtsx_free_dma_buf(chip, buf);
+                               kfree(buf);
                                TRACE_RET(chip, STATUS_FAIL);
                        }
 
@@ -621,7 +621,7 @@ int spi_write_flash(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                        len--;
                }
 
-               rtsx_free_dma_buf(chip, buf);
+               kfree(buf);
 
        } else if (program_mode == AAI_PROGRAM) {
                int first_byte = 1;
@@ -630,7 +630,7 @@ int spi_write_flash(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                if (retval != STATUS_SUCCESS)
                        TRACE_RET(chip, STATUS_FAIL);
 
-               buf = rtsx_alloc_dma_buf(chip, 4, GFP_KERNEL);
+               buf = kmalloc(4, GFP_KERNEL);
                if (!buf)
                        TRACE_RET(chip, STATUS_ERROR);
 
@@ -650,7 +650,7 @@ int spi_write_flash(struct scsi_cmnd *srb, struct rtsx_chip *chip)
 
                        retval = rtsx_send_cmd(chip, 0, 100);
                        if (retval < 0) {
-                               rtsx_free_dma_buf(chip, buf);
+                               kfree(buf);
                                rtsx_clear_spi_error(chip);
                                spi_set_err_code(chip, SPI_HW_ERR);
                                TRACE_RET(chip, STATUS_FAIL);
@@ -658,14 +658,14 @@ int spi_write_flash(struct scsi_cmnd *srb, struct rtsx_chip *chip)
 
                        retval = sf_polling_status(chip, 100);
                        if (retval != STATUS_SUCCESS) {
-                               rtsx_free_dma_buf(chip, buf);
+                               kfree(buf);
                                TRACE_RET(chip, STATUS_FAIL);
                        }
 
                        len--;
                }
 
-               rtsx_free_dma_buf(chip, buf);
+               kfree(buf);
 
                retval = sf_disable_write(chip, SPI_WRDI);
                if (retval != STATUS_SUCCESS)
@@ -675,7 +675,7 @@ int spi_write_flash(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                if (retval != STATUS_SUCCESS)
                        TRACE_RET(chip, STATUS_FAIL);
        } else if (program_mode == PAGE_PROGRAM) {
-               buf = rtsx_alloc_dma_buf(chip, SF_PAGE_LEN, GFP_KERNEL);
+               buf = kmalloc(SF_PAGE_LEN, GFP_KERNEL);
                if (!buf)
                        TRACE_RET(chip, STATUS_NOMEM);
 
@@ -687,7 +687,7 @@ int spi_write_flash(struct scsi_cmnd *srb, struct rtsx_chip *chip)
 
                        retval = sf_enable_write(chip, SPI_WREN);
                        if (retval != STATUS_SUCCESS) {
-                               rtsx_free_dma_buf(chip, buf);
+                               kfree(buf);
                                TRACE_RET(chip, STATUS_FAIL);
                        }
 
@@ -702,7 +702,7 @@ int spi_write_flash(struct scsi_cmnd *srb, struct rtsx_chip *chip)
 
                        retval = rtsx_transfer_data(chip, 0, buf, pagelen, 0, DMA_TO_DEVICE, 100);
                        if (retval < 0) {
-                               rtsx_free_dma_buf(chip, buf);
+                               kfree(buf);
                                rtsx_clear_spi_error(chip);
                                spi_set_err_code(chip, SPI_HW_ERR);
                                TRACE_RET(chip, STATUS_FAIL);
@@ -710,7 +710,7 @@ int spi_write_flash(struct scsi_cmnd *srb, struct rtsx_chip *chip)
 
                        retval = sf_polling_status(chip, 100);
                        if (retval != STATUS_SUCCESS) {
-                               rtsx_free_dma_buf(chip, buf);
+                               kfree(buf);
                                TRACE_RET(chip, STATUS_FAIL);
                        }
 
@@ -718,7 +718,7 @@ int spi_write_flash(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                        len -= pagelen;
                }
 
-               rtsx_free_dma_buf(chip, buf);
+               kfree(buf);
        } else {
                spi_set_err_code(chip, SPI_INVALID_COMMAND);
                TRACE_RET(chip, STATUS_FAIL);
index 9f3add1e8f59d885564703688df6d76554d228c6..9bba5b11a824855fe7b3ed321edc203973d56673 100644 (file)
@@ -380,7 +380,7 @@ static void xd_clear_dma_buffer(struct rtsx_chip *chip)
 
                RTSX_DEBUGP("xD ECC error, dummy write!\n");
 
-               buf = (u8 *)rtsx_alloc_dma_buf(chip, 512, GFP_KERNEL);
+               buf = kmalloc(512, GFP_KERNEL);
                if (!buf)
                        return;
 
@@ -427,7 +427,7 @@ static void xd_clear_dma_buffer(struct rtsx_chip *chip)
                        rtsx_write_register(chip, CARD_STOP, SD_STOP | SD_CLR_ERR, SD_STOP | SD_CLR_ERR);
                }
 
-               rtsx_free_dma_buf(chip, buf);
+               kfree(buf);
 
                if (chip->asic_code) {
                        rtsx_write_register(chip, CARD_PULL_CTL2, 0xFF, 0x55);
index 126a9720c6b8c5e353d0c18a329eb48c87ec595d..9dc4ec2109eb13effa559cc185f42354c9e60367 100644 (file)
@@ -341,10 +341,6 @@ u32 dc_init_descriptor_list(struct channel *sc)
                sc->ether.tx_ring = kzalloc(SBE_2T3E3_TX_DESC_RING_SIZE *
                                            sizeof(t3e3_tx_desc_t), GFP_KERNEL);
        if (sc->ether.tx_ring == NULL) {
-#ifdef T3E3_USE_CONTIGMALLOC
-               t3e3_contigmemory_size = SBE_2T3E3_RX_DESC_RING_SIZE *
-                       sizeof(t3e3_rx_desc_t);
-#endif
                kfree(sc->ether.rx_ring);
                sc->ether.rx_ring = NULL;
                dev_err(&sc->pdev->dev, "SBE 2T3E3: no buffer space for RX ring\n");
@@ -366,16 +362,8 @@ u32 dc_init_descriptor_list(struct channel *sc)
                                        dev_kfree_skb_any(sc->ether.rx_data[j]);
                                        sc->ether.rx_data[j] = NULL;
                                }
-#ifdef T3E3_USE_CONTIGMALLOC
-                               t3e3_contigmemory_size = SBE_2T3E3_RX_DESC_RING_SIZE *
-                                       sizeof(t3e3_rx_desc_t);
-#endif
                                kfree(sc->ether.rx_ring);
                                sc->ether.rx_ring = NULL;
-#ifdef T3E3_USE_CONTIGMALLOC
-                               t3e3_contigmemory_size = SBE_2T3E3_TX_DESC_RING_SIZE *
-                                       sizeof(t3e3_tx_desc_t);
-#endif
                                kfree(sc->ether.tx_ring);
                                sc->ether.tx_ring = NULL;
                                dev_err(&sc->pdev->dev, "SBE 2T3E3: token_alloc err:"
@@ -454,23 +442,10 @@ void dc_drop_descriptor_list(struct channel *sc)
                }
        }
 
-       if (sc->ether.rx_ring != NULL) {
-#ifdef T3E3_USE_CONTIGMALLOC
-               t3e3_contigmemory_size = SBE_2T3E3_RX_DESC_RING_SIZE *
-                       sizeof(t3e3_rx_desc_t);
-#endif
-               kfree(sc->ether.rx_ring);
-               sc->ether.rx_ring = NULL;
-       }
-
-       if (sc->ether.tx_ring != NULL) {
-#ifdef T3E3_USE_CONTIGMALLOC
-               t3e3_contigmemory_size = SBE_2T3E3_TX_DESC_RING_SIZE *
-                       sizeof(t3e3_tx_desc_t);
-#endif
-               kfree(sc->ether.tx_ring);
-               sc->ether.tx_ring = NULL;
-       }
+       kfree(sc->ether.rx_ring);
+       sc->ether.rx_ring = NULL;
+       kfree(sc->ether.tx_ring);
+       sc->ether.tx_ring = NULL;
 }
 
 
index 890eede5e3f916cd24752898a1620d50c8173c00..52342c17eaddd797968265dee3762be1a9bfcff4 100644 (file)
@@ -1095,13 +1095,16 @@ static int sep_lock_user_pages(struct sep_device *sep,
        if (num_pages > 1) {
                lli_array[num_pages - 1].block_size =
                        (app_virt_addr + data_size) & (~PAGE_MASK);
+               if (lli_array[num_pages - 1].block_size == 0)
+                       lli_array[num_pages - 1].block_size = PAGE_SIZE;
 
                dev_warn(&sep->pdev->dev,
-                       "lli_array[%x].bus_address is %08lx, lli_array[%x].block_size is %x\n",
+                       "lli_array[%x].bus_address is "
+                       "%08lx, lli_array[%x].block_size is %x\n",
                        num_pages - 1,
-                       (unsigned long)lli_array[count].bus_address,
+                       (unsigned long)lli_array[num_pages -1].bus_address,
                        num_pages - 1,
-                       lli_array[count].block_size);
+                       lli_array[num_pages -1].block_size);
        }
 
        /* Set output params according to the in_out flag */
index a66d9e406497fbbea5a444f80ef93d69a685c612..7304021368c3ad09cd1ffc5e94ac52c4ac64bd88 100644 (file)
@@ -2,9 +2,7 @@ TODO:
 - Dual head support
 - 2D acceleration support
 - use kernel coding style
-- checkpatch.pl clean
 - refine the code and remove unused code
-- use kernel framebuffer mode setting instead of hard code
 - move it to drivers/video/sm7xx/ or make it be drivers/video/sm7xxfb.c
 
 Please send any patches to Greg Kroah-Hartman <greg@kroah.com> and
index 3e2230f0879a327ebc1b1064fcc7c34f2bf813ae..a164fc43bd8ee19fe805c5cb9a1a8dd966a23a2a 100644 (file)
@@ -8,21 +8,24 @@
  * Copyright (C) 2009 Lemote, Inc.
  * Author: Wu Zhangjin, wuzhangjin@gmail.com
  *
+ * Copyright (C) 2011 Igalia, S.L.
+ * Author: Javier M. Mellid <jmunhoz@igalia.com>
+ *
  *  This file is subject to the terms and conditions of the GNU General Public
  *  License. See the file COPYING in the main directory of this archive for
  *  more details.
  *
  * Version 0.10.26192.21.01
  *     - Add PowerPC/Big endian support
- *     - Add 2D support for Lynx
- *     - Verified on2.6.19.2  Boyod.yang <boyod.yang@siliconmotion.com.cn>
+ *     - Verified on 2.6.19.2
+ *     Boyod.yang <boyod.yang@siliconmotion.com.cn>
  *
  * Version 0.09.2621.00.01
- *     - Only support Linux Kernel's version 2.6.21.
- *     Boyod.yang  <boyod.yang@siliconmotion.com.cn>
+ *     - Only support Linux Kernel's version 2.6.21
+ *     Boyod.yang <boyod.yang@siliconmotion.com.cn>
  *
  * Version 0.09
- *     - Only support Linux Kernel's version 2.6.12.
+ *     - Only support Linux Kernel's version 2.6.12
  *     Boyod.yang <boyod.yang@siliconmotion.com.cn>
  */
 
 #include <linux/pm.h>
 #endif
 
-struct screen_info smtc_screen_info;
-
 #include "smtcfb.h"
 
 #ifdef DEBUG
-#define smdbg(format, arg...)  printk(KERN_DEBUG format , ## arg)
+#define smdbg(format, arg...) printk(KERN_DEBUG format , ## arg)
 #else
 #define smdbg(format, arg...)
 #endif
 
+struct screen_info smtc_screen_info;
+
 /*
 * Private structure
 */
@@ -99,17 +102,17 @@ struct vesa_mode_table     {
 static struct vesa_mode_table vesa_mode[] = {
        {"0x301", 640,  480,  8},
        {"0x303", 800,  600,  8},
-       {"0x305", 1024, 768,    8},
+       {"0x305", 1024, 768,  8},
        {"0x307", 1280, 1024, 8},
 
        {"0x311", 640,  480,  16},
        {"0x314", 800,  600,  16},
-       {"0x317", 1024, 768,    16},
+       {"0x317", 1024, 768,  16},
        {"0x31A", 1280, 1024, 16},
 
        {"0x312", 640,  480,  24},
        {"0x315", 800,  600,  24},
-       {"0x318", 1024, 768,    24},
+       {"0x318", 1024, 768,  24},
        {"0x31B", 1280, 1024, 24},
 };
 
@@ -125,7 +128,30 @@ u16 smtc_ChipIDs[] = {
        0x720
 };
 
-#define numSMTCchipIDs (sizeof(smtc_ChipIDs) / sizeof(u16))
+#define numSMTCchipIDs ARRAY_SIZE(smtc_ChipIDs)
+
+static struct fb_var_screeninfo smtcfb_var = {
+       .xres           = 1024,
+       .yres           = 600,
+       .xres_virtual   = 1024,
+       .yres_virtual   = 600,
+       .bits_per_pixel = 16,
+       .red            = {16, 8, 0},
+       .green          = {8, 8, 0},
+       .blue           = {0, 8, 0},
+       .activate       = FB_ACTIVATE_NOW,
+       .height         = -1,
+       .width          = -1,
+       .vmode          = FB_VMODE_NONINTERLACED,
+};
+
+static struct fb_fix_screeninfo smtcfb_fix = {
+       .id             = "sm712fb",
+       .type           = FB_TYPE_PACKED_PIXELS,
+       .visual         = FB_VISUAL_TRUECOLOR,
+       .line_length    = 800 * 3,
+       .accel          = FB_ACCEL_SMI_LYNX,
+};
 
 static void sm712_set_timing(struct smtcfb_info *sfb,
                             struct par_info *ppar_info)
@@ -268,29 +294,6 @@ static void smtc_set_timing(struct smtcfb_info *sfb, struct par_info
        }
 }
 
-static struct fb_var_screeninfo smtcfb_var = {
-       .xres = 1024,
-       .yres = 600,
-       .xres_virtual = 1024,
-       .yres_virtual = 600,
-       .bits_per_pixel = 16,
-       .red = {16, 8, 0},
-       .green = {8, 8, 0},
-       .blue = {0, 8, 0},
-       .activate = FB_ACTIVATE_NOW,
-       .height = -1,
-       .width = -1,
-       .vmode = FB_VMODE_NONINTERLACED,
-};
-
-static struct fb_fix_screeninfo smtcfb_fix = {
-       .id = "sm712fb",
-       .type = FB_TYPE_PACKED_PIXELS,
-       .visual = FB_VISUAL_TRUECOLOR,
-       .line_length = 800 * 3,
-       .accel = FB_ACCEL_SMI_LYNX,
-};
-
 /* chan_to_field
  *
  * convert a colour value into a field position
@@ -604,20 +607,6 @@ smtcfb_write(struct fb_info *info, const char __user *buf, size_t count,
 }
 #endif /* ! __BIG_ENDIAN */
 
-static struct fb_ops smtcfb_ops = {
-       .owner = THIS_MODULE,
-       .fb_setcolreg = smtc_setcolreg,
-       .fb_blank = cfb_blank,
-       .fb_fillrect = cfb_fillrect,
-       .fb_imageblit = cfb_imageblit,
-       .fb_copyarea = cfb_copyarea,
-#ifdef __BIG_ENDIAN
-       .fb_read = smtcfb_read,
-       .fb_write = smtcfb_write,
-#endif
-
-};
-
 void smtcfb_setmode(struct smtcfb_info *sfb)
 {
        switch (sfb->fb.var.bits_per_pixel) {
@@ -676,6 +665,47 @@ void smtcfb_setmode(struct smtcfb_info *sfb)
        smtc_set_timing(sfb, &hw);
 }
 
+static int smtc_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
+{
+       /* sanity checks */
+       if (var->xres_virtual < var->xres)
+               var->xres_virtual = var->xres;
+
+       if (var->yres_virtual < var->yres)
+               var->yres_virtual = var->yres;
+
+       /* set valid default bpp */
+       if ((var->bits_per_pixel != 8)  && (var->bits_per_pixel != 16) &&
+           (var->bits_per_pixel != 24) && (var->bits_per_pixel != 32))
+               var->bits_per_pixel = 16;
+
+       return 0;
+}
+
+static int smtc_set_par(struct fb_info *info)
+{
+       struct smtcfb_info *sfb = (struct smtcfb_info *)info;
+
+       smtcfb_setmode(sfb);
+
+       return 0;
+}
+
+static struct fb_ops smtcfb_ops = {
+       .owner        = THIS_MODULE,
+       .fb_check_var = smtc_check_var,
+       .fb_set_par   = smtc_set_par,
+       .fb_setcolreg = smtc_setcolreg,
+       .fb_blank     = cfb_blank,
+       .fb_fillrect  = cfb_fillrect,
+       .fb_imageblit = cfb_imageblit,
+       .fb_copyarea  = cfb_copyarea,
+#ifdef __BIG_ENDIAN
+       .fb_read      = smtcfb_read,
+       .fb_write     = smtcfb_write,
+#endif
+};
+
 /*
  * Alloc struct smtcfb_info and assign the default value
  */
@@ -684,7 +714,7 @@ static struct smtcfb_info *smtc_alloc_fb_info(struct pci_dev *dev,
 {
        struct smtcfb_info *sfb;
 
-       sfb = kzalloc(sizeof(struct smtcfb_info), GFP_KERNEL);
+       sfb = kzalloc(sizeof(*sfb), GFP_KERNEL);
 
        if (!sfb)
                return NULL;
@@ -753,7 +783,7 @@ static int smtc_map_smem(struct smtcfb_info *sfb,
        sfb->fb.screen_base = smtc_VRAMBaseAddress;
 
        if (!sfb->fb.screen_base) {
-               printk(KERN_INFO "%s: unable to map screen memory\n",
+               printk(KERN_ERR "%s: unable to map screen memory\n",
                                sfb->fb.fix.id);
                return -ENOMEM;
        }
@@ -796,7 +826,7 @@ static void smtc_free_fb_info(struct smtcfb_info *sfb)
  *     Returns zero.
  *
  */
-static int __init __maybe_unused sm712vga_setup(char *options)
+static int __init sm712vga_setup(char *options)
 {
        int index;
 
@@ -812,7 +842,7 @@ static int __init __maybe_unused sm712vga_setup(char *options)
        smdbg("\nsm712vga_setup = %s\n", options);
 
        for (index = 0;
-            index < (sizeof(vesa_mode) / sizeof(struct vesa_mode_table));
+            index < ARRAY_SIZE(vesa_mode);
             index++) {
                if (strstr(options, vesa_mode[index].mode_index)) {
                        smtc_screen_info.lfb_width = vesa_mode[index].lfb_width;
@@ -846,7 +876,6 @@ static int __devinit smtcfb_pci_probe(struct pci_dev *pdev,
        err = pci_enable_device(pdev);  /* enable SMTC chip */
        if (err)
                return err;
-       err = -ENOMEM;
 
        hw.chipID = ent->device;
        sprintf(name, "sm%Xfb", hw.chipID);
@@ -909,7 +938,7 @@ static int __devinit smtcfb_pci_probe(struct pci_dev *pdev,
                }
 #endif
                if (!smtc_RegBaseAddress) {
-                       printk(KERN_INFO
+                       printk(KERN_ERR
                                "%s: unable to map memory mapped IO\n",
                                sfb->fb.fix.id);
                        err = -ENOMEM;
@@ -944,7 +973,7 @@ static int __devinit smtcfb_pci_probe(struct pci_dev *pdev,
                smtc_seqw(0x6b, 0x02);
                break;
        default:
-               printk(KERN_INFO
+               printk(KERN_ERR
                "No valid Silicon Motion display chip was detected!\n");
 
                goto failed_fb;
@@ -976,8 +1005,8 @@ static int __devinit smtcfb_pci_probe(struct pci_dev *pdev,
 
        return 0;
 
- failed:
-       printk(KERN_INFO "Silicon Motion, Inc.  primary display init fail\n");
+failed:
+       printk(KERN_ERR "Silicon Motion, Inc.  primary display init fail\n");
 
        smtc_unmap_smem(sfb);
        smtc_unmap_mmio(sfb);
@@ -1016,13 +1045,10 @@ static void __devexit smtcfb_pci_remove(struct pci_dev *pdev)
 }
 
 #ifdef CONFIG_PM
-/* Jason (08/14/2009)
- * suspend function, called when the suspend event is triggered
- */
-static int __maybe_unused smtcfb_suspend(struct pci_dev *pdev, pm_message_t msg)
+static int smtcfb_pci_suspend(struct device *device)
 {
+       struct pci_dev *pdev = to_pci_dev(device);
        struct smtcfb_info *sfb;
-       int retv;
 
        sfb = pci_get_drvdata(pdev);
 
@@ -1032,25 +1058,9 @@ static int __maybe_unused smtcfb_suspend(struct pci_dev *pdev, pm_message_t msg)
        smtc_seqw(0x20, (smtc_seqr(0x20) | 0xc0));
        smtc_seqw(0x69, (smtc_seqr(0x69) & 0xf7));
 
-       switch (msg.event) {
-       case PM_EVENT_FREEZE:
-       case PM_EVENT_PRETHAW:
-               pdev->dev.power.power_state = msg;
-               return 0;
-       }
-
-       /* when doing suspend, call fb apis and pci apis */
-       if (msg.event == PM_EVENT_SUSPEND) {
-               console_lock();
-               fb_set_suspend(&sfb->fb, 1);
-               console_unlock();
-               retv = pci_save_state(pdev);
-               pci_disable_device(pdev);
-               retv = pci_choose_state(pdev, msg);
-               retv = pci_set_power_state(pdev, retv);
-       }
-
-       pdev->dev.power.power_state = msg;
+       console_lock();
+       fb_set_suspend(&sfb->fb, 1);
+       console_unlock();
 
        /* additionally turn off all function blocks including internal PLLs */
        smtc_seqw(0x21, 0xff);
@@ -1058,22 +1068,13 @@ static int __maybe_unused smtcfb_suspend(struct pci_dev *pdev, pm_message_t msg)
        return 0;
 }
 
-static int __maybe_unused smtcfb_resume(struct pci_dev *pdev)
+static int smtcfb_pci_resume(struct device *device)
 {
+       struct pci_dev *pdev = to_pci_dev(device);
        struct smtcfb_info *sfb;
-       int retv;
 
        sfb = pci_get_drvdata(pdev);
 
-       /* when resuming, restore pci data and fb cursor */
-       if (pdev->dev.power.power_state.event != PM_EVENT_FREEZE) {
-               retv = pci_set_power_state(pdev, PCI_D0);
-               pci_restore_state(pdev);
-               if (pci_enable_device(pdev))
-                       return -1;
-               pci_set_master(pdev);
-       }
-
        /* reinit hardware */
        sm7xx_init_hw();
        switch (hw.chipID) {
@@ -1108,22 +1109,30 @@ static int __maybe_unused smtcfb_resume(struct pci_dev *pdev)
 
        return 0;
 }
-#endif
 
-/* Jason (08/13/2009)
- * pci_driver struct used to wrap the original driver
- * so that it can be registered into the kernel and
- * the proper method would be called when suspending and resuming
- */
+static const struct dev_pm_ops sm7xx_pm_ops = {
+       .suspend = smtcfb_pci_suspend,
+       .resume = smtcfb_pci_resume,
+       .freeze = smtcfb_pci_suspend,
+       .thaw = smtcfb_pci_resume,
+       .poweroff = smtcfb_pci_suspend,
+       .restore = smtcfb_pci_resume,
+};
+
+#define SM7XX_PM_OPS (&sm7xx_pm_ops)
+
+#else  /* !CONFIG_PM */
+
+#define SM7XX_PM_OPS NULL
+
+#endif /* !CONFIG_PM */
+
 static struct pci_driver smtcfb_driver = {
        .name = "smtcfb",
        .id_table = smtcfb_pci_table,
        .probe = smtcfb_pci_probe,
        .remove = __devexit_p(smtcfb_pci_remove),
-#ifdef CONFIG_PM
-       .suspend = smtcfb_suspend,
-       .resume = smtcfb_resume,
-#endif
+       .driver.pm  = SM7XX_PM_OPS,
 };
 
 static int __init smtcfb_init(void)
index 0c113835b85c0f29e76e99b8f9d56dc02dc79394..c5e6989e65ab6893ccca21877a67c75fc4b08172 100644 (file)
 #define SCREEN_Y_RES      600
 #define SCREEN_BPP        16
 
-#ifndef FIELD_OFFSET
-#define FIELD_OFSFET(type, field) \
-       ((unsigned long) (PUCHAR) & (((type *)0)->field))
-#endif
-
 /*Assume SM712 graphics chip has 4MB VRAM */
 #define SM712_VIDEOMEMORYSIZE    0x00400000
 /*Assume SM722 graphics chip has 8MB VRAM */
@@ -790,4 +785,4 @@ struct ModeInit VGAMode[] = {
         },
 };
 
-#define numVGAModes            (sizeof(VGAMode) / sizeof(struct ModeInit))
+#define numVGAModes            ARRAY_SIZE(VGAMode)
index 0b266272cccd5f6a6edbab2c79c067adb178e75a..ca18cbf4e3c9f26c1d49cc980d79e59bf8ab08ba 100644 (file)
@@ -186,7 +186,6 @@ static struct ktermios              stli_deftermios = {
  *     re-used for each stats call.
  */
 static comstats_t      stli_comstats;
-static combrd_t                stli_brdstats;
 static struct asystats stli_cdkstats;
 
 /*****************************************************************************/
@@ -4005,6 +4004,7 @@ static int stli_getbrdstats(combrd_t __user *bp)
 {
        struct stlibrd *brdp;
        unsigned int i;
+       combrd_t stli_brdstats;
 
        if (copy_from_user(&stli_brdstats, bp, sizeof(combrd_t)))
                return -EFAULT;
index 2c1d10acb8b52c6022461d9babb48c521f4bb93b..dd13c022068165bc3cc2b1dc160a6cbcd862c9ed 100644 (file)
@@ -1,43 +1,45 @@
-config USB_IP_COMMON
-       tristate "USB IP support (EXPERIMENTAL)"
+config USBIP_CORE
+       tristate "USB/IP support (EXPERIMENTAL)"
        depends on USB && NET && EXPERIMENTAL
        default N
        ---help---
          This enables pushing USB packets over IP to allow remote
-         machines access to USB devices directly.  For more details,
-         and links to the userspace utility programs to let this work
-         properly, see http://usbip.sourceforge.net/.
+         machines direct access to USB devices. It provides the
+         USB/IP core that is required by both drivers.
 
-         To compile this driver as a module, choose M here: the
-         module will be called usbip_common_mod.
+         For more details, and to get the userspace utility
+         programs, please see http://usbip.sourceforge.net/.
+
+         To compile this as a module, choose M here: the module will
+         be called usbip-core.
 
          If unsure, say N.
 
-config USB_IP_VHCI_HCD
-       tristate "USB IP client driver"
-       depends on USB_IP_COMMON
+config USBIP_VHCI_HCD
+       tristate "VHCI hcd"
+       depends on USBIP_CORE
        default N
        ---help---
-        This enables the USB IP host controller driver which will
-        run on the client machine.
+         This enables the USB/IP virtual host controller driver,
+         which is run on the remote machine.
 
-        To compile this driver as a module, choose M here: the
-        module will be called vhci_hcd.
+         To compile this driver as a module, choose M here: the
+         module will be called vhci-hcd.
 
-config USB_IP_HOST
-       tristate "USB IP host driver"
-       depends on USB_IP_COMMON
+config USBIP_HOST
+       tristate "Host driver"
+       depends on USBIP_CORE
        default N
        ---help---
-        This enables the USB IP device driver which will run on the
-        host machine.
+         This enables the USB/IP host driver, which is run on the
+         machine that is sharing the USB devices.
 
-        To compile this driver as a module, choose M here: the
-        module will be called usbip.
+         To compile this driver as a module, choose M here: the
+         module will be called usbip-host.
 
-config USB_IP_DEBUG_ENABLE
-       bool "USB-IP Debug Enable"
-       depends on USB_IP_COMMON
+config USBIP_DEBUG
+       bool "Debug messages for USB/IP"
+       depends on USBIP_CORE
        default N
        ---help---
-         This enables the debug messages from the USB-IP drivers.
+         This enables the debug messages from the USB/IP drivers.
index 279f3cc3eea80daa19bf2d6fe447efe4b3145d6a..9ecd61545be19de4cd9dd96aa5c4b41b952a9954 100644 (file)
@@ -1,11 +1,10 @@
-obj-$(CONFIG_USB_IP_COMMON) += usbip_common_mod.o
-usbip_common_mod-y := usbip_common.o usbip_event.o
+ccflags-$(CONFIG_USBIP_DEBUG) := -DDEBUG
 
-obj-$(CONFIG_USB_IP_VHCI_HCD) += vhci-hcd.o
-vhci-hcd-y := vhci_sysfs.o vhci_tx.o vhci_rx.o vhci_hcd.o
-
-obj-$(CONFIG_USB_IP_HOST) += usbip.o
-usbip-y := stub_dev.o stub_main.o stub_rx.o stub_tx.o
+obj-$(CONFIG_USBIP_CORE) += usbip-core.o
+usbip-core-y := usbip_common.o usbip_event.o
 
-ccflags-$(CONFIG_USB_IP_DEBUG_ENABLE) := -DDEBUG
+obj-$(CONFIG_USBIP_VHCI_HCD) += vhci-hcd.o
+vhci-hcd-y := vhci_sysfs.o vhci_tx.o vhci_rx.o vhci_hcd.o
 
+obj-$(CONFIG_USBIP_HOST) += usbip-host.o
+usbip-host-y := stub_dev.o stub_main.o stub_rx.o stub_tx.o
index 6004fcdbc1a4bd2b8d71fa4d7c54c6621e4af3c9..6592aa2ad15cacaf3b76c3370b0caf7bb0b52bb4 100644 (file)
  * USA.
  */
 
-#include <linux/kernel.h>
 #include <linux/list.h>
-#include <linux/spinlock.h>
 #include <linux/slab.h>
-#include <linux/string.h>
-#include <linux/module.h>
-#include <linux/net.h>
+#include <linux/spinlock.h>
+#include <linux/types.h>
+#include <linux/usb.h>
+#include <linux/wait.h>
 
 #define STUB_BUSID_OTHER 0
 #define STUB_BUSID_REMOV 1
@@ -58,7 +57,6 @@ struct stub_device {
        struct list_head unlink_tx;
        struct list_head unlink_free;
 
-
        wait_queue_head_t tx_waitq;
 };
 
@@ -87,25 +85,22 @@ struct bus_id_priv {
        char shutdown_busid;
 };
 
+/* stub_priv is allocated from stub_priv_cache */
 extern struct kmem_cache *stub_priv_cache;
 
-
-/*-------------------------------------------------------------------------*/
-/* prototype declarations */
-
-/* stub_tx.c */
-void stub_complete(struct urb *);
-int stub_tx_loop(void *data);
-
 /* stub_dev.c */
 extern struct usb_driver stub_driver;
 
-/* stub_rx.c */
-int stub_rx_loop(void *data);
-void stub_enqueue_ret_unlink(struct stub_device *, __u32, __u32);
-
 /* stub_main.c */
 struct bus_id_priv *get_busid_priv(const char *busid);
 int del_match_busid(char *busid);
-
 void stub_device_cleanup_urbs(struct stub_device *sdev);
+
+/* stub_rx.c */
+int stub_rx_loop(void *data);
+
+/* stub_tx.c */
+void stub_enqueue_ret_unlink(struct stub_device *sdev, __u32 seqnum,
+                            __u32 status);
+void stub_complete(struct urb *urb);
+int stub_tx_loop(void *data);
index bce7d039346c264cadfbee4d8d917678ed957f75..6e99ec87fee0b26505bdb81fc1f9147c463c049f 100644 (file)
  * USA.
  */
 
-#include <linux/slab.h>
+#include <linux/device.h>
 #include <linux/kthread.h>
 
 #include "usbip_common.h"
 #include "stub.h"
 
-
-
 static int stub_probe(struct usb_interface *interface,
-                               const struct usb_device_id *id);
+                     const struct usb_device_id *id);
 static void stub_disconnect(struct usb_interface *interface);
 
-
 /*
  * Define device IDs here if you want to explicitly limit exportable devices.
  * In the most cases, wild card matching will be ok because driver binding can
@@ -64,12 +61,6 @@ struct usb_driver stub_driver = {
        .id_table       = stub_table,
 };
 
-
-/*-------------------------------------------------------------------------*/
-
-/* Define sysfs entries for a usbip-bound device */
-
-
 /*
  * usbip_status shows status of usbip as long as this driver is bound to the
  * target device.
@@ -128,13 +119,11 @@ static ssize_t store_sockfd(struct device *dev, struct device_attribute *attr,
                        spin_unlock(&sdev->ud.lock);
                        return -EINVAL;
                }
-
 #if 0
                setnodelay(socket);
                setkeepalive(socket);
                setreuse(socket);
 #endif
-
                sdev->ud.tcp_socket = socket;
 
                spin_unlock(&sdev->ud.lock);
@@ -183,10 +172,8 @@ static int stub_add_files(struct device *dev)
 
 err_debug:
        device_remove_file(dev, &dev_attr_usbip_sockfd);
-
 err_sockfd:
        device_remove_file(dev, &dev_attr_usbip_status);
-
 err_status:
        return err;
 }
@@ -198,12 +185,6 @@ static void stub_remove_files(struct device *dev)
        device_remove_file(dev, &dev_attr_usbip_debug);
 }
 
-
-
-/*-------------------------------------------------------------------------*/
-
-/* Event handler functions called by an event handler thread */
-
 static void stub_shutdown_connection(struct usbip_device *ud)
 {
        struct stub_device *sdev = container_of(ud, struct stub_device, ud);
@@ -215,7 +196,8 @@ static void stub_shutdown_connection(struct usbip_device *ud)
         * step 1?
         */
        if (ud->tcp_socket) {
-               usbip_udbg("shutdown tcp_socket %p\n", ud->tcp_socket);
+               dev_dbg(&sdev->udev->dev, "shutdown tcp_socket %p\n",
+                       ud->tcp_socket);
                kernel_sock_shutdown(ud->tcp_socket, SHUT_RDWR);
        }
 
@@ -244,18 +226,15 @@ static void stub_shutdown_connection(struct usbip_device *ud)
                struct stub_unlink *unlink, *tmp;
 
                spin_lock_irqsave(&sdev->priv_lock, flags);
-
                list_for_each_entry_safe(unlink, tmp, &sdev->unlink_tx, list) {
                        list_del(&unlink->list);
                        kfree(unlink);
                }
-
                list_for_each_entry_safe(unlink, tmp,
                                                 &sdev->unlink_free, list) {
                        list_del(&unlink->list);
                        kfree(unlink);
                }
-
                spin_unlock_irqrestore(&sdev->priv_lock, flags);
        }
 }
@@ -266,16 +245,14 @@ static void stub_device_reset(struct usbip_device *ud)
        struct usb_device *udev = sdev->udev;
        int ret;
 
-       usbip_udbg("device reset");
+       dev_dbg(&udev->dev, "device reset");
 
        ret = usb_lock_device_for_reset(udev, sdev->interface);
        if (ret < 0) {
                dev_err(&udev->dev, "lock for reset\n");
-
                spin_lock(&ud->lock);
                ud->status = SDEV_ST_ERROR;
                spin_unlock(&ud->lock);
-
                return;
        }
 
@@ -306,9 +283,6 @@ static void stub_device_unusable(struct usbip_device *ud)
        spin_unlock(&ud->lock);
 }
 
-
-/*-------------------------------------------------------------------------*/
-
 /**
  * stub_device_alloc - allocate a new stub_device struct
  * @interface: usb_interface of a new device
@@ -339,13 +313,12 @@ static struct stub_device *stub_device_alloc(struct usb_device *udev,
         * devnum may change later if a device is reset. However, devid never
         * changes during a usbip connection.
         */
-       sdev->devid     = (busnum << 16) | devnum;
-
-       sdev->ud.side = USBIP_STUB;
-       sdev->ud.status = SDEV_ST_AVAILABLE;
+       sdev->devid             = (busnum << 16) | devnum;
+       sdev->ud.side           = USBIP_STUB;
+       sdev->ud.status         = SDEV_ST_AVAILABLE;
        /* sdev->ud.lock = SPIN_LOCK_UNLOCKED; */
        spin_lock_init(&sdev->ud.lock);
-       sdev->ud.tcp_socket = NULL;
+       sdev->ud.tcp_socket     = NULL;
 
        INIT_LIST_HEAD(&sdev->priv_init);
        INIT_LIST_HEAD(&sdev->priv_tx);
@@ -363,7 +336,8 @@ static struct stub_device *stub_device_alloc(struct usb_device *udev,
 
        usbip_start_eh(&sdev->ud);
 
-       usbip_udbg("register new interface\n");
+       dev_dbg(&interface->dev, "register new interface\n");
+
        return sdev;
 }
 
@@ -373,14 +347,11 @@ static int stub_device_free(struct stub_device *sdev)
                return -EINVAL;
 
        kfree(sdev);
-       usbip_udbg("kfree udev ok\n");
+       pr_debug("kfree udev ok\n");
 
        return 0;
 }
 
-
-/*-------------------------------------------------------------------------*/
-
 /*
  * If a usb device has multiple active interfaces, this driver is bound to all
  * the active interfaces. However, usbip exports *a* usb device (i.e., not *an*
@@ -405,10 +376,9 @@ static int stub_probe(struct usb_interface *interface,
        /* check we should claim or not by busid_table */
        busid_priv = get_busid_priv(udev_busid);
        if (!busid_priv  || (busid_priv->status == STUB_BUSID_REMOV) ||
-                            (busid_priv->status == STUB_BUSID_OTHER)) {
-               dev_info(&interface->dev,
-                        "this device %s is not in match_busid table. skip!\n",
-                        udev_busid);
+           (busid_priv->status == STUB_BUSID_OTHER)) {
+               dev_info(&interface->dev, "%s is not in match_busid table... "
+                        "skip!\n", udev_busid);
 
                /*
                 * Return value should be ENODEV or ENOXIO to continue trying
@@ -418,36 +388,35 @@ static int stub_probe(struct usb_interface *interface,
                return -ENODEV;
        }
 
-       if (udev->descriptor.bDeviceClass ==  USB_CLASS_HUB) {
-               usbip_udbg("this device %s is a usb hub device. skip!\n",
-                                                               udev_busid);
+       if (udev->descriptor.bDeviceClass == USB_CLASS_HUB) {
+               dev_dbg(&udev->dev, "%s is a usb hub device... skip!\n",
+                        udev_busid);
                return -ENODEV;
        }
 
        if (!strcmp(udev->bus->bus_name, "vhci_hcd")) {
-               usbip_udbg("this device %s is attached on vhci_hcd. skip!\n",
-                                                               udev_busid);
+               dev_dbg(&udev->dev, "%s is attached on vhci_hcd... skip!\n",
+                        udev_busid);
                return -ENODEV;
        }
 
-
        if (busid_priv->status == STUB_BUSID_ALLOC) {
                sdev = busid_priv->sdev;
                if (!sdev)
                        return -ENODEV;
 
                busid_priv->interf_count++;
-               dev_info(&interface->dev,
-                "USB/IP Stub: register a new interface "
-                "(bus %u dev %u ifn %u)\n", udev->bus->busnum, udev->devnum,
-                interface->cur_altsetting->desc.bInterfaceNumber);
+               dev_info(&interface->dev, "usbip-host: register new interface "
+                        "(bus %u dev %u ifn %u)\n",
+                        udev->bus->busnum, udev->devnum,
+                        interface->cur_altsetting->desc.bInterfaceNumber);
 
                /* set private data to usb_interface */
                usb_set_intfdata(interface, sdev);
 
                err = stub_add_files(&interface->dev);
                if (err) {
-                       dev_err(&interface->dev, "create sysfs files for %s\n",
+                       dev_err(&interface->dev, "stub_add_files for %s\n",
                                udev_busid);
                        usb_set_intfdata(interface, NULL);
                        busid_priv->interf_count--;
@@ -464,7 +433,7 @@ static int stub_probe(struct usb_interface *interface,
        if (!sdev)
                return -ENOMEM;
 
-       dev_info(&interface->dev, "USB/IP Stub: register a new device "
+       dev_info(&interface->dev, "usbip-host: register new device "
                 "(bus %u dev %u ifn %u)\n", udev->bus->busnum, udev->devnum,
                 interface->cur_altsetting->desc.bInterfaceNumber);
 
@@ -479,8 +448,7 @@ static int stub_probe(struct usb_interface *interface,
 
        err = stub_add_files(&interface->dev);
        if (err) {
-               dev_err(&interface->dev, "create sysfs files for %s\n",
-                       udev_busid);
+               dev_err(&interface->dev, "stub_add_files for %s\n", udev_busid);
                usb_set_intfdata(interface, NULL);
                usb_put_intf(interface);
 
@@ -504,10 +472,8 @@ static void shutdown_busid(struct bus_id_priv *busid_priv)
                /* 2. wait for the stop of the event handler */
                usbip_stop_eh(&busid_priv->sdev->ud);
        }
-
 }
 
-
 /*
  * called in usb_disconnect() or usb_deregister()
  * but only if actconfig(active configuration) exists
@@ -518,10 +484,9 @@ static void stub_disconnect(struct usb_interface *interface)
        const char *udev_busid = dev_name(interface->dev.parent);
        struct bus_id_priv *busid_priv;
 
-       busid_priv = get_busid_priv(udev_busid);
-
-       usbip_udbg("Enter\n");
+       dev_dbg(&interface->dev, "Enter\n");
 
+       busid_priv = get_busid_priv(udev_busid);
        if (!busid_priv) {
                BUG();
                return;
@@ -531,7 +496,7 @@ static void stub_disconnect(struct usb_interface *interface)
 
        /* get stub_device */
        if (!sdev) {
-               err(" could not get device from inteface data");
+               dev_err(&interface->dev, "could not get device");
                /* BUG(); */
                return;
        }
@@ -559,7 +524,6 @@ static void stub_disconnect(struct usb_interface *interface)
 
        busid_priv->interf_count = 0;
 
-
        /* 1. shutdown the current connection */
        shutdown_busid(busid_priv);
 
@@ -576,5 +540,4 @@ static void stub_disconnect(struct usb_interface *interface)
                busid_priv->status = STUB_BUSID_OTHER;
                del_match_busid((char *)udev_busid);
        }
-       usbip_udbg("bye\n");
 }
index 076a7e5310987afca3e5494f8bbe54d2af4ef680..e9085d6639450d9835a4d6e86e1adad8f7e294ac 100644 (file)
  * USA.
  */
 
-#include <linux/slab.h>
+#include <linux/string.h>
 
 #include "usbip_common.h"
 #include "stub.h"
 
-/* Version Information */
-#define DRIVER_VERSION "1.0"
 #define DRIVER_AUTHOR "Takahiro Hirofuchi"
-#define DRIVER_DESC "Stub Driver for USB/IP"
+#define DRIVER_DESC "USB/IP Host Driver"
 
 /* stub_priv is allocated from stub_priv_cache */
 struct kmem_cache *stub_priv_cache;
 
-/*-------------------------------------------------------------------------*/
-
-/* Define sysfs entries for the usbip driver */
-
-
 /*
  * busid_tables defines matching busids that usbip can grab. A user can change
  * dynamically what device is locally used and what device is exported to a
@@ -44,7 +37,6 @@ struct kmem_cache *stub_priv_cache;
 static struct bus_id_priv busid_table[MAX_BUSID];
 static spinlock_t busid_table_lock;
 
-
 int match_busid(const char *busid)
 {
        int i;
@@ -148,11 +140,11 @@ int del_match_busid(char *busid)
 
        return -1;
 }
+
 static void init_busid_table(void)
 {
        int i;
 
-
        for (i = 0; i < MAX_BUSID; i++) {
                memset(busid_table[i].name, 0, BUSID_SIZE);
                busid_table[i].status = STUB_BUSID_OTHER;
@@ -160,11 +152,12 @@ static void init_busid_table(void)
                busid_table[i].sdev = NULL;
                busid_table[i].shutdown_busid = 0;
        }
+
        spin_lock_init(&busid_table_lock);
 }
 
 static ssize_t store_match_busid(struct device_driver *dev, const char *buf,
-               size_t count)
+                                size_t count)
 {
        int len;
        char busid[BUSID_SIZE];
@@ -181,33 +174,25 @@ static ssize_t store_match_busid(struct device_driver *dev, const char *buf,
 
        strncpy(busid, buf + 4, BUSID_SIZE);
 
-
        if (!strncmp(buf, "add ", 4)) {
                if (add_match_busid(busid) < 0)
                        return -ENOMEM;
                else {
-                       usbip_udbg("add busid %s\n", busid);
+                       pr_debug("add busid %s\n", busid);
                        return count;
                }
        } else if (!strncmp(buf, "del ", 4)) {
                if (del_match_busid(busid) < 0)
                        return -ENODEV;
                else {
-                       usbip_udbg("del busid %s\n", busid);
+                       pr_debug("del busid %s\n", busid);
                        return count;
                }
        } else
                return -EINVAL;
 }
-
 static DRIVER_ATTR(match_busid, S_IRUSR|S_IWUSR, show_match_busid,
-                                                       store_match_busid);
-
-
-
-/*-------------------------------------------------------------------------*/
-
-/* Cleanup functions used to free private data */
+                  store_match_busid);
 
 static struct stub_priv *stub_priv_pop_from_listhead(struct list_head *listhead)
 {
@@ -254,27 +239,23 @@ void stub_device_cleanup_urbs(struct stub_device *sdev)
 {
        struct stub_priv *priv;
 
-       usbip_udbg("free sdev %p\n", sdev);
+       dev_dbg(&sdev->udev->dev, "free sdev %p\n", sdev);
 
        while ((priv = stub_priv_pop(sdev))) {
                struct urb *urb = priv->urb;
 
-               usbip_udbg("   free urb %p\n", urb);
+               dev_dbg(&sdev->udev->dev, "free urb %p\n", urb);
                usb_kill_urb(urb);
 
                kmem_cache_free(stub_priv_cache, priv);
 
                kfree(urb->transfer_buffer);
-
                kfree(urb->setup_packet);
 
                usb_free_urb(urb);
        }
 }
 
-
-/*-------------------------------------------------------------------------*/
-
 static int __init usb_stub_init(void)
 {
        int ret;
@@ -284,20 +265,17 @@ static int __init usb_stub_init(void)
                                            SLAB_HWCACHE_ALIGN, NULL);
 
        if (!stub_priv_cache) {
-               printk(KERN_ERR KBUILD_MODNAME
-                      ": create stub_priv_cache error\n");
+               pr_err("create stub_priv_cache error\n");
                return -ENOMEM;
        }
 
        ret = usb_register(&stub_driver);
        if (ret) {
-               printk(KERN_ERR KBUILD_MODNAME ": usb_register failed %d\n",
-                      ret);
+               pr_err("usb_register failed %d\n", ret);
                goto error_usb_register;
        }
 
-       printk(KERN_INFO KBUILD_MODNAME ":"
-              DRIVER_DESC ":" DRIVER_VERSION "\n");
+       pr_info(DRIVER_DESC " " USBIP_VERSION "\n");
 
        init_busid_table();
 
@@ -305,7 +283,7 @@ static int __init usb_stub_init(void)
                                 &driver_attr_match_busid);
 
        if (ret) {
-               printk(KERN_ERR KBUILD_MODNAME ": create driver sysfs\n");
+               pr_err("create driver sysfs\n");
                goto error_create_file;
        }
 
@@ -337,3 +315,4 @@ module_exit(usb_stub_exit);
 MODULE_AUTHOR(DRIVER_AUTHOR);
 MODULE_DESCRIPTION(DRIVER_DESC);
 MODULE_LICENSE("GPL");
+MODULE_VERSION(USBIP_VERSION);
index 51fbd09864751cc3de95b091dda6e822c0f9660a..a5c1fa1f0430c7d5a5b4921a55a212f347ae52ca 100644 (file)
  * USA.
  */
 
-#include <linux/slab.h>
+#include <asm/byteorder.h>
 #include <linux/kthread.h>
+#include <linux/usb.h>
+#include <linux/usb/hcd.h>
 
 #include "usbip_common.h"
 #include "stub.h"
-#include <linux/usb/hcd.h>
-
 
 static int is_clear_halt_cmd(struct urb *urb)
 {
@@ -43,7 +43,7 @@ static int is_set_interface_cmd(struct urb *urb)
        req = (struct usb_ctrlrequest *) urb->setup_packet;
 
        return (req->bRequest == USB_REQ_SET_INTERFACE) &&
-                  (req->bRequestType == USB_RECIP_INTERFACE);
+               (req->bRequestType == USB_RECIP_INTERFACE);
 }
 
 static int is_set_configuration_cmd(struct urb *urb)
@@ -53,7 +53,7 @@ static int is_set_configuration_cmd(struct urb *urb)
        req = (struct usb_ctrlrequest *) urb->setup_packet;
 
        return (req->bRequest == USB_REQ_SET_CONFIGURATION) &&
-                  (req->bRequestType == USB_RECIP_DEVICE);
+               (req->bRequestType == USB_RECIP_DEVICE);
 }
 
 static int is_reset_device_cmd(struct urb *urb)
@@ -67,8 +67,8 @@ static int is_reset_device_cmd(struct urb *urb)
        index = le16_to_cpu(req->wIndex);
 
        if ((req->bRequest == USB_REQ_SET_FEATURE) &&
-                       (req->bRequestType == USB_RT_PORT) &&
-                       (value == USB_PORT_FEAT_RESET)) {
+           (req->bRequestType == USB_RT_PORT) &&
+           (value == USB_PORT_FEAT_RESET)) {
                usbip_dbg_stub_rx("reset_device_cmd, port %u\n", index);
                return 1;
        } else
@@ -102,11 +102,11 @@ static int tweak_clear_halt_cmd(struct urb *urb)
 
        ret = usb_clear_halt(urb->dev, target_pipe);
        if (ret < 0)
-               usbip_uinfo("clear_halt error: devnum %d endp %d, %d\n",
-                                       urb->dev->devnum, target_endp, ret);
+               dev_err(&urb->dev->dev, "usb_clear_halt error: devnum %d endp "
+                       "%d ret %d\n", urb->dev->devnum, target_endp, ret);
        else
-               usbip_uinfo("clear_halt done: devnum %d endp %d\n",
-                                       urb->dev->devnum, target_endp);
+               dev_info(&urb->dev->dev, "usb_clear_halt done: devnum %d endp "
+                        "%d\n", urb->dev->devnum, target_endp);
 
        return ret;
 }
@@ -122,17 +122,16 @@ static int tweak_set_interface_cmd(struct urb *urb)
        alternate = le16_to_cpu(req->wValue);
        interface = le16_to_cpu(req->wIndex);
 
-       usbip_dbg_stub_rx("set_interface: inf %u alt %u\n", interface,
-                                                               alternate);
+       usbip_dbg_stub_rx("set_interface: inf %u alt %u\n",
+                         interface, alternate);
 
        ret = usb_set_interface(urb->dev, interface, alternate);
        if (ret < 0)
-               usbip_uinfo("set_interface error: inf %u alt %u, %d\n",
-                                       interface, alternate, ret);
+               dev_err(&urb->dev->dev, "usb_set_interface error: inf %u alt "
+                       "%u ret %d\n", interface, alternate, ret);
        else
-               usbip_uinfo("set_interface done: inf %u alt %u\n",
-                                                       interface,
-                                                       alternate);
+               dev_info(&urb->dev->dev, "usb_set_interface done: inf %u alt "
+                        "%u\n", interface, alternate);
 
        return ret;
 }
@@ -161,9 +160,8 @@ static int tweak_set_configuration_cmd(struct urb *urb)
         * A user may need to set a special configuration value before
         * exporting the device.
         */
-       usbip_uinfo("set_configuration (%d) to %s\n", config,
-                                               dev_name(&urb->dev->dev));
-       usbip_uinfo("but, skip!\n");
+       dev_info(&urb->dev->dev, "usb_set_configuration %d to %s... skip!\n",
+                config, dev_name(&urb->dev->dev));
 
        return 0;
        /* return usb_driver_set_configuration(urb->dev, config); */
@@ -174,7 +172,7 @@ static int tweak_reset_device_cmd(struct urb *urb)
        struct stub_priv *priv = (struct stub_priv *) urb->context;
        struct stub_device *sdev = priv->sdev;
 
-       usbip_uinfo("reset_device %s\n", dev_name(&urb->dev->dev));
+       dev_info(&urb->dev->dev, "usb_queue_reset_device\n");
 
        /*
         * usb_lock_device_for_reset caused a deadlock: it causes the driver
@@ -228,13 +226,12 @@ static void tweak_special_requests(struct urb *urb)
  * See also comments about unlinking strategy in vhci_hcd.c.
  */
 static int stub_recv_cmd_unlink(struct stub_device *sdev,
-                                               struct usbip_header *pdu)
+                               struct usbip_header *pdu)
 {
        unsigned long flags;
 
        struct stub_priv *priv;
 
-
        spin_lock_irqsave(&sdev->priv_lock, flags);
 
        list_for_each_entry(priv, &sdev->priv_init, list) {
@@ -289,7 +286,7 @@ static int stub_recv_cmd_unlink(struct stub_device *sdev,
        }
 
        usbip_dbg_stub_rx("seqnum %d is not pending\n",
-                                               pdu->u.cmd_unlink.seqnum);
+                         pdu->u.cmd_unlink.seqnum);
 
        /*
         * The urb of the unlink target is not found in priv_init queue. It was
@@ -301,7 +298,6 @@ static int stub_recv_cmd_unlink(struct stub_device *sdev,
 
        spin_unlock_irqrestore(&sdev->priv_lock, flags);
 
-
        return 0;
 }
 
@@ -370,8 +366,6 @@ static int get_pipe(struct stub_device *sdev, int epnum, int dir)
        }
 
        epd = &ep->desc;
-
-
 #if 0
        /* epnum 0 is always control */
        if (epnum == 0) {
@@ -381,7 +375,6 @@ static int get_pipe(struct stub_device *sdev, int epnum, int dir)
                        return usb_rcvctrlpipe(udev, 0);
        }
 #endif
-
        if (usb_endpoint_xfer_control(epd)) {
                if (dir == USBIP_DIR_OUT)
                        return usb_sndctrlpipe(udev, epnum);
@@ -430,19 +423,19 @@ static void masking_bogus_flags(struct urb *urb)
                return;
 
        ep = (usb_pipein(urb->pipe) ? dev->ep_in : dev->ep_out)
-                       [usb_pipeendpoint(urb->pipe)];
+               [usb_pipeendpoint(urb->pipe)];
        if (!ep)
                return;
 
        xfertype = usb_endpoint_type(&ep->desc);
        if (xfertype == USB_ENDPOINT_XFER_CONTROL) {
                struct usb_ctrlrequest *setup =
-                               (struct usb_ctrlrequest *) urb->setup_packet;
+                       (struct usb_ctrlrequest *) urb->setup_packet;
 
                if (!setup)
                        return;
                is_out = !(setup->bRequestType & USB_DIR_IN) ||
-                               !setup->wLength;
+                       !setup->wLength;
        } else {
                is_out = usb_endpoint_dir_out(&ep->desc);
        }
@@ -478,7 +471,6 @@ static void stub_recv_cmd_submit(struct stub_device *sdev,
        struct usb_device *udev = sdev->udev;
        int pipe = get_pipe(sdev, pdu->base.ep, pdu->base.direction);
 
-
        priv = stub_priv_alloc(sdev, pdu);
        if (!priv)
                return;
@@ -486,7 +478,7 @@ static void stub_recv_cmd_submit(struct stub_device *sdev,
        /* setup a urb */
        if (usb_pipeisoc(pipe))
                priv->urb = usb_alloc_urb(pdu->u.cmd_submit.number_of_packets,
-                                                               GFP_KERNEL);
+                                         GFP_KERNEL);
        else
                priv->urb = usb_alloc_urb(0, GFP_KERNEL);
 
@@ -500,7 +492,7 @@ static void stub_recv_cmd_submit(struct stub_device *sdev,
        if (pdu->u.cmd_submit.transfer_buffer_length > 0) {
                priv->urb->transfer_buffer =
                        kzalloc(pdu->u.cmd_submit.transfer_buffer_length,
-                                                               GFP_KERNEL);
+                               GFP_KERNEL);
                if (!priv->urb->transfer_buffer) {
                        dev_err(&sdev->interface->dev, "malloc x_buff\n");
                        usbip_event_add(ud, SDEV_EVENT_ERROR_MALLOC);
@@ -541,7 +533,7 @@ static void stub_recv_cmd_submit(struct stub_device *sdev,
 
        if (ret == 0)
                usbip_dbg_stub_rx("submit urb ok, seqnum %u\n",
-                                                       pdu->base.seqnum);
+                                 pdu->base.seqnum);
        else {
                dev_err(&sdev->interface->dev, "submit_urb error, %d\n", ret);
                usbip_dump_header(pdu);
@@ -602,9 +594,8 @@ static void stub_rx_pdu(struct usbip_device *ud)
                /* NOTREACHED */
                dev_err(dev, "unknown pdu\n");
                usbip_event_add(ud, SDEV_EVENT_ERROR_TCP);
-               return;
+               break;
        }
-
 }
 
 int stub_rx_loop(void *data)
@@ -617,5 +608,6 @@ int stub_rx_loop(void *data)
 
                stub_rx_pdu(ud);
        }
+
        return 0;
 }
index 64a52b26dcf6d7fe9d185372393a11f8af0e0149..fda2bc95e85987d4be49ff8420f66bdcd2e02ac0 100644 (file)
  * USA.
  */
 
-#include <linux/slab.h>
 #include <linux/kthread.h>
+#include <linux/socket.h>
 
 #include "usbip_common.h"
 #include "stub.h"
 
-
 static void stub_free_priv_and_urb(struct stub_priv *priv)
 {
        struct urb *urb = priv->urb;
@@ -71,28 +70,29 @@ void stub_complete(struct urb *urb)
 
        usbip_dbg_stub_tx("complete! status %d\n", urb->status);
 
-
        switch (urb->status) {
        case 0:
                /* OK */
                break;
        case -ENOENT:
-               usbip_uinfo("stopped by a call of usb_kill_urb() because of"
-                                       "cleaning up a virtual connection\n");
+               dev_info(&urb->dev->dev, "stopped by a call to usb_kill_urb() "
+                        "because of cleaning up a virtual connection\n");
                return;
        case -ECONNRESET:
-               usbip_uinfo("unlinked by a call of usb_unlink_urb()\n");
+               dev_info(&urb->dev->dev, "unlinked by a call to "
+                        "usb_unlink_urb()\n");
                break;
        case -EPIPE:
-               usbip_uinfo("endpoint %d is stalled\n",
-                                               usb_pipeendpoint(urb->pipe));
+               dev_info(&urb->dev->dev, "endpoint %d is stalled\n",
+                        usb_pipeendpoint(urb->pipe));
                break;
        case -ESHUTDOWN:
-               usbip_uinfo("device removed?\n");
+               dev_info(&urb->dev->dev, "device removed?\n");
                break;
        default:
-               usbip_uinfo("urb completion with non-zero status %d\n",
-                                                       urb->status);
+               dev_info(&urb->dev->dev, "urb completion with non-zero status "
+                        "%d\n", urb->status);
+               break;
        }
 
        /* link a urb to the queue of tx. */
@@ -104,25 +104,20 @@ void stub_complete(struct urb *urb)
        } else
                list_move_tail(&priv->list, &sdev->priv_tx);
 
-
        spin_unlock_irqrestore(&sdev->priv_lock, flags);
 
        /* wake up tx_thread */
        wake_up(&sdev->tx_waitq);
 }
 
-
-/*-------------------------------------------------------------------------*/
-/* fill PDU */
-
 static inline void setup_base_pdu(struct usbip_header_basic *base,
-               __u32 command, __u32 seqnum)
+                                 __u32 command, __u32 seqnum)
 {
        base->command = command;
        base->seqnum  = seqnum;
        base->devid   = 0;
        base->ep      = 0;
-       base->direction   = 0;
+       base->direction = 0;
 }
 
 static void setup_ret_submit_pdu(struct usbip_header *rpdu, struct urb *urb)
@@ -130,22 +125,16 @@ static void setup_ret_submit_pdu(struct usbip_header *rpdu, struct urb *urb)
        struct stub_priv *priv = (struct stub_priv *) urb->context;
 
        setup_base_pdu(&rpdu->base, USBIP_RET_SUBMIT, priv->seqnum);
-
        usbip_pack_pdu(rpdu, urb, USBIP_RET_SUBMIT, 1);
 }
 
 static void setup_ret_unlink_pdu(struct usbip_header *rpdu,
-               struct stub_unlink *unlink)
+                                struct stub_unlink *unlink)
 {
        setup_base_pdu(&rpdu->base, USBIP_RET_UNLINK, unlink->seqnum);
-
        rpdu->u.ret_unlink.status = unlink->status;
 }
 
-
-/*-------------------------------------------------------------------------*/
-/* send RET_SUBMIT */
-
 static struct stub_priv *dequeue_from_priv_tx(struct stub_device *sdev)
 {
        unsigned long flags;
@@ -203,7 +192,7 @@ static int stub_send_ret_submit(struct stub_device *sdev)
                /* 1. setup usbip_header */
                setup_ret_submit_pdu(&pdu_header, urb);
                usbip_dbg_stub_tx("setup txdata seqnum: %d urb: %p\n",
-                                               pdu_header.base.seqnum, urb);
+                                 pdu_header.base.seqnum, urb);
                /*usbip_dump_header(pdu_header);*/
                usbip_header_correct_endian(&pdu_header, 1);
 
@@ -214,14 +203,14 @@ static int stub_send_ret_submit(struct stub_device *sdev)
 
                /* 2. setup transfer buffer */
                if (usb_pipein(urb->pipe) &&
-                               usb_pipetype(urb->pipe) != PIPE_ISOCHRONOUS &&
-                                       urb->actual_length > 0) {
+                   usb_pipetype(urb->pipe) != PIPE_ISOCHRONOUS &&
+                   urb->actual_length > 0) {
                        iov[iovnum].iov_base = urb->transfer_buffer;
                        iov[iovnum].iov_len  = urb->actual_length;
                        iovnum++;
                        txsize += urb->actual_length;
                } else if (usb_pipein(urb->pipe) &&
-                               usb_pipetype(urb->pipe) == PIPE_ISOCHRONOUS) {
+                          usb_pipetype(urb->pipe) == PIPE_ISOCHRONOUS) {
                        /*
                         * For isochronous packets: actual length is the sum of
                         * the actual length of the individual, packets, but as
@@ -232,18 +221,23 @@ static int stub_send_ret_submit(struct stub_device *sdev)
 
                        int i;
                        for (i = 0; i < urb->number_of_packets; i++) {
-                               iov[iovnum].iov_base = urb->transfer_buffer + urb->iso_frame_desc[i].offset;
-                               iov[iovnum].iov_len = urb->iso_frame_desc[i].actual_length;
+                               iov[iovnum].iov_base = urb->transfer_buffer +
+                                       urb->iso_frame_desc[i].offset;
+                               iov[iovnum].iov_len =
+                                       urb->iso_frame_desc[i].actual_length;
                                iovnum++;
                                txsize += urb->iso_frame_desc[i].actual_length;
                        }
 
                        if (txsize != sizeof(pdu_header) + urb->actual_length) {
                                dev_err(&sdev->interface->dev,
-                                       "actual length of urb (%d) does not match iso packet sizes (%d)\n",
-                                       urb->actual_length, txsize-sizeof(pdu_header));
+                                       "actual length of urb %d does not "
+                                       "match iso packet sizes %lu\n",
+                                       urb->actual_length,
+                                       txsize-sizeof(pdu_header));
                                kfree(iov);
-                               usbip_event_add(&sdev->ud, SDEV_EVENT_ERROR_TCP);
+                               usbip_event_add(&sdev->ud,
+                                               SDEV_EVENT_ERROR_TCP);
                           return -1;
                        }
                }
@@ -285,20 +279,14 @@ static int stub_send_ret_submit(struct stub_device *sdev)
        }
 
        spin_lock_irqsave(&sdev->priv_lock, flags);
-
        list_for_each_entry_safe(priv, tmp, &sdev->priv_free, list) {
                stub_free_priv_and_urb(priv);
        }
-
        spin_unlock_irqrestore(&sdev->priv_lock, flags);
 
        return total_size;
 }
 
-
-/*-------------------------------------------------------------------------*/
-/* send RET_UNLINK */
-
 static struct stub_unlink *dequeue_from_unlink_tx(struct stub_device *sdev)
 {
        unsigned long flags;
@@ -317,7 +305,6 @@ static struct stub_unlink *dequeue_from_unlink_tx(struct stub_device *sdev)
        return NULL;
 }
 
-
 static int stub_send_ret_unlink(struct stub_device *sdev)
 {
        unsigned long flags;
@@ -358,13 +345,10 @@ static int stub_send_ret_unlink(struct stub_device *sdev)
                        return -1;
                }
 
-
                usbip_dbg_stub_tx("send txdata\n");
-
                total_size += txsize;
        }
 
-
        spin_lock_irqsave(&sdev->priv_lock, flags);
 
        list_for_each_entry_safe(unlink, tmp, &sdev->unlink_free, list) {
@@ -377,9 +361,6 @@ static int stub_send_ret_unlink(struct stub_device *sdev)
        return total_size;
 }
 
-
-/*-------------------------------------------------------------------------*/
-
 int stub_tx_loop(void *data)
 {
        struct usbip_device *ud = data;
@@ -410,9 +391,9 @@ int stub_tx_loop(void *data)
                        break;
 
                wait_event_interruptible(sdev->tx_waitq,
-                               (!list_empty(&sdev->priv_tx) ||
-                                !list_empty(&sdev->unlink_tx) ||
-                                kthread_should_stop()));
+                                        (!list_empty(&sdev->priv_tx) ||
+                                         !list_empty(&sdev->unlink_tx) ||
+                                         kthread_should_stop()));
        }
 
        return 0;
index 7b1fe45bf7ddf71c733c9853ed30c5fe26c5d98a..433a3b6207d6531816ccf8bf580158b8530ea155 100644 (file)
  * USA.
  */
 
-#include <linux/kernel.h>
+#include <asm/byteorder.h>
 #include <linux/file.h>
-#include <linux/tcp.h>
-#include <linux/in.h>
-#include <linux/kthread.h>
+#include <linux/fs.h>
+#include <linux/kernel.h>
 #include <linux/slab.h>
-#include "usbip_common.h"
+#include <net/sock.h>
 
-/* version information */
-#define DRIVER_VERSION "1.0"
-#define DRIVER_AUTHOR "Takahiro Hirofuchi <hirofuchi _at_ users.sourceforge.net>"
-#define DRIVER_DESC "usbip common driver"
+#include "usbip_common.h"
 
-/*-------------------------------------------------------------------------*/
-/* debug routines */
+#define DRIVER_AUTHOR "Takahiro Hirofuchi <hirofuchi@users.sourceforge.net>"
+#define DRIVER_DESC "USB/IP Core"
 
-#ifdef CONFIG_USB_IP_DEBUG_ENABLE
+#ifdef CONFIG_USBIP_DEBUG
 unsigned long usbip_debug_flag = 0xffffffff;
 #else
 unsigned long usbip_debug_flag;
 #endif
 EXPORT_SYMBOL_GPL(usbip_debug_flag);
 
-
 /* FIXME */
 struct device_attribute dev_attr_usbip_debug;
 EXPORT_SYMBOL_GPL(dev_attr_usbip_debug);
 
-
 static ssize_t show_flag(struct device *dev, struct device_attribute *attr,
-                                                               char *buf)
+                        char *buf)
 {
        return sprintf(buf, "%lx\n", usbip_debug_flag);
 }
 
 static ssize_t store_flag(struct device *dev, struct device_attribute *attr,
-               const char *buf, size_t count)
+                         const char *buf, size_t count)
 {
        sscanf(buf, "%lx", &usbip_debug_flag);
-
        return count;
 }
 DEVICE_ATTR(usbip_debug, (S_IRUGO | S_IWUSR), show_flag, store_flag);
 
 static void usbip_dump_buffer(char *buff, int bufflen)
 {
-       print_hex_dump(KERN_DEBUG, "usb-ip", DUMP_PREFIX_OFFSET, 16, 4,
+       print_hex_dump(KERN_DEBUG, "usbip-core", DUMP_PREFIX_OFFSET, 16, 4,
                       buff, bufflen, false);
 }
 
@@ -74,29 +67,25 @@ static void usbip_dump_pipe(unsigned int p)
        unsigned char dev = usb_pipedevice(p);
        unsigned char dir = usb_pipein(p);
 
-       printk(KERN_DEBUG "dev(%d) ", dev);
-       printk(KERN_DEBUG "ep(%d) ",  ep);
-       printk(KERN_DEBUG "%s ", dir ? "IN" : "OUT");
+       pr_debug("dev(%d) ep(%d) [%s] ", dev, ep, dir ? "IN" : "OUT");
 
        switch (type) {
        case PIPE_ISOCHRONOUS:
-               printk(KERN_DEBUG "%s ", "ISO");
+               pr_debug("ISO\n");
                break;
        case PIPE_INTERRUPT:
-               printk(KERN_DEBUG "%s ", "INT");
+               pr_debug("INT\n");
                break;
        case PIPE_CONTROL:
-               printk(KERN_DEBUG "%s ", "CTL");
+               pr_debug("CTRL\n");
                break;
        case PIPE_BULK:
-               printk(KERN_DEBUG "%s ", "BLK");
+               pr_debug("BULK\n");
                break;
        default:
-               printk(KERN_DEBUG "ERR");
+               pr_debug("ERR\n");
+               break;
        }
-
-       printk(KERN_DEBUG "\n");
-
 }
 
 static void usbip_dump_usb_device(struct usb_device *udev)
@@ -104,60 +93,59 @@ static void usbip_dump_usb_device(struct usb_device *udev)
        struct device *dev = &udev->dev;
        int i;
 
-       dev_dbg(dev, "       devnum(%d) devpath(%s)",
+       dev_dbg(dev, "       devnum(%d) devpath(%s) ",
                udev->devnum, udev->devpath);
 
        switch (udev->speed) {
        case USB_SPEED_HIGH:
-               printk(KERN_DEBUG " SPD_HIGH");
+               pr_debug("SPD_HIGH ");
                break;
        case USB_SPEED_FULL:
-               printk(KERN_DEBUG " SPD_FULL");
+               pr_debug("SPD_FULL ");
                break;
        case USB_SPEED_LOW:
-               printk(KERN_DEBUG " SPD_LOW");
+               pr_debug("SPD_LOW ");
                break;
        case USB_SPEED_UNKNOWN:
-               printk(KERN_DEBUG " SPD_UNKNOWN");
+               pr_debug("SPD_UNKNOWN ");
                break;
        default:
-               printk(KERN_DEBUG " SPD_ERROR");
+               pr_debug("SPD_ERROR ");
+               break;
        }
 
-       printk(KERN_DEBUG " tt %p, ttport %d", udev->tt, udev->ttport);
-       printk(KERN_DEBUG "\n");
+       pr_debug("tt %p, ttport %d\n", udev->tt, udev->ttport);
 
        dev_dbg(dev, "                    ");
        for (i = 0; i < 16; i++)
-               printk(KERN_DEBUG " %2u", i);
-       printk(KERN_DEBUG "\n");
+               pr_debug(" %2u", i);
+       pr_debug("\n");
 
        dev_dbg(dev, "       toggle0(IN) :");
        for (i = 0; i < 16; i++)
-               printk(KERN_DEBUG " %2u", (udev->toggle[0] & (1 << i)) ? 1 : 0);
-       printk(KERN_DEBUG "\n");
+               pr_debug(" %2u", (udev->toggle[0] & (1 << i)) ? 1 : 0);
+       pr_debug("\n");
 
        dev_dbg(dev, "       toggle1(OUT):");
        for (i = 0; i < 16; i++)
-               printk(KERN_DEBUG " %2u", (udev->toggle[1] & (1 << i)) ? 1 : 0);
-       printk(KERN_DEBUG "\n");
-
+               pr_debug(" %2u", (udev->toggle[1] & (1 << i)) ? 1 : 0);
+       pr_debug("\n");
 
        dev_dbg(dev, "       epmaxp_in   :");
        for (i = 0; i < 16; i++) {
                if (udev->ep_in[i])
-                       printk(KERN_DEBUG " %2u",
-                            le16_to_cpu(udev->ep_in[i]->desc.wMaxPacketSize));
+                       pr_debug(" %2u",
+                           le16_to_cpu(udev->ep_in[i]->desc.wMaxPacketSize));
        }
-       printk(KERN_DEBUG "\n");
+       pr_debug("\n");
 
        dev_dbg(dev, "       epmaxp_out  :");
        for (i = 0; i < 16; i++) {
                if (udev->ep_out[i])
-                       printk(KERN_DEBUG " %2u",
-                            le16_to_cpu(udev->ep_out[i]->desc.wMaxPacketSize));
+                       pr_debug(" %2u",
+                           le16_to_cpu(udev->ep_out[i]->desc.wMaxPacketSize));
        }
-       printk(KERN_DEBUG "\n");
+       pr_debug("\n");
 
        dev_dbg(dev, "parent %p, bus %p\n", udev->parent, udev->bus);
 
@@ -176,91 +164,84 @@ static void usbip_dump_request_type(__u8 rt)
 {
        switch (rt & USB_RECIP_MASK) {
        case USB_RECIP_DEVICE:
-               printk(KERN_DEBUG "DEVICE");
+               pr_debug("DEVICE");
                break;
        case USB_RECIP_INTERFACE:
-               printk(KERN_DEBUG "INTERF");
+               pr_debug("INTERF");
                break;
        case USB_RECIP_ENDPOINT:
-               printk(KERN_DEBUG "ENDPOI");
+               pr_debug("ENDPOI");
                break;
        case USB_RECIP_OTHER:
-               printk(KERN_DEBUG "OTHER ");
+               pr_debug("OTHER ");
                break;
        default:
-               printk(KERN_DEBUG "------");
+               pr_debug("------");
+               break;
        }
 }
 
 static void usbip_dump_usb_ctrlrequest(struct usb_ctrlrequest *cmd)
 {
        if (!cmd) {
-               printk(KERN_DEBUG "      %s : null pointer\n", __func__);
+               pr_debug("       : null pointer\n");
                return;
        }
 
-       printk(KERN_DEBUG "       ");
-       printk(KERN_DEBUG "bRequestType(%02X) ", cmd->bRequestType);
-       printk(KERN_DEBUG "bRequest(%02X) " , cmd->bRequest);
-       printk(KERN_DEBUG "wValue(%04X) ", cmd->wValue);
-       printk(KERN_DEBUG "wIndex(%04X) ", cmd->wIndex);
-       printk(KERN_DEBUG "wLength(%04X) ", cmd->wLength);
-
-       printk(KERN_DEBUG "\n       ");
+       pr_debug("       ");
+       pr_debug("bRequestType(%02X) bRequest(%02X) wValue(%04X) wIndex(%04X) "
+                "wLength(%04X) ", cmd->bRequestType, cmd->bRequest,
+                cmd->wValue, cmd->wIndex, cmd->wLength);
+       pr_debug("\n       ");
 
        if ((cmd->bRequestType & USB_TYPE_MASK) == USB_TYPE_STANDARD) {
-               printk(KERN_DEBUG "STANDARD ");
+               pr_debug("STANDARD ");
                switch (cmd->bRequest) {
                case USB_REQ_GET_STATUS:
-                       printk(KERN_DEBUG "GET_STATUS");
+                       pr_debug("GET_STATUS\n");
                        break;
                case USB_REQ_CLEAR_FEATURE:
-                       printk(KERN_DEBUG "CLEAR_FEAT");
+                       pr_debug("CLEAR_FEAT\n");
                        break;
                case USB_REQ_SET_FEATURE:
-                       printk(KERN_DEBUG "SET_FEAT  ");
+                       pr_debug("SET_FEAT  \n");
                        break;
                case USB_REQ_SET_ADDRESS:
-                       printk(KERN_DEBUG "SET_ADDRRS");
+                       pr_debug("SET_ADDRRS\n");
                        break;
                case USB_REQ_GET_DESCRIPTOR:
-                       printk(KERN_DEBUG "GET_DESCRI");
+                       pr_debug("GET_DESCRI\n");
                        break;
                case USB_REQ_SET_DESCRIPTOR:
-                       printk(KERN_DEBUG "SET_DESCRI");
+                       pr_debug("SET_DESCRI\n");
                        break;
                case USB_REQ_GET_CONFIGURATION:
-                       printk(KERN_DEBUG "GET_CONFIG");
+                       pr_debug("GET_CONFIG\n");
                        break;
                case USB_REQ_SET_CONFIGURATION:
-                       printk(KERN_DEBUG "SET_CONFIG");
+                       pr_debug("SET_CONFIG\n");
                        break;
                case USB_REQ_GET_INTERFACE:
-                       printk(KERN_DEBUG "GET_INTERF");
+                       pr_debug("GET_INTERF\n");
                        break;
                case USB_REQ_SET_INTERFACE:
-                       printk(KERN_DEBUG "SET_INTERF");
+                       pr_debug("SET_INTERF\n");
                        break;
                case USB_REQ_SYNCH_FRAME:
-                       printk(KERN_DEBUG "SYNC_FRAME");
+                       pr_debug("SYNC_FRAME\n");
                        break;
                default:
-                       printk(KERN_DEBUG "REQ(%02X) ", cmd->bRequest);
+                       pr_debug("REQ(%02X) \n", cmd->bRequest);
+                       break;
                }
-
-               printk(KERN_DEBUG " ");
                usbip_dump_request_type(cmd->bRequestType);
-
-       } else if ((cmd->bRequestType & USB_TYPE_MASK) == USB_TYPE_CLASS)
-               printk(KERN_DEBUG "CLASS   ");
-
-       else if ((cmd->bRequestType & USB_TYPE_MASK) == USB_TYPE_VENDOR)
-               printk(KERN_DEBUG "VENDOR  ");
-
-       else if ((cmd->bRequestType & USB_TYPE_MASK) == USB_TYPE_RESERVED)
-               printk(KERN_DEBUG "RESERVED");
-
-       printk(KERN_DEBUG "\n");
+       } else if ((cmd->bRequestType & USB_TYPE_MASK) == USB_TYPE_CLASS) {
+               pr_debug("CLASS   \n");
+       } else if ((cmd->bRequestType & USB_TYPE_MASK) == USB_TYPE_VENDOR) {
+               pr_debug("VENDOR  \n");
+       } else if ((cmd->bRequestType & USB_TYPE_MASK) == USB_TYPE_RESERVED) {
+               pr_debug("RESERVED\n");
+       }
 }
 
 void usbip_dump_urb(struct urb *urb)
@@ -268,16 +249,15 @@ void usbip_dump_urb(struct urb *urb)
        struct device *dev;
 
        if (!urb) {
-               printk(KERN_DEBUG KBUILD_MODNAME
-                      ":%s: urb: null pointer!!\n", __func__);
+               pr_debug("urb: null pointer!!\n");
                return;
        }
 
        if (!urb->dev) {
-               printk(KERN_DEBUG KBUILD_MODNAME
-                      ":%s: urb->dev: null pointer!!\n", __func__);
+               pr_debug("urb->dev: null pointer!!\n");
                return;
        }
+
        dev = &urb->dev->dev;
 
        dev_dbg(dev, "   urb                   :%p\n", urb);
@@ -298,7 +278,7 @@ void usbip_dump_urb(struct urb *urb)
        dev_dbg(dev, "   setup_packet          :%p\n", urb->setup_packet);
 
        if (urb->setup_packet && usb_pipetype(urb->pipe) == PIPE_CONTROL)
-                       usbip_dump_usb_ctrlrequest(
+               usbip_dump_usb_ctrlrequest(
                        (struct usb_ctrlrequest *)urb->setup_packet);
 
        dev_dbg(dev, "   start_frame           :%d\n", urb->start_frame);
@@ -312,47 +292,48 @@ EXPORT_SYMBOL_GPL(usbip_dump_urb);
 
 void usbip_dump_header(struct usbip_header *pdu)
 {
-       usbip_udbg("BASE: cmd %u seq %u devid %u dir %u ep %u\n",
-                       pdu->base.command,
-                       pdu->base.seqnum,
-                       pdu->base.devid,
-                       pdu->base.direction,
-                       pdu->base.ep);
+       pr_debug("BASE: cmd %u seq %u devid %u dir %u ep %u\n",
+                pdu->base.command,
+                pdu->base.seqnum,
+                pdu->base.devid,
+                pdu->base.direction,
+                pdu->base.ep);
 
        switch (pdu->base.command) {
        case USBIP_CMD_SUBMIT:
-               usbip_udbg("CMD_SUBMIT: "
-                               "x_flags %u x_len %u sf %u #p %u iv %u\n",
-                               pdu->u.cmd_submit.transfer_flags,
-                               pdu->u.cmd_submit.transfer_buffer_length,
-                               pdu->u.cmd_submit.start_frame,
-                               pdu->u.cmd_submit.number_of_packets,
-                               pdu->u.cmd_submit.interval);
-                               break;
+               pr_debug("USBIP_CMD_SUBMIT: "
+                        "x_flags %u x_len %u sf %u #p %d iv %d\n",
+                        pdu->u.cmd_submit.transfer_flags,
+                        pdu->u.cmd_submit.transfer_buffer_length,
+                        pdu->u.cmd_submit.start_frame,
+                        pdu->u.cmd_submit.number_of_packets,
+                        pdu->u.cmd_submit.interval);
+               break;
        case USBIP_CMD_UNLINK:
-               usbip_udbg("CMD_UNLINK: seq %u\n", pdu->u.cmd_unlink.seqnum);
+               pr_debug("USBIP_CMD_UNLINK: seq %u\n",
+                        pdu->u.cmd_unlink.seqnum);
                break;
        case USBIP_RET_SUBMIT:
-               usbip_udbg("RET_SUBMIT: st %d al %u sf %d #p %d ec %d\n",
-                               pdu->u.ret_submit.status,
-                               pdu->u.ret_submit.actual_length,
-                               pdu->u.ret_submit.start_frame,
-                               pdu->u.ret_submit.number_of_packets,
-                               pdu->u.ret_submit.error_count);
+               pr_debug("USBIP_RET_SUBMIT: st %d al %u sf %d #p %d ec %d\n",
+                        pdu->u.ret_submit.status,
+                        pdu->u.ret_submit.actual_length,
+                        pdu->u.ret_submit.start_frame,
+                        pdu->u.ret_submit.number_of_packets,
+                        pdu->u.ret_submit.error_count);
+               break;
        case USBIP_RET_UNLINK:
-               usbip_udbg("RET_UNLINK: status %d\n", pdu->u.ret_unlink.status);
+               pr_debug("USBIP_RET_UNLINK: status %d\n",
+                        pdu->u.ret_unlink.status);
                break;
        default:
                /* NOT REACHED */
-               usbip_udbg("UNKNOWN\n");
+               pr_err("unknown command\n");
+               break;
        }
 }
 EXPORT_SYMBOL_GPL(usbip_dump_header);
 
-/*-------------------------------------------------------------------------*/
-/* socket routines */
-
-/*  Send/receive messages over TCP/IP. I refer drivers/block/nbd.c */
+/* Send/receive messages over TCP/IP. I refer drivers/block/nbd.c */
 int usbip_xmit(int send, struct socket *sock, char *buf,
               int size, int msg_flags)
 {
@@ -368,27 +349,24 @@ int usbip_xmit(int send, struct socket *sock, char *buf,
        usbip_dbg_xmit("enter\n");
 
        if (!sock || !buf || !size) {
-               printk(KERN_ERR "%s: invalid arg, sock %p buff %p size %d\n",
-                      __func__, sock, buf, size);
+               pr_err("invalid arg, sock %p buff %p size %d\n", sock, buf,
+                      size);
                return -EINVAL;
        }
 
-
        if (usbip_dbg_flag_xmit) {
                if (send) {
                        if (!in_interrupt())
-                               printk(KERN_DEBUG "%-10s:", current->comm);
+                               pr_debug("%-10s:", current->comm);
                        else
-                               printk(KERN_DEBUG "interrupt  :");
+                               pr_debug("interrupt  :");
 
-                       printk(KERN_DEBUG "%s: sending... , sock %p, buf %p, "
-                              "size %d, msg_flags %d\n", __func__,
-                              sock, buf, size, msg_flags);
+                       pr_debug("sending... , sock %p, buf %p, size %d, "
+                                "msg_flags %d\n", sock, buf, size, msg_flags);
                        usbip_dump_buffer(buf, size);
                }
        }
 
-
        do {
                sock->sk->sk_allocation = GFP_NOIO;
                iov.iov_base    = buf;
@@ -404,13 +382,12 @@ int usbip_xmit(int send, struct socket *sock, char *buf,
                        result = kernel_sendmsg(sock, &msg, &iov, 1, size);
                else
                        result = kernel_recvmsg(sock, &msg, &iov, 1, size,
-                                                               MSG_WAITALL);
+                                               MSG_WAITALL);
 
                if (result <= 0) {
-                       usbip_udbg("usbip_xmit: %s sock %p buf %p size %u ret "
-                                       "%d total %d\n",
-                                       send ? "send" : "receive", sock, buf,
-                                       size, result, total);
+                       pr_debug("%s sock %p buf %p size %u ret %d total %d\n",
+                                send ? "send" : "receive", sock, buf, size,
+                                result, total);
                        goto err;
                }
 
@@ -420,24 +397,21 @@ int usbip_xmit(int send, struct socket *sock, char *buf,
 
        } while (size > 0);
 
-
        if (usbip_dbg_flag_xmit) {
                if (!send) {
                        if (!in_interrupt())
-                               printk(KERN_DEBUG "%-10s:", current->comm);
+                               pr_debug("%-10s:", current->comm);
                        else
-                               printk(KERN_DEBUG "interrupt  :");
+                               pr_debug("interrupt  :");
 
-                       printk(KERN_DEBUG "usbip_xmit: receiving....\n");
+                       pr_debug("receiving....\n");
                        usbip_dump_buffer(bp, osize);
-                       printk(KERN_DEBUG "usbip_xmit: received, osize %d ret "
-                                       "%d size %d total %d\n", osize, result,
-                                       size, total);
+                       pr_debug("received, osize %d ret %d size %d total %d\n",
+                                osize, result, size, total);
                }
 
                if (send)
-                       printk(KERN_DEBUG "usbip_xmit: send, total %d\n",
-                                                                       total);
+                       pr_debug("send, total %d\n", total);
        }
 
        return total;
@@ -455,7 +429,7 @@ struct socket *sockfd_to_socket(unsigned int sockfd)
 
        file = fget(sockfd);
        if (!file) {
-               printk(KERN_ERR "%s: invalid sockfd\n", __func__);
+               pr_err("invalid sockfd\n");
                return NULL;
        }
 
@@ -470,11 +444,6 @@ struct socket *sockfd_to_socket(unsigned int sockfd)
 }
 EXPORT_SYMBOL_GPL(sockfd_to_socket);
 
-
-
-/*-------------------------------------------------------------------------*/
-/* pdu routines */
-
 /* there may be more cases to tweak the flags. */
 static unsigned int tweak_transfer_flags(unsigned int flags)
 {
@@ -483,7 +452,7 @@ static unsigned int tweak_transfer_flags(unsigned int flags)
 }
 
 static void usbip_pack_cmd_submit(struct usbip_header *pdu, struct urb *urb,
-                                                               int pack)
+                                 int pack)
 {
        struct usbip_header_cmd_submit *spdu = &pdu->u.cmd_submit;
 
@@ -494,7 +463,7 @@ static void usbip_pack_cmd_submit(struct usbip_header *pdu, struct urb *urb,
        if (pack) {
                /* vhci_tx.c */
                spdu->transfer_flags =
-                               tweak_transfer_flags(urb->transfer_flags);
+                       tweak_transfer_flags(urb->transfer_flags);
                spdu->transfer_buffer_length    = urb->transfer_buffer_length;
                spdu->start_frame               = urb->start_frame;
                spdu->number_of_packets         = urb->number_of_packets;
@@ -511,7 +480,7 @@ static void usbip_pack_cmd_submit(struct usbip_header *pdu, struct urb *urb,
 }
 
 static void usbip_pack_ret_submit(struct usbip_header *pdu, struct urb *urb,
-                                                               int pack)
+                                 int pack)
 {
        struct usbip_header_ret_submit *rpdu = &pdu->u.ret_submit;
 
@@ -534,9 +503,8 @@ static void usbip_pack_ret_submit(struct usbip_header *pdu, struct urb *urb,
        }
 }
 
-
 void usbip_pack_pdu(struct usbip_header *pdu, struct urb *urb, int cmd,
-                                                               int pack)
+                   int pack)
 {
        switch (cmd) {
        case USBIP_CMD_SUBMIT:
@@ -546,14 +514,13 @@ void usbip_pack_pdu(struct usbip_header *pdu, struct urb *urb, int cmd,
                usbip_pack_ret_submit(pdu, urb, pack);
                break;
        default:
-               err("unknown command");
-               /* NOTREACHED */
-               /* BUG(); */
+               /* NOT REACHED */
+               pr_err("unknown command\n");
+               break;
        }
 }
 EXPORT_SYMBOL_GPL(usbip_pack_pdu);
 
-
 static void correct_endian_basic(struct usbip_header_basic *base, int send)
 {
        if (send) {
@@ -572,7 +539,7 @@ static void correct_endian_basic(struct usbip_header_basic *base, int send)
 }
 
 static void correct_endian_cmd_submit(struct usbip_header_cmd_submit *pdu,
-                                                               int send)
+                                     int send)
 {
        if (send) {
                pdu->transfer_flags = cpu_to_be32(pdu->transfer_flags);
@@ -592,7 +559,7 @@ static void correct_endian_cmd_submit(struct usbip_header_cmd_submit *pdu,
 }
 
 static void correct_endian_ret_submit(struct usbip_header_ret_submit *pdu,
-                                                               int send)
+                                     int send)
 {
        if (send) {
                cpu_to_be32s(&pdu->status);
@@ -604,13 +571,13 @@ static void correct_endian_ret_submit(struct usbip_header_ret_submit *pdu,
                be32_to_cpus(&pdu->status);
                be32_to_cpus(&pdu->actual_length);
                be32_to_cpus(&pdu->start_frame);
-               cpu_to_be32s(&pdu->number_of_packets);
+               be32_to_cpus(&pdu->number_of_packets);
                be32_to_cpus(&pdu->error_count);
        }
 }
 
 static void correct_endian_cmd_unlink(struct usbip_header_cmd_unlink *pdu,
-                                                               int send)
+                                     int send)
 {
        if (send)
                pdu->seqnum = cpu_to_be32(pdu->seqnum);
@@ -619,7 +586,7 @@ static void correct_endian_cmd_unlink(struct usbip_header_cmd_unlink *pdu,
 }
 
 static void correct_endian_ret_unlink(struct usbip_header_ret_unlink *pdu,
-                                                               int send)
+                                     int send)
 {
        if (send)
                cpu_to_be32s(&pdu->status);
@@ -653,16 +620,16 @@ void usbip_header_correct_endian(struct usbip_header *pdu, int send)
                correct_endian_ret_unlink(&pdu->u.ret_unlink, send);
                break;
        default:
-               /* NOTREACHED */
-               err("unknown command in pdu header: %d", cmd);
-               /* BUG(); */
+               /* NOT REACHED */
+               pr_err("unknown command\n");
+               break;
        }
 }
 EXPORT_SYMBOL_GPL(usbip_header_correct_endian);
 
 static void usbip_iso_pakcet_correct_endian(
-                               struct usbip_iso_packet_descriptor *iso,
-                               int send)
+       struct usbip_iso_packet_descriptor *iso,
+       int send)
 {
        /* does not need all members. but copy all simply. */
        if (send) {
@@ -679,7 +646,7 @@ static void usbip_iso_pakcet_correct_endian(
 }
 
 static void usbip_pack_iso(struct usbip_iso_packet_descriptor *iso,
-               struct usb_iso_packet_descriptor *uiso, int pack)
+                          struct usb_iso_packet_descriptor *uiso, int pack)
 {
        if (pack) {
                iso->offset             = uiso->offset;
@@ -694,7 +661,6 @@ static void usbip_pack_iso(struct usbip_iso_packet_descriptor *iso,
        }
 }
 
-
 /* must free buffer */
 void *usbip_alloc_iso_desc_pdu(struct urb *urb, ssize_t *bufflen)
 {
@@ -737,7 +703,7 @@ int usbip_recv_iso(struct usbip_device *ud, struct urb *urb)
 
        /* my Bluetooth dongle gets ISO URBs which are np = 0 */
        if (np == 0) {
-               /* usbip_uinfo("iso np == 0\n"); */
+               /* pr_info("iso np == 0\n"); */
                /* usbip_dump_urb(urb); */
                return 0;
        }
@@ -760,7 +726,6 @@ int usbip_recv_iso(struct usbip_device *ud, struct urb *urb)
                return -EPIPE;
        }
 
-
        for (i = 0; i < np; i++) {
                iso = buff + (i * sizeof(*iso));
 
@@ -773,8 +738,9 @@ int usbip_recv_iso(struct usbip_device *ud, struct urb *urb)
 
        if (total_length != urb->actual_length) {
                dev_err(&urb->dev->dev,
-                 "total length of iso packets (%d) not equal to actual length of buffer (%d)\n",
-                 total_length, urb->actual_length);
+                       "total length of iso packets %d not equal to actual "
+                       "length of buffer %d\n",
+                       total_length, urb->actual_length);
 
                if (ud->side == USBIP_STUB)
                        usbip_event_add(ud, SDEV_EVENT_ERROR_TCP);
@@ -823,9 +789,10 @@ int usbip_pad_iso(struct usbip_device *ud, struct urb *urb)
        for (i = np-1; i > 0; i--) {
                actualoffset -= urb->iso_frame_desc[i].actual_length;
                memmove(urb->transfer_buffer + urb->iso_frame_desc[i].offset,
-                                 urb->transfer_buffer + actualoffset,
-                                 urb->iso_frame_desc[i].actual_length);
+                       urb->transfer_buffer + actualoffset,
+                       urb->iso_frame_desc[i].actual_length);
        }
+
        return ret;
 }
 EXPORT_SYMBOL_GPL(usbip_pad_iso);
@@ -872,13 +839,9 @@ int usbip_recv_xbuff(struct usbip_device *ud, struct urb *urb)
 }
 EXPORT_SYMBOL_GPL(usbip_recv_xbuff);
 
-
-/*-------------------------------------------------------------------------*/
-
 static int __init usbip_common_init(void)
 {
-       printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_DESC "" DRIVER_VERSION);
-
+       pr_info(DRIVER_DESC " v" USBIP_VERSION "\n");
        return 0;
 }
 
@@ -887,12 +850,10 @@ static void __exit usbip_common_exit(void)
        return;
 }
 
-
-
-
 module_init(usbip_common_init);
 module_exit(usbip_common_exit);
 
 MODULE_AUTHOR(DRIVER_AUTHOR);
 MODULE_DESCRIPTION(DRIVER_DESC);
 MODULE_LICENSE("GPL");
+MODULE_VERSION(USBIP_VERSION);
index c767f52be5fb1499d341a574cfc33de052ae34bd..4a641c552b78cc4cf37979ab64062383c3695049 100644 (file)
  * USA.
  */
 
-#ifndef __VHCI_COMMON_H
-#define __VHCI_COMMON_H
-
-
-#include <linux/version.h>
+#ifndef __USBIP_COMMON_H
+#define __USBIP_COMMON_H
+
+#include <linux/compiler.h>
+#include <linux/device.h>
+#include <linux/interrupt.h>
+#include <linux/net.h>
+#include <linux/printk.h>
+#include <linux/spinlock.h>
+#include <linux/types.h>
 #include <linux/usb.h>
-#include <asm/byteorder.h>
-#include <net/sock.h>
-
-/*-------------------------------------------------------------------------*/
-
-/*
- * define macros to print messages
- */
-
-/**
- * usbip_udbg - print debug messages if CONFIG_USB_IP_DEBUG_ENABLE is defined
- * @fmt:
- * @args:
- */
+#include <linux/wait.h>
 
-#ifdef CONFIG_USB_IP_DEBUG_ENABLE
-
-#define usbip_udbg(fmt, args...)                                       \
-       do {                                                            \
-               printk(KERN_DEBUG "%-10s:(%s,%d) %s: " fmt,             \
-                       (in_interrupt() ? "interrupt" : (current)->comm),\
-                       __FILE__, __LINE__, __func__, ##args);          \
-       } while (0)
+#define USBIP_VERSION "1.0.0"
 
-#else  /* CONFIG_USB_IP_DEBUG_ENABLE */
-
-#define usbip_udbg(fmt, args...)               do { } while (0)
-
-#endif /* CONFIG_USB_IP_DEBUG_ENABLE */
+#undef pr_fmt
 
+#ifdef DEBUG
+#define pr_fmt(fmt)     KBUILD_MODNAME ": %s:%d: " fmt, __func__, __LINE__
+#else
+#define pr_fmt(fmt)     KBUILD_MODNAME ": " fmt
+#endif
 
 enum {
        usbip_debug_xmit        = (1 << 0),
@@ -87,16 +73,16 @@ extern struct device_attribute dev_attr_usbip_debug;
 #define usbip_dbg_with_flag(flag, fmt, args...)                \
        do {                                            \
                if (flag & usbip_debug_flag)            \
-                       usbip_udbg(fmt , ##args);               \
+                       pr_debug(fmt, ##args);          \
        } while (0)
 
-#define usbip_dbg_sysfs(fmt, args...)          \
+#define usbip_dbg_sysfs(fmt, args...) \
        usbip_dbg_with_flag(usbip_debug_sysfs, fmt , ##args)
-#define usbip_dbg_xmit(fmt, args...)           \
+#define usbip_dbg_xmit(fmt, args...) \
        usbip_dbg_with_flag(usbip_debug_xmit, fmt , ##args)
-#define usbip_dbg_urb(fmt, args...)            \
+#define usbip_dbg_urb(fmt, args...) \
        usbip_dbg_with_flag(usbip_debug_urb, fmt , ##args)
-#define usbip_dbg_eh(fmt, args...)             \
+#define usbip_dbg_eh(fmt, args...) \
        usbip_dbg_with_flag(usbip_debug_eh, fmt , ##args)
 
 #define usbip_dbg_vhci_rh(fmt, args...)        \
@@ -107,42 +93,16 @@ extern struct device_attribute dev_attr_usbip_debug;
        usbip_dbg_with_flag(usbip_debug_vhci_rx, fmt , ##args)
 #define usbip_dbg_vhci_tx(fmt, args...)        \
        usbip_dbg_with_flag(usbip_debug_vhci_tx, fmt , ##args)
-#define usbip_dbg_vhci_sysfs(fmt, args...)     \
+#define usbip_dbg_vhci_sysfs(fmt, args...) \
        usbip_dbg_with_flag(usbip_debug_vhci_sysfs, fmt , ##args)
 
-#define usbip_dbg_stub_cmp(fmt, args...)       \
+#define usbip_dbg_stub_cmp(fmt, args...) \
        usbip_dbg_with_flag(usbip_debug_stub_cmp, fmt , ##args)
-#define usbip_dbg_stub_rx(fmt, args...)        \
+#define usbip_dbg_stub_rx(fmt, args...) \
        usbip_dbg_with_flag(usbip_debug_stub_rx, fmt , ##args)
-#define usbip_dbg_stub_tx(fmt, args...)        \
+#define usbip_dbg_stub_tx(fmt, args...) \
        usbip_dbg_with_flag(usbip_debug_stub_tx, fmt , ##args)
 
-
-/**
- * usbip_uerr - print error messages
- * @fmt:
- * @args:
- */
-#define usbip_uerr(fmt, args...)                                       \
-       do {                                                            \
-               printk(KERN_ERR "%-10s: ***ERROR*** (%s,%d) %s: " fmt,  \
-                       (in_interrupt() ? "interrupt" : (current)->comm),\
-                       __FILE__, __LINE__, __func__, ##args);  \
-       } while (0)
-
-/**
- * usbip_uinfo - print information messages
- * @fmt:
- * @args:
- */
-#define usbip_uinfo(fmt, args...)                              \
-       do {                                                    \
-               printk(KERN_INFO "usbip: " fmt , ## args);      \
-       } while (0)
-
-
-/*-------------------------------------------------------------------------*/
-
 /*
  * USB/IP request headers.
  * Currently, we define 4 request types:
@@ -185,7 +145,7 @@ struct usbip_header_basic {
 #define USBIP_DIR_IN   1
        __u32 direction;
        __u32 ep;     /* endpoint number */
-} __attribute__ ((packed));
+} __packed;
 
 /*
  * An additional header for a CMD_SUBMIT packet.
@@ -212,43 +172,40 @@ struct usbip_header_cmd_submit {
 
        /* set setup packet data for a CTRL request */
        unsigned char setup[8];
-} __attribute__ ((packed));
+} __packed;
 
 /*
  * An additional header for a RET_SUBMIT packet.
  */
 struct usbip_header_ret_submit {
        __s32 status;
-       __s32 actual_length; /* returned data length */
-       __s32 start_frame; /* ISO and INT */
-       __s32 number_of_packets;  /* ISO only */
-       __s32 error_count; /* ISO only */
-} __attribute__ ((packed));
+       __s32 actual_length;            /* returned data length */
+       __s32 start_frame;              /* ISO and INT */
+       __s32 number_of_packets;        /* ISO only */
+       __s32 error_count;              /* ISO only */
+} __packed;
 
 /*
  * An additional header for a CMD_UNLINK packet.
  */
 struct usbip_header_cmd_unlink {
-       __u32 seqnum; /* URB's seqnum which will be unlinked */
-} __attribute__ ((packed));
-
+       __u32 seqnum;                   /* URB's seqnum that will be unlinked */
+} __packed;
 
 /*
  * An additional header for a RET_UNLINK packet.
  */
 struct usbip_header_ret_unlink {
        __s32 status;
-} __attribute__ ((packed));
-
+} __packed;
 
 /* the same as usb_iso_packet_descriptor but packed for pdu */
 struct usbip_iso_packet_descriptor {
        __u32 offset;
-       __u32 length;            /* expected length */
+       __u32 length;                   /* expected length */
        __u32 actual_length;
        __u32 status;
-} __attribute__ ((packed));
-
+} __packed;
 
 /*
  * All usbip packets use a common header to keep code simple.
@@ -262,18 +219,11 @@ struct usbip_header {
                struct usbip_header_cmd_unlink  cmd_unlink;
                struct usbip_header_ret_unlink  ret_unlink;
        } u;
-} __attribute__ ((packed));
-
-
-
-
-/*-------------------------------------------------------------------------*/
-
+} __packed;
 
 int usbip_xmit(int, struct socket *, char *, int, int);
 int usbip_sendmsg(struct socket *, struct msghdr *, int);
 
-
 static inline int interface_to_busnum(struct usb_interface *interface)
 {
        struct usb_device *udev = interface_to_usbdev(interface);
@@ -304,7 +254,6 @@ int set_sockaddr(struct socket *socket, struct sockaddr_storage *ss);
 void usbip_dump_urb(struct urb *purb);
 void usbip_dump_header(struct usbip_header *pdu);
 
-
 struct usbip_device;
 
 enum usbip_side {
@@ -331,7 +280,6 @@ enum usbip_status {
 /* a common structure for stub_device and vhci_device */
 struct usbip_device {
        enum usbip_side side;
-
        enum usbip_status status;
 
        /* lock for status */
@@ -370,9 +318,8 @@ struct usbip_device {
        } eh_ops;
 };
 
-
 void usbip_pack_pdu(struct usbip_header *pdu, struct urb *urb, int cmd,
-                                                               int pack);
+                   int pack);
 
 void usbip_header_correct_endian(struct usbip_header *pdu, int send);
 /* some members of urb must be substituted before. */
@@ -383,12 +330,10 @@ int usbip_recv_iso(struct usbip_device *ud, struct urb *urb);
 int usbip_pad_iso(struct usbip_device *ud, struct urb *urb);
 void *usbip_alloc_iso_desc_pdu(struct urb *urb, ssize_t *bufflen);
 
-
 /* usbip_event.c */
 int usbip_start_eh(struct usbip_device *ud);
 void usbip_stop_eh(struct usbip_device *ud);
 void usbip_event_add(struct usbip_device *ud, unsigned long event);
 int usbip_event_happened(struct usbip_device *ud);
 
-
-#endif
+#endif /* __USBIP_COMMON_H */
index f4b287ef71d0c97b92d45940ea3aae66cf87f65d..ecd1862539cd7a91786711da0575cb8c005c9cd7 100644 (file)
  * USA.
  */
 
-#include "usbip_common.h"
 #include <linux/kthread.h>
 
+#include "usbip_common.h"
+
 static int event_handler(struct usbip_device *ud)
 {
        usbip_dbg_eh("enter\n");
@@ -36,21 +37,18 @@ static int event_handler(struct usbip_device *ud)
                 */
                if (ud->event & USBIP_EH_SHUTDOWN) {
                        ud->eh_ops.shutdown(ud);
-
                        ud->event &= ~USBIP_EH_SHUTDOWN;
                }
 
                /* Reset the device. */
                if (ud->event & USBIP_EH_RESET) {
                        ud->eh_ops.reset(ud);
-
                        ud->event &= ~USBIP_EH_RESET;
                }
 
                /* Mark the device as unusable. */
                if (ud->event & USBIP_EH_UNUSABLE) {
                        ud->eh_ops.unusable(ud);
-
                        ud->event &= ~USBIP_EH_UNUSABLE;
                }
 
@@ -68,13 +66,14 @@ static int event_handler_loop(void *data)
 
        while (!kthread_should_stop()) {
                wait_event_interruptible(ud->eh_waitq,
-                                       usbip_event_happened(ud) ||
-                                       kthread_should_stop());
+                                        usbip_event_happened(ud) ||
+                                        kthread_should_stop());
                usbip_dbg_eh("wakeup\n");
 
                if (event_handler(ud) < 0)
                        break;
        }
+
        return 0;
 }
 
@@ -85,10 +84,10 @@ int usbip_start_eh(struct usbip_device *ud)
 
        ud->eh = kthread_run(event_handler_loop, ud, "usbip_eh");
        if (IS_ERR(ud->eh)) {
-               printk(KERN_WARNING
-                       "Unable to start control thread\n");
+               pr_warning("Unable to start control thread\n");
                return PTR_ERR(ud->eh);
        }
+
        return 0;
 }
 EXPORT_SYMBOL_GPL(usbip_start_eh);
@@ -106,11 +105,8 @@ EXPORT_SYMBOL_GPL(usbip_stop_eh);
 void usbip_event_add(struct usbip_device *ud, unsigned long event)
 {
        spin_lock(&ud->lock);
-
        ud->event |= event;
-
        wake_up(&ud->eh_waitq);
-
        spin_unlock(&ud->lock);
 }
 EXPORT_SYMBOL_GPL(usbip_event_add);
@@ -120,10 +116,8 @@ int usbip_event_happened(struct usbip_device *ud)
        int happened = 0;
 
        spin_lock(&ud->lock);
-
        if (ud->event != 0)
                happened = 1;
-
        spin_unlock(&ud->lock);
 
        return happened;
diff --git a/drivers/staging/usbip/userspace/AUTHORS b/drivers/staging/usbip/userspace/AUTHORS
new file mode 100644 (file)
index 0000000..2f73e65
--- /dev/null
@@ -0,0 +1,2 @@
+Takahiro Hirofuchi
+Robert Leibl
diff --git a/drivers/staging/usbip/userspace/COPYING b/drivers/staging/usbip/userspace/COPYING
new file mode 100644 (file)
index 0000000..c5611e4
--- /dev/null
@@ -0,0 +1,340 @@
+                   GNU GENERAL PUBLIC LICENSE
+                      Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+     51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+                           Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+                   GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation.  If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+                           NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+                    END OF TERMS AND CONDITIONS
+
+           How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+    Gnomovision version 69, Copyright (C) year  name of author
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+  <signature of Ty Coon>, 1 April 1989
+  Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs.  If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library.  If this is what you want to do, use the GNU Library General
+Public License instead of this License.
diff --git a/drivers/staging/usbip/userspace/INSTALL b/drivers/staging/usbip/userspace/INSTALL
new file mode 100644 (file)
index 0000000..d3c5b40
--- /dev/null
@@ -0,0 +1,237 @@
+Installation Instructions
+*************************
+
+Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
+2006, 2007 Free Software Foundation, Inc.
+
+This file is free documentation; the Free Software Foundation gives
+unlimited permission to copy, distribute and modify it.
+
+Basic Installation
+==================
+
+Briefly, the shell commands `./configure; make; make install' should
+configure, build, and install this package.  The following
+more-detailed instructions are generic; see the `README' file for
+instructions specific to this package.
+
+   The `configure' shell script attempts to guess correct values for
+various system-dependent variables used during compilation.  It uses
+those values to create a `Makefile' in each directory of the package.
+It may also create one or more `.h' files containing system-dependent
+definitions.  Finally, it creates a shell script `config.status' that
+you can run in the future to recreate the current configuration, and a
+file `config.log' containing compiler output (useful mainly for
+debugging `configure').
+
+   It can also use an optional file (typically called `config.cache'
+and enabled with `--cache-file=config.cache' or simply `-C') that saves
+the results of its tests to speed up reconfiguring.  Caching is
+disabled by default to prevent problems with accidental use of stale
+cache files.
+
+   If you need to do unusual things to compile the package, please try
+to figure out how `configure' could check whether to do them, and mail
+diffs or instructions to the address given in the `README' so they can
+be considered for the next release.  If you are using the cache, and at
+some point `config.cache' contains results you don't want to keep, you
+may remove or edit it.
+
+   The file `configure.ac' (or `configure.in') is used to create
+`configure' by a program called `autoconf'.  You need `configure.ac' if
+you want to change it or regenerate `configure' using a newer version
+of `autoconf'.
+
+The simplest way to compile this package is:
+
+  1. `cd' to the directory containing the package's source code and type
+     `./configure' to configure the package for your system.
+
+     Running `configure' might take a while.  While running, it prints
+     some messages telling which features it is checking for.
+
+  2. Type `make' to compile the package.
+
+  3. Optionally, type `make check' to run any self-tests that come with
+     the package.
+
+  4. Type `make install' to install the programs and any data files and
+     documentation.
+
+  5. You can remove the program binaries and object files from the
+     source code directory by typing `make clean'.  To also remove the
+     files that `configure' created (so you can compile the package for
+     a different kind of computer), type `make distclean'.  There is
+     also a `make maintainer-clean' target, but that is intended mainly
+     for the package's developers.  If you use it, you may have to get
+     all sorts of other programs in order to regenerate files that came
+     with the distribution.
+
+  6. Often, you can also type `make uninstall' to remove the installed
+     files again.
+
+Compilers and Options
+=====================
+
+Some systems require unusual options for compilation or linking that the
+`configure' script does not know about.  Run `./configure --help' for
+details on some of the pertinent environment variables.
+
+   You can give `configure' initial values for configuration parameters
+by setting variables in the command line or in the environment.  Here
+is an example:
+
+     ./configure CC=c99 CFLAGS=-g LIBS=-lposix
+
+   *Note Defining Variables::, for more details.
+
+Compiling For Multiple Architectures
+====================================
+
+You can compile the package for more than one kind of computer at the
+same time, by placing the object files for each architecture in their
+own directory.  To do this, you can use GNU `make'.  `cd' to the
+directory where you want the object files and executables to go and run
+the `configure' script.  `configure' automatically checks for the
+source code in the directory that `configure' is in and in `..'.
+
+   With a non-GNU `make', it is safer to compile the package for one
+architecture at a time in the source code directory.  After you have
+installed the package for one architecture, use `make distclean' before
+reconfiguring for another architecture.
+
+Installation Names
+==================
+
+By default, `make install' installs the package's commands under
+`/usr/local/bin', include files under `/usr/local/include', etc.  You
+can specify an installation prefix other than `/usr/local' by giving
+`configure' the option `--prefix=PREFIX'.
+
+   You can specify separate installation prefixes for
+architecture-specific files and architecture-independent files.  If you
+pass the option `--exec-prefix=PREFIX' to `configure', the package uses
+PREFIX as the prefix for installing programs and libraries.
+Documentation and other data files still use the regular prefix.
+
+   In addition, if you use an unusual directory layout you can give
+options like `--bindir=DIR' to specify different values for particular
+kinds of files.  Run `configure --help' for a list of the directories
+you can set and what kinds of files go in them.
+
+   If the package supports it, you can cause programs to be installed
+with an extra prefix or suffix on their names by giving `configure' the
+option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
+
+Optional Features
+=================
+
+Some packages pay attention to `--enable-FEATURE' options to
+`configure', where FEATURE indicates an optional part of the package.
+They may also pay attention to `--with-PACKAGE' options, where PACKAGE
+is something like `gnu-as' or `x' (for the X Window System).  The
+`README' should mention any `--enable-' and `--with-' options that the
+package recognizes.
+
+   For packages that use the X Window System, `configure' can usually
+find the X include and library files automatically, but if it doesn't,
+you can use the `configure' options `--x-includes=DIR' and
+`--x-libraries=DIR' to specify their locations.
+
+Specifying the System Type
+==========================
+
+There may be some features `configure' cannot figure out automatically,
+but needs to determine by the type of machine the package will run on.
+Usually, assuming the package is built to be run on the _same_
+architectures, `configure' can figure that out, but if it prints a
+message saying it cannot guess the machine type, give it the
+`--build=TYPE' option.  TYPE can either be a short name for the system
+type, such as `sun4', or a canonical name which has the form:
+
+     CPU-COMPANY-SYSTEM
+
+where SYSTEM can have one of these forms:
+
+     OS KERNEL-OS
+
+   See the file `config.sub' for the possible values of each field.  If
+`config.sub' isn't included in this package, then this package doesn't
+need to know the machine type.
+
+   If you are _building_ compiler tools for cross-compiling, you should
+use the option `--target=TYPE' to select the type of system they will
+produce code for.
+
+   If you want to _use_ a cross compiler, that generates code for a
+platform different from the build platform, you should specify the
+"host" platform (i.e., that on which the generated programs will
+eventually be run) with `--host=TYPE'.
+
+Sharing Defaults
+================
+
+If you want to set default values for `configure' scripts to share, you
+can create a site shell script called `config.site' that gives default
+values for variables like `CC', `cache_file', and `prefix'.
+`configure' looks for `PREFIX/share/config.site' if it exists, then
+`PREFIX/etc/config.site' if it exists.  Or, you can set the
+`CONFIG_SITE' environment variable to the location of the site script.
+A warning: not all `configure' scripts look for a site script.
+
+Defining Variables
+==================
+
+Variables not defined in a site shell script can be set in the
+environment passed to `configure'.  However, some packages may run
+configure again during the build, and the customized values of these
+variables may be lost.  In order to avoid this problem, you should set
+them in the `configure' command line, using `VAR=value'.  For example:
+
+     ./configure CC=/usr/local2/bin/gcc
+
+causes the specified `gcc' to be used as the C compiler (unless it is
+overridden in the site shell script).
+
+Unfortunately, this technique does not work for `CONFIG_SHELL' due to
+an Autoconf bug.  Until the bug is fixed you can use this workaround:
+
+     CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
+
+`configure' Invocation
+======================
+
+`configure' recognizes the following options to control how it operates.
+
+`--help'
+`-h'
+     Print a summary of the options to `configure', and exit.
+
+`--version'
+`-V'
+     Print the version of Autoconf used to generate the `configure'
+     script, and exit.
+
+`--cache-file=FILE'
+     Enable the cache: use and save the results of the tests in FILE,
+     traditionally `config.cache'.  FILE defaults to `/dev/null' to
+     disable caching.
+
+`--config-cache'
+`-C'
+     Alias for `--cache-file=config.cache'.
+
+`--quiet'
+`--silent'
+`-q'
+     Do not print messages saying which checks are being made.  To
+     suppress all normal output, redirect it to `/dev/null' (any error
+     messages will still be shown).
+
+`--srcdir=DIR'
+     Look for the package's source code in directory DIR.  Usually
+     `configure' can determine that directory automatically.
+
+`configure' also accepts some other, not widely useful, options.  Run
+`configure --help' for more details.
+
diff --git a/drivers/staging/usbip/userspace/Makefile.am b/drivers/staging/usbip/userspace/Makefile.am
new file mode 100644 (file)
index 0000000..83f51b8
--- /dev/null
@@ -0,0 +1,11 @@
+SUBDIRS := libsrc src
+includedir := @includedir@/usbip
+include_HEADERS := $(addprefix libsrc/, \
+                    usbip.h usbip_common.h vhci_driver.h stub_driver.h)
+
+dist_man_MANS := $(addprefix doc/, usbip.8 usbipd.8 usbip_bind_driver.8)
+
+if INSTALL_USBIDS
+pkgdata_DATA := usb.ids
+EXTRA_DIST := $(pkgdata_DATA)
+endif
diff --git a/drivers/staging/usbip/userspace/README b/drivers/staging/usbip/userspace/README
new file mode 100644 (file)
index 0000000..2ee84b9
--- /dev/null
@@ -0,0 +1,215 @@
+# vim:tw=78:ts=4:expandtab:ai:sw=4
+#
+# README for usbip-utils
+#
+# Copyright (C) 2005-2008 Takahiro Hirofuchi
+
+
+[Requirements]
+    - USB/IP device drivers
+        Its source code is included under $(top)/drivers/.
+
+    - sysfsutils >= 2.0.0
+        sysfsutils library
+
+    - libwrap0-dev
+        tcp wrapper library
+
+    - gcc >= 4.0
+
+    - libglib2.0-dev >= 2.6.0
+
+    - libtool, automake >= 1.9, autoconf >= 2.5.0, pkg-config
+
+[Install]
+    0. Skip here if you see a configure script.
+        $ ./autogen.sh
+
+    1. Compile & install.
+        $ ./configure
+        $ make install
+
+    2. Compile & install USB/IP drivers if not yet.
+
+[Usage]
+    server:# (Attach your USB device physically.)
+
+    server:# insmod usbip-core.ko
+    server:# insmod usbip-host.ko
+        - It was formerly named as stub.ko.
+
+    server:# usbipd -D
+        - Start usbip daemon.
+
+    server:# usbip_bind_driver --list
+        - List driver assignments for usb devices.
+
+    server:# usbip_bind_driver --usbip 1-2
+        - Bind usbip-host.ko to the device of busid 1-2.
+        - A usb device 1-2 is now exportable to other hosts!
+        - Use 'usbip_bind_driver --other 1-2' when you want to shutdown exporting
+          and use the device locally.
+
+
+    client:# insmod usbip-core.ko
+    client:# insmod vhci-hcd.ko
+        - It was formerly named as vhci.ko.
+
+    client:# usbip --list server
+        - List exportable usb devices on the server.
+
+    client:# usbip --attach server 1-2
+        - Connect the remote USB device.
+
+    client:# usbip --port
+        - Show virtual port status.
+
+    client:# usbip --detach 0
+        - Detach the usb device.
+
+
+[Output Example]
+--------------------------------------------------------------------------------------------------------
+- SERVER SIDE (physically attach your USB devices to this host) ----------------------------------------
+--------------------------------------------------------------------------------------------------------
+trois:# insmod (somewhere)/usbip-core.ko
+trois:# insmod (somewhere)/usbip-host.ko
+trois:# usbipd -D
+
+--------------------------------------------------------------------------------------------------------
+In another terminal, let's look up what usb devices are physically attached to
+this host.  We can see a usb storage device of busid 3-3.2 is now bound to
+usb-storage driver. To export this device, we first mark the device as
+"exportable"; the device is bound to usbip driver. Please remember you can not
+export a usb hub.
+
+   trois:# usbip_bind_driver --list
+   List USB devices
+   - busid 3-3.2 (04bb:0206)
+       3-3.2:1.0 -> usb-storage
+
+   - busid 3-3.1 (08bb:2702)
+       3-3.1:1.0 -> snd-usb-audio
+       3-3.1:1.1 -> snd-usb-audio
+
+   - busid 3-3 (0409:0058)
+       3-3:1.0 -> hub
+
+   - busid 3-2 (0711:0902)
+       3-2:1.0 -> none
+
+   - busid 1-1 (05a9:a511)
+       1-1:1.0 -> ov511
+
+   - busid 4-1 (046d:08b2)
+       4-1:1.0 -> none
+       4-1:1.1 -> none
+       4-1:1.2 -> none
+
+   - busid 5-2 (058f:9254)
+       5-2:1.0 -> hub
+
+--------------------------------------------------------------------------------------------------------
+Mark the device of busid 3-3.2 as exportable.
+
+   trois:# usbip_bind_driver --usbip 3-3.2
+   ** (process:24621): DEBUG:  3-3.2:1.0   -> none
+   ** (process:24621): DEBUG: write "add 3-3.2" to /sys/bus/usb/drivers/usbip/match_busid
+   ** Message: bind 3-3.2 to usbip, complete!
+
+   trois:# usbip_bind_driver --list
+   List USB devices
+   - busid 3-3.2 (04bb:0206)
+           3-3.2:1.0 -> usbip
+   (snip)
+
+Iterate the above operation for other devices if you like.
+
+
+--------------------------------------------------------------------------------------------------------
+- CLIENT SIDE ------------------------------------------------------------------------------------------
+--------------------------------------------------------------------------------------------------------
+First, let's list available remote devices which are marked as exportable in
+the server host.
+
+   deux:# insmod (somewhere)/usbip-core.ko
+   deux:# insmod (somewhere)/vhci_hcd.ko
+
+   deux:# usbip --list 10.0.0.3
+   - 10.0.0.3
+          1-1: Prolific Technology, Inc. : unknown product (067b:3507)
+             : /sys/devices/pci0000:00/0000:00:1f.2/usb1/1-1
+             : (Defined at Interface level) / unknown subclass / unknown protocol (00/00/00)
+             :  0 - Mass Storage / SCSI / Bulk (Zip) (08/06/50)
+
+      1-2.2.1: Apple Computer, Inc. : unknown product (05ac:0203)
+             : /sys/devices/pci0000:00/0000:00:1f.2/usb1/1-2/1-2.2/1-2.2.1
+             : (Defined at Interface level) / unknown subclass / unknown protocol (00/00/00)
+             :  0 - Human Interface Devices / Boot Interface Subclass / Keyboard (03/01/01)
+
+      1-2.2.3: OmniVision Technologies, Inc. : OV511+ WebCam (05a9:a511)
+             : /sys/devices/pci0000:00/0000:00:1f.2/usb1/1-2/1-2.2/1-2.2.3
+             : (Defined at Interface level) / unknown subclass / unknown protocol (00/00/00)
+             :  0 - Vendor Specific Class / unknown subclass / unknown protocol (ff/00/00)
+
+          3-1: Logitech, Inc. : QuickCam Pro 4000 (046d:08b2)
+             : /sys/devices/pci0000:00/0000:00:1e.0/0000:02:0a.0/usb3/3-1
+             : (Defined at Interface level) / unknown subclass / unknown protocol (00/00/00)
+             :  0 - Data / unknown subclass / unknown protocol (0a/ff/00)
+             :  1 - Audio / Control Device / unknown protocol (01/01/00)
+             :  2 - Audio / Streaming / unknown protocol (01/02/00)
+
+          4-1: Logitech, Inc. : QuickCam Express (046d:0870)
+             : /sys/devices/pci0000:00/0000:00:1e.0/0000:02:0a.1/usb4/4-1
+             : Vendor Specific Class / Vendor Specific Subclass / Vendor Specific Protocol (ff/ff/ff)
+             :  0 - Vendor Specific Class / Vendor Specific Subclass / Vendor Specific Protocol (ff/ff/ff)
+
+          4-2: Texas Instruments Japan : unknown product (08bb:2702)
+             : /sys/devices/pci0000:00/0000:00:1e.0/0000:02:0a.1/usb4/4-2
+             : (Defined at Interface level) / unknown subclass / unknown protocol (00/00/00)
+             :  0 - Audio / Control Device / unknown protocol (01/01/00)
+             :  1 - Audio / Streaming / unknown protocol (01/02/00)
+
+--------------------------------------------------------------------------------------------------------
+Attach a remote usb device!
+
+   deux:# usbip --attach 10.0.0.3 1-1
+   port 0 attached
+
+--------------------------------------------------------------------------------------------------------
+Show what devices are attached to this client.
+
+   deux:# usbip --port
+   Port 00: <Port in Use> at Full Speed(12Mbps)
+          Prolific Technology, Inc. : unknown product (067b:3507)
+          6-1 -> usbip://10.0.0.3:3240/1-1  (remote bus/dev 001/004)
+          6-1:1.0 used by usb-storage
+                         /sys/class/scsi_device/0:0:0:0/device
+                         /sys/class/scsi_host/host0/device
+                         /sys/block/sda/device
+
+--------------------------------------------------------------------------------------------------------
+Detach the imported device.
+
+   deux:# usbip --detach 0
+   port 0 detached
+
+--------------------------------------------------------------------------------------------------------
+
+
+[Check List]
+    - See Debug Tips in the project wiki.
+        - http://usbip.wiki.sourceforge.net/how-to-debug-usbip
+    - usbip-host.ko must be bound to the target device.
+        - See /proc/bus/usb/devices and find "Driver=..." lines of the device.
+    - Shutdown firewall.
+        - usbip now uses TCP port 3240.
+    - Disable SELinux.
+    - If possible, compile your kernel with CONFIG_USB_DEBUG flag and try
+      again.
+    - Check your kernel and daemon messages.
+        ex. /var/log/{messages, kern.log, daemon.log, syslog}
+
+
+[Contact]
+    Mailing List: usbip-devel _at_ lists.sourceforge.net
diff --git a/drivers/staging/usbip/userspace/autogen.sh b/drivers/staging/usbip/userspace/autogen.sh
new file mode 100755 (executable)
index 0000000..e1112d3
--- /dev/null
@@ -0,0 +1,9 @@
+#!/bin/sh -x
+
+#aclocal
+#autoheader
+#libtoolize --copy --force
+#automake-1.9 -acf
+#autoconf
+
+autoreconf -i -f -v
diff --git a/drivers/staging/usbip/userspace/cleanup.sh b/drivers/staging/usbip/userspace/cleanup.sh
new file mode 100755 (executable)
index 0000000..da2f89b
--- /dev/null
@@ -0,0 +1,10 @@
+#!/bin/sh -x
+
+
+if [ -r Makefile ]; then
+       make distclean
+fi
+
+FILES="configure cscope.out Makefile.in depcomp compile config.guess config.sub config.h.in~ config.log config.status ltmain.sh libtool config.h.in autom4te.cache missing aclocal.m4 install-sh cmd/Makefile.in lib/Makefile.in Makefile lib/Makefile cmd/Makefile"
+
+rm -Rf $FILES
diff --git a/drivers/staging/usbip/userspace/configure.ac b/drivers/staging/usbip/userspace/configure.ac
new file mode 100644 (file)
index 0000000..e3afa15
--- /dev/null
@@ -0,0 +1,114 @@
+dnl Process this file with autoconf to produce a configure script.
+
+AC_PREREQ(2.59)
+AC_INIT([usbip], [0.1.8], [usbip-devel@lists.sourceforge.net])
+AC_DEFINE([USBIP_VERSION], [0x000106], [numeric version number])
+
+CURRENT=0
+REVISION=1
+AGE=0
+AC_SUBST([LIBUSBIP_VERSION], [$CURRENT:$REVISION:$AGE], [library version])
+
+AC_CONFIG_SRCDIR([src/usbipd.c])
+AC_CONFIG_HEADERS([config.h])
+
+AM_INIT_AUTOMAKE([foreign])
+LT_INIT
+
+# Silent build for automake >= 1.11
+m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
+
+AC_SUBST([EXTRA_CFLAGS], ["-Wall -Werror -Wextra -std=gnu99"])
+
+# Checks for programs.
+AC_PROG_CC
+AC_PROG_INSTALL
+AC_PROG_MAKE_SET
+
+# Checks for header files.
+AC_HEADER_DIRENT
+AC_HEADER_STDC
+AC_CHECK_HEADERS([arpa/inet.h fcntl.h netdb.h netinet/in.h stdint.h stdlib.h dnl
+                 string.h strings.h sys/socket.h syslog.h unistd.h])
+
+# Checks for typedefs, structures, and compiler characteristics.
+AC_TYPE_INT32_T
+AC_TYPE_SIZE_T
+AC_TYPE_SSIZE_T
+AC_TYPE_UINT16_T
+AC_TYPE_UINT32_T
+AC_TYPE_UINT8_T
+
+# Checks for library functions.
+AC_FUNC_REALLOC
+AC_CHECK_FUNCS([bzero memset mkdir regcomp socket strchr strerror strstr dnl
+               strtoul])
+
+AC_CHECK_HEADER([sysfs/libsysfs.h],
+               [AC_CHECK_LIB([sysfs], [sysfs_open_directory_list],
+                             [LIBS="$LIBS -lsysfs"],
+                             [AC_MSG_ERROR([Missing sysfs2 library!])])],
+               [AC_MSG_ERROR([Missing /usr/include/sysfs/libsysfs.h])])
+
+# Checks for libwrap library.
+AC_MSG_CHECKING([whether to use the libwrap (TCP wrappers) library])
+AC_ARG_WITH([tcp-wrappers],
+           [AS_HELP_STRING([--with-tcp-wrappers],
+                           [use the libwrap (TCP wrappers) library])],
+           dnl [ACTION-IF-GIVEN]
+           [saved_LIBS="$LIBS"
+            if test "$withval" = "yes"; then
+                    AC_MSG_RESULT([yes])
+                    AC_MSG_CHECKING([for hosts_access in -lwrap])
+                    LIBS="-lwrap $LIBS"
+                    AC_TRY_LINK(
+                      [int hosts_access(); int allow_severity, deny_severity;],
+                      [hosts_access()],
+                      [AC_MSG_RESULT([yes]);
+                       AC_DEFINE([HAVE_LIBWRAP], [1],
+                                 [use tcp wrapper]) wrap_LIB="-lwrap"],
+                      [AC_MSG_RESULT([not found]); exit 1])
+            else
+                    AC_MSG_RESULT([no])
+            fi
+            LIBS="$saved_LIBS"],
+           dnl [ACTION-IF-NOT-GIVEN]
+           [AC_MSG_RESULT([(default)])
+            AC_MSG_CHECKING([for hosts_access in -lwrap])
+            saved_LIBS="$LIBS"
+            LIBS="-lwrap $saved_LIBS"
+            AC_TRY_LINK(
+              [int hosts_access(); int allow_severity, deny_severity;],
+              [hosts_access()],
+              [AC_MSG_RESULT([yes]);
+               AC_DEFINE([HAVE_LIBWRAP], [1], [use tcp wrapper])],
+              [AC_MSG_RESULT([no]); LIBS="$saved_LIBS"])])
+
+# Sets directory containing usb.ids.
+USBIDS_DIR='${datadir}/usbip'
+AC_ARG_WITH([usbids-dir],
+           [AS_HELP_STRING([--with-usbids-dir=DIR],
+              [where usb.ids is found (default ${datadir}/usbip)])],
+           [USBIDS_DIR=$withval])
+AC_SUBST([USBIDS_DIR])
+
+dnl FIXME: when disabled, empty directry is created
+usbids=install
+AC_ARG_ENABLE([usbids-install],
+             [AS_HELP_STRING([--enable-usbids-install],
+                             [install usb.ids (default)])],
+             [AS_CASE([$enableval],
+                      [yes], [usbids=install],
+                      [no], [usbids=notinstall],
+                      [AC_MSG_ERROR(
+                         [bad value ${enableval} for --enable-usbids-install])]
+                     )])
+AM_CONDITIONAL([INSTALL_USBIDS], [test x$usbids = xinstall])
+
+GLIB2_REQUIRED=2.6.0
+PKG_CHECK_MODULES([PACKAGE], [glib-2.0 >= $GLIB2_REQUIRED])
+AC_SUBST([PACKAGE_CFLAGS])
+AC_SUBST([PACKAGE_LIBS])
+
+AC_CONFIG_FILES([Makefile libsrc/Makefile src/Makefile])
+AC_OUTPUT
diff --git a/drivers/staging/usbip/userspace/doc/usbip.8 b/drivers/staging/usbip/userspace/doc/usbip.8
new file mode 100644 (file)
index 0000000..1653bb2
--- /dev/null
@@ -0,0 +1,71 @@
+.TH USBIP "8" "February 2009" "usbip" "System Administration Utilities"
+.SH NAME
+usbip \- manage USB/IP devices
+.SH SYNOPSIS
+.B usbip
+[\fIoptions\fR]
+
+.SH DESCRIPTION
+Devices exported by USB/IP servers can be listed, attached and
+detached using this program.
+
+.SH OPTIONS
+.HP
+\fB\-a\fR, \fB\-\-attach\fR <host> <bus_id>
+.IP
+Attach a remote USB device.
+.PP
+
+.HP
+\fB\-x\fR, \fB\-\-attachall\fR <host>
+.IP
+Attach all remote USB devices on the specific host.
+.PP
+
+.HP
+\fB\-d\fR, \fB\-\-detach\fR <ports>
+.IP
+Detach an imported USB device.
+.PP
+
+.HP
+\fB\-l\fR, \fB\-\-list\fR <hosts>
+.IP
+List exported USB devices.
+.PP
+
+.HP
+\fB\-p\fR, \fB\-\-port\fR
+.IP
+List virtual USB port status.
+.PP
+
+.HP
+\fB\-D\fR, \fB\-\-debug\fR
+.IP
+Print debugging information.
+.PP
+
+.HP
+\fB\-v\fR, \fB\-\-version\fR
+.IP
+Show version.
+.PP
+
+.SH EXAMPLES
+
+    client:# usbip --list server
+        - List exportable usb devices on the server.
+
+    client:# usbip --attach server 1-2
+        - Connect the remote USB device.
+
+    client:# usbip --port
+        - Show virtual port status.
+
+    client:# usbip --detach 0
+        - Detach the usb device.
+
+.SH "SEE ALSO"
+\fBusbipd\fP\fB(8)\fB\fP,
+\fBusbip_attach_driver\fP\fB(8)\fB\fP
diff --git a/drivers/staging/usbip/userspace/doc/usbip_bind_driver.8 b/drivers/staging/usbip/userspace/doc/usbip_bind_driver.8
new file mode 100644 (file)
index 0000000..d43bbd6
--- /dev/null
@@ -0,0 +1,42 @@
+.TH USBIP_BIND_DRIVER "8" "February 2009" "usbip" "System Administration Utilities"
+.SH NAME
+usbip_bind_driver \- change driver binding for USB/IP
+
+.SH SYNOPSIS
+.B usbip_bind_driver
+[\fIoptions\fR]
+
+.SH DESCRIPTION
+Driver bindings for USB devices can be changed using
+this program. It is used to export and unexport USB
+devices over USB/IP.
+
+.SH OPTIONS
+.TP
+\fB\-u\fR, \fB\-\-usbip\fR <busid>
+Make a device exportable
+.TP
+\fB\-o\fR, \fB\-\-other\fR <busid>
+Use a device by a local driver
+.TP
+\fB\-l\fR, \fB\-\-list\fR
+Print usb devices and their drivers
+.TP
+\fB\-L\fR, \fB\-\-list2\fR
+Print usb devices and their drivers in parseable mode
+
+.SH EXAMPLES
+
+    server:# usbip_bind_driver --list
+        - List driver assignments for usb devices.
+
+    server:# usbip_bind_driver --usbip 1-2
+        - Bind usbip-host.ko to the device of busid 1-2.
+        - A usb device 1-2 is now exportable to other hosts!
+
+    server:# usbip_bind_driver --other 1-2
+        - Shutdown exporting and use the device locally.
+
+.SH "SEE ALSO"
+\fBusbip\fP\fB(8)\fB\fP,
+\fBusbipd\fP\fB(8)\fB\fP
diff --git a/drivers/staging/usbip/userspace/doc/usbipd.8 b/drivers/staging/usbip/userspace/doc/usbipd.8
new file mode 100644 (file)
index 0000000..006559f
--- /dev/null
@@ -0,0 +1,62 @@
+.TH USBIP "8" "February 2009" "usbip" "System Administration Utilities"
+.SH NAME
+usbipd \- USB/IP server daemon
+.SH SYNOPSIS
+.B usbipd
+[\fIoptions\fR]
+
+.SH DESCRIPTION
+.B usbipd
+provides USB/IP clients access to exported USB devices.
+
+Devices have to explicitly be exported using
+.B usbip_bind_driver
+before usbipd makes them available to other hosts.
+
+The daemon accepts connections from USB/IP clients
+on TCP port 3240.
+
+.SH OPTIONS
+.HP
+\fB\-D\fR, \fB\-\-daemon\fR
+.IP
+Run as a daemon process.
+.PP
+
+.HP
+\fB\-d\fR, \fB\-\-debug\fR
+.IP
+Print debugging information.
+.PP
+
+.HP
+\fB\-v\fR, \fB\-\-version\fR
+.IP
+Show version.
+.PP
+
+.SH LIMITATIONS
+
+.B usbipd
+offers no authentication or authorization for USB/IP. Any
+USB/IP client can connect and use exported devices.
+
+.SH EXAMPLES
+
+    server:# modprobe usbip
+
+    server:# usbipd -D
+        - Start usbip daemon.
+
+    server:# usbip_bind_driver --list
+        - List driver assignments for usb devices.
+
+    server:# usbip_bind_driver --usbip 1-2
+        - Bind usbip-host.ko to the device of busid 1-2.
+        - A usb device 1-2 is now exportable to other hosts!
+        - Use 'usbip_bind_driver --other 1-2' when you want to shutdown exporting and use the device locally.
+
+.SH "SEE ALSO"
+\fBusbip\fP\fB(8)\fB\fP,
+\fBusbip_attach_driver\fP\fB(8)\fB\fP
+
diff --git a/drivers/staging/usbip/userspace/libsrc/Makefile.am b/drivers/staging/usbip/userspace/libsrc/Makefile.am
new file mode 100644 (file)
index 0000000..77ecf6b
--- /dev/null
@@ -0,0 +1,7 @@
+libusbip_la_CPPFLAGS := -DUSBIDS_FILE='"@USBIDS_DIR@/usb.ids"'
+libusbip_la_CFLAGS   := @EXTRA_CFLAGS@
+libusbip_la_LDFLAGS  := -version-info @LIBUSBIP_VERSION@
+
+lib_LTLIBRARIES := libusbip.la
+libusbip_la_SOURCES := names.c names.h stub_driver.c stub_driver.h usbip.h \
+                      usbip_common.c usbip_common.h vhci_driver.c vhci_driver.h
diff --git a/drivers/staging/usbip/userspace/libsrc/names.c b/drivers/staging/usbip/userspace/libsrc/names.c
new file mode 100644 (file)
index 0000000..b4de18b
--- /dev/null
@@ -0,0 +1,793 @@
+/*****************************************************************************/
+/*
+ *      names.c  --  USB name database manipulation routines
+ *
+ *      Copyright (C) 1999, 2000  Thomas Sailer (sailer@ife.ee.ethz.ch)
+ *
+ *      This program is free software; you can redistribute it and/or modify
+ *      it under the terms of the GNU General Public License as published by
+ *      the Free Software Foundation; either version 2 of the License, or
+ *      (at your option) any later version.
+ *
+ *      This program is distributed in the hope that it will be useful,
+ *      but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *      GNU General Public License for more details.
+ *
+ *      You should have received a copy of the GNU General Public License
+ *      along with this program; if not, write to the Free Software
+ *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ *
+ */
+
+/*
+ *     Copyright (C) 2005 Takahiro Hirofuchi
+ *             - names_deinit() is added.
+ */
+
+/*****************************************************************************/
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <dirent.h>
+#include <string.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <ctype.h>
+
+
+#include "names.h"
+
+
+/* ---------------------------------------------------------------------- */
+
+struct vendor {
+       struct vendor *next;
+       u_int16_t vendorid;
+       char name[1];
+};
+
+struct product {
+       struct product *next;
+       u_int16_t vendorid, productid;
+       char name[1];
+};
+
+struct class {
+       struct class *next;
+       u_int8_t classid;
+       char name[1];
+};
+
+struct subclass {
+       struct subclass *next;
+       u_int8_t classid, subclassid;
+       char name[1];
+};
+
+struct protocol {
+       struct protocol *next;
+       u_int8_t classid, subclassid, protocolid;
+       char name[1];
+};
+
+struct audioterminal {
+       struct audioterminal *next;
+       u_int16_t termt;
+       char name[1];
+};
+
+struct genericstrtable {
+        struct genericstrtable *next;
+        unsigned int num;
+        char name[1];
+};
+
+/* ---------------------------------------------------------------------- */
+
+#define HASH1  0x10
+#define HASH2  0x02
+#define HASHSZ 16
+
+static unsigned int hashnum(unsigned int num)
+{
+       unsigned int mask1 = HASH1 << 27, mask2 = HASH2 << 27;
+
+       for (; mask1 >= HASH1; mask1 >>= 1, mask2 >>= 1)
+               if (num & mask1)
+                       num ^= mask2;
+       return num & (HASHSZ-1);
+}
+
+/* ---------------------------------------------------------------------- */
+
+static struct vendor *vendors[HASHSZ] = { NULL, };
+static struct product *products[HASHSZ] = { NULL, };
+static struct class *classes[HASHSZ] = { NULL, };
+static struct subclass *subclasses[HASHSZ] = { NULL, };
+static struct protocol *protocols[HASHSZ] = { NULL, };
+static struct audioterminal *audioterminals[HASHSZ] = { NULL, };
+static struct genericstrtable *hiddescriptors[HASHSZ] = { NULL, };
+static struct genericstrtable *reports[HASHSZ] = { NULL, };
+static struct genericstrtable *huts[HASHSZ] = { NULL, };
+static struct genericstrtable *biass[HASHSZ] = { NULL, };
+static struct genericstrtable *physdess[HASHSZ] = { NULL, };
+static struct genericstrtable *hutus[HASHSZ] = { NULL, };
+static struct genericstrtable *langids[HASHSZ] = { NULL, };
+static struct genericstrtable *countrycodes[HASHSZ] = { NULL, };
+
+/* ---------------------------------------------------------------------- */
+
+static const char *names_genericstrtable(struct genericstrtable *t[HASHSZ], unsigned int index)
+{
+        struct genericstrtable *h;
+
+        for (h = t[hashnum(index)]; h; h = h->next)
+                if (h->num == index)
+                        return h->name;
+        return NULL;
+}
+
+const char *names_hid(u_int8_t hidd)
+{
+       return names_genericstrtable(hiddescriptors, hidd);
+}
+
+const char *names_reporttag(u_int8_t rt)
+{
+       return names_genericstrtable(reports, rt);
+}
+
+const char *names_huts(unsigned int data)
+{
+       return names_genericstrtable(huts, data);
+}
+
+const char *names_hutus(unsigned int data)
+{
+       return names_genericstrtable(hutus, data);
+}
+
+const char *names_langid(u_int16_t langid)
+{
+       return names_genericstrtable(langids, langid);
+}
+
+const char *names_physdes(u_int8_t ph)
+{
+       return names_genericstrtable(physdess, ph);
+}
+
+const char *names_bias(u_int8_t b)
+{
+       return names_genericstrtable(biass, b);
+}
+
+const char *names_countrycode(unsigned int countrycode)
+{
+       return names_genericstrtable(countrycodes, countrycode);
+}
+
+const char *names_vendor(u_int16_t vendorid)
+{
+       struct vendor *v;
+
+       v = vendors[hashnum(vendorid)];
+       for (; v; v = v->next)
+               if (v->vendorid == vendorid)
+                       return v->name;
+       return NULL;
+}
+
+const char *names_product(u_int16_t vendorid, u_int16_t productid)
+{
+       struct product *p;
+
+       p = products[hashnum((vendorid << 16) | productid)];
+       for (; p; p = p->next)
+               if (p->vendorid == vendorid && p->productid == productid)
+                       return p->name;
+       return NULL;
+}
+
+const char *names_class(u_int8_t classid)
+{
+       struct class *c;
+
+       c = classes[hashnum(classid)];
+       for (; c; c = c->next)
+               if (c->classid == classid)
+                       return c->name;
+       return NULL;
+}
+
+const char *names_subclass(u_int8_t classid, u_int8_t subclassid)
+{
+       struct subclass *s;
+
+       s = subclasses[hashnum((classid << 8) | subclassid)];
+       for (; s; s = s->next)
+               if (s->classid == classid && s->subclassid == subclassid)
+                       return s->name;
+       return NULL;
+}
+
+const char *names_protocol(u_int8_t classid, u_int8_t subclassid, u_int8_t protocolid)
+{
+       struct protocol *p;
+
+       p = protocols[hashnum((classid << 16) | (subclassid << 8) | protocolid)];
+       for (; p; p = p->next)
+               if (p->classid == classid && p->subclassid == subclassid && p->protocolid == protocolid)
+                       return p->name;
+       return NULL;
+}
+
+const char *names_audioterminal(u_int16_t termt)
+{
+       struct audioterminal *at;
+
+       at = audioterminals[hashnum(termt)];
+       for (; at; at = at->next)
+               if (at->termt == termt)
+                       return at->name;
+       return NULL;
+}
+
+/* ---------------------------------------------------------------------- */
+/* add a cleanup function by takahiro */
+
+struct pool {
+       struct pool *next;
+       void *mem;
+};
+
+static struct pool *pool_head = NULL;
+
+static void *my_malloc(size_t size)
+{
+       struct pool *p;
+
+       p = calloc(1, sizeof(struct pool));
+       if (!p) {
+               free(p);
+               return NULL;
+       }
+
+       p->mem = calloc(1, size);
+       if (!p->mem)
+               return NULL;
+
+       p->next = pool_head;
+       pool_head = p;
+
+       return p->mem;
+}
+
+void names_free(void)
+{
+       struct pool *pool;
+
+       if (!pool_head)
+               return;
+
+       for (pool = pool_head; pool != NULL; ) {
+               struct pool *tmp;
+
+               if (pool->mem)
+                       free(pool->mem);
+
+               tmp = pool;
+               pool = pool->next;
+               free(tmp);
+       }
+}
+
+/* ---------------------------------------------------------------------- */
+
+static int new_vendor(const char *name, u_int16_t vendorid)
+{
+       struct vendor *v;
+       unsigned int h = hashnum(vendorid);
+
+       v = vendors[h];
+       for (; v; v = v->next)
+               if (v->vendorid == vendorid)
+                       return -1;
+       v = my_malloc(sizeof(struct vendor) + strlen(name));
+       if (!v)
+               return -1;
+       strcpy(v->name, name);
+       v->vendorid = vendorid;
+       v->next = vendors[h];
+       vendors[h] = v;
+       return 0;
+}
+
+static int new_product(const char *name, u_int16_t vendorid, u_int16_t productid)
+{
+       struct product *p;
+       unsigned int h = hashnum((vendorid << 16) | productid);
+
+       p = products[h];
+       for (; p; p = p->next)
+               if (p->vendorid == vendorid && p->productid == productid)
+                       return -1;
+       p = my_malloc(sizeof(struct product) + strlen(name));
+       if (!p)
+               return -1;
+       strcpy(p->name, name);
+       p->vendorid = vendorid;
+       p->productid = productid;
+       p->next = products[h];
+       products[h] = p;
+       return 0;
+}
+
+static int new_class(const char *name, u_int8_t classid)
+{
+       struct class *c;
+       unsigned int h = hashnum(classid);
+
+       c = classes[h];
+       for (; c; c = c->next)
+               if (c->classid == classid)
+                       return -1;
+       c = my_malloc(sizeof(struct class) + strlen(name));
+       if (!c)
+               return -1;
+       strcpy(c->name, name);
+       c->classid = classid;
+       c->next = classes[h];
+       classes[h] = c;
+       return 0;
+}
+
+static int new_subclass(const char *name, u_int8_t classid, u_int8_t subclassid)
+{
+       struct subclass *s;
+       unsigned int h = hashnum((classid << 8) | subclassid);
+
+       s = subclasses[h];
+       for (; s; s = s->next)
+               if (s->classid == classid && s->subclassid == subclassid)
+                       return -1;
+       s = my_malloc(sizeof(struct subclass) + strlen(name));
+       if (!s)
+               return -1;
+       strcpy(s->name, name);
+       s->classid = classid;
+       s->subclassid = subclassid;
+       s->next = subclasses[h];
+       subclasses[h] = s;
+       return 0;
+}
+
+static int new_protocol(const char *name, u_int8_t classid, u_int8_t subclassid, u_int8_t protocolid)
+{
+       struct protocol *p;
+       unsigned int h = hashnum((classid << 16) | (subclassid << 8) | protocolid);
+
+       p = protocols[h];
+       for (; p; p = p->next)
+               if (p->classid == classid && p->subclassid == subclassid && p->protocolid == protocolid)
+                       return -1;
+       p = my_malloc(sizeof(struct protocol) + strlen(name));
+       if (!p)
+               return -1;
+       strcpy(p->name, name);
+       p->classid = classid;
+       p->subclassid = subclassid;
+       p->protocolid = protocolid;
+       p->next = protocols[h];
+       protocols[h] = p;
+       return 0;
+}
+
+static int new_audioterminal(const char *name, u_int16_t termt)
+{
+       struct audioterminal *at;
+       unsigned int h = hashnum(termt);
+
+       at = audioterminals[h];
+       for (; at; at = at->next)
+               if (at->termt == termt)
+                       return -1;
+       at = my_malloc(sizeof(struct audioterminal) + strlen(name));
+       if (!at)
+               return -1;
+       strcpy(at->name, name);
+       at->termt = termt;
+       at->next = audioterminals[h];
+       audioterminals[h] = at;
+       return 0;
+}
+
+static int new_genericstrtable(struct genericstrtable *t[HASHSZ], const char *name, unsigned int index)
+{
+        struct genericstrtable *g;
+       unsigned int h = hashnum(index);
+
+        for (g = t[h]; g; g = g->next)
+                if (g->num == index)
+                        return -1;
+        g = my_malloc(sizeof(struct genericstrtable) + strlen(name));
+        if (!g)
+                return -1;
+        strcpy(g->name, name);
+        g->num = index;
+        g->next = t[h];
+        t[h] = g;
+        return 0;
+}
+
+static int new_hid(const char *name, u_int8_t hidd)
+{
+       return new_genericstrtable(hiddescriptors, name, hidd);
+}
+
+static int new_reporttag(const char *name, u_int8_t rt)
+{
+       return new_genericstrtable(reports, name, rt);
+}
+
+static int new_huts(const char *name, unsigned int data)
+{
+       return new_genericstrtable(huts, name, data);
+}
+
+static int new_hutus(const char *name, unsigned int data)
+{
+       return new_genericstrtable(hutus, name, data);
+}
+
+static int new_langid(const char *name, u_int16_t langid)
+{
+       return new_genericstrtable(langids, name, langid);
+}
+
+static int new_physdes(const char *name, u_int8_t ph)
+{
+       return new_genericstrtable(physdess, name, ph);
+}
+static int new_bias(const char *name, u_int8_t b)
+{
+       return new_genericstrtable(biass, name, b);
+}
+
+static int new_countrycode(const char *name, unsigned int countrycode)
+{
+       return new_genericstrtable(countrycodes, name, countrycode);
+}
+
+/* ---------------------------------------------------------------------- */
+
+#define DBG(x)
+
+static void parse(FILE *f)
+{
+       char buf[512], *cp;
+       unsigned int linectr = 0;
+       int lastvendor = -1, lastclass = -1, lastsubclass = -1, lasthut=-1, lastlang=-1;
+       unsigned int u;
+
+       while (fgets(buf, sizeof(buf), f)) {
+               linectr++;
+               /* remove line ends */
+               if ((cp = strchr(buf, 13)))
+                       *cp = 0;
+               if ((cp = strchr(buf, 10)))
+                       *cp = 0;
+               if (buf[0] == '#' || !buf[0])
+                       continue;
+               cp = buf;
+                if (buf[0] == 'P' && buf[1] == 'H' && buf[2] == 'Y' && buf[3] == 'S' && buf[4] == 'D' &&
+                    buf[5] == 'E' && buf[6] == 'S' && /*isspace(buf[7])*/ buf[7] == ' ') {
+                        cp = buf + 8;
+                        while (isspace(*cp))
+                                cp++;
+                        if (!isxdigit(*cp)) {
+                                fprintf(stderr, "Invalid Physdes type at line %u\n", linectr);
+                                continue;
+                        }
+                        u = strtoul(cp, &cp, 16);
+                        while (isspace(*cp))
+                                cp++;
+                        if (!*cp) {
+                                fprintf(stderr, "Invalid Physdes type at line %u\n", linectr);
+                                continue;
+                        }
+                        if (new_physdes(cp, u))
+                                fprintf(stderr, "Duplicate Physdes  type spec at line %u terminal type %04x %s\n", linectr, u, cp);
+                        DBG(printf("line %5u physdes type %02x %s\n", linectr, u, cp));
+                        continue;
+
+                }
+                if (buf[0] == 'P' && buf[1] == 'H' && buf[2] == 'Y' && /*isspace(buf[3])*/ buf[3] == ' ') {
+                        cp = buf + 4;
+                        while (isspace(*cp))
+                                cp++;
+                        if (!isxdigit(*cp)) {
+                                fprintf(stderr, "Invalid PHY type at line %u\n", linectr);
+                                continue;
+                        }
+                        u = strtoul(cp, &cp, 16);
+                        while (isspace(*cp))
+                                cp++;
+                        if (!*cp) {
+                                fprintf(stderr, "Invalid PHY type at line %u\n", linectr);
+                                continue;
+                        }
+                        if (new_physdes(cp, u))
+                                fprintf(stderr, "Duplicate PHY type spec at line %u terminal type %04x %s\n", linectr, u, cp);
+                        DBG(printf("line %5u PHY type %02x %s\n", linectr, u, cp));
+                        continue;
+
+                }
+                if (buf[0] == 'B' && buf[1] == 'I' && buf[2] == 'A' && buf[3] == 'S' && /*isspace(buf[4])*/ buf[4] == ' ') {
+                        cp = buf + 5;
+                        while (isspace(*cp))
+                                cp++;
+                        if (!isxdigit(*cp)) {
+                                fprintf(stderr, "Invalid BIAS type at line %u\n", linectr);
+                                continue;
+                        }
+                        u = strtoul(cp, &cp, 16);
+                        while (isspace(*cp))
+                                cp++;
+                        if (!*cp) {
+                                fprintf(stderr, "Invalid BIAS type at line %u\n", linectr);
+                                continue;
+                        }
+                        if (new_bias(cp, u))
+                                fprintf(stderr, "Duplicate BIAS  type spec at line %u terminal type %04x %s\n", linectr, u, cp);
+                        DBG(printf("line %5u BIAS type %02x %s\n", linectr, u, cp));
+                        continue;
+
+                }
+                if (buf[0] == 'L' && /*isspace(buf[1])*/ buf[1] == ' ') {
+                        cp =  buf+2;
+                        while (isspace(*cp))
+                                cp++;
+                        if (!isxdigit(*cp)) {
+                                fprintf(stderr, "Invalid LANGID spec at line %u\n", linectr);
+                                continue;
+                        }
+                        u = strtoul(cp, &cp, 16);
+                        while (isspace(*cp))
+                                cp++;
+                        if (!*cp) {
+                                fprintf(stderr, "Invalid LANGID spec at line %u\n", linectr);
+                                continue;
+                        }
+                        if (new_langid(cp, u))
+                                fprintf(stderr, "Duplicate LANGID spec at line %u language-id %04x %s\n", linectr, u, cp);
+                        DBG(printf("line %5u LANGID %02x %s\n", linectr, u, cp));
+                        lasthut = lastclass = lastvendor = lastsubclass = -1;
+                        lastlang = u;
+                        continue;
+                }
+               if (buf[0] == 'C' && /*isspace(buf[1])*/ buf[1] == ' ') {
+                       /* class spec */
+                       cp = buf+2;
+                       while (isspace(*cp))
+                               cp++;
+                       if (!isxdigit(*cp)) {
+                               fprintf(stderr, "Invalid class spec at line %u\n", linectr);
+                               continue;
+                       }
+                       u = strtoul(cp, &cp, 16);
+                       while (isspace(*cp))
+                               cp++;
+                       if (!*cp) {
+                               fprintf(stderr, "Invalid class spec at line %u\n", linectr);
+                               continue;
+                       }
+                       if (new_class(cp, u))
+                               fprintf(stderr, "Duplicate class spec at line %u class %04x %s\n", linectr, u, cp);
+                       DBG(printf("line %5u class %02x %s\n", linectr, u, cp));
+                       lasthut = lastlang = lastvendor = lastsubclass = -1;
+                       lastclass = u;
+                       continue;
+               }
+               if (buf[0] == 'A' && buf[1] == 'T' && isspace(buf[2])) {
+                       /* audio terminal type spec */
+                       cp = buf+3;
+                       while (isspace(*cp))
+                               cp++;
+                       if (!isxdigit(*cp)) {
+                               fprintf(stderr, "Invalid audio terminal type at line %u\n", linectr);
+                               continue;
+                       }
+                       u = strtoul(cp, &cp, 16);
+                       while (isspace(*cp))
+                               cp++;
+                       if (!*cp) {
+                               fprintf(stderr, "Invalid audio terminal type at line %u\n", linectr);
+                               continue;
+                       }
+                       if (new_audioterminal(cp, u))
+                               fprintf(stderr, "Duplicate audio terminal type spec at line %u terminal type %04x %s\n", linectr, u, cp);
+                       DBG(printf("line %5u audio terminal type %02x %s\n", linectr, u, cp));
+                       continue;
+               }
+               if (buf[0] == 'H' && buf[1] == 'C' && buf[2] == 'C' && isspace(buf[3])) {
+                       /* HID Descriptor bCountryCode */
+                        cp =  buf+3;
+                        while (isspace(*cp))
+                                cp++;
+                        if (!isxdigit(*cp)) {
+                                fprintf(stderr, "Invalid HID country code at line %u\n", linectr);
+                                continue;
+                        }
+                        u = strtoul(cp, &cp, 10);
+                        while (isspace(*cp))
+                                cp++;
+                        if (!*cp) {
+                                fprintf(stderr, "Invalid HID country code at line %u\n", linectr);
+                                continue;
+                        }
+                        if (new_countrycode(cp, u))
+                                fprintf(stderr, "Duplicate HID country code at line %u country %02u %s\n", linectr, u, cp);
+                        DBG(printf("line %5u keyboard country code %02u %s\n", linectr, u, cp));
+                        continue;
+               }
+               if (isxdigit(*cp)) {
+                       /* vendor */
+                       u = strtoul(cp, &cp, 16);
+                       while (isspace(*cp))
+                               cp++;
+                       if (!*cp) {
+                               fprintf(stderr, "Invalid vendor spec at line %u\n", linectr);
+                               continue;
+                       }
+                       if (new_vendor(cp, u))
+                               fprintf(stderr, "Duplicate vendor spec at line %u vendor %04x %s\n", linectr, u, cp);
+                       DBG(printf("line %5u vendor %04x %s\n", linectr, u, cp));
+                       lastvendor = u;
+                       lasthut = lastlang = lastclass = lastsubclass = -1;
+                       continue;
+               }
+               if (buf[0] == '\t' && isxdigit(buf[1])) {
+                       /* product or subclass spec */
+                       u = strtoul(buf+1, &cp, 16);
+                       while (isspace(*cp))
+                               cp++;
+                       if (!*cp) {
+                               fprintf(stderr, "Invalid product/subclass spec at line %u\n", linectr);
+                               continue;
+                       }
+                       if (lastvendor != -1) {
+                               if (new_product(cp, lastvendor, u))
+                                       fprintf(stderr, "Duplicate product spec at line %u product %04x:%04x %s\n", linectr, lastvendor, u, cp);
+                               DBG(printf("line %5u product %04x:%04x %s\n", linectr, lastvendor, u, cp));
+                               continue;
+                       }
+                       if (lastclass != -1) {
+                               if (new_subclass(cp, lastclass, u))
+                                       fprintf(stderr, "Duplicate subclass spec at line %u class %02x:%02x %s\n", linectr, lastclass, u, cp);
+                               DBG(printf("line %5u subclass %02x:%02x %s\n", linectr, lastclass, u, cp));
+                               lastsubclass = u;
+                               continue;
+                       }
+                       if (lasthut != -1) {
+                               if (new_hutus(cp, (lasthut << 16)+u))
+                                       fprintf(stderr, "Duplicate HUT Usage Spec at line %u\n", linectr);
+                               continue;
+                       }
+                       if (lastlang != -1) {
+                                if (new_langid(cp, lastlang+(u<<10)))
+                                        fprintf(stderr, "Duplicate LANGID Usage Spec at line %u\n", linectr);
+                                continue;
+                        }
+                       fprintf(stderr, "Product/Subclass spec without prior Vendor/Class spec at line %u\n", linectr);
+                       continue;
+               }
+               if (buf[0] == '\t' && buf[1] == '\t' && isxdigit(buf[2])) {
+                       /* protocol spec */
+                       u = strtoul(buf+2, &cp, 16);
+                       while (isspace(*cp))
+                               cp++;
+                       if (!*cp) {
+                               fprintf(stderr, "Invalid protocol spec at line %u\n", linectr);
+                               continue;
+                       }
+                       if (lastclass != -1 && lastsubclass != -1) {
+                               if (new_protocol(cp, lastclass, lastsubclass, u))
+                                       fprintf(stderr, "Duplicate protocol spec at line %u class %02x:%02x:%02x %s\n", linectr, lastclass, lastsubclass, u, cp);
+                               DBG(printf("line %5u protocol %02x:%02x:%02x %s\n", linectr, lastclass, lastsubclass, u, cp));
+                               continue;
+                       }
+                       fprintf(stderr, "Protocol spec without prior Class and Subclass spec at line %u\n", linectr);
+                       continue;
+               }
+               if (buf[0] == 'H' && buf[1] == 'I' && buf[2] == 'D' && /*isspace(buf[3])*/ buf[3] == ' ') {
+                       cp = buf + 4;
+                        while (isspace(*cp))
+                                cp++;
+                        if (!isxdigit(*cp)) {
+                                fprintf(stderr, "Invalid HID type at line %u\n", linectr);
+                                continue;
+                        }
+                        u = strtoul(cp, &cp, 16);
+                        while (isspace(*cp))
+                                cp++;
+                        if (!*cp) {
+                                fprintf(stderr, "Invalid HID type at line %u\n", linectr);
+                                continue;
+                        }
+                        if (new_hid(cp, u))
+                                fprintf(stderr, "Duplicate HID type spec at line %u terminal type %04x %s\n", linectr, u, cp);
+                        DBG(printf("line %5u HID type %02x %s\n", linectr, u, cp));
+                        continue;
+
+               }
+                if (buf[0] == 'H' && buf[1] == 'U' && buf[2] == 'T' && /*isspace(buf[3])*/ buf[3] == ' ') {
+                        cp = buf + 4;
+                        while (isspace(*cp))
+                                cp++;
+                        if (!isxdigit(*cp)) {
+                                fprintf(stderr, "Invalid HUT type at line %u\n", linectr);
+                                continue;
+                        }
+                        u = strtoul(cp, &cp, 16);
+                        while (isspace(*cp))
+                                cp++;
+                        if (!*cp) {
+                                fprintf(stderr, "Invalid HUT type at line %u\n", linectr);
+                                continue;
+                        }
+                        if (new_huts(cp, u))
+                                fprintf(stderr, "Duplicate HUT type spec at line %u terminal type %04x %s\n", linectr, u, cp);
+                       lastlang = lastclass = lastvendor = lastsubclass = -1;
+                       lasthut = u;
+                        DBG(printf("line %5u HUT type %02x %s\n", linectr, u, cp));
+                        continue;
+
+                }
+                if (buf[0] == 'R' && buf[1] == ' ') {
+                        cp = buf + 2;
+                        while (isspace(*cp))
+                                cp++;
+                        if (!isxdigit(*cp)) {
+                                fprintf(stderr, "Invalid Report type at line %u\n", linectr);
+                                continue;
+                        }
+                        u = strtoul(cp, &cp, 16);
+                        while (isspace(*cp))
+                                cp++;
+                        if (!*cp) {
+                                fprintf(stderr, "Invalid Report type at line %u\n", linectr);
+                                continue;
+                        }
+                        if (new_reporttag(cp, u))
+                                fprintf(stderr, "Duplicate Report type spec at line %u terminal type %04x %s\n", linectr, u, cp);
+                        DBG(printf("line %5u Report type %02x %s\n", linectr, u, cp));
+                        continue;
+
+                }
+                if (buf[0] == 'V' && buf[1] == 'T') {
+                       /* add here */
+                       continue;
+               }
+               fprintf(stderr, "Unknown line at line %u\n", linectr);
+       }
+}
+
+/* ---------------------------------------------------------------------- */
+
+int names_init(char *n)
+{
+       FILE *f;
+
+       if (!(f = fopen(n, "r"))) {
+               return errno;
+       }
+       parse(f);
+       fclose(f);
+       return 0;
+}
diff --git a/drivers/staging/usbip/userspace/libsrc/names.h b/drivers/staging/usbip/userspace/libsrc/names.h
new file mode 100644 (file)
index 0000000..3a269fe
--- /dev/null
@@ -0,0 +1,57 @@
+/*****************************************************************************/
+
+/*
+ *      names.h  --  USB name database manipulation routines
+ *
+ *      Copyright (C) 1999, 2000  Thomas Sailer (sailer@ife.ee.ethz.ch)
+ *
+ *      This program is free software; you can redistribute it and/or modify
+ *      it under the terms of the GNU General Public License as published by
+ *      the Free Software Foundation; either version 2 of the License, or
+ *      (at your option) any later version.
+ *
+ *      This program is distributed in the hope that it will be useful,
+ *      but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *      GNU General Public License for more details.
+ *
+ *      You should have received a copy of the GNU General Public License
+ *      along with this program; if not, write to the Free Software
+ *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ *
+ */
+
+/*
+ *     Copyright (C) 2005 Takahiro Hirofuchi
+ *            - names_free() is added.
+ */
+
+/*****************************************************************************/
+
+#ifndef _NAMES_H
+#define _NAMES_H
+
+#include <sys/types.h>
+
+/* ---------------------------------------------------------------------- */
+
+extern const char *names_vendor(u_int16_t vendorid);
+extern const char *names_product(u_int16_t vendorid, u_int16_t productid);
+extern const char *names_class(u_int8_t classid);
+extern const char *names_subclass(u_int8_t classid, u_int8_t subclassid);
+extern const char *names_protocol(u_int8_t classid, u_int8_t subclassid, u_int8_t protocolid);
+extern const char *names_audioterminal(u_int16_t termt);
+extern const char *names_hid(u_int8_t hidd);
+extern const char *names_reporttag(u_int8_t rt);
+extern const char *names_huts(unsigned int data);
+extern const char *names_hutus(unsigned int data);
+extern const char *names_langid(u_int16_t langid);
+extern const char *names_physdes(u_int8_t ph);
+extern const char *names_bias(u_int8_t b);
+extern const char *names_countrycode(unsigned int countrycode);
+extern int  names_init(char *n);
+extern void names_free(void);
+
+/* ---------------------------------------------------------------------- */
+#endif /* _NAMES_H */
diff --git a/drivers/staging/usbip/userspace/libsrc/stub_driver.c b/drivers/staging/usbip/userspace/libsrc/stub_driver.c
new file mode 100644 (file)
index 0000000..cc33643
--- /dev/null
@@ -0,0 +1,391 @@
+/*
+ * Copyright (C) 2005-2007 Takahiro Hirofuchi
+ */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+#include "usbip.h"
+
+/* kernel module name */
+static const char *usbip_stub_driver_name = "usbip-host";
+
+
+struct usbip_stub_driver *stub_driver;
+
+static struct sysfs_driver *open_sysfs_stub_driver(void)
+{
+       int ret;
+
+       char sysfs_mntpath[SYSFS_PATH_MAX];
+       char stub_driver_path[SYSFS_PATH_MAX];
+       struct sysfs_driver *stub_driver;
+
+
+       ret = sysfs_get_mnt_path(sysfs_mntpath, SYSFS_PATH_MAX);
+       if (ret < 0) {
+               err("sysfs must be mounted");
+               return NULL;
+       }
+
+       snprintf(stub_driver_path, SYSFS_PATH_MAX, "%s/%s/usb/%s/%s",
+                       sysfs_mntpath, SYSFS_BUS_NAME, SYSFS_DRIVERS_NAME,
+                       usbip_stub_driver_name);
+
+       stub_driver = sysfs_open_driver_path(stub_driver_path);
+       if (!stub_driver) {
+               err("usbip-core.ko and usbip-host.ko must be loaded");
+               return NULL;
+       }
+
+       return stub_driver;
+}
+
+
+#define SYSFS_OPEN_RETRIES 100
+
+/* only the first interface value is true! */
+static int32_t read_attr_usbip_status(struct usb_device *udev)
+{
+       char attrpath[SYSFS_PATH_MAX];
+       struct sysfs_attribute *attr;
+       int value = 0;
+       int  ret;
+       struct stat s;
+       int retries = SYSFS_OPEN_RETRIES;
+
+       /* This access is racy!
+        *
+        * Just after detach, our driver removes the sysfs
+        * files and recreates them.
+        *
+        * We may try and fail to open the usbip_status of
+        * an exported device in the (short) window where
+        * it has been removed and not yet recreated.
+        *
+        * This is a bug in the interface. Nothing we can do
+        * except work around it here by polling for the sysfs
+        * usbip_status to reappear.
+        */
+
+       snprintf(attrpath, SYSFS_PATH_MAX, "%s/%s:%d.%d/usbip_status",
+                       udev->path, udev->busid,
+                       udev->bConfigurationValue,
+                       0);
+
+       while (retries > 0) {
+               if (stat(attrpath, &s) == 0)
+                       break;
+
+               if (errno != ENOENT) {
+                       err("error stat'ing %s", attrpath);
+                       return -1;
+               }
+
+               usleep(10000); /* 10ms */
+               retries--;
+       }
+
+       if (retries == 0)
+               err("usbip_status not ready after %d retries",
+                       SYSFS_OPEN_RETRIES);
+       else if (retries < SYSFS_OPEN_RETRIES)
+               info("warning: usbip_status ready after %d retries",
+                        SYSFS_OPEN_RETRIES - retries);
+
+       attr = sysfs_open_attribute(attrpath);
+       if (!attr) {
+               err("open %s", attrpath);
+               return -1;
+       }
+
+       ret = sysfs_read_attribute(attr);
+       if (ret) {
+               err("read %s", attrpath);
+               sysfs_close_attribute(attr);
+               return -1;
+       }
+
+       value = atoi(attr->value);
+
+       sysfs_close_attribute(attr);
+
+       return value;
+}
+
+
+static void usbip_exported_device_delete(void *dev)
+{
+       struct usbip_exported_device *edev =
+               (struct usbip_exported_device *) dev;
+
+       sysfs_close_device(edev->sudev);
+       free(dev);
+}
+
+
+static struct usbip_exported_device *usbip_exported_device_new(char *sdevpath)
+{
+       struct usbip_exported_device *edev = NULL;
+
+       edev = (struct usbip_exported_device *) calloc(1, sizeof(*edev));
+       if (!edev) {
+               err("alloc device");
+               return NULL;
+       }
+
+       edev->sudev = sysfs_open_device_path(sdevpath);
+       if (!edev->sudev) {
+               err("open %s", sdevpath);
+               goto err;
+       }
+
+       read_usb_device(edev->sudev, &edev->udev);
+
+       edev->status = read_attr_usbip_status(&edev->udev);
+       if (edev->status < 0)
+               goto err;
+
+       /* reallocate buffer to include usb interface data */
+       size_t size = sizeof(*edev) + edev->udev.bNumInterfaces * sizeof(struct usb_interface);
+       edev = (struct usbip_exported_device *) realloc(edev, size);
+       if (!edev) {
+               err("alloc device");
+               goto err;
+       }
+
+       for (int i=0; i < edev->udev.bNumInterfaces; i++)
+               read_usb_interface(&edev->udev, i, &edev->uinf[i]);
+
+       return edev;
+
+err:
+       if (edev && edev->sudev)
+               sysfs_close_device(edev->sudev);
+       if (edev)
+               free(edev);
+       return NULL;
+}
+
+
+static int check_new(struct dlist *dlist, struct sysfs_device *target)
+{
+       struct sysfs_device *dev;
+
+       dlist_for_each_data(dlist, dev, struct sysfs_device) {
+               if (!strncmp(dev->bus_id, target->bus_id, SYSFS_BUS_ID_SIZE))
+                       /* found. not new */
+                       return 0;
+       }
+
+       return 1;
+}
+
+static void delete_nothing(void *dev __attribute__((unused)))
+{
+       /* do not delete anything. but, its container will be deleted. */
+}
+
+static int refresh_exported_devices(void)
+{
+       struct sysfs_device     *suinf;  /* sysfs_device of usb_interface */
+       struct dlist            *suinf_list;
+
+       struct sysfs_device     *sudev;  /* sysfs_device of usb_device */
+       struct dlist            *sudev_list;
+
+
+       sudev_list = dlist_new_with_delete(sizeof(struct sysfs_device), delete_nothing);
+
+       suinf_list = sysfs_get_driver_devices(stub_driver->sysfs_driver);
+       if (!suinf_list) {
+               printf("Bind usbip-host.ko to a usb device to be exportable!\n");
+               goto bye;
+       }
+
+       /* collect unique USB devices (not interfaces) */
+       dlist_for_each_data(suinf_list, suinf, struct sysfs_device) {
+
+               /* get usb device of this usb interface */
+               sudev = sysfs_get_device_parent(suinf);
+               if (!sudev) {
+                       err("get parent dev of %s", suinf->name);
+                       continue;
+               }
+
+               if (check_new(sudev_list, sudev)) {
+                       dlist_unshift(sudev_list, sudev);
+               }
+       }
+
+       dlist_for_each_data(sudev_list, sudev, struct sysfs_device) {
+               struct usbip_exported_device *edev;
+
+               edev = usbip_exported_device_new(sudev->path);
+               if (!edev) {
+                       err("usbip_exported_device new");
+                       continue;
+               }
+
+               dlist_unshift(stub_driver->edev_list, (void *) edev);
+               stub_driver->ndevs++;
+       }
+
+
+       dlist_destroy(sudev_list);
+
+bye:
+
+       return 0;
+}
+
+int usbip_stub_refresh_device_list(void)
+{
+       int ret;
+
+       if (stub_driver->edev_list)
+               dlist_destroy(stub_driver->edev_list);
+
+       stub_driver->ndevs = 0;
+
+       stub_driver->edev_list = dlist_new_with_delete(sizeof(struct usbip_exported_device),
+                       usbip_exported_device_delete);
+       if (!stub_driver->edev_list) {
+               err("alloc dlist");
+               return -1;
+       }
+
+       ret = refresh_exported_devices();
+       if (ret < 0)
+               return ret;
+
+       return 0;
+}
+
+int usbip_stub_driver_open(void)
+{
+       int ret;
+
+
+       stub_driver = (struct usbip_stub_driver *) calloc(1, sizeof(*stub_driver));
+       if (!stub_driver) {
+               err("alloc stub_driver");
+               return -1;
+       }
+
+       stub_driver->ndevs = 0;
+
+       stub_driver->edev_list = dlist_new_with_delete(sizeof(struct usbip_exported_device),
+                       usbip_exported_device_delete);
+       if (!stub_driver->edev_list) {
+               err("alloc dlist");
+               goto err;
+       }
+
+       stub_driver->sysfs_driver = open_sysfs_stub_driver();
+       if (!stub_driver->sysfs_driver)
+               goto err;
+
+       ret = refresh_exported_devices();
+       if (ret < 0)
+               goto err;
+
+       return 0;
+
+
+err:
+       if (stub_driver->sysfs_driver)
+               sysfs_close_driver(stub_driver->sysfs_driver);
+       if (stub_driver->edev_list)
+               dlist_destroy(stub_driver->edev_list);
+       free(stub_driver);
+
+       stub_driver = NULL;
+       return -1;
+}
+
+
+void usbip_stub_driver_close(void)
+{
+       if (!stub_driver)
+               return;
+
+       if (stub_driver->edev_list)
+               dlist_destroy(stub_driver->edev_list);
+       if (stub_driver->sysfs_driver)
+               sysfs_close_driver(stub_driver->sysfs_driver);
+       free(stub_driver);
+
+       stub_driver = NULL;
+}
+
+int usbip_stub_export_device(struct usbip_exported_device *edev, int sockfd)
+{
+       char attrpath[SYSFS_PATH_MAX];
+       struct sysfs_attribute *attr;
+       char sockfd_buff[30];
+       int ret;
+
+
+       if (edev->status != SDEV_ST_AVAILABLE) {
+               info("device not available, %s", edev->udev.busid);
+               switch( edev->status ) {
+                       case SDEV_ST_ERROR:
+                               info("     status SDEV_ST_ERROR");
+                               break;
+                       case SDEV_ST_USED:
+                               info("     status SDEV_ST_USED");
+                               break;
+                       default:
+                               info("     status unknown: 0x%x", edev->status);
+               }
+               return -1;
+       }
+
+       /* only the first interface is true */
+       snprintf(attrpath, sizeof(attrpath), "%s/%s:%d.%d/%s",
+                       edev->udev.path,
+                       edev->udev.busid,
+                       edev->udev.bConfigurationValue, 0,
+                       "usbip_sockfd");
+
+       attr = sysfs_open_attribute(attrpath);
+       if (!attr) {
+               err("open %s", attrpath);
+               return -1;
+       }
+
+       snprintf(sockfd_buff, sizeof(sockfd_buff), "%d\n", sockfd);
+
+       dbg("write: %s", sockfd_buff);
+
+       ret = sysfs_write_attribute(attr, sockfd_buff, strlen(sockfd_buff));
+       if (ret < 0) {
+               err("write sockfd %s to %s", sockfd_buff, attrpath);
+               goto err_write_sockfd;
+       }
+
+       info("connect %s", edev->udev.busid);
+
+err_write_sockfd:
+       sysfs_close_attribute(attr);
+
+       return ret;
+}
+
+struct usbip_exported_device *usbip_stub_get_device(int num)
+{
+       struct usbip_exported_device *edev;
+       struct dlist            *dlist = stub_driver->edev_list;
+       int count = 0;
+
+       dlist_for_each_data(dlist, edev, struct usbip_exported_device) {
+               if (num == count)
+                       return edev;
+               else
+                       count++ ;
+       }
+
+       return NULL;
+}
diff --git a/drivers/staging/usbip/userspace/libsrc/stub_driver.h b/drivers/staging/usbip/userspace/libsrc/stub_driver.h
new file mode 100644 (file)
index 0000000..3107d18
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2005-2007 Takahiro Hirofuchi
+ */
+
+#ifndef _USBIP_STUB_DRIVER_H
+#define _USBIP_STUB_DRIVER_H
+
+#include "usbip.h"
+
+
+struct usbip_stub_driver {
+       int ndevs;
+       struct sysfs_driver *sysfs_driver;
+
+       struct dlist *edev_list;        /* list of exported device */
+};
+
+struct usbip_exported_device {
+       struct sysfs_device *sudev;
+
+       int32_t status;
+       struct usb_device    udev;
+       struct usb_interface uinf[];
+};
+
+
+extern struct usbip_stub_driver *stub_driver;
+
+int usbip_stub_driver_open(void);
+void usbip_stub_driver_close(void);
+
+int usbip_stub_refresh_device_list(void);
+int usbip_stub_export_device(struct usbip_exported_device *edev, int sockfd);
+
+struct usbip_exported_device *usbip_stub_get_device(int num);
+#endif
diff --git a/drivers/staging/usbip/userspace/libsrc/usbip.h b/drivers/staging/usbip/userspace/libsrc/usbip.h
new file mode 100644 (file)
index 0000000..7cb8e6f
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2005-2007 Takahiro Hirofuchi
+ */
+
+#ifndef _USBIP_H
+#define _USBIP_H
+
+#ifdef HAVE_CONFIG_H
+#include "../config.h"
+#endif
+
+#include "usbip_common.h"
+#include "stub_driver.h"
+#include "vhci_driver.h"
+#ifdef DMALLOC
+#include <dmalloc.h>
+#endif
+
+#endif
diff --git a/drivers/staging/usbip/userspace/libsrc/usbip_common.c b/drivers/staging/usbip/userspace/libsrc/usbip_common.c
new file mode 100644 (file)
index 0000000..a128a92
--- /dev/null
@@ -0,0 +1,282 @@
+/*
+ * Copyright (C) 2005-2007 Takahiro Hirofuchi
+ */
+
+#include "usbip.h"
+#include "names.h"
+
+int usbip_use_syslog = 0;
+int usbip_use_stderr = 0;
+int usbip_use_debug  = 0;
+
+struct speed_string {
+       int num;
+       char *speed;
+       char *desc;
+};
+
+static const struct speed_string speed_strings[] = {
+       { USB_SPEED_UNKNOWN, "unknown", "Unknown Speed"},
+       { USB_SPEED_LOW,  "1.5", "Low Speed(1.5Mbps)"  },
+       { USB_SPEED_FULL, "12",  "Full Speed(12Mbps)" },
+       { USB_SPEED_HIGH, "480", "High Speed(480Mbps)" },
+       { 0, NULL, NULL }
+};
+
+struct portst_string {
+       int num;
+       char *desc;
+};
+
+static struct portst_string portst_strings[] = {
+       { SDEV_ST_AVAILABLE,    "Device Available" },
+       { SDEV_ST_USED,         "Device in Use" },
+       { SDEV_ST_ERROR,        "Device Error"},
+       { VDEV_ST_NULL,         "Port Available"},
+       { VDEV_ST_NOTASSIGNED,  "Port Initializing"},
+       { VDEV_ST_USED,         "Port in Use"},
+       { VDEV_ST_ERROR,        "Port Error"},
+       { 0, NULL}
+};
+
+const char *usbip_status_string(int32_t status)
+{
+       for (int i=0; portst_strings[i].desc != NULL; i++)
+               if (portst_strings[i].num == status)
+                       return portst_strings[i].desc;
+
+       return "Unknown Status";
+}
+
+const char *usbip_speed_string(int num)
+{
+       for (int i=0; speed_strings[i].speed != NULL; i++)
+               if (speed_strings[i].num == num)
+                       return speed_strings[i].desc;
+
+       return "Unknown Speed";
+}
+
+
+#define DBG_UDEV_INTEGER(name)\
+       dbg("%-20s = %x", to_string(name), (int) udev->name)
+
+#define DBG_UINF_INTEGER(name)\
+       dbg("%-20s = %x", to_string(name), (int) uinf->name)
+
+void dump_usb_interface(struct usb_interface *uinf)
+{
+       char buff[100];
+       usbip_names_get_class(buff, sizeof(buff),
+                       uinf->bInterfaceClass,
+                       uinf->bInterfaceSubClass,
+                       uinf->bInterfaceProtocol);
+       dbg("%-20s = %s", "Interface(C/SC/P)", buff);
+}
+
+void dump_usb_device(struct usb_device *udev)
+{
+       char buff[100];
+
+
+       dbg("%-20s = %s", "path",  udev->path);
+       dbg("%-20s = %s", "busid", udev->busid);
+
+       usbip_names_get_class(buff, sizeof(buff),
+                       udev->bDeviceClass,
+                       udev->bDeviceSubClass,
+                       udev->bDeviceProtocol);
+       dbg("%-20s = %s", "Device(C/SC/P)", buff);
+
+       DBG_UDEV_INTEGER(bcdDevice);
+
+       usbip_names_get_product(buff, sizeof(buff),
+                       udev->idVendor,
+                       udev->idProduct);
+       dbg("%-20s = %s", "Vendor/Product", buff);
+
+       DBG_UDEV_INTEGER(bNumConfigurations);
+       DBG_UDEV_INTEGER(bNumInterfaces);
+
+       dbg("%-20s = %s", "speed",
+                       usbip_speed_string(udev->speed));
+
+       DBG_UDEV_INTEGER(busnum);
+       DBG_UDEV_INTEGER(devnum);
+}
+
+
+int read_attr_value(struct sysfs_device *dev, const char *name, const char *format)
+{
+       char attrpath[SYSFS_PATH_MAX];
+       struct sysfs_attribute *attr;
+       int num = 0;
+       int ret;
+
+       snprintf(attrpath, sizeof(attrpath), "%s/%s", dev->path, name);
+
+       attr = sysfs_open_attribute(attrpath);
+       if (!attr) {
+               err("open attr %s", attrpath);
+               return 0;
+       }
+
+       ret = sysfs_read_attribute(attr);
+       if (ret < 0) {
+               err("read attr");
+               goto err;
+       }
+
+       ret = sscanf(attr->value, format, &num);
+       if (ret < 1) {
+               err("sscanf");
+               goto err;
+       }
+
+err:
+       sysfs_close_attribute(attr);
+
+       return num;
+}
+
+
+int read_attr_speed(struct sysfs_device *dev)
+{
+       char attrpath[SYSFS_PATH_MAX];
+       struct sysfs_attribute *attr;
+       char speed[100];
+       int ret;
+
+       snprintf(attrpath, sizeof(attrpath), "%s/%s", dev->path, "speed");
+
+       attr = sysfs_open_attribute(attrpath);
+       if (!attr) {
+               err("open attr");
+               return 0;
+       }
+
+       ret = sysfs_read_attribute(attr);
+       if (ret < 0) {
+               err("read attr");
+               goto err;
+       }
+
+       ret = sscanf(attr->value, "%s\n", speed);
+       if (ret < 1) {
+               err("sscanf");
+               goto err;
+       }
+err:
+       sysfs_close_attribute(attr);
+
+       for (int i=0; speed_strings[i].speed != NULL; i++) {
+               if (!strcmp(speed, speed_strings[i].speed))
+                       return speed_strings[i].num;
+       }
+
+       return USB_SPEED_UNKNOWN;
+}
+
+#define READ_ATTR(object, type, dev, name, format)\
+       do { (object)->name = (type) read_attr_value(dev, to_string(name), format); } while (0)
+
+
+int read_usb_device(struct sysfs_device *sdev, struct usb_device *udev)
+{
+       uint32_t busnum, devnum;
+
+       READ_ATTR(udev, uint8_t,  sdev, bDeviceClass,           "%02x\n");
+       READ_ATTR(udev, uint8_t,  sdev, bDeviceSubClass,        "%02x\n");
+       READ_ATTR(udev, uint8_t,  sdev, bDeviceProtocol,        "%02x\n");
+
+       READ_ATTR(udev, uint16_t, sdev, idVendor,               "%04x\n");
+       READ_ATTR(udev, uint16_t, sdev, idProduct,              "%04x\n");
+       READ_ATTR(udev, uint16_t, sdev, bcdDevice,              "%04x\n");
+
+       READ_ATTR(udev, uint8_t,  sdev, bConfigurationValue,    "%02x\n");
+       READ_ATTR(udev, uint8_t,  sdev, bNumConfigurations,     "%02x\n");
+       READ_ATTR(udev, uint8_t,  sdev, bNumInterfaces,         "%02x\n");
+
+       READ_ATTR(udev, uint8_t,  sdev, devnum,                 "%d\n");
+       udev->speed = read_attr_speed(sdev);
+
+       strncpy(udev->path,  sdev->path,  SYSFS_PATH_MAX);
+       strncpy(udev->busid, sdev->name, SYSFS_BUS_ID_SIZE);
+
+       sscanf(sdev->name, "%u-%u", &busnum, &devnum);
+       udev->busnum = busnum;
+
+       return 0;
+}
+
+int read_usb_interface(struct usb_device *udev, int i, struct usb_interface *uinf)
+{
+       char busid[SYSFS_BUS_ID_SIZE];
+       struct sysfs_device *sif;
+
+       sprintf(busid, "%s:%d.%d", udev->busid, udev->bConfigurationValue, i);
+
+       sif = sysfs_open_device("usb", busid);
+       if (!sif) {
+               err("open sif of %s", busid);
+               return -1;
+       }
+
+       READ_ATTR(uinf, uint8_t,  sif, bInterfaceClass,         "%02x\n");
+       READ_ATTR(uinf, uint8_t,  sif, bInterfaceSubClass,      "%02x\n");
+       READ_ATTR(uinf, uint8_t,  sif, bInterfaceProtocol,      "%02x\n");
+
+       sysfs_close_device(sif);
+
+       return 0;
+}
+
+int usbip_names_init(char *f)
+{
+       return names_init(f);
+}
+
+void usbip_names_free()
+{
+       names_free();
+}
+
+void usbip_names_get_product(char *buff, size_t size, uint16_t vendor, uint16_t product)
+{
+       const char *prod, *vend;
+
+       prod = names_product(vendor, product);
+       if (!prod)
+               prod = "unknown product";
+
+
+       vend = names_vendor(vendor);
+       if (!vend)
+               vend = "unknown vendor";
+
+       snprintf(buff, size, "%s : %s (%04x:%04x)", vend, prod, vendor, product);
+}
+
+void usbip_names_get_class(char *buff, size_t size, uint8_t class, uint8_t subclass, uint8_t protocol)
+{
+       const char *c, *s, *p;
+
+       if (class == 0 && subclass == 0 && protocol == 0) {
+               snprintf(buff, size, "(Defined at Interface level) (%02x/%02x/%02x)", class, subclass, protocol);
+               return;
+       }
+
+       p = names_protocol(class, subclass, protocol);
+       if (!p)
+               p = "unknown protocol";
+
+       s = names_subclass(class, subclass);
+       if (!s)
+               s = "unknown subclass";
+
+       c = names_class(class);
+       if (!c)
+               c = "unknown class";
+
+       snprintf(buff, size, "%s / %s / %s (%02x/%02x/%02x)", c, s, p, class, subclass, protocol);
+}
diff --git a/drivers/staging/usbip/userspace/libsrc/usbip_common.h b/drivers/staging/usbip/userspace/libsrc/usbip_common.h
new file mode 100644 (file)
index 0000000..c254b54
--- /dev/null
@@ -0,0 +1,149 @@
+/*
+ * Copyright (C) 2005-2007 Takahiro Hirofuchi
+ */
+
+#ifndef _USBIP_COMMON_H
+#define _USBIP_COMMON_H
+
+#include <unistd.h>
+#include <stdint.h>
+#include <syslog.h>
+#include <errno.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <strings.h>
+
+#include <sysfs/libsysfs.h>
+#include <netdb.h>
+#include <sys/socket.h>
+
+#ifndef USBIDS_FILE
+#define USBIDS_FILE "/usr/share/hwdata/usb.ids"
+#endif
+
+#ifndef VHCI_STATE_PATH
+#define VHCI_STATE_PATH "/var/run/vhci_hcd"
+#endif
+
+//#include <linux/usb_ch9.h>
+enum usb_device_speed {
+       USB_SPEED_UNKNOWN = 0,                  /* enumerating */
+       USB_SPEED_LOW, USB_SPEED_FULL,          /* usb 1.1 */
+       USB_SPEED_HIGH,                         /* usb 2.0 */
+       USB_SPEED_VARIABLE                      /* wireless (usb 2.5) */
+};
+
+/* FIXME: how to sync with drivers/usbip_common.h ? */
+enum usbip_device_status{
+       /* sdev is available. */
+       SDEV_ST_AVAILABLE = 0x01,
+       /* sdev is now used. */
+       SDEV_ST_USED,
+       /* sdev is unusable because of a fatal error. */
+       SDEV_ST_ERROR,
+
+       /* vdev does not connect a remote device. */
+       VDEV_ST_NULL,
+       /* vdev is used, but the USB address is not assigned yet */
+       VDEV_ST_NOTASSIGNED,
+       VDEV_ST_USED,
+       VDEV_ST_ERROR
+};
+
+extern int usbip_use_syslog;
+extern int usbip_use_stderr;
+extern int usbip_use_debug ;
+
+#define err(fmt, args...)      do { \
+       if (usbip_use_syslog) { \
+               syslog(LOG_ERR, "usbip err: %13s:%4d (%-12s) " fmt "\n", \
+                       __FILE__, __LINE__, __FUNCTION__,  ##args); \
+       } \
+       if (usbip_use_stderr) { \
+               fprintf(stderr, "usbip err: %13s:%4d (%-12s) " fmt "\n", \
+                       __FILE__, __LINE__, __FUNCTION__,  ##args); \
+       } \
+} while (0)
+
+#define notice(fmt, args...)   do { \
+       if (usbip_use_syslog) { \
+               syslog(LOG_DEBUG, "usbip: " fmt, ##args); \
+       } \
+       if (usbip_use_stderr) { \
+               fprintf(stderr, "usbip: " fmt "\n",  ##args); \
+       } \
+} while (0)
+
+#define info(fmt, args...)     do { \
+       if (usbip_use_syslog) { \
+               syslog(LOG_DEBUG, fmt, ##args); \
+       } \
+       if (usbip_use_stderr) { \
+               fprintf(stderr, fmt "\n",  ##args); \
+       } \
+} while (0)
+
+#define dbg(fmt, args...)      do { \
+       if (usbip_use_debug) { \
+               if (usbip_use_syslog) { \
+                       syslog(LOG_DEBUG, "usbip dbg: %13s:%4d (%-12s) " fmt, \
+                               __FILE__, __LINE__, __FUNCTION__,  ##args); \
+               } \
+               if (usbip_use_stderr) { \
+                       fprintf(stderr, "usbip dbg: %13s:%4d (%-12s) " fmt "\n", \
+                               __FILE__, __LINE__, __FUNCTION__,  ##args); \
+               } \
+       } \
+} while (0)
+
+
+#define BUG()  do { err("sorry, it's a bug"); abort(); } while (0)
+
+
+struct usb_interface {
+       uint8_t bInterfaceClass;
+       uint8_t bInterfaceSubClass;
+       uint8_t bInterfaceProtocol;
+       uint8_t padding;        /* alignment */
+} __attribute__((packed));
+
+
+
+struct usb_device {
+       char path[SYSFS_PATH_MAX];
+       char busid[SYSFS_BUS_ID_SIZE];
+
+       uint32_t busnum;
+       uint32_t devnum;
+       uint32_t speed;
+
+       uint16_t idVendor;
+       uint16_t idProduct;
+       uint16_t bcdDevice;
+
+       uint8_t bDeviceClass;
+       uint8_t bDeviceSubClass;
+       uint8_t bDeviceProtocol;
+       uint8_t bConfigurationValue;
+       uint8_t bNumConfigurations;
+       uint8_t bNumInterfaces;
+} __attribute__((packed));
+
+#define to_string(s)   #s
+
+void dump_usb_interface(struct usb_interface *);
+void dump_usb_device(struct usb_device *);
+int read_usb_device(struct sysfs_device *sdev, struct usb_device *udev);
+int read_attr_value(struct sysfs_device *dev, const char *name, const char *format);
+int read_usb_interface(struct usb_device *udev, int i, struct usb_interface *uinf);
+
+const char *usbip_speed_string(int num);
+const char *usbip_status_string(int32_t status);
+
+int usbip_names_init(char *);
+void usbip_names_free(void);
+void usbip_names_get_product(char *buff, size_t size, uint16_t vendor, uint16_t product);
+void usbip_names_get_class(char *buff, size_t size, uint8_t class, uint8_t subclass, uint8_t protocol);
+
+#endif
diff --git a/drivers/staging/usbip/userspace/libsrc/vhci_driver.c b/drivers/staging/usbip/userspace/libsrc/vhci_driver.c
new file mode 100644 (file)
index 0000000..db43f8d
--- /dev/null
@@ -0,0 +1,506 @@
+/*
+ * Copyright (C) 2005-2007 Takahiro Hirofuchi
+ */
+
+
+#include "usbip.h"
+
+
+static const char vhci_driver_name[] = "vhci_hcd";
+
+struct usbip_vhci_driver *vhci_driver;
+
+static struct usbip_imported_device *imported_device_init(struct usbip_imported_device *idev, char *busid)
+{
+       struct sysfs_device *sudev;
+
+       sudev = sysfs_open_device("usb", busid);
+       if (!sudev) {
+               err("sysfs_open_device %s", busid);
+               goto err;
+       }
+       read_usb_device(sudev, &idev->udev);
+       sysfs_close_device(sudev);
+
+       /* add class devices of this imported device */
+       struct class_device *cdev;
+       dlist_for_each_data(vhci_driver->cdev_list, cdev, struct class_device) {
+               if (!strncmp(cdev->devpath, idev->udev.path, strlen(idev->udev.path))) {
+                       struct class_device *new_cdev;
+
+                       /* alloc and copy because dlist is linked from only one list */
+                       new_cdev = calloc(1, sizeof(*new_cdev));
+                       if (!new_cdev)
+                               goto err;
+
+                       memcpy(new_cdev, cdev, sizeof(*new_cdev));
+                       dlist_unshift(idev->cdev_list, (void*) new_cdev);
+               }
+       }
+
+       return idev;
+
+err:
+       return NULL;
+}
+
+
+
+static int parse_status(char *value)
+{
+       int ret = 0;
+       char *c;
+
+
+       for (int i = 0; i < vhci_driver->nports; i++)
+               bzero(&vhci_driver->idev[i], sizeof(struct usbip_imported_device));
+
+
+       /* skip a header line */
+       c = strchr(value, '\n') + 1;
+
+       while (*c != '\0') {
+               int port, status, speed, devid;
+               unsigned long socket;
+               char lbusid[SYSFS_BUS_ID_SIZE];
+
+               ret = sscanf(c, "%d %d %d %x %lx %s\n",
+                               &port, &status, &speed,
+                               &devid, &socket, lbusid);
+
+               if (ret < 5) {
+                       err("scanf %d", ret);
+                       BUG();
+               }
+
+               dbg("port %d status %d speed %d devid %x",
+                               port, status, speed, devid);
+               dbg("socket %lx lbusid %s", socket, lbusid);
+
+
+               /* if a device is connected, look at it */
+               {
+                       struct usbip_imported_device *idev = &vhci_driver->idev[port];
+
+                       idev->port      = port;
+                       idev->status    = status;
+
+                       idev->devid     = devid;
+
+                       idev->busnum    = (devid >> 16);
+                       idev->devnum    = (devid & 0x0000ffff);
+
+                       idev->cdev_list = dlist_new(sizeof(struct class_device));
+                       if (!idev->cdev_list) {
+                               err("init new device");
+                               return -1;
+                       }
+
+                       if (idev->status != VDEV_ST_NULL && idev->status != VDEV_ST_NOTASSIGNED) {
+                               idev = imported_device_init(idev, lbusid);
+                               if (!idev) {
+                                       err("init new device");
+                                       return -1;
+                               }
+                       }
+               }
+
+
+               /* go to the next line */
+               c = strchr(c, '\n') + 1;
+       }
+
+       dbg("exit");
+
+       return 0;
+}
+
+
+static int check_usbip_device(struct sysfs_class_device *cdev)
+{
+       char clspath[SYSFS_PATH_MAX];   /* /sys/class/video4linux/video0/device     */
+       char devpath[SYSFS_PATH_MAX];   /* /sys/devices/platform/vhci_hcd/usb6/6-1:1.1  */
+
+       int ret;
+
+       snprintf(clspath, sizeof(clspath), "%s/device", cdev->path);
+
+       ret = sysfs_get_link(clspath, devpath, SYSFS_PATH_MAX);
+       if (!ret) {
+               if (!strncmp(devpath, vhci_driver->hc_device->path,
+                                       strlen(vhci_driver->hc_device->path))) {
+                       /* found usbip device */
+                       struct class_device *cdev;
+
+                       cdev = calloc(1, sizeof(*cdev));
+                       if (!cdev) {
+                               err("calloc cdev");
+                               return -1;
+                       }
+                       dlist_unshift(vhci_driver->cdev_list, (void*) cdev);
+                       strncpy(cdev->clspath, clspath, sizeof(cdev->clspath));
+                       strncpy(cdev->devpath, devpath, sizeof(cdev->clspath));
+                       dbg("  found %s %s", clspath, devpath);
+               }
+       }
+
+       return 0;
+}
+
+
+static int search_class_for_usbip_device(char *cname)
+{
+       struct sysfs_class *class;
+       struct dlist *cdev_list;
+       struct sysfs_class_device *cdev;
+       int ret = 0;
+
+       class = sysfs_open_class(cname);
+       if (!class) {
+               err("open class");
+               return -1;
+       }
+
+       dbg("class %s", class->name);
+
+       cdev_list = sysfs_get_class_devices(class);
+       if (!cdev_list)
+               /* nothing */
+               goto out;
+
+       dlist_for_each_data(cdev_list, cdev, struct sysfs_class_device) {
+               dbg("   cdev %s", cdev->name);
+               ret = check_usbip_device(cdev);
+               if (ret < 0)
+                       goto out;
+       }
+
+out:
+       sysfs_close_class(class);
+
+       return ret;
+}
+
+
+static int refresh_class_device_list(void)
+{
+       int ret;
+       struct dlist *cname_list;
+       char *cname;
+
+       /* search under /sys/class */
+       cname_list = sysfs_open_directory_list("/sys/class");
+       if (!cname_list) {
+               err("open class directory");
+               return -1;
+       }
+
+       dlist_for_each_data(cname_list, cname, char) {
+               ret = search_class_for_usbip_device(cname);
+               if (ret < 0) {
+                       sysfs_close_list(cname_list);
+                       return -1;
+               }
+       }
+
+       sysfs_close_list(cname_list);
+
+       /* seach under /sys/block */
+       ret = search_class_for_usbip_device(SYSFS_BLOCK_NAME);
+       if (ret < 0)
+               return -1;
+
+       return 0;
+}
+
+
+static int refresh_imported_device_list(void)
+{
+       struct sysfs_attribute *attr_status;
+
+
+       attr_status = sysfs_get_device_attr(vhci_driver->hc_device, "status");
+       if (!attr_status) {
+               err("get attr %s of %s", "status", vhci_driver->hc_device->name);
+               return -1;
+       }
+
+       dbg("name %s, path %s, len %d, method %d\n", attr_status->name,
+                       attr_status->path, attr_status->len, attr_status->method);
+
+       dbg("%s", attr_status->value);
+
+       return parse_status(attr_status->value);
+}
+
+static int get_nports(void)
+{
+       int nports = 0;
+       struct sysfs_attribute *attr_status;
+
+       attr_status = sysfs_get_device_attr(vhci_driver->hc_device, "status");
+       if (!attr_status) {
+               err("get attr %s of %s", "status", vhci_driver->hc_device->name);
+               return -1;
+       }
+
+       dbg("name %s, path %s, len %d, method %d\n", attr_status->name,
+                       attr_status->path, attr_status->len, attr_status->method);
+
+       dbg("%s", attr_status->value);
+
+       {
+               char *c;
+
+               /* skip a header line */
+               c = strchr(attr_status->value, '\n') + 1;
+
+               while (*c != '\0') {
+                       /* go to the next line */
+                       c = strchr(c, '\n') + 1;
+                       nports += 1;
+               }
+       }
+
+       return nports;
+}
+
+static int get_hc_busid(char *sysfs_mntpath, char *hc_busid)
+{
+        struct sysfs_driver *sdriver;
+        char sdriver_path[SYSFS_PATH_MAX];
+
+       struct sysfs_device *hc_dev;
+       struct dlist *hc_devs;
+
+       int found = 0;
+
+        snprintf(sdriver_path, SYSFS_PATH_MAX, "%s/%s/platform/%s/%s",
+                                sysfs_mntpath, SYSFS_BUS_NAME, SYSFS_DRIVERS_NAME,
+                                vhci_driver_name);
+
+        sdriver = sysfs_open_driver_path(sdriver_path);
+        if (!sdriver) {
+               info("%s is not found", sdriver_path);
+                info("load usbip-core.ko and vhci-hcd.ko !");
+                return -1;
+        }
+
+       hc_devs = sysfs_get_driver_devices(sdriver);
+       if (!hc_devs) {
+               err("get hc list");
+               goto err;
+       }
+
+       /* assume only one vhci_hcd */
+       dlist_for_each_data(hc_devs, hc_dev, struct sysfs_device) {
+               strncpy(hc_busid, hc_dev->bus_id, SYSFS_BUS_ID_SIZE);
+               found = 1;
+       }
+
+err:
+       sysfs_close_driver(sdriver);
+
+       if (found)
+               return 0;
+
+       err("not found usbip hc");
+       return -1;
+}
+
+
+/* ---------------------------------------------------------------------- */
+
+int usbip_vhci_driver_open(void)
+{
+       int ret;
+       char hc_busid[SYSFS_BUS_ID_SIZE];
+
+       vhci_driver = (struct usbip_vhci_driver *) calloc(1, sizeof(*vhci_driver));
+       if (!vhci_driver) {
+               err("alloc vhci_driver");
+               return -1;
+       }
+
+       ret = sysfs_get_mnt_path(vhci_driver->sysfs_mntpath, SYSFS_PATH_MAX);
+       if (ret < 0) {
+               err("sysfs must be mounted");
+               goto err;
+       }
+
+       ret = get_hc_busid(vhci_driver->sysfs_mntpath, hc_busid);
+       if (ret < 0)
+               goto err;
+
+       /* will be freed in usbip_driver_close() */
+       vhci_driver->hc_device = sysfs_open_device("platform", hc_busid);
+       if (!vhci_driver->hc_device) {
+               err("get sysfs vhci_driver");
+               goto err;
+       }
+
+       vhci_driver->nports = get_nports();
+
+       info("%d ports available\n", vhci_driver->nports);
+
+       vhci_driver->cdev_list = dlist_new(sizeof(struct class_device));
+       if (!vhci_driver->cdev_list)
+               goto err;
+
+       if (refresh_class_device_list())
+               goto err;
+
+       if (refresh_imported_device_list())
+               goto err;
+
+
+       return 0;
+
+
+err:
+       if (vhci_driver->cdev_list)
+               dlist_destroy(vhci_driver->cdev_list);
+       if (vhci_driver->hc_device)
+               sysfs_close_device(vhci_driver->hc_device);
+       if (vhci_driver)
+               free(vhci_driver);
+
+       vhci_driver = NULL;
+       return -1;
+}
+
+
+void usbip_vhci_driver_close()
+{
+       if (!vhci_driver)
+               return;
+
+       if (vhci_driver->cdev_list)
+               dlist_destroy(vhci_driver->cdev_list);
+
+       for (int i = 0; i < vhci_driver->nports; i++) {
+               if (vhci_driver->idev[i].cdev_list)
+                       dlist_destroy(vhci_driver->idev[i].cdev_list);
+       }
+
+       if (vhci_driver->hc_device)
+               sysfs_close_device(vhci_driver->hc_device);
+       free(vhci_driver);
+
+       vhci_driver = NULL;
+}
+
+
+int usbip_vhci_refresh_device_list(void)
+{
+       if (vhci_driver->cdev_list)
+               dlist_destroy(vhci_driver->cdev_list);
+
+
+       for (int i = 0; i < vhci_driver->nports; i++) {
+               if (vhci_driver->idev[i].cdev_list)
+                       dlist_destroy(vhci_driver->idev[i].cdev_list);
+       }
+
+       vhci_driver->cdev_list = dlist_new(sizeof(struct class_device));
+       if (!vhci_driver->cdev_list)
+               goto err;
+
+       if (refresh_class_device_list())
+               goto err;
+
+       if (refresh_imported_device_list())
+               goto err;
+
+       return 0;
+err:
+       if (vhci_driver->cdev_list)
+               dlist_destroy(vhci_driver->cdev_list);
+
+       for (int i = 0; i < vhci_driver->nports; i++) {
+               if (vhci_driver->idev[i].cdev_list)
+                       dlist_destroy(vhci_driver->idev[i].cdev_list);
+       }
+
+       err("refresh device list");
+       return -1;
+}
+
+
+int usbip_vhci_get_free_port(void)
+{
+       for (int i = 0; i < vhci_driver->nports; i++) {
+               if (vhci_driver->idev[i].status == VDEV_ST_NULL)
+                       return i;
+       }
+
+       return -1;
+}
+
+int usbip_vhci_attach_device2(uint8_t port, int sockfd, uint32_t devid,
+               uint32_t speed) {
+       struct sysfs_attribute *attr_attach;
+       char buff[200]; /* what size should be ? */
+       int ret;
+
+       attr_attach = sysfs_get_device_attr(vhci_driver->hc_device, "attach");
+       if (!attr_attach) {
+               err("get attach");
+               return -1;
+       }
+
+       snprintf(buff, sizeof(buff), "%u %u %u %u",
+                       port, sockfd, devid, speed);
+       dbg("writing: %s", buff);
+
+       ret = sysfs_write_attribute(attr_attach, buff, strlen(buff));
+       if (ret < 0) {
+               err("write to attach failed");
+               return -1;
+       }
+
+       info("port %d attached", port);
+
+       return 0;
+}
+
+static unsigned long get_devid(uint8_t busnum, uint8_t devnum)
+{
+       return (busnum << 16) | devnum;
+}
+
+/* will be removed */
+int usbip_vhci_attach_device(uint8_t port, int sockfd, uint8_t busnum,
+               uint8_t devnum, uint32_t speed)
+{
+       int devid = get_devid(busnum, devnum);
+
+       return usbip_vhci_attach_device2(port, sockfd, devid, speed);
+}
+
+int usbip_vhci_detach_device(uint8_t port)
+{
+       struct sysfs_attribute  *attr_detach;
+       char buff[200]; /* what size should be ? */
+       int ret;
+
+       attr_detach = sysfs_get_device_attr(vhci_driver->hc_device, "detach");
+       if (!attr_detach) {
+               err("get detach");
+               return -1;
+       }
+
+       snprintf(buff, sizeof(buff), "%u", port);
+       dbg("writing to detach");
+       dbg("writing: %s", buff);
+
+       ret = sysfs_write_attribute(attr_detach, buff, strlen(buff));
+       if (ret < 0) {
+               err("write to detach failed");
+               return -1;
+       }
+
+       info("port %d detached", port);
+
+       return 0;
+}
diff --git a/drivers/staging/usbip/userspace/libsrc/vhci_driver.h b/drivers/staging/usbip/userspace/libsrc/vhci_driver.h
new file mode 100644 (file)
index 0000000..cad8ad7
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2005-2007 Takahiro Hirofuchi
+ */
+
+#ifndef _VHCI_DRIVER_H
+#define _VHCI_DRIVER_H
+
+#include "usbip.h"
+
+
+
+#define MAXNPORT 128
+
+struct class_device {
+       char clspath[SYSFS_PATH_MAX];
+       char devpath[SYSFS_PATH_MAX];
+};
+
+struct usbip_imported_device {
+       uint8_t port;
+       uint32_t status;
+
+       uint32_t devid;
+
+       uint8_t busnum;
+       uint8_t devnum;
+
+
+       struct dlist *cdev_list;        /* list of class device */
+       struct usb_device udev;
+};
+
+struct usbip_vhci_driver {
+       char sysfs_mntpath[SYSFS_PATH_MAX];
+       struct sysfs_device *hc_device; /* /sys/devices/platform/vhci_hcd */
+
+       struct dlist *cdev_list;        /* list of class device */
+
+       int nports;
+       struct usbip_imported_device idev[MAXNPORT];
+};
+
+
+extern struct usbip_vhci_driver *vhci_driver;
+
+int usbip_vhci_driver_open(void);
+void usbip_vhci_driver_close(void);
+
+int  usbip_vhci_refresh_device_list(void);
+
+
+int usbip_vhci_get_free_port(void);
+int usbip_vhci_attach_device2(uint8_t port, int sockfd, uint32_t devid,
+               uint32_t speed);
+
+/* will be removed */
+int usbip_vhci_attach_device(uint8_t port, int sockfd, uint8_t busnum,
+               uint8_t devnum, uint32_t speed);
+
+int usbip_vhci_detach_device(uint8_t port);
+#endif
diff --git a/drivers/staging/usbip/userspace/src/Makefile.am b/drivers/staging/usbip/userspace/src/Makefile.am
new file mode 100644 (file)
index 0000000..05a7aa5
--- /dev/null
@@ -0,0 +1,10 @@
+AM_CPPFLAGS := -I$(top_srcdir)/libsrc -DUSBIDS_FILE='"@USBIDS_DIR@/usb.ids"'
+AM_CFLAGS   := @EXTRA_CFLAGS@ @PACKAGE_CFLAGS@
+LDADD       := $(top_srcdir)/libsrc/libusbip.la @PACKAGE_LIBS@
+
+sbin_PROGRAMS := usbip usbipd usbip_bind_driver
+
+usbip_SOURCES := usbip.c usbip_network.c usbip_network.h
+usbipd_SOURCES := usbipd.c usbip_network.c usbip_network.h
+usbip_bind_driver_SOURCES := bind-driver.c utils.c utils.h \
+                            usbip_network.h usbip_network.c
diff --git a/drivers/staging/usbip/userspace/src/bind-driver.c b/drivers/staging/usbip/userspace/src/bind-driver.c
new file mode 100644 (file)
index 0000000..201ffbb
--- /dev/null
@@ -0,0 +1,643 @@
+/*
+ *
+ * Copyright (C) 2005-2007 Takahiro Hirofuchi
+ */
+
+#include "utils.h"
+
+#define _GNU_SOURCE
+#include <getopt.h>
+#include <glib.h>
+
+
+
+static const struct option longopts[] = {
+       {"usbip",       required_argument,      NULL, 'u'},
+       {"other",       required_argument,      NULL, 'o'},
+       {"list",        no_argument,            NULL, 'l'},
+       {"list2",       no_argument,            NULL, 'L'},
+       {"help",        no_argument,            NULL, 'h'},
+#if 0
+       {"allusbip",    no_argument,            NULL, 'a'},
+       {"export-to",   required_argument,      NULL, 'e'},
+       {"unexport",    required_argument,      NULL, 'x'},
+       {"busid",       required_argument,      NULL, 'b'},
+#endif
+
+       {NULL,          0,                      NULL,  0}
+};
+
+static const char match_busid_path[] = "/sys/bus/usb/drivers/usbip/match_busid";
+
+
+static void show_help(void)
+{
+       printf("Usage: usbip_bind_driver [OPTION]\n");
+       printf("Change driver binding for USB/IP.\n");
+       printf("  --usbip busid        make a device exportable\n");
+       printf("  --other busid        use a device by a local driver\n");
+       printf("  --list               print usb devices and their drivers\n");
+       printf("  --list2              print usb devices and their drivers in parseable mode\n");
+#if 0
+       printf("  --allusbip           make all devices exportable\n");
+       printf("  --export-to host     export the device to 'host'\n");
+       printf("  --unexport host      unexport a device previously exported to 'host'\n");
+       printf("  --busid busid        the busid used for --export-to\n");
+#endif
+}
+
+static int modify_match_busid(char *busid, int add)
+{
+       int fd;
+       int ret;
+       char buff[BUS_ID_SIZE + 4];
+
+       /* BUS_IS_SIZE includes NULL termination? */
+       if (strnlen(busid, BUS_ID_SIZE) > BUS_ID_SIZE - 1) {
+               g_warning("too long busid");
+               return -1;
+       }
+
+       fd = open(match_busid_path, O_WRONLY);
+       if (fd < 0)
+               return -1;
+
+       if (add)
+               snprintf(buff, BUS_ID_SIZE + 4, "add %s", busid);
+       else
+               snprintf(buff, BUS_ID_SIZE + 4, "del %s", busid);
+
+       g_debug("write \"%s\" to %s", buff, match_busid_path);
+
+       ret = write(fd, buff, sizeof(buff));
+       if (ret < 0) {
+               close(fd);
+               return -1;
+       }
+
+       close(fd);
+
+       return 0;
+}
+
+static const char unbind_path_format[] = "/sys/bus/usb/devices/%s/driver/unbind";
+
+/* buggy driver may cause dead lock */
+static int unbind_interface_busid(char *busid)
+{
+       char unbind_path[PATH_MAX];
+       int fd;
+       int ret;
+
+       snprintf(unbind_path, sizeof(unbind_path), unbind_path_format, busid);
+
+       fd = open(unbind_path, O_WRONLY);
+       if (fd < 0) {
+               g_warning("opening unbind_path failed: %d", fd);
+               return -1;
+       }
+
+       ret = write(fd, busid, strnlen(busid, BUS_ID_SIZE));
+       if (ret < 0) {
+               g_warning("write to unbind_path failed: %d", ret);
+               close(fd);
+               return -1;
+       }
+
+       close(fd);
+
+       return 0;
+}
+
+static int unbind_interface(char *busid, int configvalue, int interface)
+{
+       char inf_busid[BUS_ID_SIZE];
+       g_debug("unbinding interface");
+
+       snprintf(inf_busid, BUS_ID_SIZE, "%s:%d.%d", busid, configvalue, interface);
+
+       return unbind_interface_busid(inf_busid);
+}
+
+
+static const char bind_path_format[] = "/sys/bus/usb/drivers/%s/bind";
+
+static int bind_interface_busid(char *busid, char *driver)
+{
+       char bind_path[PATH_MAX];
+       int fd;
+       int ret;
+
+       snprintf(bind_path, sizeof(bind_path), bind_path_format, driver);
+
+       fd = open(bind_path, O_WRONLY);
+       if (fd < 0)
+               return -1;
+
+       ret = write(fd, busid, strnlen(busid, BUS_ID_SIZE));
+       if (ret < 0) {
+               close(fd);
+               return -1;
+       }
+
+       close(fd);
+
+       return 0;
+}
+
+static int bind_interface(char *busid, int configvalue, int interface, char *driver)
+{
+       char inf_busid[BUS_ID_SIZE];
+
+       snprintf(inf_busid, BUS_ID_SIZE, "%s:%d.%d", busid, configvalue, interface);
+
+       return bind_interface_busid(inf_busid, driver);
+}
+
+static int unbind(char *busid)
+{
+       int configvalue = 0;
+       int ninterface = 0;
+       int devclass = 0;
+       int i;
+       int failed = 0;
+
+       configvalue = read_bConfigurationValue(busid);
+       ninterface  = read_bNumInterfaces(busid);
+       devclass  = read_bDeviceClass(busid);
+
+       if (configvalue < 0 || ninterface < 0 || devclass < 0) {
+               g_warning("read config and ninf value, removed?");
+               return -1;
+       }
+
+       if (devclass == 0x09) {
+               g_message("skip unbinding of hub");
+               return -1;
+       }
+
+       for (i = 0; i < ninterface; i++) {
+               char driver[PATH_MAX];
+               int ret;
+
+               bzero(&driver, sizeof(driver));
+
+               getdriver(busid, configvalue, i, driver, PATH_MAX-1);
+
+               g_debug(" %s:%d.%d      -> %s ", busid, configvalue, i, driver);
+
+               if (!strncmp("none", driver, PATH_MAX))
+                       continue; /* unbound interface */
+
+#if 0
+               if (!strncmp("usbip", driver, PATH_MAX))
+                       continue; /* already bound to usbip */
+#endif
+
+               /* unbinding */
+               ret = unbind_interface(busid, configvalue, i);
+               if (ret < 0) {
+                       g_warning("unbind driver at %s:%d.%d failed",
+                                       busid, configvalue, i);
+                       failed = 1;
+               }
+       }
+
+       if (failed)
+               return -1;
+       else
+               return 0;
+}
+
+/* call at unbound state */
+static int bind_to_usbip(char *busid)
+{
+       int configvalue = 0;
+       int ninterface = 0;
+       int i;
+       int failed = 0;
+
+       configvalue = read_bConfigurationValue(busid);
+       ninterface  = read_bNumInterfaces(busid);
+
+       if (configvalue < 0 || ninterface < 0) {
+               g_warning("read config and ninf value, removed?");
+               return -1;
+       }
+
+       for (i = 0; i < ninterface; i++) {
+               int ret;
+
+               ret = bind_interface(busid, configvalue, i, "usbip");
+               if (ret < 0) {
+                       g_warning("bind usbip at %s:%d.%d, failed",
+                                       busid, configvalue, i);
+                       failed = 1;
+                       /* need to contine binding at other interfaces */
+               }
+       }
+
+       if (failed)
+               return -1;
+       else
+               return 0;
+}
+
+
+static int use_device_by_usbip(char *busid)
+{
+       int ret;
+
+       ret = unbind(busid);
+       if (ret < 0) {
+               g_warning("unbind drivers of %s, failed", busid);
+               return -1;
+       }
+
+       ret = modify_match_busid(busid, 1);
+       if (ret < 0) {
+               g_warning("add %s to match_busid, failed", busid);
+               return -1;
+       }
+
+       ret = bind_to_usbip(busid);
+       if (ret < 0) {
+               g_warning("bind usbip to %s, failed", busid);
+               modify_match_busid(busid, 0);
+               return -1;
+       }
+
+       g_message("bind %s to usbip, complete!", busid);
+
+       return 0;
+}
+
+
+
+static int use_device_by_other(char *busid)
+{
+       int ret;
+       int config;
+
+       /* read and write the same config value to kick probing */
+       config = read_bConfigurationValue(busid);
+       if (config < 0) {
+               g_warning("read bConfigurationValue of %s, failed", busid);
+               return -1;
+       }
+
+       ret = modify_match_busid(busid, 0);
+       if (ret < 0) {
+               g_warning("del %s to match_busid, failed", busid);
+               return -1;
+       }
+
+       ret = write_bConfigurationValue(busid, config);
+       if (ret < 0) {
+               g_warning("read bConfigurationValue of %s, failed", busid);
+               return -1;
+       }
+
+       g_message("bind %s to other drivers than usbip, complete!", busid);
+
+       return 0;
+}
+
+
+#include <sys/types.h>
+#include <regex.h>
+
+#include <errno.h>
+#include <string.h>
+#include <stdio.h>
+
+
+
+static int is_usb_device(char *busid)
+{
+       int ret;
+
+       regex_t regex;
+       regmatch_t pmatch[1];
+
+       ret = regcomp(&regex, "^[0-9]+-[0-9]+(\\.[0-9]+)*$", REG_NOSUB|REG_EXTENDED);
+       if (ret < 0)
+               g_error("regcomp: %s\n", strerror(errno));
+
+       ret = regexec(&regex, busid, 0, pmatch, 0);
+       if (ret)
+               return 0;       /* not matched */
+
+       return 1;
+}
+
+
+#include <dirent.h>
+static int show_devices(void)
+{
+       DIR *dir;
+
+       dir = opendir("/sys/bus/usb/devices/");
+       if (!dir)
+               g_error("opendir: %s", strerror(errno));
+
+       printf("List USB devices\n");
+       for (;;) {
+               struct dirent *dirent;
+               char *busid;
+
+               dirent = readdir(dir);
+               if (!dirent)
+                       break;
+
+               busid = dirent->d_name;
+
+               if (is_usb_device(busid)) {
+                       char name[100] = {'\0'};
+                       char driver[100] =  {'\0'};
+                       int conf, ninf = 0;
+                       int i;
+
+                       conf = read_bConfigurationValue(busid);
+                       ninf = read_bNumInterfaces(busid);
+
+                       getdevicename(busid, name, sizeof(name));
+
+                       printf(" - busid %s (%s)\n", busid, name);
+
+                       for (i = 0; i < ninf; i++) {
+                               getdriver(busid, conf, i, driver, sizeof(driver));
+                               printf("         %s:%d.%d -> %s\n", busid, conf, i, driver);
+                       }
+                       printf("\n");
+               }
+       }
+
+       closedir(dir);
+
+       return 0;
+}
+
+static int show_devices2(void)
+{
+       DIR *dir;
+
+       dir = opendir("/sys/bus/usb/devices/");
+       if (!dir)
+               g_error("opendir: %s", strerror(errno));
+
+       for (;;) {
+               struct dirent *dirent;
+               char *busid;
+
+               dirent = readdir(dir);
+               if (!dirent)
+                       break;
+
+               busid = dirent->d_name;
+
+               if (is_usb_device(busid)) {
+                       char name[100] = {'\0'};
+                       char driver[100] =  {'\0'};
+                       int conf, ninf = 0;
+                       int i;
+
+                       conf = read_bConfigurationValue(busid);
+                       ninf = read_bNumInterfaces(busid);
+
+                       getdevicename(busid, name, sizeof(name));
+
+                       printf("busid=%s#usbid=%s#", busid, name);
+
+                       for (i = 0; i < ninf; i++) {
+                               getdriver(busid, conf, i, driver, sizeof(driver));
+                               printf("%s:%d.%d=%s#", busid, conf, i, driver);
+                       }
+                       printf("\n");
+               }
+       }
+
+       closedir(dir);
+
+       return 0;
+}
+
+
+#if 0
+static int export_to(char *host, char *busid) {
+
+       int ret;
+
+       if( host == NULL ) {
+               printf( "no host given\n\n");
+               show_help();
+               return -1;
+       }
+       if( busid == NULL ) {
+               /* XXX print device list and ask for busnumber, if none is
+                * given */
+               printf( "no busid given, use --busid switch\n\n");
+               show_help();
+               return -1;
+       }
+
+
+       ret = use_device_by_usbip(busid);
+       if( ret != 0 ) {
+               printf( "could not bind driver to usbip\n");
+               return -1;
+       }
+
+       printf( "DEBUG: exporting device '%s' to '%s'\n", busid, host );
+       ret = export_busid_to_host(host, busid); /* usbip_export.[ch] */
+       if( ret != 0 ) {
+               printf( "could not export device to host\n" );
+               printf( "   host: %s, device: %s\n", host, busid );
+               use_device_by_other(busid);
+               return -1;
+       }
+
+       return 0;
+}
+
+static int unexport_from(char *host, char *busid) {
+
+       int ret;
+
+       if (!host || !busid)
+               g_error("no host or no busid\n");
+
+       g_message("unexport_from: host: '%s', busid: '%s'", host, busid);
+
+       ret = unexport_busid_from_host(host, busid); /* usbip_export.[ch] */
+       if( ret != 0 ) {
+               err( "could not unexport device from host\n" );
+               err( "   host: %s, device: %s\n", host, busid );
+       }
+
+       ret = use_device_by_other(busid);
+       if (ret < 0)
+               g_error("could not unbind device from usbip\n");
+
+       return 0;
+}
+
+
+static int allusbip(void)
+{
+       DIR *dir;
+
+       dir = opendir("/sys/bus/usb/devices/");
+       if (!dir)
+               g_error("opendir: %s", strerror(errno));
+
+       for (;;) {
+               struct dirent *dirent;
+               char *busid;
+
+               dirent = readdir(dir);
+               if (!dirent)
+                       break;
+
+               busid = dirent->d_name;
+
+               if (!is_usb_device(busid))
+                       continue;
+
+               {
+                       char name[PATH_MAX];
+                       int conf, ninf = 0;
+                       int i;
+                       int be_local = 0;
+
+                       conf = read_bConfigurationValue(busid);
+                       ninf = read_bNumInterfaces(busid);
+
+                       getdevicename(busid, name, sizeof(name));
+
+                       for (i = 0; i < ninf; i++) {
+                               char driver[PATH_MAX];
+
+                               getdriver(busid, conf, i, driver, sizeof(driver));
+#if 0
+                               if (strncmp(driver, "usbhid", 6) == 0 || strncmp(driver, "usb-storage", 11) == 0) {
+                                       be_local = 1;
+                                       break;
+                               }
+#endif
+                       }
+
+                       if (be_local == 0)
+                               use_device_by_usbip(busid);
+               }
+       }
+
+       closedir(dir);
+
+       return 0;
+}
+#endif
+
+int main(int argc, char **argv)
+{
+       char *busid = NULL;
+       char *remote_host __attribute__((unused)) = NULL;
+
+       enum {
+               cmd_unknown = 0,
+               cmd_use_by_usbip,
+               cmd_use_by_other,
+               cmd_list,
+               cmd_list2,
+               cmd_allusbip,
+               cmd_export_to,
+               cmd_unexport,
+               cmd_help,
+       } cmd = cmd_unknown;
+
+       if (geteuid() != 0)
+               g_warning("running non-root?");
+
+       for (;;) {
+               int c;
+               int index = 0;
+
+               c = getopt_long(argc, argv, "u:o:hlLae:x:b:", longopts, &index);
+               if (c == -1)
+                       break;
+
+               switch (c) {
+                       case 'u':
+                               cmd = cmd_use_by_usbip;
+                               busid = optarg;
+                               break;
+                       case 'o' :
+                               cmd = cmd_use_by_other;
+                               busid = optarg;
+                               break;
+                       case 'l' :
+                               cmd = cmd_list;
+                               break;
+                       case 'L' :
+                               cmd = cmd_list2;
+                               break;
+                       case 'a' :
+                               cmd = cmd_allusbip;
+                               break;
+                       case 'b':
+                               busid = optarg;
+                               break;
+                       case 'e':
+                               cmd = cmd_export_to;
+                               remote_host = optarg;
+                               break;
+                       case 'x':
+                               cmd = cmd_unexport;
+                               remote_host = optarg;
+                               break;
+                       case 'h': /* fallthrough */
+                       case '?':
+                               cmd = cmd_help;
+                               break;
+                       default:
+                               g_error("getopt");
+               }
+
+               //if (cmd)
+               //      break;
+       }
+
+       switch (cmd) {
+               case cmd_use_by_usbip:
+                       use_device_by_usbip(busid);
+                       break;
+               case cmd_use_by_other:
+                       use_device_by_other(busid);
+                       break;
+               case cmd_list:
+                       show_devices();
+                       break;
+               case cmd_list2:
+                       show_devices2();
+                       break;
+#if 0
+               case cmd_allusbip:
+                       allusbip();
+                       break;
+               case cmd_export_to:
+                       export_to(remote_host, busid);
+                       break;
+               case cmd_unexport:
+                       unexport_from(remote_host, busid);
+                       break;
+#endif
+               case cmd_help: /* fallthrough */
+               case cmd_unknown:
+                       show_help();
+                       break;
+               default:
+                       g_error("NOT REACHED");
+       }
+
+       return 0;
+}
diff --git a/drivers/staging/usbip/userspace/src/usbip.c b/drivers/staging/usbip/userspace/src/usbip.c
new file mode 100644 (file)
index 0000000..01a5628
--- /dev/null
@@ -0,0 +1,723 @@
+/*
+ *
+ * Copyright (C) 2005-2007 Takahiro Hirofuchi
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "../config.h"
+#endif
+
+#include "usbip.h"
+#include "usbip_network.h"
+#include <ctype.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <glib.h>
+
+static const char version[] = PACKAGE_STRING;
+
+
+/* /sys/devices/platform/vhci_hcd/usb6/6-1/6-1:1.1  -> 1 */
+static int get_interface_number(char *path)
+{
+       char *c;
+
+       c = strstr(path, vhci_driver->hc_device->bus_id);
+       if (!c)
+               return -1;      /* hc exist? */
+       c++;
+       /* -> usb6/6-1/6-1:1.1 */
+
+       c = strchr(c, '/');
+       if (!c)
+               return -1;      /* hc exist? */
+       c++;
+       /* -> 6-1/6-1:1.1 */
+
+       c = strchr(c, '/');
+       if (!c)
+               return -1;      /* no interface path */
+       c++;
+       /* -> 6-1:1.1 */
+
+       c = strchr(c, ':');
+       if (!c)
+               return -1;      /* no configuration? */
+       c++;
+       /* -> 1.1 */
+
+       c = strchr(c, '.');
+       if (!c)
+               return -1;      /* no interface? */
+       c++;
+       /* -> 1 */
+
+
+       return atoi(c);
+}
+
+
+static struct sysfs_device *open_usb_interface(struct usb_device *udev, int i)
+{
+       struct sysfs_device *suinf;
+       char busid[SYSFS_BUS_ID_SIZE];
+
+       snprintf(busid, SYSFS_BUS_ID_SIZE, "%s:%d.%d",
+                       udev->busid, udev->bConfigurationValue, i);
+
+       suinf = sysfs_open_device("usb", busid);
+       if (!suinf)
+               err("sysfs_open_device %s", busid);
+
+       return suinf;
+}
+
+
+#define MAX_BUFF 100
+static int record_connection(char *host, char *port, char *busid, int rhport)
+{
+       int fd;
+       char path[PATH_MAX+1];
+       char buff[MAX_BUFF+1];
+       int ret;
+
+       mkdir(VHCI_STATE_PATH, 0700);
+
+       snprintf(path, PATH_MAX, VHCI_STATE_PATH"/port%d", rhport);
+
+       fd = open(path, O_WRONLY|O_CREAT|O_TRUNC, S_IRWXU);
+       if (fd < 0)
+               return -1;
+
+       snprintf(buff, MAX_BUFF, "%s %s %s\n",
+                       host, port, busid);
+
+       ret = write(fd, buff, strlen(buff));
+       if (ret != (ssize_t) strlen(buff)) {
+               close(fd);
+               return -1;
+       }
+
+       close(fd);
+
+       return 0;
+}
+
+static int read_record(int rhport, char *host, char *port, char *busid)
+{
+       FILE *file;
+       char path[PATH_MAX+1];
+
+       snprintf(path, PATH_MAX, VHCI_STATE_PATH"/port%d", rhport);
+
+       file = fopen(path, "r");
+       if (!file) {
+               err("fopen");
+               return -1;
+       }
+
+       if (fscanf(file, "%s %s %s\n", host, port, busid) != 3) {
+               err("fscanf");
+               fclose(file);
+               return -1;
+       }
+
+       fclose(file);
+
+       return 0;
+}
+
+
+int usbip_vhci_imported_device_dump(struct usbip_imported_device *idev)
+{
+       char product_name[100];
+       char host[NI_MAXHOST] = "unknown host";
+       char serv[NI_MAXSERV] = "unknown port";
+       char remote_busid[SYSFS_BUS_ID_SIZE];
+       int ret;
+
+       if (idev->status == VDEV_ST_NULL || idev->status == VDEV_ST_NOTASSIGNED) {
+               info("Port %02d: <%s>", idev->port, usbip_status_string(idev->status));
+               return 0;
+       }
+
+       ret = read_record(idev->port, host, serv, remote_busid);
+       if (ret) {
+               err("read_record");
+               return -1;
+       }
+
+       info("Port %02d: <%s> at %s", idev->port,
+                       usbip_status_string(idev->status), usbip_speed_string(idev->udev.speed));
+
+       usbip_names_get_product(product_name, sizeof(product_name),
+                       idev->udev.idVendor, idev->udev.idProduct);
+
+       info("       %s",  product_name);
+
+       info("%10s -> usbip://%s:%s/%s  (remote devid %08x (bus/dev %03d/%03d))",
+                       idev->udev.busid, host, serv, remote_busid,
+                       idev->devid,
+                       idev->busnum, idev->devnum);
+
+       for (int i=0; i < idev->udev.bNumInterfaces; i++) {
+               /* show interface information */
+               struct sysfs_device *suinf;
+
+               suinf = open_usb_interface(&idev->udev, i);
+               if (!suinf)
+                       continue;
+
+               info("       %6s used by %-17s", suinf->bus_id, suinf->driver_name);
+               sysfs_close_device(suinf);
+
+               /* show class device information */
+               struct class_device *cdev;
+
+               dlist_for_each_data(idev->cdev_list, cdev, struct class_device) {
+                       int ifnum = get_interface_number(cdev->devpath);
+                       if (ifnum == i) {
+                               info("           %s", cdev->clspath);
+                       }
+               }
+       }
+
+       return 0;
+}
+
+
+
+
+static int query_exported_devices(int sockfd)
+{
+       int ret;
+       struct op_devlist_reply rep;
+       uint16_t code = OP_REP_DEVLIST;
+
+       bzero(&rep, sizeof(rep));
+
+       ret = usbip_send_op_common(sockfd, OP_REQ_DEVLIST, 0);
+       if (ret < 0) {
+               err("send op_common");
+               return -1;
+       }
+
+       ret = usbip_recv_op_common(sockfd, &code);
+       if (ret < 0) {
+               err("recv op_common");
+               return -1;
+       }
+
+       ret = usbip_recv(sockfd, (void *) &rep, sizeof(rep));
+       if (ret < 0) {
+               err("recv op_devlist");
+               return -1;
+       }
+
+       PACK_OP_DEVLIST_REPLY(0, &rep);
+       dbg("exportable %d devices", rep.ndev);
+
+       for (unsigned int i=0; i < rep.ndev; i++) {
+               char product_name[100];
+               char class_name[100];
+               struct usb_device udev;
+
+               bzero(&udev, sizeof(udev));
+
+               ret = usbip_recv(sockfd, (void *) &udev, sizeof(udev));
+               if (ret < 0) {
+                       err("recv usb_device[%d]", i);
+                       return -1;
+               }
+               pack_usb_device(0, &udev);
+
+               usbip_names_get_product(product_name, sizeof(product_name),
+                               udev.idVendor, udev.idProduct);
+               usbip_names_get_class(class_name, sizeof(class_name), udev.bDeviceClass,
+                               udev.bDeviceSubClass, udev.bDeviceProtocol);
+
+               info("%8s: %s", udev.busid, product_name);
+               info("%8s: %s", " ", udev.path);
+               info("%8s: %s", " ", class_name);
+
+               for (int j=0; j < udev.bNumInterfaces; j++) {
+                       struct usb_interface uinf;
+
+                       ret = usbip_recv(sockfd, (void *) &uinf, sizeof(uinf));
+                       if (ret < 0) {
+                               err("recv usb_interface[%d]", j);
+                               return -1;
+                       }
+
+                       pack_usb_interface(0, &uinf);
+                       usbip_names_get_class(class_name, sizeof(class_name), uinf.bInterfaceClass,
+                                       uinf.bInterfaceSubClass, uinf.bInterfaceProtocol);
+
+                       info("%8s: %2d - %s", " ", j, class_name);
+               }
+
+               info(" ");
+       }
+
+       return rep.ndev;
+}
+
+static int import_device(int sockfd, struct usb_device *udev)
+{
+       int ret;
+       int port;
+
+       ret = usbip_vhci_driver_open();
+       if (ret < 0) {
+               err("open vhci_driver");
+               return -1;
+       }
+
+       port = usbip_vhci_get_free_port();
+       if (port < 0) {
+               err("no free port");
+               usbip_vhci_driver_close();
+               return -1;
+       }
+
+       ret = usbip_vhci_attach_device(port, sockfd, udev->busnum,
+                       udev->devnum, udev->speed);
+       if (ret < 0) {
+               err("import device");
+               usbip_vhci_driver_close();
+               return -1;
+       }
+
+       usbip_vhci_driver_close();
+
+       return port;
+}
+
+
+static int query_import_device(int sockfd, char *busid)
+{
+       int ret;
+       struct op_import_request request;
+       struct op_import_reply   reply;
+       uint16_t code = OP_REP_IMPORT;
+
+       bzero(&request, sizeof(request));
+       bzero(&reply, sizeof(reply));
+
+
+       /* send a request */
+       ret = usbip_send_op_common(sockfd, OP_REQ_IMPORT, 0);
+       if (ret < 0) {
+               err("send op_common");
+               return -1;
+       }
+
+       strncpy(request.busid, busid, SYSFS_BUS_ID_SIZE-1);
+
+       PACK_OP_IMPORT_REQUEST(0, &request);
+
+       ret = usbip_send(sockfd, (void *) &request, sizeof(request));
+       if (ret < 0) {
+               err("send op_import_request");
+               return -1;
+       }
+
+
+       /* recieve a reply */
+       ret = usbip_recv_op_common(sockfd, &code);
+       if (ret < 0) {
+               err("recv op_common");
+               return -1;
+       }
+
+       ret = usbip_recv(sockfd, (void *) &reply, sizeof(reply));
+       if (ret < 0) {
+               err("recv op_import_reply");
+               return -1;
+       }
+
+       PACK_OP_IMPORT_REPLY(0, &reply);
+
+
+       /* check the reply */
+       if (strncmp(reply.udev.busid, busid, SYSFS_BUS_ID_SIZE)) {
+               err("recv different busid %s", reply.udev.busid);
+               return -1;
+       }
+
+
+       /* import a device */
+       return import_device(sockfd, &reply.udev);
+}
+
+static int attach_device(char *host, char *busid)
+{
+       int sockfd;
+       int ret;
+       int rhport;
+
+       sockfd = tcp_connect(host, USBIP_PORT_STRING);
+       if (sockfd < 0) {
+               err("tcp connect");
+               return -1;
+       }
+
+       rhport = query_import_device(sockfd, busid);
+       if (rhport < 0) {
+               err("query");
+               return -1;
+       }
+
+       close(sockfd);
+
+       ret = record_connection(host, USBIP_PORT_STRING,
+                       busid, rhport);
+       if (ret < 0) {
+               err("record connection");
+               return -1;
+       }
+
+       return 0;
+}
+
+static int detach_port(char *port)
+{
+       int ret;
+       uint8_t portnum;
+
+       for (unsigned int i=0; i < strlen(port); i++)
+               if (!isdigit(port[i])) {
+                       err("invalid port %s", port);
+                       return -1;
+               }
+
+       /* check max port */
+
+       portnum = atoi(port);
+
+       ret = usbip_vhci_driver_open();
+       if (ret < 0) {
+               err("open vhci_driver");
+               return -1;
+       }
+
+       ret = usbip_vhci_detach_device(portnum);
+       if (ret < 0)
+               return -1;
+
+       usbip_vhci_driver_close();
+
+       return ret;
+}
+
+static int show_exported_devices(char *host)
+{
+       int ret;
+       int sockfd;
+
+       sockfd = tcp_connect(host, USBIP_PORT_STRING);
+       if (sockfd < 0) {
+               err("- %s failed", host);
+               return -1;
+       }
+
+       info("- %s", host);
+
+       ret = query_exported_devices(sockfd);
+       if (ret < 0) {
+               err("query");
+               return -1;
+       }
+
+       close(sockfd);
+       return 0;
+}
+
+static int attach_exported_devices(char *host, int sockfd)
+{
+       int ret;
+       struct op_devlist_reply rep;
+       uint16_t code = OP_REP_DEVLIST;
+
+       bzero(&rep, sizeof(rep));
+
+       ret = usbip_send_op_common(sockfd, OP_REQ_DEVLIST, 0);
+       if(ret < 0) {
+               err("send op_common");
+               return -1;
+       }
+
+       ret = usbip_recv_op_common(sockfd, &code);
+       if(ret < 0) {
+               err("recv op_common");
+               return -1;
+       }
+
+       ret = usbip_recv(sockfd, (void *) &rep, sizeof(rep));
+       if(ret < 0) {
+               err("recv op_devlist");
+               return -1;
+       }
+
+       PACK_OP_DEVLIST_REPLY(0, &rep);
+       dbg("exportable %d devices", rep.ndev);
+
+       for(unsigned int i=0; i < rep.ndev; i++) {
+               char product_name[100];
+               char class_name[100];
+               struct usb_device udev;
+
+               bzero(&udev, sizeof(udev));
+
+               ret = usbip_recv(sockfd, (void *) &udev, sizeof(udev));
+               if(ret < 0) {
+                       err("recv usb_device[%d]", i);
+                       return -1;
+               }
+               pack_usb_device(0, &udev);
+
+               usbip_names_get_product(product_name, sizeof(product_name),
+                               udev.idVendor, udev.idProduct);
+               usbip_names_get_class(class_name, sizeof(class_name), udev.bDeviceClass,
+                               udev.bDeviceSubClass, udev.bDeviceProtocol);
+
+               dbg("Attaching usb port %s from host %s on usbip, with deviceid: %s", udev.busid, host, product_name);
+
+               for (int j=0; j < udev.bNumInterfaces; j++) {
+                       struct usb_interface uinf;
+
+                       ret = usbip_recv(sockfd, (void *) &uinf, sizeof(uinf));
+                       if (ret < 0) {
+                               err("recv usb_interface[%d]", j);
+                               return -1;
+                       }
+
+                       pack_usb_interface(0, &uinf);
+                       usbip_names_get_class(class_name, sizeof(class_name), uinf.bInterfaceClass,
+                                       uinf.bInterfaceSubClass, uinf.bInterfaceProtocol);
+
+                       dbg("interface %2d - %s", j, class_name);
+               }
+
+               attach_device(host, udev.busid);
+       }
+
+       return rep.ndev;
+}
+
+static int attach_devices_all(char *host)
+{
+       int ret;
+       int sockfd;
+
+       sockfd = tcp_connect(host, USBIP_PORT_STRING);
+       if(sockfd < 0) {
+               err("- %s failed", host);
+               return -1;
+       }
+
+       info("- %s", host);
+
+       ret = attach_exported_devices(host, sockfd);
+       if(ret < 0) {
+               err("query");
+               return -1;
+       }
+
+       close(sockfd);
+       return 0;
+}
+
+
+const char help_message[] = "\
+Usage: usbip [options]                         \n\
+       -a, --attach [host] [bus_id]            \n\
+               Attach a remote USB device.     \n\
+                                               \n\
+       -x, --attachall [host]          \n\
+               Attach all remote USB devices on the specific host.     \n\
+                                               \n\
+       -d, --detach [ports]                    \n\
+               Detach an imported USB device.  \n\
+                                               \n\
+       -l, --list [hosts]                      \n\
+               List exported USB devices.      \n\
+                                               \n\
+       -p, --port                              \n\
+               List virtual USB port status.   \n\
+                                               \n\
+       -D, --debug                             \n\
+               Print debugging information.    \n\
+                                               \n\
+       -v, --version                           \n\
+               Show version.                   \n\
+                                               \n\
+       -h, --help                              \n\
+               Print this help.                \n";
+
+static void show_help(void)
+{
+       printf("%s", help_message);
+}
+
+static int show_port_status(void)
+{
+       int ret;
+       struct usbip_imported_device *idev;
+
+       ret = usbip_vhci_driver_open();
+       if (ret < 0)
+               return ret;
+
+       for (int i = 0; i < vhci_driver->nports; i++) {
+               idev = &vhci_driver->idev[i];
+
+               if (usbip_vhci_imported_device_dump(idev) < 0)
+                       ret = -1;
+       }
+
+       usbip_vhci_driver_close();
+
+       return ret;
+}
+
+#define _GNU_SOURCE
+#include <getopt.h>
+static const struct option longopts[] = {
+       {"attach",      no_argument,    NULL, 'a'},
+       {"attachall",   no_argument,    NULL, 'x'},
+       {"detach",      no_argument,    NULL, 'd'},
+       {"port",        no_argument,    NULL, 'p'},
+       {"list",        no_argument,    NULL, 'l'},
+       {"version",     no_argument,    NULL, 'v'},
+       {"help",        no_argument,    NULL, 'h'},
+       {"debug",       no_argument,    NULL, 'D'},
+       {"syslog",      no_argument,    NULL, 'S'},
+       {NULL,          0,              NULL,  0}
+};
+
+int main(int argc, char *argv[])
+{
+       int ret;
+
+       enum {
+               cmd_attach = 1,
+               cmd_attachall,
+               cmd_detach,
+               cmd_port,
+               cmd_list,
+               cmd_help,
+               cmd_version
+       } cmd = 0;
+
+       usbip_use_stderr = 1;
+
+       if (geteuid() != 0)
+               g_warning("running non-root?");
+
+       ret = usbip_names_init(USBIDS_FILE);
+       if (ret)
+               notice("failed to open %s", USBIDS_FILE);
+
+       for (;;) {
+               int c;
+               int index = 0;
+
+               c = getopt_long(argc, argv, "adplvhDSx", longopts, &index);
+
+               if (c == -1)
+                       break;
+
+               switch(c) {
+                       case 'a':
+                               if (!cmd)
+                                       cmd = cmd_attach;
+                               else
+                                       cmd = cmd_help;
+                               break;
+                       case 'd':
+                               if (!cmd)
+                                       cmd = cmd_detach;
+                               else
+                                       cmd = cmd_help;
+                               break;
+                       case 'p':
+                               if (!cmd)
+                                       cmd = cmd_port;
+                               else cmd = cmd_help;
+                               break;
+                       case 'l':
+                               if (!cmd)
+                                       cmd = cmd_list;
+                               else
+                                       cmd = cmd_help;
+                               break;
+                       case 'v':
+                               if (!cmd)
+                                       cmd = cmd_version;
+                               else
+                                       cmd = cmd_help;
+                               break;
+                       case 'x':
+                               if(!cmd)
+                                       cmd = cmd_attachall;
+                               else
+                                       cmd = cmd_help;
+                               break;
+                       case 'h':
+                               cmd = cmd_help;
+                               break;
+                       case 'D':
+                               usbip_use_debug = 1;
+                               break;
+                       case 'S':
+                               usbip_use_syslog = 1;
+                               break;
+                       case '?':
+                               break;
+
+                       default:
+                               err("getopt");
+               }
+       }
+
+       ret = 0;
+       switch(cmd) {
+               case cmd_attach:
+                       if (optind == argc - 2)
+                               ret = attach_device(argv[optind], argv[optind+1]);
+                       else
+                               show_help();
+                       break;
+               case cmd_detach:
+                       while (optind < argc)
+                               ret = detach_port(argv[optind++]);
+                       break;
+               case cmd_port:
+                       ret = show_port_status();
+                       break;
+               case cmd_list:
+                       while (optind < argc)
+                               ret = show_exported_devices(argv[optind++]);
+                       break;
+               case cmd_attachall:
+                       while(optind < argc)
+                               ret = attach_devices_all(argv[optind++]);
+                       break;
+               case cmd_version:
+                       printf("%s\n", version);
+                       break;
+               case cmd_help:
+                       show_help();
+                       break;
+               default:
+                       show_help();
+       }
+
+
+       usbip_names_free();
+
+       exit((ret == 0) ? EXIT_SUCCESS : EXIT_FAILURE);
+}
diff --git a/drivers/staging/usbip/userspace/src/usbip_network.c b/drivers/staging/usbip/userspace/src/usbip_network.c
new file mode 100644 (file)
index 0000000..01be3c7
--- /dev/null
@@ -0,0 +1,251 @@
+/*
+ *
+ * Copyright (C) 2005-2007 Takahiro Hirofuchi
+ */
+
+#include "usbip_network.h"
+
+void pack_uint32_t(int pack, uint32_t *num)
+{
+       uint32_t i;
+
+       if (pack)
+               i = htonl(*num);
+       else
+               i = ntohl(*num);
+
+       *num = i;
+}
+
+void pack_uint16_t(int pack, uint16_t *num)
+{
+       uint16_t i;
+
+       if (pack)
+               i = htons(*num);
+       else
+               i = ntohs(*num);
+
+       *num = i;
+}
+
+void pack_usb_device(int pack, struct usb_device *udev)
+{
+       pack_uint32_t(pack, &udev->busnum);
+       pack_uint32_t(pack, &udev->devnum);
+       pack_uint32_t(pack, &udev->speed );
+
+       pack_uint16_t(pack, &udev->idVendor );
+       pack_uint16_t(pack, &udev->idProduct);
+       pack_uint16_t(pack, &udev->bcdDevice);
+}
+
+void pack_usb_interface(int pack __attribute__((unused)),
+                       struct usb_interface *udev __attribute__((unused)))
+{
+       /* uint8_t members need nothing */
+}
+
+
+static ssize_t usbip_xmit(int sockfd, void *buff, size_t bufflen, int sending)
+{
+       ssize_t total = 0;
+
+       if (!bufflen)
+               return 0;
+
+       do {
+               ssize_t nbytes;
+
+               if (sending)
+                       nbytes = send(sockfd, buff, bufflen, 0);
+               else
+                       nbytes = recv(sockfd, buff, bufflen, MSG_WAITALL);
+
+               if (nbytes <= 0)
+                       return -1;
+
+               buff    = (void *) ((intptr_t) buff + nbytes);
+               bufflen -= nbytes;
+               total   += nbytes;
+
+       } while (bufflen > 0);
+
+
+       return total;
+}
+
+ssize_t usbip_recv(int sockfd, void *buff, size_t bufflen)
+{
+       return usbip_xmit(sockfd, buff, bufflen, 0);
+}
+
+ssize_t usbip_send(int sockfd, void *buff, size_t bufflen)
+{
+       return usbip_xmit(sockfd, buff, bufflen, 1);
+}
+
+int usbip_send_op_common(int sockfd, uint32_t code, uint32_t status)
+{
+       int ret;
+       struct op_common op_common;
+
+       bzero(&op_common, sizeof(op_common));
+
+       op_common.version       = USBIP_VERSION;
+       op_common.code          = code;
+       op_common.status        = status;
+
+       PACK_OP_COMMON(1, &op_common);
+
+       ret = usbip_send(sockfd, (void *) &op_common, sizeof(op_common));
+       if (ret < 0) {
+               err("send op_common");
+               return -1;
+       }
+
+       return 0;
+}
+
+int usbip_recv_op_common(int sockfd, uint16_t *code)
+{
+       int ret;
+       struct op_common op_common;
+
+       bzero(&op_common, sizeof(op_common));
+
+       ret = usbip_recv(sockfd, (void *) &op_common, sizeof(op_common));
+       if (ret < 0) {
+               err("recv op_common, %d", ret);
+               goto err;
+       }
+
+       PACK_OP_COMMON(0, &op_common);
+
+       if (op_common.version != USBIP_VERSION) {
+               err("version mismatch, %d %d", op_common.version, USBIP_VERSION);
+               goto err;
+       }
+
+       switch(*code) {
+               case OP_UNSPEC:
+                       break;
+               default:
+                       if (op_common.code != *code) {
+                               info("unexpected pdu %d for %d", op_common.code, *code);
+                               goto err;
+                       }
+       }
+
+       if (op_common.status != ST_OK) {
+               info("request failed at peer, %d", op_common.status);
+               goto err;
+       }
+
+       *code = op_common.code;
+
+       return 0;
+err:
+       return -1;
+}
+
+
+int usbip_set_reuseaddr(int sockfd)
+{
+       const int val = 1;
+       int ret;
+
+       ret = setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val));
+       if (ret < 0)
+               err("setsockopt SO_REUSEADDR");
+
+       return ret;
+}
+
+int usbip_set_nodelay(int sockfd)
+{
+       const int val = 1;
+       int ret;
+
+       ret = setsockopt(sockfd, IPPROTO_TCP, TCP_NODELAY, &val, sizeof(val));
+       if (ret < 0)
+               err("setsockopt TCP_NODELAY");
+
+       return ret;
+}
+
+int usbip_set_keepalive(int sockfd)
+{
+       const int val = 1;
+       int ret;
+
+       ret = setsockopt(sockfd, SOL_SOCKET, SO_KEEPALIVE, &val, sizeof(val));
+       if (ret < 0)
+               err("setsockopt SO_KEEPALIVE");
+
+       return ret;
+}
+
+/* IPv6 Ready */
+/*
+ * moved here from vhci_attach.c
+ */
+int tcp_connect(char *hostname, char *service)
+{
+       struct addrinfo hints, *res, *res0;
+       int sockfd;
+       int err;
+
+
+       memset(&hints, 0, sizeof(hints));
+       hints.ai_socktype = SOCK_STREAM;
+
+       /* get all possible addresses */
+       err = getaddrinfo(hostname, service, &hints, &res0);
+       if (err) {
+               err("%s %s: %s", hostname, service, gai_strerror(err));
+               return -1;
+       }
+
+       /* try all the addresses */
+       for (res = res0; res; res = res->ai_next) {
+               char hbuf[NI_MAXHOST], sbuf[NI_MAXSERV];
+
+               err = getnameinfo(res->ai_addr, res->ai_addrlen,
+                               hbuf, sizeof(hbuf), sbuf, sizeof(sbuf), NI_NUMERICHOST | NI_NUMERICSERV);
+               if (err) {
+                       err("%s %s: %s", hostname, service, gai_strerror(err));
+                       continue;
+               }
+
+               dbg("trying %s port %s\n", hbuf, sbuf);
+
+               sockfd = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
+               if (sockfd < 0) {
+                       err("socket");
+                       continue;
+               }
+
+               /* should set TCP_NODELAY for usbip */
+               usbip_set_nodelay(sockfd);
+               /* TODO: write code for heatbeat */
+               usbip_set_keepalive(sockfd);
+
+               err = connect(sockfd, res->ai_addr, res->ai_addrlen);
+               if (err < 0) {
+                       close(sockfd);
+                       continue;
+               }
+
+               /* connected */
+               dbg("connected to %s:%s", hbuf, sbuf);
+               freeaddrinfo(res0);
+               return sockfd;
+       }
+
+
+       dbg("%s:%s, %s", hostname, service, "no destination to connect to");
+       freeaddrinfo(res0);
+
+       return -1;
+}
diff --git a/drivers/staging/usbip/userspace/src/usbip_network.h b/drivers/staging/usbip/userspace/src/usbip_network.h
new file mode 100644 (file)
index 0000000..1225466
--- /dev/null
@@ -0,0 +1,198 @@
+/*
+ * Copyright (C) 2005-2007 Takahiro Hirofuchi
+ */
+
+#ifndef _USBIP_NETWORK_H
+#define _USBIP_NETWORK_H
+
+#include "usbip.h"
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/tcp.h>
+
+
+/* -------------------------------------------------- */
+/* Define Protocol Format                             */
+/* -------------------------------------------------- */
+
+
+/* ---------------------------------------------------------------------- */
+/* Common header for all the kinds of PDUs. */
+struct op_common {
+       uint16_t version;
+
+#define OP_REQUEST     (0x80 << 8)
+#define OP_REPLY       (0x00 << 8)
+       uint16_t code;
+
+       /* add more error code */
+#define ST_OK  0x00
+#define ST_NA  0x01
+       uint32_t status; /* op_code status (for reply) */
+
+} __attribute__((packed));
+
+#define PACK_OP_COMMON(pack, op_common)  do {\
+       pack_uint16_t(pack, &(op_common)->version);\
+       pack_uint16_t(pack, &(op_common)->code   );\
+       pack_uint32_t(pack, &(op_common)->status );\
+} while (0)
+
+
+/* ---------------------------------------------------------------------- */
+/* Dummy Code */
+#define OP_UNSPEC      0x00
+#define OP_REQ_UNSPEC  OP_UNSPEC
+#define OP_REP_UNSPEC  OP_UNSPEC
+
+/* ---------------------------------------------------------------------- */
+/* Retrieve USB device information. (still not used) */
+#define OP_DEVINFO     0x02
+#define OP_REQ_DEVINFO (OP_REQUEST | OP_DEVINFO)
+#define OP_REP_DEVINFO (OP_REPLY   | OP_DEVINFO)
+
+struct op_devinfo_request {
+       char busid[SYSFS_BUS_ID_SIZE];
+} __attribute__((packed));
+
+struct op_devinfo_reply {
+       struct usb_device udev;
+       struct usb_interface uinf[];
+} __attribute__((packed));
+
+
+/* ---------------------------------------------------------------------- */
+/* Import a remote USB device. */
+#define OP_IMPORT      0x03
+#define OP_REQ_IMPORT  (OP_REQUEST | OP_IMPORT)
+#define OP_REP_IMPORT   (OP_REPLY   | OP_IMPORT)
+
+struct op_import_request {
+       char busid[SYSFS_BUS_ID_SIZE];
+} __attribute__((packed));
+
+struct op_import_reply {
+       struct usb_device udev;
+//     struct usb_interface uinf[];
+} __attribute__((packed));
+
+#define PACK_OP_IMPORT_REQUEST(pack, request)  do {\
+} while (0)
+
+#define PACK_OP_IMPORT_REPLY(pack, reply)  do {\
+       pack_usb_device(pack, &(reply)->udev);\
+} while (0)
+
+
+
+/* ---------------------------------------------------------------------- */
+/* Export a USB device to a remote host. */
+#define OP_EXPORT      0x06
+#define OP_REQ_EXPORT  (OP_REQUEST | OP_EXPORT)
+#define OP_REP_EXPORT  (OP_REPLY   | OP_EXPORT)
+
+struct op_export_request {
+       struct usb_device udev;
+} __attribute__((packed));
+
+struct op_export_reply {
+       int returncode;
+} __attribute__((packed));
+
+
+#define PACK_OP_EXPORT_REQUEST(pack, request)  do {\
+       pack_usb_device(pack, &(request)->udev);\
+} while (0)
+
+#define PACK_OP_EXPORT_REPLY(pack, reply)  do {\
+} while (0)
+
+/* ---------------------------------------------------------------------- */
+/* un-Export a USB device from a remote host. */
+#define OP_UNEXPORT    0x07
+#define OP_REQ_UNEXPORT        (OP_REQUEST | OP_UNEXPORT)
+#define OP_REP_UNEXPORT        (OP_REPLY   | OP_UNEXPORT)
+
+struct op_unexport_request {
+       struct usb_device udev;
+} __attribute__((packed));
+
+struct op_unexport_reply {
+       int returncode;
+} __attribute__((packed));
+
+#define PACK_OP_UNEXPORT_REQUEST(pack, request)  do {\
+       pack_usb_device(pack, &(request)->udev);\
+} while (0)
+
+#define PACK_OP_UNEXPORT_REPLY(pack, reply)  do {\
+} while (0)
+
+
+
+/* ---------------------------------------------------------------------- */
+/* Negotiate IPSec encryption key. (still not used) */
+#define OP_CRYPKEY     0x04
+#define OP_REQ_CRYPKEY (OP_REQUEST | OP_CRYPKEY)
+#define OP_REP_CRYPKEY (OP_REPLY   | OP_CRYPKEY)
+
+struct op_crypkey_request {
+       /* 128bit key */
+       uint32_t key[4];
+} __attribute__((packed));
+
+struct op_crypkey_reply {
+       uint32_t __reserved;
+} __attribute__((packed));
+
+
+/* ---------------------------------------------------------------------- */
+/* Retrieve the list of exported USB devices. */
+#define OP_DEVLIST     0x05
+#define OP_REQ_DEVLIST (OP_REQUEST | OP_DEVLIST)
+#define OP_REP_DEVLIST (OP_REPLY   | OP_DEVLIST)
+
+struct op_devlist_request {
+} __attribute__((packed));
+
+struct op_devlist_reply {
+       uint32_t ndev;
+       /* followed by reply_extra[] */
+} __attribute__((packed));
+
+struct op_devlist_reply_extra {
+       struct usb_device    udev;
+       struct usb_interface uinf[];
+} __attribute__((packed));
+
+#define PACK_OP_DEVLIST_REQUEST(pack, request)  do {\
+} while (0)
+
+#define PACK_OP_DEVLIST_REPLY(pack, reply)  do {\
+       pack_uint32_t(pack, &(reply)->ndev);\
+} while (0)
+
+
+/* -------------------------------------------------- */
+/* Declare Prototype Function                         */
+/* -------------------------------------------------- */
+
+void pack_uint32_t(int pack, uint32_t *num);
+void pack_uint16_t(int pack, uint16_t *num);
+void pack_usb_device(int pack, struct usb_device *udev);
+void pack_usb_interface(int pack, struct usb_interface *uinf);
+
+ssize_t usbip_recv(int sockfd, void *buff, size_t bufflen);
+ssize_t usbip_send(int sockfd, void *buff, size_t bufflen);
+int usbip_send_op_common(int sockfd, uint32_t code, uint32_t status);
+int usbip_recv_op_common(int sockfd, uint16_t *code);
+int usbip_set_reuseaddr(int sockfd);
+int usbip_set_nodelay(int sockfd);
+int usbip_set_keepalive(int sockfd);
+
+int tcp_connect(char *hostname, char *service);
+
+#define USBIP_PORT 3240
+#define USBIP_PORT_STRING "3240"
+
+#endif
diff --git a/drivers/staging/usbip/userspace/src/usbipd.c b/drivers/staging/usbip/userspace/src/usbipd.c
new file mode 100644 (file)
index 0000000..ec9faac
--- /dev/null
@@ -0,0 +1,570 @@
+/*
+ *
+ * Copyright (C) 2005-2007 Takahiro Hirofuchi
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "../config.h"
+#endif
+
+#include <unistd.h>
+#include <netdb.h>
+#include <strings.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <arpa/inet.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+
+#ifdef HAVE_LIBWRAP
+#include <tcpd.h>
+#endif
+
+#define _GNU_SOURCE
+#include <getopt.h>
+#include <signal.h>
+
+#include "usbip.h"
+#include "usbip_network.h"
+
+#include <glib.h>
+
+static const char version[] = PACKAGE_STRING;
+
+
+static int send_reply_devlist(int sockfd)
+{
+       int ret;
+       struct usbip_exported_device *edev;
+       struct op_devlist_reply reply;
+
+
+       reply.ndev = 0;
+
+       /* how many devices are exported ? */
+       dlist_for_each_data(stub_driver->edev_list, edev, struct usbip_exported_device) {
+               reply.ndev += 1;
+       }
+
+       dbg("%d devices are exported", reply.ndev);
+
+       ret = usbip_send_op_common(sockfd, OP_REP_DEVLIST,  ST_OK);
+       if (ret < 0) {
+               err("send op_common");
+               return ret;
+       }
+
+       PACK_OP_DEVLIST_REPLY(1, &reply);
+
+       ret = usbip_send(sockfd, (void *) &reply, sizeof(reply));
+       if (ret < 0) {
+               err("send op_devlist_reply");
+               return ret;
+       }
+
+       dlist_for_each_data(stub_driver->edev_list, edev, struct usbip_exported_device) {
+               struct usb_device pdu_udev;
+
+               dump_usb_device(&edev->udev);
+               memcpy(&pdu_udev, &edev->udev, sizeof(pdu_udev));
+               pack_usb_device(1, &pdu_udev);
+
+               ret = usbip_send(sockfd, (void *) &pdu_udev, sizeof(pdu_udev));
+               if (ret < 0) {
+                       err("send pdu_udev");
+                       return ret;
+               }
+
+               for (int i=0; i < edev->udev.bNumInterfaces; i++) {
+                       struct usb_interface pdu_uinf;
+
+                       dump_usb_interface(&edev->uinf[i]);
+                       memcpy(&pdu_uinf, &edev->uinf[i], sizeof(pdu_uinf));
+                       pack_usb_interface(1, &pdu_uinf);
+
+                       ret = usbip_send(sockfd, (void *) &pdu_uinf, sizeof(pdu_uinf));
+                       if (ret < 0) {
+                               err("send pdu_uinf");
+                               return ret;
+                       }
+               }
+       }
+
+       return 0;
+}
+
+
+static int recv_request_devlist(int sockfd)
+{
+       int ret;
+       struct op_devlist_request req;
+
+       bzero(&req, sizeof(req));
+
+       ret = usbip_recv(sockfd, (void *) &req, sizeof(req));
+       if (ret < 0) {
+               err("recv devlist request");
+               return -1;
+       }
+
+       ret = send_reply_devlist(sockfd);
+       if (ret < 0) {
+               err("send devlist reply");
+               return -1;
+       }
+
+       return 0;
+}
+
+
+static int recv_request_import(int sockfd)
+{
+       int ret;
+       struct op_import_request req;
+       struct op_common reply;
+       struct usbip_exported_device *edev;
+       int found = 0;
+       int error = 0;
+
+       bzero(&req, sizeof(req));
+       bzero(&reply, sizeof(reply));
+
+       ret = usbip_recv(sockfd, (void *) &req, sizeof(req));
+       if (ret < 0) {
+               err("recv import request");
+               return -1;
+       }
+
+       PACK_OP_IMPORT_REQUEST(0, &req);
+
+       dlist_for_each_data(stub_driver->edev_list, edev, struct usbip_exported_device) {
+               if (!strncmp(req.busid, edev->udev.busid, SYSFS_BUS_ID_SIZE)) {
+                       dbg("found requested device %s", req.busid);
+                       found = 1;
+                       break;
+               }
+       }
+
+       if (found) {
+               /* should set TCP_NODELAY for usbip */
+               usbip_set_nodelay(sockfd);
+
+               /* export_device needs a TCP/IP socket descriptor */
+               ret = usbip_stub_export_device(edev, sockfd);
+               if (ret < 0)
+                       error = 1;
+       } else {
+               info("not found requested device %s", req.busid);
+               error = 1;
+       }
+
+
+       ret = usbip_send_op_common(sockfd, OP_REP_IMPORT, (!error ? ST_OK : ST_NA));
+       if (ret < 0) {
+               err("send import reply");
+               return -1;
+       }
+
+       if (!error) {
+               struct usb_device pdu_udev;
+
+               memcpy(&pdu_udev, &edev->udev, sizeof(pdu_udev));
+               pack_usb_device(1, &pdu_udev);
+
+               ret = usbip_send(sockfd, (void *) &pdu_udev, sizeof(pdu_udev));
+               if (ret < 0) {
+                       err("send devinfo");
+                       return -1;
+               }
+       }
+
+       return 0;
+}
+
+
+
+static int recv_pdu(int sockfd)
+{
+       int ret;
+       uint16_t code = OP_UNSPEC;
+
+
+       ret = usbip_recv_op_common(sockfd, &code);
+       if (ret < 0) {
+               err("recv op_common, %d", ret);
+               return ret;
+       }
+
+
+       ret = usbip_stub_refresh_device_list();
+       if (ret < 0)
+               return -1;
+
+       switch(code) {
+               case OP_REQ_DEVLIST:
+                       ret = recv_request_devlist(sockfd);
+                       break;
+
+               case OP_REQ_IMPORT:
+                       ret = recv_request_import(sockfd);
+                       break;
+
+               case OP_REQ_DEVINFO:
+               case OP_REQ_CRYPKEY:
+
+               default:
+                       err("unknown op_code, %d", code);
+                       ret = -1;
+       }
+
+
+       return ret;
+}
+
+
+
+
+static void log_addrinfo(struct addrinfo *ai)
+{
+       int ret;
+       char hbuf[NI_MAXHOST];
+       char sbuf[NI_MAXSERV];
+
+       ret = getnameinfo(ai->ai_addr, ai->ai_addrlen, hbuf, sizeof(hbuf),
+                       sbuf, sizeof(sbuf), NI_NUMERICHOST | NI_NUMERICSERV);
+       if (ret)
+               err("getnameinfo, %s", gai_strerror(ret));
+
+       info("listen at [%s]:%s", hbuf, sbuf);
+}
+
+static struct addrinfo *my_getaddrinfo(char *host, int ai_family)
+{
+       int ret;
+       struct addrinfo hints, *ai_head;
+
+       bzero(&hints, sizeof(hints));
+
+       hints.ai_family   = ai_family;
+       hints.ai_socktype = SOCK_STREAM;
+       hints.ai_flags    = AI_PASSIVE;
+
+       ret = getaddrinfo(host, USBIP_PORT_STRING, &hints, &ai_head);
+       if (ret) {
+               err("%s: %s", USBIP_PORT_STRING, gai_strerror(ret));
+               return NULL;
+       }
+
+       return ai_head;
+}
+
+#define MAXSOCK 20
+static int listen_all_addrinfo(struct addrinfo *ai_head, int lsock[])
+{
+       struct addrinfo *ai;
+       int n = 0;              /* number of sockets */
+
+       for (ai = ai_head; ai && n < MAXSOCK; ai = ai->ai_next) {
+               int ret;
+
+               lsock[n] = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
+               if (lsock[n] < 0)
+                       continue;
+
+               usbip_set_reuseaddr(lsock[n]);
+               usbip_set_nodelay(lsock[n]);
+
+               if (lsock[n] >= FD_SETSIZE) {
+                       close(lsock[n]);
+                       lsock[n] = -1;
+                       continue;
+               }
+
+               ret = bind(lsock[n], ai->ai_addr, ai->ai_addrlen);
+               if (ret < 0) {
+                       close(lsock[n]);
+                       lsock[n] = -1;
+                       continue;
+               }
+
+               ret = listen(lsock[n], SOMAXCONN);
+               if (ret < 0) {
+                       close(lsock[n]);
+                       lsock[n] = -1;
+                       continue;
+               }
+
+               log_addrinfo(ai);
+
+               /* next if succeed */
+               n++;
+       }
+
+       if (n == 0) {
+               err("no socket to listen to");
+               return -1;
+       }
+
+       dbg("listen %d address%s", n, (n==1)?"":"es");
+
+       return n;
+}
+
+#ifdef HAVE_LIBWRAP
+static int tcpd_auth(int csock)
+{
+       int ret;
+       struct request_info request;
+
+       request_init(&request, RQ_DAEMON, "usbipd", RQ_FILE, csock, 0);
+
+       fromhost(&request);
+
+       ret = hosts_access(&request);
+       if (!ret)
+               return -1;
+
+       return 0;
+}
+#endif
+
+static int my_accept(int lsock)
+{
+       int csock;
+       struct sockaddr_storage ss;
+       socklen_t len = sizeof(ss);
+       char host[NI_MAXHOST], port[NI_MAXSERV];
+       int ret;
+
+       bzero(&ss, sizeof(ss));
+
+       csock = accept(lsock, (struct sockaddr *) &ss, &len);
+       if (csock < 0) {
+               err("accept");
+               return -1;
+       }
+
+       ret = getnameinfo((struct sockaddr *) &ss, len,
+                       host, sizeof(host), port, sizeof(port),
+                       (NI_NUMERICHOST | NI_NUMERICSERV));
+       if (ret)
+               err("getnameinfo, %s", gai_strerror(ret));
+
+#ifdef HAVE_LIBWRAP
+       ret = tcpd_auth(csock);
+       if (ret < 0) {
+               info("deny access from %s", host);
+               close(csock);
+               return -1;
+       }
+#endif
+
+       info("connected from %s:%s", host, port);
+
+       return csock;
+}
+
+
+GMainLoop *main_loop;
+
+static void signal_handler(int i)
+{
+       dbg("signal catched, code %d", i);
+
+       if (main_loop)
+               g_main_loop_quit(main_loop);
+}
+
+static void set_signal(void)
+{
+       struct sigaction act;
+
+       bzero(&act, sizeof(act));
+       act.sa_handler = signal_handler;
+       sigemptyset(&act.sa_mask);
+       sigaction(SIGTERM, &act, NULL);
+       sigaction(SIGINT, &act, NULL);
+}
+
+
+gboolean process_comming_request(GIOChannel *gio, GIOCondition condition,
+                                gpointer data __attribute__((unused)))
+{
+       int ret;
+
+       if (condition & (G_IO_ERR | G_IO_HUP | G_IO_NVAL))
+               g_error("unknown condition");
+
+
+       if (condition & G_IO_IN) {
+               int lsock;
+               int csock;
+
+               lsock = g_io_channel_unix_get_fd(gio);
+
+               csock = my_accept(lsock);
+               if (csock < 0)
+                       return TRUE;
+
+               ret = recv_pdu(csock);
+               if (ret < 0)
+                       err("process recieved pdu");
+
+               close(csock);
+       }
+
+       return TRUE;
+}
+
+
+static void do_standalone_mode(gboolean daemonize)
+{
+       int ret;
+       int lsock[MAXSOCK];
+       struct addrinfo *ai_head;
+       int n;
+
+
+
+       ret = usbip_names_init(USBIDS_FILE);
+       if (ret)
+               err("open usb.ids");
+
+       ret = usbip_stub_driver_open();
+       if (ret < 0)
+               g_error("driver open failed");
+
+       if (daemonize) {
+               if (daemon(0,0) < 0)
+                       g_error("daemonizing failed: %s", g_strerror(errno));
+
+               usbip_use_syslog = 1;
+       }
+
+       set_signal();
+
+       ai_head = my_getaddrinfo(NULL, PF_UNSPEC);
+       if (!ai_head)
+               return;
+
+       n = listen_all_addrinfo(ai_head, lsock);
+       if (n <= 0)
+               g_error("no socket to listen to");
+
+       for (int i = 0; i < n; i++) {
+               GIOChannel *gio;
+
+               gio = g_io_channel_unix_new(lsock[i]);
+               g_io_add_watch(gio, (G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL),
+                               process_comming_request, NULL);
+       }
+
+
+       info("usbipd start (%s)", version);
+
+
+       main_loop = g_main_loop_new(FALSE, FALSE);
+       g_main_loop_run(main_loop);
+
+       info("shutdown");
+
+       freeaddrinfo(ai_head);
+       usbip_names_free();
+       usbip_stub_driver_close();
+
+       return;
+}
+
+
+static const char help_message[] = "\
+Usage: usbipd [options]                                \n\
+       -D, --daemon                            \n\
+               Run as a daemon process.        \n\
+                                               \n\
+       -d, --debug                             \n\
+               Print debugging information.    \n\
+                                               \n\
+       -v, --version                           \n\
+               Show version.                   \n\
+                                               \n\
+       -h, --help                              \n\
+               Print this help.                \n";
+
+static void show_help(void)
+{
+       printf("%s", help_message);
+}
+
+static const struct option longopts[] = {
+       {"daemon",      no_argument,    NULL, 'D'},
+       {"debug",       no_argument,    NULL, 'd'},
+       {"version",     no_argument,    NULL, 'v'},
+       {"help",        no_argument,    NULL, 'h'},
+       {NULL,          0,              NULL,  0}
+};
+
+int main(int argc, char *argv[])
+{
+       gboolean daemonize = FALSE;
+
+       enum {
+               cmd_standalone_mode = 1,
+               cmd_help,
+               cmd_version
+       } cmd = cmd_standalone_mode;
+
+
+       usbip_use_stderr = 1;
+       usbip_use_syslog = 0;
+
+       if (geteuid() != 0)
+               g_warning("running non-root?");
+
+       for (;;) {
+               int c;
+               int index = 0;
+
+               c = getopt_long(argc, argv, "vhdD", longopts, &index);
+
+               if (c == -1)
+                       break;
+
+               switch (c) {
+                       case 'd':
+                               usbip_use_debug = 1;
+                               continue;
+                       case 'v':
+                               cmd = cmd_version;
+                               break;
+                       case 'h':
+                               cmd = cmd_help;
+                               break;
+                       case 'D':
+                               daemonize = TRUE;
+                               break;
+                       case '?':
+                               show_help();
+                               exit(EXIT_FAILURE);
+                       default:
+                               err("getopt");
+               }
+       }
+
+       switch (cmd) {
+               case cmd_standalone_mode:
+                       do_standalone_mode(daemonize);
+                       break;
+               case cmd_version:
+                       printf("%s\n", version);
+                       break;
+               case cmd_help:
+                       show_help();
+                       break;
+               default:
+                       info("unknown cmd");
+                       show_help();
+       }
+
+       return 0;
+}
diff --git a/drivers/staging/usbip/userspace/src/utils.c b/drivers/staging/usbip/userspace/src/utils.c
new file mode 100644 (file)
index 0000000..8f44108
--- /dev/null
@@ -0,0 +1,255 @@
+/*
+ *
+ * Copyright (C) 2005-2007 Takahiro Hirofuchi
+ */
+
+#include "utils.h"
+
+int read_integer(char *path)
+{
+       char buff[100];
+       int fd;
+       int ret = 0;
+
+       bzero(buff, sizeof(buff));
+
+       fd = open(path, O_RDONLY);
+       if (fd < 0)
+               return -1;
+
+       ret = read(fd, buff, sizeof(buff));
+       if (ret < 0) {
+               close(fd);
+               return -1;
+       }
+
+       sscanf(buff, "%d", &ret);
+
+       close(fd);
+
+       return ret;
+}
+
+int read_string(char *path, char *string, size_t len)
+{
+       int fd;
+       int ret = 0;
+       char  *p;
+
+       bzero(string, len);
+
+       fd = open(path, O_RDONLY);
+       if (fd < 0) {
+               string = NULL;
+               return -1;
+       }
+
+       ret = read(fd, string, len-1);
+       if (ret < 0) {
+               string = NULL;
+               close(fd);
+               return -1;
+       }
+
+       p = strchr(string, '\n');
+       *p = '\0';
+
+       close(fd);
+
+       return 0;
+}
+
+int write_integer(char *path, int value)
+{
+       int fd;
+       int ret;
+       char buff[100];
+
+       snprintf(buff, sizeof(buff), "%d", value);
+
+       fd = open(path, O_WRONLY);
+       if (fd < 0)
+               return -1;
+
+       ret = write(fd, buff, strlen(buff));
+       if (ret < 0) {
+               close(fd);
+               return -1;
+       }
+
+       close(fd);
+
+       return 0;
+}
+
+int read_bConfigurationValue(char *busid)
+{
+       char path[PATH_MAX];
+
+       snprintf(path, PATH_MAX, "/sys/bus/usb/devices/%s/bConfigurationValue", busid);
+
+       return read_integer(path);
+}
+
+int write_bConfigurationValue(char *busid, int config)
+{
+       char path[PATH_MAX];
+
+       snprintf(path, PATH_MAX, "/sys/bus/usb/devices/%s/bConfigurationValue", busid);
+
+       return write_integer(path, config);
+}
+
+int read_bNumInterfaces(char *busid)
+{
+       char path[PATH_MAX];
+
+       snprintf(path, PATH_MAX, "/sys/bus/usb/devices/%s/bNumInterfaces", busid);
+
+       return read_integer(path);
+}
+
+int read_bDeviceClass(char *busid)
+{
+       char path[PATH_MAX];
+
+       snprintf(path, PATH_MAX, "/sys/bus/usb/devices/%s/bDeviceClass", busid);
+
+       return read_integer(path);
+}
+
+int getdriver(char *busid, int conf, int infnum, char *driver, size_t len)
+{
+       char path[PATH_MAX];
+       char linkto[PATH_MAX];
+       int ret;
+
+       snprintf(path, PATH_MAX, "/sys/bus/usb/devices/%s:%d.%d/driver", busid, conf, infnum);
+
+       /* readlink does not add NULL */
+       bzero(linkto, sizeof(linkto));
+       ret = readlink(path, linkto, sizeof(linkto)-1);
+       if (ret < 0) {
+               strncpy(driver, "none", len);
+               return -1;
+       } else {
+               strncpy(driver, basename(linkto), len);
+               return 0;
+       }
+}
+
+int getdevicename(char *busid, char *name, size_t len)
+{
+       char path[PATH_MAX];
+       char idProduct[10], idVendor[10];
+
+       snprintf(path, PATH_MAX, "/sys/bus/usb/devices/%s/idVendor", busid);
+       read_string(path, idVendor, sizeof(idVendor));
+
+       snprintf(path, PATH_MAX, "/sys/bus/usb/devices/%s/idProduct", busid);
+       read_string(path, idProduct, sizeof(idProduct));
+
+       if (!idVendor[0] || !idProduct[0])
+               return -1;
+
+       snprintf(name, len, "%s:%s", idVendor, idProduct);
+
+       return 0;
+}
+
+#define MAXLINE 100
+
+/* if this cannot read a whole line, return -1 */
+int readline(int sockfd, char *buff, int bufflen)
+{
+       int ret;
+       char c;
+       int index = 0;
+
+
+       while (index < bufflen) {
+               ret = read(sockfd, &c, sizeof(c));
+               if (ret < 0 && errno == EINTR)
+                       continue;
+               if (ret <= 0) {
+                       return -1;
+               }
+
+               buff[index] = c;
+
+               if ( index > 0 && buff[index-1] == '\r'  && buff[index] == '\n') {
+                       /* end of line */
+                       buff[index-1] = '\0';   /* get rid of delimitor */
+                       return index;
+               } else
+                       index++;
+       }
+
+       return -1;
+}
+
+#if 0
+int writeline(int sockfd, char *str, int strlen)
+{
+       int ret;
+       int index = 0;
+       int len;
+       char buff[MAXLINE];
+
+       if (strlen + 3 > MAXLINE)
+               return -1;
+
+       strncpy(buff, str, strlen);
+       buff[strlen+1] = '\r';
+       buff[strlen+2] = '\n';
+       buff[strlen+3] = '\0';
+
+       len = strlen + 3;
+
+       while (len > 0) {
+               ret = write(sockfd, buff+index, len);
+               if (ret <= 0) {
+                       return -1;
+               }
+
+               len -= ret;
+               index += ret;
+       }
+
+       return index;
+}
+#endif
+
+int writeline(int sockfd, char *str, int strlen)
+{
+       int ret;
+       int index = 0;
+       int len;
+       char buff[MAXLINE];
+
+       len = strnlen(str, strlen);
+
+       if (strlen + 2 > MAXLINE)
+               return -1;
+
+       memcpy(buff, str, strlen);
+       buff[strlen] = '\r';
+       buff[strlen+1] = '\n';          /* strlen+1 <= MAXLINE-1 */
+
+       len = strlen + 2;
+
+       while (len > 0) {
+               ret = write(sockfd, buff+index, len);
+               if (ret < 0 && errno == EINTR)
+                       continue;
+               if (ret <= 0) {
+                       return -1;
+               }
+
+               len -= ret;
+               index += ret;
+       }
+
+       return index;
+}
+
diff --git a/drivers/staging/usbip/userspace/src/utils.h b/drivers/staging/usbip/userspace/src/utils.h
new file mode 100644 (file)
index 0000000..6c29ae9
--- /dev/null
@@ -0,0 +1,38 @@
+
+#ifdef HAVE_CONFIG_H
+#include "../config.h"
+#endif
+
+#define _GNU_SOURCE
+#include <string.h>
+#include <sys/un.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+
+#include <sysfs/libsysfs.h>
+#include <glib.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <time.h>
+#include <errno.h>
+
+
+
+/* Be sync to kernel header */
+#define BUS_ID_SIZE 20
+
+int read_string(char *path, char *, size_t len);
+int read_integer(char *path);
+int getdevicename(char *busid, char *name, size_t len);
+int getdriver(char *busid, int conf, int infnum, char *driver, size_t len);
+int read_bNumInterfaces(char *busid);
+int read_bConfigurationValue(char *busid);
+int write_integer(char *path, int value);
+int write_bConfigurationValue(char *busid, int config);
+int read_bDeviceClass(char *busid);
+int readline(int sockfd, char *str, int strlen);
+int writeline(int sockfd, char *buff, int bufflen);
diff --git a/drivers/staging/usbip/userspace/usb.ids b/drivers/staging/usbip/userspace/usb.ids
new file mode 100644 (file)
index 0000000..b1f8744
--- /dev/null
@@ -0,0 +1,13209 @@
+#
+#      List of USB ID's
+#
+#      Maintained by Stephen J. Gowdy <gowdy@slac.stanford.edu>
+#      If you have any new entries, send them to the maintainer.
+#      Send entries as patches (diff -u old new).
+#      The latest version can be obtained from
+#              http://www.linux-usb.org/usb.ids
+#
+# $Id: usb.ids,v 1.346 2008/04/23 13:51:46 gowdy Exp $
+#
+
+# Vendors, devices and interfaces. Please keep sorted.
+
+# Syntax:
+# vendor  vendor_name
+#      device  device_name                             <-- single tab
+#              interface  interface_name               <-- two tabs
+
+0001  Fry's Electronics
+0002  Ingram
+0003  Club Mac
+0004  Nebraska Furniture Mart
+0145  Unknown
+       0112  Card Reader
+0204  Chipsbank Microelectronics Co., Ltd
+       6025  CBM2080 Flash drive controller
+       6026  CBM1180 Flash drive controller
+02ad  HUMAX Co., Ltd.
+       138c  PVR Mass Storage
+0386  LTS
+       0001  PSX for USB Converter
+03e8  EndPoints, Inc.
+       0004  SE401 WebCam
+       0008  101 Ethernet [klsi]
+       0015  USB ATAPI Enclosure
+       2123  SiPix StyleCam Deluxe
+       8004  Aox 99001
+03e9  Thesys Microelectronics
+03ea  Data Broadcasting Corp.
+03eb  Atmel Corp.
+       2002  Mass Storage Device
+       2015  at90usbkey sample firmware (HID keyboard)
+       2018  at90usbkey sample firmware (CDC ACM)
+       2019  stk525 sample firmware (microphone)
+       201c  at90usbkey sample firmware (HID mouse)
+       201d  at90usbkey sample firmware (HID generic)
+       2022  at90usbkey sample firmware (composite device)
+       2103  JTAG ICE mkII
+       2104  AVR ISP mkII
+       2107  AVR Dragon
+       2ffb  at90usb AVR DFU bootloader
+       2ffd  at89c5130/c5131 DFU bootloader
+       2fff  at89c5132/c51snd1c DFU bootloader
+       3301  at43301 4-port Hub
+       3312  4-port Hub
+       5601  at76c510 Prism-II 802.11b Access Point
+       5603  Cisco 7920 WiFi IP Phone
+       6124  at91sam SAMBA bootloader
+       7603  at76c503a D-Link DWL-120 802.11b Adapter
+       7604  FastVNET
+       7605  at76c503a 802.11b Adapter
+       7606  at76c505 802.11b Adapter
+       7611  at76c510 rfmd2948 802.11b Access Point
+       7613  WL-1130 USB
+       7614  AT76c505a Wireless Adapter
+03ec  Iwatsu America, Inc.
+03ed  Mitel Corp.
+03ee  Mitsumi
+       0000  CD-R/RW Drive
+       2501  eHome Infrared Receiver
+       2502  eHome Infrared Receiver
+       5609  Japanese Keyboard
+       641f  WIF-0402C Bluetooth Adapter
+       6438  Bluetooth Device
+       6440  WML-C52APR Bluetooth Adapter
+       6901  SmartDisk FDD
+       6902  Floppy Disk Drive
+       7500  CD-R/RW
+       ffff  Dongle with BlueCore in DFU mode
+03f0  Hewlett-Packard
+       0004  DeskJet 895c
+       0011  OfficeJet G55
+       0012  DeskJet 1125C Printer Port
+       0024  KU-0316 Keyboard
+       0101  ScanJet 4100c
+       0102  PhotoSmart S20
+       0104  DeskJet 880c/970c
+       0105  ScanJet 4200c
+       0107  CD-Writer Plus
+       010c  Multimedia Keyboard Hub
+       0111  G55xi Printer/Scanner/Copier
+       0117  LaserJet 3200
+       011c  hn210w 802.11b Adapter
+       011d  Integrated Bluetooth Module
+       0121  HP49g+ Calculator
+       0122  HID Internet Keyboard
+       0201  ScanJet 6200c
+       0202  PhotoSmart S20
+       0204  DeskJet 815c
+       0205  ScanJet 3300c
+       0207  CD-Writer Plus 8200e
+       020c  Multimedia Keyboard
+       0211  OfficeJet G85
+       0212  DeskJet 1220C
+       0217  LaserJet 2200
+       0218  APOLLO P2500/2600
+       2624  Pole Display (HP522 2 x 20 Line Display)
+       0304  DeskJet 810c/812c
+       0305  ScanJet 4300c
+       0307  CD-Writer+ CD-4e
+       0311  OfficeJet G85xi
+       0312  Color Inkjet CP1700
+       0314  designjet 30/130 series
+       0317  LaserJet 1200
+       0401  ScanJet 5200c
+       0404  DeskJet 830c/832c
+       0405  ScanJet 3400cse
+       0411  OfficeJet G95
+       0412  Printing Support
+       0417  LaserJet 1200 series
+       0504  DeskJet 885c
+       0505  ScanJet 2100c
+       0507  DVD+RW
+       050c  5219 Wireless Keyboard
+       0511  OfficeJet K60
+       0512  DeckJet 450
+       0517  LaserJet 1000
+       051d  integrated module with Bluetooth wireless technology.
+       0601  ScanJet 6300c
+       0604  DeskJet 840c
+       0605  ScanJet 2200c
+       0611  OfficeJet K60xi
+       0612  business inkjet 3000
+       0624  Bluetooth Dongle
+       0701  ScanJet 5300c/5370c
+       0704  DeskJet 825c
+       0705  ScanJet 4400c
+       0711  OfficeJet K80
+       0712  DeskJet 1180c
+       0714  Printing Support
+       0801  ScanJet 7400c
+       0804  DeskJet 816c
+       0805  HP4470C
+       0811  OfficeJet K80xi
+       0817  LaserJet 3300
+       0901  ScanJet 2300c
+       0904  DeskJet 845c
+       0912  Printing Support
+       0917  LaserJet 3330
+       0924  Modular Smartcard Keyboard
+       0a01  ScanJet 2400c
+       0a17  color LaserJet 3700
+       0b01  Scanjet 82x0C
+       0b17  Laserjet 2300d
+       0c17  LaserJet 1010
+       0c24  Bluetooth Dongle
+       0d12  Officejet 9100 series
+       0d17  LaserJet 1012
+       0e17  LaserJet 1015
+       0f11  OfficeJet V40
+       0f12  Printing Support
+       0f17  LaserJet 1150
+       1001  Photo Scanner 1000
+       1002  photosmart 140 series
+       1004  DeskJet 970c/970cse
+       1005  ScanJet 5400c
+       1011  OfficeJet V40xi
+       1016  Jornada 548 / iPAQ HW6515 Pocket PC
+       1017  LaserJet 1300
+       1024  Smart Card Keyboard
+       1102  photosmart 240 series
+       1104  DeskJet 959c
+       1105  ScanJet 5470c
+       1111  officejet v60
+       1116  Jornada 568 Pocket PC
+       1117  LaserJet 1300n
+       1151  PSC-750xi Printer/Scanner/Copier
+       1202  Photosmart 320 Series
+       1204  DeskJet 930c
+       1205  ScanJet 4500C/5550C
+       1211  officejet v60xi
+       1217  LaserJet 2300L
+       1302  Photosmart 370 Series
+       1305  ScanJet 4570c
+       1311  OfficeJet V30
+       1312  Deskjet 460
+       1317  LaserJet 1005
+       1405  Scanjet 3670
+       1411  PSC 750
+       1424  f2105 Monitor Hub
+       1502  Photosmart 420 Series
+       1504  DeskJet 920c
+       1511  PSC 750xi
+       1512  Printing Support
+       1517  color LaserJet 3500
+       1524  Smart Card Keyboard - KR
+       1602  Photosmart 330 Series
+       1604  DeskJet 940c
+       1605  ScanJet 5530C Photosmart
+       1611  psc 780
+       1617  LaserJet 3015
+       161d  Wireless Rechargeable Optical Mouse (HID)
+       1624  Smart Card Keyboard - JP
+       1702  Photosmart 380 Series
+       1704  deskjet 948C
+       1705  ScanJet 5590
+       1711  psc 780xi
+       1712  Printing Support
+       1717  LaserJet 3020
+       171d  Wireless (Bluetooth + WLAN) Interface [Integrated Module]
+       1801  Inkjet P-2000U
+       1802  Photosmart 470 Series
+       1804  deskjet 916C
+       1805  ScanJet 7650
+       1811  PSC 720
+       1817  LaserJet 3030
+       181d  integrated module with Bluetooth 2.0 wireless technology.
+       1902  Photosmart A430 series
+       1904  DeskJet 3820
+       1911  OfficeJet V45
+       1917  LaserJet 3380
+       1a02  Photosmart A510 series
+       1a11  officejet 5100 series
+       1a17  color LaserJet 4650
+       1b02  Photosmart A610 series
+       1b04  deskjet 3810
+       1b05  ScanJet 4850C/4890C
+       1c02  Photosmart A710 series
+       1c17  Color LaserJet 2550l
+       1d02  Photosmart A310 series
+       1d17  LaserJet 1320
+       1e02  Photosmart A320 Printer series
+       1e11  PSC-950
+       1e17  LaserJet 1160 series
+       1f02  Photosmart A440 Printer series
+       1f11  PSC 920
+       1f12  Officejet Pro K5300
+       1f17  color LaserJet 5550
+       2001  Floppy
+       2002  Hub
+       2004  DeskJet 640c
+       2005  ScanJet 3570c
+       2012  Officejet Pro K5400
+       2102  photosmart 7345
+       2104  DeskJet 630c
+       2112  Officejet Pro L7500
+       2202  photosmart 7600 series
+       2205  ScanJet 3500c
+       2212  Officejet Pro L7600
+       2217  color LaserJet 9500 MFP
+       2302  photosmart 7600 series
+       2304  DeskJet 656c
+       2305  ScanJet 3970c
+       2311  officejet d series
+       2312  Officejet Pro L7700
+       2317  LaserJet 4350
+       2402  photosmart 7700 series
+       2405  ScanJet 4070 Photosmart
+       2417  LaserJet 4250
+       2424  LP1965 19" Monitor Hub
+       2502  photosmart 7700 series
+       2505  ScanJet 3770
+       2512  Officejet Pro L7300
+       2517  LaserJet 2410
+       2524  LP3065 30" Monitor Hub
+       2602  Photosmart A520 series
+       2605  ScanJet 3800c
+       2611  officejet 7100 series
+       2617  Color LaserJet 2820 Series
+       2702  Photosmart A620 series
+       2704  Deskjet 915
+       2717  Color LaserJet 2830
+       2811  PSC-2100
+       2817  Color LaserJet 2840
+       2902  Photosmart A820 series
+       2911  PSC 2200
+       2917  LaserJet 2420
+       2a11  PSC 2150 series
+       2a17  LaserJet 2430
+       2b11  PSC 2170 series
+       2b17  LaserJet 1020
+       2c17  Printing Support
+       2d11  OfficeJet 6110
+       2d17  Printing Support
+       2e11  PSC 1000
+       2e17  Printing Support
+       2f11  PSC 1200
+       2f17  EWS 2605dn
+       3002  photosmart P1000
+       3004  deskjet 980c
+       3005  ScanJet 4670v
+       3011  PSC 1100 series
+       3017  Printing Support
+       3102  PhotoSmart P1100 Printer w/ Card Reader
+       3104  DeskJet 960c
+       3111  officejet 4100 series
+       3117  EWS 2605dtn
+       3202  photosmart 1215
+       3211  officejet 4105 series
+       3217  LaserJet 3050
+       3302  photosmart 1218
+       3304  DeskJet 990c
+       3317  LaserJet 3052
+       3402  photosmart 1115
+       3404  DeskJet 6122
+       3417  LaserJet 3055
+       3502  photosmart 230
+       3504  DeskJet 6127c
+       3511  PSC 2300
+       3517  LaserJet 3390
+       3602  photosmart 1315
+       3611  PSC 2410 Photosmart
+       3617  EWS 2605
+       3711  PSC 2500
+       3717  EWS UPD
+       3802  photosmart 100
+       3817  LaserJet P2015 Series
+       3902  photosmart 130
+       3a02  photosmart 7150
+       3a11  OfficeJet 5500 series
+       3a17  Printing Support
+       3b02  photosmart 7150~
+       3b11  PSC 1300 series
+       3b17  LaserJet M1005 MFP
+       3c02  PhotoSmart 7350
+       3c11  PSC 1358
+       3c17  EWS UPD
+       3d02  photosmart 7350~
+       3d11  OfficeJet 4215
+       3e02  photosmart 7550
+       3f02  photosmart 7550~
+       3f11  PSC-1315/PSC-1317
+       4002  PhotoSmart 720 / PhotoSmart 935 (storage)
+       4004  cp1160
+       4102  PhotoSmart 618
+       4105  ScanJet 4370
+       4111  Officejet 7200 series
+       4117  Printing Support
+       4202  PhotoSmart 812
+       4205  Scanjet G3010
+       4211  Officejet 7300 series
+       4217  EWS CM1015
+       4302  PhotoSmart 850 (ptp)
+       4311  Officejet 7400 series
+       4317  Color LaserJet CM1017
+       4402  PhotoSmart 935 (ptp)
+       4417  EWS UPD
+       4502  PhotoSmart 945 (PTP mode)
+       4505  ScanJet G4010
+       4511  Photosmart 2600
+       4517  EWS UPD
+       4605  ScanJet G4050
+       4611  Photosmart 2700
+       4811  PSC 1600
+       4911  PSC 2350
+       4b11  Officejet 6200
+       4c11  PSC 1500 series
+       4c17  EWS UPD
+       4d11  PSC 1400
+       4d17  EWS UPD
+       4e11  Photosmart 2570 series
+       4f11  Officejet 5600 (USBHUB)
+       5004  DeskJet 995c
+       5011  Photosmart 3100 Series
+       5017  EWS UPD
+       5111  Photosmart 3200 Series
+       5211  Photosmart 3300 Series
+       5311  Officejet 6300
+       5411  Officejet 4300
+       5511  Deskjet F300 series
+       5611  PhotoSmart C3180
+       5617  LaserJet M1120 MFP
+       5711  Photosmart C4100 series
+       5717  LaserJet M1120n MFP
+       5811  Photosmart C5100 series
+       5817  LaserJet M1319f MFP
+       5911  PhotoSmart C6180
+       5a11  Photosmart C7100 series
+       5b11  Officejet J2100 Series
+       5c11  Photosmart C4200 Printer series
+       5d11  Photosmart C5200 series
+       5e11  Photosmart D7400 series
+       6004  DeskJet 5550
+       6102  Hewlett Packard Digital Camera
+       6104  DeskJet 5650c
+       6117  color LaserJet 3550
+       6202  PhotoSmart 215
+       6204  DeskJet 5150c
+       6217  Color LaserJet 4700
+       6302  PhotoSmart 318/612
+       6317  Color LaserJet 4730mfp
+       6402  PhotoSmart 715 (ptp)
+       6411  Photosmart C8100 series
+       6417  LaserJet 5200
+       6502  PhotoSmart 120 (ptp)
+       6511  Photosmart C7200 series
+       6602  PhotoSmart 320
+       6611  Photosmart C4380 series
+       6617  LaserJet 5200L
+       6702  PhotoSmart 720 (ptp)
+       6717  Color LaserJet 3000
+       6802  PhotoSmart 620 (ptp)
+       6811  Photosmart D5300 series
+       6817  Color LaserJet 3800
+       6911  Photosmart D7200 series
+       6917  Color LaserJet 3600
+       6a02  PhotoSmart 735 (ptp)
+       6a11  Photosmart C6200 series
+       6a17  LaserJet 4240
+       6b02  PhotoSmart R707 (PTP mode)
+       6c17  Color LaserJet 4610
+       6f17  Color LaserJet CP6015 series
+       7004  DeskJet 3320c
+       7102  PhotoSmart 635 (PTP mode)
+       7104  DeskJet 3420c
+       7117  CM8060 Color MFP with Edgeline Technology
+       7202  PhotoSmart 43x (ptp)
+       7204  DeskJet 36xx
+       7217  LaserJet M5035 MFP
+       7302  PhotoSmart M307 (PTP mode)
+       7304  DeskJet 35xx
+       7317  LaserJet P3005
+       7404  Printing Support
+       7417  LaserJet M4345 MFP
+       7504  Printing Support
+       7517  LaserJet M3035 MFP
+       7604  Deskjet 3940
+       7617  LaserJet P3004
+       7702  PhotoSmart R817 (PTP mode)
+       7704  Deskjet D4100
+       7717  CM8050 Color MFP with Edgeline Technology
+       7804  Deskjet D1360
+       7817  Color LaserJet CP3505
+       7917  LaserJet M5025 MFP
+       7a02  PhotoSmart M415 (PTP mode)
+       7a17  LaserJet M3027 MFP
+       7b02  PhotoSmart M23 (PTP mode)
+       7b17  Color LaserJet CP4005
+       7c17  Color LaserJet CM6040 Series
+       7d04  Deskjet F2100 Printer series
+       7d17  Color LaserJet CM4730 MFP
+       7e04  Deskjet F4100 Printer series
+       8017  LaserJet P4515
+       8104  Printing Support
+       8117  LaserJet P4015
+       811c  Ethernet HN210E
+       8204  Printing Support
+       8217  LaserJet P4014
+       8317  LaserJet M9050 MFP
+       8404  Deskjet 6800 Series
+       8417  LaserJet M9040 MFP
+       8504  Deskjet 6600 Series
+       8604  Deskjet 5440
+       8704  deskjet 5900 series
+       8804  Deskjet 6980 Series
+       8904  Deskjet 6940 Series
+       9002  Photosmart M437
+       9102  Photosmart M537
+       9302  Photosmart R930 series
+       9402  Photosmart R837
+       9502  Photosmart R840 series
+       9602  Photosmart M730 series
+       9702  Photosmart R740 series
+       9802  Photosmart Mz60 series
+       9902  Photosmart M630 series
+       9a02  Photosmart E330 series
+       9b02  Photosmart M540 series
+       9c02  Photosmart M440 series
+       a004  DeskJet 5850c
+       b002  photosmart 7200 series
+       b102  photosmart 7200 series
+       b202  photosmart 7600 series
+       b302  photosmart 7600 series
+       b402  photosmart 7700 series
+       b502  photosmart 7700 series
+       b602  photosmart 7900 series
+       b702  photosmart 7900 series
+       b802  Photosmart 7400 Series
+       b902  Photosmart 7800 Series
+       ba02  Photosmart 8100 Series
+       bb02  Photosmart 8400 Series
+       bc02  Photosmart 8700 Series
+       bd02  Photosmart Pro B9100 series
+       bef4  NEC Picty760
+       c002  Photosmart 7800 Series
+       c102  Photosmart 8000 Series
+       c202  Photosmart 8200 Series
+       c302  Deskjet D2300
+       c402  Photosmart D5100 series
+       c502  Photosmart D6100 series
+       c602  Photosmart D7100 series
+       c702  Photosmart D7300 series
+       c802  Photosmart D5060 Printer
+       d104  Bluetooth Dongle
+       efbe  NEC Picty900
+       f0be  NEC Picty920
+       f1be  NEC Picty800
+03f1  Genoa Technology
+03f2  Oak Technology, Inc.
+03f3  Adaptec, Inc.
+       0020  AWN-8020 WLAN
+       0080  AVC-1100 Audio Capture
+       0083  AVC-2200 Device
+       0087  AVC-2210 Loader
+       0088  AVC-2210 Device
+       008b  AVC-2310 Loader
+       008c  AVC-2310 Device
+       0094  eHome Infrared Receiver
+       009b  AVC-1410 GameBridge TV NTSC
+       2000  USBXchange
+       2001  USBXchange Adapter
+       2002  USB2-Xchange
+       2003  USB2-Xchange Adapter
+       adcc  Composite Device Support
+03f4  Diebold, Inc.
+03f5  Siemens Electromechanical
+03f8  Epson Imaging Technology Center
+03f9  KeyTronic Corp.
+       0100  Keyboard
+       0101  Keyboard
+       0102  Keyboard Mouse
+03fb  OPTi, Inc.
+03fc  Elitegroup Computer Systems
+03fd  Xilinx, Inc.
+03fe  Farallon Comunications
+0400  National Semiconductor Corp.
+       0807  Bluetooth Dongle
+       080a  Bluetooth Device
+       1000  Mustek BearPaw 1200 Scanner
+       1001  Mustek BearPaw 2400 Scanner
+       1237  Hub
+       a000  Smart Display Reference Device
+       c35b  Printing Support
+0401  National Registry, Inc.
+0402  ALi Corp.
+       5462  M5462 IDE Controller
+       5602  Video Camera Controller
+       5603  USB 2.0 Q-tec Webcam 300
+       5621  USB 2.0 Storage Device
+       5623  VistaScan Astra 3600
+       5627  Welland ME-740PS USB2 3.5" Power Saving Enclosure
+       5632  USB 2.0 Host-to-Host Link
+       5635  USB 2.0 Flash Card Reader
+       5636  USB 2.0 Storage Device
+       5637  M5637 IDE Controller
+0403  Future Technology Devices International, Ltd
+       0000  H4SMK 7 Port Hub
+       0232  Serial Converter
+       6001  FT232 USB-Serial (UART) IC
+       6007  Serial Converter
+       6008  Serial Converter
+       6009  Serial Converter
+       6010  FT2232C Dual USB-UART/FIFO IC
+       8040  4 Port Hub
+       8070  7 Port Hub
+       8370  7 Port Hub
+       8371  PS/2 Keyboard And Mouse
+       8372  FT8U100AX Serial Port
+       c630  lcd2usb interface
+       c7d0  RR-CirKits LocoBuffer-USB
+       cc48  product FTDI TACTRIX_OPENPORT_13M 0xcc48 OpenPort 1.3 Mitsubishi
+       cc49  product FTDI TACTRIX_OPENPORT_13S 0xcc49 OpenPort 1.3 Subaru
+       cc4a  product FTDI TACTRIX_OPENPORT_13U 0xcc4a OpenPort 1.3 Universal
+       d010  SCS PTC-IIusb
+       d011  SCS Position-Tracker/TNC
+       d012  SCS DRAGON 1
+       d013  SCS DRAGON 1
+       d6f8  UNI Black BOX
+       e700  Elster Unicom III Optical Probe
+       e888  Expert ISDN Control USB
+       e889  USB-RS232 OptoBridge
+       e88a  Expert mouseCLOCK USB II
+       e88b  Precision Clock MSF USB
+       e88c  Expert mouseCLOCK USB II HBG
+       ea90  Eclo 1-Wire Adapter
+       f208  Papenmeier Braille-Display
+       f680  Suunto Sports Instrument
+       f918  Ant8 Logic Probe
+       fa00  Matrix Orbital USB Serial
+       fa01  Matrix Orbital MX2 or MX3
+       fa02  Matrix Orbital MX4 or MX5
+       fa03  Matrix Orbital VK/LK202 Family
+       fa04  Matrix Orbital VK/LK204 Family
+       fc08  Crystalfontz CFA-632 USB LCD
+       fc09  Crystalfontz CFA-634 USB LCD
+       fc0b  Crystalfontz CFA-633 USB LCD
+       fc0c  Crystalfontz CFA-631 USB LCD
+       fc0d  Crystalfontz CFA-635 USB LCD
+       fc82  SEMC DSS-20 SyncStation
+       fd48  ShipModul MiniPlex-4xUSB NMEA Multiplexer
+       ff08  ToolHouse LoopBack Adapter
+       ff18  Logbook Bus
+       ff19  Logbook Bus
+       ff1a  Logbook Bus
+       ff1b  Logbook Bus
+       ff1c  Logbook Bus
+       ff1d  Logbook Bus
+       ff1e  Logbook Bus
+       ff1f  Logbook Bus
+0404  NCR Corp.
+       0202  78XX Scanner
+       0203  78XX Scanner - Embedded System
+       0310  K590 Printer, Self-Service
+       0311  7167 Printer, Receipt/Slip
+       0312  7197 Printer Receipt
+       0320  5932-USB Keyboard
+       0321  5953-USB Dynakey
+       0322  5932-USB Enhanced Keyboard
+       0323  5932-USB Enhanced Keyboard, Flash-Recovery/Download
+       0324  5953-USB Enhanced Dynakey
+       0325  5953-USB Enhanced Dynakey Flash-Recovery/Download
+       0328  K016: USB-MSR ISO 3-track MSR: POS Standard (See HID pages)
+       0329  K018: USB-MSR JIS 2-Track MSR: POS Standard
+       032a  K016: USB-MSR ISO 3-Track MSR: HID Keyboard Mode
+       032b  K016/K018: USB-MSR Flash-Recovery/Download
+0405  Synopsys, Inc.
+0406  Fujitsu-ICL Computers
+0407  Fujitsu Personal Systems, Inc.
+0408  Quanta Computer, Inc.
+0409  NEC Corp.
+       0011  PC98 Series Layout Keyboard Mouse
+       0012  ATerm IT75DSU ISDN TA
+       0014  Japanese Keyboard
+       0019  109 Japanese Keyboard with Bus-Powered Hub
+       001a  PC98 Series Layout Keyboard with Bus-Powered Hub
+       0025  Mini Keyboard with Bus-Powered Hub
+       0027  MultiSync Monitor
+       002c  Clik!-USB Drive
+       0034  109 Japanese Keyboard with One-touch start buttons
+       003f  Wireless Keyboard with One-touch start buttons
+       0040  Floppy
+       004e  SuperScript 1400 Series
+       004f  Wireless Keyboard with One-touch start buttons
+       0058  HighSpeed Hub
+       0059  HighSpeed Hub
+       005a  HighSpeed Hub
+       006a  Conceptronic USB Harddisk Box
+       0081  SuperScript 1400 Series
+       0082  SuperScript 1400 Series
+       0094  Japanese Keyboard with One-touch start buttons
+       0095  Japanese Keyboard
+       00a9  AtermIT21L 128K Support Standard
+       00aa  AtermITX72 128K Support Standard
+       00ab  AtermITX62 128K Support Standard
+       00ac  AtermIT42 128K Support Standard
+       00ae  INSMATEV70G-MAX Standard
+       00af  AtermITX70 128K Support Standard
+       00b0  AtermITX80 128K Support Standard
+       00b2  AtermITX80D 128K Support Standard
+       00c0  Wireless Remocon
+       00f7  Smart Display PK-SD10
+       011d  e228 Mobile Phone
+       0203  HID Audio Controls
+       55aa  Hub
+       55ab  Hub [iMac/iTouch kbd]
+       8010  Intellibase Hub
+       8011  Intellibase Hub
+       efbe  P!cty 900 [HP DJ]
+       f0be  P!cty 920 [HP DJ 812c]
+040a  Kodak Co.
+       0001  DVC-323
+       0002  DVC-325
+       0100  DC-220
+       0110  DC-260
+       0111  DC-265
+       0112  DC-290
+       0120  DC-240
+       0121  DC-240 (PTP firmware)
+       0130  DC-280
+       0131  DC-5000
+       0132  DC-3400
+       0140  DC-4800
+       0160  DC4800
+       0170  DX3900
+       0200  Digital Camera
+       0300  EZ-200
+       0400  MC3
+       0402  Digital Camera
+       0403  Z7590
+       0500  DX3500
+       0510  DX3600
+       0525  DX3215
+       0530  DX3700
+       0535  EasyShare CX4230 Camera
+       0540  LS420
+       0550  DX4900
+       0555  DX4330
+       0560  CX4200
+       0565  CX4210
+       0566  CX4300
+       0567  LS753
+       0568  LS443
+       0569  LS663
+       0570  DX6340
+       0571  CX6330
+       0572  DX6440
+       0573  CX6230
+       0574  CX6200
+       0575  DX6490
+       0576  DX4530
+       0577  DX7630
+       0578  CX7300/CX7310
+       0579  CX7220
+       057a  CX7330
+       057b  CX7430
+       057c  CX7530
+       057d  DX7440
+       057e  C300
+       057f  DX7590
+       0580  Z730
+       0581  Digital Camera
+       0582  Digital Camera
+       0583  Digital Camera
+       0584  CX6445
+       0585  Digital Camera
+       0586  CX7525
+       0587  Digital Camera
+       0588  Digital Camera
+       0589  EasyShare C360
+       058a  C310
+       058b  Digital Camera
+       058c  C330
+       058d  C340
+       058e  V530
+       058f  V550
+       0590  Digital Camera
+       0591  Digital Camera
+       0592  Digital Camera
+       0593  Digital Camera
+       0594  Digital Camera
+       0595  Digital Camera
+       0596  Digital Camera
+       0597  Digital Camera
+       0598  Digital Camera
+       0599  Digital Camera
+       059a  Digital Camera
+       059b  Digital Camera
+       059c  Digital Camera
+       059d  Digital Camera
+       059e  Digital Camera
+       059f  Digital Camera
+       05a0  Digital Camera
+       05a1  Digital Camera
+       05a2  Digital Camera
+       05a3  Digital Camera
+       05a4  Digital Camera
+       05a5  Digital Camera
+       05a6  Digital Camera
+       05a7  Digital Camera
+       05a8  Digital Camera
+       05a9  Digital Camera
+       05aa  Digital Camera
+       05ab  Digital Camera
+       05ac  Digital Camera
+       05ad  Digital Camera
+       05ae  Digital Camera
+       05af  Digital Camera
+       05b0  Digital Camera
+       05b1  Digital Camera
+       05b2  Digital Camera
+       05b3  EasyShare Z710 Camera
+       05b4  Digital Camera
+       05b5  Digital Camera
+       05b6  Digital Camera
+       05b7  Digital Camera
+       05b8  Digital Camera
+       05b9  Digital Camera
+       05ba  Digital Camera
+       05bb  Digital Camera
+       05bc  Digital Camera
+       05bd  Digital Camera
+       05be  Digital Camera
+       05bf  Digital Camera
+       05c0  Digital Camera
+       05c1  Digital Camera
+       05c2  Digital Camera
+       05c3  Digital Camera
+       05c4  Digital Camera
+       05c5  Digital Camera
+       4000  InkJet Color Printer
+       410d  EasyShare G600 Printer Dock
+       5010  Wireless Adapter
+       5012  DBT-220 Bluetooth Adapter
+       6001  i30
+       6002  i40
+       6003  i50
+       6004  i60
+       6005  i80
+040b  Weltrend Semiconductor
+       6510  Weltrend Bar Code Reader
+       6520  XBOX Xploder
+040c  VTech Computers, Ltd
+040d  VIA Technologies, Inc.
+       3184  VNT VT6656 USB-802.11 Wireless LAN Adapter
+       6205  USB 2.0 Card Reader
+040e  MCCI
+040f  Echo Speech Corp.
+0411  MelCo., Inc.
+       0001  LUA-TX Ethernet [pegasus]
+       0005  LUA-TX Ethernet
+       0006  WLI-USB-L11 Wireless LAN Adapter
+       0009  LUA2-TX Ethernet
+       000b  WLI-USB-L11G-WR Wireless LAN Adapter
+       000d  WLI-USB-L11G Wireless LAN Adapter
+       0012  LUA-KTX Ethernet
+       0013  USB2-IDE Adapter
+       0016  WLI-USB-S11 802.11b Adapter
+       0018  USB2-IDE Adapter
+       001c  USB-IDE Bridge: DUB-PxxG
+       0027  WLI-USB-KS11G 802.11b Adapter
+       003d  LUA-U2-KTX Ethernet
+       0044  WLI-USB-KB11 Wireless LAN Adapter
+       004d  WLI-USB-B11 Wireless LAN Adapter
+       0050  WLI2-USB2-G54 Wireless LAN Adapter
+       005e  WLI-U2-KG54-YB WLAN
+       0065  Python2 WDM Encoder
+       0066  WLI-U2-KG54 WLAN
+       0067  WLI-U2-KG54-AI WLAN
+       008b  Nintendo Wi-Fi
+       0091  WLI-U2-KAMG54 Wireless LAN Adapter
+       0092  WLI-U2-KAMG54 Bootloader
+       0097  WLI-U2-KG54-BB
+       00a9  WLI-U2-AMG54HP Wireless LAN Adapter
+       00aa  WLI-U2-AMG54HP Bootloader
+       00b3  PC-OP-RS1 RemoteStation
+       00ca  802.11n Network Adapter
+       00cb  WLI-U2-G300N 802.11n Adapter
+       00d8  WLI-U2-SG54HP
+       00d9  WLI-U2-G54HP
+       00da  WLI-U2-KG54L
+0412  Award Software International
+0413  Leadtek Research, Inc.
+       1310  WinFast TV - NTSC + FM
+       1311  WinFast TV - NTSC + MTS + FM
+       1312  WinFast TV - PAL BG + FM
+       1313  WinFast TV - PAL BG+TXT + FM
+       1314  WinFast TV Audio - PHP PAL I
+       1315  WinFast TV Audio - PHP PAL I+TXT
+       1316  WinFast TV Audio - PHP PAL DK
+       1317  WinFast TV Audio - PHP PAL DK+TXT
+       1318  WinFast TV - PAL I/DK + FM
+       1319  WinFast TV - PAL N + FM
+       131a  WinFast TV Audio - PHP SECAM LL
+       131b  WinFast TV Audio - PHP SECAM LL+TXT
+       131c  WinFast TV Audio - PHP SECAM DK
+       131d  WinFast TV - SECAM DK + TXT + FM
+       131e  WinFast TV - NTSC Japan + FM
+       1320  WinFast TV - NTSC
+       1321  WinFast TV - NTSC + MTS
+       1322  WinFast TV - PAL BG
+       1323  WinFast TV - PAL BG+TXT
+       1324  WinFast TV Audio - PHP PAL I
+       1325  WinFast TV Audio - PHP PAL I+TXT
+       1326  WinFast TV Audio - PHP PAL DK
+       1327  WinFast TV Audio - PHP PAL DK+TXT
+       1328  WinFast TV - PAL I/DK
+       1329  WinFast TV - PAL N
+       132a  WinFast TV Audio - PHP SECAM LL
+       132b  WinFast TV Audio - PHP SECAM LL+TXT
+       132c  WinFast TV Audio - PHP SECAM DK
+       132d  WinFast TV - SECAM DK + TXT
+       132e  WinFast TV - NTSC Japan
+       6023  EMP Audio Device
+       6024  WinFast PalmTop/Novo TV Video
+       6025  WinFast DTV Dongle (cold state)
+       6026  WinFast DTV Dongle (warm state)
+       6125  WinFast DTV Dongle
+       6126  WinFast DTV Dongle BDA Driver
+       6f00  WinFast DTV Dongle (STK7700P based)
+0414  Giga-Byte Technology Co., Ltd
+0416  Winbond Electronics Corp.
+       0035  W89C35 802.11bg WLAN Adapter
+       0101  Hub
+       0961  AVL Flash Card Reader
+       3810  Smart Card Controller
+       3811  Generic Controller - Single interface
+       3812  Smart Card Controller_2Interface
+       3813  Panel Display
+       5518  4-Port Hub
+       551a  PC Sync Keypad
+       551b  PC Async Keypad
+       551c  Sync Tenkey
+       551d  Async Tenkey
+       551e  Keyboard
+       551f  Keyboard w/ Sys and Media
+       5521  Keyboard
+       6481  16-bit Scanner
+       7721  Memory Stick Reader/Writer
+       7722  Memory Stick Reader/Writer
+       7723  SD Card Reader
+0417  Symbios Logic
+0418  AST Research
+0419  Samsung Info. Systems America, Inc.
+       0001  IrDA Remote Controller
+       3001  Xerox P1202 Laser Printer
+       3003  Olivetti PG L12L
+       3201  Docuprint P8ex
+       3404  SCX-5x12 Series
+       3406  MFP 830 Series
+       3407  ML-912
+       3601  InkJet Color Printer
+       3602  InkJet Color Printer
+       4602  Remote NDIS Network Device
+       8001  Hub
+       8002  SyncMaster 757DFX HID Device
+041a  Phoenix Technologies, Ltd
+041b  d'TV
+041d  S3, Inc.
+041e  Creative Technology, Ltd
+       1002  Nomad II
+       1003  Blaster GamePad Cobra
+       1050  GamePad Cobra
+       3000  SoundBlaster Extigy
+       3002  SB External Composite Device
+       3010  SoundBlaster MP3+
+       3014  SB External Composite Device
+       3015  Sound Blaster Digital Music LX
+       3020  SoundBlaster Audigy 2 NX
+       3030  SB External Composite Device
+       3040  SoundBlaster Live! 24-bit External SB0490
+       3060  Sound Blaster Audigy 2 ZS External
+       3061  SoundBlaster Audigy 2 ZS Video Editor
+       3090  Sound Blaster Digital Music SX
+       3f02  E-Mu 0202
+       3f04  E-Mu 0404
+       4003  VideoBlaster WebCam Go Plus [W9967CF]
+       4004  Nomad II MG
+       4005  WebCam Blaster Go ES
+       4007  Go Mini
+       400a  PC-Cam 300
+       400b  PC-Cam 600
+       400c  WebCam 5 [pwc]
+       400d  WebCam PD1001
+       400f  PC-CAM 550 (Composite)
+       4011  WebCam PRO eX
+       4012  PC-CAM350
+       4013  PC-Cam 750
+       4015  CardCam Value
+       4016  CardCam
+       4017  WebCam Mobile
+       4018  WebCam Vista
+       4019  Audio Device
+       401c  WebCam NX [PD1110]
+       401d  WebCam NX Ultra
+       401e  WebCam NX Pro
+       401f  Webcam Notebook
+       4020  WebCam NX
+       4021  WebCam NX Ultra
+       4022  WebCam NX Pro
+       4028  Vista Plus cam [VF0090]
+       402f  DC-CAM 3000Z
+       4034  WebCam Instant
+       4035  WebCam Instant
+       4036  Webcam Live!/Live! Pro
+       4037  WebCam Live!
+       4038  ORITE CCD Webcam(PC370R)
+       4039  WebCam Live! Effects
+       403a  WebCam NX Pro 2
+       403c  WebCam Live! Ultra
+       403d  WebCam Notebook Ultra
+       403e  WebCam Vista Plus
+       4041  WebCam Live! Motion
+       4045  Live! Cam Voice
+       4049  Live! Cam Voice
+       4051  Live! Cam Notebook Pro
+       4052  Live! Cam Vista IM
+       4053  Live! Cam Video IM
+       4054  Live! Cam Video IM
+       4055  Live! Cam Video IM Pro
+       4056  Live! Cam Video IM Pro
+       4057  Live! Cam Optia
+       4058  Live! Cam Optia AF
+       4068  WebCam Live! Notebook
+       4100  Nomad Jukebox 2
+       4101  Nomad Jukebox 3
+       4102  NOMAD MuVo^2
+       4106  Nomad MuVo
+       4107  NOMAD MuVo
+       4108  Nomad Jukebox Zen
+       4109  Nomad Jukebox Zen NX
+       410b  Nomad Jukebox Zen USB 2.0
+       410c  Nomad MuVo NX
+       410f  NOMAD MuVo^2 (Flash)
+       4110  Nomad Jukebox Zen Xtra
+       4111  Dell Digital Jukebox
+       4116  MuVo^2
+       4117  Nomad MuVo TX
+       411b  Zen Touch
+       411c  Nomad MuVo USB 2.0
+       411d  Zen
+       411e  Zen Micro
+       4123  Zen Portable Media Center
+       4124  MuVo^2 FM (uHDD)
+       4126  Dell DJ (2nd gen)
+       4127  Dell DJ
+       4128  NOMAD Jukebox Zen Xtra (mtp)
+       412b  MuVo N200 with FM radio
+       4130  Zen Micro (mtp)
+       4131  Zen Touch (mtp)
+       4133  Mass Storage Device
+       4134  Zen Neeon
+       4136  Zen Sleek
+       4137  Zen Sleek (mtp)
+       4139  Zen Nano Plus
+       413c  Zen MicroPhoto
+       4151  Zen Vision:M (mtp)
+       4155  Zen Stone plus
+       500f  Broadband Blaster 8012U-V
+       5015  TECOM Bluetooth Device
+       ffff  WebCam Live! Ultra
+041f  LCS Telegraphics
+0420  Chips and Technologies
+       1307  Celly SIM Card Reader
+0421  Nokia Mobile Phones
+       0018  6288 GSM Smartphone
+       0019  6288 GSM Smartphone (imaging mode)
+       001a  6288 GSM Smartphone (file transfer mode)
+       0024  5610 XpressMusic (Storage mode)
+       0025  5610 XpressMusic (PC-Suite mode)
+       0028  5610 XpressMusic (Imaging mode)
+       0096  N810 Internet Tablet
+       0103  ADL Flashing Engine AVALON Parent
+       0104  ADL Re-Flashing Engine Parent
+       0105  E-61 (Firmware update mode)
+       0106  ROM Parent
+       0400  7600 Phone Parent
+       0401  6650 GSM Phone
+       0402  6255 Phone Parent
+       0404  5510
+       0405  9500 GSM Communicator
+       0407  Music Player HDR-1(tm)
+       040b  N-Gage GSM Phone
+       040d  6620 Phone Parent
+       040e  6651 Phone Parent
+       040f  6230 GSM Phone
+       0410  6630 Imaging Smartphone
+       0411  7610 Phone Parent
+       0413  6260 Phone Parent
+       0414  7370
+       0415  9300 GSM Smartphone
+       0416  6170 Phone Parent
+       0417  7270 Phone Parent
+       0418  E-70 (PC-Suite mode)
+       0419  E-60 (PC-Suite mode)
+       041a  9500 GSM Communicator (RNDIS)
+       041b  9300 GSM Smartphone (RNDIS)
+       041c  7710 Phone Parent
+       041d  6670 Phone Parent
+       041e  6680
+       041f  6235 Phone Parent
+       0421  3230 Phone Parent
+       0422  6681 Phone Parent
+       0423  6682 Phone Parent
+       0428  6230i Modem
+       0429  6230i MultiMedia Card
+       0431  770 Internet Tablet
+       0432  N90 Phone Parent
+       0435  E-70 (IP Passthrough/RNDIS mode)
+       0436  E-60 (IP Passthrough/RNDIS mode)
+       0437  6265 Phone Parent
+       043a  N70 USB Phone Parent
+       043b  3155 Phone Parent
+       043c  6155 Phone Parent
+       043d  6270 Phone Parent
+       0443  N70 Phone Parent
+       044c  NM850iG Phone Parent
+       044d  E-61 (PC Suite mode)
+       044e  E-61 (Data Exchange mode)
+       044f  E-61 (IP Passthrough/RNDIS mode)
+       0453  9300 Phone Parent
+       0456  6111 Phone Parent
+       045a  6280 Phone Parent
+       045d  6282 Phone Parent
+       046e  6110 Navigator
+       0485  MTP Device
+       04c3  N800 Internet Tablet
+       04ce  E90 Communicator (PC-Suite mode)
+       04cf  E90 Communicator (Storage mode)
+       04f9  6300 (PC-Suite mode)
+       0600  Digital Pen SU-1B
+       0800  Connectivity Cable DKU-5
+       0801  Data Cable DKU-6
+       0802  CA-42 Phone Parent
+0422  ADI Systems, Inc.
+0423  Computer Access Technology Corp.
+       000a  NetMate Ethernet
+       000c  NetMate2 Ethernet
+       000d  USB Chief Analyzer
+       0100  Generic Universal Protocol Analyzer
+       0101  UPA USBTracer
+       0200  Generic 10K Universal Protocol Analyzer
+       020a  PETracer ML
+       0300  Generic Universal Protocol Analyzer
+       0301  2500H Tracer Trainer
+       030a  PETracer x1
+       1237  Andromeda Hub
+0424  Standard Microsystems Corp.
+       0001  Integrated Hub
+       0acd  Sitecom Internal Multi Memory reader/writer MD-005
+       0fdc  Floppy
+       10cd  Sitecom Internal Multi Memory reader/writer MD-005
+       2020  USB Hub
+       20cd  Sitecom Internal Multi Memory reader/writer MD-005
+       20fc  6-in-1 Card Reader
+       2228  9-in-2 Card Reader
+       223a  8-in-1 Card Reader
+       2503  USB 2.0 Hub
+       2504  USB 2.0 Hub
+       2524  USB MultiSwitch Hub
+0425  Motorola Semiconductors HK, Ltd
+       0101  G-Tech Wireless Mouse & Keyboard
+0426  Integrated Device Technology, Inc.
+       0426  WDM Driver
+0427  Motorola Electronics Taiwan, Ltd
+0428  Advanced Gravis Computer Tech, Ltd
+       4001  GamePad Pro
+0429  Cirrus Logic
+042a  Ericsson Austrian, AG
+042b  Intel Corp.
+       9316  8x931Hx Customer Hub
+042c  Innovative Semiconductors, Inc.
+042d  Micronics
+042e  Acer, Inc.
+       0380  MP3 Player
+042f  Molex, Inc.
+0430  Sun Microsystems, Inc.
+       0002  109 Keyboard
+       0005  Type 6 Keyboard
+       000a  109 Japanese Keyboard
+       000b  109 Japanese Keyboard
+       0082  109 Japanese Keyboard
+       0083  109 Japanese Keyboard
+       0100  3-button Mouse
+       36ba  Bus Powered Hub
+0431  Itac Systems, Inc.
+       0100  Mouse-Trak 3-button Track Ball
+0432  Unisys Corp.
+0433  Alps Electric, Inc.
+       1101  IBM Game Controller
+       abab  Keyboard
+0434  Samsung Info. Systems America, Inc.
+0435  Hyundai Electronics America
+0436  Taugagreining HF
+       0005  CameraMate (DPCM_USB)
+0437  Framatome Connectors USA
+0438  Advanced Micro Devices, Inc.
+0439  Voice Technologies Group
+043d  Lexmark International, Inc.
+       0001  Laser Printer
+       0002  Optra E310 Printer
+       0003  Laser Printer
+       0004  Laser Printer
+       0005  Laser Printer
+       0006  Laser Printer
+       0007  Laser Printer
+       0008  Inkjet Color Printer
+       0009  Optra S2450 Printer
+       000a  Laser Printer
+       000b  Inkjet Color Printer
+       000c  Optra E312 Printer
+       000d  Laser Printer
+       000e  Laser Printer
+       000f  Laser Printer
+       0010  Laser Printer
+       0011  Laser Printer
+       0012  Inkjet Color Printer
+       0013  Inkjet Color Printer
+       0014  InkJet Color Printer
+       0015  InkJet Color Printer
+       0016  Z12 Color Jetprinter
+       0017  Z32 printer
+       0018  Z52 Printer
+       0019  Forms Printer
+       001a  Z65 Printer
+       001b  InkJet Photo Printer
+       001c  Kodak Personal Picture Maker 200 Printer
+       001d  InkJet Color Printer
+       001e  InkJet Photo Printer
+       001f  Kodak Personal Picture Maker 200 Card Reader
+       0020  Z51 Printer
+       0021  Z33 Printer
+       0022  InkJet Color Printer
+       0023  Laser Printer
+       0024  Laser Printer
+       0025  InkJet Color Printer
+       0026  InkJet Color Printer
+       0027  InkJet Color Printer
+       0028  InkJet Color Printer
+       0029  Scan Print Copy
+       002a  Scan Print Copy
+       002b  Scan Print Copy
+       002c  Scan Print Copy
+       002d  X70/X73 Scan/Print/Copy
+       002e  Scan Print Copy
+       002f  Scan Print Copy
+       0030  Scan Print Copy
+       0031  Scan Print Copy
+       0032  Scan Print Copy
+       0033  Scan Print Copy
+       0034  Scan Print Copy
+       0035  Scan Print Copy
+       0036  Scan Print Copy
+       0037  Scan Print Copy
+       0038  Scan Print Copy
+       0039  Scan Print Copy
+       003a  Scan Print Copy
+       003b  Scan Print Copy
+       003c  Scan Print Copy
+       003d  X83 Scan/Print/Copy
+       003e  Scan Print Copy
+       003f  Scan Print Copy
+       0040  Scan Print Copy
+       0041  Scan Print Copy
+       0042  Scan Print Copy
+       0043  Scan Print Copy
+       0044  Scan Print Copy
+       0045  Scan Print Copy
+       0046  Scan Print Copy
+       0047  Scan Print Copy
+       0048  Scan Print Copy
+       0049  Scan Print Copy
+       004a  Scan Print Copy
+       004b  Scan Print Copy
+       004c  Scan Print Copy
+       004d  Laser Printer
+       004e  Laser Printer
+       004f  InkJet Color Printer
+       0050  InkJet Color Printer
+       0051  Laser Printer
+       0052  Laser Printer
+       0053  InkJet Color Printer
+       0054  InkJet Color Printer
+       0057  Z35 Printer
+       0058  Laser Printer
+       005a  X63
+       005c  InkJet Color Printer
+       0060  X74/X75 Scanner
+       0061  X74 Hub
+       0065  X5130
+       0069  X74/X75 Printer
+       006d  X125
+       0072  X6170 Printer
+       0073  InkJet Color Printer
+       0078  InkJet Color Printer
+       0079  InkJet Color Printer
+       007a  Generic Hub
+       007b  InkJet Color Printer
+       007c  Lexmark X1110/X1130/X1140/X1150/X1170/X1180/X1185
+       007d  Photo 3150
+       008a  4200 Series
+       008b  InkJet Color Printer
+       008c  to CF/SM/SD/MS Card Reader
+       008e  InkJet Color Printer
+       008f  X422
+       0093  X5250
+       0095  E220 Printer
+       0096  2200 Series
+       0097  P6250
+       0098  7100 Series
+       009e  P910 Series Human Interface Device
+       009f  InkJet Color Printer
+       00a9  IBM Infoprint 1410 MFP
+       00ab  InkJet Color Printer
+       00b2  3300 Series
+       00b8  7300 Series
+       00b9  8300 Series
+       00ba  InkJet Color Printer
+       00bb  2300 Series
+       00bd  Printing Support
+       00be  Printing Support
+       00bf  Printing Support
+       00c0  6300 Series
+       00c1  4300 Series
+       00c7  Printing Support
+       00c8  Printing Support
+       00c9  Printing Support
+       00cb  Printing Support
+       00d0  9300 Series
+       00d3  X340 Scanner
+       00d4  X342n Scanner
+       00d5  Printing Support
+       00d6  X340 Scanner
+       00e8  X642e
+       00e9  2400 Series
+       00f6  3400 Series
+       00f7  InkJet Color Printer
+       00ff  InkJet Color Printer
+       010b  2500 Series
+       010d  3500-4500 Series
+       010f  6500 Series
+       4303  Xerox WorkCentre Pro 412
+043e  LG Electronics USA, Inc.
+       42bd  Flatron 795FT Plus Monitor
+       4a4d  Flatron 915FT Plus Monitor
+       7001  MF-PD100 Soul Digital MP3 Player
+       7013  MP3 Player
+       8484  LPC-U30 Webcam II
+       8585  LPC-UC35 Webcam
+       8888  Electronics VCS Camera II(LPC-U20)
+       9800  Remote Control Receiver_iMON
+       9803  eHome Infrared Receiver
+       9804  DMB Receiver Control
+       9c01  LGE Sync
+043f  RadiSys Corp.
+0440  Eizo Nanao Corp.
+0441  Winbond Systems Lab.
+       1456  Hub
+0442  Ericsson, Inc.
+       abba  Bluetooth Device
+0443  Gateway, Inc.
+       000e  Multimedia Keyboard
+       002e  Millennium Keyboard
+0445  Lucent Technologies, Inc.
+0446  NMB Technologies Corp.
+       6781  Keyboard with PS/2 Mouse Port
+       6782  Keyboard
+0447  Momentum Microsystems
+044a  Shamrock Tech. Co., Ltd
+044b  WSI
+044c  CCL/ITRI
+044d  Siemens Nixdorf AG
+044e  Alps Electric Co., Ltd
+       1104  Japanese Keyboard
+       2002  MD-5500 Printer
+       2014  Bluetooth Device
+       3001  UGTZ4 Bluetooth
+       3002  Bluetooth Device
+       3003  Bluetooth Device
+       3004  Bluetooth Adapter
+       3005  Integrated Bluetooth Device
+       3006  Bluetooth Adapter
+       3007  GlidePoint PS/2 TouchPad
+       300c  Bluetooth Controller (ALPS/UGPZ6)
+       300d  Bluetooth Controller (ALPS/UGPZ6)
+       ffff  Compaq Bluetooth Multiport Module
+044f  ThrustMaster, Inc.
+       0400  HOTAS Cougar
+       a003  Rage 3D Game Pad
+       a01b  PK-GP301 Driving Wheel
+       a0a0  Top Gun Joystick
+       a0a1  Top Gun Joystick (rev2)
+       a0a3  Fusion Digital GamePad
+       a201  PK-GP201 PlayStick
+       b203  360 Modena Pro Wheel
+       b300  Firestorm Dual Power
+       b304  Firestorm Dual Power
+       b307  vibrating Upad
+       b603  force feedback Wheel
+       b605  force feedback Racing Wheel
+       b700  Tacticalboard
+0450  DFI, Inc.
+0451  Texas Instruments, Inc.
+       1234  Bluetooth Device
+       1428  Hub
+       1446  TUSB2040/2070 Hub
+       2036  TUSB2036 Hub
+       2046  TUSB2046 Hub
+       2077  TUSB2077 Hub
+       3410  TUSB3410 Microcontroller
+       3f02  SMC WSKP100 Wi-Fi Phone
+       5409  Frontier Labs NEX IA+ Digital Audio Player
+       6000  AU5 ADSL Modem (pre-reenum)
+       6001  AU5 ADSL Modem
+       6060  RNDIS/BeWAN ADSL2+
+       6070  RNDIS/BeWAN ADSL2+
+       625f  Trekstor USB-Stick 12 CS-D 12 GB
+       dbc0  Device Bay Controller
+       e001  GraphLink
+       e004  TI-89 Titanium Calculator
+       e008  TI-84 Plus Silver Calculator
+       f430  MSP-FET430UIF JTAG Tool
+       ffff  Bluetooth Device
+0452  Mitsubishi Electronics America, Inc.
+       0021  HID Monitor Controls
+       0050  Diamond Pro 900u CRT Monitor
+       0051  Integrated Hub
+0453  CMD Technology
+       6781  NMB Keyboard
+       6783  Chicony Composite Keyboard
+0454  Vobis Microcomputer AG
+0455  Telematics International, Inc.
+0456  Analog Devices, Inc.
+0457  Silicon Integrated Systems Corp.
+       0150  Super Talent 1GB Flash Drive
+       0151  Super Flash 1GB / GXT  64MB Flash Drive
+       0162  SiS162 usb Wireless LAN Adapter
+       0163  802.11 Wireless LAN Adapter
+       5401  Wireless Adapter RO80211GS-USB
+0458  KYE Systems Corp. (Mouse Systems)
+       0001  Mouse
+       0002  Genius NetMouse Pro
+       0003  Genius NetScroll+
+       0006  Easy Mouse+ USB(USB\Vid_0458&Pid;_0006) Mouse
+       000b  NetMouse Wheel(P+U)
+       000c  TACOMA Fingerprint V1.06.01
+       000e  VideoCAM Web
+       0013  TACOMA Fingerprint Mouse V1.06.01
+       001a  Genius WebScroll+
+       0036  Pocket Mouse LE
+       004c  Slimstar Pro Keyboard
+       0056  Ergo 300 Mouse
+       0057  Enhanced Gaming Device
+       0059  Enhanced Laser Device
+       005a  Enhanced Device
+       005b  Enhanced Device
+       005c  Enhanced Laser Gaming Device
+       005d  Enhanced Device
+       0061  Bluetooth Dongle
+       0083  Bluetooth Dongle
+       0100  EasyPen Tablet
+       0101  CueCat
+       1001  Joystick
+       1002  Game Pad
+       1003  Genius VideoCam
+       1004  Flight2000 F-23 Joystick
+       100a  Aashima Technology Trust Sight Fighter Vibration Feedback Joystick
+       2001  ColorPage-Vivid Pro Scanner
+       2004  ColorPage-HR6 V1 Scanner
+       2005  ColorPage-HR6/Vivid3
+       2007  ColorPage-HR6 V2 Scanner
+       2008  ColorPage-HR6 V2 Scanner
+       2009  ColorPage-HR6A Scanner
+       2011  ColorPage-Vivid3x Scanner
+       2012  Plustek Scanner
+       2013  ColorPage-HR7 Scanner
+       2014  ColorPage-Vivid4
+       2015  ColorPage-HR7LE Scanner
+       2016  ColorPage-HR6X Scanner
+       2017  ColorPage-Vivid3xe
+       2018  ColorPage-HR7X
+       2019  ColorPage-HR6X Slim
+       201a  ColorPage-Vivid4xe
+       201b  ColorPage-Vivid4x
+       201c  ColorPage-HR8
+       201d  ColorPage-Vivid 1200 X
+       201e  ColorPage-Slim 1200
+       201f  ColorPage-Vivid 1200 XE
+       2020  ColorPage-Slim 1200 USB2
+       2021  ColorPage-SF600
+       301d  Genius MaxFire MiniPad
+       6001  GF3000F Ethernet Adapter
+       7004  VideoCAM Express
+       7007  VideoCAM Web
+       7009  G-Shot G312 Still Camera Device
+       700c  VideoCAM Web V3
+       700d  G-Shot G511 Composite Device
+       700f  VideoCAM Web V4
+       7012  WebCAM USB2.0
+       7014  VideoCAM Live V3
+       701c  G-Shot G512 Still Camera
+       7020  Sim 321C
+0459  Adobe Systems, Inc.
+045a  SONICblue, Inc.
+       07da  Supra Express 56K modem
+       0b4a  SupraMax 2890 56K Modem [Lucent Atlas]
+       0b68  SupraMax 56K Modem
+       5001  Rio 600 MP3 Player
+       5002  Rio 800 MP3 Player
+       5003  Nike Psa/Play MP3 Player
+       5005  Rio S10 MP3 Player
+       5006  Rio S50 MP3 Player
+       5007  Rio S35 MP3 Player
+       5008  Rio 900 MP3 Player
+       5009  Rio S30 MP3 Player
+       500d  Fuse MP3 Player
+       500e  Chiba MP3 Player
+       500f  Cali MP3 Player
+       5010  Rio S11 MP3 Player
+       501c  Virgin MPF-1000
+       501d  Rio Fuse
+       501e  Rio Chiba
+       501f  Rio Cali
+       503f  Cali256 MP3 Player
+       5202  Rio Riot MP3 Player
+       5210  Rio Karma Music Player
+       5220  Rio Nitrus MP3 Player
+       5221  Rio Eigen
+045b  Hitachi, Ltd
+045d  Nortel Networks, Ltd
+045e  Microsoft Corp.
+       0007  SideWinder Game Pad
+       0008  SideWinder Precision Pro
+       0009  IntelliMouse
+       000b  Natural Keyboard Elite
+       000e  SideWinder® Freestyle Pro
+       0014  Digital Sound System 80
+       001a  SideWinder Precision Racing Wheel
+       001b  SideWinder Force Feedback 2 Joystick
+       001c  Internet Keyboard Pro
+       001d  Natural Keyboard Pro
+       001e  IntelliMouse Explorer
+       0023  Trackball Optical
+       0024  Trackball Explorer
+       0025  IntelliEye Mouse
+       0026  SideWinder GamePad Pro
+       0027  SideWinder PnP GamePad
+       0028  SideWinder Dual Strike
+       0029  IntelliMouse Optical
+       002b  Internet Keyboard Pro
+       002d  Internet Keyboard
+       002f  Integrated Hub
+       0033  Sidewinder Strategic Commander
+       0034  SideWinder Force Feedback Wheel
+       0038  SideWinder Precision 2
+       0039  IntelliMouse Optical
+       003b  SideWinder Game Voice
+       003c  SideWinder Joystick
+       0040  Wheel Mouse Optical
+       0047  IntelliMouse Explorer 3.0
+       0048  Office Keyboard 1.0A
+       0053  Optical Mouse
+       0059  Wireless IntelliMouse Explorer
+       005c  Office Keyboard (106/109)
+       005f  Wireless MultiMedia Keyboard
+       0061  Wireless MultiMedia Keyboard (106/109)
+       0063  Wireless Natural MultiMedia Keyboard
+       0065  Wireless Natural MultiMedia Keyboard (106/109)
+       006a  Wireless Optical Mouse (IntelliPoint)
+       006d  eHome Remote Control Keyboard keys
+       006e  MN510 802.11b Adapter
+       006f  Smart Display Reference Device
+       0070  Wireless MultiMedia Keyboard
+       0071  Wireless MultiMedia Keyboard (106/109)
+       0072  Wireless Natural MultiMedia Keyboard
+       0073  Wireless Natural MultiMedia Keyboard (106/109)
+       007a  10/100 USB NIC
+       007d  Notebook Optical Mouse
+       007e  Wireless Transceiver for Bluetooth
+       0080  Digital Media Pro Keyboard
+       0083  Basic Optical Mouse
+       0084  Basic Optical Mouse
+       008a  Wireless Keyboard and Mouse
+       008b  Dual Receiver Wireless Mouse (IntelliPoint)
+       008c  Wireless Intellimouse Explorer 2.0
+       0095  IntelliMouse Explorer 4.0 (IntelliPoint)
+       009c  Wireless Transceiver for Bluetooth 2.0
+       00a0  eHome Infrared Receiver
+       00b0  Digital Media Pro Keyboard
+       00b9  Wireless Optical Mouse 3.0
+       00bb  Fingerprint Reader
+       00bc  Fingerprint Reader
+       00bd  Fingerprint Reader
+       00c2  Wireless Adapter MN-710
+       00c9  MTP Device
+       00ce  Generic PPC Flash device
+       00d1  Optical Mouse with Tilt Wheel
+       00da  eHome Infrared Receiver
+       00db  Natural Ergonomic Keyboard 4000 V1.0
+       00e1  Wireless Laser Mouse 6000 Reciever
+       00f4  LifeCam VX-6000.
+       00f5  LifeCam VX-3000.
+       00f7  LifeCam VX-1000.
+       00f8  LifeCam NX-6000.
+       0202  Xbox Controller
+       0280  XBox Device
+       0284  Xbox DVD Playback Kit
+       0285  Xbox Controller S
+       0288  Xbox Controller S Hub
+       0289  Xbox Controller S
+       028b  Xbox360 DVD Emulator
+       028d  Xbox360 Memory Unit 64MB
+       028e  Xbox360 Controller
+       028f  Xbox360 Wireless Controller
+       0290  Xbox360 Performance Pipe (PIX)
+       0292  Xbox360 Wireless Networking Adapter
+       029c  Xbox360 HD-DVD Drive
+       029d  Xbox360 HD-DVD Drive
+       029e  Xbox360 HD-DVD Memory Unit
+       0400  Windows Powered Pocket PC 2002
+       0401  Windows Powered Pocket PC 2002
+       0402  Windows Powered Pocket PC 2002
+       0403  Windows Powered Pocket PC 2002
+       0404  Windows Powered Pocket PC 2002
+       0405  Windows Powered Pocket PC 2002
+       0406  Windows Powered Pocket PC 2002
+       0407  Windows Powered Pocket PC 2002
+       0408  Windows Powered Pocket PC 2002
+       0409  Windows Powered Pocket PC 2002
+       040a  Windows Powered Pocket PC 2002
+       040b  Windows Powered Pocket PC 2002
+       040c  Windows Powered Pocket PC 2002
+       040d  Windows Powered Pocket PC 2002
+       040e  Windows Powered Pocket PC 2002
+       040f  Windows Powered Pocket PC 2002
+       0410  Windows Powered Pocket PC 2002
+       0411  Windows Powered Pocket PC 2002
+       0412  Windows Powered Pocket PC 2002
+       0413  Windows Powered Pocket PC 2002
+       0414  Windows Powered Pocket PC 2002
+       0415  Windows Powered Pocket PC 2002
+       0416  Windows Powered Pocket PC 2002
+       0417  Windows Powered Pocket PC 2002
+       0432  Windows Powered Pocket PC 2003
+       0433  Windows Powered Pocket PC 2003
+       0434  Windows Powered Pocket PC 2003
+       0435  Windows Powered Pocket PC 2003
+       0436  Windows Powered Pocket PC 2003
+       0437  Windows Powered Pocket PC 2003
+       0438  Windows Powered Pocket PC 2003
+       0439  Windows Powered Pocket PC 2003
+       043a  Windows Powered Pocket PC 2003
+       043b  Windows Powered Pocket PC 2003
+       043c  Windows Powered Pocket PC 2003
+       043d  Becker Traffic Assist Highspeed 7934
+       043e  Windows Powered Pocket PC 2003
+       043f  Windows Powered Pocket PC 2003
+       0440  Windows Powered Pocket PC 2003
+       0441  Windows Powered Pocket PC 2003
+       0442  Windows Powered Pocket PC 2003
+       0443  Windows Powered Pocket PC 2003
+       0444  Windows Powered Pocket PC 2003
+       0445  Windows Powered Pocket PC 2003
+       0446  Windows Powered Pocket PC 2003
+       0447  Windows Powered Pocket PC 2003
+       0448  Windows Powered Pocket PC 2003
+       0449  Windows Powered Pocket PC 2003
+       044a  Windows Powered Pocket PC 2003
+       044b  Windows Powered Pocket PC 2003
+       044c  Windows Powered Pocket PC 2003
+       044d  Windows Powered Pocket PC 2003
+       044e  Windows Powered Pocket PC 2003
+       044f  Windows Powered Pocket PC 2003
+       0450  Windows Powered Pocket PC 2003
+       0451  Windows Powered Pocket PC 2003
+       0452  Windows Powered Pocket PC 2003
+       0453  Windows Powered Pocket PC 2003
+       0454  Windows Powered Pocket PC 2003
+       0455  Windows Powered Pocket PC 2003
+       0456  Windows Powered Pocket PC 2003
+       0457  Windows Powered Pocket PC 2003
+       0458  Windows Powered Pocket PC 2003
+       0459  Windows Powered Pocket PC 2003
+       045a  Windows Powered Pocket PC 2003
+       045b  Windows Powered Pocket PC 2003
+       045c  Windows Powered Pocket PC 2003
+       045d  Windows Powered Pocket PC 2003
+       045e  Windows Powered Pocket PC 2003
+       045f  Windows Powered Pocket PC 2003
+       0460  Windows Powered Pocket PC 2003
+       0461  Windows Powered Pocket PC 2003
+       0462  Windows Powered Pocket PC 2003
+       0463  Windows Powered Pocket PC 2003
+       0464  Windows Powered Pocket PC 2003
+       0465  Windows Powered Pocket PC 2003
+       0466  Windows Powered Pocket PC 2003
+       0467  Windows Powered Pocket PC 2003
+       0468  Windows Powered Pocket PC 2003
+       0469  Windows Powered Pocket PC 2003
+       046a  Windows Powered Pocket PC 2003
+       046b  Windows Powered Pocket PC 2003
+       046c  Windows Powered Pocket PC 2003
+       046d  Windows Powered Pocket PC 2003
+       046e  Windows Powered Pocket PC 2003
+       046f  Windows Powered Pocket PC 2003
+       0470  Windows Powered Pocket PC 2003
+       0471  Windows Powered Pocket PC 2003
+       0472  Windows Powered Pocket PC 2003
+       0473  Windows Powered Pocket PC 2003
+       0474  Windows Powered Pocket PC 2003
+       0475  Windows Powered Pocket PC 2003
+       0476  Windows Powered Pocket PC 2003
+       0477  Windows Powered Pocket PC 2003
+       0478  Windows Powered Pocket PC 2003
+       0479  Windows Powered Pocket PC 2003
+       047a  Windows Powered Pocket PC 2003
+       047b  Windows Powered Pocket PC 2003
+       04c8  Windows Powered Smartphone 2002
+       04c9  Windows Powered Smartphone 2002
+       04ca  Windows Powered Smartphone 2002
+       04cb  Windows Powered Smartphone 2002
+       04cc  Windows Powered Smartphone 2002
+       04cd  Windows Powered Smartphone 2002
+       04ce  Windows Powered Smartphone 2002
+       04d7  Windows Powered Smartphone 2003
+       04d8  Windows Powered Smartphone 2003
+       04d9  Windows Powered Smartphone 2003
+       04da  Windows Powered Smartphone 2003
+       04db  Windows Powered Smartphone 2003
+       04dc  Windows Powered Smartphone 2003
+       04dd  Windows Powered Smartphone 2003
+       04de  Windows Powered Smartphone 2003
+       04df  Windows Powered Smartphone 2003
+       04e0  Windows Powered Smartphone 2003
+       04e1  Windows Powered Smartphone 2003
+       04e2  Windows Powered Smartphone 2003
+       04e3  Windows Powered Smartphone 2003
+       04e4  Windows Powered Smartphone 2003
+       04e5  Windows Powered Smartphone 2003
+       04e6  Windows Powered Smartphone 2003
+       04e7  Windows Powered Smartphone 2003
+       04e8  Windows Powered Smartphone 2003
+       04e9  Windows Powered Smartphone 2003
+       04ea  Windows Powered Smartphone 2003
+       0708  Transceiver v 3.0 for Bluetooth
+       070a  Charon Bluetooth Dongle (DFU)
+       930a  ISOUSB.SYS Intel 82930 Isochronous IO Test Board
+       fff8  Keyboard
+0460  Ace Cad Enterprise Co., Ltd
+0461  Primax Electronics, Ltd
+       0300  G2-300 Scanner
+       0301  G2E-300 Scanner
+       0302  G2-300 #2 Scanner
+       0303  G2E-300 #2 Scanner
+       0340  Colorado 9600 Scanner
+       0341  Colorado 600u Scanner
+       0345  Visioneer 6200 Scanner
+       0346  Memorex Maxx 6136u Scanner
+       0347  Primascan Colorado 2600u/Visioneer 4400 Scanner
+       0360  Colorado 19200 Scanner
+       0361  Colorado 1200u Scanner
+       0363  VistaScan Astra 3600(ENG)
+       0364  LG Electronics Scanworks 600U Scanner
+       0365  VistaScan Astra 3600(ENG)
+       0366  6400
+       0367  VistaScan Astra 3600(ENG)
+       0371  Visioneer Onetouch 8920 Scanner
+       0374  UMAX Astra 2500
+       0375  VistaScan Astra 3600(ENG)
+       0377  Medion MD 5345 Scanner
+       0378  VistaScan Astra 3600(ENG)
+       037b  Medion MD 6190 Scanner
+       037c  VistaScan Astra 3600(ENG)
+       0380  G2-600 Scanner
+       0381  ReadyScan 636i Scanner
+       0382  G2-600 #2 Scanner
+       0383  G2E-600 Scanner
+       038a  UMAX Astra 3000/3600
+       038b  Xerox 2400 Onetouch
+       038c  UMAX Astra 4100
+       0392  Medion/Lifetec/Tevion/Cytron MD 6190
+       03a8  9420M
+       0813  IBM UltraPort Camera
+       0815  Micro Innovations WebCam
+       0819  Fujifilm IX-30 Camera [webcam mode]
+       081a  Fujifilm IX-30 Camera [storage mode]
+       081c  Elitegroup ECS-C11 Camera
+       081d  Elitegroup ECS-C11 Storage
+       0a00  Web Cam 320
+       4d01  Comfort Keyboard
+       4d02  Mouse-in-a-Box
+       4d03  Kensington Mouse-in-a-box
+       4d04  Mouse
+       4d06  Balless Mouse (HID)
+       4d2a  PoPo Elixir Mouse (HID)
+       4d2b  Wireless Laser Mini Mouse (HID)
+       4d2c  PoPo Mini Pointer Mouse (HID)
+       4d2e  Optical Mobile Mouse (HID)
+0463  MGE UPS Systems
+       0001  UPS
+       ffff  UPS
+0464  AMP/Tycoelectronics Corp.
+0467  AT&T Paradyne
+0468  Wieson Technologies Co., Ltd
+046a  Cherry GmbH
+       0001  My3000 Keyboard
+       0003  My3000 Hub
+       0004  CyBoard Keyboard
+       0005  XX33 SmartCard Reader Keyboard
+       0010  SmartBoard XX44
+       0023  Cymotion Master Linux Keyboard
+       002d  SmartTerminal XX44
+       003e  SmartTerminal ST-2xxx
+046b  American Megatrends, Inc.
+       0001  Keyboard
+       0101  PS/2 Keyboard, Mouse & Joystick Ports
+       0301  USB 1.0 Hub
+       0500  Serial & Parallel Ports
+046c  Toshiba Corp., Digital Media Equipment
+046d  Logitech, Inc.
+       0082  Acer Aspire 5672 Webcam
+       0200  WingMan Extreme Joystick
+       0203  M2452 Keyboard
+       0301  M4848 Mouse
+       0401  HP PageScan
+       0402  NEC PageScan
+       040f  Logitech/Storm PageScan
+       0430  Mic (Cordless)
+       0801  QuickCam Home
+       0810  QuickCam Pro
+       0820  QuickCam VC
+       0830  QuickClip
+       0840  QuickCam Express
+       0850  QuickCam Web
+       0870  QuickCam Express
+       0890  QuickCam Traveler
+       0892  OrbiCam
+       0894  CrystalCam
+       0895  QuickCam for Dell Notebooks
+       0896  OrbiCam
+       0897  QuickCam for Dell Notebooks
+       0899  QuickCam for Dell Notebooks
+       08a0  QuickCam IM
+       08a1  QuickCam IM with sound
+       08a2  Labtec WebCam Pro
+       08a3  QuickCam QuickCam Chat
+       08a6  QuickCam IM
+       08a7  QuickCam Image
+       08a9  Notebook Deluxe
+       08aa  Labtec Notebooks
+       08ac  QuickCam Cool
+       08ad  QuickCam Communicate STX
+       08ae  Quickcam for Notebooks
+       08af  QuickCam Easy/Cool
+       08b0  QuickCam 3000 Pro [pwc]
+       08b1  QuickCam Notebook Pro
+       08b2  QuickCam Pro 4000
+       08b3  QuickCam Zoom
+       08b4  QuickCam Zoom
+       08b5  QuickCam Sphere
+       08b9  QuickCam IM
+       08bd  Microphone (Pro 4000)
+       08c0  QuickCam Pro 3000
+       08c1  QuickCam Fusion
+       08c2  QuickCam PTZ
+       08c3  Camera (Notebooks Pro)
+       08c5  QuickCam Pro 5000
+       08c6  QuickCam for DELL Notebooks
+       08c9  QuickCam Ultra Vision
+       08ca  Mic (Fusion)
+       08cb  Mic (Notebooks Pro)
+       08cc  Mic (PTZ)
+       08ce  QuickCam Pro 5000
+       08cf  QuickCam UpdateMe
+       08d0  QuickCam Express
+       08d7  QuickCam Communicate STX
+       08d8  QuickCam for Notebook Deluxe
+       08d9  QuickCam IM/Connect
+       08da  QuickCam Messanger
+       08dd  QuickCam for Notebooks
+       08e0  QuickCam Express
+       08e1  Labtec WebCam
+       08f0  QuickCam Messenger
+       08f1  QuickCam Express
+       08f2  Microphone (Messenger)
+       08f3  QuickCam Express
+       08f4  Labtec WebCam
+       08f5  QuickCam Messenger Communicate
+       08f6  Quickcam Messenger Plus
+       0900  ClickSmart 310
+       0901  ClickSmart 510
+       0903  ClickSmart 820
+       0905  ClickSmart 820
+       0910  QuickCam Cordless
+       0920  QuickCam Express
+       0921  Labtec WebCam
+       0922  QuickCam Live
+       0928  Quickcam Express
+       0929  Labtec WebCam Pro
+       092a  QuickCam for Notebooks
+       092b  Labtec WebCam Plus
+       092c  QuickCam Chat
+       092d  QuickCam Express / Go
+       092e  QuickCam Chat
+       092f  QuickCam Express Plus
+       0950  Pocket Camera
+       0960  ClickSmart 420
+       0970  Pocket750
+       0990  QuickCam Pro 9000
+       0991  QuickCam Pro for Notebooks
+       0992  QuickCam Communicate Deluxe
+       0994  QuickCam Orbit/Sphere AF
+       09b0  OrbiCam
+       09c0  QuickCam for Dell Notebooks Mic
+       09c1  QuickCam Deluxe for Notebooks
+       0a01  USB Headset
+       0a02  Premium Stereo USB Headset 350
+       0a03  Logitech USB Microphone
+       0a04  V20 portable speakers (USB powered)
+       0b02  BT Mini-Receiver (HID proxy mode)
+       8801  Video Camera
+       b305  BT Mini-Receiver
+       bfe4  Premium Optical Wheel Mouse
+       c000  N43 [Pilot Mouse]
+       c001  N48/M-BB48 [FirstMouse Plus]
+       c002  M-BA47 [MouseMan Plus]
+       c003  MouseMan
+       c004  WingMan Gaming Mouse
+       c005  WingMan Gaming Wheel Mouse
+       c00b  MouseMan Wheel
+       c00c  Optical Wheel Mouse
+       c00d  MouseMan Wheel+
+       c00e  M-BJ58/M-BJ69 Optical Wheel Mouse
+       c00f  MouseMan Traveler/Mobile
+       c011  Optical MouseMan
+       c012  Mouseman Dual Optical
+       c014  Corded Workstation Mouse
+       c015  Corded Workstation Mouse
+       c016  M-UV69a/HP M-UV96 Optical Wheel Mouse
+       c018  Optical Wheel Mouse
+       c019  Optical Tilt Wheel Mouse
+       c01a  M-BQ85 Optical Wheel Mouse
+       c01b  MX310 Optical Mouse
+       c01c  Optical Mouse
+       c01d  MX510 Optical Mouse
+       c01e  MX518 Optical Mouse
+       c024  MX300 Optical Mouse
+       c025  MX500 Optical Mouse
+       c030  iFeel Mouse
+       c031  iFeel Mouse+
+       c032  MouseMan iFeel
+       c033  iFeel MouseMan+
+       c034  MouseMan Optical
+       c035  Mouse
+       c036  Mouse
+       c037  Mouse
+       c038  Mouse
+       c03d  M-BT69a Pilot Optical Mouse
+       c03e  Premium Optical Wheel Mouse
+       c03f  UltraX Optical Mouse
+       c040  Corded Tilt-Wheel Mouse
+       c043  MX320 Laser Mouse
+       c044  LX3 Optical Mouse
+       c045  Optical Mouse
+       c046  RX1000 Laser Mouse
+       c047  Laser Mouse
+       c049  G5 Laser Mouse
+       c050  RX 250 Optical Mouse
+       c051  G3 (MX518) Optical Mouse
+       c053  Laser Mouse
+       c101  UltraX Media Remote
+       c201  WingMan Extreme Joystick with Throttle
+       c202  WingMan Formula
+       c207  WingMan Extreme Digital 3D
+       c208  WingMan Gamepad Extreme
+       c209  WingMan Gamepad
+       c20a  WingMan RumblePad
+       c20b  WingMan Action Pad
+       c20c  WingMan Precision
+       c20d  WingMan Attack 2
+       c20e  WingMan Formula GP
+       c211  iTouch Cordless Reciever
+       c212  WingMan Extreme Digital 3D
+       c213  J-UH16 (Freedom 2.4 Cordless Joystick)
+       c214  ATK3 (Attack III Joystick)
+       c215  Extreme 3D Pro
+       c216  Dual Action Gamepad
+       c218  Logitech RumblePad 2 USB
+       c219  Cordless RumblePad 2
+       c21a  Precision Gamepad
+       c221  G15 Keyboard / Keyboard
+       c222  G15 Keyboard / LCD
+       c223  G15 Keyboard / USB Hub
+       c281  WingMan Force
+       c283  WingMan Force 3D
+       c285  WingMan Strike Force 3D
+       c286  Force 3D Pro
+       c291  WingMan Formula Force
+       c293  WingMan Formula Force GP
+       c294  Driving Force
+       c295  Momo Force Steering Wheel
+       c298  Driving Force Pro
+       c2a0  Wingman Force Feedback Mouse
+       c2a1  WingMan Force Feedback Mouse
+       c301  iTouch Keyboard
+       c302  iTouch Pro Keyboard
+       c303  iTouch Keyboard
+       c305  Internet Keyboard
+       c307  Internet Keyboard
+       c308  Internet Navigator Keyboard
+       c309  Internet Keyboard
+       c30a  iTouch Composite
+       c30c  Internet Keys (X)
+       c30d  Internet Keys
+       c30e  UltraX Keys (X)
+       c30f  Logicool HID-Compliant Keyboard (106 key)
+       c315  Classic New Touch Keyboard
+       c316  HID-Compliant Keyboard
+       c401  TrackMan Marble Wheel
+       c402  Marble Mouse (2-button)
+       c403  Turbo TrackMan Marble FX
+       c404  TrackMan Wheel
+       c408  Marble Mouse (4-button)
+       c501  Cordless Mouse Receiver
+       c502  Cordless Mouse & iTouch Keys
+       c503  Cordless Mouse+Keyboard Receiver
+       c504  Cordless Mouse+Keyboard Receiver
+       c505  Cordless Mouse+Keyboard Receiver
+       c506  MX-700 Cordless Mouse Receiver
+       c508  Cordless Trackball
+       c509  Cordless Keyboard
+       c50a  Cordless Mouse
+       c50b  Cordless Desktop Optical
+       c50d  Cordless Mouse
+       c50e  MX-1000 Cordless Mouse Receiver
+       c510  Cordless Mouse
+       c512  LX-700 Cordless Desktop Receiver
+       c513  MX3000 Cordless Desktop Receiver
+       c514  Cordless Mouse
+       c517  LX710 Cordless Desktop Laser
+       c518  MX610 Laser Cordless Mouse
+       c51a  MX Revolution/G7 Cordless Mouse
+       c521  MX620 Laser Cordless Mouse
+       c625  3Dconnexion Space Pilot 3D Mouse
+       c626  3DConnexion Space Navigator 3D Mouse
+       c627  3DConnexion Space Explorer 3D Mouse
+       c702  Cordless Presenter
+       c703  Elite Keyboard Y-RP20 + Mouse MX900 (Bluetooth)
+       c707  Bluetooth wireless hub
+       c708  Bluetooth wireless hub
+       c709  BT Mini-Receiver (HCI mode)
+       c70a  MX5000 Cordless Desktop
+       c70b  BT Mini-Receiver (HID proxy mode)
+       c70c  BT Mini-Receiver (HID proxy mode)
+       c70d  Bluetooth wireless hub
+       c70e  MX1000 Bluetooth Laser Mouse
+       c70f  Bluetooth wireless hub
+       c712  Bluetooth wireless hub
+       c715  Bluetooth wireless hub
+       c71a  Bluetooth wireless hub
+       c71d  Bluetooth wireless hub
+       c720  Bluetooth wireless hub
+       ca03  MOMO Racing
+       ca04  Formula Vibration Feedback Wheel
+       d001  QuickCam Pro
+046e  Behavior Tech. Computer Corp.
+       0100  Keyboard
+       3001  Mass Storage Device
+       3002  Mass Storage Device
+       3003  Mass Storage Device
+       3005  Mass Storage Device
+       3008  Mass Storage Device
+       5250  KeyMaestro Multimedia Keyboard
+       5273  KeyMaestro Multimedia Keyboard
+       5308  KeyMaestro Keyboard
+       5408  KeyMaestro Multimedia Keyboard/Hub
+       5720  Smart Card Reader
+       6782  BTC 7932 mouse+keyboard
+046f  Crystal Semiconductor
+0471  Philips
+       0101  DSS350 Digital Speaker System
+       0104  DSS330 Digital Speaker System [uda1321]
+       0105  UDA1321
+       0160  MP3 Player
+       0161  MP3 Player
+       0201  Hub
+       0222  Creative Nomad Jukebox
+       0302  PCA645VC WebCam [pwc]
+       0303  PCA646VC WebCam [pwc]
+       0304  Askey VC010 WebCam [pwc]
+       0307  PCVC675K WebCam [pwc]
+       0308  PCVC680K WebCam [pwc]
+       030b  PC VGA Camera (Vesta Fun)
+       030c  PCVC690K WebCam [pwc]
+       0310  PCVC730K WebCam [pwc]
+       0311  PCVC740K ToUcam Pro [pwc]
+       0312  PCVC750K WebCam [pwc]
+       0314  DMVC 1000K
+       0316  DMVC 2000K Video Capture
+       0321  FunCam
+       0325  SPC 200NC PC Camera
+       0326  SPC 300NC PC Camera
+       0327  WebCam SPC 6000 NC (WebCam w/ mic)
+       0329  ORITE CCD Webcam(PC370R)
+       0401  Semiconductors CICT Keyboard
+       0402  PS/2 Mouse on Semiconductors CICT Keyboard
+       0406  15 inch Detachable Monitor
+       0407  10 inch Mobile Monitor
+       0471  Digital Speaker System
+       0601  OVU1020 IR Dongle (Kbd+Mouse)
+       0602  ATI Remote Wonder II Input Device
+       0603  ATI Remote Wonder II Controller
+       0608  eHome Infrared Receiver
+       060a  TSU9600 Remote Control
+       060e  RF Dongle
+       0619  TSU9400 Remote Control
+       0700  Semiconductors CICT Hub
+       0701  150P1 TFT Display
+       0809  AVNET Bluetooth Device
+       0811  JR24 CDRW
+       0815  eHome Infrared Receiver
+       1120  Creative Rhomba MP3 player
+       1125  Nike psa[128max Player
+       1137  HDD065 MP3 player
+       1201  Arima Bluetooth Device
+       1230  Wireless Adapter 11g
+       1232  SNU6500 Wireless Adapter
+       1233  Wireless Adapter Bootloader Download
+       1236  SNU5600
+       1237  TalkTalk SNU5630NS/05 Wireless Adapter
+       1552  ISP 1581 Hi-Speed USB MPEG2 Encoder Reference Kit
+       1801  Diva MP3 player
+       200a  Wireless Network Adapter
+       200f  802.11n Wireless Adapter
+       485d  Senselock SenseIV v2.x
+0472  Chicony Electronics Co., Ltd
+       0065  PFU-65 Keyboard
+0473  Sanyo Information Business Co., Ltd
+0474  Sanyo Electric Co., Ltd
+       0110  Digital Voice Recorder R200
+       0217  Xacti J2
+       022f  C5 Digital Media Camera (mass storage mode)
+       0230  C5 Digital Media Camera (PictBridge mode)
+       0231  C5 Digital Media Camera (PC control mode)
+       0401  Optical Drive
+       0701  SCP-4900 Cellphone
+       071f  Usb Com Port Enumerator
+0475  Relisys/Teco Information System
+       0100  NEC Petiscan
+       0103  Eclipse 1200U/Episode
+       0210  Scorpio Ultra 3
+0476  AESP
+0477  Seagate Technology, Inc.
+0478  Connectix Corp.
+       0001  QuickCam
+       0002  QuickClip
+       0003  QuickCam Pro
+0479  Advanced Peripheral Laboratories
+047a  Semtech Corp.
+       0004  ScreenCoder UR7HCTS2-USB
+047b  Silitek Corp.
+       0001  Keyboard
+       0002  Keyboard and Mouse
+       00f9  SK-1789u Keyboard
+       0101  BlueTooth Keyboard and Mouse
+       020b  SK-3105 SmartCard Reader
+       050e  Internet Compact Keyboard
+       1000  Trust Office Scan USB 19200
+       1002  HP ScanJet 4300c Parallel Port
+047c  Dell Computer Corp.
+047d  Kensington
+       1001  Mouse*in*a*Box
+       1002  Expert Mouse Pro
+       1003  Orbit TrackBall
+       1004  MouseWorks
+       1005  TurboBall
+       1006  TurboRing
+       1009  Orbit TrackBall for Mac
+       1012  PocketMouse
+       1013  Mouse*in*a*Box Optical Pro
+       1014  Expert Mouse Pro Wireless
+       1015  Expert Mouse
+       1016  ADB/USB Orbit
+       1018  Studio Mouse
+       101d  Mouse*in*a*Box Optical Pro
+       101e  Studio Mouse Wireless
+       101f  PocketMouse Pro
+       1020  Expert Mouse Trackball
+       1021  Expert Mouse Wireless
+       1022  Orbit Optical
+       1023  Pocket Mouse Pro Wireless
+       1024  PocketMouse
+       1025  Mouse*in*a*Box Optical Elite Wireless
+       1026  Pocket Mouse Pro
+       1027  StudioMouse
+       1028  StudioMouse Wireless
+       1029  Mouse*in*a*Box Optical Elite
+       102a  Mouse*in*a*Box Optical
+       102b  PocketMouse
+       102c  Iridio
+       102d  Pilot Optical
+       102e  Pilot Optical Pro
+       102f  Pilot Optical Pro Wireless
+       104a  PilotMouse Mini Retractable
+       105d  PocketMouse Bluetooth
+       105e  Bluetooth EDR Dongle
+       1061  PocketMouse Grip
+       1062  PocketMouse Max
+       1063  PocketMouse Max Wireless
+       1064  PocketMouse 2.0 Wireless
+       1065  PocketMouse 2.0
+       1066  PocketMouse Max Glow
+       1067  ValueMouse
+       1068  ValueOpt White
+       1069  ValueOpt Black
+       106a  PilotMouse Laser Wireless Mini
+       106b  PilotMouse Laser - 3 Button
+       106c  PilotMouse Laser - Gaming
+       106d  PilotMouse Laser - Wired
+       106e  PilotMouse Micro Laser
+       1070  ValueOpt Travel
+       1071  ValueOpt RF TX
+       1072  PocketMouse Colour
+       1073  PilotMouse Laser - 6 Button
+       1074  PilotMouse Laser Wireless Mini
+       1075  SlimBlade Presenter Media Mouse
+       1076  SlimBlade Media Mouse
+       1077  SlimBlade Presenter Mouse
+       1152  Bluetooth EDR Dongle
+       2002  Optical Elite Wireless
+       2010  Wireless Presentation Remote
+       2021  PilotBoard Wireless
+       2030  PilotBoard Wireless
+       2034  SlimBlade Media Notebook Set
+       4003  Gravis Xterminator Digital Gamepad
+       4005  Gravis Eliminator GamePad Pro
+       4006  Gravis Eliminator AfterShock
+       4007  Gravis Xterminator Force
+       4008  Gravis Destroyer TiltPad
+       5001  Cabo I Camera
+       5002  VideoCam CABO II
+       5003  VideoCam
+047e  Agere Systems, Inc. (Lucent)
+       0300  ORiNOCO Card
+       1001  USS720 Parallel Port
+       2892  Systems Soft Modem
+       bad1  Lucent 56k Modem
+       f101  Atlas Modem
+047f  Plantronics, Inc.
+       0101  Bulk Driver
+       0301  Bulk Driver
+       0ca1  USB DSP v4 Audio Interface
+0480  Toshiba America Info. Systems, Inc.
+       0001  InTouch Module
+       0004  InTouch Module
+       0011  InTouch Module
+       0014  InTouch Module
+0481  Zenith Data Systems
+0482  Kyocera Corp.
+       000e  FS-1020D Printer
+       0100  Finecam S3x
+       0101  Finecam S4
+       0103  Finecam S5
+       0105  Finecam L3
+       0106  Finecam
+       0107  Digital Camera Device
+       0108  Digital Camera Device
+       0203  AH-K3001V
+       0204  iBurst Terminal
+0483  SGS Thomson Microelectronics
+       0137  BeWAN ADSL USB ST (blue or green)
+       1307  Cytronix 6in1 card reader
+       163d  Cool Icam Digi-MP3
+       2015  TouchChip® Fingerprint Reader
+       2016  Fingerprint Reader
+       2017  Biometric Smart Card Reader
+       2018  BioSimKey
+       2302  Portable Flash Device (PFD)
+       4810  ISDN adapter
+       481d  BT Digital Access adapter
+       5000  ST Micro Bluetooth Device
+       5001  ST Micro Bluetooth Device
+       7270  ST Micro Serial Bridge
+       7554  56k SoftModem
+       ff10  Swann ST56 Modem
+0484  Specialix
+0485  Nokia Monitors
+0486  ASUS Computers, Inc.
+0487  Stewart Connector
+0488  Cirque Corp.
+0489  Foxconn / Hon Hai
+       0502  SmartMedia Card Reader Firmware Loader
+       0503  SmartMedia Card Reader
+048a  S-MOS Systems, Inc.
+048c  Alps Electric Ireland, Ltd
+048d  Integrated Technology Express, Inc.
+048f  Eicon Tech.
+0490  United Microelectronics Corp.
+0491  Capetronic
+       0003  Taxan Monitor Control
+0492  Samsung SemiConductor, Inc.
+0493  MAG Technology Co., Ltd
+0495  ESS Technology, Inc.
+0496  Micron Electronics
+0497  Smile International
+0498  Capetronic (Kaohsiung) Corp.
+0499  Yamaha Corp.
+       1000  UX256 MIDI I/F
+       1001  MU1000
+       1002  MU2000
+       1003  MU500
+       1004  UW500
+       1005  MOTIF6
+       1006  MOTIF7
+       1007  MOTIF8
+       1008  UX96 MIDI I/F
+       1009  UX16 MIDI I/F
+       100a  EOS BX
+       100c  UC-MX
+       100d  UC-KX
+       100e  S08
+       100f  CLP-150
+       1010  CLP-170
+       1011  P-250
+       1012  TYROS
+       1013  PF-500
+       1014  S90
+       1015  MOTIF-R
+       1016  MDP-5
+       1017  CVP-204
+       1018  CVP-206
+       1019  CVP-208
+       101a  CVP-210
+       101b  PSR-1100
+       101c  PSR-2100
+       101d  CLP-175
+       101e  PSR-K1
+       101f  EZ-J24
+       1020  EZ-250i
+       1021  MOTIF ES 6
+       1022  MOTIF ES 7
+       1023  MOTIF ES 8
+       1024  CVP-301
+       1025  CVP-303
+       1026  CVP-305
+       1027  CVP-307
+       1028  CVP-309
+       1029  CVP-309GP
+       102a  PSR-1500
+       102b  PSR-3000
+       102e  ELS-01/01C
+       1030  PSR-295/293
+       1031  DGX-205/203
+       1032  DGX-305
+       1033  DGX-505
+       2000  DGP-7
+       2001  DGP-5
+       3001  YST-MS55D USB Speaker
+       4000  NetVolante RTA54i Broadband&ISDN Router
+       4001  NetVolante RTW65b Broadband Wireless Router
+       4002  NetVolante RTW65i Broadband&ISDN Wireless Router
+       4004  NetVolante RTA55i Broadband VoIP Router
+       5000  CS1D
+       5001  DSP1D
+       5002  DME32
+       5003  DM2000
+       5004  02R96
+       5005  ACU16-C
+       5006  NHB32-C
+       5007  DM1000
+       5008  01V96
+       5009  SPX2000
+       500a  PM5D
+       500b  DME64N
+       500c  DME24N
+       6001  CRW2200UX Lightspeed 2 External CD-RW Drive
+       7000  DTX
+       7010  UB99
+049a  Gandalf Technologies, Ltd
+049b  Curtis Computer Products
+049c  Acer Advanced Labs, Inc.
+       0002  Keyboard (???)
+049d  VLSI Technology
+049f  Compaq Computer Corp.
+       0002  InkJet Color Printer
+       0003  iPAQ PocketPC
+       000e  Internet Keyboard
+       0012  InkJet Color Printer
+       0018  PA-1/PA-2 MP3 Player
+       0019  InkJet Color Printer
+       001a  S4 100 Scanner
+       001e  IJ650 Inkjet Printer
+       001f  WL215 Adapter
+       0021  S200 Scanner
+       0027  Bluetooth Multiport Module by Compaq
+       002a  1400P Inkjet Printer
+       002b  A3000
+       002c  Lexmark X125
+       0032  802.11b Adapter [ipaq h5400]
+       0033  802.11b Adapter [orinoco]
+       0036  Bluetooth Multiport Module
+       0051  KU-0133 Easy Access Interner Keyboard
+       0076  Wireless LAN MultiPort W200
+       0080  GPRS Multiport
+       0086  Bluetooth Device
+       504a  Personal Jukebox PJB100
+       505a  Linux-USB "CDC Subset" Device, or Itsy (experimental)
+       8511  iPAQ Networking 10/100 Ethernet [pegasus2]
+04a0  Digital Equipment Corp.
+04a1  SystemSoft Corp.
+       fff0  Telex Composite Device
+04a2  FirePower Systems
+04a3  Trident Microsystems, Inc.
+04a4  Hitachi, Ltd
+       0004  DVD-CAM DZ-MV100A Camcorder
+       001e  DVDCAM USB HS Interface
+04a5  Acer Peripherals Inc. (now BenQ Corp.)
+       0001  Keyboard
+       0002  API Ergo K/B
+       0003  API Generic K/B Mouse
+       12a6  AcerScan C310U
+       1a20  Prisa 310U
+       1a2a  Prisa 620U
+       2022  Prisa 320U/340U
+       2040  Prisa 620UT
+       205e  ScanPrisa 640BU
+       2060  Prisa 620U+/640U
+       207e  Prisa 640BU
+       209e  ScanPrisa 640BT
+       20ae  S2W 3000U
+       20b0  S2W 3300U/4300U
+       20be  Prisa 640BT
+       20c0  Prisa 1240UT
+       20de  S2W 4300U+
+       20f8  Benq 5000
+       20fc  Benq 5000
+       20fe  SW2 5300U
+       2137  Benq 5150/5250
+       2202  Benq 7400UT
+       3003  Benq WebCam
+       3008  Benq 1500
+       300a  Benq 3410
+       300c  Benq 1016
+       3019  Benq DC C40
+       4000  P30 Composite Device
+       6001  Mass Storage Device
+       6002  Mass Storage Device
+       6003  ATA/ATAPI Adapter
+       6004  Mass Storage Device
+       6005  Mass Storage Device
+       6006  Mass Storage Device
+       6007  Mass Storage Device
+       6008  Mass Storage Device
+       6009  Mass Storage Device
+       600a  Mass Storage Device
+       600b  Mass Storage Device
+       600c  Mass Storage Device
+       600d  Mass Storage Device
+       600e  Mass Storage Device
+       600f  Mass Storage Device
+       6010  Mass Storage Device
+       6011  Mass Storage Device
+       6012  Mass Storage Device
+       6013  Mass Storage Device
+       6014  Mass Storage Device
+       6015  Mass Storage Device
+       6125  MP3 Player
+       6180  MP3 Player
+       6200  MP3 Player
+       7500  Hi-Speed Mass Storage Device
+       9000  AWL300 Wireless Adapter
+       9001  AWL400 Wireless Adapter
+       9213  Kbd Hub
+04a6  Nokia Display Products
+       00b9  Audio
+       0180  Hub Type P
+       0181  HID Monitor Controls
+04a7  Visioneer
+       0100  StrobePro
+       0101  Strobe Pro Scanner (1.01)
+       0102  StrobePro Scanner
+       0211  OneTouch 7600 Scanner
+       0221  OneTouch 5300 Scanner
+       0223  OneTouch 8200
+       0224  OneTouch 4800 USB/Microtek Scanport 3000
+       0225  VistaScan Astra 3600(ENG)
+       0226  OneTouch 5300 USB
+       0229  OneTouch 7100
+       022a  OneTouch 6600
+       022c  OneTouch 9000/9020
+       0231  6100 Scanner
+       0311  6200 EPP/USB Scanner
+       0321  OneTouch 8100 EPP/USB Scanner
+       0331  OneTouch 8600 EPP/USB Scanner
+       0341  6400
+       0361  VistaScan Astra 3600(ENG)
+       0362  OneTouch 9320
+       0371  OneTouch 8700/8920
+       0380  OneTouch 7700
+       0382  Photo Port 7700
+       0390  9650
+       03a0  Xerox 4800 One Touch
+       0410  OneTouch Pro 8800/8820
+       0421  9450 USB
+       0423  9750 Scanner
+       0424  Strobe XP 450
+       0425  Strobe XP 100
+       0426  Strobe XP 200
+       0427  Strobe XP 100
+       0444  OneTouch 7300
+       0445  CardReader 100
+       0446  Xerox DocuMate 510
+       0447  XEROX DocuMate 520
+       0448  XEROX DocuMate 250
+       0449  Xerox DocuMate 252
+       044a  Xerox 6400
+       044c  Xerox DocuMate 262
+       0474  Strobe XP 300
+       0475  Xerox DocuMate 272
+       0478  Strobe XP 220
+       0479  Strobe XP 470
+       047a  9450
+       047b  9650
+       047d  9420
+       0480  9520
+       048f  Strobe XP 470
+       0491  Strobe XP 450
+       0493  9750
+       0494  Strobe XP 120
+       0497  Patriot 430
+       0498  Patriot 680
+       0499  Patriot 780
+       049b  Strobe XP 100
+       04a0  7400
+04a8  Multivideo Labs, Inc.
+       0101  Hub
+       0303  Peripheral Switch
+       0404  Peripheral Switch
+04a9  Canon, Inc.
+       1005  BJ Printer Hub
+       1035  PD Printer Storage
+       1050  BJC-8200
+       1051  BJC-3000 Color Printer
+       1052  BJC-6100
+       1053  BJC-6200
+       1054  BJC-6500
+       1055  BJC-85
+       1056  BJC-2110 Color Printer
+       1057  LR1
+       105a  BJC-55
+       105b  S600 Printer
+       105c  S400
+       105d  S450 Printer
+       105e  S800
+       1062  S500 Printer
+       1063  S4500
+       1064  S300 Printer
+       1065  S100
+       1066  S630
+       1067  S900
+       1068  S9000
+       1069  S820
+       106a  S200 Printer
+       106b  S520 Printer
+       106d  S750 Printer
+       106e  S820D
+       1070  S530D
+       1072  I850 Printer
+       1073  I550 Printer
+       1074  S330 Printer
+       1076  i70
+       1077  i950
+       107a  S830D
+       107b  i320
+       107c  i470D
+       107d  i9100
+       107e  i450
+       107f  i860
+       1082  i350
+       1084  i250
+       1085  i255
+       1086  i560
+       1088  i965
+       108a  i455
+       108b  i900D
+       108c  i475D
+       108d  PIXMA iP2000
+       108f  i80
+       1090  i9900 Photo Printer
+       1091  PIXMA iP1500
+       1093  PIXMA iP4000
+       1094  PIXMA iP3000x Printer
+       1095  PIXMA iP6000D
+       1097  PIXMA iP5000
+       1098  PIXMA iP1000
+       1099  PIXMA iP8500
+       109c  PIXMA iP4000R
+       109d  iP90
+       10a0  PIXMA iP1600 Printer
+       10a2  iP4200
+       10a4  iP5200R
+       10a5  iP5200
+       10a7  iP6210D
+       10a8  iP6220D
+       10a9  iP6600D
+       10b6  PIXMA iP4300 Printer
+       1404  W6400PG
+       1405  W8400PG
+       150f  BIJ2350 PCL
+       1510  BIJ1350 PCL
+       1512  BIJ1350D PCL
+       1601  DR-2080C Scanner
+       1607  DR-6080 Scanner
+       1700  PIXMA MP110 Scanner
+       1701  PIXMA MP130 Scanner
+       1702  MP410 Composite
+       1703  MP430 Composite
+       1704  MP330 Composite
+       1706  PIXMA MP750 Scanner
+       1707  PIXMA MP780 Scanner
+       1708  PIXMA MP760 Scanner
+       1709  PIXMA MP150 Scanner
+       170a  PIXMA MP170 Scanner
+       170b  PIXMA MP450 Scanner
+       170c  PIXMA MP500 Scanner
+       170d  PIXMA MP800 Scanner
+       170e  MP800R
+       1710  MP950
+       1712  MP530
+       1713  PIXMA MP830 Scanner
+       1714  MP160
+       1715  MP180 Storage
+       1716  MP460 Composite
+       1717  MP510
+       1718  MP600 Storage
+       171a  MP810 Storage
+       171b  MP960
+       1721  MP210 ser
+       1723  MP470 ser
+       1725  MP610 ser
+       1726  MP970 ser
+       1727  MX300 ser
+       1728  MX310 ser
+       1729  MX700 ser
+       172b  MP140 ser
+       2200  CanoScan LiDE 25
+       2201  CanoScan FB320U
+       2202  CanoScan FB620U
+       2204  CanoScan FB630U
+       2205  CanoScan FB1210U
+       2206  CanoScan N650U/N656U
+       2207  CanoScan 1220U
+       2208  CanoScan D660U
+       220a  CanoScan D2400UF
+       220b  CanoScan D646U
+       220c  CanoScan D1250U2
+       220d  CanoScan N670U/N676U/LiDE 20
+       220e  CanoScan N1240U/LiDE 30
+       220f  CanoScan 8000F
+       2210  CanoScan 9900F
+       2212  CanoScan 5000F
+       2213  CanoScan LiDE 50/LiDE 35/LiDE 40
+       2214  CanoScan LiDE 80
+       2215  CanoScan 3000/3000F/3000ex
+       2216  CanoScan 3200F
+       2217  CanoScan 5200F
+       2219  CanoScan 9950F
+       221b  CanoScan 4200F
+       221c  CanoScan LiDE 60
+       221e  CanoScan 8400F
+       221f  CanoScan LiDE 500F
+       2220  CanoScan LIDE 25
+       2225  CanoScan LiDE 70
+       2228  CanoScan 4400F
+       2602  MultiPASS C555
+       2603  MultiPASS C755
+       260a  CAPT Printer
+       260e  LBP-2000
+       2610  MPC600F
+       2611  SmartBase MPC400
+       2612  MultiPASS C855
+       2617  CAPT Printer
+       261a  iR1600
+       261b  iR1610
+       261c  iC2300
+       261f  MPC200 Printer
+       2621  iR2000
+       2622  iR2010
+       2623  FAX-B180C
+       2629  FAXPHONE L75
+       262b  LaserShot LBP-1120 Printer
+       262d  iR C3200
+       262f  MultiPASS MP730
+       2630  MultiPASS MP700
+       2631  LASER CLASS 700
+       2632  FAX-L2000
+       2635  MPC190
+       2637  iR C6800
+       2638  iR C3100
+       263c  Smartbase MP360
+       263d  MP370
+       263e  MP390 FAX
+       263f  MP375
+       2646  MF5530 Scanner Device V1.9.1
+       2647  MF5550 Composite
+       264e  MF5630
+       264f  MF5650 (FAX)
+       2650  iR 6800C EUR
+       2651  iR 3100C EUR
+       2655  FP-L170/MF350/L380/L398
+       2659  MF8100
+       265b  CAPT Printer
+       265c  iR C3220
+       265d  MF5730
+       265e  MF5750
+       265f  MF5770
+       2660  MF3110
+       2663  iR3570/iR4570
+       2664  iR2270/iR2870
+       2665  iR C2620
+       2666  iR C5800
+       2667  iR85PLUS
+       2669  iR105PLUS
+       266a  CAPT Device
+       266b  iR8070
+       266c  iR9070
+       266d  iR 5800C EUR
+       266e  CAPT Device
+       266f  iR2230
+       2670  iR3530
+       2671  iR5570/iR6570
+       2672  iR C3170
+       2673  iR 3170C EUR
+       2674  L120
+       2675  iR2830
+       2676  CAPT Device
+       2677  iR C2570
+       2678  iR 2570C EUR
+       2679  CAPT Device
+       267a  iR2016
+       267b  iR2020
+       267d  MF7100 Series
+       2684  MF3200 Series
+       2687  iR4530
+       2688  LBP3460
+       268c  iR C6870
+       268d  iR 6870C EUR
+       268e  iR C5870
+       268f  iR 5870C EUR
+       2691  iR7105
+       26a3  MF4100 Series
+       26b5  MF4200 Series
+       3041  PowerShot S10
+       3042  CanoScan FS4000US Film Scanner
+       3043  PowerShot S20
+       3044  EOS D30
+       3045  PowerShot S100
+       3046  IXY Digital
+       3047  Digital IXUS
+       3048  PowerShot G1
+       3049  PowerShot Pro90 IS
+       304a  CP-10
+       304b  IXY Digital 300
+       304c  PowerShot S300
+       304d  Digital IXUS 300
+       304e  PowerShot A20
+       304f  PowerShot A10
+       3050  PowerShot unknown 1
+       3051  PowerShot S110
+       3052  Digital IXUS V
+       3055  PowerShot G2
+       3056  PowerShot S40
+       3057  PowerShot S30
+       3058  PowerShot A40
+       3059  PowerShot A30
+       305b  ZR45MC Digital Camcorder
+       305c  PowerShot unknown 2
+       3060  EOS D60
+       3061  PowerShot A100
+       3062  PowerShot A200
+       3063  CP-100
+       3065  PowerShot S200
+       3066  Digital IXUS 330
+       3067  MV550i Digital Video Camera
+       3069  PowerShot G3
+       306a  Digital unknown 3
+       306b  MVX2i Digital Video Camera
+       306c  PowerShot S45
+       306d  PowerShot S45 PtP Mode
+       306e  PowerShot G3 (normal mode)
+       306f  PowerShot G3 (ptp)
+       3070  PowerShot S230
+       3071  PowerShot S230 (ptp)
+       3072  PowerShot SD100 / Digital IXUS II (ptp)
+       3073  PowerShot A70 (ptp)
+       3074  PowerShot A60 (ptp)
+       3075  IXUS 400 Camera
+       3076  PowerShot A300
+       3077  PowerShot S50
+       3078  ZR70MC Digital Camcorder
+       307a  MV650i (normal mode)
+       307b  MV630i Digital Video Camera
+       307c  MV630i (normal mode)
+       307d  CP-300
+       307f  Optura 20
+       3080  MVX150i (normal mode) / Optura 20 (normal mode)
+       3081  Optura 10
+       3082  MVX100i / Optura 10
+       3083  EOS 10D
+       3084  EOS 300D / EOS Digital Rebel
+       3085  PowerShot G5
+       3087  Elura 50 (PTP mode)
+       3088  Elura 50 (normal mode)
+       308d  MVX3i
+       308e  FV M1 (normal mode) / MVX 3i (normal mode) / Optura Xi (normal mode)
+       3093  Optura 300
+       3096  IXY DV M2 (normal mode) / MVX 10i (normal mode)
+       3099  EOS 300D (ptp)
+       309a  PowerShot A80
+       309b  Digital IXUS (ptp)
+       309c  PowerShot S1 IS
+       309d  Camera
+       309f  Camera
+       30a0  Camera
+       30a1  Camera
+       30a2  Camera
+       30a8  Elura 60E/Optura 40 (ptp)
+       30a9  MVX25i (normal mode) / Optura 40 (normal mode)
+       30b1  PowerShot S70 (normal mode) / PowerShot S70 (PTP mode)
+       30b2  PowerShot S60 (normal mode) / PowerShot S60 (PTP mode)
+       30b3  PowerShot G6 (normal mode) / PowerShot G6 (PTP mode)
+       30b4  PowerShot S500
+       30b5  PowerShot A75
+       30b6  Digital IXUS II2  / Digital IXUS II2 (PTP mode) / PowerShot SD110 (PTP mode) / PowerShot SD110 Digital ELPH
+       30b7  PowerShot A400 / PowerShot A400 (PTP mode)
+       30b8  PowerShot A310 / PowerShot A310 (PTP mode)
+       30b9  Powershot A85
+       30ba  PowerShot S410 Digital Elph
+       30bb  PowerShot A95
+       30bd  CP-220
+       30be  CP-330
+       30bf  Digital IXUS 40
+       30c0  Digital IXUS 30 (PTP mode) / PowerShot SD200 (PTP mode)
+       30c1  Digital IXUS 50 (normal mode) / IXY Digital 55 (normal mode) / PowerShot A520 (PTP mode) / PowerShot SD400 (normal mode)
+       30c2  PowerShot A510 (normal mode) / PowerShot A510 (PTP mode)
+       30c4  Digital IXUS i5 (normal mode) / IXY Digital L2 (normal mode) / PowerShot SD20 (normal mode)
+       30ea  EOS 1D Mark II (PTP mode)
+       30eb  EOS 20D
+       30ec  EOS 20D (ptp)
+       30ee  EOS 350D
+       30ef  EOS 350D (ptp)
+       30f0  PowerShot S2 IS (PTP mode)
+       30f2  Digital IXUS 700 (normal mode) / Digital IXUS 700 (PTP mode) / IXY Digital 600 (normal mode) / PowerShot SD500 (normal mode) / PowerShot SD500 (PTP mode)
+       30f6  SELPHY CP400
+       30f8  Powershot A430
+       30f9  PowerShot A410 (PTP mode)
+       30fc  PowerShot A620 (PTP mode)
+       30fd  PowerShot A610 (normal mode)/PowerShot A610 (PTP mode)
+       30ff  Digital IXUS 55 (PTP mode)/PowerShot SD450 (PTP mode)
+       310b  SELPHY CP600
+       310e  Digital IXUS 50 (PTP mode)
+       3116  Digital IXUS 750 (PTP mode)
+       3117  PowerShot A700
+       3138  PowerShot A710 IS
+       315a  PowerShot G9
+       3176  PowerShot A590
+       31ff  Digital IXUS 55
+04aa  DaeWoo Telecom, Ltd
+04ab  Chromatic Research
+04ac  Micro Audiometrics Corp.
+04ad  Dooin Electronics
+       2501  Bluetooth Device
+04af  Winnov L.P.
+04b0  Nikon Corp.
+       0102  Coolpix 990
+       0103  Coolpix 880
+       0104  Coolpix 995
+       0106  Coolpix 775
+       0107  Coolpix 5000
+       0108  Coolpix 2500
+       0109  Coolpix 2500 (ptp)
+       010a  Coolpix 4500
+       010b  Coolpix 4500 (ptp)
+       010d  Coolpix 5700 (ptp)
+       010e  Coolpix 4300 (storage)
+       010f  Coolpix 4300 (ptp)
+       0110  Coolpix 3500 (Sierra Mode)
+       0111  Coolpix 3500 (ptp)
+       0112  Coolpix 885 (ptp)
+       0113  Coolpix 5000 (ptp)
+       0114  Coolpix 3100 (storage)
+       0115  Coolpix 3100 (ptp)
+       0117  Coolpix 2100 (ptp)
+       0119  Coolpix 5400 (ptp)
+       011d  Coolpix 3700 (ptp)
+       0121  Coolpix 3200 (ptp)
+       0122  Coolpix 2200 (ptp)
+       0126  Coolpix 8800
+       0129  Coolpix 4800 (ptp)
+       012c  Coolpix 4100 (storage)
+       012d  Coolpix 4100 (ptp)
+       012e  Coolpix 5600 (ptp)
+       0130  Coolpix 4600 (ptp)
+       0135  Coolpix 5900 (ptp)
+       0136  Coolpix 7900 (storage)
+       0137  Coolpix 7900 (ptp)
+       0141  Coolpix P2 (storage)
+       0142  Coolpix P2 (ptp)
+       0163  Coolpix P5100 (ptp)
+       0169  Coolpix P50 (ptp)
+       0202  Coolpix SQ (ptp)
+       0203  Coolpix 4200 (mass storage mode)
+       0204  Coolpix 4200 (ptp)
+       0205  Coolpix 5200 (storage)
+       0206  Coolpix 5200 (ptp)
+       0301  Coolpix 2000 (storage)
+       0302  Coolpix 2000 (ptp)
+       0402  DSC D100 (ptp)
+       0403  D2H (mass storage mode)
+       0404  D2H SLR (ptp)
+       0405  D70 (mass storage mode)
+       0406  DSC D70 (ptp)
+       0408  D2X SLR (ptp)
+       0409  D50 digital camera
+       040a  D50 (ptp)
+       040c  D2Hs
+       040e  DSC D70s (ptp)
+       0413  D40 (mass storage mode)
+       4000  Coolscan LS 40 ED
+       4001  LS 50 ED/Coolscan V ED
+       4002  Super Coolscan LS-5000 ED
+04b1  Pan International
+04b3  IBM Corp.
+       3003  Rapid Access III Keyboard
+       3004  Media Access Pro Keyboard
+       300a  Rapid Access IIIe Keyboard
+       3016  UltraNav Keyboard Hub
+       3018  UltraNav Keyboard
+       301b  SK-8815 Keyboard
+       301c  Enhanced Performance Keyboard
+       3020  Enhanced Performance Keyboard
+       3100  NetVista Mouse
+       3103  ScrollPoint Pro Mouse
+       3104  ScrollPoint Wireless Mouse
+       3105  ScrollPoint Optical (HID)
+       3107  ThinkPad 800dpi Optical Travel Mouse
+       3108  800dpi Optical Mouse w/ Scroll Point
+       3109  Optical ScrollPoint Pro Mouse
+       310b  Red Wheel Mouse
+       4427  Portable CD ROM
+       4482  Serial Converter
+       4525  Double sided CRT
+       4550  NVRAM (128 KB)
+       4554  Cash Drawer
+       4580  Hub w/ NVRAM
+       4581  4800-2xx Hub w/ Cash Drawer
+       4604  Keyboard w/ Card Reader
+       4671  4820 LCD w/ MSR/KB
+04b4  Cypress Semiconductor Corp.
+       0000  Dacal DC-101 CD Library
+       0001  Mouse
+       0002  CY7C63x0x Thermometer
+       0101  Keyboard/Hub
+       0102  Keyboard with APM
+       0130  MyIRC Remote Receiver
+       0bad  MetaGeek Wi-Spy
+       1002  CY7C63001 R100 FM Radio
+       1006  Human Interface Device
+       4381  SCAPS USC-1 Scanner Controller
+       4611  Storage Adapter FX2 (CY)
+       4616  Flash Disk (TPP)
+       5500  HID->COM RS232 Adapter
+       6370  ViewMate Desktop Mouse CC2201
+       6560  CY7C65640 USB-2.0 "TetraHub"
+       6830  CY7C68300A EZ-USB AT2 USB 2.0 to ATA/ATAPI
+       6831  Storage Adapter ISD-300LP (CY)
+       7417  Wireless PC Lock
+       8613  CY7C68013 EZ-USB FX2 USB 2.0 Development Kit
+       8614  DTV-DVB UDST7020BDA DVB-S Box(DVBS for MCE2005)
+       cc04  Centor USB RACIA-ALVAR USB PORT
+       cc06  Centor-P RACIA-ALVAR USB PORT
+       d5d5  CY7C63x0x Zoltrix Z-Boxer GamePad
+       f000  CY30700 Licorice evaluation board
+04b5  ROHM LSI Systems USA, LLC
+04b6  Hint Corp.
+04b7  Compal Electronics, Inc.
+04b8  Seiko Epson Corp.
+       0001  Stylus Color 740 / Photo 750
+       0002  ISD Smart Cable for Mac
+       0003  ISD Smart Cable
+       0004  Printer
+       0005  Stylus D88+
+       0006  Printer
+       0007  Printer
+       0101  Perfection 636
+       0102  GT-2200
+       0103  Perfection 610
+       0104  Perfection 1200
+       0105  StylusScan 2000
+       0106  Stylus Scan 2500
+       0107  Expression 1600U
+       0109  Expression 1640 XL
+       010a  Perfection 1640SU
+       010b  Perfection 1240
+       010c  Perfection 640
+       010e  Perfection 1680
+       010f  Perfection 1250
+       0110  Perfection 1650
+       0112  Perfection 2450
+       0114  Perfection 660
+       0116  Perfection 3170 (GT-9400)
+       0118  Perfection 4180 (GF-F600)
+       0119  Perfection 4490 Photo
+       011a  1000 ICS
+       011b  Perfection 2400 Photo
+       011c  Perfection 3200
+       011d  Perfection 1260 Photo
+       011e  Perfection 1660 Photo
+       011f  Perfection 1670
+       0120  Perfection 1270 scanner
+       0121  Perfection 2480 Photo
+       0122  Perfection 3590 scanner
+       0126  GT-15000 (ES-7000)
+       0128  Perfection 4870 (GT-X700)
+       0129  Expression 10000XL (ES-10000G)
+       012a  Perfection 4990 Photo scanner
+       012b  GT-2500 (ES-H300)
+       012c  Perfection V350 (GT-F700)
+       012d  Perfection V10/V100 (GT-S600/F650)
+       012f  Perfection V350 (GT-F700)
+       0202  Receipt Printer M129C
+       0401  CP 800 Digital Camera
+       0402  PhotoPC 850z
+       0403  PhotoPC 3000z
+       0509  JVC PIX-MC10
+       0601  Stylus Photo 875DC Card Reader
+       0602  Stylus Photo 895 Card Reader
+       0801  Stylus CX5200/CX5400/CX6600
+       0802  Stylus CX3200
+       0803  Printer (Composite Device)
+       0804  Storage Device
+       0805  Stylus CX6400
+       0806  Stylus Photo RX600/610
+       0807  Stylus Photo RX500/510
+       0808  Stylus CX5200
+       0809  Storage Device
+       080a  Storage Device
+       080c  ME100
+       080d  Stylus CX4500/4600
+       080e  CX-3500/3600/3650 MFP
+       080f  Stylus Photo RX425 scanner
+       0810  Stylus Photo RX700 (PM-A900)
+       0811  Stylus Photo RX620 all-in-one
+       0812  MFP Composite Device
+       0813  Stylus CX6500/6600
+       0814  (PM-A700)
+       0815  AcuLaser CX11 (LP-A500)
+       0816  Printer (Composite Device)
+       0817  (LP-M5500)
+       0818  Stylus CX3700/CX3800/DX3800
+       0819  Stylus CX4700/CX4800/DX4800 (PX-A750)
+       081a  Stylus Photo RX520/RX530 (PM-A750)
+       081b  MFP Composite Device
+       081c  Stylus Photo RX640/RX650 (PM-A890)
+       081d  (PM-A950)
+       081e  MFP Composite Device
+       081f  Stylus CX7700/7800
+       0820  CX4200 MP scanner
+       0821  MFP Composite Device
+       0822  Storage Device
+       0823  MFP Composite Device
+       0824  Storage Device
+       0825  MFP Composite Device
+       0826  Storage Device
+       0827  Stylus Photo RX560/580/590 (PM-A820)
+       0828  (PM-A970)
+       0829  (PM-T990)
+       082a  (PM-A920)
+       082b  Stylus DX5050
+       082c  Storage Device
+       082d  Storage Device
+       082e  0x082e  DX-60x0 MFP scanner
+       082f  Stylus DX4050
+       0830  Stylus CX2800/CX2900/ME200
+       0831  MFP Composite Device
+       0832  MFP Composite Device
+       0833  (LP-M5600)
+       0834  MFP Composite Device
+       0835  AcuLaser CX21
+       0836  MFP Composite Device
+       0837  MFP Composite Device
+       0838  CX7300/CX7400/DX7400
+       0839  CX8300/CX8400/DX8400
+       083a  CX9300F/CX9400Fax/DX9400F
+       083b  MFP Composite Device
+       083c  MFP Composite Device
+       083d  MFP Composite Device
+       083e  MFP Composite Device
+       083f  Stylus DX4450
+04b9  Rainbow Technologies, Inc.
+       0300  SafeNet USB SuperPro/UltraPro
+       1000  iKey 1000 Token
+       1001  iKey 1200 Token
+       1002  iKey Token
+       1003  iKey Token
+       1004  iKey Token
+       1005  iKey Token
+       1006  iKey Token
+       1200  iKey 2000 Token
+       1201  iKey Token
+       1202  iKey 2032 Token
+       1203  iKey Token
+       1204  iKey Token
+       1205  iKey Token
+       1206  iKey Token
+       1300  iKey 3000 Token
+       1301  iKey 3000
+       1302  iKey Token
+       1303  iKey Token
+       1304  iKey Token
+       1305  iKey Token
+       1306  iKey Token
+04ba  Toucan Systems, Ltd
+04bb  I-O Data Device, Inc.
+       0101  USB2-IDE/ATAPI Bridge Adapter
+       0201  USB2-IDE/ATAPI Bridge Adapter
+       0204  DVD Multi-plus unit iU-CD2
+       0206  DVD Multi-plus unit DVR-UEH8
+       0301  Storage Device
+       0314  USB-SSMRW SD-card
+       0319  USB2-IDE/ATAPI Bridge Adapter
+       031a  USB2-IDE/ATAPI Bridge Adapter
+       031b  USB2-IDE/ATAPI Bridge Adapter
+       031e  USB-SDRW SD-card
+       0502  Nogatech Live! (BT)
+       0901  USB ETT
+       0904  ET/TX Ethernet [pegasus]
+       0913  ET/TX-S Ethernet [pegasus2]
+       0919  USB WN-B11
+       0922  IOData AirPort WN-B11/USBS 802.11b
+       0930  ETG-US2
+       0937  WN-WAG/USL Wireless LAN Adapter
+       0938  WN-G54/USL Wireless LAN Adapter
+       0a03  Serial USB-RSAQ1
+       0a07  USB2-iCN Adapter
+       0a08  USB2-iCN Adapter
+       0c01  FM-10 Pro Disk
+04bd  Toshiba Electronics Taiwan Corp.
+04be  Telia Research AB
+04bf  TDK Corp.
+       0100  MediaReader CF
+       0115  USB-PDC Adapter UPA9664
+       0116  USB-cdmaOne Adapter UCA1464
+       0117  USB-PHS Adapter UHA6400
+       0118  USB-PHS Adapter UPA6400
+       0135  MediaReader Dual
+       0202  73S1121F Smart Card Reader-
+       0309  Bluetooth USB dongle
+       030a  IBM Bluetooth Ultraport Module
+       030b  Bluetooth Device
+       030c  Ultraport Bluetooth Device
+       0310  Integrated Bluetooth
+       0311  Integrated Bluetooth Device
+       0317  Bluetooth UltraPort Module from IBM
+       0318  IBM Integrated Bluetooth
+       0319  Bluetooth Adapter
+       0320  Bluetooth Adapter
+       0321  Bluetooth Device
+       0a28  INDI AV-IN Device
+04c1  U.S. Robotics (3Com)
+       0020  56K Voice Pro
+       0022  56K Voice Pro
+       007e  ISDN TA
+       0082  OfficeConnect Analog Modem
+       008f  Pro ISDN TA
+       0097  OfficeConnect Analog
+       009d  HomeConnect WebCam [vicam]
+       00a9  ISDN Pro TA-U
+       00b9  HomeConnect IDSL Modem
+       3021  56k Voice FaxModem Pro
+04c2  Methode Electronics Far East PTE, Ltd
+04c3  Maxi Switch, Inc.
+       1102  Mouse
+       2102  Mouse
+04c4  Lockheed Martin Energy Research
+04c5  Fujitsu, Ltd
+       1029  fi-4010c Scanner
+       1033  fi-4110CU
+       1041  fi-4120c Scanner
+       1042  fi-4220c Scanner
+       105b  AH-F401U Air H device
+       1096  fi-5110EOX
+       1097  fi-5110C
+       10ae  fi-4120C2
+       10af  fi-4220C2
+       10e0  fi-5120c Scanner
+       10e1  fi-5220C
+       10e7  fi-5900C
+       10fe  S500
+04c6  Toshiba America Electronic Components
+04c7  Micro Macro Technologies
+04c8  Konica Corp.
+       0720  Digital Color Camera
+       0721  e-miniD Camera
+       0722  e-mini
+       0723  KD-200Z Camera
+       0726  KD-310Z Camera
+       0728  Revio C2 Mass Storage Device
+       0729  Revio C2 Digital Camera
+       072c  Revio KD20M
+       072d  Revio KD410Z
+04ca  Lite-On Technology Corp.
+       1766  HID Monitor Controls
+       9304  Hub
+04cb  Fuji Photo Film Co., Ltd
+       0100  FinePix 30i/40i/50i, A101/201, 1300/2200, 1400/2400/2600/2800/4500/4700/4800/4900/6800/6900 Zoom
+       0103  FinePix NX-500/NX-700 printer
+       0104  FinePix A101, 2600/2800/4800/6800 Zoom (PC CAM)
+       0108  FinePix F601 Zoom (DSC)
+       0109  FinePix F601 Zoom (PC CAM)
+       010a  FinePix S602 (Pro) Zoom (DSC)
+       010b  FinePix S602 (Pro) Zoom (PC CAM)
+       010d  FinePix Digital Camera 020531
+       010e  FinePix F402 Zoom (DSC)
+       010f  FinePix F402 Zoom (PC CAM)
+       0110  FinePix M603 Zoom (DSC)
+       0111  FinePix M603 Zoom (PC CAM)
+       0112  FinePix A202, A200 Zoom (DSC)
+       0113  FinePix A202, A200 Zoom (PC CAM)
+       0114  FinePix F401 Zoom (DSC)
+       0115  FinePix F401 Zoom (PC CAM)
+       0116  FinePix A203 Zoom (DSC)
+       0117  FinePix A203 Zoom (PC CAM)
+       0118  FinePix A303 Zoom (DSC)
+       0119  FinePix A303 Zoom (PC CAM)
+       011a  FinePix S304/3800 Zoom (DSC)
+       011b  FinePix S304/3800 Zoom (PC CAM)
+       011c  FinePix A204/2650 Zoom (DSC)
+       011d  FinePix A204/2650 Zoom (PC CAM)
+       0120  FinePix F700 Zoom (DSC)
+       0121  FinePix F700 Zoom (PC CAM)
+       0122  FinePix F410 Zoom (DSC)
+       0123  FinePix F410 Zoom (PC CAM)
+       0124  FinePix A310 Zoom (DSC)
+       0125  FinePix A310 Zoom (PC CAM)
+       0126  FinePix A210 Zoom (DSC)
+       0127  FinePix A210 Zoom (PC CAM)
+       0128  FinePix A205(S) Zoom (DSC)
+       0129  FinePix A205(S) Zoom (PC CAM)
+       012a  FinePix F610 Zoom (DSC)
+       012b  FinePix Digital Camera 030513
+       012c  FinePix S7000 Zoom (DSC)
+       012d  FinePix S7000 Zoom (PC CAM)
+       012f  FinePix Digital Camera 030731
+       0130  FinePix S5000 Zoom (DSC)
+       0131  FinePix S5000 Zoom (PC CAM)
+       013b  FinePix Digital Camera 030722
+       013c  FinePix S3000 Zoom (DSC)
+       013d  FinePix S3000 Zoom (PC CAM)
+       013e  FinePix F420 Zoom (DSC)
+       013f  FinePix F420 Zoom (PC CAM)
+       0142  FinePix S7000 Zoom (PTP)
+       0148  FinePix A330 Zoom (DSC)
+       0149  FinePix A330 Zoom (UVC)
+       014a  FinePix A330 Zoom (PTP)
+       014b  FinePix A340 Zoom (DSC)
+       0159  FinePix F710 Zoom (DSC)
+       0165  FinePix S3500 Zoom (DSC)
+       0168  FinePix E500 Zoom (DSC)
+       0169  FinePix E500 Zoom (UVC)
+       016b  FinePix E510 Zoom (DSC)
+       016c  FinePix E510 Zoom (PC CAM)
+       016e  FinePix S5500 Zoom (DSC)
+       016f  FinePix S5500 Zoom (UVC)
+       0171  FinePix E550 Zoom (DSC)
+       0172  FinePix E550 Zoom (PTP)
+       0177  FinePix F10 (DSC)
+       0179  Finepix F10 (PTP)
+       0186  FinePix S5200/S5600 Zoom (DSC)
+       0188  FinePix S5200/S5600 Zoom (PTP)
+       018e  FinePix S9500 Zoom (DSC)
+       018f  FinePix S9500 Zoom (PTP)
+       0192  FinePix E900 Zoom (DSC)
+       0193  FinePix E900 Zoom (PTP)
+       019b  FinePix F30 (PTP)
+       01bf  FinePix F6000fd/S6500fd Zoom (PTP)
+       01c0  FinePix F20 (PTP)
+       01c1  FinePix F31fd (PTP)
+       01c4  FinePix S5700 Zoom (PTP)
+       01c5  FinePix F40fd (PTP)
+       01c6  FinePix A820 Zoom (PTP)
+       01d2  FinePix A800 Zoom (PTP)
+       01d5  FinePix F47 (PTP)
+04cc  Philips Semiconductors
+       1122  Hub
+       1521  USB 2.0 Hub
+       8116  Camera
+04cd  Tatung Co. Of America
+04ce  ScanLogic Corp.
+       0002  SL11R-IDE IDE Bridge
+       0100  USB2PRN Printer Class
+       0300  Phantom 336CX - C3 scanner
+       04ce  SL11DEMO, VID: 0x4ce, PID: 0x4ce
+       07d1  SL11R, VID: 0x4ce, PID: 0x07D1
+04cf  Myson Century, Inc.
+       0800  MTP800 Mass Storage Device
+       8810  CS8810 Mass Storage Device
+       8811  CS8811 Mass Storage Device
+       8813  CS8813 Mass Storage Device
+       8818  USB2.0 to ATAPI Bridge Controller
+04d0  Digi International
+04d1  ITT Canon
+04d2  Altec Lansing Technologies
+       0070  ADA70 Speakers
+       0305  Non-Compliant Audio Device
+       0311  ADA-310 Speakers
+       2060  Claritel-i750 - vp
+       ff05  ADA-305 Speakers
+       ff47  Lansing HID Audio Controls
+       ff49  Lansing HID Audio Controls
+04d3  VidUS, Inc.
+04d4  LSI Logic, Inc.
+04d5  Forte Technologies, Inc.
+04d6  Mentor Graphics
+04d7  Oki Semiconductor
+       1be4  Bluetooth Device
+04d8  Microchip Technology, Inc.
+       0002  USB-LCD 2x20
+       8000  In-Circuit Debugger
+       8001  ICD2 in-circuit debugger
+04d9  Holtek Semiconductor, Inc.
+       1203  MC Industries Keyboard
+04da  Panasonic (Matsushita)
+       0901  LS-120 Camera
+       0b01  CD-R/RW Drive
+       0b03  SuperDisk 240MB
+       0d01  CD-R Drive KXL-840AN
+       0d09  CD-R Drive KXL-RW32AN
+       0d0a  CD-R Drive KXL-CB20AN
+       0d0d  CDRCB03
+       0d0e  DVD-ROM & CD-R/RW
+       0f40  Printer
+       1500  MFSUSB Driver
+       1b00  MultiMediaCard
+       2121  EB-VS6
+       2317  DVC USB-SERIAL Driver for WinXP
+       2319  NV-GS15 (webcam mode)
+       231d  DVC Web Camera Device
+       231e  DVC DV Stream Device
+       2372  Lumix DMC-FZ10 Camera
+       2374  DMC-FZ20
+04db  Hypertec Pty, Ltd
+04dc  Huan Hsin Holdings, Ltd
+04dd  Sharp Corp.
+       13a6  MFC2000
+       6006  AL-1216
+       6007  AL-1045
+       6008  AL-1255
+       6009  AL-1530CS
+       600a  AL-1540CS
+       600b  AL-1456
+       600c  AL-1555
+       600d  AL-1225
+       600e  AL-1551CS
+       600f  AR-122E
+       6010  AR-152E
+       6011  AR-157E
+       6012  SN-1045
+       6013  SN-1255
+       6014  SN-1456
+       6015  SN-1555
+       6016  AR-153E
+       6017  AR-122E N
+       6018  AR-153E N
+       6019  AR-152E N
+       601a  AR-157E N
+       601b  AL-1217
+       601c  AL-1226
+       601d  AR-123E
+       7002  DVC Ver.1.0
+       7004  VE-CG40U Digital Still Camera
+       7005  VE-CG30 Digital Still Camera
+       7007  VL-Z7S Digital Camcorder
+       8004  Zaurus SL-5000D/SL-5500 PDA
+       8005  Zaurus A-300
+       8006  Zaurus SL-B500/SL-5600 PDA
+       8007  Zaurus C-700 PDA
+       9014  IM-DR80 Portable NetMD Player
+       9031  Zaurus C-750/C-760/C-860/SL-C3000 PDA
+       9032  Zaurus SL-6000
+       903a  GSM GPRS
+       9050  Zaurus C-860 PDA
+       9056  Viewcam Z
+       9073  AM-900
+       9074  GSM GPRS
+       90a9  Sharp Composite
+       90d0  USB-to-Serial Comm. Port
+       90f2  Sharp 3G GSM USB Control
+       9120  WS004SH
+       9122  WS007SH
+       9123  W-ZERO3 ES Smartphone
+       91a3  922SH Internet Machine
+04de  MindShare, Inc.
+04df  Interlink Electronics
+04e1  Iiyama North America, Inc.
+       0201  Monitor Hub
+04e2  Exar Corp.
+04e3  Zilog, Inc.
+04e4  ACC Microelectronics
+04e5  Promise Technology
+04e6  SCM Microsystems, Inc.
+       0001  E-USB ATA Bridge
+       0002  eUSCSI SCSI Bridge
+       0003  eUSB SmartMedia Card Reader
+       0005  eUSB SmartMedia/CompactFlash Card Reader
+       0006  eUSB SmartMedia Card Reader
+       0007  Hifd
+       0009  eUSB ATA/ATAPI Adapter
+       000a  eUSB CompactFlash Adapter
+       000b  eUSCSI Bridge
+       000c  eUSCSI Bridge
+       000d  Dazzle MS
+       0012  Dazzle SD/MMC
+       0101  eUSB ATA Bridge
+       0311  Dazzle DM-CF
+       0312  Dazzle DM-SD/MMC
+       0313  Dazzle SM
+       0314  Dazzle MS
+       0322  e-Film Reader-5
+       0325  eUSB ORCA Quad Reader
+       0327  Digital Media Reader
+       03fe  DMHS2 DFU Adapter
+       0406  eUSB SmartDM Reader
+       04e6  eUSB DFU Adapter
+       04e7  STCII DFU Adapter
+       04e8  eUSBDM DFU Adapter
+       04e9  DM-E DFU Adapter
+       0500  Veridicom 5thSense Fingerprint Sensor and eUSB SmartCard
+       0701  DCS200 Loader Device
+       0702  DVD Creation Station 200
+       0703  DVC100 Loader Device
+       0704  Digital Video Creator 100
+       1001  SCR300 Smart Card Reader
+       1010  USBAT-2 CompactFlash Card Reader
+       1014  e-Film Reader-3
+       1020  USBAT ATA/ATAPI Adapter
+       2007  RSA SecurID ComboReader
+       2009  Citibank Smart Card Reader
+       200a  Reflex v.2 Smart Card Reader
+       200d  STR391 Reader
+       5111  SCR331-DI SmartCard Reader
+       5113  SCR333 SmartCard Reader
+       5114  SCR331-DI SmartCard Reader
+       5115  SCR335 SmartCard Reader
+       5116  SCR331-LC1 SmartCard Reader
+       5117  SCR3320 - Smart Card Reader
+       5118  Expresscard SIM Card Reader
+       5119  SCR3340 - ExpressCard54 Smart Card Reader
+       511b  SmartCard Reader
+       511d  SCR3311 Smart Card Reader
+       5120  SCR331-DI SmartCard Reader
+       5121  SDI010 Smart Card Reader
+       5151  SCR338 Keyboard Smart Card Reader
+       5410  SCR35xx Smart Card Reader
+       e000  SCRx31 Reader
+       e001  SCR331 SmartCard Reader
+       e003  SPR532 PinPad SmartCard Reader
+04e7  Elo TouchSystems
+       0001  TouchScreen
+       0002  Touchmonitor Interface 2600 Rev 2
+       0004  4000U CarrollTouch® Touchmonitor Interface
+       0007  2500U IntelliTouch® Touchmonitor Interface
+       0008  3000U AccuTouch® Touchmonitor Interface
+       0009  4000U CarrollTouch® Touchmonitor Interface
+       0020  Touchscreen Interface (2700)
+       0021  Touchmonitor Interface
+       0030  4500U CarrollTouch® Touchmonitor Interface
+       0032  Touchmonitor Interface
+       0033  Touchmonitor Interface
+       0041  5010 Surface Capacitive Touchmonitor Interface
+       0042  Touchmonitor Interface
+       0050  2216 AccuTouch® Touchmonitor Interface
+       0071  Touchmonitor Interface
+       0072  Touchmonitor Interface
+       0081  Touchmonitor Interface
+       0082  Touchmonitor Interface
+       00ff  Touchmonitor Interface
+04e8  Samsung Electronics Co., Ltd
+       0110  Connect3D Flash Drive
+       0111  Connect3D Flash Drive
+       1003  MP3 Player and Recorder
+       1006  SDC-200Z
+       3004  ML-4600
+       3005  Docuprint P1210
+       3008  ML-6060 laser printer
+       300c  ML-1210 Printer
+       300e  Laser Printer
+       3104  ML-3550N
+       3226  Laser Printer
+       3228  Laser Printer
+       322a  Laser Printer
+       322c  Laser Printer
+       3230  ML-1440
+       3232  Laser Printer
+       3236  ML-1450
+       3238  ML-1430
+       323a  ML-1710 Printer
+       323b  Phaser 3130
+       323c  Laser Printer
+       323d  Phaser 3120
+       323e  Laser Printer
+       3240  Laser Printer
+       3242  Laser Printer
+       3248  Color Laser Printer
+       324a  Laser Printer
+       324c  ML-1740 Printer
+       324d  Phaser 3121
+       325f  Phaser 3425 Laser Printer
+       3260  CLP-510 Color Laser Printer
+       3268  ML-1610 Mono Laser Printer
+       326c  ML-2010P Mono Laser Printer
+       3409  SCX-4216F Scanner
+       340c  SCX-5x15 Series
+       340d  SCX-6x20 Series
+       340e  MFP 560 Series
+       340f  Printing Support
+       3412  SCX-4x20 Series
+       3413  SCX-4100 Scanner
+       3415  Composite Device
+       3419  Composite Device
+       341a  Printing Support
+       341b  SCX-4200 Series
+       341c  Composite Device
+       341d  Composite Device
+       341f  Composite Device
+       3420  Composite Device
+       3605  InkJet Color Printer
+       3606  InkJet Color Printer
+       3609  InkJet Color Printer
+       3902  InkJet Color Printer
+       3903  Xerox WorkCentre XK50cx
+       390f  InkJet Color Printer
+       3911  SCX-1020 Series
+       5000  YP-MF Series
+       5001  YP-100
+       5002  YP-30
+       5003  YP-700
+       5004  YP-30
+       5005  YP-300
+       5006  YP-750
+       500d  MP3 Player
+       5010  MP3 Player
+       5011  YP-780
+       5013  YP-60
+       5015  yepp upgrade
+       501b  MP3 Player
+       503b  YP-U1 MP3 Player
+       5050  YP-U2 MP3 Player
+       507d  YP-U3 MP3 Player
+       508b  YP-S5 MP3 Player
+       5a00  YP-NEU
+       5a01  YP-NDU
+       5a03  Yepp MP3 Player
+       5a04  YP-800
+       5a08  YP-90
+       5a0f  MTP Device
+       5b01  Memory Stick Reader/Writer
+       5b02  Memory Stick Reader/Writer
+       5b03  Memory Stick Reader/Writer
+       5b04  Memory Stick Reader/Writer
+       5b05  Memory Stick Reader/Writer
+       5b11  SEW-2001u Card
+       5f00  NEXiO Sync
+       5f01  NEXiO Sync
+       5f02  NEXiO Sync
+       5f03  NEXiO Sync
+       5f04  NEXiO Sync
+       6601  Z100 Mobile Phone
+       6611  MITs Sync
+       6613  MITs Sync
+       6615  MITs Sync
+       6617  MITs Sync
+       6619  MITs Sync
+       661b  MITs Sync
+       661e  Handheld
+       6620  Handheld
+       6622  Handheld
+       6624  Handheld
+       662e  MITs Sync
+       6630  MITs Sync
+       6632  MITs Sync
+       663f  SGH-E720/SGH-E840
+       6640  Usb Modem Enumerator
+       7011  SEW-2003U Card
+       7021  Bluetooth Device
+       7061  eHome Infrared Receiver
+       7081  Human Interface Device
+       8001  Handheld
+       e020  SERI E02 SCOM 6200 UMTS Phone
+       e021  SERI E02 SCOM 6200 Virtual UARTs
+       e022  SERI E02 SCOM 6200 Flash Load Disk
+       ff30  SG_iMON
+04e9  PC-Tel, Inc.
+04ea  Brooktree Corp.
+04eb  Northstar Systems, Inc.
+04ec  Tokyo Electron Device, Ltd
+04ed  Annabooks
+04ef  Pacific Electronic International, Inc.
+04f0  Daewoo Electronics Co., Ltd
+04f1  Victor Company of Japan, Ltd
+       0001  GC-QX3 Digital Still Camera
+       0004  GR-DVL815U Digital Video Camera
+       0006  DV Camera Storage
+       0008  GZ-MG30AA/MC500E Digital Video Camera
+       0009  GR-DX25EK Digital Video Camera
+       000a  GR-D72 Digital Video Camera
+       3008  MP-PRX1 Ethernet
+04f2  Chicony Electronics Co., Ltd
+       0001  KU-8933 Keyboard
+       0002  NT68P81 Keyboard
+       0110  KU-2971 Keyboard
+       0111  KU-9908 Keyboard
+       0112  KU-8933 Keyboard with PS/2 Mouse port
+       0116  KU-2971 German Keyboard
+       0403  KU-0420 keyboard
+       a001  E-Video DC-100 Camera
+       a120  ORITE CCD Webcam(PC370R)
+       a121  ORITE CCD Webcam(PC370R)
+       a122  ORITE CCD Webcam(PC370R)
+       a123  ORITE CCD Webcam(PC370R)
+       a124  ORITE CCD Webcam(PC370R)
+       a133  Gateway Webcam
+       a204  DSC WIA Device (1300)
+       a208  DSC WIA Device (2320)
+       a209  Labtec DC-2320
+       a20a  DSC WIA Device (3310)
+       a20c  DSC WIA Device (3320)
+       a210  Audio Device
+       b009  Integrated Camera
+       b010  Integrated Camera
+       b012  1.3 MPixel UVC webcam
+       b018  Video Device
+       b022  Camera
+       b025  Camera
+       b027  Gateway Webcam
+       b028  VGA UVC WebCam
+04f3  Elan Microelectronics Corp.
+       0210  AM-400 Hama Optical Mouse
+04f4  Harting Elektronik, Inc.
+04f5  Fujitsu-ICL Systems, Inc.
+04f6  Norand Corp.
+04f7  Newnex Technology Corp.
+04f8  FuturePlus Systems
+04f9  Brother Industries, Ltd
+       0002  HL-1050 Laser Printer
+       0005  Printer
+       0006  HL-1240 Laser Printer
+       0007  HL-1250 Laser Printer
+       0008  HL-1270 Laser Printer
+       0009  Printer
+       000a  P2500 Series
+       000b  Printer
+       000c  Printer
+       000d  HL-1440 Laser Printer
+       000e  HL-1450 series
+       000f  HL-1470N series
+       0010  Printer
+       0011  Printer
+       0012  Printer
+       0013  Printer
+       0014  Printer
+       0015  Printer
+       0016  Printer
+       0017  Printer
+       0018  Printer
+       001c  Printer
+       001e  Printer
+       0020  HL-5130 series
+       0021  HL-5140 series
+       0022  HL-5150D series
+       0023  HL-5170DN series
+       0024  Printer
+       0025  Printer
+       0027  HL-2030 Laser Printer
+       0028  Printer
+       0029  Printer
+       002a  Printer
+       002b  Printer
+       002c  Printer
+       002d  Printer
+       0100  MFC8600/9650 Series
+       0101  MFC9600/9870 Series
+       0102  MFC9750/1200 Series
+       0104  MFC-8300J
+       0105  MFC-9600J
+       0106  MFC-7300C
+       0107  MFC-7400C
+       0108  MFC-9200C
+       0109  MFC-830
+       010a  MFC-840
+       010b  MFC-860
+       010c  MFC-7400J
+       010d  MFC-9200J
+       010e  MFC3100C Scanner
+       010f  MFC 5100C
+       0110  MFC4800 Scanner
+       0111  MFC 6800
+       0112  DCP1000 Port(FaxModem)
+       0113  MFC-8500
+       0114  MFC9700 Port(FaxModem)
+       0115  MFC9800 Scanner
+       0116  DCP1400 Scanner
+       0119  MFC-9660
+       011b  MFC-9880
+       011c  MFC-9760
+       011d  MFC-9070
+       011e  MFC-9180
+       011f  MFC-9160
+       0120  MFC580 Port(FaxModem)
+       0121  MFC-590
+       0122  MFC-5100J
+       0129  Imagistics 2500 (MFC-8640D clone)
+       012f  FAX-4750e
+       0132  MFC-5200C RemovableDisk
+       0135  MFC-100 Scanner
+       0136  MFC-150CL Scanner
+       013c  MFC-890 Port
+       013d  MFC-5200J Printer
+       013e  MFC-4420C RemovableDisk
+       013f  MFC-4820C RemovableDisk
+       0140  DCP-8020
+       0141  DCP-8025D
+       0142  MFC-8420
+       0143  MFC-8820D
+       0144  DCP-4020C RemovableDisk
+       0146  MFC-3220C
+       0147  FAX-1820C Printer
+       0148  MFC-3320CN Printer
+       0149  FAX-1920CN Printer
+       014a  MFC-3420C
+       014b  MFC-3820CN
+       014d  FAX-1815C Printer
+       014e  MFC-8820J
+       0150  MFC-8220 Port(FaxModem)
+       0151  MFC-8210J
+       0157  MFC-3420J Printer
+       0158  MFC-3820JN Port(FaxModem)
+       015d  MFC Composite Device
+       015e  DCP-8045D
+       015f  MFC-8440
+       0160  MFC-8840D
+       0161  MFC-210C
+       0162  MFC-420CN Remote Setup Port
+       0163  MFC-410CN RemovableDisk
+       0165  MFC-620CN
+       0166  MFC-610CLN RemovableDisk
+       0168  MFC-620CLN
+       0169  DCP-110C RemovableDisk
+       016b  DCP-310CN RemovableDisk
+       016c  FAX-2440C Printer
+       016d  MFC-5440CN
+       016e  MFC-5840CN Remote Setup Port
+       0170  FAX-1840C Printer
+       0171  FAX-1835C Printer
+       0172  FAX-1940CN Printer
+       0173  MFC-3240C Remote Setup Port
+       0174  MFC-3340CN RemovableDisk
+       017b  Imagistics sx2100
+       0180  MFC-7420
+       0181  MFC-7820N Port(FaxModem)
+       0182  Composite Device
+       0183  DCP-7020
+       0184  DCP-7025 Printer
+       0185  MFC-7220 Printer
+       0186  Composite Device
+       0187  FAX-2820 Printer
+       0188  FAX-2920 Printer
+       018a  MFC-9420CN
+       018c  DCP-115C
+       018d  DCP-116C
+       018e  DCP-117C
+       018f  DCP-118C
+       0190  DCP-120C
+       0191  DCP-315CN
+       0192  DCP-340CW
+       0193  MFC-215C
+       0194  MFC-425CN
+       0195  MFC-820CW Remote Setup Port
+       0196  MFC-820CN Remote Setup Port
+       0197  MFC-640CW
+       019a  MFC-840CLN Remote Setup Port
+       01a2  MFC-8640D
+       01a3  Composite Device
+       01a4  DCP-8065DN Printer
+       01a5  MFC-8460N Port(FaxModem)
+       01a6  MFC-8860DN Port(FaxModem)
+       01a7  MFC-8870DW Printer
+       01a8  DCP-130C
+       01a9  DCP-330C
+       01aa  DCP-540CN
+       01ab  MFC-240C
+       01ae  DCP-750CW RemovableDisk
+       01af  MFC-440CN
+       01b0  MFC-660CN
+       01b1  MFC-665CW Remote Setup Port
+       01b2  MFC-845CW Remote Setup Port
+       01b4  MFC-460CN Remote Setup Port
+       01b5  MFC-630CD
+       01b6  MFC-850CDN
+       01b7  MFC-5460CN Remote Setup Port
+       01b8  MFC-5860CN
+       01ba  MFC-3360C
+       01bd  MFC-8660DN
+       01be  DCP-750CN RemovableDisk
+       01bf  MFC-860CDN Remote Setup Port
+       01c0  DCP-128C
+       01c1  DCP-129C
+       01c2  DCP-131C
+       01c3  DCP-329C
+       01c4  DCP-331C
+       01c5  MFC-239C
+       01ca  MFC-9440CN Remote Setup Port
+       01ce  DCP-135C
+       01cf  DCP-150C
+       01d0  DCP-350C
+       01d1  DCP-560CN
+       01d4  MFC-230C
+       01d5  MFC-235C
+       01d6  MFC-260C
+       01df  DCP-155C
+       01e0  MFC-265C
+       01e1  DCP-153C
+       01e2  DCP-157C
+       01e3  DCP-353C
+       01e4  DCP-357C
+       1000  Printer
+       1002  Printer
+       2002  PTUSB Printing
+       2004  PT-2300/2310 p-Touch Laber Printer
+       2015  QL-500 P-touch label printer
+       2100  Card Reader Writer
+04fa  Dallas Semiconductor
+       2490  DS1490F 2-in-1 Fob, 1-Wire adapter
+       4201  DS4201 Audio DAC
+04fb  Biostar Microtech International Corp.
+04fc  Sunplus Technology Co., Ltd
+       0003  CM1092 Optical Scroller Mouse
+       0013  ViewMate Desktop Mouse CC2201
+       0015  ViewMate Desktop Mouse CC2201
+       0232  Fingerprint
+       0561  Flexcam 100
+       1533  Mass Storage
+       504a  SPCA504a Digital Camera
+       504b  Aiptek, 1.3 mega PockerCam
+       5330  Digitrex 2110
+       5331  Vivitar Vivicam 10
+       5720  Card Reader Driver
+       7333  Finet Technology Palmpix DC-85
+       757a  Aiptek, MP315 MP3 Player
+       ffff  PureDigital Ritz Disposable
+04fd  Soliton Systems, K.K.
+       0003  Smart Card Reader II
+04fe  PFU, Ltd
+04ff  E-CMOS Corp.
+0500  Siam United Hi-Tech
+       0001  DART Keyboard Mouse
+       0002  DART-2 Keyboard
+0501  Fujikura DDK, Ltd
+0502  Acer, Inc.
+       0001  Handheld
+       0736  Handheld
+       15b1  PDA n311
+       1631  c10 Series
+       1632  c20 Series
+       16e1  n10 Handheld Sync
+       16e2  n20 Pocket PC Sync
+       16e3  n30 Handheld Sync
+       d001  Divio NW801/DVC-V6+ Digital Camera
+0503  Hitachi America, Ltd
+0504  Hayes Microcomputer Products
+0506  3Com Corp.
+       009d  HomeConnect Camera
+       00a0  3CREB96 Bluetooth Adapter
+       00a1  Bluetooth Device
+       00a2  Bluetooth Device
+       00df  3Com Home Connect lite
+       0100  HomeConnect ADSL Modem Driver
+       03e8  3C19250 Ethernet [klsi]
+       0a01  3CRSHEW696 Wireless Adapter
+       0a11  3CRWE254G72 802.11g Adapter
+       11f8  HomeConnect 3C460
+       2922  HomeConnect Cable Modem External with
+       3021  U.S.Robotics 56000 Voice FaxModem Pro
+       4601  3C460B 10/100 Ethernet Adapter
+       f002  3CP4218 ADSL Modem (pre-init)
+       f003  3CP4218 ADSL Modem
+       f100  3CP4218 ADSL Modem (pre-init)
+0507  Hosiden Corp.
+       0011  Konami ParaParaParadise Controller
+0508  Clarion Co., Ltd
+0509  Aztech Systems, Ltd
+       0801  ADSL Modem
+       0802  ADSL Modem (RFC1483)
+       0806  DSL Modem
+       080f  Binatone ADSL500 Modem Network Interface
+       0812  Pirelli ADSL Modem Network Interface
+050a  Cinch Connectors
+050b  Cable System International
+050c  InnoMedia, Inc.
+050d  Belkin Components
+       0004  Direct Connect
+       0012  F8T012 Bluetooth Adapter
+       0013  F8T013 Bluetooth Adapter
+       0050  F5D6050 802.11b Wireless Adapter
+       0081  F8T001v2 Bluetooth
+       0083  Bluetooth Device
+       0084  F8T003v2 Bluetooth
+       0102  Flip KVM
+       0103  F5U103 Serial Adapter [etek]
+       0106  VideoBus II Adapter, Video
+       0108  F1DE108B KVM
+       0109  F5U109/F5U409 PDA Adapter
+       0115  SCSI Adapter
+       0119  F5U120-PC Dual PS/2 Ports
+       0121  F5D5050 100Mbps Ethernet
+       0122  Ethernet Adapter
+       0131  Bluetooth Device with trace filter
+       0201  Peripheral Switch
+       0208  USBView II Video Adapter [nt1004]
+       0210  F5U228 Hi-Speed USB 2.0 DVD Creator
+       0211  F5U211 USB 2.0 15-in-1 Media Reader & Writer
+       0224  F5U224 USB 2.0 4-Port Hub
+       0234  F5U234 USB 2.0 4-Port Hub
+       0237  F5U237 USB 2.0 7-Port Hub
+       0240  F5U240 USB 2.0 CF Card Reader
+       0257  F5U257 Serial
+       0409  F5U409 Serial
+       0551  F6C550-AVR UPS
+       0802  Nostromo n40 Gamepad
+       0803  Nostromo 1745 GamePad
+       0805  Nostromo N50 GamePad
+       0815  Nostromo n52 HID SpeedPad Mouse Wheel
+       0826  ErgoFit Wireless Optical Mouse (HID)
+       0980  HID UPS Battery
+       1202  F5U120-PC Parallel Printer Port
+       1203  F5U120-PC Serial Port
+       258a  F5U258 Host to Host cable
+       3101  F1DF102U/F1DG102U Flip Hub
+       3201  F1DF102U/F1DG102U Flip KVM
+       4050  ZD1211B
+       5055  F5D5055
+       6051  11Mbps Wireless Network Adapter
+       7050  F5D7050 ver 1000 WiFi
+       7051  F5D7051 54g USB Network Adapter
+       705a  F5D7050A Wireless Adapter
+       705b  Wireless G Adapter
+       705c  F5D7050 v4000 Wireless Adapter
+       905b  F5D9050 ver 3 Wireless Adapter
+       905c  Wireless G Plus MIMO Network Adapter
+050e  Neon Technology, Inc.
+050f  KC Technology, Inc.
+       0001  Hub
+       0003  KC82C160S Hub
+       0180  KC-180 IrDA Dongle
+       0190  KC2190 USB Host-to-Host cable
+0510  Sejin Electron, Inc.
+       0001  Keyboard
+       1000  Keyboard with PS/2 Mouse Port
+       e001  Mouse
+0511  N'Able (DataBook) Technologies, Inc.
+0512  Hualon Microelectronics Corp.
+0513  digital-X, Inc.
+0514  FCI Electronics
+0515  ACTC
+0516  Longwell Electronics
+0517  Butterfly Communications
+0518  EzKEY Corp.
+       0001  USB to PS2 Adaptor v1.09
+       0002  EZ-9900C Keyboard
+0519  Star Micronics Co., Ltd
+       c002  Xlive Bluetooth XBM-100S MP3 Player
+051a  WYSE Technology
+       a005  Smart Display Version 9973
+051b  Silicon Graphics
+051c  Shuttle, Inc.
+       c001  eHome Infrared Receiver
+       c002  eHome Infrared Receiver
+051d  American Power Conversion
+       0001  UPS
+       0002  Uninterruptible Power Supply
+       0003  UPS
+051e  Scientific Atlanta, Inc.
+051f  IO Systems (Elite Electronics), Inc.
+0520  Taiwan Semiconductor Manufacturing Co.
+0521  Airborn Connectors
+0522  Advanced Connectek, Inc.
+0523  ATEN GmbH
+0524  Sola Electronics
+0525  Netchip Technology, Inc.
+       100d  RFMD Bluetooth Device
+       1080  NET1080 USB-USB Bridge
+       a140  USB Clik! 40
+       a141  (OME) PocketZip 40 MP3 Player Driver
+       a220  GVC Bluetooth Wireless Adapter
+       a4a0  Linux-USB "Gadget Zero"
+       a4a1  Linux-USB Ethernet Gadget
+       a4a2  Linux-USB Ethernet/RNDIS Gadget
+       a4a3  Linux-USB user-mode isochronous source/sink
+       a4a4  Linux-USB user-mode bulk source/sink
+       a4a5  Linux-USB File Storage Gadget
+       a4a6  Linux-USB Serial Gadget
+       a4a7  Linux-USB Serial Gadget (CDC ACM mode)
+       a4a8  Linux-USB Printer Gadget
+0526  Temic MHS S.A.
+0527  ALTRA
+0528  ATI Technologies, Inc.
+       7561  TV Wonder
+       7562  TV Wonder, Edition (FN5)
+       7563  TV Wonder, Edition (FI)
+       7564  TV Wonder, Edition (FQ)
+       7565  TV Wonder, Edition (NTSC+)
+       7566  TV Wonder, Edition (FN5)
+       7567  TV Wonder, Edition (FI)
+       7568  TV Wonder, Edition (FQ)
+       7569  Live! Pro (A)
+       756a  Live! Pro Audio (O)
+0529  Aladdin Knowledge Systems
+       0001  HASP v0.06
+       030b  eToken R1 v3.1.3.x
+       0313  eToken R1 v3.2.3.x
+       031b  eToken R1 v3.3.3.x
+       0323  eToken R1 v3.4.3.x
+       0412  eToken R2 v2.2.4.x
+       041a  eToken R2 v2.2.4.x
+       0422  eToken R2 v2.4.4.x
+       042a  eToken R2 v2.5.4.x
+       050c  eToken Pro v4.1.5.x
+       0514  eToken Pro v4.2.5.4
+       0600  eToken Pro 64k (4.2)
+052a  Crescent Heart Software
+052b  Tekom Technologies, Inc.
+       0102  Ca508A HP1020 Camera v.1.3.1.6
+       0801  Yakumo MegaImage 37
+       1512  Yakumo MegaImage IV
+       1513  Aosta CX100 WebCam
+       1514  Aosta CX100 WebCam Storage
+       1905  Yakumo MegaImage 47
+       1911  Yakumo MegaImage 47 SL
+       2202  WDM Still Image Capture
+       2203  Sound Vision Stream Driver
+       3a06  DigiLife DDV-5120A
+       d001  P35U Camera Capture
+052c  Canon Information Systems, Inc.
+052d  Avid Electronics Corp.
+052e  Standard Microsystems Corp.
+052f  Unicore Software, Inc.
+0530  American Microsystems, Inc.
+0531  Wacom Technology Corp.
+0532  Systech Corp.
+0533  Alcatel Mobile Phones
+0534  Motorola, Inc.
+0535  LIH TZU Electric Co., Ltd
+0536  Hand Held Products (Welch Allyn, Inc.)
+       01a0  PDT
+0537  Inventec Corp.
+0538  Caldera International, Inc. (SCO)
+0539  Shyh Shiun Terminals Co., Ltd
+053a  Preh Werke GmbH & Co. KG
+053b  Global Village Communication
+053c  Institut of Microelectronic & Mechatronic Systems
+053d  Silicon Architect
+053e  Mobility Electronics
+053f  Synopsys, Inc.
+0540  UniAccess AB
+       0101  Panache Surf ISDN TA
+0541  Sirf Technology, Inc.
+0543  ViewSonic Corp.
+       00fe  G773 Monitor Hub
+       00ff  P815 Monitor Hub
+       0bf2  airpanel V150 Wireless Smart Display
+       0bf3  airpanel V110 Wireless Smart Display
+       0ed9  Color Pocket PC V35
+       0f01  airsync Wi-Fi Wireless Adapter
+       1527  Color Pocket PC V36
+       1529  Color Pocket PC V37
+       152b  Color Pocket PC V38
+       152e  Pocket PC
+       1921  Communicator Pocket PC
+       1922  Smartphone
+       1923  Pocket PC V30
+       1a11  Wireless 802.11g Adapter
+       1e60  TA310 - ATSC/NTSC/PAL Driver(PCM4)
+       4153  ViewSonic G773 Control (?)
+0544  Cristie Electronics, Ltd
+0545  Xirlink, Inc.
+       7333  Trution Web Camera
+       8002  IBM NetCamera
+       8009  Veo PC Camera
+       800c  Veo StingRay
+       800d  Veo PC Camera
+       8080  IBM C-It WebCam
+       808a  Veo PC Camera
+       808b  Veo PC Camera
+       808d  Veo PC Camera
+       810a  Veo Advanced Connect WebCam
+       810b  Veo PC Camera
+       810c  Veo PC Camera
+       8135  Veo Mobile/Advanced Web Camera
+       813a  Veo PC Camera
+       813b  Veo PC Camera
+       813c  Veo Mobile/Advanced Web Camera
+       8333  Veo Stingray/Connect Web Camera
+       888c  eVision 123 digital camera
+       888d  eVision 123 digital camera
+0546  Polaroid Corp.
+       0daf  PDC 2300Z
+       1bed  PDC 1320 Camera
+       3097  PDC 310
+       3187  Digital Cam
+       dccf  Sound Vision Stream Driver
+0547  Anchor Chips, Inc.
+       0001  ICSI Bluetooth Device
+       1002  Python2 WDM Encoder
+       2131  AN2131 EZUSB Microcontroller
+       2235  AN2235 EZUSB-FX Microcontroller
+       2710  EZ-Link Loader (EZLNKLDR.SYS)
+       2720  AN2720 USB-USB Bridge
+       2727  Xircom PGUNET USB-USB Bridge
+       2750  EZ-Link (EZLNKUSB.SYS)
+       2810  Cypress USB ATAPI Bridge
+       7777  Bluetooth Device
+       9999  AN2131 uninitialized (?)
+0548  Tyan Computer Corp.
+       1005  EZ Cart II GameBoy Flash Programmer
+0549  Pixera Corp.
+054a  Fujitsu Microelectronics, Inc.
+054b  New Media Corp.
+054c  Sony Corp.
+       0001  HUB
+       0002  Standard HUB
+       0010  DSC-S30/S70/S75/F505V/F505/FD92/W1 Cybershot/Mavica Digital Camera
+       0014  Nogatech USBVision (SY)
+       0022  Storage Adapter V2 (TPP)
+       0023  CD Writer
+       0024  Mavica CD-1000 Camera
+       0025  NW-MS7 Walkman MemoryStick Reader
+       002b  Portable USB Harddrive V2
+       002c  USB Floppy Disk Drive
+       002d  MSAC-US1 MemoryStick Reader
+       002e  Sony HandyCam MemoryStick Reader
+       0030  Storage Adapter V2 (TPP)
+       0032  MemoryStick MSC-U01 Reader
+       0035  Network Walkman (E)
+       0036  Net MD
+       0037  MG Memory Stick Reader/Writer
+       0038  Clie PEG-S300/D PalmOS PDA
+       0039  Network Walkman (MS)
+       003c  VAIO-MX LCD Control
+       0045  Digital Imaging Video
+       0046  Network Walkman
+       004a  Memory Stick Hi-Fi System
+       004b  Memory Stick Reader/Writer
+       004e  DSC-xxx (ptp)
+       0056  MG Memory Stick Reader/Writer
+       0058  Clie PEG-N7x0C PalmOS PDA Mass Storage
+       0066  Clie PEG-N7x0C/PEG-T425 PalmOS PDA Serial
+       0069  Memorystick MSC-U03 Reader
+       006d  Clie PEG-T425 PDA Mass Storage
+       006f  Network Walkman (EV)
+       0073  Storage CRX1750U
+       0075  Net MD
+       0076  Storage Adapter ACR-U20
+       007c  Net MD
+       007f  IC Recorder (MS)
+       0080  Net MD
+       0081  Net MD
+       0084  Net MD
+       0085  Net MD
+       0086  Net MD
+       008b  Micro Vault 64M Mass Storage
+       0095  Sony Clie s360
+       0099  Clie NR70 PDA Mass Storage
+       009a  Clie NR70 PDA Serial
+       00ab  Visual Communication Camera (PCGA-UVC10)
+       00af  DPP-EX Series Digital Photo Printer
+       00bf  IC Recorder (S)
+       00c0  Handycam DCR-30
+       00c6  Net MD
+       00c7  Net MD
+       00c8  MZ-N710 Minidisc Walkman
+       00c9  Net MD
+       00ca  MZ-DN430 Minidisc Walkman
+       00cb  MSAC-US20 Memory Stick Reader
+       00da  Sony Clie nx60
+       00e8  Network Walkman (MS)
+       00e9  Handheld
+       00eb  Net MD
+       0101  Net MD
+       0103  IC Recorder (ST)
+       0105  Micro Vault Hub
+       0107  VCC-U01 Visual Communication Camera
+       0110  Digital Imaging Video
+       0113  Net MD
+       0116  IC Recorder (P)
+       0144  Clie PEG-TH55 PDA
+       0147  Visual Communication Camera (PCGA-UVC11)
+       014c  Aiwa AM-NX9 Net MD Music Recorder MDLP
+       014d  Memory Stick Reader/Writer
+       0154  Eyetoy Audio Device
+       015f  IC Recorder (BM)
+       0169  Clie PEG-TJ35 PDA Serial
+       016a  Clie PEG-TJ35 PDA Mass Storage
+       016b  Mobile HDD
+       016d  IC Recorder (SX)
+       016e  DPP-EX50 Digital Photo Printer
+       0171  Fingerprint Sensor 3500
+       017e  Net MD
+       017f  Hi-MD WALKMAN
+       0180  Net MD
+       0181  Hi-MD WALKMAN
+       0182  Net MD
+       0183  Hi-MD WALKMAN
+       0184  Net MD
+       0185  Hi-MD WALKMAN
+       0186  Net MD
+       0187  Hi-MD WALKMAN
+       0188  Net MD
+       018a  Net MD
+       018b  Hi-MD SOUND GATE
+       019e  Micro Vault 1.0G Mass Storage
+       01ad  ATRAC HDD PA
+       01bd  MRW62E Multi-Card Reader/Writer
+       01c3  NW-E55 Network Walkman
+       01c6  MEMORY P-AUDIO
+       01c7  Printing Support
+       01d0  DVD+RW External Drive DRU-700A
+       01d5  IC RECORDER
+       01de  VRD-VC10 [Video Capture]
+       01e9  Net MD
+       01ea  Hi-MD WALKMAN
+       01ee  IC RECORDER
+       01fa  Sony IC Recorder (P)
+       01fb  NW-E405 Network Walkman
+       020f  Device
+       0210  ATRAC HDD PA
+       0219  Net MD
+       021a  Hi-MD WALKMAN
+       021b  Net MD
+       021c  Hi-MD WALKMAN
+       021d  Net MD
+       0227  Printing Support
+       022c  Net MD
+       022d  Hi-MD AUDIO
+       0233  ATRAC HDD PA
+       0236  Mobile HDD
+       023b  DVD+RW External Drive DRU-800UL
+       023c  Net MD
+       023d  Hi-MD WALKMAN
+       0243  MicroVault Flash Drive
+       0257  IFU-WLM2 USB Wireless LAN Module (Wireless Mode)
+       0258  IFU-WLM2 USB Wireless LAN Module (Memory Mode)
+       0259  IC RECORDER
+       0267  Tachikoma Device
+       0268  Batoh Device
+       0269  HDD WALKMAN
+       026a  HDD WALKMAN
+       0271  IC Recorder (P)
+       027c  NETWORK WALKMAN
+       027e  SONY Communicator
+       027f  IC RECORDER
+       0286  Net MD
+       0287  Hi-MD WALKMAN
+       029b  PRS-500 eBook reader
+       02ae  PlayStation 3 Memory Card Adaptor
+       02af  Handycam DCR-DVD306E
+       02c4  Device
+       02d2  PSP
+054d  Try Corp.
+054e  Proside Corp.
+054f  WYSE Technology Taiwan
+0550  Fuji Xerox Co., Ltd
+       0002  InkJet Color Printer
+       0004  InkJet Color Printer
+       0005  InkJet Color Printer
+0551  CompuTrend Systems, Inc.
+0552  Philips Monitors
+0553  STMicroelectronics Imaging Division (VLSI Vision)
+       0001  TerraCAM
+       0002  CPiA WebCam
+       0100  STV0672 Camera
+       0140  Video Camera
+       0150  CDE CAM 100
+       0151  Digital Blue QX5 Microscope
+       0200  Dual-mode Camera0
+       0201  Dual-mode Camera1
+       0202  Aiptek PenCam 1
+       0674  Multi-mode Camera
+       0679  NMS Video Camera (Webcam)
+       1002  Che-ez! Splash
+0554  Dictaphone Corp.
+0555  ANAM S&T Co., Ltd
+0556  Asahi Kasei Microsystems Co., Ltd
+       0001  AK5370 I/F A/D Converter
+0557  ATEN International Co., Ltd
+       2001  UC-1284 Printer Port
+       2002  10Mbps Ethernet [klsi]
+       2004  UC-100KM PS/2 Mouse and Keyboard adapter
+       2006  UC-1284B Printer Port
+       2007  UC-110T 100Mbps Ethernet [pegasus]
+       2008  UC-232A Serial Port [pl2303]
+       2009  UC-210T Ethernet
+       2202  CS124U Miniview II KVM Switch
+       2600  IDE Bridge
+       4000  DSB-650 10Mbps Ethernet [klsi]
+       7000  Hub
+0558  Truevision, Inc.
+0559  Cadence Design Systems, Inc.
+055a  Kenwood USA
+055b  KnowledgeTek, Inc.
+055c  Proton Electronic Ind.
+055d  Samsung Electro-Mechanics Co.
+       0001  Keyboard
+       0bb1  Bluetooth Device
+       1030  Optical Wheel Mouse (OMS3CB/OMGB30)
+       1031  Optical Wheel Mouse (OMA3CB/OMGI30)
+       1040  Mouse HID Device
+       1050  E-Mail Optical Wheel Mouse (OMS3CE)
+       1080  Optical Wheel Mouse (OMS3CH)
+       2020  Floppy Disk Drive
+       6780  Keyboard V1
+       6781  Keyboard Mouse
+       8001  E.M. Hub
+       9000  AnyCam [pwc]
+       9001  MPC-C30 AnyCam Premium for Notebooks [pwc]
+       a010  WLAN Adapter(SWL-2300)
+       a011  Boot Device
+       a012  WLAN Adapter(SWL-2300)
+       a013  WLAN Adapter(SWL-2350)
+       a230  Boot Device
+       b000  11Mbps WLAN Mini Adapter
+       b230  Netopia 802.11b WLAN Adapter
+       b231  LG Wireless LAN 11b Adapter
+055e  CTX Opto-Electronics Corp.
+055f  Mustek Systems, Inc.
+       0001  ScanExpress 1200 CU
+       0002  ScanExpress 600 CU
+       0003  ScanExpress 1200 USB
+       0006  ScanExpress 1200 UB
+       0007  ScanExpress 1200 USB Plus
+       0008  ScanExpress 1200 CU Plus
+       0010  BearPaw 1200F
+       0210  ScanExpress A3 USB
+       0218  BearPaw 2400 TA
+       0219  BearPaw 2400 TA Plus
+       021a  BearPaw 2448 TA Plus
+       021c  BearPaw 1200 CU Plus
+       021d  BearPaw 2400 CU Plus
+       021e  BearPaw 1200 TA/CS
+       021f  SNAPSCAN e22
+       0400  BearPaw 2400 TA Pro
+       0401  P 3600 A3 Pro
+       0408  BearPaw 2448 CU Pro
+       0873  ScanExpress 600 USB
+       1000  BearPaw 4800 TA Pro
+       a350  gSmart 350
+       a800  MDC 800 Camera
+       b500  MDC 3000 Camera
+       c005  PC CAM 300A
+       c200  gSmart 300
+       c220  gSmart mini
+       c360  Mustek DV 4000
+       c420  gSmart mini 2
+       c440  Mustek DV 3000
+       c520  gSmart mini 3
+       c530  Mustek Gsmart LCD 2
+       c631  MDC-4000
+       c650  Mustek MDC5500Z
+       d001  WCam 300
+       d003  PC CAM 300A
+       d004  PC CAM 300A
+0560  Interface Corp.
+0561  Oasis Design, Inc.
+0562  Telex Communications, Inc.
+       0001  Enhanced Microphone
+       0002  Telex Microphone
+0563  Immersion Corp.
+0564  Chinon Industries, Inc.
+0565  Peracom Networks, Inc.
+       0001  Serial Port [etek]
+       0002  Enet Ethernet [klsi]
+       0003  @Home Networks Ethernet [klsi]
+       0005  Enet2 Ethernet [klsi]
+       0041  Peracom Remote NDIS Ethernet Adapter
+0566  Monterey International Corp.
+       0110  ViewMate Desktop Mouse CC2201
+       1001  ViewMate Desktop Mouse CC2201
+       1002  ViewMate Desktop Mouse CC2201
+       1003  ViewMate Desktop Mouse CC2201
+       1004  ViewMate Desktop Mouse CC2201
+       1005  ViewMate Desktop Mouse CC2201
+       1006  ViewMate Desktop Mouse CC2201
+       1007  ViewMate Desktop Mouse CC2201
+       2800  MIC K/B
+       2801  MIC K/B Mouse
+       2802  Kbd Hub
+0567  Xyratex International, Ltd
+0568  Quartz Ingenierie
+0569  SegaSoft
+056a  Wacom Co., Ltd
+       0000  PenPartner
+       0001  PenPartner 4x5
+       0002  PenPartner 6x8
+       0010  Graphire
+       0011  Graphire 2
+       0013  Graphire 3 4x5
+       0020  Intuos 4x5
+       0021  Intuos 6x8
+       0022  Intuos 9x12
+       0023  Intuos 12x12
+       0024  Intuos 12x18
+       0030  PL400
+       0031  PL500
+       0032  PL600
+       0034  PL550
+       0035  PL800
+       0041  Intuos2 4x5
+       0042  Intuos 2 6x8
+       0043  Intuos 2
+       0044  Intuos2 12x12
+       0045  Intuos2 12x18
+       0400  PenPartner 4x5
+       4850  PenPartner 6x8
+056b  Decicon, Inc.
+056c  eTEK Labs
+       0006  KwikLink Host-Host Connector
+       8007  Kwik232 Serial Port
+       8100  KwikLink Host-Host Connector
+       8101  KwikLink USB-USB Bridge
+056d  EIZO Corp.
+       0000  Hub
+       0001  Monitor
+       0002  HID Monitor Controls
+       0003  Device Bay Controller
+056e  Elecom Co., Ltd
+       0002  29UO Mouse
+       200c  LD-USB/TX
+       4002  Laneed 100Mbps Ethernet LD-USB/TX [pegasus]
+       4005  LD-USBL/TX
+       400b  LD-USB/TX
+       4010  LD-USB20
+       5003  UC-SGT
+       5004  UC-SGT
+       abc1  LD-USB/TX
+056f  Korea Data Systems Co., Ltd
+       cd00  CDM-751 CD organizer
+0570  Epson America
+0571  Interex, Inc.
+       0002  echoFX InterView Lite
+0572  Conexant Systems (Rockwell), Inc.
+       0001  Ezcam II WebCam
+       0002  Ezcam II WebCam
+       0040  Wondereye CP-115 WebCam
+       0041  WebCam Notebook
+       0042  WebCam Notebook
+       1232  V.90 modem
+       1234  Typhoon Redfun Modem V90 56k
+       1252  HCF V90 Data Fax Voice Modem
+       1253  Zoom V.92 Faxmodem
+       1300  SoftK56 Data Fax Voice CARP
+       1301  Modem Enumerator
+       2000  SoftGate 802.11 Adapter
+       2002  SoftGate 802.11 Adapter
+       8390  WinFast PalmTop/Novo TV Video
+       8392  WinFast PalmTop/Novo TV Video
+       cafe  AccessRunner ADSL Modem
+       cb00  E-Tech ADSL Modem v2
+       cb01  GeekADSL Promax Q31 ADSL Modem
+       cb06  StarModem Network Interface
+0573  Zoran Co. Personal Media Division (Nogatech)
+       0003  USBGear USBG-V1
+       0400  D-Link V100
+       0600  Dazzle USBVision (1006)
+       1300  leadtek USBVision (1006)
+       2000  X10 va10a Wireless Camera
+       2001  Dazzle EmMe (2001)
+       2101  Zoran Co. PMD (Nogatech) AV-grabber Manhattan
+       2d00  Osprey 50
+       2d01  Hauppauge USB-Live Model 600
+       3000  Dazzle MicroCam (NTSC)
+       3001  Dazzle MicroCam (PAL)
+       4000  Nogatech TV! (NTSC)
+       4001  Nogatech TV! (PAL)
+       4002  Nogatech TV! (PAL-I-)
+       4003  Nogatech TV! (MF-)
+       4008  Nogatech TV! (NTSC) (T)
+       4009  Nogatech TV! (PAL) (T)
+       4010  Nogatech TV! (NTSC) (A)
+       4100  USB-TV FM (NTSC)
+       4110  PNY USB-TV (NTSC) FM
+       4400  Nogatech TV! Pro (NTSC)
+       4401  Nogatech TV! Pro (PAL)
+       4450  PixelView PlayTv-USB PRO (PAL) FM
+       4451  Nogatech TV! Pro (PAL+)
+       4452  Nogatech TV! Pro (PAL-I+)
+       4500  Nogatech TV! Pro (NTSC)
+       4501  Nogatech TV! Pro (PAL)
+       4550  ZTV ZT-721 2.4GHz USB A/V Receiver
+       4551  Dazzle TV! Pro Audio (P+)
+       4d00  Hauppauge WinTV-USB USA
+       4d01  Hauppauge WinTV-USB
+       4d02  Hauppauge WinTV-USB UK
+       4d03  Hauppauge WinTV-USB France
+       4d04  Hauppauge WinTV (PAL D/K)
+       4d10  Hauppauge WinTV-USB with FM USA radio
+       4d11  Hauppauge WinTV-USB (PAL) with FM radio
+       4d12  Hauppauge WinTV-USB UK with FM Radio
+       4d14  Hauppauge WinTV (PAL D/K FM)
+       4d20  Hauppauge WinTV-USB II (PAL) with FM radio
+       4d21  Hauppauge WinTV-USB II (PAL)
+       4d22  Hauppauge WinTV-USB II (PAL) Model 566
+       4d23  Hauppauge WinTV-USB France 4D23
+       4d24  Hauppauge WinTV Pro (PAL D/K)
+       4d25  Hauppauge WinTV-USB Model 40209 rev B234
+       4d26  Hauppauge WinTV-USB Model 40209 rev B243
+       4d27  Hauppauge WinTV-USB Model 40204 Rev B281
+       4d28  Hauppauge WinTV-USB Model 40204 rev B283
+       4d29  Hauppauge WinTV-USB Model 40205 rev B298
+       4d2a  Hauppague WinTV-USB Model 602 Rev B285
+       4d2b  Hauppague WinTV-USB Model 602 Rev B282
+       4d2c  Hauppauge WinTV Pro (PAL/SECAM)
+       4d30  Hauppauge WinTV-USB FM Model 40211 Rev B123
+       4d31  Hauppauge WinTV-USB III (PAL) with FM radio Model 568
+       4d32  Hauppauge WinTV-USB III (PAL) FM Model 573
+       4d34  Hauppauge WinTV Pro (PAL D/K FM)
+       4d35  Hauppauge WinTV-USB III (PAL) FM Model 597
+       4d36  Hauppauge WinTV Pro (PAL B/G FM)
+       4d37  Hauppauge WinTV-USB Model 40219 rev E189
+       4d38  Hauppauge WinTV Pro (NTSC FM)
+0574  City University of Hong Kong
+0575  Philips Creative Display Solutions
+0576  BAFO/Quality Computer Accessories
+0577  ELSA
+0578  Intrinsix Corp.
+0579  GVC Corp.
+057a  Samsung Electronics America
+057b  Y-E Data, Inc.
+       0000  FlashBuster-U Floppy
+       0001  Tri-Media Reader Floppy
+       0006  Tri-Media Reader Card Reader
+       0010  Memory Stick Reader Writer
+       0020  HEXA Media Drive 6-in-1 Card Reader Writer
+       0030  Memory Card Viewer (TV)
+057c  AVM GmbH
+       0b00  ISDN-Controller B1 Family
+       0c00  ISDN-Controller FRITZ!Card
+       1000  ISDN-Controller FRITZ!Card v2.0
+       1900  ISDN-Controller FRITZ!Card v2.1
+       2000  ISDN-Connector FRITZ!X
+       2200  BlueFRITZ!
+       2300  Teledat X130 DSL
+       2800  ISDN-Connector TA
+       3200  Teledat X130 DSL
+       3500  FRITZ!Card DSL SL
+       3701  FRITZ!Box SL
+       3702  FRITZ!Box
+       3800  BlueFRITZ! Bluetooth Stick
+       3a00  FRITZ!Box Fon
+       3c00  FRITZ!Box WLAN
+       3d00  Fritz!Box
+       3e01  FRITZ!Box (Annex A)
+       4001  FRITZ!Box Fon (Annex A)
+       4101  FRITZ!Box WLAN (Annex A)
+       4201  FRITZ!Box Fon WLAN (Annex A)
+       4601  Eumex 5520PC (WinXP/2000)
+       4602  Eumex 400 (WinXP/2000)
+       4701  AVM FRITZ!Box Fon ata
+       5401  Eumex 300 IP
+       5601  AVM FRITZ!WLAN Stick
+       6201  WLAN USB v1.1
+       62ff  WLAN USB v1.1 [no firmware]
+057d  Shark Multimedia, Inc.
+057e  Nintendo Co., Ltd
+       0306  Wii Remote Controller RVL-003
+057f  QuickShot, Ltd
+       6238  USB StrikePad
+0580  Denron, Inc.
+0581  Racal Data Group
+0582  Roland Corp.
+       0000  UA-100
+       0002  UM-4/MPU-64 MIDI Interface
+       0003  SoundCanvas SC-8850
+       0004  U-8
+       0005  Edirol UM-2 MIDI Adapter
+       0007  SoundCanvas SC-8820
+       0008  PC-300
+       0009  Edirol UM-1SX MIDI Adapter
+       000b  SK-500
+       000c  SC-D70
+       0010  EDIROL UA-5
+       0011  Edirol UA-5 Sound Capture
+       0012  XV-5050
+       0013  XV-5050
+       0014  EDIROL UM-880 MIDI I/F (native)
+       0015  EDIROL UM-880 MIDI I/F (generic)
+       0016  EDIROL SD-90
+       0017  EDIROL SD-90
+       001b  MMP-2
+       001c  MMP-2
+       001d  V-SYNTH
+       001e  V-SYNTH
+       0023  EDIROL UM-550
+       0024  EDIROL UM-550
+       0025  EDIROL UA-20
+       0026  EDIROL UA-20
+       0027  EDIROL SD-20
+       0028  EDIROL SD-20
+       0029  EDIROL SD-80
+       002a  EDIROL SD-80
+       002b  EDIROL UA-700
+       002c  EDIROL UA-700
+       002d  XV-2020 Synthesizer
+       002e  XV-2020 Synthesizer
+       002f  VariOS
+       0030  VariOS
+       0033  EDIROL PCR
+       0034  EDIROL PCR
+       0037  Digital Piano
+       0038  Digital Piano
+       003b  BOSS GS-10
+       003c  BOSS GS-10
+       0040  GI-20
+       0041  GI-20
+       0042  RS-70
+       0043  RS-70
+       0044  EDIROL UA-1000
+       0047  EDIROL UR-80 WAVE
+       0048  EDIROL UR-80 MIDI
+       0049  EDIROL UR-80 WAVE
+       004a  EDIROL UR-80 MIDI
+       004b  EDIROL M-100FX
+       004c  EDIROL PCR-A WAVE
+       004d  EDIROL PCR-A MIDI
+       004e  EDIROL PCR-A WAVE
+       004f  EDIROL PCR-A MIDI
+       0050  EDIROL UA-3FX
+       0052  EDIROL UM-1SX
+       0054  Digital Piano
+       0060  EXR Series
+       0064  EDIROL PCR-1 WAVE
+       0065  EDIROL PCR-1 MIDI
+       0066  EDIROL PCR-1 WAVE
+       0067  EDIROL PCR-1 MIDI
+       006a  SP-606
+       006b  SP-606
+       006d  FANTOM-X
+       006e  FANTOM-X
+       0073  EDIROL UA-25
+       0074  EDIROL UA-25
+       0075  BOSS DR-880
+       0076  BOSS DR-880
+       007a  RD
+       007b  RD
+       007d  EDIROL UA-101
+       0080  G-70
+       0081  G-70
+       008b  EDIROL PC-50
+       008c  EDIROL PC-50
+       008d  EDIROL UA-101 USB1
+       0092  EDIROL PC-80 WAVE
+       0093  EDIROL PC-80 MIDI
+       0096  EDIROL UA-1EX
+       009a  EDIROL UM-3EX
+       009d  EDIROL UM-1
+       00a2  Digital Piano
+       00a3  EDIROL UA-4FX
+       00a6  Juno-G
+       00ad  SH-201
+       00c4  EDIROL M-16DX
+0583  Padix Co., Ltd (Rockfire)
+       2030  RM-203 USB Nest [mode 1]
+       2031  RM-203 USB Nest [mode 2]
+       2032  RM-203 USB Nest [mode 3]
+       2033  RM-203 USB Nest [mode 4]
+       2050  PX-205 PSX Bridge
+       3050  QF-305u Gamepad
+       688f  QF-688uv Windstorm Pro Joystick
+       7070  QF-707u Bazooka Joystick
+0584  RATOC System, Inc.
+       0008  Fujifilm MemoryCard ReaderWriter
+       b000  REX-USB60
+0585  FlashPoint Technology, Inc.
+       0001  Digital Camera
+       0002  Digital Camera
+       0003  Digital Camera
+       0004  Digital Camera
+       0005  Digital Camera
+       0006  Digital Camera
+       0007  Digital Camera
+       0008  Digital Camera
+       0009  Digital Camera
+       000a  Digital Camera
+       000b  Digital Camera
+       000c  Digital Camera
+       000d  Digital Camera
+       000e  Digital Camera
+       000f  Digital Camera
+0586  ZyXEL Communications Corp.
+       1000  Omni NET Modem / ISDN TA
+       1500  Omni 56K Plus
+       2011  Scorpion-980N keyboard
+       3304  LAN Modem
+       330a  ADSL Modem Interface
+       330e  USB Broadband ADSL Modem Rev 1.10
+       3400  ZyAIR B-220 IEEE 802.11b Adapter
+       3401  ZyAIR G-220
+       3402  (ZD1211)IEEE 802.11b+g Adapter
+       3407  G-200 v2
+       3409  AG-225H
+       340a  M-202
+       340f  G-220 v2
+       3410  Wi-Fi Wireless LAN Adapter
+       3412  Wi-Fi Wireless LAN Adapter
+       3413  AG-225H v2 802.11a/g Wi-Fi Finder & Adapter
+       3415  G-210H 802.11g Wireless Adapter
+0587  America Kotobuki Electronics Industries, Inc.
+0588  Sapien Design
+0589  Victron
+058a  Nohau Corp.
+058b  Infineon Technologies
+058c  In Focus Systems
+       0007  Flash
+       0008  LP130
+       000a  LP530
+       0010  Projector
+       0011  Projector
+       0012  Projector
+       0013  Projector
+       0014  Projector
+       0015  Projector
+       0016  Projector
+       0017  Projector
+       0018  Projector
+       0019  Projector
+       001a  Projector
+       001b  Projector
+       001c  Projector
+       001d  Projector
+       001e  Projector
+       001f  Projector
+058d  Micrel Semiconductor
+058e  Tripath Technology, Inc.
+058f  Alcor Micro Corp.
+       2412  SCard R/W CSR-145
+       2802  Monterey Keyboard
+       5492  Hub
+       6232  Hi-Speed 16-in-1 Flash Card Reader/Writer
+       6360  Multimedia Card Reader
+       6361  Multimedia Card Reader
+       6362  Hi-Speed 21-in-1 Flash Card Reader/Writer (Internal/External)
+       6377  Multimedia Card Reader
+       6386  Memory Card
+       6387  Transcend JetFlash Flash Drive
+       6390  USB 2.0-IDE bridge
+       9213  MacAlly Kbd Hub
+       9215  AU9814 Hub
+       9254  Hub
+       9310  Mass Storage (UID4/5A & UID7A)
+       9320  Micro Storage Driver for Win98
+       9321  Micro Storage Driver for Win98
+       9330  SD Reader
+       9331  Micro Storage Driver for Win98
+       9340  Delkin eFilm Reader-32
+       9350  Delkin eFilm Reader-32
+       9360  8-in-1 Media Card Reader
+       9361  Multimedia Card Reader
+       9368  Multimedia Card Reader
+       9380  Flash drive
+       9382  Acer/Sweex Flash drive
+       9410  Keyboard
+       9472  Keyboard Hub
+       9510  ChunghwaTL USB02 Smartcard Reader
+       9520  EMV Certified Smart Card Reader
+       9720  USB-Serial Adapter
+0590  Omron Corp.
+       0004  Cable Modem
+       000b  MR56SVS
+       0028  HJ-720IT Pedometer
+0591  Questra Consulting
+0592  Powerware Corp.
+       0002  UPS (X-Slot)
+0593  Incite
+0594  Princeton Graphic Systems
+0595  Zoran Microelectronics, Ltd
+       1001  Digitrex DSC-1300/DSC-2100 (mass storage mode)
+       4343  Digital Camera EX-20 DSC
+0596  MicroTouch Systems, Inc.
+       0001  Touchscreen
+       0002  Touch Screen Controller
+0597  Trisignal Communications
+0598  Niigata Canotec Co., Inc.
+0599  Brilliance Semiconductor, Inc.
+059a  Spectrum Signal Processing, Inc.
+059b  Iomega Corp.
+       0001  Zip 100 (Type 1)
+       000b  Zip 100 (Type 2)
+       0021  Win98 Disk Controller
+       0030  Zip 250 (Ver 1)
+       0031  Zip 100 (Type 3)
+       0032  Zip 250 (Ver 2)
+       0034  Zip 100 Driver
+       0037  Zip 750 MB
+       0040  SCSI Bridge
+       0042  Rev 70 GB
+       0050  Zip CD 650 Writer
+       0053  CDRW55292EXT CD-RW External Drive
+       0057  Mass Storage Device
+       005d  Mass Storage Device
+       005f  Mass Storage Device
+       0060  PCMCIA PocketZip Dock
+       0061  Varo PocketZip 40 MP3 Player
+       006d  HipZip MP3 Player
+       007c  Ultra Max USB/1394
+       00db  FotoShow Zip 250 Driver
+       0150  Mass Storage Device
+       015d  Super DVD Writer
+       0173  Hi-Speed USB-to-IDE Bridge Controller
+       0174  Hi-Speed USB-to-IDE Bridge Controller
+       0176  Hi-Speed USB-to-IDE Bridge Controller
+       0177  Hi-Speed USB-to-IDE Bridge Controller
+       0178  Hi-Speed USB-to-IDE Bridge Controller
+       0179  Hi-Speed USB-to-IDE Bridge Controller
+       017a  HDD
+       017b  HDD/1394A
+       017c  HDD/1394B
+       0251  Optical
+       0252  Optical
+       1052  DVD+RW External Drive
+059c  A-Trend Technology Co., Ltd
+059d  Advanced Input Devices
+059e  Intelligent Instrumentation
+059f  LaCie, Ltd
+       0201  StudioDrive USB2
+       0202  StudioDrive USB2
+       0203  StudioDrive USB2
+       0211  PocketDrive
+       0212  PocketDrive
+       0213  PocketDrive USB2
+       0323  LaCie d2 Drive USB2
+       0641  Mobile Hard Drive
+       1010  Desktop Hard Drive
+       a601  HardDrive
+       a602  CD R/W
+05a0  Vetronix Corp.
+05a1  USC Corp.
+05a2  Fuji Film Microdevices Co., Ltd
+05a3  ARC International
+05a4  Ortek Technology, Inc.
+       9720  Keyboard Mouse
+       9722  Keyboard
+       9731  MCK-600W/MCK-800USB Keyboard
+05a5  Sampo Technology Corp.
+05a6  Cisco Systems, Inc.
+       0001  CVA124 Cable Voice Adapter (WDM)
+       0002  CVA122 Cable Voice Adapter (WDM)
+       0003  CVA124E Cable Voice Adapter (WDM)
+       0004  CVA122E Cable Voice Adapter (WDM)
+05a7  Bose Corp.
+05a8  Spacetec IMC Corp.
+05a9  OmniVision Technologies, Inc.
+       0511  OV511 WebCam
+       0518  OV518 WebCam
+       0519  OV519 Microphone
+       1550  VEHO Filmscanner
+       2800  SuperCAM
+       4519  Webcam Classic
+       8519  OV519 WebCam
+       a511  OV511+ WebCam
+       a518  D-Link DSB-C310 WebCam
+05aa  Utilux South China, Ltd
+05ab  In-System Design
+       0002  Parallel Port
+       0030  Storage Adapter V2 (TPP)
+       0031  ATA Bridge
+       0060  USB 2.0 ATA Bridge
+       0061  Storage Adapter V3 (TPP-I)
+       0101  Storage Adapter (TPP)
+       0130  Compact Flash and Microdrive Reader (TPP)
+       0200  USS725 ATA Bridge
+       0201  Storage Adapter (TPP)
+       0202  ATA Bridge
+       0300  Portable Hard Drive (TPP)
+       0301  Portable Hard Drive V2
+       0350  Portable Hard Drive (TPP)
+       0351  Portable Hard Drive V2
+       081a  ATA Bridge
+       0cda  ATA Bridge for CD-R/RW
+       1001  BAYI Printer Class Support
+       5700  Storage Adapter V2 (TPP)
+       5701  USB Storage Adapter V2
+       5901  Smart Board (TPP)
+       5a01  ATI Storage Adapter (TPP)
+       5d01  DataBook Adapter (TPP)
+05ac  Apple, Inc.
+       0201  USB Keyboard [Alps or Logitech, M2452]
+       0202  Keyboard [ALPS]
+       0205  Extended Keyboard [Mitsumi]
+       0206  Extended Keyboard [Mitsumi]
+       020b  Pro Keyboard [Mitsumi, A1048/US layout]
+       020c  Extended Keyboard [Mitsumi]
+       020d  Pro Keyboard [Mitsumi, A1048/JIS layout]
+       020e  Internal Keyboard/Trackpad
+       020f  Internal Keyboard/Trackpad
+       021b  Internal Keyboard/Trackpad
+       0220  Aluminum Keyboard
+       0221  Keyboard (Aluminium) (ISO)
+       0229  Internal Keyboard/Trackpad (MacBook Pro) (ANSI)
+       022a  Internal Keyboard/Trackpad (MacBook Pro) (ISO)
+       022b  Internal Keyboard/Trackpad (MacBook Pro) (JIS)
+       0301  USB Mouse [Mitsumi, M4848]
+       0302  Optical Mouse [Fujitsu]
+       0304  Optical USB Mouse [Mitsumi]
+       0306  Optical USB Mouse [Fujitsu]
+       1000  Bluetooth HCI MacBookPro (HID mode)
+       1001  Keyboard Hub [ALPS]
+       1002  Extended Keyboard Hub [Mitsumi]
+       1003  Hub in Pro Keyboard [Mitsumi, A1048]
+       1006  Hub in Aluminum Keyboard
+       1101  Speakers
+       1201  3G iPod
+       1202  iPod 2G
+       1203  iPod 4.Gen Grayscale 40G
+       1204  iPod [Photo]
+       1205  iPod Mini 1.Gen/2.Gen
+       1206  iPod '06'
+       1207  iPod '07'
+       1208  iPod '08'
+       1209  iPod Video
+       120a  iPod Nano
+       1260  iPod Nano 2.Gen
+       1261  iPod Classic
+       1300  iPod Shuffle
+       1301  iPod Shuffle 2.Gen
+       8202  HCF V.90 Data/Fax Modem
+       8203  Bluetooth HCI
+       8204  Bluetooth HCI [Bluetooth 2.0 + EDR, build-in]
+       8205  Bluetooth HCI MacBookPro
+       8206  Bluetooth USB Host Controller
+       8240  IR Receiver [build-in]
+       8300  Built-in iSight (no firmware loaded)
+       8501  Built-in iSight [Micron]
+       912f  Hub in 30" Cinema Display
+       9221  30" Cinema Display
+       ffff  Bluetooth in DFU mode - Driver
+05ad  Y.C. Cable U.S.A., Inc.
+05ae  Synopsys, Inc.
+05af  Jing-Mold Enterprise Co., Ltd
+       0821  IDE to
+       9167  KB 9151B - 678
+       9267  KB 9251B - 678 Mouse
+05b0  Fountain Technologies, Inc.
+05b1  First International Computer, Inc.
+       1389  Bluetooth Wireless Adapter
+05b4  LG Semicon Co., Ltd
+       4857  M-Any DAH-210
+       6001  Digisette DUO-MP3 AR-100
+05b5  Dialogic Corp.
+05b6  Proxima Corp.
+05b7  Medianix Semiconductor, Inc.
+05b8  Agiler, Inc.
+       3002  Scroll Mouse
+05b9  Philips Research Laboratories
+05ba  DigitalPersona, Inc.
+05bb  Grey Cell Systems
+05bc  3G Green Green Globe Co., Ltd
+       0004  Trackball
+05bd  RAFI GmbH & Co. KG
+05be  Tyco Electronics (Raychem)
+05bf  S & S Research
+05c0  Keil Software
+05c1  Kawasaki Microelectronics, Inc.
+05c2  Media Phonics (Suisse) S.A.
+05c5  Digi International, Inc.
+       0002  AccelePort USB 2
+       0004  AccelePort USB 4
+       0008  AccelePort USB 8
+05c6  Qualcomm, Inc.
+       3100  CDMA Wireless Modem/Phone
+       3196  CDMA Wireless Modem
+       3197  CDMA Wireless Modem/Phone
+05c7  Qtronix Corp.
+       0113  PC Line Mouse
+       1001  Lynx Mouse
+       2001  Keyboard
+       2011  SCorpius Keyboard
+       6001  Ten-Keypad
+05c8  Cheng Uei Precision Industry Co., Ltd (Foxlink)
+05c9  Semtech Corp.
+05ca  Ricoh Co., Ltd
+       0101  RDC-5300 Camera
+       0325  Caplio GX (ptp)
+       032d  Caplio GX 8 (ptp)
+       032f  Caplio R3 (ptp)
+       03a1  IS200e
+       0403  Printing Support
+       0405  Type 101
+       0406  Type 102
+       1830  Visual Communication Camera VGP-VCC2
+       1835  Visual Communication Camera VGP-VCC5
+       1870  Webcam 1000
+       2201  RDC-7 Camera
+       2202  Caplio RR30
+       2203  Caplio 300G
+       2204  Caplio G3
+       2205  Caplio RR30 / Medion MD 6126 Camera
+       2206  Konica DG-3Z
+       2207  Caplio Pro G3
+       2208  Caplio G4
+       2209  Caplio 400G wide
+       220a  KONICA MINOLTA DG-4Wide
+       220b  Caplio RX
+       220c  Caplio GX
+       220d  Caplio R1/RZ1
+       220e  Sea & Sea 5000G
+       220f  Rollei dr5 / Rollei dr5 (PTP mode)
+       2211  Caplio R1S
+       2212  Caplio R1v Camera
+       2213  Caplio R2
+       2214  Caplio GX 8
+       2215  DSC 725
+       2216  Caplio R3
+       2222  RDC-i500
+05cb  PowerVision Technologies, Inc.
+       1483  PV8630 interface (scanners, webcams)
+05cc  ELSA AG
+       2100  MicroLink ISDN Office
+       2219  MicroLink ISDN
+       2265  MicroLink 56k
+       2267  MicroLink 56k (V.250)
+       2280  MicroLink 56k Fun
+       3000  Micolink USB2Ethernet [pegasus]
+       3100  AirLancer USB-11
+       3363  MicroLink ADSL Fun
+05cd  Silicom, Ltd
+05ce  sci-worx GmbH
+05cf  Sung Forn Co., Ltd
+05d0  GE Medical Systems Lunar
+05d1  Brainboxes, Ltd
+       0003  Bluetooth Adapter BL-554
+05d2  Wave Systems Corp.
+05d3  Tohoku Ricoh Co., Ltd
+05d5  Super Gate Technology Co., Ltd
+05d6  Philips Semiconductors, CICT
+05d7  Thomas & Betts Corp.
+       0099  10Mbps Ethernet [klsi]
+05d8  Ultima Electronics Corp.
+       4001  Artec Ultima 2000
+       4002  Artec Ultima 2000 (GT6801 based)/Lifetec LT9385/ScanMagic 1200 UB Plus Scanner
+       4003  Artec E+ 48U
+       4004  Artec E+ Pro
+       4005  MEM48U
+       4006  TRUST EASY WEBSCAN 19200
+       4007  TRUST 240H EASY WEBSCAN GOLD
+       4008  Trust Easy Webscan 19200
+       4009  Umax Astraslim
+       4013  IT Scan 1200
+       8105  Artec T1 USB TVBOX (cold)
+       8106  Artec T1 USB TVBOX (warm)
+       8107  Artec T1 USB TVBOX with AN2235 (cold)
+       8108  Artec T1 USB TVBOX with AN2235 (warm)
+       8109  Artec T1 USB2.0 TVBOX (cold
+05d9  Axiohm Transaction Solutions
+       a225  A225 Printer
+       a758  A758 Printer
+       a794  A794 Printer
+05da  Microtek International, Inc.
+       0091  ScanMaker X6u
+       0093  ScanMaker V6USL
+       0094  Phantom 336CX/C3
+       0099  ScanMaker X6/X6U
+       009a  Phantom C6
+       00a0  Phantom 336CX/C3 (#2)
+       00a3  ScanMaker V6USL
+       00ac  ScanMaker V6UL
+       00b6  ScanMaker V6UPL
+       00ef  ScanMaker V6UPL
+       1006  Jenoptik JD350 entrance
+       1011  NHJ Che-ez! Kiss Digital Camera
+       1018  Digital Dream Enigma 1.3
+       1020  Digital Dream l'espion xtra
+       1025  Take-it Still Camera Device
+       1026  Take-it
+       1043  Take-It 1300 DSC Bulk Driver
+       1045  Take-it D1
+       1047  Take-it Camera Composite Device
+       1048  Take-it Q3
+       1049  3M Still Camera Device
+       1051  Camcorder Series
+       1052  Mass Storage Device
+       1053  Take-it DV Composite Device
+       1054  Mass Storage Device
+       1055  Digital Camera Series(536)
+       1056  Mass Storage Device
+       1057  Take-it DSC Camera Device(536)
+       1058  Mass Storage Device
+       1059  Camcorder DSC Series
+       1060  Microtek Take-it MV500
+       2007  ArtixScan DI 1210
+       200c  1394_USB2 Scanner
+       200e  ArtixScan DI 810
+       2017  UF ICE Scanner
+       201c  4800 Scanner
+       201d  ArtixScan DI 1610
+       201f  4800 Scanner-ICE
+       202e  ArtixScan DI 2020
+       208b  ScanMaker 6800
+       208f  ArtixScan DI 2010
+       209e  ScanMaker 4700LP
+       20a7  ScanMaker 5600
+       20b0  ScanMaker X12USL
+       20b1  ScanMaker 8700
+       20b4  ScanMaker 4700
+       20bd  ScanMaker 5700
+       20c9  ScanMaker 6700
+       20d2  Microtek ArtixScan 1800f
+       20d6  PS4000
+       20de  ScanMaker 9800XL
+       20e0  ScanMaker 9700XL
+       20ed  ScanMaker 4700
+       20ee  Micortek ScanMaker X12USL
+       3008  Scanner
+       300a  4800 ICE Scanner
+       300b  4800 Scanner
+       300f  MiniScan C5
+       3020  4800dpi Scanner
+       3021  1200dpi Scanner
+       3022  Scanner 4800dpi
+       3023  USB1200II Scanner
+       30c1  USB600 Scanner
+       30ce  ScanMaker 3800
+       30cf  ScanMaker 4800
+       30d4  USB1200 Scanner
+       30d8  Scanner
+       30d9  USB2400 Scanner
+       30e4  ScanMaker 4100
+       30e5  USB3200 Scanner
+       30e6  ScanMaker i320
+       40b3  ScanMaker 3600
+       40b8  ScanMaker 3700
+       40c7  ScanMaker 4600
+       40ca  ScanMaker 3600
+       40cb  ScanMaker 3700
+       40dd  ScanMaker 3750i
+       40ff  ScanMaker 3600
+       5003  Goya
+       5013  3200 Scanner
+       80a3  ScanMaker V6USL (#2)
+       80ac  ScanMaker V6UL/SpicyU
+05db  Sun Corp. (Suntac?)
+       0003  SUNTAC U-Cable type D2
+       0005  SUNTAC U-Cable type P1
+       0009  SUNTAC Slipper U
+       000a  SUNTAC Ir-Trinity
+       000b  SUNTAC U-Cable type A3
+       0011  SUNTAC U-Cable type A4
+05dc  Lexar Media, Inc.
+       0001  jumpSHOT CompactFlash Reader
+       0002  JumpShot
+       0003  JumpShot
+       0080  Jumpdrive Secure 64MB
+       0081  RBC Compact Flash Drive
+       00a7  JumpDrive Impact
+       0100  JumpDrive PRO
+       0200  JumpDrive 2.0 Pro
+       0300  Jumpdrive Geysr
+       0301  JumpDrive Classic
+       0302  JD Micro
+       0303  JD Micro Pro
+       0304  JD Secure II
+       0310  JumpDrive
+       0311  JumpDrive Classic
+       0312  JD Micro
+       0313  JD Micro Pro
+       0320  JumpDrive
+       0321  JD Micro
+       0322  JD Micro Pro
+       0323  UFC
+       0330  JumpDrive Expression
+       0340  JumpDrive TAD
+       0350  Express Card
+       0400  UFDC
+       0401  UFDC
+       0403  Locked B Device
+       0405  Locked C Device
+       0407  Locked D Device
+       0409  Locked E Device
+       040b  Locked F Device
+       040d  Locked G Device
+       040f  Locked H Device
+       0410  JumpDrive
+       0411  JumpDrive
+       0413  Locked J Device
+       0415  Locked K Device
+       0417  Locked L Device
+       0419  Locked M Device
+       041b  Locked N Device
+       041d  Locked O Device
+       041f  Locked P Device
+       0420  JumpDrive
+       0421  JumpDrive
+       0423  Locked R Device
+       0425  Locked S Device
+       0427  Locked T Device
+       0429  Locked U Device
+       042b  Locked V Device
+       042d  Locked W Device
+       042f  Locked X Device
+       0431  Locked Y Device
+       0433  Locked Z Device
+       4d02  MP3 Player
+       4d12  MP3 Player
+       a300  JumpDrive2
+       a400  JumpDrive trade; Pro 40-501
+       a410  JumpDrive 128MB/256MB
+       a411  JumpDrive Traveler
+       a420  JumpDrive Pro
+       a421  JumpDrive Pro II
+       a422  JumpDrive Micro Pro
+       a430  JumpDrive Secure
+       a431  JumpDrive Secure II
+       a432  JumpDrive Classic
+       a440  JumpDrive Lightning
+       a450  JumpDrive TouchGuard
+       a460  JD Mercury
+       a501  JumpDrive Classic
+       a510  JumpDrive Sport
+       a530  JumpDrive Expression
+       a531  JumpDrive Secure II
+       a560  JumpDrive FireFly
+       a701  JumpDrive FireFly
+       b002  USB CF Reader
+       b018  Multi-Card Reader
+05dd  Delta Electronics, Inc.
+       ff31  AWU-120
+       ff32  FriendlyNET AeroLAN AL2011
+       ff35  PCW 100 - Wireless 802.11b Adapter
+       ff91  2Wire PC Port Phoneline 10Mbps Adapter
+05df  Silicon Vision, Inc.
+05e0  Symbol Technologies
+       0700  Bar Code Scanner (CS1504)
+       0800  Spectrum24 Wireless LAN Adapter
+       1200  DS6608 Bar Code Scanner
+       1900  SNAPI Imaging Device
+       2000  MC3090 Rugged Mobile Computer
+       200d  MC70 Rugged Mobile Computer
+05e1  Syntek Semiconductor Co., Ltd
+       0500  DC-112X
+       0501  WebCam, Chipset DC-1125 similar to 174f:a311 - Asus F2F, F2J, F3J, F3T, G1, Z53JA
+       0890  STK011 Camera
+       0892  STK013 Camera
+       0895  STK016 Camera
+       0896  STK017 Camera
+05e2  ElecVision, Inc.
+05e3  Genesys Logic, Inc.
+       000a  Keyboard with PS/2 Port
+       000b  Mouse
+       0100  Nintendo Game Boy Advance SP
+       0120  Pacific Image Electronics PrimeFilm 1800u slide/negative scanner
+       0131  CF/SM Reader/Writer
+       0142  Multiple Slides Scanner-3600
+       0143  Multiple Frames Film Scanner-36series
+       0180  Plustek Scanner
+       0182  Wize Media 1000
+       0189  ScanJet 4600 series
+       018a  Xerox 6400
+       0300  GLUSB98PT Parallel Port
+       0301  USB2LPT Cable Release2
+       0406  Hub
+       0501  GL620USB Host-Host interface
+       0502  GL620USB GeneLink USB-USB Bridge
+       0504  HID Keyboard Filter
+       0604  USB 1.1 Hub
+       0605  USB 2.0 Hub [ednet]
+       0606  USB 2.0 Hub / D-Link DUB-H4 USB 2.0 Hub
+       0608  USB-2.0 4-Port HUB
+       0660  USB 2.0 Hub
+       0700  SIIG US2256 CompactFlash Card Reader
+       0701  USB 2.0 IDE Adapter
+       0702  USB 2.0 IDE Adapter
+       0703  Card Reader
+       0704  Card Reader
+       0705  Card Reader
+       0706  Card Reader
+       0707  Card Reader
+       0708  Card Reader
+       0709  Card Reader
+       070a  Pen Flash
+       070b  DMHS1B Rev 3 DFU Adapter
+       070e  X-PRO CR20xA USB 2.0 Internal Card Reader
+       070f  Pen Flash
+       0710  USB 2.0 33-in-1 Card Reader
+       0711  Card Reader
+       0712  Delkin Mass Storage Device
+       0715  USB 2.0 microSD Reader
+       0760  USB 2.0 Card Reader/Writer
+       0761  Genesys Mass Storage Device
+       0780  USBFS DFU Adapter
+       07a0  Pen Flash
+       0927  Card Reader
+       1205  Afilias Optical Mouse H3003
+       a700  Pen Flash
+       f102  VX7012 TV Box
+       f103  VX7012 TV Box
+       f104  VX7012 TV Box
+       fd21  3M TL20 Temperature Logger
+       fe00  Razer Mouse
+05e4  Red Wing Corp.
+05e5  Fuji Electric Co., Ltd
+05e6  Keithley Instruments
+05e8  ICC, Inc.
+05e9  Kawasaki LSI
+       0008  KL5KUSB101B Ethernet [klsi]
+       0009  Sony 10Mbps Ethernet [pegasus]
+       000c  USB-to-RS-232
+       000d  USB-to-RS-232
+       0014  RS-232 J104
+       0040  Ethernet Adapter
+       2008  Ethernet Adapter
+05eb  FFC, Ltd
+05ec  COM21, Inc.
+05ee  Cytechinfo Inc.
+05ef  AVB, Inc. [anko?]
+       020a  Top Shot Pegasus Joystick
+       8884  Mag Turbo Force Wheel
+       8888  Top Shot Force Feedback Racing Wheel
+05f0  Canopus Co., Ltd
+       0101  DA-Port DAC
+05f1  Compass Communications
+05f2  Dexin Corp., Ltd
+       0010  AQ Mouse
+05f3  PI Engineering, Inc.
+       0007  Kinesis Advantage PRO MPC/USB Keyboard
+       0081  Kinesis Integrated Hub
+       020b  PS2 Adapter
+       0232  X-Keys Switch Interface, Programming Mode
+       0261  X-Keys Switch Interface, SPLAT Mode
+       0264  X-Keys Switch Interface, Composite Mode
+05f5  Unixtar Technology, Inc.
+05f6  AOC International
+05f7  RFC Distribution(s) PTE, Ltd
+05f9  PSC Scanning, Inc.
+05fa  Siemens Telecommunications Systems, Ltd
+       3301  Keyboard with PS/2 Mouse Port
+       3302  Keyboard
+       3303  Keyboard with PS/2 Mouse Port
+05fc  Harman Multimedia
+       7849  Harman/Kardon SoundSticks
+05fd  InterAct, Inc.
+       0239  SV-239 HammerHead Digital
+       0251  Raider Pro
+       0253  ProPad 8 Digital
+       0286  SV-286 Cyclone Digital
+       262a  3dfx HammerHead FX
+       262f  HammerHead Fx
+       daae  Game Shark
+05fe  Chic Technology Corp.
+       0001  Mouse
+       0003  Cypress USB Mouse
+       0005  Viewmaster 4D Browser Mouse
+       0007  Twinhead Mouse
+       0009  Inland Pro 4500/5000 Mouse
+       0011  Browser Mouse
+       1010  Optical Wireless
+05ff  LeCroy Corp.
+0600  Barco Display Systems
+0601  Jazz Hipster Corp.
+       0003  Internet Security Co., Ltd. SecureKey
+0602  Vista Imaging, Inc.
+       1001  ViCam WebCam
+0603  Novatek Microelectronics Corp.
+       00f1  Keyboard
+       6871  Mouse
+0604  Jean Co., Ltd
+0605  Anchor C&C Co., Ltd
+0606  Royal Information Electronics Co., Ltd
+0607  Bridge Information Co., Ltd
+0608  Genrad Ads
+0609  SMK Manufacturing, Inc.
+       031d  eHome Infrared Receiver
+       0322  eHome Infrared Receiver
+       ff12  SMK Bluetooth Device
+060a  Worthington Data Solutions, Inc.
+060b  Solid Year
+       0001  MacAlly Keyboard
+       1006  Japanese Keyboard - 260U
+       2101  Keyboard
+       5811  ACK-571U Wireless Keyboard
+       5903  Japanese Keyboard - 595U
+       6001  SolidTek USB 2p HUB
+       6002  SolidTek USB Keyboard
+       6003  Japanese Keyboard - 600HM
+       a001  Maxwell Compact Pc PM3
+060c  EEH Datalink GmbH
+060d  Auctor Corp.
+060e  Transmonde Technologies, Inc.
+060f  Joinsoon Electronics Mfg. Co., Ltd
+0610  Costar Electronics, Inc.
+0611  Totoku Electric Co., Ltd
+0613  TransAct Technologies, Inc.
+0614  Bio-Rad Laboratories
+0615  Quabbin Wire & Cable Co., Inc.
+0616  Future Techno Designs PVT, Ltd
+0617  Swiss Federal Insitute of Technology
+0618  MacAlly
+       0101  Mouse
+0619  Seiko Instruments, Inc.
+       0101  SLP-100 Driver
+       0102  SLP-200 Driver
+       0103  SLP-100N Driver
+       0104  SLP-200N Driver
+       0105  SLP-240 Driver
+061a  Veridicom International, Inc.
+       0110  5thSense Fingerprint Sensor
+       0200  FPS200 Fingerprint Sensor
+       8200  VKI-A Fingerprint Sensor/Flash Storage (dumb)
+       9200  VKI-B Fingerprint Sensor/Flash Storage (smart)
+061b  Promptus Communications, Inc.
+061c  Act Labs, Ltd
+061d  Quatech, Inc.
+061e  Nissei Electric Co.
+       0001  nissei 128DE-USB -
+       0010  nissei 128DE-PNA -
+0620  Alaris, Inc.
+       0004  QuickVideo weeCam
+       0007  QuickVideo weeCam
+       000a  QuickVideo weeCam
+       000b  QuickVideo weeCam
+0621  ODU-Steckverbindungssysteme GmbH & Co. KG
+0622  Iotech, Inc.
+0623  Littelfuse, Inc.
+0624  Avocent Corp.
+0625  TiMedia Technology Co., Ltd
+0626  Nippon Systems Development Co., Ltd
+0627  Adomax Technology Co., Ltd
+0628  Tasking Software, Inc.
+0629  Zida Technologies, Ltd
+062a  Creative Labs
+       0000  Optical mouse
+       0001  Notebook Optical Mouse
+       0201  Defender Office Keyboard (K7310) S Zodiak KM-9010
+       9003  VoIP Conference Hub (A16GH)
+       9004  USR9602 USB Internet Mini Phone
+062b  Greatlink Electronics Taiwan, Ltd
+062c  Institute for Information Industry
+062d  Taiwan Tai-Hao Enterprises Co., Ltd
+062e  Mainsuper Enterprises Co., Ltd
+062f  Sin Sheng Terminal & Machine, Inc.
+0631  JUJO Electronics Corp.
+0633  Cyrix Corp.
+0634  Micron Technology, Inc.
+0635  Methode Electronics, Inc.
+0636  Sierra Imaging, Inc.
+       0003  Vivicam 35Xx
+0638  Avision, Inc.
+       0268  iVina 1200U Scanner
+       026a  Minolta Dimage Scan Dual II
+       0a10  iVina FB1600/UMAX Astra 4500
+       0a13  AV600U
+       0a16  SC-215
+       0a30  UMAX Astra 6700 Scanner
+       0a41  Avision AM3000/MF3000 Series
+       0f01  fi-4010CU
+       4004  Minolta Dimage Scan Elite II
+0639  Chrontel, Inc.
+063a  Techwin Corp.
+063b  Taugagreining HF
+063c  Yamaichi Electronics Co., Ltd (Sakura)
+063d  Fong Kai Industrial Co., Ltd
+063e  RealMedia Technology, Inc.
+063f  New Technology Cable, Ltd
+0640  Hitex Development Tools
+0641  Woods Industries, Inc.
+0642  VIA Medical Corp.
+0644  TEAC Corp.
+       0000  Floppy
+       1000  CD-ROM Drive
+       800d  TASCAM Portastudio DP-01FX
+       d001  CD-R/RW Unit
+       d002  CD-R/RW Unit
+       d010  CD-RW/DVD Unit
+0645  Who? Vision Systems, Inc.
+0646  UMAX
+0647  Acton Research Corp.
+       0100  ARC SpectraPro UV/VIS/IR Monochromator/Spectrograph
+       0101  ARC AM-VM Mono Airpath/Vacuum Monochromator/Spectrograph
+       0102  ARC Inspectrum Mono
+       0103  ARC Filterwheel
+       03e9  Inspectrum 128x1024 F VIS Spectrograph
+       03ea  Inspectrum 256x1024 F VIS Spectrograph
+       03eb  Inspectrum 128x1024 B VIS Spectrograph
+       03ec  Inspectrum 256x1024 B VIS Spectrograph
+0648  Inside Out Networks
+0649  Weli Science Co., Ltd
+064b  White Mountain DSP, Inc.
+064c  Ji-Haw Industrial Co., Ltd
+064d  TriTech Microelectronics, Ltd
+064e  Suyin Corp.
+064f  WIBU-Systems AG
+       0bd7  BOX/U
+       0bd8  BOX/RU
+0650  Dynapro Systems
+0651  Likom Technology Sdn. Bhd.
+0652  Stargate Solutions, Inc.
+0653  CNF, Inc.
+0654  Granite Microsystems, Inc.
+       0005  Device Bay Controller
+       0006  Hub
+       0007  Device Bay Controller
+       0016  Hub
+0655  Space Shuttle Hi-Tech Co., Ltd
+0656  Glory Mark Electronic, Ltd
+0657  Tekcon Electronics Corp.
+0658  Sigma Designs, Inc.
+0659  Aethra
+065a  Optoelectronics Co., Ltd
+       0001  Barcode scanner
+065b  Tracewell Systems
+065e  Silicon Graphics
+065f  Good Way Technology Co., Ltd & GWC technology Inc.
+0660  TSAY-E (BVI) International, Inc.
+0661  Hamamatsu Photonics K.K.
+0662  Kansai Electric Co., Ltd
+0663  Topmax Electronic Co., Ltd
+       0103  CobraPad
+0667  Aiwa Co., Ltd
+       0fa1  TD-U8000 Tape Drive
+0668  WordWand
+0669  Oce' Printing Systems GmbH
+066a  Total Technologies, Ltd
+066b  Linksys, Inc.
+       0105  SCM eUSB SmartMedia Card Reader
+       010a  Melco MCR-U2 SmartMedia / CompactFlash Reader
+       200c  USB10TX
+       2202  USB10TX Ethernet [pegasus]
+       2203  USB100TX Ethernet [pegasus]
+       2204  USB100TX HomePNA Ethernet [pegasus]
+       2206  USB Ethernet [pegasus]
+       2207  HomeLink Phoneline 10M Network Adapter
+       2211  WUSB11 802.11b Adapter
+       2212  WUSB11v2.5 802.11b Adapter
+       2213  WUSB12v1.1 802.11b Adapter
+       2219  Instant Wireless Network Adapter
+       400b  USB10TX
+066d  Entrega, Inc.
+066e  Acer Semiconductor America, Inc.
+066f  SigmaTel, Inc.
+       003b  MP3 Player
+       003e  MP3 Player
+       003f  MP3 Player
+       0040  MP3 Player
+       0041  MP3 Player
+       0042  MP3 Player
+       0043  MP3 Player
+       004b  A-Max PA11 MP3 Player
+       3400  STMP3400 D-Major MP3 Player
+       3410  STMP3410 D-Major MP3 Player
+       3500  Player Recovery Device
+       4200  STIr4200 IrDA Bridge
+       4210  STIr4210 IrDA Bridge
+       8000  MSCN MP3 Player
+       8001  SigmaTel MSCN Audio Player
+       8004  MSCNMMC MP3 Player
+       8008  i-Bead 100 MP3 Player
+       8020  MP3 Player
+       8034  MP3 Player
+       8036  MP3 Player
+       8038  MP3 Player
+       8056  MP3 Player
+       8060  MP3 Player
+       8066  MP3 Player
+       807e  MP3 Player
+       8092  MP3 Player
+       8096  MP3 Player
+       809a  MP3 Player
+       80aa  MP3 Player
+       80ac  MP3 Player
+       80b8  MP3 Player
+       80ba  MP3 Player
+       80bc  MP3 Player
+       80bf  MP3 Player
+       80c5  MP3 Player
+       80c8  MP3 Player
+       80ca  MP3 Player
+       80cc  MP3 Player
+       8104  MP3 Player
+       8106  MP3 Player
+       8108  MP3 Player
+       810a  MP3 Player
+       810c  MP3 Player
+       8122  MP3 Player
+       8124  MP3 Player
+       8126  MP3 Player
+       8128  MP3 Player
+       8134  MP3 Player
+       8136  MP3 Player
+       8138  MP3 Player
+       813a  MP3 Player
+       813e  MP3 Player
+       8140  MP3 Player
+       8142  MP3 Player
+       8144  MP3 Player
+       8146  MP3 Player
+       8148  MP3 Player
+       814c  MP3 Player
+       8201  MP3 Player
+       8202  Jens of Sweden / I-BEAD 150M/150H MP3 player
+       8203  MP3 Player
+       8204  MP3 Player
+       8205  MP3 Player
+       8206  Digital MP3 Music Player
+       8207  MP3 Player
+       8208  MP3 Player
+       8209  MP3 Player
+       820a  MP3 Player
+       820b  MP3 Player
+       820c  MP3 Player
+       820d  MP3 Player
+       820e  MP3 Player
+       820f  MP3 Player
+       8210  MP3 Player
+       8211  MP3 Player
+       8212  MP3 Player
+       8213  MP3 Player
+       8214  MP3 Player
+       8215  MP3 Player
+       8216  MP3 Player
+       8217  MP3 Player
+       8218  MP3 Player
+       8219  MP3 Player
+       821a  MP3 Player
+       821b  MP3 Player
+       821c  MP3 Player
+       821d  MP3 Player
+       821e  MP3 Player
+       821f  MP3 Player
+       8220  MP3 Player
+       8221  MP3 Player
+       8222  MP3 Player
+       8223  MP3 Player
+       8224  MP3 Player
+       8225  MP3 Player
+       8226  MP3 Player
+       8227  MP3 Player
+       8228  MP3 Player
+       8229  MP3 Player
+       8230  MP3 Player
+       9000  MP3 Player
+       9001  MP3 Player
+       9002  MP3 Player
+0672  Labtec, Inc.
+       1041  LCS1040 Speaker System
+       5000  SpaceBall 4000 FLX
+0673  HCL
+       5000  Keyboard
+0674  Key Mouse Electronic Enterprise Co., Ltd
+0675  Draytech
+       0110  Vigor 128 ISDN TA
+       0550  Vigor550
+0676  Teles AG
+0677  Aiwa Co., Ltd
+       07d5  TM-ED1285(USB)
+       0fa1  TD-U8000 Tape Drive
+0678  ACard Technology Corp.
+067b  Prolific Technology, Inc.
+       0000  PL2301 USB-USB Bridge
+       0001  PL2302 USB-USB Bridge
+       04bb  PL2303 Serial (IODATA USB-RSAQ2)
+       0610  Onext EG210U MODEM
+       0611  AlDiga AL-11U Quad-band GSM/GPRS/EDGE modem
+       2303  PL2303 Serial Port
+       2305  PL2305 Parallel Port
+       2307  PL2307 USB-ATAPI4 Bridge
+       2313  FITEL PHS U Cable Adaptor
+       2315  Flash Disk Embedded Hub
+       2316  Flash Disk Security Device
+       2317  Mass Storage Device
+       2501  PL2501 USB-USB Bridge (USB 2.0)
+       2507  PL2507 Hi-speed USB to IDE bridge controller
+       2515  Flash Disk Embedded Hub
+       2517  Flash Disk Mass Storage Device
+       25a1  PL25A1 Host-Host Bridge
+       3400  Hi-Speed Flash Disk with TruePrint AES3400
+       3500  Hi-Speed Flash Disk with TruePrint AES3500
+       3507  PL3507 ATAPI6 Bridge
+       aaa0  Prolific Pharos
+       aaa2  PL2303 Serial Adapter (IODATA USB-RSAQ3)
+067c  Efficient Networks, Inc.
+       1001  Siemens SpeedStream 100MBps Ethernet
+       1022  Siemens SpeedStream 1022 802.11b Adapter
+       1023  SpeedStream Wireless
+       4020  SpeedStream 4020 ATM/ADSL Installer
+       4031  Efficient ADSL Modem
+       4032  SpeedStream 4031 ATM/ADSL Installer
+       4033  SpeedStream 4031 ATM/ADSL Installer
+       4060  Alcatel Speedstream 4060 ADSL Modem
+       4062  Efficient Networks 4060 Loader
+       5667  Efficient Networks Virtual Bus for ADSL Modem
+       c031  SpeedStream 4031 ATM/ADSL Installer
+       c032  SpeedStream 4031 ATM/ADSL Installer
+       c033  SpeedStream 4031 ATM/ADSL Installer
+       c060  SpeedStream 4060 Miniport ATM/ADSL Adapter
+       d667  Efficient Networks Virtual Bus for ADSL Modem
+       e240  Speedstream Ethernet Adapter E240
+       e540  Speedstream Ethernet Adapter E240
+067d  Hohner Corp.
+067e  Intermec
+       1001  Mobile Computer
+067f  Virata, Ltd
+       4552  DSL-200 ADSL Modem
+       6542  DSL Modem
+       6549  DSL Modem
+       7541  DSL Modem
+0680  Realtek Semiconductor Corp., CPP Div. (Avance Logic)
+       0002  Arowana Optical Wheel Mouse MSOP-01
+0681  Siemens Information and Communication Products
+       0001  Dect Base
+       0002  Gigaset 3075 Passive ISDN
+       0005  ID-Mouse with Fingerprint Reader
+       0012  I-Gate 802.11b Adapter
+       001b  WLL013
+       0022  Gigaset SX353 ISDN
+       002b  A-100-I ADSL Modem
+       002e  ADSL Router_S-141
+       0034  GSM module MC35/ES75 USB Modem
+       3c06  54g USB Network Adapter
+0682  Victor Company of Japan, Ltd
+0684  Actiontec Electronics, Inc.
+0686  Minolta Co., Ltd
+       2001  PagePro 4110W
+       3001  PagePro 4100
+       3006  PagePro 1250W
+       302e  Develop D 1650iD PCL
+       3034  Develop D 2050iD PCL
+       4001  Dimage 2300
+       4003  Dimage 2330 Zoom Camera
+       4004  Scan Elite II
+       4005  Minolta DiMAGE E201 Mass Storage Device
+       4006  Dimage 7 Camera
+       4007  Dimage S304 Camera
+       4008  Dimage 5 Camera
+       4009  Dimage X Camera
+       400a  Dimage S404 Camera
+       400b  Dimage 7i Camera
+       400c  Dimage F100 Camera
+       400d  Scan Dual III
+       400e  Dimage 5400
+       400f  Dimage 7Hi Camera
+       4010  Dimage Xi Camera
+       4011  Dimage F300 Camera
+       4012  Dimage F200 Camera
+       4014  Dimage S414 Camera
+       4015  Dimage XT Camera [storage]
+       4016  Dimage XT Camera [remote mode]
+       4017  Dimage E223
+       4018  Dimage Z1  Camera
+       401a  Dimage A1 Camera
+       401c  Dimage X20 Camera
+       401e  Dimage E323 Camera
+068a  Pertech, Inc.
+068b  Potrans International, Inc.
+068e  CH Products, Inc.
+       00e2  HFX OEM Joystick
+       00f1  Pro Throttle
+       00f2  Flight Sim Pedals
+       00f3  Fighterstick
+       00ff  Flight Sim Yoke
+       0500  GameStick 3D
+       0501  CH Pro Pedals
+       0504  F-16 Combat Stick
+0690  Golden Bridge Electech, Inc.
+0693  Hagiwara Sys-Com Co., Ltd
+       0002  FlashGate SmartMedia Card Reader
+       0003  FlashGate CompactFlash Card Reader
+       0005  FlashGate
+       0006  SM PCCard R/W and SPD
+       0007  FlashGate ME (Authenticated)
+       000a  SDCard/MMC Reader/Writer
+0694  Lego Group
+       0001  Mindstorms Tower
+0698  Chuntex (CTX)
+       1786  1300ex Monitor
+       9999  VLxxxx Monitor+Hub
+0699  Tektronix, Inc.
+069a  Askey Computer Corp.
+       0001  VC010 WebCam [pwc]
+       0303  Cable Modem
+       0311  ADSL Router Remote NDIS Device
+       0318  Remote NDIS Device
+       0319  220V Remote NDIS Device
+       0320  IEEE 802.11b Wireless LAN Card
+       0321  Dynalink WLL013 / Compex WLU11A 802.11b Adapter
+       0402  Scientific Atlanta WebSTAR 100 & 200 series Cable Modem
+       0811  BT Virtual Bus for Helium
+       0821  BT Voyager 1010 802.11b Adapter
+       4402  Scientific Atlanta WebSTAR 2000 series Cable Modem
+       4403  Scientific Atlanta WebSTAR 300 series Cable Modem
+       4501  Scientific-Atlanta WebSTAR 2000 series Cable Modem
+069b  Thomson, Inc.
+       0704  DCM245 Cable Modem
+       070c  MP3 Player
+       070d  MP3 Player
+       070e  MP3 Player
+       070f  RCA Lyra RD1071 MP3 Player
+       2220  RCA Kazoo RD1000 MP3 Player
+       300a  RCA Lyra MP3 Player
+       3012  MP3 Player
+       3013  MP3 Player
+       5557  RCA CDS6300
+069d  Hughes Network Systems (HNS)
+       0001  Satellite Receiver Device
+       0002  Satellite Device
+069e  Marx
+       0005  CryptoBox v1.2
+069f  Allied Data Technologies BV
+       0010  Tornado Speakerphone FaxModem 56.0
+       0011  Tornado Speakerphone FaxModem 56.0
+       1000  ADT VvBus for CopperJet
+06a2  Topro Technology, Inc.
+06a3  Saitek PLC
+       0006  Cyborg Gold Joystick
+       0109  P880 Pad
+       0160  ST290 Pro
+       0200  Xbox Adrenalin Hub
+       0241  Xbox Adrenalin Gamepad
+       0255  X52 Flight Controller
+       040b  P990 Dual Analog Pad
+       040c  P2900 Wireless Pad
+       0422  ST90 Joystick
+       0460  ST290 Pro Flight Stick
+       0463  ST290
+       0464  Cyborg Evo
+       0471  Cyborg Graphite Stick
+       0501  R100 Sports Wheel
+       0502  ST200 Stick
+       0506  R220 Digital Wheel
+       051e  Cyborg Digital II Stick
+       052d  P750 Gamepad
+       053c  X45 Flight Controller
+       053f  X36F Flightstick
+       056c  P2000 Tilt Pad
+       056f  P2000 Tilt Pad
+       05d2  PC Dash 2
+       075c  X52 Flight Controller
+       0805  R440 Force Wheel
+       1003  GM2 Action Pad
+       1009  Action Pad
+       100a  SP550 Pad and Joystick Combo
+       100b  SP550 Pad
+       1509  P3000 Wireless Pad
+       1589  P3000 Wireless Pad
+       2541  X45 Flight Controller
+       3509  P3000 RF GamePad
+       353e  Cyborg Evo Wireless
+       3589  P3000 Wireless Pad
+       35be  Cyborg Evo
+       5509  P3000 Wireless Pad
+       8000  Gamers' Keyboard
+       801e  Cyborg 3D Digital Stick II
+       8021  Eclipse II Keyboard
+       802d  P750 Pad
+       803f  X36 Flight Controller
+       806f  P2000 Tilt Pad
+       80c0  Pro Gamer Command Unit
+       a502  Gaming Mouse
+       ff04  R440 Force Wheel
+       ff0c  Cyborg Force Rumble Pad
+       ff0d  P2600 Rumble Force Pad
+       ff12  Cyborg 3D Force Stick
+       ff17  ST 330 Rumble Force Stick
+       ff52  Cyborg 3D Rumble Force Joystick
+       ffb5  Cyborg Evo Force Joystick
+06a4  Xiamen Doowell Electron Co., Ltd
+06a5  Divio
+       0000  Typhoon Webcam 100k [nw8000]
+       d001  ProLink DS3303u WebCam
+       d800  Chicony TwinkleCam
+       d820  Wize Media 1000
+06a7  MicroStore, Inc.
+06a8  Topaz Systems, Inc.
+       0042  SignatureGem 1X5 Pad
+       0043  SignatureGem 1X5-HID Pad
+06a9  Westell
+       0005  WireSpeed Dual Connect Modem
+       0006  WireSpeed Dual Connect Modem
+       000a  WireSpeed Dual Connect Modem
+       000b  WireSpeed Dual Connect Modem
+       000e  802.11g Adapter
+06aa  Sysgration, Ltd
+06ac  Fujitsu Laboratories of America, Inc.
+06ad  Greatland Electronics Taiwan, Ltd
+06ae  Professional Multimedia Testing Centre
+06af  Harting, Inc. of North America
+06b8  Pixela Corp.
+06b9  Alcatel Telecom
+       0121  SpeedTouch 121g Wireless Dongle
+       2001  SPEED TOUCH Card
+       4061  SpeedTouch ISDN or ADSL Modem
+       a5a5  DynaMiTe Modem
+06ba  Smooth Cord & Connector Co., Ltd
+06bb  EDA, Inc.
+06bc  Oki Data Corp.
+06bd  AGFA-Gevaert NV
+       0001  SnapScan 1212U
+       0002  SnapScan 1236U
+       0100  SnapScan Touch
+       0101  SNAPSCAN ELITE
+       0200  ScanMaker 8700
+       02bf  DUOSCAN f40
+       0400  CL30
+       0401  Mass Storage
+       0403  ePhoto CL18 Camera
+       0404  ePhoto CL20 Camera
+       2061  SnapScan 1212U (?)
+       208d  Snapscan e40
+       208f  SnapScan e50
+       2091  SnapScan e20
+       2093  SnapScan e10
+       2095  SnapScan e25
+       2097  SnapScan e26
+       20fd  SnapScan e52
+       20ff  SnapScan e42
+06be  AME Optimedia Technology Co., Ltd
+       1005  Dazzle DPVM! (1005)
+       d001  P35U Camera Capture
+06bf  Leoco Corp.
+06c2  Phidgets Inc. (formerly GLAB)
+       0030  PhidgetRFID
+       0038  4-Motor PhidgetServo v3.0
+       0039  1-Motor PhidgetServo v3.0
+       003a  8-Motor PhidgetAvancedServo
+       0040  PhidgetInterface Kit 0-0-4
+       0044  PhidgetInterface Kit 0-16-16
+       0045  PhidgetInterface Kit 8-8-8
+       0048  PhidgetStepper (Under Development)
+       0049  PhidgetTextLED Ver 1.0
+       004a  PhidgetLED Ver 1.0
+       004b  PhidgetEncoder Ver 1.0
+       0051  PhidgetInterface Kit 0-5-7 (Custom)
+       0052  PhidgetTextLCD
+       0053  PhidgetInterfaceKit 0-8-8
+       0058  PhidgetMotorControl Ver 1.0
+       0070  PhidgetTemperatureSensor Ver 1.0
+       0071  PhidgetAccelerometer Ver 1.0
+       0072  PhidgetWeightSensor Ver 1.0
+       0073  PhidgetHumiditySensor
+       0074  PhidgetPHSensor
+       0075  PhidgetGyroscope
+06c4  Bizlink International Corp.
+06c5  Hagenuk, GmbH
+06c6  Infowave Software, Inc.
+06c8  SIIG, Inc.
+06c9  Taxan (Europe), Ltd
+       0005  Monitor Control
+       0007  Monitor Control
+       0009  Monitor Control
+06ca  Newer Technology, Inc.
+06cb  Synaptics, Inc.
+       0001  HID Device
+       0002  HID Device
+       0003  HID Device
+       0005  Touchpad/FPS
+       0006  HID Device
+       0007  HID Device
+       0008  HID Device
+       0009  Composite TouchPad and TrackPoint
+       000e  HID Device
+       0010  Composite Human Interface Device
+       0013  Human Interface Device
+06cc  Terayon Communication Systems
+       0101  Cable Modem
+       0102  Cable Modem
+       0103  Cable Modem
+       0104  Cable Modem
+       0304  Cable Modem
+06cd  Keyspan
+       0101  USA-28 PDA [no firmware]
+       0102  USA-28X PDA [no firmware]
+       0103  USA-19 PDA [no firmware]
+       0104  PDA [prerenum]
+       0105  USA-18X PDA [no firmware]
+       0106  USA-19W PDA [no firmware]
+       0107  USA-19 PDA
+       0108  USA-19W PDA
+       0109  USA-49W serial adapter [no firmware]
+       010a  USA-49W serial adapter
+       010b  USA-19Qi serial adapter [no firmware]
+       010c  USA-19Qi serial adapter
+       010d  USA-19Q serial Adapter (no firmware)
+       010e  USA-19Q serial Adapter
+       010f  USA-28 PDA
+       0110  USA-28Xb PDA
+       0111  USA-18 serial Adapter
+       0112  USA-18X PDA
+       0113  USA-28Xb PDA [no firmware]
+       0114  USA-28Xa PDA [no firmware]
+       0115  USA-28Xa PDA
+       0116  USA-18XA serial Adapter (no firmware)
+       0117  USA-18XA serial Adapter
+       0118  USA-19QW PDA [no firmware]
+       0119  USA-19QW PDA
+       011a  USA-49Wlc serial adapter [no firmware]
+       011b  MPR Serial Preloader (MPRQI)
+       011c  MPR Serial (MPRQI)
+       011d  MPR Serial Preloader (MPRQ)
+       011e  MPR Serial (MPRQ)
+       0121  USA-19hs serial adapter
+       012a  USA-49Wlc serial adapter
+       0201  Digital Media Remote
+       0202  UIA-11 remote control
+06cf  SpheronVR AG
+       1010  PanoCam 10
+       1012  PanoCam 12/12X
+06d0  LapLink, Inc.
+       0622  LapLink Gold USB-USB Bridge [net1080]
+06d1  Daewoo Electronics Co., Ltd
+06d3  Mitsubishi Electric Corp.
+       0380  CP8000D Port
+       0381  CP770D Port
+       0385  CP900D Port
+       0387  CP980D Port
+       038b  CP3020D Port
+       038c  CP900DW(ID) Port
+       0393  CP9500D/DW Port
+       0394  CP9000D/DW Port
+       03a1  CP9550D/DW Port
+06d4  Cisco Systems
+06d5  Toshiba
+       4000  Japanese Keyboard
+06d6  Aashima Technology B.V.
+       002d  Trust PowerC@m 350FT
+       002e  Trust PowerC@m 350FS
+       0030  Trust 710 LCD POWERC@M ZOOM - MSD
+       0031  Trust 710 LCD POWERC@M ZOOM
+       003a  Trust PowerC@m 770Z
+       003c  Trust 910z PowerC@m
+       003f  Trust 735S POWERC@M ZOOM, WDM DSC Bulk Driver
+       0050  Trust 738AV LCD PV Digital Camera
+       0062  TRUST 782AV LCD P. V. Video Capture
+       0066  TRUST Digital PCTV and Movie Editor
+       006b  TRUST AUDIO VIDEO EDITOR
+06d7  Network Computing Devices (NCD)
+06d8  Technical Marketing Research, Inc.
+06da  Phoenixtec Power Co., Ltd
+       0002  UPS
+06db  Paradyne
+06dc  Foxlink Image Technology Co., Ltd
+       0012  Scan 1200c Scanner
+       0014  Prolink Winscan Pro 2448U
+06de  Heisei Electronics Co., Ltd
+06e0  Multi-Tech Systems, Inc.
+       f101  MT5634ZBA-USB MultiModemUSB (old firmware)
+       f103  MT5634MU MultiMobileUSB
+       f104  MT5634ZBA-USB MultiModemUSB (new firmware)
+       f107  MT5634ZBA-USB-V92 MultiModemUSB
+06e1  ADS Technologies, Inc.
+       0008  UBS-10BT Ethernet [klsi]
+       0009  UBS-10BT Ethernet
+       0833  Mass Storage Device
+       a160  Instant Video-To-Go RDX-160 (no firmware)
+       a161  Instant Video-To-Go RDX-160
+       a190  Instand VCD Capture
+       a191  Instant VideoXpress
+       a337  Mini DigitalTV
+       a701  DVD Xpress
+       b337  Mini DigitalTV
+       b701  DVD Xpress B
+06e4  Alcatel Microelectronics
+06e6  Tiger Jet Network, Inc.
+       0200  Internet Phone
+       0201  Internet Phone
+       0202  Composite Device
+       0203  Internet Phone
+       0210  Composite Device
+       0211  Internet Phone
+       0212  Internet Phone
+       031c  Internet Phone
+       031d  Internet Phone
+       031e  Internet Phone
+       3200  Composite Device
+       3201  Internet Phone
+       3202  Composite Device
+       3203  Composite Device
+       7200  Composite Device
+       7210  Composite Device
+       7250  Composite Device
+       825c  Internet Phone
+       831c  Internet Phone
+       831d  Composite Device
+       831e  Composite Device
+       b200  Composite Device
+       b201  Composite Device
+       b202  Internet Phone
+       b210  Internet Phone
+       b211  Composite Device
+       b212  Composite Device
+       b250  Composite Device
+       b251  Internet Phone
+       b252  Internet Phone
+       c200  Internet Phone
+       c201  Internet Phone
+       c202  Composite Device
+       c203  Internet Phone
+       c210  Personal PhoneGateway
+       c211  Personal PhoneGateway
+       c212  Personal PhoneGateway
+       c213  PPG Device
+       c25c  Composite Device
+       c290  PPG Device
+       c291  PPG Device
+       c292  PPG Device
+       c293  Personal PhoneGateway
+       c31c  Composite Device
+       c39c  Personal PhoneGateway
+       c39d  PPG Device
+       c39e  PPG Device
+       c39f  PPG Device
+       c700  Internet Phone
+       c701  Internet Phone
+       c702  Composite Device
+       c703  Internet Phone
+       c710  VoIP Combo Device
+       c711  VoIP Combo
+       c712  VoIP Combo Device
+       c713  VoIP Combo Device
+       cf00  Composite Device
+       cf01  Internet Phone
+       cf02  Internet Phone
+       cf03  Composite Device
+       d210  Personal PhoneGateway
+       d211  PPG Device
+       d212  PPG Device
+       d213  Personal PhoneGateway
+       d700  Composite Device
+       d701  Composite Device
+       d702  Internet Phone
+       d703  Composite Device
+       d710  VoIP Combo
+       d711  VoIP Combo Device
+       d712  VoIP Combo
+       d713  VoIP Combo
+       df00  Composite Device
+       df01  Composite Device
+       df02  Internet Phone
+       df03  Internet Phone
+       f200  Internet Phone
+       f201  Internet Phone
+       f202  Composite Device
+       f203  Composite Device
+       f210  Internet Phone
+       f250  Composite Device
+       f252  Internet Phone
+       f310  Internet Phone
+       f350  Composite Device
+06ea  Sirius Technologies
+       0001  NetCom Roadster II 56k
+       0002  Roadster II 56k
+06eb  PC Expert Tech. Co., Ltd
+06ef  I.A.C. Geometrische Ingenieurs B.V.
+06f0  T.N.C Industrial Co., Ltd
+       de01  DualCam Video Camera
+       de02  DualCam Still Camera
+06f1  Opcode Systems, Inc.
+       a011  SonicPort
+       a021  SonicPort Optical
+06f2  Emine Technology Co.
+       0011  KVM Switch Keyboard
+06f6  Wintrend Technology Co., Ltd
+06f7  Wailly Technology Ltd
+       0003  USB->Din 4 Adaptor
+06f8  Guillemot Corp.
+       a300  Dual Analog Leader GamePad
+       b000  Hercules DJ Console
+       c000  Hercules Muse Pocket
+       d002  Hercules DJ Console
+       e000  HWGUSB2-54 WLAN
+       e010  HWGUSB2-54-LB
+       e020  HWGUSB2-54V2-AP
+06fa  HSD S.r.L
+06fc  Motorola Semiconductor Products Sector
+06fd  Boston Acoustics
+       0101  Audio Device
+       0102  Audio Device
+       0201  2-piece Audio Device
+06fe  Gallant Computer, Inc.
+0701  Supercomal Wire & Cable SDN. BHD.
+0703  Bvtech Industry, Inc.
+0705  NKK Corp.
+0706  Ariel Corp.
+0707  Standard Microsystems Corp.
+       0100  2202 Ethernet [klsi]
+       0200  2202 Ethernet [pegasus]
+       0201  EZ Connect USB Ethernet
+       ee04  SMCWUSB32 802.11b Wireless LAN Card
+       ee06  EZ-Connect 802.11g Adapter
+       ee13  EZ-Connect 802.11g Adapter
+0708  Putercom Co., Ltd
+       047e  USB-1284 BRIDGE
+0709  Silicon Systems, Ltd (SSL)
+070a  Oki Electric Industry Co., Ltd
+       4002  Bluetooth Device
+       4003  Bluetooth Device
+070d  Comoss Electronic Co., Ltd
+070e  Excel Cell Electronic Co., Ltd
+0710  Connect Tech, Inc.
+       0001  WhiteHeat (fake ID)
+       8001  WhiteHeat
+0711  Magic Control Technology Corp.
+       0100  Hub
+       0180  IRXpress Infrared Device
+       0181  IRXpress Infrared Device
+       0200  BAY-3U1S1P Serial Port
+       0210  MCT1S Serial Port
+       0230  MCT-232 Serial Port
+       0231  PS/2 Mouse Port
+       0232  Serial On Port
+       0240  PS/2 to USB Converter
+       0300  BAY-3U1S1P Parallel Port
+       0302  Parallel Port
+       0900  SVGA Adapter
+0713  Interval Research Corp.
+0714  NewMotion, Inc.
+       0003  ADB to USB convertor
+0717  ZNK Corp.
+0718  Imation Corp.
+       0002  SuperDisk 120MB
+       0003  SuperDisk 120MB (Authenticated)
+       0060  Flash Drive
+       0061  Flash Drive
+       0062  Flash Drive
+       0063  Swivel Flash Drive
+       0064  Flash Drive
+       0065  Flash Drive
+       0066  Flash Drive
+       0067  Flash Drive
+       0068  Flash Drive
+       0084  USB Flash Drive Mini
+0719  Tremon Enterprises Co., Ltd
+071b  Domain Technologies, Inc.
+       0002  DTI-56362-USB Digital Interface Unit
+       0101  Audio4-USB DSP Data Acquisition Unit
+       0201  Audio4-5410 DSP Data Acquisition Unit
+       0301  SB-USB JTAG Emulator
+071c  Xionics Document Technologies, Inc.
+071d  Eicon Networks Corp.
+       1000  Diva ISDN TA
+       1003  Diva
+       2000  Teledat Surf
+071e  Ariston Technologies
+0723  Centillium Communications Corp.
+       0002  Palladia 300/400 Adsl Modem
+0726  Vanguard International Semiconductor-America
+0729  Amitm
+       1000  USC-1000 Serial Port
+072e  Sunix Co., Ltd
+072f  Advanced Card Systems, Ltd
+       0001  AC1030-based SmartCard Reader
+       0008  ACR 80 Smart Card Reader
+       1000  PLDT Drive
+       1001  PLDT Drive
+       8002  AET63 BioTRUSTKey
+       8003  ACR120
+       8103  ACR120
+       9000  ACR38 AC1038-based Smart Card Reader
+       90cc  ACR38 SmartCard Reader
+       90cf  ACR38 SAM Smart Card Reader
+       90d0  PertoSmart EMV - Card Reader
+0731  Susteen, Inc.
+       0528  SonyEricsson DCU-11 Cable
+0732  Goldfull Electronics & Telecommunications Corp.
+0733  ViewQuest Technologies, Inc.
+       0101  Digital Video Camera
+       0110  VQ110
+       0401  CS330 WebCam
+       0402  M-318B WebCam
+       0430  Intel Pro Share WebCam
+       0630  VQ630 Dual Mode Digital Camera(Bulk)
+       0631  Hercules Dualpix
+       0780  Smart Cam Deluxe(composite)
+       1310  Epsilon 1.3/Jenoptik JD C1.3/UMAX AstraPix 470
+       1311  Digital Dream Epsilon 1.3
+       2211  Jenoptik
+0734  Lasat Communications A/S
+       0001  560V Modem
+       0002  Lasat 560V Modem
+       043a  DVS Audio
+0735  Asuscom Network
+       2100  ISDN Adapter
+       2101  ISDN Adapter
+       6694  ISDN Adapter
+       c541  ISDN TA 280
+0736  Lorom Industrial Co., Ltd
+0738  Mad Catz, Inc.
+       4507  XBox Device
+       4516  XBox Device
+       4520  XBox Device
+       4526  XBox Device
+       4536  XBox Device
+       4540  XBox Device
+       4556  XBox Device
+       4566  XBox Device
+       4576  XBox Device
+       4586  XBox Device
+       4588  XBox Device
+073a  Chaplet Systems, Inc.
+073b  Suncom Technologies
+073d  Eutron S.p.a.
+       0005  Crypto Token
+       0007  CryptoIdentity CCID
+       0025  SmartKey 3
+       0c00  Pocket Reader
+       0d00  StarSign Bio Token 3.0 EU
+073c  Industrial Electronic Engineers, Inc.
+       0305  Pole Display (PC305-3415  2 x 20 Line Display)
+       0322  Pole Display (PC322-3415  2 x 20 Line Display)
+       0324  Pole Display (LB324-USB   4 x 20 Line Display)
+       0330  Pole Display (P330-3415   2 x 20 Line Display)
+       0450  Pole Display (L450-USB   Graphic Line Display)
+       0505  Pole Display (SPC505-3415 2 x 20 Line Display)
+       0522  Pole Display (SPC522-3415 2 x 20 Line Display)
+       0624  Pole Display (SP324-3415  2 x 20 Line Display)
+073e  NEC, Inc.
+       0301  Game Pad
+0745  Syntech Information Co., Ltd
+0746  Onkyo Corp.
+       5500  SE-U55 Audio Device
+0747  Labway Corp.
+0748  Strong Man Enterprise Co., Ltd
+0749  EVer Electronics Corp.
+074a  Ming Fortune Industry Co., Ltd
+074b  Polestar Tech. Corp.
+074c  C-C-C Group PLC
+074d  Micronas GmbH
+       3553  Composite USB-Device
+       3554  Composite USB-Device
+       3556  Composite USB-Device
+074e  Digital Stream Corp.
+       0001  PS/2 Adapter
+       0002  PS/2 Adapter
+0755  Aureal Semiconductor
+0757  Network Technologies, Inc.
+075b  Sophisticated Circuits, Inc.
+       0001  Kick-off! Watchdog
+0763  Midiman
+       0115  KeyRig 25
+       0117  Trigger Finger
+       0119  MidAir
+       0150  M-Audio Uno
+       0160  M-Audio 1x1
+       0192  M-Audio Keystation 88es
+       0193  ProKeys 88
+       0194  ProKeys 88sx
+       0195  Oxygen 8 v2
+       0196  Oxygen 49
+       0197  Oxygen 61
+       0198  Axiom 25
+       0199  Axiom 49
+       019a  Axiom 61
+       019b  KeyRig 49
+       019c  KeyStudio
+       1001  MidiSport 2x2
+       1002  MidiSport 2x2
+       1003  MidiSport 2x2
+       1010  MidiSport 1x1
+       1011  MidiSport 1x1
+       1014  M-Audio Keystation Loader
+       1015  M-Audio Keystation
+       1020  Midisport 4x4
+       1021  MidiSport 4x4
+       1030  Midisport 8x8
+       1031  MidiSport 8x8/s Loader
+       1033  MidiSport 8x8/s
+       1040  M-Audio MidiSport 2x4 Loader
+       1041  M-Audio MidiSport 2x4
+       2001  M Audio Quattro
+       2002  M Audio Duo
+       2003  M Audio AudioPhile
+       2004  M-Audio MobilePre
+       2006  M-Audio Transit
+       2007  M-Audio Sonica Theater
+       2008  M-Audio Ozone
+       200d  M-Audio OmniStudio
+       200f  M-Audio MobilePre
+       2010  M-Audio Fast Track
+       2013  M-Audio JamLab
+       2015  M-Audio RunTime DFU
+       2016  M-Audio RunTime DFU
+       2019  M-Audio Ozone Academic
+       201a  M-Audio Micro
+       201b  M-Audio RunTime DFU
+       201d  M-Audio Producer
+       2080  M-Audio RunTime DFU
+       2081  M-Audio RunTime DFU
+       2803  M-Audio Audiophile DFU
+       2804  M-Audio MobilePre DFU
+       2806  M-Audio Transit DFU
+       2815  M-Audio DFU
+       2816  M-Audio DFU
+       281b  M-Audio DFU
+       2880  M-Audio DFU
+       2881  M-Audio DFU
+0764  Cyber Power System, Inc.
+       0005  Cyber Power UPS
+       0501  CP1500 AVR UPS
+0765  X-Rite, Inc.
+0766  Jess-Link Products Co., Ltd
+0767  Tokheim Corp.
+0768  Camtel Technology Corp.
+       0006  Camtel Technology USB TV Genie Pro FM Model TVB330
+       0023  eHome Infrared Receiver
+0769  Surecom Technology Corp.
+       11f2  EP-9001-g 802.11g 54M WLAN Adapter
+       11f3  RT2570
+       11f7  802.11g 54M WLAN Adapter
+       31f3  RT2573
+076a  Smart Technology Enablers, Inc.
+076b  OmniKey AG
+       0596  CardMan 2020
+       1021  CardMan 1021
+       1221  CardMan 1221
+       1784  CardMan 6020
+       3021  CardMan 3121
+       3610  CardMan 3620
+       3621  CardMan 3621
+       3821  CardMan 3821
+       4321  CardMan 4321
+       5121  CardMan 5121
+       5125  CardMan 5125
+       6622  CardMan 6121
+       a011  CCID Smart Card Reader Keyboard
+       a021  CCID Smart Card Reader
+       a022  CardMan Smart@Link
+       c000  CardMan 3x21 CS
+       c001  CardMan 5121 CS
+076c  Partner Tech
+076d  Denso Corp.
+076e  Kuan Tech Enterprise Co., Ltd
+076f  Jhen Vei Electronic Co., Ltd
+0770  Welch Allyn, Inc - Medical Division
+0774  AmTRAN Technology Co., Ltd
+0775  Longshine Electronics Corp.
+0776  Inalways Corp.
+0777  Comda Enterprise Corp.
+0778  Volex, Inc.
+0779  Fairchild Semiconductor
+077a  Sankyo Seiki Mfg. Co., Ltd
+077b  Linksys
+       08be  BEFCMU10 v4 Cable Modem
+       2219  WUSB11 V2.6 802.11b Adapter
+       2226  USB200M 100baseTX Adapter
+077c  Forward Electronics Co., Ltd
+       0005  NEC Keyboard
+077d  Griffin Technology
+       0223  IMic Audio In/Out
+       0405  iMate, ADB Adapter
+       0410  PowerMate
+       041a  PowerWave
+       07af  iMic
+       627a  Radio SHARK
+077f  Well Excellent & Most Corp.
+0781  SanDisk Corp.
+       0001  SDDR-05a ImageMate CompactFlash Reader
+       0002  SDDR-31 ImageMate II CompactFlash Reader
+       0005  SDDR-05b (CF II) ImageMate CompactFlash Reader
+       0100  ImageMate SDDR-12
+       0200  SDDR-09 (SSFDC) ImageMate SmartMedia Reader [eusb]
+       0400  SecureMate SD/MMC Reader
+       0621  SDDR-86 Imagemate 6-in-1 Reader
+       0720  Sansa C200 series in recovery mode
+       0729  Sansa E200 series in recovery mode
+       0810  SDDR-75 ImageMate CF-SM Reader
+       0830  ImageMate CF/MMC/SD Reader
+       1234  Cruzer Mini Flash Drive
+       5150  SDCZ2 Cruzer Mini Flash Drive (thin)
+       5151  Cruzer Micro 256/512MB Flash Drive
+       5153  Cruzer USB-Flash-Drive
+       5406  Cruzer Micro 1/4GB Flash Drive
+       5408  Cruzer Titanium U3
+       6100  Ultra II SD Plus 2GB
+       7100  Cruzer Mini
+       7101  Pen Flash
+       7102  Cruzer Mini
+       7103  Cruzer Mini
+       7104  Cruzer Micro Mini 256MB Flash Drive
+       7105  Cruzer Mini
+       7106  Cruzer Mini
+       7112  Cruzer Micro 128MB Flash Drive
+       7113  Cruzer Micro 256MB Flash Drive
+       7114  Cruzer Mini
+       7115  Cruzer Mini
+       7420  Sansa E200 series (mtp)
+       7421  Sansa E200 series
+       7432  Sansa Clip (mtp)
+       7433  Sansa Clip (msc)
+       7450  Sansa C250
+       7451  Sansa C240
+       7480  Sansa Connect
+       7481  Sansa Connect (in recovery mode)
+       8181  Pen Flash
+       8183  Hi-Speed Mass Storage Device
+       8185  SDCZ2 Cruzer Mini Flash Drive (older, thick)
+       8888  Card Reader
+       8889  SDDR-88 Imagemate 8-in-1 Reader
+       8919  Card Reader
+       8989  ImageMate 12-in-1 Reader
+       9191  ImageMate CF
+       9219  Card Reader
+       9292  ImageMate CF Reader/Writer
+       9393  ImageMate SD-MMC
+       9595  ImageMate xD-SM
+       9797  ImageMate MS-PRO
+       9919  Card Reader
+       9999  SDDR-99 5-in-1 Reader
+       a7e8  SDDR-113 MicroMate SDHC Reader
+       b2b3  SDDR-103 MobileMate SD+ Reader
+0782  Trackerball
+0783  C3PO
+       0003  LTC31 SmartCard Reader
+0784  Vivitar, Inc.
+       0100  Vivicam 2655
+       1310  Vivicam 3305
+       1688  Vivicam 3665
+       1689  Gateway DC-M42/Labtec DC-505/Vivitar Vivicam 3705
+       2620  AOL Photocam Plus
+       2888  Polaroid DC700
+       3330  Nytec ND-3200 Camera
+       4300  Traveler D1
+       5260  Werlisa Sport PX 100 / JVC GC-A33 Camera
+       5300  Pretec dc530
+0785  NTT-ME
+       0001  MN128mini-V ISDN TA
+       0003  MN128mini-J ISDN TA
+0789  Logitec Corp.
+       0026  LHD Device
+       0033  DVD Multi-plus unit LDR-H443SU2
+       0063  LDR Device
+       0064  LDR-R Device
+       00b3  DVD Multi-plus unit LDR-H443U2
+       010c  Realtek RTL8187 Wireless 802.11g 54Mbps Network Adapter
+078b  Happ Controls, Inc.
+       0010  Driving UGCI
+       0020  Flying UGCI
+       0030  Fighting UGCI
+078c  GTCO/CalComp
+       0400  Digitizer (Whiteboard)
+078e  Brincom, Inc.
+0790  Pro-Image Manufacturing Co., Ltd
+0791  Copartner Wire and Cable Mfg. Corp.
+0792  Axis Communications AB
+0793  Wha Yu Industrial Co., Ltd
+0794  ABL Electronics Corp.
+0795  RealChip, Inc.
+0796  Certicom Corp.
+0797  Grandtech Semiconductor Corp.
+       6801  Flatbed Scanner
+       6802  InkJet Color Printer
+       8001  SmartCam
+       801a  Typhoon StyloCam
+       801c  Meade Binoculars/Camera
+       8901  ScanHex SX-35a
+       8909  ScanHex SX-35b
+       8911  ScanHex SX-35c
+0798  Optelec
+       0001  Braille Voyager
+079b  Sagem
+       0027  USB-Serial Controller
+       004a  XG-760A
+       004b  Wi-Fi 11g adapter
+       0056  Agfa AP1100 Photo Printer
+       0062  XG-76NA
+079d  Alfadata Computer Corp.
+       0201  GamePort Adapter
+07a1  Digicom S.p.A.
+       d952  Palladio USB V.92 Modem
+07a2  National Technical Systems
+07a3  Onnto Corp.
+07a4  Be, Inc.
+07a6  ADMtek, Inc.
+       07c2  AN986A Ethernet
+       0986  AN986 Pegasus Ethernet
+       8266  Infineon WildCard-USB Wireless LAN Adapter
+       8511  ADM8511 Pegasus II Ethernet
+       8513  AN8513 Ethernet
+       8515  AN8515 Ethernet
+07aa  Corega K.K.
+       0001  Ether USB-T Ethernet [klsi]
+       0004  FEther USB-TX Ethernet [pegasus]
+       000c  WirelessLAN USB-11
+       000d  FEther USB-TXS
+       0012  Stick-11 802.11b Adapter
+       0017  FEther USB2-TX
+       001a  ULUSB-11 Key
+       002f  CG-WLUSB2GNL
+       7613  Stick-11 V2 802.11b Adapter
+       9601  FEther USB-TXC
+07ab  Freecom Technologies
+       fc01  IDE bridge
+       fc02  Cable II USB-2
+       fc03  USB2-IDE IDE bridge
+       fcf8  Freecom Classic SL Network Drive
+07af  Microtech
+       0004  SCSI-DB25 SCSI Bridge [shuttle]
+       0005  SCSI-HD50 SCSI Bridge [shuttle]
+       0006  CameraMate SmartMedia and CompactFlash Card Reader [eusb/shuttle]
+       fc01  Freecom USB-IDE
+07b0  Trust Technologies
+       0001  ISDN TA
+       0002  ISDN TA128 Plus
+       0003  ISDN TA128 Deluxe
+       0005  ISDN TA128 SE
+       0006  ISDN TA128 CE
+       0007  ISDN TA
+       0008  ISDN TA
+07b1  IMP, Inc.
+07b2  Motorola BCS, Inc.
+       0100  SURFboard Voice over IP Cable Modem
+       0900  SURFboard Gateway
+       0950  SURFboard SBG950 Gateway
+       1000  SURFboard SBG1000 Gateway
+       4100  SurfBoard SB4100 Cable Modem
+       4200  SurfBoard SB4200 Cable Modem
+       4210  SurfBoard 4210 Cable Modem
+       4220  SURFboard SB4220 Cable Modem
+       4500  CG4500 Communications Gateway
+       450b  CG4501 Communications Gateway
+       450e  CG4500E Communications Gateway
+       5100  SurfBoard SB5100 Cable Modem
+       5101  SurfBoard SB5101 Cable Modem
+       5120  SurfBoard SB5120 Cable Modem (RNDIS)
+       7030  Wireless Adapter WU830G
+07b3  Plustek, Inc.
+       0001  OpticPro 1212U Scanner
+       0003  Scanner
+       0010  OpticPro U12 Scanner
+       0011  OpticPro U24 Scanner
+       0013  OpticPro UT12 Scanner
+       0014  Scanner
+       0015  OpticPro U24 Scanner
+       0017  OpticPro UT12/16/24 Scanner
+       0204  Scanner
+       0400  OpticPro 1248U Scanner
+       0401  OpticPro 1248U Scanner #2
+       0403  OpticPro U16B Scanner
+       0404  Scanner
+       0405  A8 Namecard-s Controller
+       0406  A8 Namecard-D Controller
+       0410  Scanner
+       0412  Scanner
+       0800  OpticPro ST48 Scanner
+       0c03  OpticPro ST64+ Scanner
+07b4  Olympus Optical Co., Ltd
+       0100  Camedia C-2100/C-3000 Ultra Zoom Camera
+       0102  Camedia E-10/C-220/C-50 Camera
+       0105  Camedia C-310Z/C-700/C-750UZ/C-755/C-765UZ/C-3040/C-4000/C-5050Z/D-560/C-3020Z Zoom Camera
+       0109  C-370Z/D-535Z/X-450
+       0112  MAUSB-100 xD Card Reader
+       0113  Mju 500
+       0114  C-350Z Camera
+       0118  Mju Mini Digital/Mju Digital 500 Camera
+       0184  P-S100 port
+       0203  Digital Voice Recorder DW-90
+       0206  Digital Voice Recorder DS-330
+       0207  Digital Voice Recorder & Camera W-10
+       0209  Digital Voice Recorder DM-20
+       020d  Digital Voice Recorder VN-240PC
+07b5  Mega World International, Ltd
+       0017  Joystick
+       0213  Thrustmaster Firestorm Digital 3 Gamepad
+       9902  GamePad
+07b6  Marubun Corp.
+07b7  TIME Interconnect, Ltd
+07b8  D-Link Corp.
+       110c  XX1
+       1201  IEEE 802.11b Adapter
+       200c  XX2
+       2573  Wireless LAN Card
+       4000  DU-E10 Ethernet [klsi]
+       4002  DU-E100 Ethernet [pegasus]
+       4003  1/10/100 Ethernet Adapter
+       4004  XX4
+       4007  XX5
+       400b  XX6
+       400c  XX7
+       401a  RTL8151
+       4102  USB 1.1 10/100M Fast Ethernet Adapter
+       4104  XX9
+       420a  UF200 Ethernet
+       6001  WL54
+       a001  Wireless Network Adapter
+       abc1  DU-E10 Ethernet [pegasus]
+       b000  BWU613
+       b02a  AboCom Bluetooth Device
+       b02b  Bluetooth dongle
+       b02c  BCM92045DG-Flash with trace filter
+       b02d  BCM92045DG-Flash with trace filter
+       b02e  BCM92045DG-Flash with trace filter
+       b030  BCM92045DG-Flash with trace filter
+       b031  BCM92045DG-Flash with trace filter
+       b032  BCM92045DG-Flash with trace filter
+       b033  BCM92045DG-Flash with trace filter
+       b21a  802.11g Wireless Adapter
+       b21b  HWU54DM
+       b21c  RT2573
+       b21d  RT2573
+       b21e  RT2573
+       b21f  WUG2700
+       d011  MP3 Player
+       e001  Mass Storage Device
+       e002  Mass Storage Device
+       e003  Mass Storage Device
+       e004  Mass Storage Device
+       e005  Mass Storage Device
+       e006  Mass Storage Device
+       e007  Mass Storage Device
+       e008  Mass Storage Device
+       e009  Mass Storage Device
+       e00a  Mass Storage Device
+       e4f0  Card Reader Driver
+       f101  DSB-560 Modem [atlas]
+07bc  Canon Computer Systems, Inc.
+07bd  Webgear, Inc.
+07be  Veridicom
+07c0  Code Mercenaries Hard- und Software GmbH
+       1121  The Claw
+       1500  IO-Warrior 40
+       1501  IO-Warrior 24
+       1502  IO-Warrior 48
+       1503  IO-Warrior 28
+07c1  Keisokugiken
+       0068  HKS-0200 USBDAQ
+07c4  Datafab Systems, Inc.
+       0102  USB to LS120
+       0103  USB to IDE
+       1234  USB to ATAPI
+       a000  CompactFlash Card Reader
+       a001  CompactFlash & SmartMedia Card Reader [eusb]
+       a002  Disk Drive
+       a003  Datafab-based Reader
+       a004  USB to MMC Class Drive
+       a005  CompactFlash & SmartMedia Card Reader
+       a006  SmartMedia Card Reader
+       a007  Memory Stick Class Drive
+       a103  MDSM-B reader
+       a107  USB to Memory Stick (LC1) Drive
+       a109  LC1 CompactFlash & SmartMedia Card Reader
+       a10b  USB to CF+MS(LC1)
+       a200  DF-UT-06 Hama MMC/SD Reader
+       a400  CompactFlash & Microdrive Reader
+       a600  Card Reader
+       ad01  Mass Storage Device
+       ae01  Mass Storage Device
+       af01  Mass Storage Device
+       b000  USB to CF(LC1)
+       b001  USB to CF+PCMCIA
+       b004  MMC/SD Reader
+       b006  USB to PCMCIA
+       b00a  USB to CF+SD Drive(LC1)
+       b00b  USB to Memory Stick(LC1)
+07c5  APG Cash Drawer
+07c6  ShareWave, Inc.
+07c7  Powertech Industrial Co., Ltd
+07c8  B.U.G., Inc.
+       0202  MN128-SOHO PAL
+07c9  Allied Telesyn International
+       b100  AT-USB100
+07ca  AVerMedia Technologies, Inc.
+       0002  AVerTV PVR USB/EZMaker Pro Device
+       0026  AVerTV
+       1228  MPEG-2 Capture Device (M038)
+       e880  MPEG-2 Capture Device (E880)
+       e882  MPEG-2 Capture Device (E882)
+07cb  Kingmax Technology, Inc.
+07cc  Carry Computer Eng., Co., Ltd
+       0000  CF Card Reader
+       0001  Reader (UICSE)
+       0002  Reader (UIS)
+       0003  SM Card Reader
+       0004  SM/CF/PCMCIA Card Reader
+       0005  Reader (UISA2SE)
+       0006  SM/CF/PCMCIA Card Reader
+       0007  Reader (UISA6SE)
+       000c  SM/CF Card Reader
+       000d  SM/CF Card Reader
+       000e  Reader (UISDA)
+       000f  Reader (UICLIK)
+       0010  Reader (UISMA)
+       0012  Reader (UISC6SE-FLASH)
+       0014  Litronic Fortezza Reader
+       0030  Mass Storage (UISDMC12S)
+       0040  Mass Storage (UISDMC13S)
+       0100  Reader (UID)
+       0101  Reader (UIM)
+       0102  Reader (UISDMA)
+       0103  Reader (UISDMC)
+       0104  Reader (UISDM)
+       0200  6-in-1 Card Reader
+       0201  Mass Storage (UISDMC1S & UISDMC3S)
+       0202  Mass Storage (UISDMC5S)
+       0203  Mass Storage (UISMC5S)
+       0204  Mass Storage (UIM4/5S & UIM7S)
+       0205  Mass Storage (UIS4/5S & UIS7S)
+       0206  Mass Storage (UISDMC10S & UISDMC11S)
+       0207  Mass Storage (UPIDMA)
+       0208  Mass Storage (UCFC II)
+       0210  Mass Storage (UPIXXA)
+       0213  Mass Storage (UPIDA)
+       0214  Mass Storage (UPIMA)
+       0215  Mass Storage (UPISA)
+       0217  Mass Storage (UPISDMA)
+       0223  Mass Storage (UCIDA)
+       0224  Mass Storage (UCIMA)
+       0225  Mass Storage (UIS7S)
+       0227  Mass Storage (UCIDMA)
+       0234  Mass Storage (UIM7S)
+       0235  Mass Storage (UIS4S-S)
+       0237  Velper (UISDMC4S)
+       0300  6-in-1 Card Reader
+       0301  6-in-1 Card Reader
+       0303  Mass Storage (UID10W)
+       0304  Mass Storage (UIM10W)
+       0305  Mass Storage (UIS10W)
+       0308  Mass Storage (UIC10W)
+       0309  Mass Storage (UISC3W)
+       0310  Mass Storage (UISDMA2W)
+       0311  Mass Storage (UISDMC14W)
+       0320  Mass Storage (UISDMC4W)
+       0321  Mass Storage (UISDMC37W)
+       0330  WINTERREADER Reader
+       0350  9-in-1 Card Reader
+       0500  Mass Storage
+       0501  Mass Storage
+07cd  Elektor
+       0001  USBuart Serial Port
+07cf  Casio Computer Co., Ltd
+       1001  QV-8000SX/5700/3000EX Digicam; Exilim EX-M20
+       1003  Exilim EX-S500
+       1004  Exilim EX-Z120
+       1011  USB-CASIO PC CAMERA
+       2002  E-125 Cassiopeia Pocket PC
+       3801  WMP-1 MP3-Watch
+       4001  Label Printer KL-P1000
+       4007  CW50 Device
+       4104  Cw75 Device
+       4107  CW-L300 Device
+       4500  LV-20 Digital Camera
+       6801  PL-40R
+       6802  MIDI Keyboard
+07d0  Dazzle
+       0001  Digital Video Creator I
+       0002  Global Village VideoFX Grabber
+       0003  Fusion Model DVC-50 Rev 1 (NTSC)
+       0004  DVC-800 (PAL) Grabber
+       0005  Fusion Video and Audio Ports
+       0006  DVC 150 Loader Device
+       0007  DVC 150
+       0327  Fusion Digital Media Reader
+       1001  DM-FLEX DFU Adapter
+       1002  DMHS2 DFU Adapter
+       1102  CF Reader/Writer
+       1103  SD Reader/Writer
+       1104  SM Reader/Writer
+       1105  MS Reader/Writer
+       1106  xD/SM Reader/Writer
+       1202  MultiSlot Reader/Writer
+       2000  FX2 DFU Adapter
+       2001  eUSB CompactFlash Reader
+       4100  Kingsun SF-620 Infrared Adapter
+       4959  Kingsun KS-959 Infrared Adapter
+07d1  D-Link System
+       13ec  VvBus for Helium 2xx
+       13ed  VvBus for Helium 2xx
+       13f1  DSL-302G Modem
+       13f2  DSL-502G Router
+       3a07  WUA-2340 Adapter
+       3a08  predator Bootloader Download
+       3a0d  DWA-120 Wireless 108G Adapter
+       3b01  AirPlus G DWL-G122 Wireless Adapter
+       3b10  RangeBooster N Adapter
+       3b11  Wireless N Adapter DWA-130
+       3c03  DWL-G122 802.11g Adapter [ralink rt73]
+       3c04  WUA-1340
+       3c05  EH103 Wireless G Adapter
+       3c07  Wireless G DWA-110 Adapter
+       3c09  DWA-140 802.11n Adapter [ralink rt2870]
+       5100  Remote NDIS Device
+       f101  DBT-122 Bluetooth
+       fc01  DBT-120 Bluetooth Adapter
+07d2  Aptio Products, Inc.
+07d3  Cyberdata Corp.
+07d7  GCC Technologies, Inc.
+07da  Arasan Chip Systems
+07de  Diamond Multimedia
+       2820  VC500 Video Capture Dongle
+07df  David Electronics Co., Ltd
+07e1  Ambient Technologies, Inc.
+       5201  V.90 Modem
+07e2  Elmeg GmbH & Co., Ltd
+07e3  Planex Communications, Inc.
+07e4  Movado Enterprise Co., Ltd
+       0967  SCard R/W CSR-145
+       0968  SCard R/W CSR-145
+07e5  QPS, Inc.
+       05c2  IDE-to-USB2.0 PCA
+       5c01  Que! CDRW
+07e6  Allied Cable Corp.
+07e7  Mirvo Toys, Inc.
+07e8  Labsystems
+07ea  Iwatsu Electric Co., Ltd
+07eb  Double-H Technology Co., Ltd
+07ec  Taiyo Electric Wire & Cable Co., Ltd
+07ee  Torex Retail (formerly Logware)
+       0002  Cash Drawer I/F
+07ef  STSN
+       0001  Internet Access Device
+07f6  Circuit Assembly Corp.
+07f7  Century Corp.
+       0005  ScanLogic/Century Corporation uATA
+       011e  Century USB Disk Enclosure
+07f9  Dotop Technology, Inc.
+07fa  Draytek
+       0778  miniVigor 128 ISDN TA
+       1012  BeWAN ADSL USB ST (grey)
+       a904  BeWAN ADSL
+       a905  BeWAN ADSL ST
+07fd  Mark of the Unicorn
+       0000  FastLane MIDI Interface
+       0001  FastLane Quad MIDI Interface
+       0002  MOTU Audio for 64 bit
+0801  Mag-Tek
+       0002  Mini Swipe Reader
+0802  Mako Technologies, LLC
+0803  Zoom Telephonics, Inc.
+       1300  V92 Faxmodem
+       4310  Wireless-G
+       5241  Cable Modem
+       5551  DSL Modem
+       9700  2986L FaxModem
+       9800  Cable Modem
+       a312  Wireless-G
+0809  Genicom Technology, Inc.
+080a  Evermuch Technology Co., Ltd
+080c  Datalogic S.p.A.
+       0300  Gryphon D120 Barcode Scanner
+       0400  Gryphon D120 Barcode Scanner
+       0500  Gryphon D120 Barcode Scanner
+       0600  Gryphon M100 Barcode Scanner
+080d  Teco Image Systems Co., Ltd
+       0102  Hercules Scan@home 48
+       0104  3.2Slim
+       0110  UMAX AstraSlim 1200 Scanner
+0810  Personal Communication Systems, Inc.
+0813  Mattel, Inc.
+       0001  Intel Play QX3 Microscope
+       0002  Dual Mode Camera Plus
+081a  MG Logic
+       1000  Duo Pen Tablet
+081b  Indigita Corp.
+       0600  Storage Adapter
+       0601  Storage Adapter
+081c  Mipsys
+081e  AlphaSmart, Inc.
+       df00  Handheld
+0822  Reudo Corp.
+       2001  IRXpress Infrared Device
+0825  GC Protronics
+0826  Data Transit
+0827  BroadLogic, Inc.
+0828  Sato Corp.
+0829  DirecTV Broadband, Inc. (Telocity)
+082d  Handspring
+       0100  Visor
+       0200  Treo
+       0300  Treo 600
+       0400  Handheld
+       0500  Handheld
+       0600  Handheld
+0830  Palm, Inc.
+       0001  m500
+       0002  m505
+       0003  m515
+       0004  Handheld
+       0005  Handheld
+       0006  Handheld
+       0010  Handheld
+       0011  Handheld
+       0012  Handheld
+       0013  Handheld
+       0014  Handheld
+       0020  i705
+       0021  Handheld
+       0022  Handheld
+       0023  Handheld
+       0024  Handheld
+       0030  Handheld
+       0031  Tungsten W
+       0032  Handheld
+       0033  Handheld
+       0034  Handheld
+       0040  m125
+       0041  Handheld
+       0042  Handheld
+       0043  Handheld
+       0044  Handheld
+       0050  m130
+       0051  Handheld
+       0052  Handheld
+       0053  Handheld
+       0054  Handheld
+       0060  Tungsten C/E/T/T2/T3 / Zire 71
+       0061  Lifedrive / Treo 650/680 / Tunsten E2/T5/TX / Zire 21/31/72 / Z22
+       0062  Handheld
+       0063  Handheld
+       0064  Handheld
+       0070  Zire
+       0071  Handheld
+       0072  Handheld
+       0080  Serial Adapter [for Palm III]
+       0081  Handheld
+       0082  Handheld
+0832  Kouwell Electronics Corp.
+       5850  Cable
+0833  Sourcenext Corp.
+       012e  KeikaiDenwa 8 with charger
+       039f  KeikaiDenwa 8
+0835  Action Star Enterprise Co., Ltd
+0839  Samsung Techwin Co., Ltd
+       0005  Digimax Camera
+       0008  Digimax 230 Camera
+       0009  Digimax 340
+       000a  Digimax 410
+       000e  Digimax 360
+       0010  Digimax 300
+       1003  Digimax 210SE
+       1005  Digimax 220
+       1009  Digimax V4
+       1012  6500 Document Camera
+       1058  S730 Camera
+       1542  Digimax 50 Duo
+       3000  Digimax 35 MP3
+083a  Accton Technology Corp.
+       1046  10/100 Ethernet [pegasus]
+       1060  HomeLine Adapter
+       1f4d  SMC8013WG Broadband Remote NDIS Device
+       3046  10/100 Series Adapter
+       3060  1/10/100 Adapter
+       3501  2664W
+       3502  WN3501D Wireless Adapter
+       3503  T-Sinus 111 Wireless Adapter
+       4501  T-Sinus 154data
+       4505  SMCWUSB-G
+       5046  SpeedStream 10/100 Ethernet [pegasus]
+       5501  Wireless Adapter 11g
+       6500  Cable Modem
+       6618  802.11n Wireless Adapter
+       7522  802.11N Wireless Adapter
+       a618  SMC EZ Connect N Draft 11n Wireless Adapter
+       b004  CPWUE001 USB/Ethernet Adapter
+       b522  EZ Connect N Draft 11n Wireless USB2.0 Adapter
+       bb01  BlueExpert Bluetooth Device
+       c003  802.11b Wireless Adapter
+       c501  Zoom Wireless-G
+       c561  802.11a/g Wireless Adapter
+       e501  ZD1211B
+       f501  802.11g Wireless Adapter
+       f502  802.11g Wireless Adapter
+083f  Global Village
+       b100  TelePort V.90 Fax/Modem
+0840  Argosy Research, Inc.
+       0060  Storage Adapter Bridge Module
+0841  Rioport.com, Inc.
+       0001  Rio 500
+0844  Welland Industrial Co., Ltd
+0846  NetGear, Inc.
+       1001  EA101 Ethernet [klsi]
+       1002  Ethernet
+       1020  Ethernet 10/100, USB1.1
+       1040  USB 2.0 Ethernet
+       4110  MA111 WiFi (v1)
+       4200  WG121 WiFi (v1)
+       4210  WG121 WiFi (v2)
+       4220  WG111 WiFi (v1)
+       4230  MA111 WiFi (v2)
+       4240  WG111 WiFi (v2)
+       4260  WG111v3 802.11g Adapter [realtek RTL8187B]
+       4300  WG111U
+       4301  WG111U (no firmware)
+       6a00  WG111 WiFi (v2)
+       7100  WN121T Wireless Adapter
+       9000  RangeMax NEXT Wireless-N Adapter WN111
+       a001  PA101 Phoneline10X Adapter
+084d  Minton Optic Industry Co., Inc.
+       0001  Jenoptik JD800i
+       0003  S-Cam F5 Digital Camera
+       0011  Argus DC3500 Digital Camera
+       0014  Praktica DC 32
+       0019  Praktica DPix3000
+       0025  Praktica DC 60
+       1001  ScanHex SX-35d
+084e  KB Gear
+       0001  KBGear JamCam
+       1002  Pablo Tablet
+084f  Empeg
+       0001  Empeg-Car Mark I/II Player
+0850  Fast Point Technologies, Inc.
+0851  Macronix International Co., Ltd
+       1542  SiPix Blink
+       1543  Maxell WS30 Slim Digital Camera
+       a168  MXIC
+0852  CSEM
+0853  Topre Corporation
+       0100  HHKB Professional
+0854  ActiveWire, Inc.
+       0100  I/O Board
+       0101  I/O Board, rev1
+0856  B&B Electronics
+       ac01  uLinks USOTL4 RS422/485 Adapter
+0858  Hitachi Maxell, Ltd
+       3102  Bluetooth Device
+       ffff  Maxell module with BlueCore in DFU mode
+0859  Minolta Systems Laboratory, Inc.
+085a  Xircom
+       0001  Portstation Dual Serial Port
+       0003  Portstation Paraller Port
+       0008  Ethernet
+       0009  Ethernet
+       000b  Portstation Dual PS/2 Port
+       0021  1 port to Serial Converter
+       0022  Parallel Port
+       0023  2 port to Serial Converter
+       0024  Parallel Port
+       0027  1 port to Serial Converter
+       0028  PortGear to SCSI Converter
+       0032  PortStation SCSI Module
+       003c  Bluetooth Adapter
+       0299  Colorvision, Inc. Monitor Spyder
+       8021  1 port to Serial
+       8023  2 port to Serial
+       8027  PGSDB9 Serial Port
+085c  ColorVision, Inc.
+       0200  Monitor Spyder
+0862  Teletrol Systems, Inc.
+0863  Filanet Corp.
+0864  NetGear, Inc.
+       4100  MA101 802.11b Adapter
+       4102  MA101 802.11b Adapter
+0867  Data Translation, Inc.
+       9812  ECON Data acquisition unit
+       9816  DT9816 ECON data acquisition module
+       9836  DT9836 data acquisition card
+086a  Emagic Soft- und Hardware GmbH
+       0001  Unitor8
+       0002  AMT8
+       0003  MT4
+086c  DeTeWe - Deutsche Telephonwerke AG & Co.
+       1001  Eumex 504PC ISDN TA
+       1002  Eumex 504PC (FlashLoad)
+       1003  TA33 ISDN TA
+       1004  TA33 (FlashLoad)
+       1005  Eumex 604PC HomeNet
+       1006  Eumex 604PC HomeNet (FlashLoad)
+       1007  Eumex 704PC DSL
+       1008  Eumex 704PC DSL (FlashLoad)
+       1009  Eumex 724PC DSL
+       100a  Eumex 724PC DSL (FlashLoad)
+       100b  OpenCom 30
+       100c  OpenCom 30 (FlashLoad)
+       100d  BeeTel Home 100
+       100e  BeeTel Home 100 (FlashLoad)
+       1011  USB2DECT
+       1012  USB2DECT (FlashLoad)
+       1013  Eumex 704PC LAN
+       1014  Eumex 704PC LAN (FlashLoad)
+       1021  OpenCom 40
+       1022  OpenCom 40 (FlashLoad)
+       1023  OpenCom 45
+       1024  OpenCom 45 (FlashLoad)
+       1025  Sinus 61 data
+       1029  dect BOX
+       102c  Eumex 604PC HomeNet [FlashLoad]
+       1030  Eumex 704PC DSL [FlashLoad]
+       1032  OpenCom 40 [FlashLoad]
+       1033  OpenCom 30 plus
+       1034  OpenCom 30 plus (FlashLoad)
+       1055  Eumex 220 ISDN TA
+       2000  OpenCom 1000
+086e  System TALKS, Inc.
+       1920  SGC-X2UL
+086f  MEC IMEX, Inc.
+0870  Metricom
+       0001  Ricochet GS
+0871  SanDisk, Inc.
+       0001  SDDR-01 Compact Flash Reader
+       0002  SDDR-31 Compact Flash Reader
+       0005  SDDR-05 Compact Flash Reader
+0873  Xpeed, Inc.
+0874  A-Tec Subsystem, Inc.
+0879  Comtrol Corp.
+087c  Adesso/Kbtek America, Inc.
+087d  Jaton Corp.
+       5704  Ethernet
+087e  Fujitsu Computer Products of America
+087f  Virtual IP Group, Inc.
+0880  APT Technologies, Inc.
+0883  Recording Industry Association of America (RIAA)
+0885  Boca Research, Inc.
+0886  XAC Automation Corp.
+       0630  Intel PC Camera CS630
+0887  Hannstar Electronics Corp.
+088b  MassWorks, Inc.
+       4944  MassWorks ID-75 TouchScreen
+0892  DioGraphy, Inc.
+       0101  Smartdio Reader/Writer
+089c  United Technologies Research Cntr.
+089d  Icron Technologies Corp.
+089e  NST Co., Ltd
+089f  Primex Aerospace Co.
+08a5  e9, Inc.
+08a8  Andrea Electronics
+08ae  Macally (Mace Group, Inc.)
+08b4  Sorenson Vision, Inc.
+08b8  J. Gordon Electronic Design, Inc.
+       01f4  USBSIMM1
+08b9  RadioShack Corp. (Tandy)
+08bb  Texas Instruments Japan
+       2702  Speakers
+       2900  PCM2900 Audio Codec
+       2904  PCM2904 Audio Codec
+08bd  Citizen Watch Co., Ltd
+       1100  X1-USB Floppy
+08c3  Precise Biometrics
+       0001  100 SC
+       0002  100 A
+       0003  100 SC BioKeyboard
+       0006  100 A BioKeyboard
+       0100  100 MC ISP
+       0101  100 MC FingerPrint and SmartCard Reader
+       0300  100 AX
+       0400  100 SC
+       0401  150 MC
+       0402  200 MC FingerPrint and SmartCard Reader
+       0404  100 SC Upgrade
+       0405  150 MC Upgrade
+       0406  100 MC Upgrade
+08c4  Proxim, Inc.
+       02f2  Farallon Home Phoneline Adapter
+08c7  Key Nice Enterprise Co., Ltd
+08c8  2Wire, Inc.
+08c9  Nippon Telegraph and Telephone Corp.
+08ca  Aiptek International, Inc.
+       0010  Tablet
+       0020  APT-6000U Tablet
+       0021  APT-2 Tablet
+       0022  Tablet
+       0023  Tablet
+       0024  Tablet
+       0100  Pen Drive
+       0102  DualCam
+       0103  Pocket DV Digital Camera
+       0104  Pocket DVII
+       0105  Mega DV(Disk)
+       0106  Pocket DV3100+
+       0107  Pocket DV 3100
+       0109  Nisis DV4 Digital Camera
+       010a  Trust 738AV LCD PV Mass Storage
+       0111  PenCam VGA Plus
+       2008  Mini PenCam 2
+       2010  Pocket CAM 3 Mega (webcam)
+       2011  Pocket CAM 3 Mega (storage)
+       2018  Pencam SD 2
+       2024  Pocket DV3500
+       2042  DV 5100M Composite Device
+       2043  DV 5100M(Disk)
+08cd  Jue Hsun Ind. Corp.
+08ce  Long Well Electronics Corp.
+08cf  Productivity Enhancement Products
+08d1  smartBridges, Inc.
+       0001  smartNIC Ethernet [catc]
+       0003  smartNIC 2 PnP Ethernet
+08d3  Virtual Ink
+08d4  Fujitsu Siemens Computers
+       0009  SCR SmartCard Reader
+08d9  Increment P Corp.
+08dd  Billionton Systems, Inc.
+       0112  Wireless LAN Adapter
+       0113  Wireless LAN Adapter
+       0986  USB-100N Ethernet [pegasus]
+       0987  USBLP-100 HomePNA Ethernet [pegasus]
+       0988  USBEL-100 Ethernet [pegasus]
+       1986  10/100 LAN Adapter
+       2103  DVB-T TV-Tuner Card-R
+       8511  USBE-100 Ethernet [pegasus2]
+       90ff  USB2AR Ethernet
+08de  ???
+       7a01  802.11b Adapter
+08df  Spyrus, Inc.
+       0001  Rosetta Token V1
+       0002  Rosetta Token V2
+       0003  Rosetta Token V3
+       0a00  Lynks Interface
+08e3  Olitec, Inc.
+       0002  USB-RS232 Bridge
+       0100  Interface ADSL
+       0101  Interface ADSL
+       0102  ADSL
+       0301  RNIS
+08e4  Pioneer Corp.
+08e5  Litronic
+08e6  Gemplus
+       0001  GemPC-Touch 430
+       0430  GemPC430 SmartCard Reader
+       0432  GemPC432 SmartCard Reader
+       0435  GemPC435 SmartCard Reader
+       0437  GemPC433 SL SmartCard Reader
+       1359  UA SECURE STORAGE TOKEN
+       2202  Gem e-Seal Pro Token
+       3437  GemPC Twin SmartCard Reader
+       3438  GemPC Key SmartCard Reader
+       3478  PinPad Smart Card Reader
+       4433  GemPC433-Swap
+       5501  GemProx-PU Contactless Smart Card Reader
+       ace0  UA HYBRID TOKEN
+08e7  Pan-International Wire & Cable
+08e8  Integrated Memory Logic
+08e9  Extended Systems, Inc.
+       0100  XTNDAccess IrDA Dongle
+08ea  Ericsson, Inc., Blue Ridge Labs
+       00c9  ADSL Modem HM120dp Loader
+       00ca  ADSL WAN Modem HM120dp
+       00ce  HM230d Virtual Bus for Helium
+       abba  USB Driver for Bluetooth Wireless Technology
+       abbb  Bluetooth Device in DFU State
+08ec  M-Systems Flash Disk Pioneers
+       0001  TravelDrive 2C
+       0002  TravelDrive 2C
+       0005  TravelDrive 2C
+       0008  TravelDrive 2C
+       0010  DiskOnKey
+       0011  DiskOnKey
+       0012  TravelDrive 2C
+       0014  TravelDrive 2C
+       0015  Kingston DataTraveler ELITE
+       0016  Kingston DataTraveler U3
+       0020  TravelDrive
+       0021  TravelDrive
+       0022  TravelDrive
+       0023  TravelDrive
+       0024  TravelDrive
+       0025  TravelDrive
+       0026  TravelDrive
+       0027  TravelDrive
+       0028  TravelDrive
+       0029  TravelDrive
+       0030  TravelDrive
+       0822  TravelDrive 2C
+       0832  Hi-Speed Mass Storage Device
+       0998  Kingston Data Traveler2.0 Disk Driver
+       0999  Kingston Data Traveler2.0 Disk Driver
+       1000  TravelDrive 2C
+       2000  TravelDrive 2C
+       2038  TravelDrive
+       2039  TravelDrive
+       204a  TravelDrive
+       204b  TravelDrive
+08ee  CCSI/Hesso
+08f0  Corex Technologies
+08f1  CTI Electronics Corp.
+08f5  SysTec Co., Ltd
+08f6  Logic 3 International, Ltd
+08f7  Vernier
+       0001  LabPro
+       0002  EasyTemp
+08f8  Keen Top International Enterprise Co., Ltd
+08f9  Wipro Technologies
+08fa  Caere
+08fb  Socket Communications
+08fc  Sicon Cable Technology Co., Ltd
+08fd  Digianswer A/S
+       0001  Bluetooth Device
+08ff  AuthenTec, Inc.
+       1600  AES1600
+       1610  AES1600
+       2500  AES2501
+       2501  AES2501
+       2502  AES2501
+       2503  AES2501
+       2504  AES2501
+       2505  AES2501
+       2506  AES2501
+       2507  AES2501
+       2508  AES2501
+       2509  AES2501
+       250a  AES2501
+       250b  AES2501
+       250c  AES2501
+       250d  AES2501
+       250e  AES2501
+       250f  AES2501
+       2510  AES2510
+       2580  AES2501 Fingerprint Sensor
+       2588  AES2501
+       2589  AES2501
+       258a  AES2501
+       258b  AES2501
+       258c  AES2501
+       258d  AES2501
+       258e  AES2501
+       258f  AES2501
+       3400  AES3400 TruePrint Sensor
+       3401  AES3400 Sensor
+       3402  AES3400 Sensor
+       3403  AES3400 Sensor
+       3404  AES3400 TruePrint Sensor
+       3405  AES3400 TruePrint Sensor
+       3406  AES3400 TruePrint Sensor
+       3407  AES3400 TruePrint Sensor
+       4902  BioMV with TruePrint AES3500
+       4903  BioMV with TruePrint AES3400
+       5500  AES4000
+       5501  AES4000 TruePrint Sensor
+       5503  AES4000 TruePrint Sensor
+       5505  AES4000 TruePrint Sensor
+       5507  AES4000 TruePrint Sensor
+       55ff  AES4000 TruePrint Sensor.
+       5700  AES3500 Fingerprint Reader
+       5701  AES3500 TruePrint Sensor
+       5702  AES3500 TruePrint Sensor
+       5703  AES3500 TruePrint Sensor
+       5704  AES3500-BZ TruePrint Sensor
+       5705  AES3500-BZ TruePrint Sensor
+       5706  AES3500-BZ TruePrint Sensor
+       5707  AES3500-BZ TruePrint Sensor
+       5710  AES3500 TruePrint Sensor
+       5711  AES3500 TruePrint Sensor
+       5712  AES3500 TruePrint Sensor
+       5713  AES3500 TruePrint Sensor
+       5714  AES3500-BZ TruePrint Sensor
+       5715  AES3500-BZ TruePrint Sensor
+       5716  AES3500-BZ TruePrint Sensor
+       5717  AES3500-BZ TruePrint Sensor
+       5730  AES3500 TruePrint Sensor
+       5731  AES3500 TruePrint Sensor
+       5732  AES3500 TruePrint Sensor
+       5733  AES3500 TruePrint Sensor
+       5734  AES3500-BZ TruePrint Sensor
+       5735  AES3500-BZ TruePrint Sensor
+       5736  AES3500-BZ TruePrint Sensor
+       5737  AES3500-BZ TruePrint Sensor
+       afe3  FingerLoc Sensor Module (Anchor)
+       afe4  FingerLoc Sensor Module (Anchor)
+       afe5  FingerLoc Sensor Module (Anchor)
+       afe6  FingerLoc Sensor Module (Anchor)
+       fffd  AES2510 Sensor (USB Emulator)
+       ffff  Sensor (Emulator)
+0900  Pinnacle Systems, Inc.
+0901  VST Technologies
+       0001  Hard Drive Adapter (TPP)
+       0002  SigmaDrive Adapter (TPP)
+0906  Faraday Technology Corp.
+0909  Audio-Technica Corp.
+090a  Trumpion Microelectronics, Inc.
+       1001  T33520 USB Flash Card Controller
+       1100  Comotron C3310 MP3 player
+       1200  MP3 player
+       1540  Digitex Container Flash Disk
+090b  Neurosmith
+090c  Feiya Technology Corp.
+       1000  Memory Bar
+       1132  5-in-1 Card Reader
+090d  Multiport Computer Vertriebs GmbH
+090e  Shining Technology, Inc.
+090f  Fujitsu Devices, Inc.
+0910  Alation Systems, Inc.
+0911  Philips Speech Processing
+       2512  SpeechMike Pro
+0912  Voquette, Inc.
+0915  GlobeSpan, Inc.
+       0001  DSL Modem
+       0002  ADSL ATM Modem
+       0005  LAN Modem
+       2000  802.11 Adapter
+       2002  802.11 Adapter
+       8000  ADSL LAN Modem
+       8005  DSL-302G Modem
+       8101  ADSL WAN Modem
+       8102  DSL-200 ADSL Modem
+       8103  DSL-200 ADSL Modem
+       8104  DSL-200 Modem
+       8400  DSL Modem
+       8401  DSL Modem
+       8402  DSL Modem
+       8500  DSL Modem
+       8501  DSL Modem
+0917  SmartDisk Corp.
+       0001  eFilm Reader-11 SM/CF
+       0002  eFilm Reader-11 SM
+       0003  eFilm Reader-11 CF
+       0200  FireFly
+       0201  FireLite
+       0202  STORAGE ADAPTER (FirePower)
+       0204  FlashTrax Storage
+       0205  STORAGE ADAPTER (CrossFire)
+       0206  FireFly 20G HDD
+       0207  FireLite
+       020f  STORAGE ADAPTER (FireLite)
+       da01  eFilm Reader-11 Test
+       ffff  eFilm Reader-11 (Class/PDR)
+0919  Tiger Electronics
+       0100  Fast Flicks Digital Camera
+091e  Garmin International
+       0003  GPSmap (various models)
+       0004  Garmin iQue 3600
+       0200  Data Card Programmer (install)
+       1200  Data Card Programmer
+0920  Echelon Co.
+       7500  Network Interface
+0921  GoHubs, Inc.
+       1001  GoCOM232 Serial
+0922  Dymo-CoStar Corp.
+       0007  LabelWriter 330
+       0009  LabelWriter 310
+0923  IC Media Corp.
+       010f  SIIG MobileCam
+0924  Xerox
+       23dd  DocuPrint M760 (X760_USB)
+       3d5b  Phaser 6115MFP TWAIN Scanner
+       420f  WorkCentre PE220 Series
+       421f  M20 Scanner
+       423b  Printing Support
+       ffef  WorkCenter M15
+       fffb  DocuPrint M750 (X750_USB)
+0925  Lakeview Research
+       8101  Phidgets, Inc., 1-Motor PhidgetServo v2.0
+       8104  Phidgets, Inc., 4-Motor PhidgetServo v2.0
+       8800  WiseGroup Ltd, MP-8800 Quad Joypad
+       8866  WiseGroup Ltd, MP-8866 Dual Joypad
+0927  Summus, Ltd
+0928  Oxford Semiconductor, Ltd
+0929  American Biometric Co.
+092a  Toshiba Information & Industrial Sys. And Services
+092b  Sena Technologies, Inc.
+092f  Northern Embedded Science/CAVNEX
+       0004  JTAG-4
+       0005  JTAG-5
+0930  Toshiba Corp.
+       0009  Gigabeat F/X (HDD audio player)
+       000c  Gigabeat F (mtp)
+       0010  Gigabeat S (mtp)
+       0301  PCX1100U Cable Modem (WDM)
+       0302  PCX2000 Cable Modem (WDM)
+       0305  Cable Modem PCX3000
+       0307  Cable Modem PCX2500
+       0308  PCX2200 Cable Modem (WDM)
+       0309  PCX5000 Cable Modem (WDM)
+       030b  Cable Modem PCX2600
+       0501  Bluetooth Controller
+       0502  Integrated Bluetooth
+       0503  Bluetooth Controller
+       0505  Integrated Bluetooth
+       0506  Integrated Bluetooth
+       0507  Bluetooth Adapter
+       0508  Integrated Bluetooth HCI
+       0509  BT EDR Dongle
+       0706  PocketPC e740
+       0707  Pocket PC e330 Series
+       0708  Pocket PC e350 Series
+       0709  Pocket PC e750 Series
+       070a  Pocket PC e400 Series
+       070b  Pocket PC e800 Series
+       1300  Wireless Broadband (CDMA EV-DO) SM-Bus Minicard Status Port
+       1301  Wireless Broadband (CDMA EV-DO) Minicard Status Port
+       1302  Wireless Broadband (3G HSDPA) SM-Bus Minicard Status Port
+       1303  Wireless Broadband (3G HSDPA) Minicard Status Port
+       1308  Broadband (3G HSDPA) SM-Bus Minicard Diagnostics Port
+       642f  TravelDrive
+       6506  TravelDrive 2C
+       6507  TravelDrive 2C
+       6508  TravelDrive 2C
+       6509  TravelDrive 2C
+       6510  TravelDrive 2C
+       6517  TravelDrive 2C
+       6518  TravelDrive 2C
+       6519  Kingston DataTraveler 2.0 USB Stick
+       651a  TravelDrive 2C
+       651b  TravelDrive 2C
+       651c  TravelDrive 2C
+       651d  TravelDrive 2C
+       651e  TravelDrive 2C
+       651f  TravelDrive 2C
+       6520  TravelDrive 2C
+       6521  TravelDrive 2C
+       6522  TravelDrive 2C
+       6523  TravelDrive
+       6524  TravelDrive
+       6525  TravelDrive
+       6526  TravelDrive
+       6527  TravelDrive
+       6528  TravelDrive
+       6529  TravelDrive
+       652a  TravelDrive
+       652b  TravelDrive
+       652c  TravelDrive
+       652d  TravelDrive
+       652f  TravelDrive
+       6530  TravelDrive
+       6531  TravelDrive
+       6532  256M USB Stick
+       6533  512M USB Stick
+       6534  TravelDrive
+       653c  Kingston DataTraveler 2.0 USB Stick (512M)
+       653d  Kingston DataTraveler 2.0 USB Stick (1GB)
+       653e  USB Flash Memory
+       6540  TransMemory USB Flash Memory
+0931  Harmonic Data Systems, Ltd
+0932  Crescentec Corp.
+       0300  VideoAdvantage
+       0302  Syntek DC-112X
+       0320  VideoAdvantage
+       1100  Video Enhamcement Device
+       1112  Veo Web Camera
+       a311  Video Enhancement Device
+0933  Quantum Corp.
+0934  Netcom Systems
+0939  Lumberg, Inc.
+093a  Pixart Imaging, Inc.
+       0007  CMOS 100K-R Rev. 1.90
+       010e  Digital camera, CD302N/Elta Medi@ digi-cam/HE-501A
+       010f  Argus DC-1610/DC-1620/Emprex PCD3600/Philips P44417B keychain camera/Precision Mini,Model HA513A/Vivitar Vivicam 55
+       2460  Q-TEC WEBCAM 100
+       2468  Cammaestro 2.5DU/X-EYE/Orite SC-120/ICGear TravelCam/Easy Snap Snake Eye WebCam
+       2470  SoC PC-Camera
+       2471  SoC PC-Camera
+       2500  USB Optical Mouse
+       2600  Typhoon Easycam USB 330K (newer)/Typhoon Easycam USB 2.0 VGA 1.3M/Sansun SN-508
+       2601  SPC 610NC Laptop Camera
+093b  Plextor Corp.
+       0010  Storage Adapter
+       0011  PlexWriter 40/12/40U
+       0042  PX-712UF DVD RW
+       a002  ConvertX M402U XLOADER
+       a003  ConvertX AV100U A/V Capture Audio
+       a004  ConvertX TV402U XLOADER
+       a005  KWorld EMP Audio Device
+       a102  ConvertX M402U A/V Capture
+       a104  ConvertX PX-TV402U/NA
+093c  Intrepid Control Systems, Inc.
+       0601  ValueCAN
+       0701  NeoVI Blue vehicle bus interface
+093d  InnoSync, Inc.
+093e  J.S.T. Mfg. Co., Ltd
+093f  Olympia Telecom Vertriebs GmbH
+0940  Japan Storage Battery Co., Ltd
+0941  Photobit Corp.
+0942  i2Go.com, LLC
+0943  HCL Technologies India Private, Ltd
+0944  KORG, Inc.
+0945  Pasco Scientific
+0948  Kronauer music in digital
+       0301  USB Pro (24/48)
+       0302  USB Pro (24/96 playback)
+       0303  USB Pro (24/96 record)
+       0304  USB Pro (16/48)
+       1105  USB One
+094b  Linkup Systems Corp.
+094d  Cable Television Laboratories
+094f  Yano
+       0101  U640MO-03
+       05fc  METALWEAR-HDD
+0951  Kingston Technology
+       0008  Ethernet
+       000a  KNU101TX 100baseTX Ethernet
+       1600  Data Traveler II Pen Drive
+       1601  Data Traveler II+ Pen Drive
+       1602  Data Traveler Mini
+       1603  Data Traveler 1GB/2GB Pen Drive
+0954  RPM Systems Corp.
+0955  NVidia Corp.
+0956  BSquare Corp.
+0957  Agilent Technologies, Inc.
+       0200  E-Video DC-350 Camera
+       0202  E-Video DC-350 Camera
+0958  CompuLink Research, Inc.
+0959  Cologne Chip AG
+       2bd0  Intelligent ISDN (Ver. 3.60.04)
+095a  Portsmith
+       3003  Express Ethernet
+095b  Medialogic Corp.
+095c  K-Tec Electronics
+095d  Polycom, Inc.
+       0001  Polycom ViaVideo
+0967  Acer (??)
+       0204  WarpLink 802.11b Adapter
+0968  Catalyst Enterprises, Inc.
+096e  Feitian Technologies, Inc.
+       0802  ePass2000 (G&D STARCOS SPK 2.4)
+0971  Gretag-Macbeth AG
+0973  Schlumberger
+       0001  e-gate Smart Card
+0974  Datagraphix, a business unit of Anacomp
+0975  OL'E Communications, Inc.
+0976  Adirondack Wire & Cable
+0977  Lightsurf Technologies
+0978  Beckhoff GmbH
+0979  Jeilin Technology Corp., Ltd
+       0224  JL2005A Toy Camera
+       0226  JL2005A Toy Camera
+097a  Minds At Work LLC
+       0001  Digital Wallet
+097b  Knudsen Engineering, Ltd
+097c  Marunix Co., Ltd
+097d  Rosun Technologies, Inc.
+097f  Barun Electronics Co., Ltd
+0981  Oak Technology, Ltd
+0984  Apricorn
+       0200  Hard Drive Storage (TPP)
+0985  cab Produkttechnik GmbH & Co KG
+       00a3  A3/200 or A3/300 Label Printer
+0986  Matsushita Electric Works, Ltd.
+098c  Vitana Corp.
+098d  INDesign
+098e  Integrated Intellectual Property, Inc.
+098f  Kenwood TMI Corp.
+0993  Gemstar eBook Group, Ltd
+       0001  REB1100 eBook Reader
+       0002  eBook
+0996  Integrated Telecom Express, Inc.
+099a  Zippy Technology Corp.
+       610c  EL-610 Super Mini Electron luminescent Keyboard
+09a3  PairGain Technologies
+09a4  Contech Research, Inc.
+09a5  VCON Telecommunications
+09a6  Poinchips
+       8001  Mass Storage Device
+09a7  Data Transmission Network Corp.
+09a8  Lin Shiung Enterprise Co., Ltd
+09a9  Smart Card Technologies Co., Ltd
+09aa  Intersil Corp.
+       1000  Prism GT 802.11b/g Adapter
+       3642  Prism 2.x 802.11b Adapter
+09ab  Japan Cash Machine Co., Ltd.
+09ae  Tripp Lite
+09b2  Franklin Electronic Publishers, Inc.
+       0001  eBookman Palm Computer
+09b3  Altius Solutions, Inc.
+09b4  MDS Telephone Systems
+09b5  Celltrix Technology Co., Ltd
+09bc  Grundig
+       0002  MPaxx MP150 MP3 Player
+09be  MySmart.Com
+       0001  MySmartPad
+09bf  Auerswald GmbH & Co. KG
+       00c0  COMpact 2104 ISDN PBX
+       00db  COMpact 4410/2206 ISDN ISDN
+       00f1  COMfort System Telephones
+09c1  Arris Interactive LLC
+       1337  TOUCHSTONE DEVICE
+09c2  Nisca Corp.
+09c3  ActivCard, Inc.
+       0007  Reader V2
+       0008  SmartCard Reader
+09c4  ACTiSYS Corp.
+       0011  ACT-IR2000U IrDA Dongle
+09c5  Memory Corp.
+09cc  Workbit Corp.
+       0404  BAFO USB-ATA/ATAPI Bridge Controller
+09cd  Psion Dacom Home Networks, Ltd
+09ce  City Electronics, Ltd
+09cf  Electronics Testing Center, Taiwan
+09d1  NeoMagic, Inc.
+09d2  Vreelin Engineering, Inc.
+09d3  Com One
+       0001  ISDN TA
+09d7  Novatel Wireless
+       0100  NovAtel FlexPack GPS receiver
+09d9  KRF Tech, Ltd
+09da  A4 Tech Co., Ltd
+       0006  Optical Mouse WOP-35 / Trust 450L Optical Mouse
+       000a  Port Mouse
+       0018  Trust Human Interface Device
+       001a  Wireless Mouse & RXM-15 Receiver
+       002a  Wireless Optical Mouse NB-30
+09db  Measurement Computing Corp.
+       0075  MiniLab 1008
+       0076  PMD-1024
+       007a  PMD-1208LS
+       0081  USB-1616FS
+       0088  USB-1616FS internal hub
+09dc  Aimex Corp.
+09dd  Fellowes, Inc.
+09df  Addonics Technologies Corp.
+09e1  Intellon Corp.
+       5121  MicroLink dLAN
+09e5  Jo-Dan International, Inc.
+09e6  Silutia, Inc.
+09e7  Real 3D, Inc.
+09e8  AKAI  Professional M.I. Corp.
+09e9  Chen-Source, Inc.
+09eb  IM Networks, Inc.
+       4331  iRhythm Tuner Remote
+09ef  Xitel
+       0101  MD-Port DG2 MiniDisc Interface
+09f5  AresCom
+       0168  Network Adapter
+       0188  LAN Adapter
+       0850  Adapter
+09f6  RocketChips, Inc.
+09f7  Edu-Science (H.K.), Ltd
+09f8  SoftConnex Technologies, Inc.
+09f9  Bay Associates
+09fa  Mtek Vision
+09fb  Altera
+09ff  Gain Technology Corp.
+0a00  Liquid Audio
+0a01  ViA, Inc.
+0a07  Ontrak Control Systems Inc.
+       0064  ADU100 Data Acquisition Interface
+       00c8  ADU200 Relay I/O Interface
+       00d0  ADU208 Data Acquisition Interface
+0a0b  Cybex Computer Products Co.
+0a11  Xentec, Inc.
+0a12  Cambridge Silicon Radio, Ltd
+       0001  Bluetooth Dongle (HCI mode)
+       0002  Frontline Test Equipment Bluetooth Device
+       0003  Nanosira
+       0004  Nanosira WHQL Reference Radio
+       0005  Nanosira-Multimedia
+       0006  Nanosira-Multimedia WHQL Reference Radio
+       0007  Nanosira3-ROM
+       0008  Nanosira3-ROM
+       0009  Nanosira4-EDR WHQL Reference Radio
+       000a  Nanosira4-EDR-ROM
+       000b  Nanosira5-ROM
+       0043  Bluetooth Device
+       0100  Casira with BlueCore2-External Module
+       0101  Casira with BlueCore2-Flash Module
+       0102  Casira with BlueCore3-Multimedia Module
+       0103  Casira with BlueCore3-Flash Module
+       0104  Casira with BlueCore4-External Module
+       0105  Casira with BlueCore4-Multimedia Module
+       1000  Bluetooth Dongle (HID proxy mode)
+       1010  Bluetooth Device
+       1011  Bluetooth Device
+       1012  Bluetooth Device
+       ffff  USB Bluetooth Device in DFU State
+0a13  Telebyte, Inc.
+0a14  Spacelabs Medical, Inc.
+0a15  Scalar Corp.
+0a16  Trek Technology (S) PTE, Ltd
+       1111  ThumbDrive
+       8888  IBM USB Memory Key
+       9988  Trek2000 TD-G2
+0a17  Pentax Corp.
+       0004  Pentax Optio 330
+       0006  Pentax Optio S
+       0007  Pentax Optio 550
+       0009  Pentax Optio 33WR
+       000a  Pentax Optio 555
+       000c  Pentax Optio 43WR (mass storage mode)
+       000d  Pentax Optio 43WR
+       0015  Pentax Optio S40/S5i
+       003b  Pentax Optio 50 (mass storage mode)
+       003d  Pentax Optio S55
+       0043  Pentax *ist DL
+       0047  Pentax Optio S60
+       0052  Optio 60 Digital Camera
+       006e  Pentax K10D
+       0070  Pentax K100D
+       1001  EI2000 Camera powered by Digita!
+0a18  Heidelberger Druckmaschinen AG
+0a19  Hua Geng Technologies, Inc.
+0a21  Medtronic Physio Control Corp.
+0a22  Century Semiconductor USA, Inc.
+0a2c  AK-Modul-Bus Computer GmbH
+       0008  GPIO Ports
+0a34  TG3 Electronics, Inc.
+       0110  Deck 82-key backlit keyboard
+0a39  Gilat Satellite Networks, Ltd
+0a3a  PentaMedia Co., Ltd
+       0163  KN-W510U 1.0 Wireless LAN Adapter
+0a3c  NTT DoCoMo, Inc.
+0a3d  Varo Vision
+0a3f  Swissonic AG
+0a43  Boca Systems, Inc.
+0a46  Davicom Semiconductor, Inc.
+       0268  ST268
+       9601  DM9601 To Fast Ethernet Adapter
+0a47  Hirose Electric
+0a48  I/O Interconnect
+       3233  Multimedia Card Reader
+       3239  Multimedia Card Reader
+       3258  Dane Elec zMate SD Reader
+       3259  Dane Elec zMate CF Reader
+       5000  MediaGear xD-SM
+       500a  Mass Storage Device
+       500f  Mass Storage Device
+       5010  Mass Storage Device
+       5011  Mass Storage Device
+       5014  Mass Storage Device
+       5020  Mass Storage Device
+       5021  Mass Storage Device
+       5022  Mass Storage Device
+       5023  Mass Storage Device
+       5024  Mass Storage Device
+       5025  Mass Storage Device
+0a4b  Fujitsu Media Devices, Ltd
+0a4c  Computex Co., Ltd
+0a4d  Evolution Electronics, Ltd
+       0064  MK-225 Driver
+       0065  MK-225C Driver
+       0066  MK-225C Driver
+       0067  MK-425C Driver
+       0078  MK-37 Driver
+       0079  MK-37C Driver
+       007a  MK-37C Driver
+       008c  TerraTec MIDI MASTER
+       008d  MK-249C Driver
+       008e  MK-249C MIDI Keyboard
+       008f  MK-449C Driver
+       0090  Keystation 49e Driver
+       0091  Keystation 61es Driver
+       00a0  MK-361 Driver
+       00a1  MK-361C Driver
+       00a2  MK-361C Driver
+       00a3  MK-461C MIDI Keyboard
+       00b5  Keystation Pro 88 Driver
+       00d2  E-Keys Driver
+       00f0  UC-16 Driver
+       00f1  X-Session Driver
+       00f5  UC-33e MIDI Controller
+0a4e  Steinberg Soft-und Hardware GmbH
+0a4f  Litton Systems, Inc.
+0a50  Mimaki Engineering Co., Ltd
+0a51  Sony Electronics, Inc.
+0a52  Jebsee Electronics Co., Ltd
+0a53  Portable Peripheral Co., Ltd
+       1000  Scanner
+       2000  Q-Scan A6 Scanner
+       2001  Q-Scan A6 Scanner
+       2013  Media Drive A6 Scanner
+       2014  Media Drive A6 Scanner
+       2015  BizCardReader 600C
+       2016  BizCardReader 600C
+       202a  Scanshell-CSSN
+       3000  Q-Scan A8 Scanner
+       3002  Q-Scan A8 Reader
+       3015  BizCardReader 300G
+       5001  BizCardReader 900C
+0a5a  Electronics For Imaging, Inc.
+0a5b  EAsics NV
+0a5c  Broadcom Corp.
+       0201  iLine10(tm) Network Adapter
+       2000  Bluetooth Device
+       2009  Bluetooth Controller
+       200a  Bluetooth dongle
+       200f  Bluetooth Controller
+       201d  Bluetooth Device
+       201e  IBM Integrated Bluetooth IV
+       2020  Bluetooth Dongle
+       2033  BCM2033 Bluetooth
+       2035  BCM2035 Bluetooth
+       2038  Blutonium Device
+       2039  Bluetooth Device
+       2045  Bluetooth Controller
+       2046  Bluetooth Device
+       2047  Bluetooth Device
+       205e  Bluetooth Device
+       2100  Bluetooth 2.0+eDR dongle
+       2101  A-Link BlueUsbA2 Bluetooth
+       2102  ANYCOM Blue USB-200/250
+       2110  Bluetooth Controller
+       2111  ANYCOM Blue USB-UHE 200/250
+       2120  2045 Bluetooth 2.0 USB-UHE Device with trace filter
+       2121  BCM2210 Bluetooth
+       2122  Bluetooth 2.0+EDR dongle
+       2130  2045 Bluetooth 2.0 USB-UHE Device with trace filter
+       2131  2045 Bluetooth 2.0 Device with trace filter
+       6300  Pirelli Remote NDIS Device
+0a5d  Diatrend Corp.
+0a5f  Zebra
+       0009  LP2844 Printer
+       930a  Printer
+0a62  MPMan
+       0010  MPMan MP-F40 MP3 Player
+0a66  ClearCube Technology
+0a67  Medeli Electronics Co., Ltd
+0a68  Comaide Corp.
+0a69  Chroma ate, Inc.
+0a6b  Green House Co., Ltd
+       0001  Compact Flash R/W with MP3 player
+0a6c  Integrated Circuit Systems, Inc.
+0a6d  UPS Manufacturing
+0a6e  Benwin
+0a6f  Core Technology, Inc.
+       0400  Xanboo
+0a70  International Game Technology
+0a72  Sanwa Denshi
+0a7d  NSTL, Inc.
+0a7e  Octagon Systems Corp.
+0a80  Rexon Technology Corp., Ltd
+0a81  Chesen Electronics Corp.
+       0101  Keyboard
+       0103  Keyboard
+       0203  Mouse
+       0205  PS/2 Keyboard+Mouse Adapter
+0a82  Syscan
+       4600  TravelScan 460/464
+0a83  NextComm, Inc.
+0a84  Maui Innovative Peripherals
+0a85  Idexx Labs
+0a86  NITGen Co., Ltd
+0a8d  Picturetel
+0a8e  Japan Aviation Electronics Industry, Ltd
+       2011  Filter Driver For JAE XMC R/W
+0a90  Candy Technology Co., Ltd
+0a91  Globlink Technology, Inc.
+       3801  Targus PAKP003 Mouse
+0a92  EGO SYStems, Inc.
+       0011  SYS WaveTerminal U2A
+       0021  GIGAPort
+       0031  GIGAPortAG
+       0053  AudioTrak Optoplay
+       0061  Waveterminal U24
+       0071  MAYA EX7
+       0091  Maya 44
+       00b1  MAYA EX5
+       1000  MIDI Mate
+       1010  RoMI/O
+       1020  M4U
+       1030  M8U
+       1090  KeyControl49
+       10a0  KeyControl25
+0a93  C Technologies AB
+       0002  C-Pen 10
+       0005  MyPen Light
+       000d  Input Pen
+       0010  C-Pen 20
+0a94  Intersense
+0aa3  Lava Computer Mfg., Inc.
+0aa4  Develco Elektronik
+0aa5  First International Digital
+       0002  irock! 500 Series
+       0801  MP3 Player
+0aa6  Perception Digital, Ltd
+       0101  Hercules Jukebox
+       1501  Store 'n' Go HD Drive
+0aa7  Wincor Nixdorf International GmbH
+       0100  POS Keyboard, TA58P-USB
+       0101  POS Keyboard, TA85P-USB
+       0102  POS Keyboard, TA59-USB
+       0103  POS Keyboard, TA60-USB
+       0104  SNIkey Keyboard, SNIKey-KB-USB
+       0200  Operator Display, BA63-USB
+       0201  Operator Display, BA66-USB
+       0202  Operator Display & Scanner, XiCheck-BA63
+       0203  Operator Display & Scanner, XiCheck-BA66
+       0204  Graphics Operator Display, BA63GV
+       0300  POS Printer (printer class mode), TH210
+       0301  POS Printer (native mode), TH210
+       0302  POS Printer (printer class mode), TH220
+       0303  POS Printer (native mode), TH220
+       0304  POS Printer, TH230
+       0305  Lottery Printer, XiPrintPlus
+       0306  POS Printer (printer class mode), TH320
+       0307  POS Printer (native mode), TH320
+       0308  POS Printer (printer class mode), TH420
+       0309  POS Printer (native mode), TH420
+       030a  POS Printer, TH200B
+       0400  Lottery Scanner, Xiscan S
+       0401  Lottery Scanner, Xiscan 3
+       4304  Banking Printer TP07
+0aa8  TriGem Computer, Inc.
+       0060  TG 11Mbps WLAN Mini Adapter
+       1001  DreamComboM4100
+       3002  InkJet Color Printer
+       8001  TG_iMON
+       8002  TG_KLOSS
+       a001  TG_X2
+       a002  TGVFD_KLOSS
+       ffda  iMON_VFD
+0aa9  Baromtec Co.
+       f01b  Medion MD 6242 MP3 Player
+0aaa  Japan CBM Corp.
+0aab  Vision Shape Europe SA
+0aac  iCompression, Inc.
+0aad  Rohde & Schwarz GmbH & Co. KG
+0aae  NEC infrontia Corp. (Nitsuko)
+0aaf  Digitalway Co., Ltd
+0ab0  Arrow Strong Electronics Co., Ltd
+0aba  Ellisys
+       8001  USB Tracker 110 Protocol Analyzer
+0abe  Stereo-Link
+       0101  SL1200 DAC
+0ac3  Sanyo Semiconductor Company Micro
+0ac4  Leco Corp.
+0ac5  I & C Corp.
+0ac6  Singing Electrons, Inc.
+0ac7  Panwest Corp.
+0ac8  Z-Star Microelectronics Corp.
+       0301  Web Camera
+       0302  ZC0302 WebCam
+       0321  USB 2.0 Webcam
+       0323  Luxya WC-1200 USB 2.0 Webcam
+       301b  ZC0301 WebCam
+       303b  ZC0303 WebCam
+       305b  ZC0305 WebCam
+       307b  USB 1.1 WebCam
+       c002  Visual Communication Camera VGP-VCC1
+0ac9  Micro Solutions, Inc.
+       0000  Backpack CD-ReWriter
+       0001  BACKPACK  2 Cable
+       0010  BACKPACK
+       0011  Backpack 40GB Hard Drive
+       0110  BACKPACK
+       0111  BackPack
+       1234  BACKPACK
+0aca  OPEN Networks Ltd
+       1060  OPEN NT1 Plus II
+0acc  Koga Electronics Co.
+0acd  ID Tech
+       0401  ID TECH Spectrum III Hybrid Smartcard Reader
+0ace  ZyDAS
+       1201  802.11b WiFi
+       1211  802.11b/g USB2 WiFi
+       1215  WLA-54L WiFi
+       1608  ONMI FAXMODEM 56K UNO (ZyXEL)
+0acf  Intoto, Inc.
+0ad0  Intellix Corp.
+0ad1  Remotec Technology, Ltd
+0ad2  Service & Quality Technology Co., Ltd
+0ae3  Allion Computer, Inc.
+0ae4  Taito Corp.
+0ae7  Neodym Systems, Inc.
+0ae8  System Support Co., Ltd
+0ae9  North Shore Circuit Design L.L.P.
+0aea  SciEssence, LLC
+0aeb  TTP Communications, Ltd
+0aec  Neodio Technologies Corp.
+       2101  SmartMedia Card Reader
+       2102  CompactFlash Card Reader
+       2103  MMC/SD Card Reader
+       2104  MemoryStick Card Reader
+       2201  SmartMedia+CompactFlash Card Reader
+       2202  SmartMedia+MMC/SD Card Reader
+       2203  SmartMedia+MemoryStick Card Reader
+       2204  CompactFlash+MMC/SD Card Reader
+       2205  CompactFlash+MemoryStick Card Reader
+       2206  MMC/SD+MemoryStick Card Reader
+       2301  SmartMedia+CompactFlash+MMC/SD Card Reader
+       2302  SmartMedia+CompactFlash+MemoryStick Card Reader
+       2303  SmartMedia+MMC/SD+MemoryStick Card Reader
+       2304  CompactFlash+MMC/SD+MemoryStick Card Reader
+       3016  MMC/SD+Memory Stick Card Reader
+       3050  ND3050 8-in-1 Card Reader
+       3060  1.1 FS Card Reader
+       3101  MMC/SD Card Reader
+       3102  MemoryStick Card Reader
+       3201  MMC/SD+MemoryStick Card Reader
+       3216  HS Card Reader
+       3260  7-in-1 Card Reader
+       5010  ND5010 Card Reader
+0af0  Option
+       5000  UMTS Card
+       6000  GlobeTrotter 3G datacard
+       6300  GT 3G Quad UMTS/GPRS Card
+       6600  GlobeTrotter 3G+ datacard
+0af6  Silver I Co., Ltd
+0af7  B2C2, Inc.
+       0101  Digital TV USB Receiver (DVB-S/T/C / ATSC)
+0af9  Hama, Inc.
+       0010  USB SightCam 100
+       0011  Micro Innovations IC50C WebCam
+0afc  Zaptronix Ltd
+0afd  Tateno Dennou, Inc.
+0afe  Cummins Engine Co.
+0aff  Jump Zone Network Products, Inc.
+0b00  INGENICO
+0b05  ASUSTek Computer, Inc.
+       1101  Mass Storage (UISDMC4S)
+       1706  WL-167G 802.11g Adapter [ralink]
+       1707  WL-167g Wireless Adapter
+       1708  Mass Storage Device
+       170b  Mass Storage Device
+       170c  WL-159g
+       170d  802.11b/g Wireless Network Adapter
+       1712  BT-183 Bluetooth 2.0+EDR adapter
+       1715  2045 Bluetooth 2.0 Device with trace filter
+       1716  Bluetooth Device
+       171b  A9T wireless
+       171c  802.11b/g Wireless Network Adapter
+       1723  WL-167G v2 802.11g Adapter [ralink]
+       1724  RT2573
+       1726  Laptop OLED Display
+       172a  ASUS 802.11n Network Adapter
+       172b  802.11n Network Adapter
+       1731  ASUS 802.11n Network Adapter
+       1732  802.11n Network Adapter
+       173c  BT-183 Bluetooth 2.0
+       1742  802.11n Network Adapter
+       6101  Cable Modem
+       620a  Remote NDIS Device
+0b0c  Todos Data System AB
+       0009  Todos Argos Mini II Smart Card Reader
+0b0e  GN Netcom
+0b0f  AVID Technology
+0b10  Pcally
+0b11  I Tech Solutions Co., Ltd
+0b1e  Electronic Warfare Assoc., Inc. (EWA)
+0b1f  Insyde Software Corp.
+0b20  TransDimension, Inc.
+0b21  Yokogawa Electric Corp.
+0b22  Japan System Development Co., Ltd
+0b23  Pan-Asia Electronics Co., Ltd
+0b24  Link Evolution Corp.
+0b27  Ritek Corp.
+0b28  Kenwood Corp.
+0b2c  Village Center, Inc.
+0b30  PNY Technologies, Inc.
+       0006  SM Media-Shuttle Card Reader
+0b33  Contour Design, Inc.
+       0020  ShuttleXpress
+0b37  Hitachi ULSI Systems Co., Ltd
+0b39  Omnidirectional Control Technology, Inc.
+       0109  USB TO Ethernet
+       0421  Serial
+       0801  USB-Parallel Bridge
+       0901  OCT To Fast Ethernet Converter
+       0c03  LAN DOCK Serial Converter
+0b3a  IPaxess
+0b3b  Tekram Technology Co., Ltd
+       0163  TL-WN320G 1.0 WLAN Adapter
+       1601  Allnet 0193 802.11b Adapter
+       1602  ZyXEL ZyAIR B200 802.11b Adapter
+       1612  AIR.Mate 2@net 802.11b Adapter
+       1613  802.11b Wireless LAN Adapter
+       1620  Allnet USB 2.0 Wireless Network Adapter
+       1630  QuickWLAN
+       5630  ZD1211
+       6630  ZD1211
+0b3c  Olivetti Techcenter
+       a010  Simple_Way Printer/Scanner/Copier
+0b3e  Kikusui Electronics Corp.
+0b41  Hal Corp.
+       0011  Crossam2+USB IR commander
+0b43  Play.com, Inc.
+       0003  PS2 Controller Converter
+0b47  Sportbug.com, Inc.
+0b48  TechnoTrend AG
+       1003  Technotrend/Hauppauge USB-Nova
+       1004  TT-PCline
+       1005  Technotrend/Hauppauge USB-Nova
+       1006  Technotrend/Hauppauge DEC3000-s
+       1007  TT-micro plus Device
+       1008  Technotrend/Hauppauge DEC2000-t
+       1009  Technotrend/Hauppauge DEC2540-t
+0b49  ASCII Corp.
+       064f  Trance Vibrator
+0b4b  Pine Corp. Ltd.
+       0100  D'music MP3 Player
+0b4d  Graphtec America, Inc.
+       110a  Graphtec CC200-20
+0b4e  Musical Electronics, Ltd
+       6500  MP3 Player
+       8028  MP3 Player
+       8920  MP3 Player
+0b50  Dumpries Co., Ltd
+0b51  Comfort Keyboard Co.
+       0020  Comfort Keyboard
+0b52  Colorado MicroDisplay, Inc.
+0b54  Sinbon Electronics Co., Ltd
+0b56  TYI Systems, Ltd
+0b57  Beijing HanwangTechnology Co., Ltd
+0b59  Lake Communications, Ltd
+0b5a  Corel Corp.
+0b5f  Green Electronics Co., Ltd
+0b60  Nsine, Ltd
+0b61  NEC Viewtechnology, Ltd
+0b62  Orange Micro, Inc.
+       000b  Bluetooth Device
+       0059  iBOT2 WebCam
+0b63  ADLink Technology, Inc.
+0b64  Wonderful Wire Cable Co., Ltd
+0b65  Expert Magnetics Corp.
+0b69  CacheVision
+0b6a  Maxim Integrated Products
+0b6f  Nagano Japan Radio Co., Ltd
+0b70  PortalPlayer, Inc.
+       00ba  iRiver H10 20GB
+0b71  SHIN-EI Sangyo Co., Ltd
+0b72  Embedded Wireless Technology Co., Ltd
+0b73  Computone Corp.
+0b75  Roland DG Corp.
+0b79  Sunrise Telecom, Inc.
+0b7a  Zeevo, Inc.
+       07d0  Bluetooth Dongle
+0b7b  Taiko Denki Co., Ltd
+0b7c  ITRAN Communications, Ltd
+0b7d  Astrodesign, Inc.
+0b84  Rextron Technology, Inc.
+0b85  Elkat Electronics, Sdn., Bhd.
+0b86  Exputer Systems, Inc.
+       5100  XMC5100 Zippy Drive
+       5110  XMC5110 Flash Drive
+       5200  XMC5200 Zippy Drive
+       5201  XMC5200 Zippy Drive
+       5202  XMC5200 Zippy Drive
+       5280  XMC5280 Storage Drive
+       fff0  ISP5200 Debugger
+0b87  Plus-One I & T, Inc.
+0b88  Sigma Koki Co., Ltd, Technology Center
+0b89  Advanced Digital Broadcast, Ltd
+0b95  ASIX Electronics Corp.
+       1720  10/100 Ethernet
+       1780  AX88178
+       7720  AX88772
+0b96  Sewon Telecom
+0b97  O2 Micro, Inc.
+       7732  Smart Card Reader
+       7761  Oz776 1.1 Hub
+       7762  Oz776 SmartCard Reader
+       7772  OZ776 CCID Smartcard Reader
+0b98  Playmates Toys, Inc.
+0b99  Audio International, Inc.
+0b9b  Dipl.-Ing. Stefan Kunde
+       4012  Reflex RC-controller Interface
+0b9d  Softprotec Co.
+0b9f  Chippo Technologies
+0baf  U.S. Robotics
+       00e5  USR6000
+       00eb  USR1120 802.11b Adapter
+       00ec  56K Faxmodem
+       00f1  SureConnect ADSL ATM Adapter
+       00f2  SureConnect ADSL Loader
+       00f5  SureConnect ADSL ATM Adapter
+       00f6  SureConnect ADSL Loader
+       00f7  SureConnect ADSL ATM Adapter
+       00f8  SureConnect ADSL Loader
+       00f9  SureConnect ADSL ATM Adapter
+       00fa  SureConnect ADSL Loader
+       00fb  SureConnect ADSL Ethernet/USB Router
+       0118  U5 802.11g Adapter
+       011b  Wireless MAXg Adapter
+       0121  USR5423 WLAN
+       6112  FaxModem Model 5633
+0bb0  Concord Camera Corp.
+       0100  Sound Vision Stream
+       5007  3340z/Rollei DC3100
+0bb1  Infinilink Corp.
+0bb2  Ambit Microsystems Corp.
+       0302  WLAN
+       6098  USB Cable Modem
+0bb3  Ofuji Technology
+0bb4  High Tech Computer Corp.
+       00ce  mmO2 XDA GSM/GPRS Pocket PC
+       00cf  SPV C500 Smart Phone
+       0a01  PocketPC Sync
+       0a02  Himalaya GSM/GPRS Pocket PC
+       0a03  PocketPC Sync
+       0a04  PocketPC Sync
+       0a05  PocketPC Sync
+       0a06  PocketPC Sync
+       0a07  Magician PocketPC SmartPhone / O2 XDA
+       0a08  PocketPC Sync
+       0a09  PocketPC Sync
+       0a0a  PocketPC Sync
+       0a0b  PocketPC Sync
+       0a0c  PocketPC Sync
+       0a0d  PocketPC Sync
+       0a0e  PocketPC Sync
+       0a0f  PocketPC Sync
+       0a10  PocketPC Sync
+       0a11  PocketPC Sync
+       0a12  PocketPC Sync
+       0a13  PocketPC Sync
+       0a14  PocketPC Sync
+       0a15  PocketPC Sync
+       0a16  PocketPC Sync
+       0a17  PocketPC Sync
+       0a18  PocketPC Sync
+       0a19  PocketPC Sync
+       0a1a  PocketPC Sync
+       0a1b  PocketPC Sync
+       0a1c  PocketPC Sync
+       0a1d  PocketPC Sync
+       0a1e  PocketPC Sync
+       0a1f  PocketPC Sync
+       0a20  PocketPC Sync
+       0a21  PocketPC Sync
+       0a22  PocketPC Sync
+       0a23  PocketPC Sync
+       0a24  PocketPC Sync
+       0a25  PocketPC Sync
+       0a26  PocketPC Sync
+       0a27  PocketPC Sync
+       0a28  PocketPC Sync
+       0a29  PocketPC Sync
+       0a2a  PocketPC Sync
+       0a2b  PocketPC Sync
+       0a2c  PocketPC Sync
+       0a2d  PocketPC Sync
+       0a2e  PocketPC Sync
+       0a2f  PocketPC Sync
+       0a30  PocketPC Sync
+       0a31  PocketPC Sync
+       0a32  PocketPC Sync
+       0a33  PocketPC Sync
+       0a34  PocketPC Sync
+       0a35  PocketPC Sync
+       0a36  PocketPC Sync
+       0a37  PocketPC Sync
+       0a38  PocketPC Sync
+       0a39  PocketPC Sync
+       0a3a  PocketPC Sync
+       0a3b  PocketPC Sync
+       0a3c  PocketPC Sync
+       0a3d  PocketPC Sync
+       0a3e  PocketPC Sync
+       0a3f  PocketPC Sync
+       0a40  PocketPC Sync
+       0a41  PocketPC Sync
+       0a42  PocketPC Sync
+       0a43  PocketPC Sync
+       0a44  PocketPC Sync
+       0a45  PocketPC Sync
+       0a46  PocketPC Sync
+       0a47  PocketPC Sync
+       0a48  PocketPC Sync
+       0a49  PocketPC Sync
+       0a4a  PocketPC Sync
+       0a4b  PocketPC Sync
+       0a4c  PocketPC Sync
+       0a4d  PocketPC Sync
+       0a4e  PocketPC Sync
+       0a4f  PocketPC Sync
+       0a50  HTC SmartPhone Sync
+       0a51  SPV C400 / T-Mobile SDA GSM/GPRS Pocket PC
+       0a52  SmartPhone Sync
+       0a53  SmartPhone Sync
+       0a54  SmartPhone Sync
+       0a55  SmartPhone Sync
+       0a56  SmartPhone Sync
+       0a57  SmartPhone Sync
+       0a58  SmartPhone Sync
+       0a59  SmartPhone Sync
+       0a5a  SmartPhone Sync
+       0a5b  SmartPhone Sync
+       0a5c  SmartPhone Sync
+       0a5d  SmartPhone Sync
+       0a5e  SmartPhone Sync
+       0a5f  SmartPhone Sync
+       0a60  SmartPhone Sync
+       0a61  SmartPhone Sync
+       0a62  SmartPhone Sync
+       0a63  SmartPhone Sync
+       0a64  SmartPhone Sync
+       0a65  SmartPhone Sync
+       0a66  SmartPhone Sync
+       0a67  SmartPhone Sync
+       0a68  SmartPhone Sync
+       0a69  SmartPhone Sync
+       0a6a  SmartPhone Sync
+       0a6b  SmartPhone Sync
+       0a6c  SmartPhone Sync
+       0a6d  SmartPhone Sync
+       0a6e  SmartPhone Sync
+       0a6f  SmartPhone Sync
+       0a70  SmartPhone Sync
+       0a71  SmartPhone Sync
+       0a72  SmartPhone Sync
+       0a73  SmartPhone Sync
+       0a74  SmartPhone Sync
+       0a75  SmartPhone Sync
+       0a76  SmartPhone Sync
+       0a77  SmartPhone Sync
+       0a78  SmartPhone Sync
+       0a79  SmartPhone Sync
+       0a7a  SmartPhone Sync
+       0a7b  SmartPhone Sync
+       0a7c  SmartPhone Sync
+       0a7d  SmartPhone Sync
+       0a7e  SmartPhone Sync
+       0a7f  SmartPhone Sync
+       0a80  SmartPhone Sync
+       0a81  SmartPhone Sync
+       0a82  SmartPhone Sync
+       0a83  SmartPhone Sync
+       0a84  SmartPhone Sync
+       0a85  SmartPhone Sync
+       0a86  SmartPhone Sync
+       0a87  SmartPhone Sync
+       0a88  SmartPhone Sync
+       0a89  SmartPhone Sync
+       0a8a  SmartPhone Sync
+       0a8b  SmartPhone Sync
+       0a8c  SmartPhone Sync
+       0a8d  SmartPhone Sync
+       0a8e  SmartPhone Sync
+       0a8f  SmartPhone Sync
+       0a90  SmartPhone Sync
+       0a91  SmartPhone Sync
+       0a92  SmartPhone Sync
+       0a93  SmartPhone Sync
+       0a94  SmartPhone Sync
+       0a95  SmartPhone Sync
+       0a96  SmartPhone Sync
+       0a97  SmartPhone Sync
+       0a98  SmartPhone Sync
+       0a99  SmartPhone Sync
+       0a9a  SmartPhone Sync
+       0a9b  SmartPhone Sync
+       0a9c  SmartPhone Sync
+       0a9d  SmartPhone Sync
+       0a9e  SmartPhone Sync
+       0a9f  SmartPhone Sync
+       0b04  Hermes / TyTN / T-Mobile MDA Vario II / O2 Xda Trion
+       0b06  Athena / Advantage x7500 / Dopod U1000 / T-Mobile AMEO
+       0b0c  Elf / Touch / P3450 / T-Mobile MDA Touch / O2 Xda Nova / Dopod S1
+       0bce  Vario MDA
+0bb5  Murata Manufacturing Co., Ltd
+0bb6  Network Alchemy
+0bb7  Joytech Computer Co., Ltd
+0bb8  Hitachi Semiconductor and Devices Sales Co., Ltd
+0bb9  Eiger M&C Co., Ltd
+0bba  ZAccess Systems
+0bbb  General Meters Corp.
+0bbc  Assistive Technology, Inc.
+0bbd  System Connection, Inc.
+0bc0  Knilink Technology, Inc.
+0bc1  Fuw Yng Electronics Co., Ltd
+0bc2  Seagate RSS LLC
+       2000  Storage Adapter V3 (TPP)
+0bc3  IPWireless, Inc.
+0bc4  Microcube Corp.
+0bc5  JCN Co., Ltd
+0bc6  ExWAY, Inc.
+0bc7  X10 Wireless Technology, Inc.
+       0001  ActiveHome (ACPI-compliant)
+       0002  Firecracker Interface (ACPI-compliant)
+       0003  VGA Video Sender (ACPI-compliant)
+       0004  X10 Receiver
+       0005  Wireless Transceiver (ACPI-compliant)
+       0006  Wireless Transceiver (ACPI-compliant)
+       0007  Wireless Transceiver (ACPI-compliant)
+       0008  Wireless Transceiver (ACPI-compliant)
+       0009  Wireless Transceiver (ACPI-compliant)
+       000a  Wireless Transceiver (ACPI-compliant)
+       000b  Transceiver (ACPI-compliant)
+       000c  Transceiver (ACPI-compliant)
+       000d  Transceiver (ACPI-compliant)
+       000e  Transceiver (ACPI-compliant)
+       000f  Transceiver (ACPI-compliant)
+0bc8  Telmax Communications
+0bc9  ECI Telecom, Ltd
+0bca  Startek Engineering, Inc.
+0bcb  Perfect Technic Enterprise Co., Ltd
+0bd7  Andrew Pargeter & Associates
+       a021  Amptek DP4 multichannel signal analyzer
+0bda  Realtek Semiconductor Corp.
+       0103  USB 2.0 Card Reader
+       0104  Mass Storage Device
+       0106  Mass Storage Device
+       0107  Mass Storage Device
+       0108  Mass Storage Device
+       0111  Card Reader
+       0113  Mass Storage Device
+       0115  Mass Storage Device
+       0116  Mass Storage Device
+       0117  Mass Storage Device
+       0118  Mass Storage Device
+       0151  Mass Stroage Device
+       0152  Mass Stroage Device
+       0153  Mass Stroage Device
+       0156  Mass Stroage Device
+       0157  Mass Stroage Device
+       0158  Mass Stroage Device
+       0161  Mass Stroage Device
+       0168  Mass Stroage Device
+       0169  Mass Stroage Device
+       0171  Mass Stroage Device
+       0176  Mass Stroage Device
+       0178  Mass Stroage Device
+       2831  2831U Device
+       8150  RTL8150 Fast Ethernet Adapter
+       8151  RTL8151 Adapteon Business Mobile Networks BV
+       8187  RTL8187 Wireless Adapter
+       8189  RTL8187B Wireless 802.11g 54Mbps Network Adapter
+       8197  RTL8187B Wireless Adapter
+0bdb  Ericsson Business Mobile Networks BV
+       1000  BV Bluetooth Device
+       1002  Bluetooth Device 1.2
+0bdc  Y Media Corp.
+0bdd  Orange PCS
+0be2  Kanda Tsushin Kogyo Co., Ltd
+0be3  TOYO Corp.
+0be4  Elka International, Ltd
+0be5  DOME imaging systems, Inc.
+0be6  Dong Guan Humen Wonderful Wire Cable Factory
+0bee  LTK Industries, Ltd
+0bef  Way2Call Communications
+0bf0  Pace Micro Technology PLC
+0bf1  Intracom S.A.
+       0001  netMod Driver Ver 2.4.17 (CAPI)
+       0002  netMod Driver Ver 2.4 (CAPI)
+       0003  netMod Driver Ver 2.4 (CAPI)
+0bf2  Konexx
+0bf6  Addonics Technologies, Inc.
+       0103  Storage Device
+       1234  Storage Device
+       a000  Cable 205 (TPP)
+       a001  Cable 205
+       a002  IDE Bridge
+0bf7  Sunny Giken, Inc.
+0bf8  Fujitsu Siemens Computers
+       1001  Fujitsu Pocket Loox 600 PDA
+0c04  MOTO Development Group, Inc.
+0c05  Appian Graphics
+0c06  Hasbro Games, Inc.
+0c07  Infinite Data Storage, Ltd
+0c08  Agate
+       0378  Q 16MB Storage Device
+0c09  Comjet Information System
+       a5a5  Litto Version USB2.0
+0c0a  Highpoint Technologies, Inc.
+0c0b  Dura Micro, Inc. (Acomdata)
+       27cb  6-in-1 Flash Reader and Writer
+       27d7  Multi Memory reader/writer MD-005
+       27da  Multi Memory reader/writer MD-005
+       27dc  Multi Memory reader/writer MD-005
+       27e7  3,5'' HDD case MD-231
+       27ee  3,5'' HDD case MD-231
+       2814  3,5'' HDD case MD-231
+       2815  3,5'' HDD case MD-231
+       281d  3,5'' HDD case MD-231
+       a109  CF/SM Reader and Writer
+       a10c  SD/MS Reader and Writer
+       b001  USB 2.0 Mass Storage IDE adapter
+       b004  MMC/SD Reader and Writer
+0c12  Zeroplus
+       0005  PSX Vibration Feedback Converter
+       8809  Red Octane Ignition Xbox DDR Pad
+0c15  Iris Graphics
+0c16  Gyration, Inc.
+       0080  eHome Infrared Receiver
+       0081  eHome Infrared Receiver
+0c17  Cyberboard A/S
+0c18  SynerTek Korea, Inc.
+0c19  cyberPIXIE, Inc.
+0c1a  Silicon Motion, Inc.
+0c1b  MIPS Technologies
+0c1c  Hang Zhou Silan Electronics Co., Ltd
+0c22  Tally Printer Corp.
+0c23  Lernout + Hauspie
+0c24  Taiyo Yuden
+       0001  Bluetooth Adaptor
+       0002  Bluetooth Device2
+       0005  Bluetooth Device(BC04-External)
+       000b  Bluetooth Device(BC04-External)
+       000c  Bluetooth Adaptor
+       000e  Bluetooth Device(BC04-External)
+       000f  Bluetooth Driver (V2.0+EDR)
+       0010  Bluetooth Device(BC04-External)
+       0012  Bluetooth Device(BC04-External)
+       0018  Bluetooth Device(BC04-External)
+       0019  Bluetooth Device
+       0c24  Bluetooth Device(SAMPLE)
+       ffff  Bluetooth module with BlueCore in DFU mode
+0c25  Sampo Corp.
+       0310  Scream Cam
+0c27  RFIDeas, Inc
+       3bfa  pcProx Card Reader
+0c2e  Metro
+       0200  Metrologic Scanner
+0c35  Eagletron, Inc.
+0c36  E Ink Corp.
+0c37  e.Digital
+0c38  Der An Electric Wire & Cable Co., Ltd
+0c39  IFR
+0c3a  Furui Precise Component (Kunshan) Co., Ltd
+0c3b  Komatsu, Ltd
+0c3c  Radius Co., Ltd
+0c3d  Innocom, Inc.
+0c3e  Nextcell, Inc.
+0c44  Motorola iDEN
+       0021  iDEN P2k0 Device
+       0022  iDEN P2k1 Device
+       03a2  iDEN Smartphone
+0c45  Microdia
+       1020  Mass Storage Reader
+       1028  Mass Storage Reader
+       1030  Mass Storage Reader
+       1031  Sonix Mass Storage Device
+       1032  Mass Storage Reader
+       1033  Sonix Mass Storage Device
+       1034  Mass Storage Reader
+       1035  Mass Storage Reader
+       1036  Mass Storage Reader
+       1037  Sonix Mass Storage Device
+       1050  CF Card Reader
+       1058  HDD Reader
+       1060  iFlash SM-Direct Card Reader
+       1061  Mass Storage Reader
+       1062  Mass Storage Reader
+       1063  Sonix Mass Storage Device
+       1064  Mass Storage Reader
+       1065  Mass Storage Reader
+       1066  Mass Storage Reader
+       1067  Mass Storage Reader
+       1158  A56AK
+       184c  VoIP Phone
+       6001  Genius VideoCAM NB
+       6005  Sweex Mini WebCam
+       6007  VideoCAM Eye
+       6009  VideoCAM ExpressII
+       600d  TwinkleCam USB camera
+       6011  PC Camera (SN9C102)
+       6019  PC Camera (SN9C102)
+       6024  VideoCAM ExpressII
+       6025  VideoCAM ExpressII
+       6028  Typhoon Easycam USB 330K (older)
+       6029  Triplex i-mini PC Camera
+       602a  Meade ETX-105EC Camera
+       602b  VideoCAM NB 300
+       602c  Clas Ohlson TWC-30XOP WebCam
+       602d  VideoCAM ExpressII
+       602e  VideoCAM Messenger
+       6030  VideoCAM ExpressII
+       603f  VideoCAM ExpressII
+       6040  CCD PC Camera (PC390A)
+       606a  CCD PC Camera (PC390A)
+       607a  CCD PC Camera (PC390A)
+       607b  Win2 PC Camera
+       607c  CCD PC Camera (PC390A)
+       607e  CCD PC Camera (PC390A)
+       6080  Audio (Microphone)
+       6082  VideoCAM Look
+       6083  VideoCAM Look
+       608c  VideoCAM Look
+       608e  VideoCAM Look
+       608f  VideoCAM Look
+       60a8  VideoCAM Look
+       60aa  VideoCAM Look
+       60ab  PC Camera
+       60af  VideoCAM Look
+       60b0  Genius VideoCam Look
+       60c0  PC Camera with Mic (SN9C105)
+       60c8  Win2 PC Camera
+       60cc  Composite Device
+       60ec  Composite Device
+       60ef  Win2 PC Camera
+       60fa  PC Camera with Mic (SN9C105)
+       60fb  Composite Device
+       60fc  PC Camera with Mic (SN9C105)
+       60fe  Audio (Microphone)
+       6108  Win2 PC Camera
+       6122  PC Camera (SN9C110)
+       6123  PC Camera (SN9C110)
+       612a  PC Camera (SN9C110)
+       612c  PC Camera (SN9C110)
+       612e  PC Camera (SN9C110)
+       612f  PC Camera (SN9C110)
+       6130  PC Camera (SN9C120)
+       6138  Win2 PC Camera
+       613a  PC Camera (SN9C120)
+       613b  Win2 PC Camera
+       613c  PC Camera (SN9C120)
+       613e  PC Camera (SN9C120)
+       6240  PC Camera (SN9C201)
+       6242  PC Camera (SN9C201)
+       6243  PC Camera (SN9C201)
+       6248  PC Camera (SN9C201)
+       624b  PC Camera (SN9C201)
+       624c  PC Camera (SN9C201)
+       624e  PC Camera (SN9C201)
+       624f  PC Camera (SN9C201)
+       6260  PC Camera (SN9C201)
+       6270  U-CAM PC Camera NE878
+       627a  PC Camera (SN9C201)
+       627b  PC Camera (SN9C201)
+       627c  PC Camera (SN9C201)
+       627f  PC Camera (SN9C201)
+       6280  Composite Device
+       6282  Audio (Microphone)
+       6283  Audio (Microphone)
+       6288  Audio (Microphone)
+       628a  Composite Device
+       628b  PC Camera (SN9C202)
+       628c  PC Camera (SN9C202)
+       628e  Composite Device
+       628f  Composite Device
+       62a0  Audio (Microphone)
+       62b0  Audio (Microphone)
+       62ba  PC Camera (SN9C202)
+       62bb  PC Camera (SN9C202)
+       62bc  Composite Device
+       62c0  Pavilion Webcam
+       8000  DC31VC
+       8006  Dual Mode Camera (8006 VGA)
+       800a  Vivitar Vivicam3350B
+0c46  WaveRider Communications, Inc.
+0c4b  Reiner SCT Kartensysteme GmbH
+       0100  cyberJack e-com/pinpad
+       0300  cyberJack pinpad(a)
+0c52  Sealevel Systems, Inc.
+       2101  Serial Converter
+0c53  ViewPLUS, Inc.
+0c54  Glory, Ltd
+0c55  Spectrum Digital, Inc.
+       0510  Spectrum Digital XDS510 JTAG Debugger
+       0540  SPI540
+       5416  TMS320C5416 DSK
+       6416  TMS320C6416 DDB
+0c56  Billion Bright, Ltd
+0c57  Imaginative Design Operation Co., Ltd
+0c58  Vidar Systems Corp.
+0c59  Dong Guan Shinko Wire Co., Ltd
+0c5a  TRS International Mfg., Inc.
+0c5e  Xytronix Research & Design
+0c62  Chant Sincere Co., Ltd
+0c63  Toko, Inc.
+0c64  Signality System Engineering Co., Ltd
+0c65  Eminence Enterprise Co., Ltd
+0c66  Rexon Electronics Corp.
+0c67  Concept Telecom, Ltd
+0c70  MCT Elektronikladen
+       0000  USB08 Development board
+0c74  Optronic Laboratories Inc.
+       0002  OL 700-30 Goniometer
+0c76  JMTek, LLC.
+       0001  Mass Storage Controller
+       0002  Mass Storage Controller
+       0003  USBdisk
+       0004  Mass Storage Controller
+       0005  Transcend USB Flash disk
+       0006  Transcend JetFlash
+       0007  Mass Storage Device
+0c77  Sipix Group, Ltd
+       1001  SiPix Web2
+       1002  SiPix SC2100
+       1010  SiPix Snap
+       1011  SiPix Blink 2
+       1015  SiPix CAMeleon
+0c78  Detto Corp.
+0c79  NuConnex Technologies Pte., Ltd
+0c7a  Wing-Span Enterprise Co., Ltd
+0c86  NDA Technologies, Inc.
+0c88  Kyocera Wireless Corp.
+       0021  Handheld
+       17da  Qualcomm Kyocera CDMA Technologies MSM
+0c89  Honda Tsushin Kogyo Co., Ltd
+0c8a  Pathway Connectivity, Inc.
+0c8b  Wavefly Corp.
+0c8c  Coactive Networks
+0c8d  Tempo
+0c8e  Cesscom Co., Ltd
+       6000  Luxian Series
+0c8f  Applied Microsystems
+0c98  Berkshire Products, Inc.
+       1140  USB PC Watchdog
+0c99  Innochips Co., Ltd
+0c9a  Hanwool Robotics Corp.
+0c9b  Jobin Yvon, Inc.
+0c9d  SemTek
+       0170  3873 Manual Insert card reader
+0ca2  Zyfer
+0ca3  Sega Corp.
+0ca4  ST&T Instrument Corp.
+0ca5  BAE Systems Canada, Inc.
+0ca6  Castles Technology Co., Ltd
+       0010  EZUSB PC/SC Smart Card Reader
+       0050  EZ220PU Reader Controller
+       1077  Bludrive Family Smart Card Reader
+       107e  Reader Controller
+       2010  myPad110 PC/SC Smart Card Reader
+0ca7  Information Systems Laboratories
+0cad  Motorola CGISS
+       9001  PowerPad Pocket PC Device
+0cae  Ascom Business Systems, Ltd
+0caf  Buslink
+       2507  Hi-Speed USB-to-IDE Bridge Controller
+       2515  Flash Disk Embedded Hub
+       2516  Flash Disk Security Device
+       2517  Flash Disk Mass Storage Device
+       25c7  Hi-Speed USB-to-IDE Bridge Controller
+       3a00  Hard Drive
+       3a20  Mass Storage Device
+       3acd  Mass Storage Device
+0cb0  Flying Pig Systems
+0cb1  Innovonics, Inc.
+0cb6  Celestix Networks, Pte., Ltd
+0cb7  Singatron Enterprise Co., Ltd
+0cb8  Opticis Co., Ltd
+0cba  Trust Electronic (Shanghai) Co., Ltd
+0cbb  Shanghai Darong Electronics Co., Ltd
+0cbc  Palmax Technology Co., Ltd
+       0101  Pocket PC P6C
+       0201  Personal Digital Assistant
+       0301  Personal Digital Assistant P6M+
+       0401  Pocket PC
+0cbd  Pentel Co., Ltd (Electronics Equipment Div.)
+0cbe  Keryx Technologies, Inc.
+0cbf  Union Genius Computer Co., Ltd
+0cc0  Kuon Yi Industrial Corp.
+0cc1  Given Imaging, Ltd
+0cc2  Timex Corp.
+0cc3  Rimage Corp.
+0cc4  emsys GmbH
+0cc5  Sendo
+0cc6  Intermagic Corp.
+0cc7  Kontron Medical AG
+0cc8  Technotools Corp.
+0cc9  BroadMAX Technologies, Inc.
+0cca  Amphenol
+0ccb  SKNet Co., Ltd
+0ccc  Domex Technology Corp.
+0ccd  TerraTec Electronic GmbH
+       0012  PHASE 26
+       0013  PHASE 26
+       0014  PHASE 26
+       0015  Flash Update for TerraTec PHASE 26
+       0021  Cameo Grabster 200
+       0023  Mystify Claw
+       0028  Aureon 5.1 MkII
+       0032  MIDI HUBBLE
+       0035  Miditech Play'n Roll
+       0036  Cinergy 250 Audio
+       0037  Cinergy 250 Audio
+       0038  Cinergy T^2 DVB-T Receiver
+       0039  Grabster AV 400
+       003b  Cinergy 400
+       003c  Grabster AV 250
+       0042  Cinergy Hybrid T XS
+       0043  Cinergy T XS
+       004e  Cinergy T XS
+       004f  Cinergy Analog XS
+       005c  Cinergy T²
+       0069  Cinergy T XE DVB-T Receiver
+0cd4  Bang Olufsen
+       0101  BeolinkPC2
+0cd7  NewChip S.r.l.
+0cd8  JS Digitech, Inc.
+       2007  Smart Card Reader/JSTU-9700
+0cd9  Hitachi Shin Din Cable, Ltd
+0cde  Z-Com
+       0001  M4Y-750
+       0002  XI-725/726 Prism2.5 802.11b Adapter
+       0003  Sagem 802.11b Dongle
+       0004  Sagem 802.11b Dongle
+       0005  XI-735 Prism3 802.11b Adapter
+       0006  Medion 40900 802.11b Adapter
+       0008  Sitecom Wireless Network Adapter 100G+ WL-125
+       0009  (ZD1211)IEEE 802.11b+g Adapter
+       0011  ZD1211
+       0012  AR5523
+       0013  AR5523 driver (no firmware)
+       0014  NB 802.11g Wireless LAN Adapter(3887A)
+       0015  Zoom Wireless-G
+       0016  NB 802.11g Wireless LAN Adapter(3887A)
+       0018  NB 802.11a/b/g Wireless LAN Adapter(3887A)
+       001a  ZD1211B
+       001c  802.11b/g Wireless Network Adapter
+       0020  Wi-Fi Wireless LAN Adapter
+       0022  802.11b/g/n Wireless Network Adapter
+0ce9  pico Technology
+       1001  PicoScope3204
+0cf1  e-Conn Electronic Co., Ltd
+0cf2  ENE Technology, Inc.
+0cf3  Atheros Communications, Inc.
+       0001  AR5523
+       0002  AR5523 (no firmware)
+       0003  AR5523
+       0004  AR5523 (no firmware)
+       0005  AR5523
+       0006  AR5523 (no firmware)
+0cf4  Fomtex Corp.
+0cf5  Cellink Co., Ltd
+0cf6  Compucable Corp.
+0cf7  ishoni Networks
+0cf8  Clarisys, Inc.
+       0750  Claritel-i750 - vp
+0cf9  Central System Research Co., Ltd
+0cfa  Inviso, Inc.
+0cfc  Minolta-QMS, Inc.
+0cff  SAFA MEDIA Co., Ltd.
+       0320  SR-380N
+0d06  telos EDV Systementwicklung GmbH
+0d08  UTStarcom
+       0602  DV007 [serial]
+       0603  DV007 [storage]
+0d0b  Contemporary Controls
+0d0c  Astron Electronics Co., Ltd
+0d0d  MKNet Corp.
+0d0e  Hybrid Networks, Inc.
+0d0f  Feng Shin Cable Co., Ltd
+0d10  Elastic Networks
+       0001  StormPort (WDM)
+0d11  Maspro Denkoh Corp.
+0d12  Hansol Electronics, Inc.
+0d13  BMF Corp.
+0d14  Array Comm, Inc.
+0d15  OnStream b.v.
+0d16  Hi-Touch Imaging Technologies Co., Ltd
+       0001  PhotoShuttle
+       0002  Photo Printer 730 series
+       0004  Photo Printer 63xPL/PS
+       0100  Photo Printer 63xPL/PS
+       0102  Photo Printer 64xPS
+       0103  Photo Printer 730 series
+       0104  Photo Printer 63xPL/PS
+       0105  Photo Printer 64xPS
+       0200  Photo Printer 64xDL
+0d17  NALTEC, Inc.
+0d18  coaXmedia
+0d19  Hank Connection Industrial Co., Ltd
+0d32  Leo Hui Electric Wire & Cable Co., Ltd
+0d33  AirSpeak, Inc.
+0d34  Rearden Steel Technologies
+0d35  Dah Kun Co., Ltd
+0d3a  Posiflex Technologies, Inc.
+0d3c  Sri Cable Technology, Ltd
+0d3d  Tangtop Technology Co., Ltd
+       0001  HID Keyboard
+0d3e  Fitcom, inc.
+0d3f  MTS Systems Corp.
+0d40  Ascor, Inc.
+0d41  Ta Yun Terminals Industrial Co., Ltd
+0d42  Full Der Co., Ltd
+0d46  Kobil Systems GmbH
+       2012  KAAN Standard Plus (Smartcard reader)
+       3003  mIDentity Light / KAAN SIM III
+       4000  mIDentity (mass storage)
+       4001  mIDentity Basic/Classic (composite device)
+       4081  mIDentity Basic/Classic (installationless)
+0d49  Maxtor
+       3000  Drive
+       3010  3000LE Drive
+       3100  Hi-Speed USB-IDE Bridge Controller
+       5000  5000XT Drive
+       5010  5000LE Drive
+       5020  Mobile Hard Disk Drive
+       7000  OneTouch
+       7010  OneTouch
+0d4a  NF Corp.
+0d4b  Grape Systems, Inc.
+0d4c  Tedas AG
+0d4d  Coherent, Inc.
+0d4e  Agere Systems Netherland BV
+       047a  WLAN Card
+       1000  Wireless Card Model 0801
+       1001  Wireless Card Model 0802
+0d4f  EADS Airbus France
+0d50  Cleware GmbH
+       0011  USB-Temp2 Thermometer
+0d51  Volex (Asia) Pte., Ltd
+0d53  HMI Co., Ltd
+0d54  Holon Corp.
+0d55  ASKA Technologies, Inc.
+0d56  AVLAB Technology, Inc.
+0d57  Solomon Microtech, Ltd
+0d5c  Belkin
+       a002  F5D6050 802.11b Adapter
+0d5e  Myacom, Ltd
+       2346  BT Digital Access adapter
+0d5f  CSI, Inc.
+0d60  IVL Technologies, Ltd
+0d61  Meilu Electronics (Shenzhen) Co., Ltd
+0d62  Darfon Electronics Corp.
+       0003  Smartcard Reader
+       0004  Filter Driver
+       0306  M530 Mouse
+       0800  Magic Wheel
+       2021  AM805 Keyboard
+       2026  TECOM Bluetooth Device
+       a100  Benq Mouse
+0d63  Fritz Gegauf AG
+0d64  DXG Technology Corp.
+       0105  Dual Mode Digital Camera 1.3M
+       0107  Horus MT-409 Camera
+       0108  Dual Mode Digital Camera
+       0202  Dual Mode Video Camera Device
+       0303  DXG-305V Camera
+       1001  SiPix Stylecam/UMAX AstraPix 320s
+       1002  Fashion Cam 01 Dual-Mode DSC (Video Camera)
+       1003  Fashion Cam Dual-Mode DSC (Controller)
+       1021  D-Link DSC 350F
+       1208  Dual Mode Still Camera Device
+       2208  Mass Storage
+       3105  Dual Mode Digital Camera Disk
+       3108  Digicam Mass Storage Device
+0d65  KMJP Co., Ltd
+0d66  TMT
+0d67  Advanet, Inc.
+0d68  Super Link Electronics Co., Ltd
+0d69  NSI
+0d6a  Megapower International Corp.
+0d6b  And-Or Logic
+0d70  Try Computer Co., Ltd
+0d71  Hirakawa Hewtech Corp.
+0d72  Winmate Communication, Inc.
+0d73  Hit's Communications, Inc.
+0d76  MFP Korea, Inc.
+0d77  Power Sentry/Newpoint
+0d78  Japan Distributor Corp.
+0d7a  MARX Datentechnik GmbH
+0d7b  Wellco Technology Co., Ltd
+0d7c  Taiwan Line Tek Electronic Co., Ltd
+0d7d  Phison Electronics Corp.
+       0100  PS1001/1011/1006/1026 Flash Disk
+       0110  Gigabyte FlexDrive
+       0120  Disk Pro 64MB
+       0124  GIGABYTE Disk
+       0240  I/O-Magic/Transcend 6-in-1 Card Reader
+       110e  NEC uPD720121/130 USB-ATA/ATAPI Bridge
+       1240  Apacer 6-in-1 Card Reader 2.0
+       1270  Wolverine SixPac 6000
+       1300  Flash Disk
+       1320  PS2031 Flash Disk
+       1400  Attache 256MB USB 2.0 Flash Drive
+       1420  PS2044 Pen Drive
+       1470  Vosonic X's-Drive II+ VP2160
+       1900  USB Thumb Drive
+0d7e  American Computer & Digital Components
+       2507  Hi-Speed USB-to-IDE Bridge Controller
+       2517  Hi-Speed Mass Storage Device
+       25c7  Hi-Speed USB-to-IDE Bridge Controller
+0d7f  Essential Reality LLC
+0d80  H.R. Silvine Electronics, Inc.
+0d81  TechnoVision
+0d83  Think Outside, Inc.
+0d89  Oz Software
+0d8a  King Jim Co., Ltd
+       0101  TEPRA PRO
+0d8b  Ascom Telecommunications, Ltd
+0d8c  C-Media Electronics, Inc.
+       0001  Audio Device
+       0002  Composite Device
+       0003  Sound Device
+       0006  Storm HP-USB500 5.1 Headset
+       000c  Audio Adapter
+       000d  Composite Device
+       000e  Audio Adapter (Planet UP-100, Genius G-Talk)
+       0102  CM106 Like Sound Device
+       0103  Turtle Beach Audio Advantage Micro
+       0201  CM6501
+       5000  Mass Storage Controller
+       5200  Mass Storage Controller(0D8C,5200)
+       b213  USB Phone CM109 (aka CT2000,VPT1000)
+0d8d  Promotion & Display Technology, Ltd
+       0234  V-234 Composite Device
+       0550  V-550 Composite Device
+       0551  V-551 Composite Device
+       0552  V-552 Composite Device
+       0651  V-651 Composite Device
+       0652  V-652 Composite Device
+       0653  V-653 Composite Device
+       0654  V-654 Composite Device
+       0655  V-655 Composite Device
+       0656  V-656 Composite Device
+       0657  V-657 Composite Device
+       0658  V-658 Composite Device
+       0659  V-659 Composite Device
+       0660  V-660 Composite Device
+       0661  V-661 Composite Device
+       0662  V-662 Composite Device
+       0850  V-850 Composite Device
+       0851  V-851 Composite Device
+       0852  V-852 Composite Device
+       0901  V-901 Composite Device
+       0902  V-902 Composite Device
+       0903  V-903 Composite Device
+       4754  Voyager DMP Composite Device
+       bb00  Bloomberg Composite Device
+       bb01  Bloomberg Composite Device
+       bb02  Bloomberg Composite Device
+       bb03  Bloomberg Composite Device
+       bb04  Bloomberg Composite Device
+       bb05  Bloomberg Composite Device
+       fffe  Global Tuner Composite Device
+       ffff  Voyager DMP Composite Device
+0d8e  Global Sun Technology, Inc.
+       0163  802.11g 54 Mbps Wireless Dongle
+       1621  802.11b Wireless Adapter
+       3762  802.11g Wireless Mini adapter
+       3763  802.11g Wireless dongle
+       7100  802.11b Adapter
+       7110  WL-210
+       7801  AR5523
+       7802  AR5523 (no firmware)
+       7811  AR5523
+       7812  AR5523 (no firmware)
+       7a01  PRISM25 802.11b Adapter
+0d8f  Pitney Bowes
+0d90  Sure-Fire Electrical Corp.
+0d96  Skanhex Technology, Inc.
+       0000  Jenoptik JD350 video
+       3300  SX330z Camera
+       4100  SX410z Camera
+       4102  MD 9700 Camera
+       4104  Jenoptik JD-4100z3s
+       410a  Medion 9801/Novatech SX-410z
+       5200  SX-520z Camera
+0d97  Santa Barbara Instrument Group
+       0001  SBIG Astronomy Camera (without firmware)
+       0101  SBIG Astronomy Camera (with firmware)
+0d98  Mars Semiconductor Corp.
+       0300  Avaya Wireless Card
+0d99  Trazer Technologies, Inc.
+0d9a  RTX Telecom AS
+       0001  Bluetooth Device
+0d9b  Tat Shing Electrical Co.
+0d9c  Chee Chen Hi-Technology Co., Ltd
+0d9d  Sanwa Supply, Inc.
+0d9e  Avaya
+       0300  Wireless Card
+0d9f  Powercom Co., Ltd
+0da0  Danger Research
+0da1  Suzhou Peter's Precise Industrial Co., Ltd
+0da2  Land Instruments International, Ltd
+0da3  Nippon Electro-Sensory Devices Corp.
+0da4  Polar Electro OY
+       0001  Interface
+0da7  IOGear, Inc.
+0da8  softDSP Co., Ltd
+       0001  SDS 200A Oscilloscope
+0dab  Cubig Group
+       0100  DVR/CVR-M140 MP3 Player
+0dad  Westover Scientific
+0db0  Micro Star International
+       1020  PC2PC WLAN Card
+       1967  Bluetooth Dongle
+       4011  Medion Flash XL V2.0 Card Reader
+       4600  802.11b/g Turbo Wireless Adapter
+       5501  Mass Storage Device
+       5502  Mass Storage Device
+       5513  MP3 Player
+       5515  MP3 Player
+       5516  MP3 Player
+       6823  UB11B/MS-6823 802.11b Wi-Fi adapter
+       6826  IEEE 802.11g Wireless Network Adapter
+       6855  Bluetooth Device
+       6861  MSI-6861 802.11g WiFi adapter
+       6865  RT2570
+       6869  RT2570
+       6874  RT2573
+       6877  RT2573
+       6881  Bluetooth Class I EDR Device
+       688a  Bluetooth Class I EDR Device
+       6970  Bluetooth adapter
+       697a  Bluetooth Dongle
+       6982  Medion Flash XL Card Reader
+       a861  RT2573
+       a874  RT2573
+       a970  Bluetooth dongle
+       a97a  Bluetooth EDR Device
+       b970  Bluetooth EDR Device
+       b97a  Bluetooth EDR Device
+0db1  Wen Te Electronics Co., Ltd
+0db2  Shian Hwi Plug Parts, Plastic Factory
+0db3  Tekram Technology Co., Ltd
+0db4  Chung Fu Chen Yeh Enterprise Corp.
+0db7  ELCON Systemtechnik
+       0002  Goldpfeil P-LAN
+0dbe  Jiuh Shiuh Precision Industry Co., Ltd
+0dbf  Quik Tech Solutions
+       0002  SmartDongle Security Key
+       0200  HDD Storage Solution
+       021b  USB-2.0 IDE Adapter
+       0300  Storage Adapter
+       0333  Storage Adapter
+       0707  ZIV Drive
+0dc0  Great Notions
+0dc1  Tamagawa Seiki Co., Ltd
+0dc3  Athena Smartcard Solutions, Inc.
+       0801  ASEDrive III
+       0802  ASEDrive IIIe
+       1104  ASEDrive IIIe KB
+       1701  ASEKey
+       1702  ASEKey
+0dc4  Macpower Peripherals, Ltd
+       0040  Mass Storage Device
+       0041  Mass Storage Device
+       0042  Mass Storage Device
+       0101  Hi-Speed Mass Storage Device
+0dc5  SDK Co., Ltd
+0dc6  Precision Squared Technology Corp.
+0dc7  First Cable Line, Inc.
+0dcd  NetworkFab Corp.
+       0001  Remote Interface Adapter
+       0002  High Bandwidth Codec
+0dd0  Access Solutions
+       1002  Triple Talk Speech Synthesizer
+0dd1  Contek Electronics Co., Ltd
+0dd2  Power Quotient International Co., Ltd
+       0003  Mass Storage (P)
+0dd3  MediaQ
+0dd4  Custom Engineering SPA
+0dd5  California Micro Devices
+0dd7  Kocom Co., Ltd
+0dd8  Netac Technology Co., Ltd
+       1060  USB-CF-Card
+       e007  OnlyDisk U222 Pendrive
+0dd9  HighSpeed Surfing
+0dda  Integrated Circuit Solution, Inc.
+       0001  Multi-Card Reader 6in1
+       0002  Multi-Card Reader 7in1
+       0003  Flash Disk
+       0005  Internal Multi-Card Reader 6in1
+       0008  SD single card reader
+       0009  MS single card reader
+       000a  MS+SD Dual Card Reader
+       000b  SM single card reader
+       0101  All-In-One Card Reader
+       0102  All-In-One Card Reader
+       0301  MP3 Player
+       0302  Multi-Card MP3 Player
+       1001  Multi-Flash Disk
+       2001  Multi-Card Reader
+       2002  Q018 default PID
+       2003  Multi-Card Reader
+       2005  Datalux DLX-1611 16in1 Card Reader
+       2006  All-In-One Card Reader
+       2007  USB to ATAPI bridge
+       2008  All-In-One Card Reader
+       2013  SD/MS Combo Card Reader
+       2014  SD/MS Single Card Reader
+       2023  card reader SD/MS DEMO board with ICSI brand name (MaskROM version)
+       2024  card reader SD/MS DEMO board with Generic brand name (MaskROM version)
+       2026  USB2.0 Card Reader
+       2027  USB 2.0 Card Reader
+       2315  UFD MP3 player (model 2)
+       2318  UFD MP3 player (model 1)
+       2321  UFD MP3 player
+0ddb  Tamarack, Inc.
+0ddd  Datelink Technology Co., Ltd
+0dde  Ubicom, Inc.
+0de0  BD Consumer Healthcare
+0dea  UTECH Electronic (D.G.) Co., Ltd.
+0ded  Novasonics
+0dee  Lifetime Memory Products
+       4010  Storage Adapter
+0def  Full Rise Electronic Co., Ltd
+0df6  Sitecom Europe B.V.
+       0001  C-Media VOIP Device
+       0004  Bluetooth 2.0 Adapter 100m
+       0007  Bluetooth 2.0 Adapter 10m
+       000b  Bluetooth 2.0.USB Adapter DFU
+       000d  WL-168 Wireless Network Adapter 54g
+       0017  WL-182
+       0019  Bluetooth 2.0 adapter 10m CN-512v2 001
+       001a  Bluetooth 2.0 adapter 100m CN-521v2 001
+       061c  LN-028
+       21f4  44 St Bluetooth Device
+       2200  Sitecom bluetooth2.0 class 2 dongle CN-512
+       2208  Sitecom bluetooth2.0 class 2 dongle CN-520
+       2209  Sitecom bluetooth2.0 class 1 dongle CN-521
+       9071  zd1211 802.11g Adapter
+       9075  ZD1211B
+       90ac  WL-172
+       9712  WL-113 rev 2
+0df7  Mobile Action Technology, Inc.
+       0620  MA-620 Infrared Adapter
+       0700  MA-700 Bluetooth Adapter
+       0720  MA-720 Bluetooth Adapter
+       0722  Bluetooth Dongle
+       0800  Data Cable
+       0820  Data Cable
+       1800  Generic Card Reader
+       1802  Card Reader
+0dfa  Toyo Communication Equipment Co., Ltd
+0dfc  GeneralTouch Technology Co., Ltd
+       0001  Touchscreen
+0e03  Nippon Systemware Co., Ltd
+0e08  Winbest Technology Co., Ltd
+0e0c  Gesytec
+       0101  LonUSB LonTalk Network Adapter
+0e16  JMTek, LLC
+0e17  Walex Electronic, Ltd
+0e1b  Crewave
+0e21  Cowon Systems, Inc.
+       0300  iAudio CW200
+       0400  MP3 Player
+       0510  iAudio X5
+       0513  iAudio X5, side USB port
+       0520  iAudio M5
+       0700  iAudio U3
+0e22  Symbian Ltd.
+0e23  Liou Yuane Enterprise Co., Ltd
+0e25  VinChip Systems, Inc.
+0e26  J-Phone East Co., Ltd
+0e30  HeartMath LLC
+0e34  Micro Computer Control Corp.
+0e35  3Pea Technologies, Inc.
+0e36  TiePie engineering
+       0008  Handyscope HS3
+       0009  Handyscope HS3 (br)
+       000a  Handyscope HS4
+       000b  Handyscope HS4 (br)
+       000e  Handyscope HS4 Diff
+       000f  Handyscope HS4 Diff (br)
+       0010  Handyscope HS2
+       0018  Handyprobe HP2
+       0042  TiePieSCOPE HS801
+       00fd  USB To Parallel adapter
+       00fe  USB To Parallel adapter
+0e38  Stratitec, Inc.
+0e39  Smart Modular Technologies, Inc.
+       0137  Bluetooth Device
+0e3a  Neostar Technology Co., Ltd
+       1100  CW-1100 Wireless Network Adapter
+0e3b  Mansella, Ltd
+0e41  Line6, Inc.
+       4250  BassPODxt
+       4252  BassPODxt Pro
+       4642  BassPODxt Live
+       4650  PODxt Live
+       4750  GuitarPort
+       5044  PODxt
+       5050  PODxt Pro
+       534d  SeaMonkey
+0e44  Sun-Riseful Technology Co., Ltd.
+0e48  Julia Corp., Ltd
+       0100  CardPro SmartCard Reader
+0e4a  Shenzhen Bao Hing Electric Wire & Cable Mfr. Co.
+0e4c  Radica Games, Ltd
+0e55  Speed Dragon Multimedia, Ltd
+       110b  MS3303H USB-to-Serial Bridge
+0e56  Kingston Technology Company, Inc.
+       6021  K-PEX 100
+0e5a  Active Co., Ltd
+0e5b  Union Power Information Industrial Co., Ltd
+0e5c  Bitland Information Technology Co., Ltd
+       6118  LCD Device
+       6119  remote receive and control device
+       6441  C-Media Sound Device
+0e5d  Neltron Industrial Co., Ltd
+0e66  Hawking
+       400b  UF100 10/100 Network Adapter
+       400c  UF100 Ethernet [pegasus2]
+0e67  Fossil, Inc.
+       0002  Wrist PDA
+0e6a  Megawin Technology Co., Ltd
+0e70  Tokyo Electronic Industry Co., Ltd
+0e72  Hsi-Chin Electronics Co., Ltd
+0e75  TVS Electronics, Ltd
+0e79  Archos, Inc.
+       1106  Pocket Medai Assistant - PMA400
+0e7b  On-Tech Industry Co., Ltd
+0e7e  Gmate, Inc.
+       0001  Yopy 3000 PDA
+       1001  YP3X00 PDA
+0e82  Ching Tai Electric Wire & Cable Co., Ltd
+0e83  Shin An Wire & Cable Co.
+0e8c  Well Force Electronic Co., Ltd
+0e8d  MediaTek Inc.
+0e8f  GreenAsia Inc.
+       0012  Joystick
+0e90  WiebeTech, LLC
+       0100  Storage Adapter V1
+0e91  VTech Engineering Canada, Ltd
+0e92  C's Glory Enterprise Co., Ltd
+0e93  eM Technics Co., Ltd
+0e95  Future Technology Co., Ltd
+0e96  Aplux Communications, Ltd
+       c001  TRUST 380 USB2 SPACEC@M
+0e97  Fingerworks, Inc.
+0e98  Advanced Analogic Technologies, Inc.
+0e99  Parallel Dice Co., Ltd
+0e9a  TA HSING Industries, Ltd
+0e9b  ADTEC Corp.
+0e9c  Streamzap, Inc.
+       0000  Streamzap Remote Control
+0e9f  Tamura Corp.
+0ea0  Ours Technology, Inc.
+       2126  7-in-1 Card Reader
+       2168  Transcend JetFlash 2.0 / Astone USB Drive
+       6803  OTI-6803 Flash Disk
+       6808  OTI-6808 Flash Disk
+       6828  OTI-6828 Flash Disk
+0ea6  Nihon Computer Co., Ltd
+0ea7  MSL Enterprises Corp.
+0ea8  CenDyne, Inc.
+0ead  Humax Co., Ltd
+0eb0  NovaTech
+       9020  NovaTech NV-902W
+       9021  RT2573
+0eb1  WIS Technologies, Inc.
+       6666  WinFast WalkieTV TV Loader
+       6668  WinFast WalkieTV TV Loader
+       7007  WinFast WalkieTV WDM Capture
+0eb2  Y-S Electronic Co., Ltd
+0eb3  Saint Technology Corp.
+0eb7  Endor AG
+0ebe  VWeb Corp.
+0ebf  Omega Technology of Taiwan, Inc.
+0ec0  LHI Technology (China) Co., Ltd
+0ec1  Abit Computer Corp.
+0ec2  Sweetray Industrial, Ltd
+0ec3  Axell Co., Ltd
+0ec4  Ballracing Developments, Ltd
+0ec5  GT Information System Co., Ltd
+0ec6  InnoVISION Multimedia, Ltd
+0ec7  Theta Link Corp.
+       1008  So., Show 301 Digital Camera
+0ecd  Lite-On IT Corp.
+       1400  CD\RW 40X
+0ece  TaiSol Electronics Co., Ltd
+0ecf  Phogenix Imaging, LLC
+0ed1  WinMaxGroup
+       6660  USB Flash Disk 64M-C
+       6680  USB Flash Disk 64M-B
+       7634  MP3 Player
+0ed2  Kyoto Micro Computer Co., Ltd
+0ed3  Wing-Tech Enterprise Co., Ltd
+0ed5  Fiberbyte
+       e000  USB-inSync Device
+       f000  Fiberbyte USB-inSync Device
+       f201  Fiberbyte USB-inSync DAQ-2500X
+0eda  Noriake Itron Corp.
+0edf  e-MDT Co., Ltd
+       2060  FID irock! 100 Series
+0ee0  Shima Seiki Mfg., Ltd
+0ee1  Sarotech Co., Ltd
+0ee2  AMI Semiconductor, Inc.
+0ee3  ComTrue Technology Corp.
+       1000  Image Tank 1.5
+0ee4  Sunrich Technology, Ltd
+0eee  Digital Stream Technology, Inc.
+       8810  Mass Storage Drive
+0eef  D-WAV Scientific Co., Ltd
+       0001  eGalax TouchScreen
+       0002  Touchscreen Controller(Professional)
+0ef0  Hitachi Cable, Ltd
+0ef1  Aichi Micro Intelligent Corp.
+0ef2  I/O Magic Corp.
+0ef3  Lynn Products, Inc.
+0ef4  DSI Datotech
+0ef5  PointChips
+       2202  Flash Disk
+       2366  Flash Disk
+0ef6  Yield Microelectronics Corp.
+0ef7  SM Tech Co., Ltd (Tulip)
+0efd  Oasis Semiconductor
+0efe  Wem Technology, Inc.
+0f06  Visual Frontier Enterprise Co., Ltd
+0f08  CSL Wire & Plug (Shen Zhen) Co.
+0f0c  CAS Corp.
+0f0d  Hori Co., Ltd
+0f0e  Energy Full Corp.
+0f12  Mars Engineering Corp.
+0f13  Acetek Technology Co., Ltd
+0f19  Oracom Co., Ltd
+0f1b  Onset Computer Corp.
+0f1c  Funai Electric Co., Ltd
+0f1d  Iwill Corp.
+0f21  IOI Technology Corp.
+0f22  Senior Industries, Inc.
+0f23  Leader Tech Manufacturer Co., Ltd
+0f24  Flex-P Industries, Snd., Bhd.
+0f2d  ViPower, Inc.
+0f2e  Geniality Maple Technology Co., Ltd
+0f2f  Priva Design Services
+0f30  Jess Technology Co., Ltd
+       001c  PS3 Guitar Controller Dongle
+       0110  10-Button Joypad
+0f31  Chrysalis Development
+0f32  YFC-BonEagle Electric Co., Ltd
+0f37  Kokuyo Co., Ltd
+0f38  Nien-Yi Industrial Corp.
+0f3d  Airprime, Incorporated
+       0112  CDMA 1xEVDO PC Card, PC 5220
+0f41  RDC Semiconductor Co., Ltd
+0f42  Nital Consulting Services, Inc.
+0f44  Polhemus
+       ef11  Patriot (firmware not loaded)
+       ef12  Patriot
+       ff11  Liberty (firmware not loaded)
+       ff12  Liberty
+0f4b  St. John Technology Co., Ltd
+0f4c  WorldWide Cable Opto Corp.
+0f4d  Microtune, Inc.
+       1000  Bluetooth Dongle
+0f4e  Freedom Scientific
+0f52  Wing Key Electrical Co., Ltd
+0f53  Dongguan White Horse Cable Factory, Ltd
+0f54  Kawai Musical Instruments Mfg. Co., Ltd
+0f55  AmbiCom, Inc.
+0f5c  Prairiecomm, Inc.
+0f5d  NewAge International, LLC
+       9455  Compact Drive
+0f5f  Key Technology Corp.
+0f60  NTK, Ltd
+0f61  Varian, Inc.
+0f62  Acrox Technologies Co., Ltd
+       1001  Targus Mini Trackball Optical Mouse
+0f68  Kobe Steel, Ltd
+0f69  Dionex Corp.
+0f6a  Vibren Technologies, Inc.
+0f6e  INTELLIGENT SYSTEMS
+       0100  GameBoy Color Emulator
+       0201  GameBoy Advance Flash Gang Writer
+       0202  GameBoy Advance Capture
+       0300  Gamecube DOL Viewer
+       0400  NDS Emulator
+       0401  NDS UIC
+       0402  NDS Writer
+       0403  NDS Capture
+       0404  NDS Emulator (Lite)
+0f73  DFI
+0f7c  DQ Technology, Inc.
+0f7d  NetBotz, Inc.
+0f7e  Fluke Corp.
+0f88  VTech Holdings, Ltd
+       3012  RT2570
+       3014  ZD1211B
+0f8b  Yazaki Corp.
+0f8c  Young Generation International Corp.
+0f8d  Uniwill Computer Corp.
+0f8e  Kingnet Technology Co., Ltd
+0f8f  Soma Networks
+0f97  CviLux Corp.
+0f98  CyberBank Corp.
+0f9c  Hyun Won, Inc.
+       0301  M-Any Premium DAH-610 MP3/WMA Player
+       0332  mobiBLU DAH-1200 MP3/Ogg Player
+0f9e  Lucent Technologies
+0fa3  Starconn Electronic Co., Ltd
+0fa4  ATL Technology
+0fa5  Sotec Co., Ltd
+0fa7  Epox Computer Co., Ltd
+0fa8  Logic Controls, Inc.
+0faf  Winpoint Electronic Corp.
+0fb0  Haurtian Wire & Cable Co., Ltd
+0fb1  Inclose Design, Inc.
+0fb2  Juan-Chern Industrial Co., Ltd
+0fb8  Wistron Corp.
+       0002  eHome Infrared Receiver
+0fb9  AACom Corp.
+0fba  San Shing Electronics Co., Ltd
+0fbb  Bitwise Systems, Inc.
+0fc1  Mitac Internatinal Corp.
+0fc2  Plug and Jack Industrial, Inc.
+0fc5  Delcom Engineering
+       1222  I/O Development Board
+0fc6  Dataplus Supplies, Inc.
+0fca  Research In Motion, Ltd.
+       0001  Blackberry Handheld
+0fce  Sony Ericsson Mobile Communications AB
+       1010  WMC Modem
+       d008  V800-Vodafone 802SE WMC Modem
+       d016  K750i Phone
+       d017  K608i Phone
+       d019  VDC EGPRS Modem
+       d025  520 WMC Data Modem
+       d038  W850i Phone
+       d041  K510i Phone
+       d042  W810i Phone
+       d046  K610i Phone
+0fcf  Dynastream Innovations, Inc.
+0fd0  Tulip Computers B.V.
+0fd1  Giant Electronics Ltd.
+0fd4  Tenovis GmbH & Co., KG
+0fd5  Direct Access Technology, Inc.
+0fdc  Micro Plus
+0fe4  IN-Tech Electronics, Ltd
+0fe5  Greenconn (U.S.A.), Inc.
+0fe9  DVICO
+       db00  FusionHDTV DVB-T (MT352+LgZ201) (uninitialized)
+       db01  FusionHDTV DVB-T (MT352+LgZ201) (initialized)
+       db10  FusionHDTV DVB-T (MT352+Thomson7579) (uninitialized)
+       db11  FusionHDTV DVB-T (MT352+Thomson7579) (initialized)
+0fea  United Computer Accessories
+0feb  CRS Electronic Co., Ltd
+0fec  UMC Electronics Co., Ltd
+0fed  Access Co., Ltd
+0fee  Xsido Corp.
+0fef  MJ Research, Inc.
+0ff6  Core Valley Co., Ltd
+0ff7  CHI SHING Computer Accessories Co., Ltd
+0fff  Aopen, Inc.
+1000  Speed Tech Corp.
+1001  Ritronics Components (S) Pte., Ltd
+1003  Sigma Corp.
+       0100  Sigma SD10
+1004  LG Electronics, Inc.
+       1fae  U8120 3G Cellphone
+       6000  VX4400/VX6000 Cellphone
+       6005  T5100
+       6800  CDMA Modem
+       7000  LG LDP-7024D(LD)USB
+1005  Apacer Technology, Inc.
+       1001  MP3 Player
+       1004  MP3 Player
+       1006  MP3 Player
+       b113  Handy Steno 2.0/HT203
+       b223  CD-RW + 6 in 1 Card Reader Digital Storage / Converter
+1006  iRiver, Ltd.
+       3001  iHP-100
+       3002  iHP-120/140 MP3 Player
+       3003  H320/H340
+       3004  H340 (mtp)
+1009  Emuzed, Inc.
+       000e  eHome Infrared Receiver
+       0013  Angel MPEG Device
+       0015  Lumanate Wave PAL SECAM DVBT Device
+       0016  Lumanate Wave NTSC/ATSC Combo Device
+100a  AV Chaseway, Ltd
+       2402  MP3 Player
+       2404  MP3 Player
+       2405  MP3 Player
+       2406  MP3 Player
+       a0c0  MP3 Player
+100b  Chou Chin Industrial Co., Ltd
+100d  Netopia, Inc.
+       3342  Cayman 3352 DSL Modem
+       3382  3380 Series Network Interface
+       cb01  Cayman 3341 Ethernet DSL Router
+1010  Fukuda Denshi Co., Ltd
+1011  Mobile Media Tech.
+       0001  AccFast Mp3
+1012  SDKM Fibres, Wires & Cables Berhad
+1013  TST-Touchless Sensor Technology AG
+1014  Densitron Technologies PLC
+1015  Softronics Pty., Ltd
+1016  Xiamen Hung's Enterprise Co., Ltd
+1017  Speedy Industrial Supplies, Pte., Ltd
+1019  Elitegroup Computer Systems (ECS)
+       0c55  USB Flash Reader, Desknote UCR-61S2B
+1020  Labtec
+       000a  Wireless Optical Mouse
+1022  Shinko Shoji Co., Ltd
+1025  Hyper-Paltek
+       005e  USB DVB-T device
+       005f  USB DVB-T device
+       0300  MP3 Player
+       0350  MP3 Player
+1026  Newly Corp.
+1027  Time Domain
+1028  Inovys Corp.
+1029  Atlantic Coast Telesys
+102a  Ramos Technology Co., Ltd
+102b  Infotronic America, Inc.
+102c  Etoms Electronics Corp.
+       6251  Q-Cam
+102d  Winic Corp.
+1031  Comax Technology, Inc.
+1032  C-One Technology Corp.
+1033  Nucam Corp.
+       0068  3,5'' HDD case MD-231
+1038  Ideazon, Inc.
+       0100  Zboard
+1039  devolo AG
+       2140  dsl+ 1100 duo
+103d  Stanton
+       0100  ScratchAmp
+       0101  ScratchAmp
+1043  iCreate Technologies Corp.
+       160f  Wireless Network Adapter
+       4901  AV-836 Video Capture Device
+       8006  Flash Disk 32-256 MB
+1044  Chu Yuen Enterprise Co., Ltd
+       7001  U7000 TV tuner device
+       8001  GN-54G
+       8002  GN-BR402W
+       8003  GN-WLBM101
+       8004  GN-WLBZ101 802.11b Adapter
+       8005  GN-WLBZ201 802.11b Adapter
+       8006  GN-WBZB-M 802.11b Adapter
+       8007  GN-WBKG
+       8008  GN-WB01GS
+       800a  GN-WI05GS
+       800b  GN-WB30N 802.11n WLAN Card
+1046  Winbond Electronics Corp. [hex]
+       8901  Bluetooth Device
+       9967  W9967CF/W9968CF WebCam IC
+1048  Targus Group International
+104c  AMCO TEC International, Inc.
+1053  Immanuel Electronics Co., Ltd
+1054  BMS International Beheer N.V.
+       5004  DSL 7420 Loader
+       5005  DSL 7420 LAN Modem
+1055  Complex Micro Interconnection Co., Ltd
+1056  Hsin Chen Ent Co., Ltd
+1057  ON Semiconductor
+1058  Western Digital Technologies, Inc.
+       0200  Firewire USB Combo
+       0400  External HDD
+       0500  hub
+       0702  Passport External HDD
+       0901  MyBook External HDD
+       1001  External Hard Disk
+1059  Giesecke & Devrient GmbH
+       000b  StarSign Bio Token 3.0
+105c  Hong Ji Electric Wire & Cable (Dongguan) Co., Ltd
+105d  Delkin Devices, Inc.
+105e  Valence Semiconductor Design, Ltd
+105f  Chin Shong Enterprise Co., Ltd
+1060  Easthome Industrial Co., Ltd
+1063  Motorola Electronics Taiwan, Ltd [hex]
+       1555  MC141555 Hub
+       4100  SB4100 USB Cable Modem
+1065  CCYU Technology
+       0020  USB-DVR2 Dev Board
+       2136  EasyDisk ED1064
+106a  Loyal Legend, Ltd
+106c  Curitel Communications, Inc.
+       1101  CDMA 2000 1xRTT USB modem (HX-550C)
+       1102  Packet Service
+       1103  Packet Service Diagnostic Serial Port (WDM)
+       1104  Packet Service Diagnostic Serial Port (WDM)
+       1105  Composite Device
+       1106  Packet Service Diagnostic Serial Port (WDM)
+       1301  Composite Device
+       1302  Packet Service Diagnostic Serial Port (WDM)
+       1303  Packet Service
+       1304  Packet Service
+       1401  Composite Device
+       1402  Packet Service
+       1403  Packet Service Diagnostic Serial Port (WDM)
+       1501  Packet Service
+       1502  Packet Service Diagnostic Serial Port (WDM)
+       1503  Packet Service
+       1601  Packet Service
+       1602  Packet Service Diagnostic Serial Port (WDM)
+       1603  Packet Service
+       2101  AudioVox 8900 Cell Phone
+       2102  Packet Service
+       2103  Packet Service Diagnostic Serial Port (WDM)
+       2301  Packet Service
+       2302  Packet Service Diagnostic Serial Port (WDM)
+       2303  Packet Service
+       2401  Packet Service Diagnostic Serial Port (WDM)
+       2402  Packet Service
+       2403  Packet Service Diagnostic Serial Port (WDM)
+       2501  Packet Service
+       2502  Packet Service Diagnostic Serial Port (WDM)
+       2503  Packet Service
+       2601  Packet Service
+       2602  Packet Service Diagnostic Serial Port (WDM)
+       2603  Packet Service
+       3701  Broadband Wireless modem
+       3702  Pantech PX-500
+       3eb4  Packet Service Diagnostic Serial Port (WDM)
+       4101  Packet Service Diagnostic Serial Port (WDM)
+       4102  Packet Service
+       4301  Composite Device
+       4302  Packet Service Diagnostic Serial Port (WDM)
+       4401  Composite Device
+       4402  Packet Service
+       4501  Packet Service
+       4502  Packet Service Diagnostic Serial Port (WDM)
+       4601  Composite Device
+       4602  Packet Service Diagnostic Serial Port (WDM)
+       5101  Packet Service
+       5102  Packet Service Diagnostic Serial Port (WDM)
+       5301  Packet Service Diagnostic Serial Port (WDM)
+       5302  Packet Service
+       5401  Packet Service
+       5402  Packet Service Diagnostic Serial Port (WDM)
+       5501  Packet Service Diagnostic Serial Port (WDM)
+       5502  Packet Service
+       5601  Packet Service Diagnostic Serial Port (WDM)
+       5602  Packet Service
+       7101  Composite Device
+       7102  Packet Service
+       a000  Packet Service
+       a001  Packet Service Diagnostic Serial Port (WDM)
+       c100  Packet Service
+       c200  Packet Service
+       c500  Packet Service Diagnostic Serial Port (WDM)
+       e200  Packet Service
+106d  San Chieh Manufacturing, Ltd
+106e  ConectL
+106f  Money Controls
+1076  GCT Semiconductor, Inc.
+       0031  Bluetooth Device
+       0032  Bluetooth Device
+107d  Arlec Australia, Ltd
+107e  Midoriya Electric Co., Ltd
+107f  KidzMouse, Inc.
+1082  Shin-Etsukaken Co., Ltd
+1083  Canon Electronics, Inc.
+1084  Pantech Co., Ltd
+108a  Chloride Power Protection
+108b  Grand-tek Technology Co., Ltd
+108c  Robert Bosch GmbH
+108e  Lotes Co., Ltd.
+1099  Surface Optics Corp.
+109a  DATASOFT Systems GmbH
+109f  eSOL Co., Ltd
+       3163  Trigem Mobile SmartDisplay84
+       3164  Trigem Mobile SmartDisplay121
+10a0  Hirotech, Inc.
+10a3  Mitsubishi Materials Corp.
+10a9  SK Teletech Co., Ltd
+10aa  Cables To Go
+10ab  USI Co., Ltd
+       1002  Bluetooth Device
+       1003  BC02-EXT in DFU
+       1005  Bluetooth Adptr
+       1006  BC04-EXT in DFU
+       10c5  Sony-Ericsson / Samsung DataCable
+10ac  Honeywell, Inc.
+10ae  Princeton Technology Corp.
+10af  Liebert Corp.
+       0000  UPS
+       0001  PowerSure PSA UPS
+       0002  PowerSure PST UPS
+       0003  PowerSure PSP UPS
+       0004  PowerSure PSI UPS
+       0005  UPStation GXT 2U UPS
+       0006  UPStation GXT UPS
+       0007  Nfinity Power Systems UPS
+       0008  PowerSure Interactive UPS
+10b5  Comodo (PLX?)
+       9060  Test Board
+10b8  DiBcom
+       0bb8  DiBcom USB DVB-T reference design (MOD300) (cold)
+       0bb9  DiBcom USB DVB-T reference design (MOD300) (warm)
+       0bc6  DiBcom USB2.0 DVB-T reference design (MOD3000P) (cold)
+       0bc7  DiBcom USB2.0 DVB-T reference design (MOD3000P) (warm)
+10bb  TM Technology, Inc.
+10bc  Dinging Technology Co., Ltd
+10bd  TMT Technology, Inc.
+       1427  Ethernet
+10bf  SmartHome
+       0001  SmartHome PowerLinc
+10c4  Cygnal Integrated Products, Inc.
+       0002  F32x USBXpress Device
+       80a9  CP210x to UART Bridge Controller
+       80ca  ATM2400 Sensor Device
+       ea60  CP210x Composite Device
+10c5  Sanei Electric, Inc.
+10c6  Intec, Inc.
+10cb  Eratech
+10cc  GBM Connector Co., Ltd
+       1101  MP3 Player
+10cd  Kycon, Inc.
+10ce  Silicon Labs
+       ea6a  MobiData EDGE USB Modem
+10cf  Velleman Components, Inc.
+       5500  8055 Experiment Interface Board (address=0)
+       5501  8055 Experiment Interface Board (address=1)
+       5502  8055 Experiment Interface Board (address=2)
+       5503  8055 Experiment Interface Board (address=3)
+10d1  Hottinger Baldwin Measurement
+       0101  USB-Module for Spider8, CP32
+       0202  CP22 - Communication Processor
+       0301  CP42 - Communication Processor
+10d4  Man Boon Manufactory, Ltd
+10d5  Uni Class Technology Co., Ltd
+10d6  Actions Semiconductor Co., Ltd
+       1000  MP3 Player
+       1100  MPMan MP-Ki 128 MP3 Player/Recorder
+       1101  D-Wave 2GB MP4 Player
+       8888  ADFU Device
+       ff51  ADFU Device
+10de  Authenex, Inc.
+10df  In-Win Development, Inc.
+10e0  Post-Op Video, Inc.
+10e1  CablePlus, Ltd
+10e2  Nada Electronics, Ltd
+10ec  Vast Technologies, Inc.
+10f5  Turtle Beach
+       0200  Audio Advantage Roadie
+10fb  Pictos Technologies, Inc.
+10fd  Anubis Electronics, Ltd
+       804d  Typhoon Webshot II Webcam [zc0301]
+       8050  FlyCAM-USB 300 XP2
+       de00  WinFast WalkieTV WDM Capture Driver.
+1100  VirTouch, Ltd
+       0001  VTPlayer VTP-1 Braille Mouse
+1101  EasyPass Industrial Co., Ltd
+       0001  FSK Electronics Super GSM Reader
+1108  Brightcom Technologies, Ltd
+1110  Analog Devices Canada, Ltd (Allied Telesyn)
+       5c01  Huawei MT-882 Remote NDIS Network Device
+       6489  ADSL ETH/USB RTR
+       9000  ADSL LAN Adapter
+       9001  ADSL Loader
+       900f  AT-AR215 DSL Modem
+       9010  AT-AR215 DSL Modem
+       9021  ADSL WAN Adapter
+       9022  ADSL Loader
+       9023  ADSL WAN Adapter
+       9024  ADSL Loader
+       9031  ADSL LAN Adapter
+       9032  ADSL Loader
+1111  Pandora International Ltd.
+       8888  Evolution Device
+1112  YM ELECTRIC CO., Ltd
+1113  Medion AG
+111e  VSO Electric Co., Ltd
+112e  Master Hill Electric Wire and Cable Co., Ltd
+112f  Cellon International, Inc.
+1130  Tenx Technology, Inc.
+       f211  USB audio headset
+1131  Integrated System Solution Corp.
+       1001  KY-BT100 Bluetooth Adapter
+       1002  Bluetooth Device
+       1003  Bluetooth Device
+       1004  Bluetooth Device
+1132  Toshiba Corp., Digital Media Equipment [hex]
+       4331  PDR-M4/M5/M70 Digital Camera
+       4332  PDR-M60 Digital Camera
+       4333  PDR-M2300/PDR-M700
+       4334  PDR-M65
+       4335  PDR-M61
+       4337  PDR-M11
+       4338  PDR-M25
+113c  Arin Tech Co., Ltd
+113d  Mapower Electronics Co., Ltd
+1141  V One Multimedia, Pte., Ltd
+1142  CyberScan Technologies, Inc.
+1145  Japan Radio Company
+       0001  AirH PHONE AH-J3001V/J3002V
+1146  Shimane SANYO Electric Co., Ltd.
+1147  Ever Great Electric Wire and Cable Co., Ltd
+114b  Sphairon Access Systems GmbH
+       0110  Turbolink UB801R WLAN USB Adapter
+114c  Tinius Olsen Testing Machine Co., Inc.
+114d  Alpha Imaging Technology Corp.
+115b  Salix Technology Co., Ltd.
+1162  Secugen Corp.
+1163  DeLorme Publishing, Inc.
+       0100  Earthmate GPS
+1164  YUAN High-Tech Development Co., Ltd
+       0300  ELSAVISION 460D
+       0601  Analog TV Tuner
+       0900  TigerBird BMP837 USB2.0 WDM Encoder
+       0bc7  Digital TV Tuner
+1165  Telson Electronics Co., Ltd
+1166  Bantam Interactive Technologies
+1167  Salient Systems Corp.
+1168  BizConn International Corp.
+116e  Gigastorage Corp.
+116f  Silicon 10 Technology Corp.
+1175  Shengyih Steel Mold Co., Ltd
+117d  Santa Electronic, Inc.
+117e  JNC, Inc.
+1182  Venture Corp., Ltd
+1183  Compaq Computer Corp. [hex] (Digital Dream ??)
+       0001  DigitalDream l'espion XS
+       19c7  ISDN TA
+       4008  56k FaxModem
+       504a  PJB-100 Personal Jukebox
+1184  Kyocera Elco Corp.
+1188  Bloomberg L.P.
+1189  Acer Communications & Multimedia
+       0893  EP-1427X-2 Ethernet Adapter
+118f  You Yang Technology Co., Ltd
+1190  Tripace
+1191  Loyalty Founder Enterprise Co., Ltd
+1196  Yankee Robotics, LLC
+       0010  Trifid Camera without code
+       0011  Trifid Camera
+1197  Technoimagia Co., Ltd
+1198  StarShine Technology Corp.
+1199  Sierra Wireless, Inc.
+       0019  AC595U
+       0021  AC597E
+       0110  Composite Device
+       0112  CDMA 1xEVDO PC Card, AirCard 580
+       0120  AC595U
+       0218  MC5720 Wireless Modem
+       6467  MP Series Network Adapter
+       6468  MP Series Network Adapter
+       6469  MP Series Network Adapter
+       6802  MC8755 Device
+       6803  MC8765 Device
+       6804  MC8755 Device
+       6805  MC8765 Device
+       6812  MC8775 Device
+       6820  AC875 Device
+       6832  MC8780 Device
+       6833  MC8781 Device
+       683a  MC8785 Device
+       6850  AirCard 880 Device
+       6851  AirCard 881 Device
+       6852  AirCard 880E Device
+       6853  AirCard 881E Device
+       6854  AirCard 885 Device
+       6870  MC8780 Device
+       6871  MC8781 Device
+119a  ZHAN QI Technology Co., Ltd
+119b  ruwido austria GmbH
+       0400  Infrared Keyboard V2.01
+11a0  Chipcon AS
+       eb11  CC2400EB 2.0 ZigBee Sniffer
+11a3  Technovas Co., Ltd
+       8031  MP3 Player
+       8032  MP3 Player
+11aa  GlobalMedia Group, LLC
+       1518  iREZ K2
+11ab  Exito Electronics Co., Ltd
+11b0  ATECH FLASH TECHNOLOGY
+11db  Topfield Co., Ltd.
+       1000  PVR
+       1100  PVR
+11e6  K.I. Technology Co. Ltd.
+11f5  Siemens AG (?)
+       0001  SX1
+       0003  Mobile phone USB cable
+       0004  X75
+11f6  Prolific
+       2001  Willcom WSIM
+11f7  Alcatel (?)
+       02df  TD10 Mobile phone USB cable
+1209  InterBiometrics
+       1001  USB Hub
+       1002  USB Relais
+       1003  IBSecureCam-P
+       1004  IBSecureCam-O
+       1005  IBSecureCam-N
+120e  Hudson Soft Co., Ltd
+121e  Jungsoft Co., Ltd
+       3403  Muzio JM250 Audio Player
+1223  SKYCABLE ENTERPRISE. CO., LTD.
+1230  Chipidea-Microelectronica, S.A.
+1235  Novation EMS
+       0001  ReMOTE Audio/XStation
+       0002  Speedio
+       4661  ReMOTE25
+1241  Belkin
+       1111  Mouse
+       1122  Typhoon Stream Optical Mouse USB+PS/2
+       1155  PS2/USB Browser Combo Mouse
+       1166  MI-2150 Trust Mouse
+       1177  F8E842-DL Mouse
+       1503  Keyboard
+124a  AirVast
+       4017  PC-Chips 802.11b Adapter
+124b  Nyko (Honey Bee)
+       4d01  Airflo EX Joystick
+125f  A-DATA Technology Co., Ltd.
+1264  Covidien Energy-based Devices
+1267  Logic3 / SpectraVideo plc
+       0103  G-720 Keyboard
+       0201  A4Tech SWOP-3 Mouse
+       a001  JP260 PC Game Pad
+       c002  Wireless Optical Mouse
+126c  Aristocrat Technologies
+126d  Bel Stewart
+126e  Strobe Data, Inc.
+126f  TwinMOS
+       1325  Mobile Disk
+       2168  Mobile Disk III
+       a006  G240
+1275  Xaxero Marine Software Engineering, Ltd.
+       0002  WeatherFax 2000 Demodulator
+       0080  SkyEye Weather Satellite Receiver
+1286  Marvell Semiconductor, Inc.
+       8001  BLOB boot loader firmware
+1292  Innomedia
+       0258  Creative Labs VoIP Blaster
+1293  Belkin Components [hex]
+       0002  F5U002 Parallel Port [uss720]
+       2101  104-key keyboard
+1294  RISO KAGAKU CORP.
+129b  CyberTAN Technology
+       1666  TG54USB
+12a7  Trendchip Technologies Corp.
+12ab  Honey Bee Electronic International Ltd.
+12ba  Licensed by Sony Computer Entertainment America
+       0200  Harmonix Guitar for PlayStation(R)3
+       0210  Harmonix Drum Kit for PlayStation(R)3
+12d1  Huawei Technologies Co., Ltd.
+       1001  E620 USB Modem
+       1003  E220 HSDPA Modem / E270 HSDPA/HSUPA Modem
+12d2  LINE TECH INDUSTRIAL CO., LTD.
+12d7  BETTER WIRE FACTORY CO., LTD.
+12ef  Tapwave, Inc.
+       0100  Tapwave Handheld [Tapwave Zodiac]
+12f5  Dynamic System Electronics Corp.
+12f7  Memorex Products, Inc.
+       1a00  TD Classic 003B
+       1e23  TravelDrive 2007 Flash Drive
+12fd  AIN Comm. Technology Co., Ltd
+       1001  AWU2000b 802.11b Stick
+1307  Transcend Information, Inc.
+       0163  512MB USB Flash Drive
+       1169  TS2GJF210 JetFlash 210 2GB
+1310  Roper
+       0001  Class 1 Bluetooth Dongle
+1312  ICS Electronics
+131d  Natural Point
+       0155  TrackIR 3 Pro Head Tracker
+132b  Konica Minolta
+       0000  Dimage A2 Camera
+       0001  Minolta DiMAGE A2 (ptp)
+       0003  Dimage Xg Camera
+       0006  Dimage Z2 Camera
+       0007  Minolta DiMAGE Z2 (PictBridge mode)
+       0008  Dimage X21 Camera
+       000a  Dimage Scan Dual IV
+       000b  Dimage Z10 Camera
+       000d  Dimage X50 Camera [storage?]
+       000f  Dimage X50 Camera [p2p?]
+       0010  Dimage G600 Camera
+       0012  Dimage Scan Elite5400 2
+       0013  Dimage X31 Camera
+       0015  Dimage G530 Camera
+       0017  Dimage Z3 Camera
+       0018  Minolta DiMAGE Z3 (PictBridge mode)
+       0019  Dimage A200 Camera
+       0021  Dimage Z5 Camera
+       0022  Minolta DiMAGE Z5 (PictBridge mode)
+1342  Mobility
+       0200  EasiDock 200 Hub
+       0201  EasiDock 200 Keyboard and Mouse Port
+       0202  EasiDock 200 Serial Port
+       0203  EasiDock 200 Printer Port
+       0204  Ethernet
+       0304  EasiDock Ethernet
+1348  Katsuragawa Electric Co., Ltd.
+134e  Digby's Bitpile, Inc. DBA D Bit
+136b  STEC
+1370  Swissbit
+       6828  Victorinox Flash Drive
+1371  Dick Smith Electronics
+       9022  RT2573
+       9032  C-Net CWD-854 rev F
+1376  Vimtron Electronics Co., Ltd.
+1385  Netgear, Inc
+       4250  WG111T
+       4251  WG111T (no firmware)
+       5f00  WPN111 RangeMax(TM) Wireless USB 2.0 Adapter
+       5f01  WPN111 (no firmware)
+138e  Jungo LTD
+       9000  Raisonance S.A. STM32 ARM evaluation board
+1390  TOMTOM B.V.
+1395  Sennheiser Communications
+       3556  USB Headset
+1398  Q-tec
+       2103  USB 2.0 Storage Device
+13ad  Baltech
+       9999  Card reader
+13b0  PerkinElmer Optoelectronics
+       000a  Alesis Photon X25 MIDI Controller
+13b1  Linksys
+       000b  WUSB11 v4.0 802.11b Adapter
+       000d  WUSB54G Wireless Adapter
+       0011  WUSB54GP v4.0 802.11g Adapter
+       0018  USB200M 10/100 Ethernet Adapter
+       001a  HU200TS Wireless Adapter
+       0020  WUSB54GC 802.11g Adapter [ralink rt73]
+       0023  WUSB54GR
+       0024  WUSBF54G v1.1 802.11g Adapter w/ Wi-Fi Finder
+13b3  Nippon Dics Co., Ltd.
+13be  Ricoh Printing Systems, Ltd.
+13ca  JyeTai Precision Industrial Co., Ltd.
+13cf  Wisair Ltd.
+13d1  A-Max Technology Macao Commercial Offshore Co. Ltd.
+13d2  Shark Multimedia
+       0400  Pocket Ethernet [klsi]
+13d3  IMC Networks
+       3201  VisionDTV USB-Ter/HAMA USB DVB-T device cold
+       3202  VisionDTV USB-Ter/HAMA USB DVB-T device warm
+       3203  DTV-DVB UDST7020BDA DVB-S Box(DVBS for MCE2005)
+       3204  DTV-DVB UDST7020BDA DVB-S Box(DVBS for MCE2005)
+       3205  DNTV Live! Tiny USB2 BDA (No Remote)
+       3206  DNTV Live! Tiny USB2 BDA (No Remote)
+       3207  DTV-DVB UDST7020BDA DVB-S Box(DVBS for MCE2005)
+       3208  DTV-DVB UDST7020BDA DVB-S Box(DVBS for MCE2005)
+       3209  DTV-DVB UDST7022BDA DVB-S Box(Without HID)
+       3211  DTV-DVB Hybrid Analog/Capture / Pinnacle PCTV 310e
+       3212  DTV-DVB UDTT704C - DVBT/NTSC/PAL Driver(PCM4)
+       3213  DTV-DVB UDTT704D - DVBT/NTSC/PAL Driver (PCM4)
+       3214  DTV-DVB UDTT704F -(MiniCard) DVBT/NTSC/PAL Driver(Without HID)
+       3215  DTV-DVB UDAT7240 - ATSC/NTSC/PAL Driver(PCM4)
+       3216  DTV-DVB UDTT 7047-USB 2.0 DVB-T Driver
+       3217  Digital-TV Receiver.
+       3219  DTV-DVB UDTT7049 - DVB-T Driver(Without HID)
+       3220  DTV-DVB UDTT 7047M-USB 2.0 DVB-T Driver
+       3223  DNTV Live! Tiny USB2 BDA (No Remote)
+       3224  DNTV Live! Tiny USB2 BDA (No Remote)
+       3226  DigitalNow TinyTwin DVB-T Receiver
+       3236  DTV-DVB UDTT 7047A-USB 2.0 DVB-T Driver
+       3237  DTV-DVB UDTT 704J - dual DVB-T Driver
+       3239  DTV-DVB UDTT704D - DVBT/NTSC/PAL Driver(Without HID)
+       3240  DTV-DVB UDXTTM6010 - A/D Driver(Without HID)
+       3241  DTV-DVB UDXTTM6010 - A/D Driver(Without HID)
+       3242  DTV-DVB UDAT7240LP - ATSC/NTSC/PAL Driver(Without HID)
+       3243  DTV-DVB UDXTTM6010 - A/D Driver(Without HID)
+       3244  DTV-DVB UDTT 7047Z-USB 2.0 DVB-T Driver
+       3247  802.11 n/g/b Wireless LAN Adapter
+       7020  DTV-DVB UDST7020BDA DVB-S Box(DVBS for MCE2005)
+       7022  DTV-DVB UDST7022BDA DVB-S Box(Without HID)
+13dc  ALEREON, INC.
+13dd  i.Tech Dynamic Limited
+13e1  Kaibo Wire & Cable (Shenzhen) Co., Ltd.
+13e5  Rane
+       0001  SL-1
+13e6  TechnoScope Co., Ltd.
+13fd  Initio Corporation
+13fe  Kingston Technology Company Inc.
+       1a00  512MB/1GB Flash Drive
+       1a23  512MB Flash Drive
+       1d00  DataTraveler 2.0 1GB/4GB Flash Drive / Patriot Xporter 4GB Flash Drive
+       1f00  DataTraveler 2.0 4GB Flash Drive
+1400  Axxion Group Corp.
+1402  Bowe Bell & Howell
+1403  Sitronix
+       0001  Digital Photo Frame
+140e  Telechips, Inc.
+1410  Novatel Wireless
+       1110  Merlin S620
+       1120  Merlin EX720
+       1130  Merlin S720
+       1400  Merlin U740
+       2110  Ovation U720/MCD3000
+       4100  U727
+1415  Nam Tai E&E Products Ltd. or OmniVision Technologies, Inc.
+       0000  Sony SingStar USBMIC
+       2000  Sony Playstation Eye
+1419  ABILITY ENTERPRISE CO., LTD.
+1429  Vega Technologies Industrial (Austria) Co.
+1430  RedOctane
+1431  Pertech Resources, Inc.
+1435  Wistron NeWeb
+       0711  UR055G
+       0826  AR5523
+       0827  AR5523 (no firmware)
+       0828  AR5523
+       0829  AR5523 (no firmware)
+1436  Denali Software, Inc.
+143c  Altek Corporation
+1453  Radio Shack
+       4026  26-183 Serial Cable
+1456  Extending Wire & Cable Co., Ltd.
+1457  First International Computer, Inc.
+       5117  OpenMoko Neo1973 kernel usbnet (g_ether, CDC Ethernet) mode
+       5118  OpenMoko Neo1973 Debug board (V2+)
+       5119  OpenMoko Neo1973 u-boot cdc_acm serial port
+       5120  OpenMoko Neo1973 u-boot usbtty generic serial
+       5121  OpenMoko Neo1973 kernel mass storage (g_storage) mode
+       5122  OpenMoko Neo1973 kernel cdc_ether USB network
+       5123  OpenMoko Neo1973 internal USB CSR4 module
+       5124  OpenMoko Neo1973 Bluetooth Device ID service
+1461  Staccato Communications
+1462  Micro Star International
+       5512  MegaStick-1 Flash Stick
+1472  Huawei-3Com
+       0009  Aolynk WUB320g
+147a  Formosa Industrial Computing, Inc.
+       e015  eHome Infrared Receiver
+       e016  eHome Infrared Receiver
+147f  Hama GmbH & Co., KG
+1484  Elsa AG [hex]
+       1746  Ecomo 19H99 Monitor
+       7616  Elsa Hub
+1485  Silicom
+       0001  U2E
+       0002  Psion Gold Port Ethernet
+1487  DSP Group, Ltd.
+148e  EVATRONIX SA
+148f  Ralink Technology, Corp.
+       1706  RT2500USB Wireless Adapter
+       2570  802.11g WiFi
+       2573  RT2501USB Wireless Adapter
+       2671  RT2601USB Wireless Adapter
+       9020  RT2500USB Wireless Adapter
+       9021  RT2501USB Wireless Adapter
+1497  Panstrong Company Ltd.
+149a  Imagination Technologies
+       2107  DBX1 DSP core
+14aa  AVerMedia (again) or C&E
+       0001  Avermedia AverTV DVBT USB1.1 (cold)
+       0002  Avermedia AverTV DVBT USB1.1 (warm)
+       0201  AVermedia/Yakumo/Hama/Typhoon DVB-T USB2.0 (cold)
+       0221  AVermedia DVBT Tuner Dongle
+       0301  AVermedia/Yakumo/Hama/Typhoon DVB-T USB2.0 (warm)
+14ad  CTK Corporation
+14ae  Printronix Inc.
+14af  ATP Electronics Inc.
+14b0  StarTech.com Ltd.
+14b2  Atheros Communications Inc
+       3a93  USB WLAN Device
+       3c02  C54RU WLAN
+       3c22  C54RU
+14c0  Rockwell Automation, Inc.
+14c2  Gemlight Computer, Ltd
+       0250  Storage Adapter V2
+       0350  Storage Adapter V2
+14cd  Super Top
+       6600  USB 2.0 IDE DEVICE
+14d8  JAMER INDUSTRIES CO., LTD.
+14dd  Raritan Computer, Inc.
+14e5  SAIN Information & Communications Co., Ltd.
+14ea  Planex Communications
+       ab10  GW-US54GZ
+       ab11  GU-1000T
+       ab13  GW-US54Mini
+14ed  Shure Inc.
+1500  Ellisys
+1501  Pine-Tum Enterprise Co., Ltd.
+1513  Hypercom
+1516  CompUSA
+       8628  128M Pen Drive
+1518  Cheshire Engineering Corp.
+       0001  HDReye High Dynamic Range Camera
+       0002  HDReye (before firmware loads)
+1520  Bitwire Corp.
+1524  ENE Technology Inc
+       6680  UTS 6680
+1527  Silicon Portals
+       0200  YAP Phone (no firmware)
+       0201  YAP Phone
+1529  UBIQUAM Co., Ltd.
+       3100  CDMA 1xRTT USB Modem (U-100/105/200/300/520)
+152d  JMicron Technology Corp. / JMicron USA Technology Corp.
+       2338  JM20337 Hi-Speed USB to SATA & PATA Combo Bridge
+152e  LG (HLDS)
+       e001  GSA-5120D DVD-RW
+1532  Razer USA, Ltd
+       0001  RZ01-020300 Optical Mouse [Diamondback]
+       0003  Krait Mouse
+       0007  DeathAdder Mouse
+       0102  Tarantula Keyboard
+1546  U-Blox AG
+154b  PNY
+       0010  USB 2.0 Flash Drive
+154d  ConnectCounty Holdings Berhad
+154e  D&M Holdings, Inc. (Denon/Marantz)
+       3000  Marantz RC9001 Remote Control
+1554  Prolink Microsystems Corp.
+1557  OQO
+       0002  model 01 WiFi interface
+       0003  model 01 Bluetooth interface
+       7720  model 01+ Ethernet
+       8150  model 01 Ethernet interface
+1568  Sunf Pu Technology Co., Ltd
+156f  Quantum Corporation
+1570  ALLTOP TECHNOLOGY CO., LTD.
+157b  Ketron SRL
+157e  TRENDnet
+       3006  TEW-444UB EU
+       3007  TEW-444UB EU (no firmware)
+       300a  TEW-429UB 802.11g Adapter with HotSpot Detector
+       300b  TEW-429UB
+       300d  TEW-429UB C1
+       3204  ALL0298 v2
+       3205  AR5523
+       3206  AR5523 (no firmware)
+1582  Fiberline
+       6003  WL-430U
+1587  SMA Technologie AG
+158d  Oakley Inc.
+1598  Kunshan Guoji Electronics Co., Ltd.
+15a2  Freescale Semiconductor, Inc.
+15a8  Teams Power Limited
+15aa  Gearway Electronics (Dong Guan) Co., Ltd.
+15ba  Olimex Ltd.
+       0003  OpenOCD JTAG
+       0004  OpenOCD JTAG TINY
+15c2  SoundGraph Inc.
+       ffdc  iMON PAD Remote Controller
+15c6  Laboratoires MXM
+       1000  DigistimSP (cold)
+       1001  DigistimSP (warm)
+       1002  DigimapSP USB (cold)
+       1003  DigimapSP USB (warm)
+15c9  D-Box Technologies
+15ca  Textech International Ltd.
+       00c3  Mini Optical Mouse
+15d5  Coulomb Electronics Ltd.
+15dc  Hynix Semiconductor Inc.
+15e0  Seong Ji Industrial Co., Ltd.
+15e1  RSA
+       2007  RSA SecurID (R) Authenticator
+15e8  SohoWare
+       9100  NUB100 Ethernet [pegasus]
+       9110  10/100 USB Ethernet
+15e9  Pacific Digital Corp.
+       04ce  MemoryFrame MF-570
+       1968  MemoryFrame MF-570
+       1969  Digital Frame
+15ec  Belcarra Technologies Corp.
+15f4  HanfTek
+       0001  HanfTek UMT-010 USB2.0 DVB-T (cold)
+       0025  HanfTek UMT-010 USB2.0 DVB-T (warm)
+1604  Tascam
+       8000  US-428 Audio/Midi Controller (without fw)
+       8001  US-428 Audio/Midi Controller
+       8004  US-224 Audio/Midi Controller (without fw)
+       8005  US-224 Audio/Midi Controller
+       8006  US-122 Audio/Midi Interface (without fw)
+       8007  US-122 Audio/Midi Interface
+1606  Umax [hex]
+       0002  Astra 1236U Scanner
+       0010  Astra 1220U
+       0030  Astra 2000U
+       0050  Scanner
+       0060  Astra 3400U
+       0130  Astra 2100U
+       0160  Astra 5400U
+       0230  Astra 2200/2200SU
+       0350  Astra 4800/4850 Scanner
+       1030  Astra 4000U
+       1220  Genesys Logic Scanner Controller NT5.0
+       2010  AstraCam Digital Camera
+       2020  AstraCam 1000
+       2030  AstraCam 1800 Digital Camera
+1608  Inside Out Networks [hex]
+       0001  EdgePort/4 Serial Port
+       0002  Edgeport/8
+       0003  Rapidport/4
+       0004  Edgeport/4
+       0005  Edgeport/2
+       0006  Edgeport/4i
+       0007  Edgeport/2i
+       0008  Edgeport/8
+       000c  Edgeport/421
+       000d  Edgeport/21
+       000e  Edgeport/4
+       000f  Edgeport/8
+       0010  Edgeport/2
+       0011  Edgeport/4
+       0012  Edgeport/416
+       0014  Edgeport/8i
+       0018  Edgeport/412
+       0019  Edgeport/412
+       001a  Edgeport/2+2i
+       0101  Edgeport/4
+       0105  Edgeport/2
+       0106  Edgeport/4i
+       0107  Edgeport/2i
+       010c  Edgeport/421
+       010d  Edgeport/21
+       0110  Edgeport/2
+       0111  Edgeport/4
+       0112  Edgeport/416
+       0114  Edgeport/8i
+       0201  Edgeport/4
+       0203  Rapidport/4
+       0204  Edgeport/4
+       0205  Edgeport/2
+       0206  Edgeport/4i
+       0207  Edgeport/2i
+       020c  Edgeport/421
+       020d  Edgeport/21
+       020e  Edgeport/4
+       020f  Edgeport/8
+       0210  Edgeport/2
+       0211  Edgeport/4
+       0212  Edgeport/416
+       0214  Edgeport/8i
+       0215  Edgeport/1
+       0216  EPOS/44
+       0217  Edgeport/42
+       021a  Edgeport/2+2i
+       021b  Edgeport/2c
+       021c  Edgeport/221c
+       021d  Edgeport/22c
+       021e  Edgeport/21c
+       021f  Edgeport/62
+       0240  Edgeport/1
+       0241  Edgeport/1i
+       0242  Edgeport/4s
+       0243  Edgeport/8s
+       0244  Edgeport/8
+       0245  Edgeport/22c
+       0301  Watchport/P
+       0302  Watchport/M
+       0303  Watchport/W
+       0304  Watchport/T
+       0305  Watchport/H
+       0306  Watchport/E
+       0307  Watchport/L
+       0308  Watchport/R
+       0309  Watchport/A
+       030a  Watchport/D
+       030b  Watchport/D
+       030c  Power Management Port
+       030e  Power Management Port
+       030f  Watchport/G
+       0310  Watchport/Tc
+       0311  Watchport/Hc
+       1403  MultiTech Systems MT4X56 Modem
+       1a17  Agilent Technologies (E6473)
+1619  L & K Precision Technology Co., Ltd.
+1621  Wionics Research
+1628  Stonestreet One, Inc.
+162a  Airgo Networks Inc.
+162f  WiQuest Communications, Inc.
+1631  Good Way Technology
+       6200  GWUSB2E
+       c019  RT2573
+1645  Entrega [hex]
+       0001  1S Serial Port
+       0002  2S Serial Port
+       0003  1S25 Serial Port
+       0004  4S Serial Port
+       0005  E45 Ethernet [klsi]
+       0006  Parallel Port
+       0007  U1-SC25 SCSI
+       0008  Ethernet
+       0016  Bi-directional to Parallel Printer Converter
+       0080  1 port to Serial Converter
+       0081  1 port to Serial Converter
+       0093  1S9 Serial Port
+       8000  EZ-USB
+       8001  1 port to Serial
+       8002  2x Serial Port
+       8003  1 port to Serial
+       8004  2U4S serial/usb hub
+       8005  Ethernet
+       8080  1 port to Serial
+       8081  1 port to Serial
+       8093  PortGear Serial Port
+164a  ChipX
+1657  Struck Innovative Systeme GmbH
+       3150  SIS3150 USB2.0 to VME interface
+1660  Creatix Polymedia GmbH
+1668  Actiontec Electronics, Inc. [hex]
+       0009  Gateway
+       0333  Modem
+       0358  InternetPhoneWizard
+       0405  Gateway
+       0408  Prism2.5 802.11b Adapter
+       0413  Gateway
+       0421  Prism2.5 802.11b Adapter
+       0441  IBM Integrated Bluetooth II
+       0500  BTM200B BlueTooth Adapter
+       1050  802.11g Wireless Mini adapter
+       1441  IBM Integrated Bluetooth II
+       2441  BMDC-2 IBM Bluetooth III w.56k
+       3441  IBM Integrated Bluetooth III
+       6010  Gateway
+       6097  802.11b Wireless Adapter
+       6106  ROPEX FreeLan 802.11b
+       7605  UAT1 Wireless Ethernet Adapter
+1669  PiKRON Ltd. [hex]
+       1001  uLan2USB Converter - PS1 protocol
+1679  Total Phase
+       2001  Beagle USB 12 Protocol Analyzer
+1682  Maxwise Production Enterprise Ltd.
+1684  Godspeed Computer Corp.
+1686  ZOOM Corporation
+       0045  H4 Digital Recorder
+1687  Kingmax Digital Inc.
+168c  Atheros Communications
+       0001  AR5523
+       0002  AR5523 (no firmware)
+1690  Askey Computer Corp. [hex]
+       0101  Creative Modem Blaster DE5670
+       0102  CDC Modem Board
+       0103  Askey 1456 VQE-R3 Modem [conexant]
+       0104  HCF V90 Data Fax RTAD Modem
+       0107  HCF V.90 Data,Fax,RTAD Modem
+       0109  Askey MagicXpress V.90 Pocket Modem [conexant]
+       0203  Voyager ADSL Modem Loader
+       0204  Voyager ADSL Modem
+       0205  DSL Modem
+       0206  GlobeSpan ADSL WAN Modem
+       0208  DSL Modem
+       0209  Voyager 100 ADSL Modem
+       0211  Globespan Virata ADSL LAN Modem
+       0212  DSL Modem
+       0213  HM121d DSL Modem
+       0214  HM121d DSL Modem
+       0215  Voyager 105 ADSL Modem
+       0701  WLAN
+       0710  SMCWUSBT-G
+       0711  SMCWUSBT-G (no firmware)
+       0712  AR5523
+       0713  AR5523 (no firmware)
+       0715  Voyager 1055 Laptop Adapter
+       0722  RT2573
+       0726  Wi-Fi Wireless LAN Adapter
+       0901  Voyager 205 ADSL Router
+1696  Hitachi Video and Information System, Inc.
+1697  VTec Test, Inc.
+16a5  Shenzhen Zhengerya Cable Co., Ltd.
+16ab  Global Sun Technology
+       7801  AR5523
+       7802  AR5523 (no firmware)
+       7811  AR5523
+       7812  AR5523 (no firmware)
+16ac  Dongguan ChingLung Wire & Cable Co., Ltd.
+16c0  VOTI
+       03e8  free for internal lab use 1000
+       03e9  free for internal lab use 1001
+       03ea  free for internal lab use 1002
+       03eb  free for internal lab use 1003
+       03ec  free for internal lab use 1004
+       03ed  free for internal lab use 1005
+       03ee  free for internal lab use 1006
+       03ef  free for internal lab use 1007
+       03f0  free for internal lab use 1008
+       03f1  free for internal lab use 1009
+       076b  OpenPCD 13.56MHz RFID Reader
+       076c  OpenPICC 13.56MHz RFID Simulator (native)
+       08ac  OpenBeacon USB stick
+16cc  silex technology, Inc.
+16d3  Frontline Test Equipment, Inc.
+16d5  AnyDATA Corporation
+       6501  CDMA 2000 1xRTT/EV-DO USB Modem
+16d8  CMOTECH Co., Ltd.
+       5141  CMOTECH CDMA Technologies USB modem
+       5543  CDMA 2000 1xRTT/1xEVDO USB modem
+       6280  CMOTECH CDMA Technologies USB modem
+16df  King Billion Electronics Co., Ltd.
+16f5  Futurelogic Inc.
+1706  BlueView Technologies, Inc.
+1707  ARTIMI
+170b  Swissonic
+       0011  MIDI-USB 1x1
+170d  Avnera
+1733  Cellink Technology Co., Ltd
+       0101  RF Wireless Optical Mouse OP-701
+1736  CANON IMAGING SYSTEM TECHNOLOGIES INC.
+1737  Linksys
+       0039  USB1000
+1740  Senao
+       2000  NUB-8301
+1743  General Atomics
+174c  ASMedia Technology Inc.
+174f  Syntek
+       5a35  1.3MPixel Web Cam - Asus G1s
+       6a31  Web Cam - Asus A8J, F3S, F5R, VX2S, V1S
+       6a33  Web Cam - Asus F3SA, F9J, F9S
+       6a51  2.0MPixel Web Cam - Asus Z96J, Z96S, S96S
+       6a54  Web Cam
+       6d51  2.0Mpixel Web Cam - Eurocom D900C
+       8a12  0.3MPixel Web Cam - Packard Bell MX37-T-003
+       a311  1.3MPixel Web Cam - Asus A3A, A6J, A6K, A6M, A6R, A6T, A6V, A7T, A7sv, A7U
+       a312  1.3MPixel Web Cam
+       a821  Web Cam - Packard Bell BU45, PB Easynote MX66-208W
+       aa11  Web Cam
+1759  LucidPort Technology, Inc.
+1772  System Level Solutions, Inc.
+1781  Multiple Vendors
+       083e  MetaGeek Wi-Spy
+       0938  Iguanaworks USB IR Transceiver
+1782  Spreadtrum Communications Inc.
+1784  TopSeed Technology Corp.
+1788  ShenZhen Litkconn Technology Co., Ltd.
+1796  Printrex, Inc.
+1797  JALCO CO., LTD.
+17a5  Advanced Connection Technology Inc.
+17a7  MICOMSOFT CO., LTD.
+17b3  Grey Innovation
+       0004  Linux-USB Midi Gadget
+17c3  Singim International Corp.
+17cc  Native Instruments
+       0815  Audio Kontrol 1
+       1940  RigKontrol3
+       1969  RigKontrol2
+       1978  Audio 8 DJ
+       4711  Kore Controller
+       4712  Kore Controller 2
+17cf  Hip Hing Cable & Plug Mfy. Ltd.
+17d0  Sanford L.P.
+17d3  Korea Techtron Co., Ltd.
+17e9  Newnham Research
+       0051  USB VGA Adaptor
+17eb  Cornice, Inc.
+17ef  Lenovo
+       3815  ChipsBnk 2GB USB Stick
+17f5  K.K. Rocky
+17f6  Unicomp, Inc
+1822  Twinhan
+       3201  VisionDTV USB-Ter/HAMA USB DVB-T device cold
+       3202  VisionDTV USB-Ter/HAMA USB DVB-T device warm
+1831  Gwo Jinn Industries Co., Ltd.
+1832  Huizhou Shenghua Industrial Co., Ltd.
+1854  Memory Devices Ltd.
+185b  Compro
+       d000  Compro Videomate DVB-U2000 - DVB-T USB cold
+       d001  Compro Videomate DVB-U2000 - DVB-T USB warm
+1861  Tech Technology Industrial Company
+1862  Teridian Semiconductor Corp.
+1871  Aveo Technology Corp.
+1894  Topseed
+       5632  Atek Tote Remote
+       5641  TSAM-004 Presentation Remote
+1897  Evertop Wire Cable Co.
+18b6  Mikkon Technology Limited
+18b7  Zotek Electronic Co., Ltd.
+18c5  AMIT
+       0002  CG-WLUSB2GO
+18d5  Starline International Group Limited
+18d9  Kaba
+       01xy  LEGIC advant desktop reader
+18e3  Fitipower Integrated Technology Inc
+18e8  Qcom
+       6196  RT2573
+       6229  RT2573
+18ea  Matrox Graphics, Inc.
+       0002  DualHead2Go [Analog Edition]
+       0004  TripleHead2Go [Digital Edition]
+18fd  FineArch Inc.
+190d  Motorola GSG
+1914  Alco Digital Devices Limited
+1915  Linksys
+       2233  WUSB11 v2.8 802.11b Adapter
+       2234  WUSB54G 802.11g Adapter
+192f  Avago Technologies, Pte.
+1930  Shenzhen Xianhe Technology Co., Ltd.
+1931  Ningbo Broad Telecommunication Co., Ltd.
+1949  Lab126
+1951  Hyperstone AG
+1953  Ironkey Inc.
+1954  Radiient Technologies
+195d  Itron Technology iONE
+       7002  Libra-Q11 IR remote
+       7006  Libra-Q26 / 1.0 Remote
+       7777  Scorpius wireless keyboard
+1967  CASIO HITACHI Mobile Communications Co., Ltd.
+196b  Wispro Technology Inc.
+1970  Dane-Elec Corp. USA
+1975  Dongguan Guneetal Wire & Cable Co., Ltd.
+1976  Chipsbrand Microelectronics (HK) Co., Ltd.
+1977  T-Logic
+       0111  TL203 MP3 Player and Voice Recorder
+1989  Nuconn Technology Corp.
+198f  Beceem Communications Inc.
+1990  Acron Precision Industrial Co., Ltd.
+1995  Trillium Technology Pty. Ltd.
+       3202  REC-ADPT-USB (recorder)
+       3203  REC-A-ADPT-USB (recorder)
+199e  The Imaging Source Europe GmbH
+199f  Benica Corporation
+19a8  Biforst Technology Inc.
+19af  S Life
+       6611  Celestia VoIP Phone
+19b5  B & W Group
+19b6  Infotech Logistic, LLC
+19ca  Mindtribe
+       0001  Sandio 3D HID Mouse
+19cf  Parrot SA
+19e1  WeiDuan Electronic Accessory (S.Z.) Co., Ltd.
+19e8  Industrial Technology Research Institute
+19ef  Pak Heng Technology (Shenzhen) Co., Ltd.
+19ff  Best Buy
+       0201  Rocketfish Wireless 2.4G Laser Mouse
+1a08  Bellwood International, Inc.
+1a0a  USB-IF non-workshop
+       badd  USB OTG Compliance test device
+1a12  KES Co., Ltd.
+1a25  Amphenol East Asia Ltd.
+1a2a  Seagate Branded Solutions
+1a36  Biwin Technology Ltd.
+1a40  TERMINUS TECHNOLOGY INC.
+1a41  Action Electronics Co., Ltd.
+1a4a  Silicon Image
+1a4b  SafeBoot International B.V.
+1a61  Abbott Diabetes Care
+1a6a  Spansion Inc.
+1a6d  SamYoung Electronics Co., Ltd
+1a6e  Global Unichip Corp.
+1a6f  Sagem Orga GmbH
+1a79  Bayer Health Care LLC
+1a7b  Lumberg Connect  GmbH & Co. KG
+1a89  Dynalith Systems Co., Ltd.
+1a8b  SGS Taiwan Ltd.
+1a98  Leica Camera AG
+1aa4  Data Drive Thru, Inc.
+1aa5  UBeacon Technologies, Inc.
+1aa6  eFortune Technology Corp.
+1acb  Salcomp Plc
+1ad1  Desay Wire Co., Ltd.
+1ae4  ic-design Reinhard Gottinger GmbH
+1aed  High Top Precision Electronic Co., Ltd.
+1aef  Conntech Electronic (Suzhou) Corporation
+1b04  Meilhaus Electronic GmBH
+       0630  ME-630
+       0940  ME-94
+       0950  ME-95
+       0960  ME-96
+       1000  ME-1000
+       100a  ME-1000
+       100b  ME-1000
+       1400  ME-1400
+       140a  ME-1400A
+       140b  ME-1400B
+       140c  ME-1400C
+       140d  ME-1400D
+       140e  ME-1400E
+       14ea  ME-1400EA
+       14eb  ME-1400EB
+       1604  ME-1600/4U
+       1608  ME-1600/8U
+       160c  ME-1600/12U
+       160f  ME-1600/16U
+       168f  ME-1600/16U8I
+       4610  ME-4610
+       4650  ME-4650
+       4660  ME-4660
+       4661  ME-4660I
+       4662  ME-4660
+       4663  ME-4660I
+       4670  ME-4670
+       4671  ME-4670I
+       4672  ME-4670S
+       4673  ME-4670IS
+       4680  ME-4680
+       4681  ME-4680I
+       4682  ME-4680S
+       4683  ME-4680IS
+       6004  ME-6000/4
+       6008  ME-6000/8
+       600f  ME-6000/16
+       6014  ME-6000I/4
+       6018  ME-6000I/8
+       601f  ME-6000I/16
+       6034  ME-6000ISLE/4
+       6038  ME-6000ISLE/8
+       603f  ME-6000ISLE/16
+       6044  ME-6000/4/DIO
+       6048  ME-6000/8/DIO
+       604f  ME-6000/16/DIO
+       6054  ME-6000I/4/DIO
+       6058  ME-6000I/8/DIO
+       605f  ME-6000I/16/DIO
+       6074  ME-6000ISLE/4/DIO
+       6078  ME-6000ISLE/8/DIO
+       607f  ME-6000ISLE/16/DIO
+       6104  ME-6100/4
+       6108  ME-6100/8
+       610f  ME-6100/16
+       6114  ME-6100I/4
+       6118  ME-6100I/8
+       611f  ME-6100I/16
+       6134  ME-6100ISLE/4
+       6138  ME-6100ISLE/8
+       613f  ME-6100ISLE/16
+       6144  ME-6100/4/DIO
+       6148  ME-6100/8/DIO
+       614f  ME-6100/16/DIO
+       6154  ME-6100I/4/DIO
+       6158  ME-6100I/8/DIO
+       615f  ME-6100I/16/DIO
+       6174  ME-6100ISLE/4/DIO
+       6178  ME-6100ISLE/8/DIO
+       617f  ME-6100ISLE/16/DIO
+       6259  ME-6200I/9/DIO
+       6359  ME-6300I/9/DIO
+       810a  ME-8100A
+       810b  ME-8100B
+       820a  ME-8200A
+       820b  ME-8200B
+1b20  MStar Semiconductor, Inc.
+1b22  WiLinx Corp.
+1b26  Cellex Power Products, Inc.
+1b27  Current Electronics Inc.
+1b28  NAVIsis Inc.
+1b32  Ugobe Life Forms, Inc.
+1b36  ViXS Systems, Inc.
+1b3f  Generalplus Technology Inc.
+1b47  Energizer Holdings, Inc.
+       0001  CHUSB Duo Charger (NiMH AA/AAA USB smart charger)
+1b48  Plastron Precision Co., Ltd.
+1b59  K.S. Terminals Inc.
+1b5a  Chao Zhou Kai Yuan Electric Co., Ltd.
+1b65  The Hong Kong Standards and Testing Centre Ltd.
+1b72  ATERGI TECHNOLOGY CO., LTD.
+1b76  Legend Silicon Corp.
+1b86  Dongguan Guanshang Electronics Co., Ltd.
+1b88  ShenMing Electron (Dong Guan) Co., Ltd.
+1b8c  Altium Limited
+1b8d  e-MOVE Technology Co., Ltd.
+1b8e  Amlogic, Inc.
+1b8f  MA LABS, Inc.
+1b98  YMax Communications Corp.
+1b99  Shenzhen Yuanchuan Electronic
+1ba1  JINQ CHERN ENTERPRISE CO., LTD.
+1ba2  Lite Metals & Plastic (Shenzhen) Co., Ltd.
+1ba4  Ember Corporation
+       0001  InSight USB Link
+1ba8  China Telecommunication Technology Labs
+1bad  Harmonix Music
+       0002  Harmonix Guitar for Xbox 360
+       0003  Harmonix Drum Kit for Xbox 360
+1bbb  T & A Mobile Phones
+1bc4  Ford Motor Co.
+1bc5  AVIXE Technology (China) Ltd.
+1bce  Contac Cable Industrial Limited
+1bcf  Sunplus Innovation Technology Inc.
+1bd0  Hangzhou Riyue Electronic Co., Ltd.
+1bde  P-TWO INDUSTRIES, INC.
+1bef  Shenzhen Tongyuan Network-Communication Cables Co., Ltd
+1bf0  RealVision Inc.
+1bf5  Extranet Systems Inc.
+1bf6  Orient Semiconductor Electronics, Ltd.
+1bfd  TouchPack
+       1688  Resistive Touch Screen
+1c02  Kreton Corporation
+1c04  QNAP System Inc.
+1c0d  Relm Wireless
+1c10  Lanterra Industrial Co., Ltd.
+1c13  ALECTRONIC LIMITED
+1c1a  Datel Electronics Ltd.
+1c1b  Volkswagen of America, Inc.
+1c1f  Goldvish S.A.
+1c20  Fuji Electric Device Technology Co., Ltd.
+1c21  ADDMM LLC
+1c22  ZHONGSHAN CHIANG YU ELECTRIC CO., LTD.
+1c26  Shanghai Haiying Electronics Co., Ltd.
+1c27  HuiYang D & S Cable Co., Ltd.
+1c31  LS Cable Ltd.
+1c37  Authorizer Technologies, Inc.
+1c3d  NONIN MEDICAL INC.
+1c3e  Wep Peripherals
+1c49  Cherng Weei Technology Corp.
+1c6b  Philips & Lite-ON Digital Solutions Corporation
+1c6c  Skydigital Inc.
+1c77  Kaetat Industrial Co., Ltd.
+1c78  Datascope Corp.
+1c79  Unigen Corporation
+1c7a  LighTuning Technology Inc.
+1c7b  LUXSHARE PRECISION INDUSTRY (SHENZHEN) CO., LTD.
+1c87  2N TELEKOMUNIKACE a.s.
+1c88  Somagic, Inc.
+1c89  HONGKONG WEIDIDA ELECTRON LIMITED
+1c8e  ASTRON INTERNATIONAL CORP.
+1c98  ALPINE ELECTRONICS, INC.
+1ca0  ACCARIO Inc.
+1cb3  Aces Electronic Co., Ltd.
+1cb4  OPEX CORPORATION
+1cbe  Luminary Micro Inc.
+1cbf  FORTAT SKYMARK INDUSTRIAL COMPANY
+1cc0  PlantSense
+1cca  NextWave Broadband Inc.
+1ccd  Bodatong Technology (Shenzhen) Co., Ltd.
+1cd4  adp corporation
+1cd5  Firecomms Ltd.
+1cd6  Antonio Precise Products Manufactory Ltd.
+1cde  Telecommunications Technology Association (TTA)
+1cdf  WonTen Technology Co., Ltd.
+1ce0  EDIMAX TECHNOLOGY CO., LTD.
+1ce1  Amphenol KAE
+1cfc  ANDES TECHNOLOGY CORPORATION
+1cfd  Flextronics Digital Design Japan, LTD.
+1d08  NINGBO HENTEK DRAGON ELECTRONICS CO., LTD.
+1d09  TechFaith Wireless Technology Limited
+1d0a  Johnson Controls, Inc. The Automotive Business Unit
+1d0b  HAN HUA CABLE & WIRE TECHNOLOGY (J.X.) CO., LTD.
+1d14  ALPHA-SAT TECHNOLOGY LIMITED
+1d1f  Diostech Co., Ltd.
+1d20  SAMTACK INC.
+1d50  OpenMoko, Inc.
+1d5b  Smartronix, Inc.
+1d6b  Linux Foundation
+       0001  1.1 root hub
+       0002  2.0 root hub
+       0003  3.0 root hub
+1ebb  NuCORE Technology, Inc.
+2001  D-Link Corp. [hex]
+       0001  DWL-120 WIRELESS ADAPTER
+       0201  DHN-120 10Mb Home Phoneline Adapter
+       1a00  10/100 Ethernet
+       200c  10/100 Ethernet
+       3200  DWL-120 802.11b (Atmel RFMD503A) [usbvnetr]
+       3500  Elitegroup Computer Systems WLAN card WL-162
+       3700  DWL-122 802.11b
+       3701  DWL-G120 Spinnaker 802.11b
+       3702  DWL-120 rev F
+       3703  DWL-122 802.11b
+       3704  DWL-G122 802.11g rev. A2
+       3705  AirPlus G DWL-G120 Wireless Adapter(rev.C)
+       3761  IEEE 802.11g USB2.0 Wireless Network Adapter-PN
+       3a00  DWL-AG132
+       3a01  DWL-AG132 (no firmware)
+       3a02  DWL-G132
+       3a03  DWL-G132 (no firmware)
+       3a04  DWL-AG122
+       3a05  DWL-AG122 (no firmware)
+       3a80  AirPlus Xtreme G DWL-G132 Wireless Adapter
+       3a81  predator Bootloader Download
+       3a82  AirPremier AG DWL-AG132 Wireless Adapter
+       3a83  predator Bootloader Download
+       3b00  AirPlus DWL-120+ Wireless Adapter
+       3b01  WLAN Boot Device
+       3c00  DWL-G122 802.11g rev. B1 [ralink]
+       3c01  AirPlus AG DWL-AG122 Wireless Adapter
+       3c02  AirPlus G DWL-G122 Wireless Adapter
+       3c05  DUB-E100 Fast Ethernet [asix]
+       4000  DSB-650C Ethernet [klsi]
+       4001  DSB-650TX Ethernet [pegasus]
+       4002  DSB-650TX Ethernet [pegasus]
+       4003  DSB-650TX-PNA Ethernet [pegasus]
+       400b  10/100 Ethernet
+       4102  10/100 Ethernet
+       5100  DSL-200 ADSL ATM Modem
+       5102  DSL-200 ADSL Loader
+       5b00  Remote NDIS Network Device
+       9414  Cable Modem
+       9b00  Broadband Cable Modem Remote NDIS Device
+       abc1  DSB-650 Ethernet [pegasus]
+       f013  DLink 7 port USB2.0 Hub
+       f10d  Accent Communications Modem
+       f110  DUB-AV300 A/V Capture
+       f111  DBT-122 Bluetooth adapter
+       f112  DUB-T210 Audio Device
+       f116  Formosa 2
+       f117  Formosa 3
+       f118  Formosa 4
+2019  PLANEX
+       3220  GW-US11S WLAN
+       5303  GW-US54GXS
+       ab01  GW-US54HP
+       ab50  GW-US54Mini2
+       c002  GW-US54SG
+       c007  GW-US54GZL
+       ed02  GW-USMM
+2040  Hauppauge
+       6502  WinTV HVR-900
+       6503  WinTV HVR-930
+       7050  Nova-T Stick
+       9300  WinTV NOVA-T USB2 (cold)
+       9301  WinTV NOVA-T USB2 (warm)
+2101  ActionStar
+       0201  SIIG 4-to-2 Printer Switch
+2162  Creative (?)
+       2031  Network Blaster Wireless Adapter
+       500c  DE5771 Modem Blaster
+       8001  Broadxent BritePort DSL Bridge 8010U
+2222  MacAlly
+       0004  iWebKey Keyboard
+       4050  AirStick joystick
+2233  RadioShack Corporation
+       6323  USB Electronic Scale
+22b8  Motorola PCS
+       0001  Wally 2.2 chipset
+       0002  Wally 2.4 chipset
+       0005  V.60c/V.60i GSM Phone
+       0850  Bluetooth Device
+       1001  Patriot 1.0 (GSM) chipset
+       1002  Patriot 2.0 chipset
+       1005  T280e GSM/GPRS Phone
+       1101  Patriot 1.0 (TDMA) chipset
+       1801  Rainbow chipset flash
+       2035  Bluetooth Device
+       2805  GSM Modem
+       2821  T720 GSM Phone
+       2822  V.120e GSM Phone
+       2823  Flash Interface
+       2a01  MSM6050 chipset
+       2a02  CDMA modem
+       2a03  MSM6050 chipset flash
+       2a21  V710 GSM Phone (P2K)
+       2a22  V710 GSM Phone (AT)
+       2a23  MSM6100 chipset flash
+       2a41  MSM6300 chipset
+       2a42  Usb Modem
+       2a43  MSM6300 chipset flash
+       2a61  E815 GSM Phone (P2K)
+       2a62  E815 GSM Phone (AT)
+       2a63  MSM6500 chipset flash
+       2a81  MSM6025 chipset
+       2a83  MSM6025 chipset flash
+       2ac1  MSM6100 chipset
+       2ac3  MSM6100 chipset flash
+       3001  A835/E1000 GSM Phone (P2K)
+       3002  A835/E1000 GSM Phone (AT)
+       3801  C350L/C450 (P2K)
+       3802  C330/C350L/C450/EZX GSM Phone (AT)
+       3803  Neptune LT chipset flash
+       4001  OMAP 1.0 chipset
+       4002  A920/A925 UMTS Phone
+       4003  OMAP 1.0 chipset flash
+       4008  OMAP 1.0 chipset RDL
+       4204  MPx200 Smartphone
+       4214  MPc GSM
+       4224  MPx220 Smartphone
+       4234  MPc CDMA
+       4244  MPx100 Smartphone
+       4801  Neptune LTS chipset
+       4803  Neptune LTS chipset flash
+       4810  Triplet GSM Phone (storage)
+       4901  Triplet GSM Phone (P2K)
+       4902  Triplet GSM Phone (AT)
+       4903  Neptune LTE chipset flash
+       4a01  Neptune LTX chipset
+       4a03  Neptune LTX chipset flash
+       4a32  L6-imode Phone
+       5801  Neptune ULS chipset
+       5803  Neptune ULS chipset flash
+       5901  Neptune VLT chipset
+       5903  Neptune VLT chipset flash
+       6001  Dalhart EZX
+       6003  Dalhart flash
+       6004  EZX GSM Phone (CDC Net)
+       6008  Dalhart RDL
+       6009  EZX GSM Phone (P2K)
+       600a  Dalhart EZX config 17
+       600b  Dalhart EZX config 18
+       600c  EZX GSM Phone (USBLAN)
+       6021  JUIX chipset
+       6023  JUIX chipset flash
+       6026  Flash RAM Downloader/miniOS
+       6027  USBLAN
+       604c  EZX GSM Phone (Storage)
+       6101  Talon integrated chipset
+       6401  Argon chipset
+       6403  Argon chipset flash
+       6415  ROKR Z6 (MTP mode)
+       6604  Washington CDMA Phone
+       6631  CDC Modem
+22b9  eTurboTouch Technology, Inc.
+22ba  Technology Innovation Holdings, Ltd
+2304  Pinnacle Systems, Inc. [hex]
+       0109  Studio PCTV USB (SECAM)
+       0110  Studio PCTV USB (PAL)
+       0111  Miro PCTV USB
+       0112  Studio PCTV USB (NTSC) with FM radio
+       0201  Systems MovieBox Device
+       0204  MovieBox USB_B
+       0205  DVC 150B
+       0206  Systems MovieBox Deluxe Device
+       0207  Dazzle DVC90 Video Device
+       0208  Studio PCTV USB2
+       020e  PCTV 200e
+       020f  PCTV 400e BDA Device
+       0210  Studio PCTV USB (PAL) with FM radio
+       0212  Studio PCTV USB (NTSC)
+       0213  500-USB Device
+       0214  Studio PCTV USB (PAL) with FM radio
+       0216  PCTV 60e
+       0219  PCTV 260e
+       021a  Dazzle DVC100 Audio Device
+       021b  Dazzle DVC130/DVC170
+       021d  Dazzle DVC130
+       021e  Dazzle DVC170
+       021f  PCTV Sat HDTV Pro BDA Device
+       0222  PCTV Sat Pro BDA Device
+       0223  DazzleTV Sat BDA Device
+       0226  PCTV 330e
+       0227  PCTV for Mac, HD Stick
+       0228  PCTV DVB-T Flash Stick
+       022a  PCTV 160e
+       022b  PCTV 71e
+       0232  PCTV 170e
+       0300  Studio Linx Video input cable (NTSC)
+       0301  Studio Linx Video input cable (PAL)
+       0302  Dazzle DVC120
+       0419  PCTV Bungee USB (PAL) with FM radio
+       061d  PCTV Deluxe (NTSC) Device
+       061e  PCTV Deluxe (PAL) Device
+2318  Shining Technologies, Inc. [hex]
+       0011  CitiDISK Jr. IDE Enclosure
+2375  Digit@lway, Inc.
+       0001  Digital Audio Player
+2406  SANHO Digital Electronics Co., Ltd.
+       6688  PD7X Portable Storage
+2478  Tripp-Lite
+       2008  U209-000-R Serial Port
+2632  TwinMOS
+       3209  7-in-1 Card Reader
+2650  Electronics For Imaging, Inc. [hex]
+2730  Citizen
+       200f  CT-S310 Label printer
+2735  DigitalWay
+       0003  MPIO 1.5GB Hard Disc Drive
+2770  NHJ, Ltd
+       0a01  ScanJet 4600 series
+       905c  Che-Ez Snap SNAP-U/Digigr8/Soundstar TDC-35
+       9060  A130
+       9120  Che-ez! Snap / iClick Tiny VGA Digital Camera
+       9130  TCG 501
+       913c  Argus DC-1730
+       9150  Mini Cam
+       9153  iClick 5X
+       915d  Cyberpix S-210S / Little Tikes My Real Digital Camera
+       930b  CCD Webcam(PC370R)
+       930c  CCD Webcam(PC370R)
+2899  Toptronic Industrial Co., Ltd
+2c02  Planex Communications
+       14ea  GW-US11H WLAN
+2fb2  Fujitsu, Ltd
+3125  Eagletron
+       0001  TrackerPod Camera Stand
+3176  Whanam Electronics Co., Ltd
+3275  VidzMedia Pte Ltd
+       4fb1  MonsterTV P2H
+3334  AEI
+       1701  Fast Ethernet
+3340  Yakumo
+       043a  Mio A701 DigiWalker PPCPhone
+       0e3a  Pocket PC 300 GPS SL / Typhoon MyGuide 3500
+       a0a3  deltaX 5 BT (D) PDA
+3504  Micro Star
+       f110  Security Key
+3538  Power Quotient International Co., Ltd
+       0001  Travel Flash
+       0015  Mass Storge Device
+       0022  Hi-Speed Mass Storage Device
+       0042  Cool Drive U339 Flash Disk
+3579  DIVA
+       6901  Media Reader
+3636  InVibro
+3838  WEM
+       0001  5-in-1 Card Reader
+3923  National Instruments Corp.
+       12c0  DAQPad-6020E
+       12d0  DAQPad-6507
+       12e0  NI 4350
+       12f0  NI 5102
+       1750  DAQPad-6508
+       17b0  USB-ISA-Bridge
+       1820  DAQPad-6020E (68 pin I/O)
+       1830  DAQPad-6020E (BNC)
+       1f00  DAQPad-6024E
+       1f10  DAQPad-6024E
+       1f20  DAQPad-6025E
+       1f30  DAQPad-6025E
+       1f40  DAQPad-6036E
+       1f50  DAQPad-6036E
+       2f80  DAQPad-6052E
+       2f90  DAQPad-6052E
+       703c  USB-485 RS485 Cable
+       7254  NI MIO (data acquisition card) firmware updater
+       729e  USB-6251 (OEM) data acquisition card
+40bb  I-O Data
+       0a09  USB2.0-SCSI Bridge USB2-SC
+4101  i-rocks
+       1301  IR-2510 usb phone
+4102  iRiver, Ltd.
+       1001  iFP-100 series mp3 player
+       1003  iFP-300 series mp3 player
+       1005  iFP-500 series mp3 player
+       1007  iFP-700 series mp3/ogg vorbis player
+       1008  iFP-800 series mp3/ogg vorbis player
+       100a  iFP-1000 series mp3/ogg vorbis player
+       1014  T20 series mp3/ogg vorbis player (ums firmware)
+       1101  iFP-100 series mp3 player (ums firmware)
+       1103  iFP-300 series mp3 player (ums firmware)
+       1105  iFP-500 series mp3 player (ums firmware)
+       1113  T10 (alternate)
+       1117  T10
+       1119  T30 series mp3/ogg/wma player
+       2002  H10 6GB
+       2101  H10 20GB (mtp)
+       2102  H10 5GB (mtp)
+       2105  H10 5/6GB (mtp)
+413c  Dell Computer Corp.
+       0058  Port Replicator
+       1001  Keyboard Hub
+       1002  Keyboard Hub
+       2001  Keyboard HID Support
+       2002  SK-8125 Keyboard
+       2003  Keyboard
+       2005  RT7D50 Keyboard
+       2100  SK-3106 Keyboard
+       2101  SmartCard Reader Keyboard
+       2500  DRAC4 Remote Access Card
+       3010  Optical Wheel Mouse
+       3200  Mouse
+       4001  Axim X5
+       4002  Axim X3
+       4003  Axim X30
+       4004  Axim Sync
+       4005  Axim Sync
+       4006  Axim Sync
+       4007  Axim Sync
+       4008  Axim Sync
+       4009  Axim Sync
+       4011  Axim X51v
+       5103  AIO Printer A940
+       5105  AIO Printer A920
+       5107  AIO Printer A960
+       5109  Photo AIO Printer 922
+       5110  Photo AIO Printer 962
+       5111  Photo AIO Printer 942
+       5112  Photo AIO Printer 924
+       5113  Photo AIO Printer 944
+       5114  Photo AIO Printer 964
+       5115  Photo AIO Printer 926
+       5116  AIO Printer 946
+       5117  Photo AIO Printer 966
+       5118  AIO 810
+       5124  Laser MFP 1815
+       5128  Photo AIO 928
+       5200  Laser Printer
+       5202  Printing Support
+       5203  Printing Support
+       5210  Printing Support
+       5211  Printing Support
+       5220  Laser MFP 1600n
+       5225  Printing Support
+       5226  Printing Support
+       5300  Laser Printer
+       5400  Laser Printer
+       5401  Laser Printer
+       5601  Laser Printer 3100cn
+       5602  Laser Printer 3000cn
+       5631  Laser Printer 5100cn
+       5905  Printing Support
+       8000  BC02 Bluetooth USB Adapter
+       8010  TrueMobile Bluetooth Module in
+       8100  TrueMobile 1180 802.11b Adapter
+       8102  TrueMobile 1300 USB2.0 WLAN Card
+       8103  Wireless 350 Bluetooth
+       8104  Wireless 1450 Dual-band (802.11a/b/g) USB2.0 Adapter
+       8105  U2 in HID - Driver
+       8106  Wireless 350 Bluetooth Internal Card in
+       8110  Wireless 3xx Bluetooth Internal Card
+       8111  Wireless 3xx Bluetooth Internal Card in
+       8114  Wireless 5700 Mobile Broadband (CDMA EV-DO) Minicard Modem
+       8115  Wireless 5500 Mobile Broadband (3G HSDPA) Minicard Modem
+       8116  Wireless 5505 Mobile Broadband (3G HSDPA) Minicard Modem
+       8117  Wireless 5700 Mobile Broadband (CDMA EV-DO) Expresscard Modem
+       8118  Wireless 5510 Mobile Broadband (3G HSDPA) Expresscard Status Port
+       8120  Bluetooth adapter
+       8121  Eastfold in HID
+       8122  Eastfold in DFU
+       8123  eHome Infrared Receiver
+       8124  eHome Infrared Receiver
+       8126  Wireless 355 Bluetooth
+       8127  Wireless 355 Module with Bluetooth 2.0 + EDR Technology.
+       8128  Wireless 5700-Sprint Mobile Broadband (CDMA EV-DO) Mini-Card Status Port
+       8129  Wireless 5700-Telus Mobile Broadband (CDMA EV-DO) Mini-Card Status Port
+       8131  Wireless 360 Bluetooth 2.0 + EDR module.
+       8133  Wireless 5720 VZW Mobile Broadband (EVDO Rev-A) Minicard GPS Port
+       8134  Wireless 5720 Sprint Mobile Broadband (EVDO Rev-A) Minicard Status Port
+       8135  Wireless 5720 TELUS Mobile Broadband (EVDO Rev-A) Minicard Diagnostics Port
+       8136  Wireless 5520 Cingular Mobile Broadband (3G HSDPA) Minicard Diagnostics Port
+       8137  Wireless 5520 Voda L Mobile Broadband (3G HSDPA) Minicard Status Port
+       8138  Wireless 5520 Voda I Mobile Broadband (3G HSDPA) Minicard EAP-SIM Port
+       8140  Wireless 360 Bluetooth
+       8142  Mobile 360 in DFU
+       8501  Bluetooth Adapter
+       a001  Hub
+       a005  Internal 2.0 Hub
+       a700  Hub (in 1905FP LCD Monitor)
+4146  USBest Technology
+       9281  Iomega Micro Mini 128MB Flash Drive
+       ba01  Intuix Flash Drive
+4242  USB Design by Example
+       4201  Buttons and Lights HID device
+       4220  Echo 1 Camera
+4348  WinChipHead
+       5523  USB->RS 232 adapter with Prolifec PL 2303 chipset
+       5537  13.56Mhz RFID Card Reader and Writer
+       5584  CH34x printer adapter cable
+4572  Shuttle, Inc.
+       4572  Shuttle PN31 Remote
+4586  Panram
+       1026  Crystal Bar Flash Drive
+4670  EMS Production
+       9394  Game Cube USB Memory Adaptor 64M
+4752  Miditech
+       0011  Midistart-2
+4766  Aceeca
+       0001  MEZ1000 RDA
+4855  Memorex
+       7288  Ultra Traveldrive 160G 2.5" HDD
+5032  Grandtec
+       0bb8  Grandtec USB1.1 DVB-T (cold)
+       0bb9  Grandtec USB1.1 DVB-T (warm)
+       0fa0  Grandtec USB1.1 DVB-T (cold)
+       0fa1  Grandtec USB1.1 DVB-T (warm)
+5041  Linksys (?)
+       2234  WUSB54G 802.11g Adapter
+5173  Sweex
+       1809  ZD1211
+5345  Owon
+       1234  PDS6062T Oscilloscope
+544d  Transmeta Corp.
+5543  UC-Logic Technology Corp.
+       0002  SuperPen WP3325U Tablet
+       0003  Genius MousePen 4x3 Tablet/Aquila L1 Tablet
+       0004  Genius MousePen 5x4 Tablet
+       0005  Genius MousePen 8x6 Tablet
+       0041  Genius PenSketch 6x8 Tablet
+       0042  Genius PenSketch 12x9 Tablet
+55aa  OnSpec Electronic, Inc.
+       0015  Hard Drive
+       0102  SuperDisk
+       0103  IDE Hard Drive
+       0201  DDI to Reader-19
+       1234  ATAPI Bridge
+       a103  Sandisk SDDR-55 SmartMedia Card Reader
+       b000  USB to CompactFlash Card Reader
+       b004  OnSpec MMC/SD Reader/Writer
+       b00b  USB to Memory Stick Card Reader
+       b00c  USB to SmartMedia Card Reader
+       b012  Mitsumi FA402M 8-in-2 Card Reader
+       b200  Compact Flash Reader
+       b204  MMC/ SD Reader
+       b207  Memory Stick Reader
+5986  Acer, Inc
+       0102  Crystal Eye webcam
+5a57  Zinwell
+       0260  RT2570
+6189  Sitecom
+       182d  USB 2.0 Ethernet
+       2068  USB to serial cable (v2)
+6253  TwinHan Technology Co., Ltd
+       0100  Ir reciver f. remote control
+636c  CoreLogic, Inc.
+6547  Arkmicro Technologies Inc.
+       0232  ARK3116 Serial
+6666  Prototype product Vendor ID
+       0667  WiseGroup Smart Joy PSX, PS-PC Smart JoyPad
+       2667  JCOP BlueZ Smartcard reader
+       8804  WiseGroup SuperJoy Box 5
+6891  3Com
+       a727  3CRUSB10075
+6993  Freshtel
+       b001  FT-102 VoIP USB Phone
+6a75  Shanghai Jujo Electronics Co., Ltd
+7104  CME (Central Music Co.)
+       2202  UF5/UF6/UF7/UF8 MIDI Master Keyboard
+8086  Intel Corp.
+       0001  AnyPoint (TM) Home Network 1.6 Mbps Wireless Adapter
+       0100  Personal Audio Player 3000
+       0101  Personal Audio Player 3000
+       0110  Easy PC Camera
+       0120  PC Camera CS120
+       0200  AnyPoint(TM) Wireless II Network 11Mbps Adapter
+       0431  Intel Pro Video PC Camera
+       0510  Digital Movie Creator
+       0630  Pocket PC Camera
+       0780  CS780 Microphone Input
+       07d3  BLOB boot loader firmware
+       0dad  Cherry MiniatureCard Keyboard
+       1010  AnyPoint(TM) Home Network 10 Mbps Phoneline Adapter
+       110a  Bluetooth Controller from (Ericsson P4A)
+       110b  Bluetooth Controller from (Intel/CSR)
+       1110  PRO/Wireless LAN Module
+       1111  PRO/Wireless 2011B 802.11b Adapter
+       1134  Hollister Mobile Monitor
+       1234  Prototype Reader/Writer
+       3100  PRO/DSL 3220 Modem - WAN
+       3101  PRO/DSL 3220 Modem
+       3240  AnyPoint® 3240 Modem - WAN
+       3241  AnyPoint® 3240 Modem
+       8602  Miniature Card Slot
+       9303  Intel 8x930Hx Hub
+       9890  82930 Test Board
+       beef  SCM Miniature Card Reader/Writer
+       c013  Wireless HID Station
+       f001  XScale PXA27x Bulverde flash
+8341  EGO Systems, Inc.
+       2000  Flashdisk
+9016  Sitecom
+       182d  WL-022
+9710  MosChip Semiconductor
+       7703  MCS7703 Serial Port Adapter
+       7705  Printer cable
+       7715  Printer cable
+       7780  MS7780 4Mbps Fast IRDA Adapter
+       7830  MCS7830 Ethernet
+a727  3Com
+       6893  AR5523
+       6895  AR5523
+       6897  AR5523
+c251  Keil Software, Inc.
+       2710  ULink
+eb1a  eMPIA Technology, Inc.
+       17de  KWorld V-Stream XPERT DTV - DVB-T USB cold
+       17df  KWorld V-Stream XPERT DTV - DVB-T USB warm
+       2710  SilverCrest WebCam
+       2750  ECS Elitegroup G220 integrated webcam
+       2800  Terratec Cinergy 200
+       2801  GrabBeeX+ Video Encoder
+f003  Hewlett Packard
+       6002  PhotoSmart C500
+
+# List of known device classes, subclasses and protocols
+
+# Syntax:
+# C class  class_name
+#      subclass  subclass_name                 <-- single tab
+#              protocol  protocol_name         <-- two tabs
+
+C 00  (Defined at Interface level)
+C 01  Audio
+       01  Control Device
+       02  Streaming
+       03  MIDI Streaming
+C 02  Communications
+       01  Direct Line
+       02  Abstract (modem)
+               00  None
+               01  AT-commands (v.25ter)
+               02  AT-commands (PCCA101)
+               03  AT-commands (PCCA101 + wakeup)
+               04  AT-commands (GSM)
+               05  AT-commands (3G)
+               06  AT-commands (CDMA)
+               fe  Defined by command set descriptor
+               ff  Vendor Specific (MSFT RNDIS?)
+       03  Telephone
+       04  Multi-Channel
+       05  CAPI Control
+       06  Ethernet Networking
+       07  ATM Networking
+       08  Wireless Handset Control
+       09  Device Management
+       0a  Mobile Direct Line
+       0b  OBEX
+       0c  Ethernet Emulation
+               07  Ethernet Emulation (EEM)
+C 03  Human Interface Device
+       00  No Subclass
+               00  None
+               01  Keyboard
+               02  Mouse
+       01  Boot Interface Subclass
+               00  None
+               01  Keyboard
+               02  Mouse
+C 05  Physical Interface Device
+C 06  Imaging
+       01  Still Image Capture
+               01  Picture Transfer Protocol (PIMA 15470)
+C 07  Printer
+       01  Printer
+               00  Reserved/Undefined
+               01  Unidirectional
+               02  Bidirectional
+               03  IEEE 1284.4 compatible bidirectional
+               ff  Vendor Specific
+C 08  Mass Storage
+       01  RBC (typically Flash)
+               00  Control/Bulk/Interrupt
+               01  Control/Bulk
+               50  Bulk (Zip)
+       02  SFF-8020i, MMC-2 (ATAPI)
+       03  QIC-157
+       04  Floppy (UFI)
+               00  Control/Bulk/Interrupt
+               01  Control/Bulk
+               50  Bulk (Zip)
+       05  SFF-8070i
+       06  SCSI
+               00  Control/Bulk/Interrupt
+               01  Control/Bulk
+               50  Bulk (Zip)
+C 09  Hub
+       00  Unused
+               00  Full speed (or root) hub
+               01  Single TT
+               02  TT per port
+C 0a  CDC Data
+       00  Unused
+               30  I.430 ISDN BRI
+               31  HDLC
+               32  Transparent
+               50  Q.921M
+               51  Q.921
+               52  Q.921TM
+               90  V.42bis
+               91  Q.932 EuroISDN
+               92  V.120 V.24 rate ISDN
+               93  CAPI 2.0
+               fd  Host Based Driver
+               fe  CDC PUF
+               ff  Vendor specific
+C 0b  Chip/SmartCard
+C 0d  Content Security
+C 0e  Video
+       00  Undefined
+       01  Video Control
+       02  Video Streaming
+       03  Video Interface Collection
+C dc  Diagnostic
+       01  Reprogrammable Diagnostics
+               01  USB2 Compliance
+C e0  Wireless
+       01  Radio Frequency
+               01  Bluetooth
+               02  Ultra WideBand Radio Control
+               03  RNDIS
+       02  Wireless USB Wire Adapter
+               01  Host Wire Adapter Control/Data Streaming
+               02  Device Wire Adapter Control/Data Streaming
+               03  Device Wire Adapter Isochronous Streaming
+C ef  Miscellaneous Device
+       01  ?
+               01  Microsoft ActiveSync
+               02  Palm Sync
+       02  ?
+               01  Interface Association
+               02  Wire Adapter Multifunction Peripheral
+       03  ?
+               01  Cable Based Association
+C fe  Application Specific Interface
+       01  Device Firmware Update
+       02  IRDA Bridge
+       03  Test and Measurement
+               01  TMC
+               02  USB488
+C ff  Vendor Specific Class
+       ff  Vendor Specific Subclass
+               ff  Vendor Specific Protocol
+
+# List of Audio Class Terminal Types
+
+# Syntax:
+# AT terminal_type  terminal_type_name
+
+AT 0100  USB Undefined
+AT 0101  USB Streaming
+AT 01ff  USB Vendor Specific
+AT 0200  Input Undefined
+AT 0201  Microphone
+AT 0202  Desktop Microphone
+AT 0203  Personal Microphone
+AT 0204  Omni-directional Microphone
+AT 0205  Microphone Array
+AT 0206  Processing Microphone Array
+AT 0300  Output Undefined
+AT 0301  Speaker
+AT 0302  Headphones
+AT 0303  Head Mounted Display Audio
+AT 0304  Desktop Speaker
+AT 0305  Room Speaker
+AT 0306  Communication Speaker
+AT 0307  Low Frequency Effects Speaker
+AT 0400  Bidirectional Undefined
+AT 0401  Handset
+AT 0402  Headset
+AT 0403  Speakerphone, no echo reduction
+AT 0404  Echo-suppressing speakerphone
+AT 0405  Echo-canceling speakerphone
+AT 0500  Telephony Undefined
+AT 0501  Phone line
+AT 0502  Telephone
+AT 0503  Down Line Phone
+AT 0600  External Undefined
+AT 0601  Analog Connector
+AT 0602  Digital Audio Interface
+AT 0603  Line Connector
+AT 0604  Legacy Audio Connector
+AT 0605  SPDIF interface
+AT 0606  1394 DA stream
+AT 0607  1394 DV stream soundtrack
+AT 0700  Embedded Undefined
+AT 0701  Level Calibration Noise Source
+AT 0702  Equalization Noise
+AT 0703  CD Player
+AT 0704  DAT
+AT 0705  DCC
+AT 0706  MiniDisc
+AT 0707  Analog Tape
+AT 0708  Phonograph
+AT 0709  VCR Audio
+AT 070a  Video Disc Audio
+AT 070b  DVD Audio
+AT 070c  TV Tuner Audio
+AT 070d  Satellite Receiver Audio
+AT 070e  Cable Tuner Audio
+AT 070f  DSS Audio
+AT 0710  Radio Receiver
+AT 0711  Radio Transmitter
+AT 0712  Multitrack Recorder
+AT 0713  Synthesizer
+
+# List of HID Descriptor Types
+
+# Syntax:
+# HID descriptor_type  descriptor_type_name
+
+HID 21  HID
+HID 22  Report
+HID 23  Physical
+
+# List of HID Descriptor Item Types
+# Note: 2 bits LSB encode data length following
+
+# Syntax:
+# R item_type  item_type_name
+
+# Main Items
+R 80  Input
+R 90  Output
+R b0  Feature
+R a0  Collection
+R c0  End Collection
+
+# Global Items
+R 04  Usage Page
+R 14  Logical Minimum
+R 24  Logical Maximum
+R 34  Physical Minimum
+R 44  Physical Maximum
+R 54  Unit Exponent
+R 64  Unit
+R 74  Report Size
+R 84  Report ID
+R 94  Report Count
+R a4  Push
+R b4  Pop
+
+# Local Items
+R 08  Usage
+R 18  Usage Minimum
+R 28  Usage Maximum
+R 38  Designator Index
+R 48  Designator Minimum
+R 58  Designator Maximum
+R 78  String Index
+R 88  String Minimum
+R 98  String Maximum
+R a8  Delimiter
+
+# List of Physical Descriptor Bias Types
+
+# Syntax:
+# BIAS item_type  item_type_name
+
+BIAS 0  Not Applicable
+BIAS 1  Right Hand
+BIAS 2  Left Hand
+BIAS 3  Both Hands
+BIAS 4  Either Hand
+
+# List of Physical Descriptor Item Types
+
+# Syntax:
+# PHY item_type  item_type_name
+
+PHY 00  None
+PHY 01  Hand
+PHY 02  Eyeball
+PHY 03  Eyebrow
+PHY 04  Eyelid
+PHY 05  Ear
+PHY 06  Nose
+PHY 07  Mouth
+PHY 08  Upper Lip
+PHY 09  Lower Lip
+PHY 0a  Jaw
+PHY 0b  Neck
+PHY 0c  Upper Arm
+PHY 0d  Elbow
+PHY 0e  Forearm
+PHY 0f  Wrist
+PHY 10  Palm
+PHY 11  Thumb
+PHY 12  Index Finger
+PHY 13  Middle Finger
+PHY 14  Ring Finger
+PHY 15  Little Finger
+PHY 16  Head
+PHY 17  Shoulder
+PHY 18  Hip
+PHY 19  Waist
+PHY 1a  Thigh
+PHY 1b  Knee
+PHY 1c  calf
+PHY 1d  Ankle
+PHY 1e  Foot
+PHY 1f  Heel
+PHY 20  Ball of Foot
+PHY 21  Big Toe
+PHY 22  Second Toe
+PHY 23  Third Toe
+PHY 24  Fourth Toe
+PHY 25  Fifth Toe
+PHY 26  Brow
+PHY 27  Cheek
+
+# List of HID Usages
+
+# Syntax:
+# HUT hi  _usage_page  hid_usage_page_name
+#      hid_usage  hid_usage_name
+
+HUT 00  Undefined
+HUT 01  Generic Desktop Controls
+       000  Undefined
+       001  Pointer
+       002  Mouse
+       004  Joystick
+       005  Gamepad
+       006  Keyboard
+       007  Keypad
+       008  Multi-Axis Controller
+       030  Direction-X
+       031  Direction-Y
+       032  Direction-Z
+       033  Rotate-X
+       034  Rotate-Y
+       035  Rotate-Z
+       036  Slider
+       037  Dial
+       038  Wheel
+       039  Hat Switch
+       03a  Counted Buffer
+       03b  Byte Count
+       03c  Motion Wakeup
+       03d  Start
+       03e  Select
+       040  Vector-X
+       041  Vector-Y
+       042  Vector-Z
+       043  Vector-X relative Body
+       044  Vector-Y relative Body
+       045  Vector-Z relative Body
+       046  Vector
+       080  System Control
+       081  System Power Down
+       082  System Sleep
+       083  System Wake Up
+       084  System Context Menu
+       085  System Main Menu
+       086  System App Menu
+       087  System Menu Help
+       088  System Menu Exit
+       089  System Menu Select
+       08a  System Menu Right
+       08b  System Menu Left
+       08c  System Menu Up
+       08d  System Menu Down
+       090  Direction Pad Up
+       091  Direction Pad Down
+       092  Direction Pad Right
+       093  Direction Pad Left
+HUT 02  Simulation Controls
+       000  Undefined
+       001  Flight Simulation Device
+       002  Automobile Simulation Device
+       003  Tank Simulation Device
+       004  Spaceship Simulation Device
+       005  Submarine Simulation Device
+       006  Sailing Simulation Device
+       007  Motorcycle Simulation Device
+       008  Sports Simulation Device
+       009  Airplane Simualtion Device
+       00a  Helicopter Simulation Device
+       00b  Magic Carpet Simulation Device
+       00c  Bicycle Simulation Device
+       020  Flight Control Stick
+       021  Flight Stick
+       022  Cyclic Control
+       023  Cyclic Trim
+       024  Flight Yoke
+       025  Track Control
+       0b0  Aileron
+       0b1  Aileron Trim
+       0b2  Anti-Torque Control
+       0b3  Autopilot Enable
+       0b4  Chaff Release
+       0b5  Collective Control
+       0b6  Dive Break
+       0b7  Electronic Countermeasures
+       0b8  Elevator
+       0b9  Elevator Trim
+       0ba  Rudder
+       0bb  Throttle
+       0bc  Flight COmmunications
+       0bd  Flare Release
+       0be  Landing Gear
+       0bf  Toe Break
+       0c0  Trigger
+       0c1  Weapon Arm
+       0c2  Weapons Select
+       0c3  Wing Flaps
+       0c4  Accelerator
+       0c5  Brake
+       0c6  Clutch
+       0c7  Shifter
+       0c8  Steering
+       0c9  Turret Direction
+       0ca  Barrel Elevation
+       0cb  Drive Plane
+       0cc  Ballast
+       0cd  Bicylce Crank
+       0ce  Handle Bars
+       0cf  Front Brake
+       0d0  Rear Brake
+HUT 03  VR Controls
+       000  Unidentified
+       001  Belt
+       002  Body Suit
+       003  Flexor
+       004  Glove
+       005  Head Tracker
+       006  Head Mounted Display
+       007  Hand Tracker
+       008  Oculometer
+       009  Vest
+       00a  Animatronic Device
+       020  Stereo Enable
+       021  Display Enable
+HUT 04  Sport Controls
+       000  Unidentified
+       001  Baseball Bat
+       002  Golf Club
+       003  Rowing Machine
+       004  Treadmill
+       030  Oar
+       031  Slope
+       032  Rate
+       033  Stick Speed
+       034  Stick Face Angle
+       035  Stick Heel/Toe
+       036  Stick Follow Through
+       047  Stick Temp
+       038  Stick Type
+       039  Stick Height
+       050  Putter
+       051  1 Iron
+       052  2 Iron
+       053  3 Iron
+       054  4 Iron
+       055  5 Iron
+       056  6 Iron
+       057  7 Iron
+       058  8 Iron
+       059  9 Iron
+       05a  10 Iron
+       05b  11 Iron
+       05c  Sand Wedge
+       05d  Loft Wedge
+       05e  Power Wedge
+       05f  1 Wood
+       060  3 Wood
+       061  5 Wood
+       062  7 Wood
+       063  9 Wood
+HUT 05  Game Controls
+       000  Undefined
+       001  3D Game Controller
+       002  Pinball Device
+       003  Gun Device
+       020  Point Of View
+       021  Turn Right/Left
+       022  Pitch Right/Left
+       023  Roll Forward/Backward
+       024  Move Right/Left
+       025  Move Forward/Backward
+       026  Move Up/Down
+       027  Lean Right/Left
+       028  Lean Forward/Backward
+       029  Height of POV
+       02a  Flipper
+       02b  Secondary Flipper
+       02c  Bump
+       02d  New Game
+       02e  Shoot Ball
+       02f  Player
+       030  Gun Bolt
+       031  Gun Clip
+       032  Gun Selector
+       033  Gun Single Shot
+       034  Gun Burst
+       035  Gun Automatic
+       036  Gun Safety
+       037  Gamepad Fire/Jump
+       038  Gamepad Fun
+       039  Gamepad Trigger
+HUT 07  Keyboard
+       000  No Event
+       001  Keyboard ErrorRollOver
+       002  Keyboard POSTfail
+       003  Keyboard Error Undefined
+       004  A
+       005  B
+       006  C
+       007  D
+       008  E
+       009  F
+       00a  G
+       00b  H
+       00c  I
+       00d  J
+       00e  K
+       00f  L
+       010  M
+       011  N
+       012  O
+       013  P
+       014  Q
+       015  R
+       016  S
+       017  T
+       018  U
+       019  V
+       01a  W
+       01b  X
+       01c  Y
+       01d  Z
+       01e  1 and ! (One and Exclamation)
+       01f  2 and @ (2 and at)
+       020  3 and # (3 and Hash)
+       021  4 and $ (4 and Dollar Sign)
+       022  5 and % (5 and Percent Sign)
+       023  6 and ^ (6 and circumflex)
+       024  7 and & (Seven and Ampersand)
+       025  8 and * (Eight and asterisk)
+       026  9 and ( (Nine and Parenthesis Left)
+       027  0 and ) (Zero and Parenthesis Right)
+       028  Return (Enter)
+       029  Escape
+       02a  Delete (Backspace)
+       02b  Tab
+       02c  Space Bar
+       02d  - and _ (Minus and underscore)
+       02e  = and + (Equal and Plus)
+       02f  [ and { (Bracket and Braces Left)
+       030  ] and } (Bracket and Braces Right)
+       031  \ and | (Backslash and Bar)
+       032  # and ~ (Hash and Tilde, Non-US Keyboard near right shift)
+       033  ; and : (Semicolon and Colon)
+       034  ´ and " (Accent Acute and Double Quotes)
+       035  ` and ~ (Accent Grace and Tilde)
+       036  , and < (Comma and Less)
+       037  . and > (Period and Greater)
+       038  / and ? (Slash and Question Mark)
+       039  Caps Lock
+       03a  F1
+       03b  F2
+       03c  F3
+       03d  F4
+       03e  F5
+       03f  F6
+       040  F7
+       041  F8
+       042  F9
+       043  F10
+       044  F11
+       045  F12
+       046  Print Screen
+       047  Scroll Lock
+       048  Pause
+       049  Insert
+       04a  Home
+       04b  Page Up
+       04c  Delete Forward (without Changing Position)
+       04d  End
+       04e  Page Down
+       04f  Right Arrow
+       050  Left Arrow
+       051  Down Arrow
+       052  Up Arrow
+       053  Num Lock and Clear
+       054  Keypad / (Division Sign)
+       055  Keypad * (Multiplication Sign)
+       056  Keypad - (Subtraction Sign)
+       057  Keypad + (Addition Sign)
+       058  Keypad Enter
+       059  Keypad 1 and END
+       05a  Keypad 2 and Down Arrow
+       05b  Keypad 3 and Page Down
+       05c  Keypad 4 and Left Arrow
+       05d  Keypad 5 (Tactilei Raised)
+       05f  Keypad 6 and Right Arrow
+       060  Keypad 7 and Home
+       061  Keypad 8 and Up Arrow
+       062  Keypad 8 and Page Up
+       063  Keypad . (decimal delimiter) and Delete
+       064  \ and | (Backslash and Bar, UK and Non-US Keyboard near left shift)
+       065  Keyboard Application (Windows Key for Win95 or Compose)
+       066  Power (not a key)
+       067  Keypad = (Equal Sign)
+       068  F13
+       069  F14
+       06a  F15
+       06b  F16
+       06c  F17
+       06d  F18
+       06e  F19
+       06f  F20
+       070  F21
+       071  F22
+       072  F23
+       073  F24
+       074  Execute
+       075  Help
+       076  Menu
+       077  Select
+       078  Stop
+       079  Again
+       07a  Undo
+       07b  Cut
+       07c  Copy
+       07d  Paste
+       07e  Find
+       07f  Mute
+       080  Volume Up
+       081  Volume Down
+       082  Locking Caps Lock
+       083  Locking Num Lock
+       084  Locking Scroll Lock
+       085  Keypad Comma
+       086  Keypad Equal Sign (AS/400)
+       087  International 1 (PC98)
+       088  International 2 (PC98)
+       089  International 3 (PC98)
+       08a  International 4 (PC98)
+       08b  International 5 (PC98)
+       08c  International 6 (PC98)
+       08d  International 7 (Toggle Single/Double Byte Mode)
+       08e  International 8
+       08f  International 9
+       090  LANG 1 (Hangul/English Toggle, Korea)
+       091  LANG 2 (Hanja Conversion, Korea)
+       092  LANG 3 (Katakana, Japan)
+       093  LANG 4 (Hiragana, Japan)
+       094  LANG 5 (Zenkaku/Hankaku, Japan)
+       095  LANG 6
+       096  LANG 7
+       097  LANG 8
+       098  LANG 9
+       099  Alternate Erase
+       09a  SysReq/Attention
+       09b  Cancel
+       09c  Clear
+       09d  Prior
+       09e  Return
+       09f  Separator
+       0a0  Out
+       0a1  Open
+       0a2  Clear/Again
+       0a3  CrSel/Props
+       0a4  ExSel
+       0e0  Control Left
+       0e1  Shift Left
+       0e2  Alt Left
+       0e3  GUI Left
+       0e4  Control Right
+       0e5  Shift Right
+       0e6  Alt Rigth
+       0e7  GUI Right
+HUT 08  LEDs
+       000  Undefined
+       001  NumLock
+       002  CapsLock
+       003  Scroll Lock
+       004  Compose
+       005  Kana
+       006  Power
+       007  Shift
+       008  Do not disturb
+       009  Mute
+       00a  Tone Enabke
+       00b  High Cut Filter
+       00c  Low Cut Filter
+       00d  Equalizer Enable
+       00e  Sound Field ON
+       00f  Surround On
+       010  Repeat
+       011  Stereo
+       012  Sampling Rate Detect
+       013  Spinning
+       014  CAV
+       015  CLV
+       016  Recording Format Detect
+       017  Off-Hook
+       018  Ring
+       019  Message Waiting
+       01a  Data Mode
+       01b  Battery Operation
+       01c  Battery OK
+       01d  Battery Low
+       01e  Speaker
+       01f  Head Set
+       020  Hold
+       021  Microphone
+       022  Coverage
+       023  Night Mode
+       024  Send Calls
+       025  Call Pickup
+       026  Conference
+       027  Stand-by
+       028  Camera On
+       029  Camera Off
+       02a  On-Line
+       02b  Off-Line
+       02c  Busy
+       02d  Ready
+       02e  Paper-Out
+       02f  Paper-Jam
+       030  Remote
+       031  Forward
+       032  Reverse
+       033  Stop
+       034  Rewind
+       035  Fast Forward
+       036  Play
+       037  Pause
+       038  Record
+       039  Error
+       03a  Usage Selected Indicator
+       03b  Usage In Use Indicator
+       03c  Usage Multi Indicator
+       03d  Indicator On
+       03e  Indicator Flash
+       03f  Indicator Slow Blink
+       040  Indicator Fast Blink
+       041  Indicator Off
+       042  Flash On Time
+       043  Slow Blink On Time
+       044  Slow Blink Off Time
+       045  Fast Blink On Time
+       046  Fast Blink Off Time
+       047  Usage Color Indicator
+       048  Indicator Red
+       049  Indicator Green
+       04a  Indicator Amber
+       04b  Generic Indicator
+       04c  System Suspend
+       04d  External Power Connected
+HUT 09  Buttons
+       000  No Button Pressed
+       001  Button 1 (Primary)
+       002  Button 2 (Secondary)
+       003  Button 3 (Tertiary)
+       004  Button 4
+       005  Button 5
+HUT 0a  Ordinal
+       001  Instance 1
+       002  Instance 2
+       003  Instance 3
+HUT 0b  Telephony
+       000  Unassigned
+       001  Phone
+       002  Answering Machine
+       003  Message Controls
+       004  Handset
+       005  Headset
+       006  Telephony Key Pad
+       007  Programmable Button
+       020  Hook Switch
+       021  Flash
+       022  Feature
+       023  Hold
+       024  Redial
+       025  Transfer
+       026  Drop
+       027  Park
+       028  Forward Calls
+       029  Alternate Function
+       02a  Line
+       02b  Speaker Phone
+       02c  Conference
+       02d  Ring Enable
+       02e  Ring Select
+       02f  Phone Mute
+       030  Caller ID
+       050  Speed Dial
+       051  Store Number
+       052  Recall Number
+       053  Phone Directory
+       070  Voice Mail
+       071  Screen Calls
+       072  Do Not Disturb
+       073  Message
+       074  Answer On/Offf
+       090  Inside Dial Tone
+       091  Outside Dial Tone
+       092  Inside Ring Tone
+       093  Outside Ring Tone
+       094  Priority Ring Tone
+       095  Inside Ringback
+       096  Priority Ringback
+       097  Line Busy Tone
+       098  Recorder Tone
+       099  Call Waiting Tone
+       09a  Confirmation Tone 1
+       09b  Confirmation Tone 2
+       09c  Tones Off
+       09d  Outside Ringback
+       0b0  Key 1
+       0b1  Key 2
+       0b3  Key 3
+       0b4  Key 4
+       0b5  Key 5
+       0b6  Key 6
+       0b7  Key 7
+       0b8  Key 8
+       0b9  Key 9
+       0ba  Key Star
+       0bb  Key Pound
+       0bc  Key A
+       0bd  Key B
+       0be  Key C
+       0bf  Key D
+HUT 0c  Consumer
+       000  Unassigned
+       001  Consumer Control
+       002  Numeric Key Pad
+       003  Programmable Buttons
+       020  +10
+       021  +100
+       022  AM/PM
+       030  Power
+       031  Reset
+       032  Sleep
+       033  Sleep After
+       034  Sleep Mode
+       035  Illumination
+       036  Function Buttons
+       040  Menu
+       041  Menu Pick
+       042  Menu Up
+       043  Menu Down
+       044  Menu Left
+       045  Menu Right
+       046  Menu Escape
+       047  Menu Value Increase
+       048  Menu Value Decrease
+       060  Data on Screen
+       061  Closed Caption
+       062  Closed Caption Select
+       063  VCR/TV
+       064  Broadcast Mode
+       065  Snapshot
+       066  Still
+       080  Selection
+       081  Assign Selection
+       082  Mode Step
+       083  Recall Last
+       084  Enter Channel
+       085  Order Movie
+       086  Channel
+       087  Media Selection
+       088  Media Select Computer
+       089  Media Select TV
+       08a  Media Select WWW
+       08b  Media Select DVD
+       08c  Media Select Telephone
+       08d  Media Select Program Guide
+       08e  Media Select Video Phone
+       08f  Media Select Games
+       090  Media Select Messages
+       091  Media Select CD
+       092  Media Select VCR
+       093  Media Select Tuner
+       094  Quit
+       095  Help
+       096  Media Select Tape
+       097  Media Select Cable
+       098  Media Select Satellite
+       099  Media Select Security
+       09a  Media Select Home
+       09b  Media Select Call
+       09c  Channel Increment
+       09d  Channel Decrement
+       09e  Media Select SAP
+       0a0  VCR Plus
+       0a1  Once
+       0a2  Daily
+       0a3  Weekly
+       0a4  Monthly
+       0b0  Play
+       0b1  Pause
+       0b2  Record
+       0b3  Fast Forward
+       0b4  Rewind
+       0b5  Scan Next Track
+       0b6  Scan Previous Track
+       0b7  Stop
+       0b8  Eject
+       0b9  Random Play
+       0ba  Select Disc
+       0bb  Enter Disc
+       0bc  Repeat
+       0bd  Tracking
+       0be  Track Normal
+       0bf  Slow Tracking
+       0c0  Frame Forward
+       0c1  Frame Back
+       0c2  Mark
+       0c3  Clear Mark
+       0c4  Repeat from Mark
+       0c5  Return to Mark
+       0c6  Search Mark Forward
+       0c7  Search Mark Backward
+       0c8  Counter Reset
+       0c9  Show Counter
+       0ca  Tracking Increment
+       0cb  Tracking Decrement
+       0cc  Stop/Eject
+       0cd  Play/Pause
+       0ce  Play/Skip
+       0e0  Volume
+       0e1  Balance
+       0e2  Mute
+       0e3  Bass
+       0e4  Treble
+       0e5  Bass Boost
+       0e6  Surround Mode
+       0e7  Loudness
+       0e8  MPX
+       0e9  Volume Increment
+       0ea  Volume Decrement
+       0f0  Speed Select
+       0f1  Playback Speed
+       0f2  Standard Play
+       0f3  Long Play
+       0f4  Extended Play
+       0f5  Slow
+       100  Fan Enable
+       101  Fan Speed
+       102  Light Enable
+       103  Light Illumination Level
+       104  Climate Control Enable
+       105  Room Temperature
+       106  Security Enable
+       107  Fire Alarm
+       108  Police Alarm
+       150  Balance Right
+       151  Balance Left
+       152  Bass Increment
+       153  Bass Decrement
+       154  Treble Increment
+       155  Treble Decrement
+       160  Speaker System
+       161  Channel Left
+       162  Channel Right
+       163  Channel Center
+       164  Channel Front
+       165  Channel Center Front
+       166  Channel Side
+       167  Channel Surround
+       168  Channel Low Frequency Enhancement
+       169  Channel Top
+       16a  Channel Unknown
+       170  Sub-Channel
+       171  Sub-Channel Increment
+       172  Sub-Channel Decrement
+       173  Alternative Audio Increment
+       174  Alternative Audio Decrement
+       180  Application Launch Buttons
+       181  AL Launch Button Configuration Tool
+       182  AL Launch Button Configuration
+       183  AL Consumer Control Configuration
+       184  AL Word Processor
+       185  AL Text Editor
+       186  AL Spreadsheet
+       187  AL Graphics Editor
+       188  AL Presentation App
+       189  AL Database App
+       18a  AL Email Reader
+       18b  AL Newsreader
+       18c  AL Voicemail
+       18d  AL Contacts/Address Book
+       18e  AL Calendar/Schedule
+       18f  AL Task/Project Manager
+       190  AL Log/Jounal/Timecard
+       191  AL Checkbook/Finance
+       192  AL Calculator
+       193  AL A/V Capture/Playback
+       194  AL Local Machine Browser
+       195  AL LAN/Wan Browser
+       196  AL Internet Browser
+       197  AL Remote Networking/ISP Connect
+       198  AL Network Conference
+       199  AL Network Chat
+       19a  AL Telephony/Dialer
+       19b  AL Logon
+       19c  AL Logoff
+       19d  AL Logon/Logoff
+       19e  AL Terminal Local/Screensaver
+       19f  AL Control Panel
+       1a0  AL Command Line Processor/Run
+       1a1  AL Process/Task Manager
+       1a2  AL Select Task/Application
+       1a3  AL Next Task/Application
+       1a4  AL Previous Task/Application
+       1a5  AL Preemptive Halt Task/Application
+       200  Generic GUI Application Controls
+       201  AC New
+       202  AC Open
+       203  AC CLose
+       204  AC Exit
+       205  AC Maximize
+       206  AC Minimize
+       207  AC Save
+       208  AC Print
+       209  AC Properties
+       21a  AC Undo
+       21b  AC Copy
+       21c  AC Cut
+       21d  AC Paste
+       21e  AC Select All
+       21f  AC Find
+       220  AC Find and Replace
+       221  AC Search
+       222  AC Go To
+       223  AC Home
+       224  AC Back
+       225  AC Forward
+       226  AC Stop
+       227  AC Refresh
+       228  AC Previous Link
+       229  AC Next Link
+       22b  AC History
+       22c  AC Subscriptions
+       22d  AC Zoom In
+       22e  AC Zoom Out
+       22f  AC Zoom
+       230  AC Full Screen View
+       231  AC Normal View
+       232  AC View Toggle
+       233  AC Scroll Up
+       234  AC Scroll Down
+       235  AC Scroll
+       236  AC Pan Left
+       237  AC Pan Right
+       238  AC Pan
+       239  AC New Window
+       23a  AC Tile Horizontally
+       23b  AC Tile Vertically
+       23c  AC Format
+HUT 0d  Digitizer
+       000  Undefined
+       001  Digitizer
+       002  Pen
+       003  Light Pen
+       004  Touch Screen
+       005  Touch Pad
+       006  White Board
+       007  Coordinate Measuring Machine
+       008  3D Digitizer
+       009  Stereo Plotter
+       00a  Articulated Arm
+       00b  Armature
+       00c  Multiple Point Digitizer
+       00d  Free Space Wand
+       020  Stylus
+       021  Puck
+       022  Finger
+       030  Tip Pressure
+       031  Barrel Pressure
+       032  In Range
+       033  Touch
+       034  Untouch
+       035  Tap
+       036  Quality
+       037  Data Valid
+       038  Transducer Index
+       039  Tablet Function Keys
+       03a  Program Change Keys
+       03b  Battery Strength
+       03c  Invert
+       03d  X Tilt
+       03e  Y Tilt
+       03f  Azimuth
+       040  Altitude
+       041  Twist
+       042  Tip Switch
+       043  Secondary Tip Switch
+       044  Barrel Switch
+       045  Eraser
+       046  Tablet Pick
+HUT 0f  PID Page
+       000  Undefined
+       001  Physical Interface Device
+       020  Normal
+       021  Set Effect Report
+       022  Effect Block Index
+       023  Parameter Block Offset
+       024  ROM Flag
+       025  Effect Type
+       026  ET Constant Force
+       027  ET Ramp
+       028  ET Custom Force Data
+       030  ET Square
+       031  ET Sine
+       032  ET Triangle
+       033  ET Sawtooth Up
+       034  ET Sawtooth Down
+       040  ET Spring
+       041  ET Damper
+       042  ET Inertia
+       043  ET Friction
+       050  Duration
+       051  Sample Period
+       052  Gain
+       053  Trigger Button
+       054  Trigger Repeat Interval
+       055  Axes Enable
+       056  Direction Enable
+       057  Direction
+       058  Type Specific Block Offset
+       059  Block Type
+       05A  Set Envelope Report
+       05B  Attack Level
+       05C  Attack Time
+       05D  Fade Level
+       05E  Fade Time
+       05F  Set Condition Report
+       060  CP Offset
+       061  Positive Coefficient
+       062  Negative Coefficient
+       063  Positive Saturation
+       064  Negative Saturation
+       065  Dead Band
+       066  Download Force Sample
+       067  Isoch Custom Force Enable
+       068  Custom Force Data Report
+       069  Custom Force Data
+       06A  Custom Force Vendor Defined Data
+       06B  Set Custom Force Report
+       06C  Custom Force Data Offset
+       06D  Sample Count
+       06E  Set Periodic Report
+       06F  Offset
+       070  Magnitude
+       071  Phase
+       072  Period
+       073  Set Constant Force Report
+       074  Set Ramp Force Report
+       075  Ramp Start
+       076  Ramp End
+       077  Effect Operation Report
+       078  Effect Operation
+       079  Op Effect Start
+       07A  Op Effect Start Solo
+       07B  Op Effect Stop
+       07C  Loop Count
+       07D  Device Gain Report
+       07E  Device Gain
+       07F  PID Pool Report
+       080  RAM Pool Size
+       081  ROM Pool Size
+       082  ROM Effect Block Count
+       083  Simultaneous Effects Max
+       084  Pool Alignment
+       085  PID Pool Move Report
+       086  Move Source
+       087  Move Destination
+       088  Move Length
+       089  PID Block Load Report
+       08B  Block Load Status
+       08C  Block Load Success
+       08D  Block Load Full
+       08E  Block Load Error
+       08F  Block Handle
+       090  PID Block Free Report
+       091  Type Specific Block Handle
+       092  PID State Report
+       094  Effect Playing
+       095  PID Device Control Report
+       096  PID Device Control
+       097  DC Enable Actuators
+       098  DC Disable Actuators
+       099  DC Stop All Effects
+       09A  DC Device Reset
+       09B  DC Device Pause
+       09C  DC Device Continue
+       09F  Device Paused
+       0A0  Actuators Enabled
+       0A4  Safety Switch
+       0A5  Actuator Override Switch
+       0A6  Actuator Power
+       0A7  Start Delay
+       0A8  Parameter Block Size
+       0A9  Device Managed Pool
+       0AA  Shared Parameter Blocks
+       0AB  Create New Effect Report
+       0AC  RAM Pool Available
+HUT 10  Unicode
+HUT 14  Alphanumeric Display
+       000  Undefined
+       001  Alphanumeric Display
+       020  Display Attributes Report
+       021  ASCII Character Set
+       022  Data Read Back
+       023  Font Read Back
+       024  Display Control Report
+       025  Clear Display
+       026  Display Enable
+       027  Screen Saver Delay
+       028  Screen Saver Enable
+       029  Vertical Scroll
+       02a  Horizontal Scroll
+       02b  Character Report
+       02c  Display Data
+       02d  Display Status
+       02e  Stat Not Ready
+       02f  Stat Ready
+       030  Err Not a loadable Character
+       031  Err Font Data Cannot Be Read
+       032  Cursur Position Report
+       033  Row
+       034  Column
+       035  Rows
+       036  Columns
+       037  Cursor Pixel Positioning
+       038  Cursor Mode
+       039  Cursor Enable
+       03a  Cursor Blink
+       03b  Font Report
+       03c  Font Data
+       03d  Character Width
+       03e  Character Height
+       03f  Character Spacing Horizontal
+       040  Character Spacing Vertical
+       041  Unicode Character Set
+HUT 80  USB Monitor
+       001  Monitor Control
+       002  EDID Information
+       003  VDIF Information
+       004  VESA Version
+HUT 81  USB Monitor Enumerated Values
+HUT 82  Monitor VESA Virtual Controls
+       001  Degauss
+       010  Brightness
+       012  Contrast
+       016  Red Video Gain
+       018  Green Video Gain
+       01a  Blue Video Gain
+       01c  Focus
+       020  Horizontal Position
+       022  Horizontal Size
+       024  Horizontal Pincushion
+       026  Horizontal Pincushion Balance
+       028  Horizontal Misconvergence
+       02a  Horizontal Linearity
+       02c  Horizontal Linearity Balance
+       030  Vertical Position
+       032  Vertical Size
+       034  Vertical Pincushion
+       036  Vertical Pincushion Balance
+       038  Vertical Misconvergence
+       03a  Vertical Linearity
+       03c  Vertical Linearity Balance
+       040  Parallelogram Balance (Key Distortion)
+       042  Trapezoidal Distortion (Key)
+       044  Tilt (Rotation)
+       046  Top Corner Distortion Control
+       048  Top Corner Distortion Balance
+       04a  Bottom Corner Distortion Control
+       04c  Bottom Corner Distortion Balance
+       056  Horizontal Moire
+       058  Vertical Moire
+       05e  Input Level Select
+       060  Input Source Select
+       06c  Red Video Black Level
+       06e  Green Video Black Level
+       070  Blue Video Black Level
+       0a2  Auto Size Center
+       0a4  Polarity Horizontal Sychronization
+       0a6  Polarity Vertical Synchronization
+       0aa  Screen Orientation
+       0ac  Horizontal Frequency in Hz
+       0ae  Vertical Frequency in 0.1 Hz
+       0b0  Settings
+       0ca  On Screen Display (OSD)
+       0d4  Stereo Mode
+HUT 84  Power Device Page
+       000  Undefined
+       001  iName
+       002  Present Status
+       003  Changed Status
+       004  UPS
+       005  Power Supply
+       010  Battery System
+       011  Battery System ID
+       012  Battery
+       013  Battery ID
+       014  Charger
+       015  Charger ID
+       016  Power Converter
+       017  Power Converter ID
+       018  Outlet System
+       019  Outlet System ID
+       01a  Input
+       01b  Input ID
+       01c  Output
+       01d  Output ID
+       01e  Flow
+       01f  Flow ID
+       020  Outlet
+       021  Outlet ID
+       022  Gang
+       023  Gang ID
+       024  Power Summary
+       025  Power Summary ID
+       030  Voltage
+       031  Current
+       032  Frequency
+       033  Apparent Power
+       034  Active Power
+       035  Percent Load
+       036  Temperature
+       037  Humidity
+       038  Bad Count
+       040  Config Voltage
+       041  Config Current
+       042  Config Frequency
+       043  Config Apparent Power
+       044  Config Active Power
+       045  Config Percent Load
+       046  Config Temperature
+       047  Config Humidity
+       050  Switch On Control
+       051  Switch Off Control
+       052  Toggle Control
+       053  Low Voltage Transfer
+       054  High Voltage Transfer
+       055  Delay Before Reboot
+       056  Delay Before Startup
+       057  Delay Before Shutdown
+       058  Test
+       059  Module Reset
+       05a  Audible Alarm Control
+       060  Present
+       061  Good
+       062  Internal Failure
+       063  Voltage out of range
+       064  Frequency out of range
+       065  Overload
+       066  Over Charged
+       067  Over Temperature
+       068  Shutdown Requested
+       069  Shutdown  Imminent
+       06a  Reserved
+       06b  Switch On/Off
+       06c  Switchable
+       06d  Used
+       06e  Boost
+       06f  Buck
+       070  Initialized
+       071  Tested
+       072  Awaiting Power
+       073  Communication Lost
+       0fd  iManufacturer
+       0fe  iProduct
+       0ff  iSerialNumber
+HUT 85  Battery System Page
+       000  Undefined
+       001  SMB Battery Mode
+       002  SMB Battery Status
+       003  SMB Alarm Warning
+       004  SMB Charger Mode
+       005  SMB Charger Status
+       006  SMB Charger Spec Info
+       007  SMB Selector State
+       008  SMB Selector Presets
+       009  SMB Selector Info
+       010  Optional Mfg. Function 1
+       011  Optional Mfg. Function 2
+       012  Optional Mfg. Function 3
+       013  Optional Mfg. Function 4
+       014  Optional Mfg. Function 5
+       015  Connection to SMBus
+       016  Output Connection
+       017  Charger Connection
+       018  Battery Insertion
+       019  Use Next
+       01a  OK to use
+       01b  Battery  Supported
+       01c  SelectorRevision
+       01d  Charging Indicator
+       028  Manufacturer Access
+       029  Remaining Capacity Limit
+       02a  Remaining Time Limit
+       02b  At Rate
+       02c  Capacity Mode
+       02d  Broadcast To Charger
+       02e  Primary Battery
+       02f  Charge Controller
+       040  Terminate Charge
+       041  Terminate Discharge
+       042  Below Remaining Capacity Limit
+       043  Remaining Time Limit Expired
+       044  Charging
+       045  Discharging
+       046  Fully Charged
+       047  Fully Discharged
+       048  Conditioning Flag
+       049  At Rate OK
+       04a  SMB Error Code
+       04b  Need Replacement
+       060  At Rate Time To Full
+       061  At Rate Time To Empty
+       062  Average Current
+       063  Max Error
+       064  Relative State Of Charge
+       065  Absolute State Of Charge
+       066  Remaining Capacity
+       067  Full Charge Capacity
+       068  Run Time To Empty
+       069  Average Time To Empty
+       06a  Average Time To Full
+       06b  Cycle Count
+       080  Batt. Pack Model Level
+       081  Internal Charge Controller
+       082  Primary Battery Support
+       083  Design Capacity
+       084  Specification Info
+       085  Manufacturer Date
+       086  Serial Number
+       087  iManufacturerName
+       088  iDeviceName
+       089  iDeviceChemistry
+       08a  Manufacturer Data
+       08b  Rechargeable
+       08c  Warning Capacity Limit
+       08d  Capacity Granularity 1
+       08e  Capacity Granularity 2
+       08f  iOEMInformation
+       0c0  Inhibit Charge
+       0c1  Enable Polling
+       0c2  Reset To Zero
+       0d0  AC Present
+       0d1  Battery Present
+       0d2  Power Fail
+       0d3  Alarm Inhibited
+       0d4  Thermistor Under Range
+       0d5  Thermistor Hot
+       0d6  Thermistor Cold
+       0d7  Thermistor Over Range
+       0d8  Voltage Out Of Range
+       0d9  Current Out Of Range
+       0da  Current Not Regulated
+       0db  Voltage Not Regulated
+       0dc  Master Mode
+       0f0  Charger Selector Support
+       0f1  Charger Spec
+       0f2  Level 2
+       0f3  Level 3
+HUT 86  Power Pages
+HUT 87  Power Pages
+HUT 8c  Bar Code Scanner Page (POS)
+HUT 8d  Scale Page (POS)
+HUT 90  Camera Control Page
+HUT 91  Arcade Control Page
+HUT f0  Cash Device
+       0f1  Cash Drawer
+       0f2  Cash Drawer Number
+       0f3  Cash Drawer Set
+       0f4  Cash Drawer Status
+HUT ff  Vendor Specific
+
+# List of Languages
+
+# Syntax:
+# L language_id  language_name
+#      dialect_id  dialect_name
+
+L 0001  Arabic
+       01  Saudi Arabia
+       02  Iraq
+       03  Egypt
+       04  Libya
+       05  Algeria
+       06  Morocco
+       07  Tunesia
+       08  Oman
+       09  Yemen
+       0a  Syria
+       0b  Jordan
+       0c  Lebanon
+       0d  Kuwait
+       0e  U.A.E
+       0f  Bahrain
+       10  Qatar
+L 0002  Bulgarian
+L 0003  Catalan
+L 0004  Chinese
+       01  Traditional
+       02  Simplified
+       03  Hongkong SAR, PRC
+       04  Singapore
+       05  Macau SAR
+L 0005  Czech
+L 0006  Danish
+L 0007  German
+       01  German
+       02  Swiss
+       03  Austrian
+       04  Luxembourg
+       05  Liechtenstein
+L 0008  Greek
+L 0009  English
+       01  US
+       02  UK
+       03  Australian
+       04  Canadian
+       05  New Zealand
+       06  Ireland
+       07  South Africa
+       08  Jamaica
+       09  Carribean
+       0a  Belize
+       0b  Trinidad
+       0c  Zimbabwe
+       0d  Philippines
+L 000a  Spanish
+       01  Castilian
+       02  Mexican
+       03  Modern
+       04  Guatemala
+       05  Costa Rica
+       06  Panama
+       07  Dominican Republic
+       08  Venzuela
+       09  Colombia
+       0a  Peru
+       0b  Argentina
+       0c  Ecuador
+       0d  Chile
+       0e  Uruguay
+       0f  Paraguay
+       10  Bolivia
+       11  El Salvador
+       12  Honduras
+       13  Nicaragua
+       14  Puerto Rico
+L 000b  Finnish
+L 000c  French
+       01  French
+       02  Belgian
+       03  Canadian
+       04  Swiss
+       05  Luxembourg
+       06  Monaco
+L 000d  Hebrew
+L 000e  Hungarian
+L 000f  Idelandic
+L 0010  Italian
+       01  Italian
+       02  Swiss
+L 0011  Japanese
+L 0012  Korean
+       01  Korean
+L 0013  Dutch
+       01  Dutch
+       02  Belgian
+L 0014  Norwegian
+       01  Bokmal
+       02  Nynorsk
+L 0015  Polish
+L 0016 Portuguese
+       01  Portuguese
+       02  Brazilian
+L 0017  forgotten
+L 0018  Romanian
+L 0019  Russian
+L 001a  Serbian
+       01  Croatian
+       02  Latin
+       03  Cyrillic
+L 001b  Slovak
+L 001c  Albanian
+L 001d  Swedish
+       01  Swedish
+       02  Finland
+L 001e  Thai
+L 001f  Turkish
+L 0020  Urdu
+       01  Pakistan
+       02  India
+L 0021  Indonesian
+L 0022  Ukrainian
+L 0023  Belarusian
+L 0024  Slovenian
+L 0025  Estonian
+L 0026  Latvian
+L 0027  Lithuanian
+       01  Lithuanian
+L 0028  forgotten
+L 0029  Farsi
+L 002a  Vietnamese
+L 002b  Armenian
+L 002c  Azeri
+       01  Cyrillic
+       02  Latin
+L 002d  Basque
+L 002e  forgotten
+L 002f  Macedonian
+L 0036  Afrikaans
+L 0037  Georgian
+L 0038  Faeroese
+L 0039  Hindi
+L 003e  Malay
+       01  Malaysia
+       02  Brunei Darassalam
+L 003f  Kazak
+L 0041  Awahili
+L 0043  Uzbek
+       01  Latin
+       02  Cyrillic
+L 0044  Tatar
+L 0045  Bengali
+L 0046  Punjabi
+L 0047  Gujarati
+L 0048  Oriya
+L 0049  Tamil
+L 004a  Telugu
+L 004b  Kannada
+L 004c  Malayalam
+L 004d  Assamese
+L 004e  Marathi
+L 004f  Sanskrit
+L 0057  Konkani
+L 0058  Manipuri
+L 0059  Sindhi
+L 0060  Kashmiri
+       02  India
+L 0061  Nepali
+       02  India
+
+# HID Descriptor bCountryCode
+# HID Specification 1.11 (2001-06-27) page 23
+#
+# Syntax:
+# HCC country_code keymap_type
+
+HCC 00  Not supported
+HCC 01  Arabic
+HCC 02  Belgian
+HCC 03  Canadian-Bilingual
+HCC 04  Canadian-French
+HCC 05  Czech Republic
+HCC 06  Danish
+HCC 07  Finnish
+HCC 08  French
+HCC 09  German
+HCC 10  Greek
+HCC 11  Hebrew
+HCC 12  Hungary
+HCC 13  International (ISO)
+HCC 14  Italian
+HCC 15  Japan (Katakana)
+HCC 16  Korean
+HCC 17  Latin American
+HCC 18  Netherlands/Dutch
+HCC 19  Norwegian
+HCC 20  Persian (Farsi)
+HCC 21  Poland
+HCC 22  Portuguese
+HCC 23  Russia
+HCC 24  Slovakia
+HCC 25  Spanish
+HCC 26  Swedish
+HCC 27  Swiss/French
+HCC 28  Swiss/German
+HCC 29  Switzerland
+HCC 30  Taiwan
+HCC 31  Turkish-Q
+HCC 32  UK
+HCC 33  US
+HCC 34  Yugoslavia
+HCC 35  Turkish-F
+
+# List of Video Class Terminal Types
+
+# Syntax:
+# VT terminal_type  terminal_type_name
+
+VT 0100  USB Vendor Specific
+VT 0101  USB Streaming
+VT 0200  Input Vendor Specific
+VT 0201  Camera Sensor
+VT 0202  Sequential Media
+VT 0300  Output Vendor Specific
+VT 0301  Generic Display
+VT 0302  Sequential Media
+VT 0400  External Vendor Specific
+VT 0401  Composite Video
+VT 0402  S-Video
+VT 0403  Component Video
index d3f1e5f8a96023c2d45d52abf7740b80191f6ae6..d5bc8e7e3d79d12ec0769c3eaa4801ade1fa297d 100644 (file)
  * USA.
  */
 
-#include <linux/platform_device.h>
+#include <linux/device.h>
+#include <linux/list.h>
+#include <linux/spinlock.h>
+#include <linux/sysfs.h>
+#include <linux/types.h>
+#include <linux/usb.h>
 #include <linux/usb/hcd.h>
-
+#include <linux/wait.h>
 
 struct vhci_device {
        struct usb_device *udev;
@@ -33,12 +38,11 @@ struct vhci_device {
        /* speed of a remote device */
        enum usb_device_speed speed;
 
-       /*  vhci root-hub port to which this device is attached  */
+       /* vhci root-hub port to which this device is attached */
        __u32 rhport;
 
        struct usbip_device ud;
 
-
        /* lock for the below link lists */
        spinlock_t priv_lock;
 
@@ -54,7 +58,6 @@ struct vhci_device {
        wait_queue_head_t waitq_tx;
 };
 
-
 /* urb->hcpriv, use container_of() */
 struct vhci_priv {
        unsigned long seqnum;
@@ -64,7 +67,6 @@ struct vhci_priv {
        struct urb *urb;
 };
 
-
 struct vhci_unlink {
        /* seqnum of this request */
        unsigned long seqnum;
@@ -85,12 +87,12 @@ struct vhci_unlink {
 
 /* for usb_bus.hcpriv */
 struct vhci_hcd {
-       spinlock_t      lock;
+       spinlock_t lock;
 
-       u32     port_status[VHCI_NPORTS];
+       u32 port_status[VHCI_NPORTS];
 
-       unsigned        resuming:1;
-       unsigned long   re_timeout;
+       unsigned resuming:1;
+       unsigned long re_timeout;
 
        atomic_t seqnum;
 
@@ -102,24 +104,20 @@ struct vhci_hcd {
        struct vhci_device vdev[VHCI_NPORTS];
 };
 
-
 extern struct vhci_hcd *the_controller;
 extern struct attribute_group dev_attr_group;
-
-
-/*-------------------------------------------------------------------------*/
-/* prototype declaration */
+#define hardware (&the_controller->pdev.dev)
 
 /* vhci_hcd.c */
 void rh_port_connect(int rhport, enum usb_device_speed speed);
 void rh_port_disconnect(int rhport);
-int vhci_rx_loop(void *data);
-int vhci_tx_loop(void *data);
 
-struct urb *pickup_urb_and_free_priv(struct vhci_device *vdev,
-                                           __u32 seqnum);
+/* vhci_rx.c */
+struct urb *pickup_urb_and_free_priv(struct vhci_device *vdev, __u32 seqnum);
+int vhci_rx_loop(void *data);
 
-#define hardware               (&the_controller->pdev.dev)
+/* vhci_tx.c */
+int vhci_tx_loop(void *data);
 
 static inline struct vhci_device *port_to_vdev(__u32 port)
 {
index 4f4f13321f403866c579dfda8a10451b443ea73c..a76e8fa69b6e3b3685e4cdd6ceab849b2afeccd5 100644 (file)
  * USA.
  */
 
-#include <linux/slab.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
 #include <linux/kthread.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
 
 #include "usbip_common.h"
 #include "vhci.h"
 
-#define DRIVER_VERSION "1.0"
 #define DRIVER_AUTHOR "Takahiro Hirofuchi"
-#define DRIVER_DESC "Virtual Host Controller Interface Driver for USB/IP"
-#define DRIVER_LICENCE "GPL"
-MODULE_AUTHOR(DRIVER_AUTHOR);
-MODULE_DESCRIPTION(DRIVER_DESC);
-MODULE_LICENSE(DRIVER_LICENCE);
-
-
+#define DRIVER_DESC "USB/IP 'Virtual' Host Controller (VHCI) Driver"
 
 /*
  * TODO
@@ -43,15 +40,13 @@ MODULE_LICENSE(DRIVER_LICENCE);
  *     - clean up everything
  */
 
-
 /* See usb gadget dummy hcd */
 
-
 static int vhci_hub_status(struct usb_hcd *hcd, char *buff);
 static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
-               u16 wIndex, char *buff, u16 wLength);
+                           u16 wIndex, char *buff, u16 wLength);
 static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
-                                                       gfp_t mem_flags);
+                           gfp_t mem_flags);
 static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status);
 static int vhci_start(struct usb_hcd *vhci_hcd);
 static void vhci_stop(struct usb_hcd *hcd);
@@ -62,57 +57,53 @@ static const char driver_desc[] = "USB/IP Virtual Host Controller";
 
 struct vhci_hcd *the_controller;
 
-static const char *bit_desc[] = {
+static const char * const bit_desc[] = {
        "CONNECTION",           /*0*/
        "ENABLE",               /*1*/
        "SUSPEND",              /*2*/
        "OVER_CURRENT",         /*3*/
        "RESET",                /*4*/
-       "R5",           /*5*/
-       "R6",           /*6*/
-       "R7",           /*7*/
+       "R5",                   /*5*/
+       "R6",                   /*6*/
+       "R7",                   /*7*/
        "POWER",                /*8*/
        "LOWSPEED",             /*9*/
        "HIGHSPEED",            /*10*/
        "PORT_TEST",            /*11*/
        "INDICATOR",            /*12*/
-       "R13",          /*13*/
-       "R14",          /*14*/
-       "R15",          /*15*/
+       "R13",                  /*13*/
+       "R14",                  /*14*/
+       "R15",                  /*15*/
        "C_CONNECTION",         /*16*/
        "C_ENABLE",             /*17*/
        "C_SUSPEND",            /*18*/
        "C_OVER_CURRENT",       /*19*/
        "C_RESET",              /*20*/
-       "R21",          /*21*/
-       "R22",          /*22*/
-       "R23",          /*23*/
-       "R24",          /*24*/
-       "R25",          /*25*/
-       "R26",          /*26*/
-       "R27",          /*27*/
-       "R28",          /*28*/
-       "R29",          /*29*/
-       "R30",          /*30*/
-       "R31",          /*31*/
+       "R21",                  /*21*/
+       "R22",                  /*22*/
+       "R23",                  /*23*/
+       "R24",                  /*24*/
+       "R25",                  /*25*/
+       "R26",                  /*26*/
+       "R27",                  /*27*/
+       "R28",                  /*28*/
+       "R29",                  /*29*/
+       "R30",                  /*30*/
+       "R31",                  /*31*/
 };
 
-
 static void dump_port_status(u32 status)
 {
        int i = 0;
 
-       printk(KERN_DEBUG "status %08x:", status);
+       pr_debug("status %08x:", status);
        for (i = 0; i < 32; i++) {
                if (status & (1 << i))
-                       printk(" %s", bit_desc[i]);
+                       pr_debug(" %s", bit_desc[i]);
        }
-
-       printk("\n");
+       pr_debug("\n");
 }
 
-
-
 void rh_port_connect(int rhport, enum usb_device_speed speed)
 {
        unsigned long   flags;
@@ -156,26 +147,20 @@ void rh_port_disconnect(int rhport)
        the_controller->port_status[rhport] |=
                                        (1 << USB_PORT_FEAT_C_CONNECTION);
 
-
        /* not yet complete the disconnection
         * spin_lock(&vdev->ud.lock);
         * vdev->ud.status = VHC_ST_DISCONNECT;
         * spin_unlock(&vdev->ud.lock); */
 
        spin_unlock_irqrestore(&the_controller->lock, flags);
-
        usb_hcd_poll_rh_status(vhci_to_hcd(the_controller));
 }
 
-
-
-/*----------------------------------------------------------------------*/
-
-#define PORT_C_MASK \
-       ((USB_PORT_STAT_C_CONNECTION \
-         | USB_PORT_STAT_C_ENABLE \
-         | USB_PORT_STAT_C_SUSPEND \
-         | USB_PORT_STAT_C_OVERCURRENT \
+#define PORT_C_MASK                            \
+       ((USB_PORT_STAT_C_CONNECTION            \
+         | USB_PORT_STAT_C_ENABLE              \
+         | USB_PORT_STAT_C_SUSPEND             \
+         | USB_PORT_STAT_C_OVERCURRENT         \
          | USB_PORT_STAT_C_RESET) << 16)
 
 /*
@@ -210,7 +195,6 @@ static int vhci_hub_status(struct usb_hcd *hcd, char *buf)
        int             rhport;
        int             changed = 0;
 
-
        *event_bits = 0;
 
        vhci = hcd_to_vhci(hcd);
@@ -232,7 +216,7 @@ static int vhci_hub_status(struct usb_hcd *hcd, char *buf)
                }
        }
 
-       usbip_uinfo("changed %d\n", changed);
+       pr_info("changed %d\n", changed);
 
        if (hcd->state == HC_STATE_SUSPENDED)
                usb_hcd_resume_root_hub(hcd);
@@ -278,10 +262,9 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
         * wIndex shows the port number and begins from 1.
         */
        usbip_dbg_vhci_rh("typeReq %x wValue %x wIndex %x\n", typeReq, wValue,
-                                                               wIndex);
+                         wIndex);
        if (wIndex > VHCI_NPORTS)
-               printk(KERN_ERR "%s: invalid port number %d\n", __func__,
-                                                               wIndex);
+               pr_err("invalid port number %d\n", wIndex);
        rhport = ((__u8)(wIndex & 0x00ff)) - 1;
 
        dum = hcd_to_vhci(hcd);
@@ -311,7 +294,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
                        break;
                case USB_PORT_FEAT_POWER:
                        usbip_dbg_vhci_rh(" ClearPortFeature: "
-                                               "USB_PORT_FEAT_POWER\n");
+                                         "USB_PORT_FEAT_POWER\n");
                        dum->port_status[rhport] = 0;
                        /* dum->address = 0; */
                        /* dum->hdev = 0; */
@@ -319,23 +302,24 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
                        break;
                case USB_PORT_FEAT_C_RESET:
                        usbip_dbg_vhci_rh(" ClearPortFeature: "
-                                               "USB_PORT_FEAT_C_RESET\n");
+                                         "USB_PORT_FEAT_C_RESET\n");
                        switch (dum->vdev[rhport].speed) {
                        case USB_SPEED_HIGH:
                                dum->port_status[rhport] |=
-                                               USB_PORT_STAT_HIGH_SPEED;
+                                       USB_PORT_STAT_HIGH_SPEED;
                                break;
                        case USB_SPEED_LOW:
                                dum->port_status[rhport] |=
-                                               USB_PORT_STAT_LOW_SPEED;
+                                       USB_PORT_STAT_LOW_SPEED;
                                break;
                        default:
                                break;
                        }
                default:
                        usbip_dbg_vhci_rh(" ClearPortFeature: default %x\n",
-                                                               wValue);
+                                         wValue);
                        dum->port_status[rhport] &= ~(1 << wValue);
+                       break;
                }
                break;
        case GetHubDescriptor:
@@ -349,8 +333,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
        case GetPortStatus:
                usbip_dbg_vhci_rh(" GetPortStatus port %x\n", wIndex);
                if (wIndex > VHCI_NPORTS || wIndex < 1) {
-                       printk(KERN_ERR "%s: invalid port number %d\n",
-                              __func__, wIndex);
+                       pr_err("invalid port number %d\n", wIndex);
                        retval = -EPIPE;
                }
 
@@ -360,7 +343,6 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
                 * complete it!!
                 *                                   */
                if (dum->resuming && time_after(jiffies, dum->re_timeout)) {
-                       printk(KERN_ERR "%s: not yet\n", __func__);
                        dum->port_status[rhport] |=
                                        (1 << USB_PORT_FEAT_C_SUSPEND);
                        dum->port_status[rhport] &=
@@ -375,39 +357,38 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
                }
 
                if ((dum->port_status[rhport] & (1 << USB_PORT_FEAT_RESET)) !=
-                               0 && time_after(jiffies, dum->re_timeout)) {
+                   0 && time_after(jiffies, dum->re_timeout)) {
                        dum->port_status[rhport] |=
-                                               (1 << USB_PORT_FEAT_C_RESET);
+                               (1 << USB_PORT_FEAT_C_RESET);
                        dum->port_status[rhport] &=
-                                               ~(1 << USB_PORT_FEAT_RESET);
+                               ~(1 << USB_PORT_FEAT_RESET);
                        dum->re_timeout = 0;
 
                        if (dum->vdev[rhport].ud.status ==
-                                                       VDEV_ST_NOTASSIGNED) {
+                           VDEV_ST_NOTASSIGNED) {
                                usbip_dbg_vhci_rh(" enable rhport %d "
-                                               "(status %u)\n",
-                                               rhport,
-                                               dum->vdev[rhport].ud.status);
+                                                 "(status %u)\n",
+                                                 rhport,
+                                                 dum->vdev[rhport].ud.status);
                                dum->port_status[rhport] |=
-                                                       USB_PORT_STAT_ENABLE;
+                                       USB_PORT_STAT_ENABLE;
                        }
 #if 0
                        if (dum->driver) {
-
                                dum->port_status[rhport] |=
-                                                       USB_PORT_STAT_ENABLE;
+                                       USB_PORT_STAT_ENABLE;
                                /* give it the best speed we agree on */
                                dum->gadget.speed = dum->driver->speed;
                                dum->gadget.ep0->maxpacket = 64;
                                switch (dum->gadget.speed) {
                                case USB_SPEED_HIGH:
                                        dum->port_status[rhport] |=
-                                       USB_PORT_STAT_HIGH_SPEED;
+                                               USB_PORT_STAT_HIGH_SPEED;
                                        break;
                                case USB_SPEED_LOW:
                                        dum->gadget.ep0->maxpacket = 8;
                                        dum->port_status[rhport] |=
-                                       USB_PORT_STAT_LOW_SPEED;
+                                               USB_PORT_STAT_LOW_SPEED;
                                        break;
                                default:
                                        dum->gadget.speed = USB_SPEED_FULL;
@@ -415,14 +396,12 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
                                }
                        }
 #endif
-
                }
                ((u16 *) buf)[0] = cpu_to_le16(dum->port_status[rhport]);
-               ((u16 *) buf)[1] =
-                               cpu_to_le16(dum->port_status[rhport] >> 16);
+               ((u16 *) buf)[1] = cpu_to_le16(dum->port_status[rhport] >> 16);
 
                usbip_dbg_vhci_rh(" GetPortStatus bye %x %x\n", ((u16 *)buf)[0],
-                                                       ((u16 *)buf)[1]);
+                                 ((u16 *)buf)[1]);
                break;
        case SetHubFeature:
                usbip_dbg_vhci_rh(" SetHubFeature\n");
@@ -432,11 +411,10 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
                switch (wValue) {
                case USB_PORT_FEAT_SUSPEND:
                        usbip_dbg_vhci_rh(" SetPortFeature: "
-                                       "USB_PORT_FEAT_SUSPEND\n");
-                       printk(KERN_ERR "%s: not yet\n", __func__);
+                                         "USB_PORT_FEAT_SUSPEND\n");
 #if 0
                        dum->port_status[rhport] |=
-                                               (1 << USB_PORT_FEAT_SUSPEND);
+                               (1 << USB_PORT_FEAT_SUSPEND);
                        if (dum->driver->suspend) {
                                spin_unlock(&dum->lock);
                                dum->driver->suspend(&dum->gadget);
@@ -446,13 +424,13 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
                        break;
                case USB_PORT_FEAT_RESET:
                        usbip_dbg_vhci_rh(" SetPortFeature: "
-                                               "USB_PORT_FEAT_RESET\n");
+                                         "USB_PORT_FEAT_RESET\n");
                        /* if it's already running, disconnect first */
                        if (dum->port_status[rhport] & USB_PORT_STAT_ENABLE) {
                                dum->port_status[rhport] &=
-                                               ~(USB_PORT_STAT_ENABLE |
-                                                 USB_PORT_STAT_LOW_SPEED |
-                                                 USB_PORT_STAT_HIGH_SPEED);
+                                       ~(USB_PORT_STAT_ENABLE |
+                                         USB_PORT_STAT_LOW_SPEED |
+                                         USB_PORT_STAT_HIGH_SPEED);
 #if 0
                                if (dum->driver) {
                                        dev_dbg(hardware, "disconnect\n");
@@ -468,13 +446,14 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
                        /* FALLTHROUGH */
                default:
                        usbip_dbg_vhci_rh(" SetPortFeature: default %d\n",
-                                                               wValue);
+                                         wValue);
                        dum->port_status[rhport] |= (1 << wValue);
+                       break;
                }
                break;
 
        default:
-               printk(KERN_ERR "%s: default: no such request\n", __func__);
+               pr_err("default: no such request\n");
                /* dev_dbg (hardware,
                 *              "hub control req%04x v%04x i%04x l%d\n",
                 *              typeReq, wValue, wIndex, wLength); */
@@ -484,7 +463,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
        }
 
        if (usbip_dbg_flag_vhci_rh) {
-               printk(KERN_DEBUG "port %d\n", rhport);
+               pr_debug("port %d\n", rhport);
                dump_port_status(prev_port_status[rhport]);
                dump_port_status(dum->port_status[rhport]);
        }
@@ -495,10 +474,6 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
        return retval;
 }
 
-
-
-/*----------------------------------------------------------------------*/
-
 static struct vhci_device *get_vdev(struct usb_device *udev)
 {
        int i;
@@ -520,7 +495,7 @@ static void vhci_tx_urb(struct urb *urb)
        unsigned long flag;
 
        if (!vdev) {
-               err("could not get virtual device");
+               pr_err("could not get virtual device");
                /* BUG(); */
                return;
        }
@@ -538,14 +513,13 @@ static void vhci_tx_urb(struct urb *urb)
 
        priv->seqnum = atomic_inc_return(&the_controller->seqnum);
        if (priv->seqnum == 0xffff)
-               usbip_uinfo("seqnum max\n");
+               dev_info(&urb->dev->dev, "seqnum max\n");
 
        priv->vdev = vdev;
        priv->urb = urb;
 
        urb->hcpriv = (void *) priv;
 
-
        list_add_tail(&priv->list, &vdev->priv_tx);
 
        wake_up(&vdev->waitq_tx);
@@ -561,7 +535,7 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
        struct vhci_device *vdev;
 
        usbip_dbg_vhci_hc("enter, usb_hcd %p urb %p mem_flags %d\n",
-                   hcd, urb, mem_flags);
+                         hcd, urb, mem_flags);
 
        /* patch to usb_sg_init() is in 2.5.60 */
        BUG_ON(!urb->transfer_buffer && urb->transfer_buffer_length);
@@ -578,8 +552,9 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
 
        /* refuse enqueue for dead connection */
        spin_lock(&vdev->ud.lock);
-       if (vdev->ud.status == VDEV_ST_NULL || vdev->ud.status == VDEV_ST_ERROR) {
-               usbip_uerr("enqueue for inactive port %d\n", vdev->rhport);
+       if (vdev->ud.status == VDEV_ST_NULL ||
+           vdev->ud.status == VDEV_ST_ERROR) {
+               dev_err(dev, "enqueue for inactive port %d\n", vdev->rhport);
                spin_unlock(&vdev->ud.lock);
                spin_unlock_irqrestore(&the_controller->lock, flags);
                return -ENODEV;
@@ -599,11 +574,10 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
         *  2. Set_Address request to DevAddr(0) EndPoint(0)
         *
         */
-
        if (usb_pipedevice(urb->pipe) == 0) {
                __u8 type = usb_pipetype(urb->pipe);
                struct usb_ctrlrequest *ctrlreq =
-                               (struct usb_ctrlrequest *) urb->setup_packet;
+                       (struct usb_ctrlrequest *) urb->setup_packet;
 
                if (type != PIPE_CONTROL || !ctrlreq) {
                        dev_err(dev, "invalid request to devnum 0\n");
@@ -636,8 +610,8 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
                case USB_REQ_GET_DESCRIPTOR:
                        if (ctrlreq->wValue == (USB_DT_DEVICE << 8))
                                usbip_dbg_vhci_hc("Not yet?: "
-                                               "Get_Descriptor to device 0 "
-                                               "(get max pipe size)\n");
+                                                 "Get_Descriptor to device 0 "
+                                                 "(get max pipe size)\n");
 
                        if (vdev->udev)
                                usb_put_dev(vdev->udev);
@@ -657,7 +631,6 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
 
 out:
        vhci_tx_urb(urb);
-
        spin_unlock_irqrestore(&the_controller->lock, flags);
 
        return 0;
@@ -724,8 +697,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
        struct vhci_priv *priv;
        struct vhci_device *vdev;
 
-       usbip_uinfo("vhci_hcd: dequeue a urb %p\n", urb);
-
+       pr_info("dequeue a urb %p\n", urb);
 
        spin_lock_irqsave(&the_controller->lock, flags);
 
@@ -755,8 +727,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
 
                spin_lock_irqsave(&vdev->priv_lock, flags2);
 
-               usbip_uinfo("vhci_hcd: device %p seems to be disconnected\n",
-                                                                       vdev);
+               pr_info("device %p seems to be disconnected\n", vdev);
                list_del(&priv->list);
                kfree(priv);
                urb->hcpriv = NULL;
@@ -768,14 +739,13 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
                 * vhci_rx will receive RET_UNLINK and give back the URB.
                 * Otherwise, we give back it here.
                 */
-               usbip_uinfo("vhci_hcd: vhci_urb_dequeue() gives back urb %p\n",
-                                                                       urb);
+               pr_info("gives back urb %p\n", urb);
 
                usb_hcd_unlink_urb_from_ep(hcd, urb);
 
                spin_unlock_irqrestore(&the_controller->lock, flags);
                usb_hcd_giveback_urb(vhci_to_hcd(the_controller), urb,
-                                                               urb->status);
+                                    urb->status);
                spin_lock_irqsave(&the_controller->lock, flags);
 
        } else {
@@ -788,7 +758,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
                /* setup CMD_UNLINK pdu */
                unlink = kzalloc(sizeof(struct vhci_unlink), GFP_ATOMIC);
                if (!unlink) {
-                       usbip_uerr("malloc vhci_unlink\n");
+                       pr_err("malloc vhci_unlink\n");
                        spin_unlock_irqrestore(&vdev->priv_lock, flags2);
                        spin_unlock_irqrestore(&the_controller->lock, flags);
                        usbip_event_add(&vdev->ud, VDEV_EVENT_ERROR_MALLOC);
@@ -797,12 +767,11 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
 
                unlink->seqnum = atomic_inc_return(&the_controller->seqnum);
                if (unlink->seqnum == 0xffff)
-                       usbip_uinfo("seqnum max\n");
+                       pr_info("seqnum max\n");
 
                unlink->unlink_seqnum = priv->seqnum;
 
-               usbip_uinfo("vhci_hcd: device %p seems to be still connected\n",
-                                                                       vdev);
+               pr_info("device %p seems to be still connected\n", vdev);
 
                /* send cmd_unlink and try to cancel the pending URB in the
                 * peer */
@@ -825,7 +794,7 @@ static void vhci_device_unlink_cleanup(struct vhci_device *vdev)
        spin_lock(&vdev->priv_lock);
 
        list_for_each_entry_safe(unlink, tmp, &vdev->unlink_tx, list) {
-               usbip_uinfo("unlink cleanup tx %lu\n", unlink->unlink_seqnum);
+               pr_info("unlink cleanup tx %lu\n", unlink->unlink_seqnum);
                list_del(&unlink->list);
                kfree(unlink);
        }
@@ -834,12 +803,12 @@ static void vhci_device_unlink_cleanup(struct vhci_device *vdev)
                struct urb *urb;
 
                /* give back URB of unanswered unlink request */
-               usbip_uinfo("unlink cleanup rx %lu\n", unlink->unlink_seqnum);
+               pr_info("unlink cleanup rx %lu\n", unlink->unlink_seqnum);
 
                urb = pickup_urb_and_free_priv(vdev, unlink->unlink_seqnum);
                if (!urb) {
-                       usbip_uinfo("the urb (seqnum %lu) was already given back\n",
-                                                       unlink->unlink_seqnum);
+                       pr_info("the urb (seqnum %lu) was already given back\n",
+                               unlink->unlink_seqnum);
                        list_del(&unlink->list);
                        kfree(unlink);
                        continue;
@@ -851,7 +820,8 @@ static void vhci_device_unlink_cleanup(struct vhci_device *vdev)
                usb_hcd_unlink_urb_from_ep(vhci_to_hcd(the_controller), urb);
                spin_unlock(&the_controller->lock);
 
-               usb_hcd_giveback_urb(vhci_to_hcd(the_controller), urb, urb->status);
+               usb_hcd_giveback_urb(vhci_to_hcd(the_controller), urb,
+                                    urb->status);
 
                list_del(&unlink->list);
                kfree(unlink);
@@ -871,7 +841,7 @@ static void vhci_shutdown_connection(struct usbip_device *ud)
 
        /* need this? see stub_dev.c */
        if (ud->tcp_socket) {
-               usbip_udbg("shutdown tcp_socket %p\n", ud->tcp_socket);
+               pr_debug("shutdown tcp_socket %p\n", ud->tcp_socket);
                kernel_sock_shutdown(ud->tcp_socket, SHUT_RDWR);
        }
 
@@ -881,14 +851,14 @@ static void vhci_shutdown_connection(struct usbip_device *ud)
        if (vdev->ud.tcp_tx)
                kthread_stop(vdev->ud.tcp_tx);
 
-       usbip_uinfo("stop threads\n");
+       pr_info("stop threads\n");
 
        /* active connection is closed */
        if (vdev->ud.tcp_socket != NULL) {
                sock_release(vdev->ud.tcp_socket);
                vdev->ud.tcp_socket = NULL;
        }
-       usbip_uinfo("release socket\n");
+       pr_info("release socket\n");
 
        vhci_device_unlink_cleanup(vdev);
 
@@ -914,7 +884,7 @@ static void vhci_shutdown_connection(struct usbip_device *ud)
         */
        rh_port_disconnect(vdev->rhport);
 
-       usbip_uinfo("disconnect device\n");
+       pr_info("disconnect device\n");
 }
 
 
@@ -932,7 +902,6 @@ static void vhci_device_reset(struct usbip_device *ud)
        vdev->udev = NULL;
 
        ud->tcp_socket = NULL;
-
        ud->status = VDEV_ST_NULL;
 
        spin_unlock(&ud->lock);
@@ -941,9 +910,7 @@ static void vhci_device_reset(struct usbip_device *ud)
 static void vhci_device_unusable(struct usbip_device *ud)
 {
        spin_lock(&ud->lock);
-
        ud->status = VDEV_ST_ERROR;
-
        spin_unlock(&ud->lock);
 }
 
@@ -972,9 +939,6 @@ static void vhci_device_init(struct vhci_device *vdev)
        usbip_start_eh(&vdev->ud);
 }
 
-
-/*----------------------------------------------------------------------*/
-
 static int vhci_start(struct usb_hcd *hcd)
 {
        struct vhci_hcd *vhci = hcd_to_vhci(hcd);
@@ -983,7 +947,6 @@ static int vhci_start(struct usb_hcd *hcd)
 
        usbip_dbg_vhci_hc("enter vhci_start\n");
 
-
        /* initialize private data of usb_hcd */
 
        for (rhport = 0; rhport < VHCI_NPORTS; rhport++) {
@@ -995,17 +958,14 @@ static int vhci_start(struct usb_hcd *hcd)
        atomic_set(&vhci->seqnum, 0);
        spin_lock_init(&vhci->lock);
 
-
-
        hcd->power_budget = 0; /* no limit */
        hcd->state  = HC_STATE_RUNNING;
        hcd->uses_new_polling = 1;
 
-
        /* vhci_hcd is now ready to be controlled through sysfs */
        err = sysfs_create_group(&vhci_dev(vhci)->kobj, &dev_attr_group);
        if (err) {
-               usbip_uerr("create sysfs files\n");
+               pr_err("create sysfs files\n");
                return err;
        }
 
@@ -1019,7 +979,6 @@ static void vhci_stop(struct usb_hcd *hcd)
 
        usbip_dbg_vhci_hc("stop VHCI controller\n");
 
-
        /* 1. remove the userland interface of vhci_hcd */
        sysfs_remove_group(&vhci_dev(vhci)->kobj, &dev_attr_group);
 
@@ -1030,20 +989,14 @@ static void vhci_stop(struct usb_hcd *hcd)
                usbip_event_add(&vdev->ud, VDEV_EVENT_REMOVED);
                usbip_stop_eh(&vdev->ud);
        }
-
-
-       usbip_uinfo("vhci_stop done\n");
 }
 
-/*----------------------------------------------------------------------*/
-
 static int vhci_get_frame_number(struct usb_hcd *hcd)
 {
-       usbip_uerr("Not yet implemented\n");
+       pr_err("Not yet implemented\n");
        return 0;
 }
 
-
 #ifdef CONFIG_PM
 
 /* FIXME: suspend/resume */
@@ -1091,8 +1044,6 @@ static int vhci_bus_resume(struct usb_hcd *hcd)
 #define vhci_bus_resume       NULL
 #endif
 
-
-
 static struct hc_driver vhci_hc_driver = {
        .description    = driver_name,
        .product_desc   = driver_desc,
@@ -1119,8 +1070,6 @@ static int vhci_hcd_probe(struct platform_device *pdev)
        struct usb_hcd          *hcd;
        int                     ret;
 
-       usbip_uinfo("proving...\n");
-
        usbip_dbg_vhci_hc("name %s id %d\n", pdev->name, pdev->id);
 
        /* will be removed */
@@ -1135,7 +1084,7 @@ static int vhci_hcd_probe(struct platform_device *pdev)
         */
        hcd = usb_create_hcd(&vhci_hc_driver, &pdev->dev, dev_name(&pdev->dev));
        if (!hcd) {
-               usbip_uerr("create hcd failed\n");
+               pr_err("create hcd failed\n");
                return -ENOMEM;
        }
        hcd->has_tt = 1;
@@ -1149,18 +1098,16 @@ static int vhci_hcd_probe(struct platform_device *pdev)
         */
        ret = usb_add_hcd(hcd, 0, 0);
        if (ret != 0) {
-               usbip_uerr("usb_add_hcd failed %d\n", ret);
+               pr_err("usb_add_hcd failed %d\n", ret);
                usb_put_hcd(hcd);
                the_controller = NULL;
                return ret;
        }
 
-
        usbip_dbg_vhci_hc("bye\n");
        return 0;
 }
 
-
 static int vhci_hcd_remove(struct platform_device *pdev)
 {
        struct usb_hcd  *hcd;
@@ -1178,12 +1125,9 @@ static int vhci_hcd_remove(struct platform_device *pdev)
        usb_put_hcd(hcd);
        the_controller = NULL;
 
-
        return 0;
 }
 
-
-
 #ifdef CONFIG_PM
 
 /* what should happen for USB/IP under suspend/resume? */
@@ -1194,25 +1138,23 @@ static int vhci_hcd_suspend(struct platform_device *pdev, pm_message_t state)
        int connected = 0;
        int ret = 0;
 
-       dev_dbg(&pdev->dev, "%s\n", __func__);
-
        hcd = platform_get_drvdata(pdev);
 
        spin_lock(&the_controller->lock);
 
        for (rhport = 0; rhport < VHCI_NPORTS; rhport++)
                if (the_controller->port_status[rhport] &
-                                               USB_PORT_STAT_CONNECTION)
+                   USB_PORT_STAT_CONNECTION)
                        connected += 1;
 
        spin_unlock(&the_controller->lock);
 
        if (connected > 0) {
-               usbip_uinfo("We have %d active connection%s. Do not suspend.\n",
-                               connected, (connected == 1 ? "" : "s"));
+               dev_info(&pdev->dev, "We have %d active connection%s. Do not "
+                        "suspend.\n", connected, (connected == 1 ? "" : "s"));
                ret =  -EBUSY;
        } else {
-               usbip_uinfo("suspend vhci_hcd");
+               dev_info(&pdev->dev, "suspend vhci_hcd");
                clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
        }
 
@@ -1239,7 +1181,6 @@ static int vhci_hcd_resume(struct platform_device *pdev)
 
 #endif
 
-
 static struct platform_driver vhci_driver = {
        .probe  = vhci_hcd_probe,
        .remove = __devexit_p(vhci_hcd_remove),
@@ -1251,8 +1192,6 @@ static struct platform_driver vhci_driver = {
        },
 };
 
-/*----------------------------------------------------------------------*/
-
 /*
  * The VHCI 'device' is 'virtual'; not a real plug&play hardware.
  * We need to add this virtual device as a platform device arbitrarily:
@@ -1277,13 +1216,9 @@ static int __init vhci_init(void)
 {
        int ret;
 
-       usbip_dbg_vhci_hc("enter\n");
        if (usb_disabled())
                return -ENODEV;
 
-       printk(KERN_INFO KBUILD_MODNAME ": %s, %s\n", driver_name,
-              DRIVER_VERSION);
-
        ret = platform_driver_register(&vhci_driver);
        if (ret < 0)
                goto err_driver_register;
@@ -1292,26 +1227,25 @@ static int __init vhci_init(void)
        if (ret < 0)
                goto err_platform_device_register;
 
-       usbip_dbg_vhci_hc("bye\n");
+       pr_info(DRIVER_DESC " v" USBIP_VERSION "\n");
        return ret;
 
-       /* error occurred */
 err_platform_device_register:
        platform_driver_unregister(&vhci_driver);
-
 err_driver_register:
-       usbip_dbg_vhci_hc("bye\n");
        return ret;
 }
-module_init(vhci_init);
 
 static void __exit vhci_cleanup(void)
 {
-       usbip_dbg_vhci_hc("enter\n");
-
        platform_device_unregister(&the_pdev);
        platform_driver_unregister(&vhci_driver);
-
-       usbip_dbg_vhci_hc("bye\n");
 }
+
+module_init(vhci_init);
 module_exit(vhci_cleanup);
+
+MODULE_AUTHOR(DRIVER_AUTHOR);
+MODULE_DESCRIPTION(DRIVER_DESC);
+MODULE_LICENSE("GPL");
+MODULE_VERSION(USBIP_VERSION);
index 2ffc96a4c0d4e3c11a6e0836d51f9b41af350770..e42ce9dab7ac5cf15676b7ac935a0fa21dea5431 100644 (file)
  * USA.
  */
 
-#include <linux/slab.h>
 #include <linux/kthread.h>
+#include <linux/slab.h>
 
 #include "usbip_common.h"
 #include "vhci.h"
 
-
 /* get URB from transmitted urb queue. caller must hold vdev->priv_lock */
-struct urb *pickup_urb_and_free_priv(struct vhci_device *vdev,
-                                           __u32 seqnum)
+struct urb *pickup_urb_and_free_priv(struct vhci_device *vdev, __u32 seqnum)
 {
        struct vhci_priv *priv, *tmp;
        struct urb *urb = NULL;
@@ -38,12 +36,12 @@ struct urb *pickup_urb_and_free_priv(struct vhci_device *vdev,
                        status = urb->status;
 
                        usbip_dbg_vhci_rx("find urb %p vurb %p seqnum %u\n",
-                                   urb, priv, seqnum);
+                                         urb, priv, seqnum);
 
                        /* TODO: fix logic here to improve indent situtation */
                        if (status != -EINPROGRESS) {
                                if (status == -ENOENT ||
-                                    status == -ECONNRESET)
+                                   status == -ECONNRESET)
                                        dev_info(&urb->dev->dev,
                                                 "urb %p was unlinked "
                                                 "%ssynchronuously.\n", urb,
@@ -66,36 +64,30 @@ struct urb *pickup_urb_and_free_priv(struct vhci_device *vdev,
 }
 
 static void vhci_recv_ret_submit(struct vhci_device *vdev,
-                                               struct usbip_header *pdu)
+                                struct usbip_header *pdu)
 {
        struct usbip_device *ud = &vdev->ud;
        struct urb *urb;
 
        spin_lock(&vdev->priv_lock);
-
        urb = pickup_urb_and_free_priv(vdev, pdu->base.seqnum);
-
        spin_unlock(&vdev->priv_lock);
 
        if (!urb) {
-               usbip_uerr("cannot find a urb of seqnum %u\n",
-                                                       pdu->base.seqnum);
-               usbip_uinfo("max seqnum %d\n",
-                                       atomic_read(&the_controller->seqnum));
+               pr_err("cannot find a urb of seqnum %u\n", pdu->base.seqnum);
+               pr_info("max seqnum %d\n",
+                       atomic_read(&the_controller->seqnum));
                usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
                return;
        }
 
-
        /* unpack the pdu to a urb */
        usbip_pack_pdu(pdu, urb, USBIP_RET_SUBMIT, 0);
 
-
        /* recv transfer buffer */
        if (usbip_recv_xbuff(ud, urb) < 0)
                return;
 
-
        /* recv iso_packet_descriptor */
        if (usbip_recv_iso(ud, urb) < 0)
                return;
@@ -107,7 +99,6 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
        if (usbip_dbg_flag_vhci_rx)
                usbip_dump_urb(urb);
 
-
        usbip_dbg_vhci_rx("now giveback urb %p\n", urb);
 
        spin_lock(&the_controller->lock);
@@ -116,25 +107,23 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
 
        usb_hcd_giveback_urb(vhci_to_hcd(the_controller), urb, urb->status);
 
-
        usbip_dbg_vhci_rx("Leave\n");
 
        return;
 }
 
-
 static struct vhci_unlink *dequeue_pending_unlink(struct vhci_device *vdev,
-               struct usbip_header *pdu)
+                                                 struct usbip_header *pdu)
 {
        struct vhci_unlink *unlink, *tmp;
 
        spin_lock(&vdev->priv_lock);
 
        list_for_each_entry_safe(unlink, tmp, &vdev->unlink_rx, list) {
-               usbip_uinfo("unlink->seqnum %lu\n", unlink->seqnum);
+               pr_info("unlink->seqnum %lu\n", unlink->seqnum);
                if (unlink->seqnum == pdu->base.seqnum) {
                        usbip_dbg_vhci_rx("found pending unlink, %lu\n",
-                                                       unlink->seqnum);
+                                         unlink->seqnum);
                        list_del(&unlink->list);
 
                        spin_unlock(&vdev->priv_lock);
@@ -147,9 +136,8 @@ static struct vhci_unlink *dequeue_pending_unlink(struct vhci_device *vdev,
        return NULL;
 }
 
-
 static void vhci_recv_ret_unlink(struct vhci_device *vdev,
-                                               struct usbip_header *pdu)
+                                struct usbip_header *pdu)
 {
        struct vhci_unlink *unlink;
        struct urb *urb;
@@ -158,15 +146,13 @@ static void vhci_recv_ret_unlink(struct vhci_device *vdev,
 
        unlink = dequeue_pending_unlink(vdev, pdu);
        if (!unlink) {
-               usbip_uinfo("cannot find the pending unlink %u\n",
-                                                       pdu->base.seqnum);
+               pr_info("cannot find the pending unlink %u\n",
+                       pdu->base.seqnum);
                return;
        }
 
        spin_lock(&vdev->priv_lock);
-
        urb = pickup_urb_and_free_priv(vdev, unlink->unlink_seqnum);
-
        spin_unlock(&vdev->priv_lock);
 
        if (!urb) {
@@ -175,21 +161,21 @@ static void vhci_recv_ret_unlink(struct vhci_device *vdev,
                 * already received the result of its submit result and gave
                 * back the URB.
                 */
-               usbip_uinfo("the urb (seqnum %d) was already given backed\n",
-                                                       pdu->base.seqnum);
+               pr_info("the urb (seqnum %d) was already given backed\n",
+                       pdu->base.seqnum);
        } else {
                usbip_dbg_vhci_rx("now giveback urb %p\n", urb);
 
                /* If unlink is succeed, status is -ECONNRESET */
                urb->status = pdu->u.ret_unlink.status;
-               usbip_uinfo("%d\n", urb->status);
+               pr_info("urb->status %d\n", urb->status);
 
                spin_lock(&the_controller->lock);
                usb_hcd_unlink_urb_from_ep(vhci_to_hcd(the_controller), urb);
                spin_unlock(&the_controller->lock);
 
                usb_hcd_giveback_urb(vhci_to_hcd(the_controller), urb,
-                                                               urb->status);
+                                    urb->status);
        }
 
        kfree(unlink);
@@ -202,9 +188,7 @@ static int vhci_priv_tx_empty(struct vhci_device *vdev)
        int empty = 0;
 
        spin_lock(&vdev->priv_lock);
-
        empty = list_empty(&vdev->priv_rx);
-
        spin_unlock(&vdev->priv_lock);
 
        return empty;
@@ -217,7 +201,6 @@ static void vhci_rx_pdu(struct usbip_device *ud)
        struct usbip_header pdu;
        struct vhci_device *vdev = container_of(ud, struct vhci_device, ud);
 
-
        usbip_dbg_vhci_rx("Enter\n");
 
        memset(&pdu, 0, sizeof(pdu));
@@ -226,26 +209,26 @@ static void vhci_rx_pdu(struct usbip_device *ud)
        ret = usbip_xmit(0, ud->tcp_socket, (char *) &pdu, sizeof(pdu), 0);
        if (ret < 0) {
                if (ret == -ECONNRESET)
-                       usbip_uinfo("connection reset by peer\n");
+                       pr_info("connection reset by peer\n");
                else if (ret == -EAGAIN) {
                        /* ignore if connection was idle */
                        if (vhci_priv_tx_empty(vdev))
                                return;
-                       usbip_uinfo("connection timed out with pending urbs\n");
+                       pr_info("connection timed out with pending urbs\n");
                } else if (ret != -ERESTARTSYS)
-                       usbip_uinfo("xmit failed %d\n", ret);
+                       pr_info("xmit failed %d\n", ret);
 
                usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
                return;
        }
        if (ret == 0) {
-               usbip_uinfo("connection closed");
+               pr_info("connection closed");
                usbip_event_add(ud, VDEV_EVENT_DOWN);
                return;
        }
        if (ret != sizeof(pdu)) {
-               usbip_uerr("received pdu size is %d, should be %d\n",
-                                       ret, (unsigned int)sizeof(pdu));
+               pr_err("received pdu size is %d, should be %d\n", ret,
+                      (unsigned int)sizeof(pdu));
                usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
                return;
        }
@@ -263,21 +246,18 @@ static void vhci_rx_pdu(struct usbip_device *ud)
                vhci_recv_ret_unlink(vdev, &pdu);
                break;
        default:
-               /* NOTREACHED */
-               usbip_uerr("unknown pdu %u\n", pdu.base.command);
+               /* NOT REACHED */
+               pr_err("unknown pdu %u\n", pdu.base.command);
                usbip_dump_header(&pdu);
                usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
+               break;
        }
 }
 
-
-/*-------------------------------------------------------------------------*/
-
 int vhci_rx_loop(void *data)
 {
        struct usbip_device *ud = data;
 
-
        while (!kthread_should_stop()) {
                if (usbip_event_happened(ud))
                        break;
index e2dadbd5ef1e2707956faa774f3c42ec44c039d4..d9736f9c4028bc38b04850ee3d002c131d888a71 100644 (file)
  * USA.
  */
 
+#include <linux/kthread.h>
+#include <linux/net.h>
+
 #include "usbip_common.h"
 #include "vhci.h"
 
-#include <linux/in.h>
-#include <linux/kthread.h>
-
 /* TODO: refine locking ?*/
 
 /* Sysfs entry to show port status */
@@ -53,20 +53,19 @@ static ssize_t show_status(struct device *dev, struct device_attribute *attr,
                struct vhci_device *vdev = port_to_vdev(i);
 
                spin_lock(&vdev->ud.lock);
-
                out += sprintf(out, "%03u %03u ", i, vdev->ud.status);
 
                if (vdev->ud.status == VDEV_ST_USED) {
                        out += sprintf(out, "%03u %08x ",
-                                       vdev->speed, vdev->devid);
+                                      vdev->speed, vdev->devid);
                        out += sprintf(out, "%16p ", vdev->ud.tcp_socket);
                        out += sprintf(out, "%s", dev_name(&vdev->udev->dev));
 
-               } else
+               } else {
                        out += sprintf(out, "000 000 000 0000000000000000 0-0");
+               }
 
                out += sprintf(out, "\n");
-
                spin_unlock(&vdev->ud.lock);
        }
 
@@ -90,7 +89,7 @@ static int vhci_port_disconnect(__u32 rhport)
 
        spin_lock(&vdev->ud.lock);
        if (vdev->ud.status == VDEV_ST_NULL) {
-               usbip_uerr("not connected %d\n", vdev->ud.status);
+               pr_err("not connected %d\n", vdev->ud.status);
 
                /* unlock */
                spin_unlock(&vdev->ud.lock);
@@ -118,7 +117,7 @@ static ssize_t store_detach(struct device *dev, struct device_attribute *attr,
 
        /* check rhport */
        if (rhport >= VHCI_NPORTS) {
-               usbip_uerr("invalid port %u\n", rhport);
+               dev_err(dev, "invalid port %u\n", rhport);
                return -EINVAL;
        }
 
@@ -127,6 +126,7 @@ static ssize_t store_detach(struct device *dev, struct device_attribute *attr,
                return -EINVAL;
 
        usbip_dbg_vhci_sysfs("Leave\n");
+
        return count;
 }
 static DEVICE_ATTR(detach, S_IWUSR, NULL, store_detach);
@@ -136,7 +136,7 @@ static int valid_args(__u32 rhport, enum usb_device_speed speed)
 {
        /* check rhport */
        if ((rhport < 0) || (rhport >= VHCI_NPORTS)) {
-               usbip_uerr("port %u\n", rhport);
+               pr_err("port %u\n", rhport);
                return -EINVAL;
        }
 
@@ -148,7 +148,7 @@ static int valid_args(__u32 rhport, enum usb_device_speed speed)
        case USB_SPEED_WIRELESS:
                break;
        default:
-               usbip_uerr("speed %d\n", speed);
+               pr_err("speed %d\n", speed);
                return -EINVAL;
        }
 
@@ -183,8 +183,7 @@ static ssize_t store_attach(struct device *dev, struct device_attribute *attr,
        sscanf(buf, "%u %u %u %u", &rhport, &sockfd, &devid, &speed);
 
        usbip_dbg_vhci_sysfs("rhport(%u) sockfd(%u) devid(%u) speed(%u)\n",
-                               rhport, sockfd, devid, speed);
-
+                            rhport, sockfd, devid, speed);
 
        /* check received parameters */
        if (valid_args(rhport, speed) < 0)
@@ -199,9 +198,7 @@ static ssize_t store_attach(struct device *dev, struct device_attribute *attr,
 
        /* begin a lock */
        spin_lock(&the_controller->lock);
-
        vdev = port_to_vdev(rhport);
-
        spin_lock(&vdev->ud.lock);
 
        if (vdev->ud.status != VDEV_ST_NULL) {
@@ -209,12 +206,12 @@ static ssize_t store_attach(struct device *dev, struct device_attribute *attr,
                spin_unlock(&vdev->ud.lock);
                spin_unlock(&the_controller->lock);
 
-               usbip_uerr("port %d already used\n", rhport);
+               dev_err(dev, "port %d already used\n", rhport);
                return -EINVAL;
        }
 
-       usbip_uinfo("rhport(%u) sockfd(%d) devid(%u) speed(%u)\n",
-                               rhport, sockfd, devid, speed);
+       dev_info(dev, "rhport(%u) sockfd(%d) devid(%u) speed(%u)\n",
+                rhport, sockfd, devid, speed);
 
        vdev->devid         = devid;
        vdev->speed         = speed;
index d9ab49d6769734870514924a065e7a2b2b5f53a0..9b437e7ef1a764032a6c63e23852a1e62440d8ae 100644 (file)
  * USA.
  */
 
-#include <linux/slab.h>
 #include <linux/kthread.h>
+#include <linux/slab.h>
 
 #include "usbip_common.h"
 #include "vhci.h"
 
-
 static void setup_cmd_submit_pdu(struct usbip_header *pdup,  struct urb *urb)
 {
        struct vhci_priv *priv = ((struct vhci_priv *)urb->hcpriv);
        struct vhci_device *vdev = priv->vdev;
 
        usbip_dbg_vhci_tx("URB, local devnum %u, remote devid %u\n",
-                               usb_pipedevice(urb->pipe), vdev->devid);
+                         usb_pipedevice(urb->pipe), vdev->devid);
 
-       pdup->base.command = USBIP_CMD_SUBMIT;
-       pdup->base.seqnum  = priv->seqnum;
-       pdup->base.devid   = vdev->devid;
-       if (usb_pipein(urb->pipe))
-               pdup->base.direction = USBIP_DIR_IN;
-       else
-               pdup->base.direction = USBIP_DIR_OUT;
-       pdup->base.ep      = usb_pipeendpoint(urb->pipe);
+       pdup->base.command   = USBIP_CMD_SUBMIT;
+       pdup->base.seqnum    = priv->seqnum;
+       pdup->base.devid     = vdev->devid;
+       pdup->base.direction = usb_pipein(urb->pipe) ?
+               USBIP_DIR_IN : USBIP_DIR_OUT;
+       pdup->base.ep        = usb_pipeendpoint(urb->pipe);
 
        usbip_pack_pdu(pdup, urb, USBIP_CMD_SUBMIT, 1);
 
@@ -65,8 +62,6 @@ static struct vhci_priv *dequeue_from_priv_tx(struct vhci_device *vdev)
        return NULL;
 }
 
-
-
 static int vhci_send_cmd_submit(struct vhci_device *vdev)
 {
        struct vhci_priv *priv = NULL;
@@ -90,7 +85,6 @@ static int vhci_send_cmd_submit(struct vhci_device *vdev)
 
                usbip_dbg_vhci_tx("setup txdata urb %p\n", urb);
 
-
                /* 1. setup usbip_header */
                setup_cmd_submit_pdu(&pdu_header, urb);
                usbip_header_correct_endian(&pdu_header, 1);
@@ -124,8 +118,8 @@ static int vhci_send_cmd_submit(struct vhci_device *vdev)
 
                ret = kernel_sendmsg(vdev->ud.tcp_socket, &msg, iov, 3, txsize);
                if (ret != txsize) {
-                       usbip_uerr("sendmsg failed!, retval %d for %zd\n", ret,
-                                                                       txsize);
+                       pr_err("sendmsg failed!, ret=%d for %zd\n", ret,
+                              txsize);
                        kfree(iso_buffer);
                        usbip_event_add(&vdev->ud, VDEV_EVENT_ERROR_TCP);
                        return -1;
@@ -140,9 +134,6 @@ static int vhci_send_cmd_submit(struct vhci_device *vdev)
        return total_size;
 }
 
-
-/*-------------------------------------------------------------------------*/
-
 static struct vhci_unlink *dequeue_from_unlink_tx(struct vhci_device *vdev)
 {
        unsigned long flags;
@@ -182,7 +173,6 @@ static int vhci_send_cmd_unlink(struct vhci_device *vdev)
 
                usbip_dbg_vhci_tx("setup cmd unlink, %lu\n", unlink->seqnum);
 
-
                /* 1. setup usbip_header */
                pdu_header.base.command = USBIP_CMD_UNLINK;
                pdu_header.base.seqnum  = unlink->seqnum;
@@ -198,13 +188,12 @@ static int vhci_send_cmd_unlink(struct vhci_device *vdev)
 
                ret = kernel_sendmsg(vdev->ud.tcp_socket, &msg, iov, 1, txsize);
                if (ret != txsize) {
-                       usbip_uerr("sendmsg failed!, retval %d for %zd\n", ret,
-                                                                       txsize);
+                       pr_err("sendmsg failed!, ret=%d for %zd\n", ret,
+                              txsize);
                        usbip_event_add(&vdev->ud, VDEV_EVENT_ERROR_TCP);
                        return -1;
                }
 
-
                usbip_dbg_vhci_tx("send txdata\n");
 
                total_size += txsize;
@@ -213,9 +202,6 @@ static int vhci_send_cmd_unlink(struct vhci_device *vdev)
        return total_size;
 }
 
-
-/*-------------------------------------------------------------------------*/
-
 int vhci_tx_loop(void *data)
 {
        struct usbip_device *ud = data;
@@ -229,9 +215,9 @@ int vhci_tx_loop(void *data)
                        break;
 
                wait_event_interruptible(vdev->waitq_tx,
-                               (!list_empty(&vdev->priv_tx) ||
-                                !list_empty(&vdev->unlink_tx) ||
-                                kthread_should_stop()));
+                                        (!list_empty(&vdev->priv_tx) ||
+                                         !list_empty(&vdev->unlink_tx) ||
+                                         kthread_should_stop()));
 
                usbip_dbg_vhci_tx("pending urbs ?, now wake up\n");
        }
index 57c1cc90afcc1f809c63c62fb932a008016d4f97..577599ed70ada2db901ba87c465dc69db9dd714b 100644 (file)
@@ -1289,7 +1289,7 @@ start:
              memset(pDevice->skb->cb, 0, sizeof(pDevice->skb->cb));
              netif_rx(pDevice->skb);
              pDevice->skb = dev_alloc_skb((int)pDevice->rx_buf_sz);
-         };
+         }
    #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
   // if(pDevice->bWPASuppWextEnabled == true)
       {
@@ -1489,7 +1489,7 @@ BSSvUpdateNodeTxCounter(
                     }
                 }
             }
-        };
+        }
 
         if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) ||
             (pMgmt->eCurrMode == WMAC_MODE_ESS_AP)) {
@@ -1543,9 +1543,9 @@ BSSvUpdateNodeTxCounter(
                         }
                     }
                 }
-            };
+            }
         }
-    };
+    }
 
     return;
 
index 2e7c2fd7b7e6b306edc20297cc32c2717077705d..780205c0a88b7d3183e703a59153e9c07a343b86 100644 (file)
@@ -396,7 +396,7 @@ typedef struct __device_info {
 
     struct pci_dev*             pcid;
 
-#if CONFIG_PM
+#ifdef CONFIG_PM
     u32                         pci_state[16];
 #endif
 
index ad39c8727e9b2e892d0c27757d35c91f862996d4..3d2a9ba16b15cdcfb3c37ceb866373f096b72886 100644 (file)
@@ -900,7 +900,7 @@ static bool device_release_WPADEV(PSDevice pDevice)
                if(ii>20)
                  break;
               }
-           };
+           }
     return true;
 }
 
@@ -1446,7 +1446,7 @@ static void device_init_defrag_cb(PSDevice pDevice) {
         if (!device_alloc_frag_buf(pDevice, pDeF)) {
             DBG_PRT(MSG_LEVEL_ERR,KERN_ERR "%s: can not alloc frag bufs\n",
                 pDevice->dev->name);
-        };
+        }
     }
     pDevice->cbDFCB = CB_MAX_RX_FRAG;
     pDevice->cbFreeDFCB = pDevice->cbDFCB;
@@ -2104,7 +2104,7 @@ static int device_dma0_tx_80211(struct sk_buff *skb, struct net_device *dev) {
         dev_kfree_skb_irq(skb);
         spin_unlock_irq(&pDevice->lock);
         return 0;
-    };
+    }
 
     cbMPDULen = skb->len;
     pbMPDU = skb->data;
@@ -2136,7 +2136,7 @@ bool device_dma0_xmit(PSDevice pDevice, struct sk_buff *skb, unsigned int uNodeI
     if (pDevice->bStopTx0Pkt == true) {
         dev_kfree_skb_irq(skb);
         return false;
-    };
+    }
 
     if (AVAIL_TD(pDevice, TYPE_TXDMA0) <= 0) {
         dev_kfree_skb_irq(skb);
@@ -2865,7 +2865,7 @@ static  irqreturn_t  device_intr(int irq,  void *dev_instance) {
             pDevice->bBeaconSent = false;
             if (pDevice->bEnablePSMode) {
                 PSbIsNextTBTTWakeUp((void *)pDevice);
-            };
+            }
 
             if ((pDevice->eOPMode == OP_MODE_AP) ||
                 (pDevice->eOPMode == OP_MODE_ADHOC)) {
@@ -2876,7 +2876,7 @@ static  irqreturn_t  device_intr(int irq,  void *dev_instance) {
 
             if (pDevice->eOPMode == OP_MODE_ADHOC && pDevice->pMgmt->wCurrATIMWindow > 0) {
                 // todo adhoc PS mode
-            };
+            }
 
         }
 
@@ -2885,7 +2885,7 @@ static  irqreturn_t  device_intr(int irq,  void *dev_instance) {
             if (pDevice->eOPMode == OP_MODE_ADHOC) {
                 pDevice->bIsBeaconBufReadySet = false;
                 pDevice->cbBeaconBufReadySetCnt = 0;
-            };
+            }
 
             if (pDevice->eOPMode == OP_MODE_AP) {
                 if(pMgmt->byDTIMCount > 0) {
index 15130733693ed8bbc9262ab335c93394f02d5370..cf0deacd9da7ae12ac71d0b2f8715cd3ce7fa6d2 100644 (file)
@@ -700,7 +700,7 @@ device_receive_frame (
                 pDevice->pMgmt->bInTIMWake = false;
             }
         }
-    };
+    }
 
     // Now it only supports 802.11g Infrastructure Mode, and support rate must up to 54 Mbps
     if (pDevice->bDiversityEnable && (FrameSize>50) &&
@@ -884,7 +884,7 @@ device_receive_frame (
                      memset(pDevice->skb->cb, 0, sizeof(pDevice->skb->cb));
                      netif_rx(pDevice->skb);
                      pDevice->skb = dev_alloc_skb((int)pDevice->rx_buf_sz);
-                 };
+                 }
 
                 return false;
 
@@ -1049,7 +1049,7 @@ static bool s_bAPModeRxCtl (
                                          );
                     DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "dpc: send vMgrDeAuthenBeginSta 1\n");
                     return true;
-                };
+                }
                 if (pMgmt->sNodeDBTable[iSANodeIndex].eNodeState < NODE_ASSOC) {
                     // send deassoc notification
                     // reason = (7) class 3 received from nonassoc sta
@@ -1061,7 +1061,7 @@ static bool s_bAPModeRxCtl (
                                          );
                     DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "dpc: send vMgrDisassocBeginSta 2\n");
                     return true;
-                };
+                }
 
                 if (pMgmt->sNodeDBTable[iSANodeIndex].bPSEnable) {
                     // delcare received ps-poll event
@@ -1486,7 +1486,7 @@ static bool s_bAPModeRxData (
                     bRelayOnly = true;
                 }
             }
-        };
+        }
     }
 
     if (bRelayOnly || bRelayAndForward) {
index 5624a41e3d5ea19f3813cd111c85592ec42cbf17..8cf88c3b68da3ab46129dee4e24b656a67033e09 100644 (file)
@@ -91,7 +91,7 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq) {
         if (copy_from_user(&sScanCmd, pReq->data, sizeof(SCmdScan))) {
                        result = -EFAULT;
                        break;
-               };
+               }
 
         pItemSSID = (PWLAN_IE_SSID)sScanCmd.ssid;
         if (pItemSSID->len != 0) {
@@ -128,7 +128,7 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq) {
         if (copy_from_user(&sZoneTypeCmd, pReq->data, sizeof(SCmdZoneTypeSet))) {
                        result = -EFAULT;
                        break;
-               };
+               }
 
           if(sZoneTypeCmd.bWrite==true) {
          //////write zonetype
@@ -167,7 +167,7 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq) {
           if (copy_to_user(pReq->data, &sZoneTypeCmd, sizeof(SCmdZoneTypeSet))) {
                        result = -EFAULT;
                        break;
-               };
+               }
        }
 
             break;
@@ -186,7 +186,7 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq) {
         if (copy_from_user(&sJoinCmd, pReq->data, sizeof(SCmdBSSJoin))) {
                        result = -EFAULT;
                        break;
-               };
+               }
 
         pItemSSID = (PWLAN_IE_SSID)sJoinCmd.ssid;
         memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
@@ -234,7 +234,7 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq) {
         if (copy_from_user(&sWEPCmd, pReq->data, sizeof(SCmdSetWEP))) {
                        result = -EFAULT;
                        break;
-               };
+               }
            if (sWEPCmd.bEnableWep != true) {
             pDevice->bEncryptionEnable = false;
             pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
@@ -300,7 +300,7 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq) {
         if (copy_to_user(pReq->data, &sLinkStatus, sizeof(SCmdLinkStatus))) {
                        result = -EFAULT;
                        break;
-               };
+               }
 
         break;
 
@@ -312,12 +312,12 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq) {
             if (!pBSS->bActive)
                 continue;
             cbListCount++;
-        };
+        }
         sList.uItem = cbListCount;
         if (copy_to_user(pReq->data, &sList, sizeof(SBSSIDList))) {
                        result = -EFAULT;
                        break;
-               };
+               }
         pReq->wResult = 0;
         break;
 
@@ -325,7 +325,7 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq) {
         if (copy_from_user(&sList, pReq->data, sizeof(SBSSIDList))) {
                        result = -EFAULT;
                        break;
-               };
+               }
         pList = (PSBSSIDList)kmalloc(sizeof(SBSSIDList) + (sList.uItem * sizeof(SBSSIDItem)), (int)GFP_ATOMIC);
         if (pList == NULL) {
             result = -ENOMEM;
@@ -367,7 +367,7 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq) {
         if (copy_to_user(pReq->data, pList, sizeof(SBSSIDList) + (sList.uItem * sizeof(SBSSIDItem)))) {
                        result = -EFAULT;
                        break;
-               };
+               }
         kfree(pList);
         pReq->wResult = 0;
         break;
@@ -376,14 +376,14 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq) {
         if (copy_to_user(pReq->data, &(pDevice->s802_11Counter), sizeof(SDot11MIBCount))) {
                        result = -EFAULT;
                        break;
-               };
+               }
         break;
 
     case WLAN_CMD_GET_STAT:
         if (copy_to_user(pReq->data, &(pDevice->scStatistic), sizeof(SStatCounter))) {
                        result = -EFAULT;
                        break;
-               };
+               }
         break;
     case WLAN_CMD_STOP_MAC:
 
@@ -427,7 +427,7 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq) {
         if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) {
                        result = -EFAULT;
                        break;
-               };
+               }
                if (sValue.dwValue == 1) {
             if (vt6655_hostap_set_hostapd(pDevice, 1, 1) == 0){
                 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable HOSTAP\n");
@@ -455,7 +455,7 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq) {
         if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) {
                        result = -EFAULT;
                        break;
-               };
+               }
 
                if (sValue.dwValue == 1) {
             pDevice->bEnable8021x = true;
@@ -475,7 +475,7 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq) {
         if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) {
                        result = -EFAULT;
                        break;
-               };
+               }
 
                if (sValue.dwValue == 1) {
             pDevice->bEnableHostWEP = true;
@@ -494,7 +494,7 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq) {
         if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) {
                        result = -EFAULT;
                        break;
-               };
+               }
                if (sValue.dwValue == 1) {
                      DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "up wpadev\n");
                   memcpy(pDevice->wpadev->dev_addr, pDevice->dev->dev_addr, ETH_ALEN);
@@ -519,7 +519,7 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq) {
         if (copy_from_user(&sStartAPCmd, pReq->data, sizeof(SCmdStartAP))) {
                        result = -EFAULT;
                        break;
-               };
+               }
 
            if (sStartAPCmd.wBSSType == AP) {
                pMgmt->eConfigMode = WMAC_CONFIG_AP;
@@ -606,13 +606,13 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq) {
             if (!pNode->bActive)
                 continue;
             cbListCount++;
-        };
+        }
 
         sNodeList.uItem = cbListCount;
         if (copy_to_user(pReq->data, &sNodeList, sizeof(SNodeList))) {
                        result = -EFAULT;
                        break;
-               };
+               }
         pReq->wResult = 0;
         break;
 
@@ -621,7 +621,7 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq) {
         if (copy_from_user(&sNodeList, pReq->data, sizeof(SNodeList))) {
                        result = -EFAULT;
                        break;
-               };
+               }
         pNodeList = (PSNodeList)kmalloc(sizeof(SNodeList) + (sNodeList.uItem * sizeof(SNodeItem)), (int)GFP_ATOMIC);
         if (pNodeList == NULL) {
             result = -ENOMEM;
@@ -657,11 +657,11 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq) {
                    if (jj >= pNodeList->uItem)
                        break;
                }
-               };
+               }
         if (copy_to_user(pReq->data, pNodeList, sizeof(SNodeList) + (sNodeList.uItem * sizeof(SNodeItem)))) {
                        result = -EFAULT;
                        break;
-               };
+               }
         kfree(pNodeList);
         pReq->wResult = 0;
         break;
index 7207aca1301252999d7f920d66df0e8dae328c9d..4c0b02e8f0b5a17c2e85e13ce8d523bb5d405dde 100644 (file)
@@ -221,7 +221,7 @@ PSbConsiderPowerDown(
         ((pDevice->dwIsr& ISR_RXDMA0) != 0) &&
         ((pDevice->dwIsr & ISR_RXDMA1) != 0)){
         return false;
-    };
+    }
 
     if (pMgmt->eCurrMode != WMAC_MODE_IBSS_STA) {
         if (bCheckCountToWakeUp &&
index c920cf694054ec8983256b841079ad96cf9ba8e6..6935b37d5444dbade814e0b66190a35203c0fd97 100644 (file)
@@ -2902,13 +2902,13 @@ vDMA0_tx_80211(PSDevice  pDevice, struct sk_buff *skb, unsigned char *pbMPDU, un
         if (pDevice->bEnableHostWEP) {
             uNodeIndex = 0;
             bNodeExist = true;
-        };
+        }
     }
     else {
         if (pDevice->bEnableHostWEP) {
             if (BSSDBbIsSTAInNodeDB(pDevice->pMgmt, (unsigned char *)(p80211Header->sA3.abyAddr1), &uNodeIndex))
                 bNodeExist = true;
-        };
+        }
         bNeedACK = true;
         pTxBufHead->wFIFOCtl |= FIFOCTL_NEEDACK;
     };
index c30170a2bc445dd6c9d17395bc6143507d10a190..bab3b0116ccca2b9fd50e7898c152176a76bcac9 100644 (file)
@@ -385,7 +385,7 @@ vCommandTimer (
                 spin_unlock_irq(&pDevice->lock);
                 vCommandTimerWait((void *)pDevice, 10);
                 return;
-            };
+            }
 
             if (pMgmt->uScanChannel == 0 ) {
                 pMgmt->uScanChannel = pDevice->byMinChannel;
@@ -519,7 +519,7 @@ vCommandTimer (
                 vCommandTimerWait((void *)pDevice, 10);
                 spin_unlock_irq(&pDevice->lock);
                 return;
-            };
+            }
             DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" CARDbRadioPowerOff\n");
        //2008-09-02  <mark>    by chester
            // CARDbRadioPowerOff(pDevice);
@@ -532,7 +532,7 @@ vCommandTimer (
                 vCommandTimerWait((void *)pDevice, 10);
                 spin_unlock_irq(&pDevice->lock);
                 return;
-            };
+            }
 //2008-09-02  <mark> by chester
            // CARDbRadioPowerOff(pDevice);
             s_bCommandComplete(pDevice);
@@ -619,7 +619,7 @@ printk("chester-abyDesireSSID=%s\n",((PWLAN_IE_SSID)pMgmt->abyDesireSSID)->abySS
                     vMgrCreateOwnIBSS((void *)pDevice, &Status);
                     if (Status != CMD_STATUS_SUCCESS){
                         DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " WLAN_CMD_IBSS_CREATE fail ! \n");
-                    };
+                    }
                     BSSvAddMulticastNode(pDevice);
                 }
             }
@@ -631,7 +631,7 @@ printk("chester-abyDesireSSID=%s\n",((PWLAN_IE_SSID)pMgmt->abyDesireSSID)->abySS
                     vMgrCreateOwnIBSS((void *)pDevice, &Status);
                     if (Status != CMD_STATUS_SUCCESS){
                         DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" WLAN_CMD_IBSS_CREATE fail ! \n");
-                    };
+                    }
                     BSSvAddMulticastNode(pDevice);
                     if (netif_queue_stopped(pDevice->dev)){
                         netif_wake_queue(pDevice->dev);
@@ -783,7 +783,7 @@ printk("chester-abyDesireSSID=%s\n",((PWLAN_IE_SSID)pMgmt->abyDesireSSID)->abySS
                 vMgrCreateOwnIBSS((void *)pDevice, &Status);
                 if (Status != CMD_STATUS_SUCCESS){
                     DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " vMgrCreateOwnIBSS fail ! \n");
-                };
+                }
                 // alway turn off unicast bit
                 MACvRegBitsOff(pDevice->PortOffset, MAC_REG_RCR, RCR_UNICAST);
                 pDevice->byRxMode &= ~RCR_UNICAST;
@@ -814,7 +814,7 @@ printk("chester-abyDesireSSID=%s\n",((PWLAN_IE_SSID)pMgmt->abyDesireSSID)->abySS
                     }
                     pMgmt->sNodeDBTable[0].wEnQueueCnt--;
                 }
-            };
+            }
 
             // PS nodes tx
             for (ii = 1; ii < (MAX_NODE_NUM + 1); ii++) {
index e540110a430e75fc77ccc6edf325c1a70b4edc8b..ab289c30edb4f085a0bdab2a9512c373dc300267 100644 (file)
@@ -661,7 +661,7 @@ vMgrDisassocBeginSta(
     if (*pStatus == CMD_STATUS_PENDING) {
         pMgmt->eCurrState = WMAC_STATE_IDLE;
         *pStatus = CMD_STATUS_SUCCESS;
-    };
+    }
 
     return;
 }
@@ -1019,7 +1019,7 @@ s_vMgrRxAssocResponse(
             (sFrame.pSuppRates == 0)){
             DBG_PORT80(0xCC);
             return;
-        };
+        }
 
         pMgmt->sAssocInfo.AssocInfo.ResponseFixedIEs.Capabilities = *(sFrame.pwCapInfo);
         pMgmt->sAssocInfo.AssocInfo.ResponseFixedIEs.StatusCode = *(sFrame.pwStatus);
@@ -1039,7 +1039,7 @@ s_vMgrRxAssocResponse(
             if ( (pMgmt->wCurrAID >> 14) != (BIT0 | BIT1) )
             {
                 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "AID from AP, has two msb clear.\n");
-            };
+            }
             DBG_PRT(MSG_LEVEL_INFO, KERN_INFO "Association Successful, AID=%d.\n", pMgmt->wCurrAID & ~(BIT14|BIT15));
             pMgmt->eCurrState = WMAC_STATE_ASSOC;
             BSSvUpdateAPNode((void *)pDevice, sFrame.pwCapInfo, sFrame.pSuppRates, sFrame.pExtSuppRates);
@@ -1692,7 +1692,7 @@ s_vMgrRxDisassociation(
         //try to send associate packet again because of inactivity timeout
       //  if (pMgmt->eCurrState == WMAC_STATE_ASSOC) {
        //     vMgrReAssocBeginSta((PSDevice)pDevice, pMgmt, &CmdStatus);
-      //  };
+      //  }
         if ((pDevice->bWPADEVUp) && (pDevice->skb != NULL)) {
              wpahdr = (viawget_wpa_header *)pDevice->skb->data;
              wpahdr->type = VIAWGET_DISASSOC_MSG;
@@ -1707,7 +1707,7 @@ s_vMgrRxDisassociation(
              memset(pDevice->skb->cb, 0, sizeof(pDevice->skb->cb));
              netif_rx(pDevice->skb);
              pDevice->skb = dev_alloc_skb((int)pDevice->rx_buf_sz);
-         };
+         }
 
  #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
   // if(pDevice->bWPASuppWextEnabled == true)
@@ -1778,7 +1778,7 @@ s_vMgrRxDeauthentication(
                     netif_stop_queue(pDevice->dev);
                     pDevice->bLinkPass = false;
                 }
-            };
+            }
 
             if ((pDevice->bWPADEVUp) && (pDevice->skb != NULL)) {
                  wpahdr = (viawget_wpa_header *)pDevice->skb->data;
@@ -1793,7 +1793,7 @@ s_vMgrRxDeauthentication(
                  memset(pDevice->skb->cb, 0, sizeof(pDevice->skb->cb));
                  netif_rx(pDevice->skb);
                  pDevice->skb = dev_alloc_skb((int)pDevice->rx_buf_sz);
-           };
+           }
 
    #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
   // if(pDevice->bWPASuppWextEnabled == true)
@@ -1912,7 +1912,7 @@ s_vMgrRxBeacon(
         (sFrame.pSuppRates == 0) ) {
         DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Rx beacon frame error\n");
         return;
-    };
+    }
 
 
     if (sFrame.pDSParms != NULL) {
@@ -2054,7 +2054,7 @@ if(ChannelExceedZoneType(pDevice,byCurrChannel)==true)
                    sFrame.pSSID->len
                    ) == 0) {
             bIsSSIDEqual = true;
-        };
+        }
     }
 
     if ((WLAN_GET_CAP_INFO_ESS(*sFrame.pwCapInfo)== true) &&
@@ -2138,8 +2138,8 @@ if(ChannelExceedZoneType(pDevice,byCurrChannel)==true)
     if (WLAN_GET_CAP_INFO_ESS(*sFrame.pwCapInfo)) {
         if (sFrame.pCFParms->wCFPDurRemaining > 0) {
             // TODO: deal with CFP period to set NAV
-        };
-    };
+        }
+    }
 
     HIDWORD(qwTimestamp) = cpu_to_le32(HIDWORD(*sFrame.pqwTimestamp));
     LODWORD(qwTimestamp) = cpu_to_le32(LODWORD(*sFrame.pqwTimestamp));
@@ -2160,7 +2160,7 @@ if(ChannelExceedZoneType(pDevice,byCurrChannel)==true)
     }
     else if (HIDWORD(qwTimestamp) < HIDWORD(qwLocalTSF)) {
         bTSFOffsetPostive = false;
-    };
+    }
 
     if (bTSFOffsetPostive) {
         qwTSFOffset = CARDqGetTSFOffset(pRxPacket->byRxRate, (qwTimestamp), (qwLocalTSF));
@@ -2218,7 +2218,7 @@ if(ChannelExceedZoneType(pDevice,byCurrChannel)==true)
                 if (pMgmt->bInTIM) {
                     PSvSendPSPOLL((PSDevice)pDevice);
 //                    DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "BCN:PS-POLL sent..\n");
-                };
+                }
 
             }
             else {
@@ -2231,7 +2231,7 @@ if(ChannelExceedZoneType(pDevice,byCurrChannel)==true)
                 }
                 if(PSbConsiderPowerDown(pDevice, false, false)) {
                    DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "BCN: Power down now...\n");
-                };
+                }
             }
 
         }
@@ -2316,7 +2316,7 @@ if(ChannelExceedZoneType(pDevice,byCurrChannel)==true)
                 pMgmt->sNodeDBTable[0].bActive = true;
                 pMgmt->sNodeDBTable[0].uInActiveCount = 0;
 
-            };
+            }
         }
         else if (bIsSSIDEqual) {
 
@@ -2356,9 +2356,9 @@ if(ChannelExceedZoneType(pDevice,byCurrChannel)==true)
                      // Prepare beacon frame
                      bMgrPrepareBeaconToSend((void *)pDevice, pMgmt);
               //  }
-            };
+            }
         }
-    };
+    }
     // endian issue ???
     // Update TSF
     if (bUpdateTSF) {
@@ -2590,7 +2590,7 @@ vMgrCreateOwnIBSS(
             pMgmt->byCSSPK = KEY_CTL_WEP;
             pMgmt->byCSSGK = KEY_CTL_WEP;
         }
-    };
+    }
 
     pMgmt->byERPContext = 0;
 
@@ -2683,7 +2683,7 @@ vMgrJoinBSSBegin(
        *pStatus = CMD_STATUS_RESOURCES;
         DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "BSS finding:BSS list is empty.\n");
        return;
-    };
+    }
 
     // memset(pMgmt->abyDesireBSSID, 0,  WLAN_BSSID_LEN);
     // Search known BSS list for prefer BSSID or SSID
@@ -2699,7 +2699,7 @@ vMgrJoinBSSBegin(
        pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID;
        DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Scanning [%s] not found, disconnected !\n", pItemSSID->abySSID);
        return;
-    };
+    }
 
     DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "AP(BSS) finding:Found a AP(BSS)..\n");
     if (WLAN_GET_CAP_INFO_ESS(cpu_to_le16(pCurr->wCapInfo))){
@@ -3179,7 +3179,7 @@ s_vMgrFormatTIM(
             }
             wEndIndex = ii;
         }
-    };
+    }
 
 
     // Round start index down to nearest even number
@@ -4343,7 +4343,7 @@ s_vMgrRxProbeResponse(
         DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Probe resp:Fail addr:[%p] \n", pRxPacket->p80211Header);
         DBG_PORT80(0xCC);
         return;
-    };
+    }
 
     if(sFrame.pSSID->len == 0)
        DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Rx Probe resp: SSID len = 0 \n");
@@ -4625,7 +4625,7 @@ vMgrRxManagePacket(
             //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "rx beacon\n");
             if (pMgmt->eScanState != WMAC_NO_SCANNING) {
                 bInScan = true;
-            };
+            }
             s_vMgrRxBeacon(pDevice, pMgmt, pRxPacket, bInScan);
             break;
 
index fbae16de27a78beec74837431d8a023a810dbef3..a0f994ed58feaa8dd29817bab181b8370375bf2f 100644 (file)
@@ -653,7 +653,7 @@ static int wpa_get_scan(PSDevice pDevice,
 
          }
 
-    };
+    }
 
   kfree(ptempBSS);
 
@@ -679,7 +679,7 @@ static int wpa_get_scan(PSDevice pDevice,
         if (!pBSS->bActive)
             continue;
         count++;
-    };
+    }
 
     pBuf = kcalloc(count, sizeof(struct viawget_scan_result), (int)GFP_ATOMIC);
 
@@ -723,7 +723,7 @@ static int wpa_get_scan(PSDevice pDevice,
 
     if (copy_to_user(param->u.scan_results.buf, pBuf, sizeof(struct viawget_scan_result) * count)) {
                ret = -EFAULT;
-       };
+       }
        param->u.scan_results.scan_count = count;
     DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " param->u.scan_results.scan_count = %d\n", count)
 
@@ -832,7 +832,7 @@ else
                break;
        default:
                pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
-       };
+       }
 
 //DavidWang add for WPA_supplicant support open/share mode
 
@@ -875,7 +875,7 @@ if (!((pMgmt->eAuthenMode == WMAC_AUTH_SHAREKEY) ||
     if (pCurr == NULL){
     printk("wpa_set_associate---->hidden mode site survey before associate.......\n");
     bScheduleCommand((void *) pDevice, WLAN_CMD_BSSID_SCAN, pMgmt->abyDesireSSID);
-  };
+  }
 }
 /****************************************************************/
     bScheduleCommand((void *) pDevice, WLAN_CMD_SSID, NULL);
index 2bdd0a2028d2f75f6dd7f90404c004d17cbf6377..af006df4c8e95253e1fe21937a0b2c2c9ed792a7 100644 (file)
@@ -1192,7 +1192,7 @@ if((pMgmt->eCurrState!=WMAC_STATE_ASSOC) &&
              memset(pDevice->skb->cb, 0, sizeof(pDevice->skb->cb));
              netif_rx(pDevice->skb);
              pDevice->skb = dev_alloc_skb((int)pDevice->rx_buf_sz);
-         };
+         }
    #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
   // if(pDevice->bWPASuppWextEnabled == TRUE)
       {
@@ -1416,7 +1416,7 @@ void BSSvUpdateNodeTxCounter(void *hDeviceContext,
                        }
                 }
             }
-        };
+        }
 
        if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) ||
             (pMgmt->eCurrMode == WMAC_MODE_ESS_AP)) {
@@ -1472,9 +1472,9 @@ void BSSvUpdateNodeTxCounter(void *hDeviceContext,
                      }
                     }
                 }
-            };
+            }
         }
-    };
+    }
 
     return;
 
index f4fb0c6e4eacc83a6365475197ef175916ff300b..cb817ced5184a24abb6491a3a7f206bb914c9aa2 100644 (file)
@@ -730,7 +730,7 @@ RXbBulkInProcessData (
                 pMgmt->bInTIMWake = FALSE;
             }
         }
-    };
+    }
 
     // Now it only supports 802.11g Infrastructure Mode, and support rate must up to 54 Mbps
     if (pDevice->bDiversityEnable && (FrameSize>50) &&
@@ -913,7 +913,7 @@ RXbBulkInProcessData (
                      memset(pDevice->skb->cb, 0, sizeof(pDevice->skb->cb));
                      netif_rx(pDevice->skb);
                      pDevice->skb = dev_alloc_skb((int)pDevice->rx_buf_sz);
-                 };
+                 }
 
                 return FALSE;
 
@@ -1045,7 +1045,7 @@ static BOOL s_bAPModeRxCtl (
                                          );
                     DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "dpc: send vMgrDeAuthenBeginSta 1\n");
                     return TRUE;
-                };
+                }
                 if (pMgmt->sNodeDBTable[iSANodeIndex].eNodeState < NODE_ASSOC) {
                     // send deassoc notification
                     // reason = (7) class 3 received from nonassoc sta
@@ -1057,7 +1057,7 @@ static BOOL s_bAPModeRxCtl (
                                          );
                     DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "dpc: send vMgrDisassocBeginSta 2\n");
                     return TRUE;
-                };
+                }
 
                 if (pMgmt->sNodeDBTable[iSANodeIndex].bPSEnable) {
                     // delcare received ps-poll event
@@ -1488,7 +1488,7 @@ static BOOL s_bAPModeRxData (
                     bRelayOnly = TRUE;
                 }
             }
-        };
+        }
     }
 
     if (bRelayOnly || bRelayAndForward) {
index 2fe071ca42fa341173d49b2547d7d256ea0ad85c..cfe9c95d78074a076d80c1560751a1575fd65512 100644 (file)
@@ -90,7 +90,7 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq) {
         if (copy_from_user(&sScanCmd, pReq->data, sizeof(SCmdScan))) {
                        result = -EFAULT;
                        break;
-               };
+               }
 
         pItemSSID = (PWLAN_IE_SSID)sScanCmd.ssid;
         if (pItemSSID->len != 0) {
@@ -124,7 +124,7 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq) {
         if (copy_from_user(&sZoneTypeCmd, pReq->data, sizeof(SCmdZoneTypeSet))) {
                        result = -EFAULT;
                        break;
-               };
+               }
 
           if(sZoneTypeCmd.bWrite==TRUE) {
          //////write zonetype
@@ -163,7 +163,7 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq) {
           if (copy_to_user(pReq->data, &sZoneTypeCmd, sizeof(SCmdZoneTypeSet))) {
                        result = -EFAULT;
                        break;
-               };
+               }
        }
 
             break;
@@ -173,7 +173,7 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq) {
         if (copy_from_user(&sJoinCmd, pReq->data, sizeof(SCmdBSSJoin))) {
                        result = -EFAULT;
                        break;
-               };
+               }
 
         pItemSSID = (PWLAN_IE_SSID)sJoinCmd.ssid;
         memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
@@ -223,7 +223,7 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq) {
         if (copy_from_user(&sWEPCmd, pReq->data, sizeof(SCmdSetWEP))) {
                        result = -EFAULT;
                        break;
-               };
+               }
            if (sWEPCmd.bEnableWep != TRUE) {
                int uu;
 
@@ -295,7 +295,7 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq) {
         if (copy_to_user(pReq->data, &sLinkStatus, sizeof(SCmdLinkStatus))) {
                        result = -EFAULT;
                        break;
-               };
+               }
 
         break;
 
@@ -307,12 +307,12 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq) {
             if (!pBSS->bActive)
                 continue;
             cbListCount++;
-        };
+        }
         sList.uItem = cbListCount;
         if (copy_to_user(pReq->data, &sList, sizeof(SBSSIDList))) {
                        result = -EFAULT;
                        break;
-               };
+               }
         pReq->wResult = 0;
         break;
 
@@ -320,7 +320,7 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq) {
         if (copy_from_user(&sList, pReq->data, sizeof(SBSSIDList))) {
                        result = -EFAULT;
                        break;
-               };
+               }
         pList = (PSBSSIDList)kmalloc(sizeof(SBSSIDList) + (sList.uItem * sizeof(SBSSIDItem)), (int)GFP_ATOMIC);
         if (pList == NULL) {
             result = -ENOMEM;
@@ -362,7 +362,7 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq) {
         if (copy_to_user(pReq->data, pList, sizeof(SBSSIDList) + (sList.uItem * sizeof(SBSSIDItem)))) {
                        result = -EFAULT;
                        break;
-               };
+               }
         kfree(pList);
         pReq->wResult = 0;
         break;
@@ -371,14 +371,14 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq) {
         if (copy_to_user(pReq->data, &(pDevice->s802_11Counter), sizeof(SDot11MIBCount))) {
                        result = -EFAULT;
                        break;
-               };
+               }
         break;
 
     case WLAN_CMD_GET_STAT:
         if (copy_to_user(pReq->data, &(pDevice->scStatistic), sizeof(SStatCounter))) {
                        result = -EFAULT;
                        break;
-               };
+               }
         break;
     case WLAN_CMD_STOP_MAC:
 
@@ -415,7 +415,7 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq) {
         if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) {
                        result = -EFAULT;
                        break;
-               };
+               }
                if (sValue.dwValue == 1) {
             if (vt6656_hostap_set_hostapd(pDevice, 1, 1) == 0){
                 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable HOSTAP\n");
@@ -443,7 +443,7 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq) {
         if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) {
                        result = -EFAULT;
                        break;
-               };
+               }
 
                if (sValue.dwValue == 1) {
             pDevice->bEnable8021x = TRUE;
@@ -463,7 +463,7 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq) {
         if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) {
                        result = -EFAULT;
                        break;
-               };
+               }
 
                if (sValue.dwValue == 1) {
             pDevice->bEnableHostWEP = TRUE;
@@ -482,7 +482,7 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq) {
         if (copy_from_user(&sValue, pReq->data, sizeof(SCmdValue))) {
                        result = -EFAULT;
                        break;
-               };
+               }
                if (sValue.dwValue == 1) {
                      DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "up wpadev\n");
                   memcpy(pDevice->wpadev->dev_addr,
@@ -507,7 +507,7 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq) {
         if (copy_from_user(&sStartAPCmd, pReq->data, sizeof(SCmdStartAP))) {
                        result = -EFAULT;
                        break;
-               };
+               }
 
            if (sStartAPCmd.wBSSType == AP) {
                pMgmt->eConfigMode = WMAC_CONFIG_AP;
@@ -594,13 +594,13 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq) {
             if (!pNode->bActive)
                 continue;
             cbListCount++;
-        };
+        }
 
         sNodeList.uItem = cbListCount;
         if (copy_to_user(pReq->data, &sNodeList, sizeof(SNodeList))) {
                        result = -EFAULT;
                        break;
-               };
+               }
         pReq->wResult = 0;
         break;
 
@@ -609,7 +609,7 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq) {
         if (copy_from_user(&sNodeList, pReq->data, sizeof(SNodeList))) {
                        result = -EFAULT;
                        break;
-               };
+               }
         pNodeList = (PSNodeList)kmalloc(sizeof(SNodeList) + (sNodeList.uItem * sizeof(SNodeItem)), (int)GFP_ATOMIC);
         if (pNodeList == NULL) {
             result = -ENOMEM;
@@ -645,11 +645,11 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq) {
                    if (jj >= pNodeList->uItem)
                        break;
                }
-               };
+               }
         if (copy_to_user(pReq->data, pNodeList, sizeof(SNodeList) + (sNodeList.uItem * sizeof(SNodeItem)))) {
                        result = -EFAULT;
                        break;
-               };
+               }
         kfree(pNodeList);
         pReq->wResult = 0;
         break;
index af14ab01ed7bcdeeacd2f34df02be0885a194fd2..e18efd43e3e0235ba8d6111b8c7bd42a975ceb71 100644 (file)
@@ -709,7 +709,7 @@ static BOOL device_release_WPADEV(PSDevice pDevice)
                if(ii>20)
                  break;
               }
-           };
+           }
     return TRUE;
 }
 
@@ -955,7 +955,6 @@ static BOOL device_alloc_bufs(PSDevice pDevice) {
        pDevice->pInterruptURB = usb_alloc_urb(0, GFP_ATOMIC);
        if (pDevice->pInterruptURB == NULL) {
            DBG_PRT(MSG_LEVEL_ERR,KERN_ERR"Failed to alloc int urb\n");
-           usb_kill_urb(pDevice->pControlURB);
            usb_free_urb(pDevice->pControlURB);
            goto free_rx_tx;
        }
@@ -963,8 +962,6 @@ static BOOL device_alloc_bufs(PSDevice pDevice) {
     pDevice->intBuf.pDataBuf = kmalloc(MAX_INTERRUPT_SIZE, GFP_KERNEL);
        if (pDevice->intBuf.pDataBuf == NULL) {
            DBG_PRT(MSG_LEVEL_ERR,KERN_ERR"Failed to alloc int buf\n");
-           usb_kill_urb(pDevice->pControlURB);
-           usb_kill_urb(pDevice->pInterruptURB);
            usb_free_urb(pDevice->pControlURB);
            usb_free_urb(pDevice->pInterruptURB);
            goto free_rx_tx;
@@ -995,7 +992,7 @@ static BOOL device_init_defrag_cb(PSDevice pDevice) {
             DBG_PRT(MSG_LEVEL_ERR,KERN_ERR "%s: can not alloc frag bufs\n",
                 pDevice->dev->name);
             goto free_frag;
-        };
+        }
     }
     pDevice->cbDFCB = CB_MAX_RX_FRAG;
     pDevice->cbFreeDFCB = pDevice->cbDFCB;
index 5185d61564d77b90953f3f23d06549bd427adefa..9b64b102f55cccea62a74c258829446b235ace2b 100644 (file)
@@ -2441,13 +2441,13 @@ vDMA0_tx_80211(PSDevice  pDevice, struct sk_buff *skb) {
         if (pDevice->bEnableHostWEP) {
             uNodeIndex = 0;
             bNodeExist = TRUE;
-        };
+        }
     }
     else {
         if (pDevice->bEnableHostWEP) {
             if (BSSbIsSTAInNodeDB(pDevice, (PBYTE)(p80211Header->sA3.abyAddr1), &uNodeIndex))
                 bNodeExist = TRUE;
-        };
+        }
         bNeedACK = TRUE;
         pTxBufHead->wFIFOCtl |= FIFOCTL_NEEDACK;
     };
index 019fb52de3662c105959771814290170819fdf6f..78ea121b7e2ef4d9aa495da61367fa83ee8e41c7 100644 (file)
@@ -642,7 +642,7 @@ void vRunCommand(void *hDeviceContext)
                     if (Status != CMD_STATUS_SUCCESS){
                        DBG_PRT(MSG_LEVEL_DEBUG,
                                KERN_INFO "WLAN_CMD_IBSS_CREATE fail!\n");
-                    };
+                    }
                     BSSvAddMulticastNode(pDevice);
                 }
                 s_bClearBSSID_SCAN(pDevice);
@@ -658,7 +658,7 @@ void vRunCommand(void *hDeviceContext)
                     if (Status != CMD_STATUS_SUCCESS){
                        DBG_PRT(MSG_LEVEL_DEBUG,
                                KERN_INFO "WLAN_CMD_IBSS_CREATE fail!\n");
-                    };
+                    }
                     BSSvAddMulticastNode(pDevice);
                     s_bClearBSSID_SCAN(pDevice);
 /*
@@ -793,7 +793,7 @@ void vRunCommand(void *hDeviceContext)
                if (Status != CMD_STATUS_SUCCESS) {
                        DBG_PRT(MSG_LEVEL_DEBUG,
                                KERN_INFO "vMgrCreateOwnIBSS fail!\n");
-                };
+                }
                 // alway turn off unicast bit
                 MACvRegBitsOff(pDevice, MAC_REG_RCR, RCR_UNICAST);
                 pDevice->byRxMode &= ~RCR_UNICAST;
@@ -827,7 +827,7 @@ void vRunCommand(void *hDeviceContext)
 
                     pMgmt->sNodeDBTable[0].wEnQueueCnt--;
                 }
-            };
+            }
 
             // PS nodes tx
             for (ii = 1; ii < (MAX_NODE_NUM + 1); ii++) {
index 2ec200d8b736f0e775e1f640f8014ac766bee0d3..d67748f90b14b7b41b42dea61ac6ac1439b6adba 100644 (file)
@@ -593,7 +593,7 @@ void vMgrDisassocBeginSta(void *hDeviceContext,
     if (*pStatus == CMD_STATUS_PENDING) {
         pMgmt->eCurrState = WMAC_STATE_IDLE;
         *pStatus = CMD_STATUS_SUCCESS;
-    };
+    }
 
     return;
 }
@@ -942,7 +942,7 @@ s_vMgrRxAssocResponse(
            || (sFrame.pSuppRates == NULL)) {
                DBG_PORT80(0xCC);
                return;
-        };
+        }
 
         pMgmt->sAssocInfo.AssocInfo.ResponseFixedIEs.Capabilities = *(sFrame.pwCapInfo);
         pMgmt->sAssocInfo.AssocInfo.ResponseFixedIEs.StatusCode = *(sFrame.pwStatus);
@@ -962,7 +962,7 @@ s_vMgrRxAssocResponse(
             if ( (pMgmt->wCurrAID >> 14) != (BIT0 | BIT1) )
             {
                 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "AID from AP, has two msb clear.\n");
-            };
+            }
             DBG_PRT(MSG_LEVEL_INFO, KERN_INFO "Association Successful, AID=%d.\n", pMgmt->wCurrAID & ~(BIT14|BIT15));
             pMgmt->eCurrState = WMAC_STATE_ASSOC;
            BSSvUpdateAPNode((void *) pDevice,
@@ -1621,7 +1621,7 @@ s_vMgrRxDisassociation(
              memset(pDevice->skb->cb, 0, sizeof(pDevice->skb->cb));
              netif_rx(pDevice->skb);
              pDevice->skb = dev_alloc_skb((int)pDevice->rx_buf_sz);
-         };
+         }
 
         //TODO: do something let upper layer know or
         //try to send associate packet again because of inactivity timeout
@@ -1636,7 +1636,7 @@ s_vMgrRxDisassociation(
                  pDevice->byReAssocCount ++;
                  return;       //mike add: you'll retry for many times, so it cann't be regarded as disconnected!
               }
-        };
+        }
 
    #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
   // if(pDevice->bWPASuppWextEnabled == TRUE)
@@ -1710,7 +1710,7 @@ s_vMgrRxDeauthentication(
                     pDevice->bLinkPass = FALSE;
                     ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_SLOW);
                 }
-            };
+            }
 
             if ((pDevice->bWPADEVUp) && (pDevice->skb != NULL)) {
                  wpahdr = (viawget_wpa_header *)pDevice->skb->data;
@@ -1725,7 +1725,7 @@ s_vMgrRxDeauthentication(
                  memset(pDevice->skb->cb, 0, sizeof(pDevice->skb->cb));
                  netif_rx(pDevice->skb);
                  pDevice->skb = dev_alloc_skb((int)pDevice->rx_buf_sz);
-           };
+           }
 
    #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
   // if(pDevice->bWPASuppWextEnabled == TRUE)
@@ -1845,7 +1845,7 @@ s_vMgrRxBeacon(
 
        DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Rx beacon frame error\n");
        return;
-    };
+    }
 
     if( byCurrChannel > CB_MAX_CHANNEL_24G )
     {
@@ -1974,7 +1974,7 @@ if(ChannelExceedZoneType(pDevice,byCurrChannel)==TRUE)
                    sFrame.pSSID->len
                    ) == 0) {
             bIsSSIDEqual = TRUE;
-        };
+        }
     }
 
     if ((WLAN_GET_CAP_INFO_ESS(*sFrame.pwCapInfo)== TRUE) &&
@@ -2074,8 +2074,8 @@ if(ChannelExceedZoneType(pDevice,byCurrChannel)==TRUE)
     if (WLAN_GET_CAP_INFO_ESS(*sFrame.pwCapInfo)) {
         if (sFrame.pCFParms->wCFPDurRemaining > 0) {
             // TODO: deal with CFP period to set NAV
-        };
-    };
+        }
+    }
 
     HIDWORD(qwTimestamp) = cpu_to_le32(HIDWORD(*sFrame.pqwTimestamp));
     LODWORD(qwTimestamp) = cpu_to_le32(LODWORD(*sFrame.pqwTimestamp));
@@ -2096,7 +2096,7 @@ if(ChannelExceedZoneType(pDevice,byCurrChannel)==TRUE)
     }
     else if (HIDWORD(qwTimestamp) < HIDWORD(qwLocalTSF)) {
         bTSFOffsetPostive = FALSE;
-    };
+    }
 
     if (bTSFOffsetPostive) {
         qwTSFOffset = CARDqGetTSFOffset(pRxPacket->byRxRate, (qwTimestamp), (qwLocalTSF));
@@ -2154,7 +2154,7 @@ if(ChannelExceedZoneType(pDevice,byCurrChannel)==TRUE)
                 if (pMgmt->bInTIM) {
                     PSvSendPSPOLL((PSDevice)pDevice);
 //                    DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "BCN:PS-POLL sent..\n");
-                };
+                }
 
             }
             else {
@@ -2167,7 +2167,7 @@ if(ChannelExceedZoneType(pDevice,byCurrChannel)==TRUE)
                 }
                 if(PSbConsiderPowerDown(pDevice, FALSE, FALSE)) {
                    DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "BCN: Power down now...\n");
-                };
+                }
             }
 
         }
@@ -2247,7 +2247,7 @@ if(ChannelExceedZoneType(pDevice,byCurrChannel)==TRUE)
                 pMgmt->sNodeDBTable[0].bActive = TRUE;
                 pMgmt->sNodeDBTable[0].uInActiveCount = 0;
 
-            };
+            }
         }
         else if (bIsSSIDEqual) {
 
@@ -2292,9 +2292,9 @@ if(ChannelExceedZoneType(pDevice,byCurrChannel)==TRUE)
                      // Prepare beacon frame
                        bMgrPrepareBeaconToSend((void *) pDevice, pMgmt);
               //  }
-            };
+            }
         }
-    };
+    }
     // endian issue ???
     // Update TSF
     if (bUpdateTSF) {
@@ -2556,7 +2556,7 @@ void vMgrCreateOwnIBSS(void *hDeviceContext,
             pMgmt->byCSSPK = KEY_CTL_WEP;
             pMgmt->byCSSGK = KEY_CTL_WEP;
         }
-    };
+    }
 
     pMgmt->byERPContext = 0;
 
@@ -2614,7 +2614,7 @@ void vMgrJoinBSSBegin(void *hDeviceContext, PCMD_STATUS pStatus)
        *pStatus = CMD_STATUS_RESOURCES;
         DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "BSS finding:BSS list is empty.\n");
        return;
-    };
+    }
 
     // memset(pMgmt->abyDesireBSSID, 0,  WLAN_BSSID_LEN);
     // Search known BSS list for prefer BSSID or SSID
@@ -2630,7 +2630,7 @@ void vMgrJoinBSSBegin(void *hDeviceContext, PCMD_STATUS pStatus)
        pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID;
        DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Scanning [%s] not found, disconnected !\n", pItemSSID->abySSID);
        return;
-    };
+    }
 
     DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "AP(BSS) finding:Found a AP(BSS)..\n");
 
@@ -3061,7 +3061,7 @@ s_vMgrSynchBSS (
         MACvRegBitsOn(pDevice, MAC_REG_RCR, RCR_BSSID);
         pDevice->byRxMode |= RCR_BSSID;
         pMgmt->bCurrBSSIDFilterOn = TRUE;
-    };
+    }
 
     if (pDevice->byBBType == BB_TYPE_11A) {
         memcpy(pMgmt->abyCurrSuppRates, &abyCurrSuppRatesA[0], sizeof(abyCurrSuppRatesA));
@@ -3167,7 +3167,7 @@ s_vMgrFormatTIM(
             }
             wEndIndex = (WORD)ii;
         }
-    };
+    }
 
 
     // Round start index down to nearest even number
@@ -4209,7 +4209,7 @@ s_vMgrRxProbeResponse(
                pRxPacket->p80211Header);
        DBG_PORT80(0xCC);
        return;
-    };
+    }
 
     if(sFrame.pSSID->len == 0)
        DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Rx Probe resp: SSID len = 0 \n");
@@ -4491,7 +4491,7 @@ void vMgrRxManagePacket(void *hDeviceContext,
             //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "rx beacon\n");
             if (pMgmt->eScanState != WMAC_NO_SCANNING) {
                 bInScan = TRUE;
-            };
+            }
             s_vMgrRxBeacon(pDevice, pMgmt, pRxPacket, bInScan);
             break;
 
index 8752736181bbf73ab58f3ecf39c195e1ce125973..9216df01829e90e53ee8edd18b779800b6e0dbd5 100644 (file)
@@ -660,7 +660,7 @@ static int wpa_get_scan(PSDevice pDevice,
 
          }
 
-    };
+    }
 
   kfree(ptempBSS);
 
@@ -673,7 +673,7 @@ static int wpa_get_scan(PSDevice pDevice,
         if (!pBSS->bActive)
             continue;
         count++;
-    };
+    }
 
     pBuf = kcalloc(count, sizeof(struct viawget_scan_result), (int)GFP_ATOMIC);
 
@@ -729,7 +729,7 @@ static int wpa_get_scan(PSDevice pDevice,
 
     if (copy_to_user(param->u.scan_results.buf, pBuf, sizeof(struct viawget_scan_result) * count)) {
                ret = -EFAULT;
-       };
+       }
        param->u.scan_results.scan_count = count;
     DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " param->u.scan_results.scan_count = %d\n", count)
 
@@ -831,7 +831,7 @@ static int wpa_set_associate(PSDevice pDevice,
                break;
        default:
                pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
-       };
+       }
 
            pMgmt->Roam_dbm = param->u.wpa_associate.roam_dbm;
          // if ((pMgmt->Roam_dbm > 40)&&(pMgmt->Roam_dbm<80))
@@ -886,7 +886,7 @@ static int wpa_set_associate(PSDevice pDevice,
     bScheduleCommand((void *) pDevice,
                     WLAN_CMD_BSSID_SCAN,
                     pMgmt->abyDesireSSID);
-  };
+  }
 }
 /****************************************************************/
 
index 3bcedce13f4ae25c369a9ac6014587f869cb763d..dd4cd412aeb57c64da97be464fb82f66879c3474 100644 (file)
@@ -768,7 +768,7 @@ uint32_t cy_as_hal_processor_hw_init(void)
                cy_as_hal_print_message(KERN_INFO "%s virt_addr=%x\n",
                                        gpio_vma_tab[i].name,
                                        (u32)gpio_vma_tab[i].virt_addr);
-       };
+       }
 
        /*
         * force OMAP_GPIO_126  to rleased state,
index 289729daba80a5dffec1e473e189bc9b787a88ae..87452bde7c93431a20014e5d98b061357baf4c6b 100644 (file)
@@ -515,7 +515,7 @@ static void cyasblkdev_issuecallback(
        while (blk_end_request(gl_bd->queue.req,
        status, blk_rq_sectors(gl_bd->queue.req)*512)) {
                retry_cnt++;
-       };
+       }
 
        #ifndef WESTBRIDGE_NDEBUG
        cy_as_hal_print_message(
index c03e5010ca34d1e1380333543290c76faf8ccf37..5250217156a76e307b4ebad1b2438e26e800784c 100644 (file)
@@ -40,14 +40,9 @@ static u8 MTO_Data_Rate_Tbl[MTO_MAX_DATA_RATE_LEVELS] = {
        2, 4, 11, 22, 12, 18, 24, 36, 48, 72, 96, 108
 };
 
-static int TotalTxPkt;
-static int TotalTxPktRetry;
 /* this record the retry rate at different data rate */
 static int retryrate_rec[MTO_MAX_DATA_RATE_LEVELS];
 
-static int PeriodTotalTxPkt;
-static int PeriodTotalTxPktRetry;
-
 static u8 boSparseTxTraffic;
 
 void MTO_Init(struct wbsoft_priv *adapter);
@@ -174,9 +169,4 @@ void MTO_SetTxCount(struct wbsoft_priv *adapter, u8 tx_rate, u8 index)
                MTO_HAL()->dto_tx_retry_count += index;
                MTO_HAL()->dto_tx_frag_count += (index + 1);
        }
-       TotalTxPkt++;
-       TotalTxPktRetry += (index + 1);
-
-       PeriodTotalTxPkt++;
-       PeriodTotalTxPktRetry += (index + 1);
 }
index 09844db64fe9e8d637ab0fe32ebc3904c0e6b224..79e53e46ecca2887bcb2d6b39b3041046fbd961b 100644 (file)
 #define DEG2RAD(X)      0.017453 * (X)
 
 static const s32 Angles[] = {
-    FIXED(DEG2RAD(45.0)),     FIXED(DEG2RAD(26.565)),   FIXED(DEG2RAD(14.0362)),
-    FIXED(DEG2RAD(7.12502)),  FIXED(DEG2RAD(3.57633)),  FIXED(DEG2RAD(1.78991)),
-    FIXED(DEG2RAD(0.895174)), FIXED(DEG2RAD(0.447614)), FIXED(DEG2RAD(0.223811)),
-    FIXED(DEG2RAD(0.111906)), FIXED(DEG2RAD(0.055953)), FIXED(DEG2RAD(0.027977))
+       FIXED(DEG2RAD(45.0)),     FIXED(DEG2RAD(26.565)),   FIXED(DEG2RAD(14.0362)),
+       FIXED(DEG2RAD(7.12502)),  FIXED(DEG2RAD(3.57633)),  FIXED(DEG2RAD(1.78991)),
+       FIXED(DEG2RAD(0.895174)), FIXED(DEG2RAD(0.447614)), FIXED(DEG2RAD(0.223811)),
+       FIXED(DEG2RAD(0.111906)), FIXED(DEG2RAD(0.055953)), FIXED(DEG2RAD(0.027977))
 };
 
 /****************** LOCAL FUNCTION DECLARATION SECTION **********************/
index 44fc3fe79b796e16c76530039fbd4990364868d5..5df39d46cda48e1f26450229dc190111d4e52a9e 100644 (file)
@@ -291,7 +291,6 @@ void Wb35Tx_EP2VM_start(struct wbsoft_priv *adapter)
        if (atomic_inc_return(&pWb35Tx->TxResultCount) == 1) {
                pWb35Tx->EP2vm_state = VM_RUNNING;
                Wb35Tx_EP2VM(adapter);
-       }
-       else
+       } else
                atomic_dec(&pWb35Tx->TxResultCount);
 }
index 46b5958ddf37912105118bcfe63c82b8f809fd0b..f6cd22d79630648a29f525b69d36499a581a54f5 100644 (file)
@@ -9,7 +9,7 @@
 #include "vb_struct.h"
 #include "vb_def.h"
 
-#define XGIFAIL(x) do { printk(x "\n"); return -EINVAL; } while(0)
+#define XGIFAIL(x) do { printk(x "\n"); return -EINVAL; } while (0)
 
 #define VER_MAJOR                 0
 #define VER_MINOR                 8
 #define XGIINITSTATIC static
 
 static DEFINE_PCI_DEVICE_TABLE(xgifb_pci_table) = {
-       { PCI_VENDOR_ID_XG, PCI_DEVICE_ID_XG_20, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-       { PCI_VENDOR_ID_XG, PCI_DEVICE_ID_XG_27, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1},
-       { PCI_VENDOR_ID_XG, PCI_DEVICE_ID_XG_40, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 2},
-       { PCI_VENDOR_ID_XG, PCI_DEVICE_ID_XG_42, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 3},
-       { 0 }
+       {PCI_VENDOR_ID_XG, PCI_DEVICE_ID_XG_20, PCI_ANY_ID, PCI_ANY_ID,
+        0, 0, 0},
+       {PCI_VENDOR_ID_XG, PCI_DEVICE_ID_XG_27, PCI_ANY_ID, PCI_ANY_ID,
+        0, 0, 1},
+       {PCI_VENDOR_ID_XG, PCI_DEVICE_ID_XG_40, PCI_ANY_ID, PCI_ANY_ID,
+        0, 0, 2},
+       {PCI_VENDOR_ID_XG, PCI_DEVICE_ID_XG_42, PCI_ANY_ID, PCI_ANY_ID,
+        0, 0, 3},
+       {0}
 };
 
 MODULE_DEVICE_TABLE(pci, xgifb_pci_table);
@@ -148,10 +152,10 @@ MODULE_DEVICE_TABLE(pci, xgifb_pci_table);
 #define XGI_DATA_BUS_64        0x00
 #define XGI_DATA_BUS_128       0x01
 #define XGI_DUAL_CHANNEL_MASK  0x0C
-#define XGI_SINGLE_CHANNEL_1_RANK      0x0
-#define XGI_SINGLE_CHANNEL_2_RANK      0x1
-#define XGI_ASYM_DDR                   0x02
-#define XGI_DUAL_CHANNEL_1_RANK        0x3
+#define XGI_SINGLE_CHANNEL_1_RANK 0x0
+#define XGI_SINGLE_CHANNEL_2_RANK 0x1
+#define XGI_ASYM_DDR             0x02
+#define XGI_DUAL_CHANNEL_1_RANK          0x3
 
 #define XGI550_DRAM_SIZE_MASK     0x3F  /* 550/650/740 SR14 */
 #define XGI550_DRAM_SIZE_4MB      0x00
@@ -190,11 +194,11 @@ MODULE_DEVICE_TABLE(pci, xgifb_pci_table);
 #define XGI_VB_CRT2               0x10
 #define XGI_CRT1                  0x20
 #define XGI_VB_HIVISION           0x40
-#define XGI_VB_YPBPR                0x80
-#define XGI_VB_TV                 (XGI_VB_COMPOSITE | XGI_VB_SVIDEO | \
-                                   XGI_VB_SCART | XGI_VB_HIVISION|XGI_VB_YPBPR)
+#define XGI_VB_YPBPR              0x80
+#define XGI_VB_TV                (XGI_VB_COMPOSITE | XGI_VB_SVIDEO | \
+                                  XGI_VB_SCART | XGI_VB_HIVISION|XGI_VB_YPBPR)
 
-#define XGI_EXTERNAL_CHIP_MASK            0x0E  /* CR37 */
+#define XGI_EXTERNAL_CHIP_MASK            0x0E  /* CR37 */
 #define XGI_EXTERNAL_CHIP_XGI301           0x01  /* in CR37 << 1 ! */
 #define XGI_EXTERNAL_CHIP_LVDS             0x02  /* in CR37 << 1 ! */
 #define XGI_EXTERNAL_CHIP_TRUMPION         0x03  /* in CR37 << 1 ! */
@@ -216,46 +220,10 @@ MODULE_DEVICE_TABLE(pci, xgifb_pci_table);
 #define SR_BUFFER_SIZE            5
 #define CR_BUFFER_SIZE            5
 
-/* Useful macros */
-#define inXGIREG(base)          inb(base)
-#define outXGIREG(base,val)     outb(val,base)
-#define orXGIREG(base,val)      do { \
-                                  unsigned char __Temp = inb(base); \
-                                  outXGIREG(base, __Temp | (val)); \
-                                } while (0)
-#define andXGIREG(base,val)     do { \
-                                  unsigned char __Temp = inb(base); \
-                                  outXGIREG(base, __Temp & (val)); \
-                                } while (0)
-#define inXGIIDXREG(base,idx,var)   do { \
-                                      outb(idx,base); var=inb((base)+1); \
-                                    } while (0)
-#define outXGIIDXREG(base,idx,val)  do { \
-                                      outb(idx,base); outb((val),(base)+1); \
-                                    } while (0)
-#define orXGIIDXREG(base,idx,val)   do { \
-                                      unsigned char __Temp; \
-                                      outb(idx,base);   \
-                                      __Temp = inb((base)+1)|(val); \
-                                      outXGIIDXREG(base,idx,__Temp); \
-                                    } while (0)
-#define andXGIIDXREG(base,idx,and)  do { \
-                                      unsigned char __Temp; \
-                                      outb(idx,base);   \
-                                      __Temp = inb((base)+1)&(and); \
-                                      outXGIIDXREG(base,idx,__Temp); \
-                                    } while (0)
-#define setXGIIDXREG(base,idx,and,or)   do { \
-                                          unsigned char __Temp; \
-                                          outb(idx,base);   \
-                                          __Temp = (inb((base)+1)&(and))|(or); \
-                                          outXGIIDXREG(base,idx,__Temp); \
-                                        } while (0)
-
 /* ------------------- Global Variables ----------------------------- */
 
 /* Fbcon variables */
-static struct fb_infofb_info;
+static struct fb_info *fb_info;
 
 
 static int    video_type = FB_TYPE_PACKED_PIXELS;
@@ -304,7 +272,7 @@ static int XGIfb_off = 0;
 static int XGIfb_crt1off = 0;
 static int XGIfb_forcecrt1 = -1;
 static int XGIfb_userom = 0;
-//static int XGIfb_useoem = -1;
+/*static int XGIfb_useoem = -1; */
 
 /* global flags */
 static int XGIfb_registered;
@@ -316,8 +284,10 @@ static int XGIfb_ypan = -1;
 
 static int XGIfb_CRT2_write_enable = 0;
 
-static int XGIfb_crt2type = -1; /* TW: CRT2 type (for overriding autodetection) */
-static int XGIfb_tvplug = -1; /* PR: Tv plug type (for overriding autodetection) */
+/* TW: CRT2 type (for overriding autodetection) */
+static int XGIfb_crt2type = -1;
+/* PR: Tv plug type (for overriding autodetection) */
+static int XGIfb_tvplug = -1;
 
 static unsigned char XGIfb_detectedpdc = 0;
 
@@ -354,82 +324,155 @@ static struct _XGIbios_mode {
        u8  chipset;
 } XGIbios_mode[] = {
 #define MODE_INDEX_NONE           0  /* TW: index for mode=none */
-       {"none",         0xFF, 0x0000, 0x0000,    0,    0,  0, 0,   0,  0, MD_XGI300|MD_XGI315},  /* TW: for mode "none" */
-       {"320x240x16",   0x56, 0x0000, 0x0000,  320,  240, 16, 1,  40, 15,           MD_XGI315},
-       {"320x480x8",    0x5A, 0x0000, 0x0000,  320,  480,  8, 1,  40, 30,           MD_XGI315},  /* TW: FSTN */
-       {"320x480x16",   0x5B, 0x0000, 0x0000,  320,  480, 16, 1,  40, 30,           MD_XGI315},  /* TW: FSTN */
-       {"640x480x8",    0x2E, 0x0101, 0x0101,  640,  480,  8, 1,  80, 30, MD_XGI300|MD_XGI315},
-       {"640x480x16",   0x44, 0x0111, 0x0111,  640,  480, 16, 1,  80, 30, MD_XGI300|MD_XGI315},
-       {"640x480x24",   0x62, 0x013a, 0x0112,  640,  480, 32, 1,  80, 30, MD_XGI300|MD_XGI315},  /* TW: That's for people who mix up color- and fb depth */
-       {"640x480x32",   0x62, 0x013a, 0x0112,  640,  480, 32, 1,  80, 30, MD_XGI300|MD_XGI315},
-       {"720x480x8",    0x31, 0x0000, 0x0000,  720,  480,  8, 1,  90, 30, MD_XGI300|MD_XGI315},
-       {"720x480x16",   0x33, 0x0000, 0x0000,  720,  480, 16, 1,  90, 30, MD_XGI300|MD_XGI315},
-       {"720x480x24",   0x35, 0x0000, 0x0000,  720,  480, 32, 1,  90, 30, MD_XGI300|MD_XGI315},
-       {"720x480x32",   0x35, 0x0000, 0x0000,  720,  480, 32, 1,  90, 30, MD_XGI300|MD_XGI315},
-       {"720x576x8",    0x32, 0x0000, 0x0000,  720,  576,  8, 1,  90, 36, MD_XGI300|MD_XGI315},
-       {"720x576x16",   0x34, 0x0000, 0x0000,  720,  576, 16, 1,  90, 36, MD_XGI300|MD_XGI315},
-       {"720x576x24",   0x36, 0x0000, 0x0000,  720,  576, 32, 1,  90, 36, MD_XGI300|MD_XGI315},
-       {"720x576x32",   0x36, 0x0000, 0x0000,  720,  576, 32, 1,  90, 36, MD_XGI300|MD_XGI315},
-       {"800x480x8",    0x70, 0x0000, 0x0000,  800,  480,  8, 1, 100, 30, MD_XGI300|MD_XGI315},
-       {"800x480x16",   0x7a, 0x0000, 0x0000,  800,  480, 16, 1, 100, 30, MD_XGI300|MD_XGI315},
-       {"800x480x24",   0x76, 0x0000, 0x0000,  800,  480, 32, 1, 100, 30, MD_XGI300|MD_XGI315},
-       {"800x480x32",   0x76, 0x0000, 0x0000,  800,  480, 32, 1, 100, 30, MD_XGI300|MD_XGI315},
+       {"none",         0xFF, 0x0000, 0x0000,    0,    0,  0, 0,   0,  0,
+        MD_XGI300|MD_XGI315},  /* TW: for mode "none" */
+       {"320x240x16",   0x56, 0x0000, 0x0000,  320,  240, 16, 1,  40, 15,
+        MD_XGI315},
+       {"320x480x8",    0x5A, 0x0000, 0x0000,  320,  480,  8, 1,  40, 30,
+        MD_XGI315},  /* TW: FSTN */
+       {"320x480x16",   0x5B, 0x0000, 0x0000,  320,  480, 16, 1,  40, 30,
+        MD_XGI315},  /* TW: FSTN */
+       {"640x480x8",    0x2E, 0x0101, 0x0101,  640,  480,  8, 1,  80, 30,
+        MD_XGI300|MD_XGI315},
+       {"640x480x16",   0x44, 0x0111, 0x0111,  640,  480, 16, 1,  80, 30,
+        MD_XGI300|MD_XGI315},
+       {"640x480x24",   0x62, 0x013a, 0x0112,  640,  480, 32, 1,  80, 30,
+        MD_XGI300|MD_XGI315},  /* TW: That's for people who mix up color-
+                                       and fb depth */
+       {"640x480x32",   0x62, 0x013a, 0x0112,  640,  480, 32, 1,  80, 30,
+        MD_XGI300|MD_XGI315},
+       {"720x480x8",    0x31, 0x0000, 0x0000,  720,  480,  8, 1,  90, 30,
+        MD_XGI300|MD_XGI315},
+       {"720x480x16",   0x33, 0x0000, 0x0000,  720,  480, 16, 1,  90, 30,
+        MD_XGI300|MD_XGI315},
+       {"720x480x24",   0x35, 0x0000, 0x0000,  720,  480, 32, 1,  90, 30,
+        MD_XGI300|MD_XGI315},
+       {"720x480x32",   0x35, 0x0000, 0x0000,  720,  480, 32, 1,  90, 30,
+        MD_XGI300|MD_XGI315},
+       {"720x576x8",    0x32, 0x0000, 0x0000,  720,  576,  8, 1,  90, 36,
+        MD_XGI300|MD_XGI315},
+       {"720x576x16",   0x34, 0x0000, 0x0000,  720,  576, 16, 1,  90, 36,
+        MD_XGI300|MD_XGI315},
+       {"720x576x24",   0x36, 0x0000, 0x0000,  720,  576, 32, 1,  90, 36,
+        MD_XGI300|MD_XGI315},
+       {"720x576x32",   0x36, 0x0000, 0x0000,  720,  576, 32, 1,  90, 36,
+        MD_XGI300|MD_XGI315},
+       {"800x480x8",    0x70, 0x0000, 0x0000,  800,  480,  8, 1, 100, 30,
+        MD_XGI300|MD_XGI315},
+       {"800x480x16",   0x7a, 0x0000, 0x0000,  800,  480, 16, 1, 100, 30,
+        MD_XGI300|MD_XGI315},
+       {"800x480x24",   0x76, 0x0000, 0x0000,  800,  480, 32, 1, 100, 30,
+        MD_XGI300|MD_XGI315},
+       {"800x480x32",   0x76, 0x0000, 0x0000,  800,  480, 32, 1, 100, 30,
+        MD_XGI300|MD_XGI315},
 #define DEFAULT_MODE              21 /* TW: index for 800x600x8 */
 #define DEFAULT_LCDMODE           21 /* TW: index for 800x600x8 */
 #define DEFAULT_TVMODE            21 /* TW: index for 800x600x8 */
-       {"800x600x8",    0x30, 0x0103, 0x0103,  800,  600,  8, 1, 100, 37, MD_XGI300|MD_XGI315},
-       {"800x600x16",   0x47, 0x0114, 0x0114,  800,  600, 16, 1, 100, 37, MD_XGI300|MD_XGI315},
-       {"800x600x24",   0x63, 0x013b, 0x0115,  800,  600, 32, 1, 100, 37, MD_XGI300|MD_XGI315},
-       {"800x600x32",   0x63, 0x013b, 0x0115,  800,  600, 32, 1, 100, 37, MD_XGI300|MD_XGI315},
-       {"1024x576x8",   0x71, 0x0000, 0x0000, 1024,  576,  8, 1, 128, 36, MD_XGI300|MD_XGI315},
-       {"1024x576x16",  0x74, 0x0000, 0x0000, 1024,  576, 16, 1, 128, 36, MD_XGI300|MD_XGI315},
-       {"1024x576x24",  0x77, 0x0000, 0x0000, 1024,  576, 32, 1, 128, 36, MD_XGI300|MD_XGI315},
-       {"1024x576x32",  0x77, 0x0000, 0x0000, 1024,  576, 32, 1, 128, 36, MD_XGI300|MD_XGI315},
-       {"1024x600x8",   0x20, 0x0000, 0x0000, 1024,  600,  8, 1, 128, 37, MD_XGI300          },  /* TW: 300 series only */
-       {"1024x600x16",  0x21, 0x0000, 0x0000, 1024,  600, 16, 1, 128, 37, MD_XGI300          },
-       {"1024x600x24",  0x22, 0x0000, 0x0000, 1024,  600, 32, 1, 128, 37, MD_XGI300          },
-       {"1024x600x32",  0x22, 0x0000, 0x0000, 1024,  600, 32, 1, 128, 37, MD_XGI300          },
-       {"1024x768x8",   0x38, 0x0105, 0x0105, 1024,  768,  8, 1, 128, 48, MD_XGI300|MD_XGI315},
-       {"1024x768x16",  0x4A, 0x0117, 0x0117, 1024,  768, 16, 1, 128, 48, MD_XGI300|MD_XGI315},
-       {"1024x768x24",  0x64, 0x013c, 0x0118, 1024,  768, 32, 1, 128, 48, MD_XGI300|MD_XGI315},
-       {"1024x768x32",  0x64, 0x013c, 0x0118, 1024,  768, 32, 1, 128, 48, MD_XGI300|MD_XGI315},
-       {"1152x768x8",   0x23, 0x0000, 0x0000, 1152,  768,  8, 1, 144, 48, MD_XGI300          },  /* TW: 300 series only */
-       {"1152x768x16",  0x24, 0x0000, 0x0000, 1152,  768, 16, 1, 144, 48, MD_XGI300          },
-       {"1152x768x24",  0x25, 0x0000, 0x0000, 1152,  768, 32, 1, 144, 48, MD_XGI300          },
-       {"1152x768x32",  0x25, 0x0000, 0x0000, 1152,  768, 32, 1, 144, 48, MD_XGI300          },
-       {"1280x720x8",   0x79, 0x0000, 0x0000, 1280,  720,  8, 1, 160, 45, MD_XGI300|MD_XGI315},
-       {"1280x720x16",  0x75, 0x0000, 0x0000, 1280,  720, 16, 1, 160, 45, MD_XGI300|MD_XGI315},
-       {"1280x720x24",  0x78, 0x0000, 0x0000, 1280,  720, 32, 1, 160, 45, MD_XGI300|MD_XGI315},
-       {"1280x720x32",  0x78, 0x0000, 0x0000, 1280,  720, 32, 1, 160, 45, MD_XGI300|MD_XGI315},
-       {"1280x768x8",   0x23, 0x0000, 0x0000, 1280,  768,  8, 1, 160, 48,           MD_XGI315},  /* TW: 310/325 series only */
-       {"1280x768x16",  0x24, 0x0000, 0x0000, 1280,  768, 16, 1, 160, 48,           MD_XGI315},
-       {"1280x768x24",  0x25, 0x0000, 0x0000, 1280,  768, 32, 1, 160, 48,           MD_XGI315},
-       {"1280x768x32",  0x25, 0x0000, 0x0000, 1280,  768, 32, 1, 160, 48,           MD_XGI315},
+       {"800x600x8",    0x30, 0x0103, 0x0103,  800,  600,  8, 1, 100, 37,
+        MD_XGI300|MD_XGI315},
+       {"800x600x16",   0x47, 0x0114, 0x0114,  800,  600, 16, 1, 100, 37,
+        MD_XGI300|MD_XGI315},
+       {"800x600x24",   0x63, 0x013b, 0x0115,  800,  600, 32, 1, 100, 37,
+        MD_XGI300|MD_XGI315},
+       {"800x600x32",   0x63, 0x013b, 0x0115,  800,  600, 32, 1, 100, 37,
+        MD_XGI300|MD_XGI315},
+       {"1024x576x8",   0x71, 0x0000, 0x0000, 1024,  576,  8, 1, 128, 36,
+        MD_XGI300|MD_XGI315},
+       {"1024x576x16",  0x74, 0x0000, 0x0000, 1024,  576, 16, 1, 128, 36,
+        MD_XGI300|MD_XGI315},
+       {"1024x576x24",  0x77, 0x0000, 0x0000, 1024,  576, 32, 1, 128, 36,
+        MD_XGI300|MD_XGI315},
+       {"1024x576x32",  0x77, 0x0000, 0x0000, 1024,  576, 32, 1, 128, 36,
+        MD_XGI300|MD_XGI315},
+       {"1024x600x8",   0x20, 0x0000, 0x0000, 1024,  600,  8, 1, 128, 37,
+        MD_XGI300          },  /* TW: 300 series only */
+       {"1024x600x16",  0x21, 0x0000, 0x0000, 1024,  600, 16, 1, 128, 37,
+        MD_XGI300          },
+       {"1024x600x24",  0x22, 0x0000, 0x0000, 1024,  600, 32, 1, 128, 37,
+        MD_XGI300          },
+       {"1024x600x32",  0x22, 0x0000, 0x0000, 1024,  600, 32, 1, 128, 37,
+        MD_XGI300          },
+       {"1024x768x8",   0x38, 0x0105, 0x0105, 1024,  768,  8, 1, 128, 48,
+        MD_XGI300|MD_XGI315},
+       {"1024x768x16",  0x4A, 0x0117, 0x0117, 1024,  768, 16, 1, 128, 48,
+        MD_XGI300|MD_XGI315},
+       {"1024x768x24",  0x64, 0x013c, 0x0118, 1024,  768, 32, 1, 128, 48,
+        MD_XGI300|MD_XGI315},
+       {"1024x768x32",  0x64, 0x013c, 0x0118, 1024,  768, 32, 1, 128, 48,
+        MD_XGI300|MD_XGI315},
+       {"1152x768x8",   0x23, 0x0000, 0x0000, 1152,  768,  8, 1, 144, 48,
+        MD_XGI300          },  /* TW: 300 series only */
+       {"1152x768x16",  0x24, 0x0000, 0x0000, 1152,  768, 16, 1, 144, 48,
+        MD_XGI300          },
+       {"1152x768x24",  0x25, 0x0000, 0x0000, 1152,  768, 32, 1, 144, 48,
+        MD_XGI300          },
+       {"1152x768x32",  0x25, 0x0000, 0x0000, 1152,  768, 32, 1, 144, 48,
+        MD_XGI300          },
+       {"1280x720x8",   0x79, 0x0000, 0x0000, 1280,  720,  8, 1, 160, 45,
+        MD_XGI300|MD_XGI315},
+       {"1280x720x16",  0x75, 0x0000, 0x0000, 1280,  720, 16, 1, 160, 45,
+        MD_XGI300|MD_XGI315},
+       {"1280x720x24",  0x78, 0x0000, 0x0000, 1280,  720, 32, 1, 160, 45,
+        MD_XGI300|MD_XGI315},
+       {"1280x720x32",  0x78, 0x0000, 0x0000, 1280,  720, 32, 1, 160, 45,
+        MD_XGI300|MD_XGI315},
+       {"1280x768x8",   0x23, 0x0000, 0x0000, 1280,  768,  8, 1, 160, 48,
+        MD_XGI315},  /* TW: 310/325 series only */
+       {"1280x768x16",  0x24, 0x0000, 0x0000, 1280,  768, 16, 1, 160, 48,
+        MD_XGI315},
+       {"1280x768x24",  0x25, 0x0000, 0x0000, 1280,  768, 32, 1, 160, 48,
+        MD_XGI315},
+       {"1280x768x32",  0x25, 0x0000, 0x0000, 1280,  768, 32, 1, 160, 48,
+        MD_XGI315},
 #define MODEINDEX_1280x960 48
-       {"1280x960x8",   0x7C, 0x0000, 0x0000, 1280,  960,  8, 1, 160, 60, MD_XGI300|MD_XGI315},  /* TW: Modenumbers being patched */
-       {"1280x960x16",  0x7D, 0x0000, 0x0000, 1280,  960, 16, 1, 160, 60, MD_XGI300|MD_XGI315},
-       {"1280x960x24",  0x7E, 0x0000, 0x0000, 1280,  960, 32, 1, 160, 60, MD_XGI300|MD_XGI315},
-       {"1280x960x32",  0x7E, 0x0000, 0x0000, 1280,  960, 32, 1, 160, 60, MD_XGI300|MD_XGI315},
-       {"1280x1024x8",  0x3A, 0x0107, 0x0107, 1280, 1024,  8, 1, 160, 64, MD_XGI300|MD_XGI315},
-       {"1280x1024x16", 0x4D, 0x011a, 0x011a, 1280, 1024, 16, 1, 160, 64, MD_XGI300|MD_XGI315},
-       {"1280x1024x24", 0x65, 0x013d, 0x011b, 1280, 1024, 32, 1, 160, 64, MD_XGI300|MD_XGI315},
-       {"1280x1024x32", 0x65, 0x013d, 0x011b, 1280, 1024, 32, 1, 160, 64, MD_XGI300|MD_XGI315},
-       {"1400x1050x8",  0x26, 0x0000, 0x0000, 1400, 1050,  8, 1, 175, 65,           MD_XGI315},  /* TW: 310/325 series only */
-       {"1400x1050x16", 0x27, 0x0000, 0x0000, 1400, 1050, 16, 1, 175, 65,           MD_XGI315},
-       {"1400x1050x24", 0x28, 0x0000, 0x0000, 1400, 1050, 32, 1, 175, 65,           MD_XGI315},
-       {"1400x1050x32", 0x28, 0x0000, 0x0000, 1400, 1050, 32, 1, 175, 65,           MD_XGI315},
-       {"1600x1200x8",  0x3C, 0x0130, 0x011c, 1600, 1200,  8, 1, 200, 75, MD_XGI300|MD_XGI315},
-       {"1600x1200x16", 0x3D, 0x0131, 0x011e, 1600, 1200, 16, 1, 200, 75, MD_XGI300|MD_XGI315},
-       {"1600x1200x24", 0x66, 0x013e, 0x011f, 1600, 1200, 32, 1, 200, 75, MD_XGI300|MD_XGI315},
-       {"1600x1200x32", 0x66, 0x013e, 0x011f, 1600, 1200, 32, 1, 200, 75, MD_XGI300|MD_XGI315},
-       {"1920x1440x8",  0x68, 0x013f, 0x0000, 1920, 1440,  8, 1, 240, 75, MD_XGI300|MD_XGI315},
-       {"1920x1440x16", 0x69, 0x0140, 0x0000, 1920, 1440, 16, 1, 240, 75, MD_XGI300|MD_XGI315},
-       {"1920x1440x24", 0x6B, 0x0141, 0x0000, 1920, 1440, 32, 1, 240, 75, MD_XGI300|MD_XGI315},
-       {"1920x1440x32", 0x6B, 0x0141, 0x0000, 1920, 1440, 32, 1, 240, 75, MD_XGI300|MD_XGI315},
-       {"2048x1536x8",  0x6c, 0x0000, 0x0000, 2048, 1536,  8, 1, 256, 96,           MD_XGI315},  /* TW: 310/325 series only */
-       {"2048x1536x16", 0x6d, 0x0000, 0x0000, 2048, 1536, 16, 1, 256, 96,           MD_XGI315},
-       {"2048x1536x24", 0x6e, 0x0000, 0x0000, 2048, 1536, 32, 1, 256, 96,           MD_XGI315},
-       {"2048x1536x32", 0x6e, 0x0000, 0x0000, 2048, 1536, 32, 1, 256, 96,           MD_XGI315},
+       {"1280x960x8",   0x7C, 0x0000, 0x0000, 1280,  960,  8, 1, 160, 60,
+        MD_XGI300|MD_XGI315},  /* TW: Modenumbers being patched */
+       {"1280x960x16",  0x7D, 0x0000, 0x0000, 1280,  960, 16, 1, 160, 60,
+        MD_XGI300|MD_XGI315},
+       {"1280x960x24",  0x7E, 0x0000, 0x0000, 1280,  960, 32, 1, 160, 60,
+        MD_XGI300|MD_XGI315},
+       {"1280x960x32",  0x7E, 0x0000, 0x0000, 1280,  960, 32, 1, 160, 60,
+        MD_XGI300|MD_XGI315},
+       {"1280x1024x8",  0x3A, 0x0107, 0x0107, 1280, 1024,  8, 1, 160, 64,
+        MD_XGI300|MD_XGI315},
+       {"1280x1024x16", 0x4D, 0x011a, 0x011a, 1280, 1024, 16, 1, 160, 64,
+        MD_XGI300|MD_XGI315},
+       {"1280x1024x24", 0x65, 0x013d, 0x011b, 1280, 1024, 32, 1, 160, 64,
+        MD_XGI300|MD_XGI315},
+       {"1280x1024x32", 0x65, 0x013d, 0x011b, 1280, 1024, 32, 1, 160, 64,
+        MD_XGI300|MD_XGI315},
+       {"1400x1050x8",  0x26, 0x0000, 0x0000, 1400, 1050,  8, 1, 175, 65,
+        MD_XGI315},  /* TW: 310/325 series only */
+       {"1400x1050x16", 0x27, 0x0000, 0x0000, 1400, 1050, 16, 1, 175, 65,
+        MD_XGI315},
+       {"1400x1050x24", 0x28, 0x0000, 0x0000, 1400, 1050, 32, 1, 175, 65,
+        MD_XGI315},
+       {"1400x1050x32", 0x28, 0x0000, 0x0000, 1400, 1050, 32, 1, 175, 65,
+        MD_XGI315},
+       {"1600x1200x8",  0x3C, 0x0130, 0x011c, 1600, 1200,  8, 1, 200, 75,
+        MD_XGI300|MD_XGI315},
+       {"1600x1200x16", 0x3D, 0x0131, 0x011e, 1600, 1200, 16, 1, 200, 75,
+        MD_XGI300|MD_XGI315},
+       {"1600x1200x24", 0x66, 0x013e, 0x011f, 1600, 1200, 32, 1, 200, 75,
+        MD_XGI300|MD_XGI315},
+       {"1600x1200x32", 0x66, 0x013e, 0x011f, 1600, 1200, 32, 1, 200, 75,
+        MD_XGI300|MD_XGI315},
+       {"1920x1440x8",  0x68, 0x013f, 0x0000, 1920, 1440,  8, 1, 240, 75,
+        MD_XGI300|MD_XGI315},
+       {"1920x1440x16", 0x69, 0x0140, 0x0000, 1920, 1440, 16, 1, 240, 75,
+        MD_XGI300|MD_XGI315},
+       {"1920x1440x24", 0x6B, 0x0141, 0x0000, 1920, 1440, 32, 1, 240, 75,
+        MD_XGI300|MD_XGI315},
+       {"1920x1440x32", 0x6B, 0x0141, 0x0000, 1920, 1440, 32, 1, 240, 75,
+        MD_XGI300|MD_XGI315},
+       {"2048x1536x8",  0x6c, 0x0000, 0x0000, 2048, 1536,  8, 1, 256, 96,
+        MD_XGI315},  /* TW: 310/325 series only */
+       {"2048x1536x16", 0x6d, 0x0000, 0x0000, 2048, 1536, 16, 1, 256, 96,
+        MD_XGI315},
+       {"2048x1536x24", 0x6e, 0x0000, 0x0000, 2048, 1536, 32, 1, 256, 96,
+        MD_XGI315},
+       {"2048x1536x32", 0x6e, 0x0000, 0x0000, 2048, 1536, 32, 1, 256, 96,
+        MD_XGI315},
        {"\0", 0x00, 0, 0, 0, 0, 0, 0, 0}
 };
 
@@ -437,44 +480,45 @@ static struct _XGIbios_mode {
 #ifdef MODULE
 static int xgifb_mode_idx = 1;
 #else
-static int xgifb_mode_idx = -1;               /* Use a default mode if we are inside the kernel */
+static int xgifb_mode_idx = -1; /* Use a default mode if we are
+                                       inside the kernel */
 #endif
 static u8  XGIfb_mode_no  = 0;
 static u8  XGIfb_rate_idx = 0;
 
 /* TW: CR36 evaluation */
-static const unsigned short XGI300paneltype[] =
-    { LCD_UNKNOWN,   LCD_800x600,  LCD_1024x768,  LCD_1280x1024,
-      LCD_1280x960,  LCD_640x480,  LCD_1024x600,  LCD_1152x768,
-       LCD_1024x768, LCD_1024x768,  LCD_1024x768,
-      LCD_1024x768,  LCD_1024x768, LCD_1024x768,  LCD_1024x768 };
-
-static const unsigned short XGI310paneltype[] =
-    { LCD_UNKNOWN,   LCD_800x600,  LCD_1024x768,  LCD_1280x1024,
-      LCD_640x480,   LCD_1024x600, LCD_1152x864,  LCD_1280x960,
-      LCD_1152x768,  LCD_1400x1050,LCD_1280x768,  LCD_1600x1200,
-      LCD_1024x768, LCD_1024x768,  LCD_1024x768 };
+static const unsigned short XGI300paneltype[] = {
+        LCD_UNKNOWN,  LCD_800x600, LCD_1024x768, LCD_1280x1024,
+       LCD_1280x960,  LCD_640x480, LCD_1024x600, LCD_1152x768,
+       LCD_1024x768, LCD_1024x768, LCD_1024x768,
+       LCD_1024x768, LCD_1024x768, LCD_1024x768, LCD_1024x768};
+
+static const unsigned short XGI310paneltype[] = {
+        LCD_UNKNOWN,   LCD_800x600, LCD_1024x768, LCD_1280x1024,
+        LCD_640x480,  LCD_1024x600, LCD_1152x864, LCD_1280x960,
+       LCD_1152x768, LCD_1400x1050, LCD_1280x768, LCD_1600x1200,
+       LCD_1024x768,  LCD_1024x768, LCD_1024x768};
 
 static const struct _XGI_crt2type {
        char name[10];
        int type_no;
        int tvplug_no;
 } XGI_crt2type[] = {
-       {"NONE",        0,              -1},
-       {"LCD",         DISPTYPE_LCD,   -1},
-       {"TV",          DISPTYPE_TV,    -1},
-       {"VGA",         DISPTYPE_CRT2,  -1},
-       {"SVIDEO",      DISPTYPE_TV,    TVPLUG_SVIDEO},
-       {"COMPOSITE",   DISPTYPE_TV,    TVPLUG_COMPOSITE},
-       {"SCART",       DISPTYPE_TV,    TVPLUG_SCART},
-       {"none",        0,              -1},
-       {"lcd",         DISPTYPE_LCD,   -1},
-       {"tv",          DISPTYPE_TV,    -1},
-       {"vga",         DISPTYPE_CRT2,  -1},
-       {"svideo",      DISPTYPE_TV,    TVPLUG_SVIDEO},
-       {"composite",   DISPTYPE_TV,    TVPLUG_COMPOSITE},
-       {"scart",       DISPTYPE_TV,    TVPLUG_SCART},
-       {"\0",          -1,             -1}
+       {"NONE",        0,              -1},
+       {"LCD",         DISPTYPE_LCD,   -1},
+       {"TV",          DISPTYPE_TV,    -1},
+       {"VGA",         DISPTYPE_CRT2,  -1},
+       {"SVIDEO",      DISPTYPE_TV,    TVPLUG_SVIDEO},
+       {"COMPOSITE",   DISPTYPE_TV,    TVPLUG_COMPOSITE},
+       {"SCART",       DISPTYPE_TV,    TVPLUG_SCART},
+       {"none",        0,              -1},
+       {"lcd",         DISPTYPE_LCD,   -1},
+       {"tv",          DISPTYPE_TV,    -1},
+       {"vga",         DISPTYPE_CRT2,  -1},
+       {"svideo",      DISPTYPE_TV,    TVPLUG_SVIDEO},
+       {"composite",   DISPTYPE_TV,    TVPLUG_COMPOSITE},
+       {"scart",       DISPTYPE_TV,    TVPLUG_SCART},
+       {"\0",          -1,             -1}
 };
 
 /* TV standard */
@@ -482,11 +526,11 @@ static const struct _XGI_tvtype {
        char name[6];
        int type_no;
 } XGI_tvtype[] = {
-       {"PAL",         1},
-       {"NTSC",        2},
-       {"pal",         1},
-       {"ntsc",        2},
-       {"\0",          -1}
+       {"PAL",         1},
+       {"NTSC",        2},
+       {"pal",         1},
+       {"ntsc",        2},
+       {"\0",          -1}
 };
 
 static const struct _XGI_vrate {
@@ -495,13 +539,19 @@ static const struct _XGI_vrate {
        u16 yres;
        u16 refresh;
 } XGIfb_vrate[] = {
-       {1,  640,  480, 60}, {2,  640,  480,  72}, {3, 640,   480,  75}, {4,  640, 480,  85},
-       {5,  640,  480,100}, {6,  640,  480, 120}, {7, 640,   480, 160}, {8,  640, 480, 200},
+       {1,  640,  480, 60}, {2,  640,  480,  72},
+       {3, 640,   480,  75}, {4,  640, 480,  85},
+
+       {5,  640,  480, 100}, {6,  640,  480, 120},
+       {7, 640,   480, 160}, {8,  640, 480, 200},
+
        {1,  720,  480, 60},
        {1,  720,  576, 58},
        {1,  800,  480, 60}, {2,  800,  480,  75}, {3, 800,   480,  85},
-        {1,  800,  600,  60}, {2, 800,   600,  72}, {3,  800, 600,  75},
-       {4,  800,  600, 85}, {5,  800,  600, 100}, {6, 800,   600, 120}, {7,  800, 600, 160},
+       {1,  800,  600,  60}, {2, 800,   600,  72}, {3,  800, 600,  75},
+       {4,  800,  600, 85}, {5,  800,  600, 100},
+       {6, 800,   600, 120}, {7,  800, 600, 160},
+
        {1, 1024,  768,  60}, {2, 1024,  768,  70}, {3, 1024, 768,  75},
        {4, 1024,  768, 85}, {5, 1024,  768, 100}, {6, 1024,  768, 120},
        {1, 1024,  576, 60}, {2, 1024,  576,  75}, {3, 1024,  576,  85},
@@ -509,279 +559,187 @@ static const struct _XGI_vrate {
        {1, 1152,  768, 60},
        {1, 1280,  720, 60}, {2, 1280,  720,  75}, {3, 1280,  720,  85},
        {1, 1280,  768, 60},
-        {1, 1280, 1024,  60}, {2, 1280, 1024,  75}, {3, 1280, 1024,  85},
+       {1, 1280, 1024,  60}, {2, 1280, 1024,  75}, {3, 1280, 1024,  85},
        {1, 1280,  960, 70},
        {1, 1400, 1050, 60},
-       {1, 1600, 1200, 60}, {2, 1600, 1200,  65}, {3, 1600, 1200,  70}, {4, 1600, 1200,  75},
-       {5, 1600, 1200, 85}, {6, 1600, 1200, 100}, {7, 1600, 1200, 120},
-       {1, 1920, 1440, 60}, {2, 1920, 1440,  65}, {3, 1920, 1440,  70}, {4, 1920, 1440,  75},
+       {1, 1600, 1200, 60}, {2, 1600, 1200,  65},
+       {3, 1600, 1200,  70}, {4, 1600, 1200,  75},
+
+       {5, 1600, 1200, 85}, {6, 1600, 1200, 100},
+       {7, 1600, 1200, 120},
+
+       {1, 1920, 1440, 60}, {2, 1920, 1440,  65},
+       {3, 1920, 1440,  70}, {4, 1920, 1440,  75},
+
        {5, 1920, 1440, 85}, {6, 1920, 1440, 100},
-       {1, 2048, 1536, 60}, {2, 2048, 1536,  65}, {3, 2048, 1536,  70}, {4, 2048, 1536,  75},
+       {1, 2048, 1536, 60}, {2, 2048, 1536,  65},
+       {3, 2048, 1536,  70}, {4, 2048, 1536,  75},
+
        {5, 2048, 1536, 85},
        {0, 0, 0, 0}
 };
 
 static const struct _chswtable {
-    int subsysVendor;
-    int subsysCard;
-    char *vendorName;
-    char *cardName;
+       int subsysVendor;
+       int subsysCard;
+       char *vendorName;
+       char *cardName;
 } mychswtable[] = {
-        { 0x1631, 0x1002, "Mitachi", "0x1002" },
+       { 0x1631, 0x1002, "Mitachi", "0x1002" },
        { 0,      0,      ""       , ""       }
 };
 
-// Eden Chen
+/* Eden Chen */
 static const struct _XGI_TV_filter {
        u8 filter[9][4];
 } XGI_TV_filter[] = {
-       { {{0x00,0x00,0x00,0x40},  /* NTSCFilter_0 */
-          {0x00,0xE0,0x10,0x60},
-          {0x00,0xEE,0x10,0x44},
-          {0x00,0xF4,0x10,0x38},
-          {0xF8,0xF4,0x18,0x38},
-          {0xFC,0xFB,0x14,0x2A},
-          {0x00,0x00,0x10,0x20},
-          {0x00,0x04,0x10,0x18},
-          {0xFF,0xFF,0xFF,0xFF} }},
-       { {{0x00,0x00,0x00,0x40},  /* NTSCFilter_1 */
-          {0x00,0xE0,0x10,0x60},
-          {0x00,0xEE,0x10,0x44},
-          {0x00,0xF4,0x10,0x38},
-          {0xF8,0xF4,0x18,0x38},
-          {0xFC,0xFB,0x14,0x2A},
-          {0x00,0x00,0x10,0x20},
-          {0x00,0x04,0x10,0x18},
-          {0xFF,0xFF,0xFF,0xFF} }},
-       { {{0x00,0x00,0x00,0x40},  /* NTSCFilter_2 */
-          {0xF5,0xEE,0x1B,0x44},
-          {0xF8,0xF4,0x18,0x38},
-          {0xEB,0x04,0x25,0x18},
-          {0xF1,0x05,0x1F,0x16},
-          {0xF6,0x06,0x1A,0x14},
-          {0xFA,0x06,0x16,0x14},
-          {0x00,0x04,0x10,0x18},
-          {0xFF,0xFF,0xFF,0xFF} }},
-       { {{0x00,0x00,0x00,0x40},  /* NTSCFilter_3 */
-          {0xF1,0x04,0x1F,0x18},
-          {0xEE,0x0D,0x22,0x06},
-          {0xF7,0x06,0x19,0x14},
-          {0xF4,0x0B,0x1C,0x0A},
-          {0xFA,0x07,0x16,0x12},
-          {0xF9,0x0A,0x17,0x0C},
-          {0x00,0x07,0x10,0x12},
-          {0xFF,0xFF,0xFF,0xFF} }},
-       { {{0x00,0x00,0x00,0x40},  /* NTSCFilter_4 */
-          {0x00,0xE0,0x10,0x60},
-          {0x00,0xEE,0x10,0x44},
-          {0x00,0xF4,0x10,0x38},
-          {0xF8,0xF4,0x18,0x38},
-          {0xFC,0xFB,0x14,0x2A},
-          {0x00,0x00,0x10,0x20},
-          {0x00,0x04,0x10,0x18},
-          {0xFF,0xFF,0xFF,0xFF} }},
-       { {{0x00,0x00,0x00,0x40},  /* NTSCFilter_5 */
-          {0xF5,0xEE,0x1B,0x44},
-          {0xF8,0xF4,0x18,0x38},
-          {0xEB,0x04,0x25,0x18},
-          {0xF1,0x05,0x1F,0x16},
-          {0xF6,0x06,0x1A,0x14},
-          {0xFA,0x06,0x16,0x14},
-          {0x00,0x04,0x10,0x18},
-          {0xFF,0xFF,0xFF,0xFF} }},
-       { {{0x00,0x00,0x00,0x40},  /* NTSCFilter_6 */
-          {0xEB,0x04,0x25,0x18},
-          {0xE7,0x0E,0x29,0x04},
-          {0xEE,0x0C,0x22,0x08},
-          {0xF6,0x0B,0x1A,0x0A},
-          {0xF9,0x0A,0x17,0x0C},
-          {0xFC,0x0A,0x14,0x0C},
-          {0x00,0x08,0x10,0x10},
-          {0xFF,0xFF,0xFF,0xFF} }},
-       { {{0x00,0x00,0x00,0x40},  /* NTSCFilter_7 */
-          {0xEC,0x02,0x24,0x1C},
-          {0xF2,0x04,0x1E,0x18},
-          {0xEB,0x15,0x25,0xF6},
-          {0xF4,0x10,0x1C,0x00},
-          {0xF8,0x0F,0x18,0x02},
-          {0x00,0x04,0x10,0x18},
-          {0x01,0x06,0x0F,0x14},
-          {0xFF,0xFF,0xFF,0xFF} }},
-       { {{0x00,0x00,0x00,0x40},  /* PALFilter_0 */
-          {0x00,0xE0,0x10,0x60},
-          {0x00,0xEE,0x10,0x44},
-          {0x00,0xF4,0x10,0x38},
-          {0xF8,0xF4,0x18,0x38},
-          {0xFC,0xFB,0x14,0x2A},
-          {0x00,0x00,0x10,0x20},
-          {0x00,0x04,0x10,0x18},
-          {0xFF,0xFF,0xFF,0xFF} }},
-       { {{0x00,0x00,0x00,0x40},  /* PALFilter_1 */
-          {0x00,0xE0,0x10,0x60},
-          {0x00,0xEE,0x10,0x44},
-          {0x00,0xF4,0x10,0x38},
-          {0xF8,0xF4,0x18,0x38},
-          {0xFC,0xFB,0x14,0x2A},
-          {0x00,0x00,0x10,0x20},
-          {0x00,0x04,0x10,0x18},
-          {0xFF,0xFF,0xFF,0xFF} }},
-       { {{0x00,0x00,0x00,0x40},  /* PALFilter_2 */
-          {0xF5,0xEE,0x1B,0x44},
-          {0xF8,0xF4,0x18,0x38},
-          {0xF1,0xF7,0x01,0x32},
-          {0xF5,0xFB,0x1B,0x2A},
-          {0xF9,0xFF,0x17,0x22},
-          {0xFB,0x01,0x15,0x1E},
-          {0x00,0x04,0x10,0x18},
-          {0xFF,0xFF,0xFF,0xFF} }},
-       { {{0x00,0x00,0x00,0x40},  /* PALFilter_3 */
-          {0xF5,0xFB,0x1B,0x2A},
-          {0xEE,0xFE,0x22,0x24},
-          {0xF3,0x00,0x1D,0x20},
-          {0xF9,0x03,0x17,0x1A},
-          {0xFB,0x02,0x14,0x1E},
-          {0xFB,0x04,0x15,0x18},
-          {0x00,0x06,0x10,0x14},
-          {0xFF,0xFF,0xFF,0xFF} }},
-       { {{0x00,0x00,0x00,0x40},  /* PALFilter_4 */
-          {0x00,0xE0,0x10,0x60},
-          {0x00,0xEE,0x10,0x44},
-          {0x00,0xF4,0x10,0x38},
-          {0xF8,0xF4,0x18,0x38},
-          {0xFC,0xFB,0x14,0x2A},
-          {0x00,0x00,0x10,0x20},
-          {0x00,0x04,0x10,0x18},
-          {0xFF,0xFF,0xFF,0xFF} }},
-       { {{0x00,0x00,0x00,0x40},  /* PALFilter_5 */
-          {0xF5,0xEE,0x1B,0x44},
-          {0xF8,0xF4,0x18,0x38},
-          {0xF1,0xF7,0x1F,0x32},
-          {0xF5,0xFB,0x1B,0x2A},
-          {0xF9,0xFF,0x17,0x22},
-          {0xFB,0x01,0x15,0x1E},
-          {0x00,0x04,0x10,0x18},
-          {0xFF,0xFF,0xFF,0xFF} }},
-       { {{0x00,0x00,0x00,0x40},  /* PALFilter_6 */
-          {0xF5,0xEE,0x1B,0x2A},
-          {0xEE,0xFE,0x22,0x24},
-          {0xF3,0x00,0x1D,0x20},
-          {0xF9,0x03,0x17,0x1A},
-          {0xFB,0x02,0x14,0x1E},
-          {0xFB,0x04,0x15,0x18},
-          {0x00,0x06,0x10,0x14},
-          {0xFF,0xFF,0xFF,0xFF} }},
-       { {{0x00,0x00,0x00,0x40},  /* PALFilter_7 */
-          {0xF5,0xEE,0x1B,0x44},
-          {0xF8,0xF4,0x18,0x38},
-          {0xFC,0xFB,0x14,0x2A},
-          {0xEB,0x05,0x25,0x16},
-          {0xF1,0x05,0x1F,0x16},
-          {0xFA,0x07,0x16,0x12},
-          {0x00,0x07,0x10,0x12},
-          {0xFF,0xFF,0xFF,0xFF} }}
+       { { {0x00, 0x00, 0x00, 0x40},  /* NTSCFilter_0 */
+           {0x00, 0xE0, 0x10, 0x60},
+           {0x00, 0xEE, 0x10, 0x44},
+           {0x00, 0xF4, 0x10, 0x38},
+           {0xF8, 0xF4, 0x18, 0x38},
+           {0xFC, 0xFB, 0x14, 0x2A},
+           {0x00, 0x00, 0x10, 0x20},
+           {0x00, 0x04, 0x10, 0x18},
+           {0xFF, 0xFF, 0xFF, 0xFF} } },
+       { { {0x00, 0x00, 0x00, 0x40},  /* NTSCFilter_1 */
+           {0x00, 0xE0, 0x10, 0x60},
+           {0x00, 0xEE, 0x10, 0x44},
+           {0x00, 0xF4, 0x10, 0x38},
+           {0xF8, 0xF4, 0x18, 0x38},
+           {0xFC, 0xFB, 0x14, 0x2A},
+           {0x00, 0x00, 0x10, 0x20},
+           {0x00, 0x04, 0x10, 0x18},
+           {0xFF, 0xFF, 0xFF, 0xFF} } },
+       { { {0x00, 0x00, 0x00, 0x40},  /* NTSCFilter_2 */
+           {0xF5, 0xEE, 0x1B, 0x44},
+           {0xF8, 0xF4, 0x18, 0x38},
+           {0xEB, 0x04, 0x25, 0x18},
+           {0xF1, 0x05, 0x1F, 0x16},
+           {0xF6, 0x06, 0x1A, 0x14},
+           {0xFA, 0x06, 0x16, 0x14},
+           {0x00, 0x04, 0x10, 0x18},
+           {0xFF, 0xFF, 0xFF, 0xFF} } },
+       { { {0x00, 0x00, 0x00, 0x40},  /* NTSCFilter_3 */
+           {0xF1, 0x04, 0x1F, 0x18},
+           {0xEE, 0x0D, 0x22, 0x06},
+           {0xF7, 0x06, 0x19, 0x14},
+           {0xF4, 0x0B, 0x1C, 0x0A},
+           {0xFA, 0x07, 0x16, 0x12},
+           {0xF9, 0x0A, 0x17, 0x0C},
+           {0x00, 0x07, 0x10, 0x12},
+           {0xFF, 0xFF, 0xFF, 0xFF} } },
+       { { {0x00, 0x00, 0x00, 0x40},  /* NTSCFilter_4 */
+           {0x00, 0xE0, 0x10, 0x60},
+           {0x00, 0xEE, 0x10, 0x44},
+           {0x00, 0xF4, 0x10, 0x38},
+           {0xF8, 0xF4, 0x18, 0x38},
+           {0xFC, 0xFB, 0x14, 0x2A},
+           {0x00, 0x00, 0x10, 0x20},
+           {0x00, 0x04, 0x10, 0x18},
+           {0xFF, 0xFF, 0xFF, 0xFF} } },
+       { { {0x00, 0x00, 0x00, 0x40},  /* NTSCFilter_5 */
+           {0xF5, 0xEE, 0x1B, 0x44},
+           {0xF8, 0xF4, 0x18, 0x38},
+           {0xEB, 0x04, 0x25, 0x18},
+           {0xF1, 0x05, 0x1F, 0x16},
+           {0xF6, 0x06, 0x1A, 0x14},
+           {0xFA, 0x06, 0x16, 0x14},
+           {0x00, 0x04, 0x10, 0x18},
+           {0xFF, 0xFF, 0xFF, 0xFF} } },
+       { { {0x00, 0x00, 0x00, 0x40},  /* NTSCFilter_6 */
+           {0xEB, 0x04, 0x25, 0x18},
+           {0xE7, 0x0E, 0x29, 0x04},
+           {0xEE, 0x0C, 0x22, 0x08},
+           {0xF6, 0x0B, 0x1A, 0x0A},
+           {0xF9, 0x0A, 0x17, 0x0C},
+           {0xFC, 0x0A, 0x14, 0x0C},
+           {0x00, 0x08, 0x10, 0x10},
+           {0xFF, 0xFF, 0xFF, 0xFF} } },
+       { { {0x00, 0x00, 0x00, 0x40},  /* NTSCFilter_7 */
+           {0xEC, 0x02, 0x24, 0x1C},
+           {0xF2, 0x04, 0x1E, 0x18},
+           {0xEB, 0x15, 0x25, 0xF6},
+           {0xF4, 0x10, 0x1C, 0x00},
+           {0xF8, 0x0F, 0x18, 0x02},
+           {0x00, 0x04, 0x10, 0x18},
+           {0x01, 0x06, 0x0F, 0x14},
+           {0xFF, 0xFF, 0xFF, 0xFF} } },
+       { { {0x00, 0x00, 0x00, 0x40},  /* PALFilter_0 */
+           {0x00, 0xE0, 0x10, 0x60},
+           {0x00, 0xEE, 0x10, 0x44},
+           {0x00, 0xF4, 0x10, 0x38},
+           {0xF8, 0xF4, 0x18, 0x38},
+           {0xFC, 0xFB, 0x14, 0x2A},
+           {0x00, 0x00, 0x10, 0x20},
+           {0x00, 0x04, 0x10, 0x18},
+           {0xFF, 0xFF, 0xFF, 0xFF} } },
+       { { {0x00, 0x00, 0x00, 0x40},  /* PALFilter_1 */
+           {0x00, 0xE0, 0x10, 0x60},
+           {0x00, 0xEE, 0x10, 0x44},
+           {0x00, 0xF4, 0x10, 0x38},
+           {0xF8, 0xF4, 0x18, 0x38},
+           {0xFC, 0xFB, 0x14, 0x2A},
+           {0x00, 0x00, 0x10, 0x20},
+           {0x00, 0x04, 0x10, 0x18},
+           {0xFF, 0xFF, 0xFF, 0xFF} } },
+       { { {0x00, 0x00, 0x00, 0x40},  /* PALFilter_2 */
+           {0xF5, 0xEE, 0x1B, 0x44},
+           {0xF8, 0xF4, 0x18, 0x38},
+           {0xF1, 0xF7, 0x01, 0x32},
+           {0xF5, 0xFB, 0x1B, 0x2A},
+           {0xF9, 0xFF, 0x17, 0x22},
+           {0xFB, 0x01, 0x15, 0x1E},
+           {0x00, 0x04, 0x10, 0x18},
+           {0xFF, 0xFF, 0xFF, 0xFF} } },
+       { { {0x00, 0x00, 0x00, 0x40},  /* PALFilter_3 */
+           {0xF5, 0xFB, 0x1B, 0x2A},
+           {0xEE, 0xFE, 0x22, 0x24},
+           {0xF3, 0x00, 0x1D, 0x20},
+           {0xF9, 0x03, 0x17, 0x1A},
+           {0xFB, 0x02, 0x14, 0x1E},
+           {0xFB, 0x04, 0x15, 0x18},
+           {0x00, 0x06, 0x10, 0x14},
+           {0xFF, 0xFF, 0xFF, 0xFF} } },
+       { { {0x00, 0x00, 0x00, 0x40},  /* PALFilter_4 */
+           {0x00, 0xE0, 0x10, 0x60},
+           {0x00, 0xEE, 0x10, 0x44},
+           {0x00, 0xF4, 0x10, 0x38},
+           {0xF8, 0xF4, 0x18, 0x38},
+           {0xFC, 0xFB, 0x14, 0x2A},
+           {0x00, 0x00, 0x10, 0x20},
+           {0x00, 0x04, 0x10, 0x18},
+           {0xFF, 0xFF, 0xFF, 0xFF} } },
+       { { {0x00, 0x00, 0x00, 0x40},  /* PALFilter_5 */
+           {0xF5, 0xEE, 0x1B, 0x44},
+           {0xF8, 0xF4, 0x18, 0x38},
+           {0xF1, 0xF7, 0x1F, 0x32},
+           {0xF5, 0xFB, 0x1B, 0x2A},
+           {0xF9, 0xFF, 0x17, 0x22},
+           {0xFB, 0x01, 0x15, 0x1E},
+           {0x00, 0x04, 0x10, 0x18},
+           {0xFF, 0xFF, 0xFF, 0xFF} } },
+       { { {0x00, 0x00, 0x00, 0x40},  /* PALFilter_6 */
+           {0xF5, 0xEE, 0x1B, 0x2A},
+           {0xEE, 0xFE, 0x22, 0x24},
+           {0xF3, 0x00, 0x1D, 0x20},
+           {0xF9, 0x03, 0x17, 0x1A},
+           {0xFB, 0x02, 0x14, 0x1E},
+           {0xFB, 0x04, 0x15, 0x18},
+           {0x00, 0x06, 0x10, 0x14},
+           {0xFF, 0xFF, 0xFF, 0xFF} } },
+       { { {0x00, 0x00, 0x00, 0x40},  /* PALFilter_7 */
+           {0xF5, 0xEE, 0x1B, 0x44},
+           {0xF8, 0xF4, 0x18, 0x38},
+           {0xFC, 0xFB, 0x14, 0x2A},
+           {0xEB, 0x05, 0x25, 0x16},
+           {0xF1, 0x05, 0x1F, 0x16},
+           {0xFA, 0x07, 0x16, 0x12},
+           {0x00, 0x07, 0x10, 0x12},
+           {0xFF, 0xFF, 0xFF, 0xFF} } }
 };
 
 static int           filter = -1;
 static unsigned char filter_tb;
 
-
-/* ---------------------- Routine prototypes ------------------------- */
-
-/* Interface used by the world */
-#ifndef MODULE
-XGIINITSTATIC int __init XGIfb_setup(char *options);
-#endif
-
-/* Interface to the low level console driver */
-
-
-
-/* fbdev routines */
-XGIINITSTATIC int __init xgifb_init(void);
-static int      XGIfb_set_par(struct fb_info *info);
-static int      XGIfb_blank(int blank,
-                            struct fb_info *info);
-/*static int   XGIfb_mmap(struct fb_info *info, struct file *file,
-                          struct vm_area_struct *vma);
-*/
-
-/*
-extern int     XGIfb_mode_rate_to_dclock(VB_DEVICE_INFO *XGI_Pr,
-                             struct xgi_hw_device_info *HwDeviceExtension,
-                             unsigned char modeno, unsigned char rateindex);
-extern int      XGIfb_mode_rate_to_ddata(VB_DEVICE_INFO *XGI_Pr, struct xgi_hw_device_info *HwDeviceExtension,
-                        unsigned char modeno, unsigned char rateindex,
-                        unsigned int *left_margin, unsigned int *right_margin,
-                        unsigned int *upper_margin, unsigned int *lower_margin,
-                        unsigned int *hsync_len, unsigned int *vsync_len,
-                        unsigned int *sync, unsigned int *vmode);
-*/
-extern unsigned char XGI_SearchModeID(unsigned short ModeNo,
-                               unsigned short *ModeIdIndex,
-                               struct vb_device_info *);
-static int      XGIfb_get_fix(struct fb_fix_screeninfo *fix, int con,
-                             struct fb_info *info);
-
-/* Internal general routines */
-static void     XGIfb_search_mode(const char *name);
-static int      XGIfb_validate_mode(int modeindex);
-static u8       XGIfb_search_refresh_rate(unsigned int rate);
-static int      XGIfb_setcolreg(unsigned regno, unsigned red, unsigned green,
-                       unsigned blue, unsigned transp,
-                       struct fb_info *fb_info);
-static int      XGIfb_do_set_var(struct fb_var_screeninfo *var, int isactive,
-                       struct fb_info *info);
-static void     XGIfb_pre_setmode(void);
-static void     XGIfb_post_setmode(void);
-
-/* Internal hardware access routines */
-void            XGIfb_set_reg4(u16 port, unsigned long data);
-u32             XGIfb_get_reg3(u16 port);
-
-/* Chipset-dependent internal routines */
-
-
-static int      XGIfb_get_dram_size(void);
-static void     XGIfb_detect_VB(void);
-static void     XGIfb_get_VB_type(void);
-static int      XGIfb_has_VB(void);
-
-
-/* Internal routines to access PCI configuration space */
-unsigned char XGIfb_query_VGA_config_space(struct xgi_hw_device_info *pXGIhw_ext,
-                                          unsigned long offset,
-                                          unsigned long set,
-                                          unsigned long *value);
-//BOOLEAN         XGIfb_query_north_bridge_space(PXGI_HW_DEVICE_INFO pXGIhw_ext,
-//                     unsigned long offset, unsigned long set, unsigned long *value);
-
-
-/* Routines from init.c/init301.c */
-extern void     InitTo330Pointer(unsigned char, struct vb_device_info *pVBInfo);
-extern unsigned char  XGIInitNew(struct xgi_hw_device_info *HwDeviceExtension);
-extern unsigned char XGISetModeNew(struct xgi_hw_device_info *HwDeviceExtension,
-                                  unsigned short ModeNo);
-//extern void     XGI_SetEnableDstn(VB_DEVICE_INFO *XGI_Pr);
-extern void     XGI_LongWait(struct vb_device_info *XGI_Pr);
-extern unsigned short XGI_GetRatePtrCRT2(struct xgi_hw_device_info *pXGIHWDE,
-                                        unsigned short ModeNo,
-                                        unsigned short ModeIdIndex,
-                                        struct vb_device_info *pVBInfo);
-/* TW: Chrontel TV functions */
-extern unsigned short XGI_GetCH700x(struct vb_device_info *XGI_Pr,
-                                   unsigned short tempbx);
-extern void XGI_SetCH700x(struct vb_device_info *XGI_Pr, unsigned short tempbx);
-extern unsigned short XGI_GetCH701x(struct vb_device_info *XGI_Pr,
-                                   unsigned short tempbx);
-extern void XGI_SetCH701x(struct vb_device_info *XGI_Pr, unsigned short tempbx);
-extern void XGI_SetCH70xxANDOR(struct vb_device_info *XGI_Pr,
-                              unsigned short tempax,
-                              unsigned short tempbh);
-extern void XGI_DDC2Delay(struct vb_device_info *XGI_Pr, unsigned short delaytime);
-
-/* TW: Sensing routines */
-void            XGI_Sense30x(void);
-int             XGIDoSense(int tempbl, int tempbh, int tempcl, int tempch);
-
-extern struct XGI21_LVDSCapStruct XGI21_LCDCapList[13];
 #endif
index 721bd25fe542ab8fa945f829aaae0dfe678672ec..cadec2ad0d3240ca858b1822ab50733d425b51fa 100644 (file)
@@ -33,7 +33,7 @@
 #define XGIFB_PAN
 #endif
 
-#include <asm/io.h>
+#include <linux/io.h>
 #ifdef CONFIG_MTRR
 #include <asm/mtrr.h>
 #endif
@@ -41,7 +41,9 @@
 #include "XGIfb.h"
 #include "vgatypes.h"
 #include "XGI_main.h"
+#include "vb_init.h"
 #include "vb_util.h"
+#include "vb_setmode.h"
 
 #define Index_CR_GPIO_Reg1 0x48
 #define Index_CR_GPIO_Reg2 0x49
@@ -50,7 +52,6 @@
 #define GPIOG_EN    (1<<6)
 #define GPIOG_WRITE (1<<6)
 #define GPIOG_READ  (1<<1)
-int XGIfb_GetXG21DefaultLVDSModeIdx(void);
 
 #define XGIFB_ROM_SIZE 65536
 
@@ -69,69 +70,69 @@ static void dumpVGAReg(void)
 {
        u8 i, reg;
 
-       outXGIIDXREG(XGISR, 0x05, 0x86);
+       xgifb_reg_set(XGISR, 0x05, 0x86);
        /*
-       outXGIIDXREG(XGISR, 0x08, 0x4f);
-       outXGIIDXREG(XGISR, 0x0f, 0x20);
-       outXGIIDXREG(XGISR, 0x11, 0x4f);
-       outXGIIDXREG(XGISR, 0x13, 0x45);
-       outXGIIDXREG(XGISR, 0x14, 0x51);
-       outXGIIDXREG(XGISR, 0x1e, 0x41);
-       outXGIIDXREG(XGISR, 0x1f, 0x0);
-       outXGIIDXREG(XGISR, 0x20, 0xa1);
-       outXGIIDXREG(XGISR, 0x22, 0xfb);
-       outXGIIDXREG(XGISR, 0x26, 0x22);
-       outXGIIDXREG(XGISR, 0x3e, 0x07);
+       xgifb_reg_set(XGISR, 0x08, 0x4f);
+       xgifb_reg_set(XGISR, 0x0f, 0x20);
+       xgifb_reg_set(XGISR, 0x11, 0x4f);
+       xgifb_reg_set(XGISR, 0x13, 0x45);
+       xgifb_reg_set(XGISR, 0x14, 0x51);
+       xgifb_reg_set(XGISR, 0x1e, 0x41);
+       xgifb_reg_set(XGISR, 0x1f, 0x0);
+       xgifb_reg_set(XGISR, 0x20, 0xa1);
+       xgifb_reg_set(XGISR, 0x22, 0xfb);
+       xgifb_reg_set(XGISR, 0x26, 0x22);
+       xgifb_reg_set(XGISR, 0x3e, 0x07);
        */
 
-       /* outXGIIDXREG(XGICR, 0x19, 0x00); */
-       /* outXGIIDXREG(XGICR, 0x1a, 0x3C); */
-       /* outXGIIDXREG(XGICR, 0x22, 0xff); */
-       /* outXGIIDXREG(XGICR, 0x3D, 0x10); */
+       /* xgifb_reg_set(XGICR, 0x19, 0x00); */
+       /* xgifb_reg_set(XGICR, 0x1a, 0x3C); */
+       /* xgifb_reg_set(XGICR, 0x22, 0xff); */
+       /* xgifb_reg_set(XGICR, 0x3D, 0x10); */
 
-       /* outXGIIDXREG(XGICR, 0x4a, 0xf3); */
+       /* xgifb_reg_set(XGICR, 0x4a, 0xf3); */
 
-       /* outXGIIDXREG(XGICR, 0x57, 0x0); */
-       /* outXGIIDXREG(XGICR, 0x7a, 0x2c); */
+       /* xgifb_reg_set(XGICR, 0x57, 0x0); */
+       /* xgifb_reg_set(XGICR, 0x7a, 0x2c); */
 
-       /* outXGIIDXREG(XGICR, 0x82, 0xcc); */
-       /* outXGIIDXREG(XGICR, 0x8c, 0x0); */
+       /* xgifb_reg_set(XGICR, 0x82, 0xcc); */
+       /* xgifb_reg_set(XGICR, 0x8c, 0x0); */
        /*
-       outXGIIDXREG(XGICR, 0x99, 0x1);
-       outXGIIDXREG(XGICR, 0x41, 0x40);
+       xgifb_reg_set(XGICR, 0x99, 0x1);
+       xgifb_reg_set(XGICR, 0x41, 0x40);
        */
 
        for (i = 0; i < 0x4f; i++) {
-               inXGIIDXREG(XGISR, i, reg);
+               reg = xgifb_reg_get(XGISR, i);
                printk("\no 3c4 %x", i);
                printk("\ni 3c5 => %x", reg);
        }
 
        for (i = 0; i < 0xF0; i++) {
-               inXGIIDXREG(XGICR, i, reg);
+               reg = xgifb_reg_get(XGICR, i);
                printk("\no 3d4 %x", i);
                printk("\ni 3d5 => %x", reg);
        }
        /*
-       outXGIIDXREG(XGIPART1,0x2F,1);
+       xgifb_reg_set(XGIPART1,0x2F,1);
        for (i=1; i < 0x50; i++) {
-               inXGIIDXREG(XGIPART1, i, reg);
+               reg = xgifb_reg_get(XGIPART1, i);
                printk("\no d004 %x", i);
                printk("\ni d005 => %x", reg);
        }
 
        for (i=0; i < 0x50; i++) {
-                inXGIIDXREG(XGIPART2, i, reg);
+                reg = xgifb_reg_get(XGIPART2, i);
                 printk("\no d010 %x", i);
                 printk("\ni d011 => %x", reg);
        }
        for (i=0; i < 0x50; i++) {
-               inXGIIDXREG(XGIPART3, i, reg);
+               reg = xgifb_reg_get(XGIPART3, i);
                printk("\no d012 %x",i);
                printk("\ni d013 => %x",reg);
        }
        for (i=0; i < 0x50; i++) {
-               inXGIIDXREG(XGIPART4, i, reg);
+               reg = xgifb_reg_get(XGIPART4, i);
                printk("\no d014 %x",i);
                printk("\ni d015 => %x",reg);
        }
@@ -348,10 +349,10 @@ static int XGIfb_mode_rate_to_ddata(struct vb_device_info *XGI_Pr,
        else {
                j = 0;
                while (XGI_Pr->EModeIDTable[j].Ext_ModeID != 0xff) {
-                       if (XGI_Pr->EModeIDTable[j].Ext_ModeID
-                                       == XGI_Pr->RefIndex[RefreshRateTableIndex].ModeID) {
-                               if (XGI_Pr->EModeIDTable[j].Ext_ModeFlag
-                                               & DoubleScanMode) {
+                       if (XGI_Pr->EModeIDTable[j].Ext_ModeID ==
+                           XGI_Pr->RefIndex[RefreshRateTableIndex].ModeID) {
+                               if (XGI_Pr->EModeIDTable[j].Ext_ModeFlag &
+                                   DoubleScanMode) {
                                        *vmode = FB_VMODE_DOUBLE;
                                }
                                break;
@@ -377,30 +378,22 @@ static void XGIRegInit(struct vb_device_info *XGI_Pr, unsigned long BaseAddr)
        XGI_Pr->P3c8 = BaseAddr + 0x18;
        XGI_Pr->P3c9 = BaseAddr + 0x19;
        XGI_Pr->P3da = BaseAddr + 0x2A;
-       XGI_Pr->Part1Port = BaseAddr + XGI_CRT2_PORT_04; /* Digital video interface registers (LCD) */
-       XGI_Pr->Part2Port = BaseAddr + XGI_CRT2_PORT_10; /* 301 TV Encoder registers */
-       XGI_Pr->Part3Port = BaseAddr + XGI_CRT2_PORT_12; /* 301 Macrovision registers */
-       XGI_Pr->Part4Port = BaseAddr + XGI_CRT2_PORT_14; /* 301 VGA2 (and LCD) registers */
-       XGI_Pr->Part5Port = BaseAddr + XGI_CRT2_PORT_14 + 2; /* 301 palette address port registers */
+       /* Digital video interface registers (LCD) */
+       XGI_Pr->Part1Port = BaseAddr + XGI_CRT2_PORT_04;
+       /* 301 TV Encoder registers */
+       XGI_Pr->Part2Port = BaseAddr + XGI_CRT2_PORT_10;
+       /* 301 Macrovision registers */
+       XGI_Pr->Part3Port = BaseAddr + XGI_CRT2_PORT_12;
+       /* 301 VGA2 (and LCD) registers */
+       XGI_Pr->Part4Port = BaseAddr + XGI_CRT2_PORT_14;
+       /* 301 palette address port registers */
+       XGI_Pr->Part5Port = BaseAddr + XGI_CRT2_PORT_14 + 2;
 
 }
 
-void XGIfb_set_reg4(u16 port, unsigned long data)
-{
-       outl((u32)(data & 0xffffffff), port);
-}
-
-u32 XGIfb_get_reg3(u16 port)
-{
-       u32 data;
-
-       data = inl(port);
-       return data;
-}
-
 /* ------------ Interface for init & mode switching code ------------- */
 
-unsigned char XGIfb_query_VGA_config_space(
+static unsigned char XGIfb_query_VGA_config_space(
                struct xgi_hw_device_info *pXGIhw_ext, unsigned long offset,
                unsigned long set, unsigned long *value)
 {
@@ -436,62 +429,34 @@ unsigned char XGIfb_query_VGA_config_space(
        return 1;
 }
 
-/*
-unsigned char XGIfb_query_north_bridge_space(struct xgi_hw_device_info *pXGIhw_ext,
-       unsigned long offset, unsigned long set, unsigned long *value)
+/* ------------------ Internal helper routines ----------------- */
+
+static int XGIfb_GetXG21DefaultLVDSModeIdx(void)
 {
-       static struct pci_dev *pdev = NULL;
-       static unsigned char init = 0, valid_pdev = 0;
-       u16 nbridge_id = 0;
 
-       if (!init) {
-               init = 1;
-               switch (xgi_video_info.chip) {
-               case XGI_540:
-                       nbridge_id = PCI_DEVICE_ID_XG_540;
-                       break;
-               case XGI_630:
-                       nbridge_id = PCI_DEVICE_ID_XG_630;
-                       break;
-               case XGI_730:
-                       nbridge_id = PCI_DEVICE_ID_XG_730;
-                       break;
-               case XGI_550:
-                       nbridge_id = PCI_DEVICE_ID_XG_550;
-                       break;
-               case XGI_650:
-                       nbridge_id = PCI_DEVICE_ID_XG_650;
-                       break;
-               case XGI_740:
-                       nbridge_id = PCI_DEVICE_ID_XG_740;
-                       break;
-               default:
-                       nbridge_id = 0;
-                       break;
-               }
+       int found_mode = 0;
+       int XGIfb_mode_idx = 0;
 
-               pdev = pci_get_device(PCI_VENDOR_ID_SI, nbridge_id, pdev);
-               if (pdev) {
-                       valid_pdev = 1;
-                       pci_dev_put(pdev);
+       found_mode = 0;
+       while ((XGIbios_mode[XGIfb_mode_idx].mode_no != 0)
+                       && (XGIbios_mode[XGIfb_mode_idx].xres
+                                       <= XGI21_LCDCapList[0].LVDSHDE)) {
+               if ((XGIbios_mode[XGIfb_mode_idx].xres
+                               == XGI21_LCDCapList[0].LVDSHDE)
+                               && (XGIbios_mode[XGIfb_mode_idx].yres
+                                               == XGI21_LCDCapList[0].LVDSVDE)
+                               && (XGIbios_mode[XGIfb_mode_idx].bpp == 8)) {
+                       XGIfb_mode_no = XGIbios_mode[XGIfb_mode_idx].mode_no;
+                       found_mode = 1;
+                       break;
                }
+               XGIfb_mode_idx++;
        }
+       if (!found_mode)
+               XGIfb_mode_idx = 0;
 
-       if (!valid_pdev) {
-               printk(KERN_DEBUG "XGIfb: Can't find XGI %d North Bridge device.\n",
-                       nbridge_id);
-               return 0;
-       }
-
-       if (set == 0)
-               pci_read_config_dword(pdev, offset, (u32 *)value);
-       else
-               pci_write_config_dword(pdev, offset, (u32)(*value));
-
-       return 1;
+       return XGIfb_mode_idx;
 }
-*/
-/* ------------------ Internal helper routines ----------------- */
 
 static void XGIfb_search_mode(const char *name)
 {
@@ -551,8 +516,8 @@ static void XGIfb_search_vesamode(unsigned int vesamode)
        vesamode &= 0x1dff; /* Clean VESA mode number from other flags */
 
        while (XGIbios_mode[i].mode_no != 0) {
-               if ((XGIbios_mode[i].vesa_mode_no_1 == vesamode)
-                               || (XGIbios_mode[i].vesa_mode_no_2 == vesamode)) {
+               if ((XGIbios_mode[i].vesa_mode_no_1 == vesamode) ||
+                   (XGIbios_mode[i].vesa_mode_no_2 == vesamode)) {
                        xgifb_mode_idx = i;
                        j = 1;
                        break;
@@ -569,11 +534,13 @@ static int XGIfb_GetXG21LVDSData(void)
        unsigned char *pData;
        int i, j, k;
 
-       inXGIIDXREG(XGISR, 0x1e, tmp);
-       outXGIIDXREG(XGISR, 0x1e, tmp | 4);
+       tmp = xgifb_reg_get(XGISR, 0x1e);
+       xgifb_reg_set(XGISR, 0x1e, tmp | 4);
 
        pData = xgi_video_info.mmio_vbase + 0x20000;
-       if ((pData[0x0] == 0x55) && (pData[0x1] == 0xAA) && (pData[0x65] & 0x1)) {
+       if ((pData[0x0] == 0x55) &&
+           (pData[0x1] == 0xAA) &&
+           (pData[0x65] & 0x1)) {
                i = pData[0x316] | (pData[0x317] << 8);
                j = pData[i - 1];
                if (j == 0xff)
@@ -616,33 +583,6 @@ static int XGIfb_GetXG21LVDSData(void)
        return 0;
 }
 
-int XGIfb_GetXG21DefaultLVDSModeIdx(void)
-{
-
-       int found_mode = 0;
-       int XGIfb_mode_idx = 0;
-
-       found_mode = 0;
-       while ((XGIbios_mode[XGIfb_mode_idx].mode_no != 0)
-                       && (XGIbios_mode[XGIfb_mode_idx].xres
-                                       <= XGI21_LCDCapList[0].LVDSHDE)) {
-               if ((XGIbios_mode[XGIfb_mode_idx].xres
-                               == XGI21_LCDCapList[0].LVDSHDE)
-                               && (XGIbios_mode[XGIfb_mode_idx].yres
-                                               == XGI21_LCDCapList[0].LVDSVDE)
-                               && (XGIbios_mode[XGIfb_mode_idx].bpp == 8)) {
-                       XGIfb_mode_no = XGIbios_mode[XGIfb_mode_idx].mode_no;
-                       found_mode = 1;
-                       break;
-               }
-               XGIfb_mode_idx++;
-       }
-       if (!found_mode)
-               XGIfb_mode_idx = 0;
-
-       return XGIfb_mode_idx;
-}
-
 static int XGIfb_validate_mode(int myindex)
 {
        u16 xres, yres;
@@ -656,8 +596,8 @@ static int XGIfb_validate_mode(int myindex)
                                return -1;
                        if (XGIbios_mode[myindex].yres > yres)
                                return -1;
-                       if ((XGIbios_mode[myindex].xres < xres)
-                                       && (XGIbios_mode[myindex].yres < yres)) {
+                       if ((XGIbios_mode[myindex].xres < xres) &&
+                           (XGIbios_mode[myindex].yres < yres)) {
                                if (XGIbios_mode[myindex].bpp > 8)
                                        return -1;
                        }
@@ -733,7 +673,7 @@ static int XGIfb_validate_mode(int myindex)
                if (XGIbios_mode[myindex].yres > yres)
                        return -1;
                if ((XGIhw_ext.ulExternalChip == 0x01) || /* LVDS */
-                               (XGIhw_ext.ulExternalChip == 0x05)) { /* LVDS+Chrontel */
+                   (XGIhw_ext.ulExternalChip == 0x05)) { /* LVDS+Chrontel */
                        switch (XGIbios_mode[myindex].xres) {
                        case 512:
                                if (XGIbios_mode[myindex].yres != 512)
@@ -752,13 +692,11 @@ static int XGIfb_validate_mode(int myindex)
                                        return -1;
                                break;
                        case 1024:
-                               if ((XGIbios_mode[myindex].yres != 600)
-                                               && (XGIbios_mode[myindex].yres
-                                                               != 768))
+                               if ((XGIbios_mode[myindex].yres != 600) &&
+                                   (XGIbios_mode[myindex].yres != 768))
                                        return -1;
-                               if ((XGIbios_mode[myindex].yres == 600)
-                                               && (XGIhw_ext.ulCRT2LCDType
-                                                               != LCD_1024x600))
+                               if ((XGIbios_mode[myindex].yres == 600) &&
+                                   (XGIhw_ext.ulCRT2LCDType != LCD_1024x600))
                                        return -1;
                                break;
                        case 1152:
@@ -768,13 +706,11 @@ static int XGIfb_validate_mode(int myindex)
                                        return -1;
                                break;
                        case 1280:
-                               if ((XGIbios_mode[myindex].yres != 768)
-                                               && (XGIbios_mode[myindex].yres
-                                                               != 1024))
+                               if ((XGIbios_mode[myindex].yres != 768) &&
+                                   (XGIbios_mode[myindex].yres != 1024))
                                        return -1;
-                               if ((XGIbios_mode[myindex].yres == 768)
-                                               && (XGIhw_ext.ulCRT2LCDType
-                                                               != LCD_1280x768))
+                               if ((XGIbios_mode[myindex].yres == 768) &&
+                                   (XGIhw_ext.ulCRT2LCDType != LCD_1280x768))
                                        return -1;
                                break;
                        case 1400:
@@ -795,9 +731,8 @@ static int XGIfb_validate_mode(int myindex)
                                        return -1;
                                break;
                        case 640:
-                               if ((XGIbios_mode[myindex].yres != 400)
-                                               && (XGIbios_mode[myindex].yres
-                                                               != 480))
+                               if ((XGIbios_mode[myindex].yres != 400) &&
+                                   (XGIbios_mode[myindex].yres != 480))
                                        return -1;
                                break;
                        case 800:
@@ -809,13 +744,12 @@ static int XGIfb_validate_mode(int myindex)
                                        return -1;
                                break;
                        case 1280:
-                               if ((XGIbios_mode[myindex].yres != 960)
-                                               && (XGIbios_mode[myindex].yres
-                                                               != 1024))
+                               if ((XGIbios_mode[myindex].yres != 960) &&
+                                   (XGIbios_mode[myindex].yres != 1024))
                                        return -1;
                                if (XGIbios_mode[myindex].yres == 960) {
-                                       if (XGIhw_ext.ulCRT2LCDType
-                                                       == LCD_1400x1050)
+                                       if (XGIhw_ext.ulCRT2LCDType ==
+                                           LCD_1400x1050)
                                                return -1;
                                }
                                break;
@@ -847,8 +781,8 @@ static int XGIfb_validate_mode(int myindex)
                                        return -1;
                        }
                        /*  TW: LVDS/CHRONTEL does not support 720 */
-                       if (xgi_video_info.hasVB == HASVB_LVDS_CHRONTEL
-                                       || xgi_video_info.hasVB == HASVB_CHRONTEL) {
+                       if (xgi_video_info.hasVB == HASVB_LVDS_CHRONTEL ||
+                           xgi_video_info.hasVB == HASVB_CHRONTEL) {
                                return -1;
                        }
                        break;
@@ -900,31 +834,31 @@ static u8 XGIfb_search_refresh_rate(unsigned int rate)
 
        XGIfb_rate_idx = 0;
        while ((XGIfb_vrate[i].idx != 0) && (XGIfb_vrate[i].xres <= xres)) {
-               if ((XGIfb_vrate[i].xres == xres) && (XGIfb_vrate[i].yres
-                               == yres)) {
+               if ((XGIfb_vrate[i].xres == xres) &&
+                   (XGIfb_vrate[i].yres == yres)) {
                        if (XGIfb_vrate[i].refresh == rate) {
                                XGIfb_rate_idx = XGIfb_vrate[i].idx;
                                break;
                        } else if (XGIfb_vrate[i].refresh > rate) {
                                if ((XGIfb_vrate[i].refresh - rate) <= 3) {
                                        DPRINTK("XGIfb: Adjusting rate from %d up to %d\n",
-                                                       rate, XGIfb_vrate[i].refresh);
+                                               rate, XGIfb_vrate[i].refresh);
                                        XGIfb_rate_idx = XGIfb_vrate[i].idx;
-                                       xgi_video_info.refresh_rate
-                                                       = XGIfb_vrate[i].refresh;
+                                       xgi_video_info.refresh_rate =
+                                               XGIfb_vrate[i].refresh;
                                } else if (((rate - XGIfb_vrate[i - 1].refresh)
                                                <= 2) && (XGIfb_vrate[i].idx
                                                != 1)) {
                                        DPRINTK("XGIfb: Adjusting rate from %d down to %d\n",
-                                                       rate, XGIfb_vrate[i-1].refresh);
+                                               rate, XGIfb_vrate[i-1].refresh);
                                        XGIfb_rate_idx = XGIfb_vrate[i - 1].idx;
-                                       xgi_video_info.refresh_rate
-                                                       = XGIfb_vrate[i - 1].refresh;
+                                       xgi_video_info.refresh_rate =
+                                               XGIfb_vrate[i - 1].refresh;
                                }
                                break;
                        } else if ((rate - XGIfb_vrate[i].refresh) <= 2) {
                                DPRINTK("XGIfb: Adjusting rate from %d down to %d\n",
-                                               rate, XGIfb_vrate[i].refresh);
+                                       rate, XGIfb_vrate[i].refresh);
                                XGIfb_rate_idx = XGIfb_vrate[i].idx;
                                break;
                        }
@@ -934,8 +868,8 @@ static u8 XGIfb_search_refresh_rate(unsigned int rate)
        if (XGIfb_rate_idx > 0) {
                return XGIfb_rate_idx;
        } else {
-               printk(KERN_INFO
-                               "XGIfb: Unsupported rate %d for %dx%d\n", rate, xres, yres);
+               printk(KERN_INFO "XGIfb: Unsupported rate %d for %dx%d\n",
+                      rate, xres, yres);
                return 0;
        }
 }
@@ -991,6 +925,282 @@ static void XGIfb_bpp_to_var(struct fb_var_screeninfo *var)
        }
 }
 
+/* --------------------- SetMode routines ------------------------- */
+
+static void XGIfb_pre_setmode(void)
+{
+       u8 cr30 = 0, cr31 = 0;
+
+       cr31 = xgifb_reg_get(XGICR, 0x31);
+       cr31 &= ~0x60;
+
+       switch (xgi_video_info.disp_state & DISPTYPE_DISP2) {
+       case DISPTYPE_CRT2:
+               cr30 = (XGI_VB_OUTPUT_CRT2 | XGI_SIMULTANEOUS_VIEW_ENABLE);
+               cr31 |= XGI_DRIVER_MODE;
+               break;
+       case DISPTYPE_LCD:
+               cr30 = (XGI_VB_OUTPUT_LCD | XGI_SIMULTANEOUS_VIEW_ENABLE);
+               cr31 |= XGI_DRIVER_MODE;
+               break;
+       case DISPTYPE_TV:
+               if (xgi_video_info.TV_type == TVMODE_HIVISION)
+                       cr30 = (XGI_VB_OUTPUT_HIVISION
+                                       | XGI_SIMULTANEOUS_VIEW_ENABLE);
+               else if (xgi_video_info.TV_plug == TVPLUG_SVIDEO)
+                       cr30 = (XGI_VB_OUTPUT_SVIDEO
+                                       | XGI_SIMULTANEOUS_VIEW_ENABLE);
+               else if (xgi_video_info.TV_plug == TVPLUG_COMPOSITE)
+                       cr30 = (XGI_VB_OUTPUT_COMPOSITE
+                                       | XGI_SIMULTANEOUS_VIEW_ENABLE);
+               else if (xgi_video_info.TV_plug == TVPLUG_SCART)
+                       cr30 = (XGI_VB_OUTPUT_SCART
+                                       | XGI_SIMULTANEOUS_VIEW_ENABLE);
+               cr31 |= XGI_DRIVER_MODE;
+
+               if (XGIfb_tvmode == 1 || xgi_video_info.TV_type == TVMODE_PAL)
+                       cr31 |= 0x01;
+               else
+                       cr31 &= ~0x01;
+               break;
+       default: /* disable CRT2 */
+               cr30 = 0x00;
+               cr31 |= (XGI_DRIVER_MODE | XGI_VB_OUTPUT_DISABLE);
+       }
+
+       xgifb_reg_set(XGICR, IND_XGI_SCRATCH_REG_CR30, cr30);
+       xgifb_reg_set(XGICR, IND_XGI_SCRATCH_REG_CR31, cr31);
+       xgifb_reg_set(XGICR, IND_XGI_SCRATCH_REG_CR33, (XGIfb_rate_idx & 0x0F));
+}
+
+static void XGIfb_post_setmode(void)
+{
+       u8 reg;
+       unsigned char doit = 1;
+       /*
+       xgifb_reg_set(XGISR,IND_XGI_PASSWORD,XGI_PASSWORD);
+       xgifb_reg_set(XGICR, 0x13, 0x00);
+       xgifb_reg_and_or(XGISR,0x0E, 0xF0, 0x01);
+       *test*
+       */
+       if (xgi_video_info.video_bpp == 8) {
+               /* TW: We can't switch off CRT1 on LVDS/Chrontel
+                * in 8bpp Modes */
+               if ((xgi_video_info.hasVB == HASVB_LVDS) ||
+                   (xgi_video_info.hasVB == HASVB_LVDS_CHRONTEL)) {
+                       doit = 0;
+               }
+               /* TW: We can't switch off CRT1 on 301B-DH
+                * in 8bpp Modes if using LCD */
+               if (xgi_video_info.disp_state & DISPTYPE_LCD)
+                       doit = 0;
+       }
+
+       /* TW: We can't switch off CRT1 if bridge is in slave mode */
+       if (xgi_video_info.hasVB != HASVB_NONE) {
+               reg = xgifb_reg_get(XGIPART1, 0x00);
+
+               if ((reg & 0x50) == 0x10)
+                       doit = 0;
+
+       } else {
+               XGIfb_crt1off = 0;
+       }
+
+       reg = xgifb_reg_get(XGICR, 0x17);
+       if ((XGIfb_crt1off) && (doit))
+               reg &= ~0x80;
+       else
+               reg |= 0x80;
+       xgifb_reg_set(XGICR, 0x17, reg);
+
+       xgifb_reg_and(XGISR, IND_XGI_RAMDAC_CONTROL, ~0x04);
+
+       if ((xgi_video_info.disp_state & DISPTYPE_TV) && (xgi_video_info.hasVB
+                       == HASVB_301)) {
+
+               reg = xgifb_reg_get(XGIPART4, 0x01);
+
+               if (reg < 0xB0) { /* Set filter for XGI301 */
+                       switch (xgi_video_info.video_width) {
+                       case 320:
+                               filter_tb = (xgi_video_info.TV_type ==
+                                            TVMODE_NTSC) ? 4 : 12;
+                               break;
+                       case 640:
+                               filter_tb = (xgi_video_info.TV_type ==
+                                            TVMODE_NTSC) ? 5 : 13;
+                               break;
+                       case 720:
+                               filter_tb = (xgi_video_info.TV_type ==
+                                            TVMODE_NTSC) ? 6 : 14;
+                               break;
+                       case 800:
+                               filter_tb = (xgi_video_info.TV_type ==
+                                            TVMODE_NTSC) ? 7 : 15;
+                               break;
+                       default:
+                               filter = -1;
+                               break;
+                       }
+                       xgifb_reg_or(XGIPART1, XGIfb_CRT2_write_enable, 0x01);
+
+                       if (xgi_video_info.TV_type == TVMODE_NTSC) {
+
+                               xgifb_reg_and(XGIPART2, 0x3a, 0x1f);
+
+                               if (xgi_video_info.TV_plug == TVPLUG_SVIDEO) {
+
+                                       xgifb_reg_and(XGIPART2, 0x30, 0xdf);
+
+                               } else if (xgi_video_info.TV_plug
+                                               == TVPLUG_COMPOSITE) {
+
+                                       xgifb_reg_or(XGIPART2, 0x30, 0x20);
+
+                                       switch (xgi_video_info.video_width) {
+                                       case 640:
+                                               xgifb_reg_set(XGIPART2,
+                                                             0x35,
+                                                             0xEB);
+                                               xgifb_reg_set(XGIPART2,
+                                                             0x36,
+                                                             0x04);
+                                               xgifb_reg_set(XGIPART2,
+                                                             0x37,
+                                                             0x25);
+                                               xgifb_reg_set(XGIPART2,
+                                                             0x38,
+                                                             0x18);
+                                               break;
+                                       case 720:
+                                               xgifb_reg_set(XGIPART2,
+                                                             0x35,
+                                                             0xEE);
+                                               xgifb_reg_set(XGIPART2,
+                                                             0x36,
+                                                             0x0C);
+                                               xgifb_reg_set(XGIPART2,
+                                                             0x37,
+                                                             0x22);
+                                               xgifb_reg_set(XGIPART2,
+                                                             0x38,
+                                                             0x08);
+                                               break;
+                                       case 800:
+                                               xgifb_reg_set(XGIPART2,
+                                                             0x35,
+                                                             0xEB);
+                                               xgifb_reg_set(XGIPART2,
+                                                             0x36,
+                                                             0x15);
+                                               xgifb_reg_set(XGIPART2,
+                                                             0x37,
+                                                             0x25);
+                                               xgifb_reg_set(XGIPART2,
+                                                             0x38,
+                                                             0xF6);
+                                               break;
+                                       }
+                               }
+
+                       } else if (xgi_video_info.TV_type == TVMODE_PAL) {
+
+                               xgifb_reg_and(XGIPART2, 0x3A, 0x1F);
+
+                               if (xgi_video_info.TV_plug == TVPLUG_SVIDEO) {
+
+                                       xgifb_reg_and(XGIPART2, 0x30, 0xDF);
+
+                               } else if (xgi_video_info.TV_plug
+                                               == TVPLUG_COMPOSITE) {
+
+                                       xgifb_reg_or(XGIPART2, 0x30, 0x20);
+
+                                       switch (xgi_video_info.video_width) {
+                                       case 640:
+                                               xgifb_reg_set(XGIPART2,
+                                                             0x35,
+                                                             0xF1);
+                                               xgifb_reg_set(XGIPART2,
+                                                             0x36,
+                                                             0xF7);
+                                               xgifb_reg_set(XGIPART2,
+                                                             0x37,
+                                                             0x1F);
+                                               xgifb_reg_set(XGIPART2,
+                                                             0x38,
+                                                             0x32);
+                                               break;
+                                       case 720:
+                                               xgifb_reg_set(XGIPART2,
+                                                             0x35,
+                                                             0xF3);
+                                               xgifb_reg_set(XGIPART2,
+                                                             0x36,
+                                                             0x00);
+                                               xgifb_reg_set(XGIPART2,
+                                                             0x37,
+                                                             0x1D);
+                                               xgifb_reg_set(XGIPART2,
+                                                             0x38,
+                                                             0x20);
+                                               break;
+                                       case 800:
+                                               xgifb_reg_set(XGIPART2,
+                                                             0x35,
+                                                             0xFC);
+                                               xgifb_reg_set(XGIPART2,
+                                                             0x36,
+                                                             0xFB);
+                                               xgifb_reg_set(XGIPART2,
+                                                             0x37,
+                                                             0x14);
+                                               xgifb_reg_set(XGIPART2,
+                                                             0x38,
+                                                             0x2A);
+                                               break;
+                                       }
+                               }
+                       }
+
+                       if ((filter >= 0) && (filter <= 7)) {
+                               DPRINTK("FilterTable[%d]-%d: %02x %02x %02x %02x\n",
+                                       filter_tb, filter,
+                                       XGI_TV_filter[filter_tb].
+                                               filter[filter][0],
+                                       XGI_TV_filter[filter_tb].
+                                               filter[filter][1],
+                                       XGI_TV_filter[filter_tb].
+                                               filter[filter][2],
+                                       XGI_TV_filter[filter_tb].
+                                               filter[filter][3]
+                               );
+                               xgifb_reg_set(
+                                       XGIPART2,
+                                       0x35,
+                                       (XGI_TV_filter[filter_tb].
+                                               filter[filter][0]));
+                               xgifb_reg_set(
+                                       XGIPART2,
+                                       0x36,
+                                       (XGI_TV_filter[filter_tb].
+                                               filter[filter][1]));
+                               xgifb_reg_set(
+                                       XGIPART2,
+                                       0x37,
+                                       (XGI_TV_filter[filter_tb].
+                                               filter[filter][2]));
+                               xgifb_reg_set(
+                                       XGIPART2,
+                                       0x38,
+                                       (XGI_TV_filter[filter_tb].
+                                               filter[filter][3]));
+                       }
+               }
+       }
+}
+
 static int XGIfb_do_set_var(struct fb_var_screeninfo *var, int isactive,
                struct fb_info *info)
 {
@@ -1039,7 +1249,10 @@ static int XGIfb_do_set_var(struct fb_var_screeninfo *var, int isactive,
        }
 
        printk(KERN_DEBUG "XGIfb: Change mode to %dx%dx%d-%dHz\n",
-                       var->xres, var->yres, var->bits_per_pixel, xgi_video_info.refresh_rate);
+              var->xres,
+              var->yres,
+              var->bits_per_pixel,
+              xgi_video_info.refresh_rate);
 
        old_mode = xgifb_mode_idx;
        xgifb_mode_idx = 0;
@@ -1064,8 +1277,8 @@ static int XGIfb_do_set_var(struct fb_var_screeninfo *var, int isactive,
                xgifb_mode_idx = -1;
 
        if (xgifb_mode_idx < 0) {
-               printk(KERN_ERR "XGIfb: Mode %dx%dx%d not supported\n", var->xres,
-                               var->yres, var->bits_per_pixel);
+               printk(KERN_ERR "XGIfb: Mode %dx%dx%d not supported\n",
+                      var->xres, var->yres, var->bits_per_pixel);
                xgifb_mode_idx = old_mode;
                return -EINVAL;
        }
@@ -1079,16 +1292,19 @@ static int XGIfb_do_set_var(struct fb_var_screeninfo *var, int isactive,
 
                XGIfb_pre_setmode();
                if (XGISetModeNew(&XGIhw_ext, XGIfb_mode_no) == 0) {
-                       printk(KERN_ERR "XGIfb: Setting mode[0x%x] failed\n", XGIfb_mode_no);
+                       printk(KERN_ERR "XGIfb: Setting mode[0x%x] failed\n",
+                              XGIfb_mode_no);
                        return -EINVAL;
                }
                info->fix.line_length = ((info->var.xres_virtual
                                * info->var.bits_per_pixel) >> 6);
 
-               outXGIIDXREG(XGISR, IND_XGI_PASSWORD, XGI_PASSWORD);
+               xgifb_reg_set(XGISR, IND_XGI_PASSWORD, XGI_PASSWORD);
 
-               outXGIIDXREG(XGICR, 0x13, (info->fix.line_length & 0x00ff));
-               outXGIIDXREG(XGISR, 0x0E, (info->fix.line_length & 0xff00) >> 8);
+               xgifb_reg_set(XGICR, 0x13, (info->fix.line_length & 0x00ff));
+               xgifb_reg_set(XGISR,
+                             0x0E,
+                             (info->fix.line_length & 0xff00) >> 8);
 
                XGIfb_post_setmode();
 
@@ -1112,16 +1328,16 @@ static int XGIfb_do_set_var(struct fb_var_screeninfo *var, int isactive,
                        xgi_video_info.XGI310_AccelDepth = 0x00000000;
                        xgi_video_info.video_cmap_len = 256;
 #if defined(__powerpc__)
-                       inXGIIDXREG(XGICR, 0x4D, cr_data);
-                       outXGIIDXREG(XGICR, 0x4D, (cr_data & 0xE0));
+                       cr_data = xgifb_reg_get(XGICR, 0x4D);
+                       xgifb_reg_set(XGICR, 0x4D, (cr_data & 0xE0));
 #endif
                        break;
                case 16:
                        xgi_video_info.DstColor = 0x8000;
                        xgi_video_info.XGI310_AccelDepth = 0x00010000;
 #if defined(__powerpc__)
-                       inXGIIDXREG(XGICR, 0x4D, cr_data);
-                       outXGIIDXREG(XGICR, 0x4D, ((cr_data & 0xE0) | 0x0B));
+                       cr_data = xgifb_reg_get(XGICR, 0x4D);
+                       xgifb_reg_set(XGICR, 0x4D, ((cr_data & 0xE0) | 0x0B));
 #endif
                        xgi_video_info.video_cmap_len = 16;
                        break;
@@ -1130,13 +1346,14 @@ static int XGIfb_do_set_var(struct fb_var_screeninfo *var, int isactive,
                        xgi_video_info.XGI310_AccelDepth = 0x00020000;
                        xgi_video_info.video_cmap_len = 16;
 #if defined(__powerpc__)
-                       inXGIIDXREG(XGICR, 0x4D, cr_data);
-                       outXGIIDXREG(XGICR, 0x4D, ((cr_data & 0xE0) | 0x15));
+                       cr_data = xgifb_reg_get(XGICR, 0x4D);
+                       xgifb_reg_set(XGICR, 0x4D, ((cr_data & 0xE0) | 0x15));
 #endif
                        break;
                default:
                        xgi_video_info.video_cmap_len = 16;
-                       printk(KERN_ERR "XGIfb: Unsupported depth %d", xgi_video_info.video_bpp);
+                       printk(KERN_ERR "XGIfb: Unsupported depth %d",
+                              xgi_video_info.video_bpp);
                        break;
                }
        }
@@ -1179,20 +1396,23 @@ static int XGIfb_pan_var(struct fb_var_screeninfo *var)
                break;
        }
 
-       outXGIIDXREG(XGISR, IND_XGI_PASSWORD, XGI_PASSWORD);
+       xgifb_reg_set(XGISR, IND_XGI_PASSWORD, XGI_PASSWORD);
 
-       outXGIIDXREG(XGICR, 0x0D, base & 0xFF);
-       outXGIIDXREG(XGICR, 0x0C, (base >> 8) & 0xFF);
-       outXGIIDXREG(XGISR, 0x0D, (base >> 16) & 0xFF);
-       outXGIIDXREG(XGISR, 0x37, (base >> 24) & 0x03);
-       setXGIIDXREG(XGISR, 0x37, 0xDF, (base >> 21) & 0x04);
+       xgifb_reg_set(XGICR, 0x0D, base & 0xFF);
+       xgifb_reg_set(XGICR, 0x0C, (base >> 8) & 0xFF);
+       xgifb_reg_set(XGISR, 0x0D, (base >> 16) & 0xFF);
+       xgifb_reg_set(XGISR, 0x37, (base >> 24) & 0x03);
+       xgifb_reg_and_or(XGISR, 0x37, 0xDF, (base >> 21) & 0x04);
 
        if (xgi_video_info.disp_state & DISPTYPE_DISP2) {
-               orXGIIDXREG(XGIPART1, XGIfb_CRT2_write_enable, 0x01);
-               outXGIIDXREG(XGIPART1, 0x06, (base & 0xFF));
-               outXGIIDXREG(XGIPART1, 0x05, ((base >> 8) & 0xFF));
-               outXGIIDXREG(XGIPART1, 0x04, ((base >> 16) & 0xFF));
-               setXGIIDXREG(XGIPART1, 0x02, 0x7F, ((base >> 24) & 0x01) << 7);
+               xgifb_reg_or(XGIPART1, XGIfb_CRT2_write_enable, 0x01);
+               xgifb_reg_set(XGIPART1, 0x06, (base & 0xFF));
+               xgifb_reg_set(XGIPART1, 0x05, ((base >> 8) & 0xFF));
+               xgifb_reg_set(XGIPART1, 0x04, ((base >> 16) & 0xFF));
+               xgifb_reg_and_or(XGIPART1,
+                                0x02,
+                                0x7F,
+                                ((base >> 24) & 0x01) << 7);
        }
        /* printk("End of pan_var"); */
        return 0;
@@ -1235,15 +1455,15 @@ static int XGIfb_setcolreg(unsigned regno, unsigned red, unsigned green,
 
        switch (info->var.bits_per_pixel) {
        case 8:
-               outXGIREG(XGIDACA, regno);
-               outXGIREG(XGIDACD, (red >> 10));
-               outXGIREG(XGIDACD, (green >> 10));
-               outXGIREG(XGIDACD, (blue >> 10));
+               outb(regno, XGIDACA);
+               outb((red >> 10), XGIDACD);
+               outb((green >> 10), XGIDACD);
+               outb((blue >> 10), XGIDACD);
                if (xgi_video_info.disp_state & DISPTYPE_DISP2) {
-                       outXGIREG(XGIDAC2A, regno);
-                       outXGIREG(XGIDAC2D, (red >> 8));
-                       outXGIREG(XGIDAC2D, (green >> 8));
-                       outXGIREG(XGIDAC2D, (blue >> 8));
+                       outb(regno, XGIDAC2A);
+                       outb((red >> 8), XGIDAC2D);
+                       outb((green >> 8), XGIDAC2D);
+                       outb((blue >> 8), XGIDAC2D);
                }
                break;
        case 16:
@@ -1262,6 +1482,41 @@ static int XGIfb_setcolreg(unsigned regno, unsigned red, unsigned green,
        return 0;
 }
 
+/* ----------- FBDev related routines for all series ---------- */
+
+static int XGIfb_get_fix(struct fb_fix_screeninfo *fix, int con,
+               struct fb_info *info)
+{
+       DEBUGPRN("inside get_fix");
+       memset(fix, 0, sizeof(struct fb_fix_screeninfo));
+
+       strcpy(fix->id, myid);
+
+       fix->smem_start = xgi_video_info.video_base;
+
+       fix->smem_len = xgi_video_info.video_size;
+
+       fix->type = video_type;
+       fix->type_aux = 0;
+       if (xgi_video_info.video_bpp == 8)
+               fix->visual = FB_VISUAL_PSEUDOCOLOR;
+       else
+               fix->visual = FB_VISUAL_DIRECTCOLOR;
+       fix->xpanstep = 0;
+#ifdef XGIFB_PAN
+       if (XGIfb_ypan)
+               fix->ypanstep = 1;
+#endif
+       fix->ywrapstep = 0;
+       fix->line_length = xgi_video_info.video_linelength;
+       fix->mmio_start = xgi_video_info.mmio_base;
+       fix->mmio_len = xgi_video_info.mmio_size;
+       fix->accel = FB_ACCEL_XGI_XABRE;
+
+       DEBUGPRN("end of get_fix");
+       return 0;
+}
+
 static int XGIfb_set_par(struct fb_info *info)
 {
        int err;
@@ -1307,7 +1562,8 @@ static int XGIfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
        if (var->pixclock && htotal && vtotal) {
                drate = 1000000000 / var->pixclock;
                hrate = (drate * 1000) / htotal;
-               xgi_video_info.refresh_rate = (unsigned int) (hrate * 2 / vtotal);
+               xgi_video_info.refresh_rate =
+                       (unsigned int) (hrate * 2 / vtotal);
                printk(KERN_DEBUG
                        "%s: pixclock = %d ,htotal=%d, vtotal=%d\n"
                        "%s: drate=%d, hrate=%d, refresh_rate=%d\n",
@@ -1350,10 +1606,10 @@ static int XGIfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
                        var->xres, var->yres, var->bits_per_pixel);
                search_idx = 0;
                while (XGIbios_mode[search_idx].mode_no != 0) {
-
                        if ((var->xres <= XGIbios_mode[search_idx].xres) &&
-                               (var->yres <= XGIbios_mode[search_idx].yres) &&
-                               (var->bits_per_pixel == XGIbios_mode[search_idx].bpp)) {
+                           (var->yres <= XGIbios_mode[search_idx].yres) &&
+                           (var->bits_per_pixel ==
+                            XGIbios_mode[search_idx].bpp)) {
                                if (XGIfb_validate_mode(search_idx) > 0) {
                                        found_mode = 1;
                                        break;
@@ -1393,7 +1649,8 @@ static int XGIfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
        } /* else { */
                /* TW: Now patch yres_virtual if we use panning */
                /* May I do this? */
-               /* var->yres_virtual = xgi_video_info.heapstart / (var->xres * (var->bits_per_pixel >> 3)); */
+               /* var->yres_virtual = xgi_video_info.heapstart /
+                       (var->xres * (var->bits_per_pixel >> 3)); */
                /* if (var->yres_virtual <= var->yres) { */
                /* TW: Paranoia check */
                /* var->yres_virtual = var->yres; */
@@ -1460,51 +1717,16 @@ static int XGIfb_blank(int blank, struct fb_info *info)
 {
        u8 reg;
 
-       inXGIIDXREG(XGICR, 0x17, reg);
+       reg = xgifb_reg_get(XGICR, 0x17);
 
        if (blank > 0)
                reg &= 0x7f;
        else
                reg |= 0x80;
 
-       outXGIIDXREG(XGICR, 0x17, reg);
-       outXGIIDXREG(XGISR, 0x00, 0x01); /* Synchronous Reset */
-       outXGIIDXREG(XGISR, 0x00, 0x03); /* End Reset */
-       return 0;
-}
-
-/* ----------- FBDev related routines for all series ---------- */
-
-static int XGIfb_get_fix(struct fb_fix_screeninfo *fix, int con,
-               struct fb_info *info)
-{
-       DEBUGPRN("inside get_fix");
-       memset(fix, 0, sizeof(struct fb_fix_screeninfo));
-
-       strcpy(fix->id, myid);
-
-       fix->smem_start = xgi_video_info.video_base;
-
-       fix->smem_len = xgi_video_info.video_size;
-
-       fix->type = video_type;
-       fix->type_aux = 0;
-       if (xgi_video_info.video_bpp == 8)
-               fix->visual = FB_VISUAL_PSEUDOCOLOR;
-       else
-               fix->visual = FB_VISUAL_DIRECTCOLOR;
-       fix->xpanstep = 0;
-#ifdef XGIFB_PAN
-       if (XGIfb_ypan)
-               fix->ypanstep = 1;
-#endif
-       fix->ywrapstep = 0;
-       fix->line_length = xgi_video_info.video_linelength;
-       fix->mmio_start = xgi_video_info.mmio_base;
-       fix->mmio_len = xgi_video_info.mmio_size;
-       fix->accel = FB_ACCEL_XGI_XABRE;
-
-       DEBUGPRN("end of get_fix");
+       xgifb_reg_set(XGICR, 0x17, reg);
+       xgifb_reg_set(XGISR, 0x00, 0x01); /* Synchronous Reset */
+       xgifb_reg_set(XGISR, 0x00, 0x03); /* End Reset */
        return 0;
 }
 
@@ -1537,9 +1759,9 @@ static int XGIfb_get_dram_size(void)
 
        /* xorg driver sets 32MB * 1 channel */
        if (xgi_video_info.chip == XG27)
-               outXGIIDXREG(XGISR, IND_XGI_DRAM_SIZE, 0x51);
+               xgifb_reg_set(XGISR, IND_XGI_DRAM_SIZE, 0x51);
 
-       inXGIIDXREG(XGISR, IND_XGI_DRAM_SIZE, reg);
+       reg = xgifb_reg_get(XGISR, IND_XGI_DRAM_SIZE);
        switch ((reg & XGI_DRAM_SIZE_MASK) >> 4) {
        case XGI_DRAM_SIZE_1MB:
                xgi_video_info.video_size = 0x100000;
@@ -1614,8 +1836,9 @@ static int XGIfb_get_dram_size(void)
        /* xgi_video_info.video_size = 0x200000; */ /* 1024x768x16 */
        /* xgi_video_info.video_size = 0x1000000; */ /* benchmark */
 
-       printk("XGIfb: SR14=%x DramSzie %x ChannelNum %x\n", reg,
-                       xgi_video_info.video_size, ChannelNum);
+       printk("XGIfb: SR14=%x DramSzie %x ChannelNum %x\n",
+              reg,
+              xgi_video_info.video_size, ChannelNum);
        return 0;
 
 }
@@ -1636,7 +1859,7 @@ static void XGIfb_detect_VB(void)
                break;
        }
 
-       inXGIIDXREG(XGICR, IND_XGI_SCRATCH_REG_CR32, cr32);
+       cr32 = xgifb_reg_get(XGICR, IND_XGI_SCRATCH_REG_CR32);
 
        if ((cr32 & XGI_CRT1) && !XGIfb_crt1off)
                XGIfb_crt1off = 0;
@@ -1673,7 +1896,7 @@ static void XGIfb_detect_VB(void)
                xgi_video_info.TV_plug = TVPLUG_SCART;
 
        if (xgi_video_info.TV_type == 0) {
-               inXGIIDXREG(XGICR, 0x38, temp);
+               temp = xgifb_reg_get(XGICR, 0x38);
                if (temp & 0x10)
                        xgi_video_info.TV_type = TVMODE_PAL;
                else
@@ -1689,30 +1912,11 @@ static void XGIfb_detect_VB(void)
        }
 }
 
-static void XGIfb_get_VB_type(void)
-{
-       u8 reg;
-
-       if (!XGIfb_has_VB()) {
-               inXGIIDXREG(XGICR, IND_XGI_SCRATCH_REG_CR37, reg);
-               switch ((reg & XGI_EXTERNAL_CHIP_MASK) >> 1) {
-               case XGI310_EXTERNAL_CHIP_LVDS:
-                       xgi_video_info.hasVB = HASVB_LVDS;
-                       break;
-               case XGI310_EXTERNAL_CHIP_LVDS_CHRONTEL:
-                       xgi_video_info.hasVB = HASVB_LVDS_CHRONTEL;
-                       break;
-               default:
-                       break;
-               }
-       }
-}
-
 static int XGIfb_has_VB(void)
 {
        u8 vb_chipid;
 
-       inXGIIDXREG(XGIPART4, 0x00, vb_chipid);
+       vb_chipid = xgifb_reg_get(XGIPART4, 0x00);
        switch (vb_chipid) {
        case 0x01:
                xgi_video_info.hasVB = HASVB_301;
@@ -1727,344 +1931,23 @@ static int XGIfb_has_VB(void)
        return 1;
 }
 
-/* ------------------ Sensing routines ------------------ */
-
-/* TW: Determine and detect attached devices on XGI30x */
-int XGIDoSense(int tempbl, int tempbh, int tempcl, int tempch)
-{
-       int temp, i;
-
-       outXGIIDXREG(XGIPART4, 0x11, tempbl);
-       temp = tempbh | tempcl;
-       setXGIIDXREG(XGIPART4, 0x10, 0xe0, temp);
-       for (i = 0; i < 10; i++)
-               XGI_LongWait(&XGI_Pr);
-       tempch &= 0x7f;
-       inXGIIDXREG(XGIPART4, 0x03, temp);
-       temp ^= 0x0e;
-       temp &= tempch;
-       return temp;
-}
-
-void XGI_Sense30x(void)
-{
-       u8 backupP4_0d;
-       u8 testsvhs_tempbl, testsvhs_tempbh;
-       u8 testsvhs_tempcl, testsvhs_tempch;
-       u8 testcvbs_tempbl, testcvbs_tempbh;
-       u8 testcvbs_tempcl, testcvbs_tempch;
-       u8 testvga2_tempbl, testvga2_tempbh;
-       u8 testvga2_tempcl, testvga2_tempch;
-       int myflag, result;
-
-       inXGIIDXREG(XGIPART4, 0x0d, backupP4_0d);
-       outXGIIDXREG(XGIPART4, 0x0d, (backupP4_0d | 0x04));
-
-       testvga2_tempbh = 0x00;
-       testvga2_tempbl = 0xd1;
-       testsvhs_tempbh = 0x00;
-       testsvhs_tempbl = 0xb9;
-       testcvbs_tempbh = 0x00;
-       testcvbs_tempbl = 0xb3;
-       if ((XGIhw_ext.ujVBChipID != VB_CHIP_301) && (XGIhw_ext.ujVBChipID
-                       != VB_CHIP_302)) {
-               testvga2_tempbh = 0x01;
-               testvga2_tempbl = 0x90;
-               testsvhs_tempbh = 0x01;
-               testsvhs_tempbl = 0x6b;
-               testcvbs_tempbh = 0x01;
-               testcvbs_tempbl = 0x74;
-               if (XGIhw_ext.ujVBChipID == VB_CHIP_301LV
-                               || XGIhw_ext.ujVBChipID == VB_CHIP_302LV) {
-                       testvga2_tempbh = 0x00;
-                       testvga2_tempbl = 0x00;
-                       testsvhs_tempbh = 0x02;
-                       testsvhs_tempbl = 0x00;
-                       testcvbs_tempbh = 0x01;
-                       testcvbs_tempbl = 0x00;
-               }
-       }
-       if (XGIhw_ext.ujVBChipID != VB_CHIP_301LV && XGIhw_ext.ujVBChipID
-                       != VB_CHIP_302LV) {
-               inXGIIDXREG(XGIPART4, 0x01, myflag);
-               if (myflag & 0x04) {
-                       testvga2_tempbh = 0x00;
-                       testvga2_tempbl = 0xfd;
-                       testsvhs_tempbh = 0x00;
-                       testsvhs_tempbl = 0xdd;
-                       testcvbs_tempbh = 0x00;
-                       testcvbs_tempbl = 0xee;
-               }
-       }
-       if ((XGIhw_ext.ujVBChipID == VB_CHIP_301LV) || (XGIhw_ext.ujVBChipID
-                       == VB_CHIP_302LV)) {
-               testvga2_tempbh = 0x00;
-               testvga2_tempbl = 0x00;
-               testvga2_tempch = 0x00;
-               testvga2_tempcl = 0x00;
-               testsvhs_tempch = 0x04;
-               testsvhs_tempcl = 0x08;
-               testcvbs_tempch = 0x08;
-               testcvbs_tempcl = 0x08;
-       } else {
-               testvga2_tempch = 0x0e;
-               testvga2_tempcl = 0x08;
-               testsvhs_tempch = 0x06;
-               testsvhs_tempcl = 0x04;
-               testcvbs_tempch = 0x08;
-               testcvbs_tempcl = 0x04;
-       }
-
-       if (testvga2_tempch || testvga2_tempcl || testvga2_tempbh
-                       || testvga2_tempbl) {
-               result = XGIDoSense(testvga2_tempbl, testvga2_tempbh,
-                               testvga2_tempcl, testvga2_tempch);
-               if (result) {
-                       printk(KERN_INFO "XGIfb: Detected secondary VGA connection\n");
-                       orXGIIDXREG(XGICR, 0x32, 0x10);
-               }
-       }
-
-       result = XGIDoSense(testsvhs_tempbl, testsvhs_tempbh, testsvhs_tempcl,
-                       testsvhs_tempch);
-       if (result) {
-               printk(KERN_INFO "XGIfb: Detected TV connected to SVHS output\n");
-               /* TW: So we can be sure that there IS a SVHS output */
-               xgi_video_info.TV_plug = TVPLUG_SVIDEO;
-               orXGIIDXREG(XGICR, 0x32, 0x02);
-       }
-
-       if (!result) {
-               result = XGIDoSense(testcvbs_tempbl, testcvbs_tempbh,
-                               testcvbs_tempcl, testcvbs_tempch);
-               if (result) {
-                       printk(KERN_INFO "XGIfb: Detected TV connected to CVBS output\n");
-                       /* TW: So we can be sure that there IS a CVBS output */
-                       xgi_video_info.TV_plug = TVPLUG_COMPOSITE;
-                       orXGIIDXREG(XGICR, 0x32, 0x01);
-               }
-       }
-       XGIDoSense(0, 0, 0, 0);
-
-       outXGIIDXREG(XGIPART4, 0x0d, backupP4_0d);
-}
-
-/* --------------------- SetMode routines ------------------------- */
-
-static void XGIfb_pre_setmode(void)
-{
-       u8 cr30 = 0, cr31 = 0;
-
-       inXGIIDXREG(XGICR, 0x31, cr31);
-       cr31 &= ~0x60;
-
-       switch (xgi_video_info.disp_state & DISPTYPE_DISP2) {
-       case DISPTYPE_CRT2:
-               cr30 = (XGI_VB_OUTPUT_CRT2 | XGI_SIMULTANEOUS_VIEW_ENABLE);
-               cr31 |= XGI_DRIVER_MODE;
-               break;
-       case DISPTYPE_LCD:
-               cr30 = (XGI_VB_OUTPUT_LCD | XGI_SIMULTANEOUS_VIEW_ENABLE);
-               cr31 |= XGI_DRIVER_MODE;
-               break;
-       case DISPTYPE_TV:
-               if (xgi_video_info.TV_type == TVMODE_HIVISION)
-                       cr30 = (XGI_VB_OUTPUT_HIVISION
-                                       | XGI_SIMULTANEOUS_VIEW_ENABLE);
-               else if (xgi_video_info.TV_plug == TVPLUG_SVIDEO)
-                       cr30 = (XGI_VB_OUTPUT_SVIDEO
-                                       | XGI_SIMULTANEOUS_VIEW_ENABLE);
-               else if (xgi_video_info.TV_plug == TVPLUG_COMPOSITE)
-                       cr30 = (XGI_VB_OUTPUT_COMPOSITE
-                                       | XGI_SIMULTANEOUS_VIEW_ENABLE);
-               else if (xgi_video_info.TV_plug == TVPLUG_SCART)
-                       cr30 = (XGI_VB_OUTPUT_SCART
-                                       | XGI_SIMULTANEOUS_VIEW_ENABLE);
-               cr31 |= XGI_DRIVER_MODE;
-
-               if (XGIfb_tvmode == 1 || xgi_video_info.TV_type == TVMODE_PAL)
-                       cr31 |= 0x01;
-               else
-                       cr31 &= ~0x01;
-               break;
-       default: /* disable CRT2 */
-               cr30 = 0x00;
-               cr31 |= (XGI_DRIVER_MODE | XGI_VB_OUTPUT_DISABLE);
-       }
-
-       outXGIIDXREG(XGICR, IND_XGI_SCRATCH_REG_CR30, cr30);
-       outXGIIDXREG(XGICR, IND_XGI_SCRATCH_REG_CR31, cr31);
-       outXGIIDXREG(XGICR, IND_XGI_SCRATCH_REG_CR33, (XGIfb_rate_idx & 0x0F));
-}
-
-static void XGIfb_post_setmode(void)
+static void XGIfb_get_VB_type(void)
 {
        u8 reg;
-       unsigned char doit = 1;
-       /*
-       outXGIIDXREG(XGISR,IND_XGI_PASSWORD,XGI_PASSWORD);
-       outXGIIDXREG(XGICR, 0x13, 0x00);
-       setXGIIDXREG(XGISR,0x0E, 0xF0, 0x01);
-       *test*
-       */
-       if (xgi_video_info.video_bpp == 8) {
-               /* TW: We can't switch off CRT1 on LVDS/Chrontel in 8bpp Modes */
-               if ((xgi_video_info.hasVB == HASVB_LVDS)
-                               || (xgi_video_info.hasVB == HASVB_LVDS_CHRONTEL)) {
-                       doit = 0;
-               }
-               /* TW: We can't switch off CRT1 on 301B-DH in 8bpp Modes if using LCD */
-               if (xgi_video_info.disp_state & DISPTYPE_LCD)
-                       doit = 0;
-       }
-
-       /* TW: We can't switch off CRT1 if bridge is in slave mode */
-       if (xgi_video_info.hasVB != HASVB_NONE) {
-               inXGIIDXREG(XGIPART1, 0x00, reg);
-
-               if ((reg & 0x50) == 0x10)
-                       doit = 0;
-
-       } else {
-               XGIfb_crt1off = 0;
-       }
-
-       inXGIIDXREG(XGICR, 0x17, reg);
-       if ((XGIfb_crt1off) && (doit))
-               reg &= ~0x80;
-       else
-               reg |= 0x80;
-       outXGIIDXREG(XGICR, 0x17, reg);
-
-       andXGIIDXREG(XGISR, IND_XGI_RAMDAC_CONTROL, ~0x04);
-
-       if ((xgi_video_info.disp_state & DISPTYPE_TV) && (xgi_video_info.hasVB
-                       == HASVB_301)) {
-
-               inXGIIDXREG(XGIPART4, 0x01, reg);
-
-               if (reg < 0xB0) { /* Set filter for XGI301 */
-
-                       switch (xgi_video_info.video_width) {
-                       case 320:
-                               filter_tb = (xgi_video_info.TV_type == TVMODE_NTSC) ? 4 : 12;
-                               break;
-                       case 640:
-                               filter_tb = (xgi_video_info.TV_type == TVMODE_NTSC) ? 5 : 13;
-                               break;
-                       case 720:
-                               filter_tb = (xgi_video_info.TV_type == TVMODE_NTSC) ? 6 : 14;
-                               break;
-                       case 800:
-                               filter_tb = (xgi_video_info.TV_type == TVMODE_NTSC) ? 7 : 15;
-                               break;
-                       default:
-                               filter = -1;
-                               break;
-                       }
-
-                       orXGIIDXREG(XGIPART1, XGIfb_CRT2_write_enable, 0x01);
-
-                       if (xgi_video_info.TV_type == TVMODE_NTSC) {
-
-                               andXGIIDXREG(XGIPART2, 0x3a, 0x1f);
-
-                               if (xgi_video_info.TV_plug == TVPLUG_SVIDEO) {
-
-                                       andXGIIDXREG(XGIPART2, 0x30, 0xdf);
-
-                               } else if (xgi_video_info.TV_plug
-                                               == TVPLUG_COMPOSITE) {
-
-                                       orXGIIDXREG(XGIPART2, 0x30, 0x20);
-
-                                       switch (xgi_video_info.video_width) {
-                                       case 640:
-                                               outXGIIDXREG(XGIPART2, 0x35, 0xEB);
-                                               outXGIIDXREG(XGIPART2, 0x36, 0x04);
-                                               outXGIIDXREG(XGIPART2, 0x37, 0x25);
-                                               outXGIIDXREG(XGIPART2, 0x38, 0x18);
-                                               break;
-                                       case 720:
-                                               outXGIIDXREG(XGIPART2, 0x35, 0xEE);
-                                               outXGIIDXREG(XGIPART2, 0x36, 0x0C);
-                                               outXGIIDXREG(XGIPART2, 0x37, 0x22);
-                                               outXGIIDXREG(XGIPART2, 0x38, 0x08);
-                                               break;
-                                       case 800:
-                                               outXGIIDXREG(XGIPART2, 0x35, 0xEB);
-                                               outXGIIDXREG(XGIPART2, 0x36, 0x15);
-                                               outXGIIDXREG(XGIPART2, 0x37, 0x25);
-                                               outXGIIDXREG(XGIPART2, 0x38, 0xF6);
-                                               break;
-                                       }
-                               }
-
-                       } else if (xgi_video_info.TV_type == TVMODE_PAL) {
-
-                               andXGIIDXREG(XGIPART2, 0x3A, 0x1F);
-
-                               if (xgi_video_info.TV_plug == TVPLUG_SVIDEO) {
-
-                                       andXGIIDXREG(XGIPART2, 0x30, 0xDF);
-
-                               } else if (xgi_video_info.TV_plug
-                                               == TVPLUG_COMPOSITE) {
-
-                                       orXGIIDXREG(XGIPART2, 0x30, 0x20);
-
-                                       switch (xgi_video_info.video_width) {
-                                       case 640:
-                                               outXGIIDXREG(XGIPART2, 0x35, 0xF1);
-                                               outXGIIDXREG(XGIPART2, 0x36, 0xF7);
-                                               outXGIIDXREG(XGIPART2, 0x37, 0x1F);
-                                               outXGIIDXREG(XGIPART2, 0x38, 0x32);
-                                               break;
-                                       case 720:
-                                               outXGIIDXREG(XGIPART2, 0x35, 0xF3);
-                                               outXGIIDXREG(XGIPART2, 0x36, 0x00);
-                                               outXGIIDXREG(XGIPART2, 0x37, 0x1D);
-                                               outXGIIDXREG(XGIPART2, 0x38, 0x20);
-                                               break;
-                                       case 800:
-                                               outXGIIDXREG(XGIPART2, 0x35, 0xFC);
-                                               outXGIIDXREG(XGIPART2, 0x36, 0xFB);
-                                               outXGIIDXREG(XGIPART2, 0x37, 0x14);
-                                               outXGIIDXREG(XGIPART2, 0x38, 0x2A);
-                                               break;
-                                       }
-                               }
-                       }
-
-                       if ((filter >= 0) && (filter <= 7)) {
-                               DPRINTK("FilterTable[%d]-%d: %02x %02x %02x %02x\n", filter_tb, filter,
-                                               XGI_TV_filter[filter_tb].filter[filter][0],
-                                               XGI_TV_filter[filter_tb].filter[filter][1],
-                                               XGI_TV_filter[filter_tb].filter[filter][2],
-                                               XGI_TV_filter[filter_tb].filter[filter][3]
-                               );
-                               outXGIIDXREG(
-                                               XGIPART2,
-                                               0x35,
-                                               (XGI_TV_filter[filter_tb].filter[filter][0]));
-                               outXGIIDXREG(
-                                               XGIPART2,
-                                               0x36,
-                                               (XGI_TV_filter[filter_tb].filter[filter][1]));
-                               outXGIIDXREG(
-                                               XGIPART2,
-                                               0x37,
-                                               (XGI_TV_filter[filter_tb].filter[filter][2]));
-                               outXGIIDXREG(
-                                               XGIPART2,
-                                               0x38,
-                                               (XGI_TV_filter[filter_tb].filter[filter][3]));
-                       }
 
+       if (!XGIfb_has_VB()) {
+               reg = xgifb_reg_get(XGICR, IND_XGI_SCRATCH_REG_CR37);
+               switch ((reg & XGI_EXTERNAL_CHIP_MASK) >> 1) {
+               case XGI310_EXTERNAL_CHIP_LVDS:
+                       xgi_video_info.hasVB = HASVB_LVDS;
+                       break;
+               case XGI310_EXTERNAL_CHIP_LVDS_CHRONTEL:
+                       xgi_video_info.hasVB = HASVB_LVDS_CHRONTEL;
+                       break;
+               default:
+                       break;
                }
-
        }
-
 }
 
 XGIINITSTATIC int __init XGIfb_setup(char *options)
@@ -2086,15 +1969,19 @@ XGIINITSTATIC int __init XGIfb_setup(char *options)
                if (!strncmp(this_opt, "mode:", 5)) {
                        XGIfb_search_mode(this_opt + 5);
                } else if (!strncmp(this_opt, "vesa:", 5)) {
-                       XGIfb_search_vesamode(simple_strtoul(this_opt + 5, NULL, 0));
+                       XGIfb_search_vesamode(simple_strtoul(
+                                               this_opt + 5, NULL, 0));
                } else if (!strncmp(this_opt, "mode:", 5)) {
                        XGIfb_search_mode(this_opt + 5);
                } else if (!strncmp(this_opt, "vesa:", 5)) {
-                       XGIfb_search_vesamode(simple_strtoul(this_opt + 5, NULL, 0));
+                       XGIfb_search_vesamode(simple_strtoul(
+                                               this_opt + 5, NULL, 0));
                } else if (!strncmp(this_opt, "vrate:", 6)) {
-                       xgi_video_info.refresh_rate = simple_strtoul(this_opt + 6, NULL, 0);
+                       xgi_video_info.refresh_rate = simple_strtoul(
+                                               this_opt + 6, NULL, 0);
                } else if (!strncmp(this_opt, "rate:", 5)) {
-                       xgi_video_info.refresh_rate = simple_strtoul(this_opt + 5, NULL, 0);
+                       xgi_video_info.refresh_rate = simple_strtoul(
+                                               this_opt + 5, NULL, 0);
                } else if (!strncmp(this_opt, "off", 3)) {
                        XGIfb_off = 1;
                } else if (!strncmp(this_opt, "crt1off", 7)) {
@@ -2104,7 +1991,8 @@ XGIINITSTATIC int __init XGIfb_setup(char *options)
                } else if (!strncmp(this_opt, "forcecrt2type:", 14)) {
                        XGIfb_search_crt2type(this_opt + 14);
                } else if (!strncmp(this_opt, "forcecrt1:", 10)) {
-                       XGIfb_forcecrt1 = (int)simple_strtoul(this_opt + 10, NULL, 0);
+                       XGIfb_forcecrt1 = (int)simple_strtoul(
+                                               this_opt + 10, NULL, 0);
                } else if (!strncmp(this_opt, "tvmode:", 7)) {
                        XGIfb_search_tvstd(this_opt + 7);
                } else if (!strncmp(this_opt, "tvstandard:", 11)) {
@@ -2122,12 +2010,15 @@ XGIINITSTATIC int __init XGIfb_setup(char *options)
                } else if (!strncmp(this_opt, "noypan", 6)) {
                        XGIfb_ypan = 0;
                } else if (!strncmp(this_opt, "userom:", 7)) {
-                       XGIfb_userom = (int)simple_strtoul(this_opt + 7, NULL, 0);
+                       XGIfb_userom = (int)simple_strtoul(
+                                               this_opt + 7, NULL, 0);
                        /* } else if (!strncmp(this_opt, "useoem:", 7)) { */
-                       /* XGIfb_useoem = (int)simple_strtoul(this_opt + 7, NULL, 0); */
+                       /* XGIfb_useoem = (int)simple_strtoul(
+                                               this_opt + 7, NULL, 0); */
                } else {
                        XGIfb_search_mode(this_opt);
-                       /* printk(KERN_INFO "XGIfb: Invalid option %s\n", this_opt); */
+                       /* printk(KERN_INFO "XGIfb: Invalid option %s\n",
+                                 this_opt); */
                }
 
                /* TW: Panning only with acceleration */
@@ -2178,7 +2069,9 @@ static int __devinit xgifb_probe(struct pci_dev *pdev,
                return -ENOMEM;
 
        xgi_video_info.chip_id = pdev->device;
-       pci_read_config_byte(pdev, PCI_REVISION_ID, &xgi_video_info.revision_id);
+       pci_read_config_byte(pdev,
+                            PCI_REVISION_ID,
+                            &xgi_video_info.revision_id);
        XGIhw_ext.jChipRevision = xgi_video_info.revision_id;
 
        xgi_video_info.pcibus = pdev->bus->number;
@@ -2194,7 +2087,7 @@ static int __devinit xgifb_probe(struct pci_dev *pdev,
        XGIhw_ext.pjIOAddress = (unsigned char *)xgi_video_info.vga_base;
        /* XGI_Pr.RelIO  = ioremap(pci_resource_start(pdev, 2), 128) + 0x30; */
        printk("XGIfb: Relocate IO address: %lx [%08lx]\n",
-                       (unsigned long)pci_resource_start(pdev, 2), XGI_Pr.RelIO);
+              (unsigned long)pci_resource_start(pdev, 2), XGI_Pr.RelIO);
 
        if (pci_enable_device(pdev)) {
                ret = -EIO;
@@ -2203,8 +2096,8 @@ static int __devinit xgifb_probe(struct pci_dev *pdev,
 
        XGIRegInit(&XGI_Pr, (unsigned long)XGIhw_ext.pjIOAddress);
 
-       outXGIIDXREG(XGISR, IND_XGI_PASSWORD, XGI_PASSWORD);
-       inXGIIDXREG(XGISR, IND_XGI_PASSWORD, reg1);
+       xgifb_reg_set(XGISR, IND_XGI_PASSWORD, XGI_PASSWORD);
+       reg1 = xgifb_reg_get(XGISR, IND_XGI_PASSWORD);
 
        if (reg1 != 0xa1) { /*I/O error */
                printk("\nXGIfb: I/O error!!!");
@@ -2214,8 +2107,8 @@ static int __devinit xgifb_probe(struct pci_dev *pdev,
 
        switch (xgi_video_info.chip_id) {
        case PCI_DEVICE_ID_XG_20:
-               orXGIIDXREG(XGICR, Index_CR_GPIO_Reg3, GPIOG_EN);
-               inXGIIDXREG(XGICR, Index_CR_GPIO_Reg1, CR48);
+               xgifb_reg_or(XGICR, Index_CR_GPIO_Reg3, GPIOG_EN);
+               CR48 = xgifb_reg_get(XGICR, Index_CR_GPIO_Reg1);
                if (CR48&GPIOG_READ)
                        xgi_video_info.chip = XG21;
                else
@@ -2249,7 +2142,8 @@ static int __devinit xgifb_probe(struct pci_dev *pdev,
        if ((xgi_video_info.chip == XG21) || (XGIfb_userom)) {
                XGIhw_ext.pjVirtualRomBase = xgifb_copy_rom(pdev);
                if (XGIhw_ext.pjVirtualRomBase)
-                       printk(KERN_INFO "XGIfb: Video ROM found and mapped to %p\n", XGIhw_ext.pjVirtualRomBase);
+                       printk(KERN_INFO "XGIfb: Video ROM found and mapped to %p\n",
+                              XGIhw_ext.pjVirtualRomBase);
                else
                        printk(KERN_INFO "XGIfb: Video ROM not found\n");
        } else {
@@ -2264,17 +2158,23 @@ static int __devinit xgifb_probe(struct pci_dev *pdev,
                goto error;
        }
 
-       if ((xgifb_mode_idx < 0) || ((XGIbios_mode[xgifb_mode_idx].mode_no) != 0xFF)) {
+       if ((xgifb_mode_idx < 0) ||
+           ((XGIbios_mode[xgifb_mode_idx].mode_no) != 0xFF)) {
                /* Enable PCI_LINEAR_ADDRESSING and MMIO_ENABLE  */
-               orXGIIDXREG(XGISR, IND_XGI_PCI_ADDRESS_SET, (XGI_PCI_ADDR_ENABLE | XGI_MEM_MAP_IO_ENABLE));
+               xgifb_reg_or(XGISR,
+                            IND_XGI_PCI_ADDRESS_SET,
+                            (XGI_PCI_ADDR_ENABLE | XGI_MEM_MAP_IO_ENABLE));
                /* Enable 2D accelerator engine */
-               orXGIIDXREG(XGISR, IND_XGI_MODULE_ENABLE, XGI_ENABLE_2D);
+               xgifb_reg_or(XGISR, IND_XGI_MODULE_ENABLE, XGI_ENABLE_2D);
        }
 
        XGIhw_ext.ulVideoMemorySize = xgi_video_info.video_size;
 
-       if (!request_mem_region(xgi_video_info.video_base, xgi_video_info.video_size, "XGIfb FB")) {
-               printk("unable request memory size %x", xgi_video_info.video_size);
+       if (!request_mem_region(xgi_video_info.video_base,
+                               xgi_video_info.video_size,
+                               "XGIfb FB")) {
+               printk("unable request memory size %x",
+                      xgi_video_info.video_size);
                printk(KERN_ERR "XGIfb: Fatal error: Unable to reserve frame buffer memory\n");
                printk(KERN_ERR "XGIfb: Is there another framebuffer driver active?\n");
                ret = -ENODEV;
@@ -2295,7 +2195,9 @@ static int __devinit xgifb_probe(struct pci_dev *pdev,
                                            xgi_video_info.mmio_size);
 
        printk(KERN_INFO "XGIfb: Framebuffer at 0x%lx, mapped to 0x%p, size %dk\n",
-                       xgi_video_info.video_base, xgi_video_info.video_vbase, xgi_video_info.video_size / 1024);
+              xgi_video_info.video_base,
+              xgi_video_info.video_vbase,
+              xgi_video_info.video_size / 1024);
 
        printk(KERN_INFO "XGIfb: MMIO at 0x%lx, mapped to 0x%p, size %ldk\n",
               xgi_video_info.mmio_base, xgi_video_info.mmio_vbase,
@@ -2308,19 +2210,21 @@ static int __devinit xgifb_probe(struct pci_dev *pdev,
 
        xgi_video_info.mtrr = (unsigned int) 0;
 
-       if ((xgifb_mode_idx < 0) || ((XGIbios_mode[xgifb_mode_idx].mode_no) != 0xFF)) {
+       if ((xgifb_mode_idx < 0) ||
+           ((XGIbios_mode[xgifb_mode_idx].mode_no) != 0xFF)) {
                xgi_video_info.hasVB = HASVB_NONE;
-               if ((xgi_video_info.chip == XG20) || (xgi_video_info.chip == XG27)) {
+               if ((xgi_video_info.chip == XG20) ||
+                   (xgi_video_info.chip == XG27)) {
                        xgi_video_info.hasVB = HASVB_NONE;
                } else if (xgi_video_info.chip == XG21) {
-                       inXGIIDXREG(XGICR, 0x38, CR38);
+                       CR38 = xgifb_reg_get(XGICR, 0x38);
                        if ((CR38&0xE0) == 0xC0) {
                                xgi_video_info.disp_state = DISPTYPE_LCD;
                                if (!XGIfb_GetXG21LVDSData()) {
                                        int m;
                                        for (m = 0; m < sizeof(XGI21_LCDCapList)/sizeof(struct XGI21_LVDSCapStruct); m++) {
                                                if ((XGI21_LCDCapList[m].LVDSHDE == XGIbios_mode[xgifb_mode_idx].xres) &&
-                                                               (XGI21_LCDCapList[m].LVDSVDE == XGIbios_mode[xgifb_mode_idx].yres)) {
+                                                   (XGI21_LCDCapList[m].LVDSVDE == XGIbios_mode[xgifb_mode_idx].yres)) {
                                                        xgifb_reg_set(XGI_Pr.P3d4, 0x36, m);
                                                }
                                        }
@@ -2340,7 +2244,7 @@ static int __devinit xgifb_probe(struct pci_dev *pdev,
 
                switch (xgi_video_info.hasVB) {
                case HASVB_301:
-                       inXGIIDXREG(XGIPART4, 0x01, reg);
+                       reg = xgifb_reg_get(XGIPART4, 0x01);
                        if (reg >= 0xE0) {
                                XGIhw_ext.ujVBChipID = VB_CHIP_302LV;
                                printk(KERN_INFO "XGIfb: XGI302LV bridge detected (revision 0x%02x)\n", reg);
@@ -2350,7 +2254,7 @@ static int __devinit xgifb_probe(struct pci_dev *pdev,
                        }
                        /* else if (reg >= 0xB0) {
                                XGIhw_ext.ujVBChipID = VB_CHIP_301B;
-                               inXGIIDXREG(XGIPART4, 0x23, reg1);
+                               reg1 = xgifb_reg_get(XGIPART4, 0x23);
                                printk("XGIfb: XGI301B bridge detected\n");
                        } */
                        else {
@@ -2359,7 +2263,7 @@ static int __devinit xgifb_probe(struct pci_dev *pdev,
                        }
                        break;
                case HASVB_302:
-                       inXGIIDXREG(XGIPART4, 0x01, reg);
+                       reg = xgifb_reg_get(XGIPART4, 0x01);
                        if (reg >= 0xE0) {
                                XGIhw_ext.ujVBChipID = VB_CHIP_302LV;
                                printk(KERN_INFO "XGIfb: XGI302LV bridge detected (revision 0x%02x)\n", reg);
@@ -2367,7 +2271,7 @@ static int __devinit xgifb_probe(struct pci_dev *pdev,
                                XGIhw_ext.ujVBChipID = VB_CHIP_301LV;
                                printk(KERN_INFO "XGIfb: XGI302LV bridge detected (revision 0x%02x)\n", reg);
                        } else if (reg >= 0xB0) {
-                               inXGIIDXREG(XGIPART4, 0x23, reg1);
+                               reg1 = xgifb_reg_get(XGIPART4, 0x23);
 
                                XGIhw_ext.ujVBChipID = VB_CHIP_302B;
 
@@ -2404,14 +2308,16 @@ static int __devinit xgifb_probe(struct pci_dev *pdev,
                        if (XGIfb_crt1off)
                                xgi_video_info.disp_state |= DISPMODE_SINGLE;
                        else
-                               xgi_video_info.disp_state |= (DISPMODE_MIRROR | DISPTYPE_CRT1);
+                               xgi_video_info.disp_state |= (DISPMODE_MIRROR |
+                                                             DISPTYPE_CRT1);
                } else {
-                       xgi_video_info.disp_state = DISPMODE_SINGLE | DISPTYPE_CRT1;
+                       xgi_video_info.disp_state = DISPMODE_SINGLE |
+                                                   DISPTYPE_CRT1;
                }
 
                if (xgi_video_info.disp_state & DISPTYPE_LCD) {
                        if (!enable_dstn) {
-                               inXGIIDXREG(XGICR, IND_XGI_LCD_PANEL, reg);
+                               reg = xgifb_reg_get(XGICR, IND_XGI_LCD_PANEL);
                                reg &= 0x0f;
                                XGIhw_ext.ulCRT2LCDType = XGI310paneltype[reg];
 
@@ -2431,21 +2337,25 @@ static int __devinit xgifb_probe(struct pci_dev *pdev,
                                (XGIhw_ext.ujVBChipID == VB_CHIP_301LV) ||
                                (XGIhw_ext.ujVBChipID == VB_CHIP_302LV)) {
                        int tmp;
-                       inXGIIDXREG(XGICR, 0x34, tmp);
+                       tmp = xgifb_reg_get(XGICR, 0x34);
                        if (tmp <= 0x13) {
-                               /* Currently on LCDA? (Some BIOSes leave CR38) */
-                               inXGIIDXREG(XGICR, 0x38, tmp);
+                               /* Currently on LCDA?
+                                *(Some BIOSes leave CR38) */
+                               tmp = xgifb_reg_get(XGICR, 0x38);
                                if ((tmp & 0x03) == 0x03) {
                                        /* XGI_Pr.XGI_UseLCDA = 1; */
                                } else {
-                                       /* Currently on LCDA? (Some newer BIOSes set D0 in CR35) */
-                                       inXGIIDXREG(XGICR, 0x35, tmp);
+                                       /* Currently on LCDA?
+                                        *(Some newer BIOSes set D0 in CR35) */
+                                       tmp = xgifb_reg_get(XGICR, 0x35);
                                        if (tmp & 0x01) {
                                                /* XGI_Pr.XGI_UseLCDA = 1; */
                                        } else {
-                                               inXGIIDXREG(XGICR, 0x30, tmp);
+                                               tmp = xgifb_reg_get(XGICR,
+                                                                   0x30);
                                                if (tmp & 0x20) {
-                                                       inXGIIDXREG(XGIPART1, 0x13, tmp);
+                                                       tmp = xgifb_reg_get(
+                                                               XGIPART1, 0x13);
                                                        if (tmp & 0x04) {
                                                                /* XGI_Pr.XGI_UseLCDA = 1; */
                                                        }
@@ -2464,7 +2374,8 @@ static int __devinit xgifb_probe(struct pci_dev *pdev,
                        case DISPTYPE_LCD:
                                xgifb_mode_idx = DEFAULT_LCDMODE;
                                if (xgi_video_info.chip == XG21)
-                                       xgifb_mode_idx = XGIfb_GetXG21DefaultLVDSModeIdx();
+                                       xgifb_mode_idx =
+                                           XGIfb_GetXG21DefaultLVDSModeIdx();
                                break;
                        case DISPTYPE_TV:
                                xgifb_mode_idx = DEFAULT_TVMODE;
@@ -2477,18 +2388,26 @@ static int __devinit xgifb_probe(struct pci_dev *pdev,
 
                XGIfb_mode_no = XGIbios_mode[xgifb_mode_idx].mode_no;
 
+               /* yilin set default refresh rate */
                if (xgi_video_info.refresh_rate == 0)
-                       xgi_video_info.refresh_rate = 60; /* yilin set default refresh rate */
-               if (XGIfb_search_refresh_rate(xgi_video_info.refresh_rate) == 0) {
+                       xgi_video_info.refresh_rate = 60;
+               if (XGIfb_search_refresh_rate(
+                               xgi_video_info.refresh_rate) == 0) {
                        XGIfb_rate_idx = XGIbios_mode[xgifb_mode_idx].rate_idx;
                        xgi_video_info.refresh_rate = 60;
                }
 
                xgi_video_info.video_bpp = XGIbios_mode[xgifb_mode_idx].bpp;
-               xgi_video_info.video_vwidth = xgi_video_info.video_width = XGIbios_mode[xgifb_mode_idx].xres;
-               xgi_video_info.video_vheight = xgi_video_info.video_height = XGIbios_mode[xgifb_mode_idx].yres;
+               xgi_video_info.video_vwidth =
+                       xgi_video_info.video_width =
+                               XGIbios_mode[xgifb_mode_idx].xres;
+               xgi_video_info.video_vheight =
+                       xgi_video_info.video_height =
+                               XGIbios_mode[xgifb_mode_idx].yres;
                xgi_video_info.org_x = xgi_video_info.org_y = 0;
-               xgi_video_info.video_linelength = xgi_video_info.video_width * (xgi_video_info.video_bpp >> 3);
+               xgi_video_info.video_linelength =
+                       xgi_video_info.video_width *
+                       (xgi_video_info.video_bpp >> 3);
                switch (xgi_video_info.video_bpp) {
                case 8:
                        xgi_video_info.DstColor = 0x0000;
@@ -2507,16 +2426,23 @@ static int __devinit xgifb_probe(struct pci_dev *pdev,
                        break;
                default:
                        xgi_video_info.video_cmap_len = 16;
-                       printk(KERN_INFO "XGIfb: Unsupported depth %d", xgi_video_info.video_bpp);
+                       printk(KERN_INFO "XGIfb: Unsupported depth %d",
+                              xgi_video_info.video_bpp);
                        break;
                }
 
                printk(KERN_INFO "XGIfb: Default mode is %dx%dx%d (%dHz)\n",
-                               xgi_video_info.video_width, xgi_video_info.video_height, xgi_video_info.video_bpp,
-                               xgi_video_info.refresh_rate);
-
-               default_var.xres = default_var.xres_virtual = xgi_video_info.video_width;
-               default_var.yres = default_var.yres_virtual = xgi_video_info.video_height;
+                      xgi_video_info.video_width,
+                      xgi_video_info.video_height,
+                      xgi_video_info.video_bpp,
+                      xgi_video_info.refresh_rate);
+
+               default_var.xres =
+                       default_var.xres_virtual =
+                               xgi_video_info.video_width;
+               default_var.yres =
+                       default_var.yres_virtual =
+                               xgi_video_info.video_height;
                default_var.bits_per_pixel = xgi_video_info.video_bpp;
 
                XGIfb_bpp_to_var(&default_var);
@@ -2532,10 +2458,12 @@ static int __devinit xgifb_probe(struct pci_dev *pdev,
                        &default_var.hsync_len, &default_var.vsync_len,
                        &default_var.sync, &default_var.vmode)) {
 
-                       if ((default_var.vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED) {
+                       if ((default_var.vmode & FB_VMODE_MASK) ==
+                           FB_VMODE_INTERLACED) {
                                default_var.yres <<= 1;
                                default_var.yres_virtual <<= 1;
-                       } else if ((default_var.vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE) {
+                       } else if ((default_var.vmode & FB_VMODE_MASK) ==
+                                  FB_VMODE_DOUBLE) {
                                default_var.pixclock >>= 1;
                                default_var.yres >>= 1;
                                default_var.yres_virtual >>= 1;
@@ -2555,9 +2483,10 @@ static int __devinit xgifb_probe(struct pci_dev *pdev,
                fb_alloc_cmap(&fb_info->cmap, 256 , 0);
 
 #ifdef CONFIG_MTRR
-               xgi_video_info.mtrr = mtrr_add((unsigned int) xgi_video_info.video_base,
-                               (unsigned int) xgi_video_info.video_size,
-                               MTRR_TYPE_WRCOMB, 1);
+               xgi_video_info.mtrr = mtrr_add(
+                       (unsigned int) xgi_video_info.video_base,
+                       (unsigned int) xgi_video_info.video_size,
+                       MTRR_TYPE_WRCOMB, 1);
                if (xgi_video_info.mtrr)
                        printk(KERN_INFO "XGIfb: Added MTRRs\n");
 #endif
@@ -2570,7 +2499,7 @@ static int __devinit xgifb_probe(struct pci_dev *pdev,
                XGIfb_registered = 1;
 
                printk(KERN_INFO "fb%d: %s frame buffer device, Version %d.%d.%02d\n",
-                               fb_info->node, myid, VER_MAJOR, VER_MINOR, VER_LEVEL);
+                      fb_info->node, myid, VER_MAJOR, VER_MINOR, VER_LEVEL);
 
        }
 
index b43a7588e57d70a94686f98b4ff3f985c5cc3f94..45b6015d160c33ae2ad304f99aff98ce8f13e55a 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef _LINUX_XGIFB
 #define _LINUX_XGIFB
-#include <asm/ioctl.h>
-#include <asm/types.h>
+#include <linux/ioctl.h>
+#include <linux/types.h>
 
 #define DISPTYPE_CRT1       0x00000008L
 #define DISPTYPE_CRT2       0x00000004L
 #define DISPMODE_MIRROR            0x00000010L
 #define DISPMODE_DUALVIEW   0x00000040L
 
-#define HASVB_NONE             0x00
-#define HASVB_301              0x01
-#define HASVB_LVDS             0x02
-#define HASVB_TRUMPION         0x04
-#define HASVB_LVDS_CHRONTEL    0x10
-#define HASVB_302              0x20
-#define HASVB_303              0x40
-#define HASVB_CHRONTEL         0x80
+#define HASVB_NONE         0x00
+#define HASVB_301          0x01
+#define HASVB_LVDS         0x02
+#define HASVB_TRUMPION     0x04
+#define HASVB_LVDS_CHRONTEL 0x10
+#define HASVB_302          0x20
+#define HASVB_303          0x40
+#define HASVB_CHRONTEL     0x80
 
 #ifndef XGIFB_ID
-#define XGIFB_ID          0x53495346    /* Identify myself with 'XGIF' */
+#define XGIFB_ID       0x53495346 /* Identify myself with 'XGIF' */
 #endif
 
 enum XGI_CHIP_TYPE {
-    XG40 = 32,
-    XG41,
-    XG42,
-    XG45,
-    XG20 = 48,
-    XG21,
-    XG27,
+       XG40 = 32,
+       XG41,
+       XG42,
+       XG45,
+       XG20 = 48,
+       XG21,
+       XG27,
 };
 
 enum xgi_tvtype {
        TVMODE_NTSC = 0,
        TVMODE_PAL,
        TVMODE_HIVISION,
-       TVTYPE_PALM,    // vicki@030226
-       TVTYPE_PALN,    // vicki@030226
-       TVTYPE_NTSCJ,   // vicki@030226
+       TVTYPE_PALM,    /* vicki@030226 */
+       TVTYPE_PALN,    /* vicki@030226 */
+       TVTYPE_NTSCJ,   /* vicki@030226 */
        TVMODE_TOTAL
 };
 
-enum xgi_tv_plug {     /* vicki@030226 */
-//     TVPLUG_Legacy = 0,
-//     TVPLUG_COMPOSITE,
-//     TVPLUG_SVIDEO,
-//     TVPLUG_SCART,
-//     TVPLUG_TOTAL
-       TVPLUG_UNKNOWN = 0,
-       TVPLUG_COMPOSITE = 1,
-       TVPLUG_SVIDEO = 2,
-       TVPLUG_COMPOSITE_AND_SVIDEO = 3,
-       TVPLUG_SCART = 4,
-       TVPLUG_YPBPR_525i = 5,
-       TVPLUG_YPBPR_525P = 6,
-       TVPLUG_YPBPR_750P = 7,
-       TVPLUG_YPBPR_1080i = 8,
+enum xgi_tv_plug { /* vicki@030226 */
+/*     TVPLUG_Legacy = 0, */
+/*     TVPLUG_COMPOSITE,  */
+/*     TVPLUG_SVIDEO,     */
+/*     TVPLUG_SCART,      */
+/*     TVPLUG_TOTAL       */
+       TVPLUG_UNKNOWN = 0,
+       TVPLUG_COMPOSITE = 1,
+       TVPLUG_SVIDEO = 2,
+       TVPLUG_COMPOSITE_AND_SVIDEO = 3,
+       TVPLUG_SCART = 4,
+       TVPLUG_YPBPR_525i = 5,
+       TVPLUG_YPBPR_525P = 6,
+       TVPLUG_YPBPR_750P = 7,
+       TVPLUG_YPBPR_1080i = 8,
        TVPLUG_TOTAL
 };
 
-struct video_info{
-        int           chip_id;
-        unsigned int  video_size;
-        unsigned long video_base;
-        char  *       video_vbase;
-        unsigned long mmio_base;
+struct video_info {
+       int           chip_id;
+       unsigned int  video_size;
+       unsigned long video_base;
+       char          *video_vbase;
+       unsigned long mmio_base;
        unsigned long mmio_size;
-        char  *       mmio_vbase;
-        unsigned long vga_base;
-        unsigned long mtrr;
-
-        int    video_bpp;
-        int    video_cmap_len;
-        int    video_width;
-        int    video_height;
-        int    video_vwidth;
-        int    video_vheight;
-        int    org_x;
-        int    org_y;
-        int    video_linelength;
-        unsigned int refresh_rate;
-
-        unsigned long disp_state;
-        unsigned char hasVB;
-        unsigned char TV_type;
-        unsigned char TV_plug;
+       char          *mmio_vbase;
+       unsigned long vga_base;
+       unsigned long mtrr;
+
+       int    video_bpp;
+       int    video_cmap_len;
+       int    video_width;
+       int    video_height;
+       int    video_vwidth;
+       int    video_vheight;
+       int    org_x;
+       int    org_y;
+       int    video_linelength;
+       unsigned int refresh_rate;
+
+       unsigned long disp_state;
+       unsigned char hasVB;
+       unsigned char TV_type;
+       unsigned char TV_plug;
 
        enum XGI_CHIP_TYPE chip;
-        unsigned char revision_id;
+       unsigned char revision_id;
 
-        unsigned short DstColor;
-        unsigned long  XGI310_AccelDepth;
-        unsigned long  CommandReg;
+       unsigned short DstColor;
+       unsigned long  XGI310_AccelDepth;
+       unsigned long  CommandReg;
 
-        unsigned int   pcibus;
-        unsigned int   pcislot;
-        unsigned int   pcifunc;
+       unsigned int   pcibus;
+       unsigned int   pcislot;
+       unsigned int   pcifunc;
 
-        unsigned short subsysvendor;
-        unsigned short subsysdevice;
+       unsigned short subsysvendor;
+       unsigned short subsysdevice;
 
-        char reserved[236];
+       char reserved[236];
 };
 
 
index 4de182b23d414816b9da2ad3e9446e76c831a99f..339c071854f0b01f20bea8ab71e8bc917b7afae1 100644 (file)
@@ -1,4 +1,5 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/xgi/initdef.h,v 1.4 2000/12/02 01:16:17 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/xgi/initdef.h
+ * ,v 1.4 2000/12/02 01:16:17 dawes Exp $*/
 #ifndef _INITDEF_
 #define _INITDEF_
 
@@ -7,38 +8,38 @@
 #endif
 /* shampoo */
 
-#define SEQ_ADDRESS_PORT         0x0014
-#define SEQ_DATA_PORT            0x0015
-#define MISC_OUTPUT_REG_READ_PORT 0x001C
-#define MISC_OUTPUT_REG_WRITE_PORT 0x0012
-#define GRAPH_DATA_PORT                  0x1F
-#define GRAPH_ADDRESS_PORT       0x1E
-#define XGI_MASK_DUAL_CHIP       0x04  /* SR3A */
-#define CRTC_ADDRESS_PORT_COLOR   0x0024
+#define SEQ_ADDRESS_PORT            0x0014
+#define SEQ_DATA_PORT               0x0015
+#define MISC_OUTPUT_REG_READ_PORT   0x001C
+#define MISC_OUTPUT_REG_WRITE_PORT  0x0012
+#define GRAPH_DATA_PORT             0x1F
+#define GRAPH_ADDRESS_PORT          0x1E
+#define XGI_MASK_DUAL_CHIP          0x04  /* SR3A */
+#define CRTC_ADDRESS_PORT_COLOR     0x0024
 #define VIDEO_SUBSYSTEM_ENABLE_PORT 0x0013
-#define PCI_COMMAND            0x04
+#define PCI_COMMAND                 0x04
 
 /* ~shampoo */
 
 
-#define VB_XGI301            0x0001  /*301b*/
-#define VB_XGI301B        0x0002
-#define VB_XGI302B        0x0004
+#define VB_XGI301       0x0001 /*301b*/
+#define VB_XGI301B      0x0002
+#define VB_XGI302B      0x0004
 #define VB_XGI301LV     0x0008 /*301lv*/
 #define VB_XGI302LV     0x0010
-#define VB_XGI301C      0x0020       /* for 301C */
-#define  VB_NoLCD        0x8000
+#define VB_XGI301C      0x0020 /* for 301C */
+#define  VB_NoLCD       0x8000
 /*end 301b*/
 
-#define VB_YPbPrInfo     0x07          /*301lv*/
-#define VB_YPbPr525i     0x00
-#define VB_YPbPr525p     0x01
-#define VB_YPbPr750p     0x02
-#define VB_YPbPr1080i    0x03
+#define VB_YPbPrInfo    0x07   /*301lv*/
+#define VB_YPbPr525i    0x00
+#define VB_YPbPr525p    0x01
+#define VB_YPbPr750p    0x02
+#define VB_YPbPr1080i   0x03
 
 /* #define CRT1Len 17 */
-#define LVDSCRT1Len             15
-#define CHTVRegDataLen          5
+#define LVDSCRT1Len     15
+#define CHTVRegDataLen  5
 
 /* #define ModeInfoFlag 0x07 */
 /* #define IsTextMode 0x07 */
@@ -70,8 +71,8 @@
 #define NoSupportTV             0x0070
 #define NoSupportHiVisionTV     0x0060
 #define NoSupportLCD            0x0058
-#define SupportCHTV            0x0800
-#define SupportCRT2in301C       0x0100       /* for 301C */
+#define SupportCHTV             0x0800
+#define SupportCRT2in301C       0x0100  /* for 301C */
 #define SupportTV1024           0x0800  /*301b*/
 #define SupportYPbPr            0x1000  /*301lv*/
 #define InterlaceMode           0x0080
 #define DisableCRT2Display      0x2000
 #define DriverMode              0x4000
 #define HotKeySwitch            0x8000
-#define SetCHTVOverScan        0x8000
+#define SetCHTVOverScan         0x8000
 /* #define SetCRT2ToLCDA 0x8000 301b */
 #define PanelRGB18Bit           0x0100
 #define PanelRGB24Bit           0x0000
 #define TVOverScan              0x10
 #define TVOverScanShift         4
 #define ClearBufferFlag         0x20
-#define EnableDualEdge                 0x01            /*301b*/
-#define SetToLCDA              0x02
+#define EnableDualEdge          0x01 /*301b*/
+#define SetToLCDA               0x02
 
 #define YPbPrModeInfo           0x38
 /* #define YPbPrMode525i 0x00 */
 
 #define SetSCARTOutput          0x01
 #define BoardTVType             0x02
-#define  EnablePALMN           0x40
+#define  EnablePALMN            0x40
 /* #define ProgrammingCRT2 0x01 */
 /* #define TVSimuMode 0x02 */
 /* #define RPLLDIV2XO 0x04 */
 #define CheckWinDos             0x40
 #define SetJDOSMode             0x80
 
-#define Panel320x480              0x07/*fstn*/
+#define Panel320x480            0x07 /*fstn*/
 /* [ycchen] 02/12/03 Modify for Multi-Sync. LCD Support */
-#define PanelResInfo            0x1F   /* CR36 Panel Type/LCDResInfo */
+#define PanelResInfo            0x1F /* CR36 Panel Type/LCDResInfo */
 #define PanelRefInfo            0x60
 #define Panel800x600            0x01
 #define Panel1024x768           0x02
 #define SoftDramType            0x80
 #define VCLK40                  0x04
 
-#define VCLK162                0x21
+#define VCLK162                 0x21
 
 #define LCDRGB18Bit             0x01
 #define LoadDACFlag             0x1000
 #define StStructSize            0x06
 
 
-#define XGI_CRT2_PORT_00        0x00 - 0x030
-#define XGI_CRT2_PORT_04        0x04 - 0x030
-#define XGI_CRT2_PORT_10        0x10 - 0x30
-#define XGI_CRT2_PORT_12        0x12 - 0x30
-#define XGI_CRT2_PORT_14        0x14 - 0x30
+#define XGI_CRT2_PORT_00        (0x00 - 0x030)
+#define XGI_CRT2_PORT_04        (0x04 - 0x030)
+#define XGI_CRT2_PORT_10        (0x10 - 0x30)
+#define XGI_CRT2_PORT_12        (0x12 - 0x30)
+#define XGI_CRT2_PORT_14        (0x14 - 0x30)
 
 
 #define LCDNonExpanding         0x10
 #define _PanelType0E             0x70
 #define _PanelType0F             0x78
 
-
-#define PRIMARY_VGA       0     /* 1: XGI is primary vga 0:XGI is secondary vga */
+/* 1: XGI is primary vga 0:XGI is secondary vga */
+#define PRIMARY_VGA             0
 #define BIOSIDCodeAddr          0x235
 #define OEMUtilIDCodeAddr       0x237
 #define VBModeIDTableAddr       0x239
 #define VideoSenseDataOffset  0xC1
 #define OutputSelectOffset    0xF3
 
-#define ECLK_MCLK_DISTANCE  0x14
+#define ECLK_MCLK_DISTANCE        0x14
 #define VBIOSTablePointerStart    0x200
-#define StandTablePtrOffset       VBIOSTablePointerStart+0x02
-#define EModeIDTablePtrOffset     VBIOSTablePointerStart+0x04
-#define CRT1TablePtrOffset        VBIOSTablePointerStart+0x06
-#define ScreenOffsetPtrOffset     VBIOSTablePointerStart+0x08
-#define VCLKDataPtrOffset         VBIOSTablePointerStart+0x0A
-#define MCLKDataPtrOffset         VBIOSTablePointerStart+0x0E
-#define CRT2PtrDataPtrOffset      VBIOSTablePointerStart+0x10
-#define TVAntiFlickPtrOffset      VBIOSTablePointerStart+0x12
-#define TVDelayPtr1Offset         VBIOSTablePointerStart+0x14
-#define TVPhaseIncrPtr1Offset     VBIOSTablePointerStart+0x16
-#define TVYFilterPtr1Offset       VBIOSTablePointerStart+0x18
-#define LCDDelayPtr1Offset        VBIOSTablePointerStart+0x20
-#define TVEdgePtr1Offset          VBIOSTablePointerStart+0x24
-#define CRT2Delay1Offset          VBIOSTablePointerStart+0x28
-#define LCDDataDesOffset     VBIOSTablePointerStart-0x02
-#define LCDDataPtrOffset          VBIOSTablePointerStart+0x2A
-#define LCDDesDataPtrOffset     VBIOSTablePointerStart+0x2C
-#define LCDDataList            VBIOSTablePointerStart+0x22     /* add for GetLCDPtr */
-#define TVDataList             VBIOSTablePointerStart+0x36     /* add for GetTVPtr */
+#define StandTablePtrOffset       (VBIOSTablePointerStart+0x02)
+#define EModeIDTablePtrOffset     (VBIOSTablePointerStart+0x04)
+#define CRT1TablePtrOffset        (VBIOSTablePointerStart+0x06)
+#define ScreenOffsetPtrOffset     (VBIOSTablePointerStart+0x08)
+#define VCLKDataPtrOffset         (VBIOSTablePointerStart+0x0A)
+#define MCLKDataPtrOffset         (VBIOSTablePointerStart+0x0E)
+#define CRT2PtrDataPtrOffset      (VBIOSTablePointerStart+0x10)
+#define TVAntiFlickPtrOffset      (VBIOSTablePointerStart+0x12)
+#define TVDelayPtr1Offset         (VBIOSTablePointerStart+0x14)
+#define TVPhaseIncrPtr1Offset     (VBIOSTablePointerStart+0x16)
+#define TVYFilterPtr1Offset       (VBIOSTablePointerStart+0x18)
+#define LCDDelayPtr1Offset        (VBIOSTablePointerStart+0x20)
+#define TVEdgePtr1Offset          (VBIOSTablePointerStart+0x24)
+#define CRT2Delay1Offset          (VBIOSTablePointerStart+0x28)
+#define LCDDataDesOffset          (VBIOSTablePointerStart-0x02)
+#define LCDDataPtrOffset          (VBIOSTablePointerStart+0x2A)
+#define LCDDesDataPtrOffset       (VBIOSTablePointerStart+0x2C)
+/* add LCDDataList for GetLCDPtr */
+#define LCDDataList               (VBIOSTablePointerStart+0x22)
+/* add TVDataList for GetTVPtr */
+#define TVDataList                (VBIOSTablePointerStart+0x36)
 /*  */
 /* Modify from 310.inc */
 /*  */
 /*  */
 
 
-#define                ShowMsgFlag                  0x20               /* SoftSetting */
-#define                ShowVESAFlag                 0x10
-#define                HotPlugFunction              0x08
-#define                ModeSoftSetting              0x04
-#define                TVSoftSetting                0x02
-#define                LCDSoftSetting               0x01
+#define ShowMsgFlag                  0x20    /* SoftSetting */
+#define ShowVESAFlag                 0x10
+#define HotPlugFunction              0x08
+#define ModeSoftSetting              0x04
+#define TVSoftSetting                0x02
+#define LCDSoftSetting               0x01
 
-#define                GatingCRTinLCDA              0x10
-#define                SetHiTVOutput                0x08
-#define                SetYPbPrOutput               0x04
-#define                BoardTVType                  0x02
-#define                SetSCARTOutput               0x01
+#define GatingCRTinLCDA              0x10
+#define SetHiTVOutput                0x08
+#define SetYPbPrOutput               0x04
+#define BoardTVType                  0x02
+#define SetSCARTOutput               0x01
 
-#define                ModeSettingYPbPr             0x02               /* TVModeSetting, Others as same as CR30 */
+/* TVModeSetting, Others as same as CR30 */
+#define ModeSettingYPbPr             0x02
 
 /* TVModeSetting same as CR35 */
 
 /* LCDModeSetting same as CR37 */
 
-#define                EnableNewTVFont              0x10               /* MiscCapability */
+#define EnableNewTVFont              0x10    /* MiscCapability */
 
-#define                EnableLCDOutput              0x80               /* LCDCfgSetting */
+#define EnableLCDOutput              0x80    /* LCDCfgSetting */
 
-#define                SoftDRAMType                 0x80               /* DRAMSetting */
-#define                SoftDRAMConfig               0x40
-#define                MosSelDRAMType               0x20
-#define                SDRAM                        000h
-#define                SGRAM                        0x01
-#define                ESDRAM                       0x02
+#define SoftDRAMType                 0x80    /* DRAMSetting */
+#define SoftDRAMConfig               0x40
+#define MosSelDRAMType               0x20
+#define SDRAM                        000h
+#define SGRAM                        0x01
+#define ESDRAM                       0x02
 
-#define                EnableAGPCfgSetting          0x01               /* AGPCfgSetting */
+#define EnableAGPCfgSetting          0x01    /* AGPCfgSetting */
 
 /* ---------------- SetMode Stack */
-#define                CRT1Len                      15
-#define                VCLKLen                      4
-#define                DefThreshold                 0x0100
-#define                ExtRegsSize                  (57+8+37+70+63+28+768+1)/64+1
-
-#define                VGA_XGI315                   0x0001       /* VGA Type Info */
-#define                VGA_SNewis315e                  0x0002       /* 315 series */
-#define                VGA_XGI550                   0x0004
-#define                VGA_XGI640                   0x0008
-#define                VGA_XGI740                   0x0010
-#define                VGA_XGI650                   0x0020
-#define                VGA_XGI650M                  0x0040
-#define                VGA_XGI651                   0x0080
-#define                VGA_XGI340                   0x0001       /* 340 series */
-#define                VGA_XGI330                   0x0001       /* 330 series */
-#define                VGA_XGI660                   0x0001       /* 660 series */
-
-#define                VB_XGI301                    0x0001       /* VB Type Info */
-#define                VB_XGI301B                   0x0002       /* 301 series */
-#define                VB_XGI302B                   0x0004
-#define                VB_NoLCD                     0x8000
-#define                VB_XGI301LV                  0x0008
-#define                VB_XGI302LV                  0x0010
-#define                VB_LVDS_NS                   0x0001       /* 3rd party chip */
-#define                VB_CH7017                    0x0002
-#define         VB_CH7007                    0x0080       /* [Billy] 07/05/03 */
+#define CRT1Len           15
+#define VCLKLen           4
+#define DefThreshold      0x0100
+#define ExtRegsSize       ((57+8+37+70+63+28+768+1)/64+1)
+
+#define VGA_XGI315        0x0001       /* VGA Type Info */
+#define VGA_SNewis315e    0x0002       /* 315 series */
+#define VGA_XGI550        0x0004
+#define VGA_XGI640        0x0008
+#define VGA_XGI740        0x0010
+#define VGA_XGI650        0x0020
+#define VGA_XGI650M       0x0040
+#define VGA_XGI651        0x0080
+#define VGA_XGI340        0x0001       /* 340 series */
+#define VGA_XGI330        0x0001       /* 330 series */
+#define VGA_XGI660        0x0001       /* 660 series */
+
+#define VB_XGI301         0x0001       /* VB Type Info */
+#define VB_XGI301B        0x0002       /* 301 series */
+#define VB_XGI302B        0x0004
+#define VB_NoLCD          0x8000
+#define VB_XGI301LV       0x0008
+#define VB_XGI302LV       0x0010
+#define VB_LVDS_NS        0x0001       /* 3rd party chip */
+#define VB_CH7017         0x0002
+#define VB_CH7007         0x0080       /* [Billy] 07/05/03 */
 /* #define VB_LVDS_SI 0x0004 */
 
-#define                ModeInfoFlag                 0x0007
-#define                IsTextMode                   0x0007
-#define                ModeText                     0x0000
-#define                ModeCGA                      0x0001
-#define                ModeEGA                      0x0002       /* 16 colors mode */
-#define                ModeVGA                      0x0003       /* 256 colors mode */
-#define                Mode15Bpp                    0x0004       /* 15 Bpp Color Mode */
-#define                Mode16Bpp                    0x0005       /* 16 Bpp Color Mode */
-#define                Mode24Bpp                    0x0006       /* 24 Bpp Color Mode */
-#define                Mode32Bpp                    0x0007       /* 32 Bpp Color Mode */
-
-#define                DACInfoFlag                  0x0018
-#define                MONODAC                      0x0000
-#define                CGADAC                       0x0008
-#define                EGADAC                       0x0010
-#define                VGADAC                       0x0018
-
-#define                MemoryInfoFlag               0x01e0
-#define                MemorySizeShift              5
-#define                Need1MSize                   0x0000
-#define                Need2MSize                   0x0020
-#define                Need4MSize                   0x0060
-#define                Need8MSize                   0x00e0
-#define                Need16MSize                  0x01e0
-
-#define                Charx8Dot                    0x0200
-#define                LineCompareOff               0x0400
-#define                CRT2Mode                     0x0800
-#define                HalfDCLK                     0x1000
-#define                NoSupportSimuTV              0x2000
-#define                DoubleScanMode               0x8000
+#define ModeInfoFlag      0x0007
+#define IsTextMode        0x0007
+#define ModeText          0x0000
+#define ModeCGA           0x0001
+#define ModeEGA           0x0002    /* 16 colors mode */
+#define ModeVGA           0x0003    /* 256 colors mode */
+#define Mode15Bpp         0x0004    /* 15 Bpp Color Mode */
+#define Mode16Bpp         0x0005    /* 16 Bpp Color Mode */
+#define Mode24Bpp         0x0006    /* 24 Bpp Color Mode */
+#define Mode32Bpp         0x0007    /* 32 Bpp Color Mode */
+
+#define DACInfoFlag       0x0018
+#define MONODAC           0x0000
+#define CGADAC            0x0008
+#define EGADAC            0x0010
+#define VGADAC            0x0018
+
+#define MemoryInfoFlag    0x01e0
+#define MemorySizeShift   5
+#define Need1MSize        0x0000
+#define Need2MSize        0x0020
+#define Need4MSize        0x0060
+#define Need8MSize        0x00e0
+#define Need16MSize       0x01e0
+
+#define Charx8Dot         0x0200
+#define LineCompareOff    0x0400
+#define CRT2Mode          0x0800
+#define HalfDCLK          0x1000
+#define NoSupportSimuTV   0x2000
+#define DoubleScanMode    0x8000
 
 /* -------------- Ext_InfoFlag */
-#define                SupportModeInfo              0x0007
-#define                Support256                   0x0003
-#define                Support15Bpp                 0x0004
-#define                Support16Bpp                 0x0005
-#define                Support24Bpp                 0x0006
-#define                Support32Bpp                 0x0007
-
-#define                SupportAllCRT2               0x0078
-#define                SupportTV                    0x0008
-#define                SupportHiVisionTV            0x0010
-#define                SupportLCD                   0x0020
-#define                SupportRAMDAC2               0x0040
-#define                NoSupportTV                  0x0070
-#define                NoSupportHiVisionTV          0x0060
-#define                NoSupportLCD                 0x0058
-#define                SupportTV1024                0x0800       /* 301btest */
-#define                SupportYPbPr                 0x1000       /* 301lv */
-#define                InterlaceMode                0x0080
-#define                SyncPP                       0x0000
-#define                SyncPN                       0x4000
-#define                SyncNP                       0x8000
-#define                SyncNN                       0xC000
+#define SupportModeInfo     0x0007
+#define Support256          0x0003
+#define Support15Bpp        0x0004
+#define Support16Bpp        0x0005
+#define Support24Bpp        0x0006
+#define Support32Bpp        0x0007
+
+#define SupportAllCRT2      0x0078
+#define SupportTV           0x0008
+#define SupportHiVisionTV   0x0010
+#define SupportLCD          0x0020
+#define SupportRAMDAC2      0x0040
+#define NoSupportTV         0x0070
+#define NoSupportHiVisionTV 0x0060
+#define NoSupportLCD        0x0058
+#define SupportTV1024       0x0800 /* 301btest */
+#define SupportYPbPr        0x1000 /* 301lv */
+#define InterlaceMode       0x0080
+#define SyncPP              0x0000
+#define SyncPN              0x4000
+#define SyncNP              0x8000
+#define SyncNN              0xC000
 
 /* -------------- SetMode Stack/Scratch */
-#define                SetSimuScanMode              0x0001       /* VBInfo/CR30 & CR31 */
-#define                SwitchToCRT2                 0x0002
-#define                SetCRT2ToTV1                 0x009C
-#define                SetCRT2ToTV                  0x089C
-#define                SetCRT2ToAVIDEO              0x0004
-#define                SetCRT2ToSVIDEO              0x0008
-#define                SetCRT2ToSCART               0x0010
-#define                SetCRT2ToLCD                 0x0020
-#define                SetCRT2ToRAMDAC              0x0040
-#define                SetCRT2ToHiVisionTV          0x0080
-#define                SetCRT2ToLCDA                0x0100
-#define                SetInSlaveMode               0x0200
-#define                SetNotSimuMode               0x0400
-#define                HKEventMode                  0x0800
-#define                SetCRT2ToYPbPr               0x0800
-#define                LoadDACFlag                  0x1000
-#define                DisableCRT2Display           0x2000
-#define                DriverMode                   0x4000
-#define                SetCRT2ToDualEdge            0x8000
-#define                HotKeySwitch                 0x8000
-
-#define                ProgrammingCRT2              0x0001       /* Set Flag */
-#define                EnableVCMode                 0x0002
-#define                SetHKEventMode               0x0004
-#define                ReserveTVOption              0x0008
-#define                DisableRelocateIO            0x0010
-#define                Win9xDOSMode                 0x0020
-#define                JDOSMode                     0x0040
+#define SetSimuScanMode     0x0001    /* VBInfo/CR30 & CR31 */
+#define SwitchToCRT2        0x0002
+#define SetCRT2ToTV1        0x009C
+#define SetCRT2ToTV         0x089C
+#define SetCRT2ToAVIDEO     0x0004
+#define SetCRT2ToSVIDEO     0x0008
+#define SetCRT2ToSCART      0x0010
+#define SetCRT2ToLCD        0x0020
+#define SetCRT2ToRAMDAC     0x0040
+#define SetCRT2ToHiVisionTV 0x0080
+#define SetCRT2ToLCDA       0x0100
+#define SetInSlaveMode      0x0200
+#define SetNotSimuMode      0x0400
+#define HKEventMode         0x0800
+#define SetCRT2ToYPbPr      0x0800
+#define LoadDACFlag         0x1000
+#define DisableCRT2Display  0x2000
+#define DriverMode          0x4000
+#define SetCRT2ToDualEdge   0x8000
+#define HotKeySwitch        0x8000
+
+#define ProgrammingCRT2     0x0001       /* Set Flag */
+#define EnableVCMode        0x0002
+#define SetHKEventMode      0x0004
+#define ReserveTVOption     0x0008
+#define DisableRelocateIO   0x0010
+#define Win9xDOSMode        0x0020
+#define JDOSMode            0x0040
 /* #define SetWin9xforJap 0x0080 // not used now */
 /* #define SetWin9xforKorea 0x0100 // not used now */
-#define                GatingCRT                    0x0800
-#define                DisableChB                   0x1000
-#define                EnableChB                    0x2000
-#define                DisableChA                   0x4000
-#define                EnableChA                    0x8000
-
-#define                SetNTSCTV                    0x0000       /* TV Info */
-#define                SetPALTV                     0x0001
-#define                SetNTSCJ                     0x0002
-#define                SetPALMTV                    0x0004
-#define                SetPALNTV                    0x0008
-#define                SetCHTVUnderScan             0x0000
+#define GatingCRT           0x0800
+#define DisableChB          0x1000
+#define EnableChB           0x2000
+#define DisableChA          0x4000
+#define EnableChA           0x8000
+
+#define SetNTSCTV           0x0000 /* TV Info */
+#define SetPALTV            0x0001
+#define SetNTSCJ            0x0002
+#define SetPALMTV           0x0004
+#define SetPALNTV           0x0008
+#define SetCHTVUnderScan    0x0000
 /* #define SetCHTVOverScan 0x0010 */
-#define                SetYPbPrMode525i             0x0020
-#define                SetYPbPrMode525p             0x0040
-#define                SetYPbPrMode750p             0x0080
-#define                SetYPbPrMode1080i            0x0100
-#define                SetTVStdMode                 0x0200
-#define                SetTVLowResolution           0x0400
-#define                SetTVSimuMode                0x0800
-#define                TVSimuMode                   0x0800
-#define                RPLLDIV2XO                   0x1000
-#define                NTSC1024x768                 0x2000
-#define                SetTVLockMode                0x4000
-
-#define                LCDVESATiming                0x0001       /* LCD Info/CR37 */
-#define                EnableLVDSDDA                0x0002
-#define                EnableScalingLCD             0x0008
-#define                SetPWDEnable                 0x0004
-#define                SetLCDtoNonExpanding         0x0010
-#define                SetLCDPolarity               0x00e0
-#define                SetLCDDualLink               0x0100
-#define                SetLCDLowResolution          0x0200
-#define                SetLCDStdMode                0x0400
-
-#define                DefaultLCDCap                0x80ea       /* LCD Capability shampoo */
-#define                RLVDSDHL00                   0x0000
-#define                RLVDSDHL01                   0x0001
-#define                RLVDSDHL10                   0x0002       /* default */
-#define                RLVDSDHL11                   0x0003
-#define                EnableLCD24bpp               0x0004       /* default */
-#define                DisableLCD24bpp              0x0000
-#define                RLVDSClkSFT0                 0x0000
-#define                RLVDSClkSFT1                 0x0008       /* default */
-#define                EnableLVDSDCBal              0x0010
-#define                DisableLVDSDCBal             0x0000       /* default */
-#define                SinglePolarity               0x0020       /* default */
-#define                MultiPolarity                0x0000
-#define                LCDPolarity                  0x00c0       /* default: SyncNN */
-#define                LCDSingleLink                0x0000       /* default */
-#define                LCDDualLink                  0x0100
-#define                EnableSpectrum               0x0200
-#define                DisableSpectrum              0x0000       /* default */
-#define                PWDEnable                    0x0400
-#define                PWDDisable                   0x0000       /* default */
-#define                PWMEnable                    0x0800
-#define                PWMDisable                   0x0000       /* default */
-#define                EnableVBCLKDRVLOW            0x4000
-#define                EnableVBCLKDRVHigh           0x0000       /* default */
-#define                EnablePLLSPLOW               0x8000
-#define                EnablePLLSPHigh              0x0000       /* default */
-
-#define                LCDBToA                      0x20               /* LCD SetFlag */
-#define                StLCDBToA                    0x40
-#define                LockLCDBToA                  0x80
-#define        LCDToFull                    0x10
-#define                AVIDEOSense                  0x01               /* CR32 */
-#define                SVIDEOSense                  0x02
-#define                SCARTSense                   0x04
-#define                LCDSense                     0x08
-#define                Monitor2Sense                0x10
-#define                Monitor1Sense                0x20
-#define                HiTVSense                    0x40
-
-#ifdef                   NewScratch
-#define                YPbPrSense                   0x80    /* NEW SCRATCH */
+#define SetYPbPrMode525i     0x0020
+#define SetYPbPrMode525p     0x0040
+#define SetYPbPrMode750p     0x0080
+#define SetYPbPrMode1080i    0x0100
+#define SetTVStdMode         0x0200
+#define SetTVLowResolution   0x0400
+#define SetTVSimuMode        0x0800
+#define TVSimuMode           0x0800
+#define RPLLDIV2XO           0x1000
+#define NTSC1024x768         0x2000
+#define SetTVLockMode        0x4000
+
+#define LCDVESATiming        0x0001 /* LCD Info/CR37 */
+#define EnableLVDSDDA        0x0002
+#define EnableScalingLCD     0x0008
+#define SetPWDEnable         0x0004
+#define SetLCDtoNonExpanding 0x0010
+#define SetLCDPolarity       0x00e0
+#define SetLCDDualLink       0x0100
+#define SetLCDLowResolution  0x0200
+#define SetLCDStdMode        0x0400
+
+/* LCD Capability shampoo */
+#define DefaultLCDCap        0x80ea
+#define RLVDSDHL00           0x0000
+#define RLVDSDHL01           0x0001
+#define RLVDSDHL10           0x0002 /* default */
+#define RLVDSDHL11           0x0003
+#define EnableLCD24bpp       0x0004 /* default */
+#define DisableLCD24bpp      0x0000
+#define RLVDSClkSFT0         0x0000
+#define RLVDSClkSFT1         0x0008 /* default */
+#define EnableLVDSDCBal      0x0010
+#define DisableLVDSDCBal     0x0000 /* default */
+#define SinglePolarity       0x0020 /* default */
+#define MultiPolarity        0x0000
+#define LCDPolarity          0x00c0 /* default: SyncNN */
+#define LCDSingleLink        0x0000 /* default */
+#define LCDDualLink          0x0100
+#define EnableSpectrum       0x0200
+#define DisableSpectrum      0x0000 /* default */
+#define PWDEnable            0x0400
+#define PWDDisable           0x0000 /* default */
+#define PWMEnable            0x0800
+#define PWMDisable           0x0000 /* default */
+#define EnableVBCLKDRVLOW    0x4000
+#define EnableVBCLKDRVHigh   0x0000 /* default */
+#define EnablePLLSPLOW       0x8000
+#define EnablePLLSPHigh      0x0000 /* default */
+
+#define LCDBToA              0x20   /* LCD SetFlag */
+#define StLCDBToA            0x40
+#define LockLCDBToA          0x80
+#define   LCDToFull          0x10
+#define AVIDEOSense          0x01   /* CR32 */
+#define SVIDEOSense          0x02
+#define SCARTSense           0x04
+#define LCDSense             0x08
+#define Monitor2Sense        0x10
+#define Monitor1Sense        0x20
+#define HiTVSense            0x40
+
+#ifdef NewScratch
+#define YPbPrSense           0x80   /* NEW SCRATCH */
 #endif
 
-#define                TVSense                      0xc7
-
-#define                TVOverScan                   0x10               /* CR35 */
-#define                TVOverScanShift              4
-
-#ifdef                   NewScratch
-#define                NTSCMode                     0x00
-#define                PALMode                      0x00
-#define                NTSCJMode                    0x02
-#define                PALMNMode                    0x0c
-#define                YPbPrMode                    0xe0
-#define                YPbPrMode525i                0x00
-#define                YPbPrMode525p                0x20
-#define                YPbPrMode750p                0x40
-#define                YPbPrMode1080i               0x60
+#define TVSense              0xc7
+
+#define TVOverScan           0x10               /* CR35 */
+#define TVOverScanShift      4
+
+#ifdef NewScratch
+#define NTSCMode             0x00
+#define PALMode              0x00
+#define NTSCJMode            0x02
+#define PALMNMode            0x0c
+#define YPbPrMode            0xe0
+#define YPbPrMode525i        0x00
+#define YPbPrMode525p        0x20
+#define YPbPrMode750p        0x40
+#define YPbPrMode1080i       0x60
 #else                    /* Old Scratch */
-#define                ClearBufferFlag              0x20
+#define ClearBufferFlag      0x20
 #endif
 
 
-#define                LCDRGB18Bit                  0x01               /* CR37 */
-#define                LCDNonExpanding              0x10
-#define                LCDNonExpandingShift         4
-#define                LCDSync                      0x20
-#define                LCDSyncBit                   0xe0               /* H/V polarity & sync ID */
-#define                LCDSyncShift                 6
-
-#ifdef                   NewScratch
-#define                ScalingLCD                   0x08
-#else                    /* Old Scratch */
-#define                ExtChipType                  0x0e
-#define                ExtChip301                   0x02
-#define                ExtChipLVDS                  0x04
-#define                ExtChipCH7019                0x06
-#define                ScalingLCD                   0x10
+#define LCDRGB18Bit          0x01               /* CR37 */
+#define LCDNonExpanding      0x10
+#define LCDNonExpandingShift 4
+#define LCDSync              0x20
+#define LCDSyncBit           0xe0 /* H/V polarity & sync ID */
+#define LCDSyncShift         6
+
+#ifdef NewScratch
+#define ScalingLCD           0x08
+#else  /* Old Scratch */
+#define ExtChipType          0x0e
+#define ExtChip301           0x02
+#define ExtChipLVDS          0x04
+#define ExtChipCH7019        0x06
+#define ScalingLCD           0x10
 #endif
 
-#define                EnableDualEdge               0x01               /* CR38 */
-#define                SetToLCDA                    0x02
-#ifdef                   NewScratch
-#define                SetYPbPr                     0x04
-#define                DisableChannelA              0x08
-#define                DisableChannelB              0x10
-#define                ExtChipType                  0xe0
-#define                ExtChip301                   0x20
-#define                ExtChipLVDS                  0x40
-#define                ExtChipCH7019                0x60
+#define EnableDualEdge       0x01 /* CR38 */
+#define SetToLCDA            0x02
+#ifdef NewScratch
+#define SetYPbPr             0x04
+#define DisableChannelA      0x08
+#define DisableChannelB      0x10
+#define ExtChipType          0xe0
+#define ExtChip301           0x20
+#define ExtChipLVDS          0x40
+#define ExtChipCH7019        0x60
 #else                    /* Old Scratch */
-#define                YPbPrSense                   0x04
-#define                SetYPbPr                     0x08
-#define                YPbPrMode                    0x30
-#define                YPbPrMode525i                0x00
-#define                YPbPrMode525p                0x10
-#define                YPbPrMode750p                0x20
-#define                YPbPrMode1080i               0x30
-#define                PALMNMode                    0xc0
+#define YPbPrSense           0x04
+#define SetYPbPr             0x08
+#define YPbPrMode            0x30
+#define YPbPrMode525i        0x00
+#define YPbPrMode525p        0x10
+#define YPbPrMode750p        0x20
+#define YPbPrMode1080i       0x30
+#define PALMNMode            0xc0
 #endif
 
-#define                BacklightControlBit          0x01               /* CR3A */
-#define                Win9xforJap                  0x40
-#define                Win9xforKorea                0x80
-
-#define                ForceMDBits                  0x07               /* CR3B */
-#define                ForceMD_JDOS                 0x00
-#define                ForceMD_640x400T             0x01
-#define                ForceMD_640x350T             0x02
-#define                ForceMD_720x400T             0x03
-#define                ForceMD_640x480E             0x04
-#define                ForceMD_640x400E             0x05
-#define                ForceP1Bit                   0x10
-#define                ForceP2Bit                   0x20
-#define                EnableForceMDinBIOS          0x40
-#define                EnableForceMDinDrv           0x80
-
-#ifdef                   NewScratch                      /* New Scratch */
+#define BacklightControlBit  0x01 /* CR3A */
+#define Win9xforJap          0x40
+#define Win9xforKorea        0x80
+
+#define ForceMDBits          0x07 /* CR3B */
+#define ForceMD_JDOS         0x00
+#define ForceMD_640x400T     0x01
+#define ForceMD_640x350T     0x02
+#define ForceMD_720x400T     0x03
+#define ForceMD_640x480E     0x04
+#define ForceMD_640x400E     0x05
+#define ForceP1Bit           0x10
+#define ForceP2Bit           0x20
+#define EnableForceMDinBIOS  0x40
+#define EnableForceMDinDrv   0x80
+
+#ifdef NewScratch /* New Scratch */
 /* ---------------------- VUMA Information */
-#define                LCDSettingFromCMOS           0x04               /* CR3C */
-#define                TVSettingFromCMOS            0x08
-#define                DisplayDeviceFromCMOS        0x10
-#define                HKSupportInSBIOS             0x20
-#define                OSDSupportInSBIOS            0x40
-#define                DisableLogo                  0x80
+#define LCDSettingFromCMOS    0x04 /* CR3C */
+#define TVSettingFromCMOS     0x08
+#define DisplayDeviceFromCMOS 0x10
+#define HKSupportInSBIOS      0x20
+#define OSDSupportInSBIOS     0x40
+#define DisableLogo           0x80
 
 /* ---------------------- HK Evnet Definition */
-#define                HKEvent                      0x0f               /* CR3D */
-#define                HK_ModeSwitch                0x01
-#define                HK_Expanding                 0x02
-#define                HK_OverScan                  0x03
-#define                HK_Brightness                0x04
-#define                HK_Contrast                  0x05
-#define                HK_Mute                      0x06
-#define                HK_Volume                    0x07
-#define                ModeSwitchStatus             0xf0
-#define                ActiveCRT1                   0x10
-#define                ActiveLCD                    0x0020
-#define                ActiveTV                     0x40
-#define                ActiveCRT2                   0x80
-
-#define                TVSwitchStatus               0x1f               /* CR3E */
-#define                ActiveAVideo                 0x01
-#define                ActiveSVideo                 0x02
-#define                ActiveSCART                  0x04
-#define                ActiveHiTV                   0x08
-#define                ActiveYPbPr                  0x10
-
-#define                EnableHKEvent                0x01               /* CR3F */
-#define                EnableOSDEvent               0x02
-#define                StartOSDEvent                0x04
-#define                IgnoreHKEvent                0x08
-#define                IgnoreOSDEvent               0x10
+#define HKEvent               0x0f /* CR3D */
+#define HK_ModeSwitch         0x01
+#define HK_Expanding          0x02
+#define HK_OverScan           0x03
+#define HK_Brightness         0x04
+#define HK_Contrast           0x05
+#define HK_Mute               0x06
+#define HK_Volume             0x07
+#define ModeSwitchStatus      0xf0
+#define ActiveCRT1            0x10
+#define ActiveLCD             0x0020
+#define ActiveTV              0x40
+#define ActiveCRT2            0x80
+
+#define TVSwitchStatus        0x1f /* CR3E */
+#define ActiveAVideo          0x01
+#define ActiveSVideo          0x02
+#define ActiveSCART           0x04
+#define ActiveHiTV            0x08
+#define ActiveYPbPr           0x10
+
+#define EnableHKEvent         0x01 /* CR3F */
+#define EnableOSDEvent        0x02
+#define StartOSDEvent         0x04
+#define IgnoreHKEvent         0x08
+#define IgnoreOSDEvent        0x10
 #else                    /* Old Scratch */
-#define                OSD_SBIOS                    0x02       /* SR17 */
-#define                DisableLogo                  0x04
-#define                SelectKDOS                   0x08
-#define                KorWinMode                   0x10
-#define                KorMode3Bit                  0x0020
-#define                PSCCtrlBit                  0x40
-#define                NPSCCtrlBitShift             6
-#define                BlueScreenBit                0x80
-
-#define                HKEvent                      0x0f       /* CR79 */
-#define                HK_ModeSwitch                0x01
-#define                HK_Expanding                 0x02
-#define                HK_OverScan                  0x03
-#define                HK_Brightness                0x04
-#define                HK_Contrast                  0x05
-#define                HK_Mute                      0x06
-#define                HK_Volume                    0x07
-#define                ActivePAL                    0x0020
-#define                ActivePALShift               5
-#define                ActiveNonExpanding           0x40
-#define                ActiveNonExpandingShift      6
-#define                ActiveOverScan               0x80
-#define                ActiveOverScanShift          7
-
-#define                ModeSwitchStatus             0x0b       /* SR15 */
-#define                ActiveCRT1                   0x01
-#define                ActiveLCD                    0x02
-#define                ActiveCRT2                   0x08
-
-#define                TVSwitchStatus               0xf0       /* SR16 */
-#define                TVConfigShift                3
-#define                ActiveTV                     0x01
-#define                ActiveYPbPr                  0x04
-#define                ActiveAVideo                 0x10
-#define                ActiveSVideo                 0x0020
-#define                ActiveSCART                  0x40
-#define                ActiveHiTV                   0x80
-
-#define                EnableHKEvent                0x01       /* CR7A */
-#define                EnableOSDEvent               0x02
-#define                StartOSDEvent                0x04
-#define                CMOSSupport                  0x08
-#define                HotKeySupport                0x10
-#define                IngoreHKOSDEvent             0x20
+#define OSD_SBIOS               0x02 /* SR17 */
+#define DisableLogo             0x04
+#define SelectKDOS              0x08
+#define KorWinMode              0x10
+#define KorMode3Bit             0x0020
+#define PSCCtrlBit              0x40
+#define NPSCCtrlBitShift        6
+#define BlueScreenBit           0x80
+
+#define HKEvent                 0x0f /* CR79 */
+#define HK_ModeSwitch           0x01
+#define HK_Expanding            0x02
+#define HK_OverScan             0x03
+#define HK_Brightness           0x04
+#define HK_Contrast             0x05
+#define HK_Mute                 0x06
+#define HK_Volume               0x07
+#define ActivePAL               0x0020
+#define ActivePALShift          5
+#define ActiveNonExpanding      0x40
+#define ActiveNonExpandingShift 6
+#define ActiveOverScan          0x80
+#define ActiveOverScanShift     7
+
+#define ModeSwitchStatus        0x0b /* SR15 */
+#define ActiveCRT1              0x01
+#define ActiveLCD               0x02
+#define ActiveCRT2              0x08
+
+#define TVSwitchStatus          0xf0 /* SR16 */
+#define TVConfigShift           3
+#define ActiveTV                0x01
+#define ActiveYPbPr             0x04
+#define ActiveAVideo            0x10
+#define ActiveSVideo            0x0020
+#define ActiveSCART             0x40
+#define ActiveHiTV              0x80
+
+#define EnableHKEvent           0x01 /* CR7A */
+#define EnableOSDEvent          0x02
+#define StartOSDEvent           0x04
+#define CMOSSupport             0x08
+#define HotKeySupport           0x10
+#define IngoreHKOSDEvent        0x20
 #endif
 
 /* //------------- Misc. Definition */
-#define                SelectCRT1Rate               00h
+#define SelectCRT1Rate               00h
 /* #define SelectCRT2Rate 04h */
 
-#define                DDC1DelayTime                1000
-#ifdef           TRUMPION
-#define                DDC2DelayTime                15
+#define DDC1DelayTime           1000
+#ifdef TRUMPION
+#define DDC2DelayTime           15
 #else
-#define                DDC2DelayTime                150
+#define DDC2DelayTime           150
 #endif
 
-#define                R_FACTOR                     04Dh
-#define                G_FACTOR                     097h
-#define                B_FACTOR                     01Ch
+#define R_FACTOR                04Dh
+#define G_FACTOR                097h
+#define B_FACTOR                01Ch
 /* --------------------------------------------------------- */
 /* translated from asm code 301def.h */
 /*  */
 /* --------------------------------------------------------- */
-#define                LCDDataLen                   8
-#define                HiTVDataLen                  12
-#define                TVDataLen                    12
-#define                LVDSCRT1Len_H                8
-#define                LVDSCRT1Len_V                7
-#define                LVDSDataLen                  6
-#define                LVDSDesDataLen               6
-#define                LCDDesDataLen                6
-#define                LVDSDesDataLen2              8
-#define                LCDDesDataLen2               8
-#define                CHTVRegLen                   16
-#define                CHLVRegLen                   12
-
-#define                StHiTVHT                     892
-#define                StHiTVVT                     1126
-#define                StHiTextTVHT                 1000
-#define                StHiTextTVVT                 1126
-#define                ExtHiTVHT                    2100
-#define                ExtHiTVVT                    1125
-#define                NTSCHT                       1716
-#define                NTSCVT                        525
-#define                NTSC1024x768HT               1908
-#define                NTSC1024x768VT                525
-#define                PALHT                        1728
-#define                PALVT                         625
-
-#define                YPbPrTV525iHT                1716            /* YPbPr */
-#define                YPbPrTV525iVT                 525
-#define                YPbPrTV525pHT                1716
-#define                YPbPrTV525pVT                 525
-#define                YPbPrTV750pHT                1650
-#define                YPbPrTV750pVT                 750
-
-#define                CRT2VCLKSel                  0xc0
-
-#define                CRT2Delay1                   0x04            /* XGI301 */
-#define                CRT2Delay2                   0x0A            /* 301B,302 */
-
-
-#define                VCLK25_175           0x00
-#define                VCLK28_322           0x01
-#define                VCLK31_5             0x02
-#define                VCLK36               0x03
-#define                VCLK40               0x04
-#define                VCLK43_163           0x05
-#define                VCLK44_9             0x06
-#define                VCLK49_5             0x07
-#define                VCLK50               0x08
-#define                VCLK52_406           0x09
-#define                VCLK56_25            0x0A
-#define                VCLK65               0x0B
-#define                VCLK67_765           0x0C
-#define                VCLK68_179           0x0D
-#define                VCLK72_852           0x0E
-#define                VCLK75               0x0F
-#define                VCLK75_8             0x10
-#define                VCLK78_75            0x11
-#define                VCLK79_411           0x12
-#define                VCLK83_95            0x13
-#define                VCLK84_8             0x14
-#define                VCLK86_6             0x15
-#define                VCLK94_5             0x16
-#define                VCLK104_998          0x17
-#define                VCLK105_882          0x18
-#define                VCLK108_2            0x19
-#define                VCLK109_175          0x1A
-#define                VCLK113_309          0x1B
-#define                VCLK116_406          0x1C
-#define                VCLK132_258          0x1D
-#define                VCLK135_5            0x1E
-#define                VCLK139_054          0x1F
-#define                VCLK157_5            0x20
-#define                VCLK162              0x21
-#define                VCLK175              0x22
-#define                VCLK189              0x23
-#define                VCLK194_4            0x24
-#define                VCLK202_5            0x25
-#define                VCLK229_5            0x26
-#define                VCLK234              0x27
-#define                VCLK252_699          0x28
-#define                VCLK254_817          0x29
-#define                VCLK265_728          0x2A
-#define                VCLK266_952          0x2B
-#define                VCLK269_655          0x2C
-#define                VCLK272_042          0x2D
-#define                VCLK277_015          0x2E
-#define                VCLK286_359          0x2F
-#define                VCLK291_132          0x30
-#define                VCLK291_766          0x31
-#define                VCLK309_789          0x32
-#define                VCLK315_195          0x33
-#define                VCLK323_586          0x34
-#define                VCLK330_615          0x35
-#define                VCLK332_177          0x36
-#define                VCLK340_477          0x37
-#define                VCLK375_847          0x38
-#define                VCLK388_631          0x39
-#define                VCLK125_999          0x51
-#define                VCLK148_5            0x52
-#define                VCLK178_992          0x54
-#define                VCLK217_325          0x55
-#define                VCLK299_505          0x56
-#define                YPbPr750pVCLK        0x57
-
-#define                TVVCLKDIV2              0x3A
-#define                TVVCLK                  0x3B
-#define                HiTVVCLKDIV2          0x3C
-#define                HiTVVCLK              0x3D
-#define                HiTVSimuVCLK          0x3E
-#define                HiTVTextVCLK          0x3F
-#define                VCLK39_77              0x40
+#define LCDDataLen           8
+#define HiTVDataLen          12
+#define TVDataLen            12
+#define LVDSCRT1Len_H        8
+#define LVDSCRT1Len_V        7
+#define LVDSDataLen          6
+#define LVDSDesDataLen       6
+#define LCDDesDataLen        6
+#define LVDSDesDataLen2      8
+#define LCDDesDataLen2       8
+#define CHTVRegLen           16
+#define CHLVRegLen           12
+
+#define StHiTVHT             892
+#define StHiTVVT             1126
+#define StHiTextTVHT         1000
+#define StHiTextTVVT         1126
+#define ExtHiTVHT            2100
+#define ExtHiTVVT            1125
+#define NTSCHT               1716
+#define NTSCVT                525
+#define NTSC1024x768HT       1908
+#define NTSC1024x768VT        525
+#define PALHT                1728
+#define PALVT                 625
+
+#define YPbPrTV525iHT        1716 /* YPbPr */
+#define YPbPrTV525iVT         525
+#define YPbPrTV525pHT        1716
+#define YPbPrTV525pVT         525
+#define YPbPrTV750pHT        1650
+#define YPbPrTV750pVT         750
+
+#define CRT2VCLKSel          0xc0
+
+#define CRT2Delay1           0x04 /* XGI301 */
+#define CRT2Delay2           0x0A /* 301B,302 */
+
+
+#define VCLK25_175           0x00
+#define VCLK28_322           0x01
+#define VCLK31_5             0x02
+#define VCLK36               0x03
+#define VCLK40               0x04
+#define VCLK43_163           0x05
+#define VCLK44_9             0x06
+#define VCLK49_5             0x07
+#define VCLK50               0x08
+#define VCLK52_406           0x09
+#define VCLK56_25            0x0A
+#define VCLK65               0x0B
+#define VCLK67_765           0x0C
+#define VCLK68_179           0x0D
+#define VCLK72_852           0x0E
+#define VCLK75               0x0F
+#define VCLK75_8             0x10
+#define VCLK78_75            0x11
+#define VCLK79_411           0x12
+#define VCLK83_95            0x13
+#define VCLK84_8             0x14
+#define VCLK86_6             0x15
+#define VCLK94_5             0x16
+#define VCLK104_998          0x17
+#define VCLK105_882          0x18
+#define VCLK108_2            0x19
+#define VCLK109_175          0x1A
+#define VCLK113_309          0x1B
+#define VCLK116_406          0x1C
+#define VCLK132_258          0x1D
+#define VCLK135_5            0x1E
+#define VCLK139_054          0x1F
+#define VCLK157_5            0x20
+#define VCLK162              0x21
+#define VCLK175              0x22
+#define VCLK189              0x23
+#define VCLK194_4            0x24
+#define VCLK202_5            0x25
+#define VCLK229_5            0x26
+#define VCLK234              0x27
+#define VCLK252_699          0x28
+#define VCLK254_817          0x29
+#define VCLK265_728          0x2A
+#define VCLK266_952          0x2B
+#define VCLK269_655          0x2C
+#define VCLK272_042          0x2D
+#define VCLK277_015          0x2E
+#define VCLK286_359          0x2F
+#define VCLK291_132          0x30
+#define VCLK291_766          0x31
+#define VCLK309_789          0x32
+#define VCLK315_195          0x33
+#define VCLK323_586          0x34
+#define VCLK330_615          0x35
+#define VCLK332_177          0x36
+#define VCLK340_477          0x37
+#define VCLK375_847          0x38
+#define VCLK388_631          0x39
+#define VCLK125_999          0x51
+#define VCLK148_5            0x52
+#define VCLK178_992          0x54
+#define VCLK217_325          0x55
+#define VCLK299_505          0x56
+#define YPbPr750pVCLK        0x57
+
+#define TVVCLKDIV2           0x3A
+#define TVVCLK               0x3B
+#define HiTVVCLKDIV2         0x3C
+#define HiTVVCLK             0x3D
+#define HiTVSimuVCLK         0x3E
+#define HiTVTextVCLK         0x3F
+#define VCLK39_77            0x40
 /* #define YPbPr750pVCLK 0x0F */
-#define                YPbPr525pVCLK           0x3A
+#define YPbPr525pVCLK           0x3A
 /* #define ;;YPbPr525iVCLK 0x3B */
 /* #define ;;YPbPr525iVCLK_2 0x3A */
-#define                NTSC1024VCLK         0x41
-#define                VCLK25_175_41        0x42                  /* ; ScaleLCD */
-#define                VCLK25_175_42        0x43
-#define                VCLK28_322_43        0x44
-#define                VCLK40_44            0x45
-#define                VCLKQVGA_1           0x46                   /* ; QVGA */
-#define                VCLKQVGA_2           0x47
-#define                VCLKQVGA_3           0x48
-#define                VCLK35_2             0x49                    /* ; 800x480 */
-#define                VCLK122_61           0x4A
-#define                VCLK80_350           0x4B
-#define                VCLK107_385          0x4C
-
-#define                CHTVVCLK30_2         0x50                 /* ;;CHTV */
-#define                CHTVVCLK28_1         0x51
-#define                CHTVVCLK43_6         0x52
-#define                CHTVVCLK26_4         0x53
-#define                CHTVVCLK24_6         0x54
-#define                CHTVVCLK47_8         0x55
-#define                CHTVVCLK31_5         0x56
-#define                CHTVVCLK26_2         0x57
-#define                CHTVVCLK39           0x58
-#define                CHTVVCLK36           0x59
-
-#define                CH7007TVVCLK30_2     0x00                 /* [Billy] 2007/05/18 For CH7007 */
-#define                CH7007TVVCLK28_1     0x01
-#define                CH7007TVVCLK43_6     0x02
-#define                CH7007TVVCLK26_4     0x03
-#define                CH7007TVVCLK24_6     0x04
-#define                CH7007TVVCLK47_8     0x05
-#define                CH7007TVVCLK31_5     0x06
-#define                CH7007TVVCLK26_2     0x07
-#define                CH7007TVVCLK39       0x08
-#define                CH7007TVVCLK36       0x09
-
-#define                RES320x200                   0x00
-#define                RES320x240                   0x01
-#define                RES400x300                   0x02
-#define                RES512x384                   0x03
-#define                RES640x400                   0x04
-#define                RES640x480x60                0x05
-#define                RES640x480x72                0x06
-#define                RES640x480x75                0x07
-#define                RES640x480x85                0x08
-#define                RES640x480x100               0x09
-#define                RES640x480x120               0x0A
-#define                RES640x480x160               0x0B
-#define                RES640x480x200               0x0C
-#define                RES800x600x56                0x0D
-#define                RES800x600x60                0x0E
-#define                RES800x600x72                0x0F
-#define                RES800x600x75                0x10
-#define                RES800x600x85                0x11
-#define                RES800x600x100               0x12
-#define                RES800x600x120               0x13
-#define                RES800x600x160               0x14
-#define                RES1024x768x43               0x15
-#define                RES1024x768x60               0x16
-#define                RES1024x768x70               0x17
-#define                RES1024x768x75               0x18
-#define                RES1024x768x85               0x19
-#define                RES1024x768x100              0x1A
-#define                RES1024x768x120              0x1B
-#define                RES1280x1024x43              0x1C
-#define                RES1280x1024x60              0x1D
-#define                RES1280x1024x75              0x1E
-#define                RES1280x1024x85              0x1F
-#define                RES1600x1200x60              0x20
-#define                RES1600x1200x65              0x21
-#define                RES1600x1200x70              0x22
-#define                RES1600x1200x75              0x23
-#define                RES1600x1200x85              0x24
-#define                RES1600x1200x100             0x25
-#define                RES1600x1200x120             0x26
-#define                RES1920x1440x60              0x27
-#define                RES1920x1440x65              0x28
-#define                RES1920x1440x70              0x29
-#define                RES1920x1440x75              0x2A
-#define                RES1920x1440x85              0x2B
-#define                RES1920x1440x100             0x2C
-#define                RES2048x1536x60              0x2D
-#define                RES2048x1536x65              0x2E
-#define                RES2048x1536x70              0x2F
-#define                RES2048x1536x75              0x30
-#define                RES2048x1536x85              0x31
-#define                RES800x480x60                0x32
-#define                RES800x480x75                0x33
-#define                RES800x480x85                0x34
-#define                RES1024x576x60               0x35
-#define                RES1024x576x75               0x36
-#define                RES1024x576x85               0x37
-#define                RES1280x720x60               0x38
-#define                RES1280x720x75               0x39
-#define                RES1280x720x85               0x3A
-#define                RES1280x960x60               0x3B
-#define                RES720x480x60                0x3C
-#define                RES720x576x56                0x3D
-#define                RES856x480x79I               0x3E
-#define                RES856x480x60                0x3F
-#define                RES1280x768x60               0x40
-#define                RES1400x1050x60              0x41
-#define                RES1152x864x60               0x42
-#define                RES1152x864x75               0x43
-#define                RES1024x768x160              0x44
-#define                RES1280x960x75               0x45
-#define                RES1280x960x85               0x46
-#define                RES1280x960x120              0x47
-
-#define        LFBDRAMTrap                  0x30
+#define NTSC1024VCLK         0x41
+#define VCLK25_175_41        0x42 /* ; ScaleLCD */
+#define VCLK25_175_42        0x43
+#define VCLK28_322_43        0x44
+#define VCLK40_44            0x45
+#define VCLKQVGA_1           0x46 /* ; QVGA */
+#define VCLKQVGA_2           0x47
+#define VCLKQVGA_3           0x48
+#define VCLK35_2             0x49 /* ; 800x480 */
+#define VCLK122_61           0x4A
+#define VCLK80_350           0x4B
+#define VCLK107_385          0x4C
+
+#define CHTVVCLK30_2         0x50 /* ;;CHTV */
+#define CHTVVCLK28_1         0x51
+#define CHTVVCLK43_6         0x52
+#define CHTVVCLK26_4         0x53
+#define CHTVVCLK24_6         0x54
+#define CHTVVCLK47_8         0x55
+#define CHTVVCLK31_5         0x56
+#define CHTVVCLK26_2         0x57
+#define CHTVVCLK39           0x58
+#define CHTVVCLK36           0x59
+
+#define CH7007TVVCLK30_2     0x00 /* [Billy] 2007/05/18 For CH7007 */
+#define CH7007TVVCLK28_1     0x01
+#define CH7007TVVCLK43_6     0x02
+#define CH7007TVVCLK26_4     0x03
+#define CH7007TVVCLK24_6     0x04
+#define CH7007TVVCLK47_8     0x05
+#define CH7007TVVCLK31_5     0x06
+#define CH7007TVVCLK26_2     0x07
+#define CH7007TVVCLK39       0x08
+#define CH7007TVVCLK36       0x09
+
+#define RES320x200           0x00
+#define RES320x240           0x01
+#define RES400x300           0x02
+#define RES512x384           0x03
+#define RES640x400           0x04
+#define RES640x480x60        0x05
+#define RES640x480x72        0x06
+#define RES640x480x75        0x07
+#define RES640x480x85        0x08
+#define RES640x480x100       0x09
+#define RES640x480x120       0x0A
+#define RES640x480x160       0x0B
+#define RES640x480x200       0x0C
+#define RES800x600x56        0x0D
+#define RES800x600x60        0x0E
+#define RES800x600x72        0x0F
+#define RES800x600x75        0x10
+#define RES800x600x85        0x11
+#define RES800x600x100       0x12
+#define RES800x600x120       0x13
+#define RES800x600x160       0x14
+#define RES1024x768x43       0x15
+#define RES1024x768x60       0x16
+#define RES1024x768x70       0x17
+#define RES1024x768x75       0x18
+#define RES1024x768x85       0x19
+#define RES1024x768x100      0x1A
+#define RES1024x768x120      0x1B
+#define RES1280x1024x43      0x1C
+#define RES1280x1024x60      0x1D
+#define RES1280x1024x75      0x1E
+#define RES1280x1024x85      0x1F
+#define RES1600x1200x60      0x20
+#define RES1600x1200x65      0x21
+#define RES1600x1200x70      0x22
+#define RES1600x1200x75      0x23
+#define RES1600x1200x85      0x24
+#define RES1600x1200x100     0x25
+#define RES1600x1200x120     0x26
+#define RES1920x1440x60      0x27
+#define RES1920x1440x65      0x28
+#define RES1920x1440x70      0x29
+#define RES1920x1440x75      0x2A
+#define RES1920x1440x85      0x2B
+#define RES1920x1440x100     0x2C
+#define RES2048x1536x60      0x2D
+#define RES2048x1536x65      0x2E
+#define RES2048x1536x70      0x2F
+#define RES2048x1536x75      0x30
+#define RES2048x1536x85      0x31
+#define RES800x480x60        0x32
+#define RES800x480x75        0x33
+#define RES800x480x85        0x34
+#define RES1024x576x60       0x35
+#define RES1024x576x75       0x36
+#define RES1024x576x85       0x37
+#define RES1280x720x60       0x38
+#define RES1280x720x75       0x39
+#define RES1280x720x85       0x3A
+#define RES1280x960x60       0x3B
+#define RES720x480x60        0x3C
+#define RES720x576x56        0x3D
+#define RES856x480x79I       0x3E
+#define RES856x480x60        0x3F
+#define RES1280x768x60       0x40
+#define RES1400x1050x60      0x41
+#define RES1152x864x60       0x42
+#define RES1152x864x75       0x43
+#define RES1024x768x160      0x44
+#define RES1280x960x75       0x45
+#define RES1280x960x85       0x46
+#define RES1280x960x120      0x47
+
+#define LFBDRAMTrap          0x30
 #endif
index d7c1b2ebed1713cef76a1f8fb7b569041e5651fc..7e1f76adf73360feed42eb2d39a541394599fde7 100644 (file)
@@ -1,5 +1,5 @@
 #include <linux/version.h>
-#include <asm/io.h>
+#include <linux/io.h>
 #include <linux/types.h>
 #include "XGIfb.h"
 
@@ -26,7 +26,9 @@ static unsigned char XGINew_Is301B(struct vb_device_info *pVBInfo)
                return 1;
 }
 
-static unsigned char XGINew_Sense(unsigned short tempbx, unsigned short tempcx, struct vb_device_info *pVBInfo)
+static unsigned char XGINew_Sense(unsigned short tempbx,
+                                 unsigned short tempcx,
+                                 struct vb_device_info *pVBInfo)
 {
        unsigned short temp, i, tempch;
 
@@ -50,7 +52,9 @@ static unsigned char XGINew_Sense(unsigned short tempbx, unsigned short tempcx,
                return 0;
 }
 
-static unsigned char XGINew_GetLCDDDCInfo(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo)
+static unsigned char
+XGINew_GetLCDDDCInfo(struct xgi_hw_device_info *HwDeviceExtension,
+                    struct vb_device_info *pVBInfo)
 {
        unsigned short temp;
 
@@ -154,7 +158,9 @@ static unsigned char XGINew_GetPanelID(struct vb_device_info *pVBInfo)
        }
 }
 
-static unsigned char XGINew_BridgeIsEnable(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo)
+static unsigned char
+XGINew_BridgeIsEnable(struct xgi_hw_device_info *HwDeviceExtension,
+                     struct vb_device_info *pVBInfo)
 {
        unsigned short flag;
 
@@ -170,7 +176,9 @@ static unsigned char XGINew_BridgeIsEnable(struct xgi_hw_device_info *HwDeviceEx
        return 0;
 }
 
-static unsigned char XGINew_SenseHiTV(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo)
+static unsigned char
+XGINew_SenseHiTV(struct xgi_hw_device_info *HwDeviceExtension,
+                struct vb_device_info *pVBInfo)
 {
        unsigned short tempbx, tempcx, temp, i, tempch;
 
@@ -238,21 +246,29 @@ static unsigned char XGINew_SenseHiTV(struct xgi_hw_device_info *HwDeviceExtensi
        }
 }
 
-void XGI_GetSenseStatus(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo)
+void XGI_GetSenseStatus(struct xgi_hw_device_info *HwDeviceExtension,
+                       struct vb_device_info *pVBInfo)
 {
-       unsigned short tempax = 0, tempbx, tempcx, temp, P2reg0 = 0, SenseModeNo = 0,
-                       OutputSelect = *pVBInfo->pOutputSelect, ModeIdIndex, i;
+       unsigned short  tempax = 0, tempbx, tempcx, temp,
+                       P2reg0 = 0, SenseModeNo = 0,
+                       OutputSelect = *pVBInfo->pOutputSelect,
+                       ModeIdIndex, i;
        pVBInfo->BaseAddr = (unsigned long) HwDeviceExtension->pjIOAddress;
 
        if (pVBInfo->IF_DEF_LVDS == 1) {
-               tempax = xgifb_reg_get(pVBInfo->P3c4, 0x1A); /* ynlai 02/27/2002 */
+               /* ynlai 02/27/2002 */
+               tempax = xgifb_reg_get(pVBInfo->P3c4, 0x1A);
                tempbx = xgifb_reg_get(pVBInfo->P3c4, 0x1B);
                tempax = ((tempax & 0xFE) >> 1) | (tempbx << 8);
                if (tempax == 0x00) { /* Get Panel id from DDC */
                        temp = XGINew_GetLCDDDCInfo(HwDeviceExtension, pVBInfo);
                        if (temp == 1) { /* LCD connect */
-                               xgifb_reg_and_or(pVBInfo->P3d4, 0x39, 0xFF, 0x01); /* set CR39 bit0="1" */
-                               xgifb_reg_and_or(pVBInfo->P3d4, 0x37, 0xEF, 0x00); /* clean CR37 bit4="0" */
+                               /* set CR39 bit0="1" */
+                               xgifb_reg_and_or(pVBInfo->P3d4,
+                                                0x39, 0xFF, 0x01);
+                               /* clean CR37 bit4="0" */
+                               xgifb_reg_and_or(pVBInfo->P3d4,
+                                                0x37, 0xEF, 0x00);
                                temp = LCDSense;
                        } else { /* LCD don't connect */
                                temp = 0;
@@ -273,25 +289,47 @@ void XGI_GetSenseStatus(struct xgi_hw_device_info *HwDeviceExtension, struct vb_
                        xgifb_reg_and_or(pVBInfo->P3d4, 0x32, 0xA0, temp);
                } else {
                        if (XGI_BridgeIsOn(pVBInfo)) {
-                               P2reg0 = xgifb_reg_get(pVBInfo->Part2Port, 0x00);
-                               if (!XGINew_BridgeIsEnable(HwDeviceExtension, pVBInfo)) {
+                               P2reg0 = xgifb_reg_get(pVBInfo->Part2Port,
+                                                      0x00);
+                               if (!XGINew_BridgeIsEnable(HwDeviceExtension,
+                                                          pVBInfo)) {
                                        SenseModeNo = 0x2e;
-                                       /* xgifb_reg_set(pVBInfo->P3d4, 0x30, 0x41); */
-                                       /* XGISetModeNew(HwDeviceExtension, 0x2e); // ynlai InitMode */
-
-                                       temp = XGI_SearchModeID(SenseModeNo, &ModeIdIndex, pVBInfo);
-                                       XGI_GetVGAType(HwDeviceExtension, pVBInfo);
+                               /* xgifb_reg_set(pVBInfo->P3d4, 0x30, 0x41);
+                                * XGISetModeNew(HwDeviceExtension, 0x2e);
+                                * // ynlai InitMode */
+
+                                       temp = XGI_SearchModeID(SenseModeNo,
+                                                               &ModeIdIndex,
+                                                               pVBInfo);
+                                       XGI_GetVGAType(HwDeviceExtension,
+                                                      pVBInfo);
                                        XGI_GetVBType(pVBInfo);
                                        pVBInfo->SetFlag = 0x00;
                                        pVBInfo->ModeType = ModeVGA;
-                                       pVBInfo->VBInfo = SetCRT2ToRAMDAC | LoadDACFlag | SetInSlaveMode;
-                                       XGI_GetLCDInfo(0x2e, ModeIdIndex, pVBInfo);
-                                       XGI_GetTVInfo(0x2e, ModeIdIndex, pVBInfo);
-                                       XGI_EnableBridge(HwDeviceExtension, pVBInfo);
-                                       XGI_SetCRT2Group301(SenseModeNo, HwDeviceExtension, pVBInfo);
-                                       XGI_SetCRT2ModeRegs(0x2e, HwDeviceExtension, pVBInfo);
-                                       /* XGI_DisableBridge( HwDeviceExtension, pVBInfo ) ; */
-                                       xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xDF, 0x20); /* Display Off 0212 */
+                                       pVBInfo->VBInfo = SetCRT2ToRAMDAC |
+                                                         LoadDACFlag |
+                                                         SetInSlaveMode;
+                                       XGI_GetLCDInfo(0x2e,
+                                                      ModeIdIndex,
+                                                      pVBInfo);
+                                       XGI_GetTVInfo(0x2e,
+                                                     ModeIdIndex,
+                                                     pVBInfo);
+                                       XGI_EnableBridge(HwDeviceExtension,
+                                                        pVBInfo);
+                                       XGI_SetCRT2Group301(SenseModeNo,
+                                                           HwDeviceExtension,
+                                                           pVBInfo);
+                                       XGI_SetCRT2ModeRegs(0x2e,
+                                                           HwDeviceExtension,
+                                                           pVBInfo);
+                                       /* XGI_DisableBridge(HwDeviceExtension,
+                                        *                   pVBInfo ) ; */
+                                       /* Display Off 0212 */
+                                       xgifb_reg_and_or(pVBInfo->P3c4,
+                                                        0x01,
+                                                        0xDF,
+                                                        0x20);
                                        for (i = 0; i < 20; i++)
                                                XGI_LongWait(pVBInfo);
                                }
@@ -304,29 +342,38 @@ void XGI_GetSenseStatus(struct xgi_hw_device_info *HwDeviceExtension, struct vb_
 
                                tempcx = 0x0E08;
                                if (XGINew_Sense(tempbx, tempcx, pVBInfo)) {
-                                       if (XGINew_Sense(tempbx, tempcx, pVBInfo))
+                                       if (XGINew_Sense(tempbx,
+                                                        tempcx,
+                                                        pVBInfo))
                                                tempax |= Monitor2Sense;
                                }
 
                                if (pVBInfo->VBType & VB_XGI301C)
-                                       xgifb_reg_or(pVBInfo->Part4Port, 0x0d, 0x04);
+                                       xgifb_reg_or(pVBInfo->Part4Port,
+                                                    0x0d,
+                                                    0x04);
 
-                               if (XGINew_SenseHiTV(HwDeviceExtension, pVBInfo)) { /* add by kuku for Multi-adapter sense HiTV */
+                               /* add by kuku for Multi-adapter sense HiTV */
+                               if (XGINew_SenseHiTV(HwDeviceExtension,
+                                                    pVBInfo)) {
                                        tempax |= HiTVSense;
                                        if ((pVBInfo->VBType & VB_XGI301C))
-                                               tempax ^= (HiTVSense | YPbPrSense);
+                                               tempax ^= (HiTVSense |
+                                                          YPbPrSense);
                                }
 
-                               if (!(tempax & (HiTVSense | YPbPrSense))) { /* start */
-
+                               /* start */
+                               if (!(tempax & (HiTVSense | YPbPrSense))) {
                                        tempbx = *pVBInfo->pYCSenseData;
-
                                        if (!(XGINew_Is301B(pVBInfo)))
                                                tempbx = *pVBInfo->pYCSenseData2;
-
                                        tempcx = 0x0604;
-                                       if (XGINew_Sense(tempbx, tempcx, pVBInfo)) {
-                                               if (XGINew_Sense(tempbx, tempcx, pVBInfo))
+                                       if (XGINew_Sense(tempbx,
+                                                        tempcx,
+                                                        pVBInfo)) {
+                                               if (XGINew_Sense(tempbx,
+                                                                tempcx,
+                                                                pVBInfo))
                                                        tempax |= SVIDEOSense;
                                        }
 
@@ -337,8 +384,12 @@ void XGI_GetSenseStatus(struct xgi_hw_device_info *HwDeviceExtension, struct vb_
                                                        tempbx = *pVBInfo->pVideoSenseData2;
 
                                                tempcx = 0x0804;
-                                               if (XGINew_Sense(tempbx, tempcx, pVBInfo)) {
-                                                       if (XGINew_Sense(tempbx, tempcx, pVBInfo))
+                                               if (XGINew_Sense(tempbx,
+                                                                tempcx,
+                                                                pVBInfo)) {
+                                                       if (XGINew_Sense(tempbx,
+                                                                        tempcx,
+                                                                        pVBInfo))
                                                                tempax |= AVIDEOSense;
                                                }
                                        } else {
@@ -349,7 +400,9 @@ void XGI_GetSenseStatus(struct xgi_hw_device_info *HwDeviceExtension, struct vb_
                                                                tempbx = *pVBInfo->pVideoSenseData2;
 
                                                        tempcx = 0x0804;
-                                                       if (XGINew_Sense(tempbx, tempcx, pVBInfo)) {
+                                                       if (XGINew_Sense(tempbx,
+                                                                        tempcx,
+                                                                        pVBInfo)) {
                                                                if (XGINew_Sense(tempbx, tempcx, pVBInfo))
                                                                        tempax |= AVIDEOSense;
                                                        }
@@ -370,7 +423,9 @@ void XGI_GetSenseStatus(struct xgi_hw_device_info *HwDeviceExtension, struct vb_
 
                        if (!(P2reg0 & 0x20)) {
                                pVBInfo->VBInfo = DisableCRT2Display;
-                               /* XGI_SetCRT2Group301(SenseModeNo, HwDeviceExtension, pVBInfo); */
+                               /* XGI_SetCRT2Group301(SenseModeNo,
+                                *                     HwDeviceExtension,
+                                *                     pVBInfo); */
                        }
                }
        }
@@ -378,7 +433,8 @@ void XGI_GetSenseStatus(struct xgi_hw_device_info *HwDeviceExtension, struct vb_
 
 }
 
-unsigned short XGINew_SenseLCD(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo)
+unsigned short XGINew_SenseLCD(struct xgi_hw_device_info *HwDeviceExtension,
+                              struct vb_device_info *pVBInfo)
 {
        /* unsigned short SoftSetting ; */
        unsigned short temp;
index cabe365579c5f13761bc63b9dacaf5cc74bf71d1..814a446b70c80ea21e98f1765317af94e227bd27 100644 (file)
@@ -1,27 +1,28 @@
-#ifndef  _VBEXT_
-#define  _VBEXT_
+#ifndef _VBEXT_
+#define _VBEXT_
 
 struct DWORDREGS {
-    unsigned long    Eax, Ebx, Ecx, Edx, Esi, Edi, Ebp;
+       unsigned long Eax, Ebx, Ecx, Edx, Esi, Edi, Ebp;
 };
 
 struct WORDREGS {
-    unsigned short ax, hi_ax, bx, hi_bx, cx, hi_cx, dx, hi_dx, si,
-           hi_si, di, hi_di, bp, hi_bp;
+       unsigned short  ax, hi_ax, bx, hi_bx, cx, hi_cx, dx, hi_dx, si,
+                       hi_si, di, hi_di, bp, hi_bp;
 };
 
 struct BYTEREGS {
-     unsigned char al, ah, hi_al, hi_ah, bl, bh, hi_bl, hi_bh, cl, ch,
-            hi_cl, hi_ch, dl, dh, hi_dl, hi_dh;
+       unsigned char   al, ah, hi_al, hi_ah, bl, bh, hi_bl, hi_bh, cl, ch,
+                       hi_cl, hi_ch, dl, dh, hi_dl, hi_dh;
 };
 
-typedef union   _X86_REGS    {
-    struct  DWORDREGS e;
-    struct  WORDREGS x;
-    struct  BYTEREGS h;
+typedef union _X86_REGS {
+       struct  DWORDREGS e;
+       struct  WORDREGS x;
+       struct  BYTEREGS h;
 } X86_REGS, *PX86_REGS;
 
-extern   void     XGI_GetSenseStatus(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo);
+extern void XGI_GetSenseStatus(struct xgi_hw_device_info *HwDeviceExtension,
+                              struct vb_device_info *pVBInfo);
 extern unsigned short XGINew_SenseLCD(struct xgi_hw_device_info *,
                                      struct vb_device_info *pVBInfo);
 
index 61d137098aa139e3b47841c2b06a91389099902b..33c6876d2a805095c2e19d8b1bc13d2478776a3c 100644 (file)
@@ -13,7 +13,7 @@
 #include "vb_ext.h"
 
 
-#include <asm/io.h>
+#include <linux/io.h>
 
 static unsigned char XGINew_ChannelAB, XGINew_DataBusWidth;
 
@@ -39,8 +39,9 @@ static unsigned short XGINew_DDRDRAM_TYPE20[12][5] = {
 
 static int XGINew_RAMType;
 
-static unsigned char XGINew_GetXG20DRAMType(struct xgi_hw_device_info *HwDeviceExtension,
-                                       struct vb_device_info *pVBInfo)
+static unsigned char
+XGINew_GetXG20DRAMType(struct xgi_hw_device_info *HwDeviceExtension,
+                      struct vb_device_info *pVBInfo)
 {
        unsigned char data, temp;
 
@@ -50,10 +51,9 @@ static unsigned char XGINew_GetXG20DRAMType(struct xgi_hw_device_info *HwDeviceE
                        return data;
                } else {
                        data = xgifb_reg_get(pVBInfo->P3c4, 0x39) & 0x02;
-
                        if (data == 0)
-                               data = (xgifb_reg_get(pVBInfo->P3c4, 0x3A) & 0x02) >> 1;
-
+                               data = (xgifb_reg_get(pVBInfo->P3c4, 0x3A) &
+                                      0x02) >> 1;
                        return data;
                }
        } else if (HwDeviceExtension->jChipType == XG27) {
@@ -62,19 +62,22 @@ static unsigned char XGINew_GetXG20DRAMType(struct xgi_hw_device_info *HwDeviceE
                        return data;
                }
                temp = xgifb_reg_get(pVBInfo->P3c4, 0x3B);
-
-               if ((temp & 0x88) == 0x80) /* SR3B[7][3]MAA15 MAA11 (Power on Trapping) */
+               /* SR3B[7][3]MAA15 MAA11 (Power on Trapping) */
+               if ((temp & 0x88) == 0x80)
                        data = 0; /* DDR */
                else
                        data = 1; /* DDRII */
                return data;
        } else if (HwDeviceExtension->jChipType == XG21) {
-               xgifb_reg_and(pVBInfo->P3d4, 0xB4, ~0x02); /* Independent GPIO control */
+               /* Independent GPIO control */
+               xgifb_reg_and(pVBInfo->P3d4, 0xB4, ~0x02);
                udelay(800);
                xgifb_reg_or(pVBInfo->P3d4, 0x4A, 0x80); /* Enable GPIOH read */
-               temp = xgifb_reg_get(pVBInfo->P3d4, 0x48); /* GPIOF 0:DVI 1:DVO */
+               /* GPIOF 0:DVI 1:DVO */
+               temp = xgifb_reg_get(pVBInfo->P3d4, 0x48);
                /* HOTPLUG_SUPPORT */
-               /* for current XG20 & XG21, GPIOH is floating, driver will fix DDR temporarily */
+               /* for current XG20 & XG21, GPIOH is floating, driver will
+                * fix DDR temporarily */
                if (temp & 0x01) /* DVI read GPIOH */
                        data = 1; /* DDRII */
                else
@@ -92,7 +95,8 @@ static unsigned char XGINew_GetXG20DRAMType(struct xgi_hw_device_info *HwDeviceE
        }
 }
 
-static void XGINew_DDR1x_MRS_340(unsigned long P3c4, struct vb_device_info *pVBInfo)
+static void XGINew_DDR1x_MRS_340(unsigned long P3c4,
+                                struct vb_device_info *pVBInfo)
 {
        xgifb_reg_set(P3c4, 0x18, 0x01);
        xgifb_reg_set(P3c4, 0x19, 0x20);
@@ -126,24 +130,42 @@ static void XGINew_SetMemoryClock(struct xgi_hw_device_info *HwDeviceExtension,
                struct vb_device_info *pVBInfo)
 {
 
-       xgifb_reg_set(pVBInfo->P3c4, 0x28, pVBInfo->MCLKData[XGINew_RAMType].SR28);
-       xgifb_reg_set(pVBInfo->P3c4, 0x29, pVBInfo->MCLKData[XGINew_RAMType].SR29);
-       xgifb_reg_set(pVBInfo->P3c4, 0x2A, pVBInfo->MCLKData[XGINew_RAMType].SR2A);
-
-       xgifb_reg_set(pVBInfo->P3c4, 0x2E, pVBInfo->ECLKData[XGINew_RAMType].SR2E);
-       xgifb_reg_set(pVBInfo->P3c4, 0x2F, pVBInfo->ECLKData[XGINew_RAMType].SR2F);
-       xgifb_reg_set(pVBInfo->P3c4, 0x30, pVBInfo->ECLKData[XGINew_RAMType].SR30);
-
-       /* [Vicent] 2004/07/07, When XG42 ECLK = MCLK = 207MHz, Set SR32 D[1:0] = 10b */
-       /* [Hsuan] 2004/08/20, Modify SR32 value, when MCLK=207MHZ, ELCK=250MHz, Set SR32 D[1:0] = 10b */
+       xgifb_reg_set(pVBInfo->P3c4,
+                     0x28,
+                     pVBInfo->MCLKData[XGINew_RAMType].SR28);
+       xgifb_reg_set(pVBInfo->P3c4,
+                     0x29,
+                     pVBInfo->MCLKData[XGINew_RAMType].SR29);
+       xgifb_reg_set(pVBInfo->P3c4,
+                     0x2A,
+                     pVBInfo->MCLKData[XGINew_RAMType].SR2A);
+
+       xgifb_reg_set(pVBInfo->P3c4,
+                     0x2E,
+                     pVBInfo->ECLKData[XGINew_RAMType].SR2E);
+       xgifb_reg_set(pVBInfo->P3c4,
+                     0x2F,
+                     pVBInfo->ECLKData[XGINew_RAMType].SR2F);
+       xgifb_reg_set(pVBInfo->P3c4,
+                     0x30,
+                     pVBInfo->ECLKData[XGINew_RAMType].SR30);
+
+       /* [Vicent] 2004/07/07,
+        * When XG42 ECLK = MCLK = 207MHz, Set SR32 D[1:0] = 10b */
+       /* [Hsuan] 2004/08/20,
+        * Modify SR32 value, when MCLK=207MHZ, ELCK=250MHz,
+        * Set SR32 D[1:0] = 10b */
        if (HwDeviceExtension->jChipType == XG42) {
-               if ((pVBInfo->MCLKData[XGINew_RAMType].SR28 == 0x1C)
-                               && (pVBInfo->MCLKData[XGINew_RAMType].SR29 == 0x01)
-                               && (((pVBInfo->ECLKData[XGINew_RAMType].SR2E == 0x1C)
-                                               && (pVBInfo->ECLKData[XGINew_RAMType].SR2F == 0x01))
-                                       || ((pVBInfo->ECLKData[XGINew_RAMType].SR2E == 0x22)
-                                               && (pVBInfo->ECLKData[XGINew_RAMType].SR2F == 0x01))))
-                       xgifb_reg_set(pVBInfo->P3c4, 0x32, ((unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x32) & 0xFC) | 0x02);
+               if ((pVBInfo->MCLKData[XGINew_RAMType].SR28 == 0x1C) &&
+                   (pVBInfo->MCLKData[XGINew_RAMType].SR29 == 0x01) &&
+                   (((pVBInfo->ECLKData[XGINew_RAMType].SR2E == 0x1C) &&
+                     (pVBInfo->ECLKData[XGINew_RAMType].SR2F == 0x01)) ||
+                    ((pVBInfo->ECLKData[XGINew_RAMType].SR2E == 0x22) &&
+                     (pVBInfo->ECLKData[XGINew_RAMType].SR2F == 0x01))))
+                       xgifb_reg_set(pVBInfo->P3c4,
+                                     0x32,
+                                     ((unsigned char) xgifb_reg_get(
+                                         pVBInfo->P3c4, 0x32) & 0xFC) | 0x02);
        }
 }
 
@@ -152,7 +174,8 @@ static void XGINew_DDRII_Bootup_XG27(
                        unsigned long P3c4, struct vb_device_info *pVBInfo)
 {
        unsigned long P3d4 = P3c4 + 0x10;
-       XGINew_RAMType = (int) XGINew_GetXG20DRAMType(HwDeviceExtension, pVBInfo);
+       XGINew_RAMType = (int) XGINew_GetXG20DRAMType(HwDeviceExtension,
+                                                     pVBInfo);
        XGINew_SetMemoryClock(HwDeviceExtension, pVBInfo);
 
        /* Set Double Frequency */
@@ -216,7 +239,8 @@ static void XGINew_DDRII_Bootup_XG27(
        xgifb_reg_set(P3c4, 0x16, 0xA0); /* Set SR16 */
        udelay(15);
 
-       xgifb_reg_set(P3c4, 0x1B, 0x04); /* Set SR1B refresh control 000:close; 010:open */
+       /* Set SR1B refresh control 000:close; 010:open */
+       xgifb_reg_set(P3c4, 0x1B, 0x04);
        udelay(200);
 
 }
@@ -226,7 +250,8 @@ static void XGINew_DDR2_MRS_XG20(struct xgi_hw_device_info *HwDeviceExtension,
 {
        unsigned long P3d4 = P3c4 + 0x10;
 
-       XGINew_RAMType = (int) XGINew_GetXG20DRAMType(HwDeviceExtension, pVBInfo);
+       XGINew_RAMType = (int) XGINew_GetXG20DRAMType(HwDeviceExtension,
+                                                     pVBInfo);
        XGINew_SetMemoryClock(HwDeviceExtension, pVBInfo);
 
        xgifb_reg_set(P3d4, 0x97, 0x11); /* CR97 */
@@ -268,9 +293,9 @@ static void XGINew_DDR2_MRS_XG20(struct xgi_hw_device_info *HwDeviceExtension,
        udelay(200);
 }
 
-static void XGINew_DDR1x_MRS_XG20(unsigned long P3c4, struct vb_device_info *pVBInfo)
+static void XGINew_DDR1x_MRS_XG20(unsigned long P3c4,
+                                 struct vb_device_info *pVBInfo)
 {
-
        xgifb_reg_set(P3c4, 0x18, 0x01);
        xgifb_reg_set(P3c4, 0x19, 0x40);
        xgifb_reg_set(P3c4, 0x16, 0x00);
@@ -306,9 +331,15 @@ static void XGINew_DDR1x_DefaultRegister(
 
        if (HwDeviceExtension->jChipType >= XG20) {
                XGINew_SetMemoryClock(HwDeviceExtension, pVBInfo);
-               xgifb_reg_set(P3d4, 0x82, pVBInfo->CR40[11][XGINew_RAMType]); /* CR82 */
-               xgifb_reg_set(P3d4, 0x85, pVBInfo->CR40[12][XGINew_RAMType]); /* CR85 */
-               xgifb_reg_set(P3d4, 0x86, pVBInfo->CR40[13][XGINew_RAMType]); /* CR86 */
+               xgifb_reg_set(P3d4,
+                             0x82,
+                             pVBInfo->CR40[11][XGINew_RAMType]); /* CR82 */
+               xgifb_reg_set(P3d4,
+                             0x85,
+                             pVBInfo->CR40[12][XGINew_RAMType]); /* CR85 */
+               xgifb_reg_set(P3d4,
+                             0x86,
+                             pVBInfo->CR40[13][XGINew_RAMType]); /* CR86 */
 
                xgifb_reg_set(P3d4, 0x98, 0x01);
                xgifb_reg_set(P3d4, 0x9A, 0x02);
@@ -320,24 +351,46 @@ static void XGINew_DDR1x_DefaultRegister(
                switch (HwDeviceExtension->jChipType) {
                case XG41:
                case XG42:
-                       xgifb_reg_set(P3d4, 0x82, pVBInfo->CR40[11][XGINew_RAMType]); /* CR82 */
-                       xgifb_reg_set(P3d4, 0x85, pVBInfo->CR40[12][XGINew_RAMType]); /* CR85 */
-                       xgifb_reg_set(P3d4, 0x86, pVBInfo->CR40[13][XGINew_RAMType]); /* CR86 */
+                       /* CR82 */
+                       xgifb_reg_set(P3d4,
+                                     0x82,
+                                     pVBInfo->CR40[11][XGINew_RAMType]);
+                       /* CR85 */
+                       xgifb_reg_set(P3d4,
+                                     0x85,
+                                     pVBInfo->CR40[12][XGINew_RAMType]);
+                       /* CR86 */
+                       xgifb_reg_set(P3d4,
+                                     0x86,
+                                     pVBInfo->CR40[13][XGINew_RAMType]);
                        break;
                default:
                        xgifb_reg_set(P3d4, 0x82, 0x88);
                        xgifb_reg_set(P3d4, 0x86, 0x00);
-                       xgifb_reg_get(P3d4, 0x86); /* Insert read command for delay */
+                       /* Insert read command for delay */
+                       xgifb_reg_get(P3d4, 0x86);
                        xgifb_reg_set(P3d4, 0x86, 0x88);
                        xgifb_reg_get(P3d4, 0x86);
-                       xgifb_reg_set(P3d4, 0x86, pVBInfo->CR40[13][XGINew_RAMType]);
+                       xgifb_reg_set(P3d4,
+                                     0x86,
+                                     pVBInfo->CR40[13][XGINew_RAMType]);
                        xgifb_reg_set(P3d4, 0x82, 0x77);
                        xgifb_reg_set(P3d4, 0x85, 0x00);
-                       xgifb_reg_get(P3d4, 0x85); /* Insert read command for delay */
+
+                       /* Insert read command for delay */
+                       xgifb_reg_get(P3d4, 0x85);
                        xgifb_reg_set(P3d4, 0x85, 0x88);
-                       xgifb_reg_get(P3d4, 0x85); /* Insert read command for delay */
-                       xgifb_reg_set(P3d4, 0x85, pVBInfo->CR40[12][XGINew_RAMType]); /* CR85 */
-                       xgifb_reg_set(P3d4, 0x82, pVBInfo->CR40[11][XGINew_RAMType]); /* CR82 */
+
+                       /* Insert read command for delay */
+                       xgifb_reg_get(P3d4, 0x85);
+                       /* CR85 */
+                       xgifb_reg_set(P3d4,
+                                     0x85,
+                                     pVBInfo->CR40[12][XGINew_RAMType]);
+                       /* CR82 */
+                       xgifb_reg_set(P3d4,
+                                     0x82,
+                                     pVBInfo->CR40[11][XGINew_RAMType]);
                        break;
                }
 
@@ -354,13 +407,15 @@ static void XGINew_DDR2_DefaultRegister(
 {
        unsigned long P3d4 = Port, P3c4 = Port - 0x10;
 
-       /* keep following setting sequence, each setting in the same reg insert idle */
+       /* keep following setting sequence, each setting in
+        * the same reg insert idle */
        xgifb_reg_set(P3d4, 0x82, 0x77);
        xgifb_reg_set(P3d4, 0x86, 0x00);
        xgifb_reg_get(P3d4, 0x86); /* Insert read command for delay */
        xgifb_reg_set(P3d4, 0x86, 0x88);
        xgifb_reg_get(P3d4, 0x86); /* Insert read command for delay */
-       xgifb_reg_set(P3d4, 0x86, pVBInfo->CR40[13][XGINew_RAMType]); /* CR86 */
+       /* CR86 */
+       xgifb_reg_set(P3d4, 0x86, pVBInfo->CR40[13][XGINew_RAMType]);
        xgifb_reg_set(P3d4, 0x82, 0x77);
        xgifb_reg_set(P3d4, 0x85, 0x00);
        xgifb_reg_get(P3d4, 0x85); /* Insert read command for delay */
@@ -368,7 +423,8 @@ static void XGINew_DDR2_DefaultRegister(
        xgifb_reg_get(P3d4, 0x85); /* Insert read command for delay */
        xgifb_reg_set(P3d4, 0x85, pVBInfo->CR40[12][XGINew_RAMType]); /* CR85 */
        if (HwDeviceExtension->jChipType == XG27)
-               xgifb_reg_set(P3d4, 0x82, pVBInfo->CR40[11][XGINew_RAMType]); /* CR82 */
+               /* CR82 */
+               xgifb_reg_set(P3d4, 0x82, pVBInfo->CR40[11][XGINew_RAMType]);
        else
                xgifb_reg_set(P3d4, 0x82, 0xA8); /* CR82 */
 
@@ -395,12 +451,14 @@ static void XGINew_SetDRAMDefaultRegister340(
 
        temp2 = 0;
        for (i = 0; i < 4; i++) {
-               temp = pVBInfo->CR6B[XGINew_RAMType][i]; /* CR6B DQS fine tune delay */
+               /* CR6B DQS fine tune delay */
+               temp = pVBInfo->CR6B[XGINew_RAMType][i];
                for (j = 0; j < 4; j++) {
                        temp1 = ((temp >> (2 * j)) & 0x03) << 2;
                        temp2 |= temp1;
                        xgifb_reg_set(P3d4, 0x6B, temp2);
-                       xgifb_reg_get(P3d4, 0x6B); /* Insert read command for delay */
+                       /* Insert read command for delay */
+                       xgifb_reg_get(P3d4, 0x6B);
                        temp2 &= 0xF0;
                        temp2 += 0x10;
                }
@@ -408,12 +466,14 @@ static void XGINew_SetDRAMDefaultRegister340(
 
        temp2 = 0;
        for (i = 0; i < 4; i++) {
-               temp = pVBInfo->CR6E[XGINew_RAMType][i]; /* CR6E DQM fine tune delay */
+               /* CR6E DQM fine tune delay */
+               temp = pVBInfo->CR6E[XGINew_RAMType][i];
                for (j = 0; j < 4; j++) {
                        temp1 = ((temp >> (2 * j)) & 0x03) << 2;
                        temp2 |= temp1;
                        xgifb_reg_set(P3d4, 0x6E, temp2);
-                       xgifb_reg_get(P3d4, 0x6E); /* Insert read command for delay */
+                       /* Insert read command for delay */
+                       xgifb_reg_get(P3d4, 0x6E);
                        temp2 &= 0xF0;
                        temp2 += 0x10;
                }
@@ -421,15 +481,18 @@ static void XGINew_SetDRAMDefaultRegister340(
 
        temp3 = 0;
        for (k = 0; k < 4; k++) {
-               xgifb_reg_and_or(P3d4, 0x6E, 0xFC, temp3); /* CR6E_D[1:0] select channel */
+               /* CR6E_D[1:0] select channel */
+               xgifb_reg_and_or(P3d4, 0x6E, 0xFC, temp3);
                temp2 = 0;
                for (i = 0; i < 8; i++) {
-                       temp = pVBInfo->CR6F[XGINew_RAMType][8 * k + i]; /* CR6F DQ fine tune delay */
+                       /* CR6F DQ fine tune delay */
+                       temp = pVBInfo->CR6F[XGINew_RAMType][8 * k + i];
                        for (j = 0; j < 4; j++) {
                                temp1 = (temp >> (2 * j)) & 0x03;
                                temp2 |= temp1;
                                xgifb_reg_set(P3d4, 0x6F, temp2);
-                               xgifb_reg_get(P3d4, 0x6F); /* Insert read command for delay */
+                               /* Insert read command for delay */
+                               xgifb_reg_get(P3d4, 0x6F);
                                temp2 &= 0xF8;
                                temp2 += 0x08;
                        }
@@ -441,7 +504,8 @@ static void XGINew_SetDRAMDefaultRegister340(
        xgifb_reg_set(P3d4, 0x81, pVBInfo->CR40[10][XGINew_RAMType]); /* CR81 */
 
        temp2 = 0x80;
-       temp = pVBInfo->CR89[XGINew_RAMType][0]; /* CR89 terminator type select */
+       /* CR89 terminator type select */
+       temp = pVBInfo->CR89[XGINew_RAMType][0];
        for (j = 0; j < 4; j++) {
                temp1 = (temp >> (2 * j)) & 0x03;
                temp2 |= temp1;
@@ -468,19 +532,20 @@ static void XGINew_SetDRAMDefaultRegister340(
        if (HwDeviceExtension->jChipType == XG27)
                xgifb_reg_set(P3d4, 0x8F, *pVBInfo->pCR8F); /* CR8F */
 
-       for (j = 0; j <= 6; j++)
+       for (j = 0; j <= 6; j++) /* CR90 - CR96 */
                xgifb_reg_set(P3d4, (0x90 + j),
-                               pVBInfo->CR40[14 + j][XGINew_RAMType]); /* CR90 - CR96 */
+                               pVBInfo->CR40[14 + j][XGINew_RAMType]);
 
-       for (j = 0; j <= 2; j++)
+       for (j = 0; j <= 2; j++) /* CRC3 - CRC5 */
                xgifb_reg_set(P3d4, (0xC3 + j),
-                               pVBInfo->CR40[21 + j][XGINew_RAMType]); /* CRC3 - CRC5 */
+                               pVBInfo->CR40[21 + j][XGINew_RAMType]);
 
-       for (j = 0; j < 2; j++)
+       for (j = 0; j < 2; j++) /* CR8A - CR8B */
                xgifb_reg_set(P3d4, (0x8A + j),
-                               pVBInfo->CR40[1 + j][XGINew_RAMType]); /* CR8A - CR8B */
+                               pVBInfo->CR40[1 + j][XGINew_RAMType]);
 
-       if ((HwDeviceExtension->jChipType == XG41) || (HwDeviceExtension->jChipType == XG42))
+       if ((HwDeviceExtension->jChipType == XG41) ||
+           (HwDeviceExtension->jChipType == XG42))
                xgifb_reg_set(P3d4, 0x8C, 0x87);
 
        xgifb_reg_set(P3d4, 0x59, pVBInfo->CR40[4][XGINew_RAMType]); /* CR59 */
@@ -550,7 +615,10 @@ static unsigned short XGINew_SetDRAMSizeReg(int index,
                memsize = data >> 4;
 
                /* [2004/03/25] Vicent, Fix DRAM Sizing Error */
-               xgifb_reg_set(pVBInfo->P3c4, 0x14, (xgifb_reg_get(pVBInfo->P3c4, 0x14) & 0x0F) | (data & 0xF0));
+               xgifb_reg_set(pVBInfo->P3c4,
+                             0x14,
+                             (xgifb_reg_get(pVBInfo->P3c4, 0x14) & 0x0F) |
+                              (data & 0xF0));
 
                /* data |= XGINew_ChannelAB << 2; */
                /* data |= (XGINew_DataBusWidth / 64) << 1; */
@@ -591,7 +659,10 @@ static unsigned short XGINew_SetDRAMSize20Reg(int index,
                memsize = data >> 4;
 
                /* [2004/03/25] Vicent, Fix DRAM Sizing Error */
-               xgifb_reg_set(pVBInfo->P3c4, 0x14, (xgifb_reg_get(pVBInfo->P3c4, 0x14) & 0x0F) | (data & 0xF0));
+               xgifb_reg_set(pVBInfo->P3c4,
+                             0x14,
+                             (xgifb_reg_get(pVBInfo->P3c4, 0x14) & 0x0F) |
+                               (data & 0xF0));
                udelay(15);
 
                /* data |= XGINew_ChannelAB << 2; */
@@ -617,7 +688,8 @@ static int XGINew_ReadWriteRest(unsigned short StopAddr,
                *((unsigned long *) (pVBInfo->FBAddr + Position)) = Position;
        }
 
-       udelay(500); /* [Vicent] 2004/04/16. Fix #1759 Memory Size error in Multi-Adapter. */
+       udelay(500); /* [Vicent] 2004/04/16.
+                       Fix #1759 Memory Size error in Multi-Adapter. */
 
        Position = 0;
 
@@ -626,7 +698,8 @@ static int XGINew_ReadWriteRest(unsigned short StopAddr,
 
        for (i = StartAddr; i <= StopAddr; i++) {
                Position = 1 << i;
-               if ((*(unsigned long *) (pVBInfo->FBAddr + Position)) != Position)
+               if ((*(unsigned long *) (pVBInfo->FBAddr + Position)) !=
+                   Position)
                        return 0;
        }
        return 1;
@@ -665,67 +738,96 @@ static void XGINew_CheckChannel(struct xgi_hw_device_info *HwDeviceExtension,
                                        > 0x1000000) {
 
                                XGINew_DataBusWidth = 32; /* 32 bits */
-                               xgifb_reg_set(pVBInfo->P3c4, 0x13, 0xB1); /* 22bit + 2 rank + 32bit */
+                               /* 22bit + 2 rank + 32bit */
+                               xgifb_reg_set(pVBInfo->P3c4, 0x13, 0xB1);
                                xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x52);
                                udelay(15);
 
                                if (XGINew_ReadWriteRest(24, 23, pVBInfo) == 1)
                                        return;
 
-                               if ((HwDeviceExtension->ulVideoMemorySize - 1) > 0x800000) {
-                                       xgifb_reg_set(pVBInfo->P3c4, 0x13, 0x31); /* 22bit + 1 rank + 32bit */
-                                       xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x42);
+                               if ((HwDeviceExtension->ulVideoMemorySize - 1) >
+                                   0x800000) {
+                                       /* 22bit + 1 rank + 32bit */
+                                       xgifb_reg_set(pVBInfo->P3c4,
+                                                     0x13,
+                                                     0x31);
+                                       xgifb_reg_set(pVBInfo->P3c4,
+                                                     0x14,
+                                                     0x42);
                                        udelay(15);
 
-                                       if (XGINew_ReadWriteRest(23, 23, pVBInfo) == 1)
+                                       if (XGINew_ReadWriteRest(23,
+                                                                23,
+                                                                pVBInfo) == 1)
                                                return;
                                }
                        }
 
-                       if ((HwDeviceExtension->ulVideoMemorySize - 1) > 0x800000) {
+                       if ((HwDeviceExtension->ulVideoMemorySize - 1) >
+                           0x800000) {
                                XGINew_DataBusWidth = 16; /* 16 bits */
-                               xgifb_reg_set(pVBInfo->P3c4, 0x13, 0xB1); /* 22bit + 2 rank + 16bit */
+                               /* 22bit + 2 rank + 16bit */
+                               xgifb_reg_set(pVBInfo->P3c4, 0x13, 0xB1);
                                xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x41);
                                udelay(15);
 
                                if (XGINew_ReadWriteRest(23, 22, pVBInfo) == 1)
                                        return;
                                else
-                                       xgifb_reg_set(pVBInfo->P3c4, 0x13, 0x31);
+                                       xgifb_reg_set(pVBInfo->P3c4,
+                                                     0x13,
+                                                     0x31);
                                udelay(15);
                        }
 
                } else { /* Dual_16_8 */
-                       if ((HwDeviceExtension->ulVideoMemorySize - 1) > 0x800000) {
-
+                       if ((HwDeviceExtension->ulVideoMemorySize - 1) >
+                           0x800000) {
                                XGINew_DataBusWidth = 16; /* 16 bits */
-                               xgifb_reg_set(pVBInfo->P3c4, 0x13, 0xB1); /* (0x31:12x8x2) 22bit + 2 rank */
-                               xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x41); /* 0x41:16Mx16 bit*/
+                               /* (0x31:12x8x2) 22bit + 2 rank */
+                               xgifb_reg_set(pVBInfo->P3c4, 0x13, 0xB1);
+                               /* 0x41:16Mx16 bit*/
+                               xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x41);
                                udelay(15);
 
                                if (XGINew_ReadWriteRest(23, 22, pVBInfo) == 1)
                                        return;
 
-                               if ((HwDeviceExtension->ulVideoMemorySize - 1) > 0x400000) {
-                                       xgifb_reg_set(pVBInfo->P3c4, 0x13, 0x31); /* (0x31:12x8x2) 22bit + 1 rank */
-                                       xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x31); /* 0x31:8Mx16 bit*/
+                               if ((HwDeviceExtension->ulVideoMemorySize - 1) >
+                                   0x400000) {
+                                       /* (0x31:12x8x2) 22bit + 1 rank */
+                                       xgifb_reg_set(pVBInfo->P3c4,
+                                                     0x13,
+                                                     0x31);
+                                       /* 0x31:8Mx16 bit*/
+                                       xgifb_reg_set(pVBInfo->P3c4,
+                                                     0x14,
+                                                     0x31);
                                        udelay(15);
 
-                                       if (XGINew_ReadWriteRest(22, 22, pVBInfo) == 1)
+                                       if (XGINew_ReadWriteRest(22,
+                                                                22,
+                                                                pVBInfo) == 1)
                                                return;
                                }
                        }
 
-                       if ((HwDeviceExtension->ulVideoMemorySize - 1) > 0x400000) {
+                       if ((HwDeviceExtension->ulVideoMemorySize - 1) >
+                           0x400000) {
                                XGINew_DataBusWidth = 8; /* 8 bits */
-                               xgifb_reg_set(pVBInfo->P3c4, 0x13, 0xB1); /* (0x31:12x8x2) 22bit + 2 rank */
-                               xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x30); /* 0x30:8Mx8 bit*/
+                               /* (0x31:12x8x2) 22bit + 2 rank */
+                               xgifb_reg_set(pVBInfo->P3c4, 0x13, 0xB1);
+                               /* 0x30:8Mx8 bit*/
+                               xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x30);
                                udelay(15);
 
                                if (XGINew_ReadWriteRest(22, 21, pVBInfo) == 1)
                                        return;
-                               else
-                                       xgifb_reg_set(pVBInfo->P3c4, 0x13, 0x31); /* (0x31:12x8x2) 22bit + 1 rank */
+                               else /* (0x31:12x8x2) 22bit + 1 rank */
+                                       xgifb_reg_set(pVBInfo->P3c4,
+                                                     0x13,
+                                                     0x31);
                                udelay(15);
                        }
                }
@@ -911,13 +1013,18 @@ static int XGINew_DDRSizing340(struct xgi_hw_device_info *HwDeviceExtension,
 
        if (HwDeviceExtension->jChipType >= XG20) {
                for (i = 0; i < 12; i++) {
-                       XGINew_SetDRAMSizingType(i, XGINew_DDRDRAM_TYPE20, pVBInfo);
-                       memsize = XGINew_SetDRAMSize20Reg(i, XGINew_DDRDRAM_TYPE20, pVBInfo);
+                       XGINew_SetDRAMSizingType(i,
+                                                XGINew_DDRDRAM_TYPE20,
+                                                pVBInfo);
+                       memsize = XGINew_SetDRAMSize20Reg(i,
+                                                         XGINew_DDRDRAM_TYPE20,
+                                                         pVBInfo);
                        if (memsize == 0)
                                continue;
 
                        addr = memsize + (XGINew_ChannelAB - 2) + 20;
-                       if ((HwDeviceExtension->ulVideoMemorySize - 1) < (unsigned long) (1 << addr))
+                       if ((HwDeviceExtension->ulVideoMemorySize - 1) <
+                           (unsigned long) (1 << addr))
                                continue;
 
                        if (XGINew_ReadWriteRest(addr, 5, pVBInfo) == 1)
@@ -925,14 +1032,19 @@ static int XGINew_DDRSizing340(struct xgi_hw_device_info *HwDeviceExtension,
                }
        } else {
                for (i = 0; i < 4; i++) {
-                       XGINew_SetDRAMSizingType(i, XGINew_DDRDRAM_TYPE340, pVBInfo);
-                       memsize = XGINew_SetDRAMSizeReg(i, XGINew_DDRDRAM_TYPE340, pVBInfo);
+                       XGINew_SetDRAMSizingType(i,
+                                                XGINew_DDRDRAM_TYPE340,
+                                                pVBInfo);
+                       memsize = XGINew_SetDRAMSizeReg(i,
+                                                       XGINew_DDRDRAM_TYPE340,
+                                                       pVBInfo);
 
                        if (memsize == 0)
                                continue;
 
                        addr = memsize + (XGINew_ChannelAB - 2) + 20;
-                       if ((HwDeviceExtension->ulVideoMemorySize - 1) < (unsigned long) (1 << addr))
+                       if ((HwDeviceExtension->ulVideoMemorySize - 1) <
+                           (unsigned long) (1 << addr))
                                continue;
 
                        if (XGINew_ReadWriteRest(addr, 9, pVBInfo) == 1)
@@ -953,7 +1065,8 @@ static void XGINew_SetDRAMSize_340(struct xgi_hw_device_info *HwDeviceExtension,
        XGISetModeNew(HwDeviceExtension, 0x2e);
 
        data = xgifb_reg_get(pVBInfo->P3c4, 0x21);
-       xgifb_reg_set(pVBInfo->P3c4, 0x21, (unsigned short) (data & 0xDF)); /* disable read cache */
+       /* disable read cache */
+       xgifb_reg_set(pVBInfo->P3c4, 0x21, (unsigned short) (data & 0xDF));
        XGI_DisplayOff(HwDeviceExtension, pVBInfo);
 
        /* data = xgifb_reg_get(pVBInfo->P3c4, 0x1); */
@@ -961,12 +1074,15 @@ static void XGINew_SetDRAMSize_340(struct xgi_hw_device_info *HwDeviceExtension,
        /* xgifb_reg_set(pVBInfo->P3c4, 0x01, data); *//* Turn OFF Display */
        XGINew_DDRSizing340(HwDeviceExtension, pVBInfo);
        data = xgifb_reg_get(pVBInfo->P3c4, 0x21);
-       xgifb_reg_set(pVBInfo->P3c4, 0x21, (unsigned short) (data | 0x20)); /* enable read cache */
+       /* enable read cache */
+       xgifb_reg_set(pVBInfo->P3c4, 0x21, (unsigned short) (data | 0x20));
 }
 
-static void ReadVBIOSTablData(unsigned char ChipType, struct vb_device_info *pVBInfo)
+static void ReadVBIOSTablData(unsigned char ChipType,
+                             struct vb_device_info *pVBInfo)
 {
-       volatile unsigned char *pVideoMemory = (unsigned char *) pVBInfo->ROMAddr;
+       volatile unsigned char *pVideoMemory =
+               (unsigned char *) pVBInfo->ROMAddr;
        unsigned long i;
        unsigned char j, k;
        /* Volari customize data area end */
@@ -980,24 +1096,34 @@ static void ReadVBIOSTablData(unsigned char ChipType, struct vb_device_info *pVB
                        if (j != 0xff) {
                                k = 0;
                                do {
-                                       pVBInfo->XG21_LVDSCapList[k].LVDS_Capability
-                                               = pVideoMemory[i] | (pVideoMemory[i + 1] << 8);
+                                       pVBInfo->XG21_LVDSCapList[k].
+                                                LVDS_Capability
+                                               = pVideoMemory[i] |
+                                                (pVideoMemory[i + 1] << 8);
                                        pVBInfo->XG21_LVDSCapList[k].LVDSHT
-                                               = pVideoMemory[i + 2] | (pVideoMemory[i + 3] << 8);
+                                               = pVideoMemory[i + 2] |
+                                                 (pVideoMemory[i + 3] << 8);
                                        pVBInfo->XG21_LVDSCapList[k].LVDSVT
-                                               = pVideoMemory[i + 4] | (pVideoMemory[i + 5] << 8);
+                                               = pVideoMemory[i + 4] |
+                                                 (pVideoMemory[i + 5] << 8);
                                        pVBInfo->XG21_LVDSCapList[k].LVDSHDE
-                                               = pVideoMemory[i + 6] | (pVideoMemory[i + 7] << 8);
+                                               = pVideoMemory[i + 6] |
+                                                 (pVideoMemory[i + 7] << 8);
                                        pVBInfo->XG21_LVDSCapList[k].LVDSVDE
-                                               = pVideoMemory[i + 8] | (pVideoMemory[i + 9] << 8);
+                                               = pVideoMemory[i + 8] |
+                                                 (pVideoMemory[i + 9] << 8);
                                        pVBInfo->XG21_LVDSCapList[k].LVDSHFP
-                                               = pVideoMemory[i + 10] | (pVideoMemory[i + 11] << 8);
+                                               = pVideoMemory[i + 10] |
+                                                 (pVideoMemory[i + 11] << 8);
                                        pVBInfo->XG21_LVDSCapList[k].LVDSVFP
-                                               = pVideoMemory[i + 12] | (pVideoMemory[i + 13] << 8);
+                                               = pVideoMemory[i + 12] |
+                                                 (pVideoMemory[i + 13] << 8);
                                        pVBInfo->XG21_LVDSCapList[k].LVDSHSYNC
-                                               = pVideoMemory[i + 14] | (pVideoMemory[i + 15] << 8);
+                                               = pVideoMemory[i + 14] |
+                                                 (pVideoMemory[i + 15] << 8);
                                        pVBInfo->XG21_LVDSCapList[k].LVDSVSYNC
-                                               = pVideoMemory[i + 16] | (pVideoMemory[i + 17] << 8);
+                                               = pVideoMemory[i + 16] |
+                                                 (pVideoMemory[i + 17] << 8);
                                        pVBInfo->XG21_LVDSCapList[k].VCLKData1
                                                = pVideoMemory[i + 18];
                                        pVBInfo->XG21_LVDSCapList[k].VCLKData2
@@ -1015,26 +1141,38 @@ static void ReadVBIOSTablData(unsigned char ChipType, struct vb_device_info *pVB
                                        i += 25;
                                        j--;
                                        k++;
-                               } while ((j > 0) && (k < (sizeof(XGI21_LCDCapList) / sizeof(struct XGI21_LVDSCapStruct))));
+                               } while ((j > 0) &&
+                                        (k < (sizeof(XGI21_LCDCapList) /
+                                              sizeof(struct
+                                                       XGI21_LVDSCapStruct))));
                        } else {
                                pVBInfo->XG21_LVDSCapList[0].LVDS_Capability
-                                               = pVideoMemory[i] | (pVideoMemory[i + 1] << 8);
+                                               = pVideoMemory[i] |
+                                                 (pVideoMemory[i + 1] << 8);
                                pVBInfo->XG21_LVDSCapList[0].LVDSHT
-                                               = pVideoMemory[i + 2] | (pVideoMemory[i + 3] << 8);
+                                               = pVideoMemory[i + 2] |
+                                                 (pVideoMemory[i + 3] << 8);
                                pVBInfo->XG21_LVDSCapList[0].LVDSVT
-                                               = pVideoMemory[i + 4] | (pVideoMemory[i + 5] << 8);
+                                               = pVideoMemory[i + 4] |
+                                                 (pVideoMemory[i + 5] << 8);
                                pVBInfo->XG21_LVDSCapList[0].LVDSHDE
-                                               = pVideoMemory[i + 6] | (pVideoMemory[i + 7] << 8);
+                                               = pVideoMemory[i + 6] |
+                                                 (pVideoMemory[i + 7] << 8);
                                pVBInfo->XG21_LVDSCapList[0].LVDSVDE
-                                               = pVideoMemory[i + 8] | (pVideoMemory[i + 9] << 8);
+                                               = pVideoMemory[i + 8] |
+                                                 (pVideoMemory[i + 9] << 8);
                                pVBInfo->XG21_LVDSCapList[0].LVDSHFP
-                                               = pVideoMemory[i + 10] | (pVideoMemory[i + 11] << 8);
+                                               = pVideoMemory[i + 10] |
+                                                 (pVideoMemory[i + 11] << 8);
                                pVBInfo->XG21_LVDSCapList[0].LVDSVFP
-                                               = pVideoMemory[i + 12] | (pVideoMemory[i + 13] << 8);
+                                               = pVideoMemory[i + 12] |
+                                                 (pVideoMemory[i + 13] << 8);
                                pVBInfo->XG21_LVDSCapList[0].LVDSHSYNC
-                                               = pVideoMemory[i + 14] | (pVideoMemory[i + 15] << 8);
+                                               = pVideoMemory[i + 14] |
+                                                 (pVideoMemory[i + 15] << 8);
                                pVBInfo->XG21_LVDSCapList[0].LVDSVSYNC
-                                               = pVideoMemory[i + 16] | (pVideoMemory[i + 17] << 8);
+                                               = pVideoMemory[i + 16] |
+                                                 (pVideoMemory[i + 17] << 8);
                                pVBInfo->XG21_LVDSCapList[0].VCLKData1
                                                = pVideoMemory[i + 18];
                                pVBInfo->XG21_LVDSCapList[0].VCLKData2
@@ -1197,21 +1335,31 @@ static void XGINew_GetXG21Sense(struct xgi_hw_device_info *HwDeviceExtension,
        if ((pVideoMemory[0x65] & 0x01)) { /* For XG21 LVDS */
                pVBInfo->IF_DEF_LVDS = 1;
                xgifb_reg_or(pVBInfo->P3d4, 0x32, LCDSense);
-               xgifb_reg_and_or(pVBInfo->P3d4, 0x38, ~0xE0, 0xC0); /* LVDS on chip */
+               /* LVDS on chip */
+               xgifb_reg_and_or(pVBInfo->P3d4, 0x38, ~0xE0, 0xC0);
        } else {
 #endif
-               xgifb_reg_and_or(pVBInfo->P3d4, 0x4A, ~0x03, 0x03); /* Enable GPIOA/B read  */
+               /* Enable GPIOA/B read  */
+               xgifb_reg_and_or(pVBInfo->P3d4, 0x4A, ~0x03, 0x03);
                Temp = xgifb_reg_get(pVBInfo->P3d4, 0x48) & 0xC0;
                if (Temp == 0xC0) { /* DVI & DVO GPIOA/B pull high */
                        XGINew_SenseLCD(HwDeviceExtension, pVBInfo);
                        xgifb_reg_or(pVBInfo->P3d4, 0x32, LCDSense);
-                       xgifb_reg_and_or(pVBInfo->P3d4, 0x4A, ~0x20, 0x20); /* Enable read GPIOF */
+                       /* Enable read GPIOF */
+                       xgifb_reg_and_or(pVBInfo->P3d4, 0x4A, ~0x20, 0x20);
                        Temp = xgifb_reg_get(pVBInfo->P3d4, 0x48) & 0x04;
                        if (!Temp)
-                               xgifb_reg_and_or(pVBInfo->P3d4, 0x38, ~0xE0, 0x80); /* TMDS on chip */
+                               xgifb_reg_and_or(pVBInfo->P3d4,
+                                                0x38,
+                                                ~0xE0,
+                                                0x80); /* TMDS on chip */
                        else
-                               xgifb_reg_and_or(pVBInfo->P3d4, 0x38, ~0xE0, 0xA0); /* Only DVO on chip */
-                       xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~0x20); /* Disable read GPIOF */
+                               xgifb_reg_and_or(pVBInfo->P3d4,
+                                                0x38,
+                                                ~0xE0,
+                                                0xA0); /* Only DVO on chip */
+                       /* Disable read GPIOF */
+                       xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~0x20);
                }
 #if 1
        }
@@ -1225,16 +1373,19 @@ static void XGINew_GetXG27Sense(struct xgi_hw_device_info *HwDeviceExtension,
 
        pVBInfo->IF_DEF_LVDS = 0;
        bCR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A);
-       xgifb_reg_and_or(pVBInfo->P3d4, 0x4A, ~0x07, 0x07); /* Enable GPIOA/B/C read  */
+       /* Enable GPIOA/B/C read  */
+       xgifb_reg_and_or(pVBInfo->P3d4, 0x4A, ~0x07, 0x07);
        Temp = xgifb_reg_get(pVBInfo->P3d4, 0x48) & 0x07;
        xgifb_reg_set(pVBInfo->P3d4, 0x4A, bCR4A);
 
        if (Temp <= 0x02) {
                pVBInfo->IF_DEF_LVDS = 1;
-               xgifb_reg_and_or(pVBInfo->P3d4, 0x38, ~0xE0, 0xC0); /* LVDS setting */
+               /* LVDS setting */
+               xgifb_reg_and_or(pVBInfo->P3d4, 0x38, ~0xE0, 0xC0);
                xgifb_reg_set(pVBInfo->P3d4, 0x30, 0x21);
        } else {
-               xgifb_reg_and_or(pVBInfo->P3d4, 0x38, ~0xE0, 0xA0); /* TMDS/DVO setting */
+               /* TMDS/DVO setting */
+               xgifb_reg_and_or(pVBInfo->P3d4, 0x38, ~0xE0, 0xA0);
        }
        xgifb_reg_or(pVBInfo->P3d4, 0x32, LCDSense);
 
@@ -1245,7 +1396,8 @@ static unsigned char GetXG21FPBits(struct vb_device_info *pVBInfo)
        unsigned char CR38, CR4A, temp;
 
        CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A);
-       xgifb_reg_and_or(pVBInfo->P3d4, 0x4A, ~0x10, 0x10); /* enable GPIOE read */
+       /* enable GPIOE read */
+       xgifb_reg_and_or(pVBInfo->P3d4, 0x4A, ~0x10, 0x10);
        CR38 = xgifb_reg_get(pVBInfo->P3d4, 0x38);
        temp = 0;
        if ((CR38 & 0xE0) > 0x80) {
@@ -1264,7 +1416,8 @@ static unsigned char GetXG27FPBits(struct vb_device_info *pVBInfo)
        unsigned char CR4A, temp;
 
        CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A);
-       xgifb_reg_and_or(pVBInfo->P3d4, 0x4A, ~0x03, 0x03); /* enable GPIOA/B/C read */
+       /* enable GPIOA/B/C read */
+       xgifb_reg_and_or(pVBInfo->P3d4, 0x4A, ~0x03, 0x03);
        temp = xgifb_reg_get(pVBInfo->P3d4, 0x48);
        if (temp <= 2)
                temp &= 0x03;
@@ -1344,7 +1497,8 @@ unsigned char XGIInitNew(struct xgi_hw_device_info *HwDeviceExtension)
        printk("5");
 
        if (HwDeviceExtension->jChipType < XG20) /* kuku 2004/06/25 */
-               XGI_GetVBType(pVBInfo); /* Run XGI_GetVBType before InitTo330Pointer */
+               /* Run XGI_GetVBType before InitTo330Pointer */
+               XGI_GetVBType(pVBInfo);
 
        InitTo330Pointer(HwDeviceExtension->jChipType, pVBInfo);
 
@@ -1381,7 +1535,8 @@ unsigned char XGIInitNew(struct xgi_hw_device_info *HwDeviceExtension)
                xgifb_reg_set(pVBInfo->P3c4, i, 0);
        printk("9");
 
-       if (HwDeviceExtension->jChipType == XG42) /* [Hsuan] 2004/08/20 Auto over driver for XG42 */
+       /* [Hsuan] 2004/08/20 Auto over driver for XG42 */
+       if (HwDeviceExtension->jChipType == XG42)
                xgifb_reg_set(pVBInfo->P3c4, 0x3B, 0xC0);
 
        /* for (i = 0x30; i <= 0x3F; i++) */
@@ -1397,7 +1552,8 @@ unsigned char XGIInitNew(struct xgi_hw_device_info *HwDeviceExtension)
 
        /* 3.SetMemoryClock
 
-        XGINew_RAMType = (int)XGINew_GetXG20DRAMType(HwDeviceExtension, pVBInfo);
+        XGINew_RAMType = (int)XGINew_GetXG20DRAMType(HwDeviceExtension,
+                                                     pVBInfo);
        */
 
        printk("11");
@@ -1411,8 +1567,10 @@ unsigned char XGIInitNew(struct xgi_hw_device_info *HwDeviceExtension)
        xgifb_reg_set(pVBInfo->P3c4, 0x11, 0x0F);
        xgifb_reg_set(pVBInfo->P3c4, 0x1F, *pVBInfo->pSR1F);
        /* xgifb_reg_set(pVBInfo->P3c4, 0x20, 0x20); */
-       xgifb_reg_set(pVBInfo->P3c4, 0x20, 0xA0); /* alan, 2001/6/26 Frame buffer can read/write SR20 */
-       xgifb_reg_set(pVBInfo->P3c4, 0x36, 0x70); /* Hsuan, 2006/01/01 H/W request for slow corner chip */
+       /* alan, 2001/6/26 Frame buffer can read/write SR20 */
+       xgifb_reg_set(pVBInfo->P3c4, 0x20, 0xA0);
+       /* Hsuan, 2006/01/01 H/W request for slow corner chip */
+       xgifb_reg_set(pVBInfo->P3c4, 0x36, 0x70);
        if (HwDeviceExtension->jChipType == XG27) /* Alan 12/07/2006 */
                xgifb_reg_set(pVBInfo->P3c4, 0x36, *pVBInfo->pSR36);
 
@@ -1441,14 +1599,24 @@ unsigned char XGIInitNew(struct xgi_hw_device_info *HwDeviceExtension)
 
                        ChipsetID &= 0x0000FFFF;
 
-                       if ((ChipsetID == 0x700E) || (ChipsetID == 0x1022) || (ChipsetID == 0x1106) || (ChipsetID == 0x10DE)) {
+                       if ((ChipsetID == 0x700E) ||
+                           (ChipsetID == 0x1022) ||
+                           (ChipsetID == 0x1106) ||
+                           (ChipsetID == 0x10DE)) {
                                if (ChipsetID == 0x1106) {
-                                       if ((VendorID == 0x1019) && (GraphicVendorID == 0x1019))
-                                               xgifb_reg_set(pVBInfo->P3d4, 0x5F, 0x0D);
+                                       if ((VendorID == 0x1019) &&
+                                           (GraphicVendorID == 0x1019))
+                                               xgifb_reg_set(pVBInfo->P3d4,
+                                                             0x5F,
+                                                             0x0D);
                                        else
-                                               xgifb_reg_set(pVBInfo->P3d4, 0x5F, 0x0B);
+                                               xgifb_reg_set(pVBInfo->P3d4,
+                                                             0x5F,
+                                                             0x0B);
                                } else {
-                                       xgifb_reg_set(pVBInfo->P3d4, 0x5F, 0x0B);
+                                       xgifb_reg_set(pVBInfo->P3d4,
+                                                     0x5F,
+                                                     0x0B);
                                }
                        }
                }
@@ -1458,13 +1626,19 @@ unsigned char XGIInitNew(struct xgi_hw_device_info *HwDeviceExtension)
 
                /* Set AGP customize registers (in SetDefAGPRegs) Start */
                for (i = 0x47; i <= 0x4C; i++)
-                       xgifb_reg_set(pVBInfo->P3d4, i, pVBInfo->AGPReg[i - 0x47]);
+                       xgifb_reg_set(pVBInfo->P3d4,
+                                     i,
+                                     pVBInfo->AGPReg[i - 0x47]);
 
                for (i = 0x70; i <= 0x71; i++)
-                       xgifb_reg_set(pVBInfo->P3d4, i, pVBInfo->AGPReg[6 + i - 0x70]);
+                       xgifb_reg_set(pVBInfo->P3d4,
+                                     i,
+                                     pVBInfo->AGPReg[6 + i - 0x70]);
 
                for (i = 0x74; i <= 0x77; i++)
-                       xgifb_reg_set(pVBInfo->P3d4, i, pVBInfo->AGPReg[8 + i - 0x74]);
+                       xgifb_reg_set(pVBInfo->P3d4,
+                                     i,
+                                     pVBInfo->AGPReg[8 + i - 0x74]);
                /* Set AGP customize registers (in SetDefAGPRegs) End */
                /* [Hsuan]2004/12/14 AGP Input Delay Adjustment on 850 */
                /*        outl(0x80000000, 0xcf8); */
@@ -1472,7 +1646,10 @@ unsigned char XGIInitNew(struct xgi_hw_device_info *HwDeviceExtension)
                /*        if (ChipsetID == 0x25308086) */
                /*            xgifb_reg_set(pVBInfo->P3d4, 0x77, 0xF0); */
 
-               HwDeviceExtension->pQueryVGAConfigSpace(HwDeviceExtension, 0x50, 0, &Temp); /* Get */
+               HwDeviceExtension->pQueryVGAConfigSpace(HwDeviceExtension,
+                                                       0x50,
+                                                       0,
+                                                       &Temp); /* Get */
                Temp >>= 20;
                Temp &= 0xF;
 
@@ -1490,12 +1667,16 @@ unsigned char XGIInitNew(struct xgi_hw_device_info *HwDeviceExtension)
        if (HwDeviceExtension->jChipType < XG20) { /* kuku 2004/06/25 */
                /* Set VB */
                XGI_UnLockCRT2(HwDeviceExtension, pVBInfo);
-               xgifb_reg_and_or(pVBInfo->Part0Port, 0x3F, 0xEF, 0x00); /* alan, disable VideoCapture */
+               /* alan, disable VideoCapture */
+               xgifb_reg_and_or(pVBInfo->Part0Port, 0x3F, 0xEF, 0x00);
                xgifb_reg_set(pVBInfo->Part1Port, 0x00, 0x00);
-               temp1 = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x7B); /* chk if BCLK>=100MHz */
+               /* chk if BCLK>=100MHz */
+               temp1 = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x7B);
                temp = (unsigned char) ((temp1 >> 4) & 0x0F);
 
-               xgifb_reg_set(pVBInfo->Part1Port, 0x02, (*pVBInfo->pCRT2Data_1_2));
+               xgifb_reg_set(pVBInfo->Part1Port,
+                             0x02,
+                             (*pVBInfo->pCRT2Data_1_2));
 
                printk("16");
 
@@ -1504,10 +1685,15 @@ unsigned char XGIInitNew(struct xgi_hw_device_info *HwDeviceExtension)
 
        xgifb_reg_set(pVBInfo->P3c4, 0x27, 0x1F);
 
-       if ((HwDeviceExtension->jChipType == XG42)
-                       && XGINew_GetXG20DRAMType(HwDeviceExtension, pVBInfo) != 0) { /* Not DDR */
-               xgifb_reg_set(pVBInfo->P3c4, 0x31, (*pVBInfo->pSR31 & 0x3F) | 0x40);
-               xgifb_reg_set(pVBInfo->P3c4, 0x32, (*pVBInfo->pSR32 & 0xFC) | 0x01);
+       if ((HwDeviceExtension->jChipType == XG42) &&
+           XGINew_GetXG20DRAMType(HwDeviceExtension, pVBInfo) != 0) {
+               /* Not DDR */
+               xgifb_reg_set(pVBInfo->P3c4,
+                             0x31,
+                             (*pVBInfo->pSR31 & 0x3F) | 0x40);
+               xgifb_reg_set(pVBInfo->P3c4,
+                             0x32,
+                             (*pVBInfo->pSR32 & 0xFC) | 0x01);
        } else {
                xgifb_reg_set(pVBInfo->P3c4, 0x31, *pVBInfo->pSR31);
                xgifb_reg_set(pVBInfo->P3c4, 0x32, *pVBInfo->pSR32);
@@ -1522,9 +1708,15 @@ unsigned char XGIInitNew(struct xgi_hw_device_info *HwDeviceExtension)
                if (XGI_BridgeIsOn(pVBInfo) == 1) {
                        if (pVBInfo->IF_DEF_LVDS == 0) {
                                xgifb_reg_set(pVBInfo->Part2Port, 0x00, 0x1C);
-                               xgifb_reg_set(pVBInfo->Part4Port, 0x0D, *pVBInfo->pCRT2Data_4_D);
-                               xgifb_reg_set(pVBInfo->Part4Port, 0x0E, *pVBInfo->pCRT2Data_4_E);
-                               xgifb_reg_set(pVBInfo->Part4Port, 0x10, *pVBInfo->pCRT2Data_4_10);
+                               xgifb_reg_set(pVBInfo->Part4Port,
+                                             0x0D,
+                                             *pVBInfo->pCRT2Data_4_D);
+                               xgifb_reg_set(pVBInfo->Part4Port,
+                                             0x0E,
+                                             *pVBInfo->pCRT2Data_4_E);
+                               xgifb_reg_set(pVBInfo->Part4Port,
+                                             0x10,
+                                             *pVBInfo->pCRT2Data_4_10);
                                xgifb_reg_set(pVBInfo->Part4Port, 0x0F, 0x3F);
                        }
 
@@ -1542,31 +1734,42 @@ unsigned char XGIInitNew(struct xgi_hw_device_info *HwDeviceExtension)
        printk("183");
        /* XGINew_DetectMonitor(HwDeviceExtension); */
        pVBInfo->IF_DEF_CH7007 = 0;
-       if ((HwDeviceExtension->jChipType == XG21) && (pVBInfo->IF_DEF_CH7007)) {
+       if ((HwDeviceExtension->jChipType == XG21) &&
+           (pVBInfo->IF_DEF_CH7007)) {
                printk("184");
-               XGI_GetSenseStatus(HwDeviceExtension, pVBInfo); /* sense CRT2 */
+               /* sense CRT2 */
+               XGI_GetSenseStatus(HwDeviceExtension, pVBInfo);
                printk("185");
 
        }
        if (HwDeviceExtension->jChipType == XG21) {
                printk("186");
 
-               xgifb_reg_and_or(pVBInfo->P3d4, 0x32, ~Monitor1Sense, Monitor1Sense); /* Z9 default has CRT */
+               xgifb_reg_and_or(pVBInfo->P3d4,
+                                0x32,
+                                ~Monitor1Sense,
+                                Monitor1Sense); /* Z9 default has CRT */
                temp = GetXG21FPBits(pVBInfo);
                xgifb_reg_and_or(pVBInfo->P3d4, 0x37, ~0x01, temp);
                printk("187");
 
        }
        if (HwDeviceExtension->jChipType == XG27) {
-               xgifb_reg_and_or(pVBInfo->P3d4, 0x32, ~Monitor1Sense, Monitor1Sense); /* Z9 default has CRT */
+               xgifb_reg_and_or(pVBInfo->P3d4,
+                                0x32,
+                                ~Monitor1Sense,
+                                Monitor1Sense); /* Z9 default has CRT */
                temp = GetXG27FPBits(pVBInfo);
                xgifb_reg_and_or(pVBInfo->P3d4, 0x37, ~0x03, temp);
        }
        printk("19");
 
-       XGINew_RAMType = (int) XGINew_GetXG20DRAMType(HwDeviceExtension, pVBInfo);
+       XGINew_RAMType = (int) XGINew_GetXG20DRAMType(HwDeviceExtension,
+                                                     pVBInfo);
 
-       XGINew_SetDRAMDefaultRegister340(HwDeviceExtension, pVBInfo->P3d4, pVBInfo);
+       XGINew_SetDRAMDefaultRegister340(HwDeviceExtension,
+                                        pVBInfo->P3d4,
+                                        pVBInfo);
 
        printk("20");
        XGINew_SetDRAMSize_340(HwDeviceExtension, pVBInfo);
@@ -1594,7 +1797,9 @@ unsigned char XGIInitNew(struct xgi_hw_device_info *HwDeviceExtension)
        /* OutPortLong(0xcf8, base); */
        /* Temp = (InPortLong(0xcfc) & 0xFFFF); */
        /* if (Temp == 0x1039) { */
-       xgifb_reg_set(pVBInfo->P3c4, 0x22, (unsigned char) ((*pVBInfo->pSR22) & 0xFE));
+       xgifb_reg_set(pVBInfo->P3c4,
+                     0x22,
+                     (unsigned char) ((*pVBInfo->pSR22) & 0xFE));
        /* } else { */
        /*      xgifb_reg_set(pVBInfo->P3c4, 0x22, *pVBInfo->pSR22); */
        /* } */
index b47352b8e34a321caf88506e9e71ce182dde56dd..6b7723057f732b240328ae7ff3baa011d3386c73 100644 (file)
@@ -1,7 +1,6 @@
-#ifndef  _VBINIT_
-#define  _VBINIT_
-extern   unsigned char    XGIInitNew(struct xgi_hw_device_info *HwDeviceExtension) ;
+#ifndef _VBINIT_
+#define _VBINIT_
+extern unsigned char XGIInitNew(struct xgi_hw_device_info *HwDeviceExtension);
 extern struct XGI21_LVDSCapStruct  XGI21_LCDCapList[13];
-
 #endif
 
index 9669c22cc82c7f1831a87410db622a4ed1a0c3f0..2669b1b0f51fca3004fcb5a7ad478bb74cf12ef7 100644 (file)
@@ -1,5 +1,5 @@
 
-#include <asm/io.h>
+#include <linux/io.h>
 #include <linux/delay.h>
 #include <linux/types.h>
 #include <linux/version.h>
@@ -71,7 +71,8 @@ void InitTo330Pointer(unsigned char ChipType, struct vb_device_info *pVBInfo)
                        = (struct XGI_CRT1TableStruct *) XGI_CRT1Table;
 
        /* add for new UNIVGABIOS */
-       /* XGINew_UBLCDDataTable = (struct XGI_LCDDataTablStruct *) XGI_LCDDataTable; */
+       /* XGINew_UBLCDDataTable =
+        *      (struct XGI_LCDDataTablStruct *) XGI_LCDDataTable; */
        /* XGINew_UBTVDataTable = (XGI_TVDataTablStruct *) XGI_TVDataTable; */
 
        pVBInfo->MCLKData = (struct XGI_MCLKDataStruct *) XGI340New_MCLKData;
@@ -190,8 +191,9 @@ void InitTo330Pointer(unsigned char ChipType, struct vb_device_info *pVBInfo)
 
 }
 
-static unsigned char XGI_GetModePtr(unsigned short ModeNo, unsigned short ModeIdIndex,
-               struct vb_device_info *pVBInfo)
+static unsigned char XGI_GetModePtr(unsigned short ModeNo,
+                                   unsigned short ModeIdIndex,
+                                   struct vb_device_info *pVBInfo)
 {
        unsigned char index;
 
@@ -207,21 +209,24 @@ static unsigned char XGI_GetModePtr(unsigned short ModeNo, unsigned short ModeId
 }
 
 /*
-unsigned char XGI_SetBIOSData(unsigned short ModeNo, unsigned short ModeIdIndex) {
+unsigned char XGI_SetBIOSData(unsigned short ModeNo,
+                             unsigned short ModeIdIndex) {
        return (0);
 }
 */
 
-/* unsigned char XGI_ClearBankRegs(unsigned short ModeNo, unsigned short ModeIdIndex) {
+/* unsigned char XGI_ClearBankRegs(unsigned short ModeNo,
+                                  unsigned short ModeIdIndex) {
        return( 0 ) ;
 }
 */
 
-static void XGI_SetSeqRegs(unsigned short ModeNo, unsigned short StandTableIndex,
-               unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
+static void XGI_SetSeqRegs(unsigned short ModeNo,
+                          unsigned short StandTableIndex,
+                          unsigned short ModeIdIndex,
+                          struct vb_device_info *pVBInfo)
 {
        unsigned char tempah, SRdata;
-
        unsigned short i, modeflag;
 
        if (ModeNo <= 0x13)
@@ -246,19 +251,25 @@ static void XGI_SetSeqRegs(unsigned short ModeNo, unsigned short StandTableIndex
        xgifb_reg_set(pVBInfo->P3c4, 0x01, tempah); /* Set SR1 */
 
        for (i = 02; i <= 04; i++) {
-               SRdata = pVBInfo->StandTable[StandTableIndex].SR[i - 1]; /* Get SR2,3,4 from file */
+               /* Get SR2,3,4 from file */
+               SRdata = pVBInfo->StandTable[StandTableIndex].SR[i - 1];
                xgifb_reg_set(pVBInfo->P3c4, i, SRdata); /* Set SR2 3 4 */
        }
 }
 
 static void XGI_SetMiscRegs(unsigned short StandTableIndex,
-               struct vb_device_info *pVBInfo)
+                           struct vb_device_info *pVBInfo)
 {
        unsigned char Miscdata;
 
-       Miscdata = pVBInfo->StandTable[StandTableIndex].MISC; /* Get Misc from file */
+       /* Get Misc from file */
+       Miscdata = pVBInfo->StandTable[StandTableIndex].MISC;
        /*
-       if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) {
+       if (pVBInfo->VBType & (VB_XGI301B |
+                              VB_XGI302B |
+                              VB_XGI301LV |
+                              VB_XGI302LV |
+                              VB_XGI301C)) {
                if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
                        Miscdata |= 0x0C;
                }
@@ -269,7 +280,8 @@ static void XGI_SetMiscRegs(unsigned short StandTableIndex,
 }
 
 static void XGI_SetCRTCRegs(struct xgi_hw_device_info *HwDeviceExtension,
-               unsigned short StandTableIndex, struct vb_device_info *pVBInfo)
+                           unsigned short StandTableIndex,
+                           struct vb_device_info *pVBInfo)
 {
        unsigned char CRTCdata;
        unsigned short i;
@@ -279,11 +291,13 @@ static void XGI_SetCRTCRegs(struct xgi_hw_device_info *HwDeviceExtension,
        xgifb_reg_set(pVBInfo->P3d4, 0x11, CRTCdata); /* Unlock CRTC */
 
        for (i = 0; i <= 0x18; i++) {
-               CRTCdata = pVBInfo->StandTable[StandTableIndex].CRTC[i]; /* Get CRTC from file */
+               /* Get CRTC from file */
+               CRTCdata = pVBInfo->StandTable[StandTableIndex].CRTC[i];
                xgifb_reg_set(pVBInfo->P3d4, i, CRTCdata); /* Set CRTC(3d4) */
        }
        /*
-       if ((HwDeviceExtension->jChipType == XGI_630) && (HwDeviceExtension->jChipRevision == 0x30)) {
+       if ((HwDeviceExtension->jChipType == XGI_630) &&
+           (HwDeviceExtension->jChipRevision == 0x30)) {
                if (pVBInfo->VBInfo & SetInSlaveMode) {
                        if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToTV)) {
                                xgifb_reg_set(pVBInfo->P3d4, 0x18, 0xFE);
@@ -293,8 +307,10 @@ static void XGI_SetCRTCRegs(struct xgi_hw_device_info *HwDeviceExtension,
        */
 }
 
-static void XGI_SetATTRegs(unsigned short ModeNo, unsigned short StandTableIndex,
-               unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
+static void XGI_SetATTRegs(unsigned short ModeNo,
+                          unsigned short StandTableIndex,
+                          unsigned short ModeIdIndex,
+                          struct vb_device_info *pVBInfo)
 {
        unsigned char ARdata;
        unsigned short i, modeflag;
@@ -313,8 +329,8 @@ static void XGI_SetATTRegs(unsigned short ModeNo, unsigned short StandTableIndex
                                } else {
                                        if (pVBInfo->VBInfo & (SetCRT2ToTV
                                                        | SetCRT2ToLCD)) {
-                                               if (pVBInfo->VBInfo
-                                                               & SetInSlaveMode)
+                                               if (pVBInfo->VBInfo &
+                                                   SetInSlaveMode)
                                                        ARdata = 0;
                                        }
                                }
@@ -334,13 +350,14 @@ static void XGI_SetATTRegs(unsigned short ModeNo, unsigned short StandTableIndex
 }
 
 static void XGI_SetGRCRegs(unsigned short StandTableIndex,
-               struct vb_device_info *pVBInfo)
+                          struct vb_device_info *pVBInfo)
 {
        unsigned char GRdata;
        unsigned short i;
 
        for (i = 0; i <= 0x08; i++) {
-               GRdata = pVBInfo->StandTable[StandTableIndex].GRC[i]; /* Get GR from file */
+               /* Get GR from file */
+               GRdata = pVBInfo->StandTable[StandTableIndex].GRC[i];
                xgifb_reg_set(pVBInfo->P3ce, i, GRdata); /* Set GR(3ce) */
        }
 
@@ -382,7 +399,8 @@ static unsigned char XGI_AjustCRT2Rate(unsigned short ModeNo,
        unsigned short tempax, tempbx, resinfo, modeflag, infoflag;
 
        if (ModeNo <= 0x13)
-               modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ModeFlag */
+               /* si+St_ModeFlag */
+               modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
        else
                modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
 
@@ -398,12 +416,14 @@ static unsigned char XGI_AjustCRT2Rate(unsigned short ModeNo,
                                tempax |= SupportCRT2in301C;
                }
 
-               if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { /* 301b */
+               /* 301b */
+               if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
                        tempax |= SupportLCD;
 
                        if (pVBInfo->LCDResInfo != Panel1280x1024) {
                                if (pVBInfo->LCDResInfo != Panel1280x960) {
-                                       if (pVBInfo->LCDInfo & LCDNonExpanding) {
+                                       if (pVBInfo->LCDInfo &
+                                           LCDNonExpanding) {
                                                if (resinfo >= 9) {
                                                        tempax = 0;
                                                        return 0;
@@ -414,8 +434,8 @@ static unsigned char XGI_AjustCRT2Rate(unsigned short ModeNo,
                }
 
                if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { /* for HiTV */
-                       if ((pVBInfo->VBType & VB_XGI301LV)
-                                       && (pVBInfo->VBExtInfo == VB_YPbPr1080i)) {
+                       if ((pVBInfo->VBType & VB_XGI301LV) &&
+                           (pVBInfo->VBExtInfo == VB_YPbPr1080i)) {
                                tempax |= SupportYPbPr;
                                if (pVBInfo->VBInfo & SetInSlaveMode) {
                                        if (resinfo == 4)
@@ -444,9 +464,11 @@ static unsigned char XGI_AjustCRT2Rate(unsigned short ModeNo,
                                }
                        }
                } else {
-                       if (pVBInfo->VBInfo & (SetCRT2ToAVIDEO
-                                       | SetCRT2ToSVIDEO | SetCRT2ToSCART
-                                       | SetCRT2ToYPbPr | SetCRT2ToHiVisionTV)) {
+                       if (pVBInfo->VBInfo & (SetCRT2ToAVIDEO |
+                                              SetCRT2ToSVIDEO |
+                                              SetCRT2ToSCART |
+                                              SetCRT2ToYPbPr |
+                                              SetCRT2ToHiVisionTV)) {
                                tempax |= SupportTV;
 
                                if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B
@@ -457,10 +479,10 @@ static unsigned char XGI_AjustCRT2Rate(unsigned short ModeNo,
 
                                if (!(pVBInfo->VBInfo & SetPALTV)) {
                                        if (modeflag & NoSupportSimuTV) {
-                                               if (pVBInfo->VBInfo
-                                                               & SetInSlaveMode) {
-                                                       if (!(pVBInfo->VBInfo
-                                                                       & SetNotSimuMode)) {
+                                               if (pVBInfo->VBInfo &
+                                                   SetInSlaveMode) {
+                                                       if (!(pVBInfo->VBInfo &
+                                                             SetNotSimuMode)) {
                                                                return 0;
                                                        }
                                                }
@@ -490,10 +512,10 @@ static unsigned char XGI_AjustCRT2Rate(unsigned short ModeNo,
                }
        }
 
-       for (; pVBInfo->RefIndex[RefreshRateTableIndex + (*i)].ModeID == tempbx; (*i)--) {
-               infoflag
-                               = pVBInfo->RefIndex[RefreshRateTableIndex
-                                               + (*i)].Ext_InfoFlag;
+       for (; pVBInfo->RefIndex[RefreshRateTableIndex + (*i)].ModeID ==
+              tempbx; (*i)--) {
+               infoflag = pVBInfo->RefIndex[RefreshRateTableIndex + (*i)].
+                               Ext_InfoFlag;
                if (infoflag & tempax)
                        return 1;
 
@@ -502,9 +524,8 @@ static unsigned char XGI_AjustCRT2Rate(unsigned short ModeNo,
        }
 
        for ((*i) = 0;; (*i)++) {
-               infoflag
-                               = pVBInfo->RefIndex[RefreshRateTableIndex
-                                               + (*i)].Ext_InfoFlag;
+               infoflag = pVBInfo->RefIndex[RefreshRateTableIndex + (*i)].
+                               Ext_InfoFlag;
                if (pVBInfo->RefIndex[RefreshRateTableIndex + (*i)].ModeID
                                != tempbx) {
                        return 0;
@@ -521,7 +542,8 @@ static void XGI_SetSync(unsigned short RefreshRateTableIndex,
 {
        unsigned short sync, temp;
 
-       sync = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag >> 8; /* di+0x00 */
+       /* di+0x00 */
+       sync = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag >> 8;
        sync &= 0xC0;
        temp = 0x2F;
        temp |= sync;
@@ -538,7 +560,8 @@ static void XGI_SetCRT1Timing_H(struct vb_device_info *pVBInfo,
        /* xgifb_reg_set(pVBInfo->P3d4, 0x56, 0); */
        /* xgifb_reg_and_or(pVBInfo->P3d4, 0x11, 0x7f, 0x00); */
 
-       data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11); /* unlock cr0-7 */
+       /* unlock cr0-7 */
+       data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11);
        data &= 0x7F;
        xgifb_reg_set(pVBInfo->P3d4, 0x11, data);
 
@@ -591,8 +614,9 @@ static void XGI_SetCRT1Timing_H(struct vb_device_info *pVBInfo,
        }
 }
 
-static void XGI_SetCRT1Timing_V(unsigned short ModeIdIndex, unsigned short ModeNo,
-               struct vb_device_info *pVBInfo)
+static void XGI_SetCRT1Timing_V(unsigned short ModeIdIndex,
+                               unsigned short ModeNo,
+                               struct vb_device_info *pVBInfo)
 {
        unsigned char data;
        unsigned short i, j;
@@ -650,7 +674,8 @@ static void XGI_SetCRT1CRTC(unsigned short ModeNo, unsigned short ModeIdIndex,
        unsigned char index, data;
        unsigned short i;
 
-       index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; /* Get index */
+       /* Get index */
+       index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
        index = index & IndexMask;
 
        data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11);
@@ -688,9 +713,12 @@ static void XGI_SetXG21CRTC(unsigned short ModeNo, unsigned short ModeIdIndex,
 
        if (ModeNo <= 0x13) {
                StandTableIndex = XGI_GetModePtr(ModeNo, ModeIdIndex, pVBInfo);
-               Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[4]; /* CR04 HRS */
-               xgifb_reg_set(pVBInfo->P3c4, 0x2E, Tempax); /* SR2E [7:0]->HRS */
-               Tempbx = pVBInfo->StandTable[StandTableIndex].CRTC[5]; /* Tempbx: CR05 HRE */
+               /* CR04 HRS */
+               Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[4];
+               /* SR2E [7:0]->HRS */
+               xgifb_reg_set(pVBInfo->P3c4, 0x2E, Tempax);
+               /* Tempbx: CR05 HRE */
+               Tempbx = pVBInfo->StandTable[StandTableIndex].CRTC[5];
                Tempbx &= 0x1F; /* Tempbx: HRE[4:0] */
                Tempcx = Tempax;
                Tempcx &= 0xE0; /* Tempcx: HRS[7:5] */
@@ -698,27 +726,34 @@ static void XGI_SetXG21CRTC(unsigned short ModeNo, unsigned short ModeIdIndex,
                if (Tempbx < (Tempax & 0x1F)) /* IF HRE < HRS */
                        Tempdx |= 0x20; /* Tempdx: HRE = HRE + 0x20 */
                Tempdx <<= 2; /* Tempdx << 2 */
-               xgifb_reg_set(pVBInfo->P3c4, 0x2F, Tempdx); /* SR2F [7:2]->HRE */
+               /* SR2F [7:2]->HRE */
+               xgifb_reg_set(pVBInfo->P3c4, 0x2F, Tempdx);
                xgifb_reg_and_or(pVBInfo->P3c4, 0x30, 0xE3, 00);
 
-               Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[16]; /* Tempax: CR16 VRS */
+               /* Tempax: CR16 VRS */
+               Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[16];
                Tempbx = Tempax; /* Tempbx=Tempax */
                Tempax &= 0x01; /* Tempax: VRS[0] */
                xgifb_reg_or(pVBInfo->P3c4, 0x33, Tempax); /* SR33[0]->VRS */
-               Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[7]; /* Tempax: CR7 VRS */
+
+               /* Tempax: CR7 VRS */
+               Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[7];
                Tempdx = Tempbx >> 1; /* Tempdx: VRS[7:1] */
                Tempcx = Tempax & 0x04; /* Tempcx: CR7[2] */
                Tempcx <<= 5; /* Tempcx[7]: VRS[8] */
                Tempdx |= Tempcx; /* Tempdx: VRS[8:1] */
-               xgifb_reg_set(pVBInfo->P3c4, 0x34, Tempdx); /* SR34[7:0]: VRS[8:1] */
+               /* SR34[7:0]: VRS[8:1] */
+               xgifb_reg_set(pVBInfo->P3c4, 0x34, Tempdx);
 
-               Temp1 = Tempcx << 1; /* Temp1[8]: VRS[8] unsigned char -> unsigned short */
+               /* Temp1[8]: VRS[8] unsigned char -> unsigned short */
+               Temp1 = Tempcx << 1;
                Temp1 |= Tempbx; /* Temp1[8:0]: VRS[8:0] */
                Tempax &= 0x80; /* Tempax[7]: CR7[7] */
                Temp2 = Tempax << 2; /* Temp2[9]: VRS[9] */
                Temp1 |= Temp2; /* Temp1[9:0]: VRS[9:0] */
 
-               Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[17]; /* CR16 VRE */
+               /* CR16 VRE */
+               Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[17];
                Tempax &= 0x0F; /* Tempax[3:0]: VRE[3:0] */
                Temp2 = Temp1 & 0x3F0; /* Temp2[9:4]: VRS[9:4] */
                Temp2 |= Tempax; /* Temp2[9:0]: VRE[9:0] */
@@ -733,12 +768,15 @@ static void XGI_SetXG21CRTC(unsigned short ModeNo, unsigned short ModeIdIndex,
                Tempbx = (unsigned char) Temp1; /* Tempbx[1:0]: VRS[10:9] */
                Tempax |= Tempbx; /* VRE[5:0]VRS[10:9] */
                Tempax &= 0x7F;
-               xgifb_reg_set(pVBInfo->P3c4, 0x3F, Tempax); /* SR3F D[7:2]->VRE D[1:0]->VRS */
+               /* SR3F D[7:2]->VRE D[1:0]->VRS */
+               xgifb_reg_set(pVBInfo->P3c4, 0x3F, Tempax);
        } else {
                index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
-               Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[3]; /* Tempax: CR4 HRS */
+               /* Tempax: CR4 HRS */
+               Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[3];
                Tempcx = Tempax; /* Tempcx: HRS */
-               xgifb_reg_set(pVBInfo->P3c4, 0x2E, Tempax); /* SR2E[7:0]->HRS */
+               /* SR2E[7:0]->HRS */
+               xgifb_reg_set(pVBInfo->P3c4, 0x2E, Tempax);
 
                Tempdx = pVBInfo->XGINEWUB_CRT1Table[index].CR[5]; /* SRB */
                Tempdx &= 0xC0; /* Tempdx[7:6]: SRB[7:6] */
@@ -766,14 +804,17 @@ static void XGI_SetXG21CRTC(unsigned short ModeNo, unsigned short ModeIdIndex,
                Tempax <<= 2; /* Tempax[7:2]: HRE[5:0] */
                Tempdx >>= 6; /* Tempdx[7:6]->[1:0] HRS[9:8] */
                Tempax |= Tempdx; /* HRE[5:0]HRS[9:8] */
-               xgifb_reg_set(pVBInfo->P3c4, 0x2F, Tempax); /* SR2F D[7:2]->HRE, D[1:0]->HRS */
+               /* SR2F D[7:2]->HRE, D[1:0]->HRS */
+               xgifb_reg_set(pVBInfo->P3c4, 0x2F, Tempax);
                xgifb_reg_and_or(pVBInfo->P3c4, 0x30, 0xE3, 00);
 
-               Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[10]; /* CR10 VRS */
+               /* CR10 VRS */
+               Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[10];
                Tempbx = Tempax; /* Tempbx: VRS */
                Tempax &= 0x01; /* Tempax[0]: VRS[0] */
                xgifb_reg_or(pVBInfo->P3c4, 0x33, Tempax); /* SR33[0]->VRS[0] */
-               Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[9]; /* CR7[2][7] VRE */
+               /* CR7[2][7] VRE */
+               Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[9];
                Tempcx = Tempbx >> 1; /* Tempcx[6:0]: VRS[7:1] */
                Tempdx = Tempax & 0x04; /* Tempdx[2]: CR7[2] */
                Tempdx <<= 5; /* Tempdx[7]: VRS[8] */
@@ -786,15 +827,18 @@ static void XGI_SetXG21CRTC(unsigned short ModeNo, unsigned short ModeIdIndex,
                Tempax &= 0x80;
                Temp2 = Tempax << 2; /* Temp2[9]: VRS[9] */
                Temp1 |= Temp2; /* Temp1[9:0]: VRS[9:0] */
-               Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[14]; /* Tempax: SRA */
+               /* Tempax: SRA */
+               Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[14];
                Tempax &= 0x08; /* Tempax[3]: VRS[3] */
                Temp2 = Tempax;
                Temp2 <<= 7; /* Temp2[10]: VRS[10] */
                Temp1 |= Temp2; /* Temp1[10:0]: VRS[10:0] */
 
-               Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[11]; /* Tempax: CR11 VRE */
+               /* Tempax: CR11 VRE */
+               Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[11];
                Tempax &= 0x0F; /* Tempax[3:0]: VRE[3:0] */
-               Tempbx = pVBInfo->XGINEWUB_CRT1Table[index].CR[14]; /* Tempbx: SRA */
+               /* Tempbx: SRA */
+               Tempbx = pVBInfo->XGINEWUB_CRT1Table[index].CR[14];
                Tempbx &= 0x20; /* Tempbx[5]: VRE[5] */
                Tempbx >>= 1; /* Tempbx[4]: VRE[4] */
                Tempax |= Tempbx; /* Tempax[4:0]: VRE[4:0] */
@@ -813,21 +857,26 @@ static void XGI_SetXG21CRTC(unsigned short ModeNo, unsigned short ModeIdIndex,
                Tempbx = (unsigned char) Temp1;
                Tempax |= Tempbx; /* Tempax[7:0]: VRE[5:0]VRS[10:9] */
                Tempax &= 0x7F;
-               xgifb_reg_set(pVBInfo->P3c4, 0x3F, Tempax); /* SR3F D[7:2]->VRE D[1:0]->VRS */
+               /* SR3F D[7:2]->VRE D[1:0]->VRS */
+               xgifb_reg_set(pVBInfo->P3c4, 0x3F, Tempax);
        }
 }
 
-static void XGI_SetXG27CRTC(unsigned short ModeNo, unsigned short ModeIdIndex,
-               unsigned short RefreshRateTableIndex,
-               struct vb_device_info *pVBInfo)
+static void XGI_SetXG27CRTC(unsigned short ModeNo,
+                           unsigned short ModeIdIndex,
+                           unsigned short RefreshRateTableIndex,
+                           struct vb_device_info *pVBInfo)
 {
        unsigned short StandTableIndex, index, Tempax, Tempbx, Tempcx, Tempdx;
 
        if (ModeNo <= 0x13) {
                StandTableIndex = XGI_GetModePtr(ModeNo, ModeIdIndex, pVBInfo);
-               Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[4]; /* CR04 HRS */
-               xgifb_reg_set(pVBInfo->P3c4, 0x2E, Tempax); /* SR2E [7:0]->HRS */
-               Tempbx = pVBInfo->StandTable[StandTableIndex].CRTC[5]; /* Tempbx: CR05 HRE */
+               /* CR04 HRS */
+               Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[4];
+               /* SR2E [7:0]->HRS */
+               xgifb_reg_set(pVBInfo->P3c4, 0x2E, Tempax);
+               /* Tempbx: CR05 HRE */
+               Tempbx = pVBInfo->StandTable[StandTableIndex].CRTC[5];
                Tempbx &= 0x1F; /* Tempbx: HRE[4:0] */
                Tempcx = Tempax;
                Tempcx &= 0xE0; /* Tempcx: HRS[7:5] */
@@ -835,39 +884,50 @@ static void XGI_SetXG27CRTC(unsigned short ModeNo, unsigned short ModeIdIndex,
                if (Tempbx < (Tempax & 0x1F)) /* IF HRE < HRS */
                        Tempdx |= 0x20; /* Tempdx: HRE = HRE + 0x20 */
                Tempdx <<= 2; /* Tempdx << 2 */
-               xgifb_reg_set(pVBInfo->P3c4, 0x2F, Tempdx); /* SR2F [7:2]->HRE */
+               /* SR2F [7:2]->HRE */
+               xgifb_reg_set(pVBInfo->P3c4, 0x2F, Tempdx);
                xgifb_reg_and_or(pVBInfo->P3c4, 0x30, 0xE3, 00);
 
-               Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[16]; /* Tempax: CR10 VRS */
+               /* Tempax: CR10 VRS */
+               Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[16];
                xgifb_reg_set(pVBInfo->P3c4, 0x34, Tempax); /* SR34[7:0]->VRS */
                Tempcx = Tempax; /* Tempcx=Tempax=VRS[7:0] */
-               Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[7]; /* Tempax[7][2]: CR7[7][2] VRS[9][8] */
+               /* Tempax[7][2]: CR7[7][2] VRS[9][8] */
+               Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[7];
                Tempbx = Tempax; /* Tempbx=CR07 */
                Tempax &= 0x04; /* Tempax[2]: CR07[2] VRS[8] */
                Tempax >>= 2;
-               xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x01, Tempax); /* SR35 D[0]->VRS D[8] */
+               /* SR35 D[0]->VRS D[8] */
+               xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x01, Tempax);
                Tempcx |= (Tempax << 8); /* Tempcx[8] |= VRS[8] */
                Tempcx |= (Tempbx & 0x80) << 2; /* Tempcx[9] |= VRS[9] */
 
-               Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[17]; /* CR11 VRE */
+               /* CR11 VRE */
+               Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[17];
                Tempax &= 0x0F; /* Tempax: VRE[3:0] */
                Tempbx = Tempcx; /* Tempbx=Tempcx=VRS[9:0] */
                Tempbx &= 0x3F0; /* Tempbx[9:4]: VRS[9:4] */
                Tempbx |= Tempax; /* Tempbx[9:0]: VRE[9:0] */
                if (Tempax <= (Tempcx & 0x0F)) /* VRE[3:0]<=VRS[3:0] */
                        Tempbx |= 0x10; /* Tempbx: VRE + 0x10 */
-               Tempax = (unsigned char) Tempbx & 0xFF; /* Tempax[7:0]: VRE[7:0] */
+               /* Tempax[7:0]: VRE[7:0] */
+               Tempax = (unsigned char) Tempbx & 0xFF;
                Tempax <<= 2; /* Tempax << 2: VRE[5:0] */
                Tempcx = (Tempcx & 0x600) >> 8; /* Tempcx VRS[10:9] */
-               xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC, Tempax); /* SR3F D[7:2]->VRE D[5:0] */
-               xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x06, Tempcx); /* SR35 D[2:1]->VRS[10:9] */
+               /* SR3F D[7:2]->VRE D[5:0] */
+               xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC, Tempax);
+               /* SR35 D[2:1]->VRS[10:9] */
+               xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x06, Tempcx);
        } else {
                index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
-               Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[3]; /* Tempax: CR4 HRS */
+               /* Tempax: CR4 HRS */
+               Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[3];
                Tempbx = Tempax; /* Tempbx: HRS[7:0] */
-               xgifb_reg_set(pVBInfo->P3c4, 0x2E, Tempax); /* SR2E[7:0]->HRS */
+               /* SR2E[7:0]->HRS */
+               xgifb_reg_set(pVBInfo->P3c4, 0x2E, Tempax);
 
-               Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[5]; /* SR0B */
+               /* SR0B */
+               Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[5];
                Tempax &= 0xC0; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/
                Tempbx |= (Tempax << 2); /* Tempbx: HRS[9:0] */
 
@@ -883,7 +943,8 @@ static void XGI_SetXG27CRTC(unsigned short ModeNo, unsigned short ModeIdIndex,
                Tempbx = Tempbx & 0x3C0; /* Tempbx[9:6]: HRS[9:6] */
                Tempbx |= Tempcx; /* Tempbx: HRS[9:6]HRE[5:0] */
 
-               Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[3]; /* Tempax: CR4 HRS */
+               /* Tempax: CR4 HRS */
+               Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[3];
                Tempax &= 0x3F; /* Tempax: HRS[5:0] */
                if (Tempcx <= Tempax) /* HRE[5:0] < HRS[5:0] */
                        Tempbx += 0x40; /* Tempbx= Tempbx + 0x40 : HRE[9:0]*/
@@ -892,27 +953,35 @@ static void XGI_SetXG27CRTC(unsigned short ModeNo, unsigned short ModeIdIndex,
                Tempax &= 0xC0; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/
                Tempax >>= 6; /* Tempax[1:0]: HRS[9:8]*/
                Tempax |= ((Tempbx << 2) & 0xFF); /* Tempax[7:2]: HRE[5:0] */
-               xgifb_reg_set(pVBInfo->P3c4, 0x2F, Tempax); /* SR2F [7:2][1:0]: HRE[5:0]HRS[9:8] */
+               /* SR2F [7:2][1:0]: HRE[5:0]HRS[9:8] */
+               xgifb_reg_set(pVBInfo->P3c4, 0x2F, Tempax);
                xgifb_reg_and_or(pVBInfo->P3c4, 0x30, 0xE3, 00);
 
-               Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[10]; /* CR10 VRS */
-               xgifb_reg_set(pVBInfo->P3c4, 0x34, Tempax); /* SR34[7:0]->VRS[7:0] */
+               /* CR10 VRS */
+               Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[10];
+               /* SR34[7:0]->VRS[7:0] */
+               xgifb_reg_set(pVBInfo->P3c4, 0x34, Tempax);
 
                Tempcx = Tempax; /* Tempcx <= VRS[7:0] */
-               Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[9]; /* CR7[7][2] VRS[9][8] */
+               /* CR7[7][2] VRS[9][8] */
+               Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[9];
                Tempbx = Tempax; /* Tempbx <= CR07[7:0] */
                Tempax = Tempax & 0x04; /* Tempax[2]: CR7[2]: VRS[8] */
                Tempax >>= 2; /* Tempax[0]: VRS[8] */
-               xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x01, Tempax); /* SR35[0]: VRS[8] */
+               /* SR35[0]: VRS[8] */
+               xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x01, Tempax);
                Tempcx |= (Tempax << 8); /* Tempcx <= VRS[8:0] */
                Tempcx |= ((Tempbx & 0x80) << 2); /* Tempcx <= VRS[9:0] */
-               Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[14]; /* Tempax: SR0A */
+               /* Tempax: SR0A */
+               Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[14];
                Tempax &= 0x08; /* SR0A[3] VRS[10] */
                Tempcx |= (Tempax << 7); /* Tempcx <= VRS[10:0] */
 
-               Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[11]; /* Tempax: CR11 VRE */
+               /* Tempax: CR11 VRE */
+               Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[11];
                Tempax &= 0x0F; /* Tempax[3:0]: VRE[3:0] */
-               Tempbx = pVBInfo->XGINEWUB_CRT1Table[index].CR[14]; /* Tempbx: SR0A */
+               /* Tempbx: SR0A */
+               Tempbx = pVBInfo->XGINEWUB_CRT1Table[index].CR[14];
                Tempbx &= 0x20; /* Tempbx[5]: SR0A[5]: VRE[4] */
                Tempbx >>= 1; /* Tempbx[4]: VRE[4] */
                Tempax |= Tempbx; /* Tempax[4:0]: VRE[4:0] */
@@ -923,10 +992,13 @@ static void XGI_SetXG27CRTC(unsigned short ModeNo, unsigned short ModeIdIndex,
                if (Tempbx <= Tempcx) /* VRE <= VRS */
                        Tempbx |= 0x20; /* VRE + 0x20 */
 
-               Tempax = (Tempbx << 2) & 0xFF; /* Tempax: Tempax[7:0]; VRE[5:0]00 */
-               xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC, Tempax); /* SR3F[7:2]:VRE[5:0] */
+               /* Tempax: Tempax[7:0]; VRE[5:0]00 */
+               Tempax = (Tempbx << 2) & 0xFF;
+               /* SR3F[7:2]:VRE[5:0] */
+               xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC, Tempax);
                Tempax = Tempcx >> 8;
-               xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x07, Tempax); /* SR35[2:0]:VRS[10:8] */
+               /* SR35[2:0]:VRS[10:8] */
+               xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x07, Tempax);
        }
 }
 
@@ -970,20 +1042,25 @@ static void XGI_SetXG21LCD(struct vb_device_info *pVBInfo,
        if (ModeNo <= 0x13) {
                b3CC = (unsigned char) inb(XGI_P3cc);
                if (b3CC & 0x40)
-                       xgifb_reg_or(pVBInfo->P3c4, 0x30, 0x20); /* Hsync polarity */
+                       /* Hsync polarity */
+                       xgifb_reg_or(pVBInfo->P3c4, 0x30, 0x20);
                if (b3CC & 0x80)
-                       xgifb_reg_or(pVBInfo->P3c4, 0x35, 0x80); /* Vsync polarity */
+                       /* Vsync polarity */
+                       xgifb_reg_or(pVBInfo->P3c4, 0x35, 0x80);
        } else {
                Data = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
                if (Data & 0x4000)
-                       xgifb_reg_or(pVBInfo->P3c4, 0x30, 0x20); /* Hsync polarity */
+                       /* Hsync polarity */
+                       xgifb_reg_or(pVBInfo->P3c4, 0x30, 0x20);
                if (Data & 0x8000)
-                       xgifb_reg_or(pVBInfo->P3c4, 0x35, 0x80); /* Vsync polarity */
+                       /* Vsync polarity */
+                       xgifb_reg_or(pVBInfo->P3c4, 0x35, 0x80);
        }
 }
 
 static void XGI_SetXG27LCD(struct vb_device_info *pVBInfo,
-               unsigned short RefreshRateTableIndex, unsigned short ModeNo)
+                          unsigned short RefreshRateTableIndex,
+                          unsigned short ModeNo)
 {
        unsigned short Data, Temp, b3CC;
        unsigned short XGI_P3cc;
@@ -1018,15 +1095,19 @@ static void XGI_SetXG27LCD(struct vb_device_info *pVBInfo,
        if (ModeNo <= 0x13) {
                b3CC = (unsigned char) inb(XGI_P3cc);
                if (b3CC & 0x40)
-                       xgifb_reg_or(pVBInfo->P3c4, 0x30, 0x20); /* Hsync polarity */
+                       /* Hsync polarity */
+                       xgifb_reg_or(pVBInfo->P3c4, 0x30, 0x20);
                if (b3CC & 0x80)
-                       xgifb_reg_or(pVBInfo->P3c4, 0x35, 0x80); /* Vsync polarity */
+                       /* Vsync polarity */
+                       xgifb_reg_or(pVBInfo->P3c4, 0x35, 0x80);
        } else {
                Data = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
                if (Data & 0x4000)
-                       xgifb_reg_or(pVBInfo->P3c4, 0x30, 0x20); /* Hsync polarity */
+                       /* Hsync polarity */
+                       xgifb_reg_or(pVBInfo->P3c4, 0x30, 0x20);
                if (Data & 0x8000)
-                       xgifb_reg_or(pVBInfo->P3c4, 0x35, 0x80); /* Vsync polarity */
+                       /* Vsync polarity */
+                       xgifb_reg_or(pVBInfo->P3c4, 0x35, 0x80);
        }
 }
 
@@ -1036,8 +1117,9 @@ static void XGI_SetXG27LCD(struct vb_device_info *pVBInfo,
 /* Output : CRT1 CRTC */
 /* Description : Modify CRT1 Hsync/Vsync to fix LCD mode timing */
 /* --------------------------------------------------------------------- */
-static void XGI_UpdateXG21CRTC(unsigned short ModeNo, struct vb_device_info *pVBInfo,
-               unsigned short RefreshRateTableIndex)
+static void XGI_UpdateXG21CRTC(unsigned short ModeNo,
+                              struct vb_device_info *pVBInfo,
+                              unsigned short RefreshRateTableIndex)
 {
        int i, index = -1;
 
@@ -1048,13 +1130,13 @@ static void XGI_UpdateXG21CRTC(unsigned short ModeNo, struct vb_device_info *pVB
                                index = i;
                }
        } else {
-               if (ModeNo == 0x2E
-                               && (pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC
-                                               == RES640x480x60))
+               if (ModeNo == 0x2E &&
+                   (pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC ==
+                                                             RES640x480x60))
                        index = 12;
-               else if (ModeNo == 0x2E
-                               && (pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC
-                                               == RES640x480x72))
+               else if (ModeNo == 0x2E &&
+                        (pVBInfo->RefIndex[RefreshRateTableIndex].
+                               Ext_CRT1CRTC == RES640x480x72))
                        index = 13;
                else if (ModeNo == 0x2F)
                        index = 14;
@@ -1157,16 +1239,19 @@ unsigned short XGI_GetResInfo(unsigned short ModeNo,
        unsigned short resindex;
 
        if (ModeNo <= 0x13)
-               resindex = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; /* si+St_ResInfo */
+               /* si+St_ResInfo */
+               resindex = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
        else
-               resindex = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; /* si+Ext_ResInfo */
+               /* si+Ext_ResInfo */
+               resindex = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
        return resindex;
 }
 
-static void XGI_SetCRT1Offset(unsigned short ModeNo, unsigned short ModeIdIndex,
-               unsigned short RefreshRateTableIndex,
-               struct xgi_hw_device_info *HwDeviceExtension,
-               struct vb_device_info *pVBInfo)
+static void XGI_SetCRT1Offset(unsigned short ModeNo,
+                             unsigned short ModeIdIndex,
+                             unsigned short RefreshRateTableIndex,
+                             struct xgi_hw_device_info *HwDeviceExtension,
+                             struct vb_device_info *pVBInfo)
 {
        unsigned short temp, ah, al, temp2, i, DisplayUnit;
 
@@ -1254,29 +1339,39 @@ static unsigned short XGI_GetVCLK2Ptr(unsigned short ModeNo,
 {
        unsigned short tempbx;
 
-       unsigned short LCDXlat1VCLK[4] = { VCLK65 + 2, VCLK65 + 2, VCLK65 + 2,
-                       VCLK65 + 2 };
-       unsigned short LCDXlat2VCLK[4] = { VCLK108_2 + 5, VCLK108_2 + 5,
-                       VCLK108_2 + 5, VCLK108_2 + 5 };
+       unsigned short LCDXlat1VCLK[4] = { VCLK65 + 2,
+                                          VCLK65 + 2,
+                                          VCLK65 + 2,
+                                          VCLK65 + 2 };
+       unsigned short LCDXlat2VCLK[4] = { VCLK108_2 + 5,
+                                          VCLK108_2 + 5,
+                                          VCLK108_2 + 5,
+                                          VCLK108_2 + 5 };
        unsigned short LVDSXlat1VCLK[4] = { VCLK40, VCLK40, VCLK40, VCLK40 };
-       unsigned short LVDSXlat2VCLK[4] = { VCLK65 + 2, VCLK65 + 2, VCLK65 + 2,
-                       VCLK65 + 2 };
-       unsigned short LVDSXlat3VCLK[4] = { VCLK65 + 2, VCLK65 + 2, VCLK65 + 2,
-                       VCLK65 + 2 };
+       unsigned short LVDSXlat2VCLK[4] = { VCLK65 + 2,
+                                           VCLK65 + 2,
+                                           VCLK65 + 2,
+                                           VCLK65 + 2 };
+       unsigned short LVDSXlat3VCLK[4] = { VCLK65 + 2,
+                                           VCLK65 + 2,
+                                           VCLK65 + 2,
+                                           VCLK65 + 2 };
 
        unsigned short CRT2Index, VCLKIndex;
        unsigned short modeflag, resinfo;
        unsigned char *CHTVVCLKPtr = NULL;
 
        if (ModeNo <= 0x13) {
-               modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
+               /* si+St_ResInfo */
+               modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
                resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
                CRT2Index = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
        } else {
-               modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
+               /* si+Ext_ResInfo */
+               modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
                resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
-               CRT2Index
-                               = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
+               CRT2Index = pVBInfo->RefIndex[RefreshRateTableIndex].
+                               Ext_CRT2CRTC;
        }
 
        if (pVBInfo->IF_DEF_LVDS == 0) {
@@ -1291,41 +1386,35 @@ static unsigned short XGI_GetVCLK2Ptr(unsigned short ModeNo,
                                if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
                                        if (pVBInfo->SetFlag & RPLLDIV2XO) {
                                                VCLKIndex = HiTVVCLKDIV2;
-
                                                VCLKIndex += 25;
-
                                        } else {
                                                VCLKIndex = HiTVVCLK;
-
                                                VCLKIndex += 25;
-
                                        }
 
                                        if (pVBInfo->SetFlag & TVSimuMode) {
                                                if (modeflag & Charx8Dot) {
-                                                       VCLKIndex
-                                                                       = HiTVSimuVCLK;
-
+                                                       VCLKIndex =
+                                                               HiTVSimuVCLK;
                                                        VCLKIndex += 25;
-
                                                } else {
-                                                       VCLKIndex
-                                                                       = HiTVTextVCLK;
-
+                                                       VCLKIndex =
+                                                               HiTVTextVCLK;
                                                        VCLKIndex += 25;
-
                                                }
                                        }
 
-                                       if (pVBInfo->VBType & VB_XGI301LV) { /* 301lv */
-                                               if (!(pVBInfo->VBExtInfo
-                                                               == VB_YPbPr1080i)) {
-                                                       VCLKIndex
-                                                                       = YPbPr750pVCLK;
+                                       /* 301lv */
+                                       if (pVBInfo->VBType & VB_XGI301LV) {
+                                               if (!(pVBInfo->VBExtInfo ==
+                                                    VB_YPbPr1080i)) {
+                                                       VCLKIndex =
+                                                               YPbPr750pVCLK;
                                                        if (!(pVBInfo->VBExtInfo
-                                                                       == VB_YPbPr750p)) {
-                                                               VCLKIndex
-                                                                               = YPbPr525pVCLK;
+                                                                       ==
+                                                            VB_YPbPr750p)) {
+                                                               VCLKIndex =
+                                                                 YPbPr525pVCLK;
                                                                if (!(pVBInfo->VBExtInfo
                                                                                == VB_YPbPr525p)) {
                                                                        VCLKIndex
@@ -1340,27 +1429,27 @@ static unsigned short XGI_GetVCLK2Ptr(unsigned short ModeNo,
                                        }
                                } else {
                                        if (pVBInfo->VBInfo & SetCRT2ToTV) {
-                                               if (pVBInfo->SetFlag
-                                                               & RPLLDIV2XO) {
+                                               if (pVBInfo->SetFlag &
+                                                   RPLLDIV2XO) {
                                                        VCLKIndex = TVVCLKDIV2;
-
                                                        VCLKIndex += 25;
-
                                                } else {
                                                        VCLKIndex = TVVCLK;
-
                                                        VCLKIndex += 25;
-
                                                }
                                        }
                                }
                        } else { /* for CRT2 */
+                               /* Port 3cch */
                                VCLKIndex = (unsigned char) inb(
-                                               (pVBInfo->P3ca + 0x02)); /* Port 3cch */
+                                               (pVBInfo->P3ca + 0x02));
                                VCLKIndex = ((VCLKIndex >> 2) & 0x03);
                                if (ModeNo > 0x13) {
-                                       VCLKIndex
-                                                       = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; /* di+Ext_CRTVCLK */
+                                       /* di+Ext_CRTVCLK */
+                                       VCLKIndex =
+                                               pVBInfo->RefIndex[
+                                                       RefreshRateTableIndex].
+                                                               Ext_CRTVCLK;
                                        VCLKIndex &= IndexMask;
                                }
                        }
@@ -1403,12 +1492,11 @@ static unsigned short XGI_GetVCLK2Ptr(unsigned short ModeNo,
                        }
                } else {
                        VCLKIndex = VCLKIndex >> 6;
-                       if ((pVBInfo->LCDResInfo == Panel800x600)
-                                       || (pVBInfo->LCDResInfo == Panel320x480))
+                       if ((pVBInfo->LCDResInfo == Panel800x600) ||
+                           (pVBInfo->LCDResInfo == Panel320x480))
                                VCLKIndex = LVDSXlat1VCLK[VCLKIndex];
-                       else if ((pVBInfo->LCDResInfo == Panel1024x768)
-                                       || (pVBInfo->LCDResInfo
-                                                       == Panel1024x768x75))
+                       else if ((pVBInfo->LCDResInfo == Panel1024x768) ||
+                                (pVBInfo->LCDResInfo == Panel1024x768x75))
                                VCLKIndex = LVDSXlat2VCLK[VCLKIndex];
                        else
                                VCLKIndex = LVDSXlat3VCLK[VCLKIndex];
@@ -1419,10 +1507,11 @@ static unsigned short XGI_GetVCLK2Ptr(unsigned short ModeNo,
        return VCLKIndex;
 }
 
-static void XGI_SetCRT1VCLK(unsigned short ModeNo, unsigned short ModeIdIndex,
-               struct xgi_hw_device_info *HwDeviceExtension,
-               unsigned short RefreshRateTableIndex,
-               struct vb_device_info *pVBInfo)
+static void XGI_SetCRT1VCLK(unsigned short ModeNo,
+                           unsigned short ModeIdIndex,
+                           struct xgi_hw_device_info *HwDeviceExtension,
+                           unsigned short RefreshRateTableIndex,
+                           struct vb_device_info *pVBInfo)
 {
        unsigned char index, data;
        unsigned short vclkindex;
@@ -1461,7 +1550,8 @@ static void XGI_SetCRT1VCLK(unsigned short ModeNo, unsigned short ModeIdIndex,
        }
 
        if (HwDeviceExtension->jChipType >= XG20) {
-               if (pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag & HalfDCLK) {
+               if (pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag &
+                   HalfDCLK) {
                        data = xgifb_reg_get(pVBInfo->P3c4, 0x2B);
                        xgifb_reg_set(pVBInfo->P3c4, 0x2B, data);
                        data = xgifb_reg_get(pVBInfo->P3c4, 0x2C);
@@ -1575,10 +1665,11 @@ static void XGI_SetCRT1ModeRegs(struct xgi_hw_device_info *HwDeviceExtension,
 
        if (ModeNo > 0x13) {
                modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
-               infoflag
-                               = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
+               infoflag = pVBInfo->RefIndex[RefreshRateTableIndex].
+                               Ext_InfoFlag;
        } else
-               modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ModeFlag */
+               /* si+St_ModeFlag */
+               modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
 
        if (xgifb_reg_get(pVBInfo->P3d4, 0x31) & 0x01)
                xgifb_reg_and_or(pVBInfo->P3c4, 0x1F, 0x3F, 0x00);
@@ -1652,7 +1743,8 @@ static void XGI_SetCRT1ModeRegs(struct xgi_hw_device_info *HwDeviceExtension,
 
        /* if (modeflag&HalfDCLK) //030305 fix lowresolution bug */
        /* if (XGINew_IF_DEF_NEW_LOWRES) */
-       /* XGI_VesaLowResolution(ModeNo, ModeIdIndex); //030305 fix lowresolution bug */
+       /* XGI_VesaLowResolution(ModeNo, ModeIdIndex);
+        * //030305 fix lowresolution bug */
 
        data = xgifb_reg_get(pVBInfo->P3d4, 0x31);
 
@@ -1681,7 +1773,9 @@ static void XGI_SetCRT1ModeRegs(struct xgi_hw_device_info *HwDeviceExtension,
 }
 
 /*
-void XGI_VesaLowResolution(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
+void XGI_VesaLowResolution(unsigned short ModeNo,
+                          unsigned short ModeIdIndex,
+                          struct vb_device_info *pVBInfo)
 {
        unsigned short modeflag;
 
@@ -1693,17 +1787,37 @@ void XGI_VesaLowResolution(unsigned short ModeNo, unsigned short ModeIdIndex, st
        if (ModeNo > 0x13) {
                if (modeflag & DoubleScanMode) {
                        if (modeflag & HalfDCLK) {
-                               if (pVBInfo->VBType & VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) {
-                                       if (!(pVBInfo->VBInfo & SetCRT2ToRAMDAC)) {
-                                               if (pVBInfo->VBInfo & SetInSlaveMode) {
-                                                       xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xf7, 0x00);
-                                                       xgifb_reg_and_or(pVBInfo->P3c4, 0x0f, 0x7f, 0x00);
+                               if (pVBInfo->VBType & VB_XGI301B |
+                                                     VB_XGI302B |
+                                                     VB_XGI301LV |
+                                                     VB_XGI302LV |
+                                                     VB_XGI301C)) {
+                                       if (!(pVBInfo->VBInfo &
+                                            SetCRT2ToRAMDAC)) {
+                                               if (pVBInfo->VBInfo &
+                                                   SetInSlaveMode) {
+                                                       xgifb_reg_and_or(
+                                                               pVBInfo->P3c4,
+                                                               0x01,
+                                                               0xf7,
+                                                               0x00);
+                                                       xgifb_reg_and_or(
+                                                               pVBInfo->P3c4,
+                                                               0x0f,
+                                                               0x7f,
+                                                               0x00);
                                                        return;
                                                }
                                        }
                                }
-                               xgifb_reg_and_or(pVBInfo->P3c4, 0x0f, 0xff, 0x80);
-                               xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xf7, 0x00);
+                               xgifb_reg_and_or(pVBInfo->P3c4,
+                                                0x0f,
+                                                0xff,
+                                                0x80);
+                               xgifb_reg_and_or(pVBInfo->P3c4,
+                                                0x01,
+                                                0xf7,
+                                                0x00);
                                return;
                        }
                }
@@ -1712,8 +1826,11 @@ void XGI_VesaLowResolution(unsigned short ModeNo, unsigned short ModeIdIndex, st
 }
 */
 
-static void XGI_WriteDAC(unsigned short dl, unsigned short ah, unsigned short al,
-               unsigned short dh, struct vb_device_info *pVBInfo)
+static void XGI_WriteDAC(unsigned short dl,
+                        unsigned short ah,
+                        unsigned short al,
+                        unsigned short dh,
+                        struct vb_device_info *pVBInfo)
 {
        unsigned short temp, bh, bl;
 
@@ -1831,15 +1948,18 @@ static void XGI_LoadDAC(unsigned short ModeNo, unsigned short ModeIdIndex,
        }
 }
 
-static void XGI_GetLVDSResInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
-               struct vb_device_info *pVBInfo)
+static void XGI_GetLVDSResInfo(unsigned short ModeNo,
+                              unsigned short ModeIdIndex,
+                              struct vb_device_info *pVBInfo)
 {
        unsigned short resindex, xres, yres, modeflag;
 
        if (ModeNo <= 0x13)
-               modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; /* si+St_ResInfo */
+               /* si+St_ResInfo */
+               modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
        else
-               modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; /* si+Ext_ResInfo */
+               /* si+Ext_ResInfo */
+               modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
 
        /* if (ModeNo > 0x13) */
        /*      modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; */
@@ -1847,9 +1967,11 @@ static void XGI_GetLVDSResInfo(unsigned short ModeNo, unsigned short ModeIdIndex
        /*      modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; */
 
        if (ModeNo <= 0x13)
-               resindex = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; /* si+St_ResInfo */
+               /* si+St_ResInfo */
+               resindex = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
        else
-               resindex = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; /* si+Ext_ResInfo */
+               /* si+Ext_ResInfo */
+               resindex = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
 
        /* resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo); */
 
@@ -1903,19 +2025,21 @@ static void *XGI_GetLcdPtr(unsigned short BX, unsigned short ModeNo,
 
        if (tempbx <= 1) { /* ExpLink */
                if (ModeNo <= 0x13) {
-                       tempal = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC; /* find no Ext_CRT2CRTC2 */
+                       /* find no Ext_CRT2CRTC2 */
+                       tempal = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
                } else {
-                       tempal
-                                       = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
+                       tempal = pVBInfo->RefIndex[RefreshRateTableIndex].
+                                       Ext_CRT2CRTC;
                }
 
                if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
                        if (ModeNo <= 0x13)
-                               tempal
-                                               = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC2;
+                               tempal = pVBInfo->SModeIDTable[ModeIdIndex].
+                                               St_CRT2CRTC2;
                        else
-                               tempal
-                                               = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC2;
+                               tempal = pVBInfo->RefIndex[
+                                               RefreshRateTableIndex].
+                                                       Ext_CRT2CRTC2;
                }
 
                if (tempbx & 0x01)
@@ -1933,7 +2057,8 @@ static void *XGI_GetLcdPtr(unsigned short BX, unsigned short ModeNo,
                        tempcx = LVDSDesDataLen2;
        }
        /* mov di, word ptr cs:LCDDataList[bx] */
-       /* tempdi = pVideoMemory[LCDDataList + tempbx * 2] | (pVideoMemory[LCDDataList + tempbx * 2 + 1] << 8); */
+       /* tempdi = pVideoMemory[LCDDataList + tempbx * 2] |
+                   (pVideoMemory[LCDDataList + tempbx * 2 + 1] << 8); */
 
        switch (tempbx) {
        case 0:
@@ -2243,36 +2368,36 @@ static void *XGI_GetLcdPtr(unsigned short BX, unsigned short ModeNo,
                        return &XGI_CetLCDDes1024x768Data[tempal];
                        break;
                case 3:
-                       if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
-                                       & VB_XGI302LV))
+                       if ((pVBInfo->VBType & VB_XGI301LV) ||
+                               (pVBInfo->VBType & VB_XGI302LV))
                                return &XGI_ExtLCDDLDes1280x1024Data[tempal];
                        else
                                return &XGI_ExtLCDDes1280x1024Data[tempal];
                        break;
                case 4:
-                       if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
-                                       & VB_XGI302LV))
+                       if ((pVBInfo->VBType & VB_XGI301LV) ||
+                           (pVBInfo->VBType & VB_XGI302LV))
                                return &XGI_StLCDDLDes1280x1024Data[tempal];
                        else
                                return &XGI_StLCDDes1280x1024Data[tempal];
                        break;
                case 5:
-                       if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
-                                       & VB_XGI302LV))
+                       if ((pVBInfo->VBType & VB_XGI301LV) ||
+                           (pVBInfo->VBType & VB_XGI302LV))
                                return &XGI_CetLCDDLDes1280x1024Data[tempal];
                        else
                                return &XGI_CetLCDDes1280x1024Data[tempal];
                        break;
                case 6:
-                       if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
-                                       & VB_XGI302LV))
+                       if ((pVBInfo->VBType & VB_XGI301LV) ||
+                           (pVBInfo->VBType & VB_XGI302LV))
                                return &XGI_ExtLCDDLDes1400x1050Data[tempal];
                        else
                                return &XGI_ExtLCDDes1400x1050Data[tempal];
                        break;
                case 7:
-                       if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
-                                       & VB_XGI302LV))
+                       if ((pVBInfo->VBType & VB_XGI301LV) ||
+                           (pVBInfo->VBType & VB_XGI302LV))
                                return &XGI_StLCDDLDes1400x1050Data[tempal];
                        else
                                return &XGI_StLCDDes1400x1050Data[tempal];
@@ -2284,15 +2409,15 @@ static void *XGI_GetLcdPtr(unsigned short BX, unsigned short ModeNo,
                        return &XGI_CetLCDDes1400x1050Data2[tempal];
                        break;
                case 10:
-                       if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
-                                       & VB_XGI302LV))
+                       if ((pVBInfo->VBType & VB_XGI301LV) ||
+                           (pVBInfo->VBType & VB_XGI302LV))
                                return &XGI_ExtLCDDLDes1600x1200Data[tempal];
                        else
                                return &XGI_ExtLCDDes1600x1200Data[tempal];
                        break;
                case 11:
-                       if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
-                                       & VB_XGI302LV))
+                       if ((pVBInfo->VBType & VB_XGI301LV) ||
+                           (pVBInfo->VBType & VB_XGI302LV))
                                return &XGI_StLCDDLDes1600x1200Data[tempal];
                        else
                                return &XGI_StLCDDes1600x1200Data[tempal];
@@ -2310,22 +2435,22 @@ static void *XGI_GetLcdPtr(unsigned short BX, unsigned short ModeNo,
                        return &XGI_CetLCDDes1024x768x75Data[tempal];
                        break;
                case 16:
-                       if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
-                                       & VB_XGI302LV))
+                       if ((pVBInfo->VBType & VB_XGI301LV) ||
+                           (pVBInfo->VBType & VB_XGI302LV))
                                return &XGI_ExtLCDDLDes1280x1024x75Data[tempal];
                        else
                                return &XGI_ExtLCDDes1280x1024x75Data[tempal];
                        break;
                case 17:
-                       if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
-                                       & VB_XGI302LV))
+                       if ((pVBInfo->VBType & VB_XGI301LV) ||
+                           (pVBInfo->VBType & VB_XGI302LV))
                                return &XGI_StLCDDLDes1280x1024x75Data[tempal];
                        else
                                return &XGI_StLCDDes1280x1024x75Data[tempal];
                        break;
                case 18:
-                       if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
-                                       & VB_XGI302LV))
+                       if ((pVBInfo->VBType & VB_XGI301LV) ||
+                           (pVBInfo->VBType & VB_XGI302LV))
                                return &XGI_CetLCDDLDes1280x1024x75Data[tempal];
                        else
                                return &XGI_CetLCDDes1280x1024x75Data[tempal];
@@ -2423,7 +2548,8 @@ static void *XGI_GetTVPtr(unsigned short BX, unsigned short ModeNo,
                i++;
        }
 
-       if (table == 0x00) { /* 07/05/22 */
+       /* 07/05/22 */
+       if (table == 0x00) {
        } else if (table == 0x01) {
        } else if (table == 0x04) {
                switch (tempdi[i].DATAPTR) {
@@ -2528,14 +2654,12 @@ static void XGI_GetLVDSData(unsigned short ModeNo, unsigned short ModeIdIndex,
        if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
                if (!(pVBInfo->LCDInfo & (SetLCDtoNonExpanding
                                | EnableScalingLCD))) {
-                       if ((pVBInfo->LCDResInfo == Panel1024x768)
-                                       || (pVBInfo->LCDResInfo
-                                                       == Panel1024x768x75)) {
+                       if ((pVBInfo->LCDResInfo == Panel1024x768) ||
+                           (pVBInfo->LCDResInfo == Panel1024x768x75)) {
                                pVBInfo->HDE = 1024;
                                pVBInfo->VDE = 768;
-                       } else if ((pVBInfo->LCDResInfo == Panel1280x1024)
-                                       || (pVBInfo->LCDResInfo
-                                                       == Panel1280x1024x75)) {
+                       } else if ((pVBInfo->LCDResInfo == Panel1280x1024) ||
+                                  (pVBInfo->LCDResInfo == Panel1280x1024x75)) {
                                pVBInfo->HDE = 1280;
                                pVBInfo->VDE = 1024;
                        } else if (pVBInfo->LCDResInfo == Panel1400x1050) {
@@ -2569,17 +2693,17 @@ static void XGI_ModCRT1Regs(unsigned short ModeNo, unsigned short ModeIdIndex,
 
        index = index & IndexMask;
 
-       if ((pVBInfo->IF_DEF_ScaleLCD == 0) || ((pVBInfo->IF_DEF_ScaleLCD == 1)
-                       && (!(pVBInfo->LCDInfo & EnableScalingLCD)))) {
+       if ((pVBInfo->IF_DEF_ScaleLCD == 0) ||
+           ((pVBInfo->IF_DEF_ScaleLCD == 1) &&
+           (!(pVBInfo->LCDInfo & EnableScalingLCD)))) {
                tempbx = 0;
 
                if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
-                       LCDPtr
-                                       = (struct XGI_LVDSCRT1HDataStruct *) XGI_GetLcdPtr(
-                                                       tempbx, ModeNo,
-                                                       ModeIdIndex,
-                                                       RefreshRateTableIndex,
-                                                       pVBInfo);
+                       LCDPtr = (struct XGI_LVDSCRT1HDataStruct *)
+                                       XGI_GetLcdPtr(tempbx, ModeNo,
+                                                     ModeIdIndex,
+                                                     RefreshRateTableIndex,
+                                                     pVBInfo);
 
                        for (i = 0; i < 8; i++)
                                pVBInfo->TimingH[0].data[i] = LCDPtr[0].Reg[i];
@@ -2587,23 +2711,30 @@ static void XGI_ModCRT1Regs(unsigned short ModeNo, unsigned short ModeIdIndex,
 
                if (pVBInfo->IF_DEF_CH7007 == 1) {
                        if (pVBInfo->VBInfo & SetCRT2ToTV) {
-                               CH7007TV_TimingHPtr
-                                               = (struct XGI_CH7007TV_TimingHStruct *) XGI_GetTVPtr(
-                                                               tempbx,
-                                                               ModeNo,
-                                                               ModeIdIndex,
-                                                               RefreshRateTableIndex,
-                                                               pVBInfo);
+                               CH7007TV_TimingHPtr =
+                                       (struct XGI_CH7007TV_TimingHStruct *)
+                                               XGI_GetTVPtr(
+                                                       tempbx,
+                                                       ModeNo,
+                                                       ModeIdIndex,
+                                                       RefreshRateTableIndex,
+                                                       pVBInfo);
 
                                for (i = 0; i < 8; i++)
-                                       pVBInfo->TimingH[0].data[i]
-                                                       = CH7007TV_TimingHPtr[0].data[i];
+                                       pVBInfo->TimingH[0].data[i] =
+                                               CH7007TV_TimingHPtr[0].data[i];
                        }
                }
 
                /* if (pVBInfo->IF_DEF_CH7017 == 1) {
                        if (pVBInfo->VBInfo & SetCRT2ToTV)
-                               TVPtr = (struct XGI330_CHTVDataStruct *)XGI_GetTVPtr(tempbx, ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
+                               TVPtr = (struct XGI330_CHTVDataStruct *)
+                                               XGI_GetTVPtr(
+                                                       tempbx,
+                                                       ModeNo,
+                                                       ModeIdIndex,
+                                                       RefreshRateTableIndex,
+                                                       pVBInfo);
                }
                */
 
@@ -2619,34 +2750,41 @@ static void XGI_ModCRT1Regs(unsigned short ModeNo, unsigned short ModeIdIndex,
                tempbx = 1;
 
                if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
-                       LCDPtr1
-                                       = (struct XGI_LVDSCRT1VDataStruct *) XGI_GetLcdPtr(
-                                                       tempbx, ModeNo,
-                                                       ModeIdIndex,
-                                                       RefreshRateTableIndex,
-                                                       pVBInfo);
+                       LCDPtr1 = (struct XGI_LVDSCRT1VDataStruct *)
+                                       XGI_GetLcdPtr(
+                                               tempbx,
+                                               ModeNo,
+                                               ModeIdIndex,
+                                               RefreshRateTableIndex,
+                                               pVBInfo);
                        for (i = 0; i < 7; i++)
                                pVBInfo->TimingV[0].data[i] = LCDPtr1[0].Reg[i];
                }
 
                if (pVBInfo->IF_DEF_CH7007 == 1) {
                        if (pVBInfo->VBInfo & SetCRT2ToTV) {
-                               CH7007TV_TimingVPtr
-                                               = (struct XGI_CH7007TV_TimingVStruct *) XGI_GetTVPtr(
-                                                               tempbx,
-                                                               ModeNo,
-                                                               ModeIdIndex,
-                                                               RefreshRateTableIndex,
-                                                               pVBInfo);
+                               CH7007TV_TimingVPtr =
+                                       (struct XGI_CH7007TV_TimingVStruct *)
+                                               XGI_GetTVPtr(
+                                                       tempbx,
+                                                       ModeNo,
+                                                       ModeIdIndex,
+                                                       RefreshRateTableIndex,
+                                                       pVBInfo);
 
                                for (i = 0; i < 7; i++)
-                                       pVBInfo->TimingV[0].data[i]
-                                                       = CH7007TV_TimingVPtr[0].data[i];
+                                       pVBInfo->TimingV[0].data[i] =
+                                               CH7007TV_TimingVPtr[0].data[i];
                        }
                }
                /* if (pVBInfo->IF_DEF_CH7017 == 1) {
                        if (pVBInfo->VBInfo & SetCRT2ToTV)
-                               TVPtr = (struct XGI330_CHTVDataStruct *)XGI_GetTVPtr(tempbx, ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
+                               TVPtr = (struct XGI330_CHTVDataStruct *)
+                                       XGI_GetTVPtr(tempbx,
+                                                    ModeNo,
+                                                    ModeIdIndex,
+                                                    RefreshRateTableIndex,
+                                                    pVBInfo);
                }
                */
 
@@ -2723,8 +2861,9 @@ static unsigned short XGI_GetLCDCapPtr1(struct vb_device_info *pVBInfo)
        return i;
 }
 
-static void XGI_GetLCDSync(unsigned short *HSyncWidth, unsigned short *VSyncWidth,
-               struct vb_device_info *pVBInfo)
+static void XGI_GetLCDSync(unsigned short *HSyncWidth,
+                          unsigned short *VSyncWidth,
+                          struct vb_device_info *pVBInfo)
 {
        unsigned short Index;
 
@@ -2754,33 +2893,35 @@ static void XGI_SetLVDSRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
                                & (SetCRT2ToLCD | SetCRT2ToLCDA))) {
                        if (pVBInfo->IF_DEF_OEMUtil == 1) {
                                tempbx = 8;
-                               LCDPtr
-                                               = (struct XGI330_LCDDataDesStruct *) XGI_GetLcdPtr(
-                                                               tempbx,
-                                                               ModeNo,
-                                                               ModeIdIndex,
-                                                               RefreshRateTableIndex,
-                                                               pVBInfo);
+                               LCDPtr = (struct XGI330_LCDDataDesStruct *)
+                                       XGI_GetLcdPtr(tempbx,
+                                                     ModeNo,
+                                                     ModeIdIndex,
+                                                     RefreshRateTableIndex,
+                                                     pVBInfo);
                        }
 
-                       if ((pVBInfo->IF_DEF_OEMUtil == 0) || (LCDPtr == NULL)) {
+                       if ((pVBInfo->IF_DEF_OEMUtil == 0) ||
+                           (LCDPtr == NULL)) {
                                tempbx = 3;
                                if (pVBInfo->LCDInfo & EnableScalingLCD)
-                                       LCDPtr1
-                                                       = (struct XGI330_LCDDataDesStruct2 *) XGI_GetLcdPtr(
-                                                                       tempbx,
-                                                                       ModeNo,
-                                                                       ModeIdIndex,
-                                                                       RefreshRateTableIndex,
-                                                                       pVBInfo);
+                                       LCDPtr1 =
+                                           (struct XGI330_LCDDataDesStruct2 *)
+                                                       XGI_GetLcdPtr(
+                                                         tempbx,
+                                                         ModeNo,
+                                                         ModeIdIndex,
+                                                         RefreshRateTableIndex,
+                                                         pVBInfo);
                                else
-                                       LCDPtr
-                                                       = (struct XGI330_LCDDataDesStruct *) XGI_GetLcdPtr(
-                                                                       tempbx,
-                                                                       ModeNo,
-                                                                       ModeIdIndex,
-                                                                       RefreshRateTableIndex,
-                                                                       pVBInfo);
+                                       LCDPtr =
+                                           (struct XGI330_LCDDataDesStruct *)
+                                                       XGI_GetLcdPtr(
+                                                         tempbx,
+                                                         ModeNo,
+                                                         ModeIdIndex,
+                                                         RefreshRateTableIndex,
+                                                         pVBInfo);
                        }
 
                        XGI_GetLCDSync(&tempax, &tempbx, pVBInfo);
@@ -2788,14 +2929,12 @@ static void XGI_SetLVDSRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
                        push2 = tempax;
 
                        /* GetLCDResInfo */
-                       if ((pVBInfo->LCDResInfo == Panel1024x768)
-                                       || (pVBInfo->LCDResInfo
-                                                       == Panel1024x768x75)) {
+                       if ((pVBInfo->LCDResInfo == Panel1024x768) ||
+                           (pVBInfo->LCDResInfo == Panel1024x768x75)) {
                                tempax = 1024;
                                tempbx = 768;
-                       } else if ((pVBInfo->LCDResInfo == Panel1280x1024)
-                                       || (pVBInfo->LCDResInfo
-                                                       == Panel1280x1024x75)) {
+                       } else if ((pVBInfo->LCDResInfo == Panel1280x1024) ||
+                                  (pVBInfo->LCDResInfo == Panel1280x1024x75)) {
                                tempax = 1280;
                                tempbx = 1024;
                        } else if (pVBInfo->LCDResInfo == Panel1400x1050) {
@@ -2813,8 +2952,8 @@ static void XGI_SetLVDSRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
                                pVBInfo->VGAVDE = tempbx;
                        }
 
-                       if ((pVBInfo->IF_DEF_ScaleLCD == 1)
-                                       && (pVBInfo->LCDInfo & EnableScalingLCD)) {
+                       if ((pVBInfo->IF_DEF_ScaleLCD == 1) &&
+                           (pVBInfo->LCDInfo & EnableScalingLCD)) {
                                tempax = pVBInfo->HDE;
                                tempbx = pVBInfo->VDE;
                        }
@@ -2961,16 +3100,18 @@ static void XGI_SetLVDSRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
 
                        if (pVBInfo->VBType & VB_XGI301C) {
                                temp2 = push3;
-                               xgifb_reg_set(pVBInfo->Part4Port, 0x3c,
-                                               (unsigned short) (temp2 & 0xff));
-                               xgifb_reg_set(pVBInfo->Part4Port, 0x3b,
-                                               (unsigned short) ((temp2 >> 8)
-                                                               & 0xff));
+                               xgifb_reg_set(pVBInfo->Part4Port,
+                                             0x3c,
+                                             (unsigned short) (temp2 & 0xff));
+                               xgifb_reg_set(pVBInfo->Part4Port,
+                                             0x3b,
+                                             (unsigned short) ((temp2 >> 8) &
+                                             0xff));
                                tempbx = (unsigned short) (temp2 >> 16);
                                xgifb_reg_and_or(pVBInfo->Part4Port, 0x3a,
                                                ~0xc0,
-                                               (unsigned short) ((tempbx
-                                                               & 0xff) << 6));
+                                               (unsigned short) ((tempbx &
+                                                                  0xff) << 6));
 
                                tempcx = pVBInfo->VGAVDE;
                                if (tempcx == pVBInfo->VDE)
@@ -3072,12 +3213,14 @@ static unsigned char XGI_GetVCLKPtr(unsigned short RefreshRateTableIndex,
        unsigned char *CHTVVCLKPtr = NULL;
 
        if (ModeNo <= 0x13)
-               modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
+               /* si+St_ResInfo */
+               modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
        else
-               modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
+               /* si+Ext_ResInfo */
+               modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
 
-       if ((pVBInfo->SetFlag & ProgrammingCRT2) && (!(pVBInfo->LCDInfo
-                       & EnableScalingLCD))) { /* {LCDA/LCDB} */
+       if ((pVBInfo->SetFlag & ProgrammingCRT2) &&
+           (!(pVBInfo->LCDInfo & EnableScalingLCD))) { /* {LCDA/LCDB} */
                index = XGI_GetLCDCapPtr(pVBInfo);
                tempal = pVBInfo->LCDCapList[index].LCD_VCLK;
 
@@ -3085,8 +3228,12 @@ static unsigned char XGI_GetVCLKPtr(unsigned short RefreshRateTableIndex,
                        return tempal;
 
                /* {TV} */
-               if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
-                               | VB_XGI302LV | VB_XGI301C)) {
+               if (pVBInfo->VBType &
+                   (VB_XGI301B |
+                    VB_XGI302B |
+                    VB_XGI301LV |
+                    VB_XGI302LV |
+                    VB_XGI301C)) {
                        if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
                                tempal = HiTVVCLKDIV2;
                                if (!(pVBInfo->TVInfo & RPLLDIV2XO))
@@ -3121,11 +3268,14 @@ static unsigned char XGI_GetVCLKPtr(unsigned short RefreshRateTableIndex,
                        if (pVBInfo->VBInfo & SetCRT2ToTV)
                                return tempal;
                }
-               /* else if ((pVBInfo->IF_DEF_CH7017==1)&&(pVBInfo->VBType&VB_CH7017)) {
+               /* else if ((pVBInfo->IF_DEF_CH7017==1) &&
+                           (pVBInfo->VBType&VB_CH7017)) {
                        if (ModeNo<=0x13)
-                               *tempal = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
+                               *tempal = pVBInfo->SModeIDTable[ModeIdIndex].
+                                               St_CRT2CRTC;
                        else
-                               *tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
+                               *tempal = pVBInfo->RefIndex[
+                                       RefreshRateTableIndex].Ext_CRT2CRTC;
                        *tempal = *tempal & 0x1F;
                        tempbx = 0;
                        if (pVBInfo->TVInfo & SetPALTV)
@@ -3136,15 +3286,18 @@ static unsigned char XGI_GetVCLKPtr(unsigned short RefreshRateTableIndex,
                } */
        } /* {End of VB} */
 
-       if ((pVBInfo->IF_DEF_CH7007 == 1) && (pVBInfo->VBType & VB_CH7007)) { /* [Billy] 07/05/08 CH7007 */
-               /* VideoDebugPrint((0, "XGI_GetVCLKPtr: pVBInfo->IF_DEF_CH7007==1\n")); */
+       if ((pVBInfo->IF_DEF_CH7007 == 1) &&
+           (pVBInfo->VBType & VB_CH7007)) { /* [Billy] 07/05/08 CH7007 */
+               /* VideoDebugPrint((
+                       0,
+                       "XGI_GetVCLKPtr: pVBInfo->IF_DEF_CH7007==1\n")); */
                if ((pVBInfo->VBInfo & SetCRT2ToTV)) {
                        if (ModeNo <= 0x13) {
-                               tempal
-                                               = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
+                               tempal = pVBInfo->SModeIDTable[ModeIdIndex].
+                                       St_CRT2CRTC;
                        } else {
-                               tempal
-                                               = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
+                               tempal = pVBInfo->RefIndex[
+                                       RefreshRateTableIndex].Ext_CRT2CRTC;
                        }
 
                        tempal = tempal & 0x0F;
@@ -3208,7 +3361,8 @@ static unsigned char XGI_GetVCLKPtr(unsigned short RefreshRateTableIndex,
        tempal = tempal >> 2;
        tempal &= 0x03;
 
-       if ((pVBInfo->LCDInfo & EnableScalingLCD) && (modeflag & Charx8Dot)) /* for Dot8 Scaling LCD */
+       /* for Dot8 Scaling LCD */
+       if ((pVBInfo->LCDInfo & EnableScalingLCD) && (modeflag & Charx8Dot))
                tempal = tempal ^ tempal; /* ; set to VCLK25MHz always */
 
        if (ModeNo <= 0x13)
@@ -3222,7 +3376,9 @@ static void XGI_GetVCLKLen(unsigned char tempal, unsigned char *di_0,
                unsigned char *di_1, struct vb_device_info *pVBInfo)
 {
        if (pVBInfo->IF_DEF_CH7007 == 1) { /* [Billy] 2007/05/16 */
-               /* VideoDebugPrint((0, "XGI_GetVCLKLen: pVBInfo->IF_DEF_CH7007==1\n")); */
+               /* VideoDebugPrint((
+                       0,
+                       "XGI_GetVCLKLen: pVBInfo->IF_DEF_CH7007==1\n")); */
                *di_0 = (unsigned char) XGI_CH7007VCLKData[tempal].SR2B;
                *di_1 = (unsigned char) XGI_CH7007VCLKData[tempal].SR2C;
        } else if (pVBInfo->VBType & (VB_XGI301 | VB_XGI301B | VB_XGI302B
@@ -3291,7 +3447,8 @@ static void XGI_UpdateModeInfo(struct xgi_hw_device_info *HwDeviceExtension,
                temp &= 0x0f;
 
                if (!(temp == 0x08)) {
-                       tempax = xgifb_reg_get(pVBInfo->Part1Port, 0x13); /* Check ChannelA by Part1_13 [2003/10/03] */
+                       /* Check ChannelA by Part1_13 [2003/10/03] */
+                       tempax = xgifb_reg_get(pVBInfo->Part1Port, 0x13);
                        if (tempax & 0x04)
                                tempcl = tempcl | ActiveLCD;
 
@@ -3388,13 +3545,12 @@ void XGI_GetVBType(struct vb_device_info *pVBInfo)
                                                tempbx = VB_XGI301LV;
                                                if (flag >= 0xE0) {
                                                        tempbx = VB_XGI302LV;
-                                                       tempah
-                                                                       = xgifb_reg_get(
-                                                                                       pVBInfo->Part4Port,
-                                                                                       0x39);
+                                                       tempah = xgifb_reg_get(
+                                                           pVBInfo->Part4Port,
+                                                           0x39);
                                                        if (tempah != 0xFF)
-                                                               tempbx
-                                                                               = VB_XGI301C;
+                                                               tempbx =
+                                                                   VB_XGI301C;
                                                }
                                        }
                                }
@@ -3436,7 +3592,8 @@ void XGI_GetVBInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
        tempbx = 0;
 
        if (pVBInfo->VBType & 0xFFFF) {
-               temp = xgifb_reg_get(pVBInfo->P3d4, 0x30); /* Check Display Device */
+               /* Check Display Device */
+               temp = xgifb_reg_get(pVBInfo->P3d4, 0x30);
                tempbx = tempbx | temp;
                temp = xgifb_reg_get(pVBInfo->P3d4, 0x31);
                push = temp;
@@ -3455,29 +3612,34 @@ void XGI_GetVBInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
                        if ((pVBInfo->Set_VGAType >= XG20)
                                        || (pVBInfo->Set_VGAType >= XG40)) {
                                if (pVBInfo->IF_DEF_LVDS == 0) {
-                                       /* if ((pVBInfo->VBType & VB_XGI302B) || (pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType & VB_XGI302LV) || (pVBInfo->VBType & VB_XGI301C)) */
-                                       if (pVBInfo->VBType & (VB_XGI302B
-                                                       | VB_XGI301LV
-                                                       | VB_XGI302LV
-                                                       | VB_XGI301C)) {
+                                       /* if ((pVBInfo->VBType & VB_XGI302B)
+                                           || (pVBInfo->VBType & VB_XGI301LV)
+                                           || (pVBInfo->VBType & VB_XGI302LV)
+                                           || (pVBInfo->VBType & VB_XGI301C))
+                                       */
+                                       if (pVBInfo->VBType &
+                                           (VB_XGI302B |
+                                            VB_XGI301LV |
+                                            VB_XGI302LV |
+                                            VB_XGI301C)) {
                                                if (temp & EnableDualEdge) {
-                                                       tempbx
-                                                                       |= SetCRT2ToDualEdge;
+                                                       tempbx |=
+                                                           SetCRT2ToDualEdge;
 
                                                        if (temp & SetToLCDA)
-                                                               tempbx
-                                                                               |= SetCRT2ToLCDA;
+                                                               tempbx |=
+                                                                 SetCRT2ToLCDA;
                                                }
                                        }
                                } else if (pVBInfo->IF_DEF_CH7017 == 1) {
                                        if (pVBInfo->VBType & VB_CH7017) {
                                                if (temp & EnableDualEdge) {
-                                                       tempbx
-                                                                       |= SetCRT2ToDualEdge;
+                                                       tempbx |=
+                                                           SetCRT2ToDualEdge;
 
                                                        if (temp & SetToLCDA)
-                                                               tempbx
-                                                                               |= SetCRT2ToLCDA;
+                                                               tempbx |=
+                                                                 SetCRT2ToLCDA;
                                                }
                                        }
                                }
@@ -3485,29 +3647,30 @@ void XGI_GetVBInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
                }
 
                if (pVBInfo->IF_DEF_YPbPr == 1) {
-                       if (((pVBInfo->IF_DEF_LVDS == 0) && ((pVBInfo->VBType
-                                       & VB_XGI301LV) || (pVBInfo->VBType
-                                       & VB_XGI302LV) || (pVBInfo->VBType
-                                       & VB_XGI301C)))
-                                       || ((pVBInfo->IF_DEF_CH7017 == 1)
-                                                       && (pVBInfo->VBType
-                                                                       & VB_CH7017))
-                                       || ((pVBInfo->IF_DEF_CH7007 == 1)
-                                                       && (pVBInfo->VBType
-                                                                       & VB_CH7007))) { /* [Billy] 07/05/04 */
+                       /* [Billy] 07/05/04 */
+                       if (((pVBInfo->IF_DEF_LVDS == 0) &&
+                           ((pVBInfo->VBType & VB_XGI301LV) ||
+                           (pVBInfo->VBType & VB_XGI302LV) ||
+                           (pVBInfo->VBType & VB_XGI301C))) ||
+                           ((pVBInfo->IF_DEF_CH7017 == 1) &&
+                           (pVBInfo->VBType & VB_CH7017)) ||
+                           ((pVBInfo->IF_DEF_CH7007 == 1) &&
+                           (pVBInfo->VBType & VB_CH7007))) {
                                if (temp & SetYPbPr) { /* temp = CR38 */
                                        if (pVBInfo->IF_DEF_HiVision == 1) {
+                                               /* shampoo add for new
+                                                * scratch */
                                                temp = xgifb_reg_get(
                                                                pVBInfo->P3d4,
-                                                               0x35); /* shampoo add for new scratch */
+                                                               0x35);
                                                temp &= YPbPrMode;
                                                tempbx |= SetCRT2ToHiVisionTV;
 
                                                if (temp != YPbPrMode1080i) {
-                                                       tempbx
-                                                                       &= (~SetCRT2ToHiVisionTV);
-                                                       tempbx
-                                                                       |= SetCRT2ToYPbPr;
+                                                       tempbx &=
+                                                        (~SetCRT2ToHiVisionTV);
+                                                       tempbx |=
+                                                        SetCRT2ToYPbPr;
                                                }
                                        }
 
@@ -3532,11 +3695,13 @@ void XGI_GetVBInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
                        }
                } else { /* 3nd party chip */
                        if (pVBInfo->IF_DEF_CH7017 == 1)
-                               temp = (SetCRT2ToTV | SetCRT2ToLCD
-                                               | SetCRT2ToLCDA);
-                       else if (pVBInfo->IF_DEF_CH7007 == 1) { /* [Billy] 07/05/03 */
+                               temp = (SetCRT2ToTV |
+                                       SetCRT2ToLCD |
+                                       SetCRT2ToLCDA);
+                       /* [Billy] 07/05/03 */
+                       else if (pVBInfo->IF_DEF_CH7007 == 1)
                                temp = SetCRT2ToTV;
-                       else
+                       else
                                temp = SetCRT2ToLCD;
                }
 
@@ -3549,60 +3714,67 @@ void XGI_GetVBInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
                        if (!(pVBInfo->VBType & VB_NoLCD)) {
                                if (tempbx & SetCRT2ToLCDA) {
                                        if (tempbx & SetSimuScanMode)
-                                               tempbx
-                                                               &= (~(SetCRT2ToLCD
-                                                                               | SetCRT2ToRAMDAC
-                                                                               | SwitchToCRT2));
+                                               tempbx &= (~(SetCRT2ToLCD |
+                                                          SetCRT2ToRAMDAC |
+                                                          SwitchToCRT2));
                                        else
-                                               tempbx
-                                                               &= (~(SetCRT2ToLCD
-                                                                               | SetCRT2ToRAMDAC
-                                                                               | SetCRT2ToTV
-                                                                               | SwitchToCRT2));
+                                               tempbx &= (~(SetCRT2ToLCD |
+                                                            SetCRT2ToRAMDAC |
+                                                            SetCRT2ToTV |
+                                                            SwitchToCRT2));
                                }
                        }
                }
 
                /* shampoo add */
-               if (!(tempbx & (SwitchToCRT2 | SetSimuScanMode))) { /* for driver abnormal */
+               /* for driver abnormal */
+               if (!(tempbx & (SwitchToCRT2 | SetSimuScanMode))) {
                        if (pVBInfo->IF_DEF_CRT2Monitor == 1) {
                                if (tempbx & SetCRT2ToRAMDAC) {
-                                       tempbx &= (0xFF00 | SetCRT2ToRAMDAC
-                                                       | SwitchToCRT2
-                                                       | SetSimuScanMode);
+                                       tempbx &= (0xFF00 |
+                                                  SetCRT2ToRAMDAC |
+                                                  SwitchToCRT2 |
+                                                  SetSimuScanMode);
                                        tempbx &= (0x00FF | (~SetCRT2ToYPbPr));
                                }
                        } else {
-                               tempbx &= (~(SetCRT2ToRAMDAC | SetCRT2ToLCD
-                                               | SetCRT2ToTV));
+                               tempbx &= (~(SetCRT2ToRAMDAC |
+                                          SetCRT2ToLCD |
+                                          SetCRT2ToTV));
                        }
                }
 
                if (!(pVBInfo->VBType & VB_NoLCD)) {
                        if (tempbx & SetCRT2ToLCD) {
-                               tempbx &= (0xFF00 | SetCRT2ToLCD | SwitchToCRT2
-                                               | SetSimuScanMode);
+                               tempbx &= (0xFF00 |
+                                          SetCRT2ToLCD |
+                                          SwitchToCRT2 |
+                                          SetSimuScanMode);
                                tempbx &= (0x00FF | (~SetCRT2ToYPbPr));
                        }
                }
 
                if (tempbx & SetCRT2ToSCART) {
-                       tempbx &= (0xFF00 | SetCRT2ToSCART | SwitchToCRT2
-                                       | SetSimuScanMode);
+                       tempbx &= (0xFF00 |
+                                  SetCRT2ToSCART |
+                                  SwitchToCRT2 |
+                                  SetSimuScanMode);
                        tempbx &= (0x00FF | (~SetCRT2ToYPbPr));
                }
 
                if (pVBInfo->IF_DEF_YPbPr == 1) {
                        if (tempbx & SetCRT2ToYPbPr)
-                               tempbx &= (0xFF00 | SwitchToCRT2
-                                               | SetSimuScanMode);
+                               tempbx &= (0xFF00 |
+                                          SwitchToCRT2 |
+                                          SetSimuScanMode);
                }
 
                if (pVBInfo->IF_DEF_HiVision == 1) {
                        if (tempbx & SetCRT2ToHiVisionTV)
-                               tempbx &= (0xFF00 | SetCRT2ToHiVisionTV
-                                               | SwitchToCRT2
-                                               | SetSimuScanMode);
+                               tempbx &= (0xFF00 |
+                                          SetCRT2ToHiVisionTV |
+                                          SwitchToCRT2 |
+                                          SetSimuScanMode);
                }
 
                if (tempax & DisableCRT2Display) { /* Set Display Device Info */
@@ -3611,38 +3783,35 @@ void XGI_GetVBInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
                }
 
                if (!(tempbx & DisableCRT2Display)) {
-                       if ((!(tempbx & DriverMode))
-                                       || (!(modeflag & CRT2Mode))) {
+                       if ((!(tempbx & DriverMode)) ||
+                           (!(modeflag & CRT2Mode))) {
                                if (pVBInfo->IF_DEF_LCDA == 1) {
                                        if (!(tempbx & SetCRT2ToLCDA))
-                                               tempbx
-                                                               |= (SetInSlaveMode
-                                                                               | SetSimuScanMode);
+                                               tempbx |= (SetInSlaveMode |
+                                                          SetSimuScanMode);
                                }
 
                                if (pVBInfo->IF_DEF_VideoCapture == 1) {
-                                       if (((HwDeviceExtension->jChipType
-                                                       == XG40)
-                                                       && (pVBInfo->Set_VGAType
-                                                                       == XG40))
-                                                       || ((HwDeviceExtension->jChipType
-                                                                       == XG41)
-                                                                       && (pVBInfo->Set_VGAType
-                                                                                       == XG41))
-                                                       || ((HwDeviceExtension->jChipType
-                                                                       == XG42)
-                                                                       && (pVBInfo->Set_VGAType
-                                                                                       == XG42))
-                                                       || ((HwDeviceExtension->jChipType
-                                                                       == XG45)
-                                                                       && (pVBInfo->Set_VGAType
-                                                                                       == XG45))) {
+                                       if (((HwDeviceExtension->jChipType ==
+                                             XG40) &&
+                                            (pVBInfo->Set_VGAType == XG40)) ||
+                                           ((HwDeviceExtension->jChipType ==
+                                             XG41) &&
+                                            (pVBInfo->Set_VGAType == XG41)) ||
+                                           ((HwDeviceExtension->jChipType ==
+                                             XG42) &&
+                                            (pVBInfo->Set_VGAType == XG42)) ||
+                                           ((HwDeviceExtension->jChipType ==
+                                             XG45) &&
+                                            (pVBInfo->Set_VGAType == XG45))) {
                                                if (ModeNo <= 13) {
-                                                       if (!(tempbx
-                                                                       & SetCRT2ToRAMDAC)) { /*CRT2 not need to support*/
-                                                               tempbx
-                                                                               &= (0x00FF
-                                                                                               | (~SetInSlaveMode));
+                                                       if (!(tempbx &
+                                                            SetCRT2ToRAMDAC)) {
+                                                               /*CRT2 not need
+                                                                * to support*/
+                                                               tempbx &=
+                                                                 (0x00FF |
+                                                                 (~SetInSlaveMode));
                                                                pVBInfo->SetFlag
                                                                                |= EnableVCMode;
                                                        }
@@ -3651,11 +3820,13 @@ void XGI_GetVBInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
                                }
                        }
 
-                       /* LCD+TV can't support in slave mode (Force LCDA+TV->LCDB) */
-                       if ((tempbx & SetInSlaveMode) && (tempbx
-                                       & SetCRT2ToLCDA)) {
-                               tempbx ^= (SetCRT2ToLCD | SetCRT2ToLCDA
-                                               | SetCRT2ToDualEdge);
+                       /* LCD+TV can't support in slave mode
+                        * (Force LCDA+TV->LCDB) */
+                       if ((tempbx & SetInSlaveMode) &&
+                           (tempbx & SetCRT2ToLCDA)) {
+                               tempbx ^= (SetCRT2ToLCD |
+                                         SetCRT2ToLCDA |
+                                         SetCRT2ToDualEdge);
                                pVBInfo->SetFlag |= ReserveTVOption;
                        }
                }
@@ -3674,33 +3845,40 @@ void XGI_GetTVInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
 
        if (pVBInfo->VBInfo & SetCRT2ToTV) {
                if (ModeNo <= 0x13) {
-                       modeflag
-                                       = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ModeFlag */
-                       resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; /* si+St_ResInfo */
+                       modeflag = pVBInfo->SModeIDTable[ModeIdIndex].
+                                       St_ModeFlag; /* si+St_ModeFlag */
+                       resinfo = pVBInfo->SModeIDTable[ModeIdIndex].
+                                       St_ResInfo; /* si+St_ResInfo */
                } else {
-                       modeflag
-                                       = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
-                       resinfo
-                                       = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; /* si+Ext_ResInfo */
+                       modeflag = pVBInfo->EModeIDTable[ModeIdIndex].
+                                       Ext_ModeFlag;
+                       resinfo = pVBInfo->EModeIDTable[ModeIdIndex].
+                                       Ext_RESINFO; /* si+Ext_ResInfo */
                }
 
                if (pVBInfo->VBInfo & SetCRT2ToTV) {
                        temp = xgifb_reg_get(pVBInfo->P3d4, 0x35);
                        tempbx = temp;
                        if (tempbx & SetPALTV) {
-                               tempbx &= (SetCHTVOverScan | SetPALMTV
-                                               | SetPALNTV | SetPALTV);
+                               tempbx &= (SetCHTVOverScan |
+                                          SetPALMTV |
+                                          SetPALNTV |
+                                          SetPALTV);
                                if (tempbx & SetPALMTV)
-                                       tempbx &= ~SetPALTV; /* set to NTSC if PAL-M */
+                                       /* set to NTSC if PAL-M */
+                                       tempbx &= ~SetPALTV;
                        } else
-                               tempbx &= (SetCHTVOverScan | SetNTSCJ
-                                               | SetPALTV);
+                               tempbx &= (SetCHTVOverScan |
+                                          SetNTSCJ |
+                                          SetPALTV);
                        /*
                        if (pVBInfo->IF_DEF_LVDS == 0) {
-                               index1 = xgifb_reg_get(pVBInfo->P3d4, 0x38); //PAL-M/PAL-N Info
-                               temp2 = (index1 & 0xC0) >> 5; //00:PAL, 01:PAL-M, 10:PAL-N
+                               //PAL-M/PAL-N Info
+                               index1 = xgifb_reg_get(pVBInfo->P3d4, 0x38);
+                               //00:PAL, 01:PAL-M, 10:PAL-N
+                               temp2 = (index1 & 0xC0) >> 5;
                                tempbx |= temp2;
-                               if (temp2 & 0x02)          //PAL-M
+                               if (temp2 & 0x02) //PAL-M
                                        tempbx &= (~SetPALTV);
                        }
                        */
@@ -3746,12 +3924,13 @@ void XGI_GetTVInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
                }
 
                if (pVBInfo->IF_DEF_LVDS == 0) { /* shampoo */
-                       if ((pVBInfo->VBInfo & SetInSlaveMode)
-                                       && (!(pVBInfo->VBInfo & SetNotSimuMode)))
+                       if ((pVBInfo->VBInfo & SetInSlaveMode) &&
+                           (!(pVBInfo->VBInfo & SetNotSimuMode)))
                                tempbx |= TVSimuMode;
 
-                       if (!(tempbx & SetPALTV) && (modeflag > 13) && (resinfo
-                                       == 8)) /* NTSC 1024x768, */
+                       if (!(tempbx & SetPALTV) &&
+                           (modeflag > 13) &&
+                           (resinfo == 8)) /* NTSC 1024x768, */
                                tempbx |= NTSC1024x768;
 
                        tempbx |= RPLLDIV2XO;
@@ -3760,12 +3939,15 @@ void XGI_GetTVInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
                                if (pVBInfo->VBInfo & SetInSlaveMode)
                                        tempbx &= (~RPLLDIV2XO);
                        } else {
-                               if (tempbx & (SetYPbPrMode525p
-                                               | SetYPbPrMode750p))
+                               if (tempbx &
+                                   (SetYPbPrMode525p | SetYPbPrMode750p))
                                        tempbx &= (~RPLLDIV2XO);
-                               else if (!(pVBInfo->VBType & (VB_XGI301B
-                                               | VB_XGI302B | VB_XGI301LV
-                                               | VB_XGI302LV | VB_XGI301C))) {
+                               else if (!(pVBInfo->VBType &
+                                        (VB_XGI301B |
+                                         VB_XGI302B |
+                                         VB_XGI301LV |
+                                         VB_XGI302LV |
+                                         VB_XGI301C))) {
                                        if (tempbx & TVSimuMode)
                                                tempbx &= (~RPLLDIV2XO);
                                }
@@ -3785,10 +3967,12 @@ unsigned char XGI_GetLCDInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
        pVBInfo->LCDInfo = 0;
 
        if (ModeNo <= 0x13) {
-               modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ModeFlag // */
+               /* si+St_ModeFlag // */
+               modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
        } else {
                modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
-               resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; /* si+Ext_ResInfo // */
+               /* si+Ext_ResInfo // */
+               resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
        }
 
        temp = xgifb_reg_get(pVBInfo->P3d4, 0x36); /* Get LCD Res.Info */
@@ -3857,7 +4041,8 @@ unsigned char XGI_GetLCDInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
                if ((pVBInfo->LCDResInfo == Panel1400x1050) && (pVBInfo->VBInfo
                                & SetCRT2ToLCD) && (ModeNo > 0x13) && (resinfo
                                == 9) && (!(tempbx & EnableScalingLCD)))
-                       tempbx |= SetLCDtoNonExpanding; /* set to center in 1280x1024 LCDB for Panel1400x1050 */
+                       /* set to center in 1280x1024 LCDB for Panel1400x1050 */
+                       tempbx |= SetLCDtoNonExpanding;
        }
 
        /*
@@ -3875,7 +4060,7 @@ unsigned char XGI_GetLCDInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
                                if (ModeNo > 0x13) {
                                        if (pVBInfo->LCDResInfo
                                                        == Panel1024x768) {
-                                               if (resinfo == 4) { /* 512x384  */
+                                               if (resinfo == 4) {/* 512x384 */
                                                        tempbx |= EnableLVDSDDA;
                                                }
                                        }
@@ -3895,8 +4080,8 @@ unsigned char XGI_GetLCDInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
 
        if (pVBInfo->IF_DEF_PWD == 1) {
                if (pVBInfo->LCDInfo & SetPWDEnable) {
-                       if ((pVBInfo->VBType & VB_XGI302LV) || (pVBInfo->VBType
-                                       & VB_XGI301C)) {
+                       if ((pVBInfo->VBType & VB_XGI302LV) ||
+                           (pVBInfo->VBType & VB_XGI301C)) {
                                if (!(tempax & PWDEnable))
                                        pVBInfo->LCDInfo &= ~SetPWDEnable;
                        }
@@ -3908,13 +4093,13 @@ unsigned char XGI_GetLCDInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
                        if (pVBInfo->VBInfo & SetInSlaveMode) {
                                if (!(tempax & LockLCDBToA)) {
                                        if (ModeNo <= 0x13) {
-                                               pVBInfo->VBInfo
-                                                               &= ~(SetSimuScanMode
-                                                                               | SetInSlaveMode
-                                                                               | SetCRT2ToLCD);
-                                               pVBInfo->VBInfo
-                                                               |= SetCRT2ToLCDA
-                                                                               | SetCRT2ToDualEdge;
+                                               pVBInfo->VBInfo &=
+                                                       ~(SetSimuScanMode |
+                                                         SetInSlaveMode |
+                                                         SetCRT2ToLCD);
+                                               pVBInfo->VBInfo |=
+                                                       SetCRT2ToLCDA |
+                                                       SetCRT2ToDualEdge;
                                        }
                                }
                        }
@@ -3925,9 +4110,15 @@ unsigned char XGI_GetLCDInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
        if (pVBInfo->IF_DEF_LVDS == 0) {
                if (tempax & (LockLCDBToA | StLCDBToA)) {
                        if (pVBInfo->VBInfo & SetInSlaveMode) {
-                               if (!((!(tempax & LockLCDBToA)) && (ModeNo > 0x13))) {
-                                       pVBInfo->VBInfo&=~(SetSimuScanMode|SetInSlaveMode|SetCRT2ToLCD);
-                                       pVBInfo->VBInfo|=SetCRT2ToLCDA|SetCRT2ToDualEdge;
+                               if (!((!(tempax & LockLCDBToA)) &&
+                                   (ModeNo > 0x13))) {
+                                       pVBInfo->VBInfo &=
+                                               ~(SetSimuScanMode |
+                                                 SetInSlaveMode |
+                                                 SetCRT2ToLCD);
+                                       pVBInfo->VBInfo |=
+                                               SetCRT2ToLCDA |
+                                               SetCRT2ToDualEdge;
                                }
                        }
                }
@@ -3943,11 +4134,16 @@ unsigned char XGI_SearchModeID(unsigned short ModeNo,
        if (ModeNo <= 5)
                ModeNo |= 1;
        if (ModeNo <= 0x13) {
-               /* for (*ModeIdIndex=0; *ModeIdIndex < sizeof(pVBInfo->SModeIDTable) / sizeof(struct XGI_StStruct); (*ModeIdIndex)++) */
+               /* for (*ModeIdIndex=0;
+                       *ModeIdIndex < sizeof(pVBInfo->SModeIDTable)
+                               / sizeof(struct XGI_StStruct);
+                       (*ModeIdIndex)++) */
                for (*ModeIdIndex = 0;; (*ModeIdIndex)++) {
-                       if (pVBInfo->SModeIDTable[*ModeIdIndex].St_ModeID == ModeNo)
+                       if (pVBInfo->SModeIDTable[*ModeIdIndex].St_ModeID ==
+                           ModeNo)
                                break;
-                       if (pVBInfo->SModeIDTable[*ModeIdIndex].St_ModeID == 0xFF)
+                       if (pVBInfo->SModeIDTable[*ModeIdIndex].St_ModeID ==
+                           0xFF)
                                return 0;
                }
 
@@ -3957,11 +4153,16 @@ unsigned char XGI_SearchModeID(unsigned short ModeNo,
                        (*ModeIdIndex) += 2; /* 400 lines */
                /* else 350 lines */
        } else {
-               /* for (*ModeIdIndex=0; *ModeIdIndex < sizeof(pVBInfo->EModeIDTable) / sizeof(struct XGI_ExtStruct); (*ModeIdIndex)++) */
+               /* for (*ModeIdIndex=0;
+                       *ModeIdIndex < sizeof(pVBInfo->EModeIDTable)
+                               / sizeof(struct XGI_ExtStruct);
+                       (*ModeIdIndex)++) */
                for (*ModeIdIndex = 0;; (*ModeIdIndex)++) {
-                       if (pVBInfo->EModeIDTable[*ModeIdIndex].Ext_ModeID == ModeNo)
+                       if (pVBInfo->EModeIDTable[*ModeIdIndex].Ext_ModeID ==
+                           ModeNo)
                                break;
-                       if (pVBInfo->EModeIDTable[*ModeIdIndex].Ext_ModeID == 0xFF)
+                       if (pVBInfo->EModeIDTable[*ModeIdIndex].Ext_ModeID ==
+                           0xFF)
                                return 0;
                }
        }
@@ -4002,19 +4203,22 @@ static unsigned char XGINew_CheckMemorySize(
        tmp = temp;
 
        if (HwDeviceExtension->jChipType == XG40) {
-               temp = 1 << ((temp & 0x0F0) >> 4); /* memory size per channel SR14[7:4] */
+               /* memory size per channel SR14[7:4] */
+               temp = 1 << ((temp & 0x0F0) >> 4);
                if ((tmp & 0x0c) == 0x0C) { /* Qual channels */
                        temp <<= 2;
                } else if ((tmp & 0x0c) == 0x08) { /* Dual channels */
                        temp <<= 1;
                }
        } else if (HwDeviceExtension->jChipType == XG42) {
-               temp = 1 << ((temp & 0x0F0) >> 4); /* memory size per channel SR14[7:4] */
+               /* memory size per channel SR14[7:4] */
+               temp = 1 << ((temp & 0x0F0) >> 4);
                if ((tmp & 0x04) == 0x04) { /* Dual channels */
                        temp <<= 1;
                }
        } else if (HwDeviceExtension->jChipType == XG45) {
-               temp = 1 << ((temp & 0x0F0) >> 4); /* memory size per channel SR14[7:4] */
+               /* memory size per channel SR14[7:4] */
+               temp = 1 << ((temp & 0x0F0) >> 4);
                if ((tmp & 0x0c) == 0x0C) { /* Qual channels */
                        temp <<= 2;
                } else if ((tmp & 0x0c) == 0x08) { /* triple channels */
@@ -4033,7 +4237,13 @@ static unsigned char XGINew_CheckMemorySize(
 #endif
 
 /*
-void XGINew_IsLowResolution(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned char XGINew_CheckMemorySize(struct xgi_hw_device_info *HwDeviceExtension, unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
+void XGINew_IsLowResolution(unsigned short ModeNo,
+                           unsigned short ModeIdIndex,
+                           unsigned char XGINew_CheckMemorySize(
+                               struct xgi_hw_device_info *HwDeviceExtension,
+                               unsigned short ModeNo,
+                               unsigned short ModeIdIndex,
+                               struct vb_device_info *pVBInfo)
 {
        unsigned short data ;
        unsigned short ModeFlag ;
@@ -4122,35 +4332,43 @@ void XGI_DisplayOn(struct xgi_hw_device_info *pXGIHWDE,
        if (pXGIHWDE->jChipType == XG21) {
                if (pVBInfo->IF_DEF_LVDS == 1) {
                        if (!(XGI_XG21GetPSCValue(pVBInfo) & 0x1)) {
-                               XGI_XG21BLSignalVDD(0x01, 0x01, pVBInfo); /* LVDS VDD on */
+                               /* LVDS VDD on */
+                               XGI_XG21BLSignalVDD(0x01, 0x01, pVBInfo);
                                XGI_XG21SetPanelDelay(2, pVBInfo);
                        }
                        if (!(XGI_XG21GetPSCValue(pVBInfo) & 0x20))
-                               XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo); /* LVDS signal on */
+                               /* LVDS signal on */
+                               XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo);
                        XGI_XG21SetPanelDelay(3, pVBInfo);
-                       XGI_XG21BLSignalVDD(0x02, 0x02, pVBInfo); /* LVDS backlight on */
+                       /* LVDS backlight on */
+                       XGI_XG21BLSignalVDD(0x02, 0x02, pVBInfo);
                } else {
-                       XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo); /* DVO/DVI signal on */
+                       /* DVO/DVI signal on */
+                       XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo);
                }
 
        }
 
-       if (pVBInfo->IF_DEF_CH7007 == 1) { /* [Billy] 07/05/23 For CH7007 */
-
+       /* [Billy] 07/05/23 For CH7007 */
+       if (pVBInfo->IF_DEF_CH7007 == 1) {
        }
 
        if (pXGIHWDE->jChipType == XG27) {
                if (pVBInfo->IF_DEF_LVDS == 1) {
                        if (!(XGI_XG27GetPSCValue(pVBInfo) & 0x1)) {
-                               XGI_XG27BLSignalVDD(0x01, 0x01, pVBInfo); /* LVDS VDD on */
+                               /* LVDS VDD on */
+                               XGI_XG27BLSignalVDD(0x01, 0x01, pVBInfo);
                                XGI_XG21SetPanelDelay(2, pVBInfo);
                        }
                        if (!(XGI_XG27GetPSCValue(pVBInfo) & 0x20))
-                               XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo); /* LVDS signal on */
+                               /* LVDS signal on */
+                               XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo);
                        XGI_XG21SetPanelDelay(3, pVBInfo);
-                       XGI_XG27BLSignalVDD(0x02, 0x02, pVBInfo); /* LVDS backlight on */
+                       /* LVDS backlight on */
+                       XGI_XG27BLSignalVDD(0x02, 0x02, pVBInfo);
                } else {
-                       XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo); /* DVO/DVI signal on */
+                       /* DVO/DVI signal on */
+                       XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo);
                }
 
        }
@@ -4162,10 +4380,12 @@ void XGI_DisplayOff(struct xgi_hw_device_info *pXGIHWDE,
 
        if (pXGIHWDE->jChipType == XG21) {
                if (pVBInfo->IF_DEF_LVDS == 1) {
-                       XGI_XG21BLSignalVDD(0x02, 0x00, pVBInfo); /* LVDS backlight off */
+                       /* LVDS backlight off */
+                       XGI_XG21BLSignalVDD(0x02, 0x00, pVBInfo);
                        XGI_XG21SetPanelDelay(3, pVBInfo);
                } else {
-                       XGI_XG21BLSignalVDD(0x20, 0x00, pVBInfo); /* DVO/DVI signal off */
+                       /* DVO/DVI signal off */
+                       XGI_XG21BLSignalVDD(0x20, 0x00, pVBInfo);
                }
        }
 
@@ -4177,12 +4397,14 @@ void XGI_DisplayOff(struct xgi_hw_device_info *pXGIHWDE,
 
        if (pXGIHWDE->jChipType == XG27) {
                if ((XGI_XG27GetPSCValue(pVBInfo) & 0x2)) {
-                       XGI_XG27BLSignalVDD(0x02, 0x00, pVBInfo); /* LVDS backlight off */
+                       /* LVDS backlight off */
+                       XGI_XG27BLSignalVDD(0x02, 0x00, pVBInfo);
                        XGI_XG21SetPanelDelay(3, pVBInfo);
                }
 
                if (pVBInfo->IF_DEF_LVDS == 0)
-                       XGI_XG27BLSignalVDD(0x20, 0x00, pVBInfo); /* DVO/DVI signal off */
+                       /* DVO/DVI signal off */
+                       XGI_XG27BLSignalVDD(0x20, 0x00, pVBInfo);
        }
 
        xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xDF, 0x20);
@@ -4200,8 +4422,10 @@ static void XGI_WaitDisply(struct vb_device_info *pVBInfo)
 #if 0
 static void XGI_WaitDisplay(struct vb_device_info *pVBInfo)
 {
-       while (!(inb(pVBInfo->P3da) & 0x01));
-       while (inb(pVBInfo->P3da) & 0x01);
+       while (!(inb(pVBInfo->P3da) & 0x01))
+               ;
+       while (inb(pVBInfo->P3da) & 0x01)
+               ;
 }
 #endif
 
@@ -4211,18 +4435,21 @@ static void XGI_AutoThreshold(struct vb_device_info *pVBInfo)
                xgifb_reg_or(pVBInfo->Part1Port, 0x01, 0x40);
 }
 
-static void XGI_SaveCRT2Info(unsigned short ModeNo, struct vb_device_info *pVBInfo)
+static void XGI_SaveCRT2Info(unsigned short ModeNo,
+                            struct vb_device_info *pVBInfo)
 {
        unsigned short temp1, temp2;
 
-       xgifb_reg_set(pVBInfo->P3d4, 0x34, ModeNo); /* reserve CR34 for CRT1 Mode No */
+       /* reserve CR34 for CRT1 Mode No */
+       xgifb_reg_set(pVBInfo->P3d4, 0x34, ModeNo);
        temp1 = (pVBInfo->VBInfo & SetInSlaveMode) >> 8;
        temp2 = ~(SetInSlaveMode >> 8);
        xgifb_reg_and_or(pVBInfo->P3d4, 0x31, temp2, temp1);
 }
 
-static void XGI_GetCRT2ResInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
-               struct vb_device_info *pVBInfo)
+static void XGI_GetCRT2ResInfo(unsigned short ModeNo,
+                              unsigned short ModeIdIndex,
+                              struct vb_device_info *pVBInfo)
 {
        unsigned short xres, yres, modeflag, resindex;
 
@@ -4230,11 +4457,13 @@ static void XGI_GetCRT2ResInfo(unsigned short ModeNo, unsigned short ModeIdIndex
        if (ModeNo <= 0x13) {
                xres = pVBInfo->StResInfo[resindex].HTotal;
                yres = pVBInfo->StResInfo[resindex].VTotal;
-               /* modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; si+St_ResInfo */
+               /* si+St_ResInfo */
+               /* modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;*/
        } else {
                xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
                yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */
-               modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+St_ModeFlag */
+               /* si+St_ModeFlag */
+               modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
 
                /*
                if (pVBInfo->IF_DEF_FSTN) {
@@ -4306,9 +4535,10 @@ static unsigned char XGI_IsLCDDualLink(struct vb_device_info *pVBInfo)
        return 0;
 }
 
-static void XGI_GetRAMDAC2DATA(unsigned short ModeNo, unsigned short ModeIdIndex,
-               unsigned short RefreshRateTableIndex,
-               struct vb_device_info *pVBInfo)
+static void XGI_GetRAMDAC2DATA(unsigned short ModeNo,
+                              unsigned short ModeIdIndex,
+                              unsigned short RefreshRateTableIndex,
+                              struct vb_device_info *pVBInfo)
 {
        unsigned short tempax, tempbx, temp1, temp2, modeflag = 0, tempcx,
                        StandTableIndex, CRT1Index;
@@ -4324,24 +4554,23 @@ static void XGI_GetRAMDAC2DATA(unsigned short ModeNo, unsigned short ModeIdIndex
                temp1 = pVBInfo->StandTable[StandTableIndex].CRTC[7];
        } else {
                modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
-               CRT1Index
-                               = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
+               CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex].
+                               Ext_CRT1CRTC;
                CRT1Index &= IndexMask;
-               temp1
-                               = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[0];
-               temp2
-                               = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[5];
+               temp1 = (unsigned short) pVBInfo->
+                       XGINEWUB_CRT1Table[CRT1Index].CR[0];
+               temp2 = (unsigned short) pVBInfo->
+                       XGINEWUB_CRT1Table[CRT1Index].CR[5];
                tempax = (temp1 & 0xFF) | ((temp2 & 0x03) << 8);
-               tempbx
-                               = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[8];
-               tempcx
-                               = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[14]
-                                               << 8;
+               tempbx = (unsigned short) pVBInfo->
+                       XGINEWUB_CRT1Table[CRT1Index].CR[8];
+               tempcx = (unsigned short) pVBInfo->
+                       XGINEWUB_CRT1Table[CRT1Index].CR[14] << 8;
                tempcx &= 0x0100;
                tempcx = tempcx << 2;
                tempbx |= tempcx;
-               temp1
-                               = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[9];
+               temp1 = (unsigned short) pVBInfo->
+                       XGINEWUB_CRT1Table[CRT1Index].CR[9];
        }
 
        if (temp1 & 0x01)
@@ -4373,10 +4602,12 @@ static void XGI_GetCRT2Data(unsigned short ModeNo, unsigned short ModeIdIndex,
        struct XGI_TVDataStruct *TVPtr = NULL;
 
        if (ModeNo <= 0x13) {
-               modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
+               /* si+St_ResInfo */
+               modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
                resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
        } else {
-               modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
+               /* si+Ext_ResInfo */
+               modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
                resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
        }
 
@@ -4598,7 +4829,8 @@ static unsigned short XGI_GetColorDepth(unsigned short ModeNo,
        return ColorDepth[index];
 }
 
-static unsigned short XGI_GetOffset(unsigned short ModeNo, unsigned short ModeIdIndex,
+static unsigned short XGI_GetOffset(unsigned short ModeNo,
+                                   unsigned short ModeIdIndex,
                unsigned short RefreshRateTableIndex,
                struct xgi_hw_device_info *HwDeviceExtension,
                struct vb_device_info *pVBInfo)
@@ -4610,7 +4842,8 @@ static unsigned short XGI_GetOffset(unsigned short ModeNo, unsigned short ModeId
        if (ModeNo <= 0x14)
                infoflag = 0;
        else
-               infoflag = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
+               infoflag = pVBInfo->
+                               RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
 
        index = (modeinfo >> 8) & 0xFF;
 
@@ -4657,8 +4890,10 @@ static void XGI_SetCRT2Offset(unsigned short ModeNo,
 
 static void XGI_SetCRT2FIFO(struct vb_device_info *pVBInfo)
 {
-       xgifb_reg_set(pVBInfo->Part1Port, 0x01, 0x3B); /* threshold high ,disable auto threshold */
-       xgifb_reg_and_or(pVBInfo->Part1Port, 0x02, ~(0x3F), 0x04); /* threshold low default 04h */
+       /* threshold high ,disable auto threshold */
+       xgifb_reg_set(pVBInfo->Part1Port, 0x01, 0x3B);
+       /* threshold low default 04h */
+       xgifb_reg_and_or(pVBInfo->Part1Port, 0x02, ~(0x3F), 0x04);
 }
 
 static void XGI_PreSetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex,
@@ -4669,7 +4904,8 @@ static void XGI_PreSetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex,
        unsigned short tempcx = 0, CRT1Index = 0, resinfo = 0;
 
        if (ModeNo > 0x13) {
-               CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
+               CRT1Index = pVBInfo->
+                               RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
                CRT1Index &= IndexMask;
                resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
        }
@@ -4695,7 +4931,8 @@ static void XGI_SetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex,
                        pushbx = 0, CRT1Index = 0, modeflag, resinfo = 0;
 
        if (ModeNo > 0x13) {
-               CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
+               CRT1Index = pVBInfo->
+                               RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
                CRT1Index &= IndexMask;
                resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
        }
@@ -4707,11 +4944,13 @@ static void XGI_SetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex,
 
        /* bainy change table name */
        if (modeflag & HalfDCLK) {
-               temp = (pVBInfo->VGAHT / 2 - 1) & 0x0FF; /* BTVGA2HT 0x08,0x09 */
+               /* BTVGA2HT 0x08,0x09 */
+               temp = (pVBInfo->VGAHT / 2 - 1) & 0x0FF;
                xgifb_reg_set(pVBInfo->Part1Port, 0x08, temp);
                temp = (((pVBInfo->VGAHT / 2 - 1) & 0xFF00) >> 8) << 4;
                xgifb_reg_and_or(pVBInfo->Part1Port, 0x09, ~0x0F0, temp);
-               temp = (pVBInfo->VGAHDE / 2 + 16) & 0x0FF; /* BTVGA2HDEE 0x0A,0x0C */
+               /* BTVGA2HDEE 0x0A,0x0C */
+               temp = (pVBInfo->VGAHDE / 2 + 16) & 0x0FF;
                xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp);
                tempcx = ((pVBInfo->VGAHT - pVBInfo->VGAHDE) / 2) >> 2;
                pushbx = pVBInfo->VGAHDE / 2 + 16;
@@ -4721,8 +4960,9 @@ static void XGI_SetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex,
 
                if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
                        tempbx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[4];
-                       tempbx |= ((pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[14]
-                                                       & 0xC0) << 2);
+                       tempbx |= ((pVBInfo->
+                                       XGINEWUB_CRT1Table[CRT1Index].CR[14] &
+                                               0xC0) << 2);
                        tempbx = (tempbx - 3) << 3; /* (VGAHRS-3)*8 */
                        tempcx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[5];
                        tempcx &= 0x1F;
@@ -4745,7 +4985,8 @@ static void XGI_SetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex,
                xgifb_reg_set(pVBInfo->Part1Port, 0x08, temp);
                temp = (((pVBInfo->VGAHT - 1) & 0xFF00) >> 8) << 4;
                xgifb_reg_and_or(pVBInfo->Part1Port, 0x09, ~0x0F0, temp);
-               temp = (pVBInfo->VGAHDE + 16) & 0x0FF; /* BTVGA2HDEE 0x0A,0x0C */
+               /* BTVGA2HDEE 0x0A,0x0C */
+               temp = (pVBInfo->VGAHDE + 16) & 0x0FF;
                xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp);
                tempcx = (pVBInfo->VGAHT - pVBInfo->VGAHDE) >> 2; /* cx */
                pushbx = pVBInfo->VGAHDE + 16;
@@ -4755,8 +4996,9 @@ static void XGI_SetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex,
 
                if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
                        tempbx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[3];
-                       tempbx |= ((pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[5]
-                                                       & 0xC0) << 2);
+                       tempbx |= ((pVBInfo->
+                                       XGINEWUB_CRT1Table[CRT1Index].CR[5] &
+                                               0xC0) << 2);
                        tempbx = (tempbx - 3) << 3; /* (VGAHRS-3)*8 */
                        tempcx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[4];
                        tempcx &= 0x1F;
@@ -4801,8 +5043,10 @@ static void XGI_SetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex,
        tempax = pVBInfo->VGAVDE;
        tempbx = pVBInfo->VGAVDE;
        tempcx = pVBInfo->VGAVT;
-       tempbx = (pVBInfo->VGAVT + pVBInfo->VGAVDE) >> 1; /* BTVGA2VRS 0x10,0x11 */
-       tempcx = ((pVBInfo->VGAVT - pVBInfo->VGAVDE) >> 4) + tempbx + 1; /* BTVGA2VRE 0x11 */
+       /* BTVGA2VRS 0x10,0x11 */
+       tempbx = (pVBInfo->VGAVT + pVBInfo->VGAVDE) >> 1;
+       /* BTVGA2VRE 0x11 */
+       tempcx = ((pVBInfo->VGAVT - pVBInfo->VGAVDE) >> 4) + tempbx + 1;
 
        if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
                tempbx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[10];
@@ -4860,12 +5104,15 @@ static void XGI_SetLockRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
                        modeflag, CRT1Index;
 
        if (ModeNo <= 0x13) {
-               modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
+               /* si+St_ResInfo */
+               modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
                resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
        } else {
-               modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
+               /* si+Ext_ResInfo */
+               modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
                resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
-               CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
+               CRT1Index = pVBInfo->
+                               RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
                CRT1Index &= IndexMask;
        }
 
@@ -4911,8 +5158,10 @@ static void XGI_SetLockRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
                }
        }
 
-       xgifb_reg_set(pVBInfo->Part1Port, 0x05, temp); /* 0x05 Horizontal Display Start */
-       xgifb_reg_set(pVBInfo->Part1Port, 0x06, 0x03); /* 0x06 Horizontal Blank end */
+       /* 0x05 Horizontal Display Start */
+       xgifb_reg_set(pVBInfo->Part1Port, 0x05, temp);
+       /* 0x06 Horizontal Blank end */
+       xgifb_reg_set(pVBInfo->Part1Port, 0x06, 0x03);
 
        if (!(pVBInfo->VBInfo & DisableCRT2Display)) { /* 030226 bainy */
                if (pVBInfo->VBInfo & SetCRT2ToTV)
@@ -4960,15 +5209,14 @@ static void XGI_SetLockRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
                                if (pVBInfo->LCDResInfo != Panel1280x960) {
                                        if (pVBInfo->VGAHDE >= 800) {
                                                temp -= 7;
-                                               if (pVBInfo->ModeType
-                                                               == ModeEGA) {
-                                                       if (pVBInfo->VGAVDE
-                                                                       == 1024) {
+                                               if (pVBInfo->ModeType ==
+                                                       ModeEGA) {
+                                                       if (pVBInfo->VGAVDE ==
+                                                           1024) {
                                                                temp += 15;
-                                                               if (pVBInfo->LCDResInfo
-                                                                               != Panel1280x1024) {
-                                                                       temp
-                                                                                       += 7;
+                                                               if (pVBInfo->LCDResInfo != Panel1280x1024) {
+                                                                       temp +=
+                                                                           7;
                                                                }
                                                        }
                                                }
@@ -4989,8 +5237,10 @@ static void XGI_SetLockRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
                }
        }
 
-       xgifb_reg_set(pVBInfo->Part1Port, 0x07, temp); /* 0x07 Horizontal Retrace Start */
-       xgifb_reg_set(pVBInfo->Part1Port, 0x08, 0); /* 0x08 Horizontal Retrace End */
+       /* 0x07 Horizontal Retrace Start */
+       xgifb_reg_set(pVBInfo->Part1Port, 0x07, temp);
+       /* 0x08 Horizontal Retrace End */
+       xgifb_reg_set(pVBInfo->Part1Port, 0x08, 0);
 
        if (pVBInfo->VBInfo & SetCRT2ToTV) {
                if (pVBInfo->TVInfo & TVSimuMode) {
@@ -5087,7 +5337,8 @@ static void XGI_SetLockRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
        temp = tempbx & 0x00FF;
        tempbx--;
        temp = tempbx & 0x00FF;
-       xgifb_reg_set(pVBInfo->Part1Port, 0x10, temp); /* 0x10 vertical Blank Start */
+       /* 0x10 vertical Blank Start */
+       xgifb_reg_set(pVBInfo->Part1Port, 0x10, temp);
        tempbx = push2;
        tempbx--;
        temp = tempbx & 0x00FF;
@@ -5110,7 +5361,8 @@ static void XGI_SetLockRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
        if (tempbx & 0x0400)
                tempcx |= 0x0600;
 
-       xgifb_reg_set(pVBInfo->Part1Port, 0x11, 0x00); /* 0x11 Vertival Blank End */
+       /* 0x11 Vertival Blank End */
+       xgifb_reg_set(pVBInfo->Part1Port, 0x11, 0x00);
 
        tempax = push1;
        tempax -= tempbx; /* 0x0C Vertical Retrace Start */
@@ -5129,12 +5381,12 @@ static void XGI_SetLockRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
                        } else {
                                if (pVBInfo->TVInfo & TVSimuMode) {
                                        if (pVBInfo->TVInfo & SetPALTV) {
-                                               if (pVBInfo->VBType
-                                                               & VB_XGI301LV) {
-                                                       if (!(pVBInfo->TVInfo
-                                                                       & (SetYPbPrMode525p
-                                                                                       | SetYPbPrMode750p
-                                                                                       | SetYPbPrMode1080i)))
+                                               if (pVBInfo->VBType &
+                                                   VB_XGI301LV) {
+                                                       if (!(pVBInfo->TVInfo &
+                                                           (SetYPbPrMode525p |
+                                                           SetYPbPrMode750p |
+                                                           SetYPbPrMode1080i)))
                                                                tempbx += 40;
                                                } else {
                                                        tempbx += 40;
@@ -5149,10 +5401,10 @@ static void XGI_SetLockRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
                if (pVBInfo->TVInfo & TVSimuMode) {
                        if (pVBInfo->TVInfo & SetPALTV) {
                                if (pVBInfo->VBType & VB_XGI301LV) {
-                                       if (!(pVBInfo->TVInfo
-                                                       & (SetYPbPrMode525p
-                                                                       | SetYPbPrMode750p
-                                                                       | SetYPbPrMode1080i)))
+                                       if (!(pVBInfo->TVInfo &
+                                           (SetYPbPrMode525p |
+                                            SetYPbPrMode750p |
+                                            SetYPbPrMode1080i)))
                                                tempbx += 40;
                                } else {
                                        tempbx += 40;
@@ -5199,7 +5451,8 @@ static void XGI_SetLockRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
        tempbx = push1; /* pop ax */
        temp = tempbx & 0x00FF;
        temp &= 0x0F;
-       xgifb_reg_set(pVBInfo->Part1Port, 0x0D, temp); /* 0x0D vertical Retrace End */
+       /* 0x0D vertical Retrace End */
+       xgifb_reg_set(pVBInfo->Part1Port, 0x0D, temp);
 
        if (tempbx & 0x0010)
                tempcx |= 0x2000;
@@ -5242,14 +5495,16 @@ static void XGI_SetGroup2(unsigned short ModeNo, unsigned short ModeIdIndex,
        unsigned long longtemp, tempeax, tempebx, temp2, tempecx;
 
        if (ModeNo <= 0x13) {
-               modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
+               /* si+St_ResInfo */
+               modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
                resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
                crt2crtc = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
        } else {
-               modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
+               /* si+Ext_ResInfo */
+               modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
                resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
-               crt2crtc
-                               = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
+               crt2crtc = pVBInfo->RefIndex[RefreshRateTableIndex].
+                               Ext_CRT2CRTC;
        }
 
        tempax = 0;
@@ -5308,7 +5563,8 @@ static void XGI_SetGroup2(unsigned short ModeNo, unsigned short ModeIdIndex,
                xgifb_reg_set(pVBInfo->Part2Port, i, TimingPoint[j]);
 
        for (i = 0x39; i <= 0x45; i++, j++)
-               xgifb_reg_set(pVBInfo->Part2Port, i, TimingPoint[j]); /* di->temp2[j] */
+               /* di->temp2[j] */
+               xgifb_reg_set(pVBInfo->Part2Port, i, TimingPoint[j]);
 
        if (pVBInfo->VBInfo & SetCRT2ToTV)
                xgifb_reg_and_or(pVBInfo->Part2Port, 0x3A, 0x1F, 0x00);
@@ -5453,9 +5709,10 @@ static void XGI_SetGroup2(unsigned short ModeNo, unsigned short ModeIdIndex,
                tempbx = 853;
 
        if (pVBInfo->VBInfo & SetCRT2ToTV) {
-               if (pVBInfo->VBType & (VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) {
-                       if (!(pVBInfo->TVInfo & (SetYPbPrMode525p
-                                       | SetYPbPrMode750p)))
+               if (pVBInfo->VBType &
+                   (VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) {
+                       if (!(pVBInfo->TVInfo &
+                           (SetYPbPrMode525p | SetYPbPrMode750p)))
                                tempbx = tempbx >> 1;
                } else
                        tempbx = tempbx >> 1;
@@ -5688,13 +5945,15 @@ static void XGI_SetLCDRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
        struct XGI_LCDDesStruct *LCDBDesPtr = NULL;
 
        if (ModeNo <= 0x13) {
-               modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
+               /* si+St_ResInfo */
+               modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
                resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
        } else {
-               modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
+               /* si+Ext_ResInfo */
+               modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
                resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
-               CRT1Index
-                               = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
+               CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex].
+                       Ext_CRT1CRTC;
                CRT1Index &= IndexMask;
        }
 
@@ -5755,7 +6014,8 @@ static void XGI_SetLCDRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
        if ((tempah == Panel1024x768) || (tempah == Panel1024x768x75)) {
                tempbx = 1024;
                tempcx = 768;
-       } else if ((tempah == Panel1280x1024) || (tempah == Panel1280x1024x75)) {
+       } else if ((tempah == Panel1280x1024) ||
+                  (tempah == Panel1280x1024x75)) {
                tempbx = 1280;
                tempcx = 1024;
        } else if (tempah == Panel1400x1050) {
@@ -5965,16 +6225,23 @@ static void XGI_SetTap4Regs(struct vb_device_info *pVBInfo)
        for (i = 0x80, j = 0; i <= 0xBF; i++, j++)
                xgifb_reg_set(pVBInfo->Part2Port, i, Tap4TimingPtr->Reg[j]);
 
-       if ((pVBInfo->VBInfo & SetCRT2ToTV) && (!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV))) {
-               Tap4TimingPtr = XGI_GetTap4Ptr(1, pVBInfo); /* Set Vertical Scaling */
+       if ((pVBInfo->VBInfo & SetCRT2ToTV) &&
+           (!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV))) {
+               /* Set Vertical Scaling */
+               Tap4TimingPtr = XGI_GetTap4Ptr(1, pVBInfo);
                for (i = 0xC0, j = 0; i < 0xFF; i++, j++)
-                       xgifb_reg_set(pVBInfo->Part2Port, i, Tap4TimingPtr->Reg[j]);
+                       xgifb_reg_set(pVBInfo->Part2Port,
+                                     i,
+                                     Tap4TimingPtr->Reg[j]);
        }
 
-       if ((pVBInfo->VBInfo & SetCRT2ToTV) && (!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV)))
-               xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x14, 0x04); /* Enable V.Scaling */
+       if ((pVBInfo->VBInfo & SetCRT2ToTV) &&
+           (!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV)))
+               /* Enable V.Scaling */
+               xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x14, 0x04);
        else
-               xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x14, 0x10); /* Enable H.Scaling */
+               /* Enable H.Scaling */
+               xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x14, 0x10);
 #endif
 }
 
@@ -5986,9 +6253,11 @@ static void XGI_SetGroup3(unsigned short ModeNo, unsigned short ModeIdIndex,
        unsigned short modeflag;
 
        if (ModeNo <= 0x13)
-               modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
+               /* si+St_ResInfo */
+               modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
        else
-               modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
+               /* si+Ext_ResInfo */
+               modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
 
        xgifb_reg_set(pVBInfo->Part3Port, 0x00, 0x00);
        if (pVBInfo->TVInfo & SetPALTV) {
@@ -6047,9 +6316,11 @@ static void XGI_SetGroup4(unsigned short ModeNo, unsigned short ModeIdIndex,
        unsigned long tempebx, tempeax, templong;
 
        if (ModeNo <= 0x13)
-               modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
+               /* si+St_ResInfo */
+               modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
        else
-               modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
+               /* si+Ext_ResInfo */
+               modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
 
        temp = pVBInfo->RVBHCFACT;
        xgifb_reg_set(pVBInfo->Part4Port, 0x13, temp);
@@ -6162,7 +6433,9 @@ static void XGI_SetGroup4(unsigned short ModeNo, unsigned short ModeIdIndex,
                if (XGI_IsLCDDualLink(pVBInfo))
                        tempax = tempax >> 1;
 
-               /* if((pVBInfo->VBInfo&(SetCRT2ToLCD))||((pVBInfo->TVInfo&SetYPbPrMode525p)||(pVBInfo->TVInfo&SetYPbPrMode750p))) { */
+               /* if((pVBInfo->VBInfo&(SetCRT2ToLCD)) ||
+                     ((pVBInfo->TVInfo&SetYPbPrMode525p) ||
+                     (pVBInfo->TVInfo&SetYPbPrMode750p))) { */
                if (pVBInfo->VBInfo & SetCRT2ToLCD) {
                        if (tempax > 800)
                                tempax -= 800;
@@ -6179,12 +6452,17 @@ static void XGI_SetGroup4(unsigned short ModeNo, unsigned short ModeIdIndex,
                /*
                if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToHiVisionTV)) {
                        if (pVBInfo->VBType & VB_XGI301LV) {
-                               if (!(pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p | SetYPbPrMode1080i))) {
+                               if (!(pVBInfo->TVInfo &
+                                     (SetYPbPrMode525p |
+                                      SetYPbPrMode750p |
+                                      SetYPbPrMode1080i))) {
                                        if (pVBInfo->VGAHDE > 800) {
                                                if (pVBInfo->VGAHDE == 1024)
-                                                       tempax = (tempax * 25 / 32) - 1;
+                                                       tempax =(tempax * 25 /
+                                                                32) - 1;
                                                else
-                                                       tempax = (tempax * 20 / 32) - 1;
+                                                       tempax = (tempax * 20 /
+                                                                 32) - 1;
                                        }
                                }
                        } else {
@@ -6297,7 +6575,8 @@ void XGI_XG21BLSignalVDD(unsigned short tempbh, unsigned short tempbl,
        if (tempbh & 0x20) {
                temp = (tempbl >> 4) & 0x02;
 
-               xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~0x02, temp); /* CR B4[1] */
+               /* CR B4[1] */
+               xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~0x02, temp);
 
        }
 
@@ -6325,7 +6604,8 @@ void XGI_XG27BLSignalVDD(unsigned short tempbh, unsigned short tempbl,
        if (tempbh & 0x20) {
                temp = (tempbl >> 4) & 0x02;
 
-               xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~0x02, temp); /* CR B4[1] */
+               /* CR B4[1] */
+               xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~0x02, temp);
 
        }
        xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~tempbh0, tempbl0);
@@ -6390,11 +6670,13 @@ unsigned char XGI_XG21CheckLVDSMode(unsigned short ModeNo,
        if (ModeNo <= 0x13) {
                xres = pVBInfo->StResInfo[resindex].HTotal;
                yres = pVBInfo->StResInfo[resindex].VTotal;
-               modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
+               /* si+St_ResInfo */
+               modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
        } else {
                xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
                yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */
-               modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+St_ModeFlag */
+               /* si+St_ModeFlag */
+               modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
        }
 
        if (!(modeflag & Charx8Dot)) {
@@ -6419,12 +6701,13 @@ unsigned char XGI_XG21CheckLVDSMode(unsigned short ModeNo,
                return 0;
 
        if (ModeNo > 0x13) {
-               if ((xres
-                               != (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE))
-                               || (yres
-                                               != (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE))) {
-                       colordepth = XGI_GetColorDepth(ModeNo, ModeIdIndex,
-                                       pVBInfo);
+               if ((xres != (pVBInfo->XG21_LVDSCapList[lvdstableindex].
+                               LVDSHDE)) ||
+                   (yres != (pVBInfo->XG21_LVDSCapList[lvdstableindex].
+                               LVDSVDE))) {
+                       colordepth = XGI_GetColorDepth(ModeNo,
+                                                      ModeIdIndex,
+                                                      pVBInfo);
                        if (colordepth > 2)
                                return 0;
 
@@ -6439,8 +6722,10 @@ void XGI_SetXG21FPBits(struct vb_device_info *pVBInfo)
 
        temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); /* D[0] 1: 18bit */
        temp = (temp & 1) << 6;
-       xgifb_reg_and_or(pVBInfo->P3c4, 0x06, ~0x40, temp); /* SR06[6] 18bit Dither */
-       xgifb_reg_and_or(pVBInfo->P3c4, 0x09, ~0xc0, temp | 0x80); /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: dual 12bits */
+       /* SR06[6] 18bit Dither */
+       xgifb_reg_and_or(pVBInfo->P3c4, 0x06, ~0x40, temp);
+       /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: dual 12bits */
+       xgifb_reg_and_or(pVBInfo->P3c4, 0x09, ~0xc0, temp | 0x80);
 
 }
 
@@ -6448,15 +6733,19 @@ void XGI_SetXG27FPBits(struct vb_device_info *pVBInfo)
 {
        unsigned char temp;
 
-       temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); /* D[1:0] 01: 18bit, 00: dual 12, 10: single 24 */
+       /* D[1:0] 01: 18bit, 00: dual 12, 10: single 24 */
+       temp = xgifb_reg_get(pVBInfo->P3d4, 0x37);
        temp = (temp & 3) << 6;
-       xgifb_reg_and_or(pVBInfo->P3c4, 0x06, ~0xc0, temp & 0x80); /* SR06[7]0: dual 12/1: single 24 [6] 18bit Dither <= 0 h/w recommend */
-       xgifb_reg_and_or(pVBInfo->P3c4, 0x09, ~0xc0, temp | 0x80); /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: 24bits */
+       /* SR06[7]0: dual 12/1: single 24 [6] 18bit Dither <= 0 h/w recommend */
+       xgifb_reg_and_or(pVBInfo->P3c4, 0x06, ~0xc0, temp & 0x80);
+       /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: 24bits */
+       xgifb_reg_and_or(pVBInfo->P3c4, 0x09, ~0xc0, temp | 0x80);
 
 }
 
-static void XGI_SetXG21LVDSPara(unsigned short ModeNo, unsigned short ModeIdIndex,
-               struct vb_device_info *pVBInfo)
+static void XGI_SetXG21LVDSPara(unsigned short ModeNo,
+                               unsigned short ModeIdIndex,
+                               struct vb_device_info *pVBInfo)
 {
        unsigned char temp, Miscdata;
        unsigned short xres, yres, modeflag, resindex, lvdstableindex;
@@ -6466,28 +6755,33 @@ static void XGI_SetXG21LVDSPara(unsigned short ModeNo, unsigned short ModeIdInde
 
        lvdstableindex = XGI_GetLVDSOEMTableIndex(pVBInfo);
 
-       temp = (unsigned char) ((pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability
-                                       & (LCDPolarity << 8)) >> 8);
+       temp = (unsigned char) ((pVBInfo->XG21_LVDSCapList[lvdstableindex].
+                                               LVDS_Capability &
+                               (LCDPolarity << 8)) >> 8);
        temp &= LCDPolarity;
        Miscdata = (unsigned char) inb(pVBInfo->P3cc);
 
        outb((Miscdata & 0x3F) | temp, pVBInfo->P3c2);
 
-       temp = (unsigned char) (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability
-                                       & LCDPolarity);
-       xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x80, temp & 0x80); /* SR35[7] FP VSync polarity */
-       xgifb_reg_and_or(pVBInfo->P3c4, 0x30, ~0x20, (temp & 0x40) >> 1); /* SR30[5] FP HSync polarity */
+       temp = (unsigned char) (pVBInfo->XG21_LVDSCapList[lvdstableindex].
+                                               LVDS_Capability & LCDPolarity);
+       /* SR35[7] FP VSync polarity */
+       xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x80, temp & 0x80);
+       /* SR30[5] FP HSync polarity */
+       xgifb_reg_and_or(pVBInfo->P3c4, 0x30, ~0x20, (temp & 0x40) >> 1);
 
        XGI_SetXG21FPBits(pVBInfo);
        resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo);
        if (ModeNo <= 0x13) {
                xres = pVBInfo->StResInfo[resindex].HTotal;
                yres = pVBInfo->StResInfo[resindex].VTotal;
-               modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
+               /* si+St_ResInfo */
+               modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
        } else {
                xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
                yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */
-               modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+St_ModeFlag */
+               /* si+St_ModeFlag */
+               modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
        }
 
        if (!(modeflag & Charx8Dot))
@@ -6619,18 +6913,21 @@ static void XGI_SetXG21LVDSPara(unsigned short ModeNo, unsigned short ModeIdInde
 
                xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, value);
                xgifb_reg_set(pVBInfo->P3c4,
-                               0x2B,
-                               pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData1);
+                             0x2B,
+                             pVBInfo->XG21_LVDSCapList[lvdstableindex].
+                                               VCLKData1);
                xgifb_reg_set(pVBInfo->P3c4,
-                               0x2C,
-                               pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData2);
+                             0x2C,
+                             pVBInfo->XG21_LVDSCapList[lvdstableindex].
+                                               VCLKData2);
                value += 0x10;
        }
 
        if (!(modeflag & Charx8Dot)) {
                inb(pVBInfo->P3da); /* reset 3da */
                outb(0x13, pVBInfo->P3c0); /* set index */
-               outb(0x00, pVBInfo->P3c0); /* set data, panning = 0, shift left 1 dot*/
+               /* set data, panning = 0, shift left 1 dot*/
+               outb(0x00, pVBInfo->P3c0);
 
                inb(pVBInfo->P3da); /* Enable Attribute */
                outb(0x20, pVBInfo->P3c0);
@@ -6641,8 +6938,9 @@ static void XGI_SetXG21LVDSPara(unsigned short ModeNo, unsigned short ModeIdInde
 }
 
 /* no shadow case */
-static void XGI_SetXG27LVDSPara(unsigned short ModeNo, unsigned short ModeIdIndex,
-               struct vb_device_info *pVBInfo)
+static void XGI_SetXG27LVDSPara(unsigned short ModeNo,
+                               unsigned short ModeIdIndex,
+                               struct vb_device_info *pVBInfo)
 {
        unsigned char temp, Miscdata;
        unsigned short xres, yres, modeflag, resindex, lvdstableindex;
@@ -6651,28 +6949,33 @@ static void XGI_SetXG27LVDSPara(unsigned short ModeNo, unsigned short ModeIdInde
        unsigned short value;
 
        lvdstableindex = XGI_GetLVDSOEMTableIndex(pVBInfo);
-       temp = (unsigned char) ((pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability
-                                       & (LCDPolarity << 8)) >> 8);
+       temp = (unsigned char) ((pVBInfo->XG21_LVDSCapList[lvdstableindex].
+                                       LVDS_Capability &
+                               (LCDPolarity << 8)) >> 8);
        temp &= LCDPolarity;
        Miscdata = (unsigned char) inb(pVBInfo->P3cc);
 
        outb((Miscdata & 0x3F) | temp, pVBInfo->P3c2);
 
-       temp = (unsigned char) (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability
-                                       & LCDPolarity);
-       xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x80, temp & 0x80); /* SR35[7] FP VSync polarity */
-       xgifb_reg_and_or(pVBInfo->P3c4, 0x30, ~0x20, (temp & 0x40) >> 1); /* SR30[5] FP HSync polarity */
+       temp = (unsigned char) (pVBInfo->XG21_LVDSCapList[lvdstableindex].
+                                       LVDS_Capability & LCDPolarity);
+       /* SR35[7] FP VSync polarity */
+       xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x80, temp & 0x80);
+       /* SR30[5] FP HSync polarity */
+       xgifb_reg_and_or(pVBInfo->P3c4, 0x30, ~0x20, (temp & 0x40) >> 1);
 
        XGI_SetXG27FPBits(pVBInfo);
        resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo);
        if (ModeNo <= 0x13) {
                xres = pVBInfo->StResInfo[resindex].HTotal;
                yres = pVBInfo->StResInfo[resindex].VTotal;
-               modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
+               /* si+St_ResInfo */
+               modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
        } else {
                xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
                yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */
-               modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+St_ModeFlag */
+               /* si+St_ModeFlag */
+               modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
        }
 
        if (!(modeflag & Charx8Dot))
@@ -6713,7 +7016,8 @@ static void XGI_SetXG27LVDSPara(unsigned short ModeNo, unsigned short ModeIdInde
        if (LVDSVRS > LVDSVT)
                LVDSVRS -= LVDSVT;
 
-       LVDSVRE = LVDSVRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVSYNC;
+       LVDSVRE = LVDSVRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].
+                                       LVDSVSYNC;
        if (LVDSVRE > LVDSVT)
                LVDSVRE -= LVDSVT;
 
@@ -6803,18 +7107,21 @@ static void XGI_SetXG27LVDSPara(unsigned short ModeNo, unsigned short ModeIdInde
 
                xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, value);
                xgifb_reg_set(pVBInfo->P3c4,
-                               0x2B,
-                               pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData1);
+                             0x2B,
+                             pVBInfo->XG21_LVDSCapList[lvdstableindex].
+                                       VCLKData1);
                xgifb_reg_set(pVBInfo->P3c4,
-                               0x2C,
-                               pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData2);
+                             0x2C,
+                             pVBInfo->XG21_LVDSCapList[lvdstableindex].
+                                       VCLKData2);
                value += 0x10;
        }
 
        if (!(modeflag & Charx8Dot)) {
                inb(pVBInfo->P3da); /* reset 3da */
                outb(0x13, pVBInfo->P3c0); /* set index */
-               outb(0x00, pVBInfo->P3c0); /* set data, panning = 0, shift left 1 dot*/
+               /* set data, panning = 0, shift left 1 dot*/
+               outb(0x00, pVBInfo->P3c0);
 
                inb(pVBInfo->P3da); /* Enable Attribute */
                outb(0x20, pVBInfo->P3c0);
@@ -6908,14 +7215,19 @@ void XGI_DisableBridge(struct xgi_hw_device_info *HwDeviceExtension,
 
        /*
        if (CH7017) {
-               if (!(pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2toLCDA)) || (XGI_DisableChISLCD(pVBInfo))) {
+               if (!(pVBInfo->VBInfo &
+                   (SetCRT2ToLCD | SetCRT2toLCDA)) ||
+                   (XGI_DisableChISLCD(pVBInfo))) {
                        if (!XGI_IsLCDON(pVBInfo)) {
                                if (DISCHARGE) {
                                        tempbx = XGINew_GetCH7005(0x61);
-                                       if (tempbx < 0x01) // first time we power up
-                                               XGINew_SetCH7005(0x0066); // and disable power sequence
+                                       // first time we power up
+                                       if (tempbx < 0x01)
+                                               // and disable power sequence
+                                               XGINew_SetCH7005(0x0066);
                                        else
-                                               XGINew_SetCH7005(0x5f66); // leave VDD on - disable power
+                                               // leave VDD on - disable power
+                                               XGINew_SetCH7005(0x5f66);
                                }
                        }
                }
@@ -6925,29 +7237,35 @@ void XGI_DisableBridge(struct xgi_hw_device_info *HwDeviceExtension,
        if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
                        | VB_XGI302LV | VB_XGI301C)) {
                tempah = 0x3F;
-               if (!(pVBInfo->VBInfo & (DisableCRT2Display | SetSimuScanMode))) {
+               if (!(pVBInfo->VBInfo &
+                   (DisableCRT2Display | SetSimuScanMode))) {
                        if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
                                if (pVBInfo->VBInfo & SetCRT2ToDualEdge) {
                                        tempah = 0x7F; /* Disable Channel A */
                                        if (!(pVBInfo->VBInfo & SetCRT2ToLCDA))
-                                               tempah = 0xBF; /* Disable Channel B */
+                                               /* Disable Channel B */
+                                               tempah = 0xBF;
 
                                        if (pVBInfo->SetFlag & DisableChB)
-                                               tempah &= 0xBF; /* force to disable Cahnnel */
+                                               /* force to disable Cahnnel */
+                                               tempah &= 0xBF;
 
                                        if (pVBInfo->SetFlag & DisableChA)
-                                               tempah &= 0x7F; /* Force to disable Channel B */
+                                               /* Force to disable Channel B */
+                                               tempah &= 0x7F;
                                }
                        }
                }
 
-               xgifb_reg_and(pVBInfo->Part4Port, 0x1F, tempah); /* disable part4_1f */
+               /* disable part4_1f */
+               xgifb_reg_and(pVBInfo->Part4Port, 0x1F, tempah);
 
                if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) {
                        if (((pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)))
                                        || (XGI_DisableChISLCD(pVBInfo))
                                        || (XGI_IsLCDON(pVBInfo)))
-                               xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x80); /* LVDS Driver power down */
+                               /* LVDS Driver power down */
+                               xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x80);
                }
 
                if ((pVBInfo->SetFlag & DisableChA) || (pVBInfo->VBInfo
@@ -6961,38 +7279,48 @@ void XGI_DisableBridge(struct xgi_hw_device_info *HwDeviceExtension,
                if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
                        if ((pVBInfo->SetFlag & DisableChA) || (pVBInfo->VBInfo
                                        & SetCRT2ToLCDA))
-                               xgifb_reg_and(pVBInfo->Part1Port, 0x1e, 0xdf); /* Power down */
+                               /* Power down */
+                               xgifb_reg_and(pVBInfo->Part1Port, 0x1e, 0xdf);
                }
 
-               xgifb_reg_and(pVBInfo->P3c4, 0x32, 0xdf); /* disable TV as primary VGA swap */
+               /* disable TV as primary VGA swap */
+               xgifb_reg_and(pVBInfo->P3c4, 0x32, 0xdf);
 
                if ((pVBInfo->VBInfo & (SetSimuScanMode | SetCRT2ToDualEdge)))
                        xgifb_reg_and(pVBInfo->Part2Port, 0x00, 0xdf);
 
-               if ((pVBInfo->SetFlag & DisableChB) || (pVBInfo->VBInfo
-                               & (DisableCRT2Display | SetSimuScanMode))
-                               || ((!(pVBInfo->VBInfo & SetCRT2ToLCDA))
-                                               && (pVBInfo->VBInfo
-                                                               & (SetCRT2ToRAMDAC
-                                                                               | SetCRT2ToLCD
-                                                                               | SetCRT2ToTV))))
-                       xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x80); /* BScreenOff=1 */
-
-               if ((pVBInfo->SetFlag & DisableChB) || (pVBInfo->VBInfo
-                               & (DisableCRT2Display | SetSimuScanMode))
-                               || (!(pVBInfo->VBInfo & SetCRT2ToLCDA))
-                               || (pVBInfo->VBInfo & (SetCRT2ToRAMDAC
-                                               | SetCRT2ToLCD | SetCRT2ToTV))) {
-                       tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x00); /* save Part1 index 0 */
-                       xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x10); /* BTDAC = 1, avoid VB reset */
-                       xgifb_reg_and(pVBInfo->Part1Port, 0x1E, 0xDF); /* disable CRT2 */
-                       xgifb_reg_set(pVBInfo->Part1Port, 0x00, tempah); /* restore Part1 index 0 */
+               if ((pVBInfo->SetFlag & DisableChB) ||
+                   (pVBInfo->VBInfo &
+                       (DisableCRT2Display | SetSimuScanMode)) ||
+                   ((!(pVBInfo->VBInfo & SetCRT2ToLCDA)) &&
+                   (pVBInfo->VBInfo &
+                       (SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV))))
+                       /* BScreenOff=1 */
+                       xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x80);
+
+               if ((pVBInfo->SetFlag & DisableChB) ||
+                   (pVBInfo->VBInfo &
+                       (DisableCRT2Display | SetSimuScanMode)) ||
+                   (!(pVBInfo->VBInfo & SetCRT2ToLCDA)) ||
+                   (pVBInfo->VBInfo &
+                       (SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV))) {
+                       /* save Part1 index 0 */
+                       tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x00);
+                       /* BTDAC = 1, avoid VB reset */
+                       xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x10);
+                       /* disable CRT2 */
+                       xgifb_reg_and(pVBInfo->Part1Port, 0x1E, 0xDF);
+                       /* restore Part1 index 0 */
+                       xgifb_reg_set(pVBInfo->Part1Port, 0x00, tempah);
                }
        } else { /* {301} */
                if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToTV)) {
-                       xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x80); /* BScreenOff=1 */
-                       xgifb_reg_and(pVBInfo->Part1Port, 0x1E, 0xDF); /* Disable CRT2 */
-                       xgifb_reg_and(pVBInfo->P3c4, 0x32, 0xDF); /* Disable TV asPrimary VGA swap */
+                       /* BScreenOff=1 */
+                       xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x80);
+                       /* Disable CRT2 */
+                       xgifb_reg_and(pVBInfo->Part1Port, 0x1E, 0xDF);
+                       /* Disable TV asPrimary VGA swap */
+                       xgifb_reg_and(pVBInfo->P3c4, 0x32, 0xDF);
                }
 
                if (pVBInfo->VBInfo & (DisableCRT2Display | SetCRT2ToLCDA
@@ -7116,12 +7444,19 @@ static void XGI_SetDelayComp(struct vb_device_info *pVBInfo)
                        /*
                        if (pVBInfo->VBInfo & SetCRT2ToRAMDAC)
                                tempbl = CRT2Delay1;    // Get CRT2 Delay
-                       if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C))
+                       if (pVBInfo->VBType &
+                           (VB_XGI301B |
+                            VB_XGI302B |
+                            VB_XGI301LV |
+                            VB_XGI302LV |
+                            VB_XGI301C))
                                tempbl = CRT2Delay2;
                        */
                        if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
-                               index = XGI_GetLCDCapPtr(pVBInfo); /* Get LCD Delay */
-                               tempbh = pVBInfo->LCDCapList[index].LCD_DelayCompensation;
+                               /* Get LCD Delay */
+                               index = XGI_GetLCDCapPtr(pVBInfo);
+                               tempbh = pVBInfo->LCDCapList[index].
+                                               LCD_DelayCompensation;
 
                                if (!(pVBInfo->VBInfo & SetCRT2ToLCDA))
                                        tempbl = tempbh;
@@ -7147,9 +7482,10 @@ static void XGI_SetDelayComp(struct vb_device_info *pVBInfo)
                tempbl = 0;
                tempbh = 0;
                if (pVBInfo->VBInfo & SetCRT2ToLCD) {
-                       tempah
-                                       = pVBInfo->LCDCapList[XGI_GetLCDCapPtr(
-                                                       pVBInfo)].LCD_DelayCompensation; /* / Get LCD Delay */
+                       /* / Get LCD Delay */
+                       tempah = pVBInfo->LCDCapList[
+                                       XGI_GetLCDCapPtr(pVBInfo)].
+                                               LCD_DelayCompensation;
                        tempah &= 0x0f;
                        tempah = tempah << 4;
                        xgifb_reg_and_or(pVBInfo->Part1Port, 0x2D, 0x0f,
@@ -7158,7 +7494,8 @@ static void XGI_SetDelayComp(struct vb_device_info *pVBInfo)
        }
 }
 
-static void XGI_SetLCDCap_A(unsigned short tempcx, struct vb_device_info *pVBInfo)
+static void XGI_SetLCDCap_A(unsigned short tempcx,
+                           struct vb_device_info *pVBInfo)
 {
        unsigned short temp;
 
@@ -7166,7 +7503,8 @@ static void XGI_SetLCDCap_A(unsigned short tempcx, struct vb_device_info *pVBInf
 
        if (temp & LCDRGB18Bit) {
                xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0x0F,
-                               (unsigned short) (0x20 | (tempcx & 0x00C0))); /* Enable Dither */
+                               /* Enable Dither */
+                               (unsigned short) (0x20 | (tempcx & 0x00C0)));
                xgifb_reg_and_or(pVBInfo->Part1Port, 0x1A, 0x7F, 0x80);
        } else {
                xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0x0F,
@@ -7176,10 +7514,17 @@ static void XGI_SetLCDCap_A(unsigned short tempcx, struct vb_device_info *pVBInf
 
        /*
        if (tempcx & EnableLCD24bpp) {  // 24bits
-               xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0x0F, (unsigned short)(0x30 | (tempcx&0x00C0)));
+               xgifb_reg_and_or(pVBInfo->Part1Port,
+                                0x19,
+                                0x0F,
+                                (unsigned short)(0x30 | (tempcx&0x00C0)));
                xgifb_reg_and_or(pVBInfo->Part1Port, 0x1A, 0x7F, 0x00);
        } else {
-               xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0x0F, (unsigned short)(0x20 | (tempcx&0x00C0))); // Enable Dither
+               xgifb_reg_and_or(pVBInfo->Part1Port,
+                                0x19,
+                                0x0F,
+                                // Enable Dither
+                                (unsigned short)(0x20 | (tempcx&0x00C0)));
                xgifb_reg_and_or(pVBInfo->Part1Port, 0x1A, 0x7F, 0x80);
        }
        */
@@ -7191,7 +7536,8 @@ static void XGI_SetLCDCap_A(unsigned short tempcx, struct vb_device_info *pVBInf
 /* Output : */
 /* Description : */
 /* --------------------------------------------------------------------- */
-static void XGI_SetLCDCap_B(unsigned short tempcx, struct vb_device_info *pVBInfo)
+static void XGI_SetLCDCap_B(unsigned short tempcx,
+                           struct vb_device_info *pVBInfo)
 {
        if (tempcx & EnableLCD24bpp) /* 24bits */
                xgifb_reg_and_or(pVBInfo->Part2Port, 0x1A, 0xE0,
@@ -7209,7 +7555,8 @@ static void SetSpectrum(struct vb_device_info *pVBInfo)
 
        index = XGI_GetLCDCapPtr(pVBInfo);
 
-       xgifb_reg_and(pVBInfo->Part4Port, 0x30, 0x8F); /* disable down spectrum D[4] */
+       /* disable down spectrum D[4] */
+       xgifb_reg_and(pVBInfo->Part4Port, 0x30, 0x8F);
        XGI_LongWait(pVBInfo);
        xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x20); /* reset spectrum */
        XGI_LongWait(pVBInfo);
@@ -7232,9 +7579,14 @@ static void XGI_SetLCDCap(struct vb_device_info *pVBInfo)
 
        tempcx = pVBInfo->LCDCapList[XGI_GetLCDCapPtr(pVBInfo)].LCD_Capability;
 
-       if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
-                       | VB_XGI302LV | VB_XGI301C)) {
-               if (pVBInfo->VBType & (VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) { /* 301LV/302LV only */
+       if (pVBInfo->VBType &
+           (VB_XGI301B |
+            VB_XGI302B |
+            VB_XGI301LV |
+            VB_XGI302LV |
+            VB_XGI301C)) { /* 301LV/302LV only */
+               if (pVBInfo->VBType &
+                   (VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) {
                        /* Set 301LV Capability */
                        xgifb_reg_set(pVBInfo->Part4Port, 0x24,
                                        (unsigned char) (tempcx & 0x1F));
@@ -7269,8 +7621,9 @@ static void XGI_SetLCDCap(struct vb_device_info *pVBInfo)
 /* Output : */
 /* Description : Set TV Customized Param. */
 /* --------------------------------------------------------------------- */
-static void XGI_SetAntiFlicker(unsigned short ModeNo, unsigned short ModeIdIndex,
-               struct vb_device_info *pVBInfo)
+static void XGI_SetAntiFlicker(unsigned short ModeNo,
+                              unsigned short ModeIdIndex,
+                              struct vb_device_info *pVBInfo)
 {
        unsigned short tempbx, index;
 
@@ -7294,8 +7647,9 @@ static void XGI_SetAntiFlicker(unsigned short ModeNo, unsigned short ModeIdIndex
        xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0x8F, tempah);
 }
 
-static void XGI_SetEdgeEnhance(unsigned short ModeNo, unsigned short ModeIdIndex,
-               struct vb_device_info *pVBInfo)
+static void XGI_SetEdgeEnhance(unsigned short ModeNo,
+                              unsigned short ModeIdIndex,
+                              struct vb_device_info *pVBInfo)
 {
        unsigned short tempbx, index;
 
@@ -7388,10 +7742,11 @@ static void XGI_SetYFilter(unsigned short ModeNo, unsigned short ModeIdIndex,
        }
 
        if (ModeNo <= 0x13)
-               tempal = pVBInfo->SModeIDTable[ModeIdIndex].VB_StTVYFilterIndex;
+               tempal = pVBInfo->SModeIDTable[ModeIdIndex].
+                               VB_StTVYFilterIndex;
        else
-               tempal
-                               = pVBInfo->EModeIDTable[ModeIdIndex].VB_ExtTVYFilterIndex;
+               tempal = pVBInfo->EModeIDTable[ModeIdIndex].
+                               VB_ExtTVYFilterIndex;
 
        if (tempcl == 0)
                index = tempal * 4;
@@ -7424,8 +7779,9 @@ static void XGI_SetYFilter(unsigned short ModeNo, unsigned short ModeIdIndex,
 /* Output : */
 /* Description : Customized Param. for 301 */
 /* --------------------------------------------------------------------- */
-static void XGI_OEM310Setting(unsigned short ModeNo, unsigned short ModeIdIndex,
-               struct vb_device_info *pVBInfo)
+static void XGI_OEM310Setting(unsigned short ModeNo,
+                             unsigned short ModeIdIndex,
+                             struct vb_device_info *pVBInfo)
 {
        if (pVBInfo->SetFlag & Win9xDOSMode)
                return;
@@ -7462,7 +7818,8 @@ void XGI_SetCRT2ModeRegs(unsigned short ModeNo,
 
        unsigned char tempah;
 
-       /* xgifb_reg_set(pVBInfo->Part1Port, 0x03, 0x00); // fix write part1 index 0 BTDRAM bit Bug */
+       /* // fix write part1 index 0 BTDRAM bit Bug
+        * xgifb_reg_set(pVBInfo->Part1Port, 0x03, 0x00); */
        tempah = 0;
        if (!(pVBInfo->VBInfo & DisableCRT2Display)) {
                tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x00);
@@ -7476,7 +7833,8 @@ void XGI_SetCRT2ModeRegs(unsigned short ModeNo,
                                tempcl = pVBInfo->ModeType;
                                tempcl -= ModeVGA;
                                if (tempcl >= 0) {
-                                       tempah = (0x008 >> tempcl); /* BT Color */
+                                       /* BT Color */
+                                       tempah = (0x008 >> tempcl);
                                        if (tempah == 0)
                                                tempah = 1;
                                        tempah |= 0x040;
@@ -7525,8 +7883,8 @@ void XGI_SetCRT2ModeRegs(unsigned short ModeNo,
 
                if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV
                                | SetCRT2ToLCD | SetCRT2ToLCDA)) {
-                       if ((pVBInfo->VBInfo & SetCRT2ToLCDA)
-                                       && (!(pVBInfo->VBInfo & SetSimuScanMode))) {
+                       if ((pVBInfo->VBInfo & SetCRT2ToLCDA) &&
+                           (!(pVBInfo->VBInfo & SetSimuScanMode))) {
                                tempbl &= 0xf7;
                                tempah |= 0x01;
                                xgifb_reg_and_or(pVBInfo->Part1Port, 0x2e,
@@ -7537,23 +7895,26 @@ void XGI_SetCRT2ModeRegs(unsigned short ModeNo,
                                        tempah |= 0x01;
                                }
 
-                               if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC
-                                               | SetCRT2ToTV | SetCRT2ToLCD)) {
+                               if (pVBInfo->VBInfo &
+                                   (SetCRT2ToRAMDAC |
+                                    SetCRT2ToTV |
+                                    SetCRT2ToLCD)) {
                                        tempbl &= 0xf8;
                                        tempah = 0x01;
 
                                        if (!(pVBInfo->VBInfo & SetInSlaveMode))
                                                tempah |= 0x02;
 
-                                       if (!(pVBInfo->VBInfo & SetCRT2ToRAMDAC)) {
+                                       if (!(pVBInfo->VBInfo &
+                                             SetCRT2ToRAMDAC)) {
                                                tempah = tempah ^ 0x05;
-                                               if (!(pVBInfo->VBInfo
-                                                               & SetCRT2ToLCD))
+                                               if (!(pVBInfo->VBInfo &
+                                                     SetCRT2ToLCD))
                                                        tempah = tempah ^ 0x01;
                                        }
 
-                                       if (!(pVBInfo->VBInfo
-                                                       & SetCRT2ToDualEdge))
+                                       if (!(pVBInfo->VBInfo &
+                                             SetCRT2ToDualEdge))
                                                tempah |= 0x08;
                                        xgifb_reg_and_or(pVBInfo->Part1Port,
                                                        0x2e, tempbl, tempah);
@@ -7578,7 +7939,8 @@ void XGI_SetCRT2ModeRegs(unsigned short ModeNo,
                tempah |= 0x080;
 
                if (pVBInfo->VBInfo & SetCRT2ToTV) {
-                       /* if (!(pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p))) { */
+                       /* if (!(pVBInfo->TVInfo &
+                                (SetYPbPrMode525p | SetYPbPrMode750p))) { */
                        tempah |= 0x020;
                        if (ModeNo > 0x13) {
                                if (pVBInfo->VBInfo & DriverMode)
@@ -7594,7 +7956,9 @@ void XGI_SetCRT2ModeRegs(unsigned short ModeNo,
                        tempah |= 0x40;
 
                if (pVBInfo->VBInfo & SetCRT2ToTV) {
-                       /* if ((!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV)) && (!(pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p)))) { */
+                       /* if ((!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV)) &&
+                              (!(pVBInfo->TVInfo &
+                                 (SetYPbPrMode525p | SetYPbPrMode750p)))) { */
                        if (pVBInfo->TVInfo & RPLLDIV2XO)
                                tempah |= 0x40;
                        /* } */
@@ -7805,13 +8169,12 @@ unsigned short XGI_GetRatePtrCRT2(struct xgi_hw_device_info *pXGIHWDE,
                                if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B
                                                | VB_XGI301LV | VB_XGI302LV
                                                | VB_XGI301C))
-                                       temp
-                                                       = LCDARefreshIndex[pVBInfo->LCDResInfo
-                                                                       & 0x0F]; /* 301b */
+                                       /* 301b */
+                                       temp = LCDARefreshIndex[
+                                               pVBInfo->LCDResInfo & 0x0F];
                                else
-                                       temp
-                                                       = LCDRefreshIndex[pVBInfo->LCDResInfo
-                                                                       & 0x0F];
+                                       temp = LCDRefreshIndex[
+                                               pVBInfo->LCDResInfo & 0x0F];
 
                                if (index > temp)
                                        index = temp;
@@ -7825,35 +8188,34 @@ unsigned short XGI_GetRatePtrCRT2(struct xgi_hw_device_info *pXGIHWDE,
        ModeNo = pVBInfo->RefIndex[RefreshRateTableIndex].ModeID;
        if (pXGIHWDE->jChipType >= XG20) { /* for XG20, XG21, XG27 */
                /*
-               if (pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag & XG2xNotSupport) {
+               if (pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag &
+                   XG2xNotSupport) {
                        index++;
                }
                */
-               if ((pVBInfo->RefIndex[RefreshRateTableIndex].XRes == 800)
-                               && (pVBInfo->RefIndex[RefreshRateTableIndex].YRes
-                                               == 600)) {
+               if ((pVBInfo->RefIndex[RefreshRateTableIndex].XRes == 800) &&
+                   (pVBInfo->RefIndex[RefreshRateTableIndex].YRes == 600)) {
                        index++;
                }
-               /* Alan 10/19/2007; do the similar adjustment like XGISearchCRT1Rate() */
-               if ((pVBInfo->RefIndex[RefreshRateTableIndex].XRes == 1024)
-                               && (pVBInfo->RefIndex[RefreshRateTableIndex].YRes
-                                               == 768)) {
+               /* Alan 10/19/2007;
+                * do the similar adjustment like XGISearchCRT1Rate() */
+               if ((pVBInfo->RefIndex[RefreshRateTableIndex].XRes == 1024) &&
+                   (pVBInfo->RefIndex[RefreshRateTableIndex].YRes == 768)) {
                        index++;
                }
-               if ((pVBInfo->RefIndex[RefreshRateTableIndex].XRes == 1280)
-                               && (pVBInfo->RefIndex[RefreshRateTableIndex].YRes
-                                               == 1024)) {
+               if ((pVBInfo->RefIndex[RefreshRateTableIndex].XRes == 1280) &&
+                   (pVBInfo->RefIndex[RefreshRateTableIndex].YRes == 1024)) {
                        index++;
                }
        }
 
        i = 0;
        do {
-               if (pVBInfo->RefIndex[RefreshRateTableIndex + i].ModeID
-                               != ModeNo)
+               if (pVBInfo->RefIndex[RefreshRateTableIndex + i].
+                       ModeID != ModeNo)
                        break;
-               temp
-                               = pVBInfo->RefIndex[RefreshRateTableIndex + i].Ext_InfoFlag;
+               temp = pVBInfo->RefIndex[RefreshRateTableIndex + i].
+                       Ext_InfoFlag;
                temp &= ModeInfoFlag;
                if (temp < pVBInfo->ModeType)
                        break;
@@ -7863,9 +8225,8 @@ unsigned short XGI_GetRatePtrCRT2(struct xgi_hw_device_info *pXGIHWDE,
        } while (index != 0xFFFF);
        if (!(pVBInfo->VBInfo & SetCRT2ToRAMDAC)) {
                if (pVBInfo->VBInfo & SetInSlaveMode) {
-                       temp
-                                       = pVBInfo->RefIndex[RefreshRateTableIndex
-                                                       + i - 1].Ext_InfoFlag;
+                       temp = pVBInfo->RefIndex[RefreshRateTableIndex + i - 1].
+                               Ext_InfoFlag;
                        if (temp & InterlaceMode)
                                i++;
                }
@@ -8055,11 +8416,14 @@ void XGI_EnableBridge(struct xgi_hw_device_info *HwDeviceExtension,
                        | VB_XGI302LV | VB_XGI301C)) {
                if (!(pVBInfo->SetFlag & DisableChA)) {
                        if (pVBInfo->SetFlag & EnableChA) {
-                               xgifb_reg_set(pVBInfo->Part1Port, 0x1E, 0x20); /* Power on */
+                               /* Power on */
+                               xgifb_reg_set(pVBInfo->Part1Port, 0x1E, 0x20);
                        } else {
-                               if (pVBInfo->VBInfo & SetCRT2ToDualEdge) { /* SetCRT2ToLCDA ) */
+                               /* SetCRT2ToLCDA ) */
+                               if (pVBInfo->VBInfo & SetCRT2ToDualEdge) {
+                                       /* Power on */
                                        xgifb_reg_set(pVBInfo->Part1Port,
-                                                       0x1E, 0x20); /* Power on */
+                                                       0x1E, 0x20);
                                }
                        }
                }
@@ -8072,7 +8436,8 @@ void XGI_EnableBridge(struct xgi_hw_device_info *HwDeviceExtension,
                                                pVBInfo->P3c4, 0x32);
                                tempah &= 0xDF;
                                if (pVBInfo->VBInfo & SetInSlaveMode) {
-                                       if (!(pVBInfo->VBInfo & SetCRT2ToRAMDAC))
+                                       if (!(pVBInfo->VBInfo &
+                                             SetCRT2ToRAMDAC))
                                                tempah |= 0x20;
                                }
                                xgifb_reg_set(pVBInfo->P3c4, 0x32, tempah);
@@ -8082,10 +8447,11 @@ void XGI_EnableBridge(struct xgi_hw_device_info *HwDeviceExtension,
                                                pVBInfo->Part1Port, 0x2E);
 
                                if (!(tempah & 0x80))
+                                       /* BVBDOENABLE = 1 */
                                        xgifb_reg_or(pVBInfo->Part1Port,
-                                                       0x2E, 0x80); /* BVBDOENABLE = 1 */
-
-                               xgifb_reg_and(pVBInfo->Part1Port, 0x00, 0x7F); /* BScreenOFF = 0 */
+                                                       0x2E, 0x80);
+                               /* BScreenOFF = 0 */
+                               xgifb_reg_and(pVBInfo->Part1Port, 0x00, 0x7F);
                        }
                }
 
@@ -8095,15 +8461,17 @@ void XGI_EnableBridge(struct xgi_hw_device_info *HwDeviceExtension,
                                        0x20); /* shampoo 0129 */
                        if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) {
                                if (!XGI_DisableChISLCD(pVBInfo)) {
-                                       if (XGI_EnableChISLCD(pVBInfo)
-                                                       || (pVBInfo->VBInfo
-                                                                       & (SetCRT2ToLCD
-                                                                                       | SetCRT2ToLCDA)))
+                                       if (XGI_EnableChISLCD(pVBInfo) ||
+                                           (pVBInfo->VBInfo &
+                                           (SetCRT2ToLCD | SetCRT2ToLCDA)))
+                                               /* LVDS PLL power on */
                                                xgifb_reg_and(
-                                                               pVBInfo->Part4Port,
-                                                               0x2A, 0x7F); /* LVDS PLL power on */
+                                                       pVBInfo->Part4Port,
+                                                       0x2A,
+                                                       0x7F);
                                }
-                               xgifb_reg_and(pVBInfo->Part4Port, 0x30, 0x7F); /* LVDS Driver power on */
+                               /* LVDS Driver power on */
+                               xgifb_reg_and(pVBInfo->Part4Port, 0x30, 0x7F);
                        }
                }
 
@@ -8114,33 +8482,35 @@ void XGI_EnableBridge(struct xgi_hw_device_info *HwDeviceExtension,
 
                        if (!(pVBInfo->VBInfo & SetSimuScanMode)) {
                                if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
-                                       if (pVBInfo->VBInfo & SetCRT2ToDualEdge) {
+                                       if (pVBInfo->VBInfo &
+                                           SetCRT2ToDualEdge) {
                                                tempah = tempah & 0x40;
-                                               if (pVBInfo->VBInfo
-                                                               & SetCRT2ToLCDA)
+                                               if (pVBInfo->VBInfo &
+                                                   SetCRT2ToLCDA)
                                                        tempah = tempah ^ 0xC0;
 
-                                               if (pVBInfo->SetFlag
-                                                               & DisableChB)
+                                               if (pVBInfo->SetFlag &
+                                                   DisableChB)
                                                        tempah &= 0xBF;
 
-                                               if (pVBInfo->SetFlag
-                                                               & DisableChA)
+                                               if (pVBInfo->SetFlag &
+                                                   DisableChA)
                                                        tempah &= 0x7F;
 
-                                               if (pVBInfo->SetFlag
-                                                               & EnableChB)
+                                               if (pVBInfo->SetFlag &
+                                                   EnableChB)
                                                        tempah |= 0x40;
 
-                                               if (pVBInfo->SetFlag
-                                                               & EnableChA)
+                                               if (pVBInfo->SetFlag &
+                                                   EnableChA)
                                                        tempah |= 0x80;
                                        }
                                }
                        }
                }
 
-               xgifb_reg_or(pVBInfo->Part4Port, 0x1F, tempah); /* EnablePart4_1F */
+               /* EnablePart4_1F */
+               xgifb_reg_or(pVBInfo->Part4Port, 0x1F, tempah);
 
                if (pVBInfo->SetFlag & Win9xDOSMode) {
                        XGI_DisplayOn(HwDeviceExtension, pVBInfo);
@@ -8150,7 +8520,8 @@ void XGI_EnableBridge(struct xgi_hw_device_info *HwDeviceExtension,
                if (!(pVBInfo->SetFlag & DisableChA)) {
                        XGI_VBLongWait(pVBInfo);
                        if (!(pVBInfo->SetFlag & GatingCRT)) {
-                               XGI_DisableGatingCRT(HwDeviceExtension, pVBInfo);
+                               XGI_DisableGatingCRT(HwDeviceExtension,
+                                                    pVBInfo);
                                XGI_DisplayOn(HwDeviceExtension, pVBInfo);
                                XGI_VBLongWait(pVBInfo);
                        }
@@ -8159,12 +8530,14 @@ void XGI_EnableBridge(struct xgi_hw_device_info *HwDeviceExtension,
        else { /* LVDS */
                if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToLCD
                                | SetCRT2ToLCDA))
-                       xgifb_reg_or(pVBInfo->Part1Port, 0x1E, 0x20); /* enable CRT2 */
+                       /* enable CRT2 */
+                       xgifb_reg_or(pVBInfo->Part1Port, 0x1E, 0x20);
 
                tempah = (unsigned char) xgifb_reg_get(pVBInfo->Part1Port,
                                0x2E);
                if (!(tempah & 0x80))
-                       xgifb_reg_or(pVBInfo->Part1Port, 0x2E, 0x80); /* BVBDOENABLE = 1 */
+                       /* BVBDOENABLE = 1 */
+                       xgifb_reg_or(pVBInfo->Part1Port, 0x2E, 0x80);
 
                xgifb_reg_and(pVBInfo->Part1Port, 0x00, 0x7F);
                XGI_DisplayOn(HwDeviceExtension, pVBInfo);
@@ -8222,8 +8595,8 @@ static void XGI_SetCRT1Group(struct xgi_hw_device_info *HwDeviceExtension,
                                RefreshRateTableIndex, pVBInfo);
        }
 
-       if ((HwDeviceExtension->jChipType >= XG20)
-                       && (HwDeviceExtension->jChipType < XG27)) { /* fix H/W DCLK/2 bug */
+       if ((HwDeviceExtension->jChipType >= XG20) &&
+           (HwDeviceExtension->jChipType < XG27)) { /* fix H/W DCLK/2 bug */
                if ((ModeNo == 0x00) | (ModeNo == 0x01)) {
                        xgifb_reg_set(pVBInfo->P3c4, 0x2B, 0x4E);
                        xgifb_reg_set(pVBInfo->P3c4, 0x2C, 0xE9);
@@ -8242,8 +8615,10 @@ static void XGI_SetCRT1Group(struct xgi_hw_device_info *HwDeviceExtension,
                temp = xgifb_reg_get(pVBInfo->P3d4, 0x38);
                if (temp & 0xA0) {
 
-                       /* xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~0x20); *//* Enable write GPIOF */
-                       /* xgifb_reg_and(pVBInfo->P3d4, 0x48, ~0x20); *//* P. DWN */
+                       /* Enable write GPIOF */
+                       /* xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~0x20); */
+                       /* P. DWN */
+                       /* xgifb_reg_and(pVBInfo->P3d4, 0x48, ~0x20); */
                        /* XG21 CRT1 Timing */
                        if (HwDeviceExtension->jChipType == XG27)
                                XGI_SetXG27CRTC(ModeNo, ModeIdIndex,
@@ -8270,7 +8645,8 @@ static void XGI_SetCRT1Group(struct xgi_hw_device_info *HwDeviceExtension,
                                        XGI_SetXG21LVDSPara(ModeNo,
                                                        ModeIdIndex, pVBInfo);
                        }
-                       /* xgifb_reg_or(pVBInfo->P3d4, 0x48, 0x20); *//* P. ON */
+                       /* P. ON */
+                       /* xgifb_reg_or(pVBInfo->P3d4, 0x48, 0x20); */
                }
        }
 
@@ -8289,7 +8665,8 @@ unsigned char XGISetModeNew(struct xgi_hw_device_info *HwDeviceExtension,
                        unsigned short ModeNo)
 {
        unsigned short ModeIdIndex;
-       /* unsigned char *pVBInfo->FBAddr = HwDeviceExtension->pjVideoMemoryAddress; */
+       /* unsigned char *pVBInfo->FBAddr =
+                               HwDeviceExtension->pjVideoMemoryAddress; */
        struct vb_device_info VBINF;
        struct vb_device_info *pVBInfo = &VBINF;
        pVBInfo->ROMAddr = HwDeviceExtension->pjVirtualRomBase;
@@ -8334,7 +8711,8 @@ unsigned char XGISetModeNew(struct xgi_hw_device_info *HwDeviceExtension,
        pVBInfo->Part4Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14;
        pVBInfo->Part5Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14 + 2;
 
-       if (HwDeviceExtension->jChipType == XG21) { /* for x86 Linux, XG21 LVDS */
+       /* for x86 Linux, XG21 LVDS */
+       if (HwDeviceExtension->jChipType == XG21) {
                if ((xgifb_reg_get(pVBInfo->P3d4, 0x38) & 0xE0) == 0xC0)
                        pVBInfo->IF_DEF_LVDS = 1;
        }
@@ -8417,17 +8795,17 @@ unsigned char XGISetModeNew(struct xgi_hw_device_info *HwDeviceExtension,
        } /* !XG20 */
        else {
                if (pVBInfo->IF_DEF_LVDS == 1)
-                       if (!XGI_XG21CheckLVDSMode(ModeNo, ModeIdIndex, pVBInfo))
+                       if (!XGI_XG21CheckLVDSMode(ModeNo,
+                                                  ModeIdIndex,
+                                                  pVBInfo))
                                return 0;
 
                if (ModeNo <= 0x13) {
-                       pVBInfo->ModeType
-                                       = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag
-                                                       & ModeInfoFlag;
+                       pVBInfo->ModeType = pVBInfo->SModeIDTable[ModeIdIndex].
+                                               St_ModeFlag & ModeInfoFlag;
                } else {
-                       pVBInfo->ModeType
-                                       = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag
-                                                       & ModeInfoFlag;
+                       pVBInfo->ModeType = pVBInfo->EModeIDTable[ModeIdIndex].
+                                               Ext_ModeFlag & ModeInfoFlag;
                }
 
                pVBInfo->SetFlag = 0;
@@ -8455,7 +8833,10 @@ unsigned char XGISetModeNew(struct xgi_hw_device_info *HwDeviceExtension,
        pVBInfo->ModeType = modeflag&ModeInfoFlag;
        pVBInfo->SetFlag = 0x00;
        pVBInfo->VBInfo = DisableCRT2Display;
-       temp = XGINew_CheckMemorySize(HwDeviceExtension, ModeNo, ModeIdIndex, pVBInfo);
+       temp = XGINew_CheckMemorySize(HwDeviceExtension,
+                                     ModeNo,
+                                     ModeIdIndex,
+                                     pVBInfo);
 
        if (temp == 0)
                return (0);
index 7a2e564b0744984b930f6d3c389bbdaf71a5bc0d..1bd8667ff5cf24c31d208b193307ad2041a2ebcd 100644 (file)
@@ -1,38 +1,71 @@
-#ifndef  _VBSETMODE_
-#define  _VBSETMODE_
+#ifndef _VBSETMODE_
+#define _VBSETMODE_
 
-extern   void     InitTo330Pointer(unsigned char, struct vb_device_info *);
-extern   void     XGI_UnLockCRT2(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *);
-extern   void     XGI_LockCRT2(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *);
-extern   void     XGI_LongWait(struct vb_device_info *);
-extern   void     XGI_SetCRT2ModeRegs(unsigned short ModeNo,
-                                     struct xgi_hw_device_info *,
-                                     struct vb_device_info *);
-extern   void     XGI_DisableBridge(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *);
-extern   void     XGI_EnableBridge(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *);
-extern   void     XGI_DisplayOff(struct xgi_hw_device_info *, struct vb_device_info *);
-extern   void     XGI_DisplayOn(struct xgi_hw_device_info *, struct vb_device_info *);
-extern   void     XGI_GetVBType(struct vb_device_info *);
-extern   void     XGI_SenseCRT1(struct vb_device_info *);
-extern   void     XGI_GetVGAType(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *);
-extern   void     XGI_GetVBInfo(unsigned short ModeNo, unsigned short ModeIdIndex, struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *);
-extern   void     XGI_GetTVInfo(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *);
-extern   unsigned short   XGI_GetResInfo(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo);
+extern void InitTo330Pointer(unsigned char, struct vb_device_info *);
+extern void XGI_UnLockCRT2(struct xgi_hw_device_info *HwDeviceExtension,
+                          struct vb_device_info *);
+extern void XGI_LockCRT2(struct xgi_hw_device_info *HwDeviceExtension,
+                        struct vb_device_info *);
+extern void XGI_LongWait(struct vb_device_info *);
+extern void XGI_SetCRT2ModeRegs(unsigned short ModeNo,
+                               struct xgi_hw_device_info *,
+                               struct vb_device_info *);
+extern void XGI_DisableBridge(struct xgi_hw_device_info *HwDeviceExtension,
+                             struct vb_device_info *);
+extern void XGI_EnableBridge(struct xgi_hw_device_info *HwDeviceExtension,
+                            struct vb_device_info *);
+extern void XGI_DisplayOff(struct xgi_hw_device_info *,
+                          struct vb_device_info *);
+extern void XGI_DisplayOn(struct xgi_hw_device_info *,
+                         struct vb_device_info *);
+extern void XGI_GetVBType(struct vb_device_info *);
+extern void XGI_SenseCRT1(struct vb_device_info *);
+extern void XGI_GetVGAType(struct xgi_hw_device_info *HwDeviceExtension,
+                          struct vb_device_info *);
+extern void XGI_GetVBInfo(unsigned short ModeNo,
+                         unsigned short ModeIdIndex,
+                         struct xgi_hw_device_info *HwDeviceExtension,
+                         struct vb_device_info *);
+extern void XGI_GetTVInfo(unsigned short ModeNo,
+                         unsigned short ModeIdIndex,
+                         struct vb_device_info *);
+extern unsigned short XGI_GetResInfo(unsigned short ModeNo,
+                                    unsigned short ModeIdIndex,
+                                    struct vb_device_info *pVBInfo);
+
+extern unsigned char XGISetModeNew(struct xgi_hw_device_info *HwDeviceExtension,
+                                  unsigned short ModeNo) ;
 
-extern   unsigned char  XGISetModeNew(struct xgi_hw_device_info *HwDeviceExtension, unsigned short ModeNo) ;
+extern unsigned char XGI_SearchModeID(unsigned short ModeNo,
+                                     unsigned short *ModeIdIndex,
+                                     struct vb_device_info *);
+extern unsigned char XGI_GetLCDInfo(unsigned short ModeNo,
+                                   unsigned short ModeIdIndex,
+                                   struct vb_device_info *);
+extern unsigned char XGI_BridgeIsOn(struct vb_device_info *);
 
-extern   unsigned char  XGI_SearchModeID(unsigned short ModeNo, unsigned short  *ModeIdIndex, struct vb_device_info *);
-extern   unsigned char  XGI_GetLCDInfo(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *);
-extern   unsigned char  XGI_BridgeIsOn(struct vb_device_info *);
-extern   unsigned char  XGI_SetCRT2Group301(unsigned short ModeNo, struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *);
-extern   unsigned short   XGI_GetRatePtrCRT2(struct xgi_hw_device_info *pXGIHWDE, unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *);
+extern unsigned char
+XGI_SetCRT2Group301(unsigned short ModeNo,
+                   struct xgi_hw_device_info *HwDeviceExtension,
+                   struct vb_device_info *);
+extern unsigned short XGI_GetRatePtrCRT2(struct xgi_hw_device_info *pXGIHWDE,
+                                        unsigned short ModeNo,
+                                        unsigned short ModeIdIndex,
+                                        struct vb_device_info *);
 
-extern   void     XGI_SetXG21FPBits(struct vb_device_info *pVBInfo);
-extern   void     XGI_SetXG27FPBits(struct vb_device_info *pVBInfo);
-extern   void     XGI_XG21BLSignalVDD(unsigned short tempbh, unsigned short tempbl, struct vb_device_info *pVBInfo);
-extern   void     XGI_XG27BLSignalVDD(unsigned short tempbh, unsigned short tempbl, struct vb_device_info *pVBInfo);
-extern   void     XGI_XG21SetPanelDelay(unsigned short tempbl, struct vb_device_info *pVBInfo);
-extern   unsigned char  XGI_XG21CheckLVDSMode(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo);
-extern   unsigned short XGI_GetLVDSOEMTableIndex(struct vb_device_info *pVBInfo);
+extern void XGI_SetXG21FPBits(struct vb_device_info *pVBInfo);
+extern void XGI_SetXG27FPBits(struct vb_device_info *pVBInfo);
+extern void XGI_XG21BLSignalVDD(unsigned short tempbh,
+                               unsigned short tempbl,
+                               struct vb_device_info *pVBInfo);
+extern void XGI_XG27BLSignalVDD(unsigned short tempbh,
+                               unsigned short tempbl,
+                               struct vb_device_info *pVBInfo);
+extern void XGI_XG21SetPanelDelay(unsigned short tempbl,
+                                 struct vb_device_info *pVBInfo);
+extern unsigned char XGI_XG21CheckLVDSMode(unsigned short ModeNo,
+                                          unsigned short ModeIdIndex,
+                                          struct vb_device_info *pVBInfo);
+extern unsigned short XGI_GetLVDSOEMTableIndex(struct vb_device_info *pVBInfo);
 
 #endif
index 9c6e0c7ac78126b7d68b0b64c7f7fb8f9dfa3df1..377d27c0c332f4faff64f5cbd944c48547044e3d 100644 (file)
 #define EXTERN extern
 #endif
 
+struct XGI_PanelDelayTblStruct {
+       unsigned char timer[2];
+};
 
+struct XGI_LCDDataStruct {
+       unsigned short RVBHCMAX;
+       unsigned short RVBHCFACT;
+       unsigned short VGAHT;
+       unsigned short VGAVT;
+       unsigned short LCDHT;
+       unsigned short LCDVT;
+};
 
 
-struct XGI_PanelDelayTblStruct
-{
- unsigned char timer[2];
+struct XGI_LVDSCRT1HDataStruct {
+       unsigned char Reg[8];
 };
 
-struct XGI_LCDDataStruct
-{
- unsigned short RVBHCMAX;
- unsigned short RVBHCFACT;
- unsigned short VGAHT;
- unsigned short VGAVT;
- unsigned short LCDHT;
- unsigned short LCDVT;
+struct XGI_LVDSCRT1VDataStruct {
+       unsigned char Reg[7];
 };
 
+struct XGI_TVDataStruct {
+       unsigned short RVBHCMAX;
+       unsigned short RVBHCFACT;
+       unsigned short VGAHT;
+       unsigned short VGAVT;
+       unsigned short TVHDE;
+       unsigned short TVVDE;
+       unsigned short RVBHRS;
+       unsigned char FlickerMode;
+       unsigned short HALFRVBHRS;
+       unsigned char RY1COE;
+       unsigned char RY2COE;
+       unsigned char RY3COE;
+       unsigned char RY4COE;
+};
 
-struct XGI_LVDSCRT1HDataStruct
-{
- unsigned char Reg[8];
+struct XGI_LVDSDataStruct {
+       unsigned short VGAHT;
+       unsigned short VGAVT;
+       unsigned short LCDHT;
+       unsigned short LCDVT;
 };
 
-struct XGI_LVDSCRT1VDataStruct
-{
unsigned char Reg[7];
+struct XGI_LVDSDesStruct {
+       unsigned short LCDHDES;
      unsigned short LCDVDES;
 };
 
+struct XGI_LVDSCRT1DataStruct {
+       unsigned char CR[15];
+};
 
-struct XGI_TVDataStruct
-{
- unsigned short RVBHCMAX;
- unsigned short RVBHCFACT;
- unsigned short VGAHT;
- unsigned short VGAVT;
- unsigned short TVHDE;
- unsigned short TVVDE;
- unsigned short RVBHRS;
- unsigned char FlickerMode;
- unsigned short HALFRVBHRS;
- unsigned char RY1COE;
- unsigned char RY2COE;
- unsigned char RY3COE;
- unsigned char RY4COE;
+/*add for LCDA*/
+
+struct XGI_StStruct {
+       unsigned char St_ModeID;
+       unsigned short St_ModeFlag;
+       unsigned char St_StTableIndex;
+       unsigned char St_CRT2CRTC;
+       unsigned char St_CRT2CRTC2;
+       unsigned char St_ResInfo;
+       unsigned char VB_StTVFlickerIndex;
+       unsigned char VB_StTVEdgeIndex;
+       unsigned char VB_StTVYFilterIndex;
+};
+
+struct XGI_StandTableStruct {
+       unsigned char CRT_COLS;
+       unsigned char ROWS;
+       unsigned char CHAR_HEIGHT;
+       unsigned short CRT_LEN;
+       unsigned char SR[4];
+       unsigned char MISC;
+       unsigned char CRTC[0x19];
+       unsigned char ATTR[0x14];
+       unsigned char GRC[9];
 };
 
-struct XGI_LVDSDataStruct
-{
- unsigned short VGAHT;
- unsigned short VGAVT;
- unsigned short LCDHT;
- unsigned short LCDVT;
+struct XGI_ExtStruct {
+       unsigned char Ext_ModeID;
+       unsigned short Ext_ModeFlag;
+       unsigned short Ext_ModeInfo;
+       unsigned short Ext_Point;
+       unsigned short Ext_VESAID;
+       unsigned char Ext_VESAMEMSize;
+       unsigned char Ext_RESINFO;
+       unsigned char VB_ExtTVFlickerIndex;
+       unsigned char VB_ExtTVEdgeIndex;
+       unsigned char VB_ExtTVYFilterIndex;
+       unsigned char REFindex;
 };
 
-struct XGI_LVDSDesStruct
-{
- unsigned short LCDHDES;
- unsigned short LCDVDES;
+struct XGI_Ext2Struct {
+       unsigned short Ext_InfoFlag;
+       unsigned char Ext_CRT1CRTC;
+       unsigned char Ext_CRTVCLK;
+       unsigned char Ext_CRT2CRTC;
+       unsigned char Ext_CRT2CRTC2;
+       unsigned char  ModeID;
+       unsigned short XRes;
+       unsigned short YRes;
+       /* unsigned short ROM_OFFSET; */
 };
 
-struct XGI_LVDSCRT1DataStruct
-{
- unsigned char CR[15];
+
+struct XGI_MCLKDataStruct {
+       unsigned char SR28, SR29, SR2A;
+       unsigned short CLOCK;
 };
 
-/*add for LCDA*/
+struct XGI_ECLKDataStruct {
+       unsigned char SR2E, SR2F, SR30;
+       unsigned short CLOCK;
+};
+
+struct XGI_VCLKDataStruct {
+       unsigned char SR2B, SR2C;
+       unsigned short CLOCK;
+};
 
-struct XGI_StStruct
-{
- unsigned char St_ModeID;
- unsigned short St_ModeFlag;
- unsigned char St_StTableIndex;
- unsigned char St_CRT2CRTC;
- unsigned char St_CRT2CRTC2;
- unsigned char St_ResInfo;
- unsigned char VB_StTVFlickerIndex;
- unsigned char VB_StTVEdgeIndex;
- unsigned char VB_StTVYFilterIndex;
-};
-
-struct XGI_StandTableStruct
-{
- unsigned char CRT_COLS;
- unsigned char ROWS;
- unsigned char CHAR_HEIGHT;
- unsigned short CRT_LEN;
- unsigned char SR[4];
- unsigned char MISC;
- unsigned char CRTC[0x19];
- unsigned char ATTR[0x14];
- unsigned char GRC[9];
-};
-
-struct XGI_ExtStruct
-{
- unsigned char Ext_ModeID;
- unsigned short Ext_ModeFlag;
- unsigned short Ext_ModeInfo;
- unsigned short Ext_Point;
- unsigned short Ext_VESAID;
- unsigned char Ext_VESAMEMSize;
- unsigned char Ext_RESINFO;
- unsigned char VB_ExtTVFlickerIndex;
- unsigned char VB_ExtTVEdgeIndex;
- unsigned char VB_ExtTVYFilterIndex;
- unsigned char REFindex;
-};
-
-struct XGI_Ext2Struct
-{
- unsigned short Ext_InfoFlag;
- unsigned char Ext_CRT1CRTC;
- unsigned char Ext_CRTVCLK;
- unsigned char Ext_CRT2CRTC;
- unsigned char Ext_CRT2CRTC2;
- unsigned char  ModeID;
- unsigned short XRes;
- unsigned short YRes;
- /* unsigned short ROM_OFFSET; */
-};
-
-
-struct XGI_MCLKDataStruct
-{
- unsigned char SR28, SR29, SR2A;
- unsigned short CLOCK;
-};
-
-struct XGI_ECLKDataStruct
-{
- unsigned char SR2E, SR2F, SR30;
- unsigned short CLOCK;
-};
-
-struct XGI_VCLKDataStruct
-{
- unsigned char SR2B, SR2C;
- unsigned short CLOCK;
-};
-
-struct XGI_VBVCLKDataStruct
-{
- unsigned char Part4_A, Part4_B;
- unsigned short CLOCK;
-};
-
-struct XGI_StResInfoStruct
-{
- unsigned short HTotal;
- unsigned short VTotal;
-};
-
-struct XGI_ModeResInfoStruct
-{
- unsigned short HTotal;
- unsigned short VTotal;
- unsigned char  XChar;
- unsigned char  YChar;
-};
-
-struct XGI_LCDNBDesStruct
-{
-  unsigned char NB[12];
-};
- /*add for new UNIVGABIOS*/
-struct XGI_LCDDesStruct
-{
- unsigned short LCDHDES;
- unsigned short LCDHRS;
- unsigned short LCDVDES;
- unsigned short LCDVRS;
+struct XGI_VBVCLKDataStruct {
+       unsigned char Part4_A, Part4_B;
+       unsigned short CLOCK;
 };
 
-struct XGI_LCDDataTablStruct
-{
- unsigned char  PANELID;
- unsigned short MASK;
- unsigned short CAP;
- unsigned short DATAPTR;
+struct XGI_StResInfoStruct {
+       unsigned short HTotal;
+       unsigned short VTotal;
 };
 
-struct XGI_TVTablDataStruct
-{
unsigned short MASK;
unsigned short CAP;
unsigned short DATAPTR;
+struct XGI_ModeResInfoStruct {
+       unsigned short HTotal;
      unsigned short VTotal;
      unsigned char  XChar;
      unsigned char  YChar;
 };
 
-struct XGI330_LCDDataDesStruct
-{
- unsigned short LCDHDES;
- unsigned short LCDHRS;
- unsigned short LCDVDES;
- unsigned short LCDVRS;
+struct XGI_LCDNBDesStruct {
+       unsigned char NB[12];
 };
 
+/*add for new UNIVGABIOS*/
+struct XGI_LCDDesStruct {
+       unsigned short LCDHDES;
+       unsigned short LCDHRS;
+       unsigned short LCDVDES;
+       unsigned short LCDVRS;
+};
 
-struct XGI330_LVDSDataStruct
-{
- unsigned short VGAHT;
- unsigned short VGAVT;
- unsigned short LCDHT;
- unsigned short LCDVT;
+struct XGI_LCDDataTablStruct {
+       unsigned char  PANELID;
+       unsigned short MASK;
+       unsigned short CAP;
+       unsigned short DATAPTR;
 };
 
-struct XGI330_LCDDataDesStruct2
-{
- unsigned short LCDHDES;
- unsigned short LCDHRS;
- unsigned short LCDVDES;
- unsigned short LCDVRS;
- unsigned short LCDHSync;
- unsigned short LCDVSync;
+struct XGI_TVTablDataStruct {
+       unsigned short MASK;
+       unsigned short CAP;
+       unsigned short DATAPTR;
 };
 
-struct XGI330_LCDDataStruct
-{
- unsigned short RVBHCMAX;
- unsigned short RVBHCFACT;
- unsigned short VGAHT;
- unsigned short VGAVT;
- unsigned short LCDHT;
- unsigned short LCDVT;
+struct XGI330_LCDDataDesStruct {
+       unsigned short LCDHDES;
+       unsigned short LCDHRS;
+       unsigned short LCDVDES;
+       unsigned short LCDVRS;
 };
 
 
-struct XGI330_TVDataStruct
-{
- unsigned short RVBHCMAX;
- unsigned short RVBHCFACT;
- unsigned short VGAHT;
- unsigned short VGAVT;
- unsigned short TVHDE;
- unsigned short TVVDE;
- unsigned short RVBHRS;
- unsigned char FlickerMode;
- unsigned short HALFRVBHRS;
-};
-
-struct XGI330_LCDDataTablStruct
-{
- unsigned char  PANELID;
- unsigned short MASK;
- unsigned short CAP;
- unsigned short DATAPTR;
-};
-
-struct XGI330_TVDataTablStruct
-{
- unsigned short MASK;
- unsigned short CAP;
- unsigned short DATAPTR;
-};
-
-
-struct XGI330_CHTVDataStruct
-{
- unsigned short VGAHT;
- unsigned short VGAVT;
- unsigned short LCDHT;
- unsigned short LCDVT;
-};
-
-struct XGI_TimingHStruct
-{
-  unsigned char data[8];
-};
+struct XGI330_LVDSDataStruct {
+       unsigned short VGAHT;
+       unsigned short VGAVT;
+       unsigned short LCDHT;
+       unsigned short LCDVT;
+};
 
-struct XGI_TimingVStruct
-{
-  unsigned char data[7];
+struct XGI330_LCDDataDesStruct2 {
+       unsigned short LCDHDES;
+       unsigned short LCDHRS;
+       unsigned short LCDVDES;
+       unsigned short LCDVRS;
+       unsigned short LCDHSync;
+       unsigned short LCDVSync;
 };
 
-struct XGI_CH7007TV_TimingHStruct
-{
-  unsigned char data[10];
+struct XGI330_LCDDataStruct {
+       unsigned short RVBHCMAX;
+       unsigned short RVBHCFACT;
+       unsigned short VGAHT;
+       unsigned short VGAVT;
+       unsigned short LCDHT;
+       unsigned short LCDVT;
 };
 
-struct XGI_CH7007TV_TimingVStruct
-{
-  unsigned char data[10];
-};
-
-struct XGI_XG21CRT1Struct
-{
- unsigned char ModeID, CR02, CR03, CR15, CR16;
+
+struct XGI330_TVDataStruct {
+       unsigned short RVBHCMAX;
+       unsigned short RVBHCFACT;
+       unsigned short VGAHT;
+       unsigned short VGAVT;
+       unsigned short TVHDE;
+       unsigned short TVVDE;
+       unsigned short RVBHRS;
+       unsigned char FlickerMode;
+       unsigned short HALFRVBHRS;
 };
 
-struct XGI330_CHTVRegDataStruct
-{
- unsigned char Reg[16];
+struct XGI330_LCDDataTablStruct {
+       unsigned char  PANELID;
+       unsigned short MASK;
+       unsigned short CAP;
+       unsigned short DATAPTR;
 };
 
-struct XGI330_LCDCapStruct
-{
-               unsigned char      LCD_ID;
-               unsigned short     LCD_Capability;
-               unsigned char      LCD_SetFlag;
-               unsigned char      LCD_DelayCompensation;
-               unsigned char      LCD_HSyncWidth;
-               unsigned char      LCD_VSyncWidth;
-               unsigned char      LCD_VCLK;
-               unsigned char      LCDA_VCLKData1;
-               unsigned char      LCDA_VCLKData2;
-               unsigned char      LCUCHAR_VCLKData1;
-               unsigned char      LCUCHAR_VCLKData2;
-               unsigned char      PSC_S1;
-               unsigned char      PSC_S2;
-               unsigned char      PSC_S3;
-               unsigned char      PSC_S4;
-               unsigned char      PSC_S5;
-               unsigned char      PWD_2B;
-               unsigned char      PWD_2C;
-               unsigned char      PWD_2D;
-               unsigned char      PWD_2E;
-               unsigned char      PWD_2F;
-               unsigned char      Spectrum_31;
-               unsigned char      Spectrum_32;
-               unsigned char      Spectrum_33;
-               unsigned char      Spectrum_34;
+struct XGI330_TVDataTablStruct {
+       unsigned short MASK;
+       unsigned short CAP;
+       unsigned short DATAPTR;
 };
 
-struct XGI21_LVDSCapStruct
-{
-               unsigned short     LVDS_Capability;
-               unsigned short     LVDSHT;
-               unsigned short     LVDSVT;
-               unsigned short     LVDSHDE;
-               unsigned short     LVDSVDE;
-               unsigned short     LVDSHFP;
-               unsigned short     LVDSVFP;
-               unsigned short     LVDSHSYNC;
-               unsigned short     LVDSVSYNC;
-               unsigned char      VCLKData1;
-               unsigned char      VCLKData2;
-               unsigned char      PSC_S1;
-               unsigned char      PSC_S2;
-               unsigned char      PSC_S3;
-               unsigned char      PSC_S4;
-               unsigned char      PSC_S5;
+
+struct XGI330_CHTVDataStruct {
+       unsigned short VGAHT;
+       unsigned short VGAVT;
+       unsigned short LCDHT;
+       unsigned short LCDVT;
 };
 
-struct XGI_CRT1TableStruct
-{
-  unsigned char CR[16];
+struct XGI_TimingHStruct {
+       unsigned char data[8];
 };
 
+struct XGI_TimingVStruct {
+       unsigned char data[7];
+};
 
-struct XGI330_VCLKDataStruct
-{
-    unsigned char SR2B, SR2C;
-    unsigned short CLOCK;
+struct XGI_CH7007TV_TimingHStruct {
+       unsigned char data[10];
 };
 
-struct XGI301C_Tap4TimingStruct
-{
-    unsigned short DE;
-    unsigned char  Reg[64];   /* C0-FF */
-};
+struct XGI_CH7007TV_TimingVStruct {
+       unsigned char data[10];
+};
+
+struct XGI_XG21CRT1Struct {
+       unsigned char ModeID, CR02, CR03, CR15, CR16;
+};
+
+struct XGI330_CHTVRegDataStruct {
+       unsigned char Reg[16];
+};
+
+struct XGI330_LCDCapStruct {
+       unsigned char   LCD_ID;
+       unsigned short  LCD_Capability;
+       unsigned char   LCD_SetFlag;
+       unsigned char   LCD_DelayCompensation;
+       unsigned char   LCD_HSyncWidth;
+       unsigned char   LCD_VSyncWidth;
+       unsigned char   LCD_VCLK;
+       unsigned char   LCDA_VCLKData1;
+       unsigned char   LCDA_VCLKData2;
+       unsigned char   LCUCHAR_VCLKData1;
+       unsigned char   LCUCHAR_VCLKData2;
+       unsigned char   PSC_S1;
+       unsigned char   PSC_S2;
+       unsigned char   PSC_S3;
+       unsigned char   PSC_S4;
+       unsigned char   PSC_S5;
+       unsigned char   PWD_2B;
+       unsigned char   PWD_2C;
+       unsigned char   PWD_2D;
+       unsigned char   PWD_2E;
+       unsigned char   PWD_2F;
+       unsigned char   Spectrum_31;
+       unsigned char   Spectrum_32;
+       unsigned char   Spectrum_33;
+       unsigned char   Spectrum_34;
+};
+
+struct XGI21_LVDSCapStruct {
+       unsigned short LVDS_Capability;
+       unsigned short LVDSHT;
+       unsigned short LVDSVT;
+       unsigned short LVDSHDE;
+       unsigned short LVDSVDE;
+       unsigned short LVDSHFP;
+       unsigned short LVDSVFP;
+       unsigned short LVDSHSYNC;
+       unsigned short LVDSVSYNC;
+       unsigned char  VCLKData1;
+       unsigned char  VCLKData2;
+       unsigned char  PSC_S1;
+       unsigned char  PSC_S2;
+       unsigned char  PSC_S3;
+       unsigned char  PSC_S4;
+       unsigned char  PSC_S5;
+};
+
+struct XGI_CRT1TableStruct {
+       unsigned char CR[16];
+};
+
+
+struct XGI330_VCLKDataStruct {
+       unsigned char SR2B, SR2C;
+       unsigned short CLOCK;
+};
+
+struct XGI301C_Tap4TimingStruct {
+       unsigned short DE;
+       unsigned char  Reg[64];   /* C0-FF */
+};
 
-struct XGI_New_StandTableStruct
-{
+struct XGI_New_StandTableStruct {
        unsigned char  CRT_COLS;
        unsigned char  ROWS;
        unsigned char  CHAR_HEIGHT;
@@ -381,36 +336,37 @@ struct XGI_New_StandTableStruct
        unsigned char  GRC[9];
 };
 
-struct vb_device_info
-{
-    unsigned char  ISXPDOS;
-    unsigned long   P3c4,P3d4,P3c0,P3ce,P3c2,P3cc;
-    unsigned long   P3ca,P3c6,P3c7,P3c8,P3c9,P3da;
-    unsigned long   Part0Port,Part1Port,Part2Port;
-    unsigned long   Part3Port,Part4Port,Part5Port;
-    unsigned short   RVBHCFACT,RVBHCMAX,RVBHRS;
-    unsigned short   VGAVT,VGAHT,VGAVDE,VGAHDE;
-    unsigned short   VT,HT,VDE,HDE;
-    unsigned short   LCDHRS,LCDVRS,LCDHDES,LCDVDES;
-
-    unsigned short   ModeType;
-    unsigned short   IF_DEF_LVDS,IF_DEF_TRUMPION,IF_DEF_DSTN;/* ,IF_DEF_FSTN; add for dstn */
-    unsigned short   IF_DEF_CRT2Monitor,IF_DEF_VideoCapture;
-    unsigned short   IF_DEF_LCDA,IF_DEF_CH7017,IF_DEF_YPbPr,IF_DEF_ScaleLCD,IF_DEF_OEMUtil,IF_DEF_PWD;
-    unsigned short   IF_DEF_ExpLink;
-    unsigned short   IF_DEF_CH7005,IF_DEF_HiVision;
-    unsigned short   IF_DEF_CH7007; /* Billy 2007/05/03 */
-    unsigned short   LCDResInfo,LCDTypeInfo, VBType;/*301b*/
-    unsigned short   VBInfo,TVInfo,LCDInfo, Set_VGAType;
-    unsigned short   VBExtInfo;/*301lv*/
-    unsigned short   SetFlag;
-    unsigned short   NewFlickerMode;
-    unsigned short   SelectCRT2Rate;
-
-    unsigned char *ROMAddr;
-    unsigned char *FBAddr;
-    unsigned long BaseAddr;
-    unsigned long RelIO;
+struct vb_device_info {
+       unsigned char  ISXPDOS;
+       unsigned long   P3c4, P3d4, P3c0, P3ce, P3c2, P3cc;
+       unsigned long   P3ca, P3c6, P3c7, P3c8, P3c9, P3da;
+       unsigned long   Part0Port, Part1Port, Part2Port;
+       unsigned long   Part3Port, Part4Port, Part5Port;
+       unsigned short   RVBHCFACT, RVBHCMAX, RVBHRS;
+       unsigned short   VGAVT, VGAHT, VGAVDE, VGAHDE;
+       unsigned short   VT, HT, VDE, HDE;
+       unsigned short   LCDHRS, LCDVRS, LCDHDES, LCDVDES;
+
+       unsigned short   ModeType;
+       /* ,IF_DEF_FSTN; add for dstn */
+       unsigned short   IF_DEF_LVDS, IF_DEF_TRUMPION, IF_DEF_DSTN;
+       unsigned short   IF_DEF_CRT2Monitor, IF_DEF_VideoCapture;
+       unsigned short   IF_DEF_LCDA, IF_DEF_CH7017, IF_DEF_YPbPr,
+                        IF_DEF_ScaleLCD, IF_DEF_OEMUtil, IF_DEF_PWD;
+       unsigned short   IF_DEF_ExpLink;
+       unsigned short   IF_DEF_CH7005, IF_DEF_HiVision;
+       unsigned short   IF_DEF_CH7007; /* Billy 2007/05/03 */
+       unsigned short   LCDResInfo, LCDTypeInfo, VBType;/*301b*/
+       unsigned short   VBInfo, TVInfo, LCDInfo, Set_VGAType;
+       unsigned short   VBExtInfo;/*301lv*/
+       unsigned short   SetFlag;
+       unsigned short   NewFlickerMode;
+       unsigned short   SelectCRT2Rate;
+
+       unsigned char *ROMAddr;
+       unsigned char *FBAddr;
+       unsigned long BaseAddr;
+       unsigned long RelIO;
 
        unsigned char (*CR6B)[4];
        unsigned char (*CR6E)[4];
@@ -420,107 +376,106 @@ struct vb_device_info
        unsigned char (*SR15)[8];
        unsigned char (*CR40)[8];
 
-    unsigned char  *pSoftSetting;
-    unsigned char  *pOutputSelect;
-
-    unsigned short *pRGBSenseData;
-    unsigned short *pRGBSenseData2; /*301b*/
-    unsigned short *pVideoSenseData;
-    unsigned short *pVideoSenseData2;
-    unsigned short *pYCSenseData;
-    unsigned short *pYCSenseData2;
-
-    unsigned char  *pSR07;
-    unsigned char  *CR49;
-    unsigned char  *pSR1F;
-    unsigned char  *AGPReg;
-    unsigned char  *SR16;
-    unsigned char  *pSR21;
-    unsigned char  *pSR22;
-    unsigned char  *pSR23;
-    unsigned char  *pSR24;
-    unsigned char  *SR25;
-    unsigned char  *pSR31;
-    unsigned char  *pSR32;
-    unsigned char  *pSR33;
-    unsigned char  *pSR36;      /* alan 12/07/2006 */
-    unsigned char  *pCRCF;
-    unsigned char  *pCRD0;      /* alan 12/07/2006 */
-    unsigned char  *pCRDE;      /* alan 12/07/2006 */
-    unsigned char  *pCR8F;      /* alan 12/07/2006 */
-    unsigned char  *pSR40;      /* alan 12/07/2006 */
-    unsigned char  *pSR41;      /* alan 12/07/2006 */
-    unsigned char  *pDVOSetting;
-    unsigned char  *pCR2E;
-    unsigned char  *pCR2F;
-    unsigned char  *pCR46;
-    unsigned char  *pCR47;
-    unsigned char  *pCRT2Data_1_2;
-    unsigned char  *pCRT2Data_4_D;
-    unsigned char  *pCRT2Data_4_E;
-    unsigned char  *pCRT2Data_4_10;
-    struct XGI_MCLKDataStruct  *MCLKData;
-    struct XGI_ECLKDataStruct  *ECLKData;
-
-    unsigned char   *XGI_TVDelayList;
-    unsigned char   *XGI_TVDelayList2;
-    unsigned char   *CHTVVCLKUNTSC;
-    unsigned char   *CHTVVCLKONTSC;
-    unsigned char   *CHTVVCLKUPAL;
-    unsigned char   *CHTVVCLKOPAL;
-    unsigned char   *NTSCTiming;
-    unsigned char   *PALTiming;
-    unsigned char   *HiTVExtTiming;
-    unsigned char   *HiTVSt1Timing;
-    unsigned char   *HiTVSt2Timing;
-    unsigned char   *HiTVTextTiming;
-    unsigned char   *YPbPr750pTiming;
-    unsigned char   *YPbPr525pTiming;
-    unsigned char   *YPbPr525iTiming;
-    unsigned char   *HiTVGroup3Data;
-    unsigned char   *HiTVGroup3Simu;
-    unsigned char   *HiTVGroup3Text;
-    unsigned char   *Ren525pGroup3;
-    unsigned char   *Ren750pGroup3;
-    unsigned char   *ScreenOffset;
-    unsigned char   *pXGINew_DRAMTypeDefinition;
-    unsigned char   *pXGINew_I2CDefinition ;
-    unsigned char   *pXGINew_CR97 ;
-
-    struct XGI330_LCDCapStruct  *LCDCapList;
-    struct XGI21_LVDSCapStruct  *XG21_LVDSCapList;
-
-    struct XGI_TimingHStruct  *TimingH;
-    struct XGI_TimingVStruct  *TimingV;
-
-    struct XGI_StStruct          *SModeIDTable;
-    struct XGI_StandTableStruct  *StandTable;
-    struct XGI_ExtStruct         *EModeIDTable;
-    struct XGI_Ext2Struct        *RefIndex;
-    /* XGINew_CRT1TableStruct *CRT1Table; */
-    struct XGI_CRT1TableStruct    *XGINEWUB_CRT1Table;
-    struct XGI_VCLKDataStruct    *VCLKData;
-    struct XGI_VBVCLKDataStruct  *VBVCLKData;
-    struct XGI_StResInfoStruct   *StResInfo;
-    struct XGI_ModeResInfoStruct *ModeResInfo;
-    struct XGI_XG21CRT1Struct    *UpdateCRT1;
+       unsigned char  *pSoftSetting;
+       unsigned char  *pOutputSelect;
+
+       unsigned short *pRGBSenseData;
+       unsigned short *pRGBSenseData2; /*301b*/
+       unsigned short *pVideoSenseData;
+       unsigned short *pVideoSenseData2;
+       unsigned short *pYCSenseData;
+       unsigned short *pYCSenseData2;
+
+       unsigned char  *pSR07;
+       unsigned char  *CR49;
+       unsigned char  *pSR1F;
+       unsigned char  *AGPReg;
+       unsigned char  *SR16;
+       unsigned char  *pSR21;
+       unsigned char  *pSR22;
+       unsigned char  *pSR23;
+       unsigned char  *pSR24;
+       unsigned char  *SR25;
+       unsigned char  *pSR31;
+       unsigned char  *pSR32;
+       unsigned char  *pSR33;
+       unsigned char  *pSR36;      /* alan 12/07/2006 */
+       unsigned char  *pCRCF;
+       unsigned char  *pCRD0;      /* alan 12/07/2006 */
+       unsigned char  *pCRDE;      /* alan 12/07/2006 */
+       unsigned char  *pCR8F;      /* alan 12/07/2006 */
+       unsigned char  *pSR40;      /* alan 12/07/2006 */
+       unsigned char  *pSR41;      /* alan 12/07/2006 */
+       unsigned char  *pDVOSetting;
+       unsigned char  *pCR2E;
+       unsigned char  *pCR2F;
+       unsigned char  *pCR46;
+       unsigned char  *pCR47;
+       unsigned char  *pCRT2Data_1_2;
+       unsigned char  *pCRT2Data_4_D;
+       unsigned char  *pCRT2Data_4_E;
+       unsigned char  *pCRT2Data_4_10;
+       struct XGI_MCLKDataStruct  *MCLKData;
+       struct XGI_ECLKDataStruct  *ECLKData;
+
+       unsigned char   *XGI_TVDelayList;
+       unsigned char   *XGI_TVDelayList2;
+       unsigned char   *CHTVVCLKUNTSC;
+       unsigned char   *CHTVVCLKONTSC;
+       unsigned char   *CHTVVCLKUPAL;
+       unsigned char   *CHTVVCLKOPAL;
+       unsigned char   *NTSCTiming;
+       unsigned char   *PALTiming;
+       unsigned char   *HiTVExtTiming;
+       unsigned char   *HiTVSt1Timing;
+       unsigned char   *HiTVSt2Timing;
+       unsigned char   *HiTVTextTiming;
+       unsigned char   *YPbPr750pTiming;
+       unsigned char   *YPbPr525pTiming;
+       unsigned char   *YPbPr525iTiming;
+       unsigned char   *HiTVGroup3Data;
+       unsigned char   *HiTVGroup3Simu;
+       unsigned char   *HiTVGroup3Text;
+       unsigned char   *Ren525pGroup3;
+       unsigned char   *Ren750pGroup3;
+       unsigned char   *ScreenOffset;
+       unsigned char   *pXGINew_DRAMTypeDefinition;
+       unsigned char   *pXGINew_I2CDefinition ;
+       unsigned char   *pXGINew_CR97 ;
+
+       struct XGI330_LCDCapStruct  *LCDCapList;
+       struct XGI21_LVDSCapStruct  *XG21_LVDSCapList;
+
+       struct XGI_TimingHStruct  *TimingH;
+       struct XGI_TimingVStruct  *TimingV;
+
+       struct XGI_StStruct          *SModeIDTable;
+       struct XGI_StandTableStruct  *StandTable;
+       struct XGI_ExtStruct         *EModeIDTable;
+       struct XGI_Ext2Struct        *RefIndex;
+       /* XGINew_CRT1TableStruct *CRT1Table; */
+       struct XGI_CRT1TableStruct    *XGINEWUB_CRT1Table;
+       struct XGI_VCLKDataStruct    *VCLKData;
+       struct XGI_VBVCLKDataStruct  *VBVCLKData;
+       struct XGI_StResInfoStruct   *StResInfo;
+       struct XGI_ModeResInfoStruct *ModeResInfo;
+       struct XGI_XG21CRT1Struct         *UpdateCRT1;
 };  /* _struct vb_device_info */
 
 
-struct TimingInfo
-{
-    unsigned short    Horizontal_ACTIVE;
-    unsigned short    Horizontal_FP;
-    unsigned short    Horizontal_SYNC;
-    unsigned short    Horizontal_BP;
-    unsigned short    Vertical_ACTIVE;
-    unsigned short    Vertical_FP;
-    unsigned short    Vertical_SYNC;
-    unsigned short    Vertical_BP;
-    double    DCLK;
-    unsigned char     FrameRate;
-    unsigned char     Interlace;
-    unsigned short    Margin;
+struct TimingInfo {
+       unsigned short Horizontal_ACTIVE;
+       unsigned short Horizontal_FP;
+       unsigned short Horizontal_SYNC;
+       unsigned short Horizontal_BP;
+       unsigned short Vertical_ACTIVE;
+       unsigned short Vertical_FP;
+       unsigned short Vertical_SYNC;
+       unsigned short Vertical_BP;
+       double         DCLK;
+       unsigned char  FrameRate;
+       unsigned char  Interlace;
+       unsigned short Margin;
 };
 
 #define _VB_STRUCT_
index d71cd55a7057a363dedef9563c30359a00fef236..d10de4888dc308fabe75cb818e33bb2b5e5fb201 100644 (file)
 #define  Tap4
 
-//yilin modify for xgi20
-static struct XGI_MCLKDataStruct XGI340New_MCLKData[] =
-{
- { 0x16,0x01,0x01,166},
- { 0x19,0x02,0x01,124},
- { 0x7C,0x08,0x01,200},
- { 0x79,0x06,0x01,250},
- { 0x29,0x01,0x81,301},
- { 0x5c,0x23,0x01,166},
- { 0x5c,0x23,0x01,166},
- { 0x5c,0x23,0x01,166}
-};
-
-static struct XGI_MCLKDataStruct XGI27New_MCLKData[] =
-{
- { 0x5c,0x23,0x01,166},
- { 0x19,0x02,0x01,124},
- { 0x7C,0x08,0x80,200},
- { 0x79,0x06,0x80,250},
- { 0x29,0x01,0x81,300},
- { 0x5c,0x23,0x01,166},
- { 0x5c,0x23,0x01,166},
- { 0x5c,0x23,0x01,166}
-};
-
-//yilin modify for xgi20
-static struct XGI_ECLKDataStruct XGI340_ECLKData[] =
-{
- { 0x5c,0x23,0x01,166},
- { 0x55,0x84,0x01,123},
- { 0x7C,0x08,0x01,200},
- { 0x79,0x06,0x01,250},
- { 0x29,0x01,0x81,301},
- { 0x5c,0x23,0x01,166},
- { 0x5c,0x23,0x01,166},
- { 0x5c,0x23,0x01,166}
+/* yilin modify for xgi20 */
+static struct XGI_MCLKDataStruct XGI340New_MCLKData[] = {
+       {0x16, 0x01, 0x01, 166},
+       {0x19, 0x02, 0x01, 124},
+       {0x7C, 0x08, 0x01, 200},
+       {0x79, 0x06, 0x01, 250},
+       {0x29, 0x01, 0x81, 301},
+       {0x5c, 0x23, 0x01, 166},
+       {0x5c, 0x23, 0x01, 166},
+       {0x5c, 0x23, 0x01, 166}
+};
+
+static struct XGI_MCLKDataStruct XGI27New_MCLKData[] = {
+       {0x5c, 0x23, 0x01, 166},
+       {0x19, 0x02, 0x01, 124},
+       {0x7C, 0x08, 0x80, 200},
+       {0x79, 0x06, 0x80, 250},
+       {0x29, 0x01, 0x81, 300},
+       {0x5c, 0x23, 0x01, 166},
+       {0x5c, 0x23, 0x01, 166},
+       {0x5c, 0x23, 0x01, 166}
+};
+
+/* yilin modify for xgi20 */
+static struct XGI_ECLKDataStruct XGI340_ECLKData[] = {
+       {0x5c, 0x23, 0x01, 166},
+       {0x55, 0x84, 0x01, 123},
+       {0x7C, 0x08, 0x01, 200},
+       {0x79, 0x06, 0x01, 250},
+       {0x29, 0x01, 0x81, 301},
+       {0x5c, 0x23, 0x01, 166},
+       {0x5c, 0x23, 0x01, 166},
+       {0x5c, 0x23, 0x01, 166}
 };
 
-
-
 static unsigned char XGI340_SR13[4][8] = {
-{0x35,0x45,0xb1,0x00,0x00,0x00,0x00,0x00},/* SR13 */
-{0x41,0x51,0x5c,0x00,0x00,0x00,0x00,0x00},/* SR14 */
-{0x31,0x42,0x42,0x00,0x00,0x00,0x00,0x00},/* SR18 */
-{0x03,0x03,0x03,0x00,0x00,0x00,0x00,0x00}/* SR1B */
-};
-
-static unsigned char XGI340_cr41[24][8] =
-{{0x20,0x50,0x60,0x00,0x00,0x00,0x00,0x00},/* 0 CR41 */
-{0xc4,0x40,0x84,0x00,0x00,0x00,0x00,0x00},/* 1 CR8A */
-{0xc4,0x40,0x84,0x00,0x00,0x00,0x00,0x00},/* 2 CR8B */
-{0xb5,0xa4,0xa4,0x00,0x00,0x00,0x00,0x00},
-{0xf0,0xf0,0xf0,0x00,0x00,0x00,0x00,0x00},
-{0x90,0x90,0x24,0x00,0x00,0x00,0x00,0x00},/* 5 CR68 */
-{0x77,0x77,0x44,0x00,0x00,0x00,0x00,0x00},/* 6 CR69 */
-{0x77,0x77,0x44,0x00,0x00,0x00,0x00,0x00},/* 7 CR6A */
-{0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00},/* 8 CR6D */
-{0x55,0x55,0x55,0x00,0x00,0x00,0x00,0x00},/* 9 CR80 */
-{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/* 10 CR81 */
-{0x88,0xa8,0x48,0x00,0x00,0x00,0x00,0x00},/* 11 CR82 */
-{0x44,0x44,0x77,0x00,0x00,0x00,0x00,0x00},/* 12 CR85 */
-{0x48,0x48,0x88,0x00,0x00,0x00,0x00,0x00},/* 13 CR86 */
-{0x54,0x54,0x44,0x00,0x00,0x00,0x00,0x00},/* 14 CR90 */
-{0x54,0x54,0x44,0x00,0x00,0x00,0x00,0x00},/* 15 CR91 */
-{0x0a,0x0a,0x07,0x00,0x00,0x00,0x00,0x00},/* 16 CR92 */
-{0x44,0x44,0x44,0x00,0x00,0x00,0x00,0x00},/* 17 CR93 */
-{0x10,0x10,0x0A,0x00,0x00,0x00,0x00,0x00},/* 18 CR94 */
-{0x11,0x11,0x0a,0x00,0x00,0x00,0x00,0x00},/* 19 CR95 */
-{0x05,0x05,0x05,0x00,0x00,0x00,0x00,0x00},/* 20 CR96 */
-{0xf0,0xf0,0xf0,0x00,0x00,0x00,0x00,0x00},/* 21 CRC3 */
-{0x05,0x00,0x02,0x00,0x00,0x00,0x00,0x00},/* 22 CRC4 */
-{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}/* 23 CRC5 */
-};
-
-
-static unsigned char XGI27_cr41[24][8] =
-{
-{0x20,0x40,0x60,0x00,0x00,0x00,0x00,0x00},/* 0 CR41 */
-{0xC4,0x40,0x84,0x00,0x00,0x00,0x00,0x00},/* 1 CR8A */
-{0xC4,0x40,0x84,0x00,0x00,0x00,0x00,0x00},/* 2 CR8B */
-{0xB5,0x13,0xa4,0x00,0x00,0x00,0x00,0x00},/* 3 CR40[7],CR99[2:0],CR45[3:0]*/
-{0xf0,0xf5,0xf0,0x00,0x00,0x00,0x00,0x00},/* 4 CR59 */
-{0x90,0x90,0x24,0x00,0x00,0x00,0x00,0x00},/* 5 CR68 */
-{0x77,0x67,0x44,0x00,0x00,0x00,0x00,0x00},/* 6 CR69 */
-{0x77,0x77,0x44,0x00,0x00,0x00,0x00,0x00},/* 7 CR6A */
-{0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00},/* 8 CR6D */
-{0x55,0x55,0x55,0x00,0x00,0x00,0x00,0x00},/* 9 CR80 */
-{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/* 10 CR81 */
-{0x88,0xcc,0x48,0x00,0x00,0x00,0x00,0x00},/* 11 CR82 */
-{0x44,0x88,0x77,0x00,0x00,0x00,0x00,0x00},/* 12 CR85 */
-{0x48,0x88,0x88,0x00,0x00,0x00,0x00,0x00},/* 13 CR86 */
-{0x54,0x32,0x44,0x00,0x00,0x00,0x00,0x00},/* 14 CR90 */
-{0x54,0x33,0x44,0x00,0x00,0x00,0x00,0x00},/* 15 CR91 */
-{0x0a,0x07,0x07,0x00,0x00,0x00,0x00,0x00},/* 16 CR92 */
-{0x44,0x63,0x44,0x00,0x00,0x00,0x00,0x00},/* 17 CR93 */
-{0x10,0x14,0x0A,0x00,0x00,0x00,0x00,0x00},/* 18 CR94 */
-{0x11,0x0B,0x0C,0x00,0x00,0x00,0x00,0x00},/* 19 CR95 */
-{0x05,0x22,0x05,0x00,0x00,0x00,0x00,0x00},/* 20 CR96 */
-{0xf0,0xf0,0x00,0x00,0x00,0x00,0x00,0x00},/* 21 CRC3 */
-{0x05,0x00,0x02,0x00,0x00,0x00,0x00,0x00},/* 22 CRC4 */
-{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}/* 23 CRC5 */
+       {0x35, 0x45, 0xb1, 0x00, 0x00, 0x00, 0x00, 0x00}, /* SR13 */
+       {0x41, 0x51, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00}, /* SR14 */
+       {0x31, 0x42, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00}, /* SR18 */
+       {0x03, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00}  /* SR1B */
+};
+
+static unsigned char XGI340_cr41[24][8] = {
+       {0x20, 0x50, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0 CR41 */
+       {0xc4, 0x40, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 1 CR8A */
+       {0xc4, 0x40, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 2 CR8B */
+       {0xb5, 0xa4, 0xa4, 0x00, 0x00, 0x00, 0x00, 0x00},
+       {0xf0, 0xf0, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00},
+       {0x90, 0x90, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 5 CR68 */
+       {0x77, 0x77, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 6 CR69 */
+       {0x77, 0x77, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 7 CR6A */
+       {0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 8 CR6D */
+       {0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 9 CR80 */
+       {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 10 CR81 */
+       {0x88, 0xa8, 0x48, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 11 CR82 */
+       {0x44, 0x44, 0x77, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 12 CR85 */
+       {0x48, 0x48, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 13 CR86 */
+       {0x54, 0x54, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 14 CR90 */
+       {0x54, 0x54, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 15 CR91 */
+       {0x0a, 0x0a, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 16 CR92 */
+       {0x44, 0x44, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 17 CR93 */
+       {0x10, 0x10, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 18 CR94 */
+       {0x11, 0x11, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 19 CR95 */
+       {0x05, 0x05, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 20 CR96 */
+       {0xf0, 0xf0, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 21 CRC3 */
+       {0x05, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 22 CRC4 */
+       {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}  /* 23 CRC5 */
+};
+
+static unsigned char XGI27_cr41[24][8] = {
+       {0x20, 0x40, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 0 CR41 */
+       {0xC4, 0x40, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 1 CR8A */
+       {0xC4, 0x40, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 2 CR8B */
+       {0xB5, 0x13, 0xa4, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 3 CR40[7],
+                                                              CR99[2:0],
+                                                              CR45[3:0]*/
+       {0xf0, 0xf5, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 4 CR59 */
+       {0x90, 0x90, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 5 CR68 */
+       {0x77, 0x67, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 6 CR69 */
+       {0x77, 0x77, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 7 CR6A */
+       {0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 8 CR6D */
+       {0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 9 CR80 */
+       {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 10 CR81 */
+       {0x88, 0xcc, 0x48, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 11 CR82 */
+       {0x44, 0x88, 0x77, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 12 CR85 */
+       {0x48, 0x88, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 13 CR86 */
+       {0x54, 0x32, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 14 CR90 */
+       {0x54, 0x33, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 15 CR91 */
+       {0x0a, 0x07, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 16 CR92 */
+       {0x44, 0x63, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 17 CR93 */
+       {0x10, 0x14, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 18 CR94 */
+       {0x11, 0x0B, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 19 CR95 */
+       {0x05, 0x22, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 20 CR96 */
+       {0xf0, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 21 CRC3 */
+       {0x05, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00}, /* 22 CRC4 */
+       {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}  /* 23 CRC5 */
 };
 
 static unsigned char XGI340_CR6B[8][4] = {
-{0xaa,0xaa,0xaa,0xaa},
-{0xaa,0xaa,0xaa,0xaa},
-{0xaa,0xaa,0xaa,0xaa},
-{0x00,0x00,0x00,0x00},
-{0x00,0x00,0x00,0x00},
-{0x00,0x00,0x00,0x00},
-{0x00,0x00,0x00,0x00},
-{0x00,0x00,0x00,0x00}
+       {0xaa, 0xaa, 0xaa, 0xaa},
+       {0xaa, 0xaa, 0xaa, 0xaa},
+       {0xaa, 0xaa, 0xaa, 0xaa},
+       {0x00, 0x00, 0x00, 0x00},
+       {0x00, 0x00, 0x00, 0x00},
+       {0x00, 0x00, 0x00, 0x00},
+       {0x00, 0x00, 0x00, 0x00},
+       {0x00, 0x00, 0x00, 0x00}
 };
 
 static unsigned char XGI340_CR6E[8][4] = {
-{0x00,0x00,0x00,0x00},
-{0x00,0x00,0x00,0x00},
-{0x00,0x00,0x00,0x00},
-{0x00,0x00,0x00,0x00},
-{0x00,0x00,0x00,0x00},
-{0x00,0x00,0x00,0x00},
-{0x00,0x00,0x00,0x00},
-{0x00,0x00,0x00,0x00}
+       {0x00, 0x00, 0x00, 0x00},
+       {0x00, 0x00, 0x00, 0x00},
+       {0x00, 0x00, 0x00, 0x00},
+       {0x00, 0x00, 0x00, 0x00},
+       {0x00, 0x00, 0x00, 0x00},
+       {0x00, 0x00, 0x00, 0x00},
+       {0x00, 0x00, 0x00, 0x00},
+       {0x00, 0x00, 0x00, 0x00}
 };
 
 static unsigned char XGI340_CR6F[8][32] = {
-{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
-{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
-{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
-{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
-{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
-{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
-{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
-{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}
+       {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+       {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+       {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+       {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+       {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+       {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+       {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+       {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
 };
 
 static unsigned char XGI340_CR89[8][2] = {
-{0x00,0x00},
-{0x00,0x00},
-{0x00,0x00},
-{0x00,0x00},
-{0x00,0x00},
-{0x00,0x00},
-{0x00,0x00},
-{0x00,0x00}
-};
-                        /* CR47,CR48,CR49,CR4A,CR4B,CR4C,CR70,CR71,CR74,CR75,CR76,CR77 */
+       {0x00, 0x00},
+       {0x00, 0x00},
+       {0x00, 0x00},
+       {0x00, 0x00},
+       {0x00, 0x00},
+       {0x00, 0x00},
+       {0x00, 0x00},
+       {0x00, 0x00}
+};
+/* CR47,CR48,CR49,CR4A,CR4B,CR4C,CR70,CR71,CR74,CR75,CR76,CR77 */
 static unsigned char XGI340_AGPReg[12] = {
-                                  0x28, 0x23, 0x00, 0x20, 0x00, 0x20, 0x00,
-                                  0x05, 0xd0, 0x10, 0x10, 0x00};
+       0x28, 0x23, 0x00, 0x20, 0x00, 0x20,
+       0x00, 0x05, 0xd0, 0x10, 0x10, 0x00
+};
 
 static unsigned char XGI340_SR16[4] = {0x03, 0x83, 0x03, 0x83};
 
 #if 0
 static unsigned char XGI330_SR15_1[8][8] = {
-{0x0,0x0,0x00,0x00,0x20,0x20,0x00,0x00},
-{0x5,0x15,0x15,0x15,0x15,0x15,0x00,0x00},
-{0xba,0xba,0xba,0xba,0xBA,0xBA,0x00,0x00},
-{0x55,0x57,0x57,0xAB,0xAB,0xAB,0x00,0x00},
-{0x60,0x34,0x34,0x34,0x34,0x34,0x00,0x00},
-{0x0,0x80,0x80,0x80,0x83,0x83,0x00,0x00},
-{0x50,0x50,0x50,0x3C,0x3C,0x3C,0x00,0x00},
-{0x0,0xa5,0xfb,0xf6,0xF6,0xF6,0x00,0x00}
+       {0x0, 0x0, 0x00, 0x00, 0x20, 0x20, 0x00, 0x00},
+       {0x5, 0x15, 0x15, 0x15, 0x15, 0x15, 0x00, 0x00},
+       {0xba, 0xba, 0xba, 0xba, 0xBA, 0xBA, 0x00, 0x00},
+       {0x55, 0x57, 0x57, 0xAB, 0xAB, 0xAB, 0x00, 0x00},
+       {0x60, 0x34, 0x34, 0x34, 0x34, 0x34, 0x00, 0x00},
+       {0x0, 0x80, 0x80, 0x80, 0x83, 0x83, 0x00, 0x00},
+       {0x50, 0x50, 0x50, 0x3C, 0x3C, 0x3C, 0x00, 0x00},
+       {0x0, 0xa5, 0xfb, 0xf6, 0xF6, 0xF6, 0x00, 0x00}
 };
 
 static unsigned char XGI330_cr40_1[15][8] = {
-{0x66,0x40,0x40,0x28,0x24,0x24,0x00,0x00},
-{0x66,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
-{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
-{0x00,0x00,0x00,0x00,0x0F,0x0F,0x00,0x00},
-{0x00,0xf0,0xf0,0xf0,0xF0,0xF0,0x00,0x00},
-{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
-{0x10,0x10,0x10,0x10,0x20,0x20,0x00,0x00},
-{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
-{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
-{0x88,0x88,0x88,0xAA,0xAC,0xAC,0x00,0x00},
-{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
-{0x00,0x00,0x00,0x00,0x77,0x77,0x00,0x00},
-{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
-{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
-{0x00,0xA2,0x00,0x00,0xA2,0xA2,0x00,0x00},
+       {0x66, 0x40, 0x40, 0x28, 0x24, 0x24, 0x00, 0x00},
+       {0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+       {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+       {0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00},
+       {0x00, 0xf0, 0xf0, 0xf0, 0xF0, 0xF0, 0x00, 0x00},
+       {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+       {0x10, 0x10, 0x10, 0x10, 0x20, 0x20, 0x00, 0x00},
+       {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+       {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+       {0x88, 0x88, 0x88, 0xAA, 0xAC, 0xAC, 0x00, 0x00},
+       {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+       {0x00, 0x00, 0x00, 0x00, 0x77, 0x77, 0x00, 0x00},
+       {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+       {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+       {0x00, 0xA2, 0x00, 0x00, 0xA2, 0xA2, 0x00, 0x00},
 };
 #endif
 
@@ -191,3248 +211,3380 @@ static unsigned char XGI330_SR33 = 0x00;
 static unsigned char XG40_CRCF = 0x13;
 static unsigned char XG40_DRAMTypeDefinition = 0xFF ;
 
-static struct XGI_StStruct XGI330_SModeIDTable[] =
-{
- {0x01,0x9208,0x01,0x00,0x10,0x00,0x00,0x01,0x00},
- {0x01,0x1210,0x14,0x01,0x00,0x01,0x00,0x01,0x00},
- {0x01,0x1010,0x17,0x02,0x11,0x00,0x00,0x01,0x01},
- {0x03,0x8208,0x03,0x00,0x14,0x00,0x00,0x01,0x02},
- {0x03,0x0210,0x16,0x01,0x04,0x01,0x00,0x01,0x02},
- {0x03,0x0010,0x18,0x02,0x15,0x00,0x00,0x01,0x03},
- {0x05,0x9209,0x05,0x00,0x10,0x00,0x00,0x00,0x04},
- {0x06,0x8209,0x06,0x00,0x14,0x00,0x00,0x00,0x05},
- {0x07,0x0000,0x07,0x03,0x05,0x03,0x00,0x01,0x03},
- {0x07,0x0000,0x19,0x02,0x15,0x02,0x00,0x01,0x03},
- {0x0d,0x920a,0x0d,0x00,0x10,0x00,0x00,0x00,0x04},
- {0x0e,0x820a,0x0e,0x00,0x14,0x00,0x00,0x00,0x05},
- {0x0f,0x0202,0x11,0x01,0x04,0x01,0x00,0x00,0x05},
- {0x10,0x0212,0x12,0x01,0x04,0x01,0x00,0x00,0x05},
- {0x11,0x0212,0x1a,0x04,0x24,0x04,0x00,0x00,0x05},
- {0x12,0x0212,0x1b,0x04,0x24,0x04,0x00,0x00,0x05},
- {0x13,0x021b,0x1c,0x00,0x14,0x00,0x00,0x00,0x04},
- {0x12,0x0010,0x18,0x02,0x24,0x02,0x00,0x00,0x05},/* St_CRT2CRTC2 not sure */
- {0x12,0x0210,0x18,0x01,0x24,0x01,0x00,0x00,0x05},/* St_CRT2CRTC2 not sure */
- {0xff,0x0000,0x00,0x00,0x00,0x00,0x00,0x00,0x00}
-};
-
-
-static struct XGI_ExtStruct  XGI330_EModeIDTable[] =
-{
- {0x6a,0x2212,0x0407,0x3a81,0x0102,0x08,0x07,0x00,0x00,0x07,0x0e},
- {0x2e,0x0a1b,0x0306,0x3a57,0x0101,0x08,0x06,0x00,0x00,0x05,0x06},
- {0x2f,0x0a1b,0x0305,0x3a50,0x0100,0x08,0x05,0x00,0x00,0x05,0x05},
- {0x30,0x2a1b,0x0407,0x3a81,0x0103,0x08,0x07,0x00,0x00,0x07,0x0e},
- {0x31,0x0a1b,0x030d,0x3b85,0x0000,0x08,0x0d,0x00,0x00,0x06,0x3d},
- {0x32,0x0a1b,0x0a0e,0x3b8c,0x0000,0x08,0x0e,0x00,0x00,0x06,0x3e},
- {0x33,0x0a1d,0x0a0d,0x3b85,0x0000,0x08,0x0d,0x00,0x00,0x06,0x3d},
- {0x34,0x2a1d,0x0a0e,0x3b8c,0x0000,0x08,0x0e,0x00,0x00,0x06,0x3e},
- {0x35,0x0a1f,0x0a0d,0x3b85,0x0000,0x08,0x0d,0x00,0x00,0x06,0x3d},
- {0x36,0x2a1f,0x0a0e,0x3b8c,0x0000,0x08,0x0e,0x00,0x00,0x06,0x3e},
- {0x37,0x0212,0x0508,0x3aab,0x0104,0x08,0x08,0x00,0x00,0x00,0x16},
- {0x38,0x0a1b,0x0508,0x3aab,0x0105,0x08,0x08,0x00,0x00,0x00,0x16},
- {0x3a,0x0e3b,0x0609,0x3adc,0x0107,0x08,0x09,0x00,0x00,0x00,0x1e},
- {0x3c,0x0e3b,0x070a,0x3af2,0x0130,0x08,0x0a,0x00,0x00,0x00,0x22},     /* mode 1600x1200 add CRT2MODE [2003/10/07] */
- {0x3d,0x0e7d,0x070a,0x3af2,0x0131,0x08,0x0a,0x00,0x00,0x00,0x22},     /* mode 1600x1200 add CRT2MODE */
- {0x40,0x9a1c,0x0000,0x3a34,0x010d,0x08,0x00,0x00,0x00,0x04,0x00},
- {0x41,0x9a1d,0x0000,0x3a34,0x010e,0x08,0x00,0x00,0x00,0x04,0x00},     /* ModeIdIndex = 0x10 */
- {0x43,0x0a1c,0x0306,0x3a57,0x0110,0x08,0x06,0x00,0x00,0x05,0x06},
- {0x44,0x0a1d,0x0306,0x3a57,0x0111,0x08,0x06,0x00,0x00,0x05,0x06},
- {0x46,0x2a1c,0x0407,0x3a81,0x0113,0x08,0x07,0x00,0x00,0x07,0x0e},
- {0x47,0x2a1d,0x0407,0x3a81,0x0114,0x08,0x07,0x00,0x00,0x07,0x0e},
- {0x49,0x0a3c,0x0508,0x3aab,0x0116,0x08,0x08,0x00,0x00,0x00,0x16},
- {0x4a,0x0a3d,0x0508,0x3aab,0x0117,0x08,0x08,0x00,0x00,0x00,0x16},
- {0x4c,0x0e7c,0x0609,0x3adc,0x0119,0x08,0x09,0x00,0x00,0x00,0x1e},
- {0x4d,0x0e7d,0x0609,0x3adc,0x011a,0x08,0x09,0x00,0x00,0x00,0x1e},
- {0x50,0x9a1b,0x0001,0x3a3b,0x0132,0x08,0x01,0x00,0x00,0x04,0x02},
- {0x51,0xba1b,0x0103,0x3a42,0x0133,0x08,0x03,0x00,0x00,0x07,0x03},
- {0x52,0x9a1b,0x0204,0x3a49,0x0134,0x08,0x04,0x00,0x00,0x00,0x04},
- {0x56,0x9a1d,0x0001,0x3a3b,0x0135,0x08,0x01,0x00,0x00,0x04,0x02},
- {0x57,0xba1d,0x0103,0x3a42,0x0136,0x08,0x03,0x00,0x00,0x07,0x03},
- {0x58,0x9a1d,0x0204,0x3a49,0x0137,0x08,0x04,0x00,0x00,0x00,0x04},
- {0x59,0x9a1b,0x0000,0x3a34,0x0138,0x08,0x00,0x00,0x00,0x04,0x00},
- {0x5A,0x021b,0x0014,0x3b83,0x0138,0x08,0x01,0x00,0x00,0x04,0x3f},     /* ModeIdIndex = 0x20 */
- {0x5B,0x0a1d,0x0014,0x3b83,0x0135,0x08,0x01,0x00,0x00,0x04,0x3f},
- {0x5d,0x0a1d,0x0305,0x3a50,0x0139,0x08,0x05,0x00,0x00,0x07,0x05},
- {0x62,0x0a3f,0x0306,0x3a57,0x013a,0x08,0x06,0x00,0x00,0x05,0x06},
- {0x63,0x2a3f,0x0407,0x3a81,0x013b,0x08,0x07,0x00,0x00,0x07,0x0e},
- {0x64,0x0a7f,0x0508,0x3aab,0x013c,0x08,0x08,0x00,0x00,0x00,0x16},
- {0x65,0x0eff,0x0609,0x3adc,0x013d,0x08,0x09,0x00,0x00,0x00,0x1e},
- {0x66,0x0eff,0x070a,0x3af2,0x013e,0x08,0x0a,0x00,0x00,0x00,0x22},     /* mode 1600x1200 add CRT2MODE */
- {0x68,0x067b,0x080b,0x3b17,0x013f,0x08,0x0b,0x00,0x00,0x00,0x29},
- {0x69,0x06fd,0x080b,0x3b17,0x0140,0x08,0x0b,0x00,0x00,0x00,0x29},
- {0x6b,0x07ff,0x080b,0x3b17,0x0141,0x10,0x0b,0x00,0x00,0x00,0x29},
- {0x6c,0x067b,0x090c,0x3b37,0x0000,0x08,0x0c,0x00,0x00,0x00,0x2f},
- {0x6d,0x06fd,0x090c,0x3b37,0x0000,0x10,0x0c,0x00,0x00,0x00,0x2f},
- {0x6e,0x07ff,0x090c,0x3b37,0x0000,0x10,0x0c,0x00,0x00,0x00,0x2f},
- {0x70,0x2a1b,0x0410,0x3b52,0x0000,0x08,0x10,0x00,0x00,0x07,0x34},
- {0x71,0x0a1b,0x0511,0x3b63,0x0000,0x08,0x11,0x00,0x00,0x00,0x37},
- {0x74,0x0a1d,0x0511,0x3b63,0x0000,0x08,0x11,0x00,0x00,0x00,0x37},     /* ModeIdIndex = 0x30 */
- {0x75,0x0a3d,0x0612,0x3b74,0x0000,0x08,0x12,0x00,0x00,0x00,0x3a},
- {0x76,0x2a1f,0x0410,0x3b52,0x0000,0x08,0x10,0x00,0x00,0x07,0x34},
- {0x77,0x0a1f,0x0511,0x3b63,0x0000,0x08,0x11,0x00,0x00,0x00,0x37},
- {0x78,0x0a3f,0x0612,0x3b74,0x0000,0x08,0x12,0x00,0x00,0x00,0x3a},
- {0x79,0x0a3b,0x0612,0x3b74,0x0000,0x08,0x12,0x00,0x00,0x00,0x3a},
- {0x7a,0x2a1d,0x0410,0x3b52,0x0000,0x08,0x10,0x00,0x00,0x07,0x34},
- {0x7b,0x0e3b,0x060f,0x3ad0,0x0000,0x08,0x0f,0x00,0x00,0x00,0x1d},
- {0x7c,0x0e7d,0x060f,0x3ad0,0x0000,0x08,0x0f,0x00,0x00,0x00,0x1d},
- {0x7d,0x0eff,0x060f,0x3ad0,0x0000,0x08,0x0f,0x00,0x00,0x00,0x1d},
- {0x20,0x0e3b,0x0D16,0x49e0,0x0000,0x08,0x16,0x00,0x00,0x00,0x43},
- {0x21,0x0e7d,0x0D16,0x49e0,0x0000,0x08,0x16,0x00,0x00,0x00,0x43},
- {0x22,0x0eff,0x0D16,0x49e0,0x0000,0x08,0x16,0x00,0x00,0x00,0x43},
- {0x23,0x0e3b,0x0614,0x49d5,0x0000,0x08,0x14,0x00,0x00,0x00,0x41},
- {0x24,0x0e7d,0x0614,0x49d5,0x0000,0x08,0x14,0x00,0x00,0x00,0x41},
- {0x25,0x0eff,0x0614,0x49d5,0x0000,0x08,0x14,0x00,0x00,0x00,0x41},
- {0x26,0x063b,0x0c15,0x49dc,0x0000,0x08,0x15,0x00,0x00,0x00,0x42},     /* ModeIdIndex = 0x40 */
- {0x27,0x067d,0x0c15,0x49dc,0x0000,0x08,0x15,0x00,0x00,0x00,0x42},
- {0x28,0x06ff,0x0c15,0x49dc,0x0000,0x08,0x15,0x00,0x00,0x00,0x42},
- {0xff,0x0000,0x0000,0x0000,0x0000,0x00,0x00,0x00,0x00,0x00,0x00}
-};
-
-static struct XGI_StandTableStruct XGI330_StandTable[] =
-{
+static struct XGI_StStruct XGI330_SModeIDTable[] = {
+       {0x01, 0x9208, 0x01, 0x00, 0x10, 0x00, 0x00, 0x01, 0x00},
+       {0x01, 0x1210, 0x14, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00},
+       {0x01, 0x1010, 0x17, 0x02, 0x11, 0x00, 0x00, 0x01, 0x01},
+       {0x03, 0x8208, 0x03, 0x00, 0x14, 0x00, 0x00, 0x01, 0x02},
+       {0x03, 0x0210, 0x16, 0x01, 0x04, 0x01, 0x00, 0x01, 0x02},
+       {0x03, 0x0010, 0x18, 0x02, 0x15, 0x00, 0x00, 0x01, 0x03},
+       {0x05, 0x9209, 0x05, 0x00, 0x10, 0x00, 0x00, 0x00, 0x04},
+       {0x06, 0x8209, 0x06, 0x00, 0x14, 0x00, 0x00, 0x00, 0x05},
+       {0x07, 0x0000, 0x07, 0x03, 0x05, 0x03, 0x00, 0x01, 0x03},
+       {0x07, 0x0000, 0x19, 0x02, 0x15, 0x02, 0x00, 0x01, 0x03},
+       {0x0d, 0x920a, 0x0d, 0x00, 0x10, 0x00, 0x00, 0x00, 0x04},
+       {0x0e, 0x820a, 0x0e, 0x00, 0x14, 0x00, 0x00, 0x00, 0x05},
+       {0x0f, 0x0202, 0x11, 0x01, 0x04, 0x01, 0x00, 0x00, 0x05},
+       {0x10, 0x0212, 0x12, 0x01, 0x04, 0x01, 0x00, 0x00, 0x05},
+       {0x11, 0x0212, 0x1a, 0x04, 0x24, 0x04, 0x00, 0x00, 0x05},
+       {0x12, 0x0212, 0x1b, 0x04, 0x24, 0x04, 0x00, 0x00, 0x05},
+       {0x13, 0x021b, 0x1c, 0x00, 0x14, 0x00, 0x00, 0x00, 0x04},
+       {0x12, 0x0010, 0x18, 0x02, 0x24, 0x02, 0x00, 0x00, 0x05},/* St_CRT2CRTC2
+                                                                   not sure */
+       {0x12, 0x0210, 0x18, 0x01, 0x24, 0x01, 0x00, 0x00, 0x05},/* St_CRT2CRTC2
+                                                                   not sure */
+       {0xff, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
+};
+
+
+static struct XGI_ExtStruct XGI330_EModeIDTable[] = {
+       {0x6a, 0x2212, 0x0407, 0x3a81, 0x0102, 0x08,
+               0x07, 0x00, 0x00, 0x07, 0x0e},
+       {0x2e, 0x0a1b, 0x0306, 0x3a57, 0x0101, 0x08,
+               0x06, 0x00, 0x00, 0x05, 0x06},
+       {0x2f, 0x0a1b, 0x0305, 0x3a50, 0x0100, 0x08,
+               0x05, 0x00, 0x00, 0x05, 0x05},
+       {0x30, 0x2a1b, 0x0407, 0x3a81, 0x0103, 0x08,
+               0x07, 0x00, 0x00, 0x07, 0x0e},
+       {0x31, 0x0a1b, 0x030d, 0x3b85, 0x0000, 0x08,
+               0x0d, 0x00, 0x00, 0x06, 0x3d},
+       {0x32, 0x0a1b, 0x0a0e, 0x3b8c, 0x0000, 0x08,
+               0x0e, 0x00, 0x00, 0x06, 0x3e},
+       {0x33, 0x0a1d, 0x0a0d, 0x3b85, 0x0000, 0x08,
+               0x0d, 0x00, 0x00, 0x06, 0x3d},
+       {0x34, 0x2a1d, 0x0a0e, 0x3b8c, 0x0000, 0x08,
+               0x0e, 0x00, 0x00, 0x06, 0x3e},
+       {0x35, 0x0a1f, 0x0a0d, 0x3b85, 0x0000, 0x08,
+               0x0d, 0x00, 0x00, 0x06, 0x3d},
+       {0x36, 0x2a1f, 0x0a0e, 0x3b8c, 0x0000, 0x08,
+               0x0e, 0x00, 0x00, 0x06, 0x3e},
+       {0x37, 0x0212, 0x0508, 0x3aab, 0x0104, 0x08,
+               0x08, 0x00, 0x00, 0x00, 0x16},
+       {0x38, 0x0a1b, 0x0508, 0x3aab, 0x0105, 0x08,
+               0x08, 0x00, 0x00, 0x00, 0x16},
+       {0x3a, 0x0e3b, 0x0609, 0x3adc, 0x0107, 0x08,
+               0x09, 0x00, 0x00, 0x00, 0x1e},
+       {0x3c, 0x0e3b, 0x070a, 0x3af2, 0x0130, 0x08,
+               0x0a, 0x00, 0x00, 0x00, 0x22},  /* mode 1600x1200
+                                                  add CRT2MODE [2003/10/07] */
+       {0x3d, 0x0e7d, 0x070a, 0x3af2, 0x0131, 0x08,
+               0x0a, 0x00, 0x00, 0x00, 0x22},  /* mode 1600x1200
+                                                  add CRT2MODE */
+       {0x40, 0x9a1c, 0x0000, 0x3a34, 0x010d, 0x08,
+               0x00, 0x00, 0x00, 0x04, 0x00},
+       {0x41, 0x9a1d, 0x0000, 0x3a34, 0x010e, 0x08,
+               0x00, 0x00, 0x00, 0x04, 0x00},  /* ModeIdIndex = 0x10 */
+       {0x43, 0x0a1c, 0x0306, 0x3a57, 0x0110, 0x08,
+               0x06, 0x00, 0x00, 0x05, 0x06},
+       {0x44, 0x0a1d, 0x0306, 0x3a57, 0x0111, 0x08,
+               0x06, 0x00, 0x00, 0x05, 0x06},
+       {0x46, 0x2a1c, 0x0407, 0x3a81, 0x0113, 0x08,
+               0x07, 0x00, 0x00, 0x07, 0x0e},
+       {0x47, 0x2a1d, 0x0407, 0x3a81, 0x0114, 0x08,
+               0x07, 0x00, 0x00, 0x07, 0x0e},
+       {0x49, 0x0a3c, 0x0508, 0x3aab, 0x0116, 0x08,
+               0x08, 0x00, 0x00, 0x00, 0x16},
+       {0x4a, 0x0a3d, 0x0508, 0x3aab, 0x0117, 0x08,
+               0x08, 0x00, 0x00, 0x00, 0x16},
+       {0x4c, 0x0e7c, 0x0609, 0x3adc, 0x0119, 0x08,
+               0x09, 0x00, 0x00, 0x00, 0x1e},
+       {0x4d, 0x0e7d, 0x0609, 0x3adc, 0x011a, 0x08,
+               0x09, 0x00, 0x00, 0x00, 0x1e},
+       {0x50, 0x9a1b, 0x0001, 0x3a3b, 0x0132, 0x08,
+               0x01, 0x00, 0x00, 0x04, 0x02},
+       {0x51, 0xba1b, 0x0103, 0x3a42, 0x0133, 0x08,
+               0x03, 0x00, 0x00, 0x07, 0x03},
+       {0x52, 0x9a1b, 0x0204, 0x3a49, 0x0134, 0x08,
+               0x04, 0x00, 0x00, 0x00, 0x04},
+       {0x56, 0x9a1d, 0x0001, 0x3a3b, 0x0135, 0x08,
+               0x01, 0x00, 0x00, 0x04, 0x02},
+       {0x57, 0xba1d, 0x0103, 0x3a42, 0x0136, 0x08,
+               0x03, 0x00, 0x00, 0x07, 0x03},
+       {0x58, 0x9a1d, 0x0204, 0x3a49, 0x0137, 0x08,
+               0x04, 0x00, 0x00, 0x00, 0x04},
+       {0x59, 0x9a1b, 0x0000, 0x3a34, 0x0138, 0x08,
+               0x00, 0x00, 0x00, 0x04, 0x00},
+       {0x5A, 0x021b, 0x0014, 0x3b83, 0x0138, 0x08,
+               0x01, 0x00, 0x00, 0x04, 0x3f},  /* ModeIdIndex = 0x20 */
+       {0x5B, 0x0a1d, 0x0014, 0x3b83, 0x0135, 0x08,
+               0x01, 0x00, 0x00, 0x04, 0x3f},
+       {0x5d, 0x0a1d, 0x0305, 0x3a50, 0x0139, 0x08,
+               0x05, 0x00, 0x00, 0x07, 0x05},
+       {0x62, 0x0a3f, 0x0306, 0x3a57, 0x013a, 0x08,
+               0x06, 0x00, 0x00, 0x05, 0x06},
+       {0x63, 0x2a3f, 0x0407, 0x3a81, 0x013b, 0x08,
+               0x07, 0x00, 0x00, 0x07, 0x0e},
+       {0x64, 0x0a7f, 0x0508, 0x3aab, 0x013c, 0x08,
+               0x08, 0x00, 0x00, 0x00, 0x16},
+       {0x65, 0x0eff, 0x0609, 0x3adc, 0x013d, 0x08,
+               0x09, 0x00, 0x00, 0x00, 0x1e},
+       {0x66, 0x0eff, 0x070a, 0x3af2, 0x013e, 0x08,
+               0x0a, 0x00, 0x00, 0x00, 0x22},  /* mode 1600x1200
+                                                  add CRT2MODE */
+       {0x68, 0x067b, 0x080b, 0x3b17, 0x013f, 0x08,
+               0x0b, 0x00, 0x00, 0x00, 0x29},
+       {0x69, 0x06fd, 0x080b, 0x3b17, 0x0140, 0x08,
+               0x0b, 0x00, 0x00, 0x00, 0x29},
+       {0x6b, 0x07ff, 0x080b, 0x3b17, 0x0141, 0x10,
+               0x0b, 0x00, 0x00, 0x00, 0x29},
+       {0x6c, 0x067b, 0x090c, 0x3b37, 0x0000, 0x08,
+               0x0c, 0x00, 0x00, 0x00, 0x2f},
+       {0x6d, 0x06fd, 0x090c, 0x3b37, 0x0000, 0x10,
+               0x0c, 0x00, 0x00, 0x00, 0x2f},
+       {0x6e, 0x07ff, 0x090c, 0x3b37, 0x0000, 0x10,
+               0x0c, 0x00, 0x00, 0x00, 0x2f},
+       {0x70, 0x2a1b, 0x0410, 0x3b52, 0x0000, 0x08,
+               0x10, 0x00, 0x00, 0x07, 0x34},
+       {0x71, 0x0a1b, 0x0511, 0x3b63, 0x0000, 0x08,
+               0x11, 0x00, 0x00, 0x00, 0x37},
+       {0x74, 0x0a1d, 0x0511, 0x3b63, 0x0000, 0x08,
+               0x11, 0x00, 0x00, 0x00, 0x37},  /* ModeIdIndex = 0x30 */
+       {0x75, 0x0a3d, 0x0612, 0x3b74, 0x0000, 0x08,
+               0x12, 0x00, 0x00, 0x00, 0x3a},
+       {0x76, 0x2a1f, 0x0410, 0x3b52, 0x0000, 0x08,
+               0x10, 0x00, 0x00, 0x07, 0x34},
+       {0x77, 0x0a1f, 0x0511, 0x3b63, 0x0000, 0x08,
+               0x11, 0x00, 0x00, 0x00, 0x37},
+       {0x78, 0x0a3f, 0x0612, 0x3b74, 0x0000, 0x08,
+               0x12, 0x00, 0x00, 0x00, 0x3a},
+       {0x79, 0x0a3b, 0x0612, 0x3b74, 0x0000, 0x08,
+               0x12, 0x00, 0x00, 0x00, 0x3a},
+       {0x7a, 0x2a1d, 0x0410, 0x3b52, 0x0000, 0x08,
+               0x10, 0x00, 0x00, 0x07, 0x34},
+       {0x7b, 0x0e3b, 0x060f, 0x3ad0, 0x0000, 0x08,
+               0x0f, 0x00, 0x00, 0x00, 0x1d},
+       {0x7c, 0x0e7d, 0x060f, 0x3ad0, 0x0000, 0x08,
+               0x0f, 0x00, 0x00, 0x00, 0x1d},
+       {0x7d, 0x0eff, 0x060f, 0x3ad0, 0x0000, 0x08,
+               0x0f, 0x00, 0x00, 0x00, 0x1d},
+       {0x20, 0x0e3b, 0x0D16, 0x49e0, 0x0000, 0x08,
+               0x16, 0x00, 0x00, 0x00, 0x43},
+       {0x21, 0x0e7d, 0x0D16, 0x49e0, 0x0000, 0x08,
+               0x16, 0x00, 0x00, 0x00, 0x43},
+       {0x22, 0x0eff, 0x0D16, 0x49e0, 0x0000, 0x08,
+               0x16, 0x00, 0x00, 0x00, 0x43},
+       {0x23, 0x0e3b, 0x0614, 0x49d5, 0x0000, 0x08,
+               0x14, 0x00, 0x00, 0x00, 0x41},
+       {0x24, 0x0e7d, 0x0614, 0x49d5, 0x0000, 0x08,
+               0x14, 0x00, 0x00, 0x00, 0x41},
+       {0x25, 0x0eff, 0x0614, 0x49d5, 0x0000, 0x08,
+               0x14, 0x00, 0x00, 0x00, 0x41},
+       {0x26, 0x063b, 0x0c15, 0x49dc, 0x0000, 0x08,
+               0x15, 0x00, 0x00, 0x00, 0x42},  /* ModeIdIndex = 0x40 */
+       {0x27, 0x067d, 0x0c15, 0x49dc, 0x0000, 0x08,
+               0x15, 0x00, 0x00, 0x00, 0x42},
+       {0x28, 0x06ff, 0x0c15, 0x49dc, 0x0000, 0x08,
+               0x15, 0x00, 0x00, 0x00, 0x42},
+       {0xff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00,
+               0x00, 0x00, 0x00, 0x00, 0x00}
+};
+
+static struct XGI_StandTableStruct XGI330_StandTable[] = {
 /* MD_0_200 */
- {
-  0x28,0x18,0x08,0x0800,
-  {0x09,0x03,0x00,0x02},
-  0x63,
-  {0x2d,0x27,0x28,0x90,0x2b,0xa0,0xbf,0x1f,
-   0x00,0xc7,0x06,0x07,0x00,0x00,0x00,0x00,
-   0x9c,0x8e,0x8f,0x14,0x1f,0x96,0xb9,0xa3,
-   0xff},
-  {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
-   0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
-   0x08,0x00,0x0f,0x00},
-  {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
-   0xff}
- },
      {
+               0x28, 0x18, 0x08, 0x0800,
+               {0x09, 0x03, 0x00, 0x02},
+               0x63,
+               {0x2d, 0x27, 0x28, 0x90, 0x2b, 0xa0, 0xbf, 0x1f,
+                0x00, 0xc7, 0x06, 0x07, 0x00, 0x00, 0x00, 0x00,
+                0x9c, 0x8e, 0x8f, 0x14, 0x1f, 0x96, 0xb9, 0xa3,
+                0xff},
+               {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+                0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+                0x08, 0x00, 0x0f, 0x00},
+               {0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x00,
+                0xff}
      },
 /* MD_1_200 */
- {
-  0x28,0x18,0x08,0x0800,
-  {0x09,0x03,0x00,0x02},
-  0x63,
-  {0x2d,0x27,0x28,0x90,0x2b,0xa0,0xbf,0x1f,
-   0x00,0xc7,0x06,0x07,0x00,0x00,0x00,0x00,
-   0x9c,0x8e,0x8f,0x14,0x1f,0x96,0xb9,0xa3,
-   0xff},
-  {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
-   0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
-   0x08,0x00,0x0f,0x00},
-  {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
-   0xff}
- },
      {
+               0x28, 0x18, 0x08, 0x0800,
+               {0x09, 0x03, 0x00, 0x02},
+               0x63,
+               {0x2d, 0x27, 0x28, 0x90, 0x2b, 0xa0, 0xbf, 0x1f,
+                0x00, 0xc7, 0x06, 0x07, 0x00, 0x00, 0x00, 0x00,
+                0x9c, 0x8e, 0x8f, 0x14, 0x1f, 0x96, 0xb9, 0xa3,
+                0xff},
+               {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+                0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+                0x08, 0x00, 0x0f, 0x00},
+               {0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x00,
+                0xff}
      },
 /* MD_2_200 */
- {
-  0x50,0x18,0x08,0x1000,
-  {0x01,0x03,0x00,0x02},
-  0x63,
-  {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,
-   0x00,0xc7,0x06,0x07,0x00,0x00,0x00,0x00,
-   0x9c,0x8e,0x8f,0x28,0x1f,0x96,0xb9,0xa3,
-   0xff},
-  {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
-   0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
-   0x08,0x00,0x0f,0x00},
-  {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
-   0xff}
- },
      {
+               0x50, 0x18, 0x08, 0x1000,
+               {0x01, 0x03, 0x00, 0x02},
+                0x63,
+               {0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f,
+                0x00, 0xc7, 0x06, 0x07, 0x00, 0x00, 0x00, 0x00,
+                0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, 0xb9, 0xa3,
+                0xff},
+               {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+                0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+                0x08, 0x00, 0x0f, 0x00},
+               {0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x00,
+                0xff}
      },
 /* MD_3_200 */
- {
-  0x50,0x18,0x08,0x1000,
-  {0x01,0x03,0x00,0x02},
-  0x63,
-  {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,
-   0x00,0xc7,0x06,0x07,0x00,0x00,0x00,0x00,
-   0x9c,0x8e,0x8f,0x28,0x1f,0x96,0xb9,0xa3,
-   0xff},
-  {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
-   0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
-   0x08,0x00,0x0f,0x00},
-  {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
-   0xff}
- },
      {
+               0x50, 0x18, 0x08, 0x1000,
+               {0x01, 0x03, 0x00, 0x02},
+                0x63,
+               {0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f,
+                0x00, 0xc7, 0x06, 0x07, 0x00, 0x00, 0x00, 0x00,
+                0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, 0xb9, 0xa3,
+                0xff},
+               {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+                0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+                0x08, 0x00, 0x0f, 0x00},
+               {0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x00,
+                0xff}
      },
 /* MD_4 */
- {
-  0x28,0x18,0x08,0x4000,
-  {0x09,0x03,0x00,0x02},
-  0x63,
-  {0x2d,0x27,0x28,0x90,0x2c,0x80,0xbf,0x1f,
-   0x00,0xc1,0x00,0x00,0x00,0x00,0x00,0x00,
-   0x9c,0x8e,0x8f,0x14,0x00,0x96,0xb9,0xa2,
-   0xff},
-  {0x00,0x13,0x15,0x17,0x02,0x04,0x06,0x07,
-   0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
-   0x01,0x00,0x03,0x00},
-  {0x00,0x00,0x00,0x00,0x00,0x30,0x0f,0x00,
-   0xff}
- },
      {
+               0x28, 0x18, 0x08, 0x4000,
+               {0x09, 0x03, 0x00, 0x02},
+                0x63,
+               {0x2d, 0x27, 0x28, 0x90, 0x2c, 0x80, 0xbf, 0x1f,
+                0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2,
+                0xff},
+               {0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07,
+                0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+                0x01, 0x00, 0x03, 0x00},
+               {0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x00,
+                0xff}
      },
 /* MD_5 */
- {
-  0x28,0x18,0x08,0x4000,
-  {0x09,0x03,0x00,0x02},
-  0x63,
-  {0x2d,0x27,0x28,0x90,0x2c,0x80,0xbf,0x1f,
-   0x00,0xc1,0x00,0x00,0x00,0x00,0x00,0x00,
-   0x9c,0x8e,0x8f,0x14,0x00,0x96,0xb9,0xa2,
-   0xff},
-  {0x00,0x13,0x15,0x17,0x02,0x04,0x06,0x07,
-   0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
-   0x01,0x00,0x03,0x00},
-  {0x00,0x00,0x00,0x00,0x00,0x30,0x0f,0x00,
-   0xff}
- },
      {
+               0x28, 0x18, 0x08, 0x4000,
+               {0x09, 0x03, 0x00, 0x02},
+                0x63,
+               {0x2d, 0x27, 0x28, 0x90, 0x2c, 0x80, 0xbf, 0x1f,
+                0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2,
+                0xff},
+               {0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07,
+                0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+                0x01, 0x00, 0x03, 0x00},
+               {0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x00,
+                0xff}
      },
 /* MD_6 */
- {
-  0x50,0x18,0x08,0x4000,
-  {0x01,0x01,0x00,0x06},
-  0x63,
-  {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,
-   0x00,0xc1,0x00,0x00,0x00,0x00,0x00,0x00,
-   0x9c,0x8e,0x8f,0x28,0x00,0x96,0xb9,0xc2,
-   0xff},
-  {0x00,0x17,0x17,0x17,0x17,0x17,0x17,0x17,
-   0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,
-   0x01,0x00,0x01,0x00},
-  {0x00,0x00,0x00,0x00,0x00,0x00,0x0d,0x00,
-   0xff}
- },
      {
+               0x50, 0x18, 0x08, 0x4000,
+               {0x01, 0x01, 0x00, 0x06},
+                0x63,
+               {0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f,
+                0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xc2,
+                0xff},
+               {0x00, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17,
+                0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17,
+                0x01, 0x00, 0x01, 0x00},
+               {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x00,
+                0xff}
      },
 /* MD_7 */
- {
-  0x50,0x18,0x0e,0x1000,
-  {0x00,0x03,0x00,0x03},
-  0xa6,
-  {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,
-   0x00,0x4d,0x0b,0x0c,0x00,0x00,0x00,0x00,
-   0x83,0x85,0x5d,0x28,0x0d,0x63,0xba,0xa3,
-   0xff},
-  {0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
-   0x10,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
-   0x0e,0x00,0x0f,0x08},
-  {0x00,0x00,0x00,0x00,0x00,0x10,0x0a,0x00,
-   0xff}
- },
      {
+               0x50, 0x18, 0x0e, 0x1000,
+               {0x00, 0x03, 0x00, 0x03},
+                0xa6,
+               {0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f,
+                0x00, 0x4d, 0x0b, 0x0c, 0x00, 0x00, 0x00, 0x00,
+                0x83, 0x85, 0x5d, 0x28, 0x0d, 0x63, 0xba, 0xa3,
+                0xff},
+               {0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
+                0x10, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
+                0x0e, 0x00, 0x0f, 0x08},
+               {0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0a, 0x00,
+                0xff}
      },
 /* MDA_DAC */
- {
-  0x00,0x00,0x00,0x0000,
-  {0x00,0x00,0x00,0x15},
-  0x15,
-  {0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,
-   0x15,0x15,0x15,0x15,0x15,0x15,0x3f,0x3f,
-   0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x00,0x00,
-   0x00},
-  {0x00,0x00,0x00,0x00,0x00,0x15,0x15,0x15,
-   0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,
-   0x15,0x15,0x15,0x15},
-  {0x15,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,
-   0x3f}
- },
      {
+               0x00, 0x00, 0x00, 0x0000,
+               {0x00, 0x00, 0x00, 0x15},
+                0x15,
+               {0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
+                0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x3f, 0x3f,
+                0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x00, 0x00,
+                0x00},
+               {0x00, 0x00, 0x00, 0x00, 0x00, 0x15, 0x15, 0x15,
+                0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
+                0x15, 0x15, 0x15, 0x15},
+               {0x15, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f,
+                0x3f}
      },
 /* CGA_DAC */
- {
-  0x00,0x10,0x04,0x0114,
-  {0x11,0x09,0x15,0x00},
-  0x10,
-  {0x04,0x14,0x01,0x11,0x09,0x15,0x2a,0x3a,
-   0x2e,0x3e,0x2b,0x3b,0x2f,0x3f,0x2a,0x3a,
-   0x2e,0x3e,0x2b,0x3b,0x2f,0x3f,0x00,0x10,
-   0x04},
-  {0x14,0x01,0x11,0x09,0x15,0x00,0x10,0x04,
-   0x14,0x01,0x11,0x09,0x15,0x2a,0x3a,0x2e,
-   0x3e,0x2b,0x3b,0x2f},
-  {0x3f,0x2a,0x3a,0x2e,0x3e,0x2b,0x3b,0x2f,
-   0x3f}
- },
      {
+               0x00, 0x10, 0x04, 0x0114,
+               {0x11, 0x09, 0x15, 0x00},
+                0x10,
+               {0x04, 0x14, 0x01, 0x11, 0x09, 0x15, 0x2a, 0x3a,
+                0x2e, 0x3e, 0x2b, 0x3b, 0x2f, 0x3f, 0x2a, 0x3a,
+                0x2e, 0x3e, 0x2b, 0x3b, 0x2f, 0x3f, 0x00, 0x10,
+                0x04},
+               {0x14, 0x01, 0x11, 0x09, 0x15, 0x00, 0x10, 0x04,
+                0x14, 0x01, 0x11, 0x09, 0x15, 0x2a, 0x3a, 0x2e,
+                0x3e, 0x2b, 0x3b, 0x2f},
+               {0x3f, 0x2a, 0x3a, 0x2e, 0x3e, 0x2b, 0x3b, 0x2f,
+                0x3f}
      },
 /* EGA_DAC */
- {
-  0x00,0x10,0x04,0x0114,
-  {0x11,0x05,0x15,0x20},
-  0x30,
-  {0x24,0x34,0x21,0x31,0x25,0x35,0x08,0x18,
-   0x0c,0x1c,0x09,0x19,0x0d,0x1d,0x28,0x38,
-   0x2c,0x3c,0x29,0x39,0x2d,0x3d,0x02,0x12,
-   0x06},
-  {0x16,0x03,0x13,0x07,0x17,0x22,0x32,0x26,
-   0x36,0x23,0x33,0x27,0x37,0x0a,0x1a,0x0e,
-   0x1e,0x0b,0x1b,0x0f},
-  {0x1f,0x2a,0x3a,0x2e,0x3e,0x2b,0x3b,0x2f,
-   0x3f}
- },
      {
+               0x00, 0x10, 0x04, 0x0114,
+               {0x11, 0x05, 0x15, 0x20},
+                0x30,
+               {0x24, 0x34, 0x21, 0x31, 0x25, 0x35, 0x08, 0x18,
+                0x0c, 0x1c, 0x09, 0x19, 0x0d, 0x1d, 0x28, 0x38,
+                0x2c, 0x3c, 0x29, 0x39, 0x2d, 0x3d, 0x02, 0x12,
+                0x06},
+               {0x16, 0x03, 0x13, 0x07, 0x17, 0x22, 0x32, 0x26,
+                0x36, 0x23, 0x33, 0x27, 0x37, 0x0a, 0x1a, 0x0e,
+                0x1e, 0x0b, 0x1b, 0x0f},
+               {0x1f, 0x2a, 0x3a, 0x2e, 0x3e, 0x2b, 0x3b, 0x2f,
+                0x3f}
      },
 /* VGA_DAC */
- {
-  0x00,0x10,0x04,0x0114,
-  {0x11,0x09,0x15,0x2a},
-  0x3a,
-  {0x2e,0x3e,0x2b,0x3b,0x2f,0x3f,0x00,0x05,
-   0x08,0x0b,0x0e,0x11,0x14,0x18,0x1c,0x20,
-   0x24,0x28,0x2d,0x32,0x38,0x3f,0x00,0x10,
-   0x1f},
-  {0x2f,0x3f,0x1f,0x27,0x2f,0x37,0x3f,0x2d,
-   0x31,0x36,0x3a,0x3f,0x00,0x07,0x0e,0x15,
-   0x1c,0x0e,0x11,0x15},
-  {0x18,0x1c,0x14,0x16,0x18,0x1a,0x1c,0x00,
-   0x04}
- },
- {
-  0x08,0x0c,0x10,0x0a08,
-  {0x0c,0x0e,0x10,0x0b},
-  0x0c,
-  {0x0d,0x0f,0x10,0x10,0x01,0x08,0x00,0x00,
-   0x00,0x00,0x01,0x00,0x02,0x02,0x01,0x00,
-   0x04,0x04,0x01,0x00,0x05,0x02,0x05,0x00,
-   0x06},
-  {0x01,0x06,0x05,0x06,0x00,0x08,0x01,0x08,
-   0x00,0x07,0x02,0x07,0x06,0x07,0x00,0x00,
-   0x00,0x00,0x00,0x00},
-  {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-   0x00}
- },
      {
+               0x00, 0x10, 0x04, 0x0114,
+               {0x11, 0x09, 0x15, 0x2a},
+                0x3a,
+               {0x2e, 0x3e, 0x2b, 0x3b, 0x2f, 0x3f, 0x00, 0x05,
+                0x08, 0x0b, 0x0e, 0x11, 0x14, 0x18, 0x1c, 0x20,
+                0x24, 0x28, 0x2d, 0x32, 0x38, 0x3f, 0x00, 0x10,
+                0x1f},
+               {0x2f, 0x3f, 0x1f, 0x27, 0x2f, 0x37, 0x3f, 0x2d,
+                0x31, 0x36, 0x3a, 0x3f, 0x00, 0x07, 0x0e, 0x15,
+                0x1c, 0x0e, 0x11, 0x15},
+               {0x18, 0x1c, 0x14, 0x16, 0x18, 0x1a, 0x1c, 0x00,
+                0x04}
      },
      {
+               0x08, 0x0c, 0x10, 0x0a08,
+               {0x0c, 0x0e, 0x10, 0x0b},
+                0x0c,
+               {0x0d, 0x0f, 0x10, 0x10, 0x01, 0x08, 0x00, 0x00,
+                0x00, 0x00, 0x01, 0x00, 0x02, 0x02, 0x01, 0x00,
+                0x04, 0x04, 0x01, 0x00, 0x05, 0x02, 0x05, 0x00,
+                0x06},
+               {0x01, 0x06, 0x05, 0x06, 0x00, 0x08, 0x01, 0x08,
+                0x00, 0x07, 0x02, 0x07, 0x06, 0x07, 0x00, 0x00,
+                0x00, 0x00, 0x00, 0x00},
+               {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x00}
      },
 /* MD_D */
- {
-  0x28,0x18,0x08,0x2000,
-  {0x09,0x0f,0x00,0x06},
-  0x63,
-  {0x2d,0x27,0x28,0x90,0x2c,0x80,0xbf,0x1f,
-   0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,
-   0x9c,0x8e,0x8f,0x14,0x00,0x96,0xb9,0xe3,
-   0xff},
-  {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
-   0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
-   0x01,0x00,0x0f,0x00},
-  {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x0f,
-   0xff}
- },
      {
+               0x28, 0x18, 0x08, 0x2000,
+               {0x09, 0x0f, 0x00, 0x06},
+                0x63,
+               {0x2d, 0x27, 0x28, 0x90, 0x2c, 0x80, 0xbf, 0x1f,
+                0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xe3,
+                0xff},
+               {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+                0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+                0x01, 0x00, 0x0f, 0x00},
+               {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f,
+                0xff}
      },
 /* MD_E */
- {
-  0x50,0x18,0x08,0x4000,
-  {0x01,0x0f,0x00,0x06},
-  0x63,
-  {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,
-   0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,
-   0x9c,0x8e,0x8f,0x28,0x00,0x96,0xb9,0xe3,
-   0xff},
-  {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
-   0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
-   0x01,0x00,0x0f,0x00},
-  {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x0f,
-   0xff}
- },
      {
+               0x50, 0x18, 0x08, 0x4000,
+               {0x01, 0x0f, 0x00, 0x06},
+                0x63,
+               {0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f,
+                0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xe3,
+                0xff},
+               {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+                0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+                0x01, 0x00, 0x0f, 0x00},
+               {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f,
+                0xff}
      },
 /* ExtVGATable */
- {
-  0x00,0x00,0x00,0x0000,
-  {0x01,0x0f,0x00,0x0e},
-  0x23,
-  {0x5f,0x4f,0x50,0x82,0x54,0x80,0x0b,0x3e,
-   0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,
-   0xea,0x8c,0xdf,0x28,0x40,0xe7,0x04,0xa3,
-   0xff},
-  {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
-   0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
-   0x01,0x00,0x00,0x00},
-  {0x00,0x00,0x00,0x00,0x00,0x40,0x05,0x0f,
-   0xff}
- },
      {
+               0x00, 0x00, 0x00, 0x0000,
+               {0x01, 0x0f, 0x00, 0x0e},
+                0x23,
+               {0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0x0b, 0x3e,
+                0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0xea, 0x8c, 0xdf, 0x28, 0x40, 0xe7, 0x04, 0xa3,
+                0xff},
+               {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+                0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+                0x01, 0x00, 0x00, 0x00},
+               {0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0f,
+                0xff}
      },
 /* ROM_SAVEPTR */
- {
-  0x9f,0x3b,0x00,0x00c0,
-  {0x00,0x00,0x00,0x00},
-  0x00,
-  {0x00,0x00,0x00,0x00,0x00,0x00,0xbb,0x3f,
-   0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,
-   0x00,0x00,0x1a,0x00,0xac,0x3e,0x00,0xc0,
-   0x00},
-  {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-   0x00,0x00,0x00,0x00},
-  {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-   0x00}
- },
      {
+               0x9f, 0x3b, 0x00, 0x00c0,
+               {0x00, 0x00, 0x00, 0x00},
+                0x00,
+               {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xbb, 0x3f,
+                0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x00, 0x00, 0x1a, 0x00, 0xac, 0x3e, 0x00, 0xc0,
+                0x00},
+               {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x00, 0x00, 0x00, 0x00},
+               {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x00}
      },
 /* MD_F */
- {
-  0x50,0x18,0x0e,0x8000,
-  {0x01,0x0f,0x00,0x06},
-  0xa2,
-  {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,
-   0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,
-   0x82,0x84,0x5d,0x28,0x0f,0x63,0xba,0xe3,
-   0xff},
-  {0x00,0x08,0x00,0x00,0x18,0x18,0x00,0x00,
-   0x00,0x08,0x00,0x00,0x00,0x18,0x00,0x00,
-   0x0b,0x00,0x05,0x00},
-  {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x05,
-   0xff}
- },
      {
+               0x50, 0x18, 0x0e, 0x8000,
+               {0x01, 0x0f, 0x00, 0x06},
+                0xa2,
+               {0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f,
+                0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x82, 0x84, 0x5d, 0x28, 0x0f, 0x63, 0xba, 0xe3,
+                0xff},
+               {0x00, 0x08, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00,
+                0x00, 0x08, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00,
+                0x0b, 0x00, 0x05, 0x00},
+               {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x05,
+                0xff}
      },
 /* MD_10 */
- {
-  0x50,0x18,0x0e,0x8000,
-  {0x01,0x0f,0x00,0x06},
-  0xa3,
-  {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,
-   0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,
-   0x82,0x84,0x5d,0x28,0x0f,0x63,0xba,0xe3,
-   0xff},
-  {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07,
-   0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
-   0x01,0x00,0x0f,0x00},
-  {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x0f,
-   0xff}
- },
      {
+               0x50, 0x18, 0x0e, 0x8000,
+               {0x01, 0x0f, 0x00, 0x06},
+                0xa3,
+               {0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f,
+                0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x82, 0x84, 0x5d, 0x28, 0x0f, 0x63, 0xba, 0xe3,
+                0xff},
+               {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07,
+                0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
+                0x01, 0x00, 0x0f, 0x00},
+               {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f,
+                0xff}
      },
 /* MD_0_350 */
- {
-  0x28,0x18,0x0e,0x0800,
-  {0x09,0x03,0x00,0x02},
-  0xa3,
-  {0x2d,0x27,0x28,0x90,0x2b,0xb1,0xbf,0x1f,
-   0x00,0x4d,0x0b,0x0c,0x00,0x00,0x00,0x00,
-   0x83,0x85,0x5d,0x14,0x1f,0x63,0xba,0xa3,
-   0xff},
-  {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07,
-   0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
-   0x08,0x00,0x0f,0x00},
-  {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
-   0xff}
- },
      {
+               0x28, 0x18, 0x0e, 0x0800,
+               {0x09, 0x03, 0x00, 0x02},
+                0xa3,
+               {0x2d, 0x27, 0x28, 0x90, 0x2b, 0xb1, 0xbf, 0x1f,
+                0x00, 0x4d, 0x0b, 0x0c, 0x00, 0x00, 0x00, 0x00,
+                0x83, 0x85, 0x5d, 0x14, 0x1f, 0x63, 0xba, 0xa3,
+                0xff},
+               {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07,
+                0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
+                0x08, 0x00, 0x0f, 0x00},
+               {0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x00,
+                0xff}
      },
 /* MD_1_350 */
- {
-  0x28,0x18,0x0e,0x0800,
-  {0x09,0x03,0x00,0x02},
-  0xa3,
-  {0x2d,0x27,0x28,0x90,0x2b,0xa0,0xbf,0x1f,
-   0x00,0x4d,0x0b,0x0c,0x00,0x00,0x00,0x00,
-   0x83,0x85,0x5d,0x14,0x1f,0x63,0xba,0xa3,
-   0xff},
-  {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07,
-   0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
-   0x08,0x00,0x0f,0x00},
-  {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
-   0xff}
- },
      {
+               0x28, 0x18, 0x0e, 0x0800,
+               {0x09, 0x03, 0x00, 0x02},
+                0xa3,
+               {0x2d, 0x27, 0x28, 0x90, 0x2b, 0xa0, 0xbf, 0x1f,
+                0x00, 0x4d, 0x0b, 0x0c, 0x00, 0x00, 0x00, 0x00,
+                0x83, 0x85, 0x5d, 0x14, 0x1f, 0x63, 0xba, 0xa3,
+                0xff},
+               {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07,
+                0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
+                0x08, 0x00, 0x0f, 0x00},
+               {0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x00,
+                0xff}
      },
 /* MD_2_350 */
- {
-  0x50,0x18,0x0e,0x1000,
-  {0x01,0x03,0x00,0x02},
-  0xa3,
-  {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,
-   0x00,0x4d,0x0b,0x0c,0x00,0x00,0x00,0x00,
-   0x83,0x85,0x5d,0x28,0x1f,0x63,0xba,0xa3,
-   0xff},
-  {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07,
-   0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
-   0x08,0x00,0x0f,0x00},
-  {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
-   0xff}
- },
      {
+               0x50, 0x18, 0x0e, 0x1000,
+               {0x01, 0x03, 0x00, 0x02},
+                0xa3,
+               {0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f,
+                0x00, 0x4d, 0x0b, 0x0c, 0x00, 0x00, 0x00, 0x00,
+                0x83, 0x85, 0x5d, 0x28, 0x1f, 0x63, 0xba, 0xa3,
+                0xff},
+               {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07,
+                0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
+                0x08, 0x00, 0x0f, 0x00},
+               {0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x00,
+                0xff}
      },
 /* MD_3_350 */
- {
-  0x50,0x18,0x0e,0x1000,
-  {0x01,0x03,0x00,0x02},
-  0xa3,
-  {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,
-   0x00,0x4d,0x0b,0x0c,0x00,0x00,0x00,0x00,
-   0x83,0x85,0x5d,0x28,0x1f,0x63,0xba,0xa3,
-   0xff},
-  {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07,
-   0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
-   0x08,0x00,0x0f,0x00},
-  {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
-   0xff}
- },
      {
+               0x50, 0x18, 0x0e, 0x1000,
+               {0x01, 0x03, 0x00, 0x02},
+                0xa3,
+               {0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f,
+                0x00, 0x4d, 0x0b, 0x0c, 0x00, 0x00, 0x00, 0x00,
+                0x83, 0x85, 0x5d, 0x28, 0x1f, 0x63, 0xba, 0xa3,
+                0xff},
+               {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07,
+                0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
+                0x08, 0x00, 0x0f, 0x00},
+               {0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x00,
+                0xff}
      },
 /* MD_0_1_400 */
- {
-  0x28,0x18,0x10,0x0800,
-  {0x08,0x03,0x00,0x02},
-  0x67,
-  {0x2d,0x27,0x28,0x90,0x2b,0xb1,0xbf,0x1f,
-   0x00,0x4f,0x0d,0x0e,0x00,0x00,0x00,0x00,
-   0x9c,0x8e,0x8f,0x14,0x1f,0x96,0xb9,0xa3,
-   0xff},
-  {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07,
-   0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
-   0x0c,0x00,0x0f,0x08},
-  {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
-   0xff}
- },
      {
+               0x28, 0x18, 0x10, 0x0800,
+               {0x08, 0x03, 0x00, 0x02},
+                0x67,
+               {0x2d, 0x27, 0x28, 0x90, 0x2b, 0xb1, 0xbf, 0x1f,
+                0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00,
+                0x9c, 0x8e, 0x8f, 0x14, 0x1f, 0x96, 0xb9, 0xa3,
+                0xff},
+               {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07,
+                0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
+                0x0c, 0x00, 0x0f, 0x08},
+               {0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x00,
+                0xff}
      },
 /* MD_2_3_400 */
- {
-  0x50,0x18,0x10,0x1000,
-  {0x00,0x03,0x00,0x02},
-  0x67,
-  {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,
-   0x00,0x4f,0x0d,0x0e,0x00,0x00,0x00,0x00,
-   0x9c,0x8e,0x8f,0x28,0x1f,0x96,0xb9,0xa3,
-   0xff},
-  {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07,
-   0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
-   0x0c,0x00,0x0f,0x08},
-  {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00,
-   0xff}
- },
      {
+               0x50, 0x18, 0x10, 0x1000,
+               {0x00, 0x03, 0x00, 0x02},
+                0x67,
+               {0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f,
+                0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00,
+                0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, 0xb9, 0xa3,
+                0xff},
+               {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07,
+                0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
+                0x0c, 0x00, 0x0f, 0x08},
+               {0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x00,
+                0xff}
      },
 /* MD_7_400 */
- {
-  0x50,0x18,0x10,0x1000,
-  {0x00,0x03,0x00,0x02},
-  0x66,
-  {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,
-   0x00,0x4f,0x0d,0x0e,0x00,0x00,0x00,0x00,
-   0x9c,0x8e,0x8f,0x28,0x0f,0x96,0xb9,0xa3,
-   0xff},
-  {0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
-   0x10,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
-   0x0e,0x00,0x0f,0x08},
-  {0x00,0x00,0x00,0x00,0x00,0x10,0x0a,0x00,
-   0xff}
- },
      {
+               0x50, 0x18, 0x10, 0x1000,
+               {0x00, 0x03, 0x00, 0x02},
+                0x66,
+               {0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f,
+                0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00,
+                0x9c, 0x8e, 0x8f, 0x28, 0x0f, 0x96, 0xb9, 0xa3,
+                0xff},
+               {0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
+                0x10, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
+                0x0e, 0x00, 0x0f, 0x08},
+               {0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0a, 0x00,
+                0xff}
      },
 /* MD_11 */
- {
-  0x50,0x1d,0x10,0xa000,
-  {0x01,0x0f,0x00,0x06},
-  0xe3,
-  {0x5f,0x4f,0x50,0x82,0x55,0x81,0x0b,0x3e,
-   0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,
-   0xe9,0x8b,0xdf,0x28,0x00,0xe7,0x04,0xc3,
-   0xff},
-  {0x00,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,
-   0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,
-   0x01,0x00,0x0f,0x00},
-  {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x01,
-   0xff}
- },
      {
+               0x50, 0x1d, 0x10, 0xa000,
+               {0x01, 0x0f, 0x00, 0x06},
+                0xe3,
+               {0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0x0b, 0x3e,
+                0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0xe9, 0x8b, 0xdf, 0x28, 0x00, 0xe7, 0x04, 0xc3,
+                0xff},
+               {0x00, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f,
+                0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f,
+                0x01, 0x00, 0x0f, 0x00},
+               {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x01,
+                0xff}
      },
 /* ExtEGATable */
- {
-  0x50,0x1d,0x10,0xa000,
-  {0x01,0x0f,0x00,0x06},
-  0xe3,
-  {0x5f,0x4f,0x50,0x82,0x55,0x81,0x0b,0x3e,
-   0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,
-   0xe9,0x8b,0xdf,0x28,0x00,0xe7,0x04,0xe3,
-   0xff},
-  {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07,
-   0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
-   0x01,0x00,0x0f,0x00},
-  {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x0f,
-   0xff}
- },
      {
+               0x50, 0x1d, 0x10, 0xa000,
+               {0x01, 0x0f, 0x00, 0x06},
+                0xe3,
+               {0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0x0b, 0x3e,
+                0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0xe9, 0x8b, 0xdf, 0x28, 0x00, 0xe7, 0x04, 0xe3,
+                0xff},
+               {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07,
+                0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
+                0x01, 0x00, 0x0f, 0x00},
+               {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f,
+                0xff}
      },
 /* MD_13 */
- {
-  0x28,0x18,0x08,0x2000,
-  {0x01,0x0f,0x00,0x0e},
-  0x63,
-  {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f,
-   0x00,0x41,0x00,0x00,0x00,0x00,0x00,0x00,
-   0x9c,0x8e,0x8f,0x28,0x40,0x96,0xb9,0xa3,
-   0xff},
-  {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
-   0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
-   0x41,0x00,0x0f,0x00},
-  {0x00,0x00,0x00,0x00,0x00,0x40,0x05,0x0f,
-   0xff}
- }
-};
-
-static struct XGI_TimingHStruct XGI_TimingH[] =
-{{{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}};
-
-static struct XGI_TimingVStruct XGI_TimingV[] =
-{{{0x00,0x00,0x00,0x00,0x00,0x00,0x00}}};
-
-static struct XGI_XG21CRT1Struct XGI_UpdateCRT1Table[] =
-{
- {0x01,0x27,0x91,0x8f,0xc0},   /* 00 */
- {0x03,0x4f,0x83,0x8f,0xc0},   /* 01 */
- {0x05,0x27,0x91,0x8f,0xc0},   /* 02 */
- {0x06,0x4f,0x83,0x8f,0xc0},   /* 03 */
- {0x07,0x4f,0x83,0x8f,0xc0},   /* 04 */
- {0x0d,0x27,0x91,0x8f,0xc0},   /* 05 */
- {0x0e,0x4f,0x83,0x8f,0xc0},   /* 06 */
- {0x0f,0x4f,0x83,0x5d,0xc0},   /* 07 */
- {0x10,0x4f,0x83,0x5d,0xc0},   /* 08 */
- {0x11,0x4f,0x83,0xdf,0x0c},   /* 09 */
- {0x12,0x4f,0x83,0xdf,0x0c},   /* 10 */
- {0x13,0x4f,0x83,0x8f,0xc0},   /* 11 */
- {0x2e,0x4f,0x83,0xdf,0x0c},   /* 12 */
- {0x2e,0x4f,0x87,0xdf,0xc0},   /* 13 */
- {0x2f,0x4f,0x83,0x8f,0xc0},   /* 14 */
- {0x50,0x27,0x91,0xdf,0x0c},   /* 15 */
- {0x59,0x27,0x91,0x8f,0xc0}    /* 16 */
-};
-
-static struct XGI_CRT1TableStruct XGI_CRT1Table[] =
-{
- {{0x2d,0x28,0x90,0x2c,0x90,0x00,0x04,0x00,
-    0xbf,0x1f,0x9c,0x8e,0x96,0xb9,0x30}}, /* 0x0 */
- {{0x2d,0x28,0x90,0x2c,0x90,0x00,0x04,0x00,
-    0x0b,0x3e,0xe9,0x8b,0xe7,0x04,0x00}}, /* 0x1 */
- {{0x3D,0x31,0x81,0x37,0x1F,0x00,0x05,0x00,
-    0x72,0xF0,0x58,0x8C,0x57,0x73,0xA0}}, /* 0x2 */
- {{0x4F,0x3F,0x93,0x45,0x0D,0x00,0x01,0x00,
-    0x24,0xF5,0x02,0x88,0xFF,0x25,0x90}}, /* 0x3 */
- {{0x5F,0x50,0x82,0x55,0x81,0x00,0x05,0x00,
-    0xBF,0x1F,0x9C,0x8E,0x96,0xB9,0x30}}, /* 0x4 */
- {{0x5F,0x50,0x82,0x55,0x81,0x00,0x05,0x00,
-    0x0B,0x3E,0xE9,0x8B,0xE7,0x04,0x00}}, /* 0x5 */
- {{0x63,0x50,0x86,0x56,0x9B,0x00,0x01,0x00,
-    0x06,0x3E,0xE8,0x8B,0xE7,0xFF,0x10}}, /* 0x6 */
- {{0x64,0x4F,0x88,0x55,0x9D,0x00,0x01,0x00,
-    0xF2,0x1F,0xE0,0x83,0xDF,0xF3,0x10}}, /* 0x7 */
- {{0x63,0x4F,0x87,0x5A,0x81,0x00,0x05,0x00,
-    0xFB,0x1F,0xE0,0x83,0xDF,0xFC,0x10}}, /* 0x8 */
- {{0x65,0x4F,0x89,0x58,0x80,0x00,0x05,0x60,
-    0xFB,0x1F,0xE0,0x83,0xDF,0xFC,0x80}}, /* 0x9 */
- {{0x65,0x4F,0x89,0x58,0x80,0x00,0x05,0x60,
-    0x01,0x3E,0xE0,0x83,0xDF,0x02,0x80}}, /* 0xa */
- {{0x67,0x4F,0x8B,0x58,0x81,0x00,0x05,0x60,
-    0x0D,0x3E,0xE0,0x83,0xDF,0x0E,0x90}}, /* 0xb */
- {{0x65,0x4F,0x89,0x57,0x9F,0x00,0x01,0x00,
-   0xFB,0x1F,0xE6,0x8A,0xDF,0xFC,0x10}}, /* 0xc */
- {{0x7B,0x63,0x9F,0x6A,0x93,0x00,0x05,0x00,    /* ; 0D (800x600,56Hz) */
-    0x6F,0xF0,0x58,0x8A,0x57,0x70,0xA0}},         /* ; (VCLK 36.0MHz) */
- {{0x7F,0x63,0x83,0x6C,0x1C,0x00,0x06,0x00,    /* ; 0E (800x600,60Hz) */
-    0x72,0xF0,0x58,0x8C,0x57,0x73,0xA0}},         /* ; (VCLK 40.0MHz) */
- {{0x7D,0x63,0x81,0x6E,0x1D,0x00,0x06,0x00,    /* ; 0F (800x600,72Hz) */
-    0x98,0xF0,0x7C,0x82,0x57,0x99,0x80}},         /* ; (VCLK 50.0MHz) */
- {{0x7F,0x63,0x83,0x69,0x13,0x00,0x06,0x00,    /* ; 10 (800x600,75Hz) */
-    0x6F,0xF0,0x58,0x8B,0x57,0x70,0xA0}},         /* ; (VCLK 49.5MHz) */
- {{0x7E,0x63,0x82,0x6B,0x13,0x00,0x06,0x00,    /* ; 11 (800x600,85Hz) */
-    0x75,0xF0,0x58,0x8B,0x57,0x76,0xA0}},         /* ; (VCLK 56.25MHz) */
- {{0x81,0x63,0x85,0x6D,0x18,0x00,0x06,0x60,    /* ; 12 (800x600,100Hz) */
-    0x7A,0xF0,0x58,0x8B,0x57,0x7B,0xA0}},         /* ; (VCLK 75.8MHz) */
- {{0x83,0x63,0x87,0x6E,0x19,0x00,0x06,0x60,    /* ; 13 (800x600,120Hz) */
-    0x81,0xF0,0x58,0x8B,0x57,0x82,0xA0}},         /* ; (VCLK 79.411MHz) */
- {{0x85,0x63,0x89,0x6F,0x1A,0x00,0x06,0x60,    /* ; 14 (800x600,160Hz) */
-   0x91,0xF0,0x58,0x8B,0x57,0x92,0xA0}},         /* ; (VCLK 105.822MHz) */
- {{0x99,0x7F,0x9D,0x84,0x1A,0x00,0x02,0x00,
-    0x96,0x1F,0x7F,0x83,0x7F,0x97,0x10}}, /* 0x15 */
- {{0xA3,0x7F,0x87,0x86,0x97,0x00,0x02,0x00,
-    0x24,0xF5,0x02,0x88,0xFF,0x25,0x90}}, /* 0x16 */
- {{0xA1,0x7F,0x85,0x86,0x97,0x00,0x02,0x00,
-    0x24,0xF5,0x02,0x88,0xFF,0x25,0x90}}, /* 0x17 */
- {{0x9F,0x7F,0x83,0x85,0x91,0x00,0x02,0x00,
-    0x1E,0xF5,0x00,0x83,0xFF,0x1F,0x90}}, /* 0x18 */
- {{0xA7,0x7F,0x8B,0x89,0x95,0x00,0x02,0x00,
-    0x26,0xF5,0x00,0x83,0xFF,0x27,0x90}}, /* 0x19 */
- {{0xA9,0x7F,0x8D,0x8C,0x9A,0x00,0x02,0x62,
-    0x2C,0xF5,0x00,0x83,0xFF,0x2D,0x14}}, /* 0x1a */
- {{0xAB,0x7F,0x8F,0x8D,0x9B,0x00,0x02,0x62,
-    0x35,0xF5,0x00,0x83,0xFF,0x36,0x14}}, /* 0x1b */
- {{0xCF,0x9F,0x93,0xB2,0x01,0x00,0x03,0x00,
-    0x14,0xBA,0x00,0x83,0xFF,0x15,0x00}}, /* 0x1c */
- {{0xCE,0x9F,0x92,0xA9,0x17,0x00,0x07,0x00,
-    0x28,0x5A,0x00,0x83,0xFF,0x29,0x89}}, /* 0x1d */
- {{0xCE,0x9F,0x92,0xA5,0x17,0x00,0x07,0x00,
-    0x28,0x5A,0x00,0x83,0xFF,0x29,0x89}}, /* 0x1e */
- {{0xD3,0x9F,0x97,0xAB,0x1F,0x00,0x07,0x00,
-    0x2E,0x5A,0x00,0x83,0xFF,0x2F,0x89}}, /* 0x1f */
- {{0x09,0xC7,0x8D,0xD3,0x0B,0x01,0x04,0x00,
-    0xE0,0x10,0xB0,0x83,0xAF,0xE1,0x2F}}, /* 0x20 */
- {{0x09,0xC7,0x8D,0xD3,0x0B,0x01,0x04,0x00,
-    0xE0,0x10,0xB0,0x83,0xAF,0xE1,0x2F}}, /* 0x21 */
- {{0x09,0xC7,0x8D,0xD3,0x0B,0x01,0x04,0x00,
-    0xE0,0x10,0xB0,0x83,0xAF,0xE1,0x2F}}, /* 0x22 */
- {{0x09,0xC7,0x8D,0xD3,0x0B,0x01,0x04,0x00,
-    0xE0,0x10,0xB0,0x83,0xAF,0xE1,0x2F}}, /* 0x23 */
- {{0x09,0xC7,0x8D,0xD3,0x0B,0x01,0x04,0x00,
-    0xE0,0x10,0xB0,0x83,0xAF,0xE1,0x2F}}, /* 0x24 */
- {{0x09,0xC7,0x8D,0xD3,0x0B,0x01,0x04,0x00,
-    0xE0,0x10,0xB0,0x83,0xAF,0xE1,0x2F}}, /* 0x25 */
- {{0x09,0xC7,0x8D,0xD3,0x0B,0x01,0x04,0x00,
-    0xE0,0x10,0xB0,0x83,0xAF,0xE1,0x2F}}, /* 0x26 */
- {{0x40,0xEF,0x84,0x03,0x1D,0x41,0x01,0x00,
-    0xDA,0x1F,0xA0,0x83,0x9F,0xDB,0x1F}}, /* 0x27 */
- {{0x43,0xEF,0x87,0x06,0x00,0x41,0x05,0x62,
-    0xD4,0x1F,0xA0,0x83,0x9F,0xD5,0x9F}}, /* 0x28 */
- {{0x45,0xEF,0x89,0x07,0x01,0x41,0x05,0x62,
-    0xD9,0x1F,0xA0,0x83,0x9F,0xDA,0x9F}}, /* 0x29 */
- {{0x40,0xEF,0x84,0x03,0x1D,0x41,0x01,0x00,
-    0xDA,0x1F,0xA0,0x83,0x9F,0xDB,0x1F}}, /* 0x2a */
- {{0x40,0xEF,0x84,0x03,0x1D,0x41,0x01,0x00,
-    0xDA,0x1F,0xA0,0x83,0x9F,0xDB,0x1F}}, /* 0x2b */
- {{0x40,0xEF,0x84,0x03,0x1D,0x41,0x01,0x00,
-    0xDA,0x1F,0xA0,0x83,0x9F,0xDB,0x1F}}, /* 0x2c */
- {{0x59,0xFF,0x9D,0x17,0x13,0x41,0x05,0x44,
-    0x33,0xBA,0x00,0x83,0xFF,0x34,0x0F}}, /* 0x2d */
- {{0x5B,0xFF,0x9F,0x18,0x14,0x41,0x05,0x44,
-    0x38,0xBA,0x00,0x83,0xFF,0x39,0x0F}}, /* 0x2e */
- {{0x5B,0xFF,0x9F,0x18,0x14,0x41,0x05,0x44,
-    0x3D,0xBA,0x00,0x83,0xFF,0x3E,0x0F}}, /* 0x2f */
- {{0x5D,0xFF,0x81,0x19,0x95,0x41,0x05,0x44,
-    0x41,0xBA,0x00,0x84,0xFF,0x42,0x0F}}, /* 0x30 */
- {{0x55,0xFF,0x99,0x0D,0x0C,0x41,0x05,0x00,
-    0x3E,0xBA,0x00,0x84,0xFF,0x3F,0x0F}}, /* 0x31 */
- {{0x7F,0x63,0x83,0x6C,0x1C,0x00,0x06,0x00,
-    0x72,0xBA,0x27,0x8B,0xDF,0x73,0x80}}, /* 0x32 */
- {{0x7F,0x63,0x83,0x69,0x13,0x00,0x06,0x00,
-    0x6F,0xBA,0x26,0x89,0xDF,0x6F,0x80}}, /* 0x33 */
- {{0x7F,0x63,0x82,0x6B,0x13,0x00,0x06,0x00,
-    0x75,0xBA,0x29,0x8C,0xDF,0x75,0x80}}, /* 0x34 */
- {{0xA3,0x7F,0x87,0x86,0x97,0x00,0x02,0x00,
-    0x24,0xF1,0xAF,0x85,0x3F,0x25,0xB0}}, /* 0x35 */
- {{0x9F,0x7F,0x83,0x85,0x91,0x00,0x02,0x00,
-    0x1E,0xF1,0xAD,0x81,0x3F,0x1F,0xB0}}, /* 0x36 */
- {{0xA7,0x7F,0x88,0x89,0x15,0x00,0x02,0x00,
-    0x26,0xF1,0xB1,0x85,0x3F,0x27,0xB0}}, /* 0x37 */
- {{0xCE,0x9F,0x92,0xA9,0x17,0x00,0x07,0x00,
-    0x28,0xC4,0x7A,0x8E,0xCF,0x29,0xA1}}, /* 0x38 */
- {{0xCE,0x9F,0x92,0xA5,0x17,0x00,0x07,0x00,
-    0x28,0xD4,0x7A,0x8E,0xCF,0x29,0xA1}}, /* 0x39 */
- {{0xD3,0x9F,0x97,0xAB,0x1F,0x00,0x07,0x00,
-    0x2E,0xD4,0x7D,0x81,0xCF,0x2F,0xA1}}, /* 0x3a */
- {{0xDC,0x9F,0x00,0xAB,0x19,0x00,0x07,0x00,
-    0xE6,0xEF,0xC0,0xC3,0xBF,0xE7,0x90}}, /* 0x3b */
- {{0x6B,0x59,0x8F,0x5E,0x8C,0x00,0x05,0x00,
-    0x0B,0x3E,0xE9,0x8B,0xE7,0x04,0x00}}, /* 0x3c */
- {{0x7B,0x63,0x9F,0x6A,0x93,0x00,0x05,0x00,
-    0x6F,0xF0,0x58,0x8A,0x57,0x70,0xA0}}, /* 0x3d */
- {{0x86,0x6A,0x8a,0x74,0x06,0x00,0x02,0x00,
-    0x8c,0x15,0x4f,0x83,0xef,0x8d,0x30}}, /* 0x3e */
- {{0x81,0x6A,0x85,0x70,0x00,0x00,0x02,0x00,
-    0x0f,0x3e,0xeb,0x8e,0xdf,0x10,0x00}}, /* 0x3f */
- {{0xCE,0x9F,0x92,0xA9,0x17,0x00,0x07,0x00,
-    0x20,0xF5,0x03,0x88,0xFF,0x21,0x90}}, /* 0x40 */
- {{0xE6,0xAE,0x8A,0xBD,0x90,0x00,0x03,0x00,
-    0x3D,0x10,0x1A,0x8D,0x19,0x3E,0x2F}}, /* 0x41 */
- {{0xB9,0x8F,0x9D,0x9B,0x8A,0x00,0x06,0x00,
-    0x7D,0xFF,0x60,0x83,0x5F,0x7E,0x90}}, /* 0x42 */
- {{0xC3,0x8F,0x87,0x9B,0x0B,0x00,0x07,0x00,
-    0x82,0xFF,0x60,0x83,0x5F,0x83,0x90}},  /* 0x43 */
- {{0xAD,0x7F,0x91,0x8E,0x9C,0x00,0x02,0x82,
-    0x49,0xF5,0x00,0x83,0xFF,0x4A,0x90}},  /* 0x44 */
- {{0xCD,0x9F,0x91,0xA7,0x19,0x00,0x07,0x60,
-    0xE6,0xFF,0xC0,0x83,0xBF,0xE7,0x90}},  /* 0x45 */
- {{0xD3,0x9F,0x97,0xAB,0x1F,0x00,0x07,0x60,
-    0xF1,0xFF,0xC0,0x83,0xBF,0xF2,0x90}},  /* 0x46 */
- {{0xD7,0x9F,0x9B,0xAC,0x1E,0x00,0x07,0x00,
-    0x03,0xDE,0xC0,0x84,0xBF,0x04,0x90}}  /* 0x47 */
+       {
+               0x28, 0x18, 0x08, 0x2000,
+               {0x01, 0x0f, 0x00, 0x0e},
+                0x63,
+               {0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f,
+                0x00, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x9c, 0x8e, 0x8f, 0x28, 0x40, 0x96, 0xb9, 0xa3,
+                0xff},
+               {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+                0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+                0x41, 0x00, 0x0f, 0x00},
+               {0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0f,
+                0xff}
+       }
+};
+
+static struct XGI_TimingHStruct XGI_TimingH[] = {
+       { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} }
+};
+
+static struct XGI_TimingVStruct XGI_TimingV[] = {
+       { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} }
+};
+
+static struct XGI_XG21CRT1Struct XGI_UpdateCRT1Table[] = {
+       {0x01, 0x27, 0x91, 0x8f, 0xc0}, /* 00 */
+       {0x03, 0x4f, 0x83, 0x8f, 0xc0}, /* 01 */
+       {0x05, 0x27, 0x91, 0x8f, 0xc0}, /* 02 */
+       {0x06, 0x4f, 0x83, 0x8f, 0xc0}, /* 03 */
+       {0x07, 0x4f, 0x83, 0x8f, 0xc0}, /* 04 */
+       {0x0d, 0x27, 0x91, 0x8f, 0xc0}, /* 05 */
+       {0x0e, 0x4f, 0x83, 0x8f, 0xc0}, /* 06 */
+       {0x0f, 0x4f, 0x83, 0x5d, 0xc0}, /* 07 */
+       {0x10, 0x4f, 0x83, 0x5d, 0xc0}, /* 08 */
+       {0x11, 0x4f, 0x83, 0xdf, 0x0c}, /* 09 */
+       {0x12, 0x4f, 0x83, 0xdf, 0x0c}, /* 10 */
+       {0x13, 0x4f, 0x83, 0x8f, 0xc0}, /* 11 */
+       {0x2e, 0x4f, 0x83, 0xdf, 0x0c}, /* 12 */
+       {0x2e, 0x4f, 0x87, 0xdf, 0xc0}, /* 13 */
+       {0x2f, 0x4f, 0x83, 0x8f, 0xc0}, /* 14 */
+       {0x50, 0x27, 0x91, 0xdf, 0x0c}, /* 15 */
+       {0x59, 0x27, 0x91, 0x8f, 0xc0}  /* 16 */
+};
+
+static struct XGI_CRT1TableStruct XGI_CRT1Table[] = {
+       { {0x2d, 0x28, 0x90, 0x2c, 0x90, 0x00, 0x04, 0x00,
+         0xbf, 0x1f, 0x9c, 0x8e, 0x96, 0xb9, 0x30} }, /* 0x0 */
+       { {0x2d, 0x28, 0x90, 0x2c, 0x90, 0x00, 0x04, 0x00,
+         0x0b, 0x3e, 0xe9, 0x8b, 0xe7, 0x04, 0x00} }, /* 0x1 */
+       { {0x3D, 0x31, 0x81, 0x37, 0x1F, 0x00, 0x05, 0x00,
+         0x72, 0xF0, 0x58, 0x8C, 0x57, 0x73, 0xA0} }, /* 0x2 */
+       { {0x4F, 0x3F, 0x93, 0x45, 0x0D, 0x00, 0x01, 0x00,
+         0x24, 0xF5, 0x02, 0x88, 0xFF, 0x25, 0x90} }, /* 0x3 */
+       { {0x5F, 0x50, 0x82, 0x55, 0x81, 0x00, 0x05, 0x00,
+         0xBF, 0x1F, 0x9C, 0x8E, 0x96, 0xB9, 0x30} }, /* 0x4 */
+       { {0x5F, 0x50, 0x82, 0x55, 0x81, 0x00, 0x05, 0x00,
+         0x0B, 0x3E, 0xE9, 0x8B, 0xE7, 0x04, 0x00} }, /* 0x5 */
+       { {0x63, 0x50, 0x86, 0x56, 0x9B, 0x00, 0x01, 0x00,
+         0x06, 0x3E, 0xE8, 0x8B, 0xE7, 0xFF, 0x10} }, /* 0x6 */
+       { {0x64, 0x4F, 0x88, 0x55, 0x9D, 0x00, 0x01, 0x00,
+         0xF2, 0x1F, 0xE0, 0x83, 0xDF, 0xF3, 0x10} }, /* 0x7 */
+       { {0x63, 0x4F, 0x87, 0x5A, 0x81, 0x00, 0x05, 0x00,
+         0xFB, 0x1F, 0xE0, 0x83, 0xDF, 0xFC, 0x10} }, /* 0x8 */
+       { {0x65, 0x4F, 0x89, 0x58, 0x80, 0x00, 0x05, 0x60,
+         0xFB, 0x1F, 0xE0, 0x83, 0xDF, 0xFC, 0x80} }, /* 0x9 */
+       { {0x65, 0x4F, 0x89, 0x58, 0x80, 0x00, 0x05, 0x60,
+         0x01, 0x3E, 0xE0, 0x83, 0xDF, 0x02, 0x80} }, /* 0xa */
+       { {0x67, 0x4F, 0x8B, 0x58, 0x81, 0x00, 0x05, 0x60,
+         0x0D, 0x3E, 0xE0, 0x83, 0xDF, 0x0E, 0x90} }, /* 0xb */
+       { {0x65, 0x4F, 0x89, 0x57, 0x9F, 0x00, 0x01, 0x00,
+         0xFB, 0x1F, 0xE6, 0x8A, 0xDF, 0xFC, 0x10} }, /* 0xc */
+       { {0x7B, 0x63, 0x9F, 0x6A, 0x93, 0x00, 0x05, 0x00, /* ;
+                                               0D (800x600,56Hz) */
+         0x6F, 0xF0, 0x58, 0x8A, 0x57, 0x70, 0xA0} },     /* ;
+                                               (VCLK 36.0MHz) */
+       { {0x7F, 0x63, 0x83, 0x6C, 0x1C, 0x00, 0x06, 0x00, /* ;
+                                               0E (800x600,60Hz) */
+         0x72, 0xF0, 0x58, 0x8C, 0x57, 0x73, 0xA0} },     /* ;
+                                               (VCLK 40.0MHz) */
+       { {0x7D, 0x63, 0x81, 0x6E, 0x1D, 0x00, 0x06, 0x00, /* ;
+                                               0F (800x600,72Hz) */
+         0x98, 0xF0, 0x7C, 0x82, 0x57, 0x99, 0x80} },     /* ;
+                                               (VCLK 50.0MHz) */
+       { {0x7F, 0x63, 0x83, 0x69, 0x13, 0x00, 0x06, 0x00, /* ;
+                                               10 (800x600,75Hz) */
+         0x6F, 0xF0, 0x58, 0x8B, 0x57, 0x70, 0xA0} },     /* ;
+                                               (VCLK 49.5MHz) */
+       { {0x7E, 0x63, 0x82, 0x6B, 0x13, 0x00, 0x06, 0x00, /* ;
+                                               11 (800x600,85Hz) */
+         0x75, 0xF0, 0x58, 0x8B, 0x57, 0x76, 0xA0} },     /* ;
+                                               (VCLK 56.25MHz) */
+       { {0x81, 0x63, 0x85, 0x6D, 0x18, 0x00, 0x06, 0x60, /* ;
+                                               12 (800x600,100Hz) */
+         0x7A, 0xF0, 0x58, 0x8B, 0x57, 0x7B, 0xA0} },     /* ;
+                                               (VCLK 75.8MHz) */
+       { {0x83, 0x63, 0x87, 0x6E, 0x19, 0x00, 0x06, 0x60, /* ;
+                                               13 (800x600,120Hz) */
+         0x81, 0xF0, 0x58, 0x8B, 0x57, 0x82, 0xA0} },     /* ;
+                                               (VCLK 79.411MHz) */
+       { {0x85, 0x63, 0x89, 0x6F, 0x1A, 0x00, 0x06, 0x60, /* ;
+                                               14 (800x600,160Hz) */
+         0x91, 0xF0, 0x58, 0x8B, 0x57, 0x92, 0xA0} },     /* ;
+                                               (VCLK 105.822MHz) */
+       { {0x99, 0x7F, 0x9D, 0x84, 0x1A, 0x00, 0x02, 0x00,
+         0x96, 0x1F, 0x7F, 0x83, 0x7F, 0x97, 0x10} }, /* 0x15 */
+       { {0xA3, 0x7F, 0x87, 0x86, 0x97, 0x00, 0x02, 0x00,
+         0x24, 0xF5, 0x02, 0x88, 0xFF, 0x25, 0x90} }, /* 0x16 */
+       { {0xA1, 0x7F, 0x85, 0x86, 0x97, 0x00, 0x02, 0x00,
+         0x24, 0xF5, 0x02, 0x88, 0xFF, 0x25, 0x90} }, /* 0x17 */
+       { {0x9F, 0x7F, 0x83, 0x85, 0x91, 0x00, 0x02, 0x00,
+         0x1E, 0xF5, 0x00, 0x83, 0xFF, 0x1F, 0x90} }, /* 0x18 */
+       { {0xA7, 0x7F, 0x8B, 0x89, 0x95, 0x00, 0x02, 0x00,
+         0x26, 0xF5, 0x00, 0x83, 0xFF, 0x27, 0x90} }, /* 0x19 */
+       { {0xA9, 0x7F, 0x8D, 0x8C, 0x9A, 0x00, 0x02, 0x62,
+         0x2C, 0xF5, 0x00, 0x83, 0xFF, 0x2D, 0x14} }, /* 0x1a */
+       { {0xAB, 0x7F, 0x8F, 0x8D, 0x9B, 0x00, 0x02, 0x62,
+         0x35, 0xF5, 0x00, 0x83, 0xFF, 0x36, 0x14} }, /* 0x1b */
+       { {0xCF, 0x9F, 0x93, 0xB2, 0x01, 0x00, 0x03, 0x00,
+         0x14, 0xBA, 0x00, 0x83, 0xFF, 0x15, 0x00} }, /* 0x1c */
+       { {0xCE, 0x9F, 0x92, 0xA9, 0x17, 0x00, 0x07, 0x00,
+         0x28, 0x5A, 0x00, 0x83, 0xFF, 0x29, 0x89} }, /* 0x1d */
+       { {0xCE, 0x9F, 0x92, 0xA5, 0x17, 0x00, 0x07, 0x00,
+         0x28, 0x5A, 0x00, 0x83, 0xFF, 0x29, 0x89} }, /* 0x1e */
+       { {0xD3, 0x9F, 0x97, 0xAB, 0x1F, 0x00, 0x07, 0x00,
+         0x2E, 0x5A, 0x00, 0x83, 0xFF, 0x2F, 0x89} }, /* 0x1f */
+       { {0x09, 0xC7, 0x8D, 0xD3, 0x0B, 0x01, 0x04, 0x00,
+         0xE0, 0x10, 0xB0, 0x83, 0xAF, 0xE1, 0x2F} }, /* 0x20 */
+       { {0x09, 0xC7, 0x8D, 0xD3, 0x0B, 0x01, 0x04, 0x00,
+         0xE0, 0x10, 0xB0, 0x83, 0xAF, 0xE1, 0x2F} }, /* 0x21 */
+       { {0x09, 0xC7, 0x8D, 0xD3, 0x0B, 0x01, 0x04, 0x00,
+         0xE0, 0x10, 0xB0, 0x83, 0xAF, 0xE1, 0x2F} }, /* 0x22 */
+       { {0x09, 0xC7, 0x8D, 0xD3, 0x0B, 0x01, 0x04, 0x00,
+         0xE0, 0x10, 0xB0, 0x83, 0xAF, 0xE1, 0x2F} }, /* 0x23 */
+       { {0x09, 0xC7, 0x8D, 0xD3, 0x0B, 0x01, 0x04, 0x00,
+         0xE0, 0x10, 0xB0, 0x83, 0xAF, 0xE1, 0x2F} }, /* 0x24 */
+       { {0x09, 0xC7, 0x8D, 0xD3, 0x0B, 0x01, 0x04, 0x00,
+         0xE0, 0x10, 0xB0, 0x83, 0xAF, 0xE1, 0x2F} }, /* 0x25 */
+       { {0x09, 0xC7, 0x8D, 0xD3, 0x0B, 0x01, 0x04, 0x00,
+         0xE0, 0x10, 0xB0, 0x83, 0xAF, 0xE1, 0x2F} }, /* 0x26 */
+       { {0x40, 0xEF, 0x84, 0x03, 0x1D, 0x41, 0x01, 0x00,
+         0xDA, 0x1F, 0xA0, 0x83, 0x9F, 0xDB, 0x1F} }, /* 0x27 */
+       { {0x43, 0xEF, 0x87, 0x06, 0x00, 0x41, 0x05, 0x62,
+         0xD4, 0x1F, 0xA0, 0x83, 0x9F, 0xD5, 0x9F} }, /* 0x28 */
+       { {0x45, 0xEF, 0x89, 0x07, 0x01, 0x41, 0x05, 0x62,
+         0xD9, 0x1F, 0xA0, 0x83, 0x9F, 0xDA, 0x9F} }, /* 0x29 */
+       { {0x40, 0xEF, 0x84, 0x03, 0x1D, 0x41, 0x01, 0x00,
+         0xDA, 0x1F, 0xA0, 0x83, 0x9F, 0xDB, 0x1F} }, /* 0x2a */
+       { {0x40, 0xEF, 0x84, 0x03, 0x1D, 0x41, 0x01, 0x00,
+         0xDA, 0x1F, 0xA0, 0x83, 0x9F, 0xDB, 0x1F} }, /* 0x2b */
+       { {0x40, 0xEF, 0x84, 0x03, 0x1D, 0x41, 0x01, 0x00,
+         0xDA, 0x1F, 0xA0, 0x83, 0x9F, 0xDB, 0x1F} }, /* 0x2c */
+       { {0x59, 0xFF, 0x9D, 0x17, 0x13, 0x41, 0x05, 0x44,
+         0x33, 0xBA, 0x00, 0x83, 0xFF, 0x34, 0x0F} }, /* 0x2d */
+       { {0x5B, 0xFF, 0x9F, 0x18, 0x14, 0x41, 0x05, 0x44,
+         0x38, 0xBA, 0x00, 0x83, 0xFF, 0x39, 0x0F} }, /* 0x2e */
+       { {0x5B, 0xFF, 0x9F, 0x18, 0x14, 0x41, 0x05, 0x44,
+         0x3D, 0xBA, 0x00, 0x83, 0xFF, 0x3E, 0x0F} }, /* 0x2f */
+       { {0x5D, 0xFF, 0x81, 0x19, 0x95, 0x41, 0x05, 0x44,
+         0x41, 0xBA, 0x00, 0x84, 0xFF, 0x42, 0x0F} }, /* 0x30 */
+       { {0x55, 0xFF, 0x99, 0x0D, 0x0C, 0x41, 0x05, 0x00,
+         0x3E, 0xBA, 0x00, 0x84, 0xFF, 0x3F, 0x0F} }, /* 0x31 */
+       { {0x7F, 0x63, 0x83, 0x6C, 0x1C, 0x00, 0x06, 0x00,
+         0x72, 0xBA, 0x27, 0x8B, 0xDF, 0x73, 0x80} }, /* 0x32 */
+       { {0x7F, 0x63, 0x83, 0x69, 0x13, 0x00, 0x06, 0x00,
+         0x6F, 0xBA, 0x26, 0x89, 0xDF, 0x6F, 0x80} }, /* 0x33 */
+       { {0x7F, 0x63, 0x82, 0x6B, 0x13, 0x00, 0x06, 0x00,
+         0x75, 0xBA, 0x29, 0x8C, 0xDF, 0x75, 0x80} }, /* 0x34 */
+       { {0xA3, 0x7F, 0x87, 0x86, 0x97, 0x00, 0x02, 0x00,
+         0x24, 0xF1, 0xAF, 0x85, 0x3F, 0x25, 0xB0} }, /* 0x35 */
+       { {0x9F, 0x7F, 0x83, 0x85, 0x91, 0x00, 0x02, 0x00,
+         0x1E, 0xF1, 0xAD, 0x81, 0x3F, 0x1F, 0xB0} }, /* 0x36 */
+       { {0xA7, 0x7F, 0x88, 0x89, 0x15, 0x00, 0x02, 0x00,
+         0x26, 0xF1, 0xB1, 0x85, 0x3F, 0x27, 0xB0} }, /* 0x37 */
+       { {0xCE, 0x9F, 0x92, 0xA9, 0x17, 0x00, 0x07, 0x00,
+         0x28, 0xC4, 0x7A, 0x8E, 0xCF, 0x29, 0xA1} }, /* 0x38 */
+       { {0xCE, 0x9F, 0x92, 0xA5, 0x17, 0x00, 0x07, 0x00,
+         0x28, 0xD4, 0x7A, 0x8E, 0xCF, 0x29, 0xA1} }, /* 0x39 */
+       { {0xD3, 0x9F, 0x97, 0xAB, 0x1F, 0x00, 0x07, 0x00,
+         0x2E, 0xD4, 0x7D, 0x81, 0xCF, 0x2F, 0xA1} }, /* 0x3a */
+       { {0xDC, 0x9F, 0x00, 0xAB, 0x19, 0x00, 0x07, 0x00,
+         0xE6, 0xEF, 0xC0, 0xC3, 0xBF, 0xE7, 0x90} }, /* 0x3b */
+       { {0x6B, 0x59, 0x8F, 0x5E, 0x8C, 0x00, 0x05, 0x00,
+         0x0B, 0x3E, 0xE9, 0x8B, 0xE7, 0x04, 0x00} }, /* 0x3c */
+       { {0x7B, 0x63, 0x9F, 0x6A, 0x93, 0x00, 0x05, 0x00,
+         0x6F, 0xF0, 0x58, 0x8A, 0x57, 0x70, 0xA0} }, /* 0x3d */
+       { {0x86, 0x6A, 0x8a, 0x74, 0x06, 0x00, 0x02, 0x00,
+         0x8c, 0x15, 0x4f, 0x83, 0xef, 0x8d, 0x30} }, /* 0x3e */
+       { {0x81, 0x6A, 0x85, 0x70, 0x00, 0x00, 0x02, 0x00,
+         0x0f, 0x3e, 0xeb, 0x8e, 0xdf, 0x10, 0x00} }, /* 0x3f */
+       { {0xCE, 0x9F, 0x92, 0xA9, 0x17, 0x00, 0x07, 0x00,
+         0x20, 0xF5, 0x03, 0x88, 0xFF, 0x21, 0x90} }, /* 0x40 */
+       { {0xE6, 0xAE, 0x8A, 0xBD, 0x90, 0x00, 0x03, 0x00,
+         0x3D, 0x10, 0x1A, 0x8D, 0x19, 0x3E, 0x2F} }, /* 0x41 */
+       { {0xB9, 0x8F, 0x9D, 0x9B, 0x8A, 0x00, 0x06, 0x00,
+         0x7D, 0xFF, 0x60, 0x83, 0x5F, 0x7E, 0x90} }, /* 0x42 */
+       { {0xC3, 0x8F, 0x87, 0x9B, 0x0B, 0x00, 0x07, 0x00,
+         0x82, 0xFF, 0x60, 0x83, 0x5F, 0x83, 0x90} },  /* 0x43 */
+       { {0xAD, 0x7F, 0x91, 0x8E, 0x9C, 0x00, 0x02, 0x82,
+         0x49, 0xF5, 0x00, 0x83, 0xFF, 0x4A, 0x90} },  /* 0x44 */
+       { {0xCD, 0x9F, 0x91, 0xA7, 0x19, 0x00, 0x07, 0x60,
+         0xE6, 0xFF, 0xC0, 0x83, 0xBF, 0xE7, 0x90} },  /* 0x45 */
+       { {0xD3, 0x9F, 0x97, 0xAB, 0x1F, 0x00, 0x07, 0x60,
+         0xF1, 0xFF, 0xC0, 0x83, 0xBF, 0xF2, 0x90} },  /* 0x46 */
+       { {0xD7, 0x9F, 0x9B, 0xAC, 0x1E, 0x00, 0x07, 0x00,
+         0x03, 0xDE, 0xC0, 0x84, 0xBF, 0x04, 0x90} }  /* 0x47 */
 };
 
 #if 0
 static struct XGI330_CHTVRegDataStruct XGI_CHTVRegUNTSC[] = {
-                /* Index:000h,001h,002h,004h,003h,005h,006h,007h,008h,015h,01Fh,00Ch,00Dh,00Eh,00Fh,010h */
-                {{      0x4A,0x77,0xBB,0x94,0x84,0x48,0xFE,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01  }},/* 00 (640x200,640x400) */
-                {{      0x4A,0x77,0xBB,0x94,0x84,0x48,0xFE,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01  }},/* 01 (640x350) */
-                {{      0x4A,0x77,0xBB,0x94,0x84,0x48,0xFE,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01  }},/* 02 (720x400) */
-                {{      0x4A,0x77,0xBB,0x94,0x84,0x48,0xFE,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01  }},/* 03 (720x350) */
-                {{      0x6A,0x77,0xBB,0x6E,0x84,0x2E,0x02,0x5A,0x04,0x00,0x80,0x20,0x7E,0x80,0x97,0x00  }},/* 04 (640x480) ;;5/6/02 */
-                {{      0xCF,0x77,0xB7,0xC8,0x84,0x3B,0x02,0x5A,0x04,0x00,0x80,0x19,0x88,0xAE,0xA3,0x00  }},/* 05 (800x600) ;;1/12/02 */
-                {{      0xEE,0x77,0xBB,0x66,0x87,0x32,0x01,0x5A,0x04,0x00,0x80,0x1B,0xD4,0x2F,0x6F,0x00  }}/* 06 (1024x768) ;;5/6/02 */
-          };
+       /* Index: 000h, 001h, 002h, 004h, 003h, 005h, 006h, 007h,
+                 008h, 015h, 01Fh, 00Ch, 00Dh, 00Eh, 00Fh, 010h */
+       /* 00 (640x200,640x400) */
+       { {0x4A, 0x77, 0xBB, 0x94, 0x84, 0x48, 0xFE, 0x50,
+          0x04, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01  } },
+       /* 01 (640x350) */
+       { {0x4A, 0x77, 0xBB, 0x94, 0x84, 0x48, 0xFE, 0x50,
+          0x04, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01  } },
+       /* 02 (720x400) */
+       { {0x4A, 0x77, 0xBB, 0x94, 0x84, 0x48, 0xFE, 0x50,
+          0x04, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01  } },
+       /* 03 (720x350) */
+       { {0x4A, 0x77, 0xBB, 0x94, 0x84, 0x48, 0xFE, 0x50,
+          0x04, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01  } },
+       /* 04 (640x480) ;;5/6/02 */
+       { {0x6A, 0x77, 0xBB, 0x6E, 0x84, 0x2E, 0x02, 0x5A,
+          0x04, 0x00, 0x80, 0x20, 0x7E, 0x80, 0x97, 0x00  } },
+       /* 05 (800x600) ;;1/12/02 */
+       { {0xCF, 0x77, 0xB7, 0xC8, 0x84, 0x3B, 0x02, 0x5A,
+          0x04, 0x00, 0x80, 0x19, 0x88, 0xAE, 0xA3, 0x00  } },
+       /* 06 (1024x768) ;;5/6/02 */
+       { {0xEE, 0x77, 0xBB, 0x66, 0x87, 0x32, 0x01, 0x5A,
+          0x04, 0x00, 0x80, 0x1B, 0xD4, 0x2F, 0x6F, 0x00  } }
+};
 
 static struct XGI330_CHTVRegDataStruct XGI_CHTVRegONTSC[] = {
-                /* Index:000h,001h,002h,004h,003h,005h,006h,007h,008h,015h,01Fh,00Ch,00Dh,00Eh,00Fh,010h */
-                {{      0x49,0x77,0xBB,0x7B,0x84,0x34,0x00,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01  }},/* 00 (640x200,640x400) */
-                {{      0x49,0x77,0xBB,0x7B,0x84,0x34,0x00,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01  }},/* 01 (640x350) */
-                {{      0x49,0x77,0xBB,0x7B,0x84,0x34,0x00,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01  }},/* 02 (720x400) */
-                {{      0x49,0x77,0xBB,0x7B,0x84,0x34,0x00,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01  }},/* 03 (720x350) */
-                {{      0x69,0x77,0xBB,0x6E,0x84,0x1E,0x00,0x5A,0x04,0x00,0x80,0x25,0x1A,0x80,0x26,0x00  }},/* 04 (640x480) ;;5/6/02 */
-                {{      0xCE,0x77,0xB7,0xB6,0x83,0x2C,0x02,0x5A,0x04,0x00,0x80,0x1C,0x00,0x82,0x97,0x00  }},/* 05 (800x600) ;;5/6/02 */
-                {{      0xED,0x77,0xBB,0x66,0x8C,0x21,0x02,0x5A,0x04,0x00,0x80,0x1F,0xA0,0x7E,0x73,0x00  }}/* 06 (1024x768) ;;5/6/02 */
-          };
+       /* Index: 000h, 001h, 002h, 004h, 003h, 005h, 006h, 007h,
+                 008h, 015h, 01Fh, 00Ch, 00Dh, 00Eh, 00Fh, 010h */
+       /* 00 (640x200,640x400) */
+       { {0x49, 0x77, 0xBB, 0x7B, 0x84, 0x34, 0x00, 0x50,
+          0x04, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01} },
+       /* 01 (640x350) */
+       { {0x49, 0x77, 0xBB, 0x7B, 0x84, 0x34, 0x00 , 0x50,
+          0x04, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01} },
+       /* 02 (720x400) */
+       { {0x49, 0x77, 0xBB, 0x7B, 0x84, 0x34, 0x00 , 0x50,
+          0x04, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01} },
+       /* 03 (720x350) */
+       { {0x49, 0x77, 0xBB, 0x7B, 0x84, 0x34, 0x00 , 0x50,
+          0x04, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01} },
+       /* 04 (640x480) ;;5/6/02 */
+       { {0x69, 0x77, 0xBB, 0x6E, 0x84, 0x1E, 0x00 , 0x5A,
+          0x04, 0x00, 0x80, 0x25, 0x1A, 0x80, 0x26, 0x00} },
+       /* 05 (800x600) ;;5/6/02 */
+       { {0xCE, 0x77, 0xB7, 0xB6, 0x83, 0x2C, 0x02 , 0x5A,
+          0x04, 0x00, 0x80, 0x1C, 0x00, 0x82, 0x97, 0x00} },
+       /* 06 (1024x768) ;;5/6/02 */
+       { {0xED, 0x77, 0xBB, 0x66, 0x8C, 0x21, 0x02 , 0x5A,
+          0x04, 0x00, 0x80, 0x1F, 0xA0, 0x7E, 0x73, 0x00} }
+};
 
 static struct XGI330_CHTVRegDataStruct XGI_CHTVRegUPAL[] = {
-                /* Index:000h,001h,002h,004h,003h,005h,006h,007h,008h,015h,01Fh,00Ch,00Dh,00Eh,00Fh,010h */
-                {{      0x41,0x7F,0xB7,0x34,0xAD,0x50,0x34,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01  }},/* ; 00 (640x200,640x400) */
-                {{      0x41,0x7F,0xB7,0x80,0x85,0x50,0x00,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01  }},/* ; 01 (640x350) */
-                {{      0x41,0x7F,0xB7,0x34,0xAD,0x50,0x34,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01  }},/* ; 02 (720x400) */
-                {{      0x41,0x7F,0xB7,0x12,0x85,0x50,0x00,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01  }},/* ; 03 (720x350) */
-                {{      0x61,0x7F,0xB7,0x99,0x84,0x35,0x04,0x5A,0x05,0x00,0x80,0x26,0x2A,0x55,0x5D,0x00  }},/* ; 04 (640x480) */
-                {{      0xC3,0x7F,0xB7,0x7A,0x84,0x40,0x02,0x5A,0x05,0x00,0x80,0x1F,0x84,0x3D,0x28,0x00  }},/* ; 05 (800x600) ;;1/12/02 */
-                {{      0xE5,0x7F,0xB7,0x1D,0xA7,0x3E,0x04,0x5A,0x05,0x00,0x80,0x20,0x3E,0xE4,0x22,0x00  }}/* ; 06 (1024x768) ;;1/12/02 */
-         };
+       /* Index: 000h, 001h, 002h, 004h, 003h, 005h, 006h, 007h,
+                 008h, 015h, 01Fh, 00Ch, 00Dh, 00Eh, 00Fh, 010h */
+       /* ; 00 (640x200,640x400) */
+       { {0x41, 0x7F, 0xB7, 0x34, 0xAD, 0x50, 0x34, 0x83,
+          0x05, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01} },
+       /* ; 01 (640x350) */
+       { {0x41, 0x7F, 0xB7, 0x80, 0x85, 0x50, 0x00, 0x83,
+          0x05, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01} },
+       /* ; 02 (720x400) */
+       { {0x41, 0x7F, 0xB7, 0x34, 0xAD, 0x50, 0x34, 0x83,
+          0x05, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01} },
+       /* ; 03 (720x350) */
+       { {0x41, 0x7F, 0xB7, 0x12, 0x85, 0x50, 0x00, 0x83,
+          0x05, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01} },
+       /* ; 04 (640x480) */
+       { {0x61, 0x7F, 0xB7, 0x99, 0x84, 0x35, 0x04, 0x5A,
+          0x05, 0x00, 0x80, 0x26, 0x2A, 0x55, 0x5D, 0x00} },
+       /* ; 05 (800x600) ;;1/12/02 */
+       { {0xC3, 0x7F, 0xB7, 0x7A, 0x84, 0x40, 0x02, 0x5A,
+          0x05, 0x00, 0x80, 0x1F, 0x84, 0x3D, 0x28, 0x00} },
+       /* ; 06 (1024x768) ;;1/12/02 */
+       { {0xE5, 0x7F, 0xB7, 0x1D, 0xA7, 0x3E, 0x04, 0x5A,
+          0x05, 0x00, 0x80, 0x20, 0x3E, 0xE4, 0x22, 0x00} }
+};
 
 static struct XGI330_CHTVRegDataStruct XGI_CHTVRegOPAL[] = {
-                /* Index:000,0x01,0x02,0x04,0x03,0x05,0x06,0x07,0x08,0x15,0x1F,0x0C,0x0D,0x0E,0x0F,0x10h */
-                {{      0x41,0x7F,0xB7,0x36,0xAD,0x50,0x34,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01 }},/* 00 (640x200,640x400) */
-                {{      0x41,0x7F,0xB7,0x86,0x85,0x50,0x00,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01 }},/* 01 (640x350) */
-                {{      0x41,0x7F,0xB7,0x36,0xAD,0x50,0x34,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01 }},/* 02 (720x400) */
-                {{      0x41,0x7F,0xB7,0x86,0x85,0x50,0x00,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01 }},/* 03 (720x350) */
-                {{      0x61,0x7F,0xB7,0x99,0x84,0x35,0x04,0x5A,0x05,0x00,0x80,0x26,0x2A,0x55,0x5D,0x00 }},/* 04 (640x480) */
-                {{      0xC1,0x7F,0xB7,0x4D,0x8C,0x1E,0x31,0x5A,0x05,0x00,0x80,0x26,0x78,0x19,0x34,0x00 }},/* 05 (800x600) ;;1/12/02 */
-                {{      0xE4,0x7F,0xB7,0x1E,0xAF,0x29,0x37,0x5A,0x05,0x00,0x80,0x25,0x8C,0xB2,0x2A,0x00 }}/* 06 (1024x768) ;;1/12/02 */
-            };
+       /* Index: 000, 0x01, 0x02, 0x04, 0x03, 0x05, 0x06, 0x07,
+                 0x08, 0x15, 0x1F, 0x0C, 0x0D, 0x0E, 0x0F, 0x10h */
+       /* 00 (640x200,640x400) */
+       { {0x41, 0x7F, 0xB7, 0x36, 0xAD, 0x50, 0x34, 0x83,
+          0x05, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01} },
+       /* 01 (640x350) */
+       { {0x41, 0x7F, 0xB7, 0x86, 0x85, 0x50, 0x00, 0x83,
+          0x05, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01} },
+       /* 02 (720x400) */
+       { {0x41, 0x7F, 0xB7, 0x36, 0xAD, 0x50, 0x34, 0x83,
+          0x05, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01} },
+       /* 03 (720x350) */
+       { {0x41, 0x7F, 0xB7, 0x86, 0x85, 0x50, 0x00, 0x83,
+          0x05, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01} },
+       /* 04 (640x480) */
+       { {0x61, 0x7F, 0xB7, 0x99, 0x84, 0x35, 0x04, 0x5A,
+          0x05, 0x00, 0x80, 0x26, 0x2A, 0x55, 0x5D, 0x00} },
+       /* 05 (800x600) ;;1/12/02 */
+       { {0xC1, 0x7F, 0xB7, 0x4D, 0x8C, 0x1E, 0x31, 0x5A,
+          0x05, 0x00, 0x80, 0x26, 0x78, 0x19, 0x34, 0x00} },
+       /* 06 (1024x768) ;;1/12/02 */
+       { {0xE4, 0x7F, 0xB7, 0x1E, 0xAF, 0x29, 0x37, 0x5A,
+          0x05, 0x00, 0x80, 0x25, 0x8C, 0xB2, 0x2A, 0x00} }
+};
 #endif
 
 static unsigned char XGI_CH7017LV1024x768[] = {
-                                       0x60, 0x02, 0x00, 0x07, 0x40, 0xED, 0xA3,
-                                       0xC8, 0xC7, 0xAC, 0xE0, 0x02};
+       0x60, 0x02, 0x00, 0x07, 0x40, 0xED,
+       0xA3, 0xC8, 0xC7, 0xAC, 0xE0, 0x02};
 static unsigned char XGI_CH7017LV1400x1050[] = {
-                                        0x60, 0x03, 0x11, 0x00, 0x40, 0xE3, 0xAD,
-                                        0xDB, 0xF6, 0xAC, 0xE0, 0x02};
-
+       0x60, 0x03, 0x11, 0x00, 0x40, 0xE3,
+       0xAD, 0xDB, 0xF6, 0xAC, 0xE0, 0x02};
 
 /*add for new UNIVGABIOS*/
-static struct XGI330_LCDDataStruct  XGI_StLCD1024x768Data[] =
-{
- {   62,  25, 800, 546,1344, 806},
- {   32,  15, 930, 546,1344, 806},
- {   62,  25, 800, 546,1344, 806}, /* chiawen for dot9 -> dot8 */
- {  104,  45, 945, 496,1344, 806},
- {   62,  25, 800, 546,1344, 806},
- {   31,  18,1008, 624,1344, 806},
- {    1,   1,1344, 806,1344, 806}
-};
-
-static struct XGI330_LCDDataStruct  XGI_ExtLCD1024x768Data[] =
-{
- {   42,  25,1536, 419,1344, 806}, /* { 12, 5, 896, 512,1344, 806}, // alan 09/12/2003 */
- {   48,  25,1536, 369,1344, 806}, /* { 12, 5, 896, 510,1344, 806}, // alan 09/12/2003 */
- {   42,  25,1536, 419,1344, 806}, /* { 32, 15,1008, 505,1344, 806}, // alan 09/12/2003 */
- {   48,  25,1536, 369,1344, 806}, /* { 32, 15,1008, 514,1344, 806}, // alan 09/12/2003 */
- {   12,   5, 896, 500,1344, 806},
- {   42,  25,1024, 625,1344, 806},
- {    1,   1,1344, 806,1344, 806},
- {   12,   5, 896, 500,1344, 806},
- {   42,  25,1024, 625,1344, 806},
- {    1,   1,1344, 806,1344, 806},
- {   12,   5, 896, 500,1344, 806},
- {   42,  25,1024, 625,1344, 806},
- {    1,   1,1344, 806,1344, 806}
-};
-
-/*struct XGI330_LCDDataStruct  XGI_St2LCD1024x768Data[] =
-{
- {   62,  25, 800, 546,1344, 806},
- {   32,  15, 930, 546,1344, 806},
- {   62,  25, 800, 546,1344, 806},
- {  104,  45, 945, 496,1344, 806},
- {   62,  25, 800, 546,1344, 806},
- {   31,  18,1008, 624,1344, 806},
- {    1,   1,1344, 806,1344, 806}
+static struct XGI330_LCDDataStruct  XGI_StLCD1024x768Data[] = {
+       {62,  25, 800,  546, 1344, 806},
+       {32,  15, 930,  546, 1344, 806},
+       {62,  25, 800,  546, 1344, 806}, /*chiawenfordot9->dot8*/
+       {104, 45, 945,  496, 1344, 806},
+       {62,  25, 800,  546, 1344, 806},
+       {31,  18, 1008, 624, 1344, 806},
+       {1,   1,  1344, 806, 1344, 806}
+};
+
+static struct XGI330_LCDDataStruct  XGI_ExtLCD1024x768Data[] = {
+       /* { 12, 5, 896, 512,1344, 806}, // alan 09/12/2003 */
+       {42, 25, 1536, 419, 1344, 806},
+       /* { 12, 5, 896, 510,1344, 806}, // alan 09/12/2003 */
+       {48, 25, 1536, 369, 1344, 806},
+       /* { 32, 15,1008, 505,1344, 806}, // alan 09/12/2003 */
+       {42, 25, 1536, 419, 1344, 806},
+       /* { 32, 15,1008, 514,1344, 806}, // alan 09/12/2003 */
+       {48, 25, 1536, 369, 1344, 806},
+       {12, 5,  896,  500, 1344, 806},
+       {42, 25, 1024, 625, 1344, 806},
+       {1,  1,  1344, 806, 1344, 806},
+       {12, 5,  896,  500, 1344, 806},
+       {42, 25, 1024, 625, 1344, 806},
+       {1,  1,  1344, 806, 1344, 806},
+       {12, 5,  896,  500, 1344, 806},
+       {42, 25, 1024, 625, 1344, 806},
+       {1,  1,  1344, 806, 1344, 806}
+};
+
+/*struct XGI330_LCDDataStruct  XGI_St2LCD1024x768Data[] = {
+       {62,  25, 800,  546, 1344, 806},
+       {32,  15, 930,  546, 1344, 806},
+       {62,  25, 800,  546, 1344, 806},
+       {104, 45, 945,  496, 1344, 806},
+       {62,  25, 800,  546, 1344, 806},
+       {31,  18, 1008, 624, 1344, 806},
+       {1,   1,  1344, 806, 1344, 806}
 };*/
 
-static struct XGI330_LCDDataStruct  XGI_CetLCD1024x768Data[] =
-{
-       {         1,1,1344,806,1344,806           }, /* ; 00 (320x200,320x400,640x200,640x400) */
-        {         1,1,1344,806,1344,806           }, /* 01 (320x350,640x350) */
-        {         1,1,1344,806,1344,806           }, /* 02 (360x400,720x400) */
-        {         1,1,1344,806,1344,806           }, /* 03 (720x350) */
-        {         1,1,1344,806,1344,806           }, /* 04 (640x480x60Hz) */
-        {         1,1,1344,806,1344,806           }, /* 05 (800x600x60Hz) */
-        {         1,1,1344,806,1344,806           }  /* 06 (1024x768x60Hz) */
-};
-
-static struct XGI330_LCDDataStruct  XGI_StLCD1280x1024Data[] =
-{
- {   22,   5, 800, 510,1650,1088},
- {   22,   5, 800, 510,1650,1088},
- {  176,  45, 900, 510,1650,1088},
- {  176,  45, 900, 510,1650,1088},
- {   22,   5, 800, 510,1650,1088},
- {   13,   5,1024, 675,1560,1152},
- {   16,   9,1266, 804,1688,1072},
- {    1,   1,1688,1066,1688,1066}
-};
-
-static struct XGI330_LCDDataStruct  XGI_ExtLCD1280x1024Data[] =
-{
- {  211,  60,1024, 501,1688,1066},
- {  211,  60,1024, 508,1688,1066},
- {  211,  60,1024, 501,1688,1066},
- {  211,  60,1024, 508,1688,1066},
- {  211,  60,1024, 500,1688,1066},
- {  211,  75,1024, 625,1688,1066},
- {  211, 120,1280, 798,1688,1066},
- {    1,   1,1688,1066,1688,1066}
+static struct XGI330_LCDDataStruct  XGI_CetLCD1024x768Data[] = {
+       {1, 1, 1344, 806, 1344, 806}, /* ; 00 (320x200,320x400,
+                                              640x200,640x400) */
+       {1, 1, 1344, 806, 1344, 806}, /* 01 (320x350,640x350) */
+       {1, 1, 1344, 806, 1344, 806}, /* 02 (360x400,720x400) */
+       {1, 1, 1344, 806, 1344, 806}, /* 03 (720x350) */
+       {1, 1, 1344, 806, 1344, 806}, /* 04 (640x480x60Hz) */
+       {1, 1, 1344, 806, 1344, 806}, /* 05 (800x600x60Hz) */
+       {1, 1, 1344, 806, 1344, 806}  /* 06 (1024x768x60Hz) */
+};
+
+static struct XGI330_LCDDataStruct  XGI_StLCD1280x1024Data[] = {
+       {22,  5,  800,  510,  1650, 1088},
+       {22,  5,  800,  510,  1650, 1088},
+       {176, 45, 900,  510,  1650, 1088},
+       {176, 45, 900,  510,  1650, 1088},
+       {22,  5,  800,  510,  1650, 1088},
+       {13,  5,  1024, 675,  1560, 1152},
+       {16,  9,  1266, 804,  1688, 1072},
+       {1,   1,  1688, 1066, 1688, 1066}
+};
+
+static struct XGI330_LCDDataStruct  XGI_ExtLCD1280x1024Data[] = {
+       {211, 60,  1024, 501,  1688, 1066},
+       {211, 60,  1024, 508,  1688, 1066},
+       {211, 60,  1024, 501,  1688, 1066},
+       {211, 60,  1024, 508,  1688, 1066},
+       {211, 60,  1024, 500,  1688, 1066},
+       {211, 75,  1024, 625,  1688, 1066},
+       {211, 120, 1280, 798,  1688, 1066},
+       {1,   1,   1688, 1066, 1688, 1066}
 };
 
 #if 0
-static struct XGI330_LCDDataStruct  XGI_St2LCD1280x1024Data[] =
-{
- {   22,   5, 800, 510,1650,1088},
- {   22,   5, 800, 510,1650,1088},
- {  176,  45, 900, 510,1650,1088},
- {  176,  45, 900, 510,1650,1088},
- {   22,   5, 800, 510,1650,1088},
- {   13,   5,1024, 675,1560,1152},
- {   16,   9,1266, 804,1688,1072},
- {    1,   1,1688,1066,1688,1066}
+static struct XGI330_LCDDataStruct  XGI_St2LCD1280x1024Data[] = {
+       {22,  5,  800,  510,  1650, 1088},
+       {22,  5,  800,  510,  1650, 1088},
+       {176, 45, 900,  510,  1650, 1088},
+       {176, 45, 900,  510,  1650, 1088},
+       {22,  5,  800,  510,  1650, 1088},
+       {13,  5,  1024, 675,  1560, 1152},
+       {16,  9,  1266, 804,  1688, 1072},
+       {1,   1,  1688, 1066, 1688, 1066}
 };
 #endif
 
-static struct XGI330_LCDDataStruct  XGI_CetLCD1280x1024Data[] =
-{
-       {         1,1,1688,1066,1688,1066         }, /* 00 (320x200,320x400,640x200,640x400) */
-        {         1,1,1688,1066,1688,1066         }, /* 01 (320x350,640x350) */
-        {         1,1,1688,1066,1688,1066         }, /* 02 (360x400,720x400) */
-        {         1,1,1688,1066,1688,1066         }, /* 03 (720x350) */
-        {         1,1,1688,1066,1688,1066         }, /* 04 (640x480x60Hz) */
-        {         1,1,1688,1066,1688,1066         }, /* 05 (800x600x60Hz) */
-        {         1,1,1688,1066,1688,1066         }, /* 06 (1024x768x60Hz) */
-        {         1,1,1688,1066,1688,1066         }, /* 07 (1280x1024x60Hz) */
-        {         1,1,1688,1066,1688,1066         } /* 08 (1400x1050x60Hz) */
-};
-
-static struct XGI330_LCDDataStruct  XGI_StLCD1400x1050Data[] =
-{
-       {         211,100,2100,408,1688,1066      }, /* 00 (320x200,320x400,640x200,640x400) */
-        {         211,64,1536,358,1688,1066       }, /* 01 (320x350,640x350) */
-        {         211,100,2100,408,1688,1066      }, /* 02 (360x400,720x400) */
-        {         211,64,1536,358,1688,1066       }, /* 03 (720x350) */
-        {         211,48,840,488,1688,1066        }, /* 04 (640x480x60Hz) */
-        {         211,72,1008,609,1688,1066       }, /* 05 (800x600x60Hz) */
-        {         211,128,1400,776,1688,1066      }, /* 06 (1024x768x60Hz) */
-        {         1,1,1688,1066,1688,1066         }, /* 07 (1280x1024x60Hz w/o Scaling) */
-        {         1,1,1688,1066,1688,1066         }  /* 08 (1400x1050x60Hz) */
-};
-
-static struct XGI330_LCDDataStruct  XGI_ExtLCD1400x1050Data[] =
-{
-       {         211,100,2100,408,1688,1066      }, /* 00 (320x200,320x400,640x200,640x400) */
-        {         211,64,1536,358,1688,1066       }, /* 01 (320x350,640x350) */
-        {         211,100,2100,408,1688,1066      }, /* 02 (360x400,720x400) */
-        {         211,64,1536,358,1688,1066       }, /* 03 (720x350) */
-        {         211,48,840,488,1688,1066        }, /* 04 (640x480x60Hz) */
-        {         211,72,1008,609,1688,1066       }, /* 05 (800x600x60Hz) */
-        {         211,128,1400,776,1688,1066      }, /* 06 (1024x768x60Hz) */
-        {         1,1,1688,1066,1688,1066         }, /* 07 (1280x1024x60Hz w/o Scaling) */
-        {         1,1,1688,1066,1688,1066         }  /* 08 (1400x1050x60Hz) */
-};
-
-static struct XGI330_LCDDataStruct  XGI_ExtLCD1600x1200Data[] =
-{
-        {         4,1,1620,420,2160,1250          }, /* { 3,1,2160,425,2160,1250 }, // 00 (320x200,320x400,640x200,640x400) // alan 10/14/2003 */
-        {         27,7,1920,375,2160,1250         }, /* 01 (320x350,640x350) */
-        {         4,1,1620,420,2160,1250          }, /* { 3,1,2160,425,2160,1250 }, // 02 (360x400,720x400) // alan 10/14/2003 */
-        {         27,7,1920,375,2160,1250         }, /* 03 (720x350) */
-        {         27,4,800,500,2160,1250          }, /* 04 (640x480x60Hz) */
-        {         4,1,1080,625,2160,1250          }, /* 05 (800x600x60Hz) */
-        {         5,2,1350,800,2160,1250          }, /* 06 (1024x768x60Hz) */
-        {         27,16,1500,1064,2160,1250       }, /* 07 (1280x1024x60Hz) */
-        {         9,7,1920,1106,2160,1250         }, /* 08 (1400x1050x60Hz) */
-        {         1,1,2160,1250,2160,1250         }  /* 09 (1600x1200x60Hz) ;302lv */
-};
-
-static struct XGI330_LCDDataStruct  XGI_StLCD1600x1200Data[] =
-{
-        {         27,4,800,500,2160,1250          },/* 00 (320x200,320x400,640x200,640x400) */
-        {         27,4,800,500,2160,1250          },/* 01 (320x350,640x350) */
-        {         27,4,800,500,2160,1250          },/* 02 (360x400,720x400) */
-        {         27,4,800,500,2160,1250          },/* 03 (720x350) */
-        {         27,4,800,500,2160,1250          },/* 04 (320x240,640x480) */
-        {         4,1,1080,625,2160,1250          },/* 05 (400x300,800x600) */
-        {         5,2,1350,800,2160,1250          },/* 06 (512x384,1024x768) */
-        {         135,88,1600,1100,2160,1250      },/* 07 (1280x1024) */
-        {         1,1,1800,1500,2160,1250         },/* 08 (1400x1050) */
-        {         1,1,2160,1250,2160,1250         } /* 09 (1600x1200) */
-};
-
-static struct XGI330_LCDDataStruct  XGI_CetLCD1400x1050Data[] =
-{
-       {         1,1,1688,1066,1688,1066         }, /* 00 (320x200,320x400,640x200,640x400) */
-        {         1,1,1688,1066,1688,1066         }, /* 01 (320x350,640x350) */
-        {         1,1,1688,1066,1688,1066         }, /* 02 (360x400,720x400) */
-        {         1,1,1688,1066,1688,1066         }, /* 03 (720x350) */
-        {         1,1,1688,1066,1688,1066         }, /* 04 (640x480x60Hz) */
-        {         1,1,1688,1066,1688,1066         }, /* 05 (800x600x60Hz) */
-        {         1,1,1688,1066,1688,1066         }, /* 06 (1024x768x60Hz) */
-        {         1,1,1688,1066,1688,1066         }, /* 07 (1280x1024x60Hz) */
-        {         1,1,1688,1066,1688,1066         }  /* 08 (1400x1050x60Hz) */
-};
-
-static struct XGI330_LCDDataStruct  XGI_NoScalingData[] =
-{
- {    1,   1, 800, 449, 800, 449},
- {    1,   1, 800, 449, 800, 449},
- {    1,   1, 900, 449, 900, 449},
- {    1,   1, 900, 449, 900, 449},
- {    1,   1, 800, 525, 800, 525},
- {    1,   1,1056, 628,1056, 628},
- {    1,   1,1344, 806,1344, 806},
- {    1,   1,1688,1066,1688,1066}
-};
-
-static struct XGI330_LCDDataStruct  XGI_ExtLCD1024x768x75Data[] =
-{
-        {42,25,1536,419,1344,806 }, /* ; 00 (320x200,320x400,640x200,640x400) */
-        {48,25,1536,369,1344,806 }, /* ; 01 (320x350,640x350) */
-        {42,25,1536,419,1344,806 }, /* ; 02 (360x400,720x400) */
-        {48,25,1536,369,1344,806 }, /* ; 03 (720x350) */
-        {8,5,1312,500,1312,800   }, /* ; 04 (640x480x75Hz) */
-        {41,25,1024,625,1312,800 }, /* ; 05 (800x600x75Hz) */
-        {1,1,1312,800,1312,800   }  /* ; 06 (1024x768x75Hz) */
+static struct XGI330_LCDDataStruct  XGI_CetLCD1280x1024Data[] = {
+       {1, 1, 1688, 1066, 1688, 1066}, /* 00 (320x200,320x400,
+                                              640x200,640x400) */
+       {1, 1, 1688, 1066, 1688, 1066}, /* 01 (320x350,640x350) */
+       {1, 1, 1688, 1066, 1688, 1066}, /* 02 (360x400,720x400) */
+       {1, 1, 1688, 1066, 1688, 1066}, /* 03 (720x350) */
+       {1, 1, 1688, 1066, 1688, 1066}, /* 04 (640x480x60Hz) */
+       {1, 1, 1688, 1066, 1688, 1066}, /* 05 (800x600x60Hz) */
+       {1, 1, 1688, 1066, 1688, 1066}, /* 06 (1024x768x60Hz) */
+       {1, 1, 1688, 1066, 1688, 1066}, /* 07 (1280x1024x60Hz) */
+       {1, 1, 1688, 1066, 1688, 1066}  /* 08 (1400x1050x60Hz) */
+};
+
+static struct XGI330_LCDDataStruct  XGI_StLCD1400x1050Data[] = {
+       {211, 100, 2100, 408,  1688, 1066}, /* 00 (320x200,320x400,
+                                                  640x200,640x400) */
+       {211, 64,  1536, 358,  1688, 1066}, /* 01 (320x350,640x350) */
+       {211, 100, 2100, 408,  1688, 1066}, /* 02 (360x400,720x400) */
+       {211, 64,  1536, 358,  1688, 1066}, /* 03 (720x350) */
+       {211, 48,  840,  488,  1688, 1066}, /* 04 (640x480x60Hz) */
+       {211, 72,  1008, 609,  1688, 1066}, /* 05 (800x600x60Hz) */
+       {211, 128, 1400, 776,  1688, 1066}, /* 06 (1024x768x60Hz) */
+       {1,   1,   1688, 1066, 1688, 1066}, /* 07 (1280x1024x60Hz
+                                                 w/o Scaling) */
+       {1,   1,   1688, 1066, 1688, 1066}  /* 08 (1400x1050x60Hz) */
+};
+
+static struct XGI330_LCDDataStruct  XGI_ExtLCD1400x1050Data[] = {
+       {211, 100, 2100, 408,  1688, 1066}, /* 00 (320x200,320x400,
+                                                  640x200,640x400) */
+       {211, 64,  1536, 358,  1688, 1066}, /* 01 (320x350,640x350) */
+       {211, 100, 2100, 408,  1688, 1066}, /* 02 (360x400,720x400) */
+       {211, 64,  1536, 358,  1688, 1066}, /* 03 (720x350) */
+       {211, 48,  840,  488,  1688, 1066}, /* 04 (640x480x60Hz) */
+       {211, 72,  1008, 609,  1688, 1066}, /* 05 (800x600x60Hz) */
+       {211, 128, 1400, 776,  1688, 1066}, /* 06 (1024x768x60Hz) */
+       {1,   1,   1688, 1066, 1688, 1066}, /* 07 (1280x1024x60Hz
+                                                 w/o Scaling) */
+       {1,   1,   1688, 1066, 1688, 1066}  /* 08 (1400x1050x60Hz) */
+};
+
+static struct XGI330_LCDDataStruct  XGI_ExtLCD1600x1200Data[] = {
+       {4,  1,  1620, 420,  2160, 1250}, /* { 3,1,2160,425,2160,1250 },
+                                         // 00 (320x200,320x400,
+                                         //     640x200,640x400)
+                                         //     // alan 10/14/2003 */
+       {27, 7,  1920, 375,  2160, 1250}, /* 01 (320x350,640x350) */
+       {4,  1,  1620, 420,  2160, 1250}, /* { 3,1,2160,425,2160,1250 },
+                                         // 02 (360x400,720x400)
+                                         // // alan 10/14/2003 */
+       {27, 7,  1920, 375,  2160, 1250}, /* 03 (720x350) */
+       {27, 4,  800,  500,  2160, 1250}, /* 04 (640x480x60Hz) */
+       {4,  1,  1080, 625,  2160, 1250}, /* 05 (800x600x60Hz) */
+       {5,  2,  1350, 800,  2160, 1250}, /* 06 (1024x768x60Hz) */
+       {27, 16, 1500, 1064, 2160, 1250}, /* 07 (1280x1024x60Hz) */
+       {9,  7,  1920, 1106, 2160, 1250}, /* 08 (1400x1050x60Hz) */
+       {1,  1,  2160, 1250, 2160, 1250}  /* 09 (1600x1200x60Hz) ;302lv */
+};
+
+static struct XGI330_LCDDataStruct  XGI_StLCD1600x1200Data[] = {
+       {27,  4,  800,  500,  2160, 1250}, /* 00 (320x200,320x400,
+                                                 640x200,640x400) */
+       {27,  4,  800,  500,  2160, 1250}, /* 01 (320x350,640x350) */
+       {27,  4,  800,  500,  2160, 1250}, /* 02 (360x400,720x400) */
+       {27,  4,  800,  500,  2160, 1250}, /* 03 (720x350) */
+       {27,  4,  800,  500,  2160, 1250}, /* 04 (320x240,640x480) */
+       {4,   1,  1080, 625,  2160, 1250}, /* 05 (400x300,800x600) */
+       {5,   2,  1350, 800,  2160, 1250}, /* 06 (512x384,1024x768) */
+       {135, 88, 1600, 1100, 2160, 1250}, /* 07 (1280x1024) */
+       {1,   1,  1800, 1500, 2160, 1250}, /* 08 (1400x1050) */
+       {1,   1,  2160, 1250, 2160, 1250}  /* 09 (1600x1200) */
+};
+
+static struct XGI330_LCDDataStruct  XGI_CetLCD1400x1050Data[] = {
+       {1, 1, 1688, 1066, 1688, 1066}, /* 00 (320x200,320x400,
+                                              640x200,640x400) */
+       {1, 1, 1688, 1066, 1688, 1066}, /* 01 (320x350,640x350) */
+       {1, 1, 1688, 1066, 1688, 1066}, /* 02 (360x400,720x400) */
+       {1, 1, 1688, 1066, 1688, 1066}, /* 03 (720x350) */
+       {1, 1, 1688, 1066, 1688, 1066}, /* 04 (640x480x60Hz) */
+       {1, 1, 1688, 1066, 1688, 1066}, /* 05 (800x600x60Hz) */
+       {1, 1, 1688, 1066, 1688, 1066}, /* 06 (1024x768x60Hz) */
+       {1, 1, 1688, 1066, 1688, 1066}, /* 07 (1280x1024x60Hz) */
+       {1, 1, 1688, 1066, 1688, 1066}  /* 08 (1400x1050x60Hz) */
+};
+
+static struct XGI330_LCDDataStruct  XGI_NoScalingData[] = {
+       {1, 1, 800,  449,  800,  449},
+       {1, 1, 800,  449,  800,  449},
+       {1, 1, 900,  449,  900,  449},
+       {1, 1, 900,  449,  900,  449},
+       {1, 1, 800,  525,  800,  525},
+       {1, 1, 1056, 628,  1056, 628},
+       {1, 1, 1344, 806,  1344, 806},
+       {1, 1, 1688, 1066, 1688, 1066}
+};
+
+static struct XGI330_LCDDataStruct  XGI_ExtLCD1024x768x75Data[] = {
+       {42, 25, 1536, 419, 1344, 806}, /* ; 00 (320x200,320x400,
+                                                640x200,640x400) */
+       {48, 25, 1536, 369, 1344, 806}, /* ; 01 (320x350,640x350) */
+       {42, 25, 1536, 419, 1344, 806}, /* ; 02 (360x400,720x400) */
+       {48, 25, 1536, 369, 1344, 806}, /* ; 03 (720x350) */
+       {8,  5,  1312, 500, 1312, 800}, /* ; 04 (640x480x75Hz) */
+       {41, 25, 1024, 625, 1312, 800}, /* ; 05 (800x600x75Hz) */
+       {1,  1,  1312, 800, 1312, 800}  /* ; 06 (1024x768x75Hz) */
 };
 
 #if 0
-static struct XGI330_LCDDataStruct  XGI_StLCD1024x768x75Data[] =
-{
-        {42,25,1536,419,1344,806 }, /* ; 00 (320x200,320x400,640x200,640x400) */
-        {48,25,1536,369,1344,806 }, /* ; 01 (320x350,640x350) */
-        {42,25,1536,419,1344,806 }, /* ; 02 (360x400,720x400) */
-        {48,25,1536,369,1344,806 }, /* ; 03 (720x350) */
-        {8,5,1312,500,1312,800   }, /* ; 04 (640x480x75Hz) */
-        {41,25,1024,625,1312,800 }, /* ; 05 (800x600x75Hz) */
-        {1,1,1312,800,1312,800   }  /* ; 06 (1024x768x75Hz) */
+static struct XGI330_LCDDataStruct  XGI_StLCD1024x768x75Data[] = {
+       {42, 25, 1536, 419, 1344, 806}, /* ; 00 (320x200,320x400,
+                                                640x200,640x400) */
+       {48, 25, 1536, 369, 1344, 806}, /* ; 01 (320x350,640x350) */
+       {42, 25, 1536, 419, 1344, 806}, /* ; 02 (360x400,720x400) */
+       {48, 25, 1536, 369, 1344, 806}, /* ; 03 (720x350) */
+       {8,  5,  1312, 500, 1312, 800}, /* ; 04 (640x480x75Hz) */
+       {41, 25, 1024, 625, 1312, 800}, /* ; 05 (800x600x75Hz) */
+       {1,  1,  1312, 800, 1312, 800}  /* ; 06 (1024x768x75Hz) */
 };
 #endif
 
-static struct XGI330_LCDDataStruct  XGI_CetLCD1024x768x75Data[] =
-{
-        {1,1,1312,800,1312,800}, /* ; 00 (320x200,320x400,640x200,640x400) */
-        {1,1,1312,800,1312,800}, /* ; 01 (320x350,640x350) */
-        {1,1,1312,800,1312,800}, /* ; 02 (360x400,720x400) */
-        {1,1,1312,800,1312,800}, /* ; 03 (720x350) */
-        {1,1,1312,800,1312,800}, /* ; 04 (640x480x75Hz) */
-        {1,1,1312,800,1312,800}, /* ; 05 (800x600x75Hz) */
-        {1,1,1312,800,1312,800} /* ; 06 (1024x768x75Hz) */
-};
-
-static struct XGI330_LCDDataStruct  XGI_ExtLCD1280x1024x75Data[] =
-{
-        {211,60,1024,501,1688,1066   }, /* ; 00 (320x200,320x400,640x200,640x400) */
-        {211,60,1024,508,1688,1066   }, /* ; 01 (320x350,640x350) */
-        {211,60,1024,501,1688,1066   }, /* ; 02 (360x400,720x400) */
-        {211,60,1024,508,1688,1066   }, /* ; 03 (720x350) */
-        {211,45,768,498,1688,1066    }, /* ; 04 (640x480x75Hz) */
-        {211,75,1024,625,1688,1066   }, /* ; 05 (800x600x75Hz) */
-        {211,120,1280,798,1688,1066  }, /* ; 06 (1024x768x75Hz) */
-        {1,1,1688,1066,1688,1066     }  /* ; 07 (1280x1024x75Hz) */
-};
-
-static struct XGI330_LCDDataStruct  XGI_StLCD1280x1024x75Data[] =
-{
-        {211,60,1024,501,1688,1066 }, /* ; 00 (320x200,320x400,640x200,640x400) */
-        {211,60,1024,508,1688,1066 }, /* ; 01 (320x350,640x350) */
-        {211,60,1024,501,1688,1066 }, /* ; 02 (360x400,720x400) */
-        {211,60,1024,508,1688,1066 }, /* ; 03 (720x350) */
-        {211,45,768,498,1688,1066  }, /* ; 04 (640x480x75Hz) */
-        {211,75,1024,625,1688,1066 }, /* ; 05 (800x600x75Hz) */
-        {211,120,1280,798,1688,1066}, /* ; 06 (1024x768x75Hz) */
-        {1,1,1688,1066,1688,1066   }  /* ; 07 (1280x1024x75Hz) */
-};
-
-static struct XGI330_LCDDataStruct  XGI_CetLCD1280x1024x75Data[] =
-{
-        {1,1,1688,1066,1688,1066}, /* ; 00 (320x200,320x400,640x200,640x400) */
-        {1,1,1688,1066,1688,1066}, /* ; 01 (320x350,640x350) */
-        {1,1,1688,1066,1688,1066}, /* ; 02 (360x400,720x400) */
-        {1,1,1688,1066,1688,1066}, /* ; 03 (720x350) */
-        {1,1,1688,1066,1688,1066}, /* ; 04 (640x480x75Hz) */
-        {1,1,1688,1066,1688,1066}, /* ; 05 (800x600x75Hz) */
-        {1,1,1688,1066,1688,1066}, /* ; 06 (1024x768x75Hz) */
-        {1,1,1688,1066,1688,1066}  /* ; 07 (1280x1024x75Hz) */
-};
-
-static struct XGI330_LCDDataStruct  XGI_NoScalingDatax75[] =
-{
-        {1,1,800,449,800,449    }, /* ; 00 (320x200,320x400,640x200,640x400) */
-        {1,1,800,449,800,449    }, /* ; 01 (320x350,640x350) */
-        {1,1,900,449,900,449    }, /* ; 02 (360x400,720x400) */
-        {1,1,900,449,900,449    }, /* ; 03 (720x350) */
-        {1,1,840,500,840,500    }, /* ; 04 (640x480x75Hz) */
-        {1,1,1056,625,1056,625  }, /* ; 05 (800x600x75Hz) */
-        {1,1,1312,800,1312,800  }, /* ; 06 (1024x768x75Hz) */
-        {1,1,1688,1066,1688,1066}, /* ; 07 (1280x1024x75Hz) */
-        {1,1,1688,1066,1688,1066}, /* ; 08 (1400x1050x75Hz) ;;[ycchen] 12/19/02 */
-        {1,1,2160,1250,2160,1250}, /* ; 09 (1600x1200x75Hz) */
-        {1,1,1688,806,1688,806  }  /* ; 0A (1280x768x75Hz) */
-};
-
-static struct XGI330_LCDDataDesStruct  XGI_ExtLCDDes1024x768Data[] =
-{
-   {  9,1057,0, 771  }, /* ; 00 (320x200,320x400,640x200,640x400) */
-   {  9,1057,0, 771  }, /* ; 01 (320x350,640x350) */
-   {  9,1057,0, 771  }, /* ; 02 (360x400,720x400) */
-   {  9,1057,0, 771  }, /* ; 03 (720x350) */
-   {  9,1057,0, 771  }, /* ; 04 (640x480x60Hz) */
-   {  9,1057,0, 771  }, /* ; 05 (800x600x60Hz) */
-   {  9,1057,805, 770  }  /* ; 06 (1024x768x60Hz) */
-};
-
-static struct XGI330_LCDDataDesStruct  XGI_StLCDDes1024x768Data[] =
-{
-        { 9,1057,737,703   }, /* ; 00 (320x200,320x400,640x200,640x400) */
-        { 9,1057,686,651   }, /* ; 01 (320x350,640x350) */
-        { 9,1057,737,703   }, /* ; 02 (360x400,720x400) */
-        { 9,1057,686,651   }, /* ; 03 (720x350) */
-        { 9,1057,776,741   }, /* ; 04 (640x480x60Hz) */
-        { 9,1057, 0 ,771   }, /* ; 05 (800x600x60Hz) */
-        { 9,1057,805,770   }  /* ; 06 (1024x768x60Hz) */
-};
-
-static struct XGI330_LCDDataDesStruct  XGI_CetLCDDes1024x768Data[] =
-{
-               {      1152,856,622,587   }, /* ; 00 (320x200,320x400,640x200,640x400) */
-        {      1152,856,597,562   }, /* ; 01 (320x350,640x350) */
-        {      1152,856,622,587   }, /* ; 02 (360x400,720x400) */
-        {      1152,856,597,562   }, /* ; 03 (720x350) */
-        {      1152,856,662,627   }, /* ; 04 (640x480x60Hz) */
-        {      1232,936,722,687   }, /* ; 05 (800x600x60Hz) */
-        {      0,1048,805,770   }  /* ; 06 (1024x768x60Hz) */
-};
-
-static struct XGI330_LCDDataDesStruct XGI_ExtLCDDLDes1280x1024Data[] =
-{
-        {      18,1346,981,940     },/* 00 (320x200,320x400,640x200,640x400) */
-        {      18,1346,926,865     },/* 01 (320x350,640x350) */
-        {      18,1346,981,940     },/* 02 (360x400,720x400) */
-        {      18,1346,926,865     },/* 03 (720x350) */
-        {      18,1346,0,1025     },/* 04 (640x480x60Hz) */
-        {      18,1346,0,1025     },/* 05 (800x600x60Hz) */
-        {      18,1346,1065,1024     },/* 06 (1024x768x60Hz) */
-        {      18,1346,1065,1024     }/* 07 (1280x1024x60Hz) */
-};
-
-static struct XGI330_LCDDataDesStruct XGI_StLCDDLDes1280x1024Data[] =
-{
-        {      18,1346,970,907     },/* 00 (320x200,320x400,640x200,640x400) */
-        {      18,1346,917,854     },/* 01 (320x350,640x350) */
-        {      18,1346,970,907     },/* 02 (360x400,720x400) */
-        {      18,1346,917,854     },/* 03 (720x350) */
-        {      18,1346,0,1025     },/* 04 (640x480x60Hz) */
-        {      18,1346,0,1025     },/* 05 (800x600x60Hz) */
-        {      18,1346,1065,1024     },/* 06 (1024x768x60Hz) */
-        {      18,1346,1065,1024     }/* 07 (1280x1024x60Hz) */
-};
-
-static struct XGI330_LCDDataDesStruct  XGI_CetLCDDLDes1280x1024Data[] =
-{
-        {      1368,1008,752,711    }, /* 00 (320x200,320x400,640x200,640x400) */
-        {      1368,1008,729,688    }, /* 01 (320x350,640x350) */
-        {      1368,1008,752,711    }, /* 02 (360x400,720x400) */
-       {      1368,1008,729,688    }, /* 03 (720x350) */
-        {      1368,1008,794,753    }, /* 04 (640x480x60Hz) */
-        {      1448,1068,854,813    }, /* 05 (800x600x60Hz) */
-        {      1560,1200,938,897    }, /* 06 (1024x768x60Hz) */
-        {      18,1346,1065,1024    }  /* 07 (1280x1024x60Hz) */
-};
-
-static struct XGI330_LCDDataDesStruct  XGI_ExtLCDDes1280x1024Data[] =
-{
-        {      9,1337,981,940    }, /* ; 00 (320x200,320x400,640x200,640x400) */
-        {      9,1337,926,884    }, /* ; 01 (320x350,640x350) alan, 2003/09/30 */
-        {      9,1337,981,940    }, /* ; 02 (360x400,720x400) */
-        {      9,1337,926,884    }, /* ; 03 (720x350) alan, 2003/09/30 */
-        {      9,1337,0,1025    }, /* ; 04 (640x480x60Hz) */
-        {      9,1337,0,1025    }, /* ; 05 (800x600x60Hz) */
-        {      9,1337,1065,1024    }, /* ; 06 (1024x768x60Hz) */
-        {      9,1337,1065,1024    }  /* ; 07 (1280x1024x60Hz) */
-};
-
-static struct XGI330_LCDDataDesStruct  XGI_StLCDDes1280x1024Data[] =
-{
-        {      9,1337,970,907    }, /* ; 00 (320x200,320x400,640x200,640x400) */
-        {      9,1337,917,854    }, /* ; 01 (320x350,640x350) */
-        {      9,1337,970,907    }, /* ; 02 (360x400,720x400) */
-        {      9,1337,917,854    }, /* ; 03 (720x350) */
-        {      9,1337,0,1025    }, /* ; 04 (640x480x60Hz) */
-        {      9,1337,0,1025    }, /* ; 05 (800x600x60Hz) */
-        {      9,1337,1065,1024    }, /* ; 06 (1024x768x60Hz) */
-        {      9,1337,1065,1024    }  /* ; 07 (1280x1024x60Hz) */
-};
-
-static struct XGI330_LCDDataDesStruct  XGI_CetLCDDes1280x1024Data[] =
-{
-        {      1368,1008,752,711    }, /* 00 (320x200,320x400,640x200,640x400) */
-        {      1368,1008,729,688    }, /* 01 (320x350,640x350) */
-        {      1368,1008,752,711    }, /* 02 (360x400,720x400) */
-       {      1368,1008,729,688    }, /* 03 (720x350) */
-        {      1368,1008,794,753    }, /* 04 (640x480x60Hz) */
-        {      1448,1068,854,813    }, /* 05 (800x600x60Hz) */
-        {      1560,1200,938,897    }, /* 06 (1024x768x60Hz) */
-        {      9,1337,1065,1024    }  /* 07 (1280x1024x60Hz) */
-};
-
-static struct XGI330_LCDDataDesStruct  XGI_StLCDDLDes1400x1050Data[] =
-{
-        {      18,1464,0,1051    }, /* 00 (320x200,320x400,640x200,640x400) */
-        {      18,1464,0,1051    }, /* 01 (320x350,640x350) */
-        {      18,1464,0,1051    }, /* 02 (360x400,720x400) */
-        {      18,1464,0,1051    }, /* 03 (720x350) */
-        {      18,1464,0,1051    }, /* 04 (640x480x60Hz) */
-        {      18,1464,0,1051    }, /* 05 (800x600x60Hz) */
-        {      18,1464,0,1051    }, /* 06 (1024x768x60Hz) */
-        {      1646,1406,1053,1038    }, /* 07 (1280x1024x60Hz) */
-        {      18,1464,0,1051    }  /* 08 (1400x1050x60Hz) */
-};
-
-static struct XGI330_LCDDataDesStruct  XGI_ExtLCDDLDes1400x1050Data[] =
-{
-        {      18,1464,0,1051    }, /* 00 (320x200,320x400,640x200,640x400) */
-        {      18,1464,0,1051    }, /* 01 (320x350,640x350) */
-        {      18,1464,0,1051    }, /* 02 (360x400,720x400) */
-        {      18,1464,0,1051    }, /* 03 (720x350) */
-        {      18,1464,0,1051    }, /* 04 (640x480x60Hz) */
-        {      18,1464,0,1051    }, /* 05 (800x600x60Hz) */
-        {      18,1464,0,1051    }, /* 06 (1024x768x60Hz) */
-        {      1646,1406,1053,1038    }, /* 07 (1280x1024x60Hz) */
-        {      18,1464,0,1051    }  /* 08 (1400x1050x60Hz) */
-};
-
-static struct XGI330_LCDDataDesStruct  XGI_StLCDDes1400x1050Data[] =
-{
-        {      9,1455,0,1051     },/* 00 (320x200,320x400,640x200,640x400) */
-        {      9,1455,0,1051     },/* 01 (320x350,640x350) */
-        {      9,1455,0,1051     },/* 02 (360x400,720x400) */
-        {      9,1455,0,1051     },/* 03 (720x350) */
-        {      9,1455,0,1051     },/* 04 (640x480x60Hz) */
-        {      9,1455,0,1051     },/* 05 (800x600x60Hz) */
-        {      9,1455,0,1051     },/* 06 (1024x768x60Hz) */
-        {      1637,1397,1053,1038     },/* 07 (1280x1024x60Hz) */
-        {      9,1455,0,1051     } /* 08 (1400x1050x60Hz) */
-};
-
-static struct XGI330_LCDDataDesStruct  XGI_ExtLCDDes1400x1050Data[] =
-{
-        {      9,1455,0,1051     },/* 00 (320x200,320x400,640x200,640x400) */
-        {      9,1455,0,1051     },/* 01 (320x350,640x350) */
-        {      9,1455,0,1051     },/* 02 (360x400,720x400) */
-        {      9,1455,0,1051     },/* 03 (720x350) */
-        {      9,1455,0,1051     },/* 04 (640x480x60Hz) */
-        {      9,1455,0,1051     },/* 05 (800x600x60Hz) */
-        {      9,1455,0,1051     },/* 06 (1024x768x60Hz) */
-        {      1637,1397,1053,1038     },/* 07 (1280x1024x60Hz) */
-        {      9,1455,0,1051     } /* 08 (1400x1050x60Hz) */
-};
-
-static struct XGI330_LCDDataDesStruct  XGI_CetLCDDes1400x1050Data[] =
-{
-        {      1308,1068,781,766    }, /* 00 (320x200,320x400,640x200,640x400) */
-        {      1308,1068,781,766    }, /* 01 (320x350,640x350) */
-        {      1308,1068,781,766    }, /* 02 (360x400,720x400) */
-        {      1308,1068,781,766    }, /* 03 (720x350) */
-        {      1308,1068,781,766    }, /* 04 (640x480x60Hz) */
-        {      1388,1148,841,826    }, /* 05 (800x600x60Hz) */
-        {      1490,1250,925,910    }, /* 06 (1024x768x60Hz) */
-        {      1646,1406,1053,1038    }, /* 07 (1280x1024x60Hz) */
-        {      18,1464,0,1051    } /* 08 (1400x1050x60Hz) */
-};
-
-static struct XGI330_LCDDataDesStruct  XGI_CetLCDDes1400x1050Data2[] =
-{
-        {      0,1448,0,1051    }, /* 00 (320x200,320x400,640x200,640x400) */
-        {      0,1448,0,1051    }, /* 01 (320x350,640x350) */
-        {      0,1448,0,1051    }, /* 02 (360x400,720x400) */
-        {      0,1448,0,1051    }, /* 03 (720x350) */
-        {      0,1448,0,1051    }  /* 04 (640x480x60Hz) */
-};
-
-
-
-static struct XGI330_LCDDataDesStruct  XGI_ExtLCDDLDes1600x1200Data[] =
-{
-       {      18,1682,0,1201    }, /* 00 (320x200,320x400,640x200,640x400) */
-        {      18,1682,0,1201    }, /* 01 (320x350,640x350) */
-        {      18,1682,0,1201    }, /* 02 (360x400,720x400) */
-        {      18,1682,0,1201    }, /* 03 (720x350) */
-        {      18,1682,0,1201    }, /* 04 (640x480x60Hz) */
-        {      18,1682,0,1201    }, /* 05 (800x600x60Hz) */
-        {      18,1682,0,1201    }, /* 06 (1024x768x60Hz) */
-        {      18,1682,0,1201    }, /* 07 (1280x1024x60Hz) */
-        {      18,1682,0,1201    }, /* 08 (1400x1050x60Hz) */
-        {      18,1682,0,1201    }  /* 09 (1600x1200x60Hz) */
-};
-
-static struct XGI330_LCDDataDesStruct  XGI_StLCDDLDes1600x1200Data[] =
-{
-        {      18,1682,1150,1101    }, /* 00 (320x200,320x400,640x200,640x400) */
-        {      18,1682,1083,1034    }, /* 01 (320x350,640x350) */
-        {      18,1682,1150,1101    }, /* 02 (360x400,720x400) */
-        {      18,1682,1083,1034    }, /* 03 (720x350) */
-        {      18,1682,0,1201    }, /* 04 (640x480x60Hz) */
-        {      18,1682,0,1201    }, /* 05 (800x600x60Hz) */
-        {      18,1682,0,1201    }, /* 06 (1024x768x60Hz) */
-        {      18,1682,1232,1183    }, /* 07 (1280x1024x60Hz) */
-        {      18,1682,0,1201    }, /* 08 (1400x1050x60Hz) */
-        {      18,1682,0,1201    } /* 09 (1600x1200x60Hz) */
-};
-
-static struct XGI330_LCDDataDesStruct  XGI_ExtLCDDes1600x1200Data[] =
-{
-        {      9,1673,0,1201     },/* 00 (320x200,320x400,640x200,640x400) */
-        {      9,1673,0,1201     },/* 01 (320x350,640x350) */
-        {      9,1673,0,1201     },/* 02 (360x400,720x400) */
-        {      9,1673,0,1201     },/* 03 (720x350) */
-        {      9,1673,0,1201     },/* 04 (640x480x60Hz) */
-        {      9,1673,0,1201     },/* 05 (800x600x60Hz) */
-        {      9,1673,0,1201     },/* 06 (1024x768x60Hz) */
-        {      9,1673,0,1201     },/* 07 (1280x1024x60Hz) */
-        {      9,1673,0,1201     },/* 08 (1400x1050x60Hz) */
-        {      9,1673,0,1201     } /* 09 (1600x1200x60Hz) */
-};
-
-static struct XGI330_LCDDataDesStruct  XGI_StLCDDes1600x1200Data[] =
-{
-       {      9,1673,1150,1101     },/* 00 (320x200,320x400,640x200,640x400) */
-        {      9,1673,1083,1034     },/* 01 (320x350,640x350) */
-        {      9,1673,1150,1101     },/* 02 (360x400,720x400) */
-        {      9,1673,1083,1034     },/* 03 (720x350) */
-        {      9,1673,0,1201     },/* 04 (640x480x60Hz) */
-        {      9,1673,0,1201     },/* 05 (800x600x60Hz) */
-        {      9,1673,0,1201     },/* 06 (1024x768x60Hz) */
-        {      9,1673,1232,1183     },/* 07 (1280x1024x60Hz) */
-        {      9,1673,0,1201     },/* 08 (1400x1050x60Hz) */
-        {      9,1673,0,1201     } /* 09 (1600x1200x60Hz) */
-};
-
-static struct XGI330_LCDDataDesStruct2  XGI_NoScalingDesData[] =
-{
-        {     9,657,448,405,96,2  }, /* 00 (320x200,320x400,640x200,640x400) */
-        {     9,657,448,355,96,2  }, /* 01 (320x350,640x350) */
-        {     9,657,448,405,96,2  }, /* 02 (360x400,720x400) */
-        {     9,657,448,355,96,2  }, /* 03 (720x350) */
-        {     9,657,1,483,96,2  }, /* 04 (640x480x60Hz) */
-        {     9,849,627,600,128,4  }, /* 05 (800x600x60Hz) */
-        {     9,1057,805,770,0136,6  }, /* 06 (1024x768x60Hz) */
-        {     9,1337,0,1025,112,3  }, /* 07 (1280x1024x60Hz) */
-        {     9,1457,0,1051,112,3  }, /* 08 (1400x1050x60Hz) }, //;[ycchen] 12/19/02 */
-        {     9,1673,0,1201,192,3  }, /* 09 (1600x1200x60Hz) */
-        {     9,1337,0,771,112,6  }  /* 0A (1280x768x60Hz) */
-};
-
-static struct XGI330_LCDDataDesStruct  XGI_ExtLCDDes1024x768x75Data[] =                /* ;;1024x768x75Hz */
-{
-        {9,1049,0,769},    /* ; 00 (320x200,320x400,640x200,640x400) */
-        {9,1049,0,769},    /* ; 01 (320x350,640x350) */
-        {9,1049,0,769},    /* ; 02 (360x400,720x400) */
-        {9,1049,0,769},    /* ; 03 (720x350) */
-        {9,1049,0,769},    /* ; 04 (640x480x75Hz) */
-        {9,1049,0,769},    /* ; 05 (800x600x75Hz) */
-        {9,1049,0,769}     /* ; 06 (1024x768x75Hz) */
-};
-
-static struct XGI330_LCDDataDesStruct  XGI_StLCDDes1024x768x75Data[] =
-{
-        {9,1049,0,769},    /* ; 00 (320x200,320x400,640x200,640x400) */
-        {9,1049,0,769},    /* ; 01 (320x350,640x350) */
-        {9,1049,0,769},    /* ; 02 (360x400,720x400) */
-        {9,1049,0,769},    /* ; 03 (720x350) */
-        {9,1049,0,769},    /* ; 04 (640x480x75Hz) */
-        {9,1049,0,769},    /* ; 05 (800x600x75Hz) */
-        {9,1049,0,769}     /* ; 06 (1024x768x75Hz) */
-};
-
-static struct XGI330_LCDDataDesStruct  XGI_CetLCDDes1024x768x75Data[] =        /* ;;1024x768x75Hz */
-{
-        {1152,856,622,587},     /* ; 00 (320x200,320x400,640x200,640x400) */
-        {1152,856,597,562},     /* ; 01 (320x350,640x350) */
-        {1192,896,622,587},     /* ; 02 (360x400,720x400) */
-        {1192,896,597,562},     /* ; 03 (720x350) */
-        {1129,857,656,625},     /* ; 04 (640x480x75Hz) */
-        {1209,937,716,685},     /* ; 05 (800x600x75Hz) */
-        {9,1049,0,769}                 /* ; 06 (1024x768x75Hz) */
-};
-
-static struct XGI330_LCDDataDesStruct  XGI_ExtLCDDLDes1280x1024x75Data[] =         /* ;;1280x1024x75Hz */
-{
-        {18,1314,0,1025     },/* ; 00 (320x200,320x400,640x200,640x400) */
-        {18,1314,0,1025     },/* ; 01 (320x350,640x350) */
-        {18,1314,0,1025     },/* ; 02 (360x400,720x400) */
-        {18,1314,0,1025     },/* ; 03 (720x350) */
-        {18,1314,0,1025     },/* ; 04 (640x480x60Hz) */
-        {18,1314,0,1025     },/* ; 05 (800x600x60Hz) */
-        {18,1314,0,1025     },/* ; 06 (1024x768x60Hz) */
-        {18,1314,0,1025     }/* ; 07 (1280x1024x60Hz) */
-};
-
-static struct XGI330_LCDDataDesStruct  XGI_StLCDDLDes1280x1024x75Data[] =
-{
-        {18,1314,0,1025     },/* ; 00 (320x200,320x400,640x200,640x400) */
-        {18,1314,0,1025     },/* ; 01 (320x350,640x350) */
-        {18,1314,0,1025     },/* ; 02 (360x400,720x400) */
-        {18,1314,0,1025     },/* ; 03 (720x350) */
-        {18,1314,0,1025     },/* ; 04 (640x480x60Hz) */
-        {18,1314,0,1025     },/* ; 05 (800x600x60Hz) */
-        {18,1314,0,1025     },/* ; 06 (1024x768x60Hz) */
-        {18,1314,0,1025     }/* ; 07 (1280x1024x60Hz) */
-};
-
-static struct XGI330_LCDDataDesStruct  XGI_CetLCDDLDes1280x1024x75Data[] =     /* 1280x1024x75Hz */
-{
-        {1368,1008,752,711},    /* ; 00 (320x200,320x400,640x200,640x400) */
-        {1368,1008,729,688},    /* ; 01 (320x350,640x350) */
-        {1408,1048,752,711},    /* ; 02 (360x400,720x400) */
-        {1408,1048,729,688},    /* ; 03 (720x350) */
-        {1377,985,794,753},    /* ; 04 (640x480x75Hz) */
-        {1457,1065,854,813},    /* ; 05 (800x600x75Hz) */
-        {1569,1177,938,897},    /* ; 06 (1024x768x75Hz) */
-        {18,1314,0,1025}         /* ; 07 (1280x1024x75Hz) */
-};
-
-static struct XGI330_LCDDataDesStruct  XGI_ExtLCDDes1280x1024x75Data[] =         /* ;;1280x1024x75Hz */
-{
-       {9,1305,0,1025},/* ; 00 (320x200,320x400,640x200,640x400) */
-        {9,1305,0,1025},/* ; 01 (320x350,640x350) */
-        {9,1305,0,1025},/* ; 02 (360x400,720x400) */
-        {9,1305,0,1025},/* ; 03 (720x350) */
-        {9,1305,0,1025},/* ; 04 (640x480x60Hz) */
-        {9,1305,0,1025},/* ; 05 (800x600x60Hz) */
-        {9,1305,0,1025},/* ; 06 (1024x768x60Hz) */
-        {9,1305,0,1025} /* ; 07 (1280x1024x60Hz) */
-};
-
-static struct XGI330_LCDDataDesStruct  XGI_StLCDDes1280x1024x75Data[] =
-{
-       {9,1305,0,1025},/* ; 00 (320x200,320x400,640x200,640x400) */
-        {9,1305,0,1025},/* ; 01 (320x350,640x350) */
-        {9,1305,0,1025},/* ; 02 (360x400,720x400) */
-        {9,1305,0,1025},/* ; 03 (720x350) */
-        {9,1305,0,1025},/* ; 04 (640x480x60Hz) */
-        {9,1305,0,1025},/* ; 05 (800x600x60Hz) */
-        {9,1305,0,1025},/* ; 06 (1024x768x60Hz) */
-        {9,1305,0,1025} /* ; 07 (1280x1024x60Hz) */
-};
-
-static struct XGI330_LCDDataDesStruct  XGI_CetLCDDes1280x1024x75Data[] =       /* 1280x1024x75Hz */
-{
-        {1368,1008,752,711},    /* ; 00 (320x200,320x400,640x200,640x400) */
-        {1368,1008,729,688},    /* ; 01 (320x350,640x350) */
-        {1408,1048,752,711},    /* ; 02 (360x400,720x400) */
-        {1408,1048,729,688},    /* ; 03 (720x350) */
-        {1377,985,794,753},    /* ; 04 (640x480x75Hz) */
-        {1457,1065,854,813},    /* ; 05 (800x600x75Hz) */
-        {1569,1177,938,897},    /* ; 06 (1024x768x75Hz) */
-        {9,1305,0,1025}          /* ; 07 (1280x1024x75Hz) */
-};
-
-static struct XGI330_LCDDataDesStruct2 XGI_NoScalingDesDatax75[] = /* Scaling LCD 75Hz */
-{
-       {9,657,448,405,96,2},   /* ; 00 (320x200,320x400,640x200,640x400) */
-        {9,657,448,355,96,2},   /* ; 01 (320x350,640x350) */
-        {9,738,448,405,108,2},   /* ; 02 (360x400,720x400) */
-        {9,738,448,355,108,2},   /* ; 03 (720x350) */
-        {9,665,0,481,64,3},   /* ; 04 (640x480x75Hz) */
-        {9,825,0,601,80,3},   /* ; 05 (800x600x75Hz) */
-        {9,1049,0,769,96,3},   /* ; 06 (1024x768x75Hz) */
-        {9,1305,0,1025,144,3},   /* ; 07 (1280x1024x75Hz) */
-        {9,1457,0,1051,112,3},   /* ; 08 (1400x1050x60Hz) ;;[ycchen] 12/19/02 */
-        {9,1673,0,1201,192,3},   /* ; 09 (1600x1200x75Hz) */
-        {9,1337,0,771,112,6}    /* ; 0A (1280x768x60Hz) */
-};
-
-static struct XGI330_TVDataStruct  XGI_StPALData[] =
-{
- {    1,   1, 864, 525,1270, 400, 100,   0, 760},
- {    1,   1, 864, 525,1270, 350, 100,   0, 760},
- {    1,   1, 864, 525,1270, 400,   0,   0, 720},
- {    1,   1, 864, 525,1270, 350,   0,   0, 720},
- {    1,   1, 864, 525,1270, 480,  50,   0, 760},
- {    1,   1, 864, 525,1270, 600,  50,   0,   0}
-};
-
-static struct XGI330_TVDataStruct  XGI_ExtPALData[] =
-{
- {    2,   1,1080, 463,1270, 500,  50,   0,  50},
- {   15,   7,1152, 413,1270, 500,  50,   0,  50},
- {    2,   1,1080, 463,1270, 500,  50,   0,  50},
- {   15,   7,1152, 413,1270, 500,  50,   0,  50},
- {    2,   1, 900, 543,1270, 500,   0,   0,  50},
- {    4,   3,1080, 663,1270, 500, 438,   0, 438},
- {    1,   1,1125, 831,1270, 500, 686,   0, 686},     /*301b*/
- {    3,   2,1080, 619,1270, 540, 438,   0, 438}
-};
-
-static struct XGI330_TVDataStruct  XGI_StNTSCData[] =
-{
- {    1,   1, 858, 525,1270, 400,  50,   0, 760},
- {    1,   1, 858, 525,1270, 350,  50,   0, 640},
- {    1,   1, 858, 525,1270, 400,   0,   0, 720},
- {    1,   1, 858, 525,1270, 350,   0,   0, 720},
- {    1,   1, 858, 525,1270, 480,   0,   0, 760}
-};
-
-static struct XGI330_TVDataStruct  XGI_ExtNTSCData[] =
-{
- {    9,  5, 1001, 453,1270, 420, 171,   0, 171},
- {   12,  5,  858, 403,1270, 420, 171,   0, 171},
- {    9,  5, 1001, 453,1270, 420, 171,   0, 171},
- {   12,  5,  858, 403,1270, 420, 171,   0, 171},
- {  143,  80, 836, 523,1270, 420, 224,   0,   0},
- {  143, 120,1008, 643,1270, 420,   0,   1,   0},
- {   1,    1,1120, 821,1516, 420,   0,   1,   0}, /*301b*/
- {    2,   1, 858, 503,1584, 480,   0,   1,   0},
- {    3,   2,1001, 533,1270, 420,   0,   0,   0}
-};
-
-static struct XGI330_TVDataStruct  XGI_St1HiTVData[] =
-{
-       {        1,1,892,563,690,800,0,0,0               }, /* 00 (320x200,320x400,640x200,640x400) */
-        {        1,1,892,563,690,700,0,0,0               }, /* 01 (320x350,640x350) */
-        {        1,1,1000,563,785,800,0,0,0              }, /* 02 (360x400,720x400) */
-        {        1,1,1000,563,785,700,0,0,0              }, /* 03 (720x350) */
-        {        1,1,892,563,690,960,0,0,0               }, /* 04 (320x240,640x480) */
-        {        8,5,1050,683,1648,960,0x150,1,0         }  /* 05 (400x300,800x600) */
-};
-
-static struct XGI330_TVDataStruct  XGI_St2HiTVData[] =
-{
-        {        3,1,840,483,1648,960,0x032,0,0          }, /* 00 (320x200,320x400,640x200,640x400) */
-        {        1,1,892,563,690,700,0,0,0               }, /* 01 (320x350,640x350) */
-        {        3,1,840,483,1648,960,0x032,0,0          }, /* 02 (360x400,720x400) */
-        {        1,1,1000,563,785,700,0,0,0              }, /* 03 (720x350) */
-        {        5,2,840,563,1648,960,0x08D,1,0          }, /* 04 (320x240,640x480) */
-        {        8,5,1050,683,1648,960,0x17C,1,0         }  /* 05 (400x300,800x600) */
-
-};
-
-static struct XGI330_TVDataStruct  XGI_ExtHiTVData[] =
-{
-        {        6,1,840,563,1632,960,0,0,0              }, /* 00 (320x200,320x400,640x200,640x400) */
-        {        3,1,960,563,1632,960,0,0,0              }, /* 01 (320x350,640x350) */
-        {        3,1,840,483,1632,960,0,0,0              }, /* 02 (360x400,720x400) */
-        {        3,1,960,563,1632,960,0,0,0              }, /* 03 (720x350) */
-        {        5,1,840,563,1648,960,0x166,1,0          }, /* 04 (320x240,640x480) */
-        {        16,5,1050,683,1648,960,0x143,1,0        }, /* 05 (400x300,800x600) */
-        {        25,12,1260,851,1648,960,0x032,0,0       }, /* 06 (512x384,1024x768) */
-        {        5,4,1575,1124,1648,960,0x128,0,0        }, /* 07 (1280x1024) */
-        {        4,1,1050,563,1548,960,0x143,1,0         }, /* 08 (800x480) */
-        {        5,2,1400,659,1648,960,0x032,0,0         }, /* 09 (1024x576) */
-        {        8,5,1750,803,1648,960,0x128,0,0         }  /* 0A (1280x720) */
-
-};
-
-static struct XGI330_TVDataStruct  XGI_ExtYPbPr525iData[] =
-{
- {    9,  5, 1001, 453,1270, 420, 171,   0, 171},
- {   12,  5,  858, 403,1270, 420, 171,   0, 171},
- {    9,  5, 1001, 453,1270, 420, 171,   0, 171},
- {   12,  5,  858, 403,1270, 420, 171,   0, 171},
- {  143,  80, 836, 523,1250, 420, 224,   0,   0},
- {  143, 120,1008, 643,1250, 420,   0,   1,   0},
- {   1,    1,1120, 821,1516, 420,   0,   1,   0}, /*301b*/
- {    2,   1, 858, 503,1584, 480,   0,   1,   0},
- {    3,   2,1001, 533,1250, 420,   0,   0,   0}
-};
-
-static struct XGI330_TVDataStruct  XGI_StYPbPr525iData[] =
-{
- {    1,   1, 858, 525,1270, 400,  50,   0, 760},
- {    1,   1, 858, 525,1270, 350,  50,   0, 640},
- {    1,   1, 858, 525,1270, 400,   0,   0, 720},
- {    1,   1, 858, 525,1270, 350,   0,   0, 720},
- {    1,   1, 858, 525,1270, 480,   0,   0, 760},
-};
-
-static struct XGI330_TVDataStruct  XGI_ExtYPbPr525pData[] =
-{
- {    9,  5, 1001, 453,1270, 420, 171,   0, 171},
- {   12,  5,  858, 403,1270, 420, 171,   0, 171},
- {    9,  5, 1001, 453,1270, 420, 171,   0, 171},
- {   12,  5,  858, 403,1270, 420, 171,   0, 171},
- {  143,  80, 836, 523,1270, 420, 224,   0,   0},
- {  143, 120,1008, 643,1270, 420,   0,   1,   0},
- {   1,    1,1120, 821,1516, 420,   0,   1,   0}, /*301b*/
- {    2,   1, 858, 503,1584, 480,   0,   1,   0},
- {    3,   2,1001, 533,1270, 420,   0,   0,   0}
- };
-
-static struct XGI330_TVDataStruct  XGI_StYPbPr525pData[] =
-{
- {    1,   1,1716, 525,1270, 400,  50,   0, 760},
- {    1,   1,1716, 525,1270, 350,  50,   0, 640},
- {    1,   1,1716, 525,1270, 400,   0,   0, 720},
- {    1,   1,1716, 525,1270, 350,   0,   0, 720},
- {    1,   1,1716, 525,1270, 480,   0,   0, 760},
-};
-
-static struct XGI330_TVDataStruct  XGI_ExtYPbPr750pData[] =
-{
- {    3,   1, 935, 470,1130, 680,  50,   0,   0},       /* 00 (320x200,320x400,640x200,640x400) */
- {   24,   7, 935, 420,1130, 680,  50,   0,   0},       /* 01 (320x350,640x350) */
- {    3,   1, 935, 470,1130, 680,  50,   0,   0},       /* 02 (360x400,720x400) */
- {   24,   7, 935, 420,1130, 680,  50,   0,   0},       /* 03 (720x350) */
- {    2,   1,1100, 590,1130, 640,  50,   0,   0},       /* 04 (320x240,640x480) */
- {    3,   2,1210, 690,1130, 660,  50,   0,   0},       /* 05 (400x300,800x600) */
- {    1,   1,1375, 878,1130, 640, 638,   0,   0},       /* 06 (1024x768) */
- {    2,   1, 858, 503,1130, 480,   0,   1,   0},        /* 07 (720x480) */
- {    5,   4,1815, 570,1130, 660,  50,   0,   0},
- {    5,   3,1100, 686,1130, 640,  50,   1,   0},
- {   10,   9,1320, 830,1130, 640,  50,   0,   0}
-};
-
-static struct XGI330_TVDataStruct  XGI_StYPbPr750pData[] =
-{
- {    1,   1,1650, 750,1280, 400,  50,   0, 760},
- {    1,   1,1650, 750,1280, 350,  50,   0, 640},
- {    1,   1,1650, 750,1280, 400,   0,   0, 720},
- {    1,   1,1650, 750,1280, 350,   0,   0, 720},
- {    1,   1,1650, 750,1280, 480,   0,   0, 760},
+static struct XGI330_LCDDataStruct  XGI_CetLCD1024x768x75Data[] = {
+       {1, 1, 1312, 800, 1312, 800}, /* ; 00 (320x200,320x400,
+                                              640x200,640x400) */
+       {1, 1, 1312, 800, 1312, 800}, /* ; 01 (320x350,640x350) */
+       {1, 1, 1312, 800, 1312, 800}, /* ; 02 (360x400,720x400) */
+       {1, 1, 1312, 800, 1312, 800}, /* ; 03 (720x350) */
+       {1, 1, 1312, 800, 1312, 800}, /* ; 04 (640x480x75Hz) */
+       {1, 1, 1312, 800, 1312, 800}, /* ; 05 (800x600x75Hz) */
+       {1, 1, 1312, 800, 1312, 800}  /* ; 06 (1024x768x75Hz) */
+};
+
+static struct XGI330_LCDDataStruct  XGI_ExtLCD1280x1024x75Data[] = {
+       {211, 60,  1024, 501,  1688, 1066}, /* ; 00 (320x200,320x400,
+                                                    640x200,640x400) */
+       {211, 60,  1024, 508,  1688, 1066}, /* ; 01 (320x350,640x350) */
+       {211, 60,  1024, 501,  1688, 1066}, /* ; 02 (360x400,720x400) */
+       {211, 60,  1024, 508,  1688, 1066}, /* ; 03 (720x350) */
+       {211, 45,  768,  498,  1688, 1066}, /* ; 04 (640x480x75Hz) */
+       {211, 75,  1024, 625,  1688, 1066}, /* ; 05 (800x600x75Hz) */
+       {211, 120, 1280, 798,  1688, 1066}, /* ; 06 (1024x768x75Hz) */
+       {1,   1,   1688, 1066, 1688, 1066}  /* ; 07 (1280x1024x75Hz) */
+};
+
+static struct XGI330_LCDDataStruct  XGI_StLCD1280x1024x75Data[] = {
+       {211, 60,  1024, 501,  1688, 1066}, /* ; 00 (320x200,320x400,
+                                                    640x200,640x400) */
+       {211, 60,  1024, 508,  1688, 1066}, /* ; 01 (320x350,640x350) */
+       {211, 60,  1024, 501,  1688, 1066}, /* ; 02 (360x400,720x400) */
+       {211, 60,  1024, 508,  1688, 1066}, /* ; 03 (720x350) */
+       {211, 45,  768,  498,  1688, 1066}, /* ; 04 (640x480x75Hz) */
+       {211, 75,  1024, 625,  1688, 1066}, /* ; 05 (800x600x75Hz) */
+       {211, 120, 1280, 798,  1688, 1066}, /* ; 06 (1024x768x75Hz) */
+       {1,   1,   1688, 1066, 1688, 1066}  /* ; 07 (1280x1024x75Hz) */
+};
+
+static struct XGI330_LCDDataStruct  XGI_CetLCD1280x1024x75Data[] = {
+       {1, 1, 1688, 1066, 1688, 1066}, /* ; 00 (320x200,320x400,
+                                                640x200,640x400) */
+       {1, 1, 1688, 1066, 1688, 1066}, /* ; 01 (320x350,640x350) */
+       {1, 1, 1688, 1066, 1688, 1066}, /* ; 02 (360x400,720x400) */
+       {1, 1, 1688, 1066, 1688, 1066}, /* ; 03 (720x350) */
+       {1, 1, 1688, 1066, 1688, 1066}, /* ; 04 (640x480x75Hz) */
+       {1, 1, 1688, 1066, 1688, 1066}, /* ; 05 (800x600x75Hz) */
+       {1, 1, 1688, 1066, 1688, 1066}, /* ; 06 (1024x768x75Hz) */
+       {1, 1, 1688, 1066, 1688, 1066}  /* ; 07 (1280x1024x75Hz) */
+};
+
+static struct XGI330_LCDDataStruct  XGI_NoScalingDatax75[] = {
+       {1, 1, 800,  449,  800,  449},  /* ; 00 (320x200, 320x400,
+                                                640x200, 640x400) */
+       {1, 1, 800,  449,  800,  449},  /* ; 01 (320x350, 640x350) */
+       {1, 1, 900,  449,  900,  449},  /* ; 02 (360x400, 720x400) */
+       {1, 1, 900,  449,  900,  449},  /* ; 03 (720x350) */
+       {1, 1, 840,  500,  840,  500},  /* ; 04 (640x480x75Hz) */
+       {1, 1, 1056, 625,  1056, 625},  /* ; 05 (800x600x75Hz) */
+       {1, 1, 1312, 800,  1312, 800},  /* ; 06 (1024x768x75Hz) */
+       {1, 1, 1688, 1066, 1688, 1066}, /* ; 07 (1280x1024x75Hz) */
+       {1, 1, 1688, 1066, 1688, 1066}, /* ; 08 (1400x1050x75Hz)
+                                          ;;[ycchen] 12/19/02 */
+       {1, 1, 2160, 1250, 2160, 1250}, /* ; 09 (1600x1200x75Hz) */
+       {1, 1, 1688, 806,  1688, 806}   /* ; 0A (1280x768x75Hz) */
+};
+
+static struct XGI330_LCDDataDesStruct  XGI_ExtLCDDes1024x768Data[] = {
+       {9, 1057, 0,   771}, /* ; 00 (320x200,320x400,640x200,640x400) */
+       {9, 1057, 0,   771}, /* ; 01 (320x350,640x350) */
+       {9, 1057, 0,   771}, /* ; 02 (360x400,720x400) */
+       {9, 1057, 0,   771}, /* ; 03 (720x350) */
+       {9, 1057, 0,   771}, /* ; 04 (640x480x60Hz) */
+       {9, 1057, 0,   771}, /* ; 05 (800x600x60Hz) */
+       {9, 1057, 805, 770}  /* ; 06 (1024x768x60Hz) */
+};
+
+static struct XGI330_LCDDataDesStruct  XGI_StLCDDes1024x768Data[] = {
+       {9, 1057, 737, 703}, /* ; 00 (320x200,320x400,640x200,640x400) */
+       {9, 1057, 686, 651}, /* ; 01 (320x350,640x350) */
+       {9, 1057, 737, 703}, /* ; 02 (360x400,720x400) */
+       {9, 1057, 686, 651}, /* ; 03 (720x350) */
+       {9, 1057, 776, 741}, /* ; 04 (640x480x60Hz) */
+       {9, 1057, 0,   771}, /* ; 05 (800x600x60Hz) */
+       {9, 1057, 805, 770}  /* ; 06 (1024x768x60Hz) */
+};
+
+static struct XGI330_LCDDataDesStruct  XGI_CetLCDDes1024x768Data[] = {
+       {1152, 856,  622, 587}, /* ; 00 (320x200,320x400,640x200,640x400) */
+       {1152, 856,  597, 562}, /* ; 01 (320x350,640x350) */
+       {1152, 856,  622, 587}, /* ; 02 (360x400,720x400) */
+       {1152, 856,  597, 562}, /* ; 03 (720x350) */
+       {1152, 856,  662, 627}, /* ; 04 (640x480x60Hz) */
+       {1232, 936,  722, 687}, /* ; 05 (800x600x60Hz) */
+       {0,    1048, 805, 770}  /* ; 06 (1024x768x60Hz) */
+};
+
+static struct XGI330_LCDDataDesStruct XGI_ExtLCDDLDes1280x1024Data[] = {
+       {18, 1346, 981,  940},  /* 00 (320x200,320x400,640x200,640x400) */
+       {18, 1346, 926,  865},  /* 01 (320x350,640x350) */
+       {18, 1346, 981,  940},  /* 02 (360x400,720x400) */
+       {18, 1346, 926,  865},  /* 03 (720x350) */
+       {18, 1346, 0,    1025}, /* 04 (640x480x60Hz) */
+       {18, 1346, 0,    1025}, /* 05 (800x600x60Hz) */
+       {18, 1346, 1065, 1024}, /* 06 (1024x768x60Hz) */
+       {18, 1346, 1065, 1024}  /* 07 (1280x1024x60Hz) */
+};
+
+static struct XGI330_LCDDataDesStruct XGI_StLCDDLDes1280x1024Data[] = {
+       {18, 1346, 970,  907},  /* 00 (320x200,320x400,640x200,640x400) */
+       {18, 1346, 917,  854},  /* 01 (320x350,640x350) */
+       {18, 1346, 970,  907},  /* 02 (360x400,720x400) */
+       {18, 1346, 917,  854},  /* 03 (720x350) */
+       {18, 1346, 0,    1025}, /* 04 (640x480x60Hz) */
+       {18, 1346, 0,    1025}, /* 05 (800x600x60Hz) */
+       {18, 1346, 1065, 1024}, /* 06 (1024x768x60Hz) */
+       {18, 1346, 1065, 1024}  /* 07 (1280x1024x60Hz) */
+};
+
+static struct XGI330_LCDDataDesStruct  XGI_CetLCDDLDes1280x1024Data[] = {
+       {1368, 1008, 752,  711}, /* 00 (320x200,320x400,640x200,640x400) */
+       {1368, 1008, 729,  688}, /* 01 (320x350,640x350) */
+       {1368, 1008, 752,  711}, /* 02 (360x400,720x400) */
+       {1368, 1008, 729,  688}, /* 03 (720x350) */
+       {1368, 1008, 794,  753}, /* 04 (640x480x60Hz) */
+       {1448, 1068, 854,  813}, /* 05 (800x600x60Hz) */
+       {1560, 1200, 938,  897}, /* 06 (1024x768x60Hz) */
+       {18,   1346, 1065, 1024} /* 07 (1280x1024x60Hz) */
+};
+
+static struct XGI330_LCDDataDesStruct  XGI_ExtLCDDes1280x1024Data[] = {
+       {9, 1337, 981,  940},  /* ; 00 (320x200,320x400,640x200,640x400) */
+       {9, 1337, 926,  884},  /* ; 01 (320x350,640x350) alan, 2003/09/30 */
+       {9, 1337, 981,  940},  /* ; 02 (360x400,720x400) */
+       {9, 1337, 926,  884},  /* ; 03 (720x350) alan, 2003/09/30 */
+       {9, 1337, 0,    1025}, /* ; 04 (640x480x60Hz) */
+       {9, 1337, 0,    1025}, /* ; 05 (800x600x60Hz) */
+       {9, 1337, 1065, 1024}, /* ; 06 (1024x768x60Hz) */
+       {9, 1337, 1065, 1024}  /* ; 07 (1280x1024x60Hz) */
+};
+
+static struct XGI330_LCDDataDesStruct  XGI_StLCDDes1280x1024Data[] = {
+       {9, 1337, 970,  907},  /* ; 00 (320x200,320x400,640x200,640x400) */
+       {9, 1337, 917,  854},  /* ; 01 (320x350,640x350) */
+       {9, 1337, 970,  907},  /* ; 02 (360x400,720x400) */
+       {9, 1337, 917,  854},  /* ; 03 (720x350) */
+       {9, 1337, 0,    1025}, /* ; 04 (640x480x60Hz) */
+       {9, 1337, 0,    1025}, /* ; 05 (800x600x60Hz) */
+       {9, 1337, 1065, 1024}, /* ; 06 (1024x768x60Hz) */
+       {9, 1337, 1065, 1024}  /* ; 07 (1280x1024x60Hz) */
+};
+
+static struct XGI330_LCDDataDesStruct  XGI_CetLCDDes1280x1024Data[] = {
+       {1368, 1008, 752,  711}, /* 00 (320x200,320x400,640x200,640x400) */
+       {1368, 1008, 729,  688}, /* 01 (320x350,640x350) */
+       {1368, 1008, 752,  711}, /* 02 (360x400,720x400) */
+       {1368, 1008, 729,  688}, /* 03 (720x350) */
+       {1368, 1008, 794,  753}, /* 04 (640x480x60Hz) */
+       {1448, 1068, 854,  813}, /* 05 (800x600x60Hz) */
+       {1560, 1200, 938,  897}, /* 06 (1024x768x60Hz) */
+       {9,    1337, 1065, 1024} /* 07 (1280x1024x60Hz) */
+};
+
+static struct XGI330_LCDDataDesStruct  XGI_StLCDDLDes1400x1050Data[] = {
+       {18,   1464, 0,    1051}, /* 00 (320x200,320x400,640x200,640x400) */
+       {18,   1464, 0,    1051}, /* 01 (320x350,640x350) */
+       {18,   1464, 0,    1051}, /* 02 (360x400,720x400) */
+       {18,   1464, 0,    1051}, /* 03 (720x350) */
+       {18,   1464, 0,    1051}, /* 04 (640x480x60Hz) */
+       {18,   1464, 0,    1051}, /* 05 (800x600x60Hz) */
+       {18,   1464, 0,    1051}, /* 06 (1024x768x60Hz) */
+       {1646, 1406, 1053, 1038}, /* 07 (1280x1024x60Hz) */
+       {18,   1464, 0,    1051}  /* 08 (1400x1050x60Hz) */
+};
+
+static struct XGI330_LCDDataDesStruct  XGI_ExtLCDDLDes1400x1050Data[] = {
+       {18,   1464, 0,    1051}, /* 00 (320x200,320x400,640x200,640x400) */
+       {18,   1464, 0,    1051}, /* 01 (320x350,640x350) */
+       {18,   1464, 0,    1051}, /* 02 (360x400,720x400) */
+       {18,   1464, 0,    1051}, /* 03 (720x350) */
+       {18,   1464, 0,    1051}, /* 04 (640x480x60Hz) */
+       {18,   1464, 0,    1051}, /* 05 (800x600x60Hz) */
+       {18,   1464, 0,    1051}, /* 06 (1024x768x60Hz) */
+       {1646, 1406, 1053, 1038}, /* 07 (1280x1024x60Hz) */
+       {18,   1464, 0,    1051}  /* 08 (1400x1050x60Hz) */
+};
+
+static struct XGI330_LCDDataDesStruct  XGI_StLCDDes1400x1050Data[] = {
+       {9,    1455, 0,    1051}, /* 00 (320x200,320x400,640x200,640x400) */
+       {9,    1455, 0,    1051}, /* 01 (320x350,640x350) */
+       {9,    1455, 0,    1051}, /* 02 (360x400,720x400) */
+       {9,    1455, 0,    1051}, /* 03 (720x350) */
+       {9,    1455, 0,    1051}, /* 04 (640x480x60Hz) */
+       {9,    1455, 0,    1051}, /* 05 (800x600x60Hz) */
+       {9,    1455, 0,    1051}, /* 06 (1024x768x60Hz) */
+       {1637, 1397, 1053, 1038}, /* 07 (1280x1024x60Hz) */
+       {9,    1455, 0,    1051}  /* 08 (1400x1050x60Hz) */
+};
+
+static struct XGI330_LCDDataDesStruct  XGI_ExtLCDDes1400x1050Data[] = {
+       {9,    1455, 0,    1051}, /* 00 (320x200,320x400,640x200,640x400) */
+       {9,    1455, 0,    1051}, /* 01 (320x350,640x350) */
+       {9,    1455, 0,    1051}, /* 02 (360x400,720x400) */
+       {9,    1455, 0,    1051}, /* 03 (720x350) */
+       {9,    1455, 0,    1051}, /* 04 (640x480x60Hz) */
+       {9,    1455, 0,    1051}, /* 05 (800x600x60Hz) */
+       {9,    1455, 0,    1051}, /* 06 (1024x768x60Hz) */
+       {1637, 1397, 1053, 1038}, /* 07 (1280x1024x60Hz) */
+       {9,    1455, 0,    1051}  /* 08 (1400x1050x60Hz) */
+};
+
+static struct XGI330_LCDDataDesStruct  XGI_CetLCDDes1400x1050Data[] = {
+       {1308, 1068, 781,  766},  /* 00 (320x200,320x400,640x200,640x400) */
+       {1308, 1068, 781,  766},  /* 01 (320x350,640x350) */
+       {1308, 1068, 781,  766},  /* 02 (360x400,720x400) */
+       {1308, 1068, 781,  766},  /* 03 (720x350) */
+       {1308, 1068, 781,  766},  /* 04 (640x480x60Hz) */
+       {1388, 1148, 841,  826},  /* 05 (800x600x60Hz) */
+       {1490, 1250, 925,  910},  /* 06 (1024x768x60Hz) */
+       {1646, 1406, 1053, 1038}, /* 07 (1280x1024x60Hz) */
+       {18,   1464, 0,    1051}  /* 08 (1400x1050x60Hz) */
+};
+
+static struct XGI330_LCDDataDesStruct  XGI_CetLCDDes1400x1050Data2[] = {
+       {0, 1448, 0, 1051}, /* 00 (320x200,320x400,640x200,640x400) */
+       {0, 1448, 0, 1051}, /* 01 (320x350,640x350) */
+       {0, 1448, 0, 1051}, /* 02 (360x400,720x400) */
+       {0, 1448, 0, 1051}, /* 03 (720x350) */
+       {0, 1448, 0, 1051}  /* 04 (640x480x60Hz) */
+};
+
+static struct XGI330_LCDDataDesStruct  XGI_ExtLCDDLDes1600x1200Data[] = {
+       {18, 1682, 0, 1201}, /* 00 (320x200,320x400,640x200,640x400) */
+       {18, 1682, 0, 1201}, /* 01 (320x350,640x350) */
+       {18, 1682, 0, 1201}, /* 02 (360x400,720x400) */
+       {18, 1682, 0, 1201}, /* 03 (720x350) */
+       {18, 1682, 0, 1201}, /* 04 (640x480x60Hz) */
+       {18, 1682, 0, 1201}, /* 05 (800x600x60Hz) */
+       {18, 1682, 0, 1201}, /* 06 (1024x768x60Hz) */
+       {18, 1682, 0, 1201}, /* 07 (1280x1024x60Hz) */
+       {18, 1682, 0, 1201}, /* 08 (1400x1050x60Hz) */
+       {18, 1682, 0, 1201}  /* 09 (1600x1200x60Hz) */
+};
+
+static struct XGI330_LCDDataDesStruct  XGI_StLCDDLDes1600x1200Data[] = {
+       {18, 1682, 1150, 1101}, /* 00 (320x200,320x400,640x200,640x400) */
+       {18, 1682, 1083, 1034}, /* 01 (320x350,640x350) */
+       {18, 1682, 1150, 1101}, /* 02 (360x400,720x400) */
+       {18, 1682, 1083, 1034}, /* 03 (720x350) */
+       {18, 1682, 0,    1201}, /* 04 (640x480x60Hz) */
+       {18, 1682, 0,    1201}, /* 05 (800x600x60Hz) */
+       {18, 1682, 0,    1201}, /* 06 (1024x768x60Hz) */
+       {18, 1682, 1232, 1183}, /* 07 (1280x1024x60Hz) */
+       {18, 1682, 0,    1201}, /* 08 (1400x1050x60Hz) */
+       {18, 1682, 0,    1201} /* 09 (1600x1200x60Hz) */
+};
+
+static struct XGI330_LCDDataDesStruct  XGI_ExtLCDDes1600x1200Data[] = {
+       {9, 1673, 0, 1201}, /* 00 (320x200,320x400,640x200,640x400) */
+       {9, 1673, 0, 1201}, /* 01 (320x350,640x350) */
+       {9, 1673, 0, 1201}, /* 02 (360x400,720x400) */
+       {9, 1673, 0, 1201}, /* 03 (720x350) */
+       {9, 1673, 0, 1201}, /* 04 (640x480x60Hz) */
+       {9, 1673, 0, 1201}, /* 05 (800x600x60Hz) */
+       {9, 1673, 0, 1201}, /* 06 (1024x768x60Hz) */
+       {9, 1673, 0, 1201}, /* 07 (1280x1024x60Hz) */
+       {9, 1673, 0, 1201}, /* 08 (1400x1050x60Hz) */
+       {9, 1673, 0, 1201}  /* 09 (1600x1200x60Hz) */
+};
+
+static struct XGI330_LCDDataDesStruct  XGI_StLCDDes1600x1200Data[] = {
+       {9, 1673, 1150, 1101}, /* 00 (320x200,320x400,640x200,640x400) */
+       {9, 1673, 1083, 1034}, /* 01 (320x350,640x350) */
+       {9, 1673, 1150, 1101}, /* 02 (360x400,720x400) */
+       {9, 1673, 1083, 1034}, /* 03 (720x350) */
+       {9, 1673, 0,    1201}, /* 04 (640x480x60Hz) */
+       {9, 1673, 0,    1201}, /* 05 (800x600x60Hz) */
+       {9, 1673, 0,    1201}, /* 06 (1024x768x60Hz) */
+       {9, 1673, 1232, 1183}, /* 07 (1280x1024x60Hz) */
+       {9, 1673, 0,    1201}, /* 08 (1400x1050x60Hz) */
+       {9, 1673, 0,    1201}  /* 09 (1600x1200x60Hz) */
+};
+
+static struct XGI330_LCDDataDesStruct2  XGI_NoScalingDesData[] = {
+       {9, 657,  448, 405,  96,   2}, /* 00 (320x200,320x400,
+                                             640x200,640x400) */
+       {9, 657,  448, 355,  96,   2}, /* 01 (320x350,640x350) */
+       {9, 657,  448, 405,  96,   2}, /* 02 (360x400,720x400) */
+       {9, 657,  448, 355,  96,   2}, /* 03 (720x350) */
+       {9, 657,  1,   483,  96,   2}, /* 04 (640x480x60Hz) */
+       {9, 849,  627, 600,  128,  4}, /* 05 (800x600x60Hz) */
+       {9, 1057, 805, 770,  0136, 6}, /* 06 (1024x768x60Hz) */
+       {9, 1337, 0,   1025, 112,  3}, /* 07 (1280x1024x60Hz) */
+       {9, 1457, 0,   1051, 112,  3}, /* 08 (1400x1050x60Hz) },
+                                       //;[ycchen] 12/19/02 */
+       {9, 1673, 0,   1201, 192,  3}, /* 09 (1600x1200x60Hz) */
+       {9, 1337, 0,   771,  112,  6}  /* 0A (1280x768x60Hz) */
+};
+
+/* ;;1024x768x75Hz */
+static struct XGI330_LCDDataDesStruct  XGI_ExtLCDDes1024x768x75Data[] = {
+       {9, 1049, 0, 769}, /* ; 00 (320x200,320x400,640x200,640x400) */
+       {9, 1049, 0, 769}, /* ; 01 (320x350,640x350) */
+       {9, 1049, 0, 769}, /* ; 02 (360x400,720x400) */
+       {9, 1049, 0, 769}, /* ; 03 (720x350) */
+       {9, 1049, 0, 769}, /* ; 04 (640x480x75Hz) */
+       {9, 1049, 0, 769}, /* ; 05 (800x600x75Hz) */
+       {9, 1049, 0, 769}  /* ; 06 (1024x768x75Hz) */
+};
+
+static struct XGI330_LCDDataDesStruct  XGI_StLCDDes1024x768x75Data[] = {
+       {9, 1049, 0, 769}, /* ; 00 (320x200,320x400,640x200,640x400) */
+       {9, 1049, 0, 769}, /* ; 01 (320x350,640x350) */
+       {9, 1049, 0, 769}, /* ; 02 (360x400,720x400) */
+       {9, 1049, 0, 769}, /* ; 03 (720x350) */
+       {9, 1049, 0, 769}, /* ; 04 (640x480x75Hz) */
+       {9, 1049, 0, 769}, /* ; 05 (800x600x75Hz) */
+       {9, 1049, 0, 769}  /* ; 06 (1024x768x75Hz) */
+};
+
+/* ;;1024x768x75Hz */
+static struct XGI330_LCDDataDesStruct  XGI_CetLCDDes1024x768x75Data[] = {
+       {1152, 856,  622, 587}, /* ; 00 (320x200,320x400,640x200,640x400) */
+       {1152, 856,  597, 562}, /* ; 01 (320x350,640x350) */
+       {1192, 896,  622, 587}, /* ; 02 (360x400,720x400) */
+       {1192, 896,  597, 562}, /* ; 03 (720x350) */
+       {1129, 857,  656, 625}, /* ; 04 (640x480x75Hz) */
+       {1209, 937,  716, 685}, /* ; 05 (800x600x75Hz) */
+       {9,    1049, 0,   769}  /* ; 06 (1024x768x75Hz) */
+};
+
+/* ;;1280x1024x75Hz */
+static struct XGI330_LCDDataDesStruct  XGI_ExtLCDDLDes1280x1024x75Data[] = {
+       {18, 1314, 0, 1025}, /* ; 00 (320x200,320x400,640x200,640x400) */
+       {18, 1314, 0, 1025}, /* ; 01 (320x350,640x350) */
+       {18, 1314, 0, 1025}, /* ; 02 (360x400,720x400) */
+       {18, 1314, 0, 1025}, /* ; 03 (720x350) */
+       {18, 1314, 0, 1025}, /* ; 04 (640x480x60Hz) */
+       {18, 1314, 0, 1025}, /* ; 05 (800x600x60Hz) */
+       {18, 1314, 0, 1025}, /* ; 06 (1024x768x60Hz) */
+       {18, 1314, 0, 1025}  /* ; 07 (1280x1024x60Hz) */
+};
+
+static struct XGI330_LCDDataDesStruct  XGI_StLCDDLDes1280x1024x75Data[] = {
+       {18, 1314, 0, 1025}, /* ; 00 (320x200,320x400,640x200,640x400) */
+       {18, 1314, 0, 1025}, /* ; 01 (320x350,640x350) */
+       {18, 1314, 0, 1025}, /* ; 02 (360x400,720x400) */
+       {18, 1314, 0, 1025}, /* ; 03 (720x350) */
+       {18, 1314, 0, 1025}, /* ; 04 (640x480x60Hz) */
+       {18, 1314, 0, 1025}, /* ; 05 (800x600x60Hz) */
+       {18, 1314, 0, 1025}, /* ; 06 (1024x768x60Hz) */
+       {18, 1314, 0, 1025}  /* ; 07 (1280x1024x60Hz) */
+};
+
+/* 1280x1024x75Hz */
+static struct XGI330_LCDDataDesStruct  XGI_CetLCDDLDes1280x1024x75Data[] = {
+       {1368, 1008, 752, 711}, /* ; 00 (320x200,320x400,640x200,640x400) */
+       {1368, 1008, 729, 688}, /* ; 01 (320x350,640x350) */
+       {1408, 1048, 752, 711}, /* ; 02 (360x400,720x400) */
+       {1408, 1048, 729, 688}, /* ; 03 (720x350) */
+       {1377, 985,  794, 753}, /* ; 04 (640x480x75Hz) */
+       {1457, 1065, 854, 813}, /* ; 05 (800x600x75Hz) */
+       {1569, 1177, 938, 897}, /* ; 06 (1024x768x75Hz) */
+       {18,   1314, 0,   1025} /* ; 07 (1280x1024x75Hz) */
+};
+
+/* ;;1280x1024x75Hz */
+static struct XGI330_LCDDataDesStruct  XGI_ExtLCDDes1280x1024x75Data[] = {
+       {9, 1305, 0, 1025}, /* ; 00 (320x200,320x400,640x200,640x400) */
+       {9, 1305, 0, 1025}, /* ; 01 (320x350,640x350) */
+       {9, 1305, 0, 1025}, /* ; 02 (360x400,720x400) */
+       {9, 1305, 0, 1025}, /* ; 03 (720x350) */
+       {9, 1305, 0, 1025}, /* ; 04 (640x480x60Hz) */
+       {9, 1305, 0, 1025}, /* ; 05 (800x600x60Hz) */
+       {9, 1305, 0, 1025}, /* ; 06 (1024x768x60Hz) */
+       {9, 1305, 0, 1025}  /* ; 07 (1280x1024x60Hz) */
+};
+
+static struct XGI330_LCDDataDesStruct  XGI_StLCDDes1280x1024x75Data[] = {
+       {9, 1305, 0, 1025}, /* ; 00 (320x200,320x400,640x200,640x400) */
+       {9, 1305, 0, 1025}, /* ; 01 (320x350,640x350) */
+       {9, 1305, 0, 1025}, /* ; 02 (360x400,720x400) */
+       {9, 1305, 0, 1025}, /* ; 03 (720x350) */
+       {9, 1305, 0, 1025}, /* ; 04 (640x480x60Hz) */
+       {9, 1305, 0, 1025}, /* ; 05 (800x600x60Hz) */
+       {9, 1305, 0, 1025}, /* ; 06 (1024x768x60Hz) */
+       {9, 1305, 0, 1025}  /* ; 07 (1280x1024x60Hz) */
+};
+
+/* 1280x1024x75Hz */
+static struct XGI330_LCDDataDesStruct  XGI_CetLCDDes1280x1024x75Data[] = {
+       {1368, 1008, 752, 711}, /* ; 00 (320x200,320x400,640x200,640x400) */
+       {1368, 1008, 729, 688}, /* ; 01 (320x350,640x350) */
+       {1408, 1048, 752, 711}, /* ; 02 (360x400,720x400) */
+       {1408, 1048, 729, 688}, /* ; 03 (720x350) */
+       {1377, 985,  794, 753}, /* ; 04 (640x480x75Hz) */
+       {1457, 1065, 854, 813}, /* ; 05 (800x600x75Hz) */
+       {1569, 1177, 938, 897}, /* ; 06 (1024x768x75Hz) */
+       {9,    1305, 0,   1025} /* ; 07 (1280x1024x75Hz) */
+};
+
+/* Scaling LCD 75Hz */
+static struct XGI330_LCDDataDesStruct2 XGI_NoScalingDesDatax75[] =  {
+       {9, 657,  448, 405,  96,  2}, /* ; 00 (320x200,320x400,
+                                              640x200,640x400) */
+       {9, 657,  448, 355,  96,  2}, /* ; 01 (320x350,640x350) */
+       {9, 738,  448, 405,  108, 2}, /* ; 02 (360x400,720x400) */
+       {9, 738,  448, 355,  108, 2}, /* ; 03 (720x350) */
+       {9, 665,  0,   481,  64,  3}, /* ; 04 (640x480x75Hz) */
+       {9, 825,  0,   601,  80,  3}, /* ; 05 (800x600x75Hz) */
+       {9, 1049, 0,   769,  96,  3}, /* ; 06 (1024x768x75Hz) */
+       {9, 1305, 0,   1025, 144, 3}, /* ; 07 (1280x1024x75Hz) */
+       {9, 1457, 0,   1051, 112, 3}, /* ; 08 (1400x1050x60Hz)
+                                        ;;[ycchen] 12/19/02 */
+       {9, 1673, 0,   1201, 192, 3}, /* ; 09 (1600x1200x75Hz) */
+       {9, 1337, 0,   771,  112, 6}  /* ; 0A (1280x768x60Hz) */
+};
+
+static struct XGI330_TVDataStruct  XGI_StPALData[] = {
+       {1, 1, 864, 525, 1270, 400, 100, 0, 760},
+       {1, 1, 864, 525, 1270, 350, 100, 0, 760},
+       {1, 1, 864, 525, 1270, 400,   0, 0, 720},
+       {1, 1, 864, 525, 1270, 350,   0, 0, 720},
+       {1, 1, 864, 525, 1270, 480,  50, 0, 760},
+       {1, 1, 864, 525, 1270, 600,  50, 0,   0}
+};
+
+static struct XGI330_TVDataStruct  XGI_ExtPALData[] = {
+       {2,  1, 1080, 463, 1270, 500,  50, 0,  50},
+       {15, 7, 1152, 413, 1270, 500,  50, 0,  50},
+       {2,  1, 1080, 463, 1270, 500,  50, 0,  50},
+       {15, 7, 1152, 413, 1270, 500,  50, 0,  50},
+       {2,  1,  900, 543, 1270, 500,   0, 0,  50},
+       {4,  3, 1080, 663, 1270, 500, 438, 0, 438},
+       {1,  1, 1125, 831, 1270, 500, 686, 0, 686}, /*301b*/
+       {3,  2, 1080, 619, 1270, 540, 438, 0, 438}
+};
+
+static struct XGI330_TVDataStruct  XGI_StNTSCData[] = {
+       {1, 1, 858, 525, 1270, 400, 50, 0, 760},
+       {1, 1, 858, 525, 1270, 350, 50, 0, 640},
+       {1, 1, 858, 525, 1270, 400,  0, 0, 720},
+       {1, 1, 858, 525, 1270, 350,  0, 0, 720},
+       {1, 1, 858, 525, 1270, 480,  0, 0, 760}
+};
+
+static struct XGI330_TVDataStruct  XGI_ExtNTSCData[] = {
+       {9,     5, 1001, 453, 1270, 420, 171, 0, 171},
+       {12,    5,  858, 403, 1270, 420, 171, 0, 171},
+       {9,     5, 1001, 453, 1270, 420, 171, 0, 171},
+       {12,    5,  858, 403, 1270, 420, 171, 0, 171},
+       {143,  80,  836, 523, 1270, 420, 224, 0,   0},
+       {143, 120, 1008, 643, 1270, 420,   0, 1,   0},
+       {1,     1, 1120, 821, 1516, 420,   0, 1,   0}, /*301b*/
+       {2,     1,  858, 503, 1584, 480,   0, 1,   0},
+       {3,     2, 1001, 533, 1270, 420,   0, 0,   0}
+};
+
+static struct XGI330_TVDataStruct  XGI_St1HiTVData[] = {
+       {1, 1, 892,  563, 690,  800, 0,     0, 0}, /* 00 (320x200,320x400,
+                                                         640x200,640x400) */
+       {1, 1, 892,  563, 690,  700, 0,     0, 0}, /* 01 (320x350,640x350) */
+       {1, 1, 1000, 563, 785,  800, 0,     0, 0}, /* 02 (360x400,720x400) */
+       {1, 1, 1000, 563, 785,  700, 0,     0, 0}, /* 03 (720x350) */
+       {1, 1, 892,  563, 690,  960, 0,     0, 0}, /* 04 (320x240,640x480) */
+       {8, 5, 1050, 683, 1648, 960, 0x150, 1, 0}  /* 05 (400x300,800x600) */
+};
+
+static struct XGI330_TVDataStruct  XGI_St2HiTVData[] = {
+       {3, 1, 840,  483, 1648, 960, 0x032, 0, 0}, /* 00 (320x200,320x400,
+                                                         640x200,640x400) */
+       {1, 1, 892,  563, 690,  700, 0,     0, 0}, /* 01 (320x350,640x350) */
+       {3, 1, 840,  483, 1648, 960, 0x032, 0, 0}, /* 02 (360x400,720x400) */
+       {1, 1, 1000, 563, 785,  700, 0,     0, 0}, /* 03 (720x350) */
+       {5, 2, 840,  563, 1648, 960, 0x08D, 1, 0}, /* 04 (320x240,640x480) */
+       {8, 5, 1050, 683, 1648, 960, 0x17C, 1, 0}  /* 05 (400x300,800x600) */
+};
+
+static struct XGI330_TVDataStruct  XGI_ExtHiTVData[] = {
+       {6,  1,  840,  563,  1632, 960, 0,     0, 0}, /* 00 (320x200,320x400,
+                                                            640x200,640x400) */
+       {3,  1,  960,  563,  1632, 960, 0,     0, 0}, /* 01 (320x350,640x350) */
+       {3,  1,  840,  483,  1632, 960, 0,     0, 0}, /* 02 (360x400,720x400) */
+       {3,  1,  960,  563,  1632, 960, 0,     0, 0}, /* 03 (720x350) */
+       {5,  1,  840,  563,  1648, 960, 0x166, 1, 0}, /* 04 (320x240,640x480) */
+       {16, 5,  1050, 683,  1648, 960, 0x143, 1, 0}, /* 05 (400x300,800x600) */
+       {25, 12, 1260, 851,  1648, 960, 0x032, 0, 0}, /* 06 (512x384,1024x768)*/
+       {5,  4,  1575, 1124, 1648, 960, 0x128, 0, 0}, /* 07 (1280x1024) */
+       {4,  1,  1050, 563,  1548, 960, 0x143, 1, 0}, /* 08 (800x480) */
+       {5,  2,  1400, 659,  1648, 960, 0x032, 0, 0}, /* 09 (1024x576) */
+       {8,  5,  1750, 803,  1648, 960, 0x128, 0, 0}  /* 0A (1280x720) */
+};
+
+static struct XGI330_TVDataStruct  XGI_ExtYPbPr525iData[] = {
+       {  9,  5,  1001, 453, 1270, 420, 171,   0, 171},
+       { 12,  5,   858, 403, 1270, 420, 171,   0, 171},
+       {  9,  5,  1001, 453, 1270, 420, 171,   0, 171},
+       { 12,  5,   858, 403, 1270, 420, 171,   0, 171},
+       {143,  80,  836, 523, 1250, 420, 224,   0,   0},
+       {143, 120, 1008, 643, 1250, 420,   0,   1,   0},
+       { 1,    1, 1120, 821, 1516, 420,   0,   1,   0}, /*301b*/
+       {  2,   1,  858, 503, 1584, 480,   0,   1,   0},
+       {  3,   2, 1001, 533, 1250, 420,   0,   0,   0}
+};
+
+static struct XGI330_TVDataStruct  XGI_StYPbPr525iData[] = {
+       {1, 1, 858, 525, 1270, 400, 50, 0, 760},
+       {1, 1, 858, 525, 1270, 350, 50, 0, 640},
+       {1, 1, 858, 525, 1270, 400,  0, 0, 720},
+       {1, 1, 858, 525, 1270, 350,  0, 0, 720},
+       {1, 1, 858, 525, 1270, 480,  0, 0, 760},
+};
+
+static struct XGI330_TVDataStruct  XGI_ExtYPbPr525pData[] = {
+       {  9,   5,  1001, 453, 1270, 420, 171, 0, 171},
+       { 12,   5,   858, 403, 1270, 420, 171, 0, 171},
+       {  9,   5,  1001, 453, 1270, 420, 171, 0, 171},
+       { 12,   5,   858, 403, 1270, 420, 171, 0, 171},
+       {143,  80,   836, 523, 1270, 420, 224, 0,   0},
+       {143, 120,  1008, 643, 1270, 420,   0, 1,   0},
+       { 1,    1,  1120, 821, 1516, 420,   0, 1,   0}, /*301b*/
+       {  2,   1,   858, 503, 1584, 480,   0, 1,   0},
+       {  3,   2,  1001, 533, 1270, 420,   0, 0,   0}
+};
+
+static struct XGI330_TVDataStruct  XGI_StYPbPr525pData[] = {
+       {1, 1, 1716, 525, 1270, 400, 50, 0, 760},
+       {1, 1, 1716, 525, 1270, 350, 50, 0, 640},
+       {1, 1, 1716, 525, 1270, 400,  0, 0, 720},
+       {1, 1, 1716, 525, 1270, 350,  0, 0, 720},
+       {1, 1, 1716, 525, 1270, 480,  0, 0, 760},
+};
+
+static struct XGI330_TVDataStruct  XGI_ExtYPbPr750pData[] = {
+       { 3, 1,  935, 470, 1130, 680,  50, 0, 0}, /* 00 (320x200,320x400,
+                                                        640x200,640x400) */
+       {24, 7,  935, 420, 1130, 680,  50, 0, 0}, /* 01 (320x350,640x350) */
+       { 3, 1,  935, 470, 1130, 680,  50, 0, 0}, /* 02 (360x400,720x400) */
+       {24, 7,  935, 420, 1130, 680,  50, 0, 0}, /* 03 (720x350) */
+       { 2, 1, 1100, 590, 1130, 640,  50, 0, 0}, /* 04 (320x240,640x480) */
+       { 3, 2, 1210, 690, 1130, 660,  50, 0, 0}, /* 05 (400x300,800x600) */
+       { 1, 1, 1375, 878, 1130, 640, 638, 0, 0}, /* 06 (1024x768) */
+       { 2, 1,  858, 503, 1130, 480,   0, 1, 0}, /* 07 (720x480) */
+       { 5, 4, 1815, 570, 1130, 660,  50, 0, 0},
+       { 5, 3, 1100, 686, 1130, 640,  50, 1, 0},
+       {10, 9, 1320, 830, 1130, 640,  50, 0, 0}
+};
+
+static struct XGI330_TVDataStruct  XGI_StYPbPr750pData[] = {
+       {1, 1, 1650, 750, 1280, 400, 50, 0, 760},
+       {1, 1, 1650, 750, 1280, 350, 50, 0, 640},
+       {1, 1, 1650, 750, 1280, 400,  0, 0, 720},
+       {1, 1, 1650, 750, 1280, 350,  0, 0, 720},
+       {1, 1, 1650, 750, 1280, 480,  0, 0, 760},
 };
 
 static unsigned char XGI330_NTSCTiming[] = {
-  0x17,0x1d,0x03,0x09,0x05,0x06,0x0c,0x0c,
-  0x94,0x49,0x01,0x0a,0x06,0x0d,0x04,0x0a,
-  0x06,0x14,0x0d,0x04,0x0a,0x00,0x85,0x1b,
-  0x0c,0x50,0x00,0x97,0x00,0xda,0x4a,0x17,
-  0x7d,0x05,0x4b,0x00,0x00,0xe2,0x00,0x02,
-  0x03,0x0a,0x65,0x9d,0x08,0x92,0x8f,0x40,
-  0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x50,
-  0x00,0x40,0x44,0x00,0xdb,0x02,0x3b,0x00};
+       0x17, 0x1d, 0x03, 0x09, 0x05, 0x06, 0x0c, 0x0c,
+       0x94, 0x49, 0x01, 0x0a, 0x06, 0x0d, 0x04, 0x0a,
+       0x06, 0x14, 0x0d, 0x04, 0x0a, 0x00, 0x85, 0x1b,
+       0x0c, 0x50, 0x00, 0x97, 0x00, 0xda, 0x4a, 0x17,
+       0x7d, 0x05, 0x4b, 0x00, 0x00, 0xe2, 0x00, 0x02,
+       0x03, 0x0a, 0x65, 0x9d, 0x08, 0x92, 0x8f, 0x40,
+       0x60, 0x80, 0x14, 0x90, 0x8c, 0x60, 0x14, 0x50,
+       0x00, 0x40, 0x44, 0x00, 0xdb, 0x02, 0x3b, 0x00
+};
 
 static unsigned char XGI330_PALTiming[] = {
-  0x21,0x5A,0x35,0x6e,0x04,0x38,0x3d,0x70,
-  0x94,0x49,0x01,0x12,0x06,0x3e,0x35,0x6d,
-  0x06,0x14,0x3e,0x35,0x6d,0x00,0x45,0x2b,
-  0x70,0x50,0x00,0x9b,0x00,0xd9,0x5d,0x17,
-  0x7d,0x05,0x45,0x00,0x00,0xe8,0x00,0x02,
-  0x0d,0x00,0x68,0xb0,0x0b,0x92,0x8f,0x40,
-  0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x63,
-  0x00,0x40,0x3e,0x00,0xe1,0x02,0x28,0x00};
-
-static unsigned char XGI330_HiTVExtTiming[] =
-{
-      0x2D,0x60,0x2C,0x5F,0x08,0x31,0x3A,0x64,
-      0x28,0x02,0x01,0x3D,0x06,0x3E,0x35,0x6D,
-      0x06,0x14,0x3E,0x35,0x6D,0x00,0xC5,0x3F,
-      0x64,0x90,0x33,0x8C,0x18,0x36,0x3E,0x13,
-      0x2A,0xDE,0x2A,0x44,0x40,0x2A,0x44,0x40,
-      0x8E,0x8E,0x82,0x07,0x0B,
-      0x92,0x0F,0x40,0x60,0x80,0x14,0x90,0x8C,
-      0x60,0x14,0x3D,0x63,0x4F,
-      0x27,0x00,0xfc,0xff,0x6a,0x00
-
-};
-
-static unsigned char XGI330_HiTVSt1Timing[] =
-{
-      0x32,0x65,0x2C,0x5F,0x08,0x31,0x3A,0x65,
-      0x28,0x02,0x01,0x3D,0x06,0x3E,0x35,0x6D,
-      0x06,0x14,0x3E,0x35,0x6D,0x00,0xC5,0x3F,
-      0x65,0x90,0x7B,0xA8,0x03,0xF0,0x87,0x03,
-      0x11,0x15,0x11,0xCF,0x10,0x11,0xCF,0x10,
-      0x35,0x35,0x3B,0x69,0x1D,
-      0x92,0x0F,0x40,0x60,0x80,0x14,0x90,0x8C,
-      0x60,0x04,0x86,0xAF,0x5D,
-      0x0E,0x00,0xfc,0xff,0x2d,0x00
-};
-
-static unsigned char XGI330_HiTVSt2Timing[] =
-{
-      0x32,0x65,0x2C,0x5F,0x08,0x31,0x3A,0x64,
-      0x28,0x02,0x01,0x3D,0x06,0x3E,0x35,0x6D,
-      0x06,0x14,0x3E,0x35,0x6D,0x00,0xC5,0x3F,
-      0x64,0x90,0x33,0x8C,0x18,0x36,0x3E,0x13,
-      0x2A,0xDE,0x2A,0x44,0x40,0x2A,0x44,0x40,
-      0x8E,0x8E,0x82,0x07,0x0B,
-      0x92,0x0F,0x40,0x60,0x80,0x14,0x90,0x8C,
-      0x60,0x14,0x3D,0x63,0x4F,
-      0x27,0x00,0xFC,0xff,0x6a,0x00
-};
-
-static unsigned char XGI330_HiTVTextTiming[] =
-{
-      0x32,0x65,0x2C,0x5F,0x08,0x31,0x3A,0x65,
-      0x28,0x02,0x01,0x3D,0x06,0x3E,0x35,0x6D,
-      0x06,0x14,0x3E,0x35,0x6D,0x00,0xC5,0x3F,
-      0x65,0x90,0xE7,0xBC,0x03,0x0C,0x97,0x03,
-      0x14,0x78,0x14,0x08,0x20,0x14,0x08,0x20,
-      0xC8,0xC8,0x3B,0xD2,0x26,
-      0x92,0x0F,0x40,0x60,0x80,0x14,0x90,0x8C,
-      0x60,0x04,0x96,0x72,0x5C,
-      0x11,0x00,0xFC,0xFF,0x32,0x00
-};
-
-static unsigned char XGI330_YPbPr750pTiming[] =
-{
-      0x30,0x1d,0xe8,0x09,0x09,0xed,0x0c,0x0c,
-      0x98,0x0a,0x01,0x0c,0x06,0x0d,0x04,0x0a,
-      0x06,0x14,0x0d,0x04,0x0a,0x00,0x85,0x3f,
-      0xed,0x50,0x70,0x9f,0x16,0x59,0x60,0x13,
-      0x27,0x0b,0x27,0xfc,0x30,0x27,0x1c,0xb0,
-      0x4b,0x4b,0x6f,0x2f,0x63,
-      0x92,0x0F,0x40,0x60,0x80,0x14,0x90,0x8C,
-      0x60,0x14,0x73,0x00,0x40,
-      0x11,0x00,0xfc,0xff,0x32,0x00
-};
-
-static unsigned char XGI330_YPbPr525pTiming[] =
-{
-      0x3E,0x11,0x06,0x09,0x0b,0x0c,0x0c,0x0c,
-      0x98,0x0a,0x01,0x0d,0x06,0x0d,0x04,0x0a,
-      0x06,0x14,0x0d,0x04,0x0a,0x00,0x85,0x3f,
-      0x0c,0x50,0xb2,0x9f,0x16,0x59,0x4f,0x13,
-      0xad,0x11,0xad,0x1d,0x40,0x8a,0x3d,0xb8,
-      0x51,0x5e,0x60,0x49,0x7d,
-      0x92,0x0F,0x40,0x60,0x80,0x14,0x90,0x8C,
-      0x60,0x14,0x4B,0x43,0x41,
-      0x11,0x00,0xFC,0xFF,0x32,0x00
-};
-
-static unsigned char XGI330_YPbPr525iTiming[] =
-{
-      0x1B,0x21,0x03,0x09,0x05,0x06,0x0C,0x0C,
-      0x94,0x49,0x01,0x0A,0x06,0x0D,0x04,0x0A,
-      0x06,0x14,0x0D,0x04,0x0A,0x00,0x85,0x1B,
-      0x0C,0x50,0x00,0x97,0x00,0xDA,0x4A,0x17,
-      0x7D,0x05,0x4B,0x00,0x00,0xE2,0x00,0x02,
-      0x03,0x0A,0x65,0x9D,0x08,
-      0x92,0x8F,0x40,0x60,0x80,0x14,0x90,0x8C,
-      0x60,0x14,0x4B,0x00,0x40,
-      0x44,0x00,0xDB,0x02,0x3B,0x00
-
-};
-
-static unsigned char XGI330_HiTVGroup3Data[] =
-{
-      0x00,0x1A,0x22,0x63,0x62,0x22,0x08,0x5F,
-      0x05,0x21,0xB2,0xB2,0x55,0x77,0x2A,0xA6,
-      0x25,0x2F,0x47,0xFA,0xC8,0xFF,0x8E,0x20,
-      0x8C,0x6E,0x60,0x2E,0x58,0x48,0x72,0x44,
-      0x56,0x36,0x4F,0x6E,0x3F,0x80,0x00,0x80,
-      0x4F,0x7F,0x03,0xA8,0x7D,0x20,0x1A,0xA9,
-      0x14,0x05,0x03,0x7E,0x64,0x31,0x14,0x75,
-      0x18,0x05,0x18,0x05,0x4C,0xA8,0x01
-};
-
-static unsigned char XGI330_HiTVGroup3Simu[] =
-{
-      0x00,0x1A,0x22,0x63,0x62,0x22,0x08,0x95,
-      0xDB,0x20,0xB8,0xB8,0x55,0x47,0x2A,0xA6,
-      0x25,0x2F,0x47,0xFA,0xC8,0xFF,0x8E,0x20,
-      0x8C,0x6E,0x60,0x15,0x26,0xD3,0xE4,0x11,
-      0x56,0x36,0x4F,0x6E,0x3F,0x80,0x00,0x80,
-      0x67,0x36,0x01,0x47,0x0E,0x10,0xBE,0xB4,
-      0x01,0x05,0x03,0x7E,0x65,0x31,0x14,0x75,
-      0x18,0x05,0x18,0x05,0x4C,0xA8,0x01
-};
-
-static unsigned char XGI330_HiTVGroup3Text[] =
-{
-      0x00,0x1A,0x22,0x63,0x62,0x22,0x08,0xA7,
-      0xF5,0x20,0xCE,0xCE,0x55,0x47,0x2A,0xA6,
-      0x25,0x2F,0x47,0xFA,0xC8,0xFF,0x8E,0x20,
-      0x8C,0x6E,0x60,0x18,0x2C,0x0C,0x20,0x22,
-      0x56,0x36,0x4F,0x6E,0x3F,0x80,0x00,0x80,
-      0x93,0x3C,0x01,0x50,0x2F,0x10,0xF4,0xCA,
-      0x01,0x05,0x03,0x7E,0x65,0x31,0x14,0x75,
-      0x18,0x05,0x18,0x05,0x4C,0xA8,0x01
-};
-
-static unsigned char XGI330_Ren525pGroup3[] =
-{
-  0x00,0x14,0x15,0x25,0x55,0x15,0x0b,0x13,
-  0xB1,0x41,0x62,0x62,0xFF,0xF4,0x45,0xa6,
-  0x25,0x2F,0x67,0xF6,0xbf,0xFF,0x8E,0x20,
-  0xAC,0xDA,0x60,0xFe,0x6A,0x9A,0x06,0x10,
-  0xd1,0x04,0x18,0x0a,0xFF,0x80,0x00,0x80,
-  0x3c,0x77,0x00,0xEF,0xE0,0x10,0xB0,0xE0,
-  0x10,0x4F,0x0F,0x0F,0x05,0x0F,0x08,0x6E,
-  0x1a,0x1F,0x25,0x2a,0x4C,0xAA,0x01
-};
-
-static unsigned char XGI330_Ren750pGroup3[] =
-{
-  0x00,0x14,0x15,0x25,0x55,0x15,0x0b,0x7a,
-  0x54,0x41,0xE7,0xE7,0xFF,0xF4,0x45,0xa6,
-  0x25,0x2F,0x67,0xF6,0xbf,0xFF,0x8E,0x20,
-  0xAC,0x6A,0x60,0x2b,0x52,0xCD,0x61,0x10,
-  0x51,0x04,0x18,0x0a,0x1F,0x80,0x00,0x80,
-  0xFF,0xA4,0x04,0x2B,0x94,0x21,0x72,0x94,
-  0x26,0x05,0x01,0x0F,0xed,0x0F,0x0A,0x64,
-  0x18,0x1D,0x23,0x28,0x4C,0xAA,0x01
+       0x21, 0x5A, 0x35, 0x6e, 0x04, 0x38, 0x3d, 0x70,
+       0x94, 0x49, 0x01, 0x12, 0x06, 0x3e, 0x35, 0x6d,
+       0x06, 0x14, 0x3e, 0x35, 0x6d, 0x00, 0x45, 0x2b,
+       0x70, 0x50, 0x00, 0x9b, 0x00, 0xd9, 0x5d, 0x17,
+       0x7d, 0x05, 0x45, 0x00, 0x00, 0xe8, 0x00, 0x02,
+       0x0d, 0x00, 0x68, 0xb0, 0x0b, 0x92, 0x8f, 0x40,
+       0x60, 0x80, 0x14, 0x90, 0x8c, 0x60, 0x14, 0x63,
+       0x00, 0x40, 0x3e, 0x00, 0xe1, 0x02, 0x28, 0x00
+};
+
+static unsigned char XGI330_HiTVExtTiming[] = {
+       0x2D, 0x60, 0x2C, 0x5F, 0x08, 0x31, 0x3A, 0x64,
+       0x28, 0x02, 0x01, 0x3D, 0x06, 0x3E, 0x35, 0x6D,
+       0x06, 0x14, 0x3E, 0x35, 0x6D, 0x00, 0xC5, 0x3F,
+       0x64, 0x90, 0x33, 0x8C, 0x18, 0x36, 0x3E, 0x13,
+       0x2A, 0xDE, 0x2A, 0x44, 0x40, 0x2A, 0x44, 0x40,
+       0x8E, 0x8E, 0x82, 0x07, 0x0B,
+       0x92, 0x0F, 0x40, 0x60, 0x80, 0x14, 0x90, 0x8C,
+       0x60, 0x14, 0x3D, 0x63, 0x4F,
+       0x27, 0x00, 0xfc, 0xff, 0x6a, 0x00
+};
+
+static unsigned char XGI330_HiTVSt1Timing[] = {
+       0x32, 0x65, 0x2C, 0x5F, 0x08, 0x31, 0x3A, 0x65,
+       0x28, 0x02, 0x01, 0x3D, 0x06, 0x3E, 0x35, 0x6D,
+       0x06, 0x14, 0x3E, 0x35, 0x6D, 0x00, 0xC5, 0x3F,
+       0x65, 0x90, 0x7B, 0xA8, 0x03, 0xF0, 0x87, 0x03,
+       0x11, 0x15, 0x11, 0xCF, 0x10, 0x11, 0xCF, 0x10,
+       0x35, 0x35, 0x3B, 0x69, 0x1D,
+       0x92, 0x0F, 0x40, 0x60, 0x80, 0x14, 0x90, 0x8C,
+       0x60, 0x04, 0x86, 0xAF, 0x5D,
+       0x0E, 0x00, 0xfc, 0xff, 0x2d, 0x00
+};
+
+static unsigned char XGI330_HiTVSt2Timing[] = {
+       0x32, 0x65, 0x2C, 0x5F, 0x08, 0x31, 0x3A, 0x64,
+       0x28, 0x02, 0x01, 0x3D, 0x06, 0x3E, 0x35, 0x6D,
+       0x06, 0x14, 0x3E, 0x35, 0x6D, 0x00, 0xC5, 0x3F,
+       0x64, 0x90, 0x33, 0x8C, 0x18, 0x36, 0x3E, 0x13,
+       0x2A, 0xDE, 0x2A, 0x44, 0x40, 0x2A, 0x44, 0x40,
+       0x8E, 0x8E, 0x82, 0x07, 0x0B,
+       0x92, 0x0F, 0x40, 0x60, 0x80, 0x14, 0x90, 0x8C,
+       0x60, 0x14, 0x3D, 0x63, 0x4F,
+       0x27, 0x00, 0xFC, 0xff, 0x6a, 0x00
+};
+
+static unsigned char XGI330_HiTVTextTiming[] = {
+       0x32, 0x65, 0x2C, 0x5F, 0x08, 0x31, 0x3A, 0x65,
+       0x28, 0x02, 0x01, 0x3D, 0x06, 0x3E, 0x35, 0x6D,
+       0x06, 0x14, 0x3E, 0x35, 0x6D, 0x00, 0xC5, 0x3F,
+       0x65, 0x90, 0xE7, 0xBC, 0x03, 0x0C, 0x97, 0x03,
+       0x14, 0x78, 0x14, 0x08, 0x20, 0x14, 0x08, 0x20,
+       0xC8, 0xC8, 0x3B, 0xD2, 0x26,
+       0x92, 0x0F, 0x40, 0x60, 0x80, 0x14, 0x90, 0x8C,
+       0x60, 0x04, 0x96, 0x72, 0x5C,
+       0x11, 0x00, 0xFC, 0xFF, 0x32, 0x00
+};
+
+static unsigned char XGI330_YPbPr750pTiming[] = {
+       0x30, 0x1d, 0xe8, 0x09, 0x09, 0xed, 0x0c, 0x0c,
+       0x98, 0x0a, 0x01, 0x0c, 0x06, 0x0d, 0x04, 0x0a,
+       0x06, 0x14, 0x0d, 0x04, 0x0a, 0x00, 0x85, 0x3f,
+       0xed, 0x50, 0x70, 0x9f, 0x16, 0x59, 0x60, 0x13,
+       0x27, 0x0b, 0x27, 0xfc, 0x30, 0x27, 0x1c, 0xb0,
+       0x4b, 0x4b, 0x6f, 0x2f, 0x63,
+       0x92, 0x0F, 0x40, 0x60, 0x80, 0x14, 0x90, 0x8C,
+       0x60, 0x14, 0x73, 0x00, 0x40,
+       0x11, 0x00, 0xfc, 0xff, 0x32, 0x00
+};
+
+static unsigned char XGI330_YPbPr525pTiming[] = {
+       0x3E, 0x11, 0x06, 0x09, 0x0b, 0x0c, 0x0c, 0x0c,
+       0x98, 0x0a, 0x01, 0x0d, 0x06, 0x0d, 0x04, 0x0a,
+       0x06, 0x14, 0x0d, 0x04, 0x0a, 0x00, 0x85, 0x3f,
+       0x0c, 0x50, 0xb2, 0x9f, 0x16, 0x59, 0x4f, 0x13,
+       0xad, 0x11, 0xad, 0x1d, 0x40, 0x8a, 0x3d, 0xb8,
+       0x51, 0x5e, 0x60, 0x49, 0x7d,
+       0x92, 0x0F, 0x40, 0x60, 0x80, 0x14, 0x90, 0x8C,
+       0x60, 0x14, 0x4B, 0x43, 0x41,
+       0x11, 0x00, 0xFC, 0xFF, 0x32, 0x00
+};
+
+static unsigned char XGI330_YPbPr525iTiming[] = {
+       0x1B, 0x21, 0x03, 0x09, 0x05, 0x06, 0x0C, 0x0C,
+       0x94, 0x49, 0x01, 0x0A, 0x06, 0x0D, 0x04, 0x0A,
+       0x06, 0x14, 0x0D, 0x04, 0x0A, 0x00, 0x85, 0x1B,
+       0x0C, 0x50, 0x00, 0x97, 0x00, 0xDA, 0x4A, 0x17,
+       0x7D, 0x05, 0x4B, 0x00, 0x00, 0xE2, 0x00, 0x02,
+       0x03, 0x0A, 0x65, 0x9D, 0x08,
+       0x92, 0x8F, 0x40, 0x60, 0x80, 0x14, 0x90, 0x8C,
+       0x60, 0x14, 0x4B, 0x00, 0x40,
+       0x44, 0x00, 0xDB, 0x02, 0x3B, 0x00
+};
+
+static unsigned char XGI330_HiTVGroup3Data[] = {
+       0x00, 0x1A, 0x22, 0x63, 0x62, 0x22, 0x08, 0x5F,
+       0x05, 0x21, 0xB2, 0xB2, 0x55, 0x77, 0x2A, 0xA6,
+       0x25, 0x2F, 0x47, 0xFA, 0xC8, 0xFF, 0x8E, 0x20,
+       0x8C, 0x6E, 0x60, 0x2E, 0x58, 0x48, 0x72, 0x44,
+       0x56, 0x36, 0x4F, 0x6E, 0x3F, 0x80, 0x00, 0x80,
+       0x4F, 0x7F, 0x03, 0xA8, 0x7D, 0x20, 0x1A, 0xA9,
+       0x14, 0x05, 0x03, 0x7E, 0x64, 0x31, 0x14, 0x75,
+       0x18, 0x05, 0x18, 0x05, 0x4C, 0xA8, 0x01
+};
+
+static unsigned char XGI330_HiTVGroup3Simu[] = {
+       0x00, 0x1A, 0x22, 0x63, 0x62, 0x22, 0x08, 0x95,
+       0xDB, 0x20, 0xB8, 0xB8, 0x55, 0x47, 0x2A, 0xA6,
+       0x25, 0x2F, 0x47, 0xFA, 0xC8, 0xFF, 0x8E, 0x20,
+       0x8C, 0x6E, 0x60, 0x15, 0x26, 0xD3, 0xE4, 0x11,
+       0x56, 0x36, 0x4F, 0x6E, 0x3F, 0x80, 0x00, 0x80,
+       0x67, 0x36, 0x01, 0x47, 0x0E, 0x10, 0xBE, 0xB4,
+       0x01, 0x05, 0x03, 0x7E, 0x65, 0x31, 0x14, 0x75,
+       0x18, 0x05, 0x18, 0x05, 0x4C, 0xA8, 0x01
+};
+
+static unsigned char XGI330_HiTVGroup3Text[] = {
+       0x00, 0x1A, 0x22, 0x63, 0x62, 0x22, 0x08, 0xA7,
+       0xF5, 0x20, 0xCE, 0xCE, 0x55, 0x47, 0x2A, 0xA6,
+       0x25, 0x2F, 0x47, 0xFA, 0xC8, 0xFF, 0x8E, 0x20,
+       0x8C, 0x6E, 0x60, 0x18, 0x2C, 0x0C, 0x20, 0x22,
+       0x56, 0x36, 0x4F, 0x6E, 0x3F, 0x80, 0x00, 0x80,
+       0x93, 0x3C, 0x01, 0x50, 0x2F, 0x10, 0xF4, 0xCA,
+       0x01, 0x05, 0x03, 0x7E, 0x65, 0x31, 0x14, 0x75,
+       0x18, 0x05, 0x18, 0x05, 0x4C, 0xA8, 0x01
+};
+
+static unsigned char XGI330_Ren525pGroup3[] = {
+       0x00, 0x14, 0x15, 0x25, 0x55, 0x15, 0x0b, 0x13,
+       0xB1, 0x41, 0x62, 0x62, 0xFF, 0xF4, 0x45, 0xa6,
+       0x25, 0x2F, 0x67, 0xF6, 0xbf, 0xFF, 0x8E, 0x20,
+       0xAC, 0xDA, 0x60, 0xFe, 0x6A, 0x9A, 0x06, 0x10,
+       0xd1, 0x04, 0x18, 0x0a, 0xFF, 0x80, 0x00, 0x80,
+       0x3c, 0x77, 0x00, 0xEF, 0xE0, 0x10, 0xB0, 0xE0,
+       0x10, 0x4F, 0x0F, 0x0F, 0x05, 0x0F, 0x08, 0x6E,
+       0x1a, 0x1F, 0x25, 0x2a, 0x4C, 0xAA, 0x01
+};
+
+static unsigned char XGI330_Ren750pGroup3[] = {
+       0x00, 0x14, 0x15, 0x25, 0x55, 0x15, 0x0b, 0x7a,
+       0x54, 0x41, 0xE7, 0xE7, 0xFF, 0xF4, 0x45, 0xa6,
+       0x25, 0x2F, 0x67, 0xF6, 0xbf, 0xFF, 0x8E, 0x20,
+       0xAC, 0x6A, 0x60, 0x2b, 0x52, 0xCD, 0x61, 0x10,
+       0x51, 0x04, 0x18, 0x0a, 0x1F, 0x80, 0x00, 0x80,
+       0xFF, 0xA4, 0x04, 0x2B, 0x94, 0x21, 0x72, 0x94,
+       0x26, 0x05, 0x01, 0x0F, 0xed, 0x0F, 0x0A, 0x64,
+       0x18, 0x1D, 0x23, 0x28, 0x4C, 0xAA, 0x01
 };
 
 #if 0
-static struct XGI_PanelDelayTblStruct XGI330_PanelDelayTbl[] =
-{
-{{0x00,0x00}},
-{{0x00,0x00}},
-{{0x00,0x00}},
-{{0x00,0x00}},
-{{0x00,0x00}},
-{{0x00,0x00}},
-{{0x00,0x00}},
-{{0x00,0x00}},
-{{0x00,0x00}},
-{{0x00,0x00}},
-{{0x00,0x00}},
-{{0x00,0x00}},
-{{0x00,0x00}},
-{{0x00,0x00}},
-{{0x00,0x00}},
-{{0x00,0x00}}
-};
-
-static struct XGI330_LVDSDataStruct  XGI330_LVDS320x480Data_1[] =
-{
- {848, 433,400,525},
- {848, 389,400,525},
- {848, 433,400,525},
- {848, 389,400,525},
- {848, 518,400, 525},
- {1056, 628,400,525},
- {400, 525,400,525},
- {800, 449,1000, 644},
- {800, 525,1000, 635}
-};
-
-static struct XGI330_LVDSDataStruct  XGI330_LVDS800x600Data_1[] =
-{
- {848, 433,1060, 629},
- {848, 389,1060, 629},
- {848, 433,1060, 629},
- {848, 389,1060, 629},
- {848, 518,1060, 629},
- {1056, 628,1056, 628},
- {1056, 628,1056, 628},
- {800, 449,1000, 644},
- {800, 525,1000, 635}
-};
-
-static struct XGI330_LVDSDataStruct  XGI330_LVDS800x600Data_2[] =
-{
- {1056, 628,1056, 628},
- {1056, 628,1056, 628},
- {1056, 628,1056, 628},
- {1056, 628,1056, 628},
- {1056, 628,1056, 628},
- {1056, 628,1056, 628},
- {1056, 628,1056, 628},
- {800, 449,1000, 644},
- {800, 525,1000, 635}
+static struct XGI_PanelDelayTblStruct XGI330_PanelDelayTbl[] = {
+       { {0x00, 0x00} },
+       { {0x00, 0x00} },
+       { {0x00, 0x00} },
+       { {0x00, 0x00} },
+       { {0x00, 0x00} },
+       { {0x00, 0x00} },
+       { {0x00, 0x00} },
+       { {0x00, 0x00} },
+       { {0x00, 0x00} },
+       { {0x00, 0x00} },
+       { {0x00, 0x00} },
+       { {0x00, 0x00} },
+       { {0x00, 0x00} },
+       { {0x00, 0x00} },
+       { {0x00, 0x00} },
+       { {0x00, 0x00} }
+};
+
+static struct XGI330_LVDSDataStruct  XGI330_LVDS320x480Data_1[] = {
+       {848,  433, 400,  525},
+       {848,  389, 400,  525},
+       {848,  433, 400,  525},
+       {848,  389, 400,  525},
+       {848,  518, 400,  525},
+       {1056, 628, 400,  525},
+       {400,  525, 400,  525},
+       {800,  449, 1000, 644},
+       {800,  525, 1000, 635}
+};
+
+static struct XGI330_LVDSDataStruct  XGI330_LVDS800x600Data_1[] = {
+       {848,  433, 1060, 629},
+       {848,  389, 1060, 629},
+       {848,  433, 1060, 629},
+       {848,  389, 1060, 629},
+       {848,  518, 1060, 629},
+       {1056, 628, 1056, 628},
+       {1056, 628, 1056, 628},
+       {800,  449, 1000, 644},
+       {800,  525, 1000, 635}
+};
+
+static struct XGI330_LVDSDataStruct  XGI330_LVDS800x600Data_2[] = {
+       {1056, 628, 1056, 628},
+       {1056, 628, 1056, 628},
+       {1056, 628, 1056, 628},
+       {1056, 628, 1056, 628},
+       {1056, 628, 1056, 628},
+       {1056, 628, 1056, 628},
+       {1056, 628, 1056, 628},
+       {800,  449, 1000, 644},
+       {800,  525, 1000, 635}
 };
 #endif
 
-static struct XGI330_LVDSDataStruct  XGI_LVDS1024x768Data_1[] =
-{
- { 960 , 438 , 1344 , 806 } ,  /* 00 (320x200,320x400,640x200,640x400) */
- { 960 , 388 , 1344 , 806 } ,  /* 01 (320x350,640x350) */
- { 1040, 438 , 1344 , 806 } ,  /* 02 (360x400,720x400) */
- { 1040, 388 , 1344 , 806 } ,  /* 03 (720x350) */
- { 960 , 518 , 1344 , 806 } ,  /* 04 (320x240,640x480) */
- {1120 , 638 , 1344 , 806 } ,  /* 05 (400x300,800x600) */
- {1344 , 806 , 1344 , 806 }    /* 06 (512x384,1024x768) */
-};
-
-
-static struct XGI330_LVDSDataStruct  XGI_LVDS1024x768Data_2[] =
-{
- {1344, 806,1344, 806},
- {1344, 806,1344, 806},
- {1344, 806,1344, 806},
- {1344, 806,1344, 806},
- {1344, 806,1344, 806},
- {1344, 806,1344, 806},
- {1344, 806,1344, 806},
- {800, 449,1280, 801},
- {800, 525,1280, 813}
-};
-
-static struct XGI330_LVDSDataStruct  XGI_LVDS1280x1024Data_1[] =
-{
- {1048, 442,1688, 1066},
- {1048, 392,1688, 1066},
- {1048, 442,1688, 1066},
- {1048, 392,1688, 1066},
- {1048, 522,1688, 1066},
- {1208, 642,1688, 1066},
- {1432, 810,1688, 1066},
- {1688, 1066,1688, 1066}
-};
-
-static struct XGI330_LVDSDataStruct  XGI_LVDS1280x1024Data_2[] =
-{
- {1344, 806,1344, 806},
- {1344, 806,1344, 806},
- {1344, 806,1344, 806},
- {1344, 806,1344, 806},
- {1344, 806,1344, 806},
- {1344, 806,1344, 806},
- {1344, 806,1344, 806},
- {800, 449,1280, 801},
- {800, 525,1280, 813}
+static struct XGI330_LVDSDataStruct  XGI_LVDS1024x768Data_1[] = {
+       { 960, 438, 1344, 806}, /* 00 (320x200,320x400,640x200,640x400) */
+       { 960, 388, 1344, 806}, /* 01 (320x350,640x350) */
+       {1040, 438, 1344, 806}, /* 02 (360x400,720x400) */
+       {1040, 388, 1344, 806}, /* 03 (720x350) */
+       { 960, 518, 1344, 806}, /* 04 (320x240,640x480) */
+       {1120, 638, 1344, 806}, /* 05 (400x300,800x600) */
+       {1344, 806, 1344, 806}  /* 06 (512x384,1024x768) */
+};
+
+
+static struct XGI330_LVDSDataStruct  XGI_LVDS1024x768Data_2[] = {
+       {1344, 806, 1344, 806},
+       {1344, 806, 1344, 806},
+       {1344, 806, 1344, 806},
+       {1344, 806, 1344, 806},
+       {1344, 806, 1344, 806},
+       {1344, 806, 1344, 806},
+       {1344, 806, 1344, 806},
+       {800,  449, 1280, 801},
+       {800,  525, 1280, 813}
+};
+
+static struct XGI330_LVDSDataStruct  XGI_LVDS1280x1024Data_1[] = {
+       {1048, 442,  1688, 1066},
+       {1048, 392,  1688, 1066},
+       {1048, 442,  1688, 1066},
+       {1048, 392,  1688, 1066},
+       {1048, 522,  1688, 1066},
+       {1208, 642,  1688, 1066},
+       {1432, 810,  1688, 1066},
+       {1688, 1066, 1688, 1066}
+};
+
+static struct XGI330_LVDSDataStruct  XGI_LVDS1280x1024Data_2[] = {
+       {1344, 806, 1344, 806},
+       {1344, 806, 1344, 806},
+       {1344, 806, 1344, 806},
+       {1344, 806, 1344, 806},
+       {1344, 806, 1344, 806},
+       {1344, 806, 1344, 806},
+       {1344, 806, 1344, 806},
+       {800,  449, 1280, 801},
+       {800,  525, 1280, 813}
 };
 /*
-struct XGI330_LVDSDataStruct  XGI_LVDS1280x768Data_1[] =
-{
- {768,438,1408,806},
- {768,388,1408,806},
- {768,438,1408,806},
- {768,388,1408,806},
- {768,518,1408,806},
- {928,638,1408,806},
- {1408,806,1408,806},
- {1408,806,1408,806},
- {1408,806,1408,806}
-};
-
-struct XGI330_LVDSDataStruct  XGI_LVDS1280x768Data_2[] =
-{
- {1408, 806,1408, 806},
- {1408, 806,1408, 806},
- {1408, 806,1408, 806},
- {1408, 806,1408, 806},
- {1408, 806,1408, 806},
- {1408, 806,1408, 806},
- {1408, 806,1408, 806},
- {1408, 806,1408, 806},
- {1408, 806,1408, 806}
-};
-
-struct XGI330_LVDSDataStruct  XGI_LVDS1280x768NData_1[] =
-{
- {704, 438,1344, 806},
- {704, 388,1344, 806},
- {704, 438,1344, 806},
- {704, 388,1344, 806},
- {704, 518,1344, 806},
- {864, 638,1344, 806},
- {1088, 806,1344, 806},
- {1344, 806,1344, 806},
- {1344, 806,1344, 806}
-};
-
-struct XGI330_LVDSDataStruct  XGI_LVDS1280x768NData_2[] =
-{
- {1344, 806,1344, 806},
- {1344, 806,1344, 806},
- {1344, 806,1344, 806},
- {1344, 806,1344, 806},
- {1344, 806,1344, 806},
- {1344, 806,1344, 806},
- {1344, 806,1344, 806},
- {1344, 806,1344, 806},
- {1344, 806,1344, 806}
-};
-
-struct XGI330_LVDSDataStruct  XGI_LVDS1280x768SData_1[] =
-{
- {1048,438,1688,806},
- {1048,388,1688,806},
- {1148,438,1688,806},
- {1148,388,1688,806},
- {1048,518,1688,806},
- {1208,638,1688,806},
- {1432,806,1688,806},
- {1688,806,1688,806},
- {1688,806,1688,806}
-};
-
-struct XGI330_LVDSDataStruct  XGI_LVDS1280x768SData_2[] =
-{
- {1688,806,1688,806},
- {1688,806,1688,806},
- {1688,806,1688,806},
- {1688,806,1688,806},
- {1688,806,1688,806},
- {1688,806,1688,806},
- {1688,806,1688,806},
- {1688,806,1688,806},
- {1688,806,1688,806}
+struct XGI330_LVDSDataStruct  XGI_LVDS1280x768Data_1[] = {
+       {768,  438, 1408, 806},
+       {768,  388, 1408, 806},
+       {768,  438, 1408, 806},
+       {768,  388, 1408, 806},
+       {768,  518, 1408, 806},
+       {928,  638, 1408, 806},
+       {1408, 806, 1408, 806},
+       {1408, 806, 1408, 806},
+       {1408, 806, 1408, 806}
+};
+
+struct XGI330_LVDSDataStruct  XGI_LVDS1280x768Data_2[] = {
+       {1408, 806, 1408, 806},
+       {1408, 806, 1408, 806},
+       {1408, 806, 1408, 806},
+       {1408, 806, 1408, 806},
+       {1408, 806, 1408, 806},
+       {1408, 806, 1408, 806},
+       {1408, 806, 1408, 806},
+       {1408, 806, 1408, 806},
+       {1408, 806, 1408, 806}
+};
+
+struct XGI330_LVDSDataStruct  XGI_LVDS1280x768NData_1[] = {
+       {704,  438, 1344, 806},
+       {704,  388, 1344, 806},
+       {704,  438, 1344, 806},
+       {704,  388, 1344, 806},
+       {704,  518, 1344, 806},
+       {864,  638, 1344, 806},
+       {1088, 806, 1344, 806},
+       {1344, 806, 1344, 806},
+       {1344, 806, 1344, 806}
+};
+
+struct XGI330_LVDSDataStruct  XGI_LVDS1280x768NData_2[] = {
+       {1344, 806, 1344, 806},
+       {1344, 806, 1344, 806},
+       {1344, 806, 1344, 806},
+       {1344, 806, 1344, 806},
+       {1344, 806, 1344, 806},
+       {1344, 806, 1344, 806},
+       {1344, 806, 1344, 806},
+       {1344, 806, 1344, 806},
+       {1344, 806, 1344, 806}
+};
+
+struct XGI330_LVDSDataStruct  XGI_LVDS1280x768SData_1[] = {
+       {1048, 438, 1688, 806},
+       {1048, 388, 1688, 806},
+       {1148, 438, 1688, 806},
+       {1148, 388, 1688, 806},
+       {1048, 518, 1688, 806},
+       {1208, 638, 1688, 806},
+       {1432, 806, 1688, 806},
+       {1688, 806, 1688, 806},
+       {1688, 806, 1688, 806}
+};
+
+struct XGI330_LVDSDataStruct  XGI_LVDS1280x768SData_2[] = {
+       {1688, 806, 1688, 806},
+       {1688, 806, 1688, 806},
+       {1688, 806, 1688, 806},
+       {1688, 806, 1688, 806},
+       {1688, 806, 1688, 806},
+       {1688, 806, 1688, 806},
+       {1688, 806, 1688, 806},
+       {1688, 806, 1688, 806},
+       {1688, 806, 1688, 806}
 };
 */
-static struct XGI330_LVDSDataStruct  XGI_LVDS1400x1050Data_1[] =
-{
- {928,416,1688,1066},
- {928,366,1688,1066},
- {928,416,1688,1066},
- {928,366,1688,1066},
- {928,496,1688,1066},
- {1088,616,1688,1066},
- {1312,784,1688,1066},
- {1568,1040,1688,1066},
- {1688,1066,1688,1066}
-};
-
-static struct XGI330_LVDSDataStruct  XGI_LVDS1400x1050Data_2[] =
-{
- {1688,1066,1688,1066},
- {1688,1066,1688,1066},
- {1688,1066,1688,1066},
- {1688,1066,1688,1066},
- {1688,1066,1688,1066},
- {1688,1066,1688,1066},
- {1688,1066,1688,1066},
- {1688,1066,1688,1066},
- {1688,1066,1688,1066}
-};
-
-static struct XGI330_LVDSDataStruct XGI_LVDS1600x1200Data_1[] =
-{      /* ;;[ycchen] 12/05/02 LCDHTxLCDVT=2048x1320 */
-        {        1088,520,2048,1320      },/* 00 (320x200,320x400,640x200,640x400) */
-        {        1088,470,2048,1320      },/* 01 (320x350,640x350) */
-        {        1088,520,2048,1320      },/* 02 (360x400,720x400) */
-        {        1088,470,2048,1320      },/* 03 (720x350) */
-        {        1088,600,2048,1320      },/* 04 (320x240,640x480) */
-        {        1248,720,2048,1320      },/* 05 (400x300,800x600) */
-        {        1472,888,2048,1320      },/* 06 (512x384,1024x768) */
-        {        1728,1144,2048,1320     },/* 07 (640x512,1280x1024) */
-        {        1848,1170,2048,1320     },/* 08 (1400x1050) */
-        {        2048,1320,2048,1320     } /* 09 (1600x1200) */
-};
-
-static struct XGI330_LVDSDataStruct XGI_LVDSNoScalingData[] =
-{
-        {        800,449,800,449             }, /* 00 (320x200,320x400,640x200,640x400) */
-        {        800,449,800,449             }, /* 01 (320x350,640x350) */
-        {        800,449,800,449             }, /* 02 (360x400,720x400) */
-        {        800,449,800,449             }, /* 03 (720x350) */
-        {        800,525,800,525             }, /* 04 (640x480x60Hz) */
-        {        1056,628,1056,628           }, /* 05 (800x600x60Hz) */
-        {        1344,806,1344,806           }, /* 06 (1024x768x60Hz) */
-        {        1688,1066,1688,1066         }, /* 07 (1280x1024x60Hz) */
-        {        1688,1066,1688,1066         }, /* 08 (1400x1050x60Hz) ;;[ycchen] 12/19/02 */
-        {        2160,1250,2160,1250         }, /* 09 (1600x1200x60Hz) */
-        {        1688,806,1688,806           }  /* 0A (1280x768x60Hz) */
-};
-
-static struct XGI330_LVDSDataStruct XGI_LVDS1024x768Data_1x75[] =
-{
-       {960,438,1312,800  }, /* 00 (320x200,320x400,640x200,640x400) */
-        {960,388,1312,800  }, /* 01 (320x350,640x350) */
-        {1040,438,1312,800 }, /* 02 (360x400,720x400) */
-        {1040,388,1312,800 }, /* 03 (720x350) */
-        {928,512,1312,800  }, /* 04 (320x240,640x480) */
-        {1088,632,1312,800 }, /* 05 (400x300,800x600) */
-        {1312,800,1312,800 }, /* 06 (512x384,1024x768) */
-};
-
-
-static struct XGI330_LVDSDataStruct XGI_LVDS1024x768Data_2x75[] =
-{
-        {1312,800,1312,800}, /* ; 00 (320x200,320x400,640x200,640x400) */
-        {1312,800,1312,800}, /* ; 01 (320x350,640x350) */
-        {1312,800,1312,800}, /* ; 02 (360x400,720x400) */
-        {1312,800,1312,800}, /* ; 03 (720x350) */
-        {1312,800,1312,800}, /* ; 04 (320x240,640x480) */
-        {1312,800,1312,800}, /* ; 05 (400x300,800x600) */
-        {1312,800,1312,800}, /* ; 06 (512x384,1024x768) */
-};
-
-static struct XGI330_LVDSDataStruct XGI_LVDS1280x1024Data_1x75[] =
-{
-        {1048,442,1688,1066  }, /* ; 00 (320x200,320x400,640x200,640x400) */
-        {1048,392,1688,1066  }, /* ; 01 (320x350,640x350) */
-        {1128,442,1688,1066  }, /* ; 02 (360x400,720x400) */
-        {1128,392,1688,1066  }, /* ; 03 (720x350) */
-        {1048,522,1688,1066  }, /* ; 04 (320x240,640x480) */
-        {1208,642,1688,1066  }, /* ; 05 (400x300,800x600) */
-        {1432,810,1688,1066  }, /* ; 06 (512x384,1024x768) */
-        {1688,1066,1688,1066 }, /* ; 06; 07 (640x512,1280x1024) */
-};
-
-static struct XGI330_LVDSDataStruct XGI_LVDS1280x1024Data_2x75[] =
-{
-        {1688,1066,1688,1066 }, /* ; 00 (320x200,320x400,640x200,640x400) */
-        {1688,1066,1688,1066 }, /* ; 01 (320x350,640x350) */
-        {1688,1066,1688,1066 }, /* ; 02 (360x400,720x400) */
-        {1688,1066,1688,1066 }, /* ; 03 (720x350) */
-        {1688,1066,1688,1066 }, /* ; 04 (320x240,640x480) */
-        {1688,1066,1688,1066 }, /* ; 05 (400x300,800x600) */
-        {1688,1066,1688,1066 }, /* ; 06 (512x384,1024x768) */
-        {1688,1066,1688,1066 }, /* ; 06; 07 (640x512,1280x1024) */
-};
-
-static struct XGI330_LVDSDataStruct XGI_LVDSNoScalingDatax75[] =
-{
-        {800,449,800,449     }, /* ; 00 (320x200,320x400,640x200,640x400) */
-        {800,449,800,449     }, /* ; 01 (320x350,640x350) */
-        {900,449,900,449     }, /* ; 02 (360x400,720x400) */
-        {900,449,900,449     }, /* ; 03 (720x350) */
-        {800,500,800,500     }, /* ; 04 (640x480x75Hz) */
-        {1056,625,1056,625   }, /* ; 05 (800x600x75Hz) */
-        {1312,800,1312,800   }, /* ; 06 (1024x768x75Hz) */
-        {1688,1066,1688,1066 }, /* ; 07 (1280x1024x75Hz) */
-        {1688,1066,1688,1066 }, /* ; 08 (1400x1050x75Hz) ;;[ycchen] 12/19/02 */
-        {2160,1250,2160,1250 }, /* ; 09 (1600x1200x75Hz) */
-        {1688,806,1688,806   }, /* ; 0A (1280x768x75Hz) */
-};
-
-static struct XGI330_LVDSDataStruct XGI_LVDS1024x768Des_1[] =
-{
-       {      0,1048,   0, 771     }, /* 00 (320x200,320x400,640x200,640x400) */
-        {      0,1048,   0, 771     }, /* 01 (320x350,640x350) */
-        {      0,1048,   0, 771     }, /* 02 (360x400,720x400) */
-        {      0,1048,   0, 771     }, /* 03 (720x350) */
-        {      0,1048,   0, 771     }, /* 04 (640x480x60Hz) */
-        {      0,1048,   0, 771     }, /* 05 (800x600x60Hz) */
-        {      0,1048, 805, 770     }  /* 06 (1024x768x60Hz) */
+static struct XGI330_LVDSDataStruct  XGI_LVDS1400x1050Data_1[] = {
+       {928,   416, 1688, 1066},
+       {928,   366, 1688, 1066},
+       {928,   416, 1688, 1066},
+       {928,   366, 1688, 1066},
+       {928,   496, 1688, 1066},
+       {1088,  616, 1688, 1066},
+       {1312,  784, 1688, 1066},
+       {1568, 1040, 1688, 1066},
+       {1688, 1066, 1688, 1066}
+};
+
+static struct XGI330_LVDSDataStruct  XGI_LVDS1400x1050Data_2[] = {
+       {1688, 1066, 1688, 1066},
+       {1688, 1066, 1688, 1066},
+       {1688, 1066, 1688, 1066},
+       {1688, 1066, 1688, 1066},
+       {1688, 1066, 1688, 1066},
+       {1688, 1066, 1688, 1066},
+       {1688, 1066, 1688, 1066},
+       {1688, 1066, 1688, 1066},
+       {1688, 1066, 1688, 1066}
+};
+
+/* ;;[ycchen] 12/05/02 LCDHTxLCDVT=2048x1320 */
+static struct XGI330_LVDSDataStruct XGI_LVDS1600x1200Data_1[] = {
+       {1088, 520,  2048, 1320}, /* 00 (320x200,320x400,640x200,640x400) */
+       {1088, 470,  2048, 1320}, /* 01 (320x350,640x350) */
+       {1088, 520,  2048, 1320}, /* 02 (360x400,720x400) */
+       {1088, 470,  2048, 1320}, /* 03 (720x350) */
+       {1088, 600,  2048, 1320}, /* 04 (320x240,640x480) */
+       {1248, 720,  2048, 1320}, /* 05 (400x300,800x600) */
+       {1472, 888,  2048, 1320}, /* 06 (512x384,1024x768) */
+       {1728, 1144, 2048, 1320}, /* 07 (640x512,1280x1024) */
+       {1848, 1170, 2048, 1320}, /* 08 (1400x1050) */
+       {2048, 1320, 2048, 1320}  /* 09 (1600x1200) */
+};
+
+static struct XGI330_LVDSDataStruct XGI_LVDSNoScalingData[] = {
+       { 800,  449,  800,  449}, /* 00 (320x200,320x400,640x200,640x400) */
+       { 800,  449,  800,  449}, /* 01 (320x350,640x350) */
+       { 800,  449,  800,  449}, /* 02 (360x400,720x400) */
+       { 800,  449,  800,  449}, /* 03 (720x350) */
+       { 800,  525,  800,  525}, /* 04 (640x480x60Hz) */
+       {1056,  628, 1056,  628}, /* 05 (800x600x60Hz) */
+       {1344,  806, 1344,  806}, /* 06 (1024x768x60Hz) */
+       {1688, 1066, 1688, 1066}, /* 07 (1280x1024x60Hz) */
+       {1688, 1066, 1688, 1066}, /* 08 (1400x1050x60Hz) ;;[ycchen] 12/19/02 */
+       {2160, 1250, 2160, 1250}, /* 09 (1600x1200x60Hz) */
+       {1688,  806, 1688,  806}  /* 0A (1280x768x60Hz) */
+};
+
+static struct XGI330_LVDSDataStruct XGI_LVDS1024x768Data_1x75[] = {
+       { 960, 438, 1312, 800}, /* 00 (320x200,320x400,640x200,640x400) */
+       { 960, 388, 1312, 800}, /* 01 (320x350,640x350) */
+       {1040, 438, 1312, 800}, /* 02 (360x400,720x400) */
+       {1040, 388, 1312, 800}, /* 03 (720x350) */
+       { 928, 512, 1312, 800}, /* 04 (320x240,640x480) */
+       {1088, 632, 1312, 800}, /* 05 (400x300,800x600) */
+       {1312, 800, 1312, 800}, /* 06 (512x384,1024x768) */
+};
+
+
+static struct XGI330_LVDSDataStruct XGI_LVDS1024x768Data_2x75[] = {
+       {1312, 800, 1312, 800}, /* ; 00 (320x200,320x400,640x200,640x400) */
+       {1312, 800, 1312, 800}, /* ; 01 (320x350,640x350) */
+       {1312, 800, 1312, 800}, /* ; 02 (360x400,720x400) */
+       {1312, 800, 1312, 800}, /* ; 03 (720x350) */
+       {1312, 800, 1312, 800}, /* ; 04 (320x240,640x480) */
+       {1312, 800, 1312, 800}, /* ; 05 (400x300,800x600) */
+       {1312, 800, 1312, 800}, /* ; 06 (512x384,1024x768) */
+};
+
+static struct XGI330_LVDSDataStruct XGI_LVDS1280x1024Data_1x75[] = {
+       {1048,  442, 1688, 1066  }, /* ; 00 (320x200,320x400,640x200,640x400) */
+       {1048,  392, 1688, 1066  }, /* ; 01 (320x350,640x350) */
+       {1128,  442, 1688, 1066  }, /* ; 02 (360x400,720x400) */
+       {1128,  392, 1688, 1066  }, /* ; 03 (720x350) */
+       {1048,  522, 1688, 1066  }, /* ; 04 (320x240,640x480) */
+       {1208,  642, 1688, 1066  }, /* ; 05 (400x300,800x600) */
+       {1432,  810, 1688, 1066  }, /* ; 06 (512x384,1024x768) */
+       {1688, 1066, 1688, 1066 },  /* ; 06; 07 (640x512,1280x1024) */
+};
+
+static struct XGI330_LVDSDataStruct XGI_LVDS1280x1024Data_2x75[] = {
+       {1688, 1066, 1688, 1066 }, /* ; 00 (320x200,320x400,640x200,640x400) */
+       {1688, 1066, 1688, 1066 }, /* ; 01 (320x350,640x350) */
+       {1688, 1066, 1688, 1066 }, /* ; 02 (360x400,720x400) */
+       {1688, 1066, 1688, 1066 }, /* ; 03 (720x350) */
+       {1688, 1066, 1688, 1066 }, /* ; 04 (320x240,640x480) */
+       {1688, 1066, 1688, 1066 }, /* ; 05 (400x300,800x600) */
+       {1688, 1066, 1688, 1066 }, /* ; 06 (512x384,1024x768) */
+       {1688, 1066, 1688, 1066 }, /* ; 06; 07 (640x512,1280x1024) */
+};
+
+static struct XGI330_LVDSDataStruct XGI_LVDSNoScalingDatax75[] = {
+       { 800,  449,  800, 449},  /* ; 00 (320x200,320x400,640x200,640x400) */
+       { 800,  449,  800, 449},  /* ; 01 (320x350,640x350) */
+       { 900,  449,  900, 449},  /* ; 02 (360x400,720x400) */
+       { 900,  449,  900, 449},  /* ; 03 (720x350) */
+       { 800,  500,  800, 500},  /* ; 04 (640x480x75Hz) */
+       {1056,  625, 1056, 625},  /* ; 05 (800x600x75Hz) */
+       {1312,  800, 1312, 800},  /* ; 06 (1024x768x75Hz) */
+       {1688, 1066, 1688, 1066}, /* ; 07 (1280x1024x75Hz) */
+       {1688, 1066, 1688, 1066}, /* ; 08 (1400x1050x75Hz)
+                                    ;;[ycchen] 12/19/02 */
+       {2160, 1250, 2160, 1250}, /* ; 09 (1600x1200x75Hz) */
+       {1688,  806, 1688, 806},  /* ; 0A (1280x768x75Hz) */
+};
+
+static struct XGI330_LVDSDataStruct XGI_LVDS1024x768Des_1[] = {
+       {0, 1048,   0, 771}, /* 00 (320x200,320x400,640x200,640x400) */
+       {0, 1048,   0, 771}, /* 01 (320x350,640x350) */
+       {0, 1048,   0, 771}, /* 02 (360x400,720x400) */
+       {0, 1048,   0, 771}, /* 03 (720x350) */
+       {0, 1048,   0, 771}, /* 04 (640x480x60Hz) */
+       {0, 1048,   0, 771}, /* 05 (800x600x60Hz) */
+       {0, 1048, 805, 770}  /* 06 (1024x768x60Hz) */
 } ;
 
-static struct XGI330_LVDSDataStruct XGI_LVDS1024x768Des_2[] =
-{
-       {      1142, 856, 622, 587     }, /* 00 (320x200,320x400,640x200,640x400) */
-        {      1142, 856, 597, 562     }, /* 01 (320x350,640x350) */
-        {      1142, 856, 622, 587     }, /* 02 (360x400,720x400) */
-        {      1142, 856, 597, 562     }, /* 03 (720x350) */
-        {      1142,1048, 722, 687     }, /* 04 (640x480x60Hz) */
-        {      1232, 936, 722, 687     }, /* 05 (800x600x60Hz) */
-        {         0,1048, 805, 771     }  /* 06 (1024x768x60Hz) */
-};
-
-static struct XGI330_LVDSDataStruct XGI_LVDS1024x768Des_3[] =
-{
-       {       320,  24, 622, 587     }, /* 00 (320x200,320x400,640x200,640x400) */
-        {       320,  24, 597, 562     }, /* 01 (320x350,640x350) */
-        {       320,  24, 622, 587     }, /* 02 (360x400,720x400) */
-        {       320,  24, 597, 562     }, /* 03 (720x350) */
-        {       320,  24, 722, 687     }  /* 04 (640x480x60Hz) */
-};
-
-static struct XGI330_LVDSDataStruct XGI_LVDS1280x1024Des_1[] =
-{
-       {      0,1328,    0, 1025     }, /* 00 (320x200,320x400,640x200,640x400) */
-        {      0,1328,    0, 1025     }, /* 01 (320x350,640x350) */
-        {      0,1328,    0, 1025     }, /* 02 (360x400,720x400) */
-        {      0,1328,    0, 1025     }, /* 03 (720x350) */
-        {      0,1328,    0, 1025     }, /* 04 (640x480x60Hz) */
-        {      0,1328,    0, 1025     }, /* 05 (800x600x60Hz) */
-        {      0,1328,    0, 1025     }, /* 06 (1024x768x60Hz) */
-        {      0,1328, 1065, 1024     }  /* 07 (1280x1024x60Hz) */
+static struct XGI330_LVDSDataStruct XGI_LVDS1024x768Des_2[] = {
+       {1142,  856, 622, 587}, /* 00 (320x200,320x400,640x200,640x400) */
+       {1142,  856, 597, 562}, /* 01 (320x350,640x350) */
+       {1142,  856, 622, 587}, /* 02 (360x400,720x400) */
+       {1142,  856, 597, 562}, /* 03 (720x350) */
+       {1142, 1048, 722, 687}, /* 04 (640x480x60Hz) */
+       {1232,  936, 722, 687}, /* 05 (800x600x60Hz) */
+       {   0, 1048, 805, 771}  /* 06 (1024x768x60Hz) */
+};
+
+static struct XGI330_LVDSDataStruct XGI_LVDS1024x768Des_3[] = {
+       {320, 24, 622, 587}, /* 00 (320x200,320x400,640x200,640x400) */
+       {320, 24, 597, 562}, /* 01 (320x350,640x350) */
+       {320, 24, 622, 587}, /* 02 (360x400,720x400) */
+       {320, 24, 597, 562}, /* 03 (720x350) */
+       {320, 24, 722, 687}  /* 04 (640x480x60Hz) */
+};
+
+static struct XGI330_LVDSDataStruct XGI_LVDS1280x1024Des_1[] = {
+       {0, 1328,    0, 1025}, /* 00 (320x200,320x400,640x200,640x400) */
+       {0, 1328,    0, 1025}, /* 01 (320x350,640x350) */
+       {0, 1328,    0, 1025}, /* 02 (360x400,720x400) */
+       {0, 1328,    0, 1025}, /* 03 (720x350) */
+       {0, 1328,    0, 1025}, /* 04 (640x480x60Hz) */
+       {0, 1328,    0, 1025}, /* 05 (800x600x60Hz) */
+       {0, 1328,    0, 1025}, /* 06 (1024x768x60Hz) */
+       {0, 1328, 1065, 1024}  /* 07 (1280x1024x60Hz) */
 };
 
  /* The Display setting for DE Mode Panel */
-static struct XGI330_LVDSDataStruct XGI_LVDS1280x1024Des_2[] =
-{
-       {      1368,1008,752,711     }, /* 00 (320x200,320x400,640x200,640x400) */
-        {      1368,1008,729,688     }, /* 01 (320x350,640x350) */
-        {      1408,1048,752,711     }, /* 02 (360x400,720x400) */
-        {      1408,1048,729,688     }, /* 03 (720x350) */
-        {      1368,1008,794,753     }, /* 04 (640x480x60Hz) */
-        {      1448,1068,854,813     }, /* 05 (800x600x60Hz) */
-        {      1560,1200,938,897     }, /* 06 (1024x768x60Hz) */
-        {      0000,1328,0,1025     }  /* 07 (1280x1024x60Hz) */
-};
-
-static struct XGI330_LVDSDataStruct XGI_LVDS1400x1050Des_1[] =
-{
-       {      0,1448,0,1051     }, /* 00 (320x200,320x400,640x200,640x400) */
-        {      0,1448,0,1051     }, /* 01 (320x350,640x350) */
-        {      0,1448,0,1051     }, /* 02 (360x400,720x400) */
-        {      0,1448,0,1051     }, /* 03 (720x350) */
-        {      0,1448,0,1051     }, /* 04 (640x480x60Hz) */
-        {      0,1448,0,1051     }, /* 05 (800x600x60Hz) */
-        {      0,1448,0,1051     }, /* 06 (1024x768x60Hz) */
-        {      0,1448,0,1051     }, /* 07 (1280x1024x60Hz) */
-        {      0,1448,0,1051     }  /* 08 (1400x1050x60Hz) */
-};
-
-static struct XGI330_LVDSDataStruct XGI_LVDS1400x1050Des_2[] =
-{
-       {      1308,1068, 781, 766     }, /* 00 (320x200,320x400,640x200,640x400) */
-        {      1308,1068, 781, 766     }, /* 01 (320x350,640x350) */
-        {      1308,1068, 781, 766     }, /* 02 (360x400,720x400) */
-        {      1308,1068, 781, 766     }, /* 03 (720x350) */
-        {      1308,1068, 781, 766     }, /* 04 (640x480x60Hz) */
-        {      1388,1148, 841, 826     }, /* 05 (800x600x60Hz) */
-        {      1490,1250, 925, 910     }, /* 06 (1024x768x60Hz) */
-        {      1608,1368,1053,1038     }, /* 07 (1280x1024x60Hz) */
-        {      0,1448,0,1051     }  /* 08 (1400x1050x60Hz) */
-};
-
-static struct XGI330_LVDSDataStruct XGI_LVDS1600x1200Des_1[] =
-{
-       {      0,1664,0,1201     }, /* 00 (320x200,320x400,640x200,640x400) */
-        {      0,1664,0,1201     }, /* 01 (320x350,640x350) */
-        {      0,1664,0,1201     }, /* 02 (360x400,720x400) */
-        {      0,1664,0,1201     }, /* 03 (720x350) */
-        {      0,1664,0,1201     }, /* 04 (640x480x60Hz) */
-        {      0,1664,0,1201     }, /* 05 (800x600x60Hz) */
-        {      0,1664,0,1201     }, /* 06 (1024x768x60Hz) */
-        {      0,1664,0,1201     }, /* 07 (1280x1024x60Hz) */
-        {      0,1664,0,1201     }, /* 08 (1400x1050x60Hz) */
-        {      0,1664,0,1201     }  /* 09 (1600x1200x60Hz) */
-};
-
-
-
-static struct XGI330_LCDDataDesStruct2  XGI_LVDSNoScalingDesData[] =
-{
-       {     0, 648, 448, 405,  96,   2   }, /* 00 (320x200,320x400,640x200,640x400) */
-        {     0, 648, 448, 355,  96,   2   }, /* 01 (320x350,640x350) */
-        {     0, 648, 448, 405,  96,   2   }, /* 02 (360x400,720x400) */
-        {     0, 648, 448, 355,  96,   2   }, /* 03 (720x350) */
-        {     0, 648,  1, 483,  96,   2   }, /* 04 (640x480x60Hz) */
-        {     0, 840, 627, 600, 128,   4   }, /* 05 (800x600x60Hz) */
-        {     0,1048, 805, 770, 136,   6   }, /* 06 (1024x768x60Hz) */
-        {     0,1328,0,1025, 112,   3   }, /* 07 (1280x1024x60Hz) */
-        {     0,1438,0,1051, 112,   3   }, /* 08 (1400x1050x60Hz) ;;[ycchen] 12/19/02 */
-        {     0,1664,0,1201, 192,   3   }, /* 09 (1600x1200x60Hz) */
-        {     0,1328,0,0771, 112,   6   }  /* 0A (1280x768x60Hz) */
-};
-
-static struct XGI330_LVDSDataStruct XGI_LVDS1024x768Des_1x75[] =                       /* ; 1024x768 Full-screen */
-{
-        {0,1040,0,769}, /* ; 00 (320x200,320x400,640x200,640x400) */
-        {0,1040,0,769}, /* ; 01 (320x350,640x350) */
-        {0,1040,0,769}, /* ; 02 (360x400,720x400) */
-        {0,1040,0,769}, /* ; 03 (720x350) */
-        {0,1040,0,769}, /* ; 04 (640x480x75Hz) */
-        {0,1040,0,769}, /* ; 05 (800x600x75Hz) */
-        {0,1040,0,769} /* ; 06 (1024x768x75Hz) */
-};
-
-static struct XGI330_LVDSDataStruct XGI_LVDS1024x768Des_2x75[] = /* ; 1024x768 center-screen (Enh. Mode) */
-{
-        {1142, 856,622,587 }, /* 00 (320x200,320x400,640x200,640x400) */
-        {1142, 856,597,562 }, /* 01 (320x350,640x350) */
-        {1142, 856,622,587 }, /* 02 (360x400,720x400) */
-        {1142, 856,597,562 }, /* 03 (720x350) */
-        {1142,1048,722,687 }, /* 04 (640x480x60Hz) */
-        {1232, 936,722,687 }, /* 05 (800x600x60Hz) */
-        {   0,1048,805,771 }  /* 06 (1024x768x60Hz) */
-};
-
-static struct XGI330_LVDSDataStruct XGI_LVDS1024x768Des_3x75[] = /* ; 1024x768 center-screen (St.Mode) */
-{
-        {320,24,622,587  }, /* ; 00 (320x200,320x400,640x200,640x400) */
-        {320,24,597,562  }, /* ; 01 (320x350,640x350) */
-        {320,24,622,587  }, /* ; 02 (360x400,720x400) */
-        {320,24,597,562  }, /* ; 03 (720x350) */
-        {320,24,722,687  } /* ; 04 (640x480x60Hz) */
-};
-
-static struct XGI330_LVDSDataStruct XGI_LVDS1280x1024Des_1x75[] =
-{
-        {0,1296,0,1025}, /* ; 00 (320x200,320x400,640x200,640x400) */
-        {0,1296,0,1025}, /* ; 01 (320x350,640x350) */
-        {0,1296,0,1025}, /* ; 02 (360x400,720x400) */
-        {0,1296,0,1025}, /* ; 03 (720x350) */
-        {0,1296,0,1025}, /* ; 04 (640x480x75Hz) */
-        {0,1296,0,1025}, /* ; 05 (800x600x75Hz) */
-        {0,1296,0,1025}, /* ; 06 (1024x768x75Hz) */
-        {0,1296,0,1025} /* ; 07 (1280x1024x75Hz) */
+static struct XGI330_LVDSDataStruct XGI_LVDS1280x1024Des_2[] = {
+       {1368, 1008, 752, 711}, /* 00 (320x200,320x400,640x200,640x400) */
+       {1368, 1008, 729, 688}, /* 01 (320x350,640x350) */
+       {1408, 1048, 752, 711}, /* 02 (360x400,720x400) */
+       {1408, 1048, 729, 688}, /* 03 (720x350) */
+       {1368, 1008, 794, 753}, /* 04 (640x480x60Hz) */
+       {1448, 1068, 854, 813}, /* 05 (800x600x60Hz) */
+       {1560, 1200, 938, 897}, /* 06 (1024x768x60Hz) */
+       {0000, 1328,   0, 1025} /* 07 (1280x1024x60Hz) */
+};
+
+static struct XGI330_LVDSDataStruct XGI_LVDS1400x1050Des_1[] = {
+       {0, 1448, 0, 1051}, /* 00 (320x200,320x400,640x200,640x400) */
+       {0, 1448, 0, 1051}, /* 01 (320x350,640x350) */
+       {0, 1448, 0, 1051}, /* 02 (360x400,720x400) */
+       {0, 1448, 0, 1051}, /* 03 (720x350) */
+       {0, 1448, 0, 1051}, /* 04 (640x480x60Hz) */
+       {0, 1448, 0, 1051}, /* 05 (800x600x60Hz) */
+       {0, 1448, 0, 1051}, /* 06 (1024x768x60Hz) */
+       {0, 1448, 0, 1051}, /* 07 (1280x1024x60Hz) */
+       {0, 1448, 0, 1051}  /* 08 (1400x1050x60Hz) */
+};
+
+static struct XGI330_LVDSDataStruct XGI_LVDS1400x1050Des_2[] = {
+       {1308, 1068,  781,  766}, /* 00 (320x200,320x400,640x200,640x400) */
+       {1308, 1068,  781,  766}, /* 01 (320x350,640x350) */
+       {1308, 1068,  781,  766}, /* 02 (360x400,720x400) */
+       {1308, 1068,  781,  766}, /* 03 (720x350) */
+       {1308, 1068,  781,  766}, /* 04 (640x480x60Hz) */
+       {1388, 1148,  841,  826}, /* 05 (800x600x60Hz) */
+       {1490, 1250,  925,  910}, /* 06 (1024x768x60Hz) */
+       {1608, 1368, 1053, 1038}, /* 07 (1280x1024x60Hz) */
+       {   0, 1448,    0, 1051}  /* 08 (1400x1050x60Hz) */
+};
+
+static struct XGI330_LVDSDataStruct XGI_LVDS1600x1200Des_1[] = {
+       {0, 1664, 0, 1201}, /* 00 (320x200,320x400,640x200,640x400) */
+       {0, 1664, 0, 1201}, /* 01 (320x350,640x350) */
+       {0, 1664, 0, 1201}, /* 02 (360x400,720x400) */
+       {0, 1664, 0, 1201}, /* 03 (720x350) */
+       {0, 1664, 0, 1201}, /* 04 (640x480x60Hz) */
+       {0, 1664, 0, 1201}, /* 05 (800x600x60Hz) */
+       {0, 1664, 0, 1201}, /* 06 (1024x768x60Hz) */
+       {0, 1664, 0, 1201}, /* 07 (1280x1024x60Hz) */
+       {0, 1664, 0, 1201}, /* 08 (1400x1050x60Hz) */
+       {0, 1664, 0, 1201}  /* 09 (1600x1200x60Hz) */
+};
+
+static struct XGI330_LCDDataDesStruct2  XGI_LVDSNoScalingDesData[] = {
+       {0,  648,  448,  405,  96, 2}, /* 00 (320x200,320x400,
+                                             640x200,640x400) */
+       {0,  648,  448,  355,  96, 2}, /* 01 (320x350,640x350) */
+       {0,  648,  448,  405,  96, 2}, /* 02 (360x400,720x400) */
+       {0,  648,  448,  355,  96, 2}, /* 03 (720x350) */
+       {0,  648,    1,  483,  96, 2}, /* 04 (640x480x60Hz) */
+       {0,  840,  627,  600, 128, 4}, /* 05 (800x600x60Hz) */
+       {0, 1048,  805,  770, 136, 6}, /* 06 (1024x768x60Hz) */
+       {0, 1328,    0, 1025, 112, 3}, /* 07 (1280x1024x60Hz) */
+       {0, 1438,    0, 1051, 112, 3}, /* 08 (1400x1050x60Hz)
+                                       ;;[ycchen] 12/19/02 */
+       {0, 1664,    0, 1201, 192, 3}, /* 09 (1600x1200x60Hz) */
+       {0, 1328,    0, 0771, 112, 6}  /* 0A (1280x768x60Hz) */
+};
+
+/* ; 1024x768 Full-screen */
+static struct XGI330_LVDSDataStruct XGI_LVDS1024x768Des_1x75[] = {
+       {0, 1040, 0, 769}, /* ; 00 (320x200,320x400,640x200,640x400) */
+       {0, 1040, 0, 769}, /* ; 01 (320x350,640x350) */
+       {0, 1040, 0, 769}, /* ; 02 (360x400,720x400) */
+       {0, 1040, 0, 769}, /* ; 03 (720x350) */
+       {0, 1040, 0, 769}, /* ; 04 (640x480x75Hz) */
+       {0, 1040, 0, 769}, /* ; 05 (800x600x75Hz) */
+       {0, 1040, 0, 769}  /* ; 06 (1024x768x75Hz) */
+};
+
+/* ; 1024x768 center-screen (Enh. Mode) */
+static struct XGI330_LVDSDataStruct XGI_LVDS1024x768Des_2x75[] = {
+       {1142,  856, 622, 587}, /* 00 (320x200,320x400,640x200,640x400) */
+       {1142,  856, 597, 562}, /* 01 (320x350,640x350) */
+       {1142,  856, 622, 587}, /* 02 (360x400,720x400) */
+       {1142,  856, 597, 562}, /* 03 (720x350) */
+       {1142, 1048, 722, 687}, /* 04 (640x480x60Hz) */
+       {1232,  936, 722, 687}, /* 05 (800x600x60Hz) */
+       {   0, 1048, 805, 771}  /* 06 (1024x768x60Hz) */
+};
+
+/* ; 1024x768 center-screen (St.Mode) */
+static struct XGI330_LVDSDataStruct XGI_LVDS1024x768Des_3x75[] =  {
+       {320, 24, 622, 587}, /* ; 00 (320x200,320x400,640x200,640x400) */
+       {320, 24, 597, 562}, /* ; 01 (320x350,640x350) */
+       {320, 24, 622, 587}, /* ; 02 (360x400,720x400) */
+       {320, 24, 597, 562}, /* ; 03 (720x350) */
+       {320, 24, 722, 687}  /* ; 04 (640x480x60Hz) */
+};
+
+static struct XGI330_LVDSDataStruct XGI_LVDS1280x1024Des_1x75[] = {
+       {0, 1296, 0, 1025}, /* ; 00 (320x200,320x400,640x200,640x400) */
+       {0, 1296, 0, 1025}, /* ; 01 (320x350,640x350) */
+       {0, 1296, 0, 1025}, /* ; 02 (360x400,720x400) */
+       {0, 1296, 0, 1025}, /* ; 03 (720x350) */
+       {0, 1296, 0, 1025}, /* ; 04 (640x480x75Hz) */
+       {0, 1296, 0, 1025}, /* ; 05 (800x600x75Hz) */
+       {0, 1296, 0, 1025}, /* ; 06 (1024x768x75Hz) */
+       {0, 1296, 0, 1025}  /* ; 07 (1280x1024x75Hz) */
 };
 
 /* The Display setting for DE Mode Panel */
-static struct XGI330_LVDSDataStruct XGI_LVDS1280x1024Des_2x75[] =   /* [ycchen] 02/18/03 Set DE as default */
-{
-        {1368,976,752,711 }, /* ; 00 (320x200,320x400,640x200,640x400) */
-        {1368,976,729,688 }, /* ; 01 (320x350,640x350) */
-        {1408,976,752,711 }, /* ; 02 (360x400,720x400) */
-        {1408,976,729,688 }, /* ; 03 (720x350) */
-        {1368,976,794,753 }, /* ; 04 (640x480x75Hz) */
-        {1448,1036,854,813}, /* ; 05 (800x600x75Hz) */
-        {1560,1168,938,897}, /* ; 06 (1024x768x75Hz) */
-        {0,1296,0,1025    } /* ; 07 (1280x1024x75Hz) */
-};
-
-static struct XGI330_LCDDataDesStruct2 XGI_LVDSNoScalingDesDatax75[] =  /* Scaling LCD 75Hz */
-{
-       { 0,648,448,405,96,2  }, /* ; 00 (320x200,320x400,640x200,640x400) */
-       { 0,648,448,355,96,2  }, /* ; 01 (320x350,640x350) */
-       { 0,729,448,405,108,2 }, /* ; 02 (360x400,720x400) */
-       { 0,729,448,355,108,2 }, /* ; 03 (720x350) */
-       { 0,656,0,481,64,3    }, /* ; 04 (640x480x75Hz) */
-       { 0,816,0,601,80,3    }, /* ; 05 (800x600x75Hz) */
-       { 0,1040,0,769,96,3   }, /* ; 06 (1024x768x75Hz) */
-       { 0,1296,0,1025,144,3 }, /* ; 07 (1280x1024x75Hz) */
-       { 0,1448,0,1051,112,3 }, /* ; 08 (1400x1050x75Hz) ;;[ycchen] 12/19/02 */
-       { 0,1664,0,1201,192,3 }, /* ; 09 (1600x1200x75Hz) */
-       { 0,1328,0,771,112,6  }  /* ; 0A (1280x768x75Hz) */
+/* [ycchen] 02/18/03 Set DE as default */
+static struct XGI330_LVDSDataStruct XGI_LVDS1280x1024Des_2x75[] = {
+       {1368,  976, 752,  711}, /* ; 00 (320x200,320x400,640x200,640x400) */
+       {1368,  976, 729,  688}, /* ; 01 (320x350,640x350) */
+       {1408,  976, 752,  711}, /* ; 02 (360x400,720x400) */
+       {1408,  976, 729,  688}, /* ; 03 (720x350) */
+       {1368,  976, 794,  753}, /* ; 04 (640x480x75Hz) */
+       {1448, 1036, 854,  813}, /* ; 05 (800x600x75Hz) */
+       {1560, 1168, 938,  897}, /* ; 06 (1024x768x75Hz) */
+       {   0, 1296,   0, 1025}  /* ; 07 (1280x1024x75Hz) */
+};
+
+/* Scaling LCD 75Hz */
+static struct XGI330_LCDDataDesStruct2 XGI_LVDSNoScalingDesDatax75[] = {
+       {0,  648, 448,  405,  96, 2}, /* ; 00 (320x200,320x400,
+                                              640x200,640x400) */
+       {0,  648, 448,  355,  96, 2}, /* ; 01 (320x350,640x350) */
+       {0,  729, 448,  405, 108, 2}, /* ; 02 (360x400,720x400) */
+       {0,  729, 448,  355, 108, 2}, /* ; 03 (720x350) */
+       {0,  656,   0,  481,  64, 3}, /* ; 04 (640x480x75Hz) */
+       {0,  816,   0,  601,  80, 3}, /* ; 05 (800x600x75Hz) */
+       {0, 1040,   0,  769,  96, 3}, /* ; 06 (1024x768x75Hz) */
+       {0, 1296,   0, 1025, 144, 3}, /* ; 07 (1280x1024x75Hz) */
+       {0, 1448,   0, 1051, 112, 3}, /* ; 08 (1400x1050x75Hz)
+                                        ;;[ycchen] 12/19/02 */
+       {0, 1664,   0, 1201, 192, 3}, /* ; 09 (1600x1200x75Hz) */
+       {0, 1328,   0,  771, 112, 6}  /* ; 0A (1280x768x75Hz) */
 };
 
 #if 0
-static struct XGI330_LVDSDataStruct  XGI330_LVDS640x480Data_1[] =
-{
- {800, 449, 800, 449},
- {800, 449, 800, 449},
- {800, 449, 800, 449},
- {800, 449, 800, 449},
- {800, 525, 800, 525},
- {1056, 628,1056, 628},
- {1056, 628,1056, 628},
- {1056, 628,1056, 628},
- {1056, 628,1056, 628}
+static struct XGI330_LVDSDataStruct  XGI330_LVDS640x480Data_1[] = {
+       { 800, 449,  800, 449},
+       { 800, 449,  800, 449},
+       { 800, 449,  800, 449},
+       { 800, 449,  800, 449},
+       { 800, 525,  800, 525},
+       {1056, 628, 1056, 628},
+       {1056, 628, 1056, 628},
+       {1056, 628, 1056, 628},
+       {1056, 628, 1056, 628}
 };
 #endif
 
-static struct XGI330_CHTVDataStruct  XGI_CHTVUNTSCData[] =
-{
- {840, 600, 840, 600},
- {840, 600, 840, 600},
- {840, 600, 840, 600},
- {840, 600, 840, 600},
- {784, 600, 784, 600},
- {1064, 750,1064, 750}
-};
-
-static struct XGI330_CHTVDataStruct  XGI_CHTVONTSCData[] =
-{
- {840, 525, 840, 525},
- {840, 525, 840, 525},
- {840, 525, 840, 525},
- {840, 525, 840, 525},
- {784, 525, 784, 525},
- {1040, 700,1040, 700}
-};
-
-static struct XGI330_CHTVDataStruct  XGI_CHTVUPALData[] =
-{
- {1008, 625,1008, 625},
- {1008, 625,1008, 625},
- {1008, 625,1008, 625},
- {1008, 625,1008, 625},
- {840, 750, 840, 750},
- {936, 836, 936, 836}
-};
-
-static struct XGI330_CHTVDataStruct  XGI_CHTVOPALData[] =
-{
- {1008, 625,1008, 625},
- {1008, 625,1008, 625},
- {1008, 625,1008, 625},
- {1008, 625,1008, 625},
- {840, 625, 840, 625},
- {960, 750, 960, 750}
-};
-
-static struct XGI_LVDSCRT1HDataStruct  XGI_LVDSCRT11024x768_1_H[] =
-{
-               /* CR00,CR02,CR03,CR04,CR05,SR0B,SR0C,SR0E */
-                {{      0x4B,0x27,0x8F,0x32,0x1B,0x00,0x45,0x00 }}, /* 00 (320x) */
-                {{      0x4B,0x27,0x8F,0x2B,0x03,0x00,0x44,0x00 }}, /* 01 (360x) */
-                {{      0x55,0x31,0x99,0x46,0x1D,0x00,0x55,0x00 }}, /* 02 (400x) */
-                {{      0x63,0x3F,0x87,0x4A,0x93,0x00,0x01,0x00 }}, /* 03 (512x) */
-                {{      0x73,0x4F,0x97,0x55,0x86,0x00,0x05,0x00 }}, /* 04 (640x) */
-                {{      0x73,0x4F,0x97,0x55,0x86,0x00,0x05,0x00 }}, /* 05 (720x) */
-                {{      0x87,0x63,0x8B,0x69,0x1A,0x00,0x26,0x00 }}, /* 06 (800x) */
-                {{      0xA3,0x7F,0x87,0x86,0x97,0x00,0x02,0x00 }} /* 07 (1024x) */
-};
-
-static struct XGI_LVDSCRT1HDataStruct  XGI_LVDSCRT11280x1024_1_H[] =
-{
-               /* CR00,CR02,CR03,CR04,CR05,SR0B,SR0C,SR0E */
-                {{      0x56,0x27,0x9A,0x30,0x1E,0x00,0x05,0x00 }}, /* 00 (320x) */
-                {{      0x56,0x27,0x9A,0x30,0x1E,0x00,0x05,0x00 }}, /* 01 (360x) */
-                {{      0x60,0x31,0x84,0x3A,0x88,0x00,0x01,0x00 }}, /* 02 (400x) */
-                {{      0x6E,0x3F,0x92,0x48,0x96,0x00,0x01,0x00 }}, /* 03 (512x) */
-                {{      0x7E,0x4F,0x82,0x58,0x06,0x00,0x06,0x00 }}, /* 04 (640x) */
-                {{      0x7E,0x4F,0x82,0x58,0x06,0x00,0x06,0x00 }}, /* 05 (720x) */
-                {{      0x92,0x63,0x96,0x6C,0x1A,0x00,0x06,0x00 }}, /* 06 (800x) */
-                {{      0xAE,0x7F,0x92,0x88,0x96,0x00,0x02,0x00 }}, /* 07 (1024x) */
-                {{      0xCE,0x9F,0x92,0xA8,0x16,0x00,0x07,0x00 }} /* 08 (1280x) */
-};
-
-static struct XGI_LVDSCRT1HDataStruct  XGI_LVDSCRT11024x768_2_H[] =
-{
-               /* CR00,CR02,CR03,CR04,CR05,SR0B,SR0C,SR0E */
-                {{      0x63,0x27,0x87,0x3B,0x8C,0x00,0x01,0x00 }}, /* 00 (320x) */
-                {{      0x63,0x27,0x87,0x3B,0x8C,0x00,0x01,0x00 }}, /* 01 (360x) */
-                {{      0x63,0x31,0x87,0x3D,0x8E,0x00,0x01,0x00 }}, /* 02 (400x) */
-                {{      0x63,0x3F,0x87,0x45,0x96,0x00,0x01,0x00 }}, /* 03 (512x) */
-                {{      0xA3,0x4F,0x87,0x6E,0x9F,0x00,0x06,0x00 }}, /* 04 (640x) */
-                {{      0xA3,0x4F,0x87,0x6E,0x9F,0x00,0x06,0x00 }}, /* 05 (720x) */
-                {{      0xA3,0x63,0x87,0x78,0x89,0x00,0x02,0x00 }}, /* 06 (800x) */
-                {{      0xA3,0x7F,0x87,0x86,0x97,0x00,0x02,0x00 }} /* 07 (1024x) */
-};
-
-static struct XGI_LVDSCRT1HDataStruct  XGI_LVDSCRT11280x1024_2_H[] =
-{
-                /* CR00,CR02,CR03,CR04,CR05,SR0B,SR0C,SR0E */
-                {{      0x7E,0x3B,0x9A,0x44,0x12,0x00,0x01,0x00 }}, /* 00 (320x) */
-                {{      0x7E,0x3B,0x9A,0x44,0x12,0x00,0x01,0x00 }}, /* 01 (360x) */
-                {{      0x7E,0x40,0x84,0x49,0x91,0x00,0x01,0x00 }}, /* 02 (400x) */
-                {{      0x7E,0x47,0x93,0x50,0x9E,0x00,0x01,0x00 }}, /* 03 (512x) */
-                {{      0xCE,0x77,0x8A,0x80,0x8E,0x00,0x02,0x00 }}, /* 04 (640x) */
-                {{      0xCE,0x77,0x8A,0x80,0x8E,0x00,0x02,0x00 }}, /* 05 (720x) */
-                {{      0xCE,0x81,0x94,0x8A,0x98,0x00,0x02,0x00 }}, /* 06 (800x) */
-                {{      0xCE,0x8F,0x82,0x98,0x06,0x00,0x07,0x00 }}, /* 07 (1024x) */
-                {{      0xCE,0x9F,0x92,0xA8,0x16,0x00,0x07,0x00 }} /* 08 (1280x) */
-};
-
-static struct XGI_LVDSCRT1HDataStruct XGI_LVDSCRT11400x1050_1_H[] =
-{               /* CR00,CR02,CR03,CR04,CR05,SR0B,SR0C,SR0E */
-                {{      0x47,0x27,0x8B,0x2C,0x1A,0x00,0x05,0x00 }}, /* 00 (320x) */
-                {{      0x47,0x27,0x8B,0x30,0x1E,0x00,0x05,0x00 }}, /* 01 (360x) */
-                {{      0x51,0x31,0x95,0x36,0x04,0x00,0x01,0x00 }}, /* 02 (400x) */
-                {{      0x5F,0x3F,0x83,0x44,0x92,0x00,0x01,0x00 }}, /* 03 (512x) */
-                {{      0x6F,0x4F,0x93,0x54,0x82,0x00,0x05,0x00 }}, /* 04 (640x) */
-                {{      0x6F,0x4F,0x93,0x54,0x82,0x00,0x05,0x00 }}, /* 05 (720x) */
-                {{      0x83,0x63,0x87,0x68,0x16,0x00,0x06,0x00 }}, /* 06 (800x) */
-                {{      0x9F,0x7F,0x83,0x84,0x92,0x00,0x02,0x00 }}, /* 07 (1024x) */
-                {{      0xBF,0x9F,0x83,0xA4,0x12,0x00,0x07,0x00 }}, /* 08 (1280x) */
-                {{      0xCE,0xAE,0x92,0xB3,0x01,0x00,0x03,0x00 }} /* 09 (1400x) */
-};
-
-static struct XGI_LVDSCRT1HDataStruct XGI_LVDSCRT11400x1050_2_H[] =
-{               /* CR00,CR02,CR03,CR04,CR05,SR0B,SR0C,SR0E */
-                {{      0x76,0x3F,0x83,0x45,0x8C,0x00,0x41,0x00 }}, /* 00 (320x) */
-                {{      0x76,0x3F,0x83,0x45,0x8C,0x00,0x41,0x00 }}, /* 01 (360x) */
-                {{      0x76,0x31,0x9A,0x48,0x9F,0x00,0x41,0x00 }}, /* 02 (400x) */
-                {{      0x76,0x3F,0x9A,0x4F,0x96,0x00,0x41,0x00 }}, /* 03 (512x) */
-                {{      0xCE,0x7E,0x82,0x87,0x9E,0x00,0x02,0x00 }}, /* 04 (640x) */
-                {{      0xCE,0x7E,0x82,0x87,0x9E,0x00,0x02,0x00 }}, /* 05 (720x) */
-                {{      0xCE,0x63,0x92,0x96,0x04,0x00,0x07,0x00 }}, /* 06 (800x) */
-                {{      0xCE,0x7F,0x92,0xA4,0x12,0x00,0x07,0x00 }}, /* 07 (1024x) */
-                {{      0xCE,0x9F,0x92,0xB4,0x02,0x00,0x03,0x00 }}, /* 08 (1280x) */
-                {{      0xCE,0xAE,0x92,0xBC,0x0A,0x00,0x03,0x00 }} /* 09 (1400x) */
-};
-
-static struct XGI_LVDSCRT1HDataStruct XGI_LVDSCRT11600x1200_1_H[] =
+static struct XGI330_CHTVDataStruct  XGI_CHTVUNTSCData[] = {
+       { 840, 600,  840, 600},
+       { 840, 600,  840, 600},
+       { 840, 600,  840, 600},
+       { 840, 600,  840, 600},
+       { 784, 600,  784, 600},
+       {1064, 750, 1064, 750}
+};
+
+static struct XGI330_CHTVDataStruct  XGI_CHTVONTSCData[] = {
+       { 840, 525,  840, 525},
+       { 840, 525,  840, 525},
+       { 840, 525,  840, 525},
+       { 840, 525,  840, 525},
+       { 784, 525,  784, 525},
+       {1040, 700, 1040, 700}
+};
+
+static struct XGI330_CHTVDataStruct  XGI_CHTVUPALData[] = {
+       {1008, 625, 1008, 625},
+       {1008, 625, 1008, 625},
+       {1008, 625, 1008, 625},
+       {1008, 625, 1008, 625},
+       { 840, 750,  840, 750},
+       { 936, 836,  936, 836}
+};
+
+static struct XGI330_CHTVDataStruct  XGI_CHTVOPALData[] = {
+       {1008, 625, 1008, 625},
+       {1008, 625, 1008, 625},
+       {1008, 625, 1008, 625},
+       {1008, 625, 1008, 625},
+       {840,  625,  840, 625},
+       {960,  750,  960, 750}
+};
+
+/* CR00,CR02,CR03,CR04,CR05,SR0B,SR0C,SR0E */
+static struct XGI_LVDSCRT1HDataStruct  XGI_LVDSCRT11024x768_1_H[] = {
+       { {0x4B, 0x27, 0x8F, 0x32, 0x1B, 0x00, 0x45, 0x00} }, /* 00 (320x) */
+       { {0x4B, 0x27, 0x8F, 0x2B, 0x03, 0x00, 0x44, 0x00} }, /* 01 (360x) */
+       { {0x55, 0x31, 0x99, 0x46, 0x1D, 0x00, 0x55, 0x00} }, /* 02 (400x) */
+       { {0x63, 0x3F, 0x87, 0x4A, 0x93, 0x00, 0x01, 0x00} }, /* 03 (512x) */
+       { {0x73, 0x4F, 0x97, 0x55, 0x86, 0x00, 0x05, 0x00} }, /* 04 (640x) */
+       { {0x73, 0x4F, 0x97, 0x55, 0x86, 0x00, 0x05, 0x00} }, /* 05 (720x) */
+       { {0x87, 0x63, 0x8B, 0x69, 0x1A, 0x00, 0x26, 0x00} }, /* 06 (800x) */
+       { {0xA3, 0x7F, 0x87, 0x86, 0x97, 0x00, 0x02, 0x00} }  /* 07 (1024x) */
+};
+
+/* CR00,CR02,CR03,CR04,CR05,SR0B,SR0C,SR0E */
+static struct XGI_LVDSCRT1HDataStruct  XGI_LVDSCRT11280x1024_1_H[] = {
+       { {0x56, 0x27, 0x9A, 0x30, 0x1E, 0x00, 0x05, 0x00 } }, /* 00 (320x) */
+       { {0x56, 0x27, 0x9A, 0x30, 0x1E, 0x00, 0x05, 0x00 } }, /* 01 (360x) */
+       { {0x60, 0x31, 0x84, 0x3A, 0x88, 0x00, 0x01, 0x00 } }, /* 02 (400x) */
+       { {0x6E, 0x3F, 0x92, 0x48, 0x96, 0x00, 0x01, 0x00 } }, /* 03 (512x) */
+       { {0x7E, 0x4F, 0x82, 0x58, 0x06, 0x00, 0x06, 0x00 } }, /* 04 (640x) */
+       { {0x7E, 0x4F, 0x82, 0x58, 0x06, 0x00, 0x06, 0x00 } }, /* 05 (720x) */
+       { {0x92, 0x63, 0x96, 0x6C, 0x1A, 0x00, 0x06, 0x00 } }, /* 06 (800x) */
+       { {0xAE, 0x7F, 0x92, 0x88, 0x96, 0x00, 0x02, 0x00 } }, /* 07 (1024x) */
+       { {0xCE, 0x9F, 0x92, 0xA8, 0x16, 0x00, 0x07, 0x00 } }  /* 08 (1280x) */
+};
+
+/* CR00,CR02,CR03,CR04,CR05,SR0B,SR0C,SR0E */
+static struct XGI_LVDSCRT1HDataStruct  XGI_LVDSCRT11024x768_2_H[] = {
+       { {0x63, 0x27, 0x87, 0x3B, 0x8C, 0x00, 0x01, 0x00} }, /* 00 (320x) */
+       { {0x63, 0x27, 0x87, 0x3B, 0x8C, 0x00, 0x01, 0x00} }, /* 01 (360x) */
+       { {0x63, 0x31, 0x87, 0x3D, 0x8E, 0x00, 0x01, 0x00} }, /* 02 (400x) */
+       { {0x63, 0x3F, 0x87, 0x45, 0x96, 0x00, 0x01, 0x00} }, /* 03 (512x) */
+       { {0xA3, 0x4F, 0x87, 0x6E, 0x9F, 0x00, 0x06, 0x00} }, /* 04 (640x) */
+       { {0xA3, 0x4F, 0x87, 0x6E, 0x9F, 0x00, 0x06, 0x00} }, /* 05 (720x) */
+       { {0xA3, 0x63, 0x87, 0x78, 0x89, 0x00, 0x02, 0x00} }, /* 06 (800x) */
+       { {0xA3, 0x7F, 0x87, 0x86, 0x97, 0x00, 0x02, 0x00} }  /* 07 (1024x) */
+};
+
+/* CR00,CR02,CR03,CR04,CR05,SR0B,SR0C,SR0E */
+static struct XGI_LVDSCRT1HDataStruct  XGI_LVDSCRT11280x1024_2_H[] = {
+       { {0x7E, 0x3B, 0x9A, 0x44, 0x12, 0x00, 0x01, 0x00} }, /* 00 (320x) */
+       { {0x7E, 0x3B, 0x9A, 0x44, 0x12, 0x00, 0x01, 0x00} }, /* 01 (360x) */
+       { {0x7E, 0x40, 0x84, 0x49, 0x91, 0x00, 0x01, 0x00} }, /* 02 (400x) */
+       { {0x7E, 0x47, 0x93, 0x50, 0x9E, 0x00, 0x01, 0x00} }, /* 03 (512x) */
+       { {0xCE, 0x77, 0x8A, 0x80, 0x8E, 0x00, 0x02, 0x00} }, /* 04 (640x) */
+       { {0xCE, 0x77, 0x8A, 0x80, 0x8E, 0x00, 0x02, 0x00} }, /* 05 (720x) */
+       { {0xCE, 0x81, 0x94, 0x8A, 0x98, 0x00, 0x02, 0x00} }, /* 06 (800x) */
+       { {0xCE, 0x8F, 0x82, 0x98, 0x06, 0x00, 0x07, 0x00} }, /* 07 (1024x) */
+       { {0xCE, 0x9F, 0x92, 0xA8, 0x16, 0x00, 0x07, 0x00} }  /* 08 (1280x) */
+};
+
+/* CR00,CR02,CR03,CR04,CR05,SR0B,SR0C,SR0E */
+static struct XGI_LVDSCRT1HDataStruct XGI_LVDSCRT11400x1050_1_H[] = {
+       { {0x47, 0x27, 0x8B, 0x2C, 0x1A, 0x00, 0x05, 0x00} }, /* 00 (320x) */
+       { {0x47, 0x27, 0x8B, 0x30, 0x1E, 0x00, 0x05, 0x00} }, /* 01 (360x) */
+       { {0x51, 0x31, 0x95, 0x36, 0x04, 0x00, 0x01, 0x00} }, /* 02 (400x) */
+       { {0x5F, 0x3F, 0x83, 0x44, 0x92, 0x00, 0x01, 0x00} }, /* 03 (512x) */
+       { {0x6F, 0x4F, 0x93, 0x54, 0x82, 0x00, 0x05, 0x00} }, /* 04 (640x) */
+       { {0x6F, 0x4F, 0x93, 0x54, 0x82, 0x00, 0x05, 0x00} }, /* 05 (720x) */
+       { {0x83, 0x63, 0x87, 0x68, 0x16, 0x00, 0x06, 0x00} }, /* 06 (800x) */
+       { {0x9F, 0x7F, 0x83, 0x84, 0x92, 0x00, 0x02, 0x00} }, /* 07 (1024x) */
+       { {0xBF, 0x9F, 0x83, 0xA4, 0x12, 0x00, 0x07, 0x00} }, /* 08 (1280x) */
+       { {0xCE, 0xAE, 0x92, 0xB3, 0x01, 0x00, 0x03, 0x00} }  /* 09 (1400x) */
+};
+
+/* CR00,CR02,CR03,CR04,CR05,SR0B,SR0C,SR0E */
+static struct XGI_LVDSCRT1HDataStruct XGI_LVDSCRT11400x1050_2_H[] = {
+       { {0x76, 0x3F, 0x83, 0x45, 0x8C, 0x00, 0x41, 0x00} }, /* 00 (320x) */
+       { {0x76, 0x3F, 0x83, 0x45, 0x8C, 0x00, 0x41, 0x00} }, /* 01 (360x) */
+       { {0x76, 0x31, 0x9A, 0x48, 0x9F, 0x00, 0x41, 0x00} }, /* 02 (400x) */
+       { {0x76, 0x3F, 0x9A, 0x4F, 0x96, 0x00, 0x41, 0x00} }, /* 03 (512x) */
+       { {0xCE, 0x7E, 0x82, 0x87, 0x9E, 0x00, 0x02, 0x00} }, /* 04 (640x) */
+       { {0xCE, 0x7E, 0x82, 0x87, 0x9E, 0x00, 0x02, 0x00} }, /* 05 (720x) */
+       { {0xCE, 0x63, 0x92, 0x96, 0x04, 0x00, 0x07, 0x00} }, /* 06 (800x) */
+       { {0xCE, 0x7F, 0x92, 0xA4, 0x12, 0x00, 0x07, 0x00} }, /* 07 (1024x) */
+       { {0xCE, 0x9F, 0x92, 0xB4, 0x02, 0x00, 0x03, 0x00} }, /* 08 (1280x) */
+       { {0xCE, 0xAE, 0x92, 0xBC, 0x0A, 0x00, 0x03, 0x00} }  /* 09 (1400x) */
+};
+
 /* ;302lv channelA [ycchen] 12/05/02 LCDHT=2048 */
-{   /* ; CR00,CR02,CR03,CR04,CR05,SR0B,SR0C,SR0E */
-                {{      0x5B,0x27,0x9F,0x32,0x0A,0x00,0x01,0x00 }},/* 00 (320x) */
-                {{      0x5B,0x27,0x9F,0x32,0x0A,0x00,0x01,0x00 }},/* 01 (360x) */
-                {{      0x65,0x31,0x89,0x3C,0x94,0x00,0x01,0x00 }},/* 02 (400x) */
-                {{      0x73,0x3F,0x97,0x4A,0x82,0x00,0x05,0x00 }},/* 03 (512x) */
-                {{      0x83,0x4F,0x87,0x51,0x09,0x00,0x06,0x00 }},/* 04 (640x) */
-               {{      0x83,0x4F,0x87,0x51,0x09,0x00,0x06,0x00 }},/* 05 (720x) */
-               {{      0x97,0x63,0x9B,0x65,0x1D,0x00,0x06,0xF0 }},/* 06 (800x) */
-               {{      0xB3,0x7F,0x97,0x81,0x99,0x00,0x02,0x00 }},/* 07 (1024x) */
-               {{      0xD3,0x9F,0x97,0xA1,0x19,0x00,0x07,0x00 }},/* 08 (1280x) */
-               {{      0xE2,0xAE,0x86,0xB9,0x91,0x00,0x03,0x00 }},/* 09 (1400x) */
-               {{      0xFB,0xC7,0x9F,0xC9,0x81,0x00,0x07,0x00 }} /* 0A (1600x) */
-};
-
-static struct XGI_LVDSCRT1VDataStruct XGI_LVDSCRT11024x768_1_V[] =
-{               /* CR06,CR07,CR10,CR11,CR15,CR16,SR0A+CR09(5->7) */
-                {{      0x97,0x1F,0x60,0x87,0x5D,0x83,0x10      }}, /* 00 (x350) */
-                {{      0xB4,0x1F,0x92,0x89,0x8F,0xB5,0x30      }}, /* 01 (x400) */
-                {{      0x04,0x3E,0xE2,0x89,0xDF,0x05,0x00      }}, /* 02 (x480) */
-                {{      0x7C,0xF0,0x5A,0x8F,0x57,0x7D,0xA0      }}, /* 03 (x600) */
-                {{      0x24,0xF5,0x02,0x88,0xFF,0x25,0x90      }} /* 04 (x768) */
-};
-
-static struct XGI_LVDSCRT1VDataStruct XGI_LVDSCRT11024x768_2_V[] =
-{               /* CR06,CR07,CR10,CR11,CR15,CR16,SR0A */
-                {{      0x24,0xBB,0x31,0x87,0x5D,0x25,0x30      }}, /* 00 (x350) */
-                {{      0x24,0xBB,0x4A,0x80,0x8F,0x25,0x30      }}, /* 01 (x400) */
-                {{      0x24,0xBB,0x72,0x88,0xDF,0x25,0x30      }}, /* 02 (x480) */
-                {{      0x24,0xF1,0xAE,0x84,0x57,0x25,0xB0      }}, /* 03 (x600) */
-                {{      0x24,0xF5,0x02,0x88,0xFF,0x25,0x90      }} /* 04 (x768) */
-};
-
-static struct XGI_LVDSCRT1VDataStruct XGI_LVDSCRT11280x1024_1_V[] =
-{               /* CR06,CR07,CR10,CR11,CR15,CR16,SR0A */
-                {{       0x86,0x1F,0x5E,0x82,0x5D,0x87,0x00     }}, /* 00 (x350) */
-                {{       0xB8,0x1F,0x90,0x84,0x8F,0xB9,0x30     }}, /* 01 (x400) */
-                {{       0x08,0x3E,0xE0,0x84,0xDF,0x09,0x00     }}, /* 02 (x480) */
-                {{       0x80,0xF0,0x58,0x8C,0x57,0x81,0xA0     }}, /* 03 (x600) */
-                {{       0x28,0xF5,0x00,0x84,0xFF,0x29,0x90     }}, /* 04 (x768) */
-                {{       0x28,0x5A,0x13,0x87,0xFF,0x29,0xA9     }} /* 05 (x1024) */
-};
-
-static struct XGI_LVDSCRT1VDataStruct XGI_LVDSCRT11280x1024_2_V[] =
-{               /* CR06,CR07,CR10,CR11,CR15,CR16,SR0A */
-                {{      0x28,0xD2,0xAF,0x83,0xAE,0xD8,0xA1      }}, /* 00 (x350) */
-                {{      0x28,0xD2,0xC8,0x8C,0xC7,0xF2,0x81      }}, /* 01 (x400) */
-                {{      0x28,0xD2,0xF0,0x84,0xEF,0x1A,0xB1      }}, /* 02 (x480) */
-                {{      0x28,0xDE,0x2C,0x8F,0x2B,0x56,0x91      }}, /* 03 (x600) */
-                {{      0x28,0xDE,0x80,0x83,0x7F,0xAA,0x91      }}, /* 04 (x768) */
-                {{      0x28,0x5A,0x13,0x87,0xFF,0x29,0xA9      }} /* 05 (x1024) */
-};
-
-static struct XGI_LVDSCRT1VDataStruct XGI_LVDSCRT11400x1050_1_V[] =
-{               /* CR06,CR07,CR10,CR11,CR15,CR16,SR0A */
-                {{      0x6C,0x1F,0x60,0x84,0x5D,0x6D,0x10      }}, /* 00 (x350) */
-                {{      0x9E,0x1F,0x93,0x86,0x8F,0x9F,0x30      }}, /* 01 (x400) */
-                {{      0xEE,0x1F,0xE2,0x86,0xDF,0xEF,0x10      }}, /* 02 (x480) */
-                {{      0x66,0xF0,0x5A,0x8e,0x57,0x67,0xA0      }}, /* 03 (x600) */
-                {{      0x0E,0xF5,0x02,0x86,0xFF,0x0F,0x90      }}, /* 04 (x768) */
-                {{      0x0E,0x5A,0x02,0x86,0xFF,0x0F,0x89      }}, /* 05 (x1024) */
-                {{      0x28,0x10,0x1A,0x80,0x19,0x29,0x0F      }} /* 06 (x1050) */
-};
-
-static struct XGI_LVDSCRT1VDataStruct XGI_LVDSCRT11400x1050_2_V[] =
-{              /* CR06,CR07,CR10,CR11,CR15,CR16,SR0A */
-                {{      0x28,0x92,0xB6,0x83,0xB5,0xCF,0x81      }}, /* 00 (x350) */
-                {{      0x28,0x92,0xD5,0x82,0xD4,0xEE,0x81      }}, /* 01 (x400) */
-                {{      0x28,0x92,0xFD,0x8A,0xFC,0x16,0xB1      }}, /* 02 (x480) */
-                {{      0x28,0xD4,0x39,0x86,0x57,0x29,0x81      }}, /* 03 (x600) */
-                {{      0x28,0xD4,0x8D,0x9A,0xFF,0x29,0xA1      }}, /* 04 (x768) */
-                {{      0x28,0x5A,0x0D,0x9A,0xFF,0x29,0xA9      }}, /* 05 (x1024) */
-                {{      0x28,0x10,0x1A,0x87,0x19,0x29,0x8F      }} /* 06 (x1050) */
-};
-
-static struct XGI_LVDSCRT1VDataStruct XGI_LVDSCRT11600x1200_1_V[] =
-{
-               /* CR06,CR07,CR10,CR11,CR15,CR16,SR0A+CR09(5->7) */
-                {{      0xd4,0x1F,0x81,0x84,0x5D,0xd5,0x10      }}, /* 00 (x350) */
-                {{      0x06,0x3e,0xb3,0x86,0x8F,0x07,0x20      }}, /* 01 (x400) */
-                {{      0x56,0xba,0x03,0x86,0xDF,0x57,0x00      }}, /* 02 (x480) */
-                {{      0xce,0xF0,0x7b,0x8e,0x57,0xcf,0xa0      }}, /* 03 (x600) */
-                {{      0x76,0xF5,0x23,0x86,0xFF,0x77,0x90      }}, /* 04 (x768) */
-                {{      0x76,0x5A,0x23,0x86,0xFF,0x77,0x89      }}, /* 05 (x1024) */
-                {{      0x90,0x10,0x1A,0x8E,0x19,0x91,0x2F      }}, /* 06 (x1050) */
-                {{      0x26,0x11,0xd3,0x86,0xaF,0x27,0x3f      }} /* 07 (x1200) */
-};
-
-static struct XGI_LVDSCRT1HDataStruct XGI_LVDSCRT11024x768_1_Hx75[] =
-{      /* CR00,CR02,CR03,CR04,CR05,SR0B,SR0C,SR0E */
-    {{      0x4B,0x27,0x8F,0x32,0x1B,0x00,0x45,0x00 }},/* ; 00 (320x) */
-    {{      0x4B,0x27,0x8F,0x2B,0x03,0x00,0x44,0x00 }},/* ; 01 (360x) */
-    {{      0x55,0x31,0x99,0x46,0x1D,0x00,0x55,0x00 }},/* ; 02 (400x) */
-    {{      0x63,0x3F,0x87,0x4A,0x93,0x00,0x01,0x00 }},/* ; 03 (512x) */
-    {{      0x6F,0x4F,0x93,0x54,0x80,0x00,0x05,0x00 }},/* ; 04 (640x) */
-    {{      0x6F,0x4F,0x93,0x54,0x80,0x00,0x05,0x00 }},/* ; 05 (720x) */
-    {{      0x83,0x63,0x87,0x68,0x14,0x00,0x26,0x00 }},/* ; 06 (800x) */
-    {{      0x9F,0x7F,0x83,0x85,0x91,0x00,0x02,0x00 }} /* ; 07 (1024x) */
-};
-
-static struct XGI_LVDSCRT1VDataStruct XGI_LVDSCRT11024x768_1_Vx75[] =
-{      /* CR06,CR07,CR10,CR11,CR15,CR16,SR0A+CR09(5->7) */
-    {{      0x97,0x1F,0x60,0x87,0x5D,0x83,0x10      }},/* ; 00 (x350) */
-    {{      0xB4,0x1F,0x92,0x89,0x8F,0xB5,0x30      }},/* ; 01 (x400) */
-    {{      0xFE,0x1F,0xE0,0x84,0xDF,0xFF,0x10      }},/* ; 02 (x480) */
-    {{      0x76,0xF0,0x58,0x8C,0x57,0x77,0xA0      }},/* ; 03 (x600) */
-    {{      0x1E,0xF5,0x00,0x83,0xFF,0x1F,0x90      }} /* ; 04 (x768) */
-};
-
-static struct XGI_LVDSCRT1HDataStruct XGI_LVDSCRT11024x768_2_Hx75[] =
-{       /* CR00,CR02,CR03,CR04,CR05,SR0B,SR0C,SR0E */
-    {{      0x63,0x27,0x87,0x3B,0x8C,0x00,0x01,0x00 }},/* ; 00 (320x) */
-    {{      0x63,0x27,0x87,0x3B,0x8C,0x00,0x01,0x00 }},/* ; 01 (360x) */
-    {{      0x63,0x31,0x87,0x3D,0x8E,0x00,0x01,0x00 }},/* ; 02 (400x) */
-    {{      0x63,0x3F,0x87,0x45,0x96,0x00,0x01,0x00 }},/* ; 03 (512x) */
-    {{      0xA3,0x4F,0x87,0x6E,0x9F,0x00,0x06,0x00 }},/* ; 04 (640x) */
-    {{      0xA3,0x4F,0x87,0x6E,0x9F,0x00,0x06,0x00 }},/* ; 05 (720x) */
-    {{      0xA3,0x63,0x87,0x78,0x89,0x00,0x02,0x00 }},/* ; 06 (800x) */
-    {{      0xA3,0x7F,0x87,0x86,0x97,0x00,0x02,0x00 }} /* ; 07 (1024x) */
-};
-
-static struct XGI_LVDSCRT1VDataStruct XGI_LVDSCRT11024x768_2_Vx75[] =
-{       /* CR06,CR07,CR10,CR11,CR15,CR16,SR0A */
-    {{      0x24,0xBB,0x31,0x87,0x5D,0x25,0x30      }},/* ; 00 (x350) */
-    {{      0x24,0xBB,0x4A,0x80,0x8F,0x25,0x30      }},/* ; 01 (x400) */
-    {{      0x24,0xBB,0x72,0x88,0xDF,0x25,0x30      }},/* ; 02 (x480) */
-    {{      0x24,0xF1,0xAE,0x84,0x57,0x25,0xB0      }},/* ; 03 (x600) */
-    {{      0x24,0xF5,0x02,0x88,0xFF,0x25,0x90      }} /* ; 04 (x768) */
-};
-
-static struct XGI_LVDSCRT1HDataStruct XGI_LVDSCRT11280x1024_1_Hx75[] =
-{      /* CR00,CR02,CR03,CR04,CR05,SR0B,SR0C,SR0E */
-    {{      0x56,0x27,0x9A,0x30,0x1E,0x00,0x05,0x00 }},/* ; 00 (320x) */
-    {{      0x56,0x27,0x9A,0x30,0x1E,0x00,0x05,0x00 }},/* ; 01 (360x) */
-    {{      0x60,0x31,0x84,0x3A,0x88,0x00,0x01,0x00 }},/* ; 02 (400x) */
-    {{      0x6E,0x3F,0x92,0x48,0x96,0x00,0x01,0x00 }},/* ; 03 (512x) */
-    {{      0x7E,0x4F,0x82,0x54,0x06,0x00,0x06,0x00 }},/* ; 04 (640x) */
-    {{      0x7E,0x4F,0x82,0x54,0x06,0x00,0x06,0x00 }},/* ; 05 (720x) */
-    {{      0x92,0x63,0x96,0x68,0x1A,0x00,0x06,0x00 }},/* ; 06 (800x) */
-    {{      0xAE,0x7F,0x92,0x84,0x96,0x00,0x02,0x00 }},/* ; 07 (1024x) */
-    {{      0xCE,0x9F,0x92,0xA5,0x17,0x00,0x07,0x00 }} /* ; 08 (1280x) */
-};
-
-static struct XGI_LVDSCRT1VDataStruct XGI_LVDSCRT11280x1024_1_Vx75[] =
-{      /* CR06,CR07,CR10,CR11,CR15,CR16,SR0A */
-    {{      0x86,0xD1,0xBC,0x80,0xBB,0xE5,0x00      }},/* ; 00 (x350) */
-    {{      0xB8,0x1F,0x90,0x84,0x8F,0xB9,0x30      }},/* ; 01 (x400) */
-    {{      0x08,0x3E,0xE0,0x84,0xDF,0x09,0x00      }},/* ; 02 (x480) */
-    {{      0x80,0xF0,0x58,0x8C,0x57,0x81,0xA0      }},/* ; 03 (x600) */
-    {{      0x28,0xF5,0x00,0x84,0xFF,0x29,0x90      }},/* ; 04 (x768) */
-    {{      0x28,0x5A,0x13,0x87,0xFF,0x29,0xA9      }} /* ; 05 (x1024) */
-};
-
-static struct XGI_LVDSCRT1HDataStruct XGI_LVDSCRT11280x1024_2_Hx75[] =
-{
-       /* CR00,CR02,CR03,CR04,CR05,SR0B,SR0C,SR0E */
-    {{      0x7E,0x3B,0x9A,0x44,0x12,0x00,0x01,0x00 }},/* ; 00 (320x) */
-    {{      0x7E,0x3B,0x9A,0x44,0x12,0x00,0x01,0x00 }},/* ; 01 (360x) */
-    {{      0x7E,0x40,0x84,0x49,0x91,0x00,0x01,0x00 }},/* ; 02 (400x) */
-    {{      0x7E,0x47,0x93,0x50,0x9E,0x00,0x01,0x00 }},/* ; 03 (512x) */
-    {{      0xCE,0x77,0x8A,0x80,0x8E,0x00,0x02,0x00 }},/* ; 04 (640x) */
-    {{      0xCE,0x77,0x8A,0x80,0x8E,0x00,0x02,0x00 }},/* ; 05 (720x) */
-    {{      0xCE,0x81,0x94,0x8A,0x98,0x00,0x02,0x00 }},/* ; 06 (800x) */
-    {{      0xCE,0x8F,0x82,0x98,0x06,0x00,0x07,0x00 }},/* ; 07 (1024x) */
-    {{      0xCE,0x9F,0x92,0xA8,0x16,0x00,0x07,0x00 }} /* ; 08 (1280x) */
-};
-
-static struct XGI_LVDSCRT1VDataStruct XGI_LVDSCRT11280x1024_2_Vx75[] =
-{
-        /* CR06,CR07,CR10,CR11,CR15,CR16,SR0A */
-     {{     0x28,0xD2,0xAF,0x83,0xAE,0xD8,0xA1     }},/* ; 00 (x350) */
-     {{     0x28,0xD2,0xC8,0x8C,0xC7,0xF2,0x81     }},/* ; 01 (x400) */
-     {{     0x28,0xD2,0xF0,0x84,0xEF,0x1A,0xB1     }},/* ; 02 (x480) */
-     {{     0x28,0xDE,0x2C,0x8F,0x2B,0x56,0x91     }},/* ; 03 (x600) */
-     {{     0x28,0xDE,0x80,0x83,0x7F,0xAA,0x91     }},/* ; 04 (x768) */
-     {{     0x28,0x5A,0x13,0x87,0xFF,0x29,0xA9     }} /* ; 05 (x1024) */
+/* ; CR00,CR02,CR03,CR04,CR05,SR0B,SR0C,SR0E */
+static struct XGI_LVDSCRT1HDataStruct XGI_LVDSCRT11600x1200_1_H[] = {
+       { {0x5B, 0x27, 0x9F, 0x32, 0x0A, 0x00, 0x01, 0x00} }, /* 00 (320x) */
+       { {0x5B, 0x27, 0x9F, 0x32, 0x0A, 0x00, 0x01, 0x00} }, /* 01 (360x) */
+       { {0x65, 0x31, 0x89, 0x3C, 0x94, 0x00, 0x01, 0x00} }, /* 02 (400x) */
+       { {0x73, 0x3F, 0x97, 0x4A, 0x82, 0x00, 0x05, 0x00} }, /* 03 (512x) */
+       { {0x83, 0x4F, 0x87, 0x51, 0x09, 0x00, 0x06, 0x00} }, /* 04 (640x) */
+       { {0x83, 0x4F, 0x87, 0x51, 0x09, 0x00, 0x06, 0x00} }, /* 05 (720x) */
+       { {0x97, 0x63, 0x9B, 0x65, 0x1D, 0x00, 0x06, 0xF0} }, /* 06 (800x) */
+       { {0xB3, 0x7F, 0x97, 0x81, 0x99, 0x00, 0x02, 0x00} }, /* 07 (1024x) */
+       { {0xD3, 0x9F, 0x97, 0xA1, 0x19, 0x00, 0x07, 0x00} }, /* 08 (1280x) */
+       { {0xE2, 0xAE, 0x86, 0xB9, 0x91, 0x00, 0x03, 0x00} }, /* 09 (1400x) */
+       { {0xFB, 0xC7, 0x9F, 0xC9, 0x81, 0x00, 0x07, 0x00} }  /* 0A (1600x) */
+};
+
+/* CR06,CR07,CR10,CR11,CR15,CR16,SR0A+CR09(5->7) */
+static struct XGI_LVDSCRT1VDataStruct XGI_LVDSCRT11024x768_1_V[] = {
+       { {0x97, 0x1F, 0x60, 0x87, 0x5D, 0x83, 0x10} }, /* 00 (x350) */
+       { {0xB4, 0x1F, 0x92, 0x89, 0x8F, 0xB5, 0x30} }, /* 01 (x400) */
+       { {0x04, 0x3E, 0xE2, 0x89, 0xDF, 0x05, 0x00} }, /* 02 (x480) */
+       { {0x7C, 0xF0, 0x5A, 0x8F, 0x57, 0x7D, 0xA0} }, /* 03 (x600) */
+       { {0x24, 0xF5, 0x02, 0x88, 0xFF, 0x25, 0x90} }  /* 04 (x768) */
+};
+
+/* CR06,CR07,CR10,CR11,CR15,CR16,SR0A */
+static struct XGI_LVDSCRT1VDataStruct XGI_LVDSCRT11024x768_2_V[] = {
+       { {0x24, 0xBB, 0x31, 0x87, 0x5D, 0x25, 0x30} }, /* 00 (x350) */
+       { {0x24, 0xBB, 0x4A, 0x80, 0x8F, 0x25, 0x30} }, /* 01 (x400) */
+       { {0x24, 0xBB, 0x72, 0x88, 0xDF, 0x25, 0x30} }, /* 02 (x480) */
+       { {0x24, 0xF1, 0xAE, 0x84, 0x57, 0x25, 0xB0} }, /* 03 (x600) */
+       { {0x24, 0xF5, 0x02, 0x88, 0xFF, 0x25, 0x90} }  /* 04 (x768) */
+};
+
+/* CR06,CR07,CR10,CR11,CR15,CR16,SR0A */
+static struct XGI_LVDSCRT1VDataStruct XGI_LVDSCRT11280x1024_1_V[] = {
+       { {0x86, 0x1F, 0x5E, 0x82, 0x5D, 0x87, 0x00} }, /* 00 (x350) */
+       { {0xB8, 0x1F, 0x90, 0x84, 0x8F, 0xB9, 0x30} }, /* 01 (x400) */
+       { {0x08, 0x3E, 0xE0, 0x84, 0xDF, 0x09, 0x00} }, /* 02 (x480) */
+       { {0x80, 0xF0, 0x58, 0x8C, 0x57, 0x81, 0xA0} }, /* 03 (x600) */
+       { {0x28, 0xF5, 0x00, 0x84, 0xFF, 0x29, 0x90} }, /* 04 (x768) */
+       { {0x28, 0x5A, 0x13, 0x87, 0xFF, 0x29, 0xA9} }  /* 05 (x1024) */
+};
+
+/* CR06,CR07,CR10,CR11,CR15,CR16,SR0A */
+static struct XGI_LVDSCRT1VDataStruct XGI_LVDSCRT11280x1024_2_V[] = {
+       { {0x28, 0xD2, 0xAF, 0x83, 0xAE, 0xD8, 0xA1} }, /* 00 (x350) */
+       { {0x28, 0xD2, 0xC8, 0x8C, 0xC7, 0xF2, 0x81} }, /* 01 (x400) */
+       { {0x28, 0xD2, 0xF0, 0x84, 0xEF, 0x1A, 0xB1} }, /* 02 (x480) */
+       { {0x28, 0xDE, 0x2C, 0x8F, 0x2B, 0x56, 0x91} }, /* 03 (x600) */
+       { {0x28, 0xDE, 0x80, 0x83, 0x7F, 0xAA, 0x91} }, /* 04 (x768) */
+       { {0x28, 0x5A, 0x13, 0x87, 0xFF, 0x29, 0xA9} }  /* 05 (x1024) */
+};
+
+/* CR06,CR07,CR10,CR11,CR15,CR16,SR0A */
+static struct XGI_LVDSCRT1VDataStruct XGI_LVDSCRT11400x1050_1_V[] = {
+       { {0x6C, 0x1F, 0x60, 0x84, 0x5D, 0x6D, 0x10} }, /* 00 (x350) */
+       { {0x9E, 0x1F, 0x93, 0x86, 0x8F, 0x9F, 0x30} }, /* 01 (x400) */
+       { {0xEE, 0x1F, 0xE2, 0x86, 0xDF, 0xEF, 0x10} }, /* 02 (x480) */
+       { {0x66, 0xF0, 0x5A, 0x8e, 0x57, 0x67, 0xA0} }, /* 03 (x600) */
+       { {0x0E, 0xF5, 0x02, 0x86, 0xFF, 0x0F, 0x90} }, /* 04 (x768) */
+       { {0x0E, 0x5A, 0x02, 0x86, 0xFF, 0x0F, 0x89} }, /* 05 (x1024) */
+       { {0x28, 0x10, 0x1A, 0x80, 0x19, 0x29, 0x0F} }  /* 06 (x1050) */
+};
+
+/* CR06,CR07,CR10,CR11,CR15,CR16,SR0A */
+static struct XGI_LVDSCRT1VDataStruct XGI_LVDSCRT11400x1050_2_V[] = {
+       { {0x28, 0x92, 0xB6, 0x83, 0xB5, 0xCF, 0x81} }, /* 00 (x350) */
+       { {0x28, 0x92, 0xD5, 0x82, 0xD4, 0xEE, 0x81} }, /* 01 (x400) */
+       { {0x28, 0x92, 0xFD, 0x8A, 0xFC, 0x16, 0xB1} }, /* 02 (x480) */
+       { {0x28, 0xD4, 0x39, 0x86, 0x57, 0x29, 0x81} }, /* 03 (x600) */
+       { {0x28, 0xD4, 0x8D, 0x9A, 0xFF, 0x29, 0xA1} }, /* 04 (x768) */
+       { {0x28, 0x5A, 0x0D, 0x9A, 0xFF, 0x29, 0xA9} }, /* 05 (x1024) */
+       { {0x28, 0x10, 0x1A, 0x87, 0x19, 0x29, 0x8F} }  /* 06 (x1050) */
+};
+
+/* CR06,CR07,CR10,CR11,CR15,CR16,SR0A+CR09(5->7) */
+static struct XGI_LVDSCRT1VDataStruct XGI_LVDSCRT11600x1200_1_V[] = {
+       { {0xd4, 0x1F, 0x81, 0x84, 0x5D, 0xd5, 0x10} }, /* 00 (x350) */
+       { {0x06, 0x3e, 0xb3, 0x86, 0x8F, 0x07, 0x20} }, /* 01 (x400) */
+       { {0x56, 0xba, 0x03, 0x86, 0xDF, 0x57, 0x00} }, /* 02 (x480) */
+       { {0xce, 0xF0, 0x7b, 0x8e, 0x57, 0xcf, 0xa0} }, /* 03 (x600) */
+       { {0x76, 0xF5, 0x23, 0x86, 0xFF, 0x77, 0x90} }, /* 04 (x768) */
+       { {0x76, 0x5A, 0x23, 0x86, 0xFF, 0x77, 0x89} }, /* 05 (x1024) */
+       { {0x90, 0x10, 0x1A, 0x8E, 0x19, 0x91, 0x2F} }, /* 06 (x1050) */
+       { {0x26, 0x11, 0xd3, 0x86, 0xaF, 0x27, 0x3f} }  /* 07 (x1200) */
+};
+
+/* CR00,CR02,CR03,CR04,CR05,SR0B,SR0C,SR0E */
+static struct XGI_LVDSCRT1HDataStruct XGI_LVDSCRT11024x768_1_Hx75[] = {
+       { {0x4B, 0x27, 0x8F, 0x32, 0x1B, 0x00, 0x45, 0x00} },/* ; 00 (320x) */
+       { {0x4B, 0x27, 0x8F, 0x2B, 0x03, 0x00, 0x44, 0x00} },/* ; 01 (360x) */
+       { {0x55, 0x31, 0x99, 0x46, 0x1D, 0x00, 0x55, 0x00} },/* ; 02 (400x) */
+       { {0x63, 0x3F, 0x87, 0x4A, 0x93, 0x00, 0x01, 0x00} },/* ; 03 (512x) */
+       { {0x6F, 0x4F, 0x93, 0x54, 0x80, 0x00, 0x05, 0x00} },/* ; 04 (640x) */
+       { {0x6F, 0x4F, 0x93, 0x54, 0x80, 0x00, 0x05, 0x00} },/* ; 05 (720x) */
+       { {0x83, 0x63, 0x87, 0x68, 0x14, 0x00, 0x26, 0x00} },/* ; 06 (800x) */
+       { {0x9F, 0x7F, 0x83, 0x85, 0x91, 0x00, 0x02, 0x00} } /* ; 07 (1024x) */
+};
+
+/* CR06,CR07,CR10,CR11,CR15,CR16,SR0A+CR09(5->7) */
+static struct XGI_LVDSCRT1VDataStruct XGI_LVDSCRT11024x768_1_Vx75[] = {
+       { {0x97, 0x1F, 0x60, 0x87, 0x5D, 0x83, 0x10} },/* ; 00 (x350) */
+       { {0xB4, 0x1F, 0x92, 0x89, 0x8F, 0xB5, 0x30} },/* ; 01 (x400) */
+       { {0xFE, 0x1F, 0xE0, 0x84, 0xDF, 0xFF, 0x10} },/* ; 02 (x480) */
+       { {0x76, 0xF0, 0x58, 0x8C, 0x57, 0x77, 0xA0} },/* ; 03 (x600) */
+       { {0x1E, 0xF5, 0x00, 0x83, 0xFF, 0x1F, 0x90} } /* ; 04 (x768) */
+};
+
+/* CR00,CR02,CR03,CR04,CR05,SR0B,SR0C,SR0E */
+static struct XGI_LVDSCRT1HDataStruct XGI_LVDSCRT11024x768_2_Hx75[] = {
+       { {0x63, 0x27, 0x87, 0x3B, 0x8C, 0x00, 0x01, 0x00} },/* ; 00 (320x) */
+       { {0x63, 0x27, 0x87, 0x3B, 0x8C, 0x00, 0x01, 0x00} },/* ; 01 (360x) */
+       { {0x63, 0x31, 0x87, 0x3D, 0x8E, 0x00, 0x01, 0x00} },/* ; 02 (400x) */
+       { {0x63, 0x3F, 0x87, 0x45, 0x96, 0x00, 0x01, 0x00} },/* ; 03 (512x) */
+       { {0xA3, 0x4F, 0x87, 0x6E, 0x9F, 0x00, 0x06, 0x00} },/* ; 04 (640x) */
+       { {0xA3, 0x4F, 0x87, 0x6E, 0x9F, 0x00, 0x06, 0x00} },/* ; 05 (720x) */
+       { {0xA3, 0x63, 0x87, 0x78, 0x89, 0x00, 0x02, 0x00} },/* ; 06 (800x) */
+       { {0xA3, 0x7F, 0x87, 0x86, 0x97, 0x00, 0x02, 0x00} } /* ; 07 (1024x) */
+};
+
+/* CR06,CR07,CR10,CR11,CR15,CR16,SR0A */
+static struct XGI_LVDSCRT1VDataStruct XGI_LVDSCRT11024x768_2_Vx75[] = {
+       { {0x24, 0xBB, 0x31, 0x87, 0x5D, 0x25, 0x30} },/* ; 00 (x350) */
+       { {0x24, 0xBB, 0x4A, 0x80, 0x8F, 0x25, 0x30} },/* ; 01 (x400) */
+       { {0x24, 0xBB, 0x72, 0x88, 0xDF, 0x25, 0x30} },/* ; 02 (x480) */
+       { {0x24, 0xF1, 0xAE, 0x84, 0x57, 0x25, 0xB0} },/* ; 03 (x600) */
+       { {0x24, 0xF5, 0x02, 0x88, 0xFF, 0x25, 0x90} } /* ; 04 (x768) */
+};
+
+/* CR00,CR02,CR03,CR04,CR05,SR0B,SR0C,SR0E */
+static struct XGI_LVDSCRT1HDataStruct XGI_LVDSCRT11280x1024_1_Hx75[] = {
+       { {0x56, 0x27, 0x9A, 0x30, 0x1E, 0x00, 0x05, 0x00} },/* ; 00 (320x) */
+       { {0x56, 0x27, 0x9A, 0x30, 0x1E, 0x00, 0x05, 0x00} },/* ; 01 (360x) */
+       { {0x60, 0x31, 0x84, 0x3A, 0x88, 0x00, 0x01, 0x00} },/* ; 02 (400x) */
+       { {0x6E, 0x3F, 0x92, 0x48, 0x96, 0x00, 0x01, 0x00} },/* ; 03 (512x) */
+       { {0x7E, 0x4F, 0x82, 0x54, 0x06, 0x00, 0x06, 0x00} },/* ; 04 (640x) */
+       { {0x7E, 0x4F, 0x82, 0x54, 0x06, 0x00, 0x06, 0x00} },/* ; 05 (720x) */
+       { {0x92, 0x63, 0x96, 0x68, 0x1A, 0x00, 0x06, 0x00} },/* ; 06 (800x) */
+       { {0xAE, 0x7F, 0x92, 0x84, 0x96, 0x00, 0x02, 0x00} },/* ; 07 (1024x) */
+       { {0xCE, 0x9F, 0x92, 0xA5, 0x17, 0x00, 0x07, 0x00} } /* ; 08 (1280x) */
+};
+
+/* CR06,CR07,CR10,CR11,CR15,CR16,SR0A */
+static struct XGI_LVDSCRT1VDataStruct XGI_LVDSCRT11280x1024_1_Vx75[] = {
+       { {0x86, 0xD1, 0xBC, 0x80, 0xBB, 0xE5, 0x00} },/* ; 00 (x350) */
+       { {0xB8, 0x1F, 0x90, 0x84, 0x8F, 0xB9, 0x30} },/* ; 01 (x400) */
+       { {0x08, 0x3E, 0xE0, 0x84, 0xDF, 0x09, 0x00} },/* ; 02 (x480) */
+       { {0x80, 0xF0, 0x58, 0x8C, 0x57, 0x81, 0xA0} },/* ; 03 (x600) */
+       { {0x28, 0xF5, 0x00, 0x84, 0xFF, 0x29, 0x90} },/* ; 04 (x768) */
+       { {0x28, 0x5A, 0x13, 0x87, 0xFF, 0x29, 0xA9} } /* ; 05 (x1024) */
+};
+/* CR00,CR02,CR03,CR04,CR05,SR0B,SR0C,SR0E */
+static struct XGI_LVDSCRT1HDataStruct XGI_LVDSCRT11280x1024_2_Hx75[] = {
+       { {0x7E, 0x3B, 0x9A, 0x44, 0x12, 0x00, 0x01, 0x00} },/* ; 00 (320x) */
+       { {0x7E, 0x3B, 0x9A, 0x44, 0x12, 0x00, 0x01, 0x00} },/* ; 01 (360x) */
+       { {0x7E, 0x40, 0x84, 0x49, 0x91, 0x00, 0x01, 0x00} },/* ; 02 (400x) */
+       { {0x7E, 0x47, 0x93, 0x50, 0x9E, 0x00, 0x01, 0x00} },/* ; 03 (512x) */
+       { {0xCE, 0x77, 0x8A, 0x80, 0x8E, 0x00, 0x02, 0x00} },/* ; 04 (640x) */
+       { {0xCE, 0x77, 0x8A, 0x80, 0x8E, 0x00, 0x02, 0x00} },/* ; 05 (720x) */
+       { {0xCE, 0x81, 0x94, 0x8A, 0x98, 0x00, 0x02, 0x00} },/* ; 06 (800x) */
+       { {0xCE, 0x8F, 0x82, 0x98, 0x06, 0x00, 0x07, 0x00} },/* ; 07 (1024x) */
+       { {0xCE, 0x9F, 0x92, 0xA8, 0x16, 0x00, 0x07, 0x00} } /* ; 08 (1280x) */
+};
+
+/* CR06,CR07,CR10,CR11,CR15,CR16,SR0A */
+static struct XGI_LVDSCRT1VDataStruct XGI_LVDSCRT11280x1024_2_Vx75[] = {
+       { {0x28, 0xD2, 0xAF, 0x83, 0xAE, 0xD8, 0xA1} },/* ; 00 (x350) */
+       { {0x28, 0xD2, 0xC8, 0x8C, 0xC7, 0xF2, 0x81} },/* ; 01 (x400) */
+       { {0x28, 0xD2, 0xF0, 0x84, 0xEF, 0x1A, 0xB1} },/* ; 02 (x480) */
+       { {0x28, 0xDE, 0x2C, 0x8F, 0x2B, 0x56, 0x91} },/* ; 03 (x600) */
+       { {0x28, 0xDE, 0x80, 0x83, 0x7F, 0xAA, 0x91} },/* ; 04 (x768) */
+       { {0x28, 0x5A, 0x13, 0x87, 0xFF, 0x29, 0xA9} } /* ; 05 (x1024) */
 };
 
 #if 0
-static struct XGI_LVDSCRT1DataStruct  XGI_CHTVCRT1UNTSC[] =
-{
- {{0x64,0x4f,0x88,0x56,0x9f,0x56,0x3e,
-    0xe8,0x84,0x8f,0x57,0x20,0x00,0x01,0x00 }},
- {{0x64,0x4f,0x88,0x56,0x9f,0x56,0x3e,
-    0xd0,0x82,0x5d,0x57,0x00,0x00,0x01,0x00 }},
- {{0x64,0x4f,0x88,0x56,0x9f,0x56,0x3e,
-    0xe8,0x84,0x8f,0x57,0x20,0x00,0x01,0x00 }},
- {{0x64,0x4f,0x88,0x56,0x9f,0x56,0x3e,
-    0xd0,0x82,0x5d,0x57,0x00,0x00,0x01,0x00 }},
- {{0x5d,0x4f,0x81,0x53,0x9c,0x56,0xba,
-    0x18,0x84,0xdf,0x57,0x00,0x00,0x01,0x00 }},
- {{0x80,0x63,0x84,0x6c,0x17,0xec,0xf0,
-   0x90,0x8c,0x57,0xed,0x20,0x00,0x06,0x01 }}
-};
-
-static struct XGI_LVDSCRT1DataStruct  XGI_CHTVCRT1ONTSC[] =
-{
- {{0x64,0x4f,0x88,0x5a,0x9f,0x0b,0x3e,
-    0xc0,0x84,0x8f,0x0c,0x20,0x00,0x01,0x00 }},
- {{0x64,0x4f,0x88,0x5a,0x9f,0x0b,0x3e,
-    0xb0,0x8d,0x5d,0x0c,0x00,0x00,0x01,0x00 }},
- {{0x64,0x4f,0x88,0x5a,0x9f,0x0b,0x3e,
-    0xc0,0x84,0x8f,0x0c,0x20,0x00,0x01,0x00 }},
- {{0x64,0x4f,0x88,0x5a,0x9f,0x0b,0x3e,
-    0xb0,0x8d,0x5d,0x0c,0x00,0x00,0x01,0x00 }},
- {{0x5d,0x4f,0x81,0x56,0x9c,0x0b,0x3e,
-    0xe8,0x84,0xdf,0x0c,0x00,0x00,0x01,0x00 }},
- {{0x7d,0x63,0x81,0x6a,0x16,0xba,0xf0,
-   0x7f,0x86,0x57,0xbb,0x00,0x00,0x06,0x01 }}
-};
-
-static struct XGI_LVDSCRT1DataStruct  XGI_CHTVCRT1UPAL[] =
-{
- {{0x79,0x4f,0x9d,0x5a,0x90,0x6f,0x3e,
-    0xf8,0x83,0x8f,0x70,0x20,0x00,0x05,0x00 }},
- {{0x79,0x4f,0x9d,0x5a,0x90,0x6f,0x3e,
-    0xde,0x81,0x5d,0x70,0x00,0x00,0x05,0x00 }},
- {{0x79,0x4f,0x9d,0x5a,0x90,0x6f,0x3e,
-    0xf8,0x83,0x8f,0x70,0x20,0x00,0x05,0x00 }},
- {{0x79,0x4f,0x9d,0x5a,0x90,0x6f,0x3e,
-    0xde,0x81,0x5d,0x70,0x00,0x00,0x05,0x00 }},
- {{0x64,0x4f,0x88,0x55,0x80,0xec,0xba,
-    0x50,0x84,0xdf,0xed,0x00,0x00,0x05,0x00 }},
- {{0x70,0x63,0x94,0x68,0x8d,0x42,0xf1,
-   0xc8,0x8c,0x57,0xe9,0x20,0x00,0x05,0x01 }}
-};
-
-static struct XGI_LVDSCRT1DataStruct  XGI_CHTVCRT1OPAL[] =
-{
- {{0x79,0x4f,0x9d,0x5a,0x90,0x6f,0x3e,
-    0xf0,0x83,0x8f,0x70,0x20,0x00,0x05,0x00 }},
- {{0x79,0x4f,0x9d,0x5a,0x90,0x6f,0x3e,
-    0xde,0x81,0x5d,0x70,0x00,0x00,0x05,0x00 }},
- {{0x79,0x4f,0x9d,0x5a,0x90,0x6f,0x3e,
-    0xf0,0x83,0x8f,0x70,0x20,0x00,0x05,0x00 }},
- {{0x79,0x4f,0x9d,0x5a,0x90,0x6f,0x3e,
-    0xde,0x81,0x5d,0x70,0x00,0x00,0x05,0x00 }},
- {{0x64,0x4f,0x88,0x55,0x80,0x6f,0xba,
-    0x20,0x83,0xdf,0x70,0x00,0x00,0x05,0x00 }},
- {{0x73,0x63,0x97,0x69,0x8e,0xec,0xf0,
-   0x90,0x8c,0x57,0xed,0x20,0x00,0x05,0x01 }}
+static struct XGI_LVDSCRT1DataStruct  XGI_CHTVCRT1UNTSC[] = {
+       { {0x64, 0x4f, 0x88, 0x56, 0x9f, 0x56, 0x3e,
+         0xe8, 0x84, 0x8f, 0x57, 0x20, 0x00, 0x01, 0x00 } },
+       { {0x64, 0x4f, 0x88, 0x56, 0x9f, 0x56, 0x3e,
+         0xd0, 0x82, 0x5d, 0x57, 0x00, 0x00, 0x01, 0x00 } },
+       { {0x64, 0x4f, 0x88, 0x56, 0x9f, 0x56, 0x3e,
+         0xe8, 0x84, 0x8f, 0x57, 0x20, 0x00, 0x01, 0x00 } },
+       { {0x64, 0x4f, 0x88, 0x56, 0x9f, 0x56, 0x3e,
+         0xd0, 0x82, 0x5d, 0x57, 0x00, 0x00, 0x01, 0x00 } },
+       { {0x5d, 0x4f, 0x81, 0x53, 0x9c, 0x56, 0xba,
+         0x18, 0x84, 0xdf, 0x57, 0x00, 0x00, 0x01, 0x00 } },
+       { {0x80, 0x63, 0x84, 0x6c, 0x17, 0xec, 0xf0,
+         x90, 0x8c, 0x57, 0xed, 0x20, 0x00, 0x06, 0x01 } }
+};
+
+static struct XGI_LVDSCRT1DataStruct  XGI_CHTVCRT1ONTSC[] = {
+       { {0x64, 0x4f, 0x88, 0x5a, 0x9f, 0x0b, 0x3e,
+         0xc0, 0x84, 0x8f, 0x0c, 0x20, 0x00, 0x01, 0x00 } },
+       { {0x64, 0x4f, 0x88, 0x5a, 0x9f, 0x0b, 0x3e,
+         0xb0, 0x8d, 0x5d, 0x0c, 0x00, 0x00, 0x01, 0x00 } },
+       { {0x64, 0x4f, 0x88, 0x5a, 0x9f, 0x0b, 0x3e,
+         0xc0, 0x84, 0x8f, 0x0c, 0x20, 0x00, 0x01, 0x00 } },
+       { {0x64, 0x4f, 0x88, 0x5a, 0x9f, 0x0b, 0x3e,
+         0xb0, 0x8d, 0x5d, 0x0c, 0x00, 0x00, 0x01, 0x00 } },
+       { {0x5d, 0x4f, 0x81, 0x56, 0x9c, 0x0b, 0x3e,
+         0xe8, 0x84, 0xdf, 0x0c, 0x00, 0x00, 0x01, 0x00 } },
+       { {0x7d, 0x63, 0x81, 0x6a, 0x16, 0xba, 0xf0,
+         x7f, 0x86, 0x57, 0xbb, 0x00, 0x00, 0x06, 0x01 } }
+};
+
+static struct XGI_LVDSCRT1DataStruct  XGI_CHTVCRT1UPAL[] = {
+       { {0x79, 0x4f, 0x9d, 0x5a, 0x90, 0x6f, 0x3e,
+         0xf8, 0x83, 0x8f, 0x70, 0x20, 0x00, 0x05, 0x00 } },
+       { {0x79, 0x4f, 0x9d, 0x5a, 0x90, 0x6f, 0x3e,
+         0xde, 0x81, 0x5d, 0x70, 0x00, 0x00, 0x05, 0x00 } },
+       { {0x79, 0x4f, 0x9d, 0x5a, 0x90, 0x6f, 0x3e,
+         0xf8, 0x83, 0x8f, 0x70, 0x20, 0x00, 0x05, 0x00 } },
+       { {0x79, 0x4f, 0x9d, 0x5a, 0x90, 0x6f, 0x3e,
+         0xde, 0x81, 0x5d, 0x70, 0x00, 0x00, 0x05, 0x00 } },
+       { {0x64, 0x4f, 0x88, 0x55, 0x80, 0xec, 0xba,
+         0x50, 0x84, 0xdf, 0xed, 0x00, 0x00, 0x05, 0x00 } },
+       { {0x70, 0x63, 0x94, 0x68, 0x8d, 0x42, 0xf1,
+         xc8, 0x8c, 0x57, 0xe9, 0x20, 0x00, 0x05, 0x01 } }
+};
+
+static struct XGI_LVDSCRT1DataStruct  XGI_CHTVCRT1OPAL[] = {
+       { {0x79, 0x4f, 0x9d, 0x5a, 0x90, 0x6f, 0x3e,
+         0xf0, 0x83, 0x8f, 0x70, 0x20, 0x00, 0x05, 0x00 } },
+       { {0x79, 0x4f, 0x9d, 0x5a, 0x90, 0x6f, 0x3e,
+         0xde, 0x81, 0x5d, 0x70, 0x00, 0x00, 0x05, 0x00 } },
+       { {0x79, 0x4f, 0x9d, 0x5a, 0x90, 0x6f, 0x3e,
+         0xf0, 0x83, 0x8f, 0x70, 0x20, 0x00, 0x05, 0x00 } },
+       { {0x79, 0x4f, 0x9d, 0x5a, 0x90, 0x6f, 0x3e,
+         0xde, 0x81, 0x5d, 0x70, 0x00, 0x00, 0x05, 0x00 } },
+       { {0x64, 0x4f, 0x88, 0x55, 0x80, 0x6f, 0xba,
+         0x20, 0x83, 0xdf, 0x70, 0x00, 0x00, 0x05, 0x00 } },
+       { {0x73, 0x63, 0x97, 0x69, 0x8e, 0xec, 0xf0,
+         x90, 0x8c, 0x57, 0xed, 0x20, 0x00, 0x05, 0x01 } }
 };
 #endif
 
 /*add for new UNIVGABIOS*/
-static struct XGI330_LCDDataTablStruct XGI_LCDDataTable[] =
-{
-  {Panel1024x768,0x0019,0x0001,0},  /* XGI_ExtLCD1024x768Data */
-  {Panel1024x768,0x0019,0x0000,1},  /* XGI_StLCD1024x768Data */
-  {Panel1024x768,0x0018,0x0010,2},  /* XGI_CetLCD1024x768Data */
-  {Panel1280x1024,0x0019,0x0001,3},  /* XGI_ExtLCD1280x1024Data */
-  {Panel1280x1024,0x0019,0x0000,4},  /* XGI_StLCD1280x1024Data */
-  {Panel1280x1024,0x0018,0x0010,5},  /* XGI_CetLCD1280x1024Data */
-  {Panel1400x1050,0x0019,0x0001,6},  /* XGI_ExtLCD1400x1050Data */
-  {Panel1400x1050,0x0019,0x0000,7},  /* XGI_StLCD1400x1050Data */
-  {Panel1400x1050,0x0018,0x0010,8},  /* XGI_CetLCD1400x1050Data */
-  {Panel1600x1200,0x0019,0x0001,9},   /* XGI_ExtLCD1600x1200Data */
-  {Panel1600x1200,0x0019,0x0000,10},  /* XGI_StLCD1600x1200Data */
-  {PanelRef60Hz,0x0008,0x0008,11},     /* XGI_NoScalingData */
-  {Panel1024x768x75,0x0019,0x0001,12},         /* XGI_ExtLCD1024x768x75Data */
-  {Panel1024x768x75,0x0019,0x0000,13},         /* XGI_StLCD1024x768x75Data */
-  {Panel1024x768x75,0x0018,0x0010,14},         /* XGI_CetLCD1024x768x75Data */
-  {Panel1280x1024x75,0x0019,0x0001,15}, /* XGI_ExtLCD1280x1024x75Data */
-  {Panel1280x1024x75,0x0019,0x0000,16}, /* XGI_StLCD1280x1024x75Data */
-  {Panel1280x1024x75,0x0018,0x0010,17}, /* XGI_CetLCD1280x1024x75Data */
-  {PanelRef75Hz,0x0008,0x0008,18},     /* XGI_NoScalingDatax75 */
-  {0xFF,0x0000,0x0000,0}               /* End of table */
-};
-
-static struct XGI330_LCDDataTablStruct XGI_LCDDesDataTable[] =
-{
-  {Panel1024x768,0x0019,0x0001,0}, /* XGI_ExtLCDDes1024x768Data */
-  {Panel1024x768,0x0019,0x0000,1}, /* XGI_StLCDDes1024x768Data */
-  {Panel1024x768,0x0018,0x0010,2}, /* XGI_CetLCDDes1024x768Data */
-  {Panel1280x1024,0x0019,0x0001,3}, /* XGI_ExtLCDDes1280x1024Data */
-  {Panel1280x1024,0x0019,0x0000,4}, /* XGI_StLCDDes1280x1024Data */
-  {Panel1280x1024,0x0018,0x0010,5}, /* XGI_CetLCDDes1280x1024Data */
-  {Panel1400x1050,0x0019,0x0001,6}, /* XGI_ExtLCDDes1400x1050Data */
-  {Panel1400x1050,0x0019,0x0000,7}, /* XGI_StLCDDes1400x1050Data */
-  {Panel1400x1050,0x0418,0x0010,8}, /* XGI_CetLCDDes1400x1050Data */
-  {Panel1400x1050,0x0418,0x0410,9}, /* XGI_CetLCDDes1400x1050Data2 */
-  {Panel1600x1200,0x0019,0x0001,10}, /* XGI_ExtLCDDes1600x1200Data */
-  {Panel1600x1200,0x0019,0x0000,11}, /* XGI_StLCDDes1600x1200Data */
-  {PanelRef60Hz,0x0008,0x0008,12},     /* XGI_NoScalingDesData */
-  {Panel1024x768x75,0x0019,0x0001,13},         /* XGI_ExtLCDDes1024x768x75Data */
-  {Panel1024x768x75,0x0019,0x0000,14}, /* XGI_StLCDDes1024x768x75Data */
-  {Panel1024x768x75,0x0018,0x0010,15},  /* XGI_CetLCDDes1024x768x75Data */
-  {Panel1280x1024x75,0x0019,0x0001,16},        /* XGI_ExtLCDDes1280x1024x75Data */
-  {Panel1280x1024x75,0x0019,0x0000,17}, /* XGI_StLCDDes1280x1024x75Data */
-  {Panel1280x1024x75,0x0018,0x0010,18},        /* XGI_CetLCDDes1280x1024x75Data */
-  {PanelRef75Hz,0x0008,0x0008,19},     /* XGI_NoScalingDesDatax75 */
-  {0xFF,0x0000,0x0000,0}
-};
-
-static struct XGI330_LCDDataTablStruct XGI_EPLLCDCRT1Ptr_H[] =
-{
-  {Panel1024x768,0x0018,0x0000,0}, /* XGI_LVDSCRT11024x768_1_H */
-  {Panel1024x768,0x0018,0x0010,1}, /* XGI_LVDSCRT11024x768_2_H */
-  {Panel1280x1024,0x0018,0x0000,2}, /* XGI_LVDSCRT11280x1024_1_H */
-  {Panel1280x1024,0x0018,0x0010,3}, /* XGI_LVDSCRT11280x1024_2_H */
-  {Panel1400x1050,0x0018,0x0000,4}, /* XGI_LVDSCRT11400x1050_1_H */
-  {Panel1400x1050,0x0018,0x0010,5}, /* XGI_LVDSCRT11400x1050_2_H */
-  {Panel1600x1200,0x0018,0x0000,6},  /* XGI_LVDSCRT11600x1200_1_H */
-  {Panel1024x768x75,0x0018,0x0000,7},  /* XGI_LVDSCRT11024x768_1_Hx75 */
-  {Panel1024x768x75,0x0018,0x0010,8},  /* XGI_LVDSCRT11024x768_2_Hx75 */
-  {Panel1280x1024x75,0x0018,0x0000,9}, /* XGI_LVDSCRT11280x1024_1_Hx75 */
-  {Panel1280x1024x75,0x0018,0x0010,10},        /* XGI_LVDSCRT11280x1024_2_Hx75 */
-  {0xFF,0x0000,0x0000,0}
-};
-
-static struct XGI330_LCDDataTablStruct XGI_EPLLCDCRT1Ptr_V[] =
-{
-  {Panel1024x768,0x0018,0x0000,0}, /* XGI_LVDSCRT11024x768_1_V */
-  {Panel1024x768,0x0018,0x0010,1}, /* XGI_LVDSCRT11024x768_2_V */
-  {Panel1280x1024,0x0018,0x0000,2}, /* XGI_LVDSCRT11280x1024_1_V */
-  {Panel1280x1024,0x0018,0x0010,3}, /* XGI_LVDSCRT11280x1024_2_V */
-  {Panel1400x1050,0x0018,0x0000,4}, /* XGI_LVDSCRT11400x1050_1_V */
-  {Panel1400x1050,0x0018,0x0010,5}, /* XGI_LVDSCRT11400x1050_2_V */
-  {Panel1600x1200,0x0018,0x0000,6}, /* XGI_LVDSCRT11600x1200_1_V */
-  {Panel1024x768x75,0x0018,0x0000,7},  /* XGI_LVDSCRT11024x768_1_Vx75 */
-  {Panel1024x768x75,0x0018,0x0010,8},  /* XGI_LVDSCRT11024x768_2_Vx75 */
-  {Panel1280x1024x75,0x0018,0x0000,9}, /* XGI_LVDSCRT11280x1024_1_Vx75 */
-  {Panel1280x1024x75,0x0018,0x0010,10},        /* XGI_LVDSCRT11280x1024_2_Vx75 */
-  {0xFF,0x0000,0x0000,0}
-};
-
-static struct XGI330_LCDDataTablStruct XGI_EPLLCDDataPtr[] =
-{
-  {Panel1024x768,0x0018,0x0000,0}, /* XGI_LVDS1024x768Data_1 */
-  {Panel1024x768,0x0018,0x0010,1}, /* XGI_LVDS1024x768Data_2 */
-  {Panel1280x1024,0x0018,0x0000,2}, /* XGI_LVDS1280x1024Data_1 */
-  {Panel1280x1024,0x0018,0x0010,3}, /* XGI_LVDS1280x1024Data_2 */
-  {Panel1400x1050,0x0018,0x0000,4}, /* XGI_LVDS1400x1050Data_1 */
-  {Panel1400x1050,0x0018,0x0010,5}, /* XGI_LVDS1400x1050Data_2 */
-  {Panel1600x1200,0x0018,0x0000,6}, /* XGI_LVDS1600x1200Data_1 */
-  {PanelRef60Hz,0x0008,0x0008,7}, /* XGI_LVDSNoScalingData */
-  {Panel1024x768x75,0x0018,0x0000,8},  /* XGI_LVDS1024x768Data_1x75 */
-  {Panel1024x768x75,0x0018,0x0010,9},  /* XGI_LVDS1024x768Data_2x75 */
-  {Panel1280x1024x75,0x0018,0x0000,10},        /* XGI_LVDS1280x1024Data_1x75 */
-  {Panel1280x1024x75,0x0018,0x0010,11}, /* XGI_LVDS1280x1024Data_2x75 */
-  {PanelRef75Hz,0x0008,0x0008,12},     /* XGI_LVDSNoScalingDatax75 */
-  {0xFF,0x0000,0x0000,0}
-};
-
-static struct XGI330_LCDDataTablStruct XGI_EPLLCDDesDataPtr[] =
-{
-  {Panel1024x768,0x0018,0x0000,0}, /* XGI_LVDS1024x768Des_1 */
-  {Panel1024x768,0x0618,0x0410,1}, /* XGI_LVDS1024x768Des_3 */
-  {Panel1024x768,0x0018,0x0010,2}, /* XGI_LVDS1024x768Des_2 */
-  {Panel1280x1024,0x0018,0x0000,3}, /* XGI_LVDS1280x1024Des_1 */
-  {Panel1280x1024,0x0018,0x0010,4}, /* XGI_LVDS1280x1024Des_2 */
-  {Panel1400x1050,0x0018,0x0000,5}, /* XGI_LVDS1400x1050Des_1 */
-  {Panel1400x1050,0x0018,0x0010,6}, /* XGI_LVDS1400x1050Des_2 */
-  {Panel1600x1200,0x0018,0x0000,7}, /* XGI_LVDS1600x1200Des_1 */
-  {PanelRef60Hz,0x0008,0x0008,8},      /* XGI_LVDSNoScalingDesData */
-  {Panel1024x768x75,0x0018,0x0000,9},  /* XGI_LVDS1024x768Des_1x75 */
-  {Panel1024x768x75,0x0618,0x0410,10}, /* XGI_LVDS1024x768Des_3x75 */
-  {Panel1024x768x75,0x0018,0x0010,11}, /* XGI_LVDS1024x768Des_2x75 */
-  {Panel1280x1024x75,0x0018,0x0000,12},        /* XGI_LVDS1280x1024Des_1x75 */
-  {Panel1280x1024x75,0x0018,0x0010,13},        /* XGI_LVDS1280x1024Des_2x75 */
-  {PanelRef75Hz,0x0008,0x0008,14},     /* XGI_LVDSNoScalingDesDatax75 */
-  {0xFF,0x0000,0x0000,0}
-};
-
-static struct XGI330_LCDDataTablStruct XGI_EPLCHLCDRegPtr[] =
-{
-  {Panel1024x768,0x0000,0x0000,0}, /* XGI_CH7017LV1024x768 */
-  {Panel1400x1050,0x0000,0x0000,1}, /* XGI_CH7017LV1400x1050 */
-  {0xFF,0x0000,0x0000,0}
-};
-
-static struct XGI330_TVDataTablStruct XGI_TVDataTable[] =
-{
- {0x09E1,0x0001,0},    /* XGI_ExtPALData */
- {0x09E1,0x0000,1},    /* XGI_ExtNTSCData */
- {0x09E1,0x0801,2},    /* XGI_StPALData */
- {0x09E1,0x0800,3},    /* XGI_StNTSCData */
- {0x49E0,0x0100,4},    /* XGI_ExtHiTVData */
- {0x49E0,0x4100,5},    /* XGI_St2HiTVData */
- {0x49E0,0x4900,13},   /* XGI_St1HiTVData */
- {0x09E0,0x0020,6},    /* XGI_ExtYPbPr525iData */
- {0x09E0,0x0040,7},    /* XGI_ExtYPbPr525pData */
- {0x09E0,0x0080,8},    /* XGI_ExtYPbPr750pData */
- {0x09E0,0x0820,9},    /* XGI_StYPbPr525iData */
- {0x09E0,0x0840,10},   /* XGI_StYPbPr525pData */
- {0x09E0,0x0880,11},   /* XGI_StYPbPr750pData */
- {0xffff,0x0000,12}    /* END */
+static struct XGI330_LCDDataTablStruct XGI_LCDDataTable[] = {
+       {Panel1024x768, 0x0019, 0x0001, 0}, /* XGI_ExtLCD1024x768Data */
+       {Panel1024x768, 0x0019, 0x0000, 1}, /* XGI_StLCD1024x768Data */
+       {Panel1024x768, 0x0018, 0x0010, 2}, /* XGI_CetLCD1024x768Data */
+       {Panel1280x1024, 0x0019, 0x0001, 3}, /* XGI_ExtLCD1280x1024Data */
+       {Panel1280x1024, 0x0019, 0x0000, 4}, /* XGI_StLCD1280x1024Data */
+       {Panel1280x1024, 0x0018, 0x0010, 5}, /* XGI_CetLCD1280x1024Data */
+       {Panel1400x1050, 0x0019, 0x0001, 6}, /* XGI_ExtLCD1400x1050Data */
+       {Panel1400x1050, 0x0019, 0x0000, 7}, /* XGI_StLCD1400x1050Data */
+       {Panel1400x1050, 0x0018, 0x0010, 8}, /* XGI_CetLCD1400x1050Data */
+       {Panel1600x1200, 0x0019, 0x0001, 9}, /* XGI_ExtLCD1600x1200Data */
+       {Panel1600x1200, 0x0019, 0x0000, 10}, /* XGI_StLCD1600x1200Data */
+       {PanelRef60Hz, 0x0008, 0x0008, 11}, /* XGI_NoScalingData */
+       {Panel1024x768x75, 0x0019, 0x0001, 12}, /* XGI_ExtLCD1024x768x75Data */
+       {Panel1024x768x75, 0x0019, 0x0000, 13}, /* XGI_StLCD1024x768x75Data */
+       {Panel1024x768x75, 0x0018, 0x0010, 14}, /* XGI_CetLCD1024x768x75Data */
+       {Panel1280x1024x75, 0x0019, 0x0001, 15}, /* XGI_ExtLCD1280x1024x75Data*/
+       {Panel1280x1024x75, 0x0019, 0x0000, 16}, /* XGI_StLCD1280x1024x75Data */
+       {Panel1280x1024x75, 0x0018, 0x0010, 17}, /* XGI_CetLCD1280x1024x75Data*/
+       {PanelRef75Hz, 0x0008, 0x0008, 18}, /* XGI_NoScalingDatax75 */
+       {0xFF, 0x0000, 0x0000, 0} /* End of table */
+};
+
+static struct XGI330_LCDDataTablStruct XGI_LCDDesDataTable[] = {
+       {Panel1024x768, 0x0019, 0x0001, 0}, /* XGI_ExtLCDDes1024x768Data */
+       {Panel1024x768, 0x0019, 0x0000, 1}, /* XGI_StLCDDes1024x768Data */
+       {Panel1024x768, 0x0018, 0x0010, 2}, /* XGI_CetLCDDes1024x768Data */
+       {Panel1280x1024, 0x0019, 0x0001, 3}, /* XGI_ExtLCDDes1280x1024Data */
+       {Panel1280x1024, 0x0019, 0x0000, 4}, /* XGI_StLCDDes1280x1024Data */
+       {Panel1280x1024, 0x0018, 0x0010, 5}, /* XGI_CetLCDDes1280x1024Data */
+       {Panel1400x1050, 0x0019, 0x0001, 6}, /* XGI_ExtLCDDes1400x1050Data */
+       {Panel1400x1050, 0x0019, 0x0000, 7}, /* XGI_StLCDDes1400x1050Data */
+       {Panel1400x1050, 0x0418, 0x0010, 8}, /* XGI_CetLCDDes1400x1050Data */
+       {Panel1400x1050, 0x0418, 0x0410, 9}, /* XGI_CetLCDDes1400x1050Data2 */
+       {Panel1600x1200, 0x0019, 0x0001, 10}, /* XGI_ExtLCDDes1600x1200Data */
+       {Panel1600x1200, 0x0019, 0x0000, 11}, /* XGI_StLCDDes1600x1200Data */
+       {PanelRef60Hz, 0x0008, 0x0008, 12}, /* XGI_NoScalingDesData */
+       {Panel1024x768x75, 0x0019, 0x0001, 13}, /*XGI_ExtLCDDes1024x768x75Data*/
+       {Panel1024x768x75, 0x0019, 0x0000, 14}, /* XGI_StLCDDes1024x768x75Data*/
+       {Panel1024x768x75, 0x0018, 0x0010, 15}, /*XGI_CetLCDDes1024x768x75Data*/
+       /* XGI_ExtLCDDes1280x1024x75Data */
+       {Panel1280x1024x75, 0x0019, 0x0001, 16},
+       /* XGI_StLCDDes1280x1024x75Data */
+       {Panel1280x1024x75, 0x0019, 0x0000, 17},
+       /* XGI_CetLCDDes1280x1024x75Data */
+       {Panel1280x1024x75, 0x0018, 0x0010, 18},
+       {PanelRef75Hz, 0x0008, 0x0008, 19}, /* XGI_NoScalingDesDatax75 */
+       {0xFF, 0x0000, 0x0000, 0}
+};
+
+static struct XGI330_LCDDataTablStruct XGI_EPLLCDCRT1Ptr_H[] = {
+       {Panel1024x768, 0x0018, 0x0000, 0}, /* XGI_LVDSCRT11024x768_1_H */
+       {Panel1024x768, 0x0018, 0x0010, 1}, /* XGI_LVDSCRT11024x768_2_H */
+       {Panel1280x1024, 0x0018, 0x0000, 2}, /* XGI_LVDSCRT11280x1024_1_H */
+       {Panel1280x1024, 0x0018, 0x0010, 3}, /* XGI_LVDSCRT11280x1024_2_H */
+       {Panel1400x1050, 0x0018, 0x0000, 4}, /* XGI_LVDSCRT11400x1050_1_H */
+       {Panel1400x1050, 0x0018, 0x0010, 5}, /* XGI_LVDSCRT11400x1050_2_H */
+       {Panel1600x1200, 0x0018, 0x0000, 6}, /* XGI_LVDSCRT11600x1200_1_H */
+       {Panel1024x768x75, 0x0018, 0x0000, 7}, /* XGI_LVDSCRT11024x768_1_Hx75 */
+       {Panel1024x768x75, 0x0018, 0x0010, 8}, /* XGI_LVDSCRT11024x768_2_Hx75 */
+       {Panel1280x1024x75, 0x0018, 0x0000, 9}, /*XGI_LVDSCRT11280x1024_1_Hx75*/
+       {Panel1280x1024x75, 0x0018, 0x0010, 10},/*XGI_LVDSCRT11280x1024_2_Hx75*/
+       {0xFF, 0x0000, 0x0000, 0}
+};
+
+static struct XGI330_LCDDataTablStruct XGI_EPLLCDCRT1Ptr_V[] = {
+       {Panel1024x768, 0x0018, 0x0000, 0}, /* XGI_LVDSCRT11024x768_1_V */
+       {Panel1024x768, 0x0018, 0x0010, 1}, /* XGI_LVDSCRT11024x768_2_V */
+       {Panel1280x1024, 0x0018, 0x0000, 2}, /* XGI_LVDSCRT11280x1024_1_V */
+       {Panel1280x1024, 0x0018, 0x0010, 3}, /* XGI_LVDSCRT11280x1024_2_V */
+       {Panel1400x1050, 0x0018, 0x0000, 4}, /* XGI_LVDSCRT11400x1050_1_V */
+       {Panel1400x1050, 0x0018, 0x0010, 5}, /* XGI_LVDSCRT11400x1050_2_V */
+       {Panel1600x1200, 0x0018, 0x0000, 6}, /* XGI_LVDSCRT11600x1200_1_V */
+       {Panel1024x768x75, 0x0018, 0x0000, 7}, /* XGI_LVDSCRT11024x768_1_Vx75 */
+       {Panel1024x768x75, 0x0018, 0x0010, 8}, /* XGI_LVDSCRT11024x768_2_Vx75 */
+       {Panel1280x1024x75, 0x0018, 0x0000, 9}, /*XGI_LVDSCRT11280x1024_1_Vx75*/
+       {Panel1280x1024x75, 0x0018, 0x0010, 10},/*XGI_LVDSCRT11280x1024_2_Vx75*/
+       {0xFF, 0x0000, 0x0000, 0}
+};
+
+static struct XGI330_LCDDataTablStruct XGI_EPLLCDDataPtr[] = {
+       {Panel1024x768, 0x0018, 0x0000, 0}, /* XGI_LVDS1024x768Data_1 */
+       {Panel1024x768, 0x0018, 0x0010, 1}, /* XGI_LVDS1024x768Data_2 */
+       {Panel1280x1024, 0x0018, 0x0000, 2}, /* XGI_LVDS1280x1024Data_1 */
+       {Panel1280x1024, 0x0018, 0x0010, 3}, /* XGI_LVDS1280x1024Data_2 */
+       {Panel1400x1050, 0x0018, 0x0000, 4}, /* XGI_LVDS1400x1050Data_1 */
+       {Panel1400x1050, 0x0018, 0x0010, 5}, /* XGI_LVDS1400x1050Data_2 */
+       {Panel1600x1200, 0x0018, 0x0000, 6}, /* XGI_LVDS1600x1200Data_1 */
+       {PanelRef60Hz, 0x0008, 0x0008, 7}, /* XGI_LVDSNoScalingData */
+       {Panel1024x768x75, 0x0018, 0x0000, 8}, /* XGI_LVDS1024x768Data_1x75 */
+       {Panel1024x768x75, 0x0018, 0x0010, 9}, /* XGI_LVDS1024x768Data_2x75 */
+       {Panel1280x1024x75, 0x0018, 0x0000, 10}, /* XGI_LVDS1280x1024Data_1x75*/
+       {Panel1280x1024x75, 0x0018, 0x0010, 11},  /*XGI_LVDS1280x1024Data_2x75*/
+       {PanelRef75Hz, 0x0008, 0x0008, 12}, /* XGI_LVDSNoScalingDatax75 */
+       {0xFF, 0x0000, 0x0000, 0}
+};
+
+static struct XGI330_LCDDataTablStruct XGI_EPLLCDDesDataPtr[] = {
+       {Panel1024x768, 0x0018, 0x0000, 0}, /* XGI_LVDS1024x768Des_1 */
+       {Panel1024x768, 0x0618, 0x0410, 1}, /* XGI_LVDS1024x768Des_3 */
+       {Panel1024x768, 0x0018, 0x0010, 2}, /* XGI_LVDS1024x768Des_2 */
+       {Panel1280x1024, 0x0018, 0x0000, 3}, /* XGI_LVDS1280x1024Des_1 */
+       {Panel1280x1024, 0x0018, 0x0010, 4}, /* XGI_LVDS1280x1024Des_2 */
+       {Panel1400x1050, 0x0018, 0x0000, 5}, /* XGI_LVDS1400x1050Des_1 */
+       {Panel1400x1050, 0x0018, 0x0010, 6}, /* XGI_LVDS1400x1050Des_2 */
+       {Panel1600x1200, 0x0018, 0x0000, 7}, /* XGI_LVDS1600x1200Des_1 */
+       {PanelRef60Hz, 0x0008, 0x0008, 8},  /* XGI_LVDSNoScalingDesData */
+       {Panel1024x768x75, 0x0018, 0x0000, 9}, /* XGI_LVDS1024x768Des_1x75 */
+       {Panel1024x768x75, 0x0618, 0x0410, 10}, /* XGI_LVDS1024x768Des_3x75 */
+       {Panel1024x768x75, 0x0018, 0x0010, 11}, /* XGI_LVDS1024x768Des_2x75 */
+       {Panel1280x1024x75, 0x0018, 0x0000, 12}, /* XGI_LVDS1280x1024Des_1x75 */
+       {Panel1280x1024x75, 0x0018, 0x0010, 13}, /* XGI_LVDS1280x1024Des_2x75 */
+       {PanelRef75Hz, 0x0008, 0x0008, 14}, /* XGI_LVDSNoScalingDesDatax75 */
+       {0xFF, 0x0000, 0x0000, 0}
+};
+
+static struct XGI330_LCDDataTablStruct XGI_EPLCHLCDRegPtr[] = {
+       {Panel1024x768, 0x0000, 0x0000, 0}, /* XGI_CH7017LV1024x768 */
+       {Panel1400x1050, 0x0000, 0x0000, 1}, /* XGI_CH7017LV1400x1050 */
+       {0xFF, 0x0000, 0x0000, 0}
+};
+
+static struct XGI330_TVDataTablStruct XGI_TVDataTable[] = {
+       {0x09E1, 0x0001, 0}, /* XGI_ExtPALData */
+       {0x09E1, 0x0000, 1}, /* XGI_ExtNTSCData */
+       {0x09E1, 0x0801, 2}, /* XGI_StPALData */
+       {0x09E1, 0x0800, 3}, /* XGI_StNTSCData */
+       {0x49E0, 0x0100, 4}, /* XGI_ExtHiTVData */
+       {0x49E0, 0x4100, 5}, /* XGI_St2HiTVData */
+       {0x49E0, 0x4900, 13}, /* XGI_St1HiTVData */
+       {0x09E0, 0x0020, 6}, /* XGI_ExtYPbPr525iData */
+       {0x09E0, 0x0040, 7}, /* XGI_ExtYPbPr525pData */
+       {0x09E0, 0x0080, 8}, /* XGI_ExtYPbPr750pData */
+       {0x09E0, 0x0820, 9}, /* XGI_StYPbPr525iData */
+       {0x09E0, 0x0840, 10}, /* XGI_StYPbPr525pData */
+       {0x09E0, 0x0880, 11}, /* XGI_StYPbPr750pData */
+       {0xffff, 0x0000, 12}  /* END */
 };
 
 #if 0
-static unsigned short TVLenList[] =
-{
-   LVDSCRT1Len_H,
-   LVDSCRT1Len_V,
-   LVDSDataLen,
-   0,
-   TVDataLen,
-   0,
-   0,
-   CHTVRegLen
-} ;
+static unsigned short TVLenList[] = {
+       LVDSCRT1Len_H,
+       LVDSCRT1Len_V,
+       LVDSDataLen,
+       0,
+       TVDataLen,
+       0,
+       0,
+       CHTVRegLen
+};
 #endif
 
 /* Chrontel 7017 TV CRT1 Timing List */
-static struct XGI330_TVDataTablStruct XGI_EPLCHTVCRT1Ptr[] =
-{
-  {0x0011,0x0000,0}, /* XGI_CHTVCRT1UNTSC */
-  {0x0011,0x0010,1}, /* XGI_CHTVCRT1ONTSC */
-  {0x0011,0x0001,2}, /* XGI_CHTVCRT1UPAL */
-  {0x0011,0x0011,3}, /* XGI_CHTVCRT1OPAL */
-  {0xFFFF,0x0000,4}
+static struct XGI330_TVDataTablStruct XGI_EPLCHTVCRT1Ptr[] = {
+       {0x0011, 0x0000, 0}, /* XGI_CHTVCRT1UNTSC */
+       {0x0011, 0x0010, 1}, /* XGI_CHTVCRT1ONTSC */
+       {0x0011, 0x0001, 2}, /* XGI_CHTVCRT1UPAL */
+       {0x0011, 0x0011, 3}, /* XGI_CHTVCRT1OPAL */
+       {0xFFFF, 0x0000, 4}
 };
 
 /* ;;Chrontel 7017 TV Timing List */
-static struct XGI330_TVDataTablStruct XGI_EPLCHTVDataPtr[] =
-{
-  {0x0011,0x0000,0}, /* XGI_CHTVUNTSCData */
-  {0x0011,0x0010,1}, /* XGI_CHTVONTSCData */
-  {0x0011,0x0001,2}, /* XGI_CHTVUPALData */
-  {0x0011,0x0011,3}, /* XGI_CHTVOPALData */
-  {0xFFFF,0x0000,4}
+static struct XGI330_TVDataTablStruct XGI_EPLCHTVDataPtr[] = {
+       {0x0011, 0x0000, 0}, /* XGI_CHTVUNTSCData */
+       {0x0011, 0x0010, 1}, /* XGI_CHTVONTSCData */
+       {0x0011, 0x0001, 2}, /* XGI_CHTVUPALData */
+       {0x0011, 0x0011, 3}, /* XGI_CHTVOPALData */
+       {0xFFFF, 0x0000, 4}
 };
 
 /* ;;Chrontel 7017 TV Reg. List */
-static struct XGI330_TVDataTablStruct XGI_EPLCHTVRegPtr[] =
-{
-  {0x0011,0x0000,0}, /* XGI_CHTVRegUNTSC */
-  {0x0011,0x0010,1}, /* XGI_CHTVRegONTSC */
-  {0x0011,0x0001,2}, /* XGI_CHTVRegUPAL */
-  {0x0011,0x0011,3}, /* XGI_CHTVRegOPAL */
-  {0xFFFF,0x0000,4}
-};
-
-static unsigned short LCDLenList[] =
-{
-   LVDSCRT1Len_H,
-   LVDSCRT1Len_V,
-   LVDSDataLen,
-   LCDDesDataLen,
-   LCDDataLen,
-   LCDDesDataLen,
-   0,
-   LCDDesDataLen,
-   LCDDesDataLen,
-   0
-} ;
+static struct XGI330_TVDataTablStruct XGI_EPLCHTVRegPtr[] = {
+       {0x0011, 0x0000, 0}, /* XGI_CHTVRegUNTSC */
+       {0x0011, 0x0010, 1}, /* XGI_CHTVRegONTSC */
+       {0x0011, 0x0001, 2}, /* XGI_CHTVRegUPAL */
+       {0x0011, 0x0011, 3}, /* XGI_CHTVRegOPAL */
+       {0xFFFF, 0x0000, 4}
+};
+
+static unsigned short LCDLenList[] = {
+       LVDSCRT1Len_H,
+       LVDSCRT1Len_V,
+       LVDSDataLen,
+       LCDDesDataLen,
+       LCDDataLen,
+       LCDDesDataLen,
+       0,
+       LCDDesDataLen,
+       LCDDesDataLen,
+       0
+};
 
 #if 0
-static struct XGI330_LCDCapStruct  XGI660_LCDDLCapList[] =  /* 660, Dual link */
-{
+/* 660, Dual link */
+static struct XGI330_LCDCapStruct  XGI660_LCDDLCapList[] = {
 /* LCDCap1024x768 */
-               {Panel1024x768, DefaultLCDCap, 0, 0x014, 0x88, 0x06, VCLK65,
-                0x6C, 0xC3, 0x35, 0x62, 0x02, 0x14, 0x0A, 0x02, 0x00,
-                0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x28, 0x10},
+       {Panel1024x768, DefaultLCDCap, 0, 0x014, 0x88, 0x06, VCLK65,
+        0x6C, 0xC3, 0x35, 0x62, 0x02, 0x14, 0x0A, 0x02, 0x00,
+        0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x28, 0x10},
 /* LCDCap1280x1024 */
-                {Panel1280x1024, LCDDualLink+DefaultLCDCap, StLCDBToA, 0x053, 0x70, 0x03, VCLK108_2,
-                0x70, 0x44, 0xF8, 0x2F, 0x02, 0x14, 0x0A, 0x02, 0x00,
-                0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x30, 0x10},
+       {Panel1280x1024, LCDDualLink+DefaultLCDCap, StLCDBToA,
+       0x053, 0x70, 0x03, VCLK108_2,
+        0x70, 0x44, 0xF8, 0x2F, 0x02, 0x14, 0x0A, 0x02, 0x00,
+        0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x30, 0x10},
 /* LCDCap1400x1050 */
-                {Panel1400x1050, LCDDualLink+DefaultLCDCap, StLCDBToA, 0x053, 0x70, 0x03, VCLK108_2,
-                0x70, 0x44, 0xF8, 0x2F, 0x02, 0x14, 0x0A, 0x02, 0x00,
-                0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x30, 0x10},
+       {Panel1400x1050, LCDDualLink+DefaultLCDCap, StLCDBToA,
+       0x053, 0x70, 0x03, VCLK108_2,
+        0x70, 0x44, 0xF8, 0x2F, 0x02, 0x14, 0x0A, 0x02, 0x00,
+        0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x30, 0x10},
 /* LCDCap1600x1200 */
-                {Panel1600x1200, LCDDualLink+DefaultLCDCap, LCDToFull, 0x053, 0xC0, 0x03, VCLK162,
-                0x43, 0x22, 0x70, 0x24, 0x02, 0x14, 0x0A, 0x02, 0x00,
-                0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x30, 0x10},
+       {Panel1600x1200, LCDDualLink+DefaultLCDCap, LCDToFull,
+       0x053, 0xC0, 0x03, VCLK162,
+        0x43, 0x22, 0x70, 0x24, 0x02, 0x14, 0x0A, 0x02, 0x00,
+        0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x30, 0x10},
 /* LCDCap1024x768x75 */
-               {Panel1024x768x75, DefaultLCDCap, 0, 0x014, 0x60, 0, VCLK78_75,
-                0x2B, 0x61, 0x2B, 0x61, 0x02, 0x14, 0x0A, 0x02, 0x00,
-                0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x28, 0x10},
+       {Panel1024x768x75, DefaultLCDCap, 0, 0x014, 0x60, 0, VCLK78_75,
+        0x2B, 0x61, 0x2B, 0x61, 0x02, 0x14, 0x0A, 0x02, 0x00,
+        0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x28, 0x10},
 /* LCDCap1280x1024x75 */
-                {Panel1280x1024x75, LCDDualLink+DefaultLCDCap, StLCDBToA, 0x053, 0x90, 0x03, VCLK135_5,
-                0x54, 0x42, 0x4A, 0x61, 0x02, 0x14, 0x0A, 0x02, 0x00,
-                0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x30, 0x10},
+       {Panel1280x1024x75, LCDDualLink+DefaultLCDCap, StLCDBToA,
+       0x053, 0x90, 0x03, VCLK135_5,
+        0x54, 0x42, 0x4A, 0x61, 0x02, 0x14, 0x0A, 0x02, 0x00,
+        0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x30, 0x10},
 /* LCDCapDefault */
-                {0xFF, DefaultLCDCap, 0, 0x053, 0x88, 0x06, VCLK65,
-               0x6C, 0xC3, 0x35, 0x62, 0x02, 0x14, 0x0A, 0x02, 0x00,
-               0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x28, 0x10}
+       {0xFF, DefaultLCDCap, 0, 0x053, 0x88, 0x06, VCLK65,
+       0x6C, 0xC3, 0x35, 0x62, 0x02, 0x14, 0x0A, 0x02, 0x00,
+       0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x28, 0x10}
 };
 #endif
 
-static struct XGI330_LCDCapStruct  XGI_LCDDLCapList[] =  /* Dual link only */
-{
+/* Dual link only */
+static struct XGI330_LCDCapStruct  XGI_LCDDLCapList[] = {
 /* LCDCap1024x768 */
-               {Panel1024x768, DefaultLCDCap, 0, 0x012, 0x88, 0x06, VCLK65,
-               0x6C, 0xC3, 0x35, 0x62, 0x02, 0x14, 0x0A, 0x02, 0x00,
-               0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x28, 0x10},
+       {Panel1024x768, DefaultLCDCap, 0, 0x012, 0x88, 0x06, VCLK65,
+       0x6C, 0xC3, 0x35, 0x62, 0x02, 0x14, 0x0A, 0x02, 0x00,
+       0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x28, 0x10},
 /* LCDCap1280x1024 */
-               {Panel1280x1024, LCDDualLink+DefaultLCDCap, StLCDBToA, 0x012, 0x70, 0x03, VCLK108_2,
-               0x70, 0x44, 0xF8, 0x2F, 0x02, 0x14, 0x0A, 0x02, 0x00,
-               0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x30, 0x10},
+       {Panel1280x1024, LCDDualLink+DefaultLCDCap, StLCDBToA,
+       0x012, 0x70, 0x03, VCLK108_2,
+       0x70, 0x44, 0xF8, 0x2F, 0x02, 0x14, 0x0A, 0x02, 0x00,
+       0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x30, 0x10},
 /* LCDCap1400x1050 */
-               {Panel1400x1050, LCDDualLink+DefaultLCDCap, StLCDBToA, 0x012, 0x70, 0x03, VCLK108_2,
-                0x70, 0x44, 0xF8, 0x2F, 0x02, 0x14, 0x0A, 0x02, 0x00,
-                0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x30, 0x10},
+       {Panel1400x1050, LCDDualLink+DefaultLCDCap, StLCDBToA,
+       0x012, 0x70, 0x03, VCLK108_2,
+        0x70, 0x44, 0xF8, 0x2F, 0x02, 0x14, 0x0A, 0x02, 0x00,
+        0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x30, 0x10},
 /* LCDCap1600x1200 */
-               {Panel1600x1200, LCDDualLink+DefaultLCDCap, LCDToFull, 0x012, 0xC0, 0x03, VCLK162,
-                0x43, 0x22, 0x70, 0x24, 0x02, 0x14, 0x0A, 0x02, 0x00,
-                0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x30, 0x10},
+       {Panel1600x1200, LCDDualLink+DefaultLCDCap, LCDToFull,
+       0x012, 0xC0, 0x03, VCLK162,
+        0x43, 0x22, 0x70, 0x24, 0x02, 0x14, 0x0A, 0x02, 0x00,
+        0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x30, 0x10},
 /* LCDCap1024x768x75 */
-               {Panel1024x768x75, DefaultLCDCap, 0, 0x012, 0x60, 0, VCLK78_75,
-                0x2B, 0x61, 0x2B, 0x61, 0x02, 0x14, 0x0A, 0x02, 0x00,
-                0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x28, 0x10},
+       {Panel1024x768x75, DefaultLCDCap, 0, 0x012, 0x60, 0, VCLK78_75,
+        0x2B, 0x61, 0x2B, 0x61, 0x02, 0x14, 0x0A, 0x02, 0x00,
+        0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x28, 0x10},
 /* LCDCap1280x1024x75 */
-               {Panel1280x1024x75, LCDDualLink+DefaultLCDCap, StLCDBToA, 0x012, 0x90, 0x03, VCLK135_5,
-                0x54, 0x42, 0x4A, 0x61, 0x02, 0x14, 0x0A, 0x02, 0x00,
-                0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x30, 0x10},
+       {Panel1280x1024x75, LCDDualLink+DefaultLCDCap, StLCDBToA,
+       0x012, 0x90, 0x03, VCLK135_5,
+        0x54, 0x42, 0x4A, 0x61, 0x02, 0x14, 0x0A, 0x02, 0x00,
+        0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x30, 0x10},
 /* LCDCapDefault */
-               {0xFF, DefaultLCDCap, 0, 0x012, 0x88, 0x06, VCLK65,
-               0x6C, 0xC3, 0x35, 0x62, 0x02, 0x14, 0x0A, 0x02, 0x00,
-               0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x28, 0x10}
+       {0xFF, DefaultLCDCap, 0, 0x012, 0x88, 0x06, VCLK65,
+       0x6C, 0xC3, 0x35, 0x62, 0x02, 0x14, 0x0A, 0x02, 0x00,
+       0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x28, 0x10}
 };
 
 #if 0
-static struct XGI330_LCDCapStruct  XGI660_LCDCapList[] =
-{
+static struct XGI330_LCDCapStruct  XGI660_LCDCapList[] = {
 /* LCDCap1024x768 */
-                {Panel1024x768, DefaultLCDCap, 0, 0x014, 0x88, 0x06, VCLK65,
-               0x6C, 0xC3, 0x35, 0x62, 0x02, 0x14, 0x0A, 0x02, 0x00,
-               0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x28, 0x10},
+       {Panel1024x768, DefaultLCDCap, 0, 0x014, 0x88, 0x06, VCLK65,
+       0x6C, 0xC3, 0x35, 0x62, 0x02, 0x14, 0x0A, 0x02, 0x00,
+       0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x28, 0x10},
 /* LCDCap1280x1024 */
-                {Panel1280x1024, DefaultLCDCap, StLCDBToA, 0x053, 0x70, 0x03, VCLK108_2,
-               0x70, 0x44, 0xF8, 0x2F, 0x02, 0x14, 0x0A, 0x02, 0x00,
-               0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x30, 0x10},
+       {Panel1280x1024, DefaultLCDCap, StLCDBToA, 0x053, 0x70, 0x03, VCLK108_2,
+       0x70, 0x44, 0xF8, 0x2F, 0x02, 0x14, 0x0A, 0x02, 0x00,
+       0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x30, 0x10},
 /* LCDCap1400x1050 */
-                {Panel1400x1050, DefaultLCDCap, StLCDBToA, 0x053, 0x70, 0x03, VCLK108_2,
-                0x70, 0x44, 0xF8, 0x2F, 0x02, 0x14, 0x0A, 0x02, 0x00,
-                0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x30, 0x10},
+       {Panel1400x1050, DefaultLCDCap, StLCDBToA, 0x053, 0x70, 0x03, VCLK108_2,
+        0x70, 0x44, 0xF8, 0x2F, 0x02, 0x14, 0x0A, 0x02, 0x00,
+        0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x30, 0x10},
 /* LCDCap1600x1200 */
-                {Panel1600x1200, DefaultLCDCap, LCDToFull, 0x053, 0xC0, 0x03, VCLK162,
-                0x5A, 0x23, 0x5A, 0x23, 0x02, 0x14, 0x0A, 0x02, 0x00,
-                0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x30, 0x10},
+       {Panel1600x1200, DefaultLCDCap, LCDToFull, 0x053, 0xC0, 0x03, VCLK162,
+        0x5A, 0x23, 0x5A, 0x23, 0x02, 0x14, 0x0A, 0x02, 0x00,
+        0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x30, 0x10},
 /* LCDCap1024x768x75 */
-               {Panel1024x768x75, DefaultLCDCap, 0, 0x014, 0x60, 0, VCLK78_75,
-                0x2B, 0x61, 0x2B, 0x61, 0x02, 0x14, 0x0A, 0x02, 0x00,
-                0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x28, 0x10},
+       {Panel1024x768x75, DefaultLCDCap, 0, 0x014, 0x60, 0, VCLK78_75,
+        0x2B, 0x61, 0x2B, 0x61, 0x02, 0x14, 0x0A, 0x02, 0x00,
+        0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x28, 0x10},
 /* LCDCap1280x1024x75 */
-                {Panel1280x1024x75,+DefaultLCDCap, StLCDBToA, 0x053, 0x90, 0x03, VCLK135_5,
-                0x54, 0x42, 0x4A, 0x61, 0x02, 0x14, 0x0A, 0x02, 0x00,
-                0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x30, 0x10},
+       {Panel1280x1024x75, + DefaultLCDCap, StLCDBToA,
+       0x053, 0x90, 0x03, VCLK135_5,
+        0x54, 0x42, 0x4A, 0x61, 0x02, 0x14, 0x0A, 0x02, 0x00,
+        0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x30, 0x10},
 /* LCDCapDefault */
-                {0xFF, DefaultLCDCap, 0, 0x053, 0x88, 0x06, VCLK65,
-               0x6C, 0xC3, 0x35, 0x62, 0x02, 0x14, 0x0A, 0x02, 0x00,
-               0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x28, 0x10}
+       {0xFF, DefaultLCDCap, 0, 0x053, 0x88, 0x06, VCLK65,
+       0x6C, 0xC3, 0x35, 0x62, 0x02, 0x14, 0x0A, 0x02, 0x00,
+       0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x28, 0x10}
 };
 #endif
 
-static struct XGI330_LCDCapStruct  XGI_LCDCapList[] =
-{
+static struct XGI330_LCDCapStruct  XGI_LCDCapList[] = {
 /* LCDCap1024x768 */
-               {Panel1024x768, DefaultLCDCap, 0, 0x012, 0x88, 0x06, VCLK65,
-               0x6C, 0xC3, 0x35, 0x62, 0x02, 0x14, 0x0A, 0x02, 0x00,
-               0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x28, 0x10},
+       {Panel1024x768, DefaultLCDCap, 0, 0x012, 0x88, 0x06, VCLK65,
+       0x6C, 0xC3, 0x35, 0x62, 0x02, 0x14, 0x0A, 0x02, 0x00,
+       0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x28, 0x10},
 /* LCDCap1280x1024 */
-               {Panel1280x1024, DefaultLCDCap, StLCDBToA, 0x012, 0x70, 0x03, VCLK108_2,
-               0x70, 0x44, 0xF8, 0x2F, 0x02, 0x14, 0x0A, 0x02, 0x00,
-               0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x30, 0x10},
+       {Panel1280x1024, DefaultLCDCap, StLCDBToA,
+       0x012, 0x70, 0x03, VCLK108_2,
+       0x70, 0x44, 0xF8, 0x2F, 0x02, 0x14, 0x0A, 0x02, 0x00,
+       0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x30, 0x10},
 /* LCDCap1400x1050 */
-               {Panel1400x1050, DefaultLCDCap, StLCDBToA, 0x012, 0x70, 0x03, VCLK108_2,
-                0x70, 0x44, 0xF8, 0x2F, 0x02, 0x14, 0x0A, 0x02, 0x00,
-                0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x30, 0x10},
+       {Panel1400x1050, DefaultLCDCap, StLCDBToA,
+       0x012, 0x70, 0x03, VCLK108_2,
+        0x70, 0x44, 0xF8, 0x2F, 0x02, 0x14, 0x0A, 0x02, 0x00,
+        0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x30, 0x10},
 /* LCDCap1600x1200 */
-               {Panel1600x1200, DefaultLCDCap, LCDToFull, 0x012, 0xC0, 0x03, VCLK162,
-                0x5A, 0x23, 0x5A, 0x23, 0x02, 0x14, 0x0A, 0x02, 0x00,
-                0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x30, 0x10},
+       {Panel1600x1200, DefaultLCDCap, LCDToFull,
+       0x012, 0xC0, 0x03, VCLK162,
+        0x5A, 0x23, 0x5A, 0x23, 0x02, 0x14, 0x0A, 0x02, 0x00,
+        0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x30, 0x10},
 /* LCDCap1024x768x75 */
-               {Panel1024x768x75, DefaultLCDCap, 0, 0x012, 0x60, 0, VCLK78_75,
-                0x2B, 0x61, 0x2B, 0x61, 0x02, 0x14, 0x0A, 0x02, 0x00,
-                0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x28, 0x10},
+       {Panel1024x768x75, DefaultLCDCap, 0, 0x012, 0x60, 0, VCLK78_75,
+        0x2B, 0x61, 0x2B, 0x61, 0x02, 0x14, 0x0A, 0x02, 0x00,
+        0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x28, 0x10},
 /* LCDCap1280x1024x75 */
-               {Panel1280x1024x75, DefaultLCDCap, StLCDBToA, 0x012, 0x90, 0x03, VCLK135_5,
-                0x54, 0x42, 0x4A, 0x61, 0x02, 0x14, 0x0A, 0x02, 0x00,
-                0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x30, 0x10},
+       {Panel1280x1024x75, DefaultLCDCap, StLCDBToA,
+       0x012, 0x90, 0x03, VCLK135_5,
+        0x54, 0x42, 0x4A, 0x61, 0x02, 0x14, 0x0A, 0x02, 0x00,
+        0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x30, 0x10},
 /* LCDCapDefault */
-               {0xFF, DefaultLCDCap, 0, 0x012, 0x88, 0x06, VCLK65,
-               0x6C, 0xC3, 0x35, 0x62, 0x02, 0x14, 0x0A, 0x02, 0x00,
-               0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x28, 0x10}
-};
-
-struct XGI21_LVDSCapStruct XGI21_LCDCapList[] =
-{
-    {DisableLCD24bpp + LCDPolarity,
-     2160,1250,1600,1200,  64,  1,  192,   3,
-     0x70,0x24,0x20,0x04,0x0A,0x02,0xC8
-    },
-    {DisableLCD24bpp + LCDPolarity,
-     1688,1066,1280,1024,  48,  1,  112,   3,
-     0x70,0x44,0x20,0x04,0x0A,0x02,0xC8
-    },
-    {DisableLCD24bpp + LCDPolarity + (LCDPolarity << 8),
-     1344, 806,1024, 768,  24,  3,  136,   6,
-     0x6C,0x65,0x20,0x04,0x0A,0x02,0xC8
-    },
-    {DisableLCD24bpp + LCDPolarity,
-     1056, 628, 800, 600,  40,   1, 128,   4,
-     0x42,0xE2,0x20,0x14,0x0A,0x02,0x00
-    },
-    {DisableLCD24bpp + LCDPolarity,
-      928, 525, 800, 480,  40,  13,  48,   3,
-     0x52,0xC5,0x20,0x14,0x0A,0x02,0x00
-    },
-    {DisableLCD24bpp + LCDPolarity + (LCDPolarity << 8),
-      800, 525, 640, 480,  16,  10,  96,   2,
-     0x1B,0xE1,0x20,0x04,0x0A,0x02,0xC8
-    }
-
-};
-
-static struct XGI_Ext2Struct XGI330_RefIndex[] =
-{
-{Support32Bpp + SupportAllCRT2 + SyncPN,                       RES320x200,      VCLK25_175, 0x00,0x10,0x59, 320, 200},/* 00 */
-{Support32Bpp + SupportAllCRT2 + SyncPN,                       RES320x200,      VCLK25_175, 0x00,0x10,0x00, 320, 400},/* 01 */
-{Support32Bpp + SupportAllCRT2 + SyncNN,                       RES320x240,      VCLK25_175, 0x04,0x20,0x50, 320, 240},/* 02 */
-{Support32Bpp + SupportAllCRT2 + SyncPP,                       RES400x300,      VCLK40,     0x05,0x32,0x51, 400, 300},/* 03 */
-{Support32Bpp + NoSupportTV + SyncNN + SupportTV1024,          RES512x384,      VCLK65,     0x06,0x43,0x52, 512, 384},/* 04 */
-{Support32Bpp + SupportAllCRT2 + SyncPN,                       RES640x400,      VCLK25_175, 0x00,0x14,0x2f, 640, 400},/* 05 */
-{Support32Bpp + SupportAllCRT2 + SyncNN,                       RES640x480x60,   VCLK25_175, 0x04,0x24,0x2e, 640, 480},/* 06 640x480x60Hz (LCD 640x480x60z) */
-{Support32Bpp + NoSupportHiVisionTV + SyncNN,                  RES640x480x72,   VCLK31_5,   0x04,0x24,0x2e, 640, 480},/* 07 640x480x72Hz (LCD 640x480x70Hz) */
-{Support32Bpp + NoSupportHiVisionTV + SyncNN,                  RES640x480x75,   VCLK31_5,   0x47,0x24,0x2e, 640, 480},/* 08 640x480x75Hz (LCD 640x480x75Hz) */
-{Support32Bpp + SupportRAMDAC2 + SyncNN,                       RES640x480x85,   VCLK36,     0x8A,0x24,0x2e, 640, 480},/* 09 640x480x85Hz */
-{Support32Bpp + SupportRAMDAC2 + SyncPN,                       RES640x480x100,  VCLK43_163, 0x00,0x24,0x2e, 640, 480},/* 0a 640x480x100Hz */
-{Support32Bpp + SupportRAMDAC2 + SyncPN,                       RES640x480x120,  VCLK52_406, 0x00,0x24,0x2e, 640, 480},/* 0b 640x480x120Hz */
-{Support32Bpp + SupportRAMDAC2 + SyncPN,                       RES640x480x160,  VCLK72_852, 0x00,0x24,0x2e, 640, 480},/* 0c 640x480x160Hz */
-{Support32Bpp + SupportRAMDAC2 + SyncNN,                       RES640x480x200,  VCLK86_6,   0x00,0x24,0x2e, 640, 480},/* 0d 640x480x200Hz */
-{Support32Bpp + NoSupportLCD + SyncPP,                         RES800x600x56,   VCLK36,     0x05,0x36,0x6a, 800, 600},/* 0e 800x600x56Hz */
-{Support32Bpp + NoSupportTV + SyncPP,                          RES800x600x60,   VCLK40,     0x05,0x36,0x6a, 800, 600},/* 0f 800x600x60Hz (LCD 800x600x60Hz) */
-{Support32Bpp + NoSupportHiVisionTV + SyncPP,                  RES800x600x72,   VCLK50,     0x48,0x36,0x6a, 800, 600},/* 10 800x600x72Hz (LCD 800x600x70Hz) */
-{Support32Bpp + NoSupportHiVisionTV + SyncPP,                  RES800x600x75,   VCLK49_5,   0x8B,0x36,0x6a, 800, 600},/* 11 800x600x75Hz (LCD 800x600x75Hz) */
-{Support32Bpp + SupportRAMDAC2 + SyncPP,                       RES800x600x85,   VCLK56_25,  0x00,0x36,0x6a, 800, 600},/* 12 800x600x85Hz */
-{Support32Bpp + SupportRAMDAC2 + SyncPN,                       RES800x600x100,  VCLK68_179, 0x00,0x36,0x6a, 800, 600},/* 13 800x600x100Hz */
-{Support32Bpp + SupportRAMDAC2 + SyncPN,                       RES800x600x120,  VCLK83_95,  0x00,0x36,0x6a, 800, 600},/* 14 800x600x120Hz */
-{Support32Bpp + SupportRAMDAC2 + SyncPN,                       RES800x600x160,  VCLK116_406,0x00,0x36,0x6a, 800, 600},/* 15 800x600x160Hz */
-{Support32Bpp + InterlaceMode + SyncPP,                                RES1024x768x43,  VCLK44_9,   0x00,0x47,0x37,1024, 768},/* 16 1024x768x43Hz */
-{Support32Bpp + NoSupportTV + SyncNN + SupportTV1024,          RES1024x768x60,  VCLK65,     0x06,0x47,0x37,1024, 768},/* 17 1024x768x60Hz (LCD 1024x768x60Hz) */
-{Support32Bpp + NoSupportHiVisionTV + SyncNN,                  RES1024x768x70,  VCLK75,     0x49,0x47,0x37,1024, 768},/* 18 1024x768x70Hz (LCD 1024x768x70Hz) */
-{Support32Bpp + NoSupportHiVisionTV + SyncPP,                  RES1024x768x75,  VCLK78_75,  0x00,0x47,0x37,1024, 768},/* 19 1024x768x75Hz (LCD 1024x768x75Hz) */
-{Support32Bpp + SupportRAMDAC2 + SyncPP,                       RES1024x768x85,  VCLK94_5,   0x8C,0x47,0x37,1024, 768},/* 1a 1024x768x85Hz */
-{Support32Bpp + SupportRAMDAC2 + SyncPN,                       RES1024x768x100, VCLK113_309,0x00,0x47,0x37,1024, 768},/* 1b 1024x768x100Hz */
-{Support32Bpp + SupportRAMDAC2 + SyncPN,                       RES1024x768x120, VCLK139_054,0x00,0x47,0x37,1024, 768},/* 1c 1024x768x120Hz */
-{Support32Bpp + SupportLCD + SyncPP,                           RES1280x960x60,  VCLK108_2,  0x08,0x58,0x7b,1280, 960},/* 1d 1280x960x60Hz */
-{Support32Bpp + InterlaceMode + SyncPP,                                RES1280x1024x43, VCLK78_75,  0x00,0x58,0x3a,1280,1024},/* 1e 1280x1024x43Hz */
-{Support32Bpp + NoSupportTV + SyncPP,                          RES1280x1024x60, VCLK108_2,  0x07,0x58,0x3a,1280,1024},/* 1f 1280x1024x60Hz (LCD 1280x1024x60Hz) */
-{Support32Bpp + NoSupportTV + SyncPP,                          RES1280x1024x75, VCLK135_5,  0x00,0x58,0x3a,1280,1024},/* 20 1280x1024x75Hz (LCD 1280x1024x75Hz) */
-{Support32Bpp + SyncPP,                                                RES1280x1024x85, VCLK157_5,  0x00,0x58,0x3a,1280,1024},/* 21 1280x1024x85Hz */
-{Support32Bpp + SupportLCD + SyncPP + SupportCRT2in301C,       RES1600x1200x60, VCLK162,    0x09,0x7A,0x3c,1600,1200},/* 22 1600x1200x60Hz */
-{Support32Bpp + SyncPP + SupportCRT2in301C,                    RES1600x1200x65, VCLK175,    0x00,0x69,0x3c,1600,1200},/* 23 1600x1200x65Hz */
-{Support32Bpp + SyncPP + SupportCRT2in301C,                    RES1600x1200x70, VCLK189,    0x00,0x69,0x3c,1600,1200},/* 24 1600x1200x70Hz */
-{Support32Bpp + SyncPP + SupportCRT2in301C,                    RES1600x1200x75, VCLK202_5,  0x00,0x69,0x3c,1600,1200},/* 25 1600x1200x75Hz */
-{Support32Bpp + SyncPP,                                                RES1600x1200x85, VCLK229_5,  0x00,0x69,0x3c,1600,1200},/* 26 1600x1200x85Hz */
-{Support32Bpp + SyncPP,                                                RES1600x1200x100,VCLK269_655,0x00,0x69,0x3c,1600,1200},/* 27 1600x1200x100Hz */
-{Support32Bpp + SyncPP,                                                RES1600x1200x120,VCLK323_586,0x00,0x69,0x3c,1600,1200},/* 28 1600x1200x120Hz */
-{Support32Bpp + SupportLCD + SyncNP,                           RES1920x1440x60, VCLK234,    0x00,0x00,0x68,1920,1440},/* 29 1920x1440x60Hz */
-{Support32Bpp + SyncPN,                                                RES1920x1440x65, VCLK254_817,0x00,0x00,0x68,1920,1440},/* 2a 1920x1440x65Hz */
-{Support32Bpp + SyncPN,                                                RES1920x1440x70, VCLK277_015,0x00,0x00,0x68,1920,1440},/* 2b 1920x1440x70Hz */
-{Support32Bpp + SyncPN,                                                RES1920x1440x75, VCLK291_132,0x00,0x00,0x68,1920,1440},/* 2c 1920x1440x75Hz */
-{Support32Bpp + SyncPN,                                                RES1920x1440x85, VCLK330_615,0x00,0x00,0x68,1920,1440},/* 2d 1920x1440x85Hz */
-{Support16Bpp + SyncPN,                                                RES1920x1440x100,VCLK388_631,0x00,0x00,0x68,1920,1440},/* 2e 1920x1440x100Hz */
-{Support32Bpp + SupportLCD + SyncPN,                           RES2048x1536x60, VCLK266_952,0x00,0x00,0x6c,2048,1536},/* 2f 2048x1536x60Hz */
-{Support32Bpp + SyncPN,                                                RES2048x1536x65, VCLK291_766,0x00,0x00,0x6c,2048,1536},/* 30 2048x1536x65Hz */
-{Support32Bpp + SyncPN,                                                RES2048x1536x70, VCLK315_195,0x00,0x00,0x6c,2048,1536},/* 31 2048x1536x70Hz */
-{Support32Bpp + SyncPN,                                                RES2048x1536x75, VCLK340_477,0x00,0x00,0x6c,2048,1536},/* 32 2048x1536x75Hz */
-{Support16Bpp + SyncPN,                                                RES2048x1536x85, VCLK375_847,0x00,0x00,0x6c,2048,1536},/* 33 2048x1536x85Hz */
-{Support32Bpp + SupportHiVisionTV + SupportRAMDAC2 + SyncPP + SupportYPbPr,    RES800x480x60,   VCLK39_77,  0x08,0x00,0x70, 800, 480},/* 34 800x480x60Hz */
-{Support32Bpp + SupportRAMDAC2 + SyncPP,                       RES800x480x75,   VCLK49_5,   0x08,0x00,0x70, 800, 480},/* 35 800x480x75Hz */
-{Support32Bpp + SupportRAMDAC2 + SyncPP,                       RES800x480x85,   VCLK56_25,  0x08,0x00,0x70, 800, 480},/* 36 800x480x85Hz */
-{Support32Bpp + SupportHiVisionTV + SupportRAMDAC2 + SyncPP + SupportYPbPr,    RES1024x576x60,  VCLK65,     0x09,0x00,0x71,1024, 576},/* 37 1024x576x60Hz */
-{Support32Bpp + SupportRAMDAC2 + SyncPP,                       RES1024x576x75,  VCLK78_75,  0x09,0x00,0x71,1024, 576},/* 38 1024x576x75Hz */
-{Support32Bpp + SupportRAMDAC2 + SyncPP,                       RES1024x576x85,  VCLK94_5,   0x09,0x00,0x71,1024, 576},/* 39 1024x576x85Hz */
-{Support32Bpp + SupportHiVisionTV + SupportRAMDAC2 + SyncPP + SupportYPbPr,    RES1280x720x60,  VCLK108_2,  0x0A,0x00,0x75,1280, 720},/* 3a 1280x720x60Hz */
-{Support32Bpp + SupportRAMDAC2 + SyncPP,                       RES1280x720x75,  VCLK135_5,  0x0A,0x00,0x75,1280, 720},/* 3b 1280x720x75Hz */
-{Support32Bpp + SupportRAMDAC2 + SyncPP,                       RES1280x720x85,  VCLK157_5,  0x0A,0x00,0x75,1280, 720},/* 3c 1280x720x85Hz */
-{Support32Bpp + SupportTV + SyncNN,                            RES720x480x60,   VCLK28_322, 0x06,0x00,0x31, 720, 480},/* 3d 720x480x60Hz */
-{Support32Bpp + SupportTV + SyncPP,                            RES720x576x56,   VCLK36,     0x06,0x00,0x32, 720, 576},/* 3e 720x576x56Hz */
-{Support32Bpp + InterlaceMode + NoSupportLCD + SyncPP,         RES856x480x79I,  VCLK35_2,   0x00,0x00,0x00, 856, 480},/* 3f 856x480x79I */
-{Support32Bpp + NoSupportLCD + SyncNN,                         RES856x480x60,   VCLK35_2,   0x00,0x00,0x00, 856, 480},/* 40 856x480x60Hz */
-{Support32Bpp + NoSupportHiVisionTV + SyncPP,                  RES1280x768x60,  VCLK79_411, 0x08,0x48,0x23,1280, 768},/* 41 1280x768x60Hz */
-{Support32Bpp + NoSupportHiVisionTV + SyncPP,                  RES1400x1050x60, VCLK122_61, 0x08,0x69,0x26,1400,1050},/* 42 1400x1050x60Hz */
-{Support32Bpp + SupportRAMDAC2 + SyncPP,                       RES1152x864x60,  VCLK80_350, 0x37,0x00,0x20,1152, 864},/* 43 1152x864x60Hz */
-{Support32Bpp + SupportRAMDAC2 + SyncPP,                       RES1152x864x75,  VCLK107_385,0x37,0x00,0x20,1152, 864},/* 44 1152x864x75Hz */
-{Support32Bpp + SupportLCD + SupportRAMDAC2 + SyncPP,          RES1280x960x75,  VCLK125_999,0x3A,0x88,0x7b,1280, 960},/* 45 1280x960x75Hz */
-{Support32Bpp + SupportLCD + SupportRAMDAC2 + SyncPP,          RES1280x960x85,  VCLK148_5,  0x0A,0x88,0x7b,1280, 960},/* 46 1280x960x85Hz */
-{Support32Bpp + SupportLCD + SupportRAMDAC2 + SyncPP,          RES1280x960x120, VCLK217_325,0x3A,0x88,0x7b,1280, 960},/* 47 1280x960x120Hz */
-{Support32Bpp + SupportRAMDAC2 + SyncPN,                       RES1024x768x160, VCLK139_054,0x30,0x47,0x37,1024, 768},/* 48 1024x768x160Hz */
+       {0xFF, DefaultLCDCap, 0, 0x012, 0x88, 0x06, VCLK65,
+       0x6C, 0xC3, 0x35, 0x62, 0x02, 0x14, 0x0A, 0x02, 0x00,
+       0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x28, 0x10}
+};
+
+struct XGI21_LVDSCapStruct XGI21_LCDCapList[] = {
+       {DisableLCD24bpp + LCDPolarity,
+        2160, 1250, 1600, 1200,   64,    1,  192,    3,
+        0x70, 0x24, 0x20, 0x04, 0x0A, 0x02, 0xC8
+       },
+       {DisableLCD24bpp + LCDPolarity,
+        1688, 1066, 1280, 1024,   48,    1,   112,    3,
+        0x70, 0x44, 0x20, 0x04, 0x0A, 0x02, 0xC8
+       },
+       {DisableLCD24bpp + LCDPolarity + (LCDPolarity << 8),
+        1344,  806, 1024,  768,   24,    3,   136,    6,
+        0x6C, 0x65, 0x20, 0x04, 0x0A, 0x02, 0xC8
+       },
+       {DisableLCD24bpp + LCDPolarity,
+        1056,  628,  800,  600,   40,    1,  128,    4,
+        0x42, 0xE2, 0x20, 0x14, 0x0A, 0x02, 0x00
+       },
+       {DisableLCD24bpp + LCDPolarity,
+         928,  525,  800,  480,   40,   13,   48,    3,
+        0x52, 0xC5, 0x20, 0x14, 0x0A, 0x02, 0x00
+       },
+       {DisableLCD24bpp + LCDPolarity + (LCDPolarity << 8),
+         800,  525,  640,  480,   16,   10,   96,    2,
+        0x1B, 0xE1, 0x20, 0x04, 0x0A, 0x02, 0xC8
+       }
+};
+
+static struct XGI_Ext2Struct XGI330_RefIndex[] = {
+       {Support32Bpp + SupportAllCRT2 + SyncPN, RES320x200, VCLK25_175,
+       0x00, 0x10, 0x59, 320, 200},/* 00 */
+       {Support32Bpp + SupportAllCRT2 + SyncPN, RES320x200, VCLK25_175,
+       0x00, 0x10, 0x00, 320, 400},/* 01 */
+       {Support32Bpp + SupportAllCRT2 + SyncNN, RES320x240, VCLK25_175,
+       0x04, 0x20, 0x50, 320, 240},/* 02 */
+       {Support32Bpp + SupportAllCRT2 + SyncPP, RES400x300, VCLK40,
+       0x05, 0x32, 0x51, 400, 300},/* 03 */
+       {Support32Bpp + NoSupportTV + SyncNN + SupportTV1024, RES512x384,
+       VCLK65, 0x06, 0x43, 0x52, 512, 384},/* 04 */
+       {Support32Bpp + SupportAllCRT2 + SyncPN, RES640x400, VCLK25_175,
+       0x00, 0x14, 0x2f, 640, 400},/* 05 */
+       {Support32Bpp + SupportAllCRT2 + SyncNN, RES640x480x60, VCLK25_175,
+       0x04, 0x24, 0x2e, 640, 480},/* 06 640x480x60Hz (LCD 640x480x60z) */
+       {Support32Bpp + NoSupportHiVisionTV + SyncNN, RES640x480x72, VCLK31_5,
+       0x04, 0x24, 0x2e, 640, 480},/* 07 640x480x72Hz (LCD 640x480x70Hz) */
+       {Support32Bpp + NoSupportHiVisionTV + SyncNN, RES640x480x75, VCLK31_5,
+       0x47, 0x24, 0x2e, 640, 480},/* 08 640x480x75Hz (LCD 640x480x75Hz) */
+       {Support32Bpp + SupportRAMDAC2 + SyncNN, RES640x480x85, VCLK36,
+       0x8A, 0x24, 0x2e, 640, 480},/* 09 640x480x85Hz */
+       {Support32Bpp + SupportRAMDAC2 + SyncPN, RES640x480x100, VCLK43_163,
+       0x00, 0x24, 0x2e, 640, 480},/* 0a 640x480x100Hz */
+       {Support32Bpp + SupportRAMDAC2 + SyncPN, RES640x480x120, VCLK52_406,
+       0x00, 0x24, 0x2e, 640, 480},/* 0b 640x480x120Hz */
+       {Support32Bpp + SupportRAMDAC2 + SyncPN, RES640x480x160, VCLK72_852,
+       0x00, 0x24, 0x2e, 640, 480},/* 0c 640x480x160Hz */
+       {Support32Bpp + SupportRAMDAC2 + SyncNN, RES640x480x200, VCLK86_6,
+       0x00, 0x24, 0x2e, 640, 480},/* 0d 640x480x200Hz */
+       {Support32Bpp + NoSupportLCD + SyncPP, RES800x600x56, VCLK36,
+       0x05, 0x36, 0x6a, 800, 600},/* 0e 800x600x56Hz */
+       {Support32Bpp + NoSupportTV + SyncPP, RES800x600x60, VCLK40,
+       0x05, 0x36, 0x6a, 800, 600},/* 0f 800x600x60Hz (LCD 800x600x60Hz) */
+       {Support32Bpp + NoSupportHiVisionTV + SyncPP, RES800x600x72, VCLK50,
+       0x48, 0x36, 0x6a, 800, 600},/* 10 800x600x72Hz (LCD 800x600x70Hz) */
+       {Support32Bpp + NoSupportHiVisionTV + SyncPP, RES800x600x75, VCLK49_5,
+       0x8B, 0x36, 0x6a, 800, 600},/* 11 800x600x75Hz (LCD 800x600x75Hz) */
+       {Support32Bpp + SupportRAMDAC2 + SyncPP, RES800x600x85, VCLK56_25,
+       0x00, 0x36, 0x6a, 800, 600},/* 12 800x600x85Hz */
+       {Support32Bpp + SupportRAMDAC2 + SyncPN, RES800x600x100, VCLK68_179,
+       0x00, 0x36, 0x6a, 800, 600},/* 13 800x600x100Hz */
+       {Support32Bpp + SupportRAMDAC2 + SyncPN, RES800x600x120, VCLK83_95,
+       0x00, 0x36, 0x6a, 800, 600},/* 14 800x600x120Hz */
+       {Support32Bpp + SupportRAMDAC2 + SyncPN, RES800x600x160, VCLK116_406,
+       0x00, 0x36, 0x6a, 800, 600},/* 15 800x600x160Hz */
+       {Support32Bpp + InterlaceMode + SyncPP, RES1024x768x43, VCLK44_9,
+       0x00, 0x47, 0x37, 1024, 768},/* 16 1024x768x43Hz */
+       /* 17 1024x768x60Hz (LCD 1024x768x60Hz) */
+       {Support32Bpp + NoSupportTV + SyncNN + SupportTV1024, RES1024x768x60,
+       VCLK65, 0x06, 0x47, 0x37, 1024, 768},
+       {Support32Bpp + NoSupportHiVisionTV + SyncNN, RES1024x768x70, VCLK75,
+       0x49, 0x47, 0x37, 1024, 768},/* 18 1024x768x70Hz (LCD 1024x768x70Hz) */
+       {Support32Bpp + NoSupportHiVisionTV + SyncPP, RES1024x768x75, VCLK78_75,
+       0x00, 0x47, 0x37, 1024, 768},/* 19 1024x768x75Hz (LCD 1024x768x75Hz) */
+       {Support32Bpp + SupportRAMDAC2 + SyncPP, RES1024x768x85, VCLK94_5,
+       0x8C, 0x47, 0x37, 1024, 768},/* 1a 1024x768x85Hz */
+       {Support32Bpp + SupportRAMDAC2 + SyncPN, RES1024x768x100, VCLK113_309,
+       0x00, 0x47, 0x37, 1024, 768},/* 1b 1024x768x100Hz */
+       {Support32Bpp + SupportRAMDAC2 + SyncPN, RES1024x768x120, VCLK139_054,
+       0x00, 0x47, 0x37, 1024, 768},/* 1c 1024x768x120Hz */
+       {Support32Bpp + SupportLCD + SyncPP, RES1280x960x60, VCLK108_2,
+       0x08, 0x58, 0x7b, 1280, 960},/* 1d 1280x960x60Hz */
+       {Support32Bpp + InterlaceMode + SyncPP, RES1280x1024x43, VCLK78_75,
+       0x00, 0x58, 0x3a, 1280, 1024},/* 1e 1280x1024x43Hz */
+       {Support32Bpp + NoSupportTV + SyncPP, RES1280x1024x60, VCLK108_2,
+       0x07, 0x58, 0x3a, 1280, 1024},/*1f 1280x1024x60Hz (LCD 1280x1024x60Hz)*/
+       {Support32Bpp + NoSupportTV + SyncPP, RES1280x1024x75, VCLK135_5,
+       0x00, 0x58, 0x3a, 1280, 1024},/*20 1280x1024x75Hz (LCD 1280x1024x75Hz)*/
+       {Support32Bpp + SyncPP, RES1280x1024x85, VCLK157_5,
+       0x00, 0x58, 0x3a, 1280, 1024},/* 21 1280x1024x85Hz */
+       /* 22 1600x1200x60Hz */
+       {Support32Bpp + SupportLCD + SyncPP + SupportCRT2in301C,
+       RES1600x1200x60, VCLK162, 0x09, 0x7A, 0x3c, 1600, 1200},
+       {Support32Bpp + SyncPP + SupportCRT2in301C, RES1600x1200x65, VCLK175,
+       0x00, 0x69, 0x3c, 1600, 1200},/* 23 1600x1200x65Hz */
+       {Support32Bpp + SyncPP + SupportCRT2in301C, RES1600x1200x70, VCLK189,
+       0x00, 0x69, 0x3c, 1600, 1200},/* 24 1600x1200x70Hz */
+       {Support32Bpp + SyncPP + SupportCRT2in301C, RES1600x1200x75, VCLK202_5,
+       0x00, 0x69, 0x3c, 1600, 1200},/* 25 1600x1200x75Hz */
+       {Support32Bpp + SyncPP, RES1600x1200x85, VCLK229_5,
+       0x00, 0x69, 0x3c, 1600, 1200},/* 26 1600x1200x85Hz */
+       {Support32Bpp + SyncPP, RES1600x1200x100, VCLK269_655,
+       0x00, 0x69, 0x3c, 1600, 1200},/* 27 1600x1200x100Hz */
+       {Support32Bpp + SyncPP, RES1600x1200x120, VCLK323_586,
+       0x00, 0x69, 0x3c, 1600, 1200},/* 28 1600x1200x120Hz */
+       {Support32Bpp + SupportLCD + SyncNP, RES1920x1440x60, VCLK234,
+       0x00, 0x00, 0x68, 1920, 1440},/* 29 1920x1440x60Hz */
+       {Support32Bpp + SyncPN, RES1920x1440x65, VCLK254_817,
+       0x00, 0x00, 0x68, 1920, 1440},/* 2a 1920x1440x65Hz */
+       {Support32Bpp + SyncPN, RES1920x1440x70, VCLK277_015,
+       0x00, 0x00, 0x68, 1920, 1440},/* 2b 1920x1440x70Hz */
+       {Support32Bpp + SyncPN, RES1920x1440x75, VCLK291_132,
+       0x00, 0x00, 0x68, 1920, 1440},/* 2c 1920x1440x75Hz */
+       {Support32Bpp + SyncPN, RES1920x1440x85, VCLK330_615,
+       0x00, 0x00, 0x68, 1920, 1440},/* 2d 1920x1440x85Hz */
+       {Support16Bpp + SyncPN, RES1920x1440x100, VCLK388_631,
+       0x00, 0x00, 0x68, 1920, 1440},/* 2e 1920x1440x100Hz */
+       {Support32Bpp + SupportLCD + SyncPN, RES2048x1536x60, VCLK266_952,
+       0x00, 0x00, 0x6c, 2048, 1536},/* 2f 2048x1536x60Hz */
+       {Support32Bpp + SyncPN, RES2048x1536x65, VCLK291_766,
+       0x00, 0x00, 0x6c, 2048, 1536},/* 30 2048x1536x65Hz */
+       {Support32Bpp + SyncPN, RES2048x1536x70, VCLK315_195,
+       0x00, 0x00, 0x6c, 2048, 1536},/* 31 2048x1536x70Hz */
+       {Support32Bpp + SyncPN, RES2048x1536x75, VCLK340_477,
+       0x00, 0x00, 0x6c, 2048, 1536},/* 32 2048x1536x75Hz */
+       {Support16Bpp + SyncPN, RES2048x1536x85, VCLK375_847,
+       0x00, 0x00, 0x6c, 2048, 1536},/* 33 2048x1536x85Hz */
+       {Support32Bpp + SupportHiVisionTV + SupportRAMDAC2 +
+        SyncPP + SupportYPbPr, RES800x480x60, VCLK39_77,
+        0x08, 0x00, 0x70, 800, 480},/* 34 800x480x60Hz */
+       {Support32Bpp + SupportRAMDAC2 + SyncPP, RES800x480x75, VCLK49_5,
+       0x08, 0x00, 0x70, 800, 480},/* 35 800x480x75Hz */
+       {Support32Bpp + SupportRAMDAC2 + SyncPP, RES800x480x85, VCLK56_25,
+       0x08, 0x00, 0x70, 800, 480},/* 36 800x480x85Hz */
+       {Support32Bpp + SupportHiVisionTV + SupportRAMDAC2 +
+        SyncPP + SupportYPbPr, RES1024x576x60, VCLK65,
+        0x09, 0x00, 0x71, 1024, 576},/* 37 1024x576x60Hz */
+       {Support32Bpp + SupportRAMDAC2 + SyncPP, RES1024x576x75, VCLK78_75,
+       0x09, 0x00, 0x71, 1024, 576},/* 38 1024x576x75Hz */
+       {Support32Bpp + SupportRAMDAC2 + SyncPP, RES1024x576x85, VCLK94_5,
+       0x09, 0x00, 0x71, 1024, 576},/* 39 1024x576x85Hz */
+       {Support32Bpp + SupportHiVisionTV + SupportRAMDAC2 +
+       SyncPP + SupportYPbPr, RES1280x720x60, VCLK108_2,
+       0x0A, 0x00, 0x75, 1280, 720},/* 3a 1280x720x60Hz*/
+       {Support32Bpp + SupportRAMDAC2 + SyncPP, RES1280x720x75, VCLK135_5,
+       0x0A, 0x00, 0x75, 1280, 720},/* 3b 1280x720x75Hz */
+       {Support32Bpp + SupportRAMDAC2 + SyncPP, RES1280x720x85, VCLK157_5,
+       0x0A, 0x00, 0x75, 1280, 720},/* 3c 1280x720x85Hz */
+       {Support32Bpp + SupportTV + SyncNN, RES720x480x60, VCLK28_322,
+       0x06, 0x00, 0x31,  720, 480},/* 3d 720x480x60Hz */
+       {Support32Bpp + SupportTV + SyncPP, RES720x576x56, VCLK36,
+       0x06, 0x00, 0x32, 720, 576},/* 3e 720x576x56Hz */
+       {Support32Bpp + InterlaceMode + NoSupportLCD + SyncPP, RES856x480x79I,
+       VCLK35_2, 0x00, 0x00, 0x00,  856, 480},/* 3f 856x480x79I */
+       {Support32Bpp + NoSupportLCD + SyncNN, RES856x480x60, VCLK35_2,
+       0x00, 0x00, 0x00,  856, 480},/* 40 856x480x60Hz */
+       {Support32Bpp + NoSupportHiVisionTV + SyncPP, RES1280x768x60,
+       VCLK79_411, 0x08, 0x48, 0x23, 1280, 768},/* 41 1280x768x60Hz */
+       {Support32Bpp + NoSupportHiVisionTV + SyncPP, RES1400x1050x60,
+       VCLK122_61, 0x08, 0x69, 0x26, 1400, 1050},/* 42 1400x1050x60Hz */
+       {Support32Bpp + SupportRAMDAC2 + SyncPP, RES1152x864x60, VCLK80_350,
+       0x37, 0x00, 0x20, 1152, 864},/* 43 1152x864x60Hz */
+       {Support32Bpp + SupportRAMDAC2 + SyncPP, RES1152x864x75, VCLK107_385,
+       0x37, 0x00, 0x20, 1152, 864},/* 44 1152x864x75Hz */
+       {Support32Bpp + SupportLCD + SupportRAMDAC2 + SyncPP, RES1280x960x75,
+       VCLK125_999, 0x3A, 0x88, 0x7b, 1280, 960},/* 45 1280x960x75Hz */
+       {Support32Bpp + SupportLCD + SupportRAMDAC2 + SyncPP, RES1280x960x85,
+       VCLK148_5, 0x0A, 0x88, 0x7b, 1280, 960},/* 46 1280x960x85Hz */
+       {Support32Bpp + SupportLCD + SupportRAMDAC2 + SyncPP, RES1280x960x120,
+       VCLK217_325, 0x3A, 0x88, 0x7b, 1280, 960},/* 47 1280x960x120Hz */
+       {Support32Bpp + SupportRAMDAC2 + SyncPN, RES1024x768x160, VCLK139_054,
+       0x30, 0x47, 0x37, 1024, 768},/* 48 1024x768x160Hz */
 };
 
 
 #if 0
-static struct XGI330_VCLKDataStruct XGI330_VCLKData[] =
-{
- { 0x1b,0xe1, 25}, /* 0x0 */
- { 0x4e,0xe4, 28}, /* 0x1 */
- { 0x57,0xe4, 31}, /* 0x2 */
- { 0xc3,0xc8, 36}, /* 0x3 */
- { 0x42,0xe2, 40}, /* 0x4 */
- { 0xfe,0xcd, 43}, /* 0x5 */
- { 0x5d,0xc4, 44}, /* 0x6 */
- { 0x52,0xe2, 49}, /* 0x7 */
- { 0x53,0xe2, 50}, /* 0x8 */
- { 0x74,0x67, 52}, /* 0x9 */
- { 0x6d,0x66, 56}, /* 0xa */
- { 0x6c,0xc3, 65}, /* 0xb */
- { 0x46,0x44, 67}, /* 0xc */
- { 0xb1,0x46, 68}, /* 0xd */
- { 0xd3,0x4a, 72}, /* 0xe */
- { 0x29,0x61, 75}, /* 0xf */
- { 0x6e,0x46, 76}, /* 0x10 */
- { 0x2b,0x61, 78}, /* 0x11 */
- { 0x31,0x42, 79}, /* 0x12 */
- { 0xab,0x44, 83}, /* 0x13 */
- { 0x46,0x25, 84}, /* 0x14 */
- { 0x78,0x29, 86}, /* 0x15 */
- { 0x62,0x44, 94}, /* 0x16 */
- { 0x2b,0x41,104}, /* 0x17 */
- { 0x3a,0x23,105}, /* 0x18 */
- { 0x70,0x44,108}, /* 0x19 */
- { 0x3c,0x23,109}, /* 0x1a */
- { 0x5e,0x43,113}, /* 0x1b */
- { 0xbc,0x44,116}, /* 0x1c */
- { 0xe0,0x46,132}, /* 0x1d */
- { 0x54,0x42,135}, /* 0x1e */
- { 0xea,0x2a,139}, /* 0x1f */
- { 0x41,0x22,157}, /* 0x20 */
- { 0x70,0x24,162}, /* 0x21 */
- { 0x30,0x21,175}, /* 0x22 */
- { 0x4e,0x22,189}, /* 0x23 */
- { 0xde,0x26,194}, /* 0x24 */
- { 0x62,0x06,202}, /* 0x25 */
- { 0x3f,0x03,229}, /* 0x26 */
- { 0xb8,0x06,234}, /* 0x27 */
- { 0x34,0x02,253}, /* 0x28 */
- { 0x58,0x04,255}, /* 0x29 */
- { 0x24,0x01,265}, /* 0x2a */
- { 0x9b,0x02,267}, /* 0x2b */
- { 0x70,0x05,270}, /* 0x2c */
- { 0x25,0x01,272}, /* 0x2d */
- { 0x9c,0x02,277}, /* 0x2e */
- { 0x27,0x01,286}, /* 0x2f */
- { 0x3c,0x02,291}, /* 0x30 */
- { 0xef,0x0a,292}, /* 0x31 */
- { 0xf6,0x0a,310}, /* 0x32 */
- { 0x95,0x01,315}, /* 0x33 */
- { 0xf0,0x09,324}, /* 0x34 */
- { 0xfe,0x0a,331}, /* 0x35 */
- { 0xf3,0x09,332}, /* 0x36 */
- { 0xea,0x08,340}, /* 0x37 */
- { 0xe8,0x07,376}, /* 0x38 */
- { 0xde,0x06,389}, /* 0x39 */
- { 0x52,0x2a, 54}, /* 0x3a */
- { 0x52,0x6a, 27}, /* 0x3b */
- { 0x62,0x24, 70}, /* 0x3c */
- { 0x62,0x64, 70}, /* 0x3d */
- { 0xa8,0x4c, 30}, /* 0x3e */
- { 0x20,0x26, 33}, /* 0x3f */
- { 0x31,0xc2, 39}, /* 0x40 */
- { 0x60,0x36, 30}, /* 0x41 */
- { 0x40,0x4A, 28}, /* 0x42 */
- { 0x9F,0x46, 44}, /* 0x43 */
- { 0x97,0x2C, 26}, /* 0x44 */
- { 0x44,0xE4, 25}, /* 0x45 */
- { 0x7E,0x32, 47}, /* 0x46 */
- { 0x08,0x24, 31}, /* 0x47 */
- { 0x97,0x2c, 26}, /* 0x48 */
- { 0xCE,0x3c, 39}, /* 0x49 */
- { 0x52,0x4A, 36}, /* 0x4a */
- { 0x2C,0x61, 95}, /* 0x4b */
- { 0x78,0x27,108}, /* 0x4c */
- { 0x66,0x43,123},  /* 0x4d */
- { 0x2c,0x61, 80},  /* 0x4e */
- { 0x3b,0x61,108}  /* 0x4f */
-};
-
-static struct XGI_VBVCLKDataStruct XGI330_VBVCLKData[] =
-{
- { 0x1b,0xe1, 25}, /* 0x0 */
- { 0x4e,0xe4, 28}, /* 0x1 */
- { 0x57,0xe4, 31}, /* 0x2 */
- { 0xc3,0xc8, 36}, /* 0x3 */
- { 0x42,0x47, 40}, /* 0x4 */
- { 0xfe,0xcd, 43}, /* 0x5 */
- { 0x5d,0xc4, 44}, /* 0x6 */
- { 0x52,0x47, 49}, /* 0x7 */
- { 0x53,0x47, 50}, /* 0x8 */
- { 0x74,0x67, 52}, /* 0x9 */
- { 0x6d,0x66, 56}, /* 0xa */
- { 0x5a,0x64, 65}, /* 0xb */
- { 0x46,0x44, 67}, /* 0xc */
- { 0xb1,0x46, 68}, /* 0xd */
- { 0xd3,0x4a, 72}, /* 0xe */
- { 0x29,0x61, 75}, /* 0xf */
- { 0x6d,0x46, 75}, /* 0x10 */
- { 0x41,0x43, 78}, /* 0x11 */
- { 0x31,0x42, 79}, /* 0x12 */
- { 0xab,0x44, 83}, /* 0x13 */
- { 0x46,0x25, 84}, /* 0x14 */
- { 0x78,0x29, 86}, /* 0x15 */
- { 0x62,0x44, 94}, /* 0x16 */
- { 0x2b,0x22,104}, /* 0x17 */
- { 0x49,0x24,105}, /* 0x18 */
- { 0xf8,0x2f,108}, /* 0x19 */
- { 0x3c,0x23,109}, /* 0x1a */
- { 0x5e,0x43,113}, /* 0x1b */
- { 0xbc,0x44,116}, /* 0x1c */
- { 0xe0,0x46,132}, /* 0x1d */
- { 0xd4,0x28,135}, /* 0x1e */
- { 0xea,0x2a,139}, /* 0x1f */
- { 0x41,0x22,157}, /* 0x20 */
- { 0x70,0x24,162}, /* 0x21 */
- { 0x30,0x21,175}, /* 0x22 */
- { 0x4e,0x22,189}, /* 0x23 */
- { 0xde,0x26,194}, /* 0x24 */
- { 0x70,0x07,202}, /* 0x25 */
- { 0x3f,0x03,229}, /* 0x26 */
- { 0xb8,0x06,234}, /* 0x27 */
- { 0x34,0x02,253}, /* 0x28 */
- { 0x58,0x04,255}, /* 0x29 */
- { 0x24,0x01,265}, /* 0x2a */
- { 0x9b,0x02,267}, /* 0x2b */
- { 0x70,0x05,270}, /* 0x2c */
- { 0x25,0x01,272}, /* 0x2d */
- { 0x9c,0x02,277}, /* 0x2e */
- { 0x27,0x01,286}, /* 0x2f */
- { 0x3c,0x02,291}, /* 0x30 */
- { 0xef,0x0a,292}, /* 0x31 */
- { 0xf6,0x0a,310}, /* 0x32 */
- { 0x95,0x01,315}, /* 0x33 */
- { 0xf0,0x09,324}, /* 0x34 */
- { 0xfe,0x0a,331}, /* 0x35 */
- { 0xf3,0x09,332}, /* 0x36 */
- { 0xea,0x08,340}, /* 0x37 */
- { 0xe8,0x07,376}, /* 0x38 */
- { 0xde,0x06,389}, /* 0x39 */
- { 0x52,0x2a, 54}, /* 0x3a */
- { 0x52,0x6a, 27}, /* 0x3b */
- { 0x62,0x24, 70}, /* 0x3c */
- { 0x62,0x64, 70}, /* 0x3d */
- { 0xa8,0x4c, 30}, /* 0x3e */
- { 0x20,0x26, 33}, /* 0x3f */
- { 0x31,0xc2, 39}, /* 0x40 */
- { 0x2e,0x48, 25}, /* 0x41 */
- { 0x24,0x46, 25}, /* 0x42 */
- { 0x26,0x64, 28}, /* 0x43 */
- { 0x37,0x64, 40}, /* 0x44 */
- { 0xa1,0x42,108}, /* 0x45 */
- { 0x37,0x61,100}, /* 0x46 */
- { 0x78,0x27,108}, /* 0x47 */
- { 0x5e,0x64,68},  /* 0x48 chiawen for fuj1280x768*/
- { 0x70,0x44,108}, /* 0x49 chiawen for 1400x1050*/
+static struct XGI330_VCLKDataStruct XGI330_VCLKData[] = {
+       {0x1b, 0xe1,  25}, /* 0x0 */
+       {0x4e, 0xe4,  28}, /* 0x1 */
+       {0x57, 0xe4,  31}, /* 0x2 */
+       {0xc3, 0xc8,  36}, /* 0x3 */
+       {0x42, 0xe2,  40}, /* 0x4 */
+       {0xfe, 0xcd,  43}, /* 0x5 */
+       {0x5d, 0xc4,  44}, /* 0x6 */
+       {0x52, 0xe2,  49}, /* 0x7 */
+       {0x53, 0xe2,  50}, /* 0x8 */
+       {0x74, 0x67,  52}, /* 0x9 */
+       {0x6d, 0x66,  56}, /* 0xa */
+       {0x6c, 0xc3,  65}, /* 0xb */
+       {0x46, 0x44,  67}, /* 0xc */
+       {0xb1, 0x46,  68}, /* 0xd */
+       {0xd3, 0x4a,  72}, /* 0xe */
+       {0x29, 0x61,  75}, /* 0xf */
+       {0x6e, 0x46,  76}, /* 0x10 */
+       {0x2b, 0x61,  78}, /* 0x11 */
+       {0x31, 0x42,  79}, /* 0x12 */
+       {0xab, 0x44,  83}, /* 0x13 */
+       {0x46, 0x25,  84}, /* 0x14 */
+       {0x78, 0x29,  86}, /* 0x15 */
+       {0x62, 0x44,  94}, /* 0x16 */
+       {0x2b, 0x41, 104}, /* 0x17 */
+       {0x3a, 0x23, 105}, /* 0x18 */
+       {0x70, 0x44, 108}, /* 0x19 */
+       {0x3c, 0x23, 109}, /* 0x1a */
+       {0x5e, 0x43, 113}, /* 0x1b */
+       {0xbc, 0x44, 116}, /* 0x1c */
+       {0xe0, 0x46, 132}, /* 0x1d */
+       {0x54, 0x42, 135}, /* 0x1e */
+       {0xea, 0x2a, 139}, /* 0x1f */
+       {0x41, 0x22, 157}, /* 0x20 */
+       {0x70, 0x24, 162}, /* 0x21 */
+       {0x30, 0x21, 175}, /* 0x22 */
+       {0x4e, 0x22, 189}, /* 0x23 */
+       {0xde, 0x26, 194}, /* 0x24 */
+       {0x62, 0x06, 202}, /* 0x25 */
+       {0x3f, 0x03, 229}, /* 0x26 */
+       {0xb8, 0x06, 234}, /* 0x27 */
+       {0x34, 0x02, 253}, /* 0x28 */
+       {0x58, 0x04, 255}, /* 0x29 */
+       {0x24, 0x01, 265}, /* 0x2a */
+       {0x9b, 0x02, 267}, /* 0x2b */
+       {0x70, 0x05, 270}, /* 0x2c */
+       {0x25, 0x01, 272}, /* 0x2d */
+       {0x9c, 0x02, 277}, /* 0x2e */
+       {0x27, 0x01, 286}, /* 0x2f */
+       {0x3c, 0x02, 291}, /* 0x30 */
+       {0xef, 0x0a, 292}, /* 0x31 */
+       {0xf6, 0x0a, 310}, /* 0x32 */
+       {0x95, 0x01, 315}, /* 0x33 */
+       {0xf0, 0x09, 324}, /* 0x34 */
+       {0xfe, 0x0a, 331}, /* 0x35 */
+       {0xf3, 0x09, 332}, /* 0x36 */
+       {0xea, 0x08, 340}, /* 0x37 */
+       {0xe8, 0x07, 376}, /* 0x38 */
+       {0xde, 0x06, 389}, /* 0x39 */
+       {0x52, 0x2a,  54}, /* 0x3a */
+       {0x52, 0x6a,  27}, /* 0x3b */
+       {0x62, 0x24,  70}, /* 0x3c */
+       {0x62, 0x64,  70}, /* 0x3d */
+       {0xa8, 0x4c,  30}, /* 0x3e */
+       {0x20, 0x26,  33}, /* 0x3f */
+       {0x31, 0xc2,  39}, /* 0x40 */
+       {0x60, 0x36,  30}, /* 0x41 */
+       {0x40, 0x4A,  28}, /* 0x42 */
+       {0x9F, 0x46,  44}, /* 0x43 */
+       {0x97, 0x2C,  26}, /* 0x44 */
+       {0x44, 0xE4,  25}, /* 0x45 */
+       {0x7E, 0x32,  47}, /* 0x46 */
+       {0x08, 0x24,  31}, /* 0x47 */
+       {0x97, 0x2c,  26}, /* 0x48 */
+       {0xCE, 0x3c,  39}, /* 0x49 */
+       {0x52, 0x4A,  36}, /* 0x4a */
+       {0x2C, 0x61,  95}, /* 0x4b */
+       {0x78, 0x27, 108}, /* 0x4c */
+       {0x66, 0x43, 123},  /* 0x4d */
+       {0x2c, 0x61,  80},  /* 0x4e */
+       {0x3b, 0x61, 108}  /* 0x4f */
+};
+
+static struct XGI_VBVCLKDataStruct XGI330_VBVCLKData[] = {
+       {0x1b, 0xe1,  25}, /* 0x0 */
+       {0x4e, 0xe4,  28}, /* 0x1 */
+       {0x57, 0xe4,  31}, /* 0x2 */
+       {0xc3, 0xc8,  36}, /* 0x3 */
+       {0x42, 0x47,  40}, /* 0x4 */
+       {0xfe, 0xcd,  43}, /* 0x5 */
+       {0x5d, 0xc4,  44}, /* 0x6 */
+       {0x52, 0x47,  49}, /* 0x7 */
+       {0x53, 0x47,  50}, /* 0x8 */
+       {0x74, 0x67,  52}, /* 0x9 */
+       {0x6d, 0x66,  56}, /* 0xa */
+       {0x5a, 0x64,  65}, /* 0xb */
+       {0x46, 0x44,  67}, /* 0xc */
+       {0xb1, 0x46,  68}, /* 0xd */
+       {0xd3, 0x4a,  72}, /* 0xe */
+       {0x29, 0x61,  75}, /* 0xf */
+       {0x6d, 0x46,  75}, /* 0x10 */
+       {0x41, 0x43,  78}, /* 0x11 */
+       {0x31, 0x42,  79}, /* 0x12 */
+       {0xab, 0x44,  83}, /* 0x13 */
+       {0x46, 0x25,  84}, /* 0x14 */
+       {0x78, 0x29,  86}, /* 0x15 */
+       {0x62, 0x44,  94}, /* 0x16 */
+       {0x2b, 0x22, 104}, /* 0x17 */
+       {0x49, 0x24, 105}, /* 0x18 */
+       {0xf8, 0x2f, 108}, /* 0x19 */
+       {0x3c, 0x23, 109}, /* 0x1a */
+       {0x5e, 0x43, 113}, /* 0x1b */
+       {0xbc, 0x44, 116}, /* 0x1c */
+       {0xe0, 0x46, 132}, /* 0x1d */
+       {0xd4, 0x28, 135}, /* 0x1e */
+       {0xea, 0x2a, 139}, /* 0x1f */
+       {0x41, 0x22, 157}, /* 0x20 */
+       {0x70, 0x24, 162}, /* 0x21 */
+       {0x30, 0x21, 175}, /* 0x22 */
+       {0x4e, 0x22, 189}, /* 0x23 */
+       {0xde, 0x26, 194}, /* 0x24 */
+       {0x70, 0x07, 202}, /* 0x25 */
+       {0x3f, 0x03, 229}, /* 0x26 */
+       {0xb8, 0x06, 234}, /* 0x27 */
+       {0x34, 0x02, 253}, /* 0x28 */
+       {0x58, 0x04, 255}, /* 0x29 */
+       {0x24, 0x01, 265}, /* 0x2a */
+       {0x9b, 0x02, 267}, /* 0x2b */
+       {0x70, 0x05, 270}, /* 0x2c */
+       {0x25, 0x01, 272}, /* 0x2d */
+       {0x9c, 0x02, 277}, /* 0x2e */
+       {0x27, 0x01, 286}, /* 0x2f */
+       {0x3c, 0x02, 291}, /* 0x30 */
+       {0xef, 0x0a, 292}, /* 0x31 */
+       {0xf6, 0x0a, 310}, /* 0x32 */
+       {0x95, 0x01, 315}, /* 0x33 */
+       {0xf0, 0x09, 324}, /* 0x34 */
+       {0xfe, 0x0a, 331}, /* 0x35 */
+       {0xf3, 0x09, 332}, /* 0x36 */
+       {0xea, 0x08, 340}, /* 0x37 */
+       {0xe8, 0x07, 376}, /* 0x38 */
+       {0xde, 0x06, 389}, /* 0x39 */
+       {0x52, 0x2a,  54}, /* 0x3a */
+       {0x52, 0x6a,  27}, /* 0x3b */
+       {0x62, 0x24,  70}, /* 0x3c */
+       {0x62, 0x64,  70}, /* 0x3d */
+       {0xa8, 0x4c,  30}, /* 0x3e */
+       {0x20, 0x26,  33}, /* 0x3f */
+       {0x31, 0xc2,  39}, /* 0x40 */
+       {0x2e, 0x48,  25}, /* 0x41 */
+       {0x24, 0x46,  25}, /* 0x42 */
+       {0x26, 0x64,  28}, /* 0x43 */
+       {0x37, 0x64,  40}, /* 0x44 */
+       {0xa1, 0x42, 108}, /* 0x45 */
+       {0x37, 0x61, 100}, /* 0x46 */
+       {0x78, 0x27, 108}, /* 0x47 */
+       {0x5e, 0x64, 68},  /* 0x48 chiawen for fuj1280x768*/
+       {0x70, 0x44, 108}, /* 0x49 chiawen for 1400x1050*/
 };
 #endif
 
 static unsigned char XGI330_ScreenOffset[] = {
-                                       0x14, 0x19, 0x20, 0x28, 0x32, 0x40,
-                                       0x50, 0x64, 0x78, 0x80, 0x2d, 0x35,
-                                       0x57, 0x48};
-
-static struct XGI_StResInfoStruct XGI330_StResInfo[] =
-{
- { 640,400},
- { 640,350},
- { 720,400},
- { 720,350},
- { 640,480}
-};
-
-static struct XGI_ModeResInfoStruct XGI330_ModeResInfo[] =
-{
- {  320, 200, 8, 8},
- {  320, 240, 8, 8},
- {  320, 400, 8, 8},
- {  400, 300, 8, 8},
- {  512, 384, 8, 8},
- {  640, 400, 8,16},
- {  640, 480, 8,16},
- {  800, 600, 8,16},
- { 1024, 768, 8,16},
- { 1280,1024, 8,16},
- { 1600,1200, 8,16},
- { 1920,1440, 8,16},
- { 2048,1536, 8,16},
- {  720, 480, 8,16},
- {  720, 576, 8,16},
- { 1280, 960, 8,16},
- {  800, 480, 8,16},
- { 1024, 576, 8,16},
- { 1280, 720, 8,16},
- {  856, 480, 8,16},
- { 1280, 768, 8,16},
- { 1400,1050, 8,16},
- { 1152, 864, 8,16}
+       0x14, 0x19, 0x20, 0x28, 0x32, 0x40,
+       0x50, 0x64, 0x78, 0x80, 0x2d, 0x35,
+       0x57, 0x48
+};
+
+static struct XGI_StResInfoStruct XGI330_StResInfo[] = {
+       {640, 400},
+       {640, 350},
+       {720, 400},
+       {720, 350},
+       {640, 480}
+};
+
+static struct XGI_ModeResInfoStruct XGI330_ModeResInfo[] = {
+       { 320,  200, 8,  8},
+       { 320,  240, 8,  8},
+       { 320,  400, 8,  8},
+       { 400,  300, 8,  8},
+       { 512,  384, 8,  8},
+       { 640,  400, 8, 16},
+       { 640,  480, 8, 16},
+       { 800,  600, 8, 16},
+       {1024,  768, 8, 16},
+       {1280, 1024, 8, 16},
+       {1600, 1200, 8, 16},
+       {1920, 1440, 8, 16},
+       {2048, 1536, 8, 16},
+       { 720,  480, 8, 16},
+       { 720,  576, 8, 16},
+       {1280,  960, 8, 16},
+       { 800,  480, 8, 16},
+       {1024,  576, 8, 16},
+       {1280,  720, 8, 16},
+       { 856,  480, 8, 16},
+       {1280,  768, 8, 16},
+       {1400, 1050, 8, 16},
+       {1152,  864, 8, 16}
 };
 
 static unsigned char XGI330_OutputSelect = 0x40;
@@ -3441,22 +3593,22 @@ static unsigned char XGI330_SR07 = 0x18;
 
 #if 0
 static unsigned char XGI330New_SR15[8][8] = {
-{0x0,0x4,0x60,0x60},
-{0xf,0xf,0xf,0xf},
-{0xba,0xba,0xba,0xba},
-{0xa9,0xa9,0xac,0xac},
-{0xa0,0xa0,0xa0,0xa8},
-{0x0,0x0,0x2,0x2},
-{0x30,0x30,0x40,0x40},
-{0x0,0xa5,0xfb,0xf6}
+       { 0x0,  0x4, 0x60, 0x60},
+       { 0xf,  0xf,  0xf,  0xf},
+       {0xba, 0xba, 0xba, 0xba},
+       {0xa9, 0xa9, 0xac, 0xac},
+       {0xa0, 0xa0, 0xa0, 0xa8},
+       { 0x0,  0x0,  0x2,  0x2},
+       {0x30, 0x30, 0x40, 0x40},
+       { 0x0, 0xa5, 0xfb, 0xf6}
 };
 
 static unsigned char XGI330New_CR40[5][8] = {
-{0x77,0x77,0x44,0x44},
-{0x77,0x77,0x44,0x44},
-{0x0,0x0,0x0,0x0},
-{0x5b,0x5b,0xab,0xab},
-{0x0,0x0,0xf0,0xf8}
+       {0x77, 0x77, 0x44, 0x44},
+       {0x77, 0x77, 0x44, 0x44},
+       { 0x0,  0x0,  0x0,  0x0},
+       {0x5b, 0x5b, 0xab, 0xab},
+       { 0x0,  0x0, 0xf0, 0xf8}
 };
 #endif
 
@@ -3509,7 +3661,9 @@ static unsigned char XG21_CR47 = 0x00 ;
 static unsigned char XG27_CR97 = 0xC1 ;
 static unsigned char XG27_SR36 = 0x30 ;
 static unsigned char XG27_CR8F = 0x0C ;
-static unsigned char XG27_CRD0[] = {0, 0, 0, 0, 0, 0, 0, 0x82, 0x00, 0x66, 0x01, 0x00};
+static unsigned char XG27_CRD0[] = {
+       0, 0, 0, 0, 0, 0, 0, 0x82, 0x00, 0x66, 0x01, 0x00
+};
 static unsigned char XG27_CRDE[] = {0, 0};
 static unsigned char XG27_SR40 = 0x04 ;
 static unsigned char XG27_SR41 = 0x00 ;
@@ -3522,871 +3676,660 @@ static unsigned char XGI330_CHTVVCLKUPAL[] = {0x00};
 
 static unsigned char XGI330_CHTVVCLKOPAL[] = {0x00};
 
-static unsigned char XGI7007_CHTVVCLKUNTSC[] = {CH7007TVVCLK30_2,
-                               CH7007TVVCLK30_2,
-                               CH7007TVVCLK30_2,
-                               CH7007TVVCLK30_2,
-                               CH7007TVVCLK28_1,
-                               CH7007TVVCLK47_8
-                              };
-
-static unsigned char XGI7007_CHTVVCLKONTSC[] = {CH7007TVVCLK26_4,
-                               CH7007TVVCLK26_4,
-                               CH7007TVVCLK26_4,
-                               CH7007TVVCLK26_4,
-                               CH7007TVVCLK24_6,
-                               CH7007TVVCLK43_6
-                              };
-
-static unsigned char XGI7007_CHTVVCLKUPAL[] = {CH7007TVVCLK31_5,
-                              CH7007TVVCLK31_5,
-                              CH7007TVVCLK31_5,
-                              CH7007TVVCLK31_5,
-                              CH7007TVVCLK26_2,
-                              CH7007TVVCLK39
-                             };
-
-static unsigned char XGI7007_CHTVVCLKOPAL[] = {CH7007TVVCLK31_5,
-                              CH7007TVVCLK31_5,
-                              CH7007TVVCLK31_5,
-                              CH7007TVVCLK31_5,
-                              CH7007TVVCLK26_2,
-                              CH7007TVVCLK36
-                             };
-
-static struct XGI330_VCLKDataStruct XGI_CH7007VCLKData[] =
-{
- { 0x60,0x36,30},  /* 0 30.2 MHZ */
- { 0x40,0x4A,28},  /* 1 28.19 MHZ */
- { 0x9F,0x46,44},  /* 2 43.6 MHZ */
- { 0x97,0x2C,26},  /* 3 26.4 MHZ */
- { 0x44,0xE4,25},  /* 4 24.6 MHZ */
- { 0x7E,0x32,47},  /* 5 47.832 MHZ */
- { 0x8A,0x24,31},  /* 6 31.5 MHZ */
- { 0x97,0x2C,26},  /* 7 26.2 MHZ */
- { 0xCE,0x3C,39},  /* 8 39 MHZ   */
- { 0x52,0x4A,36},  /* 9 36 MHZ   */
- { 0xFF,0x00,0 }   /* End mark      */
-};
-
-static struct XGI330_VCLKDataStruct XGI_VCLKData[] =
-{
-                       /* SR2B,SR2C,SR2D */
-               {      0x1B,0xE1,25               },/* 00 (25.175MHz) */
-
-               {      0x4E,0xE4,28               },/* 01 (28.322MHz) */
-
-                {      0x57,0xE4,31               },/* 02 (31.500MHz) */
-
-                {      0xC3,0xC8,36               },/* 03 (36.000MHz) */
-
-                {      0x42,0xE2,40               },/* 04 (40.000MHz) */
-
-                {      0xFE,0xCD,43               },/* 05 (43.163MHz) */
-
-                {      0x5D,0xC4,44               },/* 06 (44.900MHz) */
-
-                {      0x52,0xE2,49               },/* 07 (49.500MHz) */
-
-                {      0x53,0xE2,50               },/* 08 (50.000MHz) */
-
-                {      0x74,0x67,52               },/* 09 (52.406MHz) */
-
-                {      0x6D,0x66,56               },/* 0A (56.250MHz) */
-
-                {      0x6C,0xC3,65               },/* 0B (65.000MHz) */
-
-                {      0x46,0x44,67               },/* 0C (67.765MHz) */
-
-                {      0xB1,0x46,68               },/* 0D (68.179MHz) */
-
-                {      0xD3,0x4A,72               },/* 0E (72.852MHz) */
-
-                {      0x29,0x61,75              },/* 0F (75.000MHz) */
-
-                {      0x6E,0x46,76               },/* 10 (75.800MHz) */
-
-                {      0x2B,0x61,78               },/* 11 (78.750MHz) */
-
-                {      0x31,0x42,79               },/* 12 (79.411MHz) */
-
-                {      0xAB,0x44,83               },/* 13 (83.950MHz) */
-
-                {      0x46,0x25,84               },/* 14 (84.800MHz) */
-
-                {      0x78,0x29,86               },/* 15 (86.600MHz) */
-
-                {      0x62,0x44,94               },/* 16 (94.500MHz) */
-
-                {      0x2B,0x41,104               },/* 17 (104.998MHz) */
-
-                {      0x3A,0x23,105               },/* 18 (105.882MHz) */
-
-                {      0x70,0x44,108               },/* 19 (107.862MHz) */
-
-                {      0x3C,0x23,109               },/* 1A (109.175MHz) */
-
-                {      0x5E,0x43,113              },/* 1B (113.309MHz) */
-
-                {      0xBC,0x44,116              },/* 1C (116.406MHz) */
-
-                {      0xE0,0x46,132              },/* 1D (132.258MHz) */
-
-                {      0x54,0x42,135               },/* 1E (135.500MHz) */
-
-                {      0x9C,0x22,139               },/* 1F (139.275MHz) */
-
-                {      0x41,0x22,157               },/* 20 (157.500MHz) */
-
-                {      0x70,0x24,162               },/* 21 (161.793MHz) */
-
-                {      0x30,0x21,175               },/* 22 (175.000MHz) */
-
-                {      0x4E,0x22,189              },/* 23 (188.520MHz) */
-
-                {      0xDE,0x26,194              },/* 24 (194.400MHz) */
-
-                {      0x62,0x06,202               },/* 25 (202.500MHz) */
-
-                {      0x3F,0x03,229               },/* 26 (229.500MHz) */
-
-                {      0xB8,0x06,234               },/* 27 (233.178MHz) */
-
-                {      0x34,0x02,253               },/* 28 (252.699MHz) */
-
-                {      0x58,0x04,255               },/* 29 (254.817MHz) */
-
-                {      0x24,0x01,265              },/* 2A (265.728MHz) */
-
-                {      0x9B,0x02,267               },/* 2B (266.952MHz) */
-
-                {      0x70,0x05,270               },/* 2C (269.65567MHz) */
-
-                {      0x25,0x01,272               },/* 2D (272.04199MHz) */
-
-                {      0x9C,0x02,277               },/* 2E (277.015MHz) */
-
-                {      0x27,0x01,286               },/* 2F (286.359985MHz) */
-
-                {      0xB3,0x04,291               },/* 30 (291.13266MHz) */
-
-                {      0xBC,0x05,292               },/* 31 (291.766MHz) */
-
-                {      0xF6,0x0A,310               },/* 32 (309.789459MHz) */
-
-                {      0x95,0x01,315               },/* 33 (315.195MHz) */
-
-                {      0xF0,0x09,324               },/* 34 (323.586792MHz) */
-
-                {      0xFE,0x0A,331               },/* 35 (330.615631MHz) */
-
-                {      0xF3,0x09,332              },/* 36 (332.177612MHz) */
-
-                {      0x5E,0x03,340              },/* 37 (340.477MHz) */
-
-                {      0xE8,0x07,376              },/* 38 (375.847504MHz) */
-
-                {      0xDE, 0x06,389             },/* 39 (388.631439MHz) */
-
-                {      0x52,0x2A,54               },/* 3A (54.000MHz) */
-
-                {      0x52,0x6A,27              },/* 3B (27.000MHz) */
-
-                {      0x62,0x24,70               },/* 3C (70.874991MHz) */
-
-                {      0x62,0x64,70               },/* 3D (70.1048912MHz) */
-
-                {      0xA8,0x4C,30               },/* 3E (30.1048912MHz) */
-
-                {      0x20,0x26,33               },/* 3F (33.7499957MHz) */
-
-                {      0x31,0xc2,39               },/* 40 (39.77MHz) */
-
-                {      0x11,0x21,30               },/* 41 (30MHz) }// NTSC 1024X768 */
-
-                {      0x2E,0x48,25               },/* 42 (25.175MHz) }// ScaleLCD */
-
-                {      0x24,0x46,25               },/* 43 (25.175MHz) */
-
-                {      0x26,0x64,28               },/* 44 (28.322MHz) */
-
-                {      0x37,0x64,40               },/* 45 (40.000MHz) */
-
-                {      0xA1,0x42,108               },/* 46 (95.000MHz) }// QVGA */
-
-                {      0x37,0x61,100               },/* 47 (100.00MHz) */
-
-                {      0x78,0x27,108               },/* 48 (108.200MHz) */
-
-                {      0xBF,0xC8,35               },/* 49 (35.2MHz) */
-
-                {      0x66,0x43,123               },/* 4A (122.61Mhz) */
-
-                {      0x2C,0x61,80               },/* 4B (80.350Mhz) */
-
-                {      0x3B,0x61,108               },/* 4C (107.385Mhz) */
-
-
-/*                {      0x60,0x36,30               },// 4D (30.200MHz)   }// No use
-
-                {      0x60,0x36,30               },// 4E (30.200MHz)   }// No use
-
-                {      0x60,0x36,30               },// 4F (30.200MHz)   }// No use
-
-                {      0x60,0x36,30               },// 50 (30.200MHz)   }// CHTV
-
-                {      0x40,0x4A,28               },// 51 (28.190MHz)
-
-                {      0x9F,0x46,44               },// 52 (43.600MHz)
-
-                {      0x97,0x2C,26               },// 53 (26.400MHz)
-
-                {      0x44,0xE4,25               },// 54 (24.600MHz)
-
-                {      0x7E,0x32,47               },// 55 (47.832MHz)
-
-                {      0x8A,0x24,31               },// 56 (31.500MHz)
-
-                {      0x97,0x2C,26               },// 57 (26.200MHz)
-
-                {      0xCE,0x3C,39               },// 58 (39.000MHz)
-
-                {      0x52,0x4A,36               },// 59 (36.000MHz)
-
+static unsigned char XGI7007_CHTVVCLKUNTSC[] = {
+       CH7007TVVCLK30_2,
+       CH7007TVVCLK30_2,
+       CH7007TVVCLK30_2,
+       CH7007TVVCLK30_2,
+       CH7007TVVCLK28_1,
+       CH7007TVVCLK47_8
+};
+
+static unsigned char XGI7007_CHTVVCLKONTSC[] = {
+       CH7007TVVCLK26_4,
+       CH7007TVVCLK26_4,
+       CH7007TVVCLK26_4,
+       CH7007TVVCLK26_4,
+       CH7007TVVCLK24_6,
+       CH7007TVVCLK43_6
+};
+
+static unsigned char XGI7007_CHTVVCLKUPAL[] = {
+       CH7007TVVCLK31_5,
+       CH7007TVVCLK31_5,
+       CH7007TVVCLK31_5,
+       CH7007TVVCLK31_5,
+       CH7007TVVCLK26_2,
+       CH7007TVVCLK39
+};
+
+static unsigned char XGI7007_CHTVVCLKOPAL[] = {
+       CH7007TVVCLK31_5,
+       CH7007TVVCLK31_5,
+       CH7007TVVCLK31_5,
+       CH7007TVVCLK31_5,
+       CH7007TVVCLK26_2,
+       CH7007TVVCLK36
+};
+
+static struct XGI330_VCLKDataStruct XGI_CH7007VCLKData[] = {
+       {0x60, 0x36, 30},  /* 0 30.2 MHZ */
+       {0x40, 0x4A, 28},  /* 1 28.19 MHZ */
+       {0x9F, 0x46, 44},  /* 2 43.6 MHZ */
+       {0x97, 0x2C, 26},  /* 3 26.4 MHZ */
+       {0x44, 0xE4, 25},  /* 4 24.6 MHZ */
+       {0x7E, 0x32, 47},  /* 5 47.832 MHZ */
+       {0x8A, 0x24, 31},  /* 6 31.5 MHZ */
+       {0x97, 0x2C, 26},  /* 7 26.2 MHZ */
+       {0xCE, 0x3C, 39},  /* 8 39 MHZ   */
+       {0x52, 0x4A, 36},  /* 9 36 MHZ   */
+       {0xFF, 0x00,  0}   /* End mark      */
+};
+
+static struct XGI330_VCLKDataStruct XGI_VCLKData[] = {
+       /* SR2B,SR2C,SR2D */
+       {0x1B, 0xE1,  25}, /* 00 (25.175MHz) */
+       {0x4E, 0xE4,  28}, /* 01 (28.322MHz) */
+       {0x57, 0xE4,  31}, /* 02 (31.500MHz) */
+       {0xC3, 0xC8,  36}, /* 03 (36.000MHz) */
+       {0x42, 0xE2,  40}, /* 04 (40.000MHz) */
+       {0xFE, 0xCD,  43}, /* 05 (43.163MHz) */
+       {0x5D, 0xC4,  44}, /* 06 (44.900MHz) */
+       {0x52, 0xE2,  49}, /* 07 (49.500MHz) */
+       {0x53, 0xE2,  50}, /* 08 (50.000MHz) */
+       {0x74, 0x67,  52}, /* 09 (52.406MHz) */
+       {0x6D, 0x66,  56}, /* 0A (56.250MHz) */
+       {0x6C, 0xC3,  65}, /* 0B (65.000MHz) */
+       {0x46, 0x44,  67}, /* 0C (67.765MHz) */
+       {0xB1, 0x46,  68}, /* 0D (68.179MHz) */
+       {0xD3, 0x4A,  72}, /* 0E (72.852MHz) */
+       {0x29, 0x61,  75}, /* 0F (75.000MHz) */
+       {0x6E, 0x46,  76}, /* 10 (75.800MHz) */
+       {0x2B, 0x61,  78}, /* 11 (78.750MHz) */
+       {0x31, 0x42,  79}, /* 12 (79.411MHz) */
+       {0xAB, 0x44,  83}, /* 13 (83.950MHz) */
+       {0x46, 0x25,  84}, /* 14 (84.800MHz) */
+       {0x78, 0x29,  86}, /* 15 (86.600MHz) */
+       {0x62, 0x44,  94}, /* 16 (94.500MHz) */
+       {0x2B, 0x41, 104}, /* 17 (104.998MHz) */
+       {0x3A, 0x23, 105}, /* 18 (105.882MHz) */
+       {0x70, 0x44, 108}, /* 19 (107.862MHz) */
+       {0x3C, 0x23, 109}, /* 1A (109.175MHz) */
+       {0x5E, 0x43, 113}, /* 1B (113.309MHz) */
+       {0xBC, 0x44, 116}, /* 1C (116.406MHz) */
+       {0xE0, 0x46, 132}, /* 1D (132.258MHz) */
+       {0x54, 0x42, 135}, /* 1E (135.500MHz) */
+       {0x9C, 0x22, 139}, /* 1F (139.275MHz) */
+       {0x41, 0x22, 157}, /* 20 (157.500MHz) */
+       {0x70, 0x24, 162}, /* 21 (161.793MHz) */
+       {0x30, 0x21, 175}, /* 22 (175.000MHz) */
+       {0x4E, 0x22, 189}, /* 23 (188.520MHz) */
+       {0xDE, 0x26, 194}, /* 24 (194.400MHz) */
+       {0x62, 0x06, 202}, /* 25 (202.500MHz) */
+       {0x3F, 0x03, 229}, /* 26 (229.500MHz) */
+       {0xB8, 0x06, 234}, /* 27 (233.178MHz) */
+       {0x34, 0x02, 253}, /* 28 (252.699MHz) */
+       {0x58, 0x04, 255}, /* 29 (254.817MHz) */
+       {0x24, 0x01, 265}, /* 2A (265.728MHz) */
+       {0x9B, 0x02, 267}, /* 2B (266.952MHz) */
+       {0x70, 0x05, 270}, /* 2C (269.65567MHz) */
+       {0x25, 0x01, 272}, /* 2D (272.04199MHz) */
+       {0x9C, 0x02, 277}, /* 2E (277.015MHz) */
+       {0x27, 0x01, 286}, /* 2F (286.359985MHz) */
+       {0xB3, 0x04, 291}, /* 30 (291.13266MHz) */
+       {0xBC, 0x05, 292}, /* 31 (291.766MHz) */
+       {0xF6, 0x0A, 310}, /* 32 (309.789459MHz) */
+       {0x95, 0x01, 315}, /* 33 (315.195MHz) */
+       {0xF0, 0x09, 324}, /* 34 (323.586792MHz) */
+       {0xFE, 0x0A, 331}, /* 35 (330.615631MHz) */
+       {0xF3, 0x09, 332}, /* 36 (332.177612MHz) */
+       {0x5E, 0x03, 340}, /* 37 (340.477MHz) */
+       {0xE8, 0x07, 376}, /* 38 (375.847504MHz) */
+       {0xDE, 0x06, 389}, /* 39 (388.631439MHz) */
+       {0x52, 0x2A,  54}, /* 3A (54.000MHz) */
+       {0x52, 0x6A,  27}, /* 3B (27.000MHz) */
+       {0x62, 0x24,  70}, /* 3C (70.874991MHz) */
+       {0x62, 0x64,  70}, /* 3D (70.1048912MHz) */
+       {0xA8, 0x4C,  30}, /* 3E (30.1048912MHz) */
+       {0x20, 0x26,  33}, /* 3F (33.7499957MHz) */
+       {0x31, 0xc2,  39}, /* 40 (39.77MHz) */
+       {0x11, 0x21,  30}, /* 41 (30MHz) }// NTSC 1024X768 */
+       {0x2E, 0x48,  25}, /* 42 (25.175MHz) }// ScaleLCD */
+       {0x24, 0x46,  25}, /* 43 (25.175MHz) */
+       {0x26, 0x64,  28}, /* 44 (28.322MHz) */
+       {0x37, 0x64,  40}, /* 45 (40.000MHz) */
+       {0xA1, 0x42, 108}, /* 46 (95.000MHz) }// QVGA */
+       {0x37, 0x61, 100}, /* 47 (100.00MHz) */
+       {0x78, 0x27, 108}, /* 48 (108.200MHz) */
+       {0xBF, 0xC8,  35}, /* 49 (35.2MHz) */
+       {0x66, 0x43, 123}, /* 4A (122.61Mhz) */
+       {0x2C, 0x61,  80}, /* 4B (80.350Mhz) */
+       {0x3B, 0x61, 108}, /* 4C (107.385Mhz) */
+/*
+       {0x60, 0x36, 30},// 4D (30.200MHz)   }// No use
+       {0x60, 0x36, 30},// 4E (30.200MHz)   }// No use
+       {0x60, 0x36, 30},// 4F (30.200MHz)   }// No use
+       {0x60, 0x36, 30},// 50 (30.200MHz)   }// CHTV
+       {0x40, 0x4A, 28},// 51 (28.190MHz)
+       {0x9F, 0x46, 44},// 52 (43.600MHz)
+       {0x97, 0x2C, 26},// 53 (26.400MHz)
+       {0x44, 0xE4, 25},// 54 (24.600MHz)
+       {0x7E, 0x32, 47},// 55 (47.832MHz)
+       {0x8A, 0x24, 31},// 56 (31.500MHz)
+       {0x97, 0x2C, 26},// 57 (26.200MHz)
+       {0xCE, 0x3C, 39},// 58 (39.000MHz)
+       {0x52, 0x4A, 36},// 59 (36.000MHz)
 */
-               {      0x69,0x61,191              }, /* 4D (190.96MHz ) */
-               {      0x4F,0x22,192              }, /* 4E (192.069MHz) */
-               {      0x28,0x26,322              }, /* 4F (322.273MHz) */
-               {      0x5C,0x6B,27               }, /* 50 (27.74HMz) */
-               {      0x57,0x24,126              }, /* 51 (125.999MHz) */
-               {      0x5C,0x42,148              }, /* 52 (148.5MHz) */
-               {      0x42,0x61,120              }, /* 53 (120.839MHz) */
-               {      0x62,0x61,178              }, /* 54 (178.992MHz) */
-               {      0x59,0x22,217              }, /* 55 (217.325MHz) */
-               {      0x29,0x01,300              }, /* 56 (299.505Mhz) */
-               {      0x52,0x63,74               }, /* 57 (74.25MHz) */
-
-
-                {      0xFF,0x00,0                }/* End mark */
- }  ;
-
-static struct XGI330_VCLKDataStruct XGI_VBVCLKData[] =
-{
-                {      0x1B,0xE1,25               },/* 00 (25.175MHz) */
-
-                {      0x4E,0xE4,28               },/* 01 (28.322MHz) */
-
-                {      0x57,0xE4,31               },/* 02 (31.500MHz) */
-
-                {      0xC3,0xC8,36               },/* 03 (36.000MHz) */
-
-                {      0x42,0x47,40               },/* 04 (40.000MHz) */
-
-                {      0xFE,0xCD,43               },/* 05 (43.163MHz) */
-
-                {      0x5D,0xC4,44               },/* 06 (44.900MHz) */
-
-                {      0x52,0x47,49               },/* 07 (49.500MHz) */
-
-                {      0x53,0x47,50               },/* 08 (50.000MHz) */
-
-                {      0x74,0x67,52               },/* 09 (52.406MHz) */
-
-                {      0x6D,0x66,56               },/* 0A (56.250MHz) */
-
-                {      0x35,0x62,65               },/* 0B (65.000MHz) */
-
-                {      0x46,0x44,67               },/* 0C (67.765MHz) */
-
-                {      0xB1,0x46,68               },/* 0D (68.179MHz) */
-
-                {      0xD3,0x4A,72               },/* 0E (72.852MHz) */
-
-                {      0x29,0x61,75               },/* 0F (75.000MHz) */
-
-                {      0x6D,0x46,75               },/* 10 (75.800MHz) */
-
-                {      0x41,0x43,78               },/* 11 (78.750MHz) */
-
-                {      0x31,0x42,79               },/* 12 (79.411MHz) */
-
-                {      0xAB,0x44,83               },/* 13 (83.950MHz) */
-
-                {      0x46,0x25,84               },/* 14 (84.800MHz) */
-
-                {      0x78,0x29,86               },/* 15 (86.600MHz) */
-
-                {      0x62,0x44,94               },/* 16 (94.500MHz) */
-
-                {      0x2B,0x22,104               },/* 17 (104.998MHz) */
-
-                {      0x49,0x24,105               },/* 18 (105.882MHz) */
-
-                {      0xF8,0x2F,108               },/* 19 (108.279MHz) */
-
-                {      0x3C,0x23,109               },/* 1A (109.175MHz) */
-
-                {      0x5E,0x43,113               },/* 1B (113.309MHz) */
-
-                {      0xBC,0x44,116               },/* 1C (116.406MHz) */
-
-                {      0xE0,0x46,132               },/* 1D (132.258MHz) */
-
-                {      0xD4,0x28,135               },/* 1E (135.220MHz) */
-
-                {      0xEA,0x2A,139               },/* 1F (139.275MHz) */
-
-                {      0x41,0x22,157               },/* 20 (157.500MHz) */
-
-                {      0x70,0x24,162               },/* 21 (161.793MHz) */
-
-                {      0x30,0x21,175               },/* 22 (175.000MHz) */
-
-                {      0x4E,0x22,189               },/* 23 (188.520MHz) */
-
-                {      0xDE,0x26,194               },/* 24 (194.400MHz) */
-
-                {      0x70,0x07,202               },/* 25 (202.500MHz) */
-
-                {      0x3F,0x03,229               },/* 26 (229.500MHz) */
-
-                {      0xB8,0x06,234               },/* 27 (233.178MHz) */
-
-                {      0x34,0x02,253               },/* 28 (252.699997 MHz) */
-
-                {      0x58,0x04,255               },/* 29 (254.817MHz) */
-
-                {      0x24,0x01,265               },/* 2A (265.728MHz) */
-
-                {      0x9B,0x02,267               },/* 2B (266.952MHz) */
-
-                {      0x70,0x05,270               },/* 2C (269.65567 MHz) */
-
-                {      0x25,0x01,272               },/* 2D (272.041992 MHz) */
-
-                {      0x9C,0x02,277               },/* 2E (277.015MHz) */
-
-                {      0x27,0x01,286               },/* 2F (286.359985 MHz) */
-
-                {      0x3C,0x02,291               },/* 30 (291.132660 MHz) */
-
-                {      0xEF,0x0A,292               },/* 31 (291.766MHz) */
-
-                {      0xF6,0x0A,310               },/* 32 (309.789459 MHz) */
-
-                {      0x95,0x01,315               },/* 33 (315.195MHz) */
-
-                {      0xF0,0x09,324               },/* 34 (323.586792 MHz) */
-
-                {      0xFE,0x0A,331               },/* 35 (330.615631 MHz) */
-
-                {      0xF3,0x09,332               },/* 36 (332.177612 MHz) */
-
-                {      0xEA,0x08,340               },/* 37 (340.477MHz) */
-
-                {      0xE8,0x07,376               },/* 38 (375.847504 MHz) */
-
-                {      0xDE,0x06,389               },/* 39 (388.631439 MHz) */
-
-                {      0x52,0x2A,54                },/* 3A (54.000MHz) */
-
-                {      0x52,0x6A,27                },/* 3B (27.000MHz) */
-
-
-                {      0x62,0x24,70                },/* 3C (70.874991MHz) */
-
-
-                {      0x62,0x64,70                },/* 3D (70.1048912MHz) */
-
-                {      0xA8,0x4C,30                },/* 3E (30.1048912MHz) */
-
-                {      0x20,0x26,33                },/* 3F (33.7499957MHz) */
-
-                {      0x31,0xc2,39                },/* 40 (39.77MHz) */
-
-                {      0x11,0x21,30                },/* 41 (30MHz) }// NTSC 1024X768 */
-
-                {      0x2E,0x48,25                },/* 42 (25.175MHz) }// ScaleLCD */
-
-                {      0x24,0x46,25                },/* 43 (25.175MHz) */
-
-                {      0x26,0x64,28                },/* 44 (28.322MHz) */
-
-                {      0x37,0x64,40                },/* 45 (40.000MHz) */
-
-                {      0xA1,0x42,108               },/* 46 (95.000MHz) }// QVGA */
-
-                {      0x37,0x61,100               },/* 47 (100.00MHz) */
-
-                {      0x78,0x27,108               },/* 48 (108.200MHz) */
-
-                {      0xBF,0xC8,35                },/* 49 (35.2MHz) */
-
-                {      0x66,0x43,123               },/* 4A (122.61Mhz) */
-
-                {      0x2C,0x61,80                },/* 4B (80.350Mhz) */
-
-                {      0x3B,0x61,108               },/* 4C (107.385Mhz) */
-
+       {0x69, 0x61, 191}, /* 4D (190.96MHz ) */
+       {0x4F, 0x22, 192}, /* 4E (192.069MHz) */
+       {0x28, 0x26, 322}, /* 4F (322.273MHz) */
+       {0x5C, 0x6B,  27}, /* 50 (27.74HMz) */
+       {0x57, 0x24, 126}, /* 51 (125.999MHz) */
+       {0x5C, 0x42, 148}, /* 52 (148.5MHz) */
+       {0x42, 0x61, 120}, /* 53 (120.839MHz) */
+       {0x62, 0x61, 178}, /* 54 (178.992MHz) */
+       {0x59, 0x22, 217}, /* 55 (217.325MHz) */
+       {0x29, 0x01, 300}, /* 56 (299.505Mhz) */
+       {0x52, 0x63,  74}, /* 57 (74.25MHz) */
+       {0xFF, 0x00,   0}  /* End mark */
+};
+
+static struct XGI330_VCLKDataStruct XGI_VBVCLKData[] = {
+       {0x1B, 0xE1,  25}, /* 00 (25.175MHz) */
+       {0x4E, 0xE4,  28}, /* 01 (28.322MHz) */
+       {0x57, 0xE4,  31}, /* 02 (31.500MHz) */
+       {0xC3, 0xC8,  36}, /* 03 (36.000MHz) */
+       {0x42, 0x47,  40}, /* 04 (40.000MHz) */
+       {0xFE, 0xCD,  43}, /* 05 (43.163MHz) */
+       {0x5D, 0xC4,  44}, /* 06 (44.900MHz) */
+       {0x52, 0x47,  49}, /* 07 (49.500MHz) */
+       {0x53, 0x47,  50}, /* 08 (50.000MHz) */
+       {0x74, 0x67,  52}, /* 09 (52.406MHz) */
+       {0x6D, 0x66,  56}, /* 0A (56.250MHz) */
+       {0x35, 0x62,  65}, /* 0B (65.000MHz) */
+       {0x46, 0x44,  67}, /* 0C (67.765MHz) */
+       {0xB1, 0x46,  68}, /* 0D (68.179MHz) */
+       {0xD3, 0x4A,  72}, /* 0E (72.852MHz) */
+       {0x29, 0x61,  75}, /* 0F (75.000MHz) */
+       {0x6D, 0x46,  75}, /* 10 (75.800MHz) */
+       {0x41, 0x43,  78}, /* 11 (78.750MHz) */
+       {0x31, 0x42,  79}, /* 12 (79.411MHz) */
+       {0xAB, 0x44,  83}, /* 13 (83.950MHz) */
+       {0x46, 0x25,  84}, /* 14 (84.800MHz) */
+       {0x78, 0x29,  86}, /* 15 (86.600MHz) */
+       {0x62, 0x44,  94}, /* 16 (94.500MHz) */
+       {0x2B, 0x22, 104}, /* 17 (104.998MHz) */
+       {0x49, 0x24, 105}, /* 18 (105.882MHz) */
+       {0xF8, 0x2F, 108}, /* 19 (108.279MHz) */
+       {0x3C, 0x23, 109}, /* 1A (109.175MHz) */
+       {0x5E, 0x43, 113}, /* 1B (113.309MHz) */
+       {0xBC, 0x44, 116}, /* 1C (116.406MHz) */
+       {0xE0, 0x46, 132}, /* 1D (132.258MHz) */
+       {0xD4, 0x28, 135}, /* 1E (135.220MHz) */
+       {0xEA, 0x2A, 139}, /* 1F (139.275MHz) */
+       {0x41, 0x22, 157}, /* 20 (157.500MHz) */
+       {0x70, 0x24, 162}, /* 21 (161.793MHz) */
+       {0x30, 0x21, 175}, /* 22 (175.000MHz) */
+       {0x4E, 0x22, 189}, /* 23 (188.520MHz) */
+       {0xDE, 0x26, 194}, /* 24 (194.400MHz) */
+       {0x70, 0x07, 202}, /* 25 (202.500MHz) */
+       {0x3F, 0x03, 229}, /* 26 (229.500MHz) */
+       {0xB8, 0x06, 234}, /* 27 (233.178MHz) */
+       {0x34, 0x02, 253}, /* 28 (252.699997 MHz) */
+       {0x58, 0x04, 255}, /* 29 (254.817MHz) */
+       {0x24, 0x01, 265}, /* 2A (265.728MHz) */
+       {0x9B, 0x02, 267}, /* 2B (266.952MHz) */
+       {0x70, 0x05, 270}, /* 2C (269.65567 MHz) */
+       {0x25, 0x01, 272}, /* 2D (272.041992 MHz) */
+       {0x9C, 0x02, 277}, /* 2E (277.015MHz) */
+       {0x27, 0x01, 286}, /* 2F (286.359985 MHz) */
+       {0x3C, 0x02, 291}, /* 30 (291.132660 MHz) */
+       {0xEF, 0x0A, 292}, /* 31 (291.766MHz) */
+       {0xF6, 0x0A, 310}, /* 32 (309.789459 MHz) */
+       {0x95, 0x01, 315}, /* 33 (315.195MHz) */
+       {0xF0, 0x09, 324}, /* 34 (323.586792 MHz) */
+       {0xFE, 0x0A, 331}, /* 35 (330.615631 MHz) */
+       {0xF3, 0x09, 332}, /* 36 (332.177612 MHz) */
+       {0xEA, 0x08, 340}, /* 37 (340.477MHz) */
+       {0xE8, 0x07, 376}, /* 38 (375.847504 MHz) */
+       {0xDE, 0x06, 389}, /* 39 (388.631439 MHz) */
+       {0x52, 0x2A,  54}, /* 3A (54.000MHz) */
+       {0x52, 0x6A,  27}, /* 3B (27.000MHz) */
+       {0x62, 0x24,  70}, /* 3C (70.874991MHz) */
+       {0x62, 0x64,  70}, /* 3D (70.1048912MHz) */
+       {0xA8, 0x4C,  30}, /* 3E (30.1048912MHz) */
+       {0x20, 0x26,  33}, /* 3F (33.7499957MHz) */
+       {0x31, 0xc2,  39}, /* 40 (39.77MHz) */
+       {0x11, 0x21,  30}, /* 41 (30MHz) }// NTSC 1024X768 */
+       {0x2E, 0x48,  25}, /* 42 (25.175MHz) }// ScaleLCD */
+       {0x24, 0x46,  25}, /* 43 (25.175MHz) */
+       {0x26, 0x64,  28}, /* 44 (28.322MHz) */
+       {0x37, 0x64,  40}, /* 45 (40.000MHz) */
+       {0xA1, 0x42, 108}, /* 46 (95.000MHz) }// QVGA */
+       {0x37, 0x61, 100}, /* 47 (100.00MHz) */
+       {0x78, 0x27, 108}, /* 48 (108.200MHz) */
+       {0xBF, 0xC8, 35 }, /* 49 (35.2MHz) */
+       {0x66, 0x43, 123}, /* 4A (122.61Mhz) */
+       {0x2C, 0x61, 80 }, /* 4B (80.350Mhz) */
+       {0x3B, 0x61, 108}, /* 4C (107.385Mhz) */
 /*
-                {      0x60,0x36,30               },// 4D (30.200MHz)   }// No use
-
-                {      0x60,0x36,30               },// 4E (30.200MHz)   }// No use
-
-                {      0x60,0x36,30               },// 4F (30.200MHz)   }// No use
-
-                {      0x60,0x36,30               },// 50 (30.200MHz)   }// CHTV
-
-                {      0x40,0x4A,28               },// 51 (28.190MHz)
-
-                {      0x9F,0x46,44               },// 52 (43.600MHz)
-
-                {      0x97,0x2C,26               },// 53 (26.400MHz)
-
-                {      0x44,0xE4,25               },// 54 (24.600MHz)
-
-                {      0x7E,0x32,47               },// 55 (47.832MHz)
-
-                {      0x8A,0x24,31               },// 56 (31.500MHz)
-
-                {      0x97,0x2C,26               },// 57 (26.200MHz)
-
-                {      0xCE,0x3C,39               },// 58 (39.000MHz)
-
-                {      0x52,0x4A,36               },// 59 (36.000MHz)
+       {0x60, 0x36, 30}, // 4D (30.200MHz)   }// No use
+       {0x60, 0x36, 30}, // 4E (30.200MHz)   }// No use
+       {0x60, 0x36, 30}, // 4F (30.200MHz)   }// No use
+       {0x60, 0x36, 30}, // 50 (30.200MHz)   }// CHTV
+       {0x40, 0x4A, 28}, // 51 (28.190MHz)
+       {0x9F, 0x46, 44}, // 52 (43.600MHz)
+       {0x97, 0x2C, 26}, // 53 (26.400MHz)
+       {0x44, 0xE4, 25}, // 54 (24.600MHz)
+       {0x7E, 0x32, 47}, // 55 (47.832MHz)
+       {0x8A, 0x24, 31}, // 56 (31.500MHz)
+       {0x97, 0x2C, 26}, // 57 (26.200MHz)
+       {0xCE, 0x3C, 39}, // 58 (39.000MHz)
+       {0x52, 0x4A, 36}, // 59 (36.000MHz)
 */
-               {      0x69,0x61,191              }, /* 4D (190.96MHz ) */
-               {      0x4F,0x22,192              }, /* 4E (192.069MHz) */
-               {      0x28,0x26,322              }, /* 4F (322.273MHz) */
-               {      0x5C,0x6B,27               }, /* 50 (27.74HMz) */
-               {      0x57,0x24,126              }, /* 51 (125.999MHz) */
-               {      0x5C,0x42,148              }, /* 52 (148.5MHz) */
-               {      0x42,0x61,120              }, /* 53 (120.839MHz) */
-               {      0x62,0x61,178              }, /* 54 (178.992MHz) */
-               {      0x59,0x22,217              }, /* 55 (217.325MHz) */
-               {      0x29,0x01,300              }, /* 56 (299.505Mhz) */
-               {      0x52,0x63,74               }, /* 57 (74.25MHz) */
-
-
-                {      0xFF,0x00,0                }      /* End mark */
+       {0x69, 0x61, 191}, /* 4D (190.96MHz ) */
+       {0x4F, 0x22, 192}, /* 4E (192.069MHz) */
+       {0x28, 0x26, 322}, /* 4F (322.273MHz) */
+       {0x5C, 0x6B,  27}, /* 50 (27.74HMz) */
+       {0x57, 0x24, 126}, /* 51 (125.999MHz) */
+       {0x5C, 0x42, 148}, /* 52 (148.5MHz) */
+       {0x42, 0x61, 120}, /* 53 (120.839MHz) */
+       {0x62, 0x61, 178}, /* 54 (178.992MHz) */
+       {0x59, 0x22, 217}, /* 55 (217.325MHz) */
+       {0x29, 0x01, 300}, /* 56 (299.505Mhz) */
+       {0x52, 0x63,  74}, /* 57 (74.25MHz) */
+       {0xFF, 0x00,   0}  /* End mark */
 };
 
 #if 0
-static unsigned char XGI660_TVDelayList[] =
-{
-          0x44,            /* ; 0 ExtNTSCDelay */
-          0x44,            /* ; 1 StNTSCDelay */
-          0x44,            /* ; 2 ExtPALDelay */
-          0x44,            /* ; 3 StPALDelay */
-          0x44,            /* ; 4 ExtHiTVDelay(1080i) */
-          0x44,            /* ; 5 StHiTVDelay(1080i) */
-          0x44,            /* ; 6 ExtYPbPrDelay(525i) */
-          0x44,            /* ; 7 StYPbPrDealy(525i) */
-          0x44,            /* ; 8 ExtYPbPrDelay(525p) */
-          0x44,            /* ; 9 StYPbPrDealy(525p) */
-          0x44,            /* ; A ExtYPbPrDelay(750p) */
-          0x44             /* ; B StYPbPrDealy(750p) */
-};
-
-static unsigned char XGI660_TVDelayList2[] =
-{
-          0x44,           /* ; 0 ExtNTSCDelay */
-          0x44,           /* ; 1 StNTSCDelay */
-          0x44,           /* ; 2 ExtPALDelay */
-          0x44,           /* ; 3 StPALDelay */
-          0x44,           /* ; 4 ExtHiTVDelay */
-          0x44,           /* ; 5 StHiTVDelay */
-          0x44,           /* ; 6 ExtYPbPrDelay(525i) */
-          0x44,           /* ; 7 StYPbPrDealy(525i) */
-          0x44,           /* ; 8 ExtYPbPrDelay(525p) */
-          0x44,           /* ; 9 StYPbPrDealy(525p) */
-          0x44,           /* ; A ExtYPbPrDelay(750p) */
-          0x44            /* ; B StYPbPrDealy(750p) */
+static unsigned char XGI660_TVDelayList[] = {
+       0x44, /* ; 0 ExtNTSCDelay */
+       0x44, /* ; 1 StNTSCDelay */
+       0x44, /* ; 2 ExtPALDelay */
+       0x44, /* ; 3 StPALDelay */
+       0x44, /* ; 4 ExtHiTVDelay(1080i) */
+       0x44, /* ; 5 StHiTVDelay(1080i) */
+       0x44, /* ; 6 ExtYPbPrDelay(525i) */
+       0x44, /* ; 7 StYPbPrDealy(525i) */
+       0x44, /* ; 8 ExtYPbPrDelay(525p) */
+       0x44, /* ; 9 StYPbPrDealy(525p) */
+       0x44, /* ; A ExtYPbPrDelay(750p) */
+       0x44  /* ; B StYPbPrDealy(750p) */
+};
+
+static unsigned char XGI660_TVDelayList2[] = {
+       0x44, /* ; 0 ExtNTSCDelay */
+       0x44, /* ; 1 StNTSCDelay */
+       0x44, /* ; 2 ExtPALDelay */
+       0x44, /* ; 3 StPALDelay */
+       0x44, /* ; 4 ExtHiTVDelay */
+       0x44, /* ; 5 StHiTVDelay */
+       0x44, /* ; 6 ExtYPbPrDelay(525i) */
+       0x44, /* ; 7 StYPbPrDealy(525i) */
+       0x44, /* ; 8 ExtYPbPrDelay(525p) */
+       0x44, /* ; 9 StYPbPrDealy(525p) */
+       0x44, /* ; A ExtYPbPrDelay(750p) */
+       0x44  /* ; B StYPbPrDealy(750p) */
 };
 #endif
 
-static unsigned char XGI301TVDelayList[] =
-{
-       0x22,            /* ; 0 ExtNTSCDelay */
-       0x22,            /* ; 1 StNTSCDelay */
-       0x22,            /* ; 2 ExtPALDelay */
-       0x22,            /* ; 3 StPALDelay */
-       0x88,            /* ; 4 ExtHiTVDelay(1080i) */
-       0xBB,            /* ; 5 StHiTVDelay(1080i) */
-       0x22,            /* ; 6 ExtYPbPrDelay(525i) */
-       0x22,            /* ; 7 StYPbPrDealy(525i) */
-       0x22,            /* ; 8 ExtYPbPrDelay(525p) */
-       0x22,            /* ; 9 StYPbPrDealy(525p) */
-       0x22,            /* ; A ExtYPbPrDelay(750p) */
-       0x22            /* B StYPbPrDealy(750p) */
-};
-
-static unsigned char XGI301TVDelayList2[] =
-{
-       0x22,           /* ; 0 ExtNTSCDelay */
-       0x22,           /* ; 1 StNTSCDelay */
-       0x22,           /* ; 2 ExtPALDelay */
-       0x22,           /* ; 3 StPALDelay */
-       0x22,           /* ; 4 ExtHiTVDelay */
-       0x22,           /* ; 5 StHiTVDelay */
-       0x22,           /* ; 6 ExtYPbPrDelay(525i) */
-       0x22,           /* ; 7 StYPbPrDealy(525i) */
-       0x22,           /* ; 8 ExtYPbPrDelay(525p) */
-       0x22,           /* ; 9 StYPbPrDealy(525p) */
-       0x22,           /* ; A ExtYPbPrDelay(750p) */
-       0x22            /* ; B StYPbPrDealy(750p) */
-};
-
-
-static unsigned char TVAntiFlickList[] =
-{/* NTSCAntiFlicker */
-                      0x04,           /* ; 0 Adaptive */
-                      0x00,           /* ; 1 new anti-flicker ? */
-/* PALAntiFlicker */
-                      0x04,           /* ; 0 Adaptive */
-                      0x08,           /* ; 1 new anti-flicker ? */
-/* HiTVAntiFlicker */
-                      0x04,           /* ; 0 ? */
-                      0x00            /* ; 1 new anti-flicker ? */
-};
-
-
-static unsigned char TVEdgeList[] =
-{
-      0x00,            /* ; 0 NTSC No Edge enhance */
-      0x04,            /* ; 1 NTSC Adaptive Edge enhance */
-      0x00,            /* ; 0 PAL No Edge enhance */
-      0x04,            /* ; 1 PAL Adaptive Edge enhance */
-      0x00,            /* ; 0 HiTV */
-      0x00             /* ; 1 HiTV */
-};
-
-static unsigned long TVPhaseList[] =
-{      0x08BAED21, /* ; 0 NTSC phase */
-       0x00E3052A, /* ; 1 PAL phase */
-       0x9B2EE421, /* ; 2 PAL-M phase */
-       0xBA3EF421, /* ; 3 PAL-N phase */
-       0xA7A28B1E, /* ; 4 NTSC 1024x768 */
-       0xE00A831E, /* ; 5 PAL-M 1024x768 */
-       0x00000000, /* ; 6 reserved */
-       0x00000000, /* ; 7 reserved */
-       0xD67BF021, /* ; 8 NTSC phase */
-       0xE986092A, /* ; 9 PAL phase */
-       0xA4EFE621, /* ; A PAL-M phase */
-       0x4694F621, /* ; B PAL-N phase */
-       0x8BDE711C, /* ; C NTSC 1024x768 */
-       0xE00A831E  /* ; D PAL-M 1024x768 */
-};
-
-static unsigned char NTSCYFilter1[] =
-{
-                     0x00,0xF4,0x10,0x38     ,/* 0 : 320x text mode */
-                      0x00,0xF4,0x10,0x38     ,/* 1 : 360x text mode */
-                      0xEB,0x04,0x25,0x18     ,/* 2 : 640x text mode */
-                      0xF1,0x04,0x1F,0x18     ,/* 3 : 720x text mode */
-                      0x00,0xF4,0x10,0x38     ,/* 4 : 320x gra. mode */
-                      0xEB,0x04,0x25,0x18     ,/* 5 : 640x gra. mode */
-                      0xEB,0x15,0x25,0xF6     /* 6 : 800x gra. mode */
-};
-
-static unsigned char PALYFilter1[] =
-{
-                     0x00,0xF4,0x10,0x38, /* 0 : 320x text mode */
-                      0x00,0xF4,0x10,0x38     ,/* 1 : 360x text mode */
-                      0xF1,0xF7,0x1F,0x32     ,/* 2 : 640x text mode */
-                      0xF3,0x00,0x1D,0x20     ,/* 3 : 720x text mode */
-                      0x00,0xF4,0x10,0x38     ,/* 4 : 320x gra. mode */
-                      0xF1,0xF7,0x1F,0x32     ,/* 5 : 640x gra. mode */
-                      0xFC,0xFB,0x14,0x2A     /* 6 : 800x gra. mode */
-};
-
-static unsigned char PALMYFilter1[] =
-{
-                     0x00,0xF4,0x10,0x38, /* 0 : 320x text mode */
-                      0x00,0xF4,0x10,0x38, /* 1 : 360x text mode */
-                      0xEB,0x04,0x10,0x18, /* 2 : 640x text mode */
-                      0xF7,0x06,0x19,0x14, /* 3 : 720x text mode */
-                      0x00,0xF4,0x10,0x38, /* 4 : 320x gra. mode */
-                      0xEB,0x04,0x25,0x18, /* 5 : 640x gra. mode */
-                      0xEB,0x15,0x25,0xF6, /* 6 : 800x gra. mode */
-                      0xFF,0xFF,0xFF,0xFF  /* End of Table */
-};
-
-static unsigned char PALNYFilter1[] =
-{
-                     0x00,0xF4,0x10,0x38, /* 0 : 320x text mode */
-                      0x00,0xF4,0x10,0x38, /* 1 : 360x text mode */
-                      0xEB,0x04,0x10,0x18, /* 2 : 640x text mode */
-                      0xF7,0x06,0x19,0x14, /* 3 : 720x text mode */
-                      0x00,0xF4,0x10,0x38, /* 4 : 320x gra. mode */
-                      0xEB,0x04,0x25,0x18, /* 5 : 640x gra. mode */
-                      0xEB,0x15,0x25,0xF6, /* 6 : 800x gra. mode */
-                      0xFF,0xFF,0xFF,0xFF  /* End of Table */
-};
-
-static unsigned char NTSCYFilter2[] =
-{
-                     0xFF,0x03,0x02,0xF6,0xFC,0x27,0x46, /* 0 : 320x text mode */
-                      0x01,0x02,0xFE,0xF7,0x03,0x27,0x3C, /* 1 : 360x text mode */
-                      0xFF,0x03,0x02,0xF6,0xFC,0x27,0x46, /* 2 : 640x text mode */
-                      0x01,0x02,0xFE,0xF7,0x03,0x27,0x3C, /* 3 : 720x text mode */
-                      0xFF,0x03,0x02,0xF6,0xFC,0x27,0x46, /* 4 : 320x gra. mode */
-                      0xFF,0x03,0x02,0xF6,0xFC,0x27,0x46, /* 5 : 640x gra. mode */
-                      0x01,0x01,0xFC,0xF8,0x08,0x26,0x38, /* 6 : 800x gra. mode */
-                      0xFF,0xFF,0xFC,0x00,0x0F,0x22,0x28  /* 7 : 1024xgra. mode */
-};
-
-static unsigned char PALYFilter2[] =
-{
-                     0xFF,0x03,0x02,0xF6,0xFC,0x27,0x46, /* 0 : 320x text mode */
-                      0x01,0x02,0xFE,0xF7,0x03,0x27,0x3C, /* 1 : 360x text mode */
-                      0xFF,0x03,0x02,0xF6,0xFC,0x27,0x46, /* 2 : 640x text mode */
-                      0x01,0x02,0xFE,0xF7,0x03,0x27,0x3C, /* 3 : 720x text mode */
-                      0xFF,0x03,0x02,0xF6,0xFC,0x27,0x46, /* 4 : 320x gra. mode */
-                      0xFF,0x03,0x02,0xF6,0xFC,0x27,0x46, /* 5 : 640x gra. mode */
-                      0x01,0x01,0xFC,0xF8,0x08,0x26,0x38, /* 6 : 800x gra. mode */
-                      0xFF,0xFF,0xFC,0x00,0x0F,0x22,0x28  /* 7 : 1024xgra. mode */
-};
-
-static unsigned char PALMYFilter2[] =
-{
-                     0xFF,0x03,0x02,0xF6,0xFC,0x27,0x46, /* 0 : 320x text mode */
-                      0x01,0x02,0xFE,0xF7,0x03,0x27,0x3C, /* 1 : 360x text mode */
-                      0xFF,0x03,0x02,0xF6,0xFC,0x27,0x46, /* 2 : 640x text mode */
-                      0x01,0x02,0xFE,0xF7,0x03,0x27,0x3C, /* 3 : 720x text mode */
-                      0xFF,0x03,0x02,0xF6,0xFC,0x27,0x46, /* 4 : 320x gra. mode */
-                      0xFF,0x03,0x02,0xF6,0xFC,0x27,0x46, /* 5 : 640x gra. mode */
-                      0x01,0x01,0xFC,0xF8,0x08,0x26,0x38, /* 6 : 800x gra. mode */
-                      0xFF,0xFF,0xFC,0x00,0x0F,0x22,0x28  /* 7 : 1024xgra. mode */
-};
-
-static unsigned char PALNYFilter2[] =
-{
-                     0xFF,0x03,0x02,0xF6,0xFC,0x27,0x46, /* 0 : 320x text mode */
-                      0x01,0x02,0xFE,0xF7,0x03,0x27,0x3C, /* 1 : 360x text mode */
-                      0xFF,0x03,0x02,0xF6,0xFC,0x27,0x46, /* 2 : 640x text mode */
-                      0x01,0x02,0xFE,0xF7,0x03,0x27,0x3C, /* 3 : 720x text mode */
-                      0xFF,0x03,0x02,0xF6,0xFC,0x27,0x46, /* 4 : 320x gra. mode */
-                      0xFF,0x03,0x02,0xF6,0xFC,0x27,0x46, /* 5 : 640x gra. mode */
-                      0x01,0x01,0xFC,0xF8,0x08,0x26,0x38, /* 6 : 800x gra. mode */
-                      0xFF,0xFF,0xFC,0x00,0x0F,0x22,0x28  /* 7 : 1024xgra. mode */
-};
-
-static unsigned char XGI_NTSC1024AdjTime[] =
-{
-      0xa7,0x07,0xf2,0x6e,0x17,0x8b,0x73,0x53,
-      0x13,0x40,0x34,0xF4,0x63,0xBB,0xCC,0x7A,
-      0x58,0xe4,0x73,0xd0,0x13
-};
-
-static struct XGI301C_Tap4TimingStruct HiTVTap4Timing[] =
-{
-       {0,{
-       0x00,0x20,0x00,0x00,0x7F,0x20,0x02,0x7F, /* ; C0-C7 */
-       0x7D,0x20,0x04,0x7F,0x7D,0x1F,0x06,0x7E, /* ; C8-CF */
-       0x7C,0x1D,0x09,0x7E,0x7C,0x1B,0x0B,0x7E, /* ; D0-D7 */
-       0x7C,0x19,0x0E,0x7D,0x7C,0x17,0x11,0x7C, /* ; D8-DF */
-       0x7C,0x14,0x14,0x7C,0x7C,0x11,0x17,0x7C, /* ; E0-E7 */
-       0x7D,0x0E,0x19,0x7C,0x7E,0x0B,0x1B,0x7C, /* ; EA-EF */
-       0x7E,0x09,0x1D,0x7C,0x7F,0x06,0x1F,0x7C, /* ; F0-F7 */
-       0x7F,0x04,0x20,0x7D,0x00,0x02,0x20,0x7E  /* ; F8-FF */
+static unsigned char XGI301TVDelayList[] = {
+       0x22, /* ; 0 ExtNTSCDelay */
+       0x22, /* ; 1 StNTSCDelay */
+       0x22, /* ; 2 ExtPALDelay */
+       0x22, /* ; 3 StPALDelay */
+       0x88, /* ; 4 ExtHiTVDelay(1080i) */
+       0xBB, /* ; 5 StHiTVDelay(1080i) */
+       0x22, /* ; 6 ExtYPbPrDelay(525i) */
+       0x22, /* ; 7 StYPbPrDealy(525i) */
+       0x22, /* ; 8 ExtYPbPrDelay(525p) */
+       0x22, /* ; 9 StYPbPrDealy(525p) */
+       0x22, /* ; A ExtYPbPrDelay(750p) */
+       0x22  /* B StYPbPrDealy(750p) */
+};
+
+static unsigned char XGI301TVDelayList2[] = {
+       0x22, /* ; 0 ExtNTSCDelay */
+       0x22, /* ; 1 StNTSCDelay */
+       0x22, /* ; 2 ExtPALDelay */
+       0x22, /* ; 3 StPALDelay */
+       0x22, /* ; 4 ExtHiTVDelay */
+       0x22, /* ; 5 StHiTVDelay */
+       0x22, /* ; 6 ExtYPbPrDelay(525i) */
+       0x22, /* ; 7 StYPbPrDealy(525i) */
+       0x22, /* ; 8 ExtYPbPrDelay(525p) */
+       0x22, /* ; 9 StYPbPrDealy(525p) */
+       0x22, /* ; A ExtYPbPrDelay(750p) */
+       0x22  /* ; B StYPbPrDealy(750p) */
+};
+
+
+static unsigned char TVAntiFlickList[] = {/* NTSCAntiFlicker */
+       0x04, /* ; 0 Adaptive */
+       0x00, /* ; 1 new anti-flicker ? */
+
+       0x04, /* ; 0 Adaptive */
+       0x08, /* ; 1 new anti-flicker ? */
+
+       0x04, /* ; 0 ? */
+       0x00  /* ; 1 new anti-flicker ? */
+};
+
+
+static unsigned char TVEdgeList[] = {
+       0x00, /* ; 0 NTSC No Edge enhance */
+       0x04, /* ; 1 NTSC Adaptive Edge enhance */
+       0x00, /* ; 0 PAL No Edge enhance */
+       0x04, /* ; 1 PAL Adaptive Edge enhance */
+       0x00, /* ; 0 HiTV */
+       0x00  /* ; 1 HiTV */
+};
+
+static unsigned long TVPhaseList[] = {
+       0x08BAED21, /* ; 0 NTSC phase */
+       0x00E3052A, /* ; 1 PAL phase */
+       0x9B2EE421, /* ; 2 PAL-M phase */
+       0xBA3EF421, /* ; 3 PAL-N phase */
+       0xA7A28B1E, /* ; 4 NTSC 1024x768 */
+       0xE00A831E, /* ; 5 PAL-M 1024x768 */
+       0x00000000, /* ; 6 reserved */
+       0x00000000, /* ; 7 reserved */
+       0xD67BF021, /* ; 8 NTSC phase */
+       0xE986092A, /* ; 9 PAL phase */
+       0xA4EFE621, /* ; A PAL-M phase */
+       0x4694F621, /* ; B PAL-N phase */
+       0x8BDE711C, /* ; C NTSC 1024x768 */
+       0xE00A831E  /* ; D PAL-M 1024x768 */
+};
+
+static unsigned char NTSCYFilter1[] = {
+       0x00, 0xF4, 0x10, 0x38, /* 0 : 320x text mode */
+       0x00, 0xF4, 0x10, 0x38, /* 1 : 360x text mode */
+       0xEB, 0x04, 0x25, 0x18, /* 2 : 640x text mode */
+       0xF1, 0x04, 0x1F, 0x18, /* 3 : 720x text mode */
+       0x00, 0xF4, 0x10, 0x38, /* 4 : 320x gra. mode */
+       0xEB, 0x04, 0x25, 0x18, /* 5 : 640x gra. mode */
+       0xEB, 0x15, 0x25, 0xF6  /* 6 : 800x gra. mode */
+};
+
+static unsigned char PALYFilter1[] = {
+       0x00, 0xF4, 0x10, 0x38, /* 0 : 320x text mode */
+       0x00, 0xF4, 0x10, 0x38, /* 1 : 360x text mode */
+       0xF1, 0xF7, 0x1F, 0x32, /* 2 : 640x text mode */
+       0xF3, 0x00, 0x1D, 0x20, /* 3 : 720x text mode */
+       0x00, 0xF4, 0x10, 0x38, /* 4 : 320x gra. mode */
+       0xF1, 0xF7, 0x1F, 0x32, /* 5 : 640x gra. mode */
+       0xFC, 0xFB, 0x14, 0x2A  /* 6 : 800x gra. mode */
+};
+
+static unsigned char PALMYFilter1[] = {
+       0x00, 0xF4, 0x10, 0x38, /* 0 : 320x text mode */
+       0x00, 0xF4, 0x10, 0x38, /* 1 : 360x text mode */
+       0xEB, 0x04, 0x10, 0x18, /* 2 : 640x text mode */
+       0xF7, 0x06, 0x19, 0x14, /* 3 : 720x text mode */
+       0x00, 0xF4, 0x10, 0x38, /* 4 : 320x gra. mode */
+       0xEB, 0x04, 0x25, 0x18, /* 5 : 640x gra. mode */
+       0xEB, 0x15, 0x25, 0xF6, /* 6 : 800x gra. mode */
+       0xFF, 0xFF, 0xFF, 0xFF  /* End of Table */
+};
+
+static unsigned char PALNYFilter1[] = {
+       0x00, 0xF4, 0x10, 0x38, /* 0 : 320x text mode */
+       0x00, 0xF4, 0x10, 0x38, /* 1 : 360x text mode */
+       0xEB, 0x04, 0x10, 0x18, /* 2 : 640x text mode */
+       0xF7, 0x06, 0x19, 0x14, /* 3 : 720x text mode */
+       0x00, 0xF4, 0x10, 0x38, /* 4 : 320x gra. mode */
+       0xEB, 0x04, 0x25, 0x18, /* 5 : 640x gra. mode */
+       0xEB, 0x15, 0x25, 0xF6, /* 6 : 800x gra. mode */
+       0xFF, 0xFF, 0xFF, 0xFF  /* End of Table */
+};
+
+static unsigned char NTSCYFilter2[] = {
+       0xFF, 0x03, 0x02, 0xF6, 0xFC, 0x27, 0x46, /* 0 : 320x text mode */
+       0x01, 0x02, 0xFE, 0xF7, 0x03, 0x27, 0x3C, /* 1 : 360x text mode */
+       0xFF, 0x03, 0x02, 0xF6, 0xFC, 0x27, 0x46, /* 2 : 640x text mode */
+       0x01, 0x02, 0xFE, 0xF7, 0x03, 0x27, 0x3C, /* 3 : 720x text mode */
+       0xFF, 0x03, 0x02, 0xF6, 0xFC, 0x27, 0x46, /* 4 : 320x gra. mode */
+       0xFF, 0x03, 0x02, 0xF6, 0xFC, 0x27, 0x46, /* 5 : 640x gra. mode */
+       0x01, 0x01, 0xFC, 0xF8, 0x08, 0x26, 0x38, /* 6 : 800x gra. mode */
+       0xFF, 0xFF, 0xFC, 0x00, 0x0F, 0x22, 0x28  /* 7 : 1024xgra. mode */
+};
+
+static unsigned char PALYFilter2[] = {
+       0xFF, 0x03, 0x02, 0xF6, 0xFC, 0x27, 0x46, /* 0 : 320x text mode */
+       0x01, 0x02, 0xFE, 0xF7, 0x03, 0x27, 0x3C, /* 1 : 360x text mode */
+       0xFF, 0x03, 0x02, 0xF6, 0xFC, 0x27, 0x46, /* 2 : 640x text mode */
+       0x01, 0x02, 0xFE, 0xF7, 0x03, 0x27, 0x3C, /* 3 : 720x text mode */
+       0xFF, 0x03, 0x02, 0xF6, 0xFC, 0x27, 0x46, /* 4 : 320x gra. mode */
+       0xFF, 0x03, 0x02, 0xF6, 0xFC, 0x27, 0x46, /* 5 : 640x gra. mode */
+       0x01, 0x01, 0xFC, 0xF8, 0x08, 0x26, 0x38, /* 6 : 800x gra. mode */
+       0xFF, 0xFF, 0xFC, 0x00, 0x0F, 0x22, 0x28  /* 7 : 1024xgra. mode */
+};
+
+static unsigned char PALMYFilter2[] = {
+       0xFF, 0x03, 0x02, 0xF6, 0xFC, 0x27, 0x46, /* 0 : 320x text mode */
+       0x01, 0x02, 0xFE, 0xF7, 0x03, 0x27, 0x3C, /* 1 : 360x text mode */
+       0xFF, 0x03, 0x02, 0xF6, 0xFC, 0x27, 0x46, /* 2 : 640x text mode */
+       0x01, 0x02, 0xFE, 0xF7, 0x03, 0x27, 0x3C, /* 3 : 720x text mode */
+       0xFF, 0x03, 0x02, 0xF6, 0xFC, 0x27, 0x46, /* 4 : 320x gra. mode */
+       0xFF, 0x03, 0x02, 0xF6, 0xFC, 0x27, 0x46, /* 5 : 640x gra. mode */
+       0x01, 0x01, 0xFC, 0xF8, 0x08, 0x26, 0x38, /* 6 : 800x gra. mode */
+       0xFF, 0xFF, 0xFC, 0x00, 0x0F, 0x22, 0x28  /* 7 : 1024xgra. mode */
+};
+
+static unsigned char PALNYFilter2[] = {
+       0xFF, 0x03, 0x02, 0xF6, 0xFC, 0x27, 0x46, /* 0 : 320x text mode */
+       0x01, 0x02, 0xFE, 0xF7, 0x03, 0x27, 0x3C, /* 1 : 360x text mode */
+       0xFF, 0x03, 0x02, 0xF6, 0xFC, 0x27, 0x46, /* 2 : 640x text mode */
+       0x01, 0x02, 0xFE, 0xF7, 0x03, 0x27, 0x3C, /* 3 : 720x text mode */
+       0xFF, 0x03, 0x02, 0xF6, 0xFC, 0x27, 0x46, /* 4 : 320x gra. mode */
+       0xFF, 0x03, 0x02, 0xF6, 0xFC, 0x27, 0x46, /* 5 : 640x gra. mode */
+       0x01, 0x01, 0xFC, 0xF8, 0x08, 0x26, 0x38, /* 6 : 800x gra. mode */
+       0xFF, 0xFF, 0xFC, 0x00, 0x0F, 0x22, 0x28  /* 7 : 1024xgra. mode */
+};
+
+static unsigned char XGI_NTSC1024AdjTime[] = {
+       0xa7, 0x07, 0xf2, 0x6e, 0x17, 0x8b, 0x73, 0x53,
+       0x13, 0x40, 0x34, 0xF4, 0x63, 0xBB, 0xCC, 0x7A,
+       0x58, 0xe4, 0x73, 0xd0, 0x13
+};
+
+static struct XGI301C_Tap4TimingStruct HiTVTap4Timing[] = {
+       {0, {
+       0x00, 0x20, 0x00, 0x00, 0x7F, 0x20, 0x02, 0x7F, /* ; C0-C7 */
+       0x7D, 0x20, 0x04, 0x7F, 0x7D, 0x1F, 0x06, 0x7E, /* ; C8-CF */
+       0x7C, 0x1D, 0x09, 0x7E, 0x7C, 0x1B, 0x0B, 0x7E, /* ; D0-D7 */
+       0x7C, 0x19, 0x0E, 0x7D, 0x7C, 0x17, 0x11, 0x7C, /* ; D8-DF */
+       0x7C, 0x14, 0x14, 0x7C, 0x7C, 0x11, 0x17, 0x7C, /* ; E0-E7 */
+       0x7D, 0x0E, 0x19, 0x7C, 0x7E, 0x0B, 0x1B, 0x7C, /* ; EA-EF */
+       0x7E, 0x09, 0x1D, 0x7C, 0x7F, 0x06, 0x1F, 0x7C, /* ; F0-F7 */
+       0x7F, 0x04, 0x20, 0x7D, 0x00, 0x02, 0x20, 0x7E  /* ; F8-FF */
        }
        }
 };
 
-static struct XGI301C_Tap4TimingStruct EnlargeTap4Timing[] =
-{
-       {0,{
-       0x00,0x20,0x00,0x00,0x7F,0x20,0x02,0x7F, /* ; C0-C7 */
-       0x7D,0x20,0x04,0x7F,0x7D,0x1F,0x06,0x7E, /* ; C8-CF */
-       0x7C,0x1D,0x09,0x7E,0x7C,0x1B,0x0B,0x7E, /* ; D0-D7 */
-       0x7C,0x19,0x0E,0x7D,0x7C,0x17,0x11,0x7C, /* ; D8-DF */
-       0x7C,0x14,0x14,0x7C,0x7C,0x11,0x17,0x7C, /* ; E0-E7 */
-       0x7D,0x0E,0x19,0x7C,0x7E,0x0B,0x1B,0x7C, /* ; EA-EF */
-       0x7E,0x09,0x1D,0x7C,0x7F,0x06,0x1F,0x7C, /* ; F0-F7 */
-       0x7F,0x04,0x20,0x7D,0x00,0x02,0x20,0x7E   /* ; F8-FF */
+static struct XGI301C_Tap4TimingStruct EnlargeTap4Timing[] = {
+       {0, {
+       0x00, 0x20, 0x00, 0x00, 0x7F, 0x20, 0x02, 0x7F, /* ; C0-C7 */
+       0x7D, 0x20, 0x04, 0x7F, 0x7D, 0x1F, 0x06, 0x7E, /* ; C8-CF */
+       0x7C, 0x1D, 0x09, 0x7E, 0x7C, 0x1B, 0x0B, 0x7E, /* ; D0-D7 */
+       0x7C, 0x19, 0x0E, 0x7D, 0x7C, 0x17, 0x11, 0x7C, /* ; D8-DF */
+       0x7C, 0x14, 0x14, 0x7C, 0x7C, 0x11, 0x17, 0x7C, /* ; E0-E7 */
+       0x7D, 0x0E, 0x19, 0x7C, 0x7E, 0x0B, 0x1B, 0x7C, /* ; EA-EF */
+       0x7E, 0x09, 0x1D, 0x7C, 0x7F, 0x06, 0x1F, 0x7C, /* ; F0-F7 */
+       0x7F, 0x04, 0x20, 0x7D, 0x00, 0x02, 0x20, 0x7E   /* ; F8-FF */
        }
        }
 };
 
-static struct XGI301C_Tap4TimingStruct NoScaleTap4Timing[] =
-{
-       {0,{
-       0x00,0x20,0x00,0x00,0x7F,0x20,0x02,0x7F, /* ; C0-C7 */
-       0x7D,0x20,0x04,0x7F,0x7D,0x1F,0x06,0x7E, /* ; C8-CF */
-       0x7C,0x1D,0x09,0x7E,0x7C,0x1B,0x0B,0x7E, /* ; D0-D7 */
-       0x7C,0x19,0x0E,0x7D,0x7C,0x17,0x11,0x7C, /* ; D8-DF */
-       0x7C,0x14,0x14,0x7C,0x7C,0x11,0x17,0x7C, /* ; E0-E7 */
-       0x7D,0x0E,0x19,0x7C,0x7E,0x0B,0x1B,0x7C, /* ; EA-EF */
-       0x7E,0x09,0x1D,0x7C,0x7F,0x06,0x1F,0x7C, /* ; F0-F7 */
-       0x7F,0x04,0x20,0x7D,0x00,0x02,0x20,0x7E  /* ; F8-FF */
+static struct XGI301C_Tap4TimingStruct NoScaleTap4Timing[] = {
+       {0, {
+       0x00, 0x20, 0x00, 0x00, 0x7F, 0x20, 0x02, 0x7F, /* ; C0-C7 */
+       0x7D, 0x20, 0x04, 0x7F, 0x7D, 0x1F, 0x06, 0x7E, /* ; C8-CF */
+       0x7C, 0x1D, 0x09, 0x7E, 0x7C, 0x1B, 0x0B, 0x7E, /* ; D0-D7 */
+       0x7C, 0x19, 0x0E, 0x7D, 0x7C, 0x17, 0x11, 0x7C, /* ; D8-DF */
+       0x7C, 0x14, 0x14, 0x7C, 0x7C, 0x11, 0x17, 0x7C, /* ; E0-E7 */
+       0x7D, 0x0E, 0x19, 0x7C, 0x7E, 0x0B, 0x1B, 0x7C, /* ; EA-EF */
+       0x7E, 0x09, 0x1D, 0x7C, 0x7F, 0x06, 0x1F, 0x7C, /* ; F0-F7 */
+       0x7F, 0x04, 0x20, 0x7D, 0x00, 0x02, 0x20, 0x7E  /* ; F8-FF */
+       }
        }
+};
+
+static struct XGI301C_Tap4TimingStruct PALTap4Timing[] = {
+       {600,   {
+               0x05, 0x19, 0x05, 0x7D, 0x03, 0x19, 0x06, 0x7E, /* ; C0-C7 */
+               0x02, 0x19, 0x08, 0x7D, 0x01, 0x18, 0x0A, 0x7D, /* ; C8-CF */
+               0x00, 0x18, 0x0C, 0x7C, 0x7F, 0x17, 0x0E, 0x7C, /* ; D0-D7 */
+               0x7E, 0x16, 0x0F, 0x7D, 0x7E, 0x14, 0x11, 0x7D, /* ; D8-DF */
+               0x7D, 0x13, 0x13, 0x7D, 0x7D, 0x11, 0x14, 0x7E, /* ; E0-E7 */
+               0x7D, 0x0F, 0x16, 0x7E, 0x7D, 0x0E, 0x17, 0x7E, /* ; EA-EF */
+               0x7D, 0x0C, 0x18, 0x7F, 0x7D, 0x0A, 0x18, 0x01, /* ; F0-F7 */
+               0x7D, 0x08, 0x19, 0x02, 0x7D, 0x06, 0x19, 0x04  /* ; F8-FF */
+               }
+       },
+       {768,   {
+               0x08, 0x12, 0x08, 0x7E, 0x07, 0x12, 0x09, 0x7E, /* ; C0-C7 */
+               0x06, 0x12, 0x0A, 0x7E, 0x05, 0x11, 0x0B, 0x7F, /* ; C8-CF */
+               0x04, 0x11, 0x0C, 0x7F, 0x03, 0x11, 0x0C, 0x00, /* ; D0-D7 */
+               0x03, 0x10, 0x0D, 0x00, 0x02, 0x0F, 0x0E, 0x01, /* ; D8-DF */
+               0x01, 0x0F, 0x0F, 0x01, 0x01, 0x0E, 0x0F, 0x02, /* ; E0-E7 */
+               0x00, 0x0D, 0x10, 0x03, 0x7F, 0x0C, 0x11, 0x04, /* ; EA-EF */
+               0x7F, 0x0C, 0x11, 0x04, 0x7F, 0x0B, 0x11, 0x05, /* ; F0-F7 */
+               0x7E, 0x0A, 0x12, 0x06, 0x7E, 0x09, 0x12, 0x07  /* ; F8-FF */
+               }
+       },
+       {0xFFFF, {
+                0x04, 0x1A, 0x04, 0x7E, 0x02, 0x1B, 0x05, 0x7E, /* ; C0-C7 */
+                0x01, 0x1A, 0x07, 0x7E, 0x00, 0x1A, 0x09, 0x7D, /* ; C8-CF */
+                0x7F, 0x19, 0x0B, 0x7D, 0x7E, 0x18, 0x0D, 0x7D, /* ; D0-D7 */
+                0x7D, 0x17, 0x10, 0x7C, 0x7D, 0x15, 0x12, 0x7C, /* ; D8-DF */
+                0x7C, 0x14, 0x14, 0x7C, 0x7C, 0x12, 0x15, 0x7D, /* ; E0-E7 */
+                0x7C, 0x10, 0x17, 0x7D, 0x7C, 0x0D, 0x18, 0x7F, /* ; EA-EF */
+                0x7D, 0x0B, 0x19, 0x7F, 0x7D, 0x09, 0x1A, 0x00, /* ; F0-F7 */
+                0x7D, 0x07, 0x1A, 0x02, 0x7E, 0x05, 0x1B, 0x02  /* ; F8-FF */
+                }
        }
 };
 
-static struct XGI301C_Tap4TimingStruct PALTap4Timing[] =
-{
-       {600,  {
-                0x05,0x19,0x05,0x7D,0x03,0x19,0x06,0x7E, /* ; C0-C7 */
-                0x02,0x19,0x08,0x7D,0x01,0x18,0x0A,0x7D, /* ; C8-CF */
-                0x00,0x18,0x0C,0x7C,0x7F,0x17,0x0E,0x7C, /* ; D0-D7 */
-                0x7E,0x16,0x0F,0x7D,0x7E,0x14,0x11,0x7D, /* ; D8-DF */
-                0x7D,0x13,0x13,0x7D,0x7D,0x11,0x14,0x7E, /* ; E0-E7 */
-                0x7D,0x0F,0x16,0x7E,0x7D,0x0E,0x17,0x7E, /* ; EA-EF */
-                0x7D,0x0C,0x18,0x7F,0x7D,0x0A,0x18,0x01, /* ; F0-F7 */
-                0x7D,0x08,0x19,0x02,0x7D,0x06,0x19,0x04  /* ; F8-FF */
-                }
-       },
-        {768,  {
-                0x08,0x12,0x08,0x7E,0x07,0x12,0x09,0x7E, /* ; C0-C7 */
-                0x06,0x12,0x0A,0x7E,0x05,0x11,0x0B,0x7F, /* ; C8-CF */
-                0x04,0x11,0x0C,0x7F,0x03,0x11,0x0C,0x00, /* ; D0-D7 */
-                0x03,0x10,0x0D,0x00,0x02,0x0F,0x0E,0x01, /* ; D8-DF */
-                0x01,0x0F,0x0F,0x01,0x01,0x0E,0x0F,0x02, /* ; E0-E7 */
-                0x00,0x0D,0x10,0x03,0x7F,0x0C,0x11,0x04, /* ; EA-EF */
-                0x7F,0x0C,0x11,0x04,0x7F,0x0B,0x11,0x05, /* ; F0-F7 */
-                0x7E,0x0A,0x12,0x06,0x7E,0x09,0x12,0x07  /* ; F8-FF */
-                }
-        },
-        {0xFFFF,
-               {
-                0x04,0x1A,0x04,0x7E,0x02,0x1B,0x05,0x7E, /* ; C0-C7 */
-                0x01,0x1A,0x07,0x7E,0x00,0x1A,0x09,0x7D, /* ; C8-CF */
-                0x7F,0x19,0x0B,0x7D,0x7E,0x18,0x0D,0x7D, /* ; D0-D7 */
-                0x7D,0x17,0x10,0x7C,0x7D,0x15,0x12,0x7C, /* ; D8-DF */
-                0x7C,0x14,0x14,0x7C,0x7C,0x12,0x15,0x7D, /* ; E0-E7 */
-                0x7C,0x10,0x17,0x7D,0x7C,0x0D,0x18,0x7F, /* ; EA-EF */
-                0x7D,0x0B,0x19,0x7F,0x7D,0x09,0x1A,0x00, /* ; F0-F7 */
-                0x7D,0x07,0x1A,0x02,0x7E,0x05,0x1B,0x02  /* ; F8-FF */
-                }
-        }
-};
-
-static struct XGI301C_Tap4TimingStruct NTSCTap4Timing[] =
-{
+static struct XGI301C_Tap4TimingStruct NTSCTap4Timing[] = {
        {480,   {
-               0x04,0x1A,0x04,0x7E,0x03,0x1A,0x06,0x7D, /* ; C0-C7 */
-               0x01,0x1A,0x08,0x7D,0x00,0x19,0x0A,0x7D, /* ; C8-CF */
-               0x7F,0x19,0x0C,0x7C,0x7E,0x18,0x0E,0x7C, /* ; D0-D7 */
-               0x7E,0x17,0x10,0x7B,0x7D,0x15,0x12,0x7C, /* ; D8-DF */
-               0x7D,0x13,0x13,0x7D,0x7C,0x12,0x15,0x7D, /* ; E0-E7 */
-               0x7C,0x10,0x17,0x7D,0x7C,0x0E,0x18,0x7E, /* ; EA-EF */
-               0x7D,0x0C,0x19,0x7E,0x7D,0x0A,0x19,0x00, /* ; F0-F7 */
-               0x7D,0x08,0x1A,0x01,0x7E,0x06,0x1A,0x02  /* ; F8-FF */
-               }
-        },
-        {600,  {
-               0x07,0x14,0x07,0x7E,0x06,0x14,0x09,0x7D, /* ; C0-C7 */
-               0x05,0x14,0x0A,0x7D,0x04,0x13,0x0B,0x7E, /* ; C8-CF */
-               0x03,0x13,0x0C,0x7E,0x02,0x12,0x0D,0x7F, /* ; D0-D7 */
-               0x01,0x12,0x0E,0x7F,0x01,0x11,0x0F,0x7F, /* ; D8-DF */
-               0x01,0x10,0x10,0x00,0x7F,0x0F,0x11,0x01, /* ; E0-E7 */
-               0x7F,0x0E,0x12,0x01,0x7E,0x0D,0x12,0x03, /* ; EA-EF */
-               0x7E,0x0C,0x13,0x03,0x7E,0x0B,0x13,0x04, /* ; F0-F7 */
-               0x7E,0x0A,0x14,0x04,0x7D,0x09,0x14,0x06  /* ; F8-FF */
-               }
-        },
-        {0xFFFF,
-               {
-               0x09,0x0F,0x09,0x7F,0x08,0x0F,0x09,0x00, /* ; C0-C7 */
-               0x07,0x0F,0x0A,0x00,0x06,0x0F,0x0A,0x01, /* ; C8-CF */
-               0x06,0x0E,0x0B,0x01,0x05,0x0E,0x0B,0x02, /* ; D0-D7 */
-               0x04,0x0E,0x0C,0x02,0x04,0x0D,0x0C,0x03, /* ; D8-DF */
-               0x03,0x0D,0x0D,0x03,0x02,0x0C,0x0D,0x05, /* ; E0-E7 */
-               0x02,0x0C,0x0E,0x04,0x01,0x0B,0x0E,0x06, /* ; EA-EF */
-               0x01,0x0B,0x0E,0x06,0x00,0x0A,0x0F,0x07, /* ; F0-F7 */
-               0x00,0x0A,0x0F,0x07,0x00,0x09,0x0F,0x08  /* ; F8-FF */
-               }
-        }
-};
-
-static struct XGI301C_Tap4TimingStruct YPbPr525pTap4Timing[] =
-{
+               0x04, 0x1A, 0x04, 0x7E, 0x03, 0x1A, 0x06, 0x7D, /* ; C0-C7 */
+               0x01, 0x1A, 0x08, 0x7D, 0x00, 0x19, 0x0A, 0x7D, /* ; C8-CF */
+               0x7F, 0x19, 0x0C, 0x7C, 0x7E, 0x18, 0x0E, 0x7C, /* ; D0-D7 */
+               0x7E, 0x17, 0x10, 0x7B, 0x7D, 0x15, 0x12, 0x7C, /* ; D8-DF */
+               0x7D, 0x13, 0x13, 0x7D, 0x7C, 0x12, 0x15, 0x7D, /* ; E0-E7 */
+               0x7C, 0x10, 0x17, 0x7D, 0x7C, 0x0E, 0x18, 0x7E, /* ; EA-EF */
+               0x7D, 0x0C, 0x19, 0x7E, 0x7D, 0x0A, 0x19, 0x00, /* ; F0-F7 */
+               0x7D, 0x08, 0x1A, 0x01, 0x7E, 0x06, 0x1A, 0x02  /* ; F8-FF */
+               }
+       },
+       {600,   {
+               0x07, 0x14, 0x07, 0x7E, 0x06, 0x14, 0x09, 0x7D, /* ; C0-C7 */
+               0x05, 0x14, 0x0A, 0x7D, 0x04, 0x13, 0x0B, 0x7E, /* ; C8-CF */
+               0x03, 0x13, 0x0C, 0x7E, 0x02, 0x12, 0x0D, 0x7F, /* ; D0-D7 */
+               0x01, 0x12, 0x0E, 0x7F, 0x01, 0x11, 0x0F, 0x7F, /* ; D8-DF */
+               0x01, 0x10, 0x10, 0x00, 0x7F, 0x0F, 0x11, 0x01, /* ; E0-E7 */
+               0x7F, 0x0E, 0x12, 0x01, 0x7E, 0x0D, 0x12, 0x03, /* ; EA-EF */
+               0x7E, 0x0C, 0x13, 0x03, 0x7E, 0x0B, 0x13, 0x04, /* ; F0-F7 */
+               0x7E, 0x0A, 0x14, 0x04, 0x7D, 0x09, 0x14, 0x06  /* ; F8-FF */
+               }
+       },
+       {0xFFFF, {
+                0x09, 0x0F, 0x09, 0x7F, 0x08, 0x0F, 0x09, 0x00, /* ; C0-C7 */
+                0x07, 0x0F, 0x0A, 0x00, 0x06, 0x0F, 0x0A, 0x01, /* ; C8-CF */
+                0x06, 0x0E, 0x0B, 0x01, 0x05, 0x0E, 0x0B, 0x02, /* ; D0-D7 */
+                0x04, 0x0E, 0x0C, 0x02, 0x04, 0x0D, 0x0C, 0x03, /* ; D8-DF */
+                0x03, 0x0D, 0x0D, 0x03, 0x02, 0x0C, 0x0D, 0x05, /* ; E0-E7 */
+                0x02, 0x0C, 0x0E, 0x04, 0x01, 0x0B, 0x0E, 0x06, /* ; EA-EF */
+                0x01, 0x0B, 0x0E, 0x06, 0x00, 0x0A, 0x0F, 0x07, /* ; F0-F7 */
+                0x00, 0x0A, 0x0F, 0x07, 0x00, 0x09, 0x0F, 0x08  /* ; F8-FF */
+                }
+       }
+};
+
+static struct XGI301C_Tap4TimingStruct YPbPr525pTap4Timing[] = {
        {480,   {
-               0x04,0x1A,0x04,0x7E,0x03,0x1A,0x06,0x7D, /* ; C0-C7 */
-               0x01,0x1A,0x08,0x7D,0x00,0x19,0x0A,0x7D, /* ; C8-CF */
-               0x7F,0x19,0x0C,0x7C,0x7E,0x18,0x0E,0x7C, /* ; D0-D7 */
-               0x7E,0x17,0x10,0x7B,0x7D,0x15,0x12,0x7C, /* ; D8-DF */
-               0x7D,0x13,0x13,0x7D,0x7C,0x12,0x15,0x7D, /* ; E0-E7 */
-               0x7C,0x10,0x17,0x7D,0x7C,0x0E,0x18,0x7E, /* ; EA-EF */
-               0x7D,0x0C,0x19,0x7E,0x7D,0x0A,0x19,0x00, /* ; F0-F7 */
-               0x7D,0x08,0x1A,0x01,0x7E,0x06,0x1A,0x02  /* ; F8-FF */
-               }
-        },
-        {600,  {
-               0x07,0x14,0x07,0x7E,0x06,0x14,0x09,0x7D, /* ; C0-C7 */
-               0x05,0x14,0x0A,0x7D,0x04,0x13,0x0B,0x7E, /* ; C8-CF */
-               0x03,0x13,0x0C,0x7E,0x02,0x12,0x0D,0x7F, /* ; D0-D7 */
-               0x01,0x12,0x0E,0x7F,0x01,0x11,0x0F,0x7F, /* ; D8-DF */
-               0x01,0x10,0x10,0x00,0x7F,0x0F,0x11,0x01, /* ; E0-E7 */
-               0x7F,0x0E,0x12,0x01,0x7E,0x0D,0x12,0x03, /* ; EA-EF */
-               0x7E,0x0C,0x13,0x03,0x7E,0x0B,0x13,0x04, /* ; F0-F7 */
-               0x7E,0x0A,0x14,0x04,0x7D,0x09,0x14,0x06  /* ; F8-FF */
-               }
-        },
-        {0xFFFF,
-               {
-               0x09,0x0F,0x09,0x7F,0x08,0x0F,0x09,0x00, /* ; C0-C7 */
-               0x07,0x0F,0x0A,0x00,0x06,0x0F,0x0A,0x01, /* ; C8-CF */
-               0x06,0x0E,0x0B,0x01,0x05,0x0E,0x0B,0x02, /* ; D0-D7 */
-               0x04,0x0E,0x0C,0x02,0x04,0x0D,0x0C,0x03, /* ; D8-DF */
-               0x03,0x0D,0x0D,0x03,0x02,0x0C,0x0D,0x05, /* ; E0-E7 */
-               0x02,0x0C,0x0E,0x04,0x01,0x0B,0x0E,0x06, /* ; EA-EF */
-               0x01,0x0B,0x0E,0x06,0x00,0x0A,0x0F,0x07, /* ; F0-F7 */
-               0x00,0x0A,0x0F,0x07,0x00,0x09,0x0F,0x08  /* ; F8-FF */
-               }
-        }
-};
-
-static struct XGI301C_Tap4TimingStruct YPbPr525iTap4Timing[] =
-{
+               0x04, 0x1A, 0x04, 0x7E, 0x03, 0x1A, 0x06, 0x7D, /* ; C0-C7 */
+               0x01, 0x1A, 0x08, 0x7D, 0x00, 0x19, 0x0A, 0x7D, /* ; C8-CF */
+               0x7F, 0x19, 0x0C, 0x7C, 0x7E, 0x18, 0x0E, 0x7C, /* ; D0-D7 */
+               0x7E, 0x17, 0x10, 0x7B, 0x7D, 0x15, 0x12, 0x7C, /* ; D8-DF */
+               0x7D, 0x13, 0x13, 0x7D, 0x7C, 0x12, 0x15, 0x7D, /* ; E0-E7 */
+               0x7C, 0x10, 0x17, 0x7D, 0x7C, 0x0E, 0x18, 0x7E, /* ; EA-EF */
+               0x7D, 0x0C, 0x19, 0x7E, 0x7D, 0x0A, 0x19, 0x00, /* ; F0-F7 */
+               0x7D, 0x08, 0x1A, 0x01, 0x7E, 0x06, 0x1A, 0x02  /* ; F8-FF */
+               }
+       },
+       {600,   {
+               0x07, 0x14, 0x07, 0x7E, 0x06, 0x14, 0x09, 0x7D, /* ; C0-C7 */
+               0x05, 0x14, 0x0A, 0x7D, 0x04, 0x13, 0x0B, 0x7E, /* ; C8-CF */
+               0x03, 0x13, 0x0C, 0x7E, 0x02, 0x12, 0x0D, 0x7F, /* ; D0-D7 */
+               0x01, 0x12, 0x0E, 0x7F, 0x01, 0x11, 0x0F, 0x7F, /* ; D8-DF */
+               0x01, 0x10, 0x10, 0x00, 0x7F, 0x0F, 0x11, 0x01, /* ; E0-E7 */
+               0x7F, 0x0E, 0x12, 0x01, 0x7E, 0x0D, 0x12, 0x03, /* ; EA-EF */
+               0x7E, 0x0C, 0x13, 0x03, 0x7E, 0x0B, 0x13, 0x04, /* ; F0-F7 */
+               0x7E, 0x0A, 0x14, 0x04, 0x7D, 0x09, 0x14, 0x06  /* ; F8-FF */
+               }
+       },
+       {0xFFFF, {
+               0x09, 0x0F, 0x09, 0x7F, 0x08, 0x0F, 0x09, 0x00, /* ; C0-C7 */
+               0x07, 0x0F, 0x0A, 0x00, 0x06, 0x0F, 0x0A, 0x01, /* ; C8-CF */
+               0x06, 0x0E, 0x0B, 0x01, 0x05, 0x0E, 0x0B, 0x02, /* ; D0-D7 */
+               0x04, 0x0E, 0x0C, 0x02, 0x04, 0x0D, 0x0C, 0x03, /* ; D8-DF */
+               0x03, 0x0D, 0x0D, 0x03, 0x02, 0x0C, 0x0D, 0x05, /* ; E0-E7 */
+               0x02, 0x0C, 0x0E, 0x04, 0x01, 0x0B, 0x0E, 0x06, /* ; EA-EF */
+               0x01, 0x0B, 0x0E, 0x06, 0x00, 0x0A, 0x0F, 0x07, /* ; F0-F7 */
+               0x00, 0x0A, 0x0F, 0x07, 0x00, 0x09, 0x0F, 0x08  /* ; F8-FF */
+               }
+       }
+};
+
+static struct XGI301C_Tap4TimingStruct YPbPr525iTap4Timing[] = {
        {480,   {
-               0x04,0x1A,0x04,0x7E,0x03,0x1A,0x06,0x7D, /* ; C0-C7 */
-               0x01,0x1A,0x08,0x7D,0x00,0x19,0x0A,0x7D, /* ; C8-CF */
-               0x7F,0x19,0x0C,0x7C,0x7E,0x18,0x0E,0x7C, /* ; D0-D7 */
-               0x7E,0x17,0x10,0x7B,0x7D,0x15,0x12,0x7C, /* ; D8-DF */
-               0x7D,0x13,0x13,0x7D,0x7C,0x12,0x15,0x7D, /* ; E0-E7 */
-               0x7C,0x10,0x17,0x7D,0x7C,0x0E,0x18,0x7E, /* ; EA-EF */
-               0x7D,0x0C,0x19,0x7E,0x7D,0x0A,0x19,0x00, /* ; F0-F7 */
-               0x7D,0x08,0x1A,0x01,0x7E,0x06,0x1A,0x02  /* ; F8-FF */
-               }
-        },
-        {600,  {
-               0x07,0x14,0x07,0x7E,0x06,0x14,0x09,0x7D, /* ; C0-C7 */
-               0x05,0x14,0x0A,0x7D,0x04,0x13,0x0B,0x7E, /* ; C8-CF */
-               0x03,0x13,0x0C,0x7E,0x02,0x12,0x0D,0x7F, /* ; D0-D7 */
-               0x01,0x12,0x0E,0x7F,0x01,0x11,0x0F,0x7F, /* ; D8-DF */
-               0x01,0x10,0x10,0x00,0x7F,0x0F,0x11,0x01, /* ; E0-E7 */
-               0x7F,0x0E,0x12,0x01,0x7E,0x0D,0x12,0x03, /* ; EA-EF */
-               0x7E,0x0C,0x13,0x03,0x7E,0x0B,0x13,0x04, /* ; F0-F7 */
-               0x7E,0x0A,0x14,0x04,0x7D,0x09,0x14,0x06  /* ; F8-FF */
-               }
-        },
-        {0xFFFF,
-               {
-               0x09,0x0F,0x09,0x7F,0x08,0x0F,0x09,0x00, /* ; C0-C7 */
-               0x07,0x0F,0x0A,0x00,0x06,0x0F,0x0A,0x01, /* ; C8-CF */
-               0x06,0x0E,0x0B,0x01,0x05,0x0E,0x0B,0x02, /* ; D0-D7 */
-               0x04,0x0E,0x0C,0x02,0x04,0x0D,0x0C,0x03, /* ; D8-DF */
-               0x03,0x0D,0x0D,0x03,0x02,0x0C,0x0D,0x05, /* ; E0-E7 */
-               0x02,0x0C,0x0E,0x04,0x01,0x0B,0x0E,0x06, /* ; EA-EF */
-               0x01,0x0B,0x0E,0x06,0x00,0x0A,0x0F,0x07, /* ; F0-F7 */
-               0x00,0x0A,0x0F,0x07,0x00,0x09,0x0F,0x08  /* ; F8-FF */
-               }
-        }
-};
-
-static struct XGI301C_Tap4TimingStruct YPbPr750pTap4Timing[] =
-{        {0xFFFF,
-               {
-               0x05,0x19,0x05,0x7D,0x03,0x19,0x06,0x7E, /* ; C0-C7 */
-               0x02,0x19,0x08,0x7D,0x01,0x18,0x0A,0x7D, /* ; C8-CF */
-               0x00,0x18,0x0C,0x7C,0x7F,0x17,0x0E,0x7C, /* ; D0-D7 */
-               0x7E,0x16,0x0F,0x7D,0x7E,0x14,0x11,0x7D, /* ; D8-DF */
-               0x7D,0x13,0x13,0x7D,0x7D,0x11,0x14,0x7E, /* ; E0-E7 */
-               0x7D,0x0F,0x16,0x7E,0x7D,0x0E,0x17,0x7E, /* ; EA-EF */
-               0x7D,0x0C,0x18,0x7F,0x7D,0x0A,0x18,0x01, /* ; F0-F7 */
-               0x7D,0x08,0x19,0x02,0x7D,0x06,0x19,0x04 /* F8-FF */
-               }
-        }
+               0x04, 0x1A, 0x04, 0x7E, 0x03, 0x1A, 0x06, 0x7D, /* ; C0-C7 */
+               0x01, 0x1A, 0x08, 0x7D, 0x00, 0x19, 0x0A, 0x7D, /* ; C8-CF */
+               0x7F, 0x19, 0x0C, 0x7C, 0x7E, 0x18, 0x0E, 0x7C, /* ; D0-D7 */
+               0x7E, 0x17, 0x10, 0x7B, 0x7D, 0x15, 0x12, 0x7C, /* ; D8-DF */
+               0x7D, 0x13, 0x13, 0x7D, 0x7C, 0x12, 0x15, 0x7D, /* ; E0-E7 */
+               0x7C, 0x10, 0x17, 0x7D, 0x7C, 0x0E, 0x18, 0x7E, /* ; EA-EF */
+               0x7D, 0x0C, 0x19, 0x7E, 0x7D, 0x0A, 0x19, 0x00, /* ; F0-F7 */
+               0x7D, 0x08, 0x1A, 0x01, 0x7E, 0x06, 0x1A, 0x02  /* ; F8-FF */
+               }
+       },
+       {600,   {
+               0x07, 0x14, 0x07, 0x7E, 0x06, 0x14, 0x09, 0x7D, /* ; C0-C7 */
+               0x05, 0x14, 0x0A, 0x7D, 0x04, 0x13, 0x0B, 0x7E, /* ; C8-CF */
+               0x03, 0x13, 0x0C, 0x7E, 0x02, 0x12, 0x0D, 0x7F, /* ; D0-D7 */
+               0x01, 0x12, 0x0E, 0x7F, 0x01, 0x11, 0x0F, 0x7F, /* ; D8-DF */
+               0x01, 0x10, 0x10, 0x00, 0x7F, 0x0F, 0x11, 0x01, /* ; E0-E7 */
+               0x7F, 0x0E, 0x12, 0x01, 0x7E, 0x0D, 0x12, 0x03, /* ; EA-EF */
+               0x7E, 0x0C, 0x13, 0x03, 0x7E, 0x0B, 0x13, 0x04, /* ; F0-F7 */
+               0x7E, 0x0A, 0x14, 0x04, 0x7D, 0x09, 0x14, 0x06  /* ; F8-FF */
+               }
+       },
+       {0xFFFF, {
+               0x09, 0x0F, 0x09, 0x7F, 0x08, 0x0F, 0x09, 0x00, /* ; C0-C7 */
+               0x07, 0x0F, 0x0A, 0x00, 0x06, 0x0F, 0x0A, 0x01, /* ; C8-CF */
+               0x06, 0x0E, 0x0B, 0x01, 0x05, 0x0E, 0x0B, 0x02, /* ; D0-D7 */
+               0x04, 0x0E, 0x0C, 0x02, 0x04, 0x0D, 0x0C, 0x03, /* ; D8-DF */
+               0x03, 0x0D, 0x0D, 0x03, 0x02, 0x0C, 0x0D, 0x05, /* ; E0-E7 */
+               0x02, 0x0C, 0x0E, 0x04, 0x01, 0x0B, 0x0E, 0x06, /* ; EA-EF */
+               0x01, 0x0B, 0x0E, 0x06, 0x00, 0x0A, 0x0F, 0x07, /* ; F0-F7 */
+               0x00, 0x0A, 0x0F, 0x07, 0x00, 0x09, 0x0F, 0x08  /* ; F8-FF */
+               }
+       }
+};
+
+static struct XGI301C_Tap4TimingStruct YPbPr750pTap4Timing[] = {
+       {0xFFFF, {
+                0x05, 0x19, 0x05, 0x7D, 0x03, 0x19, 0x06, 0x7E, /* ; C0-C7 */
+                0x02, 0x19, 0x08, 0x7D, 0x01, 0x18, 0x0A, 0x7D, /* ; C8-CF */
+                0x00, 0x18, 0x0C, 0x7C, 0x7F, 0x17, 0x0E, 0x7C, /* ; D0-D7 */
+                0x7E, 0x16, 0x0F, 0x7D, 0x7E, 0x14, 0x11, 0x7D, /* ; D8-DF */
+                0x7D, 0x13, 0x13, 0x7D, 0x7D, 0x11, 0x14, 0x7E, /* ; E0-E7 */
+                0x7D, 0x0F, 0x16, 0x7E, 0x7D, 0x0E, 0x17, 0x7E, /* ; EA-EF */
+                0x7D, 0x0C, 0x18, 0x7F, 0x7D, 0x0A, 0x18, 0x01, /* ; F0-F7 */
+                0x7D, 0x08, 0x19, 0x02, 0x7D, 0x06, 0x19, 0x04 /* F8-FF */
+                }
+       }
 };
index a97e44f98c080ba6da217b6dfcf1cf977d446cd1..ea2b795bfa5091404a38075d0c93fb65ef671a93 100644 (file)
@@ -3,7 +3,7 @@
 #include "vb_struct.h"
 
 #include "XGIfb.h"
-#include <asm/io.h>
+#include <linux/io.h>
 #include <linux/types.h>
 
 #include "vb_util.h"
index d613e84aab620e3c3b9ffce884dbb1f450332e4c..5aeb3a4d66fb744a262a642bc24c6ba2491a82ff 100644 (file)
@@ -1,4 +1,3 @@
-
 #ifndef _VGATYPES_
 #define _VGATYPES_
 
@@ -6,79 +5,79 @@
 
 #ifndef XGI_VB_CHIP_TYPE
 enum XGI_VB_CHIP_TYPE {
-    VB_CHIP_Legacy = 0,
-    VB_CHIP_301,
-    VB_CHIP_301B,
-    VB_CHIP_301LV,
-    VB_CHIP_302,
-    VB_CHIP_302B,
-    VB_CHIP_302LV,
-    VB_CHIP_301C,
-    VB_CHIP_302ELV,
-    VB_CHIP_UNKNOWN, /* other video bridge or no video bridge */
-    MAX_VB_CHIP
+       VB_CHIP_Legacy = 0,
+       VB_CHIP_301,
+       VB_CHIP_301B,
+       VB_CHIP_301LV,
+       VB_CHIP_302,
+       VB_CHIP_302B,
+       VB_CHIP_302LV,
+       VB_CHIP_301C,
+       VB_CHIP_302ELV,
+       VB_CHIP_UNKNOWN, /* other video bridge or no video bridge */
+       MAX_VB_CHIP
 };
 #endif
 
 #ifndef XGI_LCD_TYPE
 enum XGI_LCD_TYPE {
-    LCD_INVALID = 0,
-    LCD_320x480,       /* FSTN, DSTN */
-    LCD_640x480,
-    LCD_640x480_2,     /* FSTN, DSTN */
-    LCD_640x480_3,     /* FSTN, DSTN */
-    LCD_800x600,
-    LCD_848x480,
-    LCD_1024x600,
-    LCD_1024x768,
-    LCD_1152x768,
-    LCD_1152x864,
-    LCD_1280x720,
-    LCD_1280x768,
-    LCD_1280x800,
-    LCD_1280x960,
-    LCD_1280x1024,
-    LCD_1400x1050,
-    LCD_1600x1200,
-    LCD_1680x1050,
-    LCD_1920x1440,
-    LCD_2048x1536,
-    LCD_CUSTOM,
-    LCD_UNKNOWN
+       LCD_INVALID = 0,
+       LCD_320x480,       /* FSTN, DSTN */
+       LCD_640x480,
+       LCD_640x480_2,     /* FSTN, DSTN */
+       LCD_640x480_3,     /* FSTN, DSTN */
+       LCD_800x600,
+       LCD_848x480,
+       LCD_1024x600,
+       LCD_1024x768,
+       LCD_1152x768,
+       LCD_1152x864,
+       LCD_1280x720,
+       LCD_1280x768,
+       LCD_1280x800,
+       LCD_1280x960,
+       LCD_1280x1024,
+       LCD_1400x1050,
+       LCD_1600x1200,
+       LCD_1680x1050,
+       LCD_1920x1440,
+       LCD_2048x1536,
+       LCD_CUSTOM,
+       LCD_UNKNOWN
 };
 #endif
 
-struct XGI_DSReg
-{
-  unsigned char  jIdx;
-  unsigned char  jVal;
+struct XGI_DSReg {
+       unsigned char jIdx;
+       unsigned char jVal;
 };
 
-struct xgi_hw_device_info
-{
-    unsigned long  ulExternalChip;       /* NO VB or other video bridge*/
-                                 /* if ujVBChipID = VB_CHIP_UNKNOWN, */
+struct xgi_hw_device_info {
+       unsigned long ulExternalChip; /* NO VB or other video bridge*/
+                                     /* if ujVBChipID = VB_CHIP_UNKNOWN, */
 
-    unsigned char *pjVirtualRomBase;    /* ROM image */
+       unsigned char *pjVirtualRomBase; /* ROM image */
 
-    unsigned char *pjVideoMemoryAddress;/* base virtual memory address */
-                                 /* of Linear VGA memory */
+       unsigned char *pjVideoMemoryAddress;/* base virtual memory address */
+                                           /* of Linear VGA memory */
 
-    unsigned long  ulVideoMemorySize;    /* size, in bytes, of the memory on the board */
+       unsigned long ulVideoMemorySize; /* size, in bytes, of the
+                                           memory on the board */
 
-    unsigned char *pjIOAddress;          /* base I/O address of VGA ports (0x3B0) */
+       unsigned char *pjIOAddress; /* base I/O address of VGA ports (0x3B0) */
 
-    unsigned char  jChipType;            /* Used to Identify Graphics Chip */
-                                 /* defined in the data structure type  */
-                                 /* "XGI_CHIP_TYPE" */
+       unsigned char jChipType; /* Used to Identify Graphics Chip */
+                                /* defined in the data structure type  */
+                                /* "XGI_CHIP_TYPE" */
 
-    unsigned char  jChipRevision;        /* Used to Identify Graphics Chip Revision */
+       unsigned char jChipRevision; /* Used to Identify Graphics
+                                       Chip Revision */
 
-    unsigned char  ujVBChipID;           /* the ID of video bridge */
-                                 /* defined in the data structure type */
-                                 /* "XGI_VB_CHIP_TYPE" */
+       unsigned char ujVBChipID; /* the ID of video bridge */
+                                 /* defined in the data structure type */
+                                 /* "XGI_VB_CHIP_TYPE" */
 
-    unsigned long  ulCRT2LCDType;        /* defined in the data structure type */
+       unsigned long ulCRT2LCDType; /* defined in the data structure type */
 
        unsigned char(*pQueryVGAConfigSpace)(struct xgi_hw_device_info *,
                                            unsigned long, unsigned long,
@@ -87,7 +86,5 @@ struct xgi_hw_device_info
 
 /* Additional IOCTL for communication xgifb <> X driver        */
 /* If changing this, xgifb.h must also be changed (for xgifb) */
-
-
 #endif
 
index 22879725678dfcd53324698504500dc97decdea6..795bdc7f5c3f270301abcb56e2f787550f36c6b9 100644 (file)
@@ -2812,7 +2812,7 @@ static struct module *load_module(void __user *umod,
        }
 
        /* This has to be done once we're sure module name is unique. */
-       if (!mod->taints)
+       if (!mod->taints || mod->taints == (1U<<TAINT_CRAP))
                dynamic_debug_setup(info.debug, info.num_debug);
 
        /* Find duplicate symbols */
@@ -2849,7 +2849,7 @@ static struct module *load_module(void __user *umod,
        module_bug_cleanup(mod);
 
  ddebug:
-       if (!mod->taints)
+       if (!mod->taints || mod->taints == (1U<<TAINT_CRAP))
                dynamic_debug_remove(info.debug);
  unlock:
        mutex_unlock(&module_mutex);